diff --git "a/data/train/python-002.jsonl" "b/data/train/python-002.jsonl" --- "a/data/train/python-002.jsonl" +++ "b/data/train/python-002.jsonl" @@ -1,586 +1,622 @@ -{"question_id": 1302, "task_id": "deepest-leaves-sum", "difficulty": "Medium", "problem_description": "Given the root of a binary tree, return the sum of values of its deepest leaves.\n \nExample 1:\n\n\nInput: root = [1,2,3,4,5,null,6,7,null,null,null,null,8]\nOutput: 15\n\nExample 2:\n\nInput: root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5]\nOutput: 19\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 104].\n1 <= Node.val <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([1, 2, 3])) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 92\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5])) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, 7, None, None, None, None, 8])) == 15\n assert candidate(root = tree_node([6, 7, 8, 2, 7, 1, 3, 9, None, 1, 4, None, None, None, 5])) == 19\n assert candidate(root = tree_node([1])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, None, None, None, 6])) == 9\n assert candidate(root = tree_node([3, 9, 20, None, None, 15, 7, 1, None, None, 2, None, None, 3, None, None, 4])) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 8, 9, 10, 11, 12, 13, 14, 15])) == 29\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 10\n assert candidate(root = tree_node([2, 4, 6, 8, 10, 12, 14, None, None, None, None, None, None, 16, 18, None, None, None, None, None, None, 20, 22, 24, None, None, None, None, 26, 28, 30])) == 34\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, None, None, 31])) == 31\n assert candidate(root = tree_node([1, 2, 3, None, 4, 5, None, 6, 7, None, 8, 9, None, 10, 11, None, 12, 13, None, 14, 15, None, 16, 17, None, 18, 19, None, 20, 21])) == 78\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, None, None, None, None, None, None, None, None, None, 21])) == 111\n assert candidate(root = tree_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])) == 184\n assert candidate(root = tree_node([5, 4, 5, 4, 7, None, None, None, None, 7, 7])) == 14\n assert candidate(root = tree_node([5, 10, None, 15, 20, None, 25, 30, 35, None, None, 40, 45, None, None, None, None, None, None, 50, 55])) == 85\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])) == 15\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, None, 16, None, None, None, None, 17, None, None, None, None, 18, None, None, None, None, 19, None, None, None, None, 20, None, None, None, None, 21, None, None, None, None, 22, None, None, None, None, 23, None, None, None, None, 24, None, None, None, None, 25])) == 33\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, None, None, None, 31, 32, None, None, None, None, 35, 36, 37, 38])) == 209\n assert candidate(root = tree_node([1, 2, None, 4, None, None, None, 8, None, None, None, None, None, None, None, 16])) == 4\n assert candidate(root = tree_node([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4, None, None, None, None, 9, 10])) == 19\n assert candidate(root = tree_node([5, 4, 8, 11, None, 13, 4, 7, 2, None, None, None, 1, None, 3])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, None, None, None, 31, 32])) == 63\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, None, 7, 8, None, None, None, None, None, None, None, 9, 10, None, None, None, None, 11])) == 15\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, None, 16, None, None, None, None, 17, None, None, None, None, 18, None, None, None, None, 19, None, None, None, None, 20, None, None, None, None, 21, None, None, None, None, 22, None, None, None, None, 23, None, None, None, None, 24])) == 33\n assert candidate(root = tree_node([4, 2, 7, 1, 3, 6, 9, None, None, None, None, 5, 8, None, None, 13, 14])) == 27\n assert candidate(root = tree_node([5, 3, 8, 1, 4, None, 10, None, None, None, 9, 7, 11])) == 27\n assert candidate(root = tree_node([3, 9, 20, None, None, 15, 7, 11, None, 12, None, 13, None, 14, None, 15])) == 15\n assert candidate(root = tree_node([31, 15, 47, 7, 23, 39, 55, 3, 11, 19, 27, 35, 43, 51, 59, 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 63])) == 63\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == 72\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, None, None, 9, None, None, 10, None, None, 11, None, None, 12, None, None, 13, None, None, 14, None, None, 15, None, None, 16, None, None, 17, None, None, 18, None, None, 19, None, None, 20, None, None, 21, None, None, 22, None, None, 23, None, None, 24, None, None, 25])) == 15\n assert candidate(root = tree_node([5, 10, 15, 20, 25, 30, 35, None, 40, None, None, None, 45, None, None, 50, 55])) == 105\n assert candidate(root = tree_node([1, 2, 2, 3, 3, None, None, 4, 4, 4, 4, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == 16\n assert candidate(root = tree_node([5, 3, 8, 1, 4, 7, 10, None, None, None, 6, None, 9, None, None, 11, 12])) == 23\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, None, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == 234\n assert candidate(root = tree_node([10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80])) == 500\n assert candidate(root = tree_node([9, 18, 27, 36, 45, 54, 63, 72, 81, 90, None, 99, None, None, None, None, None, None, None, None, None, None, 108, 117, 126, 135, 144, 153, 162, 171, 180])) == 351\n assert candidate(root = tree_node([5, 4, 8, 11, None, 13, 4, 7, 2, None, None, None, 1])) == 10\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9, 10, 11, None, None, None, None, None, None, None, None, 12, None, None, None, 13])) == 21\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, 11, None, None, 12, 13, None, None, 14, 15, None, None, 16, 17])) == 33\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == 345\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25, None, 26, None, 27, None, 28, None, 29, None, 30, None, 31, None, 32, None, 33, None, 34, None, 35, None, 36, None, 37])) == 37\n assert candidate(root = tree_node([1, 2, 3, None, 5, 6, None, 7, None, None, 8, None, None, 9, None, None, 10])) == 10\n assert candidate(root = tree_node([5, 4, 8, 11, None, 13, 4, 7, 2, None, None, 5, 1, None, None, None, 6])) == 6\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 90\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, 8, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20])) == 20\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, 29, 30])) == 59\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == 140\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, None, 16, None, None, None, None, 17, None, None, None, None, 18, None, None, None, None, 19, None, None, None, None, 20, None, None, None, None, 21, None, None, None, None, 22, None, None, None, None, 23])) == 33\n assert candidate(root = tree_node([3, 9, 20, None, None, 15, 7, 25, 30, 40, 50, 60, 70, 80, 90])) == 300\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == 205\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50])) == 779\n assert candidate(root = tree_node([5, 4, 8, 11, None, 13, 4, 7, 2, None, None, 5, 1, None, None, None, 9])) == 9\n assert candidate(root = tree_node([1, 2, 3, None, None, None, 4, None, None, None, None, 5, None, None, None, None, 6, None, None, None, None, 7, None, None, None, None, 8, None, None, None, None, 9])) == 4\n assert candidate(root = tree_node([3, 9, 20, None, None, 15, 7, 1, None, None, None, None, 2, None, None, 16])) == 2\n assert candidate(root = tree_node([10, 9, 20, None, None, 15, 7, None, None, 1, 2, None, None, 3, 4])) == 7\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, None, None, None, 31, 32, None, None, 33, 34])) == 130\n assert candidate(root = tree_node([1, 2, 3, None, 4, 5, 6, None, None, 7, 8, 9, 10, 11, 12, None, None, None, None, None, 13, 14, 15])) == 29\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, 6, 7, 8, 9, None, None, None, None, None, None, 10, 11, 12, 13])) == 25\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7])) == 7\n assert candidate(root = tree_node([20, 15, 25, 10, 18, 23, 30, 5, 12, 16, 19, 22, 24, 29, 32, 3, 7, 11, 13, 14, 17, 21, 26, 28, 31, 33])) == 204\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, None, 16, None, None, None, None, 17, None, None, None, None, 18, None, None, None, None, 19, None, None, None, None, 20, None, None, None, None, 21, None, None, None, None, 22, None, None, None, None, 23, None, None, None, None, 24, None, None, None, None, 25, None, None, None, None, 26])) == 33\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, None, None, None, None, None, None, None, None, None, None, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, None, None, None, None, 31, 32, 33, 34, 35])) == 165\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])) == 15\n assert candidate(root = tree_node([1, 2, 3, 4, None, 6, None, 7, None, None, None, 8, None, 9, None, None, None, None, 10, None])) == 9\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, 6, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21])) == 60\n assert candidate(root = tree_node([9, 4, 5, None, None, 6, 7, None, None, None, None, None, 8])) == 13\n assert candidate(root = tree_node([9, 3, 15, 2, 7, 12, 20, 1, None, 5, 8, 11, None, None, 13, None, None, 6, 4, 9, None, 10])) == 29\n assert candidate(root = tree_node([20, 15, 25, 10, 18, 22, 30, 8, None, 14, 19, None, 21, 24, 32])) == 118\n assert candidate(root = tree_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, None, None, None, None, None, None, None, None, None, None, None, 0])) == 6\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20])) == 20\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 17\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6, 8, 16, 20])) == 51\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, None, 6, None, None, None, None, 14])) == 21\n assert candidate(root = tree_node([1, 2, 3, None, 5, None, 6, None, 7, 8, 9, None, None, None, None, None, None, 10, 11])) == 24\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 10\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, None, None, 36])) == 341\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12])) == 12\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6, 8, None, None, 14, None, 17, 19])) == 50\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12])) == 12\n assert candidate(root = tree_node([7, 14, 21, 28, 35, None, 42, 49, 56, 63, None, 70, 77, None, None, None, None, None, None, None, None, 84, 91, 98])) == 98\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, 11])) == 21\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])) == 306\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, None, None, 16, None, None, None, None, 17, None, None, None, None, 18, None, None, None, None, 19, None, None, None, None, 20, None, None, None, None, 21])) == 17\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11])) == 11\n assert candidate(root = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31])) == 31\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == 205\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, None, None, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == 115\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, 7, None, None, None, None, 8, None, None, None, None, None, 9, None, None, None, None, 10, None, None, None, None, 11, None, None, None, None, 12])) == 15\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35])) == 305\n assert candidate(root = tree_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, None, None, None, None, None, None, None, None, None, None, None, None, None, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150])) == 295\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, None, 16, None, None, None, None, 17, None, None, None, None, 18, None, None, None, None, 19, None, None, None, None, 20])) == 33\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, None, None, 5, None, None, None, None, None, None, 6, None, None, None, None, None, None, None, None, 7])) == 5\n assert candidate(root = tree_node([1, 3, None, None, 2])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, 6, None, 7, 8, None, 9, 10, None, 11, 12, None, 13, 14, None, 15, 16, None, 17, 18, None, 19, 20, None, 21, 22, None, 23, 24, None, 25, 26, None, 27, 28, None, 29, 30])) == 212\n assert candidate(root = tree_node([3, 6, 9, 12, 15, None, 18, None, None, None, None, 21, 24, None, None, None, None, None, None, None, 27, None, None, None, None, 30])) == 45\n assert candidate(root = tree_node([5, 4, 8, 11, None, 13, 4, 7, 2, None, None, 5, 1])) == 15\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().deepestLeavesSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def deepestLeavesSum(self, root: TreeNode | None) -> int:", "container": "Solution", "callable": "deepestLeavesSum", "parameters": [{"name": "root", "type": "TreeNode | None"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1304, "task_id": "find-n-unique-integers-sum-up-to-zero", "difficulty": "Easy", "problem_description": "Given an integer n, return any array containing n unique integers such that they add up to 0.\n \nExample 1:\n\nInput: n = 5\nOutput: [-7,-1,1,3,4]\nExplanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4].\n\nExample 2:\n\nInput: n = 3\nOutput: [-1,0,1]\n\nExample 3:\n\nInput: n = 1\nOutput: [0]\n\n \nConstraints:\n\n1 <= n <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == [1, -1, 0]\n assert candidate(n = 100) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50]\n assert candidate(n = 2) == [1, -1]\n assert candidate(n = 1) == [0]\n assert candidate(n = 1000) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 498, -498, 499, -499, 500, -500]\n assert candidate(n = 10) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]\n assert candidate(n = 5) == [1, -1, 2, -2, 0]\n assert candidate(n = 601) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 0]\n assert candidate(n = 105) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 0]\n assert candidate(n = 666) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333]\n assert candidate(n = 995) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 0]\n assert candidate(n = 50) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25]\n assert candidate(n = 300) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150]\n assert candidate(n = 123) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 0]\n assert candidate(n = 333) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 0]\n assert candidate(n = 550) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275]\n assert candidate(n = 4) == [1, -1, 2, -2]\n assert candidate(n = 600) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300]\n assert candidate(n = 64) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32]\n assert candidate(n = 16) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]\n assert candidate(n = 450) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225]\n assert candidate(n = 99) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 0]\n assert candidate(n = 17) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 0]\n assert candidate(n = 501) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 0]\n assert candidate(n = 23) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 0]\n assert candidate(n = 51) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 0]\n assert candidate(n = 80) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40]\n assert candidate(n = 128) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64]\n assert candidate(n = 101) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 0]\n assert candidate(n = 8) == [1, -1, 2, -2, 3, -3, 4, -4]\n assert candidate(n = 250) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125]\n assert candidate(n = 999) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 498, -498, 499, -499, 0]\n assert candidate(n = 75) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 0]\n assert candidate(n = 32) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16]\n assert candidate(n = 997) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 498, -498, 0]\n assert candidate(n = 256) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128]\n assert candidate(n = 20) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\n assert candidate(n = 201) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 0]\n assert candidate(n = 889) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 0]\n assert candidate(n = 19) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 0]\n assert candidate(n = 667) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 0]\n assert candidate(n = 513) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 0]\n assert candidate(n = 13) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 0]\n assert candidate(n = 150) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75]\n assert candidate(n = 800) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400]\n assert candidate(n = 11) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 0]\n assert candidate(n = 876) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438]\n assert candidate(n = 200) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100]\n assert candidate(n = 400) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200]\n assert candidate(n = 512) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256]\n assert candidate(n = 9) == [1, -1, 2, -2, 3, -3, 4, -4, 0]\n assert candidate(n = 6) == [1, -1, 2, -2, 3, -3]\n assert candidate(n = 750) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375]\n assert candidate(n = 120) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60]\n assert candidate(n = 499) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 0]\n assert candidate(n = 199) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 0]\n assert candidate(n = 500) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250]\n assert candidate(n = 998) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 498, -498, 499, -499]\n assert candidate(n = 7) == [1, -1, 2, -2, 3, -3, 0]\n assert candidate(n = 25) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 0]\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().sumZero", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def sumZero(self, n: int) -> list[int]:", "container": "Solution", "callable": "sumZero", "parameters": [{"name": "n", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1305, "task_id": "all-elements-in-two-binary-search-trees", "difficulty": "Medium", "problem_description": "Given two binary search trees root1 and root2, return a list containing all the integers from both trees sorted in ascending order.\n \nExample 1:\n\n\nInput: root1 = [2,1,4], root2 = [1,0,3]\nOutput: [0,1,1,2,3,4]\n\nExample 2:\n\n\nInput: root1 = [1,null,8], root2 = [8,1]\nOutput: [1,1,8,8]\n\n \nConstraints:\n\nThe number of nodes in each tree is in the range [0, 5000].\n-105 <= Node.val <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root1 = tree_node([5, 3, 6]),root2 = tree_node([2, 2, 3, None, None, 4, 4])) == [2, 2, 3, 4, 3, 4, 5, 6]\n assert candidate(root1 = tree_node([]),root2 = tree_node([5])) == [5]\n assert candidate(root1 = tree_node([5, 3, 7]),root2 = tree_node([2, 6, 8])) == [3, 5, 6, 2, 7, 8]\n assert candidate(root1 = tree_node([]),root2 = tree_node([])) == []\n assert candidate(root1 = tree_node([2, 1, 4]),root2 = tree_node([1, 0, 3])) == [0, 1, 1, 2, 3, 4]\n assert candidate(root1 = tree_node([10]),root2 = tree_node([5, 15])) == [10, 15, 5]\n assert candidate(root1 = tree_node([5]),root2 = tree_node([])) == [5]\n assert candidate(root1 = tree_node([1, None, 8]),root2 = tree_node([8, 1])) == [1, 1, 8, 8]\n assert candidate(root1 = tree_node([5, 3, 6]),root2 = tree_node([2, 4, 7])) == [3, 4, 2, 5, 6, 7]\n assert candidate(root1 = tree_node([30, 15, 45, 10, 20, 40, 50, 5, 12, 18, 22, 35, 42, 48, 55]),root2 = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 8, 12, 17, 23, 28, 33, 38])) == [3, 5, 5, 8, 10, 10, 12, 12, 15, 15, 17, 18, 20, 20, 22, 23, 25, 28, 30, 30, 33, 35, 35, 38, 40, 42, 45, 48, 50, 55]\n assert candidate(root1 = tree_node([10, None, 20, None, 30, None, 40, None, 50]),root2 = tree_node([5, None, 15, None, 25, None, 35, None, 45])) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(root1 = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19]),root2 = tree_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20])) == [15, 7, 16, 8, 17, 3, 18, 4, 19, 9, 1, 11, 5, 13, 20, 10, 2, 12, 6, 14]\n assert candidate(root1 = tree_node([1, None, None, None]),root2 = tree_node([2, None, None, None])) == [1, 2]\n assert candidate(root1 = tree_node([50, 30, 70, 20, 40, 60, 80, None, 25, 35, 45, 55, 65, 75, 85]),root2 = tree_node([45, 35, 55, 25, 48, 58, 75, None, 28, 32, 42, 47, 57, 70, 78])) == [20, 25, 25, 28, 30, 35, 35, 32, 40, 45, 48, 42, 45, 47, 50, 55, 58, 57, 55, 60, 65, 70, 70, 75, 75, 78, 80, 85]\n assert candidate(root1 = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 7, 12, 18, 23, 27, 32, 38]),root2 = tree_node([30, 15, 45, 10, 20, 35, 50, 5, 12, 18, 25, 40, 42, 48, 55])) == [1, 5, 5, 7, 10, 10, 12, 12, 15, 15, 18, 18, 20, 20, 23, 25, 25, 27, 30, 30, 32, 35, 38, 40, 35, 42, 45, 48, 50, 55]\n assert candidate(root1 = tree_node([100000, -100000]),root2 = tree_node([50000, -50000])) == [-100000, -50000, 50000, 100000]\n assert candidate(root1 = tree_node([5, 3, 8, 1, 4, 7, 10]),root2 = tree_node([2, 6, 9, 0, 3, 5, 11, 2, 4, 6, 8, 10, 12])) == [1, 2, 0, 3, 4, 4, 5, 6, 6, 3, 7, 8, 8, 2, 10, 10, 5, 12, 9, 11]\n assert candidate(root1 = tree_node([1, None, 2, None, 3, None, 4, None, 5]),root2 = tree_node([6, None, 7, None, 8, None, 9, None, 10])) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(root1 = tree_node([100]),root2 = tree_node([50, 25, 75, 10, 30, 60, 80, 5, 15, 20, 40, 55, 65, 70, 85])) == [5, 10, 15, 25, 20, 30, 40, 50, 55, 60, 65, 75, 70, 80, 85, 100]\n assert candidate(root1 = tree_node([5, 2, 6, 1, 3, None, None]),root2 = tree_node([3, 1, 7, None, 2, None, 8, None, None, None, None, None, None])) == [1, 1, 2, 2, 3, 3, 5, 6, 7, 8]\n assert candidate(root1 = tree_node([1, 0, 3, None, None, 2, None, None, None, None, None, None, None]),root2 = tree_node([4, 3, 5, None, None, None, None, None, None, None, None, None, None])) == [0, 1, 2, 3, 3, 4, 5]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175]),root2 = tree_node([200, 150, 250, 125, 175, 225, 275])) == [25, 50, 75, 100, 125, 125, 150, 150, 175, 175, 200, 225, 250, 275]\n assert candidate(root1 = tree_node([1]),root2 = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(root1 = tree_node([1, None, 2, None, 3, None, 4, None, 5]),root2 = tree_node([5, None, 4, None, 3, None, 2, None, 1])) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]\n assert candidate(root1 = tree_node([50, 25, 75, 10, 40, 60, 90, 5, 20, 30, 45, 55, 65, 80, 95]),root2 = tree_node([30, 15, 45, 10, 20, 35, 50, 25, 40, 42, 46, 48, 52, 54, 58])) == [5, 10, 20, 25, 25, 10, 30, 40, 40, 15, 42, 20, 45, 46, 30, 48, 35, 50, 52, 45, 54, 50, 55, 58, 60, 65, 75, 80, 90, 95]\n assert candidate(root1 = tree_node([100, 50, 150, None, 75, 125, 175]),root2 = tree_node([80, 60, 90, 55, 65, 85, 95])) == [50, 55, 60, 65, 75, 80, 85, 90, 95, 100, 125, 150, 175]\n assert candidate(root1 = tree_node([-5, -10, -3, -15, -7]),root2 = tree_node([-20, -12, -8, -17, -13])) == [-17, -15, -12, -13, -20, -10, -8, -7, -5, -3]\n assert candidate(root1 = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19]),root2 = tree_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])) == [15, 7, 16, 8, 17, 3, 18, 4, 19, 9, 1, 11, 5, 13, 20, 10, 22, 2, 24, 12, 26, 6, 28, 14, 30]\n assert candidate(root1 = tree_node([5, 2, 7, 1, 3, None, 8, None, None, 4, 6]),root2 = tree_node([15, 12, 20, 10, 13, 18, 25, None, 11, 14, 16, 19, 21, 24, 26])) == [1, 2, 4, 3, 6, 5, 7, 8, 10, 11, 12, 14, 13, 16, 15, 19, 18, 21, 20, 24, 25, 26]\n assert candidate(root1 = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),root2 = tree_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [3, 7, 2, 8, 4, 9, 2, 9, 1, 6, 10, 5, 1, 6, 3, 7, 10, 5, 8, 4]\n assert candidate(root1 = tree_node([5, 3, 7, 2, 4, 6, 8]),root2 = tree_node([5, 3, 7, 2, 4, 6, 8])) == [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180]),root2 = tree_node([90, 40, 130, 30, 60, 110, 150, 20, 50, 70, 80, 100, 120, 140, 160])) == [10, 20, 25, 30, 30, 50, 50, 40, 60, 70, 60, 75, 80, 80, 90, 100, 100, 110, 110, 120, 125, 130, 140, 140, 150, 150, 160, 160, 175, 180]\n assert candidate(root1 = tree_node([20, 10, 30, 5, 15, 25, 35]),root2 = tree_node([18, 9, 21, 8, 11, 19, 22])) == [5, 8, 9, 10, 11, 15, 18, 19, 20, 21, 22, 25, 30, 35]\n assert candidate(root1 = tree_node([30, 15, 45, 10, 20, 35, 40]),root2 = tree_node([50, 25, 75, 12, 38, 60, 80, 7, 18, 28, 42, 55, 65, 78, 90])) == [7, 10, 12, 15, 18, 20, 25, 28, 30, 35, 38, 42, 45, 40, 50, 55, 60, 65, 75, 78, 80, 90]\n assert candidate(root1 = tree_node([50, 30, 70, 20, 40, 60, 80]),root2 = tree_node([45, 35, 55, 33, 37, 53, 57])) == [20, 30, 33, 35, 37, 40, 45, 50, 53, 55, 57, 60, 70, 80]\n assert candidate(root1 = tree_node([10, None, 20, None, 30, None, 40, None, 50]),root2 = tree_node([15, None, 25, None, 35, None, 45, None, 55])) == [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]\n assert candidate(root1 = tree_node([50, 25, 75, 10, 40, 60, 90]),root2 = tree_node([20, 15, 28, 12, 18, 26, 30])) == [10, 12, 15, 18, 20, 25, 26, 28, 30, 40, 50, 60, 75, 90]\n assert candidate(root1 = tree_node([5, 3, 8, 1, 4, 7, 9, None, 2, 6, None, None, None, None, None, None, None, None, None, None, None]),root2 = tree_node([10, 8, 12, 6, 9, 11, 13, None, 5, 7, 14])) == [1, 2, 3, 6, 4, 5, 6, 5, 7, 8, 8, 7, 9, 9, 14, 10, 11, 12, 13]\n assert candidate(root1 = tree_node([50, 25, 75, 12, 37, 62, 87, 6, 18, 31, 43, 56, 70, 81, 93, 3, 9, 15, 21, 27, 34, 39, 46, 51, 58, 65, 68, 74, 79, 84, 89, 96]),root2 = tree_node([60, 30, 90, 15, 45, 75, 105, 7, 23, 35, 55, 85, 115, 3, 11, 17, 29, 33, 37, 51, 59, 63, 67, 73, 77, 81, 83, 87, 91, 95, 99])) == [17, 7, 29, 15, 33, 23, 37, 30, 51, 35, 59, 45, 63, 55, 67, 60, 73, 85, 77, 75, 81, 96, 3, 6, 9, 12, 15, 18, 21, 25, 27, 31, 34, 37, 39, 43, 46, 50, 51, 56, 58, 62, 65, 70, 68, 75, 74, 81, 79, 87, 84, 93, 89, 115, 83, 90, 87, 3, 91, 105, 95, 11, 99]\n assert candidate(root1 = tree_node([30, 10, 50, 5, 20, 40, 60, 3, 7, 15, 25, 35, 45, 55, 65]),root2 = tree_node([40, 20, 60, 10, 30, 50, 70, 5, 15, 25, 35, 45, 55, 65, 75])) == [3, 5, 5, 7, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50, 55, 55, 60, 60, 65, 65, 70, 75]\n assert candidate(root1 = tree_node([100, 90, 110, 80, 95, 105, 120, 70, 85, 92, 98, 102, 115, 118, 125]),root2 = tree_node([200, 190, 210, 180, 195, 205, 215, 170, 185, 192, 198, 202, 215, 218, 225])) == [70, 80, 85, 90, 92, 95, 98, 100, 102, 105, 115, 110, 118, 120, 125, 170, 180, 185, 190, 192, 195, 198, 200, 202, 205, 215, 210, 218, 215, 225]\n assert candidate(root1 = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),root2 = tree_node([5, 6, 7, 8, 9, 10, 11, 12, 13, 14])) == [8, 4, 9, 2, 10, 5, 1, 6, 3, 7, 12, 8, 13, 6, 14, 9, 5, 10, 7, 11]\n assert candidate(root1 = tree_node([3, 1, 5, None, 2, None, None]),root2 = tree_node([4, 2, 6, None, 3, None, None])) == [1, 2, 2, 3, 3, 4, 5, 6]\n assert candidate(root1 = tree_node([5, 2, 7, 1, None, 6, 8]),root2 = tree_node([3, 1, 6, None, 2, 5, 7])) == [1, 1, 2, 2, 3, 5, 5, 6, 6, 7, 7, 8]\n assert candidate(root1 = tree_node([5, 5, 5, 5, 5, 5, 5]),root2 = tree_node([5, 5, 5, 5, 5, 5, 5])) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 190]),root2 = tree_node([90, 40, 160, 30, 50, 130, 180, 20, 40, 50, 60, 120, 150, 170, 190])) == [10, 20, 25, 30, 30, 40, 40, 50, 50, 50, 60, 60, 75, 80, 90, 100, 110, 120, 125, 130, 140, 150, 150, 160, 160, 170, 175, 180, 190, 190]\n assert candidate(root1 = tree_node([10, 5, 15, 3, 7, 12, 18, 1, 4, 6, 8, 11, 13, 17, 19]),root2 = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15])) == [1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 15, 17, 18, 19]\n assert candidate(root1 = tree_node([20, 10, 30, 5, 15, 25, 35]),root2 = tree_node([12, 8, 18, 6, 10, 16, 20])) == [5, 6, 8, 10, 10, 12, 15, 16, 18, 20, 20, 25, 30, 35]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180]),root2 = tree_node([90, 40, 140, 30, 60, 100, 160, 20, 50, 70, 90, 110, 130, 150, 170])) == [10, 20, 25, 30, 30, 50, 50, 40, 60, 70, 60, 75, 80, 90, 90, 100, 110, 110, 100, 125, 130, 140, 140, 150, 150, 160, 160, 170, 175, 180]\n assert candidate(root1 = tree_node([10000, 5000, 15000, 2500, 7500, 12500, 17500]),root2 = tree_node([10000, 9999, 10001, 9998, 9999, 10000, 10002])) == [2500, 5000, 7500, 9998, 9999, 9999, 10000, 10000, 10000, 10001, 10002, 12500, 15000, 17500]\n assert candidate(root1 = tree_node([1]),root2 = tree_node([2, 3, 4, 5, 6, 7, 8, 9, 10])) == [1, 9, 5, 10, 3, 6, 2, 7, 4, 8]\n assert candidate(root1 = tree_node([10, 5, 15, 2, 7, 12, 18, 1, 4, 6, 8, 11, 13, 16, 19]),root2 = tree_node([15, 7, 20, 3, 11, 17, 25, 1, 5, 9, 12, 14, 18, 22, 28])) == [1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 9, 10, 11, 11, 12, 12, 13, 15, 15, 14, 16, 17, 18, 18, 19, 20, 22, 25, 28]\n assert candidate(root1 = tree_node([50, 30, 70, 20, 40, 60, 80]),root2 = tree_node([45, 35, 55, 25, 48, 58, 75])) == [20, 25, 30, 35, 40, 48, 45, 50, 58, 55, 60, 70, 75, 80]\n assert candidate(root1 = tree_node([1000, 500, 1500, 250, 750, 1250, 1750, 125, 375, 625, 875, 1125, 1375, 1625, 1875]),root2 = tree_node([1500, 1250, 1750, 1125, 1375, 1625, 1875, 1000, 750, 1250, 1500, 875, 1375, 1625, 1875])) == [125, 250, 375, 500, 625, 750, 875, 1000, 1000, 1125, 1125, 750, 1250, 1250, 1250, 1375, 1375, 1500, 1500, 1500, 875, 1625, 1625, 1375, 1750, 1750, 1625, 1875, 1875, 1875]\n assert candidate(root1 = tree_node([50, 30, 70, 20, 40, 60, 80, 10, 25, 35, 45, 55, 65, 75, 85]),root2 = tree_node([30, 10, 50, 5, 20, 40, 60, 3, 7, 15, 25, 35, 45, 55, 65])) == [3, 5, 7, 10, 10, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50, 55, 55, 60, 60, 65, 65, 70, 75, 80, 85]\n assert candidate(root1 = tree_node([100000, -100000, None, None, None]),root2 = tree_node([-100000, 100000, None, None, None])) == [-100000, 100000, 100000, -100000]\n assert candidate(root1 = tree_node([100, -100, 200, -200, 0, 150, 250]),root2 = tree_node([150, 100, 250, 50, 125, 200, 300, -50, 75, 110, 130, 180, 225, 275, 350])) == [-200, -100, -50, 0, 50, 75, 100, 100, 110, 125, 130, 150, 150, 180, 200, 200, 225, 250, 250, 275, 300, 350]\n assert candidate(root1 = tree_node([5, 3, 7, 2, 4, 6, 8]),root2 = tree_node([3, 1, 6, None, 2, 5, 9])) == [1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 8, 9]\n assert candidate(root1 = tree_node([50, 25, 75, 10, 40, 60, 90, 5, 20, 30, 45, 55, 70, 85, 100]),root2 = tree_node([30, 15, 45, 10, 20, 35, 40, 5, 12, 25, 38, 42, 50, 48, 52])) == [5, 5, 10, 10, 12, 15, 20, 25, 25, 20, 30, 38, 30, 40, 42, 35, 45, 50, 50, 45, 48, 40, 52, 55, 60, 70, 75, 85, 90, 100]\n assert candidate(root1 = tree_node([50, 30, 70, 20, 40, 60, 80, 10, 25, 35, 45, 55, 65, 75, 85]),root2 = tree_node([45, 35, 55, 25, 40, 50, 60, 15, 30, 42, 48, 52, 58, 62, 68])) == [10, 15, 20, 25, 25, 30, 30, 35, 35, 40, 42, 40, 45, 48, 45, 50, 52, 50, 55, 58, 55, 60, 62, 60, 65, 68, 70, 75, 80, 85]\n assert candidate(root1 = tree_node([1, 0, 2]),root2 = tree_node([2, 1, 3])) == [0, 1, 1, 2, 2, 3]\n assert candidate(root1 = tree_node([0]),root2 = tree_node([0, 0, 0, 0, 0])) == [0, 0, 0, 0, 0, 0]\n assert candidate(root1 = tree_node([50, 25, 75, 12, 37, 62, 87, 6, 18, 31, 43, 56, 70, 81, 93]),root2 = tree_node([45, 22, 60, 10, 30, 50, 70, 5, 15, 25, 35, 40, 55, 65, 75])) == [5, 6, 10, 12, 15, 18, 22, 25, 25, 30, 31, 35, 37, 43, 45, 40, 50, 50, 55, 56, 60, 62, 65, 70, 70, 75, 75, 81, 87, 93]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175]),root2 = tree_node([110, 60, 160, 55, 65, 130, 170, 50, 62, 120, 135, 165, 175])) == [25, 50, 50, 55, 62, 60, 75, 100, 120, 65, 125, 135, 110, 150, 165, 130, 175, 175, 160, 170]\n assert candidate(root1 = tree_node([2, 1, None, None, None, None, 3, 4, None, None, None, None, None, None, 5, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]),root2 = tree_node([1, None, 3, None, None, 2, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == [1, 1, 2, 3]\n assert candidate(root1 = tree_node([1, 2, 3, 4, 5, 6, 7]),root2 = tree_node([8, 9, 10, 11, 12, 13, 14])) == [4, 2, 5, 1, 6, 3, 7, 11, 9, 12, 8, 13, 10, 14]\n assert candidate(root1 = tree_node([10]),root2 = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9])) == [8, 4, 9, 2, 5, 1, 6, 3, 7, 10]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180]),root2 = tree_node([50, 25, 75, 15, 35, 65, 85, 10, 20, 40, 50, 70, 90, 110, 130])) == [10, 10, 15, 20, 25, 25, 30, 40, 35, 50, 50, 50, 60, 70, 65, 75, 80, 90, 75, 100, 110, 110, 85, 125, 130, 140, 150, 160, 175, 180]\n assert candidate(root1 = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7]),root2 = tree_node([7, None, 6, None, 5, None, 4, None, 3, None, 2, None, 1])) == [1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(root1 = tree_node([50, 25, 75, 10, 40, 60, 90, 5, 20, 30, 45, 55, 70, 85, 100]),root2 = tree_node([60, 30, 90, 15, 45, 75, 120, 10, 25, 35, 50, 65, 80, 105, 130])) == [5, 10, 10, 15, 20, 25, 25, 30, 30, 35, 40, 45, 45, 50, 50, 55, 60, 60, 65, 70, 75, 75, 80, 85, 90, 90, 100, 105, 120, 130]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175]),root2 = tree_node([80, 60, 90, 55, 65, 85, 95])) == [25, 50, 55, 60, 65, 75, 80, 85, 90, 95, 100, 125, 150, 175]\n assert candidate(root1 = tree_node([50, 25, 75, 12, 37, 62, 88, 6, 18, 31, 43, 56, 70, 82, 95]),root2 = tree_node([50, 25, 75, 12, 37, 62, 88, 6, 18, 31, 43, 56, 70, 82, 95])) == [6, 6, 12, 12, 18, 18, 25, 25, 31, 31, 37, 37, 43, 43, 50, 50, 56, 56, 62, 62, 70, 70, 75, 75, 82, 82, 88, 88, 95, 95]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 130, 160, 180]),root2 = tree_node([90, 40, 140, 35, 45, 135, 145, 32, 37, 42, 48, 132, 138, 142, 147])) == [10, 25, 30, 32, 35, 37, 40, 42, 45, 48, 50, 60, 75, 80, 90, 100, 110, 125, 130, 132, 135, 138, 140, 142, 145, 147, 150, 160, 175, 180]\n assert candidate(root1 = tree_node([5, 2, 7, 1, None, 6, 8]),root2 = tree_node([5, 2, 7, 1, None, 6, 8])) == [1, 1, 2, 2, 5, 5, 6, 6, 7, 7, 8, 8]\n assert candidate(root1 = tree_node([5]),root2 = tree_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(root1 = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),root2 = tree_node([11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == [8, 4, 9, 2, 10, 5, 1, 6, 3, 7, 18, 14, 19, 12, 20, 15, 11, 16, 13, 17]\n assert candidate(root1 = tree_node([500, 250, 750, 125, 375, 625, 875, 63, 188, 313, 438, 563, 688, 813, 938]),root2 = tree_node([450, 225, 675, 113, 338, 500, 825, 57, 169, 294, 388, 450, 588, 732, 898])) == [57, 63, 113, 125, 169, 188, 225, 250, 294, 313, 338, 375, 388, 438, 450, 450, 500, 500, 563, 588, 625, 675, 688, 732, 750, 813, 825, 875, 898, 938]\n assert candidate(root1 = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]),root2 = tree_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])) == [15, 7, 16, 8, 17, 3, 18, 4, 19, 9, 20, 10, 21, 1, 22, 2, 23, 11, 24, 12, 25, 5, 26, 6, 27, 13, 28, 14, 29, 30]\n assert candidate(root1 = tree_node([100]),root2 = tree_node([50, 25, 75, 12, 37, 63, 88, 6, 18, 30, 44, 56, 70, 82, 93])) == [6, 12, 18, 25, 30, 37, 44, 50, 56, 63, 70, 75, 82, 88, 93, 100]\n assert candidate(root1 = tree_node([5, 1, 7, None, 2, None, 8]),root2 = tree_node([3, 1, 6, None, 2, 5, 9])) == [1, 1, 2, 2, 3, 5, 5, 6, 7, 8, 9]\n assert candidate(root1 = tree_node([10, 5, 15, 3, 7, 13, 18, 1, 4, 6, 8, 12, 14, 17, 20]),root2 = tree_node([11, 6, 16, 5, 7, 13, 17, 4, 8, 12, 14, 15, 18, 19, 21])) == [1, 3, 4, 4, 5, 5, 6, 7, 8, 8, 6, 10, 12, 12, 7, 13, 14, 14, 11, 15, 15, 13, 17, 18, 18, 16, 19, 17, 20, 21]\n assert candidate(root1 = tree_node([50, 25, 75, 10, 40, 60, 90, 5, 20, 30, 45, 55, 65, 80, 95]),root2 = tree_node([100, 50, 150, 25, 75, 125, 175])) == [5, 10, 20, 25, 25, 30, 40, 45, 50, 50, 55, 60, 65, 75, 75, 80, 90, 95, 100, 125, 150, 175]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180]),root2 = tree_node([90, 40, 140, 20, 60, 120, 160, 15, 25, 50, 55, 115, 130, 155, 170])) == [10, 15, 20, 25, 25, 30, 40, 50, 50, 60, 60, 55, 75, 80, 90, 100, 110, 115, 120, 125, 130, 140, 140, 150, 155, 160, 160, 170, 175, 180]\n assert candidate(root1 = tree_node([1, None, None]),root2 = tree_node([1, None, None])) == [1, 1]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 130, 160, 180]),root2 = tree_node([90, 40, 140, 35, 45, 85, 135, 33, 37, 43, 47, 83, 87, 133, 137])) == [10, 25, 30, 33, 35, 37, 40, 43, 45, 47, 50, 60, 75, 80, 90, 83, 85, 87, 100, 110, 125, 130, 140, 133, 135, 137, 150, 160, 175, 180]\n assert candidate(root1 = tree_node([5, 2, 8, None, 3, 6, 9, None, None, 4, 7]),root2 = tree_node([3, 1, 7, 2, 4, 6, 8])) == [2, 2, 1, 3, 4, 3, 5, 4, 6, 6, 7, 7, 8, 8, 9]\n assert candidate(root1 = tree_node([1]),root2 = tree_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])) == [1, 9, 5, 10, 3, 11, 6, 12, 2, 13, 7, 14, 4, 15, 8, 16]\n assert candidate(root1 = tree_node([20, 10, 30, 5, 15, 25, 35, None, None, None, None, 22, 27, 32, 37]),root2 = tree_node([18, 9, 21, 8, 11, 19, 22, None, None, None, None, 20, 25, 28, 31])) == [5, 8, 9, 10, 11, 15, 18, 20, 20, 19, 22, 25, 25, 21, 27, 28, 22, 30, 31, 32, 35, 37]\n assert candidate(root1 = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),root2 = tree_node([15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [8, 4, 8, 9, 2, 10, 5, 11, 1, 12, 6, 12, 7, 13, 3, 14, 7, 14, 6, 11, 5, 15, 15, 4, 10, 3, 13, 2, 9, 1]\n assert candidate(root1 = tree_node([10, None, 20, None, None, 15, None, None, None, None, None, None, None, None, None]),root2 = tree_node([20, None, 30, None, None, 25, None, None, None, None, None, None, None, None, None])) == [10, 20, 20, 30]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 12, 37, 62, 87, 112, 137, 162, 187]),root2 = tree_node([80, 60, 90, 55, 65, 85, 95, 50, 60, 70, 80, 90, 100, 110, 120])) == [12, 25, 37, 50, 50, 55, 60, 60, 62, 70, 65, 75, 80, 80, 87, 90, 85, 100, 100, 90, 110, 95, 112, 120, 125, 137, 150, 162, 175, 187]\n assert candidate(root1 = tree_node([1, 3, 5, 7, 9, 11, 13]),root2 = tree_node([2, 4, 6, 8, 10, 12, 14])) == [7, 3, 8, 4, 9, 1, 10, 2, 11, 5, 12, 6, 13, 14]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175]),root2 = tree_node([90, 40, 140, 30, 60, 130, 160])) == [25, 30, 40, 50, 60, 75, 90, 100, 125, 130, 140, 150, 160, 175]\n assert candidate(root1 = tree_node([1, 0, 2, None, None, 1.5, None, None, None, None, None, None, None]),root2 = tree_node([2, 1, 3, None, None, 1.5, None, None, None, None, None, None, None])) == [0, 1, 1, 1.5, 2, 2, 1.5, 3]\n assert candidate(root1 = tree_node([10000, 5000, 15000, 2500, 7500, 12500, 17500, 1250, 3750, 6250, 8750, 11250, 14375, 16250, 18750]),root2 = tree_node([10000, 5000, 15000, 2500, 7500, 12500, 17500, 1250, 3750, 6250, 8750, 11250, 14375, 16250, 18750])) == [1250, 1250, 2500, 2500, 3750, 3750, 5000, 5000, 6250, 6250, 7500, 7500, 8750, 8750, 10000, 10000, 11250, 11250, 12500, 12500, 14375, 14375, 15000, 15000, 16250, 16250, 17500, 17500, 18750, 18750]\n"}, "metadata": {"canonical_parameter_names": ["root1", "root2"], "leetcode_dataset_entry_point": "Solution().getAllElements", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getAllElements(self, root1: TreeNode | None, root2: TreeNode | None) -> list[int]:", "container": "Solution", "callable": "getAllElements", "parameters": [{"name": "root1", "type": "TreeNode | None"}, {"name": "root2", "type": "TreeNode | None"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1306, "task_id": "jump-game-iii", "difficulty": "Medium", "problem_description": "Given an array of non-negative integers arr, you are initially positioned at start index of the array. When you are at index i, you can jump to i + arr[i] or i - arr[i], check if you can reach any index with value 0.\nNotice that you can not jump outside of the array at any time.\n \nExample 1:\n\nInput: arr = [4,2,3,0,3,1,2], start = 5\nOutput: true\nExplanation: \nAll possible ways to reach at index 3 with value 0 are: \nindex 5 -> index 4 -> index 1 -> index 3 \nindex 5 -> index 6 -> index 4 -> index 1 -> index 3 \n\nExample 2:\n\nInput: arr = [4,2,3,0,3,1,2], start = 0\nOutput: true \nExplanation: \nOne possible way to reach at index 3 with value 0 is: \nindex 0 -> index 4 -> index 1 -> index 3\n\nExample 3:\n\nInput: arr = [3,0,2,1,2], start = 2\nOutput: false\nExplanation: There is no way to reach at index 1 with value 0.\n\n \nConstraints:\n\n1 <= arr.length <= 5 * 104\n0 <= arr[i] < arr.length\n0 <= start < arr.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 0, 5, 0, 5, 0],start = 1) == True\n assert candidate(arr = [5, 0, 0, 0, 0, 0],start = 0) == True\n assert candidate(arr = [4, 2, 3, 0, 3, 1, 2],start = 0) == True\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0],start = 1) == True\n assert candidate(arr = [0, 1, 0, 1, 0],start = 4) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],start = 5) == True\n assert candidate(arr = [3, 0, 2, 1, 2],start = 2) == False\n assert candidate(arr = [0, 1, 0, 1, 0],start = 3) == True\n assert candidate(arr = [0, 1, 1, 0, 1, 1],start = 4) == True\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0],start = 0) == True\n assert candidate(arr = [1, 2, 3, 4, 0],start = 0) == False\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],start = 0) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0],start = 5) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 0) == True\n assert candidate(arr = [0, 1, 0, 1, 0],start = 2) == True\n assert candidate(arr = [0, 1, 0, 1, 0],start = 0) == True\n assert candidate(arr = [4, 2, 3, 0, 3, 1, 2],start = 5) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],start = 5) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5],start = 3) == True\n assert candidate(arr = [1, 2, 3, 4, 0],start = 4) == True\n assert candidate(arr = [2, 3, 1, 1, 4],start = 3) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1],start = 0) == False\n assert candidate(arr = [0, 1],start = 1) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5],start = 0) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 0) == False\n assert candidate(arr = [1, 2, 3, 4, 0],start = 2) == False\n assert candidate(arr = [2, 3, 0, 1, 4],start = 2) == True\n assert candidate(arr = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0],start = 1) == True\n assert candidate(arr = [0, 1, 0, 1, 0],start = 1) == True\n assert candidate(arr = [1, 0, 1, 0, 1, 0],start = 0) == True\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],start = 6) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],start = 15) == True\n assert candidate(arr = [2, 0, 1, 1, 3, 0, 2, 0, 1, 0],start = 1) == True\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],start = 1) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 18) == True\n assert candidate(arr = [1, 3, 0, 0, 2, 4, 2, 0, 1, 3],start = 5) == True\n assert candidate(arr = [5, 0, 2, 0, 3, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0],start = 1) == True\n assert candidate(arr = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 0],start = 1) == True\n assert candidate(arr = [3, 5, 2, 1, 0, 0, 1, 2, 3],start = 5) == True\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],start = 0) == False\n assert candidate(arr = [5, 1, 4, 1, 2, 3, 0, 1],start = 2) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5],start = 6) == True\n assert candidate(arr = [5, 2, 1, 4, 0, 0, 0, 3, 1, 2, 1],start = 0) == True\n assert candidate(arr = [4, 0, 1, 0, 2, 3, 0, 1],start = 2) == True\n assert candidate(arr = [0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],start = 15) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],start = 10) == True\n assert candidate(arr = [5, 0, 0, 0, 0, 0, 0, 0, 0, 5],start = 9) == True\n assert candidate(arr = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],start = 10) == True\n assert candidate(arr = [3, 2, 1, 0, 4, 2, 0, 3, 0, 1],start = 0) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0],start = 19) == True\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0],start = 0) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 24) == True\n assert candidate(arr = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 0) == True\n assert candidate(arr = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0],start = 10) == True\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3],start = 15) == False\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 20) == True\n assert candidate(arr = [3, 4, 1, 2, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2],start = 19) == True\n assert candidate(arr = [4, 2, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],start = 13) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],start = 0) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0],start = 5) == False\n assert candidate(arr = [4, 0, 5, 0, 3, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5],start = 1) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],start = 19) == True\n assert candidate(arr = [4, 2, 3, 0, 3, 1, 2, 3, 0, 1],start = 8) == True\n assert candidate(arr = [3, 4, 2, 3, 0, 1, 2, 0, 1, 3],start = 0) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 14) == True\n assert candidate(arr = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0],start = 0) == False\n assert candidate(arr = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],start = 6) == True\n assert candidate(arr = [5, 3, 0, 0, 2, 0, 1, 0, 0, 3, 0],start = 2) == True\n assert candidate(arr = [1, 3, 0, 0, 2, 3, 4, 0, 0, 5, 4, 3],start = 1) == True\n assert candidate(arr = [4, 0, 5, 3, 0, 1, 2, 0, 3, 1],start = 5) == True\n assert candidate(arr = [4, 1, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 2) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0],start = 19) == True\n assert candidate(arr = [2, 3, 0, 1, 4, 5, 6, 0, 2, 1],start = 3) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 5) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 19) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],start = 9) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0],start = 39) == False\n assert candidate(arr = [1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 0],start = 0) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 9) == True\n assert candidate(arr = [0, 2, 1, 0, 1, 0, 1, 0, 1, 0],start = 8) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 5) == True\n assert candidate(arr = [2, 0, 2, 0, 1, 0, 1, 0, 2, 0, 1, 0, 1, 0, 2, 0],start = 14) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 10) == True\n assert candidate(arr = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 34) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 13) == True\n assert candidate(arr = [5, 0, 1, 2, 3, 0, 1, 0, 2, 3, 0],start = 5) == True\n assert candidate(arr = [4, 2, 3, 1, 0, 2, 3, 4, 5, 0],start = 2) == True\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],start = 14) == True\n assert candidate(arr = [2, 3, 4, 5, 0, 0, 5, 4, 3, 2],start = 5) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],start = 0) == True\n assert candidate(arr = [10, 8, 5, 0, 12, 10, 7, 3, 8, 4, 2, 9, 0, 6, 1],start = 5) == False\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],start = 10) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 20) == True\n assert candidate(arr = [5, 1, 3, 2, 4, 0, 6],start = 2) == True\n assert candidate(arr = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0],start = 1) == True\n assert candidate(arr = [3, 0, 2, 5, 0, 1, 2, 0, 0, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],start = 1) == True\n assert candidate(arr = [2, 1, 0, 0, 2, 1, 0, 1, 0, 1, 0, 1, 0],start = 2) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 0, 11, 13, 15, 17],start = 4) == False\n assert candidate(arr = [2, 3, 1, 1, 2, 4, 2, 0, 1, 3, 1, 2, 3, 4, 0],start = 6) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0],start = 14) == True\n assert candidate(arr = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0],start = 10) == True\n assert candidate(arr = [2, 3, 1, 1, 4, 2, 3, 1, 1, 4],start = 5) == False\n assert candidate(arr = [2, 4, 3, 2, 0, 1, 2, 3, 4, 0],start = 0) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 21) == True\n assert candidate(arr = [0, 3, 0, 5, 0, 0, 3, 1, 0, 2],start = 5) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 0, 1, 2, 3, 4],start = 8) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],start = 4) == True\n assert candidate(arr = [3, 2, 1, 4, 5, 6, 0, 1, 2, 3],start = 8) == True\n assert candidate(arr = [0, 3, 2, 1, 5, 4, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0],start = 10) == True\n assert candidate(arr = [1, 0, 3, 4, 0, 5, 2, 0, 0, 3, 2],start = 4) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],start = 10) == True\n"}, "metadata": {"canonical_parameter_names": ["arr", "start"], "leetcode_dataset_entry_point": "Solution().canReach", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canReach(self, arr: list[int], start: int) -> bool:", "container": "Solution", "callable": "canReach", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "start", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1307, "task_id": "verbal-arithmetic-puzzle", "difficulty": "Hard", "problem_description": "Given an equation, represented by words on the left side and the result on the right side.\nYou need to check if the equation is solvable under the following rules:\n\nEach character is decoded as one digit (0 - 9).\nNo two characters can map to the same digit.\nEach words[i] and result are decoded as one number without leading zeros.\nSum of numbers on the left side (words) will equal to the number on the right side (result).\n\nReturn true if the equation is solvable, otherwise return false.\n \nExample 1:\n\nInput: words = [\"SEND\",\"MORE\"], result = \"MONEY\"\nOutput: true\nExplanation: Map 'S'-> 9, 'E'->5, 'N'->6, 'D'->7, 'M'->1, 'O'->0, 'R'->8, 'Y'->'2'\nSuch that: \"SEND\" + \"MORE\" = \"MONEY\" , 9567 + 1085 = 10652\nExample 2:\n\nInput: words = [\"SIX\",\"SEVEN\",\"SEVEN\"], result = \"TWENTY\"\nOutput: true\nExplanation: Map 'S'-> 6, 'I'->5, 'X'->0, 'E'->8, 'V'->7, 'N'->2, 'T'->1, 'W'->'3', 'Y'->4\nSuch that: \"SIX\" + \"SEVEN\" + \"SEVEN\" = \"TWENTY\" , 650 + 68782 + 68782 = 138214\nExample 3:\n\nInput: words = [\"LEET\",\"CODE\"], result = \"POINT\"\nOutput: false\nExplanation: There is no possible mapping to satisfy the equation, so we return false.\nNote that two different characters cannot map to the same digit.\n\n \nConstraints:\n\n2 <= words.length <= 5\n1 <= words[i].length, result.length <= 7\nwords[i], result contain only uppercase English letters.\nThe number of different characters used in the expression is at most 10.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['SEND', 'MORE'],result = \"MONEY\") == True\n assert candidate(words = ['A', 'A', 'A', 'A'],result = \"AA\") == False\n assert candidate(words = ['LEET', 'CODE'],result = \"POINT\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"HIALL\") == False\n assert candidate(words = ['AA', 'BB'],result = \"CC\") == True\n assert candidate(words = ['SIX', 'SEVEN', 'SEVEN'],result = \"TWENTY\") == True\n assert candidate(words = ['CAT', 'DOG'],result = \"BIRD\") == True\n assert candidate(words = ['ABA', 'B'],result = \"ABC\") == True\n assert candidate(words = ['A', 'B'],result = \"C\") == True\n assert candidate(words = ['ABC', 'BCD'],result = \"DEE\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"PEACE\") == True\n assert candidate(words = ['LONG', 'WORDS', 'HERE'],result = \"ADDITION\") == False\n assert candidate(words = ['CASTLE', 'KNIGHT'],result = \"BATTLE\") == False\n assert candidate(words = ['MAX', 'MIN'],result = \"SUM\") == True\n assert candidate(words = ['ALGEBRA', 'GEOMETRY'],result = \"MATHEMATICS\") == False\n assert candidate(words = ['BAT', 'BALL', 'BASE'],result = \"TABLE\") == False\n assert candidate(words = ['EULER', 'GAUSS'],result = \"ARITHMETIC\") == False\n assert candidate(words = ['COMPUTER', 'SCIENCE'],result = \"DISCOVERY\") == False\n assert candidate(words = ['FAST', 'CAR'],result = \"RACING\") == False\n assert candidate(words = ['HEAL', 'HURT'],result = \"BALANCE\") == False\n assert candidate(words = ['MATH', 'ENGLISH', 'SCIENCE'],result = \"CURRICULUM\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"PYTHON\") == False\n assert candidate(words = ['SAINT', 'SEER'],result = \"VISION\") == False\n assert candidate(words = ['SUN', 'MOON', 'STAR'],result = \"GALAXY\") == False\n assert candidate(words = ['SNOW', 'ICE'],result = \"COLD\") == True\n assert candidate(words = ['HELLO', 'WORLD'],result = \"HAPPY\") == False\n assert candidate(words = ['A', 'BB', 'CCC', 'DDDD'],result = \"E\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"DISPATCH\") == False\n assert candidate(words = ['KNIGHT', 'KNIGHT'],result = \"WARLORD\") == False\n assert candidate(words = ['ZERO', 'ONE', 'TWO', 'THREE'],result = \"SIX\") == False\n assert candidate(words = ['FIVE', 'NINE', 'ELEVEN'],result = \"TWENTYFIVE\") == False\n assert candidate(words = ['TRUE', 'FALSE'],result = \"PARADOX\") == False\n assert candidate(words = ['STAR', 'SHIP'],result = \"GALAXY\") == False\n assert candidate(words = ['TEN', 'TEN', 'TEN'],result = \"THIRTY\") == False\n assert candidate(words = ['HOUSE', 'DOG'],result = \"FAMILY\") == False\n assert candidate(words = ['MATH', 'ROCKS'],result = \"LEARNING\") == False\n assert candidate(words = ['SIX', 'EIGHT', 'TEN'],result = \"TWENTYFOUR\") == False\n assert candidate(words = ['APPLE', 'BANANA'],result = \"GRAPE\") == False\n assert candidate(words = ['ONE', 'TWO', 'THREE', 'FOUR', 'FIVE'],result = \"SUMUP\") == False\n assert candidate(words = ['FOUR', 'FIVE', 'SIX'],result = \"FIFTEEN\") == False\n assert candidate(words = ['UP', 'DOWN'],result = \"ZERO\") == True\n assert candidate(words = ['SUN', 'MOON'],result = \"STAR\") == True\n assert candidate(words = ['BIG', 'DOG'],result = \"ANIMAL\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"PLANETS\") == False\n assert candidate(words = ['MOON', 'EARTH'],result = \"UNIVERSE\") == False\n assert candidate(words = ['APPLE', 'BANANA', 'CHERRY'],result = \"FRUITBOWL\") == False\n assert candidate(words = ['HAPPY', 'BIRTHDAY'],result = \"CELEBRATE\") == False\n assert candidate(words = ['ABACAXI', 'MANGO', 'KIWI'],result = \"FRUITS\") == False\n assert candidate(words = ['CAT', 'DOG', 'MOUSE'],result = \"PIG\") == False\n assert candidate(words = ['UNIVERSAL', 'GALAXY', 'EARTH'],result = \"COSMOS\") == False\n assert candidate(words = ['BIRD', 'FLY', 'HIGH'],result = \"FLIGHT\") == False\n assert candidate(words = ['ALICE', 'BOB'],result = \"GAME\") == False\n assert candidate(words = ['RIGHT', 'WRONG'],result = \"FALSE\") == False\n assert candidate(words = ['CAT', 'DOG', 'MOUSE'],result = \"CLAW\") == False\n assert candidate(words = ['ALICE', 'BOB', 'CHARLIE'],result = \"FRIENDSHIP\") == False\n assert candidate(words = ['PHOENIX', 'DRAGON'],result = \"MYTHICAL\") == False\n assert candidate(words = ['PYTHON', 'ROCKS'],result = \"PROGRAM\") == False\n assert candidate(words = ['FLY', 'FLY', 'HIGH'],result = \"SKYLINE\") == False\n assert candidate(words = ['SEND', 'MORE', 'MONEY'],result = \"TWICE\") == False\n assert candidate(words = ['UNO', 'DOS', 'TRES'],result = \"SEIS\") == True\n assert candidate(words = ['WIZARD', 'WAND'],result = \"MAGIC\") == False\n assert candidate(words = ['LUCK', 'IN', 'THE', 'DRAW'],result = \"SUCCESS\") == False\n assert candidate(words = ['STAR', 'NIGHT'],result = \"TWILIGHT\") == False\n assert candidate(words = ['SUN', 'MOON', 'STARS'],result = \"SKYLINE\") == False\n assert candidate(words = ['BLACK', 'WHITE', 'GRAY'],result = \"COLORS\") == False\n assert candidate(words = ['JAVA', 'PYTHON', 'CPLUSPLUS'],result = \"PROGRAMMING\") == False\n assert candidate(words = ['AARDVARK', 'ANTELOPE'],result = \"MAMMALS\") == False\n assert candidate(words = ['NINE', 'NINE'],result = \"EIGHTEEN\") == False\n assert candidate(words = ['ALICE', 'BOB', 'CHARLIE'],result = \"FICTION\") == False\n assert candidate(words = ['ZERO', 'ONE', 'TWO', 'THREE'],result = \"SUM\") == False\n assert candidate(words = ['MAGIC', 'WAND'],result = \"WIZARD\") == False\n assert candidate(words = ['JAVA', 'PYTHON'],result = \"SCRIPT\") == False\n assert candidate(words = ['KNIGHT', 'BISHOP'],result = \"CHECKMATE\") == False\n assert candidate(words = ['COMPUTER', 'SCIENCE', 'PROGRAMMING'],result = \"DEVELOPMENT\") == False\n assert candidate(words = ['EARTH', 'MOON'],result = \"UNIVERSE\") == False\n assert candidate(words = ['SIXTY', 'SIXTY'],result = \"ONETWENTY\") == False\n assert candidate(words = ['SNOW', 'FALL'],result = \"SNOWBALL\") == False\n assert candidate(words = ['FALCON', 'HAWK'],result = \"BIRD\") == False\n assert candidate(words = ['APPLE', 'BANANA'],result = \"GRAPES\") == False\n assert candidate(words = ['ZEBRA', 'ELEPHANT'],result = \"WILDLIFE\") == False\n assert candidate(words = ['ZERO', 'ONE'],result = \"SUM\") == False\n assert candidate(words = ['EARTH', 'WATER'],result = \"PLANET\") == False\n assert candidate(words = ['APPLE', 'BANANA', 'CHERRY'],result = \"FRUIT\") == False\n assert candidate(words = ['ONE', 'TWO', 'THREE', 'FOUR'],result = \"TEN\") == False\n assert candidate(words = ['ONE', 'TWO', 'THREE', 'FOUR'],result = \"SUM\") == False\n assert candidate(words = ['MATH', 'IS', 'FUN'],result = \"JOKES\") == False\n assert candidate(words = ['DOG', 'CAT'],result = \"ANIMAL\") == False\n assert candidate(words = ['GREEN', 'BLUE', 'YELLOW'],result = \"COLORS\") == False\n assert candidate(words = ['ZERO', 'ONE', 'TWO', 'THREE'],result = \"FIVE\") == False\n assert candidate(words = ['MAT', 'ADD', 'SUB'],result = \"SUM\") == False\n assert candidate(words = ['KANGAROO', 'KANGAROO', 'KANGAROO'],result = \"JUMPOUTS\") == False\n assert candidate(words = ['OCEAN', 'SEA', 'LAKE'],result = \"WATERBODY\") == False\n assert candidate(words = ['WITCH', 'WAND'],result = \"MAGIC\") == True\n assert candidate(words = ['HAPPY', 'JOY'],result = \"BLISS\") == True\n assert candidate(words = ['STAR', 'PLANET', 'GALAXY'],result = \"COSMOS\") == False\n assert candidate(words = ['FAST', 'SLOW'],result = \"BALANCE\") == False\n assert candidate(words = ['LEFT', 'RIGHT'],result = \"EQUAL\") == False\n assert candidate(words = ['COOL', 'DRINK'],result = \"REFRESH\") == False\n assert candidate(words = ['MAGICAL', 'REALM'],result = \"MYSTERY\") == False\n assert candidate(words = ['LEARN', 'PYTHON'],result = \"CODEING\") == False\n assert candidate(words = ['CAR', 'BIKE'],result = \"VEHICLE\") == False\n assert candidate(words = ['HEART', 'SOUL'],result = \"LOVE\") == False\n assert candidate(words = ['MATH', 'IS', 'FUN'],result = \"GAMES\") == False\n assert candidate(words = ['PARIS', 'BERLIN'],result = \"ROME\") == False\n assert candidate(words = ['ABCDEFGHIJK', 'LMNOPQRS'],result = \"TUVWXYZ\") == False\n assert candidate(words = ['SUN', 'MOON'],result = \"AURA\") == True\n assert candidate(words = ['MATH', 'SCI', 'ENG'],result = \"STUDY\") == False\n assert candidate(words = ['UNICORN', 'PEGASUS'],result = \"MYTHOLOGY\") == False\n assert candidate(words = ['SUN', 'MOON', 'STAR'],result = \"SKY\") == False\n assert candidate(words = ['ALPHA', 'BETA', 'GAMMA'],result = \"DELTA\") == True\n assert candidate(words = ['PYTHON', 'JAVA'],result = \"SCRIPT\") == False\n assert candidate(words = ['CLOCK', 'BELL'],result = \"TICKTOCK\") == False\n assert candidate(words = ['DAY', 'NIGHT'],result = \"TIMELESS\") == False\n assert candidate(words = ['TEN', 'TWO'],result = \"TWELVE\") == False\n assert candidate(words = ['FAST', 'RUN', 'JUMP'],result = \"ATHLETE\") == False\n assert candidate(words = ['APPLE', 'BANANA'],result = \"CHERRY\") == True\n assert candidate(words = ['ALCHEMY', 'ENCHANT'],result = \"MAGICAL\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"PEACEFUL\") == False\n assert candidate(words = ['PYTHON', 'JAVA', 'CPLUS'],result = \"PROGRAMMING\") == False\n assert candidate(words = ['PYTHON', 'JAVA'],result = \"SCRIPT\") == False\n assert candidate(words = ['SUN', 'MOON', 'STAR'],result = \"UNIVERSAL\") == False\n assert candidate(words = ['MOUNTAIN', 'CLIMBER'],result = \"ADVENTURE\") == False\n assert candidate(words = ['PYTHON', 'JAVA', 'CPLUSPLUS'],result = \"PROGRAMMING\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"HALLO\") == False\n assert candidate(words = ['ONE', 'TWO', 'THREE'],result = \"SIX\") == False\n assert candidate(words = ['ABCDE', 'FGHIJ'],result = \"KLMNO\") == False\n assert candidate(words = ['SKY', 'TREE'],result = \"FOREST\") == False\n assert candidate(words = ['PI', 'E'],result = \"CIRCLE\") == False\n assert candidate(words = ['FOUR', 'FIVE', 'SIX'],result = \"FIFTEEN\") == False\n assert candidate(words = ['RED', 'BLUE'],result = \"COLOR\") == False\n assert candidate(words = ['JUMP', 'HIGH', 'LONG'],result = \"JUMPROPE\") == False\n assert candidate(words = ['SUN', 'MOON', 'STAR'],result = \"PLANET\") == False\n assert candidate(words = ['HIGH', 'LOW'],result = \"AMPLITUDE\") == False\n assert candidate(words = ['ALPACA', 'ANIMAL', 'ZOO'],result = \"WILDLIFE\") == False\n assert candidate(words = ['HAPPY', 'JOY'],result = \"HARMONY\") == False\n assert candidate(words = ['SPY', 'SPY'],result = \"QUIZ\") == True\n assert candidate(words = ['APPLE', 'BANANA'],result = \"FRUIT\") == False\n assert candidate(words = ['HAPPY', 'SAD'],result = \"JOY\") == False\n assert candidate(words = ['CRYPT', 'GRAPH', 'DRY'],result = \"DRYRUN\") == False\n assert candidate(words = ['GENIE', 'BOTTLE'],result = \"WISHES\") == False\n assert candidate(words = ['RED', 'BLUE'],result = \"GREEN\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"HELLOWORLD\") == False\n assert candidate(words = ['BIRD', 'FLY'],result = \"SKY\") == False\n assert candidate(words = ['MYTH', 'HERO'],result = \"LEGEND\") == False\n assert candidate(words = ['Babbage', 'Difference', 'Engine'],result = \"Calculator\") == False\n assert candidate(words = ['ZERO', 'ONE', 'TWO', 'THREE'],result = \"SUM\") == False\n assert candidate(words = ['PYTHON', 'JAVA', 'CPP'],result = \"PROGRAM\") == False\n assert candidate(words = ['TREE', 'FOREST'],result = \"GREEN\") == False\n"}, "metadata": {"canonical_parameter_names": ["words", "result"], "leetcode_dataset_entry_point": "Solution().isSolvable", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def isSolvable(self, words: list[str], result: str) -> bool:", "container": "Solution", "callable": "isSolvable", "parameters": [{"name": "words", "type": "list[str]"}, {"name": "result", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1309, "task_id": "decrypt-string-from-alphabet-to-integer-mapping", "difficulty": "Easy", "problem_description": "You are given a string s formed by digits and '#'. We want to map s to English lowercase characters as follows:\n\nCharacters ('a' to 'i') are represented by ('1' to '9') respectively.\nCharacters ('j' to 'z') are represented by ('10#' to '26#') respectively.\n\nReturn the string formed after mapping.\nThe test cases are generated so that a unique mapping will always exist.\n \nExample 1:\n\nInput: s = \"10#11#12\"\nOutput: \"jkab\"\nExplanation: \"j\" -> \"10#\" , \"k\" -> \"11#\" , \"a\" -> \"1\" , \"b\" -> \"2\".\n\nExample 2:\n\nInput: s = \"1326#\"\nOutput: \"acz\"\n\n \nConstraints:\n\n1 <= s.length <= 1000\ns consists of digits and the '#' letter.\ns will be a valid string such that mapping is always possible.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"11#11#11#11#11#11#11#11#11#11#\") == \"kkkkkkkkkk\"\n assert candidate(s = \"12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"26#25#24#23#22#21#\") == \"zyxwvu\"\n assert candidate(s = \"1326#\") == \"acz\"\n assert candidate(s = \"25#24#23#22#21#20#19#18#17#16#15#14#13#\") == \"yxwvutsrqponm\"\n assert candidate(s = \"11#12#13#14#15#16#17#18#19#\") == \"klmnopqrs\"\n assert candidate(s = \"10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"jklmnopqrstuvwxyz\"\n assert candidate(s = \"12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26\") == \"abcdefghijklmnopqrstuvwxybf\"\n assert candidate(s = \"10#11#12\") == \"jkab\"\n assert candidate(s = \"10#20#30#40#50#60#70#80#90#\") == \"jt~ˆ’œ¦°º\"\n assert candidate(s = \"10#11#12#13#14#15#\") == \"jklmno\"\n assert candidate(s = \"10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321#\") == \"jklmnopqrstuvwxyzihgfedcu\"\n assert candidate(s = \"20#21#22#23#24#25#26#\") == \"tuvwxyz\"\n assert candidate(s = \"10#10#10#10#10#10#10#10#10#10#\") == \"jjjjjjjjjj\"\n assert candidate(s = \"26#25#24#23#22#21#20#19#18#17#16#15#14#13#12#11#10#\") == \"zyxwvutsrqponmlkj\"\n assert candidate(s = \"25#26#\") == \"yz\"\n assert candidate(s = \"123456789\") == \"abcdefghi\"\n assert candidate(s = \"11#22#33#44#55#66#77#88#99#\") == \"kvŒ—¢­¸Ã\"\n assert candidate(s = \"25#26#10#10#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"yzjjjklmnopqrstuvwxyz\"\n assert candidate(s = \"52525252525252525252525252525252525252525252525252525252525252525252525252525#\") == \"ebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebey\"\n assert candidate(s = \"26#25#24#23#22#21#20#19#18#17#16#15#14#13#12#11#10#987654321\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"10#20#30#40#50#60#70#80#90#11#21#31#41#51#61#71#81#91#26#\") == \"jt~ˆ’œ¦°ºku‰“§±»z\"\n assert candidate(s = \"12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#98765432112345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321\") == \"abcdefghijklmnopqrstuvwxyzihgfedcbaabcdefghijklmnopqrstuvwxyzihgfedcba\"\n assert candidate(s = \"12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321\") == \"lmnopqrstuvwxyzihgfedcba\"\n assert candidate(s = \"910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26\") == \"ijklmnopqrstuvwxybf\"\n assert candidate(s = \"12345678910#20#30#40#50#60#70#80#90#11#21#31#41#51#61#71#81#91#26#\") == \"abcdefghijt~ˆ’œ¦°ºku‰“§±»z\"\n assert candidate(s = \"910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321\") == \"ijklmnopqrstuvwxyzihgfedcba\"\n assert candidate(s = \"26#10#26#10#26#10#26#10#26#10#26#10#26#10#26#10#\") == \"zjzjzjzjzjzjzjzj\"\n assert candidate(s = \"10#20#30#11#21#31#12#22#32#13#23#33#14#24#34#15#25#35#16#26#36#\") == \"jt~kulv€mwnx‚oyƒpz„\"\n assert candidate(s = \"91#82#73#64#55#46#37#28#19#10#11#12#13#14#15#16#17#18#\") == \"»²© —Ž\u0085|sjklmnopqr\"\n assert candidate(s = \"12#14#16#18#20#22#24#26#11#13#15#17#19#21#23#25#\") == \"lnprtvxzkmoqsuwy\"\n assert candidate(s = \"11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#\") == \"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk\"\n assert candidate(s = \"25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#\") == \"yzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyz\"\n assert candidate(s = \"11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321\") == \"klmnopqrstuvwxyzihgfedcba\"\n assert candidate(s = \"99999999999999999999999999999999999999999999999999999999999999999999999999999#10#\") == \"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiÃj\"\n assert candidate(s = \"10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"jklmnopqrstuvwxyzjklmnopqrstuvwxyz\"\n assert candidate(s = \"10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#\") == \"jjjjjjjjjjjjjjjjjjjjjjjj\"\n assert candidate(s = \"910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"ijklmnopqrstuvwxyz\"\n assert candidate(s = \"10#20#30#11#21#31#12#22#32#13#23#14#24#15#25#16#26\") == \"jt~kulv€mwnxoypbf\"\n assert candidate(s = \"10#20#30#40#50#60#70#80#90#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"jt~ˆ’œ¦°ºjklmnopqrstuvwxyz\"\n assert candidate(s = \"10#10#10#11#11#11#12#12#12#13#13#13#14#14#14#15#15#15#16#16#16#17#17#17#18#18#18#19#19#19#20#20#20#21#21#21#22#22#22#23#23#23#24#24#24#25#25#25#26#26#26#\") == \"jjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\"\n assert candidate(s = \"10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#\") == \"jjjjjjjjjjjjjjjjjjjjjjj\"\n assert candidate(s = \"10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#\") == \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().freqAlphabets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def freqAlphabets(self, s: str) -> str:", "container": "Solution", "callable": "freqAlphabets", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1310, "task_id": "xor-queries-of-a-subarray", "difficulty": "Medium", "problem_description": "You are given an array arr of positive integers. You are also given the array queries where queries[i] = [lefti, righti].\nFor each query i compute the XOR of elements from lefti to righti (that is, arr[lefti] XOR arr[lefti + 1] XOR ... XOR arr[righti] ).\nReturn an array answer where answer[i] is the answer to the ith query.\n \nExample 1:\n\nInput: arr = [1,3,4,8], queries = [[0,1],[1,2],[0,3],[3,3]]\nOutput: [2,7,14,8] \nExplanation: \nThe binary representation of the elements in the array are:\n1 = 0001 \n3 = 0011 \n4 = 0100 \n8 = 1000 \nThe XOR values for queries are:\n[0,1] = 1 xor 3 = 2 \n[1,2] = 3 xor 4 = 7 \n[0,3] = 1 xor 3 xor 4 xor 8 = 14 \n[3,3] = 8\n\nExample 2:\n\nInput: arr = [4,8,2,10], queries = [[2,3],[1,3],[0,0],[0,3]]\nOutput: [8,0,4,4]\n\n \nConstraints:\n\n1 <= arr.length, queries.length <= 3 * 104\n1 <= arr[i] <= 109\nqueries[i].length == 2\n0 <= lefti <= righti < arr.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [4, 8, 2, 10],queries = [[2, 3], [1, 3], [0, 0], [0, 3]]) == [8, 0, 4, 4]\n assert candidate(arr = [10, 5, 2, 3, 15],queries = [[0, 4], [1, 2], [2, 3], [0, 1], [3, 4]]) == [1, 7, 1, 15, 12]\n assert candidate(arr = [5, 2, 3, 9],queries = [[0, 0], [1, 3], [0, 2], [2, 3]]) == [5, 8, 4, 10]\n assert candidate(arr = [7, 11, 15, 22, 29],queries = [[0, 2], [1, 3], [0, 4], [4, 4]]) == [3, 18, 8, 29]\n assert candidate(arr = [5, 1, 4, 2],queries = [[0, 2], [1, 3], [0, 1], [2, 2]]) == [0, 7, 4, 4]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [11, 0, 11, 0, 3]\n assert candidate(arr = [15, 10, 5, 3],queries = [[0, 3], [1, 1], [0, 0], [2, 3]]) == [3, 10, 15, 6]\n assert candidate(arr = [5, 2, 4, 6, 1],queries = [[0, 2], [1, 4], [0, 4], [3, 3]]) == [3, 1, 4, 6]\n assert candidate(arr = [7, 11, 13, 8],queries = [[0, 2], [1, 3], [2, 3], [0, 1]]) == [1, 14, 5, 12]\n assert candidate(arr = [5, 1, 4, 2],queries = [[0, 0], [1, 1], [0, 1], [0, 3]]) == [5, 1, 4, 2]\n assert candidate(arr = [15, 14, 13, 12, 11],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == [15, 14, 13, 12, 11]\n assert candidate(arr = [1, 1, 1, 1],queries = [[0, 1], [1, 2], [0, 3], [3, 3]]) == [0, 0, 0, 1]\n assert candidate(arr = [5, 1, 4, 2],queries = [[0, 1], [2, 3], [0, 2], [1, 2]]) == [4, 6, 0, 5]\n assert candidate(arr = [1, 3, 4, 8],queries = [[0, 1], [1, 2], [0, 3], [3, 3]]) == [2, 7, 14, 8]\n assert candidate(arr = [3, 6, 9, 12, 15],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == [3, 6, 9, 12, 15]\n assert candidate(arr = [7, 11, 15],queries = [[0, 2], [0, 0], [1, 1], [2, 2]]) == [3, 7, 11, 15]\n assert candidate(arr = [2, 6, 1, 8, 3, 9, 4],queries = [[0, 6], [2, 5], [1, 3], [4, 6], [0, 2]]) == [3, 3, 15, 14, 5]\n assert candidate(arr = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 4]]) == [503538687, 587645496, 362994761, 847757604, 111254601, 996193791, 161737801, 518034651, 195148873, 1025255708]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],queries = [[0, 10], [1, 8], [2, 9], [0, 3], [6, 8], [5, 7], [0, 1], [9, 10]]) == [2047, 510, 1020, 15, 448, 224, 3, 1536]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],queries = [[0, 10], [1, 5], [3, 7], [0, 6], [6, 10], [2, 9]]) == [2047, 992, 248, 2032, 31, 510]\n assert candidate(arr = [8, 13, 21, 34, 55, 89, 144, 233],queries = [[0, 7], [1, 5], [3, 6], [4, 7], [0, 6]]) == [37, 84, 220, 23, 204]\n assert candidate(arr = [255, 128, 64, 32, 16, 8, 4, 2, 1],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [0, 7], [1, 6], [2, 5], [3, 4], [0, 6], [1, 5], [2, 4], [0, 5], [1, 4], [0, 4], [1, 3], [0, 3], [1, 2], [0, 2], [1, 1], [0, 1], [0, 0]]) == [0, 254, 124, 56, 16, 1, 252, 120, 48, 3, 248, 112, 7, 240, 15, 224, 31, 192, 63, 128, 127, 255]\n assert candidate(arr = [3, 6, 8, 12, 15, 9, 7, 11],queries = [[0, 7], [2, 5], [1, 6], [4, 6], [0, 3], [3, 7]]) == [11, 2, 3, 1, 1, 6]\n assert candidate(arr = [987654321, 876543219, 765432198, 654321987, 543219876, 432198765, 321987654, 219876543, 198765432, 98765432, 87654321],queries = [[0, 9], [1, 5], [3, 7], [0, 6], [6, 9], [2, 8]]) == [768397751, 117666047, 8926579, 787233800, 269601273, 651120525]\n assert candidate(arr = [29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10],queries = [[0, 19], [1, 18], [3, 17], [4, 16], [6, 15]]) == [0, 23, 27, 13, 1]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],queries = [[0, 20], [2, 7], [5, 9], [0, 10], [10, 20], [4, 15]]) == [2097151, 252, 992, 2047, 2096128, 65520]\n assert candidate(arr = [123456789, 987654321, 135792468, 246813579, 975318642, 864213579, 753186429, 642135798, 531864297, 421357986],queries = [[0, 9], [1, 4], [3, 6], [0, 5], [5, 9], [2, 8]]) == [1049048706, 106058268, 737300943, 847988034, 1066314123, 438303364]\n assert candidate(arr = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],queries = [[0, 12], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [0, 4], [6, 8], [0, 7], [8, 10], [0, 1], [11, 12]]) == [129, 366, 613, 600, 432, 648, 521, 563, 843, 949, 435, 127]\n assert candidate(arr = [13, 7, 18, 5, 12, 6, 9, 4, 8, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7]]) == [24, 31, 16, 6, 10, 18, 23]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [682, 340, 168, 80, 32, 683, 343, 175, 95, 63, 31, 15, 7, 3, 1]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1023, 510, 252, 120, 48]\n assert candidate(arr = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707],queries = [[0, 9], [2, 7], [1, 8], [4, 5], [0, 3]]) == [982, 760, 366, 485, 707]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10], [0, 9], [10, 19], [0, 4], [5, 9], [10, 14], [15, 19]]) == [0, 9, 0, 5, 0, 1, 0, 5, 0, 9, 1, 1, 5, 4, 5, 4]\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7], [0, 1], [1, 2], [2, 3], [3, 4]]) == [26, 55, 31, 51, 17, 5, 21, 19, 1, 6, 2, 12]\n assert candidate(arr = [987654321, 987654322, 987654323, 987654324, 987654325, 987654326, 987654327, 987654328, 987654329, 987654330],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [11, 0, 11, 0, 3]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 9], [1, 2], [6, 7], [8, 9]]) == [682, 340, 168, 80, 32, 640, 21, 256, 8, 2]\n assert candidate(arr = [9, 3, 5, 7, 11, 13, 17, 19, 23, 29],queries = [[0, 9], [1, 4], [3, 6], [0, 5], [5, 9], [2, 8]]) == [6, 10, 16, 14, 5, 17]\n assert candidate(arr = [13, 29, 17, 23, 19, 31, 2, 5, 7, 11, 13, 17, 19, 23, 29],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 6], [7, 14]]) == [20, 4, 14, 12, 10, 20, 0, 24, 12]\n assert candidate(arr = [21, 33, 47, 59, 71, 83, 97, 101, 103, 107, 109, 113, 127],queries = [[0, 12], [2, 7], [5, 9], [0, 8], [9, 12], [4, 11]]) == [95, 4, 91, 87, 8, 0]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],queries = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [0, 0], [10, 10], [0, 5], [5, 10]]) == [2047, 1022, 508, 248, 112, 32, 1024, 1, 2016, 63]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [20, 1, 16, 1, 20, 1, 8, 1, 4, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == [0, 14, 2, 12, 4, 10, 6, 8]\n assert candidate(arr = [2, 6, 3, 9, 11, 12, 5],queries = [[0, 6], [1, 4], [2, 3], [4, 5], [0, 5]]) == [12, 7, 10, 7, 9]\n assert candidate(arr = [6, 2, 8, 4, 10, 12, 14, 16, 18, 20],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [22, 4, 20, 12, 6]\n assert candidate(arr = [13, 19, 31, 14, 20, 27, 25, 22, 23, 29, 30, 18, 21, 16, 26, 15, 24, 17, 28, 11, 3, 10, 5, 6, 7, 8, 9, 4, 12, 1],queries = [[0, 29], [5, 24], [10, 22], [15, 28], [20, 26], [25, 27], [0, 28], [1, 27], [2, 26], [3, 25], [4, 24], [5, 23], [6, 22], [7, 21], [8, 20], [9, 19], [10, 18], [11, 17], [12, 16], [13, 15], [0, 27], [1, 26], [2, 25], [3, 24], [4, 23], [5, 22], [6, 21], [7, 20], [8, 19], [9, 18], [10, 17], [11, 16], [12, 15], [0, 26], [1, 25], [2, 24], [3, 23], [4, 22], [5, 21], [6, 20], [7, 19], [8, 18], [9, 17], [10, 16], [11, 15], [12, 14], [0, 25], [1, 24], [2, 23], [3, 22], [4, 21], [5, 20], [6, 19], [7, 18], [8, 17], [9, 16], [10, 15], [11, 14], [12, 13], [0, 24], [1, 23], [2, 22], [3, 21], [4, 20], [5, 19], [6, 18], [7, 17], [8, 16], [9, 15], [10, 14], [11, 13], [12, 12]]) == [2, 17, 14, 21, 12, 5, 3, 2, 21, 3, 5, 22, 11, 23, 11, 31, 9, 11, 8, 5, 15, 6, 28, 11, 2, 16, 14, 29, 8, 20, 21, 26, 16, 11, 15, 20, 12, 4, 21, 4, 30, 3, 8, 4, 2, 31, 2, 7, 19, 10, 1, 31, 7, 21, 31, 25, 28, 13, 5, 10, 0, 21, 15, 11, 28, 12, 9, 14, 1, 19, 23, 21]\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 5], [5, 9]]) == [524095, 241270, 30061, 201228, 30433, 130751, 292406]\n assert candidate(arr = [2, 6, 12, 8, 3, 10],queries = [[0, 5], [1, 3], [2, 4], [0, 2], [4, 5]]) == [9, 2, 7, 8, 9]\n assert candidate(arr = [3, 8, 15, 2, 7, 9, 6, 11, 5, 10],queries = [[0, 9], [2, 5], [4, 7], [0, 4], [6, 9], [1, 8]]) == [10, 3, 3, 1, 2, 3]\n assert candidate(arr = [2, 6, 8, 10, 12, 14, 16, 18],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 3], [4, 7]]) == [6, 22, 0, 6, 6, 0]\n assert candidate(arr = [123456789, 987654321, 135792468, 246813579, 1112131415, 1514131211, 1010101010, 2020202020, 3030303030, 4040404040],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9], [0, 0], [9, 9], [1, 7], [2, 6], [3, 5], [0, 3], [4, 8], [1, 6], [2, 5], [3, 4]]) == [592308591, 3569715250, 1518674357, 720695493, 410388572, 2036495916, 1513070403, 123456789, 4040404040, 1616595204, 585955217, 381688791, 992719227, 3904238684, 405970720, 517479555, 1291834588]\n assert candidate(arr = [5, 12, 25, 50, 100, 200, 400, 800, 1600, 3200],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 9], [0, 4], [6, 8]]) == [2302, 1147, 567, 270, 172, 2232, 70, 1264]\n assert candidate(arr = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985, 999999984, 999999983, 999999982, 999999981],queries = [[0, 19], [2, 7], [5, 9], [0, 6], [6, 19], [2, 15]]) == [1004, 7, 999999991, 1000000001, 23, 15]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7], [0, 0], [14, 14]]) == [0, 14, 2, 12, 4, 10, 6, 8, 1, 15]\n assert candidate(arr = [6, 9, 4, 7, 3, 8, 10, 12],queries = [[0, 7], [2, 5], [1, 4], [3, 6], [0, 3], [4, 7]]) == [1, 8, 9, 6, 12, 13]\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 3], [4, 7]]) == [29918, 200913, 130828, 232367, 100446, 130176]\n assert candidate(arr = [31, 15, 7, 3, 1],queries = [[0, 4], [1, 3], [2, 2], [3, 3], [0, 3], [1, 2]]) == [21, 11, 7, 3, 20, 8]\n assert candidate(arr = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10], [0, 18], [1, 17], [2, 16], [3, 15], [4, 14], [5, 13], [6, 12], [7, 11], [8, 10], [0, 17], [1, 16], [2, 15], [3, 14], [4, 13], [5, 12], [6, 11], [7, 10], [8, 9], [0, 16], [1, 15], [2, 14], [3, 13], [4, 12], [5, 11], [6, 10], [7, 9], [0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8], [0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7], [0, 12], [1, 11], [2, 10], [3, 9], [4, 8], [5, 7], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7], [2, 6], [3, 5], [0, 7], [1, 6], [2, 5], [0, 6], [1, 5], [2, 4], [0, 5], [1, 4], [0, 4], [1, 3], [0, 3], [1, 2], [0, 2], [1, 1], [0, 1], [0, 0]]) == [8388600, 4194288, 2097120, 1048512, 524160, 261888, 130560, 64512, 30720, 12288, 4194296, 2097136, 1048544, 524224, 262016, 130816, 65024, 31744, 14336, 2097144, 1048560, 524256, 262080, 130944, 65280, 32256, 15360, 6144, 1048568, 524272, 262112, 131008, 65408, 32512, 15872, 7168, 524280, 262128, 131040, 65472, 32640, 16128, 7680, 3072, 262136, 131056, 65504, 32704, 16256, 7936, 3584, 131064, 65520, 32736, 16320, 8064, 3840, 1536, 65528, 32752, 16352, 8128, 3968, 1792, 32760, 16368, 8160, 4032, 1920, 768, 16376, 8176, 4064, 1984, 896, 8184, 4080, 2016, 960, 384, 4088, 2032, 992, 448, 2040, 1008, 480, 1016, 496, 224, 504, 240, 248, 112, 120, 48, 56, 16, 24, 8]\n assert candidate(arr = [97, 43, 27, 58, 103, 82, 75, 34, 69, 20, 15, 88, 47, 62, 91],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]]) == [123, 65, 84, 96, 2, 106, 44, 34, 69, 20, 15, 88, 47, 62]\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],queries = [[0, 9], [1, 6], [2, 7], [3, 8], [4, 9], [0, 5], [5, 8], [0, 1], [8, 9]]) == [67, 9, 83, 25, 103, 63, 16, 27, 11]\n assert candidate(arr = [255, 127, 63, 31, 15, 7, 3, 1],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 3], [4, 7], [0, 5], [2, 7], [1, 4], [0, 1], [6, 7], [0, 0], [7, 7]]) == [170, 84, 40, 16, 160, 10, 168, 42, 80, 128, 2, 255, 1]\n assert candidate(arr = [17, 23, 5, 31, 4, 6, 7, 9],queries = [[0, 7], [2, 5], [3, 6], [1, 4], [0, 0], [7, 7]]) == [16, 24, 26, 9, 17, 9]\n assert candidate(arr = [123456789, 987654321, 135792468, 246813579, 111213141, 191817161, 151413121, 121110987, 765432109, 890123456],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [541748032, 304059029, 90073865, 176057750, 231612316]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]]) == [0, 14, 2, 12, 4, 10, 6]\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 9], [0, 4], [6, 8]]) == [524095, 241270, 30061, 201228, 30433, 292406, 231689, 151730]\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5],queries = [[0, 14], [5, 10], [2, 12], [0, 7], [8, 14]]) == [4, 14, 5, 15, 11]\n assert candidate(arr = [31, 28, 30, 29, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 29], [1, 28], [2, 27], [3, 26], [4, 25], [5, 24], [6, 23], [7, 22], [8, 21], [9, 20], [10, 19], [11, 18], [12, 17], [13, 16], [14, 15], [0, 15], [15, 29]]) == [1, 28, 3, 25, 1, 28, 1, 16, 1, 28, 1, 24, 1, 28, 1, 0, 17]\n assert candidate(arr = [8, 16, 32, 64, 128, 256, 512, 1024],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 6], [1, 5], [2, 4], [0, 5], [1, 4], [2, 3]]) == [2040, 1008, 480, 192, 1016, 496, 224, 504, 240, 96]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 4], [3, 6], [0, 5], [5, 9], [2, 8]]) == [11, 0, 0, 7, 10, 2]\n assert candidate(arr = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],queries = [[0, 14], [1, 12], [3, 11], [4, 10], [6, 9]]) == [16, 0, 28, 20, 12]\n assert candidate(arr = [17, 23, 31, 47, 59, 67, 71, 83, 97, 101],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 9], [0, 4], [6, 8]]) == [94, 42, 92, 16, 120, 83, 13, 117]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [0, 4], [5, 8]]) == [511, 254, 124, 56, 16, 31, 480]\n assert candidate(arr = [25, 35, 45, 55, 65, 75, 85, 95, 105],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [0, 4], [5, 8]]) == [73, 57, 69, 61, 97, 40]\n assert candidate(arr = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 9], [1, 2], [6, 7], [8, 9]]) == [1015, 0, 7, 0, 7, 1020, 999999991, 1, 3, 15]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],queries = [[0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8], [0, 0], [15, 15]]) == [16, 1, 12, 1, 8, 1, 12, 1, 1, 16]\n assert candidate(arr = [2147483647, 1073741823, 536870911, 268435455, 134217727],queries = [[0, 4], [1, 3], [0, 2], [3, 4], [2, 2]]) == [1476395007, 805306367, 1610612735, 134217728, 536870911]\n assert candidate(arr = [234, 567, 890, 1234, 5678, 9012, 3456, 7890, 12345, 67890, 112233, 445566, 778899, 101112, 212223, 313233, 414243, 515253, 616263, 717273],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [650028, 203295, 687983, 893088, 783953, 993262, 800805, 900957, 410396, 48987]\n assert candidate(arr = [134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576, 524288, 262144],queries = [[0, 9], [1, 5], [3, 7], [0, 6], [6, 9], [2, 8]]) == [268173312, 130023424, 32505856, 266338304, 3932160, 66584576]\n"}, "metadata": {"canonical_parameter_names": ["arr", "queries"], "leetcode_dataset_entry_point": "Solution().xorQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def xorQueries(self, arr: list[int], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "xorQueries", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1311, "task_id": "get-watched-videos-by-your-friends", "difficulty": "Medium", "problem_description": "There are n people, each person has a unique id between 0 and n-1. Given the arrays watchedVideos and friends, where watchedVideos[i] and friends[i] contain the list of watched videos and the list of friends respectively for the person with id = i.\nLevel 1 of videos are all watched videos by your friends, level 2 of videos are all watched videos by the friends of your friends and so on. In general, the level k of videos are all watched videos by people with the shortest path exactly equal to k with you. Given your id and the level of videos, return the list of videos ordered by their frequencies (increasing). For videos with the same frequency order them alphabetically from least to greatest. \n \nExample 1:\n\n\nInput: watchedVideos = [[\"A\",\"B\"],[\"C\"],[\"B\",\"C\"],[\"D\"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 1\nOutput: [\"B\",\"C\"] \nExplanation: \nYou have id = 0 (green color in the figure) and your friends are (yellow color in the figure):\nPerson with id = 1 -> watchedVideos = [\"C\"] \nPerson with id = 2 -> watchedVideos = [\"B\",\"C\"] \nThe frequencies of watchedVideos by your friends are: \nB -> 1 \nC -> 2\n\nExample 2:\n\n\nInput: watchedVideos = [[\"A\",\"B\"],[\"C\"],[\"B\",\"C\"],[\"D\"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 2\nOutput: [\"D\"]\nExplanation: \nYou have id = 0 (green color in the figure) and the only friend of your friends is the person with id = 3 (yellow color in the figure).\n\n \nConstraints:\n\nn == watchedVideos.length == friends.length\n2 <= n <= 100\n1 <= watchedVideos[i].length <= 100\n1 <= watchedVideos[i][j].length <= 8\n0 <= friends[i].length < n\n0 <= friends[i][j] < n\n0 <= id < n\n1 <= level < n\nif friends[i] contains j, then friends[j] contains i\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(watchedVideos = [['Action', 'Comedy'], ['Action'], ['Comedy', 'Drama'], ['Drama']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 3,level = 1) == ['Action', 'Comedy', 'Drama']\n assert candidate(watchedVideos = [['X', 'Y'], ['Y', 'Z'], ['Z', 'X'], ['X', 'Y', 'Z']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 1,level = 1) == ['Z', 'X', 'Y']\n assert candidate(watchedVideos = [['X', 'Y'], ['Z'], ['X', 'Z'], ['W']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 1,level = 1) == ['W', 'X', 'Y']\n assert candidate(watchedVideos = [['A', 'B'], ['C'], ['B', 'C'], ['D']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 0,level = 1) == ['B', 'C']\n assert candidate(watchedVideos = [['M', 'N'], ['N'], ['M', 'N'], ['O']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 2,level = 1) == ['M', 'N', 'O']\n assert candidate(watchedVideos = [['Movie1', 'Movie2'], ['Movie3'], ['Movie2', 'Movie3'], ['Movie4']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 2,level = 2) == ['Movie3']\n assert candidate(watchedVideos = [['Movie1', 'Movie2'], ['Movie2', 'Movie3'], ['Movie3', 'Movie4'], ['Movie4', 'Movie5']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 2,level = 2) == ['Movie2', 'Movie3']\n assert candidate(watchedVideos = [['P', 'Q'], ['R'], ['P', 'R'], ['S']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 3,level = 1) == ['P', 'R']\n assert candidate(watchedVideos = [['X', 'Y'], ['Y', 'Z'], ['X', 'Z'], ['W']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 1,level = 1) == ['W', 'X', 'Y']\n assert candidate(watchedVideos = [['Movie1'], ['Movie2'], ['Movie3'], ['Movie4']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 2,level = 2) == ['Movie2']\n assert candidate(watchedVideos = [['A', 'B'], ['C'], ['B', 'C'], ['D']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 0,level = 2) == ['D']\n assert candidate(watchedVideos = [['Fitness', 'Yoga'], ['Yoga', 'Pilates'], ['Pilates', 'Meditation'], ['Meditation', 'TaiChi'], ['TaiChi', 'Fitness'], ['Fitness', 'Yoga']],friends = [[1, 5], [0, 2], [1, 3], [2, 4], [3, 5], [0, 4]],id = 0,level = 3) == ['Meditation', 'TaiChi']\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Horror', 'Comedy'], ['Comedy', 'Drama'], ['Drama', 'Thriller'], ['Action', 'Thriller']],friends = [[1, 3], [0, 2, 4], [1, 3], [0, 2], [1]],id = 0,level = 2) == ['Action', 'Comedy', 'Drama', 'Thriller']\n assert candidate(watchedVideos = [['Reality', 'TalkShow'], ['Reality'], ['TalkShow', 'Documentary'], ['Documentary'], ['Reality', 'TalkShow'], ['Documentary', 'Reality'], ['TalkShow']],friends = [[1, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 6], [4, 5]],id = 2,level = 2) == ['Reality', 'TalkShow']\n assert candidate(watchedVideos = [['Romance', 'Horror'], ['Romance', 'Drama'], ['Horror', 'Drama'], ['Romance'], ['Horror', 'Drama', 'Romance']],friends = [[1, 2, 3], [0, 4], [0, 3], [0, 2, 4], [1, 3]],id = 2,level = 1) == ['Horror', 'Romance']\n assert candidate(watchedVideos = [['Thriller'], ['Horror', 'Thriller'], ['Horror'], ['Comedy', 'Horror'], ['Comedy', 'Drama'], ['Drama', 'Thriller']],friends = [[1, 2, 3], [0, 2, 4], [0, 1, 4, 5], [0, 4, 5], [1, 2, 3, 5], [2, 3, 4]],id = 3,level = 3) == []\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Horror', 'Romance'], ['Romance', 'Action'], ['Action', 'Comedy'], ['Comedy', 'Thriller']],friends = [[1, 3], [0, 2, 4], [1, 3], [0, 2], [1]],id = 0,level = 2) == ['Action', 'Comedy', 'Romance', 'Thriller']\n assert candidate(watchedVideos = [['Action', 'Adventure'], ['Adventure', 'Horror'], ['Horror', 'SciFi'], ['SciFi', 'Drama'], ['Drama', 'Action'], ['Action', 'Horror'], ['Horror', 'SciFi'], ['SciFi', 'Adventure'], ['Adventure', 'Drama'], ['Drama', 'Action']],friends = [[1, 3, 5, 7], [0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [2, 4, 6, 8]],id = 4,level = 2) == ['Action', 'Drama', 'Adventure', 'Horror', 'SciFi']\n assert candidate(watchedVideos = [['Action'], ['Action', 'Adventure'], ['Action', 'Adventure', 'Comedy'], ['Action', 'Adventure', 'Comedy', 'Drama'], ['Action', 'Adventure', 'Comedy', 'Drama', 'Thriller']],friends = [[1, 2], [0, 3], [0, 3, 4], [1, 2, 4], [2, 3]],id = 3,level = 2) == ['Action']\n assert candidate(watchedVideos = [['Horror', 'Thriller'], ['Horror'], ['Thriller'], ['Horror', 'Thriller'], ['Horror'], ['Thriller', 'Comedy']],friends = [[1, 2], [0, 3], [0, 3, 4], [1, 2, 5], [2], [3]],id = 0,level = 2) == ['Thriller', 'Horror']\n assert candidate(watchedVideos = [['Adventure', 'Sci-Fi'], ['Sci-Fi', 'Animation'], ['Animation', 'Adventure'], ['Adventure', 'Drama'], ['Drama', 'Sci-Fi'], ['Sci-Fi', 'Adventure']],friends = [[1, 4], [0, 2, 5], [1, 3], [2], [0], [1]],id = 1,level = 3) == []\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Horror', 'SciFi'], ['SciFi', 'Comedy'], ['Comedy', 'Thriller'], ['Thriller', 'SciFi']],friends = [[1, 2], [0, 3], [0, 4], [1, 4], [2, 3]],id = 0,level = 2) == ['Comedy', 'SciFi', 'Thriller']\n assert candidate(watchedVideos = [['Romance', 'Drama'], ['Drama', 'Thriller'], ['Thriller', 'Horror'], ['Horror', 'Comedy'], ['Comedy', 'Romance'], ['Romance', 'Thriller']],friends = [[1, 2], [0, 3, 5], [0, 4], [1, 4], [2, 3], [1]],id = 3,level = 1) == ['Comedy', 'Drama', 'Romance', 'Thriller']\n assert candidate(watchedVideos = [['Anime', 'Cartoon'], ['Drama', 'Horror'], ['Cartoon'], ['Sci-Fi', 'Drama'], ['Horror', 'Anime']],friends = [[1, 2], [0, 3], [0, 4], [1, 4], [2, 3]],id = 0,level = 2) == ['Anime', 'Drama', 'Horror', 'Sci-Fi']\n assert candidate(watchedVideos = [['Drama', 'Romance'], ['Romance', 'Adventure'], ['Adventure', 'Thriller'], ['Thriller', 'SciFi'], ['SciFi', 'Drama'], ['Drama', 'Adventure']],friends = [[1, 5], [0, 2], [1, 3], [2, 4], [3, 5], [0, 4]],id = 3,level = 3) == ['Drama', 'Romance']\n assert candidate(watchedVideos = [['Adventure', 'Sci-Fi'], ['Action', 'Adventure'], ['Sci-Fi'], ['Drama'], ['Comedy', 'Drama']],friends = [[1, 2, 3], [0, 3, 4], [0, 3, 4], [0, 1, 2, 4], [1, 2, 3]],id = 0,level = 2) == ['Comedy', 'Drama']\n assert candidate(watchedVideos = [['Sci-Fi', 'Horror'], ['Romance'], ['Sci-Fi', 'Drama'], ['Romance', 'Sci-Fi'], ['Horror', 'Drama'], ['Comedy'], ['Drama'], ['Romance']],friends = [[1, 2, 3], [0, 4, 5], [0, 3, 6], [0, 2, 4, 7], [1, 3, 5, 7], [1, 4, 6], [2, 5], [3, 4, 7]],id = 1,level = 3) == []\n assert candidate(watchedVideos = [['MusicVideo', 'Pop'], ['Pop', 'Rock'], ['Rock', 'HipHop'], ['HipHop', 'Jazz'], ['Jazz', 'Pop'], ['Pop', 'MusicVideo']],friends = [[1, 3], [0, 2], [1, 3], [0, 2, 4], [3, 5], [4]],id = 2,level = 3) == ['MusicVideo', 'Pop']\n assert candidate(watchedVideos = [['SciFi', 'Romance'], ['Action', 'Adventure'], ['Action', 'SciFi'], ['Romance', 'Adventure'], ['SciFi', 'Drama'], ['SciFi', 'Adventure', 'Drama']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2], [2, 5], [4]],id = 2,level = 2) == ['Action', 'Adventure']\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Horror'], ['Horror', 'Thriller'], ['Action', 'Drama'], ['Action'], ['Drama', 'Thriller'], ['Drama'], ['Thriller', 'Horror'], ['Drama', 'Horror'], ['Drama', 'Action']],friends = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 2, 3, 4, 5, 6, 7, 8], [1, 0, 3, 4, 5, 6, 7, 8, 9], [1, 0, 2, 4, 5, 6, 7, 8, 9], [1, 2, 3, 0, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9], [1, 2, 3, 4, 5, 0, 7, 8, 9], [1, 2, 3, 4, 5, 6, 0, 8, 9], [1, 2, 3, 4, 5, 6, 7, 0, 9], [1, 2, 3, 4, 5, 6, 7, 8, 0]],id = 4,level = 4) == []\n assert candidate(watchedVideos = [['Documentary'], ['Documentary', 'Animation'], ['Animation', 'Horror'], ['Horror', 'Sci-Fi'], ['Sci-Fi', 'Documentary'], ['Animation', 'Sci-Fi']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2, 5], [1, 5], [3, 4]],id = 3,level = 2) == ['Sci-Fi', 'Documentary']\n assert candidate(watchedVideos = [['Fantasy', 'Comedy'], ['Fantasy'], ['Fantasy', 'Comedy'], ['Drama'], ['Fantasy', 'Drama'], ['Comedy', 'Drama']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2, 5], [2], [3]],id = 3,level = 2) == ['Comedy', 'Drama', 'Fantasy']\n assert candidate(watchedVideos = [['Adventure', 'Comedy'], ['Action', 'Adventure'], ['Comedy', 'Drama'], ['Drama'], ['Action', 'Adventure']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2], [1]],id = 1,level = 2) == ['Comedy', 'Drama']\n assert candidate(watchedVideos = [['Drama'], ['Drama', 'Drama'], ['Thriller'], ['Thriller', 'Thriller', 'Drama'], ['Thriller', 'Drama']],friends = [[1, 2], [0, 3], [0, 3, 4], [1, 2, 4], [2, 3]],id = 1,level = 3) == []\n assert candidate(watchedVideos = [['Anime', 'Cartoon'], ['Cartoon', 'Action'], ['Action', 'Adventure'], ['Adventure', 'Comedy'], ['Comedy', 'Anime']],friends = [[1, 2], [0, 3], [0, 4], [1, 4], [2, 3]],id = 1,level = 3) == []\n assert candidate(watchedVideos = [['Sci-Fi', 'Adventure'], ['Action', 'Drama'], ['Drama', 'Sci-Fi'], ['Adventure', 'Comedy'], ['Comedy', 'Action']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2], [1, 4]],id = 0,level = 2) == ['Action', 'Adventure', 'Comedy']\n assert candidate(watchedVideos = [['RealityShow', 'TalkShow'], ['TalkShow', 'Documentary'], ['Documentary', 'RealityShow'], ['RealityShow', 'Drama'], ['Drama', 'TalkShow'], ['TalkShow', 'RealityShow']],friends = [[1, 2], [0, 3], [0, 3], [1, 4], [3, 5], [1, 5]],id = 0,level = 2) == ['Drama', 'RealityShow']\n assert candidate(watchedVideos = [['Action', 'Drama'], ['Comedy', 'Romance'], ['Action', 'Comedy'], ['Romance'], ['Action', 'Romance'], ['Drama', 'Comedy']],friends = [[1, 2, 3], [0, 4], [0, 5], [0, 5], [1, 5], [2, 3, 4]],id = 0,level = 2) == ['Action', 'Comedy', 'Drama', 'Romance']\n assert candidate(watchedVideos = [['Animation', 'Comedy'], ['Comedy', 'Adventure'], ['Adventure', 'Animation'], ['Animation', 'Comedy'], ['Adventure'], ['Adventure', 'Comedy'], ['Comedy'], ['Animation', 'Adventure'], ['Comedy', 'Animation'], ['Animation', 'Adventure']],friends = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 0, 9], [0, 1, 2, 3, 4, 5, 6, 7, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8]],id = 3,level = 5) == []\n assert candidate(watchedVideos = [['Documentary', 'Biography'], ['Biography', 'Historical'], ['Historical', 'War'], ['War', 'Documentary'], ['Documentary', 'Biography'], ['Biography', 'Historical'], ['Historical', 'War'], ['War', 'Documentary']],friends = [[1, 2, 4], [0, 3, 5], [0, 4, 6], [1, 5, 7], [0, 2, 8], [1, 3, 8], [2], [3], [4, 5]],id = 0,level = 3) == ['Documentary', 'War']\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Comedy', 'Action'], ['Drama', 'Comedy'], ['Horror', 'Thriller'], ['Action', 'Drama']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2], [1, 2]],id = 0,level = 2) == ['Action', 'Drama', 'Horror', 'Thriller']\n assert candidate(watchedVideos = [['Comedy'], ['Comedy', 'Horror'], ['Horror', 'Drama'], ['Comedy', 'Drama', 'Thriller'], ['Drama', 'Thriller'], ['Drama', 'Thriller', 'Horror'], ['Horror', 'Drama', 'Comedy'], ['Horror', 'Drama', 'Comedy', 'Thriller']],friends = [[1, 3, 4], [0, 2, 5], [1, 4], [0, 5, 7], [0, 2, 6], [1, 3, 6], [4, 7], [3, 6]],id = 5,level = 3) == []\n assert candidate(watchedVideos = [['Adventure', 'Action'], ['Action', 'Comedy'], ['Comedy', 'Horror'], ['Horror', 'Drama'], ['Drama', 'Adventure']],friends = [[1, 2], [0, 3], [0, 4], [1, 4], [2, 3]],id = 4,level = 2) == ['Adventure', 'Comedy', 'Action']\n assert candidate(watchedVideos = [['Adventure', 'Action'], ['Action', 'Drama'], ['Adventure', 'Drama'], ['Drama', 'Action'], ['Adventure', 'Drama'], ['Action', 'Adventure'], ['Adventure', 'Action'], ['Drama', 'Action'], ['Action', 'Adventure'], ['Adventure', 'Drama']],friends = [[1, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 6], [4, 7], [5, 8], [6, 9], [7, 8]],id = 4,level = 4) == ['Action', 'Adventure', 'Drama']\n assert candidate(watchedVideos = [['Thriller', 'Romance'], ['Action'], ['Romance', 'Drama'], ['Drama', 'Thriller'], ['Action', 'Thriller'], ['Action', 'Romance']],friends = [[1, 2], [0, 3], [0, 4], [1, 5], [2, 5], [3, 4]],id = 1,level = 3) == ['Action', 'Thriller']\n assert candidate(watchedVideos = [['RealityShow', 'TalkShow'], ['RealityShow'], ['TalkShow'], ['RealityShow', 'TalkShow'], ['RealityShow', 'TalkShow'], ['RealityShow', 'TalkShow'], ['RealityShow', 'TalkShow'], ['RealityShow', 'TalkShow'], ['RealityShow', 'TalkShow'], ['RealityShow', 'TalkShow']],friends = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [0], [0], [0], [0], [0], [0], [0], [0], [0]],id = 0,level = 1) == ['RealityShow', 'TalkShow']\n assert candidate(watchedVideos = [['Animation', 'ShortFilm'], ['ShortFilm', 'Documentary'], ['Documentary', 'Animation'], ['Animation', 'LiveAction'], ['LiveAction', 'ShortFilm'], ['ShortFilm', 'Documentary']],friends = [[1, 5], [0, 2], [1, 3], [2, 4], [3, 5], [0, 4]],id = 3,level = 2) == ['Documentary', 'ShortFilm']\n assert candidate(watchedVideos = [['Animation', 'Comedy'], ['Animation'], ['Animation', 'Comedy'], ['Drama'], ['Comedy', 'Drama'], ['Drama']],friends = [[1, 2], [0, 3], [0, 3, 4, 5], [1, 2, 5], [2], [2, 3]],id = 2,level = 3) == []\n assert candidate(watchedVideos = [['Music', 'Documentary'], ['Documentary', 'Animation'], ['Animation', 'Music'], ['Music', 'Animation'], ['Animation', 'Music']],friends = [[1, 2, 3, 4], [0, 2, 3, 4], [0, 1, 3, 4], [0, 1, 2, 4], [0, 1, 2, 3]],id = 1,level = 3) == []\n assert candidate(watchedVideos = [['Action'], ['Action', 'Comedy'], ['Comedy'], ['Drama', 'Action'], ['Drama'], ['Action', 'Drama'], ['Action', 'Comedy'], ['Comedy', 'Drama']],friends = [[1, 2, 3], [0, 2, 3, 4], [0, 1, 5, 6], [0, 1, 6, 7], [1, 6], [2, 7], [2, 3, 4, 7], [3, 5, 6]],id = 4,level = 2) == ['Action', 'Comedy', 'Drama']\n assert candidate(watchedVideos = [['Documentary'], ['Comedy'], ['Drama'], ['Comedy'], ['Documentary'], ['Drama'], ['Comedy'], ['Documentary'], ['Drama'], ['Comedy'], ['Documentary']],friends = [[1, 2, 3], [0, 4, 5], [0, 6, 7], [0, 8, 9], [1, 10], [1], [2], [2], [3], [3], [4]],id = 4,level = 2) == ['Documentary', 'Drama']\n assert candidate(watchedVideos = [['Action', 'Horror'], ['Horror', 'Sci-Fi'], ['Action', 'Sci-Fi'], ['Sci-Fi', 'Adventure'], ['Adventure', 'Action'], ['Adventure', 'Horror']],friends = [[1, 2, 3], [0, 4], [0, 3], [0, 2, 4], [1, 3]],id = 0,level = 3) == []\n assert candidate(watchedVideos = [['SciFi', 'Adventure'], ['Adventure', 'Fantasy'], ['Fantasy', 'Mystery'], ['Mystery', 'Horror'], ['Horror', 'SciFi']],friends = [[1, 4], [0, 2], [1, 3], [2, 4], [0, 3]],id = 2,level = 2) == ['Adventure', 'Horror', 'SciFi']\n assert candidate(watchedVideos = [['Adventure', 'Animation'], ['Action', 'Adventure'], ['Animation', 'Comedy'], ['Action', 'Comedy'], ['Adventure', 'Comedy'], ['Animation', 'Action']],friends = [[1, 2, 3], [0, 4, 5], [0, 3, 5], [0, 2, 4], [1, 3, 5], [1, 2, 4]],id = 1,level = 2) == ['Action', 'Animation', 'Comedy']\n assert candidate(watchedVideos = [['SciFi', 'Romance'], ['Action', 'Adventure'], ['Action', 'SciFi'], ['Romance', 'Adventure'], ['SciFi', 'Drama']],friends = [[1, 2], [0, 3], [0, 3, 4], [1, 2], [2]],id = 0,level = 3) == []\n assert candidate(watchedVideos = [['Animation', 'Action'], ['Adventure', 'Comedy'], ['Action', 'Comedy'], ['Animation', 'Adventure'], ['Drama', 'Adventure']],friends = [[1, 3], [0, 2, 4], [1, 3], [0, 2], [1, 4]],id = 2,level = 3) == []\n assert candidate(watchedVideos = [['Reality', 'TalkShow'], ['Reality', 'Documentary'], ['TalkShow', 'Documentary'], ['Documentary'], ['Reality', 'TalkShow'], ['Documentary', 'Reality'], ['TalkShow'], ['Reality', 'Documentary'], ['TalkShow', 'Documentary']],friends = [[1, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 6], [4, 5], [6, 7], [7, 8]],id = 3,level = 3) == ['Documentary', 'Reality', 'TalkShow']\n assert candidate(watchedVideos = [['Comedy'], ['Action'], ['Romance'], ['Action', 'Romance'], ['Comedy', 'Romance'], ['Comedy', 'Action']],friends = [[1, 2, 3, 4], [0, 4, 5], [0, 5, 3], [0, 2, 5], [0, 1, 3], [1, 2, 4]],id = 2,level = 3) == []\n assert candidate(watchedVideos = [['Thriller'], ['Horror'], ['Sci-Fi'], ['Thriller', 'Horror'], ['Sci-Fi', 'Thriller'], ['Horror', 'Sci-Fi']],friends = [[1, 2], [0, 3, 4], [0, 5], [1, 5], [1, 5], [2, 3, 4]],id = 2,level = 3) == []\n assert candidate(watchedVideos = [['Romantic', 'Comedy'], ['Action', 'Adventure'], ['Drama', 'Thriller'], ['Comedy', 'Romantic'], ['Adventure', 'Action'], ['Thriller', 'Drama'], ['Romantic', 'Drama'], ['Action', 'Comedy'], ['Adventure', 'Thriller']],friends = [[1, 2, 4], [0, 3, 5], [0, 4, 6], [1, 5, 7], [0, 2, 8], [1, 3, 8], [2], [3], [4, 5]],id = 4,level = 2) == ['Action', 'Adventure', 'Romantic', 'Thriller', 'Drama']\n assert candidate(watchedVideos = [['Documentary'], ['Documentary', 'Animation'], ['Animation'], ['Documentary', 'Animation', 'Comedy'], ['Comedy', 'Action'], ['Action', 'Comedy'], ['Comedy']],friends = [[1, 2, 3], [0, 2, 4], [0, 1, 3, 5], [0, 2, 4, 5, 6], [1, 3, 5], [2, 3, 4, 6], [3, 5]],id = 1,level = 4) == []\n assert candidate(watchedVideos = [['Horror'], ['Horror', 'Thriller'], ['Thriller'], ['Horror', 'Thriller', 'Comedy'], ['Comedy', 'Action'], ['Action', 'Comedy'], ['Action', 'Comedy'], ['Comedy', 'Thriller'], ['Thriller', 'Horror']],friends = [[1, 2, 3], [0, 2, 3, 4], [0, 1, 5, 6], [0, 1, 6, 7], [1, 6], [2, 7], [2, 3, 4, 7], [3, 5, 6], [3, 7]],id = 5,level = 3) == ['Action', 'Comedy']\n assert candidate(watchedVideos = [['Horror', 'SciFi'], ['Adventure', 'SciFi'], ['Horror', 'Comedy'], ['Comedy', 'SciFi'], ['Adventure', 'Comedy']],friends = [[1, 3, 4], [0, 2], [1, 3], [0, 2, 4], [0, 3]],id = 0,level = 2) == ['Comedy', 'Horror']\n assert candidate(watchedVideos = [['Adventure', 'Action'], ['Action'], ['Adventure', 'Action'], ['Adventure'], ['Action', 'Adventure'], ['Action'], ['Adventure', 'Action'], ['Action', 'Adventure']],friends = [[1, 2, 3, 4, 5, 6, 7], [0, 2, 3, 4, 5, 6, 7], [0, 1, 3, 4, 5, 6, 7], [0, 1, 2, 4, 5, 6, 7], [0, 1, 2, 3, 5, 6, 7], [0, 1, 2, 3, 4, 6, 7], [0, 1, 2, 3, 4, 5, 7], [0, 1, 2, 3, 4, 5, 6]],id = 6,level = 3) == []\n assert candidate(watchedVideos = [['Adventure', 'Comedy'], ['Action', 'Adventure'], ['Comedy', 'Drama'], ['Drama'], ['Action', 'Adventure']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2], [1]],id = 0,level = 2) == ['Action', 'Adventure', 'Drama']\n assert candidate(watchedVideos = [['Romance'], ['Romance', 'Comedy'], ['Romance'], ['Comedy'], ['Romance', 'Action'], ['Action', 'Drama'], ['Drama', 'Action'], ['Drama'], ['Comedy', 'Romance'], ['Romance', 'Drama']],friends = [[1, 2, 3, 4], [0, 5, 6, 7, 8, 9], [0, 9, 8], [0, 5, 7], [0, 5, 8, 9], [1, 3, 4, 6, 9], [1, 5, 9], [1, 3, 9], [2, 4, 9], [2, 3, 4, 5, 6, 7]],id = 5,level = 3) == []\n assert candidate(watchedVideos = [['Action', 'Adventure'], ['Sci-Fi', 'Thriller'], ['Adventure', 'Sci-Fi'], ['Action', 'Thriller'], ['Action', 'Sci-Fi'], ['Adventure', 'Thriller'], ['Adventure', 'Sci-Fi'], ['Action', 'Adventure'], ['Action', 'Thriller'], ['Sci-Fi', 'Adventure']],friends = [[1, 2, 3], [0, 4, 5], [0, 6, 7], [0, 8, 9], [1], [1, 2], [2], [2], [3], [3, 4]],id = 2,level = 2) == ['Action', 'Sci-Fi', 'Thriller']\n"}, "metadata": {"canonical_parameter_names": ["watchedVideos", "friends", "id", "level"], "leetcode_dataset_entry_point": "Solution().watchedVideosByFriends", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def watchedVideosByFriends(self, watchedVideos: list[list[str]], friends: list[list[int]], id: int, level: int) -> list[str]:", "container": "Solution", "callable": "watchedVideosByFriends", "parameters": [{"name": "watchedVideos", "type": "list[list[str]]"}, {"name": "friends", "type": "list[list[int]]"}, {"name": "id", "type": "int"}, {"name": "level", "type": "int"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1312, "task_id": "minimum-insertion-steps-to-make-a-string-palindrome", "difficulty": "Hard", "problem_description": "Given a string s. In one step you can insert any character at any index of the string.\nReturn the minimum number of steps to make s palindrome.\nA Palindrome String is one that reads the same backward as well as forward.\n \nExample 1:\n\nInput: s = \"zzazz\"\nOutput: 0\nExplanation: The string \"zzazz\" is already palindrome we do not need any insertions.\n\nExample 2:\n\nInput: s = \"mbadm\"\nOutput: 2\nExplanation: String can be \"mbdadbm\" or \"mdbabdm\".\n\nExample 3:\n\nInput: s = \"leetcode\"\nOutput: 5\nExplanation: Inserting 5 characters the string becomes \"leetcodocteel\".\n\n \nConstraints:\n\n1 <= s.length <= 500\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"race\") == 3\n assert candidate(s = \"noon\") == 0\n assert candidate(s = \"abcba\") == 0\n assert candidate(s = \"abcdef\") == 5\n assert candidate(s = \"zzazz\") == 0\n assert candidate(s = \"google\") == 2\n assert candidate(s = \"mbadm\") == 2\n assert candidate(s = \"abcd\") == 3\n assert candidate(s = \"algorithm\") == 8\n assert candidate(s = \"leetcode\") == 5\n assert candidate(s = \"aabb\") == 2\n assert candidate(s = \"abacabadabacabadabacaba\") == 0\n assert candidate(s = \"noonappa\") == 4\n assert candidate(s = \"wasitacaroracatisawwasitacaroracatisaw\") == 0\n assert candidate(s = \"amanaplanacanalpanamanaplanacanalpanama\") == 0\n assert candidate(s = \"aaaabaaaa\") == 0\n assert candidate(s = \"aabaa\") == 0\n assert candidate(s = \"abcde\") == 4\n assert candidate(s = \"abcdabcdabcd\") == 7\n assert candidate(s = \"racecarrace\") == 3\n assert candidate(s = \"rotorlevel\") == 5\n assert candidate(s = \"flzxrpfr\") == 5\n assert candidate(s = \"geeksforgeeks\") == 8\n assert candidate(s = \"abcdefghijklijklkjihgfedcba\") == 2\n assert candidate(s = \"aaaaabbbbb\") == 5\n assert candidate(s = \"flasflasflas\") == 7\n assert candidate(s = \"abcdefghikjlmnopqrstuvwxyzzyxwvutnmlkjihgfedcba\") == 7\n assert candidate(s = \"noonnoonnoonnoon\") == 0\n assert candidate(s = \"mississippimississippi\") == 6\n assert candidate(s = \"jglkhflhfl\") == 5\n assert candidate(s = \"abca\") == 1\n assert candidate(s = \"verylongstringthatneedsmanyinsertionstopalindrome\") == 27\n assert candidate(s = \"bananaananabanana\") == 2\n assert candidate(s = \"abcdxyzzyxwvutrdcba\") == 5\n assert candidate(s = \"abcdxyzzyxdcba\") == 0\n assert candidate(s = \"qzihxknhzvqt\") == 5\n assert candidate(s = \"triplepletriple\") == 10\n assert candidate(s = \"xyxzzxyxyxyxyxyx\") == 3\n assert candidate(s = \"abcdbca\") == 2\n assert candidate(s = \"kayak\") == 0\n assert candidate(s = \"flrif\") == 2\n assert candidate(s = \"abcdefghijjiuhgfedcba\") == 1\n assert candidate(s = \"aabaaabaabaaa\") == 2\n assert candidate(s = \"pqrstuabutsrqp\") == 1\n assert candidate(s = \"xyxz\") == 1\n assert candidate(s = \"abcda\") == 2\n assert candidate(s = \"ababababababab\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"abababababa\") == 0\n assert candidate(s = \"deeee\") == 1\n assert candidate(s = \"abcbabc\") == 2\n assert candidate(s = \"abcdefedcbafedcba\") == 4\n assert candidate(s = \"randomstring\") == 9\n assert candidate(s = \"thisisaverylongstringthatneedsmuchinsertionstobecomeapalindrome\") == 42\n assert candidate(s = \"abbaabbaba\") == 2\n assert candidate(s = \"wasitacaroracatisaw\") == 0\n assert candidate(s = \"trinitrotoluene\") == 8\n assert candidate(s = \"xyxxyxyxyxyx\") == 1\n assert candidate(s = \"aibohphobia\") == 0\n assert candidate(s = \"abcdefedcba\") == 0\n assert candidate(s = \"level\") == 0\n assert candidate(s = \"aabbccdd\") == 6\n assert candidate(s = \"stats\") == 0\n assert candidate(s = \"levellevellevel\") == 0\n assert candidate(s = \"fdlhdlf\") == 2\n assert candidate(s = \"abccbaabc\") == 3\n assert candidate(s = \"abababab\") == 1\n assert candidate(s = \"abacaxabaycabacaxaba\") == 5\n assert candidate(s = \"radar\") == 0\n assert candidate(s = \"xyxzxy\") == 1\n assert candidate(s = \"abacabadabacaba\") == 0\n assert candidate(s = \"pwwkew\") == 3\n assert candidate(s = \"redivider\") == 0\n assert candidate(s = \"abcdabcd\") == 5\n assert candidate(s = \"banana\") == 1\n assert candidate(s = \"noonnoonnoonnoonnoon\") == 0\n assert candidate(s = \"anana\") == 0\n assert candidate(s = \"noonabbada\") == 6\n assert candidate(s = \"agbdba\") == 1\n assert candidate(s = \"ananana\") == 0\n assert candidate(s = \"detartrated\") == 0\n assert candidate(s = \"abcdedcbaabcdedcba\") == 0\n assert candidate(s = \"hellohello\") == 5\n assert candidate(s = \"abccba\") == 0\n assert candidate(s = \"aabbccddeeff\") == 10\n assert candidate(s = \"xyxzxyxyyzz\") == 4\n assert candidate(s = \"madamimadam\") == 0\n assert candidate(s = \"abcdefghikjlmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 2\n assert candidate(s = \"bbbbabc\") == 2\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 50\n assert candidate(s = \"cabbbbb\") == 2\n assert candidate(s = \"amanaplanacanalpanama\") == 0\n assert candidate(s = \"aebcbda\") == 2\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(s = \"abcdefg\") == 6\n assert candidate(s = \"zyelkx\") == 5\n assert candidate(s = \"aaaaabbbbbaaaaa\") == 0\n assert candidate(s = \"abbbbac\") == 1\n assert candidate(s = \"abcbbbb\") == 2\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"noonoonnoon\") == 1\n assert candidate(s = \"repaper\") == 0\n assert candidate(s = \"xyzxyz\") == 3\n assert candidate(s = \"abcdedcba\") == 0\n assert candidate(s = \"mamad\") == 2\n assert candidate(s = \"noonhighnoon\") == 1\n assert candidate(s = \"abacdfgdcaba\") == 1\n assert candidate(s = \"abcabc\") == 3\n assert candidate(s = \"rotor\") == 0\n assert candidate(s = \"abcdefghihgfedcba\") == 0\n assert candidate(s = \"racecar\") == 0\n assert candidate(s = \"racecarrracecar\") == 0\n assert candidate(s = \"madamimadamimadam\") == 0\n assert candidate(s = \"aabbccddeeefff\") == 11\n assert candidate(s = \"xyzyxyzyx\") == 0\n assert candidate(s = \"aabbcc\") == 4\n assert candidate(s = \"mississippi\") == 4\n assert candidate(s = \"flamingo\") == 7\n assert candidate(s = \"zxcvbnmasdfghjkloiuytrewq\") == 24\n assert candidate(s = \"amcelkpal\") == 6\n assert candidate(s = \"abbababa\") == 1\n assert candidate(s = \"aaabaaaa\") == 1\n assert candidate(s = \"abcdabcda\") == 4\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minInsertions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minInsertions(self, s: str) -> int:", "container": "Solution", "callable": "minInsertions", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1313, "task_id": "decompress-run-length-encoded-list", "difficulty": "Easy", "problem_description": "We are given a list nums of integers representing a list compressed with run-length encoding.\nConsider each adjacent pair of elements [freq, val] = [nums[2*i], nums[2*i+1]] (with i >= 0).  For each such pair, there are freq elements with value val concatenated in a sublist. Concatenate all the sublists from left to right to generate the decompressed list.\nReturn the decompressed list.\n \nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: [2,4,4,4]\nExplanation: The first pair [1,2] means we have freq = 1 and val = 2 so we generate the array [2].\nThe second pair [3,4] means we have freq = 3 and val = 4 so we generate [4,4,4].\nAt the end the concatenation [2] + [4,4,4] is [2,4,4,4].\n\nExample 2:\n\nInput: nums = [1,1,2,3]\nOutput: [1,3,3]\n\n \nConstraints:\n\n2 <= nums.length <= 100\nnums.length % 2 == 0\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 9, 2, 8, 3, 7]) == [9, 8, 8, 7, 7, 7]\n assert candidate(nums = [3, 1, 2, 2]) == [1, 1, 1, 2, 2]\n assert candidate(nums = [2, 5, 3, 1]) == [5, 5, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4]) == [2, 4, 4, 4]\n assert candidate(nums = [2, 5, 3, 7]) == [5, 5, 7, 7, 7]\n assert candidate(nums = [2, 5, 3, 6]) == [5, 5, 6, 6, 6]\n assert candidate(nums = [10, 1, 5, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]\n assert candidate(nums = [4, 6, 2, 7]) == [6, 6, 6, 6, 7, 7]\n assert candidate(nums = [5, 10, 3, 20]) == [10, 10, 10, 10, 10, 20, 20, 20]\n assert candidate(nums = [4, 8, 1, 6]) == [8, 8, 8, 8, 6]\n assert candidate(nums = [1, 1, 2, 3]) == [1, 3, 3]\n assert candidate(nums = [1, 9, 3, 8, 2, 4]) == [9, 8, 8, 8, 4, 4]\n assert candidate(nums = [4, 7, 1, 2]) == [7, 7, 7, 7, 2]\n assert candidate(nums = [1, 9, 1, 8, 1, 7, 1, 6, 1, 5, 1, 4, 1, 3, 1, 2, 1, 1]) == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [2, 5, 4, 1]) == [5, 5, 1, 1, 1, 1]\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [99, 99, 1, 1]) == [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 1]\n assert candidate(nums = [7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]\n assert candidate(nums = [1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10, 90, 11, 89, 12, 88, 13, 87, 14, 86, 15, 85, 16, 84, 17, 83, 18, 82, 19, 81, 20, 80]) == [99, 98, 98, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 95, 95, 94, 94, 94, 94, 94, 94, 93, 93, 93, 93, 93, 93, 93, 92, 92, 92, 92, 92, 92, 92, 92, 91, 91, 91, 91, 91, 91, 91, 91, 91, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80]\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == [2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == [100, 99, 99, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 96]\n assert candidate(nums = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10]\n assert candidate(nums = [30, 10, 20, 20, 10, 30, 5, 5]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 5, 5, 5, 5, 5]\n assert candidate(nums = [2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [2, 3, 3, 2, 2, 3, 3, 2]) == [3, 3, 2, 2, 2, 3, 3, 2, 2, 2]\n assert candidate(nums = [5, 5, 10, 10, 15, 15]) == [5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]\n assert candidate(nums = [10, 5, 6, 3, 2, 8, 9, 1]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 3, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6]) == [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [2, 50, 3, 40, 4, 30, 5, 20, 6, 10]) == [50, 50, 40, 40, 40, 30, 30, 30, 30, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == [3, 3, 7, 7, 7, 7, 7, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53]\n assert candidate(nums = [7, 1, 3, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]\n assert candidate(nums = [1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1, 19, 1, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [2, 2, 2, 4, 2, 6, 2, 8, 2, 10, 2, 12, 2, 14, 2, 16, 2, 18, 2, 20, 2, 22, 2, 24, 2, 26, 2, 28, 2, 30]) == [2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30]\n assert candidate(nums = [10, 5, 3, 6, 7, 1]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [2, 2, 2, 2, 2, 2]\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1, 19, 1, 20]) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10]) == [2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [99, 1, 1, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]\n assert candidate(nums = [10, 5, 3, 3, 7, 2]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4]) == [1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [5, 10, 4, 20, 3, 30, 2, 40, 1, 50]) == [10, 10, 10, 10, 10, 20, 20, 20, 20, 30, 30, 30, 40, 40, 50]\n assert candidate(nums = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [8, 1, 7, 2, 6, 3, 5, 4, 4, 5, 3, 6, 2, 7, 1, 8]) == [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8]\n assert candidate(nums = [7, 1, 7, 2, 7, 3, 7, 4, 7, 5, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [99, 1, 1, 99]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 99]\n assert candidate(nums = [33, 3, 33, 3, 33, 3, 33, 3, 33, 3]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [50, 1, 50, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20]) == [3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97]) == [100, 99, 99, 98, 98, 98, 97, 97, 97, 97]\n assert candidate(nums = [25, 9, 15, 3, 5, 8]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 8, 8, 8, 8, 8]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [10, 5, 3, 2, 7, 9]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [100, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, 5, 3, 1, 7, 2, 6, 9]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [5, 10, 3, 20, 7, 30]) == [10, 10, 10, 10, 10, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30]\n assert candidate(nums = [5, 5, 3, 3, 2, 2, 1, 1]) == [5, 5, 5, 5, 5, 3, 3, 3, 2, 2, 1]\n assert candidate(nums = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == [100, 99, 99, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 96, 95, 95, 95, 95, 95, 95, 94, 94, 94, 94, 94, 94, 94, 93, 93, 93, 93, 93, 93, 93, 93, 92, 92, 92, 92, 92, 92, 92, 92, 92, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91]\n assert candidate(nums = [1, 1, 1, 2, 1, 3, 1, 4, 1, 5]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [2, 1, 3, 2, 2, 3, 4, 4, 10, 5, 20, 6]) == [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [10, 5, 6, 3, 2, 9, 1, 8]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 3, 9, 9, 8]\n assert candidate(nums = [33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [25, 1, 25, 2, 25, 3, 25, 4, 25, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]\n assert candidate(nums = [7, 1, 6, 2, 5, 3, 4, 4, 3, 5]) == [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5]\n assert candidate(nums = [100, 1, 1, 100]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100]\n assert candidate(nums = [20, 1, 15, 2, 10, 3, 5, 4, 3, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(nums = [5, 10, 3, 20, 1, 30]) == [10, 10, 10, 10, 10, 20, 20, 20, 30]\n assert candidate(nums = [20, 30, 10, 40, 5, 50, 2, 60]) == [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60]\n assert candidate(nums = [3, 3, 2, 2, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [3, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93]) == [100, 99, 99, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 96, 95, 95, 95, 95, 95, 95, 94, 94, 94, 94, 94, 94, 94, 93, 93, 93, 93, 93, 93, 93, 93]\n assert candidate(nums = [2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, 5, 8, 15, 6, 25]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 15, 15, 15, 15, 15, 15, 15, 15, 25, 25, 25, 25, 25, 25]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == [3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]\n assert candidate(nums = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20]) == [2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 4, 4, 4, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 1, 1]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().decompressRLElist", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def decompressRLElist(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "decompressRLElist", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1314, "task_id": "matrix-block-sum", "difficulty": "Medium", "problem_description": "Given a m x n matrix mat and an integer k, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for:\n\ni - k <= r <= i + k,\nj - k <= c <= j + k, and\n(r, c) is a valid position in the matrix.\n\n \nExample 1:\n\nInput: mat = [[1,2,3],[4,5,6],[7,8,9]], k = 1\nOutput: [[12,21,16],[27,45,33],[24,39,28]]\n\nExample 2:\n\nInput: mat = [[1,2,3],[4,5,6],[7,8,9]], k = 2\nOutput: [[45,45,45],[45,45,45],[45,45,45]]\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n1 <= m, n, k <= 100\n1 <= mat[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 2) == [[45, 45, 45], [45, 45, 45], [45, 45, 45]]\n assert candidate(mat = [[5, 10, 15], [20, 25, 30], [35, 40, 45]],k = 0) == [[5, 10, 15], [20, 25, 30], [35, 40, 45]]\n assert candidate(mat = [[1, 2], [3, 4]],k = 1) == [[10, 10], [10, 10]]\n assert candidate(mat = [[5, 6, 7], [8, 9, 10], [11, 12, 13]],k = 0) == [[5, 6, 7], [8, 9, 10], [11, 12, 13]]\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],k = 1) == [[4, 6, 4], [6, 9, 6], [4, 6, 4]]\n assert candidate(mat = [[5]],k = 1) == [[5]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 1) == [[12, 21, 16], [27, 45, 33], [24, 39, 28]]\n assert candidate(mat = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],k = 0) == [[10, 20, 30], [40, 50, 60], [70, 80, 90]]\n assert candidate(mat = [[5]],k = 0) == [[5]]\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],k = 5) == [[9, 9, 9], [9, 9, 9], [9, 9, 9]]\n assert candidate(mat = [[2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]],k = 0) == [[2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]]\n assert candidate(mat = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]],k = 3) == [[80, 100, 120, 120, 100, 80], [100, 125, 150, 150, 125, 100], [120, 150, 180, 180, 150, 120], [120, 150, 180, 180, 150, 120], [100, 125, 150, 150, 125, 100], [80, 100, 120, 120, 100, 80]]\n assert candidate(mat = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 19, 18, 17, 16, 15, 14, 13, 12]],k = 2) == [[69, 94, 120, 125, 130, 135, 140, 114, 87], [126, 168, 210, 210, 210, 210, 210, 168, 126], [126, 168, 210, 210, 210, 210, 210, 168, 126], [102, 138, 175, 180, 185, 190, 195, 158, 120]]\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],k = 1) == [[4, 6, 4], [6, 9, 6], [6, 9, 6], [6, 9, 6], [4, 6, 4]]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60], [70, 80, 90, 100, 110, 120], [130, 140, 150, 160, 170, 180], [190, 200, 210, 220, 230, 240], [250, 260, 270, 280, 290, 300]],k = 2) == [[720, 1020, 1350, 1500, 1260, 990], [1320, 1840, 2400, 2600, 2160, 1680], [2100, 2900, 3750, 4000, 3300, 2550], [2040, 2800, 3600, 3800, 3120, 2400], [1800, 2460, 3150, 3300, 2700, 2070]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 2) == [[63, 90, 120, 102, 81], [114, 160, 210, 176, 138], [180, 250, 325, 270, 210], [174, 240, 310, 256, 198], [153, 210, 270, 222, 171]]\n assert candidate(mat = [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]],k = 0) == [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],k = 0) == [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]\n assert candidate(mat = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60], [65, 70, 75, 80]],k = 3) == [[680, 680, 680, 680], [680, 680, 680, 680], [680, 680, 680, 680], [680, 680, 680, 680]]\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20]],k = 2) == [[60, 92, 130, 116, 96], [102, 152, 210, 184, 150], [102, 152, 210, 184, 150], [93, 136, 185, 160, 129]]\n assert candidate(mat = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]],k = 3) == [[64, 64, 64, 64], [64, 64, 64, 64], [64, 64, 64, 64], [64, 64, 64, 64]]\n assert candidate(mat = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],k = 1) == [[4, 4], [6, 6], [6, 6], [6, 6], [6, 6], [4, 4]]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == [[16, 20, 24, 28, 28, 28, 24, 20, 16], [20, 25, 30, 35, 35, 35, 30, 25, 20], [24, 30, 36, 42, 42, 42, 36, 30, 24], [28, 35, 42, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 42, 35, 28], [24, 30, 36, 42, 42, 42, 36, 30, 24], [20, 25, 30, 35, 35, 35, 30, 25, 20], [16, 20, 24, 28, 28, 28, 24, 20, 16]]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 2) == [[9, 12, 12, 9], [12, 16, 16, 12], [15, 20, 20, 15], [12, 16, 16, 12], [9, 12, 12, 9]]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60], [70, 80, 90, 100, 110, 120], [130, 140, 150, 160, 170, 180], [190, 200, 210, 220, 230, 240], [250, 260, 270, 280, 290, 300], [310, 320, 330, 340, 350, 360]],k = 1) == [[180, 300, 360, 420, 480, 340], [450, 720, 810, 900, 990, 690], [810, 1260, 1350, 1440, 1530, 1050], [1170, 1800, 1890, 1980, 2070, 1410], [1530, 2340, 2430, 2520, 2610, 1770], [1140, 1740, 1800, 1860, 1920, 1300]]\n assert candidate(mat = [[3, 0, 1, 4, 2], [5, 6, 3, 2, 1], [1, 2, 0, 1, 5], [4, 1, 0, 1, 7], [1, 0, 3, 0, 5]],k = 1) == [[14, 18, 16, 13, 9], [17, 21, 19, 19, 15], [19, 22, 16, 20, 17], [9, 12, 8, 22, 19], [6, 9, 5, 16, 13]]\n assert candidate(mat = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]],k = 1) == [[140, 240, 300, 220], [330, 540, 630, 450], [570, 900, 990, 690], [460, 720, 780, 540]]\n assert candidate(mat = [[2, 1, 3, 4], [1, 2, 2, 1], [3, 3, 2, 4], [4, 1, 5, 4]],k = 1) == [[6, 11, 13, 10], [12, 19, 22, 16], [14, 23, 24, 18], [11, 18, 19, 15]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 3) == [[45, 45, 45], [45, 45, 45], [45, 45, 45]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8]],k = 0) == [[1, 2], [3, 4], [5, 6], [7, 8]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 1) == [[12, 21, 16], [27, 45, 33], [45, 72, 51], [63, 99, 69], [48, 75, 52]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 2) == [[63, 90, 120, 102, 81], [114, 160, 210, 176, 138], [180, 250, 325, 270, 210], [174, 240, 310, 256, 198], [153, 210, 270, 222, 171]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 1) == [[16, 27, 33, 39, 28], [39, 63, 72, 81, 57], [69, 108, 117, 126, 87], [99, 153, 162, 171, 117], [76, 117, 123, 129, 88]]\n assert candidate(mat = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]],k = 1) == [[20, 30, 30, 30, 20], [30, 45, 45, 45, 30], [30, 45, 45, 45, 30], [30, 45, 45, 45, 30], [20, 30, 30, 30, 20]]\n assert candidate(mat = [[1, 3, 1], [1, 5, 1], [4, 2, 4]],k = 2) == [[22, 22, 22], [22, 22, 22], [22, 22, 22]]\n assert candidate(mat = [[100, 200], [300, 400], [500, 600]],k = 1) == [[1000, 1000], [2100, 2100], [1800, 1800]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 1) == [[26, 42, 48, 54, 60, 66, 72, 78, 84, 58], [69, 108, 117, 126, 135, 144, 153, 162, 171, 117], [66, 102, 108, 114, 120, 126, 132, 138, 144, 98]]\n assert candidate(mat = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30], [32, 34, 36, 38, 40], [42, 44, 46, 48, 50]],k = 2) == [[126, 180, 240, 204, 162], [228, 320, 420, 352, 276], [360, 500, 650, 540, 420], [348, 480, 620, 512, 396], [306, 420, 540, 444, 342]]\n assert candidate(mat = [[100, 99, 98, 97, 96, 95], [94, 93, 92, 91, 90, 89], [88, 87, 86, 85, 84, 83], [82, 81, 80, 79, 78, 77], [76, 75, 74, 73, 72, 71]],k = 2) == [[837, 1110, 1380, 1365, 1086, 810], [1080, 1432, 1780, 1760, 1400, 1044], [1305, 1730, 2150, 2125, 1690, 1260], [1008, 1336, 1660, 1640, 1304, 972], [729, 966, 1200, 1185, 942, 702]]\n assert candidate(mat = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]],k = 2) == [[27, 42, 42, 36], [42, 64, 64, 54], [42, 64, 64, 54], [36, 54, 54, 45]]\n assert candidate(mat = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]],k = 1) == [[20, 30, 30, 30, 30, 20], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [20, 30, 30, 30, 30, 20]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35]],k = 2) == [[81, 114, 150, 165, 180, 150, 117], [150, 208, 270, 290, 310, 256, 198], [240, 330, 425, 450, 475, 390, 300], [234, 320, 410, 430, 450, 368, 282], [207, 282, 360, 375, 390, 318, 243]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]],k = 3) == [[280, 360, 444, 532, 560, 588, 616, 540, 460, 376], [280, 360, 444, 532, 560, 588, 616, 540, 460, 376], [280, 360, 444, 532, 560, 588, 616, 540, 460, 376], [280, 360, 444, 532, 560, 588, 616, 540, 460, 376]]\n assert candidate(mat = [[5, 4, 3, 2, 1], [10, 9, 8, 7, 6], [15, 14, 13, 12, 11], [20, 19, 18, 17, 16], [25, 24, 23, 22, 21]],k = 2) == [[81, 102, 120, 90, 63], [138, 176, 210, 160, 114], [210, 270, 325, 250, 180], [198, 256, 310, 240, 174], [171, 222, 270, 210, 153]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 3) == [[160, 210, 210, 210, 176], [160, 210, 210, 210, 176], [160, 210, 210, 210, 176], [160, 210, 210, 210, 176]]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 3) == [[16, 16, 16, 16], [16, 16, 16, 16], [16, 16, 16, 16], [16, 16, 16, 16]]\n assert candidate(mat = [[9, 2, 3, 4, 6], [7, 1, 8, 5, 3], [6, 5, 4, 7, 9], [2, 3, 1, 4, 5], [8, 6, 7, 2, 3]],k = 1) == [[19, 30, 23, 29, 18], [30, 45, 39, 49, 34], [24, 37, 38, 46, 33], [30, 42, 39, 42, 30], [19, 27, 23, 22, 14]]\n assert candidate(mat = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60]],k = 2) == [[270, 390, 390, 315], [270, 390, 390, 315], [270, 390, 390, 315]]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == [[16, 20, 24, 28, 28, 28, 28, 24, 20, 16], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [24, 30, 36, 42, 42, 42, 42, 36, 30, 24], [28, 35, 42, 49, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 49, 42, 35, 28], [24, 30, 36, 42, 42, 42, 42, 36, 30, 24], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [16, 20, 24, 28, 28, 28, 28, 24, 20, 16]]\n assert candidate(mat = [[3, 6, 9, 12, 15], [18, 21, 24, 27, 30], [33, 36, 39, 42, 45], [48, 51, 54, 57, 60], [63, 66, 69, 72, 75]],k = 1) == [[48, 81, 99, 117, 84], [117, 189, 216, 243, 171], [207, 324, 351, 378, 261], [297, 459, 486, 513, 351], [228, 351, 369, 387, 264]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24]],k = 2) == [[72, 102, 135, 150, 126, 99], [132, 184, 240, 260, 216, 168], [132, 184, 240, 260, 216, 168], [126, 174, 225, 240, 198, 153]]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == [[16, 20, 24, 28, 28, 28, 28, 24, 20, 16], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [16, 20, 24, 28, 28, 28, 28, 24, 20, 16]]\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 2) == [[9, 12, 15, 12, 9], [12, 16, 20, 16, 12], [15, 20, 25, 20, 15], [12, 16, 20, 16, 12], [9, 12, 15, 12, 9]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 0) == [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]\n assert candidate(mat = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]],k = 1) == [[140, 240, 300, 220], [330, 540, 630, 450], [570, 900, 990, 690], [460, 720, 780, 540]]\n assert candidate(mat = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]],k = 0) == [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10], [6, 7, 8, 9, 10, 11]],k = 1) == [[8, 15, 21, 27, 33, 24], [15, 27, 36, 45, 54, 39], [21, 36, 45, 54, 63, 45], [27, 45, 54, 63, 72, 51], [33, 54, 63, 72, 81, 57], [24, 39, 45, 51, 57, 40]]\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]],k = 3) == [[88, 130, 130, 130, 120], [120, 175, 175, 175, 160], [120, 175, 175, 175, 160], [120, 175, 175, 175, 160], [104, 150, 150, 150, 136]]\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 3) == [[16, 20, 20, 20, 16], [20, 25, 25, 25, 20], [20, 25, 25, 25, 20], [20, 25, 25, 25, 20], [16, 20, 20, 20, 16]]\n assert candidate(mat = [[100, 200, 300, 400, 500], [600, 700, 800, 900, 1000], [1100, 1200, 1300, 1400, 1500], [1600, 1700, 1800, 1900, 2000]],k = 3) == [[16000, 21000, 21000, 21000, 17600], [16000, 21000, 21000, 21000, 17600], [16000, 21000, 21000, 21000, 17600], [16000, 21000, 21000, 21000, 17600]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],k = 1) == [[10, 10], [21, 21], [33, 33], [45, 45], [57, 57], [42, 42]]\n assert candidate(mat = [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23], [25, 27, 29, 31]],k = 2) == [[99, 144, 144, 117], [180, 256, 256, 204], [180, 256, 256, 204], [171, 240, 240, 189]]\n assert candidate(mat = [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23], [25, 27, 29, 31]],k = 1) == [[24, 42, 54, 40], [60, 99, 117, 84], [108, 171, 189, 132], [88, 138, 150, 104]]\n assert candidate(mat = [[5, 3, 2, 4, 1], [3, 7, 8, 6, 2], [9, 1, 0, 5, 7], [4, 6, 3, 8, 9], [0, 2, 5, 3, 1]],k = 1) == [[18, 28, 30, 23, 13], [28, 38, 36, 35, 25], [30, 41, 44, 48, 37], [22, 30, 33, 41, 33], [12, 20, 27, 29, 21]]\n assert candidate(mat = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]],k = 0) == [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 3) == [[136, 136, 136, 136], [136, 136, 136, 136], [136, 136, 136, 136], [136, 136, 136, 136]]\n assert candidate(mat = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]],k = 1) == [[20, 30, 30, 30, 30, 20], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [20, 30, 30, 30, 30, 20]]\n assert candidate(mat = [[9, 8, 7], [6, 5, 4], [3, 2, 1]],k = 2) == [[45, 45, 45], [45, 45, 45], [45, 45, 45]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 1) == [[16, 27, 33, 39, 28], [39, 63, 72, 81, 57], [69, 108, 117, 126, 87], [56, 87, 93, 99, 68]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]],k = 4) == [[575, 705, 840, 980, 1125, 1170, 1060, 945, 825, 700], [840, 1026, 1218, 1416, 1620, 1674, 1512, 1344, 1170, 990], [1155, 1407, 1666, 1932, 2205, 2268, 2044, 1813, 1575, 1330], [1520, 1848, 2184, 2528, 2880, 2952, 2656, 2352, 2040, 1720], [1935, 2349, 2772, 3204, 3645, 3726, 3348, 2961, 2565, 2160], [2385, 2889, 3402, 3924, 4455, 4536, 4068, 3591, 3105, 2610], [2320, 2808, 3304, 3808, 4320, 4392, 3936, 3472, 3000, 2520], [2205, 2667, 3136, 3612, 4095, 4158, 3724, 3283, 2835, 2380], [2040, 2466, 2898, 3336, 3780, 3834, 3432, 3024, 2610, 2190], [1825, 2205, 2590, 2980, 3375, 3420, 3060, 2695, 2325, 1950]]\n assert candidate(mat = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30], [32, 34, 36, 38, 40]],k = 2) == [[126, 180, 240, 204, 162], [228, 320, 420, 352, 276], [228, 320, 420, 352, 276], [216, 300, 390, 324, 252]]\n assert candidate(mat = [[3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3]],k = 2) == [[27, 36, 36, 27], [36, 48, 48, 36], [36, 48, 48, 36], [27, 36, 36, 27]]\n assert candidate(mat = [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200], [1300, 1400, 1500]],k = 0) == [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200], [1300, 1400, 1500]]\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 2) == [[9, 12, 15, 12, 9], [12, 16, 20, 16, 12], [15, 20, 25, 20, 15], [12, 16, 20, 16, 12], [9, 12, 15, 12, 9]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],k = 2) == [[45, 45, 45], [78, 78, 78], [120, 120, 120], [165, 165, 165], [150, 150, 150], [126, 126, 126]]\n assert candidate(mat = [[2, 1, 3], [1, 1, 1], [3, 2, 1]],k = 2) == [[15, 15, 15], [15, 15, 15], [15, 15, 15]]\n assert candidate(mat = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [110, 120, 130, 140, 150], [160, 170, 180, 190, 200], [210, 220, 230, 240, 250]],k = 1) == [[160, 270, 330, 390, 280], [390, 630, 720, 810, 570], [690, 1080, 1170, 1260, 870], [990, 1530, 1620, 1710, 1170], [760, 1170, 1230, 1290, 880]]\n assert candidate(mat = [[100, 200, 300], [400, 500, 600], [700, 800, 900]],k = 1) == [[1200, 2100, 1600], [2700, 4500, 3300], [2400, 3900, 2800]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],k = 1) == [[12, 21, 16], [27, 45, 33], [45, 72, 51], [36, 57, 40]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]],k = 1) == [[18, 30, 36, 42, 48, 34], [45, 72, 81, 90, 99, 69], [81, 126, 135, 144, 153, 105], [117, 180, 189, 198, 207, 141], [90, 138, 144, 150, 156, 106]]\n assert candidate(mat = [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 12, 13], [14, 15, 16]],k = 2) == [[54, 54, 54], [90, 90, 90], [135, 135, 135], [126, 126, 126], [108, 108, 108]]\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 0) == [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 1) == [[4, 6, 6, 6, 4], [6, 9, 9, 9, 6], [6, 9, 9, 9, 6], [6, 9, 9, 9, 6], [4, 6, 6, 6, 4]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],k = 1) == [[12, 21, 16], [27, 45, 33], [45, 72, 51], [63, 99, 69], [81, 126, 87], [60, 93, 64]]\n assert candidate(mat = [[2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31], [32, 33, 34, 35, 36, 37]],k = 2) == [[81, 114, 150, 165, 138, 108], [144, 200, 260, 280, 232, 180], [225, 310, 400, 425, 350, 270], [315, 430, 550, 575, 470, 360], [288, 392, 500, 520, 424, 324], [243, 330, 420, 435, 354, 270]]\n assert candidate(mat = [[3, 0, 1, 4, 2], [5, 6, 3, 2, 1], [1, 2, 0, 1, 5], [4, 1, 0, 1, 7], [1, 0, 3, 0, 5]],k = 2) == [[21, 28, 36, 27, 19], [26, 34, 49, 36, 27], [30, 38, 58, 44, 35], [26, 30, 48, 37, 28], [12, 14, 31, 25, 22]]\n assert candidate(mat = [[20, 30, 40, 50, 60], [70, 80, 90, 100, 110], [120, 130, 140, 150, 160], [170, 180, 190, 200, 210], [220, 230, 240, 250, 260]],k = 2) == [[720, 1020, 1350, 1140, 900], [1260, 1760, 2300, 1920, 1500], [1950, 2700, 3500, 2900, 2250], [1860, 2560, 3300, 2720, 2100], [1620, 2220, 2850, 2340, 1800]]\n assert candidate(mat = [[5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5]],k = 2) == [[45, 60, 75, 75, 75, 60, 45], [60, 80, 100, 100, 100, 80, 60], [60, 80, 100, 100, 100, 80, 60], [45, 60, 75, 75, 75, 60, 45]]\n"}, "metadata": {"canonical_parameter_names": ["mat", "k"], "leetcode_dataset_entry_point": "Solution().matrixBlockSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def matrixBlockSum(self, mat: list[list[int]], k: int) -> list[list[int]]:", "container": "Solution", "callable": "matrixBlockSum", "parameters": [{"name": "mat", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1315, "task_id": "sum-of-nodes-with-even-valued-grandparent", "difficulty": "Medium", "problem_description": "Given the root of a binary tree, return the sum of values of nodes with an even-valued grandparent. If there are no nodes with an even-valued grandparent, return 0.\nA grandparent of a node is the parent of its parent if it exists.\n \nExample 1:\n\n\nInput: root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5]\nOutput: 18\nExplanation: The red nodes are the nodes with even-value grandparent while the blue nodes are the even-value grandparents.\n\nExample 2:\n\n\nInput: root = [1]\nOutput: 0\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 104].\n1 <= Node.val <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([8, 4, 5, 0, 1, None, None, None, None, 7])) == 8\n assert candidate(root = tree_node([4, 2, 7, 1, 3, 6, 9, 8, None, None, None, None, 5])) == 27\n assert candidate(root = tree_node([4, 2, 5, 1, 3, None, 7, None, None, None, None, None, 9])) == 11\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 38\n assert candidate(root = tree_node([2, 1, 3, None, None, 4, None, None, None, 5])) == 4\n assert candidate(root = tree_node([5, 14, 3, None, 10, None, 7])) == 0\n assert candidate(root = tree_node([2, 1, 3, None, None, 4, 5, 6, 7])) == 9\n assert candidate(root = tree_node([5, 3, 1, 4, None, 2, 6, 8, None, None, None, None, 7])) == 0\n assert candidate(root = tree_node([2, None, 3, None, 4, None, 5])) == 4\n assert candidate(root = tree_node([11, 10, 12, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == 15\n assert candidate(root = tree_node([6, 7, 8, 2, 7, 1, 3, 9, None, 1, 4, None, None, None, 5])) == 18\n assert candidate(root = tree_node([4, 2, 7, 1, 3, 6, 9])) == 19\n assert candidate(root = tree_node([6, 11, 1, None, None, 2, None, None, 3, None, None, 4, None, None, 5, None, None, 6, None, None, 7, None, None, 8, None, None, 9, None, None, 10, None, None, 11, None, None, 12, None, None, 13, None, None, 14, None, None, 15, None, None, 16, None, None, 17, None, None, 18, None, None, 19, None, None, 20, None, None, 21, None, None, 22, None, None, 23, None, None, 24, None, None, 25, None, None, 26, None, None, 27, None, None, 28, None, None, 29, None, None, 30])) == 2\n assert candidate(root = tree_node([1])) == 0\n assert candidate(root = tree_node([2, 3, 4, 5, 6, 7, 8])) == 26\n assert candidate(root = tree_node([5, 3, 7, 2, 4, 6, 8, 1, None, None, None, None, None, None, 9])) == 0\n assert candidate(root = tree_node([3, None, 9, 6, None, 10, 11, 2, None, None, None, 8, None, 7])) == 17\n assert candidate(root = tree_node([3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45])) == 114\n assert candidate(root = tree_node([6, 3, 8, 1, 4, 7, 9, 0, 5, None, None, None, 10, None, None, None, None, 11, None, None, 12])) == 31\n assert candidate(root = tree_node([24, 12, 16, 6, 10, 8, 20, 3, 9, 7, 11, 5, 15, 1, 13, None, None, None, None, None, None, None, None, None, 4, None, None, None, 14, 17, 18, 19, None, 21, 22, 23])) == 161\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 40, 60, 90, 110, 140, 160, 190, 5, 15, 30, 45, 55, 65, 80, 100, 115, 130, 135, 155, 165, 180, 195])) == 1200\n assert candidate(root = tree_node([18, 4, 5, 2, 9, 10, 6, None, None, 1, 3, None, None, 7, 8, None, None, 11, 12, 13, 14, 15, 16, 17])) == 89\n assert candidate(root = tree_node([20, 12, 13, 8, 11, 14, 15, None, None, None, 10, None, 9, 16, 17, 18, 19, None, None, None, None, 21, 22, None, 23])) == 81\n assert candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15])) == 96\n assert candidate(root = tree_node([5, 3, 1, 6, 2, None, 8, 4, None, None, None, 7, 9])) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100])) == 2568\n assert candidate(root = tree_node([16, 12, 20, 8, 14, 18, 22, 4, 10, 13, 15, 17, 19, 21, 23])) == 184\n assert candidate(root = tree_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32])) == 296\n assert candidate(root = tree_node([14, 11, 8, 6, 12, 9, 5, 2, 4, 13, 7, 3, 10, None, None, None, None, None, None, None, 1, None, None, 15, 16, 17, None, None, None, None, 18, 19, 20, 21])) == 67\n assert candidate(root = tree_node([30, 15, 45, 10, 20, 40, 50, 5, 12, 18, 22, 35, 42, 48, 55, 3, 7, 9, 11, 13, 17, 19, 21, 23, 37, 38, 41, 43, 47, 49, 53, 57, 59])) == 551\n assert candidate(root = tree_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150])) == 1140\n assert candidate(root = tree_node([13, 11, 17, 7, 3, 16, 20, 1, 5, 9, 15, 12, None, None, None, 4, 6, 8, 10, 14, None, 18, 19, 21, 2, None, None, None, None, None, None, None, None, None, None, None])) == 23\n assert candidate(root = tree_node([14, 7, 27, 4, 9, 20, 35, 2, 6, 8, 11, 16, 22, 29, 42])) == 68\n assert candidate(root = tree_node([18, 9, 21, 15, 5, 10, 3, 7, None, 6, None, 8, 2, None, 4, None, None, 1, None, None, None, 11])) == 44\n assert candidate(root = tree_node([10, 5, None, 3, 7, None, None, 2, None, 6, 8, 1, None, None, None, 4, 9, 10, None, None, None, None, 11, 12, 13, 14, 15])) == 60\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 63, 90, 6, 20, 30, 40, 55, 65, 85, 95])) == 202\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, 45, 47, 49])) == 178\n assert candidate(root = tree_node([6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6])) == 666\n assert candidate(root = tree_node([6, 10, 14, 4, 8, 12, 16, 2, 6, 10, 14, 18, 22, 26, 30, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31])) == 424\n assert candidate(root = tree_node([22, 6, 18, 2, 14, 16, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41])) == 493\n assert candidate(root = tree_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])) == 228\n assert candidate(root = tree_node([18, 3, 20, None, 5, 15, 25, None, None, None, None, 13, None, 22])) == 58\n assert candidate(root = tree_node([6, 2, 12, 1, 5, 9, 15, 0, None, None, 3, 7, 11, 13, 19, None, None, None, 4, 6, 8, 10, 12, 14, 16, 18, 20])) == 83\n assert candidate(root = tree_node([25, 15, 35, 10, 20, 30, 40, 5, 11, 16, 24, 29, 31, 34, 41])) == 0\n assert candidate(root = tree_node([10, 4, 6, 8, 2, None, 5, None, None, None, None, 1, 3, 7, 9, 11, 13, 15, 17, 19])) == 19\n assert candidate(root = tree_node([6, 2, 8, 0, 4, 7, 9, None, None, 3, 5])) == 28\n assert candidate(root = tree_node([5, 3, 8, 2, 4, 7, 9, None, None, 6, None, None, None, None, 10])) == 10\n assert candidate(root = tree_node([30, 10, 50, 5, 15, 40, 60, 3, 7, 13, 17, 35, 45, 55, 65])) == 360\n assert candidate(root = tree_node([32, 16, 48, 8, 24, 36, 56, 4, 12, 20, 28, 32, 40, 52, 60])) == 372\n assert candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15])) == 96\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 190, 5, 15, 22, 35, 55, 65, 72, 78, 85, 95, 105, 135, 137, 145, 155, 172, 180, 195, 200])) == 1755\n assert candidate(root = tree_node([8, 3, 6, 1, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16])) == 74\n assert candidate(root = tree_node([40, 20, 60, 10, 30, 50, 70, 5, 15, 25, 35, 45, 55, 65, 75])) == 480\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, None, None, 6])) == 28\n assert candidate(root = tree_node([15, 5, 6, 3, 1, None, None, 2, 4, None, None, None, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])) == 279\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 2, 4, 6, 8, 11, 13, 18, 22])) == 42\n assert candidate(root = tree_node([8, 6, 5, 2, 4, 9, 7, None, None, 1, None, None, 3, 10, None, None, 11, 12, 13, None, None, 14, 15, None, 16])) == 34\n assert candidate(root = tree_node([3, 9, 20, None, None, 15, 7, None, None, 25, 35, None, None, 45, 55])) == 60\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, None, None, 30, 60, 90, 110, 140, 180, 20, 40, 55, 65, 85, 95, 105, 115, 130, 145, 160, 185, 195, None, None, 22, 28, 35, 45, 58, 68, 72, 82, 92, 102, 112, 118, 128, 135, 148, 155, 165, 175, 188, 198])) == 3331\n assert candidate(root = tree_node([50, 25, 75, 10, 40, 60, 90, 5, 15, 30, 45, 55, 65, 70, 100, 2, 6, 12, 20, 35, 43, 53, 57, 63, 67, 73, 77, 85, 95, 105])) == 993\n assert candidate(root = tree_node([10, 4, 15, 1, None, 11, 19, 6, None, None, 12, None, None, 5])) == 37\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 1, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38, 39])) == 240\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == 210\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 2, 7, 13, 18, 23, 28, 33, 38])) == 242\n assert candidate(root = tree_node([8, 5, 10, 3, 6, None, 11, 1, None, 4, 7, None, 14])) == 34\n assert candidate(root = tree_node([4, 2, 7, 1, 3, 6, 9, 9, None, 1, 4, None, None, None, 5, 6, None, None, 8, 10])) == 33\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 3, 7, 13, 19, 23, 29, 37])) == 212\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 14, 17, 22, 0, None, None, None, None, None, None, 9, None, None, 13, None, None, 16, None, None, 18, None, None, 21, None, None])) == 92\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 108\n assert candidate(root = tree_node([22, 11, 44, 7, 33, 55, 66, 1, 5, 9, 27, 50, 70, 100, 200])) == 581\n assert candidate(root = tree_node([2, 1, 5, 2, 3, 4, 8, 5, 6, 7, 9, 10, 11, 12, 13])) == 17\n assert candidate(root = tree_node([6, 2, 10, 1, 3, 7, 13, None, 4, None, 5, 8, 12, 14, 16])) == 83\n assert candidate(root = tree_node([46, 23, 69, 11, 35, 55, 82, 5, 19, 30, 40, 50, 60, 70, 80, 2, 7, 14, 21, 27, 32, 39, 45, 47, 53, 57, 61, 67, 73, 77, 81, 1, 3, 8, 12, 20, 26, 31, 37, 43, 49, 52, 58, 62, 66, 72, 76, 83, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == 1042\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 108\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 40, 60, 90, 110, 140, 160, 190])) == 1200\n assert candidate(root = tree_node([32, 16, 48, 8, 24, 36, 60, 4, 12, 20, 28, 32, 44, 52, 56, 2, 6, 10, 14, 18, 22, 26, 30, 34, 46, 50, 54, 58, None, None, 3, None, None, None, None, None, None, None, None, None, None, None, None, None, 7, None, None, None, 11, None, None, None, None, None, None, None, None, None, 15, None, None, None, None, None, None, None, None, None, 19, None, None, None, None, None, None, None, None, None])) == 782\n assert candidate(root = tree_node([4, 2, 5, 1, 3, None, 6, 0, 8, None, None, 7, 9])) == 18\n assert candidate(root = tree_node([17, 5, 10, None, None, 8, 9, None, None, 3, None, None, 13])) == 3\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 60, 82, 6, 20, None, 40, 55, 70, 10, 5, 15, 30, 45, 65, 77, None, None, None, None, 58])) == 404\n assert candidate(root = tree_node([16, 8, 24, 4, 12, 20, 28, 2, 6, 10, 14, 18, 22, 26, 30])) == 192\n assert candidate(root = tree_node([24, 12, 25, 6, 18, 21, 29, 3, 9, 15, None, 19, 23, 27, 31, 1, 5, 7, 11, 13, None, 17, None, None, 22, None, 26, None, 30, 2, 4, 8, 10, 14, 16, None, None, None, None, None, 20, None, None, 25, None, None, 28, None, None, 32])) == 138\n assert candidate(root = tree_node([6, 7, 8, 2, 7, 1, 3, 9, None, 1, 4, None, None, None, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 31\n assert candidate(root = tree_node([2, 1, 3, None, None, 4, None, None, None, 5, None, None, None, 6, None, None, None, 7, None, None, None, 8, None, None, None, 9, None, None, None, 10])) == 4\n assert candidate(root = tree_node([6, 7, 8, 2, 7, 1, 3, 9, None, 1, 4, 8, None, None, None, 5, 6, 7])) == 32\n assert candidate(root = tree_node([14, 8, 22, 4, 12, 16, 28, 2, 6, 10, 14, 18, 22, 26, 30])) == 188\n assert candidate(root = tree_node([7, 5, 9, 3, 6, 8, 10, 2, 4, None, None, None, None, None, None])) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 38\n assert candidate(root = tree_node([22, 17, 30, 10, 21, 28, 32, 5, 14, 19, 29, None, 35, 3, None, None, 12, None, 18, None, None, None, None, None, 24, 26, 31, 33, 36])) == 240\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().sumEvenGrandparent", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def sumEvenGrandparent(self, root: TreeNode | None) -> int:", "container": "Solution", "callable": "sumEvenGrandparent", "parameters": [{"name": "root", "type": "TreeNode | None"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1316, "task_id": "distinct-echo-substrings", "difficulty": "Hard", "problem_description": "Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself (i.e. it can be written as a + a where a is some string).\n \nExample 1:\n\nInput: text = \"abcabcabc\"\nOutput: 3\nExplanation: The 3 substrings are \"abcabc\", \"bcabca\" and \"cabcab\".\n\nExample 2:\n\nInput: text = \"leetcodeleetcode\"\nOutput: 2\nExplanation: The 2 substrings are \"ee\" and \"leetcodeleetcode\".\n\n \nConstraints:\n\n1 <= text.length <= 2000\ntext has only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"ababab\") == 2\n assert candidate(text = \"\") == 0\n assert candidate(text = \"abcabcabc\") == 3\n assert candidate(text = \"aaaa\") == 2\n assert candidate(text = \"ab\") == 0\n assert candidate(text = \"abbbabbb\") == 2\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 51\n assert candidate(text = \"abcd\") == 0\n assert candidate(text = \"abacaba\") == 0\n assert candidate(text = \"abc\") == 0\n assert candidate(text = \"leetcodeleetcode\") == 2\n assert candidate(text = \"banana\") == 2\n assert candidate(text = \"xyzxyzxyzxyz\") == 4\n assert candidate(text = \"abcdefg\") == 0\n assert candidate(text = \"racecar racecar\") == 0\n assert candidate(text = \"a\") == 0\n assert candidate(text = \"abababab\") == 3\n assert candidate(text = \"aabbccddeeff\") == 6\n assert candidate(text = \"mississippi\") == 4\n assert candidate(text = \"ababababab\") == 4\n assert candidate(text = \"xyxyxyxyxyxyxyxyxyxyxyxy\") == 11\n assert candidate(text = \"abacaxiabacaxiabacaxi\") == 7\n assert candidate(text = \"abcabcabcabcabcabcabc\") == 9\n assert candidate(text = \"abcdeabcdeabcdeabcde\") == 6\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 33\n assert candidate(text = \"repeatedrepeatedrepeatedrepeated\") == 9\n assert candidate(text = \"tattattattattattat\") == 8\n assert candidate(text = \"aaaaabaaaabaaaa\") == 7\n assert candidate(text = \"racecaracecaracecar\") == 6\n assert candidate(text = \"abcababcababcab\") == 6\n assert candidate(text = \"aabbccddeeffaabbccddeeff\") == 7\n assert candidate(text = \"xyxyxyxyxyxyxyxyxyxyxy\") == 10\n assert candidate(text = \"abacabaabacaba\") == 3\n assert candidate(text = \"leetcodeleetcodeleetcodeleetcode\") == 10\n assert candidate(text = \"thisisaverylongstringthatrepeatstitselfthisisaverylongstringthatrepeatstitself\") == 2\n assert candidate(text = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 26\n assert candidate(text = \"aaaabaaaab\") == 3\n assert candidate(text = \"abcabcabcabcabcabc\") == 7\n assert candidate(text = \"aaaaaaa\") == 3\n assert candidate(text = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 20\n assert candidate(text = \"abababababab\") == 5\n assert candidate(text = \"aaaaabcabcabcabcabc\") == 8\n assert candidate(text = \"qwertyqwertyqwerty\") == 6\n assert candidate(text = \"aabbccddeeffaabbccddeeffaabbccddeeff\") == 18\n assert candidate(text = \"xyzxyzxyzxyzxyzxyz\") == 7\n assert candidate(text = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 27\n assert candidate(text = \"abababababababababababababababababababababababababababababababababab\") == 33\n assert candidate(text = \"leetcodeisgoodandleetcodeisgood\") == 2\n assert candidate(text = \"supercalifragilisticexpialidocioussupercalifragilisticexpialidocious\") == 2\n assert candidate(text = \"abacabacabacabac\") == 5\n assert candidate(text = \"patternpatternpatternpattern\") == 9\n assert candidate(text = \"mississippimississippi\") == 5\n assert candidate(text = \"abcdabcdabcdabcd\") == 5\n assert candidate(text = \"zxcvbnmlkjhgfdsazxcvbnmlkjhgfdsa\") == 1\n assert candidate(text = \"abcdefgabcdefgabcdefg\") == 7\n assert candidate(text = \"abracadabraabracadabra\") == 3\n assert candidate(text = \"hellohellohellohellohello\") == 11\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzz\") == 10\n assert candidate(text = \"zzzzzzzzzzzzzzzz\") == 8\n assert candidate(text = \"abababa\") == 2\n assert candidate(text = \"ababababababab\") == 6\n assert candidate(text = \"aaaaaaaaaa\") == 5\n assert candidate(text = \"abcdabcdeabcd\") == 1\n assert candidate(text = \"racecar\") == 0\n assert candidate(text = \"abcdefghabcdefgh\") == 1\n assert candidate(text = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\") == 32\n assert candidate(text = \"xyzxyzxyzxyzxyzxyzxyzxyz\") == 10\n assert candidate(text = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 30\n assert candidate(text = \"abcabcabcabc\") == 4\n assert candidate(text = \"abcdefghijabcdefghijabcdefghij\") == 10\n assert candidate(text = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == 0\n assert candidate(text = \"aaaaa\") == 2\n assert candidate(text = \"abracadabrabracadabra\") == 4\n assert candidate(text = \"aaaaaa\") == 3\n assert candidate(text = \"abacabadabacabadabacaba\") == 8\n assert candidate(text = \"aaaaabbbbbaaaaabbbbb\") == 5\n assert candidate(text = \"noonnoonnoonnoon\") == 7\n assert candidate(text = \"abacabadabacaba\") == 0\n assert candidate(text = \"xyxyxyxyxyxyxyxy\") == 7\n assert candidate(text = \"abracadabraabracadabraabracadabraabracadabraabracadabraabracadabra\") == 25\n assert candidate(text = \"abcabcabcabcabc\") == 6\n assert candidate(text = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 43\n assert candidate(text = \"abababababababab\") == 7\n assert candidate(text = \"aaaaaaaaaabaaaaaaaaaa\") == 5\n assert candidate(text = \"aaaabbbbcccc\") == 6\n assert candidate(text = \"noonnoonnoonnoonnoon\") == 10\n assert candidate(text = \"abcxyzabcxyzabcxyz\") == 6\n assert candidate(text = \"abcabca\") == 2\n assert candidate(text = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 52\n assert candidate(text = \"uniqueuniqueuniqueunique\") == 7\n assert candidate(text = \"racecaracecar\") == 2\n assert candidate(text = \"abcdefabcdefabcdef\") == 6\n assert candidate(text = \"bananabananaananabanana\") == 7\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 32\n assert candidate(text = \"bananaabanana\") == 3\n assert candidate(text = \"aaaabbbbccccddddeeeeffff\") == 12\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 27\n assert candidate(text = \"hellohellohellohellohellohellohellohellohellohello\") == 22\n"}, "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().distinctEchoSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def distinctEchoSubstrings(self, text: str) -> int:", "container": "Solution", "callable": "distinctEchoSubstrings", "parameters": [{"name": "text", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1317, "task_id": "convert-integer-to-the-sum-of-two-no-zero-integers", "difficulty": "Easy", "problem_description": "No-Zero integer is a positive integer that does not contain any 0 in its decimal representation.\nGiven an integer n, return a list of two integers [a, b] where:\n\na and b are No-Zero integers.\na + b = n\n\nThe test cases are generated so that there is at least one valid solution. If there are many valid solutions, you can return any of them.\n \nExample 1:\n\nInput: n = 2\nOutput: [1,1]\nExplanation: Let a = 1 and b = 1.\nBoth a and b are no-zero integers, and a + b = 2 = n.\n\nExample 2:\n\nInput: n = 11\nOutput: [2,9]\nExplanation: Let a = 2 and b = 9.\nBoth a and b are no-zero integers, and a + b = 11 = n.\nNote that there are other valid answers as [8, 3] that can be accepted.\n\n \nConstraints:\n\n2 <= n <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 101) == [2, 99]\n assert candidate(n = 1010) == [11, 999]\n assert candidate(n = 11) == [2, 9]\n assert candidate(n = 104) == [5, 99]\n assert candidate(n = 1001) == [2, 999]\n assert candidate(n = 2) == [1, 1]\n assert candidate(n = 9999) == [1, 9998]\n assert candidate(n = 100) == [1, 99]\n assert candidate(n = 210) == [11, 199]\n assert candidate(n = 9801) == [2, 9799]\n assert candidate(n = 2345) == [1, 2344]\n assert candidate(n = 2100) == [111, 1989]\n assert candidate(n = 1111) == [112, 999]\n assert candidate(n = 10606) == [611, 9995]\n assert candidate(n = 8888) == [1, 8887]\n assert candidate(n = 1000) == [1, 999]\n assert candidate(n = 43) == [1, 42]\n assert candidate(n = 10202) == [211, 9991]\n assert candidate(n = 1357) == [1, 1356]\n assert candidate(n = 10001) == [2, 9999]\n assert candidate(n = 32109) == [111, 31998]\n assert candidate(n = 6789) == [1, 6788]\n assert candidate(n = 6005) == [6, 5999]\n assert candidate(n = 8181) == [2, 8179]\n assert candidate(n = 2468) == [1, 2467]\n assert candidate(n = 2048) == [49, 1999]\n assert candidate(n = 999) == [1, 998]\n assert candidate(n = 3030) == [31, 2999]\n assert candidate(n = 9012) == [13, 8999]\n assert candidate(n = 87654) == [1, 87653]\n assert candidate(n = 43210) == [11, 43199]\n assert candidate(n = 54321) == [2, 54319]\n assert candidate(n = 9090) == [91, 8999]\n assert candidate(n = 65) == [1, 64]\n assert candidate(n = 12345) == [1, 12344]\n assert candidate(n = 21) == [2, 19]\n assert candidate(n = 432) == [1, 431]\n assert candidate(n = 543) == [1, 542]\n assert candidate(n = 87) == [1, 86]\n assert candidate(n = 98) == [1, 97]\n assert candidate(n = 10303) == [311, 9992]\n assert candidate(n = 2023) == [24, 1999]\n assert candidate(n = 10505) == [511, 9994]\n assert candidate(n = 65432) == [1, 65431]\n assert candidate(n = 9998) == [1, 9997]\n assert candidate(n = 7007) == [8, 6999]\n assert candidate(n = 10101) == [112, 9989]\n assert candidate(n = 7070) == [71, 6999]\n assert candidate(n = 6543) == [1, 6542]\n assert candidate(n = 10404) == [411, 9993]\n assert candidate(n = 7777) == [1, 7776]\n assert candidate(n = 8080) == [81, 7999]\n assert candidate(n = 4999) == [1, 4998]\n assert candidate(n = 98765) == [1, 98764]\n assert candidate(n = 9876) == [1, 9875]\n assert candidate(n = 987) == [1, 986]\n assert candidate(n = 76543) == [1, 76542]\n assert candidate(n = 8901) == [2, 8899]\n assert candidate(n = 5678) == [1, 5677]\n assert candidate(n = 67890) == [1, 67889]\n assert candidate(n = 4004) == [5, 3999]\n assert candidate(n = 2000) == [1, 1999]\n assert candidate(n = 4567) == [1, 4566]\n assert candidate(n = 6006) == [7, 5999]\n assert candidate(n = 8008) == [9, 7999]\n assert candidate(n = 6666) == [1, 6665]\n assert candidate(n = 76) == [1, 75]\n assert candidate(n = 4680) == [1, 4679]\n assert candidate(n = 765) == [1, 764]\n assert candidate(n = 2020) == [21, 1999]\n assert candidate(n = 3050) == [51, 2999]\n assert candidate(n = 32) == [1, 31]\n assert candidate(n = 1023) == [24, 999]\n assert candidate(n = 7890) == [1, 7889]\n assert candidate(n = 90123) == [124, 89999]\n assert candidate(n = 7654) == [1, 7653]\n assert candidate(n = 876) == [1, 875]\n assert candidate(n = 7006) == [7, 6999]\n assert candidate(n = 21098) == [1111, 19987]\n assert candidate(n = 5050) == [51, 4999]\n assert candidate(n = 5002) == [3, 4999]\n assert candidate(n = 9997) == [1, 9996]\n assert candidate(n = 3003) == [4, 2999]\n assert candidate(n = 8765) == [1, 8764]\n assert candidate(n = 10987) == [988, 9999]\n assert candidate(n = 321) == [2, 319]\n assert candidate(n = 23456) == [1, 23455]\n assert candidate(n = 56789) == [1, 56788]\n assert candidate(n = 89012) == [13, 88999]\n assert candidate(n = 3333) == [1, 3332]\n assert candidate(n = 3456) == [1, 3455]\n assert candidate(n = 1098) == [99, 999]\n assert candidate(n = 10000) == [1, 9999]\n assert candidate(n = 5432) == [1, 5431]\n assert candidate(n = 2109) == [111, 1998]\n assert candidate(n = 54) == [1, 53]\n assert candidate(n = 654) == [1, 653]\n assert candidate(n = 8642) == [1, 8641]\n assert candidate(n = 5555) == [1, 5554]\n assert candidate(n = 3210) == [11, 3199]\n assert candidate(n = 9009) == [11, 8998]\n assert candidate(n = 6060) == [61, 5999]\n assert candidate(n = 5005) == [6, 4999]\n assert candidate(n = 4444) == [1, 4443]\n assert candidate(n = 4321) == [2, 4319]\n assert candidate(n = 34567) == [1, 34566]\n assert candidate(n = 2222) == [1, 2221]\n assert candidate(n = 6234) == [1, 6233]\n assert candidate(n = 10707) == [711, 9996]\n assert candidate(n = 109) == [11, 98]\n assert candidate(n = 4040) == [41, 3999]\n assert candidate(n = 1234) == [1, 1233]\n assert candidate(n = 7272) == [1, 7271]\n assert candidate(n = 45678) == [1, 45677]\n assert candidate(n = 78901) == [2, 78899]\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().getNoZeroIntegers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getNoZeroIntegers(self, n: int) -> list[int]:", "container": "Solution", "callable": "getNoZeroIntegers", "parameters": [{"name": "n", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1318, "task_id": "minimum-flips-to-make-a-or-b-equal-to-c", "difficulty": "Medium", "problem_description": "Given 3 positives numbers a, b and c. Return the minimum flips required in some bits of a and b to make ( a OR b == c ). (bitwise OR operation).\\r\nFlip operation consists of change any single bit 1 to 0 or change the bit 0 to 1 in their binary representation.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\n\\r\n\\r\nInput: a = 2, b = 6, c = 5\\r\nOutput: 3\\r\nExplanation: After flips a = 1 , b = 4 , c = 5 such that (a OR b == c)\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: a = 4, b = 2, c = 7\\r\nOutput: 1\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: a = 1, b = 2, c = 3\\r\nOutput: 0\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= a <= 10^9\\r\n\t1 <= b <= 10^9\\r\n\t1 <= c <= 10^9\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = 10,b = 15,c = 25) == 4\n assert candidate(a = 2,b = 6,c = 5) == 3\n assert candidate(a = 1,b = 2,c = 3) == 0\n assert candidate(a = 8,b = 3,c = 11) == 0\n assert candidate(a = 4,b = 2,c = 7) == 1\n assert candidate(a = 1000000000,b = 1000000000,c = 1) == 27\n assert candidate(a = 123,b = 456,c = 789) == 9\n assert candidate(a = 1000000007,b = 1000000009,c = 1000000011) == 1\n assert candidate(a = 8388607,b = 16777215,c = 16777215) == 0\n assert candidate(a = 65535,b = 65535,c = 65535) == 0\n assert candidate(a = 987654321,b = 123456789,c = 864197532) == 20\n assert candidate(a = 123456789,b = 987654321,c = 135792468) == 25\n assert candidate(a = 1048575,b = 2097151,c = 3145727) == 2\n assert candidate(a = 123456789,b = 987654321,c = 1234567890) == 26\n assert candidate(a = 255,b = 128,c = 254) == 1\n assert candidate(a = 894967295,b = 1073741823,c = 2147483647) == 1\n assert candidate(a = 255,b = 255,c = 0) == 16\n assert candidate(a = 16777215,b = 33554431,c = 67108863) == 1\n assert candidate(a = 1023,b = 511,c = 1535) == 2\n assert candidate(a = 1023,b = 2047,c = 3071) == 2\n assert candidate(a = 1073741824,b = 536870912,c = 1610612736) == 0\n assert candidate(a = 255,b = 128,c = 383) == 3\n assert candidate(a = 987654,b = 321456,c = 654321) == 9\n assert candidate(a = 987654321,b = 348712387,c = 1) == 30\n assert candidate(a = 2147483647,b = 0,c = 2147483647) == 0\n assert candidate(a = 777,b = 888,c = 999) == 6\n assert candidate(a = 123456789,b = 987654321,c = 999999999) == 10\n assert candidate(a = 134217728,b = 67108864,c = 201326592) == 0\n assert candidate(a = 15,b = 30,c = 45) == 4\n assert candidate(a = 1023,b = 512,c = 1024) == 12\n assert candidate(a = 123456789,b = 987654321,c = 1000000000) == 16\n assert candidate(a = 123456789,b = 987654321,c = 987654321) == 7\n assert candidate(a = 134217727,b = 67108863,c = 201326592) == 53\n assert candidate(a = 1000000000,b = 1,c = 1000000001) == 0\n assert candidate(a = 32,b = 16,c = 48) == 0\n assert candidate(a = 14,b = 28,c = 42) == 4\n assert candidate(a = 8,b = 3,c = 15) == 1\n assert candidate(a = 999,b = 888,c = 777) == 8\n assert candidate(a = 2147483647,b = 2147483647,c = 0) == 62\n assert candidate(a = 1000000,b = 999999,c = 1000001) == 5\n assert candidate(a = 1073741823,b = 536870912,c = 805306368) == 28\n assert candidate(a = 8,b = 16,c = 24) == 0\n assert candidate(a = 1048575,b = 524287,c = 1572863) == 2\n assert candidate(a = 1000000000,b = 999999999,c = 1000000000) == 9\n assert candidate(a = 2147483647,b = 2147483647,c = 1) == 60\n assert candidate(a = 1000000000,b = 500000000,c = 1000000001) == 8\n assert candidate(a = 1023,b = 512,c = 768) == 8\n assert candidate(a = 134217727,b = 268435455,c = 335544319) == 4\n assert candidate(a = 897,b = 564,c = 231) == 6\n assert candidate(a = 511,b = 255,c = 127) == 3\n assert candidate(a = 134217727,b = 268435455,c = 536870911) == 1\n assert candidate(a = 1023,b = 511,c = 255) == 3\n assert candidate(a = 536870911,b = 268435455,c = 805306367) == 2\n assert candidate(a = 255,b = 511,c = 1023) == 1\n assert candidate(a = 255,b = 128,c = 191) == 1\n assert candidate(a = 1000000000,b = 1000000000,c = 500000000) == 21\n assert candidate(a = 1000000000,b = 500000000,c = 1500000000) == 14\n assert candidate(a = 65535,b = 131071,c = 262143) == 1\n assert candidate(a = 500,b = 600,c = 700) == 3\n assert candidate(a = 2147483647,b = 2147483647,c = 4294967295) == 1\n assert candidate(a = 65535,b = 32768,c = 98304) == 16\n assert candidate(a = 255,b = 128,c = 64) == 8\n assert candidate(a = 16777215,b = 255,c = 16777470) == 19\n assert candidate(a = 100000000,b = 200000000,c = 300000000) == 10\n assert candidate(a = 5349,b = 7281,c = 12630) == 11\n assert candidate(a = 123456789,b = 987654321,c = 101110101) == 20\n assert candidate(a = 29,b = 15,c = 31) == 0\n assert candidate(a = 7,b = 14,c = 21) == 4\n assert candidate(a = 3,b = 12,c = 15) == 0\n assert candidate(a = 1048576,b = 2097152,c = 3145727) == 21\n assert candidate(a = 25,b = 50,c = 75) == 4\n assert candidate(a = 500000000,b = 500000000,c = 1000000000) == 21\n assert candidate(a = 31,b = 15,c = 7) == 3\n assert candidate(a = 1,b = 1,c = 0) == 2\n assert candidate(a = 1048575,b = 1048576,c = 2097151) == 0\n assert candidate(a = 536870911,b = 268435455,c = 703687440) == 32\n assert candidate(a = 348712387,b = 987654321,c = 1000000000) == 18\n assert candidate(a = 170,b = 85,c = 255) == 0\n assert candidate(a = 987654,b = 321456,c = 1309110) == 8\n assert candidate(a = 1023,b = 512,c = 1535) == 3\n assert candidate(a = 999999,b = 888888,c = 777777) == 8\n assert candidate(a = 1048575,b = 524287,c = 262143) == 3\n assert candidate(a = 65535,b = 65535,c = 131071) == 1\n assert candidate(a = 89,b = 67,c = 45) == 6\n assert candidate(a = 1,b = 1023,c = 1023) == 0\n assert candidate(a = 858993459,b = 2576980377,c = 1717986918) == 32\n assert candidate(a = 65535,b = 32767,c = 98303) == 2\n assert candidate(a = 536870911,b = 1073741823,c = 2147483647) == 1\n assert candidate(a = 1,b = 1000000000,c = 1000000000) == 1\n assert candidate(a = 8,b = 3,c = 10) == 1\n assert candidate(a = 789,b = 456,c = 1245) == 4\n assert candidate(a = 4294967295,b = 2147483647,c = 4294967294) == 2\n"}, "metadata": {"canonical_parameter_names": ["a", "b", "c"], "leetcode_dataset_entry_point": "Solution().minFlips", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minFlips(self, a: int, b: int, c: int) -> int:", "container": "Solution", "callable": "minFlips", "parameters": [{"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1319, "task_id": "number-of-operations-to-make-network-connected", "difficulty": "Medium", "problem_description": "There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [ai, bi] represents a connection between computers ai and bi. Any computer can reach any other computer directly or indirectly through the network.\nYou are given an initial computer network connections. You can extract certain cables between two directly connected computers, and place them between any pair of disconnected computers to make them directly connected.\nReturn the minimum number of times you need to do this in order to make all the computers connected. If it is not possible, return -1.\n \nExample 1:\n\n\nInput: n = 4, connections = [[0,1],[0,2],[1,2]]\nOutput: 1\nExplanation: Remove cable between computer 1 and 2 and place between computers 1 and 3.\n\nExample 2:\n\n\nInput: n = 6, connections = [[0,1],[0,2],[0,3],[1,2],[1,3]]\nOutput: 2\n\nExample 3:\n\nInput: n = 6, connections = [[0,1],[0,2],[0,3],[1,2]]\nOutput: -1\nExplanation: There are not enough cables.\n\n \nConstraints:\n\n1 <= n <= 105\n1 <= connections.length <= min(n * (n - 1) / 2, 105)\nconnections[i].length == 2\n0 <= ai, bi < n\nai != bi\nThere are no repeated connections.\nNo two computers are connected by more than one cable.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(n = 5,connections = [[0, 1], [1, 2], [3, 4]]) == -1\n assert candidate(n = 6,connections = [[0, 1], [0, 2], [0, 3], [1, 2]]) == -1\n assert candidate(n = 5,connections = [[0, 1], [2, 3]]) == -1\n assert candidate(n = 3,connections = [[0, 1], [1, 2]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]]) == 3\n assert candidate(n = 5,connections = [[0, 1], [0, 2], [3, 4]]) == -1\n assert candidate(n = 2,connections = [[0, 1]]) == 0\n assert candidate(n = 4,connections = [[0, 1], [0, 2], [1, 2]]) == 1\n assert candidate(n = 10,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == -1\n assert candidate(n = 1,connections = []) == 0\n assert candidate(n = 6,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3]]) == 2\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [5, 6]]) == -1\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8], [8, 9]]) == -1\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 6]]) == 1\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8], [8, 9], [9, 10], [11, 12], [12, 13], [13, 14]]) == -1\n assert candidate(n = 20,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 0\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 6], [0, 6], [1, 7], [2, 8], [3, 9], [4, 0]]) == 0\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 5]]) == 1\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [3, 4], [4, 5], [6, 7], [7, 8], [8, 9]]) == -1\n assert candidate(n = 9,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 8]]) == 0\n assert candidate(n = 14,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [13, 0], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == 0\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4]]) == 1\n assert candidate(n = 20,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [12, 14], [13, 15], [16, 18], [17, 19]]) == 4\n assert candidate(n = 11,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == -1\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 10]]) == 2\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [10, 11]]) == 3\n assert candidate(n = 13,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == 0\n assert candidate(n = 100,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21], [22, 23], [24, 25], [26, 27], [28, 29], [30, 31], [32, 33], [34, 35], [36, 37], [38, 39], [40, 41], [42, 43], [44, 45], [46, 47], [48, 49], [50, 51], [52, 53], [54, 55], [56, 57], [58, 59], [60, 61], [62, 63], [64, 65], [66, 67], [68, 69], [70, 71], [72, 73], [74, 75], [76, 77], [78, 79], [80, 81], [82, 83], [84, 85], [86, 87], [88, 89], [90, 91], [92, 93], [94, 95], [96, 97], [98, 99]]) == -1\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [13, 14]]) == 4\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 5], [5, 10], [10, 3], [3, 8], [8, 1]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 6]]) == 1\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]]) == 0\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 1\n assert candidate(n = 30,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [0, 29]]) == 0\n assert candidate(n = 30,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == 0\n assert candidate(n = 12,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]]) == -1\n assert candidate(n = 25,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == -1\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9]]) == 2\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [5, 6], [7, 8], [8, 9]]) == -1\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 3], [2, 5], [4, 7], [6, 8]]) == 0\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 11]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [0, 14]]) == 0\n assert candidate(n = 11,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(n = 20,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]]) == -1\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14]]) == 0\n assert candidate(n = 25,connections = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 9], [2, 10], [2, 11], [2, 12], [3, 13], [3, 14], [3, 15], [3, 16], [4, 17], [4, 18], [4, 19], [4, 20], [5, 21], [6, 22], [7, 23], [8, 24]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 1\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [4, 5], [5, 6], [6, 7]]) == -1\n assert candidate(n = 14,connections = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7], [13, 13]]) == 3\n assert candidate(n = 14,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == 1\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 0\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 2], [1, 3]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 1\n assert candidate(n = 16,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 0], [0, 7], [7, 14], [14, 6], [6, 13], [13, 5], [5, 12], [12, 4], [4, 11], [11, 3], [3, 10], [10, 2], [2, 9], [9, 1], [1, 8]]) == 0\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [3, 6], [2, 5]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 3]]) == 1\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8], [8, 9]]) == -1\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0]]) == 0\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [1, 2], [3, 4], [4, 5]]) == -1\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == 0\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 14]]) == 0\n assert candidate(n = 30,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21], [22, 23], [24, 25], [26, 27], [28, 29]]) == -1\n assert candidate(n = 20,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0]]) == 0\n assert candidate(n = 30,connections = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25], [22, 26], [23, 27], [24, 28], [25, 29]]) == 0\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9]]) == -1\n assert candidate(n = 5,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3], [2, 4], [3, 0], [4, 1]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5], [5, 1]]) == 0\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9]]) == 1\n assert candidate(n = 16,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]]) == -1\n assert candidate(n = 9,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [0, 8], [1, 7], [2, 5], [3, 6]]) == 0\n assert candidate(n = 9,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8]]) == -1\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == 0\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 0\n assert candidate(n = 25,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24]]) == 0\n assert candidate(n = 20,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 6]]) == 1\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [0, 3], [2, 5], [4, 7], [6, 9], [8, 11], [10, 13], [12, 15], [14, 17], [16, 19]]) == 0\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["n", "connections"], "leetcode_dataset_entry_point": "Solution().makeConnected", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def makeConnected(self, n: int, connections: list[list[int]]) -> int:", "container": "Solution", "callable": "makeConnected", "parameters": [{"name": "n", "type": "int"}, {"name": "connections", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1320, "task_id": "minimum-distance-to-type-a-word-using-two-fingers", "difficulty": "Hard", "problem_description": "\nYou have a keyboard layout as shown above in the X-Y plane, where each English uppercase letter is located at some coordinate.\n\nFor example, the letter 'A' is located at coordinate (0, 0), the letter 'B' is located at coordinate (0, 1), the letter 'P' is located at coordinate (2, 3) and the letter 'Z' is located at coordinate (4, 1).\n\nGiven the string word, return the minimum total distance to type such string using only two fingers.\nThe distance between coordinates (x1, y1) and (x2, y2) is |x1 - x2| + |y1 - y2|.\nNote that the initial positions of your two fingers are considered free so do not count towards your total distance, also your two fingers do not have to start at the first letter or the first two letters.\n \nExample 1:\n\nInput: word = \"CAKE\"\nOutput: 3\nExplanation: Using two fingers, one optimal way to type \"CAKE\" is: \nFinger 1 on letter 'C' -> cost = 0 \nFinger 1 on letter 'A' -> cost = Distance from letter 'C' to letter 'A' = 2 \nFinger 2 on letter 'K' -> cost = 0 \nFinger 2 on letter 'E' -> cost = Distance from letter 'K' to letter 'E' = 1 \nTotal distance = 3\n\nExample 2:\n\nInput: word = \"HAPPY\"\nOutput: 6\nExplanation: Using two fingers, one optimal way to type \"HAPPY\" is:\nFinger 1 on letter 'H' -> cost = 0\nFinger 1 on letter 'A' -> cost = Distance from letter 'H' to letter 'A' = 2\nFinger 2 on letter 'P' -> cost = 0\nFinger 2 on letter 'P' -> cost = Distance from letter 'P' to letter 'P' = 0\nFinger 1 on letter 'Y' -> cost = Distance from letter 'A' to letter 'Y' = 4\nTotal distance = 6\n\n \nConstraints:\n\n2 <= word.length <= 300\nword consists of uppercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"QWERTYUIOPASDFGHJKLZXCVBNM\") == 52\n assert candidate(word = \"ZZZZZ\") == 0\n assert candidate(word = \"CAKE\") == 3\n assert candidate(word = \"RHYTHM\") == 9\n assert candidate(word = \"FINGER\") == 8\n assert candidate(word = \"ALPHABET\") == 12\n assert candidate(word = \"ABCD\") == 2\n assert candidate(word = \"QWERTYUIOPASDFGHJKLMZXCVBNM\") == 54\n assert candidate(word = \"NEW\") == 3\n assert candidate(word = \"HAPPY\") == 6\n assert candidate(word = \"ABCMN\") == 3\n assert candidate(word = \"LONGEST\") == 8\n assert candidate(word = \"MISSISSIPPI\") == 5\n assert candidate(word = \"YEAR\") == 7\n assert candidate(word = \"ZXY\") == 1\n assert candidate(word = \"OPTIMIZATION\") == 17\n assert candidate(word = \"YYYYYY\") == 0\n assert candidate(word = \"ACB\") == 1\n assert candidate(word = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 36\n assert candidate(word = \"MOUSE\") == 5\n assert candidate(word = \"ZZZZ\") == 0\n assert candidate(word = \"AA\") == 0\n assert candidate(word = \"TRANSFER\") == 15\n assert candidate(word = \"ABCDEFGHIJKLMNOP\") == 18\n assert candidate(word = \"PYTHON\") == 6\n assert candidate(word = \"QRSTUVWXYZ\") == 12\n assert candidate(word = \"KEYBOARD\") == 15\n assert candidate(word = \"ABAB\") == 0\n assert candidate(word = \"A\") == 0\n assert candidate(word = \"ABCDEFG\") == 5\n assert candidate(word = \"DISTANCE\") == 11\n assert candidate(word = \"ALGORITHMS\") == 14\n assert candidate(word = \"CAPABILITY\") == 13\n assert candidate(word = \"HASHMAP\") == 9\n assert candidate(word = \"LONGWORDLONGWORDLONGWORDLONGWORDLONGWORDLONGWORDLONGWORD\") == 122\n assert candidate(word = \"SPECIAL\") == 12\n assert candidate(word = \"DEPLOYMENT\") == 14\n assert candidate(word = \"VOLCANOES\") == 15\n assert candidate(word = \"VICTORY\") == 10\n assert candidate(word = \"BACKSPACENOTPOSSIBLE\") == 35\n assert candidate(word = \"PROSPERING\") == 18\n assert candidate(word = \"METHOD\") == 7\n assert candidate(word = \"ROBUST\") == 7\n assert candidate(word = \"PLANNING\") == 11\n assert candidate(word = \"JOY\") == 2\n assert candidate(word = \"DEPTHFIRSTSEARCH\") == 29\n assert candidate(word = \"CONCEPT\") == 7\n assert candidate(word = \"INTEGRATION\") == 19\n assert candidate(word = \"PLENTY\") == 7\n assert candidate(word = \"COORDINATION\") == 18\n assert candidate(word = \"ACCOMPLISHED\") == 18\n assert candidate(word = \"RUBY\") == 7\n assert candidate(word = \"SERVER\") == 10\n assert candidate(word = \"PYTHONIC\") == 8\n assert candidate(word = \"PRODUCT\") == 8\n assert candidate(word = \"JUST\") == 3\n assert candidate(word = \"RESEARCH\") == 13\n assert candidate(word = \"PYTHONCODING\") == 15\n assert candidate(word = \"INITIATION\") == 9\n assert candidate(word = \"OBJECTORIENTED\") == 22\n assert candidate(word = \"REQUIREMENT\") == 15\n assert candidate(word = \"BANANA\") == 1\n assert candidate(word = \"FINANCE\") == 10\n assert candidate(word = \"HELLOFROMTHEOTHERSIDE\") == 35\n assert candidate(word = \"DEDICATED\") == 10\n assert candidate(word = \"SUPERLONGWORD\") == 23\n assert candidate(word = \"ACCOMPLISHMENT\") == 20\n assert candidate(word = \"PROGRAMMER\") == 13\n assert candidate(word = \"SPECIALCHARACTERS\") == 32\n assert candidate(word = \"NETWORK\") == 10\n assert candidate(word = \"AWESOME\") == 11\n assert candidate(word = \"PROGRESS\") == 9\n assert candidate(word = \"WIN\") == 2\n assert candidate(word = \"OBJECTIVE\") == 15\n assert candidate(word = \"FLOURISH\") == 10\n assert candidate(word = \"PROSPEROUS\") == 16\n assert candidate(word = \"EXPERIMENT\") == 14\n assert candidate(word = \"FINGERBOARD\") == 20\n assert candidate(word = \"PATIENCE\") == 13\n assert candidate(word = \"ADJUSTMENT\") == 13\n assert candidate(word = \"EXCEL\") == 6\n assert candidate(word = \"SUPERCALIFRAGILISTICEXPIALIDOCIOUS\") == 59\n assert candidate(word = \"FRANK\") == 7\n assert candidate(word = \"SOFTWARE\") == 18\n assert candidate(word = \"TWOPOINTERS\") == 15\n assert candidate(word = \"ANALYSIS\") == 13\n assert candidate(word = \"RESOLUTION\") == 15\n assert candidate(word = \"LONGWORDFORTESTING\") == 32\n assert candidate(word = \"INTERACTION\") == 18\n assert candidate(word = \"UNOBTRUDES\") == 17\n assert candidate(word = \"FINGERMOVEMENT\") == 20\n assert candidate(word = \"PEACE\") == 5\n assert candidate(word = \"DEPONIBLE\") == 11\n assert candidate(word = \"ASTARSEARCH\") == 22\n assert candidate(word = \"ANGULAR\") == 10\n assert candidate(word = \"SERVICE\") == 12\n assert candidate(word = \"PROSPERITY\") == 19\n assert candidate(word = \"RECOGNITION\") == 13\n assert candidate(word = \"KINDNESS\") == 7\n assert candidate(word = \"PYTHONPYTHONPYTHON\") == 26\n assert candidate(word = \"PARTNER\") == 12\n assert candidate(word = \"IDEAL\") == 5\n assert candidate(word = \"PRODUCTIVE\") == 14\n assert candidate(word = \"HARMONY\") == 10\n assert candidate(word = \"MYSQL\") == 5\n assert candidate(word = \"PYTHONISFUN\") == 17\n assert candidate(word = \"UNIVERSAL\") == 16\n assert candidate(word = \"KEYBOARDLAYOUT\") == 29\n assert candidate(word = \"SAFE\") == 4\n assert candidate(word = \"TYPESCRIPT\") == 20\n assert candidate(word = \"TREE\") == 3\n assert candidate(word = \"FINGERFINGER\") == 20\n assert candidate(word = \"AAAAA\") == 0\n assert candidate(word = \"GENTLE\") == 7\n assert candidate(word = \"ETHICAL\") == 8\n assert candidate(word = \"BACKTRACKING\") == 21\n assert candidate(word = \"AFFLUENT\") == 11\n assert candidate(word = \"TIMECOMPLEXITY\") == 27\n assert candidate(word = \"HUMBLE\") == 11\n assert candidate(word = \"API\") == 2\n assert candidate(word = \"OVERCOME\") == 14\n assert candidate(word = \"DOBRE\") == 8\n assert candidate(word = \"PRACTICE\") == 13\n assert candidate(word = \"PLAIN\") == 8\n assert candidate(word = \"ACHIEVEMENT\") == 14\n assert candidate(word = \"COMPUTERSCIENCE\") == 28\n assert candidate(word = \"SUCCESSFUL\") == 9\n assert candidate(word = \"GOAL\") == 5\n assert candidate(word = \"CHANGE\") == 9\n assert candidate(word = \"FULFILLMENT\") == 12\n assert candidate(word = \"PRINCIPLE\") == 13\n assert candidate(word = \"CODER\") == 5\n assert candidate(word = \"ALLOCATION\") == 13\n assert candidate(word = \"DIJKSTRAS\") == 14\n assert candidate(word = \"INTERPRETATION\") == 22\n assert candidate(word = \"INTEGRITY\") == 16\n assert candidate(word = \"HACK\") == 4\n assert candidate(word = \"QWJRTYUPASDFGZXCVB\") == 43\n assert candidate(word = \"SUPERLATIVE\") == 23\n assert candidate(word = \"PERSISTENT\") == 16\n assert candidate(word = \"MULTIPLEFINGERS\") == 24\n assert candidate(word = \"OPERATION\") == 16\n assert candidate(word = \"DELIVERY\") == 14\n assert candidate(word = \"DETERMINATION\") == 20\n assert candidate(word = \"DATASTRUCTURE\") == 24\n assert candidate(word = \"CALCULATION\") == 19\n assert candidate(word = \"OPULANCE\") == 15\n assert candidate(word = \"TOP\") == 1\n assert candidate(word = \"SIMULATION\") == 19\n assert candidate(word = \"ATTENTIVE\") == 12\n assert candidate(word = \"PROFILING\") == 9\n assert candidate(word = \"EFFICIENT\") == 7\n assert candidate(word = \"MEMORYMANAGEMENT\") == 26\n assert candidate(word = \"STRATEGY\") == 18\n assert candidate(word = \"THRIVE\") == 9\n assert candidate(word = \"ENERGETIC\") == 15\n assert candidate(word = \"THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG\") == 73\n assert candidate(word = \"CUSTOMIZATION\") == 20\n assert candidate(word = \"OPTIMIZE\") == 11\n assert candidate(word = \"ELITE\") == 6\n assert candidate(word = \"PROGRAMMINGISFUN\") == 24\n assert candidate(word = \"COMMITTED\") == 9\n assert candidate(word = \"EFFECTIVE\") == 10\n assert candidate(word = \"REPORT\") == 6\n assert candidate(word = \"SPACESAVING\") == 22\n assert candidate(word = \"INTERFACE\") == 15\n assert candidate(word = \"NEURALNETWORKS\") == 29\n assert candidate(word = \"CORRECT\") == 9\n assert candidate(word = \"KNIGHTMARCH\") == 17\n assert candidate(word = \"SIMPLE\") == 8\n assert candidate(word = \"TECHNOLOGY\") == 16\n assert candidate(word = \"QUEUE\") == 2\n assert candidate(word = \"ABACAXABABACAB\") == 15\n assert candidate(word = \"PROGRAMMING\") == 14\n assert candidate(word = \"SEARCH\") == 10\n assert candidate(word = \"MULTIPLEWORDSHEREANDTHERE\") == 49\n assert candidate(word = \"LOAD\") == 7\n assert candidate(word = \"CONFIDENT\") == 11\n assert candidate(word = \"HTML\") == 4\n assert candidate(word = \"SECURE\") == 10\n assert candidate(word = \"MECHANISM\") == 13\n assert candidate(word = \"WEALTHY\") == 15\n assert candidate(word = \"FLAWLESS\") == 12\n assert candidate(word = \"MORAL\") == 6\n assert candidate(word = \"RESPONSIBLE\") == 19\n assert candidate(word = \"DEVOTED\") == 6\n assert candidate(word = \"PASSIONATE\") == 15\n assert candidate(word = \"RANDOMKEYPAD\") == 24\n assert candidate(word = \"BACKSPACENEEDED\") == 20\n assert candidate(word = \"JAVA\") == 2\n assert candidate(word = \"CHALLENGE\") == 11\n assert candidate(word = \"PRESENTATION\") == 17\n assert candidate(word = \"BOOMING\") == 7\n assert candidate(word = \"HELLOWORLD\") == 13\n assert candidate(word = \"EQUITABLE\") == 16\n assert candidate(word = \"GREATEST\") == 10\n assert candidate(word = \"DATASTRUCTURES\") == 26\n assert candidate(word = \"EXCELLENCE\") == 14\n assert candidate(word = \"PRECISE\") == 10\n assert candidate(word = \"OBTAINED\") == 11\n assert candidate(word = \"EXECUTION\") == 9\n assert candidate(word = \"DELICATE\") == 11\n assert candidate(word = \"KRUSKALSMST\") == 16\n assert candidate(word = \"AAABBBCCCDDD\") == 2\n assert candidate(word = \"BEST\") == 4\n assert candidate(word = \"ABCDEFGHIJABCDEFGHIJ\") == 24\n assert candidate(word = \"EXEMPLARY\") == 19\n assert candidate(word = \"PRIMSMST\") == 9\n assert candidate(word = \"MANAGER\") == 10\n assert candidate(word = \"RELATIONSHIP\") == 19\n assert candidate(word = \"COMMUNICATION\") == 15\n assert candidate(word = \"FINGERPRINT\") == 17\n assert candidate(word = \"RECOMMENDATION\") == 18\n assert candidate(word = \"MULTITHREADING\") == 24\n assert candidate(word = \"MEETING\") == 8\n assert candidate(word = \"TRIUMPHANT\") == 17\n assert candidate(word = \"PRIDE\") == 5\n assert candidate(word = \"STRETCH\") == 8\n assert candidate(word = \"FINGERLATERALMOVEMENT\") == 38\n assert candidate(word = \"CLIENT\") == 6\n assert candidate(word = \"BOOM\") == 2\n assert candidate(word = \"AFFLUENCE\") == 13\n assert candidate(word = \"CONSECUTIVE\") == 16\n assert candidate(word = \"GREAT\") == 8\n assert candidate(word = \"MARKET\") == 9\n assert candidate(word = \"GENUINE\") == 8\n assert candidate(word = \"BIGDATAANALYSIS\") == 24\n assert candidate(word = \"CONVINCED\") == 10\n assert candidate(word = \"UNIT\") == 3\n assert candidate(word = \"CONFIGURATION\") == 25\n assert candidate(word = \"PLAN\") == 6\n assert candidate(word = \"ADAPTABLE\") == 13\n assert candidate(word = \"TEAMWORK\") == 15\n assert candidate(word = \"AAAAAAAAA\") == 0\n assert candidate(word = \"ACHIEVE\") == 8\n assert candidate(word = \"UTILIZATION\") == 17\n assert candidate(word = \"THRIVING\") == 10\n assert candidate(word = \"PERFORMANCE\") == 20\n assert candidate(word = \"MODEST\") == 6\n assert candidate(word = \"DEVELOPMENT\") == 13\n assert candidate(word = \"ACHIEVED\") == 9\n assert candidate(word = \"BREADTHFIRSTSEARCH\") == 35\n assert candidate(word = \"ASSURED\") == 9\n assert candidate(word = \"TRIUMPH\") == 12\n assert candidate(word = \"ENTHUSIASTIC\") == 17\n assert candidate(word = \"BUSINESS\") == 11\n assert candidate(word = \"PHP\") == 0\n assert candidate(word = \"EARNED\") == 10\n assert candidate(word = \"BBBBC\") == 0\n assert candidate(word = \"LONGKEYSEQUENCE\") == 20\n assert candidate(word = \"RIGHT\") == 5\n assert candidate(word = \"PERFECTION\") == 14\n assert candidate(word = \"PRINCIPLED\") == 14\n assert candidate(word = \"DEBUGGINGISSLOW\") == 23\n assert candidate(word = \"GUARANTEED\") == 13\n assert candidate(word = \"PROSPER\") == 11\n assert candidate(word = \"SYNCHRONIZATION\") == 25\n assert candidate(word = \"ACCOUNTABLE\") == 14\n assert candidate(word = \"VIVACIOUS\") == 10\n assert candidate(word = \"ACCURATE\") == 14\n assert candidate(word = \"INITIALIZE\") == 17\n assert candidate(word = \"ABUNDANCE\") == 12\n assert candidate(word = \"EXACT\") == 10\n assert candidate(word = \"PREMIERE\") == 12\n assert candidate(word = \"PNEUMONULA\") == 19\n assert candidate(word = \"SYNTAXERRORHANDLING\") == 36\n assert candidate(word = \"PYTHONANDJAVA\") == 15\n assert candidate(word = \"PROBLEM\") == 10\n assert candidate(word = \"DECIDED\") == 4\n assert candidate(word = \"INFORMATION\") == 18\n assert candidate(word = \"CODINGCHALLENGES\") == 23\n assert candidate(word = \"TRANSACTION\") == 16\n assert candidate(word = \"CONTESTSAREFUN\") == 24\n assert candidate(word = \"DYNAMIC\") == 11\n assert candidate(word = \"PATTERN\") == 11\n assert candidate(word = \"CONCURRENT\") == 12\n assert candidate(word = \"TEST\") == 2\n assert candidate(word = \"SUPERIOR\") == 10\n assert candidate(word = \"LOVEPYTHON\") == 17\n assert candidate(word = \"COLLABORATION\") == 22\n assert candidate(word = \"MINIMALIZATION\") == 20\n assert candidate(word = \"MACHINELEARNING\") == 28\n assert candidate(word = \"PLETHORA\") == 16\n assert candidate(word = \"MEMORIZATION\") == 21\n assert candidate(word = \"PROTECTED\") == 11\n assert candidate(word = \"JAVASCRIPT\") == 19\n assert candidate(word = \"EXCEPTIONAL\") == 20\n assert candidate(word = \"FLOURISHING\") == 15\n assert candidate(word = \"COORDINATOR\") == 17\n assert candidate(word = \"VARIABLESANDTYPES\") == 33\n assert candidate(word = \"TEAM\") == 6\n assert candidate(word = \"TRAVELINGSALESMANPROBLEM\") == 51\n assert candidate(word = \"VUE\") == 1\n assert candidate(word = \"DIRECT\") == 10\n assert candidate(word = \"AVOIDDISTANCE\") == 17\n assert candidate(word = \"PREMIUM\") == 10\n assert candidate(word = \"FLEXIBLE\") == 12\n assert candidate(word = \"CPLUSPLUS\") == 15\n assert candidate(word = \"BUG\") == 2\n assert candidate(word = \"COOLCODE\") == 8\n assert candidate(word = \"CONGRATULATIONS\") == 25\n assert candidate(word = \"MONGODB\") == 8\n assert candidate(word = \"NETWORKFLOW\") == 16\n assert candidate(word = \"SIMULATEDANNEALING\") == 34\n assert candidate(word = \"STRONG\") == 6\n assert candidate(word = \"POSTGRESQL\") == 17\n assert candidate(word = \"TARGET\") == 11\n assert candidate(word = \"PROJECT\") == 10\n assert candidate(word = \"ARTIFICIALINTELLIGENCE\") == 37\n assert candidate(word = \"DATABASE\") == 10\n assert candidate(word = \"RECURSION\") == 13\n assert candidate(word = \"REACT\") == 9\n assert candidate(word = \"FRAMEWORK\") == 16\n assert candidate(word = \"OPTIMAL\") == 10\n assert candidate(word = \"REACHED\") == 8\n assert candidate(word = \"EXCELLENT\") == 12\n assert candidate(word = \"KANGAROO\") == 11\n assert candidate(word = \"GENETICALGORITHM\") == 24\n assert candidate(word = \"STRESS\") == 5\n assert candidate(word = \"PYTHONPROGRAMMING\") == 23\n assert candidate(word = \"GRAPH\") == 5\n assert candidate(word = \"MIGHTY\") == 6\n assert candidate(word = \"HONEST\") == 6\n assert candidate(word = \"ACCELERATION\") == 18\n assert candidate(word = \"XYLOPHONE\") == 15\n assert candidate(word = \"LUXURY\") == 6\n assert candidate(word = \"LOYAL\") == 8\n assert candidate(word = \"DIVIDEANDCONQUER\") == 25\n assert candidate(word = \"IDENTIFICATION\") == 19\n assert candidate(word = \"HONORABLE\") == 11\n assert candidate(word = \"TYPINGISAWAYTORELAX\") == 37\n assert candidate(word = \"ENGINEERING\") == 15\n assert candidate(word = \"TYPINGWITHTWOFINGERS\") == 39\n assert candidate(word = \"COMPANY\") == 10\n assert candidate(word = \"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 84\n assert candidate(word = \"ARRAY\") == 4\n assert candidate(word = \"CSS\") == 0\n assert candidate(word = \"CYBER\") == 7\n assert candidate(word = \"ENGINEER\") == 9\n assert candidate(word = \"FUTURE\") == 7\n assert candidate(word = \"APPLICATION\") == 14\n assert candidate(word = \"STACK\") == 6\n assert candidate(word = \"VICTORIOUS\") == 13\n assert candidate(word = \"IMPLEMENTATION\") == 18\n assert candidate(word = \"HELLOUNIVERSE\") == 23\n assert candidate(word = \"PROCESS\") == 9\n assert candidate(word = \"FUNCTION\") == 9\n assert candidate(word = \"CAREER\") == 6\n assert candidate(word = \"INITIATIVE\") == 12\n assert candidate(word = \"RESULT\") == 8\n assert candidate(word = \"EMPATHY\") == 12\n assert candidate(word = \"ABILITY\") == 8\n assert candidate(word = \"SUPPLIER\") == 10\n assert candidate(word = \"INTERVENTION\") == 20\n assert candidate(word = \"ATTAINED\") == 8\n assert candidate(word = \"ALGORITHM\") == 13\n assert candidate(word = \"LEADER\") == 7\n assert candidate(word = \"SOFTWAREENGINEERING\") == 36\n assert candidate(word = \"SUPERABUNDANCE\") == 26\n assert candidate(word = \"TENACIOUS\") == 11\n assert candidate(word = \"FAIR\") == 5\n assert candidate(word = \"HELLOWORLDHELLOWORLD\") == 29\n assert candidate(word = \"REFACTOR\") == 14\n assert candidate(word = \"SATISFACTION\") == 20\n assert candidate(word = \"ALGORITHMSANDDATA\") == 26\n assert candidate(word = \"PROLIFIC\") == 5\n assert candidate(word = \"GRAPHALGORITHMS\") == 24\n assert candidate(word = \"CAREFUL\") == 12\n assert candidate(word = \"ECONOMY\") == 7\n assert candidate(word = \"OUTSTANDING\") == 12\n assert candidate(word = \"GREEDYALGORITHM\") == 27\n assert candidate(word = \"VIP\") == 1\n assert candidate(word = \"BAAABBBCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWWXXXXYYYYZZZZZ\") == 36\n assert candidate(word = \"COMPASSION\") == 12\n assert candidate(word = \"ARCHITECTURE\") == 20\n assert candidate(word = \"BELLMANFORD\") == 17\n assert candidate(word = \"WORKFLOW\") == 10\n assert candidate(word = \"NODEJS\") == 7\n assert candidate(word = \"RESILIENT\") == 14\n assert candidate(word = \"ZYXWVUTSRQPONMLKJIHGFEDCBA\") == 36\n assert candidate(word = \"HAPPINESS\") == 12\n assert candidate(word = \"RELIABLE\") == 10\n assert candidate(word = \"POWERFUL\") == 11\n assert candidate(word = \"PERFECT\") == 10\n assert candidate(word = \"TRUSTWORTHY\") == 18\n assert candidate(word = \"TRANSPARENT\") == 23\n assert candidate(word = \"MINIMIZE\") == 8\n assert candidate(word = \"COMPLEXITY\") == 20\n assert candidate(word = \"TENDER\") == 6\n assert candidate(word = \"ACCEPTANCE\") == 13\n assert candidate(word = \"FLASK\") == 5\n assert candidate(word = \"KNOWLEDGE\") == 13\n assert candidate(word = \"RICH\") == 3\n assert candidate(word = \"ENVIRONMENT\") == 17\n assert candidate(word = \"GAINED\") == 7\n assert candidate(word = \"DISCOVER\") == 13\n assert candidate(word = \"DOUBTFREE\") == 13\n assert candidate(word = \"LUXURIOUS\") == 9\n assert candidate(word = \"SECURITY\") == 14\n assert candidate(word = \"INDUSTRY\") == 13\n assert candidate(word = \"MOVEMENTOFKEYS\") == 19\n assert candidate(word = \"DJANGO\") == 6\n assert candidate(word = \"FUNCTIONCALLSARE\") == 28\n assert candidate(word = \"CONSCIENTIOUS\") == 16\n assert candidate(word = \"HELLOORLD\") == 9\n assert candidate(word = \"REVISION\") == 11\n assert candidate(word = \"INNOVATION\") == 12\n assert candidate(word = \"EXCLUSIVE\") == 18\n assert candidate(word = \"SURE\") == 5\n assert candidate(word = \"TRUST\") == 4\n assert candidate(word = \"DYNAMICPROGRAMMING\") == 31\n assert candidate(word = \"LEARN\") == 8\n assert candidate(word = \"SUCCESS\") == 5\n assert candidate(word = \"AAAAAAAAAABBBBBBBBBBCCCCCCCCCC\") == 1\n assert candidate(word = \"EVOLUTION\") == 11\n assert candidate(word = \"SOLUTION\") == 10\n assert candidate(word = \"OPPORTUNITY\") == 14\n assert candidate(word = \"ABUNDANT\") == 9\n assert candidate(word = \"FAILURE\") == 10\n assert candidate(word = \"REVOLUTION\") == 14\n assert candidate(word = \"SEQUENCE\") == 11\n assert candidate(word = \"FINGERFINGERFINGER\") == 32\n assert candidate(word = \"LINKEDLIST\") == 14\n assert candidate(word = \"EXPERIENCE\") == 14\n assert candidate(word = \"OPEN\") == 3\n assert candidate(word = \"LOVE\") == 4\n assert candidate(word = \"CONCLUSION\") == 14\n assert candidate(word = \"SKILL\") == 5\n assert candidate(word = \"EVALUATION\") == 19\n assert candidate(word = \"FINGERTYPINGISFUN\") == 32\n assert candidate(word = \"MAGNIFICENT\") == 13\n assert candidate(word = \"LEETCODE\") == 8\n assert candidate(word = \"CUSTOMER\") == 12\n assert candidate(word = \"STRIGHT\") == 8\n assert candidate(word = \"SPACECOMPLEXITY\") == 28\n assert candidate(word = \"DEPENDABLE\") == 13\n assert candidate(word = \"DEVELOPER\") == 10\n assert candidate(word = \"EXPRESS\") == 11\n assert candidate(word = \"KEYPADTYPING\") == 24\n assert candidate(word = \"PROFESSION\") == 12\n assert candidate(word = \"REPOSITION\") == 11\n assert candidate(word = \"KNAPSACKPROBLEM\") == 28\n assert candidate(word = \"DESIGN\") == 8\n assert candidate(word = \"DEBUG\") == 6\n assert candidate(word = \"TRACING\") == 11\n assert candidate(word = \"STURDY\") == 9\n assert candidate(word = \"WEALTH\") == 11\n assert candidate(word = \"TRANSFORMATION\") == 29\n assert candidate(word = \"EFFORT\") == 5\n assert candidate(word = \"EXERCISE\") == 11\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().minimumDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumDistance(self, word: str) -> int:", "container": "Solution", "callable": "minimumDistance", "parameters": [{"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1324, "task_id": "print-words-vertically", "difficulty": "Medium", "problem_description": "Given a string s. Return all the words vertically in the same order in which they appear in s.\\r\nWords are returned as a list of strings, complete with spaces when is necessary. (Trailing spaces are not allowed).\\r\nEach word would be put on only one column and that in one column there will be only one word.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: s = \"HOW ARE YOU\"\\r\nOutput: [\"HAY\",\"ORO\",\"WEU\"]\\r\nExplanation: Each word is printed vertically. \\r\n \"HAY\"\\r\n \"ORO\"\\r\n \"WEU\"\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: s = \"TO BE OR NOT TO BE\"\\r\nOutput: [\"TBONTB\",\"OEROOE\",\" T\"]\\r\nExplanation: Trailing spaces is not allowed. \\r\n\"TBONTB\"\\r\n\"OEROOE\"\\r\n\" T\"\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: s = \"CONTEST IS COMING\"\\r\nOutput: [\"CIC\",\"OSO\",\"N M\",\"T I\",\"E N\",\"S G\",\"T\"]\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= s.length <= 200\\r\n\ts contains only upper case English letters.\\r\n\tIt's guaranteed that there is only one space between 2 words.\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"AB CD\") == ['AC', 'BD']\n assert candidate(s = \"A B C D\") == ['ABCD']\n assert candidate(s = \"A B C D E\") == ['ABCDE']\n assert candidate(s = \"SINGLEWORD\") == ['S', 'I', 'N', 'G', 'L', 'E', 'W', 'O', 'R', 'D']\n assert candidate(s = \"A B C\") == ['ABC']\n assert candidate(s = \"PYTHON\") == ['P', 'Y', 'T', 'H', 'O', 'N']\n assert candidate(s = \"HELLO WORLD\") == ['HW', 'EO', 'LR', 'LL', 'OD']\n assert candidate(s = \"ABCD EF GHIJK\") == ['AEG', 'BFH', 'C I', 'D J', ' K']\n assert candidate(s = \"PROGRAMMING IS FUN\") == ['PIF', 'RSU', 'O N', 'G', 'R', 'A', 'M', 'M', 'I', 'N', 'G']\n assert candidate(s = \"MAKE AMERICA GREAT AGAIN\") == ['MAGA', 'AMRG', 'KEEA', 'ERAI', ' ITN', ' C', ' A']\n assert candidate(s = \"SPACE BETWEEN\") == ['SB', 'PE', 'AT', 'CW', 'EE', ' E', ' N']\n assert candidate(s = \"UPPER CASE ONLY\") == ['UCO', 'PAN', 'PSL', 'EEY', 'R']\n assert candidate(s = \"HOW ARE YOU\") == ['HAY', 'ORO', 'WEU']\n assert candidate(s = \"PYTHON CODING CHALLENGE\") == ['PCC', 'YOH', 'TDA', 'HIL', 'ONL', 'NGE', ' N', ' G', ' E']\n assert candidate(s = \"JUMP HIGH\") == ['JH', 'UI', 'MG', 'PH']\n assert candidate(s = \"A\") == ['A']\n assert candidate(s = \"ALIGNED TEXT VERTICALLY\") == ['ATV', 'LEE', 'IXR', 'GTT', 'N I', 'E C', 'D A', ' L', ' L', ' Y']\n assert candidate(s = \"KEEP IT SIMPLE\") == ['KIS', 'ETI', 'E M', 'P P', ' L', ' E']\n assert candidate(s = \"HELLO HELLO HELLO\") == ['HHH', 'EEE', 'LLL', 'LLL', 'OOO']\n assert candidate(s = \"TO BE OR NOT TO BE\") == ['TBONTB', 'OEROOE', ' T']\n assert candidate(s = \"CONTEST IS COMING\") == ['CIC', 'OSO', 'N M', 'T I', 'E N', 'S G', 'T']\n assert candidate(s = \"SAME LENGTH\") == ['SL', 'AE', 'MN', 'EG', ' T', ' H']\n assert candidate(s = \"PYTHON IS FUN\") == ['PIF', 'YSU', 'T N', 'H', 'O', 'N']\n assert candidate(s = \"MULTIPLE SPACES BETWEEN WORDS\") == ['MSBW', 'UPEO', 'LATR', 'TCWD', 'IEES', 'PSE', 'L N', 'E']\n assert candidate(s = \"VERTICAL PRINTING TEST\") == ['VPT', 'ERE', 'RIS', 'TNT', 'IT', 'CI', 'AN', 'LG']\n assert candidate(s = \"VERTICALALIGNMENT WITH SPACES\") == ['VWS', 'EIP', 'RTA', 'THC', 'I E', 'C S', 'A', 'L', 'A', 'L', 'I', 'G', 'N', 'M', 'E', 'N', 'T']\n assert candidate(s = \"VERYLONGWORDSTOCHALLENGEIMPLEMENTATION\") == ['V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'S', 'T', 'O', 'C', 'H', 'A', 'L', 'L', 'E', 'N', 'G', 'E', 'I', 'M', 'P', 'L', 'E', 'M', 'E', 'N', 'T', 'A', 'T', 'I', 'O', 'N']\n assert candidate(s = \"SHORT LONGER LONGEST\") == ['SLL', 'HOO', 'ONN', 'RGG', 'TEE', ' RS', ' T']\n assert candidate(s = \"UNIVERSITY OF WATERLOO\") == ['UOW', 'NFA', 'I T', 'V E', 'E R', 'R L', 'S O', 'I O', 'T', 'Y']\n assert candidate(s = \"VERTICAL ALIGNMENT TEST\") == ['VAT', 'ELE', 'RIS', 'TGT', 'IN', 'CM', 'AE', 'LN', ' T']\n assert candidate(s = \"COMPACT AND READABLE CODE\") == ['CARC', 'ONEO', 'MDAD', 'P DE', 'A A', 'C B', 'T L', ' E']\n assert candidate(s = \"MIXED CASE words\") == ['MCw', 'IAo', 'XSr', 'EEd', 'D s']\n assert candidate(s = \"LONGESTWORDHERE SHORT MEDIUM\") == ['LSM', 'OHE', 'NOD', 'GRI', 'ETU', 'S M', 'T', 'W', 'O', 'R', 'D', 'H', 'E', 'R', 'E']\n assert candidate(s = \"SMALL BIGGEST WORD\") == ['SBW', 'MIO', 'AGR', 'LGD', 'LE', ' S', ' T']\n assert candidate(s = \"HELLO WORLD THIS IS A TEST\") == ['HWTIAT', 'EOHS E', 'LRI S', 'LLS T', 'OD']\n assert candidate(s = \"MIXED LENGTH WORDS HERE\") == ['MLWH', 'IEOE', 'XNRR', 'EGDE', 'DTS', ' H']\n assert candidate(s = \"COMPUTER SCIENCE DEPARTMENT\") == ['CSD', 'OCE', 'MIP', 'PEA', 'UNR', 'TCT', 'EEM', 'R E', ' N', ' T']\n assert candidate(s = \"VERYLONGWORDSTO TEST THE SYSTEM\") == ['VTTS', 'EEHY', 'RSES', 'YT T', 'L E', 'O M', 'N', 'G', 'W', 'O', 'R', 'D', 'S', 'T', 'O']\n assert candidate(s = \"SAMEWORDSAMEWORD\") == ['S', 'A', 'M', 'E', 'W', 'O', 'R', 'D', 'S', 'A', 'M', 'E', 'W', 'O', 'R', 'D']\n assert candidate(s = \"SMALL WORDS\") == ['SW', 'MO', 'AR', 'LD', 'LS']\n assert candidate(s = \"VERTICAL PRINTING IS FUN\") == ['VPIF', 'ERSU', 'RI N', 'TN', 'IT', 'CI', 'AN', 'LG']\n assert candidate(s = \"ALGORITHMS DATA STRUCTURES\") == ['ADS', 'LAT', 'GTR', 'OAU', 'R C', 'I T', 'T U', 'H R', 'M E', 'S S']\n assert candidate(s = \"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\") == ['ABCDEFGHIJKLMNOPQRSTUVWXYZ']\n assert candidate(s = \"EFFICIENT AND POWERFUL\") == ['EAP', 'FNO', 'FDW', 'I E', 'C R', 'I F', 'E U', 'N L', 'T']\n assert candidate(s = \"AVERYLONGWORD THATFITSSNICELY INTOTHECOLUMN\") == ['ATI', 'VHN', 'EAT', 'RTO', 'YFT', 'LIH', 'OTE', 'NSC', 'GSO', 'WNL', 'OIU', 'RCM', 'DEN', ' L', ' Y']\n assert candidate(s = \"MIXEDCASEANDUPPERCASE\") == ['M', 'I', 'X', 'E', 'D', 'C', 'A', 'S', 'E', 'A', 'N', 'D', 'U', 'P', 'P', 'E', 'R', 'C', 'A', 'S', 'E']\n assert candidate(s = \"MIXEDCASE mixedcase\") == ['Mm', 'Ii', 'Xx', 'Ee', 'Dd', 'Cc', 'Aa', 'Ss', 'Ee']\n assert candidate(s = \"MIXED CASE Words AND NUMBERS 123\") == ['MCWAN1', 'IAoNU2', 'XSrDM3', 'EEd B', 'D s E', ' R', ' S']\n assert candidate(s = \"SPACES ARE IGNORED BETWEEN WORDS\") == ['SAIBW', 'PRGEO', 'AENTR', 'C OWD', 'E RES', 'S EE', ' DN']\n assert candidate(s = \"PYTHONPROGRAMMING\") == ['P', 'Y', 'T', 'H', 'O', 'N', 'P', 'R', 'O', 'G', 'R', 'A', 'M', 'M', 'I', 'N', 'G']\n assert candidate(s = \"CHECK FOR SPACES IN BETWEEN\") == ['CFSIB', 'HOPNE', 'ERA T', 'C C W', 'K E E', ' S E', ' N']\n assert candidate(s = \"DATA SCIENCE AND MACHINE LEARNING\") == ['DSAML', 'ACNAE', 'TIDCA', 'AE HR', ' N IN', ' C NI', ' E EN', ' G']\n assert candidate(s = \"LEADING AND TRAILING SPACES\") == ['LATS', 'ENRP', 'ADAA', 'D IC', 'I LE', 'N IS', 'G N', ' G']\n assert candidate(s = \"VERYLONGWORDSHOULDTESTTHEFUNCTION\") == ['V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'S', 'H', 'O', 'U', 'L', 'D', 'T', 'E', 'S', 'T', 'T', 'H', 'E', 'F', 'U', 'N', 'C', 'T', 'I', 'O', 'N']\n assert candidate(s = \"MULTILINE VERTICAL OUTPUT\") == ['MVO', 'UEU', 'LRT', 'TTP', 'IIU', 'LCT', 'IA', 'NL', 'E']\n assert candidate(s = \"LONGESTWORD IN A SENTENCE\") == ['LIAS', 'ON E', 'N N', 'G T', 'E E', 'S N', 'T C', 'W E', 'O', 'R', 'D']\n assert candidate(s = \"ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE TEN\") == ['OTTFFSSENT', 'NWHOIIEIIE', 'EORUVXVGNN', ' ERE EHE', ' E NT']\n assert candidate(s = \"ALIGNED COLUMN OUTPUT PRINTING\") == ['ACOP', 'LOUR', 'ILTI', 'GUPN', 'NMUT', 'ENTI', 'D N', ' G']\n assert candidate(s = \"ANOTHEREXAMPLEFOR TESTING\") == ['AT', 'NE', 'OS', 'TT', 'HI', 'EN', 'RG', 'E', 'X', 'A', 'M', 'P', 'L', 'E', 'F', 'O', 'R']\n assert candidate(s = \"SHORT LONGEST SHORTEST\") == ['SLS', 'HOH', 'ONO', 'RGR', 'TET', ' SE', ' TS', ' T']\n assert candidate(s = \"SAMEWORD SAMEWORD SAMEWORD\") == ['SSS', 'AAA', 'MMM', 'EEE', 'WWW', 'OOO', 'RRR', 'DDD']\n assert candidate(s = \"ALIGNED ROWS\") == ['AR', 'LO', 'IW', 'GS', 'N', 'E', 'D']\n assert candidate(s = \"JUSTIFIED TEXT\") == ['JT', 'UE', 'SX', 'TT', 'I', 'F', 'I', 'E', 'D']\n assert candidate(s = \"SHORTEST LONGEST WORD\") == ['SLW', 'HOO', 'ONR', 'RGD', 'TE', 'ES', 'ST', 'T']\n assert candidate(s = \"ENDING SPACES ARE NOT ALLOWED \") == ['ESANA', 'NPROL', 'DAETL', 'IC O', 'NE W', 'GS E', ' D']\n assert candidate(s = \"S P A C E S E P A R A T E D\") == ['SPACESEPARATED']\n assert candidate(s = \"VERYLONGWORDTHATREQUIRESPROPERVERTICALALIGNMENT\") == ['V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'T', 'H', 'A', 'T', 'R', 'E', 'Q', 'U', 'I', 'R', 'E', 'S', 'P', 'R', 'O', 'P', 'E', 'R', 'V', 'E', 'R', 'T', 'I', 'C', 'A', 'L', 'A', 'L', 'I', 'G', 'N', 'M', 'E', 'N', 'T']\n assert candidate(s = \"MIX SOME VERY LONG WORDS IN THIS STRING\") == ['MSVLWITS', 'IOEOONHT', 'XMRNR IR', ' EYGD SI', ' S N', ' G']\n assert candidate(s = \"MULTILINE TEXT PRINTING\") == ['MTP', 'UER', 'LXI', 'TTN', 'I T', 'L I', 'I N', 'N G', 'E']\n assert candidate(s = \"VERY LONG WORDS IN THIS SENTENCE\") == ['VLWITS', 'EOONHE', 'RNR IN', 'YGD ST', ' S E', ' N', ' C', ' E']\n assert candidate(s = \"LEADING SPACES ARE IGNORED\") == ['LSAI', 'EPRG', 'AAEN', 'DC O', 'IE R', 'NS E', 'G D']\n assert candidate(s = \"VERTICAL PRINTING TEST CASE\") == ['VPTC', 'EREA', 'RISS', 'TNTE', 'IT', 'CI', 'AN', 'LG']\n assert candidate(s = \"REALLYLONGWORD THATS EVENLONGER\") == ['RTE', 'EHV', 'AAE', 'LTN', 'LSL', 'Y O', 'L N', 'O G', 'N E', 'G R', 'W', 'O', 'R', 'D']\n assert candidate(s = \"SIXTEENCHARACTERLIMITHERE\") == ['S', 'I', 'X', 'T', 'E', 'E', 'N', 'C', 'H', 'A', 'R', 'A', 'C', 'T', 'E', 'R', 'L', 'I', 'M', 'I', 'T', 'H', 'E', 'R', 'E']\n assert candidate(s = \"HIGH LEVEL LANGUAGE\") == ['HLL', 'IEA', 'GVN', 'HEG', ' LU', ' A', ' G', ' E']\n assert candidate(s = \"SAMELENGTH WORDS\") == ['SW', 'AO', 'MR', 'ED', 'LS', 'E', 'N', 'G', 'T', 'H']\n assert candidate(s = \"ONECHAR PER WORD A B C D E\") == ['OPWABCDE', 'NEO', 'ERR', 'C D', 'H', 'A', 'R']\n assert candidate(s = \"VARYING WORD LENGTHS\") == ['VWL', 'AOE', 'RRN', 'YDG', 'I T', 'N H', 'G S']\n assert candidate(s = \"PYTHON IS AWESOME\") == ['PIA', 'YSW', 'T E', 'H S', 'O O', 'N M', ' E']\n assert candidate(s = \"SHOULD HANDLE LARGE WORDS CORRECTLY\") == ['SHLWC', 'HAAOO', 'ONRRR', 'UDGDR', 'LLESE', 'DE C', ' T', ' L', ' Y']\n assert candidate(s = \"ONEVERYLONGWORDHERE\") == ['O', 'N', 'E', 'V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'H', 'E', 'R', 'E']\n assert candidate(s = \"HELLO WORLD FROM ALIBABA CLOUD\") == ['HWFAC', 'EORLL', 'LROIO', 'LLMBU', 'OD AD', ' B', ' A']\n assert candidate(s = \"DIFFERENT LENGTH WORDS\") == ['DLW', 'IEO', 'FNR', 'FGD', 'ETS', 'RH', 'E', 'N', 'T']\n assert candidate(s = \"UPPERCASE WORDS ONLY\") == ['UWO', 'PON', 'PRL', 'EDY', 'RS', 'C', 'A', 'S', 'E']\n assert candidate(s = \"THIS IS A LONG STRING FOR TESTING\") == ['TIALSFT', 'HS OTOE', 'I NRRS', 'S GI T', ' N I', ' G N', ' G']\n assert candidate(s = \"LEADING AND TRAILING SPACES ARE NOT ALLOWED\") == ['LATSANA', 'ENRPROL', 'ADAAETL', 'D IC O', 'I LE W', 'N IS E', 'G N D', ' G']\n assert candidate(s = \"SPECIAL CASES LIKE EMPTY STRING\") == ['SCLES', 'PAIMT', 'ESKPR', 'CEETI', 'IS YN', 'A G', 'L']\n assert candidate(s = \"UNIVERSAL ACCEPTANCE OF PYTHON\") == ['UAOP', 'NCFY', 'IC T', 'VE H', 'EP O', 'RT N', 'SA', 'AN', 'LC', ' E']\n assert candidate(s = \"HELLO WORLD FROM THE OTHER SIDE\") == ['HWFTOS', 'EORHTI', 'LROEHD', 'LLM EE', 'OD R']\n assert candidate(s = \"TESTING WITH SPECIAL CHARACTERS !@#\") == ['TWSC!', 'EIPH@', 'STEA#', 'THCR', 'I IA', 'N AC', 'G LT', ' E', ' R', ' S']\n assert candidate(s = \"MULTILINE STRING WITH MULTIPLE LINES\") == ['MSWML', 'UTIUI', 'LRTLN', 'TIHTE', 'IN IS', 'LG P', 'I L', 'N E', 'E']\n assert candidate(s = \"SHORTEST WORD\") == ['SW', 'HO', 'OR', 'RD', 'T', 'E', 'S', 'T']\n assert candidate(s = \"TEST WITH MANY WORDS AND DIFFERENT LENGTHS\") == ['TWMWADL', 'EIAONIE', 'STNRDFN', 'THYD FG', ' S ET', ' RH', ' ES', ' N', ' T']\n assert candidate(s = \"EXTREMELYLONGWORD SOMETIMES ARE NECESSARY\") == ['ESAN', 'XORE', 'TMEC', 'RE E', 'ET S', 'MI S', 'EM A', 'LE R', 'YS Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D']\n assert candidate(s = \"EQUAL LENGTH WORDS HERE\") == ['ELWH', 'QEOE', 'UNRR', 'AGDE', 'LTS', ' H']\n assert candidate(s = \"HELLO WORLD THIS IS A VERTICALLY PRINTED TEXT\") == ['HWTIAVPT', 'EOHS ERE', 'LRI RIX', 'LLS TNT', 'OD IT', ' CE', ' AD', ' L', ' L', ' Y']\n assert candidate(s = \"SINGLE\") == ['S', 'I', 'N', 'G', 'L', 'E']\n assert candidate(s = \"PYTHONCODE JAVA CODE CSHARP\") == ['PJCC', 'YAOS', 'TVDH', 'HAEA', 'O R', 'N P', 'C', 'O', 'D', 'E']\n assert candidate(s = \"WITH MANY DIFFERENT LENGTHS\") == ['WMDL', 'IAIE', 'TNFN', 'HYFG', ' ET', ' RH', ' ES', ' N', ' T']\n assert candidate(s = \"DIFFERENT LENGTHS\") == ['DL', 'IE', 'FN', 'FG', 'ET', 'RH', 'ES', 'N', 'T']\n assert candidate(s = \"PYTHON PROGRAMMING\") == ['PP', 'YR', 'TO', 'HG', 'OR', 'NA', ' M', ' M', ' I', ' N', ' G']\n assert candidate(s = \"ALMOSTDONE\") == ['A', 'L', 'M', 'O', 'S', 'T', 'D', 'O', 'N', 'E']\n assert candidate(s = \"VARYING LENGTHS IN THIS STRING\") == ['VLITS', 'AENHT', 'RN IR', 'YG SI', 'IT N', 'NH G', 'GS']\n assert candidate(s = \"AVERYLONGWORDWITHNOSPACE\") == ['A', 'V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'W', 'I', 'T', 'H', 'N', 'O', 'S', 'P', 'A', 'C', 'E']\n assert candidate(s = \"PROGRAMMING CHALLENGES ARE FUN\") == ['PCAF', 'RHRU', 'OAEN', 'GL', 'RL', 'AE', 'MN', 'MG', 'IE', 'NS', 'G']\n assert candidate(s = \"TESTING EDGE CASES HERE\") == ['TECH', 'EDAE', 'SGSR', 'TEEE', 'I S', 'N', 'G']\n assert candidate(s = \"DIFFERENT SPACING TEST\") == ['DST', 'IPE', 'FAS', 'FCT', 'EI', 'RN', 'EG', 'N', 'T']\n assert candidate(s = \"MIXED SPACES AND VARYING LENGTHS\") == ['MSAVL', 'IPNAE', 'XADRN', 'EC YG', 'DE IT', ' S NH', ' GS']\n assert candidate(s = \"SPARSEMATRIX AND DENSEMATRIX\") == ['SAD', 'PNE', 'ADN', 'R S', 'S E', 'E M', 'M A', 'A T', 'T R', 'R I', 'I X', 'X']\n assert candidate(s = \"ALIGNED COLUMN OUTPUT\") == ['ACO', 'LOU', 'ILT', 'GUP', 'NMU', 'ENT', 'D']\n assert candidate(s = \"UPPERCASE LOWERCASE MIXEDCASE\") == ['ULM', 'POI', 'PWX', 'EEE', 'RRD', 'CCC', 'AAA', 'SSS', 'EEE']\n assert candidate(s = \"REALLYLONGWORD AND SHORT\") == ['RAS', 'ENH', 'ADO', 'L R', 'L T', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D']\n assert candidate(s = \"ONE\") == ['O', 'N', 'E']\n assert candidate(s = \"PYTHONJAVAJS CPLUSPLUS RUBY\") == ['PCR', 'YPU', 'TLB', 'HUY', 'OS', 'NP', 'JL', 'AU', 'VS', 'A', 'J', 'S']\n assert candidate(s = \"MULTILINE STRINGS ARE NOT ALLOWED\") == ['MSANA', 'UTROL', 'LRETL', 'TI O', 'IN W', 'LG E', 'IS D', 'N', 'E']\n assert candidate(s = \"VERTICAL PRINTING\") == ['VP', 'ER', 'RI', 'TN', 'IT', 'CI', 'AN', 'LG']\n assert candidate(s = \"VERTICAL PRINTING OF STRINGS\") == ['VPOS', 'ERFT', 'RI R', 'TN I', 'IT N', 'CI G', 'AN S', 'LG']\n assert candidate(s = \"TRAILING SPACES ARE NOT ALLOWED \") == ['TSANA', 'RPROL', 'AAETL', 'IC O', 'LE W', 'IS E', 'N D', 'G']\n assert candidate(s = \"MULTILINE VERTICAL PRINT\") == ['MVP', 'UER', 'LRI', 'TTN', 'IIT', 'LC', 'IA', 'NL', 'E']\n assert candidate(s = \"SINGLELETTERS ABC DEF GHI\") == ['SADG', 'IBEH', 'NCFI', 'G', 'L', 'E', 'L', 'E', 'T', 'T', 'E', 'R', 'S']\n assert candidate(s = \"SMALL LARGER LARGEST\") == ['SLL', 'MAA', 'ARR', 'LGG', 'LEE', ' RS', ' T']\n assert candidate(s = \"SAME LENGTH WORDS\") == ['SLW', 'AEO', 'MNR', 'EGD', ' TS', ' H']\n assert candidate(s = \"ALIGNS WORDS CORRECTLY\") == ['AWC', 'LOO', 'IRR', 'GDR', 'NSE', 'S C', ' T', ' L', ' Y']\n assert candidate(s = \"MIXED CASE STRING\") == ['MCS', 'IAT', 'XSR', 'EEI', 'D N', ' G']\n assert candidate(s = \"UPPERCASE LOWERCASE MIXED\") == ['ULM', 'POI', 'PWX', 'EEE', 'RRD', 'CC', 'AA', 'SS', 'EE']\n assert candidate(s = \"VERIFYING THE CORRECTNESS OF THE IMPLEMENTATION\") == ['VTCOTI', 'EHOFHM', 'RER EP', 'I R L', 'F E E', 'Y C M', 'I T E', 'N N N', 'G E T', ' S A', ' S T', ' I', ' O', ' N']\n assert candidate(s = \"HELLO WORLD HELLO WORLD\") == ['HWHW', 'EOEO', 'LRLR', 'LLLL', 'ODOD']\n assert candidate(s = \"PYTHON IS A GREAT LANGUAGE\") == ['PIAGL', 'YS RA', 'T EN', 'H AG', 'O TU', 'N A', ' G', ' E']\n assert candidate(s = \"MIXEDCASE Words ARE Allowed\") == ['MWAA', 'IoRl', 'XrEl', 'Ed o', 'Ds w', 'C e', 'A d', 'S', 'E']\n assert candidate(s = \"ONE TWO THREE FOUR FIVE SIX\") == ['OTTFFS', 'NWHOII', 'EORUVX', ' ERE', ' E']\n assert candidate(s = \"SPECIAL !@#$%^&*() CHARACTERS ARE NOT ALLOWED BUT UPPER CASE ONLY\") == ['S!CANABUCO', 'P@HROLUPAN', 'E#AETLTPSL', 'C$R O EEY', 'I%A W R', 'A^C E', 'L&T D', ' *E', ' (R', ' )S']\n assert candidate(s = \"MIXED CASE WITH VARYING LENGTHS\") == ['MCWVL', 'IAIAE', 'XSTRN', 'EEHYG', 'D IT', ' NH', ' GS']\n assert candidate(s = \"HELLO WORLD FROM PYTHON\") == ['HWFP', 'EORY', 'LROT', 'LLMH', 'OD O', ' N']\n assert candidate(s = \"LONGESTWORDINASENTENCEISHERE\") == ['L', 'O', 'N', 'G', 'E', 'S', 'T', 'W', 'O', 'R', 'D', 'I', 'N', 'A', 'S', 'E', 'N', 'T', 'E', 'N', 'C', 'E', 'I', 'S', 'H', 'E', 'R', 'E']\n assert candidate(s = \"EQUAL LENGTH WORDS\") == ['ELW', 'QEO', 'UNR', 'AGD', 'LTS', ' H']\n assert candidate(s = \"ONE TWO THREE FOUR FIVE SIX SEVEN\") == ['OTTFFSS', 'NWHOIIE', 'EORUVXV', ' ERE E', ' E N']\n assert candidate(s = \"MIXED LENGTHS SHORTEST LONGEST MIDDLE\") == ['MLSLM', 'IEHOI', 'XNOND', 'EGRGD', 'DTTEL', ' HESE', ' SST', ' T']\n assert candidate(s = \"PYTHON PROGRAMMING LANGUAGE\") == ['PPL', 'YRA', 'TON', 'HGG', 'ORU', 'NAA', ' MG', ' ME', ' I', ' N', ' G']\n assert candidate(s = \"LONGESTWORDFORTESTING VARYING LENGTHS TESTING\") == ['LVLT', 'OAEE', 'NRNS', 'GYGT', 'EITI', 'SNHN', 'TGSG', 'W', 'O', 'R', 'D', 'F', 'O', 'R', 'T', 'E', 'S', 'T', 'I', 'N', 'G']\n assert candidate(s = \"DIFFERENT LENGTH WORDS HERE\") == ['DLWH', 'IEOE', 'FNRR', 'FGDE', 'ETS', 'RH', 'E', 'N', 'T']\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().printVertically", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def printVertically(self, s: str) -> List[str]:", "container": "Solution", "callable": "printVertically", "parameters": [{"name": "s", "type": "str"}], "return_type": "List[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1325, "task_id": "delete-leaves-with-a-given-value", "difficulty": "Medium", "problem_description": "Given a binary tree root and an integer target, delete all the leaf nodes with value target.\nNote that once you delete a leaf node with value target, if its parent node becomes a leaf node and has the value target, it should also be deleted (you need to continue doing that until you cannot).\n \nExample 1:\n\n\nInput: root = [1,2,3,2,null,2,4], target = 2\nOutput: [1,null,3,null,4]\nExplanation: Leaf nodes in green with value (target = 2) are removed (Picture in left). \nAfter removing, new nodes become leaf nodes with value (target = 2) (Picture in center).\n\nExample 2:\n\n\nInput: root = [1,3,3,3,2], target = 3\nOutput: [1,3,null,null,2]\n\nExample 3:\n\n\nInput: root = [1,2,null,2,null,2], target = 2\nOutput: [1]\nExplanation: Leaf nodes in green with value (target = 2) are removed at each step.\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 3000].\n1 <= Node.val, target <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([1, 2, None, 2, None, 2]),target = 2), tree_node([1]))\n assert candidate(root = tree_node([1000, 1000, 1000, 1000, 1000, 1000, 1000]),target = 1000) == None\n assert candidate(root = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),target = 1) == None\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, 4, 5, None, 6, 7, None, 8, 9, 10]),target = 5), tree_node([1, 2, 3, None, 4, 5, None, 6, 7, None, 8, 9, 10]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 2, None, 2, 4]),target = 2), tree_node([1, None, 3, None, 4]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 2, 2, 4, 2, None, 2, None, 2, None, 2]),target = 2), tree_node([1, 2, 3, 4, None, None, 4]))\n assert is_same_tree(candidate(root = tree_node([1, 3, 3, 3, 2]),target = 3), tree_node([1, 3, None, None, 2]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, None, None, 4]),target = 4), tree_node([1, 2, 3]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),target = 15), tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2]),target = 3), tree_node([1, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3]),target = 4), tree_node([1, 2, 3]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]),target = 2), tree_node([1]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, None, 4, 5]),target = 2), tree_node([1, None, 3, 4, 5]))\n assert candidate(root = tree_node([1, None, 1, None, 1, None, 1]),target = 1) == None\n assert is_same_tree(candidate(root = tree_node([1, 2, 3]),target = 2), tree_node([1, None, 3]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),target = 7), tree_node([1, 2, 3, 4, 5, 6]))\n assert candidate(root = tree_node([1, 1, 1, 1, 1, 1, 1]),target = 1) == None\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]),target = 2), tree_node([1, None, 3]))\n assert candidate(root = tree_node([1, None, 1, None, 1, None, 1, None, 1]),target = 1) == None\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),target = 10), tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, None, 11, 12, 13, 14, 15]))\n assert is_same_tree(candidate(root = tree_node([1, None, 3, None, 4, 5, None, 6, 7]),target = 2), tree_node([1, None, 3, None, 4, 5, None, 6, 7]))\n assert candidate(root = tree_node([1]),target = 1) == None\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, None, 4, 5]),target = 5), tree_node([1, 2, 3, None, None, 4]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 2, 2, 2, 4]),target = 2), tree_node([1, None, 3, None, 4]))\n assert is_same_tree(candidate(root = tree_node([1, None, 3, 3, 3]),target = 3), tree_node([1]))\n assert is_same_tree(candidate(root = tree_node([1, None, 3, 2, 2, None, 4, 2, None, 2]),target = 2), tree_node([1, None, 3, 2, None, None, 4]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),target = 3), tree_node([1, 2, 3, 4, 5, 6, 7]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 2, 2, 2, 2]),target = 2), tree_node([1, None, 3]))\n assert candidate(root = tree_node([1, None, 1, 1, 1, 1, 1, 1]),target = 1) == None\n"}, "metadata": {"canonical_parameter_names": ["root", "target"], "leetcode_dataset_entry_point": "Solution().removeLeafNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def removeLeafNodes(self, root: TreeNode | None, target: int) -> TreeNode | None:", "container": "Solution", "callable": "removeLeafNodes", "parameters": [{"name": "root", "type": "TreeNode | None"}, {"name": "target", "type": "int"}], "return_type": "TreeNode | None", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1326, "task_id": "minimum-number-of-taps-to-open-to-water-a-garden", "difficulty": "Hard", "problem_description": "There is a one-dimensional garden on the x-axis. The garden starts at the point 0 and ends at the point n. (i.e., the length of the garden is n).\nThere are n + 1 taps located at points [0, 1, ..., n] in the garden.\nGiven an integer n and an integer array ranges of length n + 1 where ranges[i] (0-indexed) means the i-th tap can water the area [i - ranges[i], i + ranges[i]] if it was open.\nReturn the minimum number of taps that should be open to water the whole garden, If the garden cannot be watered return -1.\n \nExample 1:\n\n\nInput: n = 5, ranges = [3,4,1,1,0,0]\nOutput: 1\nExplanation: The tap at point 0 can cover the interval [-3,3]\nThe tap at point 1 can cover the interval [-3,5]\nThe tap at point 2 can cover the interval [1,3]\nThe tap at point 3 can cover the interval [2,4]\nThe tap at point 4 can cover the interval [4,4]\nThe tap at point 5 can cover the interval [5,5]\nOpening Only the second tap will water the whole garden [0,5]\n\nExample 2:\n\nInput: n = 3, ranges = [0,0,0,0]\nOutput: -1\nExplanation: Even if you activate all the four taps you cannot water the whole garden.\n\n \nConstraints:\n\n1 <= n <= 104\nranges.length == n + 1\n0 <= ranges[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 5,ranges = [3, 4, 1, 1, 0, 0]) == 1\n assert candidate(n = 8,ranges = [4, 0, 0, 0, 0, 0, 0, 0, 4]) == 2\n assert candidate(n = 3,ranges = [0, 0, 0, 0]) == -1\n assert candidate(n = 2,ranges = [1, 0, 1]) == 2\n assert candidate(n = 6,ranges = [1, 2, 3, 4, 5, 6, 7]) == 1\n assert candidate(n = 8,ranges = [4, 0, 0, 0, 0, 0, 1, 0, 1]) == -1\n assert candidate(n = 7,ranges = [1, 2, 1, 0, 2, 1, 0, 1]) == 3\n assert candidate(n = 10,ranges = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(n = 6,ranges = [1, 2, 1, 0, 2, 1, 0]) == 2\n assert candidate(n = 1,ranges = [1, 1]) == 1\n assert candidate(n = 6,ranges = [1, 2, 2, 1, 0, 1, 0]) == 2\n assert candidate(n = 20,ranges = [0, 2, 1, 1, 0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 0, 1, 0, 1, 0]) == 8\n assert candidate(n = 7,ranges = [1, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(n = 12,ranges = [0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2]) == 6\n assert candidate(n = 20,ranges = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 6\n assert candidate(n = 20,ranges = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 20,ranges = [4, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 1, 2, 0, 1, 0, 0, 1, 0, 1, 0]) == -1\n assert candidate(n = 10,ranges = [2, 3, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 3\n assert candidate(n = 20,ranges = [5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]) == -1\n assert candidate(n = 15,ranges = [3, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0]) == -1\n assert candidate(n = 14,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 7,ranges = [3, 2, 2, 3, 2, 2, 1, 1]) == 2\n assert candidate(n = 10,ranges = [2, 3, 0, 2, 1, 0, 1, 0, 1, 0, 1]) == 5\n assert candidate(n = 14,ranges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1]) == 1\n assert candidate(n = 25,ranges = [4, 2, 1, 1, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 7,ranges = [0, 1, 0, 0, 1, 0, 1, 0]) == -1\n assert candidate(n = 12,ranges = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(n = 12,ranges = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(n = 15,ranges = [1, 2, 2, 3, 1, 2, 3, 0, 1, 2, 1, 0, 1, 2, 1, 0]) == 4\n assert candidate(n = 9,ranges = [0, 0, 2, 0, 0, 0, 2, 0, 0, 2]) == 3\n assert candidate(n = 11,ranges = [0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 5\n assert candidate(n = 12,ranges = [4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4]) == -1\n assert candidate(n = 12,ranges = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 9,ranges = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 5\n assert candidate(n = 10,ranges = [2, 2, 0, 2, 2, 0, 1, 0, 1, 2, 0]) == 4\n assert candidate(n = 12,ranges = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 3\n assert candidate(n = 10,ranges = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(n = 9,ranges = [0, 0, 1, 0, 0, 0, 0, 0, 1, 1]) == -1\n assert candidate(n = 25,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 8,ranges = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(n = 15,ranges = [3, 1, 4, 2, 1, 0, 1, 0, 0, 2, 3, 0, 1, 0, 1, 0]) == 4\n assert candidate(n = 8,ranges = [0, 1, 2, 3, 4, 3, 2, 1, 0]) == 1\n assert candidate(n = 13,ranges = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(n = 12,ranges = [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4]) == -1\n assert candidate(n = 20,ranges = [3, 1, 0, 0, 0, 0, 0, 2, 2, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0]) == -1\n assert candidate(n = 7,ranges = [3, 2, 1, 0, 0, 0, 2, 1]) == -1\n assert candidate(n = 7,ranges = [3, 0, 1, 2, 0, 1, 0, 1]) == 4\n assert candidate(n = 12,ranges = [0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(n = 20,ranges = [10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 8,ranges = [0, 1, 0, 0, 0, 2, 1, 0, 1]) == -1\n assert candidate(n = 15,ranges = [3, 0, 1, 1, 0, 2, 1, 0, 0, 2, 3, 1, 0, 1, 0, 1]) == 5\n assert candidate(n = 9,ranges = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 15,ranges = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(n = 12,ranges = [2, 3, 0, 1, 0, 3, 0, 1, 0, 0, 1, 0, 1]) == -1\n assert candidate(n = 10,ranges = [3, 1, 2, 1, 3, 2, 1, 1, 2, 3, 1]) == 3\n assert candidate(n = 12,ranges = [0, 0, 3, 0, 0, 2, 0, 1, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 25,ranges = [0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 20,ranges = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10]) == 2\n assert candidate(n = 11,ranges = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 6\n assert candidate(n = 8,ranges = [3, 0, 2, 1, 1, 0, 2, 1, 1]) == 2\n assert candidate(n = 10,ranges = [2, 3, 1, 1, 0, 2, 1, 0, 1, 2, 1]) == 3\n assert candidate(n = 18,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 10,ranges = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1]) == 2\n assert candidate(n = 8,ranges = [0, 0, 2, 0, 0, 0, 2, 1, 1]) == 2\n assert candidate(n = 18,ranges = [5, 0, 3, 0, 0, 0, 0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 4]) == 6\n assert candidate(n = 14,ranges = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0]) == -1\n assert candidate(n = 10,ranges = [2, 3, 1, 4, 0, 1, 2, 0, 3, 1, 2]) == 2\n assert candidate(n = 11,ranges = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 8,ranges = [1, 0, 1, 1, 0, 0, 0, 1, 1]) == -1\n assert candidate(n = 15,ranges = [3, 0, 0, 0, 3, 2, 0, 1, 0, 0, 2, 0, 0, 0, 1]) == -1\n assert candidate(n = 10,ranges = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(n = 13,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 9,ranges = [4, 0, 0, 0, 4, 0, 0, 0, 4, 0]) == 2\n assert candidate(n = 10,ranges = [2, 3, 1, 4, 0, 0, 2, 0, 1, 0, 1]) == 3\n assert candidate(n = 15,ranges = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(n = 18,ranges = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 15,ranges = [3, 0, 1, 1, 0, 0, 0, 1, 2, 1, 0, 1, 1, 0, 0, 3]) == -1\n assert candidate(n = 14,ranges = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1]) == 1\n assert candidate(n = 9,ranges = [0, 2, 1, 3, 1, 2, 0, 1, 0, 2]) == 3\n assert candidate(n = 14,ranges = [3, 2, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1]) == -1\n assert candidate(n = 20,ranges = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]) == -1\n assert candidate(n = 7,ranges = [3, 2, 0, 0, 1, 0, 1, 1]) == 3\n assert candidate(n = 12,ranges = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 1\n assert candidate(n = 50,ranges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == -1\n assert candidate(n = 12,ranges = [0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 15,ranges = [1, 2, 2, 3, 1, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(n = 20,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 25,ranges = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 3\n assert candidate(n = 20,ranges = [4, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(n = 10,ranges = [2, 3, 1, 0, 0, 1, 2, 1, 0, 2, 0]) == 3\n assert candidate(n = 20,ranges = [2, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0]) == -1\n assert candidate(n = 20,ranges = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n"}, "metadata": {"canonical_parameter_names": ["n", "ranges"], "leetcode_dataset_entry_point": "Solution().minTaps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minTaps(self, n: int, ranges: list[int]) -> int:", "container": "Solution", "callable": "minTaps", "parameters": [{"name": "n", "type": "int"}, {"name": "ranges", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1328, "task_id": "break-a-palindrome", "difficulty": "Medium", "problem_description": "Given a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the resulting string is not a palindrome and that it is the lexicographically smallest one possible.\nReturn the resulting string. If there is no way to replace a character to make it not a palindrome, return an empty string.\nA string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, a has a character strictly smaller than the corresponding character in b. For example, \"abcc\" is lexicographically smaller than \"abcd\" because the first position they differ is at the fourth character, and 'c' is smaller than 'd'.\n \nExample 1:\n\nInput: palindrome = \"abccba\"\nOutput: \"aaccba\"\nExplanation: There are many ways to make \"abccba\" not a palindrome, such as \"zbccba\", \"aaccba\", and \"abacba\".\nOf all the ways, \"aaccba\" is the lexicographically smallest.\n\nExample 2:\n\nInput: palindrome = \"a\"\nOutput: \"\"\nExplanation: There is no way to replace a single character to make \"a\" not a palindrome, so return an empty string.\n\n \nConstraints:\n\n1 <= palindrome.length <= 1000\npalindrome consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(palindrome = \"refer\") == \"aefer\"\n assert candidate(palindrome = \"abba\") == \"aaba\"\n assert candidate(palindrome = \"rotor\") == \"aotor\"\n assert candidate(palindrome = \"aa\") == \"ab\"\n assert candidate(palindrome = \"aba\") == \"abb\"\n assert candidate(palindrome = \"a\") == \"\"\n assert candidate(palindrome = \"madam\") == \"aadam\"\n assert candidate(palindrome = \"abccba\") == \"aaccba\"\n assert candidate(palindrome = \"racecar\") == \"aacecar\"\n assert candidate(palindrome = \"moom\") == \"aoom\"\n assert candidate(palindrome = \"aabaa\") == \"aabab\"\n assert candidate(palindrome = \"zzz\") == \"azz\"\n assert candidate(palindrome = \"xyx\") == \"ayx\"\n assert candidate(palindrome = \"level\") == \"aevel\"\n assert candidate(palindrome = \"aaaaa\") == \"aaaab\"\n assert candidate(palindrome = \"abcdedcba\") == \"aacdedcba\"\n assert candidate(palindrome = \"abcba\") == \"aacba\"\n assert candidate(palindrome = \"bcb\") == \"acb\"\n assert candidate(palindrome = \"noon\") == \"aoon\"\n assert candidate(palindrome = \"mamad\") == \"aamad\"\n assert candidate(palindrome = \"deified\") == \"aeified\"\n assert candidate(palindrome = \"z\") == \"\"\n assert candidate(palindrome = \"aabaaa\") == \"aaaaaa\"\n assert candidate(palindrome = \"toot\") == \"aoot\"\n assert candidate(palindrome = \"babababab\") == \"aabababab\"\n assert candidate(palindrome = \"peep\") == \"aeep\"\n assert candidate(palindrome = \"ppppppppp\") == \"apppppppp\"\n assert candidate(palindrome = \"aabbaa\") == \"aaabaa\"\n assert candidate(palindrome = \"abcdefghihgfedcba\") == \"aacdefghihgfedcba\"\n assert candidate(palindrome = \"zzzzzzzz\") == \"azzzzzzz\"\n assert candidate(palindrome = \"bbaab\") == \"abaab\"\n assert candidate(palindrome = \"redder\") == \"aedder\"\n assert candidate(palindrome = \"abcdefghgfedcba\") == \"aacdefghgfedcba\"\n assert candidate(palindrome = \"abcdefghijklmnoponmlkjihgfedcbaedcbafghijklmnop\") == \"aacdefghijklmnoponmlkjihgfedcbaedcbafghijklmnop\"\n assert candidate(palindrome = \"abacaba\") == \"aaacaba\"\n assert candidate(palindrome = \"aabbccddeeffgggggeeeddccbbaa\") == \"aaabccddeeffgggggeeeddccbbaa\"\n assert candidate(palindrome = \"xyzzyx\") == \"ayzzyx\"\n assert candidate(palindrome = \"kayakkayak\") == \"aayakkayak\"\n assert candidate(palindrome = \"repaper\") == \"aepaper\"\n assert candidate(palindrome = \"aaaaaaaa\") == \"aaaaaaab\"\n assert candidate(palindrome = \"ivicc\") == \"avicc\"\n assert candidate(palindrome = \"abaacaaba\") == \"aaaacaaba\"\n assert candidate(palindrome = \"racecarxracecar\") == \"aacecarxracecar\"\n assert candidate(palindrome = \"abacdfgdcaba\") == \"aaacdfgdcaba\"\n assert candidate(palindrome = \"nnnnnnnnna\") == \"annnnnnnna\"\n assert candidate(palindrome = \"aaaaaaaaa\") == \"aaaaaaaab\"\n assert candidate(palindrome = \"abcdddcba\") == \"aacdddcba\"\n assert candidate(palindrome = \"aabbccddeeffgggeeeddccbbaa\") == \"aaabccddeeffgggeeeddccbbaa\"\n assert candidate(palindrome = \"stats\") == \"atats\"\n assert candidate(palindrome = \"aacaaca\") == \"aaaaaca\"\n assert candidate(palindrome = \"reviver\") == \"aeviver\"\n assert candidate(palindrome = \"aabbccddeedccbaa\") == \"aaabccddeedccbaa\"\n assert candidate(palindrome = \"amanaplanacanalpanama\") == \"aaanaplanacanalpanama\"\n assert candidate(palindrome = \"xyzyx\") == \"ayzyx\"\n assert candidate(palindrome = \"ababababab\") == \"aaabababab\"\n assert candidate(palindrome = \"zzzzzzzzz\") == \"azzzzzzzz\"\n assert candidate(palindrome = \"abaababa\") == \"aaaababa\"\n assert candidate(palindrome = \"aaaaaaaaaa\") == \"aaaaaaaaab\"\n assert candidate(palindrome = \"aabbccddeedccbbaa\") == \"aaabccddeedccbbaa\"\n assert candidate(palindrome = \"noonnoon\") == \"aoonnoon\"\n assert candidate(palindrome = \"aabbccddeeffgggeeddccbbaa\") == \"aaabccddeeffgggeeddccbbaa\"\n assert candidate(palindrome = \"reviled\") == \"aeviled\"\n assert candidate(palindrome = \"aabbbaa\") == \"aaabbaa\"\n assert candidate(palindrome = \"aabbccddeeffggfeeddccbbaa\") == \"aaabccddeeffggfeeddccbbaa\"\n assert candidate(palindrome = \"rotator\") == \"aotator\"\n assert candidate(palindrome = \"abccbaa\") == \"aaccbaa\"\n assert candidate(palindrome = \"bbbbb\") == \"abbbb\"\n assert candidate(palindrome = \"aaa\") == \"aab\"\n assert candidate(palindrome = \"aabbccddeccbaa\") == \"aaabccddeccbaa\"\n assert candidate(palindrome = \"ababababa\") == \"aaabababa\"\n assert candidate(palindrome = \"aabbccddeeffgggggggeeeddccbbaa\") == \"aaabccddeeffgggggggeeeddccbbaa\"\n assert candidate(palindrome = \"aaaabaaa\") == \"aaaabaab\"\n assert candidate(palindrome = \"fedcbafedcba\") == \"aedcbafedcba\"\n assert candidate(palindrome = \"abcbaba\") == \"aacbaba\"\n assert candidate(palindrome = \"aaabaaa\") == \"aaabaab\"\n assert candidate(palindrome = \"zyxwvutsrqponmlkjihgfedcbaedcba\") == \"ayxwvutsrqponmlkjihgfedcbaedcba\"\n assert candidate(palindrome = \"sees\") == \"aees\"\n assert candidate(palindrome = \"aabbccddeeffggggggfeeddccbbaa\") == \"aaabccddeeffggggggfeeddccbbaa\"\n assert candidate(palindrome = \"aaaaaaa\") == \"aaaaaab\"\n assert candidate(palindrome = \"bbcb\") == \"abcb\"\n assert candidate(palindrome = \"zyxwvutsrqponmlkjihgfedcbaedcbafghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"ayxwvutsrqponmlkjihgfedcbaedcbafghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(palindrome = \"civic\") == \"aivic\"\n assert candidate(palindrome = \"zzzzzzz\") == \"azzzzzz\"\n assert candidate(palindrome = \"babababababababababababababababababa\") == \"aabababababababababababababababababa\"\n assert candidate(palindrome = \"repaid\") == \"aepaid\"\n assert candidate(palindrome = \"rotorrotor\") == \"aotorrotor\"\n assert candidate(palindrome = \"abcdeedcba\") == \"aacdeedcba\"\n assert candidate(palindrome = \"reeve\") == \"aeeve\"\n assert candidate(palindrome = \"abcddddcba\") == \"aacddddcba\"\n assert candidate(palindrome = \"kayak\") == \"aayak\"\n assert candidate(palindrome = \"reviler\") == \"aeviler\"\n assert candidate(palindrome = \"abcdefedcba\") == \"aacdefedcba\"\n assert candidate(palindrome = \"rotavator\") == \"aotavator\"\n assert candidate(palindrome = \"madamimadam\") == \"aadamimadam\"\n assert candidate(palindrome = \"redivider\") == \"aedivider\"\n assert candidate(palindrome = \"abacabadaba\") == \"aaacabadaba\"\n assert candidate(palindrome = \"abcddcba\") == \"aacddcba\"\n assert candidate(palindrome = \"aaaabaaaa\") == \"aaaabaaab\"\n assert candidate(palindrome = \"leveler\") == \"aeveler\"\n assert candidate(palindrome = \"abababa\") == \"aaababa\"\n assert candidate(palindrome = \"abecba\") == \"aaecba\"\n assert candidate(palindrome = \"zaz\") == \"aaz\"\n assert candidate(palindrome = \"aabbccbaa\") == \"aaabccbaa\"\n assert candidate(palindrome = \"abcdcba\") == \"aacdcba\"\n assert candidate(palindrome = \"aabbccddeeffggggfeeddccbbaa\") == \"aaabccddeeffggggfeeddccbbaa\"\n assert candidate(palindrome = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\") == \"acbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\"\n assert candidate(palindrome = \"anana\") == \"aaana\"\n assert candidate(palindrome = \"bababababa\") == \"aababababa\"\n assert candidate(palindrome = \"zzzzz\") == \"azzzz\"\n assert candidate(palindrome = \"abcaaba\") == \"aacaaba\"\n assert candidate(palindrome = \"bob\") == \"aob\"\n assert candidate(palindrome = \"abaabaaabaabaa\") == \"aaaabaaabaabaa\"\n assert candidate(palindrome = \"deed\") == \"aeed\"\n assert candidate(palindrome = \"detartrated\") == \"aetartrated\"\n assert candidate(palindrome = \"civiccivic\") == \"aiviccivic\"\n assert candidate(palindrome = \"zzzz\") == \"azzz\"\n assert candidate(palindrome = \"repel\") == \"aepel\"\n assert candidate(palindrome = \"deedeed\") == \"aeedeed\"\n"}, "metadata": {"canonical_parameter_names": ["palindrome"], "leetcode_dataset_entry_point": "Solution().breakPalindrome", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def breakPalindrome(self, palindrome: str) -> str:", "container": "Solution", "callable": "breakPalindrome", "parameters": [{"name": "palindrome", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1329, "task_id": "sort-the-matrix-diagonally", "difficulty": "Medium", "problem_description": "A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix's end. For example, the matrix diagonal starting from mat[2][0], where mat is a 6 x 3 matrix, includes cells mat[2][0], mat[3][1], and mat[4][2].\nGiven an m x n matrix mat of integers, sort each matrix diagonal in ascending order and return the resulting matrix.\n \nExample 1:\n\n\nInput: mat = [[3,3,1,1],[2,2,1,2],[1,1,1,2]]\nOutput: [[1,1,1,1],[1,2,2,2],[1,2,3,3]]\n\nExample 2:\n\nInput: mat = [[11,25,66,1,69,7],[23,55,17,45,15,52],[75,31,36,44,58,8],[22,27,33,25,68,4],[84,28,14,11,5,50]]\nOutput: [[5,17,4,1,52,7],[11,11,25,45,8,69],[14,23,25,44,58,15],[22,27,31,36,50,66],[84,28,75,33,55,68]]\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n1 <= m, n <= 100\n1 <= mat[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1]]) == [[1]]\n assert candidate(mat = [[37, 47, 1, 44], [20, 3, 2, 90], [96, 50, 4, 24]]) == [[3, 2, 1, 44], [20, 4, 24, 90], [96, 50, 37, 47]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]\n assert candidate(mat = [[30, 29, 28, 27, 26, 25], [24, 23, 22, 21, 20, 19], [18, 17, 16, 15, 14, 13], [12, 11, 10, 9, 8, 7], [6, 5, 4, 3, 2, 1]]) == [[2, 1, 7, 13, 19, 25], [3, 9, 8, 14, 20, 26], [4, 10, 16, 15, 21, 27], [5, 11, 17, 23, 22, 28], [6, 12, 18, 24, 30, 29]]\n assert candidate(mat = [[30, 29, 19, 53, 22], [47, 27, 45, 54, 30], [28, 42, 23, 45, 52], [40, 11, 52, 33, 46], [15, 50, 46, 32, 48]]) == [[23, 29, 19, 30, 22], [32, 27, 45, 52, 53], [11, 42, 30, 45, 54], [40, 28, 47, 33, 46], [15, 50, 46, 52, 48]]\n assert candidate(mat = [[11, 25, 66, 1, 69, 7], [23, 55, 17, 45, 15, 52], [75, 31, 36, 44, 58, 8], [22, 27, 33, 25, 68, 4], [84, 28, 14, 11, 5, 50]]) == [[5, 17, 4, 1, 52, 7], [11, 11, 25, 45, 8, 69], [14, 23, 25, 44, 58, 15], [22, 27, 31, 36, 50, 66], [84, 28, 75, 33, 55, 68]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 2], [3, 4], [5, 6], [7, 8]]\n assert candidate(mat = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == [[1, 4, 7], [2, 5, 8], [3, 6, 9]]\n assert candidate(mat = [[3, 3, 1, 1], [2, 2, 1, 2], [1, 1, 1, 2]]) == [[1, 1, 1, 1], [1, 2, 2, 2], [1, 2, 3, 3]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n assert candidate(mat = [[10, 9, 8, 7], [6, 5, 4, 3], [2, 1, 0, -1]]) == [[0, -1, 3, 7], [1, 5, 4, 8], [2, 6, 10, 9]]\n assert candidate(mat = [[100, 99, 98], [97, 96, 95], [94, 93, 92]]) == [[92, 95, 98], [93, 96, 99], [94, 97, 100]]\n assert candidate(mat = [[10, 9, 8, 7], [6, 5, 4, 3], [2, 1, 1, 1]]) == [[1, 1, 3, 7], [1, 5, 4, 8], [2, 6, 10, 9]]\n assert candidate(mat = [[37, 71], [58, 62]]) == [[37, 71], [58, 62]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]\n assert candidate(mat = [[1, 10, 3, 7, 5], [6, 2, 8, 4, 1], [11, 13, 12, 15, 14], [17, 16, 19, 18, 20]]) == [[1, 8, 3, 1, 5], [6, 2, 10, 4, 7], [11, 13, 12, 15, 14], [17, 16, 19, 18, 20]]\n assert candidate(mat = [[100, 99, 98, 97, 96, 95, 94, 93, 92, 91], [90, 89, 88, 87, 86, 85, 84, 83, 82, 81], [80, 79, 78, 77, 76, 75, 74, 73, 72, 71], [70, 69, 68, 67, 66, 65, 64, 63, 62, 61], [60, 59, 58, 57, 56, 55, 54, 53, 52, 51], [50, 49, 48, 47, 46, 45, 44, 43, 42, 41], [40, 39, 38, 37, 36, 35, 34, 33, 32, 31], [30, 29, 28, 27, 26, 25, 24, 23, 22, 21], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [[1, 11, 21, 31, 41, 51, 61, 71, 81, 91], [2, 12, 22, 32, 42, 52, 62, 72, 82, 92], [3, 13, 23, 33, 43, 53, 63, 73, 83, 93], [4, 14, 24, 34, 44, 54, 64, 74, 84, 94], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [6, 16, 26, 36, 46, 56, 66, 76, 86, 96], [7, 17, 27, 37, 47, 57, 67, 77, 87, 97], [8, 18, 28, 38, 48, 58, 68, 78, 88, 98], [9, 19, 29, 39, 49, 59, 69, 79, 89, 99], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]\n assert candidate(mat = [[99, 98, 97, 96, 95], [94, 93, 92, 91, 90], [89, 88, 87, 86, 85], [84, 83, 82, 81, 80], [79, 78, 77, 76, 75]]) == [[75, 80, 85, 90, 95], [76, 81, 86, 91, 96], [77, 82, 87, 92, 97], [78, 83, 88, 93, 98], [79, 84, 89, 94, 99]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14], [2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15], [3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14, 1], [4, 6, 8, 10, 12, 14, 1, 2, 3, 5, 7, 9, 11, 13, 15], [5, 7, 9, 11, 13, 15, 2, 3, 4, 6, 8, 10, 12, 14, 1], [6, 8, 10, 12, 14, 1, 2, 3, 4, 5, 7, 9, 11, 13, 15]]) == [[1, 1, 2, 2, 1, 3, 2, 4, 1, 5, 1, 3, 2, 1, 15], [2, 2, 2, 3, 3, 4, 6, 5, 7, 6, 8, 4, 12, 13, 14], [1, 3, 3, 3, 4, 4, 5, 6, 7, 7, 6, 10, 10, 12, 14], [2, 1, 6, 5, 4, 5, 6, 5, 7, 8, 8, 9, 11, 11, 15], [3, 5, 4, 9, 8, 7, 9, 7, 8, 9, 8, 10, 9, 14, 13], [4, 6, 8, 7, 12, 11, 10, 12, 11, 9, 10, 9, 11, 12, 15], [5, 7, 9, 11, 10, 15, 14, 13, 12, 11, 10, 11, 12, 14, 13], [6, 8, 10, 12, 14, 13, 15, 14, 13, 15, 14, 13, 15, 13, 15]]\n assert candidate(mat = [[1, 9, 3, 7, 5], [6, 2, 8, 4, 10], [11, 13, 12, 15, 14], [17, 16, 19, 18, 20]]) == [[1, 8, 3, 7, 5], [6, 2, 9, 4, 10], [11, 13, 12, 15, 14], [17, 16, 19, 18, 20]]\n assert candidate(mat = [[15, 25, 35, 45, 55], [14, 24, 34, 44, 54], [13, 23, 33, 43, 53], [12, 22, 32, 42, 52], [11, 21, 31, 41, 51]]) == [[15, 25, 35, 45, 55], [14, 24, 34, 44, 54], [13, 23, 33, 43, 53], [12, 22, 32, 42, 52], [11, 21, 31, 41, 51]]\n assert candidate(mat = [[8, 5, 2, 7], [9, 6, 3, 4], [1, 0, 5, 8], [2, 1, 6, 3]]) == [[3, 3, 2, 7], [0, 5, 5, 4], [1, 6, 6, 8], [2, 1, 9, 8]]\n assert candidate(mat = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]\n assert candidate(mat = [[99, 98, 97, 96, 95, 94, 93, 92, 91, 90], [89, 88, 87, 86, 85, 84, 83, 82, 81, 80], [79, 78, 77, 76, 75, 74, 73, 72, 71, 70], [69, 68, 67, 66, 65, 64, 63, 62, 61, 60], [59, 58, 57, 56, 55, 54, 53, 52, 51, 50], [49, 48, 47, 46, 45, 44, 43, 42, 41, 40], [39, 38, 37, 36, 35, 34, 33, 32, 31, 30], [29, 28, 27, 26, 25, 24, 23, 22, 21, 20], [19, 18, 17, 16, 15, 14, 13, 12, 11, 10], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]) == [[0, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 11, 21, 31, 41, 51, 61, 71, 81, 91], [2, 12, 22, 32, 42, 52, 62, 72, 82, 92], [3, 13, 23, 33, 43, 53, 63, 73, 83, 93], [4, 14, 24, 34, 44, 54, 64, 74, 84, 94], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [6, 16, 26, 36, 46, 56, 66, 76, 86, 96], [7, 17, 27, 37, 47, 57, 67, 77, 87, 97], [8, 18, 28, 38, 48, 58, 68, 78, 88, 98], [9, 19, 29, 39, 49, 59, 69, 79, 89, 99]]\n assert candidate(mat = [[50, 30, 10, 90], [80, 60, 40, 20], [70, 50, 30, 10], [60, 40, 20, 80], [50, 30, 10, 70], [40, 20, 80, 60], [30, 10, 70, 50]]) == [[30, 10, 10, 90], [20, 50, 30, 20], [10, 50, 60, 40], [30, 40, 70, 80], [20, 50, 60, 80], [10, 50, 60, 70], [30, 40, 70, 80]]\n assert candidate(mat = [[9, 7, 5, 3, 1], [10, 8, 6, 4, 2], [11, 9, 7, 5, 3], [12, 10, 8, 6, 4], [13, 11, 9, 7, 5]]) == [[5, 4, 3, 2, 1], [7, 6, 5, 4, 3], [9, 8, 7, 6, 5], [11, 10, 9, 8, 7], [13, 12, 11, 10, 9]]\n assert candidate(mat = [[1, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10]]) == [[1, 4, 5, 6, 7, 10], [2, 3, 6, 7, 8, 9], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10]]\n assert candidate(mat = [[1, 3, 5, 7, 9], [10, 8, 6, 4, 2], [11, 13, 15, 17, 19], [20, 18, 16, 14, 12]]) == [[1, 3, 4, 2, 9], [10, 8, 6, 5, 7], [11, 13, 14, 12, 19], [20, 18, 16, 15, 17]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60]]\n assert candidate(mat = [[100, 99, 98, 97, 96, 95, 94, 93, 92, 91], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]) == [[2, 3, 4, 5, 6, 7, 8, 9, 10, 91], [1, 13, 14, 15, 16, 17, 18, 19, 20, 92], [11, 12, 24, 25, 26, 27, 28, 29, 30, 93], [21, 22, 23, 100, 99, 98, 97, 96, 95, 94]]\n assert candidate(mat = [[50, 40, 30, 20, 10], [55, 45, 35, 25, 15], [60, 50, 40, 30, 20], [65, 55, 45, 35, 25], [70, 60, 50, 40, 30]]) == [[30, 25, 20, 15, 10], [40, 35, 30, 25, 20], [50, 45, 40, 35, 30], [60, 55, 50, 45, 40], [70, 65, 60, 55, 50]]\n assert candidate(mat = [[1, 9, 2, 8, 3, 7, 4, 6, 5], [2, 8, 3, 7, 4, 6, 5, 9, 1], [3, 7, 4, 6, 5, 9, 1, 2, 8], [4, 6, 5, 9, 1, 2, 8, 3, 7], [5, 9, 1, 2, 8, 3, 7, 4, 6]]) == [[1, 1, 2, 4, 1, 2, 4, 1, 5], [2, 4, 3, 2, 4, 3, 5, 8, 6], [1, 2, 8, 3, 5, 8, 3, 7, 9], [4, 3, 5, 8, 6, 7, 8, 6, 7], [5, 9, 6, 7, 9, 9, 7, 9, 6]]\n assert candidate(mat = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [10, 9, 8, 7, 6, 5, 4, 3, 2], [11, 10, 9, 8, 7, 6, 5, 4, 3], [12, 11, 10, 9, 8, 7, 6, 5, 4], [13, 12, 11, 10, 9, 8, 7, 6, 5]]) == [[9, 8, 7, 6, 5, 4, 3, 2, 1], [10, 9, 8, 7, 6, 5, 4, 3, 2], [11, 10, 9, 8, 7, 6, 5, 4, 3], [12, 11, 10, 9, 8, 7, 6, 5, 4], [13, 12, 11, 10, 9, 8, 7, 6, 5]]\n assert candidate(mat = [[5, 4, 3, 2, 1], [9, 8, 7, 6, 5], [13, 12, 11, 10, 9], [17, 16, 15, 14, 13], [21, 20, 19, 18, 17]]) == [[5, 4, 3, 2, 1], [9, 8, 7, 6, 5], [13, 12, 11, 10, 9], [17, 16, 15, 14, 13], [21, 20, 19, 18, 17]]\n assert candidate(mat = [[10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10]]) == [[10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10]]\n assert candidate(mat = [[25, 24, 23, 22, 21, 20], [19, 18, 17, 16, 15, 14], [13, 12, 11, 10, 9, 8], [7, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 6]]) == [[4, 3, 2, 8, 14, 20], [4, 5, 6, 9, 15, 21], [3, 5, 11, 10, 16, 22], [2, 6, 12, 18, 17, 23], [1, 7, 13, 19, 25, 24]]\n assert candidate(mat = [[50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39], [38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28], [27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17], [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6], [5, 4, 3, 2, 1, 60, 59, 58, 57, 56, 55]]) == [[12, 11, 10, 9, 8, 7, 6, 17, 28, 39, 60], [1, 24, 23, 22, 21, 20, 19, 18, 29, 40, 59], [2, 13, 36, 35, 34, 33, 32, 31, 30, 41, 58], [3, 14, 25, 48, 47, 46, 45, 44, 43, 42, 57], [4, 15, 26, 37, 50, 51, 52, 53, 54, 55, 56], [5, 16, 27, 38, 49, 60, 59, 58, 57, 56, 55]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20]]) == [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20]]\n assert candidate(mat = [[9, 1, 4, 7, 3, 8], [6, 5, 2, 9, 1, 4], [3, 8, 5, 2, 9, 1], [8, 3, 9, 1, 4, 7], [1, 4, 7, 3, 8, 6]]) == [[1, 1, 4, 1, 3, 8], [3, 5, 2, 7, 1, 4], [3, 6, 5, 2, 9, 7], [4, 3, 8, 8, 4, 9], [1, 8, 7, 9, 9, 6]]\n assert candidate(mat = [[10, 9, 8, 7, 6, 5, 4], [3, 2, 1, 10, 9, 8, 7], [4, 3, 2, 1, 10, 9, 8], [5, 4, 3, 2, 1, 10, 9], [6, 5, 4, 3, 2, 1, 10]]) == [[2, 1, 8, 7, 6, 5, 4], [3, 2, 1, 10, 9, 8, 7], [4, 3, 2, 1, 10, 9, 8], [5, 4, 3, 2, 1, 10, 9], [6, 5, 4, 3, 10, 9, 10]]\n assert candidate(mat = [[50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66], [67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83], [84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34], [35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51]]) == [[4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 64, 65, 66], [3, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 63, 82, 83], [2, 21, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 62, 81, 100], [1, 20, 39, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 80, 99], [18, 19, 38, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 98], [35, 36, 37, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]]\n assert candidate(mat = [[14, 13], [12, 11], [10, 9], [8, 7], [6, 5], [4, 3], [2, 1]]) == [[11, 13], [9, 14], [7, 12], [5, 10], [3, 8], [1, 6], [2, 4]]\n assert candidate(mat = [[97, 96, 95, 94, 93, 92, 91, 90], [89, 88, 87, 86, 85, 84, 83, 82], [81, 80, 79, 78, 77, 76, 75, 74], [73, 72, 71, 70, 69, 68, 67, 66], [65, 64, 63, 62, 61, 60, 59, 58], [57, 56, 55, 54, 53, 52, 51, 50], [49, 48, 47, 46, 45, 44, 43, 42], [41, 40, 39, 38, 37, 36, 35, 34], [33, 32, 31, 30, 29, 28, 27, 26], [25, 24, 23, 22, 21, 20, 19, 18], [17, 16, 15, 14, 13, 12, 11, 10], [9, 8, 7, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 6, 7, 8]]) == [[34, 42, 50, 58, 66, 74, 82, 90], [26, 43, 51, 59, 67, 75, 83, 91], [18, 35, 52, 60, 68, 76, 84, 92], [10, 27, 44, 61, 69, 77, 85, 93], [2, 19, 36, 53, 70, 78, 86, 94], [3, 11, 28, 45, 62, 79, 87, 95], [4, 8, 20, 37, 54, 71, 88, 96], [5, 7, 12, 29, 46, 63, 80, 97], [5, 6, 13, 21, 38, 55, 72, 89], [4, 6, 14, 22, 30, 47, 64, 81], [3, 7, 15, 23, 31, 39, 56, 73], [2, 8, 16, 24, 32, 40, 48, 65], [1, 9, 17, 25, 33, 41, 49, 57]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]]) == [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]]\n assert candidate(mat = [[100, 99, 98, 97, 96], [95, 94, 93, 92, 91], [90, 89, 88, 87, 86], [85, 84, 83, 82, 81], [80, 79, 78, 77, 76]]) == [[76, 81, 86, 91, 96], [77, 82, 87, 92, 97], [78, 83, 88, 93, 98], [79, 84, 89, 94, 99], [80, 85, 90, 95, 100]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42, 43, 44, 45]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42, 43, 44, 45]]\n assert candidate(mat = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [3, 5, 7, 9, 11, 13], [4, 6, 8, 10, 12, 14], [5, 7, 9, 11, 13, 15], [6, 8, 10, 12, 14, 16]]) == [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [3, 5, 7, 9, 11, 13], [4, 6, 8, 10, 12, 14], [5, 7, 9, 11, 13, 15], [6, 8, 10, 12, 14, 16]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30]]) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30]]\n assert candidate(mat = [[1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]]) == [[1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]]\n assert candidate(mat = [[5, 10, 15, 20, 25], [30, 35, 40, 45, 50], [55, 60, 65, 70, 75], [80, 85, 90, 95, 100], [105, 110, 115, 120, 125]]) == [[5, 10, 15, 20, 25], [30, 35, 40, 45, 50], [55, 60, 65, 70, 75], [80, 85, 90, 95, 100], [105, 110, 115, 120, 125]]\n assert candidate(mat = [[5, 20, 30, 40, 50], [15, 10, 35, 45, 55], [20, 25, 5, 50, 60], [25, 35, 45, 15, 65]]) == [[5, 20, 30, 40, 50], [15, 5, 35, 45, 55], [20, 25, 10, 50, 60], [25, 35, 45, 15, 65]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35]]) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35]]\n assert candidate(mat = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]]) == [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]]\n assert candidate(mat = [[99, 98, 97, 96, 95, 94, 93, 92, 91], [90, 89, 88, 87, 86, 85, 84, 83, 82], [81, 80, 79, 78, 77, 76, 75, 74, 73], [72, 71, 70, 69, 68, 67, 66, 65, 64], [63, 62, 61, 60, 59, 58, 57, 56, 55], [54, 53, 52, 51, 50, 49, 48, 47, 46], [45, 44, 43, 42, 41, 40, 39, 38, 37], [36, 35, 34, 33, 32, 31, 30, 29, 28], [27, 26, 25, 24, 23, 22, 21, 20, 19], [18, 17, 16, 15, 14, 13, 12, 11, 10], [9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [[19, 28, 37, 46, 55, 64, 73, 82, 91], [10, 29, 38, 47, 56, 65, 74, 83, 92], [1, 20, 39, 48, 57, 66, 75, 84, 93], [2, 11, 30, 49, 58, 67, 76, 85, 94], [3, 12, 21, 40, 59, 68, 77, 86, 95], [4, 13, 22, 31, 50, 69, 78, 87, 96], [5, 14, 23, 32, 41, 60, 79, 88, 97], [6, 15, 24, 33, 42, 51, 70, 89, 98], [7, 16, 25, 34, 43, 52, 61, 80, 99], [8, 17, 26, 35, 44, 53, 62, 71, 90], [9, 18, 27, 36, 45, 54, 63, 72, 81]]\n assert candidate(mat = [[99, 22, 33, 11, 44], [55, 66, 77, 88, 99], [10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [15, 25, 35, 45, 55]]) == [[30, 22, 33, 11, 44], [20, 55, 40, 50, 99], [10, 45, 66, 77, 88], [25, 35, 55, 90, 100], [15, 60, 70, 80, 99]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22], [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33], [34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44], [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22], [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33], [34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44], [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55]]\n assert candidate(mat = [[100, 99, 98, 97, 96, 95], [94, 93, 92, 91, 90, 89], [88, 87, 86, 85, 84, 83], [82, 81, 80, 79, 78, 77], [76, 75, 74, 73, 72, 71]]) == [[72, 71, 77, 83, 89, 95], [73, 79, 78, 84, 90, 96], [74, 80, 86, 85, 91, 97], [75, 81, 87, 93, 92, 98], [76, 82, 88, 94, 100, 99]]\n assert candidate(mat = [[4, 3, 2, 1], [5, 9, 8, 7], [6, 10, 11, 12], [7, 6, 5, 4], [8, 7, 6, 5]]) == [[4, 3, 2, 1], [5, 4, 8, 7], [6, 5, 9, 12], [7, 6, 5, 11], [8, 7, 6, 10]]\n assert candidate(mat = [[9, 7, 8, 6, 5, 4], [3, 2, 1, 10, 11, 12], [15, 14, 13, 18, 17, 16], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]) == [[2, 1, 8, 6, 5, 4], [3, 9, 7, 10, 11, 12], [15, 14, 13, 18, 17, 16], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]\n assert candidate(mat = [[9, 7, 5, 3, 1], [8, 6, 4, 2, 0], [7, 5, 3, 1, 9], [6, 4, 2, 0, 8], [5, 3, 1, 9, 7]]) == [[0, 1, 2, 0, 1], [2, 3, 4, 5, 3], [1, 5, 6, 7, 9], [3, 4, 8, 7, 8], [5, 6, 7, 9, 9]]\n assert candidate(mat = [[45, 12, 23, 34, 45, 56, 67, 78, 89, 90], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [11, 22, 33, 44, 55, 66, 77, 88, 99, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]]) == [[8, 7, 6, 5, 4, 3, 2, 1, 0, 90], [9, 33, 12, 23, 34, 45, 56, 67, 78, 89], [11, 22, 35, 44, 55, 65, 75, 85, 95, 100], [5, 15, 25, 45, 45, 55, 66, 77, 88, 99]]\n assert candidate(mat = [[50, 24, 78, 42, 31], [63, 83, 92, 22, 58], [30, 50, 14, 32, 59], [97, 35, 88, 64, 50]]) == [[14, 24, 22, 42, 31], [50, 50, 32, 59, 58], [30, 63, 64, 50, 78], [97, 35, 88, 83, 92]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3]]) == [[1, 2, 2, 2, 1, 6], [3, 3, 3, 3, 4, 5], [2, 4, 4, 4, 3, 7], [4, 5, 5, 4, 5, 6], [3, 6, 5, 6, 5, 8], [8, 7, 7, 6, 6, 7]]\n assert candidate(mat = [[95, 85, 65, 25, 55, 75, 35, 45, 15], [10, 90, 80, 70, 60, 50, 40, 30, 20], [5, 15, 25, 35, 45, 55, 65, 75, 85]]) == [[25, 35, 45, 25, 50, 40, 30, 20, 15], [10, 90, 80, 65, 55, 55, 75, 35, 45], [5, 15, 95, 85, 70, 60, 65, 75, 85]]\n assert candidate(mat = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65]]) == [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65]]\n assert candidate(mat = [[7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 1, 7, 1, 7, 1, 7, 1, 7, 1], [7, 7, 2, 2, 2, 2, 2, 2, 2, 2], [7, 1, 2, 3, 3, 3, 3, 3, 3, 3], [7, 1, 2, 3, 4, 4, 4, 4, 4, 4], [7, 1, 2, 3, 4, 5, 5, 5, 5, 5], [7, 1, 2, 3, 4, 5, 6, 6, 6, 6]]) == [[1, 2, 1, 2, 1, 2, 1, 2, 1, 7], [2, 2, 3, 2, 3, 2, 3, 2, 7, 7], [1, 3, 3, 4, 3, 4, 3, 4, 3, 7], [1, 2, 4, 4, 5, 4, 5, 4, 7, 7], [1, 2, 3, 5, 5, 6, 5, 6, 5, 7], [1, 2, 3, 4, 7, 6, 7, 6, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]]\n assert candidate(mat = [[9, 7, 11, 8, 5, 4], [12, 14, 10, 3, 13, 15], [6, 2, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25]]) == [[9, 7, 3, 8, 5, 4], [2, 14, 10, 11, 13, 15], [6, 12, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15], [15, 13, 11, 9, 7, 5, 3, 1]]) == [[1, 2, 3, 3, 1, 2, 1, 8], [3, 5, 6, 5, 4, 3, 6, 7], [1, 8, 7, 7, 5, 4, 5, 15], [15, 13, 11, 9, 7, 9, 11, 13]]\n assert candidate(mat = [[100, 99, 98, 97, 96], [95, 94, 93, 92, 91], [90, 89, 88, 87, 86], [85, 84, 83, 82, 81], [80, 79, 78, 77, 76]]) == [[76, 81, 86, 91, 96], [77, 82, 87, 92, 97], [78, 83, 88, 93, 98], [79, 84, 89, 94, 99], [80, 85, 90, 95, 100]]\n assert candidate(mat = [[7, 17, 12, 5, 10, 9, 3], [14, 2, 11, 16, 13, 18, 8], [15, 4, 6, 1, 19, 12, 17], [10, 3, 15, 7, 2, 14, 6], [5, 9, 1, 18, 17, 13, 4]]) == [[2, 1, 4, 5, 10, 8, 3], [4, 6, 2, 12, 6, 17, 9], [1, 14, 7, 11, 14, 12, 18], [9, 3, 15, 7, 13, 16, 13], [5, 10, 15, 18, 17, 17, 19]]\n assert candidate(mat = [[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13], [20, 19, 18, 17]]) == [[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13], [20, 19, 18, 17]]\n assert candidate(mat = [[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3], [3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3], [3, 2, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3], [3, 2, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3], [3, 2, 1, 1, 1, 1, 1, 2, 3, 3, 3, 3], [3, 2, 1, 1, 1, 1, 2, 3, 3, 3, 3, 3], [3, 2, 1, 1, 1, 2, 3, 3, 3, 3, 3, 3], [3, 2, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3], [3, 2, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3], [3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3], [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3], [1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3], [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3], [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3], [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3], [1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3], [2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]\n assert candidate(mat = [[100, 99, 98, 97, 96, 95], [94, 93, 92, 91, 90, 89], [88, 87, 86, 85, 84, 83], [82, 81, 80, 79, 78, 77], [76, 75, 74, 73, 72, 71]]) == [[72, 71, 77, 83, 89, 95], [73, 79, 78, 84, 90, 96], [74, 80, 86, 85, 91, 97], [75, 81, 87, 93, 92, 98], [76, 82, 88, 94, 100, 99]]\n assert candidate(mat = [[5, 12, 11, 10, 9], [8, 4, 3, 2, 1], [9, 8, 7, 6, 5], [10, 9, 8, 7, 6], [11, 10, 9, 8, 7], [12, 11, 10, 9, 8]]) == [[4, 3, 2, 1, 9], [8, 5, 6, 5, 10], [9, 8, 7, 6, 11], [10, 9, 8, 7, 12], [11, 10, 9, 8, 7], [12, 11, 10, 9, 8]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2]]) == [[1, 2, 3, 2, 2, 1, 7], [3, 4, 4, 3, 3, 5, 6], [2, 6, 5, 5, 4, 4, 8], [8, 7, 7, 6, 5, 6, 7]]\n assert candidate(mat = [[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]) == [[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]\n assert candidate(mat = [[33, 22, 11, 44, 55], [66, 77, 88, 99, 100], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == [[3, 4, 5, 44, 55], [2, 9, 10, 11, 100], [1, 8, 15, 22, 99], [6, 7, 14, 33, 88], [11, 12, 13, 20, 77], [16, 17, 18, 19, 66]]\n assert candidate(mat = [[5, 20, 15, 80, 75], [45, 10, 55, 60, 15], [12, 65, 35, 90, 100], [10, 25, 40, 50, 65], [5, 15, 25, 35, 45]]) == [[5, 20, 15, 15, 75], [35, 10, 55, 60, 80], [12, 40, 35, 65, 100], [10, 25, 45, 45, 90], [5, 15, 25, 65, 50]]\n"}, "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().diagonalSort", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def diagonalSort(self, mat: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "diagonalSort", "parameters": [{"name": "mat", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1330, "task_id": "reverse-subarray-to-maximize-array-value", "difficulty": "Hard", "problem_description": "You are given an integer array nums. The value of this array is defined as the sum of |nums[i] - nums[i + 1]| for all 0 <= i < nums.length - 1.\nYou are allowed to select any subarray of the given array and reverse it. You can perform this operation only once.\nFind maximum possible value of the final array.\n \nExample 1:\n\nInput: nums = [2,3,1,5,4]\nOutput: 10\nExplanation: By reversing the subarray [3,1,5] the array becomes [2,5,1,3,4] whose value is 10.\n\nExample 2:\n\nInput: nums = [2,4,9,24,2,1,10]\nOutput: 68\n\n \nConstraints:\n\n2 <= nums.length <= 3 * 104\n-105 <= nums[i] <= 105\nThe answer is guaranteed to fit in a 32-bit integer.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 5]) == 9\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 230\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == 22\n assert candidate(nums = [1, -1, 1, -1, 1]) == 8\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 10\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000]) == 800000\n assert candidate(nums = [-10, -5, 0, 5, 10]) == 40\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 230\n assert candidate(nums = [2, 4, 9, 24, 2, 1, 10]) == 68\n assert candidate(nums = [1, 2, 3, 4, 5]) == 8\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 1]) == 9\n assert candidate(nums = [-1, 4, -2, 3]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [-100000, 100000, -100000, 100000]) == 600000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 200\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 38\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 100000, 1, 100000, 1]) == 399996\n assert candidate(nums = [100, -100, 100, -100]) == 600\n assert candidate(nums = [100000, -100000, 100000, -100000]) == 600000\n assert candidate(nums = [-100000, 100000, -100000, 100000, -100000]) == 800000\n assert candidate(nums = [5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [2, 3, 1, 5, 4]) == 10\n assert candidate(nums = [1, 2, 1, 2, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 38\n assert candidate(nums = [5, 3, 8, 6, 7, 2, 4, 1, 9]) == 33\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 12500]) == 687500\n assert candidate(nums = [-10, 10, -10, 10, -10, 10, -10, 10, -10, 10]) == 180\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 6, 4, 2, 0]) == 29\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50]) == 580\n assert candidate(nums = [100000, 0, -100000, 100000, 0, -100000, 100000]) == 900000\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17, 16, 18, 17, 19, 18, 20, 19, 21, 20]) == 91\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995]) == 11\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 9\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4]) == 38\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 53\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1]) == 39\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 38\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400]) == 2900\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [-50000, 50000, -50000, 50000, -50000]) == 400000\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 9\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == 38\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000, -100000]) == 1000000\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 21\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [100000, 0, -100000, 0, 100000, 0, -100000, 0, 100000]) == 900000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 580\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 23\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 53\n assert candidate(nums = [1, -100000, 2, -99999, 3, -99998, 4, -99997, 5, -99996]) == 900013\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 23\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == 36\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10]) == 43\n assert candidate(nums = [10000, 1000, 100, 10, 1, 0, -1, -10, -100, -1000, -10000]) == 31000\n assert candidate(nums = [1, 2, 3, -1, -2, -3, 4, 5, 6, -4, -5, -6, 7, 8, 9]) == 70\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 28\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 219\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 38\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 38\n assert candidate(nums = [-100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000]) == 1800000\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000]) == 800000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 23\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97]) == 675\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 17\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 320\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [-5, 5, -15, 15, -25, 25, -35, 35, -45, 45, -55, 55]) == 710\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 0, 6, 4, 3, 2, 1]) == 59\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 107\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == 38\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 33\n assert candidate(nums = [1, 2, 3, 100, 3, 2, 1, 99, 2, 1, 0]) == 399\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40]) == 380\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 68\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000]) == 1400000\n assert candidate(nums = [-100000, -100000, -100000, -100000, -100000, -100000, -100000, -100000, -100000, -100000]) == 0\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991]) == 23\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 36\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 236\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 32\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 49\n assert candidate(nums = [1, 2, 3, 4, 5, 10000, 6, 7, 8, 9, 10]) == 20011\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 230\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 53\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500]) == 5800\n assert candidate(nums = [1, 200000, 3, 400000, 5, 600000, 7, 800000, 9, 1000000]) == 5799951\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 4000, 3000, 2000, 1000]) == 12000\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 31\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 859\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9]) == 48\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5]) == 140\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxValueAfterReverse", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxValueAfterReverse(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maxValueAfterReverse", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1331, "task_id": "rank-transform-of-an-array", "difficulty": "Easy", "problem_description": "Given an array of integers arr, replace each element with its rank.\nThe rank represents how large the element is. The rank has the following rules:\n\nRank is an integer starting from 1.\nThe larger the element, the larger the rank. If two elements are equal, their rank must be the same.\nRank should be as small as possible.\n\n \nExample 1:\n\nInput: arr = [40,10,20,30]\nOutput: [4,1,2,3]\nExplanation: 40 is the largest element. 10 is the smallest. 20 is the second smallest. 30 is the third smallest.\nExample 2:\n\nInput: arr = [100,100,100]\nOutput: [1,1,1]\nExplanation: Same elements share the same rank.\n\nExample 3:\n\nInput: arr = [37,12,28,9,100,56,80,5,12]\nOutput: [5,3,4,2,8,6,7,1,3]\n\n \nConstraints:\n\n0 <= arr.length <= 105\n-109 <= arr[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 4, 3, 2, 1]) == [5, 4, 3, 2, 1]\n assert candidate(arr = [-10, 100, 0, 5, 3]) == [1, 5, 2, 4, 3]\n assert candidate(arr = [-10, -20, -30, -40, -50]) == [5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(arr = [0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1]\n assert candidate(arr = [1000000000, -1000000000, 0, 500000000, -500000000]) == [5, 1, 3, 4, 2]\n assert candidate(arr = [1]) == [1]\n assert candidate(arr = [40, 10, 20, 30]) == [4, 1, 2, 3]\n assert candidate(arr = [1000000000, -1000000000, 0]) == [3, 1, 2]\n assert candidate(arr = [37, 12, 28, 9, 100, 56, 80, 5, 12]) == [5, 3, 4, 2, 8, 6, 7, 1, 3]\n assert candidate(arr = []) == []\n assert candidate(arr = [100, 100, 100]) == [1, 1, 1]\n assert candidate(arr = [1, 1, 2, 2, 3, 3]) == [1, 1, 2, 2, 3, 3]\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == [11, 10, 12, 9, 13, 8, 14, 7, 15, 6, 16, 5, 17, 4, 18, 3, 19, 2, 20, 1]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1000000000, 999999999, 1000000001, 999999998, 1000000002, 999999997, 1000000003, 999999996, 1000000004, 999999995]) == [6, 5, 7, 4, 8, 3, 9, 2, 10, 1]\n assert candidate(arr = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]\n assert candidate(arr = [100, 200, 100, 300, 200, 400, 300, 500]) == [1, 2, 1, 3, 2, 4, 3, 5]\n assert candidate(arr = [123456789, 987654321, 123456789, 987654321, 456789123]) == [1, 3, 1, 3, 2]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(arr = [50, 20, 30, 40, 10, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [5, 2, 3, 4, 1, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [10, 20, 20, 10, 30, 40, 50, 50, 40, 30]) == [1, 2, 2, 1, 3, 4, 5, 5, 4, 3]\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, -1, -10, -100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000]) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1, 2, 3, 4, 5]\n assert candidate(arr = [49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [1, 1, 1, 1, 1]\n assert candidate(arr = [1, 3, 2, 6, 5, 4, 7, 9, 8, 10, 11, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == [1, 3, 2, 6, 5, 4, 7, 9, 8, 10, 11, 13, 12, 15, 14, 17, 16, 19, 18, 20]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -1, -2, -3, -4, -5]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [1, 1, 1, 1, 1]\n assert candidate(arr = [-1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1000, 999, 1001, 998, 1002, 997, 1003, 996, 1004]) == [5, 4, 6, 3, 7, 2, 8, 1, 9]\n assert candidate(arr = [1, 3, 2, 1, 4, 2, 3, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == [1, 3, 2, 1, 4, 2, 3, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [100, 100, 100, 99, 99, 98, 98, 98, 97, 97, 97, 97]) == [4, 4, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1]\n assert candidate(arr = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1000000000, -1000000000, 1000000000, -1000000000, 0, 0, 500000000, -500000000]) == [5, 1, 5, 1, 3, 3, 4, 2]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1000000000, -1000000000, 500000000, -500000000, 250000000, -250000000, 125000000, -125000000, 62500000, -62500000]) == [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]\n assert candidate(arr = [5, 2, 9, 5, 9, 1, 5, 7, 8, 9, 1, 2, 3, 4, 6, 7, 8, 9]) == [5, 2, 9, 5, 9, 1, 5, 7, 8, 9, 1, 2, 3, 4, 6, 7, 8, 9]\n assert candidate(arr = [10, 20, 20, 10, 30, 40, 30, 20, 50, 60, 50, 40, 70, 80, 70, 60, 90, 100, 90, 80]) == [1, 2, 2, 1, 3, 4, 3, 2, 5, 6, 5, 4, 7, 8, 7, 6, 9, 10, 9, 8]\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(arr = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == [11, 10, 12, 9, 13, 8, 14, 7, 15, 6, 16, 5, 17, 4, 18, 3, 19, 2, 20, 1]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4]) == [5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4]\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [5, 3, 1, 4, 2, 1, 3, 5, 4]) == [5, 3, 1, 4, 2, 1, 3, 5, 4]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1]) == [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [50, 50, 40, 40, 30, 30, 20, 20, 10, 10, 5, 5, 1, 1, -1, -1, -5, -5, -10, -10]) == [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(arr = [987654321, 123456789, 987654321, 123456789, 987654321]) == [2, 1, 2, 1, 2]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(arr = [1000000, 999999, 1000001, 999998, 1000002, 999997, 1000003, 999996, 1000004, 999995]) == [6, 5, 7, 4, 8, 3, 9, 2, 10, 1]\n assert candidate(arr = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(arr = [-999999999, -888888888, -777777777, -666666666, -555555555, -444444444, -333333333, -222222222, -111111111, 0]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2, -3, -3, -4, -4]) == [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [-1000000000, -999999999, -999999998, -999999997, -999999996, -999999995, -999999994, -999999993, -999999992, -999999991]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [5, 3, 5, 2, 3, 3, 9, 0, 123, -1, -100]) == [6, 5, 6, 4, 5, 5, 7, 3, 8, 2, 1]\n assert candidate(arr = [5, 3, 1, 2, 4, 6, 7, 8, 9, 10]) == [5, 3, 1, 2, 4, 6, 7, 8, 9, 10]\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [5, 3, 5, 2, 4, 3, 5, 1]) == [5, 3, 5, 2, 4, 3, 5, 1]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n assert candidate(arr = [100, 50, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750]) == [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(arr = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]\n assert candidate(arr = [5, 3, 1, 2, 4, 3, 2, 1]) == [5, 3, 1, 2, 4, 3, 2, 1]\n assert candidate(arr = [5, 3, 1, 4, 2, 6, 8, 7, 10, 9]) == [5, 3, 1, 4, 2, 6, 8, 7, 10, 9]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [5, 3, 1, 2, 4, 1, 3, 5, 2, 4, 6, 7, 8, 6, 7, 8, 9, 10, 9, 10]) == [5, 3, 1, 2, 4, 1, 3, 5, 2, 4, 6, 7, 8, 6, 7, 8, 9, 10, 9, 10]\n assert candidate(arr = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [999999999, 1000000000, -1000000000, -999999999, 500000000, -500000000, 1, -1]) == [7, 8, 1, 2, 6, 3, 5, 4]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [-1, -2, -3, -1, -2, -3, -1, -2, -3]) == [3, 2, 1, 3, 2, 1, 3, 2, 1]\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(arr = [1000, 999, 1000, 998, 1000, 997, 1000, 996, 1000, 995, 1000, 994, 1000, 993, 1000]) == [8, 7, 8, 6, 8, 5, 8, 4, 8, 3, 8, 2, 8, 1, 8]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1000000, 999999, 1000001, 1000000, 999998]) == [3, 2, 4, 3, 1]\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().arrayRankTransform", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def arrayRankTransform(self, arr: list[int]) -> list[int]:", "container": "Solution", "callable": "arrayRankTransform", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1332, "task_id": "remove-palindromic-subsequences", "difficulty": "Easy", "problem_description": "You are given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s.\nReturn the minimum number of steps to make the given string empty.\nA string is a subsequence of a given string if it is generated by deleting some characters of a given string without changing its order. Note that a subsequence does not necessarily need to be contiguous.\nA string is called palindrome if is one that reads the same backward as well as forward.\n \nExample 1:\n\nInput: s = \"ababa\"\nOutput: 1\nExplanation: s is already a palindrome, so its entirety can be removed in a single step.\n\nExample 2:\n\nInput: s = \"abb\"\nOutput: 2\nExplanation: \"abb\" -> \"bb\" -> \"\". \nRemove palindromic subsequence \"a\" then \"bb\".\n\nExample 3:\n\nInput: s = \"baabb\"\nOutput: 2\nExplanation: \"baabb\" -> \"b\" -> \"\". \nRemove palindromic subsequence \"baab\" then \"b\".\n\n \nConstraints:\n\n1 <= s.length <= 1000\ns[i] is either 'a' or 'b'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"b\") == 1\n assert candidate(s = \"aabbab\") == 2\n assert candidate(s = \"baba\") == 2\n assert candidate(s = \"aababb\") == 2\n assert candidate(s = \"abbaab\") == 2\n assert candidate(s = \"ab\") == 2\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"ababa\") == 1\n assert candidate(s = \"bbaabaaa\") == 2\n assert candidate(s = \"aabbaa\") == 1\n assert candidate(s = \"\") == 1\n assert candidate(s = \"abb\") == 2\n assert candidate(s = \"baabb\") == 2\n assert candidate(s = \"aaaa\") == 1\n assert candidate(s = \"bbbb\") == 1\n assert candidate(s = \"abab\") == 2\n assert candidate(s = \"baaaabb\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbb\") == 2\n assert candidate(s = \"babbabbbaba\") == 2\n assert candidate(s = \"baabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\") == 2\n assert candidate(s = \"bababababababababa\") == 2\n assert candidate(s = \"bbaabbababb\") == 2\n assert candidate(s = \"baaabaaaaaabbaaab\") == 2\n assert candidate(s = \"aabbaabbaabb\") == 2\n assert candidate(s = \"baabbaab\") == 1\n assert candidate(s = \"baaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababb\") == 2\n assert candidate(s = \"abaababaababaababa\") == 2\n assert candidate(s = \"aaabbaabbaabbaabba\") == 2\n assert candidate(s = \"aabaaaab\") == 2\n assert candidate(s = \"bbaaabbaaabbaaabbaa\") == 2\n assert candidate(s = \"aabbabbaa\") == 1\n assert candidate(s = \"bababa\") == 2\n assert candidate(s = \"aaaaaaaabbaaaaaaa\") == 2\n assert candidate(s = \"aaabbbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbb\") == 2\n assert candidate(s = \"aabbbbbaaa\") == 2\n assert candidate(s = \"abbbabbbabbb\") == 2\n assert candidate(s = \"abbaababbababbab\") == 2\n assert candidate(s = \"aabbaabbabbaabbaabbabbaabbabbaabbaabbabbaabbabbaabbaabbabbaabbaabbabbaabbaabbabbaabbaabbabbaabbaabb\") == 2\n assert candidate(s = \"baabbaabbbaaba\") == 2\n assert candidate(s = \"bbbbbaaaaaaaaabbbb\") == 2\n assert candidate(s = \"abbaabbbaabbaabbba\") == 2\n assert candidate(s = \"aaabbbabaabbaa\") == 2\n assert candidate(s = \"aaabbbbaaaaabbbbaa\") == 2\n assert candidate(s = \"bbbbbaaaaa\") == 2\n assert candidate(s = \"aabbbaaabbbaa\") == 1\n assert candidate(s = \"bbbbbaaabbbbbaaabbbb\") == 2\n assert candidate(s = \"baababababababababab\") == 2\n assert candidate(s = \"bbbaabbaabbaabbaabbb\") == 1\n assert candidate(s = \"bbbbbbbbbba\") == 2\n assert candidate(s = \"bbaabbaabbaabbaab\") == 2\n assert candidate(s = \"abbbabbbabbbbaba\") == 2\n assert candidate(s = \"babbabbabbabbabbab\") == 1\n assert candidate(s = \"abaaabbaaabbbaaaab\") == 2\n assert candidate(s = \"aabbaabbaab\") == 2\n assert candidate(s = \"aabbaabbbaabbaabbba\") == 2\n assert candidate(s = \"bbaabbaab\") == 2\n assert candidate(s = \"bbaabbbaaabb\") == 2\n assert candidate(s = \"bbbbbbbbbbb\") == 1\n assert candidate(s = \"abbaaabaaa\") == 2\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 1\n assert candidate(s = \"ababbbababbbabaabb\") == 2\n assert candidate(s = \"abbaabbaabbaabba\") == 1\n assert candidate(s = \"aabbbbaaabaaaabbbb\") == 2\n assert candidate(s = \"abbbabbbabbbabbbabbb\") == 2\n assert candidate(s = \"babababababababab\") == 1\n assert candidate(s = \"abbaabbbaabbaabbaa\") == 2\n assert candidate(s = \"bbaabaaaabb\") == 2\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 1\n assert candidate(s = \"bababababa\") == 2\n assert candidate(s = \"aaabbbaaabbbbaaa\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbb\") == 2\n assert candidate(s = \"aabbaaabbbaaabbaaa\") == 2\n assert candidate(s = \"ababababababab\") == 2\n assert candidate(s = \"aaaaaa\") == 1\n assert candidate(s = \"abababababa\") == 1\n assert candidate(s = \"abababababababab\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbaaaaaaaaaaabbbbbbbbbbaaaaaaaaaaabbbbbbbbbbaaaaaaaaaaabbbbbbbbbbaaaaaaaaaa\") == 1\n assert candidate(s = \"baaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbbaaaaaaaaaa\") == 2\n assert candidate(s = \"abababababab\") == 2\n assert candidate(s = \"ababababababababab\") == 2\n assert candidate(s = \"aabaaabbaaaab\") == 2\n assert candidate(s = \"abababbabababababab\") == 2\n assert candidate(s = \"baaaabbbaabb\") == 2\n assert candidate(s = \"bbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaa\") == 2\n assert candidate(s = \"aaaaaaaaaaaaaaaaaa\") == 1\n assert candidate(s = \"bbbababaabbabababb\") == 2\n assert candidate(s = \"bbbbabbbbb\") == 2\n assert candidate(s = \"aaaaaaabbbbb\") == 2\n assert candidate(s = \"bbaabbbaa\") == 2\n assert candidate(s = \"baabbaaabbbaabbaab\") == 2\n assert candidate(s = \"abbbbbba\") == 1\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbb\") == 1\n assert candidate(s = \"babbbbabbbbabbbbab\") == 1\n assert candidate(s = \"abababababababababababababab\") == 2\n assert candidate(s = \"aabbbaaaabbbbaa\") == 2\n assert candidate(s = \"abaabaabaabaabaaba\") == 1\n assert candidate(s = \"aabbaabbbaaabbbaab\") == 2\n assert candidate(s = \"aabababababa\") == 2\n assert candidate(s = \"aaaabbbb\") == 2\n assert candidate(s = \"abbaabbbaabbaa\") == 2\n assert candidate(s = \"ababababababababababab\") == 2\n assert candidate(s = \"baabbaabbaabbaab\") == 1\n assert candidate(s = \"ababbababbab\") == 2\n assert candidate(s = \"abababababababababab\") == 2\n assert candidate(s = \"abaabaabaabaabaabaa\") == 2\n assert candidate(s = \"abababab\") == 2\n assert candidate(s = \"bbbbbaaabbbbabab\") == 2\n assert candidate(s = \"bababababababa\") == 2\n assert candidate(s = \"babababab\") == 1\n assert candidate(s = \"aabbabbbabaabbabbb\") == 2\n assert candidate(s = \"abababa\") == 1\n assert candidate(s = \"aabbbbbaa\") == 1\n assert candidate(s = \"bbbaaaabbbbbaaaabb\") == 2\n assert candidate(s = \"aabbaabbaabbaabbaabbaab\") == 2\n assert candidate(s = \"ababbbabaabab\") == 2\n assert candidate(s = \"aaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaa\") == 2\n assert candidate(s = \"babab\") == 1\n assert candidate(s = \"abababababababababababa\") == 1\n assert candidate(s = \"aabbaabbbaa\") == 2\n assert candidate(s = \"babababababababababa\") == 2\n assert candidate(s = \"abbabbabb\") == 2\n assert candidate(s = \"bbbbbaaaabaaaabbbb\") == 2\n assert candidate(s = \"bbbbbbbbbaaaaaaaaaa\") == 2\n assert candidate(s = \"ababababbababa\") == 2\n assert candidate(s = \"ababbbaba\") == 1\n assert candidate(s = \"abababaabbabababab\") == 2\n assert candidate(s = \"bbbbbbbbbbbbbbbbbb\") == 1\n assert candidate(s = \"aabbaabbaabbaabbaa\") == 1\n assert candidate(s = \"aaaaabbbbbaaaa\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbaaaaaaaaa\") == 2\n assert candidate(s = \"aabbaabbabbaaabb\") == 2\n assert candidate(s = \"bbaabbaabbaa\") == 2\n assert candidate(s = \"aabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabb\") == 2\n assert candidate(s = \"bababbbabababbbaba\") == 2\n assert candidate(s = \"baabbaabbaabba\") == 2\n assert candidate(s = \"ababab\") == 2\n assert candidate(s = \"aabbabba\") == 2\n assert candidate(s = \"ababbbbaababbbbaabab\") == 2\n assert candidate(s = \"bbaaabaaabaaaaabbb\") == 2\n assert candidate(s = \"bababababab\") == 1\n assert candidate(s = \"bababababababab\") == 1\n assert candidate(s = \"bbaaaabbbbaaa\") == 2\n assert candidate(s = \"bbbaabbbbabbbabbbba\") == 2\n assert candidate(s = \"abbaabbaabba\") == 1\n assert candidate(s = \"bbaabbaabbaabbaabbaabbaab\") == 2\n assert candidate(s = \"abaababa\") == 2\n assert candidate(s = \"ababbbababbbababbbab\") == 2\n assert candidate(s = \"ababbababbabab\") == 2\n assert candidate(s = \"baaaaab\") == 1\n assert candidate(s = \"aababbabaab\") == 2\n assert candidate(s = \"aabbaaabbaa\") == 1\n assert candidate(s = \"abababababababababa\") == 1\n assert candidate(s = \"aaaaaaaaabbbbbbbbb\") == 2\n assert candidate(s = \"bbbaaabbbbaaaabbba\") == 2\n assert candidate(s = \"bbaaaaabbbbba\") == 2\n assert candidate(s = \"abbbbaaaaabbba\") == 2\n assert candidate(s = \"abbaabba\") == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaa\") == 1\n assert candidate(s = \"aabbaaaabbbbaaabbbbaaaabbbaaabbbbaaaabbbaaabbbbaaaabbbaaabbbbaaaabbbaaabbbbaaaabbbaaabbbbaaaabbbbaaaabb\") == 2\n assert candidate(s = \"abbbbabbbbabbbbabbbb\") == 2\n assert candidate(s = \"ababababa\") == 1\n assert candidate(s = \"abababbabaabbababbab\") == 2\n assert candidate(s = \"babbbbbbbabbbbbbb\") == 2\n assert candidate(s = \"bbaaaaaabbbaaaaaab\") == 2\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababab\") == 2\n assert candidate(s = \"bbbbbaaaaabbbbbaaaaa\") == 2\n assert candidate(s = \"ababbababa\") == 2\n assert candidate(s = \"babababa\") == 2\n assert candidate(s = \"aababbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabb\") == 2\n assert candidate(s = \"baabbaabbaab\") == 1\n assert candidate(s = \"ababbbababbbabaab\") == 2\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\") == 2\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().removePalindromeSub", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def removePalindromeSub(self, s: str) -> int:", "container": "Solution", "callable": "removePalindromeSub", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1333, "task_id": "filter-restaurants-by-vegan-friendly-price-and-distance", "difficulty": "Medium", "problem_description": "Given the array restaurants where  restaurants[i] = [idi, ratingi, veganFriendlyi, pricei, distancei]. You have to filter the restaurants using three filters.\nThe veganFriendly filter will be either true (meaning you should only include restaurants with veganFriendlyi set to true) or false (meaning you can include any restaurant). In addition, you have the filters maxPrice and maxDistance which are the maximum value for price and distance of restaurants you should consider respectively.\nReturn the array of restaurant IDs after filtering, ordered by rating from highest to lowest. For restaurants with the same rating, order them by id from highest to lowest. For simplicity veganFriendlyi and veganFriendly take value 1 when it is true, and 0 when it is false.\n \nExample 1:\n\nInput: restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 1, maxPrice = 50, maxDistance = 10\nOutput: [3,1,5] \nExplanation: \nThe restaurants are:\nRestaurant 1 [id=1, rating=4, veganFriendly=1, price=40, distance=10]\nRestaurant 2 [id=2, rating=8, veganFriendly=0, price=50, distance=5]\nRestaurant 3 [id=3, rating=8, veganFriendly=1, price=30, distance=4]\nRestaurant 4 [id=4, rating=10, veganFriendly=0, price=10, distance=3]\nRestaurant 5 [id=5, rating=1, veganFriendly=1, price=15, distance=1] \nAfter filter restaurants with veganFriendly = 1, maxPrice = 50 and maxDistance = 10 we have restaurant 3, restaurant 1 and restaurant 5 (ordered by rating from highest to lowest). \n\nExample 2:\n\nInput: restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 0, maxPrice = 50, maxDistance = 10\nOutput: [4,3,2,1,5]\nExplanation: The restaurants are the same as in example 1, but in this case the filter veganFriendly = 0, therefore all restaurants are considered.\n\nExample 3:\n\nInput: restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 0, maxPrice = 30, maxDistance = 3\nOutput: [4,5]\n\n \nConstraints:\n\n1 <= restaurants.length <= 10^4\nrestaurants[i].length == 5\n1 <= idi, ratingi, pricei, distancei <= 10^5\n1 <= maxPrice, maxDistance <= 10^5\nveganFriendlyi and veganFriendly are 0 or 1.\nAll idi are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(restaurants = [[1, 4, 1, 40, 10], [2, 8, 0, 50, 5], [3, 8, 1, 30, 4], [4, 10, 0, 10, 3], [5, 1, 1, 15, 1]],veganFriendly = 0,maxPrice = 50,maxDistance = 10) == [4, 3, 2, 1, 5]\n assert candidate(restaurants = [[1, 4, 1, 40, 10], [2, 8, 0, 50, 5], [3, 8, 1, 30, 4], [4, 10, 0, 10, 3], [5, 1, 1, 15, 1]],veganFriendly = 0,maxPrice = 30,maxDistance = 3) == [4, 5]\n assert candidate(restaurants = [[1, 4, 1, 40, 10], [2, 8, 0, 50, 5], [3, 8, 1, 30, 4], [4, 10, 0, 10, 3], [5, 1, 1, 15, 1]],veganFriendly = 1,maxPrice = 50,maxDistance = 10) == [3, 1, 5]\n assert candidate(restaurants = [[100, 95, 1, 10, 1], [200, 94, 0, 20, 2], [300, 93, 1, 30, 3], [400, 92, 0, 40, 4], [500, 91, 1, 50, 5]],veganFriendly = 1,maxPrice = 50,maxDistance = 5) == [100, 300, 500]\n assert candidate(restaurants = [[101, 9, 1, 25, 7], [102, 7, 0, 35, 12], [103, 9, 1, 20, 5], [104, 5, 0, 20, 8], [105, 9, 1, 20, 5], [106, 8, 1, 30, 3], [107, 6, 0, 35, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 8) == [105, 103, 101, 106]\n assert candidate(restaurants = [[1001, 45, 1, 30, 12], [2002, 65, 0, 20, 6], [3003, 50, 1, 25, 7], [4004, 40, 0, 15, 4], [5005, 75, 1, 5, 2], [6006, 55, 0, 40, 22], [7007, 45, 1, 10, 16], [8008, 35, 0, 25, 12], [9009, 25, 1, 35, 22], [10010, 80, 1, 10, 6]],veganFriendly = 0,maxPrice = 45,maxDistance = 20) == [10010, 5005, 2002, 3003, 7007, 1001, 4004, 8008]\n assert candidate(restaurants = [[10001, 10, 1, 100, 100], [20002, 20, 0, 80, 90], [30003, 30, 1, 70, 80], [40004, 40, 0, 60, 70], [50005, 50, 1, 50, 60], [60006, 60, 0, 40, 50], [70007, 70, 1, 30, 40], [80008, 80, 0, 20, 30], [90009, 90, 1, 10, 20], [100010, 100, 1, 0, 10]],veganFriendly = 0,maxPrice = 100,maxDistance = 100) == [100010, 90009, 80008, 70007, 60006, 50005, 40004, 30003, 20002, 10001]\n assert candidate(restaurants = [[11, 3, 1, 20, 10], [12, 8, 1, 18, 8], [13, 5, 0, 15, 7], [14, 7, 0, 12, 6], [15, 9, 1, 9, 5]],veganFriendly = 1,maxPrice = 20,maxDistance = 10) == [15, 12, 11]\n assert candidate(restaurants = [[401, 5, 1, 10, 10], [402, 6, 1, 15, 9], [403, 7, 1, 20, 8], [404, 8, 1, 25, 7], [405, 9, 1, 30, 6], [406, 10, 1, 35, 5]],veganFriendly = 1,maxPrice = 20,maxDistance = 7) == []\n assert candidate(restaurants = [[101, 99, 1, 10, 5], [202, 98, 0, 20, 3], [303, 99, 1, 10, 2], [404, 98, 0, 25, 5], [505, 97, 1, 15, 4], [606, 98, 0, 10, 4]],veganFriendly = 1,maxPrice = 15,maxDistance = 5) == [303, 101, 505]\n assert candidate(restaurants = [[401, 10, 0, 10, 1], [402, 9, 1, 15, 2], [403, 8, 0, 20, 3], [404, 7, 1, 25, 4], [405, 6, 0, 30, 5], [406, 5, 1, 12, 6]],veganFriendly = 1,maxPrice = 25,maxDistance = 5) == [402, 404]\n assert candidate(restaurants = [[10, 9, 1, 15, 5], [11, 7, 0, 20, 6], [12, 9, 1, 18, 3], [13, 8, 0, 25, 4], [14, 7, 1, 10, 2], [15, 10, 0, 5, 1]],veganFriendly = 1,maxPrice = 20,maxDistance = 5) == [12, 10, 14]\n assert candidate(restaurants = [[30, 10, 1, 10, 1], [31, 9, 0, 15, 2], [32, 8, 1, 20, 3], [33, 7, 1, 25, 4], [34, 6, 0, 30, 5], [35, 5, 1, 35, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 5) == [30, 32, 33]\n assert candidate(restaurants = [[301, 9, 0, 15, 10], [302, 8, 1, 20, 8], [303, 7, 0, 25, 6], [304, 6, 1, 30, 4], [305, 5, 0, 35, 2], [306, 4, 1, 40, 0]],veganFriendly = 1,maxPrice = 20,maxDistance = 8) == [302]\n assert candidate(restaurants = [[26, 2, 1, 40, 10], [27, 8, 0, 35, 9], [28, 7, 1, 30, 8], [29, 9, 0, 25, 7], [30, 6, 1, 20, 6]],veganFriendly = 0,maxPrice = 35,maxDistance = 9) == [29, 27, 28, 30]\n assert candidate(restaurants = [[10001, 10, 1, 100, 100], [20002, 20, 0, 80, 90], [30003, 30, 1, 70, 80], [40004, 40, 0, 60, 70], [50005, 50, 1, 50, 60], [60006, 60, 0, 40, 50], [70007, 70, 1, 30, 40], [80008, 80, 0, 20, 30], [90009, 90, 1, 10, 20], [100010, 100, 1, 0, 10]],veganFriendly = 1,maxPrice = 60,maxDistance = 70) == [100010, 90009, 70007, 50005]\n assert candidate(restaurants = [[101, 80, 1, 10, 5], [202, 85, 0, 20, 3], [303, 80, 1, 10, 2], [404, 80, 0, 25, 5], [505, 85, 1, 15, 4], [606, 80, 0, 10, 4]],veganFriendly = 1,maxPrice = 20,maxDistance = 5) == [505, 303, 101]\n assert candidate(restaurants = [[101, 50, 1, 10, 5], [202, 70, 0, 20, 3], [303, 70, 1, 10, 2], [404, 80, 0, 25, 5], [505, 60, 1, 15, 4], [606, 60, 0, 10, 4]],veganFriendly = 1,maxPrice = 15,maxDistance = 4) == [303, 505]\n assert candidate(restaurants = [[24, 9, 1, 20, 5], [25, 10, 0, 25, 3], [26, 8, 1, 15, 2], [27, 7, 1, 10, 1], [28, 6, 0, 5, 1], [29, 5, 1, 30, 4]],veganFriendly = 1,maxPrice = 20,maxDistance = 3) == [26, 27]\n assert candidate(restaurants = [[1, 100, 1, 1, 1], [2, 100, 1, 2, 2], [3, 100, 1, 3, 3], [4, 100, 1, 4, 4], [5, 100, 1, 5, 5], [6, 100, 1, 6, 6], [7, 100, 1, 7, 7], [8, 100, 1, 8, 8], [9, 100, 1, 9, 9], [10, 100, 1, 10, 10]],veganFriendly = 1,maxPrice = 5,maxDistance = 5) == [5, 4, 3, 2, 1]\n assert candidate(restaurants = [[101, 10, 0, 100, 100], [102, 9, 1, 95, 95], [103, 8, 0, 90, 90], [104, 7, 1, 85, 85], [105, 6, 0, 80, 80]],veganFriendly = 0,maxPrice = 90,maxDistance = 90) == [103, 104, 105]\n assert candidate(restaurants = [[10001, 5, 0, 50, 50], [20002, 15, 1, 40, 40], [30003, 25, 0, 30, 30], [40004, 35, 1, 20, 20], [50005, 45, 0, 10, 10], [60006, 55, 1, 5, 5]],veganFriendly = 0,maxPrice = 40,maxDistance = 40) == [60006, 50005, 40004, 30003, 20002]\n assert candidate(restaurants = [[42, 10, 1, 10, 1], [43, 9, 0, 15, 2], [44, 8, 1, 20, 3], [45, 7, 1, 25, 4], [46, 6, 0, 30, 5], [47, 5, 1, 35, 6]],veganFriendly = 0,maxPrice = 5,maxDistance = 1) == []\n assert candidate(restaurants = [[21, 6, 0, 30, 9], [22, 7, 0, 25, 7], [23, 9, 1, 18, 5], [24, 8, 1, 22, 4], [25, 10, 0, 15, 3]],veganFriendly = 1,maxPrice = 25,maxDistance = 6) == [23, 24]\n assert candidate(restaurants = [[54, 10, 1, 10, 1], [55, 9, 0, 15, 2], [56, 8, 1, 20, 3], [57, 7, 1, 25, 4], [58, 6, 0, 30, 5], [59, 5, 1, 35, 6]],veganFriendly = 1,maxPrice = 35,maxDistance = 6) == [54, 56, 57, 59]\n assert candidate(restaurants = [[901, 9, 0, 10, 1], [902, 8, 1, 15, 2], [903, 7, 0, 20, 3], [904, 6, 1, 25, 4], [905, 5, 0, 12, 5]],veganFriendly = 0,maxPrice = 25,maxDistance = 5) == [901, 902, 903, 904, 905]\n assert candidate(restaurants = [[41, 2, 0, 45, 10], [42, 8, 1, 35, 9], [43, 7, 1, 30, 8], [44, 9, 0, 25, 7], [45, 6, 1, 20, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 7) == [45]\n assert candidate(restaurants = [[101, 80, 1, 10, 5], [202, 85, 0, 20, 3], [303, 80, 1, 10, 2], [404, 80, 0, 25, 5], [505, 85, 1, 15, 4], [606, 80, 0, 10, 4]],veganFriendly = 0,maxPrice = 10,maxDistance = 5) == [606, 303, 101]\n assert candidate(restaurants = [[101, 50, 1, 30, 10], [202, 20, 0, 20, 5], [303, 40, 1, 25, 8], [404, 30, 0, 15, 3], [505, 60, 1, 5, 1], [606, 55, 0, 40, 20], [707, 45, 1, 10, 15], [808, 35, 0, 25, 10], [909, 25, 1, 35, 20], [1010, 70, 1, 10, 5]],veganFriendly = 1,maxPrice = 35,maxDistance = 15) == [1010, 505, 101, 707, 303]\n assert candidate(restaurants = [[601, 7, 1, 25, 10], [602, 8, 0, 30, 15], [603, 9, 1, 45, 8], [604, 6, 0, 35, 15], [605, 8, 1, 50, 6], [606, 9, 1, 35, 10], [607, 7, 0, 40, 8]],veganFriendly = 0,maxPrice = 50,maxDistance = 20) == [606, 603, 605, 602, 607, 601, 604]\n assert candidate(restaurants = [[701, 10, 0, 20, 20], [702, 9, 0, 25, 25], [703, 8, 0, 30, 30], [704, 7, 0, 35, 35], [705, 6, 0, 40, 40], [706, 5, 0, 45, 45], [707, 4, 0, 50, 50], [708, 3, 0, 55, 55], [709, 2, 0, 60, 60], [710, 1, 0, 65, 65]],veganFriendly = 0,maxPrice = 40,maxDistance = 40) == [701, 702, 703, 704, 705]\n assert candidate(restaurants = [[36, 5, 1, 15, 2], [37, 4, 0, 10, 3], [38, 3, 1, 5, 4], [39, 2, 1, 20, 5], [40, 1, 0, 25, 6], [41, 8, 1, 10, 1]],veganFriendly = 1,maxPrice = 20,maxDistance = 5) == [41, 36, 38, 39]\n assert candidate(restaurants = [[101, 95, 1, 20, 15], [202, 85, 0, 55, 18], [303, 95, 1, 25, 12], [404, 75, 0, 22, 14], [505, 88, 1, 18, 16], [606, 80, 0, 30, 10]],veganFriendly = 1,maxPrice = 30,maxDistance = 20) == [303, 101, 505]\n assert candidate(restaurants = [[1, 5, 1, 10, 1], [2, 5, 1, 10, 1], [3, 5, 1, 10, 1], [4, 5, 1, 10, 1], [5, 5, 1, 10, 1]],veganFriendly = 1,maxPrice = 10,maxDistance = 1) == [5, 4, 3, 2, 1]\n assert candidate(restaurants = [[101, 80, 1, 10, 5], [202, 85, 0, 20, 3], [303, 80, 1, 10, 2], [404, 80, 0, 25, 5], [505, 85, 1, 15, 4], [606, 80, 0, 10, 4]],veganFriendly = 0,maxPrice = 25,maxDistance = 5) == [505, 202, 606, 404, 303, 101]\n assert candidate(restaurants = [[101, 5, 1, 100, 5], [102, 9, 0, 50, 4], [103, 6, 1, 40, 3], [104, 7, 0, 30, 2], [105, 8, 1, 20, 1], [106, 4, 0, 10, 6], [107, 9, 1, 15, 2]],veganFriendly = 0,maxPrice = 50,maxDistance = 4) == [107, 102, 105, 104, 103]\n assert candidate(restaurants = [[35, 6, 0, 20, 17], [36, 7, 1, 45, 21], [37, 6, 0, 35, 15], [38, 9, 1, 25, 10], [39, 8, 0, 45, 25], [40, 11, 1, 10, 4], [41, 13, 0, 22, 18]],veganFriendly = 1,maxPrice = 45,maxDistance = 25) == [40, 38, 36]\n assert candidate(restaurants = [[201, 10, 0, 1000, 50], [202, 9, 1, 900, 45], [203, 8, 0, 800, 40], [204, 7, 1, 700, 35], [205, 6, 0, 600, 30], [206, 5, 1, 500, 25], [207, 4, 0, 400, 20], [208, 3, 1, 300, 15], [209, 2, 0, 200, 10], [210, 1, 1, 100, 5]],veganFriendly = 1,maxPrice = 500,maxDistance = 30) == [206, 208, 210]\n assert candidate(restaurants = [[301, 7, 0, 20, 4], [302, 9, 1, 10, 2], [303, 6, 0, 25, 5], [304, 8, 1, 15, 3], [305, 9, 0, 30, 1], [306, 7, 1, 12, 6]],veganFriendly = 0,maxPrice = 15,maxDistance = 4) == [302, 304]\n assert candidate(restaurants = [[401, 8, 1, 25, 10], [402, 7, 0, 30, 15], [403, 9, 1, 20, 5], [404, 8, 0, 20, 8], [405, 6, 1, 20, 5], [406, 9, 1, 30, 3], [407, 5, 0, 35, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 15) == [406, 403, 401, 405]\n assert candidate(restaurants = [[101, 90, 1, 30, 5], [202, 85, 0, 40, 10], [303, 90, 1, 30, 4], [404, 85, 0, 45, 8], [505, 85, 1, 25, 6], [606, 80, 0, 35, 7]],veganFriendly = 1,maxPrice = 35,maxDistance = 10) == [303, 101, 505]\n assert candidate(restaurants = [[101, 50, 1, 30, 10], [202, 20, 0, 20, 5], [303, 40, 1, 25, 8], [404, 30, 0, 15, 3], [505, 60, 1, 5, 1], [606, 55, 0, 40, 20], [707, 45, 1, 10, 15], [808, 35, 0, 25, 10], [909, 25, 1, 35, 20], [1010, 70, 1, 10, 5]],veganFriendly = 0,maxPrice = 20,maxDistance = 5) == [1010, 505, 404, 202]\n assert candidate(restaurants = [[701, 6, 1, 25, 10], [702, 8, 0, 30, 15], [703, 7, 1, 45, 8], [704, 9, 0, 35, 15], [705, 5, 1, 50, 6], [706, 8, 1, 35, 10], [707, 6, 0, 40, 8]],veganFriendly = 1,maxPrice = 40,maxDistance = 15) == [706, 701]\n assert candidate(restaurants = [[22, 6, 0, 20, 17], [23, 7, 1, 45, 21], [24, 6, 0, 35, 15], [25, 9, 1, 25, 10], [26, 8, 0, 45, 25], [27, 11, 1, 10, 4]],veganFriendly = 1,maxPrice = 40,maxDistance = 20) == [27, 25]\n assert candidate(restaurants = [[301, 6, 1, 30, 10], [302, 8, 0, 40, 12], [303, 7, 1, 45, 8], [304, 9, 1, 50, 6], [305, 5, 0, 35, 15], [306, 8, 1, 45, 10], [307, 7, 0, 40, 8]],veganFriendly = 0,maxPrice = 50,maxDistance = 15) == [304, 306, 302, 307, 303, 301, 305]\n assert candidate(restaurants = [[101, 100, 1, 5, 5], [102, 100, 1, 5, 6], [103, 100, 1, 5, 7], [104, 100, 1, 5, 8], [105, 100, 1, 5, 9]],veganFriendly = 1,maxPrice = 5,maxDistance = 9) == [105, 104, 103, 102, 101]\n assert candidate(restaurants = [[501, 10, 0, 50, 100], [502, 10, 0, 55, 95], [503, 10, 0, 60, 90], [504, 10, 0, 65, 85], [505, 10, 0, 70, 80], [506, 10, 0, 75, 75], [507, 10, 0, 80, 70], [508, 10, 0, 85, 65], [509, 10, 0, 90, 60]],veganFriendly = 0,maxPrice = 80,maxDistance = 70) == [507]\n assert candidate(restaurants = [[36, 6, 1, 40, 9], [37, 8, 0, 35, 8], [38, 7, 1, 30, 7], [39, 9, 0, 25, 6], [40, 10, 1, 20, 5]],veganFriendly = 1,maxPrice = 30,maxDistance = 8) == [40, 38]\n assert candidate(restaurants = [[101, 1, 1, 5, 5], [102, 1, 1, 6, 6], [103, 1, 1, 7, 7], [104, 1, 1, 8, 8], [105, 1, 1, 9, 9]],veganFriendly = 1,maxPrice = 10,maxDistance = 10) == [105, 104, 103, 102, 101]\n assert candidate(restaurants = [[101, 50, 1, 30, 10], [202, 20, 0, 20, 5], [303, 40, 1, 25, 8], [404, 30, 0, 15, 3], [505, 60, 1, 5, 1], [606, 55, 0, 40, 20], [707, 45, 1, 10, 15], [808, 35, 0, 25, 10], [909, 25, 1, 35, 20], [1010, 70, 1, 10, 5]],veganFriendly = 1,maxPrice = 50,maxDistance = 20) == [1010, 505, 101, 707, 303, 909]\n assert candidate(restaurants = [[2001, 100, 0, 50, 50], [2002, 99, 1, 49, 49], [2003, 98, 0, 48, 48], [2004, 97, 1, 47, 47], [2005, 96, 0, 46, 46]],veganFriendly = 0,maxPrice = 50,maxDistance = 50) == [2001, 2002, 2003, 2004, 2005]\n assert candidate(restaurants = [[10, 10, 0, 100, 100], [20, 9, 1, 90, 90], [30, 8, 0, 80, 80], [40, 7, 1, 70, 70], [50, 6, 0, 60, 60]],veganFriendly = 0,maxPrice = 100,maxDistance = 100) == [10, 20, 30, 40, 50]\n assert candidate(restaurants = [[31, 1, 0, 45, 10], [32, 3, 0, 30, 8], [33, 2, 1, 25, 6], [34, 4, 1, 20, 5], [35, 5, 0, 15, 4]],veganFriendly = 1,maxPrice = 25,maxDistance = 7) == [34, 33]\n assert candidate(restaurants = [[101, 6, 0, 20, 5], [102, 9, 1, 18, 2], [103, 5, 0, 10, 3], [104, 8, 1, 12, 4], [105, 7, 1, 15, 6], [106, 9, 0, 22, 3]],veganFriendly = 0,maxPrice = 25,maxDistance = 6) == [106, 102, 104, 105, 101, 103]\n assert candidate(restaurants = [[101, 95, 1, 20, 15], [202, 85, 0, 55, 18], [303, 95, 1, 25, 12], [404, 75, 0, 22, 14], [505, 88, 1, 18, 16], [606, 80, 0, 30, 10]],veganFriendly = 0,maxPrice = 55,maxDistance = 20) == [303, 101, 505, 202, 606, 404]\n assert candidate(restaurants = [[601, 9, 1, 10, 1], [602, 8, 0, 15, 2], [603, 7, 1, 20, 3], [604, 6, 0, 25, 4], [605, 5, 1, 12, 5]],veganFriendly = 1,maxPrice = 15,maxDistance = 4) == [601]\n assert candidate(restaurants = [[10001, 5, 0, 50, 50], [20002, 15, 1, 40, 40], [30003, 25, 0, 30, 30], [40004, 35, 1, 20, 20], [50005, 45, 0, 10, 10], [60006, 55, 1, 5, 5]],veganFriendly = 1,maxPrice = 50,maxDistance = 50) == [60006, 40004, 20002]\n assert candidate(restaurants = [[801, 8, 1, 15, 3], [802, 9, 0, 10, 2], [803, 7, 1, 25, 4], [804, 6, 0, 20, 5], [805, 5, 1, 12, 1]],veganFriendly = 1,maxPrice = 20,maxDistance = 4) == [801, 805]\n assert candidate(restaurants = [[48, 1, 1, 5, 1], [49, 2, 0, 10, 2], [50, 3, 1, 15, 3], [51, 4, 1, 20, 4], [52, 5, 0, 25, 5], [53, 6, 1, 30, 6]],veganFriendly = 1,maxPrice = 25,maxDistance = 5) == [51, 50, 48]\n assert candidate(restaurants = [[10, 9, 1, 25, 7], [20, 8, 0, 35, 9], [30, 10, 1, 20, 5], [40, 7, 0, 45, 3], [50, 6, 1, 15, 2]],veganFriendly = 1,maxPrice = 30,maxDistance = 8) == [30, 10, 50]\n assert candidate(restaurants = [[1, 99, 0, 1, 1], [2, 98, 0, 2, 2], [3, 97, 0, 3, 3], [4, 96, 0, 4, 4], [5, 95, 0, 5, 5], [6, 94, 0, 6, 6], [7, 93, 0, 7, 7], [8, 92, 0, 8, 8], [9, 91, 0, 9, 9]],veganFriendly = 0,maxPrice = 9,maxDistance = 9) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(restaurants = [[3001, 9, 1, 9, 9], [3002, 8, 0, 8, 8], [3003, 7, 1, 7, 7], [3004, 6, 0, 6, 6], [3005, 5, 1, 5, 5], [3006, 4, 0, 4, 4], [3007, 3, 1, 3, 3], [3008, 2, 0, 2, 2], [3009, 1, 1, 1, 1]],veganFriendly = 1,maxPrice = 10,maxDistance = 10) == [3001, 3003, 3005, 3007, 3009]\n assert candidate(restaurants = [[51, 6, 1, 40, 10], [52, 8, 1, 35, 9], [53, 7, 1, 30, 8], [54, 9, 1, 25, 7], [55, 10, 1, 20, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 8) == [55, 54, 53]\n assert candidate(restaurants = [[501, 6, 1, 10, 5], [502, 7, 0, 15, 4], [503, 8, 1, 20, 3], [504, 9, 0, 25, 2], [505, 10, 1, 12, 1]],veganFriendly = 0,maxPrice = 25,maxDistance = 5) == [505, 504, 503, 502, 501]\n assert candidate(restaurants = [[101, 80, 1, 10, 5], [202, 85, 0, 20, 3], [303, 80, 1, 10, 2], [404, 80, 0, 25, 5], [505, 85, 1, 15, 4], [606, 80, 0, 10, 4]],veganFriendly = 1,maxPrice = 100,maxDistance = 100) == [505, 303, 101]\n assert candidate(restaurants = [[201, 3, 0, 40, 15], [202, 5, 1, 45, 20], [203, 8, 1, 50, 10], [204, 4, 0, 50, 25], [205, 6, 0, 40, 15], [206, 7, 1, 45, 15], [207, 9, 1, 35, 10]],veganFriendly = 1,maxPrice = 50,maxDistance = 20) == [207, 203, 206, 202]\n assert candidate(restaurants = [[100, 90, 1, 10, 20], [200, 85, 0, 15, 25], [300, 80, 1, 5, 15], [400, 75, 0, 25, 10], [500, 70, 1, 20, 5]],veganFriendly = 0,maxPrice = 25,maxDistance = 20) == [100, 300, 400, 500]\n assert candidate(restaurants = [[201, 8, 1, 10, 4], [202, 6, 0, 15, 3], [203, 9, 1, 20, 2], [204, 7, 0, 25, 5], [205, 8, 1, 12, 3], [206, 9, 0, 30, 4]],veganFriendly = 1,maxPrice = 30,maxDistance = 5) == [203, 205, 201]\n assert candidate(restaurants = [[17, 2, 0, 30, 13], [18, 5, 1, 40, 18], [19, 7, 1, 50, 22], [20, 1, 0, 60, 30], [21, 4, 0, 10, 2]],veganFriendly = 1,maxPrice = 55,maxDistance = 28) == [19, 18]\n assert candidate(restaurants = [[11, 3, 1, 60, 20], [12, 8, 0, 70, 22], [13, 9, 1, 20, 10], [14, 10, 0, 5, 5], [15, 8, 1, 35, 12], [16, 12, 0, 15, 9]],veganFriendly = 0,maxPrice = 75,maxDistance = 25) == [16, 14, 13, 15, 12, 11]\n assert candidate(restaurants = [[66, 1, 1, 1, 1], [77, 1, 0, 2, 2], [88, 2, 1, 3, 3], [99, 2, 0, 4, 4], [100, 3, 1, 5, 5]],veganFriendly = 0,maxPrice = 5,maxDistance = 5) == [100, 99, 88, 77, 66]\n assert candidate(restaurants = [[12, 3, 0, 60, 7], [13, 2, 1, 45, 6], [14, 5, 1, 55, 8], [15, 4, 0, 35, 5], [16, 6, 1, 40, 9], [17, 7, 1, 30, 3]],veganFriendly = 1,maxPrice = 50,maxDistance = 10) == [17, 16, 13]\n assert candidate(restaurants = [[18, 9, 1, 20, 5], [19, 10, 0, 25, 3], [20, 8, 1, 15, 2], [21, 7, 1, 10, 1], [22, 6, 0, 5, 1], [23, 5, 1, 30, 4]],veganFriendly = 0,maxPrice = 100,maxDistance = 10) == [19, 18, 20, 21, 22, 23]\n assert candidate(restaurants = [[60, 10, 1, 10, 1], [61, 9, 0, 15, 2], [62, 8, 1, 20, 3], [63, 7, 1, 25, 4], [64, 6, 0, 30, 5], [65, 5, 1, 35, 6]],veganFriendly = 1,maxPrice = 10,maxDistance = 1) == [60]\n assert candidate(restaurants = [[1001, 1, 1, 1, 1], [1002, 2, 0, 2, 2], [1003, 3, 1, 3, 3], [1004, 4, 0, 4, 4], [1005, 5, 1, 5, 5], [1006, 6, 0, 6, 6], [1007, 7, 1, 7, 7]],veganFriendly = 1,maxPrice = 7,maxDistance = 7) == [1007, 1005, 1003, 1001]\n assert candidate(restaurants = [[28, 5, 0, 30, 15], [29, 8, 1, 40, 20], [30, 6, 0, 25, 10], [31, 7, 1, 5, 5], [32, 9, 0, 10, 4], [33, 12, 1, 35, 12], [34, 10, 0, 15, 9]],veganFriendly = 0,maxPrice = 55,maxDistance = 28) == [33, 34, 32, 29, 31, 30, 28]\n assert candidate(restaurants = [[10, 9, 1, 20, 1], [20, 8, 0, 10, 2], [30, 7, 1, 5, 3], [40, 10, 1, 15, 2], [50, 6, 0, 25, 4], [60, 8, 1, 30, 1]],veganFriendly = 1,maxPrice = 30,maxDistance = 3) == [40, 10, 60, 30]\n assert candidate(restaurants = [[6, 5, 1, 20, 5], [7, 7, 0, 25, 3], [8, 6, 1, 15, 2], [9, 9, 1, 10, 1], [10, 10, 0, 5, 1], [11, 8, 1, 30, 4]],veganFriendly = 1,maxPrice = 25,maxDistance = 4) == [9, 8]\n assert candidate(restaurants = [[1, 100, 1, 1, 1], [2, 99, 0, 2, 2], [3, 98, 1, 3, 3], [4, 97, 0, 4, 4], [5, 96, 1, 5, 5], [6, 95, 0, 6, 6], [7, 94, 1, 7, 7], [8, 93, 0, 8, 8], [9, 92, 1, 9, 9], [10, 91, 0, 10, 10]],veganFriendly = 1,maxPrice = 10,maxDistance = 10) == [1, 3, 5, 7, 9]\n assert candidate(restaurants = [[6, 9, 0, 20, 6], [7, 7, 1, 15, 3], [8, 6, 1, 25, 2], [9, 10, 0, 5, 1], [10, 4, 1, 35, 8]],veganFriendly = 1,maxPrice = 30,maxDistance = 5) == [7, 8]\n assert candidate(restaurants = [[1000, 95, 1, 40, 50], [2000, 90, 0, 50, 60], [3000, 85, 1, 30, 40], [4000, 80, 0, 40, 30], [5000, 75, 1, 20, 20], [6000, 70, 0, 30, 10]],veganFriendly = 1,maxPrice = 30,maxDistance = 30) == [5000]\n assert candidate(restaurants = [[501, 9, 1, 25, 7], [502, 6, 0, 40, 12], [503, 8, 1, 45, 8], [504, 7, 0, 35, 15], [505, 9, 1, 50, 6], [506, 6, 1, 35, 10], [507, 8, 0, 40, 8]],veganFriendly = 1,maxPrice = 50,maxDistance = 20) == [505, 501, 503, 506]\n assert candidate(restaurants = [[11, 3, 1, 10, 10], [22, 2, 0, 9, 9], [33, 3, 1, 8, 8], [44, 2, 0, 7, 7], [55, 3, 1, 6, 6]],veganFriendly = 1,maxPrice = 10,maxDistance = 10) == [55, 33, 11]\n assert candidate(restaurants = [[601, 5, 1, 5, 5], [602, 6, 1, 10, 10], [603, 7, 1, 15, 15], [604, 8, 1, 20, 20], [605, 9, 1, 25, 25], [606, 10, 1, 30, 30]],veganFriendly = 1,maxPrice = 25,maxDistance = 25) == [605, 604, 603, 602, 601]\n assert candidate(restaurants = [[11, 50, 1, 20, 10], [12, 50, 1, 20, 9], [13, 50, 1, 20, 8], [14, 50, 1, 20, 7], [15, 50, 1, 20, 6], [16, 50, 1, 20, 5], [17, 50, 1, 20, 4], [18, 50, 1, 20, 3], [19, 50, 1, 20, 2], [20, 50, 1, 20, 1]],veganFriendly = 1,maxPrice = 20,maxDistance = 10) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]\n assert candidate(restaurants = [[6, 6, 0, 55, 15], [7, 7, 1, 35, 7], [8, 9, 0, 25, 8], [9, 7, 1, 5, 1], [10, 5, 0, 10, 4]],veganFriendly = 1,maxPrice = 40,maxDistance = 10) == [9, 7]\n assert candidate(restaurants = [[16, 1, 0, 40, 7], [17, 3, 1, 20, 5], [18, 2, 1, 30, 4], [19, 4, 0, 50, 3], [20, 5, 1, 45, 2]],veganFriendly = 0,maxPrice = 45,maxDistance = 7) == [20, 17, 18, 16]\n assert candidate(restaurants = [[101, 95, 1, 20, 15], [202, 85, 0, 55, 18], [303, 95, 1, 25, 12], [404, 75, 0, 22, 14], [505, 88, 1, 18, 16], [606, 80, 0, 30, 10]],veganFriendly = 1,maxPrice = 55,maxDistance = 20) == [303, 101, 505]\n assert candidate(restaurants = [[701, 10, 0, 20, 1], [702, 9, 1, 25, 2], [703, 8, 0, 30, 3], [704, 7, 1, 15, 4], [705, 6, 0, 10, 5]],veganFriendly = 0,maxPrice = 30,maxDistance = 5) == [701, 702, 703, 704, 705]\n assert candidate(restaurants = [[46, 1, 0, 50, 10], [47, 3, 1, 45, 9], [48, 2, 1, 40, 8], [49, 4, 0, 35, 7], [50, 5, 1, 30, 6]],veganFriendly = 0,maxPrice = 45,maxDistance = 9) == [50, 49, 47, 48]\n"}, "metadata": {"canonical_parameter_names": ["restaurants", "veganFriendly", "maxPrice", "maxDistance"], "leetcode_dataset_entry_point": "Solution().filterRestaurants", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def filterRestaurants(self, restaurants: list[list[int]], veganFriendly: int, maxPrice: int, maxDistance: int) -> list[int]:", "container": "Solution", "callable": "filterRestaurants", "parameters": [{"name": "restaurants", "type": "list[list[int]]"}, {"name": "veganFriendly", "type": "int"}, {"name": "maxPrice", "type": "int"}, {"name": "maxDistance", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1334, "task_id": "find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance", "difficulty": "Medium", "problem_description": "There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional and weighted edge between cities fromi and toi, and given the integer distanceThreshold.\nReturn the city with the smallest number of cities that are reachable through some path and whose distance is at most distanceThreshold, If there are multiple such cities, return the city with the greatest number.\nNotice that the distance of a path connecting cities i and j is equal to the sum of the edges' weights along that path.\n \nExample 1:\n\n\nInput: n = 4, edges = [[0,1,3],[1,2,1],[1,3,4],[2,3,1]], distanceThreshold = 4\nOutput: 3\nExplanation: The figure above describes the graph. \nThe neighboring cities at a distanceThreshold = 4 for each city are:\nCity 0 -> [City 1, City 2] \nCity 1 -> [City 0, City 2, City 3] \nCity 2 -> [City 0, City 1, City 3] \nCity 3 -> [City 1, City 2] \nCities 0 and 3 have 2 neighboring cities at a distanceThreshold = 4, but we have to return city 3 since it has the greatest number.\n\nExample 2:\n\n\nInput: n = 5, edges = [[0,1,2],[0,4,8],[1,2,3],[1,4,2],[2,3,1],[3,4,1]], distanceThreshold = 2\nOutput: 0\nExplanation: The figure above describes the graph. \nThe neighboring cities at a distanceThreshold = 2 for each city are:\nCity 0 -> [City 1] \nCity 1 -> [City 0, City 4] \nCity 2 -> [City 3, City 4] \nCity 3 -> [City 2, City 4]\nCity 4 -> [City 1, City 2, City 3] \nThe city 0 has 1 neighboring city at a distanceThreshold = 2.\n\n \nConstraints:\n\n2 <= n <= 100\n1 <= edges.length <= n * (n - 1) / 2\nedges[i].length == 3\n0 <= fromi < toi < n\n1 <= weighti, distanceThreshold <= 10^4\nAll pairs (fromi, toi) are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,edges = [[0, 1, 2], [0, 4, 8], [1, 2, 3], [1, 4, 2], [2, 3, 1], [3, 4, 1]],distanceThreshold = 2) == 0\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 1], [1, 3, 4], [2, 3, 1]],distanceThreshold = 4) == 3\n assert candidate(n = 6,edges = [[0, 1, 10], [0, 2, 3], [1, 2, 1], [1, 3, 7], [2, 4, 2], [3, 4, 8], [4, 5, 6]],distanceThreshold = 20) == 5\n assert candidate(n = 3,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 5]],distanceThreshold = 10) == 2\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1], [2, 4, 1], [3, 4, 1], [3, 5, 1], [4, 5, 1], [4, 6, 1], [5, 6, 1]],distanceThreshold = 1) == 6\n assert candidate(n = 10,edges = [[0, 1, 2], [0, 5, 3], [1, 2, 1], [1, 3, 4], [2, 4, 3], [2, 5, 2], [3, 4, 1], [3, 6, 5], [4, 7, 2], [5, 6, 1], [6, 7, 3], [7, 8, 1], [8, 9, 4]],distanceThreshold = 5) == 9\n assert candidate(n = 6,edges = [[0, 1, 1], [0, 2, 5], [1, 2, 1], [1, 3, 3], [1, 4, 7], [2, 3, 1], [2, 4, 2], [3, 4, 1], [3, 5, 2], [4, 5, 2]],distanceThreshold = 4) == 5\n assert candidate(n = 10,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 7, 2], [7, 8, 2], [8, 9, 2], [9, 0, 2]],distanceThreshold = 5) == 9\n assert candidate(n = 10,edges = [[0, 1, 3], [0, 2, 5], [0, 3, 7], [0, 4, 9], [1, 2, 4], [1, 3, 6], [1, 4, 8], [1, 5, 2], [2, 3, 3], [2, 4, 5], [2, 5, 7], [2, 6, 1], [3, 4, 4], [3, 5, 6], [3, 6, 8], [3, 7, 2], [4, 5, 3], [4, 6, 5], [4, 7, 7], [4, 8, 1], [5, 6, 4], [5, 7, 6], [5, 8, 8], [5, 9, 2], [6, 7, 3], [6, 8, 5], [6, 9, 7], [7, 8, 4], [7, 9, 6], [8, 9, 5]],distanceThreshold = 20) == 9\n assert candidate(n = 9,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 0, 1], [0, 2, 1], [1, 3, 1], [2, 4, 1], [3, 5, 1], [4, 6, 1], [5, 7, 1], [6, 8, 1], [7, 0, 1], [8, 1, 1]],distanceThreshold = 2) == 8\n assert candidate(n = 10,edges = [[0, 1, 100], [0, 5, 100], [0, 4, 100], [1, 2, 100], [1, 5, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [5, 6, 100], [6, 7, 100], [7, 8, 100], [8, 9, 100], [9, 0, 100]],distanceThreshold = 50) == 9\n assert candidate(n = 6,edges = [[0, 1, 2], [1, 2, 4], [2, 3, 6], [3, 4, 8], [4, 5, 10], [0, 5, 12], [1, 4, 14], [2, 5, 16]],distanceThreshold = 10) == 5\n assert candidate(n = 6,edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [0, 3, 25], [0, 2, 30], [1, 3, 35]],distanceThreshold = 50) == 5\n assert candidate(n = 8,edges = [[0, 1, 4], [0, 2, 1], [1, 2, 2], [1, 3, 5], [2, 3, 1], [3, 4, 3], [4, 5, 2], [4, 6, 6], [5, 6, 1], [6, 7, 3]],distanceThreshold = 6) == 7\n assert candidate(n = 6,edges = [[0, 1, 3], [0, 2, 4], [0, 4, 5], [1, 2, 1], [1, 3, 2], [1, 5, 6], [2, 3, 3], [2, 5, 1], [3, 5, 2], [4, 5, 4]],distanceThreshold = 7) == 5\n assert candidate(n = 12,edges = [[0, 1, 2], [0, 4, 4], [0, 11, 6], [1, 2, 1], [1, 3, 3], [1, 4, 2], [2, 3, 1], [2, 4, 3], [2, 5, 2], [3, 4, 1], [3, 6, 4], [3, 7, 5], [4, 5, 1], [4, 6, 2], [4, 7, 3], [5, 6, 1], [5, 7, 2], [5, 8, 4], [5, 9, 5], [6, 8, 1], [6, 9, 3], [6, 10, 4], [7, 8, 2], [7, 9, 1], [7, 10, 3], [8, 9, 1], [8, 10, 2], [8, 11, 6], [9, 10, 1], [9, 11, 3], [10, 11, 2]],distanceThreshold = 5) == 11\n assert candidate(n = 7,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [0, 6, 10], [0, 3, 1], [1, 4, 1], [2, 5, 1]],distanceThreshold = 15) == 6\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [0, 5, 5], [0, 6, 6], [0, 7, 7], [0, 8, 8], [1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [2, 3, 1], [2, 4, 2], [2, 5, 3], [2, 6, 4], [2, 7, 5], [2, 8, 6], [3, 4, 1], [3, 5, 2], [3, 6, 3], [3, 7, 4], [3, 8, 5], [4, 5, 1], [4, 6, 2], [4, 7, 3], [4, 8, 4], [5, 6, 1], [5, 7, 2], [5, 8, 3], [6, 7, 1], [6, 8, 2], [7, 8, 1]],distanceThreshold = 5) == 8\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 6, 5], [1, 2, 3], [1, 3, 1], [1, 6, 4], [2, 3, 1], [2, 4, 3], [3, 4, 1], [3, 5, 2], [4, 5, 2], [5, 6, 3]],distanceThreshold = 5) == 6\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 6], [0, 6, 7], [1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [2, 3, 1], [2, 4, 2], [2, 5, 3], [2, 6, 4], [3, 4, 1], [3, 5, 2], [3, 6, 3], [4, 5, 1], [4, 6, 2], [5, 6, 1]],distanceThreshold = 10) == 6\n assert candidate(n = 9,edges = [[0, 1, 5], [0, 3, 4], [1, 2, 1], [1, 3, 2], [2, 3, 3], [2, 4, 2], [3, 4, 4], [3, 5, 6], [3, 6, 7], [4, 5, 1], [5, 6, 1], [5, 7, 3], [5, 8, 2], [6, 8, 4]],distanceThreshold = 10) == 0\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [1, 4, 3], [2, 3, 2], [2, 5, 5], [3, 4, 1], [3, 5, 3], [3, 6, 4], [4, 5, 1], [5, 6, 2]],distanceThreshold = 5) == 6\n assert candidate(n = 8,edges = [[0, 1, 7], [0, 2, 5], [1, 2, 9], [1, 3, 8], [1, 4, 4], [2, 3, 2], [2, 5, 3], [3, 5, 6], [3, 6, 7], [4, 5, 1], [4, 7, 3], [5, 6, 8], [6, 7, 6]],distanceThreshold = 15) == 7\n assert candidate(n = 7,edges = [[0, 1, 4], [0, 2, 6], [1, 2, 5], [1, 3, 3], [1, 4, 8], [2, 4, 7], [3, 4, 5], [4, 5, 9], [4, 6, 2]],distanceThreshold = 10) == 5\n assert candidate(n = 10,edges = [[0, 1, 4], [0, 2, 5], [0, 3, 6], [1, 2, 1], [1, 3, 2], [1, 4, 3], [2, 3, 1], [2, 4, 2], [2, 5, 3], [3, 4, 1], [3, 5, 2], [3, 6, 3], [4, 5, 1], [4, 6, 2], [4, 7, 3], [5, 6, 1], [5, 7, 2], [5, 8, 3], [6, 7, 1], [6, 8, 2], [6, 9, 3], [7, 8, 1], [7, 9, 2], [8, 9, 1]],distanceThreshold = 5) == 0\n assert candidate(n = 6,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [0, 5, 5], [1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [2, 3, 1], [2, 4, 2], [2, 5, 3], [3, 4, 1], [3, 5, 2], [4, 5, 1]],distanceThreshold = 5) == 5\n assert candidate(n = 8,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [0, 4, 15], [1, 5, 10], [2, 6, 9], [3, 7, 12]],distanceThreshold = 20) == 7\n assert candidate(n = 6,edges = [[0, 1, 3], [0, 2, 5], [1, 2, 2], [1, 3, 4], [1, 4, 6], [2, 3, 1], [2, 4, 3], [3, 4, 1], [3, 5, 2], [4, 5, 2]],distanceThreshold = 4) == 0\n assert candidate(n = 12,edges = [[0, 1, 10], [0, 5, 30], [0, 4, 100], [1, 2, 50], [1, 5, 20], [2, 3, 10], [3, 4, 20], [4, 5, 30], [5, 6, 10], [6, 7, 20], [7, 8, 10], [8, 9, 30], [9, 10, 20], [10, 11, 10], [11, 0, 50]],distanceThreshold = 60) == 11\n assert candidate(n = 6,edges = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [1, 4, 5], [2, 3, 2], [2, 4, 3], [3, 4, 1], [3, 5, 1], [4, 5, 2]],distanceThreshold = 5) == 0\n assert candidate(n = 10,edges = [[0, 1, 2], [1, 2, 3], [0, 3, 4], [3, 4, 5], [4, 5, 1], [2, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [0, 9, 7]],distanceThreshold = 10) == 9\n assert candidate(n = 7,edges = [[0, 1, 4], [1, 2, 3], [2, 3, 2], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 0, 4]],distanceThreshold = 6) == 0\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 5], [1, 2, 2], [1, 3, 6], [2, 4, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7]],distanceThreshold = 10) == 7\n assert candidate(n = 9,edges = [[0, 1, 4], [0, 2, 9], [0, 3, 5], [0, 4, 3], [1, 2, 10], [1, 3, 2], [1, 4, 8], [2, 3, 5], [2, 4, 7], [3, 4, 4], [5, 6, 2], [5, 7, 3], [5, 8, 5], [6, 7, 1], [6, 8, 4], [7, 8, 2]],distanceThreshold = 7) == 8\n assert candidate(n = 6,edges = [[0, 1, 3], [1, 2, 2], [2, 3, 3], [3, 4, 2], [4, 5, 3], [5, 0, 2]],distanceThreshold = 6) == 5\n assert candidate(n = 10,edges = [[0, 1, 4], [0, 2, 15], [0, 3, 10], [1, 2, 3], [1, 3, 12], [1, 4, 20], [2, 3, 7], [2, 4, 13], [2, 5, 8], [3, 4, 1], [3, 5, 6], [3, 6, 14], [4, 5, 9], [4, 6, 11], [5, 6, 5], [6, 7, 17], [6, 8, 22], [7, 8, 2], [7, 9, 23], [8, 9, 18]],distanceThreshold = 30) == 9\n assert candidate(n = 8,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 0, 1]],distanceThreshold = 3) == 7\n assert candidate(n = 10,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 0, 5], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10], [8, 0, 10], [9, 1, 10]],distanceThreshold = 25) == 9\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 4, 8], [1, 2, 3], [1, 4, 2], [2, 3, 1], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 1], [7, 8, 2], [8, 9, 1], [9, 5, 3]],distanceThreshold = 10) == 0\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1], [4, 5, 2], [4, 6, 3], [4, 7, 4], [5, 6, 1], [5, 7, 2], [6, 7, 1]],distanceThreshold = 3) == 7\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 6, 6], [1, 2, 1], [1, 5, 5], [2, 3, 1], [2, 4, 4], [3, 4, 1], [3, 6, 6], [4, 5, 1], [5, 6, 6]],distanceThreshold = 6) == 6\n assert candidate(n = 15,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 0, 1]],distanceThreshold = 7) == 14\n assert candidate(n = 6,edges = [[0, 1, 2], [0, 5, 10], [1, 2, 1], [1, 4, 3], [2, 3, 2], [3, 4, 2], [3, 5, 3], [4, 5, 5]],distanceThreshold = 6) == 5\n assert candidate(n = 8,edges = [[0, 1, 4], [1, 2, 4], [2, 3, 4], [3, 4, 4], [4, 5, 4], [5, 6, 4], [6, 7, 4], [0, 7, 8], [0, 3, 5], [1, 4, 5], [2, 5, 5], [3, 6, 5], [4, 7, 5]],distanceThreshold = 12) == 7\n assert candidate(n = 8,edges = [[0, 1, 5], [0, 2, 5], [0, 7, 6], [1, 2, 5], [1, 3, 3], [1, 6, 4], [1, 7, 3], [2, 3, 5], [2, 4, 5], [3, 4, 3], [3, 5, 2], [4, 5, 2], [4, 6, 5], [5, 6, 5], [6, 7, 5]],distanceThreshold = 8) == 0\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 20], [1, 2, 30], [1, 3, 40], [2, 4, 50], [3, 4, 60], [4, 5, 70], [5, 6, 80], [6, 7, 90], [7, 8, 100], [8, 9, 110], [0, 9, 120]],distanceThreshold = 200) == 8\n assert candidate(n = 9,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [0, 8, 1]],distanceThreshold = 4) == 8\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 0, 1]],distanceThreshold = 2) == 6\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8], [6, 7, 9], [7, 8, 10], [8, 0, 11], [0, 3, 12], [1, 4, 13], [2, 5, 14], [3, 6, 15], [4, 7, 16], [5, 8, 17]],distanceThreshold = 20) == 7\n assert candidate(n = 7,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 0, 8]],distanceThreshold = 10) == 5\n assert candidate(n = 12,edges = [[0, 1, 7], [0, 2, 10], [0, 3, 12], [0, 4, 8], [0, 5, 9], [0, 6, 5], [0, 7, 2], [0, 8, 6], [0, 9, 8], [0, 10, 3], [0, 11, 4], [1, 2, 6], [1, 3, 4], [1, 4, 2], [1, 5, 7], [1, 6, 8], [1, 7, 9], [1, 8, 3], [1, 9, 5], [1, 10, 11], [1, 11, 2], [2, 3, 10], [2, 4, 3], [2, 5, 12], [2, 6, 6], [2, 7, 1], [2, 8, 4], [2, 9, 7], [2, 10, 5], [2, 11, 8], [3, 4, 5], [3, 5, 10], [3, 6, 9], [3, 7, 11], [3, 8, 2], [3, 9, 6], [3, 10, 1], [3, 11, 4], [4, 5, 2], [4, 6, 10], [4, 7, 3], [4, 8, 5], [4, 9, 1], [4, 10, 7], [4, 11, 8], [5, 6, 3], [5, 7, 11], [5, 8, 9], [5, 9, 4], [5, 10, 6], [5, 11, 2], [6, 7, 5], [6, 8, 10], [6, 9, 3], [6, 10, 12], [6, 11, 4], [7, 8, 3], [7, 9, 2], [7, 10, 5], [7, 11, 1], [8, 9, 5], [8, 10, 2], [8, 11, 4], [9, 10, 7], [9, 11, 3], [10, 11, 2]],distanceThreshold = 10) == 11\n assert candidate(n = 10,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 11]],distanceThreshold = 15) == 8\n assert candidate(n = 6,edges = [[0, 1, 2], [0, 2, 4], [0, 3, 5], [1, 2, 1], [1, 3, 8], [1, 4, 3], [2, 3, 2], [2, 4, 6], [3, 4, 7], [3, 5, 3], [4, 5, 1]],distanceThreshold = 5) == 5\n assert candidate(n = 8,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [1, 4, 5], [1, 5, 6], [2, 6, 7], [2, 7, 8], [3, 7, 9]],distanceThreshold = 10) == 7\n assert candidate(n = 6,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [0, 5, 7]],distanceThreshold = 9) == 5\n assert candidate(n = 9,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 6], [0, 6, 7], [0, 7, 8], [0, 8, 9], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [1, 3, 4], [2, 4, 5], [3, 5, 6], [4, 6, 7], [5, 7, 8], [6, 8, 9], [1, 4, 6], [2, 5, 7], [3, 6, 8], [4, 7, 9], [5, 8, 10], [1, 5, 8], [2, 6, 9], [3, 7, 10], [4, 8, 11], [1, 6, 9], [2, 7, 10], [3, 8, 11], [1, 7, 10], [2, 8, 11], [1, 8, 11]],distanceThreshold = 15) == 8\n assert candidate(n = 9,edges = [[0, 1, 100], [1, 2, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [5, 6, 100], [6, 7, 100], [7, 8, 100], [0, 8, 100], [0, 4, 50], [1, 5, 50], [2, 6, 50], [3, 7, 50], [4, 8, 50], [5, 0, 50], [6, 1, 50], [7, 2, 50], [8, 3, 50]],distanceThreshold = 150) == 8\n assert candidate(n = 10,edges = [[0, 1, 4], [0, 2, 8], [0, 3, 7], [0, 4, 9], [0, 5, 10], [0, 6, 1], [0, 7, 2], [0, 8, 6], [0, 9, 8], [1, 2, 2], [1, 3, 9], [1, 4, 3], [1, 5, 5], [1, 6, 1], [1, 7, 4], [1, 8, 7], [1, 9, 1], [2, 3, 7], [2, 4, 5], [2, 5, 10], [2, 6, 6], [2, 7, 1], [2, 8, 4], [2, 9, 3], [3, 4, 3], [3, 5, 9], [3, 6, 5], [3, 7, 10], [3, 8, 6], [3, 9, 1], [4, 5, 5], [4, 6, 9], [4, 7, 7], [4, 8, 1], [4, 9, 8], [5, 6, 8], [5, 7, 6], [5, 8, 10], [5, 9, 4], [6, 7, 7], [6, 8, 5], [6, 9, 3], [7, 8, 4], [7, 9, 2], [8, 9, 5]],distanceThreshold = 10) == 9\n assert candidate(n = 6,edges = [[0, 1, 2], [0, 3, 4], [1, 2, 1], [1, 4, 5], [2, 3, 1], [3, 4, 3], [4, 5, 2]],distanceThreshold = 5) == 5\n assert candidate(n = 9,edges = [[0, 1, 5], [0, 2, 7], [0, 3, 9], [1, 4, 11], [1, 5, 13], [2, 5, 15], [2, 6, 17], [3, 6, 19], [4, 7, 21], [4, 8, 23], [5, 7, 25], [5, 8, 27], [6, 8, 29]],distanceThreshold = 20) == 8\n assert candidate(n = 8,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 7, 9], [1, 6, 10]],distanceThreshold = 15) == 7\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "distanceThreshold"], "leetcode_dataset_entry_point": "Solution().findTheCity", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findTheCity(self, n: int, edges: list[list[int]], distanceThreshold: int) -> int:", "container": "Solution", "callable": "findTheCity", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "distanceThreshold", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1335, "task_id": "minimum-difficulty-of-a-job-schedule", "difficulty": "Hard", "problem_description": "You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the ith job, you have to finish all the jobs j where 0 <= j < i).\nYou have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximum difficulty of a job done on that day.\nYou are given an integer array jobDifficulty and an integer d. The difficulty of the ith job is jobDifficulty[i].\nReturn the minimum difficulty of a job schedule. If you cannot find a schedule for the jobs return -1.\n \nExample 1:\n\n\nInput: jobDifficulty = [6,5,4,3,2,1], d = 2\nOutput: 7\nExplanation: First day you can finish the first 5 jobs, total difficulty = 6.\nSecond day you can finish the last job, total difficulty = 1.\nThe difficulty of the schedule = 6 + 1 = 7 \n\nExample 2:\n\nInput: jobDifficulty = [9,9,9], d = 4\nOutput: -1\nExplanation: If you finish a job per day you will still have a free day. you cannot find a schedule for the given jobs.\n\nExample 3:\n\nInput: jobDifficulty = [1,1,1], d = 3\nOutput: 3\nExplanation: The schedule is one job per day. total difficulty will be 3.\n\n \nConstraints:\n\n1 <= jobDifficulty.length <= 300\n0 <= jobDifficulty[i] <= 1000\n1 <= d <= 10\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 10) == 55\n assert candidate(jobDifficulty = [300, 500, 1000],d = 3) == 1800\n assert candidate(jobDifficulty = [6, 5, 4, 3, 2, 1],d = 2) == 7\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 5) == 20\n assert candidate(jobDifficulty = [15, 97, 88, 92, 49],d = 2) == 112\n assert candidate(jobDifficulty = [7, 1, 7, 1, 7, 1],d = 3) == 15\n assert candidate(jobDifficulty = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],d = 5) == 25\n assert candidate(jobDifficulty = [0, 0, 0, 0],d = 4) == 0\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50],d = 3) == 80\n assert candidate(jobDifficulty = [1000, 0, 1000, 0, 1000],d = 3) == 2000\n assert candidate(jobDifficulty = [30, 10, 40, 20, 10, 50],d = 3) == 90\n assert candidate(jobDifficulty = [100, 200, 300],d = 1) == 300\n assert candidate(jobDifficulty = [3, 2, 1],d = 1) == 3\n assert candidate(jobDifficulty = [1],d = 1) == 1\n assert candidate(jobDifficulty = [5, 4, 3, 2, 1],d = 1) == 5\n assert candidate(jobDifficulty = [9, 9, 9],d = 4) == -1\n assert candidate(jobDifficulty = [5, 4, 3, 2, 1],d = 5) == 15\n assert candidate(jobDifficulty = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],d = 10) == 30\n assert candidate(jobDifficulty = [1, 2],d = 2) == 3\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50],d = 2) == 60\n assert candidate(jobDifficulty = [1, 1, 1],d = 3) == 3\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50],d = 5) == 150\n assert candidate(jobDifficulty = [500, 400, 300, 200, 100, 900, 800, 700, 600, 500],d = 4) == 1700\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1],d = 5) == 32\n assert candidate(jobDifficulty = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],d = 10) == 550\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],d = 15) == 1200\n assert candidate(jobDifficulty = [10, 4, 15, 8, 12, 9, 5, 6, 7, 11, 3],d = 4) == 32\n assert candidate(jobDifficulty = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 10) == 55\n assert candidate(jobDifficulty = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],d = 10) == 15\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 300],d = 15) == 405\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 5) == 25\n assert candidate(jobDifficulty = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 13\n assert candidate(jobDifficulty = [8, 5, 7, 9, 4, 2, 6, 3, 10, 1, 12, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 20) == 220\n assert candidate(jobDifficulty = [9, 4, 5, 3, 2, 8, 7, 1, 6, 10],d = 5) == 29\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 29) == 29\n assert candidate(jobDifficulty = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],d = 10) == 180\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 10) == 65\n assert candidate(jobDifficulty = [300, 200, 100, 250, 400, 350, 500, 450, 550, 600],d = 5) == 1450\n assert candidate(jobDifficulty = [5, 8, 6, 5, 3, 4, 2, 7, 1, 9],d = 4) == 23\n assert candidate(jobDifficulty = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],d = 25) == 660\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],d = 15) == 1350\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],d = 5) == 400\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 10) == 60\n assert candidate(jobDifficulty = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],d = 10) == 6500\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 4) == 16\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 1) == 30\n assert candidate(jobDifficulty = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],d = 5) == 21\n assert candidate(jobDifficulty = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],d = 7) == 35\n assert candidate(jobDifficulty = [10, 100, 20, 50, 30, 70, 40, 60, 90, 80, 10, 200, 150, 300, 250],d = 5) == 480\n assert candidate(jobDifficulty = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],d = 15) == 75\n assert candidate(jobDifficulty = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],d = 10) == 100\n assert candidate(jobDifficulty = [8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 11\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 300],d = 10) == 345\n assert candidate(jobDifficulty = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],d = 5) == 25\n assert candidate(jobDifficulty = [9, 18, 1, 5, 19, 12, 4, 7, 8, 6],d = 5) == 44\n assert candidate(jobDifficulty = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980],d = 10) == 9855\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 15) == 135\n assert candidate(jobDifficulty = [3, 6, 1, 9, 10, 5, 4, 8, 7, 2],d = 10) == 55\n assert candidate(jobDifficulty = [300, 299, 298, 297, 296, 295, 294, 293, 292, 291, 290, 289, 288, 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, 275, 274, 273, 272, 271],d = 5) == 1390\n assert candidate(jobDifficulty = [7, 8, 4, 3, 2, 9, 10, 11, 1, 2],d = 3) == 14\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],d = 3) == 130\n assert candidate(jobDifficulty = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550, 1650, 1750, 1850, 1950],d = 10) == 6000\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],d = 15) == 1200\n assert candidate(jobDifficulty = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 13\n assert candidate(jobDifficulty = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],d = 10) == 3250\n assert candidate(jobDifficulty = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500],d = 5) == 1400\n assert candidate(jobDifficulty = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],d = 10) == 5500\n assert candidate(jobDifficulty = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],d = 5) == 300\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 30) == 465\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 5) == 40\n assert candidate(jobDifficulty = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],d = 25) == 50\n assert candidate(jobDifficulty = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],d = 10) == 45\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [3, 6, 5, 10, 12, 8, 7, 4, 15, 11, 9, 1, 14, 13, 2, 16, 18, 17, 19, 20, 21, 22, 23, 24, 25],d = 10) == 86\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 30) == 465\n assert candidate(jobDifficulty = [300, 200, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],d = 10) == 300\n assert candidate(jobDifficulty = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 2) == 20\n assert candidate(jobDifficulty = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16],d = 10) == 69\n assert candidate(jobDifficulty = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 50, 100, 150, 200, 250, 300],d = 10) == 2300\n assert candidate(jobDifficulty = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],d = 2) == 1100\n assert candidate(jobDifficulty = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],d = 10) == 140\n assert candidate(jobDifficulty = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991],d = 5) == 2993\n assert candidate(jobDifficulty = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],d = 15) == 1500\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],d = 3) == 130\n assert candidate(jobDifficulty = [300, 250, 200, 150, 100, 50, 10, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 10) == 353\n assert candidate(jobDifficulty = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],d = 10) == 10000\n assert candidate(jobDifficulty = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],d = 10) == 550\n assert candidate(jobDifficulty = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],d = 5) == 500\n assert candidate(jobDifficulty = [9, 18, 7, 16, 15, 14, 13, 2, 11, 10, 8, 6, 5, 4, 3, 1, 12, 17, 19, 20],d = 5) == 46\n assert candidate(jobDifficulty = [500, 300, 700, 100, 200, 400, 800, 600, 900],d = 4) == 1900\n assert candidate(jobDifficulty = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],d = 15) == 255\n assert candidate(jobDifficulty = [5, 8, 3, 1, 9, 4, 6, 7, 2, 10, 15, 12, 14, 11, 13, 16, 18, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 8) == 64\n assert candidate(jobDifficulty = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],d = 29) == 87\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 7) == 31\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 5) == 25\n assert candidate(jobDifficulty = [2, 3, 6, 5, 4, 7, 8, 9, 10, 1, 11, 12, 13, 14, 15],d = 7) == 41\n assert candidate(jobDifficulty = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],d = 1) == 0\n assert candidate(jobDifficulty = [300, 250, 200, 150, 100, 50, 0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],d = 7) == 1600\n assert candidate(jobDifficulty = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10],d = 4) == 25\n assert candidate(jobDifficulty = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105],d = 7) == 240\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 10) == 75\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 7) == 41\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 7) == 36\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [200, 150, 100, 50, 0, 50, 100, 150, 200],d = 6) == 600\n assert candidate(jobDifficulty = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],d = 20) == -1\n assert candidate(jobDifficulty = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],d = 10) == 10000\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],d = 5) == 400\n"}, "metadata": {"canonical_parameter_names": ["jobDifficulty", "d"], "leetcode_dataset_entry_point": "Solution().minDifficulty", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minDifficulty(self, jobDifficulty: list[int], d: int) -> int:", "container": "Solution", "callable": "minDifficulty", "parameters": [{"name": "jobDifficulty", "type": "list[int]"}, {"name": "d", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1337, "task_id": "the-k-weakest-rows-in-a-matrix", "difficulty": "Easy", "problem_description": "You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the civilians. That is, all the 1's will appear to the left of all the 0's in each row.\nA row i is weaker than a row j if one of the following is true:\n\nThe number of soldiers in row i is less than the number of soldiers in row j.\nBoth rows have the same number of soldiers and i < j.\n\nReturn the indices of the k weakest rows in the matrix ordered from weakest to strongest.\n \nExample 1:\n\nInput: mat = \n[[1,1,0,0,0],\n [1,1,1,1,0],\n [1,0,0,0,0],\n [1,1,0,0,0],\n [1,1,1,1,1]], \nk = 3\nOutput: [2,0,3]\nExplanation: \nThe number of soldiers in each row is: \n- Row 0: 2 \n- Row 1: 4 \n- Row 2: 1 \n- Row 3: 2 \n- Row 4: 5 \nThe rows ordered from weakest to strongest are [2,0,3,1,4].\n\nExample 2:\n\nInput: mat = \n[[1,0,0,0],\n [1,1,1,1],\n [1,0,0,0],\n [1,0,0,0]], \nk = 2\nOutput: [0,2]\nExplanation: \nThe number of soldiers in each row is: \n- Row 0: 1 \n- Row 1: 4 \n- Row 2: 1 \n- Row 3: 1 \nThe rows ordered from weakest to strongest are [0,2,3,1].\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n2 <= n, m <= 100\n1 <= k <= m\nmatrix[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 2) == [0, 1]\n assert candidate(mat = [[0, 0, 0, 0], [1, 0, 0, 0], [1, 1, 0, 0], [1, 1, 1, 0]],k = 2) == [0, 1]\n assert candidate(mat = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 0, 0], [0, 1, 1, 1]],k = 3) == [1, 2, 0]\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 0], [1, 1, 1, 1], [1, 1, 1, 1]],k = 2) == [0, 1]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 1) == [0]\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 1, 1]],k = 3) == [2, 0, 3]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 4) == [3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 1, 1]],k = 4) == [2, 3, 0, 1]\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 1) == [0]\n assert candidate(mat = [[1, 0, 0, 0], [1, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0]],k = 2) == [0, 2]\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 1, 1]],k = 5) == [2, 3, 0, 1, 4]\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 0], [1, 0, 0, 0], [1, 1, 0, 0]],k = 2) == [1, 2]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 7) == [9, 10, 8, 7, 6, 5, 4]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 10) == [10, 11, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [6, 5, 4, 3, 2]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [5, 4, 3, 2, 1]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == [0, 1, 2]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 2) == [4, 3]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]],k = 7) == [1, 5, 3, 0, 2, 4, 6]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 6) == [1, 8, 9, 0, 3, 4]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],k = 6) == [5, 4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0]],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0]],k = 5) == [3, 0, 2, 1, 4]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 2) == [3, 4]\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]],k = 6) == [1, 3, 5, 0, 2, 4]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == [0, 1, 2]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0]],k = 3) == [3, 2, 5]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]],k = 2) == [0, 1]\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 7) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [1, 7, 6, 5, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [5, 6, 7, 4, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 3) == [5, 4, 3]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0]],k = 5) == [3, 1, 5, 4, 0]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]],k = 3) == [3, 2, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],k = 4) == [4, 3, 2, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0]],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 4) == [1, 5, 4, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],k = 3) == [5, 4, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0]],k = 3) == [3, 4, 1]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0], [1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]],k = 3) == [4, 3, 2]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [0, 1, 2, 3, 4]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [0, 1, 2, 3, 4]\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0]],k = 4) == [1, 0, 3, 2]\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [0, 1, 2, 3, 4]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]],k = 3) == [3, 2, 1]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0]],k = 5) == [3, 4, 1, 0, 2]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [1, 4, 2, 0, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 4) == [4, 3, 2, 1]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 4) == [8, 9, 7, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 10) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],k = 3) == [0, 1, 2]\n assert candidate(mat = [[1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]],k = 6) == [5, 0, 1, 2, 3, 4]\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [1, 0, 2, 3, 4]\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 3) == [5, 4, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0]],k = 4) == [5, 1, 6, 4]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 3) == [2, 3, 4]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0]],k = 6) == [4, 5, 0, 7, 1, 6]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0]],k = 5) == [3, 4, 5, 0, 1]\n assert candidate(mat = [[1, 1, 0, 0], [1, 0, 0, 0], [1, 1, 1, 0], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 0, 0]],k = 4) == [1, 0, 5, 2]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 10) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]],k = 5) == [1, 3, 4, 0, 2]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]],k = 4) == [4, 3, 2, 1]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0]],k = 4) == [2, 1, 5, 0]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 7) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],k = 6) == [2, 0, 3, 4, 1, 5]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 6) == [10, 9, 8, 7, 6, 5]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == [0, 1, 2]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 3) == [0, 1, 2]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 2) == [0, 1]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [9, 8, 7, 6, 5]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 7) == [9, 8, 7, 6, 5, 4, 3]\n"}, "metadata": {"canonical_parameter_names": ["mat", "k"], "leetcode_dataset_entry_point": "Solution().kWeakestRows", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def kWeakestRows(self, mat: list[list[int]], k: int) -> list[int]:", "container": "Solution", "callable": "kWeakestRows", "parameters": [{"name": "mat", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1338, "task_id": "reduce-array-size-to-the-half", "difficulty": "Medium", "problem_description": "You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array.\nReturn the minimum size of the set so that at least half of the integers of the array are removed.\n \nExample 1:\n\nInput: arr = [3,3,3,3,5,5,5,2,2,7]\nOutput: 2\nExplanation: Choosing {3,7} will make the new array [5,5,5,2,2] which has size 5 (i.e equal to half of the size of the old array).\nPossible sets of size 2 are {3,5},{3,2},{5,2}.\nChoosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] which has a size greater than half of the size of the old array.\n\nExample 2:\n\nInput: arr = [7,7,7,7,7,7]\nOutput: 1\nExplanation: The only possible set you can choose is {7}. This will make the new array empty.\n\n \nConstraints:\n\n2 <= arr.length <= 105\narr.length is even.\n1 <= arr[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [7, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [10, 10, 20, 20, 20, 30, 30, 30, 30, 30]) == 1\n assert candidate(arr = [3, 3, 3, 3, 5, 5, 5, 2, 2, 7]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 2\n assert candidate(arr = [10, 20, 20, 10, 10, 30, 50, 10, 20, 20]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5]) == 2\n assert candidate(arr = [10, 10, 20, 20, 30, 30, 30, 40, 40, 40, 40]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 4]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 3, 3, 4, 5]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 25\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 8\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 1\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 9]) == 3\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200]) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 3\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 4\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 1\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 5\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 2\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 1\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 5\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 1\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, 70, 70]) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7]) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(arr = [99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 83, 82, 82, 81, 81, 80, 80, 79, 79, 78, 78, 77, 77, 76, 76, 75, 75, 74, 74, 73, 73, 72, 72, 71, 71, 70, 70, 69, 69, 68, 68, 67, 67, 66, 66, 65, 65, 64, 64, 63, 63, 62, 62, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 56, 56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50]) == 25\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 2\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 3\n assert candidate(arr = [1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 2\n assert candidate(arr = [7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr = [100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400]) == 2\n assert candidate(arr = [10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8]) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 2, 2, 2, 3, 3, 4]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 3\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4]) == 1\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().minSetSize", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minSetSize(self, arr: list[int]) -> int:", "container": "Solution", "callable": "minSetSize", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1339, "task_id": "maximum-product-of-splitted-binary-tree", "difficulty": "Medium", "problem_description": "Given the root of a binary tree, split the binary tree into two subtrees by removing one edge such that the product of the sums of the subtrees is maximized.\nReturn the maximum product of the sums of the two subtrees. Since the answer may be too large, return it modulo 109 + 7.\nNote that you need to maximize the answer before taking the mod and not after taking it.\n \nExample 1:\n\n\nInput: root = [1,2,3,4,5,6]\nOutput: 110\nExplanation: Remove the red edge and get 2 binary trees with sum 11 and 10. Their product is 110 (11*10)\n\nExample 2:\n\n\nInput: root = [1,null,2,3,4,null,null,5,6]\nOutput: 90\nExplanation: Remove the red edge and get 2 binary trees with sum 15 and 6.Their product is 90 (15*6)\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [2, 5 * 104].\n1 <= Node.val <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([1, 2, 3])) == 9\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18])) == 825\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6])) == 110\n assert candidate(root = tree_node([1, None, 2, 3, 4, None, None, 5, 6])) == 90\n assert candidate(root = tree_node([2, 3, 9, 10, 7, 4, 6, 5, 8, 11, 13, None, 14, 9, 1, None, 2, 3, None, None, None, None, None, None, 4, 6])) == 3410\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 130, 160, 180])) == 486675\n assert candidate(root = tree_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100])) == 270725\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25, None, 26, None, 27, None, 28, None, 29, None, 30, None, 31])) == 61503\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 756\n assert candidate(root = tree_node([1, 2, 2, 3, None, None, 3, None, None, 4, None, None, 4])) == 88\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == 24600\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50])) == 374900\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100])) == 5933400\n assert candidate(root = tree_node([10, 2, 20, 1, None, 15, 30, 8, None, None, None, 9, None, 7, None, 6, None, 5, None, 4, None, 3, None, 2, None, 1, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == 3672\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 756\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40])) == 166875\n assert candidate(root = tree_node([9999, 4999, 4999, 2499, 2500, 2499, 2500, 1249, 1250, 1250, 1250, 1249, 1250, 1249, 1250, 624, 625, 625, 625, 625, 625, 625, 625, 625, 625, 625, 625, 625, 625, 625, 625])) == 599780020\n assert candidate(root = tree_node([5000, 2500, 7500, 1250, 3750, 6250, 8750, 625, 1875, 2500, 5000, 4375, 7500, 8125, 9375])) == 263281243\n assert candidate(root = tree_node([5, 2, 9, 1, 3, 8, 12, None, None, None, None, 6, 10, 11, 13])) == 1584\n assert candidate(root = tree_node([7, 3, 15, None, None, 9, 20])) == 680\n assert candidate(root = tree_node([2, 3, 9, 10, 7, 4, 6, 5, 8, 11, 13, None, 14, 9, 1, None, 2, 3, None, None, None, None, None, None, 4, 6, 7, 8, 11, 13, None, 14, 9, 1, None, 2, 3, None, None, None, None, None, None, 4, 6, 7, 8, 11, 13, None, 14, 9, 1, None, 2, 3, None, None, None, None, None, None, 4, 6])) == 18522\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 2, 4, None, None, None, None, None, 25, 20])) == 2970\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, 6, None, None, 7, 8, None, None, 9, 10])) == 756\n assert candidate(root = tree_node([500, 250, 750, 125, 375, 500, 1000, 62, 188, 250, 500, 375, 625, 875, 1125, 31, 94, 125, 250, 375, 438, 625, 750, 875, 1000, 1125, 1250, 1375, 1500, 1625, 1750, 1875])) == 123145250\n assert candidate(root = tree_node([10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == 899800054\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 11025\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50])) == 376650\n assert candidate(root = tree_node([7, 3, 6, 2, 4, None, 10, 1, 5, None, None, 8, 9, 11, 12])) == 1520\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20])) == 11024\n assert candidate(root = tree_node([999, 499, 1499, 249, 749, 999, 1999, 124, 374, 499, 749, 999, 1249, 1499, 1749, 62, 187, 249, 374, 499, 562, 749, 999, 1249, 1499, 1749, 1999, 2249, 2499, 2749, 2999, 3249, 3499, 3749, 3999, 4249, 4499, 4749, 4999, 5249, 5499, 5749, 5999])) == 930774628\n assert candidate(root = tree_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80])) == 115500\n assert candidate(root = tree_node([5, 10, None, 15, 20, None, None, 25, 30, 35, 40, None, None, None, None, 45, 50, None, None, None, None, None, None, 55, 60])) == 18900\n assert candidate(root = tree_node([25000, 12500, 37500, 6250, 18750, 25000, 50000, 3125, 9375, 15625, 21875, 12500, 18750, 31250, 37500, 1562, 4688, 7812, 9375, 12500, 15625, 18750, 21875, 25000, 31250, 37500, 43750, 46875, 50000, 53125, 56250, 59375, 62500])) == 650111233\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 130, 160, 190])) == 496125\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 7, 13, 17, 23, 27, 33, 37, 0, 2, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38])) == 90405\n assert candidate(root = tree_node([500, 400, 600, 300, 450, 550, 650, 200, 350, 425, 475, 525, 575, 625, 675, 100, 250, 325, 375, 412, 437, 462, 487, 512, 537, 562, 587, 612, 637, 662, 687, 90, 160, 225, 275, 312, 337, 362, 387, 402, 447, 492, 532, 557, 592, 627, 642, 677, 702, 65, 125, 187, 237, 262, 287, 302, 347, 392, 417, 432, 477, 502, 527, 542, 577, 602, 632, 657, 692, 717, 742, 767, 792])) == 287180438\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 190, None, 40, 55, 65, 70, 85, 90, 115, 120, 130, 145, 155, 165, 185, 195, None, 35, 45, 56, 64, 72, 78, 82, 88, 95, 105, 117, 123, 127, 133, 138, 143, 148, 153, 158, 163, 168, 173, 178, 183, 188, 193, None, 9, 11, 13, 17, 21, 23, 27, 29, 33, 37, 41, 43, 47, 49, 51, 53, 57, 59, 61, 63, 67, 69, 71, 73, 77, 79, 81, 83, 87, 89, 91, 93, 97, 99])) == 16555528\n assert candidate(root = tree_node([5000, 2500, 7500, 1250, 3750, 6250, 8750, 625, 1875, 2500, 4375, 5625, 7187, 9375, 10625, 3125, 937, 1250, 1687, 2187, 3125, 3750, 4687, 5312, 5937, 6562, 7187, 7812, 8437, 9062, 9687, 10312, 10937, 11562, 12187, 12812, 13437, 14062, 14687, 15312])) == 398822622\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, 2, 6, 8, 16, 20, None, None, None, None, 9, 12, None, None, None, None, 17, 21])) == 7176\n assert candidate(root = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == 225\n assert candidate(root = tree_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400])) == 16687500\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8])) == 315\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])) == 3575\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180])) == 491825\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == 53354\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None])) == 11025\n assert candidate(root = tree_node([5, 3, 8, 2, 4, 7, 9, 1, 6, None, None, 10, 11, None, None, 12, 13, None, None, 14, 15, None, None, 16])) == 4588\n assert candidate(root = tree_node([1000, 500, 1500, 250, 750, 1250, 1750, 100, 300, 600, 800, 1100, 1400, 1600, 1800, 50, 150, 250, 350, 450, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550, 1650, 1750, 1850, 1950])) == 277680000\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25, None, 26, None, 27, None, 28, None, 29, None, 30, None, 31, None, 32, None, 33, None, 34, None, 35, None, 36, None, 37, None, 38, None, 39, None, 40, None, 41, None, 42, None, 43, None, 44, None, 45, None, 46, None, 47, None, 48, None, 49, None, 50])) == 406350\n assert candidate(root = tree_node([10000, 5000, 15000, 2500, 7500, 12500, 17500, 1000, 3000, 6000, 8000, 11000, 13000, 16000, 18000, 500, 1500, 2500, 3500, 4500, 6500, 7500, 8500, 9500, 10500, 11500, 12500, 13500, 14500, 15500])) == 482499888\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, None, None, None, None, 9, 10, 11, 12, 13, None, None, 14, 15, 16, 17])) == 5670\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9])) == 504\n assert candidate(root = tree_node([1, None, 2, None, None, None, 3, None, None, None, 4, None, None, None, 5, None, None, None, 6, None, None, None, 7, None, None, None, 8, None, None, None, 9])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 10829\n assert candidate(root = tree_node([1000, 900, 100, 800, 950, 50, 150, 700, 850, 925, 975, 25, 75, 125, 175, 650, 750, 825, 875, 912, 937, 962, 987, 10, 30, 60, 80, 110, 140, 160, 180, 5, 15, 20, 40, 85, 90, 113, 130, 153, 172, 183, 190])) == 68450028\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 50, 100, 6, 18, 25, 37, 43, 62, 75, 87, 3, 9, 12, 25, 37, 43, 56, 62, 75, 87, 100, 112, 125, 137, 150, 162, 175, 187])) == 1189628\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 3500\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180, 5, 15, 20, 40, 85, 95, 115, 135, 155, 170, 185, 3, 7, 12, 18, 35, 45, 77, 90, 113, 130, 153, 172, 183, 190])) == 3437925\n assert candidate(root = tree_node([9999, None, 9998, None, 9997, None, 9996, None, 9995, None, 9994, None, 9993, None, 9992, None, 9991, None, 9990, None, 9989, None, 9988, None, 9987, None, 9986, None, 9985, None, 9984, None, 9983, None, 9982, None, 9981, None, 9980, None, 9979, None, 9978, None, 9977, None, 9976, None, 9975, None, 9974, None, 9973, None, 9972, None, 9971, None, 9970, None, 9969, None, 9968, None, 9967, None, 9966, None, 9965, None, 9964, None, 9963, None, 9962, None, 9961, None, 9960])) == 836127827\n assert candidate(root = tree_node([4, 2, 6, 1, 3, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == 53244\n assert candidate(root = tree_node([1000, 500, 1500, 250, 750, 1250, 1750, 125, 375, 625, 875, 1125, 1375, 1625, 1875, 62, 188, 288, 462, 512, 688, 748, 1062, 1112, 1288, 1348, 1662, 1712, 1888, 1938, 31, 83, 133, 183, 233, 283, 333, 383, 433, 483, 533, 583, 633, 683, 733, 783, 833, 883, 933, 983, 141, 191, 241, 291, 341, 391, 441, 491, 541, 591, 641, 691, 741, 791, 841, 891, 941, 991, 26, 76, 126, 176, 226, 276, 326, 376, 426, 476, 526, 576, 626, 676, 726, 776, 826, 876, 926, 976, 3, 53, 103, 153, 203, 253, 303, 353, 403, 453, 503, 553, 603, 653, 703, 753, 803, 853, 903, 953, 18, 68, 118, 168, 218, 268, 318, 368, 418, 468, 518, 568, 618, 668, 718, 768, 818, 868, 918, 968])) == 533225977\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, None, 6, None, 7, None, None, None, None, 8, None, 9, None, None, None, None, 10, None, 11, None, None, None, None, 12, None, 13, None, None, None, None, 14, None, 15])) == 192\n assert candidate(root = tree_node([10000, 5000, 5000, 2500, 2500, 2500, 2500, 1250, 1250, 1250, 1250, 1250, 1250, 1250, 1250])) == 375000000\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().maxProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxProduct(self, root: TreeNode | None) -> int:", "container": "Solution", "callable": "maxProduct", "parameters": [{"name": "root", "type": "TreeNode | None"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1340, "task_id": "jump-game-v", "difficulty": "Hard", "problem_description": "Given an array of integers arr and an integer d. In one step you can jump from index i to index:\n\ni + x where: i + x < arr.length and 0 < x <= d.\ni - x where: i - x >= 0 and 0 < x <= d.\n\nIn addition, you can only jump from index i to index j if arr[i] > arr[j] and arr[i] > arr[k] for all indices k between i and j (More formally min(i, j) < k < max(i, j)).\nYou can choose any index of the array and start jumping. Return the maximum number of indices you can visit.\nNotice that you can not jump outside of the array at any time.\n \nExample 1:\n\n\nInput: arr = [6,4,14,6,8,13,9,7,10,6,12], d = 2\nOutput: 4\nExplanation: You can start at index 10. You can jump 10 --> 8 --> 6 --> 7 as shown.\nNote that if you start at index 6 you can only jump to index 7. You cannot jump to index 5 because 13 > 9. You cannot jump to index 4 because index 5 is between index 4 and 6 and 13 > 9.\nSimilarly You cannot jump from index 3 to index 2 or index 1.\n\nExample 2:\n\nInput: arr = [3,3,3,3,3], d = 3\nOutput: 1\nExplanation: You can start at any index. You always cannot jump to any index.\n\nExample 3:\n\nInput: arr = [7,6,5,4,3,2,1], d = 1\nOutput: 7\nExplanation: Start at index 0. You can visit all the indicies. \n\n \nConstraints:\n\n1 <= arr.length <= 1000\n1 <= arr[i] <= 105\n1 <= d <= arr.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5],d = 4) == 5\n assert candidate(arr = [1, 2, 3, 4, 5],d = 2) == 5\n assert candidate(arr = [3, 3, 3, 3, 3],d = 3) == 1\n assert candidate(arr = [5, 4, 3, 2, 1],d = 4) == 5\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1],d = 1) == 7\n assert candidate(arr = [6, 4, 14, 6, 8, 13, 9, 7, 10, 6, 12],d = 2) == 4\n assert candidate(arr = [5, 4, 3, 2, 1],d = 1) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],d = 2) == 2\n assert candidate(arr = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],d = 2) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],d = 5) == 1\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],d = 5) == 10\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 15\n assert candidate(arr = [3, 5, 2, 1, 4, 7, 6, 8, 9, 10],d = 3) == 7\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 4) == 10\n assert candidate(arr = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10, 1],d = 10) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 5) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1],d = 3) == 5\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],d = 2) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 10) == 20\n assert candidate(arr = [1, 5, 3, 8, 2, 7, 4, 9, 6, 10],d = 5) == 5\n assert candidate(arr = [10, 1, 10, 1, 10, 1, 10],d = 2) == 2\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],d = 6) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 2) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 5) == 20\n assert candidate(arr = [8, 7, 6, 5, 4, 3, 2, 1, 9, 10, 11, 12, 13, 14, 15, 16, 17],d = 4) == 13\n assert candidate(arr = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 7) == 17\n assert candidate(arr = [6, 1, 5, 3, 2, 7, 4],d = 3) == 4\n assert candidate(arr = [6, 8, 9, 2, 1, 5, 3, 4, 7],d = 2) == 3\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],d = 2) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 2) == 10\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],d = 1) == 2\n assert candidate(arr = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5],d = 2) == 6\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],d = 1) == 9\n assert candidate(arr = [6, 12, 8, 14, 3, 10, 11, 9, 5, 7, 2, 4, 13, 1, 6],d = 4) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 5) == 15\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 20\n assert candidate(arr = [10, 20, 30, 40, 50, 45, 44, 43, 42, 41],d = 3) == 6\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 6) == 15\n assert candidate(arr = [4, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],d = 3) == 4\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5],d = 3) == 5\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 10) == 11\n assert candidate(arr = [2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9],d = 3) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 2) == 20\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],d = 2) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 1) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 10) == 10\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],d = 3) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 50, 40, 30, 20, 10],d = 5) == 6\n assert candidate(arr = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],d = 2) == 6\n assert candidate(arr = [1, 5, 2, 6, 3, 7, 4, 8],d = 2) == 5\n assert candidate(arr = [3, 8, 1, 6, 2, 9, 5, 4, 7],d = 3) == 4\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 4) == 10\n assert candidate(arr = [2, 6, 4, 8, 4, 6, 4, 8, 4, 6, 4, 8, 4, 6, 4, 8, 4, 6, 4, 8],d = 2) == 3\n assert candidate(arr = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1],d = 2) == 3\n assert candidate(arr = [8, 3, 5, 2, 4, 6, 7, 1, 9],d = 3) == 6\n assert candidate(arr = [3, 1, 5, 4, 2, 6, 7, 8, 9, 1],d = 5) == 7\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 5) == 10\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 8, 7, 9],d = 3) == 6\n assert candidate(arr = [10, 20, 15, 25, 30, 5, 40, 35, 50, 45],d = 5) == 6\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],d = 1) == 1\n assert candidate(arr = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100, 10],d = 1) == 2\n assert candidate(arr = [1, 6, 5, 4, 3, 2, 7],d = 3) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 4) == 15\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 2) == 15\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17, 16, 18, 17, 19, 18, 20],d = 2) == 19\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 10\n assert candidate(arr = [5, 1, 4, 1, 3, 1, 2, 1],d = 2) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 5) == 20\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 9) == 10\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 20\n assert candidate(arr = [5, 6, 1, 2, 9, 3, 4, 8, 7, 10],d = 3) == 4\n assert candidate(arr = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],d = 4) == 2\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],d = 5) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 4) == 15\n assert candidate(arr = [1, 6, 5, 4, 6, 1, 2, 3, 4, 6, 5, 4, 6, 1, 2, 3, 4, 6, 5, 4],d = 2) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4],d = 4) == 5\n assert candidate(arr = [1, 6, 3, 5, 2, 4, 7, 8, 10, 9],d = 4) == 6\n assert candidate(arr = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],d = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 5) == 10\n assert candidate(arr = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],d = 5) == 10\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],d = 3) == 11\n assert candidate(arr = [3, 1, 2, 1, 3, 1, 2, 1, 3],d = 1) == 2\n assert candidate(arr = [1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10],d = 5) == 9\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 4) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 1) == 1\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],d = 4) == 9\n assert candidate(arr = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100],d = 5) == 2\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],d = 3) == 6\n assert candidate(arr = [10, 2, 8, 4, 7, 9, 3, 1, 5, 6],d = 4) == 5\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2],d = 2) == 3\n assert candidate(arr = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],d = 5) == 6\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 3) == 10\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],d = 4) == 10\n assert candidate(arr = [7, 2, 8, 9, 1, 3, 5, 6, 4],d = 3) == 4\n assert candidate(arr = [5, 1, 3, 4, 2, 6, 7, 8, 9, 10],d = 2) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],d = 3) == 6\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],d = 2) == 9\n assert candidate(arr = [5, 1, 3, 2, 4, 6, 7, 8, 10, 9],d = 2) == 7\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],d = 2) == 2\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],d = 4) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1],d = 2) == 6\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9],d = 3) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],d = 4) == 5\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],d = 3) == 8\n assert candidate(arr = [8, 7, 6, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 7, 8],d = 3) == 5\n assert candidate(arr = [3, 5, 1, 2, 4, 6, 8, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 4) == 18\n assert candidate(arr = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10],d = 4) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 10\n assert candidate(arr = [1, 5, 5, 5, 1, 5, 5, 5, 1],d = 2) == 2\n assert candidate(arr = [2, 1, 5, 3, 4, 8, 6, 7, 10, 9],d = 3) == 5\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5],d = 5) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 10\n assert candidate(arr = [8, 3, 5, 2, 4, 7, 6, 1, 10, 9],d = 5) == 5\n assert candidate(arr = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10],d = 3) == 10\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],d = 2) == 2\n assert candidate(arr = [50, 40, 30, 20, 10, 1, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1],d = 5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 5) == 20\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 3) == 10\n"}, "metadata": {"canonical_parameter_names": ["arr", "d"], "leetcode_dataset_entry_point": "Solution().maxJumps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxJumps(self, arr: list[int], d: int) -> int:", "container": "Solution", "callable": "maxJumps", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "d", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1342, "task_id": "number-of-steps-to-reduce-a-number-to-zero", "difficulty": "Easy", "problem_description": "Given an integer num, return the number of steps to reduce it to zero.\nIn one step, if the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it.\n��\nExample 1:\n\nInput: num = 14\nOutput: 6\nExplanation: \nStep 1) 14 is even; divide by 2 and obtain 7. \nStep 2) 7 is odd; subtract 1 and obtain 6.\nStep 3) 6 is even; divide by 2 and obtain 3. \nStep 4) 3 is odd; subtract 1 and obtain 2. \nStep 5) 2 is even; divide by 2 and obtain 1. \nStep 6) 1 is odd; subtract 1 and obtain 0.\n\nExample 2:\n\nInput: num = 8\nOutput: 4\nExplanation: \nStep 1) 8 is even; divide by 2 and obtain 4. \nStep 2) 4 is even; divide by 2 and obtain 2. \nStep 3) 2 is even; divide by 2 and obtain 1. \nStep 4) 1 is odd; subtract 1 and obtain 0.\n\nExample 3:\n\nInput: num = 123\nOutput: 12\n\n \nConstraints:\n\n0 <= num <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 14) == 6\n assert candidate(num = 1000000) == 26\n assert candidate(num = 8) == 4\n assert candidate(num = 65535) == 31\n assert candidate(num = 0) == 0\n assert candidate(num = 2) == 2\n assert candidate(num = 1) == 1\n assert candidate(num = 123) == 12\n assert candidate(num = 8191) == 25\n assert candidate(num = 750000) == 29\n assert candidate(num = 500000) == 25\n assert candidate(num = 1234567) == 31\n assert candidate(num = 131072) == 18\n assert candidate(num = 1023) == 19\n assert candidate(num = 777777) == 31\n assert candidate(num = 127) == 13\n assert candidate(num = 888888) == 27\n assert candidate(num = 16384) == 15\n assert candidate(num = 31) == 9\n assert candidate(num = 100001) == 23\n assert candidate(num = 1048575) == 39\n assert candidate(num = 8192) == 14\n assert candidate(num = 123456789) == 42\n assert candidate(num = 15) == 7\n assert candidate(num = 135792468) == 36\n assert candidate(num = 32768) == 16\n assert candidate(num = 63) == 11\n assert candidate(num = 3125) == 17\n assert candidate(num = 5318008) == 32\n assert candidate(num = 1000002) == 27\n assert candidate(num = 2097151) == 41\n assert candidate(num = 131071) == 33\n assert candidate(num = 16383) == 27\n assert candidate(num = 665772) == 27\n assert candidate(num = 987654321) == 46\n assert candidate(num = 4096) == 13\n assert candidate(num = 511) == 17\n assert candidate(num = 524288) == 20\n assert candidate(num = 7) == 5\n assert candidate(num = 543210) == 28\n assert candidate(num = 1048576) == 21\n assert candidate(num = 567890) == 27\n assert candidate(num = 255) == 15\n assert candidate(num = 8675309) == 37\n assert candidate(num = 1024) == 11\n assert candidate(num = 246813579) == 42\n assert candidate(num = 100000) == 22\n assert candidate(num = 54321) == 22\n assert candidate(num = 262143) == 35\n assert candidate(num = 123456) == 22\n assert candidate(num = 999999) == 31\n assert candidate(num = 32767) == 29\n assert candidate(num = 65536) == 17\n assert candidate(num = 2048) == 12\n assert candidate(num = 1000001) == 27\n assert candidate(num = 536870911) == 57\n assert candidate(num = 2147483647) == 61\n assert candidate(num = 3) == 3\n assert candidate(num = 987654) == 27\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().numberOfSteps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numberOfSteps(self, num: int) -> int:", "container": "Solution", "callable": "numberOfSteps", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1343, "task_id": "number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold", "difficulty": "Medium", "problem_description": "Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.\n \nExample 1:\n\nInput: arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4\nOutput: 3\nExplanation: Sub-arrays [2,5,5],[5,5,5] and [5,5,8] have averages 4, 5 and 6 respectively. All other sub-arrays of size 3 have averages less than 4 (the threshold).\n\nExample 2:\n\nInput: arr = [11,13,17,23,29,31,7,5,2,3], k = 3, threshold = 5\nOutput: 6\nExplanation: The first 6 sub-arrays of size 3 have averages greater than 5. Note that averages are not integers.\n\n \nConstraints:\n\n1 <= arr.length <= 105\n1 <= arr[i] <= 104\n1 <= k <= arr.length\n0 <= threshold <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 2, 2, 2, 5, 5, 5, 8],k = 3,threshold = 4) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5],k = 3,threshold = 5) == 5\n assert candidate(arr = [10000, 10000, 10000],k = 3,threshold = 10000) == 1\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2,threshold = 3) == 2\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000],k = 1,threshold = 10000) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1],k = 2,threshold = 1) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4,threshold = 5) == 4\n assert candidate(arr = [10, 20, 30, 40, 50],k = 1,threshold = 10) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,threshold = 1) == 6\n assert candidate(arr = [5, 5, 5, 5, 5],k = 5,threshold = 5) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5],k = 4,threshold = 6) == 0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5],k = 5,threshold = 5) == 4\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 3\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000],k = 5,threshold = 10000) == 1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3],k = 4,threshold = 3) == 4\n assert candidate(arr = [1, 1, 1, 1, 1],k = 2,threshold = 1) == 4\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2,threshold = 2) == 3\n assert candidate(arr = [11, 13, 17, 23, 29, 31, 7, 5, 2, 3],k = 3,threshold = 5) == 6\n assert candidate(arr = [10, 20, 30, 40, 50],k = 4,threshold = 25) == 2\n assert candidate(arr = [9, 7, 3, 5, 6, 2, 0, 8, 1, 4],k = 4,threshold = 4) == 4\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11,threshold = 5.5) == 0\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 6,threshold = 15) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10,threshold = 13) == 8\n assert candidate(arr = [1, 3, 2, 6, 5, 4, 8, 7, 9, 10],k = 3,threshold = 6) == 3\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 7,threshold = 7) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,threshold = 10.5) == 6\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2,threshold = 55) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5) == 4\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 3,threshold = 3) == 6\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6,threshold = 10) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 6,threshold = 10) == 8\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5,threshold = 5) == 9\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 20,threshold = 9) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10,threshold = 5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7,threshold = 10) == 8\n assert candidate(arr = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],k = 6,threshold = 3) == 8\n assert candidate(arr = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],k = 10,threshold = 25) == 6\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 20,threshold = 5000) == 1\n assert candidate(arr = [3, 6, 1, 3, 9, 6, 1, 7, 8, 2],k = 3,threshold = 5) == 4\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5,threshold = 5) == 9\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 10,threshold = 3) == 11\n assert candidate(arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 15,threshold = 50) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19,threshold = 1) == 2\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 11,threshold = 800) == 3\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5,threshold = 5) == 4\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 7,threshold = 5000) == 6\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 10,threshold = 5000) == 6\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 3,threshold = 10) == 15\n assert candidate(arr = [5000, 4000, 3000, 2000, 1000, 0, 0, 0, 0, 0, 0, 0],k = 5,threshold = 2000) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 1) == 11\n assert candidate(arr = [4999, 5000, 4999, 5000, 4999, 5000, 4999, 5000, 4999, 5000],k = 3,threshold = 5000) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5.5) == 3\n assert candidate(arr = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1],k = 5,threshold = 5000) == 3\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 5,threshold = 1.5) == 8\n assert candidate(arr = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 3,threshold = 10) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2,threshold = 5) == 5\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 3,threshold = 8) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5) == 11\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10,threshold = 55) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 7,threshold = 15) == 5\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 10,threshold = 10000) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 5,threshold = 12) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,threshold = 10) == 6\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85],k = 7,threshold = 92) == 5\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4,threshold = 3.5) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5,threshold = 20) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5,threshold = 15) == 11\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3,threshold = 55) == 4\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 8,threshold = 9000) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 6,threshold = 10) == 8\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5,threshold = 550) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7,threshold = 1) == 9\n assert candidate(arr = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6,threshold = 4) == 9\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 3,threshold = 2) == 18\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 5,threshold = 5000) == 6\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10,threshold = 10.5) == 6\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5,threshold = 4) == 11\n assert candidate(arr = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1],k = 2,threshold = 5000) == 9\n assert candidate(arr = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],k = 7,threshold = 15) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 1) == 73\n assert candidate(arr = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 6,threshold = 5) == 9\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 1) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5,threshold = 10) == 9\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 7,threshold = 15) == 5\n assert candidate(arr = [40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2],k = 10,threshold = 15) == 9\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 5,threshold = 15) == 6\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 3,threshold = 4) == 5\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],k = 4,threshold = 2) == 18\n assert candidate(arr = [1, 1, 1, 1, 10, 1, 1, 1, 1, 10, 1, 1, 1, 1, 10],k = 3,threshold = 3) == 7\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 6,threshold = 55) == 3\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4,threshold = 5) == 7\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 4\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4,threshold = 55) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5,threshold = 450) == 4\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 3,threshold = 15) == 12\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 4\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 6,threshold = 10) == 3\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 6,threshold = 500) == 3\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 9,threshold = 9999) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10,threshold = 8) == 3\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 4,threshold = 15) == 4\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 8,threshold = 100) == 9\n assert candidate(arr = [5000, 4000, 3000, 2000, 1000, 0, 1000, 2000, 3000, 4000, 5000],k = 4,threshold = 3000) == 2\n assert candidate(arr = [3, 5, 1, 8, 7, 9, 4, 6, 2, 10, 11, 12],k = 5,threshold = 6) == 5\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2,threshold = 500) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 0.5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 6) == 3\n"}, "metadata": {"canonical_parameter_names": ["arr", "k", "threshold"], "leetcode_dataset_entry_point": "Solution().numOfSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numOfSubarrays(self, arr: list[int], k: int, threshold: int) -> int:", "container": "Solution", "callable": "numOfSubarrays", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "k", "type": "int"}, {"name": "threshold", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1344, "task_id": "angle-between-hands-of-a-clock", "difficulty": "Medium", "problem_description": "Given two numbers, hour and minutes, return the smaller angle (in degrees) formed between the hour and the minute hand.\nAnswers within 10-5 of the actual value will be accepted as correct.\n \nExample 1:\n\n\nInput: hour = 12, minutes = 30\nOutput: 165\n\nExample 2:\n\n\nInput: hour = 3, minutes = 30\nOutput: 75\n\nExample 3:\n\n\nInput: hour = 3, minutes = 15\nOutput: 7.5\n\n \nConstraints:\n\n1 <= hour <= 12\n0 <= minutes <= 59\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(hour = 3,minutes = 30) == 75.0\n assert candidate(hour = 11,minutes = 59) == 5.5\n assert candidate(hour = 3,minutes = 15) == 7.5\n assert candidate(hour = 7,minutes = 30) == 45.0\n assert candidate(hour = 11,minutes = 0) == 30.0\n assert candidate(hour = 2,minutes = 10) == 5.0\n assert candidate(hour = 12,minutes = 30) == 165.0\n assert candidate(hour = 1,minutes = 0) == 30.0\n assert candidate(hour = 1,minutes = 55) == 87.5\n assert candidate(hour = 9,minutes = 45) == 22.5\n assert candidate(hour = 1,minutes = 5) == 2.5\n assert candidate(hour = 12,minutes = 0) == 0.0\n assert candidate(hour = 6,minutes = 0) == 180.0\n assert candidate(hour = 7,minutes = 10) == 155.0\n assert candidate(hour = 7,minutes = 35) == 17.5\n assert candidate(hour = 2,minutes = 5) == 32.5\n assert candidate(hour = 6,minutes = 15) == 97.5\n assert candidate(hour = 5,minutes = 0) == 150.0\n assert candidate(hour = 2,minutes = 47) == 161.5\n assert candidate(hour = 4,minutes = 0) == 120.0\n assert candidate(hour = 10,minutes = 25) == 162.5\n assert candidate(hour = 8,minutes = 23) == 113.5\n assert candidate(hour = 11,minutes = 15) == 112.5\n assert candidate(hour = 4,minutes = 50) == 155.0\n assert candidate(hour = 8,minutes = 18) == 141.0\n assert candidate(hour = 8,minutes = 20) == 130.0\n assert candidate(hour = 10,minutes = 31) == 129.5\n assert candidate(hour = 5,minutes = 10) == 95.0\n assert candidate(hour = 12,minutes = 15) == 82.5\n assert candidate(hour = 5,minutes = 14) == 73.0\n assert candidate(hour = 5,minutes = 45) == 97.5\n assert candidate(hour = 12,minutes = 59) == 35.5\n assert candidate(hour = 12,minutes = 1) == 5.5\n assert candidate(hour = 10,minutes = 10) == 115.0\n assert candidate(hour = 7,minutes = 22) == 89.0\n assert candidate(hour = 12,minutes = 47) == 101.5\n assert candidate(hour = 2,minutes = 40) == 160.0\n assert candidate(hour = 5,minutes = 55) == 152.5\n assert candidate(hour = 7,minutes = 0) == 150.0\n assert candidate(hour = 4,minutes = 48) == 144.0\n assert candidate(hour = 6,minutes = 37) == 23.5\n assert candidate(hour = 2,minutes = 24) == 72.0\n assert candidate(hour = 8,minutes = 40) == 20.0\n assert candidate(hour = 5,minutes = 15) == 67.5\n assert candidate(hour = 4,minutes = 10) == 65.0\n assert candidate(hour = 8,minutes = 50) == 35.0\n assert candidate(hour = 4,minutes = 40) == 100.0\n assert candidate(hour = 4,minutes = 25) == 17.5\n assert candidate(hour = 1,minutes = 37) == 173.5\n assert candidate(hour = 3,minutes = 47) == 168.5\n assert candidate(hour = 10,minutes = 48) == 36.0\n assert candidate(hour = 8,minutes = 32) == 64.0\n assert candidate(hour = 1,minutes = 10) == 25.0\n assert candidate(hour = 7,minutes = 5) == 177.5\n assert candidate(hour = 6,minutes = 30) == 15.0\n assert candidate(hour = 7,minutes = 59) == 114.5\n assert candidate(hour = 8,minutes = 28) == 86.0\n assert candidate(hour = 9,minutes = 27) == 121.5\n assert candidate(hour = 4,minutes = 55) == 177.5\n assert candidate(hour = 10,minutes = 35) == 107.5\n assert candidate(hour = 7,minutes = 32) == 34.0\n assert candidate(hour = 6,minutes = 33) == 1.5\n assert candidate(hour = 10,minutes = 20) == 170.0\n assert candidate(hour = 1,minutes = 50) == 115.0\n assert candidate(hour = 5,minutes = 37) == 53.5\n assert candidate(hour = 5,minutes = 47) == 108.5\n assert candidate(hour = 11,minutes = 5) == 57.5\n assert candidate(hour = 2,minutes = 30) == 105.0\n assert candidate(hour = 2,minutes = 20) == 50.0\n assert candidate(hour = 12,minutes = 45) == 112.5\n assert candidate(hour = 8,minutes = 0) == 120.0\n assert candidate(hour = 7,minutes = 47) == 48.5\n"}, "metadata": {"canonical_parameter_names": ["hour", "minutes"], "leetcode_dataset_entry_point": "Solution().angleClock", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def angleClock(self, hour: int, minutes: int) -> float:", "container": "Solution", "callable": "angleClock", "parameters": [{"name": "hour", "type": "int"}, {"name": "minutes", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1345, "task_id": "jump-game-iv", "difficulty": "Hard", "problem_description": "Given an array of integers arr, you are initially positioned at the first index of the array.\nIn one step you can jump from index i to index:\n\ni + 1 where: i + 1 < arr.length.\ni - 1 where: i - 1 >= 0.\nj where: arr[i] == arr[j] and i != j.\n\nReturn the minimum number of steps to reach the last index of the array.\nNotice that you can not jump outside of the array at any time.\n \nExample 1:\n\nInput: arr = [100,-23,-23,404,100,23,23,23,3,404]\nOutput: 3\nExplanation: You need three jumps from index 0 --> 4 --> 3 --> 9. Note that index 9 is the last index of the array.\n\nExample 2:\n\nInput: arr = [7]\nOutput: 0\nExplanation: Start index is the last index. You do not need to jump.\n\nExample 3:\n\nInput: arr = [7,6,9,6,9,6,9,7]\nOutput: 1\nExplanation: You can jump directly from index 0 to index 7 which is last index of the array.\n\n \nConstraints:\n\n1 <= arr.length <= 5 * 104\n-108 <= arr[i] <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [11, 22, 7, 7, 7, 7, 7, 7, 7, 22, 13]) == 3\n assert candidate(arr = [6, 1, 9, 6, 9, 1, 9, 6, 1, 9]) == 3\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 11, 11, 11, 11, 11, 11]) == 3\n assert candidate(arr = [7, 6, 9, 6, 9, 6, 9, 7]) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 1\n assert candidate(arr = [1, 2, 3, 5, 3, 2, 1, 2, 3, 4]) == 4\n assert candidate(arr = [7]) == 0\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(arr = [100, -23, -23, 404, 100, 23, 23, 23, 3, 404]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 9\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 4\n assert candidate(arr = [7, 7, 7, 7, 11, 11, 11, 11, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1]) == 1\n assert candidate(arr = [7, 7, 7, 7, 12, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [10, 20, 30, 20, 10, 10, 20, 30, 10]) == 1\n assert candidate(arr = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 3\n assert candidate(arr = [6, 1, 9, 8, 4, 10, 9, 4, 10, 4, 10, 9, 10, 9, 8, 10, 9, 4, 10, 9, 10, 9, 8, 10, 9, 4, 10, 9]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [10, 22, 10, 20, 11, 22, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100, 10, 110, 10, 120, 10, 130, 10, 140, 10, 150, 10, 160, 10, 170, 10, 180, 10, 190, 10, 200]) == 2\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(arr = [1, 3, 5, 3, 1, 2, 4, 2, 6, 4, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19]) == 37\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().minJumps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minJumps(self, arr: list[int]) -> int:", "container": "Solution", "callable": "minJumps", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1346, "task_id": "check-if-n-and-its-double-exist", "difficulty": "Easy", "problem_description": "Given an array arr of integers, check if there exist two indices i and j such that :\n\ni != j\n0 <= i, j < arr.length\narr[i] == 2 * arr[j]\n\n \nExample 1:\n\nInput: arr = [10,2,5,3]\nOutput: true\nExplanation: For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j]\n\nExample 2:\n\nInput: arr = [3,1,7,11]\nOutput: false\nExplanation: There is no i and j that satisfy the conditions.\n\n \nConstraints:\n\n2 <= arr.length <= 500\n-103 <= arr[i] <= 103\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 4, 6, 8, 10]) == True\n assert candidate(arr = [6, 10, 1, 0, -3, 3]) == True\n assert candidate(arr = [-3, -6, -1, 0, 1, 2, 3]) == True\n assert candidate(arr = [-2, -4, -6, -8, -10]) == True\n assert candidate(arr = [100, 200, 300, 400, 500]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64]) == True\n assert candidate(arr = [-10, -20, -5, -3]) == True\n assert candidate(arr = [1, 2, 3, 6, 12]) == True\n assert candidate(arr = [0, 0]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(arr = [-10, 10]) == False\n assert candidate(arr = [10, 2, 5, 3]) == True\n assert candidate(arr = [1, 2, 3, 4, 5]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(arr = [1, 2, 4, 8, 16]) == True\n assert candidate(arr = [-2, 0, 10, -19, 4, 6, -8]) == False\n assert candidate(arr = [1, 3, 5, 7, 9]) == False\n assert candidate(arr = [3, 1, 7, 11]) == False\n assert candidate(arr = [-10, -20, -30, -40, -50]) == True\n assert candidate(arr = [-10, -5, -3, -1, 2]) == True\n assert candidate(arr = [10, 5, 15, 20, 25]) == True\n assert candidate(arr = [1, -1, 2, -2, 4, -4, 8, -8, 16, -16]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8]) == True\n assert candidate(arr = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == True\n assert candidate(arr = [2, 1, 4, 2, 8, 4, 16]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 20, 40]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == True\n assert candidate(arr = [-100, -50, -25, -12, -6, -3, -1, 0, 1, 2, 4]) == True\n assert candidate(arr = [4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -10, -20]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == True\n assert candidate(arr = [0, 0, 0, 0]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1]) == True\n assert candidate(arr = [101, 202, 50, 25, 12, 6, 3]) == True\n assert candidate(arr = [1000, 501, 250, 125, 62, 31, 15, 7, 3, 1]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 60]) == True\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == False\n assert candidate(arr = [100, 50, 25, 125, 625, 3125]) == True\n assert candidate(arr = [-1, 2, -3, 6, -4, 8]) == False\n assert candidate(arr = [-10, -20, 5, 3, 15]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 250, 125]) == True\n assert candidate(arr = [-1, -2, -3, -6, -12]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(arr = [100, 50, 25, 12.5, 6.25, 3.125, 1.5625]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200]) == True\n assert candidate(arr = [3, 6, 9, 18, 27, 54, 81]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56]) == True\n assert candidate(arr = [1, 2, 3, 6, 9, 18, 36, 72]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5]) == True\n assert candidate(arr = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == True\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 50, 100]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96, 192, 384]) == True\n assert candidate(arr = [-1, -2, -4, -8, -16]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == True\n assert candidate(arr = [0, 0, 1, 2, 4]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 220, 330, 440, 550, 660, 770, 880, 990, 1100]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 38]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 15, 20, 30, 60]) == True\n assert candidate(arr = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6]) == True\n assert candidate(arr = [-2, 2, -4, 4, -8, 8, -16, 16]) == True\n assert candidate(arr = [-10, -5, -15, -20, -25]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == True\n assert candidate(arr = [-1, 1, -2, 2, -4, 4, 8, -8]) == True\n assert candidate(arr = [0, 1, 2, 3, 6, 12, 24, 48, 96]) == True\n assert candidate(arr = [13, 26, 52, 104, 208, 416]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [-5, 10, -15, 20, -25, 50, -75]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 50, 75]) == True\n assert candidate(arr = [21, 42, 84, 168, 336, 672, 1344]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == True\n assert candidate(arr = [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560]) == True\n assert candidate(arr = [6, 12, 18, 24, 48]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0, 16, 0]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40]) == True\n assert candidate(arr = [1000, -500, 250, -125, 62.5, 31.25]) == True\n assert candidate(arr = [-1, 2, -2, 4, -4, 8]) == True\n assert candidate(arr = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(arr = [1, 5, 25, 125, 625, 3125, 15625, 78125]) == False\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8]) == True\n assert candidate(arr = [15, 30, 45, 90, 135, 270]) == True\n assert candidate(arr = [-10, -5, -1, -2, -3, -4, -6, -8, -12, -16]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 1000, 2000]) == True\n assert candidate(arr = [10, 20, 40, 80, 160, 320, 640]) == True\n assert candidate(arr = [-10, -5, 0, 5, 10]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -100, -200, -300]) == True\n assert candidate(arr = [-3, -6, -9, -12, -15, -18, -21, -24]) == True\n assert candidate(arr = [3, 6, 12, 24, 48, 96, 192, 384]) == True\n assert candidate(arr = [0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(arr = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25, -30, -35, -40, -45]) == True\n assert candidate(arr = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == False\n assert candidate(arr = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 10]) == True\n assert candidate(arr = [11, 22, 44, 88, 176, 352, 704]) == True\n assert candidate(arr = [0, 0, 0, 0, 0]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24]) == True\n assert candidate(arr = [100, 51, 25, 12, 6, 3, 1]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 17, 19, 21]) == False\n assert candidate(arr = [0, 1, 2, 4, 8, 16, 32]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 3, 9, 27, 81, 243, 729]) == False\n assert candidate(arr = [0, 1, 2, 3, 4, 8, 16]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 50, 100]) == True\n assert candidate(arr = [9, 18, 36, 72, 144, 288, 576]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 18, 36, 72]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224, 448]) == True\n assert candidate(arr = [1000, 500, 250, 125, 62.5]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96, 192, 384, 768]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1, 0]) == True\n assert candidate(arr = [1, 5, 10, 20, 25, 50, 100]) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(arr = [-2, -4, -6, -8, -16]) == True\n assert candidate(arr = [-10, -20, -30, -200, -300, -150]) == True\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == True\n assert candidate(arr = [0, 1, 2, 4, 8, 16, 32, 64]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 15, 20, 30, 60, 120, 240]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1, 0, -1, -2, -4]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224]) == True\n assert candidate(arr = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224, 448, 896]) == True\n assert candidate(arr = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 115]) == True\n assert candidate(arr = [10, 5, 15, 20, 2, 25, 50]) == True\n assert candidate(arr = [-2, -4, -1, -3, -5, -10]) == True\n assert candidate(arr = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == True\n assert candidate(arr = [-1, -2, -4, -8, -16, -32, -64]) == True\n assert candidate(arr = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32]) == True\n assert candidate(arr = [1, 2, 3, 6, 9, 18, 27, 54]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0, 16, 0, 32, 0, 64, 0, 128, 0]) == True\n assert candidate(arr = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == True\n assert candidate(arr = [-2, -4, -8, -16, -32, -64, -128]) == True\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().checkIfExist", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def checkIfExist(self, arr: list[int]) -> bool:", "container": "Solution", "callable": "checkIfExist", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1347, "task_id": "minimum-number-of-steps-to-make-two-strings-anagram", "difficulty": "Medium", "problem_description": "You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character.\nReturn the minimum number of steps to make t an anagram of s.\nAn Anagram of a string is a string that contains the same characters with a different (or the same) ordering.\n \nExample 1:\n\nInput: s = \"bab\", t = \"aba\"\nOutput: 1\nExplanation: Replace the first 'a' in t with b, t = \"bba\" which is anagram of s.\n\nExample 2:\n\nInput: s = \"leetcode\", t = \"practice\"\nOutput: 5\nExplanation: Replace 'p', 'r', 'a', 'i' and 'c' from t with proper characters to make t anagram of s.\n\nExample 3:\n\nInput: s = \"anagram\", t = \"mangaar\"\nOutput: 0\nExplanation: \"anagram\" and \"mangaar\" are anagrams. \n\n \nConstraints:\n\n1 <= s.length <= 5 * 104\ns.length == t.length\ns and t consist of lowercase English letters only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abacabadabacaba\",t = \"abcadbabacabaab\") == 1\n assert candidate(s = \"transform\",t = \"formartin\") == 1\n assert candidate(s = \"hello\",t = \"billion\") == 4\n assert candidate(s = \"aabbcc\",t = \"ccbbaa\") == 0\n assert candidate(s = \"minimum\",t = \"numinum\") == 2\n assert candidate(s = \"hello\",t = \"bello\") == 1\n assert candidate(s = \"leetcode\",t = \"practice\") == 5\n assert candidate(s = \"aaabbb\",t = \"bbbaaa\") == 0\n assert candidate(s = \"transform\",t = \"formtrans\") == 0\n assert candidate(s = \"anagram\",t = \"mangaar\") == 0\n assert candidate(s = \"abcd\",t = \"dcba\") == 0\n assert candidate(s = \"transform\",t = \"formant\") == 0\n assert candidate(s = \"bab\",t = \"aba\") == 1\n assert candidate(s = \"aaa\",t = \"bbb\") == 3\n assert candidate(s = \"abc\",t = \"def\") == 3\n assert candidate(s = \"abcde\",t = \"edcba\") == 0\n assert candidate(s = \"xyz\",t = \"zyx\") == 0\n assert candidate(s = \"antidisestablishmentarianism\",t = \"staimnariesmedtahilbesdisantii\") == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxwwvvuuttrrssqqppoonnmmllkkjjiihhggffeeeeddccbbaa\") == 2\n assert candidate(s = \"optimization\",t = \"inipotizaton\") == 1\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",t = \"sinsivocnoclaocivlospercimicroscopoultraomneupnc\") == 5\n assert candidate(s = \"thisisaverylongstringthatwearetesting\",t = \"testingaverylongstringthatwesarethis\") == 0\n assert candidate(s = \"pythonprogramming\",t = \"gnimmargorpnohtyp\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxwwvvuuttrrssqqppoonnmmllkkjjiihhggeeffddccbbaa\") == 0\n assert candidate(s = \"floccinaucinihilipilification\",t = \"nicihilopilicifinaucinnilociflloa\") == 5\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",t = \"abcdefghijklmnopqrstuvwzyx\") == 0\n assert candidate(s = \"mississippi\",t = \"ppissimissim\") == 1\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\",t = \"aquickbrownfoxjumpsoverthelazydog\") == 0\n assert candidate(s = \"aaaaabbbbccccddddd\",t = \"dddddaaaaabbbcccc\") == 0\n assert candidate(s = \"bbaacc\",t = \"aabacc\") == 1\n assert candidate(s = \"aabbccddeeff\",t = \"fedcbafedcba\") == 0\n assert candidate(s = \"xylophone\",t = \"poloxynhe\") == 0\n assert candidate(s = \"almostthere\",t = \"lmostahere\") == 0\n assert candidate(s = \"abcdabcdabcd\",t = \"ddddccccbbbaaa\") == 2\n assert candidate(s = \"strength\",t = \"grenstht\") == 0\n assert candidate(s = \"pythonprogramming\",t = \"prognimmargyphnot\") == 0\n assert candidate(s = \"algorithms\",t = \"logarithms\") == 0\n assert candidate(s = \"pythonprogramming\",t = \"programmingpython\") == 0\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"pseudopseudohypoparathyroidism\") == 11\n assert candidate(s = \"characterization\",t = \"carricahztinoe\") == 0\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",t = \"doglazythequickbrownfoxjumpsoverthelazy\") == 4\n assert candidate(s = \"longestword\",t = \"wordlongset\") == 0\n assert candidate(s = \"photosynthesis\",t = \"synthesphotosis\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttrrssqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 0\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"ecilafragisticexpialidocuosspr\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeeeddccbbaa\") == 2\n assert candidate(s = \"onomatopoeia\",t = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == 33\n assert candidate(s = \"mississippi\",t = \"ppissimisss\") == 1\n assert candidate(s = \"mississippi\",t = \"pississippi\") == 1\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\") == 0\n assert candidate(s = \"abracadabra\",t = \"arabracadab\") == 0\n assert candidate(s = \"permutations\",t = \"interpromust\") == 1\n assert candidate(s = \"aabbcceeddffee\",t = \"eeddffccbbbaaa\") == 2\n assert candidate(s = \"programmingisfun\",t = \"funprogrammingis\") == 0\n assert candidate(s = \"abracadabra\",t = \"occipital\") == 7\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 0\n assert candidate(s = \"aabbccddeeff\",t = \"zzzzyyxxwwvvuutt\") == 16\n assert candidate(s = \"elephant\",t = \"tehlanpe\") == 0\n assert candidate(s = \"elephant\",t = \"talehpen\") == 0\n assert candidate(s = \"permutations\",t = \"pertumations\") == 0\n assert candidate(s = \"synchronized\",t = \"chronizedsyn\") == 0\n assert candidate(s = \"elevenletters\",t = \"twelvethletters\") == 4\n assert candidate(s = \"thisisaverylongstring\",t = \"stringlongaverythisis\") == 0\n assert candidate(s = \"interstellar\",t = \"stellarestri\") == 1\n assert candidate(s = \"mississippi\",t = \"pisissmipis\") == 0\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"ciousiliexpalodicisgratefulsuper\") == 2\n assert candidate(s = \"xylophone\",t = \"polyphonex\") == 1\n assert candidate(s = \"elephant\",t = \"telephone\") == 2\n assert candidate(s = \"mississippi\",t = \"psissimippi\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"abcdefghijklmnopqrstuvwxyzzzyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"mississippi\",t = \"pissimissi\") == 0\n assert candidate(s = \"amazingrace\",t = \"raceingazam\") == 0\n assert candidate(s = \"mississippi\",t = \"pississimissm\") == 3\n assert candidate(s = \"algorithm\",t = \"logarithmxx\") == 2\n assert candidate(s = \"reducibility\",t = \"reducibility\") == 0\n assert candidate(s = \"recharacterization\",t = \"characterizationre\") == 0\n assert candidate(s = \"programming\",t = \"gimmnoprram\") == 1\n assert candidate(s = \"frequencydistribution\",t = \"charactercount\") == 5\n assert candidate(s = \"thecommunistmanifesto\",t = \"theCommunistManifesto\") == 2\n assert candidate(s = \"characterization\",t = \"intercharacterization\") == 5\n assert candidate(s = \"aaaaabbbbcccccdddddeeeee\",t = \"eeeeeaaaaabbbbbcccccddddd\") == 1\n assert candidate(s = \"xylophone\",t = \"polyphonicx\") == 3\n assert candidate(s = \"thisisaverylongstringwithvariouscharacters\",t = \"thisisanotherlongstringwithdifferentcharacters\") == 10\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"ecilapersixfulicadogstcilxpiaiodisu\") == 2\n assert candidate(s = \"characterization\",t = \"charizmatation\") == 1\n assert candidate(s = \"programming\",t = \"remmprogain\") == 1\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"pronunciationdictionary\") == 7\n assert candidate(s = \"multimedia\",t = \"meediamult\") == 1\n assert candidate(s = \"xylophone\",t = \"phonexylo\") == 0\n assert candidate(s = \"mississippi\",t = \"ssissippiim\") == 0\n assert candidate(s = \"development\",t = \"elopmentd\") == 0\n assert candidate(s = \"interviewquestion\",t = \"questioverntein\") == 0\n assert candidate(s = \"anagramanagram\",t = \"mangaarmangaar\") == 0\n assert candidate(s = \"congratulations\",t = \"congratulations\") == 0\n assert candidate(s = \"programming\",t = \"pgmromanig\") == 0\n assert candidate(s = \"thequickbrownfox\",t = \"quickbrownfoxt\") == 0\n assert candidate(s = \"algorithm\",t = \"logarithm\") == 0\n assert candidate(s = \"racecar\",t = \"carrace\") == 0\n assert candidate(s = \"congratulations\",t = \"gratulationscon\") == 0\n assert candidate(s = \"optimization\",t = \"tionsimipazy\") == 2\n assert candidate(s = \"rhythm\",t = \"myrthh\") == 0\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",t = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"aabbccddeeff\",t = \"ffeeddccbbaa\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"unitedstates\",t = \"statedinutes\") == 0\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"expialidocioussupercalifragilistic\") == 0\n assert candidate(s = \"unanimous\",t = \"manusiousun\") == 2\n assert candidate(s = \"abacabadabacabadabacabad\",t = \"bacdabcdabcdabcdabcdabcd\") == 6\n assert candidate(s = \"characterization\",t = \"recharacterization\") == 2\n assert candidate(s = \"abacaxi\",t = \"xicabaa\") == 0\n assert candidate(s = \"programming\",t = \"gnimmargorp\") == 0\n assert candidate(s = \"mississippi\",t = \"ppiimississ\") == 0\n"}, "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().minSteps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minSteps(self, s: str, t: str) -> int:", "container": "Solution", "callable": "minSteps", "parameters": [{"name": "s", "type": "str"}, {"name": "t", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1349, "task_id": "maximum-students-taking-exam", "difficulty": "Hard", "problem_description": "Given a m * n matrix seats  that represent seats distributions in a classroom. If a seat is broken, it is denoted by '#' character otherwise it is denoted by a '.' character.\nStudents can see the answers of those sitting next to the left, right, upper left and upper right, but he cannot see the answers of the student sitting directly in front or behind him. Return the maximum number of students that can take the exam together without any cheating being possible.\nStudents must be placed in seats in good condition.\n \nExample 1:\n\n\nInput: seats = [[\"#\",\".\",\"#\",\"#\",\".\",\"#\"],\n  [\".\",\"#\",\"#\",\"#\",\"#\",\".\"],\n  [\"#\",\".\",\"#\",\"#\",\".\",\"#\"]]\nOutput: 4\nExplanation: Teacher can place 4 students in available seats so they don't cheat on the exam. \n\nExample 2:\n\nInput: seats = [[\".\",\"#\"],\n  [\"#\",\"#\"],\n  [\"#\",\".\"],\n  [\"#\",\"#\"],\n  [\".\",\"#\"]]\nOutput: 3\nExplanation: Place all students in available seats. \n\n\nExample 3:\n\nInput: seats = [[\"#\",\".\",\".\",\".\",\"#\"],\n  [\".\",\"#\",\".\",\"#\",\".\"],\n  [\".\",\".\",\"#\",\".\",\".\"],\n  [\".\",\"#\",\".\",\"#\",\".\"],\n  [\"#\",\".\",\".\",\".\",\"#\"]]\nOutput: 10\nExplanation: Place students in available seats in column 1, 3 and 5.\n\n \nConstraints:\n\nseats contains only characters '.' and'#'.\nm == seats.length\nn == seats[i].length\n1 <= m <= 8\n1 <= n <= 8\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['#', '.', '#', '#', '.', '#'], ['.', '#', '#', '#', '#', '.'], ['#', '.', '#', '#', '.', '#']]) == 4\n assert candidate(seats = [['.', '.#'], ['#', '#'], ['#', '.'], ['#', '#'], ['.', '#']]) == 3\n assert candidate(seats = [['.', '#'], ['#', '#'], ['#', '.'], ['#', '#'], ['.', '#']]) == 3\n assert candidate(seats = [['#', '.', '#', '#', '.', '#'], ['.', '#', '#', '#', '#', '.'], ['#', '.', '#', '#', '.', '#']]) == 4\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['.', '#'], ['#', '#'], ['#', '.'], ['#', '#'], ['.', '#']]) == 3\n assert candidate(seats = [['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 23\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 15\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 32\n assert candidate(seats = [['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 31\n assert candidate(seats = [['.', '.', '#'], ['.', '#', '.'], ['#', '.', '.'], ['.', '.', '#'], ['.', '#', '.'], ['#', '.', '.']]) == 8\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['#', '.', '#', '.', '.', '#']]) == 16\n assert candidate(seats = [['.', '.', '.', '#'], ['.', '#', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '#', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#']]) == 15\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['#', '.', '.', '.', '#']]) == 9\n assert candidate(seats = [['#', '.', '#', '#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 30\n assert candidate(seats = [['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.']]) == 9\n assert candidate(seats = [['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#']]) == 9\n assert candidate(seats = [['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.']]) == 11\n assert candidate(seats = [['.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.']]) == 23\n assert candidate(seats = [['.', '#', '.', '.', '#', '.', '#'], ['#', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['#', '.', '.', '.', '.', '.', '#']]) == 16\n assert candidate(seats = [['.', '.', '#', '#', '.', '.', '#'], ['#', '.', '.', '.', '#', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '#']]) == 12\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 14\n assert candidate(seats = [['.', '#', '.', '#', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '.']]) == 15\n assert candidate(seats = [['.', '.', '.', '#', '.'], ['#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#'], ['.', '.', '.', '#', '.']]) == 9\n assert candidate(seats = [['.', '#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 24\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.']]) == 21\n assert candidate(seats = [['#', '.', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '.', '#'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['#', '.', '#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#', '.', '#']]) == 19\n assert candidate(seats = [['#', '.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '.', '#'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '.', '#', '.'], ['.', '#', '#', '.', '#', '.', '.', '#'], ['#', '.', '.', '#', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '#', '.', '#']]) == 20\n assert candidate(seats = [['#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.']]) == 12\n assert candidate(seats = [['#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#']]) == 0\n assert candidate(seats = [['.', '.', '#', '.', '#', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '.', '.', '#'], ['.', '.', '#', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.', '.', '.']]) == 23\n assert candidate(seats = [['.', '.', '#', '.', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.']]) == 16\n assert candidate(seats = [['.', '.', '#', '.', '.', '#'], ['.', '#', '.', '#', '.', '.'], ['#', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '.', '#'], ['#', '.', '#', '.', '.', '.'], ['.', '.', '.', '#', '.', '#']]) == 13\n assert candidate(seats = [['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 18\n assert candidate(seats = [['#', '#', '.', '#', '#', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 28\n assert candidate(seats = [['#', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['.', '.', '#', '#', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '#', '.']]) == 15\n assert candidate(seats = [['.', '.', '#', '#', '.', '.'], ['#', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['#', '.', '#', '.', '.', '#']]) == 14\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 22\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['#', '#', '.', '#', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '#', '#', '#', '.'], ['.', '.', '.', '.', '.', '.']]) == 13\n assert candidate(seats = [['#', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.', '#']]) == 28\n assert candidate(seats = [['.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 18\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.']]) == 28\n assert candidate(seats = [['.', '.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 32\n assert candidate(seats = [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]) == 15\n assert candidate(seats = [['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#']]) == 6\n assert candidate(seats = [['#', '.', '.', '.', '.', '#'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['#', '.', '.', '.', '.', '#']]) == 11\n assert candidate(seats = [['.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.']]) == 13\n assert candidate(seats = [['.', '#', '.', '.', '#', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.', '.', '.']]) == 24\n assert candidate(seats = [['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#']]) == 12\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 12\n assert candidate(seats = [['#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['#', '.', '#', '.', '.', '#']]) == 16\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '#', '.', '.', '.'], ['.', '.', '#', '.', '#', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.']]) == 24\n assert candidate(seats = [['.', '.', '.', '#', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 32\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#']]) == 9\n assert candidate(seats = [['.', '.', '.', '#'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.']]) == 11\n assert candidate(seats = [['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '#']]) == 29\n assert candidate(seats = [['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.']]) == 9\n assert candidate(seats = [['#', '.', '.', '#'], ['.', '.', '.', '.'], ['#', '.', '.', '#'], ['.', '.', '.', '.'], ['#', '.', '.', '#']]) == 7\n assert candidate(seats = [['#', '.', '.', '#', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 13\n assert candidate(seats = [['#', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '#']]) == 20\n assert candidate(seats = [['.', '#', '.', '.', '#', '.'], ['#', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '#', '.']]) == 12\n assert candidate(seats = [['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.']]) == 9\n assert candidate(seats = [['.', '.', '.', '.', '.', '#', '.'], ['#', '.', '#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '#'], ['.', '.', '.', '.', '.', '#', '.']]) == 15\n"}, "metadata": {"canonical_parameter_names": ["seats"], "leetcode_dataset_entry_point": "Solution().maxStudents", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxStudents(self, seats: list[list[str]]) -> int:", "container": "Solution", "callable": "maxStudents", "parameters": [{"name": "seats", "type": "list[list[str]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1351, "task_id": "count-negative-numbers-in-a-sorted-matrix", "difficulty": "Easy", "problem_description": "Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.\n \nExample 1:\n\nInput: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]\nOutput: 8\nExplanation: There are 8 negatives number in the matrix.\n\nExample 2:\n\nInput: grid = [[3,2],[1,0]]\nOutput: 0\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 100\n-100 <= grid[i][j] <= 100\n\n \nFollow up: Could you find an O(n + m) solution?", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[-1, -1], [-1, -1]]) == 4\n assert candidate(grid = [[-3], [-2], [-1], [0], [1]]) == 0\n assert candidate(grid = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == 12\n assert candidate(grid = [[-1, -1, -1], [-5, -5, -5]]) == 6\n assert candidate(grid = [[3, 2], [1, 0]]) == 0\n assert candidate(grid = [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3]]) == 8\n assert candidate(grid = [[1, -1], [-1, -1]]) == 3\n assert candidate(grid = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == 16\n assert candidate(grid = [[5, 2, 1], [4, 3, 1], [3, 2, 1]]) == 0\n assert candidate(grid = [[1, 2, 3], [4, 5, 6]]) == 0\n assert candidate(grid = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == 12\n assert candidate(grid = [[100, 90, 80, -10], [-9, -8, -7, -6], [-5, -4, -3, -2], [-4, -3, -2, -1]]) == 13\n assert candidate(grid = [[1]]) == 0\n assert candidate(grid = [[-5]]) == 1\n assert candidate(grid = [[1, 2, 3], [0, -1, -2], [-3, -4, -5]]) == 5\n assert candidate(grid = [[-1]]) == 1\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, 0, -1], [2, 1, 0, -1, -2], [1, 0, -1, -2, -3]]) == 6\n assert candidate(grid = [[-1, 0], [0, -1]]) == 1\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) == 0\n assert candidate(grid = [[-1, 2, -3, 4, -5], [6, -7, 8, -9, 10], [-11, 12, -13, 14, -15], [16, -17, 18, -19, 20]]) == 10\n assert candidate(grid = [[1, 0, 0, 0, 0], [-1, 0, 0, 0, 0], [-1, -1, 0, 0, 0], [-1, -1, -1, 0, 0], [-1, -1, -1, -1, 0]]) == 20\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, -1]]) == 1\n assert candidate(grid = [[50, 40, 30, 20, 10, 0, -10, -20], [-5, -10, -15, -20, -25, -30, -35, -40], [-50, -60, -70, -80, -90, -100, -110, -120]]) == 18\n assert candidate(grid = [[-100, -99, -98, -97, -96], [-95, -94, -93, -92, -91], [-90, -89, -88, -87, -86], [-85, -84, -83, -82, -81], [-80, -79, -78, -77, -76]]) == 25\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, -1], [7, 6, 5, 4, 3, 2, 1, 0, -1, -2], [6, 5, 4, 3, 2, 1, 0, -1, -2, -3], [5, 4, 3, 2, 1, 0, -1, -2, -3, -4], [4, 3, 2, 1, 0, -1, -2, -3, -4, -5], [3, 2, 1, 0, -1, -2, -3, -4, -5, -6], [2, 1, 0, -1, -2, -3, -4, -5, -6, -7], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8]]) == 36\n assert candidate(grid = [[-99, -98, -97, -96, -95, -94, -93, -92, -91, -90], [-89, -88, -87, -86, -85, -84, -83, -82, -81, -80], [-79, -78, -77, -76, -75, -74, -73, -72, -71, -70], [-69, -68, -67, -66, -65, -64, -63, -62, -61, -60], [-59, -58, -57, -56, -55, -54, -53, -52, -51, -50], [-49, -48, -47, -46, -45, -44, -43, -42, -41, -40], [-39, -38, -37, -36, -35, -34, -33, -32, -31, -30], [-29, -28, -27, -26, -25, -24, -23, -22, -21, -20], [-19, -18, -17, -16, -15, -14, -13, -12, -11, -10], [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0]]) == 100\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-2, -2, -2, -2, -2, -2, -2, -2, -2, -2], [-3, -3, -3, -3, -3, -3, -3, -3, -3, -3]]) == 30\n assert candidate(grid = [[1, 1, 1, -1, -1, -1], [1, 1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1]]) == 13\n assert candidate(grid = [[9, -9, 8, -8], [7, -7, 6, -6], [5, -5, 4, -4], [3, -3, 2, -2], [1, -1, 0, -1]]) == 15\n assert candidate(grid = [[99, 98, 97, 96, 95, 94], [93, 92, 91, 90, -1, -2], [-3, -4, -5, -6, -7, -8], [-9, -10, -11, -12, -13, -14]]) == 14\n assert candidate(grid = [[10, -10, 20, -20, 30, -30], [9, -9, 18, -18, 27, -27], [8, -8, 16, -16, 24, -24], [7, -7, 14, -14, 21, -21]]) == 20\n assert candidate(grid = [[0, 0, 0, 0, -1], [0, 0, -1, -1, -1], [0, -1, -1, -1, -1], [-1, -1, -1, -1, -1]]) == 13\n assert candidate(grid = [[-5, -4, -3, -2, -1], [0, 0, 0, 0, 0], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 20\n assert candidate(grid = [[1, 0, -1, 0, -1], [0, -1, 0, -1, 0], [-1, 0, -1, 0, -1], [0, -1, 0, -1, 0], [-1, 0, -1, 0, -1]]) == 15\n assert candidate(grid = [[-50, -40, -30, -20, -10], [30, 20, 10, 0, -10], [-20, -10, 0, 10, 20], [10, 0, 10, 20, 30], [0, 10, 20, 30, 40]]) == 0\n assert candidate(grid = [[90, 80, 70, 60, 50, 40, 30, 20, 10, 0], [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]]) == 10\n assert candidate(grid = [[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[-5, -4, -3, -2, -1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[-1, -1, -1, 0], [1, 0, -1, -1], [1, -1, -1, -1], [-1, -1, -1, -1]]) == 11\n assert candidate(grid = [[-3, -2, -1, 0], [2, 1, 0, -1], [1, 0, -1, -2], [0, -1, -2, -3]]) == 6\n assert candidate(grid = [[10, -5, 3, 2, -1], [-3, 0, -1, 0, -4], [-5, -6, -7, -8, -9]]) == 14\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, -1], [7, 6, 5, 4, 3, 2, 1, 0, -1, -2], [6, 5, 4, 3, 2, 1, 0, -1, -2, -3], [5, 4, 3, 2, 1, 0, -1, -2, -3, -4], [4, 3, 2, 1, 0, -1, -2, -3, -4, -5], [3, 2, 1, 0, -1, -2, -3, -4, -5, -6], [2, 1, 0, -1, -2, -3, -4, -5, -6, -7], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8]]) == 36\n assert candidate(grid = [[-100, -99, -98, -97, -96], [0, 0, 0, -1, -2], [-3, -4, -5, -6, -7], [-8, -9, -10, -11, -12]]) == 14\n assert candidate(grid = [[1, -1, -2, -3], [-1, -2, -3, -4], [-2, -3, -4, -5], [-3, -4, -5, -6]]) == 15\n assert candidate(grid = [[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], [-2, -3, -4, -5, -6, -7, -8, -9, -10, -11], [-3, -4, -5, -6, -7, -8, -9, -10, -11, -12]]) == 30\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, -1], [0, 0, 0, 0, 0, 0, 0, 0, -1, -1], [0, 0, 0, 0, 0, 0, 0, -1, -1, -1], [0, 0, 0, 0, 0, 0, -1, -1, -1, -1], [0, 0, 0, 0, 0, -1, -1, -1, -1, -1], [0, 0, 0, 0, -1, -1, -1, -1, -1, -1], [0, 0, 0, -1, -1, -1, -1, -1, -1, -1], [0, 0, -1, -1, -1, -1, -1, -1, -1, -1], [0, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 45\n assert candidate(grid = [[-1, 0, 1, 2, 3], [0, -1, -2, -3, -4], [-1, -2, -3, -4, -5], [-10, -20, -30, -40, -50]]) == 14\n assert candidate(grid = [[10, -10, 20, -20], [5, -5, 15, -15], [0, 0, 0, 0], [-1, -2, -3, -4]]) == 4\n assert candidate(grid = [[99, 98, 97, 96, 95, 94, 93, 92, 91, 90], [89, 88, 87, 86, 85, 84, 83, 82, 81, 80], [79, 78, 77, 76, 75, 74, 73, 72, 71, 70], [69, 68, 67, 66, 65, 64, 63, 62, 61, 60], [59, 58, 57, 56, 55, 54, 53, 52, 51, 50], [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], [-11, -12, -13, -14, -15, -16, -17, -18, -19, -20], [-21, -22, -23, -24, -25, -26, -27, -28, -29, -30], [-31, -32, -33, -34, -35, -36, -37, -38, -39, -40], [-41, -42, -43, -44, -45, -46, -47, -48, -49, -50]]) == 50\n assert candidate(grid = [[-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1]]) == 15\n assert candidate(grid = [[2, 1, 0, -1, -2], [1, 0, -1, -2, -3], [0, -1, -2, -3, -4], [-1, -2, -3, -4, -5], [-2, -3, -4, -5, -6]]) == 19\n assert candidate(grid = [[100, 90, 80, 70, 60, 50, 40, 30, 20, 10], [90, 80, 70, 60, 50, 40, 30, 20, 10, 0], [80, 70, 60, 50, 40, 30, 20, 10, 0, -10], [70, 60, 50, 40, 30, 20, 10, 0, -10, -20], [60, 50, 40, 30, 20, 10, 0, -10, -20, -30]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[-1, -2, -3, -4], [-5, -6, -7, -8], [-9, -10, -11, -12], [-13, -14, -15, -16]]) == 16\n assert candidate(grid = [[-1, -2, -3, -4, -5], [-6, -7, -8, -9, -10], [-11, -12, -13, -14, -15], [-16, -17, -18, -19, -20]]) == 20\n assert candidate(grid = [[1, -1, 0, 0], [-1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, -1, -2], [2, 1, -2, -3, -4], [1, 0, -3, -4, -5]]) == 8\n assert candidate(grid = [[99, 98, 97, 96, 95], [-1, -2, -3, -4, -5], [-10, -20, -30, -40, -50], [-100, -101, -102, -103, -104]]) == 15\n assert candidate(grid = [[10, -5, -4, -3], [-7, -6, -5, -4], [-8, -7, -6, -5], [-9, -8, -7, -6]]) == 15\n assert candidate(grid = [[50, 40, 30, 20, 10], [45, 35, 25, 15, 5], [40, 30, 20, 10, 0], [35, 25, 15, 5, -5]]) == 1\n assert candidate(grid = [[-1, -2, -3, -4, -5], [-2, -3, -4, -5, -6], [-3, -4, -5, -6, -7], [-4, -5, -6, -7, -8], [-5, -6, -7, -8, -9]]) == 25\n assert candidate(grid = [[1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]]) == 90\n assert candidate(grid = [[0, 0, 0, 0, -1], [0, 0, 0, -1, -2], [0, 0, -1, -2, -3], [0, -1, -2, -3, -4], [-1, -2, -3, -4, -5]]) == 15\n assert candidate(grid = [[-100, -99, -98, -97, -96, -95, -94, -93, -92, -91], [-90, -89, -88, -87, -86, -85, -84, -83, -82, -81], [-80, -79, -78, -77, -76, -75, -74, -73, -72, -71], [-70, -69, -68, -67, -66, -65, -64, -63, -62, -61], [-60, -59, -58, -57, -56, -55, -54, -53, -52, -51], [-50, -49, -48, -47, -46, -45, -44, -43, -42, -41], [-40, -39, -38, -37, -36, -35, -34, -33, -32, -31], [-30, -29, -28, -27, -26, -25, -24, -23, -22, -21], [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11], [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]]) == 100\n assert candidate(grid = [[-5, -4, -3, -2, -1], [-10, -9, -8, -7, -6], [-15, -14, -13, -12, -11], [-20, -19, -18, -17, -16], [-25, -24, -23, -22, -21]]) == 25\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, -1, -2], [0, -1, -2, -3], [-1, -2, -3, -4]]) == 9\n assert candidate(grid = [[1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1]]) == 20\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, -1], [0, 0, -1, -1], [0, -1, -1, -1]]) == 6\n assert candidate(grid = [[50, 40, 30, 20, 10], [45, 35, 25, 15, 5], [40, 30, 20, 10, 0], [35, 25, 15, 5, -5], [30, 20, 10, 0, -10]]) == 2\n assert candidate(grid = [[10, 8, 6, 4, 2, 0, -2, -4], [-6, -8, -10, -12, -14, -16, -18, -20], [-10, -12, -14, -16, -18, -20, -22, -24]]) == 18\n assert candidate(grid = [[-10, -20, -30, -40], [-20, -30, -40, -50], [-30, -40, -50, -60], [-40, -50, -60, -70]]) == 16\n assert candidate(grid = [[-10, -20, -30, -40, -50, -60, -70, -80, -90], [-110, -120, -130, -140, -150, -160, -170, -180, -190], [-200, -210, -220, -230, -240, -250, -260, -270, -280]]) == 27\n assert candidate(grid = [[-100, -99, -98, -97], [-96, -95, -94, -93], [-92, -91, -90, -89], [-88, -87, -86, -85]]) == 16\n assert candidate(grid = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70], [40, 50, 60, 70, 80], [50, 60, 70, 80, 90]]) == 0\n assert candidate(grid = [[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 0\n assert candidate(grid = [[-100, -99, -98, -97, -96, -95, -94, -93, -92, -91], [-90, -89, -88, -87, -86, -85, -84, -83, -82, -81], [-80, -79, -78, -77, -76, -75, -74, -73, -72, -71], [-70, -69, -68, -67, -66, -65, -64, -63, -62, -61]]) == 40\n assert candidate(grid = [[-50, -49, -48, -47, -46, -45], [-44, -43, -42, -41, -40, -39], [-38, -37, -36, -35, -34, -33], [-32, -31, -30, -29, -28, -27]]) == 24\n assert candidate(grid = [[-100, -99, -98], [-99, -98, -97], [-98, -97, -96], [-97, -96, -95]]) == 12\n assert candidate(grid = [[10, 5, 0, -10, -20], [-5, -15, -20, -25, -30], [-1, -2, -3, -4, -5]]) == 12\n assert candidate(grid = [[1, -1, 0], [1, -1, 0], [1, -1, 0]]) == 6\n assert candidate(grid = [[1, 0, -1], [-1, -2, -3], [-2, -3, -4], [-3, -4, -5]]) == 10\n assert candidate(grid = [[9, 7, 5, 3, 1], [-1, -3, -5, -7, -9], [-2, -4, -6, -8, -10], [-3, -6, -9, -12, -15]]) == 15\n assert candidate(grid = [[0, 0, 0], [0, 0, -1], [0, -1, -2], [-1, -2, -3]]) == 6\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, -1], [3, 2, 1, -1, -2], [2, 1, -1, -2, -3], [1, -1, -2, -3, -4]]) == 10\n assert candidate(grid = [[1, 0, -1], [-1, 0, 1], [0, 1, -1]]) == 1\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, -1], [8, 7, 6, 5, 4, 3, 2, 1, -2, -3], [7, 6, 5, 4, 3, 2, 1, -3, -4, -5]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -1, -1], [0, 0, 0, -1, -1, -2], [-1, -1, -2, -3, -4, -5]]) == 11\n assert candidate(grid = [[-2, -1, 0, 1, 2], [3, 4, 5, 6, 7], [8, 9, 10, 11, 12], [-13, -14, -15, -16, -17], [-18, -19, -20, -21, -22]]) == 10\n assert candidate(grid = [[1, -1, 2, -2, 3, -3, 4, -4], [1, -1, 2, -2, 3, -3, 4, -4], [1, -1, 2, -2, 3, -3, 4, -4], [1, -1, 2, -2, 3, -3, 4, -4]]) == 28\n assert candidate(grid = [[5, 4, 3, 2, 1, 0, -1, -2, -3, -4], [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]]) == 9\n assert candidate(grid = [[5, 4, 3, 2, 1], [-1, -2, -3, -4, -5], [-6, -7, -8, -9, -10]]) == 10\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, -1], [8, 7, 6, 5, 4, 3, 2, 1, -1, -2], [7, 6, 5, 4, 3, 2, 1, -1, -2, -3], [6, 5, 4, 3, 2, 1, -1, -2, -3, -4], [5, 4, 3, 2, 1, -1, -2, -3, -4, -5], [4, 3, 2, 1, -1, -2, -3, -4, -5, -6], [3, 2, 1, -1, -2, -3, -4, -5, -6, -7], [2, 1, -1, -2, -3, -4, -5, -6, -7, -8], [1, -1, -2, -3, -4, -5, -6, -7, -8, -9]]) == 45\n assert candidate(grid = [[100, -50, 0], [90, -40, 0], [80, -30, 0], [70, -20, 0], [60, -10, 0]]) == 10\n assert candidate(grid = [[50, 20, 10, 0, -10, -20], [-30, -40, -50, -60, -70, -80], [-90, -100, -110, -120, -130, -140]]) == 14\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().countNegatives", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countNegatives(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "countNegatives", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1353, "task_id": "maximum-number-of-events-that-can-be-attended", "difficulty": "Medium", "problem_description": "You are given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.\nYou can attend an event i at any day d where startTimei <= d <= endTimei. You can only attend one event at any time d.\nReturn the maximum number of events you can attend.\n \nExample 1:\n\n\nInput: events = [[1,2],[2,3],[3,4]]\nOutput: 3\nExplanation: You can attend all the three events.\nOne way to attend them all is as shown.\nAttend the first event on day 1.\nAttend the second event on day 2.\nAttend the third event on day 3.\n\nExample 2:\n\nInput: events= [[1,2],[2,3],[3,4],[1,2]]\nOutput: 4\n\n \nConstraints:\n\n1 <= events.length <= 105\nevents[i].length == 2\n1 <= startDayi <= endDayi <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(events = [[1, 100], [1, 100], [1, 100], [1, 100], [1, 100]]) == 5\n assert candidate(events = [[1, 3], [2, 4], [3, 5], [4, 6]]) == 4\n assert candidate(events = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55]]) == 5\n assert candidate(events = [[5, 5], [1, 5], [1, 5], [1, 5]]) == 4\n assert candidate(events = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15]]) == 7\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 5\n assert candidate(events = [[1, 2], [2, 2], [3, 3], [4, 4], [5, 5]]) == 5\n assert candidate(events = [[1, 5], [1, 5], [1, 5], [2, 3], [2, 3]]) == 5\n assert candidate(events = [[1, 2], [2, 3], [3, 4]]) == 3\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [1, 2]]) == 4\n assert candidate(events = [[1, 10], [2, 2], [3, 3], [4, 4], [5, 5]]) == 5\n assert candidate(events = [[1, 10], [2, 3], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == 8\n assert candidate(events = [[1, 3], [2, 3], [3, 4], [4, 5], [5, 6]]) == 5\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 2\n assert candidate(events = [[1, 2], [2, 2], [3, 4], [4, 5]]) == 4\n assert candidate(events = [[1, 100], [1, 100], [1, 100]]) == 3\n assert candidate(events = [[1, 100000], [1, 100000], [1, 100000], [1, 100000], [1, 100000]]) == 5\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 9\n assert candidate(events = [[1, 2], [2, 2], [3, 3], [3, 4]]) == 4\n assert candidate(events = [[1, 1], [1, 2], [1, 3], [1, 4]]) == 4\n assert candidate(events = [[1, 5], [1, 10], [1, 15], [1, 20], [2, 6], [2, 11], [2, 16], [2, 21], [3, 7], [3, 12], [3, 17], [3, 22], [4, 8], [4, 13], [4, 18], [4, 23], [5, 9], [5, 14], [5, 19], [5, 24]]) == 20\n assert candidate(events = [[1, 100000], [50000, 60000], [50000, 55000], [30000, 40000], [10000, 20000], [60000, 70000]]) == 6\n assert candidate(events = [[10, 20], [10, 20], [10, 20], [10, 20], [10, 20], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20]]) == 11\n assert candidate(events = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10]]) == 11\n assert candidate(events = [[1, 30000], [2, 29999], [3, 29998], [4, 29997], [5, 29996], [6, 29995], [7, 29994], [8, 29993], [9, 29992], [10, 29991]]) == 10\n assert candidate(events = [[1, 3], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13]]) == 10\n assert candidate(events = [[1, 100000], [100000, 100000], [1, 100000], [100000, 100000], [1, 100000], [100000, 100000], [1, 100000], [100000, 100000], [1, 100000], [100000, 100000]]) == 6\n assert candidate(events = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]]) == 10\n assert candidate(events = [[1, 3], [2, 3], [3, 3], [4, 6], [5, 6], [6, 6], [7, 9], [8, 9], [9, 9], [10, 12], [11, 12], [12, 12]]) == 12\n assert candidate(events = [[1, 5], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21], [22, 23], [24, 25], [26, 27], [28, 29]]) == 15\n assert candidate(events = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 10\n assert candidate(events = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30]]) == 29\n assert candidate(events = [[5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25]]) == 17\n assert candidate(events = [[1, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 16], [16, 18], [18, 20], [20, 22], [22, 24], [24, 26], [26, 28], [28, 30], [30, 32], [32, 34], [34, 36], [36, 38], [38, 40], [40, 42], [42, 44], [44, 46], [46, 48], [48, 50], [50, 52], [52, 54], [54, 56], [56, 58], [58, 60]]) == 30\n assert candidate(events = [[1, 100], [1, 100], [2, 99], [2, 99], [3, 98], [3, 98], [4, 97], [4, 97], [5, 96], [5, 96], [6, 95], [6, 95]]) == 12\n assert candidate(events = [[2, 2], [3, 3], [1, 2], [1, 3], [1, 4]]) == 4\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 10\n assert candidate(events = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [1, 20], [2, 19], [3, 18], [4, 17], [5, 16]]) == 15\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [1, 2], [2, 3], [3, 4], [4, 5]]) == 16\n assert candidate(events = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 15], [12, 15], [13, 15], [14, 15], [15, 15], [16, 20], [17, 20], [18, 20], [19, 20], [20, 20]]) == 20\n assert candidate(events = [[1, 2], [3, 4], [2, 3], [4, 5], [1, 5]]) == 5\n assert candidate(events = [[5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20]]) == 11\n assert candidate(events = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [1, 5], [5, 10], [1, 3], [3, 5]]) == 10\n assert candidate(events = [[1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10]]) == 10\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [5, 6], [5, 6], [5, 6], [6, 7], [6, 7], [6, 7], [7, 8], [7, 8], [7, 8]]) == 8\n assert candidate(events = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991]]) == 10\n assert candidate(events = [[5, 21], [1, 10], [2, 20], [3, 19], [4, 18], [5, 17], [6, 16], [7, 15], [8, 14], [9, 13], [10, 12], [11, 11], [12, 10], [13, 9], [14, 8], [15, 7], [16, 6], [17, 5], [18, 4], [19, 3], [20, 2], [21, 1]]) == 21\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [4, 5], [5, 6], [5, 6], [5, 6], [5, 6], [6, 7], [6, 7], [6, 7], [6, 7], [7, 8], [7, 8], [7, 8], [7, 8], [8, 9], [8, 9], [8, 9], [8, 9], [9, 10], [9, 10], [9, 10], [9, 10]]) == 10\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21]]) == 20\n assert candidate(events = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 10\n assert candidate(events = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10]]) == 10\n assert candidate(events = [[1, 20], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 19\n assert candidate(events = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 1\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 10\n assert candidate(events = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 10\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 10\n assert candidate(events = [[1, 2], [2, 5], [3, 4], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]]) == 9\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 15\n assert candidate(events = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20]]) == 18\n assert candidate(events = [[2, 4], [2, 5], [2, 7], [2, 8], [2, 9], [4, 7], [5, 7], [5, 8], [5, 9], [7, 10], [8, 10], [9, 10]]) == 9\n assert candidate(events = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 9\n assert candidate(events = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [11, 10], [12, 9], [13, 8], [14, 7], [15, 6], [16, 5], [17, 4], [18, 3], [19, 2], [20, 1]]) == 20\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17], [15, 18], [16, 19], [17, 20]]) == 20\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 10\n assert candidate(events = [[1, 4], [1, 4], [1, 4], [2, 4], [2, 4], [3, 4], [3, 4], [4, 4], [4, 4], [4, 4]]) == 4\n assert candidate(events = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22]]) == 20\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 2\n assert candidate(events = [[1, 5], [5, 5], [1, 5], [2, 3], [4, 6]]) == 5\n assert candidate(events = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12]]) == 11\n assert candidate(events = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25], [22, 26], [23, 27], [24, 28], [25, 29], [26, 30], [27, 31], [28, 32], [29, 33], [30, 34], [31, 35], [32, 36], [33, 37], [34, 38], [35, 39], [36, 40], [37, 41], [38, 42], [39, 43], [40, 44], [41, 45], [42, 46], [43, 47], [44, 48], [45, 49], [46, 50]]) == 46\n assert candidate(events = [[1, 5], [2, 3], [3, 4], [2, 5], [1, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 9\n assert candidate(events = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7]]) == 5\n assert candidate(events = [[10, 15], [20, 25], [15, 20], [25, 30], [10, 25], [20, 30], [15, 30]]) == 7\n assert candidate(events = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 15\n assert candidate(events = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23], [23, 25], [25, 27], [27, 29], [29, 31], [31, 33], [33, 35], [35, 37], [37, 39], [39, 41], [41, 43], [43, 45], [45, 47], [47, 49], [49, 51], [51, 53], [53, 55], [55, 57], [57, 59], [59, 61], [61, 63]]) == 31\n assert candidate(events = [[10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60]]) == 10\n assert candidate(events = [[1, 50000], [50001, 100000], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21]]) == 22\n assert candidate(events = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [1, 25], [2, 24], [3, 23], [4, 22], [5, 21]]) == 10\n assert candidate(events = [[1, 3], [1, 10], [2, 5], [2, 8], [3, 6], [3, 9], [4, 7], [4, 10], [5, 8], [5, 11], [6, 9], [6, 12], [7, 10], [7, 13], [8, 11], [8, 14], [9, 12], [9, 15], [10, 13], [10, 16]]) == 16\n assert candidate(events = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]]) == 5\n assert candidate(events = [[5, 5], [1, 5], [1, 5], [2, 3], [2, 3], [3, 4], [3, 4], [4, 5], [4, 5]]) == 5\n assert candidate(events = [[1, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 65], [65, 70], [70, 75], [75, 80], [80, 85], [85, 90], [90, 95], [95, 100]]) == 20\n assert candidate(events = [[1, 2], [3, 4], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 10\n assert candidate(events = [[10, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100], [101, 110], [111, 120], [121, 130], [131, 140], [141, 150], [151, 160]]) == 15\n assert candidate(events = [[1, 5], [1, 5], [2, 6], [2, 6], [3, 7], [3, 7], [4, 8], [4, 8], [5, 9], [5, 9], [6, 10], [6, 10], [7, 11], [7, 11], [8, 12], [8, 12], [9, 13], [9, 13], [10, 14], [10, 14]]) == 14\n assert candidate(events = [[1, 5], [5, 10], [10, 15], [15, 20], [20, 25], [1, 25], [2, 24], [3, 23], [4, 22], [5, 21], [6, 20], [7, 19], [8, 18], [9, 17], [10, 16], [11, 15], [12, 14], [13, 13], [14, 12], [15, 11]]) == 20\n assert candidate(events = [[3, 6], [2, 6], [1, 6], [1, 5], [2, 5], [3, 5], [2, 4], [3, 4], [4, 5], [4, 6], [4, 7]]) == 7\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 10\n assert candidate(events = [[1, 3], [2, 5], [3, 7], [4, 10], [5, 15], [6, 20], [7, 25], [8, 30], [9, 35], [10, 40]]) == 10\n assert candidate(events = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6]]) == 6\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [5, 6], [5, 6], [5, 6], [6, 7], [6, 7], [6, 7]]) == 7\n assert candidate(events = [[1, 2], [2, 3], [2, 3], [3, 4], [3, 4], [4, 5], [4, 5], [5, 6]]) == 6\n assert candidate(events = [[1, 10], [1, 20], [1, 30], [2, 20], [2, 30], [2, 40], [3, 30], [3, 40], [3, 50], [4, 40], [4, 50], [4, 60], [5, 50], [5, 60], [5, 70]]) == 15\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 10\n assert candidate(events = [[1, 20000], [1, 30000], [2, 30000], [2, 40000], [3, 40000], [3, 50000], [4, 50000], [4, 60000], [5, 60000], [5, 70000]]) == 10\n assert candidate(events = [[1, 2], [2, 3], [2, 3], [3, 4], [3, 4], [4, 5], [4, 5], [5, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n assert candidate(events = [[1, 2], [2, 5], [5, 6], [6, 10], [10, 15]]) == 5\n"}, "metadata": {"canonical_parameter_names": ["events"], "leetcode_dataset_entry_point": "Solution().maxEvents", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxEvents(self, events: list[list[int]]) -> int:", "container": "Solution", "callable": "maxEvents", "parameters": [{"name": "events", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1354, "task_id": "construct-target-array-with-multiple-sums", "difficulty": "Hard", "problem_description": "You are given an array target of n integers. From a starting array arr consisting of n 1's, you may perform the following procedure :\n\nlet x be the sum of all elements currently in your array.\nchoose index i, such that 0 <= i < n and set the value of arr at index i to x.\nYou may repeat this procedure as many times as needed.\n\nReturn true if it is possible to construct the target array from arr, otherwise, return false.\n \nExample 1:\n\nInput: target = [9,3,5]\nOutput: true\nExplanation: Start with arr = [1, 1, 1] \n[1, 1, 1], sum = 3 choose index 1\n[1, 3, 1], sum = 5 choose index 2\n[1, 3, 5], sum = 9 choose index 0\n[9, 3, 5] Done\n\nExample 2:\n\nInput: target = [1,1,1,2]\nOutput: false\nExplanation: Impossible to create target array from [1,1,1,1].\n\nExample 3:\n\nInput: target = [8,5]\nOutput: true\n\n \nConstraints:\n\nn == target.length\n1 <= n <= 5 * 104\n1 <= target[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(target = [1, 2, 3, 4, 5]) == False\n assert candidate(target = [1000000000, 1, 1]) == False\n assert candidate(target = [5, 7, 1]) == True\n assert candidate(target = [10, 1]) == True\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == False\n assert candidate(target = [5, 5, 5]) == False\n assert candidate(target = [1000000000, 1000000000]) == False\n assert candidate(target = [1000000000, 1]) == True\n assert candidate(target = [1, 1, 1, 2]) == False\n assert candidate(target = [5, 10, 15]) == False\n assert candidate(target = [1, 1000000000, 1000000000]) == False\n assert candidate(target = [9, 3, 5]) == True\n assert candidate(target = [1, 1, 1]) == True\n assert candidate(target = [2, 900000000]) == False\n assert candidate(target = [8, 5]) == True\n assert candidate(target = [1, 1000000000]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(target = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == False\n assert candidate(target = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == False\n assert candidate(target = [21, 17, 13, 9, 5, 1]) == False\n assert candidate(target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(target = [100, 100, 100, 100, 100, 99, 98, 97, 96, 95]) == False\n assert candidate(target = [5, 10, 15, 20, 25, 30]) == False\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == False\n assert candidate(target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == False\n assert candidate(target = [37, 11, 25, 7, 19]) == False\n assert candidate(target = [41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131]) == False\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == False\n assert candidate(target = [1, 1000000000, 1, 1000000000, 1, 1000000000]) == False\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == False\n assert candidate(target = [2, 6, 10, 14, 18, 22]) == False\n assert candidate(target = [100, 100, 100, 100, 99]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20]) == False\n assert candidate(target = [13, 11, 10]) == False\n assert candidate(target = [81, 27, 9, 3, 1]) == False\n assert candidate(target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == False\n assert candidate(target = [5, 7, 9, 13, 21, 34, 55]) == False\n assert candidate(target = [10, 5, 15, 20]) == False\n assert candidate(target = [987, 654, 321]) == False\n assert candidate(target = [18, 5, 7]) == False\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == False\n assert candidate(target = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == False\n assert candidate(target = [3, 5, 11, 13, 17]) == False\n assert candidate(target = [50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25]) == False\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994]) == False\n assert candidate(target = [21, 15, 12]) == False\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996]) == False\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(target = [7, 14, 21, 28, 35, 42, 49]) == False\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000001]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(target = [123456789, 987654321, 456789123, 321987654]) == False\n assert candidate(target = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == False\n assert candidate(target = [999999999, 999999999, 1]) == False\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == False\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(target = [8, 13, 21, 34, 55, 89]) == False\n assert candidate(target = [100, 99, 98, 97]) == False\n assert candidate(target = [1000000000, 1, 1, 1, 1]) == False\n assert candidate(target = [123456789, 987654321, 111111111]) == False\n assert candidate(target = [17, 7, 17, 7, 17]) == False\n assert candidate(target = [4, 12, 33, 55]) == False\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == False\n assert candidate(target = [45, 12, 18, 30, 36, 24]) == False\n assert candidate(target = [314159265, 271828182, 161803398, 141421356]) == False\n assert candidate(target = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == False\n assert candidate(target = [7, 11, 15, 22]) == False\n assert candidate(target = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == False\n assert candidate(target = [17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17]) == False\n assert candidate(target = [999999999, 1, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == False\n assert candidate(target = [33, 17, 13]) == True\n assert candidate(target = [1, 1, 2, 3, 6, 11, 20, 37, 68]) == False\n assert candidate(target = [101, 103, 107, 109]) == False\n assert candidate(target = [10, 15, 3]) == False\n assert candidate(target = [7, 18, 5, 4]) == False\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(target = [2, 900000000, 900000000]) == False\n assert candidate(target = [123456789, 987654321]) == False\n assert candidate(target = [100, 200, 300, 400, 500]) == False\n assert candidate(target = [1, 1000000000, 1000000000, 1000000000]) == False\n assert candidate(target = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711]) == False\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == False\n assert candidate(target = [5, 11, 19, 29, 41]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == False\n assert candidate(target = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == False\n assert candidate(target = [10, 15, 20, 30]) == False\n assert candidate(target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == False\n assert candidate(target = [1000000000, 1000000000, 999999999, 1]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(target = [123456789, 987654321, 456789123, 321987654, 654321987, 789456123, 123789456, 456123789, 789654321, 987456123]) == False\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == False\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == False\n assert candidate(target = [3, 9, 20, 5]) == False\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == False\n assert candidate(target = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == False\n assert candidate(target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n"}, "metadata": {"canonical_parameter_names": ["target"], "leetcode_dataset_entry_point": "Solution().isPossible", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def isPossible(self, target: list[int]) -> bool:", "container": "Solution", "callable": "isPossible", "parameters": [{"name": "target", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1356, "task_id": "sort-integers-by-the-number-of-1-bits", "difficulty": "Easy", "problem_description": "You are given an integer array arr. Sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order.\nReturn the array after sorting it.\n \nExample 1:\n\nInput: arr = [0,1,2,3,4,5,6,7,8]\nOutput: [0,1,2,4,8,3,5,6,7]\nExplantion: [0] is the only integer with 0 bits.\n[1,2,4,8] all have 1 bit.\n[3,5,6] have 2 bits.\n[7] has 3 bits.\nThe sorted array by bits is [0,1,2,4,8,3,5,6,7]\n\nExample 2:\n\nInput: arr = [1024,512,256,128,64,32,16,8,4,2,1]\nOutput: [1,2,4,8,16,32,64,128,256,512,1024]\nExplantion: All integers have 1 bit in the binary representation, you should just sort them in ascending order.\n\n \nConstraints:\n\n1 <= arr.length <= 500\n0 <= arr[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [3, 7, 8, 9]) == [8, 3, 9, 7]\n assert candidate(arr = [1, 3, 5, 7, 9]) == [1, 3, 5, 9, 7]\n assert candidate(arr = [1, 0, 2, 3, 4]) == [0, 1, 2, 4, 3]\n assert candidate(arr = [3, 8, 3, 6, 5, 7, 9, 2]) == [2, 8, 3, 3, 5, 6, 9, 7]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15]) == [1, 3, 5, 9, 7, 11, 13, 15]\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8]) == [0, 1, 2, 4, 8, 3, 5, 6, 7]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]\n assert candidate(arr = [10, 100, 1000, 10000]) == [10, 100, 10000, 1000]\n assert candidate(arr = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]\n assert candidate(arr = [31, 15, 7, 3, 1, 0, 16, 8, 4, 2]) == [0, 1, 2, 4, 8, 16, 3, 7, 15, 31]\n assert candidate(arr = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191]\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [3, 5, 9, 17, 7, 11, 13, 19, 21, 25, 15, 23, 27, 29, 31]\n assert candidate(arr = [123, 456, 789, 101, 234, 567, 890, 112, 345, 678]) == [112, 101, 456, 234, 345, 678, 789, 123, 567, 890]\n assert candidate(arr = [4095, 4094, 4093, 4092, 4091, 4090, 4089, 4088, 4087, 4086, 4085, 4084]) == [4084, 4088, 4085, 4086, 4089, 4090, 4092, 4087, 4091, 4093, 4094, 4095]\n assert candidate(arr = [4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095]\n assert candidate(arr = [123, 456, 789, 101, 234, 567, 890, 111, 222, 333]) == [101, 456, 234, 333, 789, 111, 123, 222, 567, 890]\n assert candidate(arr = [33, 2, 7, 5, 8, 9, 6, 11, 14]) == [2, 8, 5, 6, 9, 33, 7, 11, 14]\n assert candidate(arr = [9, 5, 3, 7, 11, 13, 19, 21, 23, 29, 31, 37, 41, 43, 47]) == [3, 5, 9, 7, 11, 13, 19, 21, 37, 41, 23, 29, 43, 31, 47]\n assert candidate(arr = [1234, 4321, 5678, 8765, 9876, 6789, 2345, 5432]) == [1234, 2345, 4321, 5432, 6789, 9876, 5678, 8765]\n assert candidate(arr = [3, 7, 8, 9, 6, 5, 2, 1, 0, 4]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 7]\n assert candidate(arr = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]\n assert candidate(arr = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32]) == [0, 1, 2, 4, 8, 16, 32, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191]\n assert candidate(arr = [49, 33, 25, 17, 9, 5, 3, 1, 0, 2, 6, 10, 18, 34, 66, 130]) == [0, 1, 2, 3, 5, 6, 9, 10, 17, 18, 33, 34, 66, 130, 25, 49]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1023]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]\n assert candidate(arr = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == [0, 1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024, 2048, 2048]\n assert candidate(arr = [13, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [17, 18, 20, 24, 13, 19, 21, 22, 25, 26, 28, 23, 27, 29, 30]\n assert candidate(arr = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == [3, 5, 17, 7, 11, 13, 19, 37, 41, 23, 29, 43, 53, 31, 47]\n assert candidate(arr = [1234, 2345, 3456, 4567, 5678, 6789, 7890, 8901, 9012]) == [3456, 1234, 2345, 6789, 8901, 9012, 5678, 4567, 7890]\n assert candidate(arr = [4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 8191, 16383, 32767]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]\n assert candidate(arr = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717]) == [101, 202, 404, 808, 1313, 1616, 707, 1414, 303, 606, 909, 1111, 1212, 505, 1010, 1717, 1515]\n assert candidate(arr = [63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48]) == [48, 49, 50, 52, 56, 51, 53, 54, 57, 58, 60, 55, 59, 61, 62, 63]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 3, 7, 15, 31, 63, 127, 255, 511, 1023]\n assert candidate(arr = [5, 3, 15, 7, 8, 12, 9, 6, 2, 4, 10, 14, 13, 11, 1]) == [1, 2, 4, 8, 3, 5, 6, 9, 10, 12, 7, 11, 13, 14, 15]\n assert candidate(arr = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191]\n assert candidate(arr = [9, 5, 6, 2, 31, 14, 12, 10, 28, 20, 24]) == [2, 5, 6, 9, 10, 12, 20, 24, 14, 28, 31]\n assert candidate(arr = [1001, 1010, 1011, 1100, 1101, 1110, 1111, 100, 101, 110, 111, 10, 1, 0]) == [0, 1, 10, 100, 101, 1100, 110, 1101, 1110, 111, 1111, 1001, 1010, 1011]\n assert candidate(arr = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988]) == [9988, 9992, 10000, 9989, 9990, 9993, 9994, 9996, 9991, 9995, 9997, 9998, 9999]\n assert candidate(arr = [1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [10000, 1000, 100000, 1000000, 10000000, 100000000, 1000000000]\n assert candidate(arr = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191]\n assert candidate(arr = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1110, 1101, 1100, 1011, 1010, 1001, 1000, 999, 888, 777, 666, 555, 444, 333, 222, 111, 110, 101, 100, 99, 88, 77, 66, 55, 44, 33, 22, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 10, 33, 66, 7, 11, 22, 44, 88, 100, 77, 99, 101, 777, 1100, 55, 110, 333, 555, 666, 1101, 1110, 3333, 6666, 111, 222, 444, 888, 1000, 1111, 2222, 4444, 8888, 1001, 1010, 7777, 999, 1011, 5555, 9999]\n assert candidate(arr = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0]) == [0, 1, 3, 7, 15, 31, 62, 125, 250, 500, 1000]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]) == [1, 2, 4, 8, 16, 32, 3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, 34, 36, 40, 48, 7, 11, 13, 14, 19, 21, 22, 25, 26, 28, 35, 37, 38, 41, 42, 44, 49, 50, 52, 56, 15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58, 60, 31, 47, 55, 59, 61, 62, 63]\n assert candidate(arr = [31, 15, 7, 3, 1, 0, 32, 16, 8, 4, 2]) == [0, 1, 2, 4, 8, 16, 32, 3, 7, 15, 31]\n assert candidate(arr = [15, 31, 63, 127, 255, 511, 1023, 2047]) == [15, 31, 63, 127, 255, 511, 1023, 2047]\n assert candidate(arr = [3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]) == [3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]\n assert candidate(arr = [500, 125, 62, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 3, 7, 15, 31, 62, 125, 500]\n assert candidate(arr = [129, 258, 516, 1032, 2064, 4128, 8256]) == [129, 258, 516, 1032, 2064, 4128, 8256]\n assert candidate(arr = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]\n assert candidate(arr = [1001, 1010, 1100, 1101, 1110, 1111, 999, 998, 997, 996, 995, 994]) == [1100, 1101, 1110, 994, 996, 1111, 995, 997, 998, 1001, 1010, 999]\n assert candidate(arr = [9, 5, 1, 3, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [1, 3, 5, 9, 17, 7, 11, 13, 19, 21, 25, 15, 23, 27, 29, 31]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 3, 5, 6, 7, 9, 10, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 7, 13, 14, 19, 21, 22, 25, 26, 28, 15, 23, 27, 29, 30]\n assert candidate(arr = [64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == [64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]\n assert candidate(arr = [32, 16, 8, 4, 2, 1, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]\n assert candidate(arr = [13, 29, 11, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 3, 7, 11, 13, 29]\n assert candidate(arr = [1001, 1100, 1010, 1110, 1000, 1111, 1101, 1011, 111, 110, 101, 11, 10, 1, 0]) == [0, 1, 10, 11, 101, 1100, 110, 1101, 1110, 111, 1000, 1111, 1001, 1010, 1011]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [1, 3, 5, 9, 17, 7, 11, 13, 19, 21, 25, 15, 23, 27, 29, 31]\n assert candidate(arr = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1010, 1101, 1000, 111, 110, 101, 11, 10, 1, 0]) == [0, 1, 10, 11, 101, 110, 1101, 3333, 6666, 111, 1000, 1111, 2222, 4444, 8888, 1010, 7777, 5555, 9999]\n assert candidate(arr = [8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 4, 8, 16, 3, 5, 6, 9, 10, 12, 17, 18, 20, 7, 11, 13, 14, 19, 15]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]\n assert candidate(arr = [1234, 4321, 5678, 8765, 9876, 6789, 3456, 7890]) == [3456, 1234, 4321, 6789, 9876, 5678, 8765, 7890]\n assert candidate(arr = [31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 3, 7, 15, 31]\n assert candidate(arr = [5, 3, 15, 7, 11, 13, 19, 21, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == [3, 5, 7, 11, 13, 19, 21, 37, 41, 67, 73, 97, 15, 23, 29, 43, 53, 71, 83, 89, 31, 47, 59, 61, 79]\n assert candidate(arr = [31, 29, 28, 27, 26, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 3, 5, 9, 17, 7, 11, 13, 19, 21, 25, 26, 28, 15, 23, 27, 29, 31]\n assert candidate(arr = [33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289, 1048577, 2097153, 4194305, 8388609, 16777217]) == [33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289, 1048577, 2097153, 4194305, 8388609, 16777217]\n assert candidate(arr = [3, 5, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == [3, 5, 6, 9, 12, 18, 24, 33, 36, 21, 42, 15, 27, 30, 39, 45]\n assert candidate(arr = [1234, 4321, 2345, 5432, 3456, 6543, 4567, 7654, 5678, 8765, 6789, 9876, 7890, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 10, 12, 7, 11, 13, 14, 15, 3456, 1234, 2345, 4321, 5432, 6789, 9876, 5678, 8765, 4567, 6543, 7890, 7654]\n assert candidate(arr = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989]) == [9992, 10000, 9989, 9990, 9993, 9994, 9996, 9991, 9995, 9997, 9998, 9999]\n assert candidate(arr = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [17, 18, 20, 24, 19, 21, 22, 25, 26, 28, 23, 27, 29, 30, 31]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]\n assert candidate(arr = [777, 888, 999, 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == [777, 3333, 6666, 888, 1111, 2222, 4444, 8888, 7777, 999, 5555, 9999]\n assert candidate(arr = [32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]\n assert candidate(arr = [9, 5, 3, 7, 11, 13, 14, 19, 21, 22, 25, 29]) == [3, 5, 9, 7, 11, 13, 14, 19, 21, 22, 25, 29]\n assert candidate(arr = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012]) == [1008, 1001, 1002, 1004, 1009, 1010, 1012, 1003, 1005, 1006, 1011, 1007]\n assert candidate(arr = [9, 5, 6, 7, 8, 4, 2, 3, 1, 0]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 7]\n assert candidate(arr = [1431655765, 1431655764, 1431655763, 1431655762, 1431655761, 1431655760, 1431655759, 1431655758, 1431655757, 1431655756, 1431655755, 1431655754, 1431655753, 1431655752, 1431655751, 1431655750, 1431655749]) == [1431655752, 1431655760, 1431655749, 1431655750, 1431655753, 1431655754, 1431655756, 1431655761, 1431655762, 1431655764, 1431655751, 1431655755, 1431655757, 1431655758, 1431655763, 1431655765, 1431655759]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == [100, 200, 400, 800, 300, 600, 900, 1100, 1200, 500, 700, 1000]\n assert candidate(arr = [13, 7, 14, 28, 35, 42, 56, 70, 84, 98]) == [7, 13, 14, 28, 35, 42, 56, 70, 84, 98]\n assert candidate(arr = [9, 5, 3, 7, 2, 8, 6, 4, 1, 0, 11, 13, 14, 10, 12]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 10, 12, 7, 11, 13, 14]\n assert candidate(arr = [8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == [0, 1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024, 2048, 2048, 4096, 4096, 8192, 8192]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [0, 1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024]\n assert candidate(arr = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 3, 6, 12, 25, 50, 100, 200, 400, 300, 500]\n assert candidate(arr = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1023, 511]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 511, 1023]\n assert candidate(arr = [1431655765, 2863311530, 1431655764, 715827882, 357913941, 178956970, 89478485, 44739242, 22369621, 11184810, 5592405, 2796202, 1398101, 699050, 349525, 174762, 87381, 43690, 21845, 10922, 5461, 2730, 1365, 682, 341, 170, 85, 42, 21, 10, 5, 2, 1, 0]) == [0, 1, 2, 5, 10, 21, 42, 85, 170, 341, 682, 1365, 2730, 5461, 10922, 21845, 43690, 87381, 174762, 349525, 699050, 1398101, 2796202, 5592405, 11184810, 22369621, 44739242, 89478485, 178956970, 357913941, 715827882, 1431655764, 1431655765, 2863311530]\n assert candidate(arr = [15, 7, 3, 1, 0, 8, 16, 4]) == [0, 1, 4, 8, 16, 3, 7, 15]\n assert candidate(arr = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == [9009, 1001, 2002, 4004, 5005, 8008, 3003, 6006, 7007]\n assert candidate(arr = [1374, 8314, 5296, 7916, 4154, 9666, 8078, 2933, 269, 9218, 4688, 7266, 2650, 9016, 1350, 8202]) == [8202, 9218, 269, 4688, 1350, 4154, 5296, 2650, 7266, 8314, 9016, 9666, 1374, 2933, 7916, 8078]\n assert candidate(arr = [1234, 4321, 5678, 8765, 2345, 5432, 6789, 9876, 3456, 6543, 7890, 8907]) == [3456, 1234, 2345, 4321, 5432, 6789, 9876, 5678, 8765, 8907, 6543, 7890]\n assert candidate(arr = [32767, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32767]\n assert candidate(arr = [13, 9, 6, 5, 12, 10, 3, 7, 2, 8, 4, 1, 0]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 10, 12, 7, 13]\n assert candidate(arr = [31, 15, 7, 3, 1, 0, 2, 4, 8, 16]) == [0, 1, 2, 4, 8, 16, 3, 7, 15, 31]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == [0, 1, 1, 3, 3, 7, 7, 15, 15, 31, 31, 63, 63, 127, 127, 255, 255, 511, 511, 1023, 1023]\n assert candidate(arr = [5, 3, 1, 9, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [1, 3, 5, 9, 17, 33, 7, 11, 13, 19, 21, 25, 35, 37, 15, 23, 27, 29, 39, 31]\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().sortByBits", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def sortByBits(self, arr: list[int]) -> list[int]:", "container": "Solution", "callable": "sortByBits", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1358, "task_id": "number-of-substrings-containing-all-three-characters", "difficulty": "Medium", "problem_description": "Given a string s consisting only of characters a, b and c.\nReturn the number of substrings containing at least one occurrence of all these characters a, b and c.\n \nExample 1:\n\nInput: s = \"abcabc\"\nOutput: 10\nExplanation: The substrings containing at least one occurrence of the characters a, b and c are \"abc\", \"abca\", \"abcab\", \"abcabc\", \"bca\", \"bcab\", \"bcabc\", \"cab\", \"cabc\" and \"abc\" (again). \n\nExample 2:\n\nInput: s = \"aaacb\"\nOutput: 3\nExplanation: The substrings containing at least one occurrence of the characters a, b and c are \"aaacb\", \"aacb\" and \"acb\". \n\nExample 3:\n\nInput: s = \"abc\"\nOutput: 1\n\n \nConstraints:\n\n3 <= s.length <= 5 x 10^4\ns only consists of a, b or c characters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaabbbccc\") == 9\n assert candidate(s = \"abcba\") == 5\n assert candidate(s = \"cba\") == 1\n assert candidate(s = \"cbaacb\") == 8\n assert candidate(s = \"bbbacbac\") == 18\n assert candidate(s = \"ccccabc\") == 9\n assert candidate(s = \"abcabcabc\") == 28\n assert candidate(s = \"abcabcabcabc\") == 55\n assert candidate(s = \"aabbc\") == 2\n assert candidate(s = \"cccbaab\") == 9\n assert candidate(s = \"aabbbc\") == 2\n assert candidate(s = \"aabcbc\") == 6\n assert candidate(s = \"abcabc\") == 10\n assert candidate(s = \"aabbaacc\") == 8\n assert candidate(s = \"abacbc\") == 8\n assert candidate(s = \"abacabacabc\") == 41\n assert candidate(s = \"aaaabbbbcccc\") == 16\n assert candidate(s = \"ccbaaabb\") == 10\n assert candidate(s = \"baccab\") == 7\n assert candidate(s = \"bca\") == 1\n assert candidate(s = \"abc\") == 1\n assert candidate(s = \"ccccbaaa\") == 12\n assert candidate(s = \"aaacb\") == 3\n assert candidate(s = \"ccccbaab\") == 12\n assert candidate(s = \"abcababc\") == 18\n assert candidate(s = \"aabbcc\") == 4\n assert candidate(s = \"aaaabbbccc\") == 12\n assert candidate(s = \"abacbac\") == 14\n assert candidate(s = \"abcacbacbacbabc\") == 89\n assert candidate(s = \"aabbcacabcabc\") == 59\n assert candidate(s = \"ccabababc\") == 17\n assert candidate(s = \"abacbabacbabacbab\") == 112\n assert candidate(s = \"aabccbabcbacbac\") == 85\n assert candidate(s = \"abcabcabccba\") == 52\n assert candidate(s = \"aabbccbaa\") == 18\n assert candidate(s = \"aaabbbcccbbbccc\") == 27\n assert candidate(s = \"acbacbacbacbacb\") == 91\n assert candidate(s = \"abacbacbacb\") == 44\n assert candidate(s = \"aabcbacbacbabc\") == 75\n assert candidate(s = \"bcabcabcabcabc\") == 78\n assert candidate(s = \"aaabbbcccabcabcabc\") == 115\n assert candidate(s = \"abacbacbacbacbabcababcabc\") == 271\n assert candidate(s = \"acbacbacbacb\") == 55\n assert candidate(s = \"abacbacbacbabc\") == 76\n assert candidate(s = \"cccbbbaaa\") == 9\n assert candidate(s = \"caabcbacbacb\") == 52\n assert candidate(s = \"abbbcccaabbbabc\") == 59\n assert candidate(s = \"abacbcabc\") == 26\n assert candidate(s = \"aaabbbcccbbbaaa\") == 45\n assert candidate(s = \"bacbacbacbacb\") == 66\n assert candidate(s = \"cabcbacbacbabcb\") == 88\n assert candidate(s = \"abacbcacab\") == 31\n assert candidate(s = \"bbbbbbcccaaa\") == 18\n assert candidate(s = \"aaaaaaaaaabbbccc\") == 30\n assert candidate(s = \"ccbbbaaabbbccc\") == 36\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 406\n assert candidate(s = \"abcabcabcab\") == 45\n assert candidate(s = \"aabbaaccabcabcabc\") == 104\n assert candidate(s = \"bacbacbacbacbacba\") == 120\n assert candidate(s = \"ccccbbbaaaaa\") == 20\n assert candidate(s = \"abababababababab\") == 0\n assert candidate(s = \"abacbcabcabcab\") == 76\n assert candidate(s = \"abababababab\") == 0\n assert candidate(s = \"cacbacbacbac\") == 54\n assert candidate(s = \"cabbacbac\") == 25\n assert candidate(s = \"aabbaacccbaab\") == 45\n assert candidate(s = \"abcabcabcabcabcabc\") == 136\n assert candidate(s = \"cbacbacbacbac\") == 66\n assert candidate(s = \"aabbbcccaaaabbbccc\") == 86\n assert candidate(s = \"bacbacbacbacba\") == 78\n assert candidate(s = \"aabacababaac\") == 40\n assert candidate(s = \"abcababccbaabc\") == 69\n assert candidate(s = \"ababababcabcab\") == 57\n assert candidate(s = \"aaabbbcccbbb\") == 18\n assert candidate(s = \"abcabcabcabcababc\") == 117\n assert candidate(s = \"abccbaabccbaab\") == 66\n assert candidate(s = \"baccabaccabacc\") == 69\n assert candidate(s = \"abacbcacbacb\") == 52\n assert candidate(s = \"cccccbbaaaabbbccc\") == 68\n assert candidate(s = \"bbcccaabbcccaab\") == 65\n assert candidate(s = \"aabbbccccaaaabbbbccc\") == 103\n assert candidate(s = \"abababab\") == 0\n assert candidate(s = \"cbacbacbacbacbacbacbacbacbacbacb\") == 465\n assert candidate(s = \"abcbaabcbaabc\") == 58\n assert candidate(s = \"aabcbabacabc\") == 49\n assert candidate(s = \"aabacbacbacbac\") == 75\n assert candidate(s = \"aabbaaccbbacbbacaacabcbacbacbacbac\") == 498\n assert candidate(s = \"abacbabacbabac\") == 71\n assert candidate(s = \"aabbbcccaabbbabc\") == 70\n assert candidate(s = \"aaaabbccccabbbccc\") == 85\n assert candidate(s = \"cccaaaabbbcccbbb\") == 51\n assert candidate(s = \"ccccbbaaaabc\") == 30\n assert candidate(s = \"acbacbacbacbacbacbacbacbacbacbac\") == 465\n assert candidate(s = \"abcbbccaaa\") == 20\n assert candidate(s = \"cccaabbbaaacc\") == 34\n assert candidate(s = \"ccccccccabbaabbcbbb\") == 100\n assert candidate(s = \"cccbababac\") == 23\n assert candidate(s = \"ccccabcabcabc\") == 60\n assert candidate(s = \"aabacbababcabc\") == 69\n assert candidate(s = \"aaabbbcccbbbaaabbbc\") == 87\n assert candidate(s = \"abccabccabccabc\") == 85\n assert candidate(s = \"abcbacbacbacbaca\") == 103\n assert candidate(s = \"abcabcabcabacbacb\") == 119\n assert candidate(s = \"aabbbcccabcabcabc\") == 103\n assert candidate(s = \"abacbcabcabc\") == 53\n assert candidate(s = \"aabbaaccaabbcc\") == 52\n assert candidate(s = \"abcabcabacbcab\") == 76\n assert candidate(s = \"aabbbccc\") == 6\n assert candidate(s = \"aabbaacccbbcabab\") == 77\n assert candidate(s = \"babababacacacacbcbbcbcbcbacbacbacb\") == 441\n assert candidate(s = \"cacbacbacbacbacbac\") == 135\n assert candidate(s = \"cccbbaaaabacbacb\") == 78\n assert candidate(s = \"ccccbbbaaa\") == 12\n assert candidate(s = \"aaaaaaaaaabcabcabcabcabc\") == 208\n assert candidate(s = \"aabbbccccaaa\") == 23\n assert candidate(s = \"abacbacbac\") == 35\n assert candidate(s = \"aabbbaccccba\") == 36\n assert candidate(s = \"ccbaabccababab\") == 62\n assert candidate(s = \"ccccbaabccc\") == 33\n assert candidate(s = \"ccccbaa\") == 8\n assert candidate(s = \"bacabcabcabcabcabcabcabc\") == 252\n assert candidate(s = \"ccccccaaaabbbccc\") == 48\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\") == 496\n assert candidate(s = \"abacbabcc\") == 25\n assert candidate(s = \"abacbacbacbacb\") == 77\n assert candidate(s = \"bacbacbacbacbacbacbac\") == 190\n assert candidate(s = \"abcabcabcabcabc\") == 91\n assert candidate(s = \"bbaacccaaaabbccba\") == 76\n assert candidate(s = \"aaaaabbbbbccccc\") == 25\n assert candidate(s = \"aaabbbcccabc\") == 34\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numberOfSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numberOfSubstrings(self, s: str) -> int:", "container": "Solution", "callable": "numberOfSubstrings", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1359, "task_id": "count-all-valid-pickup-and-delivery-options", "difficulty": "Hard", "problem_description": "Given n orders, each order consists of a pickup and a delivery service.\nCount all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i). \nSince the answer may be too large, return it modulo 10^9 + 7.\n \nExample 1:\n\nInput: n = 1\nOutput: 1\nExplanation: Unique order (P1, D1), Delivery 1 always is after of Pickup 1.\n\nExample 2:\n\nInput: n = 2\nOutput: 6\nExplanation: All possible orders: \n(P1,P2,D1,D2), (P1,P2,D2,D1), (P1,D1,P2,D2), (P2,P1,D1,D2), (P2,P1,D2,D1) and (P2,D2,P1,D1).\nThis is an invalid order (P1,D2,P2,D1) because Pickup 2 is after of Delivery 2.\n\nExample 3:\n\nInput: n = 3\nOutput: 90\n\n \nConstraints:\n\n1 <= n <= 500\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 90\n assert candidate(n = 250) == 418733499\n assert candidate(n = 100) == 14159051\n assert candidate(n = 4) == 2520\n assert candidate(n = 2) == 6\n assert candidate(n = 20) == 580270580\n assert candidate(n = 1) == 1\n assert candidate(n = 500) == 764678010\n assert candidate(n = 50) == 784760423\n assert candidate(n = 10) == 850728840\n assert candidate(n = 5) == 113400\n assert candidate(n = 12) == 67543367\n assert candidate(n = 125) == 129345050\n assert candidate(n = 110) == 120658916\n assert candidate(n = 300) == 234038968\n assert candidate(n = 60) == 988537746\n assert candidate(n = 30) == 920731808\n assert candidate(n = 450) == 586675271\n assert candidate(n = 80) == 189044563\n assert candidate(n = 175) == 82390790\n assert candidate(n = 495) == 498394413\n assert candidate(n = 8) == 729647433\n assert candidate(n = 18) == 368349166\n assert candidate(n = 75) == 149163518\n assert candidate(n = 350) == 436707893\n assert candidate(n = 150) == 707081203\n assert candidate(n = 15) == 621371750\n assert candidate(n = 200) == 880584563\n assert candidate(n = 400) == 467993882\n assert candidate(n = 499) == 496638171\n assert candidate(n = 55) == 22089728\n assert candidate(n = 25) == 586091532\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countOrders", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countOrders(self, n: int) -> int:", "container": "Solution", "callable": "countOrders", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1360, "task_id": "number-of-days-between-two-dates", "difficulty": "Easy", "problem_description": "Write a program to count the number of days between two dates.\nThe two dates are given as strings, their format is YYYY-MM-DD as shown in the examples.\n \nExample 1:\nInput: date1 = \"2019-06-29\", date2 = \"2019-06-30\"\nOutput: 1\nExample 2:\nInput: date1 = \"2020-01-15\", date2 = \"2019-12-31\"\nOutput: 15\n\n \nConstraints:\n\nThe given dates are valid dates between the years 1971 and 2100.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(date1 = \"2019-02-28\",date2 = \"2019-03-01\") == 1\n assert candidate(date1 = \"2020-01-15\",date2 = \"2019-12-31\") == 15\n assert candidate(date1 = \"2000-03-01\",date2 = \"2000-02-29\") == 1\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-10-02\") == 1\n assert candidate(date1 = \"2022-02-28\",date2 = \"2022-03-01\") == 1\n assert candidate(date1 = \"2012-01-01\",date2 = \"2012-12-31\") == 365\n assert candidate(date1 = \"2021-10-10\",date2 = \"2021-10-10\") == 0\n assert candidate(date1 = \"2021-10-01\",date2 = \"2021-10-10\") == 9\n assert candidate(date1 = \"2020-02-28\",date2 = \"2020-03-01\") == 2\n assert candidate(date1 = \"1971-01-01\",date2 = \"2100-12-31\") == 47481\n assert candidate(date1 = \"2019-06-29\",date2 = \"2019-06-30\") == 1\n assert candidate(date1 = \"2023-01-01\",date2 = \"2023-12-31\") == 364\n assert candidate(date1 = \"2023-01-01\",date2 = \"2023-01-01\") == 0\n assert candidate(date1 = \"2050-06-15\",date2 = \"2050-06-14\") == 1\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-10-01\") == 0\n assert candidate(date1 = \"2016-02-29\",date2 = \"2016-02-28\") == 1\n assert candidate(date1 = \"2000-02-28\",date2 = \"2000-03-01\") == 2\n assert candidate(date1 = \"2023-04-10\",date2 = \"2023-04-01\") == 9\n assert candidate(date1 = \"2000-02-29\",date2 = \"2000-03-01\") == 1\n assert candidate(date1 = \"2100-02-28\",date2 = \"2100-03-01\") == 1\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-09-01\") == 30\n assert candidate(date1 = \"1971-01-02\",date2 = \"1971-01-01\") == 1\n assert candidate(date1 = \"2012-02-29\",date2 = \"2012-03-31\") == 31\n assert candidate(date1 = \"1985-04-12\",date2 = \"2023-07-25\") == 13983\n assert candidate(date1 = \"1972-02-29\",date2 = \"1972-03-01\") == 1\n assert candidate(date1 = \"2017-10-01\",date2 = \"2018-10-01\") == 365\n assert candidate(date1 = \"2023-06-04\",date2 = \"2023-06-04\") == 0\n assert candidate(date1 = \"2004-02-28\",date2 = \"2004-03-01\") == 2\n assert candidate(date1 = \"2021-06-30\",date2 = \"2021-09-30\") == 92\n assert candidate(date1 = \"2004-03-01\",date2 = \"2004-02-29\") == 1\n assert candidate(date1 = \"2025-01-01\",date2 = \"2026-01-01\") == 365\n assert candidate(date1 = \"2024-03-01\",date2 = \"2024-02-29\") == 1\n assert candidate(date1 = \"2023-11-30\",date2 = \"2023-12-01\") == 1\n assert candidate(date1 = \"2100-01-01\",date2 = \"2100-12-31\") == 364\n assert candidate(date1 = \"2020-02-29\",date2 = \"2020-03-01\") == 1\n assert candidate(date1 = \"2015-06-30\",date2 = \"2016-06-30\") == 366\n assert candidate(date1 = \"1980-02-29\",date2 = \"1981-02-28\") == 365\n assert candidate(date1 = \"2099-12-31\",date2 = \"2100-01-01\") == 1\n assert candidate(date1 = \"2023-06-01\",date2 = \"2023-07-01\") == 30\n assert candidate(date1 = \"2100-12-31\",date2 = \"2099-12-31\") == 365\n assert candidate(date1 = \"2020-02-01\",date2 = \"2021-02-01\") == 366\n assert candidate(date1 = \"2000-01-01\",date2 = \"2100-12-31\") == 36889\n assert candidate(date1 = \"2016-02-29\",date2 = \"2017-02-28\") == 365\n assert candidate(date1 = \"2020-01-31\",date2 = \"2020-02-29\") == 29\n assert candidate(date1 = \"1980-02-28\",date2 = \"1980-03-01\") == 2\n assert candidate(date1 = \"2050-11-15\",date2 = \"2050-11-15\") == 0\n assert candidate(date1 = \"2099-12-30\",date2 = \"2100-01-01\") == 2\n assert candidate(date1 = \"2024-11-01\",date2 = \"2023-11-01\") == 366\n assert candidate(date1 = \"2016-06-30\",date2 = \"2016-06-01\") == 29\n assert candidate(date1 = \"2023-02-28\",date2 = \"2024-02-29\") == 366\n assert candidate(date1 = \"2019-01-31\",date2 = \"2019-02-28\") == 28\n assert candidate(date1 = \"2021-01-01\",date2 = \"2021-12-31\") == 364\n assert candidate(date1 = \"2024-02-28\",date2 = \"2024-02-29\") == 1\n assert candidate(date1 = \"2004-12-31\",date2 = \"2005-01-01\") == 1\n assert candidate(date1 = \"2023-06-05\",date2 = \"2023-06-04\") == 1\n assert candidate(date1 = \"2016-02-28\",date2 = \"2016-02-29\") == 1\n assert candidate(date1 = \"2023-04-30\",date2 = \"2023-05-01\") == 1\n assert candidate(date1 = \"2019-12-31\",date2 = \"2020-01-01\") == 1\n assert candidate(date1 = \"2025-12-31\",date2 = \"2026-01-01\") == 1\n assert candidate(date1 = \"2023-06-30\",date2 = \"2023-07-01\") == 1\n assert candidate(date1 = \"2000-02-29\",date2 = \"2004-02-29\") == 1461\n assert candidate(date1 = \"2021-12-31\",date2 = \"2022-01-01\") == 1\n assert candidate(date1 = \"2024-02-28\",date2 = \"2024-03-01\") == 2\n assert candidate(date1 = \"2077-07-04\",date2 = \"2077-07-05\") == 1\n assert candidate(date1 = \"2018-04-30\",date2 = \"2018-05-01\") == 1\n assert candidate(date1 = \"2019-10-15\",date2 = \"2020-10-15\") == 366\n assert candidate(date1 = \"2004-02-29\",date2 = \"2004-03-01\") == 1\n assert candidate(date1 = \"2012-12-31\",date2 = \"2013-01-01\") == 1\n assert candidate(date1 = \"1999-02-28\",date2 = \"1999-03-01\") == 1\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-09-29\") == 2\n assert candidate(date1 = \"2012-02-28\",date2 = \"2012-03-01\") == 2\n assert candidate(date1 = \"2020-03-01\",date2 = \"2020-02-28\") == 2\n assert candidate(date1 = \"2020-02-29\",date2 = \"2019-02-28\") == 366\n assert candidate(date1 = \"2000-01-01\",date2 = \"2000-12-31\") == 365\n assert candidate(date1 = \"2023-10-15\",date2 = \"2024-10-15\") == 366\n assert candidate(date1 = \"2023-08-31\",date2 = \"2023-09-01\") == 1\n assert candidate(date1 = \"2024-02-29\",date2 = \"2024-03-01\") == 1\n assert candidate(date1 = \"2015-06-15\",date2 = \"2015-06-14\") == 1\n assert candidate(date1 = \"2000-01-01\",date2 = \"2004-01-01\") == 1461\n assert candidate(date1 = \"1999-12-31\",date2 = \"1971-01-01\") == 10591\n assert candidate(date1 = \"2024-12-31\",date2 = \"2025-01-01\") == 1\n assert candidate(date1 = \"1980-06-15\",date2 = \"1980-07-15\") == 30\n assert candidate(date1 = \"2023-03-01\",date2 = \"2023-02-28\") == 1\n assert candidate(date1 = \"2023-10-02\",date2 = \"2023-10-01\") == 1\n assert candidate(date1 = \"2020-03-01\",date2 = \"2020-02-29\") == 1\n assert candidate(date1 = \"2050-06-15\",date2 = \"2050-07-15\") == 30\n assert candidate(date1 = \"2021-06-01\",date2 = \"2022-06-01\") == 365\n assert candidate(date1 = \"2023-12-31\",date2 = \"2023-01-01\") == 364\n assert candidate(date1 = \"2019-12-31\",date2 = \"2020-01-31\") == 31\n assert candidate(date1 = \"2023-05-31\",date2 = \"2023-06-01\") == 1\n assert candidate(date1 = \"1971-01-01\",date2 = \"1971-01-02\") == 1\n assert candidate(date1 = \"1996-02-29\",date2 = \"1997-02-28\") == 365\n assert candidate(date1 = \"2023-12-31\",date2 = \"2024-01-01\") == 1\n assert candidate(date1 = \"2019-11-11\",date2 = \"2020-02-29\") == 110\n assert candidate(date1 = \"2100-12-31\",date2 = \"2100-01-01\") == 364\n assert candidate(date1 = \"2023-01-31\",date2 = \"2023-02-28\") == 28\n assert candidate(date1 = \"2100-12-31\",date2 = \"2100-12-30\") == 1\n assert candidate(date1 = \"2023-09-30\",date2 = \"2023-10-01\") == 1\n assert candidate(date1 = \"2023-10-31\",date2 = \"2023-11-01\") == 1\n assert candidate(date1 = \"2023-11-05\",date2 = \"2024-11-05\") == 366\n assert candidate(date1 = \"2019-02-28\",date2 = \"2020-02-29\") == 366\n assert candidate(date1 = \"1972-02-28\",date2 = \"1972-02-29\") == 1\n assert candidate(date1 = \"2023-10-15\",date2 = \"2023-10-15\") == 0\n assert candidate(date1 = \"2019-06-15\",date2 = \"2019-06-14\") == 1\n assert candidate(date1 = \"1996-02-28\",date2 = \"1996-02-29\") == 1\n assert candidate(date1 = \"1996-04-15\",date2 = \"1996-05-15\") == 30\n assert candidate(date1 = \"1980-03-01\",date2 = \"1980-02-29\") == 1\n assert candidate(date1 = \"2023-10-15\",date2 = \"2022-10-15\") == 365\n assert candidate(date1 = \"2024-03-15\",date2 = \"2024-03-01\") == 14\n assert candidate(date1 = \"2024-03-01\",date2 = \"2025-03-01\") == 365\n assert candidate(date1 = \"2023-06-04\",date2 = \"2023-06-05\") == 1\n assert candidate(date1 = \"2022-12-31\",date2 = \"2023-01-01\") == 1\n assert candidate(date1 = \"2000-01-01\",date2 = \"2001-01-01\") == 366\n assert candidate(date1 = \"2023-11-01\",date2 = \"2024-11-01\") == 366\n assert candidate(date1 = \"1971-01-01\",date2 = \"1971-12-31\") == 364\n assert candidate(date1 = \"2050-12-31\",date2 = \"2051-01-01\") == 1\n assert candidate(date1 = \"2000-02-29\",date2 = \"1999-02-28\") == 366\n assert candidate(date1 = \"2004-02-28\",date2 = \"2004-02-29\") == 1\n assert candidate(date1 = \"2020-01-01\",date2 = \"2020-12-31\") == 365\n assert candidate(date1 = \"2012-02-29\",date2 = \"2012-03-01\") == 1\n assert candidate(date1 = \"2024-02-28\",date2 = \"2025-02-28\") == 366\n assert candidate(date1 = \"2012-02-29\",date2 = \"2013-02-28\") == 365\n assert candidate(date1 = \"2020-02-28\",date2 = \"2020-02-29\") == 1\n assert candidate(date1 = \"2016-06-01\",date2 = \"2016-06-30\") == 29\n assert candidate(date1 = \"2008-02-29\",date2 = \"2009-02-28\") == 365\n assert candidate(date1 = \"2023-02-14\",date2 = \"2023-03-14\") == 28\n assert candidate(date1 = \"2023-07-31\",date2 = \"2023-08-01\") == 1\n assert candidate(date1 = \"1987-07-04\",date2 = \"1999-07-04\") == 4383\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-09-30\") == 1\n assert candidate(date1 = \"2016-02-28\",date2 = \"2016-03-01\") == 2\n assert candidate(date1 = \"1980-02-29\",date2 = \"1980-03-01\") == 1\n assert candidate(date1 = \"2025-06-15\",date2 = \"2026-06-15\") == 365\n assert candidate(date1 = \"2023-01-01\",date2 = \"2024-01-01\") == 365\n assert candidate(date1 = \"2023-05-05\",date2 = \"2022-05-05\") == 365\n assert candidate(date1 = \"2023-09-29\",date2 = \"2023-10-01\") == 2\n assert candidate(date1 = \"2016-02-29\",date2 = \"2016-03-01\") == 1\n assert candidate(date1 = \"1999-12-31\",date2 = \"2000-01-01\") == 1\n assert candidate(date1 = \"2019-09-15\",date2 = \"2023-09-15\") == 1461\n"}, "metadata": {"canonical_parameter_names": ["date1", "date2"], "leetcode_dataset_entry_point": "Solution().daysBetweenDates", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def daysBetweenDates(self, date1: str, date2: str) -> int:", "container": "Solution", "callable": "daysBetweenDates", "parameters": [{"name": "date1", "type": "str"}, {"name": "date2", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1361, "task_id": "validate-binary-tree-nodes", "difficulty": "Medium", "problem_description": "You have n binary tree nodes numbered from 0 to n - 1 where node i has two children leftChild[i] and rightChild[i], return true if and only if all the given nodes form exactly one valid binary tree.\nIf node i has no left child then leftChild[i] will equal -1, similarly for the right child.\nNote that the nodes have no values and that we only use the node numbers in this problem.\n \nExample 1:\n\n\nInput: n = 4, leftChild = [1,-1,3,-1], rightChild = [2,-1,-1,-1]\nOutput: true\n\nExample 2:\n\n\nInput: n = 4, leftChild = [1,-1,3,-1], rightChild = [2,3,-1,-1]\nOutput: false\n\nExample 3:\n\n\nInput: n = 2, leftChild = [1,0], rightChild = [-1,-1]\nOutput: false\n\n \nConstraints:\n\nn == leftChild.length == rightChild.length\n1 <= n <= 104\n-1 <= leftChild[i], rightChild[i] <= n - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 2,leftChild = [1, 0],rightChild = [-1, -1]) == False\n assert candidate(n = 3,leftChild = [1, -1, -1],rightChild = [2, -1, -1]) == True\n assert candidate(n = 3,leftChild = [1, 0, -1],rightChild = [-1, -1, -1]) == False\n assert candidate(n = 1,leftChild = [-1],rightChild = [-1]) == True\n assert candidate(n = 4,leftChild = [1, -1, 3, -1],rightChild = [2, -1, -1, -1]) == True\n assert candidate(n = 4,leftChild = [1, -1, 3, -1],rightChild = [2, 3, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, 3, 4, -1],rightChild = [-1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, 5, -1],rightChild = [-1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, -1],rightChild = [4, 5, -1, -1, -1, -1]) == True\n assert candidate(n = 3,leftChild = [1, 2, -1],rightChild = [-1, -1, 1]) == False\n assert candidate(n = 5,leftChild = [1, 3, -1, -1, -1],rightChild = [2, 4, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [3, 4, -1, -1, -1]) == True\n assert candidate(n = 13,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [3, 4, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, 5, -1],rightChild = [-1, -1, -1, -1, 3, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [2, -1, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, -1, 2, 0, -1],rightChild = [-1, 2, -1, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, 3, 4],rightChild = [-1, -1, 5, -1, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, -1, -1, -1],rightChild = [5, 6, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, -1, -1, -1, -1, -1, -1],rightChild = [5, 6, 7, 8, -1, 9, -1, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, 3, -1, -1],rightChild = [-1, -1, -1, 4, 0]) == False\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, 5, -1],rightChild = [2, 3, 4, -1, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, 6, 7, -1],rightChild = [-1, 5, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, 2],rightChild = [-1, 3, 4, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [3, 4, 5, 0, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, -1, -1, -1, -1, -1],rightChild = [-1, -1, -1, 4, -1, 5, 6, 7]) == False\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, -1, -1, -1],rightChild = [-1, -1, 3, 4, 5, 6, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, -1, 6, 7],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, 7, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, -1, -1, -1, -1, -1],rightChild = [-1, 6, 7, -1, -1, 8, -1, -1, 9, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, -1],rightChild = [-1, -1, 4, -1, 5, -1]) == True\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, -1],rightChild = [2, 3, 4, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, -1, -1, -1, 6, -1],rightChild = [3, 4, 5, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 12,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, -1],rightChild = [2, 3, 4, 5, 6, 7, 8, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, -1, -1, 5, 6, 7, 8, 9, -1],rightChild = [-1, 3, 4, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, -1, -1, -1, -1, 7]) == False\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, 5, -1, -1],rightChild = [-1, -1, -1, -1, 6, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, 4, -1],rightChild = [-1, 3, -1, 5, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, 5, 6, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [3, 4, 2, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 3, -1, -1, -1],rightChild = [-1, 2, 4, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, 4, -1, -1],rightChild = [-1, -1, 3, -1, 5, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, 0],rightChild = [-1, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, 3, -1, -1],rightChild = [-1, -1, -1, 4, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, -1, 3, 4, 5, -1, -1],rightChild = [-1, -1, -1, -1, 6, 7, -1, -1]) == False\n assert candidate(n = 11,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [3, 4, 5, 6, 7, 8, 9, -1, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, 4, -1],rightChild = [-1, -1, -1, 5, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, -1, 3, 5, -1, 7, -1, -1],rightChild = [2, 4, 6, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [-1, -1, 3, 4, 5, -1]) == True\n assert candidate(n = 6,leftChild = [1, -1, -1, 2, -1, -1],rightChild = [2, 3, 4, -1, 5, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, -1, -1],rightChild = [-1, -1, -1, -1, 5, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [3, 4, -1, -1, -1, 5]) == False\n assert candidate(n = 8,leftChild = [1, -1, 2, -1, 3, 4, -1, -1],rightChild = [-1, 5, -1, 6, 7, -1, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, -1, 6, 7],rightChild = [3, 4, 5, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, 5, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, 5, -1],rightChild = [-1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, -1, -1, -1],rightChild = [5, -1, 6, -1, 7, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, -1, 3, 5, -1, -1],rightChild = [2, 4, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, -1, 2, -1, 3, -1, 4, -1, 5, -1],rightChild = [2, 3, 4, 5, 6, 7, 8, 9, -1, -1]) == False\n assert candidate(n = 7,leftChild = [1, -1, -1, 5, -1, -1, -1],rightChild = [2, 3, 4, 6, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [3, 4, -1, -1, 5, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, -1, -1, 5, 6],rightChild = [-1, -1, -1, 4, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [-1, 3, -1, 4, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, -1, 4, 5, -1, -1],rightChild = [-1, -1, -1, -1, -1, 6, -1]) == False\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, 4, -1, -1],rightChild = [3, -1, 5, 6, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [-1, 3, 4, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, -1, 2, -1, 3, -1],rightChild = [-1, -1, -1, -1, -1, 4]) == False\n assert candidate(n = 10,leftChild = [1, -1, 3, -1, -1, 6, -1, -1, -1, -1],rightChild = [2, 4, 5, 7, 8, 9, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, -1, -1, -1, 7, -1, 9],rightChild = [-1, -1, -1, -1, 5, 6, 8, -1, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [3, 4, -1, -1, 5, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, -1, -1, -1, 7, -1],rightChild = [-1, -1, -1, -1, 5, 6, 8, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, -1, -1, -1, -1, -1, -1],rightChild = [-1, 5, 6, 7, -1, 8, 9, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, -1],rightChild = [-1, -1, -1, 4, 5, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, -1],rightChild = [2, 3, 4, -1, -1, -1]) == False\n assert candidate(n = 12,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, -1, -1],rightChild = [-1, -1, 5, -1, 3, -1]) == False\n assert candidate(n = 6,leftChild = [1, -1, 3, -1, -1, -1],rightChild = [2, -1, -1, 4, 5, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, -1, -1, 8, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, -1, -1, 9]) == False\n assert candidate(n = 7,leftChild = [1, -1, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, 5, 6, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, -1, 5, -1, -1],rightChild = [4, -1, -1, -1, 6, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, -1, -1, -1],rightChild = [3, 4, 5, 6, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, 3, 4, -1],rightChild = [-1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, 4],rightChild = [2, -1, 3, -1, 5, -1]) == False\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, -1, -1, -1],rightChild = [5, -1, 4, -1, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, 4],rightChild = [-1, -1, -1, 3, -1]) == False\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, -1, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, 8, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, -1, -1, -1, -1],rightChild = [4, 5, 6, -1, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, -1, 3, -1],rightChild = [4, -1, -1, -1, -1]) == False\n assert candidate(n = 7,leftChild = [1, -1, 2, 3, -1, 4, -1],rightChild = [-1, -1, -1, 5, 6, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, -1, -1],rightChild = [7, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, -1, -1, -1, -1, -1, -1],rightChild = [4, 5, 6, 7, 8, -1, -1, -1, -1]) == True\n assert candidate(n = 12,leftChild = [1, 2, -1, 4, -1, 6, -1, -1, 8, -1, -1, -1],rightChild = [-1, 3, 5, -1, 7, -1, 9, -1, 10, -1, 11, -1]) == False\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, -1],rightChild = [2, -1, 3, -1, 4]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, 7, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, -1, 9],rightChild = [2, -1, -1, -1, 5, 6, -1, -1, 9, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, 5, 6, 7, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, -1, -1, -1],rightChild = [-1, -1, -1, -1, 5, 6, 7, -1]) == True\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, -1],rightChild = [2, 3, 4, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, 5, -1, -1],rightChild = [-1, -1, -1, 6, -1, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, -1, 4, -1, -1, 7, -1, -1],rightChild = [-1, 3, -1, -1, 5, 6, -1, -1, 8]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, -1, -1, -1],rightChild = [3, 4, 5, 6, 7, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [2, 4, 3, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, -1, -1, -1, -1, -1, -1, -1, -1],rightChild = [3, 4, 5, 6, 7, 8, 9, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, -1, 2, -1, -1, -1],rightChild = [2, -1, 3, 4, 5, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, 4, -1],rightChild = [-1, -1, 3, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, -1, -1, 3, 4, -1, 5, 6, -1],rightChild = [-1, -1, -1, 3, 5, 6, 7, 8, 9, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, 3, 5, -1],rightChild = [4, -1, -1, -1, 6, -1, 7, -1]) == True\n assert candidate(n = 8,leftChild = [1, -1, -1, 4, -1, -1, -1, -1],rightChild = [2, 3, 5, -1, 6, 7, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, -1, 8, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, -1, -1]) == True\n assert candidate(n = 11,leftChild = [1, 2, -1, 4, 5, 6, -1, 8, -1, -1, -1],rightChild = [-1, 3, -1, 7, -1, -1, 9, -1, 10, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, 6, 7, -1],rightChild = [-1, -1, 3, 4, 5, -1, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, -1, 4, 5, -1, -1, -1, -1],rightChild = [-1, -1, 3, -1, -1, 6, -1, -1, 7]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, 3, 4, 5, 6, -1],rightChild = [-1, -1, -1, -1, -1, 7, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, -1, 6, 7],rightChild = [5, -1, -1, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, -1, -1],rightChild = [5, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, -1, 2, 3, -1, 4, 5, 6, 7, 8],rightChild = [-1, 2, 3, -1, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, -1],rightChild = [-1, 2, 3, 4, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [2, 3, 4, 5, 6, 7, 8, 9, -1, -1]) == False\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, -1, 5, 6],rightChild = [2, -1, 3, 4, -1, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, -1, 6, 7, 8, -1],rightChild = [-1, -1, -1, -1, 9, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, 6, 7, -1],rightChild = [5, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, 5, 6, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, 5, -1, -1],rightChild = [-1, 6, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 4,leftChild = [1, -1, -1, -1],rightChild = [2, 3, 0, -1]) == False\n assert candidate(n = 6,leftChild = [1, -1, 3, -1, -1, 4],rightChild = [2, 5, -1, -1, -1, -1]) == True\n assert candidate(n = 11,leftChild = [1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1],rightChild = [5, 6, 7, 8, 9, -1, 10, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, 4],rightChild = [3, -1, -1, -1, 5, -1]) == False\n assert candidate(n = 6,leftChild = [1, -1, 2, 3, -1, -1],rightChild = [-1, -1, -1, 4, -1, 5]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, 0]) == False\n"}, "metadata": {"canonical_parameter_names": ["n", "leftChild", "rightChild"], "leetcode_dataset_entry_point": "Solution().validateBinaryTreeNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def validateBinaryTreeNodes(self, n: int, leftChild: list[int], rightChild: list[int]) -> bool:", "container": "Solution", "callable": "validateBinaryTreeNodes", "parameters": [{"name": "n", "type": "int"}, {"name": "leftChild", "type": "list[int]"}, {"name": "rightChild", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1362, "task_id": "closest-divisors", "difficulty": "Medium", "problem_description": "Given an integer num, find the closest two integers in absolute difference whose product equals num + 1 or num + 2.\nReturn the two integers in any order.\n \nExample 1:\n\nInput: num = 8\nOutput: [3,3]\nExplanation: For num + 1 = 9, the closest divisors are 3 & 3, for num + 2 = 10, the closest divisors are 2 & 5, hence 3 & 3 is chosen.\n\nExample 2:\n\nInput: num = 123\nOutput: [5,25]\n\nExample 3:\n\nInput: num = 999\nOutput: [40,25]\n\n \nConstraints:\n\n1 <= num <= 10^9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 1000000000) == [23658, 42269]\n assert candidate(num = 999) == [25, 40]\n assert candidate(num = 8) == [3, 3]\n assert candidate(num = 1) == [1, 2]\n assert candidate(num = 100) == [6, 17]\n assert candidate(num = 123) == [5, 25]\n assert candidate(num = 100000000) == [7122, 14041]\n assert candidate(num = 111111111) == [9352, 11881]\n assert candidate(num = 555555555) == [1457, 381301]\n assert candidate(num = 456789) == [170, 2687]\n assert candidate(num = 888888888) == [21847, 40687]\n assert candidate(num = 999999998) == [31250, 32000]\n assert candidate(num = 4) == [2, 3]\n assert candidate(num = 234567890) == [13707, 17113]\n assert candidate(num = 999999997) == [2997, 333667]\n assert candidate(num = 1048575) == [1024, 1024]\n assert candidate(num = 800000000) == [20201, 39602]\n assert candidate(num = 123456789) == [370, 333667]\n assert candidate(num = 300000000) == [49, 6122449]\n assert candidate(num = 104729) == [30, 3491]\n assert candidate(num = 65535) == [256, 256]\n assert candidate(num = 500000000) == [11829, 42269]\n assert candidate(num = 499999999) == [20000, 25000]\n assert candidate(num = 135792468) == [7810, 17387]\n assert candidate(num = 1000000001) == [23658, 42269]\n assert candidate(num = 77777777) == [7213, 10783]\n assert candidate(num = 2000000000) == [38038, 52579]\n assert candidate(num = 100000001) == [7122, 14041]\n assert candidate(num = 499999) == [625, 800]\n assert candidate(num = 319912345) == [12039, 26573]\n assert candidate(num = 345678901) == [10853, 31851]\n assert candidate(num = 456789123) == [17525, 26065]\n assert candidate(num = 789012345) == [24293, 32479]\n assert candidate(num = 987654321) == [1402, 704461]\n assert candidate(num = 1048576) == [17, 61681]\n assert candidate(num = 2) == [2, 2]\n assert candidate(num = 8675309) == [2653, 3270]\n assert candidate(num = 600000001) == [98, 6122449]\n assert candidate(num = 1122334455) == [8, 140291807]\n assert candidate(num = 42424242) == [124, 342131]\n assert candidate(num = 999999999) == [31250, 32000]\n assert candidate(num = 1000000) == [101, 9901]\n assert candidate(num = 49) == [5, 10]\n assert candidate(num = 750000000) == [4727, 158663]\n assert candidate(num = 876543210) == [12652, 69281]\n assert candidate(num = 500000001) == [3362, 148721]\n assert candidate(num = 65536) == [198, 331]\n assert candidate(num = 314159) == [560, 561]\n assert candidate(num = 271828182) == [11, 24711653]\n assert candidate(num = 678901234) == [22686, 29926]\n assert candidate(num = 2147483647) == [32768, 65536]\n assert candidate(num = 3) == [2, 2]\n assert candidate(num = 15) == [4, 4]\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().closestDivisors", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def closestDivisors(self, num: int) -> list[int]:", "container": "Solution", "callable": "closestDivisors", "parameters": [{"name": "num", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1363, "task_id": "largest-multiple-of-three", "difficulty": "Hard", "problem_description": "Given an array of digits digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order. If there is no answer return an empty string.\nSince the answer may not fit in an integer data type, return the answer as a string. Note that the returning answer must not contain unnecessary leading zeros.\n \nExample 1:\n\nInput: digits = [8,1,9]\nOutput: \"981\"\n\nExample 2:\n\nInput: digits = [8,6,7,1,0]\nOutput: \"8760\"\n\nExample 3:\n\nInput: digits = [1]\nOutput: \"\"\n\n \nConstraints:\n\n1 <= digits.length <= 104\n0 <= digits[i] <= 9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(digits = [5, 5, 5]) == \"555\"\n assert candidate(digits = [3, 3, 3]) == \"333\"\n assert candidate(digits = [3, 3, 3, 3, 3]) == \"33333\"\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9876543210\"\n assert candidate(digits = [0, 0, 0]) == \"0\"\n assert candidate(digits = [3, 3, 3, 3]) == \"3333\"\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2]) == \"222222\"\n assert candidate(digits = [3, 6, 9, 1, 8]) == \"98631\"\n assert candidate(digits = [8, 6, 7, 1, 0]) == \"8760\"\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"987654321\"\n assert candidate(digits = [1]) == \"\"\n assert candidate(digits = [1, 4, 7, 8, 5, 2]) == \"875421\"\n assert candidate(digits = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == \"333222111\"\n assert candidate(digits = [3, 6, 9, 3, 6, 9]) == \"996633\"\n assert candidate(digits = [5, 5, 5, 5, 5, 5]) == \"555555\"\n assert candidate(digits = [1, 1, 1, 2, 2, 2]) == \"222111\"\n assert candidate(digits = [1, 4, 7, 2, 5, 8, 3, 6, 9, 0]) == \"9876543210\"\n assert candidate(digits = [2, 2, 2, 2, 2, 2]) == \"222222\"\n assert candidate(digits = [8, 1, 9]) == \"981\"\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9876543210\"\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5]) == \"555555\"\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"111111111\"\n assert candidate(digits = [2, 5, 8, 1, 4, 7, 0, 3, 6, 9]) == \"9876543210\"\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"0\"\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"0\"\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == \"33333222222\"\n assert candidate(digits = [2, 3, 6, 9, 9, 3, 2, 6, 2, 3]) == \"9966333222\"\n assert candidate(digits = [3, 0, 3, 0, 3, 0, 3, 0, 3, 0]) == \"3333300000\"\n assert candidate(digits = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == \"33333333333333333333\"\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"99999999999999999999\"\n assert candidate(digits = [9, 6, 3, 0, 9, 6, 3, 0, 9, 6, 3, 0, 9, 6, 3, 0, 9, 6, 3, 0]) == \"99999666663333300000\"\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 0, 0, 0]) == \"555555000\"\n assert candidate(digits = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == \"444333222111\"\n assert candidate(digits = [2, 5, 8, 2, 6, 3, 6, 9, 0, 5]) == \"98665530\"\n assert candidate(digits = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4]) == \"988776655443210\"\n assert candidate(digits = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == \"333333333222222222111111111\"\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == \"555555555\"\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0]) == \"9876543210000\"\n assert candidate(digits = [7, 8, 5, 2, 3, 6, 1, 4, 9, 0]) == \"9876543210\"\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0]) == \"987654321000000\"\n assert candidate(digits = [1, 4, 7, 1, 4, 7, 1, 4, 7]) == \"777444111\"\n assert candidate(digits = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == \"22222222222222222221\"\n assert candidate(digits = [2, 5, 8, 5, 2, 8, 5, 2, 8]) == \"888555222\"\n assert candidate(digits = [5, 8, 4, 2, 7, 9, 3, 6, 0, 1]) == \"9876543210\"\n assert candidate(digits = [2, 3, 4, 5, 6, 7, 8, 9]) == \"9876543\"\n assert candidate(digits = [7, 8, 9, 4, 5, 6, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4]) == \"9988776655443210\"\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"99887766554433221100\"\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"999888777666555444333222111000\"\n assert candidate(digits = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == \"999888777666555444333222111\"\n assert candidate(digits = [6, 3, 2, 1, 0, 9, 8, 7, 4, 5]) == \"9876543210\"\n assert candidate(digits = [4, 7, 4, 7, 4, 7]) == \"777444\"\n assert candidate(digits = [3, 3, 3, 6, 6, 6, 9, 9, 9, 0, 0, 0]) == \"999666333000\"\n assert candidate(digits = [3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0]) == \"33333333333330000000000000\"\n assert candidate(digits = [5, 2, 5, 2, 5, 2, 5, 2, 5]) == \"555552222\"\n assert candidate(digits = [5, 8, 3, 9, 2, 6, 1, 0]) == \"9865320\"\n assert candidate(digits = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == \"999888777666555444333222111\"\n assert candidate(digits = [2, 4, 6, 8, 0, 0, 0, 0, 0, 0]) == \"864000000\"\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"0\"\n assert candidate(digits = [5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8]) == \"888888888855555555\"\n assert candidate(digits = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == \"777777777777777\"\n assert candidate(digits = [2, 4, 6, 8, 0, 1, 3, 5, 7, 9]) == \"9876543210\"\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"111111111\"\n assert candidate(digits = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == \"777777777777777777777777777\"\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"0\"\n assert candidate(digits = [1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7]) == \"777777777744444444441111111111\"\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"111111111111111111\"\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"111111111111\"\n assert candidate(digits = [1, 4, 7, 2, 5, 8, 3, 6, 9]) == \"987654321\"\n assert candidate(digits = [9, 9, 9, 6, 6, 6, 3, 3, 3, 0, 0, 0]) == \"999666333000\"\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"999999999999999\"\n assert candidate(digits = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == \"777777777\"\n"}, "metadata": {"canonical_parameter_names": ["digits"], "leetcode_dataset_entry_point": "Solution().largestMultipleOfThree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def largestMultipleOfThree(self, digits: list[int]) -> str:", "container": "Solution", "callable": "largestMultipleOfThree", "parameters": [{"name": "digits", "type": "list[int]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1365, "task_id": "how-many-numbers-are-smaller-than-the-current-number", "difficulty": "Easy", "problem_description": "Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of valid j's such that j != i and nums[j] < nums[i].\nReturn the answer in an array.\n \nExample 1:\n\nInput: nums = [8,1,2,2,3]\nOutput: [4,0,1,1,3]\nExplanation: \nFor nums[0]=8 there exist four smaller numbers than it (1, 2, 2 and 3). \nFor nums[1]=1 does not exist any smaller number than it.\nFor nums[2]=2 there exist one smaller number than it (1). \nFor nums[3]=2 there exist one smaller number than it (1). \nFor nums[4]=3 there exist three smaller numbers than it (1, 2 and 2).\n\nExample 2:\n\nInput: nums = [6,5,4,8]\nOutput: [2,1,0,3]\n\nExample 3:\n\nInput: nums = [7,7,7,7]\nOutput: [0,0,0,0]\n\n \nConstraints:\n\n2 <= nums.length <= 500\n0 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [8, 1, 2, 2, 3]) == [4, 0, 1, 1, 3]\n assert candidate(nums = [100, 99, 98, 97, 96]) == [4, 3, 2, 1, 0]\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3]) == [0, 0, 2, 2, 4, 4, 6, 6]\n assert candidate(nums = [100, 99, 98, 97]) == [3, 2, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [3, 0, 1, 2, 5]) == [3, 0, 1, 2, 4]\n assert candidate(nums = [10, 20, 30, 40, 50]) == [0, 1, 2, 3, 4]\n assert candidate(nums = [1, 2, 0, 3, 4]) == [1, 2, 0, 3, 4]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [100, 0, 50, 25, 75]) == [4, 0, 2, 1, 3]\n assert candidate(nums = [3, 0, 6, 1, 5]) == [2, 0, 4, 1, 3]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [6, 5, 4, 8]) == [2, 1, 0, 3]\n assert candidate(nums = [5, 5, 5, 5, 1]) == [1, 1, 1, 1, 0]\n assert candidate(nums = [0, 0, 0, 1]) == [0, 0, 0, 3]\n assert candidate(nums = [5, 4, 3, 2, 1]) == [4, 3, 2, 1, 0]\n assert candidate(nums = [7, 7, 7, 7]) == [0, 0, 0, 0]\n assert candidate(nums = [50, 20, 30, 10, 40]) == [4, 1, 2, 0, 3]\n assert candidate(nums = [3, 3, 3, 3, 3]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [2, 2, 2, 2, 2]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [100, 0, 50, 25, 75, 12, 37, 62, 88, 99]) == [9, 0, 4, 2, 6, 1, 3, 5, 7, 8]\n assert candidate(nums = [0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100]) == [0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [8, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [13, 0, 1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 16, 16, 18, 18]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == [0, 0, 0, 0, 4, 4, 4, 4, 8, 8, 8, 8, 12, 12, 12, 12]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 100, 99, 98, 97]) == [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]\n assert candidate(nums = [5, 8, 3, 9, 1, 7, 4, 6, 2, 0]) == [5, 8, 3, 9, 1, 7, 4, 6, 2, 0]\n assert candidate(nums = [42, 23, 78, 56, 34, 12, 90, 67, 89, 2, 3, 1, 5, 6, 7, 8, 9, 10, 11]) == [13, 11, 16, 14, 12, 10, 18, 15, 17, 1, 2, 0, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [42, 31, 77, 28, 55, 19, 89, 64, 42, 77]) == [3, 2, 7, 1, 5, 0, 9, 6, 3, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\n assert candidate(nums = [25, 50, 75, 100, 25, 50, 75, 100]) == [0, 2, 4, 6, 0, 2, 4, 6]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == [0, 2, 4, 6, 8, 10, 0, 2, 4, 6, 8, 10]\n assert candidate(nums = [47, 53, 100, 42, 55, 80, 86, 29, 93, 37, 48, 51, 21, 79, 68, 94, 3, 8, 58, 52]) == [6, 10, 19, 5, 11, 15, 16, 3, 17, 4, 7, 8, 2, 14, 13, 18, 0, 1, 12, 9]\n assert candidate(nums = [100, 99, 98, 97, 96, 95]) == [5, 4, 3, 2, 1, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [2, 1, 0, 3, 4, 9, 8, 7, 6, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [2, 1, 0, 3, 4, 9, 8, 7, 6, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 3, 1, 2, 4, 6, 8, 7, 9, 10]) == [4, 2, 0, 1, 3, 5, 7, 6, 8, 9]\n assert candidate(nums = [34, 67, 23, 89, 23, 67, 34, 23, 67, 89]) == [3, 5, 0, 8, 0, 5, 3, 0, 5, 8]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [50, 25, 75, 25, 50, 75, 50, 25, 75, 50]) == [3, 0, 7, 0, 3, 7, 3, 0, 7, 3]\n assert candidate(nums = [50, 25, 75, 12, 37, 88, 63, 49, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [14, 11, 16, 10, 12, 17, 15, 13, 18, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [3, 1, 2, 4, 5, 9, 8, 7, 6, 0]) == [3, 1, 2, 4, 5, 9, 8, 7, 6, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [0, 0, 2, 2, 4, 4, 6, 6, 8, 8]\n assert candidate(nums = [50, 24, 7, 9, 12, 33, 18, 42, 60, 5]) == [8, 5, 1, 2, 3, 6, 4, 7, 9, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [0, 0, 2, 2, 4, 4, 6, 6, 8, 8]\n assert candidate(nums = [50, 20, 10, 30, 40, 5, 15, 25, 35, 45]) == [9, 3, 1, 5, 7, 0, 2, 4, 6, 8]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16]\n assert candidate(nums = [3, 3, 3, 2, 2, 1, 1, 0, 0, 0]) == [7, 7, 7, 5, 5, 3, 3, 0, 0, 0]\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60]) == [9, 7, 5, 3, 1, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == [0, 0, 0, 0, 4, 4, 4, 4, 8, 8, 8, 8]\n assert candidate(nums = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11]) == [2, 4, 6, 8, 1, 3, 5, 7, 9, 0]\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 2, 2, 2, 2]) == [3, 3, 3, 0, 0, 0, 6, 6, 6, 6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == [0, 2, 1, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 0, 0, 0, 0]) == [9, 8, 7, 6, 5, 0, 0, 0, 0, 0]\n assert candidate(nums = [100, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [0, 100, 50, 25, 75, 20, 80, 30, 60, 40, 90]) == [0, 10, 5, 2, 7, 1, 8, 3, 6, 4, 9]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [23, 45, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90]) == [4, 9, 0, 5, 10, 14, 18, 0, 5, 10, 14, 18, 0, 5, 10, 14, 18, 0, 5, 10, 14, 18]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5]) == [13, 11, 9, 7, 5, 4, 3, 2, 1, 0, 13, 11, 9, 7, 5]\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == [0, 0, 2, 2, 4, 4, 6, 6, 8, 8]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [50, 20, 30, 10, 40]) == [4, 1, 2, 0, 3]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0]) == [15, 12, 9, 6, 3, 0, 15, 12, 9, 6, 3, 0, 15, 12, 9, 6, 3, 0]\n assert candidate(nums = [10, 20, 20, 10, 30, 30, 20, 10, 40, 40, 50, 50, 60, 60, 70]) == [0, 3, 3, 0, 6, 6, 3, 0, 8, 8, 10, 10, 12, 12, 14]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [50, 25, 75, 25, 75, 50, 25, 75, 50, 25]) == [4, 0, 7, 0, 7, 4, 0, 7, 4, 0]\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10]) == [0, 2, 1, 3, 5, 4, 6, 8, 7, 9]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [49, 38, 27, 16, 5, 48, 37, 26, 15, 4, 47, 36, 25, 14, 3, 46, 35, 24, 13, 2, 45, 34, 23, 12, 1, 44, 33, 22, 11, 0]) == [29, 23, 17, 11, 5, 28, 22, 16, 10, 4, 27, 21, 15, 9, 3, 26, 20, 14, 8, 2, 25, 19, 13, 7, 1, 24, 18, 12, 6, 0]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == [29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [10, 20, 10, 30, 40, 50, 10]) == [0, 3, 0, 4, 5, 6, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 0, 3, 6, 9, 12, 15, 18, 21, 24, 27]\n assert candidate(nums = [33, 10, 55, 72, 21, 45, 66, 100, 33, 55, 72, 21, 45, 66, 100, 33, 55, 72, 21, 45, 66, 100]) == [4, 0, 10, 16, 1, 7, 13, 19, 4, 10, 16, 1, 7, 13, 19, 4, 10, 16, 1, 7, 13, 19]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4]) == [18, 14, 10, 6, 2, 0, 2, 6, 10, 14, 18, 14, 10, 6, 2, 0, 2, 6, 10, 14]\n assert candidate(nums = [34, 23, 56, 12, 78, 45, 90, 67, 34, 23, 12, 56, 78, 45, 67, 90]) == [4, 2, 8, 0, 12, 6, 14, 10, 4, 2, 0, 8, 12, 6, 10, 14]\n assert candidate(nums = [42, 32, 55, 11, 22, 33, 44, 55, 66, 77, 88, 99]) == [4, 2, 6, 0, 1, 3, 5, 6, 8, 9, 10, 11]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [0, 5, 0, 5, 0, 5, 0, 5, 0, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == [0, 2, 4, 6, 8, 10, 11, 12, 13, 14, 0, 2, 4, 6, 8]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == [0, 19, 1, 18, 2, 17, 3, 16, 4, 15, 5, 14, 6, 13, 7, 12, 8, 11, 9, 10]\n assert candidate(nums = [45, 67, 89, 23, 34, 56, 78, 90, 12, 34, 56, 78, 90, 23, 45, 67, 89]) == [5, 9, 13, 1, 3, 7, 11, 15, 0, 3, 7, 11, 15, 1, 5, 9, 13]\n assert candidate(nums = [10, 20, 10, 20, 30, 40, 50]) == [0, 2, 0, 2, 4, 5, 6]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().smallerNumbersThanCurrent", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def smallerNumbersThanCurrent(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "smallerNumbersThanCurrent", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1366, "task_id": "rank-teams-by-votes", "difficulty": "Medium", "problem_description": "In a special ranking system, each voter gives a rank from highest to lowest to all teams participating in the competition.\nThe ordering of teams is decided by who received the most position-one votes. If two or more teams tie in the first position, we consider the second position to resolve the conflict, if they tie again, we continue this process until the ties are resolved. If two or more teams are still tied after considering all positions, we rank them alphabetically based on their team letter.\nYou are given an array of strings votes which is the votes of all voters in the ranking systems. Sort all teams according to the ranking system described above.\nReturn a string of all teams sorted by the ranking system.\n \nExample 1:\n\nInput: votes = [\"ABC\",\"ACB\",\"ABC\",\"ACB\",\"ACB\"]\nOutput: \"ACB\"\nExplanation: \nTeam A was ranked first place by 5 voters. No other team was voted as first place, so team A is the first team.\nTeam B was ranked second by 2 voters and ranked third by 3 voters.\nTeam C was ranked second by 3 voters and ranked third by 2 voters.\nAs most of the voters ranked C second, team C is the second team, and team B is the third.\n\nExample 2:\n\nInput: votes = [\"WXYZ\",\"XYZW\"]\nOutput: \"XWYZ\"\nExplanation:\nX is the winner due to the tie-breaking rule. X has the same votes as W for the first position, but X has one vote in the second position, while W does not have any votes in the second position. \n\nExample 3:\n\nInput: votes = [\"ZMNAGUEDSJYLBOPHRQICWFXTVK\"]\nOutput: \"ZMNAGUEDSJYLBOPHRQICWFXTVK\"\nExplanation: Only one voter, so their votes are used for the ranking.\n\n \nConstraints:\n\n1 <= votes.length <= 1000\n1 <= votes[i].length <= 26\nvotes[i].length == votes[j].length for 0 <= i, j < votes.length.\nvotes[i][j] is an English uppercase letter.\nAll characters of votes[i] are unique.\nAll the characters that occur in votes[0] also occur in votes[j] where 1 <= j < votes.length.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(votes = ['ABC', 'ACB', 'ABC', 'ACB', 'ACB']) == \"ACB\"\n assert candidate(votes = ['WXYZ', 'XYZW']) == \"XWYZ\"\n assert candidate(votes = ['BCA', 'CAB', 'ACB', 'BAC', 'CBA', 'ABC']) == \"ABC\"\n assert candidate(votes = ['A', 'B', 'C', 'D', 'E']) == \"ABCDE\"\n assert candidate(votes = ['ABCDEF', 'BCDEFA', 'CDEFAB', 'DEFABC', 'EFABCD', 'FABCDE']) == \"ABCDEF\"\n assert candidate(votes = ['BCA', 'CAB', 'CBA', 'ABC', 'ACB', 'BAC']) == \"ABC\"\n assert candidate(votes = ['A', 'A', 'A', 'A', 'A']) == \"A\"\n assert candidate(votes = ['BCA', 'CAB', 'ACB', 'ABC', 'ABC', 'ACB']) == \"ACB\"\n assert candidate(votes = ['A', 'A', 'A', 'A']) == \"A\"\n assert candidate(votes = ['ZMNAGUEDSJYLBOPHRQICWFXTVK']) == \"ZMNAGUEDSJYLBOPHRQICWFXTVK\"\n assert candidate(votes = ['RGB', 'GBR', 'BRG', 'RBB', 'BBR', 'RBB', 'RRG', 'GRR']) == \"RBG\"\n assert candidate(votes = ['ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ZYXWVUTSRQPONMLKJIHGFEDCBA']) == \"AZBYCXDWEVFUGTHSIRJQKPLOMN\"\n assert candidate(votes = ['BCA', 'CAB', 'ABC', 'ACB', 'BAC']) == \"ABC\"\n assert candidate(votes = ['GHIJKL', 'LKHGJI', 'HKLGJI', 'IGJLKH', 'JIGKHL', 'KGLHJI', 'GHILJK']) == \"GHKILJ\"\n assert candidate(votes = ['LMNO', 'NOLM', 'OLMN', 'MNLO', 'LNMO', 'ONML', 'MLOL', 'LONM', 'MOLN', 'NOML', 'OMNL', 'LMON', 'NLMO', 'OMLN', 'LMNO', 'NOLM', 'OLMN', 'MNLO', 'LNMO', 'ONML', 'MLOL', 'LONM', 'MOLN', 'NOML', 'OMNL']) == \"OLMN\"\n assert candidate(votes = ['ABCDEFGH', 'BCDEFGHA', 'CDEFGHAB', 'DEFGHABC', 'EFGHABCD', 'FGHABCDE', 'GHABCDEF', 'HABCDEFG']) == \"ABCDEFGH\"\n assert candidate(votes = ['ABCDEFG', 'GFEDCBA', 'FBCDEAG', 'BCDEAFG', 'CDEABGF', 'DEABCFG', 'EABCDFG']) == \"BCEDAFG\"\n assert candidate(votes = ['ABCD', 'BCDA', 'CDAB', 'DABC', 'ABCD', 'ABCD']) == \"ABCD\"\n assert candidate(votes = ['QWOP', 'WOPQ', 'OPQW', 'PQWO', 'QWPO', 'WPOQ', 'OPWQ', 'POWQ']) == \"PWOQ\"\n assert candidate(votes = ['QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ']) == \"MQNWBERVCTXYUZILKOJPAHGSDF\"\n assert candidate(votes = ['MNO', 'OMN', 'NMO', 'MON', 'NMN', 'OMM', 'NMM', 'MMM']) == \"MNO\"\n assert candidate(votes = ['UVWXYZ', 'VWXYZU', 'WXYZUV', 'XYZUVW', 'YZUVWX', 'ZUVWXY', 'UVWXYZ', 'VWXYZU', 'WXYZUV', 'XYZUVW', 'YZUVWX', 'ZUVWXY', 'UVWXYZ', 'VWXYZU', 'WXYZUV', 'XYZUVW', 'YZUVWX', 'ZUVWXY', 'UVWXYZ']) == \"UVWXYZ\"\n assert candidate(votes = ['MATH', 'TEAM', 'META', 'HATE', 'HEAT', 'MATE', 'TAME', 'TIME']) == \"TMHAEI\"\n assert candidate(votes = ['ZYX', 'XYZ', 'YZX', 'XZY', 'YXZ', 'ZXY']) == \"XYZ\"\n assert candidate(votes = ['PQRST', 'QPRST', 'RQPST', 'SPQRT', 'TQPRS', 'PQRST', 'QPRST', 'RQPST', 'SPQRT', 'TQPRS', 'PQRST', 'QPRST', 'RQPST', 'SPQRT', 'TQPRS']) == \"QPRST\"\n assert candidate(votes = ['ABCD', 'BCDA', 'CDAB', 'DABC', 'ACBD']) == \"ACBD\"\n assert candidate(votes = ['PQR', 'QPR', 'RQP', 'PRQ', 'RPQ', 'QRP', 'PQR', 'RQP', 'QRP', 'PRQ']) == \"PQR\"\n assert candidate(votes = ['ZYX', 'YZX', 'XZY', 'XYZ', 'YXZ', 'ZXY', 'YZX', 'ZXY']) == \"ZYX\"\n assert candidate(votes = ['ABCDE', 'EDCBA', 'CBADE', 'BCADE', 'DECAB']) == \"BCDEA\"\n assert candidate(votes = ['ABC', 'BAC', 'BCA', 'CAB', 'CBA', 'ACB', 'BAC', 'CAB', 'CBA', 'BCA', 'ACB', 'CAB', 'CBA', 'BCA', 'ACB', 'BAC', 'CAB', 'CBA', 'BCA', 'ACB', 'BAC', 'CAB', 'CBA', 'BCA', 'ACB']) == \"CBA\"\n assert candidate(votes = ['ABCD', 'BCDA', 'CDAB', 'DABC']) == \"ABCD\"\n assert candidate(votes = ['AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA']) == \"AB\"\n assert candidate(votes = ['QWERTYUIOPASDFGHJKLZXCVBNM', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'QWERTYUIOPASDFGHJKLZXCVBNM']) == \"QWERTYUIOPASDFGHJKLZXCVBNM\"\n assert candidate(votes = ['XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY']) == \"XYZ\"\n assert candidate(votes = ['EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG']) == \"IHGFEJ\"\n assert candidate(votes = ['XYZ', 'YZX', 'ZXY', 'YXZ', 'XZY', 'ZYX', 'XYZ', 'YZX']) == \"YXZ\"\n assert candidate(votes = ['AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA']) == \"AB\"\n assert candidate(votes = ['TLI', 'LIT', 'ITL', 'TIL', 'ILT', 'LTI', 'TIL', 'LTI', 'ILT', 'TLI']) == \"TLI\"\n assert candidate(votes = ['QWERTY', 'QWRETY', 'QWRTEY', 'QWRTYE', 'QWRYTE']) == \"QWRETY\"\n assert candidate(votes = ['ZEBRA', 'BRACE', 'BEZAR', 'RABZE', 'AREBZ', 'ZERBA']) == \"BZRAEC\"\n assert candidate(votes = ['ZYX', 'YXZ', 'XYZ', 'YZX', 'XZY', 'ZXY']) == \"XYZ\"\n assert candidate(votes = ['GHIJK', 'HIJKG', 'IJKGH', 'JKGHI', 'KGIJH', 'GHIJK', 'HGIJK', 'IGHJK', 'JGIHK', 'KGIJH']) == \"GHIJK\"\n assert candidate(votes = ['WXYZ', 'YZWX', 'ZWXY', 'XWYZ', 'WZYX', 'XYZW']) == \"WXZY\"\n assert candidate(votes = ['PQRSTU', 'QPRSTU', 'QRPTSU', 'QRSTUP', 'QPRTSU', 'QTRPSU', 'QTRSPU', 'QTSRPU', 'QTSPUR', 'QTPRSU', 'QTPSUR', 'QTUSPR', 'QTUSRP', 'QTURPS', 'QTURSP', 'QTUPRS', 'QTUPSR', 'QTRSPU', 'QTSRPU', 'QTRPUS', 'QTRUPS', 'QTPRSU', 'QTPSUR', 'QTUSPR', 'QTURPS', 'QTURSP', 'QTUPRS', 'QTUPSR']) == \"QPTRUS\"\n assert candidate(votes = ['ABCD', 'DCBA', 'BCAD', 'CADB', 'ACDB', 'DABC', 'BCDA']) == \"ABDC\"\n assert candidate(votes = ['LOVE', 'VOTE', 'LEVO', 'OVEL', 'VOLE', 'ELOV']) == \"VLOET\"\n assert candidate(votes = ['LMNO', 'MLON', 'OLNM', 'NOLM', 'ONML', 'MNLO', 'LOMN', 'LONM', 'NMLO', 'OMNL', 'NOLM', 'OLNM']) == \"OLNM\"\n assert candidate(votes = ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'C', 'C', 'C', 'C', 'D', 'D', 'D', 'D', 'E', 'E', 'E', 'E', 'F', 'F', 'F', 'F', 'G', 'G', 'G', 'G', 'H', 'H', 'H', 'H', 'I', 'I', 'I', 'I', 'J', 'J', 'J', 'J', 'K', 'K', 'K', 'K', 'L', 'L', 'L', 'L', 'M', 'M', 'M', 'M', 'N', 'N', 'N', 'N', 'O', 'O', 'O', 'O', 'P', 'P', 'P', 'P', 'Q', 'Q', 'Q', 'Q', 'R', 'R', 'R', 'R', 'S', 'S', 'S', 'S', 'T', 'T', 'T', 'T', 'U', 'U', 'U', 'U', 'V', 'V', 'V', 'V', 'W', 'W', 'W', 'W', 'X', 'X', 'X', 'X', 'Y', 'Y', 'Y', 'Y', 'Z', 'Z', 'Z', 'Z']) == \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(votes = ['ABCDEF', 'FEDCBA', 'DEFABC', 'BCDAFE', 'CBAFED', 'AFECBD', 'BDFECA']) == \"BAFDCE\"\n assert candidate(votes = ['AC', 'CA', 'AC', 'CA', 'AC', 'CA', 'AC', 'CA', 'AC', 'CA']) == \"AC\"\n assert candidate(votes = ['LMNO', 'MLNO', 'NOLM', 'OLMN', 'NOML', 'OMNL', 'LONM', 'OLNM', 'MOLN', 'LNOM', 'LOMN', 'MONL', 'NLOM', 'LNMO', 'LNMN', 'OMLN', 'NOLM', 'NLMO', 'MOLN', 'ONLM', 'OMNL', 'LONM', 'OLNM', 'MOLN', 'LNOM', 'LOMN', 'MONL', 'NLOM', 'LNMO', 'LNMN']) == \"LONM\"\n assert candidate(votes = ['PQRST', 'QPRST', 'RSPTQ', 'TRPQS', 'SQPTR', 'PRQST', 'PQRST', 'RQPTS', 'TQRS', 'SPRQT']) == \"PRSTQ\"\n assert candidate(votes = ['PQR', 'QRP', 'RPQ', 'PRQ', 'QPR', 'RQP', 'PQR', 'QRP', 'RPQ', 'PRQ', 'QPR', 'RQP']) == \"PQR\"\n assert candidate(votes = ['ABCDE', 'ACBDE', 'CABDE', 'BCADE', 'DCABE']) == \"ACBDE\"\n assert candidate(votes = ['XYZ', 'YXZ', 'YZX', 'ZXY', 'ZYX', 'XZY', 'YZX', 'ZYX', 'XYZ', 'YXZ', 'XZY', 'XYZ']) == \"XYZ\"\n assert candidate(votes = ['FGHIJK', 'GHIJKF', 'HIJKFG', 'IJKFGH', 'JKFGHI', 'KFGHIJ', 'FGHIJK', 'GHIJKF', 'HIJKFG', 'IJKFGH']) == \"IHGFJK\"\n assert candidate(votes = ['ACBD', 'BDAC', 'CDAB', 'DABC', 'ABCD', 'BACD', 'CABD', 'DABC', 'ACDB', 'BCDA']) == \"ABCD\"\n assert candidate(votes = ['ABCD', 'ABDC', 'ACBD', 'ACDB', 'ADBC', 'ADCB', 'BACD', 'BADC', 'BCAD', 'BCDA', 'BDAC', 'BDCA', 'CABD', 'CADB', 'CBAD', 'CBDA', 'CDAB', 'CDBA', 'DABC', 'DACB', 'DBAC', 'DBCA', 'DCAB', 'DCBA']) == \"ABCD\"\n assert candidate(votes = ['UVWX', 'VWXU', 'WXUV', 'XUVW', 'UVWX', 'VWXU', 'WXUV', 'XUVW', 'UVWX', 'VWXU']) == \"VUWX\"\n assert candidate(votes = ['ZR', 'RZ', 'ZR', 'RZ', 'ZR']) == \"ZR\"\n assert candidate(votes = ['SUNNY', 'UNNYS', 'NUNYS', 'NNYSU', 'NUYNS', 'USNNY', 'NSUNY']) == \"NUSY\"\n assert candidate(votes = ['HELLO', 'OLLEH', 'LOHEL', 'LLOEH', 'HLOEL', 'ELOHL', 'ELLOH', 'OLEHL', 'LELOH', 'OHELL']) == \"LOEH\"\n assert candidate(votes = ['ACB', 'BAC', 'CBA', 'BCA', 'CAB', 'ACB', 'BAC', 'CBA', 'BCA', 'CAB', 'ACB', 'BAC', 'CBA']) == \"CBA\"\n assert candidate(votes = ['EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'JEFGH', 'EFGIH', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'JEFGH', 'EFGIH', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'JEFGH', 'EFGIH', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'JEFGH', 'EFGIH']) == \"EFGIJH\"\n assert candidate(votes = ['QWRTY', 'QWYRT', 'WQRTY', 'WQYRT', 'RTQWY', 'RTYQW', 'YRQWT', 'YRTQW', 'TWQRY', 'TYWQR']) == \"WQRTY\"\n assert candidate(votes = ['PYTHON', 'TYHONP', 'YHTNPO', 'HNOTYP', 'NOTYHP', 'OTHNYP']) == \"YTHONP\"\n assert candidate(votes = ['MNO', 'NOM', 'OMN', 'MON', 'NMO', 'OMN', 'MNO']) == \"MNO\"\n assert candidate(votes = ['MNO', 'OMN', 'NMO', 'MON', 'NOM', 'OMN']) == \"MON\"\n assert candidate(votes = ['ABCD', 'DCBA', 'BCDA', 'CBAD', 'ADBC', 'BDAC', 'ACBD', 'CADB', 'DABC', 'DBCA']) == \"ADBC\"\n assert candidate(votes = ['FGHIJ', 'IJFGH', 'JFGHI', 'HGIJF', 'IGHFJ', 'GFHIJ']) == \"IGFJH\"\n assert candidate(votes = ['VWXYZ', 'YZWXV', 'ZWXYV', 'XWYZV', 'WZYXV', 'XYZWV', 'VWYZX', 'WVXYZ', 'XYZVW', 'YZXVW', 'ZXYVW', 'VZWXY', 'WXYVZ', 'XVZXY', 'YZVWX', 'ZVXYW', 'VXYWZ', 'XYWVZ', 'YWVZX', 'YVZXW', 'VZXWY', 'ZXWYV', 'XWYVZ']) == \"XVYZW\"\n assert candidate(votes = ['ABCDE', 'ABCDE', 'ABCDE', 'EABCD', 'DEABC']) == \"AEDBC\"\n assert candidate(votes = ['UV', 'VU', 'UV', 'UV', 'VU', 'UV', 'UV', 'VU', 'VU', 'VU', 'UV', 'VU', 'VU', 'VU', 'VU', 'VU', 'VU', 'VU', 'VU', 'VU']) == \"VU\"\n"}, "metadata": {"canonical_parameter_names": ["votes"], "leetcode_dataset_entry_point": "Solution().rankTeams", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def rankTeams(self, votes: list[str]) -> str:", "container": "Solution", "callable": "rankTeams", "parameters": [{"name": "votes", "type": "list[str]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1367, "task_id": "linked-list-in-binary-tree", "difficulty": "Medium", "problem_description": "Given a binary tree root and a linked list with head as the first node. \nReturn True if all the elements in the linked list starting from the head correspond to some downward path connected in the binary tree otherwise return False.\nIn this context downward path means a path that starts at some node and goes downwards.\n \nExample 1:\n\n\nInput: head = [4,2,8], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3]\nOutput: true\nExplanation: Nodes in blue form a subpath in the binary Tree. \n\nExample 2:\n\n\nInput: head = [1,4,2,6], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3]\nOutput: true\n\nExample 3:\n\nInput: head = [1,4,2,6,8], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3]\nOutput: false\nExplanation: There is no path in the binary tree that contains all the elements of the linked list from head.\n\n \nConstraints:\n\nThe number of nodes in the tree will be in the range [1, 2500].\nThe number of nodes in the list will be in the range [1, 100].\n1 <= Node.val <= 100 for each node in the linked list and binary tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(head = list_node([4, 2, 8]),root = tree_node([1, 4, 4, None, 2, 2, None, 1, None, 6, 8, None, None, None, None, 1, 3])) == True\n assert candidate(head = list_node([1, 4, 2, 6]),root = tree_node([1, 4, 4, None, 2, 2, None, 1, None, 6, 8, None, None, None, None, 1, 3])) == True\n assert candidate(head = list_node([1, 4, 2, 6, 8]),root = tree_node([1, 4, 4, None, 2, 2, None, 1, None, 6, 8, None, None, None, None, 1, 3])) == False\n assert candidate(head = list_node([10, 1, 3, 7]),root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, None, 2, None, 4, None, 6, None, 14, None, 17])) == False\n assert candidate(head = list_node([7, 8, 9]),root = tree_node([5, 4, 1, None, None, 7, 8, None, None, None, 9])) == False\n assert candidate(head = list_node([20, 21, 22, 23, 24, 25]),root = tree_node([10, 15, 20, 12, 16, 18, 22, 8, 13, 17, 19, 21, 23, 7, 9, 11, 14, 24, 25])) == False\n assert candidate(head = list_node([1, 1, 1, 1, 1]),root = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == True\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([1, 3, 5, 7, 9]),root = tree_node([1, None, 3, None, 5, None, 7, None, 9])) == True\n assert candidate(head = list_node([1, 3, 5, 7, 9]),root = tree_node([1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9])) == False\n assert candidate(head = list_node([9, 8, 7, 6, 5]),root = tree_node([9, 8, 7, 6, 5, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([2, 1, 3]),root = tree_node([1, 2, 3, None, None, 4, 5])) == False\n assert candidate(head = list_node([3, 2, 1]),root = tree_node([3, 2, 1, None, None, 2, None, None, 1])) == False\n assert candidate(head = list_node([5, 4, 3, 2, 1]),root = tree_node([5, 4, 3, 2, 1, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([1, 2, 3, 4, 5]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == False\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7]),root = tree_node([1, 2, 3, 4, 5, 6, 7])) == False\n assert candidate(head = list_node([1, 2, 3, 4, 5]),root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == True\n assert candidate(head = list_node([3, 6, 9, 12]),root = tree_node([3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45])) == False\n assert candidate(head = list_node([8, 9, 10, 11]),root = tree_node([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == False\n assert candidate(head = list_node([10, 9, 8]),root = tree_node([10, 9, 8, 8, None, 9, 8, 7, None, 8, None, 6, 8, None, 8, 5, None, 8, None, 8, 4, None, 8, None, 8, 3, None, 8, None, 8, 2, None, 8, None, 8, 1, None, 8])) == True\n assert candidate(head = list_node([3, 3, 3]),root = tree_node([3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3])) == True\n assert candidate(head = list_node([15, 16, 17, 18, 19, 20]),root = tree_node([10, 15, 20, 12, 16, 18, 22, 8, 13, 17, 19, 21, 23, 7, 9, 11, 14, 24, 25])) == False\n assert candidate(head = list_node([5, 6, 7]),root = tree_node([5, 3, 6, 2, 4, None, 7, None, None, 6, None, None, None, None, 7])) == True\n assert candidate(head = list_node([4, 2, 1, 3]),root = tree_node([4, 2, 1, None, None, 3, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([2, 1, 3]),root = tree_node([1, 2, 3, 2, 1, None, 4, None, None, 1, None, None, 3, None, None, 2, None, None, 1])) == False\n assert candidate(head = list_node([5, 8, 9, 7, 3]),root = tree_node([5, 3, 8, 5, 8, 9, 1, None, 7, None, None, None, 9, None, None, None, 7, None, None, None, 3, None, None, None, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([10, 20, 30, 40]),root = tree_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, None, None, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250])) == False\n assert candidate(head = list_node([8, 7, 6]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),root = tree_node([25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == False\n assert candidate(head = list_node([7, 1, 5]),root = tree_node([3, 7, 7, None, 1, None, None, None, 5, None, 6, None, None, 8])) == True\n assert candidate(head = list_node([10, 5, 3]),root = tree_node([10, 5, 10, 5, 3, 10, 10, None, None, 3, None, None, 10, 10, 10, 3, None, None, 10, None, None, None, None, 10, 10, None, None, None, None, 10])) == True\n assert candidate(head = list_node([1, 2, 3, 4, 5]),root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7])) == False\n assert candidate(head = list_node([5, 3, 8, 6]),root = tree_node([5, 3, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6])) == False\n assert candidate(head = list_node([3, 1, 2]),root = tree_node([1, None, 2, None, 3])) == False\n assert candidate(head = list_node([2, 3, 4]),root = tree_node([5, 2, 1, None, 3, None, 4, None, None, None, 6, 7, 8])) == False\n assert candidate(head = list_node([2, 5, 6, 7]),root = tree_node([2, 1, 3, 2, 5, None, None, 2, 5, None, None, None, None, 6, None, None, None, None, 7, None, None, None, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([3, 4, 5, 6]),root = tree_node([1, None, 3, None, 4, None, 5, None, 6, None, 7])) == True\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1]),root = tree_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20])) == False\n assert candidate(head = list_node([10, 20, 30, 40]),root = tree_node([10, 5, 10, None, None, 20, None, None, 30, None, 40])) == True\n assert candidate(head = list_node([1, 2, 3, 4, 5]),root = tree_node([1, 2, 1, 2, 3, None, None, 2, 3, None, None, None, None, None, None, None, None, None, 4, None, None, None, None, None, None, None, None, 5])) == False\n assert candidate(head = list_node([7, 8, 9]),root = tree_node([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4])) == False\n assert candidate(head = list_node([10, 20, 30, 40, 50]),root = tree_node([10, 20, 30, None, 40, None, 50, None, 60, None, 70])) == False\n assert candidate(head = list_node([1, 2, 3, 2, 1]),root = tree_node([1, 2, 3, 2, 1, None, None, 2, None, 1, None, None, 1, None, None, 1, None, None, 1, None, None, 1, None, None, 1])) == False\n assert candidate(head = list_node([10, 9, 8, 7]),root = tree_node([5, 3, 8, 10, 9, 6, 7, None, None, None, None, None, 8, None, None])) == False\n assert candidate(head = list_node([100, 99, 98, 97, 96]),root = tree_node([100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71])) == False\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])) == False\n assert candidate(head = list_node([11, 3, 4]),root = tree_node([11, 3, 14, 3, 4, 9, 14, 3, 4, None, None, 9, 14, None, None, None, None, 4, None, None, None, None, None, None, 4, None, None, None, None, None, 4, None, None, None])) == True\n assert candidate(head = list_node([1, 1, 1, 1, 1]),root = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == True\n assert candidate(head = list_node([1]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == True\n assert candidate(head = list_node([5, 6, 7, 8, 9]),root = tree_node([1, 5, 6, 7, 8, 9, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([3, 7, 9]),root = tree_node([5, 3, 8, 7, 9, None, None, 2, None, None, None, 6, None])) == False\n assert candidate(head = list_node([1, 3, 5, 7, 9, 11]),root = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59])) == False\n assert candidate(head = list_node([5, 5, 5]),root = tree_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])) == True\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == False\n assert candidate(head = list_node([2, 4, 6, 8, 10]),root = tree_node([2, None, 4, None, 6, None, 8, None, 10])) == True\n assert candidate(head = list_node([1, 2, 3, 4, 5]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == False\n assert candidate(head = list_node([6, 7, 8, 9]),root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 8, 9])) == False\n assert candidate(head = list_node([7, 3, 1]),root = tree_node([5, 7, 6, 3, None, None, 1, None, None, None, None])) == False\n assert candidate(head = list_node([5, 6, 7, 8, 9]),root = tree_node([3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23])) == False\n assert candidate(head = list_node([7, 8, 9]),root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 8, None, None, 9])) == True\n assert candidate(head = list_node([7, 3, 1, 5]),root = tree_node([5, 7, 5, None, 3, 7, 5, None, None, 1, None, None, 2, None, None, None, 8])) == False\n assert candidate(head = list_node([1, 2, 1, 2, 3]),root = tree_node([1, 2, 1, 2, 3, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([1, 2, 3, 4, 5]),root = tree_node([1, None, 2, None, 3, None, 4, None, 5])) == True\n assert candidate(head = list_node([25, 24, 23, 22, 21, 20]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == False\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])) == False\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([10, 11, 12]),root = tree_node([5, 10, 15, 8, 11, 13, 18, 7, 12, 9, 14, 16, 19, 6, 17, 20])) == False\n assert candidate(head = list_node([3, 2, 1]),root = tree_node([1, None, 3, None, 2, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == False\n assert candidate(head = list_node([1, 3, 2, 3, 1]),root = tree_node([1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1])) == False\n assert candidate(head = list_node([5, 6, 7, 8]),root = tree_node([5, 1, 4, 6, None, 2, None, 7, None, 3, None, 8, None, 4, None, 9, None, 5])) == False\n assert candidate(head = list_node([2, 3, 4, 5, 6, 7, 8]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == False\n assert candidate(head = list_node([9, 5, 1]),root = tree_node([9, 3, 11, 1, None, 5, None, 9, None, 5, None, 1, None, 1, None, 1, None, 9, None, 1, None, 1, None, 1, None, 1])) == False\n assert candidate(head = list_node([1, 2, 3, 2, 1]),root = tree_node([1, 2, 1, 2, 3, 2, 1, 3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1])) == True\n assert candidate(head = list_node([1, 2, 3]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == False\n assert candidate(head = list_node([6, 7, 8, 9]),root = tree_node([6, 2, 6, 7, 8, 6, 6, 9, None, None, None, 7, 8, None, None, None, 8, 9, None, None, None, None, None, 9, None, None, None, None, None, 9, None, None, None])) == False\n assert candidate(head = list_node([5, 6, 7]),root = tree_node([1, 2, 3, 4, 5, None, None, None, None, 6, None, None, 7, None, None, 8, None, None, 9, None, None, 10, None, None, 11, None, None, 12, None, None, 13])) == True\n assert candidate(head = list_node([1, 1, 1, 1, 1]),root = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == True\n assert candidate(head = list_node([3, 5, 7, 9]),root = tree_node([3, 5, 7, 1, 5, 7, 9, None, None, 1, None, None, 9, 3, 5, None, 9])) == False\n assert candidate(head = list_node([2, 3, 6]),root = tree_node([1, 2, 3, 4, 2, 6, 3, 4, 2, 6, 3, 4, 2, 6, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([2, 3, 4, 5]),root = tree_node([2, 3, None, 4, None, 5, None, 6, None, 7, None, 8])) == True\n assert candidate(head = list_node([10, 11, 12, 13]),root = tree_node([10, None, 11, None, 12, None, 13, None, 10])) == True\n assert candidate(head = list_node([7, 5, 2]),root = tree_node([7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2])) == False\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1]),root = tree_node([9, 8, 7, 6, 5, 4, 3, 2, 1, None, None, 8, 7, 6, 5, 4, 3, 2, 1, None, None, 7, 6, 5, 4, 3, 2, 1])) == False\n assert candidate(head = list_node([7, 1, 2, 1]),root = tree_node([7, 1, 2, 1, 2, 2, None, 2, None, 2, None, 1, None, 1, None, 2, None, 1, None, 1, None, 2, None, 2, None, 2])) == False\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == False\n"}, "metadata": {"canonical_parameter_names": ["head", "root"], "leetcode_dataset_entry_point": "Solution().isSubPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def isSubPath(self, head: ListNode | None, root: TreeNode | None) -> bool:", "container": "Solution", "callable": "isSubPath", "parameters": [{"name": "head", "type": "ListNode | None"}, {"name": "root", "type": "TreeNode | None"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1368, "task_id": "minimum-cost-to-make-at-least-one-valid-path-in-a-grid", "difficulty": "Hard", "problem_description": "Given an m x n grid. Each cell of the grid has a sign pointing to the next cell you should visit if you are currently in this cell. The sign of grid[i][j] can be:\n\n1 which means go to the cell to the right. (i.e go from grid[i][j] to grid[i][j + 1])\n2 which means go to the cell to the left. (i.e go from grid[i][j] to grid[i][j - 1])\n3 which means go to the lower cell. (i.e go from grid[i][j] to grid[i + 1][j])\n4 which means go to the upper cell. (i.e go from grid[i][j] to grid[i - 1][j])\n\nNotice that there could be some signs on the cells of the grid that point outside the grid.\nYou will initially start at the upper left cell (0, 0). A valid path in the grid is a path that starts from the upper left cell (0, 0) and ends at the bottom-right cell (m - 1, n - 1) following the signs on the grid. The valid path does not have to be the shortest.\nYou can modify the sign on a cell with cost = 1. You can modify the sign on a cell one time only.\nReturn the minimum cost to make the grid have at least one valid path.\n \nExample 1:\n\n\nInput: grid = [[1,1,1,1],[2,2,2,2],[1,1,1,1],[2,2,2,2]]\nOutput: 3\nExplanation: You will start at point (0, 0).\nThe path to (3, 3) is as follows. (0, 0) --> (0, 1) --> (0, 2) --> (0, 3) change the arrow to down with cost = 1 --> (1, 3) --> (1, 2) --> (1, 1) --> (1, 0) change the arrow to down with cost = 1 --> (2, 0) --> (2, 1) --> (2, 2) --> (2, 3) change the arrow to down with cost = 1 --> (3, 3)\nThe total cost = 3.\n\nExample 2:\n\n\nInput: grid = [[1,1,3],[3,2,2],[1,1,4]]\nOutput: 0\nExplanation: You can follow the path from (0, 0) to (2, 2).\n\nExample 3:\n\n\nInput: grid = [[1,2],[4,3]]\nOutput: 1\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 100\n1 <= grid[i][j] <= 4\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 2\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]]) == 3\n assert candidate(grid = [[4, 4, 4], [4, 4, 4], [4, 4, 4]]) == 4\n assert candidate(grid = [[2, 3, 4, 1], [4, 2, 3, 1], [3, 4, 2, 1], [1, 2, 3, 4]]) == 4\n assert candidate(grid = [[3, 4, 2, 1], [4, 2, 3, 1], [2, 1, 4, 3], [1, 4, 3, 2]]) == 3\n assert candidate(grid = [[1, 1, 1, 1], [2, 2, 2, 2], [1, 1, 1, 1], [2, 2, 2, 2]]) == 3\n assert candidate(grid = [[4, 2, 3], [1, 2, 1], [1, 2, 4]]) == 3\n assert candidate(grid = [[2, 1, 1], [1, 2, 2], [2, 2, 1]]) == 3\n assert candidate(grid = [[1, 2], [4, 3]]) == 1\n assert candidate(grid = [[1, 1, 3], [3, 2, 2], [1, 1, 4]]) == 0\n assert candidate(grid = [[4, 2, 3], [1, 3, 2], [2, 1, 4]]) == 1\n assert candidate(grid = [[2, 2, 2], [2, 2, 2], [2, 2, 2]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3], [4, 3, 2, 1, 4, 3, 2], [1, 2, 3, 4, 1, 2, 3], [4, 3, 2, 1, 4, 3, 2], [1, 2, 3, 4, 1, 2, 3], [4, 3, 2, 1, 4, 3, 2]]) == 5\n assert candidate(grid = [[4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 3, 3, 3, 3, 3, 3, 3, 3, 4], [4, 3, 2, 2, 2, 2, 2, 2, 3, 4], [4, 3, 2, 1, 1, 1, 2, 2, 3, 4], [4, 3, 2, 1, 4, 1, 2, 2, 3, 4], [4, 3, 2, 1, 4, 4, 1, 2, 3, 4], [4, 3, 2, 1, 4, 4, 4, 1, 3, 4], [4, 3, 2, 1, 4, 4, 4, 4, 3, 4], [4, 3, 2, 1, 4, 4, 4, 4, 4, 4], [4, 3, 2, 1, 4, 4, 4, 4, 4, 4]]) == 8\n assert candidate(grid = [[2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]]) == 8\n assert candidate(grid = [[1, 1, 1, 4, 1, 1], [2, 2, 2, 4, 2, 2], [1, 1, 1, 4, 1, 1], [4, 4, 4, 1, 4, 4], [1, 1, 1, 4, 1, 1], [2, 2, 2, 4, 2, 2]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 3, 2, 3, 4], [3, 2, 1, 4, 3], [1, 2, 3, 4, 1], [3, 4, 1, 2, 3], [2, 1, 4, 3, 2]]) == 2\n assert candidate(grid = [[1, 1, 1, 2, 3, 4], [4, 3, 2, 1, 1, 1], [1, 2, 3, 4, 2, 1], [2, 3, 4, 1, 3, 4]]) == 3\n assert candidate(grid = [[1, 4, 3, 2, 1], [1, 4, 3, 2, 1], [1, 4, 3, 2, 1], [1, 4, 3, 2, 1], [1, 4, 3, 2, 1]]) == 3\n assert candidate(grid = [[1, 3, 2, 3, 4], [4, 2, 3, 1, 2], [3, 1, 4, 2, 3], [2, 4, 1, 3, 4], [1, 2, 3, 4, 1]]) == 3\n assert candidate(grid = [[2, 1, 2, 3, 2], [1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1], [2, 1, 2, 1, 2]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 1], [2, 3, 4, 1, 2], [3, 4, 1, 2, 3], [4, 1, 2, 3, 4], [1, 2, 3, 4, 1]]) == 4\n assert candidate(grid = [[3, 4, 3, 4, 3, 4, 3, 4, 3], [1, 2, 1, 2, 1, 2, 1, 2, 1], [3, 4, 3, 4, 3, 4, 3, 4, 3], [1, 2, 1, 2, 1, 2, 1, 2, 1], [3, 4, 3, 4, 3, 4, 3, 4, 3], [1, 2, 1, 2, 1, 2, 1, 2, 1], [3, 4, 3, 4, 3, 4, 3, 4, 3], [1, 2, 1, 2, 1, 2, 1, 2, 1], [3, 4, 3, 4, 3, 4, 3, 4, 3]]) == 8\n assert candidate(grid = [[2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2]]) == 5\n assert candidate(grid = [[1, 1, 2, 4, 3], [3, 2, 1, 1, 4], [1, 3, 4, 1, 2], [2, 1, 3, 4, 1], [3, 4, 1, 2, 1]]) == 2\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4], [4, 3, 2, 1, 4, 3, 2, 1], [1, 2, 3, 4, 1, 2, 3, 4], [2, 1, 4, 3, 2, 1, 4, 3]]) == 5\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3]]) == 9\n assert candidate(grid = [[2, 2, 2, 4, 4], [4, 3, 3, 2, 1], [3, 1, 1, 3, 2], [2, 1, 4, 3, 1], [4, 3, 2, 1, 2]]) == 2\n assert candidate(grid = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 4, 3, 2], [2, 3, 4, 1]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [1, 2, 3, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [3, 4, 1, 2, 3, 4, 1, 2, 3, 4], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1]]) == 6\n assert candidate(grid = [[1, 4, 3, 3, 2, 2, 1, 1, 2, 4], [3, 4, 4, 2, 2, 1, 4, 3, 2, 4], [4, 3, 2, 4, 2, 1, 1, 1, 4, 3], [3, 4, 2, 2, 1, 1, 4, 3, 2, 4], [1, 2, 4, 1, 3, 3, 2, 2, 4, 3], [3, 2, 3, 4, 3, 4, 1, 1, 2, 3], [4, 3, 4, 2, 1, 1, 2, 2, 3, 4], [3, 4, 3, 1, 2, 2, 3, 4, 1, 2], [1, 2, 4, 3, 2, 2, 1, 1, 4, 3], [3, 2, 3, 4, 1, 1, 2, 2, 3, 4]]) == 6\n assert candidate(grid = [[1, 3, 2, 4, 1], [1, 1, 3, 2, 4], [3, 4, 1, 1, 3], [2, 3, 4, 1, 1], [1, 2, 3, 4, 2]]) == 1\n assert candidate(grid = [[3, 2, 1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1]]) == 9\n assert candidate(grid = [[4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4]]) == 8\n assert candidate(grid = [[1, 2, 3, 4, 1, 2], [3, 4, 1, 2, 3, 4], [2, 1, 4, 3, 2, 1], [4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2], [3, 4, 1, 2, 3, 4]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 1], [4, 3, 2, 1, 4], [1, 2, 3, 4, 1], [4, 3, 2, 1, 4], [1, 2, 3, 4, 1]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4]]) == 5\n assert candidate(grid = [[4, 2, 3, 1, 3, 1, 4], [2, 4, 3, 2, 1, 3, 2], [3, 1, 4, 3, 2, 4, 3], [1, 3, 2, 4, 3, 1, 2], [4, 2, 3, 1, 2, 3, 4]]) == 5\n assert candidate(grid = [[3, 3, 2, 1, 1], [4, 3, 2, 4, 3], [2, 3, 3, 4, 2], [1, 4, 4, 4, 1], [2, 2, 3, 1, 2]]) == 4\n assert candidate(grid = [[1, 1, 2, 2, 3, 3], [4, 4, 1, 1, 2, 2], [3, 3, 4, 4, 1, 1], [2, 2, 3, 3, 4, 4], [1, 1, 2, 2, 3, 3], [4, 4, 1, 1, 2, 2]]) == 4\n assert candidate(grid = [[2, 3, 4, 1, 2], [1, 2, 3, 4, 1], [4, 1, 2, 3, 4], [3, 4, 1, 2, 3], [2, 1, 4, 3, 1]]) == 4\n assert candidate(grid = [[1, 4, 2, 3, 4, 1, 2], [2, 3, 4, 1, 2, 3, 4], [1, 2, 3, 4, 1, 2, 3], [2, 3, 4, 1, 2, 3, 4], [3, 4, 1, 2, 3, 4, 1]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 7\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2]]) == 7\n assert candidate(grid = [[3, 2, 1, 4, 3, 2, 1, 4], [2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1], [3, 2, 1, 4, 3, 2, 1, 4], [2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1]]) == 7\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 3, 2, 4], [2, 4, 3, 1], [3, 1, 4, 2], [4, 2, 1, 3]]) == 2\n assert candidate(grid = [[1, 3, 1, 1, 3, 2], [1, 2, 2, 2, 3, 3], [2, 2, 2, 1, 1, 3], [3, 3, 1, 2, 2, 3], [3, 2, 3, 3, 1, 1], [1, 1, 1, 3, 1, 1]]) == 2\n assert candidate(grid = [[1, 2, 1, 2, 1], [3, 4, 3, 4, 3], [1, 2, 1, 2, 1], [3, 4, 3, 4, 3], [1, 2, 1, 2, 1]]) == 4\n assert candidate(grid = [[1, 3, 4, 3, 1, 2], [2, 4, 3, 1, 2, 3], [3, 1, 2, 3, 4, 1], [4, 2, 3, 4, 1, 2], [1, 3, 4, 1, 2, 3], [2, 4, 1, 2, 3, 4]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 1, 1, 4, 3, 2, 1], [1, 2, 3, 4, 1, 2, 4, 3, 2, 1], [1, 2, 3, 4, 1, 2, 3, 4, 2, 1], [1, 2, 3, 4, 1, 2, 3, 4, 3, 1], [1, 2, 3, 4, 1, 2, 3, 4, 4, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 3, 1, 1, 1], [1, 4, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 3\n assert candidate(grid = [[1, 1, 1, 2, 3, 3, 3, 4], [2, 2, 2, 1, 1, 1, 4, 3], [3, 3, 2, 2, 2, 4, 1, 2], [4, 4, 3, 3, 3, 1, 2, 1], [1, 1, 4, 4, 4, 2, 1, 3], [2, 2, 1, 1, 1, 3, 2, 4], [3, 3, 2, 2, 2, 4, 3, 1], [4, 4, 3, 3, 3, 1, 4, 2]]) == 6\n assert candidate(grid = [[4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4]]) == 4\n assert candidate(grid = [[2, 2, 2, 1, 1], [1, 1, 1, 2, 2], [2, 2, 2, 1, 1], [1, 1, 1, 2, 2], [2, 2, 2, 1, 1]]) == 4\n assert candidate(grid = [[1, 3, 2, 4, 1], [2, 4, 1, 3, 2], [3, 1, 4, 2, 3], [4, 2, 3, 1, 4], [1, 4, 3, 2, 1]]) == 3\n assert candidate(grid = [[4, 3, 2, 1], [3, 2, 1, 4], [2, 1, 4, 3], [1, 4, 3, 2]]) == 3\n assert candidate(grid = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[2, 3, 4, 1, 1, 2], [1, 4, 2, 3, 4, 2], [2, 3, 1, 4, 2, 3], [3, 4, 2, 1, 3, 4], [4, 1, 3, 2, 4, 1], [1, 2, 4, 3, 1, 2]]) == 5\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3], [2, 3, 4, 1, 2, 3, 4], [3, 4, 1, 2, 3, 4, 1], [4, 1, 2, 3, 4, 1, 2], [1, 2, 3, 4, 1, 2, 3], [2, 3, 4, 1, 2, 3, 4], [3, 4, 1, 2, 3, 4, 1]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2, 1, 4]]) == 6\n assert candidate(grid = [[1, 2, 2, 2, 3, 3, 1], [3, 1, 1, 1, 1, 2, 3], [2, 3, 3, 3, 2, 3, 2], [1, 1, 1, 1, 3, 2, 1], [2, 3, 2, 3, 1, 1, 2], [3, 2, 3, 2, 1, 2, 3], [1, 2, 1, 2, 3, 3, 1]]) == 3\n assert candidate(grid = [[2, 3, 4, 1], [4, 1, 2, 3], [1, 2, 3, 4], [3, 4, 1, 2]]) == 2\n assert candidate(grid = [[3, 3, 2, 1, 1], [2, 1, 1, 4, 1], [1, 2, 1, 4, 3], [2, 1, 4, 2, 4], [1, 2, 3, 4, 4]]) == 4\n assert candidate(grid = [[1, 1, 2, 2, 3, 3], [3, 3, 4, 4, 1, 1], [2, 2, 1, 1, 4, 4], [4, 4, 3, 3, 2, 2], [1, 1, 2, 2, 3, 3], [3, 3, 4, 4, 1, 1]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 1], [1, 2, 3, 4, 1], [1, 2, 3, 4, 1], [1, 2, 3, 4, 1], [1, 2, 3, 4, 1]]) == 3\n assert candidate(grid = [[4, 1, 1, 1, 3], [2, 4, 2, 4, 2], [1, 2, 1, 2, 1], [3, 2, 3, 2, 3], [1, 4, 1, 4, 1]]) == 3\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[2, 2, 4, 1, 2, 4, 1, 3, 3, 4], [1, 1, 1, 3, 3, 4, 2, 1, 3, 1], [3, 2, 2, 1, 1, 2, 4, 4, 4, 3], [4, 1, 3, 2, 4, 1, 3, 2, 3, 1], [2, 3, 4, 2, 1, 4, 1, 1, 3, 4], [1, 4, 1, 4, 2, 1, 2, 4, 3, 4]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4], [2, 3, 4, 1, 2, 3, 4, 1], [3, 4, 1, 2, 3, 4, 1, 2], [4, 1, 2, 3, 4, 1, 2, 3], [1, 2, 3, 4, 1, 2, 3, 4]]) == 5\n assert candidate(grid = [[1, 3, 2, 4, 1, 2, 3, 4], [2, 4, 3, 1, 2, 3, 4, 1], [3, 1, 4, 2, 3, 4, 1, 2], [4, 2, 3, 4, 1, 2, 3, 4], [1, 3, 4, 1, 2, 3, 4, 1], [2, 4, 1, 2, 3, 4, 1, 2], [3, 1, 2, 3, 4, 1, 2, 3], [4, 2, 3, 4, 1, 2, 3, 4]]) == 6\n assert candidate(grid = [[1, 2, 2, 3], [3, 4, 1, 2], [1, 3, 4, 2], [2, 1, 3, 4]]) == 2\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1], [4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4]]) == 8\n assert candidate(grid = [[3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1], [4, 4, 4, 4, 4, 4, 4], [1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3]]) == 5\n assert candidate(grid = [[3, 1, 1, 2, 1, 4, 1], [3, 3, 4, 1, 3, 3, 3], [3, 4, 2, 2, 3, 1, 3], [3, 3, 3, 1, 1, 4, 3], [1, 3, 2, 3, 4, 4, 2], [2, 2, 4, 1, 3, 2, 4], [4, 4, 1, 1, 2, 3, 3]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 3, 4, 1, 2, 3, 4, 1, 2, 3], [3, 4, 1, 2, 3, 4, 1, 2, 3, 4], [4, 1, 2, 3, 4, 1, 2, 3, 4, 1], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 3, 4, 1, 2, 3, 4, 1, 2, 3], [3, 4, 1, 2, 3, 4, 1, 2, 3, 4], [4, 1, 2, 3, 4, 1, 2, 3, 4, 1], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 3, 4, 1, 2, 3, 4, 1, 2, 3]]) == 9\n assert candidate(grid = [[3, 1, 2, 1, 4], [1, 4, 3, 2, 1], [2, 3, 4, 1, 2], [4, 1, 2, 3, 4], [1, 2, 3, 4, 3]]) == 3\n assert candidate(grid = [[4, 4, 4, 2, 4, 1, 2, 4], [1, 4, 2, 4, 2, 4, 4, 4], [2, 1, 3, 3, 1, 3, 3, 1], [4, 2, 3, 4, 1, 2, 4, 4], [1, 3, 4, 4, 1, 2, 3, 1], [2, 4, 2, 2, 4, 4, 1, 2], [4, 3, 4, 2, 1, 2, 3, 4], [4, 4, 4, 1, 3, 4, 2, 3]]) == 7\n assert candidate(grid = [[3, 3, 3, 3, 3, 3, 3], [2, 1, 2, 1, 2, 1, 2], [3, 3, 3, 3, 3, 3, 3], [1, 2, 1, 2, 1, 2, 1], [3, 3, 3, 3, 3, 3, 3], [2, 1, 2, 1, 2, 1, 2]]) == 4\n assert candidate(grid = [[4, 4, 4, 4], [4, 4, 4, 4], [4, 4, 4, 4], [4, 4, 4, 4]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 2, 1, 2, 1], [1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 2, 1, 2, 1], [1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 4, 1, 4, 1, 4, 1], [2, 3, 2, 3, 2, 3, 2], [1, 4, 1, 4, 1, 4, 1], [2, 3, 2, 3, 2, 3, 2], [1, 4, 1, 4, 1, 4, 1], [2, 3, 2, 3, 2, 3, 2], [1, 4, 1, 4, 1, 4, 1]]) == 6\n assert candidate(grid = [[4, 1, 2, 3], [3, 4, 1, 2], [2, 3, 4, 1], [1, 2, 3, 4], [4, 3, 2, 1]]) == 4\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minCost(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "minCost", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1370, "task_id": "increasing-decreasing-string", "difficulty": "Easy", "problem_description": "You are given a string s. Reorder the string using the following algorithm:\n\nRemove the smallest character from s and append it to the result.\nRemove the smallest character from s that is greater than the last appended character, and append it to the result.\nRepeat step 2 until no more characters can be removed.\nRemove the largest character from s and append it to the result.\nRemove the largest character from s that is smaller than the last appended character, and append it to the result.\nRepeat step 5 until no more characters can be removed.\nRepeat steps 1 through 6 until all characters from s have been removed.\n\nIf the smallest or largest character appears more than once, you may choose any occurrence to append to the result.\nReturn the resulting string after reordering s using this algorithm.\n \nExample 1:\n\nInput: s = \"aaaabbbbcccc\"\nOutput: \"abccbaabccba\"\nExplanation: After steps 1, 2 and 3 of the first iteration, result = \"abc\"\nAfter steps 4, 5 and 6 of the first iteration, result = \"abccba\"\nFirst iteration is done. Now s = \"aabbcc\" and we go back to step 1\nAfter steps 1, 2 and 3 of the second iteration, result = \"abccbaabc\"\nAfter steps 4, 5 and 6 of the second iteration, result = \"abccbaabccba\"\n\nExample 2:\n\nInput: s = \"rat\"\nOutput: \"art\"\nExplanation: The word \"rat\" becomes \"art\" after re-ordering it with the mentioned algorithm.\n\n \nConstraints:\n\n1 <= s.length <= 500\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"rqy\") == \"qry\"\n assert candidate(s = \"fuvofn\") == \"fnouvf\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"vibhu\") == \"bhiuv\"\n assert candidate(s = \"xyyzz\") == \"xyzzy\"\n assert candidate(s = \"ijkpqxz\") == \"ijkpqxz\"\n assert candidate(s = \"hfnmwy\") == \"fhmnwy\"\n assert candidate(s = \"tkfjkj\") == \"fjktkj\"\n assert candidate(s = \"rat\") == \"art\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"abacabadabacaba\") == \"abcdcbaabbaaaaa\"\n assert candidate(s = \"ukqay\") == \"akquy\"\n assert candidate(s = \"spo\") == \"ops\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\") == \"abcddcbaabcddcbaabcddcbaabcddcba\"\n assert candidate(s = \"ukqms\") == \"kmqsu\"\n assert candidate(s = \"leetcode\") == \"cdelotee\"\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aaaabbbbcccc\") == \"abccbaabccba\"\n assert candidate(s = \"ggggggg\") == \"ggggggg\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"abacaba\") == \"abcbaaa\"\n assert candidate(s = \"aaaazzzz\") == \"azzaazza\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"wzyzxwzyzxwzyz\") == \"wxyzzyxwwyzzzz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazzzzzzzzzzzzzzz\"\n assert candidate(s = \"xzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzy\") == \"xyzzyxxyzzyxxyzzyxxyzzyxxyzzyxxyzzyxxyzzyx\"\n assert candidate(s = \"abacabadabacabadabacabad\") == \"abcddcbaabcdbaabbaaaaaaa\"\n assert candidate(s = \"rearrange\") == \"aegnrrear\"\n assert candidate(s = \"abcdefghiabcdefghiabcdefghiabcdefghiabcdefghi\") == \"abcdefghiihgfedcbaabcdefghiihgfedcbaabcdefghi\"\n assert candidate(s = \"zzzzzyyyyxxxwwvvuuttssrrqqppoonnmmlkkjjiihhggffeedcba\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmkjihgfexyzzyz\"\n assert candidate(s = \"zzzzzyyyxxxwwwwvvvuuttssrrqqppoonnmmlkkjjiihhggffeeddccba\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmkjihgfedcvwxyzzwz\"\n assert candidate(s = \"qwertypoiuytrewqpoiuytr\") == \"eiopqrtuwyywutrqpoierty\"\n assert candidate(s = \"aabbccccdddd\") == \"abcddcbacddc\"\n assert candidate(s = \"ppqqrrsstttuuuuvvvwwxxxyyyzzzz\") == \"pqrstuvwxyzzyxwvutsrqptuvxyzzu\"\n assert candidate(s = \"thisisaverylongstringthatneedstobesortedbythealgorithm\") == \"abdeghilmnorstvyytsronlihgedbaaeghinorsttsroiheesttett\"\n assert candidate(s = \"lkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkj\") == \"jkllkjjkllkjjkllkjjkllkjjkllkjjkllkjjkllkj\"\n assert candidate(s = \"abcdabcdbcdabcdabcdbcdabcdabcdbcd\") == \"abcddcbaabcddcbaabcddcbabcddcbbcd\"\n assert candidate(s = \"nnnnoooppqqrrsssttuuuvvwwxxxyyyzzz\") == \"nopqrstuvwxyzzyxwvutsrqponnosuxyzn\"\n assert candidate(s = \"svilikwd\") == \"diklsvwi\"\n assert candidate(s = \"ppqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpq\") == \"pqqppqqppqqppqqppqqppqqppqqppqqppqqppqqppqqppqp\"\n assert candidate(s = \"zabzabzabzabzabzabzabzabzabzabzabzabzab\") == \"abzzbaabzzbaabzzbaabzzbaabzzbaabzzbaabz\"\n assert candidate(s = \"ppqpqpppqpppqpppqpqppppqpqpppppp\") == \"pqqppqqppqqppqqppppppppppppppppp\"\n assert candidate(s = \"fedcbazyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyzfedcba\"\n assert candidate(s = \"successfultesting\") == \"cefgilnstuutsecss\"\n assert candidate(s = \"mmuuxxxaannnltttvvvsssss\") == \"almnstuvxxvutsnmanstvxss\"\n assert candidate(s = \"abababababababababababab\") == \"abbaabbaabbaabbaabbaabba\"\n assert candidate(s = \"aabbbcccddddeeeeefffffff\") == \"abcdeffedcbabcdeffedefff\"\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnooopppqqqrrrssstttuuuvvvwwwxxyyzzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmopqrstuvwz\"\n assert candidate(s = \"abracadabraabracadabraabracadabra\") == \"abcdrrdcbaabcdrrbaabrrbaaaaaaaaaa\"\n assert candidate(s = \"xyzzzyyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyzzyxyz\"\n assert candidate(s = \"abcdabcdbca\") == \"abcddcbaabc\"\n assert candidate(s = \"zzzzzyyyyyxxxxxxwwwwvvvvuuuuttttssssrrrrqqqqpppplllloooonnnnmmmmlkkkkjjjjiiihhhhggggffffeeeedddccccbbbaaaaaa\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjhgfecaalxyzxa\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazz\"\n assert candidate(s = \"abcdefabcdefabcdefabcdef\") == \"abcdeffedcbaabcdeffedcba\"\n assert candidate(s = \"banana\") == \"abnnaa\"\n assert candidate(s = \"gggggggggggggggggggggggggg\") == \"gggggggggggggggggggggggggg\"\n assert candidate(s = \"mmmmnnnnnnnnlllllkkkkjjjjiiihhhhggggffffffeeeeeeeedddddcccccbbbbbaaaaa\") == \"abcdefghijklmnnmlkjihgfedcbaabcdefghijklmnnmlkjhgfedcbaabcdeflnnfeenne\"\n assert candidate(s = \"mamamamamamamamamamamama\") == \"ammaammaammaammaammaamma\"\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppppppppppppp\") == \"pppppppppppppppppppppppppppppppppppppppppppppppppppppp\"\n assert candidate(s = \"elephantzoo\") == \"aehlnoptzoe\"\n assert candidate(s = \"elephant\") == \"aehlnpte\"\n assert candidate(s = \"algorithm\") == \"aghilmort\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazzzzzz\"\n assert candidate(s = \"bcaaacbcabcabcabcabcabcabcabc\") == \"abccbaabccbaabccbaabccbaabcca\"\n assert candidate(s = \"qazwsxedcrfvtgbyhnujmiklopqazwsxedcrfvtgbyhnujmiklop\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"mississippi\") == \"impsspiissi\"\n assert candidate(s = \"flfrffvfrmfvffvvfrrfmfffffrfrfrff\") == \"flmrvvrmffrvvrffrrffrffffffffffff\"\n assert candidate(s = \"abcdefgfedcbabcdefgfedcba\") == \"abcdefggfedcbaabcdeffedcb\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().sortString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def sortString(self, s: str) -> str:", "container": "Solution", "callable": "sortString", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1371, "task_id": "find-the-longest-substring-containing-vowels-in-even-counts", "difficulty": "Medium", "problem_description": "Given the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must appear an even number of times.\n \nExample 1:\n\nInput: s = \"eleetminicoworoep\"\nOutput: 13\nExplanation: The longest substring is \"leetminicowor\" which contains two each of the vowels: e, i and o and zero of the vowels: a and u.\n\nExample 2:\n\nInput: s = \"leetcodeisgreat\"\nOutput: 5\nExplanation: The longest substring is \"leetc\" which contains two e's.\n\nExample 3:\n\nInput: s = \"bcbcbc\"\nOutput: 6\nExplanation: In this case, the given string \"bcbcbc\" is the longest because all vowels: a, e, i, o and u appear zero times.\n\n \nConstraints:\n\n1 <= s.length <= 5 x 10^5\ns contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"bcbcbc\") == 6\n assert candidate(s = \"cbacdcdcdbacdbad\") == 14\n assert candidate(s = \"aeiouaeiouaeiouaeiou\") == 20\n assert candidate(s = \"aaaaaeeeeeiioooouuuu\") == 14\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 5\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuuu\") == 26\n assert candidate(s = \"aaeeiioouu\") == 10\n assert candidate(s = \"aeiou\") == 0\n assert candidate(s = \"aaaaa\") == 4\n assert candidate(s = \"a\") == 0\n assert candidate(s = \"leetcodeisgreat\") == 5\n assert candidate(s = \"abacabadabacaba\") == 15\n assert candidate(s = \"aeiaaioaaaaeiiiiouuuooaaaaea\") == 18\n assert candidate(s = \"\") == 0\n assert candidate(s = \"aeeeeeiiiiioooouuuu\") == 12\n assert candidate(s = \"xyz\") == 3\n assert candidate(s = \"abcdefghiijkeilmnopqrstuvwxyzaeiou\") == 12\n assert candidate(s = \"aabbeeaabbeeaabb\") == 16\n assert candidate(s = \"eiouaeiouaeiou\") == 10\n assert candidate(s = \"eleetminicoworoep\") == 13\n assert candidate(s = \"bbaeixaaaaooxu\") == 8\n assert candidate(s = \"aioieu\") == 0\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\") == 21\n assert candidate(s = \"aeiaaioaaaaeiiiiiioooeeeauuaeuia\") == 28\n assert candidate(s = \"aabbccddeeff\") == 12\n assert candidate(s = \"leetcodeleetcode\") == 16\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 52\n assert candidate(s = \"zxcvbnmlkjhgfdsapoiuytrewq\") == 15\n assert candidate(s = \"aaaaaaaa\") == 8\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouxyzuvwaeiouaeiouaeiou\") == 45\n assert candidate(s = \"eeioouuuaeeioouuua\") == 18\n assert candidate(s = \"aeiouaeiouaeiou\") == 10\n assert candidate(s = \"abacaxebecixodeoxou\") == 9\n assert candidate(s = \"thisisaverylongstringwithvariousvowels\") == 13\n assert candidate(s = \"eiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 40\n assert candidate(s = \"uoieaouioeaoieauoi\") == 12\n assert candidate(s = \"mamad\") == 5\n assert candidate(s = \"leetcodeleetcodeleetcode\") == 21\n assert candidate(s = \"bbaaccddeeffgg\") == 14\n assert candidate(s = \"eiouaeiouaieouaeiouaeiouaeiou\") == 20\n assert candidate(s = \"xyzuvwaeiouaeiouxyzuvwaeiouaeiouxyzuvwaeiouaeiou\") == 47\n assert candidate(s = \"abcdeabcdeabcde\") == 13\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouabcdeffedcbaaeiouaeiou\") == 52\n assert candidate(s = \"xyzabcdeiouaeiouabcdeiouaeiouxyz\") == 32\n assert candidate(s = \"bbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 50\n assert candidate(s = \"bcbcbcbaeibcbcbcbaeibcbcbc\") == 26\n assert candidate(s = \"aeeeeiiiooouuuuuuuuu\") == 10\n assert candidate(s = \"bcbcbcabcabcabcabcabcabc\") == 24\n assert candidate(s = \"abacaxebecixodeoxouabacaxebecixodeoxou\") == 38\n assert candidate(s = \"zzzaeizzzaeiouzzzaeiouzzz\") == 19\n assert candidate(s = \"aeiouabcdefghijklmnopqrstuvwxyzaeiou\") == 31\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\") == 52\n assert candidate(s = \"uvceeaieeaaceeaiaa\") == 17\n assert candidate(s = \"aebecixodeoxouaebecixodeoxou\") == 28\n assert candidate(s = \"vvvvvvvvvvvvvvvvvv\") == 18\n assert candidate(s = \"aebecidofugoeiaoeiu\") == 4\n assert candidate(s = \"aeiouaeiouabcdeffedcbaaeiouaeiou\") == 32\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaeiouaeiouaeiou\") == 41\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 52\n assert candidate(s = \"leetcodeisgreataeiou\") == 17\n assert candidate(s = \"aeiouaeiouaeiouxyzuvw\") == 17\n assert candidate(s = \"abcdeffedcbabcdeffedcbabcdeffedcbabcdeffedcb\") == 44\n assert candidate(s = \"xyzuvwaeiouxyzuvwaeiou\") == 22\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmaeiouaeiou\") == 31\n assert candidate(s = \"vwxyz\") == 5\n assert candidate(s = \"aabbccddeeffgg\") == 14\n assert candidate(s = \"eleetminicoworoepzzzzzzzzzz\") == 13\n assert candidate(s = \"abecidofug\") == 1\n assert candidate(s = \"eiouaieouaieoua\") == 10\n assert candidate(s = \"aeiaoeiuioeiuaeiaoeiuioeiuaeiaoeiuioeiaoeiu\") == 26\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 50\n assert candidate(s = \"eiouaeiouaeiouaeiouaeiouaeiou\") == 20\n assert candidate(s = \"eleetminicoworoepaeiou\") == 13\n assert candidate(s = \"eeioouuuaeeioouuuaeeioouuuaeeioouuua\") == 36\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 50\n assert candidate(s = \"aabbccddeeffaabbccddeeff\") == 24\n assert candidate(s = \"leetcodeisgreatleetcodeisgreatleetcodeisgreat\") == 35\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().findTheLongestSubstring", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findTheLongestSubstring(self, s: str) -> int:", "container": "Solution", "callable": "findTheLongestSubstring", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1372, "task_id": "longest-zigzag-path-in-a-binary-tree", "difficulty": "Medium", "problem_description": "You are given the root of a binary tree.\nA ZigZag path for a binary tree is defined as follow:\n\nChoose any node in the binary tree and a direction (right or left).\nIf the current direction is right, move to the right child of the current node; otherwise, move to the left child.\nChange the direction from right to left or from left to right.\nRepeat the second and third steps until you can't move in the tree.\n\nZigzag length is defined as the number of nodes visited - 1. (A single node has a length of 0).\nReturn the longest ZigZag path contained in that tree.\n \nExample 1:\n\n\nInput: root = [1,null,1,1,1,null,null,1,1,null,1,null,null,null,1]\nOutput: 3\nExplanation: Longest ZigZag path in blue nodes (right -> left -> right).\n\nExample 2:\n\n\nInput: root = [1,1,1,null,1,null,null,1,1,null,1]\nOutput: 4\nExplanation: Longest ZigZag path in blue nodes (left -> right -> left -> right).\n\nExample 3:\n\nInput: root = [1]\nOutput: 0\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 5 * 104].\n1 <= Node.val <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([1, None, 1, 1, 1, None, None, 1, 1, None, 1, None, None, None, 1])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7])) == 2\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5])) == 1\n assert candidate(root = tree_node([1, 1, 1, None, 1, None, None, 1, 1, None, 1])) == 4\n assert candidate(root = tree_node([1])) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 8, 9, 10, 11, 12, 13, 14, 15])) == 3\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 1\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, 5, None, None, 6, None, None, 7, 8, None, None, 9, None, None, 10])) == 5\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, None, None, None, None, None, 10])) == 2\n assert candidate(root = tree_node([1, 2, 3, None, 4, 5, None, 6, None, 7, 8, 9, None, 10, None, None, 11, None, None, 12])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, None, None, None, None, None, 9, 10])) == 2\n assert candidate(root = tree_node([1, 2, None, 3, 4, None, None, 5, 6, None, 7, None, 8])) == 4\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, 7, None, 8, None, None, 9, 10, None, None, 11, 12, None, None, 13, 14, None, None, 15, 16])) == 4\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])) == 1\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 1\n assert candidate(root = tree_node([1, None, 3, 2, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9])) == 8\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, None, 5, None, 6, 7, 8, None, None, None, None, 9, 10, 11, 12, 13, 14, 15])) == 3\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, 16, 17, None, None, None, None, 18, 19, 20, None, None, 21, 22, None, None, 23, 24])) == 4\n assert candidate(root = tree_node([1, None, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 2\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, 5, None, None, 6, 7, 8, None, None, 9, None, 10])) == 6\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, 6, None, None, 7, None, 8, None, None, None, 9])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, 16])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, None, 6, 7, 8, None, None, 9, None, 10, None, 11])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])) == 4\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11])) == 1\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, None, None, None, 14, 15, 16, 17, 18, 19, 20])) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, None, None, 10, 11, None, None, 12, 13, None, None, 14, 15])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, 8, None, 9, None, 10])) == 3\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, 6, None, None, 7, None, None, 8, None, 9])) == 3\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11])) == 2\n assert candidate(root = tree_node([1, 2, None, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 2\n assert candidate(root = tree_node([1, None, 2, None, None, None, 3, None, None, None, None, 4, None, None, None, None, 5])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, None, 6, None, None, 7, 8, 9])) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, None, 7, None, 8, 9, None, 10])) == 3\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, None, None, 5])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, None, None, None, None, None, None, 6, 7, 8, 9, 10, 11])) == 1\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, None, 5, 6, None, 7, None, 8, None, None, None, 9])) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 3\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, None, 6, 7, None, None, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, 16, None, 17])) == 3\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, None, 5, None, None, 6, None, None, 7])) == 3\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, None, 5, None, 6])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])) == 2\n assert candidate(root = tree_node([1, 2, 3, None, 4, 5, 6, None, 7, None, 8, 9, 10, None, None, None, None, 11, 12, 13, 14])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == 4\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, None, 6, 7, None, 8, 9, None, None, None, 10])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, 6, None, None, 7, None, 8])) == 3\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])) == 2\n assert candidate(root = tree_node([1, None, 2, 3, None, 4, None, 5, 6, 7, 8, 9, 10, 11, 12])) == 3\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, 5, None, None, 6, None, None, 7, 8, None, None, 9, 10, None, None, 11])) == 5\n assert candidate(root = tree_node([1, None, 2, None, 3, 4, None, None, 5, None, None, 6, 7])) == 3\n assert candidate(root = tree_node([1, None, 2, None, None, None, 3, None, None, None, 4])) == 1\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14])) == 1\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, None, None, 9, None, None, 10, None, 11, None, 12])) == 2\n assert candidate(root = tree_node([1, None, 2, 3, None, 4, 5, None, 6, None, None, None, 7, None, 8])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, 6, None, None, 7, None, None, 8, None, None, 9])) == 3\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])) == 1\n assert candidate(root = tree_node([1, None, 2, 3, 4, None, 5, 6, None, None, None, None, 7, 8, None, None, 9, 10])) == 6\n assert candidate(root = tree_node([1, 2, None, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])) == 4\n assert candidate(root = tree_node([1, 2, None, None, 3, None, None, 4, None, None, 5, None, None, 6, None, None, 7, None, None, 8, None, None, 9, None, None, 10])) == 2\n assert candidate(root = tree_node([1, 2, 3, None, 4, 5, None, 6, 7, None, None, None, None, 8, 9, None, None, 10, 11])) == 3\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20])) == 1\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7])) == 1\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, 11, None, None, 12, 13, None, None, 14, 15])) == 14\n assert candidate(root = tree_node([1, 2, None, None, 3, 4, None, None, 5, None, None, 6, 7, None, None, 8, None, None, 9, 10, None, None, 11, 12])) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, 7, None, None, None, None, 8, 9, None, None, None, 10, None, None, 11, None, None, 12])) == 2\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 2\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12])) == 1\n assert candidate(root = tree_node([1, 2, None, 3, None, None, 4, None, 5, None, None, 6, None, None, 7, None, None, 8, None, 9])) == 2\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, 11])) == 2\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, None, None, 7, None, None, 8, None, None, 9])) == 3\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, 6, 7, None, None, None, None, None, 8, 9, None, None, 10])) == 3\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25])) == 1\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, 11])) == 10\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 1\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11])) == 1\n assert candidate(root = tree_node([1, 2, None, 3, 4, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14])) == 3\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, None, None, 11])) == 3\n assert candidate(root = tree_node([1, 2, 3, None, 4, 5, None, 6, 7, None, 8, 9, None, 10, 11, None, 12, 13, None, 14, 15])) == 3\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 1\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, 6, None, None, 7, 8, None, 9, 10, None, None, None, 11, 12, 13, None, 14, None, 15, None, 16, None, 17])) == 5\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, None, 5, 6, None, 7])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, None, None, None, None, None, 10])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, 8, 9, None, None, None, None, 10, 11, 12, None, None, 13, None, None, 14])) == 2\n assert candidate(root = tree_node([1, None, 2, 3, 4, None, None, None, 5, None, 6, None, None, 7, None, 8, None, 9, None, 10])) == 2\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, 5, None, 6, None, 7])) == 4\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().longestZigZag", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def longestZigZag(self, root: TreeNode | None) -> int:", "container": "Solution", "callable": "longestZigZag", "parameters": [{"name": "root", "type": "TreeNode | None"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1373, "task_id": "maximum-sum-bst-in-binary-tree", "difficulty": "Hard", "problem_description": "Given a binary tree root, return the maximum sum of all keys of any sub-tree which is also a Binary Search Tree (BST).\nAssume a BST is defined as follows:\n\nThe left subtree of a node contains only nodes with keys less than the node's key.\nThe right subtree of a node contains only nodes with keys greater than the node's key.\nBoth the left and right subtrees must also be binary search trees.\n\n \nExample 1:\n\n\nInput: root = [1,4,3,2,4,2,5,null,null,null,null,null,null,4,6]\nOutput: 20\nExplanation: Maximum sum in a valid Binary search tree is obtained in root node with key equal to 3.\n\nExample 2:\n\n\nInput: root = [4,3,null,1,2]\nOutput: 2\nExplanation: Maximum sum in a valid Binary search tree is obtained in a single root node with key equal to 2.\n\nExample 3:\n\nInput: root = [-4,-2,-5]\nOutput: 0\nExplanation: All values are negatives. Return an empty BST.\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 4 * 104].\n-4 * 104 <= Node.val <= 4 * 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5])) == 15\n assert candidate(root = tree_node([5, 4, 8, 3, None, 6, 3])) == 7\n assert candidate(root = tree_node([5, 4, 6, None, None, 3, 7])) == 16\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18])) == 58\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 7])) == 14\n assert candidate(root = tree_node([-4, -2, -5])) == 0\n assert candidate(root = tree_node([1, None, 10, -5, 20])) == 25\n assert candidate(root = tree_node([2, 1, 3])) == 6\n assert candidate(root = tree_node([0, None, -1])) == 0\n assert candidate(root = tree_node([1, 4, 3, 2, 4, 2, 5, None, None, None, None, None, None, 4, 6])) == 20\n assert candidate(root = tree_node([4, 3, None, 1, 2])) == 2\n assert candidate(root = tree_node([2, 1, 3, None, None, None, 4])) == 10\n assert candidate(root = tree_node([3, 1, 4, None, None, 2])) == 6\n assert candidate(root = tree_node([15, 10, 20, 5, 13, 18, 25, 2, 7, 11, 14, 16, 19, 23, 27, 1, 3, 6, 8, 9, 12, 17, 21, 22, 24, 26, 28, 29, 30])) == 32\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 55\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 8, 9, 10, 11, None, None, None, None, None, None, None, None, None])) == 11\n assert candidate(root = tree_node([2, 1, 3, 0, 4, None, None, -2, None, None, 5, None, None, None, None, None, 6])) == 9\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 13, 17, 25, None, None, None, None, None, 16, None, None, None, 18, None, None, None, None, 22, None, None, None, None, None, None, None, None, 24, None, None, None, None, None, None, 23])) == 84\n assert candidate(root = tree_node([5, 3, 12, 1, 4, None, 15, None, None, None, None, None, 18, 13, 17])) == 17\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, None, None, None, None, 11, 14])) == 95\n assert candidate(root = tree_node([50, 30, 70, 20, 40, 60, 80, 10, 25, 35, 45, 55, 65, 75, 85, 5, 15, None, 28, 32, 38, 43, 48, 52, 58, 63, 68, 72, 78, 82, 88, 90, 92, 95, 98, 100])) == 1051\n assert candidate(root = tree_node([1, 1, 1, 1, 1, None, 1])) == 1\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 45\n assert candidate(root = tree_node([3, 2, 5, None, None, 4, 6])) == 20\n assert candidate(root = tree_node([10, 5, 15, 1, 8, 12, 20, 0, 4, 9, 11, 14, 18, 13, 19, None, None, 3, None, None, None, None, None, 2, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 1])) == 19\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 7, 0, 6, None, 9])) == 17\n assert candidate(root = tree_node([3, 1, 5, 0, 2, 4, 6, -1])) == 20\n assert candidate(root = tree_node([5, 3, 8, 1, 4, 7, 10, 0, 2, 6, 9, 5, 11])) == 23\n assert candidate(root = tree_node([3, 2, 5, 1, None, 4, None])) == 15\n assert candidate(root = tree_node([2, 1, 3, None, 4])) == 5\n assert candidate(root = tree_node([2, 1, 3, None, None, 0, 5])) == 8\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 20, -2, None, None, 6, None, None, None, None, None, 25])) == 35\n assert candidate(root = tree_node([30, 10, 50, 5, 20, 40, 60, 1, None, 15, 25, 35, 45, 55, 65, None, 3, 7, 13, 17, 23, 27, 33, 37, 43, 47, 53, 57, 63])) == 63\n assert candidate(root = tree_node([1, None, -1, -2, None, None, -3, None, -4, None, -5])) == 0\n assert candidate(root = tree_node([15, 10, 20, 8, 12, 16, 25, 7, 9, 11, 13, 15, 17, 22, 27])) == 142\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 20, None, None, 6, 9])) == 74\n assert candidate(root = tree_node([2, 1, 3, None, None, None, 4, None, 5])) == 15\n assert candidate(root = tree_node([10, 5, 15, 1, 8, 7, 20])) == 42\n assert candidate(root = tree_node([5, 3, 9, -2, 4, None, 10, None, None, 1, 6, None, None, 8])) == 19\n assert candidate(root = tree_node([5, 2, 13, 1, 5, 10, 20, None, None, None, None, 8, 15])) == 33\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 20, -3, None, None, 6, None, None, None, 26])) == 35\n assert candidate(root = tree_node([2, 1, 3, 0, 5, None, 7, 0, 6, None, None, 9])) == 9\n assert candidate(root = tree_node([5, 2, 6, None, 4, None, 7])) == 24\n assert candidate(root = tree_node([2, 1, 3, None, None, 0, 4])) == 7\n assert candidate(root = tree_node([10, 5, 15, 1, 8, 7, 20, 0, None, None, None, 6, 12, None, 18])) == 25\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 7, None, None, 6, 9])) == 29\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 20, -1, None, None, 6, None, None, None, None, None, 26, None, 27])) == 59\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 20, None, None, 6, 9, None, None, 16, 25])) == 35\n assert candidate(root = tree_node([5, 2, 6, 1, 3, None, None, None, None, 4])) == 6\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 15\n assert candidate(root = tree_node([10, 5, 10, 2, 8, None, None, 1, None, None, 9])) == 25\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6])) == 65\n assert candidate(root = tree_node([15, 10, 20, 8, 12, 16, 25, 6, 9, 11, 13, 14, 17, 19, 30])) == 74\n assert candidate(root = tree_node([5, 2, 3, None, None, None, None, 1])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7])) == 7\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50])) == 50\n assert candidate(root = tree_node([0, -10, 10, -20, 0, -5, 5, None, None, None, None, None, None, -15, -1, 0, 1, 5, None, None, None, None, None, None, -15, -1, 0, 1, 5])) == 5\n assert candidate(root = tree_node([4, 2, 7, 2, 3, 5, None, 2, None, None, None, None, None, 1])) == 12\n assert candidate(root = tree_node([5, 2, 13, None, None, 10, 15, 6, 12, 11, 14, 13, 16])) == 16\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4])) == 10\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, 4, 6, 8, 11, 14, 17, 19])) == 151\n assert candidate(root = tree_node([50, 30, 80, 20, 40, 70, 90, None, None, 25])) == 240\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, 1, None, 6, 8, None, 11, 13, 17, 19])) == 21\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, None, 6, 8, 11, 13, None, 19])) == 36\n assert candidate(root = tree_node([10, 5, 15, 1, 8, 7, 20, None, None, 6, 9, 11, 19])) == 29\n assert candidate(root = tree_node([5, 2, 6, None, None, 3, 8, None, 4, None, None, 7])) == 8\n assert candidate(root = tree_node([50, 30, 70, 20, 40, 60, 80, None, None, 25, None, None, 55, 65, None, None, 75, 85])) == 145\n assert candidate(root = tree_node([50, 30, 70, 20, 40, 60, 80, 15, 25, 35, 45, 55, 65, 75, 85])) == 750\n assert candidate(root = tree_node([5, 1, 4, None, None, 3, 6])) == 13\n assert candidate(root = tree_node([50, 30, 60, 10, 40, 55, 70, None, 45, None, None, None, 65, 80])) == 120\n assert candidate(root = tree_node([50, 30, 60, 5, 20, 45, 70, None, None, 15, 25, 35, 48, 65, 75, None, None, None, None, 40, 50])) == 210\n assert candidate(root = tree_node([10, 5, 15, 1, 8, 12, 20, None, None, 6, 9, 11, 13, None, None, None, None, None, 18, 22])) == 47\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20])) == 210\n assert candidate(root = tree_node([3, 2, 5, None, 3, None, 9])) == 14\n assert candidate(root = tree_node([2, 1, 3, None, None, None, None, 0, 4])) == 6\n assert candidate(root = tree_node([4, 2, 6, 1, 3, 5, 7, 0, None, None, None, None, None, None, 8])) == 36\n assert candidate(root = tree_node([5, 4, 6, 3, 7, None, None, 2, 8, 1, 9])) == 17\n assert candidate(root = tree_node([1, None, 10, None, None, 5, None, None, 15])) == 11\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12])) == 78\n assert candidate(root = tree_node([20, 10, 30, 5, 15, None, None, 3, 7, 13, 18])) == 121\n assert candidate(root = tree_node([5, 2, 3, None, None, 1])) == 4\n assert candidate(root = tree_node([5, 2, 13, None, None, 9, 21, 7, 11, 14, 25])) == 107\n assert candidate(root = tree_node([50, 10, 60, 5, 20, None, None, 3, 7, 15, 35, 25, 45, 17, 25])) == 70\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, None, 6, 8, 12, 14, None, 19])) == 131\n assert candidate(root = tree_node([100, 50, 150, 20, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180])) == 1465\n assert candidate(root = tree_node([4, 2, 6, 1, 3, 5, 7])) == 28\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, None, None, None, None, 10, 14])) == 69\n assert candidate(root = tree_node([10, 5, 15, 1, 8, 12, 20, 0, 4, 9, 11, 14, 18, 13, 19])) == 19\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180])) == 1470\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 13, 18, 25, None, None, None, None, None, None, None, None, None, None, None, 14, None, 16, None, None, 17, None, None, None, None, None, None, None, 21, None, 24, None, None, None, None, 19, None, 22, None, 23, None, None, 26, None, 27])) == 34\n assert candidate(root = tree_node([4, 2, 7, 1, 3, 6, 9, 0, 1, 5, 8, None, None, None, None, None, None, None, None, None])) == 22\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180, None, 12, 28, 55, 65, 77, 85, 105, 115, 135, 145, 155, 165, 178, 185, 190])) == 190\n assert candidate(root = tree_node([50, 30, 60, 5, 20, 45, 70, None, None, 10, 25, 40, 55, 65, 80])) == 415\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, None, 1])) == 21\n assert candidate(root = tree_node([3, 2, 5, None, None, 4, 6, 3, 7])) == 14\n assert candidate(root = tree_node([5, 2, 13, None, None, 8, 14, 3, 12, 7, 11, None, 15])) == 18\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().maxSumBST", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxSumBST(self, root: TreeNode | None) -> int:", "container": "Solution", "callable": "maxSumBST", "parameters": [{"name": "root", "type": "TreeNode | None"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1374, "task_id": "generate-a-string-with-characters-that-have-odd-counts", "difficulty": "Easy", "problem_description": "Given an integer n, return a string with n characters such that each character in such string occurs an odd number of times.\nThe returned string must contain only lowercase English letters. If there are multiples valid strings, return any of them.  \n \nExample 1:\n\nInput: n = 4\nOutput: \"pppz\"\nExplanation: \"pppz\" is a valid string since the character 'p' occurs three times and the character 'z' occurs once. Note that there are many other valid strings such as \"ohhh\" and \"love\".\n\nExample 2:\n\nInput: n = 2\nOutput: \"xy\"\nExplanation: \"xy\" is a valid string since the characters 'x' and 'y' occur once. Note that there are many other valid strings such as \"ag\" and \"ur\".\n\nExample 3:\n\nInput: n = 7\nOutput: \"holasss\"\n\n \nConstraints:\n\n1 <= n <= 500\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 250) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 3) == \"aaa\"\n assert candidate(n = 100) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 4) == \"aaab\"\n assert candidate(n = 2) == \"ab\"\n assert candidate(n = 1) == \"a\"\n assert candidate(n = 500) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 7) == \"aaaaaaa\"\n assert candidate(n = 10) == \"aaaaaaaaab\"\n assert candidate(n = 97) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 267) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 279) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 49) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 125) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 47) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 21) == \"aaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 50) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 5) == \"aaaaa\"\n assert candidate(n = 300) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 222) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 333) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 123) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 87) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 450) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 99) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 37) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 64) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 257) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 23) == \"aaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 167) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 42) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 51) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 175) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 251) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 101) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 495) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 299) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 255) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 375) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 27) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 75) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 249) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 150) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 11) == \"aaaaaaaaaaa\"\n assert candidate(n = 497) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 498) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 399) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 400) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 41) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 275) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 9) == \"aaaaaaaaa\"\n assert candidate(n = 301) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 31) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 200) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 83) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 499) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 199) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 13) == \"aaaaaaaaaaaaa\"\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().generateTheString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def generateTheString(self, n: int) -> str:", "container": "Solution", "callable": "generateTheString", "parameters": [{"name": "n", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1375, "task_id": "number-of-times-binary-string-is-prefix-aligned", "difficulty": "Medium", "problem_description": "You have a 1-indexed binary string of length n where all the bits are 0 initially. We will flip all the bits of this binary string (i.e., change them from 0 to 1) one by one. You are given a 1-indexed integer array flips where flips[i] indicates that the bit at index i will be flipped in the ith step.\nA binary string is prefix-aligned if, after the ith step, all the bits in the inclusive range [1, i] are ones and all the other bits are zeros.\nReturn the number of times the binary string is prefix-aligned during the flipping process.\n \nExample 1:\n\nInput: flips = [3,2,4,1,5]\nOutput: 2\nExplanation: The binary string is initially \"00000\".\nAfter applying step 1: The string becomes \"00100\", which is not prefix-aligned.\nAfter applying step 2: The string becomes \"01100\", which is not prefix-aligned.\nAfter applying step 3: The string becomes \"01110\", which is not prefix-aligned.\nAfter applying step 4: The string becomes \"11110\", which is prefix-aligned.\nAfter applying step 5: The string becomes \"11111\", which is prefix-aligned.\nWe can see that the string was prefix-aligned 2 times, so we return 2.\n\nExample 2:\n\nInput: flips = [4,1,2,3]\nOutput: 1\nExplanation: The binary string is initially \"0000\".\nAfter applying step 1: The string becomes \"0001\", which is not prefix-aligned.\nAfter applying step 2: The string becomes \"1001\", which is not prefix-aligned.\nAfter applying step 3: The string becomes \"1101\", which is not prefix-aligned.\nAfter applying step 4: The string becomes \"1111\", which is prefix-aligned.\nWe can see that the string was prefix-aligned 1 time, so we return 1.\n\n \nConstraints:\n\nn == flips.length\n1 <= n <= 5 * 104\nflips is a permutation of the integers in the range [1, n].\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(flips = [5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 2, 3, 4, 5]) == 5\n assert candidate(flips = [2, 1, 3, 5, 4]) == 3\n assert candidate(flips = [3, 2, 4, 1, 5]) == 2\n assert candidate(flips = [4, 1, 2, 3]) == 1\n assert candidate(flips = [2, 1, 5, 3, 4]) == 2\n assert candidate(flips = [5, 1, 4, 3, 2, 7, 6, 9, 8, 10]) == 4\n assert candidate(flips = [2, 3, 1, 5, 4]) == 2\n assert candidate(flips = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15]) == 6\n assert candidate(flips = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 3\n assert candidate(flips = [1, 4, 3, 2, 5, 8, 6, 7, 10, 9]) == 5\n assert candidate(flips = [3, 1, 4, 2, 5, 7, 6, 9, 8, 10]) == 5\n assert candidate(flips = [3, 1, 2, 6, 5, 4, 7, 8, 9, 10]) == 6\n assert candidate(flips = [6, 5, 4, 3, 2, 1, 7, 8, 9, 10, 11]) == 6\n assert candidate(flips = [1, 3, 2, 5, 4, 6]) == 4\n assert candidate(flips = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 3\n assert candidate(flips = [2, 5, 6, 1, 4, 3, 8, 9, 7, 10]) == 3\n assert candidate(flips = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == 6\n assert candidate(flips = [1, 3, 5, 7, 2, 4, 6, 8, 9, 10]) == 5\n assert candidate(flips = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14]) == 2\n assert candidate(flips = [6, 1, 3, 5, 2, 4]) == 1\n assert candidate(flips = [14, 12, 10, 8, 6, 4, 2, 15, 13, 11, 9, 7, 5, 3, 1]) == 1\n assert candidate(flips = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 5\n assert candidate(flips = [3, 1, 2, 5, 4, 7, 6, 9, 8, 10]) == 5\n assert candidate(flips = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(flips = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(flips = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(flips = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 2\n assert candidate(flips = [6, 3, 1, 4, 2, 5, 7, 8, 9, 10]) == 5\n assert candidate(flips = [2, 1, 5, 4, 3, 6, 8, 7, 10, 9]) == 5\n assert candidate(flips = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9]) == 6\n assert candidate(flips = [5, 2, 3, 4, 1, 6, 7, 8, 9, 10]) == 6\n assert candidate(flips = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10]) == 6\n assert candidate(flips = [1, 11, 2, 10, 3, 9, 4, 8, 5, 7, 6]) == 2\n assert candidate(flips = [10, 1, 20, 2, 19, 3, 18, 4, 17, 5, 16, 6, 15, 7, 14, 8, 13, 9, 12, 11]) == 1\n assert candidate(flips = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 5, 3, 4, 2, 6, 7, 8, 9, 10]) == 7\n assert candidate(flips = [6, 5, 4, 3, 2, 1, 7, 8, 9, 10]) == 5\n assert candidate(flips = [1, 3, 5, 2, 4, 6]) == 3\n assert candidate(flips = [1, 5, 2, 4, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 22\n assert candidate(flips = [1, 5, 2, 4, 3, 6, 7, 8, 9, 10]) == 7\n assert candidate(flips = [6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 2, 5, 4, 3, 6, 8, 7, 10, 9]) == 6\n assert candidate(flips = [1, 3, 5, 2, 4, 6, 7, 8, 9, 10]) == 7\n assert candidate(flips = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [5, 3, 1, 2, 4, 6, 8, 7, 10, 9]) == 4\n assert candidate(flips = [2, 3, 1, 5, 4, 6, 7, 8, 9, 10]) == 7\n assert candidate(flips = [1, 2, 3, 5, 4, 6, 7, 8, 9, 10]) == 9\n assert candidate(flips = [1, 2, 4, 3, 5, 7, 6, 8, 10, 9]) == 7\n assert candidate(flips = [5, 1, 4, 3, 2, 6]) == 2\n assert candidate(flips = [5, 2, 3, 1, 4, 6, 8, 7, 10, 9]) == 4\n assert candidate(flips = [10, 5, 8, 7, 9, 3, 1, 2, 4, 6]) == 1\n assert candidate(flips = [1, 3, 2, 5, 4, 6, 7]) == 5\n assert candidate(flips = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10]) == 2\n assert candidate(flips = [8, 7, 6, 5, 4, 3, 2, 1, 9, 10]) == 3\n assert candidate(flips = [1, 3, 2, 5, 4]) == 3\n assert candidate(flips = [1, 2, 5, 3, 6, 4, 7, 8, 10, 9]) == 6\n assert candidate(flips = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]) == 3\n assert candidate(flips = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(flips = [7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 3, 5, 2, 4, 6, 8, 7, 10, 9]) == 5\n assert candidate(flips = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(flips = [5, 1, 3, 2, 6, 4, 8, 7, 10, 9]) == 3\n assert candidate(flips = [10, 5, 8, 7, 3, 2, 9, 4, 6, 1]) == 1\n assert candidate(flips = [1, 3, 5, 2, 4]) == 2\n assert candidate(flips = [1, 5, 2, 6, 3, 7, 4, 8, 9, 10]) == 5\n assert candidate(flips = [1, 4, 2, 3, 7, 5, 6, 10, 8, 9]) == 4\n assert candidate(flips = [3, 1, 2, 5, 4, 6, 8, 7, 10, 9]) == 5\n assert candidate(flips = [1, 3, 2, 4, 5, 7, 6, 8, 10, 9]) == 7\n assert candidate(flips = [6, 3, 1, 5, 2, 4, 10, 7, 9, 8]) == 2\n assert candidate(flips = [5, 1, 6, 2, 7, 3, 8, 4, 9, 10]) == 3\n assert candidate(flips = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 2, 3, 4, 6, 5, 7, 8, 9, 10]) == 9\n assert candidate(flips = [2, 1, 5, 4, 3, 8, 6, 7, 10, 9]) == 4\n assert candidate(flips = [2, 1, 4, 3, 6, 5, 7]) == 4\n assert candidate(flips = [5, 2, 1, 3, 4, 6, 7, 8, 9, 10]) == 6\n assert candidate(flips = [1, 2, 10, 5, 4, 9, 6, 7, 3, 8]) == 3\n assert candidate(flips = [2, 4, 6, 8, 10, 9, 7, 5, 3, 1]) == 1\n assert candidate(flips = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(flips = [2, 3, 1, 5, 6, 4, 8, 7, 10, 9]) == 4\n assert candidate(flips = [7, 1, 2, 3, 4, 5, 6]) == 1\n assert candidate(flips = [1, 5, 3, 4, 2, 6, 7, 8, 10, 9]) == 6\n assert candidate(flips = [2, 1, 3, 5, 4, 6, 7, 8]) == 6\n assert candidate(flips = [1, 2, 3, 4, 5, 6]) == 6\n assert candidate(flips = [1, 2, 5, 4, 3, 6, 7, 8, 9, 10]) == 8\n assert candidate(flips = [5, 1, 4, 3, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 26\n assert candidate(flips = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 1\n assert candidate(flips = [10, 5, 1, 6, 2, 7, 3, 8, 4, 9]) == 1\n assert candidate(flips = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 6\n"}, "metadata": {"canonical_parameter_names": ["flips"], "leetcode_dataset_entry_point": "Solution().numTimesAllBlue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numTimesAllBlue(self, flips: list[int]) -> int:", "container": "Solution", "callable": "numTimesAllBlue", "parameters": [{"name": "flips", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1376, "task_id": "time-needed-to-inform-all-employees", "difficulty": "Medium", "problem_description": "A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company is the one with headID.\nEach employee has one direct manager given in the manager array where manager[i] is the direct manager of the i-th employee, manager[headID] = -1. Also, it is guaranteed that the subordination relationships have a tree structure.\nThe head of the company wants to inform all the company employees of an urgent piece of news. He will inform his direct subordinates, and they will inform their subordinates, and so on until all employees know about the urgent news.\nThe i-th employee needs informTime[i] minutes to inform all of his direct subordinates (i.e., After informTime[i] minutes, all his direct subordinates can start spreading the news).\nReturn the number of minutes needed to inform all the employees about the urgent news.\n \nExample 1:\n\nInput: n = 1, headID = 0, manager = [-1], informTime = [0]\nOutput: 0\nExplanation: The head of the company is the only employee in the company.\n\nExample 2:\n\n\nInput: n = 6, headID = 2, manager = [2,2,-1,2,2,2], informTime = [0,0,1,0,0,0]\nOutput: 1\nExplanation: The head of the company with id = 2 is the direct manager of all the employees in the company and needs 1 minute to inform them all.\nThe tree structure of the employees in the company is shown.\n\n \nConstraints:\n\n1 <= n <= 105\n0 <= headID < n\nmanager.length == n\n0 <= manager[i] < n\nmanager[headID] == -1\ninformTime.length == n\n0 <= informTime[i] <= 1000\ninformTime[i] == 0 if employee i has no subordinates.\nIt is guaranteed that all the employees can be informed.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,headID = 2,manager = [2, 2, -1, 2, 2, 2],informTime = [0, 0, 1, 0, 0, 0]) == 1\n assert candidate(n = 15,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],informTime = [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]) == 3\n assert candidate(n = 1,headID = 0,manager = [-1],informTime = [0]) == 0\n assert candidate(n = 4,headID = 2,manager = [3, 3, -1, 2],informTime = [0, 0, 162, 954]) == 1116\n assert candidate(n = 7,headID = 6,manager = [1, 2, 3, 4, 5, 6, -1],informTime = [0, 6, 5, 4, 3, 2, 1]) == 21\n assert candidate(n = 4,headID = 2,manager = [3, 3, -1, 2],informTime = [0, 0, 162, 956]) == 1118\n assert candidate(n = 4,headID = 2,manager = [3, 3, -1, 2],informTime = [0, 0, 162, 914]) == 1076\n assert candidate(n = 20,headID = 10,manager = [-1, 10, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 67, 33, 12, 45, 78, 12, 34, 56, 23]) == 112\n assert candidate(n = 12,headID = 5,manager = [2, 2, 3, 4, 5, -1, 3, 5, 3, 5, 5, 4],informTime = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(n = 30,headID = 29,manager = [28, 28, 28, 28, 29, 29, 29, 29, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(n = 12,headID = 3,manager = [5, 5, 5, 5, 6, 6, -1, 7, 7, 8, 8, 9],informTime = [0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 10]) == 0\n assert candidate(n = 20,headID = 0,manager = [-1, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],informTime = [0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9]) == 4\n assert candidate(n = 20,headID = 19,manager = [18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1],informTime = [0, 6, 5, 4, 3, 2, 1, 0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0]) == 0\n assert candidate(n = 15,headID = 7,manager = [6, 6, 6, 7, 7, 7, 7, -1, 8, 8, 8, 9, 9, 10, 10],informTime = [1, 1, 1, 2, 2, 2, 3, 0, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(n = 18,headID = 9,manager = [9, 9, 9, 9, 9, 9, 9, 9, 9, -1, 10, 10, 11, 11, 12, 12, 13, 13],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 0\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 2, 2, 1, 1, 3, 3, 4, 4, 5]) == 3\n assert candidate(n = 15,headID = 5,manager = [5, 5, 5, 5, 5, -1, 6, 6, 7, 7, 8, 8, 9, 9, 10],informTime = [0, 12, 34, 56, 78, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 90\n assert candidate(n = 15,headID = 7,manager = [7, 7, 7, 7, 7, 7, 7, -1, 8, 8, 9, 9, 10, 10, 11],informTime = [0, 0, 0, 0, 0, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0]) == 23\n assert candidate(n = 50,headID = 0,manager = [-1, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24],informTime = [0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 16\n assert candidate(n = 15,headID = 7,manager = [10, 9, 9, 9, 10, 10, 7, -1, 6, 6, 6, 4, 4, 3, 3],informTime = [0, 0, 0, 0, 0, 0, 1, 5, 0, 0, 0, 1, 1, 2, 2]) == 6\n assert candidate(n = 17,headID = 10,manager = [10, 10, 10, 11, 11, 12, 12, 13, 13, 14, -1, 15, 15, 16, 16, 16, 16],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 50, 50, 20, 20, 10, 10]) == 100\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 67, 34, 23, 56, 45, 12, 89, 34, 12]) == 123\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 67, 13, 10, 15, 20, 8, 5, 7, 12]) == 82\n assert candidate(n = 100,headID = 50,manager = [49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, -1],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(n = 100,headID = 50,manager = [49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, -1, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 2, 1, 1, 3, 1, 1, 0, 0, 0]) == 5\n assert candidate(n = 20,headID = 0,manager = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],informTime = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 160\n assert candidate(n = 25,headID = 24,manager = [19, 19, 19, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -1],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 0]) == 55\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 67, 34, 0, 0, 0, 0, 0, 0, 0]) == 67\n assert candidate(n = 12,headID = 3,manager = [3, 3, 3, -1, 4, 4, 5, 5, 6, 6, 7, 7],informTime = [0, 0, 0, 100, 50, 50, 25, 25, 10, 10, 5, 5]) == 100\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3],informTime = [0, 6, 5, 4, 3, 2, 1, 7, 8, 9]) == 6\n assert candidate(n = 15,headID = 7,manager = [10, 9, 9, 10, 8, 8, 7, -1, 10, 10, 10, 11, 11, 12, 12],informTime = [0, 6, 5, 4, 3, 2, 1, 0, 7, 8, 9, 10, 11, 12, 13]) == 0\n assert candidate(n = 50,headID = 25,manager = [24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -1, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(n = 15,headID = 14,manager = [10, 9, 12, 5, 5, 14, 6, 6, 8, 9, 9, 12, 12, 13, -1],informTime = [0, 23, 34, 0, 0, 18, 19, 12, 21, 13, 18, 28, 35, 0, 0]) == 18\n assert candidate(n = 20,headID = 15,manager = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -1, 16, 16, 16, 16],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2]) == 0\n assert candidate(n = 20,headID = 19,manager = [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, -1],informTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 0\n assert candidate(n = 9,headID = 0,manager = [-1, 0, 0, 0, 0, 1, 1, 2, 2],informTime = [0, 30, 40, 50, 60, 70, 80, 90, 100]) == 40\n assert candidate(n = 18,headID = 4,manager = [4, 4, 4, 4, -1, 12, 13, 12, 13, 12, 13, 4, 14, 14, 4, 15, 16, 15],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 18, 0, 0, 0]) == 18\n assert candidate(n = 8,headID = 4,manager = [2, 2, 4, 2, 7, 5, 5, -1],informTime = [0, 0, 4, 0, 0, 0, 6, 0]) == 4\n assert candidate(n = 15,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],informTime = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(n = 25,headID = 12,manager = [12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, -1, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(n = 13,headID = 0,manager = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],informTime = [0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 88\n"}, "metadata": {"canonical_parameter_names": ["n", "headID", "manager", "informTime"], "leetcode_dataset_entry_point": "Solution().numOfMinutes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numOfMinutes(self, n: int, headID: int, manager: list[int], informTime: list[int]) -> int:", "container": "Solution", "callable": "numOfMinutes", "parameters": [{"name": "n", "type": "int"}, {"name": "headID", "type": "int"}, {"name": "manager", "type": "list[int]"}, {"name": "informTime", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1377, "task_id": "frog-position-after-t-seconds", "difficulty": "Hard", "problem_description": "Given an undirected tree consisting of n vertices numbered from 1 to n. A frog starts jumping from vertex 1. In one second, the frog jumps from its current vertex to another unvisited vertex if they are directly connected. The frog can not jump back to a visited vertex. In case the frog can jump to several vertices, it jumps randomly to one of them with the same probability. Otherwise, when the frog can not jump to any unvisited vertex, it jumps forever on the same vertex.\nThe edges of the undirected tree are given in the array edges, where edges[i] = [ai, bi] means that exists an edge connecting the vertices ai and bi.\nReturn the probability that after t seconds the frog is on the vertex target. Answers within 10-5 of the actual answer will be accepted.\n \nExample 1:\n\n\nInput: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 2, target = 4\nOutput: 0.16666666666666666 \nExplanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 probability to the vertex 2 after second 1 and then jumping with 1/2 probability to vertex 4 after second 2. Thus the probability for the frog is on the vertex 4 after 2 seconds is 1/3 * 1/2 = 1/6 = 0.16666666666666666. \n\nExample 2:\n\n\nInput: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 1, target = 7\nOutput: 0.3333333333333333\nExplanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 = 0.3333333333333333 probability to the vertex 7 after second 1. \n\n \nConstraints:\n\n1 <= n <= 100\nedges.length == n - 1\nedges[i].length == 2\n1 <= ai, bi <= n\n1 <= t <= 50\n1 <= target <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],t = 4,target = 10) == 0.16666666666666666\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6]],t = 2,target = 5) == 0.25\n assert candidate(n = 4,edges = [[1, 2], [1, 3], [2, 4]],t = 2,target = 4) == 0.5\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 7], [2, 4], [2, 6], [3, 5]],t = 2,target = 4) == 0.16666666666666666\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 7], [2, 4], [2, 6], [3, 5]],t = 1,target = 7) == 0.3333333333333333\n assert candidate(n = 1,edges = [],t = 10,target = 1) == 1.0\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [2, 5]],t = 3,target = 5) == 0.3333333333333333\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [1, 5]],t = 1,target = 3) == 0.25\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [2, 4], [2, 5]],t = 2,target = 4) == 0.25\n assert candidate(n = 3,edges = [[1, 2], [1, 3]],t = 2,target = 1) == 0\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10]],t = 4,target = 6) == 0.125\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [1, 5]],t = 2,target = 3) == 0.25\n assert candidate(n = 1,edges = [],t = 1,target = 1) == 1.0\n assert candidate(n = 4,edges = [[1, 2], [1, 3], [2, 4]],t = 3,target = 2) == 0\n assert candidate(n = 3,edges = [[1, 2], [1, 3]],t = 1,target = 2) == 0.5\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]],t = 5,target = 15) == 0.125\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27], [13, 28], [13, 29], [14, 30]],t = 5,target = 29) == 0.041666666666666664\n assert candidate(n = 14,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],t = 5,target = 14) == 0.08333333333333333\n assert candidate(n = 50,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35], [18, 36], [18, 37], [19, 38], [19, 39], [20, 40], [20, 41], [21, 42], [21, 43], [22, 44], [22, 45], [23, 46], [23, 47], [24, 48], [24, 49], [25, 50]],t = 7,target = 40) == 0.03125\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],t = 3,target = 9) == 0.3333333333333333\n assert candidate(n = 18,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [9, 17], [9, 18]],t = 4,target = 16) == 0.125\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [6, 18], [7, 19], [7, 20], [7, 21], [8, 22], [8, 23], [8, 24], [9, 25], [9, 26], [9, 27], [10, 28], [10, 29], [10, 30]],t = 6,target = 16) == 0.037037037037037035\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]],t = 3,target = 12) == 0.08333333333333333\n assert candidate(n = 28,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28]],t = 6,target = 24) == 0.0625\n assert candidate(n = 35,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35]],t = 15,target = 34) == 0.03125\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20]],t = 5,target = 15) == 0.125\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25]],t = 6,target = 22) == 0.0625\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25]],t = 4,target = 24) == 0.0625\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15]],t = 5,target = 11) == 0.08333333333333333\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30]],t = 10,target = 30) == 0.125\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15]],t = 3,target = 11) == 0.16666666666666666\n assert candidate(n = 18,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [9, 17], [10, 18]],t = 4,target = 13) == 0.125\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [6, 18], [7, 19], [7, 20], [7, 21], [8, 22], [8, 23], [8, 24], [9, 25]],t = 5,target = 22) == 0.037037037037037035\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [4, 12]],t = 4,target = 10) == 0.05555555555555555\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20]],t = 5,target = 16) == 0.0625\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25]],t = 7,target = 24) == 0.0625\n assert candidate(n = 40,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [10, 26], [10, 27], [11, 28], [11, 29], [11, 30], [12, 31], [12, 32], [12, 33], [13, 34], [13, 35], [14, 36], [14, 37], [14, 38], [15, 39], [15, 40]],t = 6,target = 39) == 0.027777777777777776\n assert candidate(n = 35,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35]],t = 9,target = 32) == 0.03125\n assert candidate(n = 35,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [6, 18], [7, 19], [7, 20], [7, 21], [8, 22], [8, 23], [8, 24], [9, 25], [9, 26], [9, 27], [10, 28], [10, 29], [10, 30], [11, 31], [11, 32], [11, 33], [12, 34], [12, 35]],t = 7,target = 25) == 0.037037037037037035\n assert candidate(n = 22,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22]],t = 5,target = 18) == 0.0625\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [8, 15]],t = 3,target = 10) == 0.08333333333333333\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12]],t = 3,target = 12) == 0.25\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25]],t = 7,target = 16) == 0.0625\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 20]],t = 5,target = 17) == 0.08333333333333333\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20]],t = 5,target = 13) == 0.08333333333333333\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15]],t = 3,target = 11) == 0.08333333333333333\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25]],t = 6,target = 16) == 0.08333333333333333\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 20]],t = 4,target = 15) == 0.125\n assert candidate(n = 18,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18]],t = 3,target = 18) == 0\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [7, 22], [8, 23], [8, 24], [8, 25], [9, 26], [9, 27], [9, 28], [10, 29], [10, 30]],t = 5,target = 23) == 0.037037037037037035\n assert candidate(n = 13,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13]],t = 5,target = 13) == 0.16666666666666666\n assert candidate(n = 18,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18]],t = 4,target = 18) == 0.08333333333333333\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]],t = 8,target = 27) == 0.041666666666666664\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30]],t = 7,target = 28) == 0.0625\n assert candidate(n = 16,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16]],t = 6,target = 16) == 0.08333333333333333\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25]],t = 7,target = 25) == 0.0625\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [8, 21], [9, 22], [9, 23], [10, 24], [10, 25]],t = 5,target = 20) == 0.05555555555555555\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]],t = 3,target = 12) == 0.125\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20]],t = 6,target = 15) == 0.08333333333333333\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 20]],t = 4,target = 15) == 0.08333333333333333\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],t = 4,target = 11) == 0.16666666666666666\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30]],t = 5,target = 29) == 0.0625\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12]],t = 4,target = 9) == 0.125\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20]],t = 6,target = 20) == 0.125\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "t", "target"], "leetcode_dataset_entry_point": "Solution().frogPosition", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def frogPosition(self, n: int, edges: list[list[int]], t: int, target: int) -> float:", "container": "Solution", "callable": "frogPosition", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "t", "type": "int"}, {"name": "target", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1380, "task_id": "lucky-numbers-in-a-matrix", "difficulty": "Easy", "problem_description": "Given an m x n matrix of distinct numbers, return all lucky numbers in the matrix in any order.\nA lucky number is an element of the matrix such that it is the minimum element in its row and maximum in its column.\n \nExample 1:\n\nInput: matrix = [[3,7,8],[9,11,13],[15,16,17]]\nOutput: [15]\nExplanation: 15 is the only lucky number since it is the minimum in its row and the maximum in its column.\n\nExample 2:\n\nInput: matrix = [[1,10,4,2],[9,3,8,7],[15,16,17,12]]\nOutput: [12]\nExplanation: 12 is the only lucky number since it is the minimum in its row and the maximum in its column.\n\nExample 3:\n\nInput: matrix = [[7,8],[1,2]]\nOutput: [7]\nExplanation: 7 is the only lucky number since it is the minimum in its row and the maximum in its column.\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n1 <= n, m <= 50\n1 <= matrix[i][j] <= 105.\nAll elements in the matrix are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[5, 9, 11], [9, 4, 8], [3, 15, 17]]) == []\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == [13]\n assert candidate(matrix = [[33, 18, 46, 39], [68, 35, 41, 26], [55, 87, 52, 37], [17, 47, 99, 22]]) == []\n assert candidate(matrix = [[3, 7, 8], [9, 11, 13], [15, 16, 17]]) == [15]\n assert candidate(matrix = [[5, 1, 4], [1, 5, 7], [8, 3, 2]]) == []\n assert candidate(matrix = [[3, 6], [7, 1], [5, 9]]) == []\n assert candidate(matrix = [[40, 10], [24, 30]]) == []\n assert candidate(matrix = [[5, 9, 11], [9, 2, 8], [1, 6, 3]]) == []\n assert candidate(matrix = [[1, 10, 4, 2], [9, 3, 8, 7], [15, 16, 17, 12]]) == [12]\n assert candidate(matrix = [[1]]) == [1]\n assert candidate(matrix = [[7, 8], [1, 2]]) == [7]\n assert candidate(matrix = [[36376, 85652], [55712, 5396]]) == []\n assert candidate(matrix = [[33, 18, 46], [19, 66, 58], [54, 88, 92]]) == [54]\n assert candidate(matrix = [[100000, 99999, 99998, 99997], [99996, 99995, 99994, 99993], [99992, 99991, 99990, 99989]]) == [99997]\n assert candidate(matrix = [[23, 45, 12, 78, 56], [89, 34, 23, 10, 32], [67, 88, 90, 11, 54], [12, 34, 56, 78, 90], [100, 200, 300, 400, 500]]) == [100]\n assert candidate(matrix = [[100000, 90000, 80000], [70000, 60000, 50000], [40000, 30000, 20000]]) == [80000]\n assert candidate(matrix = [[1, 3, 5, 7, 9], [10, 12, 14, 16, 18], [11, 13, 15, 17, 19], [20, 22, 24, 26, 28], [21, 23, 25, 27, 29]]) == [21]\n assert candidate(matrix = [[55, 54, 53, 52, 51], [45, 44, 43, 42, 41], [35, 34, 33, 32, 31], [25, 24, 23, 22, 21], [15, 14, 13, 12, 11]]) == [51]\n assert candidate(matrix = [[50, 49, 48, 47, 46], [45, 44, 43, 42, 41], [40, 39, 38, 37, 36], [35, 34, 33, 32, 31], [30, 29, 28, 27, 26]]) == [46]\n assert candidate(matrix = [[100000, 99999, 99998], [1, 2, 3], [99997, 99996, 99995]]) == [99998]\n assert candidate(matrix = [[12345, 67890, 23456, 34567], [78901, 89012, 90123, 12346], [65432, 54321, 43210, 32109]]) == []\n assert candidate(matrix = [[3, 6, 9, 12, 15], [2, 5, 8, 11, 14], [1, 4, 7, 10, 13]]) == [3]\n assert candidate(matrix = [[34, 56, 12, 90], [78, 89, 45, 67], [23, 34, 56, 78], [90, 12, 34, 56]]) == []\n assert candidate(matrix = [[42, 58, 76], [89, 21, 34], [95, 67, 12], [56, 45, 83]]) == []\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [7, 8, 9, 10, 11, 12], [12, 11, 10, 9, 8, 7], [13, 14, 15, 16, 17, 18], [18, 17, 16, 15, 14, 13]]) == []\n assert candidate(matrix = [[47, 2, 37, 58, 59], [1, 53, 34, 24, 60], [4, 22, 50, 18, 61], [11, 49, 16, 57, 35], [54, 3, 14, 13, 55]]) == []\n assert candidate(matrix = [[50000, 40000, 30000, 20000, 10000], [40001, 30001, 20001, 10001, 50001], [30002, 20002, 10002, 50002, 40002], [20003, 10003, 50003, 40003, 30003], [10004, 50004, 40004, 30004, 20004]]) == []\n assert candidate(matrix = [[25, 15, 35, 20], [10, 5, 45, 40], [30, 2, 60, 50], [65, 55, 5, 3]]) == []\n assert candidate(matrix = [[50000, 40000, 30000, 20000, 10000], [90000, 80000, 70000, 60000, 50000], [1, 2, 3, 4, 5]]) == [50000]\n assert candidate(matrix = [[100000, 99999, 99998], [1, 2, 3], [99997, 99996, 99995]]) == [99998]\n assert candidate(matrix = [[100000, 1, 100, 10], [1000, 99999, 2, 50], [99998, 500, 3, 1000], [50, 10000, 100000, 4]]) == []\n assert candidate(matrix = [[50000, 50001, 50002, 50003, 50004], [49999, 49998, 49997, 49996, 49995], [49994, 49993, 49992, 49991, 49990]]) == [50000]\n assert candidate(matrix = [[99999, 1, 2, 3, 4, 5], [5, 99998, 6, 7, 8, 9], [9, 10, 99997, 12, 13, 14], [14, 15, 16, 99996, 18, 19], [19, 20, 21, 22, 99995, 24]]) == []\n assert candidate(matrix = [[42, 41, 44, 43], [38, 39, 36, 37], [46, 45, 48, 47], [50, 49, 52, 51]]) == [49]\n assert candidate(matrix = [[50000, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23], [24, 25, 26, 27], [28, 29, 30, 31], [32, 33, 34, 35], [36, 37, 38, 39], [40, 41, 42, 43], [44, 45, 46, 47], [48, 49, 50, 51]]) == []\n assert candidate(matrix = [[34, 77, 56, 23], [89, 10, 45, 67], [55, 88, 22, 33], [44, 66, 77, 88]]) == []\n assert candidate(matrix = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20], [21, 23, 25, 27, 29]]) == [21]\n assert candidate(matrix = [[100000, 99999, 99998, 99997, 99996], [99995, 99994, 99993, 99992, 99991], [99990, 99989, 99988, 99987, 99986], [99985, 99984, 99983, 99982, 99981]]) == [99996]\n assert candidate(matrix = [[10, 20, 30, 40], [9, 8, 7, 6], [5, 4, 3, 2], [1, 18, 19, 20]]) == [10]\n assert candidate(matrix = [[50000, 1, 50001, 50002], [50003, 50004, 50005, 50006], [50007, 50008, 2, 50009], [50010, 50011, 50012, 50013]]) == [50010]\n assert candidate(matrix = [[33, 44, 55, 66, 77, 88, 99], [22, 34, 45, 56, 67, 78, 89], [11, 23, 35, 46, 57, 68, 79], [10, 21, 32, 43, 54, 65, 76], [9, 20, 31, 42, 53, 64, 75], [8, 19, 30, 41, 52, 63, 74], [7, 18, 29, 40, 51, 62, 73]]) == [33]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16]]) == [16]\n assert candidate(matrix = [[8, 16, 9, 12, 15], [10, 5, 14, 6, 13], [18, 17, 11, 7, 4], [19, 20, 3, 1, 2]]) == []\n assert candidate(matrix = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [5, 1, 55, 59, 60], [2, 3, 6, 7, 8], [61, 62, 63, 64, 65]]) == [61]\n assert candidate(matrix = [[12345, 67890, 11111, 22222], [33333, 44444, 55555, 66666], [77777, 88888, 99999, 100000], [100001, 100002, 100003, 100004]]) == [100001]\n assert candidate(matrix = [[50000, 49999, 1], [49998, 49997, 2], [49996, 49995, 3]]) == [3]\n assert candidate(matrix = [[3, 6, 8, 14, 5], [20, 10, 16, 19, 17], [7, 1, 15, 4, 13], [18, 9, 21, 12, 11]]) == [10]\n assert candidate(matrix = [[40, 20, 60, 70], [30, 10, 50, 80], [25, 5, 35, 90], [15, 2, 45, 100]]) == [20]\n assert candidate(matrix = [[8, 5, 9, 10, 7], [6, 1, 3, 4, 2], [11, 12, 14, 15, 13], [16, 17, 19, 20, 18], [21, 22, 24, 25, 23]]) == [21]\n assert candidate(matrix = [[10, 15, 20, 25], [5, 30, 35, 40], [45, 41, 42, 43], [50, 55, 60, 65]]) == [50]\n assert candidate(matrix = [[85, 21, 17, 45], [62, 59, 100, 58], [90, 28, 29, 83]]) == []\n assert candidate(matrix = [[50000, 45000, 40000, 35000, 30000], [29000, 24000, 20000, 15000, 10000], [9999, 4999, 2499, 1249, 624], [312, 156, 78, 39, 19], [9, 4, 2, 1, 0]]) == [30000]\n assert candidate(matrix = [[34, 67, 89, 12], [12, 98, 23, 45], [56, 33, 78, 88], [87, 66, 55, 44]]) == []\n assert candidate(matrix = [[100, 200, 300, 400], [150, 250, 350, 450], [50, 150, 250, 350], [200, 300, 400, 500]]) == [200]\n assert candidate(matrix = [[100, 99, 98, 97, 96], [95, 94, 93, 92, 91], [90, 89, 88, 87, 86], [85, 84, 83, 82, 81], [80, 79, 78, 77, 76]]) == [96]\n assert candidate(matrix = [[10000, 10001, 10002], [9999, 10000, 10003], [9998, 9997, 10000]]) == [10000]\n assert candidate(matrix = [[98, 99, 100], [95, 96, 97], [92, 93, 94], [89, 90, 91]]) == [98]\n assert candidate(matrix = [[5, 3, 9, 1], [8, 4, 2, 7], [6, 10, 12, 11]]) == []\n assert candidate(matrix = [[5, 8, 9, 10], [1, 3, 4, 7], [11, 12, 13, 14], [6, 2, 0, 15]]) == [11]\n assert candidate(matrix = [[1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [2, 4, 6, 8, 0], [8, 6, 4, 2, 10]]) == []\n assert candidate(matrix = [[55, 56, 57], [54, 53, 58], [51, 52, 59]]) == [55]\n assert candidate(matrix = [[101, 102, 103, 104], [105, 106, 107, 108], [109, 110, 111, 112], [113, 114, 115, 116], [117, 118, 119, 120]]) == [117]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [1, 5, 4, 3, 2], [3, 4, 5, 1, 2]]) == []\n assert candidate(matrix = [[9, 8, 7, 6], [5, 4, 3, 2], [1, 10, 11, 12], [13, 14, 15, 16]]) == [13]\n assert candidate(matrix = [[10, 50, 30, 40], [60, 20, 90, 80], [70, 100, 110, 120], [130, 140, 150, 160]]) == [130]\n assert candidate(matrix = [[100, 90, 80, 70, 60], [50, 40, 30, 20, 10], [1, 101, 201, 301, 401], [9, 109, 209, 309, 409], [8, 108, 208, 308, 408]]) == []\n assert candidate(matrix = [[55, 65, 75, 85, 95], [15, 25, 35, 45, 5], [60, 70, 80, 90, 100], [1, 2, 3, 4, 6]]) == [60]\n assert candidate(matrix = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [12, 11, 10]]) == [10]\n assert candidate(matrix = [[23, 24, 25, 26, 27], [18, 19, 20, 21, 22], [13, 14, 15, 16, 17], [8, 9, 10, 11, 12], [3, 4, 5, 6, 7], [1, 2, 3, 4, 5]]) == [23]\n assert candidate(matrix = [[5, 12, 45, 32], [99, 3, 87, 67], [15, 16, 17, 18], [20, 21, 22, 23]]) == []\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == [31]\n assert candidate(matrix = [[22, 34, 40, 54], [2, 3, 7, 65], [99, 23, 35, 22]]) == []\n assert candidate(matrix = [[1, 99999, 2, 99998, 3, 99997], [99996, 4, 99995, 5, 99994, 6], [7, 99993, 8, 99992, 9, 99991]]) == []\n assert candidate(matrix = [[500, 400, 300], [200, 100, 300], [150, 50, 400], [450, 350, 250]]) == []\n assert candidate(matrix = [[99999, 10000, 10001], [99998, 99997, 10002], [1, 99996, 99995]]) == []\n assert candidate(matrix = [[10, 20, 30, 40], [50, 60, 70, 80], [1, 2, 3, 4], [5, 6, 7, 9]]) == [50]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]]) == [21]\n assert candidate(matrix = [[2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [20, 18, 16, 14, 12]]) == []\n assert candidate(matrix = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [9, 19, 29, 39, 49], [8, 18, 28, 38, 48]]) == [10]\n assert candidate(matrix = [[100, 200, 300, 400, 500], [99, 199, 299, 399, 499], [98, 198, 298, 398, 498], [97, 197, 297, 397, 497], [96, 196, 296, 396, 496]]) == [100]\n assert candidate(matrix = [[34, 73, 89, 52], [12, 76, 87, 42], [61, 94, 66, 21], [71, 54, 62, 78]]) == []\n assert candidate(matrix = [[100000, 99999, 99998], [99997, 99996, 99995], [99994, 99993, 99992]]) == [99998]\n assert candidate(matrix = [[999, 888, 777], [666, 555, 444], [333, 222, 111], [99, 88, 77]]) == [777]\n assert candidate(matrix = [[100, 200, 300], [250, 150, 100], [100, 300, 200], [50, 400, 250]]) == []\n assert candidate(matrix = [[8, 6, 4, 2, 0], [13, 11, 9, 7, 5], [18, 16, 14, 12, 10]]) == [10]\n assert candidate(matrix = [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39]]) == [31]\n assert candidate(matrix = [[2, 4, 6, 8, 10, 12], [1, 3, 5, 7, 9, 11], [11, 9, 7, 5, 3, 1], [12, 10, 8, 6, 4, 2], [13, 15, 17, 19, 21, 23]]) == [13]\n"}, "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().luckyNumbers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def luckyNumbers(self, matrix: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "luckyNumbers", "parameters": [{"name": "matrix", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1382, "task_id": "balance-a-binary-search-tree", "difficulty": "Medium", "problem_description": "Given the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any of them.\nA binary search tree is balanced if the depth of the two subtrees of every node never differs by more than 1.\n \nExample 1:\n\n\nInput: root = [1,null,2,null,3,null,4,null,null]\nOutput: [2,1,3,null,null,null,4]\nExplanation: This is not the only correct answer, [3,1,4,null,2] is also correct.\n\nExample 2:\n\n\nInput: root = [2,1,3]\nOutput: [2,1,3]\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 104].\n1 <= Node.val <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7])), tree_node([1, 2, 3, 4, 5, 6, 7]))\n assert is_same_tree(candidate(root = tree_node([3, 1, 4, None, 2])), tree_node([2, 1, 3, None, None, None, 4]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5])), tree_node([3, 1, 4, None, 2, None, 5]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 6, 2, 4, None, 7, 1, None, None, None, 8])), tree_node([4, 2, 6, 1, 3, 5, 8, None, None, None, None, None, None, None, 7]))\n assert is_same_tree(candidate(root = tree_node([10, 5, None, 2, 7, None, None, 1, 3, None, None, 6, 8])), tree_node([7, 5, 3, 2, 1, 6, 8, None, None, None, None, None, None, None, 10]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4])), tree_node([2, 4, 1, None, None, None, 3]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, 3, 7, None, 18])), tree_node([7, 3, 15, None, 5, 10, 18]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])), tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, None])), tree_node([2, 1, 3, None, None, None, 4]))\n assert is_same_tree(candidate(root = tree_node([2, 1, 3])), tree_node([2, 1, 3]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3])), tree_node([2, 1, 3]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, None, None, 6, 20])), tree_node([6, 5, 15, None, 10, None, 20]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13])), tree_node([1, 6, 7, 2, 10, 3, 11, None, 4, 8, 12, None, 5, 9, 13]))\n assert is_same_tree(candidate(root = tree_node([50, 30, 80, 10, 40, 60, 90, 5, 20, 35, 45, 55, 65, 85, 95, 1, 9, 15, 25, 32, 38, 42, 48, 52, 58, 63, 68, 75, 83, 92, 98])), tree_node([50, 30, 80, 10, 40, 60, 90, 5, 20, 35, 45, 55, 65, 85, 95, 1, 9, 15, 25, 32, 38, 42, 48, 52, 58, 63, 68, 75, 83, 92, 98]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])), tree_node([5, 2, 8, 1, 3, 6, 9, None, None, None, 4, None, 7, None, 10]))\n assert is_same_tree(candidate(root = tree_node([7, 3, 15, None, 4, 10, 20, 2, None, 5, 8, 13, 17, 22, 27])), tree_node([5, 2, 15, 3, 4, 10, 20, None, 22, 27, 7, None, 8, 13, 17]))\n assert is_same_tree(candidate(root = tree_node([9, 4, 20, 2, None, 15, 22, None, None, 11, 17, 21, 27, None, None, None, 13, None, None, None, None, 18, 24, 30, None, None, None, None, 23, 25, 29, 31])), tree_node([25, 11, 24, 4, 17, 29, 21, 2, 9, 15, 30, 23, 18, 20, 22, None, None, None, None, None, None, None, 31, None, None, None, 13, None, None, None, 27]))\n assert is_same_tree(candidate(root = tree_node([15, 10, 20, 5, 12, None, 25, None, None, 11, 13, 22, 30, None, None, 18, 24, None, None, 21, 23, 26, 29, None, None, None, None, 19])), tree_node([24, 12, 25, 10, 18, 20, 30, 5, 11, 26, 29, 15, 22, 21, 19, None, None, None, None, None, None, None, 13, None, None, None, None, None, None, None, 23]))\n assert is_same_tree(candidate(root = tree_node([25, 15, 35, 10, 20, 30, 40, 5, 12, 18, 22, 28, 32, 38, 45, 1, 7, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, 47, 4, 6, 8, 9, 14, 16, 24, 26, 36, 42, 44, 46, 48, 49])), tree_node([44, 14, 30, 6, 26, 49, 38, 1, 10, 13, 18, 21, 27, 33, 41, 47, 4, 7, 9, 12, 24, 17, 42, 20, 48, 23, 28, 31, 35, 39, 45, None, None, None, 5, None, 8, None, 11, None, 16, None, 15, None, 36, None, 19, None, 46, None, 22, None, 25, None, 29, None, 32, None, 37, None, 40, None, 43]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 6, 2, 4, None, 8, 1, None, None, None, 7, 9])), tree_node([5, 2, 7, 1, 3, 6, 8, None, None, None, 4, None, None, None, 9]))\n assert is_same_tree(candidate(root = tree_node([7, 3, 11, 2, 5, 9, 13, 1, 4, 6, 8, 10, 12, 14, 15])), tree_node([7, 3, 11, 2, 5, 9, 13, 1, 4, 6, 8, 10, 12, 14, 15]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 1, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38])), tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 1, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38]))\n assert is_same_tree(candidate(root = tree_node([50, 30, 70, 20, 40, 60, 80, 10, 25, 35, 45, 55, 65, 75, 85, 5, 15, 22, 28, 32, 38, 43, 47, 52, 58, 63, 68, 72, 78, 82, 87, 90, 95, 100])), tree_node([45, 22, 68, 10, 32, 55, 78, 5, 15, 28, 38, 50, 60, 72, 82, 90, 95, 100, 20, 25, 30, 35, 40, 47, 52, 58, 63, 70, 75, 80, 85, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 43, None, None, None, None, None, None, None, 65, None, None, None, None, None, None, None, 87]))\n assert is_same_tree(candidate(root = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])), tree_node([16, 8, 24, 4, 12, 20, 28, 2, 6, 10, 14, 18, 22, 26, 30, None, 15, 7, 17, 3, 19, 9, 21, 1, 23, 11, 25, 5, 27, 13, 29]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 2, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38, 1, 9, 11, 19, 21, 29, 31, 39, 40])), tree_node([14, 6, 26, 11, 39, 20, 33, 2, 19, 7, 40, 16, 23, 28, 36, 1, 9, 4, 5, 29, 31, 10, 12, 15, 17, 22, 24, 27, 30, 34, 37, None, None, None, 3, None, None, None, 21, None, None, None, 8, None, None, None, 13, None, None, None, 18, None, None, None, 25, None, None, None, 32, None, 35, None, 38]))\n assert is_same_tree(candidate(root = tree_node([10, 9, 11, 8, None, None, 12, 7, None, None, None, 13, 14, 6, None, None, None, None, 5])), tree_node([14, 5, 10, 6, 13, 8, 11, None, None, None, 7, None, 9, None, 12]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 8, 2, 4, None, 9, 1, None, None, None, 7, 10, 6, None, None, 11])), tree_node([5, 2, 11, 6, 3, 8, 9, None, 1, None, 4, None, 7, None, 10]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, None, None, 12, 20, 11, 13, 18, 25])), tree_node([13, 10, 18, 5, 11, 15, 20, None, None, None, 12, None, None, None, 25]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 6, 2, 4, None, None, 1, None, None, None, None, None, 8, 7])), tree_node([3, 1, 5, None, 2, 4, 6]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 8, 2, 4, 6, 9, 1, None, None, None, None, 7, None, None, 10])), tree_node([4, 1, 7, 10, 2, 5, 8, None, None, None, 3, None, 6, None, 9]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 20, 3, 7, 15, 25, 2, 4, 6, 8, 12, 18, 22, 27, 1, None, None, None, None, None, None, None, None, 9, None, None, 11, None, 13, None, 17, 16, 19, 21, None, 23, None, 24, 26, None, 28, None, 29])), tree_node([12, 3, 20, 1, 6, 9, 25, 26, 16, 4, 8, 29, 15, 23, 24, None, 17, 28, 2, None, 5, 7, 10, None, 19, 21, 18, 11, 22, 13, 27]))\n assert is_same_tree(candidate(root = tree_node([7, 3, 15, None, None, 9, 20])), tree_node([9, 3, 15, None, 7, None, 20]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 13, 19, 21])), tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 13, 19, 21]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 7, 13, 17, 23, 27, 33, 37, 0, 2, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38, 39])), tree_node([16, 7, 26, 1, 13, 22, 32, 0, 5, 10, 15, 18, 24, 28, 34, 38, 39, 2, 4, 6, 8, 12, 14, 20, 23, 25, 27, 30, 33, 35, 37, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 17, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 36]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, None, 7, 12, 17, 6, 8, 11, 13, 16, 18])), tree_node([11, 7, 15, 5, 8, 12, 17, None, 6, None, 10, None, 13, 16, 18]))\n assert is_same_tree(candidate(root = tree_node([10, 5, None, 2, 7, None, 1, 3, 6, 8, 9])), tree_node([5, 8, 7, 2, 1, 3, 6, None, None, None, 9, None, None, None, 10]))\n assert is_same_tree(candidate(root = tree_node([20, 15, 25, 10, 18, 22, 30, 5, 13, None, None, 16, 19, None, None, None, None, 1, None, None, 7, 12])), tree_node([20, 1, 12, 5, 15, 7, 25, None, 10, 13, 18, 16, 22, 19, 30]))\n assert is_same_tree(candidate(root = tree_node([20, 10, None, 5, 15, None, 3, 7, None, None, None, None, None, 4])), tree_node([10, 5, 15, None, 3, 7, 20]))\n assert is_same_tree(candidate(root = tree_node([6, 2, 8, 0, 4, 7, 9, None, None, 3, 5, None, None, None, None, None, None, None, None, None, None, None])), tree_node([5, 2, 7, 0, 3, 6, 8, None, None, None, 4, None, None, None, 9]))\n assert is_same_tree(candidate(root = tree_node([2, 1, 3, None, None, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])), tree_node([12, 10, 3, 1, 11, 7, 5, None, 2, 6, 4, None, 13, 8, 9]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 9, 1, 4, 7, 10, None, None, 2, None, 6, 8, None, None, None, None, 11])), tree_node([11, 2, 8, 1, 4, 6, 9, None, 3, None, 5, None, 7, None, 10]))\n assert is_same_tree(candidate(root = tree_node([8, 5, 11, 3, 6, None, None, 2, None, 4, None, 1, None, 7])), tree_node([7, 2, 6, 1, 3, 4, 8, None, None, None, 5, None, None, None, 11]))\n assert is_same_tree(candidate(root = tree_node([7, 1, 9, None, 2, None, 10, None, 3, None, 4, None, 5, None, 6])), tree_node([7, 2, 10, 1, 3, 9, 4, None, None, None, 5, None, None, None, 6]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, None, None, 13, 20, 12, 14, 18, 25, 16, 19, 22, 27])), tree_node([22, 16, 15, 5, 19, 14, 20, None, 10, 12, 13, None, 27, 18, 25]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 8, 2, 4, 6, 9, 1, None, 3.5, 4.5, 5.5, 6.5])), tree_node([4.5, 3, 6, 1, 3.5, 5, 8, None, 2, None, 4, None, 5.5, 6.5, 9]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])), tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7])), tree_node([4, 2, 6, 1, 3, 5, 7]))\n assert is_same_tree(candidate(root = tree_node([50, 30, 70, 20, 40, 60, 80, 10, 25, 35, 45, 55, 65, 75, 90, 5, 15, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 95])), tree_node([40, 15, 65, 5, 25, 50, 75, 95, 10, 20, 30, 45, 55, 70, 80, None, None, None, None, None, None, None, 35, None, None, None, 60, None, None, None, 90]))\n assert is_same_tree(candidate(root = tree_node([1, 2, None, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8])), tree_node([5, 3, 7, 2, 4, 6, 8, None, None, None, None, None, None, None, 1]))\n assert is_same_tree(candidate(root = tree_node([8, 5, 11, 2, 7, 10, 12, 1, None, 6, None, 9])), tree_node([7, 2, 10, 1, 5, 8, 11, None, None, None, 6, None, 9, None, 12]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 22, 27, 32, 37, 1, 4, 6, 8, 11, 13, 16, 18, 19, 21, 23, 24, 26, 28, 29, 31, 33, 34, 36, 38, 39, 40])), tree_node([16, 39, 27, 3, 10, 19, 28, 1, 4, 40, 12, 18, 21, 30, 29, 33, 34, 36, 38, 6, 7, 11, 13, 17, 20, 22, 25, 24, 26, 35, 37, None, None, None, None, None, None, None, 5, None, None, None, 8, None, None, None, 15, None, None, None, None, None, None, None, 23, None, None, None, 32, None, None, None, 31]))\n assert is_same_tree(candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15])), tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])), tree_node([5, 2, 7, 1, 3, 6, 8, None, None, None, 4, None, None, None, 9]))\n assert is_same_tree(candidate(root = tree_node([4, 2, 6, 1, 3, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15])), tree_node([4, 2, 6, 1, 3, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, None, None, 6])), tree_node([7, 5, 15, 3, 6, 10, 18]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8])), tree_node([4, 2, 6, 1, 3, 5, 7, None, None, None, None, None, None, None, 8]))\n assert is_same_tree(candidate(root = tree_node([4, 2, 6, 1, 3, 5, 7, 0, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5])), tree_node([4, 2, 6, 1, 3, 5, 7, 0, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5]))\n assert is_same_tree(candidate(root = tree_node([25, 10, 30, 5, 15, 27, 40, 1, None, 8, 12, None, 18, 22, 29, 38, None, None, 3, None, 7, None, 11, None, 13, None, 17, None, 21, None, 23, None, 33, None, 35, None, 37, None, 42, None, 45, None, 48])), tree_node([33, 8, 22, 45, 48, 18, 40, 38, 5, 3, 12, 25, 35, 13, 17, None, 21, 1, 10, None, 23, 15, 7, None, 27, 11, 30, None, 37, 29, 42]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])), tree_node([23, 19, 27, 17, 21, 25, 29, 16, 18, 20, 22, 24, 26, 28, 30, None, 8, 4, 9, 2, 10, 5, 11, 1, 12, 6, 13, 3, 14, 7, 15]))\n assert is_same_tree(candidate(root = tree_node([7, 3, 15, None, 5, 9, 20, None, 4, 6, 8, 11, 17, 19, 22, None, 2, None, None, None, None, None, None, 10])), tree_node([6, 19, 15, 5, 22, 9, 20, 3, 10, 4, 7, 2, 8, 11, 17]))\n assert is_same_tree(candidate(root = tree_node([25, 15, 50, 10, 22, 35, 60, 5, 12, 18, 24, 30, 44, 55, 65, 2, 7, None, 13, None, None, 19, 23, None, 29, 33, 41, 47, 53, 63, None, None, None, 3, 8, 11, 14, None, None, 20, None, 28, None, None, 32, None, 36, 40, None, 45, 48, None, 52, 58, 62, 67, None, None, None, None, None, None, 6, None, None, None, None, None, 4, None, None, 9, None, None, 16, None, 21, 26, None, 31, 34, 38, 42, None, None, 46, None, 50, None, 54, 57, 61, 66, 68, None, None, None, None, None, 1, None, None, None, None, None, None, None, None, None, 17, None, 27, None, None, 37, None, None, None, None, None, None, None, None, None, None, 43, None, None, None, 51, None, None, 56, None, None, 64, None, 69])), tree_node([28, 8, 45, 31, 22, 46, 63, 68, 1, 13, 6, 32, 47, 16, 21, 2, 58, 34, 67, 12, 15, 24, 25, 35, 41, 50, 50, 48, 57, 27, 37, None, 5, 26, 3, 62, 7, 38, 42, 10, 11, 14, 18, 19, 20, 23, 30, 29, 33, 44, 36, 4, 40, 55, 9, 53, 54, 17, 60, 52, 61, 66, 65]))\n assert is_same_tree(candidate(root = tree_node([1, None, 3, None, 5, None, 7, None, 9, None, 11, None, 13, None, 15])), tree_node([7, 3, 11, 1, 5, 9, 13, None, None, None, None, None, None, None, 15]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), tree_node([10, 18, 6, 8, 19, 11, 14, 16, 17, 9, 2, 5, 1, 13, 7, None, None, None, 4, None, None, None, 20, None, None, None, 12, None, 3, None, 15]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 1, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38, None, None, 2, 9, 11, 19, 21, 29, 31, 39])), tree_node([15, 7, 27, 9, 31, 22, 34, 3, 11, 8, 39, 17, 24, 30, 36, 1, 2, 5, 6, 21, 29, 12, 13, 16, 18, 23, 25, 28, 32, 35, 37, None, None, None, 4, None, None, None, 19, None, None, None, 10, None, None, None, 14, None, None, None, 20, None, None, None, 26, None, None, None, 33, None, None, None, 38]))\n assert is_same_tree(candidate(root = tree_node([50, 30, 70, 20, 40, 60, 80, 10, 25, 35, 45, 55, 65, 75, 90, 5, None, 15, None, 28, None, 32, None, 38, None, 43, None, 48, None, 52, None, 58, None, 63, None, 68, None, 72, None, 78, None, 83, None, 88, None, 95])), tree_node([50, 30, 70, 20, 40, 60, 80, 5, 15, 28, 32, 38, 43, 48, 52, 58, 10, 63, 25, 68, 35, 72, 45, 78, 55, 83, 65, 88, 75, 95, 90]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])), tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 20, 3, 7, 15, 25, 2, 4, 6, 8, 13, 17, 22, 27, 1, 9, 11, 14, 16, 18, 21, 23, 26, 28, 30])), tree_node([21, 4, 15, 9, 16, 10, 20, 1, 3, 14, 18, 8, 13, 30, 25, None, 2, None, 11, None, 5, 6, 7, None, 23, 26, 28, None, 17, 22, 27]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 22, 27, 32, 37, 1, 4, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 33, 36, 38])), tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 22, 27, 32, 37, 1, 4, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 33, 36, 38]))\n assert is_same_tree(candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 40, 60, 80, 110, 140, 160, 190, 5, 15, 35, 45, 55, 65, 70, 85, 90, 105, 115, 135, 145, 155, 165, 185, 195, 1, 9, 20, 30, 41, 49, 51, 59, 61, 69, 71, 79, 81, 89, 91, 99, 101, 109, 111, 119, 121, 129, 131, 139, 141, 149, 151, 159, 161, 169, 171, 179, 181, 189, 191, 199, 200])), tree_node([89, 41, 135, 10, 60, 109, 151, 5, 15, 51, 75, 99, 119, 145, 161, 195, 1, 9, 25, 49, 59, 65, 70, 91, 101, 111, 121, 150, 160, 159, 169, 179, 181, 189, 191, 199, 200, 20, 30, 40, 45, 50, 55, 69, 71, 79, 81, 85, 100, 90, 110, 105, 125, 115, 140, 131, 139, 141, 149, 175, 165, 190, 185, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 35, None, None, None, None, None, None, None, 61, None, None, None, None, None, None, None, 80, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 129, None, None, None, None, None, None, None, 155, None, None, None, None, None, None, None, 171]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, None, 7, 12, 18, None, 6, 9, 11, 13, 16, None, 8, 14, None, None, 10.5, 14.5, 16.5, 17.5])), tree_node([11, 8, 13, 7, 14, 15, 18, 5, 6, 10, 9, 10.5, 14.5, 16.5, 17.5, None, None, None, None, None, None, None, 12, None, None, None, None, None, None, None, 16]))\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().balanceBST", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def balanceBST(self, root: TreeNode | None) -> TreeNode | None:", "container": "Solution", "callable": "balanceBST", "parameters": [{"name": "root", "type": "TreeNode | None"}], "return_type": "TreeNode | None", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1383, "task_id": "maximum-performance-of-a-team", "difficulty": "Hard", "problem_description": "You are given two integers n and k and two integer arrays speed and efficiency both of length n. There are n engineers numbered from 1 to n. speed[i] and efficiency[i] represent the speed and efficiency of the ith engineer respectively.\nChoose at most k different engineers out of the n engineers to form a team with the maximum performance.\nThe performance of a team is the sum of its engineers' speeds multiplied by the minimum efficiency among its engineers.\nReturn the maximum performance of this team. Since the answer can be a huge number, return it modulo 109 + 7.\n \nExample 1:\n\nInput: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 2\nOutput: 60\nExplanation: \nWe have the maximum performance of the team by selecting engineer 2 (with speed=10 and efficiency=4) and engineer 5 (with speed=5 and efficiency=7). That is, performance = (10 + 5) * min(4, 7) = 60.\n\nExample 2:\n\nInput: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 3\nOutput: 68\nExplanation:\nThis is the same example as the first but k = 3. We can select engineer 1, engineer 2 and engineer 5 to get the maximum performance of the team. That is, performance = (2 + 10 + 5) * min(5, 4, 7) = 68.\n\nExample 3:\n\nInput: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 4\nOutput: 72\n\n \nConstraints:\n\n1 <= k <= n <= 105\nspeed.length == n\nefficiency.length == n\n1 <= speed[i] <= 105\n1 <= efficiency[i] <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,speed = [2, 10, 3, 1, 5, 8],efficiency = [5, 4, 3, 9, 7, 2],k = 2) == 60\n assert candidate(n = 6,speed = [2, 10, 3, 1, 5, 8],efficiency = [5, 4, 3, 9, 7, 2],k = 3) == 68\n assert candidate(n = 5,speed = [4, 1, 12, 7, 8],efficiency = [2, 10, 8, 19, 4],k = 3) == 160\n assert candidate(n = 1,speed = [1],efficiency = [1],k = 1) == 1\n assert candidate(n = 10,speed = [9, 7, 6, 5, 4, 3, 2, 1, 10, 8],efficiency = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 40\n assert candidate(n = 3,speed = [2, 8, 2],efficiency = [2, 7, 1],k = 2) == 56\n assert candidate(n = 10,speed = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],efficiency = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 180\n assert candidate(n = 5,speed = [3, 5, 9, 7, 6],efficiency = [5, 3, 8, 6, 2],k = 4) == 96\n assert candidate(n = 5,speed = [5, 4, 3, 2, 1],efficiency = [1, 2, 3, 4, 5],k = 3) == 18\n assert candidate(n = 5,speed = [10, 20, 30, 40, 50],efficiency = [50, 40, 30, 20, 10],k = 3) == 1800\n assert candidate(n = 3,speed = [1, 2, 3],efficiency = [3, 2, 1],k = 2) == 6\n assert candidate(n = 10,speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],efficiency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 100\n assert candidate(n = 6,speed = [2, 10, 3, 1, 5, 8],efficiency = [5, 4, 3, 9, 7, 2],k = 4) == 72\n assert candidate(n = 5,speed = [1, 1, 1, 1, 1],efficiency = [1, 1, 1, 1, 1],k = 5) == 5\n assert candidate(n = 10,speed = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],efficiency = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 5) == 996499717\n assert candidate(n = 10,speed = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],efficiency = [50, 40, 30, 20, 10, 90, 80, 70, 60, 50],k = 3) == 13650\n assert candidate(n = 50,speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],efficiency = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(n = 25,speed = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000, 180000, 190000, 200000, 210000, 220000, 230000, 240000, 250000],efficiency = [250000, 240000, 230000, 220000, 210000, 200000, 190000, 180000, 170000, 160000, 150000, 140000, 130000, 120000, 110000, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 15) == 999999062\n assert candidate(n = 20,speed = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],efficiency = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 10) == 2400\n assert candidate(n = 20,speed = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 5000, 4000, 3000, 2000, 1000, 500, 400, 300, 200, 100],efficiency = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 10) == 980000000\n assert candidate(n = 5,speed = [10, 10, 10, 10, 10],efficiency = [10, 10, 10, 10, 10],k = 3) == 300\n assert candidate(n = 25,speed = [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 95000, 100000, 105000, 110000, 115000, 120000, 125000],efficiency = [125, 120, 115, 110, 105, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5],k = 15) == 33750000\n assert candidate(n = 10,speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],efficiency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 30\n assert candidate(n = 50,speed = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000, 21000, 22000, 23000, 24000, 25000, 26000, 27000, 28000, 29000, 30000, 31000, 32000, 33000, 34000, 35000, 36000, 37000, 38000, 39000, 40000, 41000, 42000, 43000, 44000, 45000, 46000, 47000, 48000, 49000, 50000],efficiency = [50000, 49000, 48000, 47000, 46000, 45000, 44000, 43000, 42000, 41000, 40000, 39000, 38000, 37000, 36000, 35000, 34000, 33000, 32000, 31000, 30000, 29000, 28000, 27000, 26000, 25000, 24000, 23000, 22000, 21000, 20000, 19000, 18000, 17000, 16000, 15000, 14000, 13000, 12000, 11000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],k = 25) == 499999937\n assert candidate(n = 8,speed = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000],efficiency = [100, 150, 200, 250, 300, 350, 400, 450],k = 4) == 55000000\n assert candidate(n = 15,speed = [2, 4, 5, 7, 8, 10, 12, 15, 18, 20, 25, 30, 35, 40, 45],efficiency = [3, 5, 2, 8, 7, 4, 6, 9, 10, 11, 13, 12, 15, 14, 16],k = 6) == 2145\n assert candidate(n = 15,speed = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],efficiency = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30],k = 8) == 15300\n assert candidate(n = 15,speed = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],efficiency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 2450\n assert candidate(n = 50,speed = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 5000, 4000, 3000, 2000, 1000, 500, 400, 300, 200, 100, 99, 88, 77, 66, 55, 44, 33, 22, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 200, 300, 400, 500, 600, 700, 800, 900],efficiency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 999, 888, 777, 666, 555, 444, 333, 222, 111, 11, 22, 33, 44, 55, 66, 77, 88, 99, 100],k = 15) == 2388600\n assert candidate(n = 20,speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],efficiency = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 680\n assert candidate(n = 25,speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],efficiency = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 1350\n assert candidate(n = 20,speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],efficiency = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 10) == 68000\n assert candidate(n = 50,speed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000],efficiency = [5000, 4900, 4800, 4700, 4600, 4500, 4400, 4300, 4200, 4100, 4000, 3900, 3800, 3700, 3600, 3500, 3400, 3300, 3200, 3100, 3000, 2900, 2800, 2700, 2600, 2500, 2400, 2300, 2200, 2100, 2000, 1900, 1800, 1700, 1600, 1500, 1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 25) == 95000000\n assert candidate(n = 12,speed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],efficiency = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 12],k = 6) == 40000\n assert candidate(n = 10,speed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],efficiency = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 5500\n assert candidate(n = 15,speed = [5, 3, 8, 2, 7, 6, 4, 9, 1, 11, 10, 12, 13, 14, 15],efficiency = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 290\n assert candidate(n = 10,speed = [1, 100000, 100, 1000, 10000, 10, 100000, 10000, 1000, 1],efficiency = [100000, 1, 10000, 100, 1000, 100000, 1000, 100, 10, 1],k = 5) == 110111000\n assert candidate(n = 20,speed = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],efficiency = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5],k = 10) == 17000\n assert candidate(n = 15,speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],efficiency = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 7) == 2940\n assert candidate(n = 20,speed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],efficiency = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 68000\n assert candidate(n = 75,speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750],efficiency = [750, 740, 730, 720, 710, 700, 690, 680, 670, 660, 650, 640, 630, 620, 610, 600, 590, 580, 570, 560, 550, 540, 530, 520, 510, 500, 490, 480, 470, 460, 450, 440, 430, 420, 410, 400, 390, 380, 370, 360, 350, 340, 330, 320, 310, 300, 290, 280, 270, 260, 250, 240, 230, 220, 210, 200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 50) == 3315000\n"}, "metadata": {"canonical_parameter_names": ["n", "speed", "efficiency", "k"], "leetcode_dataset_entry_point": "Solution().maxPerformance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxPerformance(self, n: int, speed: list[int], efficiency: list[int], k: int) -> int:", "container": "Solution", "callable": "maxPerformance", "parameters": [{"name": "n", "type": "int"}, {"name": "speed", "type": "list[int]"}, {"name": "efficiency", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1385, "task_id": "find-the-distance-value-between-two-arrays", "difficulty": "Easy", "problem_description": "Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays.\nThe distance value is defined as the number of elements arr1[i] such that there is not any element arr2[j] where |arr1[i]-arr2[j]| <= d.\n \nExample 1:\n\nInput: arr1 = [4,5,8], arr2 = [10,9,1,8], d = 2\nOutput: 2\nExplanation: \nFor arr1[0]=4 we have: \n|4-10|=6 > d=2 \n|4-9|=5 > d=2 \n|4-1|=3 > d=2 \n|4-8|=4 > d=2 \nFor arr1[1]=5 we have: \n|5-10|=5 > d=2 \n|5-9|=4 > d=2 \n|5-1|=4 > d=2 \n|5-8|=3 > d=2\nFor arr1[2]=8 we have:\n|8-10|=2 <= d=2\n|8-9|=1 <= d=2\n|8-1|=7 > d=2\n|8-8|=0 <= d=2\n\nExample 2:\n\nInput: arr1 = [1,4,2,3], arr2 = [-4,-3,6,10,20,30], d = 3\nOutput: 2\n\nExample 3:\n\nInput: arr1 = [2,1,100,3], arr2 = [-5,-2,10,-3,7], d = 6\nOutput: 1\n\n \nConstraints:\n\n1 <= arr1.length, arr2.length <= 500\n-1000 <= arr1[i], arr2[j] <= 1000\n0 <= d <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr1 = [10, 20, 30],arr2 = [5, 15, 25],d = 4) == 3\n assert candidate(arr1 = [-1000, 1000],arr2 = [-500, 500],d = 499) == 2\n assert candidate(arr1 = [4, 5, 8],arr2 = [10, 9, 1, 8],d = 2) == 2\n assert candidate(arr1 = [1, 4, 2, 3],arr2 = [-4, -3, 6, 10, 20, 30],d = 3) == 2\n assert candidate(arr1 = [-1, -2, -3],arr2 = [1, 2, 3],d = 2) == 2\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [1, 2, 3, 4],d = 0) == 4\n assert candidate(arr1 = [1000],arr2 = [-1000],d = 1999) == 1\n assert candidate(arr1 = [1],arr2 = [1],d = 0) == 0\n assert candidate(arr1 = [2, 1, 100, 3],arr2 = [-5, -2, 10, -3, 7],d = 6) == 1\n assert candidate(arr1 = [1, 2, 3],arr2 = [4, 5, 6],d = 0) == 3\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [6, 7, 8, 9, 10],d = 1) == 4\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],d = 49) == 0\n assert candidate(arr1 = [-1000, -900, -800, -700, -600],arr2 = [600, 700, 800, 900, 1000],d = 100) == 5\n assert candidate(arr1 = [-100, -200, -300],arr2 = [-50, -150, -250],d = 49) == 3\n assert candidate(arr1 = [500, 500, 500, 500, 500],arr2 = [500, 500, 500, 500, 500],d = 0) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [1, 2, 3, 4, 5],d = 5) == 4\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [10, 20, 30, 40, 50],d = 10) == 0\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 4, 6, 8, 10],d = 1) == 0\n assert candidate(arr1 = [500, 1000, 1500, 2000],arr2 = [400, 900, 1400, 1900],d = 100) == 0\n assert candidate(arr1 = [0, 100, 200, 300, 400],arr2 = [50, 150, 250, 350, 450],d = 50) == 0\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [50, 150, 250, 350, 450],d = 49) == 5\n assert candidate(arr1 = [0, 5, 10, 15, 20],arr2 = [3, 6, 9, 12, 18],d = 2) == 2\n assert candidate(arr1 = [500, 400, 300, 200, 100],arr2 = [0, 100, 200, 300, 400, 500],d = 99) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45, 55],d = 9) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45, 55],d = 4) == 5\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10],d = 0) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 1) == 0\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [1, -1, 2, -2],d = 1) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [6, 7, 8, 9, 10],d = 0) == 5\n assert candidate(arr1 = [-100, -200, -300, -400, -500],arr2 = [100, 200, 300, 400, 500],d = 150) == 5\n assert candidate(arr1 = [-10, -20, -30],arr2 = [10, 20, 30],d = 19) == 3\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [90, 190, 290, 390, 490],d = 9) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 3, 5, 7, 9],d = 0) == 2\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 0) == 5\n assert candidate(arr1 = [5, 5, 5, 5, 5],arr2 = [1, 2, 3, 4, 6],d = 1) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [0, 2, 4, 6, 8],d = 0) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90],d = 3) == 3\n assert candidate(arr1 = [-10, -20, -30, -40],arr2 = [-11, -21, -31, -41],d = 0) == 4\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [5],d = 1) == 7\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],d = 0) == 1\n assert candidate(arr1 = [0, 0, 0, 0, 0],arr2 = [1, 2, 3, 4, 5],d = 0) == 5\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 2, 2, 2, 2],d = 0) == 5\n assert candidate(arr1 = [2, 4, 6, 8, 10],arr2 = [1, 3, 5, 7, 9],d = 1) == 0\n assert candidate(arr1 = [1000, -1000, 500, -500],arr2 = [1000, -1000, 500, -500],d = 0) == 0\n assert candidate(arr1 = [5, 10, 15, 20, 25],arr2 = [3, 6, 9, 12, 18],d = 2) == 2\n assert candidate(arr1 = [5, 15, 25, 35, 45],arr2 = [0, 10, 20, 30, 40],d = 4) == 5\n assert candidate(arr1 = [-1000, -500, 0, 500, 1000],arr2 = [-500, 0, 500],d = 499) == 2\n assert candidate(arr1 = [-1000, 1000, 500, -500],arr2 = [0, -2000, 2000, 1000],d = 500) == 1\n assert candidate(arr1 = [500, 400, 300, 200, 100],arr2 = [-100, -200, -300, -400, -500],d = 100) == 5\n assert candidate(arr1 = [100, 200, 300, 400],arr2 = [50, 150, 250, 350],d = 49) == 4\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],d = 8) == 1\n assert candidate(arr1 = [-500, -1000, -1500, -2000],arr2 = [-400, -900, -1400, -1900],d = 100) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [0, 0, 0, 0, 0],d = 1) == 4\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45, 55],d = 5) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10],d = 0) == 5\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [150, 250, 350, 450],d = 49) == 5\n assert candidate(arr1 = [0, 1, 2, 3, 4],arr2 = [0, 0, 0, 0, 0],d = 2) == 2\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],d = 5) == 4\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [1, 2, 3, 4],d = 0) == 4\n assert candidate(arr1 = [-5, -10, -15, -20, -25],arr2 = [5, 10, 15, 20, 25],d = 4) == 5\n assert candidate(arr1 = [50, 51, 52, 53, 54, 55],arr2 = [50, 55],d = 0) == 4\n assert candidate(arr1 = [1, 1, 1, 1],arr2 = [2, 2, 2, 2],d = 1) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45],d = 5) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 2, 3, 4, 5],d = 1) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],d = 9) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [0, 2, 4, 6, 8],d = 1) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45],d = 4) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18],d = 0) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [10, 20, 30, 40, 50],d = 5) == 4\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 2, 3, 4, 5],d = 10) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 2, 3, 4, 5],d = 0) == 0\n assert candidate(arr1 = [0, 0, 0, 0, 0],arr2 = [-1, -2, -3, -4, -5],d = 1) == 0\n assert candidate(arr1 = [100, 200, 300],arr2 = [95, 195, 295, 105, 205, 305],d = 5) == 0\n assert candidate(arr1 = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],arr2 = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],d = 2) == 0\n assert candidate(arr1 = [-100, -90, -80, -70, -60, -50],arr2 = [-95, -85, -75, -65, -55],d = 4) == 6\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr2 = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91],d = 9) == 0\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1],d = 1) == 0\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90],d = 1) == 7\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 2, 3, 4, 5],d = 0) == 0\n assert candidate(arr1 = [1000, -1000, 0],arr2 = [500, -500, 0],d = 500) == 0\n assert candidate(arr1 = [0, 10, 20, 30, 40],arr2 = [5, 15, 25, 35, 45],d = 5) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 8) == 9\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],d = 0) == 10\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [10, 20, 30, 40, 50],d = 9) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15],arr2 = [2, 4, 6, 8, 10, 12, 14, 16],d = 1) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45],d = 6) == 0\n assert candidate(arr1 = [0, 100, 200],arr2 = [50, 150, 250],d = 49) == 3\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [-1, -2, -3, -4, -5],d = 1) == 5\n assert candidate(arr1 = [1, 1, 1, 1],arr2 = [1],d = 1) == 0\n assert candidate(arr1 = [-50, -40, -30, -20, -10],arr2 = [-45, -35, -25, -15, -5],d = 4) == 5\n assert candidate(arr1 = [-10, -20, -30, -40, -50],arr2 = [-5, -15, -25, -35, -45, -55],d = 9) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [2, 4, 6, 8, 10],d = 1) == 0\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [0, 0, 0, 0],d = 0) == 0\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [50, 150, 250, 350, 450, 550],d = 49) == 5\n assert candidate(arr1 = [-100, -200, -300, -400, -500],arr2 = [-95, -195, -295, -395, -495, -595],d = 5) == 0\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 2, 2, 2, 2],d = 1) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [0, 6, 7, 8, 9],d = 1) == 3\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [90, 190, 290, 390, 490],d = 5) == 5\n assert candidate(arr1 = [1, 10, 100, 1000],arr2 = [-1, -10, -100, -1000],d = 5) == 3\n assert candidate(arr1 = [100, 200, 300, 400],arr2 = [99, 199, 299, 399],d = 1) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10],d = 1) == 0\n assert candidate(arr1 = [-100, -200, -300, -400],arr2 = [-50, -150, -250, -350],d = 49) == 4\n assert candidate(arr1 = [5, 15, 25, 35],arr2 = [10, 20, 30, 40],d = 5) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [6, 7, 8, 9, 10],d = 1) == 4\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [1, 3, 5, 7, 9],d = 0) == 5\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 3, 4, 5, 6],d = 0) == 5\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15],arr2 = [2, 4, 6, 8, 10, 12, 14, 16],d = 0) == 8\n assert candidate(arr1 = [-50, -40, -30, -20, -10],arr2 = [-60, -55, -45, -35, -25],d = 5) == 1\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [15, 25, 35, 45, 55],d = 4) == 5\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90],arr2 = [1, 11, 21, 31, 41, 51, 61, 71, 81],d = 9) == 0\n assert candidate(arr1 = [-100, -200, -300, -400, -500],arr2 = [-50, -150, -250, -350, -450],d = 49) == 5\n assert candidate(arr1 = [500, 400, 300, 200, 100],arr2 = [550, 450, 350, 250, 150],d = 49) == 5\n assert candidate(arr1 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],arr2 = [-5, 0, 5],d = 2) == 3\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [6, 7, 8, 9, 10],d = 4) == 1\n assert candidate(arr1 = [-50, -25, 0, 25, 50],arr2 = [-30, -15, 15, 30],d = 14) == 3\n"}, "metadata": {"canonical_parameter_names": ["arr1", "arr2", "d"], "leetcode_dataset_entry_point": "Solution().findTheDistanceValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findTheDistanceValue(self, arr1: list[int], arr2: list[int], d: int) -> int:", "container": "Solution", "callable": "findTheDistanceValue", "parameters": [{"name": "arr1", "type": "list[int]"}, {"name": "arr2", "type": "list[int]"}, {"name": "d", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1386, "task_id": "cinema-seat-allocation", "difficulty": "Medium", "problem_description": "\nA cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above.\nGiven the array reservedSeats containing the numbers of seats already reserved, for example, reservedSeats[i] = [3,8] means the seat located in row 3 and labelled with 8 is already reserved.\nReturn the maximum number of four-person groups you can assign on the cinema seats. A four-person group occupies four adjacent seats in one single row. Seats across an aisle (such as [3,3] and [3,4]) are not considered to be adjacent, but there is an exceptional case on which an aisle split a four-person group, in that case, the aisle split a four-person group in the middle, which means to have two people on each side.\n \nExample 1:\n\n\nInput: n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]\nOutput: 4\nExplanation: The figure above shows the optimal allocation for four groups, where seats mark with blue are already reserved and contiguous seats mark with orange are for one group.\n\nExample 2:\n\nInput: n = 2, reservedSeats = [[2,1],[1,8],[2,6]]\nOutput: 2\n\nExample 3:\n\nInput: n = 4, reservedSeats = [[4,3],[1,4],[4,6],[1,7]]\nOutput: 4\n\n \nConstraints:\n\n1 <= n <= 10^9\n1 <= reservedSeats.length <= min(10*n, 10^4)\nreservedSeats[i].length == 2\n1 <= reservedSeats[i][0] <= n\n1 <= reservedSeats[i][1] <= 10\nAll reservedSeats[i] are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,reservedSeats = []) == 2\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 8\n assert candidate(n = 4,reservedSeats = [[4, 3], [1, 4], [4, 6], [1, 7]]) == 4\n assert candidate(n = 5,reservedSeats = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 5\n assert candidate(n = 5,reservedSeats = [[5, 5], [5, 6], [5, 7], [5, 8]]) == 8\n assert candidate(n = 2,reservedSeats = [[2, 1], [1, 8], [2, 6]]) == 2\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9]]) == 6\n assert candidate(n = 5,reservedSeats = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == 10\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [4, 4], [4, 5], [4, 6], [5, 7], [5, 8]]) == 4\n assert candidate(n = 1000000000,reservedSeats = [[500000000, 5]]) == 1999999999\n assert candidate(n = 10,reservedSeats = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]]) == 15\n assert candidate(n = 1000000000,reservedSeats = [[1, 2], [1000000000, 9]]) == 1999999998\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 6], [3, 7], [4, 8], [4, 9], [5, 2], [5, 3], [6, 4], [6, 5], [7, 6], [7, 7], [8, 4], [8, 5], [9, 8], [9, 9]]) == 11\n assert candidate(n = 1,reservedSeats = [[1, 5]]) == 1\n assert candidate(n = 5,reservedSeats = [[2, 4], [2, 5], [2, 6], [2, 7]]) == 8\n assert candidate(n = 5,reservedSeats = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2]]) == 5\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 1], [3, 10], [4, 2], [4, 3], [5, 4], [5, 5], [6, 2], [6, 3], [7, 8], [7, 9], [8, 4], [8, 5], [9, 6], [9, 7]]) == 12\n assert candidate(n = 3,reservedSeats = [[1, 2], [1, 3], [1, 8], [2, 6], [3, 1], [3, 10]]) == 4\n assert candidate(n = 20,reservedSeats = [[5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [10, 2], [10, 3], [10, 8], [10, 9], [15, 4], [15, 5], [15, 6], [15, 7], [20, 1], [20, 2], [20, 3], [20, 4], [20, 5], [20, 6], [20, 7], [20, 8], [20, 9], [20, 10]]) == 33\n assert candidate(n = 10,reservedSeats = [[3, 2], [3, 3], [3, 4], [4, 4], [4, 5], [5, 5], [5, 6], [6, 6], [6, 7], [7, 7], [7, 8], [8, 8], [8, 9], [9, 9], [9, 10], [10, 10]]) == 12\n assert candidate(n = 30,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 2], [4, 3], [4, 8], [4, 9], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 2], [6, 3], [6, 4], [6, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 2], [8, 3], [8, 4], [8, 5], [9, 6], [9, 7], [9, 8], [9, 9], [10, 2], [10, 3], [10, 4], [10, 5], [11, 6], [11, 7], [11, 8], [11, 9], [12, 2], [12, 3], [12, 4], [12, 5], [13, 6], [13, 7], [13, 8], [13, 9], [14, 2], [14, 3], [14, 4], [14, 5], [15, 6], [15, 7], [15, 8], [15, 9], [16, 2], [16, 3], [16, 4], [16, 5], [17, 6], [17, 7], [17, 8], [17, 9], [18, 2], [18, 3], [18, 4], [18, 5], [19, 6], [19, 7], [19, 8], [19, 9], [20, 2], [20, 3], [20, 4], [20, 5], [21, 6], [21, 7], [21, 8], [21, 9], [22, 2], [22, 3], [22, 4], [22, 5], [23, 6], [23, 7], [23, 8], [23, 9], [24, 2], [24, 3], [24, 4], [24, 5], [25, 6], [25, 7], [25, 8], [25, 9], [26, 2], [26, 3], [26, 4], [26, 5], [27, 6], [27, 7], [27, 8], [27, 9], [28, 2], [28, 3], [28, 4], [28, 5], [29, 6], [29, 7], [29, 8], [29, 9], [30, 2], [30, 3], [30, 4], [30, 5]]) == 28\n assert candidate(n = 7,reservedSeats = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 1], [6, 2], [6, 3], [7, 4], [7, 5]]) == 8\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9]]) == 16\n assert candidate(n = 100,reservedSeats = [[10, 3], [10, 4], [20, 3], [20, 4], [30, 3], [30, 4], [40, 3], [40, 4], [50, 3], [50, 4], [60, 3], [60, 4], [70, 3], [70, 4], [80, 3], [80, 4], [90, 3], [90, 4]]) == 191\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [6, 3], [6, 4], [6, 5], [6, 6], [7, 4], [7, 5], [7, 6], [7, 7], [8, 3], [8, 4], [8, 5], [8, 6], [9, 5], [9, 6], [10, 3], [10, 4], [10, 5], [10, 6]]) == 2\n assert candidate(n = 10,reservedSeats = [[2, 5], [3, 4], [3, 5], [3, 6], [4, 3], [4, 4], [4, 5], [4, 6], [5, 5], [5, 6], [6, 7], [6, 8], [7, 3], [7, 4], [8, 5], [8, 6], [9, 7], [9, 8]]) == 8\n assert candidate(n = 20,reservedSeats = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 5], [2, 6], [3, 3], [3, 4], [4, 7], [4, 8], [5, 2], [5, 3], [6, 8], [6, 9], [7, 1], [7, 2], [8, 5], [8, 6], [9, 4], [9, 5], [10, 9], [10, 10], [11, 1], [11, 10], [12, 2], [12, 9], [13, 3], [13, 8], [14, 4], [14, 7], [15, 5], [15, 6], [16, 2], [16, 3], [17, 8], [17, 9], [18, 4], [18, 5], [19, 6], [19, 7], [20, 1], [20, 10]]) == 17\n assert candidate(n = 20,reservedSeats = [[1, 2], [1, 9], [2, 5], [2, 6], [3, 3], [3, 4], [3, 7], [3, 8], [4, 2], [4, 9], [5, 3], [5, 8], [6, 5], [6, 6], [7, 2], [7, 9], [8, 3], [8, 8], [9, 4], [9, 7], [10, 2], [10, 9], [11, 5], [11, 6], [12, 3], [12, 8], [13, 2], [13, 9], [14, 3], [14, 8], [15, 5], [15, 6], [16, 2], [16, 9], [17, 3], [17, 8], [18, 5], [18, 6], [19, 2], [19, 9], [20, 3], [20, 8]]) == 13\n assert candidate(n = 10,reservedSeats = [[1, 1], [1, 10], [2, 2], [2, 9], [3, 3], [3, 8], [4, 4], [4, 7], [5, 5], [5, 6], [6, 1], [6, 10], [7, 2], [7, 9], [8, 3], [8, 8], [9, 4], [9, 7], [10, 5], [10, 6]]) == 8\n assert candidate(n = 15,reservedSeats = [[2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 1], [4, 10], [5, 3], [5, 4], [5, 7], [5, 8], [6, 1], [6, 10], [7, 2], [7, 3], [7, 8], [7, 9], [8, 2], [8, 3], [8, 8], [8, 9], [9, 1], [9, 10], [10, 4], [10, 5], [10, 6], [10, 7], [11, 2], [11, 3], [11, 8], [11, 9], [12, 4], [12, 5], [12, 6], [12, 7], [13, 1], [13, 10], [14, 2], [14, 3], [14, 8], [14, 9], [15, 4], [15, 5], [15, 6], [15, 7]]) == 15\n assert candidate(n = 10,reservedSeats = []) == 20\n assert candidate(n = 15,reservedSeats = [[1, 2], [1, 3], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 1], [5, 10], [6, 3], [6, 4], [6, 7], [6, 8], [7, 2], [7, 3], [7, 8], [7, 9], [8, 5], [8, 6], [9, 4], [9, 5], [9, 6], [9, 7], [10, 2], [10, 3], [11, 8], [11, 9], [12, 5], [12, 6], [13, 3], [13, 4], [14, 7], [14, 8], [15, 1], [15, 10]]) == 11\n assert candidate(n = 7,reservedSeats = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 10], [3, 1], [3, 10], [4, 1], [4, 10], [5, 1], [5, 10], [6, 1], [6, 10], [7, 1], [7, 10]]) == 12\n assert candidate(n = 8,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5], [4, 2], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5], [6, 2], [6, 3], [6, 4], [6, 5], [7, 2], [7, 3], [7, 4], [7, 5], [8, 2], [8, 3], [8, 4], [8, 5]]) == 8\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 1], [4, 10], [5, 5], [5, 6], [6, 3], [6, 4], [6, 7], [6, 8], [7, 2], [7, 9], [8, 1], [8, 10], [9, 3], [9, 4], [9, 7], [9, 8], [10, 2], [10, 3], [10, 8], [10, 9]]) == 9\n assert candidate(n = 15,reservedSeats = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [11, 2], [12, 3], [13, 4], [14, 5], [15, 6]]) == 17\n assert candidate(n = 10,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 8], [3, 9], [4, 1], [4, 10], [5, 5], [5, 6], [6, 3], [6, 4], [6, 7], [6, 8], [7, 2], [7, 9], [8, 1], [8, 10], [9, 3], [9, 4], [9, 7], [9, 8], [10, 2], [10, 3], [10, 8], [10, 9]]) == 7\n assert candidate(n = 30,reservedSeats = [[2, 2], [2, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [3, 9], [4, 2], [4, 3], [4, 4], [4, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 2], [6, 3], [6, 4], [6, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 2], [8, 3], [8, 4], [8, 5], [9, 6], [9, 7], [9, 8], [9, 9], [10, 2], [10, 3], [10, 4], [10, 5]]) == 51\n assert candidate(n = 100,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [75, 2], [75, 3], [75, 4], [75, 5], [75, 6], [75, 7], [75, 8], [75, 9], [75, 10], [99, 2], [99, 3], [99, 4], [99, 5], [99, 6], [99, 7], [99, 8], [99, 9], [99, 10]]) == 192\n assert candidate(n = 3,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 8], [3, 9]]) == 1\n assert candidate(n = 7,reservedSeats = [[1, 4], [1, 5], [1, 6], [1, 7], [2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 3], [4, 4], [4, 7], [4, 8], [5, 2], [5, 3], [5, 8], [5, 9], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 4], [7, 5]]) == 3\n assert candidate(n = 25,reservedSeats = [[10, 2], [10, 3], [11, 8], [11, 9], [12, 4], [12, 5], [13, 6], [13, 7], [14, 2], [14, 3], [15, 8], [15, 9], [16, 4], [16, 5], [17, 6], [17, 7], [18, 2], [18, 3], [19, 8], [19, 9], [20, 4], [20, 5], [21, 6], [21, 7], [22, 2], [22, 3], [23, 8], [23, 9], [24, 4], [24, 5], [25, 6], [25, 7], [1, 2], [1, 3], [2, 8], [2, 9], [3, 4], [3, 5], [4, 6], [4, 7], [5, 2], [5, 3], [6, 8], [6, 9], [7, 4], [7, 5], [8, 6], [8, 7], [9, 2], [9, 3]]) == 25\n assert candidate(n = 12,reservedSeats = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 2], [2, 3], [3, 4], [3, 5], [4, 7], [4, 8], [5, 2], [5, 3], [6, 8], [6, 9], [7, 1], [7, 2], [8, 5], [8, 6], [9, 4], [9, 5], [10, 9], [10, 10], [11, 1], [11, 10], [12, 2], [12, 9]]) == 11\n assert candidate(n = 6,reservedSeats = [[1, 2], [1, 3], [2, 5], [2, 6], [2, 7], [2, 8], [3, 3], [3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [4, 7], [5, 2], [5, 3], [5, 8], [5, 9], [6, 5], [6, 6], [6, 7], [6, 8]]) == 2\n assert candidate(n = 1000,reservedSeats = [[1, 2], [1, 3], [2, 2], [2, 3], [3, 2], [3, 3], [4, 2], [4, 3], [5, 2], [5, 3], [6, 2], [6, 3], [7, 2], [7, 3], [8, 2], [8, 3], [9, 2], [9, 3], [10, 2], [10, 3]]) == 1990\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 2], [4, 3], [4, 8], [4, 9], [5, 3], [5, 4], [5, 7], [5, 8], [6, 1], [6, 10], [7, 5], [7, 6], [8, 4], [8, 5], [8, 6], [8, 7], [9, 2], [9, 3], [9, 8], [9, 9], [10, 4], [10, 5], [10, 6], [10, 7]]) == 6\n assert candidate(n = 100,reservedSeats = [[1, 1], [1, 10], [10, 1], [10, 10], [20, 1], [20, 10], [30, 1], [30, 10], [40, 1], [40, 10], [50, 1], [50, 10], [60, 1], [60, 10], [70, 1], [70, 10], [80, 1], [80, 10], [90, 1], [90, 10], [100, 1], [100, 10]]) == 200\n assert candidate(n = 50,reservedSeats = [[10, 2], [10, 3], [10, 8], [10, 9], [20, 4], [20, 5], [20, 6], [20, 7], [30, 1], [30, 10], [40, 2], [40, 3], [40, 8], [40, 9], [50, 2], [50, 3], [50, 8], [50, 9]]) == 95\n assert candidate(n = 100,reservedSeats = [[50, 4], [50, 5], [50, 6], [50, 7], [51, 2], [51, 3], [51, 8], [51, 9], [52, 4], [52, 5], [52, 6], [52, 7], [53, 2], [53, 3], [53, 8], [53, 9], [54, 4], [54, 5], [54, 6], [54, 7], [55, 2], [55, 3], [55, 8], [55, 9], [56, 4], [56, 5], [56, 6], [56, 7], [57, 2], [57, 3], [57, 8], [57, 9], [58, 4], [58, 5], [58, 6], [58, 7]]) == 186\n assert candidate(n = 10,reservedSeats = [[1, 2], [1, 3], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 1], [5, 10], [6, 3], [6, 4], [6, 7], [6, 8], [7, 2], [7, 3], [7, 8], [7, 9], [8, 5], [8, 6], [9, 4], [9, 5], [9, 6], [9, 7], [10, 2], [10, 3], [10, 8], [10, 9]]) == 6\n assert candidate(n = 15,reservedSeats = [[5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 2], [6, 3], [6, 8], [6, 9], [7, 4], [7, 5], [7, 6], [7, 7], [8, 3], [8, 4], [8, 5], [8, 6], [9, 2], [9, 3], [9, 8], [9, 9]]) == 22\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10]]) == 15\n assert candidate(n = 100,reservedSeats = [[10, 2], [10, 3], [10, 4], [10, 5], [20, 4], [20, 5], [30, 6], [30, 7], [40, 8], [40, 9], [50, 2], [50, 3], [60, 4], [60, 5], [70, 6], [70, 7], [80, 8], [80, 9], [90, 2], [90, 3]]) == 191\n assert candidate(n = 3,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]]) == 0\n assert candidate(n = 20,reservedSeats = [[5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]]) == 36\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [3, 7], [4, 6], [4, 7], [4, 8], [4, 9], [5, 2], [5, 3], [5, 8], [5, 9], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 4], [7, 5], [8, 6], [8, 7], [8, 8], [8, 9], [9, 2], [9, 3], [9, 8], [9, 9], [10, 4], [10, 5], [10, 6], [10, 7]]) == 8\n assert candidate(n = 5,reservedSeats = [[1, 5], [1, 6], [2, 4], [2, 5], [3, 7], [3, 8], [4, 3], [4, 4], [5, 9], [5, 10]]) == 4\n assert candidate(n = 100,reservedSeats = [[10, 3], [10, 4], [10, 5], [10, 6], [20, 2], [20, 3], [20, 8], [20, 9], [30, 4], [30, 5], [30, 6], [30, 7], [40, 1], [40, 2], [40, 3], [40, 4], [40, 5], [40, 6], [40, 7], [40, 8], [40, 9], [40, 10], [50, 4], [50, 5], [50, 6], [50, 7], [60, 2], [60, 3], [60, 8], [60, 9], [70, 4], [70, 5], [70, 6], [70, 7], [80, 1], [80, 2], [80, 3], [80, 4], [80, 5], [80, 6], [80, 7], [80, 8], [80, 9], [80, 10], [90, 3], [90, 4], [90, 5], [90, 6], [100, 2], [100, 3], [100, 8], [100, 9]]) == 183\n assert candidate(n = 25,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [6, 3], [6, 4], [6, 5], [6, 6], [7, 4], [7, 5], [7, 6], [7, 7], [8, 3], [8, 4], [8, 5], [8, 6], [9, 5], [9, 6], [10, 3], [10, 4], [10, 5], [10, 6], [11, 5], [11, 6], [12, 3], [12, 4], [12, 5], [12, 6], [13, 4], [13, 5], [13, 6], [13, 7], [14, 3], [14, 4], [14, 5], [14, 6], [15, 5], [15, 6], [16, 3], [16, 4], [16, 5], [16, 6], [17, 4], [17, 5], [17, 6], [17, 7], [18, 3], [18, 4], [18, 5], [18, 6], [19, 5], [19, 6], [20, 3], [20, 4], [20, 5], [20, 6], [21, 5], [21, 6], [22, 3], [22, 4], [22, 5], [22, 6], [23, 4], [23, 5], [23, 6], [23, 7], [24, 3], [24, 4], [24, 5], [24, 6], [25, 5], [25, 6]]) == 2\n assert candidate(n = 1000,reservedSeats = [[100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [200, 2], [200, 3], [200, 4], [200, 5], [200, 6], [200, 7], [200, 8], [500, 2], [500, 3], [500, 4], [500, 5], [500, 6], [500, 7], [500, 8], [500, 9], [500, 10], [750, 2], [750, 3], [750, 4], [750, 5], [750, 6], [750, 7], [750, 8], [750, 9], [750, 10], [900, 2], [900, 3], [900, 4], [900, 5], [900, 6], [900, 7], [900, 8], [900, 9], [900, 10], [999, 2], [999, 3], [999, 4], [999, 5], [999, 6], [999, 7], [999, 8], [999, 9], [999, 10]]) == 1988\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 2], [4, 3], [4, 8], [4, 9]]) == 15\n assert candidate(n = 15,reservedSeats = [[5, 3], [5, 4], [5, 5], [5, 6], [6, 2], [6, 3], [6, 8], [6, 9], [7, 2], [7, 3], [7, 4], [7, 5], [8, 6], [8, 7], [8, 8], [8, 9]]) == 25\n assert candidate(n = 20,reservedSeats = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 1], [6, 2], [6, 3], [7, 4], [7, 5], [8, 6], [8, 7], [9, 8], [9, 9], [10, 10], [10, 1]]) == 32\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [1, 8], [1, 9], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 8], [3, 9], [4, 1], [4, 10], [5, 5], [5, 6]]) == 4\n assert candidate(n = 5,reservedSeats = [[1, 1], [1, 10], [2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [4, 8], [5, 5], [5, 6], [5, 7], [5, 8]]) == 3\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 4], [2, 5], [2, 6], [2, 7], [3, 6], [3, 7], [3, 8], [3, 9], [4, 8], [4, 9], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]]) == 3\n assert candidate(n = 20,reservedSeats = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 2], [5, 3], [6, 4], [6, 5], [7, 6], [7, 7], [8, 8], [8, 9], [9, 2], [9, 3], [10, 4], [10, 5]]) == 30\n assert candidate(n = 15,reservedSeats = [[1, 2], [1, 3], [1, 8], [1, 9], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 8], [3, 9], [4, 1], [4, 10], [5, 2], [5, 3], [5, 8], [5, 9], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 8], [7, 9], [8, 1], [8, 10], [9, 2], [9, 3], [9, 8], [9, 9], [10, 4], [10, 5], [10, 6], [10, 7], [11, 2], [11, 3], [11, 8], [11, 9], [12, 1], [12, 10], [13, 2], [13, 3], [13, 8], [13, 9], [14, 4], [14, 5], [14, 6], [14, 7], [15, 2], [15, 3], [15, 8], [15, 9]]) == 14\n assert candidate(n = 20,reservedSeats = [[1, 2], [1, 3], [2, 8], [2, 9], [3, 4], [3, 5], [4, 6], [4, 7], [5, 2], [5, 3], [5, 8], [5, 9], [6, 2], [6, 3], [6, 4], [6, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 2], [8, 3], [8, 8], [8, 9], [9, 4], [9, 5], [10, 6], [10, 7], [11, 2], [11, 3], [12, 8], [12, 9], [13, 4], [13, 5], [14, 6], [14, 7], [15, 2], [15, 3], [16, 8], [16, 9], [17, 4], [17, 5], [18, 6], [18, 7], [19, 2], [19, 3], [20, 8], [20, 9]]) == 20\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 8], [3, 6], [4, 1], [4, 10], [5, 5], [5, 6], [6, 3], [6, 4], [6, 9], [7, 7], [7, 8], [8, 2], [8, 3], [9, 8], [9, 9], [10, 10]]) == 11\n assert candidate(n = 15,reservedSeats = [[2, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 2], [6, 3], [7, 4], [7, 5], [8, 6], [8, 7], [9, 8], [9, 9], [10, 10], [11, 1], [11, 2], [12, 3], [12, 4], [13, 5], [13, 6], [14, 7], [14, 8], [15, 9]]) == 15\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8]]) == 3\n assert candidate(n = 50,reservedSeats = [[10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [20, 2], [20, 3], [20, 4], [20, 5], [20, 6], [20, 7], [20, 8], [25, 5], [25, 6], [25, 7], [25, 8]]) == 94\n assert candidate(n = 20,reservedSeats = [[1, 5], [2, 4], [3, 6], [4, 7], [5, 8], [6, 9], [7, 2], [8, 3], [9, 4], [10, 5], [11, 6], [12, 7], [13, 8], [14, 9], [15, 2], [16, 3], [17, 4], [18, 5], [19, 6], [20, 7]]) == 20\n assert candidate(n = 20,reservedSeats = [[5, 2], [5, 3], [5, 8], [5, 9], [10, 4], [10, 5], [10, 6], [10, 7], [15, 1], [15, 10], [20, 2], [20, 3], [20, 8], [20, 9]]) == 36\n assert candidate(n = 50,reservedSeats = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [10, 2], [10, 3], [10, 8], [10, 9], [15, 1], [15, 2], [15, 3], [15, 4], [15, 5], [15, 6], [15, 7], [15, 8], [15, 9], [15, 10], [20, 1], [20, 2], [20, 3], [20, 4], [20, 5], [20, 6], [20, 7], [20, 8], [20, 9], [20, 10], [25, 1], [25, 2], [25, 3], [25, 4], [25, 5], [25, 6], [25, 7], [25, 8], [25, 9], [25, 10], [30, 1], [30, 2], [30, 3], [30, 4], [30, 5], [30, 6], [30, 7], [30, 8], [30, 9], [30, 10], [35, 1], [35, 2], [35, 3], [35, 4], [35, 5], [35, 6], [35, 7], [35, 8], [35, 9], [35, 10], [40, 1], [40, 2], [40, 3], [40, 4], [40, 5], [40, 6], [40, 7], [40, 8], [40, 9], [40, 10], [45, 1], [45, 2], [45, 3], [45, 4], [45, 5], [45, 6], [45, 7], [45, 8], [45, 9], [45, 10]]) == 83\n"}, "metadata": {"canonical_parameter_names": ["n", "reservedSeats"], "leetcode_dataset_entry_point": "Solution().maxNumberOfFamilies", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxNumberOfFamilies(self, n: int, reservedSeats: list[list[int]]) -> int:", "container": "Solution", "callable": "maxNumberOfFamilies", "parameters": [{"name": "n", "type": "int"}, {"name": "reservedSeats", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1387, "task_id": "sort-integers-by-the-power-value", "difficulty": "Medium", "problem_description": "The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:\n\nif x is even then x = x / 2\nif x is odd then x = 3 * x + 1\n\nFor example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1).\nGiven three integers lo, hi and k. The task is to sort all integers in the interval [lo, hi] by the power value in ascending order, if two or more integers have the same power value sort them by ascending order.\nReturn the kth integer in the range [lo, hi] sorted by the power value.\nNotice that for any integer x (lo <= x <= hi) it is guaranteed that x will transform into 1 using these steps and that the power of x is will fit in a 32-bit signed integer.\n \nExample 1:\n\nInput: lo = 12, hi = 15, k = 2\nOutput: 13\nExplanation: The power of 12 is 9 (12 --> 6 --> 3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1)\nThe power of 13 is 9\nThe power of 14 is 17\nThe power of 15 is 17\nThe interval sorted by the power value [12,13,14,15]. For k = 2 answer is the second element which is 13.\nNotice that 12 and 13 have the same power value and we sorted them in ascending order. Same for 14 and 15.\n\nExample 2:\n\nInput: lo = 7, hi = 11, k = 4\nOutput: 7\nExplanation: The power array corresponding to the interval [7, 8, 9, 10, 11] is [16, 3, 19, 6, 14].\nThe interval sorted by power is [8, 10, 11, 7, 9].\nThe fourth number in the sorted array is 7.\n\n \nConstraints:\n\n1 <= lo <= hi <= 1000\n1 <= k <= hi - lo + 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(lo = 1,hi = 10,k = 1) == 1\n assert candidate(lo = 5,hi = 5,k = 1) == 5\n assert candidate(lo = 12,hi = 15,k = 2) == 13\n assert candidate(lo = 1,hi = 10,k = 5) == 5\n assert candidate(lo = 10,hi = 20,k = 5) == 13\n assert candidate(lo = 7,hi = 11,k = 4) == 7\n assert candidate(lo = 10,hi = 20,k = 3) == 20\n assert candidate(lo = 1,hi = 10,k = 3) == 4\n assert candidate(lo = 300,hi = 500,k = 100) == 370\n assert candidate(lo = 100,hi = 200,k = 1) == 128\n assert candidate(lo = 300,hi = 700,k = 150) == 613\n assert candidate(lo = 700,hi = 800,k = 18) == 794\n assert candidate(lo = 100,hi = 200,k = 75) == 183\n assert candidate(lo = 1,hi = 100,k = 100) == 97\n assert candidate(lo = 700,hi = 800,k = 50) == 766\n assert candidate(lo = 800,hi = 900,k = 5) == 802\n assert candidate(lo = 900,hi = 1000,k = 50) == 988\n assert candidate(lo = 600,hi = 800,k = 150) == 756\n assert candidate(lo = 800,hi = 1000,k = 50) == 912\n assert candidate(lo = 500,hi = 900,k = 100) == 692\n assert candidate(lo = 400,hi = 600,k = 100) == 489\n assert candidate(lo = 400,hi = 700,k = 120) == 418\n assert candidate(lo = 750,hi = 850,k = 50) == 758\n assert candidate(lo = 300,hi = 400,k = 100) == 313\n assert candidate(lo = 5,hi = 25,k = 1) == 8\n assert candidate(lo = 300,hi = 350,k = 30) == 338\n assert candidate(lo = 950,hi = 1000,k = 25) == 984\n assert candidate(lo = 200,hi = 300,k = 1) == 256\n assert candidate(lo = 800,hi = 900,k = 50) == 855\n assert candidate(lo = 800,hi = 900,k = 85) == 898\n assert candidate(lo = 500,hi = 600,k = 50) == 509\n assert candidate(lo = 250,hi = 450,k = 150) == 428\n assert candidate(lo = 150,hi = 450,k = 100) == 173\n assert candidate(lo = 300,hi = 350,k = 10) == 309\n assert candidate(lo = 300,hi = 600,k = 150) == 374\n assert candidate(lo = 100,hi = 200,k = 10) == 138\n assert candidate(lo = 400,hi = 600,k = 150) == 486\n assert candidate(lo = 900,hi = 1000,k = 10) == 965\n assert candidate(lo = 250,hi = 500,k = 100) == 312\n assert candidate(lo = 300,hi = 400,k = 50) == 367\n assert candidate(lo = 500,hi = 1000,k = 250) == 658\n assert candidate(lo = 300,hi = 350,k = 25) == 315\n assert candidate(lo = 200,hi = 300,k = 75) == 242\n assert candidate(lo = 50,hi = 150,k = 25) == 56\n assert candidate(lo = 250,hi = 350,k = 100) == 313\n assert candidate(lo = 50,hi = 75,k = 1) == 64\n assert candidate(lo = 500,hi = 1000,k = 150) == 943\n assert candidate(lo = 100,hi = 800,k = 200) == 547\n assert candidate(lo = 100,hi = 500,k = 30) == 150\n assert candidate(lo = 1,hi = 500,k = 250) == 465\n assert candidate(lo = 400,hi = 600,k = 120) == 590\n assert candidate(lo = 1,hi = 100,k = 10) == 3\n assert candidate(lo = 200,hi = 300,k = 50) == 271\n assert candidate(lo = 250,hi = 750,k = 250) == 741\n assert candidate(lo = 300,hi = 400,k = 5) == 384\n assert candidate(lo = 400,hi = 600,k = 200) == 487\n assert candidate(lo = 1,hi = 500,k = 150) == 163\n assert candidate(lo = 150,hi = 250,k = 20) == 234\n assert candidate(lo = 800,hi = 1000,k = 200) == 937\n assert candidate(lo = 1,hi = 1000,k = 1) == 1\n assert candidate(lo = 999,hi = 1000,k = 1) == 999\n assert candidate(lo = 1,hi = 1000,k = 500) == 606\n assert candidate(lo = 200,hi = 300,k = 100) == 231\n assert candidate(lo = 200,hi = 300,k = 10) == 280\n assert candidate(lo = 300,hi = 700,k = 250) == 699\n assert candidate(lo = 250,hi = 400,k = 100) == 263\n assert candidate(lo = 750,hi = 850,k = 30) == 813\n assert candidate(lo = 100,hi = 300,k = 150) == 242\n assert candidate(lo = 25,hi = 75,k = 25) == 36\n assert candidate(lo = 400,hi = 500,k = 100) == 487\n assert candidate(lo = 800,hi = 900,k = 80) == 874\n assert candidate(lo = 50,hi = 75,k = 25) == 55\n assert candidate(lo = 150,hi = 300,k = 75) == 210\n assert candidate(lo = 1,hi = 100,k = 1) == 1\n assert candidate(lo = 500,hi = 1000,k = 300) == 754\n assert candidate(lo = 600,hi = 700,k = 20) == 663\n assert candidate(lo = 800,hi = 900,k = 100) == 889\n assert candidate(lo = 200,hi = 400,k = 150) == 243\n assert candidate(lo = 100,hi = 200,k = 100) == 129\n assert candidate(lo = 100,hi = 200,k = 50) == 114\n assert candidate(lo = 800,hi = 900,k = 25) == 882\n assert candidate(lo = 1,hi = 100,k = 50) == 9\n assert candidate(lo = 500,hi = 600,k = 25) == 538\n assert candidate(lo = 50,hi = 150,k = 50) == 66\n assert candidate(lo = 1000,hi = 1000,k = 1) == 1000\n assert candidate(lo = 1,hi = 100,k = 75) == 67\n assert candidate(lo = 900,hi = 999,k = 15) == 985\n assert candidate(lo = 2,hi = 10,k = 5) == 10\n assert candidate(lo = 1,hi = 1000,k = 750) == 322\n assert candidate(lo = 600,hi = 900,k = 150) == 718\n assert candidate(lo = 50,hi = 100,k = 15) == 93\n assert candidate(lo = 1,hi = 1,k = 1) == 1\n assert candidate(lo = 600,hi = 800,k = 100) == 676\n"}, "metadata": {"canonical_parameter_names": ["lo", "hi", "k"], "leetcode_dataset_entry_point": "Solution().getKth", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getKth(self, lo: int, hi: int, k: int) -> int:", "container": "Solution", "callable": "getKth", "parameters": [{"name": "lo", "type": "int"}, {"name": "hi", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1388, "task_id": "pizza-with-3n-slices", "difficulty": "Hard", "problem_description": "There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:\n\nYou will pick any pizza slice.\nYour friend Alice will pick the next slice in the anti-clockwise direction of your pick.\nYour friend Bob will pick the next slice in the clockwise direction of your pick.\nRepeat until there are no more slices of pizzas.\n\nGiven an integer array slices that represent the sizes of the pizza slices in a clockwise direction, return the maximum possible sum of slice sizes that you can pick.\n \nExample 1:\n\n\nInput: slices = [1,2,3,4,5,6]\nOutput: 10\nExplanation: Pick pizza slice of size 4, Alice and Bob will pick slices with size 3 and 5 respectively. Then Pick slices with size 6, finally Alice and Bob will pick slice of size 2 and 1 respectively. Total = 4 + 6.\n\nExample 2:\n\n\nInput: slices = [8,9,8,6,1,1]\nOutput: 16\nExplanation: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8.\n\n \nConstraints:\n\n3 * n == slices.length\n1 <= slices.length <= 500\n1 <= slices[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(slices = [9, 7, 7, 7, 6, 6]) == 16\n assert candidate(slices = [1000, 1000, 1000, 1000, 1000, 1000]) == 2000\n assert candidate(slices = [10, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 21\n assert candidate(slices = [1, 2, 3, 4, 1, 2]) == 6\n assert candidate(slices = [8, 9, 8, 6, 1, 1]) == 16\n assert candidate(slices = [10, 1, 1, 1, 1, 10]) == 11\n assert candidate(slices = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 36\n assert candidate(slices = [7, 8, 9, 1, 2, 3, 4, 5, 6]) == 21\n assert candidate(slices = [7, 7, 7, 7, 7, 7, 7]) == 14\n assert candidate(slices = [1000, 1, 1000, 1, 1000, 1]) == 2000\n assert candidate(slices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(slices = [5, 7, 8, 6, 3, 4]) == 13\n assert candidate(slices = [1, 3, 1, 5, 2, 5, 1, 5, 6]) == 16\n assert candidate(slices = [1, 2, 3, 4, 5, 6]) == 10\n assert candidate(slices = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(slices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 2100\n assert candidate(slices = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]) == 798\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 78\n assert candidate(slices = [1, 1000, 2, 1000, 3, 1000, 4, 1000, 5, 1000, 6, 1000]) == 4000\n assert candidate(slices = [5, 3, 9, 7, 1, 4, 8, 6, 2, 10, 12, 11]) == 38\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(slices = [500, 1, 500, 2, 500, 3, 500, 4, 500, 5, 500, 6]) == 2000\n assert candidate(slices = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8]) == 280\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 55\n assert candidate(slices = [100, 200, 300, 400, 500, 600, 100, 200, 300, 400, 500, 600]) == 2000\n assert candidate(slices = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == 400\n assert candidate(slices = [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800]) == 3200\n assert candidate(slices = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6]) == 394\n assert candidate(slices = [900, 100, 200, 300, 400, 500, 600, 700, 800, 100, 200, 300, 400, 500, 600, 700, 800, 900, 100, 200, 300, 400, 500, 600, 700]) == 5400\n assert candidate(slices = [10, 1, 15, 2, 20, 3, 25, 4, 30, 5, 35, 6]) == 110\n assert candidate(slices = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 55\n assert candidate(slices = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 3600\n assert candidate(slices = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 144\n assert candidate(slices = [300, 200, 100, 50, 25, 12, 6, 3, 1, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]) == 3450\n assert candidate(slices = [15, 1, 25, 3, 20, 4, 2, 30, 5, 6, 7, 8]) == 90\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 560\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 35\n assert candidate(slices = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995]) == 3994\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12]) == 36\n assert candidate(slices = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 12\n assert candidate(slices = [1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 3600\n assert candidate(slices = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150]) == 2278\n assert candidate(slices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 550\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 144\n assert candidate(slices = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 3600\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125]) == 3485\n assert candidate(slices = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 2000\n assert candidate(slices = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(slices = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 60\n assert candidate(slices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 360\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12]) == 36\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 12, 11]) == 35\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 23\n assert candidate(slices = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 21000\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 144\n assert candidate(slices = [300, 1, 100, 2, 200, 3, 150, 4, 250, 5, 350, 6]) == 1100\n assert candidate(slices = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 64\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 210\n assert candidate(slices = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 5000\n assert candidate(slices = [12, 3, 11, 4, 2, 5, 6, 7, 8, 9, 10, 1]) == 41\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 2244\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150]) == 5050\n assert candidate(slices = [5, 6, 3, 7, 4, 8, 5, 6, 3, 7, 4, 8, 5, 6, 3, 7, 4, 8, 5, 6, 3, 7, 4, 8, 5, 6, 3, 7, 4, 8]) == 75\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(slices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11]) == 36\n assert candidate(slices = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 210\n assert candidate(slices = [999, 1, 999, 2, 999, 3, 999, 4, 999, 5, 999, 6, 999, 7, 999, 8, 999, 9, 999, 10, 999, 11, 999, 12, 999, 13, 999, 14, 999, 15]) == 9990\n assert candidate(slices = [9, 2, 8, 1, 5, 6, 7, 3, 4, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 60\n assert candidate(slices = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == 3996\n assert candidate(slices = [500, 1, 500, 2, 500, 3, 500, 4, 500, 5, 500, 6]) == 2000\n assert candidate(slices = [200, 150, 100, 50, 100, 150, 200, 250, 300, 350, 400, 450]) == 1200\n assert candidate(slices = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 68\n assert candidate(slices = [5, 7, 4, 6, 10, 3, 8, 2, 9, 1, 11, 6]) == 38\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 560\n assert candidate(slices = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 1000\n assert candidate(slices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 76\n assert candidate(slices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 2100\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10]) == 55\n assert candidate(slices = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15]) == 39\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 97\n assert candidate(slices = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n assert candidate(slices = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 180\n assert candidate(slices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500]) == 5600\n assert candidate(slices = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 133\n assert candidate(slices = [10, 5, 1, 2, 8, 3, 9, 4, 7, 6, 11, 12]) == 38\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 55\n assert candidate(slices = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 50\n assert candidate(slices = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 210\n assert candidate(slices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 114\n assert candidate(slices = [500, 1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6]) == 3994\n assert candidate(slices = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9, 10, 11]) == 127\n assert candidate(slices = [900, 100, 800, 200, 700, 300, 600, 400, 500, 500, 600, 400]) == 3000\n assert candidate(slices = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 28\n assert candidate(slices = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(slices = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 8\n assert candidate(slices = [200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230]) == 2210\n assert candidate(slices = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 560\n assert candidate(slices = [12, 3, 14, 5, 16, 7, 18, 9, 11, 2, 13, 4]) == 61\n assert candidate(slices = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 10000\n assert candidate(slices = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 3600\n assert candidate(slices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 90\n assert candidate(slices = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9, 1000, 10, 1100, 11, 1200, 12]) == 6800\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 210\n assert candidate(slices = [300, 200, 100, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 3600\n assert candidate(slices = [10, 1, 1, 1, 1, 10, 1, 1, 1, 1, 10, 1]) == 31\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(slices = [500, 300, 200, 400, 100, 600, 700, 800, 900, 100, 100, 100]) == 2500\n assert candidate(slices = [2, 5, 3, 4, 8, 1, 9, 7, 6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 210\n"}, "metadata": {"canonical_parameter_names": ["slices"], "leetcode_dataset_entry_point": "Solution().maxSizeSlices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxSizeSlices(self, slices: list[int]) -> int:", "container": "Solution", "callable": "maxSizeSlices", "parameters": [{"name": "slices", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1389, "task_id": "create-target-array-in-the-given-order", "difficulty": "Easy", "problem_description": "Given two arrays of integers nums and index. Your task is to create target array under the following rules:\n\nInitially target array is empty.\nFrom left to right read nums[i] and index[i], insert at index index[i] the value nums[i] in target array.\nRepeat the previous step until there are no elements to read in nums and index.\n\nReturn the target array.\nIt is guaranteed that the insertion operations will be valid.\n \nExample 1:\n\nInput: nums = [0,1,2,3,4], index = [0,1,2,2,1]\nOutput: [0,4,1,3,2]\nExplanation:\nnums index target\n0 0 [0]\n1 1 [0,1]\n2 2 [0,1,2]\n3 2 [0,1,3,2]\n4 1 [0,4,1,3,2]\n\nExample 2:\n\nInput: nums = [1,2,3,4,0], index = [0,1,2,3,0]\nOutput: [0,1,2,3,4]\nExplanation:\nnums index target\n1 0 [1]\n2 1 [1,2]\n3 2 [1,2,3]\n4 3 [1,2,3,4]\n0 0 [0,1,2,3,4]\n\nExample 3:\n\nInput: nums = [1], index = [0]\nOutput: [1]\n\n \nConstraints:\n\n1 <= nums.length, index.length <= 100\nnums.length == index.length\n0 <= nums[i] <= 100\n0 <= index[i] <= i\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1],index = [0]) == [1]\n assert candidate(nums = [10, 9, 8, 7, 6],index = [0, 1, 1, 1, 1]) == [10, 6, 7, 8, 9]\n assert candidate(nums = [0, 1, 2, 3, 4],index = [0, 1, 2, 2, 1]) == [0, 4, 1, 3, 2]\n assert candidate(nums = [5, 5, 5, 5],index = [0, 1, 2, 0]) == [5, 5, 5, 5]\n assert candidate(nums = [5, 4, 3, 2, 1],index = [4, 3, 2, 1, 0]) == [1, 5, 2, 4, 3]\n assert candidate(nums = [5, 5, 5, 5],index = [0, 1, 2, 3]) == [5, 5, 5, 5]\n assert candidate(nums = [9, 8, 7, 6, 5],index = [0, 0, 0, 0, 0]) == [5, 6, 7, 8, 9]\n assert candidate(nums = [1, 3, 2],index = [0, 0, 1]) == [3, 2, 1]\n assert candidate(nums = [0, 0, 0, 0],index = [0, 1, 2, 3]) == [0, 0, 0, 0]\n assert candidate(nums = [9, 8, 7, 6, 5],index = [0, 1, 2, 3, 4]) == [9, 8, 7, 6, 5]\n assert candidate(nums = [1, 3, 2],index = [0, 1, 1]) == [1, 2, 3]\n assert candidate(nums = [1, 2, 3, 4, 0],index = [0, 1, 2, 3, 0]) == [0, 1, 2, 3, 4]\n assert candidate(nums = [9, 8, 7, 6],index = [0, 0, 1, 2]) == [8, 7, 6, 9]\n assert candidate(nums = [10, 9, 8, 7, 6],index = [4, 3, 2, 1, 0]) == [6, 10, 7, 9, 8]\n assert candidate(nums = [9, 8, 7, 6],index = [0, 0, 0, 0]) == [6, 7, 8, 9]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],index = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [5, 5, 3, 2, 6, 5, 9, 4, 1, 3, 1]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]\n assert candidate(nums = [10, 1, 2, 3, 4, 5],index = [0, 3, 1, 1, 2, 4]) == [10, 3, 4, 2, 5, 1]\n assert candidate(nums = [2, 4, 6, 8, 10],index = [0, 2, 4, 1, 3]) == [2, 8, 4, 10, 6]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],index = [0, 1, 2, 3, 4, 5, 6]) == [7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30],index = [0, 1, 2, 2, 2, 2]) == [5, 10, 30, 25, 20, 15]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [42, 31, 20, 10, 0],index = [4, 3, 2, 1, 0]) == [0, 42, 10, 31, 20]\n assert candidate(nums = [5, 3, 8, 6, 2],index = [2, 4, 0, 1, 3]) == [8, 6, 5, 2, 3]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],index = [8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9, 1, 8, 2, 7, 3, 6, 4, 5]\n assert candidate(nums = [3, 1, 2],index = [0, 1, 1]) == [3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 1, 0, 3, 2, 3, 4, 5, 6, 7]) == [3, 1, 5, 6, 7, 8, 9, 10, 2, 4]\n assert candidate(nums = [5, 3, 7, 1, 9],index = [0, 1, 1, 2, 3]) == [5, 7, 1, 9, 3]\n assert candidate(nums = [1, 3, 2, 5, 4],index = [0, 1, 1, 2, 3]) == [1, 2, 5, 4, 3]\n assert candidate(nums = [100, 99, 98, 97, 96, 95],index = [0, 0, 0, 0, 0, 0]) == [95, 96, 97, 98, 99, 100]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 5, 5],index = [4, 3, 2, 1, 0]) == [5, 5, 5, 5, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == [2, 4, 6, 8, 10, 9, 7, 5, 3, 1]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],index = [0, 1, 2, 3, 4, 5, 6, 7]) == [5, 3, 8, 6, 2, 7, 4, 1]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13],index = [0, 1, 2, 0, 1, 2, 3]) == [10, 11, 12, 13, 7, 8, 9]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],index = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [100, 10, 90, 20, 80, 30, 70, 40, 60, 50]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [10, 20, 30, 40, 50, 60],index = [5, 4, 3, 2, 1, 0]) == [60, 10, 50, 20, 40, 30]\n assert candidate(nums = [5, 3, 8, 9, 2],index = [0, 1, 2, 3, 4]) == [5, 3, 8, 9, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 0, 1, 2, 1, 0, 3, 4, 5, 6]) == [6, 2, 5, 7, 8, 9, 10, 3, 4, 1]\n assert candidate(nums = [3, 2, 1],index = [1, 1, 1]) == [3, 1, 2]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [0, 2, 1, 2, 4]) == [10, 30, 40, 20, 50]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],index = [0, 1, 0, 2, 1, 3, 0]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],index = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],index = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]\n assert candidate(nums = [50, 40, 30, 20, 10],index = [4, 3, 2, 1, 0]) == [10, 50, 20, 40, 30]\n assert candidate(nums = [1, 3, 5, 7, 9],index = [0, 0, 0, 0, 0]) == [9, 7, 5, 3, 1]\n assert candidate(nums = [2, 4, 6, 8, 10],index = [5, 4, 3, 2, 1]) == [2, 10, 4, 8, 6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],index = [0, 2, 4, 6, 8, 10, 12]) == [1, 3, 5, 7, 9, 11, 13]\n assert candidate(nums = [100, 90, 80, 70, 60],index = [0, 1, 2, 3, 4]) == [100, 90, 80, 70, 60]\n assert candidate(nums = [1, 3, 5, 7, 9, 11],index = [0, 2, 4, 6, 8, 10]) == [1, 3, 5, 7, 9, 11]\n assert candidate(nums = [1, 3, 2, 5, 4, 8, 7, 6, 10, 9],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [9, 10, 6, 7, 8, 4, 5, 2, 3, 1]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],index = [0, 0, 1, 1, 0, 2, 3, 4, 5, 6, 7]) == [5, 1, 9, 2, 6, 5, 3, 5, 1, 4, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],index = [0, 1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],index = [0, 0, 0, 0, 0, 0, 0, 0, 0]) == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],index = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9, 0, 8, 1, 7, 2, 6, 3, 5, 4]\n assert candidate(nums = [6, 6, 6, 6, 6],index = [0, 0, 1, 1, 2]) == [6, 6, 6, 6, 6]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [4, 3, 2, 1, 0]) == [50, 10, 40, 20, 30]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [0, 1, 0, 2, 3]) == [30, 10, 40, 50, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [5, 15, 25, 35, 45],index = [0, 2, 1, 3, 4]) == [5, 25, 15, 35, 45]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],index = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == [1, 11, 3, 13, 5, 15, 7, 17, 9, 19]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == [1, 3, 5, 7, 9, 10, 2, 4, 8, 6]\n assert candidate(nums = [9, 7, 5, 3, 1],index = [4, 3, 2, 1, 0]) == [1, 9, 3, 7, 5]\n assert candidate(nums = [1, 2, 3, 4, 5],index = [2, 2, 2, 2, 2]) == [1, 2, 5, 4, 3]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [0, 2, 1, 4, 3]) == [10, 30, 20, 50, 40]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 4, 3, 2, 1],index = [0, 1, 2, 2, 2]) == [5, 4, 1, 2, 3]\n assert candidate(nums = [1, 2, 3, 4, 5],index = [2, 3, 4, 0, 1]) == [4, 5, 1, 2, 3]\n assert candidate(nums = [5, 3, 8, 1],index = [2, 2, 1, 0]) == [1, 5, 8, 3]\n assert candidate(nums = [7, 8, 9, 10, 11, 12],index = [1, 3, 3, 2, 0, 5]) == [11, 7, 8, 10, 9, 12]\n assert candidate(nums = [1, 2, 3, 4],index = [0, 0, 0, 0]) == [4, 3, 2, 1]\n assert candidate(nums = [7, 8, 9, 10, 11, 12],index = [0, 0, 1, 1, 2, 2]) == [8, 10, 12, 11, 9, 7]\n assert candidate(nums = [1, 2, 3, 4, 5],index = [4, 3, 2, 1, 0]) == [5, 1, 4, 2, 3]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [0, 2, 1, 3, 1]) == [10, 50, 30, 20, 40]\n assert candidate(nums = [1, 2, 3, 4, 5, 6],index = [5, 4, 3, 2, 1, 0]) == [6, 1, 5, 2, 4, 3]\n assert candidate(nums = [1, 3, 2, 5, 4],index = [0, 0, 1, 1, 2]) == [3, 5, 4, 2, 1]\n assert candidate(nums = [4, 3, 2, 1, 0],index = [2, 2, 2, 2, 2]) == [4, 3, 0, 1, 2]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],index = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]) == [19, 1, 3, 11, 5, 13, 7, 15, 9, 17]\n assert candidate(nums = [9, 8, 7, 6, 5],index = [4, 4, 4, 4, 4]) == [9, 8, 7, 6, 5]\n assert candidate(nums = [0, 1, 0, 1, 0],index = [0, 1, 2, 3, 4]) == [0, 1, 0, 1, 0]\n assert candidate(nums = [100, 99, 98, 97, 96, 95],index = [5, 4, 3, 2, 1, 0]) == [95, 100, 96, 99, 97, 98]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],index = [0, 5, 2, 3, 1, 4, 6, 7, 8, 9]) == [10, 50, 20, 30, 60, 40, 70, 80, 90, 100]\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6],index = [0, 1, 1, 3, 4, 5, 5]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]\n assert candidate(nums = [1, 3, 5, 7, 9],index = [0, 0, 1, 2, 3]) == [3, 5, 7, 9, 1]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [4, 3, 2, 1, 0]) == [50, 10, 40, 20, 30]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5],index = [0, 1, 1, 0, 3, 2]) == [7, 10, 5, 8, 6, 9]\n assert candidate(nums = [7, 8, 9],index = [1, 1, 1]) == [7, 9, 8]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],index = [0, 1, 0, 1, 2, 0, 3, 0, 4, 5, 6]) == [6, 9, 4, 1, 5, 3, 5, 2, 5, 3, 1]\n assert candidate(nums = [0, 1, 1, 1, 0],index = [0, 1, 2, 2, 0]) == [0, 0, 1, 1, 1]\n assert candidate(nums = [3, 2, 1],index = [2, 1, 0]) == [1, 3, 2]\n assert candidate(nums = [6, 5, 4, 3, 2, 1],index = [0, 0, 0, 0, 0, 0]) == [1, 2, 3, 4, 5, 6]\n assert candidate(nums = [100, 99, 98, 97, 96, 95],index = [0, 1, 0, 2, 1, 3]) == [98, 96, 100, 95, 97, 99]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [0, 0, 0, 0, 4]) == [40, 30, 20, 10, 50]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6],index = [0, 2, 2, 1, 5, 3]) == [1, 4, 2, 6, 3, 5]\n assert candidate(nums = [0, 1, 0, 1, 0],index = [0, 1, 0, 1, 0]) == [0, 0, 1, 0, 1]\n assert candidate(nums = [5, 3, 1, 4, 2],index = [4, 1, 3, 0, 2]) == [4, 5, 2, 3, 1]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],index = [6, 5, 4, 3, 2, 1, 0]) == [1, 7, 2, 6, 3, 5, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 1, 0, 2, 3, 4, 5, 6, 7, 8]) == [3, 1, 4, 5, 6, 7, 8, 9, 10, 2]\n assert candidate(nums = [1, 1, 1, 1, 1],index = [0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],index = [0, 0, 0, 0, 0, 0, 0]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4],index = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == [5, 0, 6, 1, 7, 2, 8, 3, 9, 4]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],index = [0, 1, 2, 3, 4, 5, 6]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [33, 22, 11, 66, 55, 44],index = [0, 0, 0, 0, 0, 0]) == [44, 55, 66, 11, 22, 33]\n assert candidate(nums = [1, 1, 1, 1, 1],index = [0, 1, 0, 2, 1]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [2, 3, 1, 5, 4],index = [2, 3, 0, 4, 1]) == [1, 4, 2, 3, 5]\n assert candidate(nums = [1, 3, 5, 7, 9],index = [0, 1, 2, 0, 3]) == [7, 1, 3, 9, 5]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],index = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]\n"}, "metadata": {"canonical_parameter_names": ["nums", "index"], "leetcode_dataset_entry_point": "Solution().createTargetArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def createTargetArray(self, nums: list[int], index: list[int]) -> list[int]:", "container": "Solution", "callable": "createTargetArray", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "index", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1390, "task_id": "four-divisors", "difficulty": "Medium", "problem_description": "Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.\n \nExample 1:\n\nInput: nums = [21,4,7]\nOutput: 32\nExplanation: \n21 has 4 divisors: 1, 3, 7, 21\n4 has 3 divisors: 1, 2, 4\n7 has 2 divisors: 1, 7\nThe answer is the sum of divisors of 21 only.\n\nExample 2:\n\nInput: nums = [21,21]\nOutput: 64\n\nExample 3:\n\nInput: nums = [1,2,3,4,5]\nOutput: 0\n\n \nConstraints:\n\n1 <= nums.length <= 104\n1 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [101, 103, 107, 109, 113]) == 0\n assert candidate(nums = [2310, 2320, 2330, 2340, 2350]) == 0\n assert candidate(nums = [30, 44, 25, 63]) == 0\n assert candidate(nums = [30, 100, 49]) == 0\n assert candidate(nums = [6, 8, 10, 12, 14]) == 69\n assert candidate(nums = [100, 121, 144, 169]) == 0\n assert candidate(nums = [11, 13, 17, 19, 23]) == 0\n assert candidate(nums = [15, 21, 28, 30, 35]) == 104\n assert candidate(nums = [105, 106, 107, 108, 109]) == 162\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [110, 111, 112, 113, 114]) == 152\n assert candidate(nums = [21, 21]) == 64\n assert candidate(nums = [15, 21, 25, 49, 77]) == 152\n assert candidate(nums = [6, 8, 10, 12]) == 45\n assert candidate(nums = [10, 15, 21, 28, 30]) == 74\n assert candidate(nums = [100, 101, 102, 103, 104]) == 0\n assert candidate(nums = [30, 49, 64, 81, 97]) == 0\n assert candidate(nums = [30, 49, 64, 81]) == 0\n assert candidate(nums = [10, 15, 21, 22]) == 110\n assert candidate(nums = [21, 4, 7]) == 32\n assert candidate(nums = [30, 40, 50, 60, 70]) == 0\n assert candidate(nums = [1001, 1009, 1013, 1019, 1021]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19]) == 0\n assert candidate(nums = [10, 15, 21, 22, 28]) == 110\n assert candidate(nums = [15, 28, 91]) == 136\n assert candidate(nums = [36, 49, 64, 81, 100]) == 0\n assert candidate(nums = [6, 8, 10, 12, 14]) == 69\n assert candidate(nums = [100, 101, 102, 103, 104]) == 0\n assert candidate(nums = [500, 525, 546, 567, 570, 588, 594, 616, 630, 646, 660, 672, 684]) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 162\n assert candidate(nums = [144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484]) == 0\n assert candidate(nums = [231, 252, 273, 294, 315]) == 0\n assert candidate(nums = [901, 903, 917, 923, 925, 927, 931, 943, 945, 949, 957, 963, 965, 979, 987, 989, 993, 995, 999, 1001]) == 10908\n assert candidate(nums = [323, 333, 341, 351, 361]) == 744\n assert candidate(nums = [145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165]) == 1242\n assert candidate(nums = [9999, 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010]) == 36664\n assert candidate(nums = [231, 275, 299, 322, 341, 361, 385, 407, 429, 451, 473, 495]) == 2208\n assert candidate(nums = [500, 505, 511, 513, 529, 539, 551, 561, 573, 583, 585, 595, 605, 621, 627, 637, 645, 651, 655, 667, 685]) == 5560\n assert candidate(nums = [220, 280, 300, 330, 350]) == 0\n assert candidate(nums = [882, 924, 966, 1008, 1050]) == 0\n assert candidate(nums = [2048, 2187, 2345, 2500, 2648, 2809, 3003, 3215, 3432, 3654, 3888]) == 3864\n assert candidate(nums = [100, 121, 143, 169, 181]) == 168\n assert candidate(nums = [5005, 5007, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087]) == 6680\n assert candidate(nums = [500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000]) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1005, 1006, 1007, 1009, 1011, 1013, 1015, 1017, 1019, 1021, 1023, 1025, 1027, 1029, 1031, 1033, 1035, 1037, 1039, 1041, 1043, 1045, 1047, 1049, 1051, 1053, 1055]) == 12524\n assert candidate(nums = [56, 84, 91, 112, 119, 126, 133]) == 416\n assert candidate(nums = [1100, 1120, 1122, 1134, 1140, 1155, 1166, 1176, 1183, 1197, 1209, 1225, 1232, 1242, 1254, 1260, 1275]) == 0\n assert candidate(nums = [1485, 1506, 1527, 1548, 1569]) == 4136\n assert candidate(nums = [100, 121, 144, 169, 196, 225]) == 0\n assert candidate(nums = [1275, 1296, 1317, 1338, 1359]) == 1760\n assert candidate(nums = [10001, 10003, 10007, 10009, 10037, 10039, 10061, 10067, 10079]) == 21652\n assert candidate(nums = [1330, 1333, 1343, 1353, 1369]) == 2848\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384]) == 0\n assert candidate(nums = [1105, 1111, 1122, 1147, 1159]) == 3680\n assert candidate(nums = [100000, 99999, 99997, 99989, 99971, 99959, 99949, 99929, 99907]) == 206104\n assert candidate(nums = [961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600]) == 0\n assert candidate(nums = [100, 121, 143, 169, 189]) == 168\n assert candidate(nums = [12, 18, 20, 24, 30, 36, 40, 42, 44, 45, 48, 50]) == 0\n assert candidate(nums = [435, 456, 477, 498, 519]) == 696\n assert candidate(nums = [540, 561, 582, 603, 624]) == 0\n assert candidate(nums = [11025, 11236, 11449, 11664, 11881, 12100, 12321, 12544, 12769, 12996]) == 0\n assert candidate(nums = [221, 231, 253, 273, 299]) == 876\n assert candidate(nums = [1380, 1401, 1422, 1443, 1464]) == 1872\n assert candidate(nums = [1820, 1833, 1849, 1859, 1877]) == 0\n assert candidate(nums = [713, 721, 741, 759, 779]) == 2440\n assert candidate(nums = [1170, 1191, 1212, 1233, 1254]) == 1592\n assert candidate(nums = [130, 156, 168, 182, 208, 224, 234]) == 0\n assert candidate(nums = [407, 413, 437, 459, 463]) == 1416\n assert candidate(nums = [29, 41, 53, 61, 67, 71, 73, 79, 83, 89, 97, 101]) == 0\n assert candidate(nums = [960, 981, 1002, 1023, 1044]) == 0\n assert candidate(nums = [1363, 1403, 1459, 1489, 1517]) == 4524\n assert candidate(nums = [496, 504, 512, 520, 528]) == 0\n assert candidate(nums = [245, 273, 294, 322, 338, 364, 378]) == 0\n assert candidate(nums = [729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739]) == 2712\n assert candidate(nums = [385, 405, 429, 441, 455, 462, 473, 483, 495]) == 528\n assert candidate(nums = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 0\n assert candidate(nums = [1800, 1821, 1842, 1863, 1884]) == 2432\n assert candidate(nums = [100, 121, 144, 169, 196]) == 0\n assert candidate(nums = [1065, 1086, 1107, 1128, 1149]) == 1536\n assert candidate(nums = [1369, 1521, 1681, 1849, 2025, 2209, 2401, 2601, 2809, 3025, 3249]) == 0\n assert candidate(nums = [2115, 2136, 2157, 2178, 2199]) == 5816\n assert candidate(nums = [120, 180, 240, 300, 360]) == 0\n assert candidate(nums = [1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063]) == 0\n assert candidate(nums = [1111, 1189, 1247, 1271, 1309]) == 5148\n assert candidate(nums = [2002, 2014, 2021, 2035, 2047]) == 4272\n assert candidate(nums = [1610, 1619, 1643, 1657, 1679]) == 3504\n assert candidate(nums = [110, 132, 154, 176, 198]) == 0\n assert candidate(nums = [913, 943, 979, 1009, 1037]) == 4212\n assert candidate(nums = [700, 715, 729, 741, 756, 765, 777, 784, 792, 805, 819, 828, 832, 840, 855]) == 0\n assert candidate(nums = [330, 351, 372, 393, 414]) == 528\n assert candidate(nums = [855, 876, 897, 918, 939]) == 1256\n assert candidate(nums = [1155, 1365, 1785, 1995, 2310, 2730, 3003, 3276, 3570]) == 0\n assert candidate(nums = [900, 910, 924, 936, 945, 966, 975, 990, 1001, 1008, 1014, 1029, 1035, 1053, 1056, 1065]) == 0\n assert candidate(nums = [561, 609, 657, 703, 759]) == 760\n assert candidate(nums = [1430, 1441, 1451, 1463, 1481]) == 1584\n assert candidate(nums = [100, 121, 143, 169, 180]) == 168\n assert candidate(nums = [1541, 1547, 1561, 1577, 1589]) == 6928\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 0\n assert candidate(nums = [1925, 1931, 1943, 1946, 1957]) == 4120\n assert candidate(nums = [1729, 1739, 1751, 1763, 1771]) == 5544\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 0\n assert candidate(nums = [143, 221, 247, 299, 323]) == 1396\n assert candidate(nums = [1905, 1926, 1947, 1968, 1989]) == 0\n assert candidate(nums = [600, 625, 648, 675, 700, 729, 756, 784, 810, 841, 864, 891]) == 0\n assert candidate(nums = [667, 713, 779, 817, 851]) == 4120\n assert candidate(nums = [65537, 65539, 65543, 65551, 65561, 65579, 65591, 65597]) == 208140\n assert candidate(nums = [645, 666, 687, 708, 729]) == 920\n assert candidate(nums = [105, 126, 147, 168, 189]) == 0\n assert candidate(nums = [1386, 1452, 1518, 1584, 1650]) == 0\n assert candidate(nums = [903, 913, 924, 931, 943]) == 2016\n assert candidate(nums = [841, 961, 1089, 1225, 1369]) == 0\n assert candidate(nums = [609, 621, 637, 651, 671]) == 744\n assert candidate(nums = [121, 125, 143, 147, 169, 175, 182, 189, 196, 209, 221, 225, 245, 253, 265, 275, 287, 299]) == 2100\n assert candidate(nums = [1695, 1716, 1737, 1758, 1779]) == 2376\n assert candidate(nums = [1590, 1611, 1632, 1653, 1674]) == 0\n assert candidate(nums = [496, 672, 728, 840, 924]) == 0\n assert candidate(nums = [121, 144, 169, 196, 225]) == 0\n assert candidate(nums = [1105, 1365, 1615, 1885, 2145, 2415, 2685, 2955, 3225, 3495, 3765]) == 0\n assert candidate(nums = [506, 518, 529, 539, 551]) == 600\n assert candidate(nums = [1331, 1369, 1406, 1444, 1482, 1521, 1562, 1600, 1640, 1681, 1722, 1764]) == 1464\n assert candidate(nums = [406, 429, 455, 462, 494, 518, 546]) == 0\n assert candidate(nums = [45, 60, 77, 84, 91, 99, 100]) == 208\n assert candidate(nums = [325, 351, 375, 399, 425]) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115]) == 458\n assert candidate(nums = [2010, 2031, 2052, 2073, 2094]) == 5480\n assert candidate(nums = [120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130]) == 686\n assert candidate(nums = [1001, 1007, 1029, 1045, 1067]) == 2256\n assert candidate(nums = [805, 819, 836, 851, 869]) == 1872\n assert candidate(nums = [1221, 1235, 1241, 1254, 1265]) == 1332\n assert candidate(nums = [750, 771, 792, 813, 834]) == 2120\n assert candidate(nums = [703, 707, 713, 725, 729, 735, 741, 745, 749, 759, 763, 779, 783, 799, 803, 805, 815, 825, 833, 835, 837, 841]) == 9572\n assert candidate(nums = [77, 110, 143, 176, 209]) == 504\n assert candidate(nums = [324, 325, 329, 333, 341, 343, 345, 351, 357, 361, 363, 371, 375, 385, 387, 399, 405, 425, 427, 429, 441, 451]) == 2600\n assert candidate(nums = [1021, 1031, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097]) == 0\n assert candidate(nums = [391, 437, 493, 529, 551]) == 2052\n assert candidate(nums = [231, 255, 273, 297, 315, 333, 351]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumFourDivisors", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def sumFourDivisors(self, nums: list[int]) -> int:", "container": "Solution", "callable": "sumFourDivisors", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1391, "task_id": "check-if-there-is-a-valid-path-in-a-grid", "difficulty": "Medium", "problem_description": "You are given an m x n grid. Each cell of grid represents a street. The street of grid[i][j] can be:\n\n1 which means a street connecting the left cell and the right cell.\n2 which means a street connecting the upper cell and the lower cell.\n3 which means a street connecting the left cell and the lower cell.\n4 which means a street connecting the right cell and the lower cell.\n5 which means a street connecting the left cell and the upper cell.\n6 which means a street connecting the right cell and the upper cell.\n\n\nYou will initially start at the street of the upper-left cell (0, 0). A valid path in the grid is a path that starts from the upper left cell (0, 0) and ends at the bottom-right cell (m - 1, n - 1). The path should only follow the streets.\nNotice that you are not allowed to change any street.\nReturn true if there is a valid path in the grid or false otherwise.\n \nExample 1:\n\n\nInput: grid = [[2,4,3],[6,5,2]]\nOutput: true\nExplanation: As shown you can start at cell (0, 0) and visit all the cells of the grid to reach (m - 1, n - 1).\n\nExample 2:\n\n\nInput: grid = [[1,2,1],[1,2,1]]\nOutput: false\nExplanation: As shown you the street at cell (0, 0) is not connected with any street of any other cell and you will get stuck at cell (0, 0)\n\nExample 3:\n\nInput: grid = [[1,1,2]]\nOutput: false\nExplanation: You will get stuck at cell (0, 1) and you cannot reach cell (0, 2).\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 300\n1 <= grid[i][j] <= 6\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[4, 3, 2, 1], [2, 1, 4, 3], [3, 2, 1, 4]]) == False\n assert candidate(grid = [[2], [2], [2]]) == True\n assert candidate(grid = [[1, 1, 2]]) == False\n assert candidate(grid = [[2, 4, 3], [6, 5, 2]]) == True\n assert candidate(grid = [[4, 1, 3], [6, 1, 6], [3, 2, 4]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 3]]) == True\n assert candidate(grid = [[2, 6, 6, 5], [6, 6, 5, 6], [5, 6, 6, 6], [6, 5, 2, 6]]) == False\n assert candidate(grid = [[1, 3, 5, 1], [1, 2, 1, 2], [1, 2, 1, 2]]) == False\n assert candidate(grid = [[5, 3, 1, 1, 2, 3, 6, 4, 4, 5], [6, 1, 3, 2, 2, 1, 4, 3, 5, 4], [4, 3, 5, 1, 2, 2, 2, 1, 3, 4], [4, 1, 4, 2, 3, 3, 1, 1, 2, 4], [1, 2, 2, 4, 2, 3, 3, 3, 1, 4], [2, 2, 4, 1, 4, 2, 1, 1, 3, 4], [6, 4, 4, 1, 4, 1, 3, 1, 4, 1], [5, 1, 5, 4, 2, 2, 1, 2, 6, 4], [1, 1, 3, 1, 2, 5, 2, 3, 6, 5], [2, 2, 1, 4, 4, 1, 3, 1, 4, 6]]) == False\n assert candidate(grid = [[2, 1, 1, 1, 1, 1, 3]]) == False\n assert candidate(grid = [[1, 2, 1], [1, 2, 1]]) == False\n assert candidate(grid = [[4, 3, 3], [6, 5, 2]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 1], [1, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 1], [1, 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 1], [1, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2, 2, 2, 2, 2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2, 1, 1, 1, 2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2, 1, 6, 1, 2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2, 1, 6, 5, 2, 3, 4, 5, 6, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 4, 2, 5, 6], [2, 6, 5, 3, 3], [5, 4, 1, 6, 2], [1, 2, 1, 2, 1], [1, 3, 6, 4, 5]]) == False\n assert candidate(grid = [[3, 1, 1, 2, 2, 5, 2, 1, 5, 4], [4, 6, 5, 3, 5, 1, 6, 1, 4, 1], [2, 4, 2, 6, 1, 3, 2, 1, 6, 5], [1, 4, 2, 1, 5, 4, 2, 6, 3, 1], [2, 5, 1, 4, 6, 2, 3, 1, 5, 4], [1, 3, 4, 2, 1, 6, 5, 4, 2, 3], [4, 2, 1, 5, 4, 2, 1, 6, 5, 1], [2, 5, 1, 4, 6, 2, 3, 1, 4, 2], [5, 1, 4, 2, 1, 5, 4, 2, 1, 6], [6, 3, 2, 1, 5, 4, 1, 6, 5, 3]]) == False\n assert candidate(grid = [[3, 2, 1, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3, 4, 5], [5, 6, 1, 2, 3, 4, 5, 6], [6, 1, 2, 3, 4, 5, 6, 1], [1, 2, 3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1, 2, 3]]) == False\n assert candidate(grid = [[3, 3, 6, 6, 4, 4, 5, 2, 5, 4], [3, 6, 3, 1, 2, 2, 3, 1, 3, 5], [4, 2, 2, 6, 3, 5, 5, 4, 1, 2], [1, 1, 5, 2, 1, 1, 1, 2, 6, 5], [2, 3, 1, 2, 1, 2, 1, 4, 1, 5]]) == False\n assert candidate(grid = [[2, 3, 4, 5, 1, 1, 5, 6, 3, 3], [4, 2, 5, 2, 1, 1, 1, 3, 5, 2], [5, 5, 5, 6, 4, 4, 2, 4, 5, 5], [2, 3, 1, 1, 3, 1, 4, 5, 4, 4], [2, 1, 1, 4, 5, 3, 2, 1, 4, 5], [3, 4, 5, 4, 6, 6, 3, 2, 5, 1], [6, 4, 3, 1, 5, 6, 1, 3, 3, 3], [1, 2, 5, 5, 4, 3, 3, 3, 3, 2], [3, 1, 4, 4, 3, 6, 1, 4, 4, 5], [1, 1, 2, 5, 2, 3, 3, 5, 4, 5]]) == False\n assert candidate(grid = [[2, 1, 1, 1, 1, 1, 1, 1, 1, 6], [3, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4]]) == False\n assert candidate(grid = [[6, 3, 1, 4, 3, 2], [4, 2, 3, 6, 5, 4], [1, 5, 4, 2, 1, 6], [4, 2, 1, 6, 5, 4], [3, 6, 5, 4, 2, 1], [6, 5, 4, 2, 1, 4]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3]]) == False\n assert candidate(grid = [[4, 3, 1, 5, 2, 3, 6, 4, 4, 5], [6, 5, 3, 2, 2, 1, 4, 3, 5, 4], [4, 3, 5, 1, 2, 2, 2, 1, 3, 4], [4, 1, 4, 2, 3, 3, 1, 1, 2, 4], [1, 2, 2, 4, 2, 3, 3, 3, 1, 4], [2, 2, 4, 1, 4, 2, 1, 1, 3, 4], [6, 4, 4, 1, 4, 1, 3, 1, 4, 1], [5, 1, 5, 4, 2, 2, 1, 2, 6, 4], [1, 1, 3, 1, 2, 5, 2, 3, 6, 5], [2, 2, 1, 4, 4, 1, 3, 1, 4, 6]]) == False\n assert candidate(grid = [[2, 5, 3, 4, 3, 2, 1], [1, 6, 5, 4, 3, 2, 4], [4, 3, 2, 1, 6, 5, 3], [3, 2, 1, 6, 5, 4, 2], [6, 5, 4, 2, 1, 4, 3], [5, 4, 2, 1, 6, 5, 1], [2, 1, 6, 5, 4, 2, 6]]) == False\n assert candidate(grid = [[3, 2, 1, 6, 5, 4], [2, 1, 4, 3, 6, 5], [1, 6, 3, 4, 5, 2], [6, 5, 1, 4, 3, 2], [3, 2, 6, 5, 4, 1], [4, 3, 5, 2, 1, 6]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[3, 4, 5, 2, 1, 6, 5, 4], [6, 4, 3, 1, 6, 5, 4, 3], [5, 3, 2, 4, 5, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3], [1, 6, 5, 4, 1, 6, 5, 4], [4, 2, 1, 6, 4, 2, 1, 6], [3, 6, 5, 4, 3, 6, 5, 4], [6, 5, 4, 2, 6, 5, 4, 2]]) == False\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == False\n assert candidate(grid = [[5, 6, 3, 4, 1, 2, 3, 4, 1, 2], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[1, 5, 1, 3, 3], [1, 1, 4, 1, 6], [3, 2, 5, 1, 2], [3, 1, 5, 1, 3], [1, 1, 6, 1, 2]]) == False\n assert candidate(grid = [[5, 2, 1, 6], [6, 5, 2, 1], [1, 6, 5, 2], [2, 1, 6, 5]]) == False\n assert candidate(grid = [[1, 4, 3, 6, 2, 6, 1, 1, 6, 6], [6, 6, 2, 2, 4, 4, 4, 6, 1, 6], [3, 6, 1, 1, 3, 6, 6, 1, 6, 5], [6, 3, 2, 2, 3, 6, 6, 5, 1, 1], [1, 4, 6, 3, 4, 6, 3, 2, 6, 3], [6, 5, 5, 4, 2, 3, 3, 4, 1, 6], [6, 6, 1, 5, 2, 5, 6, 3, 4, 4], [4, 5, 6, 5, 2, 3, 5, 6, 3, 4], [1, 3, 4, 6, 5, 6, 5, 3, 5, 6], [6, 4, 6, 1, 5, 6, 4, 4, 4, 4]]) == False\n assert candidate(grid = [[2, 3, 1, 4, 2, 3, 6, 5, 1, 4], [4, 2, 5, 3, 4, 2, 5, 3, 4, 2], [5, 3, 4, 2, 5, 3, 4, 2, 5, 3], [4, 2, 5, 3, 4, 2, 5, 3, 4, 2], [5, 3, 4, 2, 5, 3, 4, 2, 5, 3], [4, 2, 5, 3, 4, 2, 5, 3, 4, 2]]) == False\n assert candidate(grid = [[4, 2, 3, 1, 5, 4, 2, 5, 6, 2], [5, 1, 1, 1, 2, 3, 3, 4, 4, 4], [2, 2, 6, 5, 4, 4, 4, 1, 5, 6], [4, 3, 2, 1, 5, 3, 4, 5, 1, 2], [3, 2, 2, 3, 5, 1, 4, 1, 3, 6], [5, 4, 2, 4, 4, 3, 5, 1, 4, 6], [3, 4, 3, 2, 5, 2, 3, 2, 1, 2], [5, 3, 2, 2, 6, 1, 4, 3, 5, 5], [6, 5, 4, 1, 3, 6, 2, 3, 5, 1], [2, 1, 4, 5, 2, 3, 4, 4, 3, 4]]) == False\n assert candidate(grid = [[4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4]]) == False\n assert candidate(grid = [[6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[6, 1, 1, 1, 1, 1, 2, 4, 3, 2], [5, 4, 6, 5, 4, 2, 2, 5, 4, 6], [3, 2, 2, 6, 4, 1, 3, 1, 1, 3], [5, 3, 2, 1, 2, 5, 4, 3, 4, 4], [5, 2, 1, 4, 3, 3, 3, 1, 2, 5], [1, 2, 3, 1, 6, 1, 4, 4, 5, 3], [3, 1, 4, 4, 1, 4, 1, 4, 2, 4], [1, 2, 6, 3, 4, 1, 5, 1, 1, 1], [3, 4, 2, 1, 6, 3, 2, 6, 4, 1], [1, 5, 6, 5, 6, 4, 2, 4, 5, 3]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]]) == False\n assert candidate(grid = [[5, 2, 3, 1, 2, 6, 4, 4, 5, 3, 1, 2], [3, 1, 5, 4, 2, 3, 2, 1, 5, 4, 2, 3], [2, 6, 4, 3, 6, 5, 3, 5, 4, 3, 6, 5], [4, 3, 5, 4, 3, 5, 4, 3, 5, 4, 3, 5], [5, 4, 3, 5, 4, 3, 5, 4, 3, 5, 4, 3]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 5, 4, 3, 2], [2, 3, 4, 5, 6, 1, 4, 3, 2, 1], [3, 4, 5, 6, 1, 2, 5, 4, 3, 2], [4, 5, 6, 1, 2, 3, 6, 5, 4, 3], [5, 6, 1, 2, 3, 4, 1, 6, 5, 4], [6, 1, 2, 3, 4, 5, 2, 1, 6, 5]]) == False\n assert candidate(grid = [[2, 6, 6, 2, 6, 6, 2, 2, 2, 5], [3, 3, 3, 5, 5, 3, 5, 6, 5, 6], [1, 5, 6, 4, 5, 6, 1, 1, 6, 3], [1, 4, 5, 6, 4, 3, 6, 4, 1, 6], [3, 3, 3, 2, 5, 4, 1, 4, 4, 1], [1, 5, 4, 1, 3, 3, 5, 4, 1, 6], [1, 1, 4, 1, 4, 2, 1, 1, 3, 6], [1, 4, 5, 2, 1, 4, 4, 6, 4, 5], [5, 1, 6, 6, 1, 6, 3, 5, 1, 3], [4, 3, 5, 1, 4, 1, 4, 1, 5, 1]]) == False\n assert candidate(grid = [[1, 3, 6, 2, 6, 5, 6, 1, 3, 6], [1, 4, 5, 2, 5, 1, 3, 5, 2, 1], [5, 4, 5, 2, 3, 3, 3, 2, 6, 4], [4, 4, 1, 1, 6, 2, 4, 3, 4, 4], [4, 1, 6, 5, 3, 5, 1, 5, 4, 3], [6, 6, 3, 4, 2, 3, 5, 5, 2, 3], [3, 2, 2, 2, 5, 1, 4, 5, 3, 2], [1, 2, 2, 3, 1, 4, 5, 1, 3, 1], [6, 4, 1, 2, 1, 6, 4, 5, 2, 6], [2, 5, 4, 3, 1, 6, 2, 1, 1, 6]]) == False\n assert candidate(grid = [[5, 3, 4, 2, 1, 4, 2, 5, 3, 6], [6, 4, 5, 1, 2, 3, 5, 2, 4, 1], [3, 2, 1, 4, 5, 6, 1, 4, 5, 2], [2, 1, 4, 5, 6, 1, 4, 5, 6, 3], [1, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[5, 5, 1, 6, 3, 1, 4, 2, 5, 4], [2, 1, 4, 1, 2, 3, 1, 4, 6, 2], [4, 5, 1, 1, 6, 2, 6, 1, 2, 6], [2, 6, 5, 2, 4, 6, 1, 2, 1, 3], [4, 1, 2, 5, 1, 4, 4, 1, 3, 2], [3, 2, 1, 3, 5, 4, 1, 2, 6, 3], [1, 2, 2, 3, 1, 2, 5, 1, 2, 4], [1, 3, 2, 6, 3, 2, 2, 1, 6, 4], [6, 3, 6, 1, 1, 6, 2, 3, 6, 3], [6, 3, 4, 4, 6, 2, 3, 1, 2, 1]]) == False\n assert candidate(grid = [[2, 3, 6, 5, 5, 4, 5, 1, 1, 4], [2, 1, 5, 5, 2, 1, 5, 5, 1, 3], [1, 5, 4, 2, 4, 3, 3, 4, 5, 4], [3, 6, 5, 6, 4, 1, 3, 3, 2, 2], [5, 2, 4, 1, 4, 2, 5, 5, 6, 6], [1, 2, 4, 6, 6, 4, 5, 5, 4, 4], [4, 1, 2, 4, 1, 4, 5, 6, 4, 6], [3, 5, 5, 6, 3, 4, 5, 4, 1, 1], [3, 5, 3, 2, 3, 2, 4, 1, 6, 5], [4, 1, 4, 1, 5, 3, 3, 5, 3, 3]]) == False\n assert candidate(grid = [[2, 3, 4, 1, 2, 5, 3, 6, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 6, 5, 4, 3, 2], [2, 1, 6, 5, 4, 3], [3, 2, 1, 6, 5, 4], [4, 3, 2, 1, 6, 5]]) == False\n assert candidate(grid = [[2, 3, 4, 5, 6, 1, 3, 2, 4, 1], [1, 4, 2, 3, 5, 6, 1, 2, 3, 4], [5, 6, 1, 4, 2, 3, 4, 1, 2, 3], [6, 1, 2, 3, 4, 5, 6, 1, 4, 2], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[3, 4, 5, 2], [6, 4, 3, 1], [5, 3, 2, 4], [2, 1, 4, 3]]) == False\n assert candidate(grid = [[1, 4, 2, 3, 6, 5, 4, 1, 2, 6], [5, 3, 1, 2, 1, 1, 4, 2, 3, 5], [4, 2, 1, 5, 4, 2, 1, 3, 6, 1], [1, 6, 2, 3, 1, 5, 4, 1, 2, 4], [2, 5, 1, 2, 6, 3, 1, 6, 4, 1], [5, 3, 4, 1, 6, 1, 2, 5, 1, 3], [1, 2, 6, 3, 1, 4, 1, 6, 2, 1], [4, 2, 1, 5, 4, 2, 3, 1, 6, 5], [3, 6, 1, 2, 4, 1, 5, 4, 2, 3], [2, 1, 5, 4, 1, 3, 1, 6, 2, 4]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == False\n assert candidate(grid = [[2, 1, 1, 1, 1, 1, 1, 1, 1, 6], [3, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4]]) == False\n assert candidate(grid = [[2, 1, 1, 1, 1], [1, 6, 1, 4, 2], [2, 1, 2, 1, 1], [2, 6, 1, 1, 1], [1, 1, 1, 6, 4]]) == False\n assert candidate(grid = [[6, 4, 5, 2, 1, 3, 3, 1, 4, 6], [2, 4, 6, 5, 1, 1, 4, 3, 3, 2], [5, 5, 5, 4, 3, 2, 1, 4, 1, 3], [1, 1, 5, 2, 4, 4, 1, 4, 3, 5], [6, 1, 2, 1, 6, 3, 2, 2, 5, 3], [1, 4, 6, 3, 3, 4, 2, 4, 1, 3], [4, 4, 1, 2, 5, 1, 5, 3, 5, 2], [2, 3, 1, 1, 1, 1, 5, 4, 5, 5], [4, 2, 2, 3, 5, 5, 5, 4, 6, 6], [2, 4, 3, 6, 3, 2, 3, 5, 6, 5]]) == False\n assert candidate(grid = [[2, 1, 2, 3, 6, 5, 6, 4, 5, 1], [3, 1, 6, 1, 3, 3, 1, 1, 5, 6], [5, 1, 4, 2, 5, 2, 2, 5, 4, 3], [6, 6, 6, 3, 2, 5, 3, 2, 6, 5], [1, 4, 4, 6, 3, 4, 5, 6, 6, 1], [3, 2, 4, 2, 1, 5, 3, 1, 4, 3], [6, 2, 1, 4, 6, 4, 4, 4, 5, 3], [2, 3, 2, 6, 6, 1, 3, 1, 5, 4], [6, 6, 5, 4, 3, 2, 1, 2, 4, 3], [2, 5, 4, 3, 1, 1, 4, 5, 5, 1]]) == False\n assert candidate(grid = [[6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [6, 5, 5, 5, 5, 5, 5, 5, 5, 6], [6, 5, 4, 4, 4, 4, 4, 4, 5, 6], [6, 5, 4, 3, 3, 3, 3, 4, 5, 6], [6, 5, 4, 3, 2, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 6, 5, 4, 6], [6, 5, 4, 3, 2, 1, 6, 5, 6, 6], [6, 5, 4, 3, 2, 1, 6, 6, 6, 6]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2], [2, 1, 6, 5, 4, 3], [3, 2, 1, 6, 5, 4]]) == False\n assert candidate(grid = [[6, 1, 3, 5, 2, 4, 3, 1, 5, 1], [4, 2, 5, 4, 1, 6, 4, 2, 3, 4], [1, 5, 2, 4, 6, 2, 6, 3, 2, 6], [3, 6, 2, 1, 5, 4, 6, 2, 4, 4], [1, 2, 4, 4, 3, 3, 4, 6, 2, 5], [2, 5, 5, 6, 1, 3, 5, 4, 4, 6], [5, 4, 4, 6, 2, 3, 1, 6, 1, 3], [5, 5, 2, 4, 1, 4, 3, 2, 6, 1], [5, 6, 2, 1, 3, 2, 4, 2, 3, 5], [4, 5, 5, 1, 3, 4, 2, 5, 1, 2]]) == False\n assert candidate(grid = [[6, 2, 1, 3, 5, 4], [4, 5, 6, 1, 2, 3], [3, 2, 1, 6, 5, 4], [2, 1, 4, 3, 5, 6], [5, 6, 3, 2, 4, 1], [1, 4, 2, 5, 3, 6]]) == False\n assert candidate(grid = [[5, 1, 6, 1, 3, 2, 5, 4, 1, 3], [4, 2, 1, 5, 6, 3, 1, 2, 4, 5], [1, 6, 2, 3, 1, 5, 6, 1, 3, 2], [6, 3, 1, 2, 4, 1, 5, 4, 2, 1], [2, 1, 5, 4, 1, 3, 2, 1, 5, 6], [4, 2, 1, 5, 6, 3, 1, 2, 4, 1], [1, 6, 2, 3, 1, 5, 4, 2, 1, 5], [2, 1, 5, 4, 1, 3, 2, 1, 6, 3], [5, 4, 2, 1, 6, 1, 3, 5, 4, 2], [1, 3, 2, 5, 4, 1, 6, 3, 2, 1]]) == False\n assert candidate(grid = [[2, 5, 3, 6, 1, 4], [1, 4, 2, 5, 3, 6], [3, 6, 1, 4, 2, 5], [2, 5, 3, 6, 1, 4], [1, 4, 2, 5, 3, 6]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[4, 6, 1, 3, 5, 2], [5, 2, 4, 6, 1, 3], [3, 5, 2, 4, 6, 1], [6, 1, 3, 5, 2, 4], [2, 4, 6, 1, 3, 5], [1, 3, 5, 2, 4, 6]]) == False\n assert candidate(grid = [[2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4, 3, 2]]) == False\n assert candidate(grid = [[1, 5, 1, 2, 6, 4, 1, 3, 2, 5], [5, 4, 2, 1, 1, 3, 4, 1, 6, 2], [1, 3, 5, 4, 2, 6, 1, 2, 5, 1], [3, 4, 6, 1, 1, 2, 6, 4, 1, 2], [5, 1, 2, 4, 1, 1, 4, 1, 2, 6], [4, 6, 5, 2, 1, 6, 2, 3, 5, 4], [1, 2, 4, 5, 2, 1, 6, 1, 4, 3], [2, 5, 1, 4, 2, 1, 1, 4, 1, 6], [4, 1, 6, 1, 4, 2, 3, 2, 6, 1], [5, 4, 2, 3, 1, 4, 1, 1, 4, 2]]) == False\n assert candidate(grid = [[5, 4, 3, 6, 1, 2], [2, 1, 4, 3, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3], [3, 2, 1, 6, 5, 4]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1]]) == False\n assert candidate(grid = [[1, 6, 5, 4, 3, 2, 1, 2, 3, 4], [6, 5, 4, 3, 2, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4, 5, 6], [4, 3, 2, 1, 2, 3, 4, 5, 6, 1], [3, 2, 1, 2, 3, 4, 5, 6, 1, 2], [2, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1]]) == False\n assert candidate(grid = [[2, 6, 2, 5, 4, 3, 5, 1, 6, 5], [5, 4, 3, 5, 4, 3, 5, 4, 3, 5], [4, 3, 5, 4, 3, 5, 4, 3, 5, 4], [3, 5, 4, 3, 5, 4, 3, 5, 4, 3], [5, 4, 3, 5, 4, 3, 5, 4, 3, 5], [4, 3, 5, 4, 3, 5, 4, 3, 5, 4]]) == False\n assert candidate(grid = [[1, 2, 5, 6, 3, 4], [4, 3, 2, 1, 6, 5], [5, 6, 4, 3, 2, 1], [1, 6, 5, 4, 3, 2], [2, 1, 3, 4, 5, 6], [6, 5, 2, 1, 4, 3]]) == False\n assert candidate(grid = [[1, 3, 1, 3, 1, 3, 1, 3, 1, 3], [3, 1, 3, 1, 3, 1, 3, 1, 3, 1], [1, 3, 1, 3, 1, 3, 1, 3, 1, 3], [3, 1, 3, 1, 3, 1, 3, 1, 3, 1], [1, 3, 1, 3, 1, 3, 1, 3, 1, 3], [3, 1, 3, 1, 3, 1, 3, 1, 3, 1]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[5, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 5], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 5]]) == False\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().hasValidPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def hasValidPath(self, grid: list[list[int]]) -> bool:", "container": "Solution", "callable": "hasValidPath", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1392, "task_id": "longest-happy-prefix", "difficulty": "Hard", "problem_description": "A string is called a happy prefix if is a non-empty prefix which is also a suffix (excluding itself).\nGiven a string s, return the longest happy prefix of s. Return an empty string \"\" if no such prefix exists.\n \nExample 1:\n\nInput: s = \"level\"\nOutput: \"l\"\nExplanation: s contains 4 prefix excluding itself (\"l\", \"le\", \"lev\", \"leve\"), and suffix (\"l\", \"el\", \"vel\", \"evel\"). The largest prefix which is also suffix is given by \"l\".\n\nExample 2:\n\nInput: s = \"ababab\"\nOutput: \"abab\"\nExplanation: \"abab\" is the largest prefix which is also suffix. They can overlap in the original string.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"prefixprefix\") == \"prefix\"\n assert candidate(s = \"abcdef\") == \"\"\n assert candidate(s = \"aaaaa\") == \"aaaa\"\n assert candidate(s = \"aaaaabaaaa\") == \"aaaa\"\n assert candidate(s = \"a\") == \"\"\n assert candidate(s = \"abacabadabacaba\") == \"abacaba\"\n assert candidate(s = \"abcabcabc\") == \"abcabc\"\n assert candidate(s = \"abcabcabcabc\") == \"abcabcabc\"\n assert candidate(s = \"aaaaaabbbaaaa\") == \"aaaa\"\n assert candidate(s = \"happy\") == \"\"\n assert candidate(s = \"noon\") == \"n\"\n assert candidate(s = \"banana\") == \"\"\n assert candidate(s = \"abc\") == \"\"\n assert candidate(s = \"aabbccddeeaabbccdd\") == \"aabbccdd\"\n assert candidate(s = \"abcd\") == \"\"\n assert candidate(s = \"aabbccddeeffgg\") == \"\"\n assert candidate(s = \"suffix\") == \"\"\n assert candidate(s = \"aaaa\") == \"aaa\"\n assert candidate(s = \"mississippi\") == \"\"\n assert candidate(s = \"abcdabc\") == \"abc\"\n assert candidate(s = \"ababab\") == \"abab\"\n assert candidate(s = \"level\") == \"l\"\n assert candidate(s = \"abacababacab\") == \"abacab\"\n assert candidate(s = \"ababababcababab\") == \"ababab\"\n assert candidate(s = \"abacabadabacabadabacaba\") == \"abacabadabacaba\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == \"abcdefghijabcdefghijabcdefghij\"\n assert candidate(s = \"bananaananabay\") == \"\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"abracadabra\") == \"abra\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"abcdefabcdefabcdef\") == \"abcdefabcdef\"\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == \"abacabadabacabadabacabad\"\n assert candidate(s = \"abcabcabcabcabcd\") == \"\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyzxyz\"\n assert candidate(s = \"aababaabaababaaba\") == \"aababaaba\"\n assert candidate(s = \"aaaabaaaa\") == \"aaaa\"\n assert candidate(s = \"zazazazazazazazazazaz\") == \"zazazazazazazazazaz\"\n assert candidate(s = \"abcabcabcabcabcabca\") == \"abcabcabcabcabca\"\n assert candidate(s = \"abbaabbaabbaabbaabbaabba\") == \"abbaabbaabbaabbaabba\"\n assert candidate(s = \"aabaaabaabaaabaabaabaaabaabaab\") == \"aab\"\n assert candidate(s = \"mississippimississippimississippimis\") == \"mississippimississippimis\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\"\n assert candidate(s = \"abcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcba\") == \"abcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcba\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"aaaaaaabaaaaaab\") == \"\"\n assert candidate(s = \"aaaaabbbbbccccdddd\") == \"\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"acacacacac\") == \"acacacac\"\n assert candidate(s = \"xyzxyzxyzxyz\") == \"xyzxyzxyz\"\n assert candidate(s = \"mississippimississippi\") == \"mississippi\"\n assert candidate(s = \"aaaaaabbbaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"aaaaabbbbbbbaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"bananaananabanana\") == \"banana\"\n assert candidate(s = \"mississippimississippimiss\") == \"mississippimiss\"\n assert candidate(s = \"aabbaabbaabbaabb\") == \"aabbaabbaabb\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacaba\") == \"abacabadabacabadabacabadabacaba\"\n assert candidate(s = \"abcabcabcabcabcabcabc\") == \"abcabcabcabcabcabc\"\n assert candidate(s = \"zazazazazazaz\") == \"zazazazazaz\"\n assert candidate(s = \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\") == \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\"\n assert candidate(s = \"ababcabababa\") == \"aba\"\n assert candidate(s = \"aaabaaaab\") == \"aaab\"\n assert candidate(s = \"aaaaaaaab\") == \"\"\n assert candidate(s = \"abacabacabac\") == \"abacabac\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == \"abcdabcdabcdabcdabcdabcdabcdabcdabcd\"\n assert candidate(s = \"mississippimississippimississippi\") == \"mississippimississippi\"\n assert candidate(s = \"xyzxyzzxyzxyz\") == \"xyzxyz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"abcdabcde\") == \"\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"ababbababbababbabab\") == \"ababbababbabab\"\n assert candidate(s = \"abcabcabcabcab\") == \"abcabcabcab\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"ababababababab\") == \"abababababab\"\n assert candidate(s = \"abcdeedcba\") == \"a\"\n assert candidate(s = \"aaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abababababababab\") == \"ababababababab\"\n assert candidate(s = \"ababababababababab\") == \"abababababababab\"\n assert candidate(s = \"abcabcabcabcabcabc\") == \"abcabcabcabcabc\"\n assert candidate(s = \"aaaaaaaaaabaaaaaaaaa\") == \"aaaaaaaaa\"\n assert candidate(s = \"aaaaabaaaabaaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"aaaaaaa\") == \"aaaaaa\"\n assert candidate(s = \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\") == \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\"\n assert candidate(s = \"abababababababababababababab\") == \"ababababababababababababab\"\n assert candidate(s = \"racecaracecarace\") == \"racecarace\"\n assert candidate(s = \"abcdabcdabcdabcdabcd\") == \"abcdabcdabcdabcd\"\n assert candidate(s = \"racecaracecaracecar\") == \"racecaracecar\"\n assert candidate(s = \"abcdeedcbaedcbaedcba\") == \"a\"\n assert candidate(s = \"racecaracecaracecarace\") == \"racecaracecarace\"\n assert candidate(s = \"ababababababababababababa\") == \"abababababababababababa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"racecaracecaracecaracecaracecarace\") == \"racecaracecaracecaracecarace\"\n assert candidate(s = \"aaaaaabaaaaaab\") == \"aaaaaab\"\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxy\") == \"xyxyxyxyxyxyxyxyxy\"\n assert candidate(s = \"xyxxyxyxyxxyx\") == \"xyxxyx\"\n assert candidate(s = \"zazazazazazaza\") == \"zazazazazaza\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyz\"\n assert candidate(s = \"aabbccddeeffggaabbccddeeffgg\") == \"aabbccddeeffgg\"\n assert candidate(s = \"abcdabcabc\") == \"abc\"\n assert candidate(s = \"aaaaaaaaaab\") == \"\"\n assert candidate(s = \"aaaaaaabaaaaaaaa\") == \"aaaaaaa\"\n assert candidate(s = \"mnopqrstuvutsrqponm\") == \"m\"\n assert candidate(s = \"ababababc\") == \"\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcdefgabcdefg\") == \"abcdefg\"\n assert candidate(s = \"abcdabcabcabcd\") == \"abcd\"\n assert candidate(s = \"abcdeabcdeabcdeabcde\") == \"abcdeabcdeabcde\"\n assert candidate(s = \"aaaaaaabcabcabc\") == \"\"\n assert candidate(s = \"abcdabcdabcdabcdabcda\") == \"abcdabcdabcdabcda\"\n assert candidate(s = \"abcdabcabcabc\") == \"abc\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"\"\n assert candidate(s = \"aaaaaaaaaabaaaaaaaaaa\") == \"aaaaaaaaaa\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabad\") == \"abacabadabacabadabacabadabacabadabacabad\"\n assert candidate(s = \"aabbccddeeffaabbccddeeff\") == \"aabbccddeeff\"\n assert candidate(s = \"aaaaaabaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abcdabcabcabcabcabcabcabcabc\") == \"abc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcd\") == \"\"\n assert candidate(s = \"abcabcabcabcabcabcabcab\") == \"abcabcabcabcabcabcab\"\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababababababab\") == \"abababababababababababababababababababababababababababababababababababababab\"\n assert candidate(s = \"aabbaabbaabbaabbaabb\") == \"aabbaabbaabbaabb\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcd\") == \"abcdabcdabcdabcdabcdabcdabcdabcd\"\n assert candidate(s = \"bananaananabananaananaba\") == \"bananaananaba\"\n assert candidate(s = \"aabaaabaabaaabaab\") == \"aabaaabaab\"\n assert candidate(s = \"abcdefghijkllkjihgfedcba\") == \"a\"\n assert candidate(s = \"aabaaab\") == \"aab\"\n assert candidate(s = \"aaaaaaabaaaaaa\") == \"aaaaaa\"\n assert candidate(s = \"abcdeabcdeabcde\") == \"abcdeabcde\"\n assert candidate(s = \"abcdabcabcde\") == \"\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"zxyxzyxyzxyxzyxzyz\") == \"z\"\n assert candidate(s = \"ababababab\") == \"abababab\"\n assert candidate(s = \"abababababababababababab\") == \"ababababababababababab\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyzxyzxyz\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\") == \"abcdabcdabcdabcdabcdabcdabcd\"\n assert candidate(s = \"axbyczdxcyzbyxa\") == \"a\"\n assert candidate(s = \"abcdefgabcdefgabcdefg\") == \"abcdefgabcdefg\"\n assert candidate(s = \"abcxyzabcxyzabcxyz\") == \"abcxyzabcxyz\"\n assert candidate(s = \"abcdefghihgfedcba\") == \"a\"\n assert candidate(s = \"racecar\") == \"r\"\n assert candidate(s = \"abcdefghijabcdefghij\") == \"abcdefghij\"\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\") == \"ababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\"\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabc\"\n assert candidate(s = \"bananaabanana\") == \"banana\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"aabaaabaabaaabaabaab\") == \"aab\"\n assert candidate(s = \"ababcabcababc\") == \"ababc\"\n assert candidate(s = \"abababcabababc\") == \"abababc\"\n assert candidate(s = \"abcabcabcabcabc\") == \"abcabcabcabc\"\n assert candidate(s = \"abracadabracadabrac\") == \"abracadabrac\"\n assert candidate(s = \"ababababababababababababababababababab\") == \"abababababababababababababababababab\"\n assert candidate(s = \"xyzxyzyzyzxzyzyzyzyzyz\") == \"\"\n assert candidate(s = \"papapapapapap\") == \"papapapapap\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().longestPrefix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def longestPrefix(self, s: str) -> str:", "container": "Solution", "callable": "longestPrefix", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1394, "task_id": "find-lucky-integer-in-an-array", "difficulty": "Easy", "problem_description": "Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value.\nReturn the largest lucky integer in the array. If there is no lucky integer return -1.\n \nExample 1:\n\nInput: arr = [2,2,3,4]\nOutput: 2\nExplanation: The only lucky number in the array is 2 because frequency[2] == 2.\n\nExample 2:\n\nInput: arr = [1,2,2,3,3,3]\nOutput: 3\nExplanation: 1, 2 and 3 are all lucky numbers, return the largest of them.\n\nExample 3:\n\nInput: arr = [2,2,2,3,3]\nOutput: -1\nExplanation: There are no lucky numbers in the array.\n\n \nConstraints:\n\n1 <= arr.length <= 500\n1 <= arr[i] <= 500\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 1]) == -1\n assert candidate(arr = [5, 5, 4, 4, 4]) == -1\n assert candidate(arr = [5]) == -1\n assert candidate(arr = [5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [2, 2, 3, 4]) == 2\n assert candidate(arr = [300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300]) == -1\n assert candidate(arr = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == -1\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(arr = [4, 4, 4, 4]) == 4\n assert candidate(arr = [2, 2, 2, 3, 3]) == -1\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4]) == -1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(arr = [6, 6, 6, 6, 6, 6]) == 6\n assert candidate(arr = [3, 3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [1, 2, 2, 3, 3, 3]) == 3\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == -1\n assert candidate(arr = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == -1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == -1\n assert candidate(arr = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == -1\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == -1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == -1\n assert candidate(arr = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == -1\n assert candidate(arr = [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400]) == -1\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == -1\n assert candidate(arr = [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == -1\n assert candidate(arr = [200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200]) == -1\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == -1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == -1\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == -1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == -1\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == -1\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == -1\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == -1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == -1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 6\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().findLucky", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findLucky(self, arr: list[int]) -> int:", "container": "Solution", "callable": "findLucky", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1395, "task_id": "count-number-of-teams", "difficulty": "Medium", "problem_description": "There are n soldiers standing in a line. Each soldier is assigned a unique rating value.\nYou have to form a team of 3 soldiers amongst them under the following rules:\n\nChoose 3 soldiers with index (i, j, k) with rating (rating[i], rating[j], rating[k]).\nA team is valid if: (rating[i] < rating[j] < rating[k]) or (rating[i] > rating[j] > rating[k]) where (0 <= i < j < k < n).\n\nReturn the number of teams you can form given the conditions. (soldiers can be part of multiple teams).\n \nExample 1:\n\nInput: rating = [2,5,3,4,1]\nOutput: 3\nExplanation: We can form three teams given the conditions. (2,3,4), (5,4,1), (5,3,1). \n\nExample 2:\n\nInput: rating = [2,1,3]\nOutput: 0\nExplanation: We can't form any team given the conditions.\n\nExample 3:\n\nInput: rating = [1,2,3,4]\nOutput: 4\n\n \nConstraints:\n\nn == rating.length\n3 <= n <= 1000\n1 <= rating[i] <= 105\nAll the integers in rating are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rating = [2, 1, 3]) == 0\n assert candidate(rating = [3, 1, 2, 5, 4]) == 2\n assert candidate(rating = [1, 5, 2, 4, 3]) == 3\n assert candidate(rating = [10, 6, 5, 8]) == 1\n assert candidate(rating = [5, 4, 3, 2, 1]) == 10\n assert candidate(rating = [7, 9, 1, 10, 4, 8]) == 2\n assert candidate(rating = [5, 3, 2, 1, 4]) == 4\n assert candidate(rating = [5, 3, 1, 2, 4]) == 3\n assert candidate(rating = [3, 6, 7, 5, 10, 8]) == 9\n assert candidate(rating = [2, 5, 3, 4, 1]) == 3\n assert candidate(rating = [6, 3, 8, 1, 2, 9, 7]) == 6\n assert candidate(rating = [1, 3, 2, 4, 5]) == 7\n assert candidate(rating = [6, 9, 1, 3, 5, 7, 8, 2, 4]) == 23\n assert candidate(rating = [100, 200, 300, 400, 500]) == 10\n assert candidate(rating = [3, 2, 1, 5, 4]) == 1\n assert candidate(rating = [1, 2, 3, 4]) == 4\n assert candidate(rating = [5, 1, 4, 2, 3]) == 3\n assert candidate(rating = [100, 200, 150, 300, 250, 400, 350]) == 20\n assert candidate(rating = [4, 1, 5, 3, 2, 7, 6, 8, 10, 9]) == 66\n assert candidate(rating = [1, 5, 2, 6, 3, 7, 4, 8, 9]) == 50\n assert candidate(rating = [3, 6, 1, 5, 9, 2, 8, 4, 7, 10]) == 41\n assert candidate(rating = [5, 3, 8, 1, 7, 2, 6, 4]) == 9\n assert candidate(rating = [1, 5, 3, 7, 9, 2, 4, 8, 6, 10]) == 50\n assert candidate(rating = [7, 1, 3, 5, 9, 6, 2, 8, 4]) == 24\n assert candidate(rating = [9, 5, 7, 3, 8, 1, 6, 4, 2, 10]) == 41\n assert candidate(rating = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 455\n assert candidate(rating = [100, 200, 150, 250, 300, 10, 50, 350]) == 19\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1140\n assert candidate(rating = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 120\n assert candidate(rating = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16]) == 600\n assert candidate(rating = [15, 12, 14, 11, 13, 10, 16, 17, 9, 8, 7, 6]) == 122\n assert candidate(rating = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 88\n assert candidate(rating = [50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 60, 70, 80, 90, 100, 110]) == 594\n assert candidate(rating = [50, 25, 75, 100, 60, 30, 80, 40, 90]) == 25\n assert candidate(rating = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 40\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 120\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 84\n assert candidate(rating = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 120\n assert candidate(rating = [3, 1, 2, 6, 5, 4, 9, 8, 7, 10, 12, 11, 14, 13, 15, 16, 17]) == 537\n assert candidate(rating = [23, 17, 11, 5, 29, 25, 19, 13, 31, 27, 21, 15, 33, 28, 22, 16, 35, 30, 24, 18, 37, 32, 26, 20, 39, 34, 28, 23, 41, 36, 31, 25]) == 1835\n assert candidate(rating = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 980\n assert candidate(rating = [2, 1, 3, 6, 5, 4, 8, 7, 9]) == 52\n assert candidate(rating = [3, 1, 2, 4, 6, 5]) == 9\n assert candidate(rating = [5, 7, 9, 3, 6, 2, 8, 4, 1]) == 28\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 120\n assert candidate(rating = [10, 20, 30, 40, 50, 15, 25, 35, 45, 55, 5, 1, 6, 2, 7, 3, 8, 4, 9, 11]) == 320\n assert candidate(rating = [5, 2, 1, 7, 3, 8, 4, 6, 9, 10]) == 57\n assert candidate(rating = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 50\n assert candidate(rating = [1, 5, 2, 8, 3, 7, 4, 6]) == 19\n assert candidate(rating = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 430\n assert candidate(rating = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1]) == 525\n assert candidate(rating = [2, 5, 1, 6, 3, 4]) == 3\n assert candidate(rating = [3, 1, 2, 6, 5, 4, 9, 8, 7, 10]) == 63\n assert candidate(rating = [1, 3, 2, 4, 6, 5, 8, 7, 10, 9, 12, 11]) == 170\n assert candidate(rating = [5, 3, 1, 7, 9, 6, 10, 2, 4, 8]) == 30\n assert candidate(rating = [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]) == 570\n assert candidate(rating = [15, 25, 10, 20, 5, 30, 35, 50, 45, 40]) == 57\n assert candidate(rating = [5, 1, 2, 4, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 398\n assert candidate(rating = [5, 1, 6, 2, 7, 3, 8, 4, 9, 10]) == 60\n assert candidate(rating = [50, 1, 51, 2, 52, 3, 53, 4, 54, 5]) == 40\n assert candidate(rating = [8, 1, 2, 7, 4, 3, 6, 5]) == 21\n assert candidate(rating = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 60\n assert candidate(rating = [3, 1, 5, 2, 8, 4, 6, 7, 9, 10]) == 71\n assert candidate(rating = [10, 15, 20, 25, 30, 5, 12, 18, 24, 35]) == 44\n assert candidate(rating = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15]) == 239\n assert candidate(rating = [2, 10, 4, 3, 8, 1, 6, 5]) == 15\n assert candidate(rating = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 84\n assert candidate(rating = [15, 18, 12, 19, 21, 14, 22, 20, 23, 24, 25]) == 104\n assert candidate(rating = [7, 6, 9, 10, 5, 8, 2, 1, 4, 3]) == 43\n assert candidate(rating = [25, 20, 30, 10, 40, 50, 15, 25, 35, 45]) == 33\n assert candidate(rating = [5, 2, 8, 3, 1, 9, 4, 6, 7]) == 20\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 455\n assert candidate(rating = [100, 101, 99, 98, 102, 103, 97, 96, 104, 105, 95, 94]) == 98\n assert candidate(rating = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 120\n assert candidate(rating = [5, 50, 15, 40, 25, 35, 10, 20, 30, 45]) == 47\n assert candidate(rating = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 21, 22, 23, 24, 25]) == 1350\n assert candidate(rating = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 120\n assert candidate(rating = [5, 3, 7, 1, 9, 4, 6, 8, 2, 10, 11]) == 67\n assert candidate(rating = [20, 50, 40, 60, 10, 70, 30]) == 9\n assert candidate(rating = [20, 30, 10, 40, 50, 15, 25, 35, 45, 5]) == 36\n assert candidate(rating = [30, 20, 10, 50, 40, 60, 80, 70]) == 29\n assert candidate(rating = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 455\n assert candidate(rating = [9, 6, 7, 3, 8, 2, 5, 4, 10, 1]) == 47\n assert candidate(rating = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 120\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 455\n assert candidate(rating = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 84\n assert candidate(rating = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 50\n assert candidate(rating = [8, 1, 2, 3, 4, 5, 6, 7]) == 35\n assert candidate(rating = [5, 3, 7, 1, 9, 2, 8, 4, 6, 10]) == 34\n assert candidate(rating = [1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8]) == 203\n assert candidate(rating = [1, 3, 5, 2, 4, 6, 7]) == 22\n assert candidate(rating = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 444\n assert candidate(rating = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 120\n assert candidate(rating = [2, 1, 3, 6, 5, 7, 4, 8, 9, 10]) == 85\n assert candidate(rating = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 84\n assert candidate(rating = [8, 5, 12, 9, 15, 6, 13, 7, 14, 4, 11, 3, 10, 2, 1]) == 179\n assert candidate(rating = [7, 6, 5, 4, 3, 2, 1]) == 35\n assert candidate(rating = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 978\n assert candidate(rating = [10, 20, 30, 15, 25, 35, 5, 12, 18, 28, 50]) == 56\n assert candidate(rating = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 70\n assert candidate(rating = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7]) == 881\n assert candidate(rating = [1, 2, 10, 4, 3, 8, 7, 9, 6, 5]) == 50\n assert candidate(rating = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115]) == 560\n assert candidate(rating = [1, 9, 3, 6, 5, 8, 4, 7, 2]) == 32\n assert candidate(rating = [7, 8, 9, 1, 2, 3, 4, 5, 6]) == 21\n assert candidate(rating = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15]) == 355\n assert candidate(rating = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 444\n assert candidate(rating = [1, 2, 3, 5, 4, 6, 8, 7, 9, 10]) == 104\n assert candidate(rating = [50, 25, 75, 10, 40, 60, 90, 5, 30, 65, 80, 100, 15, 45, 70, 85, 95]) == 238\n assert candidate(rating = [1, 3, 5, 7, 9, 11, 13]) == 35\n assert candidate(rating = [13, 11, 9, 7, 5, 3, 1]) == 35\n assert candidate(rating = [9, 5, 3, 7, 2, 8, 1, 6, 4, 10]) == 37\n assert candidate(rating = [20, 18, 19, 15, 17, 13, 16, 12, 14, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1036\n assert candidate(rating = [100, 200, 150, 300, 50, 400, 250, 350, 10, 20]) == 35\n"}, "metadata": {"canonical_parameter_names": ["rating"], "leetcode_dataset_entry_point": "Solution().numTeams", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numTeams(self, rating: list[int]) -> int:", "container": "Solution", "callable": "numTeams", "parameters": [{"name": "rating", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1397, "task_id": "find-all-good-strings", "difficulty": "Hard", "problem_description": "Given the strings s1 and s2 of size n and the string evil, return the number of good strings.\nA good string has size n, it is alphabetically greater than or equal to s1, it is alphabetically smaller than or equal to s2, and it does not contain the string evil as a substring. Since the answer can be a huge number, return this modulo 109 + 7.\n \nExample 1:\n\nInput: n = 2, s1 = \"aa\", s2 = \"da\", evil = \"b\"\nOutput: 51 \nExplanation: There are 25 good strings starting with 'a': \"aa\",\"ac\",\"ad\",...,\"az\". Then there are 25 good strings starting with 'c': \"ca\",\"cc\",\"cd\",...,\"cz\" and finally there is one good string starting with 'd': \"da\". \n\nExample 2:\n\nInput: n = 8, s1 = \"leetcode\", s2 = \"leetgoes\", evil = \"leet\"\nOutput: 0 \nExplanation: All strings greater than or equal to s1 and smaller than or equal to s2 start with the prefix \"leet\", therefore, there is not any good string.\n\nExample 3:\n\nInput: n = 2, s1 = \"gx\", s2 = \"gz\", evil = \"x\"\nOutput: 2\n\n \nConstraints:\n\ns1.length == n\ns2.length == n\ns1 <= s2\n1 <= n <= 500\n1 <= evil.length <= 50\nAll strings consist of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,s1 = \"apple\",s2 = \"zebra\",evil = \"app\") == 11220078\n assert candidate(n = 5,s1 = \"apple\",s2 = \"appla\",evil = \"appl\") == 0\n assert candidate(n = 3,s1 = \"aaa\",s2 = \"zzz\",evil = \"abc\") == 17575\n assert candidate(n = 5,s1 = \"aaaaa\",s2 = \"zzzzz\",evil = \"abc\") == 11879348\n assert candidate(n = 10,s1 = \"abcdefghij\",s2 = \"abcdefghij\",evil = \"ghij\") == 0\n assert candidate(n = 5,s1 = \"apple\",s2 = \"zebra\",evil = \"dog\") == 11219789\n assert candidate(n = 2,s1 = \"gx\",s2 = \"gz\",evil = \"x\") == 2\n assert candidate(n = 3,s1 = \"abc\",s2 = \"xyz\",evil = \"def\") == 16169\n assert candidate(n = 8,s1 = \"leetcode\",s2 = \"leetgoes\",evil = \"leet\") == 0\n assert candidate(n = 3,s1 = \"aaa\",s2 = \"zzz\",evil = \"xyz\") == 17575\n assert candidate(n = 2,s1 = \"aa\",s2 = \"da\",evil = \"b\") == 51\n assert candidate(n = 3,s1 = \"abc\",s2 = \"xyz\",evil = \"de\") == 16120\n assert candidate(n = 10,s1 = \"aaaaaaaaaa\",s2 = \"zzzzzzzzzz\",evil = \"mnop\") == 932258852\n assert candidate(n = 10,s1 = \"abcdefghij\",s2 = \"zzzzzzzzzz\",evil = \"mnop\") == 67339166\n assert candidate(n = 25,s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"abcdefghijklmnopqrstuvwxyz\",evil = \"abcde\") == 0\n assert candidate(n = 45,s1 = \"abcdefghijklmnopqrstuvwxyzabcdefghij\",s2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",evil = \"mnopqr\") == 720631236\n assert candidate(n = 6,s1 = \"aaaaaa\",s2 = \"zzzzzz\",evil = \"ab\") == 306634951\n assert candidate(n = 20,s1 = \"aaabaaabaaabaaabaa\",s2 = \"zzzzzzzzzzzzzzzzzzzz\",evil = \"aaa\") == 357553640\n assert candidate(n = 35,s1 = \"applepieapplepieapplepieapplepie\",s2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",evil = \"apple\") == 695022504\n assert candidate(n = 7,s1 = \"aaaaaaa\",s2 = \"zzzzzzz\",evil = \"abc\") == 29525318\n assert candidate(n = 20,s1 = \"abcdabcdabcdabcdabcd\",s2 = \"zzzzzzzzzzzzzzzzzzzz\",evil = \"zabcd\") == 426896930\n assert candidate(n = 10,s1 = \"abcdefghij\",s2 = \"abcdefghiz\",evil = \"ghi\") == 0\n assert candidate(n = 15,s1 = \"abcdefghijklnmop\",s2 = \"abcdefghijklnmopqrstuvwxyz\",evil = \"mnop\") == 1\n assert candidate(n = 30,s1 = \"abcdefghijklmnopqrstuvwxyzabcde\",s2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",evil = \"vwxyz\") == 858527385\n assert candidate(n = 50,s1 = \"leetcodeleetcodeleetcodeleetcodeleetcode\",s2 = \"leetgoesleetgoesleetgoesleetgoesleetgoes\",evil = \"leet\") == 0\n assert candidate(n = 40,s1 = \"aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxxyyyzzz\",s2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",evil = \"mnopqr\") == 438601268\n assert candidate(n = 10,s1 = \"abcdefghij\",s2 = \"zjklmnopqr\",evil = \"mnop\") == 922212598\n assert candidate(n = 40,s1 = \"abcdefghijabcdefghijabcdefghijabcdefghij\",s2 = \"zjklmnopqrzjklmnopqrzjklmnopqrzjklmnopqr\",evil = \"mnopqr\") == 54391096\n assert candidate(n = 5,s1 = \"aaaaa\",s2 = \"zzzzz\",evil = \"b\") == 9765625\n"}, "metadata": {"canonical_parameter_names": ["n", "s1", "s2", "evil"], "leetcode_dataset_entry_point": "Solution().findGoodStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findGoodStrings(self, n: int, s1: str, s2: str, evil: str) -> int:", "container": "Solution", "callable": "findGoodStrings", "parameters": [{"name": "n", "type": "int"}, {"name": "s1", "type": "str"}, {"name": "s2", "type": "str"}, {"name": "evil", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1399, "task_id": "count-largest-group", "difficulty": "Easy", "problem_description": "You are given an integer n.\nEach number from 1 to n is grouped according to the sum of its digits.\nReturn the number of groups that have the largest size.\n \nExample 1:\n\nInput: n = 13\nOutput: 4\nExplanation: There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13:\n[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9].\nThere are 4 groups with largest size.\n\nExample 2:\n\nInput: n = 2\nOutput: 2\nExplanation: There are 2 groups [1], [2] of size 1.\n\n \nConstraints:\n\n1 <= n <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 200) == 2\n assert candidate(n = 10000) == 1\n assert candidate(n = 9) == 9\n assert candidate(n = 104) == 1\n assert candidate(n = 9999) == 1\n assert candidate(n = 2) == 2\n assert candidate(n = 100) == 1\n assert candidate(n = 1000) == 2\n assert candidate(n = 13) == 4\n assert candidate(n = 25) == 6\n assert candidate(n = 4000) == 1\n assert candidate(n = 2345) == 1\n assert candidate(n = 1111) == 1\n assert candidate(n = 7000) == 2\n assert candidate(n = 4096) == 1\n assert candidate(n = 7500) == 1\n assert candidate(n = 4567) == 1\n assert candidate(n = 2000) == 1\n assert candidate(n = 111) == 1\n assert candidate(n = 8888) == 1\n assert candidate(n = 300) == 1\n assert candidate(n = 333) == 2\n assert candidate(n = 3000) == 2\n assert candidate(n = 99) == 1\n assert candidate(n = 888) == 1\n assert candidate(n = 1024) == 2\n assert candidate(n = 8192) == 1\n assert candidate(n = 999) == 2\n assert candidate(n = 5555) == 1\n assert candidate(n = 8000) == 1\n assert candidate(n = 5000) == 2\n assert candidate(n = 6543) == 1\n assert candidate(n = 7865) == 1\n assert candidate(n = 7777) == 1\n assert candidate(n = 2222) == 1\n assert candidate(n = 2500) == 1\n assert candidate(n = 9000) == 2\n assert candidate(n = 4999) == 2\n assert candidate(n = 3999) == 1\n assert candidate(n = 1234) == 1\n assert candidate(n = 6000) == 1\n assert candidate(n = 1) == 1\n assert candidate(n = 500) == 1\n assert candidate(n = 10) == 1\n assert candidate(n = 1500) == 1\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countLargestGroup", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countLargestGroup(self, n: int) -> int:", "container": "Solution", "callable": "countLargestGroup", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1400, "task_id": "construct-k-palindrome-strings", "difficulty": "Medium", "problem_description": "Given a string s and an integer k, return true if you can use all the characters in s to construct non-empty k palindrome strings or false otherwise.\n \nExample 1:\n\nInput: s = \"annabelle\", k = 2\nOutput: true\nExplanation: You can construct two palindromes using all characters in s.\nSome possible constructions \"anna\" + \"elble\", \"anbna\" + \"elle\", \"anellena\" + \"b\"\n\nExample 2:\n\nInput: s = \"leetcode\", k = 3\nOutput: false\nExplanation: It is impossible to construct 3 palindromes using all the characters of s.\n\nExample 3:\n\nInput: s = \"true\", k = 4\nOutput: true\nExplanation: The only possible solution is to put each character in a separate string.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of lowercase English letters.\n1 <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"a\",k = 2) == False\n assert candidate(s = \"aabbcc\",k = 3) == True\n assert candidate(s = \"abcd\",k = 2) == False\n assert candidate(s = \"yzyzyzyzyzyzyzy\",k = 17) == False\n assert candidate(s = \"\",k = 0) == True\n assert candidate(s = \"true\",k = 4) == True\n assert candidate(s = \"aaaaa\",k = 2) == True\n assert candidate(s = \"racecar\",k = 1) == True\n assert candidate(s = \"abcd\",k = 1) == False\n assert candidate(s = \"abacabadabacaba\",k = 7) == True\n assert candidate(s = \"yzyzyzyzyzyzyzy\",k = 2) == True\n assert candidate(s = \"aabbcc\",k = 6) == True\n assert candidate(s = \"annabelle\",k = 2) == True\n assert candidate(s = \"aabbc\",k = 4) == True\n assert candidate(s = \"leetcode\",k = 3) == False\n assert candidate(s = \"aabbccddeeffgghh\",k = 8) == True\n assert candidate(s = \"aaa\",k = 3) == True\n assert candidate(s = \"z\",k = 1) == True\n assert candidate(s = \"abcabcabc\",k = 3) == True\n assert candidate(s = \"aaaaaa\",k = 1) == True\n assert candidate(s = \"a\",k = 1) == True\n assert candidate(s = \"aabb\",k = 2) == True\n assert candidate(s = \"aabbcc\",k = 1) == True\n assert candidate(s = \"abcd\",k = 4) == True\n assert candidate(s = \"aabbc\",k = 3) == True\n assert candidate(s = \"palindrome\",k = 2) == False\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 50) == True\n assert candidate(s = \"mississippi\",k = 4) == True\n assert candidate(s = \"abacabadabacabadabacabad\",k = 10) == True\n assert candidate(s = \"racecar\",k = 5) == True\n assert candidate(s = \"aaabbbccc\",k = 5) == True\n assert candidate(s = \"zyxzyxzyx\",k = 3) == True\n assert candidate(s = \"palindromicracecar\",k = 7) == False\n assert candidate(s = \"level\",k = 1) == True\n assert candidate(s = \"mamad\",k = 3) == True\n assert candidate(s = \"ababababab\",k = 5) == True\n assert candidate(s = \"amanaplanacanalpanama\",k = 13) == True\n assert candidate(s = \"aabbccddeeffgg\",k = 8) == True\n assert candidate(s = \"aabbccddeeffgghhiijj\",k = 10) == True\n assert candidate(s = \"aabaaaacaabbaaaacaaba\",k = 15) == True\n assert candidate(s = \"aabbccddeeefff\",k = 6) == True\n assert candidate(s = \"abcdefghij\",k = 10) == True\n assert candidate(s = \"aabaaa\",k = 3) == True\n assert candidate(s = \"xyxxyxyxyxyxyx\",k = 7) == True\n assert candidate(s = \"palindrome\",k = 5) == False\n assert candidate(s = \"racecarannakayak\",k = 5) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 20) == True\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\",k = 16) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == True\n assert candidate(s = \"noonnoonnoon\",k = 3) == True\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababab\",k = 100) == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 26) == True\n assert candidate(s = \"bananaananabananaananabanana\",k = 12) == True\n assert candidate(s = \"mississippi\",k = 5) == True\n assert candidate(s = \"neupq\",k = 5) == True\n assert candidate(s = \"babbabababababa\",k = 11) == True\n assert candidate(s = \"abcabcabcabcabcabc\",k = 9) == True\n assert candidate(s = \"aaaaaaaaaa\",k = 10) == True\n assert candidate(s = \"noonnoonnoon\",k = 6) == True\n assert candidate(s = \"racecarannakayak\",k = 3) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 52) == True\n assert candidate(s = \"abcabcabc\",k = 9) == True\n assert candidate(s = \"banana\",k = 3) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 10) == True\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",k = 26) == True\n assert candidate(s = \"thisisaverylongstringwithvariouscharacters\",k = 20) == True\n assert candidate(s = \"noon\",k = 2) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 1) == True\n assert candidate(s = \"palindrome\",k = 6) == False\n assert candidate(s = \"mississippiissim\",k = 6) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 100) == False\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == True\n assert candidate(s = \"abcdabcdeabcdabcdef\",k = 7) == True\n assert candidate(s = \"abababababababababababababab\",k = 12) == True\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 20) == True\n assert candidate(s = \"abcdabcdabcdabcd\",k = 8) == True\n assert candidate(s = \"aabbccccddeeeeffff\",k = 7) == True\n assert candidate(s = \"xyzzycba\",k = 6) == True\n assert candidate(s = \"aabbccddeeffgg\",k = 14) == True\n assert candidate(s = \"noonmoon\",k = 2) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 30) == True\n assert candidate(s = \"racecarr\",k = 2) == True\n assert candidate(s = \"aabaaabbbbccccddddd\",k = 11) == True\n assert candidate(s = \"zzzzzzyyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihhhgggffeeddccbbaa\",k = 26) == True\n assert candidate(s = \"abracadabra\",k = 5) == True\n assert candidate(s = \"abababababababababababababababababababababab\",k = 20) == True\n assert candidate(s = \"mammamia\",k = 2) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 100) == False\n assert candidate(s = \"zyxzyxzyxzyx\",k = 12) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == False\n assert candidate(s = \"abcdabcdbabcdbcdbabcdabcdabcd\",k = 10) == True\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",k = 26) == True\n assert candidate(s = \"aaabbbcccdddeeefffggghhhhiiiiiijjjjjjjkkkkkkkkkllllllllll\",k = 25) == True\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",k = 10) == True\n assert candidate(s = \"thisisaverylongstringwithsomerepeatedcharacters\",k = 15) == True\n assert candidate(s = \"aabbbccccdddddeeeeeffffffgggggghhhhhiiiiijjjjjkkkkklllllm\",k = 14) == True\n assert candidate(s = \"xyzxyzxyz\",k = 9) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 26) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaaa\",k = 27) == True\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 26) == True\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().canConstruct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canConstruct(self, s: str, k: int) -> bool:", "container": "Solution", "callable": "canConstruct", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1401, "task_id": "circle-and-rectangle-overlapping", "difficulty": "Medium", "problem_description": "You are given a circle represented as (radius, xCenter, yCenter) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.\nReturn true if the circle and rectangle are overlapped otherwise return false. In other words, check if there is any point (xi, yi) that belongs to the circle and the rectangle at the same time.\n \nExample 1:\n\n\nInput: radius = 1, xCenter = 0, yCenter = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1\nOutput: true\nExplanation: Circle and rectangle share the point (1,0).\n\nExample 2:\n\nInput: radius = 1, xCenter = 1, yCenter = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1\nOutput: false\n\nExample 3:\n\n\nInput: radius = 1, xCenter = 0, yCenter = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1\nOutput: true\n\n \nConstraints:\n\n1 <= radius <= 2000\n-104 <= xCenter, yCenter <= 104\n-104 <= x1 < x2 <= 104\n-104 <= y1 < y2 <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(radius = 3,xCenter = -3,yCenter = -4,x1 = -6,y1 = -6,x2 = -2,y2 = -2) == True\n assert candidate(radius = 2,xCenter = -2,yCenter = -2,x1 = -5,y1 = -5,x2 = -3,y2 = -3) == True\n assert candidate(radius = 5,xCenter = 0,yCenter = 0,x1 = -5,y1 = -5,x2 = 5,y2 = 5) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 1,y1 = -1,x2 = 3,y2 = 1) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = -1,y1 = 0,x2 = 0,y2 = 1) == True\n assert candidate(radius = 2,xCenter = 3,yCenter = 4,x1 = 0,y1 = 0,x2 = 2,y2 = 2) == False\n assert candidate(radius = 3,xCenter = -3,yCenter = 4,x1 = -5,y1 = 1,x2 = -1,y2 = 8) == True\n assert candidate(radius = 2,xCenter = -2,yCenter = -2,x1 = -4,y1 = -4,x2 = 0,y2 = 0) == True\n assert candidate(radius = 1,xCenter = 1,yCenter = 1,x1 = 1,y1 = -3,x2 = 2,y2 = -1) == False\n assert candidate(radius = 5,xCenter = 5,yCenter = 5,x1 = 0,y1 = 0,x2 = 10,y2 = 10) == True\n assert candidate(radius = 15,xCenter = -10,yCenter = -10,x1 = -20,y1 = -20,x2 = -5,y2 = -5) == True\n assert candidate(radius = 8,xCenter = -20,yCenter = -20,x1 = -25,y1 = -25,x2 = -15,y2 = -15) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = -1,y1 = -1,x2 = 1,y2 = 1) == True\n assert candidate(radius = 25,xCenter = -30,yCenter = 30,x1 = -50,y1 = 10,x2 = -10,y2 = 50) == True\n assert candidate(radius = 100,xCenter = 1000,yCenter = 1000,x1 = 900,y1 = 900,x2 = 1050,y2 = 1050) == True\n assert candidate(radius = 4,xCenter = 1,yCenter = 1,x1 = -2,y1 = -2,x2 = 2,y2 = 2) == True\n assert candidate(radius = 3,xCenter = 0,yCenter = 0,x1 = -3,y1 = -3,x2 = 3,y2 = 3) == True\n assert candidate(radius = 1,xCenter = 10,yCenter = 10,x1 = 11,y1 = 11,x2 = 13,y2 = 13) == False\n assert candidate(radius = 1,xCenter = -4,yCenter = -4,x1 = -5,y1 = -5,x2 = -3,y2 = -3) == True\n assert candidate(radius = 20,xCenter = 50,yCenter = 50,x1 = 20,y1 = 20,x2 = 80,y2 = 80) == True\n assert candidate(radius = 7,xCenter = 2500,yCenter = -2500,x1 = 2490,y1 = -2510,x2 = 2510,y2 = -2490) == True\n assert candidate(radius = 12,xCenter = 18,yCenter = 18,x1 = 10,y1 = 10,x2 = 26,y2 = 26) == True\n assert candidate(radius = 10,xCenter = 0,yCenter = 0,x1 = -20,y1 = -20,x2 = 20,y2 = 20) == True\n assert candidate(radius = 1,xCenter = -10000,yCenter = -10000,x1 = -10001,y1 = -10001,x2 = -9999,y2 = -9999) == True\n assert candidate(radius = 7,xCenter = 0,yCenter = 0,x1 = -8,y1 = -8,x2 = 8,y2 = 8) == True\n assert candidate(radius = 1,xCenter = 2,yCenter = 3,x1 = 1,y1 = 2,x2 = 3,y2 = 4) == True\n assert candidate(radius = 9,xCenter = 0,yCenter = -1,x1 = -5,y1 = -10,x2 = 5,y2 = -5) == True\n assert candidate(radius = 15,xCenter = 25,yCenter = -25,x1 = 15,y1 = -35,x2 = 35,y2 = -15) == True\n assert candidate(radius = 4,xCenter = 10,yCenter = 10,x1 = 5,y1 = 5,x2 = 15,y2 = 15) == True\n assert candidate(radius = 10,xCenter = -15,yCenter = -15,x1 = -25,y1 = -25,x2 = -5,y2 = -5) == True\n assert candidate(radius = 1000,xCenter = 10000,yCenter = 10000,x1 = 9999,y1 = 9999,x2 = 10001,y2 = 10001) == True\n assert candidate(radius = 2,xCenter = 3,yCenter = 4,x1 = 2,y1 = 3,x2 = 4,y2 = 5) == True\n assert candidate(radius = 1,xCenter = 5,yCenter = 0,x1 = 4,y1 = -1,x2 = 6,y2 = 1) == True\n assert candidate(radius = 12,xCenter = -200,yCenter = 200,x1 = -220,y1 = 180,x2 = -180,y2 = 220) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = -1,y1 = -1,x2 = 0,y2 = 0) == True\n assert candidate(radius = 100,xCenter = -500,yCenter = 500,x1 = -600,y1 = 400,x2 = -400,y2 = 600) == True\n assert candidate(radius = 4,xCenter = 0,yCenter = 0,x1 = 4,y1 = 4,x2 = 5,y2 = 5) == False\n assert candidate(radius = 10,xCenter = -10,yCenter = -10,x1 = -20,y1 = -20,x2 = 0,y2 = 0) == True\n assert candidate(radius = 2000,xCenter = -10000,yCenter = -10000,x1 = -10001,y1 = -10001,x2 = -9999,y2 = -9999) == True\n assert candidate(radius = 10,xCenter = 0,yCenter = 0,x1 = -5,y1 = -5,x2 = 5,y2 = 5) == True\n assert candidate(radius = 9,xCenter = 15,yCenter = 15,x1 = 10,y1 = 10,x2 = 20,y2 = 20) == True\n assert candidate(radius = 10,xCenter = 0,yCenter = 0,x1 = -10,y1 = -10,x2 = 10,y2 = 10) == True\n assert candidate(radius = 6,xCenter = -5,yCenter = 5,x1 = -10,y1 = 0,x2 = 0,y2 = 10) == True\n assert candidate(radius = 2,xCenter = 5,yCenter = 5,x1 = 3,y1 = 3,x2 = 7,y2 = 7) == True\n assert candidate(radius = 10,xCenter = 10000,yCenter = 10000,x1 = 9990,y1 = 9990,x2 = 10010,y2 = 10010) == True\n assert candidate(radius = 2000,xCenter = 0,yCenter = 0,x1 = -2001,y1 = -2001,x2 = 2001,y2 = 2001) == True\n assert candidate(radius = 3,xCenter = 10,yCenter = 10,x1 = 5,y1 = 5,x2 = 15,y2 = 15) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 2,y1 = 2,x2 = 3,y2 = 3) == False\n assert candidate(radius = 500,xCenter = 5000,yCenter = 5000,x1 = 4500,y1 = 4500,x2 = 5500,y2 = 5500) == True\n assert candidate(radius = 2,xCenter = -100,yCenter = 100,x1 = -110,y1 = 90,x2 = -90,y2 = 110) == True\n assert candidate(radius = 4,xCenter = -10,yCenter = 10,x1 = -15,y1 = 5,x2 = -5,y2 = 15) == True\n assert candidate(radius = 1,xCenter = 500,yCenter = 500,x1 = 499,y1 = 499,x2 = 501,y2 = 501) == True\n assert candidate(radius = 10,xCenter = -10000,yCenter = 10000,x1 = -10010,y1 = 9990,x2 = -9990,y2 = 10010) == True\n assert candidate(radius = 20,xCenter = 0,yCenter = 0,x1 = -30,y1 = -30,x2 = 30,y2 = 30) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = -2,y1 = -2,x2 = -1,y2 = -1) == False\n assert candidate(radius = 2,xCenter = 0,yCenter = 0,x1 = 0,y1 = 0,x2 = 4,y2 = 4) == True\n assert candidate(radius = 1,xCenter = 10000,yCenter = 10000,x1 = 9999,y1 = 9999,x2 = 10001,y2 = 10001) == True\n assert candidate(radius = 10,xCenter = 20,yCenter = 20,x1 = 15,y1 = 15,x2 = 25,y2 = 25) == True\n assert candidate(radius = 2,xCenter = -6,yCenter = -6,x1 = -10,y1 = -10,x2 = -5,y2 = -5) == True\n assert candidate(radius = 12,xCenter = 0,yCenter = 0,x1 = -10,y1 = -10,x2 = 10,y2 = 10) == True\n assert candidate(radius = 1,xCenter = -10,yCenter = -10,x1 = -13,y1 = -13,x2 = -11,y2 = -11) == False\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 1,y1 = 1,x2 = 2,y2 = 2) == False\n assert candidate(radius = 6,xCenter = -2,yCenter = 4,x1 = -6,y1 = 0,x2 = 0,y2 = 6) == True\n assert candidate(radius = 5,xCenter = 25,yCenter = 25,x1 = 20,y1 = 20,x2 = 30,y2 = 30) == True\n assert candidate(radius = 15,xCenter = 15,yCenter = 15,x1 = 20,y1 = 20,x2 = 30,y2 = 30) == True\n assert candidate(radius = 2,xCenter = -2,yCenter = -3,x1 = -4,y1 = -5,x2 = -3,y2 = -4) == True\n assert candidate(radius = 2000,xCenter = 0,yCenter = 0,x1 = -10000,y1 = -10000,x2 = 10000,y2 = 10000) == True\n assert candidate(radius = 8,xCenter = 12,yCenter = 12,x1 = 8,y1 = 8,x2 = 16,y2 = 16) == True\n assert candidate(radius = 15,xCenter = -10,yCenter = 10,x1 = -20,y1 = -10,x2 = 0,y2 = 10) == True\n assert candidate(radius = 300,xCenter = -750,yCenter = 750,x1 = -1000,y1 = 500,x2 = -500,y2 = 1000) == True\n assert candidate(radius = 3,xCenter = 20,yCenter = -20,x1 = 15,y1 = -25,x2 = 25,y2 = -15) == True\n assert candidate(radius = 15,xCenter = 50,yCenter = 50,x1 = 40,y1 = 40,x2 = 60,y2 = 60) == True\n assert candidate(radius = 2000,xCenter = 5000,yCenter = 5000,x1 = 0,y1 = 0,x2 = 10000,y2 = 10000) == True\n assert candidate(radius = 5,xCenter = 10,yCenter = 10,x1 = 5,y1 = 5,x2 = 15,y2 = 15) == True\n assert candidate(radius = 4,xCenter = -4,yCenter = -4,x1 = -6,y1 = -6,x2 = -2,y2 = -2) == True\n assert candidate(radius = 15,xCenter = 15,yCenter = 15,x1 = 10,y1 = 10,x2 = 20,y2 = 20) == True\n assert candidate(radius = 3,xCenter = -3,yCenter = 3,x1 = -6,y1 = 0,x2 = 0,y2 = 6) == True\n assert candidate(radius = 1,xCenter = 10000,yCenter = -10000,x1 = 9999,y1 = -10001,x2 = 10001,y2 = -9999) == True\n assert candidate(radius = 8,xCenter = 100,yCenter = -100,x1 = 90,y1 = -110,x2 = 110,y2 = -90) == True\n assert candidate(radius = 2000,xCenter = 0,yCenter = 0,x1 = -3000,y1 = -3000,x2 = 3000,y2 = 3000) == True\n assert candidate(radius = 10,xCenter = 5,yCenter = 5,x1 = 0,y1 = 0,x2 = 10,y2 = 10) == True\n assert candidate(radius = 1500,xCenter = 5000,yCenter = 5000,x1 = 4500,y1 = 4500,x2 = 5500,y2 = 5500) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 0,y1 = 0,x2 = 2,y2 = 2) == True\n assert candidate(radius = 7,xCenter = -5,yCenter = 5,x1 = -10,y1 = 0,x2 = -2,y2 = 10) == True\n assert candidate(radius = 4,xCenter = -5,yCenter = 5,x1 = -10,y1 = 0,x2 = 0,y2 = 10) == True\n assert candidate(radius = 10,xCenter = -5,yCenter = -5,x1 = 5,y1 = 5,x2 = 15,y2 = 15) == False\n assert candidate(radius = 500,xCenter = 2500,yCenter = -2500,x1 = 2000,y1 = -3000,x2 = 3000,y2 = -2000) == True\n assert candidate(radius = 5,xCenter = 1,yCenter = 1,x1 = -3,y1 = -3,x2 = 3,y2 = 3) == True\n assert candidate(radius = 2000,xCenter = 1000,yCenter = 1000,x1 = 900,y1 = 900,x2 = 1100,y2 = 1100) == True\n assert candidate(radius = 150,xCenter = 0,yCenter = 0,x1 = -200,y1 = -200,x2 = 200,y2 = 200) == True\n assert candidate(radius = 6,xCenter = -15,yCenter = -15,x1 = -20,y1 = -20,x2 = -10,y2 = -10) == True\n assert candidate(radius = 4,xCenter = 2,yCenter = 2,x1 = -1,y1 = -1,x2 = 3,y2 = 3) == True\n assert candidate(radius = 2,xCenter = 100,yCenter = 100,x1 = 101,y1 = 101,x2 = 103,y2 = 103) == True\n assert candidate(radius = 3,xCenter = 5,yCenter = 5,x1 = 8,y1 = 8,x2 = 12,y2 = 12) == False\n assert candidate(radius = 5,xCenter = -10,yCenter = -10,x1 = -15,y1 = -15,x2 = -5,y2 = -5) == True\n assert candidate(radius = 2,xCenter = 2,yCenter = 2,x1 = 1,y1 = 1,x2 = 3,y2 = 3) == True\n assert candidate(radius = 1,xCenter = 2,yCenter = 2,x1 = 3,y1 = 3,x2 = 5,y2 = 5) == False\n assert candidate(radius = 2,xCenter = -5,yCenter = -5,x1 = -10,y1 = -10,x2 = -2,y2 = -2) == True\n assert candidate(radius = 7,xCenter = -5,yCenter = -5,x1 = -10,y1 = -10,x2 = -2,y2 = -2) == True\n assert candidate(radius = 15,xCenter = -100,yCenter = -100,x1 = -120,y1 = -120,x2 = -80,y2 = -80) == True\n assert candidate(radius = 8,xCenter = 10,yCenter = -10,x1 = 5,y1 = -15,x2 = 15,y2 = -5) == True\n assert candidate(radius = 20,xCenter = -30,yCenter = 30,x1 = -40,y1 = 20,x2 = -20,y2 = 40) == True\n assert candidate(radius = 5,xCenter = -10000,yCenter = 10000,x1 = -10010,y1 = 9990,x2 = -9990,y2 = 10010) == True\n assert candidate(radius = 2,xCenter = 6,yCenter = 6,x1 = 0,y1 = 0,x2 = 5,y2 = 5) == True\n assert candidate(radius = 15,xCenter = -10,yCenter = 10,x1 = -20,y1 = -20,x2 = 0,y2 = 0) == True\n assert candidate(radius = 7,xCenter = 5,yCenter = -5,x1 = 0,y1 = -10,x2 = 10,y2 = 0) == True\n assert candidate(radius = 2,xCenter = 0,yCenter = 0,x1 = -3,y1 = -3,x2 = -2,y2 = -2) == False\n assert candidate(radius = 7,xCenter = 3,yCenter = -3,x1 = 1,y1 = -5,x2 = 5,y2 = -1) == True\n assert candidate(radius = 5,xCenter = 0,yCenter = 0,x1 = -10,y1 = -10,x2 = 10,y2 = 10) == True\n assert candidate(radius = 10,xCenter = 0,yCenter = 0,x1 = -15,y1 = -15,x2 = 15,y2 = 15) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 1,y1 = 0,x2 = 2,y2 = 1) == True\n assert candidate(radius = 2000,xCenter = -5000,yCenter = -5000,x1 = -10000,y1 = -10000,x2 = 0,y2 = 0) == True\n assert candidate(radius = 4,xCenter = 15,yCenter = 15,x1 = 10,y1 = 10,x2 = 20,y2 = 20) == True\n assert candidate(radius = 50,xCenter = -100,yCenter = 100,x1 = -150,y1 = 50,x2 = -50,y2 = 150) == True\n"}, "metadata": {"canonical_parameter_names": ["radius", "xCenter", "yCenter", "x1", "y1", "x2", "y2"], "leetcode_dataset_entry_point": "Solution().checkOverlap", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def checkOverlap(self, radius: int, xCenter: int, yCenter: int, x1: int, y1: int, x2: int, y2: int) -> bool:", "container": "Solution", "callable": "checkOverlap", "parameters": [{"name": "radius", "type": "int"}, {"name": "xCenter", "type": "int"}, {"name": "yCenter", "type": "int"}, {"name": "x1", "type": "int"}, {"name": "y1", "type": "int"}, {"name": "x2", "type": "int"}, {"name": "y2", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1402, "task_id": "reducing-dishes", "difficulty": "Hard", "problem_description": "A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time.\nLike-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. time[i] * satisfaction[i].\nReturn the maximum sum of like-time coefficient that the chef can obtain after preparing some amount of dishes.\nDishes can be prepared in any order and the chef can discard some dishes to get this maximum value.\n \nExample 1:\n\nInput: satisfaction = [-1,-8,0,5,-9]\nOutput: 14\nExplanation: After Removing the second and last dish, the maximum total like-time coefficient will be equal to (-1*1 + 0*2 + 5*3 = 14).\nEach dish is prepared in one unit of time.\nExample 2:\n\nInput: satisfaction = [4,3,2]\nOutput: 20\nExplanation: Dishes can be prepared in any order, (2*1 + 3*2 + 4*3 = 20)\n\nExample 3:\n\nInput: satisfaction = [-1,-4,-5]\nOutput: 0\nExplanation: People do not like the dishes. No dish is prepared.\n\n \nConstraints:\n\nn == satisfaction.length\n1 <= n <= 500\n-1000 <= satisfaction[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(satisfaction = [1, -1, 2, -2, 3, -3]) == 22\n assert candidate(satisfaction = [0]) == 0\n assert candidate(satisfaction = [-1]) == 0\n assert candidate(satisfaction = [-500, -500, -500, -500, -500]) == 0\n assert candidate(satisfaction = [0, 0, 0, 0, 0]) == 0\n assert candidate(satisfaction = [-1000, 1000, -500, 500]) == 3500\n assert candidate(satisfaction = [0, 0, 0, 0]) == 0\n assert candidate(satisfaction = [1000, -1000, 1000, -1000, 1000]) == 9000\n assert candidate(satisfaction = [-1, -8, 0, 5, -9]) == 14\n assert candidate(satisfaction = [-10, -20, -30, 10, 20, 30]) == 220\n assert candidate(satisfaction = [1, 2, 3, 4, 5]) == 55\n assert candidate(satisfaction = [100, 200, 300, 400, 500]) == 5500\n assert candidate(satisfaction = [-10, -20, -30, -40, -50]) == 0\n assert candidate(satisfaction = [4, 3, 2]) == 20\n assert candidate(satisfaction = [500, 500, 500, 500, 500]) == 7500\n assert candidate(satisfaction = [-1000, 1000]) == 1000\n assert candidate(satisfaction = [-1, -4, -5]) == 0\n assert candidate(satisfaction = [-5, -4, -3, -2, -1]) == 0\n assert candidate(satisfaction = [-500, -400, -300, -200, -100]) == 0\n assert candidate(satisfaction = [1000, -1000, 1000, -1000, 1000]) == 9000\n assert candidate(satisfaction = [1]) == 1\n assert candidate(satisfaction = [-1, 1, -2, 2, -3, 3]) == 22\n assert candidate(satisfaction = [1000, -1000, 1000, -1000]) == 4000\n assert candidate(satisfaction = [5, -1, 3, 2, -2, 1]) == 52\n assert candidate(satisfaction = [10, 9, 8, 7, 6, 5, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 415\n assert candidate(satisfaction = [100, -90, 50, -40, 30, -20, 10, -5, 0]) == 1320\n assert candidate(satisfaction = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 13600\n assert candidate(satisfaction = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 715\n assert candidate(satisfaction = [-500, -499, -498, -497, -496, -495, -494, -493, -492, -491, -490, -489, -488, -487, -486]) == 0\n assert candidate(satisfaction = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 155\n assert candidate(satisfaction = [999, -999, 998, -998, 997, -997, 996, -996, 995, -995]) == 24945\n assert candidate(satisfaction = [999, 1000, 998, -1000, 500, 499, 501, -499, -501, 0, 1, -1, 2, -2, 3, -3]) == 59488\n assert candidate(satisfaction = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9]) == 525\n assert candidate(satisfaction = [-1, -2, -3, 4, 5, 6, 7, 8]) == 180\n assert candidate(satisfaction = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == 110\n assert candidate(satisfaction = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, 1, 2, 3, 4, 5]) == 60\n assert candidate(satisfaction = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == 625\n assert candidate(satisfaction = [5, 4, 3, 2, 1, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == 625\n assert candidate(satisfaction = [-500, -400, -300, -200, -100, 100, 200, 300, 400, 500]) == 9500\n assert candidate(satisfaction = [-10, 0, 10, -20, 0, 20, -30, 0, 30, -40]) == 400\n assert candidate(satisfaction = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50, 60, 70, 80, 90, 100]) == 6250\n assert candidate(satisfaction = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(satisfaction = [-500, 500, -250, 250, 0, 100, -100, 150]) == 5850\n assert candidate(satisfaction = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 95\n assert candidate(satisfaction = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == 570\n assert candidate(satisfaction = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50]) == 950\n assert candidate(satisfaction = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 229460\n assert candidate(satisfaction = [-100, -200, -300, 50, 100, 150, 200, 250]) == 4000\n assert candidate(satisfaction = [50, 20, -10, 0, -30, 100, -200, 300, -400, 500]) == 8040\n assert candidate(satisfaction = [-100, -200, -300, -400, 100, 200, 300, 400, 500]) == 9500\n assert candidate(satisfaction = [-1, -2, -3, -4, -5, 0, 1, 2, 3, 4, 5]) == 110\n assert candidate(satisfaction = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486]) == 59440\n assert candidate(satisfaction = [500, -1, -2, -3, 0, 1, 2, 3, 4, 5]) == 5105\n assert candidate(satisfaction = [-999, -998, -997, -996, 999, 998, 997, 996]) == 15970\n assert candidate(satisfaction = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == 95\n assert candidate(satisfaction = [5, -5, 15, -15, 25, -25, 35, -35]) == 420\n assert candidate(satisfaction = [5, -1, 3, -2, 4, -3, 2]) == 72\n assert candidate(satisfaction = [-100, 0, 100, -200, 200, -300, 300, -400, 400, -500, 500]) == 11000\n assert candidate(satisfaction = [999, 1000, -999, -1000, 998, 997, -998, -997, 996, -996]) == 24970\n assert candidate(satisfaction = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 0\n assert candidate(satisfaction = [10, -1, 2, 5, -7, 8, -2]) == 137\n assert candidate(satisfaction = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 100\n assert candidate(satisfaction = [-5, -2, 0, 1, 3, 6]) == 46\n assert candidate(satisfaction = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, -1, -2, -3, -4, -5]) == 6565\n assert candidate(satisfaction = [-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1]) == 36\n assert candidate(satisfaction = [-500, 500, -499, 499, -498, 498, -497, 497, -496, 496]) == 12470\n assert candidate(satisfaction = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 100\n assert candidate(satisfaction = [9, -1, -2, 3, -4, 5, -6, 7, -8, 9]) == 235\n assert candidate(satisfaction = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 950\n assert candidate(satisfaction = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 625\n assert candidate(satisfaction = [-5, -3, -2, 1, 4, 6]) == 43\n assert candidate(satisfaction = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 0\n assert candidate(satisfaction = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 3850\n assert candidate(satisfaction = [900, 100, 200, -900, 50, -50, 300, -300, 400, -400]) == 14450\n assert candidate(satisfaction = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50]) == 950\n assert candidate(satisfaction = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]) == 95\n assert candidate(satisfaction = [-100, -200, -300, -400, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 385\n assert candidate(satisfaction = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]) == 161\n assert candidate(satisfaction = [-999, -998, -997, -996, -995, 995, 996, 997, 998, 999]) == 24945\n assert candidate(satisfaction = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 40\n assert candidate(satisfaction = [-1, 0, 1, -2, 0, 2, -3, 0, 3]) == 40\n assert candidate(satisfaction = [-5, -3, -1, 1, 3, 5]) == 35\n assert candidate(satisfaction = [-50, -50, 50, 50, -25, -25, 25, 25, -75, 75]) == 1375\n assert candidate(satisfaction = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 465\n assert candidate(satisfaction = [-10, -20, -30, -40, -50, 5, 15, 25, 35, 45]) == 775\n assert candidate(satisfaction = [-9, -8, -7, -6, -5, 1, 2, 3, 4, 5]) == 69\n assert candidate(satisfaction = [-100, -200, -300, 100, 200, 300, 400, 500]) == 9000\n assert candidate(satisfaction = [-1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == 295\n assert candidate(satisfaction = [-100, -90, -80, 70, 80, 90, 100]) == 1400\n assert candidate(satisfaction = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(satisfaction = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == 110\n assert candidate(satisfaction = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 385\n assert candidate(satisfaction = [50, 100, 150, 200, -10, -20, -30, -40, -50, -60]) == 3940\n assert candidate(satisfaction = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 715\n assert candidate(satisfaction = [100, 100, 100, -1, -1, -1, -1, -1, -1, -1]) == 2672\n assert candidate(satisfaction = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(satisfaction = [-1000, -999, -998, -997, -996, -995, -994, -993, -992, -991, -990, -989, -988, -987, -986, -985, -984, -983, -982, -981, -980]) == 0\n assert candidate(satisfaction = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(satisfaction = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 0\n assert candidate(satisfaction = [-1000, 1000, -999, 999, -998, 998, -997, 997, -996, 996, -995, 995, -994, 994]) == 48909\n assert candidate(satisfaction = [-1, -2, -3, 4, 5, 6]) == 67\n assert candidate(satisfaction = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16]) == 780\n assert candidate(satisfaction = [-500, 500, -400, 400, -300, 300, -200, 200, -100, 100]) == 9500\n assert candidate(satisfaction = [500, -500, 250, -250, 125, -125, 62, -62, 31, -31]) == 7092\n assert candidate(satisfaction = [-1000, -500, 0, 500, 1000, 1500, 2000]) == 28000\n assert candidate(satisfaction = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55\n assert candidate(satisfaction = [-100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100]) == 0\n assert candidate(satisfaction = [5, 1, 3, 7, -5, -3, 2, 6, -2, 4]) == 207\n assert candidate(satisfaction = [-999, -998, -997, -996, 996, 997, 998, 999]) == 15970\n assert candidate(satisfaction = [-999, 999, -998, 998, -997, 997, -996, 996, -995, 995, -994, 994, -993, 993, -992, 992]) == 63796\n assert candidate(satisfaction = [500, -500, 400, -400, 300, -300, 200, -200, 100, -100, 0]) == 11000\n assert candidate(satisfaction = [-5, -3, -1, 2, 4, 6]) == 50\n assert candidate(satisfaction = [-999, -1000, 1000, 999, -998, 998, 0, 0, 0, 0, 0]) == 23980\n assert candidate(satisfaction = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1240\n"}, "metadata": {"canonical_parameter_names": ["satisfaction"], "leetcode_dataset_entry_point": "Solution().maxSatisfaction", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxSatisfaction(self, satisfaction: list[int]) -> int:", "container": "Solution", "callable": "maxSatisfaction", "parameters": [{"name": "satisfaction", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1403, "task_id": "minimum-subsequence-in-non-increasing-order", "difficulty": "Easy", "problem_description": "Given the array nums, obtain a subsequence of the array whose sum of elements is strictly greater than the sum of the non included elements in such subsequence. \nIf there are multiple solutions, return the subsequence with minimum size and if there still exist multiple solutions, return the subsequence with the maximum total sum of all its elements. A subsequence of an array can be obtained by erasing some (possibly zero) elements from the array. \nNote that the solution with the given constraints is guaranteed to be unique. Also return the answer sorted in non-increasing order.\n \nExample 1:\n\nInput: nums = [4,3,10,9,8]\nOutput: [10,9] \nExplanation: The subsequences [10,9] and [10,8] are minimal such that the sum of their elements is strictly greater than the sum of elements not included. However, the subsequence [10,9] has the maximum total sum of its elements. \n\nExample 2:\n\nInput: nums = [4,4,7,6,7]\nOutput: [7,7,6] \nExplanation: The subsequence [7,7] has the sum of its elements equal to 14 which is not strictly greater than the sum of elements not included (14 = 4 + 4 + 6). Therefore, the subsequence [7,6,7] is the minimal satisfying the conditions. Note the subsequence has to be returned in non-increasing order. \n\n \nConstraints:\n\n1 <= nums.length <= 500\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 4, 7, 6, 7]) == [7, 7, 6]\n assert candidate(nums = [100, 90, 80, 70, 60]) == [100, 90, 80]\n assert candidate(nums = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5, 5]\n assert candidate(nums = [100, 99, 98, 97, 96]) == [100, 99, 98]\n assert candidate(nums = [4, 3, 10, 9, 8]) == [10, 9]\n assert candidate(nums = [5, 5, 5, 5, 5]) == [5, 5, 5]\n assert candidate(nums = [50, 50, 50, 50, 50]) == [50, 50, 50]\n assert candidate(nums = [5, 5, 5, 5, 5, 1]) == [5, 5, 5]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [5, 4]\n assert candidate(nums = [33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 1]) == [33, 33, 33, 33, 33, 33]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [100, 90, 80, 70]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 9, 9, 8, 8, 7]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == [99, 98, 97, 96, 95]\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == [50, 45, 40, 35]\n assert candidate(nums = [50, 20, 10, 100, 30, 60, 40, 80, 70, 90]) == [100, 90, 80, 70]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [100, 20, 19, 18]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == [1000, 1000, 1000, 1000, 1000, 1000]\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100, 50]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 500]) == [500]\n assert candidate(nums = [83, 54, 43, 21, 27, 48, 85, 96, 18, 33, 62, 59, 74, 95, 29, 72, 67, 44, 37, 52, 58, 49, 60, 88, 91, 25, 76, 87, 50, 41, 38, 94, 61, 92, 26, 34, 40, 71, 80, 63, 86, 90, 30, 77, 42, 55, 82, 57, 51, 36, 97, 84, 22, 39, 45, 56, 64, 73, 69, 81, 75, 68, 46, 70, 79, 89, 23, 53, 31, 32, 65, 35, 47, 78]) == [97, 96, 95, 94, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 19, 18, 17, 16, 15, 14]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [10, 10, 9, 9, 8, 8, 7]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == [256]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71]\n assert candidate(nums = [34, 34, 23, 23, 12, 12, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [34, 34, 23, 23]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 1]) == [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]\n assert candidate(nums = [34, 23, 12, 3, 45, 67, 89, 12, 34, 56, 78, 90, 23, 45, 67, 89]) == [90, 89, 89, 78, 67]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 90, 80, 70]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11]\n assert candidate(nums = [99, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [99, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 1, 2, 3, 4, 5]) == [100, 95, 90, 85, 80, 75, 70]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [100, 90, 80, 70]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == [99, 98, 97, 96, 95, 94, 93, 92]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [200, 190, 180, 170, 160, 150, 140]\n assert candidate(nums = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100]\n assert candidate(nums = [123, 45, 67, 89, 101, 12, 34, 56, 78, 90, 23, 45, 67, 89, 101]) == [123, 101, 101, 90, 89, 89]\n assert candidate(nums = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 1]) == [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]\n assert candidate(nums = [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]) == [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == [100, 99, 98, 97, 96, 95]\n assert candidate(nums = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [500, 400]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == [100, 99, 98, 97, 96]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2, 3, 4, 5]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [100, 100, 100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100, 100]\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 100]) == [100, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 1]) == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == [50, 49, 48, 47, 46, 45, 44, 43, 42]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [20, 19, 18, 17, 16, 15, 14]\n assert candidate(nums = [99, 100, 1, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10]) == [100, 99, 98, 97, 96, 95]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 10, 9, 9, 8, 8, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11]\n assert candidate(nums = [30, 25, 20, 15, 10, 5, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17]) == [30, 25, 20, 17, 16, 15]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minSubsequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minSubsequence(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "minSubsequence", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1404, "task_id": "number-of-steps-to-reduce-a-number-in-binary-representation-to-one", "difficulty": "Medium", "problem_description": "Given the binary representation of an integer as a string s, return the number of steps to reduce it to 1 under the following rules:\n\n\nIf the current number is even, you have to divide it by 2.\n\n\nIf the current number is odd, you have to add 1 to it.\n\n\nIt is guaranteed that you can always reach one for all test cases.\n \nExample 1:\n\nInput: s = \"1101\"\nOutput: 6\nExplanation: \"1101\" corressponds to number 13 in their decimal representation.\nStep 1) 13 is odd, add 1 and obtain 14. \nStep 2) 14 is even, divide by 2 and obtain 7.\nStep 3) 7 is odd, add 1 and obtain 8.\nStep 4) 8 is even, divide by 2 and obtain 4.  \nStep 5) 4 is even, divide by 2 and obtain 2. \nStep 6) 2 is even, divide by 2 and obtain 1.  \n\nExample 2:\n\nInput: s = \"10\"\nOutput: 1\nExplanation: \"10\" corresponds to number 2 in their decimal representation.\nStep 1) 2 is even, divide by 2 and obtain 1.  \n\nExample 3:\n\nInput: s = \"1\"\nOutput: 0\n\n \nConstraints:\n\n1 <= s.length <= 500\ns consists of characters '0' or '1'\ns[0] == '1'\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"11101110111\") == 14\n assert candidate(s = \"1111\") == 5\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101\") == 95\n assert candidate(s = \"1100110\") == 10\n assert candidate(s = \"111\") == 4\n assert candidate(s = \"10010\") == 8\n assert candidate(s = \"100000\") == 5\n assert candidate(s = \"100000000000000000000000000000000000000000000000000000000000000\") == 62\n assert candidate(s = \"1001001\") == 12\n assert candidate(s = \"1111111111\") == 11\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111111111111\") == 64\n assert candidate(s = \"1111111\") == 8\n assert candidate(s = \"1101\") == 6\n assert candidate(s = \"11011011\") == 11\n assert candidate(s = \"10\") == 1\n assert candidate(s = \"10101010\") == 12\n assert candidate(s = \"10000000000\") == 10\n assert candidate(s = \"1010101010\") == 15\n assert candidate(s = \"1\") == 0\n assert candidate(s = \"1101001\") == 11\n assert candidate(s = \"101010\") == 9\n assert candidate(s = \"1110011\") == 10\n assert candidate(s = \"1100100\") == 10\n assert candidate(s = \"110011001100110011001100110011001100110011001100110011001100110\") == 94\n assert candidate(s = \"11010\") == 7\n assert candidate(s = \"100000000000000000000000000000000\") == 32\n assert candidate(s = \"1100100100100100100100100100100100\") == 55\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001001001001001001\") == 132\n assert candidate(s = \"1011011011011011011011011011011011011011011\") == 58\n assert candidate(s = \"1000100010001\") == 23\n assert candidate(s = \"1011011011011011011011011011011011\") == 46\n assert candidate(s = \"1111111011111110111111101111111\") == 35\n assert candidate(s = \"11111111111111111111111111111111111111111\") == 42\n assert candidate(s = \"1000000000000000000000000000000\") == 30\n assert candidate(s = \"1010101010101010101\") == 29\n assert candidate(s = \"1111000011110000111100001111000\") == 44\n assert candidate(s = \"1010101010101010101010101010101\") == 47\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001\") == 107\n assert candidate(s = \"1101101101101101101101101101101101101101101\") == 58\n assert candidate(s = \"1110101010101010101010101010101\") == 46\n assert candidate(s = \"1000000000000000000000000000000000000000000000000000000000000001\") == 127\n assert candidate(s = \"11110101010101010101010101010101010101010101010101010101010101010\") == 96\n assert candidate(s = \"1101101011010110101101011010110\") == 43\n assert candidate(s = \"1010101010101010101010101010101010101010101010101\") == 74\n assert candidate(s = \"1001001001001001001001001001001001001\") == 62\n assert candidate(s = \"101010101010101010101010101010101010101010101\") == 68\n assert candidate(s = \"1110111011101110111011101110111011101110111011101110111011101110\") == 80\n assert candidate(s = \"1101101101101101101101101101101101101101101101101101101101101101\") == 86\n assert candidate(s = \"10101010101010101010101\") == 35\n assert candidate(s = \"10000000000000000000000000000000000000000000000000000000000000001\") == 129\n assert candidate(s = \"110011001100110011001100110011001100110011001100110011001100110011001100\") == 107\n assert candidate(s = \"110111011101110111011101110111011101110111011101110111011101110111011101\") == 91\n assert candidate(s = \"11110000111100001111000011110000111100001111\") == 65\n assert candidate(s = \"1001001001001001001001001001001\") == 52\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101010101\") == 107\n assert candidate(s = \"1011101010101010101010101010101\") == 46\n assert candidate(s = \"11101110111011101110111011101110111011101110111011101110111011101110111\") == 89\n assert candidate(s = \"1111111111111111111111111111111\") == 32\n assert candidate(s = \"1111000011110000111100001111000011110000111100001111000011110000\") == 93\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111\") == 80\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101\") == 98\n assert candidate(s = \"1011010110101101011010110101101011010110101101011\") == 69\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111\") == 65\n assert candidate(s = \"101010101010101010101010101010101010101\") == 59\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101\") == 86\n assert candidate(s = \"1101010101010101010101010101010\") == 46\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010\") == 108\n assert candidate(s = \"11101010101010101010101010101\") == 43\n assert candidate(s = \"1000011111111111111111111111111\") == 36\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111111111\") == 69\n assert candidate(s = \"1010000000000000000000000000000000001\") == 72\n assert candidate(s = \"1000000000000000000000000000000000000000000000000000000000000111\") == 125\n assert candidate(s = \"1011011011011011011011011011011011011011011011011011011011011011011\") == 90\n assert candidate(s = \"1110111011101110111011101110111\") == 39\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111\") == 63\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001001001001\") == 122\n assert candidate(s = \"11110000111100001111000011110000\") == 45\n assert candidate(s = \"1101101101101101101101101101101101101101\") == 54\n assert candidate(s = \"1100110011001100110011001100110011001100110011001\") == 74\n assert candidate(s = \"110101010101010101010101010101010101010101010101010101010101010101\") == 99\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010000\") == 96\n assert candidate(s = \"11111111111111111111111111111111\") == 33\n assert candidate(s = \"1101111111000000\") == 18\n assert candidate(s = \"1001001001001001001001001001001001001001\") == 67\n assert candidate(s = \"10101010101010101010101010101010101010101\") == 62\n assert candidate(s = \"10000000000000000000000000000000000000000\") == 40\n assert candidate(s = \"11001100110011001100110011001100110011001100\") == 65\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111010\") == 66\n assert candidate(s = \"1111101010101010101010101010101\") == 45\n assert candidate(s = \"11010101010101010101\") == 30\n assert candidate(s = \"1011101001101001101001101001101\") == 46\n assert candidate(s = \"1100110011001100110011001100110\") == 46\n assert candidate(s = \"1100011000110001100011000110001\") == 50\n assert candidate(s = \"1111101111101111101111101111101111101111101111101\") == 58\n assert candidate(s = \"1001001001001001001001001001001001001001001001001\") == 82\n assert candidate(s = \"11001101100110110\") == 24\n assert candidate(s = \"1110111011101110111011101110111011101110111\") == 54\n assert candidate(s = \"111001000111001000111001000111001000\") == 54\n assert candidate(s = \"1000000000000000000000000000000000000000000000000\") == 48\n assert candidate(s = \"1011011011011011011011011011011011011011011011011011011011011011011011\") == 94\n assert candidate(s = \"1011101110111011101110111011101110111011101110111011101110111011\") == 81\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numSteps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numSteps(self, s: str) -> int:", "container": "Solution", "callable": "numSteps", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1405, "task_id": "longest-happy-string", "difficulty": "Medium", "problem_description": "A string s is called happy if it satisfies the following conditions:\n\ns only contains the letters 'a', 'b', and 'c'.\ns does not contain any of \"aaa\", \"bbb\", or \"ccc\" as a substring.\ns contains at most a occurrences of the letter 'a'.\ns contains at most b occurrences of the letter 'b'.\ns contains at most c occurrences of the letter 'c'.\n\nGiven three integers a, b, and c, return the longest possible happy string. If there are multiple longest happy strings, return any of them. If there is no such string, return the empty string \"\".\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: a = 1, b = 1, c = 7\nOutput: \"ccaccbcc\"\nExplanation: \"ccbccacc\" would also be a correct answer.\n\nExample 2:\n\nInput: a = 7, b = 1, c = 0\nOutput: \"aabaa\"\nExplanation: It is the only correct answer in this case.\n\n \nConstraints:\n\n0 <= a, b, c <= 100\na + b + c > 0\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = 7,b = 1,c = 0) == \"aabaa\"\n assert candidate(a = 100,b = 100,c = 100) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 33,b = 33,c = 34) == \"cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 2,b = 2,c = 2) == \"abcabc\"\n assert candidate(a = 5,b = 5,c = 5) == \"abcabcabcabcabc\"\n assert candidate(a = 5,b = 3,c = 2) == \"aabaabcabc\"\n assert candidate(a = 50,b = 50,c = 0) == \"abababababababababababababababababababababababababababababababababababababababababababababababababab\"\n assert candidate(a = 50,b = 30,c = 20) == \"aabaabaabaabaabaabaabaabaabaabaabaacaabaacaabaacaabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 7) == \"ccaccbcc\"\n assert candidate(a = 0,b = 0,c = 1) == \"c\"\n assert candidate(a = 0,b = 0,c = 0) == \"\"\n assert candidate(a = 100,b = 0,c = 0) == \"aa\"\n assert candidate(a = 0,b = 0,c = 3) == \"cc\"\n assert candidate(a = 40,b = 30,c = 30) == \"aabaacaabaacaabaacaabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 0,b = 10,c = 10) == \"bcbcbcbcbcbcbcbcbcbc\"\n assert candidate(a = 10,b = 10,c = 1) == \"ababababababababababc\"\n assert candidate(a = 20,b = 10,c = 15) == \"aacaacaacaacaacabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 15,b = 20,c = 10) == \"bbabbabbabbabababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 45,b = 10,c = 45) == \"acacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 6,b = 6,c = 6) == \"abcabcabcabcabcabc\"\n assert candidate(a = 3,b = 3,c = 3) == \"abcabcabc\"\n assert candidate(a = 40,b = 20,c = 40) == \"acacacacacacacacacacacacacacacacacacacacabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 15,b = 15,c = 15) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 33,b = 34,c = 33) == \"babcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 5,b = 5,c = 4) == \"ababcabcabcabc\"\n assert candidate(a = 10,b = 10,c = 20) == \"ccaccbccaccbccaccbcabcabcabcabcabcabcabc\"\n assert candidate(a = 60,b = 40,c = 5) == \"aabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabababababababababababababababababcabcabcabcabc\"\n assert candidate(a = 4,b = 4,c = 3) == \"ababcabcabc\"\n assert candidate(a = 15,b = 15,c = 5) == \"abababababababababababcabcabcabcabc\"\n assert candidate(a = 5,b = 4,c = 4) == \"aabcabcabcabc\"\n assert candidate(a = 5,b = 5,c = 0) == \"ababababab\"\n assert candidate(a = 10,b = 10,c = 5) == \"ababababababcabcabcabcabc\"\n assert candidate(a = 5,b = 0,c = 5) == \"acacacacac\"\n assert candidate(a = 20,b = 20,c = 10) == \"abababababababababababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 34,b = 33,c = 33) == \"aabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 0,b = 0,c = 100) == \"cc\"\n assert candidate(a = 10,b = 20,c = 10) == \"bbabbcbbabbcbbabbcbabcabcabcabcabcabcabc\"\n assert candidate(a = 30,b = 20,c = 10) == \"aabaabaabaabaabaabaabaabaabaababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 30,b = 30,c = 20) == \"abababababababababababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 20,b = 25,c = 20) == \"bbabbcbbabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 0,b = 50,c = 50) == \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\"\n assert candidate(a = 90,b = 5,c = 5) == \"aabaacaabaacaabaacaabaacaabaacaa\"\n assert candidate(a = 20,b = 19,c = 18) == \"aababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 6,b = 7,c = 8) == \"cbcabcabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 5) == \"ccaccbc\"\n assert candidate(a = 4,b = 4,c = 5) == \"cabcabcabcabc\"\n assert candidate(a = 2,b = 1,c = 1) == \"aabc\"\n assert candidate(a = 50,b = 50,c = 50) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 99,b = 1,c = 0) == \"aabaa\"\n assert candidate(a = 34,b = 34,c = 32) == \"abababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 10,b = 45,c = 45) == \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 2,b = 3,c = 5) == \"ccbcabcabc\"\n assert candidate(a = 15,b = 5,c = 10) == \"aacaacaacaacaacabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 2) == \"cabc\"\n assert candidate(a = 7,b = 8,c = 9) == \"cbcabcabcabcabcabcabcabc\"\n assert candidate(a = 8,b = 8,c = 8) == \"abcabcabcabcabcabcabcabc\"\n assert candidate(a = 33,b = 33,c = 33) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 25,b = 25,c = 24) == \"ababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 100,b = 50,c = 50) == \"aabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabacabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 5,b = 2,c = 2) == \"aabaacabc\"\n assert candidate(a = 25,b = 25,c = 25) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 99,b = 99,c = 99) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 15,b = 15,c = 10) == \"ababababababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 3,b = 3,c = 9) == \"ccaccbccacbcabc\"\n assert candidate(a = 15,b = 15,c = 1) == \"abababababababababababababababc\"\n assert candidate(a = 10,b = 10,c = 10) == \"abcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 9,b = 8,c = 7) == \"aababcabcabcabcabcabcabc\"\n assert candidate(a = 3,b = 3,c = 4) == \"cabcabcabc\"\n assert candidate(a = 1,b = 2,c = 1) == \"babc\"\n assert candidate(a = 3,b = 2,c = 1) == \"aababc\"\n assert candidate(a = 10,b = 1,c = 1) == \"aabaacaa\"\n assert candidate(a = 10,b = 5,c = 15) == \"ccaccaccaccacacabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 1) == \"abc\"\n assert candidate(a = 49,b = 50,c = 51) == \"cbcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 20,b = 10,c = 10) == \"aabaacaabaacaabaacaabcabcabcabcabcabcabc\"\n assert candidate(a = 51,b = 50,c = 49) == \"aababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 20,b = 30,c = 20) == \"bbabbcbbabbcbbabbcbabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 1,b = 100,c = 1) == \"bbabbcbb\"\n assert candidate(a = 5,b = 5,c = 10) == \"ccaccbccabcabcabcabc\"\n assert candidate(a = 50,b = 50,c = 1) == \"ababababababababababababababababababababababababababababababababababababababababababababababababababc\"\n assert candidate(a = 0,b = 100,c = 0) == \"bb\"\n assert candidate(a = 24,b = 25,c = 25) == \"bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 10,b = 10,c = 15) == \"ccaccbccabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 100) == \"ccaccbcc\"\n assert candidate(a = 1,b = 2,c = 3) == \"cbcabc\"\n assert candidate(a = 20,b = 20,c = 19) == \"ababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 45,b = 45,c = 10) == \"ababababababababababababababababababababababababababababababababababababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 0,b = 5,c = 5) == \"bcbcbcbcbc\"\n assert candidate(a = 60,b = 40,c = 0) == \"aabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaababababababababababababababababababababab\"\n assert candidate(a = 3,b = 7,c = 5) == \"bbcbbcabcabcabc\"\n assert candidate(a = 30,b = 30,c = 30) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 30,b = 25,c = 45) == \"ccaccaccaccaccaccaccbccaccbccaccbcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n"}, "metadata": {"canonical_parameter_names": ["a", "b", "c"], "leetcode_dataset_entry_point": "Solution().longestDiverseString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def longestDiverseString(self, a: int, b: int, c: int) -> str:", "container": "Solution", "callable": "longestDiverseString", "parameters": [{"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1406, "task_id": "stone-game-iii", "difficulty": "Hard", "problem_description": "Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.\nAlice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2, or 3 stones from the first remaining stones in the row.\nThe score of each player is the sum of the values of the stones taken. The score of each player is 0 initially.\nThe objective of the game is to end with the highest score, and the winner is the player with the highest score and there could be a tie. The game continues until all the stones have been taken.\nAssume Alice and Bob play optimally.\nReturn \"Alice\" if Alice will win, \"Bob\" if Bob will win, or \"Tie\" if they will end the game with the same score.\n \nExample 1:\n\nInput: stoneValue = [1,2,3,7]\nOutput: \"Bob\"\nExplanation: Alice will always lose. Her best move will be to take three piles and the score become 6. Now the score of Bob is 7 and Bob wins.\n\nExample 2:\n\nInput: stoneValue = [1,2,3,-9]\nOutput: \"Alice\"\nExplanation: Alice must choose all the three piles at the first move to win and leave Bob with negative score.\nIf Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. In the next move, Alice will take the pile with value = -9 and lose.\nIf Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. In the next move, Alice will take the pile with value = -9 and also lose.\nRemember that both play optimally so here Alice will choose the scenario that makes her win.\n\nExample 3:\n\nInput: stoneValue = [1,2,3,6]\nOutput: \"Tie\"\nExplanation: Alice cannot win this game. She can end the game in a draw if she decided to choose all the first three piles, otherwise she will lose.\n\n \nConstraints:\n\n1 <= stoneValue.length <= 5 * 104\n-1000 <= stoneValue[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stoneValue = [0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [1]) == \"Alice\"\n assert candidate(stoneValue = [1, -100, 1, 100]) == \"Tie\"\n assert candidate(stoneValue = [5, 3, 7, 1]) == \"Alice\"\n assert candidate(stoneValue = [5, 3, 1, 4, 2]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == \"Tie\"\n assert candidate(stoneValue = [-1, -2, -3, -4]) == \"Tie\"\n assert candidate(stoneValue = [1, 2, 3, 6]) == \"Tie\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == \"Alice\"\n assert candidate(stoneValue = [5, 3, -6, 7, 2, 8, -1, 4, 10]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == \"Bob\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [1000, -1000, 1000, -1000]) == \"Alice\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 7]) == \"Bob\"\n assert candidate(stoneValue = [1000, -1000, 1000, -1000, 1000]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, -9]) == \"Alice\"\n assert candidate(stoneValue = [-1, -2, -3, -4, -5]) == \"Bob\"\n assert candidate(stoneValue = [3, 2, 10, 4]) == \"Alice\"\n assert candidate(stoneValue = [1000, -1000, 1000, -1000, 1000]) == \"Alice\"\n assert candidate(stoneValue = [5, 10, -5, 1]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == \"Alice\"\n assert candidate(stoneValue = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8]) == \"Alice\"\n assert candidate(stoneValue = [3, -2, 5, 1, -4, 6, -3, 2, 5, -1, 4, -6, 3, 2, -5, 1, 4, -6, 3, 2, -5, 1, 4, -6, 3, 2, -5]) == \"Alice\"\n assert candidate(stoneValue = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300, -1400, 1500]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == \"Alice\"\n assert candidate(stoneValue = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == \"Alice\"\n assert candidate(stoneValue = [1000, -999, 998, -997, 996, -995, 994, -993, 992, -991]) == \"Alice\"\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == \"Tie\"\n assert candidate(stoneValue = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == \"Alice\"\n assert candidate(stoneValue = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [5, 10, -5, 20, 25, -30, 35, -40, 45, 50]) == \"Alice\"\n assert candidate(stoneValue = [5, -1, 3, -4, 2, 10, -7, 8, -2, 6]) == \"Alice\"\n assert candidate(stoneValue = [5, 3, 2, 4, 1, 3, 2, 1, 2, 3, 4, 5, 1, 2, 3]) == \"Alice\"\n assert candidate(stoneValue = [100, -99, 100, -99, 100, -99, 100, -99, 100, -99]) == \"Alice\"\n assert candidate(stoneValue = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == \"Alice\"\n assert candidate(stoneValue = [10, 15, -5, 20, -10, 25, -15, 30, -20, 35]) == \"Alice\"\n assert candidate(stoneValue = [100, -50, 200, -150, 300, -200, 400, -250, 500, -300, 600, -350, 700, -400, 800]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == \"Bob\"\n assert candidate(stoneValue = [3, 1, 5, 4, 2, 6, 7, 8, 9, 10]) == \"Alice\"\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == \"Tie\"\n assert candidate(stoneValue = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8]) == \"Alice\"\n assert candidate(stoneValue = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == \"Tie\"\n assert candidate(stoneValue = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50]) == \"Alice\"\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == \"Bob\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1, 0, 1, -3, 7, -15, 31, -62, 125, -250, 500, -1000]) == \"Alice\"\n assert candidate(stoneValue = [-10, 100, -20, 200, -30, 300, -40, 400, -50, 500]) == \"Alice\"\n assert candidate(stoneValue = [5, 7, -3, 12, 15, -10, 8, 11, -2, 6, 14, 1, -5, 9, -7]) == \"Alice\"\n assert candidate(stoneValue = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25]) == \"Alice\"\n assert candidate(stoneValue = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == \"Tie\"\n assert candidate(stoneValue = [-100, -200, -300, 400, 500, 600, -700, -800, 900, 1000]) == \"Alice\"\n assert candidate(stoneValue = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"Alice\"\n assert candidate(stoneValue = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == \"Alice\"\n assert candidate(stoneValue = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == \"Bob\"\n assert candidate(stoneValue = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == \"Alice\"\n assert candidate(stoneValue = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == \"Alice\"\n assert candidate(stoneValue = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89]) == \"Alice\"\n assert candidate(stoneValue = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == \"Alice\"\n assert candidate(stoneValue = [100, 200, 300, 400, -1000, 500, 600, 700, -800, 900, 1000]) == \"Alice\"\n assert candidate(stoneValue = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == \"Alice\"\n assert candidate(stoneValue = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000]) == \"Alice\"\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == \"Alice\"\n assert candidate(stoneValue = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120, 130, -140, 150, -160, 170, -180, 190, -200, 210, -220, 230, -240, 250]) == \"Alice\"\n assert candidate(stoneValue = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == \"Tie\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [-5, 10, -15, 20, -25, 30, -35, 40, -45, 50]) == \"Alice\"\n assert candidate(stoneValue = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150]) == \"Tie\"\n assert candidate(stoneValue = [1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Alice\"\n assert candidate(stoneValue = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000]) == \"Alice\"\n assert candidate(stoneValue = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, 110, -120, 130, -140, 150, -160, 170, -180, 190, -200]) == \"Alice\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -30]) == \"Alice\"\n assert candidate(stoneValue = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50]) == \"Tie\"\n assert candidate(stoneValue = [-50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50]) == \"Tie\"\n assert candidate(stoneValue = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25, -26, 27, -28, 29, -30]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == \"Alice\"\n assert candidate(stoneValue = [5, -2, 4, -1, 3, -3, 2, 1, -5, 6, 7, -8, 9]) == \"Alice\"\n assert candidate(stoneValue = [500, 250, -100, 200, -150, 300, -50, 100, -200, 300, 500]) == \"Alice\"\n assert candidate(stoneValue = [5, -3, 2, 7, -8, 10, -15, 20, -25, 30]) == \"Alice\"\n assert candidate(stoneValue = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == \"Alice\"\n assert candidate(stoneValue = [-5, 10, 20, -15, 30, 25, -20, 40, -35, 50, -45, 60, -55]) == \"Alice\"\n assert candidate(stoneValue = [100, 200, 300, -100, -200, -300, 400, 500, 600, -400, -500, -600]) == \"Alice\"\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1000, -900, -800, -700, -600, -500, -400, -300, -200, -100]) == \"Tie\"\n assert candidate(stoneValue = [-50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50]) == \"Alice\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Tie\"\n assert candidate(stoneValue = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == \"Alice\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [1000, -500, 2000, -1000, 3000, -1500, 4000, -2000, 5000, -2500, 6000, -3000, 7000, -3500, 8000, -4000, 9000, -4500, 10000, -5000]) == \"Alice\"\n assert candidate(stoneValue = [5, -2, 3, 1, 4, -1, 7, -3, 2, 6, -5]) == \"Alice\"\n assert candidate(stoneValue = [-999, 1000, -999, 1000, -999, 1000, -999, 1000, -999, 1000]) == \"Alice\"\n assert candidate(stoneValue = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == \"Alice\"\n assert candidate(stoneValue = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == \"Alice\"\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == \"Alice\"\n"}, "metadata": {"canonical_parameter_names": ["stoneValue"], "leetcode_dataset_entry_point": "Solution().stoneGameIII", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def stoneGameIII(self, stoneValue: list[int]) -> str:", "container": "Solution", "callable": "stoneGameIII", "parameters": [{"name": "stoneValue", "type": "list[int]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1408, "task_id": "string-matching-in-an-array", "difficulty": "Easy", "problem_description": "Given an array of string words, return all strings in words that are a substring of another word. You can return the answer in any order.\n \nExample 1:\n\nInput: words = [\"mass\",\"as\",\"hero\",\"superhero\"]\nOutput: [\"as\",\"hero\"]\nExplanation: \"as\" is substring of \"mass\" and \"hero\" is substring of \"superhero\".\n[\"hero\",\"as\"] is also a valid answer.\n\nExample 2:\n\nInput: words = [\"leetcode\",\"et\",\"code\"]\nOutput: [\"et\",\"code\"]\nExplanation: \"et\", \"code\" are substring of \"leetcode\".\n\nExample 3:\n\nInput: words = [\"blue\",\"green\",\"bu\"]\nOutput: []\nExplanation: No string of words is substring of another string.\n\n \nConstraints:\n\n1 <= words.length <= 100\n1 <= words[i].length <= 30\nwords[i] contains only lowercase English letters.\nAll the strings of words are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['leetcode', 'et', 'code']) == ['et', 'code']\n assert candidate(words = ['blue', 'green', 'bu']) == []\n assert candidate(words = ['mass', 'as', 'hero', 'superhero']) == ['as', 'hero']\n assert candidate(words = ['nested', 'nest', 'sted', 'stednested', 'nestedsted', 'st']) == ['nested', 'nest', 'sted', 'st']\n assert candidate(words = ['computer', 'com', 'puter', 'put', 'ter', 'er', 'r', 'software', 'soft', 'ware', 'awe', 'awe', 're']) == ['com', 'puter', 'put', 'ter', 'er', 'r', 'soft', 'ware', 'awe', 'awe', 're']\n assert candidate(words = ['apple', 'pineapple', 'banana', 'app', 'pine']) == ['apple', 'app', 'pine']\n assert candidate(words = ['apple', 'app', 'pineapple', 'pie', 'pine']) == ['apple', 'app', 'pine']\n assert candidate(words = ['hello', 'world', 'hello world', 'world hello', 'owor', 'dlrow', 'lohel']) == ['hello', 'world']\n assert candidate(words = ['abcdefgh', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a']) == ['abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a']\n assert candidate(words = ['one', 'once', 'only', 'no', 'on', 'o', 'onceuponatime', 'time', 'upon']) == ['once', 'on', 'o', 'time', 'upon']\n assert candidate(words = ['interview', 'view', 'terview', 'enter', 'viewer', 'inter']) == ['view', 'terview', 'inter']\n assert candidate(words = ['hello', 'hell', 'ello', 'lo', 'll', 'he', 'oh', 'el', 'le', 'hellos', 'los']) == ['hello', 'hell', 'ello', 'lo', 'll', 'he', 'el', 'los']\n assert candidate(words = ['adventure', 'venture', 'adven', 'advenu', 'tu', 'tre', 'ven', 'ure', 'enture', 'venu']) == ['venture', 'adven', 'tu', 'ven', 'ure', 'enture', 'venu']\n assert candidate(words = ['abcdef', 'def', 'ghij', 'jkl', 'ghijkl', 'defgh']) == ['def', 'ghij', 'jkl']\n assert candidate(words = ['hello', 'world', 'hello_world', 'helloworld']) == ['hello', 'world']\n assert candidate(words = ['algorithm', 'algo', 'rhythm', 'thm', 'hythm', 'ythm', 'thm', 'hm', 'm', 'rythm']) == ['algo', 'thm', 'hythm', 'ythm', 'thm', 'hm', 'm']\n assert candidate(words = ['abc', 'bca', 'cab', 'abcd', 'bcda', 'cdab', 'dabc']) == ['abc']\n assert candidate(words = ['amazing', 'zing', 'zinga', 'zingalingo']) == ['zing', 'zinga']\n assert candidate(words = ['xyz', 'zyx', 'xyzz', 'zzxy', 'yxz', 'zyxz', 'xyzzyx']) == ['xyz', 'zyx', 'xyzz', 'yxz']\n assert candidate(words = ['algorithms', 'algo', 'rithm', 'log', 'thm', 'gms']) == ['algo', 'rithm', 'thm']\n assert candidate(words = ['extraterrestrial', 'extra', 'terrestrial', 'restrial', 'estrial', 'trial', 'rial', 'ial', 'al', 'l']) == ['extra', 'terrestrial', 'restrial', 'estrial', 'trial', 'rial', 'ial', 'al', 'l']\n assert candidate(words = ['substring', 'super', 'sub', 'superstring', 'string', 'ingsub']) == ['super', 'sub', 'string']\n assert candidate(words = ['a', 'b', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh']) == ['a', 'b', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg']\n assert candidate(words = ['unique', 'unicorn', 'unicore', 'uniques', 'unicorns', 'unicornicorns']) == ['unique', 'unicorn']\n assert candidate(words = ['programming', 'gram', 'gramming', 'pro', 'ming']) == ['gram', 'gramming', 'pro', 'ming']\n assert candidate(words = ['python', 'java', 'c', 'c++', 'javascript', 'typescript', 'script', 'type', 'java', 'script', 'scripting']) == ['java', 'c', 'script', 'type', 'java', 'script']\n assert candidate(words = ['one', 'two', 'three', 'onetwo', 'twothree', 'onetwothree', 'threeonetwo']) == ['one', 'two', 'three', 'onetwo', 'twothree']\n assert candidate(words = ['abc', 'bcd', 'abcd', 'ab', 'cde', 'def', 'abcdefg']) == ['abc', 'bcd', 'abcd', 'ab', 'cde', 'def']\n assert candidate(words = ['abcd', 'abcde', 'abcdef', 'def', 'cde', 'bcde']) == ['abcd', 'abcde', 'def', 'cde', 'bcde']\n assert candidate(words = ['substring', 'string', 'sub', 'str', 'st', 's']) == ['string', 'sub', 'str', 'st', 's']\n assert candidate(words = ['abc', 'def', 'abcdef', 'ghijkl', 'mnop', 'mnopqr', 'abcde']) == ['abc', 'def', 'mnop', 'abcde']\n assert candidate(words = ['python', 'java', 'javascript', 'pythonic', 'code', 'script']) == ['python', 'java', 'script']\n assert candidate(words = ['microcosm', 'micro', 'cosm', 'co', 'sm', 'microscopic', 'scop', 'scope', 'opic', 'pic']) == ['micro', 'cosm', 'co', 'sm', 'scop', 'opic', 'pic']\n assert candidate(words = ['elephant', 'elephantium', 'phant', 'phantom', 'ele', 'fantastic']) == ['elephant', 'phant', 'ele']\n assert candidate(words = ['incomprehensible', 'in', 'comprehensible', 'prehensible', 'prehens', 'hensible', 'ensible', 'sible', 'ible', 'ble']) == ['in', 'comprehensible', 'prehensible', 'prehens', 'hensible', 'ensible', 'sible', 'ible', 'ble']\n assert candidate(words = ['algorithm', 'log', 'arithm', 'rhythm', 'mthm', 'them']) == []\n assert candidate(words = ['repetition', 'petition', 'iteration', 'repeat', 'pet', 'tion', 'peti', 'petit', 'petiti', 'petitio']) == ['petition', 'pet', 'tion', 'peti', 'petit', 'petiti', 'petitio']\n assert candidate(words = ['substring', 'string', 'sub', 'substringing', 'ing']) == ['substring', 'string', 'sub', 'ing']\n assert candidate(words = ['quick', 'brown', 'fox', 'the', 'quickbrownfoxjumpsoverthelazydog']) == ['quick', 'brown', 'fox', 'the']\n assert candidate(words = ['substring', 'string', 'sub', 'ing', 'substr', 'str', 'ingstr', 'substrin']) == ['string', 'sub', 'ing', 'substr', 'str', 'substrin']\n assert candidate(words = ['hello', 'world', 'hel', 'lo', 'wor', 'rld', 'ldo']) == ['hel', 'lo', 'wor', 'rld']\n assert candidate(words = ['programming', 'gram', 'ming', 'pro', 'gramming']) == ['gram', 'ming', 'pro', 'gramming']\n assert candidate(words = ['aabbcc', 'bbaa', 'ccaa', 'aabb', 'bbcc', 'ccaabb', 'aabbccaa']) == ['aabbcc', 'ccaa', 'aabb', 'bbcc']\n assert candidate(words = ['tiny', 'tinier', 'tinytinier', 'tinytiny', 'tinieriny']) == ['tiny', 'tinier']\n assert candidate(words = ['apple', 'app', 'le', 'banana', 'nan', 'batman', 'man', 'at']) == ['app', 'le', 'nan', 'man', 'at']\n assert candidate(words = ['aabbcc', 'aabb', 'abbc', 'bbcc', 'abcc', 'aabc', 'bccc', 'ccaa', 'aacc', 'bbca']) == ['aabb', 'abbc', 'bbcc']\n assert candidate(words = ['random', 'rand', 'dom', 'ra', 'doma', 'mon', 'ndom', 'and', 'ran', 'domi']) == ['rand', 'dom', 'ra', 'ndom', 'and', 'ran']\n assert candidate(words = ['xylophone', 'xylo', 'phone', 'pho', 'ne', 'xy', 'lo', 'lopho', 'phone']) == ['xylo', 'phone', 'pho', 'ne', 'xy', 'lo', 'lopho', 'phone']\n assert candidate(words = ['algorithm', 'logarithm', 'rhythm', 'algorithmic', 'logarithmic', 'rhythmic']) == ['algorithm', 'logarithm', 'rhythm']\n assert candidate(words = ['abcd', 'abc', 'ab', 'a', 'bcde', 'cde', 'de', 'e']) == ['abc', 'ab', 'a', 'cde', 'de', 'e']\n assert candidate(words = ['substring', 'string', 'sub', 'str', 'ing', 'sun', 'set', 'net', 'get', 'ten']) == ['string', 'sub', 'str', 'ing']\n assert candidate(words = ['photography', 'photo', 'graphy', 'graph', 'graphy', 'photo', 'graphi', 'graphis', 'photo', 'photog']) == ['photo', 'graphy', 'graph', 'graphy', 'photo', 'graphi', 'photo', 'photog']\n assert candidate(words = ['subsequence', 'sequence', 'sub', 'ence', 'quen']) == ['sequence', 'sub', 'ence', 'quen']\n assert candidate(words = ['abcdefg', 'bcdef', 'cdefg', 'defgh', 'efghi', 'fghij', 'ghijk', 'hijkl', 'ijklm', 'jklmn']) == ['bcdef', 'cdefg']\n assert candidate(words = ['tiny', 'tinytiny', 'tinytinytiny', 'tinytinytinytiny', 'tinytinytinytinytiny']) == ['tiny', 'tinytiny', 'tinytinytiny', 'tinytinytinytiny']\n assert candidate(words = ['substring', 'substr', 'string', 'str', 'tri', 'ing', 'sub', 'subtr', 'ing', 'subtrin']) == ['substr', 'string', 'str', 'tri', 'ing', 'sub', 'subtr', 'ing']\n assert candidate(words = ['submarine', 'sub', 'marine', 'submar', 'in', 'a', 'mar', 'ne']) == ['sub', 'marine', 'submar', 'in', 'a', 'mar', 'ne']\n assert candidate(words = ['abcd', 'abc', 'ab', 'a', 'bcde', 'cde', 'de']) == ['abc', 'ab', 'a', 'cde', 'de']\n assert candidate(words = ['abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'e', 'f']) == ['abcde', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'e', 'f']\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg']) == ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef']\n assert candidate(words = ['programming', 'gram', 'ming', 'pro', 'am', 'ing', 'gramming', 'program']) == ['gram', 'ming', 'pro', 'am', 'ing', 'gramming', 'program']\n assert candidate(words = ['hello', 'he', 'hell', 'lo', 'he', 'ello', 'hel', 'ell', 'llo', 'lo']) == ['he', 'hell', 'lo', 'he', 'ello', 'hel', 'ell', 'llo', 'lo']\n assert candidate(words = ['apple', 'plea', 'ple', 'applepie']) == ['apple', 'ple']\n assert candidate(words = ['fantastic', 'fant', 'ast', 'astic', 'tic']) == ['fant', 'ast', 'astic', 'tic']\n assert candidate(words = ['supercalifragilisticexpialidocious', 'cali', 'frag', 'listic', 'expiali', 'docious', 'super']) == ['cali', 'frag', 'listic', 'expiali', 'docious', 'super']\n assert candidate(words = ['subsequence', 'sequence', 'sub', 'seq', 'subseq', 'quen', 'ence', 'quence', 'suben', 'queseq']) == ['sequence', 'sub', 'seq', 'subseq', 'quen', 'ence', 'quence']\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh']) == ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg']\n assert candidate(words = ['abcdabcd', 'ab', 'abc', 'abcd', 'abcde', 'abcdef']) == ['ab', 'abc', 'abcd', 'abcde']\n assert candidate(words = ['banana', 'ana', 'nan', 'ban', 'an']) == ['ana', 'nan', 'ban', 'an']\n assert candidate(words = ['hello', 'world', 'hello world', 'helloworld', 'lowor', 'wor']) == ['hello', 'world', 'lowor', 'wor']\n assert candidate(words = ['programming', 'gram', 'ming', 'pro', 'gramming', 'program']) == ['gram', 'ming', 'pro', 'gramming', 'program']\n assert candidate(words = ['interdisciplinary', 'inter', 'disciplinary', 'disci', 'plinary', 'sci', 'sciency', 'interdisci', 'plin', 'sciencyplin']) == ['inter', 'disciplinary', 'disci', 'plinary', 'sci', 'sciency', 'interdisci', 'plin']\n assert candidate(words = ['abcdefg', 'abcde', 'abcd', 'abc', 'ab', 'a', 'abcdefgh', 'efg', 'hij', 'ijk']) == ['abcdefg', 'abcde', 'abcd', 'abc', 'ab', 'a', 'efg']\n assert candidate(words = ['tiny', 'tinytiny', 'tinytinytiny', 'tinytinytinytiny']) == ['tiny', 'tinytiny', 'tinytinytiny']\n assert candidate(words = ['overlap', 'lapping', 'lap', 'lappping', 'lapppinglap']) == ['lap', 'lappping']\n assert candidate(words = ['programming', 'program', 'ming', 'code', 'coding']) == ['program', 'ming']\n assert candidate(words = ['algorithm', 'algo', 'rhythm', 'rhythmic', 'algothm', 'rhyth', 'thm']) == ['algo', 'rhythm', 'rhyth', 'thm']\n assert candidate(words = ['substring', 'string', 'sub', 'substrings', 'str']) == ['substring', 'string', 'sub', 'str']\n assert candidate(words = ['abcdef', 'bcde', 'cde', 'de', 'e', 'f']) == ['bcde', 'cde', 'de', 'e', 'f']\n assert candidate(words = ['nested', 'nest', 'nestedword', 'word', 'edword', 'st', 'sted']) == ['nested', 'nest', 'word', 'edword', 'st', 'sted']\n assert candidate(words = ['photographically', 'photo', 'graphically', 'graphic', 'ically', 'ally', 'ly', 'y']) == ['photo', 'graphically', 'graphic', 'ically', 'ally', 'ly', 'y']\n assert candidate(words = ['xylophone', 'phone', 'lophone', 'xylo', 'loph', 'pho', 'hon', 'xyl', 'one', 'phe']) == ['phone', 'lophone', 'xylo', 'loph', 'pho', 'hon', 'xyl', 'one']\n assert candidate(words = ['programming', 'gram', 'ming', 'mingo', 'prog', 'ingram', 'program', 'gramming', 'programm', 'progr']) == ['gram', 'ming', 'prog', 'program', 'gramming', 'programm', 'progr']\n assert candidate(words = ['abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'e', 'f', 'abcdefg', 'gh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == ['abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'e', 'f', 'gh']\n assert candidate(words = ['algorithm', 'log', 'rithm', 'algo', 'thm']) == ['rithm', 'algo', 'thm']\n assert candidate(words = ['unique', 'uni', 'ique', 'un', 'que', 'nique', 'niqe', 'neiq', 'uqei', 'inqeu']) == ['uni', 'ique', 'un', 'que', 'nique']\n assert candidate(words = ['programming', 'gram', 'pro', 'ming', 'ring']) == ['gram', 'pro', 'ming']\n assert candidate(words = ['water', 'watermelon', 'melon', 'wa', 'ter', 'melonade', 'ade']) == ['water', 'melon', 'wa', 'ter', 'ade']\n assert candidate(words = ['apple', 'pineapple', 'grape', 'pinegrape', 'grapefruit', 'pineapplegrape']) == ['apple', 'pineapple', 'grape']\n assert candidate(words = ['abc', 'def', 'abcd', 'abcde', 'abcdef']) == ['abc', 'def', 'abcd', 'abcde']\n assert candidate(words = ['supercalifragilisticexpialidocious', 'super', 'cali', 'fragi', 'listic', 'expiali', 'docious', 'fragilisticexpialidocious']) == ['super', 'cali', 'fragi', 'listic', 'expiali', 'docious', 'fragilisticexpialidocious']\n assert candidate(words = ['unbelievable', 'un', 'believe', 'able', 'e', 'a', 'i', 'o', 'u']) == ['un', 'able', 'e', 'a', 'i', 'u']\n assert candidate(words = ['encyclopedia', 'encyclop', 'yclopedia', 'cloped', 'lopedia', 'pedia', 'dia', 'dialect', 'logic', 'encyclopediaic']) == ['encyclopedia', 'encyclop', 'yclopedia', 'cloped', 'lopedia', 'pedia', 'dia']\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnop', 'qrstuvwxyz', 'mnopqrstu', 'vwxyz']) == ['abcdefghijklmnop', 'qrstuvwxyz', 'mnopqrstu', 'vwxyz']\n assert candidate(words = ['supercalifragilisticexpialidocious', 'fragilistic', 'expialidocious', 'docious', 'ious', 'ous', 'us', 's']) == ['fragilistic', 'expialidocious', 'docious', 'ious', 'ous', 'us', 's']\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef']) == ['a', 'ab', 'abc', 'abcd', 'abcde']\n assert candidate(words = ['algorithm', 'algo', 'rhythm', 'thm', 'rthm', 'hythmthm']) == ['algo', 'thm']\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().stringMatching", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def stringMatching(self, words: list[str]) -> list[str]:", "container": "Solution", "callable": "stringMatching", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1409, "task_id": "queries-on-a-permutation-with-key", "difficulty": "Medium", "problem_description": "Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the following rules:\n\nIn the beginning, you have the permutation P=[1,2,3,...,m].\nFor the current i, find the position of queries[i] in the permutation P (indexing from 0) and then move this at the beginning of the permutation P. Notice that the position of queries[i] in P is the result for queries[i].\n\nReturn an array containing the result for the given queries.\n \nExample 1:\n\nInput: queries = [3,1,2,1], m = 5\nOutput: [2,1,2,1] \nExplanation: The queries are processed as follow: \nFor i=0: queries[i]=3, P=[1,2,3,4,5], position of 3 in P is 2, then we move 3 to the beginning of P resulting in P=[3,1,2,4,5]. \nFor i=1: queries[i]=1, P=[3,1,2,4,5], position of 1 in P is 1, then we move 1 to the beginning of P resulting in P=[1,3,2,4,5]. \nFor i=2: queries[i]=2, P=[1,3,2,4,5], position of 2 in P is 2, then we move 2 to the beginning of P resulting in P=[2,1,3,4,5]. \nFor i=3: queries[i]=1, P=[2,1,3,4,5], position of 1 in P is 1, then we move 1 to the beginning of P resulting in P=[1,2,3,4,5]. \nTherefore, the array containing the result is [2,1,2,1]. \n\nExample 2:\n\nInput: queries = [4,1,2,2], m = 4\nOutput: [3,1,2,0]\n\nExample 3:\n\nInput: queries = [7,5,5,8,3], m = 8\nOutput: [6,5,0,7,5]\n\n \nConstraints:\n\n1 <= m <= 10^3\n1 <= queries.length <= m\n1 <= queries[i] <= m\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(queries = [3, 1, 2, 1],m = 5) == [2, 1, 2, 1]\n assert candidate(queries = [1, 2, 3],m = 3) == [0, 1, 2]\n assert candidate(queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [7, 5, 5, 8, 3],m = 8) == [6, 5, 0, 7, 5]\n assert candidate(queries = [1, 2, 3, 4, 5],m = 5) == [0, 1, 2, 3, 4]\n assert candidate(queries = [5, 4, 3, 2, 1],m = 5) == [4, 4, 4, 4, 4]\n assert candidate(queries = [4, 1, 2, 2],m = 4) == [3, 1, 2, 0]\n assert candidate(queries = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5) == [0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],m = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 1) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],m = 20) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(queries = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 15) == [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14]\n assert candidate(queries = [5, 3, 8, 6, 2, 7, 4, 1],m = 8) == [4, 3, 7, 6, 5, 7, 7, 7]\n assert candidate(queries = [100, 1, 100, 2, 100, 3, 100, 4, 100, 5, 100, 6, 100, 7, 100, 8, 100, 9, 100, 10],m = 100) == [99, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]\n assert candidate(queries = [8, 7, 6, 5, 4, 3, 2, 1],m = 8) == [7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(queries = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 10) == [9, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 7) == [6, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],m = 5) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2],m = 20) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(queries = [2, 3, 2, 1, 3, 2, 1, 3, 2, 1],m = 3) == [1, 2, 1, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(queries = [10, 1, 10, 2, 10, 3, 10, 4, 10, 5, 10, 6, 10, 7, 10, 8, 10, 9, 10, 10],m = 10) == [9, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 0]\n assert candidate(queries = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],m = 5) == [2, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [8, 3, 8, 5, 8, 3, 8, 5, 8, 3, 8, 5, 8, 3],m = 8) == [7, 3, 1, 5, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n assert candidate(queries = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],m = 3) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(queries = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],m = 2) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [3, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3) == [2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1],m = 8) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(queries = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 9) == [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],m = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [10, 1, 10, 2, 10, 3, 10, 4, 10, 5],m = 10) == [9, 1, 1, 2, 1, 3, 1, 4, 1, 5]\n assert candidate(queries = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],m = 100) == [99, 99, 99, 99, 99, 99, 99, 99, 99, 99]\n assert candidate(queries = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 15) == [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14]\n assert candidate(queries = [2, 4, 6, 8, 1, 3, 5, 7, 2, 4, 6, 8, 1, 3, 5, 7],m = 8) == [1, 3, 5, 7, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(queries = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 7) == [6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],m = 10) == [1, 3, 5, 7, 9, 5, 6, 7, 8, 9]\n assert candidate(queries = [8, 7, 6, 5, 4, 3, 2, 1],m = 8) == [7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],m = 20) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [1, 5, 9, 3, 7, 2, 6, 4, 8, 10],m = 10) == [0, 4, 8, 4, 7, 5, 7, 7, 8, 9]\n assert candidate(queries = [100, 50, 25, 75, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 100) == [99, 50, 26, 75, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(queries = [2, 3, 2, 1, 4, 3, 2, 1],m = 4) == [1, 2, 1, 2, 3, 3, 3, 3]\n assert candidate(queries = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],m = 5) == [2, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],m = 6) == [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 5) == [4, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 30) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\n assert candidate(queries = [5, 3, 8, 9, 2, 10, 7, 1, 4, 6],m = 10) == [4, 3, 7, 8, 5, 9, 9, 7, 8, 9]\n assert candidate(queries = [1, 4, 3, 2, 5, 6, 7, 8, 9, 10],m = 10) == [0, 3, 3, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 20) == [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(queries = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10) == [9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [7, 3, 7, 3, 5, 3, 7],m = 7) == [6, 3, 1, 1, 5, 1, 2]\n assert candidate(queries = [1, 2, 3, 4, 5, 4, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],m = 5) == [0, 1, 2, 3, 4, 1, 2, 3, 4, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(queries = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],m = 6) == [5, 5, 5, 5, 5, 5, 1, 2, 3, 4, 5]\n assert candidate(queries = [4, 2, 4, 3, 2, 4, 1],m = 5) == [3, 2, 1, 3, 2, 2, 3]\n assert candidate(queries = [10, 5, 1, 5, 10, 5, 1, 10, 10, 1, 5],m = 10) == [9, 5, 2, 1, 2, 1, 2, 2, 0, 1, 2]\n assert candidate(queries = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10],m = 10) == [4, 3, 7, 6, 5, 7, 7, 7, 8, 9]\n assert candidate(queries = [5, 5, 5, 5, 5],m = 5) == [4, 0, 0, 0, 0]\n assert candidate(queries = [5, 3, 7, 1, 9, 2, 8, 4, 6],m = 10) == [4, 3, 6, 3, 8, 5, 8, 7, 8]\n assert candidate(queries = [8, 3, 1, 7, 10, 4, 6, 5, 9, 2],m = 10) == [7, 3, 2, 7, 9, 6, 8, 8, 9, 9]\n assert candidate(queries = [3, 5, 2, 8, 6, 7, 4, 1, 5, 3, 9, 2, 8, 6, 7, 4, 1],m = 9) == [2, 4, 3, 7, 6, 7, 7, 7, 6, 7, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(queries = [5, 2, 9, 1, 5, 3, 8, 4, 7, 6, 5, 2, 9, 1, 5],m = 10) == [4, 2, 8, 3, 3, 4, 8, 6, 8, 8, 5, 8, 8, 8, 3]\n assert candidate(queries = [5, 3, 7, 1, 4, 2, 8, 6],m = 8) == [4, 3, 6, 3, 5, 5, 7, 7]\n assert candidate(queries = [15, 8, 2, 7, 12, 14, 4, 1, 13, 6, 9, 11, 10, 5, 3],m = 15) == [14, 8, 3, 8, 12, 14, 8, 7, 14, 11, 12, 14, 14, 14, 14]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 15) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9]\n assert candidate(queries = [5, 3, 8, 2, 5, 3],m = 10) == [4, 3, 7, 4, 3, 3]\n assert candidate(queries = [7, 7, 7, 7, 7, 7, 7],m = 10) == [6, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 15) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(queries = [9, 1, 9, 2, 9, 3, 9, 4, 9, 5],m = 10) == [8, 1, 1, 2, 1, 3, 1, 4, 1, 5]\n assert candidate(queries = [8, 6, 4, 2, 1, 3, 5, 7],m = 8) == [7, 6, 5, 4, 4, 5, 6, 7]\n assert candidate(queries = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1],m = 6) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(queries = [2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [5, 3, 1, 4, 2, 5, 3, 1],m = 5) == [4, 3, 2, 4, 4, 4, 4, 4]\n assert candidate(queries = [1, 3, 2, 1, 2, 3, 1, 2, 3, 1],m = 3) == [0, 2, 2, 2, 1, 2, 2, 2, 2, 2]\n assert candidate(queries = [3, 4, 3, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1],m = 4) == [2, 3, 1, 3, 1, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3]\n assert candidate(queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 20) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 5) == [4, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 1) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 20) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [3, 2, 3, 1, 2, 3, 2, 1, 3, 2, 1],m = 3) == [2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],m = 25) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]\n assert candidate(queries = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3) == [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(queries = [1, 1, 1, 1, 1, 1, 1, 1],m = 1) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [7, 5, 5, 8, 3, 7, 5, 5, 8, 3, 7, 5, 5, 8, 3],m = 8) == [6, 5, 0, 7, 5, 3, 3, 0, 3, 3, 3, 3, 0, 3, 3]\n assert candidate(queries = [10, 1, 10, 2, 10, 3, 10, 4, 10, 5, 10, 6, 10, 7, 10, 8, 10, 9],m = 10) == [9, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9]\n assert candidate(queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],m = 20) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]\n assert candidate(queries = [5, 1, 5, 2, 5, 3, 5, 4, 5],m = 5) == [4, 1, 1, 2, 1, 3, 1, 4, 1]\n assert candidate(queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],m = 20) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1],m = 10) == [8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(queries = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 5) == [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [7, 7, 7, 7, 7, 7, 7],m = 7) == [6, 0, 0, 0, 0, 0, 0]\n"}, "metadata": {"canonical_parameter_names": ["queries", "m"], "leetcode_dataset_entry_point": "Solution().processQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def processQueries(self, queries: list[int], m: int) -> list[int]:", "container": "Solution", "callable": "processQueries", "parameters": [{"name": "queries", "type": "list[int]"}, {"name": "m", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1410, "task_id": "html-entity-parser", "difficulty": "Medium", "problem_description": "HTML entity parser is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself.\nThe special characters and their entities for HTML are:\n\nQuotation Mark: the entity is " and symbol character is \".\nSingle Quote Mark: the entity is ' and symbol character is '.\nAmpersand: the entity is & and symbol character is &.\nGreater Than Sign: the entity is > and symbol character is >.\nLess Than Sign: the entity is < and symbol character is <.\nSlash: the entity is ⁄ and symbol character is /.\n\nGiven the input text string to the HTML parser, you have to implement the entity parser.\nReturn the text after replacing the entities by the special characters.\n \nExample 1:\n\nInput: text = \"& is an HTML entity but &ambassador; is not.\"\nOutput: \"& is an HTML entity but &ambassador; is not.\"\nExplanation: The parser will replace the & entity by &\n\nExample 2:\n\nInput: text = \"and I quote: "..."\"\nOutput: \"and I quote: \\\"...\\\"\"\n\n \nConstraints:\n\n1 <= text.length <= 105\nThe string may contain any possible characters out of all the 256 ASCII characters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"& is an HTML entity but &ambassador; is not.\") == \"& is an HTML entity but &ambassador; is not.\"\n assert candidate(text = \"and I quote: "..."\") == \"and I quote: \\\"...\\\"\"\n assert candidate(text = \"Stay home! Practice on Leetcode :)\") == \"Stay home! Practice on Leetcode :)\"\n assert candidate(text = \"x > y && x < y is always False\") == \"x > y && x < y is always False\"\n assert candidate(text = \"leetcode.com⁄problemset⁄all\") == \"leetcode.com/problemset/all\"\n"}, "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().entityParser", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def entityParser(self, text: str) -> str:", "container": "Solution", "callable": "entityParser", "parameters": [{"name": "text", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1411, "task_id": "number-of-ways-to-paint-n-3-grid", "difficulty": "Hard", "problem_description": "You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colors: Red, Yellow, or Green while making sure that no two adjacent cells have the same color (i.e., no two cells that share vertical or horizontal sides have the same color).\nGiven n the number of rows of the grid, return the number of ways you can paint this grid. As the answer may grow large, the answer must be computed modulo 109 + 7.\n \nExample 1:\n\n\nInput: n = 1\nOutput: 12\nExplanation: There are 12 possible way to paint the grid as shown.\n\nExample 2:\n\nInput: n = 5000\nOutput: 30228214\n\n \nConstraints:\n\nn == grid.length\n1 <= n <= 5000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 246\n assert candidate(n = 1000) == 650420578\n assert candidate(n = 100) == 905790447\n assert candidate(n = 2500) == 80958521\n assert candidate(n = 4) == 1122\n assert candidate(n = 4999) == 134620719\n assert candidate(n = 5000) == 30228214\n assert candidate(n = 2) == 54\n assert candidate(n = 1) == 12\n assert candidate(n = 500) == 350959293\n assert candidate(n = 50) == 151149117\n assert candidate(n = 10) == 10107954\n assert candidate(n = 5) == 5118\n assert candidate(n = 4000) == 685933196\n assert candidate(n = 12) == 210323922\n assert candidate(n = 2000) == 897054912\n assert candidate(n = 3750) == 477003884\n assert candidate(n = 3500) == 28484708\n assert candidate(n = 3000) == 313837042\n assert candidate(n = 30) == 462032897\n assert candidate(n = 16) == 62485141\n assert candidate(n = 10000) == 779575021\n assert candidate(n = 8) == 485778\n assert candidate(n = 250) == 601916395\n assert candidate(n = 999) == 672393158\n assert candidate(n = 32) == 554911778\n assert candidate(n = 20) == 690883140\n assert candidate(n = 11) == 46107966\n assert candidate(n = 15) == 963045241\n assert candidate(n = 200) == 693684710\n assert candidate(n = 1234) == 18988659\n assert candidate(n = 750) == 493513580\n assert candidate(n = 4500) == 471193061\n assert candidate(n = 6) == 23346\n assert candidate(n = 7) == 106494\n assert candidate(n = 25) == 676744457\n assert candidate(n = 1500) == 814277332\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().numOfWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numOfWays(self, n: int) -> int:", "container": "Solution", "callable": "numOfWays", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1413, "task_id": "minimum-value-to-get-positive-step-by-step-sum", "difficulty": "Easy", "problem_description": "Given an array of integers nums, you start with an initial positive value startValue.\nIn each iteration, you calculate the step by step sum of startValue plus elements in nums (from left to right).\nReturn the minimum positive value of startValue such that the step by step sum is never less than 1.\n \nExample 1:\n\nInput: nums = [-3,2,-3,4,2]\nOutput: 5\nExplanation: If you choose startValue = 4, in the third iteration your step by step sum is less than 1.\nstep by step sum\nstartValue = 4 | startValue = 5 | nums\n (4 -3 ) = 1 | (5 -3 ) = 2 | -3\n (1 +2 ) = 3 | (2 +2 ) = 4 | 2\n (3 -3 ) = 0 | (4 -3 ) = 1 | -3\n (0 +4 ) = 4 | (1 +4 ) = 5 | 4\n (4 +2 ) = 6 | (5 +2 ) = 7 | 2\n\nExample 2:\n\nInput: nums = [1,2]\nOutput: 1\nExplanation: Minimum start value should be positive. \n\nExample 3:\n\nInput: nums = [1,-2,-3]\nOutput: 5\n\n \nConstraints:\n\n1 <= nums.length <= 100\n-100 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 1, -1, 1]) == 2\n assert candidate(nums = [100, 100, 100]) == 1\n assert candidate(nums = [-3, 2, -3, 4, 2]) == 5\n assert candidate(nums = [1, -2, -3]) == 5\n assert candidate(nums = [-1]) == 2\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [100]) == 1\n assert candidate(nums = [-100, 100, -100, 100]) == 101\n assert candidate(nums = [50, 50, 50]) == 1\n assert candidate(nums = [-100, -50, -25, -12, -6, -3, -1]) == 198\n assert candidate(nums = [0, 0, 0]) == 1\n assert candidate(nums = [-1, -2, -3, -4]) == 11\n assert candidate(nums = [-100]) == 101\n assert candidate(nums = [1, 2]) == 1\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1]) == 1\n assert candidate(nums = [50, -50, 50, -50]) == 1\n assert candidate(nums = [-50, -50, -50]) == 151\n assert candidate(nums = [-1, 0, 1]) == 2\n assert candidate(nums = [10, 20, 30, 40]) == 1\n assert candidate(nums = [10, 20, -30, 40, -50, 60, -70, 80]) == 21\n assert candidate(nums = [5, -3, -4, 2, 0, 1, -2, -3, 4, 5]) == 5\n assert candidate(nums = [10, -5, -15, 20, -10, 5]) == 11\n assert candidate(nums = [0, -1, -2, -3, -4, -5, 6]) == 16\n assert candidate(nums = [-1, -1, -1, -1, -1, 10]) == 6\n assert candidate(nums = [100, -100, 100, -100, 100, -100]) == 1\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 51\n assert candidate(nums = [0, 0, 0, 0, 0, -1, 1]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, -150, 60]) == 1\n assert candidate(nums = [100, -50, 25, -12, 62, -31, 15, -7, 3, -1]) == 1\n assert candidate(nums = [5, -3, 2, -8, 6, -1, 4, -7]) == 5\n assert candidate(nums = [1, -100, 100, -200, 200, -300, 300]) == 300\n assert candidate(nums = [10, -20, 30, -40, 50, -60]) == 31\n assert candidate(nums = [100, -50, -50, 50, -25, 25, -12, 12]) == 1\n assert candidate(nums = [-99, -98, -97, -96, -95, -94, -93, -92, -91, -90]) == 946\n assert candidate(nums = [5, -15, 20, -25, 30, -35, 40]) == 21\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 11\n assert candidate(nums = [1, -100, 100, -100, 100, -100, 100, -100]) == 100\n assert candidate(nums = [-50, 50, -25, 25, -12, 12, -6, 6, -3, 3]) == 51\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 6\n assert candidate(nums = [-10, 20, -30, 40, -50, 60]) == 31\n assert candidate(nums = [-50, 50, -50, 50, -50, 50]) == 51\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 16\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3]) == 4\n assert candidate(nums = [100, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10]) == 1\n assert candidate(nums = [5, 5, 5, 5, -20, 5, 5, 5, 5]) == 1\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700]) == 301\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [5, -10, 15, -20, 25, -30, 35, -40, 45, -50]) == 26\n assert candidate(nums = [10, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, 10]) == 41\n assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25]) == 1\n assert candidate(nums = [0, -1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [-10, 0, 10, -20, 20, -30, 30]) == 31\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, 15]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [-10, -20, -30, 40, 50, -15]) == 61\n assert candidate(nums = [0, 0, 0, 0, 0, 0, -1]) == 2\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6]) == 7\n assert candidate(nums = [-1, -2, -3, -4, -5, 15, -1, -1, -1, -1]) == 16\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 1\n assert candidate(nums = [-20, 10, 0, -10, 20, 0, -10, 0, 20]) == 21\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80]) == 41\n assert candidate(nums = [-50, -20, -30, 100, -10, 20]) == 101\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, -150]) == 1\n assert candidate(nums = [-50, 50, -50, 50, -50, 50, -50, 50, -50, 50]) == 51\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70]) == 31\n assert candidate(nums = [-10, -20, -30, -40, -50, 100]) == 151\n assert candidate(nums = [30, -10, 20, -15, 5, -5, 10, -10, 15, -20]) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 6\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 1\n assert candidate(nums = [10, 20, 30, -50, 40, -10, -20, -30, 50]) == 11\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [3, -5, 2, -1, 4, -6]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, -5, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3]) == 4\n assert candidate(nums = [-50, -50, -50, 50, 50]) == 151\n assert candidate(nums = [10, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == 36\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [10, -1, 10, -1, 10, -1, 10, -1, 10, -1, 10, -1, 10, -1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 10, 20, -50, 100]) == 21\n assert candidate(nums = [-10, -20, -30, -40, -50]) == 151\n assert candidate(nums = [0, -1, 0, -2, 0, -3, 0, -4, 0, -5]) == 16\n assert candidate(nums = [-5, -5, -5, -5, 20, -5, -5, -5, -5]) == 21\n assert candidate(nums = [100, -50, 25, -75, 10, -10, 5, -5]) == 1\n assert candidate(nums = [100, -50, -50, -50, -50, 200]) == 101\n assert candidate(nums = [0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [100, -50, 25, -20, 10, -5, 1]) == 1\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 551\n assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 1]) == 46\n assert candidate(nums = [-5, -4, -3, -2, -1]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55]) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minStartValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minStartValue(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minStartValue", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1414, "task_id": "find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k", "difficulty": "Medium", "problem_description": "Given an integer k, return the minimum number of Fibonacci numbers whose sum is equal to k. The same Fibonacci number can be used multiple times.\nThe Fibonacci numbers are defined as:\n\nF1 = 1\nF2 = 1\nFn = Fn-1 + Fn-2 for n > 2.\n\nIt is guaranteed that for the given constraints we can always find such Fibonacci numbers that sum up to k.\n \nExample 1:\n\nInput: k = 7\nOutput: 2 \nExplanation: The Fibonacci numbers are: 1, 1, 2, 3, 5, 8, 13, ... \nFor k = 7 we can use 2 + 5 = 7.\nExample 2:\n\nInput: k = 10\nOutput: 2 \nExplanation: For k = 10 we can use 2 + 8 = 10.\n\nExample 3:\n\nInput: k = 19\nOutput: 3 \nExplanation: For k = 19 we can use 1 + 5 + 13 = 19.\n\n \nConstraints:\n\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 433494437) == 1\n assert candidate(k = 377) == 1\n assert candidate(k = 6765) == 1\n assert candidate(k = 24157817) == 1\n assert candidate(k = 102334155) == 1\n assert candidate(k = 89) == 1\n assert candidate(k = 121393) == 1\n assert candidate(k = 500) == 3\n assert candidate(k = 514229) == 1\n assert candidate(k = 50) == 3\n assert candidate(k = 39088169) == 1\n assert candidate(k = 21) == 1\n assert candidate(k = 2584) == 1\n assert candidate(k = 2178309) == 1\n assert candidate(k = 100) == 3\n assert candidate(k = 46368) == 1\n assert candidate(k = 233) == 1\n assert candidate(k = 63245986) == 1\n assert candidate(k = 1000000000) == 14\n assert candidate(k = 7) == 2\n assert candidate(k = 13) == 1\n assert candidate(k = 144) == 1\n assert candidate(k = 701408733) == 1\n assert candidate(k = 55) == 1\n assert candidate(k = 5702887) == 1\n assert candidate(k = 196418) == 1\n assert candidate(k = 2) == 1\n assert candidate(k = 28657) == 1\n assert candidate(k = 14930352) == 1\n assert candidate(k = 4) == 2\n assert candidate(k = 4181) == 1\n assert candidate(k = 3524578) == 1\n assert candidate(k = 17711) == 1\n assert candidate(k = 34) == 1\n assert candidate(k = 10946) == 1\n assert candidate(k = 1) == 1\n assert candidate(k = 19) == 3\n assert candidate(k = 165580141) == 1\n assert candidate(k = 3) == 1\n assert candidate(k = 610) == 1\n assert candidate(k = 8) == 1\n assert candidate(k = 317811) == 1\n assert candidate(k = 1346269) == 1\n assert candidate(k = 10) == 2\n assert candidate(k = 9227465) == 1\n assert candidate(k = 832040) == 1\n assert candidate(k = 1597) == 1\n assert candidate(k = 1000000) == 5\n assert candidate(k = 75025) == 1\n assert candidate(k = 1000) == 2\n assert candidate(k = 267914296) == 1\n assert candidate(k = 5) == 1\n assert candidate(k = 987) == 1\n assert candidate(k = 35) == 2\n assert candidate(k = 123456789) == 12\n assert candidate(k = 1234567) == 10\n assert candidate(k = 863999999) == 13\n assert candidate(k = 12586269025) == 1\n assert candidate(k = 1134903170) == 1\n assert candidate(k = 555555555) == 11\n assert candidate(k = 2123366401) == 14\n assert candidate(k = 340513) == 7\n assert candidate(k = 1836311903) == 1\n assert candidate(k = 104941883) == 11\n assert candidate(k = 999999999) == 13\n assert candidate(k = 470001109) == 13\n assert candidate(k = 55555555) == 11\n assert candidate(k = 2971215073) == 1\n assert candidate(k = 123456) == 4\n assert candidate(k = 987654321) == 15\n"}, "metadata": {"canonical_parameter_names": ["k"], "leetcode_dataset_entry_point": "Solution().findMinFibonacciNumbers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findMinFibonacciNumbers(self, k: int) -> int:", "container": "Solution", "callable": "findMinFibonacciNumbers", "parameters": [{"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1415, "task_id": "the-k-th-lexicographical-string-of-all-happy-strings-of-length-n", "difficulty": "Medium", "problem_description": "A happy string is a string that:\n\nconsists only of letters of the set ['a', 'b', 'c'].\ns[i] != s[i + 1] for all values of i from 1 to s.length - 1 (string is 1-indexed).\n\nFor example, strings \"abc\", \"ac\", \"b\" and \"abcbabcbcb\" are all happy strings and strings \"aa\", \"baa\" and \"ababbc\" are not happy strings.\nGiven two integers n and k, consider a list of all happy strings of length n sorted in lexicographical order.\nReturn the kth string of this list or return an empty string if there are less than k happy strings of length n.\n \nExample 1:\n\nInput: n = 1, k = 3\nOutput: \"c\"\nExplanation: The list [\"a\", \"b\", \"c\"] contains all happy strings of length 1. The third string is \"c\".\n\nExample 2:\n\nInput: n = 1, k = 4\nOutput: \"\"\nExplanation: There are only 3 happy strings of length 1.\n\nExample 3:\n\nInput: n = 3, k = 9\nOutput: \"cab\"\nExplanation: There are 12 different happy string of length 3 [\"aba\", \"abc\", \"aca\", \"acb\", \"bab\", \"bac\", \"bca\", \"bcb\", \"cab\", \"cac\", \"cba\", \"cbc\"]. You will find the 9th string = \"cab\"\n\n \nConstraints:\n\n1 <= n <= 10\n1 <= k <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,k = 101) == \"abacbabcab\"\n assert candidate(n = 5,k = 1) == \"ababa\"\n assert candidate(n = 10,k = 100) == \"abacbabacb\"\n assert candidate(n = 1,k = 4) == \"\"\n assert candidate(n = 2,k = 5) == \"ca\"\n assert candidate(n = 5,k = 25) == \"bcaba\"\n assert candidate(n = 5,k = 20) == \"babcb\"\n assert candidate(n = 1,k = 3) == \"c\"\n assert candidate(n = 3,k = 9) == \"cab\"\n assert candidate(n = 2,k = 6) == \"cb\"\n assert candidate(n = 4,k = 15) == \"bcba\"\n assert candidate(n = 2,k = 1) == \"ab\"\n assert candidate(n = 5,k = 15) == \"acbca\"\n assert candidate(n = 5,k = 30) == \"bcbac\"\n assert candidate(n = 3,k = 12) == \"cbc\"\n assert candidate(n = 2,k = 3) == \"ba\"\n assert candidate(n = 4,k = 20) == \"cacb\"\n assert candidate(n = 3,k = 1) == \"aba\"\n assert candidate(n = 4,k = 10) == \"babc\"\n assert candidate(n = 9,k = 30) == \"ababcbcac\"\n assert candidate(n = 9,k = 1024) == \"\"\n assert candidate(n = 8,k = 33) == \"abcababa\"\n assert candidate(n = 3,k = 13) == \"\"\n assert candidate(n = 7,k = 50) == \"acbabac\"\n assert candidate(n = 10,k = 1023) == \"bcbcbcbcba\"\n assert candidate(n = 7,k = 127) == \"bcbcbca\"\n assert candidate(n = 9,k = 300) == \"babcacacb\"\n assert candidate(n = 1,k = 1) == \"a\"\n assert candidate(n = 6,k = 123) == \"\"\n assert candidate(n = 7,k = 1) == \"abababa\"\n assert candidate(n = 7,k = 200) == \"\"\n assert candidate(n = 6,k = 27) == \"acbaca\"\n assert candidate(n = 9,k = 175) == \"acacacbca\"\n assert candidate(n = 10,k = 10) == \"abababcabc\"\n assert candidate(n = 10,k = 3) == \"ababababca\"\n assert candidate(n = 10,k = 1) == \"ababababab\"\n assert candidate(n = 9,k = 150) == \"acabcacac\"\n assert candidate(n = 4,k = 25) == \"\"\n assert candidate(n = 8,k = 150) == \"babcacac\"\n assert candidate(n = 2,k = 7) == \"\"\n assert candidate(n = 3,k = 15) == \"\"\n assert candidate(n = 6,k = 70) == \"cabcac\"\n assert candidate(n = 6,k = 30) == \"acbcac\"\n assert candidate(n = 9,k = 2048) == \"\"\n assert candidate(n = 7,k = 123) == \"bcbcaca\"\n assert candidate(n = 8,k = 512) == \"\"\n assert candidate(n = 7,k = 100) == \"bcabacb\"\n assert candidate(n = 10,k = 512) == \"acbcbcbcbc\"\n assert candidate(n = 5,k = 10) == \"acabc\"\n assert candidate(n = 10,k = 500) == \"acbcbcabcb\"\n assert candidate(n = 8,k = 256) == \"bcbcbcbc\"\n assert candidate(n = 8,k = 511) == \"\"\n assert candidate(n = 6,k = 64) == \"bcbcbc\"\n assert candidate(n = 8,k = 200) == \"bcabacbc\"\n assert candidate(n = 10,k = 2048) == \"\"\n assert candidate(n = 7,k = 85) == \"bacacab\"\n assert candidate(n = 8,k = 255) == \"bcbcbcba\"\n assert candidate(n = 10,k = 123) == \"abacbcbaca\"\n assert candidate(n = 7,k = 128) == \"bcbcbcb\"\n assert candidate(n = 8,k = 128) == \"acbcbcbc\"\n assert candidate(n = 5,k = 31) == \"bcbca\"\n assert candidate(n = 6,k = 42) == \"bacabc\"\n assert candidate(n = 10,k = 64) == \"ababcbcbcb\"\n assert candidate(n = 6,k = 63) == \"bcbcba\"\n assert candidate(n = 1,k = 2) == \"b\"\n assert candidate(n = 9,k = 100) == \"abcbabacb\"\n assert candidate(n = 9,k = 512) == \"bcbcbcbcb\"\n assert candidate(n = 5,k = 125) == \"\"\n assert candidate(n = 9,k = 1023) == \"\"\n assert candidate(n = 10,k = 125) == \"abacbcbcab\"\n assert candidate(n = 8,k = 100) == \"acbabacb\"\n assert candidate(n = 9,k = 50) == \"abacbabac\"\n assert candidate(n = 6,k = 5) == \"abacab\"\n assert candidate(n = 8,k = 64) == \"abcbcbcb\"\n assert candidate(n = 9,k = 500) == \"bcbcbabcb\"\n assert candidate(n = 9,k = 243) == \"acbcbabca\"\n assert candidate(n = 10,k = 200) == \"abcbabacbc\"\n assert candidate(n = 10,k = 1024) == \"bcbcbcbcbc\"\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().getHappyString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getHappyString(self, n: int, k: int) -> str:", "container": "Solution", "callable": "getHappyString", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1416, "task_id": "restore-the-array", "difficulty": "Hard", "problem_description": "A program was supposed to print an array of integers. The program forgot to print whitespaces and the array is printed as a string of digits s and all we know is that all integers in the array were in the range [1, k] and there are no leading zeros in the array.\nGiven the string s and the integer k, return the number of the possible arrays that can be printed as s using the mentioned program. Since the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: s = \"1000\", k = 10000\nOutput: 1\nExplanation: The only possible array is [1000]\n\nExample 2:\n\nInput: s = \"1000\", k = 10\nOutput: 0\nExplanation: There cannot be an array that was printed this way and has all integer >= 1 and <= 10.\n\nExample 3:\n\nInput: s = \"1317\", k = 2000\nOutput: 8\nExplanation: Possible arrays are [1317],[131,7],[13,17],[1,317],[13,1,7],[1,31,7],[1,3,17],[1,3,1,7]\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of only digits and does not contain leading zeros.\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"237\",k = 50) == 3\n assert candidate(s = \"111111111111111111111\",k = 11) == 17711\n assert candidate(s = \"123123123\",k = 123) == 100\n assert candidate(s = \"1317\",k = 2000) == 8\n assert candidate(s = \"99999\",k = 99999) == 16\n assert candidate(s = \"1000\",k = 10) == 0\n assert candidate(s = \"1234567891011121314151617181920\",k = 20) == 1280\n assert candidate(s = \"1000\",k = 10000) == 1\n assert candidate(s = \"1111\",k = 1) == 1\n assert candidate(s = \"123456789\",k = 9) == 1\n assert candidate(s = \"11111111111111111111111111111111111111111111\",k = 11) == 134903163\n assert candidate(s = \"123123123123123123123123123123123123123123123123\",k = 321) == 171507379\n assert candidate(s = \"4294967294294967294294967294294967294294294967294\",k = 4294967294) == 849136492\n assert candidate(s = \"112233445566778899101011121314151617181920\",k = 100) == 17480761\n assert candidate(s = \"11111111111111111111\",k = 11) == 10946\n assert candidate(s = \"12345678910111213141516171819202122232425\",k = 25) == 129792\n assert candidate(s = \"1010101010101010101010101010101010101010\",k = 10) == 1\n assert candidate(s = \"1111111111111111111111111111111111111111111111111\",k = 11) == 586268941\n assert candidate(s = \"55555555555555555555\",k = 55) == 10946\n assert candidate(s = \"987654321098765432109876543210\",k = 987654321) == 64504063\n assert candidate(s = \"999999999999999999\",k = 1000000000) == 129792\n assert candidate(s = \"999999999999999999\",k = 999999999) == 129792\n assert candidate(s = \"1230123\",k = 123) == 8\n assert candidate(s = \"1\",k = 1) == 1\n assert candidate(s = \"101010101010101010\",k = 100) == 1\n assert candidate(s = \"111111111111111111111111111111111111111111111111\",k = 100) == 778742000\n assert candidate(s = \"9999999999999999999\",k = 999999999) == 259328\n assert candidate(s = \"123456789\",k = 999999999) == 256\n assert candidate(s = \"21474836472147483647214748364721474836472147483647\",k = 2147483647) == 80057812\n assert candidate(s = \"111111111111111111\",k = 11) == 4181\n assert candidate(s = \"102030405060708090\",k = 100) == 1\n assert candidate(s = \"311131\",k = 100) == 13\n assert candidate(s = \"123456789101112\",k = 15) == 10\n assert candidate(s = \"999999999\",k = 999999999) == 256\n assert candidate(s = \"12345678901234567890\",k = 123456789) == 125704\n assert candidate(s = \"123456789101112131415161718192021222324252627282930\",k = 30) == 2076672\n assert candidate(s = \"55555555555555555555555555555555555555555555\",k = 555) == 809181231\n assert candidate(s = \"111111111111111111111111111111111111\",k = 1) == 1\n assert candidate(s = \"11111111111111111111\",k = 10) == 1\n assert candidate(s = \"111111111111111111111111111111111111111111\",k = 111) == 641778114\n assert candidate(s = \"9876543210123456789876543210\",k = 2147483647) == 32657088\n assert candidate(s = \"321321321321321321321321321321321321321321\",k = 321) == 641778114\n assert candidate(s = \"429496729542949672954294967295\",k = 4294967295) == 527718016\n assert candidate(s = \"314159265358979323846264338327950288419716939937510\",k = 10000) == 578862353\n assert candidate(s = \"11111111111111111111111111111111111111111111\",k = 111) == 809181231\n assert candidate(s = \"123456789012345678901234567890\",k = 50000) == 23834271\n assert candidate(s = \"30303030303030303030\",k = 30) == 1\n assert candidate(s = \"9999999999999999999999999999999999999999\",k = 1000000000) == 707881333\n assert candidate(s = \"1111111111111111111\",k = 11) == 6765\n assert candidate(s = \"222222222222222222222222222222222222222222\",k = 22) == 433494437\n assert candidate(s = \"31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679\",k = 1000000000) == 893659449\n assert candidate(s = \"10101010101010101010\",k = 101) == 1\n assert candidate(s = \"32791623145341\",k = 2000) == 3480\n assert candidate(s = \"123123123123123123123123\",k = 123) == 312500\n assert candidate(s = \"111213141516171819202122232425262728293031323334353637383940\",k = 40) == 287913465\n assert candidate(s = \"32767327673276732767\",k = 32767) == 338744\n assert candidate(s = \"1234567891011121314151617181920\",k = 5000) == 51814885\n assert candidate(s = \"123451234512345123451234512345123451234512345\",k = 50000) == 820858001\n assert candidate(s = \"2222222222222222222\",k = 2) == 1\n assert candidate(s = \"327683276832768\",k = 65536) == 12208\n assert candidate(s = \"987654321987654321987654321\",k = 987654321) == 65866496\n assert candidate(s = \"123456789101112131415161718192021\",k = 25) == 4992\n assert candidate(s = \"10101010101010101010101010101010101010101010\",k = 100) == 1\n assert candidate(s = \"111111111111111111111111111111111111\",k = 111) == 82876089\n assert candidate(s = \"112233445566778899\",k = 112233) == 105312\n assert candidate(s = \"1111111111111111111\",k = 1) == 1\n assert candidate(s = \"22222222222222222222\",k = 222) == 121415\n assert candidate(s = \"3034558\",k = 1000) == 20\n assert candidate(s = \"121314151617181920\",k = 20) == 256\n assert candidate(s = \"3030303030303030303\",k = 30) == 1\n assert candidate(s = \"99999999999999999999\",k = 999999999) == 518145\n assert candidate(s = \"1010101010101010101\",k = 101) == 2\n assert candidate(s = \"987654321987654321987654321987654321987654321\",k = 987654321) == 840181650\n assert candidate(s = \"12312312312312312312\",k = 123) == 31250\n assert candidate(s = \"1234567890\",k = 1000) == 125\n assert candidate(s = \"123123123123123123123123123123123123123123123123123\",k = 123) == 351558230\n assert candidate(s = \"9999999999999999999999999999999999999999\",k = 999999999) == 707881333\n assert candidate(s = \"333333333333\",k = 3333) == 1490\n assert candidate(s = \"555555555555555555555555555555555555555555555555\",k = 555) == 171507379\n assert candidate(s = \"111111111111111111111111111111\",k = 111) == 53798080\n assert candidate(s = \"12345678910111213141516171819202122232425262728293031323334353637383940\",k = 50) == 100424031\n assert candidate(s = \"1213141516171819202122232425262728293031323334353637383940\",k = 40) == 492437504\n assert candidate(s = \"1010101010101010101010101010101010101010101010101\",k = 10) == 1\n assert candidate(s = \"474747474747474747474747474747474747474747474747\",k = 4747) == 134502416\n assert candidate(s = \"1000000000000000000000000000000000000000000000000\",k = 1000000000) == 0\n assert candidate(s = \"22222222222222222222222222222222222222222\",k = 222) == 844048728\n assert candidate(s = \"999999999999999999999999999999999999999999999999\",k = 999) == 171507379\n assert candidate(s = \"5229458433423234234234\",k = 1000000) == 1825529\n assert candidate(s = \"112233445566778899\",k = 99) == 4181\n assert candidate(s = \"12345678910\",k = 10) == 1\n assert candidate(s = \"999999999999999999999999999999999999999999\",k = 999999999) == 634726928\n assert candidate(s = \"10101010101010101010\",k = 10) == 1\n assert candidate(s = \"999999999999999999999999999999999999999999\",k = 9) == 1\n assert candidate(s = \"12345123451234512345\",k = 5000) == 250625\n assert candidate(s = \"50505050505050505050\",k = 500) == 1\n assert candidate(s = \"12345678910\",k = 100) == 55\n assert candidate(s = \"123456789123456789123456789\",k = 10000) == 28074040\n assert candidate(s = \"1000000000100000000010000000001000000000\",k = 1000000000) == 1\n assert candidate(s = \"32791879\",k = 500) == 54\n assert candidate(s = \"222222222222222222222222222222222222222222222222\",k = 22) == 778742000\n assert candidate(s = \"987654321098765432109876543210987654321098765432109876543210\",k = 5000) == 712104623\n assert candidate(s = \"123456789\",k = 100) == 55\n assert candidate(s = \"987654321\",k = 100000) == 236\n assert candidate(s = \"33333333333333333333\",k = 3333) == 283953\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().numberOfArrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numberOfArrays(self, s: str, k: int) -> int:", "container": "Solution", "callable": "numberOfArrays", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1417, "task_id": "reformat-the-string", "difficulty": "Easy", "problem_description": "You are given an alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits).\nYou have to find a permutation of the string where no letter is followed by another letter and no digit is followed by another digit. That is, no two adjacent characters have the same type.\nReturn the reformatted string or return an empty string if it is impossible to reformat the string.\n \nExample 1:\n\nInput: s = \"a0b1c2\"\nOutput: \"0a1b2c\"\nExplanation: No two adjacent characters have the same type in \"0a1b2c\". \"a0b1c2\", \"0a1b2c\", \"0c2a1b\" are also valid permutations.\n\nExample 2:\n\nInput: s = \"leetcode\"\nOutput: \"\"\nExplanation: \"leetcode\" has only characters so we cannot separate them by digits.\n\nExample 3:\n\nInput: s = \"1229857369\"\nOutput: \"\"\nExplanation: \"1229857369\" has only digits so we cannot separate them by characters.\n\n \nConstraints:\n\n1 <= s.length <= 500\ns consists of only lowercase English letters and/or digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"a1b1\") == \"a1b1\"\n assert candidate(s = \"1229857369\") == \"\"\n assert candidate(s = \"aa1\") == \"a1a\"\n assert candidate(s = \"abc123def456\") == \"a1b2c3d4e5f6\"\n assert candidate(s = \"0123456789abcdefghijklmnopqrstuvwxyz\") == \"\"\n assert candidate(s = \"111\") == \"\"\n assert candidate(s = \"ab123\") == \"1a2b3\"\n assert candidate(s = \"1a\") == \"a1\"\n assert candidate(s = \"aabbcc123\") == \"\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"1234\") == \"\"\n assert candidate(s = \"a0b1c2d3e4f5g6h7i8j9\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"ab12cd34\") == \"a1b2c3d4\"\n assert candidate(s = \"a1\") == \"a1\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"1a2b3c4d\") == \"a1b2c3d4\"\n assert candidate(s = \"ab\") == \"\"\n assert candidate(s = \"a0b1c2\") == \"a0b1c2\"\n assert candidate(s = \"1a2b3c\") == \"a1b2c3\"\n assert candidate(s = \"a1b2c3\") == \"a1b2c3\"\n assert candidate(s = \"abcd1234\") == \"a1b2c3d4\"\n assert candidate(s = \"112233aabbcc\") == \"a1a1b2b2c3c3\"\n assert candidate(s = \"aaa\") == \"\"\n assert candidate(s = \"leetcode\") == \"\"\n assert candidate(s = \"a1b2c3d4\") == \"a1b2c3d4\"\n assert candidate(s = \"11a\") == \"1a1\"\n assert candidate(s = \"112233aabb\") == \"\"\n assert candidate(s = \"1a2b3c4d5e\") == \"a1b2c3d4e5\"\n assert candidate(s = \"abc\") == \"\"\n assert candidate(s = \"111222abc\") == \"\"\n assert candidate(s = \"12\") == \"\"\n assert candidate(s = \"abcd\") == \"\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz0123456789\") == \"\"\n assert candidate(s = \"1\") == \"1\"\n assert candidate(s = \"aab\") == \"\"\n assert candidate(s = \"123abc\") == \"a1b2c3\"\n assert candidate(s = \"aabbcc112233\") == \"a1a1b2b2c3c3\"\n assert candidate(s = \"0a0b0c0d\") == \"a0b0c0d0\"\n assert candidate(s = \"123\") == \"\"\n assert candidate(s = \"1a1b\") == \"a1b1\"\n assert candidate(s = \"c0d1e2f3\") == \"c0d1e2f3\"\n assert candidate(s = \"1234abcd\") == \"a1b2c3d4\"\n assert candidate(s = \"zzzz1111\") == \"z1z1z1z1\"\n assert candidate(s = \"9a8b7c6d5e4f3g2h1i0\") == \"9a8b7c6d5e4f3g2h1i0\"\n assert candidate(s = \"0z6y5x4w3v2u1t0s9r8q7p6o5n4m3l2k1j0i9h8g7f6e5d4c3b2a1\") == \"0z6y5x4w3v2u1t0s9r8q7p6o5n4m3l2k1j0i9h8g7f6e5d4c3b2a1\"\n assert candidate(s = \"0000000000aaaaaaaaaa\") == \"a0a0a0a0a0a0a0a0a0a0\"\n assert candidate(s = \"abcdefghij123456789\") == \"a1b2c3d4e5f6g7h8i9j\"\n assert candidate(s = \"0j9i8h7g6f5e4d3c2b1a\") == \"j0i9h8g7f6e5d4c3b2a1\"\n assert candidate(s = \"9876543210qwerty\") == \"\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\"\n assert candidate(s = \"123abc456def789ghi0\") == \"1a2b3c4d5e6f7g8h9i0\"\n assert candidate(s = \"90ijkl5678efgh1234abcd\") == \"\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1k1\") == \"a1b1c1d1e1f1g1h1i1j1k1\"\n assert candidate(s = \"1z1y1x1w1v1u1t1s1r1q1p1o1n1m1l1k1j1i1h1g1f1e1d1c1b1a1\") == \"1z1y1x1w1v1u1t1s1r1q1p1o1n1m1l1k1j1i1h1g1f1e1d1c1b1a1\"\n assert candidate(s = \"9876543210zyxcba\") == \"\"\n assert candidate(s = \"abcde12345fghij67890\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"a1a2a3a4a5b1b2b3b4b5c1c2c3c4c5\") == \"a1a2a3a4a5b1b2b3b4b5c1c2c3c4c5\"\n assert candidate(s = \"000aaa111bbb222ccc\") == \"a0a0a0b1b1b1c2c2c2\"\n assert candidate(s = \"1234567890abcdefghijklmnopqrstuvwxyz\") == \"\"\n assert candidate(s = \"0a1b2c3d4e5f6g7h8i9j\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"aabbccddeeff11223344\") == \"\"\n assert candidate(s = \"a0b0c0d0e0f0g0h0i0j0\") == \"a0b0c0d0e0f0g0h0i0j0\"\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s\") == \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9\"\n assert candidate(s = \"a1a1a1b2b2b2\") == \"a1a1a1b2b2b2\"\n assert candidate(s = \"9876543210zyxwvutsrqponmlkjihgfedcba\") == \"\"\n assert candidate(s = \"aabbccddeeff112233445566\") == \"a1a1b2b2c3c3d4d4e5e5f6f6\"\n assert candidate(s = \"abc123abc123abc123\") == \"a1b2c3a1b2c3a1b2c3\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\"\n assert candidate(s = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\"\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq0987654321\") == \"\"\n assert candidate(s = \"1111aaaa\") == \"a1a1a1a1\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9\") == \"a1b2c3d4e5f6g7h8i9\"\n assert candidate(s = \"1a2b3c4d5e6f\") == \"a1b2c3d4e5f6\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j\") == \"a1b2c3d4e5f6g7h8i9j\"\n assert candidate(s = \"0123456789abcdefghij\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"0a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t\") == \"a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\") == \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\"\n assert candidate(s = \"123456789abcdefghij\") == \"a1b2c3d4e5f6g7h8i9j\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p1234567890\") == \"\"\n assert candidate(s = \"abcd1234efgh5678ijkl0987\") == \"a1b2c3d4e5f6g7h8i0j9k8l7\"\n assert candidate(s = \"aaaaaaaaa11111111\") == \"a1a1a1a1a1a1a1a1a\"\n assert candidate(s = \"abcd0123efgh4567ijkl89\") == \"\"\n assert candidate(s = \"1234abcd5678abcd\") == \"a1b2c3d4a5b6c7d8\"\n assert candidate(s = \"0987654321abcdef\") == \"\"\n assert candidate(s = \"0a0b0c0d0e0f0g0h0i0j0\") == \"0a0b0c0d0e0f0g0h0i0j0\"\n assert candidate(s = \"12345abcde67890fghij\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"11223344556677889900\") == \"\"\n assert candidate(s = \"abcdefg123456\") == \"a1b2c3d4e5f6g\"\n assert candidate(s = \"abcdefghij0123456789\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"a0b1c2d3\") == \"a0b1c2d3\"\n assert candidate(s = \"0987654321jihgfedcba\") == \"j0i9h8g7f6e5d4c3b2a1\"\n assert candidate(s = \"abcdef123456\") == \"a1b2c3d4e5f6\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k\") == \"a1b2c3d4e5f6g7h8i9j0k\"\n assert candidate(s = \"0a0b0c0d0e0f0g0h0i0j0k0\") == \"0a0b0c0d0e0f0g0h0i0j0k0\"\n assert candidate(s = \"abc123def456ghi789j0\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"1234567890qwertyuiopasdfghjklzxcvbnm\") == \"\"\n assert candidate(s = \"123456abcdef\") == \"a1b2c3d4e5f6\"\n assert candidate(s = \"112233445566778899aabbccddeeffgghhii\") == \"a1a1b2b2c3c3d4d4e5e5f6f6g7g7h8h8i9i9\"\n assert candidate(s = \"abcd1234abcd5678\") == \"a1b2c3d4a5b6c7d8\"\n assert candidate(s = \"abcd1234abcd1234\") == \"a1b2c3d4a1b2c3d4\"\n assert candidate(s = \"9876543210\") == \"\"\n assert candidate(s = \"121212abcabc\") == \"a1b2c1a2b1c2\"\n assert candidate(s = \"a1a1a1a1a1122334455\") == \"\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1\") == \"a1b1c1d1e1f1g1h1i1j1\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p\") == \"z9y8x7w6v5u4t3s2r1q0p\"\n assert candidate(s = \"abc123def456ghi789\") == \"a1b2c3d4e5f6g7h8i9\"\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccdddddddd\") == \"\"\n assert candidate(s = \"0abcdefghij123456789\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"1a2a3a4a5a\") == \"a1a2a3a4a5\"\n assert candidate(s = \"abcdefghij1234567890\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"012345abcde67890fghij\") == \"0a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"1a2b3c4d5\") == \"1a2b3c4d5\"\n assert candidate(s = \"1234abcd1234abcd\") == \"a1b2c3d4a1b2c3d4\"\n assert candidate(s = \"a1b2a1b2a1b2a1b2\") == \"a1b2a1b2a1b2a1b2\"\n assert candidate(s = \"000aaa111bbb222ccc333ddd\") == \"a0a0a0b1b1b1c2c2c2d3d3d3\"\n assert candidate(s = \"abcd1234efgh5678ijkl90\") == \"\"\n assert candidate(s = \"abcdefghij\") == \"\"\n assert candidate(s = \"abcdefghij12345678901\") == \"1a2b3c4d5e6f7g8h9i0j1\"\n assert candidate(s = \"aabbccddeeffgghhiijj\") == \"\"\n assert candidate(s = \"123abc456def789ghi0jkl\") == \"\"\n assert candidate(s = \"9a8b7c6d\") == \"a9b8c7d6\"\n assert candidate(s = \"1234567890\") == \"\"\n assert candidate(s = \"a1a2a3a4a5a6a7a8a9\") == \"a1a2a3a4a5a6a7a8a9\"\n assert candidate(s = \"a0b0c0d0e0f0g0h0i0j0k0l0m0n0o0p0q0r0s0t0u0v0w0x0y0z0\") == \"a0b0c0d0e0f0g0h0i0j0k0l0m0n0o0p0q0r0s0t0u0v0w0x0y0z0\"\n assert candidate(s = \"0u1v2w3x4y5z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == \"0u1v2w3x4y5z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\"\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"00112233445566778899\") == \"\"\n assert candidate(s = \"1234567890abcdefghij\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"11111111111111111111aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"\"\n assert candidate(s = \"xyz987uvw654tsr321\") == \"x9y8z7u6v5w4t3s2r1\"\n assert candidate(s = \"zzzzzzzzz99999999\") == \"z9z9z9z9z9z9z9z9z\"\n assert candidate(s = \"abc123\") == \"a1b2c3\"\n assert candidate(s = \"abcdef1234567890\") == \"\"\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i\") == \"a1b2c3d4e5f6g7h8i9\"\n assert candidate(s = \"0000aaaa\") == \"a0a0a0a0\"\n assert candidate(s = \"654321fedcba\") == \"f6e5d4c3b2a1\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().reformat", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def reformat(self, s: str) -> str:", "container": "Solution", "callable": "reformat", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1418, "task_id": "display-table-of-food-orders-in-a-restaurant", "difficulty": "Medium", "problem_description": "Given the array orders, which represents the orders that customers have done in a restaurant. More specifically orders[i]=[customerNamei,tableNumberi,foodItemi] where customerNamei is the name of the customer, tableNumberi is the table customer sit at, and foodItemi is the item customer orders.\\r\n\\r\nReturn the restaurant's “display table”. The “display table” is a table whose row entries denote how many of each food item each table ordered. The first column is the table number and the remaining columns correspond to each food item in alphabetical order. The first row should be a header whose first column is “Table”, followed by the names of the food items. Note that the customer names are not part of the table. Additionally, the rows should be sorted in numerically increasing order.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: orders = [[\"David\",\"3\",\"Ceviche\"],[\"Corina\",\"10\",\"Beef Burrito\"],[\"David\",\"3\",\"Fried Chicken\"],[\"Carla\",\"5\",\"Water\"],[\"Carla\",\"5\",\"Ceviche\"],[\"Rous\",\"3\",\"Ceviche\"]]\\r\nOutput: [[\"Table\",\"Beef Burrito\",\"Ceviche\",\"Fried Chicken\",\"Water\"],[\"3\",\"0\",\"2\",\"1\",\"0\"],[\"5\",\"0\",\"1\",\"0\",\"1\"],[\"10\",\"1\",\"0\",\"0\",\"0\"]] \\r\nExplanation:\\r\nThe displaying table looks like:\\r\nTable,Beef Burrito,Ceviche,Fried Chicken,Water\\r\n3 ,0 ,2 ,1 ,0\\r\n5 ,0 ,1 ,0 ,1\\r\n10 ,1 ,0 ,0 ,0\\r\nFor the table 3: David orders \"Ceviche\" and \"Fried Chicken\", and Rous orders \"Ceviche\".\\r\nFor the table 5: Carla orders \"Water\" and \"Ceviche\".\\r\nFor the table 10: Corina orders \"Beef Burrito\". \\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: orders = [[\"James\",\"12\",\"Fried Chicken\"],[\"Ratesh\",\"12\",\"Fried Chicken\"],[\"Amadeus\",\"12\",\"Fried Chicken\"],[\"Adam\",\"1\",\"Canadian Waffles\"],[\"Brianna\",\"1\",\"Canadian Waffles\"]]\\r\nOutput: [[\"Table\",\"Canadian Waffles\",\"Fried Chicken\"],[\"1\",\"2\",\"0\"],[\"12\",\"0\",\"3\"]] \\r\nExplanation: \\r\nFor the table 1: Adam and Brianna order \"Canadian Waffles\".\\r\nFor the table 12: James, Ratesh and Amadeus order \"Fried Chicken\".\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: orders = [[\"Laura\",\"2\",\"Bean Burrito\"],[\"Jhon\",\"2\",\"Beef Burrito\"],[\"Melissa\",\"2\",\"Soda\"]]\\r\nOutput: [[\"Table\",\"Bean Burrito\",\"Beef Burrito\",\"Soda\"],[\"2\",\"1\",\"1\",\"1\"]]\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= orders.length <= 5 * 10^4\\r\n\torders[i].length == 3\\r\n\t1 <= customerNamei.length, foodItemi.length <= 20\\r\n\tcustomerNamei and foodItemi consist of lowercase and uppercase English letters and the space character.\\r\n\ttableNumberi is a valid integer between 1 and 500.\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(orders = [['Alice', '2', 'Veggie Delight'], ['Bob', '1', 'Salmon'], ['Charlie', '2', 'Salmon'], ['David', '3', 'Veggie Delight'], ['Eve', '3', 'Salmon']]) == [['Table', 'Salmon', 'Veggie Delight'], ['1', '1', '0'], ['2', '1', '1'], ['3', '1', '1']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight']]) == [['Table', 'Beef Burrito', 'Spring Roll', 'Veggie Delight'], ['1', '1', '1', '1'], ['2', '1', '0', '1']]\n assert candidate(orders = [['Laura', '2', 'Bean Burrito'], ['Jhon', '2', 'Beef Burrito'], ['Melissa', '2', 'Soda']]) == [['Table', 'Bean Burrito', 'Beef Burrito', 'Soda'], ['2', '1', '1', '1']]\n assert candidate(orders = [['David', '3', 'Ceviche'], ['Corina', '10', 'Beef Burrito'], ['David', '3', 'Fried Chicken'], ['Carla', '5', 'Water'], ['Carla', '5', 'Ceviche'], ['Rous', '3', 'Ceviche']]) == [['Table', 'Beef Burrito', 'Ceviche', 'Fried Chicken', 'Water'], ['3', '0', '2', '1', '0'], ['5', '0', '1', '0', '1'], ['10', '1', '0', '0', '0']]\n assert candidate(orders = [['James', '12', 'Fried Chicken'], ['Ratesh', '12', 'Fried Chicken'], ['Amadeus', '12', 'Fried Chicken'], ['Adam', '1', 'Canadian Waffles'], ['Brianna', '1', 'Canadian Waffles']]) == [['Table', 'Canadian Waffles', 'Fried Chicken'], ['1', '2', '0'], ['12', '0', '3']]\n assert candidate(orders = [['Sam', '2', 'Chocolate Cake'], ['Anna', '4', 'Fried Chicken'], ['Elsa', '4', 'Chocolate Cake'], ['Olaf', '2', 'Fried Chicken'], ['Kristoff', '4', 'Veggie Delight'], ['Sven', '2', 'Beef Burrito'], ['Hans', '4', 'Beef Burrito'], ['Kristoff', '2', 'Beef Burrito'], ['Anna', '1', 'Spring Roll'], ['Kristoff', '1', 'Fried Chicken'], ['Sven', '1', 'Chocolate Cake'], ['Olaf', '3', 'Veggie Delight'], ['Hans', '3', 'Beef Burrito'], ['Kristoff', '3', 'Beef Burrito'], ['Anna', '3', 'Chocolate Cake'], ['Elsa', '3', 'Spring Roll'], ['Olaf', '1', 'Veggie Delight'], ['Hans', '2', 'Fried Chicken']]) == [['Table', 'Beef Burrito', 'Chocolate Cake', 'Fried Chicken', 'Spring Roll', 'Veggie Delight'], ['1', '0', '1', '1', '1', '1'], ['2', '2', '1', '2', '0', '0'], ['3', '2', '1', '0', '1', '1'], ['4', '1', '1', '1', '0', '1']]\n assert candidate(orders = [['Ella', '1', 'Egg Muffin'], ['Nathan', '2', 'Bagel Sandwich'], ['Ella', '1', 'Egg Muffin'], ['Nathan', '2', 'Bagel Sandwich'], ['Ella', '1', 'Bagel Sandwich'], ['Nathan', '2', 'Egg Muffin'], ['Ella', '1', 'Tomato Juice'], ['Nathan', '2', 'Tomato Juice'], ['Ella', '1', 'Bagel Sandwich'], ['Nathan', '2', 'Egg Muffin'], ['Ella', '1', 'Tomato Juice'], ['Nathan', '2', 'Bagel Sandwich'], ['Ella', '1', 'Chicken Salad'], ['Nathan', '2', 'Chicken Salad'], ['Ella', '1', 'Tomato Juice'], ['Nathan', '2', 'Egg Muffin'], ['Ella', '1', 'Chicken Salad'], ['Nathan', '2', 'Bagel Sandwich'], ['Ella', '1', 'Tomato Juice'], ['Nathan', '2', 'Chicken Salad']]) == [['Table', 'Bagel Sandwich', 'Chicken Salad', 'Egg Muffin', 'Tomato Juice'], ['1', '2', '2', '2', '4'], ['2', '4', '2', '3', '1']]\n assert candidate(orders = [['Alice', '1', 'Beef Burrito'], ['Bob', '2', 'Chicken Curry'], ['Charlie', '3', 'Shrimp Fried Rice'], ['David', '4', 'Spicy Noodles'], ['Eve', '5', 'Vegetable Stir Fry'], ['Frank', '1', 'Beef Burrito'], ['Grace', '2', 'Chicken Curry'], ['Hank', '3', 'Shrimp Fried Rice'], ['Ivy', '4', 'Spicy Noodles'], ['Jack', '5', 'Vegetable Stir Fry'], ['Kathy', '1', 'Beef Burrito'], ['Leo', '2', 'Chicken Curry'], ['Mona', '3', 'Shrimp Fried Rice'], ['Nate', '4', 'Spicy Noodles'], ['Oscar', '5', 'Vegetable Stir Fry']]) == [['Table', 'Beef Burrito', 'Chicken Curry', 'Shrimp Fried Rice', 'Spicy Noodles', 'Vegetable Stir Fry'], ['1', '3', '0', '0', '0', '0'], ['2', '0', '3', '0', '0', '0'], ['3', '0', '0', '3', '0', '0'], ['4', '0', '0', '0', '3', '0'], ['5', '0', '0', '0', '0', '3']]\n assert candidate(orders = [['John', '1', 'Chocolate Cake'], ['Alice', '2', 'Vanilla Ice Cream'], ['Bob', '3', 'Strawberry Shake'], ['Charlie', '4', 'Chocolate Cake'], ['David', '5', 'Vanilla Ice Cream'], ['Eve', '6', 'Strawberry Shake'], ['Frank', '7', 'Chocolate Cake'], ['Grace', '8', 'Vanilla Ice Cream'], ['Hannah', '9', 'Strawberry Shake'], ['Ian', '10', 'Chocolate Cake'], ['Jack', '11', 'Vanilla Ice Cream'], ['Katherine', '12', 'Strawberry Shake'], ['Laura', '13', 'Chocolate Cake'], ['Michael', '14', 'Vanilla Ice Cream'], ['Nancy', '15', 'Strawberry Shake'], ['Oliver', '16', 'Chocolate Cake'], ['Penelope', '17', 'Vanilla Ice Cream'], ['Quinn', '18', 'Strawberry Shake'], ['Rachel', '19', 'Chocolate Cake'], ['Sam', '20', 'Vanilla Ice Cream'], ['Trent', '21', 'Strawberry Shake'], ['Uma', '22', 'Chocolate Cake'], ['Victor', '23', 'Vanilla Ice Cream'], ['Wendy', '24', 'Strawberry Shake'], ['Xander', '25', 'Chocolate Cake'], ['Yvonne', '26', 'Vanilla Ice Cream'], ['Zane', '27', 'Strawberry Shake']]) == [['Table', 'Chocolate Cake', 'Strawberry Shake', 'Vanilla Ice Cream'], ['1', '1', '0', '0'], ['2', '0', '0', '1'], ['3', '0', '1', '0'], ['4', '1', '0', '0'], ['5', '0', '0', '1'], ['6', '0', '1', '0'], ['7', '1', '0', '0'], ['8', '0', '0', '1'], ['9', '0', '1', '0'], ['10', '1', '0', '0'], ['11', '0', '0', '1'], ['12', '0', '1', '0'], ['13', '1', '0', '0'], ['14', '0', '0', '1'], ['15', '0', '1', '0'], ['16', '1', '0', '0'], ['17', '0', '0', '1'], ['18', '0', '1', '0'], ['19', '1', '0', '0'], ['20', '0', '0', '1'], ['21', '0', '1', '0'], ['22', '1', '0', '0'], ['23', '0', '0', '1'], ['24', '0', '1', '0'], ['25', '1', '0', '0'], ['26', '0', '0', '1'], ['27', '0', '1', '0']]\n assert candidate(orders = [['Laura', '10', 'Chocolate Cake'], ['Laura', '10', 'Chocolate Cake'], ['Laura', '10', 'Vanilla Ice Cream'], ['Laura', '20', 'Vanilla Ice Cream'], ['Laura', '20', 'Chocolate Cake'], ['Laura', '20', 'Chocolate Cake'], ['Laura', '30', 'Chocolate Cake'], ['Laura', '30', 'Vanilla Ice Cream'], ['Laura', '30', 'Vanilla Ice Cream'], ['Laura', '30', 'Vanilla Ice Cream']]) == [['Table', 'Chocolate Cake', 'Vanilla Ice Cream'], ['10', '2', '1'], ['20', '2', '1'], ['30', '1', '3']]\n assert candidate(orders = [['Zoe', '10', 'Ice Cream'], ['Chris', '15', 'Water'], ['Diana', '10', 'Ice Cream'], ['Eli', '20', 'Beef Burrito'], ['Finn', '15', 'Water'], ['George', '20', 'Beef Burrito'], ['Hannah', '10', 'Water'], ['Ian', '20', 'Ice Cream'], ['Jack', '15', 'Ice Cream'], ['Katie', '10', 'Beef Burrito'], ['Lucas', '20', 'Water'], ['Mia', '15', 'Ice Cream'], ['Noah', '10', 'Beef Burrito'], ['Oliver', '20', 'Water'], ['Penelope', '15', 'Ice Cream'], ['Quinn', '10', 'Beef Burrito'], ['Ryan', '20', 'Water'], ['Sophia', '15', 'Ice Cream'], ['Thomas', '10', 'Beef Burrito'], ['Uma', '20', 'Water'], ['Victor', '15', 'Ice Cream'], ['Will', '10', 'Beef Burrito'], ['Xander', '20', 'Water'], ['Yara', '15', 'Ice Cream'], ['Zane', '10', 'Beef Burrito']]) == [['Table', 'Beef Burrito', 'Ice Cream', 'Water'], ['10', '6', '2', '1'], ['15', '0', '6', '2'], ['20', '2', '1', '5']]\n assert candidate(orders = [['Emily', '1', 'Garden Salad'], ['Madison', '2', 'Grilled Cheese'], ['Emily', '3', 'Club Sandwich'], ['Madison', '1', 'Club Sandwich'], ['Emily', '2', 'Grilled Cheese'], ['Madison', '3', 'Garden Salad'], ['Avery', '1', 'Caesar Salad'], ['Chloe', '2', 'Chicken Salad'], ['Avery', '3', 'Grilled Cheese'], ['Chloe', '1', 'Club Sandwich'], ['Avery', '2', 'Garden Salad'], ['Chloe', '3', 'Caesar Salad'], ['Hannah', '1', 'Chicken Salad'], ['Ella', '2', 'Caesar Salad'], ['Hannah', '3', 'Grilled Cheese'], ['Ella', '1', 'Garden Salad'], ['Hannah', '2', 'Club Sandwich'], ['Ella', '3', 'Chicken Salad']]) == [['Table', 'Caesar Salad', 'Chicken Salad', 'Club Sandwich', 'Garden Salad', 'Grilled Cheese'], ['1', '1', '1', '2', '2', '0'], ['2', '1', '1', '1', '1', '2'], ['3', '1', '1', '1', '1', '2']]\n assert candidate(orders = [['Sophia', '15', 'Penne Arrabbiata'], ['Ava', '15', 'Margherita Pizza'], ['Mia', '15', 'Penne Arrabbiata'], ['Ella', '15', 'Margherita Pizza'], ['Olivia', '15', 'Margherita Pizza'], ['Sophia', '16', 'Caesar Salad'], ['Ava', '16', 'Caesar Salad'], ['Mia', '16', 'Penne Arrabbiata'], ['Ella', '16', 'Caesar Salad'], ['Olivia', '16', 'Penne Arrabbiata'], ['Sophia', '17', 'Tiramisu'], ['Ava', '17', 'Penne Arrabbiata'], ['Mia', '17', 'Caesar Salad'], ['Ella', '17', 'Tiramisu'], ['Olivia', '17', 'Margherita Pizza'], ['Sophia', '18', 'Vanilla Ice Cream'], ['Ava', '18', 'Tiramisu'], ['Mia', '18', 'Caesar Salad'], ['Ella', '18', 'Vanilla Ice Cream'], ['Olivia', '18', 'Margherita Pizza'], ['Sophia', '19', 'Penne Arrabbiata'], ['Ava', '19', 'Vanilla Ice Cream'], ['Mia', '19', 'Caesar Salad'], ['Ella', '19', 'Margherita Pizza'], ['Olivia', '19', 'Penne Arrabbiata']]) == [['Table', 'Caesar Salad', 'Margherita Pizza', 'Penne Arrabbiata', 'Tiramisu', 'Vanilla Ice Cream'], ['15', '0', '3', '2', '0', '0'], ['16', '3', '0', '2', '0', '0'], ['17', '1', '1', '1', '2', '0'], ['18', '1', '1', '0', '1', '2'], ['19', '1', '1', '2', '0', '1']]\n assert candidate(orders = [['Alice', '10', 'Beef Burrito'], ['Bob', '5', 'Spring Roll'], ['Charlie', '10', 'Spring Roll'], ['David', '3', 'Beef Burrito'], ['Eve', '3', 'Spring Roll'], ['Frank', '5', 'Veggie Delight'], ['Grace', '1', 'Beef Burrito'], ['Heidi', '5', 'Beef Burrito'], ['Ivy', '1', 'Spring Roll'], ['Jack', '3', 'Veggie Delight']]) == [['Table', 'Beef Burrito', 'Spring Roll', 'Veggie Delight'], ['1', '1', '1', '0'], ['3', '1', '1', '1'], ['5', '1', '1', '1'], ['10', '1', '1', '0']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Jerry', '3', 'Spring Roll'], ['Anna', '3', 'Beef Burrito'], ['Tom', '3', 'Veggie Delight'], ['Jerry', '2', 'Spring Roll']]) == [['Table', 'Beef Burrito', 'Spring Roll', 'Veggie Delight'], ['1', '1', '1', '1'], ['2', '1', '1', '1'], ['3', '1', '1', '1']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight']]) == [['Table', 'Beef Burrito', 'Spring Roll', 'Veggie Delight'], ['1', '5', '5', '5'], ['2', '5', '0', '5']]\n assert candidate(orders = [['Zach', '1', 'Spaghetti Carbonara'], ['Kyle', '2', 'Margherita Pizza'], ['Zach', '3', 'Caesar Salad'], ['Kyle', '1', 'Caesar Salad'], ['Zach', '2', 'Margherita Pizza'], ['Kyle', '3', 'Spaghetti Carbonara'], ['Mia', '1', 'Lasagna'], ['Noah', '2', 'Caesar Salad'], ['Mia', '3', 'Margherita Pizza'], ['Noah', '1', 'Spaghetti Carbonara'], ['Mia', '2', 'Lasagna'], ['Noah', '3', 'Caesar Salad'], ['Isabella', '1', 'Margherita Pizza'], ['Oliver', '2', 'Spaghetti Carbonara'], ['Isabella', '3', 'Caesar Salad'], ['Oliver', '1', 'Lasagna'], ['Isabella', '2', 'Margherita Pizza'], ['Oliver', '3', 'Spaghetti Carbonara']]) == [['Table', 'Caesar Salad', 'Lasagna', 'Margherita Pizza', 'Spaghetti Carbonara'], ['1', '1', '2', '1', '2'], ['2', '1', '1', '3', '1'], ['3', '3', '0', '1', '2']]\n assert candidate(orders = [['Amy', '5', 'Taco'], ['Brian', '4', 'Taco'], ['Chris', '5', 'Grilled Cheese'], ['Dan', '4', 'Taco'], ['Eli', '6', 'Grilled Cheese'], ['Fiona', '4', 'Salad'], ['George', '6', 'Salad'], ['Hannah', '4', 'Grilled Cheese'], ['Ian', '5', 'Salad']]) == [['Table', 'Grilled Cheese', 'Salad', 'Taco'], ['4', '1', '1', '2'], ['5', '1', '1', '1'], ['6', '1', '1', '0']]\n assert candidate(orders = [['Zoe', '1', 'Chicken Curry'], ['Jackson', '1', 'Prawn Curry'], ['Ava', '2', 'Chicken Curry'], ['Noah', '2', 'Prawn Curry'], ['James', '2', 'Chicken Curry'], ['Sophia', '3', 'Chicken Curry'], ['Mia', '3', 'Prawn Curry'], ['Emma', '3', 'Chicken Curry'], ['Olivia', '3', 'Chicken Curry'], ['Jackson', '4', 'Chicken Curry'], ['Zoe', '4', 'Prawn Curry'], ['Ava', '4', 'Chicken Curry'], ['Noah', '4', 'Prawn Curry'], ['James', '4', 'Chicken Curry'], ['Sophia', '4', 'Chicken Curry'], ['Mia', '4', 'Prawn Curry'], ['Emma', '4', 'Chicken Curry'], ['Olivia', '4', 'Chicken Curry'], ['Jackson', '5', 'Chicken Curry'], ['Zoe', '5', 'Prawn Curry'], ['Ava', '5', 'Chicken Curry'], ['Noah', '5', 'Prawn Curry'], ['James', '5', 'Chicken Curry'], ['Sophia', '5', 'Chicken Curry'], ['Mia', '5', 'Prawn Curry'], ['Emma', '5', 'Chicken Curry'], ['Olivia', '5', 'Chicken Curry']]) == [['Table', 'Chicken Curry', 'Prawn Curry'], ['1', '1', '1'], ['2', '2', '1'], ['3', '3', '1'], ['4', '6', '3'], ['5', '6', '3']]\n assert candidate(orders = [['Sam', '10', 'Steak'], ['Alex', '20', 'Pasta'], ['Chris', '10', 'Salmon'], ['Rachel', '20', 'Steak'], ['Mike', '30', 'Lasagna'], ['Liz', '10', 'Pasta'], ['Jake', '20', 'Salmon'], ['Amy', '30', 'Steak'], ['Tom', '10', 'Lasagna'], ['Jessica', '20', 'Pasta'], ['Scott', '30', 'Salmon'], ['Melissa', '10', 'Steak'], ['Chris', '20', 'Lasagna'], ['Samantha', '30', 'Pasta'], ['Neil', '10', 'Salmon'], ['James', '20', 'Steak'], ['Ava', '30', 'Lasagna'], ['Eric', '10', 'Pasta'], ['Sophia', '20', 'Salmon'], ['Daniel', '30', 'Steak'], ['Ella', '10', 'Lasagna'], ['Andrew', '20', 'Pasta'], ['Isabella', '30', 'Salmon'], ['Matthew', '10', 'Steak'], ['Olivia', '20', 'Lasagna'], ['William', '30', 'Pasta'], ['Ava', '10', 'Salmon'], ['Mia', '20', 'Steak'], ['Elijah', '30', 'Lasagna'], ['Emma', '10', 'Pasta'], ['Ethan', '20', 'Salmon'], ['Alexander', '30', 'Steak'], ['Sophia', '10', 'Lasagna'], ['Benjamin', '20', 'Pasta'], ['Abigail', '30', 'Salmon'], ['Daniel', '10', 'Steak']]) == [['Table', 'Lasagna', 'Pasta', 'Salmon', 'Steak'], ['10', '3', '3', '3', '4'], ['20', '2', '4', '3', '3'], ['30', '3', '2', '3', '3']]\n assert candidate(orders = [['Michael', '1', 'Margherita Pizza'], ['Emily', '1', 'Caesar Salad'], ['John', '2', 'Margherita Pizza'], ['John', '2', 'Caesar Salad'], ['Sarah', '3', 'Caesar Salad'], ['David', '4', 'Margherita Pizza'], ['David', '4', 'Caesar Salad'], ['David', '4', 'Tiramisu']]) == [['Table', 'Caesar Salad', 'Margherita Pizza', 'Tiramisu'], ['1', '1', '1', '0'], ['2', '1', '1', '0'], ['3', '1', '0', '0'], ['4', '1', '1', '1']]\n assert candidate(orders = [['Anna', '300', 'Eggplant Parmesan'], ['Bob', '300', 'Lasagna'], ['Charlie', '300', 'Eggplant Parmesan'], ['David', '299', 'Lasagna'], ['Eve', '299', 'Eggplant Parmesan'], ['Frank', '298', 'Eggplant Parmesan'], ['Grace', '298', 'Lasagna'], ['Heidi', '298', 'Eggplant Parmesan'], ['Ian', '297', 'Lasagna'], ['Jenny', '297', 'Eggplant Parmesan'], ['Katie', '297', 'Lasagna'], ['Leo', '297', 'Eggplant Parmesan'], ['Mandy', '296', 'Eggplant Parmesan'], ['Neil', '296', 'Lasagna'], ['Oliver', '296', 'Eggplant Parmesan'], ['Paul', '295', 'Eggplant Parmesan'], ['Quincy', '295', 'Lasagna'], ['Rachel', '295', 'Eggplant Parmesan'], ['Steve', '295', 'Lasagna'], ['Tina', '294', 'Eggplant Parmesan'], ['Uma', '294', 'Lasagna'], ['Victor', '294', 'Eggplant Parmesan'], ['Wanda', '294', 'Lasagna'], ['Xander', '293', 'Eggplant Parmesan'], ['Yvonne', '293', 'Lasagna'], ['Zane', '293', 'Eggplant Parmesan'], ['Aaron', '292', 'Eggplant Parmesan'], ['Ben', '292', 'Lasagna'], ['Charlie', '292', 'Eggplant Parmesan'], ['David', '292', 'Lasagna'], ['Eve', '291', 'Eggplant Parmesan'], ['Frank', '291', 'Lasagna'], ['Grace', '291', 'Eggplant Parmesan'], ['Hannah', '291', 'Eggplant Parmesan'], ['Ian', '290', 'Eggplant Parmesan'], ['Jack', '290', 'Lasagna'], ['Karen', '289', 'Eggplant Parmesan'], ['Leo', '289', 'Lasagna'], ['Maggie', '288', 'Eggplant Parmesan'], ['Nancy', '288', 'Lasagna'], ['Oscar', '287', 'Eggplant Parmesan'], ['Paul', '287', 'Lasagna'], ['Quinn', '286', 'Eggplant Parmesan'], ['Rachel', '286', 'Lasagna'], ['Steve', '285', 'Eggplant Parmesan'], ['Tina', '285', 'Lasagna'], ['Uma', '284', 'Eggplant Parmesan'], ['Victor', '284', 'Lasagna'], ['Wanda', '283', 'Eggplant Parmesan'], ['Xander', '283', 'Lasagna'], ['Yvonne', '282', 'Eggplant Parmesan'], ['Zane', '282', 'Lasagna']]) == [['Table', 'Eggplant Parmesan', 'Lasagna'], ['282', '1', '1'], ['283', '1', '1'], ['284', '1', '1'], ['285', '1', '1'], ['286', '1', '1'], ['287', '1', '1'], ['288', '1', '1'], ['289', '1', '1'], ['290', '1', '1'], ['291', '3', '1'], ['292', '2', '2'], ['293', '2', '1'], ['294', '2', '2'], ['295', '2', '2'], ['296', '2', '1'], ['297', '2', '2'], ['298', '2', '1'], ['299', '1', '1'], ['300', '2', '1']]\n assert candidate(orders = [['Sarah', '1', 'Steak'], ['Jessica', '2', 'Pasta'], ['Sarah', '3', 'Sushi'], ['Jessica', '1', 'Sushi'], ['Sarah', '2', 'Pasta'], ['Jessica', '3', 'Steak'], ['Emma', '1', 'Veggie Soup'], ['Olivia', '2', 'Steak'], ['Emma', '3', 'Pasta'], ['Olivia', '1', 'Sushi'], ['Emma', '2', 'Veggie Soup'], ['Olivia', '3', 'Steak'], ['Ava', '1', 'Sushi'], ['Sophia', '2', 'Veggie Soup'], ['Ava', '3', 'Steak'], ['Sophia', '1', 'Pasta'], ['Ava', '2', 'Sushi'], ['Sophia', '3', 'Veggie Soup']]) == [['Table', 'Pasta', 'Steak', 'Sushi', 'Veggie Soup'], ['1', '1', '1', '3', '1'], ['2', '2', '1', '1', '2'], ['3', '1', '3', '1', '1']]\n assert candidate(orders = [['Amy', '100', 'Lasagna'], ['Ben', '150', 'Pasta'], ['Cathy', '100', 'Salad'], ['Dan', '200', 'Lasagna'], ['Eve', '150', 'Pasta'], ['Frank', '200', 'Salad'], ['Grace', '100', 'Pasta'], ['Hank', '150', 'Salad'], ['Ivy', '200', 'Pasta'], ['Jack', '100', 'Salad'], ['Kara', '150', 'Pasta'], ['Liam', '200', 'Lasagna'], ['Mia', '100', 'Pasta'], ['Noam', '150', 'Salad'], ['Olivia', '200', 'Pasta'], ['Paul', '100', 'Salad'], ['Quinn', '150', 'Pasta'], ['Remy', '200', 'Lasagna'], ['Sara', '100', 'Pasta'], ['Tom', '150', 'Salad'], ['Ula', '200', 'Pasta'], ['Victor', '100', 'Salad'], ['Will', '150', 'Pasta'], ['Xena', '200', 'Lasagna'], ['Yara', '100', 'Pasta'], ['Zane', '150', 'Salad']]) == [['Table', 'Lasagna', 'Pasta', 'Salad'], ['100', '1', '4', '4'], ['150', '0', '5', '4'], ['200', '4', '3', '1']]\n assert candidate(orders = [['Jack', '1', 'Steak'], ['Karen', '2', 'Sushi'], ['Leo', '1', 'Sushi'], ['Maggie', '3', 'Steak'], ['Nancy', '2', 'Salmon'], ['Oscar', '3', 'Salmon'], ['Paul', '1', 'Sushi'], ['Quinn', '3', 'Salmon'], ['Rachel', '2', 'Steak'], ['Steve', '1', 'Steak'], ['Tina', '2', 'Salmon'], ['Uma', '3', 'Steak'], ['Victor', '1', 'Sushi'], ['Wanda', '3', 'Salmon'], ['Xander', '2', 'Steak'], ['Yvonne', '1', 'Salmon'], ['Zane', '3', 'Steak']]) == [['Table', 'Salmon', 'Steak', 'Sushi'], ['1', '1', '2', '3'], ['2', '2', '2', '1'], ['3', '3', '3', '0']]\n assert candidate(orders = [['Michael', '10', 'Pasta'], ['Emily', '10', 'Spaghetti Carbonara'], ['Noah', '20', 'Pasta'], ['Olivia', '20', 'Caesar Salad'], ['Daniel', '10', 'Caesar Salad'], ['Ava', '30', 'Spaghetti Carbonara'], ['James', '30', 'Pasta'], ['Sophia', '40', 'Caesar Salad'], ['Benjamin', '40', 'Pasta'], ['Isabella', '10', 'Pasta']]) == [['Table', 'Caesar Salad', 'Pasta', 'Spaghetti Carbonara'], ['10', '1', '2', '1'], ['20', '1', '1', '0'], ['30', '0', '1', '1'], ['40', '1', '1', '0']]\n assert candidate(orders = [['Aaron', '10', 'Fajitas'], ['Ben', '10', 'Margherita Pizza'], ['Charlie', '10', 'Fajitas'], ['Dan', '9', 'Margherita Pizza'], ['Eve', '9', 'Fajitas'], ['Frank', '8', 'Spaghetti Carbonara'], ['Grace', '8', 'Margherita Pizza'], ['Heidi', '8', 'Spaghetti Carbonara'], ['Ian', '7', 'Fajitas'], ['Jenny', '7', 'Margherita Pizza'], ['Katie', '7', 'Spaghetti Carbonara'], ['Leo', '7', 'Margherita Pizza'], ['Mandy', '6', 'Fajitas'], ['Neil', '6', 'Spaghetti Carbonara'], ['Oliver', '6', 'Margherita Pizza'], ['Paul', '5', 'Fajitas'], ['Quincy', '5', 'Margherita Pizza'], ['Rachel', '5', 'Spaghetti Carbonara'], ['Steve', '5', 'Margherita Pizza'], ['Tina', '4', 'Fajitas'], ['Uma', '4', 'Margherita Pizza'], ['Victor', '4', 'Spaghetti Carbonara'], ['Wanda', '4', 'Margherita Pizza'], ['Xander', '3', 'Fajitas'], ['Yvonne', '3', 'Margherita Pizza'], ['Zane', '3', 'Spaghetti Carbonara'], ['Aaron', '2', 'Fajitas'], ['Ben', '2', 'Margherita Pizza'], ['Charlie', '2', 'Spaghetti Carbonara'], ['Dan', '2', 'Margherita Pizza'], ['Eve', '2', 'Fajitas'], ['Frank', '1', 'Spaghetti Carbonara'], ['Grace', '1', 'Margherita Pizza'], ['Heidi', '1', 'Fajitas'], ['Ian', '1', 'Margherita Pizza']]) == [['Table', 'Fajitas', 'Margherita Pizza', 'Spaghetti Carbonara'], ['1', '1', '2', '1'], ['2', '2', '2', '1'], ['3', '1', '1', '1'], ['4', '1', '2', '1'], ['5', '1', '2', '1'], ['6', '1', '1', '1'], ['7', '1', '2', '1'], ['8', '0', '1', '2'], ['9', '1', '1', '0'], ['10', '2', '1', '0']]\n assert candidate(orders = [['Alice', '100', 'Beef Burrito'], ['Bob', '200', 'Chicken Curry'], ['Charlie', '300', 'Shrimp Fried Rice'], ['David', '400', 'Spicy Noodles'], ['Eve', '500', 'Vegetable Stir Fry'], ['Frank', '100', 'Beef Burrito'], ['Grace', '200', 'Chicken Curry'], ['Hank', '300', 'Shrimp Fried Rice'], ['Ivy', '400', 'Spicy Noodles'], ['Jack', '500', 'Vegetable Stir Fry'], ['Kathy', '100', 'Beef Burrito'], ['Leo', '200', 'Chicken Curry'], ['Mona', '300', 'Shrimp Fried Rice'], ['Nate', '400', 'Spicy Noodles'], ['Oscar', '500', 'Vegetable Stir Fry'], ['Paul', '100', 'Beef Burrito'], ['Quinn', '200', 'Chicken Curry'], ['Ruth', '300', 'Shrimp Fried Rice'], ['Steve', '400', 'Spicy Noodles'], ['Tina', '500', 'Vegetable Stir Fry'], ['Uma', '100', 'Beef Burrito'], ['Vera', '200', 'Chicken Curry'], ['Will', '300', 'Shrimp Fried Rice'], ['Xander', '400', 'Spicy Noodles'], ['Yara', '500', 'Vegetable Stir Fry'], ['Zane', '100', 'Beef Burrito']]) == [['Table', 'Beef Burrito', 'Chicken Curry', 'Shrimp Fried Rice', 'Spicy Noodles', 'Vegetable Stir Fry'], ['100', '6', '0', '0', '0', '0'], ['200', '0', '5', '0', '0', '0'], ['300', '0', '0', '5', '0', '0'], ['400', '0', '0', '0', '5', '0'], ['500', '0', '0', '0', '0', '5']]\n assert candidate(orders = [['Amy', '1', 'Spring Roll'], ['Brian', '1', 'Spring Roll'], ['Cathy', '1', 'Spring Roll'], ['David', '1', 'Spring Roll'], ['Eva', '1', 'Spring Roll'], ['Frank', '1', 'Spring Roll'], ['Grace', '1', 'Spring Roll'], ['Henry', '1', 'Spring Roll'], ['Isabella', '1', 'Spring Roll'], ['Jack', '1', 'Spring Roll'], ['Katie', '1', 'Spring Roll'], ['Leo', '1', 'Spring Roll'], ['Mona', '1', 'Spring Roll'], ['Nathan', '1', 'Spring Roll'], ['Olivia', '1', 'Spring Roll'], ['Paul', '1', 'Spring Roll'], ['Quinn', '1', 'Spring Roll'], ['Ryan', '1', 'Spring Roll'], ['Sara', '1', 'Spring Roll'], ['Tina', '1', 'Spring Roll'], ['Uma', '1', 'Spring Roll'], ['Victor', '1', 'Spring Roll'], ['Wendy', '1', 'Spring Roll'], ['Xander', '1', 'Spring Roll'], ['Yara', '1', 'Spring Roll'], ['Zane', '1', 'Spring Roll']]) == [['Table', 'Spring Roll'], ['1', '26']]\n assert candidate(orders = [['Alice', '1', 'Pizza'], ['Bob', '2', 'Pasta'], ['Charlie', '3', 'Pizza'], ['David', '4', 'Salad'], ['Eve', '5', 'Burger'], ['Frank', '1', 'Pasta'], ['Grace', '2', 'Pizza'], ['Hannah', '3', 'Salad'], ['Ian', '4', 'Burger'], ['Jack', '5', 'Pizza']]) == [['Table', 'Burger', 'Pasta', 'Pizza', 'Salad'], ['1', '0', '1', '1', '0'], ['2', '0', '1', '1', '0'], ['3', '0', '0', '1', '1'], ['4', '1', '0', '0', '1'], ['5', '1', '0', '1', '0']]\n assert candidate(orders = [['Aaron', '1', 'Coffee'], ['Aaron', '1', 'Tea'], ['Aaron', '1', 'Juice'], ['Ben', '2', 'Coffee'], ['Ben', '2', 'Tea'], ['Charlie', '3', 'Tea'], ['Charlie', '3', 'Juice'], ['David', '4', 'Coffee'], ['David', '4', 'Tea'], ['David', '4', 'Juice'], ['Eve', '5', 'Coffee'], ['Eve', '5', 'Tea'], ['Eve', '5', 'Juice'], ['Frank', '6', 'Coffee'], ['Frank', '6', 'Tea'], ['Frank', '6', 'Juice'], ['Grace', '7', 'Coffee'], ['Grace', '7', 'Tea'], ['Grace', '7', 'Juice'], ['Hannah', '8', 'Coffee'], ['Hannah', '8', 'Tea'], ['Hannah', '8', 'Juice'], ['Ian', '9', 'Coffee'], ['Ian', '9', 'Tea'], ['Ian', '9', 'Juice'], ['Jack', '10', 'Coffee'], ['Jack', '10', 'Tea'], ['Jack', '10', 'Juice'], ['Katherine', '11', 'Coffee'], ['Katherine', '11', 'Tea'], ['Katherine', '11', 'Juice'], ['Laura', '12', 'Coffee'], ['Laura', '12', 'Tea'], ['Laura', '12', 'Juice'], ['Michael', '13', 'Coffee'], ['Michael', '13', 'Tea'], ['Michael', '13', 'Juice'], ['Nancy', '14', 'Coffee'], ['Nancy', '14', 'Tea'], ['Nancy', '14', 'Juice'], ['Oliver', '15', 'Coffee'], ['Oliver', '15', 'Tea'], ['Oliver', '15', 'Juice'], ['Penelope', '16', 'Coffee'], ['Penelope', '16', 'Tea'], ['Penelope', '16', 'Juice'], ['Quinn', '17', 'Coffee'], ['Quinn', '17', 'Tea'], ['Quinn', '17', 'Juice'], ['Rachel', '18', 'Coffee'], ['Rachel', '18', 'Tea'], ['Rachel', '18', 'Juice'], ['Sam', '19', 'Coffee'], ['Sam', '19', 'Tea'], ['Sam', '19', 'Juice'], ['Trent', '20', 'Coffee'], ['Trent', '20', 'Tea'], ['Trent', '20', 'Juice'], ['Uma', '21', 'Coffee'], ['Uma', '21', 'Tea'], ['Uma', '21', 'Juice'], ['Victor', '22', 'Coffee'], ['Victor', '22', 'Tea'], ['Victor', '22', 'Juice'], ['Wendy', '23', 'Coffee'], ['Wendy', '23', 'Tea'], ['Wendy', '23', 'Juice'], ['Xander', '24', 'Coffee'], ['Xander', '24', 'Tea'], ['Xander', '24', 'Juice'], ['Yvonne', '25', 'Coffee'], ['Yvonne', '25', 'Tea'], ['Yvonne', '25', 'Juice'], ['Zane', '26', 'Coffee'], ['Zane', '26', 'Tea'], ['Zane', '26', 'Juice']]) == [['Table', 'Coffee', 'Juice', 'Tea'], ['1', '1', '1', '1'], ['2', '1', '0', '1'], ['3', '0', '1', '1'], ['4', '1', '1', '1'], ['5', '1', '1', '1'], ['6', '1', '1', '1'], ['7', '1', '1', '1'], ['8', '1', '1', '1'], ['9', '1', '1', '1'], ['10', '1', '1', '1'], ['11', '1', '1', '1'], ['12', '1', '1', '1'], ['13', '1', '1', '1'], ['14', '1', '1', '1'], ['15', '1', '1', '1'], ['16', '1', '1', '1'], ['17', '1', '1', '1'], ['18', '1', '1', '1'], ['19', '1', '1', '1'], ['20', '1', '1', '1'], ['21', '1', '1', '1'], ['22', '1', '1', '1'], ['23', '1', '1', '1'], ['24', '1', '1', '1'], ['25', '1', '1', '1'], ['26', '1', '1', '1']]\n assert candidate(orders = [['William', '1', 'Steak'], ['Harper', '1', 'Mashed Potatoes'], ['Mason', '1', 'Steak'], ['Zoe', '1', 'Mashed Potatoes'], ['Ella', '1', 'Grilled Salmon'], ['Sebastian', '2', 'Steak'], ['Olivia', '2', 'Grilled Salmon'], ['Avery', '2', 'Steak'], ['Isabella', '2', 'Mashed Potatoes'], ['Grayson', '3', 'Grilled Salmon'], ['Scarlett', '3', 'Steak'], ['Sophia', '3', 'Mashed Potatoes'], ['Benjamin', '3', 'Grilled Salmon'], ['Ava', '4', 'Steak'], ['Evelyn', '4', 'Mashed Potatoes'], ['Daniel', '4', 'Grilled Salmon'], ['Amelia', '4', 'Steak'], ['Mia', '5', 'Mashed Potatoes'], ['Ella', '5', 'Steak'], ['Logan', '5', 'Grilled Salmon'], ['Abigail', '5', 'Steak'], ['James', '5', 'Mashed Potatoes'], ['Olivia', '5', 'Grilled Salmon'], ['Avery', '5', 'Steak'], ['Isabella', '5', 'Mashed Potatoes'], ['Mia', '5', 'Grilled Salmon'], ['Ella', '5', 'Steak'], ['Logan', '5', 'Mashed Potatoes']]) == [['Table', 'Grilled Salmon', 'Mashed Potatoes', 'Steak'], ['1', '1', '2', '2'], ['2', '1', '1', '2'], ['3', '2', '1', '1'], ['4', '1', '1', '2'], ['5', '3', '4', '4']]\n assert candidate(orders = [['Eli', '1', 'Pasta'], ['Nina', '2', 'Steak'], ['Eli', '2', 'Salmon'], ['Nina', '1', 'Salmon'], ['Eli', '1', 'Pasta'], ['Nina', '2', 'Pasta'], ['Eli', '2', 'Steak'], ['Nina', '1', 'Pasta'], ['Eli', '1', 'Steak'], ['Nina', '2', 'Salmon'], ['Eli', '2', 'Pasta'], ['Nina', '1', 'Steak'], ['Eli', '1', 'Salmon'], ['Nina', '2', 'Pasta']]) == [['Table', 'Pasta', 'Salmon', 'Steak'], ['1', '3', '2', '2'], ['2', '3', '2', '2']]\n assert candidate(orders = [['Alice', '2', 'Veggie Delight'], ['Bob', '1', 'Salmon'], ['Charlie', '2', 'Salmon'], ['David', '3', 'Veggie Delight'], ['Eve', '3', 'Salmon'], ['Alice', '1', 'Salmon'], ['Bob', '2', 'Veggie Delight'], ['Charlie', '3', 'Salmon'], ['David', '2', 'Veggie Delight'], ['Eve', '1', 'Salmon']]) == [['Table', 'Salmon', 'Veggie Delight'], ['1', '3', '0'], ['2', '1', '3'], ['3', '2', '1']]\n assert candidate(orders = [['Sarah', '1', 'Grilled Cheese'], ['Tom', '2', 'Grilled Cheese'], ['Sarah', '1', 'Caesar Salad'], ['Tom', '2', 'Caesar Salad'], ['Sarah', '1', 'Spaghetti'], ['Tom', '2', 'Spaghetti'], ['Sarah', '1', 'Steak'], ['Tom', '2', 'Steak'], ['Sarah', '1', 'Lasagna'], ['Tom', '2', 'Lasagna'], ['Sarah', '1', 'Pasta'], ['Tom', '2', 'Pasta'], ['Sarah', '1', 'Pizza'], ['Tom', '2', 'Pizza'], ['Sarah', '1', 'Fried Rice'], ['Tom', '2', 'Fried Rice'], ['Sarah', '1', 'Chicken Curry'], ['Tom', '2', 'Chicken Curry'], ['Sarah', '1', 'Fish and Chips'], ['Tom', '2', 'Fish and Chips'], ['Sarah', '1', 'Tacos'], ['Tom', '2', 'Tacos'], ['Sarah', '1', 'Burrito'], ['Tom', '2', 'Burrito'], ['Sarah', '1', 'Sushi'], ['Tom', '2', 'Sushi'], ['Sarah', '1', 'Ramen'], ['Tom', '2', 'Ramen'], ['Sarah', '1', 'Pho'], ['Tom', '2', 'Pho'], ['Sarah', '1', 'Dim Sum'], ['Tom', '2', 'Dim Sum']]) == [['Table', 'Burrito', 'Caesar Salad', 'Chicken Curry', 'Dim Sum', 'Fish and Chips', 'Fried Rice', 'Grilled Cheese', 'Lasagna', 'Pasta', 'Pho', 'Pizza', 'Ramen', 'Spaghetti', 'Steak', 'Sushi', 'Tacos'], ['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'], ['2', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1']]\n assert candidate(orders = [['Laura', '5', 'Bean Burrito'], ['Jhon', '5', 'Beef Burrito'], ['Melissa', '5', 'Soda'], ['Laura', '15', 'Bean Burrito'], ['Jhon', '15', 'Beef Burrito'], ['Melissa', '15', 'Soda'], ['Laura', '25', 'Bean Burrito'], ['Jhon', '25', 'Beef Burrito'], ['Melissa', '25', 'Soda'], ['Laura', '35', 'Bean Burrito'], ['Jhon', '35', 'Beef Burrito'], ['Melissa', '35', 'Soda']]) == [['Table', 'Bean Burrito', 'Beef Burrito', 'Soda'], ['5', '1', '1', '1'], ['15', '1', '1', '1'], ['25', '1', '1', '1'], ['35', '1', '1', '1']]\n assert candidate(orders = [['Laura', '1', 'Bean Burrito'], ['Jhon', '2', 'Beef Burrito'], ['Melissa', '2', 'Soda'], ['Chris', '3', 'Chocolate Cake'], ['Chris', '3', 'Soda'], ['Laura', '3', 'Beef Burrito'], ['Jhon', '1', 'Chocolate Cake'], ['Melissa', '1', 'Bean Burrito']]) == [['Table', 'Bean Burrito', 'Beef Burrito', 'Chocolate Cake', 'Soda'], ['1', '2', '0', '1', '0'], ['2', '0', '1', '0', '1'], ['3', '0', '1', '1', '1']]\n assert candidate(orders = [['Alice', '1', 'Burger'], ['Bob', '1', 'Pasta'], ['Charlie', '2', 'Burger'], ['David', '2', 'Pasta'], ['Eve', '3', 'Burger'], ['Frank', '3', 'Pasta'], ['Grace', '4', 'Burger'], ['Hannah', '4', 'Pasta'], ['Ian', '5', 'Burger'], ['Jack', '5', 'Pasta'], ['Karen', '6', 'Burger'], ['Leo', '6', 'Pasta'], ['Maggie', '7', 'Burger'], ['Nancy', '7', 'Pasta'], ['Oscar', '8', 'Burger'], ['Paul', '8', 'Pasta'], ['Quinn', '9', 'Burger'], ['Rachel', '9', 'Pasta'], ['Steve', '10', 'Burger'], ['Tina', '10', 'Pasta'], ['Uma', '11', 'Burger'], ['Victor', '11', 'Pasta'], ['Wanda', '12', 'Burger'], ['Xander', '12', 'Pasta'], ['Yvonne', '13', 'Burger'], ['Zane', '13', 'Pasta'], ['Aaron', '14', 'Burger'], ['Ben', '14', 'Pasta'], ['Charlie', '15', 'Burger'], ['David', '15', 'Pasta'], ['Eve', '16', 'Burger'], ['Frank', '16', 'Pasta'], ['Grace', '17', 'Burger'], ['Hannah', '17', 'Pasta'], ['Ian', '18', 'Burger'], ['Jack', '18', 'Pasta'], ['Karen', '19', 'Burger'], ['Leo', '19', 'Pasta'], ['Maggie', '20', 'Burger'], ['Nancy', '20', 'Pasta']]) == [['Table', 'Burger', 'Pasta'], ['1', '1', '1'], ['2', '1', '1'], ['3', '1', '1'], ['4', '1', '1'], ['5', '1', '1'], ['6', '1', '1'], ['7', '1', '1'], ['8', '1', '1'], ['9', '1', '1'], ['10', '1', '1'], ['11', '1', '1'], ['12', '1', '1'], ['13', '1', '1'], ['14', '1', '1'], ['15', '1', '1'], ['16', '1', '1'], ['17', '1', '1'], ['18', '1', '1'], ['19', '1', '1'], ['20', '1', '1']]\n assert candidate(orders = [['Daniel', '1', 'Sushi'], ['Julia', '2', 'Tempura'], ['Carlos', '1', 'Sashimi'], ['Sophie', '2', 'Sushi'], ['Christopher', '3', 'Sushi'], ['Mia', '3', 'Sashimi'], ['Nicole', '4', 'Tempura'], ['Alexander', '5', 'Sushi'], ['Oliver', '5', 'Sashimi'], ['Ella', '5', 'Tempura'], ['William', '6', 'Sushi'], ['Amelia', '6', 'Sashimi'], ['Ethan', '6', 'Tempura'], ['Grace', '7', 'Sushi'], ['Jack', '8', 'Tempura'], ['Hannah', '8', 'Sashimi']]) == [['Table', 'Sashimi', 'Sushi', 'Tempura'], ['1', '1', '1', '0'], ['2', '0', '1', '1'], ['3', '1', '1', '0'], ['4', '0', '0', '1'], ['5', '1', '1', '1'], ['6', '1', '1', '1'], ['7', '0', '1', '0'], ['8', '1', '0', '1']]\n assert candidate(orders = [['Michael', '5', 'Spaghetti'], ['John', '1', 'Chicken Wings'], ['Doe', '3', 'Nachos'], ['Michael', '1', 'Caesar Salad'], ['John', '5', 'Nachos'], ['Doe', '1', 'Caesar Salad'], ['Alice', '4', 'Veggie Platter'], ['Bob', '2', 'Caesar Salad'], ['Charlie', '2', 'Spaghetti'], ['David', '3', 'Chicken Wings'], ['Eve', '4', 'Nachos'], ['Frank', '5', 'Veggie Platter']]) == [['Table', 'Caesar Salad', 'Chicken Wings', 'Nachos', 'Spaghetti', 'Veggie Platter'], ['1', '2', '1', '0', '0', '0'], ['2', '1', '0', '0', '1', '0'], ['3', '0', '1', '1', '0', '0'], ['4', '0', '0', '1', '0', '1'], ['5', '0', '0', '1', '1', '1']]\n assert candidate(orders = [['Michael', '10', 'Tomato Soup'], ['Jessica', '10', 'Grilled Cheese'], ['Michael', '10', 'Tomato Soup'], ['Jessica', '10', 'Grilled Cheese'], ['Robert', '20', 'Chicken Salad'], ['Katherine', '20', 'Tomato Soup'], ['Robert', '20', 'Chicken Salad'], ['Katherine', '20', 'Tomato Soup'], ['Robert', '30', 'Grilled Cheese'], ['Katherine', '30', 'Chicken Salad'], ['Robert', '30', 'Grilled Cheese'], ['Katherine', '30', 'Chicken Salad'], ['Robert', '40', 'Tomato Soup'], ['Katherine', '40', 'Grilled Cheese'], ['Robert', '40', 'Tomato Soup'], ['Katherine', '40', 'Grilled Cheese']]) == [['Table', 'Chicken Salad', 'Grilled Cheese', 'Tomato Soup'], ['10', '0', '2', '2'], ['20', '2', '0', '2'], ['30', '2', '2', '0'], ['40', '0', '2', '2']]\n assert candidate(orders = [['Ella', '2', 'Grilled Cheese'], ['Ella', '2', 'Caesar Salad'], ['Finn', '2', 'Grilled Cheese'], ['Gwen', '3', 'Caesar Salad'], ['Hank', '4', 'Grilled Cheese'], ['Izzy', '4', 'Caesar Salad'], ['Jack', '4', 'Grilled Cheese'], ['Kai', '5', 'Caesar Salad'], ['Liam', '6', 'Grilled Cheese'], ['Mia', '6', 'Caesar Salad'], ['Nina', '7', 'Grilled Cheese'], ['Oscar', '7', 'Caesar Salad'], ['Paul', '8', 'Grilled Cheese'], ['Quinn', '8', 'Caesar Salad'], ['Ruth', '9', 'Grilled Cheese'], ['Sam', '9', 'Caesar Salad'], ['Tina', '10', 'Grilled Cheese'], ['Uma', '10', 'Caesar Salad'], ['Victor', '11', 'Grilled Cheese'], ['Wendy', '11', 'Caesar Salad'], ['Xander', '12', 'Grilled Cheese'], ['Yvonne', '12', 'Caesar Salad'], ['Zane', '13', 'Grilled Cheese'], ['Aaron', '13', 'Caesar Salad'], ['Ben', '14', 'Grilled Cheese'], ['Cathy', '14', 'Caesar Salad'], ['Dylan', '15', 'Grilled Cheese'], ['Eva', '15', 'Caesar Salad'], ['Frank', '16', 'Grilled Cheese'], ['Grace', '16', 'Caesar Salad'], ['Hannah', '17', 'Grilled Cheese'], ['Ian', '17', 'Caesar Salad'], ['Jack', '18', 'Grilled Cheese'], ['Kai', '18', 'Caesar Salad'], ['Liam', '19', 'Grilled Cheese'], ['Mia', '19', 'Caesar Salad'], ['Nina', '20', 'Grilled Cheese'], ['Oscar', '20', 'Caesar Salad'], ['Paul', '21', 'Grilled Cheese'], ['Quinn', '21', 'Caesar Salad'], ['Ruth', '22', 'Grilled Cheese'], ['Sam', '22', 'Caesar Salad'], ['Tina', '23', 'Grilled Cheese'], ['Uma', '23', 'Caesar Salad'], ['Victor', '24', 'Grilled Cheese'], ['Wendy', '24', 'Caesar Salad'], ['Xander', '25', 'Grilled Cheese'], ['Yvonne', '25', 'Caesar Salad'], ['Zane', '26', 'Grilled Cheese'], ['Aaron', '26', 'Caesar Salad'], ['Ben', '27', 'Grilled Cheese'], ['Cathy', '27', 'Caesar Salad'], ['Dylan', '28', 'Grilled Cheese'], ['Eva', '28', 'Caesar Salad'], ['Frank', '29', 'Grilled Cheese'], ['Grace', '29', 'Caesar Salad'], ['Hannah', '30', 'Grilled Cheese'], ['Ian', '30', 'Caesar Salad']]) == [['Table', 'Caesar Salad', 'Grilled Cheese'], ['2', '1', '2'], ['3', '1', '0'], ['4', '1', '2'], ['5', '1', '0'], ['6', '1', '1'], ['7', '1', '1'], ['8', '1', '1'], ['9', '1', '1'], ['10', '1', '1'], ['11', '1', '1'], ['12', '1', '1'], ['13', '1', '1'], ['14', '1', '1'], ['15', '1', '1'], ['16', '1', '1'], ['17', '1', '1'], ['18', '1', '1'], ['19', '1', '1'], ['20', '1', '1'], ['21', '1', '1'], ['22', '1', '1'], ['23', '1', '1'], ['24', '1', '1'], ['25', '1', '1'], ['26', '1', '1'], ['27', '1', '1'], ['28', '1', '1'], ['29', '1', '1'], ['30', '1', '1']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Jerry', '3', 'Spring Roll'], ['Anna', '4', 'Pasta'], ['Tom', '5', 'Pizza'], ['Jerry', '6', 'Salad'], ['Anna', '7', 'Burger'], ['Tom', '8', 'Fried Chicken'], ['Jerry', '9', 'Water'], ['Anna', '10', 'Ceviche'], ['Tom', '11', 'Beef Burrito'], ['Jerry', '12', 'Veggie Delight'], ['Anna', '13', 'Pizza'], ['Tom', '14', 'Salad'], ['Jerry', '15', 'Burger'], ['Anna', '16', 'Fried Chicken'], ['Tom', '17', 'Water'], ['Jerry', '18', 'Ceviche'], ['Anna', '19', 'Beef Burrito'], ['Tom', '20', 'Veggie Delight']]) == [['Table', 'Beef Burrito', 'Burger', 'Ceviche', 'Fried Chicken', 'Pasta', 'Pizza', 'Salad', 'Spring Roll', 'Veggie Delight', 'Water'], ['1', '1', '0', '0', '0', '0', '0', '0', '1', '1', '0'], ['2', '1', '0', '0', '0', '0', '0', '0', '0', '1', '0'], ['3', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0'], ['4', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0'], ['5', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0'], ['6', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0'], ['7', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0'], ['8', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0'], ['9', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1'], ['10', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0'], ['11', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0'], ['12', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0'], ['13', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0'], ['14', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0'], ['15', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0'], ['16', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0'], ['17', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1'], ['18', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0'], ['19', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0'], ['20', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0']]\n assert candidate(orders = [['Alice', '1', 'Beef Burrito'], ['Bob', '2', 'Chicken Curry'], ['Charlie', '3', 'Shrimp Fried Rice'], ['David', '4', 'Spicy Noodles'], ['Eve', '5', 'Vegetable Stir Fry'], ['Frank', '6', 'Beef Burrito'], ['Grace', '7', 'Chicken Curry'], ['Hank', '8', 'Shrimp Fried Rice'], ['Ivy', '9', 'Spicy Noodles'], ['Jack', '10', 'Vegetable Stir Fry'], ['Kathy', '1', 'Beef Burrito'], ['Leo', '2', 'Chicken Curry'], ['Mona', '3', 'Shrimp Fried Rice'], ['Nate', '4', 'Spicy Noodles'], ['Oscar', '5', 'Vegetable Stir Fry'], ['Paul', '6', 'Beef Burrito'], ['Quinn', '7', 'Chicken Curry'], ['Ruth', '8', 'Shrimp Fried Rice'], ['Steve', '9', 'Spicy Noodles'], ['Tina', '10', 'Vegetable Stir Fry']]) == [['Table', 'Beef Burrito', 'Chicken Curry', 'Shrimp Fried Rice', 'Spicy Noodles', 'Vegetable Stir Fry'], ['1', '2', '0', '0', '0', '0'], ['2', '0', '2', '0', '0', '0'], ['3', '0', '0', '2', '0', '0'], ['4', '0', '0', '0', '2', '0'], ['5', '0', '0', '0', '0', '2'], ['6', '2', '0', '0', '0', '0'], ['7', '0', '2', '0', '0', '0'], ['8', '0', '0', '2', '0', '0'], ['9', '0', '0', '0', '2', '0'], ['10', '0', '0', '0', '0', '2']]\n assert candidate(orders = [['John', '10', 'Lobster'], ['Paul', '12', 'Grilled Chicken'], ['John', '12', 'Lobster'], ['Paul', '10', 'Grilled Chicken'], ['John', '10', 'Grilled Chicken'], ['Paul', '12', 'Lobster'], ['John', '12', 'Grilled Chicken'], ['Paul', '10', 'Lobster'], ['John', '10', 'Lobster'], ['Paul', '12', 'Grilled Chicken']]) == [['Table', 'Grilled Chicken', 'Lobster'], ['10', '2', '3'], ['12', '3', '2']]\n assert candidate(orders = [['Emma', '5', 'Chicken Tikka Masala'], ['James', '5', 'Chicken Tikka Masala'], ['Oliver', '5', 'Chicken Tikka Masala'], ['Noah', '5', 'Chicken Tikka Masala'], ['Amelia', '5', 'Chicken Tikka Masala'], ['Olivia', '6', 'Chicken Tikka Masala'], ['Ava', '6', 'Chicken Tikka Masala'], ['Isabella', '6', 'Chicken Tikka Masala'], ['Sophia', '6', 'Chicken Tikka Masala'], ['Isaac', '6', 'Chicken Tikka Masala'], ['Oliver', '7', 'Chicken Tikka Masala'], ['Elijah', '7', 'Chicken Tikka Masala'], ['Noah', '7', 'Chicken Tikka Masala'], ['James', '7', 'Chicken Tikka Masala'], ['Olivia', '7', 'Chicken Tikka Masala'], ['Emma', '8', 'Chicken Tikka Masala'], ['Isabella', '8', 'Chicken Tikka Masala'], ['Amelia', '8', 'Chicken Tikka Masala'], ['Sophia', '8', 'Chicken Tikka Masala'], ['Isaac', '8', 'Chicken Tikka Masala'], ['Ava', '8', 'Chicken Tikka Masala'], ['Elijah', '8', 'Chicken Tikka Masala'], ['James', '8', 'Chicken Tikka Masala'], ['Oliver', '8', 'Chicken Tikka Masala'], ['Noah', '8', 'Chicken Tikka Masala'], ['Amelia', '8', 'Chicken Tikka Masala'], ['Olivia', '8', 'Chicken Tikka Masala']]) == [['Table', 'Chicken Tikka Masala'], ['5', '5'], ['6', '5'], ['7', '5'], ['8', '12']]\n assert candidate(orders = [['Will', '500', 'Mushroom Risotto'], ['Sam', '499', 'Steak'], ['Greg', '498', 'Salmon'], ['May', '497', 'Vegetable Lasagna'], ['Diana', '496', 'Mushroom Risotto'], ['Tom', '495', 'Steak'], ['Jenny', '494', 'Salmon'], ['Chris', '493', 'Vegetable Lasagna'], ['Lucas', '492', 'Mushroom Risotto'], ['Sarah', '491', 'Steak'], ['Joe', '490', 'Salmon'], ['Karen', '489', 'Vegetable Lasagna'], ['Matt', '488', 'Mushroom Risotto'], ['Lisa', '487', 'Steak'], ['Scott', '486', 'Salmon'], ['Rachel', '485', 'Vegetable Lasagna'], ['Mark', '484', 'Mushroom Risotto'], ['Beth', '483', 'Steak'], ['Dave', '482', 'Salmon'], ['Nancy', '481', 'Vegetable Lasagna'], ['Ken', '480', 'Mushroom Risotto'], ['Jan', '479', 'Steak'], ['Jill', '478', 'Salmon'], ['Gregory', '477', 'Vegetable Lasagna'], ['Christina', '476', 'Mushroom Risotto'], ['Kevin', '475', 'Steak'], ['Laura', '474', 'Salmon'], ['Megan', '473', 'Vegetable Lasagna'], ['Ryan', '472', 'Mushroom Risotto'], ['Amanda', '471', 'Steak'], ['Charles', '470', 'Salmon'], ['Rebecca', '469', 'Vegetable Lasagna'], ['Andrew', '468', 'Mushroom Risotto'], ['Jessica', '467', 'Steak'], ['Arthur', '466', 'Salmon'], ['Shirley', '465', 'Vegetable Lasagna'], ['Daniel', '464', 'Mushroom Risotto'], ['Emma', '463', 'Steak'], ['Christopher', '462', 'Salmon'], ['Nicole', '461', 'Vegetable Lasagna'], ['Scott', '460', 'Mushroom Risotto'], ['Melissa', '459', 'Steak'], ['Robert', '458', 'Salmon'], ['Michelle', '457', 'Vegetable Lasagna'], ['John', '456', 'Mushroom Risotto'], ['Brenda', '455', 'Steak'], ['Steve', '454', 'Salmon'], ['Anna', '453', 'Vegetable Lasagna']]) == [['Table', 'Mushroom Risotto', 'Salmon', 'Steak', 'Vegetable Lasagna'], ['453', '0', '0', '0', '1'], ['454', '0', '1', '0', '0'], ['455', '0', '0', '1', '0'], ['456', '1', '0', '0', '0'], ['457', '0', '0', '0', '1'], ['458', '0', '1', '0', '0'], ['459', '0', '0', '1', '0'], ['460', '1', '0', '0', '0'], ['461', '0', '0', '0', '1'], ['462', '0', '1', '0', '0'], ['463', '0', '0', '1', '0'], ['464', '1', '0', '0', '0'], ['465', '0', '0', '0', '1'], ['466', '0', '1', '0', '0'], ['467', '0', '0', '1', '0'], ['468', '1', '0', '0', '0'], ['469', '0', '0', '0', '1'], ['470', '0', '1', '0', '0'], ['471', '0', '0', '1', '0'], ['472', '1', '0', '0', '0'], ['473', '0', '0', '0', '1'], ['474', '0', '1', '0', '0'], ['475', '0', '0', '1', '0'], ['476', '1', '0', '0', '0'], ['477', '0', '0', '0', '1'], ['478', '0', '1', '0', '0'], ['479', '0', '0', '1', '0'], ['480', '1', '0', '0', '0'], ['481', '0', '0', '0', '1'], ['482', '0', '1', '0', '0'], ['483', '0', '0', '1', '0'], ['484', '1', '0', '0', '0'], ['485', '0', '0', '0', '1'], ['486', '0', '1', '0', '0'], ['487', '0', '0', '1', '0'], ['488', '1', '0', '0', '0'], ['489', '0', '0', '0', '1'], ['490', '0', '1', '0', '0'], ['491', '0', '0', '1', '0'], ['492', '1', '0', '0', '0'], ['493', '0', '0', '0', '1'], ['494', '0', '1', '0', '0'], ['495', '0', '0', '1', '0'], ['496', '1', '0', '0', '0'], ['497', '0', '0', '0', '1'], ['498', '0', '1', '0', '0'], ['499', '0', '0', '1', '0'], ['500', '1', '0', '0', '0']]\n assert candidate(orders = [['Alice', '1', 'Pizza'], ['Bob', '2', 'Burger'], ['Charlie', '3', 'Sushi'], ['David', '1', 'Salad'], ['Eve', '2', 'Pizza'], ['Frank', '3', 'Burger'], ['Grace', '1', 'Sushi'], ['Heidi', '2', 'Salad'], ['Ivy', '3', 'Pizza'], ['Jack', '1', 'Burger'], ['Kara', '2', 'Sushi'], ['Liam', '3', 'Salad'], ['Mia', '1', 'Pizza'], ['Nina', '2', 'Burger'], ['Oscar', '3', 'Sushi'], ['Paul', '1', 'Salad'], ['Quinn', '2', 'Pizza'], ['Rachel', '3', 'Burger'], ['Steve', '1', 'Sushi'], ['Tina', '2', 'Salad'], ['Uma', '3', 'Pizza'], ['Victor', '1', 'Burger'], ['Wendy', '2', 'Sushi'], ['Xavier', '3', 'Salad'], ['Yara', '1', 'Pizza'], ['Zane', '2', 'Burger']]) == [['Table', 'Burger', 'Pizza', 'Salad', 'Sushi'], ['1', '2', '3', '2', '2'], ['2', '3', '2', '2', '2'], ['3', '2', '2', '2', '2']]\n assert candidate(orders = [['Leo', '1', 'Fish and Chips'], ['Mia', '2', 'Fish and Chips'], ['Leo', '3', 'Caesar Salad'], ['Mia', '1', 'Caesar Salad'], ['Leo', '2', 'Fish and Chips'], ['Mia', '3', 'Caesar Salad'], ['Ava', '1', 'Club Sandwich'], ['Sophia', '2', 'Caesar Salad'], ['Ava', '3', 'Fish and Chips'], ['Sophia', '1', 'Club Sandwich'], ['Ava', '2', 'Caesar Salad'], ['Sophia', '3', 'Fish and Chips'], ['Isabella', '1', 'Fish and Chips'], ['Oliver', '2', 'Club Sandwich'], ['Isabella', '3', 'Caesar Salad'], ['Oliver', '1', 'Fish and Chips'], ['Isabella', '2', 'Caesar Salad'], ['Oliver', '3', 'Club Sandwich']]) == [['Table', 'Caesar Salad', 'Club Sandwich', 'Fish and Chips'], ['1', '1', '2', '3'], ['2', '3', '1', '2'], ['3', '3', '1', '2']]\n assert candidate(orders = [['David', '3', 'Ceviche'], ['Corina', '10', 'Beef Burrito'], ['David', '3', 'Fried Chicken'], ['Carla', '5', 'Water'], ['Carla', '5', 'Ceviche'], ['Rous', '3', 'Ceviche'], ['David', '5', 'Beef Burrito'], ['Carla', '3', 'Fried Chicken'], ['Rous', '5', 'Spring Roll']]) == [['Table', 'Beef Burrito', 'Ceviche', 'Fried Chicken', 'Spring Roll', 'Water'], ['3', '0', '2', '2', '0', '0'], ['5', '1', '1', '0', '1', '1'], ['10', '1', '0', '0', '0', '0']]\n assert candidate(orders = [['Alexander', '50', 'Fruit Salad'], ['Dominic', '51', 'Pancakes'], ['Alexander', '50', 'Fruit Salad'], ['Dominic', '51', 'Pancakes'], ['Elizabeth', '52', 'Tomato Soup'], ['Alexander', '50', 'Tomato Soup'], ['Dominic', '51', 'Tomato Soup'], ['Elizabeth', '52', 'Pancakes'], ['Alexander', '50', 'Pancakes'], ['Dominic', '51', 'Fruit Salad'], ['Elizabeth', '52', 'Fruit Salad'], ['Alexander', '50', 'Chicken Salad'], ['Dominic', '51', 'Chicken Salad'], ['Elizabeth', '52', 'Chicken Salad']]) == [['Table', 'Chicken Salad', 'Fruit Salad', 'Pancakes', 'Tomato Soup'], ['50', '1', '2', '1', '1'], ['51', '1', '1', '2', '1'], ['52', '1', '1', '1', '1']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Bob', '3', 'Chicken Curry'], ['Charlie', '4', 'Shrimp Fried Rice'], ['David', '5', 'Spicy Noodles'], ['Eve', '6', 'Vegetable Stir Fry'], ['Frank', '1', 'Spring Roll'], ['Grace', '2', 'Beef Burrito'], ['Hank', '3', 'Chicken Curry'], ['Ivy', '4', 'Shrimp Fried Rice'], ['Jack', '5', 'Spicy Noodles'], ['Kathy', '6', 'Vegetable Stir Fry'], ['Leo', '1', 'Spring Roll'], ['Mona', '2', 'Beef Burrito'], ['Nate', '3', 'Chicken Curry'], ['Oscar', '4', 'Shrimp Fried Rice'], ['Paul', '5', 'Spicy Noodles'], ['Quinn', '6', 'Vegetable Stir Fry'], ['Ruth', '1', 'Spring Roll'], ['Steve', '2', 'Beef Burrito'], ['Tina', '3', 'Chicken Curry'], ['Uma', '4', 'Shrimp Fried Rice'], ['Vera', '5', 'Spicy Noodles'], ['Will', '6', 'Vegetable Stir Fry']]) == [['Table', 'Beef Burrito', 'Chicken Curry', 'Shrimp Fried Rice', 'Spicy Noodles', 'Spring Roll', 'Vegetable Stir Fry', 'Veggie Delight'], ['1', '1', '0', '0', '0', '4', '0', '1'], ['2', '4', '0', '0', '0', '0', '0', '1'], ['3', '0', '4', '0', '0', '0', '0', '0'], ['4', '0', '0', '4', '0', '0', '0', '0'], ['5', '0', '0', '0', '4', '0', '0', '0'], ['6', '0', '0', '0', '0', '0', '4', '0']]\n assert candidate(orders = [['Sarah', '101', 'Spaghetti Carbonara'], ['John', '202', 'Caesar Salad'], ['Sarah', '101', 'Caesar Salad'], ['Alice', '303', 'Grilled Salmon'], ['Bob', '202', 'Grilled Salmon'], ['Sarah', '101', 'Spaghetti Carbonara'], ['Alice', '303', 'Caesar Salad'], ['Bob', '202', 'Spaghetti Carbonara'], ['Charlie', '404', 'Grilled Salmon'], ['Charlie', '404', 'Caesar Salad'], ['Charlie', '404', 'Spaghetti Carbonara']]) == [['Table', 'Caesar Salad', 'Grilled Salmon', 'Spaghetti Carbonara'], ['101', '1', '0', '2'], ['202', '1', '1', '1'], ['303', '1', '1', '0'], ['404', '1', '1', '1']]\n"}, "metadata": {"canonical_parameter_names": ["orders"], "leetcode_dataset_entry_point": "Solution().displayTable", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def displayTable(self, orders: List[List[str]]) -> List[List[str]]:", "container": "Solution", "callable": "displayTable", "parameters": [{"name": "orders", "type": "List[List[str]]"}], "return_type": "List[List[str]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1419, "task_id": "minimum-number-of-frogs-croaking", "difficulty": "Medium", "problem_description": "You are given the string croakOfFrogs, which represents a combination of the string \"croak\" from different frogs, that is, multiple frogs can croak at the same time, so multiple \"croak\" are mixed.\nReturn the minimum number of different frogs to finish all the croaks in the given string.\nA valid \"croak\" means a frog is printing five letters 'c', 'r', 'o', 'a', and 'k' sequentially. The frogs have to print all five letters to finish a croak. If the given string is not a combination of a valid \"croak\" return -1.\n \nExample 1:\n\nInput: croakOfFrogs = \"croakcroak\"\nOutput: 1 \nExplanation: One frog yelling \"croak\" twice.\n\nExample 2:\n\nInput: croakOfFrogs = \"crcoakroak\"\nOutput: 2 \nExplanation: The minimum number of frogs is two. \nThe first frog could yell \"crcoakroak\".\nThe second frog could yell later \"crcoakroak\".\n\nExample 3:\n\nInput: croakOfFrogs = \"croakcrook\"\nOutput: -1\nExplanation: The given string is an invalid combination of \"croak\" from different frogs.\n\n \nConstraints:\n\n1 <= croakOfFrogs.length <= 105\ncroakOfFrogs is either 'c', 'r', 'o', 'a', or 'k'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(croakOfFrogs = \"croakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"croak\") == 1\n assert candidate(croakOfFrogs = \"cccrroooaaakkk\") == -1\n assert candidate(croakOfFrogs = \"crcoakroak\") == 2\n assert candidate(croakOfFrogs = \"crrcooakak\") == -1\n assert candidate(croakOfFrogs = \"k\") == -1\n assert candidate(croakOfFrogs = \"crocakroak\") == 2\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkk\") == 4\n assert candidate(croakOfFrogs = \"crrrroooaaaakkk\") == -1\n assert candidate(croakOfFrogs = \"ccroooakk\") == -1\n assert candidate(croakOfFrogs = \"ccroakroak\") == 2\n assert candidate(croakOfFrogs = \"crrrroooookkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrroooaaaaakkkkkk\") == -1\n assert candidate(croakOfFrogs = \"kakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakak\") == -1\n assert candidate(croakOfFrogs = \"ccccroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"kkkrrrooocccaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrroooaaaaakkkkk\") == -1\n assert candidate(croakOfFrogs = \"croakcrook\") == -1\n assert candidate(croakOfFrogs = \"crorocroakakak\") == -1\n assert candidate(croakOfFrogs = \"crocroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"c\") == -1\n assert candidate(croakOfFrogs = \"crorocakak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrroooaaaakkk\") == -1\n assert candidate(croakOfFrogs = \"kroac\") == -1\n assert candidate(croakOfFrogs = \"crocak\") == -1\n assert candidate(croakOfFrogs = \"crcroaoakk\") == 2\n assert candidate(croakOfFrogs = \"kraoc\") == -1\n assert candidate(croakOfFrogs = \"ccccrrooookkkk\") == -1\n assert candidate(croakOfFrogs = \"\") == 0\n assert candidate(croakOfFrogs = \"ccrroookkaak\") == -1\n assert candidate(croakOfFrogs = \"crocroakakroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroak\") == 1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaaaaaaaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccccroooooorrrraaaaaakkkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrrrroooooooooookkkkkkkkaaaaaaaaaacrrrrrrroooooooooookkkkkkkkaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakccccrrroooookkkkroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcrocroakcroak\") == -1\n assert candidate(croakOfFrogs = \"cccrroooakkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"crocakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"croakccroakrrrooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrooookaaaakkkkk\") == -1\n assert candidate(croakOfFrogs = \"crocakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakkkkroakkkkroakkkk\") == -1\n assert candidate(croakOfFrogs = \"croakkkkkkkkkk\") == -1\n assert candidate(croakOfFrogs = \"crrrroookaaaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crcrooakakro\") == -1\n assert candidate(croakOfFrogs = \"crocakroakcroakcroakcroakcroak\") == 2\n assert candidate(croakOfFrogs = \"crocroakcroakccccrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooooookkkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkkccrrrrooooaaaakkkkccrrrrooooaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"crcrccrooaaakk\") == -1\n assert candidate(croakOfFrogs = \"cccrrooookkkkraaacroak\") == -1\n assert candidate(croakOfFrogs = \"croakccroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crrroooookkkkaaaakkk\") == -1\n assert candidate(croakOfFrogs = \"cccrooookkkkrrrooookkkk\") == -1\n assert candidate(croakOfFrogs = \"crrrcroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakccroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcroakcroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrroooookkkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"crocroakcrocroakcrocroak\") == -1\n assert candidate(croakOfFrogs = \"croakkkkrooocrakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"crocakrocakrocak\") == -1\n assert candidate(croakOfFrogs = \"croakcrocakcroakcrocakcrocak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkkccccrrrrooooaaaakkkkccccrrrrooooaaaakkkkccccrrrrooooaaaakkkk\") == 4\n assert candidate(croakOfFrogs = \"croakkkkrooocrakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcoakrcoak\") == -1\n assert candidate(croakOfFrogs = \"crrrrooooookkkkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaaaaakkkakkkakkk\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaaaaakkkakkk\") == -1\n assert candidate(croakOfFrogs = \"crorocokakak\") == -1\n assert candidate(croakOfFrogs = \"crrrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcrrooakroakroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakkaakrook\") == -1\n assert candidate(croakOfFrogs = \"crocakroakroakroakroakroakroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakokcrcrooakrakokcrcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"ccccrooookaaaakkkkkkk\") == -1\n assert candidate(croakOfFrogs = \"ccrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakccrookraaaakkk\") == -1\n assert candidate(croakOfFrogs = \"ccccccccrrrrrroooooookkkkkkkkkkkaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"crocroakkkk\") == -1\n assert candidate(croakOfFrogs = \"croakrcoakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakkkkrooocrakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crocrocrocrocroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crrrroooookkkkaaaak\") == -1\n assert candidate(croakOfFrogs = \"croakkkkkkrrroooooooaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"crcoakroakcrcoakroak\") == 2\n assert candidate(croakOfFrogs = \"crocrocrocrocrocroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crocakroakcroakcroak\") == 2\n assert candidate(croakOfFrogs = \"crcrcooakokrakraokakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrrroooookkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"croakkkkkkkkkkroakroakroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccccccroooooorrrraaaaaakkkkkkk\") == -1\n assert candidate(croakOfFrogs = \"crcroakroakcrcoak\") == -1\n assert candidate(croakOfFrogs = \"ccrrroooookkkkaaaak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcroakcroakcroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcoakrcoakrcoak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooookkkkaaaakkkkroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccccccrrrrrrrrrrroooooooooookkkkkkkkaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccrooakrkkaocroakcraok\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakokcrcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"crorarokkorakocraok\") == -1\n assert candidate(croakOfFrogs = \"croakroakroakcroakroakroakroakcroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"cccrroooraaakk\") == -1\n assert candidate(croakOfFrogs = \"crocrocrocrocroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccccroooraaaakkkkk\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcrorocroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrrrroooookkkkaaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaarrrkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaaaaakkkaaa\") == -1\n assert candidate(croakOfFrogs = \"crrrrrrrrroooooooooookkkkkkkkaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"ccrroooaakkccrooakaakk\") == -1\n assert candidate(croakOfFrogs = \"ccrrroooookkkkaaaacccrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccroakcroakcroakroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakakroccrooakakro\") == -1\n assert candidate(croakOfFrogs = \"croakcroakroakroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crocrokakakcroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkkccccrrrrooooaaaakkkkccccrrrrooooaaaakkkk\") == 4\n assert candidate(croakOfFrogs = \"ccroakccroakccroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkkk\") == -1\n assert candidate(croakOfFrogs = \"cccrroooookkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"crrrroooookkkkac\") == -1\n assert candidate(croakOfFrogs = \"crorokokokakakc\") == -1\n assert candidate(croakOfFrogs = \"crocakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrrooookkkkaaacrrrooookkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccrroookkaaa\") == -1\n assert candidate(croakOfFrogs = \"crrrooookkkk\") == -1\n assert candidate(croakOfFrogs = \"crocrokakakcroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccrroooaakkccrooakaakkccrroooaakk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaacrrroooookkkkaaaacrrroooookkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"crcrrooookkkaaa\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrrcroakroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crrroookkkkrrroooookkkk\") == -1\n assert candidate(croakOfFrogs = \"crrrooookkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"crocrokrocroakakak\") == -1\n assert candidate(croakOfFrogs = \"crrookkcraaacroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcrcooakokrakraokak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcrocroakcrocroakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakccroooaakk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrrrrooooooookkkkkkkaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcroakccroaaaakkk\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakroakroakroakroakroakroakroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrroooookkkkaaaakkkkkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooookkkkaaakk\") == -1\n assert candidate(croakOfFrogs = \"crrcroakroakcroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrroooookkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakcrocakcroakcrocak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkkccccrrrrooooaaaakkkk\") == 4\n assert candidate(croakOfFrogs = \"croakcroakcrcoakroakcrocroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakakroccrooakakroccrooakakro\") == -1\n assert candidate(croakOfFrogs = \"crocakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakkkcroak\") == -1\n assert candidate(croakOfFrogs = \"ccroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrooorkkkaa\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakokcrcrooakrakokcrcrooakrakokcrcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakokcrcrooakrakokcrcrooakrakokcrcrooakrakokcrcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"cccroooraakk\") == -1\n assert candidate(croakOfFrogs = \"crrrooookkkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crrroookkkkrrroooookkkkrrroooookkkk\") == -1\n assert candidate(croakOfFrogs = \"crocrocrocroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crocrocrocrocrocrocrocrocrocrocrocrocroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"crrrooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crrrrroooookkkkaaaaacrrrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooookkkkaaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"cccroaaakkkkroooraak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcrocroakroak\") == -1\n assert candidate(croakOfFrogs = \"crcroakroakroakroakroakroak\") == -1\n"}, "metadata": {"canonical_parameter_names": ["croakOfFrogs"], "leetcode_dataset_entry_point": "Solution().minNumberOfFrogs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minNumberOfFrogs(self, croakOfFrogs: str) -> int:", "container": "Solution", "callable": "minNumberOfFrogs", "parameters": [{"name": "croakOfFrogs", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1420, "task_id": "build-array-where-you-can-find-the-maximum-exactly-k-comparisons", "difficulty": "Hard", "problem_description": "You are given three integers n, m and k. Consider the following algorithm to find the maximum element of an array of positive integers:\n\nYou should build the array arr which has the following properties:\n\narr has exactly n integers.\n1 <= arr[i] <= m where (0 <= i < n).\nAfter applying the mentioned algorithm to arr, the value search_cost is equal to k.\n\nReturn the number of ways to build the array arr under the mentioned conditions. As the answer may grow large, the answer must be computed modulo 109 + 7.\n \nExample 1:\n\nInput: n = 2, m = 3, k = 1\nOutput: 6\nExplanation: The possible arrays are [1, 1], [2, 1], [2, 2], [3, 1], [3, 2] [3, 3]\n\nExample 2:\n\nInput: n = 5, m = 2, k = 3\nOutput: 0\nExplanation: There are no possible arrays that satisfy the mentioned conditions.\n\nExample 3:\n\nInput: n = 9, m = 1, k = 1\nOutput: 1\nExplanation: The only possible array is [1, 1, 1, 1, 1, 1, 1, 1, 1]\n\n \nConstraints:\n\n1 <= n <= 50\n1 <= m <= 100\n0 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,m = 1,k = 1) == 1\n assert candidate(n = 4,m = 5,k = 2) == 305\n assert candidate(n = 3,m = 3,k = 0) == 0\n assert candidate(n = 3,m = 5,k = 2) == 60\n assert candidate(n = 5,m = 2,k = 3) == 0\n assert candidate(n = 4,m = 4,k = 2) == 125\n assert candidate(n = 1,m = 1,k = 0) == 0\n assert candidate(n = 50,m = 100,k = 50) == 538992043\n assert candidate(n = 10,m = 10,k = 5) == 282622725\n assert candidate(n = 4,m = 4,k = 0) == 0\n assert candidate(n = 2,m = 3,k = 1) == 6\n assert candidate(n = 50,m = 100,k = 0) == 0\n assert candidate(n = 9,m = 1,k = 1) == 1\n assert candidate(n = 40,m = 30,k = 20) == 620836495\n assert candidate(n = 25,m = 10,k = 15) == 0\n assert candidate(n = 45,m = 5,k = 2) == 741424886\n assert candidate(n = 40,m = 20,k = 15) == 992287753\n assert candidate(n = 50,m = 50,k = 25) == 60065601\n assert candidate(n = 10,m = 4,k = 3) == 241950\n assert candidate(n = 25,m = 10,k = 5) == 513807183\n assert candidate(n = 10,m = 1,k = 0) == 0\n assert candidate(n = 20,m = 15,k = 19) == 0\n assert candidate(n = 10,m = 5,k = 4) == 595775\n assert candidate(n = 6,m = 3,k = 3) == 90\n assert candidate(n = 40,m = 15,k = 7) == 487352486\n assert candidate(n = 30,m = 10,k = 10) == 967895731\n assert candidate(n = 35,m = 50,k = 15) == 67294554\n assert candidate(n = 15,m = 3,k = 2) == 7174452\n assert candidate(n = 25,m = 5,k = 5) == 957053963\n assert candidate(n = 50,m = 100,k = 25) == 34549172\n assert candidate(n = 35,m = 25,k = 5) == 706635531\n assert candidate(n = 50,m = 50,k = 50) == 1\n assert candidate(n = 30,m = 30,k = 15) == 153434023\n assert candidate(n = 5,m = 5,k = 3) == 585\n assert candidate(n = 15,m = 8,k = 4) == 997233503\n assert candidate(n = 25,m = 2,k = 1) == 16777217\n assert candidate(n = 35,m = 1,k = 1) == 1\n assert candidate(n = 15,m = 7,k = 5) == 128631420\n assert candidate(n = 35,m = 50,k = 20) == 604238599\n assert candidate(n = 30,m = 20,k = 10) == 91721467\n assert candidate(n = 15,m = 30,k = 7) == 115201714\n assert candidate(n = 25,m = 40,k = 9) == 701520657\n assert candidate(n = 40,m = 25,k = 6) == 775163810\n assert candidate(n = 40,m = 25,k = 20) == 121510237\n assert candidate(n = 5,m = 100,k = 3) == 874379186\n assert candidate(n = 42,m = 50,k = 15) == 300194714\n assert candidate(n = 15,m = 15,k = 7) == 687790825\n assert candidate(n = 30,m = 50,k = 10) == 467663134\n assert candidate(n = 45,m = 50,k = 18) == 362047302\n assert candidate(n = 20,m = 15,k = 10) == 836223400\n assert candidate(n = 5,m = 10,k = 3) == 24420\n assert candidate(n = 35,m = 40,k = 25) == 920448080\n assert candidate(n = 10,m = 10,k = 10) == 1\n assert candidate(n = 20,m = 2,k = 0) == 0\n assert candidate(n = 15,m = 1,k = 0) == 0\n assert candidate(n = 7,m = 6,k = 4) == 15435\n assert candidate(n = 20,m = 15,k = 5) == 290343834\n assert candidate(n = 40,m = 20,k = 20) == 494331990\n assert candidate(n = 10,m = 10,k = 3) == 141166029\n assert candidate(n = 30,m = 100,k = 29) == 66522256\n assert candidate(n = 45,m = 5,k = 10) == 0\n assert candidate(n = 5,m = 4,k = 2) == 500\n assert candidate(n = 50,m = 100,k = 10) == 329962470\n assert candidate(n = 50,m = 100,k = 20) == 90726602\n assert candidate(n = 20,m = 5,k = 5) == 206085257\n assert candidate(n = 45,m = 10,k = 5) == 505926106\n assert candidate(n = 45,m = 40,k = 25) == 391896760\n assert candidate(n = 25,m = 20,k = 4) == 983809007\n assert candidate(n = 50,m = 100,k = 30) == 724411167\n assert candidate(n = 30,m = 3,k = 0) == 0\n assert candidate(n = 20,m = 20,k = 10) == 802034327\n assert candidate(n = 10,m = 5,k = 3) == 2604825\n assert candidate(n = 10,m = 7,k = 3) == 84246120\n assert candidate(n = 30,m = 15,k = 10) == 934932290\n assert candidate(n = 5,m = 3,k = 2) == 120\n assert candidate(n = 50,m = 1,k = 1) == 1\n assert candidate(n = 40,m = 20,k = 1) == 615177897\n assert candidate(n = 15,m = 5,k = 4) == 319448936\n assert candidate(n = 50,m = 1,k = 0) == 0\n assert candidate(n = 35,m = 7,k = 7) == 888706682\n assert candidate(n = 50,m = 10,k = 0) == 0\n assert candidate(n = 20,m = 15,k = 4) == 581619126\n assert candidate(n = 8,m = 8,k = 4) == 1511559\n assert candidate(n = 25,m = 50,k = 15) == 576291422\n assert candidate(n = 25,m = 20,k = 6) == 286391446\n assert candidate(n = 40,m = 10,k = 5) == 403011874\n assert candidate(n = 30,m = 100,k = 10) == 182325231\n assert candidate(n = 30,m = 20,k = 6) == 661827822\n assert candidate(n = 40,m = 40,k = 20) == 387728551\n assert candidate(n = 45,m = 5,k = 0) == 0\n assert candidate(n = 45,m = 30,k = 8) == 208992079\n assert candidate(n = 20,m = 10,k = 5) == 650197027\n assert candidate(n = 15,m = 15,k = 15) == 1\n assert candidate(n = 20,m = 5,k = 3) == 982515902\n assert candidate(n = 40,m = 20,k = 10) == 728982973\n assert candidate(n = 45,m = 9,k = 9) == 102251773\n assert candidate(n = 45,m = 5,k = 1) == 675218148\n assert candidate(n = 30,m = 10,k = 15) == 0\n assert candidate(n = 15,m = 10,k = 5) == 483153304\n assert candidate(n = 45,m = 90,k = 40) == 920197928\n assert candidate(n = 7,m = 7,k = 5) == 5320\n assert candidate(n = 20,m = 50,k = 5) == 46582970\n assert candidate(n = 40,m = 15,k = 15) == 696143324\n assert candidate(n = 25,m = 25,k = 10) == 458548979\n assert candidate(n = 35,m = 15,k = 25) == 0\n assert candidate(n = 45,m = 25,k = 20) == 820427360\n assert candidate(n = 40,m = 25,k = 0) == 0\n assert candidate(n = 20,m = 3,k = 2) == 743392192\n assert candidate(n = 30,m = 20,k = 15) == 845454640\n"}, "metadata": {"canonical_parameter_names": ["n", "m", "k"], "leetcode_dataset_entry_point": "Solution().numOfArrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numOfArrays(self, n: int, m: int, k: int) -> int:", "container": "Solution", "callable": "numOfArrays", "parameters": [{"name": "n", "type": "int"}, {"name": "m", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1422, "task_id": "maximum-score-after-splitting-a-string", "difficulty": "Easy", "problem_description": "Given a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e. left substring and right substring).\nThe score after splitting a string is the number of zeros in the left substring plus the number of ones in the right substring.\n \nExample 1:\n\nInput: s = \"011101\"\nOutput: 5 \nExplanation: \nAll possible ways of splitting s into two non-empty substrings are:\nleft = \"0\" and right = \"11101\", score = 1 + 4 = 5 \nleft = \"01\" and right = \"1101\", score = 1 + 3 = 4 \nleft = \"011\" and right = \"101\", score = 1 + 2 = 3 \nleft = \"0111\" and right = \"01\", score = 1 + 1 = 2 \nleft = \"01110\" and right = \"1\", score = 2 + 1 = 3\n\nExample 2:\n\nInput: s = \"00111\"\nOutput: 5\nExplanation: When left = \"00\" and right = \"111\", we get the maximum score = 2 + 3 = 5\n\nExample 3:\n\nInput: s = \"1111\"\nOutput: 3\n\n \nConstraints:\n\n2 <= s.length <= 500\nThe string s consists of characters '0' and '1' only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == 3\n assert candidate(s = \"00111\") == 5\n assert candidate(s = \"100100\") == 3\n assert candidate(s = \"110011\") == 4\n assert candidate(s = \"001001\") == 5\n assert candidate(s = \"11110000\") == 3\n assert candidate(s = \"0000\") == 3\n assert candidate(s = \"111000\") == 2\n assert candidate(s = \"1001001\") == 5\n assert candidate(s = \"1100\") == 1\n assert candidate(s = \"100001\") == 5\n assert candidate(s = \"00001111\") == 8\n assert candidate(s = \"000111\") == 6\n assert candidate(s = \"1001001001\") == 7\n assert candidate(s = \"001100\") == 4\n assert candidate(s = \"01010101\") == 5\n assert candidate(s = \"010101\") == 4\n assert candidate(s = \"101010\") == 3\n assert candidate(s = \"11001100\") == 4\n assert candidate(s = \"011101\") == 5\n assert candidate(s = \"000111000111000111000\") == 12\n assert candidate(s = \"101010101010101010\") == 9\n assert candidate(s = \"00000000000000000000000001\") == 26\n assert candidate(s = \"1000000000000000001\") == 18\n assert candidate(s = \"000000111111000000111111\") == 18\n assert candidate(s = \"01010101010101010101010101010101010101010\") == 21\n assert candidate(s = \"1000100010001\") == 10\n assert candidate(s = \"11111111110000000001111111111100000000\") == 20\n assert candidate(s = \"0110110110110110110110110110\") == 19\n assert candidate(s = \"0000000011111111111111\") == 22\n assert candidate(s = \"000011110000111100001111000011110000111100001111\") == 28\n assert candidate(s = \"1111111110\") == 8\n assert candidate(s = \"111110000011111000001111100000\") == 15\n assert candidate(s = \"10000000001111111111000000001111111111\") == 29\n assert candidate(s = \"010101010101010101010101\") == 13\n assert candidate(s = \"0110110110\") == 7\n assert candidate(s = \"10101010101010101010101010\") == 13\n assert candidate(s = \"00000000000000001111111111111111\") == 32\n assert candidate(s = \"111000111000111\") == 9\n assert candidate(s = \"111111111111111110\") == 16\n assert candidate(s = \"10011111000111\") == 10\n assert candidate(s = \"000111000111000111\") == 12\n assert candidate(s = \"101010101010101010101010\") == 12\n assert candidate(s = \"1010101010\") == 5\n assert candidate(s = \"010010010010010\") == 10\n assert candidate(s = \"0000000000\") == 9\n assert candidate(s = \"0000000000000000\") == 15\n assert candidate(s = \"1010101010101010\") == 8\n assert candidate(s = \"111100001111000011110000111100001111\") == 20\n assert candidate(s = \"111111000000111111000000\") == 12\n assert candidate(s = \"111100001111000011110000\") == 12\n assert candidate(s = \"000000000000001\") == 15\n assert candidate(s = \"011101110111011101\") == 14\n assert candidate(s = \"111100000000\") == 7\n assert candidate(s = \"101010010101001010100101010010101\") == 19\n assert candidate(s = \"11111000001111100000\") == 10\n assert candidate(s = \"000011110000111100001111000011110000\") == 20\n assert candidate(s = \"1111110000000001\") == 10\n assert candidate(s = \"111111100000001111111100000000111111\") == 21\n assert candidate(s = \"110011001100110011001100110011001100110011001100110011001100110011001100\") == 36\n assert candidate(s = \"010101010101010101010101010\") == 14\n assert candidate(s = \"000000011111110000000011111111000000\") == 23\n assert candidate(s = \"0110110110110110\") == 11\n assert candidate(s = \"0000000001\") == 10\n assert candidate(s = \"11111111111111111110000000000000000\") == 18\n assert candidate(s = \"010100101001010010100101001\") == 17\n assert candidate(s = \"000001111111111111\") == 18\n assert candidate(s = \"101010101010\") == 6\n assert candidate(s = \"0001111000\") == 7\n assert candidate(s = \"1001001001001001001001001001001001001001001001\") == 31\n assert candidate(s = \"0000011111\") == 10\n assert candidate(s = \"11111111111111111111\") == 19\n assert candidate(s = \"1000000000\") == 8\n assert candidate(s = \"1111111111111111\") == 15\n assert candidate(s = \"000111000111000\") == 9\n assert candidate(s = \"0110110110110110110110110110110110110110110110\") == 31\n assert candidate(s = \"110001010101101010010101011110000101010101\") == 22\n assert candidate(s = \"111001010101010\") == 7\n assert candidate(s = \"01000110011001100110\") == 12\n assert candidate(s = \"101010101010101010101010101010101010101\") == 20\n assert candidate(s = \"0000001111111111\") == 16\n assert candidate(s = \"000111111110000\") == 11\n assert candidate(s = \"00000000001111111111\") == 20\n assert candidate(s = \"100100100100100100100100100100100100\") == 23\n assert candidate(s = \"00000000000000000001111111111111111\") == 35\n assert candidate(s = \"111111111111111111111111111111111111111111111\") == 44\n assert candidate(s = \"111000111000111000111\") == 12\n assert candidate(s = \"11001100110011001100\") == 10\n assert candidate(s = \"11111111110000000000\") == 9\n assert candidate(s = \"11100011100011100011\") == 11\n assert candidate(s = \"01010101010101010101010101010101\") == 17\n assert candidate(s = \"0000000001111111110000000001111111110000000000111111111\") == 37\n assert candidate(s = \"0101010101010101010101010101010101010101\") == 21\n assert candidate(s = \"10010010010010010010\") == 13\n assert candidate(s = \"1010101010101010101010101010\") == 14\n assert candidate(s = \"00000000000000000000000000000000000000000000\") == 43\n assert candidate(s = \"111000111000\") == 6\n assert candidate(s = \"111000011111100\") == 10\n assert candidate(s = \"1000000000000000\") == 14\n assert candidate(s = \"000011111111\") == 12\n assert candidate(s = \"1100110011001100110011001100\") == 14\n assert candidate(s = \"0100101010101010\") == 9\n assert candidate(s = \"0101010101010101\") == 9\n assert candidate(s = \"1111111111111101\") == 14\n assert candidate(s = \"0101010101010101010\") == 10\n assert candidate(s = \"00010001000100010001\") == 16\n assert candidate(s = \"000011110000111100001111\") == 16\n assert candidate(s = \"0000111000111000\") == 10\n assert candidate(s = \"0101010101\") == 6\n assert candidate(s = \"11111111111111111111111110\") == 24\n assert candidate(s = \"00110011001100110011\") == 12\n assert candidate(s = \"0111111111000000\") == 10\n assert candidate(s = \"00000000000000000000\") == 19\n assert candidate(s = \"1111000011110000\") == 8\n assert candidate(s = \"10101010101010101010101010101010\") == 16\n assert candidate(s = \"1111100000\") == 4\n assert candidate(s = \"1111000000001111000000001111000000001111000000001111\") == 36\n assert candidate(s = \"0000000000000001\") == 16\n assert candidate(s = \"01010101010101\") == 8\n assert candidate(s = \"1101101101\") == 6\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 20\n assert candidate(s = \"1111111111\") == 9\n assert candidate(s = \"111110000011111\") == 10\n assert candidate(s = \"00011100011100011100\") == 12\n assert candidate(s = \"11101110111011101110\") == 14\n assert candidate(s = \"000100010001000100\") == 13\n assert candidate(s = \"01010101010101010101\") == 11\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101010101\") == 36\n assert candidate(s = \"1001001001001001001001001001\") == 19\n assert candidate(s = \"000001111100000111110000011111\") == 20\n assert candidate(s = \"0010100101001010010100101001010010\") == 21\n assert candidate(s = \"010101010101010\") == 8\n assert candidate(s = \"00011110001111\") == 11\n assert candidate(s = \"01101101101101101101\") == 14\n assert candidate(s = \"10101010101010101010\") == 10\n assert candidate(s = \"11111111111111110000000000000000\") == 15\n assert candidate(s = \"0001100110\") == 7\n assert candidate(s = \"0000000000011111111111\") == 22\n assert candidate(s = \"11111111111111110000000000\") == 15\n assert candidate(s = \"001100110011001100110011001100\") == 16\n assert candidate(s = \"001100110011\") == 8\n assert candidate(s = \"0111000001\") == 7\n assert candidate(s = \"0000111100001111\") == 12\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxScore(self, s: str) -> int:", "container": "Solution", "callable": "maxScore", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1423, "task_id": "maximum-points-you-can-obtain-from-cards", "difficulty": "Medium", "problem_description": "There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints.\nIn one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards.\nYour score is the sum of the points of the cards you have taken.\nGiven the integer array cardPoints and the integer k, return the maximum score you can obtain.\n \nExample 1:\n\nInput: cardPoints = [1,2,3,4,5,6,1], k = 3\nOutput: 12\nExplanation: After the first step, your score will always be 1. However, choosing the rightmost card first will maximize your total score. The optimal strategy is to take the three cards on the right, giving a final score of 1 + 6 + 5 = 12.\n\nExample 2:\n\nInput: cardPoints = [2,2,2], k = 2\nOutput: 4\nExplanation: Regardless of which two cards you take, your score will always be 4.\n\nExample 3:\n\nInput: cardPoints = [9,7,7,9,7,7,9], k = 7\nOutput: 55\nExplanation: You have to take all the cards. Your score is the sum of points of all cards.\n\n \nConstraints:\n\n1 <= cardPoints.length <= 105\n1 <= cardPoints[i] <= 104\n1 <= k <= cardPoints.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cardPoints = [5, 2, 1, 2, 5],k = 3) == 12\n assert candidate(cardPoints = [9, 7, 7, 9, 7, 7, 9],k = 7) == 55\n assert candidate(cardPoints = [1, 1000, 1],k = 1) == 1\n assert candidate(cardPoints = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 40\n assert candidate(cardPoints = [2, 2, 2],k = 2) == 4\n assert candidate(cardPoints = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 34\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 1],k = 3) == 12\n assert candidate(cardPoints = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 90\n assert candidate(cardPoints = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 5) == 5000\n assert candidate(cardPoints = [100, 400, 300, 100, 200, 500, 600, 300, 400],k = 4) == 1800\n assert candidate(cardPoints = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 10) == 1111111111\n assert candidate(cardPoints = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 300\n assert candidate(cardPoints = [5, 2, 1, 2, 5, 5, 5, 5, 5, 2, 1, 2, 5],k = 8) == 30\n assert candidate(cardPoints = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 10) == 100000\n assert candidate(cardPoints = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 155\n assert candidate(cardPoints = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 50\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 195\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 19\n assert candidate(cardPoints = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 5) == 50000\n assert candidate(cardPoints = [3, 1, 2, 7, 4, 5, 6],k = 3) == 15\n assert candidate(cardPoints = [10, 1, 1, 10, 1, 1, 10, 1, 1],k = 3) == 12\n assert candidate(cardPoints = [5, 1, 1, 2, 4, 2, 2, 5, 5, 4],k = 5) == 21\n assert candidate(cardPoints = [8, 9, 10, 4, 10, 1, 1, 1, 5, 9],k = 4) == 36\n assert candidate(cardPoints = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 10) == 5000\n assert candidate(cardPoints = [5, 1, 1, 2, 4, 2, 2, 5, 5, 5],k = 3) == 15\n assert candidate(cardPoints = [5, 6, 4, 2, 7, 8, 3, 1, 9],k = 4) == 24\n assert candidate(cardPoints = [1000, 100, 10, 1, 10000, 1000, 100, 10],k = 4) == 11110\n assert candidate(cardPoints = [1, 2, 100, 3, 4, 100, 5, 6, 100, 7, 8, 100, 9, 10, 100, 11, 12, 100, 13, 14],k = 7) == 260\n assert candidate(cardPoints = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 34\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 90\n assert candidate(cardPoints = [5, 3, 8, 7, 6, 2, 9, 1, 4, 10],k = 4) == 26\n assert candidate(cardPoints = [10, 4, 5, 1, 7, 12, 3, 8, 6],k = 4) == 29\n assert candidate(cardPoints = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(cardPoints = [5, 9, 3, 4, 6, 7, 2, 8, 1, 0],k = 5) == 27\n assert candidate(cardPoints = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(cardPoints = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 6) == 39\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 195\n assert candidate(cardPoints = [5, 2, 1, 3, 4, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1],k = 8) == 51\n assert candidate(cardPoints = [10000, 10000, 10000, 10000, 10000],k = 5) == 50000\n assert candidate(cardPoints = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 20\n assert candidate(cardPoints = [8, 9, 10, 4, 10, 4, 2, 2, 10, 10, 8, 6, 5, 1, 5, 9, 1, 6, 10, 8],k = 6) == 51\n assert candidate(cardPoints = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 5) == 15\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 49\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == 57\n assert candidate(cardPoints = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 1550\n assert candidate(cardPoints = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3],k = 10) == 20\n assert candidate(cardPoints = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 25\n assert candidate(cardPoints = [10000, 1, 10000, 1, 10000, 1],k = 3) == 20001\n assert candidate(cardPoints = [100, 40, 17, 9, 73, 75, 36, 21, 14, 92, 58],k = 5) == 307\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 34\n assert candidate(cardPoints = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 15) == 23\n assert candidate(cardPoints = [8, 9, 7, 6, 5, 4, 3, 2, 1],k = 3) == 24\n assert candidate(cardPoints = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 18) == 90\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 20) == 810\n assert candidate(cardPoints = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 6) == 84\n assert candidate(cardPoints = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991],k = 5) == 49990\n assert candidate(cardPoints = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41],k = 15) == 405\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 84\n assert candidate(cardPoints = [2, 3, 1, 2, 4, 3, 1, 5, 4],k = 5) == 17\n assert candidate(cardPoints = [5, 1, 1, 2, 4, 2, 2, 5, 5, 1],k = 3) == 11\n assert candidate(cardPoints = [5, 3, 1, 2, 6, 4, 8, 9, 10, 7, 2, 1, 3, 4, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 193\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == 209\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 40\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 155\n assert candidate(cardPoints = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 400\n assert candidate(cardPoints = [3, 2, 6, 7, 5, 4, 8, 1, 9],k = 4) == 22\n assert candidate(cardPoints = [3, 2, 7, 4, 1],k = 2) == 5\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 345\n assert candidate(cardPoints = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 155\n assert candidate(cardPoints = [3, 1, 3, 100, 100, 100, 3, 1, 3],k = 5) == 207\n assert candidate(cardPoints = [3, 1, 5, 9, 2, 6, 5, 3, 5, 9],k = 5) == 28\n assert candidate(cardPoints = [5, 2, 1, 7, 3, 4, 6],k = 4) == 20\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 210\n assert candidate(cardPoints = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == 270\n assert candidate(cardPoints = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 55\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 27\n assert candidate(cardPoints = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 15) == 3450\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 65\n"}, "metadata": {"canonical_parameter_names": ["cardPoints", "k"], "leetcode_dataset_entry_point": "Solution().maxScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxScore(self, cardPoints: list[int], k: int) -> int:", "container": "Solution", "callable": "maxScore", "parameters": [{"name": "cardPoints", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1424, "task_id": "diagonal-traverse-ii", "difficulty": "Medium", "problem_description": "Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.\n \nExample 1:\n\n\nInput: nums = [[1,2,3],[4,5,6],[7,8,9]]\nOutput: [1,4,2,7,5,3,8,6,9]\n\nExample 2:\n\n\nInput: nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]]\nOutput: [1,6,2,8,7,3,9,4,12,10,5,13,11,14,15,16]\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i].length <= 105\n1 <= sum(nums[i].length) <= 105\n1 <= nums[i][j] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [[1]]) == [1]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == [1, 4, 2, 7, 5, 3, 8, 6, 9]\n assert candidate(nums = [[1, 2, 3], [4, 5], [6]]) == [1, 4, 2, 6, 5, 3]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7], [8], [9, 10, 11], [12, 13, 14, 15, 16]]) == [1, 6, 2, 8, 7, 3, 9, 4, 12, 10, 5, 13, 11, 14, 15, 16]\n assert candidate(nums = [[1, 2], [3, 4], [5, 6]]) == [1, 3, 2, 5, 4, 6]\n assert candidate(nums = [[1, 2, 3], [4], [5, 6, 7], [8, 9]]) == [1, 4, 2, 5, 3, 8, 6, 9, 7]\n assert candidate(nums = [[1, 2], [3, 4, 5], [6, 7, 8, 9]]) == [1, 3, 2, 6, 4, 7, 5, 8, 9]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31], [32, 33, 34], [35, 36], [37]]) == [1, 11, 2, 20, 12, 3, 27, 21, 13, 4, 32, 28, 22, 14, 5, 35, 33, 29, 23, 15, 6, 37, 36, 34, 30, 24, 16, 7, 31, 25, 17, 8, 26, 18, 9, 19, 10]\n assert candidate(nums = [[100, 200], [300, 400, 500, 600], [700], [800, 900, 1000, 1100, 1200, 1300], [1400, 1500]]) == [100, 300, 200, 700, 400, 800, 500, 1400, 900, 600, 1500, 1000, 1100, 1200, 1300]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6, 7], [8], [9, 10, 11, 12], [13, 14], [15, 16, 17, 18, 19, 20]]) == [1, 5, 2, 8, 6, 3, 9, 7, 4, 13, 10, 15, 14, 11, 16, 12, 17, 18, 19, 20]\n assert candidate(nums = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36], [37, 38, 39, 40], [41, 42], [43], [44, 45, 46], [47, 48, 49, 50, 51]]) == [1, 21, 2, 31, 22, 3, 37, 32, 23, 4, 41, 38, 33, 24, 5, 43, 42, 39, 34, 25, 6, 44, 40, 35, 26, 7, 47, 45, 36, 27, 8, 48, 46, 28, 9, 49, 29, 10, 50, 30, 11, 51, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [[1, 2], [3, 4, 5], [6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27]]) == [1, 3, 2, 6, 4, 10, 7, 5, 15, 11, 8, 21, 16, 12, 9, 22, 17, 13, 23, 18, 14, 24, 19, 25, 20, 26, 27]\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18], [19, 20], [21], [22, 23, 24], [25, 26, 27, 28]]) == [1, 11, 2, 16, 12, 3, 19, 17, 13, 4, 21, 20, 18, 14, 5, 22, 15, 6, 25, 23, 7, 26, 24, 8, 27, 9, 28, 10]\n assert candidate(nums = [[1], [2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31], [32, 33, 34, 35, 36, 37, 38, 39, 40]]) == [1, 2, 11, 3, 26, 12, 4, 32, 27, 13, 5, 33, 28, 14, 6, 34, 29, 15, 7, 35, 30, 16, 8, 36, 31, 17, 9, 37, 18, 10, 38, 19, 39, 20, 40, 21, 22, 23, 24, 25]\n assert candidate(nums = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35, 36]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 16, 12, 9, 22, 17, 13, 10, 29, 23, 18, 14, 30, 24, 19, 15, 31, 25, 20, 32, 26, 21, 33, 27, 34, 28, 35, 36]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33], [34, 35, 36, 37, 38], [39, 40, 41, 42], [43, 44, 45], [46, 47], [48, 49], [50]]) == [1, 11, 2, 20, 12, 3, 28, 21, 13, 4, 34, 29, 22, 14, 5, 39, 35, 30, 23, 15, 6, 43, 40, 36, 31, 24, 16, 7, 46, 44, 41, 37, 32, 25, 17, 8, 48, 47, 45, 42, 38, 33, 26, 18, 9, 50, 49, 27, 19, 10]\n assert candidate(nums = [[1], [2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31, 32, 33, 34], [35, 36, 37, 38, 39, 40, 41, 42, 43]]) == [1, 2, 5, 3, 9, 6, 4, 14, 10, 7, 20, 15, 11, 8, 27, 21, 16, 12, 35, 28, 22, 17, 13, 36, 29, 23, 18, 37, 30, 24, 19, 38, 31, 25, 39, 32, 26, 40, 33, 41, 34, 42, 43]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6], [7, 8, 9], [10], [11, 12, 13, 14, 15], [16, 17, 18], [19, 20], [21, 22, 23, 24], [25, 26, 27], [28, 29, 30]]) == [1, 5, 2, 7, 6, 3, 10, 8, 4, 11, 9, 16, 12, 19, 17, 13, 21, 20, 18, 14, 25, 22, 15, 28, 26, 23, 29, 27, 24, 30]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8], [9, 10], [11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21], [22]]) == [1, 6, 2, 9, 7, 3, 11, 10, 8, 4, 12, 5, 18, 13, 22, 19, 14, 20, 15, 21, 16, 17]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37], [38, 39, 40, 41], [42, 43, 44], [45, 46], [47]]) == [1, 11, 2, 20, 12, 3, 27, 21, 13, 4, 33, 28, 22, 14, 5, 38, 34, 29, 23, 15, 6, 42, 39, 35, 30, 24, 16, 7, 45, 43, 40, 36, 31, 25, 17, 8, 47, 46, 44, 41, 37, 32, 26, 18, 9, 19, 10]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6, 7, 8, 9, 10], [11, 12, 13], [14, 15, 16, 17, 18, 19, 20, 21, 22]]) == [1, 4, 2, 11, 5, 3, 14, 12, 6, 15, 13, 7, 16, 8, 17, 9, 18, 10, 19, 20, 21, 22]\n assert candidate(nums = [[1, 2], [3, 4, 5, 6, 7], [8, 9, 10], [11, 12], [13], [14, 15, 16, 17], [18, 19, 20], [21, 22], [23], [24, 25, 26, 27, 28]]) == [1, 3, 2, 8, 4, 11, 9, 5, 13, 12, 10, 6, 14, 7, 18, 15, 21, 19, 16, 23, 22, 20, 17, 24, 25, 26, 27, 28]\n assert candidate(nums = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 16, 12, 9, 17, 13, 10, 18, 14, 19, 15, 20, 21]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43]]) == [1, 4, 2, 9, 5, 3, 19, 10, 6, 28, 20, 11, 7, 29, 21, 12, 8, 30, 22, 13, 31, 23, 14, 32, 24, 15, 33, 25, 16, 34, 26, 17, 35, 27, 18, 36, 37, 38, 39, 40, 41, 42, 43]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37], [38, 39, 40, 41], [42, 43, 44], [45, 46], [47], [48]]) == [1, 11, 2, 20, 12, 3, 27, 21, 13, 4, 33, 28, 22, 14, 5, 38, 34, 29, 23, 15, 6, 42, 39, 35, 30, 24, 16, 7, 45, 43, 40, 36, 31, 25, 17, 8, 47, 46, 44, 41, 37, 32, 26, 18, 9, 48, 19, 10]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6], [7, 8, 9], [10, 11], [12, 13, 14, 15], [16, 17, 18, 19, 20]]) == [1, 7, 2, 10, 8, 3, 12, 11, 9, 4, 16, 13, 5, 17, 14, 6, 18, 15, 19, 20]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n assert candidate(nums = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13], [14, 15], [16]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 14, 12, 9, 16, 15, 13, 10]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24], [25, 26, 27], [28, 29, 30, 31, 32, 33, 34, 35, 36]]) == [1, 11, 2, 20, 12, 3, 25, 21, 13, 4, 28, 26, 22, 14, 5, 29, 27, 23, 15, 6, 30, 24, 16, 7, 31, 17, 8, 32, 18, 9, 33, 19, 10, 34, 35, 36]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6], [7, 8], [9, 10, 11], [12, 13, 14], [15], [16, 17, 18, 19]]) == [1, 7, 2, 9, 8, 3, 12, 10, 4, 15, 13, 11, 5, 16, 14, 6, 17, 18, 19]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6, 7], [8], [9, 10, 11, 12], [13, 14]]) == [1, 5, 2, 8, 6, 3, 9, 7, 4, 13, 10, 14, 11, 12]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19], [20, 21], [22]]) == [1, 4, 2, 8, 5, 3, 13, 9, 6, 17, 14, 10, 7, 20, 18, 15, 11, 22, 21, 19, 16, 12]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6], [7, 8, 9], [10, 11, 12, 13], [14, 15], [16]]) == [1, 7, 2, 10, 8, 3, 14, 11, 9, 4, 16, 15, 12, 5, 13, 6]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28], [29, 30, 31], [32, 33], [34], [35, 36, 37], [38, 39, 40, 41, 42]]) == [1, 11, 2, 19, 12, 3, 25, 20, 13, 4, 29, 26, 21, 14, 5, 32, 30, 27, 22, 15, 6, 34, 33, 31, 28, 23, 16, 7, 35, 24, 17, 8, 38, 36, 18, 9, 39, 37, 10, 40, 41, 42]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28, 29], [30, 31, 32, 33, 34, 35, 36, 37, 38]]) == [1, 4, 2, 9, 5, 3, 15, 10, 6, 22, 16, 11, 7, 30, 23, 17, 12, 8, 31, 24, 18, 13, 32, 25, 19, 14, 33, 26, 20, 34, 27, 21, 35, 28, 36, 29, 37, 38]\n assert candidate(nums = [[1], [2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31, 32, 33, 34]]) == [1, 2, 5, 3, 9, 6, 4, 14, 10, 7, 20, 15, 11, 8, 27, 21, 16, 12, 28, 22, 17, 13, 29, 23, 18, 30, 24, 19, 31, 25, 32, 26, 33, 34]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29], [30, 31, 32, 33], [34, 35, 36], [37, 38], [39]]) == [1, 6, 2, 12, 7, 3, 19, 13, 8, 4, 25, 20, 14, 9, 5, 30, 26, 21, 15, 10, 34, 31, 27, 22, 16, 11, 37, 35, 32, 28, 23, 17, 39, 38, 36, 33, 29, 24, 18]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55]\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == [1, 11, 2, 20, 12, 3, 27, 21, 13, 4, 28, 22, 14, 5, 29, 23, 15, 6, 30, 24, 16, 7, 31, 25, 17, 8, 32, 26, 18, 9, 33, 19, 10, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10], [11, 12, 13], [14, 15], [16], [17, 18, 19, 20]]) == [1, 7, 2, 11, 8, 3, 14, 12, 9, 4, 16, 15, 13, 10, 5, 17, 6, 18, 19, 20]\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]]) == [1, 26, 2, 27, 3, 28, 4, 29, 5, 30, 6, 31, 7, 32, 8, 33, 9, 34, 10, 35, 11, 36, 12, 37, 13, 38, 14, 39, 15, 40, 16, 41, 17, 42, 18, 43, 19, 44, 20, 45, 21, 46, 22, 47, 23, 48, 24, 49, 25, 50]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16], [17, 18, 19, 20], [21]]) == [1, 4, 2, 10, 5, 3, 15, 11, 6, 17, 16, 12, 7, 21, 18, 13, 8, 19, 14, 9, 20]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8], [9, 10], [11], [12, 13, 14, 15], [16, 17, 18], [19], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]) == [1, 6, 2, 9, 7, 3, 11, 10, 8, 4, 12, 5, 16, 13, 19, 17, 14, 20, 18, 15, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8, 9], [10, 11, 12], [13, 14], [15], [16, 17, 18, 19, 20]]) == [1, 6, 2, 10, 7, 3, 13, 11, 8, 4, 15, 14, 12, 9, 5, 16, 17, 18, 19, 20]\n assert candidate(nums = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 12, 9, 13, 10, 14, 15]\n assert candidate(nums = [[1, 2], [3, 4, 5], [6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20]]) == [1, 3, 2, 6, 4, 10, 7, 5, 15, 11, 8, 16, 12, 9, 17, 13, 18, 14, 19, 20]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41], [42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52], [53, 54, 55, 56, 57, 58, 59, 60, 61, 62], [63, 64, 65, 66, 67, 68, 69, 70, 71], [72, 73, 74, 75, 76, 77, 78], [79, 80, 81, 82, 83, 84], [85, 86, 87, 88, 89], [90, 91, 92, 93], [94, 95, 96], [97, 98], [99]]) == [1, 16, 2, 30, 17, 3, 42, 31, 18, 4, 53, 43, 32, 19, 5, 63, 54, 44, 33, 20, 6, 72, 64, 55, 45, 34, 21, 7, 79, 73, 65, 56, 46, 35, 22, 8, 85, 80, 74, 66, 57, 47, 36, 23, 9, 90, 86, 81, 75, 67, 58, 48, 37, 24, 10, 94, 91, 87, 82, 76, 68, 59, 49, 38, 25, 11, 97, 95, 92, 88, 83, 77, 69, 60, 50, 39, 26, 12, 99, 98, 96, 93, 89, 84, 78, 70, 61, 51, 40, 27, 13, 71, 62, 52, 41, 28, 14, 29, 15]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8, 9], [10, 11, 12], [13, 14], [15]]) == [1, 6, 2, 10, 7, 3, 13, 11, 8, 4, 15, 14, 12, 9, 5]\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20], [21], [22], [23], [24], [25]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6, 7], [8, 9], [10], [11, 12, 13, 14, 15], [16, 17, 18, 19]]) == [1, 5, 2, 8, 6, 3, 10, 9, 7, 4, 11, 16, 12, 17, 13, 18, 14, 19, 15]\n assert candidate(nums = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 16, 12, 9, 22, 17, 13, 10, 23, 18, 14, 24, 19, 15, 25, 20, 26, 21, 27, 28]\n assert candidate(nums = [[1, 2], [3], [4, 5, 6, 7], [8, 9], [10, 11, 12], [13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23]]) == [1, 3, 2, 4, 8, 5, 10, 9, 6, 13, 11, 7, 18, 14, 12, 19, 15, 20, 16, 21, 17, 22, 23]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6, 7], [8, 9], [10], [11, 12, 13, 14], [15, 16]]) == [1, 5, 2, 8, 6, 3, 10, 9, 7, 4, 11, 15, 12, 16, 13, 14]\n assert candidate(nums = [[1], [2, 3, 4], [5, 6], [7, 8, 9, 10], [11, 12, 13], [14, 15, 16, 17, 18]]) == [1, 2, 5, 3, 7, 6, 4, 11, 8, 14, 12, 9, 15, 13, 10, 16, 17, 18]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8, 9], [10, 11, 12], [13, 14], [15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [1, 6, 2, 10, 7, 3, 13, 11, 8, 4, 15, 14, 12, 9, 5, 16, 21, 17, 22, 18, 23, 19, 24, 20, 25]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28], [29, 30, 31], [32, 33], [34]]) == [1, 11, 2, 19, 12, 3, 25, 20, 13, 4, 29, 26, 21, 14, 5, 32, 30, 27, 22, 15, 6, 34, 33, 31, 28, 23, 16, 7, 24, 17, 8, 18, 9, 10]\n assert candidate(nums = [[100, 200, 300], [400, 500], [600], [700, 800, 900, 1000], [1100, 1200, 1300], [1400, 1500, 1600, 1700, 1800]]) == [100, 400, 200, 600, 500, 300, 700, 1100, 800, 1400, 1200, 900, 1500, 1300, 1000, 1600, 1700, 1800]\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6, 7], [8, 9], [10]]) == [1, 5, 2, 8, 6, 3, 10, 9, 7, 4]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40], [41, 42, 43, 44, 45]]) == [1, 6, 2, 11, 7, 3, 16, 12, 8, 4, 21, 17, 13, 9, 5, 26, 22, 18, 14, 10, 31, 27, 23, 19, 15, 36, 32, 28, 24, 20, 41, 37, 33, 29, 25, 42, 38, 34, 30, 43, 39, 35, 44, 40, 45]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21], [22, 23, 24, 25], [26, 27], [28]]) == [1, 10, 2, 17, 11, 3, 22, 18, 12, 4, 26, 23, 19, 13, 5, 28, 27, 24, 20, 14, 6, 25, 21, 15, 7, 16, 8, 9]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45]]) == [1, 16, 2, 31, 17, 3, 32, 18, 4, 33, 19, 5, 34, 20, 6, 35, 21, 7, 36, 22, 8, 37, 23, 9, 38, 24, 10, 39, 25, 11, 40, 26, 12, 41, 27, 13, 42, 28, 14, 43, 29, 15, 44, 30, 45]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == [1, 21, 2, 22, 3, 23, 4, 24, 5, 25, 6, 26, 7, 27, 8, 28, 9, 29, 10, 30, 11, 31, 12, 32, 13, 33, 14, 34, 15, 35, 16, 36, 17, 37, 18, 38, 19, 39, 20, 40]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34], [35, 36, 37, 38, 39, 40]]) == [1, 11, 2, 20, 12, 3, 28, 21, 13, 4, 35, 29, 22, 14, 5, 36, 30, 23, 15, 6, 37, 31, 24, 16, 7, 38, 32, 25, 17, 8, 39, 33, 26, 18, 9, 40, 34, 27, 19, 10]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32], [33, 34, 35, 36], [37, 38, 39], [40, 41], [42], [43]]) == [1, 12, 2, 21, 13, 3, 28, 22, 14, 4, 33, 29, 23, 15, 5, 37, 34, 30, 24, 16, 6, 40, 38, 35, 31, 25, 17, 7, 42, 41, 39, 36, 32, 26, 18, 8, 43, 27, 19, 9, 20, 10, 11]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findDiagonalOrder", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findDiagonalOrder(self, nums: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "findDiagonalOrder", "parameters": [{"name": "nums", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1425, "task_id": "constrained-subsequence-sum", "difficulty": "Hard", "problem_description": "Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums[i] and nums[j], where i < j, the condition j - i <= k is satisfied.\nA subsequence of an array is obtained by deleting some number of elements (can be zero) from the array, leaving the remaining elements in their original order.\n \nExample 1:\n\nInput: nums = [10,2,-10,5,20], k = 2\nOutput: 37\nExplanation: The subsequence is [10, 2, 5, 20].\n\nExample 2:\n\nInput: nums = [-1,-2,-3], k = 1\nOutput: -1\nExplanation: The subsequence must be non-empty, so we choose the largest number.\n\nExample 3:\n\nInput: nums = [10,-2,-10,-5,20], k = 2\nOutput: 23\nExplanation: The subsequence is [10, -2, -5, 20].\n\n \nConstraints:\n\n1 <= k <= nums.length <= 105\n-104 <= nums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 7, -3, 5],k = 1) == 14\n assert candidate(nums = [10, 2, -10, 5, 20],k = 2) == 37\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 15\n assert candidate(nums = [3, -1, 4, -2, 2, 1],k = 2) == 10\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 4) == -1\n assert candidate(nums = [5, -1, 5],k = 2) == 10\n assert candidate(nums = [-1, -2, -3],k = 1) == -1\n assert candidate(nums = [5, 4, 3, 2, 1],k = 5) == 15\n assert candidate(nums = [5, 3, -5, -10, -3, 7],k = 4) == 15\n assert candidate(nums = [1, -1, 5, -2, 3],k = 3) == 9\n assert candidate(nums = [10, -2, -10, -5, 20],k = 2) == 23\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 2) == 15\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 2) == 150\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],k = 5) == -1\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70],k = 1) == -10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 20\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 4) == 150\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 10) == 55\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 15) == 5500\n assert candidate(nums = [1000, -500, 200, -300, 400, -200, 600, -100, 700, -300],k = 5) == 2900\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000],k = 4) == 50000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 55\n assert candidate(nums = [-10, -3, -5, -1, -6, -2, -4, -8, -9],k = 2) == -1\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981],k = 5) == 19810\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1],k = 2) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == 0\n assert candidate(nums = [10, -2, 3, 5, -1, 2, 0, 8, -5, 10],k = 4) == 38\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 0\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100],k = 2) == 500\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 1) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 55\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 7) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 55\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 550\n assert candidate(nums = [100, -200, 300, -400, 500, 600, -700, 800, -900, 1000],k = 3) == 3300\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000],k = 2) == 15000\n assert candidate(nums = [1, 2, 3, -4, 5, 6, -7, 8, 9, -10],k = 3) == 34\n assert candidate(nums = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 7) == 400\n assert candidate(nums = [-1000, -2000, -3000, -4000, -5000, 5000, 4000, 3000, 2000, 1000],k = 4) == 15000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 210\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9],k = 4) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1) == 550\n assert candidate(nums = [5, 2, 3, 1, 6, 4, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 65\n assert candidate(nums = [100, -300, 200, 50, -150, 400, 300],k = 3) == 1050\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 3) == 30\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 5) == 1500\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 8) == 400\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 1) == -1\n assert candidate(nums = [-10, 2, -3, -4, 5, 6, -1, 2, 3, -10, 100, -200, 300],k = 4) == 418\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 5) == 15\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15],k = 6) == 64\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1],k = 2) == 5\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5],k = 15) == 50\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, -5000, -4000, -3000, -2000, -1000],k = 5) == 15000\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],k = 7) == 8000\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5],k = 5) == 50\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],k = 4) == 1045\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500, 600, 700, 800, 900, 1000],k = 7) == 5500\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 50\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 2) == -1\n assert candidate(nums = [0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19],k = 9) == 90\n assert candidate(nums = [100, -50, 200, -250, 300, -350, 400, -450, 500],k = 5) == 1500\n assert candidate(nums = [1, -2, 3, 5, -1, 2, 4, -3, 7],k = 3) == 22\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10],k = 6) == 550\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 10) == 55\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1) == 5500\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],k = 5) == 105\n assert candidate(nums = [3, -1, 4, -1, 5, -9, 2, 6, -5, 3, 5, -7, 8, -2, 6],k = 5) == 42\n assert candidate(nums = [100, 50, 20, 10, -10, -20, -50, -100, 30, 40],k = 4) == 240\n assert candidate(nums = [-10, 2, -3, 4, -1, 5, -6, 7, -8, 9],k = 4) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 7) == 325\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 2100\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 5) == 6\n assert candidate(nums = [10, -2, -10, 5, 20, -30, 40, -50, 60, -70],k = 3) == 135\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100],k = 7) == 550\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91],k = 5) == -91\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 3) == -1\n assert candidate(nums = [1, 2, 3, -6, 4, 5, -7, 6, 7, -8, 8, 9],k = 3) == 45\n assert candidate(nums = [1, -100, 1000, -10000, 100000, -1000000, 10000000, -100000000, 1000000000],k = 2) == 1010101001\n assert candidate(nums = [3, -2, 5, -1, 6, 2, -5, 10],k = 3) == 26\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120],k = 6) == 360\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 55\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 1) == 1\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],k = 4) == 2500\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6, 3, -3, 1, -1],k = 6) == 197\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 5\n assert candidate(nums = [3, -1, -10, 4, 13, -5, 12, -3, 15, -10, 7, 8],k = 3) == 62\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 210\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000],k = 3) == 15000\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],k = 5) == 2500\n assert candidate(nums = [10, 20, 30, 40, 50, -1, -2, -3, -4, -5, 60, 70, 80, 90, 100],k = 10) == 550\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20],k = 10) == 100\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 4) == -10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 210\n assert candidate(nums = [-10000, -9000, -8000, -7000, -6000, -5000, -4000, -3000, -2000, -1000],k = 2) == -1000\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15],k = 7) == 64\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 3) == 55\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],k = 4) == -1\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 120\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == 0\n assert candidate(nums = [10, -5, 20, -10, 5, 15, -3],k = 3) == 50\n assert candidate(nums = [-5, -5, -5, -5, -5, -5, -5, -5, -5, -5],k = 1) == -5\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [-1, 3, -2, 5, -6, 4, 2, -3, 5, -4],k = 3) == 19\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().constrainedSubsetSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def constrainedSubsetSum(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "constrainedSubsetSum", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1431, "task_id": "kids-with-the-greatest-number-of-candies", "difficulty": "Easy", "problem_description": "There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer extraCandies, denoting the number of extra candies that you have.\nReturn a boolean array result of length n, where result[i] is true if, after giving the ith kid all the extraCandies, they will have the greatest number of candies among all the kids, or false otherwise.\nNote that multiple kids can have the greatest number of candies.\n \nExample 1:\n\nInput: candies = [2,3,5,1,3], extraCandies = 3\nOutput: [true,true,true,false,true] \nExplanation: If you give all extraCandies to:\n- Kid 1, they will have 2 + 3 = 5 candies, which is the greatest among the kids.\n- Kid 2, they will have 3 + 3 = 6 candies, which is the greatest among the kids.\n- Kid 3, they will have 5 + 3 = 8 candies, which is the greatest among the kids.\n- Kid 4, they will have 1 + 3 = 4 candies, which is not the greatest among the kids.\n- Kid 5, they will have 3 + 3 = 6 candies, which is the greatest among the kids.\n\nExample 2:\n\nInput: candies = [4,2,1,1,2], extraCandies = 1\nOutput: [true,false,false,false,false] \nExplanation: There is only 1 extra candy.\nKid 1 will always have the greatest number of candies, even if a different kid is given the extra candy.\n\nExample 3:\n\nInput: candies = [12,1,12], extraCandies = 10\nOutput: [true,false,true]\n\n \nConstraints:\n\nn == candies.length\n2 <= n <= 100\n1 <= candies[i] <= 100\n1 <= extraCandies <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(candies = [4, 2, 1, 1, 2],extraCandies = 1) == [True, False, False, False, False]\n assert candidate(candies = [12, 1, 12],extraCandies = 10) == [True, False, True]\n assert candidate(candies = [50, 50, 50, 50, 50],extraCandies = 50) == [True, True, True, True, True]\n assert candidate(candies = [1, 2, 3, 4, 5],extraCandies = 2) == [False, False, True, True, True]\n assert candidate(candies = [2, 3, 5, 1, 3],extraCandies = 3) == [True, True, True, False, True]\n assert candidate(candies = [1, 2, 3, 4, 5],extraCandies = 0) == [False, False, False, False, True]\n assert candidate(candies = [5, 8, 7],extraCandies = 5) == [True, True, True]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],extraCandies = 10) == [False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25],extraCandies = 25) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [90, 80, 70, 60, 50, 40, 30, 20, 10, 0],extraCandies = 15) == [True, True, False, False, False, False, False, False, False, False]\n assert candidate(candies = [98, 99, 100, 101, 102],extraCandies = 3) == [False, True, True, True, True]\n assert candidate(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],extraCandies = 10) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [50, 40, 30, 20, 10],extraCandies = 20) == [True, True, True, False, False]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],extraCandies = 5) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [5, 5, 5, 5, 5],extraCandies = 5) == [True, True, True, True, True]\n assert candidate(candies = [5, 5, 5, 5, 5],extraCandies = 1) == [True, True, True, True, True]\n assert candidate(candies = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],extraCandies = 50) == [False, True, False, True, False, True, False, True, False, True]\n assert candidate(candies = [10, 20, 30, 40, 50],extraCandies = 20) == [False, False, True, True, True]\n assert candidate(candies = [90, 90, 90, 90, 90, 90, 90, 90, 90, 90],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25],extraCandies = 24) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100],extraCandies = 50) == [False, False, False, False, False, False, False, False, False, True]\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],extraCandies = 1) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],extraCandies = 50) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [50, 50, 50, 50, 50],extraCandies = 10) == [True, True, True, True, True]\n assert candidate(candies = [90, 80, 70, 60, 50, 40, 30, 20, 10],extraCandies = 10) == [True, True, False, False, False, False, False, False, False]\n assert candidate(candies = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5],extraCandies = 50) == [True, False, True, False, True, False, True, False, True, False]\n assert candidate(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],extraCandies = 10) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [50, 40, 30, 20, 10, 0],extraCandies = 10) == [True, True, False, False, False, False]\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],extraCandies = 40) == [False, False, False, False, False, True, True, True, True, True]\n assert candidate(candies = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],extraCandies = 25) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [23, 45, 12, 67, 34, 89, 10, 56],extraCandies = 20) == [False, False, False, False, False, True, False, False]\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],extraCandies = 1) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],extraCandies = 9) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100],extraCandies = 99) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],extraCandies = 5) == [True, True, True, True, True, True, False, False, False, False]\n assert candidate(candies = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],extraCandies = 5) == [False, False, False, False, False, False, False, True, True, True]\n assert candidate(candies = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],extraCandies = 25) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],extraCandies = 50) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],extraCandies = 5) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False]\n assert candidate(candies = [10, 20, 30, 40, 50],extraCandies = 15) == [False, False, False, True, True]\n assert candidate(candies = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],extraCandies = 25) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],extraCandies = 255) == [False, False, False, False, False, False, False, False, False, True]\n assert candidate(candies = [90, 80, 70, 60, 50, 40, 30, 20, 10],extraCandies = 15) == [True, True, False, False, False, False, False, False, False]\n assert candidate(candies = [30, 40, 20, 50, 10],extraCandies = 10) == [False, True, False, True, False]\n assert candidate(candies = [1, 50, 25, 75, 35],extraCandies = 25) == [False, True, False, True, False]\n assert candidate(candies = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5],extraCandies = 7) == [True, False, True, False, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False]\n assert candidate(candies = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9],extraCandies = 50) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(candies = [50, 20, 20, 10, 30],extraCandies = 20) == [True, False, False, False, True]\n assert candidate(candies = [10, 20, 30, 40, 50],extraCandies = 25) == [False, False, True, True, True]\n assert candidate(candies = [50, 40, 30, 20, 10],extraCandies = 10) == [True, True, False, False, False]\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],extraCandies = 80) == [False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [50, 25, 75, 25, 50, 100, 75, 50, 25, 75],extraCandies = 25) == [False, False, True, False, False, True, True, False, False, True]\n assert candidate(candies = [90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],extraCandies = 9) == [False, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],extraCandies = 99) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],extraCandies = 1) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [50, 40, 30, 20, 10],extraCandies = 25) == [True, True, True, False, False]\n assert candidate(candies = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],extraCandies = 25) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [50, 10, 20, 30, 40],extraCandies = 20) == [True, False, False, True, True]\n assert candidate(candies = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],extraCandies = 5) == [True, True, True, True, True, True, False, False, False, False]\n assert candidate(candies = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5],extraCandies = 50) == [True, False, True, False, True, False, True, False, True, False]\n assert candidate(candies = [80, 80, 80, 80, 80],extraCandies = 20) == [True, True, True, True, True]\n assert candidate(candies = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9],extraCandies = 90) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],extraCandies = 4) == [False, False, False, False, False, True, True, True, True, True]\n assert candidate(candies = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],extraCandies = 0) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [50, 40, 30, 20, 10],extraCandies = 30) == [True, True, True, True, False]\n assert candidate(candies = [100, 100, 100, 100, 100],extraCandies = 50) == [True, True, True, True, True]\n assert candidate(candies = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],extraCandies = 15) == [False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True]\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],extraCandies = 10) == [False, False, False, False, False, False, False, False, True, True]\n assert candidate(candies = [3, 3, 3, 3, 3],extraCandies = 3) == [True, True, True, True, True]\n assert candidate(candies = [7, 5, 9, 10, 2],extraCandies = 5) == [True, True, True, True, False]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],extraCandies = 50) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],extraCandies = 49) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],extraCandies = 45) == [False, False, False, False, False, True, True, True, True, True]\n assert candidate(candies = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],extraCandies = 1) == [True, True, False, False, False, False, False, False, False, False]\n assert candidate(candies = [20, 15, 20, 10, 30],extraCandies = 10) == [True, False, True, False, True]\n assert candidate(candies = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [10, 10, 10, 10, 10],extraCandies = 1) == [True, True, True, True, True]\n assert candidate(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],extraCandies = 8) == [False, False, False, False, False, True, True, True, True, True]\n"}, "metadata": {"canonical_parameter_names": ["candies", "extraCandies"], "leetcode_dataset_entry_point": "Solution().kidsWithCandies", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def kidsWithCandies(self, candies: list[int], extraCandies: int) -> list[bool]:", "container": "Solution", "callable": "kidsWithCandies", "parameters": [{"name": "candies", "type": "list[int]"}, {"name": "extraCandies", "type": "int"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1432, "task_id": "max-difference-you-can-get-from-changing-an-integer", "difficulty": "Medium", "problem_description": "You are given an integer num. You will apply the following steps exactly two times:\n\nPick a digit x (0 <= x <= 9).\nPick another digit y (0 <= y <= 9). The digit y can be equal to x.\nReplace all the occurrences of x in the decimal representation of num by y.\nThe new integer cannot have any leading zeros, also the new integer cannot be 0.\n\nLet a and b be the results of applying the operations to num the first and second times, respectively.\nReturn the max difference between a and b.\n \nExample 1:\n\nInput: num = 555\nOutput: 888\nExplanation: The first time pick x = 5 and y = 9 and store the new integer in a.\nThe second time pick x = 5 and y = 1 and store the new integer in b.\nWe have now a = 999 and b = 111 and max difference = 888\n\nExample 2:\n\nInput: num = 9\nOutput: 8\nExplanation: The first time pick x = 9 and y = 9 and store the new integer in a.\nThe second time pick x = 9 and y = 1 and store the new integer in b.\nWe have now a = 9 and b = 1 and max difference = 8\n\n \nConstraints:\n\n1 <= num <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 1001100) == 8008800\n assert candidate(num = 9) == 8\n assert candidate(num = 98789) == 81018\n assert candidate(num = 123456) == 820000\n assert candidate(num = 987654321) == 810000000\n assert candidate(num = 1000000) == 8000000\n assert candidate(num = 1221) == 8228\n assert candidate(num = 123456789) == 820000000\n assert candidate(num = 1111111) == 8888888\n assert candidate(num = 987789) == 810018\n assert candidate(num = 1001001) == 8008008\n assert candidate(num = 12321) == 82028\n assert candidate(num = 555) == 888\n assert candidate(num = 9999999) == 8888888\n assert candidate(num = 123321) == 820028\n assert candidate(num = 99100099) == 88800088\n assert candidate(num = 543212345) == 800000008\n assert candidate(num = 599599599) == 800800800\n assert candidate(num = 100000000) == 800000000\n assert candidate(num = 12212212) == 82282282\n assert candidate(num = 8877665544332211) == 8800000000000000\n assert candidate(num = 109080706) == 809000000\n assert candidate(num = 888888888) == 888888888\n assert candidate(num = 890123456) == 800000000\n assert candidate(num = 543210987) == 800000000\n assert candidate(num = 111000111) == 888000888\n assert candidate(num = 98765432109876543210) == 81000000008100000000\n assert candidate(num = 10000000) == 80000000\n assert candidate(num = 90000009) == 89999998\n assert candidate(num = 1234321) == 8200028\n assert candidate(num = 999111111) == 888888888\n assert candidate(num = 110101010) == 880808080\n assert candidate(num = 20202020) == 80808080\n assert candidate(num = 567890123) == 800000000\n assert candidate(num = 5566778899) == 8800000000\n assert candidate(num = 909090909) == 898989898\n assert candidate(num = 44440000) == 88880000\n assert candidate(num = 3330333) == 8880888\n assert candidate(num = 10000001) == 80000008\n assert candidate(num = 111222333) == 888222000\n assert candidate(num = 9876543210) == 8100000000\n assert candidate(num = 9191919) == 8888888\n assert candidate(num = 98709870987) == 81008100810\n assert candidate(num = 334455667788) == 880000000000\n assert candidate(num = 122121) == 822828\n assert candidate(num = 8998) == 8008\n assert candidate(num = 77777777) == 88888888\n assert candidate(num = 88888888) == 88888888\n assert candidate(num = 19000000) == 89000000\n assert candidate(num = 200200200) == 800800800\n assert candidate(num = 1919191) == 8989898\n assert candidate(num = 918273645) == 880000000\n assert candidate(num = 100000001) == 800000008\n assert candidate(num = 11001100) == 88008800\n assert candidate(num = 59595959) == 80808080\n assert candidate(num = 209209209) == 800800800\n assert candidate(num = 1100110011) == 8800880088\n assert candidate(num = 333222111) == 888000000\n assert candidate(num = 999000) == 888999\n assert candidate(num = 90000000) == 89999999\n assert candidate(num = 1098765432) == 8090000000\n assert candidate(num = 101010101) == 808080808\n assert candidate(num = 57575757) == 80808080\n assert candidate(num = 123123123) == 820820820\n assert candidate(num = 777770777) == 888880888\n assert candidate(num = 123212321) == 820282028\n assert candidate(num = 90009) == 89998\n assert candidate(num = 1122334455) == 8822000000\n assert candidate(num = 100100100) == 800800800\n assert candidate(num = 99999999) == 88888888\n assert candidate(num = 100000) == 800000\n assert candidate(num = 109090909) == 809090909\n assert candidate(num = 999999999) == 888888888\n assert candidate(num = 1000100) == 8000800\n assert candidate(num = 19191919) == 89898989\n assert candidate(num = 202020202) == 808080808\n assert candidate(num = 1000001) == 8000008\n assert candidate(num = 44444444) == 88888888\n assert candidate(num = 8880888) == 8880888\n assert candidate(num = 191919191) == 898989898\n assert candidate(num = 1230123) == 8200820\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().maxDiff", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxDiff(self, num: int) -> int:", "container": "Solution", "callable": "maxDiff", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1433, "task_id": "check-if-a-string-can-break-another-string", "difficulty": "Medium", "problem_description": "Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa. In other words s2 can break s1 or vice-versa.\nA string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.\n \nExample 1:\n\nInput: s1 = \"abc\", s2 = \"xya\"\nOutput: true\nExplanation: \"ayx\" is a permutation of s2=\"xya\" which can break to string \"abc\" which is a permutation of s1=\"abc\".\n\nExample 2:\n\nInput: s1 = \"abe\", s2 = \"acd\"\nOutput: false \nExplanation: All permutations for s1=\"abe\" are: \"abe\", \"aeb\", \"bae\", \"bea\", \"eab\" and \"eba\" and all permutation for s2=\"acd\" are: \"acd\", \"adc\", \"cad\", \"cda\", \"dac\" and \"dca\". However, there is not any permutation from s1 which can break some permutation from s2 and vice-versa.\n\nExample 3:\n\nInput: s1 = \"leetcodee\", s2 = \"interview\"\nOutput: true\n\n \nConstraints:\n\ns1.length == n\ns2.length == n\n1 <= n <= 10^5\nAll strings consist of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"same\",s2 = \"same\") == True\n assert candidate(s1 = \"abc\",s2 = \"bca\") == True\n assert candidate(s1 = \"hello\",s2 = \"bello\") == True\n assert candidate(s1 = \"aazz\",s2 = \"zzaa\") == True\n assert candidate(s1 = \"abac\",s2 = \"baca\") == True\n assert candidate(s1 = \"xyz\",s2 = \"wvu\") == True\n assert candidate(s1 = \"abc\",s2 = \"xya\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"abcabc\") == True\n assert candidate(s1 = \"pqrs\",s2 = \"rstu\") == True\n assert candidate(s1 = \"zyx\",s2 = \"wvu\") == True\n assert candidate(s1 = \"abcd\",s2 = \"adcb\") == True\n assert candidate(s1 = \"aaa\",s2 = \"bbb\") == True\n assert candidate(s1 = \"abcd\",s2 = \"dcba\") == True\n assert candidate(s1 = \"abe\",s2 = \"acd\") == False\n assert candidate(s1 = \"leetcodee\",s2 = \"interview\") == True\n assert candidate(s1 = \"python\",s2 = \"typhon\") == True\n assert candidate(s1 = \"abcdxyz\",s2 = \"zyxwvut\") == True\n assert candidate(s1 = \"zzzz\",s2 = \"zzzz\") == True\n assert candidate(s1 = \"xyz\",s2 = \"zyx\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzyyxxwwvvuuttrrssqqpponnmlkkjjiihhggeeffddaabbcc\") == True\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s1 = \"algorithm\",s2 = \"logarithm\") == True\n assert candidate(s1 = \"longerstringwithvariouscharacters\",s2 = \"variouscharacterswithlongerstring\") == True\n assert candidate(s1 = \"zzzzzz\",s2 = \"aaaaaa\") == True\n assert candidate(s1 = \"unbreakable\",s2 = \"rebreakable\") == True\n assert candidate(s1 = \"abcdabcdabcd\",s2 = \"ddddcccbbbbaaa\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"ccbbaa\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"pippiimissi\") == True\n assert candidate(s1 = \"almostsame\",s2 = \"almostsane\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzzzyyxwwvvuutssrrqqponnmmllkkjjiihhggeeffdccbaaab\") == False\n assert candidate(s1 = \"racecar\",s2 = \"carrace\") == True\n assert candidate(s1 = \"thisisaverylongstringthatneedstobecomparesothattwostingsareofthesamelength\",s2 = \"somuchlongeranddifferentsomenecessarypaddingletterssotheyareofthesame\") == False\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"zyzxzyzyzxzyzyz\") == True\n assert candidate(s1 = \"abracadabra\",s2 = \"cadabrabara\") == True\n assert candidate(s1 = \"zyxwvutsrqponmlkjihgfedcba\",s2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(s1 = \"abcdefghijk\",s2 = \"fghijklmno\") == True\n assert candidate(s1 = \"abracadabra\",s2 = \"alakazamazam\") == False\n assert candidate(s1 = \"randomstringhere\",s2 = \"somestringrandom\") == True\n assert candidate(s1 = \"uniquechars\",s2 = \"distinctset\") == False\n assert candidate(s1 = \"aazzzzzzzzzzzzzzzz\",s2 = \"zzzzzzzzzzzzzzaa\") == True\n assert candidate(s1 = \"zzzzzzzz\",s2 = \"zzzzzzzz\") == True\n assert candidate(s1 = \"aabbbccc\",s2 = \"bbbcccaaa\") == True\n assert candidate(s1 = \"zzzzzzzzzz\",s2 = \"zzzzzzzzzz\") == True\n assert candidate(s1 = \"complex\",s2 = \"lexicom\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzyyxxwwvvuuttssrrqqppoonnmlkkjjiihhggffeeddccbbaa\") == True\n assert candidate(s1 = \"abcdxyzabcdxyz\",s2 = \"xyzabcdxyzabcd\") == True\n assert candidate(s1 = \"abcdefgh\",s2 = \"hgfedcba\") == True\n assert candidate(s1 = \"pppppppppp\",s2 = \"qqqqqqqqqq\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"fedcbaghij\") == True\n assert candidate(s1 = \"aaaaabbbbcccccddeeefffffgggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxxxyyyyyzzzzz\",s2 = \"zzzzzyyyyyxxxwwwvvvuuutttsssrqqppoonnmlkkkjjjiiihgggfffffeeedddccccbbbaaaa\") == True\n assert candidate(s1 = \"programming\",s2 = \"gnimmargorp\") == True\n assert candidate(s1 = \"permutation\",s2 = \"reupmttinao\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"pppnnnnmsssssiiii\") == True\n assert candidate(s1 = \"aabbccddeeffgghhii\",s2 = \"iihhggeeffddccbbaa\") == True\n assert candidate(s1 = \"abcdefghijk\",s2 = \"jihgfedcbaa\") == True\n assert candidate(s1 = \"xyzzzz\",s2 = \"zzzzxy\") == True\n assert candidate(s1 = \"medium\",s2 = \"median\") == True\n assert candidate(s1 = \"mnopqr\",s2 = \"qrstuv\") == True\n assert candidate(s1 = \"xyzyzyzyzyzyzyzyz\",s2 = \"zyxzyxzyxzyxzyxzy\") == True\n assert candidate(s1 = \"abcdefghijklnopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s1 = \"aaaabbbbccccdddd\",s2 = \"ddddccccbbbbaaaa\") == True\n assert candidate(s1 = \"thisisalongstring\",s2 = \"stringlongthisisalo\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"abcdefghijklmnopqrstuvwxyzzzyxwvutsrqponmlkjihgfedcbaaabb\") == True\n assert candidate(s1 = \"algorithm\",s2 = \"thmalogri\") == True\n assert candidate(s1 = \"xyzz\",s2 = \"yyzz\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzzzyyxwwvvuttsrrqqponnmlkkjjiihhggffeeeeddccbbaa\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"bbccaa\") == True\n assert candidate(s1 = \"aaaaabbbbbcccccc\",s2 = \"bbbbbaaaaacccccb\") == True\n assert candidate(s1 = \"abcdefghijklmnop\",s2 = \"ponmlkjihgfedcba\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"ppssiiimmm\") == False\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"zxyzyxzyxzyxzyxzyx\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"ghijkl\") == True\n assert candidate(s1 = \"aabbbcccddddeeeeffffgggghhhhiiiiiijjjjjjkkkkkkllllllmmmmmmmnnnnnnnooooooooppppppppqqqqqqqqrrrrrrrrssssssssstttttttttuuuuuuuuuvvvvvvvvvwwwwwwwwwxxxxxxxxxyyyyyyyyyzzzzzzzzz\",s2 = \"zzzzzzzzzyyyyyyyyyxxxxxxxxxwwwwwwwwwvvvvvvvvvuuuuuuuuutttttttttssssssssrrrrrrrrqqqqqqqqppppppppooooooonnnnnnnmmmmmmmllllllkkkkkkjjjjjjiiiiiiggggffffeeeeeeeeeddddddccccbbbaaa\") == True\n assert candidate(s1 = \"aaaabbbbcccc\",s2 = \"ccccbbbbaaaa\") == True\n assert candidate(s1 = \"aabcc\",s2 = \"bbdda\") == True\n assert candidate(s1 = \"congratulations\",s2 = \"stucgnioalort\") == True\n assert candidate(s1 = \"abcdabcdabcd\",s2 = \"dcbaabcddcba\") == True\n assert candidate(s1 = \"permutation\",s2 = \"nutationspr\") == True\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyzz\",s2 = \"zzzzzyzyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s1 = \"aaaaaaab\",s2 = \"baaaaaaa\") == True\n assert candidate(s1 = \"equalstring\",s2 = \"equalstring\") == True\n assert candidate(s1 = \"abcdefghijk\",s2 = \"zyxwvutsrqz\") == True\n assert candidate(s1 = \"aaaaaa\",s2 = \"bbbbbb\") == True\n assert candidate(s1 = \"abcdabcd\",s2 = \"dcbaabcd\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"jihgfedcba\") == True\n assert candidate(s1 = \"abcdabcdabcdabcdabcd\",s2 = \"dcbaabdcbaabdcbaabdcba\") == True\n assert candidate(s1 = \"optimization\",s2 = \"nttimzpiaoos\") == True\n assert candidate(s1 = \"optimization\",s2 = \"izationoptim\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghij\") == True\n assert candidate(s1 = \"leetcodeleetcode\",s2 = \"interviewinterview\") == True\n assert candidate(s1 = \"qwertypoiuytrewq\",s2 = \"mnbvcxzlkjhgfd\") == False\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"zyxzyxzyxzyxzyx\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"pississippi\") == True\n assert candidate(s1 = \"aaaaaaaaaabbbbbbbbbbcccccccccc\",s2 = \"ccccccccccbbbbbbbbbbaaaaaaaaaa\") == True\n assert candidate(s1 = \"longerstringexample\",s2 = \"examplelongerstring\") == True\n assert candidate(s1 = \"abacabacabacabac\",s2 = \"zyxzyxzyxzyxzyxzyx\") == True\n assert candidate(s1 = \"abcabcabc\",s2 = \"xyzxyzxyz\") == True\n assert candidate(s1 = \"pqrstuvw\",s2 = \"qrstuvwp\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"fedcba\") == True\n assert candidate(s1 = \"pqrsrpqrsrpqrsr\",s2 = \"zyxwzyxwzyxwzyx\") == True\n assert candidate(s1 = \"abcde\",s2 = \"edcba\") == True\n assert candidate(s1 = \"abcdefghijklnmopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s1 = \"abcdefghijabcdefghijabcdefghij\",s2 = \"zyxwvutsrqzyxwvutsrqzyxwvutsrq\") == True\n assert candidate(s1 = \"interview\",s2 = \"terviewin\") == True\n assert candidate(s1 = \"mnopqr\",s2 = \"rstuvw\") == True\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"zzzzzzzzzzzzzzz\") == True\n assert candidate(s1 = \"break\",s2 = \"maker\") == True\n assert candidate(s1 = \"qrstuv\",s2 = \"vwxyza\") == False\n assert candidate(s1 = \"permutation\",s2 = \"interwoven\") == True\n assert candidate(s1 = \"abcdxyz\",s2 = \"zyxcbaa\") == True\n assert candidate(s1 = \"zzzzz\",s2 = \"aaaaa\") == True\n assert candidate(s1 = \"aabbbccc\",s2 = \"cccbbbaa\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"ghijklm\") == True\n assert candidate(s1 = \"leetcode\",s2 = \"docodele\") == True\n assert candidate(s1 = \"xyzz\",s2 = \"wxyz\") == True\n assert candidate(s1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",s2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(s1 = \"zzzzzzzzzzzzzzzzzz\",s2 = \"aaaaaaaaaaaaaaaaaa\") == True\n assert candidate(s1 = \"banana\",s2 = \"anabna\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"ppissimiss\") == True\n"}, "metadata": {"canonical_parameter_names": ["s1", "s2"], "leetcode_dataset_entry_point": "Solution().checkIfCanBreak", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def checkIfCanBreak(self, s1: str, s2: str) -> bool:", "container": "Solution", "callable": "checkIfCanBreak", "parameters": [{"name": "s1", "type": "str"}, {"name": "s2", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1434, "task_id": "number-of-ways-to-wear-different-hats-to-each-other", "difficulty": "Hard", "problem_description": "There are n people and 40 types of hats labeled from 1 to 40.\nGiven a 2D integer array hats, where hats[i] is a list of all hats preferred by the ith person.\nReturn the number of ways that n people can wear different hats from each other.\nSince the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: hats = [[3,4],[4,5],[5]]\nOutput: 1\nExplanation: There is only one way to choose hats given the conditions. \nFirst person choose hat 3, Second person choose hat 4 and last one hat 5.\n\nExample 2:\n\nInput: hats = [[3,5,1],[3,5]]\nOutput: 4\nExplanation: There are 4 ways to choose hats:\n(3,5), (5,3), (1,3) and (1,5)\n\nExample 3:\n\nInput: hats = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]\nOutput: 24\nExplanation: Each person can choose hats labeled from 1 to 4.\nNumber of Permutations of (1,2,3,4) = 24.\n\n \nConstraints:\n\nn == hats.length\n1 <= n <= 10\n1 <= hats[i].length <= 40\n1 <= hats[i][j] <= 40\nhats[i] contains a list of unique integers.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(hats = [[1, 2], [3, 4], [5, 6]]) == 8\n assert candidate(hats = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60]]) == 26\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 40\n assert candidate(hats = [[1, 2], [3, 4], [5, 6], [7, 8]]) == 16\n assert candidate(hats = [[10, 20, 30], [20, 30, 40], [30, 40, 50]]) == 14\n assert candidate(hats = [[1], [1, 2], [1, 2, 3], [1, 2, 3, 4]]) == 1\n assert candidate(hats = [[1, 2], [2, 3], [3, 4]]) == 4\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]) == 25\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 100\n assert candidate(hats = [[1], [2], [3], [4], [5]]) == 1\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 90\n assert candidate(hats = [[1], [1], [1], [1], [1], [1], [1], [1], [1], [1]]) == 0\n assert candidate(hats = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) == 26\n assert candidate(hats = [[3], [5], [1], [2]]) == 1\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 90\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 10000\n assert candidate(hats = [[3, 5, 1], [3, 5]]) == 4\n assert candidate(hats = [[3, 4], [4, 5], [5]]) == 1\n assert candidate(hats = [[1, 2, 3], [2, 3, 4], [3, 4, 5]]) == 14\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29]]) == 625\n assert candidate(hats = [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]) == 24\n assert candidate(hats = [[1, 4, 7, 10, 13], [2, 5, 8, 11, 14], [3, 6, 9, 12, 15], [1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20]]) == 38130\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 2250\n assert candidate(hats = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]]) == 7600\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 90000\n assert candidate(hats = [[3, 4, 5], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) == 20\n assert candidate(hats = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 1024\n assert candidate(hats = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9], [6, 7, 8, 9, 10]]) == 2108\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 10000\n assert candidate(hats = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]) == 0\n assert candidate(hats = [[3, 4, 5, 6, 7, 8, 9, 10], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 9580\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 40\n assert candidate(hats = [[3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 28196\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 2193360\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 30240\n assert candidate(hats = [[1, 5, 9, 13, 17, 21, 25, 29, 33, 37], [2, 6, 10, 14, 18, 22, 26, 30, 34, 38], [3, 7, 11, 15, 19, 23, 27, 31, 35, 39], [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]]) == 10000\n assert candidate(hats = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 1712256\n assert candidate(hats = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 0\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 720\n assert candidate(hats = [[3, 5, 10], [3, 7, 11], [5, 9, 12], [8, 11, 15], [10, 13, 17]]) == 141\n assert candidate(hats = [[3, 4, 5, 6], [1, 2, 3, 4], [2, 3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9]]) == 315\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]]) == 11400\n assert candidate(hats = [[1, 40], [2, 39], [3, 38], [4, 37], [5, 36], [6, 35], [7, 34], [8, 33], [9, 32], [10, 31], [11, 30], [12, 29], [13, 28], [14, 27], [15, 26], [16, 25], [17, 24], [18, 23], [19, 22], [20, 21]]) == 1048576\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 900\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20], [21, 23, 25, 27, 29]]) == 3125\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 144400\n assert candidate(hats = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]]) == 1\n assert candidate(hats = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12]]) == 596\n assert candidate(hats = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 243\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 400\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [1, 6, 11, 16, 21], [2, 7, 12, 17, 22], [3, 8, 13, 18, 23], [4, 9, 14, 19, 24], [5, 10, 15, 20, 25]]) == 473100\n assert candidate(hats = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10, 1], [1, 3, 5], [5, 7, 9], [9, 11, 13], [13, 15, 17], [17, 19, 21]]) == 2723\n assert candidate(hats = [[1], [1, 2], [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 1\n assert candidate(hats = [[1, 10, 19, 28, 37], [2, 11, 20, 29, 38], [3, 12, 21, 30, 39], [4, 13, 22, 31, 40], [5, 14, 23, 32], [6, 15, 24, 33], [7, 16, 25, 34], [8, 17, 26, 35], [9, 18, 27, 36]]) == 640000\n assert candidate(hats = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]) == 120\n assert candidate(hats = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == 1\n assert candidate(hats = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40]]) == 390625\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]) == 1000\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 300\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 4, 7, 10], [2, 5, 8], [3, 6, 9]]) == 416\n assert candidate(hats = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27], [28, 29, 30]]) == 59049\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 3628800\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 308055528\n assert candidate(hats = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]) == 738\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 1560\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 720\n assert candidate(hats = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 3125\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 30240\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 880\n assert candidate(hats = [[3, 5, 1], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23], [23, 25], [25, 27], [27, 29], [29, 31], [31, 33], [33, 35], [35, 37], [37, 39], [39, 40]]) == 22\n assert candidate(hats = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]]) == 400\n assert candidate(hats = [[10, 20, 30, 40], [11, 21, 31, 41], [12, 22, 32, 42], [13, 23, 33, 43], [14, 24, 34, 44], [15, 25, 35, 45], [16, 26, 36, 46], [17, 27, 37, 47], [18, 28, 38, 48], [19, 29, 39, 49]]) == 1048576\n assert candidate(hats = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]]) == 400\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 40688\n assert candidate(hats = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27], [28, 29, 30], [31, 32, 33], [34, 35, 36], [37, 38, 39], [40]]) == 1594323\n assert candidate(hats = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]]) == 221\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]]) == 5766\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 400\n assert candidate(hats = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 7600\n assert candidate(hats = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40]]) == 390625\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 5040\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 1560\n assert candidate(hats = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12]]) == 596\n"}, "metadata": {"canonical_parameter_names": ["hats"], "leetcode_dataset_entry_point": "Solution().numberWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numberWays(self, hats: list[list[int]]) -> int:", "container": "Solution", "callable": "numberWays", "parameters": [{"name": "hats", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1436, "task_id": "destination-city", "difficulty": "Easy", "problem_description": "You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination city, that is, the city without any path outgoing to another city.\nIt is guaranteed that the graph of paths forms a line without any loop, therefore, there will be exactly one destination city.\n \nExample 1:\n\nInput: paths = [[\"London\",\"New York\"],[\"New York\",\"Lima\"],[\"Lima\",\"Sao Paulo\"]]\nOutput: \"Sao Paulo\" \nExplanation: Starting at \"London\" city you will reach \"Sao Paulo\" city which is the destination city. Your trip consist of: \"London\" -> \"New York\" -> \"Lima\" -> \"Sao Paulo\".\n\nExample 2:\n\nInput: paths = [[\"B\",\"C\"],[\"D\",\"B\"],[\"C\",\"A\"]]\nOutput: \"A\"\nExplanation: All possible trips are: \n\"D\" -> \"B\" -> \"C\" -> \"A\". \n\"B\" -> \"C\" -> \"A\". \n\"C\" -> \"A\". \n\"A\". \nClearly the destination city is \"A\".\n\nExample 3:\n\nInput: paths = [[\"A\",\"Z\"]]\nOutput: \"Z\"\n\n \nConstraints:\n\n1 <= paths.length <= 100\npaths[i].length == 2\n1 <= cityAi.length, cityBi.length <= 10\ncityAi != cityBi\nAll strings consist of lowercase and uppercase English letters and the space character.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(paths = [['X', 'Y'], ['Y', 'Z'], ['Z', 'W']]) == \"W\"\n assert candidate(paths = [['Chicago', 'Los Angeles'], ['New York', 'Chicago']]) == \"Los Angeles\"\n assert candidate(paths = [['Chicago', 'Los Angeles'], ['Los Angeles', 'Las Vegas']]) == \"Las Vegas\"\n assert candidate(paths = [['Paris', 'Berlin'], ['Berlin', 'Madrid'], ['Madrid', 'Rome']]) == \"Rome\"\n assert candidate(paths = [['B', 'C'], ['D', 'B'], ['C', 'A']]) == \"A\"\n assert candidate(paths = [['Paris', 'Berlin'], ['Berlin', 'Madrid']]) == \"Madrid\"\n assert candidate(paths = [['A', 'Z']]) == \"Z\"\n assert candidate(paths = [['Chicago', 'Los Angeles'], ['Miami', 'Chicago'], ['Los Angeles', 'New York']]) == \"New York\"\n assert candidate(paths = [['London', 'New York'], ['New York', 'Lima'], ['Lima', 'Sao Paulo']]) == \"Sao Paulo\"\n assert candidate(paths = [['Boston', 'New York'], ['New York', 'Philadelphia'], ['Philadelphia', 'Washington'], ['Washington', 'Baltimore'], ['Baltimore', 'Annapolis']]) == \"Annapolis\"\n assert candidate(paths = [['Alpha', 'Beta'], ['Beta', 'Gamma'], ['Gamma', 'Delta'], ['Delta', 'Epsilon'], ['Epsilon', 'Zeta'], ['Zeta', 'Eta']]) == \"Eta\"\n assert candidate(paths = [['Newark', 'Boston'], ['Boston', 'Philadelphia'], ['Philadelphia', 'New York'], ['New York', 'Washington DC'], ['Washington DC', 'Miami'], ['Miami', 'Orlando'], ['Orlando', 'Jacksonville'], ['Jacksonville', 'Atlanta']]) == \"Atlanta\"\n assert candidate(paths = [['A', 'B'], ['B', 'C'], ['C', 'D'], ['D', 'E'], ['E', 'F'], ['F', 'G'], ['G', 'H'], ['H', 'I'], ['I', 'J'], ['J', 'K']]) == \"K\"\n assert candidate(paths = [['Berlin', 'Hamburg'], ['Hamburg', 'Copenhagen'], ['Copenhagen', 'Stockholm'], ['Stockholm', 'Oslo'], ['Oslo', 'Trondheim']]) == \"Trondheim\"\n assert candidate(paths = [['New York', 'Boston'], ['Boston', 'Chicago'], ['Chicago', 'Denver'], ['Denver', 'Seattle'], ['Seattle', 'San Francisco'], ['San Francisco', 'Los Angeles']]) == \"Los Angeles\"\n assert candidate(paths = [['San Francisco', 'Los Angeles'], ['Los Angeles', 'San Diego'], ['San Diego', 'Phoenix'], ['Phoenix', 'Las Vegas']]) == \"Las Vegas\"\n assert candidate(paths = [['Alpha', 'Beta'], ['Gamma', 'Delta'], ['Delta', 'Epsilon'], ['Epsilon', 'Zeta'], ['Zeta', 'Eta'], ['Eta', 'Theta']]) == \"Beta\"\n assert candidate(paths = [['Mars', 'Venus'], ['Venus', 'Earth'], ['Earth', 'Mars2'], ['Mars2', 'Jupiter'], ['Jupiter', 'Saturn'], ['Saturn', 'Uranus'], ['Uranus', 'Neptune']]) == \"Neptune\"\n assert candidate(paths = [['Berlin', 'Hamburg'], ['Hamburg', 'Munich'], ['Munich', 'Stuttgart'], ['Stuttgart', 'Frankfurt'], ['Frankfurt', 'Düsseldorf'], ['Düsseldorf', 'Cologne'], ['Cologne', 'Dortmund'], ['Dortmund', 'Wuppertal']]) == \"Wuppertal\"\n assert candidate(paths = [['Vienna', 'Bratislava'], ['Bratislava', 'Budapest'], ['Budapest', 'Belgrade'], ['Belgrade', 'Sofia'], ['Sofia', 'Athens'], ['Athens', 'Thessaloniki'], ['Thessaloniki', 'Skopje'], ['Skopje', 'Zagreb'], ['Zagreb', 'Ljubljana'], ['Ljubljana', 'Maribor']]) == \"Maribor\"\n assert candidate(paths = [['Delhi', 'Agra'], ['Agra', 'Jaipur'], ['Jaipur', 'Jodhpur'], ['Jodhpur', 'Jaisalmer'], ['Jaisalmer', 'Bikaner'], ['Bikaner', 'Ajmer'], ['Ajmer', 'Udaipur'], ['Udaipur', 'Rajkot'], ['Rajkot', 'Surat']]) == \"Surat\"\n assert candidate(paths = [['Beijing', 'Tokyo'], ['Tokyo', 'Seoul'], ['Seoul', 'Osaka'], ['Osaka', 'Fukuoka'], ['Fukuoka', 'Nagoya'], ['Nagoya', 'Kyoto'], ['Kyoto', 'Sapporo']]) == \"Sapporo\"\n assert candidate(paths = [['X', 'Y'], ['Y', 'Z'], ['Z', 'W'], ['W', 'V'], ['V', 'U'], ['U', 'T'], ['T', 'S'], ['S', 'R'], ['R', 'Q']]) == \"Q\"\n assert candidate(paths = [['Atlanta', 'Charlotte'], ['Charlotte', 'Miami'], ['Miami', 'Tampa'], ['Tampa', 'Orlando'], ['Orlando', 'Fort Lauderdale'], ['Fort Lauderdale', 'Key West']]) == \"Key West\"\n assert candidate(paths = [['San Francisco', 'Los Angeles'], ['Los Angeles', 'Las Vegas'], ['Las Vegas', 'Seattle'], ['Seattle', 'Portland']]) == \"Portland\"\n assert candidate(paths = [['San Francisco', 'Seattle'], ['Seattle', 'Denver'], ['Denver', 'Austin'], ['Austin', 'Houston']]) == \"Houston\"\n assert candidate(paths = [['Casablanca', 'Tangier'], ['Tangier', 'Fes'], ['Fes', 'Meknes'], ['Meknes', 'Fez'], ['Fez', 'Rabat'], ['Rabat', 'Agadir'], ['Agadir', 'Essaouira'], ['Essaouira', 'Marrakesh']]) == \"Marrakesh\"\n assert candidate(paths = [['Chicago', 'Milwaukee'], ['Milwaukee', 'Des Moines'], ['Des Moines', 'Omaha'], ['Omaha', 'Denver'], ['Denver', 'Albuquerque'], ['Albuquerque', 'El Paso'], ['El Paso', 'Las Vegas'], ['Las Vegas', 'Los Angeles']]) == \"Los Angeles\"\n assert candidate(paths = [['Toronto', 'Ottawa'], ['Ottawa', 'Montreal'], ['Montreal', 'Quebec'], ['Quebec', 'Halifax'], ['Halifax', \"St. John's\"], [\"St. John's\", 'Gander']]) == \"Gander\"\n assert candidate(paths = [['Rome', 'Florence'], ['Florence', 'Venice'], ['Venice', 'Milan'], ['Milan', 'Turin'], ['Turin', 'Genoa'], ['Genoa', 'Pisa'], ['Pisa', 'Lyon']]) == \"Lyon\"\n assert candidate(paths = [['Miami', 'Los Angeles'], ['Los Angeles', 'Seattle'], ['Seattle', 'Portland'], ['Portland', 'Vancouver'], ['Vancouver', 'Calgary'], ['Calgary', 'Edmonton'], ['Edmonton', 'Winnipeg']]) == \"Winnipeg\"\n assert candidate(paths = [['Paris', 'Lyon'], ['Lyon', 'Lyon'], ['Lyon', 'Marseille'], ['Marseille', 'Toulouse'], ['Toulouse', 'Nice']]) == \"Nice\"\n assert candidate(paths = [['Sydney', 'Melbourne'], ['Melbourne', 'Brisbane'], ['Brisbane', 'Adelaide'], ['Adelaide', 'Perth'], ['Perth', 'Alice Springs'], ['Alice Springs', 'Cairns']]) == \"Cairns\"\n assert candidate(paths = [['Berlin', 'Hamburg'], ['Hamburg', 'Munich'], ['Munich', 'Frankfurt'], ['Frankfurt', 'Stuttgart'], ['Stuttgart', 'Dortmund'], ['Dortmund', 'Cologne']]) == \"Cologne\"\n assert candidate(paths = [['First', 'Second'], ['Second', 'Third'], ['Third', 'Fourth'], ['Fourth', 'Fifth'], ['Fifth', 'Sixth'], ['Sixth', 'Seventh'], ['Seventh', 'Eighth'], ['Eighth', 'Ninth'], ['Ninth', 'Tenth'], ['Tenth', 'Eleventh'], ['Eleventh', 'Twelfth'], ['Twelfth', 'Thirteenth'], ['Thirteenth', 'Fourteenth'], ['Fourteenth', 'Fifteenth'], ['Fifteenth', 'Sixteenth'], ['Sixteenth', 'Seventeenth'], ['Seventeenth', 'Eighteenth'], ['Eighteenth', 'Nineteenth'], ['Nineteenth', 'Twentieth'], ['Twentieth', 'TwentyFirst'], ['TwentyFirst', 'TwentySecond'], ['TwentySecond', 'TwentyThird'], ['TwentyThird', 'TwentyFourth'], ['TwentyFourth', 'TwentyFifth']]) == \"TwentyFifth\"\n assert candidate(paths = [['New York', 'Chicago'], ['Chicago', 'Denver'], ['Denver', 'Phoenix'], ['Phoenix', 'Los Angeles'], ['Los Angeles', 'San Francisco']]) == \"San Francisco\"\n assert candidate(paths = [['Oslo', 'Stockholm'], ['Stockholm', 'Helsinki'], ['Helsinki', 'Riga'], ['Riga', 'Vilnius'], ['Vilnius', 'Warsaw'], ['Warsaw', 'Krakow'], ['Krakow', 'Berlin'], ['Berlin', 'Hamburg']]) == \"Hamburg\"\n assert candidate(paths = [['Istanbul', 'Ankara'], ['Ankara', 'Eskisehir'], ['Eskisehir', 'Konya'], ['Konya', 'Gaziantep'], ['Gaziantep', 'Sanliurfa'], ['Sanliurfa', 'Mardin'], ['Mardin', 'Diyarbakir'], ['Diyarbakir', 'Siirt'], ['Siirt', 'Elazig'], ['Elazig', 'Malatya']]) == \"Malatya\"\n assert candidate(paths = [['Vienna', 'Innsbruck'], ['Innsbruck', 'Graz'], ['Graz', 'Linz'], ['Linz', 'Salzburg'], ['Salzburg', 'Wien'], ['Wien', 'Graz'], ['Graz', 'Ljubljana'], ['Ljubljana', 'Zagreb'], ['Zagreb', 'Belgrade'], ['Belgrade', 'Sofia'], ['Sofia', 'Bucharest'], ['Bucharest', 'Bucuresti']]) == \"Bucuresti\"\n assert candidate(paths = [['Vancouver', 'Calgary'], ['Calgary', 'Edmonton'], ['Edmonton', 'Winnipeg'], ['Winnipeg', 'Thunder Bay'], ['Thunder Bay', 'Toronto'], ['Toronto', 'Ottawa'], ['Ottawa', 'Quebec City'], ['Quebec City', 'Montreal']]) == \"Montreal\"\n assert candidate(paths = [['Tokyo', 'Osaka'], ['Osaka', 'Kyoto'], ['Kyoto', 'Nagoya'], ['Nagoya', 'Fukuoka'], ['Fukuoka', 'Sapporo']]) == \"Sapporo\"\n assert candidate(paths = [['New York', 'Boston'], ['Boston', 'Chicago'], ['Chicago', 'Houston'], ['Houston', 'Miami'], ['Miami', 'Orlando']]) == \"Orlando\"\n assert candidate(paths = [['Lagos', 'Kano'], ['Kano', 'Ilorin'], ['Ilorin', 'Ibadan'], ['Ibadan', 'Osogbo'], ['Osogbo', 'Akure'], ['Akure', 'Ondo'], ['Ondo', 'Port Harcourt'], ['Port Harcourt', 'Calabar'], ['Calabar', 'Cross River']]) == \"Cross River\"\n assert candidate(paths = [['Miami', 'Orlando'], ['Orlando', 'Atlanta'], ['Atlanta', 'Chicago'], ['Chicago', 'Denver'], ['Denver', 'Las Vegas'], ['Las Vegas', 'Seattle']]) == \"Seattle\"\n assert candidate(paths = [['Hyderabad', 'Bangalore'], ['Bangalore', 'Mysuru'], ['Mysuru', 'Mangalore'], ['Mangalore', 'Udupi'], ['Udupi', 'Karwar']]) == \"Karwar\"\n assert candidate(paths = [['Mumbai', 'Delhi'], ['Delhi', 'Chennai'], ['Chennai', 'Bangalore'], ['Bangalore', 'Hyderabad'], ['Hyderabad', 'Ahmedabad'], ['Ahmedabad', 'Kolkata']]) == \"Kolkata\"\n assert candidate(paths = [['Vienna', 'Salzburg'], ['Salzburg', 'Innsbruck'], ['Innsbruck', 'Linz'], ['Linz', 'Graz'], ['Graz', 'Steyr'], ['Steyr', 'Klagenfurt']]) == \"Klagenfurt\"\n assert candidate(paths = [['M', 'N'], ['O', 'M'], ['P', 'O'], ['Q', 'P'], ['R', 'Q'], ['S', 'R'], ['T', 'S']]) == \"N\"\n assert candidate(paths = [['Houston', 'Dallas'], ['Dallas', 'San Antonio'], ['San Antonio', 'El Paso'], ['El Paso', 'Las Vegas'], ['Las Vegas', 'Los Angeles'], ['Los Angeles', 'Sacramento']]) == \"Sacramento\"\n assert candidate(paths = [['Lisbon', 'Porto'], ['Porto', 'Braga'], ['Braga', 'Guimaraes'], ['Guimaraes', 'Vila Real'], ['Vila Real', 'Braganca'], ['Braganca', 'Viseu'], ['Viseu', 'Guarda'], ['Guarda', 'Castelo Branco'], ['Castelo Branco', 'Coimbra'], ['Coimbra', 'Leiria'], ['Leiria', 'Faro'], ['Faro', 'Evora']]) == \"Evora\"\n assert candidate(paths = [['Sydney', 'Melbourne'], ['Melbourne', 'Brisbane'], ['Brisbane', 'Perth'], ['Perth', 'Adelaide'], ['Adelaide', 'Darwin']]) == \"Darwin\"\n assert candidate(paths = [['Berlin', 'Hamburg'], ['Hamburg', 'Frankfurt'], ['Frankfurt', 'Munich'], ['Munich', 'Stuttgart'], ['Stuttgart', 'Zurich'], ['Zurich', 'Geneva'], ['Geneva', 'Lyon']]) == \"Lyon\"\n assert candidate(paths = [['Origin', 'FirstStop'], ['FirstStop', 'SecondStop'], ['SecondStop', 'ThirdStop'], ['ThirdStop', 'FourthStop'], ['FourthStop', 'FifthStop'], ['FifthStop', 'SixthStop'], ['SixthStop', 'SeventhStop'], ['SeventhStop', 'EighthStop'], ['EighthStop', 'NinthStop'], ['NinthStop', 'TenthStop'], ['TenthStop', 'EleventhStop'], ['EleventhStop', 'TwelfthStop'], ['TwelfthStop', 'ThirteenthStop'], ['ThirteenthStop', 'FourteenthStop'], ['FourteenthStop', 'FifteenthStop'], ['FifteenthStop', 'SixteenthStop'], ['SixteenthStop', 'SeventeenthStop'], ['SeventeenthStop', 'EighteenthStop'], ['EighteenthStop', 'NineteenthStop'], ['NineteenthStop', 'TwentiethStop'], ['TwentiethStop', 'TwentyFirstStop'], ['TwentyFirstStop', 'TwentySecondStop'], ['TwentySecondStop', 'TwentyThirdStop'], ['TwentyThirdStop', 'TwentyFourthStop'], ['TwentyFourthStop', 'TwentyFifthStop'], ['TwentyFifthStop', 'Destination']]) == \"Destination\"\n assert candidate(paths = [['Sydney', 'Melbourne'], ['Melbourne', 'Brisbane'], ['Brisbane', 'Perth'], ['Perth', 'Adelaide'], ['Adelaide', 'Darwin'], ['Darwin', 'Canberra']]) == \"Canberra\"\n assert candidate(paths = [['Paris', 'Berlin'], ['Berlin', 'Vienna'], ['Vienna', 'Budapest'], ['Budapest', 'Prague'], ['Prague', 'Warsaw'], ['Warsaw', 'Krakow']]) == \"Krakow\"\n assert candidate(paths = [['San Francisco', 'Los Angeles'], ['Los Angeles', 'Phoenix'], ['Phoenix', 'Denver'], ['Denver', 'Chicago']]) == \"Chicago\"\n assert candidate(paths = [['Vienna', 'Prague'], ['Prague', 'Bratislava'], ['Bratislava', 'Budapest'], ['Budapest', 'Belgrade'], ['Belgrade', 'Sofia'], ['Sofia', 'Istanbul'], ['Istanbul', 'Athens'], ['Athens', 'Delhi'], ['Delhi', 'Mumbai']]) == \"Mumbai\"\n assert candidate(paths = [['Toronto', 'Ottawa'], ['Ottawa', 'Montreal'], ['Montreal', 'Quebec City'], ['Quebec City', \"St. John's\"]]) == \"St. John's\"\n assert candidate(paths = [['Alpha', 'Beta'], ['Gamma', 'Alpha'], ['Delta', 'Gamma'], ['Epsilon', 'Delta'], ['Zeta', 'Epsilon']]) == \"Beta\"\n assert candidate(paths = [['Tokyo', 'Osaka'], ['Osaka', 'Kyoto'], ['Kyoto', 'Fukuoka'], ['Fukuoka', 'Sapporo'], ['Sapporo', 'Hokkaido'], ['Hokkaido', 'Nagoya'], ['Nagoya', 'Yokohama']]) == \"Yokohama\"\n assert candidate(paths = [['Seattle', 'Portland'], ['Portland', 'Eugene'], ['Eugene', 'Bend'], ['Bend', 'Medford'], ['Medford', 'Ashland'], ['Ashland', 'Crater Lake']]) == \"Crater Lake\"\n assert candidate(paths = [['San Francisco', 'San Jose'], ['San Jose', 'San Diego'], ['San Diego', 'Los Angeles'], ['Los Angeles', 'Las Vegas'], ['Las Vegas', 'Reno'], ['Reno', 'Salt Lake City'], ['Salt Lake City', 'Denver'], ['Denver', 'Kansas City'], ['Kansas City', 'Omaha'], ['Omaha', 'Chicago'], ['Chicago', 'Milwaukee'], ['Milwaukee', 'Madison'], ['Madison', 'Green Bay']]) == \"Green Bay\"\n assert candidate(paths = [['NodeA', 'NodeB'], ['NodeB', 'NodeC'], ['NodeC', 'NodeD'], ['NodeD', 'NodeE'], ['NodeE', 'NodeF'], ['NodeF', 'NodeG'], ['NodeG', 'NodeH'], ['NodeH', 'NodeI'], ['NodeI', 'NodeJ'], ['NodeJ', 'NodeK'], ['NodeK', 'NodeL'], ['NodeL', 'NodeM'], ['NodeM', 'NodeN'], ['NodeN', 'NodeO'], ['NodeO', 'NodeP'], ['NodeP', 'NodeQ'], ['NodeQ', 'NodeR'], ['NodeR', 'NodeS'], ['NodeS', 'NodeT']]) == \"NodeT\"\n assert candidate(paths = [['Oslo', 'Helsinki'], ['Helsinki', 'Stockholm'], ['Stockholm', 'Reykjavik'], ['Reykjavik', 'Vilnius'], ['Vilnius', 'Riga']]) == \"Riga\"\n assert candidate(paths = [['A', 'B'], ['B', 'C'], ['C', 'D'], ['D', 'E'], ['E', 'F'], ['F', 'G'], ['G', 'H']]) == \"H\"\n assert candidate(paths = [['Start', 'Middle'], ['Middle', 'End1'], ['End1', 'End2'], ['End2', 'End3'], ['End3', 'End4'], ['End4', 'FinalDestination']]) == \"FinalDestination\"\n assert candidate(paths = [['Doha', 'Abu Dhabi'], ['Abu Dhabi', 'Masqat'], ['Masqat', 'Dubai'], ['Dubai', 'Sharjah'], ['Sharjah', 'Ras Al Khaimah'], ['Ras Al Khaimah', 'Fujairah']]) == \"Fujairah\"\n assert candidate(paths = [['Sydney', 'Melbourne'], ['Melbourne', 'Brisbane'], ['Brisbane', 'Perth'], ['Perth', 'Adelaide'], ['Adelaide', 'Gold Coast'], ['Gold Coast', 'Darwin'], ['Darwin', 'Alice Springs'], ['Alice Springs', 'Uluru']]) == \"Uluru\"\n assert candidate(paths = [['Los Angeles', 'San Diego'], ['San Diego', 'San Jose'], ['San Jose', 'Sacramento'], ['Sacramento', 'Reno'], ['Reno', 'Salt Lake City'], ['Salt Lake City', 'Boise'], ['Boise', 'Spokane']]) == \"Spokane\"\n assert candidate(paths = [['New Delhi', 'Bangalore'], ['Bangalore', 'Chennai'], ['Chennai', 'Hyderabad'], ['Hyderabad', 'Mumbai'], ['Mumbai', 'Pune'], ['Pune', 'Kochi'], ['Kochi', 'Trivandrum']]) == \"Trivandrum\"\n assert candidate(paths = [['Sydney', 'Melbourne'], ['Melbourne', 'Brisbane'], ['Brisbane', 'Perth'], ['Perth', 'Adelaide'], ['Adelaide', 'Alice Springs']]) == \"Alice Springs\"\n assert candidate(paths = [['Tokyo', 'Osaka'], ['Osaka', 'Kyoto'], ['Kyoto', 'Nagoya'], ['Nagoya', 'Fukuoka'], ['Fukuoka', 'Sapporo'], ['Sapporo', 'Hokkaido']]) == \"Hokkaido\"\n assert candidate(paths = [['Cairo', 'Luxor'], ['Luxor', 'Aswan'], ['Aswan', 'Assiut'], ['Assiut', 'Ismailia'], ['Ismailia', 'Suez'], ['Suez', 'Port Said'], ['Port Said', 'Alexandria'], ['Alexandria', 'Damietta'], ['Damietta', 'Mansoura'], ['Mansoura', 'Tanta'], ['Tanta', 'Qena']]) == \"Qena\"\n assert candidate(paths = [['Kuala Lumpur', 'George Town'], ['George Town', 'Ipoh'], ['Ipoh', 'Perak'], ['Perak', 'Klang'], ['Klang', 'Petaling Jaya']]) == \"Petaling Jaya\"\n"}, "metadata": {"canonical_parameter_names": ["paths"], "leetcode_dataset_entry_point": "Solution().destCity", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def destCity(self, paths: list[list[str]]) -> str:", "container": "Solution", "callable": "destCity", "parameters": [{"name": "paths", "type": "list[list[str]]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1437, "task_id": "check-if-all-1s-are-at-least-length-k-places-away", "difficulty": "Easy", "problem_description": "Given an binary array nums and an integer k, return true if all 1's are at least k places away from each other, otherwise return false.\n \nExample 1:\n\n\nInput: nums = [1,0,0,0,1,0,0,1], k = 2\nOutput: true\nExplanation: Each of the 1s are at least 2 places away from each other.\n\nExample 2:\n\n\nInput: nums = [1,0,0,1,0,1], k = 2\nOutput: false\nExplanation: The second 1 and third 1 are only one apart from each other.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= k <= nums.length\nnums[i] is 0 or 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 0, 0, 0, 0],k = 1) == False\n assert candidate(nums = [0, 1, 0, 1, 0, 1],k = 1) == True\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],k = 2) == True\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 0, 0, 1],k = 1) == False\n assert candidate(nums = [1, 1, 1, 1, 1],k = 0) == True\n assert candidate(nums = [1],k = 1) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1],k = 2) == True\n assert candidate(nums = [0, 0, 0, 0, 0],k = 1) == True\n assert candidate(nums = [1],k = 0) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == False\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1],k = 1) == True\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1],k = 0) == True\n assert candidate(nums = [0, 0, 0, 0, 0],k = 3) == True\n assert candidate(nums = [1, 1, 0, 1],k = 0) == True\n assert candidate(nums = [1, 0, 0, 1, 0, 1],k = 2) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 150) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 3) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 15) == True\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 1) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 20) == True\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 70) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == True\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 1) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 15) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 15) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 100) == True\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 20) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 20) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 60) == True\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],k = 5) == False\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 2) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 10) == False\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == True\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 1) == True\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 0) == True\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1) == False\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 0) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == True\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 30) == True\n assert candidate(nums = [1, 0, 1, 0, 0, 1, 0, 0, 0, 1],k = 1) == True\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 4) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],k = 6) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 40) == True\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 19) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 50) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 9) == True\n assert candidate(nums = [1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1],k = 2) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],k = 7) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 20) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 30) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 0) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 25) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 30) == False\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == True\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == True\n assert candidate(nums = [0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 20) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 5) == False\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 9) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 18) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1) == True\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 2) == True\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().kLengthApart", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def kLengthApart(self, nums: list[int], k: int) -> bool:", "container": "Solution", "callable": "kLengthApart", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1438, "task_id": "longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit", "difficulty": "Medium", "problem_description": "Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray is less than or equal to limit.\n \nExample 1:\n\nInput: nums = [8,2,4,7], limit = 4\nOutput: 2 \nExplanation: All subarrays are: \n[8] with maximum absolute diff |8-8| = 0 <= 4.\n[8,2] with maximum absolute diff |8-2| = 6 > 4. \n[8,2,4] with maximum absolute diff |8-2| = 6 > 4.\n[8,2,4,7] with maximum absolute diff |8-2| = 6 > 4.\n[2] with maximum absolute diff |2-2| = 0 <= 4.\n[2,4] with maximum absolute diff |2-4| = 2 <= 4.\n[2,4,7] with maximum absolute diff |2-7| = 5 > 4.\n[4] with maximum absolute diff |4-4| = 0 <= 4.\n[4,7] with maximum absolute diff |4-7| = 3 <= 4.\n[7] with maximum absolute diff |7-7| = 0 <= 4. \nTherefore, the size of the longest subarray is 2.\n\nExample 2:\n\nInput: nums = [10,1,2,4,7,2], limit = 5\nOutput: 4 \nExplanation: The subarray [2,4,7,2] is the longest since the maximum absolute diff is |2-7| = 5 <= 5.\n\nExample 3:\n\nInput: nums = [4,2,2,2,4,4,2,2], limit = 0\nOutput: 3\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n0 <= limit <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 2) == 3\n assert candidate(nums = [100, 101, 102, 103, 104],limit = 3) == 4\n assert candidate(nums = [4, 2, 2, 2, 4, 4, 2, 2],limit = 0) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 2) == 3\n assert candidate(nums = [1, 2],limit = 1) == 2\n assert candidate(nums = [1],limit = 1) == 1\n assert candidate(nums = [1, 3, 6, 8, 10, 15],limit = 2) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],limit = 0) == 7\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 4) == 5\n assert candidate(nums = [1, 5, 6, 7, 8, 10],limit = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 9) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5) == 6\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 1) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],limit = 0) == 5\n assert candidate(nums = [10, 1, 2, 4, 7, 2],limit = 5) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 0) == 1\n assert candidate(nums = [8, 2, 4, 7],limit = 4) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],limit = 10) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 2) == 3\n assert candidate(nums = [1, 5, 6, 7, 8, 10, 6, 5, 6],limit = 4) == 5\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4],limit = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],limit = 3) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],limit = 4) == 10\n assert candidate(nums = [5, 1, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 3) == 6\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0],limit = 10) == 2\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15],limit = 2) == 5\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],limit = 3) == 4\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1],limit = 99) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 5) == 12\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],limit = 2) == 6\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3],limit = 2) == 15\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 5) == 10\n assert candidate(nums = [2, 2, 2, 1, 1, 1, 3, 3, 3, 4, 4, 4, 5, 5, 5],limit = 1) == 6\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3],limit = 2) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],limit = 2) == 6\n assert candidate(nums = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],limit = 4) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 15) == 16\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],limit = 50) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],limit = 20) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 3) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 0) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 0) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 5) == 6\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],limit = 9) == 10\n assert candidate(nums = [8, 2, 4, 7, 1, 3, 6, 5, 9, 11, 10],limit = 4) == 3\n assert candidate(nums = [25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],limit = 6) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],limit = 10) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 4) == 5\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10],limit = 9) == 12\n assert candidate(nums = [10, 1, 2, 4, 7, 2, 9, 3, 5, 6],limit = 5) == 4\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],limit = 5) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 2) == 2\n assert candidate(nums = [5, 8, 8, 8, 8, 5, 5, 5, 5, 8, 8, 8, 5, 5],limit = 3) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 0) == 1\n assert candidate(nums = [10, 10, 10, 10, 1, 1, 1, 1, 10, 10, 10, 10, 1, 1, 1, 1],limit = 9) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 1) == 2\n assert candidate(nums = [5, 1, 3, 5, 9, 11, 9, 7, 5, 3, 1],limit = 2) == 3\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],limit = 1000000000) == 10\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],limit = 5) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 8) == 5\n assert candidate(nums = [5, 9, 1, 3, 7, 6, 2, 8, 4, 10],limit = 3) == 2\n assert candidate(nums = [10, 1, 2, 4, 7, 2, 10, 1, 2, 4, 7, 2, 10, 1, 2, 4, 7, 2, 10, 1, 2, 4, 7, 2],limit = 5) == 4\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],limit = 2) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 10) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 0) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],limit = 10) == 6\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 2) == 12\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000],limit = 999999999) == 8\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],limit = 0) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],limit = 3) == 4\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],limit = 1) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 5) == 6\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 2) == 15\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],limit = 0) == 15\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000],limit = 999999999) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 50) == 6\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 4) == 9\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 2) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],limit = 100) == 2\n assert candidate(nums = [7, 7, 7, 1, 1, 1, 7, 7, 7, 1, 1, 1, 7, 7, 7],limit = 6) == 15\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],limit = 3) == 8\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],limit = 10) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],limit = 10) == 6\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],limit = 0) == 10\n assert candidate(nums = [1000000000, 999999999, 1000000000, 999999999, 1000000000, 999999999],limit = 1) == 6\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],limit = 100) == 2\n assert candidate(nums = [100, 100, 100, 100, 101, 102, 103, 104, 105],limit = 5) == 9\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10, 14],limit = 5) == 6\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 7) == 8\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10],limit = 9) == 18\n assert candidate(nums = [8, 6, 5, 7, 2, 3, 10, 12, 15, 1],limit = 5) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],limit = 4) == 3\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],limit = 9) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],limit = 5) == 6\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],limit = 0) == 30\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],limit = 100) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],limit = 2) == 3\n assert candidate(nums = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],limit = 4) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 0) == 10\n assert candidate(nums = [8, 2, 4, 7, 10, 15, 1, 3, 6, 9],limit = 5) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 4) == 5\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1],limit = 3) == 10\n assert candidate(nums = [2, 3, 1, 1, 5, 7, 5, 10, 12, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],limit = 5) == 13\n assert candidate(nums = [1, 3, 3, 1, 2, 3, 2, 1, 1, 2, 3, 3, 2, 1, 1, 2, 3, 3, 2, 1],limit = 2) == 20\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 1) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],limit = 6) == 4\n assert candidate(nums = [5, 2, 3, 4, 1, 5, 2],limit = 3) == 4\n assert candidate(nums = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1],limit = 0) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 0) == 69\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 2) == 3\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],limit = 1) == 30\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2],limit = 1) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 5) == 6\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],limit = 1) == 9\n assert candidate(nums = [10, 15, 10, 20, 15, 10, 25, 30, 25],limit = 5) == 3\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],limit = 4) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],limit = 2) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 4) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],limit = 5) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],limit = 1) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],limit = 1) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],limit = 0) == 8\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],limit = 3) == 10\n assert candidate(nums = [100, 1, 2, 3, 4, 100, 2, 3, 4, 100],limit = 99) == 10\n assert candidate(nums = [1, 3, 5, 7, 9],limit = 6) == 4\n assert candidate(nums = [1, 2, 3, 1, 5, 6, 7, 8, 9, 10],limit = 2) == 4\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1],limit = 2) == 10\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],limit = 1) == 10\n assert candidate(nums = [1, 3, 6, 8, 9, 10, 12, 15],limit = 3) == 3\n assert candidate(nums = [5, 4, 3, 2, 1],limit = 4) == 5\n assert candidate(nums = [1, 2, 3, 1, 5],limit = 2) == 4\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4],limit = 3) == 1\n assert candidate(nums = [1000000000, 1, 1000000000, 1],limit = 1) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5],limit = 0) == 6\n assert candidate(nums = [100, 1, 2, 3, 4, 100, 101],limit = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 3) == 4\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 3) == 4\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2],limit = 0) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 9) == 10\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 10) == 5\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5],limit = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 1) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 1) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],limit = 3) == 4\n assert candidate(nums = [10, 20, 30, 40, 50],limit = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 5) == 5\n assert candidate(nums = [1, 5, 6, 7, 8, 8, 9, 10, 10, 10],limit = 2) == 6\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 1) == 2\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 1) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 3) == 4\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1],limit = 1) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 1) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],limit = 15) == 2\n assert candidate(nums = [1, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13],limit = 4) == 6\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],limit = 1) == 2\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4, 104, 5],limit = 100) == 4\n assert candidate(nums = [1000000000, 1000000000, 1000000000],limit = 0) == 3\n assert candidate(nums = [1],limit = 10) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 0) == 1\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],limit = 0) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1],limit = 2) == 5\n assert candidate(nums = [1, 5, 6, 7, 8, 8, 9, 10],limit = 4) == 6\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000],limit = 999999999) == 5\n assert candidate(nums = [1, 5, 6, 7, 8, 9],limit = 2) == 3\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1000000000],limit = 1000000000) == 11\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 4) == 4\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 5) == 4\n assert candidate(nums = [1, 2, 3],limit = 10) == 3\n assert candidate(nums = [1, 3, 5, 7, 9],limit = 2) == 2\n assert candidate(nums = [1, 5, 6, 7, 8, 10],limit = 4) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 2) == 3\n assert candidate(nums = [1, 3, 6, 8, 10],limit = 2) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 1) == 2\n assert candidate(nums = [1, 3, 6, 8, 10, 15],limit = 5) == 3\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5) == 6\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],limit = 10) == 10\n assert candidate(nums = [1, 3, 6, 2, 7, 8, 4, 5, 9],limit = 3) == 2\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 3) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1],limit = 3) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 0) == 20\n assert candidate(nums = [1],limit = 0) == 1\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 2) == 9\n"}, "metadata": {"canonical_parameter_names": ["nums", "limit"], "leetcode_dataset_entry_point": "Solution().longestSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def longestSubarray(self, nums: list[int], limit: int) -> int:", "container": "Solution", "callable": "longestSubarray", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "limit", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1439, "task_id": "find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows", "difficulty": "Hard", "problem_description": "You are given an m x n matrix mat that has its rows sorted in non-decreasing order and an integer k.\nYou are allowed to choose exactly one element from each row to form an array.\nReturn the kth smallest array sum among all possible arrays.\n \nExample 1:\n\nInput: mat = [[1,3,11],[2,4,6]], k = 5\nOutput: 7\nExplanation: Choosing one element from each row, the first k smallest sum are:\n[1,2], [1,4], [3,2], [3,4], [1,6]. Where the 5th sum is 7.\n\nExample 2:\n\nInput: mat = [[1,3,11],[2,4,6]], k = 9\nOutput: 17\n\nExample 3:\n\nInput: mat = [[1,10,10],[1,4,5],[2,3,6]], k = 7\nOutput: 9\nExplanation: Choosing one element from each row, the first k smallest sum are:\n[1,1,2], [1,1,3], [1,4,2], [1,4,3], [1,1,6], [1,5,2], [1,5,3]. Where the 7th sum is 9. \n\n \nConstraints:\n\nm == mat.length\nn == mat.length[i]\n1 <= m, n <= 40\n1 <= mat[i][j] <= 5000\n1 <= k <= min(200, nm)\nmat[i] is a non-decreasing array.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 10, 10], [1, 4, 5], [2, 3, 6]],k = 7) == 9\n assert candidate(mat = [[1, 2, 3], [4, 5, 6]],k = 9) == 9\n assert candidate(mat = [[1, 3, 11], [2, 4, 6]],k = 5) == 7\n assert candidate(mat = [[1, 3, 11], [2, 4, 6]],k = 9) == 17\n assert candidate(mat = [[1, 2, 3], [4, 5, 6]],k = 1) == 5\n assert candidate(mat = [[1, 5, 9], [10, 11, 13], [12, 13, 15]],k = 8) == 27\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]],k = 100) == 69\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 100) == 4\n assert candidate(mat = [[1, 7, 10, 15], [2, 8, 12, 16], [3, 9, 13, 17], [4, 10, 14, 18]],k = 15) == 22\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]],k = 100) == 68\n assert candidate(mat = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]],k = 160) == 15\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 180) == 42\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]],k = 200) == 24\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 100) == 33\n assert candidate(mat = [[500, 1000, 1500], [550, 1050, 1550], [600, 1100, 1600], [650, 1150, 1650]],k = 10) == 3300\n assert candidate(mat = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],k = 200) == 10\n assert candidate(mat = [[1, 2, 3, 4, 5], [10, 11, 12, 13, 14], [20, 21, 22, 23, 24], [30, 31, 32, 33, 34]],k = 50) == 65\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11]],k = 100) == 22\n assert candidate(mat = [[10, 20, 30], [15, 25, 35], [20, 30, 40], [25, 35, 45], [30, 40, 50]],k = 50) == 130\n assert candidate(mat = [[5, 10, 15], [6, 11, 16], [7, 12, 17], [8, 13, 18]],k = 25) == 41\n assert candidate(mat = [[5, 10, 15, 20, 25], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19]],k = 100) == 32\n assert candidate(mat = [[100, 200, 300, 400, 500], [101, 201, 301, 401, 501], [102, 202, 302, 402, 502], [103, 203, 303, 403, 503]],k = 20) == 706\n assert candidate(mat = [[1, 100, 200], [5, 150, 250], [9, 190, 290], [13, 230, 330]],k = 80) == 970\n assert candidate(mat = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [3, 5, 7, 9, 11, 13], [4, 6, 8, 10, 12, 14]],k = 50) == 18\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],k = 150) == 27\n assert candidate(mat = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [6, 16, 26, 36, 46]],k = 50) == 62\n assert candidate(mat = [[5, 8, 12, 18], [1, 3, 7, 11], [2, 4, 6, 10], [9, 13, 15, 17]],k = 100) == 33\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 250) == 61\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]],k = 50) == 35\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24]],k = 150) == 46\n assert candidate(mat = [[1, 5, 9, 12], [2, 6, 10, 13], [3, 7, 11, 14], [4, 8, 15, 16]],k = 15) == 21\n assert candidate(mat = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60]],k = 15) == 90\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]],k = 150) == 16\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],k = 30) == 25\n assert candidate(mat = [[5, 9, 14], [4, 12, 18], [2, 8, 10], [1, 3, 6]],k = 25) == 26\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],k = 50) == 102\n assert candidate(mat = [[100, 200, 300, 400, 500], [50, 100, 150, 200, 250], [25, 50, 75, 100, 125], [1, 2, 3, 4, 5]],k = 80) == 328\n assert candidate(mat = [[10, 20, 30, 40, 50], [11, 22, 33, 44, 55], [12, 24, 36, 48, 60], [13, 26, 39, 52, 65]],k = 100) == 104\n assert candidate(mat = [[500, 1000, 1500], [100, 200, 300], [250, 500, 750], [50, 100, 150], [200, 400, 600]],k = 60) == 1800\n assert candidate(mat = [[1, 10, 100], [1, 4, 50], [2, 3, 60]],k = 20) == 107\n assert candidate(mat = [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39]],k = 175) == 76\n assert candidate(mat = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30], [32, 34, 36, 38, 40]],k = 30) == 74\n assert candidate(mat = [[2, 6, 10, 14], [1, 5, 9, 13], [3, 7, 11, 15], [4, 8, 12, 16]],k = 15) == 18\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 50) == 4\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 50) == 38\n assert candidate(mat = [[1, 1000, 2000, 3000, 4000], [2, 2000, 3000, 4000, 5000], [3, 3000, 4000, 5000, 6000], [4, 4000, 5000, 6000, 7000]],k = 120) == 9005\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],k = 300) == 11\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],k = 199) == 10\n assert candidate(mat = [[1, 1, 1, 1], [1, 2, 2, 2], [1, 2, 3, 3], [1, 2, 3, 4]],k = 20) == 5\n assert candidate(mat = [[1, 1000, 5000], [500, 2000, 4000], [100, 3000, 4500], [200, 2500, 3500]],k = 100) == 17000\n assert candidate(mat = [[1, 5, 9, 13], [2, 6, 10, 14], [3, 7, 11, 15], [4, 8, 12, 16], [5, 9, 13, 17]],k = 200) == 35\n assert candidate(mat = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]],k = 120) == 16\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [3, 5, 7, 9, 11, 13, 15], [4, 6, 8, 10, 12, 14, 16]],k = 70) == 18\n assert candidate(mat = [[1000, 2000, 3000, 4000], [500, 1500, 2500, 3500], [100, 1100, 2100, 3100], [50, 1050, 2050, 3050]],k = 10) == 3650\n assert candidate(mat = [[100, 200, 300, 400, 500], [600, 700, 800, 900, 1000], [1100, 1200, 1300, 1400, 1500]],k = 18) == 2100\n assert candidate(mat = [[1, 4, 7, 10], [2, 5, 8, 11], [3, 6, 9, 12]],k = 60) == 27\n assert candidate(mat = [[100, 200, 300], [50, 150, 250], [10, 110, 210], [5, 105, 205], [1, 101, 201]],k = 80) == 566\n assert candidate(mat = [[1, 1000, 2000, 3000], [2, 2000, 3000, 4000], [3, 3000, 4000, 5000], [4, 4000, 5000, 6000]],k = 160) == 12001\n assert candidate(mat = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4], [5, 5, 5, 5, 5]],k = 125) == 15\n assert candidate(mat = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7]],k = 10) == 8\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [15, 17, 19, 21, 23, 25, 27], [29, 31, 33, 35, 37, 39, 41]],k = 180) == 59\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],k = 150) == 11\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]],k = 120) == 69\n assert candidate(mat = [[1, 7, 12, 22], [5, 8, 9, 13], [6, 12, 15, 18]],k = 15) == 24\n assert candidate(mat = [[3, 6, 9, 12], [2, 5, 8, 11], [1, 4, 7, 10]],k = 24) == 18\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 60) == 39\n assert candidate(mat = [[5, 10, 15, 20, 25], [6, 11, 16, 21, 26], [7, 12, 17, 22, 27], [8, 13, 18, 23, 28], [9, 14, 19, 24, 29]],k = 50) == 50\n assert candidate(mat = [[1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20]],k = 150) == 34\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 120) == 40\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15]],k = 60) == 20\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],k = 100) == 55\n assert candidate(mat = [[1, 100, 500, 1000], [2, 200, 600, 1100], [3, 300, 700, 1200], [4, 400, 800, 1300]],k = 120) == 1904\n assert candidate(mat = [[10, 20, 30, 40], [11, 22, 33, 44], [12, 24, 36, 48], [13, 26, 39, 52]],k = 150) == 121\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 150) == 60\n assert candidate(mat = [[1, 3, 7, 9], [2, 4, 6, 8], [0, 5, 10, 12], [1, 6, 11, 13]],k = 20) == 13\n assert candidate(mat = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]],k = 32) == 30\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [9, 10, 11, 12, 13]],k = 50) == 20\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 100) == 59\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13, 15], [2, 4, 6, 8, 10, 12, 14, 16], [3, 5, 7, 9, 11, 13, 15, 17], [4, 6, 8, 10, 12, 14, 16, 18]],k = 100) == 20\n assert candidate(mat = [[5, 10, 15, 20, 25], [4, 9, 14, 19, 24], [3, 8, 13, 18, 23], [2, 7, 12, 17, 22], [1, 6, 11, 16, 21]],k = 50) == 30\n assert candidate(mat = [[1, 100, 200, 300, 400], [2, 200, 300, 400, 500], [3, 300, 400, 500, 600], [4, 400, 500, 600, 700], [5, 500, 600, 700, 800]],k = 150) == 910\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 200) == 41\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 100) == 5\n assert candidate(mat = [[1, 100, 1000], [2, 200, 2000], [3, 300, 3000]],k = 20) == 3201\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 200) == 42\n"}, "metadata": {"canonical_parameter_names": ["mat", "k"], "leetcode_dataset_entry_point": "Solution().kthSmallest", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def kthSmallest(self, mat: list[list[int]], k: int) -> int:", "container": "Solution", "callable": "kthSmallest", "parameters": [{"name": "mat", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1441, "task_id": "build-an-array-with-stack-operations", "difficulty": "Medium", "problem_description": "You are given an integer array target and an integer n.\nYou have an empty stack with the two following operations:\n\n\"Push\": pushes an integer to the top of the stack.\n\"Pop\": removes the integer on the top of the stack.\n\nYou also have a stream of the integers in the range [1, n].\nUse the two stack operations to make the numbers in the stack (from the bottom to the top) equal to target. You should follow the following rules:\n\nIf the stream of the integers is not empty, pick the next integer from the stream and push it to the top of the stack.\nIf the stack is not empty, pop the integer at the top of the stack.\nIf, at any moment, the elements in the stack (from the bottom to the top) are equal to target, do not read new integers from the stream and do not do more operations on the stack.\n\nReturn the stack operations needed to build target following the mentioned rules. If there are multiple valid answers, return any of them.\n \nExample 1:\n\nInput: target = [1,3], n = 3\nOutput: [\"Push\",\"Push\",\"Pop\",\"Push\"]\nExplanation: Initially the stack s is empty. The last element is the top of the stack.\nRead 1 from the stream and push it to the stack. s = [1].\nRead 2 from the stream and push it to the stack. s = [1,2].\nPop the integer on the top of the stack. s = [1].\nRead 3 from the stream and push it to the stack. s = [1,3].\n\nExample 2:\n\nInput: target = [1,2,3], n = 3\nOutput: [\"Push\",\"Push\",\"Push\"]\nExplanation: Initially the stack s is empty. The last element is the top of the stack.\nRead 1 from the stream and push it to the stack. s = [1].\nRead 2 from the stream and push it to the stack. s = [1,2].\nRead 3 from the stream and push it to the stack. s = [1,2,3].\n\nExample 3:\n\nInput: target = [1,2], n = 4\nOutput: [\"Push\",\"Push\"]\nExplanation: Initially the stack s is empty. The last element is the top of the stack.\nRead 1 from the stream and push it to the stack. s = [1].\nRead 2 from the stream and push it to the stack. s = [1,2].\nSince the stack (from the bottom to the top) is equal to target, we stop the stack operations.\nThe answers that read integer 3 from the stream are not accepted.\n\n \nConstraints:\n\n1 <= target.length <= 100\n1 <= n <= 100\n1 <= target[i] <= n\ntarget is strictly increasing.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [3, 4, 5],n = 5) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push']\n assert candidate(target = [3, 4, 6],n = 7) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 9],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 9],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2],n = 4) == ['Push', 'Push']\n assert candidate(target = [1, 2, 3, 4, 5],n = 5) == ['Push', 'Push', 'Push', 'Push', 'Push']\n assert candidate(target = [2, 3, 5],n = 5) == ['Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 3, 4],n = 5) == ['Push', 'Pop', 'Push', 'Push', 'Push']\n assert candidate(target = [2, 4, 6, 8],n = 10) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 3, 4],n = 4) == ['Push', 'Pop', 'Push', 'Push', 'Push']\n assert candidate(target = [1],n = 1) == ['Push']\n assert candidate(target = [1, 2, 3],n = 3) == ['Push', 'Push', 'Push']\n assert candidate(target = [4, 5, 6],n = 6) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push']\n assert candidate(target = [1, 3, 5],n = 5) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 6, 7, 8],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push']\n assert candidate(target = [1, 3],n = 3) == ['Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [10],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6],n = 7) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6, 7, 10],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 6, 7, 8, 9, 10],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push']\n assert candidate(target = [1, 4, 6, 9],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 9, 13, 17, 21],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 4, 8, 16],n = 20) == ['Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12, 15, 18],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 4, 5, 7, 8, 10],n = 12) == ['Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 9, 11, 13, 15],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [4, 8, 16, 32, 64],n = 100) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [6, 8, 10, 12, 14],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 6, 10, 14, 18],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 4, 8, 16, 32, 64, 128],n = 150) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 8, 10],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11],n = 15) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15],n = 20) == ['Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6, 7, 9],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 11, 13, 15],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 8, 11, 14, 17],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 7, 10, 13, 16, 19, 22, 25],n = 30) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30, 40],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 14, 21, 28],n = 35) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12, 15, 18, 21],n = 25) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 7, 10, 13],n = 15) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 8, 11, 14],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 7, 11, 15, 19, 23, 27, 31, 35],n = 40) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 8, 9, 10, 11, 12, 13, 14, 15],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push']\n assert candidate(target = [3, 7, 10, 11],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [10, 12, 15, 19, 20],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [3, 5, 7, 9, 11, 13, 15],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 5, 10, 15, 20, 25, 30],n = 30) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 10, 15, 20, 25, 30, 35],n = 40) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [4, 7, 10, 13, 16, 19],n = 25) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 8, 9, 11],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 3, 5, 6, 7, 9, 10],n = 10) == ['Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [2, 5, 6, 8, 11, 12],n = 15) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [1, 2, 3, 5, 6, 7, 9, 10],n = 10) == ['Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [1, 2, 5, 7, 11, 13],n = 20) == ['Push', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30, 40, 50],n = 55) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 14, 21, 28],n = 35) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 20) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6, 8],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 11, 13, 17, 19],n = 25) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 4, 6, 8, 10, 12],n = 15) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 25) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 14, 21, 28, 35, 42],n = 42) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 20) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13],n = 15) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 7, 10, 13],n = 13) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 5, 9, 13, 17, 21],n = 25) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 11],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],n = 25) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 11, 13],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 7, 11, 15, 19],n = 25) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 14, 21, 28],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 8, 11, 14, 17, 20],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 9, 10],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [3, 6, 8, 10],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [6, 12, 18, 24, 30],n = 35) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 4, 7, 10, 12],n = 20) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 5, 7, 10, 13],n = 20) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12, 15, 18],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 8, 11, 14, 17, 20],n = 25) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 6, 10, 14, 18],n = 25) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 15, 20, 25],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12, 15, 18, 21, 24],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 7, 10],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 10],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 10],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 12, 14],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30, 40, 50],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 8, 10, 12],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 6, 8, 10],n = 12) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14],n = 15) == ['Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [11, 22, 33, 44, 55, 66, 77, 88, 99],n = 100) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 9, 10],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [5, 7, 9, 10],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11],n = 15) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 9, 11],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30, 40, 50],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 8, 10],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [4, 8, 12, 16, 20, 24, 28],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [6, 7, 8, 10, 12, 14, 15],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [2, 6, 10, 14, 18],n = 25) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 9, 13, 17],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 6, 10, 14, 18, 22, 26],n = 30) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 11, 12],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push']\n"}, "metadata": {"canonical_parameter_names": ["target", "n"], "leetcode_dataset_entry_point": "Solution().buildArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def buildArray(self, target: list[int], n: int) -> list[str]:", "container": "Solution", "callable": "buildArray", "parameters": [{"name": "target", "type": "list[int]"}, {"name": "n", "type": "int"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1442, "task_id": "count-triplets-that-can-form-two-arrays-of-equal-xor", "difficulty": "Medium", "problem_description": "Given an array of integers arr.\nWe want to select three indices i, j and k where (0 <= i < j <= k < arr.length).\nLet's define a and b as follows:\n\na = arr[i] ^ arr[i + 1] ^ ... ^ arr[j - 1]\nb = arr[j] ^ arr[j + 1] ^ ... ^ arr[k]\n\nNote that ^ denotes the bitwise-xor operation.\nReturn the number of triplets (i, j and k) Where a == b.\n \nExample 1:\n\nInput: arr = [2,3,1,6,7]\nOutput: 4\nExplanation: The triplets are (0,1,2), (0,2,2), (2,3,4) and (2,4,4)\n\nExample 2:\n\nInput: arr = [1,1,1,1,1]\nOutput: 10\n\n \nConstraints:\n\n1 <= arr.length <= 300\n1 <= arr[i] <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 3, 4, 1, 5, 6, 7, 8, 9]) == 17\n assert candidate(arr = [5, 5, 5, 5, 5, 5]) == 19\n assert candidate(arr = [8, 12, 3, 10]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 24\n assert candidate(arr = [3, 3, 3, 3, 3, 3]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [2, 3, 1, 6, 7]) == 4\n assert candidate(arr = [2, 3, 4, 5, 6, 7]) == 6\n assert candidate(arr = [5, 3, 0, 1, 4]) == 0\n assert candidate(arr = [8, 1, 6, 2, 1]) == 0\n assert candidate(arr = [5, 1, 4, 1, 5]) == 4\n assert candidate(arr = [1, 1, 1, 1, 1]) == 10\n assert candidate(arr = [7, 11, 1, 2, 9, 5]) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 285\n assert candidate(arr = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 10\n assert candidate(arr = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000]) == 0\n assert candidate(arr = [15, 3, 9, 7, 11, 6, 2, 8, 14, 5]) == 8\n assert candidate(arr = [123456789, 987654321, 135792468, 246813579, 111222333, 333222111]) == 0\n assert candidate(arr = [256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(arr = [7, 5, 3, 2, 6, 8, 4, 3, 5, 2, 9, 1, 5]) == 21\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 245\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 13\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 47\n assert candidate(arr = [29, 17, 23, 29, 17, 23, 29, 17, 23, 29, 17, 23, 29]) == 62\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2255\n assert candidate(arr = [31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2]) == 41\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 62790\n assert candidate(arr = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]) == 0\n assert candidate(arr = [123456789, 987654321, 1122334455, 5544332211, 9988776655]) == 0\n assert candidate(arr = [2, 5, 3, 2, 1, 4, 7, 8, 9, 6]) == 8\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 2870\n assert candidate(arr = [15, 13, 14, 11, 8, 7, 5, 2, 3, 4]) == 19\n assert candidate(arr = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000]) == 0\n assert candidate(arr = [23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]) == 0\n assert candidate(arr = [255, 128, 64, 32, 16, 8, 4, 2, 1, 255, 128, 64, 32, 16, 8, 4, 2, 1]) == 97\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 100\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16, 32, 64, 128]) == 72\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 665\n assert candidate(arr = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11, 22, 33, 44, 55, 66, 77, 88, 99, 10, 20]) == 0\n assert candidate(arr = [100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000]) == 2736\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 0\n assert candidate(arr = [100, 200, 300, 100, 200, 300, 100, 200]) == 15\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 2255\n assert candidate(arr = [10, 15, 3, 7, 8, 5, 2, 1]) == 0\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 265\n assert candidate(arr = [1, 3, 2, 3, 1, 5, 7, 5, 7, 9, 11, 9, 11, 13, 15]) == 97\n assert candidate(arr = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]) == 25\n assert candidate(arr = [300, 200, 100, 50, 25, 12, 6, 3, 1, 0, 1, 3, 6, 12, 25, 50, 100, 200, 300]) == 90\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2736\n assert candidate(arr = [13, 17, 11, 14, 13, 14, 12, 11, 17, 13, 15, 16, 18, 14, 12, 15]) == 11\n assert candidate(arr = [12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90]) == 54\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 390\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 100\n assert candidate(arr = [15, 9, 8, 3, 6, 1, 1, 1, 1, 2]) == 6\n assert candidate(arr = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 2255\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 670\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1156\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930, 313233, 343536, 373839, 404142, 434445, 464748, 495051, 525354, 555657, 585960, 616263, 646566, 676869, 707172, 737475, 767778, 798081, 828384, 858687, 888990, 919293]) == 0\n assert candidate(arr = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 344\n assert candidate(arr = [23, 35, 47, 59, 71, 83, 95, 107, 119, 131, 143, 155, 167, 179, 191]) == 13\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824]) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 385\n assert candidate(arr = [100000000, 99999999, 99999998, 99999997, 99999996, 99999995, 99999994, 99999993, 99999992, 99999991]) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 24\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 104\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 190\n assert candidate(arr = [99999999, 88888888, 77777777, 66666666, 55555555, 44444444, 33333333, 22222222, 11111111, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 24\n assert candidate(arr = [100000000, 99999999, 100000000, 99999999, 100000000, 99999999, 100000000]) == 12\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 8\n assert candidate(arr = [123, 456, 789, 101, 202, 303, 404, 505, 606]) == 0\n assert candidate(arr = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 110\n assert candidate(arr = [1, 3, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 384\n assert candidate(arr = [100000000, 100000000, 100000000, 100000000, 100000000, 100000000]) == 19\n assert candidate(arr = [123456789, 987654321, 135792468, 246813579, 111222333]) == 0\n assert candidate(arr = [123456789, 987654321, 1122334455, 5544332211, 123123123, 987987987]) == 0\n assert candidate(arr = [101, 203, 307, 409, 511, 613, 719, 821, 923, 1027, 1131, 1237, 1349, 1451, 1553, 1657, 1763, 1867, 1979, 2083]) == 0\n assert candidate(arr = [256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == 0\n assert candidate(arr = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == 3\n assert candidate(arr = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 1127\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 670\n assert candidate(arr = [255, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == 17\n assert candidate(arr = [17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 136\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 34\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 0\n assert candidate(arr = [17, 17, 34, 34, 68, 68, 136, 136, 272, 272, 544, 544]) == 91\n assert candidate(arr = [256, 128, 64, 32, 16, 8, 4, 2, 1, 2, 4, 8, 16, 32, 64, 128, 256]) == 0\n assert candidate(arr = [8, 15, 17, 4, 3, 10, 12, 7, 6, 9, 11, 5, 2, 14, 13, 1, 0, 16, 32, 64, 128, 256]) == 45\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 5\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().countTriplets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countTriplets(self, arr: list[int]) -> int:", "container": "Solution", "callable": "countTriplets", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1444, "task_id": "number-of-ways-of-cutting-a-pizza", "difficulty": "Hard", "problem_description": "Given a rectangular pizza represented as a rows x cols matrix containing the following characters: 'A' (an apple) and '.' (empty cell) and given the integer k. You have to cut the pizza into k pieces using k-1 cuts. \nFor each cut you choose the direction: vertical or horizontal, then you choose a cut position at the cell boundary and cut the pizza into two pieces. If you cut the pizza vertically, give the left part of the pizza to a person. If you cut the pizza horizontally, give the upper part of the pizza to a person. Give the last piece of pizza to the last person.\nReturn the number of ways of cutting the pizza such that each piece contains at least one apple. Since the answer can be a huge number, return this modulo 10^9 + 7.\n \nExample 1:\n\n\nInput: pizza = [\"A..\",\"AAA\",\"...\"], k = 3\nOutput: 3 \nExplanation: The figure above shows the three ways to cut the pizza. Note that pieces must contain at least one apple.\n\nExample 2:\n\nInput: pizza = [\"A..\",\"AA.\",\"...\"], k = 3\nOutput: 1\n\nExample 3:\n\nInput: pizza = [\"A..\",\"A..\",\"...\"], k = 1\nOutput: 1\n\n \nConstraints:\n\n1 <= rows, cols <= 50\nrows == pizza.length\ncols == pizza[i].length\n1 <= k <= 10\npizza consists of characters 'A' and '.' only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pizza = ['A', 'A', 'A'],k = 3) == 1\n assert candidate(pizza = ['AA', 'AA'],k = 2) == 2\n assert candidate(pizza = ['A.A', 'A.A', 'A.A'],k = 4) == 6\n assert candidate(pizza = ['A.A', 'A.A', 'A.A'],k = 5) == 0\n assert candidate(pizza = ['...', '...', '...', '...', '...', '...', 'AAA'],k = 4) == 0\n assert candidate(pizza = ['AAA', '...', 'AAA'],k = 2) == 4\n assert candidate(pizza = ['A..', 'A..', '...'],k = 1) == 1\n assert candidate(pizza = ['AAA', 'AAA', 'AAA'],k = 4) == 12\n assert candidate(pizza = ['AA.', 'AA.', '..A'],k = 2) == 4\n assert candidate(pizza = ['AAA', 'AAA', 'AAA'],k = 2) == 4\n assert candidate(pizza = ['A..', 'AA.', '...'],k = 3) == 1\n assert candidate(pizza = ['A.A', '.A.', 'A.A'],k = 2) == 4\n assert candidate(pizza = ['A..', 'A..'],k = 2) == 1\n assert candidate(pizza = ['A.A', 'A.A'],k = 2) == 3\n assert candidate(pizza = ['...', '...', '...'],k = 1) == 0\n assert candidate(pizza = ['A..', 'AAA', '...'],k = 3) == 3\n assert candidate(pizza = ['AAAAA', 'AA.AA', 'AA.AA', 'AA.AA', 'AAAAA'],k = 5) == 346\n assert candidate(pizza = ['AAAA', 'A.AA', 'AA.A', 'AAAA'],k = 4) == 56\n assert candidate(pizza = ['A.A.A', 'A....', 'A.A.A'],k = 3) == 21\n assert candidate(pizza = ['A.A', 'A.A', 'A.A'],k = 3) == 9\n assert candidate(pizza = ['A...A', '.....', 'A...A', '.....', 'A...A'],k = 3) == 36\n assert candidate(pizza = ['...A', '...A', '...A'],k = 2) == 2\n assert candidate(pizza = ['A...', '....', '....', 'A...'],k = 2) == 3\n assert candidate(pizza = ['A...A', '.A.A.', 'A...A', '.A.A.', 'A...A'],k = 5) == 198\n assert candidate(pizza = ['A.A', '.A.', 'A.A'],k = 3) == 10\n assert candidate(pizza = ['A.A', '.A.', 'A.A', '.A.', 'A.A'],k = 3) == 23\n assert candidate(pizza = ['A..A.', 'A..A.', 'A..A.', 'A..A.', 'A..A.'],k = 3) == 30\n assert candidate(pizza = ['AAAAAA', 'A...A.', 'A...A.', 'A...A.', 'AAAAAA'],k = 4) == 212\n assert candidate(pizza = ['AAAAA', '.....', 'AAAAA', '.....', 'AAAAA'],k = 3) == 42\n assert candidate(pizza = ['A...A', '.....', '.....', 'A...A'],k = 3) == 24\n assert candidate(pizza = ['A.A.A.A.A', '.A.A.A.A.', 'A.A.A.A.A', '.A.A.A.A.', 'A.A.A.A.A'],k = 5) == 1955\n assert candidate(pizza = ['AAAA', 'AAAA', 'AAAA', 'AAAA'],k = 5) == 78\n assert candidate(pizza = ['A.A.A', 'A.A.A', 'A.A.A'],k = 2) == 6\n assert candidate(pizza = ['A.A.A', 'A.A.A', 'A.A.A'],k = 3) == 21\n assert candidate(pizza = ['A.A.A.A', 'A.A.A.A', 'A.A.A.A'],k = 4) == 98\n assert candidate(pizza = ['AAAA', 'AAAA', 'AAAA'],k = 3) == 16\n assert candidate(pizza = ['A', 'A', 'A', 'A', 'A'],k = 3) == 6\n assert candidate(pizza = ['A..', '...', 'A..', '...', 'A..'],k = 3) == 4\n assert candidate(pizza = ['AA.AA', 'A...A', 'A...A', 'AA.AA'],k = 3) == 32\n assert candidate(pizza = ['A.....A', 'A.....A', 'A.....A', 'A.....A', 'A.....A'],k = 2) == 10\n assert candidate(pizza = ['AA.', 'A..', '.AA'],k = 2) == 4\n assert candidate(pizza = ['A.A.A', 'A...A', 'A.A.A'],k = 3) == 21\n assert candidate(pizza = ['A....A', '......', '......', 'A....A'],k = 4) == 0\n assert candidate(pizza = ['AAA..', 'AAA..', 'AAA..'],k = 3) == 10\n assert candidate(pizza = ['...A', '...A', 'A...', 'A...'],k = 2) == 6\n assert candidate(pizza = ['A.A.A', 'A.A.A', 'A.A.A', 'A.A.A', 'A.A.A'],k = 4) == 124\n assert candidate(pizza = ['A....', '.....', '.....', '.....', 'A....'],k = 2) == 4\n assert candidate(pizza = ['A...', '.A..', '..A.', '...A'],k = 4) == 8\n assert candidate(pizza = ['.A.A.', 'A.A.A', '.A.A.', 'A.A.A', '.A.A.'],k = 6) == 256\n assert candidate(pizza = ['AAAAA', 'A...A', 'A...A', 'A...A', 'AAAAA'],k = 5) == 346\n assert candidate(pizza = ['A....', '.....', '.....', '.....', '.....'],k = 4) == 0\n assert candidate(pizza = ['A.A.A.A', '.A.A.A.', 'A.A.A.A'],k = 3) == 40\n assert candidate(pizza = ['A.A.A.A', 'A.A.A.A', 'A.A.A.A', 'A.A.A.A', 'A.A.A.A', 'A.A.A.A', 'A.A.A.A', 'A.A.A.A'],k = 8) == 15387\n assert candidate(pizza = ['A...', '.A.A', '....', 'A...'],k = 2) == 6\n assert candidate(pizza = ['A.A.A.A', '.A.A.', 'A.A.A.A', '.A.A.', 'A.A.A.A'],k = 6) == 0\n assert candidate(pizza = ['........', '...A....', '........', '........', '........', '........', '........', '........'],k = 2) == 0\n assert candidate(pizza = ['.A..A.', 'A..A..', '.A..A.', 'A..A..', '.A..A.'],k = 3) == 42\n assert candidate(pizza = ['A..A', '....', 'A..A', '....'],k = 3) == 12\n assert candidate(pizza = ['A.A.A', '.A.A.', 'A.A.A'],k = 3) == 23\n assert candidate(pizza = ['A.A.A.A', '.A.A.A.', 'A.A.A.A', '.A.A.A.'],k = 3) == 51\n assert candidate(pizza = ['AAAAA', 'A...A', 'A...A', 'A...A', 'AAAAA'],k = 4) == 152\n assert candidate(pizza = ['A......', 'A......', 'A......', '.......', '.......', '.......'],k = 2) == 2\n assert candidate(pizza = ['A.A', 'A.A', 'A.A', 'A.A', 'A.A'],k = 4) == 40\n assert candidate(pizza = ['A.A.A', 'A...A', 'A...A', 'A...A', 'A.A.A'],k = 5) == 209\n assert candidate(pizza = ['AAAAA', 'AAAAA', '.....', '.....', '.....'],k = 3) == 14\n assert candidate(pizza = ['A.A.A', '.A.A.', 'A.A.A'],k = 4) == 46\n assert candidate(pizza = ['A.A.A', '.....', 'A.A.A', '.....', 'A.A.A'],k = 5) == 96\n assert candidate(pizza = ['A.A.A.A', '.A.A.A.', 'A.A.A.A', '.A.A.A.', 'A.A.A.A', '.A.A.A.', 'A.A.A.A', '.A.A.A.'],k = 6) == 8692\n assert candidate(pizza = ['A.A..', '.A.A.', '..A.A'],k = 3) == 17\n assert candidate(pizza = ['A....', '.A...', '..A..'],k = 3) == 4\n assert candidate(pizza = ['A....', '..A..', '....A', '.....', '.....'],k = 4) == 0\n assert candidate(pizza = ['A.A.A.A', '.....', 'A.A.A.A', '.....', 'A.A.A.A'],k = 5) == 0\n"}, "metadata": {"canonical_parameter_names": ["pizza", "k"], "leetcode_dataset_entry_point": "Solution().ways", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def ways(self, pizza: list[str], k: int) -> int:", "container": "Solution", "callable": "ways", "parameters": [{"name": "pizza", "type": "list[str]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1446, "task_id": "consecutive-characters", "difficulty": "Easy", "problem_description": "The power of the string is the maximum length of a non-empty substring that contains only one unique character.\nGiven a string s, return the power of s.\n \nExample 1:\n\nInput: s = \"leetcode\"\nOutput: 2\nExplanation: The substring \"ee\" is of length 2 with the character 'e' only.\n\nExample 2:\n\nInput: s = \"abbcccddddeeeeedcba\"\nOutput: 5\nExplanation: The substring \"eeeee\" is of length 5 with the character 'e' only.\n\n \nConstraints:\n\n1 <= s.length <= 500\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"tourist\") == 1\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"aabbbbccc\") == 4\n assert candidate(s = \"cccccaaaa\") == 5\n assert candidate(s = \"bbaaaaacccddddeeeefffggghhhiiijjjkkkllmmnnnooopppqqrrssttuuvvwwwxxxyyyzzz\") == 5\n assert candidate(s = \"leetcode\") == 2\n assert candidate(s = \"zzzzzzzzzz\") == 10\n assert candidate(s = \"hooray\") == 2\n assert candidate(s = \"ccbccbbbaaaa\") == 4\n assert candidate(s = \"triplepilloooooo\") == 6\n assert candidate(s = \"aabbbcccccdd\") == 5\n assert candidate(s = \"abcd\") == 1\n assert candidate(s = \"ccbccbb\") == 2\n assert candidate(s = \"aabbcc\") == 2\n assert candidate(s = \"cc\") == 2\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 2\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"abbcccddddeeeeedcba\") == 5\n assert candidate(s = \"abcdeffffffffghijklmnopqrstuvwxyz\") == 8\n assert candidate(s = \"aaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaab\") == 4\n assert candidate(s = \"pppppqqqqqrrrrrsssss\") == 5\n assert candidate(s = \"aaabbaaabbbaaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaa\") == 4\n assert candidate(s = \"ababababababababababab\") == 1\n assert candidate(s = \"aaaaaaaaaaa\") == 11\n assert candidate(s = \"mmmmmmnnnnnnooooooppppppqqqqqqrrrrrrssssssttttttuuuuuuvvvvvvwwwwwwxxxxxxxxxyyyyyyzzzzzz\") == 9\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhiiijjjkkklllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 28\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 96\n assert candidate(s = \"aaaaaaabbbbbbcccccc\") == 7\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 1\n assert candidate(s = \"abcdefffffffffghijklmnopqrstuvwxyz\") == 9\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\") == 4\n assert candidate(s = \"abacabadabacaba\") == 1\n assert candidate(s = \"aabbbccccdddddeeeeeeeeefffffffffggggggggggg\") == 11\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 188\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 1\n assert candidate(s = \"abcdddddddddddabcdddddddddddabcddddddddddd\") == 11\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\") == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 88\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 202\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 180\n assert candidate(s = \"aabaaaaccaaaaabbb\") == 5\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 10\n assert candidate(s = \"mnopqrstuvwxyzaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbccccccccccccccccccdddddddddddddddddddd\") == 26\n assert candidate(s = \"aabcccccaaaaddddddeeeeffffggggghhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\") == 6\n assert candidate(s = \"zzzzzyyyyyzzzzzzzzz\") == 9\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 1\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 1\n assert candidate(s = \"aabbaabbccbbccddeeffggffhhiiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 3\n assert candidate(s = \"aabbccddeeeefffbbbccc\") == 4\n assert candidate(s = \"aabbaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaa\") == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 152\n assert candidate(s = \"aaaaabbbbbccccccdddddeeeeeeffffffgggggghhhhhiiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\") == 6\n assert candidate(s = \"abcabcabcabcabcabc\") == 1\n assert candidate(s = \"abccbaabccbaabccbaabccbaabccbaabccbaabccbaabccba\") == 2\n assert candidate(s = \"aabbbcccdddeeefffggghhh\") == 3\n assert candidate(s = \"zzzzzyyyyxxwwwwvvvuuutttsssrqqpponnmmllkkjjiihhggffeeddccbbaa\") == 5\n assert candidate(s = \"aaabbbcccddddeeeeffffggggg\") == 5\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 51\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 34\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzz\") == 6\n assert candidate(s = \"pppppaaaabbbbccccdddddeeeeeeeeeffffffggggggggggghhhhhhhhhiiiiiiiijjjjjjjkkkkkkllllllmmmmmmnnnnnoooooopppppqqqqrrrrsssttttuuuuuuuuuuuuvvvvvvvvvvvvvvvwwwwwwwwwwwxxxxxyyyyyyyyyyyyyzzzzzzzzzzzzzzzzz\") == 17\n assert candidate(s = \"aabbbccccdddddeeeee\") == 5\n assert candidate(s = \"abcabcabcabcabc\") == 1\n assert candidate(s = \"sssssssqqqqqqqqqqppppppooooonnnnnnmmmmmmm\") == 10\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\") == 1\n assert candidate(s = \"mnonononoqpqrstuvwxyzzzzzzzz\") == 8\n assert candidate(s = \"aabbccddeeffaabbccddeeff\") == 2\n assert candidate(s = \"aabbbcccddddeeeeeffffffggggg\") == 6\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxPower", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxPower(self, s: str) -> int:", "container": "Solution", "callable": "maxPower", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1447, "task_id": "simplified-fractions", "difficulty": "Medium", "problem_description": "Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n. You can return the answer in any order.\n \nExample 1:\n\nInput: n = 2\nOutput: [\"1/2\"]\nExplanation: \"1/2\" is the only unique fraction with a denominator less-than-or-equal-to 2.\n\nExample 2:\n\nInput: n = 3\nOutput: [\"1/2\",\"1/3\",\"2/3\"]\n\nExample 3:\n\nInput: n = 4\nOutput: [\"1/2\",\"1/3\",\"1/4\",\"2/3\",\"3/4\"]\nExplanation: \"2/4\" is not a simplified fraction because it can be simplified to \"1/2\".\n\n \nConstraints:\n\n1 <= n <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == ['1/2', '1/3', '2/3']\n assert candidate(n = 4) == ['1/2', '1/3', '1/4', '2/3', '3/4']\n assert candidate(n = 2) == ['1/2']\n assert candidate(n = 20) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '6/7', '6/11', '6/13', '6/17', '6/19', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '10/11', '10/13', '10/17', '10/19', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '12/13', '12/17', '12/19', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '14/15', '14/17', '14/19', '15/16', '15/17', '15/19', '16/17', '16/19', '17/18', '17/19', '17/20', '18/19', '19/20']\n assert candidate(n = 100) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '1/76', '1/77', '1/78', '1/79', '1/80', '1/81', '1/82', '1/83', '1/84', '1/85', '1/86', '1/87', '1/88', '1/89', '1/90', '1/91', '1/92', '1/93', '1/94', '1/95', '1/96', '1/97', '1/98', '1/99', '1/100', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '2/87', '2/89', '2/91', '2/93', '2/95', '2/97', '2/99', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '3/86', '3/88', '3/89', '3/91', '3/92', '3/94', '3/95', '3/97', '3/98', '3/100', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '4/87', '4/89', '4/91', '4/93', '4/95', '4/97', '4/99', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '5/86', '5/87', '5/88', '5/89', '5/91', '5/92', '5/93', '5/94', '5/96', '5/97', '5/98', '5/99', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '6/89', '6/91', '6/95', '6/97', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '7/86', '7/87', '7/88', '7/89', '7/90', '7/92', '7/93', '7/94', '7/95', '7/96', '7/97', '7/99', '7/100', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '8/87', '8/89', '8/91', '8/93', '8/95', '8/97', '8/99', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '9/86', '9/88', '9/89', '9/91', '9/92', '9/94', '9/95', '9/97', '9/98', '9/100', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '10/87', '10/89', '10/91', '10/93', '10/97', '10/99', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '11/86', '11/87', '11/89', '11/90', '11/91', '11/92', '11/93', '11/94', '11/95', '11/96', '11/97', '11/98', '11/100', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '12/89', '12/91', '12/95', '12/97', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '13/86', '13/87', '13/88', '13/89', '13/90', '13/92', '13/93', '13/94', '13/95', '13/96', '13/97', '13/98', '13/99', '13/100', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '14/87', '14/89', '14/93', '14/95', '14/97', '14/99', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '15/86', '15/88', '15/89', '15/91', '15/92', '15/94', '15/97', '15/98', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '16/87', '16/89', '16/91', '16/93', '16/95', '16/97', '16/99', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '17/86', '17/87', '17/88', '17/89', '17/90', '17/91', '17/92', '17/93', '17/94', '17/95', '17/96', '17/97', '17/98', '17/99', '17/100', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '18/89', '18/91', '18/95', '18/97', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '19/86', '19/87', '19/88', '19/89', '19/90', '19/91', '19/92', '19/93', '19/94', '19/96', '19/97', '19/98', '19/99', '19/100', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '20/87', '20/89', '20/91', '20/93', '20/97', '20/99', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '21/86', '21/88', '21/89', '21/92', '21/94', '21/95', '21/97', '21/100', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '22/87', '22/89', '22/91', '22/93', '22/95', '22/97', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '23/86', '23/87', '23/88', '23/89', '23/90', '23/91', '23/93', '23/94', '23/95', '23/96', '23/97', '23/98', '23/99', '23/100', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '24/89', '24/91', '24/95', '24/97', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '25/86', '25/87', '25/88', '25/89', '25/91', '25/92', '25/93', '25/94', '25/96', '25/97', '25/98', '25/99', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '26/87', '26/89', '26/93', '26/95', '26/97', '26/99', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '27/86', '27/88', '27/89', '27/91', '27/92', '27/94', '27/95', '27/97', '27/98', '27/100', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '28/87', '28/89', '28/93', '28/95', '28/97', '28/99', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '29/86', '29/88', '29/89', '29/90', '29/91', '29/92', '29/93', '29/94', '29/95', '29/96', '29/97', '29/98', '29/99', '29/100', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '30/89', '30/91', '30/97', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '31/86', '31/87', '31/88', '31/89', '31/90', '31/91', '31/92', '31/94', '31/95', '31/96', '31/97', '31/98', '31/99', '31/100', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '32/87', '32/89', '32/91', '32/93', '32/95', '32/97', '32/99', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '33/86', '33/89', '33/91', '33/92', '33/94', '33/95', '33/97', '33/98', '33/100', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '34/87', '34/89', '34/91', '34/93', '34/95', '34/97', '34/99', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '35/86', '35/87', '35/88', '35/89', '35/92', '35/93', '35/94', '35/96', '35/97', '35/99', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '36/89', '36/91', '36/95', '36/97', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '37/86', '37/87', '37/88', '37/89', '37/90', '37/91', '37/92', '37/93', '37/94', '37/95', '37/96', '37/97', '37/98', '37/99', '37/100', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '38/87', '38/89', '38/91', '38/93', '38/97', '38/99', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '39/86', '39/88', '39/89', '39/92', '39/94', '39/95', '39/97', '39/98', '39/100', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '40/87', '40/89', '40/91', '40/93', '40/97', '40/99', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '41/86', '41/87', '41/88', '41/89', '41/90', '41/91', '41/92', '41/93', '41/94', '41/95', '41/96', '41/97', '41/98', '41/99', '41/100', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '42/89', '42/95', '42/97', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '43/87', '43/88', '43/89', '43/90', '43/91', '43/92', '43/93', '43/94', '43/95', '43/96', '43/97', '43/98', '43/99', '43/100', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '44/87', '44/89', '44/91', '44/93', '44/95', '44/97', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '45/86', '45/88', '45/89', '45/91', '45/92', '45/94', '45/97', '45/98', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '46/87', '46/89', '46/91', '46/93', '46/95', '46/97', '46/99', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '47/86', '47/87', '47/88', '47/89', '47/90', '47/91', '47/92', '47/93', '47/95', '47/96', '47/97', '47/98', '47/99', '47/100', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '48/89', '48/91', '48/95', '48/97', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '49/86', '49/87', '49/88', '49/89', '49/90', '49/92', '49/93', '49/94', '49/95', '49/96', '49/97', '49/99', '49/100', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '50/87', '50/89', '50/91', '50/93', '50/97', '50/99', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '51/86', '51/88', '51/89', '51/91', '51/92', '51/94', '51/95', '51/97', '51/98', '51/100', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '52/87', '52/89', '52/93', '52/95', '52/97', '52/99', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '53/86', '53/87', '53/88', '53/89', '53/90', '53/91', '53/92', '53/93', '53/94', '53/95', '53/96', '53/97', '53/98', '53/99', '53/100', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '54/89', '54/91', '54/95', '54/97', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '55/86', '55/87', '55/89', '55/91', '55/92', '55/93', '55/94', '55/96', '55/97', '55/98', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '56/87', '56/89', '56/93', '56/95', '56/97', '56/99', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '57/86', '57/88', '57/89', '57/91', '57/92', '57/94', '57/97', '57/98', '57/100', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '58/89', '58/91', '58/93', '58/95', '58/97', '58/99', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '59/86', '59/87', '59/88', '59/89', '59/90', '59/91', '59/92', '59/93', '59/94', '59/95', '59/96', '59/97', '59/98', '59/99', '59/100', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '60/89', '60/91', '60/97', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '61/86', '61/87', '61/88', '61/89', '61/90', '61/91', '61/92', '61/93', '61/94', '61/95', '61/96', '61/97', '61/98', '61/99', '61/100', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '62/87', '62/89', '62/91', '62/95', '62/97', '62/99', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '63/86', '63/88', '63/89', '63/92', '63/94', '63/95', '63/97', '63/100', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '64/87', '64/89', '64/91', '64/93', '64/95', '64/97', '64/99', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '65/86', '65/87', '65/88', '65/89', '65/92', '65/93', '65/94', '65/96', '65/97', '65/98', '65/99', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '66/89', '66/91', '66/95', '66/97', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '67/86', '67/87', '67/88', '67/89', '67/90', '67/91', '67/92', '67/93', '67/94', '67/95', '67/96', '67/97', '67/98', '67/99', '67/100', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '68/87', '68/89', '68/91', '68/93', '68/95', '68/97', '68/99', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '69/86', '69/88', '69/89', '69/91', '69/94', '69/95', '69/97', '69/98', '69/100', '70/71', '70/73', '70/79', '70/81', '70/83', '70/87', '70/89', '70/93', '70/97', '70/99', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '71/86', '71/87', '71/88', '71/89', '71/90', '71/91', '71/92', '71/93', '71/94', '71/95', '71/96', '71/97', '71/98', '71/99', '71/100', '72/73', '72/77', '72/79', '72/83', '72/85', '72/89', '72/91', '72/95', '72/97', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '73/86', '73/87', '73/88', '73/89', '73/90', '73/91', '73/92', '73/93', '73/94', '73/95', '73/96', '73/97', '73/98', '73/99', '73/100', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '74/87', '74/89', '74/91', '74/93', '74/95', '74/97', '74/99', '75/76', '75/77', '75/79', '75/82', '75/83', '75/86', '75/88', '75/89', '75/91', '75/92', '75/94', '75/97', '75/98', '76/77', '76/79', '76/81', '76/83', '76/85', '76/87', '76/89', '76/91', '76/93', '76/97', '76/99', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '77/86', '77/87', '77/89', '77/90', '77/92', '77/93', '77/94', '77/95', '77/96', '77/97', '77/100', '78/79', '78/83', '78/85', '78/89', '78/95', '78/97', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '79/86', '79/87', '79/88', '79/89', '79/90', '79/91', '79/92', '79/93', '79/94', '79/95', '79/96', '79/97', '79/98', '79/99', '79/100', '80/81', '80/83', '80/87', '80/89', '80/91', '80/93', '80/97', '80/99', '81/82', '81/83', '81/85', '81/86', '81/88', '81/89', '81/91', '81/92', '81/94', '81/95', '81/97', '81/98', '81/100', '82/83', '82/85', '82/87', '82/89', '82/91', '82/93', '82/95', '82/97', '82/99', '83/84', '83/85', '83/86', '83/87', '83/88', '83/89', '83/90', '83/91', '83/92', '83/93', '83/94', '83/95', '83/96', '83/97', '83/98', '83/99', '83/100', '84/85', '84/89', '84/95', '84/97', '85/86', '85/87', '85/88', '85/89', '85/91', '85/92', '85/93', '85/94', '85/96', '85/97', '85/98', '85/99', '86/87', '86/89', '86/91', '86/93', '86/95', '86/97', '86/99', '87/88', '87/89', '87/91', '87/92', '87/94', '87/95', '87/97', '87/98', '87/100', '88/89', '88/91', '88/93', '88/95', '88/97', '89/90', '89/91', '89/92', '89/93', '89/94', '89/95', '89/96', '89/97', '89/98', '89/99', '89/100', '90/91', '90/97', '91/92', '91/93', '91/94', '91/95', '91/96', '91/97', '91/99', '91/100', '92/93', '92/95', '92/97', '92/99', '93/94', '93/95', '93/97', '93/98', '93/100', '94/95', '94/97', '94/99', '95/96', '95/97', '95/98', '95/99', '96/97', '97/98', '97/99', '97/100', '98/99', '99/100']\n assert candidate(n = 50) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '36/37', '36/41', '36/43', '36/47', '36/49', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '40/41', '40/43', '40/47', '40/49', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '42/43', '42/47', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '44/45', '44/47', '44/49', '45/46', '45/47', '45/49', '46/47', '46/49', '47/48', '47/49', '47/50', '48/49', '49/50']\n assert candidate(n = 10) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '2/3', '2/5', '2/7', '2/9', '3/4', '3/5', '3/7', '3/8', '3/10', '4/5', '4/7', '4/9', '5/6', '5/7', '5/8', '5/9', '6/7', '7/8', '7/9', '7/10', '8/9', '9/10']\n assert candidate(n = 5) == ['1/2', '1/3', '1/4', '1/5', '2/3', '2/5', '3/4', '3/5', '4/5']\n assert candidate(n = 97) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '1/76', '1/77', '1/78', '1/79', '1/80', '1/81', '1/82', '1/83', '1/84', '1/85', '1/86', '1/87', '1/88', '1/89', '1/90', '1/91', '1/92', '1/93', '1/94', '1/95', '1/96', '1/97', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '2/87', '2/89', '2/91', '2/93', '2/95', '2/97', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '3/86', '3/88', '3/89', '3/91', '3/92', '3/94', '3/95', '3/97', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '4/87', '4/89', '4/91', '4/93', '4/95', '4/97', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '5/86', '5/87', '5/88', '5/89', '5/91', '5/92', '5/93', '5/94', '5/96', '5/97', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '6/89', '6/91', '6/95', '6/97', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '7/86', '7/87', '7/88', '7/89', '7/90', '7/92', '7/93', '7/94', '7/95', '7/96', '7/97', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '8/87', '8/89', '8/91', '8/93', '8/95', '8/97', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '9/86', '9/88', '9/89', '9/91', '9/92', '9/94', '9/95', '9/97', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '10/87', '10/89', '10/91', '10/93', '10/97', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '11/86', '11/87', '11/89', '11/90', '11/91', '11/92', '11/93', '11/94', '11/95', '11/96', '11/97', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '12/89', '12/91', '12/95', '12/97', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '13/86', '13/87', '13/88', '13/89', '13/90', '13/92', '13/93', '13/94', '13/95', '13/96', '13/97', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '14/87', '14/89', '14/93', '14/95', '14/97', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '15/86', '15/88', '15/89', '15/91', '15/92', '15/94', '15/97', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '16/87', '16/89', '16/91', '16/93', '16/95', '16/97', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '17/86', '17/87', '17/88', '17/89', '17/90', '17/91', '17/92', '17/93', '17/94', '17/95', '17/96', '17/97', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '18/89', '18/91', '18/95', '18/97', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '19/86', '19/87', '19/88', '19/89', '19/90', '19/91', '19/92', '19/93', '19/94', '19/96', '19/97', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '20/87', '20/89', '20/91', '20/93', '20/97', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '21/86', '21/88', '21/89', '21/92', '21/94', '21/95', '21/97', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '22/87', '22/89', '22/91', '22/93', '22/95', '22/97', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '23/86', '23/87', '23/88', '23/89', '23/90', '23/91', '23/93', '23/94', '23/95', '23/96', '23/97', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '24/89', '24/91', '24/95', '24/97', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '25/86', '25/87', '25/88', '25/89', '25/91', '25/92', '25/93', '25/94', '25/96', '25/97', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '26/87', '26/89', '26/93', '26/95', '26/97', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '27/86', '27/88', '27/89', '27/91', '27/92', '27/94', '27/95', '27/97', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '28/87', '28/89', '28/93', '28/95', '28/97', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '29/86', '29/88', '29/89', '29/90', '29/91', '29/92', '29/93', '29/94', '29/95', '29/96', '29/97', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '30/89', '30/91', '30/97', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '31/86', '31/87', '31/88', '31/89', '31/90', '31/91', '31/92', '31/94', '31/95', '31/96', '31/97', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '32/87', '32/89', '32/91', '32/93', '32/95', '32/97', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '33/86', '33/89', '33/91', '33/92', '33/94', '33/95', '33/97', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '34/87', '34/89', '34/91', '34/93', '34/95', '34/97', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '35/86', '35/87', '35/88', '35/89', '35/92', '35/93', '35/94', '35/96', '35/97', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '36/89', '36/91', '36/95', '36/97', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '37/86', '37/87', '37/88', '37/89', '37/90', '37/91', '37/92', '37/93', '37/94', '37/95', '37/96', '37/97', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '38/87', '38/89', '38/91', '38/93', '38/97', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '39/86', '39/88', '39/89', '39/92', '39/94', '39/95', '39/97', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '40/87', '40/89', '40/91', '40/93', '40/97', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '41/86', '41/87', '41/88', '41/89', '41/90', '41/91', '41/92', '41/93', '41/94', '41/95', '41/96', '41/97', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '42/89', '42/95', '42/97', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '43/87', '43/88', '43/89', '43/90', '43/91', '43/92', '43/93', '43/94', '43/95', '43/96', '43/97', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '44/87', '44/89', '44/91', '44/93', '44/95', '44/97', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '45/86', '45/88', '45/89', '45/91', '45/92', '45/94', '45/97', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '46/87', '46/89', '46/91', '46/93', '46/95', '46/97', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '47/86', '47/87', '47/88', '47/89', '47/90', '47/91', '47/92', '47/93', '47/95', '47/96', '47/97', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '48/89', '48/91', '48/95', '48/97', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '49/86', '49/87', '49/88', '49/89', '49/90', '49/92', '49/93', '49/94', '49/95', '49/96', '49/97', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '50/87', '50/89', '50/91', '50/93', '50/97', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '51/86', '51/88', '51/89', '51/91', '51/92', '51/94', '51/95', '51/97', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '52/87', '52/89', '52/93', '52/95', '52/97', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '53/86', '53/87', '53/88', '53/89', '53/90', '53/91', '53/92', '53/93', '53/94', '53/95', '53/96', '53/97', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '54/89', '54/91', '54/95', '54/97', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '55/86', '55/87', '55/89', '55/91', '55/92', '55/93', '55/94', '55/96', '55/97', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '56/87', '56/89', '56/93', '56/95', '56/97', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '57/86', '57/88', '57/89', '57/91', '57/92', '57/94', '57/97', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '58/89', '58/91', '58/93', '58/95', '58/97', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '59/86', '59/87', '59/88', '59/89', '59/90', '59/91', '59/92', '59/93', '59/94', '59/95', '59/96', '59/97', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '60/89', '60/91', '60/97', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '61/86', '61/87', '61/88', '61/89', '61/90', '61/91', '61/92', '61/93', '61/94', '61/95', '61/96', '61/97', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '62/87', '62/89', '62/91', '62/95', '62/97', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '63/86', '63/88', '63/89', '63/92', '63/94', '63/95', '63/97', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '64/87', '64/89', '64/91', '64/93', '64/95', '64/97', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '65/86', '65/87', '65/88', '65/89', '65/92', '65/93', '65/94', '65/96', '65/97', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '66/89', '66/91', '66/95', '66/97', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '67/86', '67/87', '67/88', '67/89', '67/90', '67/91', '67/92', '67/93', '67/94', '67/95', '67/96', '67/97', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '68/87', '68/89', '68/91', '68/93', '68/95', '68/97', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '69/86', '69/88', '69/89', '69/91', '69/94', '69/95', '69/97', '70/71', '70/73', '70/79', '70/81', '70/83', '70/87', '70/89', '70/93', '70/97', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '71/86', '71/87', '71/88', '71/89', '71/90', '71/91', '71/92', '71/93', '71/94', '71/95', '71/96', '71/97', '72/73', '72/77', '72/79', '72/83', '72/85', '72/89', '72/91', '72/95', '72/97', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '73/86', '73/87', '73/88', '73/89', '73/90', '73/91', '73/92', '73/93', '73/94', '73/95', '73/96', '73/97', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '74/87', '74/89', '74/91', '74/93', '74/95', '74/97', '75/76', '75/77', '75/79', '75/82', '75/83', '75/86', '75/88', '75/89', '75/91', '75/92', '75/94', '75/97', '76/77', '76/79', '76/81', '76/83', '76/85', '76/87', '76/89', '76/91', '76/93', '76/97', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '77/86', '77/87', '77/89', '77/90', '77/92', '77/93', '77/94', '77/95', '77/96', '77/97', '78/79', '78/83', '78/85', '78/89', '78/95', '78/97', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '79/86', '79/87', '79/88', '79/89', '79/90', '79/91', '79/92', '79/93', '79/94', '79/95', '79/96', '79/97', '80/81', '80/83', '80/87', '80/89', '80/91', '80/93', '80/97', '81/82', '81/83', '81/85', '81/86', '81/88', '81/89', '81/91', '81/92', '81/94', '81/95', '81/97', '82/83', '82/85', '82/87', '82/89', '82/91', '82/93', '82/95', '82/97', '83/84', '83/85', '83/86', '83/87', '83/88', '83/89', '83/90', '83/91', '83/92', '83/93', '83/94', '83/95', '83/96', '83/97', '84/85', '84/89', '84/95', '84/97', '85/86', '85/87', '85/88', '85/89', '85/91', '85/92', '85/93', '85/94', '85/96', '85/97', '86/87', '86/89', '86/91', '86/93', '86/95', '86/97', '87/88', '87/89', '87/91', '87/92', '87/94', '87/95', '87/97', '88/89', '88/91', '88/93', '88/95', '88/97', '89/90', '89/91', '89/92', '89/93', '89/94', '89/95', '89/96', '89/97', '90/91', '90/97', '91/92', '91/93', '91/94', '91/95', '91/96', '91/97', '92/93', '92/95', '92/97', '93/94', '93/95', '93/97', '94/95', '94/97', '95/96', '95/97', '96/97']\n assert candidate(n = 60) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '42/43', '42/47', '42/53', '42/55', '42/59', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '48/49', '48/53', '48/55', '48/59', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '50/51', '50/53', '50/57', '50/59', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '52/53', '52/55', '52/57', '52/59', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '54/55', '54/59', '55/56', '55/57', '55/58', '55/59', '56/57', '56/59', '57/58', '57/59', '58/59', '59/60']\n assert candidate(n = 30) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '18/19', '18/23', '18/25', '18/29', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '20/21', '20/23', '20/27', '20/29', '21/22', '21/23', '21/25', '21/26', '21/29', '22/23', '22/25', '22/27', '22/29', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '24/25', '24/29', '25/26', '25/27', '25/28', '25/29', '26/27', '26/29', '27/28', '27/29', '28/29', '29/30']\n assert candidate(n = 99) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '1/76', '1/77', '1/78', '1/79', '1/80', '1/81', '1/82', '1/83', '1/84', '1/85', '1/86', '1/87', '1/88', '1/89', '1/90', '1/91', '1/92', '1/93', '1/94', '1/95', '1/96', '1/97', '1/98', '1/99', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '2/87', '2/89', '2/91', '2/93', '2/95', '2/97', '2/99', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '3/86', '3/88', '3/89', '3/91', '3/92', '3/94', '3/95', '3/97', '3/98', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '4/87', '4/89', '4/91', '4/93', '4/95', '4/97', '4/99', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '5/86', '5/87', '5/88', '5/89', '5/91', '5/92', '5/93', '5/94', '5/96', '5/97', '5/98', '5/99', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '6/89', '6/91', '6/95', '6/97', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '7/86', '7/87', '7/88', '7/89', '7/90', '7/92', '7/93', '7/94', '7/95', '7/96', '7/97', '7/99', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '8/87', '8/89', '8/91', '8/93', '8/95', '8/97', '8/99', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '9/86', '9/88', '9/89', '9/91', '9/92', '9/94', '9/95', '9/97', '9/98', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '10/87', '10/89', '10/91', '10/93', '10/97', '10/99', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '11/86', '11/87', '11/89', '11/90', '11/91', '11/92', '11/93', '11/94', '11/95', '11/96', '11/97', '11/98', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '12/89', '12/91', '12/95', '12/97', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '13/86', '13/87', '13/88', '13/89', '13/90', '13/92', '13/93', '13/94', '13/95', '13/96', '13/97', '13/98', '13/99', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '14/87', '14/89', '14/93', '14/95', '14/97', '14/99', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '15/86', '15/88', '15/89', '15/91', '15/92', '15/94', '15/97', '15/98', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '16/87', '16/89', '16/91', '16/93', '16/95', '16/97', '16/99', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '17/86', '17/87', '17/88', '17/89', '17/90', '17/91', '17/92', '17/93', '17/94', '17/95', '17/96', '17/97', '17/98', '17/99', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '18/89', '18/91', '18/95', '18/97', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '19/86', '19/87', '19/88', '19/89', '19/90', '19/91', '19/92', '19/93', '19/94', '19/96', '19/97', '19/98', '19/99', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '20/87', '20/89', '20/91', '20/93', '20/97', '20/99', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '21/86', '21/88', '21/89', '21/92', '21/94', '21/95', '21/97', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '22/87', '22/89', '22/91', '22/93', '22/95', '22/97', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '23/86', '23/87', '23/88', '23/89', '23/90', '23/91', '23/93', '23/94', '23/95', '23/96', '23/97', '23/98', '23/99', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '24/89', '24/91', '24/95', '24/97', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '25/86', '25/87', '25/88', '25/89', '25/91', '25/92', '25/93', '25/94', '25/96', '25/97', '25/98', '25/99', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '26/87', '26/89', '26/93', '26/95', '26/97', '26/99', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '27/86', '27/88', '27/89', '27/91', '27/92', '27/94', '27/95', '27/97', '27/98', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '28/87', '28/89', '28/93', '28/95', '28/97', '28/99', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '29/86', '29/88', '29/89', '29/90', '29/91', '29/92', '29/93', '29/94', '29/95', '29/96', '29/97', '29/98', '29/99', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '30/89', '30/91', '30/97', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '31/86', '31/87', '31/88', '31/89', '31/90', '31/91', '31/92', '31/94', '31/95', '31/96', '31/97', '31/98', '31/99', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '32/87', '32/89', '32/91', '32/93', '32/95', '32/97', '32/99', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '33/86', '33/89', '33/91', '33/92', '33/94', '33/95', '33/97', '33/98', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '34/87', '34/89', '34/91', '34/93', '34/95', '34/97', '34/99', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '35/86', '35/87', '35/88', '35/89', '35/92', '35/93', '35/94', '35/96', '35/97', '35/99', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '36/89', '36/91', '36/95', '36/97', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '37/86', '37/87', '37/88', '37/89', '37/90', '37/91', '37/92', '37/93', '37/94', '37/95', '37/96', '37/97', '37/98', '37/99', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '38/87', '38/89', '38/91', '38/93', '38/97', '38/99', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '39/86', '39/88', '39/89', '39/92', '39/94', '39/95', '39/97', '39/98', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '40/87', '40/89', '40/91', '40/93', '40/97', '40/99', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '41/86', '41/87', '41/88', '41/89', '41/90', '41/91', '41/92', '41/93', '41/94', '41/95', '41/96', '41/97', '41/98', '41/99', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '42/89', '42/95', '42/97', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '43/87', '43/88', '43/89', '43/90', '43/91', '43/92', '43/93', '43/94', '43/95', '43/96', '43/97', '43/98', '43/99', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '44/87', '44/89', '44/91', '44/93', '44/95', '44/97', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '45/86', '45/88', '45/89', '45/91', '45/92', '45/94', '45/97', '45/98', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '46/87', '46/89', '46/91', '46/93', '46/95', '46/97', '46/99', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '47/86', '47/87', '47/88', '47/89', '47/90', '47/91', '47/92', '47/93', '47/95', '47/96', '47/97', '47/98', '47/99', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '48/89', '48/91', '48/95', '48/97', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '49/86', '49/87', '49/88', '49/89', '49/90', '49/92', '49/93', '49/94', '49/95', '49/96', '49/97', '49/99', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '50/87', '50/89', '50/91', '50/93', '50/97', '50/99', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '51/86', '51/88', '51/89', '51/91', '51/92', '51/94', '51/95', '51/97', '51/98', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '52/87', '52/89', '52/93', '52/95', '52/97', '52/99', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '53/86', '53/87', '53/88', '53/89', '53/90', '53/91', '53/92', '53/93', '53/94', '53/95', '53/96', '53/97', '53/98', '53/99', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '54/89', '54/91', '54/95', '54/97', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '55/86', '55/87', '55/89', '55/91', '55/92', '55/93', '55/94', '55/96', '55/97', '55/98', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '56/87', '56/89', '56/93', '56/95', '56/97', '56/99', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '57/86', '57/88', '57/89', '57/91', '57/92', '57/94', '57/97', '57/98', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '58/89', '58/91', '58/93', '58/95', '58/97', '58/99', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '59/86', '59/87', '59/88', '59/89', '59/90', '59/91', '59/92', '59/93', '59/94', '59/95', '59/96', '59/97', '59/98', '59/99', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '60/89', '60/91', '60/97', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '61/86', '61/87', '61/88', '61/89', '61/90', '61/91', '61/92', '61/93', '61/94', '61/95', '61/96', '61/97', '61/98', '61/99', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '62/87', '62/89', '62/91', '62/95', '62/97', '62/99', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '63/86', '63/88', '63/89', '63/92', '63/94', '63/95', '63/97', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '64/87', '64/89', '64/91', '64/93', '64/95', '64/97', '64/99', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '65/86', '65/87', '65/88', '65/89', '65/92', '65/93', '65/94', '65/96', '65/97', '65/98', '65/99', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '66/89', '66/91', '66/95', '66/97', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '67/86', '67/87', '67/88', '67/89', '67/90', '67/91', '67/92', '67/93', '67/94', '67/95', '67/96', '67/97', '67/98', '67/99', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '68/87', '68/89', '68/91', '68/93', '68/95', '68/97', '68/99', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '69/86', '69/88', '69/89', '69/91', '69/94', '69/95', '69/97', '69/98', '70/71', '70/73', '70/79', '70/81', '70/83', '70/87', '70/89', '70/93', '70/97', '70/99', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '71/86', '71/87', '71/88', '71/89', '71/90', '71/91', '71/92', '71/93', '71/94', '71/95', '71/96', '71/97', '71/98', '71/99', '72/73', '72/77', '72/79', '72/83', '72/85', '72/89', '72/91', '72/95', '72/97', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '73/86', '73/87', '73/88', '73/89', '73/90', '73/91', '73/92', '73/93', '73/94', '73/95', '73/96', '73/97', '73/98', '73/99', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '74/87', '74/89', '74/91', '74/93', '74/95', '74/97', '74/99', '75/76', '75/77', '75/79', '75/82', '75/83', '75/86', '75/88', '75/89', '75/91', '75/92', '75/94', '75/97', '75/98', '76/77', '76/79', '76/81', '76/83', '76/85', '76/87', '76/89', '76/91', '76/93', '76/97', '76/99', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '77/86', '77/87', '77/89', '77/90', '77/92', '77/93', '77/94', '77/95', '77/96', '77/97', '78/79', '78/83', '78/85', '78/89', '78/95', '78/97', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '79/86', '79/87', '79/88', '79/89', '79/90', '79/91', '79/92', '79/93', '79/94', '79/95', '79/96', '79/97', '79/98', '79/99', '80/81', '80/83', '80/87', '80/89', '80/91', '80/93', '80/97', '80/99', '81/82', '81/83', '81/85', '81/86', '81/88', '81/89', '81/91', '81/92', '81/94', '81/95', '81/97', '81/98', '82/83', '82/85', '82/87', '82/89', '82/91', '82/93', '82/95', '82/97', '82/99', '83/84', '83/85', '83/86', '83/87', '83/88', '83/89', '83/90', '83/91', '83/92', '83/93', '83/94', '83/95', '83/96', '83/97', '83/98', '83/99', '84/85', '84/89', '84/95', '84/97', '85/86', '85/87', '85/88', '85/89', '85/91', '85/92', '85/93', '85/94', '85/96', '85/97', '85/98', '85/99', '86/87', '86/89', '86/91', '86/93', '86/95', '86/97', '86/99', '87/88', '87/89', '87/91', '87/92', '87/94', '87/95', '87/97', '87/98', '88/89', '88/91', '88/93', '88/95', '88/97', '89/90', '89/91', '89/92', '89/93', '89/94', '89/95', '89/96', '89/97', '89/98', '89/99', '90/91', '90/97', '91/92', '91/93', '91/94', '91/95', '91/96', '91/97', '91/99', '92/93', '92/95', '92/97', '92/99', '93/94', '93/95', '93/97', '93/98', '94/95', '94/97', '94/99', '95/96', '95/97', '95/98', '95/99', '96/97', '97/98', '97/99', '98/99']\n assert candidate(n = 80) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '1/76', '1/77', '1/78', '1/79', '1/80', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '66/67', '66/71', '66/73', '66/79', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '70/71', '70/73', '70/79', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '72/73', '72/77', '72/79', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '74/75', '74/77', '74/79', '75/76', '75/77', '75/79', '76/77', '76/79', '77/78', '77/79', '77/80', '78/79', '79/80']\n assert candidate(n = 8) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '2/3', '2/5', '2/7', '3/4', '3/5', '3/7', '3/8', '4/5', '4/7', '5/6', '5/7', '5/8', '6/7', '7/8']\n assert candidate(n = 75) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '60/61', '60/67', '60/71', '60/73', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '66/67', '66/71', '66/73', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '68/69', '68/71', '68/73', '68/75', '69/70', '69/71', '69/73', '69/74', '70/71', '70/73', '71/72', '71/73', '71/74', '71/75', '72/73', '73/74', '73/75', '74/75']\n assert candidate(n = 81) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '1/76', '1/77', '1/78', '1/79', '1/80', '1/81', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '66/67', '66/71', '66/73', '66/79', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '70/71', '70/73', '70/79', '70/81', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '72/73', '72/77', '72/79', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '74/75', '74/77', '74/79', '74/81', '75/76', '75/77', '75/79', '76/77', '76/79', '76/81', '77/78', '77/79', '77/80', '77/81', '78/79', '79/80', '79/81', '80/81']\n assert candidate(n = 15) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '6/7', '6/11', '6/13', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '8/9', '8/11', '8/13', '8/15', '9/10', '9/11', '9/13', '9/14', '10/11', '10/13', '11/12', '11/13', '11/14', '11/15', '12/13', '13/14', '13/15', '14/15']\n assert candidate(n = 85) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '1/76', '1/77', '1/78', '1/79', '1/80', '1/81', '1/82', '1/83', '1/84', '1/85', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '70/71', '70/73', '70/79', '70/81', '70/83', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '72/73', '72/77', '72/79', '72/83', '72/85', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '75/76', '75/77', '75/79', '75/82', '75/83', '76/77', '76/79', '76/81', '76/83', '76/85', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '78/79', '78/83', '78/85', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '80/81', '80/83', '81/82', '81/83', '81/85', '82/83', '82/85', '83/84', '83/85', '84/85']\n assert candidate(n = 1) == []\n assert candidate(n = 55) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '42/43', '42/47', '42/53', '42/55', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '44/45', '44/47', '44/49', '44/51', '44/53', '45/46', '45/47', '45/49', '45/52', '45/53', '46/47', '46/49', '46/51', '46/53', '46/55', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '48/49', '48/53', '48/55', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '50/51', '50/53', '51/52', '51/53', '51/55', '52/53', '52/55', '53/54', '53/55', '54/55']\n assert candidate(n = 90) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '1/76', '1/77', '1/78', '1/79', '1/80', '1/81', '1/82', '1/83', '1/84', '1/85', '1/86', '1/87', '1/88', '1/89', '1/90', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '2/87', '2/89', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '3/86', '3/88', '3/89', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '4/87', '4/89', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '5/86', '5/87', '5/88', '5/89', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '6/89', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '7/86', '7/87', '7/88', '7/89', '7/90', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '8/87', '8/89', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '9/86', '9/88', '9/89', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '10/87', '10/89', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '11/86', '11/87', '11/89', '11/90', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '12/89', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '13/86', '13/87', '13/88', '13/89', '13/90', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '14/87', '14/89', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '15/86', '15/88', '15/89', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '16/87', '16/89', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '17/86', '17/87', '17/88', '17/89', '17/90', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '18/89', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '19/86', '19/87', '19/88', '19/89', '19/90', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '20/87', '20/89', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '21/86', '21/88', '21/89', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '22/87', '22/89', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '23/86', '23/87', '23/88', '23/89', '23/90', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '24/89', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '25/86', '25/87', '25/88', '25/89', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '26/87', '26/89', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '27/86', '27/88', '27/89', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '28/87', '28/89', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '29/86', '29/88', '29/89', '29/90', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '30/89', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '31/86', '31/87', '31/88', '31/89', '31/90', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '32/87', '32/89', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '33/86', '33/89', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '34/87', '34/89', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '35/86', '35/87', '35/88', '35/89', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '36/89', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '37/86', '37/87', '37/88', '37/89', '37/90', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '38/87', '38/89', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '39/86', '39/88', '39/89', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '40/87', '40/89', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '41/86', '41/87', '41/88', '41/89', '41/90', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '42/89', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '43/87', '43/88', '43/89', '43/90', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '44/87', '44/89', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '45/86', '45/88', '45/89', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '46/87', '46/89', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '47/86', '47/87', '47/88', '47/89', '47/90', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '48/89', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '49/86', '49/87', '49/88', '49/89', '49/90', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '50/87', '50/89', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '51/86', '51/88', '51/89', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '52/87', '52/89', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '53/86', '53/87', '53/88', '53/89', '53/90', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '54/89', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '55/86', '55/87', '55/89', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '56/87', '56/89', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '57/86', '57/88', '57/89', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '58/89', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '59/86', '59/87', '59/88', '59/89', '59/90', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '60/89', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '61/86', '61/87', '61/88', '61/89', '61/90', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '62/87', '62/89', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '63/86', '63/88', '63/89', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '64/87', '64/89', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '65/86', '65/87', '65/88', '65/89', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '66/89', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '67/86', '67/87', '67/88', '67/89', '67/90', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '68/87', '68/89', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '69/86', '69/88', '69/89', '70/71', '70/73', '70/79', '70/81', '70/83', '70/87', '70/89', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '71/86', '71/87', '71/88', '71/89', '71/90', '72/73', '72/77', '72/79', '72/83', '72/85', '72/89', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '73/86', '73/87', '73/88', '73/89', '73/90', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '74/87', '74/89', '75/76', '75/77', '75/79', '75/82', '75/83', '75/86', '75/88', '75/89', '76/77', '76/79', '76/81', '76/83', '76/85', '76/87', '76/89', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '77/86', '77/87', '77/89', '77/90', '78/79', '78/83', '78/85', '78/89', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '79/86', '79/87', '79/88', '79/89', '79/90', '80/81', '80/83', '80/87', '80/89', '81/82', '81/83', '81/85', '81/86', '81/88', '81/89', '82/83', '82/85', '82/87', '82/89', '83/84', '83/85', '83/86', '83/87', '83/88', '83/89', '83/90', '84/85', '84/89', '85/86', '85/87', '85/88', '85/89', '86/87', '86/89', '87/88', '87/89', '88/89', '89/90']\n assert candidate(n = 25) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '12/13', '12/17', '12/19', '12/23', '12/25', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '14/15', '14/17', '14/19', '14/23', '14/25', '15/16', '15/17', '15/19', '15/22', '15/23', '16/17', '16/19', '16/21', '16/23', '16/25', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '18/19', '18/23', '18/25', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '20/21', '20/23', '21/22', '21/23', '21/25', '22/23', '22/25', '23/24', '23/25', '24/25']\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().simplifiedFractions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def simplifiedFractions(self, n: int) -> list[str]:", "container": "Solution", "callable": "simplifiedFractions", "parameters": [{"name": "n", "type": "int"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1448, "task_id": "count-good-nodes-in-binary-tree", "difficulty": "Medium", "problem_description": "Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X.\\r\n\\r\nReturn the number of good nodes in the binary tree.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\n\\r\n\\r\nInput: root = [3,1,4,3,null,1,5]\\r\nOutput: 4\\r\nExplanation: Nodes in blue are good.\\r\nRoot Node (3) is always a good node.\\r\nNode 4 -> (3,4) is the maximum value in the path starting from the root.\\r\nNode 5 -> (3,4,5) is the maximum value in the path\\r\nNode 3 -> (3,1,3) is the maximum value in the path.\\r\n\\r\nExample 2:\\r\n\\r\n\\r\n\\r\n\\r\nInput: root = [3,3,null,4,2]\\r\nOutput: 3\\r\nExplanation: Node 2 -> (3, 3, 2) is not good, because \"3\" is higher than it.\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: root = [1]\\r\nOutput: 1\\r\nExplanation: Root is considered as good.\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\tThe number of nodes in the binary tree is in the range [1, 10^5].\\r\n\tEach node's value is between [-10^4, 10^4].\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([3, 1, 4, 3, None, 1, 5])) == 4\n assert candidate(root = tree_node([-10, -20, -5, -15, -30])) == 2\n assert candidate(root = tree_node([5, 10, 20, 15, 25])) == 5\n assert candidate(root = tree_node([-10, None, -20, None, -30])) == 1\n assert candidate(root = tree_node([3, 3, None, 4, 2])) == 3\n assert candidate(root = tree_node([5, 4, 6, 3, 8, 5, 7])) == 4\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, 7])) == 3\n assert candidate(root = tree_node([-10000, -5000, -2500])) == 3\n assert candidate(root = tree_node([1])) == 1\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5])) == 5\n assert candidate(root = tree_node([20, 10, 25, 5, 15, 22, 30, 2, 7, 12, 18, 21, 24, 28, 32])) == 4\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 10\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, 7, 1, None, None, None, None, 8])) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == 25\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 8, 9, 10, 11])) == 11\n assert candidate(root = tree_node([7, 6, 8, 5, None, 9, 10, 4, None, None, None, 1, 11, None, 12])) == 6\n assert candidate(root = tree_node([3, 1, 4, 3, None, 1, 5, 2, None, None, 3, None, None, 1, 6])) == 5\n assert candidate(root = tree_node([1, 2, 2, 2, 3, None, None, 4, None, 5, 6])) == 8\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, 8, 1, None, None, None, 7, 9])) == 4\n assert candidate(root = tree_node([-10, -20, -30, -40, -50, None, -60])) == 1\n assert candidate(root = tree_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == 10\n assert candidate(root = tree_node([15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == 1\n assert candidate(root = tree_node([1, 3, 2, 5, 3, None, 9, 4, None, 6, None, 7, 8, 10, 11])) == 9\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18])) == 3\n assert candidate(root = tree_node([4, 2, 6, 1, 3, 5, 7, -2, None, None, None, None, None, None, -3])) == 3\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 18, 23, 27, 33, 37])) == 4\n assert candidate(root = tree_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])) == 52\n assert candidate(root = tree_node([-5, -4, -3, -6, -2, -4, -2, -8, -1, -3, -1, -5, -1, -7, -1])) == 9\n assert candidate(root = tree_node([100, 50, 200, 25, 75, 150, 250, 10, 30, 60, 80, 125, 175, 225, 275])) == 4\n assert candidate(root = tree_node([5, 3, 6, 2, 4, 7, 8, 1, 9, None, None, None, None, None, None, None, None])) == 5\n assert candidate(root = tree_node([50, 25, 75, 10, 30, 60, 80, None, 20, 28, 35, None, 55, 70, None, 15, None, 22, 26, 29, 33, 38, 52, 57, 72, None, 13, 17, None, None, 21, None, 24, 27, None, None, 31, 36, None, None, 51, 54, 56, 58, 71, None, None, None, 12, None, None, None, 16, None, 19, None, None, 23, None, None, 32, None, 34, 37, None, 50, None, 53, None, 59, None, 69, 73, None, None, 11, None, 14, None, 18, None, 21, None, None, 25, None, 30, None, None, None, None, None, 49, None, 52, None, 68, None, 72, None, 10, None, 13, None, None, None, 17, None, 19, None, None, 25, None, 29, None, 33, None, None, 48, None, None, 51, None, 67, None, 71, None, None, None, None, 9, None, 12, None, None, None, 16, None, 18, None, None, 24, None, None, 28, None, None, 32, None, 34, None, None, 47, None, None, 50, None, 66, None, 70, None, None, None, None, 8, None, 11, None, None, None, 15, None, None, None, 17, None, 19, None, None, 23, None, None, 27, None, None, 31, None, 34, None, None, 46, None, None, 49, None, 65, None, 69, None, None, None, None, 7, None, 10, None, None, None, 14, None, None, None, 17, None, 19, None, None, 23, None, None, 27, None, None, 31, None, 33, None, None, 45, None, None, 48, None, 64, None, 68, None, None, None, None, 6, None, 9, None, None, None, 13, None, None, None, 16, None, 18, None, None, 22, None, None, 26, None, None, 30, None, 33, None, None, 44, None, None, 47, None, 63, None, 67, None, None, None, None, 5, None, 8, None, None, None, 12, None, None, None, 15, None, None, None, 17, None, 19, None, None, 22, None, None, 26, None, None, 30, None, 32, None, None, 43, None, None, 46, None, 62, None, 66, None, None, None, None, 4, None, 7, None, None, None, 11, None, None, None, 14, None, None, None, 16, None, 18, None, None, 21, None, None, 25, None, None, 29, None, 32, None, None, 42, None, None, 45, None, 61, None, 65, None, None, None, None, 3, None, 6, None, None, None, 10, None, None, None, 13, None, None, None, 15, None, None, None, 18, None, 20, None, None, 24, None, None, 28, None, 31, None, 33, None, None, 41, None, None, 44, None, 60, None, 64, None, None, None, None, 2, None, 5, None, None, None, 9, None, None, None, 12, None, None, None, 14, None, None, None, 17, None, 19, None, None, 23, None, None, 27, None, None, 31, None, 33, None, None, 40, None, None, 43, None, 59, None, 63, None, None, None, None, 1, None, 4, None, None, None, 8, None, None, None, 11, None, None, None, 13, None, None, None, 16, None, 18, None, None, 22, None, None, 26, None, None, 30, None, 32, None, None, 39, None, None, 42, None, 58, None, 62, None, None, None, None])) == 10\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, 4, 6, 8, 12, 14, 17, 20])) == 4\n assert candidate(root = tree_node([8, 3, 10, 1, 6, None, 14, None, None, 4, 7, 13])) == 3\n assert candidate(root = tree_node([8, 5, 9, 7, 6, 12, None, None, None, None, 15, None, 18])) == 5\n assert candidate(root = tree_node([8, 3, 10, 1, 6, None, 14, None, None, 4, 7, 12, 16])) == 4\n assert candidate(root = tree_node([1, None, 2, None, None, 3, None, None, None, None, 4, None, None, None, None, 5])) == 2\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6])) == 3\n assert candidate(root = tree_node([100, -20, -30, -40, -50, -60, -70, -80, -90, -100, 101, 102, 103, 104, 105])) == 6\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 9\n assert candidate(root = tree_node([100, -50, 50, -100, 0, 25, 75, -200, -100, -75, -25, 0, 100, 150, 200])) == 4\n assert candidate(root = tree_node([20, 10, 20, 5, 15, 15, 25, 3, 7, 12, 18, 22, 30])) == 5\n assert candidate(root = tree_node([5, 1, 6, 0, 2, 5, 8, -1, None, None, 3, None, 4, 7, 9])) == 4\n assert candidate(root = tree_node([1, 3, 2, 5, 3, None, 9, 2, None, 8, None, None, None, None, 4])) == 7\n assert candidate(root = tree_node([5, 4, 8, 11, None, 13, 4, 7, 2, None, None, None, 1])) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, 11, None, None, None, None, 12, 13, None, None, None, None, None, 14, 15])) == 13\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180])) == 4\n assert candidate(root = tree_node([3, 1, 4, 3, None, 1, 5, 2, None, None, None, None, None, 6, None])) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, 7, 8, None, 9, None, 10, 11, 12])) == 12\n assert candidate(root = tree_node([-10, None, -5, -6, None, -8, None, -7])) == 2\n assert candidate(root = tree_node([15, 10, 20, 8, 12, 16, 25, None, None, None, None, None, 19, 22, 30])) == 4\n assert candidate(root = tree_node([3, 2, 4, None, None, 3, 5, None, None, 2, None, None, None, 6])) == 3\n assert candidate(root = tree_node([20, 10, 25, 5, 15, 22, 30, None, None, None, None, 21, 27, 28, 35])) == 5\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 2, 8])) == 3\n assert candidate(root = tree_node([-10, 9, 20, None, None, 15, 7, None, None, None, 12])) == 3\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 9\n assert candidate(root = tree_node([1, 2, 3, None, 5, None, 4, None, None, None, 6])) == 6\n assert candidate(root = tree_node([7, 3, 15, 1, 5, 10, 20, -1, 2, None, 6, 8, 12, 18, 25])) == 4\n assert candidate(root = tree_node([5, 4, 6, 3, 7, None, None, 2, None, None, None, None, None, 8])) == 3\n assert candidate(root = tree_node([10, 10, 10, 10, 10, None, None, 10, 10])) == 7\n assert candidate(root = tree_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, None, None, None, None, None, None, None, None, None])) == 1\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180])) == 4\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, 7, 1, None, 3, 4])) == 3\n assert candidate(root = tree_node([1, -10, -5, 6, 5, None, -8, 3, 12, -9, None, None, -3, None, None, None, None])) == 4\n assert candidate(root = tree_node([-1, -2, -3, -4, -5, None, None, -6, -7])) == 1\n assert candidate(root = tree_node([5, 1, 4, 2, 3, None, None, None, None, 4, 5])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 20\n assert candidate(root = tree_node([-10, -20, -30, -40, -50, -60, -70, -80, -90, -100])) == 1\n assert candidate(root = tree_node([5, 4, 6, 3, None, None, 7, 2, None, None, None, 8])) == 4\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, None, 6, None, 14, None, None, None, 8])) == 3\n assert candidate(root = tree_node([-10, -5, 20, None, 0, 15, 25, -8, None, None, 5, None, None, None, None])) == 5\n assert candidate(root = tree_node([1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])) == 30\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 15\n assert candidate(root = tree_node([5, 4, 6, 3, 8, 5, 7, 2, 9, 10, None, None, 11, 12, 13])) == 9\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 40, 60, 80, 110, 140, 160, 180])) == 4\n assert candidate(root = tree_node([1, 3, 2, 5, 3, None, 9, 2, 8, 2, None, None, None, None, 4, 4, None, None, 5])) == 8\n assert candidate(root = tree_node([7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7])) == 15\n assert candidate(root = tree_node([1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4])) == 15\n assert candidate(root = tree_node([8, 3, 10, 1, 6, 9, 14, None, 2, 4, 7, None, 11, 13, 15])) == 5\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11])) == 11\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, 1, 6, 8, 11, 13, 17, 19, 20])) == 7\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 13, 18, 25])) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 15\n assert candidate(root = tree_node([-1, -2, -3, -4, -5, -6, -7, -8, -9])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11])) == 11\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().goodNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def goodNodes(self, root: TreeNode) -> int:", "container": "Solution", "callable": "goodNodes", "parameters": [{"name": "root", "type": "TreeNode"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1449, "task_id": "form-largest-integer-with-digits-that-add-up-to-target", "difficulty": "Hard", "problem_description": "Given an array of integers cost and an integer target, return the maximum integer you can paint under the following rules:\n\nThe cost of painting a digit (i + 1) is given by cost[i] (0-indexed).\nThe total cost used must be equal to target.\nThe integer does not have 0 digits.\n\nSince the answer may be very large, return it as a string. If there is no way to paint any integer given the condition, return \"0\".\n \nExample 1:\n\nInput: cost = [4,3,2,5,6,7,2,5,5], target = 9\nOutput: \"7772\"\nExplanation: The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost(\"7772\") = 2*3+ 3*1 = 9. You could also paint \"977\", but \"7772\" is the largest number.\nDigit cost\n 1 -> 4\n 2 -> 3\n 3 -> 2\n 4 -> 5\n 5 -> 6\n 6 -> 7\n 7 -> 2\n 8 -> 5\n 9 -> 5\n\nExample 2:\n\nInput: cost = [7,6,5,5,5,6,8,7,8], target = 12\nOutput: \"85\"\nExplanation: The cost to paint the digit '8' is 7, and the digit '5' is 5. Then cost(\"85\") = 7 + 5 = 12.\n\nExample 3:\n\nInput: cost = [2,4,6,2,4,6,4,4,4], target = 5\nOutput: \"0\"\nExplanation: It is impossible to paint any integer with total cost equal to target.\n\n \nConstraints:\n\ncost.length == 9\n1 <= cost[i], target <= 5000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cost = [5, 3, 7, 5, 2, 6, 8, 9, 1],target = 10) == \"9999999999\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 20) == \"99999999999999999999\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 25) == \"99999\"\n assert candidate(cost = [2, 4, 6, 2, 4, 6, 4, 4, 4],target = 5) == \"0\"\n assert candidate(cost = [7, 6, 5, 5, 5, 6, 8, 7, 8],target = 12) == \"85\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == \"999\"\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2],target = 45) == \"9999999999999999999998\"\n assert candidate(cost = [9, 9, 9, 9, 9, 9, 9, 9, 9],target = 5) == \"0\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 9) == \"999999999\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 15) == \"999999999999999\"\n assert candidate(cost = [3, 3, 3, 3, 3, 3, 3, 3, 3],target = 18) == \"999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 10) == \"1111111111\"\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2],target = 30) == \"999999999999999\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 4) == \"9999\"\n assert candidate(cost = [4, 3, 2, 5, 6, 7, 2, 5, 5],target = 9) == \"7772\"\n assert candidate(cost = [7, 3, 2, 1, 5, 8, 4, 6, 9],target = 36) == \"444444444444444444444444444444444444\"\n assert candidate(cost = [5, 3, 9, 1, 7, 6, 2, 8, 4],target = 30) == \"444444444444444444444444444444\"\n assert candidate(cost = [4, 4, 4, 4, 4, 4, 4, 4, 4],target = 200) == \"99999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [8, 7, 6, 5, 4, 3, 2, 1, 9],target = 50) == \"88888888888888888888888888888888888888888888888888\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 35) == \"99999999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 45) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 100) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 15) == \"111111111111111\"\n assert candidate(cost = [8, 5, 2, 6, 4, 3, 9, 7, 1],target = 50) == \"99999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 1, 2, 1, 2, 1, 2, 1],target = 50) == \"99999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 450) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 30) == \"999999\"\n assert candidate(cost = [5, 4, 3, 2, 1, 9, 8, 7, 6],target = 30) == \"555555555555555555555555555555\"\n assert candidate(cost = [4, 5, 6, 1, 2, 3, 7, 8, 9],target = 24) == \"444444444444444444444444\"\n assert candidate(cost = [2, 3, 2, 2, 3, 3, 2, 3, 2],target = 18) == \"999999999\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == \"99999999999999999999\"\n assert candidate(cost = [1, 1, 2, 3, 5, 8, 13, 21, 34],target = 50) == \"22222222222222222222222222222222222222222222222222\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 45) == \"999999999999999999999999999999999999999999999\"\n assert candidate(cost = [5, 9, 2, 7, 3, 6, 8, 1, 4],target = 150) == \"888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\"\n assert candidate(cost = [5, 4, 3, 2, 1, 2, 3, 4, 5],target = 30) == \"555555555555555555555555555555\"\n assert candidate(cost = [100, 200, 300, 400, 500, 600, 700, 800, 900],target = 1800) == \"111111111111111111\"\n assert candidate(cost = [1, 9, 1, 9, 1, 9, 1, 9, 1],target = 45) == \"999999999999999999999999999999999999999999999\"\n assert candidate(cost = [2, 3, 4, 5, 6, 7, 8, 9, 10],target = 25) == \"211111111111\"\n assert candidate(cost = [100, 200, 300, 400, 500, 600, 700, 800, 900],target = 4500) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [4, 3, 2, 5, 6, 7, 2, 5, 5],target = 20) == \"7777777777\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5000) == \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [1, 3, 5, 7, 9, 11, 13, 15, 17],target = 50) == \"11111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 250) == \"1111111111111111111111111\"\n assert candidate(cost = [8, 8, 8, 8, 8, 8, 8, 8, 8],target = 72) == \"999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 50) == \"11111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [4, 4, 4, 4, 4, 4, 4, 4, 4],target = 36) == \"999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 45) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [10, 11, 12, 13, 14, 15, 16, 17, 18],target = 150) == \"111111111111111\"\n assert candidate(cost = [1, 2, 3, 1, 2, 3, 1, 2, 3],target = 20) == \"77777777777777777777\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 100) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 2500) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [3, 1, 4, 1, 5, 9, 2, 6, 5],target = 50) == \"44444444444444444444444444444444444444444444444444\"\n assert candidate(cost = [9, 18, 27, 36, 45, 54, 63, 72, 81],target = 162) == \"111111111111111111\"\n assert candidate(cost = [3, 3, 2, 1, 4, 5, 6, 7, 8],target = 25) == \"4444444444444444444444444\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 30) == \"999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 500) == \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2],target = 20) == \"9999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 1500) == \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [7, 6, 5, 5, 5, 6, 8, 7, 8],target = 24) == \"9655\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 300) == \"111111111111111111111111111111\"\n assert candidate(cost = [10, 10, 10, 10, 10, 10, 10, 10, 10],target = 45) == \"0\"\n assert candidate(cost = [4, 3, 2, 5, 6, 7, 2, 5, 5],target = 18) == \"777777777\"\n assert candidate(cost = [2, 3, 4, 5, 6, 7, 8, 9, 10],target = 55) == \"211111111111111111111111111\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 30) == \"999999\"\n assert candidate(cost = [2, 3, 4, 5, 6, 7, 8, 9, 10],target = 50) == \"1111111111111111111111111\"\n assert candidate(cost = [7, 3, 3, 6, 2, 5, 5, 5, 5],target = 25) == \"555555555553\"\n assert candidate(cost = [9, 9, 9, 9, 9, 9, 9, 9, 9],target = 27) == \"999\"\n assert candidate(cost = [1, 3, 1, 3, 1, 3, 1, 3, 1],target = 15) == \"999999999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 20) == \"11111111111111111111\"\n assert candidate(cost = [2, 3, 5, 7, 11, 13, 17, 19, 23],target = 50) == \"1111111111111111111111111\"\n assert candidate(cost = [4, 3, 2, 5, 6, 7, 2, 5, 5],target = 20) == \"7777777777\"\n assert candidate(cost = [1, 1, 2, 2, 3, 3, 4, 4, 5],target = 20) == \"22222222222222222222\"\n assert candidate(cost = [3, 1, 4, 1, 5, 9, 2, 6, 5],target = 30) == \"444444444444444444444444444444\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1000) == \"9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2],target = 60) == \"999999999999999999999999999999\"\n assert candidate(cost = [3, 5, 7, 9, 11, 13, 15, 17, 19],target = 50) == \"2111111111111111\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 100) == \"9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 27) == \"0\"\n assert candidate(cost = [2, 2, 2, 2, 2, 2, 2, 2, 2],target = 1000) == \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [2, 2, 2, 2, 2, 2, 2, 2, 2],target = 18) == \"999999999\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 25) == \"99999\"\n assert candidate(cost = [1, 3, 1, 3, 1, 3, 1, 3, 1],target = 25) == \"9999999999999999999999999\"\n assert candidate(cost = [1, 2, 1, 2, 1, 2, 1, 2, 1],target = 10) == \"9999999999\"\n assert candidate(cost = [2, 3, 5, 7, 11, 13, 17, 19, 23],target = 100) == \"11111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [2, 2, 2, 2, 2, 2, 2, 2, 2],target = 3000) == \"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [5, 6, 7, 8, 9, 10, 11, 12, 13],target = 30) == \"111111\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 99) == \"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 2, 1, 1, 2, 2, 1, 1],target = 10) == \"9999999999\"\n assert candidate(cost = [2, 3, 3, 4, 4, 4, 5, 5, 5],target = 36) == \"111111111111111111\"\n assert candidate(cost = [2, 2, 2, 2, 2, 2, 2, 2, 2],target = 25) == \"0\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5000) == \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 100) == \"1111111111\"\n assert candidate(cost = [2, 4, 6, 8, 10, 12, 14, 16, 18],target = 5000) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [50, 50, 50, 50, 50, 50, 50, 50, 50],target = 100) == \"99\"\n assert candidate(cost = [100, 200, 300, 400, 500, 600, 700, 800, 900],target = 2700) == \"111111111111111111111111111\"\n assert candidate(cost = [5, 3, 5, 3, 5, 3, 5, 3, 5],target = 20) == \"988888\"\n assert candidate(cost = [20, 19, 18, 17, 16, 15, 14, 13, 12],target = 100) == \"99999995\"\n assert candidate(cost = [2, 3, 4, 5, 6, 7, 8, 9, 10],target = 45) == \"2111111111111111111111\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 1000) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [3, 2, 5, 7, 9, 4, 8, 6, 1],target = 15) == \"999999999999999\"\n assert candidate(cost = [3, 5, 2, 3, 9, 7, 5, 4, 2],target = 15) == \"9999994\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 450) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [3, 3, 3, 3, 3, 3, 3, 3, 3],target = 27) == \"999999999\"\n assert candidate(cost = [3, 1, 4, 1, 5, 9, 2, 6, 5],target = 27) == \"444444444444444444444444444\"\n assert candidate(cost = [3, 3, 3, 3, 3, 3, 3, 3, 3],target = 81) == \"999999999999999999999999999\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 1],target = 30) == \"999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 30) == \"111111111111111111111111111111\"\n assert candidate(cost = [1, 3, 2, 1, 2, 1, 3, 2, 1],target = 50) == \"99999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 45) == \"999999999999999999999999999999999999999999999\"\n assert candidate(cost = [5, 6, 7, 8, 9, 10, 11, 12, 13],target = 100) == \"11111111111111111111\"\n"}, "metadata": {"canonical_parameter_names": ["cost", "target"], "leetcode_dataset_entry_point": "Solution().largestNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def largestNumber(self, cost: list[int], target: int) -> str:", "container": "Solution", "callable": "largestNumber", "parameters": [{"name": "cost", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1450, "task_id": "number-of-students-doing-homework-at-a-given-time", "difficulty": "Easy", "problem_description": "Given two integer arrays startTime and endTime and given an integer queryTime.\nThe ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].\nReturn the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.\n \nExample 1:\n\nInput: startTime = [1,2,3], endTime = [3,2,7], queryTime = 4\nOutput: 1\nExplanation: We have 3 students where:\nThe first student started doing homework at time 1 and finished at time 3 and wasn't doing anything at time 4.\nThe second student started doing homework at time 2 and finished at time 2 and also wasn't doing anything at time 4.\nThe third student started doing homework at time 3 and finished at time 7 and was the only student doing homework at time 4.\n\nExample 2:\n\nInput: startTime = [4], endTime = [4], queryTime = 4\nOutput: 1\nExplanation: The only student was doing their homework at the queryTime.\n\n \nConstraints:\n\nstartTime.length == endTime.length\n1 <= startTime.length <= 100\n1 <= startTime[i] <= endTime[i] <= 1000\n1 <= queryTime <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(startTime = [9, 8, 7, 6],endTime = [10, 9, 8, 7],queryTime = 8) == 2\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [5, 4, 3, 2, 1],queryTime = 3) == 3\n assert candidate(startTime = [5, 5, 5, 5],endTime = [10, 10, 10, 10],queryTime = 7) == 4\n assert candidate(startTime = [9, 8, 7, 6, 5, 4, 3, 2, 1],endTime = [10, 9, 8, 7, 6, 5, 4, 3, 2],queryTime = 5) == 2\n assert candidate(startTime = [4],endTime = [4],queryTime = 4) == 1\n assert candidate(startTime = [1, 2, 3],endTime = [3, 2, 7],queryTime = 4) == 1\n assert candidate(startTime = [100, 200, 300],endTime = [150, 250, 350],queryTime = 225) == 1\n assert candidate(startTime = [1, 3, 6, 7, 9],endTime = [2, 5, 8, 10, 12],queryTime = 6) == 1\n assert candidate(startTime = [9, 8, 7, 6, 5, 4, 3, 2, 1],endTime = [10, 9, 8, 7, 6, 5, 4, 3, 2],queryTime = 6) == 2\n assert candidate(startTime = [1, 1, 1, 1],endTime = [2, 2, 2, 2],queryTime = 1) == 4\n assert candidate(startTime = [1, 3, 5, 7],endTime = [2, 4, 6, 8],queryTime = 5) == 1\n assert candidate(startTime = [10, 20, 30],endTime = [15, 25, 35],queryTime = 22) == 1\n assert candidate(startTime = [5, 5, 5, 5],endTime = [6, 6, 6, 6],queryTime = 5) == 4\n assert candidate(startTime = [100, 200, 300],endTime = [150, 250, 350],queryTime = 225) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [2, 2, 2, 2, 2],queryTime = 1) == 5\n assert candidate(startTime = [100, 200, 300, 400],endTime = [199, 299, 399, 499],queryTime = 250) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queryTime = 500) == 6\n assert candidate(startTime = [500, 550, 600, 650, 700, 750, 800, 850, 900, 950],endTime = [550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],queryTime = 725) == 1\n assert candidate(startTime = [10, 15, 20, 25, 30, 35, 40, 45, 50],endTime = [14, 19, 24, 29, 34, 39, 44, 49, 54],queryTime = 22) == 1\n assert candidate(startTime = [50, 100, 150, 200, 250],endTime = [75, 125, 175, 225, 275],queryTime = 100) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1, 1],endTime = [10, 20, 30, 40, 50, 60],queryTime = 5) == 6\n assert candidate(startTime = [250, 500, 750],endTime = [260, 510, 760],queryTime = 255) == 1\n assert candidate(startTime = [300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],endTime = [350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250],queryTime = 625) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [5, 4, 3, 2, 1],queryTime = 3) == 3\n assert candidate(startTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],endTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queryTime = 55) == 5\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [19, 29, 39, 49, 59, 69, 79, 89, 99, 109],queryTime = 55) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [15, 25, 35, 45, 55],queryTime = 28) == 0\n assert candidate(startTime = [1, 3, 5, 7, 9],endTime = [10, 8, 6, 4, 2],queryTime = 5) == 3\n assert candidate(startTime = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],endTime = [55, 105, 155, 205, 255, 305, 355, 405, 455, 505],queryTime = 102) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [5, 5, 5, 5, 5],queryTime = 3) == 5\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queryTime = 5) == 5\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queryTime = 10) == 1\n assert candidate(startTime = [1, 10, 20, 30, 40, 50],endTime = [10, 20, 30, 40, 50, 60],queryTime = 55) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [15, 25, 35, 45, 55],queryTime = 33) == 1\n assert candidate(startTime = [300, 300, 300, 300],endTime = [600, 600, 600, 600],queryTime = 400) == 4\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [10, 20, 30, 40, 50],queryTime = 10) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 11, 12, 13, 14],queryTime = 8) == 5\n assert candidate(startTime = [1, 1, 1, 1, 1, 1],endTime = [6, 7, 8, 9, 10, 11],queryTime = 5) == 6\n assert candidate(startTime = [1, 1, 1, 1],endTime = [1000, 1000, 1000, 1000],queryTime = 500) == 4\n assert candidate(startTime = [5, 10, 15, 20, 25],endTime = [14, 19, 24, 29, 34],queryTime = 22) == 2\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queryTime = 6) == 5\n assert candidate(startTime = [100, 200, 300, 400],endTime = [150, 250, 350, 450],queryTime = 225) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 20, 30, 40, 50],queryTime = 1) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 225) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],endTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queryTime = 5) == 10\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],queryTime = 10) == 2\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [100, 200, 300, 400, 500],queryTime = 100) == 1\n assert candidate(startTime = [10, 20, 30, 40],endTime = [100, 200, 300, 400],queryTime = 150) == 3\n assert candidate(startTime = [900, 905, 910, 915],endTime = [909, 914, 919, 924],queryTime = 907) == 2\n assert candidate(startTime = [1, 3, 6, 8, 10],endTime = [2, 5, 7, 10, 12],queryTime = 4) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [1, 1, 1, 1, 1],queryTime = 1) == 5\n assert candidate(startTime = [2, 2, 2, 2, 2],endTime = [10, 10, 10, 10, 10],queryTime = 6) == 5\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [200, 300, 400, 500, 600],queryTime = 350) == 1\n assert candidate(startTime = [1, 3, 5, 7, 9],endTime = [2, 4, 6, 8, 10],queryTime = 5) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 275) == 0\n assert candidate(startTime = [100, 200, 300, 400],endTime = [101, 201, 301, 401],queryTime = 200) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],queryTime = 63) == 1\n assert candidate(startTime = [100, 150, 200, 250],endTime = [149, 199, 249, 299],queryTime = 175) == 1\n assert candidate(startTime = [50, 100, 150, 200, 250],endTime = [99, 199, 299, 399, 499],queryTime = 100) == 1\n assert candidate(startTime = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],endTime = [14, 24, 34, 44, 54, 64, 74, 84, 94, 104],queryTime = 100) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],endTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queryTime = 50) == 6\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queryTime = 10) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],endTime = [110, 210, 310, 410, 510, 610, 710, 810, 910, 1010],queryTime = 305) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queryTime = 5) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [500, 400, 300, 200, 100],queryTime = 300) == 3\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 9, 8, 7, 6],queryTime = 6) == 5\n assert candidate(startTime = [200, 200, 300, 300],endTime = [200, 400, 400, 500],queryTime = 200) == 2\n assert candidate(startTime = [10, 10, 10, 10, 10],endTime = [15, 15, 15, 15, 15],queryTime = 12) == 5\n assert candidate(startTime = [1, 10, 20, 30, 40, 50],endTime = [10, 20, 30, 40, 50, 60],queryTime = 25) == 1\n assert candidate(startTime = [999, 998, 997, 996, 995],endTime = [1000, 1000, 1000, 1000, 1000],queryTime = 999) == 5\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 325) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [90, 80, 70, 60, 50, 40, 30, 20, 10, 0],queryTime = 55) == 4\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [1000, 1000, 1000, 1000, 1000],queryTime = 500) == 5\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [200, 300, 400, 500, 600],queryTime = 250) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [5, 10, 15, 20, 25],queryTime = 3) == 3\n assert candidate(startTime = [9, 10, 11, 12, 13],endTime = [10, 12, 14, 16, 18],queryTime = 12) == 3\n assert candidate(startTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],endTime = [101, 201, 301, 401, 501, 601, 701, 801, 901, 1001],queryTime = 500) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 20, 30, 40, 50],queryTime = 25) == 3\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [199, 299, 399, 499, 599],queryTime = 450) == 1\n assert candidate(startTime = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29],endTime = [4, 7, 10, 13, 16, 19, 22, 25, 28, 31],queryTime = 15) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],queryTime = 55) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],endTime = [1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],queryTime = 1500) == 6\n assert candidate(startTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],endTime = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],queryTime = 550) == 5\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [100, 110, 120, 130, 140],queryTime = 60) == 5\n assert candidate(startTime = [1, 3, 5, 7, 9, 11],endTime = [2, 4, 6, 8, 10, 12],queryTime = 6) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 400) == 1\n assert candidate(startTime = [500, 501, 502, 503, 504, 505],endTime = [500, 501, 502, 503, 504, 505],queryTime = 505) == 1\n assert candidate(startTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],endTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queryTime = 7) == 10\n assert candidate(startTime = [500, 600, 700, 800],endTime = [599, 699, 799, 899],queryTime = 750) == 1\n assert candidate(startTime = [1, 100, 200, 300, 400],endTime = [100, 200, 300, 400, 500],queryTime = 150) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queryTime = 15) == 6\n assert candidate(startTime = [500, 550, 600, 650],endTime = [501, 551, 601, 651],queryTime = 550) == 1\n assert candidate(startTime = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],endTime = [5, 6, 6, 7, 7, 8, 8, 9, 9, 10],queryTime = 6) == 9\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [1000, 1000, 1000, 1000, 1000],queryTime = 500) == 5\n assert candidate(startTime = [10, 20, 30, 40],endTime = [15, 25, 35, 45],queryTime = 22) == 1\n"}, "metadata": {"canonical_parameter_names": ["startTime", "endTime", "queryTime"], "leetcode_dataset_entry_point": "Solution().busyStudent", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def busyStudent(self, startTime: list[int], endTime: list[int], queryTime: int) -> int:", "container": "Solution", "callable": "busyStudent", "parameters": [{"name": "startTime", "type": "list[int]"}, {"name": "endTime", "type": "list[int]"}, {"name": "queryTime", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1451, "task_id": "rearrange-words-in-a-sentence", "difficulty": "Medium", "problem_description": "Given a sentence text (A sentence is a string of space-separated words) in the following format:\n\nFirst letter is in upper case.\nEach word in text are separated by a single space.\n\nYour task is to rearrange the words in text such that all words are rearranged in an increasing order of their lengths. If two words have the same length, arrange them in their original order.\nReturn the new text following the format shown above.\n \nExample 1:\n\nInput: text = \"Leetcode is cool\"\nOutput: \"Is cool leetcode\"\nExplanation: There are 3 words, \"Leetcode\" of length 8, \"is\" of length 2 and \"cool\" of length 4.\nOutput is ordered by length and the new first word starts with capital letter.\n\nExample 2:\n\nInput: text = \"Keep calm and code on\"\nOutput: \"On and keep calm code\"\nExplanation: Output is ordered as follows:\n\"On\" 2 letters.\n\"and\" 3 letters.\n\"keep\" 4 letters in case of tie order by position in original text.\n\"calm\" 4 letters.\n\"code\" 4 letters.\n\nExample 3:\n\nInput: text = \"To be or not to be\"\nOutput: \"To be or to be not\"\n\n \nConstraints:\n\ntext begins with a capital letter and then contains lowercase letters and single space between words.\n1 <= text.length <= 10^5\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"A quick brown fox jumps over the lazy dog\") == \"A fox the dog over lazy quick brown jumps\"\n assert candidate(text = \"This is a simple test case\") == \"A is this test case simple\"\n assert candidate(text = \"The weather is sunny\") == \"Is the sunny weather\"\n assert candidate(text = \"A\") == \"A\"\n assert candidate(text = \"A B C D E\") == \"A B C D E\"\n assert candidate(text = \"Pack my box with five dozen liquor jugs\") == \"My box pack with five jugs dozen liquor\"\n assert candidate(text = \"Sorting words by length is fun\") == \"By is fun words length sorting\"\n assert candidate(text = \"I love programming in Python\") == \"I in love Python programming\"\n assert candidate(text = \"How vexingly quick daft zebras jump\") == \"How daft jump quick zebras vexingly\"\n assert candidate(text = \"Every good boy does fine\") == \"Boy good does fine every\"\n assert candidate(text = \"To be or not to be\") == \"To be or to be not\"\n assert candidate(text = \"Leetcode is cool\") == \"Is cool leetcode\"\n assert candidate(text = \"The quick brown fox jumps over the lazy dog\") == \"The fox the dog over lazy quick brown jumps\"\n assert candidate(text = \"This is a test sentence with various word lengths\") == \"A is this test with word various lengths sentence\"\n assert candidate(text = \"Keep calm and code on\") == \"On and keep calm code\"\n assert candidate(text = \"This is a test sentence for the function\") == \"A is for the this test sentence function\"\n assert candidate(text = \"In computer science algorithms often require creative solutions\") == \"In often science require computer creative solutions algorithms\"\n assert candidate(text = \"Silent nights filled with the promise of new beginnings\") == \"Of the new with silent nights filled promise beginnings\"\n assert candidate(text = \"Beautiful sentences flow rhythmically and gracefully\") == \"And flow beautiful sentences gracefully rhythmically\"\n assert candidate(text = \"Health and happiness are the most valuable possessions\") == \"And are the most health valuable happiness possessions\"\n assert candidate(text = \"Exploring the mysteries of the universe is a lifelong journey\") == \"A of is the the journey universe lifelong exploring mysteries\"\n assert candidate(text = \"Understanding these concepts is crucial for programming\") == \"Is for these crucial concepts programming understanding\"\n assert candidate(text = \"Repeating words like test test test should stay in order\") == \"In like test test test stay words order should repeating\"\n assert candidate(text = \"Programming challenges are a great way to improve your skills\") == \"A to are way your great skills improve challenges programming\"\n assert candidate(text = \"The smallest words often hide the deepest meanings\") == \"The the hide words often deepest smallest meanings\"\n assert candidate(text = \"You are never too old to set another goal or to dream a new dream\") == \"A to or to you are too old set new goal never dream dream another\"\n assert candidate(text = \"Sorting algorithms like quicksort and mergesort\") == \"And like sorting quicksort mergesort algorithms\"\n assert candidate(text = \"Learning never stops no matter how much one knows\") == \"No how one much never stops knows matter learning\"\n assert candidate(text = \"Despite its simplicity Unix is a powerful and flexible operating system\") == \"A is its and Unix system despite powerful flexible operating simplicity\"\n assert candidate(text = \"A journey of a thousand miles begins with a single step\") == \"A a a of with step miles begins single journey thousand\"\n assert candidate(text = \"Problem-solving skills are highly valued in the tech industry\") == \"In are the tech skills highly valued industry problem-solving\"\n assert candidate(text = \"Complexity arises when multiple words share the same length\") == \"The when same words share arises length multiple complexity\"\n assert candidate(text = \"In the midst of winter I found there was, within me, an invincible summer\") == \"I in of an the me, was, midst found there winter within summer invincible\"\n assert candidate(text = \"Happiness is not something ready made. It comes from your own actions\") == \"Is It not own from your ready made. comes actions happiness something\"\n assert candidate(text = \"Small steps lead to big progress\") == \"To big lead small steps progress\"\n assert candidate(text = \"With unwavering determination, she embarked on the perilous journey\") == \"On she the with journey embarked perilous unwavering determination,\"\n assert candidate(text = \"BeautifulSoup lxml html parser are widely used for web scraping\") == \"Are for web lxml html used parser widely scraping beautifulsoup\"\n assert candidate(text = \"Sorting words by length while maintaining original order\") == \"By words while order length sorting original maintaining\"\n assert candidate(text = \"We may encounter many defeats but we must not be defeated\") == \"We we be may but not many must defeats defeated encounter\"\n assert candidate(text = \"To achieve great things, we must not only act, but also dream; not only plan, but also believe\") == \"To we not but not but must only act, also only also great plan, dream; achieve things, believe\"\n assert candidate(text = \"A beautiful butterfly gracefully flutters among the colorful flowers\") == \"A the among flowers flutters colorful beautiful butterfly gracefully\"\n assert candidate(text = \"The greatest glory in living lies not in never falling, but in rising every time we fall\") == \"In in in we the not but lies time fall glory never every living rising greatest falling,\"\n assert candidate(text = \"The only way to do great work is to love what you do\") == \"To do is to do the way you only work love what great\"\n assert candidate(text = \"Innovative solutions can be achieved through collaborative efforts\") == \"Be can through efforts achieved solutions innovative collaborative\"\n assert candidate(text = \"Documentation plays a vital role in software development\") == \"A in role plays vital software development documentation\"\n assert candidate(text = \"In the heart of the city stood a magnificent gothic cathedral\") == \"A in of the the city heart stood gothic cathedral magnificent\"\n assert candidate(text = \"In the realm of competitive programming challenges are vast\") == \"In of the are vast realm challenges competitive programming\"\n assert candidate(text = \"In the heart of the city, amidst towering skyscrapers, lies a hidden gem\") == \"A in of the the gem lies heart city, amidst hidden towering skyscrapers,\"\n assert candidate(text = \"Continuous integration and deployment practices improve software quality\") == \"And improve quality software practices continuous deployment integration\"\n assert candidate(text = \"When words are of equal length they should remain in order\") == \"Of in are when they words equal order length should remain\"\n assert candidate(text = \"Understanding the nuances of human behavior is crucial\") == \"Of is the human nuances crucial behavior understanding\"\n assert candidate(text = \"Sometimes simplicity is the ultimate sophistication\") == \"Is the ultimate sometimes simplicity sophistication\"\n assert candidate(text = \"Beautiful scenery can uplift one's spirits\") == \"Can one's uplift scenery spirits beautiful\"\n assert candidate(text = \"If you want to live a happy life, tie it to a goal, not to people or things\") == \"A a if to it to to or you tie not want live happy life, goal, people things\"\n assert candidate(text = \"Consistency is the key to achieving long-term success\") == \"Is to the key success achieving long-term consistency\"\n assert candidate(text = \"The rapid expansion of cloud computing services has transformed many industries\") == \"Of the has many rapid cloud services expansion computing industries transformed\"\n assert candidate(text = \"Data structures and algorithms form the backbone of software\") == \"Of and the data form backbone software structures algorithms\"\n assert candidate(text = \"When faced with difficult problems persistence is key\") == \"Is key when with faced problems difficult persistence\"\n assert candidate(text = \"The sound of crashing waves soothed his restless mind\") == \"Of the his mind sound waves soothed crashing restless\"\n assert candidate(text = \"Effective communication skills are crucial in software engineering\") == \"In are skills crucial software effective engineering communication\"\n assert candidate(text = \"Can you solve this complex rearrangement problem\") == \"Can you this solve complex problem rearrangement\"\n assert candidate(text = \"Keep smiling because life is a beautiful journey not a destination\") == \"A a is not keep life smiling because journey beautiful destination\"\n assert candidate(text = \"Given a string containing multiple words of different lengths\") == \"A of given words string lengths multiple different containing\"\n assert candidate(text = \"A quick brown fox jumps over the lazy dog in an unexpected manner\") == \"A in an fox the dog over lazy quick brown jumps manner unexpected\"\n assert candidate(text = \"Programming challenges often require deep understanding and patience\") == \"And deep often require patience challenges programming understanding\"\n assert candidate(text = \"Adapting to new technologies and methodologies is important\") == \"To is new and adapting important technologies methodologies\"\n assert candidate(text = \"Handling edge cases is important for robust code\") == \"Is for edge code cases robust handling important\"\n assert candidate(text = \"Understanding data structures is crucial for computer scientists\") == \"Is for data crucial computer structures scientists understanding\"\n assert candidate(text = \"Programming challenges are intellectually stimulating\") == \"Are challenges programming stimulating intellectually\"\n assert candidate(text = \"Efficient algorithms can significantly reduce computation time\") == \"Can time reduce efficient algorithms computation significantly\"\n assert candidate(text = \"Believe you can and you're halfway there\") == \"You can and there you're believe halfway\"\n assert candidate(text = \"Actions speak louder than words\") == \"Than speak words louder actions\"\n assert candidate(text = \"Complex algorithms often require sophisticated data structures\") == \"Data often complex require algorithms structures sophisticated\"\n assert candidate(text = \"Python programming language is powerful and versatile\") == \"Is and python language powerful versatile programming\"\n assert candidate(text = \"In the realm of possibilities, anything is achievable\") == \"In of is the realm anything achievable possibilities,\"\n assert candidate(text = \"Learning to code is one of the most empowering experiences\") == \"To is of one the code most learning empowering experiences\"\n assert candidate(text = \"Crafting intricate designs in wood requires both skill and creativity\") == \"In and wood both skill designs crafting requires intricate creativity\"\n assert candidate(text = \"Despite the odds being stacked against him, he never gave up hope\") == \"He up the odds him, gave hope being never despite stacked against\"\n assert candidate(text = \"Those who dare to fail miserably can achieve greatly\") == \"To who can dare fail those achieve greatly miserably\"\n assert candidate(text = \"May the Force be with you\") == \"Be may the you with Force\"\n assert candidate(text = \"Every problem has a unique solution waiting to be discovered\") == \"A to be has every unique problem waiting solution discovered\"\n assert candidate(text = \"Consider various scenarios when testing your solution\") == \"When your various testing consider solution scenarios\"\n assert candidate(text = \"Despite the harsh conditions, the resilient hikers forged ahead\") == \"The the harsh ahead hikers forged despite resilient conditions,\"\n assert candidate(text = \"The ancient ruins whispered tales of forgotten civilizations\") == \"Of the ruins tales ancient whispered forgotten civilizations\"\n assert candidate(text = \"Python programming can be quite challenging indeed\") == \"Be can quite python indeed programming challenging\"\n assert candidate(text = \"Resilience and determination are the keys to success\") == \"To and are the keys success resilience determination\"\n assert candidate(text = \"A very very long sentence that needs to be properly rearranged\") == \"A to be very very long that needs sentence properly rearranged\"\n assert candidate(text = \"When sorting algorithms fail gracefully\") == \"When fail sorting algorithms gracefully\"\n assert candidate(text = \"Adventure and exploration are essential for personal growth\") == \"And are for growth personal adventure essential exploration\"\n assert candidate(text = \"Python Java JavaScript and C are popular programming languages\") == \"C and are Java python popular languages JavaScript programming\"\n assert candidate(text = \"Algorithms and data structures are fundamental to computer science\") == \"To and are data science computer algorithms structures fundamental\"\n assert candidate(text = \"In the heart of autumn leaves change their colors\") == \"In of the heart their autumn leaves change colors\"\n assert candidate(text = \"If life were predictable it would cease to be life, and be without flavor\") == \"If it to be be and life were would cease life, flavor without predictable\"\n assert candidate(text = \"A storm of emotions surged through her heart\") == \"A of her storm heart surged through emotions\"\n assert candidate(text = \"Continuous improvement is the hallmark of excellence\") == \"Is of the hallmark continuous excellence improvement\"\n assert candidate(text = \"The rain in Spain stays mainly in the plain\") == \"In in the the rain Spain stays plain mainly\"\n assert candidate(text = \"Do not watch the clock; do what it does. Keep going\") == \"Do do it not the what Keep watch does. going clock;\"\n assert candidate(text = \"The rapid expansion of artificial intelligence is fascinating\") == \"Of is the rapid expansion artificial fascinating intelligence\"\n assert candidate(text = \"An extraordinary journey through the magical lands\") == \"An the lands journey through magical extraordinary\"\n assert candidate(text = \"The early morning light illuminated the dew-kissed grass\") == \"The the early light grass morning dew-kissed illuminated\"\n assert candidate(text = \"Python is an interpreted high level programming language\") == \"Is an high level python language interpreted programming\"\n assert candidate(text = \"Understanding the intricacies of quantum mechanics requires patience\") == \"Of the quantum requires patience mechanics intricacies understanding\"\n assert candidate(text = \"A bird in the hand is worth two in the bush\") == \"A in is in the two the bird hand bush worth\"\n assert candidate(text = \"XMLHttpRequest allows clients to send and receive data asynchronously without reloading the web page\") == \"To and the web send data page allows clients receive without reloading xmlhttprequest asynchronously\"\n assert candidate(text = \"An overwhelming sense of serenity filled the quaint village\") == \"An of the sense filled quaint village serenity overwhelming\"\n assert candidate(text = \"Beautiful minds think in unpredictable ways\") == \"In ways minds think beautiful unpredictable\"\n assert candidate(text = \"Artificial intelligence and machine learning are transforming industries\") == \"And are machine learning artificial industries intelligence transforming\"\n assert candidate(text = \"It is during our darkest moments that we must focus the light\") == \"It is we our the that must focus light during darkest moments\"\n assert candidate(text = \"Do what you can with all you have, wherever you are\") == \"Do you can all you you are what with have, wherever\"\n assert candidate(text = \"Python is an interpreted high-level general-purpose programming language\") == \"Is an python language high-level interpreted programming general-purpose\"\n assert candidate(text = \"Sometimes life gives you lemons and you make lemonade\") == \"You and you life make gives lemons lemonade sometimes\"\n assert candidate(text = \"Creativity is the key to solving complex problems\") == \"Is to the key solving complex problems creativity\"\n assert candidate(text = \"Even seemingly simple tasks can be complex\") == \"Be can even tasks simple complex seemingly\"\n assert candidate(text = \"Data structures like arrays and linked lists\") == \"And data like lists arrays linked structures\"\n assert candidate(text = \"In computer science algorithms are fundamental\") == \"In are science computer algorithms fundamental\"\n assert candidate(text = \"Wherever you go, go with all your heart\") == \"Go you go, all with your heart wherever\"\n assert candidate(text = \"The magic of books lies in the stories they hold\") == \"Of in the the lies they hold magic books stories\"\n assert candidate(text = \"The children laughed joyfully in the sunlit playground\") == \"In the the sunlit laughed children joyfully playground\"\n assert candidate(text = \"The best time to plant a tree was 20 years ago. The second best time is now\") == \"A to 20 is the was The now best time tree ago. best time plant years second\"\n assert candidate(text = \"This is a test to see if the function handles ties correctly\") == \"A is to if see the this test ties handles function correctly\"\n assert candidate(text = \"Nature's beauty is a constant source of inspiration\") == \"A is of beauty source nature's constant inspiration\"\n assert candidate(text = \"Despite its simplicity quicksort is incredibly effective\") == \"Is its despite quicksort effective simplicity incredibly\"\n assert candidate(text = \"Programming challenges are a great way to improve skills\") == \"A to are way great skills improve challenges programming\"\n assert candidate(text = \"Check if the function can handle sentences with repeated words\") == \"If the can with check words handle function repeated sentences\"\n assert candidate(text = \"In every day, there are 1440 minutes, 86400 seconds and 5184000 milliseconds, so live every second\") == \"In so are and day, 1440 live every there 86400 every second seconds 5184000 minutes, milliseconds,\"\n assert candidate(text = \"Somebody once told me the world is gonna roll me\") == \"Me is me the once told roll world gonna somebody\"\n assert candidate(text = \"Many software projects involve working with multiple programming languages\") == \"Many with involve working software projects multiple languages programming\"\n assert candidate(text = \"Version control systems are essential for software development\") == \"Are for version control systems software essential development\"\n assert candidate(text = \"Writing clean and maintainable code is beneficial\") == \"Is and code clean writing beneficial maintainable\"\n assert candidate(text = \"Understanding the complexities of software development requires patience\") == \"Of the software requires patience development complexities understanding\"\n assert candidate(text = \"Debugging is twice as hard as writing the code in the first place\") == \"Is as as in the the hard code twice first place writing debugging\"\n assert candidate(text = \"Handling large datasets efficiently is a common requirement\") == \"A is large common handling datasets efficiently requirement\"\n assert candidate(text = \"Sometimes simple sentences are the most powerful\") == \"Are the most simple powerful sometimes sentences\"\n assert candidate(text = \"Algorithms data structures and programming languages\") == \"And data languages algorithms structures programming\"\n assert candidate(text = \"Some programmers prefer to use snake_case others CamelCase\") == \"To use some prefer others CamelCase snake_case programmers\"\n assert candidate(text = \"Exploring new cultures broadens one's horizons immensely\") == \"New one's cultures broadens horizons exploring immensely\"\n assert candidate(text = \"This is a simple example to demonstrate the functionality\") == \"A is to the this simple example demonstrate functionality\"\n assert candidate(text = \"Efficient algorithms can significantly reduce processing time\") == \"Can time reduce efficient algorithms processing significantly\"\n assert candidate(text = \"Python programming challenges are incredibly rewarding\") == \"Are python rewarding challenges incredibly programming\"\n assert candidate(text = \"Do not judge each day by the harvest you reap but by the seeds that you plant\") == \"Do by by not day the you but the you each reap that judge seeds plant harvest\"\n assert candidate(text = \"The quick movement of the enemy will jeopardize six gunboats\") == \"Of the the six will quick enemy movement gunboats jeopardize\"\n assert candidate(text = \"Contrary to popular belief Lorem Ipsum is not simply random text\") == \"To is not text Lorem Ipsum belief simply random popular contrary\"\n assert candidate(text = \"Every small victory is a stepping stone to greatness\") == \"A is to every small stone victory stepping greatness\"\n assert candidate(text = \"A mix of long and short words challenges the function greatly\") == \"A of mix and the long short words greatly function challenges\"\n assert candidate(text = \"Innovative solutions require creative thinking processes\") == \"Require creative thinking solutions processes innovative\"\n assert candidate(text = \"Consistency is the bridge between goals and accomplishment\") == \"Is the and goals bridge between consistency accomplishment\"\n assert candidate(text = \"An apple a day keeps the doctor away\") == \"A an day the away apple keeps doctor\"\n assert candidate(text = \"The scent of blooming roses filled the tranquil garden\") == \"Of the the scent roses filled garden blooming tranquil\"\n assert candidate(text = \"In the end we will remember not the words of our enemies but the silence of our friends\") == \"In we of of the end not the our but the our will words enemies silence friends remember\"\n assert candidate(text = \"Edge cases like very long words or many short ones\") == \"Or edge like very long many ones cases words short\"\n assert candidate(text = \"The future belongs to those who believe in the beauty of their dreams\") == \"To in of the who the those their future beauty dreams belongs believe\"\n assert candidate(text = \"Innovative solutions drive technological advancement\") == \"Drive solutions innovative advancement technological\"\n"}, "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().arrangeWords", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def arrangeWords(self, text: str) -> str:", "container": "Solution", "callable": "arrangeWords", "parameters": [{"name": "text", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1452, "task_id": "people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list", "difficulty": "Medium", "problem_description": "Given the array favoriteCompanies where favoriteCompanies[i] is the list of favorites companies for the ith person (indexed from 0).\nReturn the indices of people whose list of favorite companies is not a subset of any other list of favorites companies. You must return the indices in increasing order.\n \nExample 1:\n\nInput: favoriteCompanies = [[\"leetcode\",\"google\",\"facebook\"],[\"google\",\"microsoft\"],[\"google\",\"facebook\"],[\"google\"],[\"amazon\"]]\nOutput: [0,1,4] \nExplanation: \nPerson with index=2 has favoriteCompanies[2]=[\"google\",\"facebook\"] which is a subset of favoriteCompanies[0]=[\"leetcode\",\"google\",\"facebook\"] corresponding to the person with index 0. \nPerson with index=3 has favoriteCompanies[3]=[\"google\"] which is a subset of favoriteCompanies[0]=[\"leetcode\",\"google\",\"facebook\"] and favoriteCompanies[1]=[\"google\",\"microsoft\"]. \nOther lists of favorite companies are not a subset of another list, therefore, the answer is [0,1,4].\n\nExample 2:\n\nInput: favoriteCompanies = [[\"leetcode\",\"google\",\"facebook\"],[\"leetcode\",\"amazon\"],[\"facebook\",\"google\"]]\nOutput: [0,1] \nExplanation: In this case favoriteCompanies[2]=[\"facebook\",\"google\"] is a subset of favoriteCompanies[0]=[\"leetcode\",\"google\",\"facebook\"], therefore, the answer is [0,1].\n\nExample 3:\n\nInput: favoriteCompanies = [[\"leetcode\"],[\"google\"],[\"facebook\"],[\"amazon\"]]\nOutput: [0,1,2,3]\n\n \nConstraints:\n\n1 <= favoriteCompanies.length <= 100\n1 <= favoriteCompanies[i].length <= 500\n1 <= favoriteCompanies[i][j].length <= 20\nAll strings in favoriteCompanies[i] are distinct.\nAll lists of favorite companies are distinct, that is, If we sort alphabetically each list then favoriteCompanies[i] != favoriteCompanies[j].\nAll strings consist of lowercase English letters only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(favoriteCompanies = [['leetcode'], ['google'], ['facebook'], ['amazon']]) == [0, 1, 2, 3]\n assert candidate(favoriteCompanies = [['apple'], ['apple', 'google'], ['google', 'facebook'], ['apple', 'facebook', 'google']]) == [3]\n assert candidate(favoriteCompanies = [['tech', 'innovation'], ['startup', 'tech'], ['innovation', 'startup', 'tech']]) == [2]\n assert candidate(favoriteCompanies = [['leetcode', 'google', 'facebook'], ['leetcode', 'amazon'], ['facebook', 'google']]) == [0, 1]\n assert candidate(favoriteCompanies = [['apple'], ['apple', 'google'], ['google', 'facebook'], ['facebook', 'microsoft']]) == [1, 2, 3]\n assert candidate(favoriteCompanies = [['leetcode', 'google', 'facebook'], ['google', 'microsoft'], ['google', 'facebook'], ['google'], ['amazon']]) == [0, 1, 4]\n assert candidate(favoriteCompanies = [['apple', 'microsoft'], ['google'], ['apple', 'google', 'microsoft'], ['google', 'microsoft']]) == [2]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['banana'], ['apple', 'banana']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana'], ['apple', 'orange'], ['banana', 'orange'], ['apple']]) == [0, 2, 3]\n assert candidate(favoriteCompanies = [['apple'], ['banana'], ['cherry'], ['date'], ['elderberry']]) == [0, 1, 2, 3, 4]\n assert candidate(favoriteCompanies = [['apple', 'google'], ['google'], ['apple', 'microsoft'], ['facebook']]) == [0, 2, 3]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date'], ['banana', 'date'], ['apple', 'banana', 'cherry']]) == [1, 2, 4]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date', 'fig'], ['banana', 'date', 'fig', 'grape'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'kiwi']]) == [4]\n assert candidate(favoriteCompanies = [['google', 'amazon', 'facebook'], ['google', 'facebook'], ['facebook'], ['google'], ['amazon'], ['google', 'amazon'], ['amazon', 'facebook'], ['google', 'amazon', 'facebook']]) == []\n assert candidate(favoriteCompanies = [['amazon', 'apple', 'facebook', 'google', 'microsoft'], ['google'], ['amazon', 'facebook'], ['apple', 'google', 'microsoft'], ['amazon', 'google', 'microsoft', 'apple', 'facebook']]) == []\n assert candidate(favoriteCompanies = [['airbnb', 'expedia', 'booking'], ['expedia', 'tripadvisor', 'kayak'], ['booking', 'tripadvisor', 'kayak'], ['airbnb', 'tripadvisor', 'kayak'], ['expedia', 'booking', 'tripadvisor'], ['airbnb', 'expedia', 'booking', 'tripadvisor', 'kayak']]) == [5]\n assert candidate(favoriteCompanies = [['apple', 'microsoft', 'amazon'], ['google', 'facebook', 'apple'], ['amazon', 'google', 'microsoft', 'facebook'], ['google'], ['microsoft', 'facebook']]) == [0, 1, 2]\n assert candidate(favoriteCompanies = [['leetcode', 'google'], ['google'], ['google', 'facebook'], ['google', 'facebook', 'microsoft'], ['google', 'facebook', 'microsoft', 'amazon'], ['amazon'], ['amazon', 'google'], ['amazon', 'facebook'], ['amazon', 'microsoft'], ['amazon', 'google', 'facebook', 'microsoft']]) == [0]\n assert candidate(favoriteCompanies = [['linkedin', 'facebook', 'twitter'], ['linkedin', 'google', 'instagram'], ['facebook', 'instagram'], ['google', 'twitter'], ['facebook'], ['google'], ['twitter'], ['instagram'], ['linkedin'], ['facebook', 'google', 'instagram', 'twitter', 'linkedin']]) == [9]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['cherry', 'date'], ['apple', 'banana', 'cherry', 'date'], ['banana', 'date', 'apple'], ['apple', 'banana']]) == [3]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry'], ['cherry', 'date'], ['date', 'fig'], ['fig', 'grape'], ['grape', 'honeydew'], ['honeydew', 'kiwi'], ['kiwi', 'lemon'], ['lemon', 'mango'], ['mango', 'nectarine'], ['nectarine', 'orange'], ['orange', 'papaya'], ['papaya', 'quince'], ['quince', 'raspberry'], ['raspberry', 'strawberry'], ['strawberry', 'tangerine'], ['tangerine', 'ugli'], ['ugli', 'vanilla'], ['vanilla', 'watermelon'], ['watermelon', 'xigua'], ['xigua', 'yam'], ['yam', 'zucchini'], ['apple', 'banana', 'cherry'], ['banana', 'cherry', 'date'], ['cherry', 'date', 'fig'], ['date', 'fig', 'grape'], ['fig', 'grape', 'honeydew'], ['honeydew', 'kiwi', 'lemon'], ['kiwi', 'lemon', 'mango'], ['lemon', 'mango', 'nectarine'], ['mango', 'nectarine', 'orange'], ['nectarine', 'orange', 'papaya'], ['orange', 'papaya', 'quince'], ['papaya', 'quince', 'raspberry'], ['quince', 'raspberry', 'strawberry'], ['raspberry', 'strawberry', 'tangerine'], ['strawberry', 'tangerine', 'ugli'], ['tangerine', 'ugli', 'vanilla'], ['ugli', 'vanilla', 'watermelon'], ['vanilla', 'watermelon', 'xigua'], ['watermelon', 'xigua', 'yam'], ['xigua', 'yam', 'zucchini']]) == [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41]\n assert candidate(favoriteCompanies = [['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h', 'i', 'j'], ['a', 'b', 'c', 'd'], ['b', 'c', 'd', 'e'], ['a', 'b', 'c'], ['a', 'b'], ['a'], ['b'], ['c'], ['d'], ['e'], ['f'], ['g'], ['h'], ['i'], ['j']]) == [0, 1]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['cherry'], ['apple', 'cherry'], ['banana', 'cherry', 'date', 'fig'], ['date', 'fig']]) == [0, 4]\n assert candidate(favoriteCompanies = [['uber', 'lyft', 'careem'], ['careem', 'grab', 'gojek'], ['grab', 'uber', 'gojek'], ['gojek', 'grab'], ['careem', 'uber', 'lyft', 'grab', 'gojek']]) == [4]\n assert candidate(favoriteCompanies = [['amazon', 'apple', 'google'], ['google', 'microsoft'], ['facebook', 'google'], ['amazon', 'google', 'facebook'], ['microsoft', 'amazon'], ['amazon', 'facebook', 'google', 'microsoft'], ['apple', 'google', 'facebook']]) == [0, 5, 6]\n assert candidate(favoriteCompanies = [['tech', 'science', 'arts'], ['science', 'arts', 'literature'], ['tech', 'science'], ['science'], ['tech'], ['arts'], ['literature'], ['arts', 'literature'], ['tech', 'arts', 'literature'], ['tech', 'science', 'literature']]) == [0, 1, 8, 9]\n assert candidate(favoriteCompanies = [['tesla', 'toyota', 'ford'], ['toyota', 'ford', 'gm'], ['tesla', 'toyota', 'gm'], ['ford', 'gm'], ['tesla', 'toyota', 'ford', 'gm'], ['tesla', 'gm']]) == [4]\n assert candidate(favoriteCompanies = [['p', 'q', 'r'], ['q', 'r', 's'], ['r', 's', 't'], ['s', 't', 'u'], ['t', 'u', 'v'], ['u', 'v', 'w'], ['v', 'w', 'x'], ['w', 'x', 'y'], ['x', 'y', 'z'], ['y', 'z', 'p'], ['z', 'p', 'q'], ['p', 'q', 'r', 's'], ['q', 'r', 's', 't'], ['r', 's', 't', 'u'], ['s', 't', 'u', 'v'], ['t', 'u', 'v', 'w'], ['u', 'v', 'w', 'x'], ['v', 'w', 'x', 'y'], ['w', 'x', 'y', 'z'], ['x', 'y', 'z', 'p']]) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(favoriteCompanies = [['leetcode'], ['google'], ['facebook'], ['amazon'], ['apple'], ['twitter'], ['youtube'], ['instagram'], ['snapchat'], ['linkedin']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(favoriteCompanies = [['leetcode', 'google', 'facebook', 'amazon'], ['google', 'facebook', 'microsoft'], ['google', 'amazon'], ['amazon'], ['google'], ['facebook']]) == [0, 1]\n assert candidate(favoriteCompanies = [['netflix', 'amazon', 'hulu'], ['amazon', 'hbo', 'crunchyroll'], ['netflix', 'hbo', 'crunchyroll'], ['hulu', 'hbo', 'crunchyroll'], ['netflix', 'amazon', 'hbo', 'crunchyroll'], ['amazon', 'hbo']]) == [0, 3, 4]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry', 'date'], ['date', 'fig', 'grape', 'honeydew'], ['honeydew', 'kiwi', 'lemon', 'mango'], ['mango', 'nectarine', 'orange', 'papaya'], ['papaya', 'quince', 'raspberry', 'strawberry'], ['strawberry', 'tangerine', 'ugli', 'vanilla'], ['vanilla', 'watermelon', 'xigua', 'yam'], ['yam', 'zucchini', 'blueberry', 'blackberry'], ['blueberry', 'blackberry', 'cranberry', 'elderberry'], ['elderberry', 'fig', 'grape', 'honeydew'], ['honeydew', 'kiwi', 'lemon', 'mango'], ['mango', 'nectarine', 'orange', 'papaya'], ['papaya', 'quince', 'raspberry', 'strawberry'], ['strawberry', 'tangerine', 'ugli', 'vanilla'], ['vanilla', 'watermelon', 'xigua', 'yam'], ['yam', 'zucchini', 'blueberry', 'blackberry'], ['blueberry', 'blackberry', 'cranberry', 'elderberry'], ['elderberry', 'fig', 'grape', 'honeydew'], ['honeydew', 'kiwi', 'lemon', 'mango'], ['mango', 'nectarine', 'orange', 'papaya']]) == [0, 1]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry', 'date'], ['cherry', 'date', 'fig'], ['date', 'fig', 'grape'], ['fig', 'grape', 'apple'], ['grape', 'apple', 'banana'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape']]) == [6]\n assert candidate(favoriteCompanies = [['microsoft', 'apple', 'google', 'facebook'], ['google', 'microsoft'], ['facebook', 'apple'], ['apple', 'google', 'facebook'], ['microsoft', 'apple'], ['google', 'amazon'], ['amazon', 'facebook'], ['microsoft', 'google', 'facebook']]) == [0, 5, 6]\n assert candidate(favoriteCompanies = [['twitter'], ['twitter', 'instagram'], ['twitter', 'facebook'], ['instagram', 'facebook'], ['twitter', 'instagram', 'facebook'], ['twitter', 'google'], ['google', 'facebook'], ['instagram', 'google'], ['twitter', 'instagram', 'google', 'facebook']]) == [8]\n assert candidate(favoriteCompanies = [['leetcode'], ['leetcode', 'google'], ['google', 'facebook'], ['leetcode', 'facebook'], ['facebook', 'amazon'], ['google', 'amazon', 'facebook'], ['leetcode', 'amazon', 'google', 'facebook']]) == [6]\n assert candidate(favoriteCompanies = [['apple'], ['banana'], ['cherry'], ['date'], ['fig'], ['grape'], ['kiwi'], ['lemon'], ['mango'], ['orange']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(favoriteCompanies = [['google', 'apple'], ['google', 'apple', 'facebook'], ['google', 'facebook'], ['apple', 'facebook', 'microsoft'], ['google', 'microsoft'], ['apple', 'microsoft'], ['google', 'amazon'], ['apple', 'amazon'], ['facebook', 'amazon'], ['google', 'facebook', 'amazon', 'apple', 'microsoft']]) == [9]\n assert candidate(favoriteCompanies = [['spotify', 'apple', 'google'], ['apple', 'google', 'amazon'], ['google', 'microsoft', 'apple'], ['facebook', 'google', 'amazon'], ['twitter', 'google', 'apple'], ['spotify', 'google', 'microsoft'], ['apple', 'google', 'facebook'], ['google', 'amazon', 'microsoft'], ['twitter', 'facebook', 'microsoft'], ['google', 'apple', 'facebook', 'microsoft', 'amazon', 'twitter', 'spotify']]) == [9]\n assert candidate(favoriteCompanies = [['google', 'facebook', 'amazon', 'apple', 'microsoft'], ['google', 'facebook'], ['google', 'amazon'], ['google', 'apple'], ['google', 'microsoft'], ['facebook', 'amazon'], ['facebook', 'apple'], ['facebook', 'microsoft'], ['amazon', 'apple'], ['amazon', 'microsoft'], ['apple', 'microsoft'], ['google'], ['facebook'], ['amazon'], ['apple'], ['microsoft']]) == [0]\n assert candidate(favoriteCompanies = [['a', 'b', 'c', 'd', 'e'], ['b', 'c', 'd'], ['d', 'e'], ['e', 'a'], ['a', 'b'], ['c', 'd', 'e'], ['a', 'b', 'c'], ['b', 'c'], ['c', 'd'], ['d', 'e'], ['e', 'a'], ['a', 'b']]) == [0]\n assert candidate(favoriteCompanies = [['tech1', 'tech2', 'tech3', 'tech4'], ['tech2', 'tech3'], ['tech3', 'tech4'], ['tech4', 'tech1'], ['tech1', 'tech2'], ['tech2', 'tech3', 'tech4'], ['tech3', 'tech4', 'tech1'], ['tech4', 'tech1', 'tech2'], ['tech1', 'tech2', 'tech3']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['apple', 'banana'], ['banana', 'cherry'], ['apple', 'cherry'], ['date', 'fig', 'grape']]) == [0, 4]\n assert candidate(favoriteCompanies = [['x', 'y', 'z', 'w', 'v'], ['y', 'z'], ['z', 'w'], ['w', 'v'], ['v', 'x'], ['x', 'y'], ['y', 'z', 'w'], ['z', 'w', 'v'], ['w', 'v', 'x'], ['v', 'x', 'y'], ['x', 'y', 'z']]) == [0]\n assert candidate(favoriteCompanies = [['spotify', 'apple', 'deez', 'pandora'], ['apple', 'soundcloud', 'tidal'], ['deez', 'pandora', 'soundcloud'], ['spotify', 'soundcloud', 'tidal'], ['spotify', 'apple', 'deez', 'pandora', 'soundcloud', 'tidal']]) == [4]\n assert candidate(favoriteCompanies = [['uber', 'lyft', 'grubhub'], ['grubhub', 'doorDash', 'postmates'], ['lyft', 'postmates', 'uber'], ['uber', 'lyft', 'grubhub', 'doorDash', 'postmates'], ['postmates', 'grubhub'], ['uber', 'grubhub', 'doorDash'], ['grubhub', 'lyft', 'uber', 'postmates'], ['doorDash', 'lyft']]) == [3]\n assert candidate(favoriteCompanies = [['pinterest', 'quora', 'reddit'], ['quora', 'snapchat', 'twitter'], ['facebook', 'google', 'instagram'], ['linkedin', 'pinterest', 'quora', 'reddit'], ['facebook', 'google', 'instagram', 'linkedin', 'pinterest'], ['pinterest', 'quora', 'reddit', 'snapchat', 'twitter'], ['instagram', 'linkedin', 'pinterest', 'quora', 'reddit']]) == [4, 5, 6]\n assert candidate(favoriteCompanies = [['tech1', 'tech2', 'tech3', 'tech4'], ['tech1', 'tech2'], ['tech2', 'tech3'], ['tech3', 'tech4'], ['tech4', 'tech1'], ['tech2', 'tech4'], ['tech1', 'tech3'], ['tech1', 'tech2', 'tech3'], ['tech2', 'tech3', 'tech4'], ['tech1', 'tech2', 'tech4']]) == [0]\n assert candidate(favoriteCompanies = [['techcrunch', 'theverge'], ['theverge', 'recode'], ['techcrunch', 'recode', 'theverge'], ['theverge', 'cnet'], ['recode', 'cnet', 'theverge'], ['techcrunch', 'cnet'], ['recode', 'cnet'], ['techcrunch', 'recode', 'theverge', 'cnet'], ['cnet', 'theverge'], ['recode', 'theverge', 'cnet'], ['techcrunch', 'theverge', 'cnet', 'recode'], ['cnet'], ['techcrunch'], ['recode']]) == []\n assert candidate(favoriteCompanies = [['xbox', 'playstation', 'nintendo'], ['nintendo', 'sega'], ['playstation', 'nintendo', 'sega'], ['xbox', 'nintendo'], ['playstation', 'sega'], ['xbox', 'playstation', 'nintendo', 'sega'], ['xbox', 'playstation'], ['nintendo']]) == [5]\n assert candidate(favoriteCompanies = [['microsoft', 'amazon', 'google'], ['google'], ['amazon'], ['microsoft'], ['google', 'amazon'], ['google', 'microsoft'], ['microsoft', 'amazon'], ['amazon', 'google'], ['google', 'microsoft', 'amazon'], ['google', 'microsoft', 'amazon', 'facebook']]) == [9]\n assert candidate(favoriteCompanies = [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['b', 'c'], ['c', 'd', 'e'], ['d', 'e', 'f'], ['e', 'f', 'g'], ['f', 'g', 'h'], ['g', 'h'], ['h']]) == [0]\n assert candidate(favoriteCompanies = [['amazon', 'ebay', 'google'], ['google', 'microsoft'], ['ebay', 'microsoft'], ['amazon', 'microsoft'], ['amazon', 'ebay', 'google', 'microsoft']]) == [4]\n assert candidate(favoriteCompanies = [['ibm', 'apple', 'microsoft'], ['apple', 'google', 'amazon'], ['ibm', 'google', 'amazon'], ['microsoft', 'amazon'], ['ibm', 'apple', 'google', 'amazon'], ['apple', 'microsoft', 'google'], ['ibm', 'google']]) == [0, 3, 4, 5]\n assert candidate(favoriteCompanies = [['facebook', 'instagram'], ['instagram', 'snapchat'], ['facebook', 'snapchat'], ['facebook', 'instagram', 'snapchat'], ['facebook'], ['snapchat'], ['instagram']]) == [3]\n assert candidate(favoriteCompanies = [['amazon', 'google', 'apple'], ['google', 'facebook', 'microsoft'], ['amazon', 'facebook', 'apple'], ['google', 'amazon', 'facebook', 'microsoft'], ['google', 'apple']]) == [0, 2, 3]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry'], ['cherry', 'date'], ['date', 'elderberry'], ['elderberry', 'fig'], ['fig', 'grape'], ['grape', 'honeydew'], ['honeydew', 'apple']]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date'], ['banana', 'date'], ['apple', 'banana', 'cherry'], ['apple', 'banana', 'cherry', 'date'], ['apple', 'banana', 'cherry', 'date', 'fig']]) == [6]\n assert candidate(favoriteCompanies = [['apple'], ['banana'], ['cherry'], ['date'], ['elderberry'], ['fig'], ['grape'], ['honeydew'], ['kiwi'], ['lemon'], ['mango'], ['nectarine'], ['orange'], ['papaya'], ['quince'], ['raspberry'], ['strawberry'], ['tangerine'], ['ugli'], ['vanilla'], ['watermelon'], ['xigua'], ['yam'], ['zucchini']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'date', 'elderberry'], ['apple', 'banana', 'cherry', 'date', 'elderberry'], ['cherry', 'date'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape']]) == [2, 4]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date'], ['cherry', 'date', 'fig'], ['apple', 'banana', 'date', 'fig'], ['banana', 'date', 'fig', 'grape'], ['apple', 'cherry', 'fig', 'grape'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'mango'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'mango'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'mango', 'nectarine']]) == [14, 15]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date'], ['banana', 'date'], ['apple', 'banana', 'cherry'], ['apple', 'banana'], ['banana', 'cherry'], ['cherry', 'date'], ['apple', 'date'], ['date']]) == [1, 2]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['cherry', 'date'], ['apple', 'banana'], ['banana', 'cherry', 'date'], ['apple', 'banana', 'cherry', 'date']]) == [4]\n assert candidate(favoriteCompanies = [['a', 'b', 'c', 'd', 'e'], ['a', 'b'], ['b', 'c'], ['c', 'd'], ['d', 'e'], ['e', 'a'], ['a', 'c'], ['b', 'd'], ['c', 'e'], ['d', 'a'], ['e', 'b'], ['a', 'b', 'c'], ['b', 'c', 'd'], ['c', 'd', 'e'], ['d', 'e', 'a'], ['e', 'a', 'b']]) == [0]\n assert candidate(favoriteCompanies = [['company1'], ['company2'], ['company3'], ['company4'], ['company5'], ['company6'], ['company7'], ['company8'], ['company9'], ['company10'], ['company11'], ['company12'], ['company13'], ['company14'], ['company15'], ['company16'], ['company17'], ['company18'], ['company19'], ['company20'], ['company21'], ['company22'], ['company23'], ['company24'], ['company25'], ['company26'], ['company27'], ['company28'], ['company29'], ['company30']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry'], ['cherry', 'date'], ['date', 'fig'], ['fig', 'grape'], ['grape', 'honeydew'], ['honeydew', 'kiwi'], ['kiwi', 'lemon'], ['lemon', 'mango'], ['mango', 'nectarine'], ['nectarine', 'orange'], ['orange', 'papaya'], ['papaya', 'quince'], ['quince', 'raspberry'], ['raspberry', 'strawberry'], ['strawberry', 'tangerine'], ['tangerine', 'ugli'], ['ugli', 'vanilla'], ['vanilla', 'watermelon'], ['watermelon', 'xigua'], ['xigua', 'yam'], ['yam', 'zucchini']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(favoriteCompanies = [['one', 'two', 'three'], ['two', 'three', 'four'], ['three', 'four', 'five'], ['four', 'five', 'six'], ['five', 'six', 'seven'], ['six', 'seven', 'eight'], ['seven', 'eight', 'nine'], ['eight', 'nine', 'ten'], ['nine', 'ten', 'one'], ['ten', 'one', 'two']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(favoriteCompanies = [['honda', 'toyota', 'mazda'], ['toyota', 'nissan', 'mitsubishi'], ['honda', 'toyota', 'nissan', 'mitsubishi'], ['mazda', 'nissan', 'mitsubishi'], ['honda', 'toyota', 'mazda', 'nissan', 'mitsubishi']]) == [4]\n assert candidate(favoriteCompanies = [['amazon', 'apple', 'facebook', 'google'], ['apple', 'facebook'], ['amazon', 'google'], ['facebook', 'google'], ['amazon', 'facebook', 'google'], ['apple', 'google']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry', 'date', 'elderberry'], ['banana', 'cherry', 'date', 'fig'], ['apple', 'banana', 'date', 'fig', 'grape'], ['cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'cherry', 'fig', 'grape', 'honeydew'], ['banana', 'cherry', 'grape', 'honeydew']]) == [0, 1, 2, 3, 4, 5]\n assert candidate(favoriteCompanies = [['alibaba', 'tencent', 'jd'], ['tencent', 'xiami', 'sina'], ['jd', 'xiami', 'sina'], ['alibaba', 'tencent', 'jd', 'sina'], ['xiami', 'sina'], ['alibaba', 'jd']]) == [1, 2, 3]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry', 'date'], ['banana', 'cherry'], ['apple', 'cherry', 'date'], ['cherry', 'date'], ['apple', 'banana', 'cherry'], ['banana', 'date'], ['apple', 'banana', 'cherry', 'date', 'elderberry'], ['banana', 'cherry', 'date', 'fig'], ['apple', 'banana', 'date', 'fig', 'grape'], ['cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'cherry', 'fig', 'grape', 'honeydew'], ['banana', 'cherry', 'grape', 'honeydew']]) == [6, 7, 8, 9, 10, 11]\n assert candidate(favoriteCompanies = [['google'], ['google', 'facebook'], ['google', 'facebook', 'amazon'], ['google', 'facebook', 'amazon', 'apple'], ['google', 'facebook', 'amazon', 'apple', 'microsoft'], ['google', 'facebook', 'amazon', 'apple', 'microsoft', 'netflix'], ['google', 'facebook', 'amazon', 'apple', 'microsoft', 'netflix', 'spotify']]) == [6]\n assert candidate(favoriteCompanies = [['microsoft', 'google'], ['google', 'facebook'], ['leetcode', 'google', 'facebook'], ['google'], ['amazon'], ['microsoft', 'amazon'], ['amazon', 'google']]) == [0, 2, 5, 6]\n assert candidate(favoriteCompanies = [['apple', 'google', 'facebook', 'microsoft'], ['google', 'facebook', 'microsoft'], ['apple', 'facebook', 'microsoft'], ['apple', 'google', 'microsoft'], ['apple', 'google', 'facebook'], ['facebook', 'microsoft'], ['google', 'microsoft'], ['apple', 'microsoft'], ['apple', 'google'], ['apple', 'facebook']]) == [0]\n assert candidate(favoriteCompanies = [['netflix', 'hulu'], ['hulu', 'crunchyroll'], ['netflix', 'crunchyroll'], ['netflix', 'hulu', 'crunchyroll'], ['netflix', 'hulu', 'crunchyroll', 'disney'], ['disney'], ['netflix'], ['hulu'], ['crunchyroll'], ['netflix', 'hulu', 'disney'], ['hulu', 'crunchyroll', 'disney'], ['netflix', 'crunchyroll', 'disney']]) == [4]\n assert candidate(favoriteCompanies = [['google', 'amazon', 'facebook'], ['google', 'amazon'], ['google'], ['amazon'], ['facebook'], ['google', 'facebook'], ['amazon', 'facebook']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['apple', 'cherry'], ['cherry'], ['apple', 'banana'], ['banana']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'microsoft', 'google'], ['amazon', 'apple', 'microsoft'], ['apple', 'google'], ['google', 'microsoft'], ['facebook', 'google', 'microsoft', 'amazon'], ['apple', 'banana', 'cherry']]) == [0, 1, 4, 5]\n"}, "metadata": {"canonical_parameter_names": ["favoriteCompanies"], "leetcode_dataset_entry_point": "Solution().peopleIndexes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def peopleIndexes(self, favoriteCompanies: list[list[str]]) -> list[int]:", "container": "Solution", "callable": "peopleIndexes", "parameters": [{"name": "favoriteCompanies", "type": "list[list[str]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1453, "task_id": "maximum-number-of-darts-inside-of-a-circular-dartboard", "difficulty": "Hard", "problem_description": "Alice is throwing n darts on a very large wall. You are given an array darts where darts[i] = [xi, yi] is the position of the ith dart that Alice threw on the wall.\nBob knows the positions of the n darts on the wall. He wants to place a dartboard of radius r on the wall so that the maximum number of darts that Alice throws lie on the dartboard.\nGiven the integer r, return the maximum number of darts that can lie on the dartboard.\n \nExample 1:\n\n\nInput: darts = [[-2,0],[2,0],[0,2],[0,-2]], r = 2\nOutput: 4\nExplanation: Circle dartboard with center in (0,0) and radius = 2 contain all points.\n\nExample 2:\n\n\nInput: darts = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5\nOutput: 5\nExplanation: Circle dartboard with center in (0,4) and radius = 5 contain all points except the point (7,8).\n\n \nConstraints:\n\n1 <= darts.length <= 100\ndarts[i].length == 2\n-104 <= xi, yi <= 104\nAll the darts are unique\n1 <= r <= 5000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(darts = [[100, 100], [-100, -100], [0, 0]],r = 150) == 3\n assert candidate(darts = [[-5000, -5000], [5000, 5000], [-5000, 5000], [5000, -5000]],r = 7071) == 2\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3]],r = 1) == 3\n assert candidate(darts = [[-3, 0], [3, 0], [2, 6], [5, 4], [0, 9], [7, 8]],r = 5) == 5\n assert candidate(darts = [[-10000, 10000], [10000, -10000]],r = 5000) == 1\n assert candidate(darts = [[-1, -1], [1, 1], [-1, 1], [1, -1]],r = 2) == 4\n assert candidate(darts = [[-2, 2], [-3, 3], [-1, 1], [0, 0]],r = 2) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3]],r = 1) == 2\n assert candidate(darts = [[0, 0], [1, 1], [1.4, 1.4]],r = 1) == 3\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]],r = 2) == 3\n assert candidate(darts = [[0, 0], [10000, 0], [0, 10000], [10000, 10000]],r = 5000) == 2\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 2) == 3\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]],r = 1) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 1) == 2\n assert candidate(darts = [[1000, -1000], [-1000, 1000], [0, 0]],r = 1500) == 3\n assert candidate(darts = [[-5, 0], [5, 0], [0, 5], [0, -5]],r = 5) == 4\n assert candidate(darts = [[0, 0], [10, 0], [0, 10], [10, 10]],r = 7) == 2\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]],r = 1) == 3\n assert candidate(darts = [[-5, -5], [5, 5], [-5, 5], [5, -5]],r = 7) == 2\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 3) == 4\n assert candidate(darts = [[-1, 0], [0, 1], [1, 0], [0, -1]],r = 1) == 4\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0]],r = 1) == 3\n assert candidate(darts = [[0, 0], [1, 1], [1, -1], [-1, 1], [-1, -1]],r = 2) == 5\n assert candidate(darts = [[10, 10], [11, 11], [12, 12], [13, 13], [14, 14]],r = 1) == 2\n assert candidate(darts = [[-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2]],r = 1) == 2\n assert candidate(darts = [[0, 0], [0, 1], [1, 0], [1, 1]],r = 1) == 4\n assert candidate(darts = [[0, 0], [1, 0], [0, 1]],r = 1) == 3\n assert candidate(darts = [[-2, 0], [2, 0], [0, 2], [0, -2]],r = 2) == 4\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5]],r = 1) == 2\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],r = 1) == 2\n assert candidate(darts = [[-5000, 0], [5000, 0], [0, -5000], [0, 5000], [2500, 2500]],r = 5000) == 5\n assert candidate(darts = [[-2, -2], [-2, 0], [-2, 2], [0, -2], [0, 0], [0, 2], [2, -2], [2, 0], [2, 2]],r = 2) == 5\n assert candidate(darts = [[-200, 200], [-100, 100], [-50, 50], [0, 0], [50, -50], [100, -100], [200, -200], [50, 150], [150, 50], [-150, -50], [-50, -150]],r = 150) == 7\n assert candidate(darts = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]],r = 5) == 2\n assert candidate(darts = [[-10000, 10000], [10000, -10000], [0, 0], [5000, 5000], [-5000, -5000]],r = 5000) == 2\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],r = 5) == 4\n assert candidate(darts = [[-1, 0], [1, 0], [0, -1], [0, 1], [0.5, 0.5], [-0.5, -0.5], [0.5, -0.5], [-0.5, 0.5]],r = 1) == 8\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]],r = 2) == 5\n assert candidate(darts = [[-2, 2], [-2, -2], [2, 2], [2, -2], [0, 0], [0, 4], [4, 0], [4, 4]],r = 4) == 7\n assert candidate(darts = [[100, 100], [200, 200], [150, 150], [50, 50], [300, 300]],r = 150) == 4\n assert candidate(darts = [[1, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]],r = 5) == 4\n assert candidate(darts = [[1, 1], [1, 3], [3, 1], [3, 3], [5, 5], [5, 7], [7, 5], [7, 7], [9, 9], [9, 11]],r = 2.83) == 5\n assert candidate(darts = [[-5000, -5000], [-5000, 5000], [5000, 5000], [5000, -5000], [0, 0]],r = 7071) == 3\n assert candidate(darts = [[0, 0], [10, 0], [20, 0], [30, 0], [40, 0], [50, 0], [60, 0], [70, 0], [80, 0], [90, 0]],r = 10) == 3\n assert candidate(darts = [[-1000, -1000], [1000, 1000], [1000, -1000], [-1000, 1000], [0, 0]],r = 1414) == 3\n assert candidate(darts = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000], [1100, 1200], [1300, 1400], [1500, 1600], [1700, 1800], [1900, 2000]],r = 500) == 4\n assert candidate(darts = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700]],r = 150) == 3\n assert candidate(darts = [[0, 0], [5000, 0], [0, 5000], [5000, 5000], [2500, 2500]],r = 3000) == 3\n assert candidate(darts = [[-10, -10], [-9, -9], [-8, -8], [-7, -7], [-6, -6], [-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1]],r = 4) == 6\n assert candidate(darts = [[-1000, -1000], [-1000, 1000], [1000, -1000], [1000, 1000], [0, 0]],r = 1500) == 5\n assert candidate(darts = [[-500, -500], [-250, -250], [0, 0], [250, 250], [500, 500], [-500, 500], [500, -500]],r = 500) == 4\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]],r = 4) == 9\n assert candidate(darts = [[0, 0], [0, 2], [2, 0], [2, 2], [1, 1], [1, 3], [3, 1], [3, 3]],r = 2) == 7\n assert candidate(darts = [[0, 0], [100, 0], [200, 0], [300, 0], [400, 0], [500, 0], [600, 0], [700, 0], [800, 0], [900, 0]],r = 150) == 4\n assert candidate(darts = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]],r = 5) == 5\n assert candidate(darts = [[0, 0], [10, 0], [5, 5]],r = 10) == 3\n assert candidate(darts = [[100, 100], [200, 100], [100, 200], [200, 200], [150, 150], [125, 125], [175, 175]],r = 50) == 4\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 2) == 3\n assert candidate(darts = [[0, 0], [50, 0], [100, 0], [150, 0], [200, 0], [250, 0], [300, 0], [350, 0], [400, 0], [450, 0], [500, 0]],r = 200) == 9\n assert candidate(darts = [[100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [100, 200], [200, 300]],r = 100) == 5\n assert candidate(darts = [[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000]],r = 5000) == 5\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 1) == 2\n assert candidate(darts = [[0, 0], [1, 0], [0, 1], [1, 1], [0.5, 0.5]],r = 1) == 5\n assert candidate(darts = [[-1, -1], [-1, 1], [1, -1], [1, 1], [0, 0]],r = 1) == 3\n assert candidate(darts = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],r = 2) == 3\n assert candidate(darts = [[0, 0], [10, 0], [20, 0], [30, 0], [40, 0]],r = 10) == 3\n assert candidate(darts = [[-2000, -2000], [-1000, -1000], [0, 0], [1000, 1000], [2000, 2000], [1000, 0], [0, 1000]],r = 1414) == 4\n assert candidate(darts = [[-5000, -5000], [-4000, -4000], [-4500, -4500], [-3000, -3000], [-5500, -5500]],r = 1000) == 3\n assert candidate(darts = [[-1, -1], [0, -1], [1, -1], [-1, 0], [0, 0], [1, 0], [-1, 1], [0, 1], [1, 1]],r = 1) == 5\n assert candidate(darts = [[-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10]],r = 8) == 3\n assert candidate(darts = [[-100, -100], [-100, 100], [100, -100], [100, 100], [0, 0]],r = 150) == 5\n assert candidate(darts = [[-1, -2], [-2, -4], [-3, -6], [-4, -8], [-5, -10], [-6, -12], [-7, -14]],r = 3) == 3\n assert candidate(darts = [[-1000, 0], [0, -1000], [1000, 0], [0, 1000], [500, 500], [-500, 500], [500, -500], [-500, -500]],r = 1000) == 8\n assert candidate(darts = [[-1000, -1000], [-1000, 1000], [1000, 1000], [1000, -1000], [0, 0], [500, 500]],r = 1000) == 4\n assert candidate(darts = [[-10, 0], [0, -10], [10, 0], [0, 10], [0, 0], [5, 5], [-5, -5], [-5, 5], [5, -5]],r = 15) == 9\n assert candidate(darts = [[-10, -10], [-10, 0], [-10, 10], [0, -10], [0, 0], [0, 10], [10, -10], [10, 0], [10, 10]],r = 15) == 9\n assert candidate(darts = [[-10, 0], [10, 0], [0, -10], [0, 10], [5, 5], [-5, -5]],r = 10) == 6\n assert candidate(darts = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15], [0, 0]],r = 10) == 5\n assert candidate(darts = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]],r = 50) == 8\n assert candidate(darts = [[0, 0], [0, 100], [0, 200], [0, 300], [0, 400], [0, 500], [0, 600], [0, 700], [0, 800], [0, 900]],r = 150) == 4\n assert candidate(darts = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],r = 15) == 3\n assert candidate(darts = [[10, 10], [10, 20], [20, 10], [20, 20], [30, 30], [40, 40], [50, 50]],r = 15) == 5\n assert candidate(darts = [[-2000, -2000], [-2000, 2000], [2000, -2000], [2000, 2000], [0, 0]],r = 2500) == 3\n assert candidate(darts = [[-5000, 0], [5000, 0], [0, 5000], [0, -5000]],r = 5000) == 4\n assert candidate(darts = [[-2, -2], [-2, 2], [2, -2], [2, 2], [0, 0], [-1, 1], [1, -1], [-1, -1], [1, 1]],r = 3) == 9\n assert candidate(darts = [[1, 1], [1, 5], [5, 5], [5, 1], [3, 3], [2, 2], [4, 4], [2, 3], [3, 2], [4, 3], [3, 4]],r = 2) == 8\n assert candidate(darts = [[-500, 0], [-400, 0], [-300, 0], [-200, 0], [-100, 0], [0, 0], [100, 0], [200, 0], [300, 0], [400, 0]],r = 100) == 3\n assert candidate(darts = [[-5000, -5000], [5000, 5000], [0, 0], [1000, 1000], [-1000, -1000]],r = 6000) == 4\n assert candidate(darts = [[-10, 10], [10, -10], [-10, -10], [10, 10], [0, 0]],r = 20) == 5\n assert candidate(darts = [[1000, 1000], [1500, 1000], [1000, 1500], [1500, 1500], [2500, 2500]],r = 1000) == 4\n assert candidate(darts = [[-1000, 1000], [-500, 500], [0, 0], [500, -500], [1000, -1000]],r = 1500) == 5\n assert candidate(darts = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],r = 150) == 3\n assert candidate(darts = [[5, 5], [10, 5], [15, 5], [20, 5], [25, 5], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10]],r = 5) == 4\n assert candidate(darts = [[-20, 20], [-20, -20], [20, 20], [20, -20], [0, 0], [0, 40], [40, 0], [40, 40], [50, 50]],r = 50) == 9\n assert candidate(darts = [[1, 1], [2, 1], [3, 1], [4, 1], [1, 2], [2, 2], [3, 2], [4, 2], [1, 3], [2, 3], [3, 3], [4, 3]],r = 1) == 5\n assert candidate(darts = [[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000]],r = 1000) == 2\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]],r = 5) == 4\n assert candidate(darts = [[-5000, 5000], [5000, -5000], [-5000, -5000], [5000, 5000], [0, 0]],r = 5000) == 3\n assert candidate(darts = [[0, 0], [100, 0], [200, 0], [300, 0], [400, 0], [500, 0], [600, 0], [700, 0], [800, 0], [900, 0]],r = 100) == 3\n assert candidate(darts = [[1000, -1000], [1500, -1000], [2000, -1000], [1000, -1500], [1000, -2000]],r = 500) == 3\n assert candidate(darts = [[1000, 1000], [1001, 1001], [1002, 1002], [1003, 1003], [1004, 1004], [1005, 1005], [1006, 1006], [1007, 1007], [1008, 1008], [1009, 1009]],r = 1) == 2\n assert candidate(darts = [[1, 1], [1, 4], [4, 1], [4, 4], [2, 2], [3, 3]],r = 2) == 4\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],r = 3) == 7\n assert candidate(darts = [[-5000, -5000], [5000, 5000], [0, 0], [1, 1]],r = 5000) == 3\n assert candidate(darts = [[0, 0], [0, 10], [10, 0], [10, 10]],r = 7) == 2\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],r = 2) == 3\n assert candidate(darts = [[0, 0], [10000, 10000], [-10000, -10000], [5000, -5000], [-5000, 5000]],r = 14142) == 4\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],r = 1) == 1\n assert candidate(darts = [[-1000, 1000], [1000, -1000], [500, 500], [-500, -500]],r = 1000) == 3\n assert candidate(darts = [[1, 1], [1, 3], [3, 1], [3, 3], [2, 2], [4, 4], [4, 5], [5, 4]],r = 1) == 3\n assert candidate(darts = [[-5000, -5000], [-4000, -4000], [-3000, -3000], [-2000, -2000], [-1000, -1000]],r = 1000) == 2\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0]],r = 2) == 5\n assert candidate(darts = [[-5, -5], [0, 0], [5, 5], [10, 10], [15, 15]],r = 7) == 2\n assert candidate(darts = [[-100, -100], [100, 100], [-100, 100], [100, -100], [0, 0]],r = 150) == 5\n assert candidate(darts = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],r = 1) == 5\n assert candidate(darts = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700]],r = 100) == 2\n assert candidate(darts = [[100, 100], [101, 100], [102, 102], [102, 101], [101, 102]],r = 2) == 5\n assert candidate(darts = [[0, 0], [5, 0], [5, 5], [0, 5], [2.5, 2.5]],r = 3) == 3\n assert candidate(darts = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3]],r = 1) == 4\n assert candidate(darts = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14]],r = 3) == 3\n assert candidate(darts = [[-1000, 1000], [-900, 1100], [-800, 1200], [-700, 1300], [-600, 1400], [-500, 1500], [-400, 1600], [-300, 1700]],r = 200) == 3\n assert candidate(darts = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]],r = 50) == 4\n assert candidate(darts = [[-2000, -2000], [2000, 2000], [0, 0], [1000, -1000], [-1000, 1000]],r = 2500) == 4\n assert candidate(darts = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600]],r = 100) == 2\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],r = 1.5) == 3\n assert candidate(darts = [[500, 500], [500, 600], [600, 500], [600, 600], [300, 300], [300, 400], [400, 300], [400, 400]],r = 141) == 4\n assert candidate(darts = [[-5, 5], [5, 5], [5, -5], [-5, -5], [0, 0]],r = 5) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 2) == 3\n assert candidate(darts = [[1, 1], [2, 1], [1, 2], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],r = 1) == 4\n assert candidate(darts = [[0, 0], [0, 1], [1, 0], [1, 1], [0, 2], [1, 2], [2, 0], [2, 1], [2, 2]],r = 1.5) == 9\n"}, "metadata": {"canonical_parameter_names": ["darts", "r"], "leetcode_dataset_entry_point": "Solution().numPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numPoints(self, darts: list[list[int]], r: int) -> int:", "container": "Solution", "callable": "numPoints", "parameters": [{"name": "darts", "type": "list[list[int]]"}, {"name": "r", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1455, "task_id": "check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence", "difficulty": "Easy", "problem_description": "Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence.\nReturn the index of the word in sentence (1-indexed) where searchWord is a prefix of this word. If searchWord is a prefix of more than one word, return the index of the first word (minimum index). If there is no such word return -1.\nA prefix of a string s is any leading contiguous substring of s.\n \nExample 1:\n\nInput: sentence = \"i love eating burger\", searchWord = \"burg\"\nOutput: 4\nExplanation: \"burg\" is prefix of \"burger\" which is the 4th word in the sentence.\n\nExample 2:\n\nInput: sentence = \"this problem is an easy problem\", searchWord = \"pro\"\nOutput: 2\nExplanation: \"pro\" is prefix of \"problem\" which is the 2nd and the 6th word in the sentence, but we return 2 as it's the minimal index.\n\nExample 3:\n\nInput: sentence = \"i am tired\", searchWord = \"you\"\nOutput: -1\nExplanation: \"you\" is not a prefix of any word in the sentence.\n\n \nConstraints:\n\n1 <= sentence.length <= 100\n1 <= searchWord.length <= 10\nsentence consists of lowercase English letters and spaces.\nsearchWord consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence = \"a ab abc abd\",searchWord = \"a\") == 1\n assert candidate(sentence = \"abcde fghij klmno\",searchWord = \"mnop\") == -1\n assert candidate(sentence = \"find prefix quickly\",searchWord = \"qui\") == 3\n assert candidate(sentence = \"prefix test\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"prefix test\",searchWord = \"testprefix\") == -1\n assert candidate(sentence = \"hello world\",searchWord = \"he\") == 1\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aaaa\") == 4\n assert candidate(sentence = \"coding in python is fun\",searchWord = \"py\") == 3\n assert candidate(sentence = \"i love eating burger\",searchWord = \"burg\") == 4\n assert candidate(sentence = \"prefix prefixation prefixed pre\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"i am tired\",searchWord = \"you\") == -1\n assert candidate(sentence = \"example test case\",searchWord = \"exa\") == 1\n assert candidate(sentence = \"start end\",searchWord = \"sta\") == 1\n assert candidate(sentence = \"no match here\",searchWord = \"none\") == -1\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"qui\") == 2\n assert candidate(sentence = \"coding in python\",searchWord = \"py\") == 3\n assert candidate(sentence = \"prefix test\",searchWord = \"fix\") == -1\n assert candidate(sentence = \"prefix test\",searchWord = \"test\") == 2\n assert candidate(sentence = \"abc def ghi\",searchWord = \"def\") == 2\n assert candidate(sentence = \"no matches here\",searchWord = \"match\") == 2\n assert candidate(sentence = \"all words unique\",searchWord = \"word\") == 2\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aaa\") == 3\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"a\") == 1\n assert candidate(sentence = \"unique words only here\",searchWord = \"word\") == 2\n assert candidate(sentence = \"prefix prefix prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"one two three\",searchWord = \"four\") == -1\n assert candidate(sentence = \"prefix test\",searchWord = \"tes\") == 2\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aa\") == 2\n assert candidate(sentence = \"make america great again\",searchWord = \"am\") == 2\n assert candidate(sentence = \"prefix is the start\",searchWord = \"start\") == 4\n assert candidate(sentence = \"a b c d e f g\",searchWord = \"g\") == 7\n assert candidate(sentence = \"find the prefix\",searchWord = \"pre\") == 3\n assert candidate(sentence = \"this problem is an easy problem\",searchWord = \"pro\") == 2\n assert candidate(sentence = \"last word match\",searchWord = \"match\") == 3\n assert candidate(sentence = \"prefix test\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"a ab abc abcd abcde\",searchWord = \"abc\") == 3\n assert candidate(sentence = \"mississippi missouri\",searchWord = \"miss\") == 1\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aaaaa\") == -1\n assert candidate(sentence = \"multiple matches match matcher matching\",searchWord = \"mat\") == 2\n assert candidate(sentence = \"introduction to the world of algorithms and datastructures\",searchWord = \"data\") == 8\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyz\",searchWord = \"abc\") == 1\n assert candidate(sentence = \"mississippi missouri missing\",searchWord = \"miss\") == 1\n assert candidate(sentence = \"prefix is present in the prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"unique words only unique\",searchWord = \"uniq\") == 1\n assert candidate(sentence = \"look at these examples\",searchWord = \"these\") == 3\n assert candidate(sentence = \"unique words only here\",searchWord = \"only\") == 3\n assert candidate(sentence = \"prefix suffix prefixsuffix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"testing for edge cases with different words\",searchWord = \"dif\") == 6\n assert candidate(sentence = \"python java c++ c#\",searchWord = \"c\") == 3\n assert candidate(sentence = \"one two three four five six seven eight nine ten\",searchWord = \"ten\") == 10\n assert candidate(sentence = \"aaaaa aaaaa aaaaa aaaaa\",searchWord = \"aaaa\") == 1\n assert candidate(sentence = \"algorithm datastructure code compiler bytecode\",searchWord = \"byte\") == 5\n assert candidate(sentence = \"finding exact match in the sentence\",searchWord = \"exac\") == 2\n assert candidate(sentence = \"hello world from the other side\",searchWord = \"from\") == 3\n assert candidate(sentence = \"singleword\",searchWord = \"single\") == 1\n assert candidate(sentence = \"this is a very very long sentence to test the code properly\",searchWord = \"very\") == 4\n assert candidate(sentence = \"multiple occurrences of the same prefix\",searchWord = \"same\") == 5\n assert candidate(sentence = \"prefix testing with prefix prefix prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"overlap overlapping overlapped overlap\",searchWord = \"overl\") == 1\n assert candidate(sentence = \"find the correct index\",searchWord = \"cor\") == 3\n assert candidate(sentence = \"python programming is powerful\",searchWord = \"pro\") == 2\n assert candidate(sentence = \"boundary conditions need testing\",searchWord = \"test\") == 4\n assert candidate(sentence = \"algorithm and data structures are important\",searchWord = \"and\") == 2\n assert candidate(sentence = \"substring matching problem\",searchWord = \"match\") == 2\n assert candidate(sentence = \"pneumonoultramicroscopicsilicovolcanoconiosis pneumonoultramicroscopicsilicovolcanoconiosis\",searchWord = \"pneumono\") == 1\n assert candidate(sentence = \"hello world hello universe\",searchWord = \"he\") == 1\n assert candidate(sentence = \"algorithm datastructure programming language compiler\",searchWord = \"pro\") == 3\n assert candidate(sentence = \"uniquewordsinthesentence\",searchWord = \"words\") == -1\n assert candidate(sentence = \"prefixprefixprefixprefix\",searchWord = \"pref\") == 1\n assert candidate(sentence = \"quick brown fox jumps over the lazy dog\",searchWord = \"qu\") == 1\n assert candidate(sentence = \"continuous conversation connection component\",searchWord = \"con\") == 1\n assert candidate(sentence = \"small big medium small\",searchWord = \"sm\") == 1\n assert candidate(sentence = \"algorithm and data structures\",searchWord = \"alg\") == 1\n assert candidate(sentence = \"prefix problem prefixing prefixer\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"short longword reallylongword evenlongerword\",searchWord = \"long\") == 2\n assert candidate(sentence = \"binary search quicksort mergesort heapsort\",searchWord = \"sort\") == -1\n assert candidate(sentence = \"one two three four five six seven eight nine ten\",searchWord = \"fi\") == 5\n assert candidate(sentence = \"aaaaa aaaa aa a\",searchWord = \"a\") == 1\n assert candidate(sentence = \"prefix search in a list of words\",searchWord = \"sea\") == 2\n assert candidate(sentence = \"testing boundary conditions\",searchWord = \"boundary\") == 2\n assert candidate(sentence = \"testing edgecases with variouslengthwords\",searchWord = \"var\") == 4\n assert candidate(sentence = \"very very long sentence with many words to test the function\",searchWord = \"very\") == 1\n assert candidate(sentence = \"repeated repeated repeated\",searchWord = \"rep\") == 1\n assert candidate(sentence = \"searching for a longprefixword\",searchWord = \"longprefix\") == 4\n assert candidate(sentence = \"an apple a day keeps the doctor away\",searchWord = \"app\") == 2\n assert candidate(sentence = \"sun moon stars planets galaxies blackholes nebulas\",searchWord = \"black\") == 6\n assert candidate(sentence = \"every good boy does fine great boys deserve fine gifts\",searchWord = \"fi\") == 5\n assert candidate(sentence = \"abcdefgh abcdefghij abcdefghijk abcdefghijkl\",searchWord = \"abcdefg\") == 1\n assert candidate(sentence = \"another example to check\",searchWord = \"to\") == 3\n assert candidate(sentence = \"this is a simple test to check for prefix matching\",searchWord = \"tes\") == 5\n assert candidate(sentence = \"searching for exact prefix\",searchWord = \"sea\") == 1\n assert candidate(sentence = \"prefix prefix prefix prefix\",searchWord = \"pref\") == 1\n assert candidate(sentence = \"this is a simple sentence for testing\",searchWord = \"simple\") == 4\n assert candidate(sentence = \"hiddenprefixword is here\",searchWord = \"hidden\") == 1\n assert candidate(sentence = \"banana apple banana apple banana\",searchWord = \"ba\") == 1\n assert candidate(sentence = \"words with multiple spaces\",searchWord = \"mul\") == 3\n assert candidate(sentence = \"algorithm datastructure programming language\",searchWord = \"pro\") == 3\n assert candidate(sentence = \"prefixprefixprefixprefixprefix\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"prefix prefix prefix prefix prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"complex problem requiring careful thought\",searchWord = \"com\") == 1\n assert candidate(sentence = \"random words with no match\",searchWord = \"nomatch\") == -1\n assert candidate(sentence = \"python programming py pyth pytho\",searchWord = \"py\") == 1\n assert candidate(sentence = \"abcd efgh ijkl mnop qrst uvwx yz\",searchWord = \"yz\") == 7\n assert candidate(sentence = \"findingprefixsinthesentence\",searchWord = \"finding\") == 1\n assert candidate(sentence = \"prefix matching is important for search engines\",searchWord = \"search\") == 6\n assert candidate(sentence = \"abcdefghij abcdefghij abcdefghij\",searchWord = \"abcdefghijk\") == -1\n assert candidate(sentence = \"abracadabra abracadabra abracadabra\",searchWord = \"abra\") == 1\n assert candidate(sentence = \"nonmatchingprefix prefix\",searchWord = \"non\") == 1\n assert candidate(sentence = \"finding the first occurrence firstness\",searchWord = \"fir\") == 3\n assert candidate(sentence = \"prefix matching problem prefixing preposition\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"none of these should match\",searchWord = \"non\") == 1\n assert candidate(sentence = \"prefix prefixing prefixation prefixed\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"multiple occurrences of a word word\",searchWord = \"word\") == 5\n assert candidate(sentence = \"all words are different\",searchWord = \"dif\") == 4\n assert candidate(sentence = \"prefixes are important in computer science\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"mismatch mismatching mismatches\",searchWord = \"mis\") == 1\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"do\") == 9\n assert candidate(sentence = \"xy xxy xxxy xxxxy xxxxyy xxxxyyy\",searchWord = \"xxxxy\") == 4\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"dog\") == 9\n assert candidate(sentence = \"repeated repeated repeated repeated\",searchWord = \"repeat\") == 1\n assert candidate(sentence = \"quick brown fox jumps over lazy dog\",searchWord = \"quic\") == 1\n assert candidate(sentence = \"prefixprefixprefix prefixprefix prefix pre prefixing\",searchWord = \"prefixp\") == 1\n assert candidate(sentence = \"ab ac ad ae af ag ah ai aj\",searchWord = \"a\") == 1\n assert candidate(sentence = \"this is a simple test case\",searchWord = \"sim\") == 4\n assert candidate(sentence = \"prefixprefix prefixprefixer prefixprefixing\",searchWord = \"prefixpre\") == 1\n assert candidate(sentence = \"unique words with no match\",searchWord = \"xyz\") == -1\n assert candidate(sentence = \"abracadabra abracadabra abracadabra\",searchWord = \"abrac\") == 1\n assert candidate(sentence = \"continuous integration and continuous delivery\",searchWord = \"cont\") == 1\n assert candidate(sentence = \"searching for the prefix within\",searchWord = \"with\") == 5\n assert candidate(sentence = \"consecutive words with same start\",searchWord = \"con\") == 1\n assert candidate(sentence = \"short long longer longest\",searchWord = \"long\") == 2\n assert candidate(sentence = \"consistent consistent consistency consistently\",searchWord = \"consist\") == 1\n assert candidate(sentence = \"a short simple sentence\",searchWord = \"shor\") == 2\n assert candidate(sentence = \"searching for a unique prefix\",searchWord = \"uniq\") == 4\n assert candidate(sentence = \"a quick brown fox jumps over the lazy dog\",searchWord = \"fox\") == 4\n assert candidate(sentence = \"programming is fun and educational\",searchWord = \"edu\") == 5\n assert candidate(sentence = \"finding the veryfirst occurrence\",searchWord = \"ver\") == 3\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"qu\") == 2\n assert candidate(sentence = \"prefix prefixing prefixed\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"boundary conditions are tricky\",searchWord = \"tri\") == 4\n assert candidate(sentence = \"complexity of the problem\",searchWord = \"com\") == 1\n assert candidate(sentence = \"a aa aaa aaaa aaaaa aaaaaa\",searchWord = \"aaaa\") == 4\n assert candidate(sentence = \"searching for a specific word\",searchWord = \"spec\") == 4\n assert candidate(sentence = \"multiple occurrences of the same prefix prefix prefix\",searchWord = \"pre\") == 6\n assert candidate(sentence = \"ab abc abcd abcde abcdef abcdefg abcdefgh abcdefghi abcdefghij\",searchWord = \"abcde\") == 4\n assert candidate(sentence = \"partial match is not allowed\",searchWord = \"parti\") == 1\n assert candidate(sentence = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",searchWord = \"z\") == 26\n assert candidate(sentence = \"one two three four five six seven eight nine ten\",searchWord = \"nine\") == 9\n assert candidate(sentence = \"prefixes prefixing prefix pre prefixed\",searchWord = \"pref\") == 1\n assert candidate(sentence = \"prefix prefixing prefixed pre prefixable\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"a a aa aa aaa\",searchWord = \"aaa\") == 5\n assert candidate(sentence = \"looking for a specific starting sequence\",searchWord = \"spe\") == 4\n assert candidate(sentence = \"alibaba cloud offers many products like ecs ec2 s3\",searchWord = \"ec\") == 7\n assert candidate(sentence = \"algorithm data structure and algorithm\",searchWord = \"algo\") == 1\n assert candidate(sentence = \"overlapwording overlapword overlap\",searchWord = \"overlap\") == 1\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"the\") == 1\n assert candidate(sentence = \"prefix prefix prefix\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"prefix prefix prefix prefix\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"shorter is better\",searchWord = \"short\") == 1\n assert candidate(sentence = \"algorithms and data structures\",searchWord = \"and\") == 2\n assert candidate(sentence = \"interview question with multiple prefixes prefix\",searchWord = \"pre\") == 5\n assert candidate(sentence = \"banana bandana band breadth\",searchWord = \"ban\") == 1\n assert candidate(sentence = \"algorithms and data structures are fundamental\",searchWord = \"data\") == 3\n assert candidate(sentence = \"practice makes perfect in programming\",searchWord = \"per\") == 3\n assert candidate(sentence = \"verylongwordthatwilltesttheboundariesofthisfunction\",searchWord = \"verylong\") == 1\n assert candidate(sentence = \"longerprefix longerpre long pre\",searchWord = \"longerpre\") == 1\n assert candidate(sentence = \"this is a simple sentence with repeated words repeated words\",searchWord = \"repe\") == 7\n assert candidate(sentence = \"a quick brown fox jumps over the lazy dog\",searchWord = \"do\") == 9\n assert candidate(sentence = \"multiple occurrences of words words\",searchWord = \"words\") == 4\n assert candidate(sentence = \"double double double trouble\",searchWord = \"double\") == 1\n assert candidate(sentence = \"complicated complex complication\",searchWord = \"comp\") == 1\n assert candidate(sentence = \"banana bandana bandanna banana bandana\",searchWord = \"band\") == 2\n"}, "metadata": {"canonical_parameter_names": ["sentence", "searchWord"], "leetcode_dataset_entry_point": "Solution().isPrefixOfWord", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def isPrefixOfWord(self, sentence: str, searchWord: str) -> int:", "container": "Solution", "callable": "isPrefixOfWord", "parameters": [{"name": "sentence", "type": "str"}, {"name": "searchWord", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1456, "task_id": "maximum-number-of-vowels-in-a-substring-of-given-length", "difficulty": "Medium", "problem_description": "Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.\nVowel letters in English are 'a', 'e', 'i', 'o', and 'u'.\n \nExample 1:\n\nInput: s = \"abciiidef\", k = 3\nOutput: 3\nExplanation: The substring \"iii\" contains 3 vowel letters.\n\nExample 2:\n\nInput: s = \"aeiou\", k = 2\nOutput: 2\nExplanation: Any substring of length 2 contains 2 vowels.\n\nExample 3:\n\nInput: s = \"leetcode\", k = 3\nOutput: 2\nExplanation: \"lee\", \"eet\" and \"ode\" contain 2 vowels.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of lowercase English letters.\n1 <= k <= s.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aooiiieeec\",k = 6) == 6\n assert candidate(s = \"a\",k = 1) == 1\n assert candidate(s = \"happy\",k = 2) == 1\n assert candidate(s = \"rhythms\",k = 5) == 0\n assert candidate(s = \"fluffy\",k = 2) == 1\n assert candidate(s = \"leetcode\",k = 3) == 2\n assert candidate(s = \"aeiou\",k = 2) == 2\n assert candidate(s = \"beautiful\",k = 4) == 3\n assert candidate(s = \"rhythms\",k = 4) == 0\n assert candidate(s = \"bbbb\",k = 2) == 0\n assert candidate(s = \"aaaaaa\",k = 5) == 5\n assert candidate(s = \"abciiidef\",k = 3) == 3\n assert candidate(s = \"aabbccddeeff\",k = 4) == 2\n assert candidate(s = \"quartz\",k = 3) == 2\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuu\",k = 5) == 5\n assert candidate(s = \"eiuaooeiuaooeiuaooeiuaoo\",k = 8) == 8\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\",k = 3) == 0\n assert candidate(s = \"understanding\",k = 4) == 2\n assert candidate(s = \"abacabadabacaba\",k = 5) == 3\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\",k = 100) == 50\n assert candidate(s = \"aeiouaeiou\",k = 1) == 1\n assert candidate(s = \"bbbbbbaaaaa\",k = 5) == 5\n assert candidate(s = \"bbaeixixixixxxeiiixieeiix\",k = 15) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 50) == 0\n assert candidate(s = \"uoieaouieaouieaouieaouieaouieao\",k = 15) == 15\n assert candidate(s = \"mississippi\",k = 4) == 2\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiou\",k = 20) == 20\n assert candidate(s = \"iouaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 50) == 50\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 12) == 4\n assert candidate(s = \"xyzvowelsabcdefg\",k = 5) == 2\n assert candidate(s = \"leetcodeisawesome\",k = 5) == 3\n assert candidate(s = \"lovelaceeinstein\",k = 7) == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 13) == 3\n assert candidate(s = \"thisisaverylongstringwithsomevowelsinside\",k = 20) == 8\n assert candidate(s = \"aaaaaaaabbbbbbbbcccccccc\",k = 12) == 8\n assert candidate(s = \"bbaeiooacaioiiceiue\",k = 11) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 20) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 26) == 6\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiou\",k = 10) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzz\",k = 20) == 0\n assert candidate(s = \"uvvwxyz\",k = 3) == 1\n assert candidate(s = \"abcdeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\",k = 15) == 15\n assert candidate(s = \"uoieaouieaouieaouieaouieaouiea\",k = 7) == 7\n assert candidate(s = \"mnoabcdeioufghijkl\",k = 7) == 4\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 15) == 4\n assert candidate(s = \"leetcodeisaverygoodplatform\",k = 10) == 6\n assert candidate(s = \"ababababab\",k = 5) == 3\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\",k = 30) == 30\n assert candidate(s = \"bcdafg\",k = 6) == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaa\",k = 10) == 10\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\",k = 1) == 0\n assert candidate(s = \"thisisaverylongstringwithseveralvowelsinside\",k = 15) == 6\n assert candidate(s = \"aiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioiei\",k = 20) == 20\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\",k = 15) == 15\n assert candidate(s = \"uoieaouioeaouioeaouioe\",k = 12) == 12\n assert candidate(s = \"aeiouaeiouaeiouaeiou\",k = 7) == 7\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbc\",k = 7) == 0\n assert candidate(s = \"uqeiouqeiouqeiouqeiouqeiouqe\",k = 11) == 9\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 10) == 3\n assert candidate(s = \"qqqwwweee\",k = 4) == 3\n assert candidate(s = \"bbaeixoubb\",k = 5) == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 26) == 5\n assert candidate(s = \"aeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeiioooooooouuuuuuuuuuuaaaaaaaa\",k = 25) == 25\n assert candidate(s = \"bvflkqmbvkjgnqmfqlqjflvngqnvfkvnqjvfbvmqjbfvmlkjbfnvqjgbfnvqjbngfjkqnvbmfkqjbgfnjkbv\",k = 10) == 0\n assert candidate(s = \"vowelsarebeautiful\",k = 10) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 15) == 0\n assert candidate(s = \"bcbcbcbcbcbaaaaaa\",k = 10) == 6\n assert candidate(s = \"aeiaaioaaaaeiiiiiiooooaauuaeiu\",k = 15) == 15\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\",k = 8) == 0\n assert candidate(s = \"thisisaverylongstringwithlotsofvowelsandconsonants\",k = 18) == 7\n assert candidate(s = \"environmentally\",k = 10) == 4\n assert candidate(s = \"leetcodeisacommunityforcoders\",k = 8) == 5\n assert candidate(s = \"leetcodeisfun\",k = 7) == 4\n assert candidate(s = \"leetcodeisawesome\",k = 7) == 4\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\",k = 10) == 0\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiii\",k = 5) == 3\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbc\",k = 3) == 0\n assert candidate(s = \"uoieaooooieau\",k = 7) == 7\n assert candidate(s = \"abecidofugihanukleomnonuopqrstuvwxyz\",k = 20) == 10\n assert candidate(s = \"aeiaaioaaaaeiiiiouuuu\",k = 12) == 12\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().maxVowels", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxVowels(self, s: str, k: int) -> int:", "container": "Solution", "callable": "maxVowels", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1458, "task_id": "max-dot-product-of-two-subsequences", "difficulty": "Hard", "problem_description": "Given two arrays nums1 and nums2.\nReturn the maximum dot product between non-empty subsequences of nums1 and nums2 with the same length.\nA subsequence of a array is a new array which is formed from the original array by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, [2,3,5] is a subsequence of [1,2,3,4,5] while [1,5,3] is not).\n \nExample 1:\n\nInput: nums1 = [2,1,-2,5], nums2 = [3,0,-6]\nOutput: 18\nExplanation: Take subsequence [2,-2] from nums1 and subsequence [3,-6] from nums2.\nTheir dot product is (2*3 + (-2)*(-6)) = 18.\nExample 2:\n\nInput: nums1 = [3,-2], nums2 = [2,-6,7]\nOutput: 21\nExplanation: Take subsequence [3] from nums1 and subsequence [7] from nums2.\nTheir dot product is (3*7) = 21.\nExample 3:\n\nInput: nums1 = [-1,-1], nums2 = [1,1]\nOutput: -1\nExplanation: Take subsequence [-1] from nums1 and subsequence [1] from nums2.\nTheir dot product is -1.\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 500\n-1000 <= nums1[i], nums2[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1]) == 2\n assert candidate(nums1 = [2, 1, -2, 5],nums2 = [3, 0, -6]) == 18\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 46\n assert candidate(nums1 = [1, 3, -5, 4],nums2 = [-2, -4, 0, 3]) == 32\n assert candidate(nums1 = [-1, -1],nums2 = [1, 1]) == -1\n assert candidate(nums1 = [1000, -1000],nums2 = [-1000, 1000]) == 1000000\n assert candidate(nums1 = [-1000, 1000],nums2 = [-1000, 1000]) == 2000000\n assert candidate(nums1 = [5, 4, -3],nums2 = [4, -1, -2]) == 26\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 46\n assert candidate(nums1 = [1000],nums2 = [-1000]) == -1000000\n assert candidate(nums1 = [0, 1, 2, 3, 4],nums2 = [5, 6, 7, 8, 9]) == 80\n assert candidate(nums1 = [-1000],nums2 = [1000]) == -1000000\n assert candidate(nums1 = [3, -2],nums2 = [2, -6, 7]) == 21\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [-3, -2, -1, 0]) == 0\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 46\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 46\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1]) == 12\n assert candidate(nums1 = [1, 2, 3],nums2 = [-5, -4, -3]) == -3\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 32\n assert candidate(nums1 = [5, 4, 3],nums2 = [1, 2, 3]) == 22\n assert candidate(nums1 = [5, 5, 2, 1, 5],nums2 = [1, 2, 4, 2, 5]) == 59\n assert candidate(nums1 = [1],nums2 = [1]) == 1\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [-1, -2, -3, -4, -5]) == 46\n assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0]) == 0\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums1 = [999, -999, 999, -999, 999],nums2 = [-999, 999, -999, 999, -999]) == 3992004\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums1 = [5, 2, -4, 7, -8],nums2 = [3, -1, 6, -3, 2]) == 85\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 2, 3, 4]) == 0\n assert candidate(nums1 = [1, -1, 1, -1, 1, -1],nums2 = [-1, 1, -1, 1, -1, 1]) == 5\n assert candidate(nums1 = [1, -1, 1, -1, 1],nums2 = [1, -1, 1, -1, 1]) == 5\n assert candidate(nums1 = [5, 3, -4, 2, 1],nums2 = [-2, 6, 3, -5, 4]) == 67\n assert candidate(nums1 = [5, 3, -2, 4],nums2 = [1, 2, 3, 4, 5]) == 47\n assert candidate(nums1 = [100, -100, 200, -200, 300],nums2 = [1, -1, 2, -2, 3]) == 1900\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],nums2 = [-5, 5, -4, 4, -3, 3, -2, 2, -1, 1]) == 90\n assert candidate(nums1 = [100, -100, 200, -200],nums2 = [-100, 100, -200, 200]) == 70000\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-1, -2, -3, -4, -5]) == -10\n assert candidate(nums1 = [-10, -20, -30, -40, -50],nums2 = [1, 2, 3, 4, 5]) == -10\n assert candidate(nums1 = [999, 1000, -999, -1000],nums2 = [-999, 999, -1000, 1000]) == 1999000\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == -100\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-10, -20, -30, -40, -50]) == -100\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 320\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],nums2 = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 81\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5]) == 125\n assert candidate(nums1 = [5, -10, 15, -20, 25],nums2 = [-5, 10, -15, 20]) == 1000\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 46\n assert candidate(nums1 = [100, -100, 200, -200, 300, -300],nums2 = [10, -10, 20, -20, 30, -30]) == 28000\n assert candidate(nums1 = [0, 1, -1, 2, -2, 3, -3],nums2 = [3, -3, 2, -2, 1, -1, 0]) == 24\n assert candidate(nums1 = [5, -3, 10, 2, -7],nums2 = [8, 4, -2, 6, 1]) == 108\n assert candidate(nums1 = [-500, -400, -300, -200, -100],nums2 = [100, 200, 300, 400, 500]) == -10000\n assert candidate(nums1 = [-5, -3, -2, -4],nums2 = [-1, -2, -3, -4, -5]) == 47\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1029\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 74\n assert candidate(nums1 = [100, 0, 200, 0, 300, 0, 400, 0, 500, 0],nums2 = [0, 500, 0, 400, 0, 300, 0, 200, 0, 100]) == 460000\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [1, 3, 5, 7, 9]) == 190\n assert candidate(nums1 = [10, -10, 20, -20, 30],nums2 = [30, -30, 20, -20, 10]) == 1800\n assert candidate(nums1 = [-1, 0, 1, 0, -1],nums2 = [-1, 0, 1, 0, -1]) == 3\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [-1, -2, -3, -4, -5]) == -1\n assert candidate(nums1 = [5, -3, 8, -1, 7],nums2 = [-2, 4, 1, -5, 3]) == 64\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3]) == 56\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [5, 4, 3, 2, 1]) == -1\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [-100, -200, -300, -400, -500]) == -10000\n assert candidate(nums1 = [1000, 900, 800, 700, 600],nums2 = [10, 20, 30, 40, 50]) == 114000\n assert candidate(nums1 = [5, -3, 2, 1, 6],nums2 = [-1, 2, -3, 4, 5]) == 57\n assert candidate(nums1 = [1, 2, 3],nums2 = [100, 200, 300, 400, 500]) == 2600\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [-5, -4, -3, -2, -1]) == 46\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == -1\n assert candidate(nums1 = [1, -2, 3, -4, 5],nums2 = [-5, 4, -3, 2, -1]) == 44\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 385\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 2, 3]) == 2600\n assert candidate(nums1 = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],nums2 = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 38500\n assert candidate(nums1 = [999, -999, 888, -888, 777, -777],nums2 = [-666, 666, -555, 555, -444, 444, -333, 333]) == 2710620\n assert candidate(nums1 = [1, -1, 1, -1, 1],nums2 = [-1, 1, -1, 1, -1]) == 4\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 4750\n assert candidate(nums1 = [1000, 999, 998, 997, 996],nums2 = [1, 2, 3, 4, 5]) == 14960\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [100, 200, 300]) == 2200\n assert candidate(nums1 = [100, -100, 200, -200],nums2 = [300, -300, 400, -400]) == 220000\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6, 7, 8, 9, 10, 11, 12]) == 68\n assert candidate(nums1 = [1, 2, 3],nums2 = [-1, -2, -3, 4, 5]) == 23\n assert candidate(nums1 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums1 = [5, -3, 8, 1],nums2 = [-7, 4, 6, -2]) == 69\n assert candidate(nums1 = [1, 3, -5, 7, -9],nums2 = [-9, 7, -5, 3, 1]) == 139\n assert candidate(nums1 = [1, 3, -5, 7, -9, 11],nums2 = [11, -9, 7, -5, 3, -1]) == 235\n assert candidate(nums1 = [1, 3, -5, 7, -9],nums2 = [-2, 4, -6, 8, -10]) == 188\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 20, 10]) == 1200\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3850\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 190\n assert candidate(nums1 = [-5, -5, -5, -5, -5],nums2 = [-5, -5, -5, -5, -5]) == 125\n assert candidate(nums1 = [1, 0, -1, 0, 1],nums2 = [0, 1, 0, -1, 0]) == 2\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100]) == 460000\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5]) == 55\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums1 = [-50, -40, -30, -20, -10],nums2 = [-10, -20, -30, -40, -50]) == 4600\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3],nums2 = [-1, 1, -2, 2, -3, 3]) == 22\n assert candidate(nums1 = [100, 200, 300],nums2 = [1, 2, 3, 4, 5]) == 2600\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [-1, -1, -1, -1, -1]) == -1\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3],nums2 = [3, -3, 2, -2, 1, -1]) == 24\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [-1, -2, -3, -4, -5]) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [10]) == 1000\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-50, -40, -30, -20, -10]) == -100\n assert candidate(nums1 = [-10, -20, -30, -40, -50],nums2 = [10, 20, 30, 40, 50]) == -100\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10]) == 4600\n assert candidate(nums1 = [1, 0, -1, 0, 1],nums2 = [1, 0, -1, 0, 1]) == 3\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13],nums2 = [2, 4, 6, 8, 10, 12, 14]) == 504\n assert candidate(nums1 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [-1, -1, -1, -1, -1]) == -1\n assert candidate(nums1 = [-1, 0, 1, -2, 0, 2],nums2 = [2, 0, -2, 0, 1, -1]) == 8\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maxDotProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxDotProduct(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "maxDotProduct", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1460, "task_id": "make-two-arrays-equal-by-reversing-subarrays", "difficulty": "Easy", "problem_description": "You are given two integer arrays of equal length target and arr. In one step, you can select any non-empty subarray of arr and reverse it. You are allowed to make any number of steps.\nReturn true if you can make arr equal to target or false otherwise.\n \nExample 1:\n\nInput: target = [1,2,3,4], arr = [2,4,1,3]\nOutput: true\nExplanation: You can follow the next steps to convert arr to target:\n1- Reverse subarray [2,4,1], arr becomes [1,4,2,3]\n2- Reverse subarray [4,2], arr becomes [1,2,4,3]\n3- Reverse subarray [4,3], arr becomes [1,2,3,4]\nThere are multiple ways to convert arr to target, this is not the only way to do so.\n\nExample 2:\n\nInput: target = [7], arr = [7]\nOutput: true\nExplanation: arr is equal to target without any reverses.\n\nExample 3:\n\nInput: target = [3,7,9], arr = [3,7,11]\nOutput: false\nExplanation: arr does not have value 9 and it can never be converted to target.\n\n \nConstraints:\n\ntarget.length == arr.length\n1 <= target.length <= 1000\n1 <= target[i] <= 1000\n1 <= arr[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [4, 3, 2, 1],arr = [1, 2, 3, 4]) == True\n assert candidate(target = [5, 6, 7, 8],arr = [8, 7, 6, 5]) == True\n assert candidate(target = [1, 1, 1, 1],arr = [1, 1, 1, 1]) == True\n assert candidate(target = [1, 3, 5, 7],arr = [7, 5, 3, 1]) == True\n assert candidate(target = [1000, 1000, 1000],arr = [1000, 1000, 1000]) == True\n assert candidate(target = [10, 20, 30, 40],arr = [40, 30, 20, 10]) == True\n assert candidate(target = [1, 2, 3],arr = [3, 2, 1]) == True\n assert candidate(target = [5, 4, 3, 2, 1],arr = [1, 2, 3, 4, 5]) == True\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 4, 3, 2, 1]) == True\n assert candidate(target = [10, 20, 30],arr = [30, 20, 10]) == True\n assert candidate(target = [5, 1, 3, 2],arr = [2, 1, 3, 5]) == True\n assert candidate(target = [1000, 1, 1000],arr = [1, 1000, 1000]) == True\n assert candidate(target = [1, 2, 2, 3],arr = [2, 1, 3, 2]) == True\n assert candidate(target = [10, 20, 30, 40, 50],arr = [50, 40, 30, 20, 10]) == True\n assert candidate(target = [1, 3, 5, 7, 9],arr = [9, 7, 5, 3, 1]) == True\n assert candidate(target = [3, 7, 9],arr = [3, 7, 11]) == False\n assert candidate(target = [5, 3, 1],arr = [1, 3, 5]) == True\n assert candidate(target = [1, 2, 3, 4],arr = [2, 4, 1, 3]) == True\n assert candidate(target = [1, 2, 2, 3],arr = [3, 2, 2, 1]) == True\n assert candidate(target = [4, 4, 4, 4],arr = [4, 4, 4, 4]) == True\n assert candidate(target = [1000, 1, 1000, 1],arr = [1, 1000, 1, 1000]) == True\n assert candidate(target = [10, 9, 8, 7],arr = [7, 8, 9, 10]) == True\n assert candidate(target = [1, 3, 2],arr = [2, 1, 3]) == True\n assert candidate(target = [1, 2, 3],arr = [4, 5, 6]) == False\n assert candidate(target = [7],arr = [7]) == True\n assert candidate(target = [999, 998, 997],arr = [997, 998, 999]) == True\n assert candidate(target = [5, 6, 7],arr = [7, 6, 5]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(target = [10, 20, 30, 40, 50],arr = [50, 40, 30, 20, 10]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == True\n assert candidate(target = [5, 5, 5, 5, 5],arr = [5, 5, 5, 5, 5]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3],arr = [3, 2, 1, 3, 1, 2]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],arr = [6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],arr = [991, 992, 993, 994, 995, 996, 997, 998, 999, 1000]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [500, 400, 300, 200, 100],arr = [100, 200, 300, 400, 500]) == True\n assert candidate(target = [5, 5, 5, 5, 5],arr = [5, 5, 5, 5, 5]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 2, 8, 4, 6, 5, 9, 7, 3, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == True\n assert candidate(target = [5, 10, 15, 20, 25],arr = [25, 20, 15, 10, 5]) == True\n assert candidate(target = [250, 200, 150, 100, 50, 0, -50, -100, -150, -200, -250],arr = [-250, -200, -150, -100, -50, 0, 50, 100, 150, 200, 250]) == True\n assert candidate(target = [1, 2, 2, 3, 3, 4, 4],arr = [4, 4, 3, 3, 2, 2, 1]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 1]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [999, 1000, 999, 1000, 999, 1000, 999, 1000],arr = [1000, 999, 1000, 999, 1000, 999, 1000, 999]) == True\n assert candidate(target = [4, 4, 4, 4, 4, 4, 4],arr = [4, 4, 4, 4, 4, 4, 4]) == True\n assert candidate(target = [5, 1, 4, 3, 2],arr = [2, 3, 1, 5, 4]) == True\n assert candidate(target = [5, 3, 1, 4, 2],arr = [2, 1, 4, 3, 5]) == True\n assert candidate(target = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 1, 2, 3]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 1, 2]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 1, 2, 3, 4, 5]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(target = [3, 3, 3, 3, 3],arr = [3, 3, 3, 3, 3]) == True\n assert candidate(target = [1000, 500, 250, 125],arr = [125, 250, 500, 1000]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [1, 1, 1, 2, 2, 2, 3, 3, 3],arr = [3, 2, 1, 3, 2, 1, 3, 2, 1]) == True\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == True\n assert candidate(target = [100, 200, 100, 200, 100],arr = [200, 100, 200, 100, 200]) == False\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],arr = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],arr = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [5, 5, 5, 5, 5, 5],arr = [5, 5, 5, 5, 5, 5]) == True\n assert candidate(target = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(target = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5],arr = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 1, 2, 3, 4]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 2, 3, 1]) == True\n assert candidate(target = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [100, 200, 300, 400, 500],arr = [500, 400, 300, 200, 100]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(target = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 2, 1]) == True\n assert candidate(target = [1000, 500, 1000, 500, 1000, 500, 1000, 500, 1000, 500],arr = [500, 1000, 500, 1000, 500, 1000, 500, 1000, 500, 1000]) == True\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],arr = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [7, 8, 9, 10, 11],arr = [11, 10, 9, 8, 7]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],arr = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [1, 2, 2, 1, 3, 3, 4, 4, 5, 5],arr = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1, 3, 5, 7, 9],arr = [9, 7, 5, 3, 1]) == True\n assert candidate(target = [234, 234, 234, 234, 234, 234, 234, 234, 234, 234],arr = [234, 234, 234, 234, 234, 234, 234, 234, 234, 234]) == True\n assert candidate(target = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],arr = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(target = [1000, 999, 998, 997, 996],arr = [996, 997, 998, 999, 1000]) == True\n assert candidate(target = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 11]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 10, 9, 8, 7, 6, 5, 4]) == True\n assert candidate(target = [300, 200, 100, 400, 500, 600, 700, 800, 900, 1000],arr = [1000, 900, 800, 700, 600, 500, 400, 100, 200, 300]) == True\n assert candidate(target = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16],arr = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7]) == True\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 4, 3, 2, 1]) == True\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [3, 2, 1, 6, 5, 4, 9, 8, 7, 10]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],arr = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 11]) == False\n assert candidate(target = [10, 20, 30, 40, 50],arr = [50, 10, 30, 20, 40]) == True\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == True\n assert candidate(target = [1000, 999, 998, 997, 996, 995],arr = [995, 996, 997, 998, 999, 1000]) == True\n assert candidate(target = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],arr = [4, 4, 3, 3, 4, 3, 2, 1, 2, 4]) == True\n assert candidate(target = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8]) == False\n assert candidate(target = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16],arr = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == True\n assert candidate(target = [5, 3, 4, 1, 2],arr = [2, 1, 4, 3, 5]) == True\n assert candidate(target = [1, 1, 1, 1, 1],arr = [1, 1, 1, 1, 1]) == True\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [10, 20, 30, 40, 50, 60, 70, 100, 90, 80]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2]) == False\n assert candidate(target = [1, 3, 2, 4, 5],arr = [2, 1, 4, 5, 3]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 3, 2, 1],arr = [1, 2, 3, 4, 3, 2, 1]) == True\n assert candidate(target = [200, 300, 100, 400, 500, 600],arr = [100, 200, 300, 400, 500, 600]) == True\n assert candidate(target = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],arr = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1]) == True\n assert candidate(target = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],arr = [9, 5, 3, 5, 2, 6, 9, 5, 1, 4, 1, 3]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4],arr = [4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3],arr = [3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n"}, "metadata": {"canonical_parameter_names": ["target", "arr"], "leetcode_dataset_entry_point": "Solution().canBeEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canBeEqual(self, target: list[int], arr: list[int]) -> bool:", "container": "Solution", "callable": "canBeEqual", "parameters": [{"name": "target", "type": "list[int]"}, {"name": "arr", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1461, "task_id": "check-if-a-string-contains-all-binary-codes-of-size-k", "difficulty": "Medium", "problem_description": "Given a binary string s and an integer k, return true if every binary code of length k is a substring of s. Otherwise, return false.\n \nExample 1:\n\nInput: s = \"00110110\", k = 2\nOutput: true\nExplanation: The binary codes of length 2 are \"00\", \"01\", \"10\" and \"11\". They can be all found as substrings at indices 0, 1, 3 and 2 respectively.\n\nExample 2:\n\nInput: s = \"0110\", k = 1\nOutput: true\nExplanation: The binary codes of length 1 are \"0\" and \"1\", it is clear that both exist as a substring. \n\nExample 3:\n\nInput: s = \"0110\", k = 2\nOutput: false\nExplanation: The binary code \"00\" is of length 2 and does not exist in the array.\n\n \nConstraints:\n\n1 <= s.length <= 5 * 105\ns[i] is either '0' or '1'.\n1 <= k <= 20\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1010101010\",k = 5) == False\n assert candidate(s = \"1010101010\",k = 3) == False\n assert candidate(s = \"0000000\",k = 3) == False\n assert candidate(s = \"00110110\",k = 2) == True\n assert candidate(s = \"00000000\",k = 4) == False\n assert candidate(s = \"11110000\",k = 3) == False\n assert candidate(s = \"1111111\",k = 2) == False\n assert candidate(s = \"0110\",k = 2) == False\n assert candidate(s = \"0110\",k = 1) == True\n assert candidate(s = \"00001111000011110000111100001111000011110000111100\",k = 8) == False\n assert candidate(s = \"0110011001100110011001100110\",k = 5) == False\n assert candidate(s = \"0100100100100100100100100100\",k = 7) == False\n assert candidate(s = \"10100101101001011010\",k = 4) == False\n assert candidate(s = \"11001100110011001100\",k = 5) == False\n assert candidate(s = \"01101101101101101101\",k = 4) == False\n assert candidate(s = \"01010101010101010101\",k = 7) == False\n assert candidate(s = \"1010101010101010101010101010101010101010\",k = 10) == False\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\",k = 15) == False\n assert candidate(s = \"0001010111001100101010110111\",k = 4) == False\n assert candidate(s = \"1100110011001100110011001100\",k = 8) == False\n assert candidate(s = \"1010010100101001010010100101001010010100101001\",k = 6) == False\n assert candidate(s = \"101010101010101010101010101010101010101010101010\",k = 7) == False\n assert candidate(s = \"10101010101010101010101010101010\",k = 10) == False\n assert candidate(s = \"010101010101010101010101010101010101010101010101\",k = 5) == False\n assert candidate(s = \"01010101010101010101010101010101010101010101010101\",k = 6) == False\n assert candidate(s = \"1001001001001001001001001001001001001001001001\",k = 7) == False\n assert candidate(s = \"01001100111000011001\",k = 3) == False\n assert candidate(s = \"0101010101010101010101010101\",k = 3) == False\n assert candidate(s = \"110011001100\",k = 4) == False\n assert candidate(s = \"1001101001101001101001101001101001101001\",k = 6) == False\n assert candidate(s = \"00010010100101110110\",k = 3) == True\n assert candidate(s = \"0101010101010101010101010101010101010101\",k = 3) == False\n assert candidate(s = \"1100101001110010110011000111001111001111110011111100\",k = 8) == False\n assert candidate(s = \"100110101110100011001010001110001001\",k = 8) == False\n assert candidate(s = \"0000000000000000000000000000000000000000\",k = 10) == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000000000000000000\",k = 15) == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\",k = 10) == False\n assert candidate(s = \"1001001001001001001001001001001001001001\",k = 4) == False\n assert candidate(s = \"0101010101010101\",k = 5) == False\n assert candidate(s = \"00101011110100101010100101010010101010\",k = 5) == False\n assert candidate(s = \"11111111111111111111\",k = 10) == False\n assert candidate(s = \"00101110011011001011\",k = 3) == False\n assert candidate(s = \"11100100110101110100010111010010100011000101110001011101001010001011101000101110100\",k = 5) == False\n assert candidate(s = \"1101010101101010101\",k = 5) == False\n assert candidate(s = \"000000000111111111000000001111111100000000\",k = 8) == False\n assert candidate(s = \"110010011110000110\",k = 3) == False\n assert candidate(s = \"110010110110011010001011\",k = 3) == False\n assert candidate(s = \"1111111111111111111111111111\",k = 5) == False\n assert candidate(s = \"1111111110000000001111111110000000011111\",k = 9) == False\n assert candidate(s = \"0011001100110011001100110011\",k = 6) == False\n assert candidate(s = \"1010001110011101001010101010101010101010101010101010\",k = 5) == False\n assert candidate(s = \"1110010011010111010001011101001010001100010111000101110100101000101110100010111010010100100010001000100010001000100010001000100010001000100010001000100\",k = 10) == False\n assert candidate(s = \"0011001100110011001100110011\",k = 7) == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",k = 20) == False\n assert candidate(s = \"00001111000011110000\",k = 4) == False\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111\",k = 10) == False\n assert candidate(s = \"0110100111000101000110110001101101101001010111011100011111000011011111010011101001110\",k = 19) == False\n assert candidate(s = \"0110100101101001011010010110100101101001\",k = 5) == False\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 9) == False\n assert candidate(s = \"11110000111100001111000011110000\",k = 4) == False\n assert candidate(s = \"1111111111\",k = 2) == False\n assert candidate(s = \"101010101010101010101010101010101010101010101010\",k = 6) == False\n assert candidate(s = \"1010101010101010101010101010\",k = 5) == False\n assert candidate(s = \"00010110111100010111\",k = 4) == False\n assert candidate(s = \"0001110001110001110001110001110001110001\",k = 4) == False\n assert candidate(s = \"11111111111111111111\",k = 19) == False\n assert candidate(s = \"01001001001001001001001001001001\",k = 4) == False\n assert candidate(s = \"11001100110011001100\",k = 6) == False\n assert candidate(s = \"0110110110110110110110110110110110110110\",k = 6) == False\n assert candidate(s = \"11101011110001011010\",k = 4) == False\n assert candidate(s = \"10000011110000111110001101110011100110011111110000001001001011000110010011001011110101\",k = 15) == False\n assert candidate(s = \"01101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 12) == False\n assert candidate(s = \"0001010001010110001010001010101010101010101010101010\",k = 7) == False\n assert candidate(s = \"0001011000110000111110101011011110011110101001101100100100011111100100000011111010101101110001101010110111010010101110100011011101001101110100\",k = 7) == False\n assert candidate(s = \"1111111111111111111111111111111111111111111111\",k = 20) == False\n assert candidate(s = \"10000000001\",k = 5) == False\n assert candidate(s = \"10010010010010010010\",k = 5) == False\n assert candidate(s = \"0100101011100111001010110111110000001111001110\",k = 5) == False\n assert candidate(s = \"1100101011100010011000011111000000111111\",k = 5) == False\n assert candidate(s = \"10101010101010101010101010\",k = 6) == False\n assert candidate(s = \"01010101010101010101\",k = 5) == False\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010\",k = 10) == False\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 12) == False\n assert candidate(s = \"110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100\",k = 15) == False\n assert candidate(s = \"1111111111111111111111111111111111111111\",k = 15) == False\n assert candidate(s = \"1111000011110000\",k = 6) == False\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 8) == False\n assert candidate(s = \"01010101010101010101\",k = 6) == False\n assert candidate(s = \"10010010010010010010010010010010010010010010010010\",k = 7) == False\n assert candidate(s = \"00110011001100110011001100110011001100110011001100\",k = 4) == False\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101\",k = 6) == False\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\",k = 5) == False\n assert candidate(s = \"1110001110001110001110001110001110001110\",k = 7) == False\n assert candidate(s = \"00000000000000000000\",k = 2) == False\n assert candidate(s = \"10101010101010101010\",k = 6) == False\n assert candidate(s = \"00000000000000000000\",k = 5) == False\n assert candidate(s = \"1000100010001000100010001000\",k = 4) == False\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001001001001001001001001\",k = 18) == False\n assert candidate(s = \"0000000000000000000000000000000000000000000000\",k = 20) == False\n assert candidate(s = \"11111111111111111111\",k = 5) == False\n assert candidate(s = \"01100110011001100110011001100110011001100110011001100110\",k = 9) == False\n assert candidate(s = \"1100011001110100101000101101010001101110100110\",k = 7) == False\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().hasAllCodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def hasAllCodes(self, s: str, k: int) -> bool:", "container": "Solution", "callable": "hasAllCodes", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1462, "task_id": "course-schedule-iv", "difficulty": "Medium", "problem_description": "There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course ai first if you want to take course bi.\n\nFor example, the pair [0, 1] indicates that you have to take course 0 before you can take course 1.\n\nPrerequisites can also be indirect. If course a is a prerequisite of course b, and course b is a prerequisite of course c, then course a is a prerequisite of course c.\nYou are also given an array queries where queries[j] = [uj, vj]. For the jth query, you should answer whether course uj is a prerequisite of course vj or not.\nReturn a boolean array answer, where answer[j] is the answer to the jth query.\n \nExample 1:\n\n\nInput: numCourses = 2, prerequisites = [[1,0]], queries = [[0,1],[1,0]]\nOutput: [false,true]\nExplanation: The pair [1, 0] indicates that you have to take course 1 before you can take course 0.\nCourse 0 is not a prerequisite of course 1, but the opposite is true.\n\nExample 2:\n\nInput: numCourses = 2, prerequisites = [], queries = [[1,0],[0,1]]\nOutput: [false,false]\nExplanation: There are no prerequisites, and each course is independent.\n\nExample 3:\n\n\nInput: numCourses = 3, prerequisites = [[1,2],[1,0],[2,0]], queries = [[1,0],[1,2]]\nOutput: [true,true]\n\n \nConstraints:\n\n2 <= numCourses <= 100\n0 <= prerequisites.length <= (numCourses * (numCourses - 1) / 2)\nprerequisites[i].length == 2\n0 <= ai, bi <= numCourses - 1\nai != bi\nAll the pairs [ai, bi] are unique.\nThe prerequisites graph has no cycles.\n1 <= queries.length <= 104\n0 <= ui, vi <= numCourses - 1\nui != vi\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0]]) == [True, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 3], [0, 2]]) == [True, True, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4]],queries = [[0, 3], [1, 4], [2, 3]]) == [True, True, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2]],queries = [[0, 2], [2, 0]]) == [True, False]\n assert candidate(numCourses = 2,prerequisites = [],queries = [[1, 0], [0, 1]]) == [False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [3, 4]]) == [True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [1, 4], [2, 3]]) == [True, True, True, True]\n assert candidate(numCourses = 3,prerequisites = [[1, 2], [1, 0], [2, 0]],queries = [[1, 0], [1, 2]]) == [True, True]\n assert candidate(numCourses = 2,prerequisites = [[1, 0]],queries = [[0, 1], [1, 0]]) == [False, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 2], [2, 0], [3, 0]]) == [True, True, False, False]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 5], [0, 4], [1, 2]]) == [True, True, True, False, False, True, False]\n assert candidate(numCourses = 15,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],queries = [[0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [1, 11], [1, 12], [2, 7], [2, 8]]) == [True, True, True, True, True, True, True, True, False, False, False, False]\n assert candidate(numCourses = 15,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == [True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]],queries = [[0, 7], [1, 5], [2, 4], [3, 6], [5, 7]]) == [True, False, False, False, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4]]) == [True, True, True, True, True, False]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [1, 2]]) == [True, True, False, False, False, True, False]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 8], [4, 9], [5, 10], [5, 11], [6, 10], [6, 11], [7, 11], [8, 11], [9, 11]],queries = [[0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [1, 10], [1, 11], [2, 10], [2, 11], [3, 11], [4, 11]]) == [True, True, True, True, True, False, True, True, True, True, True]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8]],queries = [[0, 7], [0, 8], [1, 7], [1, 8], [2, 7], [2, 8], [0, 3], [0, 4]]) == [True, True, True, True, False, False, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]],queries = [[0, 9], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [5, 7], [6, 8]],queries = [[0, 7], [0, 8], [1, 5], [1, 6], [2, 7], [2, 8], [3, 7], [3, 8], [4, 7], [5, 7], [6, 8]]) == [True, True, False, False, True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 4], [2, 3], [0, 2]]) == [True, True, True, True]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11]],queries = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [0, 5], [1, 2]]) == [True, False, False, True, False, False, True, False]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [3, 6], [4, 6], [5, 6]],queries = [[0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [1, 5], [0, 4], [0, 3]]) == [True, True, True, True, True, True, False, True, True]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]],queries = [[0, 3], [0, 7], [1, 8], [2, 6], [3, 5]]) == [True, True, True, True, False]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8]],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1], [8, 0]]) == [True, True, True, True, True, False, False, False, False]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5], [5, 6]],queries = [[0, 3], [1, 5], [2, 6], [3, 6]]) == [True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4], [2, 5], [4, 6], [5, 6]],queries = [[0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [1, 5]]) == [True, True, True, False, True, True, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 3]]) == [True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [4, 5]],queries = [[0, 5], [1, 4], [2, 4], [3, 5], [1, 3], [2, 3]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],queries = [[0, 3], [0, 4], [0, 5], [1, 2], [1, 5], [2, 3], [2, 4]]) == [True, True, True, False, False, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 5], [3, 6], [4, 6], [5, 6], [6, 7]],queries = [[0, 3], [0, 4], [0, 5], [1, 6], [1, 7], [2, 6], [2, 7]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 8,prerequisites = [[0, 2], [1, 2], [2, 3], [3, 5], [3, 6], [6, 7], [7, 5]],queries = [[0, 5], [0, 7], [1, 5], [1, 7], [2, 5], [2, 7], [3, 7]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9], [8, 9]],queries = [[0, 9], [1, 9], [2, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [2, 7], [2, 6], [2, 5], [3, 6], [3, 5], [4, 6], [4, 5]]) == [True, True, True, True, True, True, True, True, True, True, True, False, True, False, False, True, False, True, True, False, False, False, False]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 10], [8, 11]],queries = [[0, 10], [0, 11], [1, 10], [1, 11], [2, 10], [2, 11], [3, 10], [3, 11], [4, 10], [4, 11]]) == [True, True, True, True, True, True, True, True, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [4, 3]]) == [True, True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 4], [2, 3], [0, 2], [3, 5]]) == [True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 5], [2, 5], [0, 4], [1, 4], [2, 4]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 7], [1, 6], [2, 5], [3, 4]],queries = [[0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],queries = [[0, 3], [0, 4], [0, 5], [0, 6], [1, 5], [1, 6]]) == [True, True, True, True, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 2], [1, 3]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 6]]) == [True, True, True, True, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [4, 5], [5, 6]],queries = [[0, 3], [0, 4], [0, 5], [0, 6], [1, 5], [1, 6], [2, 5], [2, 6], [3, 6], [4, 6]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 11,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [True, True, True, True, True, True, False, False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [0, 4], [1, 4], [2, 5]]) == [True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [0, 2], [2, 4], [3, 4], [4, 5]],queries = [[0, 5], [2, 5], [3, 5], [0, 3], [5, 0]]) == [True, True, True, False, False]\n assert candidate(numCourses = 15,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 10], [10, 0]]) == [True, True, True, True, True, True, True, True, False]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [1, 2], [3, 4], [5, 6], [7, 8]],queries = [[0, 9], [2, 8], [4, 7], [6, 5], [0, 8]]) == [True, True, True, False, True]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 8], [6, 8]],queries = [[0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [1, 5], [1, 6], [1, 7], [1, 8], [2, 3], [2, 4], [2, 7], [2, 8], [3, 8], [4, 8], [5, 6], [6, 7]]) == [True, True, True, True, True, True, False, False, True, True, False, False, False, True, False, True, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 2], [1, 2], [2, 3], [2, 4], [3, 5], [4, 5], [5, 6], [5, 7]],queries = [[0, 5], [0, 6], [0, 7], [1, 5], [1, 6], [1, 7], [2, 6], [2, 7], [3, 6], [3, 7], [4, 6], [4, 7]]) == [True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 5], [2, 5], [0, 4]]) == [True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [0, 8], [1, 7], [2, 6], [3, 5]]) == [True, True, True, False, False]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11]],queries = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [0, 7], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4]]) == [True, True, True, True, True, True, True, True, True, True, True, False]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 6]],queries = [[0, 5], [0, 6], [1, 5], [1, 6], [2, 5], [2, 6], [3, 6]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [0, 8], [1, 6], [3, 9], [5, 4]]) == [True, True, True, True, False]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 3], [1, 4], [2, 5]],queries = [[0, 6], [1, 5], [2, 4], [0, 5], [3, 4], [0, 4], [4, 6], [1, 3]]) == [True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 15,prerequisites = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14]],queries = [[0, 13], [0, 14], [1, 13], [1, 14], [2, 13], [2, 14], [3, 13], [3, 14], [4, 13], [4, 14]]) == [True, True, True, True, False, False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 4], [1, 2], [1, 3], [2, 4], [3, 4]],queries = [[0, 2], [0, 3], [1, 4], [2, 3], [3, 2]]) == [True, True, True, False, False]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9]],queries = [[0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 9], [2, 9], [3, 5], [3, 6], [4, 7]]) == [True, True, True, True, True, False, False, False, False, False]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11]],queries = [[0, 11], [1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11]]) == [True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 9], [6, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [True, True, False, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [6, 7], [2, 6]],queries = [[0, 7], [1, 6], [2, 5], [3, 4]]) == [True, True, False, False]\n assert candidate(numCourses = 15,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 8], [4, 9], [5, 10], [5, 11], [6, 11], [6, 12], [7, 13], [8, 13], [9, 13], [10, 14], [11, 14], [12, 14]],queries = [[0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14]]) == [True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7], [2, 6], [3, 5], [0, 7], [1, 6], [2, 5], [3, 4]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 4], [5, 6]],queries = [[0, 4], [0, 5], [0, 6], [1, 3], [1, 5], [1, 6], [2, 5], [2, 6], [3, 5], [4, 6]]) == [True, True, True, True, False, False, True, True, False, False]\n assert candidate(numCourses = 10,prerequisites = [[0, 2], [1, 2], [2, 3], [2, 4], [3, 5], [4, 5], [5, 6], [5, 7], [6, 8], [7, 9]],queries = [[0, 5], [1, 6], [2, 8], [3, 9], [4, 7], [5, 8]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],queries = [[0, 3], [0, 5], [1, 6], [3, 5], [4, 6]]) == [True, True, False, False, False]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7], [2, 6], [3, 5], [0, 7], [1, 6], [2, 5], [3, 4]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9]]) == [True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]],queries = [[0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 2], [1, 0], [2, 0]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [3, 0], [1, 2]]) == [True, False, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [1, 2], [3, 4]]) == [True, True, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [0, 3], [3, 4], [1, 4]],queries = [[0, 2], [2, 0], [0, 4], [4, 0]]) == [True, False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [5, 0], [1, 4], [4, 1]]) == [True, False, True, False]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [False, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [2, 0]],queries = [[0, 1], [2, 1], [1, 2]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [0, 2], [1, 3], [2, 3]]) == [False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[1, 0], [0, 2], [2, 3], [3, 4]],queries = [[1, 4], [0, 4], [0, 3], [0, 2]]) == [True, True, True, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [0, 2]],queries = [[0, 1], [1, 2], [0, 2], [3, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [False, False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5]],queries = [[1, 5], [1, 4], [2, 5], [3, 5], [4, 5]]) == [True, True, True, True, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [2, 3]],queries = [[0, 3], [1, 3], [0, 2]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [0, 2], [0, 3], [1, 3], [2, 3]]) == [False, False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 2]]) == [True, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [1, 3], [3, 1]]) == [True, False, True, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 3], [2, 3], [3, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 4], [2, 4], [3, 5], [4, 5]],queries = [[1, 5], [2, 5], [3, 4]]) == [True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [1, 3]]) == [True, False, True]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [5, 3]],queries = [[5, 0], [5, 1], [4, 2], [4, 3], [2, 1]]) == [True, True, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[0, 1]],queries = [[0, 1], [1, 0], [1, 2]]) == [True, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3]],queries = [[0, 3], [3, 0], [1, 2], [2, 1]]) == [True, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [1, 2]]) == [True, True, False]\n assert candidate(numCourses = 4,prerequisites = [],queries = [[0, 1], [1, 2], [2, 3], [3, 0]]) == [False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [2, 3]],queries = [[0, 2], [1, 3], [0, 3], [2, 1]]) == [False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [0, 2], [1, 3], [2, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [5, 3]],queries = [[0, 1], [0, 3], [0, 5], [1, 2], [2, 3], [3, 4]]) == [False, False, False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1]],queries = [[0, 3], [1, 3], [2, 3]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0]],queries = [[0, 1], [1, 0], [1, 2], [0, 2]]) == [False, True, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [1, 3], [0, 3]]) == [False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [2, 3], [3, 4], [4, 5]],queries = [[1, 5], [2, 4], [3, 5], [0, 5]]) == [True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 1], [1, 0], [2, 0]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [],queries = [[0, 1], [1, 0], [2, 3], [3, 2]]) == [False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [0, 2]],queries = [[0, 1], [1, 2], [0, 2], [2, 0], [1, 0], [2, 1]]) == [True, True, True, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[1, 2], [2, 3], [3, 4], [1, 3], [1, 4]],queries = [[0, 1], [1, 0], [2, 4]]) == [False, False, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [2, 3]],queries = [[0, 1], [1, 2], [2, 3], [3, 0]]) == [True, False, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 2], [0, 2]]) == [False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4]],queries = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == [False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 3], [1, 3], [2, 3]]) == [False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5]],queries = [[0, 5], [1, 5], [2, 5]]) == [True, True, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 4], [2, 4], [3, 4]],queries = [[0, 4], [1, 4], [2, 4], [3, 4], [4, 0]]) == [True, True, True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [1, 3], [3, 0]]) == [True, False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [5, 0], [2, 3], [3, 2]]) == [True, False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 2], [5, 3], [5, 4]],queries = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == [False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 1], [0, 4], [1, 3], [2, 4], [4, 0]]) == [True, True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2]],queries = [[0, 5], [1, 4], [2, 5], [0, 3], [3, 2]]) == [False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [1, 4], [0, 3], [1, 3], [0, 2], [1, 2], [2, 4], [0, 1], [2, 3], [4, 0]]) == [True, True, True, True, True, True, True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[0, 1]],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [True, False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2]],queries = [[0, 1], [0, 2], [1, 2], [2, 3], [3, 4], [4, 5]]) == [False, False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [2, 3]]) == [True, False, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [3, 0], [1, 2], [0, 2]]) == [True, False, True, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3]],queries = [[0, 3], [1, 3], [2, 3], [3, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [2, 5]]) == [True, True]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[1, 0], [0, 1], [2, 1]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0]],queries = [[0, 1], [2, 0], [1, 2]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [2, 0]],queries = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 0]]) == [False, True, False, False, True]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [False, True, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [0, 3], [3, 2]],queries = [[0, 2], [1, 3], [2, 0], [0, 1]]) == [True, False, False, True]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [1, 4], [1, 5], [2, 3], [3, 4], [3, 5]],queries = [[1, 3], [1, 4], [2, 5], [3, 1]]) == [True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [1, 3], [2, 4], [3, 5]],queries = [[1, 4], [2, 5], [3, 4], [0, 5]]) == [True, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 2], [2, 0]]) == [False, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [3, 4]],queries = [[0, 2], [3, 4]]) == [True, True]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 0], [1, 2], [2, 1]]) == [False, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2], [0, 2]],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [False, False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 2], [5, 3]],queries = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == [False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [1, 3], [2, 4]]) == [True, False, True, True]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2], [4, 3], [5, 4]],queries = [[0, 5], [1, 5], [2, 5], [3, 5]]) == [False, False, False, False]\n assert candidate(numCourses = 7,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 2], [5, 3], [6, 4], [6, 5]],queries = [[0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6]]) == [False, False, False, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0]],queries = [[2, 0], [2, 1]]) == [False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 0], [0, 2]]) == [False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [2, 3], [1, 3], [2, 4], [3, 5]],queries = [[0, 3], [2, 5], [0, 5], [1, 2]]) == [True, True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4]],queries = [[0, 4], [1, 4], [2, 4]]) == [True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],queries = [[0, 3], [0, 4], [1, 5], [2, 3]]) == [True, True, False, False]\n assert candidate(numCourses = 5,prerequisites = [[1, 2], [2, 3], [3, 4], [4, 0]],queries = [[1, 4], [4, 1], [0, 3], [3, 2]]) == [True, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2], [2, 0]],queries = [[1, 0], [2, 0], [0, 1]]) == [True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 1], [0, 2], [1, 0]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0]],queries = [[0, 1], [1, 0]]) == [False, True]\n assert candidate(numCourses = 3,prerequisites = [[0, 1], [0, 2]],queries = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 0], [0, 2]]) == [True, False, False, False, False, True]\n assert candidate(numCourses = 4,prerequisites = [],queries = [[0, 1], [1, 0], [1, 2], [2, 1]]) == [False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [1, 3], [0, 3], [3, 0]]) == [False, False, False, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 4], [2, 3], [0, 2], [3, 1]]) == [True, True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 2], [1, 0], [2, 1]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3]],queries = [[1, 3], [2, 3], [3, 0], [3, 1]]) == [True, True, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 0]]) == [False, False, False, False, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 4], [2, 4], [3, 4]],queries = [[0, 4], [1, 2], [2, 0], [3, 1]]) == [True, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [0, 2], [1, 2], [2, 3], [3, 0]]) == [False, False, False, False, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4]],queries = [[0, 3], [0, 4]]) == [True, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4]],queries = [[0, 4], [0, 3], [1, 4], [2, 3], [3, 4]]) == [True, True, True, False, False]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 2], [2, 0]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2], [1, 0]],queries = [[0, 1], [1, 0], [2, 0]]) == [False, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [2, 1]],queries = [[0, 1], [1, 2], [0, 2]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 2]]) == [False, True]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [1, 3], [2, 3], [3, 0]]) == [False, False, False, True]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 0]],queries = [[0, 1], [0, 2], [0, 3], [1, 2]]) == [False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [1, 4], [2, 0]]) == [True, True, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [1, 3], [2, 4], [3, 5]],queries = [[1, 4], [4, 1], [1, 5], [5, 1]]) == [True, False, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 0], [1, 2]]) == [False, True, True]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 0], [1, 2]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 1], [1, 3], [0, 3]]) == [True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [2, 3], [4, 5]],queries = [[0, 1], [2, 3], [4, 5], [3, 4]]) == [True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 0], [2, 1]]) == [False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 2], [5, 3], [5, 4]],queries = [[0, 5], [1, 5], [2, 5], [3, 5]]) == [False, False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2]],queries = [[3, 0], [5, 0], [4, 2], [1, 2]]) == [True, True, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [1, 4], [2, 4]],queries = [[0, 4], [1, 4], [2, 3], [3, 4]]) == [True, True, True, False]\n assert candidate(numCourses = 4,prerequisites = [[2, 0], [1, 0], [3, 1], [3, 2]],queries = [[0, 1], [2, 0], [0, 3], [3, 0], [2, 3]]) == [False, True, False, True, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 3], [0, 2], [3, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 1], [1, 3], [0, 4], [2, 3], [4, 2]]) == [True, True, True, True, False]\n"}, "metadata": {"canonical_parameter_names": ["numCourses", "prerequisites", "queries"], "leetcode_dataset_entry_point": "Solution().checkIfPrerequisite", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def checkIfPrerequisite(self, numCourses: int, prerequisites: list[list[int]], queries: list[list[int]]) -> list[bool]:", "container": "Solution", "callable": "checkIfPrerequisite", "parameters": [{"name": "numCourses", "type": "int"}, {"name": "prerequisites", "type": "list[list[int]]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1463, "task_id": "cherry-pickup-ii", "difficulty": "Hard", "problem_description": "You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell.\nYou have two robots that can collect cherries for you:\n\nRobot #1 is located at the top-left corner (0, 0), and\nRobot #2 is located at the top-right corner (0, cols - 1).\n\nReturn the maximum number of cherries collection using both robots by following the rules below:\n\nFrom a cell (i, j), robots can move to cell (i + 1, j - 1), (i + 1, j), or (i + 1, j + 1).\nWhen any robot passes through a cell, It picks up all cherries, and the cell becomes an empty cell.\nWhen both robots stay in the same cell, only one takes the cherries.\nBoth robots cannot move outside of the grid at any moment.\nBoth robots should reach the bottom row in grid.\n\n \nExample 1:\n\n\nInput: grid = [[3,1,1],[2,5,1],[1,5,5],[2,1,1]]\nOutput: 24\nExplanation: Path of robot #1 and #2 are described in color green and blue respectively.\nCherries taken by Robot #1, (3 + 2 + 5 + 2) = 12.\nCherries taken by Robot #2, (1 + 5 + 5 + 1) = 12.\nTotal of cherries: 12 + 12 = 24.\n\nExample 2:\n\n\nInput: grid = [[1,0,0,0,0,0,1],[2,0,0,0,0,3,0],[2,0,9,0,0,0,0],[0,3,0,5,4,0,0],[1,0,2,3,0,0,6]]\nOutput: 28\nExplanation: Path of robot #1 and #2 are described in color green and blue respectively.\nCherries taken by Robot #1, (1 + 9 + 5 + 2) = 17.\nCherries taken by Robot #2, (1 + 3 + 4 + 3) = 11.\nTotal of cherries: 17 + 11 = 28.\n\n \nConstraints:\n\nrows == grid.length\ncols == grid[i].length\n2 <= rows, cols <= 70\n0 <= grid[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2, 3], [0, 1, 0], [3, 0, 1], [1, 2, 3]]) == 14\n assert candidate(grid = [[5, 0, 0, 5], [0, 4, 4, 0], [0, 4, 4, 0], [5, 0, 0, 5]]) == 36\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 1, 4, 3, 2], [3, 2, 1, 4, 3]]) == 35\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]]) == 16\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[10, 0, 0, 10], [0, 0, 0, 0], [0, 10, 10, 0], [10, 0, 0, 10]]) == 60\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(grid = [[3, 1, 1], [2, 5, 1], [1, 5, 5], [2, 1, 1]]) == 24\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [2, 0, 0, 0, 0, 3, 0], [2, 0, 9, 0, 0, 0, 0], [0, 3, 0, 5, 4, 0, 0], [1, 0, 2, 3, 0, 0, 6]]) == 28\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 32\n assert candidate(grid = [[1, 1], [1, 1]]) == 4\n assert candidate(grid = [[10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]]) == 120\n assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0], [1, 0, 0, 1, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 16\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 100, 0, 0, 100, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 100, 0, 0, 100, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 400\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 159\n assert candidate(grid = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60], [50, 60, 70]]) == 440\n assert candidate(grid = [[5, 5, 5], [5, 0, 5], [5, 5, 5]]) == 30\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == 18\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0]]) == 13\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 10, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == 26\n assert candidate(grid = [[5, 3, 2, 1, 4, 0], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11], [0, 2, 4, 6, 8, 10]]) == 55\n assert candidate(grid = [[100, 0, 0, 0, 0, 0, 100], [0, 90, 0, 0, 0, 90, 0], [0, 0, 80, 0, 80, 0, 0], [0, 0, 0, 70, 0, 0, 0], [0, 0, 0, 0, 60, 0, 0], [0, 0, 0, 0, 0, 50, 0], [0, 0, 0, 0, 0, 0, 40]]) == 760\n assert candidate(grid = [[2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2]]) == 23\n assert candidate(grid = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 4, 6, 4, 2], [3, 5, 7, 5, 3]]) == 43\n assert candidate(grid = [[3, 0, 0, 2, 1, 0, 1], [0, 4, 3, 0, 0, 0, 0], [2, 1, 5, 0, 1, 0, 1], [0, 0, 0, 5, 0, 0, 0], [1, 2, 3, 0, 1, 2, 1], [0, 0, 0, 0, 0, 0, 5], [0, 3, 4, 3, 0, 0, 2]]) == 35\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 8\n assert candidate(grid = [[10, 15, 10], [15, 0, 15], [10, 15, 10], [15, 0, 15]]) == 105\n assert candidate(grid = [[10, 0, 0, 0, 10], [0, 10, 0, 10, 0], [0, 0, 10, 0, 0], [0, 10, 0, 10, 0], [10, 0, 0, 0, 10]]) == 90\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 8, 6, 4, 2], [3, 6, 9, 12, 15, 12, 9, 6, 3], [4, 8, 12, 16, 20, 16, 12, 8, 4], [5, 10, 15, 20, 25, 20, 15, 10, 5]]) == 154\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[50, 100, 50], [100, 50, 100], [50, 100, 50], [100, 50, 100]]) == 650\n assert candidate(grid = [[0, 0, 0, 0], [0, 100, 100, 0], [0, 100, 100, 0], [0, 0, 0, 0]]) == 400\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15], [15, 13, 11, 9, 7, 5, 3, 1], [1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15], [15, 13, 11, 9, 7, 5, 3, 1]]) == 111\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0]]) == 7\n assert candidate(grid = [[0, 0, 0, 0, 50], [0, 0, 50, 0, 0], [50, 0, 0, 0, 0], [0, 50, 0, 50, 0]]) == 200\n assert candidate(grid = [[3, 1, 2, 1, 3], [2, 1, 3, 1, 2], [1, 2, 1, 2, 1], [3, 1, 2, 1, 3], [2, 1, 3, 1, 2]]) == 24\n assert candidate(grid = [[10, 20, 30, 40, 50, 60], [60, 50, 40, 30, 20, 10], [10, 30, 50, 70, 90, 110], [110, 90, 70, 50, 30, 10]]) == 430\n assert candidate(grid = [[100, 0, 0, 0, 100], [0, 50, 50, 0, 0], [0, 0, 0, 50, 50], [50, 50, 0, 0, 0], [0, 0, 100, 0, 0]]) == 450\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == 14\n assert candidate(grid = [[3, 0, 0, 0, 0, 0, 0, 4], [0, 2, 0, 0, 0, 0, 5, 0], [0, 0, 1, 0, 0, 6, 0, 0], [0, 0, 0, 7, 8, 0, 0, 0], [0, 0, 9, 0, 0, 10, 0, 0], [0, 11, 0, 0, 0, 0, 12, 0], [13, 0, 0, 0, 0, 0, 0, 14]]) == 105\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0], [0, 0, 0, 10, 0, 10, 0, 10, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0]]) == 21\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 20\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [100, 100, 100, 100, 100, 100, 100, 100, 100]]) == 200\n assert candidate(grid = [[10, 0, 0, 0, 0, 0, 10], [0, 1, 0, 1, 0, 1, 0], [1, 0, 9, 0, 9, 0, 1], [0, 3, 0, 5, 0, 3, 0], [1, 0, 2, 3, 0, 2, 1]]) == 53\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 67\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 2, 2, 2, 2, 1, 0], [0, 1, 2, 3, 3, 3, 2, 1, 0], [0, 1, 2, 3, 4, 3, 2, 1, 0], [0, 1, 2, 3, 3, 3, 2, 1, 0], [0, 1, 2, 2, 2, 2, 2, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 31\n assert candidate(grid = [[5, 0, 0, 0, 0, 0, 0, 0, 5], [0, 5, 0, 0, 0, 0, 0, 5, 0], [0, 0, 5, 0, 0, 0, 5, 0, 0], [0, 0, 0, 5, 0, 5, 0, 0, 0], [0, 0, 0, 0, 10, 0, 0, 0, 0], [0, 0, 0, 5, 0, 5, 0, 0, 0], [0, 0, 5, 0, 0, 0, 5, 0, 0], [0, 5, 0, 0, 0, 0, 0, 5, 0], [5, 0, 0, 0, 0, 0, 0, 0, 5]]) == 90\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 18\n assert candidate(grid = [[3, 0, 0, 0, 0, 0, 3], [0, 2, 0, 0, 0, 2, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 5, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 2, 0, 0, 0, 2, 0], [3, 0, 0, 0, 0, 0, 3]]) == 29\n assert candidate(grid = [[30, 10, 0, 10, 30], [10, 20, 0, 20, 10], [0, 0, 30, 0, 0], [10, 20, 0, 20, 10], [30, 10, 0, 10, 30]]) == 230\n assert candidate(grid = [[10, 0, 0, 10, 0], [0, 10, 0, 10, 0], [0, 0, 10, 0, 0], [0, 10, 0, 10, 0], [10, 0, 0, 10, 0]]) == 80\n assert candidate(grid = [[10, 0, 0, 0, 0, 0, 10], [0, 20, 0, 0, 0, 20, 0], [0, 0, 30, 0, 30, 0, 0], [0, 0, 0, 40, 0, 0, 0], [0, 0, 30, 0, 30, 0, 0], [0, 20, 0, 0, 0, 20, 0], [10, 0, 0, 0, 0, 0, 10]]) == 280\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 30\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9]]) == 52\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == 14\n assert candidate(grid = [[10, 0, 0, 0, 0, 0, 10], [0, 10, 0, 0, 0, 10, 0], [0, 0, 10, 0, 10, 0, 0], [0, 0, 0, 20, 0, 0, 0], [10, 0, 0, 0, 0, 0, 10]]) == 90\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 26\n assert candidate(grid = [[10, 0, 0, 10], [0, 20, 20, 0], [0, 20, 20, 0], [10, 0, 0, 10]]) == 120\n assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 6\n assert candidate(grid = [[10, 0, 0, 0, 0, 0, 0, 0, 0, 10], [0, 10, 0, 0, 0, 0, 0, 0, 10, 0], [0, 0, 10, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 10, 0, 0, 10, 0, 0, 0], [0, 0, 0, 0, 10, 10, 0, 0, 0, 0], [0, 0, 0, 10, 0, 0, 10, 0, 0, 0], [0, 0, 10, 0, 0, 0, 0, 10, 0, 0], [0, 10, 0, 0, 0, 0, 0, 0, 10, 0], [10, 0, 0, 0, 0, 0, 0, 0, 0, 10]]) == 180\n assert candidate(grid = [[5, 1, 1, 1], [1, 1, 1, 5], [1, 1, 1, 1], [1, 1, 1, 1]]) == 16\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 2, 0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 3, 0, 0, 3, 0, 0, 0], [0, 0, 0, 0, 4, 4, 0, 0, 0, 0], [0, 0, 0, 0, 4, 4, 0, 0, 0, 0], [0, 0, 0, 3, 0, 0, 3, 0, 0, 0], [0, 0, 2, 0, 0, 0, 0, 2, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 40\n assert candidate(grid = [[5, 0, 0, 5, 0, 0, 5], [0, 5, 5, 0, 5, 5, 0], [5, 0, 5, 0, 5, 0, 5], [0, 5, 0, 5, 0, 5, 0], [5, 5, 5, 5, 5, 5, 5], [0, 0, 0, 0, 0, 0, 0]]) == 50\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 45\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 5, 0, 0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]]) == 22\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 4, 4, 4, 4, 4, 4, 4, 5], [5, 4, 3, 3, 3, 3, 3, 4, 5], [5, 4, 3, 2, 2, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4, 5], [5, 4, 3, 2, 2, 2, 3, 4, 5], [5, 4, 3, 3, 3, 3, 3, 4, 5], [5, 4, 4, 4, 4, 4, 4, 4, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 90\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().cherryPickup", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def cherryPickup(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "cherryPickup", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1464, "task_id": "maximum-product-of-two-elements-in-an-array", "difficulty": "Easy", "problem_description": "Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1).\n \nExample 1:\n\nInput: nums = [3,4,5,2]\nOutput: 12 \nExplanation: If you choose the indices i=1 and j=2 (indexed from 0), you will get the maximum value, that is, (nums[1]-1)*(nums[2]-1) = (4-1)*(5-1) = 3*4 = 12. \n\nExample 2:\n\nInput: nums = [1,5,4,5]\nOutput: 16\nExplanation: Choosing the indices i=1 and j=3 (indexed from 0), you will get the maximum value of (5-1)*(5-1) = 16.\n\nExample 3:\n\nInput: nums = [3,7]\nOutput: 12\n\n \nConstraints:\n\n2 <= nums.length <= 500\n1 <= nums[i] <= 10^3\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10]) == 81\n assert candidate(nums = [2, 3, 5, 7, 11, 13]) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 72\n assert candidate(nums = [1, 1000, 2, 999, 3, 998]) == 997002\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 72\n assert candidate(nums = [10, 20, 30, 40, 50]) == 1911\n assert candidate(nums = [5, 6, 7, 8, 9]) == 56\n assert candidate(nums = [5, 5, 5, 5]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5]) == 12\n assert candidate(nums = [500, 500, 500, 500, 500]) == 249001\n assert candidate(nums = [999, 1000]) == 997002\n assert candidate(nums = [1, 5, 4, 5]) == 16\n assert candidate(nums = [10, 2, 3, 8]) == 63\n assert candidate(nums = [1, 1000, 1, 1000]) == 998001\n assert candidate(nums = [2, 3, 100, 101, 99]) == 9900\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 616\n assert candidate(nums = [100, 100]) == 9801\n assert candidate(nums = [500, 500, 1, 1]) == 249001\n assert candidate(nums = [3, 7]) == 12\n assert candidate(nums = [3, 4, 5, 2]) == 12\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496]) == 249001\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127]) == 14112\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 898101\n assert candidate(nums = [500, 500, 500, 500, 499, 499, 499, 499, 498, 498]) == 249001\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420]) == 157963\n assert candidate(nums = [500, 250, 125, 625, 312, 156, 78, 39, 19, 9, 4, 2]) == 311376\n assert candidate(nums = [500, 400, 300, 200, 100, 50, 40, 30, 20, 10]) == 199101\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 1, 1, 1, 1, 1]) == 199101\n assert candidate(nums = [333, 666, 999, 334, 667, 998, 335, 668, 997]) == 995006\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8]) == 997002\n assert candidate(nums = [1000, 999, 998, 997, 996]) == 997002\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 1000]) == 997002\n assert candidate(nums = [300, 301, 302, 303, 304, 305, 306, 307, 308, 309]) == 94556\n assert candidate(nums = [1000, 1000, 999, 999, 998, 998, 997, 997]) == 998001\n assert candidate(nums = [300, 300, 300, 300, 300, 300, 299, 299, 299, 299]) == 89401\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 754\n assert candidate(nums = [500, 500, 450, 450, 400, 400, 350, 350, 300, 300]) == 249001\n assert candidate(nums = [250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265]) == 69432\n assert candidate(nums = [1000, 1000, 999, 999, 998, 998, 997, 997, 996, 996]) == 998001\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000, 1000, 1000, 1000, 1000]) == 998001\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 1932\n assert candidate(nums = [500, 450, 400, 350, 300, 250, 200, 150, 100, 50]) == 224051\n assert candidate(nums = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491]) == 248502\n assert candidate(nums = [1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 17982\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 4620\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 6\n assert candidate(nums = [300, 300, 300, 300, 300, 300, 300, 300, 300, 1]) == 89401\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 9702\n assert candidate(nums = [23, 45, 67, 89, 12, 34, 56, 78]) == 6776\n assert candidate(nums = [100, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 99]) == 9702\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 249001\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 997002\n assert candidate(nums = [999, 999, 999, 999, 999, 999, 999, 999, 999, 1000]) == 997002\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 8811\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 995006\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000]) == 0\n assert candidate(nums = [1, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 498501\n assert candidate(nums = [500, 500, 500, 1, 2, 3, 4, 5]) == 249001\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 288\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 0\n assert candidate(nums = [999, 1, 999, 2, 999, 3, 999, 4, 999, 5]) == 996004\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 182\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 72\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 616\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 37611\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509]) == 257556\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 323\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996]) == 997002\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 12971\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985]) == 997002\n assert candidate(nums = [500, 501, 499, 502, 498, 503, 497, 504, 496, 505]) == 253512\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 11556\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 342\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 100]) == 4851\n assert candidate(nums = [1000, 999, 998, 1, 2, 3]) == 997002\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == 995006\n assert candidate(nums = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 998001\n assert candidate(nums = [1, 10, 100, 1000, 100, 10, 1]) == 98901\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 1368\n assert candidate(nums = [333, 666, 999, 222, 555, 888, 111, 444, 777, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 885226\n assert candidate(nums = [500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4]) == 199101\n assert candidate(nums = [3, 3, 3, 3, 3, 1000, 1000, 1000, 1000, 1000]) == 998001\n assert candidate(nums = [1, 2, 3, 1000, 4, 5, 6, 7, 8, 9]) == 7992\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 8811\n assert candidate(nums = [999, 999, 998, 998, 997, 997, 996, 996, 995, 995]) == 996004\n assert candidate(nums = [999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 1000]) == 997002\n assert candidate(nums = [999, 1000, 1, 2, 3, 4, 5, 6, 7, 8]) == 997002\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 81\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1000]) == 8991\n assert candidate(nums = [250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269]) == 71556\n assert candidate(nums = [1, 2, 3, 4, 5, 1000, 1001, 1002, 1003, 1004]) == 1005006\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 20711\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 25\n assert candidate(nums = [1000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 7992\n assert candidate(nums = [999, 1000, 998, 1000, 997]) == 998001\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxProduct(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maxProduct", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1465, "task_id": "maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts", "difficulty": "Medium", "problem_description": "You are given a rectangular cake of size h x w and two arrays of integers horizontalCuts and verticalCuts where:\n\nhorizontalCuts[i] is the distance from the top of the rectangular cake to the ith horizontal cut and similarly, and\nverticalCuts[j] is the distance from the left of the rectangular cake to the jth vertical cut.\n\nReturn the maximum area of a piece of cake after you cut at each horizontal and vertical position provided in the arrays horizontalCuts and verticalCuts. Since the answer can be a large number, return this modulo 109 + 7.\n \nExample 1:\n\n\nInput: h = 5, w = 4, horizontalCuts = [1,2,4], verticalCuts = [1,3]\nOutput: 4 \nExplanation: The figure above represents the given rectangular cake. Red lines are the horizontal and vertical cuts. After you cut the cake, the green piece of cake has the maximum area.\n\nExample 2:\n\n\nInput: h = 5, w = 4, horizontalCuts = [3,1], verticalCuts = [1]\nOutput: 6\nExplanation: The figure above represents the given rectangular cake. Red lines are the horizontal and vertical cuts. After you cut the cake, the green and yellow pieces of cake have the maximum area.\n\nExample 3:\n\nInput: h = 5, w = 4, horizontalCuts = [3], verticalCuts = [3]\nOutput: 9\n\n \nConstraints:\n\n2 <= h, w <= 109\n1 <= horizontalCuts.length <= min(h - 1, 105)\n1 <= verticalCuts.length <= min(w - 1, 105)\n1 <= horizontalCuts[i] < h\n1 <= verticalCuts[i] < w\nAll the elements in horizontalCuts are distinct.\nAll the elements in verticalCuts are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(h = 10,w = 10,horizontalCuts = [2, 5, 7],verticalCuts = [2, 5, 7]) == 9\n assert candidate(h = 5,w = 4,horizontalCuts = [3, 1],verticalCuts = [1]) == 6\n assert candidate(h = 5,w = 4,horizontalCuts = [1, 2, 4],verticalCuts = [1, 3]) == 4\n assert candidate(h = 10,w = 10,horizontalCuts = [2, 5, 7],verticalCuts = [3, 6, 9]) == 9\n assert candidate(h = 10,w = 10,horizontalCuts = [2, 4, 6, 8],verticalCuts = [2, 4, 6, 8]) == 4\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 500000000],verticalCuts = [1, 500000000]) == 250000014\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 999999999],verticalCuts = [1, 999999999]) == 81\n assert candidate(h = 5,w = 4,horizontalCuts = [3],verticalCuts = [3]) == 9\n assert candidate(h = 7,w = 7,horizontalCuts = [1, 2, 3, 4, 5, 6],verticalCuts = [1, 2, 3, 4, 5, 6]) == 1\n assert candidate(h = 6,w = 4,horizontalCuts = [1, 2, 5],verticalCuts = [1, 3]) == 6\n assert candidate(h = 10,w = 10,horizontalCuts = [2, 5, 7],verticalCuts = [3, 6, 8]) == 9\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [500000000],verticalCuts = [500000000]) == 250000014\n assert candidate(h = 6,w = 6,horizontalCuts = [1, 2, 3, 4, 5],verticalCuts = [1, 2, 3, 4, 5]) == 1\n assert candidate(h = 600,w = 800,horizontalCuts = [100, 200, 300, 400, 500],verticalCuts = [120, 240, 360, 480, 600, 720]) == 12000\n assert candidate(h = 100,w = 200,horizontalCuts = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 100\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 2, 999999998, 999999999],verticalCuts = [1, 2, 999999998, 999999999]) == 121\n assert candidate(h = 50000,w = 100000,horizontalCuts = [25000, 37500],verticalCuts = [50000]) == 249999993\n assert candidate(h = 200,w = 150,horizontalCuts = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190],verticalCuts = [15, 45, 75, 105, 135]) == 600\n assert candidate(h = 7,w = 13,horizontalCuts = [1, 3, 5],verticalCuts = [2, 4, 6, 8, 10, 12]) == 4\n assert candidate(h = 100,w = 200,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 100\n assert candidate(h = 999999999,w = 999999999,horizontalCuts = [500000000, 250000000, 750000000, 100000000],verticalCuts = [500000000, 250000000, 750000000, 100000000]) == 562500007\n assert candidate(h = 100,w = 50,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 50\n assert candidate(h = 500,w = 400,horizontalCuts = [100, 200, 300],verticalCuts = [80, 160, 240, 320]) == 16000\n assert candidate(h = 100,w = 100,horizontalCuts = [10, 30, 50, 70, 90],verticalCuts = [20, 40, 60, 80]) == 400\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [100, 200, 300, 400, 500],verticalCuts = [150, 250, 350, 450, 550]) == 282399\n assert candidate(h = 1000,w = 1000,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 828100\n assert candidate(h = 1000,w = 1000,horizontalCuts = [250, 500, 750],verticalCuts = [250, 500, 750]) == 62500\n assert candidate(h = 1000,w = 1000,horizontalCuts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95],verticalCuts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]) == 819025\n assert candidate(h = 8,w = 12,horizontalCuts = [2, 3, 5, 7],verticalCuts = [2, 4, 6, 8, 10]) == 4\n assert candidate(h = 8,w = 8,horizontalCuts = [2, 4, 6],verticalCuts = [2, 4, 6]) == 4\n assert candidate(h = 1000,w = 1000,horizontalCuts = [1, 2, 3, 997, 998, 999],verticalCuts = [1, 2, 3, 997, 998, 999]) == 988036\n assert candidate(h = 500,w = 500,horizontalCuts = [25, 125, 225, 325, 425],verticalCuts = [25, 125, 225, 325, 425]) == 10000\n assert candidate(h = 50,w = 60,horizontalCuts = [10, 20, 30, 40],verticalCuts = [12, 24, 36, 48]) == 120\n assert candidate(h = 1000,w = 500,horizontalCuts = [200, 400, 600, 800],verticalCuts = [100, 200, 300, 400]) == 20000\n assert candidate(h = 50000,w = 30000,horizontalCuts = [10000, 20000, 30000, 40000],verticalCuts = [5000, 10000, 15000, 25000, 28000]) == 100000000\n assert candidate(h = 1000000,w = 1000000,horizontalCuts = [1, 999999],verticalCuts = [1, 999999]) == 995993011\n assert candidate(h = 200,w = 300,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],verticalCuts = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285]) == 150\n assert candidate(h = 100,w = 100,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 100\n assert candidate(h = 500,w = 300,horizontalCuts = [50, 100, 150, 200, 250, 450],verticalCuts = [30, 60, 90, 120, 150, 180, 210, 240, 270]) == 6000\n assert candidate(h = 1000,w = 1000,horizontalCuts = [100, 200, 300, 400, 500, 600, 700, 800, 900],verticalCuts = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 10000\n assert candidate(h = 50,w = 50,horizontalCuts = [25],verticalCuts = [25]) == 625\n assert candidate(h = 30,w = 40,horizontalCuts = [5, 15, 25],verticalCuts = [8, 16, 24, 32]) == 80\n assert candidate(h = 100,w = 150,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [15, 30, 45, 60, 75, 90, 120, 135]) == 300\n assert candidate(h = 150,w = 200,horizontalCuts = [25, 50, 75, 100, 125],verticalCuts = [30, 60, 90, 120, 150, 180]) == 750\n assert candidate(h = 100000,w = 50000,horizontalCuts = [50000],verticalCuts = [25000, 37500]) == 249999993\n assert candidate(h = 1000,w = 1000,horizontalCuts = [100, 200, 300, 400, 500, 600, 700, 800, 900],verticalCuts = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 10000\n assert candidate(h = 1000,w = 500,horizontalCuts = [10, 20, 30, 40, 50],verticalCuts = [25, 50, 75, 100, 125]) == 356250\n assert candidate(h = 2000,w = 3000,horizontalCuts = [500, 1000, 1500],verticalCuts = [750, 1500, 2250]) == 375000\n assert candidate(h = 1000000,w = 1000000,horizontalCuts = [500000],verticalCuts = [500000]) == 999998257\n assert candidate(h = 40,w = 50,horizontalCuts = [8, 16, 24, 32, 40],verticalCuts = [10, 20, 30, 40, 50]) == 80\n assert candidate(h = 15,w = 20,horizontalCuts = [1, 3, 5, 7, 9, 11, 13],verticalCuts = [2, 4, 6, 8, 10, 12, 14, 16, 18]) == 4\n assert candidate(h = 10,w = 10,horizontalCuts = [1, 2, 3, 4, 5, 6, 7, 8, 9],verticalCuts = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(h = 100,w = 100,horizontalCuts = [1, 99],verticalCuts = [1, 99]) == 9604\n assert candidate(h = 500000000,w = 300000000,horizontalCuts = [100000000, 200000000, 300000000, 400000000],verticalCuts = [50000000, 150000000, 250000000]) == 930000007\n assert candidate(h = 1000,w = 2000,horizontalCuts = [250, 500, 750],verticalCuts = [500, 1000, 1500]) == 125000\n assert candidate(h = 100,w = 200,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [20, 40, 60, 80, 100, 120, 140, 160, 180]) == 200\n assert candidate(h = 800,w = 600,horizontalCuts = [50, 100, 200, 300, 400, 500, 600, 700],verticalCuts = [50, 100, 200, 300, 400, 500, 600]) == 10000\n assert candidate(h = 10,w = 10,horizontalCuts = [1, 2, 3, 4, 5, 6, 7, 8, 9],verticalCuts = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(h = 100000,w = 100000,horizontalCuts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],verticalCuts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 99999944\n assert candidate(h = 20,w = 30,horizontalCuts = [3, 6, 9, 12, 15, 18],verticalCuts = [4, 8, 12, 16, 24, 28]) == 24\n assert candidate(h = 800,w = 600,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],verticalCuts = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 315000\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 500000000, 999999999],verticalCuts = [1, 500000000, 999999999]) == 250000022\n assert candidate(h = 999999999,w = 999999999,horizontalCuts = [1, 2, 3, 4, 5],verticalCuts = [1, 2, 3, 4, 5]) == 169\n assert candidate(h = 800,w = 600,horizontalCuts = [50, 150, 250, 350, 450, 550, 650, 750],verticalCuts = [30, 130, 230, 330, 430, 530, 590]) == 10000\n assert candidate(h = 200,w = 100,horizontalCuts = [20, 180],verticalCuts = [10, 90]) == 12800\n assert candidate(h = 150,w = 200,horizontalCuts = [10, 30, 50, 70, 90, 110, 130, 140],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 200\n assert candidate(h = 999,w = 999,horizontalCuts = [1, 998],verticalCuts = [1, 998]) == 994009\n assert candidate(h = 200,w = 200,horizontalCuts = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190],verticalCuts = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190]) == 400\n assert candidate(h = 1000000,w = 1000000,horizontalCuts = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000],verticalCuts = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000]) == 999999937\n assert candidate(h = 999999999,w = 999999999,horizontalCuts = [500000000],verticalCuts = [500000000]) == 250000014\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 2, 3, 4, 5],verticalCuts = [1, 2, 3, 4, 5]) == 144\n assert candidate(h = 999999,w = 999999,horizontalCuts = [1, 999998],verticalCuts = [1, 999998]) == 993993016\n assert candidate(h = 500,w = 600,horizontalCuts = [100, 200, 300, 400],verticalCuts = [150, 250, 350, 450, 550]) == 15000\n assert candidate(h = 500000000,w = 500000000,horizontalCuts = [125000000, 250000000, 375000000, 500000000],verticalCuts = [125000000, 250000000, 375000000, 500000000]) == 890625007\n assert candidate(h = 10000,w = 10000,horizontalCuts = [2500, 5000, 7500],verticalCuts = [2500, 5000, 7500]) == 6250000\n assert candidate(h = 30,w = 20,horizontalCuts = [2, 5, 8, 12, 16, 25],verticalCuts = [2, 4, 6, 10, 14]) == 54\n assert candidate(h = 800,w = 600,horizontalCuts = [100, 300, 500, 700],verticalCuts = [150, 300, 450, 600]) == 30000\n assert candidate(h = 100,w = 200,horizontalCuts = [10, 90],verticalCuts = [20, 180]) == 12800\n assert candidate(h = 1000,w = 1500,horizontalCuts = [100, 200, 300, 400, 500, 600, 700, 800, 900],verticalCuts = [150, 300, 450, 600, 750, 900, 1200, 1350]) == 30000\n assert candidate(h = 700,w = 500,horizontalCuts = [50, 100, 200, 300, 400, 500, 600, 650, 700],verticalCuts = [50, 100, 200, 300, 400, 500]) == 10000\n assert candidate(h = 25,w = 30,horizontalCuts = [5, 10, 15, 20],verticalCuts = [5, 10, 15, 20, 25]) == 25\n assert candidate(h = 50,w = 50,horizontalCuts = [1, 5, 10, 25, 49],verticalCuts = [2, 10, 20, 30, 45]) == 360\n assert candidate(h = 1000,w = 1000,horizontalCuts = [10, 100, 200, 300, 400, 500, 600, 700, 800, 900],verticalCuts = [10, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == 10000\n assert candidate(h = 20,w = 15,horizontalCuts = [1, 5, 10, 15],verticalCuts = [2, 6, 10, 14]) == 20\n assert candidate(h = 60,w = 70,horizontalCuts = [10, 20, 30, 40, 50],verticalCuts = [14, 28, 42, 56, 70]) == 140\n assert candidate(h = 500,w = 500,horizontalCuts = [100, 150, 200, 250, 300, 350, 400, 450],verticalCuts = [100, 150, 200, 250, 300, 350, 400, 450]) == 10000\n assert candidate(h = 100,w = 100,horizontalCuts = [1, 50, 99],verticalCuts = [1, 50, 99]) == 2401\n assert candidate(h = 50,w = 200,horizontalCuts = [5, 15, 25, 35, 45],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 100\n assert candidate(h = 100,w = 100,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 100\n assert candidate(h = 70,w = 80,horizontalCuts = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],verticalCuts = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80]) == 56\n assert candidate(h = 300,w = 300,horizontalCuts = [50, 100, 150, 200, 250],verticalCuts = [50, 100, 150, 200, 250]) == 2500\n assert candidate(h = 100,w = 100,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 100\n"}, "metadata": {"canonical_parameter_names": ["h", "w", "horizontalCuts", "verticalCuts"], "leetcode_dataset_entry_point": "Solution().maxArea", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxArea(self, h: int, w: int, horizontalCuts: list[int], verticalCuts: list[int]) -> int:", "container": "Solution", "callable": "maxArea", "parameters": [{"name": "h", "type": "int"}, {"name": "w", "type": "int"}, {"name": "horizontalCuts", "type": "list[int]"}, {"name": "verticalCuts", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1466, "task_id": "reorder-routes-to-make-all-paths-lead-to-the-city-zero", "difficulty": "Medium", "problem_description": "There are n cities numbered from 0 to n - 1 and n - 1 roads such that there is only one way to travel between two different cities (this network form a tree). Last year, The ministry of transport decided to orient the roads in one direction because they are too narrow.\nRoads are represented by connections where connections[i] = [ai, bi] represents a road from city ai to city bi.\nThis year, there will be a big event in the capital (city 0), and many people want to travel to this city.\nYour task consists of reorienting some roads such that each city can visit the city 0. Return the minimum number of edges changed.\nIt's guaranteed that each city can reach city 0 after reorder.\n \nExample 1:\n\n\nInput: n = 6, connections = [[0,1],[1,3],[2,3],[4,0],[4,5]]\nOutput: 3\nExplanation: Change the direction of edges show in red such that each node can reach the node 0 (capital).\n\nExample 2:\n\n\nInput: n = 5, connections = [[1,0],[1,2],[3,2],[3,4]]\nOutput: 2\nExplanation: Change the direction of edges show in red such that each node can reach the node 0 (capital).\n\nExample 3:\n\nInput: n = 3, connections = [[1,0],[2,0]]\nOutput: 0\n\n \nConstraints:\n\n2 <= n <= 5 * 104\nconnections.length == n - 1\nconnections[i].length == 2\n0 <= ai, bi <= n - 1\nai != bi\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 7,connections = [[1, 0], [2, 0], [3, 1], [4, 0], [5, 0], [6, 4]]) == 0\n assert candidate(n = 6,connections = [[0, 1], [1, 3], [2, 3], [4, 0], [4, 5]]) == 3\n assert candidate(n = 5,connections = [[1, 0], [1, 2], [3, 2], [3, 4]]) == 2\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [1, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 9\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [3, 2], [4, 2], [5, 4], [6, 4]]) == 2\n assert candidate(n = 4,connections = [[2, 0], [3, 0], [1, 2]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [2, 0], [3, 2], [4, 2], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8]]) == 1\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 6\n assert candidate(n = 3,connections = [[1, 0], [2, 0]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [3, 2], [4, 3], [5, 4], [6, 5]]) == 2\n assert candidate(n = 7,connections = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]]) == 0\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]]) == 19\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 11\n assert candidate(n = 30,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29]]) == 29\n assert candidate(n = 11,connections = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [6, 7], [0, 8], [8, 9], [9, 10]]) == 10\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [9, 10], [10, 11]]) == 11\n assert candidate(n = 18,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17]]) == 17\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 9\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [13, 14]]) == 14\n assert candidate(n = 11,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n assert candidate(n = 11,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [5, 10]]) == 10\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14]]) == 14\n assert candidate(n = 13,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12]]) == 12\n assert candidate(n = 18,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17]]) == 17\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14]]) == 14\n assert candidate(n = 16,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [8, 15]]) == 15\n assert candidate(n = 16,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15]]) == 15\n assert candidate(n = 9,connections = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]]) == 8\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [7, 5]]) == 6\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]]) == 11\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6], [4, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 11\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == 19\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9]]) == 9\n assert candidate(n = 10,connections = [[9, 0], [7, 6], [3, 2], [4, 2], [6, 3], [0, 5], [8, 0], [0, 9]]) == 2\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11]]) == 11\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == 11\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 9\n assert candidate(n = 14,connections = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13]]) == 13\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [0, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 19\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == 11\n assert candidate(n = 14,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [12, 13]]) == 13\n assert candidate(n = 9,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 8\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 7\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19]]) == 19\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [6, 9]]) == 9\n assert candidate(n = 9,connections = [[0, 1], [1, 2], [0, 3], [3, 4], [2, 5], [5, 6], [4, 7], [7, 8]]) == 8\n assert candidate(n = 18,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [9, 17]]) == 17\n assert candidate(n = 13,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [11, 12]]) == 12\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [8, 9]]) == 9\n assert candidate(n = 25,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24]]) == 24\n assert candidate(n = 18,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [1, 15], [15, 16], [16, 17]]) == 17\n assert candidate(n = 21,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20]]) == 20\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [2, 7], [7, 8], [8, 9], [0, 10], [10, 11]]) == 11\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == 14\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 14\n assert candidate(n = 14,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == 13\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 9\n"}, "metadata": {"canonical_parameter_names": ["n", "connections"], "leetcode_dataset_entry_point": "Solution().minReorder", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minReorder(self, n: int, connections: list[list[int]]) -> int:", "container": "Solution", "callable": "minReorder", "parameters": [{"name": "n", "type": "int"}, {"name": "connections", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1467, "task_id": "probability-of-a-two-boxes-having-the-same-number-of-distinct-balls", "difficulty": "Hard", "problem_description": "Given 2n balls of k distinct colors. You will be given an integer array balls of size k where balls[i] is the number of balls of color i.\nAll the balls will be shuffled uniformly at random, then we will distribute the first n balls to the first box and the remaining n balls to the other box (Please read the explanation of the second example carefully).\nPlease note that the two boxes are considered different. For example, if we have two balls of colors a and b, and two boxes [] and (), then the distribution [a] (b) is considered different than the distribution [b] (a) (Please read the explanation of the first example carefully).\nReturn the probability that the two boxes have the same number of distinct balls. Answers within 10-5 of the actual value will be accepted as correct.\n \nExample 1:\n\nInput: balls = [1,1]\nOutput: 1.00000\nExplanation: Only 2 ways to divide the balls equally:\n- A ball of color 1 to box 1 and a ball of color 2 to box 2\n- A ball of color 2 to box 1 and a ball of color 1 to box 2\nIn both ways, the number of distinct colors in each box is equal. The probability is 2/2 = 1\n\nExample 2:\n\nInput: balls = [2,1,1]\nOutput: 0.66667\nExplanation: We have the set of balls [1, 1, 2, 3]\nThis set of balls will be shuffled randomly and we may have one of the 12 distinct shuffles with equal probability (i.e. 1/12):\n[1,1 / 2,3], [1,1 / 3,2], [1,2 / 1,3], [1,2 / 3,1], [1,3 / 1,2], [1,3 / 2,1], [2,1 / 1,3], [2,1 / 3,1], [2,3 / 1,1], [3,1 / 1,2], [3,1 / 2,1], [3,2 / 1,1]\nAfter that, we add the first two balls to the first box and the second two balls to the second box.\nWe can see that 8 of these 12 possible random distributions have the same number of distinct colors of balls in each box.\nProbability is 8/12 = 0.66667\n\nExample 3:\n\nInput: balls = [1,2,1,2]\nOutput: 0.60000\nExplanation: The set of balls is [1, 2, 2, 3, 4, 4]. It is hard to display all the 180 possible random shuffles of this set but it is easy to check that 108 of them will have the same number of distinct colors in each box.\nProbability = 108 / 180 = 0.6\n\n \nConstraints:\n\n1 <= balls.length <= 8\n1 <= balls[i] <= 6\nsum(balls) is even.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(balls = [6, 6]) == 1.0\n assert candidate(balls = [4, 4, 4, 4]) == 0.820979020979021\n assert candidate(balls = [2, 1, 1]) == 0.6666666666666666\n assert candidate(balls = [1, 2, 2, 2, 2, 2, 2]) == 0.8571428571428571\n assert candidate(balls = [1, 2, 1, 2]) == 0.6\n assert candidate(balls = [2, 2, 2, 2]) == 1.0\n assert candidate(balls = [6, 1]) == 0.0\n assert candidate(balls = [6]) == 1.0\n assert candidate(balls = [3, 3]) == 1.0\n assert candidate(balls = [1, 2, 3, 4, 5, 6]) == 0.5375089306977852\n assert candidate(balls = [2, 2, 2]) == 1.0\n assert candidate(balls = [1, 1, 1, 1, 1, 1, 1, 1]) == 1.0\n assert candidate(balls = [2, 1, 1, 1, 1]) == 0.6\n assert candidate(balls = [1, 1]) == 1.0\n assert candidate(balls = [3, 2, 1]) == 0.3\n assert candidate(balls = [1, 2, 3]) == 0.3\n assert candidate(balls = [6, 6, 6, 6, 6, 6, 6, 6]) == 0.8557108876701283\n assert candidate(balls = [1, 1, 1, 1]) == 1.0\n assert candidate(balls = [1, 1, 2, 2, 3, 3]) == 0.38311688311688313\n assert candidate(balls = [4, 2]) == 0.6\n assert candidate(balls = [5, 5, 1, 1, 1]) == 0.032467532467532464\n assert candidate(balls = [4, 3, 2, 1]) == 0.30952380952380953\n assert candidate(balls = [5, 5, 1, 1]) == 0.5454545454545454\n assert candidate(balls = [1, 2, 3, 4]) == 0.30952380952380953\n assert candidate(balls = [6, 2, 2, 2]) == 0.4329004329004329\n assert candidate(balls = [6, 4, 2, 2, 2]) == 0.40792540792540793\n assert candidate(balls = [2, 2, 2, 1, 1]) == 0.5714285714285714\n assert candidate(balls = [5, 1, 1, 1, 1]) == 0.8571428571428571\n assert candidate(balls = [4, 4, 1]) == 0.11428571428571428\n assert candidate(balls = [2, 2, 2, 2, 2, 2]) == 1.0\n assert candidate(balls = [6, 6]) == 1.0\n assert candidate(balls = [6, 1, 1, 1]) == 0.0\n assert candidate(balls = [3, 2, 1, 1, 1]) == 0.2571428571428571\n assert candidate(balls = [3, 3, 3, 1]) == 0.21428571428571427\n assert candidate(balls = [3, 2, 2, 1]) == 0.37142857142857144\n assert candidate(balls = [1, 1, 1, 1, 1, 1]) == 1.0\n assert candidate(balls = [1, 1, 1, 1, 1, 1]) == 1.0\n assert candidate(balls = [5, 4, 3, 2, 1]) == 0.5474941724941725\n assert candidate(balls = [2, 2, 2, 2, 1]) == 0.8\n assert candidate(balls = [6, 6, 6]) == 0.9777869189633895\n assert candidate(balls = [1, 2, 3, 4]) == 0.30952380952380953\n assert candidate(balls = [4, 2, 1]) == 0.5\n assert candidate(balls = [1, 2, 2, 1, 1]) == 0.6\n assert candidate(balls = [3, 2, 2, 1, 1, 1]) == 0.30952380952380953\n assert candidate(balls = [5, 3, 2]) == 0.5555555555555556\n assert candidate(balls = [6, 1, 1]) == 0.5714285714285714\n assert candidate(balls = [5, 3, 1]) == 0.21428571428571427\n assert candidate(balls = [4, 2, 1, 1]) == 0.34285714285714286\n assert candidate(balls = [3, 2, 1, 1]) == 0.7\n assert candidate(balls = [5, 3, 3]) == 1.3531746031746033\n assert candidate(balls = [6, 3, 3]) == 0.7251082251082251\n assert candidate(balls = [5, 1, 1]) == 1.0\n assert candidate(balls = [4, 2, 2]) == 0.5142857142857142\n assert candidate(balls = [3, 3, 1, 1]) == 0.5714285714285714\n assert candidate(balls = [3, 3, 3, 3, 3, 3]) == 0.6334841628959276\n assert candidate(balls = [4, 3, 2, 1]) == 0.30952380952380953\n assert candidate(balls = [2, 3, 2, 1]) == 0.37142857142857144\n assert candidate(balls = [2, 2, 2, 2]) == 1.0\n assert candidate(balls = [4, 2, 2, 1]) == 0.5857142857142857\n assert candidate(balls = [4, 4, 4, 2]) == 0.5664335664335665\n assert candidate(balls = [1, 2, 2, 3, 3]) == 0.6507936507936508\n assert candidate(balls = [2, 2, 1, 1, 1, 1]) == 0.5142857142857142\n assert candidate(balls = [1, 1, 1, 1, 1, 1, 1, 1]) == 1.0\n assert candidate(balls = [3, 2, 2]) == 1.1\n assert candidate(balls = [6, 2, 1, 1]) == 0.31746031746031744\n assert candidate(balls = [5, 5, 5]) == 1.7657342657342658\n assert candidate(balls = [4, 3, 1]) == 0.11428571428571428\n assert candidate(balls = [5, 1, 1, 1, 1, 1]) == 0.0\n assert candidate(balls = [4, 4, 1, 1]) == 0.5555555555555556\n assert candidate(balls = [6, 2, 2]) == 0.47619047619047616\n assert candidate(balls = [1, 3, 3, 1]) == 0.5714285714285714\n assert candidate(balls = [5, 1, 1, 1]) == 0.0\n assert candidate(balls = [3, 3, 1, 1]) == 0.5714285714285714\n assert candidate(balls = [3, 3, 3, 3]) == 0.7662337662337663\n assert candidate(balls = [6, 1, 1, 1, 1, 1, 1, 1]) == 0.0\n assert candidate(balls = [3, 3, 3, 3]) == 0.7662337662337663\n assert candidate(balls = [6, 2, 1, 1, 1]) == 0.4166666666666667\n assert candidate(balls = [4, 2]) == 0.6\n assert candidate(balls = [5, 1, 1, 1]) == 0.0\n assert candidate(balls = [4, 2, 2]) == 0.5142857142857142\n assert candidate(balls = [2, 2, 1, 1, 1, 1]) == 0.5142857142857142\n assert candidate(balls = [4, 4, 4, 4]) == 0.820979020979021\n assert candidate(balls = [1, 1, 2, 2, 3, 3]) == 0.38311688311688313\n assert candidate(balls = [4, 4, 2, 2]) == 0.5238095238095238\n assert candidate(balls = [6, 1, 1]) == 0.5714285714285714\n assert candidate(balls = [4, 4, 1]) == 0.11428571428571428\n assert candidate(balls = [6, 6, 1, 1]) == 0.5384615384615384\n assert candidate(balls = [4, 4, 2]) == 0.6190476190476191\n assert candidate(balls = [6, 2, 2, 2, 2, 2, 2]) == 0.38009049773755654\n assert candidate(balls = [4, 4, 3, 2, 1]) == 0.30186480186480186\n assert candidate(balls = [3, 2, 1, 1, 1]) == 0.2571428571428571\n assert candidate(balls = [4, 4, 4]) == 0.8961038961038961\n assert candidate(balls = [6, 1, 1, 1]) == 0.0\n assert candidate(balls = [2, 2, 2, 2, 2, 2]) == 1.0\n assert candidate(balls = [6, 1, 1, 1, 1, 1]) == 0.0\n assert candidate(balls = [6, 3, 1, 1, 1, 1]) == 0.6818181818181818\n assert candidate(balls = [1, 2, 3, 2]) == 0.37142857142857144\n assert candidate(balls = [5, 2, 2, 1]) == 0.31746031746031744\n assert candidate(balls = [3, 2, 1]) == 0.3\n assert candidate(balls = [3, 2, 1, 1, 1, 1]) == 0.6\n assert candidate(balls = [2, 2, 2, 1, 1]) == 0.5714285714285714\n assert candidate(balls = [3, 2, 2, 1]) == 0.37142857142857144\n"}, "metadata": {"canonical_parameter_names": ["balls"], "leetcode_dataset_entry_point": "Solution().getProbability", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getProbability(self, balls: list[int]) -> float:", "container": "Solution", "callable": "getProbability", "parameters": [{"name": "balls", "type": "list[int]"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1470, "task_id": "shuffle-the-array", "difficulty": "Easy", "problem_description": "Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn].\\r\n\\r\nReturn the array in the form [x1,y1,x2,y2,...,xn,yn].\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: nums = [2,5,1,3,4,7], n = 3\\r\nOutput: [2,3,5,4,1,7] \\r\nExplanation: Since x1=2, x2=5, x3=1, y1=3, y2=4, y3=7 then the answer is [2,3,5,4,1,7].\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: nums = [1,2,3,4,4,3,2,1], n = 4\\r\nOutput: [1,4,2,3,3,2,4,1]\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: nums = [1,1,2,2], n = 2\\r\nOutput: [1,2,1,2]\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= n <= 500\\r\n\tnums.length == 2n\\r\n\t1 <= nums[i] <= 10^3\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],n = 6) == [5, 11, 6, 12, 7, 13, 8, 14, 9, 15, 10, 16]\n assert candidate(nums = [2, 5, 1, 3, 4, 7],n = 3) == [2, 3, 5, 4, 1, 7]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80],n = 4) == [10, 50, 20, 60, 30, 70, 40, 80]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],n = 5) == [9, 4, 8, 3, 7, 2, 6, 1, 5, 0]\n assert candidate(nums = [7, 11, 3, 4, 8, 10],n = 3) == [7, 4, 11, 8, 3, 10]\n assert candidate(nums = [6, 2, 3, 4, 5, 1],n = 3) == [6, 4, 2, 5, 3, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 8) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],n = 6) == [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12]\n assert candidate(nums = [5, 3, 2, 4, 1, 6],n = 3) == [5, 4, 3, 1, 2, 6]\n assert candidate(nums = [1, 1, 2, 2],n = 2) == [1, 2, 1, 2]\n assert candidate(nums = [10, 20, 30, 40, 50, 60],n = 3) == [10, 40, 20, 50, 30, 60]\n assert candidate(nums = [100, 200, 101, 201, 102, 202, 103, 203],n = 4) == [100, 102, 200, 202, 101, 103, 201, 203]\n assert candidate(nums = [100, 200, 101, 201, 102, 202],n = 3) == [100, 201, 200, 102, 101, 202]\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],n = 10) == [999, 2, 888, 3, 777, 4, 666, 5, 555, 6, 444, 7, 333, 8, 222, 9, 111, 10, 1, 11]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14],n = 4) == [7, 11, 8, 12, 9, 13, 10, 14]\n assert candidate(nums = [1, 2, 3, 4, 4, 3, 2, 1],n = 4) == [1, 4, 2, 3, 3, 2, 4, 1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 30],n = 8) == [1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 30]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34],n = 17) == [5, 22, 6, 23, 7, 24, 8, 25, 9, 26, 10, 27, 11, 28, 12, 29, 13, 30, 14, 31, 15, 32, 16, 33, 17, 34]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],n = 20) == [1, 11, 1, 11, 2, 12, 2, 12, 3, 13, 3, 13, 4, 14, 4, 14, 5, 15, 5, 15, 6, 16, 6, 16, 7, 17, 7, 17, 8, 18, 8, 18, 9, 19, 9, 19, 10, 20, 10, 20]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600],n = 8) == [100, 900, 200, 1000, 300, 1100, 400, 1200, 500, 1300, 600, 1400, 700, 1500, 800, 1600]\n assert candidate(nums = [500, 1, 499, 2, 498, 3, 497, 4, 496, 5, 495, 6, 494, 7, 493, 8, 492, 9, 491, 10, 490, 11, 489, 12, 488, 13, 487, 14, 486, 15, 485, 16, 484, 17, 483, 18, 482, 19, 481, 20],n = 25) == [500, 13, 1, 487, 499, 14, 2, 486, 498, 15, 3, 485, 497, 16, 4, 484, 496, 17, 5, 483, 495, 18, 6, 482, 494, 19, 7, 481, 493, 20]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],n = 15) == [1, 6, 1, 6, 1, 6, 2, 7, 2, 7, 2, 7, 3, 8, 3, 8, 3, 8, 4, 9, 4, 9, 4, 9, 5, 10, 5, 10, 5, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500],n = 25) == [10, 260, 20, 270, 30, 280, 40, 290, 50, 300, 60, 310, 70, 320, 80, 330, 90, 340, 100, 350, 110, 360, 120, 370, 130, 380, 140, 390, 150, 400, 160, 410, 170, 420, 180, 430, 190, 440, 200, 450, 210, 460, 220, 470, 230, 480, 240, 490, 250, 500]\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],n = 10) == [999, 2, 888, 3, 777, 4, 666, 5, 555, 6, 444, 7, 333, 8, 222, 9, 111, 10]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],n = 15) == [2, 32, 4, 34, 6, 36, 8, 38, 10, 40, 12, 42, 14, 44, 16, 46, 18, 48, 20, 50, 22, 52, 24, 54, 26, 56, 28, 58, 30, 60]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],n = 10) == [5, 55, 10, 60, 15, 65, 20, 70, 25, 75, 30, 80, 35, 85, 40, 90, 45, 95, 50, 100]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971],n = 15) == [1000, 985, 999, 984, 998, 983, 997, 982, 996, 981, 995, 980, 994, 979, 993, 978, 992, 977, 991, 976, 990, 975, 989, 974, 988, 973, 987, 972, 986, 971]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],n = 10) == [9, 11, 8, 12, 7, 13, 6, 14, 5, 15, 4, 16, 3, 17, 2, 18, 1, 19, 10, 20]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11],n = 10) == [10, 20, 9, 19, 8, 18, 7, 17, 6, 16, 5, 15, 4, 14, 3, 13, 2, 12, 1, 11]\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020],n = 10) == [101, 1111, 202, 1212, 303, 1313, 404, 1414, 505, 1515, 606, 1616, 707, 1717, 808, 1818, 909, 1919, 1010, 2020]\n assert candidate(nums = [99, 100, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60],n = 32) == [99, 68, 100, 67, 98, 66, 97, 65, 96, 64, 95, 63, 94, 62, 93, 61, 92, 60]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],n = 25) == [1, 26, 2, 27, 3, 28, 4, 29, 5, 30, 6, 31, 7, 32, 8, 33, 9, 34, 10, 35, 11, 36, 12, 37, 13, 38, 14, 39, 15, 40, 16, 41, 17, 42, 18, 43, 19, 44, 20, 45, 21, 46, 22, 47, 23, 48, 24, 49, 25, 50]\n assert candidate(nums = [300, 299, 298, 297, 296, 295, 294, 293, 292, 291, 290, 289, 288, 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, 275, 274, 273, 272, 271, 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210],n = 25) == [300, 275, 299, 274, 298, 273, 297, 272, 296, 271, 295, 270, 294, 269, 293, 268, 292, 267, 291, 266, 290, 265, 289, 264, 288, 263, 287, 262, 286, 261, 285, 260, 284, 259, 283, 258, 282, 257, 281, 256, 280, 255, 279, 254, 278, 253, 277, 252, 276, 251]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],n = 15) == [100, 6, 200, 7, 300, 8, 400, 9, 500, 10, 600, 11, 700, 12, 800, 13, 900, 14, 1000, 15, 1, 16, 2, 17, 3, 18, 4, 19, 5, 20]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200],n = 17) == [5, 90, 10, 95, 15, 100, 20, 105, 25, 110, 30, 115, 35, 120, 40, 125, 45, 130, 50, 135, 55, 140, 60, 145, 65, 150, 70, 155, 75, 160, 80, 165, 85, 170]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32],n = 16) == [1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23, 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31, 16, 32]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],n = 10) == [5, 55, 10, 60, 15, 65, 20, 70, 25, 75, 30, 80, 35, 85, 40, 90, 45, 95, 50, 100]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],n = 15) == [5, 80, 10, 85, 15, 90, 20, 95, 25, 100, 30, 105, 35, 110, 40, 115, 45, 120, 50, 125, 55, 130, 60, 135, 65, 140, 70, 145, 75, 150]\n assert candidate(nums = [123, 456, 789, 1011, 1213, 1415, 1617, 1819, 2021, 2223, 2425, 2627, 2829, 3031, 3233, 3435, 3637, 3839, 4041, 4243, 4445, 4647, 4849, 5051, 5253, 5455, 5657, 5859, 6061, 6263, 6465, 6667, 6869, 7071, 7273, 7475, 7677, 7879, 8081, 8283, 8485, 8687, 8889, 9091, 9293, 9495, 9697, 9899],n = 25) == [123, 5455, 456, 5657, 789, 5859, 1011, 6061, 1213, 6263, 1415, 6465, 1617, 6667, 1819, 6869, 2021, 7071, 2223, 7273, 2425, 7475, 2627, 7677, 2829, 7879, 3031, 8081, 3233, 8283, 3435, 8485, 3637, 8687, 3839, 8889, 4041, 9091, 4243, 9293, 4445, 9495, 4647, 9697, 4849, 9899]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],n = 8) == [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],n = 30) == [10, 1, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6, 70, 7, 80, 8, 90, 9, 100, 10, 110, 11, 120, 12, 130, 13, 140, 14, 150, 15, 160, 16, 170, 17, 180, 18, 190, 19, 200, 20, 210, 21, 220, 22, 230, 23, 240, 24, 250, 25, 260, 26, 270, 27, 280, 28, 290, 29, 300, 30]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],n = 10) == [10, 110, 20, 120, 30, 130, 40, 140, 50, 150, 60, 160, 70, 170, 80, 180, 90, 190, 100, 200]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],n = 8) == [10, 90, 20, 100, 30, 110, 40, 120, 50, 130, 60, 140, 70, 150, 80, 160]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100],n = 50) == [1, 51, 2, 52, 3, 53, 4, 54, 5, 55, 6, 56, 7, 57, 8, 58, 9, 59, 10, 60, 11, 61, 12, 62, 13, 63, 14, 64, 15, 65, 16, 66, 17, 67, 18, 68, 19, 69, 20, 70, 21, 71, 22, 72, 23, 73, 24, 74, 25, 75, 26, 76, 27, 77, 28, 78, 29, 79, 30, 80, 31, 81, 32, 82, 33, 83, 34, 84, 35, 85, 36, 86, 37, 87, 38, 88, 39, 89, 40, 90, 41, 91, 42, 92, 43, 93, 44, 94, 45, 95, 46, 96, 47, 97, 48, 98, 49, 99, 50, 1000]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],n = 10) == [1, 6, 1, 6, 2, 7, 2, 7, 3, 8, 3, 8, 4, 9, 4, 9, 5, 10, 5, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150],n = 75) == [1, 76, 2, 77, 3, 78, 4, 79, 5, 80, 6, 81, 7, 82, 8, 83, 9, 84, 10, 85, 11, 86, 12, 87, 13, 88, 14, 89, 15, 90, 16, 91, 17, 92, 18, 93, 19, 94, 20, 95, 21, 96, 22, 97, 23, 98, 24, 99, 25, 100, 26, 101, 27, 102, 28, 103, 29, 104, 30, 105, 31, 106, 32, 107, 33, 108, 34, 109, 35, 110, 36, 111, 37, 112, 38, 113, 39, 114, 40, 115, 41, 116, 42, 117, 43, 118, 44, 119, 45, 120, 46, 121, 47, 122, 48, 123, 49, 124, 50, 125, 51, 126, 52, 127, 53, 128, 54, 129, 55, 130, 56, 131, 57, 132, 58, 133, 59, 134, 60, 135, 61, 136, 62, 137, 63, 138, 64, 139, 65, 140, 66, 141, 67, 142, 68, 143, 69, 144, 70, 145, 71, 146, 72, 147, 73, 148, 74, 149, 75, 150]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 6, 7, 9],n = 50) == [3, 0, 1, 5, 4, 8, 1, 2, 5, 0, 9, 9, 2, 7, 6, 4, 5, 9, 3, 4, 5, 4, 8, 5, 9, 9, 7, 2, 9, 3, 3, 0, 2, 7, 3, 8, 8, 1, 4, 6, 6, 4, 2, 0, 6, 6, 4, 2, 3, 8, 3, 6, 8, 2, 3, 0, 2, 8, 7, 9, 9, 9, 5, 8, 0, 6, 2, 2, 8, 8, 8, 0, 4, 3, 1, 4, 9, 8, 7, 2, 1, 5, 6, 3, 9, 4, 3, 2, 9, 1, 9, 1, 3, 7, 7, 0, 5, 6, 1, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],n = 50) == [1, 51, 2, 52, 3, 53, 4, 54, 5, 55, 6, 56, 7, 57, 8, 58, 9, 59, 10, 60, 11, 61, 12, 62, 13, 63, 14, 64, 15, 65, 16, 66, 17, 67, 18, 68, 19, 69, 20, 70, 21, 71, 22, 72, 23, 73, 24, 74, 25, 75, 26, 76, 27, 77, 28, 78, 29, 79, 30, 80, 31, 81, 32, 82, 33, 83, 34, 84, 35, 85, 36, 86, 37, 87, 38, 88, 39, 89, 40, 90, 41, 91, 42, 92, 43, 93, 44, 94, 45, 95, 46, 96, 47, 97, 48, 98, 49, 99, 50, 100]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],n = 50) == [1, 51, 2, 52, 3, 53, 4, 54, 5, 55, 6, 56, 7, 57, 8, 58, 9, 59, 10, 60, 11, 61, 12, 62, 13, 63, 14, 64, 15, 65, 16, 66, 17, 67, 18, 68, 19, 69, 20, 70, 21, 71, 22, 72, 23, 73, 24, 74, 25, 75, 26, 76, 27, 77, 28, 78, 29, 79, 30, 80, 31, 81, 32, 82, 33, 83, 34, 84, 35, 85, 36, 86, 37, 87, 38, 88, 39, 89, 40, 90, 41, 91, 42, 92, 43, 93, 44, 94, 45, 95, 46, 96, 47, 97, 48, 98, 49, 99, 50, 100]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],n = 12) == [1, 25, 3, 27, 5, 29, 7, 31, 9, 33, 11, 35, 13, 37, 15, 39, 17, 41, 19, 43, 21, 45, 23, 47]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],n = 15) == [10, 160, 20, 170, 30, 180, 40, 190, 50, 200, 60, 210, 70, 220, 80, 230, 90, 240, 100, 250, 110, 260, 120, 270, 130, 280, 140, 290, 150, 300]\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616],n = 8) == [101, 909, 202, 1010, 303, 1111, 404, 1212, 505, 1313, 606, 1414, 707, 1515, 808, 1616]\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],n = 8) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]\n assert candidate(nums = [1, 100, 2, 101, 3, 102, 4, 103, 5, 104, 6, 105, 7, 106, 8, 107, 9, 108, 10, 109, 11, 110, 12, 111, 13, 112, 14, 113, 15, 114, 16, 115, 17, 116, 18, 117, 19, 118, 20, 119, 21, 120, 22, 121, 23, 122, 24, 123, 25, 124, 26, 125, 27, 126, 28, 127, 29, 128, 30, 129],n = 15) == [1, 107, 100, 9, 2, 108, 101, 10, 3, 109, 102, 11, 4, 110, 103, 12, 5, 111, 104, 13, 6, 112, 105, 14, 7, 113, 106, 15, 8, 114]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960, 959, 958, 957, 956, 955, 954, 953, 952, 951, 950, 949, 948, 947, 946, 945, 944, 943, 942, 941, 940, 939, 938, 937, 936, 935, 934, 933, 932, 931, 930],n = 25) == [1000, 975, 999, 974, 998, 973, 997, 972, 996, 971, 995, 970, 994, 969, 993, 968, 992, 967, 991, 966, 990, 965, 989, 964, 988, 963, 987, 962, 986, 961, 985, 960, 984, 959, 983, 958, 982, 957, 981, 956, 980, 955, 979, 954, 978, 953, 977, 952, 976, 951]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],n = 20) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410],n = 10) == [101, 201, 102, 202, 103, 203, 104, 204, 105, 205, 106, 206, 107, 207, 108, 208, 109, 209, 110, 210]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295, 305, 315, 325, 335, 345, 355, 365, 375, 385, 395, 400],n = 20) == [5, 205, 15, 215, 25, 225, 35, 235, 45, 245, 55, 255, 65, 265, 75, 275, 85, 285, 95, 295, 105, 305, 115, 315, 125, 325, 135, 335, 145, 345, 155, 355, 165, 365, 175, 375, 185, 385, 195, 395]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],n = 8) == [10, 90, 20, 100, 30, 110, 40, 120, 50, 130, 60, 140, 70, 150, 80, 160]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],n = 16) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],n = 15) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],n = 20) == [5, 25, 6, 26, 7, 27, 8, 28, 9, 29, 10, 30, 11, 31, 12, 32, 13, 33, 14, 34, 15, 35, 16, 36, 17, 37, 18, 38, 19, 39, 20, 40]\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960, 959, 958, 957, 956, 955, 954, 953, 952, 951, 950, 949, 948, 947, 946, 945, 944, 943, 942, 941, 940, 939, 938, 937, 936, 935, 934, 933, 932, 931, 930, 929, 928, 927, 926, 925, 924, 923, 922, 921, 920, 919, 918, 917, 916, 915, 914, 913, 912, 911, 910],n = 50) == [999, 949, 998, 948, 997, 947, 996, 946, 995, 945, 994, 944, 993, 943, 992, 942, 991, 941, 990, 940, 989, 939, 988, 938, 987, 937, 986, 936, 985, 935, 984, 934, 983, 933, 982, 932, 981, 931, 980, 930, 979, 929, 978, 928, 977, 927, 976, 926, 975, 925, 974, 924, 973, 923, 972, 922, 971, 921, 970, 920, 969, 919, 968, 918, 967, 917, 966, 916, 965, 915, 964, 914, 963, 913, 962, 912, 961, 911, 960, 910]\n assert candidate(nums = [1, 1001, 2, 1002, 3, 1003, 4, 1004, 5, 1005, 6, 1006, 7, 1007, 8, 1008, 9, 1009, 10, 1010, 11, 1011, 12, 1012, 13, 1013, 14, 1014, 15, 1015, 16, 1016, 17, 1017, 18, 1018, 19, 1019, 20, 1020, 21, 1021, 22, 1022, 23, 1023, 24, 1024, 25, 1025, 26, 1026, 27, 1027, 28, 1028, 29, 1029, 30, 1030, 31, 1031, 32, 1032, 33, 1033, 34, 1034, 35, 1035, 36, 1036, 37, 1037, 38, 1038, 39, 1039, 40, 1040, 41, 1041, 42, 1042, 43, 1043, 44, 1044, 45, 1045, 46, 1046, 47, 1047, 48, 1048, 49, 1049, 50, 1050],n = 25) == [1, 1013, 1001, 14, 2, 1014, 1002, 15, 3, 1015, 1003, 16, 4, 1016, 1004, 17, 5, 1017, 1005, 18, 6, 1018, 1006, 19, 7, 1019, 1007, 20, 8, 1020, 1008, 21, 9, 1021, 1009, 22, 10, 1022, 1010, 23, 11, 1023, 1011, 24, 12, 1024, 1012, 25, 13, 1025]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],n = 10) == [1, 6, 3, 8, 5, 10, 7, 12, 9, 14, 11, 16, 13, 18, 15, 20, 2, 22, 4, 24]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600],n = 8) == [100, 900, 200, 1000, 300, 1100, 400, 1200, 500, 1300, 600, 1400, 700, 1500, 800, 1600]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30],n = 30) == [1, 16, 1, 16, 2, 17, 2, 17, 3, 18, 3, 18, 4, 19, 4, 19, 5, 20, 5, 20, 6, 21, 6, 21, 7, 22, 7, 22, 8, 23, 8, 23, 9, 24, 9, 24, 10, 25, 10, 25, 11, 26, 11, 26, 12, 27, 12, 27, 13, 28, 13, 28, 14, 29, 14, 29, 15, 30, 15, 30]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295],n = 15) == [5, 155, 15, 165, 25, 175, 35, 185, 45, 195, 55, 205, 65, 215, 75, 225, 85, 235, 95, 245, 105, 255, 115, 265, 125, 275, 135, 285, 145, 295]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000, 5100, 5200, 5300, 5400, 5500, 5600, 5700, 5800, 5900, 6000, 6100, 6200, 6300, 6400, 6500, 6600, 6700, 6800, 6900, 7000, 7100, 7200, 7300, 7400, 7500, 7600, 7700, 7800, 7900, 8000, 8100, 8200, 8300, 8400, 8500, 8600, 8700, 8800, 8900, 9000, 9100, 9200, 9300, 9400, 9500, 9600, 9700, 9800, 9900, 10000],n = 50) == [100, 5100, 200, 5200, 300, 5300, 400, 5400, 500, 5500, 600, 5600, 700, 5700, 800, 5800, 900, 5900, 1000, 6000, 1100, 6100, 1200, 6200, 1300, 6300, 1400, 6400, 1500, 6500, 1600, 6600, 1700, 6700, 1800, 6800, 1900, 6900, 2000, 7000, 2100, 7100, 2200, 7200, 2300, 7300, 2400, 7400, 2500, 7500, 2600, 7600, 2700, 7700, 2800, 7800, 2900, 7900, 3000, 8000, 3100, 8100, 3200, 8200, 3300, 8300, 3400, 8400, 3500, 8500, 3600, 8600, 3700, 8700, 3800, 8800, 3900, 8900, 4000, 9000, 4100, 9100, 4200, 9200, 4300, 9300, 4400, 9400, 4500, 9500, 4600, 9600, 4700, 9700, 4800, 9800, 4900, 9900, 5000, 10000]\n assert candidate(nums = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],n = 50) == [1001, 1051, 1002, 1052, 1003, 1053, 1004, 1054, 1005, 1055, 1006, 1056, 1007, 1057, 1008, 1058, 1009, 1059, 1010, 1060, 1011, 1061, 1012, 1062, 1013, 1063, 1014, 1064, 1015, 1065, 1016, 1066, 1017, 1067, 1018, 1068, 1019, 1069, 1020, 1070, 1021, 1071, 1022, 1072, 1023, 1073, 1024, 1074, 1025, 1075, 1026, 1076, 1027, 1077, 1028, 1078, 1029, 1079, 1030, 1080, 1031, 1081, 1032, 1082, 1033, 1083, 1034, 1084, 1035, 1085, 1036, 1086, 1037, 1087, 1038, 1088, 1039, 1089, 1040, 1090, 1041, 1091, 1042, 1092, 1043, 1093, 1044, 1094, 1045, 1095, 1046, 1096, 1047, 1097, 1048, 1098, 1049, 1099, 1050, 1100]\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960, 959, 958, 957, 956, 955, 954, 953, 952, 951, 950, 949, 948, 947, 946, 945, 944, 943, 942, 941, 940, 939, 938, 937, 936, 935, 934, 933, 932, 931, 930],n = 50) == [999, 949, 998, 948, 997, 947, 996, 946, 995, 945, 994, 944, 993, 943, 992, 942, 991, 941, 990, 940, 989, 939, 988, 938, 987, 937, 986, 936, 985, 935, 984, 934, 983, 933, 982, 932, 981, 931, 980, 930]\n"}, "metadata": {"canonical_parameter_names": ["nums", "n"], "leetcode_dataset_entry_point": "Solution().shuffle", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def shuffle(self, nums: List[int], n: int) -> List[int]:", "container": "Solution", "callable": "shuffle", "parameters": [{"name": "nums", "type": "List[int]"}, {"name": "n", "type": "int"}], "return_type": "List[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1471, "task_id": "the-k-strongest-values-in-an-array", "difficulty": "Medium", "problem_description": "Given an array of integers arr and an integer k.\nA value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the centre of the array.\nIf |arr[i] - m| == |arr[j] - m|, then arr[i] is said to be stronger than arr[j] if arr[i] > arr[j].\nReturn a list of the strongest k values in the array. return the answer in any arbitrary order.\nThe centre is the middle value in an ordered integer list. More formally, if the length of the list is n, the centre is the element in position ((n - 1) / 2) in the sorted list (0-indexed).\n\nFor arr = [6, -3, 7, 2, 11], n = 5 and the centre is obtained by sorting the array arr = [-3, 2, 6, 7, 11] and the centre is arr[m] where m = ((5 - 1) / 2) = 2. The centre is 6.\nFor arr = [-7, 22, 17, 3], n = 4 and the centre is obtained by sorting the array arr = [-7, 3, 17, 22] and the centre is arr[m] where m = ((4 - 1) / 2) = 1. The centre is 3.\n\n\n\n \n\n\n \n\n \n \n\n\n\n\n\n \nExample 1:\n\nInput: arr = [1,2,3,4,5], k = 2\nOutput: [5,1]\nExplanation: Centre is 3, the elements of the array sorted by the strongest are [5,1,4,2,3]. The strongest 2 elements are [5, 1]. [1, 5] is also accepted answer.\nPlease note that although |5 - 3| == |1 - 3| but 5 is stronger than 1 because 5 > 1.\n\nExample 2:\n\nInput: arr = [1,1,3,5,5], k = 2\nOutput: [5,5]\nExplanation: Centre is 3, the elements of the array sorted by the strongest are [5,5,1,1,3]. The strongest 2 elements are [5, 5].\n\nExample 3:\n\nInput: arr = [6,7,11,7,6,8], k = 5\nOutput: [11,8,6,6,7]\nExplanation: Centre is 7, the elements of the array sorted by the strongest are [11,8,6,6,7,7].\nAny permutation of [11,8,6,6,7] is accepted.\n\n \nConstraints:\n\n1 <= arr.length <= 105\n-105 <= arr[i] <= 105\n1 <= k <= arr.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2) == [5, 1]\n assert candidate(arr = [100000, -100000, 50000, -50000, 0],k = 3) == [100000, -100000, 50000]\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 3) == [9, 8, 0]\n assert candidate(arr = [1, 1, 3, 5, 5],k = 2) == [5, 5]\n assert candidate(arr = [1, 3, 2, 4, 5],k = 3) == [5, 1, 4]\n assert candidate(arr = [-100000, 100000],k = 1) == [100000]\n assert candidate(arr = [6, -3, 7, 2, 11],k = 4) == [-3, 11, 2, 7]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == [10, 9, 1, 8]\n assert candidate(arr = [-7, 22, 17, 3],k = 2) == [22, 17]\n assert candidate(arr = [6, 7, 11, 7, 6, 8],k = 5) == [11, 8, 6, 6, 7]\n assert candidate(arr = [5, 3, 1, 2, 4],k = 3) == [5, 1, 4]\n assert candidate(arr = [0, 0, 0, 0, 0],k = 1) == [0]\n assert candidate(arr = [-7, 22, 17, 3],k = 3) == [22, 17, -7]\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == [10, 9, 1]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 6) == [-1, -15, -2, -14, -3, -13]\n assert candidate(arr = [-99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991, -99990],k = 5) == [-99990, -99991, -99999, -99992, -99998]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],k = 7) == [110, 10, 100, 20, 90, 30, 80]\n assert candidate(arr = [-5, 5, -10, 10, -15, 15, -20, 20, -25, 25, -30, 30, -35, 35],k = 6) == [35, 30, 25, -35, 20, -30]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == [1, 1, 1]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == [-1, -2, -10, -3, -9]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 4) == [-1, -2, -10, -3]\n assert candidate(arr = [1, 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10],k = 10) == [1, 10, 10, 10, 2, 2, 9, 9, 3, 8]\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91],k = 8) == [100, 99, 98, 97, 96, 95, 94, 93]\n assert candidate(arr = [-5, -3, -1, 1, 3, 5, -4, -2, 0, 2, 4, 6],k = 5) == [6, 5, -5, 4, -4]\n assert candidate(arr = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 7) == [10000, 9000, 1000, 8000, 2000, 7000, 3000]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(arr = [-10, -5, 0, 5, 10, 15],k = 3) == [15, 10, -10]\n assert candidate(arr = [1, 3, 2, 4, 6, 5, 7, 8, 10, 9, 11],k = 8) == [11, 1, 10, 2, 9, 3, 8, 4]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [100, 90, 10, 80, 20]\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 6) == [100, 90, 10, 80, 20, 70]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 8) == [29, 1, 27, 3, 25, 5, 23, 7]\n assert candidate(arr = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 3) == [1000, 900, 100]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],k = 10) == [1000, 900, 800, -1000, 700, -900, 600, -800, 500, -700]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == [1000, 900, 100, 800, 200]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9],k = 10) == [9, -9, 8, -8, 7, -7, 6, -6, 5, -5]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],k = 8) == [130, 10, 120, 20, 110, 30, 100, 40]\n assert candidate(arr = [1000, -1000, 500, -500, 250, -250, 750, -750, 375, -375],k = 5) == [1000, 750, 500, -1000, 375]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == [5, 5, 5, 5, 5]\n assert candidate(arr = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000],k = 6) == [13000, 1000, 12000, 2000, 11000, 3000]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == [5, 5, 5]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(arr = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 5) == [100000, 99999, 99991, 99998, 99992]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 6) == [19, 17, 1, 15, 3, 13]\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 8) == [99, 98, 90, 97, 91, 96, 92, 95]\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 8) == [1, 2, 2, 5, 5, 5, 5, 5]\n assert candidate(arr = [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500, 6250, -6250],k = 7) == [100000, -100000, 50000, -50000, 25000, 12500, -25000]\n assert candidate(arr = [-10, -20, 15, 10, 0, 5, -5],k = 4) == [-20, 15, 10, -10]\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 4) == [5, 4, 3, -5]\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 9) == [5, 5, 5, 1, 1, 1, 4, 4, 4]\n assert candidate(arr = [-1000, -2000, -3000, -4000, -5000, -6000, -7000, -8000, -9000, -10000, -11000, -12000, -13000],k = 7) == [-1000, -13000, -2000, -12000, -3000, -11000, -4000]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, -1, -10, -100, -1000, -10000, -100000],k = 6) == [100000, -100000, 10000, -10000, 1000, -1000]\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == [10, 9, 1, 8, 2, 7]\n assert candidate(arr = [-500, -300, -100, 100, 300, 500, 700, 900, 1100, 1300],k = 8) == [1300, 1100, -500, 900, -300, 700, -100, 500]\n assert candidate(arr = [-5, -5, -5, -5, -5, 5, 5, 5, 5, 5],k = 8) == [5, 5, 5, 5, 5, -5, -5, -5]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 7) == [-1, -2, -10, -3, -9, -4, -8]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == [20, 19, 1, 18, 2, 17, 3, 16, 4, 15]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == [19, 17, 1, 15, 3]\n assert candidate(arr = [23, 45, 12, 67, 34, 89, 90, 21, 56, 78, 9, 34, 56, 78, 90],k = 10) == [9, 12, 21, 90, 90, 89, 23, 78, 78, 34]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 7) == [1000, 900, 100, 800, 200, 700, 300]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == [5, 5, 5, 5]\n assert candidate(arr = [-10, -5, 0, 5, 10, 15, 20, 25, 30],k = 5) == [30, -10, 25, -5, 20]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == [15, 1, 14, 2, 13, 3, 12]\n assert candidate(arr = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 8) == [39, 37, 1, 35, 3, 33, 5, 31]\n assert candidate(arr = [9, 3, 7, -1, 2, 5, 8, -4, 6],k = 5) == [-4, -1, 9, 8, 2]\n assert candidate(arr = [-100, 100, -50, 50, 0],k = 3) == [100, -100, 50]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 10) == [150, 10, 140, 20, 130, 30, 120, 40, 110, 50]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 7) == [29, 1, 27, 3, 25, 5, 23]\n assert candidate(arr = [-20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40],k = 6) == [40, -20, 35, -15, 30, -10]\n assert candidate(arr = [-50, -40, -30, -20, -10, 10, 20, 30, 40, 50],k = 6) == [50, 40, 30, -50, 20, -40]\n assert candidate(arr = [10, -20, 30, -40, 50, -60, 70],k = 5) == [-60, 70, -40, 50, -20]\n assert candidate(arr = [-1, -2, -3, -4, -5, 5, 4, 3, 2, 1],k = 5) == [5, 4, 3, -5, 2]\n assert candidate(arr = [5, 3, 1, 2, 4, 6, 8, 7, 9, 10],k = 4) == [10, 9, 1, 8]\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 6) == [5, 4, 3, -5, 2, -4]\n assert candidate(arr = [100000, -100000, 99999, -99999, 0, 1, -1],k = 4) == [100000, -100000, 99999, -99999]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 4) == [1000, 900, 100, 800]\n assert candidate(arr = [-29, -27, -25, -23, -21, -19, -17, -15, -13, -11, -9, -7, -5, -3, -1],k = 5) == [-1, -29, -3, -27, -5]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == [15, 1, 14, 2, 13, 3, 12, 4, 11, 5]\n assert candidate(arr = [-100, 0, 50, 100, 200],k = 3) == [200, -100, 100]\n assert candidate(arr = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10],k = 10) == [10, -10, 9, -9, 8, -8, 7, -7, 6, -6]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == [150, 10, 140, 20, 130, 30, 120]\n assert candidate(arr = [-100000, 100000, 0, 50000, -50000],k = 3) == [100000, -100000, 50000]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 12) == [1500, 100, 1400, 200, 1300, 300, 1200, 400, 1100, 500, 1000, 600]\n assert candidate(arr = [-10, -20, -30, 0, 10, 20, 30, 40, 50, 60],k = 4) == [60, 50, -30, 40]\n assert candidate(arr = [10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 40, 40, 40, 40, 40],k = 15) == [40, 40, 40, 40, 40, 30, 30, 30, 30, 30, 10, 10, 10, 10, 10]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 10) == [29, 1, 27, 3, 25, 5, 23, 7, 21, 9]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 15) == [39, 37, 1, 35, 3, 33, 5, 31, 7, 29, 9, 27, 11, 25, 13]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 7) == [9, 8, -10, 7, -9, 6, -8]\n"}, "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().getStrongest", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getStrongest(self, arr: list[int], k: int) -> list[int]:", "container": "Solution", "callable": "getStrongest", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1473, "task_id": "paint-house-iii", "difficulty": "Hard", "problem_description": "There is a row of m houses in a small city, each house must be painted with one of the n colors (labeled from 1 to n), some houses that have been painted last summer should not be painted again.\nA neighborhood is a maximal group of continuous houses that are painted with the same color.\n\nFor example: houses = [1,2,2,3,3,2,1,1] contains 5 neighborhoods [{1}, {2,2}, {3,3}, {2}, {1,1}].\n\nGiven an array houses, an m x n matrix cost and an integer target where:\n\nhouses[i]: is the color of the house i, and 0 if the house is not painted yet.\ncost[i][j]: is the cost of paint the house i with the color j + 1.\n\nReturn the minimum cost of painting all the remaining houses in such a way that there are exactly target neighborhoods. If it is not possible, return -1.\n \nExample 1:\n\nInput: houses = [0,0,0,0,0], cost = [[1,10],[10,1],[10,1],[1,10],[5,1]], m = 5, n = 2, target = 3\nOutput: 9\nExplanation: Paint houses of this way [1,2,2,1,1]\nThis array contains target = 3 neighborhoods, [{1}, {2,2}, {1,1}].\nCost of paint all houses (1 + 1 + 1 + 1 + 5) = 9.\n\nExample 2:\n\nInput: houses = [0,2,1,2,0], cost = [[1,10],[10,1],[10,1],[1,10],[5,1]], m = 5, n = 2, target = 3\nOutput: 11\nExplanation: Some houses are already painted, Paint the houses of this way [2,2,1,2,2]\nThis array contains target = 3 neighborhoods, [{2,2}, {1}, {2,2}]. \nCost of paint the first and last house (10 + 1) = 11.\n\nExample 3:\n\nInput: houses = [3,1,2,3], cost = [[1,1,1],[1,1,1],[1,1,1],[1,1,1]], m = 4, n = 3, target = 3\nOutput: -1\nExplanation: Houses are already painted with a total of 4 neighborhoods [{3},{1},{2},{3}] different of target = 3.\n\n \nConstraints:\n\nm == houses.length == cost.length\nn == cost[i].length\n1 <= m <= 100\n1 <= n <= 20\n1 <= target <= m\n0 <= houses[i] <= n\n1 <= cost[i][j] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(houses = [1, 0, 0, 0, 0],cost = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],m = 5,n = 2,target = 2) == 15\n assert candidate(houses = [0, 0, 0, 0, 0],cost = [[10, 20, 30, 40], [20, 30, 40, 50], [30, 40, 50, 60], [40, 50, 60, 70], [50, 60, 70, 80]],m = 5,n = 4,target = 3) == 160\n assert candidate(houses = [1, 2, 3, 4, 5],cost = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],m = 5,n = 5,target = 5) == 0\n assert candidate(houses = [3, 1, 2, 3],cost = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],m = 4,n = 3,target = 3) == -1\n assert candidate(houses = [1, 0, 1, 0, 0],cost = [[1, 2], [3, 4], [1, 2], [3, 4], [1, 2]],m = 5,n = 2,target = 2) == 8\n assert candidate(houses = [0, 2, 1, 2, 0],cost = [[1, 10], [10, 1], [10, 1], [1, 10], [5, 1]],m = 5,n = 2,target = 3) == 11\n assert candidate(houses = [0, 1, 0, 0, 0],cost = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],m = 5,n = 2,target = 2) == 5\n assert candidate(houses = [0, 0, 0, 0, 0],cost = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],m = 5,n = 3,target = 2) == 36\n assert candidate(houses = [0, 0, 0, 0, 0, 0],cost = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],m = 6,n = 2,target = 1) == 6\n assert candidate(houses = [1, 0, 2, 0, 3],cost = [[5, 8, 6], [19, 14, 13], [7, 5, 5], [3, 6, 14], [2, 11, 1]],m = 5,n = 3,target = 3) == 20\n assert candidate(houses = [1, 0, 3, 0, 2],cost = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],m = 5,n = 3,target = 3) == 2\n assert candidate(houses = [0, 0, 0, 0, 0],cost = [[1, 10], [10, 1], [10, 1], [1, 10], [5, 1]],m = 5,n = 2,target = 3) == 9\n assert candidate(houses = [0, 0, 0],cost = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],m = 3,n = 3,target = 2) == 13\n assert candidate(houses = [0, 0, 0, 0, 0],cost = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]],m = 5,n = 4,target = 2) == 16\n assert candidate(houses = [0, 2, 0, 0, 0, 1, 0, 0, 0, 0],cost = [[10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 20, 30]],m = 10,n = 3,target = 5) == 100\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0],cost = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],m = 7,n = 5,target = 7) == 7\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 4, 7, 2, 8, 6], [5, 9, 1, 3, 4, 7], [9, 3, 5, 6, 2, 8], [8, 6, 9, 1, 7, 4], [7, 5, 8, 9, 3, 2], [6, 8, 4, 5, 9, 1], [3, 7, 9, 8, 6, 5], [2, 9, 6, 7, 4, 8], [8, 1, 4, 2, 9, 6], [6, 2, 8, 3, 1, 9]],m = 10,n = 6,target = 5) == 22\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3], [4, 5, 6]],m = 8,n = 3,target = 4) == 31\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[2, 5, 1], [1, 2, 5], [5, 1, 2], [2, 5, 1], [1, 2, 5], [5, 1, 2], [2, 5, 1], [1, 2, 5], [5, 1, 2], [2, 5, 1], [1, 2, 5]],m = 11,n = 3,target = 5) == 19\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [5, 5, 5, 5, 5], [1, 1, 1, 1, 1], [10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [2, 4, 6, 8, 10], [10, 8, 6, 4, 2], [1, 1, 1, 1, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 6, 9, 12, 15], [15, 12, 9, 6, 3], [3, 2, 1, 4, 5], [5, 4, 3, 2, 1]],m = 15,n = 5,target = 7) == 53\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0],cost = [[1, 4, 3], [3, 2, 1], [2, 1, 4], [1, 3, 2], [4, 3, 1], [2, 1, 3], [3, 2, 4]],m = 7,n = 3,target = 4) == 10\n assert candidate(houses = [1, 0, 0, 2, 0, 0, 0, 0, 0, 3],cost = [[1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3]],m = 10,n = 3,target = 6) == 9\n assert candidate(houses = [0, 3, 0, 1, 0, 2, 0, 0],cost = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]],m = 8,n = 4,target = 5) == 6\n assert candidate(houses = [0, 0, 1, 0, 0, 0, 0, 0],cost = [[1, 9, 3, 5], [3, 4, 1, 10], [7, 8, 4, 5], [3, 2, 8, 5], [2, 6, 3, 7], [7, 1, 8, 3], [4, 2, 1, 4], [1, 4, 3, 9]],m = 8,n = 4,target = 5) == 11\n assert candidate(houses = [0, 2, 0, 2, 0, 2],cost = [[10, 20, 30, 40], [20, 30, 10, 40], [30, 10, 20, 40], [10, 40, 20, 30], [20, 30, 40, 10], [30, 40, 10, 20]],m = 6,n = 4,target = 3) == 40\n assert candidate(houses = [1, 0, 0, 0, 0, 0, 0, 0, 0, 2],cost = [[10, 20, 30, 40], [1, 2, 3, 4], [10, 20, 30, 40], [1, 2, 3, 4], [10, 20, 30, 40], [1, 2, 3, 4], [10, 20, 30, 40], [1, 2, 3, 4], [10, 20, 30, 40], [1, 2, 3, 4]],m = 10,n = 4,target = 4) == 45\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]],m = 10,n = 10,target = 5) == 57\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],m = 11,n = 11,target = 3) == 11\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[5, 3, 2, 1, 4], [3, 2, 1, 4, 5], [2, 1, 4, 5, 3], [1, 4, 5, 3, 2], [4, 5, 3, 2, 1], [5, 4, 3, 2, 1], [4, 3, 2, 1, 5], [3, 2, 1, 5, 4], [2, 1, 5, 4, 3], [1, 5, 4, 3, 2]],m = 10,n = 5,target = 4) == 16\n assert candidate(houses = [0, 2, 0, 2, 0, 2, 0, 2, 0, 2],cost = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8], [6, 7, 8, 9], [7, 8, 9, 10], [8, 9, 10, 11], [9, 10, 11, 12], [10, 11, 12, 13]],m = 10,n = 4,target = 5) == 28\n assert candidate(houses = [0, 2, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[10, 10, 10], [1, 2, 3], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]],m = 10,n = 3,target = 3) == 90\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2]],m = 15,n = 2,target = 7) == 19\n assert candidate(houses = [0, 0, 0, 2, 0, 0, 0, 0],cost = [[4, 3, 1, 2], [9, 1, 4, 8], [5, 7, 9, 6], [1, 1, 5, 2], [8, 5, 3, 3], [4, 6, 1, 9], [2, 3, 7, 7], [7, 4, 8, 5]],m = 8,n = 4,target = 4) == 20\n assert candidate(houses = [0, 0, 0, 1, 0, 0, 0],cost = [[2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1]],m = 7,n = 3,target = 4) == 8\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0],cost = [[10, 15], [15, 10], [20, 25], [25, 20], [30, 35], [35, 30], [40, 45], [45, 40]],m = 8,n = 2,target = 6) == 205\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0],cost = [[4, 8, 2], [1, 10, 9], [6, 4, 8], [10, 2, 9], [3, 7, 5], [8, 3, 2], [1, 6, 5], [2, 4, 3]],m = 8,n = 3,target = 3) == 24\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0],cost = [[7, 5, 9], [9, 7, 5], [5, 9, 7], [7, 5, 9], [9, 7, 5], [5, 9, 7], [7, 5, 9], [9, 7, 5]],m = 8,n = 3,target = 5) == 46\n assert candidate(houses = [0, 3, 0, 2, 0, 1, 0, 0],cost = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],m = 8,n = 4,target = 4) == 5\n assert candidate(houses = [2, 0, 2, 0, 2, 0, 2, 0],cost = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 2, 1]],m = 8,n = 3,target = 3) == 6\n assert candidate(houses = [0, 0, 2, 1, 0, 0, 3],cost = [[10, 8, 6, 4, 2], [9, 7, 5, 3, 1], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [5, 10, 15, 20, 25], [100, 90, 80, 70, 60], [30, 25, 20, 15, 10]],m = 7,n = 5,target = 4) == 80\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9]],m = 7,n = 3,target = 4) == 30\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8], [6, 7, 8, 9], [7, 8, 9, 10]],m = 7,n = 4,target = 4) == 30\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]],m = 20,n = 2,target = 10) == 25\n assert candidate(houses = [0, 0, 1, 0, 0, 0],cost = [[1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1], [3, 1, 2]],m = 6,n = 3,target = 4) == 6\n assert candidate(houses = [0, 2, 0, 2, 0, 2, 0, 2, 0, 2],cost = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]],m = 10,n = 2,target = 5) == 28\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]],m = 10,n = 2,target = 5) == 13\n assert candidate(houses = [0, 0, 0, 1, 0, 0, 0, 0],cost = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 4, 2, 3], [3, 2, 4, 1], [1, 2, 3, 4], [4, 3, 2, 1], [1, 4, 2, 3], [3, 2, 4, 1]],m = 8,n = 4,target = 5) == 9\n assert candidate(houses = [0, 0, 3, 0, 0, 0, 0],cost = [[1, 3, 2], [3, 1, 4], [1, 2, 3], [3, 2, 1], [1, 3, 2], [3, 2, 1], [1, 2, 3]],m = 7,n = 3,target = 3) == 9\n assert candidate(houses = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0],cost = [[100, 100, 100], [50, 50, 50], [100, 100, 100], [50, 50, 50], [100, 100, 100], [50, 50, 50], [100, 100, 100], [50, 50, 50], [100, 100, 100], [50, 50, 50]],m = 10,n = 3,target = 5) == 250\n assert candidate(houses = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],m = 11,n = 10,target = 6) == 66\n assert candidate(houses = [1, 0, 2, 0, 3, 0, 4, 0],cost = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],m = 8,n = 5,target = 4) == 10\n assert candidate(houses = [0, 1, 0, 2, 0, 0, 0],cost = [[1, 10, 100, 1000], [10, 100, 1000, 10000], [100, 1000, 10000, 100000], [1000, 10000, 100000, 1000000], [10, 100, 1000, 10000], [100, 1000, 10000, 100000], [1000, 10000, 100000, 1000000]],m = 7,n = 4,target = 3) == 1211\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],m = 20,n = 2,target = 10) == 20\n assert candidate(houses = [0, 1, 2, 0, 0, 0, 0],cost = [[1, 2, 3], [2, 3, 1], [3, 1, 2], [4, 5, 6], [5, 6, 4], [6, 4, 5], [7, 8, 9]],m = 7,n = 3,target = 5) == 21\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[3, 2, 1, 8, 9], [7, 8, 6, 4, 5], [2, 4, 3, 1, 8], [9, 1, 5, 7, 3], [4, 9, 2, 3, 7], [5, 3, 8, 1, 4], [1, 7, 2, 8, 6], [8, 6, 4, 9, 2], [3, 1, 7, 2, 5]],m = 9,n = 5,target = 4) == 24\n assert candidate(houses = [1, 0, 2, 0, 3, 0, 1, 0, 2],cost = [[10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]],m = 9,n = 3,target = 6) == 40\n assert candidate(houses = [0, 1, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]],m = 20,n = 4,target = 12) == 23\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],m = 10,n = 3,target = 10) == 10\n assert candidate(houses = [0, 2, 0, 0, 0, 2, 0],cost = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]],m = 7,n = 3,target = 3) == 25\n assert candidate(houses = [0, 0, 0, 1, 0, 0, 0, 0, 0],cost = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6], [7, 7, 7, 7, 7, 7, 7, 7, 7], [8, 8, 8, 8, 8, 8, 8, 8, 8], [9, 9, 9, 9, 9, 9, 9, 9, 9]],m = 9,n = 9,target = 6) == 41\n assert candidate(houses = [1, 0, 1, 0, 1, 0, 1],cost = [[10, 20, 30], [30, 10, 20], [20, 30, 10], [10, 20, 30], [30, 10, 20], [20, 30, 10], [10, 20, 30]],m = 7,n = 3,target = 3) == 40\n assert candidate(houses = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],cost = [[1, 10], [10, 1], [1, 10], [10, 1], [1, 10], [10, 1], [1, 10], [10, 1], [1, 10], [10, 1]],m = 10,n = 2,target = 5) == 32\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12]],m = 10,n = 3,target = 5) == 57\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]],m = 10,n = 2,target = 5) == 13\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],m = 15,n = 2,target = 8) == 15\n assert candidate(houses = [0, 2, 0, 1, 0, 3, 0],cost = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 1, 4, 3], [3, 4, 1, 2], [1, 4, 3, 2], [2, 3, 4, 1], [4, 1, 2, 3]],m = 7,n = 4,target = 5) == 4\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[7, 2, 1, 9, 5, 6, 3, 8], [8, 7, 6, 3, 9, 1, 5, 4], [2, 1, 8, 7, 6, 9, 4, 3], [5, 6, 7, 8, 2, 1, 9, 4], [9, 4, 5, 6, 7, 8, 2, 1], [3, 9, 4, 5, 6, 7, 8, 2], [1, 3, 9, 4, 5, 6, 7, 8], [6, 1, 3, 9, 4, 5, 6, 7], [7, 6, 1, 3, 9, 4, 5, 6], [8, 7, 6, 1, 3, 9, 4, 5], [5, 8, 7, 6, 1, 3, 9, 4]],m = 11,n = 8,target = 6) == 21\n"}, "metadata": {"canonical_parameter_names": ["houses", "cost", "m", "n", "target"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minCost(self, houses: list[int], cost: list[list[int]], m: int, n: int, target: int) -> int:", "container": "Solution", "callable": "minCost", "parameters": [{"name": "houses", "type": "list[int]"}, {"name": "cost", "type": "list[list[int]]"}, {"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1475, "task_id": "final-prices-with-a-special-discount-in-a-shop", "difficulty": "Easy", "problem_description": "You are given an integer array prices where prices[i] is the price of the ith item in a shop.\nThere is a special discount for items in the shop. If you buy the ith item, then you will receive a discount equivalent to prices[j] where j is the minimum index such that j > i and prices[j] <= prices[i]. Otherwise, you will not receive any discount at all.\nReturn an integer array answer where answer[i] is the final price you will pay for the ith item of the shop, considering the special discount.\n \nExample 1:\n\nInput: prices = [8,4,6,2,3]\nOutput: [4,2,4,2,3]\nExplanation: \nFor item 0 with price[0]=8 you will receive a discount equivalent to prices[1]=4, therefore, the final price you will pay is 8 - 4 = 4.\nFor item 1 with price[1]=4 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 4 - 2 = 2.\nFor item 2 with price[2]=6 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 6 - 2 = 4.\nFor items 3 and 4 you will not receive any discount at all.\n\nExample 2:\n\nInput: prices = [1,2,3,4,5]\nOutput: [1,2,3,4,5]\nExplanation: In this case, for all items, you will not receive any discount at all.\n\nExample 3:\n\nInput: prices = [10,1,1,6]\nOutput: [9,0,1,6]\n\n \nConstraints:\n\n1 <= prices.length <= 500\n1 <= prices[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(prices = [5, 5, 5, 5, 5]) == [0, 0, 0, 0, 5]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [8, 4, 6, 2, 3]) == [4, 2, 4, 2, 3]\n assert candidate(prices = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(prices = [9, 8, 7, 6, 5]) == [1, 1, 1, 1, 5]\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(prices = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == [1, 3, 5, 7, 9, 11, 13, 15, 17]\n assert candidate(prices = [60, 70, 80, 90, 100]) == [60, 70, 80, 90, 100]\n assert candidate(prices = [10, 10, 10, 10, 10, 10]) == [0, 0, 0, 0, 0, 10]\n assert candidate(prices = [5, 1, 4, 2, 3]) == [4, 1, 2, 2, 3]\n assert candidate(prices = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(prices = [100, 50, 25, 12, 6, 3, 1]) == [50, 25, 13, 6, 3, 2, 1]\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [10, 1, 1, 6]) == [9, 0, 1, 6]\n assert candidate(prices = [1, 2, 3, 2, 1]) == [0, 0, 1, 1, 1]\n assert candidate(prices = [5, 1, 3, 4, 6, 2]) == [4, 1, 1, 2, 4, 2]\n assert candidate(prices = [3, 3, 3, 2, 2, 1]) == [0, 0, 1, 0, 1, 1]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [100, 90, 80, 70, 60]) == [10, 10, 10, 10, 60]\n assert candidate(prices = [100, 200, 300, 200, 100]) == [0, 0, 100, 100, 100]\n assert candidate(prices = [1, 1, 1, 1, 1]) == [0, 0, 0, 0, 1]\n assert candidate(prices = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(prices = [2, 3, 1]) == [1, 2, 1]\n assert candidate(prices = [100, 50, 50, 100, 50, 25, 25, 100]) == [50, 0, 0, 50, 25, 0, 25, 100]\n assert candidate(prices = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10]) == [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 5, 10]\n assert candidate(prices = [100, 50, 25, 12, 6, 3, 1, 0, 0, 0]) == [50, 25, 13, 6, 3, 2, 1, 0, 0, 0]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]\n assert candidate(prices = [1, 2, 3, 2, 3, 4, 5, 4, 5, 6]) == [1, 0, 1, 2, 3, 0, 1, 4, 5, 6]\n assert candidate(prices = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2]\n assert candidate(prices = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(prices = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]\n assert candidate(prices = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == [1, 98, 2, 96, 3, 94, 4, 92, 5, 96]\n assert candidate(prices = [10, 10, 10, 10, 10, 10, 10, 10]) == [0, 0, 0, 0, 0, 0, 0, 10]\n assert candidate(prices = [10, 5, 15, 5, 20, 10, 25, 15, 30, 20]) == [5, 0, 10, 5, 10, 10, 10, 15, 10, 20]\n assert candidate(prices = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4]) == [1, 1, 1, 1, 1, 1, 1, 2, 3, 4]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [7, 5, 6, 4, 3, 2, 1, 8, 9, 10]) == [2, 1, 2, 1, 1, 1, 1, 8, 9, 10]\n assert candidate(prices = [2, 3, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1]) == [0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1]\n assert candidate(prices = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4, 1, 2, 3, 4, 5]\n assert candidate(prices = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [0, 8, 1, 6, 2, 4, 3, 2, 4, 5, 1, 8, 2, 6, 3, 4, 4, 2, 5, 6]\n assert candidate(prices = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1000]\n assert candidate(prices = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]\n assert candidate(prices = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == [0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5]\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(prices = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == [500, 250, 125, 63, 31, 16, 8, 4, 2, 1]\n assert candidate(prices = [10, 20, 30, 40, 50, 40, 30, 20, 10]) == [0, 0, 0, 0, 10, 10, 10, 10, 10]\n assert candidate(prices = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [0, 10, 0, 10, 0, 10, 0, 10, 10, 20]\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == [0, 0, 1, 1, 0, 0, 1, 1, 1]\n assert candidate(prices = [30, 20, 10, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == [10, 10, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10]\n assert candidate(prices = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == [1, 1, 1, 1, 1, 2, 3, 4, 5]\n assert candidate(prices = [8, 6, 7, 6, 5, 4, 3, 2, 1]) == [2, 0, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(prices = [300, 200, 100, 50, 25, 12, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100, 100, 50, 25, 13, 6, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(prices = [8, 4, 6, 2, 3, 8, 4, 6, 2, 3]) == [4, 2, 4, 0, 1, 4, 2, 4, 2, 3]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == [1, 1, 2, 1, 3, 1, 4, 1, 5, 7]\n assert candidate(prices = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]\n assert candidate(prices = [15, 10, 5, 10, 15, 5, 10, 15, 20, 10]) == [5, 5, 0, 5, 10, 5, 0, 5, 10, 10]\n assert candidate(prices = [10, 20, 30, 10, 20, 30, 10, 20, 30]) == [0, 10, 20, 0, 10, 20, 10, 20, 30]\n assert candidate(prices = [3, 6, 5, 1, 8, 7, 9, 2, 4, 10]) == [2, 1, 4, 1, 1, 5, 7, 2, 4, 10]\n assert candidate(prices = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == [0, 1, 0, 1, 0, 1, 0, 1, 2, 3]\n assert candidate(prices = [8, 5, 7, 6, 4, 5, 3, 2, 1]) == [3, 1, 1, 2, 1, 2, 1, 1, 1]\n assert candidate(prices = [100, 50, 25, 12, 6, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [50, 25, 13, 6, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [50, 20, 30, 10, 20, 30, 40, 50, 60, 70]) == [30, 10, 20, 10, 20, 30, 40, 50, 60, 70]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -5]\n assert candidate(prices = [500, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == [400, 100, 200, 300, 400, 500, 600, 700, 800, 900]\n assert candidate(prices = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == [99, 1, 198, 2, 297, 3, 396, 4, 495, 5]\n assert candidate(prices = [999, 1000, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == [1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 980]\n assert candidate(prices = [100, 200, 150, 250, 300, 220, 180, 160, 170]) == [100, 50, 150, 30, 80, 40, 20, 160, 170]\n assert candidate(prices = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(prices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(prices = [5, 10, 15, 20, 15, 10, 5, 10, 15, 20, 15, 10, 5]) == [0, 0, 0, 5, 5, 5, 0, 0, 0, 5, 5, 5, 5]\n assert candidate(prices = [3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5]) == [0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 5]\n assert candidate(prices = [5, 15, 25, 10, 20, 5, 30, 25, 40, 10]) == [0, 5, 15, 5, 15, 5, 5, 15, 30, 10]\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 1]\n assert candidate(prices = [8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5]\n assert candidate(prices = [1000, 1000, 1000, 1000, 1000]) == [0, 0, 0, 0, 1000]\n assert candidate(prices = [5, 1, 4, 3, 2, 6, 7, 8, 10, 9]) == [4, 1, 1, 1, 2, 6, 7, 8, 1, 9]\n assert candidate(prices = [8, 4, 6, 2, 3, 5, 7, 1, 9, 10]) == [4, 2, 4, 1, 2, 4, 6, 1, 9, 10]\n assert candidate(prices = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]) == [100, 100, 100, 100, 50, 25, 13, 6, 3, 2, 1]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(prices = [250, 200, 150, 100, 50, 100, 150, 200, 250, 300]) == [50, 50, 50, 50, 50, 100, 150, 200, 250, 300]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [30, 25, 20, 15, 10, 5, 10, 15, 20, 25]) == [5, 5, 5, 5, 5, 5, 10, 15, 20, 25]\n assert candidate(prices = [4, 3, 2, 1, 2, 3, 4, 5, 6, 7]) == [1, 1, 1, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(prices = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == [1, 1, 1, 1, 0, 1, 2, 3, 4, 5]\n assert candidate(prices = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n assert candidate(prices = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 50]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(prices = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10]) == [0, 5, 0, 5, 0, 5, 0, 5, 5, 10]\n assert candidate(prices = [7, 6, 5, 4, 3, 2, 1, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 0, 0, 0]\n assert candidate(prices = [1, 2, 2, 1, 1, 2, 2, 1, 1]) == [0, 0, 1, 0, 0, 0, 1, 0, 1]\n assert candidate(prices = [100, 50, 25, 200, 100, 50, 25, 200]) == [50, 25, 0, 100, 50, 25, 25, 200]\n assert candidate(prices = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == [1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8]\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 2, 3]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 10]\n assert candidate(prices = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 2]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(prices = [1, 3, 2, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == [0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5]) == [0, 0, 0, 0, 10, 10, 10, 10, 5, 5]\n assert candidate(prices = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5]\n assert candidate(prices = [50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == [10, 10, 10, 10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]\n assert candidate(prices = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == [4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4]\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [50, 25, 75, 100, 50, 75, 100, 125]) == [25, 25, 25, 50, 50, 75, 100, 125]\n assert candidate(prices = [100, 200, 300, 400, 500, 400, 300, 200, 100]) == [0, 0, 0, 0, 100, 100, 100, 100, 100]\n"}, "metadata": {"canonical_parameter_names": ["prices"], "leetcode_dataset_entry_point": "Solution().finalPrices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def finalPrices(self, prices: list[int]) -> list[int]:", "container": "Solution", "callable": "finalPrices", "parameters": [{"name": "prices", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1477, "task_id": "find-two-non-overlapping-sub-arrays-each-with-target-sum", "difficulty": "Medium", "problem_description": "You are given an array of integers arr and an integer target.\nYou have to find two non-overlapping sub-arrays of arr each with a sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum.\nReturn the minimum sum of the lengths of the two required sub-arrays, or return -1 if you cannot find such two sub-arrays.\n \nExample 1:\n\nInput: arr = [3,2,2,4,3], target = 3\nOutput: 2\nExplanation: Only two sub-arrays have sum = 3 ([3] and [3]). The sum of their lengths is 2.\n\nExample 2:\n\nInput: arr = [7,3,4,7], target = 7\nOutput: 2\nExplanation: Although we have three non-overlapping sub-arrays of sum = 7 ([7], [3,4] and [7]), but we will choose the first and third sub-arrays as the sum of their lengths is 2.\n\nExample 3:\n\nInput: arr = [4,3,2,6,2,3,4], target = 6\nOutput: -1\nExplanation: We have only one sub-array of sum = 6.\n\n \nConstraints:\n\n1 <= arr.length <= 105\n1 <= arr[i] <= 1000\n1 <= target <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 5, 5, 5, 5],target = 10) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 6) == 6\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3],target = 6) == 5\n assert candidate(arr = [1, 2, 3, 4, 5],target = 9) == -1\n assert candidate(arr = [3, 2, 2, 4, 3],target = 3) == 2\n assert candidate(arr = [5, 5, 4, 4, 5],target = 9) == 4\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 4) == 4\n assert candidate(arr = [1000, 1000, 1000],target = 2000) == -1\n assert candidate(arr = [7, 3, 4, 7],target = 7) == 2\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000],target = 2000) == 4\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3],target = 3) == 2\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],target = 3) == 4\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000],target = 5000) == -1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 4\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [1, 2, 3, 4, 5],target = 10) == -1\n assert candidate(arr = [10, 20, 30, 40, 50],target = 60) == -1\n assert candidate(arr = [1, 4, 4, 4, 4, 4, 4, 4, 4, 1],target = 8) == 4\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [4, 3, 2, 6, 2, 3, 4],target = 6) == -1\n assert candidate(arr = [10, 20, 30, 40, 50],target = 90) == -1\n assert candidate(arr = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1],target = 1000) == 4\n assert candidate(arr = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],target = 50) == 4\n assert candidate(arr = [3, 1, 2, 4, 3, 2, 1, 3, 4, 2, 1, 3, 5, 2, 1, 3, 4, 2, 1, 3],target = 6) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],target = 30) == 4\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 15) == 3\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 500) == -1\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 300) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],target = 100) == 13\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 20) == 8\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == -1\n assert candidate(arr = [1, 3, 2, 1, 5, 2, 3, 1, 4, 2, 3, 1, 5, 2, 3, 1, 4, 2, 3, 1],target = 6) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15) == 3\n assert candidate(arr = [1, 4, 2, 3, 5, 7, 9, 11, 13, 15],target = 15) == 4\n assert candidate(arr = [5, 1, 3, 5, 10, 7, 4, 9, 2, 8, 6],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 4\n assert candidate(arr = [1, 4, 4, 1, 1, 2, 3, 5, 3, 2, 3, 4, 1],target = 8) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 10\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 30) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 20\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 20) == 8\n assert candidate(arr = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50],target = 60) == 4\n assert candidate(arr = [9, 1, 2, 3, 9, 4, 5, 9, 6, 7, 8, 9],target = 9) == 2\n assert candidate(arr = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],target = 6) == 6\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [5, 2, 3, 4, 1, 5, 2, 3, 4, 1, 5, 2, 3, 4, 1, 5, 2, 3, 4, 1],target = 10) == 6\n assert candidate(arr = [5, 1, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3],target = 9) == -1\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1500) == 5\n assert candidate(arr = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 4\n assert candidate(arr = [7, 8, 3, 4, 7, 6, 5, 4, 3, 2, 1],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 20) == -1\n assert candidate(arr = [7, 1, 3, 1, 2, 1, 3, 1, 7, 1, 3, 1, 2, 1, 3, 1, 7, 1, 3, 1, 2, 1, 3, 1, 7, 1, 3, 1],target = 10) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 10\n assert candidate(arr = [5, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 21) == 5\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],target = 3000) == 8\n assert candidate(arr = [1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3],target = 8) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500],target = 600) == 5\n assert candidate(arr = [2, 3, 2, 2, 3, 3, 2, 2, 2, 3],target = 6) == 5\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1500) == 5\n assert candidate(arr = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300],target = 600) == 6\n assert candidate(arr = [5, 1, 3, 5, 2, 4, 8, 6, 3, 7],target = 10) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 30) == 8\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 5\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 10\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3],target = 5) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 4\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 400) == -1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == 40\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 100) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 9) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 20) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 4\n assert candidate(arr = [5, 1, 3, 5, 10, 7, 4, 9, 2, 8],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],target = 3) == 3\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],target = 4) == 6\n assert candidate(arr = [100, 200, 100, 300, 200, 400, 300, 500, 400, 600],target = 300) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 5\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500],target = 1000) == 8\n"}, "metadata": {"canonical_parameter_names": ["arr", "target"], "leetcode_dataset_entry_point": "Solution().minSumOfLengths", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minSumOfLengths(self, arr: list[int], target: int) -> int:", "container": "Solution", "callable": "minSumOfLengths", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1478, "task_id": "allocate-mailboxes", "difficulty": "Hard", "problem_description": "Given the array houses where houses[i] is the location of the ith house along a street and an integer k, allocate k mailboxes in the street.\nReturn the minimum total distance between each house and its nearest mailbox.\nThe test cases are generated so that the answer fits in a 32-bit integer.\n \nExample 1:\n\n\nInput: houses = [1,4,8,10,20], k = 3\nOutput: 5\nExplanation: Allocate mailboxes in position 3, 9 and 20.\nMinimum total distance from each houses to nearest mailboxes is |3-1| + |4-3| + |9-8| + |10-9| + |20-20| = 5 \n\nExample 2:\n\n\nInput: houses = [2,3,5,12,18], k = 2\nOutput: 9\nExplanation: Allocate mailboxes in position 3 and 14.\nMinimum total distance from each houses to nearest mailboxes is |2-3| + |3-3| + |5-3| + |12-14| + |18-14| = 9.\n\n \nConstraints:\n\n1 <= k <= houses.length <= 100\n1 <= houses[i] <= 104\nAll the integers of houses are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(houses = [10, 5, 17, 1, 18, 2, 12, 9],k = 3) == 8\n assert candidate(houses = [5, 10, 15, 20, 25],k = 2) == 15\n assert candidate(houses = [3, 6, 14, 10],k = 4) == 0\n assert candidate(houses = [3, 6, 14, 16, 25, 28, 30],k = 2) == 26\n assert candidate(houses = [1, 4, 8, 10, 20],k = 3) == 5\n assert candidate(houses = [1, 10000],k = 1) == 9999\n assert candidate(houses = [1, 2, 3, 4, 5],k = 1) == 6\n assert candidate(houses = [2, 3, 5, 12, 18],k = 2) == 9\n assert candidate(houses = [7, 4, 6, 1],k = 1) == 8\n assert candidate(houses = [5, 7, 10, 11, 12, 16],k = 3) == 4\n assert candidate(houses = [5, 10, 15, 20, 25, 30],k = 2) == 20\n assert candidate(houses = [8, 5, 2, 9, 6],k = 2) == 5\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 5\n assert candidate(houses = [10, 20, 30, 40, 50],k = 5) == 0\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 5) == 200\n assert candidate(houses = [1, 6, 9, 12, 17, 23, 30],k = 4) == 12\n assert candidate(houses = [2, 5, 7, 12, 16, 22, 26, 30, 35],k = 3) == 24\n assert candidate(houses = [1, 3, 6, 8, 12, 15, 18, 22],k = 4) == 10\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125],k = 6) == 70\n assert candidate(houses = [2, 6, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 28\n assert candidate(houses = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29],k = 4) == 18\n assert candidate(houses = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50],k = 5) == 42\n assert candidate(houses = [1, 3, 6, 8, 12, 15, 18, 22, 25, 28, 30, 33, 36, 39, 42, 45, 48],k = 6) == 32\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 100\n assert candidate(houses = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 7) == 465\n assert candidate(houses = [1, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 15) == 159\n assert candidate(houses = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990],k = 15) == 633\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 10\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 20) == 0\n assert candidate(houses = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 599\n assert candidate(houses = [1, 10, 100, 1000, 10000],k = 2) == 1089\n assert candidate(houses = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 5) == 65025\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 100\n assert candidate(houses = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 2) == 111098889\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 10\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 20\n assert candidate(houses = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 3) == 225\n assert candidate(houses = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == 999\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 100\n assert candidate(houses = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115, 121, 127, 133, 139, 145, 151, 157, 163, 169, 175],k = 15) == 90\n assert candidate(houses = [1, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 89\n assert candidate(houses = [10, 25, 62, 155, 387, 967, 2417, 6042, 15105, 37762, 94405, 236012],k = 6) == 3674\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 2) == 60\n assert candidate(houses = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],k = 4) == 8001\n assert candidate(houses = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90],k = 15) == 45\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 10) == 50\n assert candidate(houses = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90],k = 10) == 60\n assert candidate(houses = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145, 160, 175, 190, 200],k = 8) == 85\n assert candidate(houses = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],k = 8) == 701\n assert candidate(houses = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101],k = 16) == 40\n assert candidate(houses = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27],k = 3) == 23\n assert candidate(houses = [1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200],k = 8) == 5871\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 10\n assert candidate(houses = [2, 8, 14, 20, 26, 32, 38, 44, 50, 56],k = 5) == 30\n assert candidate(houses = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961],k = 12) == 539\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205],k = 5) == 220\n assert candidate(houses = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 109\n assert candidate(houses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5) == 10\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],k = 10) == 100\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 100\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 50\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],k = 5) == 16\n assert candidate(houses = [2, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 11) == 48\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 10) == 50\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],k = 8) == 40\n assert candidate(houses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 3) == 36\n assert candidate(houses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],k = 10) == 30\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225],k = 13) == 100\n assert candidate(houses = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],k = 10) == 3969\n assert candidate(houses = [5, 15, 45, 135, 405, 1215, 3645, 10935, 32805, 98415],k = 5) == 1690\n assert candidate(houses = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101],k = 8) == 80\n assert candidate(houses = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],k = 5) == 199\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 50\n assert candidate(houses = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 5) == 35\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 6) == 90\n assert candidate(houses = [1, 5, 10, 20, 35, 55, 80, 110, 145, 185, 230],k = 3) == 189\n assert candidate(houses = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 7) == 139\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == 80\n assert candidate(houses = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 4) == 34\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 10\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],k = 15) == 20\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 100\n assert candidate(houses = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 2) == 131\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 80\n assert candidate(houses = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],k = 6) == 44\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 5\n assert candidate(houses = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 7) == 24\n assert candidate(houses = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],k = 6) == 154\n assert candidate(houses = [1, 3, 6, 8, 14, 15, 20, 25],k = 4) == 10\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],k = 7) == 60\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 4) == 24\n assert candidate(houses = [1, 3, 6, 10, 15, 21, 28, 36, 45],k = 4) == 24\n assert candidate(houses = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 7) == 465\n assert candidate(houses = [2, 8, 24, 64, 160, 416, 1040, 2608, 6528, 16384, 40960, 102400],k = 8) == 214\n assert candidate(houses = [2, 8, 15, 20, 26, 32, 40, 45, 50],k = 4) == 27\n assert candidate(houses = [7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77],k = 3) == 90\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 8\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500],k = 20) == 300\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 8) == 120\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 7) == 130\n assert candidate(houses = [1, 2, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 4) == 1697\n assert candidate(houses = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],k = 4) == 33\n assert candidate(houses = [3, 7, 11, 15, 19, 23, 27, 31],k = 3) == 20\n assert candidate(houses = [2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90],k = 6) == 39\n assert candidate(houses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100],k = 25) == 50\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 6) == 9\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 20\n assert candidate(houses = [1, 5, 9, 14, 20, 25, 30, 35, 40],k = 4) == 23\n"}, "metadata": {"canonical_parameter_names": ["houses", "k"], "leetcode_dataset_entry_point": "Solution().minDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minDistance(self, houses: list[int], k: int) -> int:", "container": "Solution", "callable": "minDistance", "parameters": [{"name": "houses", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1480, "task_id": "running-sum-of-1d-array", "difficulty": "Easy", "problem_description": "Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]).\nReturn the running sum of nums.\n \nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: [1,3,6,10]\nExplanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].\nExample 2:\n\nInput: nums = [1,1,1,1,1]\nOutput: [1,2,3,4,5]\nExplanation: Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].\nExample 3:\n\nInput: nums = [3,1,2,10,1]\nOutput: [3,4,6,16,17]\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n-10^6 <= nums[i] <= 10^6\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 2, -3, 4, -5]) == [-1, 1, -2, 2, -3]\n assert candidate(nums = [-5]) == [-5]\n assert candidate(nums = [0, -1, 2, -3, 4]) == [0, -1, 1, -2, 2]\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0]\n assert candidate(nums = [1]) == [1]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000]) == [1000000, 0, 1000000, 0]\n assert candidate(nums = [1, 2, 3, 4]) == [1, 3, 6, 10]\n assert candidate(nums = [0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [0, 0, 0, 0]) == [0, 0, 0, 0]\n assert candidate(nums = [-1, -2, -3, -4]) == [-1, -3, -6, -10]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000, 1000000]) == [1000000, 0, 1000000, 0, 1000000]\n assert candidate(nums = [-1000000]) == [-1000000]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000]\n assert candidate(nums = [5]) == [5]\n assert candidate(nums = [1000000]) == [1000000]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000]) == [1000000, 0, 1000000, 0]\n assert candidate(nums = [3, 1, 2, 10, 1]) == [3, 4, 6, 16, 17]\n assert candidate(nums = [1000, -500, 250, -125, 62.5, -31.25, 15.625, -7.8125, 3.90625, -1.953125, 0.9765625, -0.48828125, 0.244140625, -0.1220703125, 0.06103515625]) == [1000, 500, 750, 625, 687.5, 656.25, 671.875, 664.0625, 667.96875, 666.015625, 666.9921875, 666.50390625, 666.748046875, 666.6259765625, 666.68701171875]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [5, 15, 30, 50, 75, 105, 140, 180, 225, 275, 330, 390, 455, 525, 600, 680, 765, 855, 950, 1050]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]) == [100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500, 6600, 7800, 9100]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 11, 111, 1111, 11111, 111111, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == [-1, -3, -6, -10, -15, -21, -28, -36, -45, -55, -66, -78, -91, -105, -120, -136, -153, -171, -190, -210]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [5, 20, 45, 80, 125, 180, 245, 320, 405, 500, 605]\n assert candidate(nums = [100, 50, -50, -100, 150, 200, -250, 300, -350, 400]) == [100, 150, 100, 0, 150, 350, 100, 400, 50, 450]\n assert candidate(nums = [-1000000, 500000, -250000, 125000, -62500]) == [-1000000, -500000, -750000, -625000, -687500]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == [-1, -3, -6, -10, -15, -21, -28, -36, -45, -55, -66, -78, -91, -105, -120]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]\n assert candidate(nums = [-1000000, -2000000, -3000000, -4000000, -5000000]) == [-1000000, -3000000, -6000000, -10000000, -15000000]\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000]) == [1000, 0, 2000, 0, 3000, 0, 4000, 0, 5000, 0]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == [10, 0, 20, 0, 30, 0, 40, 0, 50, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 19, 27, 34, 40, 45, 49, 52, 54, 55]\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == [999999, 1888887, 2666664, 3333330, 3888885, 4333329, 4666662, 4888884, 4999995]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 39, 57, 74, 90, 105, 119, 132, 144, 155, 165, 174, 182, 189, 195, 200, 204, 207, 209, 210]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == [10, 0, 20, 0, 30, 0]\n assert candidate(nums = [-1000, -2000, -3000, -4000, -5000, -6000, -7000, -8000, -9000, -10000]) == [-1000, -3000, -6000, -10000, -15000, -21000, -28000, -36000, -45000, -55000]\n assert candidate(nums = [500000, -500000, 500000, -500000, 500000, -500000, 500000, -500000, 500000, -500000]) == [500000, 0, 500000, 0, 500000, 0, 500000, 0, 500000, 0]\n assert candidate(nums = [5, -5, 15, -15, 25, -25]) == [5, 0, 15, 0, 25, 0]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000, 1000000]) == [1000000, 0, 1000000, 0, 1000000]\n assert candidate(nums = [1000000, -500000, 500000, -250000, 250000]) == [1000000, 500000, 1000000, 750000, 1000000]\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == [10000, 30000, 60000, 100000, 150000, 210000, 280000, 360000, 450000, 550000]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [15, 29, 42, 54, 65, 75, 84, 92, 99, 105, 110, 114, 117, 119, 120]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]\n assert candidate(nums = [-1000000, -999999, -999998, -999997, -999996, -999995]) == [-1000000, -1999999, -2999997, -3999994, -4999990, -5999985]\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000, -2500000]) == [500000, 1000000, 1500000, 2000000, 2500000, 0]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992, 999991]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4, 999995]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 30, 60, 100, 150, 210, 280, 360, 450, 550]\n assert candidate(nums = [0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000]) == [1000000, 0, 500000, 0, 250000, 0]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4]\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70]) == [10, -10, 20, -20, 30, -30, 40]\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000]) == [1000000, 3000000, 6000000, 10000000, 15000000]\n assert candidate(nums = [1000000, -500000, 250000, -125000, 62500]) == [1000000, 500000, 750000, 625000, 687500]\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0]\n assert candidate(nums = [999999, 1, -999998, 2, -999997, 3]) == [999999, 1000000, 2, 4, -999993, -999990]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [-1000000, -2000000, -3000000, -4000000, -5000000, -6000000, -7000000, -8000000, -9000000, -10000000]) == [-1000000, -3000000, -6000000, -10000000, -15000000, -21000000, -28000000, -36000000, -45000000, -55000000]\n assert candidate(nums = [-1000, 2000, -3000, 4000, -5000, 6000, -7000, 8000, -9000, 10000]) == [-1000, 1000, -2000, 2000, -3000, 3000, -4000, 4000, -5000, 5000]\n assert candidate(nums = [123456, -234567, 345678, -456789, 567890, -678901, 789012, -890123, 901234]) == [123456, -111111, 234567, -222222, 345668, -333233, 455779, -434344, 466890]\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990]) == [999999, 1999997, 2999994, 3999990, 4999985, 5999979, 6999972, 7999964, 8999955, 9999945]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == [100, 199, 297, 394, 490, 585, 679, 772, 864, 955, 1045, 1134, 1222, 1309, 1395, 1480, 1564, 1647, 1729, 1810]\n assert candidate(nums = [1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(nums = [-999999, -888888, -777777, -666666, -555555, -444444, -333333, -222222, -111111]) == [-999999, -1888887, -2666664, -3333330, -3888885, -4333329, -4666662, -4888884, -4999995]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [1000000, 500000, -1500000, 2000000, -2500000, 3000000, -3500000]) == [1000000, 1500000, 0, 2000000, -500000, 2500000, -1000000]\n assert candidate(nums = [1000000, -1000000, 2000000, -2000000, 3000000, -3000000]) == [1000000, 0, 2000000, 0, 3000000, 0]\n assert candidate(nums = [500000, 250000, -125000, 62500, -31250, 15625, -7812, 3906, -1953]) == [500000, 750000, 625000, 687500, 656250, 671875, 664063, 667969, 666016]\n assert candidate(nums = [0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8]\n assert candidate(nums = [-1000000, -1000000, -1000000, -1000000]) == [-1000000, -2000000, -3000000, -4000000]\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == [1, 0, 2, 0, 3, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, -1500, 600, 700, 800, 900]) == [100, 300, 600, 1000, 1500, 0, 600, 1300, 2100, 3000]\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == [1, 2, 4, 7, 12, 20, 33, 54, 88, 143, 232, 376, 609, 986, 1596, 2583, 4180, 6764, 10945, 17710]\n assert candidate(nums = [999999, -999999, 999999, -999999, 999999, -999999, 999999, -999999, 999999, -999999]) == [999999, 0, 999999, 0, 999999, 0, 999999, 0, 999999, 0]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [1000, 3000, 6000, 10000, 15000, 21000, 28000, 36000, 45000, 55000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150]) == [-10, -30, -60, -100, -150, -210, -280, -360, -450, -550, -660, -780, -910, -1050, -1200]\n assert candidate(nums = [500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500]) == [500, 900, 1200, 1400, 1500, 1500, 1400, 1200, 900, 500, 0]\n assert candidate(nums = [100, -50, 25, -12, 6, -3, 1, 0, -1, 3, -6, 12, -24, 48, -96, 192, -384, 768, -1536, 3072]) == [100, 50, 75, 63, 69, 66, 67, 67, 66, 69, 63, 75, 51, 99, 3, 195, -189, 579, -957, 2115]\n assert candidate(nums = [1, 0, -1, 2, 0, -2, 3, 0, -3]) == [1, 1, 0, 2, 2, 0, 3, 3, 0]\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == [1000000, 3000000, 6000000, 10000000, 15000000, 21000000, 28000000, 36000000, 45000000, 55000000]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992, 999991, -999990]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4, 999995, 5]\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == [-10, -19, -27, -34, -40, -45, -49, -52, -54, -55]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().runningSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def runningSum(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "runningSum", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1481, "task_id": "least-number-of-unique-integers-after-k-removals", "difficulty": "Medium", "problem_description": "Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements.\\r\n\\r\n\\r\n\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: arr = [5,5,4], k = 1\\r\nOutput: 1\\r\nExplanation: Remove the single 4, only 5 is left.\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: arr = [4,3,1,1,3,3,2], k = 3\\r\nOutput: 2\\r\nExplanation: Remove 4, 2 and either one of the two 1s or three 3s. 1 and 3 will be left.\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= arr.length <= 10^5\\r\n\t1 <= arr[i] <= 10^9\\r\n\t0 <= k <= arr.length\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 1, 1, 1, 1],k = 3) == 1\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2) == 3\n assert candidate(arr = [10, 20, 20, 10, 10, 30, 50, 10, 20],k = 4) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60],k = 0) == 6\n assert candidate(arr = [4, 3, 1, 1, 3, 3, 2],k = 3) == 2\n assert candidate(arr = [1, 2, 3, 4, 5],k = 0) == 5\n assert candidate(arr = [10, 10, 10, 20, 20, 30],k = 3) == 1\n assert candidate(arr = [1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(arr = [1, 2, 3, 4, 5],k = 5) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 9) == 5\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 4) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 1\n assert candidate(arr = [5, 5, 4],k = 1) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 2) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3],k = 2) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 5) == 3\n assert candidate(arr = [10, 20, 20, 10, 10, 30, 50, 10, 20],k = 5) == 1\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50],k = 10) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 30) == 2\n assert candidate(arr = [100, 100, 200, 200, 200, 300, 300, 300, 300, 400, 400, 400, 400, 400, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 15) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 15) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 20) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9],k = 18) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 50) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 5\n assert candidate(arr = [29, 30, 30, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35],k = 25) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 9],k = 20) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 30) == 4\n assert candidate(arr = [6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10],k = 8) == 2\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, 70, 70, 80, 80, 80, 80, 80, 80, 80, 80, 90, 90, 90, 90, 90, 90, 90, 90, 90, 100],k = 25) == 3\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 25) == 5\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6],k = 18) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8],k = 20) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 15) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 25) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 7) == 2\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],k = 15) == 1\n assert candidate(arr = [7, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 13],k = 10) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 20) == 20\n assert candidate(arr = [11, 12, 12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16],k = 8) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 5) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 30) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 14],k = 15) == 2\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60],k = 15) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 5) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 1\n assert candidate(arr = [7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12],k = 10) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 5) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 40) == 1\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 30) == 1\n assert candidate(arr = [6, 7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10],k = 10) == 1\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 20) == 4\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 30) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 10) == 3\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60],k = 12) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 25) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],k = 15) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 15) == 2\n assert candidate(arr = [22, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28],k = 20) == 2\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 15) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 20) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 10\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 20) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 25) == 1\n assert candidate(arr = [36, 37, 37, 38, 38, 38, 39, 39, 39, 39, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],k = 30) == 1\n assert candidate(arr = [17, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21],k = 15) == 1\n"}, "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().findLeastNumOfUniqueInts", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findLeastNumOfUniqueInts(self, arr: List[int], k: int) -> int:", "container": "Solution", "callable": "findLeastNumOfUniqueInts", "parameters": [{"name": "arr", "type": "List[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1482, "task_id": "minimum-number-of-days-to-make-m-bouquets", "difficulty": "Medium", "problem_description": "You are given an integer array bloomDay, an integer m and an integer k.\nYou want to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.\nThe garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.\nReturn the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.\n \nExample 1:\n\nInput: bloomDay = [1,10,3,10,2], m = 3, k = 1\nOutput: 3\nExplanation: Let us see what happened in the first three days. x means flower bloomed and _ means flower did not bloom in the garden.\nWe need 3 bouquets each should contain 1 flower.\nAfter day 1: [x, _, _, _, _] // we can only make one bouquet.\nAfter day 2: [x, _, _, _, x] // we can only make two bouquets.\nAfter day 3: [x, _, x, _, x] // we can make 3 bouquets. The answer is 3.\n\nExample 2:\n\nInput: bloomDay = [1,10,3,10,2], m = 3, k = 2\nOutput: -1\nExplanation: We need 3 bouquets each has 2 flowers, that means we need 6 flowers. We only have 5 flowers so it is impossible to get the needed bouquets and we return -1.\n\nExample 3:\n\nInput: bloomDay = [7,7,7,7,12,7,7], m = 2, k = 3\nOutput: 12\nExplanation: We need 2 bouquets each should have 3 flowers.\nHere is the garden after the 7 and 12 days:\nAfter day 7: [x, x, x, x, _, x, x]\nWe can make one bouquet of the first three flowers that bloomed. We cannot make another bouquet from the last three flowers that bloomed because they are not adjacent.\nAfter day 12: [x, x, x, x, x, x, x]\nIt is obvious that we can make two bouquets in different ways.\n\n \nConstraints:\n\nbloomDay.length == n\n1 <= n <= 105\n1 <= bloomDay[i] <= 109\n1 <= m <= 106\n1 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(bloomDay = [1, 10, 3, 10, 2],m = 3,k = 1) == 3\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 2) == 1\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5,k = 1) == 5\n assert candidate(bloomDay = [1],m = 1,k = 1) == 1\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000],m = 1,k = 3) == 1000000000\n assert candidate(bloomDay = [1, 10, 3, 10, 2],m = 3,k = 2) == -1\n assert candidate(bloomDay = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5,k = 2) == 10\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000],m = 1,k = 2) == 1000000000\n assert candidate(bloomDay = [7, 7, 7, 7, 12, 7, 7],m = 2,k = 3) == 12\n assert candidate(bloomDay = [1, 3, 2],m = 1,k = 2) == 3\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 1,k = 10) == 10\n assert candidate(bloomDay = [1, 2, 4, 9, 3, 4, 1],m = 2,k = 2) == 4\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 2,k = 5) == 1\n assert candidate(bloomDay = [5, 8, 6, 9, 3, 2, 7, 4],m = 3,k = 2) == 8\n assert candidate(bloomDay = [5, 5, 5, 5, 5, 5],m = 2,k = 3) == 5\n assert candidate(bloomDay = [5, 8, 6, 9, 7],m = 2,k = 2) == 9\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5,k = 2) == 10\n assert candidate(bloomDay = [2, 1, 3, 1, 2],m = 3,k = 1) == 2\n assert candidate(bloomDay = [100, 100, 100, 100],m = 1,k = 4) == 100\n assert candidate(bloomDay = [1, 2, 3, 4, 5],m = 1,k = 5) == 5\n assert candidate(bloomDay = [1000000000],m = 1,k = 1) == 1000000000\n assert candidate(bloomDay = [5, 8, 6, 9, 2, 5, 9, 1, 1, 5, 1, 8, 9, 1, 8],m = 3,k = 1) == 1\n assert candidate(bloomDay = [5, 8, 6, 9, 2, 4, 7, 1, 3, 10],m = 4,k = 2) == 9\n assert candidate(bloomDay = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],m = 10,k = 2) == 20\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 2,k = 7) == 1\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 5,k = 3) == 15\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5,k = 3) == 6\n assert candidate(bloomDay = [30, 10, 20, 30, 20, 10, 30, 20, 10, 30],m = 3,k = 3) == 30\n assert candidate(bloomDay = [9, 1, 2, 3, 4, 5, 6, 7, 8, 1000000000],m = 1,k = 1) == 1\n assert candidate(bloomDay = [3, 5, 1, 5, 9, 6, 2, 10, 8, 7],m = 3,k = 3) == 10\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 5) == 1\n assert candidate(bloomDay = [2, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1],m = 8,k = 2) == 10\n assert candidate(bloomDay = [5, 3, 8, 1, 9, 2, 4, 6, 7],m = 3,k = 2) == 7\n assert candidate(bloomDay = [5, 1, 10, 2, 8, 3, 5, 10],m = 2,k = 2) == 5\n assert candidate(bloomDay = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000],m = 4,k = 2) == 1000000000\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 3,k = 5) == -1\n assert candidate(bloomDay = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 2,k = 5) == 10\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 1,k = 10) == 1\n assert candidate(bloomDay = [5, 8, 4, 3, 7, 1, 9],m = 3,k = 2) == 8\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 10,k = 1) == 1\n assert candidate(bloomDay = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 4,k = 3) == 3\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,k = 2) == 6\n assert candidate(bloomDay = [3, 1, 5, 1, 3, 2, 5, 7, 5, 8, 4, 3],m = 3,k = 2) == 4\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000, 1000000000],m = 1,k = 4) == 1000000000\n assert candidate(bloomDay = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1],m = 4,k = 2) == 10\n assert candidate(bloomDay = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],m = 3,k = 4) == 2\n assert candidate(bloomDay = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],m = 5,k = 3) == -1\n assert candidate(bloomDay = [6, 5, 8, 10, 6, 11, 5, 3],m = 4,k = 1) == 6\n assert candidate(bloomDay = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],m = 3,k = 3) == 3\n assert candidate(bloomDay = [1, 2, 2, 1, 2, 1, 1, 2, 2, 1],m = 2,k = 3) == 2\n assert candidate(bloomDay = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5,k = 4) == 20\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 4,k = 2) == 8\n assert candidate(bloomDay = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10],m = 4,k = 2) == 8\n assert candidate(bloomDay = [5, 3, 3, 3, 5, 5, 2, 2, 2, 5],m = 3,k = 3) == 5\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 100,k = 5) == -1\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 3,k = 5) == 5\n assert candidate(bloomDay = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],m = 5,k = 1) == 1\n assert candidate(bloomDay = [5, 8, 9, 6, 4, 3, 7, 2, 1],m = 4,k = 2) == 8\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 10,k = 2) == 20\n assert candidate(bloomDay = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10],m = 1,k = 10) == 10\n assert candidate(bloomDay = [2, 4, 1, 1, 1, 1, 2, 3, 3],m = 2,k = 3) == 3\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 4,k = 3) == -1\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 3) == 1\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],m = 1,k = 8) == 1000000000\n assert candidate(bloomDay = [5, 8, 6, 9, 10, 11, 12, 13, 14, 15],m = 4,k = 2) == 13\n assert candidate(bloomDay = [7, 7, 7, 12, 7, 7, 7, 12, 7, 7, 7, 12],m = 4,k = 3) == 12\n assert candidate(bloomDay = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 1,k = 1) == 1\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 3) == 1\n assert candidate(bloomDay = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],m = 5,k = 3) == 2\n assert candidate(bloomDay = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],m = 5,k = 2) == 20\n assert candidate(bloomDay = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 10,k = 5) == -1\n assert candidate(bloomDay = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],m = 5,k = 4) == 10\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 15,k = 2) == 30\n assert candidate(bloomDay = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],m = 5,k = 3) == 30\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 10,k = 2) == 1\n assert candidate(bloomDay = [3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 10,k = 1) == 10\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 3,k = 5) == 5\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 15,k = 5) == 10\n assert candidate(bloomDay = [1, 10, 3, 10, 2, 1, 10, 3, 10, 2],m = 4,k = 2) == 10\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 5,k = 3) == 15\n assert candidate(bloomDay = [9, 3, 5, 7, 2, 8, 10, 6, 4],m = 2,k = 3) == 9\n assert candidate(bloomDay = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 5,k = 4) == 7\n assert candidate(bloomDay = [5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5],m = 10,k = 2) == 3\n assert candidate(bloomDay = [5, 8, 6, 9, 7, 2, 4, 3, 10, 1],m = 2,k = 4) == 9\n assert candidate(bloomDay = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 3,k = 3) == 9\n assert candidate(bloomDay = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 5,k = 3) == 5\n assert candidate(bloomDay = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 5,k = 4) == 200\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],m = 5,k = 5) == 25\n assert candidate(bloomDay = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],m = 10,k = 3) == 3\n"}, "metadata": {"canonical_parameter_names": ["bloomDay", "m", "k"], "leetcode_dataset_entry_point": "Solution().minDays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minDays(self, bloomDay: list[int], m: int, k: int) -> int:", "container": "Solution", "callable": "minDays", "parameters": [{"name": "bloomDay", "type": "list[int]"}, {"name": "m", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1486, "task_id": "xor-operation-in-an-array", "difficulty": "Easy", "problem_description": "You are given an integer n and an integer start.\nDefine an array nums where nums[i] = start + 2 * i (0-indexed) and n == nums.length.\nReturn the bitwise XOR of all elements of nums.\n \nExample 1:\n\nInput: n = 5, start = 0\nOutput: 8\nExplanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.\nWhere \"^\" corresponds to bitwise XOR operator.\n\nExample 2:\n\nInput: n = 4, start = 3\nOutput: 8\nExplanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.\n\n \nConstraints:\n\n1 <= n <= 1000\n0 <= start <= 1000\nn == nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,start = 3) == 8\n assert candidate(n = 8,start = 12) == 0\n assert candidate(n = 7,start = 2) == 0\n assert candidate(n = 3,start = 2) == 0\n assert candidate(n = 10,start = 1) == 2\n assert candidate(n = 5,start = 0) == 8\n assert candidate(n = 1,start = 7) == 7\n assert candidate(n = 10,start = 5) == 2\n assert candidate(n = 8,start = 2) == 16\n assert candidate(n = 7,start = 5) == 19\n assert candidate(n = 1,start = 5) == 5\n assert candidate(n = 10,start = 999) == 30\n assert candidate(n = 50,start = 25) == 2\n assert candidate(n = 100,start = 200) == 0\n assert candidate(n = 15,start = 2) == 0\n assert candidate(n = 33,start = 17) == 81\n assert candidate(n = 12,start = 8) == 0\n assert candidate(n = 750,start = 10) == 1518\n assert candidate(n = 750,start = 50) == 1598\n assert candidate(n = 3,start = 333) == 339\n assert candidate(n = 666,start = 333) == 2\n assert candidate(n = 500,start = 250) == 1048\n assert candidate(n = 12,start = 3) == 24\n assert candidate(n = 9,start = 1) == 17\n assert candidate(n = 50,start = 10) == 102\n assert candidate(n = 6,start = 999) == 22\n assert candidate(n = 8,start = 11) == 16\n assert candidate(n = 64,start = 42) == 128\n assert candidate(n = 15,start = 7) == 5\n assert candidate(n = 80,start = 600) == 0\n assert candidate(n = 250,start = 100) == 2\n assert candidate(n = 20,start = 10) == 56\n assert candidate(n = 30,start = 42) == 78\n assert candidate(n = 7,start = 25) == 39\n assert candidate(n = 256,start = 128) == 0\n assert candidate(n = 400,start = 400) == 0\n assert candidate(n = 11,start = 8) == 30\n assert candidate(n = 100,start = 250) == 312\n assert candidate(n = 20,start = 11) == 56\n assert candidate(n = 500,start = 750) == 1080\n assert candidate(n = 500,start = 500) == 0\n assert candidate(n = 700,start = 600) == 0\n assert candidate(n = 60,start = 8) == 0\n assert candidate(n = 100,start = 999) == 1864\n assert candidate(n = 250,start = 250) == 534\n assert candidate(n = 8,start = 15) == 16\n assert candidate(n = 18,start = 4) == 2\n assert candidate(n = 1000,start = 0) == 0\n assert candidate(n = 333,start = 256) == 920\n assert candidate(n = 75,start = 300) == 450\n assert candidate(n = 128,start = 99) == 256\n assert candidate(n = 500,start = 999) == 1064\n assert candidate(n = 100,start = 50) == 200\n assert candidate(n = 50,start = 50) == 166\n assert candidate(n = 250,start = 123) == 534\n assert candidate(n = 999,start = 0) == 1998\n assert candidate(n = 999,start = 500) == 2498\n assert candidate(n = 25,start = 6) == 6\n assert candidate(n = 64,start = 32) == 0\n assert candidate(n = 20,start = 12) == 0\n assert candidate(n = 50,start = 100) == 2\n assert candidate(n = 8,start = 1) == 0\n assert candidate(n = 30,start = 15) == 70\n assert candidate(n = 9,start = 7) == 7\n assert candidate(n = 13,start = 11) == 11\n assert candidate(n = 20,start = 3) == 40\n assert candidate(n = 100,start = 25) == 0\n assert candidate(n = 500,start = 0) == 0\n assert candidate(n = 120,start = 750) == 304\n assert candidate(n = 7,start = 1) == 15\n assert candidate(n = 15,start = 12) == 42\n assert candidate(n = 50,start = 0) == 2\n assert candidate(n = 1000,start = 1) == 0\n assert candidate(n = 333,start = 222) == 222\n assert candidate(n = 20,start = 15) == 56\n assert candidate(n = 7,start = 14) == 12\n assert candidate(n = 1000,start = 1000) == 0\n assert candidate(n = 800,start = 150) == 1600\n assert candidate(n = 300,start = 300) == 0\n assert candidate(n = 8,start = 100) == 0\n assert candidate(n = 7,start = 17) == 31\n assert candidate(n = 7,start = 10) == 8\n assert candidate(n = 666,start = 128) == 2\n assert candidate(n = 20,start = 2) == 40\n assert candidate(n = 300,start = 600) == 0\n assert candidate(n = 12,start = 42) == 104\n assert candidate(n = 40,start = 0) == 0\n assert candidate(n = 20,start = 0) == 0\n assert candidate(n = 80,start = 12) == 0\n assert candidate(n = 300,start = 450) == 1496\n assert candidate(n = 999,start = 1) == 1999\n assert candidate(n = 600,start = 300) == 0\n"}, "metadata": {"canonical_parameter_names": ["n", "start"], "leetcode_dataset_entry_point": "Solution().xorOperation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def xorOperation(self, n: int, start: int) -> int:", "container": "Solution", "callable": "xorOperation", "parameters": [{"name": "n", "type": "int"}, {"name": "start", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1487, "task_id": "making-file-names-unique", "difficulty": "Medium", "problem_description": "Given an array of strings names of size n. You will create n folders in your file system such that, at the ith minute, you will create a folder with the name names[i].\nSince two files cannot have the same name, if you enter a folder name that was previously used, the system will have a suffix addition to its name in the form of (k), where, k is the smallest positive integer such that the obtained name remains unique.\nReturn an array of strings of length n where ans[i] is the actual name the system will assign to the ith folder when you create it.\n \nExample 1:\n\nInput: names = [\"pes\",\"fifa\",\"gta\",\"pes(2019)\"]\nOutput: [\"pes\",\"fifa\",\"gta\",\"pes(2019)\"]\nExplanation: Let's see how the file system creates folder names:\n\"pes\" --> not assigned before, remains \"pes\"\n\"fifa\" --> not assigned before, remains \"fifa\"\n\"gta\" --> not assigned before, remains \"gta\"\n\"pes(2019)\" --> not assigned before, remains \"pes(2019)\"\n\nExample 2:\n\nInput: names = [\"gta\",\"gta(1)\",\"gta\",\"avalon\"]\nOutput: [\"gta\",\"gta(1)\",\"gta(2)\",\"avalon\"]\nExplanation: Let's see how the file system creates folder names:\n\"gta\" --> not assigned before, remains \"gta\"\n\"gta(1)\" --> not assigned before, remains \"gta(1)\"\n\"gta\" --> the name is reserved, system adds (k), since \"gta(1)\" is also reserved, systems put k = 2. it becomes \"gta(2)\"\n\"avalon\" --> not assigned before, remains \"avalon\"\n\nExample 3:\n\nInput: names = [\"onepiece\",\"onepiece(1)\",\"onepiece(2)\",\"onepiece(3)\",\"onepiece\"]\nOutput: [\"onepiece\",\"onepiece(1)\",\"onepiece(2)\",\"onepiece(3)\",\"onepiece(4)\"]\nExplanation: When the last folder is created, the smallest positive valid k is 4, and it becomes \"onepiece(4)\".\n\n \nConstraints:\n\n1 <= names.length <= 5 * 104\n1 <= names[i].length <= 20\nnames[i] consists of lowercase English letters, digits, and/or round brackets.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(names = ['doc', 'doc(1)', 'image', 'doc(1)', 'doc']) == ['doc', 'doc(1)', 'image', 'doc(1)(1)', 'doc(2)']\n assert candidate(names = ['abcd', 'abcde', 'abcd(1)', 'abcd', 'abcd(2)', 'abcd(1)(1)']) == ['abcd', 'abcde', 'abcd(1)', 'abcd(2)', 'abcd(2)(1)', 'abcd(1)(1)']\n assert candidate(names = ['a', 'a', 'a', 'a', 'a']) == ['a', 'a(1)', 'a(2)', 'a(3)', 'a(4)']\n assert candidate(names = ['pes', 'fifa', 'gta', 'pes(2019)']) == ['pes', 'fifa', 'gta', 'pes(2019)']\n assert candidate(names = ['gta', 'gta(1)', 'gta', 'avalon']) == ['gta', 'gta(1)', 'gta(2)', 'avalon']\n assert candidate(names = ['doc', 'doc', 'image', 'doc(1)', 'doc']) == ['doc', 'doc(1)', 'image', 'doc(1)(1)', 'doc(2)']\n assert candidate(names = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']) == ['a', 'a(1)', 'a(2)', 'a(3)', 'a(4)', 'a(5)', 'a(6)', 'a(7)', 'a(8)', 'a(9)']\n assert candidate(names = ['doc', 'doc(1)', 'image', 'doc(1)(1)', 'doc(2)', 'doc(1)(2)', 'doc(3)', 'doc(1)(3)', 'doc(2)(1)']) == ['doc', 'doc(1)', 'image', 'doc(1)(1)', 'doc(2)', 'doc(1)(2)', 'doc(3)', 'doc(1)(3)', 'doc(2)(1)']\n assert candidate(names = ['a', 'a', 'a', 'a', 'a', 'a']) == ['a', 'a(1)', 'a(2)', 'a(3)', 'a(4)', 'a(5)']\n assert candidate(names = ['onepiece', 'onepiece(1)', 'onepiece(2)', 'onepiece(3)', 'onepiece']) == ['onepiece', 'onepiece(1)', 'onepiece(2)', 'onepiece(3)', 'onepiece(4)']\n assert candidate(names = ['a', 'a', 'a', 'a(1)', 'a(2)', 'a(1)(1)']) == ['a', 'a(1)', 'a(2)', 'a(1)(1)', 'a(2)(1)', 'a(1)(1)(1)']\n assert candidate(names = ['game', 'game(1)', 'game', 'game(2)', 'game(1)', 'game(3)', 'game(1)(1)']) == ['game', 'game(1)', 'game(2)', 'game(2)(1)', 'game(1)(1)', 'game(3)', 'game(1)(1)(1)']\n assert candidate(names = ['project', 'project', 'project', 'project', 'project(1)', 'project(1)', 'project(2)', 'project', 'project(1)', 'project(2)', 'project(3)', 'project(1)(1)', 'project(1)(2)', 'project(1)(3)', 'project(1)', 'project(2)', 'project(3)', 'project(4)', 'project', 'project(1)', 'project(2)', 'project(3)', 'project(4)', 'project(5)']) == ['project', 'project(1)', 'project(2)', 'project(3)', 'project(1)(1)', 'project(1)(2)', 'project(2)(1)', 'project(4)', 'project(1)(3)', 'project(2)(2)', 'project(3)(1)', 'project(1)(1)(1)', 'project(1)(2)(1)', 'project(1)(3)(1)', 'project(1)(4)', 'project(2)(3)', 'project(3)(2)', 'project(4)(1)', 'project(5)', 'project(1)(5)', 'project(2)(4)', 'project(3)(3)', 'project(4)(2)', 'project(5)(1)']\n assert candidate(names = ['file1', 'file1(1)', 'file1', 'file1(2)', 'file1', 'file1(1)', 'file1(2)', 'file1(1)(1)', 'file1(1)(2)', 'file1(1)(1)(1)', 'file1(1)(1)(2)', 'file1(1)(1)(1)(1)', 'file1(3)', 'file1(4)', 'file1(5)', 'file1(1)(3)', 'file1(1)(4)', 'file1(2)(1)', 'file1(2)(2)', 'file1(2)(1)(1)']) == ['file1', 'file1(1)', 'file1(2)', 'file1(2)(1)', 'file1(3)', 'file1(1)(1)', 'file1(2)(2)', 'file1(1)(1)(1)', 'file1(1)(2)', 'file1(1)(1)(1)(1)', 'file1(1)(1)(2)', 'file1(1)(1)(1)(1)(1)', 'file1(3)(1)', 'file1(4)', 'file1(5)', 'file1(1)(3)', 'file1(1)(4)', 'file1(2)(1)(1)', 'file1(2)(2)(1)', 'file1(2)(1)(1)(1)']\n assert candidate(names = ['album', 'album', 'album', 'album(1)', 'album(2)', 'album', 'album(1)(1)', 'album(1)', 'album(1)(2)', 'album(1)(3)', 'album(1)(4)', 'album(1)(5)', 'album(1)(6)', 'album(1)(7)', 'album(1)(8)', 'album(1)(9)', 'album(1)(10)']) == ['album', 'album(1)', 'album(2)', 'album(1)(1)', 'album(2)(1)', 'album(3)', 'album(1)(1)(1)', 'album(1)(2)', 'album(1)(2)(1)', 'album(1)(3)', 'album(1)(4)', 'album(1)(5)', 'album(1)(6)', 'album(1)(7)', 'album(1)(8)', 'album(1)(9)', 'album(1)(10)']\n assert candidate(names = ['data', 'data', 'data(1)', 'data(2)', 'data', 'data(1)(1)', 'data(1)', 'data(2)', 'data(3)', 'data(2)(1)', 'data(2)(2)', 'data(2)(3)', 'data(2)(1)(1)']) == ['data', 'data(1)', 'data(1)(1)', 'data(2)', 'data(3)', 'data(1)(1)(1)', 'data(1)(2)', 'data(2)(1)', 'data(3)(1)', 'data(2)(1)(1)', 'data(2)(2)', 'data(2)(3)', 'data(2)(1)(1)(1)']\n assert candidate(names = ['photo', 'photo', 'photo(1)', 'photo', 'photo(2)', 'photo(3)', 'photo(1)(1)', 'photo(1)(2)', 'photo(1)']) == ['photo', 'photo(1)', 'photo(1)(1)', 'photo(2)', 'photo(2)(1)', 'photo(3)', 'photo(1)(1)(1)', 'photo(1)(2)', 'photo(1)(3)']\n assert candidate(names = ['video', 'video', 'video(1)', 'video(2)', 'video', 'video(1)', 'video', 'video(1)(1)', 'video(3)', 'video(4)', 'video(2)(2)', 'video(5)', 'video(2)', 'video(6)', 'video(7)', 'video', 'video(8)', 'video(9)', 'video(10)']) == ['video', 'video(1)', 'video(1)(1)', 'video(2)', 'video(3)', 'video(1)(2)', 'video(4)', 'video(1)(1)(1)', 'video(3)(1)', 'video(4)(1)', 'video(2)(2)', 'video(5)', 'video(2)(1)', 'video(6)', 'video(7)', 'video(8)', 'video(8)(1)', 'video(9)', 'video(10)']\n assert candidate(names = ['report', 'report', 'report(1)', 'report', 'report(1)', 'report(2)', 'report(2)', 'report(3)', 'report(3)', 'report(4)', 'report(4)', 'report(5)', 'report(5)']) == ['report', 'report(1)', 'report(1)(1)', 'report(2)', 'report(1)(2)', 'report(2)(1)', 'report(2)(2)', 'report(3)', 'report(3)(1)', 'report(4)', 'report(4)(1)', 'report(5)', 'report(5)(1)']\n assert candidate(names = ['image', 'image', 'image', 'image', 'image(1)', 'image(1)', 'image(2)', 'image', 'image(1)', 'image(2)', 'image(3)', 'image(1)(1)', 'image(1)(2)', 'image(1)(3)', 'image(1)', 'image(2)', 'image(3)', 'image(4)', 'image', 'image(1)', 'image(2)', 'image(3)', 'image(4)', 'image(5)', 'image(1)(1)', 'image(1)(2)', 'image(1)(3)', 'image(1)(4)', 'image(1)(5)', 'image(1)(6)', 'image(1)(7)', 'image(1)(8)', 'image(1)(9)', 'image(1)(10)', 'image(1)(11)', 'image(1)(12)', 'image(1)(13)', 'image(1)(14)', 'image(1)(15)']) == ['image', 'image(1)', 'image(2)', 'image(3)', 'image(1)(1)', 'image(1)(2)', 'image(2)(1)', 'image(4)', 'image(1)(3)', 'image(2)(2)', 'image(3)(1)', 'image(1)(1)(1)', 'image(1)(2)(1)', 'image(1)(3)(1)', 'image(1)(4)', 'image(2)(3)', 'image(3)(2)', 'image(4)(1)', 'image(5)', 'image(1)(5)', 'image(2)(4)', 'image(3)(3)', 'image(4)(2)', 'image(5)(1)', 'image(1)(1)(2)', 'image(1)(2)(2)', 'image(1)(3)(2)', 'image(1)(4)(1)', 'image(1)(5)(1)', 'image(1)(6)', 'image(1)(7)', 'image(1)(8)', 'image(1)(9)', 'image(1)(10)', 'image(1)(11)', 'image(1)(12)', 'image(1)(13)', 'image(1)(14)', 'image(1)(15)']\n assert candidate(names = ['photo', 'photo', 'photo(1)', 'photo', 'photo(1)', 'photo(2)', 'photo(1)(1)', 'photo(1)']) == ['photo', 'photo(1)', 'photo(1)(1)', 'photo(2)', 'photo(1)(2)', 'photo(2)(1)', 'photo(1)(1)(1)', 'photo(1)(3)']\n assert candidate(names = ['data', 'data', 'data(1)', 'data', 'data(1)', 'data(2)', 'data', 'data(1)', 'data(2)', 'data(3)', 'data(1)(1)', 'data(1)(2)', 'data(1)(3)', 'data(1)', 'data(2)', 'data(3)', 'data']) == ['data', 'data(1)', 'data(1)(1)', 'data(2)', 'data(1)(2)', 'data(2)(1)', 'data(3)', 'data(1)(3)', 'data(2)(2)', 'data(3)(1)', 'data(1)(1)(1)', 'data(1)(2)(1)', 'data(1)(3)(1)', 'data(1)(4)', 'data(2)(3)', 'data(3)(2)', 'data(4)']\n assert candidate(names = ['project', 'project', 'project', 'project(1)', 'project', 'project(1)', 'project(2)', 'project(3)']) == ['project', 'project(1)', 'project(2)', 'project(1)(1)', 'project(3)', 'project(1)(2)', 'project(2)(1)', 'project(3)(1)']\n assert candidate(names = ['record', 'record', 'record', 'record(1)', 'record(2)', 'record(3)', 'record', 'record(1)(1)', 'record(1)(2)', 'record(2)(1)', 'record(4)', 'record', 'record(5)', 'record(6)', 'record(1)(1)', 'record(7)', 'record', 'record(2)', 'record(8)', 'record(9)', 'record(10)', 'record(11)']) == ['record', 'record(1)', 'record(2)', 'record(1)(1)', 'record(2)(1)', 'record(3)', 'record(4)', 'record(1)(1)(1)', 'record(1)(2)', 'record(2)(1)(1)', 'record(4)(1)', 'record(5)', 'record(5)(1)', 'record(6)', 'record(1)(1)(2)', 'record(7)', 'record(8)', 'record(2)(2)', 'record(8)(1)', 'record(9)', 'record(10)', 'record(11)']\n assert candidate(names = ['document', 'document', 'document', 'document(1)', 'document', 'document(1)', 'document', 'document(2)', 'document(1)(1)', 'document(1)', 'document(2)', 'document', 'document(1)', 'document(1)(1)', 'document(1)(2)', 'document(1)(3)', 'document(1)(4)', 'document(1)(5)', 'document(1)(6)', 'document(1)(7)', 'document(1)(8)', 'document(1)(9)', 'document(1)(10)', 'document(1)(11)', 'document(1)(12)', 'document(1)(13)', 'document(1)(14)', 'document(1)(15)', 'document(1)(16)', 'document(1)(17)', 'document(1)(18)', 'document(1)(19)', 'document(1)(20)']) == ['document', 'document(1)', 'document(2)', 'document(1)(1)', 'document(3)', 'document(1)(2)', 'document(4)', 'document(2)(1)', 'document(1)(1)(1)', 'document(1)(3)', 'document(2)(2)', 'document(5)', 'document(1)(4)', 'document(1)(1)(2)', 'document(1)(2)(1)', 'document(1)(3)(1)', 'document(1)(4)(1)', 'document(1)(5)', 'document(1)(6)', 'document(1)(7)', 'document(1)(8)', 'document(1)(9)', 'document(1)(10)', 'document(1)(11)', 'document(1)(12)', 'document(1)(13)', 'document(1)(14)', 'document(1)(15)', 'document(1)(16)', 'document(1)(17)', 'document(1)(18)', 'document(1)(19)', 'document(1)(20)']\n assert candidate(names = ['project', 'project', 'project(1)', 'project', 'project(2)', 'project(1)(1)', 'project(1)', 'project(2)(2)', 'project(1)(2)', 'project(2)(1)']) == ['project', 'project(1)', 'project(1)(1)', 'project(2)', 'project(2)(1)', 'project(1)(1)(1)', 'project(1)(2)', 'project(2)(2)', 'project(1)(2)(1)', 'project(2)(1)(1)']\n assert candidate(names = ['game', 'game(1)', 'game', 'game(1)', 'game(2)', 'game', 'game(1)(1)']) == ['game', 'game(1)', 'game(2)', 'game(1)(1)', 'game(2)(1)', 'game(3)', 'game(1)(1)(1)']\n assert candidate(names = ['music', 'music', 'music(1)', 'music', 'music(2)', 'music(3)', 'music', 'music(1)(1)', 'music(4)']) == ['music', 'music(1)', 'music(1)(1)', 'music(2)', 'music(2)(1)', 'music(3)', 'music(4)', 'music(1)(1)(1)', 'music(4)(1)']\n assert candidate(names = ['movie', 'movie', 'movie', 'movie(1)', 'movie', 'movie(1)', 'movie', 'movie(2)', 'movie(1)(1)', 'movie(1)', 'movie(2)']) == ['movie', 'movie(1)', 'movie(2)', 'movie(1)(1)', 'movie(3)', 'movie(1)(2)', 'movie(4)', 'movie(2)(1)', 'movie(1)(1)(1)', 'movie(1)(3)', 'movie(2)(2)']\n assert candidate(names = ['document', 'document(1)', 'document(2)', 'document', 'document(1)', 'document', 'document(3)', 'document(1)(1)', 'document(2)(1)', 'document(4)']) == ['document', 'document(1)', 'document(2)', 'document(3)', 'document(1)(1)', 'document(4)', 'document(3)(1)', 'document(1)(1)(1)', 'document(2)(1)', 'document(4)(1)']\n assert candidate(names = ['data', 'data', 'data', 'data(1)', 'data(2)', 'data(3)', 'data', 'data(1)(1)', 'data(1)(2)', 'data(2)(1)', 'data(4)', 'data', 'data(5)', 'data(6)', 'data(1)(1)', 'data(7)']) == ['data', 'data(1)', 'data(2)', 'data(1)(1)', 'data(2)(1)', 'data(3)', 'data(4)', 'data(1)(1)(1)', 'data(1)(2)', 'data(2)(1)(1)', 'data(4)(1)', 'data(5)', 'data(5)(1)', 'data(6)', 'data(1)(1)(2)', 'data(7)']\n assert candidate(names = ['doc', 'doc', 'doc(1)', 'doc', 'doc(1)', 'doc(2)', 'doc', 'doc(1)(1)', 'doc(1)(2)', 'doc(1)(1)']) == ['doc', 'doc(1)', 'doc(1)(1)', 'doc(2)', 'doc(1)(2)', 'doc(2)(1)', 'doc(3)', 'doc(1)(1)(1)', 'doc(1)(2)(1)', 'doc(1)(1)(2)']\n assert candidate(names = ['test', 'test', 'test', 'test(1)', 'test', 'test(1)', 'test(2)', 'test(1)(1)', 'test(1)(2)', 'test(1)(1)(1)', 'test(1)(1)(2)', 'test(1)(1)(1)(1)']) == ['test', 'test(1)', 'test(2)', 'test(1)(1)', 'test(3)', 'test(1)(2)', 'test(2)(1)', 'test(1)(1)(1)', 'test(1)(2)(1)', 'test(1)(1)(1)(1)', 'test(1)(1)(2)', 'test(1)(1)(1)(1)(1)']\n assert candidate(names = ['file', 'file', 'file(1)', 'file(1)', 'file(2)', 'file(3)', 'file(2)', 'file(1)(1)']) == ['file', 'file(1)', 'file(1)(1)', 'file(1)(2)', 'file(2)', 'file(3)', 'file(2)(1)', 'file(1)(1)(1)']\n assert candidate(names = ['file', 'file', 'file', 'file', 'file(1)', 'file(1)', 'file(2)', 'file(1)(1)', 'file(1)(2)', 'file(1)', 'file(2)']) == ['file', 'file(1)', 'file(2)', 'file(3)', 'file(1)(1)', 'file(1)(2)', 'file(2)(1)', 'file(1)(1)(1)', 'file(1)(2)(1)', 'file(1)(3)', 'file(2)(2)']\n assert candidate(names = ['project', 'project', 'project', 'project', 'project(1)', 'project(1)', 'project', 'project(2)', 'project(1)(1)', 'project(1)', 'project(2)', 'project', 'project(1)', 'project(1)(1)', 'project(1)(2)']) == ['project', 'project(1)', 'project(2)', 'project(3)', 'project(1)(1)', 'project(1)(2)', 'project(4)', 'project(2)(1)', 'project(1)(1)(1)', 'project(1)(3)', 'project(2)(2)', 'project(5)', 'project(1)(4)', 'project(1)(1)(2)', 'project(1)(2)(1)']\n assert candidate(names = ['file', 'file', 'file(1)', 'file(1)', 'file(2)', 'file(2)', 'file(3)']) == ['file', 'file(1)', 'file(1)(1)', 'file(1)(2)', 'file(2)', 'file(2)(1)', 'file(3)']\n assert candidate(names = ['app', 'app', 'app', 'app(1)', 'app(1)', 'app(2)', 'app', 'app(1)(1)', 'app(1)(2)', 'app(1)(1)(1)', 'app(1)(1)(2)', 'app(1)(1)(1)(1)', 'app(3)', 'app(4)', 'app(5)', 'app(1)(3)', 'app(1)(4)', 'app(2)(1)', 'app(2)(2)', 'app(2)(1)(1)', 'app(5)', 'app(1)', 'app(2)', 'app(3)', 'app(1)(1)', 'app(1)(2)', 'app(1)(1)(1)', 'app(1)(1)(2)', 'app(1)(1)(1)(1)', 'app(6)', 'app(7)', 'app(8)', 'app(1)(5)', 'app(1)(6)', 'app(2)(3)', 'app(2)(4)', 'app(2)(1)(2)']) == ['app', 'app(1)', 'app(2)', 'app(1)(1)', 'app(1)(2)', 'app(2)(1)', 'app(3)', 'app(1)(1)(1)', 'app(1)(2)(1)', 'app(1)(1)(1)(1)', 'app(1)(1)(2)', 'app(1)(1)(1)(1)(1)', 'app(3)(1)', 'app(4)', 'app(5)', 'app(1)(3)', 'app(1)(4)', 'app(2)(1)(1)', 'app(2)(2)', 'app(2)(1)(1)(1)', 'app(5)(1)', 'app(1)(5)', 'app(2)(3)', 'app(3)(2)', 'app(1)(1)(3)', 'app(1)(2)(2)', 'app(1)(1)(1)(2)', 'app(1)(1)(2)(1)', 'app(1)(1)(1)(1)(2)', 'app(6)', 'app(7)', 'app(8)', 'app(1)(5)(1)', 'app(1)(6)', 'app(2)(3)(1)', 'app(2)(4)', 'app(2)(1)(2)']\n assert candidate(names = ['report', 'report', 'report(1)', 'report(2)', 'report(1)(1)', 'report', 'report(1)', 'report(2)', 'report(1)(1)', 'report(1)(2)', 'report(2)(1)', 'report(2)(2)', 'report(2)(3)', 'report(1)(2)(1)', 'report(1)(1)(1)']) == ['report', 'report(1)', 'report(1)(1)', 'report(2)', 'report(1)(1)(1)', 'report(3)', 'report(1)(2)', 'report(2)(1)', 'report(1)(1)(2)', 'report(1)(2)(1)', 'report(2)(1)(1)', 'report(2)(2)', 'report(2)(3)', 'report(1)(2)(1)(1)', 'report(1)(1)(1)(1)']\n assert candidate(names = ['test', 'test', 'test(1)', 'test(2)', 'test', 'test(1)(1)', 'test(1)', 'test(2)', 'test(3)', 'test(2)(1)', 'test(2)(2)', 'test(2)(3)', 'test(1)(2)(1)', 'test(1)(1)(1)', 'test(1)(1)(2)', 'test(1)(1)(1)(1)', 'test(1)(1)(1)(2)']) == ['test', 'test(1)', 'test(1)(1)', 'test(2)', 'test(3)', 'test(1)(1)(1)', 'test(1)(2)', 'test(2)(1)', 'test(3)(1)', 'test(2)(1)(1)', 'test(2)(2)', 'test(2)(3)', 'test(1)(2)(1)', 'test(1)(1)(1)(1)', 'test(1)(1)(2)', 'test(1)(1)(1)(1)(1)', 'test(1)(1)(1)(2)']\n assert candidate(names = ['example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example']) == ['example', 'example(1)', 'example(2)', 'example(3)', 'example(4)', 'example(5)', 'example(6)', 'example(7)', 'example(8)', 'example(9)', 'example(10)', 'example(11)', 'example(12)', 'example(13)', 'example(14)', 'example(15)', 'example(16)', 'example(17)', 'example(18)', 'example(19)', 'example(20)', 'example(21)', 'example(22)', 'example(23)', 'example(24)', 'example(25)', 'example(26)', 'example(27)', 'example(28)', 'example(29)', 'example(30)', 'example(31)', 'example(32)', 'example(33)', 'example(34)', 'example(35)', 'example(36)', 'example(37)', 'example(38)', 'example(39)', 'example(40)', 'example(41)', 'example(42)', 'example(43)', 'example(44)', 'example(45)', 'example(46)', 'example(47)', 'example(48)', 'example(49)', 'example(50)', 'example(51)', 'example(52)', 'example(53)', 'example(54)', 'example(55)', 'example(56)', 'example(57)']\n assert candidate(names = ['file', 'file', 'file', 'file(1)', 'file(2)', 'file', 'file(3)', 'file(1)(1)', 'file(2)(1)', 'file(1)', 'file(4)', 'file(1)(2)', 'file(5)', 'file(2)', 'file(6)']) == ['file', 'file(1)', 'file(2)', 'file(1)(1)', 'file(2)(1)', 'file(3)', 'file(3)(1)', 'file(1)(1)(1)', 'file(2)(1)(1)', 'file(1)(2)', 'file(4)', 'file(1)(2)(1)', 'file(5)', 'file(2)(2)', 'file(6)']\n assert candidate(names = ['movie', 'movie', 'movie', 'movie(1)', 'movie(2)', 'movie(3)', 'movie', 'movie(1)(1)', 'movie(1)(2)', 'movie(2)(1)', 'movie(4)', 'movie', 'movie(5)', 'movie(6)', 'movie(1)(1)', 'movie(7)', 'movie', 'movie(2)', 'movie(8)']) == ['movie', 'movie(1)', 'movie(2)', 'movie(1)(1)', 'movie(2)(1)', 'movie(3)', 'movie(4)', 'movie(1)(1)(1)', 'movie(1)(2)', 'movie(2)(1)(1)', 'movie(4)(1)', 'movie(5)', 'movie(5)(1)', 'movie(6)', 'movie(1)(1)(2)', 'movie(7)', 'movie(8)', 'movie(2)(2)', 'movie(8)(1)']\n assert candidate(names = ['file', 'file', 'file', 'file', 'file', 'file', 'file', 'file', 'file', 'file(1)', 'file(1)', 'file(2)', 'file(2)']) == ['file', 'file(1)', 'file(2)', 'file(3)', 'file(4)', 'file(5)', 'file(6)', 'file(7)', 'file(8)', 'file(1)(1)', 'file(1)(2)', 'file(2)(1)', 'file(2)(2)']\n assert candidate(names = ['alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha']) == ['alpha', 'alpha(1)', 'alpha(2)', 'alpha(3)', 'alpha(4)', 'alpha(5)', 'alpha(6)', 'alpha(7)', 'alpha(8)', 'alpha(9)', 'alpha(10)', 'alpha(11)', 'alpha(12)', 'alpha(13)', 'alpha(14)', 'alpha(15)', 'alpha(16)', 'alpha(17)', 'alpha(18)', 'alpha(19)']\n assert candidate(names = ['doc', 'doc', 'doc', 'doc(1)', 'doc', 'doc(1)', 'doc(2)', 'doc(1)(1)', 'doc(1)(1)', 'doc(1)(2)']) == ['doc', 'doc(1)', 'doc(2)', 'doc(1)(1)', 'doc(3)', 'doc(1)(2)', 'doc(2)(1)', 'doc(1)(1)(1)', 'doc(1)(1)(2)', 'doc(1)(2)(1)']\n assert candidate(names = ['report', 'report', 'report', 'report(1)', 'report', 'report(1)', 'report', 'report(2)', 'report(1)(1)', 'report(1)', 'report(2)', 'report', 'report(1)', 'report(1)(1)', 'report(1)(2)', 'report(1)(3)', 'report(1)(4)', 'report(1)(5)', 'report(1)(6)', 'report(1)(7)', 'report(1)(8)', 'report(1)(9)', 'report(1)(10)', 'report(1)(11)', 'report(1)(12)', 'report(1)(13)', 'report(1)(14)', 'report(1)(15)']) == ['report', 'report(1)', 'report(2)', 'report(1)(1)', 'report(3)', 'report(1)(2)', 'report(4)', 'report(2)(1)', 'report(1)(1)(1)', 'report(1)(3)', 'report(2)(2)', 'report(5)', 'report(1)(4)', 'report(1)(1)(2)', 'report(1)(2)(1)', 'report(1)(3)(1)', 'report(1)(4)(1)', 'report(1)(5)', 'report(1)(6)', 'report(1)(7)', 'report(1)(8)', 'report(1)(9)', 'report(1)(10)', 'report(1)(11)', 'report(1)(12)', 'report(1)(13)', 'report(1)(14)', 'report(1)(15)']\n assert candidate(names = ['doc', 'doc(1)', 'image', 'image', 'doc', 'doc(1)', 'doc(2)', 'doc(2)', 'image(1)', 'image(1)']) == ['doc', 'doc(1)', 'image', 'image(1)', 'doc(2)', 'doc(1)(1)', 'doc(2)(1)', 'doc(2)(2)', 'image(1)(1)', 'image(1)(2)']\n assert candidate(names = ['video', 'video', 'video', 'video', 'video(1)', 'video(1)', 'video(2)', 'video', 'video(1)', 'video(2)', 'video(3)', 'video(1)(1)', 'video(1)(2)', 'video(1)(3)', 'video(1)', 'video(2)', 'video(3)', 'video(4)', 'video', 'video(1)', 'video(2)', 'video(3)', 'video(4)', 'video(5)', 'video(1)(1)', 'video(1)(2)', 'video(1)(3)', 'video(1)(4)', 'video(1)(5)', 'video(1)(6)']) == ['video', 'video(1)', 'video(2)', 'video(3)', 'video(1)(1)', 'video(1)(2)', 'video(2)(1)', 'video(4)', 'video(1)(3)', 'video(2)(2)', 'video(3)(1)', 'video(1)(1)(1)', 'video(1)(2)(1)', 'video(1)(3)(1)', 'video(1)(4)', 'video(2)(3)', 'video(3)(2)', 'video(4)(1)', 'video(5)', 'video(1)(5)', 'video(2)(4)', 'video(3)(3)', 'video(4)(2)', 'video(5)(1)', 'video(1)(1)(2)', 'video(1)(2)(2)', 'video(1)(3)(2)', 'video(1)(4)(1)', 'video(1)(5)(1)', 'video(1)(6)']\n assert candidate(names = ['game', 'game', 'game', 'game(1)', 'game(1)', 'game(2)', 'game', 'game(1)(1)', 'game(1)(1)']) == ['game', 'game(1)', 'game(2)', 'game(1)(1)', 'game(1)(2)', 'game(2)(1)', 'game(3)', 'game(1)(1)(1)', 'game(1)(1)(2)']\n assert candidate(names = ['photo', 'photo(1)', 'photo', 'photo(1)', 'photo(2)', 'photo(1)(1)', 'photo(2)(1)']) == ['photo', 'photo(1)', 'photo(2)', 'photo(1)(1)', 'photo(2)(1)', 'photo(1)(1)(1)', 'photo(2)(1)(1)']\n assert candidate(names = ['test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test']) == ['test', 'test(1)', 'test(2)', 'test(3)', 'test(4)', 'test(5)', 'test(6)', 'test(7)', 'test(8)', 'test(9)', 'test(10)', 'test(11)', 'test(12)', 'test(13)', 'test(14)', 'test(15)', 'test(16)']\n assert candidate(names = ['report', 'report', 'report(1)', 'report(2)', 'report', 'report(1)', 'report', 'report(1)(1)', 'report(3)', 'report(4)', 'report(2)(2)', 'report(5)', 'report(2)', 'report(6)', 'report(7)']) == ['report', 'report(1)', 'report(1)(1)', 'report(2)', 'report(3)', 'report(1)(2)', 'report(4)', 'report(1)(1)(1)', 'report(3)(1)', 'report(4)(1)', 'report(2)(2)', 'report(5)', 'report(2)(1)', 'report(6)', 'report(7)']\n assert candidate(names = ['report', 'report', 'report', 'report', 'report(1)', 'report(1)', 'report(2)', 'report', 'report(1)(1)', 'report(1)(2)', 'report(1)', 'report(2)', 'report(3)', 'report']) == ['report', 'report(1)', 'report(2)', 'report(3)', 'report(1)(1)', 'report(1)(2)', 'report(2)(1)', 'report(4)', 'report(1)(1)(1)', 'report(1)(2)(1)', 'report(1)(3)', 'report(2)(2)', 'report(3)(1)', 'report(5)']\n assert candidate(names = ['file', 'file(1)', 'file', 'file(2)', 'file', 'file(1)', 'file', 'file(1)(1)', 'file(3)', 'file(4)', 'file(2)(2)']) == ['file', 'file(1)', 'file(2)', 'file(2)(1)', 'file(3)', 'file(1)(1)', 'file(4)', 'file(1)(1)(1)', 'file(3)(1)', 'file(4)(1)', 'file(2)(2)']\n assert candidate(names = ['log', 'log', 'log(1)', 'log(2)', 'log', 'log(1)(1)', 'log(1)', 'log(2)', 'log(3)', 'log(2)(1)', 'log(2)(2)', 'log(2)(3)', 'log(1)(2)(1)', 'log(1)(1)(1)', 'log(1)(1)(2)', 'log(1)(1)(1)(1)', 'log(1)(1)(1)(2)', 'log(3)(1)', 'log(3)(2)', 'log(3)(3)', 'log(3)(2)(1)']) == ['log', 'log(1)', 'log(1)(1)', 'log(2)', 'log(3)', 'log(1)(1)(1)', 'log(1)(2)', 'log(2)(1)', 'log(3)(1)', 'log(2)(1)(1)', 'log(2)(2)', 'log(2)(3)', 'log(1)(2)(1)', 'log(1)(1)(1)(1)', 'log(1)(1)(2)', 'log(1)(1)(1)(1)(1)', 'log(1)(1)(1)(2)', 'log(3)(1)(1)', 'log(3)(2)', 'log(3)(3)', 'log(3)(2)(1)']\n assert candidate(names = ['game', 'game(1)', 'game(2)', 'game(3)', 'game', 'game(1)', 'game(4)']) == ['game', 'game(1)', 'game(2)', 'game(3)', 'game(4)', 'game(1)(1)', 'game(4)(1)']\n assert candidate(names = ['image', 'image', 'image', 'image(1)', 'image(2)', 'image(3)', 'image', 'image(1)(1)', 'image(1)(2)', 'image(2)(1)', 'image(4)', 'image', 'image(5)', 'image(6)', 'image(1)(1)', 'image(7)', 'image', 'image(2)', 'image(8)', 'image(9)', 'image(10)', 'image(11)', 'image', 'image(12)', 'image', 'image(13)', 'image', 'image(14)', 'image', 'image(15)', 'image', 'image(16)', 'image', 'image(17)']) == ['image', 'image(1)', 'image(2)', 'image(1)(1)', 'image(2)(1)', 'image(3)', 'image(4)', 'image(1)(1)(1)', 'image(1)(2)', 'image(2)(1)(1)', 'image(4)(1)', 'image(5)', 'image(5)(1)', 'image(6)', 'image(1)(1)(2)', 'image(7)', 'image(8)', 'image(2)(2)', 'image(8)(1)', 'image(9)', 'image(10)', 'image(11)', 'image(12)', 'image(12)(1)', 'image(13)', 'image(13)(1)', 'image(14)', 'image(14)(1)', 'image(15)', 'image(15)(1)', 'image(16)', 'image(16)(1)', 'image(17)', 'image(17)(1)']\n assert candidate(names = ['game', 'game', 'game(1)', 'game', 'game(1)', 'game(2)', 'game(2)']) == ['game', 'game(1)', 'game(1)(1)', 'game(2)', 'game(1)(2)', 'game(2)(1)', 'game(2)(2)']\n assert candidate(names = ['data', 'data', 'data', 'data(1)', 'data', 'data(1)', 'data(2)', 'data(1)(1)', 'data(1)(2)', 'data(1)(1)(1)']) == ['data', 'data(1)', 'data(2)', 'data(1)(1)', 'data(3)', 'data(1)(2)', 'data(2)(1)', 'data(1)(1)(1)', 'data(1)(2)(1)', 'data(1)(1)(1)(1)']\n assert candidate(names = ['music', 'music', 'music', 'music', 'music(1)', 'music(1)', 'music(2)', 'music', 'music(1)', 'music(2)', 'music(3)', 'music(1)(1)', 'music(1)(2)', 'music(1)(3)', 'music(1)', 'music(2)', 'music(3)', 'music(4)', 'music', 'music(1)', 'music(2)', 'music(3)', 'music(4)', 'music(5)', 'music(1)(1)', 'music(1)(2)', 'music(1)(3)', 'music(1)(4)', 'music(1)(5)', 'music(1)(6)', 'music(1)(7)', 'music(1)(8)', 'music(1)(9)', 'music(1)(10)']) == ['music', 'music(1)', 'music(2)', 'music(3)', 'music(1)(1)', 'music(1)(2)', 'music(2)(1)', 'music(4)', 'music(1)(3)', 'music(2)(2)', 'music(3)(1)', 'music(1)(1)(1)', 'music(1)(2)(1)', 'music(1)(3)(1)', 'music(1)(4)', 'music(2)(3)', 'music(3)(2)', 'music(4)(1)', 'music(5)', 'music(1)(5)', 'music(2)(4)', 'music(3)(3)', 'music(4)(2)', 'music(5)(1)', 'music(1)(1)(2)', 'music(1)(2)(2)', 'music(1)(3)(2)', 'music(1)(4)(1)', 'music(1)(5)(1)', 'music(1)(6)', 'music(1)(7)', 'music(1)(8)', 'music(1)(9)', 'music(1)(10)']\n assert candidate(names = ['doc', 'doc', 'doc(1)', 'doc', 'doc(1)', 'doc(2)', 'doc', 'doc(1)', 'doc(2)', 'doc(3)', 'doc']) == ['doc', 'doc(1)', 'doc(1)(1)', 'doc(2)', 'doc(1)(2)', 'doc(2)(1)', 'doc(3)', 'doc(1)(3)', 'doc(2)(2)', 'doc(3)(1)', 'doc(4)']\n assert candidate(names = ['movie', 'movie', 'movie', 'movie', 'movie(1)', 'movie(1)', 'movie(2)', 'movie(2)', 'movie(3)', 'movie(3)']) == ['movie', 'movie(1)', 'movie(2)', 'movie(3)', 'movie(1)(1)', 'movie(1)(2)', 'movie(2)(1)', 'movie(2)(2)', 'movie(3)(1)', 'movie(3)(2)']\n assert candidate(names = ['photo', 'photo', 'photo(1)', 'photo', 'photo(2)', 'photo(1)', 'photo(3)', 'photo(4)']) == ['photo', 'photo(1)', 'photo(1)(1)', 'photo(2)', 'photo(2)(1)', 'photo(1)(2)', 'photo(3)', 'photo(4)']\n assert candidate(names = ['game', 'game', 'game', 'game(1)', 'game(2)', 'game', 'game(1)(1)', 'game(1)']) == ['game', 'game(1)', 'game(2)', 'game(1)(1)', 'game(2)(1)', 'game(3)', 'game(1)(1)(1)', 'game(1)(2)']\n assert candidate(names = ['doc', 'doc', 'doc', 'doc', 'doc', 'doc(1)', 'doc(2)', 'doc', 'doc(3)', 'doc(1)(1)']) == ['doc', 'doc(1)', 'doc(2)', 'doc(3)', 'doc(4)', 'doc(1)(1)', 'doc(2)(1)', 'doc(5)', 'doc(3)(1)', 'doc(1)(1)(1)']\n"}, "metadata": {"canonical_parameter_names": ["names"], "leetcode_dataset_entry_point": "Solution().getFolderNames", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getFolderNames(self, names: list[str]) -> list[str]:", "container": "Solution", "callable": "getFolderNames", "parameters": [{"name": "names", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1488, "task_id": "avoid-flood-in-the-city", "difficulty": "Medium", "problem_description": "Your country has an infinite number of lakes. Initially, all the lakes are empty, but when it rains over the nth lake, the nth lake becomes full of water. If it rains over a lake that is full of water, there will be a flood. Your goal is to avoid floods in any lake.\nGiven an integer array rains where:\n\nrains[i] > 0 means there will be rains over the rains[i] lake.\nrains[i] == 0 means there are no rains this day and you can choose one lake this day and dry it.\n\nReturn an array ans where:\n\nans.length == rains.length\nans[i] == -1 if rains[i] > 0.\nans[i] is the lake you choose to dry in the ith day if rains[i] == 0.\n\nIf there are multiple valid answers return any of them. If it is impossible to avoid flood return an empty array.\nNotice that if you chose to dry a full lake, it becomes empty, but if you chose to dry an empty lake, nothing changes.\n \nExample 1:\n\nInput: rains = [1,2,3,4]\nOutput: [-1,-1,-1,-1]\nExplanation: After the first day full lakes are [1]\nAfter the second day full lakes are [1,2]\nAfter the third day full lakes are [1,2,3]\nAfter the fourth day full lakes are [1,2,3,4]\nThere's no day to dry any lake and there is no flood in any lake.\n\nExample 2:\n\nInput: rains = [1,2,0,0,2,1]\nOutput: [-1,-1,2,1,-1,-1]\nExplanation: After the first day full lakes are [1]\nAfter the second day full lakes are [1,2]\nAfter the third day, we dry lake 2. Full lakes are [1]\nAfter the fourth day, we dry lake 1. There is no full lakes.\nAfter the fifth day, full lakes are [2].\nAfter the sixth day, full lakes are [1,2].\nIt is easy that this scenario is flood-free. [-1,-1,1,2,-1,-1] is another acceptable scenario.\n\nExample 3:\n\nInput: rains = [1,2,0,1,2]\nOutput: []\nExplanation: After the second day, full lakes are [1,2]. We have to dry one lake in the third day.\nAfter that, it will rain over lakes [1,2]. It's easy to prove that no matter which lake you choose to dry in the 3rd day, the other one will flood.\n\n \nConstraints:\n\n1 <= rains.length <= 105\n0 <= rains[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rains = [0, 1, 1, 0, 2, 0, 1]) == []\n assert candidate(rains = [1, 2, 0, 1, 2]) == []\n assert candidate(rains = [1, 0, 2, 0, 0, 1, 0, 2]) == [-1, 1, -1, 2, 1, -1, 1, -1]\n assert candidate(rains = [0, 0, 0, 0]) == [1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 0, 2, 1]) == [-1, -1, 2, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 2, 1]) == [-1, 1, -1, 2, -1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 1, 2, 3]) == []\n assert candidate(rains = [2, 3, 0, 0, 3, 1, 0, 1, 0, 1]) == [-1, -1, 3, 1, -1, -1, 1, -1, 1, -1]\n assert candidate(rains = [0, 1, 0, 2, 0, 1, 0, 2]) == [1, -1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 2, 1, 0, 1, 0]) == []\n assert candidate(rains = [1, 2, 0, 0, 2, 0, 1, 0]) == [-1, -1, 2, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4]) == [-1, -1, -1, -1]\n assert candidate(rains = [0, 1, 1]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 2]) == [-1, -1, 1, 2, 1, -1, -1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0]) == [-1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 1]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == [-1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == []\n assert candidate(rains = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == []\n assert candidate(rains = [0, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1, 11, -1, 12, -1, 13, -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, -1, 19, -1, 20, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0]) == [-1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [-1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 3, 4, 0, 5, 6, 0, 7, 8, 0, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == []\n assert candidate(rains = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == []\n assert candidate(rains = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == []\n assert candidate(rains = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == []\n assert candidate(rains = [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0]) == [-1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, 2, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1, 1, -1, 2, -1, 3, -1, 1, -1, 2, -1, 3, -1]\n assert candidate(rains = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20]) == []\n assert candidate(rains = [1, 2, 0, 0, 2, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]) == [-1, -1, 2, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 1, 0, 2, 0, 2, 0, 3, 0, 3, 0, 4, 0, 4, 0, 5, 0, 5, 0]) == [-1, 1, -1, 1, -1, 2, -1, 1, -1, 3, -1, 1, -1, 4, -1, 1, -1, 5, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 6, 7, 0, 8, 9, 0, 10, 11, 0, 12, 13, 0, 14, 15, 0, 16, 17, 0, 18, 19, 0, 20]) == [-1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 1]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0]) == [-1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 1, 2, 3, 0, 3, 4, 0, 4, 5, 0, 5, 6, 0, 6, 7, 0, 7, 8, 0, 8, 9, 0, 9, 10, 0, 10]) == []\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 1, 2, 3, 0, 4, 5, 0, 1, 2, 3, 0, 4, 5]) == []\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [3, 0, 4, 0, 5, 0, 3, 0, 4, 0, 5]) == [-1, 3, -1, 4, -1, 5, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0, 5, 6, 7, 8, 0, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1, 0, 2, 0, 3, 0]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == []\n assert candidate(rains = [1, 2, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1, 1, -1, 2, -1, 3, -1, 1]\n assert candidate(rains = [1, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 5, 0, 0, 0, 0]) == [-1, 1, 1, 1, 1, -1, 2, 1, 1, -1, 3, 1, 1, 1, -1, 4, 1, 1, 1, -1, 5, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 0, 2, 0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == []\n assert candidate(rains = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [0, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 0, 1, 2, 3, 4]) == []\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3]) == [-1, -1, -1, 1, 2, 3, -1, -1, -1, 1, 2, 3, -1, -1, -1, 1, 2, 3, -1, -1, -1, 1, 2, 3, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 0, 0, 0, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == [-1, -1, 2, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 2, 0, 3, 0, 0, 3, 0, 0, 4, 0, 0, 4, 0, 0, 5, 0, 0, 5]) == [-1, 1, 1, -1, 2, 1, -1, 1, -1, 3, 1, -1, 1, 1, -1, 4, 1, -1, 1, 1, -1, 5, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 1, 0, 2, 0, 3, 0, 4]) == [-1, 1, -1, 2, -1, 3, -1, 4, -1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == [-1, 1, -1, 2, -1, 3, -1, 2, -1, 1, -1, 3, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0]) == []\n assert candidate(rains = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == [-1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6]) == [-1, -1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 6, 1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 4, 5, 6, 0, 0, 0, 7, 8, 9, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1, 1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 0, 10, 0, 0]) == [-1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5]) == [-1, -1, -1, -1, -1, 5, -1, 4, -1, 3, -1, 2, -1, 1, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1]\n assert candidate(rains = [1, 2, 0, 3, 4, 0, 5, 6, 0, 7, 8, 0, 9, 10, 0, 11, 12, 0, 13, 14]) == [-1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 2]) == [-1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1, 0, 2, 0, 3, 0, 4, 0]) == [-1, -1, 1, -1, 2, -1, 3, -1, 4, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 2, 0, 3, 0, 0, 1, 0, 2, 0, 3, 0, 0, 1, 0, 2, 0, 3]) == [-1, 1, 1, -1, 2, -1, 3, 1, -1, 1, -1, 2, -1, 3, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 1, 0, 0, 0, 2, 2, 0, 0, 3, 3, 0, 0, 4, 4, 0, 0, 5, 5, 0, 0]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6]) == [-1, -1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 6, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 0, 0, 0, 0, 3, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, 1, -1, 2, 1, 1, 1, 1, -1, 3, -1, 4, 1, 1, -1, 5, 1, 1, -1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0, 8, 0, 0, 0, 9, 0, 0, 0, 10, 0, 0, 0]) == [-1, -1, 1, 2, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 2, 0, 0]) == [-1, 1, 1, -1, 2, 1, -1, 1, 1, -1, 2, 1, -1, 1, 1, -1, 1, 1]\n assert candidate(rains = [1, 1, 0, 2, 2, 0, 3, 3, 0, 4, 4, 0, 5, 5, 0, 6, 6, 0, 7, 7, 0, 8, 8, 0, 9, 9, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 2, 3, 0, 4, 0, 5, 0, 4]) == [-1, 1, -1, 2, -1, 1, -1, -1, 1, -1, 4, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == []\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1, 0, 1, 0, 2, 0]) == [-1, 1, -1, 2, -1, 2, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1000000000, 0, 1000000000, 0, 1000000000, 0, 1000000000, 0]) == [-1, 1000000000, -1, 1000000000, -1, 1000000000, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 1, 2, 3, 4, 5, 0, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0, 1, 2, 3, 4]) == [-1, -1, -1, -1, 1, 2, 3, 4, -1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 3, 0, 1, 2, 0, 3, 4, 0, 5, 4, 0, 3, 2, 1, 0]) == []\n assert candidate(rains = [1, 1, 0, 0]) == []\n assert candidate(rains = [0, 1, 2, 3, 0, 1, 2]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 2, 0, 0, 1]) == [-1, -1, 1, 2, 1, -1, -1, 1, 1, -1]\n assert candidate(rains = [1, 1, 0, 2, 0, 2, 1]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1]\n assert candidate(rains = [0]) == [1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 0, 0, 0, 2]) == [-1, 1, -1, 2, 1, 1, 1, -1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 1, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1]) == [-1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 1, 2]) == []\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 1, 2, 3]) == [-1, -1, -1, 1, 2, 3, -1, -1, -1]\n assert candidate(rains = [1, 1, 2, 2, 0, 0]) == []\n assert candidate(rains = [1, 2, 3, 0, 4, 0, 5, 0, 6, 0, 1, 2, 3, 4, 5, 6]) == []\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1]) == [-1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 3, 0, 2, 0, 1]) == [-1, -1, -1, 3, 2, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 3, 0, 1, 2]) == [-1, 1, -1, -1, 2, -1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1, 0, 2]) == [-1, 1, -1, 2, -1, 2, -1, 1, -1]\n assert candidate(rains = [0, 0, 0, 0]) == [1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 3]) == []\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 3, 2, 1]) == [-1, -1, -1, 3, 2, 1, -1, -1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 0, 2, 0, 1]) == [-1, -1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 1, 2]) == [-1, 1, 1, -1, 2, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 2, 0, 1, 0, 3, 0]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 0, 2, 0, 3]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 2]) == []\n assert candidate(rains = [1, 2, 0, 1, 2, 0]) == []\n assert candidate(rains = [1, 0, 2, 3, 0, 1, 0, 2, 3]) == [-1, 1, -1, -1, 2, -1, 3, -1, -1]\n assert candidate(rains = [1, 0, 2, 3, 0, 0, 1, 2]) == [-1, 1, -1, -1, 2, 1, -1, -1]\n assert candidate(rains = [2, 3, 0, 0, 2, 1, 0, 1, 2]) == []\n assert candidate(rains = [1, 1, 0, 0, 2, 2]) == []\n assert candidate(rains = [0, 1, 0, 2, 0, 3, 0, 1, 2, 3]) == [1, -1, 1, -1, 2, -1, 3, -1, -1, -1]\n assert candidate(rains = [1, 0, 0, 0, 0, 2, 1]) == [-1, 1, 1, 1, 1, -1, -1]\n assert candidate(rains = [1, 0, 0, 0, 0, 2, 0, 2]) == [-1, 1, 1, 1, 1, -1, 2, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 1, 2, 3, 4, 0, 5]) == [-1, 1, -1, 2, -1, 3, -1, 4, -1, -1, -1, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 0, 3, 0, 1, 0, 2, 0, 3]) == [-1, -1, 1, 2, -1, 3, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 4, 0, 5, 0, 1, 2, 3]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 1, 2]) == [-1, 1, -1, 2, -1, -1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 2]) == []\n assert candidate(rains = [1, 2, 3, 0, 1, 0, 2, 0, 3, 0]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1, 1]\n assert candidate(rains = [0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 5, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 0, 2, 0, 1, 0]) == [-1, 1, 1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 0, 0, 0, 1, 0, 2]) == [-1, 1, -1, 2, 1, 1, 1, -1, 1, -1]\n assert candidate(rains = [1, 0, 0, 0, 0, 0, 1]) == [-1, 1, 1, 1, 1, 1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 1, 0, 2, 2, 0, 3, 3]) == []\n assert candidate(rains = [0, 0, 0, 0, 1, 1, 1, 1]) == []\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 0, 1, 2, 3]) == [-1, -1, -1, 1, 2, 3, 1, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 0, 2, 1]) == [-1, -1, 2, 1, -1, -1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1000000000, 0, 1000000000, 0]) == [-1, 1000000000, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 0, 3]) == []\n assert candidate(rains = [1, 2, 3, 0, 4, 0, 5, 0, 6, 0, 1]) == [-1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 0, 2, 1, 0, 1, 0, 2]) == [-1, -1, 2, 1, -1, -1, 1, -1, 2, -1]\n assert candidate(rains = [1, 0, 2, 3, 0, 4, 5, 0, 6, 7, 0, 8, 9, 0, 10, 11, 0, 12, 13, 0]) == [-1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 0, 1, 2, 0]) == []\n assert candidate(rains = [1, 2, 3, 0, 4, 0, 5, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 1]) == []\n assert candidate(rains = [0, 1, 1, 0, 2, 0, 1, 0, 2, 0]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 0, 2, 0]) == [-1, -1, 1, 2, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 2]) == [-1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 1, 2]) == [-1, 1, -1, 2, -1, 1, -1, 1, -1, -1]\n assert candidate(rains = [1, 2, 3, 0, 2, 1, 0, 1, 2, 0]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 0, 2]) == [-1, -1, 1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 0, 4]) == [-1, -1, -1, 1, 1, 1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 2, 0, 3, 0, 1]) == [-1, -1, -1, 2, -1, 3, -1, 1, -1]\n assert candidate(rains = [10, 20, 20]) == []\n assert candidate(rains = [1, 0, 2, 0, 0, 0, 1, 2]) == [-1, 1, -1, 2, 1, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 2, 0, 4, 0, 2, 0, 1, 0, 2, 0, 1, 0, 1, 0]) == [-1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 3, 0]) == [-1, -1, -1, 3, -1, -1, -1, 1]\n assert candidate(rains = [1, 2, 0, 0, 0, 0, 2, 1]) == [-1, -1, 2, 1, 1, 1, -1, -1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1]) == [-1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1]) == [-1]\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 3, 0, 2, 0, 4, 0]) == [-1, 1, -1, 2, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 0, 1, 0, 2, 0, 1]) == [-1, -1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 1, 0, 2, 2, 0, 1]) == []\n assert candidate(rains = [1, 2, 3, 4, 0, 0]) == [-1, -1, -1, -1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 2, 0, 1]) == [-1, 1, -1, 2, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 1, 0, 2]) == [-1, 1, 1, -1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 0, 2, 1, 0, 0]) == [-1, -1, 2, 1, -1, -1, 1, 1]\n assert candidate(rains = [1, 1, 1, 1, 1]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 3, 2]) == [-1, -1, 2, 1, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 0, 1, 0, 2]) == [-1, 1, -1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 0, 0, 0, 0, 2]) == [-1, 1, 1, 1, 1, 1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0]) == [-1, -1, -1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 1, 0, 2, 3, 4, 5]) == []\n assert candidate(rains = [3, 3, 0, 0, 0, 2, 0, 0, 3, 2, 1, 0, 0, 1]) == []\n assert candidate(rains = [1, 1, 0, 1, 2]) == []\n assert candidate(rains = [1, 0, 0, 0, 2, 0, 0, 2]) == [-1, 1, 1, 1, -1, 2, 1, -1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 1, 0]) == [-1, 1, 1, -1, 1, 1, -1, 1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 2, 0]) == []\n assert candidate(rains = [1, 2, 0, 0, 2, 1, 0]) == [-1, -1, 2, 1, -1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1, 1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 3]) == []\n assert candidate(rains = [1, 2, 0, 2, 3, 0, 1]) == [-1, -1, 2, -1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 3]) == []\n assert candidate(rains = [1, 0, 0, 0, 2, 2, 2, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 0, 3, 0, 2, 1, 0]) == [-1, 1, -1, 2, 1, -1, 1, -1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4]) == [-1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 3, 0, 1, 0, 2, 0, 3]) == [-1, 1, -1, -1, 2, -1, 3, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 1]) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, -1]\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1, 0]) == [-1, 1, -1, 2, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 0, 1, 2, 3, 0, 0, 1, 2]) == []\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 1]) == [-1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 0, 2]) == [-1, -1, 1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 1]) == [-1, -1, -1, 1, -1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 2, 0, 1, 0]) == [-1, -1, -1, 2, 1, -1, 1, -1, 1]\n assert candidate(rains = [0, 1, 0, 2, 0, 1, 0]) == [1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 2, 0]) == [-1, 1, -1, 2, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 0, 2, 0, 0, 1]) == [-1, 1, 1, 1, -1, 1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == []\n"}, "metadata": {"canonical_parameter_names": ["rains"], "leetcode_dataset_entry_point": "Solution().avoidFlood", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def avoidFlood(self, rains: list[int]) -> list[int]:", "container": "Solution", "callable": "avoidFlood", "parameters": [{"name": "rains", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1489, "task_id": "find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree", "difficulty": "Hard", "problem_description": "Given a weighted undirected connected graph with n vertices numbered from 0 to n - 1, and an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional and weighted edge between nodes ai and bi. A minimum spanning tree (MST) is a subset of the graph's edges that connects all vertices without cycles and with the minimum possible total edge weight.\nFind all the critical and pseudo-critical edges in the given graph's minimum spanning tree (MST). An MST edge whose deletion from the graph would cause the MST weight to increase is called a critical edge. On the other hand, a pseudo-critical edge is that which can appear in some MSTs but not all.\nNote that you can return the indices of the edges in any order.\n \nExample 1:\n\n\nInput: n = 5, edges = [[0,1,1],[1,2,1],[2,3,2],[0,3,2],[0,4,3],[3,4,3],[1,4,6]]\nOutput: [[0,1],[2,3,4,5]]\nExplanation: The figure above describes the graph.\nThe following figure shows all the possible MSTs:\n\nNotice that the two edges 0 and 1 appear in all MSTs, therefore they are critical edges, so we return them in the first list of the output.\nThe edges 2, 3, 4, and 5 are only part of some MSTs, therefore they are considered pseudo-critical edges. We add them to the second list of the output.\n\nExample 2:\n\n\nInput: n = 4, edges = [[0,1,1],[1,2,1],[2,3,1],[0,3,1]]\nOutput: [[],[0,1,2,3]]\nExplanation: We can observe that since all 4 edges have equal weight, choosing any 3 edges from the given 4 will yield an MST. Therefore all 4 edges are pseudo-critical.\n\n \nConstraints:\n\n2 <= n <= 100\n1 <= edges.length <= min(200, n * (n - 1) / 2)\nedges[i].length == 3\n0 <= ai < bi < n\n1 <= weighti <= 1000\nAll pairs (ai, bi) are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,edges = [[0, 1, 1], [1, 2, 1], [0, 2, 2]]) == [[0, 1], []]\n assert candidate(n = 5,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [0, 3, 2], [0, 4, 3], [3, 4, 3], [1, 4, 6]]) == [[0, 1], [2, 3, 4, 5]]\n assert candidate(n = 6,edges = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [3, 4, 6], [4, 5, 7]]) == [[0, 1, 3, 5, 6], []]\n assert candidate(n = 6,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 0, 5], [1, 3, 6]]) == [[0, 1, 2, 3, 4], []]\n assert candidate(n = 4,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [0, 3, 1]]) == [[], [0, 1, 2, 3]]\n assert candidate(n = 3,edges = [[0, 1, 1], [1, 2, 2], [2, 0, 2]]) == [[0], [1, 2]]\n assert candidate(n = 3,edges = [[0, 1, 1], [1, 2, 2], [0, 2, 3]]) == [[0, 1], []]\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 3, 2]]) == [[], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 0, 1]]) == [[], [0, 1, 2, 3, 4, 5, 6]]\n assert candidate(n = 5,edges = [[0, 1, 2], [0, 3, 6], [1, 2, 5], [1, 3, 8], [1, 4, 9], [2, 4, 7], [3, 4, 4]]) == [[0, 6, 2, 1], []]\n assert candidate(n = 6,edges = [[0, 1, 4], [0, 2, 4], [1, 2, 2], [1, 3, 3], [1, 4, 2], [2, 3, 1], [3, 4, 2], [3, 5, 3], [4, 5, 3]]) == [[5], [2, 4, 6, 7, 8, 0, 1]]\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [5, 6, 15], [0, 4, 16], [0, 5, 17], [0, 6, 18], [1, 5, 19], [1, 6, 20], [2, 6, 21]]) == [[0, 1, 2, 5, 8, 11], []]\n assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 0, 1], [0, 6, 2], [1, 7, 2], [2, 8, 2], [3, 9, 2], [4, 10, 2], [5, 11, 2]]) == [[], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]]\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 2, 10], [1, 3, 20], [1, 4, 30], [2, 3, 10], [2, 4, 20], [2, 5, 30], [3, 4, 10], [3, 5, 20], [3, 6, 30], [4, 5, 10], [4, 6, 20], [4, 7, 30], [5, 6, 10], [5, 7, 20], [5, 8, 30], [6, 7, 10], [6, 8, 20], [6, 9, 30], [7, 8, 10], [7, 9, 20], [8, 9, 10]]) == [[0, 3, 6, 9, 12, 15, 18, 21, 23], []]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [2, 3, 6], [2, 4, 7], [3, 4, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [7, 9, 16], [8, 9, 17]]) == [[0, 1, 2, 6, 8, 9, 11, 13, 15], []]\n assert candidate(n = 12,edges = [[0, 1, 3], [0, 2, 4], [0, 3, 5], [1, 2, 2], [1, 3, 6], [1, 4, 7], [2, 3, 8], [2, 4, 9], [2, 5, 10], [3, 4, 11], [3, 5, 12], [3, 6, 13], [4, 5, 14], [4, 6, 15], [4, 7, 16], [5, 6, 17], [5, 7, 18], [5, 8, 19], [6, 7, 20], [6, 8, 21], [6, 9, 22], [7, 8, 23], [7, 9, 24], [7, 10, 25], [8, 9, 26], [8, 10, 27], [8, 11, 28], [9, 10, 29], [9, 11, 30], [10, 11, 31]]) == [[3, 0, 2, 5, 8, 11, 14, 17, 20, 23, 26], []]\n assert candidate(n = 9,edges = [[0, 1, 100], [0, 2, 90], [0, 3, 95], [1, 2, 85], [1, 3, 80], [1, 4, 75], [2, 3, 65], [2, 4, 60], [2, 5, 55], [3, 4, 50], [3, 5, 45], [3, 6, 40], [4, 5, 35], [4, 6, 30], [4, 7, 25], [5, 6, 20], [5, 7, 15], [5, 8, 10], [6, 7, 5], [6, 8, 1], [7, 8, 50]]) == [[19, 18, 17, 14, 11, 8, 5, 1], []]\n assert candidate(n = 12,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [1, 4, 40], [2, 5, 50], [2, 6, 60], [3, 7, 70], [3, 8, 80], [4, 9, 90], [4, 10, 100], [5, 11, 110], [6, 11, 120], [7, 8, 130], [8, 9, 140], [9, 10, 150], [10, 11, 160], [0, 3, 170], [1, 5, 180], [2, 7, 190], [3, 9, 200], [4, 11, 210]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], []]\n assert candidate(n = 15,edges = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 2, 25], [1, 4, 35], [2, 3, 40], [2, 5, 45], [3, 4, 50], [3, 6, 55], [4, 5, 60], [5, 6, 65], [6, 7, 70], [6, 8, 75], [7, 8, 80], [7, 9, 85], [8, 9, 90], [9, 10, 95], [9, 11, 100], [10, 11, 105], [10, 12, 110], [11, 12, 115], [12, 13, 120], [12, 14, 125], [13, 14, 130]]) == [[0, 1, 2, 4, 6, 8, 11, 12, 14, 16, 17, 19, 21, 22], []]\n assert candidate(n = 8,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [0, 7, 8], [1, 3, 9], [2, 4, 10], [3, 5, 11], [4, 6, 12], [5, 7, 13], [0, 3, 14], [1, 4, 15], [2, 5, 16], [3, 6, 17], [4, 7, 18]]) == [[0, 1, 2, 3, 4, 5, 6], []]\n assert candidate(n = 8,edges = [[0, 1, 5], [0, 2, 20], [0, 3, 30], [1, 2, 15], [1, 4, 10], [2, 3, 10], [2, 4, 25], [2, 5, 35], [3, 4, 5], [3, 6, 15], [4, 5, 20], [4, 6, 10], [4, 7, 25], [5, 6, 30], [5, 7, 15], [6, 7, 20]]) == [[0, 8, 4, 5, 11, 14], [10, 15]]\n assert candidate(n = 8,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [0, 7, 7], [1, 3, 8], [2, 4, 9], [3, 5, 10], [4, 6, 11]]) == [[0, 1, 2, 3, 4, 5, 6], []]\n assert candidate(n = 6,edges = [[0, 1, 100], [0, 2, 50], [0, 3, 20], [1, 2, 60], [1, 3, 40], [1, 4, 70], [2, 3, 30], [2, 4, 80], [2, 5, 90], [3, 4, 5], [3, 5, 10], [4, 5, 100]]) == [[9, 10, 2, 6, 4], []]\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [4, 7, 15], [5, 6, 16], [5, 7, 17], [6, 7, 18]]) == [[0, 1, 2, 5, 8, 11, 14], []]\n assert candidate(n = 8,edges = [[0, 1, 10], [0, 2, 6], [0, 3, 5], [1, 3, 15], [2, 3, 4], [2, 4, 11], [3, 4, 9], [3, 5, 10], [4, 5, 13], [4, 6, 14], [5, 6, 16], [5, 7, 7], [6, 7, 18]]) == [[4, 2, 11, 6, 0, 7, 9], []]\n assert candidate(n = 12,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 3], [1, 4, 5], [2, 3, 6], [2, 4, 7], [3, 5, 8], [4, 5, 9], [5, 6, 10], [6, 7, 11], [6, 8, 12], [7, 9, 13], [8, 9, 14], [9, 10, 15], [10, 11, 16], [11, 0, 17], [2, 7, 18], [3, 8, 19], [4, 9, 20], [5, 10, 21]]) == [[0, 2, 1, 3, 6, 8, 9, 10, 11, 13, 14], []]\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 20], [1, 2, 5], [1, 3, 15], [2, 3, 25], [2, 4, 10], [3, 4, 30], [3, 5, 15], [4, 5, 5], [4, 6, 20], [5, 6, 25], [5, 7, 10], [6, 7, 30], [6, 8, 15], [7, 8, 5], [7, 9, 20], [8, 9, 25]]) == [[2, 8, 14, 0, 5, 11, 13, 15], [3, 7]]\n assert candidate(n = 9,edges = [[0, 1, 5], [0, 2, 6], [0, 3, 7], [1, 2, 8], [1, 3, 9], [2, 3, 10], [2, 4, 11], [3, 4, 12], [3, 5, 13], [4, 5, 14], [4, 6, 15], [5, 6, 16], [5, 7, 17], [6, 7, 18], [6, 8, 19], [7, 8, 20], [0, 4, 21], [1, 5, 22], [2, 6, 23], [3, 7, 24], [4, 8, 25]]) == [[0, 1, 2, 6, 8, 10, 12, 14], []]\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 15], [0, 3, 20], [1, 2, 35], [1, 3, 25], [2, 3, 30], [4, 5, 10], [4, 6, 20], [4, 7, 30], [5, 6, 25], [5, 7, 35], [6, 7, 40], [8, 9, 5], [8, 7, 15], [7, 9, 10]]) == [[12, 0, 6, 14, 1, 13, 2, 7, 4, 9, 5, 8, 3, 10, 11], []]\n assert candidate(n = 15,edges = [[0, 1, 5], [0, 2, 7], [0, 3, 9], [1, 2, 3], [1, 3, 2], [1, 4, 6], [2, 3, 1], [2, 4, 4], [2, 5, 8], [3, 4, 11], [3, 5, 13], [3, 6, 15], [4, 5, 12], [4, 6, 14], [5, 6, 16], [5, 7, 18], [5, 8, 20], [6, 7, 21], [6, 8, 22], [7, 8, 23], [7, 9, 25], [7, 10, 27], [8, 9, 24], [8, 10, 26], [9, 10, 28], [9, 11, 29], [9, 12, 31], [10, 11, 30], [10, 12, 32], [11, 12, 33], [11, 13, 35], [11, 14, 37], [12, 13, 34], [12, 14, 36], [13, 14, 38]]) == [[6, 4, 7, 0, 8, 13, 15, 16, 22, 23, 25, 26, 32, 33], []]\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 6, 7], [3, 7, 8], [4, 7, 9], [5, 7, 10], [0, 3, 11], [1, 5, 12], [2, 4, 13], [6, 7, 14]]) == [[0, 1, 2, 3, 4, 5, 7], []]\n assert candidate(n = 9,edges = [[0, 1, 5], [0, 2, 6], [0, 3, 7], [1, 2, 8], [1, 3, 9], [1, 4, 10], [2, 3, 11], [2, 4, 12], [2, 5, 13], [3, 4, 14], [3, 5, 15], [3, 6, 16], [4, 5, 17], [4, 6, 18], [4, 7, 19], [5, 6, 20], [5, 7, 21], [5, 8, 22], [6, 7, 23], [7, 8, 24]]) == [[0, 1, 2, 5, 8, 11, 14, 17], []]\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10], [0, 3, 20], [1, 4, 20], [2, 5, 20], [3, 6, 20], [4, 7, 20], [5, 8, 20], [6, 9, 20], [7, 0, 20], [8, 1, 20], [9, 2, 20]]) == [[], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(n = 10,edges = [[0, 1, 4], [0, 2, 8], [1, 2, 2], [1, 3, 6], [2, 3, 3], [3, 4, 5], [4, 5, 9], [5, 6, 10], [6, 7, 1], [7, 8, 7], [8, 9, 11], [9, 0, 12], [1, 4, 13], [2, 5, 14]]) == [[8, 2, 4, 0, 5, 9, 6, 7, 10], []]\n assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [5, 6, 15], [6, 7, 16], [6, 8, 17], [7, 8, 18], [7, 9, 19], [8, 9, 20], [8, 10, 21], [9, 10, 22], [9, 11, 23], [10, 11, 24]]) == [[0, 1, 2, 5, 8, 11, 15, 16, 18, 20, 22], []]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8], [6, 7, 9], [7, 8, 10], [8, 9, 11], [0, 9, 15], [2, 8, 12], [4, 7, 13]]) == [[0, 1, 3, 5, 6, 7, 8, 9, 10], []]\n assert candidate(n = 11,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [1, 2, 6], [1, 3, 7], [1, 4, 8], [1, 5, 9], [2, 3, 10], [2, 4, 11], [2, 5, 12], [2, 6, 13], [3, 4, 14], [3, 5, 15], [3, 6, 16], [3, 7, 17], [4, 5, 18], [4, 6, 19], [4, 7, 20], [4, 8, 21], [5, 6, 22], [5, 7, 23], [5, 8, 24], [5, 9, 25], [6, 7, 26], [6, 8, 27], [6, 9, 28], [6, 10, 29], [7, 8, 30], [7, 9, 31], [7, 10, 32], [8, 9, 33], [8, 10, 34], [9, 10, 35]]) == [[0, 1, 2, 3, 7, 11, 15, 19, 23, 27], []]\n assert candidate(n = 8,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 0, 9], [0, 3, 10], [1, 4, 11], [2, 5, 12], [3, 6, 13], [4, 7, 14], [5, 0, 15], [6, 1, 16], [7, 2, 17]]) == [[0, 1, 2, 3, 4, 5, 6], []]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [1, 4, 1], [1, 5, 1], [2, 4, 1], [2, 6, 1], [3, 5, 1], [3, 6, 1], [4, 7, 1], [5, 7, 1], [6, 7, 1], [7, 8, 1], [0, 4, 1], [0, 5, 1], [0, 6, 1], [1, 6, 1], [1, 7, 1], [2, 5, 1], [2, 7, 1], [3, 4, 1], [3, 7, 1], [4, 6, 1], [5, 6, 1], [4, 8, 1], [5, 8, 1], [6, 8, 1]]) == [[], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]]\n assert candidate(n = 7,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 0, 10], [0, 3, 20], [1, 4, 20], [2, 5, 20], [3, 6, 20], [4, 0, 20], [5, 1, 20], [6, 2, 20]]) == [[], [0, 1, 2, 3, 4, 5, 6]]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [0, 5, 5], [0, 6, 6], [0, 7, 7], [0, 8, 8], [1, 2, 9], [2, 3, 10], [3, 4, 11], [4, 5, 12], [5, 6, 13], [6, 7, 14], [7, 8, 15], [8, 1, 16], [1, 3, 17], [3, 5, 18], [5, 7, 19], [7, 1, 20], [1, 4, 21], [4, 6, 22], [6, 8, 23], [8, 2, 24], [2, 4, 25], [4, 7, 26], [7, 3, 27], [3, 6, 28], [6, 1, 29], [1, 5, 30], [5, 2, 31], [2, 7, 32], [7, 4, 33], [4, 8, 34], [8, 3, 35], [3, 1, 36]]) == [[0, 1, 2, 3, 4, 5, 6, 7], []]\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [0, 5, 1], [0, 6, 1], [0, 7, 1], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 7, 2], [7, 1, 2], [1, 3, 2], [3, 5, 2], [5, 7, 2], [7, 2, 2], [2, 4, 2], [4, 6, 2], [6, 1, 2], [1, 4, 2], [4, 7, 2], [7, 3, 2], [3, 6, 2], [6, 2, 2], [2, 5, 2], [5, 3, 2], [3, 7, 2], [7, 4, 2], [4, 1, 2], [1, 5, 2], [5, 2, 2], [2, 6, 2], [6, 3, 2], [3, 1, 2], [1, 6, 2], [6, 4, 2], [4, 2, 2], [2, 7, 2], [7, 5, 2], [5, 4, 2], [4, 3, 2], [3, 2, 2], [2, 1, 2], [1, 7, 2], [7, 6, 2], [6, 5, 2], [5, 4, 2], [4, 3, 2], [3, 1, 2], [1, 6, 2], [6, 4, 2], [4, 2, 2], [2, 7, 2], [7, 5, 2], [5, 3, 2], [3, 7, 2]]) == [[0, 1, 2, 3, 4, 5, 6], []]\n assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 4], [1, 5, 5], [2, 6, 6], [2, 7, 7], [3, 8, 8], [3, 9, 9], [4, 10, 10], [5, 11, 11], [6, 11, 12], [7, 10, 13], [8, 9, 14], [9, 10, 15], [10, 11, 16]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], []]\n assert candidate(n = 10,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 0, 1], [0, 5, 2], [1, 6, 2], [2, 7, 2], [3, 8, 2], [4, 9, 2]]) == [[], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]\n assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 0, 11], [0, 2, 12], [1, 3, 13], [2, 4, 14], [3, 5, 15], [4, 6, 16], [5, 7, 17], [6, 8, 18], [7, 9, 19], [8, 10, 20], [9, 11, 21], [10, 0, 22], [11, 1, 23], [0, 3, 24], [1, 4, 25], [2, 5, 26], [3, 6, 27], [4, 7, 28], [5, 8, 29], [6, 9, 30], [7, 10, 31], [8, 11, 32], [9, 0, 33], [10, 1, 34], [11, 2, 35], [0, 4, 36], [1, 5, 37], [2, 6, 38], [3, 7, 39], [4, 8, 40], [5, 9, 41], [6, 10, 42], [7, 11, 43], [8, 0, 44], [9, 1, 45], [10, 2, 46], [11, 3, 47], [0, 5, 48], [1, 6, 49], [2, 7, 50], [3, 8, 51], [4, 9, 52], [5, 10, 53], [6, 11, 54], [7, 0, 55], [8, 1, 56], [9, 2, 57], [10, 3, 58], [11, 4, 59]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], []]\n assert candidate(n = 8,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [1, 2, 1], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [4, 7, 15], [5, 6, 16], [5, 7, 17], [6, 7, 18]]) == [[3, 0, 2, 5, 8, 11, 14], []]\n assert candidate(n = 15,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15], [0, 7, 16], [1, 8, 17], [2, 9, 18], [3, 10, 19], [4, 11, 20], [5, 12, 21], [6, 13, 22], [7, 14, 23], [8, 0, 24], [9, 1, 25], [10, 2, 26], [11, 3, 27], [12, 4, 28], [13, 5, 29], [14, 6, 30]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], []]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [0, 4, 16], [1, 5, 17], [2, 6, 18], [3, 7, 19], [0, 5, 20], [1, 6, 21], [2, 7, 22], [3, 8, 23], [0, 6, 24], [1, 7, 25], [2, 8, 26]]) == [[0, 1, 3, 5, 7, 9, 11, 13], []]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 10], [0, 3, 10], [1, 2, 10], [1, 3, 10], [2, 3, 10], [2, 4, 1], [2, 5, 10], [3, 4, 10], [3, 5, 10], [4, 5, 1], [4, 6, 10], [4, 7, 10], [5, 6, 10], [5, 7, 10], [6, 7, 1], [6, 8, 10], [7, 8, 10]]) == [[0, 6, 10, 15], [1, 2, 3, 4, 5, 8, 9, 11, 12, 13, 14, 16, 17]]\n assert candidate(n = 9,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [1, 2, 5], [1, 3, 6], [2, 3, 7], [3, 4, 8], [4, 5, 9], [5, 6, 10], [6, 7, 11], [7, 8, 12], [8, 4, 13], [0, 5, 14], [1, 6, 15], [2, 7, 16]]) == [[0, 1, 2, 6, 7, 8, 9, 10], []]\n assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [4, 7, 15], [5, 6, 16], [5, 7, 17], [5, 8, 18], [6, 7, 19], [6, 8, 20], [6, 9, 21], [7, 8, 22], [7, 9, 23], [7, 10, 24], [8, 9, 25], [8, 10, 26], [8, 11, 27], [9, 10, 28], [9, 11, 29], [10, 11, 30]]) == [[0, 1, 2, 5, 8, 11, 14, 17, 20, 23, 26], []]\n assert candidate(n = 10,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 5, 11], [1, 6, 12], [2, 7, 13], [3, 8, 14], [4, 9, 15]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8], []]\n assert candidate(n = 9,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 7, 2], [7, 8, 2], [8, 0, 2], [0, 2, 3], [1, 3, 3], [2, 4, 3], [3, 5, 3], [4, 6, 3], [5, 7, 3], [6, 8, 3], [7, 0, 3], [8, 1, 3]]) == [[], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [4, 7, 15], [5, 6, 16], [5, 7, 17], [5, 8, 18], [6, 7, 19], [6, 8, 20], [6, 9, 21], [7, 8, 22], [7, 9, 23], [7, 10, 24], [8, 9, 25], [8, 10, 26], [8, 11, 27], [9, 10, 28], [9, 11, 29], [10, 11, 30], [11, 12, 31], [11, 13, 32], [11, 14, 33], [12, 13, 34], [12, 14, 35], [13, 14, 36]]) == [[0, 1, 2, 5, 8, 11, 14, 17, 20, 23, 26, 30, 31, 32], []]\n assert candidate(n = 10,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [1, 2, 1], [1, 4, 5], [1, 5, 6], [2, 3, 2], [2, 5, 3], [3, 6, 7], [3, 7, 8], [4, 5, 2], [4, 8, 9], [5, 6, 4], [5, 9, 10], [6, 7, 5], [7, 8, 6], [8, 9, 7]]) == [[3, 0, 6, 10, 7, 12, 14, 15, 16], []]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().findCriticalAndPseudoCriticalEdges", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findCriticalAndPseudoCriticalEdges(self, n: int, edges: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "findCriticalAndPseudoCriticalEdges", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1491, "task_id": "average-salary-excluding-the-minimum-and-maximum-salary", "difficulty": "Easy", "problem_description": "You are given an array of unique integers salary where salary[i] is the salary of the ith employee.\nReturn the average salary of employees excluding the minimum and maximum salary. Answers within 10-5 of the actual answer will be accepted.\n \nExample 1:\n\nInput: salary = [4000,3000,1000,2000]\nOutput: 2500.00000\nExplanation: Minimum salary and maximum salary are 1000 and 4000 respectively.\nAverage salary excluding minimum and maximum salary is (2000+3000) / 2 = 2500\n\nExample 2:\n\nInput: salary = [1000,2000,3000]\nOutput: 2000.00000\nExplanation: Minimum salary and maximum salary are 1000 and 3000 respectively.\nAverage salary excluding minimum and maximum salary is (2000) / 1 = 2000\n\n \nConstraints:\n\n3 <= salary.length <= 100\n1000 <= salary[i] <= 106\nAll the integers of salary are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(salary = [54000, 25000, 75000, 30000, 45000]) == 43000.0\n assert candidate(salary = [7500, 8500, 6500, 9500, 7000]) == 7666.666666666667\n assert candidate(salary = [5000, 6000, 7000, 8000, 9000, 10000]) == 7500.0\n assert candidate(salary = [12000, 11000, 13000, 9000, 10000, 14000]) == 11500.0\n assert candidate(salary = [4000, 3000, 1000, 2000]) == 2500.0\n assert candidate(salary = [8000, 9000, 2000, 3000, 6000, 10000, 5000]) == 6200.0\n assert candidate(salary = [1500, 2500, 3500, 4500, 5500]) == 3500.0\n assert candidate(salary = [5000, 10000, 15000, 20000, 25000]) == 15000.0\n assert candidate(salary = [15000, 25000, 35000, 45000, 55000]) == 35000.0\n assert candidate(salary = [100000, 120000, 110000]) == 110000.0\n assert candidate(salary = [1000, 2000, 3000]) == 2000.0\n assert candidate(salary = [7500, 8200, 9000, 12000, 6000]) == 8233.333333333334\n assert candidate(salary = [6000, 5000, 4000, 3000, 2000, 1000]) == 3500.0\n assert candidate(salary = [9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 5000.0\n assert candidate(salary = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990]) == 999994.5\n assert candidate(salary = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 550000.0\n assert candidate(salary = [1234, 2345, 3456, 4567, 5678, 6789, 7890, 8901, 9012, 1012]) == 5107.5\n assert candidate(salary = [9999, 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010]) == 10004.5\n assert candidate(salary = [45000, 55000, 65000, 35000, 25000, 75000, 85000, 95000, 105000, 115000, 125000, 135000]) == 80000.0\n assert candidate(salary = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000]) == 60000.0\n assert candidate(salary = [123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234, 12345, 54321]) == 460081.8888888889\n assert candidate(salary = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981]) == 999990.5\n assert candidate(salary = [111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999, 1111111, 2222222, 3333333, 4444444, 5555555, 6666666, 7777777, 8888888, 9999999, 10000000]) == 3228757.588235294\n assert candidate(salary = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009, 10010, 11011, 12012, 13013]) == 7007.0\n assert candidate(salary = [10000, 10100, 10200, 10300, 10400, 10500, 10600, 10700, 10800, 10900, 11000, 11100, 11200]) == 10600.0\n assert candidate(salary = [888888, 888889, 888890, 888891, 888892, 888893, 888894, 888895, 888896, 888897, 888898, 888899, 888900, 888901, 888902, 888903, 888904]) == 888896.0\n assert candidate(salary = [555555, 555556, 555557, 555558, 555559, 555560, 555561, 555562, 555563, 555564, 555565]) == 555560.0\n assert candidate(salary = [123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234, 101234, 212345, 321234, 432123, 543212, 654321, 765432]) == 501077.35714285716\n assert candidate(salary = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == 1005.5\n assert candidate(salary = [50000, 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 95000]) == 72500.0\n assert candidate(salary = [3500, 4500, 5500, 6500, 7500, 8500, 9500, 10500, 11500, 12500, 13500]) == 8500.0\n assert candidate(salary = [9999, 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007]) == 10003.0\n assert candidate(salary = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000]) == 7000.0\n assert candidate(salary = [15000, 14000, 13000, 12000, 11000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 8000.0\n assert candidate(salary = [10500, 20500, 30500, 40500, 50500, 60500, 70500, 80500, 90500, 100500]) == 55500.0\n assert candidate(salary = [555555, 444444, 333333, 222222, 111111, 999999, 888888, 777777, 666666, 123456, 789012, 345678, 901234, 567890, 234567, 890123, 456789, 678901, 101234, 987654]) == 554183.3333333334\n assert candidate(salary = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996, 6, 999995, 7, 999994, 8, 999993, 9, 999992, 10]) == 470589.29411764705\n assert candidate(salary = [500000, 490000, 480000, 470000, 460000, 450000, 440000, 430000, 420000, 410000, 400000]) == 450000.0\n assert candidate(salary = [5000, 3000, 4000, 6000, 7000, 8000, 9000, 10000, 11000]) == 7000.0\n assert candidate(salary = [8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 72000, 80000, 88000, 96000, 104000, 112000, 120000, 128000]) == 68000.0\n assert candidate(salary = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 5500000.0\n assert candidate(salary = [123456, 654321, 111111, 999999, 555555, 333333, 777777, 888888, 222222, 444444, 666666, 100000, 900000]) == 516161.1818181818\n assert candidate(salary = [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 95000, 100000]) == 52500.0\n assert candidate(salary = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 13000000, 14000000, 15000000]) == 8000000.0\n assert candidate(salary = [250000, 225000, 200000, 175000, 150000, 125000, 100000, 75000, 50000, 25000]) == 137500.0\n assert candidate(salary = [150000, 250000, 140000, 160000, 130000, 170000, 120000, 180000, 110000, 190000, 100000, 200000, 210000]) == 160000.0\n assert candidate(salary = [150000, 150001, 150002, 150003, 150004, 150005, 150006, 150007, 150008, 150009, 150010, 150011, 150012]) == 150006.0\n assert candidate(salary = [123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234, 101234]) == 510802.0\n assert candidate(salary = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013]) == 1007.0\n assert candidate(salary = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == 999995.5\n assert candidate(salary = [999999, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100001, 100000]) == 450000.125\n assert candidate(salary = [100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009, 100010]) == 100005.5\n assert candidate(salary = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 100000000, 99999999, 88888888, 77777777, 66666666, 55555555, 44444444, 33333333, 22222222, 11111111]) == 269934640.0\n assert candidate(salary = [1000, 1200, 1400, 1600, 1800, 2000, 2200, 2400, 2600, 2800, 3000, 3200, 3400, 3600, 3800, 4000]) == 2500.0\n assert candidate(salary = [30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000]) == 90000.0\n assert candidate(salary = [50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000, 180000, 190000]) == 120000.0\n assert candidate(salary = [1234, 2345, 3456, 4567, 5678, 6789, 7890, 8901, 9012, 1012, 2123, 3234, 4345, 5456, 6567, 7678, 8789, 9890, 8989, 7989]) == 5835.666666666667\n assert candidate(salary = [500001, 500002, 500003, 500004, 500005, 500006, 500007, 500008, 500009, 500010, 500011, 500012, 500013, 500014, 500015, 500016, 500017, 500018, 500019, 500020, 500021, 500022, 500023, 500024, 500025]) == 500013.0\n assert candidate(salary = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000, 1100000]) == 600000.0\n assert candidate(salary = [250000, 260000, 270000, 280000, 290000, 300000, 310000, 320000, 330000, 340000, 350000, 360000, 370000, 380000, 390000]) == 320000.0\n assert candidate(salary = [100000, 100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009, 100010]) == 100005.0\n assert candidate(salary = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000]) == 500000.0\n assert candidate(salary = [100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009, 100010, 100011, 100012, 100013, 100014, 100015]) == 100008.0\n assert candidate(salary = [500000, 400000, 300000, 200000, 100000, 150000, 250000, 350000, 450000, 550000]) == 325000.0\n assert candidate(salary = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 13.0\n assert candidate(salary = [123456, 789012, 345678, 901234, 567890, 234567, 890123]) == 565454.0\n assert candidate(salary = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 13000000, 14000000, 15000000, 16000000, 17000000, 18000000, 19000000, 20000000]) == 10500000.0\n assert candidate(salary = [999999, 1000000, 1000001, 1000002, 1000003, 1000004, 1000005]) == 1000002.0\n assert candidate(salary = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011]) == 5005.5\n assert candidate(salary = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015]) == 1008.0\n assert candidate(salary = [500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000]) == 1250000.0\n assert candidate(salary = [1000, 999999, 500000, 250000, 750000, 375000, 625000]) == 500000.0\n assert candidate(salary = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011]) == 1006.0\n assert candidate(salary = [100000, 200000, 150000, 180000, 170000, 160000, 130000, 120000, 110000]) == 145714.2857142857\n assert candidate(salary = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876, 98765, 87654, 76543, 65432, 54321, 43210, 32109, 21098, 10987, 9876, 8765]) == 245198.38888888888\n assert candidate(salary = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == 999995.0\n assert candidate(salary = [999999, 1000000, 1000001, 1000002, 1000003, 1000004, 1000005, 1000006]) == 1000002.5\n assert candidate(salary = [500000, 500001, 500002, 500003, 500004, 500005, 500006, 500007, 500008, 500009, 500010, 500011, 500012, 500013, 500014, 500015]) == 500007.5\n assert candidate(salary = [1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 1000000000001, 1000000000002]) == 211111111000.1\n assert candidate(salary = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 13000000]) == 7000000.0\n assert candidate(salary = [999999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 8.5\n assert candidate(salary = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876, 98765, 87654, 76543, 65432, 54321, 43210, 32109]) == 309964.35714285716\n assert candidate(salary = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876, 98765, 87654, 76543, 65432]) == 379685.2727272727\n assert candidate(salary = [999999, 1000000, 1000001, 1000002, 1000003, 1000004, 1000005, 1000006, 1000007, 1000008, 1000009, 1000010]) == 1000004.5\n assert candidate(salary = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 5500.0\n assert candidate(salary = [200000, 150000, 180000, 170000, 190000, 160000, 210000, 220000, 230000, 240000]) == 195000.0\n assert candidate(salary = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, 1300000, 1400000, 1500000]) == 800000.0\n assert candidate(salary = [23456, 34567, 45678, 56789, 67890, 78901, 89012, 90123, 101234, 111234, 121234, 131234, 141234, 151234]) == 89094.16666666667\n assert candidate(salary = [500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, 1300000, 1400000]) == 950000.0\n assert candidate(salary = [150000, 250000, 350000, 450000, 550000, 650000, 750000, 850000, 950000, 1050000, 1150000, 1250000, 1350000, 1450000, 1550000, 1650000, 1750000, 1850000, 1950000, 2050000]) == 1100000.0\n assert candidate(salary = [3456, 6543, 1234, 4321, 9876, 6789, 2345, 5432, 8765, 7654, 1111, 2222, 3333]) == 4735.818181818182\n assert candidate(salary = [999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984]) == 999991.0\n assert candidate(salary = [123456, 789012, 345678, 901234, 567890, 1234567, 2345678, 3456789, 4567890, 5678901, 6789012, 7890123, 8901234, 9012345, 10123456]) == 4036950.230769231\n assert candidate(salary = [1000, 2500, 5000, 7500, 10000, 12500, 15000]) == 7500.0\n assert candidate(salary = [120000, 95000, 110000, 90000, 105000, 85000, 100000, 80000, 115000]) == 100000.0\n assert candidate(salary = [123456789, 987654321, 111222333, 444555666, 777888999, 222333444, 555666777, 888999000, 333444555, 666777888, 999000111]) == 555641937.6666666\n assert candidate(salary = [95000, 96000, 97000, 98000, 99000, 100000, 101000, 102000, 103000, 104000, 105000, 106000, 107000, 108000, 109000]) == 102000.0\n assert candidate(salary = [12000, 15000, 13000, 10000, 9000, 11000, 14000]) == 12000.0\n assert candidate(salary = [80000, 75000, 100000, 65000, 90000, 55000, 60000, 70000]) == 73333.33333333333\n"}, "metadata": {"canonical_parameter_names": ["salary"], "leetcode_dataset_entry_point": "Solution().average", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def average(self, salary: list[int]) -> float:", "container": "Solution", "callable": "average", "parameters": [{"name": "salary", "type": "list[int]"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1492, "task_id": "the-kth-factor-of-n", "difficulty": "Medium", "problem_description": "You are given two positive integers n and k. A factor of an integer n is defined as an integer i where n % i == 0.\nConsider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if n has less than k factors.\n \nExample 1:\n\nInput: n = 12, k = 3\nOutput: 3\nExplanation: Factors list is [1, 2, 3, 4, 6, 12], the 3rd factor is 3.\n\nExample 2:\n\nInput: n = 7, k = 2\nOutput: 7\nExplanation: Factors list is [1, 7], the 2nd factor is 7.\n\nExample 3:\n\nInput: n = 4, k = 4\nOutput: -1\nExplanation: Factors list is [1, 2, 4], there is only 3 factors. We should return -1.\n\n \nConstraints:\n\n1 <= k <= n <= 1000\n\n \nFollow up:\nCould you solve this problem in less than O(n) complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,k = 1) == 1\n assert candidate(n = 49,k = 3) == 49\n assert candidate(n = 100,k = 5) == 10\n assert candidate(n = 7,k = 2) == 7\n assert candidate(n = 17,k = 2) == 17\n assert candidate(n = 1000,k = 15) == 500\n assert candidate(n = 30,k = 5) == 6\n assert candidate(n = 12,k = 3) == 3\n assert candidate(n = 30,k = 1) == 1\n assert candidate(n = 100,k = 10) == -1\n assert candidate(n = 36,k = 6) == 9\n assert candidate(n = 1000,k = 10) == 50\n assert candidate(n = 84,k = 5) == 6\n assert candidate(n = 500,k = 7) == 25\n assert candidate(n = 999,k = 9) == -1\n assert candidate(n = 97,k = 2) == 97\n assert candidate(n = 17,k = 1) == 1\n assert candidate(n = 4,k = 4) == -1\n assert candidate(n = 50,k = 5) == 25\n assert candidate(n = 37,k = 1) == 1\n assert candidate(n = 60,k = 8) == 12\n assert candidate(n = 81,k = 4) == 27\n assert candidate(n = 60,k = 6) == 6\n assert candidate(n = 100,k = 11) == -1\n assert candidate(n = 120,k = 12) == 24\n assert candidate(n = 144,k = 9) == 16\n assert candidate(n = 841,k = 3) == 841\n assert candidate(n = 49,k = 2) == 7\n assert candidate(n = 36,k = 8) == 18\n assert candidate(n = 121,k = 3) == 121\n assert candidate(n = 100,k = 7) == 25\n assert candidate(n = 256,k = 7) == 64\n assert candidate(n = 360,k = 15) == 30\n assert candidate(n = 999,k = 20) == -1\n assert candidate(n = 64,k = 7) == 64\n assert candidate(n = 504,k = 8) == 9\n assert candidate(n = 625,k = 5) == 625\n assert candidate(n = 15,k = 3) == 5\n assert candidate(n = 120,k = 7) == 8\n assert candidate(n = 997,k = 2) == 997\n assert candidate(n = 256,k = 8) == 128\n assert candidate(n = 999,k = 15) == -1\n assert candidate(n = 500,k = 15) == -1\n assert candidate(n = 810,k = 16) == 135\n assert candidate(n = 841,k = 7) == -1\n assert candidate(n = 45,k = 5) == 15\n assert candidate(n = 441,k = 4) == 9\n assert candidate(n = 1024,k = 9) == 256\n assert candidate(n = 200,k = 1) == 1\n assert candidate(n = 999,k = 3) == 9\n assert candidate(n = 25,k = 3) == 25\n assert candidate(n = 1000,k = 18) == -1\n assert candidate(n = 1000,k = 16) == 1000\n assert candidate(n = 450,k = 15) == 90\n assert candidate(n = 600,k = 15) == 40\n assert candidate(n = 6,k = 4) == 6\n assert candidate(n = 225,k = 8) == 75\n assert candidate(n = 500,k = 8) == 50\n assert candidate(n = 9,k = 3) == 9\n assert candidate(n = 729,k = 6) == 243\n assert candidate(n = 504,k = 10) == 14\n assert candidate(n = 500,k = 12) == 500\n assert candidate(n = 96,k = 10) == 32\n assert candidate(n = 999,k = 5) == 37\n assert candidate(n = 343,k = 3) == 49\n assert candidate(n = 72,k = 9) == 18\n assert candidate(n = 450,k = 20) == -1\n assert candidate(n = 1000,k = 1) == 1\n assert candidate(n = 1024,k = 10) == 512\n assert candidate(n = 36,k = 11) == -1\n assert candidate(n = 441,k = 5) == 21\n assert candidate(n = 729,k = 12) == -1\n assert candidate(n = 999,k = 10) == -1\n assert candidate(n = 36,k = 7) == 12\n assert candidate(n = 50,k = 3) == 5\n assert candidate(n = 225,k = 5) == 15\n assert candidate(n = 200,k = 20) == -1\n assert candidate(n = 100,k = 9) == 100\n assert candidate(n = 16,k = 5) == 16\n assert candidate(n = 625,k = 6) == -1\n assert candidate(n = 840,k = 10) == 12\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().kthFactor", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def kthFactor(self, n: int, k: int) -> int:", "container": "Solution", "callable": "kthFactor", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1493, "task_id": "longest-subarray-of-1s-after-deleting-one-element", "difficulty": "Medium", "problem_description": "Given a binary array nums, you should delete one element from it.\nReturn the size of the longest non-empty subarray containing only 1's in the resulting array. Return 0 if there is no such subarray.\n \nExample 1:\n\nInput: nums = [1,1,0,1]\nOutput: 3\nExplanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's.\n\nExample 2:\n\nInput: nums = [0,1,1,1,0,1,1,0,1]\nOutput: 5\nExplanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1].\n\nExample 3:\n\nInput: nums = [1,1,1]\nOutput: 2\nExplanation: You must delete one element.\n\n \nConstraints:\n\n1 <= nums.length <= 105\nnums[i] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1]) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 1, 1, 1, 0]) == 5\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0]) == 6\n assert candidate(nums = [1, 1, 1]) == 2\n assert candidate(nums = [1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0]) == 6\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 1, 1, 0, 1]) == 4\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1]) == 6\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0]) == 7\n assert candidate(nums = [1, 1, 0, 1]) == 3\n assert candidate(nums = [0, 1, 1, 1, 0, 1, 1, 0, 1]) == 5\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == 4\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 24\n assert candidate(nums = [0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1]) == 9\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 38\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 24\n assert candidate(nums = [1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 25\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1]) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1]) == 23\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 29\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0]) == 10\n assert candidate(nums = [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0]) == 6\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 33\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 29\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]) == 14\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 3\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]) == 20\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 22\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(nums = [1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0]) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 3\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1]) == 6\n assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 24\n assert candidate(nums = [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1]) == 6\n assert candidate(nums = [1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1]) == 22\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1]) == 9\n assert candidate(nums = [1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 19\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 32\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 28\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 31\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1]) == 8\n assert candidate(nums = [1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0]) == 6\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1]) == 30\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1]) == 9\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]) == 16\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums = [1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]) == 8\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]) == 10\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == 1\n assert candidate(nums = [1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1]) == 3\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 43\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().longestSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def longestSubarray(self, nums: list[int]) -> int:", "container": "Solution", "callable": "longestSubarray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1494, "task_id": "parallel-courses-ii", "difficulty": "Hard", "problem_description": "You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given an array relations where relations[i] = [prevCoursei, nextCoursei], representing a prerequisite relationship between course prevCoursei and course nextCoursei: course prevCoursei has to be taken before course nextCoursei. Also, you are given the integer k.\nIn one semester, you can take at most k courses as long as you have taken all the prerequisites in the previous semesters for the courses you are taking.\nReturn the minimum number of semesters needed to take all courses. The testcases will be generated such that it is possible to take every course.\n \nExample 1:\n\n\nInput: n = 4, relations = [[2,1],[3,1],[1,4]], k = 2\nOutput: 3\nExplanation: The figure above represents the given graph.\nIn the first semester, you can take courses 2 and 3.\nIn the second semester, you can take course 1.\nIn the third semester, you can take course 4.\n\nExample 2:\n\n\nInput: n = 5, relations = [[2,1],[3,1],[4,1],[1,5]], k = 2\nOutput: 4\nExplanation: The figure above represents the given graph.\nIn the first semester, you can only take courses 2 and 3 since you cannot take more than two per semester.\nIn the second semester, you can take course 4.\nIn the third semester, you can take course 1.\nIn the fourth semester, you can take course 5.\n\n \nConstraints:\n\n1 <= n <= 15\n1 <= k <= n\n0 <= relations.length <= n * (n-1) / 2\nrelations[i].length == 2\n1 <= prevCoursei, nextCoursei <= n\nprevCoursei != nextCoursei\nAll the pairs [prevCoursei, nextCoursei] are unique.\nThe given graph is a directed acyclic graph.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,relations = [[2, 1], [3, 1], [1, 4]],k = 2) == 3\n assert candidate(n = 5,relations = [],k = 3) == 2\n assert candidate(n = 5,relations = [[2, 1], [3, 1], [4, 1], [1, 5]],k = 2) == 4\n assert candidate(n = 3,relations = [[1, 3], [2, 3]],k = 2) == 2\n assert candidate(n = 3,relations = [],k = 3) == 1\n assert candidate(n = 4,relations = [[2, 1], [3, 1]],k = 1) == 4\n assert candidate(n = 6,relations = [[1, 2], [2, 3], [4, 5], [5, 6]],k = 2) == 3\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [7, 15]],k = 4) == 5\n assert candidate(n = 15,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],k = 3) == 15\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [3, 6], [4, 6], [5, 6], [6, 7], [6, 8], [7, 9], [8, 9], [9, 10], [9, 11], [10, 12], [11, 12], [12, 13], [12, 14], [13, 15], [14, 15]],k = 3) == 10\n assert candidate(n = 3,relations = [],k = 2) == 2\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]],k = 4) == 5\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 3], [1, 5], [1, 7], [1, 9]],k = 4) == 10\n assert candidate(n = 7,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [1, 4], [2, 5], [3, 6]],k = 2) == 7\n assert candidate(n = 14,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],k = 2) == 14\n assert candidate(n = 15,relations = [[1, 5], [2, 5], [3, 5], [4, 5], [1, 6], [2, 6], [3, 6], [4, 6], [1, 7], [2, 7], [3, 7], [4, 7]],k = 3) == 5\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8]],k = 2) == 5\n assert candidate(n = 8,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],k = 3) == 8\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15]],k = 5) == 5\n assert candidate(n = 7,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],k = 2) == 7\n assert candidate(n = 10,relations = [[1, 5], [1, 6], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10]],k = 3) == 4\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12]],k = 2) == 7\n assert candidate(n = 12,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],k = 4) == 12\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 12], [8, 12], [9, 12], [10, 12]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 10]],k = 4) == 4\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 8], [7, 8]],k = 2) == 5\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 12], [11, 12]],k = 4) == 5\n assert candidate(n = 13,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 12], [8, 12], [9, 13], [10, 13]],k = 5) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 10]],k = 2) == 6\n assert candidate(n = 14,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 14], [12, 14], [13, 14]],k = 5) == 6\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 4], [3, 6], [4, 7], [5, 7], [6, 7], [7, 8], [7, 9]],k = 2) == 6\n assert candidate(n = 10,relations = [[1, 5], [1, 6], [2, 6], [2, 7], [3, 7], [3, 8], [4, 8], [4, 9], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10]],k = 3) == 4\n assert candidate(n = 14,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [5, 8], [6, 9], [6, 10], [7, 11], [7, 12], [8, 13], [8, 14], [9, 13], [10, 14]],k = 4) == 6\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15]],k = 2) == 9\n assert candidate(n = 13,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 8], [5, 9], [6, 10], [6, 11], [7, 10], [7, 11], [8, 12], [8, 13], [9, 12], [9, 13], [10, 13], [11, 13]],k = 4) == 5\n assert candidate(n = 9,relations = [[1, 3], [1, 4], [1, 5], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8], [5, 7], [5, 8], [6, 9], [7, 9], [8, 9]],k = 3) == 4\n assert candidate(n = 11,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 11]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10]],k = 4) == 4\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 12], [8, 12], [9, 12], [10, 12]],k = 4) == 5\n assert candidate(n = 14,relations = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 10], [7, 10], [8, 10], [9, 10], [10, 11], [11, 12], [11, 13], [11, 14]],k = 4) == 6\n assert candidate(n = 13,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 13], [11, 13]],k = 4) == 5\n assert candidate(n = 14,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 14]],k = 3) == 6\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 12]],k = 2) == 7\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],k = 2) == 14\n assert candidate(n = 10,relations = [[1, 5], [2, 5], [3, 5], [4, 5], [6, 7], [7, 8], [8, 9], [9, 10]],k = 2) == 5\n assert candidate(n = 14,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14]],k = 3) == 6\n assert candidate(n = 15,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],k = 5) == 15\n assert candidate(n = 12,relations = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 12], [11, 12]],k = 3) == 5\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],k = 2) == 5\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 8], [5, 9], [6, 10], [6, 11], [7, 10], [7, 11], [8, 12], [9, 12], [10, 12], [11, 12]],k = 4) == 5\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 6], [4, 6], [4, 7], [5, 8], [6, 8], [7, 8]],k = 2) == 5\n assert candidate(n = 13,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]],k = 4) == 13\n assert candidate(n = 12,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],k = 3) == 12\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 2) == 8\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],k = 1) == 10\n assert candidate(n = 7,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]],k = 2) == 5\n assert candidate(n = 15,relations = [[1, 6], [1, 7], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 14], [7, 15], [8, 14], [8, 15], [9, 14], [9, 15], [10, 14], [10, 15], [11, 14], [11, 15], [12, 14], [12, 15], [13, 14], [13, 15]],k = 5) == 4\n assert candidate(n = 11,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 8], [5, 9], [6, 10], [7, 10], [8, 11], [9, 11]],k = 3) == 5\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9]],k = 2) == 5\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15]],k = 4) == 6\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],k = 3) == 11\n assert candidate(n = 11,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11]],k = 3) == 5\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]],k = 3) == 6\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8]],k = 2) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],k = 3) == 6\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],k = 3) == 10\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [7, 10], [8, 10], [9, 10]],k = 3) == 6\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12]],k = 2) == 7\n assert candidate(n = 9,relations = [[1, 2], [2, 3], [1, 3], [4, 5], [5, 6], [4, 6], [7, 8], [8, 9], [7, 9], [2, 4], [3, 5]],k = 3) == 5\n assert candidate(n = 15,relations = [[1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],k = 5) == 14\n assert candidate(n = 14,relations = [[1, 4], [2, 4], [3, 4], [4, 5], [5, 6], [5, 7], [6, 8], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],k = 3) == 11\n assert candidate(n = 10,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [6, 8], [7, 9], [8, 9], [9, 10]],k = 3) == 7\n assert candidate(n = 12,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [6, 11], [7, 12], [8, 10], [9, 11]],k = 3) == 6\n assert candidate(n = 7,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7]],k = 2) == 5\n assert candidate(n = 12,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [6, 8], [7, 9], [8, 9], [9, 10], [9, 11], [10, 12], [11, 12]],k = 3) == 8\n assert candidate(n = 14,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14]],k = 3) == 6\n assert candidate(n = 7,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],k = 1) == 7\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 5], [4, 6], [5, 7], [5, 8], [6, 9], [6, 10], [7, 10], [8, 10]],k = 2) == 6\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [5, 7], [6, 8], [7, 8], [8, 9], [8, 10]],k = 3) == 7\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 14], [7, 15], [8, 14], [8, 15], [9, 14], [9, 15], [10, 14], [10, 15], [11, 14], [11, 15], [12, 14], [12, 15], [13, 14], [13, 15]],k = 5) == 5\n assert candidate(n = 15,relations = [[1, 4], [1, 5], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10], [10, 11], [10, 12], [11, 13], [12, 13], [13, 14], [13, 15], [14, 15]],k = 4) == 8\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],k = 2) == 5\n assert candidate(n = 11,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 8], [5, 9], [6, 10], [6, 11], [7, 10], [7, 11], [8, 11], [9, 10]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 10], [7, 10]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 6], [2, 7], [3, 8], [4, 9]],k = 4) == 10\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]],k = 3) == 6\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],k = 2) == 6\n assert candidate(n = 11,relations = [[1, 3], [1, 4], [2, 4], [2, 5], [3, 6], [4, 7], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [2, 6], [3, 7]],k = 2) == 6\n assert candidate(n = 13,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13]],k = 2) == 7\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],k = 1) == 10\n assert candidate(n = 15,relations = [[1, 15], [2, 15], [3, 15], [4, 15], [5, 15], [6, 15], [7, 15], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15]],k = 5) == 4\n"}, "metadata": {"canonical_parameter_names": ["n", "relations", "k"], "leetcode_dataset_entry_point": "Solution().minNumberOfSemesters", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minNumberOfSemesters(self, n: int, relations: list[list[int]], k: int) -> int:", "container": "Solution", "callable": "minNumberOfSemesters", "parameters": [{"name": "n", "type": "int"}, {"name": "relations", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1496, "task_id": "path-crossing", "difficulty": "Easy", "problem_description": "Given a string path, where path[i] = 'N', 'S', 'E' or 'W', each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0) on a 2D plane and walk on the path specified by path.\nReturn true if the path crosses itself at any point, that is, if at any time you are on a location you have previously visited. Return false otherwise.\n \nExample 1:\n\n\nInput: path = \"NES\"\nOutput: false \nExplanation: Notice that the path doesn't cross any point more than once.\n\nExample 2:\n\n\nInput: path = \"NESWW\"\nOutput: true\nExplanation: Notice that the path visits the origin twice.\n \nConstraints:\n\n1 <= path.length <= 104\npath[i] is either 'N', 'S', 'E', or 'W'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(path = \"NEESWNWWSNNWNSSSWEWEWEWE\") == True\n assert candidate(path = \"NNNSSSSSSEEEEEEEWWWWWWWWW\") == True\n assert candidate(path = \"NEWSNEWS\") == True\n assert candidate(path = \"EWEWEWEW\") == True\n assert candidate(path = \"NESWW\") == True\n assert candidate(path = \"NSSS\") == True\n assert candidate(path = \"N\") == False\n assert candidate(path = \"NNSSEEEWWS\") == True\n assert candidate(path = \"NSSSWEWNNEE\") == True\n assert candidate(path = \"\") == False\n assert candidate(path = \"NSNSNSNS\") == True\n assert candidate(path = \"NNNSSSSS\") == True\n assert candidate(path = \"NESWNE\") == True\n assert candidate(path = \"NNESSEWSWNWNWSSSNW\") == True\n assert candidate(path = \"NS\") == True\n assert candidate(path = \"NNESSWW\") == True\n assert candidate(path = \"NENESSWW\") == True\n assert candidate(path = \"EWE\") == True\n assert candidate(path = \"NES\") == False\n assert candidate(path = \"NEWS\") == True\n assert candidate(path = \"NNNNSSSSWWWWEEEE\") == True\n assert candidate(path = \"WEWEWEWE\") == True\n assert candidate(path = \"NWSWEWNWNW\") == True\n assert candidate(path = \"NNEESSWW\") == True\n assert candidate(path = \"NNEEESSWWNNNEEESSWWNNNESSWWN\") == True\n assert candidate(path = \"EEEE\") == False\n assert candidate(path = \"EESSEENN\") == False\n assert candidate(path = \"WEWN\") == True\n assert candidate(path = \"EENW\") == False\n assert candidate(path = \"NEEEEWWWWSSSSNNN\") == True\n assert candidate(path = \"ENWSWNESWSWNESWS\") == True\n assert candidate(path = \"NENWSEWSWESWESWESW\") == True\n assert candidate(path = \"NNEWSSEESSEENNNWNNNW\") == True\n assert candidate(path = \"NNNSSSWEWEWESWNWNWNWWSWSWENENE\") == True\n assert candidate(path = \"ENWNENWENW\") == True\n assert candidate(path = \"NWSNWSNWSNWSNWS\") == True\n assert candidate(path = \"EEEEEWWWWWSSSSSNNNNN\") == True\n assert candidate(path = \"NWNWNWNWNWSWSWSWSW\") == False\n assert candidate(path = \"NESWWNESWWNESWW\") == True\n assert candidate(path = \"EESWWNNESWNESESW\") == True\n assert candidate(path = \"WENWENWENW\") == True\n assert candidate(path = \"NSEENWNNWSSSWEE\") == True\n assert candidate(path = \"NNSSEEEWWW\") == True\n assert candidate(path = \"NEWSNEWSNEWSNEWSNEWS\") == True\n assert candidate(path = \"SSNNEEWW\") == True\n assert candidate(path = \"NNWNWSSSWNEEEEEN\") == True\n assert candidate(path = \"NNESWSWNWNWS\") == True\n assert candidate(path = \"NNNNSSSSWWWW\") == True\n assert candidate(path = \"EENWNWSS\") == True\n assert candidate(path = \"NNNNEEESSEWWNNNNEE\") == True\n assert candidate(path = \"NESEWNESEWNESEW\") == True\n assert candidate(path = \"EENNWWSSNNSSEE\") == True\n assert candidate(path = \"SSSSNNNNEEEEWWWW\") == True\n assert candidate(path = \"EEEEEEEEEEEEEEEWWWWWWWWWWWWWWWSSSSSSSSSSSSSSSNNNNNNNNNNNNNNN\") == True\n assert candidate(path = \"NNNSSSNNNSSS\") == True\n assert candidate(path = \"NEWSNEWSNEWS\") == True\n assert candidate(path = \"ENSNWNWNWN\") == True\n assert candidate(path = \"ESSNNWWSSEN\") == True\n assert candidate(path = \"SWENSWENSWENSWEN\") == True\n assert candidate(path = \"WESSNNESWWSE\") == True\n assert candidate(path = \"NENWSWSENENW\") == True\n assert candidate(path = \"WSEWSEWSEWSEW\") == True\n assert candidate(path = \"NNNSSSSSSEEWWWW\") == True\n assert candidate(path = \"WENSNWSWES\") == True\n assert candidate(path = \"NWWWSSENNE\") == True\n assert candidate(path = \"NEESWNESWSWN\") == True\n assert candidate(path = \"WEWNSWESWESWESW\") == True\n assert candidate(path = \"NNWESWSWSEENW\") == True\n assert candidate(path = \"WNWSSNSSWEEENEEN\") == True\n assert candidate(path = \"EWEWEWEWEEWWEWEEWWSWWSW\") == True\n assert candidate(path = \"NSSSSEEEEWWWNNSNWEEE\") == True\n assert candidate(path = \"SSENNWESSW\") == True\n assert candidate(path = \"NEEEEESWWWWNSSSSS\") == True\n assert candidate(path = \"NNNNNSSSSSAAAABBBB\") == True\n assert candidate(path = \"NESWNEESWW\") == True\n assert candidate(path = \"NENWSEWSWENWSEWSW\") == True\n assert candidate(path = \"NNNNNNNNSSSSSSSSWWWWWWWWEEEEEEEE\") == True\n assert candidate(path = \"ENENEWNWNWSWSW\") == True\n assert candidate(path = \"NENENENENESESESESESWSWSWSWSW\") == False\n assert candidate(path = \"ENEWWNNEWSWE\") == True\n assert candidate(path = \"NNNNNNNNNN\") == False\n assert candidate(path = \"ENWESWNESEENWSWEN\") == True\n assert candidate(path = \"NESESWWSSWNE\") == True\n assert candidate(path = \"NENENENENEWWWWWW\") == True\n assert candidate(path = \"NNNEEEESSSNNNWWSW\") == True\n assert candidate(path = \"NENENENENNENESESWSWWSW\") == True\n assert candidate(path = \"ENSWNESWNESEWS\") == True\n assert candidate(path = \"ENWSESWNESWENSWE\") == True\n assert candidate(path = \"ENEENWNNWSSSSNE\") == True\n assert candidate(path = \"EEESSSNNNW\") == True\n assert candidate(path = \"NNNSSSSSSEEEWWWW\") == True\n assert candidate(path = \"EESNNWWSSEEN\") == True\n assert candidate(path = \"NNNEEESSEESWWNN\") == True\n assert candidate(path = \"EENWNNWSSNNWEE\") == True\n assert candidate(path = \"NEWWNWSSWSEWSSN\") == True\n assert candidate(path = \"NESESWNESESWNESESW\") == True\n assert candidate(path = \"NENWSWNWNWSWNWNW\") == True\n assert candidate(path = \"NENWSESWNESWNES\") == True\n assert candidate(path = \"NENENNENNE\") == False\n assert candidate(path = \"NEWSNEWSNEWSNEWS\") == True\n assert candidate(path = \"NSEWSSEEEWWWNNEENW\") == True\n assert candidate(path = \"NNWESSSWNE\") == True\n assert candidate(path = \"ESSSWWNNEEEWWNNSSEEE\") == True\n assert candidate(path = \"NESWNESWNESW\") == True\n assert candidate(path = \"NESESWWSWN\") == False\n assert candidate(path = \"NESWNESESWNESESW\") == True\n assert candidate(path = \"NENWSEWSWNNWSEWSW\") == True\n assert candidate(path = \"ENWNNWSSNWNWEE\") == True\n assert candidate(path = \"NNWSENNWWSSSEEE\") == True\n assert candidate(path = \"WNWSSNSSWEEENEENE\") == True\n assert candidate(path = \"NSEWNSSEWW\") == True\n assert candidate(path = \"ENWSENWSENWSENWS\") == True\n assert candidate(path = \"SSSSWWWWNNEE\") == False\n assert candidate(path = \"NSSSWWNEEENNEESSE\") == True\n assert candidate(path = \"ENWSWWSESNWEN\") == True\n assert candidate(path = \"NSSSNWWNEEEE\") == True\n assert candidate(path = \"NNSESSWWNE\") == True\n assert candidate(path = \"NESWENSWEWNENSWSEWNESW\") == True\n assert candidate(path = \"WESSNNWESSNNWESSNN\") == True\n assert candidate(path = \"SSWWSSENNE\") == True\n assert candidate(path = \"ESWENSWENSWENSWENSWEN\") == True\n assert candidate(path = \"NESWNSWENSWE\") == True\n assert candidate(path = \"NESWWSEN\") == True\n assert candidate(path = \"EWEWNEWEWN\") == True\n assert candidate(path = \"EENNWWNSSSNEEE\") == True\n assert candidate(path = \"EESWWNNEWSNEWSNEWS\") == True\n assert candidate(path = \"WEWNENEWNWNWSWSNEN\") == True\n assert candidate(path = \"NESWNSWENWEWSWEWNSWEWENWSWEN\") == True\n assert candidate(path = \"NENWSEWNENWSEWNENWSEW\") == True\n assert candidate(path = \"WNESSWNESSWNE\") == True\n assert candidate(path = \"WENWNNWENWSE\") == True\n assert candidate(path = \"NSEWNNNSSSWEWEWEWWE\") == True\n assert candidate(path = \"NENWNWNWSENW\") == True\n assert candidate(path = \"WNEEESSNWWWEN\") == True\n assert candidate(path = \"EEENNWWWWNEESSS\") == True\n assert candidate(path = \"SSSSNNNNWWEEEE\") == True\n assert candidate(path = \"EEENNNEEWWSSSWWN\") == True\n assert candidate(path = \"EEEEEEEWWWWWWSSSSSSNNNNNN\") == True\n assert candidate(path = \"EEEEEENNNNNNSSSSSWEWE\") == True\n assert candidate(path = \"NSSSSWWWWEEEEEENNN\") == True\n assert candidate(path = \"SSSSEEEEWWWWNNNN\") == True\n assert candidate(path = \"SSSSSSSSSS\") == False\n assert candidate(path = \"NSSSWWEENNSSSWWEEN\") == True\n assert candidate(path = \"EENNWWSSNWNWEEWN\") == True\n assert candidate(path = \"NENENENE\") == False\n assert candidate(path = \"NENESWNESE\") == True\n assert candidate(path = \"ENWSWEWNWSWEWNWS\") == True\n assert candidate(path = \"NENWSEWSWNESWESW\") == True\n assert candidate(path = \"WWEENNWEES\") == True\n assert candidate(path = \"EWEWNEWNWSWE\") == True\n assert candidate(path = \"NNNSSSSSSSWWWWWWWWWEEEEE\") == True\n assert candidate(path = \"NWSWNWSWNW\") == False\n assert candidate(path = \"NNSSWWEENN\") == True\n assert candidate(path = \"NSEENWNNWSSSWEEE\") == True\n assert candidate(path = \"NENWSNWSNESW\") == True\n assert candidate(path = \"NNSWESWESWESWESW\") == True\n assert candidate(path = \"NESNESNESNESNES\") == True\n assert candidate(path = \"NESWNNNWWWEES\") == True\n assert candidate(path = \"SSNNSSNNSS\") == True\n assert candidate(path = \"NEWSWNNWSSNWNWEE\") == True\n assert candidate(path = \"NNWNWSSSWNEEE\") == True\n assert candidate(path = \"NENWNSNS\") == True\n assert candidate(path = \"EWSWNWESWE\") == True\n assert candidate(path = \"NNEEWWSS\") == True\n assert candidate(path = \"SEENENENEWSWSWNENE\") == True\n assert candidate(path = \"WNWSSNSSSENEEN\") == True\n assert candidate(path = \"NESESWSEWN\") == True\n assert candidate(path = \"NNEWSWSEWSSNENW\") == True\n assert candidate(path = \"EWEWEWEWEW\") == True\n assert candidate(path = \"SSEWEEWEEE\") == True\n assert candidate(path = \"NSSSSEEEEEWWWWNNNN\") == True\n assert candidate(path = \"NNNWWWSSSE\") == False\n assert candidate(path = \"NSSSNEEEWNWSS\") == True\n assert candidate(path = \"NESWNESW\") == True\n assert candidate(path = \"ESESWNEWSWSWNENESE\") == True\n assert candidate(path = \"NNNWWSSSNE\") == True\n assert candidate(path = \"NEWSWNESWESWNES\") == True\n assert candidate(path = \"NNESSEWW\") == True\n assert candidate(path = \"WEEWEEWEEE\") == True\n assert candidate(path = \"NENENWENWENWENWENW\") == True\n assert candidate(path = \"NNSSEEEWWWS\") == True\n assert candidate(path = \"SWSWSWSWNENENENENE\") == True\n assert candidate(path = \"SSSEEESSSWWNNN\") == True\n assert candidate(path = \"NNSSNNSS\") == True\n assert candidate(path = \"NNSEESSWNW\") == True\n assert candidate(path = \"NNNSSSWEWEWESWNWNWNWWSWSWENENESESESESNESWENSWEWNENSWSEWNESW\") == True\n"}, "metadata": {"canonical_parameter_names": ["path"], "leetcode_dataset_entry_point": "Solution().isPathCrossing", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def isPathCrossing(self, path: str) -> bool:", "container": "Solution", "callable": "isPathCrossing", "parameters": [{"name": "path", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1497, "task_id": "check-if-array-pairs-are-divisible-by-k", "difficulty": "Medium", "problem_description": "Given an array of integers arr of even length n and an integer k.\nWe want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k.\nReturn true If you can find a way to do that or false otherwise.\n \nExample 1:\n\nInput: arr = [1,2,3,4,5,10,6,7,8,9], k = 5\nOutput: true\nExplanation: Pairs are (1,9),(2,8),(3,7),(4,6) and (5,10).\n\nExample 2:\n\nInput: arr = [1,2,3,4,5,6], k = 7\nOutput: true\nExplanation: Pairs are (1,6),(2,5) and(3,4).\n\nExample 3:\n\nInput: arr = [1,2,3,4,5,6], k = 10\nOutput: false\nExplanation: You can try all possible pairs to see that there is no way to divide arr into 3 pairs each with sum divisible by 10.\n\n \nConstraints:\n\narr.length == n\n1 <= n <= 105\nn is even.\n-109 <= arr[i] <= 109\n1 <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8],k = 4) == True\n assert candidate(arr = [0, 0, 0, 0],k = 1) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6],k = 10) == False\n assert candidate(arr = [-1, 1, -2, 2, -3, 3],k = 2) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3],k = 3) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6],k = 7) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8],k = 8) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9],k = 5) == True\n assert candidate(arr = [0, 0, 0, 0],k = 3) == True\n assert candidate(arr = [0, 0, 0, 0],k = 2) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 6) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],k = 8) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 10) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 7) == False\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 3) == False\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],k = 20) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == True\n assert candidate(arr = [123, 246, 369, 492, 615, 738, 861, 984, 1107, 1230],k = 123) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 25) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == True\n assert candidate(arr = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 6) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],k = 6) == False\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 10) == False\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 3) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 17) == False\n assert candidate(arr = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 3) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 13) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],k = 10) == False\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],k = 7) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16],k = 6) == False\n assert candidate(arr = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600],k = 50) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, 6, 6],k = 5) == False\n assert candidate(arr = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],k = 15) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == False\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 10) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 4) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],k = 15) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 20) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 13) == False\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 15) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 100000) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 7) == False\n assert candidate(arr = [1000000000, 2000000000, -3000000000, 4000000000, 500000000, -600000000, 70000000, -80000000],k = 500000000) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 31) == True\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 20) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 7) == True\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],k = 4) == False\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 2) == True\n assert candidate(arr = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115],k = 6) == False\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 2) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 10) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],k = 25) == False\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220],k = 11) == True\n assert candidate(arr = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 13) == False\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16],k = 5) == False\n assert candidate(arr = [1, 3, 2, 4, 6, 8, 5, 7, 9, 11],k = 3) == False\n assert candidate(arr = [7, 3, 2, 6, 8, 10, 9, 5, 1, 4],k = 7) == False\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3],k = 5) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 5) == False\n assert candidate(arr = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 10) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12],k = 5) == False\n assert candidate(arr = [9, 7, 5, 3, 1, 8, 6, 4, 2, 0, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == False\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],k = 20) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == False\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 5) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 8) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 13) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],k = 5) == False\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 9) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == True\n assert candidate(arr = [-1, -2, -3, -4, 1, 2, 3, 4],k = 3) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 15) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 20) == False\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 3) == True\n assert candidate(arr = [-10, 10, 20, -20, 30, -30, 40, -40],k = 10) == True\n assert candidate(arr = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 8) == True\n assert candidate(arr = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],k = 101) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32],k = 19) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 39) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == True\n"}, "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().canArrange", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canArrange(self, arr: list[int], k: int) -> bool:", "container": "Solution", "callable": "canArrange", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1498, "task_id": "number-of-subsequences-that-satisfy-the-given-sum-condition", "difficulty": "Medium", "problem_description": "You are given an array of integers nums and an integer target.\nReturn the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [3,5,6,7], target = 9\nOutput: 4\nExplanation: There are 4 subsequences that satisfy the condition.\n[3] -> Min value + max value <= target (3 + 3 <= 9)\n[3,5] -> (3 + 5 <= 9)\n[3,5,6] -> (3 + 6 <= 9)\n[3,6] -> (3 + 6 <= 9)\n\nExample 2:\n\nInput: nums = [3,3,6,8], target = 10\nOutput: 6\nExplanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers).\n[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6]\n\nExample 3:\n\nInput: nums = [2,3,3,4,6,7], target = 12\nOutput: 61\nExplanation: There are 63 non-empty subsequences, two of them do not satisfy the condition ([6,7], [7]).\nNumber of valid subsequences (63 - 2 = 61).\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 106\n1 <= target <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],target = 10) == 31\n assert candidate(nums = [10, 10, 10, 10],target = 20) == 15\n assert candidate(nums = [1, 3, 5, 7],target = 8) == 10\n assert candidate(nums = [1, 2, 3, 4, 5],target = 5) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10) == 341\n assert candidate(nums = [9, 7, 5, 3, 1],target = 10) == 21\n assert candidate(nums = [1, 2, 3],target = 5) == 6\n assert candidate(nums = [5, 2, 4, 1, 7, 6, 8],target = 12) == 117\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 1023\n assert candidate(nums = [1],target = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],target = 10) == 31\n assert candidate(nums = [1000000],target = 1000000) == 0\n assert candidate(nums = [3, 3, 6, 8],target = 10) == 6\n assert candidate(nums = [2, 3, 3, 4, 6, 7],target = 12) == 61\n assert candidate(nums = [3, 5, 6, 7],target = 9) == 4\n assert candidate(nums = [5, 2, 4, 1, 7, 6, 8],target = 10) == 101\n assert candidate(nums = [1, 3, 5, 7, 9],target = 10) == 21\n assert candidate(nums = [1, 2, 4, 8, 16],target = 24) == 30\n assert candidate(nums = [1, 1, 1, 1, 1],target = 2) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 20) == 349525\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 1023\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 250) == 1026730\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],target = 1111111) == 126\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],target = 10) == 341\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],target = 1999998) == 1023\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 20) == 682\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 1048575\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1024) == 1023\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],target = 2000000) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],target = 30) == 357913941\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 1023\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 200) == 349525\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],target = 30) == 21845\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 191690598\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 25) == 1026730\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 40) == 699050\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15) == 10922\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],target = 50) == 966320448\n assert candidate(nums = [999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999],target = 1999998) == 1048575\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],target = 200) == 873813\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 10) == 341\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 21) == 699050\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1200) == 853\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 1002\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],target = 100) == 898961330\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],target = 1000000) == 511\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 15) == 1002\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],target = 2000000) == 1023\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],target = 30) == 357913941\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 100) == 341\n assert candidate(nums = [1, 100, 1000, 10000, 100000, 1000000],target = 1100000) == 62\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000],target = 1000000) == 1023\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 300) == 1047893\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],target = 2000000) == 1023\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 1002\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 30) == 1047893\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 300) == 1047893\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 986564552\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],target = 150) == 1047893\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12],target = 15) == 986316\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995],target = 1999993) == 10\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996],target = 1000000) == 341\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 20) == 1048575\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 1002\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],target = 1999998) == 1021\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],target = 1000000) == 1048574\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],target = 1048576) == 1048575\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000],target = 1000000) == 0\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4],target = 6) == 967\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],target = 15) == 1002\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989],target = 1999989) == 1706\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000],target = 1500000) == 1002\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996],target = 2000000) == 1023\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],target = 2500) == 32746\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 10) == 209715\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 20) == 349525\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],target = 200000) == 1023\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = 30) == 21845\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9],target = 10) == 985115752\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 20) == 32085\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],target = 10) == 18641351\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().numSubseq", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numSubseq(self, nums: list[int], target: int) -> int:", "container": "Solution", "callable": "numSubseq", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1499, "task_id": "max-value-of-equation", "difficulty": "Hard", "problem_description": "You are given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <= points.length. You are also given an integer k.\nReturn the maximum value of the equation yi + yj + |xi - xj| where |xi - xj| <= k and 1 <= i < j <= points.length.\nIt is guaranteed that there exists at least one pair of points that satisfy the constraint |xi - xj| <= k.\n \nExample 1:\n\nInput: points = [[1,3],[2,0],[5,10],[6,-10]], k = 1\nOutput: 4\nExplanation: The first two points satisfy the condition |xi - xj| <= 1 and if we calculate the equation we get 3 + 0 + |1 - 2| = 4. Third and fourth points also satisfy the condition and give a value of 10 + -10 + |5 - 6| = 1.\nNo other pairs satisfy the condition, so we return the max of 4 and 1.\n\nExample 2:\n\nInput: points = [[0,0],[3,0],[9,2]], k = 3\nOutput: 3\nExplanation: Only the first two points have an absolute difference of 3 or less in the x-values, and give the value of 0 + 0 + |0 - 3| = 3.\n\n \nConstraints:\n\n2 <= points.length <= 105\npoints[i].length == 2\n-108 <= xi, yi <= 108\n0 <= k <= 2 * 108\nxi < xj for all 1 <= i < j <= points.length\nxi form a strictly increasing sequence.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 3], [2, 0], [5, 10], [6, -10]],k = 1) == 4\n assert candidate(points = [[100000000, 100000000], [200000000, 200000000], [300000000, 300000000]],k = 100000000) == 600000000\n assert candidate(points = [[1, 5], [2, 3], [4, 7], [8, 10]],k = 6) == 21\n assert candidate(points = [[1, 3], [2, 0], [5, 10], [6, -10], [7, 5]],k = 4) == 17\n assert candidate(points = [[-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10]],k = 15) == 20\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4]],k = 2) == 8\n assert candidate(points = [[-1, 1], [-2, 2], [-3, 3]],k = 1) == 4\n assert candidate(points = [[-10, 5], [0, 0], [10, 10], [20, -5]],k = 25) == 35\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5]],k = 2) == 10\n assert candidate(points = [[-10, -10], [0, 0], [10, 10]],k = 20) == 20\n assert candidate(points = [[1, 100000000], [100000000, 1]],k = 200000000) == 200000000\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],k = 4) == 10\n assert candidate(points = [[1, 1], [3, 3], [5, 5]],k = 4) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],k = 2) == 10\n assert candidate(points = [[0, 0], [3, 0], [9, 2]],k = 3) == 3\n assert candidate(points = [[-1, 2], [-3, 3], [1, 3], [2, 4]],k = 4) == 10\n assert candidate(points = [[-1, 20], [-10, 15], [-5, 10], [0, 5], [5, 0], [10, -5], [15, -10]],k = 12) == 30\n assert candidate(points = [[1, 100000000], [2, 99999999], [3, 99999998], [4, 99999997], [5, 99999996], [6, 99999995]],k = 4) == 200000000\n assert candidate(points = [[1, 1], [2, 100000000], [3, 1], [4, 100000000], [5, 1]],k = 1) == 100000002\n assert candidate(points = [[100000000, 100000000], [200000000, -200000000], [300000000, 300000000]],k = 150000000) == 200000000\n assert candidate(points = [[1, 1], [3, 4], [5, 7], [8, 10], [12, 13], [15, 14], [18, 15], [20, 16], [25, 17], [30, 18]],k = 15) == 47\n assert candidate(points = [[100000000, -100000000], [100000001, 100000000], [100000002, -100000000], [100000003, 100000000]],k = 4) == 200000002\n assert candidate(points = [[1, 3], [4, 1], [8, 5], [15, 10], [20, 6], [25, 3]],k = 15) == 27\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],k = 9) == 11\n assert candidate(points = [[1, 3], [4, 5], [7, 8], [10, 12], [13, 15], [16, 18]],k = 5) == 36\n assert candidate(points = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [7, -1], [8, -2], [9, -3], [10, -4]],k = 4) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],k = 2) == 30\n assert candidate(points = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700]],k = 3) == 1301\n assert candidate(points = [[1, 3], [5, 10], [8, 15], [10, 7], [12, 20], [16, 5], [20, 25]],k = 10) == 53\n assert candidate(points = [[1, -1], [2, -2], [3, -3], [4, -4], [5, -5], [6, -6], [7, -7], [8, -8], [9, -9], [10, -10], [11, -11], [12, -12], [13, -13], [14, -14], [15, -15], [16, -16], [17, -17], [18, -18], [19, -19], [20, -20]],k = 5) == -2\n assert candidate(points = [[-1, 1], [0, 0], [1, -1], [2, 2], [3, -3], [4, 4], [5, -5], [6, 6]],k = 2) == 12\n assert candidate(points = [[1, 100], [5, 200], [10, 300], [15, 400], [20, 500], [25, 600], [30, 700]],k = 10) == 1305\n assert candidate(points = [[1, 3], [2, 0], [5, 10], [6, -10], [7, 2], [8, -5], [10, 4]],k = 3) == 14\n assert candidate(points = [[1, 1], [2, 3], [4, 2], [5, 3], [6, 5], [8, 6], [9, 7], [10, 8]],k = 5) == 17\n assert candidate(points = [[1, -1], [2, -2], [3, -3], [4, -4], [5, -5], [6, -6], [7, -7], [8, -8], [9, -9], [10, -10]],k = 5) == -2\n assert candidate(points = [[1, 100000000], [2, -100000000], [3, 100000000], [4, -100000000], [5, 100000000], [6, -100000000], [7, 100000000], [8, -100000000], [9, 100000000], [10, -100000000]],k = 1) == 1\n assert candidate(points = [[1, 1], [3, 5], [5, 3], [7, 9], [9, 4], [11, 10], [13, 6], [15, 8], [17, 2], [19, 12]],k = 4) == 24\n assert candidate(points = [[100000, -100000], [100005, 100000], [100010, -100000], [100015, 100000]],k = 10) == 200010\n assert candidate(points = [[1, 10], [3, 20], [5, 15], [7, 5], [9, 25], [11, 30], [13, 10], [15, 35]],k = 15) == 69\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],k = 1) == 3\n assert candidate(points = [[-5, 10], [-2, 3], [0, 0], [3, -5], [7, 2], [8, -1], [10, 6]],k = 4) == 16\n assert candidate(points = [[1, 1], [3, 4], [6, 7], [8, 10], [11, 13], [15, 16], [18, 19]],k = 7) == 39\n assert candidate(points = [[100000000, -100000000], [200000000, -200000000], [300000000, 100000000], [400000000, 200000000]],k = 250000000) == 400000000\n assert candidate(points = [[-5, -5], [-3, -3], [0, 0], [4, 4], [6, 6], [10, 10]],k = 6) == 20\n assert candidate(points = [[-20, 20], [-18, 18], [-16, 16], [-14, 14], [-12, 12], [-10, 10], [-8, 8], [-6, 6], [-4, 4], [-2, 2]],k = 4) == 40\n assert candidate(points = [[-100000000, -100000000], [-90000000, -90000000], [-80000000, -80000000], [-70000000, -70000000], [-60000000, -60000000], [-50000000, -50000000], [-40000000, -40000000], [-30000000, -30000000], [-20000000, -20000000], [-10000000, -10000000]],k = 20000000) == -20000000\n assert candidate(points = [[1, 100000000], [2, 99999999], [3, 99999998], [4, 99999997], [5, 99999996]],k = 1) == 200000000\n assert candidate(points = [[1, 100000000], [2, 50000000], [5, 10000000], [10, 5000000], [20, 1000000], [50, 500000], [100, 100000]],k = 99) == 150000001\n assert candidate(points = [[-5, -10], [-3, -7], [-1, -2], [1, 3], [4, 9]],k = 4) == 15\n assert candidate(points = [[1, 5], [4, 3], [6, 7], [8, 2], [10, 8]],k = 5) == 19\n assert candidate(points = [[1, 5], [3, 4], [7, 10], [8, 2], [10, 1]],k = 5) == 18\n assert candidate(points = [[1, 2], [4, 5], [6, 7], [8, 9], [10, 12], [12, 15], [14, 17], [16, 19], [18, 21], [20, 23]],k = 10) == 46\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],k = 15) == 29\n assert candidate(points = [[1, 100000000], [-50000000, -100000000], [100000000, -100000000], [-100000000, 100000000]],k = 200000000) == 99999999\n assert candidate(points = [[1, 1], [3, 5], [6, 2], [8, 8], [10, 4], [15, 7], [20, 1]],k = 5) == 18\n assert candidate(points = [[1, 100000000], [100000000, 1], [100000001, 2], [200000000, 3], [300000000, 4], [400000000, 5], [500000000, 6], [600000000, 7], [700000000, 8], [800000000, 9], [900000000, 10]],k = 100000000) == 200000002\n assert candidate(points = [[-1000000, -1000000], [-900000, -900000], [-800000, -800000], [-700000, -700000], [-600000, -600000]],k = 100000) == -1200000\n assert candidate(points = [[-5, 5], [0, 0], [1, 3], [3, -1], [5, 10], [6, -10], [8, 2], [10, 3], [15, 0]],k = 5) == 18\n assert candidate(points = [[1, -1], [2, -2], [3, -3], [4, -4], [5, -5], [6, -6], [7, -7], [8, -8], [9, -9]],k = 2) == -2\n assert candidate(points = [[1, 1], [10, 10], [100, 100], [1000, 1000], [10000, 10000], [100000, 100000], [1000000, 1000000], [10000000, 10000000], [100000000, 100000000]],k = 50000000) == 20000000\n assert candidate(points = [[100000, -100000], [100001, -99999], [100002, -99998], [100003, -99997], [100004, -99996]],k = 4) == -199992\n assert candidate(points = [[-10, -10], [-9, -9], [-8, -8], [-7, -7], [-6, -6], [-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1]],k = 2) == -2\n assert candidate(points = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],k = 3) == 200\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 3) == 20\n assert candidate(points = [[1, 5], [3, 7], [6, 8], [8, 6], [10, 9], [15, 1]],k = 5) == 21\n assert candidate(points = [[-50, -50], [-25, -100], [0, 0], [25, 100], [50, 50]],k = 75) == 175\n assert candidate(points = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]],k = 3) == 1901\n assert candidate(points = [[1, 2], [2, 4], [3, 8], [4, 16], [5, 32]],k = 4) == 49\n assert candidate(points = [[1, 10], [2, 15], [5, 20], [8, 25], [10, 30], [15, 35], [20, 40], [25, 45], [30, 50], [35, 55]],k = 15) == 110\n assert candidate(points = [[-5, -5], [-3, -1], [0, 0], [2, 4], [3, 6], [8, 8]],k = 5) == 19\n assert candidate(points = [[1, 1], [10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10]],k = 15) == 29\n assert candidate(points = [[-100000000, 100000000], [-90000000, 90000000], [0, -50000000], [100000000, 50000000]],k = 110000000) == 200000000\n assert candidate(points = [[1, -1], [3, -2], [5, -3], [7, -4], [9, -5], [11, -6], [13, -7], [15, -8], [17, -9], [19, -10]],k = 18) == 7\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 1) == 20\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 10) == 20\n assert candidate(points = [[2, 3], [5, 6], [8, 9], [11, 12], [14, 15]],k = 3) == 30\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],k = 1) == -inf\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],k = 1) == 18\n assert candidate(points = [[1, -100000000], [2, 100000000], [3, -100000000], [4, 100000000], [5, -100000000], [6, 100000000], [7, -100000000]],k = 2) == 200000002\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]],k = 1) == 20\n assert candidate(points = [[1, 100000000], [2, 99999999], [3, 99999998], [4, 99999997], [5, 99999996], [6, 99999995], [7, 99999994], [8, 99999993], [9, 99999992], [10, 99999991]],k = 1) == 200000000\n assert candidate(points = [[1, 10], [2, 3], [3, 5], [4, 7], [5, 2], [6, 8]],k = 4) == 20\n assert candidate(points = [[10, 50], [20, 30], [30, 20], [40, 10], [50, 0], [60, -10], [70, -20], [80, -30], [90, -40]],k = 25) == 90\n assert candidate(points = [[1, 100000000], [2, 90000000], [3, 80000000], [4, 70000000], [5, 60000000]],k = 3) == 190000001\n assert candidate(points = [[5, 5], [15, 10], [25, 3], [35, 15], [45, 10], [55, 20], [65, 5], [75, 25]],k = 20) == 65\n assert candidate(points = [[1, 1], [10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]],k = 30) == 180\n assert candidate(points = [[1, 1], [2, 10], [3, 3], [4, 15], [5, 5], [6, 20], [7, 7], [8, 25], [9, 9], [10, 30]],k = 10) == 57\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19], [21, 21], [23, 23], [25, 25], [27, 27], [29, 29], [31, 31], [33, 33], [35, 35], [37, 37], [39, 39]],k = 2) == 78\n assert candidate(points = [[-100000000, 100000000], [0, 0], [100000000, -100000000]],k = 200000000) == 200000000\n assert candidate(points = [[-100, 100], [-90, 90], [-80, 80], [-70, 70], [-60, 60], [-50, 50], [-40, 40], [-30, 30], [-20, 20], [-10, 10]],k = 20) == 200\n assert candidate(points = [[-5, -5], [-2, 3], [-1, 2], [0, 0], [1, 5], [2, 1], [4, -2], [6, 3]],k = 4) == 11\n assert candidate(points = [[-10, 0], [-9, 1], [-8, 2], [-7, 3], [-6, 4], [-5, 5], [-4, 6], [-3, 7], [-2, 8], [-1, 9]],k = 3) == 18\n assert candidate(points = [[10, 20], [15, 10], [20, 20], [25, 30], [30, 5], [35, 25], [40, 30]],k = 10) == 65\n assert candidate(points = [[1, 5], [3, 4], [6, 7], [8, 2], [10, 10]],k = 4) == 21\n assert candidate(points = [[-5, 10], [0, -1], [4, 3], [7, -2], [12, 5]],k = 5) == 14\n assert candidate(points = [[-100, 100], [-90, -80], [-80, 80], [-70, -70], [-60, 60], [-50, -50]],k = 20) == 200\n assert candidate(points = [[1, 10], [2, 5], [3, -5], [4, -10], [5, -15], [6, -20], [7, -25], [8, -30]],k = 3) == 16\n assert candidate(points = [[1, 3], [2, 1], [3, 2], [4, 4], [5, 1], [6, 3], [7, 2], [8, 5], [9, 4]],k = 4) == 13\n assert candidate(points = [[-5, -5], [-3, -2], [-1, 0], [2, 3], [5, 5], [8, 8], [11, 11]],k = 7) == 22\n assert candidate(points = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8], [17, 9]],k = 8) == 22\n assert candidate(points = [[1, 2], [3, 5], [5, 7], [7, 10], [9, 15], [11, 20], [13, 25], [15, 30], [17, 35], [19, 40]],k = 10) == 77\n assert candidate(points = [[-50, 10], [-30, 20], [-10, 30], [10, 40], [30, 50], [50, 60], [70, 70], [90, 80], [110, 90]],k = 30) == 190\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 3) == 20\n assert candidate(points = [[-100000000, 100000000], [0, -100000000], [100000000, 100000000]],k = 200000000) == 400000000\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],k = 2) == 40\n assert candidate(points = [[-100000000, 100000000], [-99999999, 99999999], [-99999998, 99999998], [-99999997, 99999997], [-99999996, 99999996], [-99999995, 99999995]],k = 4) == 200000000\n assert candidate(points = [[-100000, 100000], [-90000, 50000], [-80000, 0], [-70000, -50000], [-60000, -100000], [-50000, 100000], [-40000, 50000], [-30000, 0], [-20000, -50000], [-10000, -100000], [0, 100000], [10000, 50000], [20000, 0], [30000, -50000], [40000, -100000], [50000, 100000], [60000, 50000], [70000, 0], [80000, -50000], [90000, -100000], [100000, 100000]],k = 20000) == 160000\n assert candidate(points = [[1, 100], [2, 50], [3, 75], [4, 25], [5, 150]],k = 4) == 254\n"}, "metadata": {"canonical_parameter_names": ["points", "k"], "leetcode_dataset_entry_point": "Solution().findMaxValueOfEquation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findMaxValueOfEquation(self, points: list[list[int]], k: int) -> int:", "container": "Solution", "callable": "findMaxValueOfEquation", "parameters": [{"name": "points", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1502, "task_id": "can-make-arithmetic-progression-from-sequence", "difficulty": "Easy", "problem_description": "A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same.\nGiven an array of numbers arr, return true if the array can be rearranged to form an arithmetic progression. Otherwise, return false.\n \nExample 1:\n\nInput: arr = [3,5,1]\nOutput: true\nExplanation: We can reorder the elements as [1,3,5] or [5,3,1] with differences 2 and -2 respectively, between each consecutive elements.\n\nExample 2:\n\nInput: arr = [1,2,4]\nOutput: false\nExplanation: There is no way to reorder the elements to obtain an arithmetic progression.\n\n \nConstraints:\n\n2 <= arr.length <= 1000\n-106 <= arr[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 4, 6, 8, 10]) == True\n assert candidate(arr = [-1, 1, 0]) == True\n assert candidate(arr = [5, 3, 1, 4, 2]) == True\n assert candidate(arr = [10, 20, 30, 40, 50]) == True\n assert candidate(arr = [10, 5, 15]) == True\n assert candidate(arr = [5, 3, 1, 2, 4]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [5, 3, 1, 4]) == False\n assert candidate(arr = [1, 2, 3, 5]) == False\n assert candidate(arr = [100, -100, 0]) == True\n assert candidate(arr = [-5, -3, -1, 1, 3, 5]) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [5, 3, 1]) == True\n assert candidate(arr = [1, 2, 3, 4, 5]) == True\n assert candidate(arr = [0, 0, 0, 0]) == True\n assert candidate(arr = [10, 5, 0, -5, -10]) == True\n assert candidate(arr = [1, 1, 1, 1]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [1, 2, 4]) == False\n assert candidate(arr = [-1, 1, 3]) == True\n assert candidate(arr = [100, 50, 0, -50, -100]) == True\n assert candidate(arr = [3, 5, 1]) == True\n assert candidate(arr = [0, 0, 0]) == True\n assert candidate(arr = [-1, 0, 1, 2]) == True\n assert candidate(arr = [1, 2, 2, 3, 3, 4]) == False\n assert candidate(arr = [10, 10, 10, 10]) == True\n assert candidate(arr = [1000000, -1000000, 0]) == True\n assert candidate(arr = [10, 0, 20, 10]) == False\n assert candidate(arr = [-5, 0, 5, 10, 15, 20, 25]) == True\n assert candidate(arr = [5, 8, 11, 14, 17, 20]) == True\n assert candidate(arr = [100, 200, 300, 400, 500]) == True\n assert candidate(arr = [-3, -6, -9, -12, -15]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == True\n assert candidate(arr = [5, 5, 5, 5, 5]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16]) == True\n assert candidate(arr = [1, 2, 2, 3, 4]) == False\n assert candidate(arr = [1, 6, 3, 11, 9, 5]) == False\n assert candidate(arr = [-1000000, -999998, -999996, -999994]) == True\n assert candidate(arr = [1000000, -1000000, 500000, -500000, 0]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == False\n assert candidate(arr = [1000000, 999998, 999996, 999994]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27]) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == False\n assert candidate(arr = [1000000, 2000000, 3000000, 4000000, 5000000]) == True\n assert candidate(arr = [1000000, 999998, 1000002, 999996, 1000004, 999994, 1000006, 999992, 1000008, 999990]) == True\n assert candidate(arr = [1, 2, 3, 4, 6, 8, 10]) == False\n assert candidate(arr = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == True\n assert candidate(arr = [-2, -4, -6, -8, -10, -12, -14, -16]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 100]) == False\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == True\n assert candidate(arr = [38, 34, 30, 26, 22, 18, 14, 10, 6, 2]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == True\n assert candidate(arr = [-5, 0, 5, 10, 15]) == True\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]) == False\n assert candidate(arr = [1000000, 1000000, 1000000, 1000000, 1000000]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56]) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == True\n assert candidate(arr = [1000, 1001, 1002, 1003, 1004, 1005]) == True\n assert candidate(arr = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(arr = [1, 2, 2, 3, 4, 5]) == False\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == True\n assert candidate(arr = [100, 50, 0, -50, -100]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60]) == True\n assert candidate(arr = [-1000000, -1000001, -1000002, -1000003, -1000004]) == True\n assert candidate(arr = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0, -1, -3, -7, -15, -31, -62, -125, -250, -500, -1000]) == False\n assert candidate(arr = [1000000, 500000, 0, -500000, -1000000]) == True\n assert candidate(arr = [100, 50, 25, 0, -25, -50, -100]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(arr = [-1000000, -999999, -999998, -999997, -999996]) == True\n assert candidate(arr = [9, 3, 15, 6, 12, 0, 18, 21, 24, 27]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == True\n assert candidate(arr = [1, 3, 6, 10, 15]) == False\n assert candidate(arr = [-3, -1, 1, 3, 5, 7, 9, 11, 13]) == True\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == True\n assert candidate(arr = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700]) == True\n assert candidate(arr = [1, 6, 11, 16, 21, 26]) == True\n assert candidate(arr = [7, 3, 11, 5, 9, 1]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == False\n assert candidate(arr = [7, 14, 21, 28, 35]) == True\n assert candidate(arr = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48]) == True\n assert candidate(arr = [1, 2, 3, 4, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [7, 7, 7, 7, 7]) == True\n assert candidate(arr = [-1000, 1000, 0, 500, -500, 250, -250, 750, -750]) == True\n assert candidate(arr = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7]) == True\n assert candidate(arr = [23, 19, 15, 11, 7, 3, -1, -5]) == True\n assert candidate(arr = [10, 20, 30, 40, 50]) == True\n assert candidate(arr = [10, 5, 0, -5, -10, -15, -20, -25, -30]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(arr = [10, 20, 40, 50, 60]) == False\n assert candidate(arr = [42, 42]) == True\n assert candidate(arr = [-1000000, 1000000, 0, 500000, -500000]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600]) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 101]) == False\n assert candidate(arr = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25, -30]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(arr = [-1000000, -1000001, -1000002, -1000003]) == True\n assert candidate(arr = [3, -1, 1, 5, -3, 7]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11]) == False\n assert candidate(arr = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38]) == True\n assert candidate(arr = [0, 1, 3, 6, 10, 15, 21]) == False\n assert candidate(arr = [100, 99, 97, 94, 90, 85, 79, 72, 64, 55, 45]) == False\n assert candidate(arr = [5, 1, 7, 3, 9]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == True\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == True\n assert candidate(arr = [1000000, 999999, 999998, 999997]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == True\n assert candidate(arr = [1000000, -1000000, 500000, 0, 1500000, -500000]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == True\n assert candidate(arr = [1, 2, 3, 6, 5, 4]) == True\n assert candidate(arr = [100, 200, 150, 50, 250, 0]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33]) == True\n assert candidate(arr = [-3, -2, -1, 0, 1, 2, 3]) == True\n assert candidate(arr = [1, 2, 2, 3, 4, 5, 6]) == False\n assert candidate(arr = [50, 60, 70, 80, 90, 100, 110, 120]) == True\n assert candidate(arr = [2, 4, 8, 16, 32]) == False\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64]) == False\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15]) == True\n assert candidate(arr = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == True\n assert candidate(arr = [5, 9, 13, 17, 21, 25]) == True\n assert candidate(arr = [12, 18, 24, 30, 36, 42, 48]) == True\n assert candidate(arr = [1, 1, 2, 3, 5, 8, 13, 21]) == False\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == True\n assert candidate(arr = [100, 200, 150, 250, 300, 350, 400]) == True\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1]) == True\n assert candidate(arr = [10, 70, 30, 50, 90]) == True\n assert candidate(arr = [1, 100, 50, 75, 25]) == False\n assert candidate(arr = [500000, 499998, 499996, 499994, 499992]) == True\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25]) == True\n assert candidate(arr = [10, 5, 0, -5, -10]) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40]) == True\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == True\n assert candidate(arr = [-1000, -500, 0, 500, 1000]) == True\n assert candidate(arr = [5, 3, 1, -1, -3, -5, -7, -9, -11, -13]) == True\n assert candidate(arr = [1000000, -1000000, 0, 500000, -500000]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(arr = [10, 0, -10, -20, -30]) == True\n assert candidate(arr = [-5, 0, 5, 10, 15, 20]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30]) == True\n assert candidate(arr = [5, 10, 15, 20, 25]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == False\n assert candidate(arr = [3, 1, 5, 7, 9]) == True\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().canMakeArithmeticProgression", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canMakeArithmeticProgression(self, arr: list[int]) -> bool:", "container": "Solution", "callable": "canMakeArithmeticProgression", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1503, "task_id": "last-moment-before-all-ants-fall-out-of-a-plank", "difficulty": "Medium", "problem_description": "We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with a speed of 1 unit per second. Some of the ants move to the left, the other move to the right.\nWhen two ants moving in two different directions meet at some point, they change their directions and continue moving again. Assume changing directions does not take any additional time.\nWhen an ant reaches one end of the plank at a time t, it falls out of the plank immediately.\nGiven an integer n and two integer arrays left and right, the positions of the ants moving to the left and the right, return the moment when the last ant(s) fall out of the plank.\n \nExample 1:\n\n\nInput: n = 4, left = [4,3], right = [0,1]\nOutput: 4\nExplanation: In the image above:\n-The ant at index 0 is named A and going to the right.\n-The ant at index 1 is named B and going to the right.\n-The ant at index 3 is named C and going to the left.\n-The ant at index 4 is named D and going to the left.\nThe last moment when an ant was on the plank is t = 4 seconds. After that, it falls immediately out of the plank. (i.e., We can say that at t = 4.0000000001, there are no ants on the plank).\n\nExample 2:\n\n\nInput: n = 7, left = [], right = [0,1,2,3,4,5,6,7]\nOutput: 7\nExplanation: All ants are going to the right, the ant at index 0 needs 7 seconds to fall.\n\nExample 3:\n\n\nInput: n = 7, left = [0,1,2,3,4,5,6,7], right = []\nOutput: 7\nExplanation: All ants are going to the left, the ant at index 7 needs 7 seconds to fall.\n\n \nConstraints:\n\n1 <= n <= 104\n0 <= left.length <= n + 1\n0 <= left[i] <= n\n0 <= right.length <= n + 1\n0 <= right[i] <= n\n1 <= left.length + right.length <= n + 1\nAll values of left and right are unique, and each value can appear only in one of the two arrays.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 15,left = [10, 11, 12],right = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 15\n assert candidate(n = 1,left = [],right = [0]) == 1\n assert candidate(n = 5,left = [5],right = [0]) == 5\n assert candidate(n = 1,left = [1],right = []) == 1\n assert candidate(n = 5,left = [1, 2],right = [3, 4]) == 2\n assert candidate(n = 1,left = [0],right = [1]) == 0\n assert candidate(n = 7,left = [0, 1, 2, 3, 4, 5, 6, 7],right = []) == 7\n assert candidate(n = 4,left = [4, 3],right = [0, 1]) == 4\n assert candidate(n = 10,left = [2, 6, 7],right = [1, 3, 5, 8]) == 9\n assert candidate(n = 100,left = [10, 20, 30, 40, 50],right = [60, 70, 80, 90, 100]) == 50\n assert candidate(n = 10,left = [2, 6],right = [3, 7]) == 7\n assert candidate(n = 7,left = [],right = [0, 1, 2, 3, 4, 5, 6]) == 7\n assert candidate(n = 100,left = [],right = [0, 100]) == 100\n assert candidate(n = 1000,left = [500, 501, 502],right = [497, 498, 499]) == 503\n assert candidate(n = 100,left = [50],right = [50]) == 50\n assert candidate(n = 1,left = [0],right = []) == 0\n assert candidate(n = 7,left = [],right = [0, 1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(n = 7,left = [0, 1, 2, 3, 4, 5, 6],right = []) == 6\n assert candidate(n = 100,left = [0, 100],right = []) == 100\n assert candidate(n = 10,left = [5],right = [5]) == 5\n assert candidate(n = 10000,left = [1, 2, 3],right = [9997, 9998, 9999]) == 3\n assert candidate(n = 10,left = [1, 2, 3],right = [5, 6, 7]) == 5\n assert candidate(n = 200,left = [100, 150],right = [50, 100]) == 150\n assert candidate(n = 7000,left = [0, 7000],right = [3500]) == 7000\n assert candidate(n = 10000,left = [],right = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 9000\n assert candidate(n = 1000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [990, 991, 992, 993, 994, 995, 996, 997, 998, 999]) == 10\n assert candidate(n = 3000,left = [100, 200, 300, 400, 500, 600],right = [2400, 2500, 2600, 2700, 2800, 2900]) == 600\n assert candidate(n = 8000,left = [100, 200, 300, 400, 500],right = [7900, 7800, 7700, 7600, 7500]) == 500\n assert candidate(n = 3000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [2999, 2998, 2997, 2996, 2995, 2994, 2993, 2992, 2991, 2990]) == 10\n assert candidate(n = 10000,left = [1000, 3000, 5000],right = [2000, 4000, 6000, 8000, 9000]) == 8000\n assert candidate(n = 5000,left = [1234, 2345, 3456, 4567],right = [1000, 2000, 3000, 4000]) == 4567\n assert candidate(n = 10000,left = [1000, 2000, 3000, 4000],right = [6000, 7000, 8000, 9000]) == 4000\n assert candidate(n = 10000,left = [9990, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999],right = []) == 9999\n assert candidate(n = 6000,left = [1500, 2000, 2500, 3000],right = [3500, 4000, 4500, 5000, 5500]) == 3000\n assert candidate(n = 8000,left = [1, 100, 200, 300, 400, 500, 600, 700],right = [7999, 7899, 7799, 7699, 7599, 7499, 7399, 7299]) == 701\n assert candidate(n = 6000,left = [1000, 2000, 3000, 4000, 5000],right = [1500, 2500, 3500, 4500, 5500]) == 5000\n assert candidate(n = 3000,left = [300, 600, 900, 1200, 1500],right = [2700, 2400, 2100, 1800, 1500]) == 1500\n assert candidate(n = 9000,left = [9000],right = [0]) == 9000\n assert candidate(n = 10000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [9990, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999]) == 10\n assert candidate(n = 4000,left = [0, 800, 1600, 2400, 3200],right = [0, 800, 1600, 2400, 3200]) == 4000\n assert candidate(n = 8000,left = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],right = [7900, 7910, 7920, 7930, 7940, 7950, 7960, 7970, 7980, 7990]) == 100\n assert candidate(n = 10000,left = [5000, 6000, 7000, 8000, 9000],right = [1000, 2000, 3000, 4000]) == 9000\n assert candidate(n = 9999,left = [9998, 9997, 9996],right = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9998\n assert candidate(n = 7000,left = [1000, 2000, 3000, 4000, 5000, 6000],right = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 6999\n assert candidate(n = 2000,left = [1000, 1500, 1600, 1700],right = [400, 500, 600, 700]) == 1700\n assert candidate(n = 6000,left = [3000],right = [3000]) == 3000\n assert candidate(n = 6000,left = [0, 1000, 2000, 3000, 4000, 5000],right = [1500, 2500, 3500, 4500, 5500]) == 5000\n assert candidate(n = 15000,left = [],right = [0, 3000, 6000, 9000, 12000, 15000]) == 15000\n assert candidate(n = 9000,left = [1000, 3000, 5000, 7000],right = [2000, 4000, 6000, 8000]) == 7000\n assert candidate(n = 6000,left = [50, 150, 250, 350, 450, 550],right = [5450, 5550, 5650, 5750, 5850, 5950]) == 550\n assert candidate(n = 8000,left = [1000, 2000, 3000, 4000, 5000],right = [3000, 4000, 5000, 6000, 7000]) == 5000\n assert candidate(n = 9000,left = [100, 200, 300, 400, 500, 600, 700, 800],right = [8200, 8300, 8400, 8500, 8600, 8700, 8800, 8900]) == 800\n assert candidate(n = 2000,left = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900],right = [900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 1400, 1500, 1600, 1700, 1800, 1900, 1000, 100]) == 1900\n assert candidate(n = 10000,left = [1, 10, 100, 1000, 10000],right = [2, 20, 200, 2000, 9999]) == 10000\n assert candidate(n = 2000,left = [500, 1500],right = [100, 1900, 1600]) == 1900\n assert candidate(n = 10000,left = [1, 2, 3, 5000, 9999],right = [4, 6, 5002, 9997]) == 9999\n assert candidate(n = 8000,left = [0, 1000, 2000, 3000, 4000, 5000, 6000, 7000],right = [8000]) == 7000\n assert candidate(n = 4000,left = [2000],right = [2000]) == 2000\n assert candidate(n = 10000,left = [],right = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9999\n assert candidate(n = 12000,left = [0, 2400, 4800, 7200, 9600, 12000],right = []) == 12000\n assert candidate(n = 7500,left = [100, 200, 300, 400, 500, 600, 700],right = [7400, 7300, 7200, 7100, 7000, 6900, 6800]) == 700\n assert candidate(n = 9000,left = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500],right = [8500, 8000, 7500, 7000, 6500, 6000, 5500, 5000, 4500]) == 4500\n assert candidate(n = 7000,left = [100, 200, 300, 400],right = [6600, 6700, 6800, 6900]) == 400\n assert candidate(n = 5000,left = [2500, 2501, 2502, 2503],right = [2499, 2498, 2497, 2496]) == 2504\n assert candidate(n = 500,left = [10, 20, 30, 40, 50],right = [450, 460, 470, 480, 490]) == 50\n assert candidate(n = 8000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [7990, 7991, 7992, 7993, 7994, 7995, 7996, 7997, 7998, 7999]) == 10\n assert candidate(n = 9000,left = [100, 200, 300, 400, 500, 600, 700, 800, 900],right = [8100, 8200, 8300, 8400, 8500, 8600, 8700, 8800, 8900]) == 900\n assert candidate(n = 5000,left = [1000, 2000, 3000, 4000, 5000],right = [1, 2, 3, 4]) == 5000\n assert candidate(n = 2000,left = [500, 1000, 1500],right = [100, 600, 1100, 1600]) == 1900\n assert candidate(n = 1500,left = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],right = [1400, 1390, 1380, 1370, 1360, 1350, 1340, 1330, 1320, 1310]) == 190\n assert candidate(n = 5000,left = [10, 20, 30, 40, 50],right = [4950, 4960, 4970, 4980, 4990]) == 50\n assert candidate(n = 12000,left = [6000, 6100, 6200, 6300],right = [5700, 5800, 5900, 6000]) == 6300\n assert candidate(n = 5000,left = [1, 2, 3, 4, 5],right = [4995, 4996, 4997, 4998, 4999]) == 5\n assert candidate(n = 10000,left = [2000, 4000, 6000, 8000],right = [1000, 3000, 5000, 7000, 9000]) == 9000\n assert candidate(n = 10000,left = [1, 100, 1000, 10000],right = [2, 200, 2000, 9999]) == 10000\n assert candidate(n = 1000,left = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],right = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 990\n assert candidate(n = 2000,left = [500, 1000, 1500, 2000],right = [10, 20, 30, 40, 50]) == 2000\n assert candidate(n = 4500,left = [500, 1500, 2500, 3500],right = [1000, 2000, 3000, 4000]) == 3500\n assert candidate(n = 10000,left = [0, 2500, 5000, 7500, 10000],right = [10000, 7500, 5000, 2500, 0]) == 10000\n assert candidate(n = 9500,left = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500],right = [1, 2, 3, 4, 5]) == 9500\n assert candidate(n = 10000,left = [1, 3, 5, 7, 9],right = [2, 4, 6, 8, 10]) == 9998\n assert candidate(n = 6000,left = [1000, 2000, 3000, 4000, 5000],right = [500, 1500, 2500, 3500, 4500]) == 5500\n assert candidate(n = 7500,left = [1000, 2000, 3000],right = [5000, 6000, 7000, 7499]) == 3000\n assert candidate(n = 7500,left = [3000, 4000, 5000],right = [2000, 3000, 4000]) == 5500\n assert candidate(n = 12000,left = [12000],right = [6000]) == 12000\n assert candidate(n = 10000,left = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000],right = []) == 9000\n assert candidate(n = 10000,left = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500],right = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500]) == 9500\n assert candidate(n = 6000,left = [1000, 2000, 3000, 4000, 5000],right = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5900\n assert candidate(n = 10000,left = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],right = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 9998\n assert candidate(n = 1000,left = [500, 600, 700, 800, 900],right = [100, 200, 300, 400]) == 900\n assert candidate(n = 7000,left = [0, 7000],right = [0, 7000]) == 7000\n assert candidate(n = 8000,left = [1, 2, 3, 4, 5, 6, 7, 8],right = [7992, 7993, 7994, 7995, 7996, 7997, 7998, 7999]) == 8\n assert candidate(n = 10000,left = [5000],right = [5000]) == 5000\n assert candidate(n = 1000,left = [999],right = [0]) == 1000\n assert candidate(n = 1000,left = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509],right = [499, 498, 497, 496, 495, 494, 493, 492, 491, 490]) == 510\n assert candidate(n = 5000,left = [100, 200, 300, 400, 500],right = [4500, 4600, 4700, 4800, 4900]) == 500\n assert candidate(n = 5000,left = [0, 1250, 2500, 3750, 5000],right = [1249, 2499, 3749, 4998]) == 5000\n assert candidate(n = 4000,left = [100, 200, 300, 400],right = [3600, 3700, 3800, 3900]) == 400\n assert candidate(n = 12000,left = [2000, 4000, 6000, 8000, 10000],right = [1000, 3000, 5000, 7000, 9000, 11000]) == 11000\n assert candidate(n = 9000,left = [1000, 2000, 3000, 4000, 5000],right = [6000, 7000, 8000, 9000]) == 5000\n assert candidate(n = 9999,left = [1, 2, 3, 4, 5, 6, 7, 8, 9],right = [9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990]) == 9\n assert candidate(n = 9000,left = [100, 200, 300, 400, 500, 600, 700, 800, 900],right = [8900, 8800, 8700, 8600, 8500, 8400, 8300, 8200, 8100]) == 900\n assert candidate(n = 7000,left = [100, 1000, 2000, 3000, 4000],right = [300, 1300, 2300, 3300, 4300]) == 6700\n assert candidate(n = 5000,left = [2500, 2501, 2502, 2503, 2504],right = [2495, 2496, 2497, 2498, 2499]) == 2505\n assert candidate(n = 1000,left = [100, 200, 300, 400, 500, 600, 700, 800, 900],right = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 950\n assert candidate(n = 9999,left = [500, 1500, 2500, 3500, 4500],right = [5500, 6500, 7500, 8500, 9500]) == 4500\n assert candidate(n = 1000,left = [100, 200, 300, 400, 500],right = [600, 700, 800, 900]) == 500\n assert candidate(n = 10000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999, 10000]) == 10\n assert candidate(n = 10000,left = [1, 2, 3, 4, 5],right = [9996, 9995, 9994, 9993, 9992]) == 8\n assert candidate(n = 8500,left = [8500],right = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 7500]) == 8500\n assert candidate(n = 6000,left = [0, 6000],right = [3000]) == 6000\n assert candidate(n = 5000,left = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],right = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 4998\n assert candidate(n = 5000,left = [4999, 4998, 4997, 4996],right = [1, 2, 3, 4]) == 4999\n assert candidate(n = 5000,left = [1000, 2000, 3000, 4000],right = [500, 1500, 2500, 3500, 4500]) == 4500\n assert candidate(n = 10000,left = [1000, 2000, 3000, 4000],right = [7000, 8000, 9000]) == 4000\n assert candidate(n = 12000,left = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],right = [11900, 11800, 11700, 11600, 11500, 11400, 11300, 11200, 11100, 11000]) == 1000\n assert candidate(n = 500,left = [0, 250, 500],right = [0, 250, 500]) == 500\n assert candidate(n = 9999,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989]) == 10\n assert candidate(n = 10000,left = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],right = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9999\n assert candidate(n = 500,left = [0, 100, 200, 300, 400],right = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 490\n assert candidate(n = 7000,left = [500, 1000, 1500, 2000, 2500],right = [6500, 7000, 6000, 6500, 7000]) == 2500\n assert candidate(n = 5000,left = [100, 200, 300, 400],right = [4600, 4700, 4800, 4900]) == 400\n assert candidate(n = 10000,left = [1, 100, 1000, 10000],right = [50, 500, 5000, 9950]) == 10000\n assert candidate(n = 8000,left = [1, 2, 3, 4, 5],right = [7995, 7996, 7997, 7998, 7999]) == 5\n assert candidate(n = 2000,left = [100, 200, 300, 400, 500],right = [1500, 1600, 1700, 1800, 1900]) == 500\n assert candidate(n = 3000,left = [500, 1000, 1500, 2000, 2500],right = [100, 600, 1100, 1600, 2100]) == 2900\n"}, "metadata": {"canonical_parameter_names": ["n", "left", "right"], "leetcode_dataset_entry_point": "Solution().getLastMoment", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getLastMoment(self, n: int, left: list[int], right: list[int]) -> int:", "container": "Solution", "callable": "getLastMoment", "parameters": [{"name": "n", "type": "int"}, {"name": "left", "type": "list[int]"}, {"name": "right", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1504, "task_id": "count-submatrices-with-all-ones", "difficulty": "Medium", "problem_description": "Given an m x n binary matrix mat, return the number of submatrices that have all ones.\n \nExample 1:\n\n\nInput: mat = [[1,0,1],[1,1,0],[1,1,0]]\nOutput: 13\nExplanation: \nThere are 6 rectangles of side 1x1.\nThere are 2 rectangles of side 1x2.\nThere are 3 rectangles of side 2x1.\nThere is 1 rectangle of side 2x2. \nThere is 1 rectangle of side 3x1.\nTotal number of rectangles = 6 + 2 + 3 + 1 + 1 = 13.\n\nExample 2:\n\n\nInput: mat = [[0,1,1,0],[0,1,1,1],[1,1,1,0]]\nOutput: 24\nExplanation: \nThere are 8 rectangles of side 1x1.\nThere are 5 rectangles of side 1x2.\nThere are 2 rectangles of side 1x3. \nThere are 4 rectangles of side 2x1.\nThere are 2 rectangles of side 2x2. \nThere are 2 rectangles of side 3x1. \nThere is 1 rectangle of side 3x2. \nTotal number of rectangles = 8 + 5 + 2 + 4 + 2 + 2 + 1 = 24.\n\n \nConstraints:\n\n1 <= m, n <= 150\nmat[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[0, 0], [0, 0]]) == 0\n assert candidate(mat = [[1, 0, 1], [1, 1, 0], [1, 1, 0]]) == 13\n assert candidate(mat = [[1, 0], [0, 1]]) == 2\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 60\n assert candidate(mat = [[0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 36\n assert candidate(mat = [[0, 1, 1, 0], [0, 1, 1, 1], [1, 1, 1, 0]]) == 24\n assert candidate(mat = [[1, 1], [1, 1]]) == 9\n assert candidate(mat = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(mat = [[1, 1, 0, 1], [0, 1, 1, 0], [1, 0, 1, 1], [1, 1, 1, 1]]) == 28\n assert candidate(mat = [[0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 0, 0, 0, 1]]) == 89\n assert candidate(mat = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == 36\n assert candidate(mat = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 15\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 32\n assert candidate(mat = [[0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]]) == 29\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 126\n assert candidate(mat = [[0, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 0]]) == 69\n assert candidate(mat = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 18\n assert candidate(mat = [[1, 1, 1, 0, 0, 0], [1, 1, 0, 1, 1, 0], [1, 0, 0, 0, 0, 1], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 0]]) == 43\n assert candidate(mat = [[1, 0, 1, 1], [1, 1, 1, 1], [0, 1, 1, 0], [1, 0, 1, 0], [0, 1, 1, 1]]) == 40\n assert candidate(mat = [[1, 1, 1, 0, 1], [1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0]]) == 59\n assert candidate(mat = [[1, 1, 0, 1], [1, 1, 1, 0], [0, 1, 1, 1], [1, 0, 1, 1]]) == 31\n assert candidate(mat = [[1, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1]]) == 85\n assert candidate(mat = [[1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == 50\n assert candidate(mat = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0]]) == 18\n assert candidate(mat = [[1, 1, 0, 1, 1], [1, 0, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 0, 1], [1, 0, 1, 1, 1]]) == 50\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 420\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 28\n assert candidate(mat = [[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [1, 0, 0, 0, 1]]) == 25\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1], [1, 0, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 1]]) == 105\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 13\n assert candidate(mat = [[1, 1, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1], [1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1]]) == 105\n assert candidate(mat = [[1, 1, 0, 0], [1, 1, 1, 1], [0, 0, 1, 0], [1, 1, 1, 1]]) == 30\n assert candidate(mat = [[1, 1, 0, 1], [1, 1, 1, 1], [0, 1, 1, 1], [1, 0, 1, 0]]) == 36\n assert candidate(mat = [[1, 0, 1], [1, 1, 1], [0, 1, 1], [1, 1, 1], [1, 0, 1]]) == 37\n assert candidate(mat = [[1, 1, 0, 0, 1, 1], [0, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 0, 0]]) == 60\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1], [1, 1, 1, 1, 1]]) == 48\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 128\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 270\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 141\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1]]) == 93\n assert candidate(mat = [[1, 1, 1, 1, 0], [1, 1, 1, 1, 0], [1, 1, 0, 0, 1], [0, 1, 0, 1, 1], [1, 1, 1, 1, 1]]) == 71\n assert candidate(mat = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 21\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 0], [1, 1, 0, 0, 1]]) == 114\n assert candidate(mat = [[1, 1, 1, 0], [0, 1, 1, 1], [1, 1, 1, 1], [0, 1, 0, 1]]) == 41\n assert candidate(mat = [[1, 0, 1, 1], [1, 1, 1, 0], [1, 1, 0, 1], [0, 1, 1, 1]]) == 29\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 233\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 0, 1]]) == 44\n assert candidate(mat = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == 9\n assert candidate(mat = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 1, 1], [0, 1, 1, 0]]) == 34\n assert candidate(mat = [[1, 0, 1, 0, 1], [1, 1, 0, 1, 1], [0, 1, 1, 0, 1], [1, 0, 1, 0, 1], [1, 1, 0, 1, 1]]) == 36\n assert candidate(mat = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == 18\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 57\n assert candidate(mat = [[1, 1, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 0]]) == 76\n assert candidate(mat = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 1]]) == 51\n assert candidate(mat = [[1, 1, 1], [0, 0, 0], [1, 1, 1], [0, 0, 0], [1, 1, 1], [0, 0, 0]]) == 18\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]]) == 196\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 210\n assert candidate(mat = [[1, 1, 0, 1], [0, 1, 1, 0], [1, 0, 1, 1], [0, 1, 0, 1], [1, 1, 1, 0]]) == 23\n assert candidate(mat = [[1, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 62\n assert candidate(mat = [[0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0]]) == 54\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 540\n assert candidate(mat = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 1, 1]]) == 25\n assert candidate(mat = [[0, 1, 1, 0, 0, 1, 1, 0, 0, 1], [1, 1, 1, 0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1, 0, 0, 1], [1, 1, 1, 0, 0, 1, 1, 1, 0, 0]]) == 74\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 1], [1, 1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0], [1, 1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 112\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 315\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 10\n assert candidate(mat = [[1, 1, 1, 0, 1, 1], [1, 0, 1, 1, 1, 0], [1, 1, 0, 1, 1, 1], [0, 1, 1, 1, 1, 0]]) == 52\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 56\n assert candidate(mat = [[1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == 71\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1]]) == 87\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 89\n assert candidate(mat = [[1, 0, 1, 0, 1], [1, 1, 1, 0, 0], [0, 1, 1, 1, 1], [1, 1, 1, 1, 0]]) == 45\n assert candidate(mat = [[1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1, 0], [1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0]]) == 30\n assert candidate(mat = [[1, 1, 1, 0, 0, 1], [1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1], [1, 0, 0, 1, 1, 1]]) == 51\n assert candidate(mat = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 14\n assert candidate(mat = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1]]) == 45\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [0, 1, 1, 1, 1], [0, 0, 1, 1, 1], [1, 1, 1, 0, 0]]) == 67\n assert candidate(mat = [[0, 1, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 0, 1]]) == 68\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 110\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 45\n assert candidate(mat = [[1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 1, 1], [0, 1, 1, 1, 1]]) == 91\n assert candidate(mat = [[1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0], [1, 0, 1, 1]]) == 28\n assert candidate(mat = [[1, 1, 0, 1], [1, 1, 1, 1], [0, 1, 1, 1], [1, 1, 1, 1]]) == 56\n assert candidate(mat = [[0, 1, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 1], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1]]) == 50\n assert candidate(mat = [[1, 0, 1, 1, 1], [1, 1, 1, 0, 1], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1]]) == 58\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 117\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1, 1]]) == 56\n"}, "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().numSubmat", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numSubmat(self, mat: list[list[int]]) -> int:", "container": "Solution", "callable": "numSubmat", "parameters": [{"name": "mat", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1505, "task_id": "minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits", "difficulty": "Hard", "problem_description": "You are given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the integer at most k times.\nReturn the minimum integer you can obtain also as a string.\n \nExample 1:\n\n\nInput: num = \"4321\", k = 4\nOutput: \"1342\"\nExplanation: The steps to obtain the minimum integer from 4321 with 4 adjacent swaps are shown.\n\nExample 2:\n\nInput: num = \"100\", k = 1\nOutput: \"010\"\nExplanation: It's ok for the output to have leading zeros, but the input is guaranteed not to have any leading zeros.\n\nExample 3:\n\nInput: num = \"36789\", k = 1000\nOutput: \"36789\"\nExplanation: We can keep the number without any swaps.\n\n \nConstraints:\n\n1 <= num.length <= 3 * 104\nnum consists of only digits and does not contain leading zeros.\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"36789\",k = 1000) == \"36789\"\n assert candidate(num = \"100\",k = 1) == \"010\"\n assert candidate(num = \"9876543210\",k = 9) == \"0987654321\"\n assert candidate(num = \"9876543210\",k = 100) == \"0123456789\"\n assert candidate(num = \"222111333\",k = 10) == \"111222333\"\n assert candidate(num = \"4321\",k = 4) == \"1342\"\n assert candidate(num = \"3452345\",k = 3) == \"2345345\"\n assert candidate(num = \"111222333\",k = 5) == \"111222333\"\n assert candidate(num = \"9876543210\",k = 5) == \"4987653210\"\n assert candidate(num = \"123456789\",k = 0) == \"123456789\"\n assert candidate(num = \"102030405060708090\",k = 20) == \"000001023456708090\"\n assert candidate(num = \"29431\",k = 2) == \"23941\"\n assert candidate(num = \"59585756555453525150\",k = 100) == \"01234555555556987555\"\n assert candidate(num = \"9999999999\",k = 50) == \"9999999999\"\n assert candidate(num = \"9487653210\",k = 10) == \"0498765321\"\n assert candidate(num = \"1234567890\",k = 9) == \"0123456789\"\n assert candidate(num = \"5397268410\",k = 15) == \"0235796841\"\n assert candidate(num = \"111222333444555\",k = 25) == \"111222333444555\"\n assert candidate(num = \"98765432101234567890\",k = 50) == \"00112987654323456789\"\n assert candidate(num = \"5432109876\",k = 10) == \"0145329876\"\n assert candidate(num = \"1234321\",k = 5) == \"1123432\"\n assert candidate(num = \"9999999999888888888877777777776666666666\",k = 100) == \"6668999999999988888888877777777776666666\"\n assert candidate(num = \"0000000000000000000000001\",k = 1) == \"0000000000000000000000001\"\n assert candidate(num = \"198765432\",k = 20) == \"123479865\"\n assert candidate(num = \"54321098765432109876543210\",k = 50) == \"00012453987654321987654321\"\n assert candidate(num = \"98765432101234567890\",k = 100) == \"00112233445566778899\"\n assert candidate(num = \"5432109876\",k = 30) == \"0123456789\"\n assert candidate(num = \"5943281760\",k = 15) == \"0159432876\"\n assert candidate(num = \"19876543210\",k = 10) == \"01987654321\"\n assert candidate(num = \"77665544332211009988\",k = 100) == \"00112233447766559988\"\n assert candidate(num = \"543210987654321098765432109876543210\",k = 200) == \"000011112222345498765398765439876543\"\n assert candidate(num = \"5946132780\",k = 15) == \"0145963278\"\n assert candidate(num = \"987654321012345678909876543210\",k = 1000) == \"000111222333444555666777888999\"\n assert candidate(num = \"342134213421\",k = 15) == \"112234343421\"\n assert candidate(num = \"9876543210\",k = 30) == \"0123987654\"\n assert candidate(num = \"1234567890\",k = 10) == \"0123456789\"\n assert candidate(num = \"1234567890\",k = 15) == \"0123456789\"\n assert candidate(num = \"999999999999999999999999\",k = 1000000) == \"999999999999999999999999\"\n assert candidate(num = \"44444444444444444444\",k = 1000) == \"44444444444444444444\"\n assert candidate(num = \"87654321098765432109\",k = 200) == \"00112233445566778899\"\n assert candidate(num = \"999888777666555444333222111000\",k = 1000) == \"000111222333444555666777888999\"\n assert candidate(num = \"9876543210987654321098765432109876543210\",k = 200) == \"0000111122369875498765439876543298765432\"\n assert candidate(num = \"5555555555\",k = 100) == \"5555555555\"\n assert candidate(num = \"98765432109876543210\",k = 25) == \"01289765439876543210\"\n assert candidate(num = \"9876543210\",k = 45) == \"0123456789\"\n assert candidate(num = \"9876543210\",k = 0) == \"9876543210\"\n assert candidate(num = \"1234567890123456789012345678901234567890\",k = 500) == \"0000111122223333444455556666777788889999\"\n assert candidate(num = \"55555555555555555555555555555555\",k = 10000) == \"55555555555555555555555555555555\"\n assert candidate(num = \"12345678901234567890\",k = 100) == \"00112233445566778899\"\n assert candidate(num = \"1010101010101010101010101010101010101010\",k = 50) == \"0000000001111101111110101010101010101010\"\n assert candidate(num = \"9438527610\",k = 10) == \"0493852761\"\n assert candidate(num = \"987654321098765432109876543210\",k = 1000) == \"000111222333444555666777888999\"\n assert candidate(num = \"5432198760\",k = 20) == \"0123458976\"\n assert candidate(num = \"9876543210123456789098765432101234567890\",k = 300) == \"0000111122223333444479865567899876556789\"\n assert candidate(num = \"2134567890\",k = 5) == \"1234506789\"\n assert candidate(num = \"3333222211110000\",k = 50) == \"0000332332221111\"\n assert candidate(num = \"1234567890987654321\",k = 25) == \"0112345678998765432\"\n assert candidate(num = \"0000000001\",k = 5) == \"0000000001\"\n assert candidate(num = \"1098765432\",k = 20) == \"0123489765\"\n assert candidate(num = \"111112222233333444445555566666777778888899999\",k = 500) == \"111112222233333444445555566666777778888899999\"\n assert candidate(num = \"12345678909876543210\",k = 50) == \"00112345657899876432\"\n assert candidate(num = \"1432214321\",k = 10) == \"1122343421\"\n assert candidate(num = \"12341234123412341234\",k = 50) == \"11111222223434343434\"\n assert candidate(num = \"111222333444555666777888999\",k = 300) == \"111222333444555666777888999\"\n assert candidate(num = \"333222111000999888777666555444333222111000\",k = 500) == \"000000111111222222333333444555666779899887\"\n assert candidate(num = \"9999999999999999999999999999999999999999\",k = 100000) == \"9999999999999999999999999999999999999999\"\n assert candidate(num = \"1111111111111111111111111111111\",k = 30000) == \"1111111111111111111111111111111\"\n assert candidate(num = \"6482319570\",k = 8) == \"1264839570\"\n assert candidate(num = \"5999888777666555444333222111000\",k = 100) == \"0004599988877766655544333222111\"\n assert candidate(num = \"94321\",k = 3) == \"29431\"\n assert candidate(num = \"1234321\",k = 3) == \"1223431\"\n assert candidate(num = \"87654321098765432109\",k = 50) == \"00115876432987654329\"\n assert candidate(num = \"8765432109\",k = 100) == \"0123456789\"\n assert candidate(num = \"555555555555555555555555\",k = 100000) == \"555555555555555555555555\"\n assert candidate(num = \"123456789876543212345678987654321\",k = 150) == \"111222233334456789876545678987654\"\n assert candidate(num = \"54321098765432109876\",k = 100) == \"00112233445566778899\"\n assert candidate(num = \"432101234\",k = 10) == \"011432234\"\n assert candidate(num = \"1234567890\",k = 30) == \"0123456789\"\n assert candidate(num = \"9876543210\",k = 50) == \"0123456789\"\n assert candidate(num = \"1987654320\",k = 15) == \"0139876542\"\n assert candidate(num = \"5142369870\",k = 15) == \"0123456987\"\n assert candidate(num = \"444333222111000\",k = 50) == \"000134344322211\"\n assert candidate(num = \"98765432109876543210\",k = 20) == \"01698754329876543210\"\n assert candidate(num = \"9457836120\",k = 8) == \"1495783620\"\n assert candidate(num = \"9876543210\",k = 10000) == \"0123456789\"\n assert candidate(num = \"9632147850\",k = 12) == \"0296314785\"\n assert candidate(num = \"10987654321\",k = 10) == \"01189765432\"\n assert candidate(num = \"1234543210\",k = 25) == \"0112233445\"\n assert candidate(num = \"1221331223\",k = 20) == \"1112222333\"\n assert candidate(num = \"1234567890\",k = 50) == \"0123456789\"\n assert candidate(num = \"8642013579\",k = 20) == \"0123456789\"\n assert candidate(num = \"11111111111111111111\",k = 10000) == \"11111111111111111111\"\n assert candidate(num = \"192837465546738291\",k = 50) == \"112233458976546789\"\n assert candidate(num = \"9438276510\",k = 10) == \"0493827651\"\n assert candidate(num = \"123456789012345678901234567890\",k = 100) == \"000111222345678394567893456789\"\n assert candidate(num = \"12345678901234567890\",k = 20) == \"01123456278934567890\"\n assert candidate(num = \"333222111\",k = 20) == \"111323322\"\n assert candidate(num = \"9876543210\",k = 25) == \"0128976543\"\n assert candidate(num = \"98765432109876543210\",k = 100) == \"00112233458976987654\"\n assert candidate(num = \"000111222333444555666777888999\",k = 50) == \"000111222333444555666777888999\"\n assert candidate(num = \"1234567890\",k = 25) == \"0123456789\"\n assert candidate(num = \"5432109876\",k = 15) == \"0123459876\"\n assert candidate(num = \"010203040506070809\",k = 30) == \"000000001234560789\"\n assert candidate(num = \"99999999999999999999\",k = 1000) == \"99999999999999999999\"\n assert candidate(num = \"99887766554433221100\",k = 50) == \"00299887766554433211\"\n assert candidate(num = \"12345678900987654321\",k = 50) == \"00112234567889976543\"\n"}, "metadata": {"canonical_parameter_names": ["num", "k"], "leetcode_dataset_entry_point": "Solution().minInteger", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minInteger(self, num: str, k: int) -> str:", "container": "Solution", "callable": "minInteger", "parameters": [{"name": "num", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1507, "task_id": "reformat-date", "difficulty": "Easy", "problem_description": "Given a date string in the form Day Month Year, where:\n\nDay is in the set {\"1st\", \"2nd\", \"3rd\", \"4th\", ..., \"30th\", \"31st\"}.\nMonth is in the set {\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"}.\nYear is in the range [1900, 2100].\n\nConvert the date string to the format YYYY-MM-DD, where:\n\nYYYY denotes the 4 digit year.\nMM denotes the 2 digit month.\nDD denotes the 2 digit day.\n\n \nExample 1:\n\nInput: date = \"20th Oct 2052\"\nOutput: \"2052-10-20\"\n\nExample 2:\n\nInput: date = \"6th Jun 1933\"\nOutput: \"1933-06-06\"\n\nExample 3:\n\nInput: date = \"26th May 1960\"\nOutput: \"1960-05-26\"\n\n \nConstraints:\n\nThe given dates are guaranteed to be valid, so no error handling is necessary.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(date = \"15th Aug 2022\") == \"2022-08-15\"\n assert candidate(date = \"22nd Aug 1999\") == \"1999-08-22\"\n assert candidate(date = \"3rd Mar 1987\") == \"1987-03-03\"\n assert candidate(date = \"3rd Nov 2022\") == \"2022-11-03\"\n assert candidate(date = \"2nd Mar 2020\") == \"2020-03-02\"\n assert candidate(date = \"15th Nov 2000\") == \"2000-11-15\"\n assert candidate(date = \"2nd Mar 2010\") == \"2010-03-02\"\n assert candidate(date = \"31st Dec 2100\") == \"2100-12-31\"\n assert candidate(date = \"25th Dec 2000\") == \"2000-12-25\"\n assert candidate(date = \"11th Sep 2023\") == \"2023-09-11\"\n assert candidate(date = \"15th Nov 1999\") == \"1999-11-15\"\n assert candidate(date = \"15th Nov 2020\") == \"2020-11-15\"\n assert candidate(date = \"11th Mar 2000\") == \"2000-03-11\"\n assert candidate(date = \"5th Sep 1899\") == \"1899-09-05\"\n assert candidate(date = \"3rd Apr 2015\") == \"2015-04-03\"\n assert candidate(date = \"26th May 1960\") == \"1960-05-26\"\n assert candidate(date = \"11th Sep 1999\") == \"1999-09-11\"\n assert candidate(date = \"28th Feb 1900\") == \"1900-02-28\"\n assert candidate(date = \"20th Oct 2052\") == \"2052-10-20\"\n assert candidate(date = \"6th Jun 1933\") == \"1933-06-06\"\n assert candidate(date = \"2nd Mar 2015\") == \"2015-03-02\"\n assert candidate(date = \"1st Jan 1900\") == \"1900-01-01\"\n assert candidate(date = \"28th Feb 1996\") == \"1996-02-28\"\n assert candidate(date = \"29th Feb 2004\") == \"2004-02-29\"\n assert candidate(date = \"2nd Feb 2020\") == \"2020-02-02\"\n assert candidate(date = \"11th Sep 2020\") == \"2020-09-11\"\n assert candidate(date = \"29th Feb 2000\") == \"2000-02-29\"\n assert candidate(date = \"8th Feb 1987\") == \"1987-02-08\"\n assert candidate(date = \"31st Jan 2100\") == \"2100-01-31\"\n assert candidate(date = \"5th Nov 1999\") == \"1999-11-05\"\n assert candidate(date = \"22nd Sep 1965\") == \"1965-09-22\"\n assert candidate(date = \"27th Jun 2012\") == \"2012-06-27\"\n assert candidate(date = \"30th Nov 2010\") == \"2010-11-30\"\n assert candidate(date = \"19th Dec 2099\") == \"2099-12-19\"\n assert candidate(date = \"31st May 2023\") == \"2023-05-31\"\n assert candidate(date = \"31st Dec 2099\") == \"2099-12-31\"\n assert candidate(date = \"4th Mar 2003\") == \"2003-03-04\"\n assert candidate(date = \"24th Jun 2050\") == \"2050-06-24\"\n assert candidate(date = \"23rd Apr 2040\") == \"2040-04-23\"\n assert candidate(date = \"27th Sep 2077\") == \"2077-09-27\"\n assert candidate(date = \"6th Mar 2077\") == \"2077-03-06\"\n assert candidate(date = \"18th Jun 2050\") == \"2050-06-18\"\n assert candidate(date = \"10th Oct 2033\") == \"2033-10-10\"\n assert candidate(date = \"29th Apr 1999\") == \"1999-04-29\"\n assert candidate(date = \"25th Oct 2050\") == \"2050-10-25\"\n assert candidate(date = \"14th May 2005\") == \"2005-05-14\"\n assert candidate(date = \"23rd Oct 2005\") == \"2005-10-23\"\n assert candidate(date = \"30th Apr 2047\") == \"2047-04-30\"\n assert candidate(date = \"19th Aug 2076\") == \"2076-08-19\"\n assert candidate(date = \"21st Jun 1972\") == \"1972-06-21\"\n assert candidate(date = \"18th May 1950\") == \"1950-05-18\"\n assert candidate(date = \"4th Nov 2035\") == \"2035-11-04\"\n assert candidate(date = \"29th Feb 2020\") == \"2020-02-29\"\n assert candidate(date = \"9th Sep 1987\") == \"1987-09-09\"\n assert candidate(date = \"31st Jan 1980\") == \"1980-01-31\"\n assert candidate(date = \"18th Sep 2089\") == \"2089-09-18\"\n assert candidate(date = \"21st Aug 1955\") == \"1955-08-21\"\n assert candidate(date = \"30th Nov 1969\") == \"1969-11-30\"\n assert candidate(date = \"27th Oct 2075\") == \"2075-10-27\"\n assert candidate(date = \"3rd Nov 2021\") == \"2021-11-03\"\n assert candidate(date = \"18th Jul 1950\") == \"1950-07-18\"\n assert candidate(date = \"12th Aug 2022\") == \"2022-08-12\"\n assert candidate(date = \"19th Dec 2021\") == \"2021-12-19\"\n assert candidate(date = \"3rd Jul 1970\") == \"1970-07-03\"\n assert candidate(date = \"7th Dec 2099\") == \"2099-12-07\"\n assert candidate(date = \"9th Jun 2040\") == \"2040-06-09\"\n assert candidate(date = \"21st Nov 2050\") == \"2050-11-21\"\n assert candidate(date = \"16th May 2067\") == \"2067-05-16\"\n assert candidate(date = \"14th Oct 1960\") == \"1960-10-14\"\n assert candidate(date = \"25th Dec 1984\") == \"1984-12-25\"\n assert candidate(date = \"22nd Sep 2050\") == \"2050-09-22\"\n assert candidate(date = \"28th Feb 2000\") == \"2000-02-28\"\n assert candidate(date = \"15th Aug 2024\") == \"2024-08-15\"\n assert candidate(date = \"5th Oct 2100\") == \"2100-10-05\"\n assert candidate(date = \"22nd Aug 2022\") == \"2022-08-22\"\n assert candidate(date = \"21st Sep 1989\") == \"1989-09-21\"\n assert candidate(date = \"22nd Mar 2015\") == \"2015-03-22\"\n assert candidate(date = \"12th Mar 2021\") == \"2021-03-12\"\n assert candidate(date = \"13th Dec 2033\") == \"2033-12-13\"\n assert candidate(date = \"13th Aug 1984\") == \"1984-08-13\"\n assert candidate(date = \"3rd Mar 2030\") == \"2030-03-03\"\n assert candidate(date = \"13th Aug 2023\") == \"2023-08-13\"\n assert candidate(date = \"10th Oct 1899\") == \"1899-10-10\"\n assert candidate(date = \"17th Mar 1925\") == \"1925-03-17\"\n assert candidate(date = \"21st Dec 1900\") == \"1900-12-21\"\n assert candidate(date = \"4th Mar 1921\") == \"1921-03-04\"\n assert candidate(date = \"24th Jun 1998\") == \"1998-06-24\"\n assert candidate(date = \"22nd Jul 2034\") == \"2034-07-22\"\n assert candidate(date = \"25th Jun 2023\") == \"2023-06-25\"\n assert candidate(date = \"30th Nov 2045\") == \"2045-11-30\"\n assert candidate(date = \"30th Apr 2000\") == \"2000-04-30\"\n assert candidate(date = \"28th Feb 1999\") == \"1999-02-28\"\n assert candidate(date = \"2nd Jan 1901\") == \"1901-01-02\"\n assert candidate(date = \"1st Mar 2024\") == \"2024-03-01\"\n assert candidate(date = \"5th Jul 1955\") == \"1955-07-05\"\n assert candidate(date = \"28th Feb 2001\") == \"2001-02-28\"\n assert candidate(date = \"9th Dec 2030\") == \"2030-12-09\"\n assert candidate(date = \"5th Oct 1987\") == \"1987-10-05\"\n assert candidate(date = \"10th Mar 2012\") == \"2012-03-10\"\n assert candidate(date = \"7th Jun 2080\") == \"2080-06-07\"\n assert candidate(date = \"9th Jul 1987\") == \"1987-07-09\"\n assert candidate(date = \"28th Feb 1901\") == \"1901-02-28\"\n assert candidate(date = \"7th Jul 2021\") == \"2021-07-07\"\n assert candidate(date = \"7th Nov 1969\") == \"1969-11-07\"\n assert candidate(date = \"2nd Mar 1990\") == \"1990-03-02\"\n assert candidate(date = \"28th Feb 2004\") == \"2004-02-28\"\n assert candidate(date = \"30th Apr 2077\") == \"2077-04-30\"\n assert candidate(date = \"30th Apr 2100\") == \"2100-04-30\"\n assert candidate(date = \"12th Sep 1995\") == \"1995-09-12\"\n assert candidate(date = \"2nd Apr 2023\") == \"2023-04-02\"\n assert candidate(date = \"17th Oct 2061\") == \"2061-10-17\"\n"}, "metadata": {"canonical_parameter_names": ["date"], "leetcode_dataset_entry_point": "Solution().reformatDate", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def reformatDate(self, date: str) -> str:", "container": "Solution", "callable": "reformatDate", "parameters": [{"name": "date", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1508, "task_id": "range-sum-of-sorted-subarray-sums", "difficulty": "Medium", "problem_description": "You are given the array nums consisting of n positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreasing order, creating a new array of n * (n + 1) / 2 numbers.\nReturn the sum of the numbers from index left to index right (indexed from 1), inclusive, in the new array. Since the answer can be a huge number return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [1,2,3,4], n = 4, left = 1, right = 5\nOutput: 13 \nExplanation: All subarray sums are 1, 3, 6, 10, 2, 5, 9, 3, 7, 4. After sorting them in non-decreasing order we have the new array [1, 2, 3, 3, 4, 5, 6, 7, 9, 10]. The sum of the numbers from index le = 1 to ri = 5 is 1 + 2 + 3 + 3 + 4 = 13. \n\nExample 2:\n\nInput: nums = [1,2,3,4], n = 4, left = 3, right = 4\nOutput: 6\nExplanation: The given array is the same as example 1. We have the new array [1, 2, 3, 3, 4, 5, 6, 7, 9, 10]. The sum of the numbers from index le = 3 to ri = 4 is 3 + 3 = 6.\n\nExample 3:\n\nInput: nums = [1,2,3,4], n = 4, left = 1, right = 10\nOutput: 50\n\n \nConstraints:\n\nn == nums.length\n1 <= nums.length <= 1000\n1 <= nums[i] <= 100\n1 <= left <= right <= n * (n + 1) / 2\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4],n = 4,left = 3,right = 4) == 6\n assert candidate(nums = [10, 20, 30],n = 3,left = 1,right = 3) == 60\n assert candidate(nums = [5, 1, 2],n = 3,left = 1,right = 4) == 11\n assert candidate(nums = [1, 2, 3, 4],n = 4,left = 1,right = 5) == 13\n assert candidate(nums = [3, 3, 3, 3],n = 4,left = 2,right = 8) == 36\n assert candidate(nums = [1, 2, 3, 4],n = 4,left = 1,right = 10) == 50\n assert candidate(nums = [3, 3, 3],n = 3,left = 2,right = 5) == 18\n assert candidate(nums = [5, 2, 1, 4],n = 4,left = 3,right = 7) == 24\n assert candidate(nums = [10, 20, 30],n = 3,left = 2,right = 5) == 130\n assert candidate(nums = [5, 1, 4],n = 3,left = 1,right = 6) == 31\n assert candidate(nums = [5, 1, 2, 3],n = 4,left = 2,right = 6) == 18\n assert candidate(nums = [10, 20, 30],n = 3,left = 1,right = 5) == 140\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],n = 15,left = 60,right = 120) == 46215\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],n = 10,left = 25,right = 50) == 756\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 20,right = 30) == 36\n assert candidate(nums = [5, 15, 10, 20, 25],n = 5,left = 1,right = 15) == 520\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],n = 10,left = 25,right = 55) == 2334\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 15,right = 45) == 6700\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 25,right = 75) == 10110\n assert candidate(nums = [100, 200, 300, 400, 500],n = 5,left = 10,right = 20) == 6900\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 10,left = 1,right = 100) == 2200\n assert candidate(nums = [50, 40, 30, 20, 10],n = 5,left = 5,right = 15) == 960\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],n = 11,left = 15,right = 45) == 460\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],n = 20,left = 100,right = 200) == 11368\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],n = 15,left = 50,right = 100) == 5098\n assert candidate(nums = [23, 34, 45, 56, 67, 78, 89, 90, 100, 110],n = 10,left = 25,right = 60) == 12693\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],n = 9,left = 25,right = 35) == 250\n assert candidate(nums = [10, 20, 30, 40, 50],n = 5,left = 3,right = 12) == 610\n assert candidate(nums = [5, 15, 10, 20],n = 4,left = 5,right = 12) == 200\n assert candidate(nums = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],n = 12,left = 30,right = 75) == 8471\n assert candidate(nums = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 25,right = 75) == 9910\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],n = 7,left = 1,right = 28) == 588\n assert candidate(nums = [9, 7, 5, 3, 1],n = 5,left = 6,right = 16) == 155\n assert candidate(nums = [5, 6, 7, 8, 9],n = 5,left = 3,right = 7) == 48\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 1,right = 55) == 220\n assert candidate(nums = [5, 1, 7, 3, 8],n = 5,left = 3,right = 7) == 34\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],n = 10,left = 15,right = 40) == 497\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],n = 10,left = 1,right = 100) == 1210\n assert candidate(nums = [99, 100, 98, 97, 96],n = 5,left = 10,right = 20) == 2158\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],n = 15,left = 50,right = 150) == 9416\n assert candidate(nums = [42, 53, 64, 75, 86, 97, 108, 119, 130, 141],n = 10,left = 15,right = 45) == 11216\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 30,right = 70) == 9190\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],n = 10,left = 30,right = 50) == 664\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],n = 20,left = 150,right = 250) == 46005\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],n = 11,left = 20,right = 40) == 310\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],n = 10,left = 25,right = 50) == 7560\n assert candidate(nums = [100, 200, 300, 400, 500],n = 5,left = 1,right = 15) == 10500\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 10,left = 10,right = 30) == 496\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],n = 10,left = 50,right = 100) == 30000\n assert candidate(nums = [9, 8, 7, 6, 5],n = 5,left = 1,right = 15) == 245\n assert candidate(nums = [9, 18, 27, 36, 45, 54],n = 6,left = 10,right = 20) == 1260\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 15,right = 30) == 46\n assert candidate(nums = [100, 200, 300, 400, 500, 600],n = 6,left = 10,right = 30) == 16100\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],n = 10,left = 20,right = 40) == 44500\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],n = 10,left = 50,right = 75) == 364\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],n = 10,left = 30,right = 50) == 664\n assert candidate(nums = [7, 3, 8, 6, 2, 5, 4, 9, 1],n = 9,left = 20,right = 40) == 480\n assert candidate(nums = [99, 98, 97, 96, 95, 94],n = 6,left = 20,right = 30) == 1064\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],n = 20,left = 150,right = 250) == 9201\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],n = 10,left = 10,right = 30) == 5233\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],n = 15,left = 50,right = 60) == 379\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],n = 10,left = 20,right = 50) == 1036\n assert candidate(nums = [10, 20, 30, 40, 50, 60],n = 6,left = 10,right = 20) == 1400\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 10,left = 25,right = 35) == 421\n assert candidate(nums = [10, 20, 30, 40, 50],n = 5,left = 1,right = 25) == 1050\n assert candidate(nums = [34, 78, 12, 56, 90, 23, 45, 67, 89, 10],n = 10,left = 30,right = 60) == 8474\n assert candidate(nums = [10, 20, 30, 40, 50, 60],n = 6,left = 10,right = 20) == 1400\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],n = 11,left = 5,right = 20) == 95\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 10,left = 1,right = 100) == 2200\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 30,right = 40) == 2810\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],n = 10,left = 30,right = 45) == 908\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],n = 10,left = 55,right = 85) == 550\n assert candidate(nums = [50, 40, 30, 20, 10],n = 5,left = 10,right = 20) == 690\n assert candidate(nums = [9, 7, 5, 3, 1],n = 5,left = 8,right = 12) == 68\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],n = 7,left = 15,right = 25) == 179\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],n = 15,left = 100,right = 200) == 2074\n assert candidate(nums = [50, 40, 30, 20, 10],n = 5,left = 1,right = 15) == 1050\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],n = 15,left = 50,right = 100) == 2715\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 45,right = 75) == 5010\n assert candidate(nums = [9, 3, 5, 7, 2, 8],n = 6,left = 4,right = 12) == 89\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 25,right = 50) == 133\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20],n = 20,left = 50,right = 150) == 6400\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],n = 20,left = 100,right = 150) == 8103\n assert candidate(nums = [5, 15, 25, 35, 45],n = 5,left = 7,right = 14) == 610\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 20,left = 50,right = 100) == 232\n assert candidate(nums = [1, 2, 3, 4, 5],n = 5,left = 1,right = 15) == 105\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],n = 10,left = 25,right = 50) == 410\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 55,right = 75) == 550\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],n = 10,left = 5,right = 55) == 21600\n assert candidate(nums = [5, 15, 25, 35, 45],n = 5,left = 5,right = 15) == 810\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],n = 15,left = 50,right = 100) == 5098\n assert candidate(nums = [8, 6, 4, 2, 0, 8, 6, 4, 2, 0],n = 10,left = 20,right = 40) == 344\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],n = 9,left = 10,right = 30) == 291\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 25,right = 45) == 97\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],n = 12,left = 50,right = 75) == 6660\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65],n = 7,left = 15,right = 25) == 1585\n assert candidate(nums = [5, 15, 10, 20, 25],n = 5,left = 4,right = 10) == 195\n assert candidate(nums = [50, 40, 30, 20, 10, 5, 2, 1],n = 8,left = 10,right = 35) == 2000\n assert candidate(nums = [100, 100, 100, 100, 100, 100],n = 6,left = 20,right = 30) == 1100\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],n = 15,left = 50,right = 100) == 5430\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],n = 15,left = 100,right = 150) == 2074\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 5,right = 20) == 27\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],n = 12,left = 40,right = 80) == 13083\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],n = 10,left = 5,right = 15) == 1520\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],n = 20,left = 120,right = 200) == 19092\n"}, "metadata": {"canonical_parameter_names": ["nums", "n", "left", "right"], "leetcode_dataset_entry_point": "Solution().rangeSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def rangeSum(self, nums: list[int], n: int, left: int, right: int) -> int:", "container": "Solution", "callable": "rangeSum", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "n", "type": "int"}, {"name": "left", "type": "int"}, {"name": "right", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1509, "task_id": "minimum-difference-between-largest-and-smallest-value-in-three-moves", "difficulty": "Medium", "problem_description": "You are given an integer array nums.\nIn one move, you can choose one element of nums and change it to any value.\nReturn the minimum difference between the largest and smallest value of nums after performing at most three moves.\n \nExample 1:\n\nInput: nums = [5,3,2,4]\nOutput: 0\nExplanation: We can make at most 3 moves.\nIn the first move, change 2 to 3. nums becomes [5,3,3,4].\nIn the second move, change 4 to 3. nums becomes [5,3,3,3].\nIn the third move, change 5 to 3. nums becomes [3,3,3,3].\nAfter performing 3 moves, the difference between the minimum and maximum is 3 - 3 = 0.\n\nExample 2:\n\nInput: nums = [1,5,0,10,14]\nOutput: 1\nExplanation: We can make at most 3 moves.\nIn the first move, change 5 to 0. nums becomes [1,0,0,10,14].\nIn the second move, change 10 to 0. nums becomes [1,0,0,0,14].\nIn the third move, change 14 to 1. nums becomes [1,0,0,0,1].\nAfter performing 3 moves, the difference between the minimum and maximum is 1 - 0 = 1.\nIt can be shown that there is no way to make the difference 0 in 3 moves.\nExample 3:\n\nInput: nums = [3,100,20]\nOutput: 0\nExplanation: We can make at most 3 moves.\nIn the first move, change 100 to 7. nums becomes [3,7,20].\nIn the second move, change 20 to 7. nums becomes [3,7,7].\nIn the third move, change 3 to 7. nums becomes [7,7,7].\nAfter performing 3 moves, the difference between the minimum and maximum is 7 - 7 = 0.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n-109 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 100, 20]) == 0\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 6\n assert candidate(nums = [1, 1000000000, -1000000000, 0]) == 0\n assert candidate(nums = [1, 2]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 0]) == 0\n assert candidate(nums = [6, 6, 0, 1, 1, 4, 6]) == 2\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 11\n assert candidate(nums = [1, 5, 0, 10, 14]) == 1\n assert candidate(nums = [5, 3, 2, 4]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 46\n assert candidate(nums = [1, 2, 3, 1000000, 1000001, 1000002, 1000003, 1000004, 1000005, 1000006]) == 6\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1100\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101]) == 88\n assert candidate(nums = [-1000000, -900000, -800000, -700000, -600000, -500000, -400000, -300000, -200000, -100000]) == 600000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 1600\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290]) == 250\n assert candidate(nums = [1, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 999\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, -1, -10, -100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000]) == 110000000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 22\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 52\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 32\n assert candidate(nums = [5, 3, 2, 4, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 11\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 2600\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 8\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93]) == 96\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 1600\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 36\n assert candidate(nums = [-1, -1, -1, -2, -2, -2, -3, -3, -3, -4, -4, -4, -5, -5, -5, -6, -6, -6, -7, -7, -7, -8, -8, -8, -9, -9, -9, -10, -10, -10]) == 8\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91, 11, 90, 12, 89, 13, 88, 14, 87]) == 96\n assert candidate(nums = [1000, 100, 10, 1, 0, -1, -10, -100, -1000]) == 110\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 6\n assert candidate(nums = [-1000, -999, -998, -997, -996, -995, -994, -993, -992, -991, -990]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 16000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500]) == 600\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 6\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 6\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 21\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200]) == 180\n assert candidate(nums = [100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 99999\n assert candidate(nums = [-1000000, 0, 1000000, -500000, 500000, -250000, 250000, -750000, 750000, -1250000, 1250000, -1500000, 1500000, -2000000, 2000000]) == 2750000\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 3\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1000, 2000, 3000]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 26\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 80\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500]) == 2100\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == 85\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == 130\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 21\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 60\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 6000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 11\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 60\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 160\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 210\n assert candidate(nums = [1, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200]) == 1049\n assert candidate(nums = [5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1000]) == 0\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101]) == 88\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80]) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 16\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000]) == 4600\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150]) == 110\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 100, 200, 300, 400, 500]) == 199\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 23, 54, 12, 19, 33, 8, 2, 99, 101, 102, 103, 104, 105, 106]) == 94\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 60\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 46\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 100]) == 93\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986]) == 11\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014]) == 11\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, -1100, -1200, -1300, -1400, -1500, -1600, -1700, -1800, -1900, -2000]) == 1600\n assert candidate(nums = [100, 200, 300, 400, 500, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 199\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == 11\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40]) == 110\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, -14, 14]) == 25\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000]) == 0\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996]) == 999996\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500]) == 2199\n assert candidate(nums = [-1000000000, -900000000, -800000000, -700000000, -600000000, -500000000, -400000000, -300000000, -200000000, -100000000]) == 600000000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 60\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 0\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000]) == 600\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 5]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [10, 1, 2, 9, 3, 8, 4, 7, 5, 6]) == 6\n assert candidate(nums = [1000000, 1000001, 1000002, 1000003, 1000004, -1000000, -1000001, -1000002, -1000003, -1000004]) == 2000005\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 110\n assert candidate(nums = [500000000, 500000001, 500000002, 500000003, 500000004, 500000005, 500000006, 500000007, 500000008, 500000009, 500000010]) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minDifference(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minDifference", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1510, "task_id": "stone-game-iv", "difficulty": "Hard", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\nInitially, there are n stones in a pile. On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile.\nAlso, if a player cannot make a move, he/she loses the game.\nGiven a positive integer n, return true if and only if Alice wins the game otherwise return false, assuming both players play optimally.\n \nExample 1:\n\nInput: n = 1\nOutput: true\nExplanation: Alice can remove 1 stone winning the game because Bob doesn't have any moves.\nExample 2:\n\nInput: n = 2\nOutput: false\nExplanation: Alice can only remove 1 stone, after that Bob removes the last one winning the game (2 -> 1 -> 0).\n\nExample 3:\n\nInput: n = 4\nOutput: true\nExplanation: n is already a perfect square, Alice can win with one move, removing 4 stones (4 -> 0).\n\n \nConstraints:\n\n1 <= n <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 101) == True\n assert candidate(n = 3) == True\n assert candidate(n = 100) == True\n assert candidate(n = 30) == True\n assert candidate(n = 5) == False\n assert candidate(n = 4) == True\n assert candidate(n = 200) == True\n assert candidate(n = 17) == False\n assert candidate(n = 2) == False\n assert candidate(n = 20) == False\n assert candidate(n = 1) == True\n assert candidate(n = 7) == False\n assert candidate(n = 10) == False\n assert candidate(n = 25) == True\n assert candidate(n = 50) == True\n assert candidate(n = 300) == True\n assert candidate(n = 123) == True\n assert candidate(n = 64) == True\n assert candidate(n = 16) == True\n assert candidate(n = 169) == True\n assert candidate(n = 81) == True\n assert candidate(n = 150) == False\n assert candidate(n = 55) == True\n assert candidate(n = 180) == False\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().winnerSquareGame", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def winnerSquareGame(self, n: int) -> bool:", "container": "Solution", "callable": "winnerSquareGame", "parameters": [{"name": "n", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1512, "task_id": "number-of-good-pairs", "difficulty": "Easy", "problem_description": "Given an array of integers nums, return the number of good pairs.\nA pair (i, j) is called good if nums[i] == nums[j] and i < j.\n \nExample 1:\n\nInput: nums = [1,2,3,1,1,3]\nOutput: 4\nExplanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed.\n\nExample 2:\n\nInput: nums = [1,1,1,1]\nOutput: 6\nExplanation: Each pair in the array are good.\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: 0\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 6, 7, 8, 9, 5]) == 1\n assert candidate(nums = [1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 21\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3]) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [42, 42, 42, 42, 42]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 5, 6, 7, 8, 9]) == 5\n assert candidate(nums = [10, 10, 10]) == 3\n assert candidate(nums = [1, 3, 2, 3, 3, 4, 1]) == 4\n assert candidate(nums = [1, 2, 3, 1, 1, 3]) == 4\n assert candidate(nums = [1, 2, 1, 3, 2, 3, 4, 5]) == 3\n assert candidate(nums = [1, 2, 1, 2, 1, 2]) == 6\n assert candidate(nums = [10, 20, 10, 10, 30, 20, 50, 20]) == 6\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [100, 100]) == 1\n assert candidate(nums = [1, 2, 1, 3, 2, 1]) == 4\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2]) == 21\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1653\n assert candidate(nums = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9]) == 63\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == 0\n assert candidate(nums = [99, 99, 99, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 0\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6]) == 20\n assert candidate(nums = [10, 20, 20, 10, 30, 30, 30, 30]) == 8\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [100, 1, 2, 100, 2, 1, 100, 2, 1, 100]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 150\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5]) == 41\n assert candidate(nums = [1, 3, 2, 3, 2, 4, 2, 3, 4, 1, 4, 1, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == 300\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 3003\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == 50\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 30\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 66\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == 84\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 100, 99, 98, 97, 96]) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 30\n assert candidate(nums = [5, 6, 7, 5, 6, 5, 6, 7, 7]) == 9\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 300\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 190\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 15\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 45\n assert candidate(nums = [10, 20, 10, 20, 30, 10, 20, 30, 40, 50]) == 7\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 63\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9]) == 59\n assert candidate(nums = [10, 20, 10, 20, 30, 10, 30, 30]) == 7\n assert candidate(nums = [25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75]) == 84\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 435\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 2346\n assert candidate(nums = [10, 20, 30, 10, 10, 20, 30, 30, 30]) == 10\n assert candidate(nums = [99, 99, 99, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 95]) == 15\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2]) == 57\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 165\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 35\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 135\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 36\n assert candidate(nums = [7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10]) == 40\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1711\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 435\n assert candidate(nums = [10, 20, 10, 20, 10, 30, 20, 10]) == 9\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 190\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 435\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 6105\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 20, 10]) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 210\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 30\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == 0\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34]) == 435\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 33\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1980\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(nums = [7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 65\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 450\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [10, 20, 10, 20, 30, 10, 20, 30, 30]) == 9\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 83, 82, 82, 81, 81, 80, 80, 79, 79, 78, 78, 77, 77, 76, 76, 75, 75, 74, 74, 73, 73, 72, 72, 71, 71, 70, 70, 69, 69, 68, 68, 67, 67, 66, 66, 65, 65, 64, 64, 63, 63, 62, 62, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 56, 56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50]) == 50\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1]) == 105\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numIdenticalPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numIdenticalPairs(self, nums: list[int]) -> int:", "container": "Solution", "callable": "numIdenticalPairs", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1513, "task_id": "number-of-substrings-with-only-1s", "difficulty": "Medium", "problem_description": "Given a binary string s, return the number of substrings with all characters 1's. Since the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: s = \"0110111\"\nOutput: 9\nExplanation: There are 9 substring in total with only 1's characters.\n\"1\" -> 5 times.\n\"11\" -> 3 times.\n\"111\" -> 1 time.\nExample 2:\n\nInput: s = \"101\"\nOutput: 2\nExplanation: Substring \"1\" is shown 2 times in s.\n\nExample 3:\n\nInput: s = \"111111\"\nOutput: 21\nExplanation: Each substring contains only 1's characters.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1100110011\") == 9\n assert candidate(s = \"101\") == 2\n assert candidate(s = \"1001001001\") == 4\n assert candidate(s = \"1111101111\") == 25\n assert candidate(s = \"110110110110110\") == 15\n assert candidate(s = \"000\") == 0\n assert candidate(s = \"111111\") == 21\n assert candidate(s = \"0110111\") == 9\n assert candidate(s = \"0\") == 0\n assert candidate(s = \"01010101010101010101\") == 10\n assert candidate(s = \"111000111000111\") == 18\n assert candidate(s = \"1001001\") == 3\n assert candidate(s = \"111011101110111\") == 24\n assert candidate(s = \"1111111111\") == 55\n assert candidate(s = \"00000\") == 0\n assert candidate(s = \"11111111111111111111\") == 210\n assert candidate(s = \"111100001111\") == 20\n assert candidate(s = \"1\") == 1\n assert candidate(s = \"1100110011001100110011\") == 18\n assert candidate(s = \"11110000111111110000111100001111111111110000\") == 134\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111111111111111111111\") == 3240\n assert candidate(s = \"111000111000111000111000111000111000111000111000111000111000111000111000111\") == 78\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101010101010101010101\") == 41\n assert candidate(s = \"100100100100100100100100100100100100100100100100100100100100100100100100100100100\") == 27\n assert candidate(s = \"0111111111101111111111101111111111101111111111101111111111101111111111101111111111101111111111101111111111\") == 572\n assert candidate(s = \"000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"101010101010101010101010101010101010101010101010\") == 24\n assert candidate(s = \"111111111100000000000000000000000000000000000000000000000000000000000000000000000001111111111\") == 110\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numSub", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numSub(self, s: str) -> int:", "container": "Solution", "callable": "numSub", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1514, "task_id": "path-with-maximum-probability", "difficulty": "Medium", "problem_description": "You are given an undirected weighted graph of n nodes (0-indexed), represented by an edge list where edges[i] = [a, b] is an undirected edge connecting the nodes a and b with a probability of success of traversing that edge succProb[i].\nGiven two nodes start and end, find the path with the maximum probability of success to go from start to end and return its success probability.\nIf there is no path from start to end, return 0. Your answer will be accepted if it differs from the correct answer by at most 1e-5.\n \nExample 1:\n\n\nInput: n = 3, edges = [[0,1],[1,2],[0,2]], succProb = [0.5,0.5,0.2], start = 0, end = 2\nOutput: 0.25000\nExplanation: There are two paths from start to end, one having a probability of success = 0.2 and the other has 0.5 * 0.5 = 0.25.\n\nExample 2:\n\n\nInput: n = 3, edges = [[0,1],[1,2],[0,2]], succProb = [0.5,0.5,0.3], start = 0, end = 2\nOutput: 0.30000\n\nExample 3:\n\n\nInput: n = 3, edges = [[0,1]], succProb = [0.5], start = 0, end = 2\nOutput: 0.00000\nExplanation: There is no path between 0 and 2.\n\n \nConstraints:\n\n2 <= n <= 10^4\n0 <= start, end < n\nstart != end\n0 <= a, b < n\na != b\n0 <= succProb.length == edges.length <= 2*10^4\n0 <= succProb[i] <= 1\nThere is at most one edge between every two nodes.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3]],succProb = [0.1, 0.2, 0.3],start_node = 0,end_node = 3) == 0.006000000000000001\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3]],succProb = [0.1, 0.9, 0.8],start_node = 0,end_node = 3) == 0.07200000000000001\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4]],succProb = [0.5, 0.5, 0.5, 0.5],start_node = 0,end_node = 4) == 0.0625\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1],start_node = 0,end_node = 6) == 1.0000000000000004e-06\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1],start_node = 0,end_node = 7) == 0.09000000000000001\n assert candidate(n = 3,edges = [[0, 1], [1, 2], [0, 2]],succProb = [0.5, 0.5, 0.3],start_node = 0,end_node = 2) == 0.3\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5],start_node = 0,end_node = 5) == 0.0012000000000000003\n assert candidate(n = 3,edges = [[0, 1], [1, 2], [0, 2]],succProb = [0.5, 0.5, 0.2],start_node = 0,end_node = 2) == 0.25\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6],start_node = 0,end_node = 4) == 0.12\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3]],succProb = [0.1, 0.9, 0.5],start_node = 0,end_node = 3) == 0.045000000000000005\n assert candidate(n = 3,edges = [[0, 1]],succProb = [0.5],start_node = 0,end_node = 2) == 0\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3]],succProb = [0.9, 0.8, 0.7],start_node = 0,end_node = 3) == 0.504\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4]],succProb = [0.1, 0.9, 0.8, 0.2],start_node = 0,end_node = 4) == 0.014400000000000003\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [0, 3], [3, 4]],succProb = [0.9, 0.8, 0.7, 0.6],start_node = 0,end_node = 2) == 0.7200000000000001\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [3, 4]],succProb = [0.7, 0.8, 0.9],start_node = 0,end_node = 4) == 0\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4]],succProb = [0.5, 0.4, 0.3, 0.2],start_node = 0,end_node = 4) == 0.012\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],succProb = [0.01, 0.99, 0.02, 0.98, 0.03, 0.97, 0.04, 0.96, 0.05, 0.95, 0.06, 0.94, 0.07, 0.93],start_node = 0,end_node = 14) == 3.7815442046807046e-11\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],start_node = 1,end_node = 7) == 0.08000000000000002\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],start_node = 0,end_node = 11) == 0.3\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],succProb = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1],start_node = 0,end_node = 5) == 0.5\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8],start_node = 0,end_node = 7) == 0.06400000000000002\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 14]],succProb = [0.1, 0.1, 0.1, 0.2, 0.2, 0.3, 0.3, 0.4, 0.4, 0.5, 0.5, 0.6, 0.6, 0.7, 0.7],start_node = 0,end_node = 14) == 0.028000000000000004\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1],start_node = 0,end_node = 5) == 0.03024\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 6]],succProb = [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.99],start_node = 0,end_node = 6) == 0.99\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],succProb = [0.1, 0.9, 0.2, 0.8, 0.3, 0.7, 0.4, 0.6],start_node = 0,end_node = 9) == 0\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6],start_node = 0,end_node = 9) == 0.1\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [1, 4], [4, 5], [5, 6], [6, 7], [7, 4]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],start_node = 0,end_node = 6) == 0.036000000000000004\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]],succProb = [0.1, 0.1, 0.2, 0.2, 0.3, 0.3, 0.4, 0.4, 0.5, 0.5],start_node = 0,end_node = 7) == 0.015\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 2], [1, 3], [2, 4], [3, 5]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1],start_node = 0,end_node = 5) == 0.6\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],succProb = [0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05],start_node = 0,end_node = 19) == 1.907348632812502e-25\n assert candidate(n = 6,edges = [[0, 1], [0, 5], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7],start_node = 0,end_node = 4) == 0.13999999999999999\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [0, 2], [2, 3], [3, 4], [2, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1],start_node = 0,end_node = 9) == 0\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],succProb = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5],start_node = 5,end_node = 9) == 0.0625\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],succProb = [0.99, 0.98, 0.97, 0.96, 0.95, 0.94, 0.93, 0.92, 0.91],start_node = 0,end_node = 9) == 0.6281565095552946\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 0], [6, 1], [7, 2]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],start_node = 0,end_node = 6) == 0.5599999999999999\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]],succProb = [0.5, 0.4, 0.3, 0.2, 0.1, 0.9, 0.8, 0.7, 0.6, 0.5],start_node = 0,end_node = 9) == 0.5\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 6], [1, 3], [2, 4], [3, 5]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.01],start_node = 0,end_node = 6) == 0.7\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 5]],succProb = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5],start_node = 0,end_node = 5) == 0.5\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],start_node = 0,end_node = 19) == 0.1\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],start_node = 0,end_node = 9) == 0.0003628800000000001\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 5], [5, 10], [1, 6], [6, 11], [2, 7], [7, 0], [3, 8], [8, 1], [4, 9], [9, 2]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2],start_node = 0,end_node = 11) == 0.33599999999999997\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.9],start_node = 0,end_node = 9) == 0.9\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 3], [3, 5], [5, 7], [7, 9]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2],start_node = 0,end_node = 9) == 0.1\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4],start_node = 0,end_node = 14) == 0.048\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]],succProb = [0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.01, 0.02, 0.03, 0.04, 0.05],start_node = 0,end_node = 9) == 0.1\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5],start_node = 0,end_node = 9) == 0.1\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],start_node = 0,end_node = 19) == 1.000000000000001e-19\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [1, 3], [2, 4], [0, 4], [1, 5], [2, 5]],succProb = [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.9, 0.9, 0.9, 0.9, 0.9],start_node = 0,end_node = 5) == 0.7290000000000001\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [3, 5], [4, 5]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],start_node = 0,end_node = 5) == 0.108\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 7], [1, 5], [2, 6], [3, 7]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3],start_node = 0,end_node = 7) == 0.8\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],succProb = [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6],start_node = 0,end_node = 14) == 2.6127360000000006e-06\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],succProb = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5],start_node = 0,end_node = 9) == 0.001953125\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 3], [2, 5]],succProb = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3],start_node = 0,end_node = 5) == 0.21600000000000003\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [0, 14]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],start_node = 0,end_node = 14) == 0.1\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 6], [1, 3], [2, 4], [3, 5]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1],start_node = 0,end_node = 6) == 0.7\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],succProb = [0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18],start_node = 0,end_node = 14) == 2.6676557107200007e-14\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 19]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.9],start_node = 0,end_node = 19) == 0.9\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],start_node = 0,end_node = 5) == 1.0000000000000004e-05\n assert candidate(n = 10,edges = [[0, 9], [0, 8], [8, 9], [1, 7], [1, 6], [6, 7], [2, 5], [2, 4], [4, 5], [3, 0], [3, 1], [3, 2]],succProb = [0.1, 0.2, 0.15, 0.3, 0.4, 0.35, 0.5, 0.6, 0.55, 0.7, 0.8, 0.85],start_node = 3,end_node = 9) == 0.06999999999999999\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],succProb = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5],start_node = 0,end_node = 4) == 0.0625\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],succProb = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2],start_node = 0,end_node = 11) == 0.024\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],succProb = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5],start_node = 0,end_node = 19) == 6.584094720000003e-13\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]],succProb = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1],start_node = 0,end_node = 19) == 0.8\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],succProb = [0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05],start_node = 0,end_node = 19) == 1.907348632812502e-25\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],succProb = [0.01, 0.01, 0.01, 0.01, 0.01, 0.01],start_node = 0,end_node = 6) == 1.0000000000000002e-12\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 10], [10, 15]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.5, 0.3, 0.4],start_node = 0,end_node = 19) == 0.03024\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]],succProb = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.05, 0.15, 0.25, 0.35, 0.45],start_node = 0,end_node = 7) == 0.2\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],succProb = [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.99],start_node = 0,end_node = 11) == 9.900000000000002e-21\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 0]],succProb = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3],start_node = 0,end_node = 24) == 0.3\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "succProb", "start_node", "end_node"], "leetcode_dataset_entry_point": "Solution().maxProbability", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxProbability(self, n: int, edges: list[list[int]], succProb: list[float], start_node: int, end_node: int) -> float:", "container": "Solution", "callable": "maxProbability", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "succProb", "type": "list[float]"}, {"name": "start_node", "type": "int"}, {"name": "end_node", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1515, "task_id": "best-position-for-a-service-centre", "difficulty": "Hard", "problem_description": "A delivery company wants to build a new service center in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new center in a position such that the sum of the euclidean distances to all customers is minimum.\nGiven an array positions where positions[i] = [xi, yi] is the position of the ith customer on the map, return the minimum sum of the euclidean distances to all customers.\nIn other words, you need to choose the position of the service center [xcentre, ycentre] such that the following formula is minimized:\n\nAnswers within 10-5 of the actual value will be accepted.\n \nExample 1:\n\n\nInput: positions = [[0,1],[1,0],[1,2],[2,1]]\nOutput: 4.00000\nExplanation: As shown, you can see that choosing [xcentre, ycentre] = [1, 1] will make the distance to each customer = 1, the sum of all distances is 4 which is the minimum possible we can achieve.\n\nExample 2:\n\n\nInput: positions = [[1,1],[3,3]]\nOutput: 2.82843\nExplanation: The minimum possible sum of distances = sqrt(2) + sqrt(2) = 2.82843\n\n \nConstraints:\n\n1 <= positions.length <= 50\npositions[i].length == 2\n0 <= xi, yi <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(positions = [[1, 1], [1, 1], [1, 1], [1, 1]]) == 0.0\n assert candidate(positions = [[50, 50], [51, 51], [49, 49]]) == 2.8284271247461903\n assert candidate(positions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 8.485281374238571\n assert candidate(positions = [[2, 2], [2, 3], [3, 2], [3, 3]]) == 2.8284271247461903\n assert candidate(positions = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 5.65685424949238\n assert candidate(positions = [[0, 0], [0, 1], [1, 0], [1, 1]]) == 2.8284271247461903\n assert candidate(positions = [[5, 5], [5, 10], [10, 5], [10, 10]]) == 14.142135623730951\n assert candidate(positions = [[1, 1], [3, 3]]) == 2.8284271247461903\n assert candidate(positions = [[10, 10], [20, 20], [30, 30]]) == 28.284271247461902\n assert candidate(positions = [[0, 0], [100, 100], [50, 50]]) == 141.4213562373095\n assert candidate(positions = [[0, 1], [1, 0], [1, 2], [2, 1]]) == 4.0\n assert candidate(positions = [[1, 1], [1, 1], [1, 1]]) == 0.0\n assert candidate(positions = [[1, 1]]) == 0.0\n assert candidate(positions = [[0, 0], [100, 100]]) == 141.4213562373095\n assert candidate(positions = [[1, 1], [0, 0], [2, 2]]) == 2.8284271247461903\n assert candidate(positions = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 0.0\n assert candidate(positions = [[0, 0], [0, 100], [100, 0], [100, 100]]) == 282.842712474619\n assert candidate(positions = [[10, 20], [20, 30], [30, 40]]) == 28.284271247461902\n assert candidate(positions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 8.485281374238571\n assert candidate(positions = [[50, 50], [40, 40], [30, 30], [20, 20], [10, 10]]) == 84.8528137423857\n assert candidate(positions = [[2, 3], [3, 4], [4, 5], [5, 6]]) == 5.65685424949238\n assert candidate(positions = [[10, 10], [20, 20], [30, 30], [40, 40]]) == 56.568542494923804\n assert candidate(positions = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70], [10, 80], [10, 90], [10, 100]]) == 250.0\n assert candidate(positions = [[10, 20], [20, 10], [30, 40], [40, 30], [50, 50]]) == 92.03629479406317\n assert candidate(positions = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [0, 0]]) == 424.26406871192853\n assert candidate(positions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 35.35533905932737\n assert candidate(positions = [[0, 0], [100, 100], [20, 50], [80, 50], [50, 20], [50, 80], [30, 30], [70, 70], [40, 40], [60, 60]]) == 346.2741699796952\n assert candidate(positions = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [10, 90], [90, 10], [50, 50], [25, 75], [75, 25]]) == 364.54949915148427\n assert candidate(positions = [[5, 0], [0, 5], [5, 10], [10, 5], [0, 0], [10, 10]]) == 34.14213562373095\n assert candidate(positions = [[1, 99], [2, 98], [3, 97], [4, 96], [5, 95], [96, 5], [97, 4], [98, 3], [99, 2], [100, 1]]) == 668.2252698115078\n assert candidate(positions = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 65], [65, 70], [70, 75], [75, 80]]) == 395.9797974644666\n assert candidate(positions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 70.71067811865474\n assert candidate(positions = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 0.0\n assert candidate(positions = [[90, 90], [80, 80], [70, 70], [60, 60], [50, 50], [40, 40], [30, 30], [20, 20], [10, 10], [0, 0]]) == 353.5533905932738\n assert candidate(positions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25]]) == 220.61731573020282\n assert candidate(positions = [[10, 90], [90, 10], [50, 50], [10, 10], [90, 90]]) == 226.27416997969522\n assert candidate(positions = [[10, 10], [15, 25], [25, 30], [35, 40], [40, 50], [50, 60], [60, 70], [75, 85], [80, 90]]) == 270.02810340103866\n assert candidate(positions = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]]) == 84.8528137423857\n assert candidate(positions = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]) == 282.842712474619\n assert candidate(positions = [[10, 10], [20, 25], [30, 35], [40, 50], [50, 60], [60, 65], [70, 75], [80, 85], [90, 95], [100, 100]]) == 347.5091699395884\n assert candidate(positions = [[10, 10], [10, 11], [11, 10], [11, 11], [50, 50], [50, 51], [51, 50], [51, 51], [90, 90], [90, 91], [91, 90], [91, 91]]) == 455.39444406318626\n assert candidate(positions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 79.19595949289332\n assert candidate(positions = [[1, 1], [1, 99], [99, 1], [99, 99], [25, 25], [25, 75], [75, 25], [75, 75], [50, 50]]) == 418.60721446243616\n assert candidate(positions = [[25, 25], [75, 25], [25, 75], [75, 75], [50, 50], [25, 50], [50, 25], [50, 75]]) == 216.42135624263756\n assert candidate(positions = [[20, 20], [20, 30], [20, 40], [20, 50], [20, 60], [20, 70], [20, 80], [20, 90], [20, 100], [20, 10]]) == 250.0\n assert candidate(positions = [[0, 0], [0, 100], [100, 0], [100, 100], [50, 50], [25, 25], [75, 75]]) == 353.5533905932738\n assert candidate(positions = [[15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95], [5, 5], [100, 100]]) == 417.1930016070778\n assert candidate(positions = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [110, 120], [130, 140], [150, 160], [170, 180], [190, 200]]) == 707.1067811865476\n assert candidate(positions = [[1, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 10]]) == 24.108834188712063\n assert candidate(positions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 79.19595949289332\n assert candidate(positions = [[5, 5], [10, 15], [20, 25], [30, 35], [40, 45], [50, 55]]) == 123.91362113238543\n assert candidate(positions = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [10, 90], [90, 10]]) == 283.73687053280355\n assert candidate(positions = [[10, 50], [20, 40], [30, 30], [40, 20], [50, 10], [60, 20], [70, 30], [80, 40], [90, 50]]) == 239.52812655611027\n assert candidate(positions = [[1, 99], [50, 50], [99, 1], [99, 99], [1, 1], [0, 0]]) == 347.8965372098106\n assert candidate(positions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 70.71067811865474\n assert candidate(positions = [[50, 0], [50, 100], [0, 50], [100, 50], [25, 25], [25, 75], [75, 25], [75, 75], [10, 10], [90, 90], [10, 90], [90, 10]]) == 567.6955262170047\n assert candidate(positions = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]]) == 251.24689052802228\n assert candidate(positions = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35]]) == 84.8528137423857\n assert candidate(positions = [[2, 3], [5, 6], [8, 9], [12, 15], [16, 18], [20, 21], [25, 26], [30, 33], [35, 36], [40, 41], [45, 46], [50, 51], [55, 56], [60, 61], [65, 66]]) == 369.09298276151657\n assert candidate(positions = [[5, 5], [5, 10], [5, 15], [10, 5], [10, 10], [10, 15], [15, 5], [15, 10], [15, 15], [20, 20], [20, 30], [30, 20], [30, 30]]) == 129.78753195123062\n assert candidate(positions = [[0, 5], [0, 10], [0, 15], [0, 20], [0, 25], [0, 30], [0, 35], [0, 40], [0, 45], [0, 50]]) == 125.0\n assert candidate(positions = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 42.42640687119285\n assert candidate(positions = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]]) == 226.27416997969522\n assert candidate(positions = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 90], [90, 80], [80, 70], [70, 60], [60, 50], [50, 40], [40, 30], [30, 20], [20, 10]]) == 594.0883170846846\n assert candidate(positions = [[0, 0], [0, 100], [100, 0], [100, 100], [50, 50], [25, 25], [75, 75], [25, 75], [75, 25]]) == 424.26406871192853\n assert candidate(positions = [[1, 99], [99, 1], [49, 50], [50, 49], [50, 50], [25, 25], [75, 75]]) == 211.23672778921815\n assert candidate(positions = [[25, 25], [25, 75], [75, 25], [75, 75], [50, 50]]) == 141.4213562373095\n assert candidate(positions = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50], [55, 55], [60, 60], [65, 65], [70, 70], [75, 75], [80, 80], [85, 85], [90, 90], [95, 95], [100, 100]]) == 707.1067811865476\n assert candidate(positions = [[10, 5], [20, 30], [50, 20], [30, 10], [70, 60], [80, 90]]) == 207.8396049492494\n assert candidate(positions = [[10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10]]) == 282.842712474619\n assert candidate(positions = [[0, 0], [0, 100], [100, 0], [100, 100], [50, 50], [25, 25], [75, 75], [25, 75], [75, 25], [50, 25]]) == 449.2640687173813\n assert candidate(positions = [[0, 0], [100, 100], [0, 100], [100, 0], [50, 50], [25, 25], [75, 75], [25, 75], [75, 25], [40, 40], [60, 60], [60, 40], [40, 60]]) == 480.83261120685233\n assert candidate(positions = [[10, 10], [90, 90], [10, 90], [90, 10], [50, 50], [25, 25], [75, 75], [30, 30], [70, 70], [40, 40], [60, 60]]) == 381.8376618407357\n assert candidate(positions = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [10, 50], [50, 10], [25, 25], [35, 35], [45, 45]]) == 176.7766958145084\n assert candidate(positions = [[10, 30], [20, 20], [30, 10], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]) == 287.4326185352413\n assert candidate(positions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 35.35533905932737\n assert candidate(positions = [[10, 50], [20, 40], [30, 30], [40, 20], [50, 10], [60, 20], [70, 30], [80, 40], [90, 50]]) == 239.52812655611027\n assert candidate(positions = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20]]) == 90.50966799187809\n assert candidate(positions = [[1, 1], [1, 99], [99, 1], [99, 99], [50, 50], [20, 20], [80, 80], [30, 30], [70, 70], [40, 40], [60, 60]]) == 446.89148570989806\n assert candidate(positions = [[0, 0], [100, 0], [50, 50], [0, 100], [100, 100], [25, 75], [75, 25]]) == 353.5533905932738\n assert candidate(positions = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6], [6, 4], [6, 5], [6, 6]]) == 40.91242019857078\n assert candidate(positions = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [0, 0], [100, 100]]) == 424.26406871192853\n assert candidate(positions = [[10, 20], [20, 10], [30, 40], [40, 30], [50, 10], [10, 50], [30, 20], [20, 30], [40, 20], [30, 10]]) == 160.8040760315738\n assert candidate(positions = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == 169.7056274847714\n assert candidate(positions = [[0, 0], [100, 100], [50, 50], [30, 70], [70, 30], [20, 20], [80, 80]]) == 282.842712474619\n assert candidate(positions = [[10, 50], [20, 50], [30, 50], [40, 50], [50, 50], [60, 50], [70, 50], [80, 50], [90, 50]]) == 200.0\n assert candidate(positions = [[20, 20], [40, 40], [60, 60], [80, 80], [10, 10], [30, 30], [50, 50], [70, 70], [90, 90]]) == 282.842712474619\n assert candidate(positions = [[5, 0], [10, 0], [15, 0], [20, 0], [25, 0], [30, 0], [35, 0], [40, 0], [45, 0], [50, 0]]) == 125.0\n assert candidate(positions = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50]]) == 176.7766952966369\n assert candidate(positions = [[20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [30, 30], [31, 31], [32, 32], [33, 33], [34, 34]]) == 70.71067811865476\n assert candidate(positions = [[25, 25], [50, 50], [75, 75], [25, 75], [75, 25], [50, 25], [50, 75], [25, 50], [75, 50]]) == 241.4213562373095\n assert candidate(positions = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 36.909588067414894\n assert candidate(positions = [[0, 0], [50, 0], [0, 50], [50, 50], [25, 25], [10, 10], [40, 40], [30, 30], [20, 20], [15, 15]]) == 212.13203493359106\n assert candidate(positions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30], [31, 32], [33, 34], [35, 36], [37, 38], [39, 40]]) == 282.842712474619\n assert candidate(positions = [[1, 1], [1, 99], [99, 1], [99, 99]]) == 277.18585822512665\n assert candidate(positions = [[0, 0], [25, 25], [50, 50], [75, 75], [100, 100], [0, 100], [100, 0], [50, 0], [0, 50], [100, 50], [50, 100]]) == 553.5533905932738\n assert candidate(positions = [[1, 1], [10, 1], [1, 10], [10, 10], [5, 5], [2, 2], [8, 8], [3, 3], [7, 7], [4, 4], [6, 6]]) == 42.504733973998164\n assert candidate(positions = [[10, 10], [10, 10], [10, 10], [90, 90], [90, 90], [90, 90], [50, 50], [50, 50], [50, 50], [50, 50]]) == 339.4112549695428\n assert candidate(positions = [[5, 10], [10, 5], [15, 10], [10, 15], [5, 20], [20, 5], [25, 10], [10, 25], [15, 20], [20, 15]]) == 84.7585594020777\n assert candidate(positions = [[1, 1], [2, 3], [3, 1], [4, 5], [5, 3], [6, 7], [7, 5], [8, 9], [9, 7], [10, 11]]) == 38.13182008152135\n assert candidate(positions = [[90, 10], [10, 90], [50, 50], [40, 60], [60, 40], [20, 80], [80, 20]]) == 226.27416997969522\n assert candidate(positions = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35]]) == 84.8528137423857\n assert candidate(positions = [[10, 50], [50, 10], [50, 50], [90, 50], [50, 90], [5, 5], [95, 95], [5, 95], [95, 5], [50, 25]]) == 439.5584412326267\n assert candidate(positions = [[0, 0], [100, 100], [50, 50], [75, 25], [25, 75], [0, 100], [100, 0], [50, 100], [100, 50], [50, 0]]) == 503.55339096524574\n"}, "metadata": {"canonical_parameter_names": ["positions"], "leetcode_dataset_entry_point": "Solution().getMinDistSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getMinDistSum(self, positions: list[list[int]]) -> float:", "container": "Solution", "callable": "getMinDistSum", "parameters": [{"name": "positions", "type": "list[list[int]]"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1518, "task_id": "water-bottles", "difficulty": "Easy", "problem_description": "There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the market with one full water bottle.\nThe operation of drinking a full water bottle turns it into an empty bottle.\nGiven the two integers numBottles and numExchange, return the maximum number of water bottles you can drink.\n \nExample 1:\n\n\nInput: numBottles = 9, numExchange = 3\nOutput: 13\nExplanation: You can exchange 3 empty bottles to get 1 full water bottle.\nNumber of water bottles you can drink: 9 + 3 + 1 = 13.\n\nExample 2:\n\n\nInput: numBottles = 15, numExchange = 4\nOutput: 19\nExplanation: You can exchange 4 empty bottles to get 1 full water bottle. \nNumber of water bottles you can drink: 15 + 3 + 1 = 19.\n\n \nConstraints:\n\n1 <= numBottles <= 100\n2 <= numExchange <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(numBottles = 10,numExchange = 2) == 19\n assert candidate(numBottles = 20,numExchange = 6) == 23\n assert candidate(numBottles = 100,numExchange = 10) == 111\n assert candidate(numBottles = 5,numExchange = 5) == 6\n assert candidate(numBottles = 15,numExchange = 4) == 19\n assert candidate(numBottles = 100,numExchange = 2) == 199\n assert candidate(numBottles = 9,numExchange = 3) == 13\n assert candidate(numBottles = 99,numExchange = 2) == 197\n assert candidate(numBottles = 98,numExchange = 14) == 105\n assert candidate(numBottles = 75,numExchange = 9) == 84\n assert candidate(numBottles = 80,numExchange = 10) == 88\n assert candidate(numBottles = 60,numExchange = 10) == 66\n assert candidate(numBottles = 30,numExchange = 15) == 32\n assert candidate(numBottles = 60,numExchange = 8) == 68\n assert candidate(numBottles = 85,numExchange = 3) == 127\n assert candidate(numBottles = 33,numExchange = 33) == 34\n assert candidate(numBottles = 80,numExchange = 7) == 93\n assert candidate(numBottles = 50,numExchange = 5) == 62\n assert candidate(numBottles = 77,numExchange = 14) == 82\n assert candidate(numBottles = 55,numExchange = 9) == 61\n assert candidate(numBottles = 80,numExchange = 12) == 87\n assert candidate(numBottles = 45,numExchange = 12) == 49\n assert candidate(numBottles = 72,numExchange = 8) == 82\n assert candidate(numBottles = 100,numExchange = 100) == 101\n assert candidate(numBottles = 25,numExchange = 11) == 27\n assert candidate(numBottles = 55,numExchange = 13) == 59\n assert candidate(numBottles = 100,numExchange = 9) == 112\n assert candidate(numBottles = 80,numExchange = 5) == 99\n assert candidate(numBottles = 25,numExchange = 3) == 37\n assert candidate(numBottles = 65,numExchange = 9) == 73\n assert candidate(numBottles = 5,numExchange = 6) == 5\n assert candidate(numBottles = 60,numExchange = 4) == 79\n assert candidate(numBottles = 45,numExchange = 9) == 50\n assert candidate(numBottles = 30,numExchange = 7) == 34\n assert candidate(numBottles = 75,numExchange = 8) == 85\n assert candidate(numBottles = 50,numExchange = 3) == 74\n assert candidate(numBottles = 55,numExchange = 11) == 60\n assert candidate(numBottles = 25,numExchange = 6) == 29\n assert candidate(numBottles = 1,numExchange = 2) == 1\n assert candidate(numBottles = 70,numExchange = 8) == 79\n assert candidate(numBottles = 30,numExchange = 4) == 39\n assert candidate(numBottles = 45,numExchange = 4) == 59\n assert candidate(numBottles = 64,numExchange = 8) == 73\n assert candidate(numBottles = 40,numExchange = 8) == 45\n assert candidate(numBottles = 50,numExchange = 7) == 58\n assert candidate(numBottles = 75,numExchange = 6) == 89\n assert candidate(numBottles = 99,numExchange = 9) == 111\n assert candidate(numBottles = 70,numExchange = 9) == 78\n assert candidate(numBottles = 99,numExchange = 7) == 115\n assert candidate(numBottles = 85,numExchange = 5) == 106\n assert candidate(numBottles = 81,numExchange = 9) == 91\n assert candidate(numBottles = 99,numExchange = 10) == 109\n assert candidate(numBottles = 88,numExchange = 11) == 96\n assert candidate(numBottles = 60,numExchange = 11) == 65\n assert candidate(numBottles = 60,numExchange = 12) == 65\n assert candidate(numBottles = 77,numExchange = 13) == 83\n assert candidate(numBottles = 45,numExchange = 7) == 52\n assert candidate(numBottles = 99,numExchange = 3) == 148\n assert candidate(numBottles = 65,numExchange = 15) == 69\n assert candidate(numBottles = 33,numExchange = 11) == 36\n assert candidate(numBottles = 45,numExchange = 3) == 67\n assert candidate(numBottles = 40,numExchange = 13) == 43\n assert candidate(numBottles = 99,numExchange = 5) == 123\n assert candidate(numBottles = 100,numExchange = 11) == 109\n assert candidate(numBottles = 90,numExchange = 6) == 107\n assert candidate(numBottles = 75,numExchange = 12) == 81\n assert candidate(numBottles = 30,numExchange = 6) == 35\n assert candidate(numBottles = 100,numExchange = 5) == 124\n assert candidate(numBottles = 40,numExchange = 15) == 42\n assert candidate(numBottles = 65,numExchange = 13) == 70\n assert candidate(numBottles = 90,numExchange = 4) == 119\n assert candidate(numBottles = 50,numExchange = 10) == 55\n assert candidate(numBottles = 80,numExchange = 4) == 106\n"}, "metadata": {"canonical_parameter_names": ["numBottles", "numExchange"], "leetcode_dataset_entry_point": "Solution().numWaterBottles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numWaterBottles(self, numBottles: int, numExchange: int) -> int:", "container": "Solution", "callable": "numWaterBottles", "parameters": [{"name": "numBottles", "type": "int"}, {"name": "numExchange", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1519, "task_id": "number-of-nodes-in-the-sub-tree-with-the-same-label", "difficulty": "Medium", "problem_description": "You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e. The node with the number i has the label labels[i]).\nThe edges array is given on the form edges[i] = [ai, bi], which means there is an edge between nodes ai and bi in the tree.\nReturn an array of size n where ans[i] is the number of nodes in the subtree of the ith node which have the same label as node i.\nA subtree of a tree T is the tree consisting of a node in T and all of its descendant nodes.\n \nExample 1:\n\n\nInput: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], labels = \"abaedcd\"\nOutput: [2,1,1,1,1,1,1]\nExplanation: Node 0 has label 'a' and its sub-tree has node 2 with label 'a' as well, thus the answer is 2. Notice that any node is part of its sub-tree.\nNode 1 has a label 'b'. The sub-tree of node 1 contains nodes 1,4 and 5, as nodes 4 and 5 have different labels than node 1, the answer is just 1 (the node itself).\n\nExample 2:\n\n\nInput: n = 4, edges = [[0,1],[1,2],[0,3]], labels = \"bbbb\"\nOutput: [4,2,1,1]\nExplanation: The sub-tree of node 2 contains only node 2, so the answer is 1.\nThe sub-tree of node 3 contains only node 3, so the answer is 1.\nThe sub-tree of node 1 contains nodes 1 and 2, both have label 'b', thus the answer is 2.\nThe sub-tree of node 0 contains nodes 0, 1, 2 and 3, all with label 'b', thus the answer is 4.\n\nExample 3:\n\n\nInput: n = 5, edges = [[0,1],[0,2],[1,3],[0,4]], labels = \"aabab\"\nOutput: [3,2,1,1,1]\n\n \nConstraints:\n\n1 <= n <= 105\nedges.length == n - 1\nedges[i].length == 2\n0 <= ai, bi < n\nai != bi\nlabels.length == n\nlabels is consisting of only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [0, 3]],labels = \"bbbb\") == [4, 2, 1, 1]\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],labels = \"cbabaa\") == [1, 2, 2, 1, 1, 1]\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],labels = \"cbabac\") == [2, 2, 1, 1, 1, 1]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],labels = \"aadbdbdbaa\") == [4, 3, 2, 2, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 3,edges = [[0, 1], [0, 2]],labels = \"aaa\") == [3, 1, 1]\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [0, 4]],labels = \"aabab\") == [3, 2, 1, 1, 1]\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 4], [1, 5], [2, 3], [2, 6]],labels = \"abaedcd\") == [2, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],labels = \"aebabacd\") == [3, 1, 2, 1, 1, 1, 1, 1]\n assert candidate(n = 1,edges = [],labels = \"a\") == [1]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],labels = \"abacabadabacaba\") == [8, 2, 4, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]],labels = \"aabbccddeeffgghhiijj\") == [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 26,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [8, 20], [9, 21], [10, 22], [11, 23], [12, 24], [13, 25]],labels = \"abcdefghijklmnopqrstuvwxyz\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [5, 16], [5, 17], [6, 18], [6, 19], [7, 20], [7, 21], [8, 22], [8, 23], [9, 24], [9, 25], [10, 26], [10, 27], [11, 28], [11, 29]],labels = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19], [12, 20], [12, 21], [13, 22], [13, 23], [14, 24], [14, 25], [15, 26], [15, 27], [16, 28], [16, 29]],labels = \"ababababababababababababababababab\") == [15, 8, 7, 5, 3, 4, 4, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]],labels = \"abcabcabcabcabcabcabcabcabcabc\") == [7, 6, 4, 3, 3, 2, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],labels = \"abcdefghij\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 100,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [7, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [10, 26], [11, 27], [11, 28], [12, 29], [12, 30], [13, 31], [13, 32], [14, 33], [14, 34], [15, 35], [15, 36], [16, 37], [16, 38], [17, 39], [17, 40], [18, 41], [18, 42], [19, 43], [19, 44], [20, 45], [20, 46], [21, 47], [21, 48], [22, 49], [22, 50], [23, 51], [23, 52], [24, 53], [24, 54], [25, 55], [25, 56], [26, 57], [26, 58], [27, 59], [27, 60], [28, 61], [28, 62], [29, 63], [29, 64], [30, 65], [30, 66], [31, 67], [31, 68], [32, 69], [32, 70], [33, 71], [33, 72], [34, 73], [34, 74], [35, 75], [35, 76], [36, 77], [36, 78], [37, 79], [37, 80], [38, 81], [38, 82], [39, 83], [39, 84], [40, 85], [40, 86], [41, 87], [41, 88], [42, 89], [42, 90], [43, 91], [43, 92], [44, 93], [44, 94], [45, 95], [45, 96], [46, 97], [46, 98], [47, 99]],labels = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == [4, 2, 2, 3, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 40,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30], [15, 31], [15, 32], [16, 33], [16, 34], [17, 35], [17, 36], [18, 37], [18, 38], [19, 39]],labels = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh\") == [2, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 21,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [8, 20]],labels = \"ababababababababababa\") == [11, 5, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27], [13, 28], [13, 29]],labels = \"bababbababababababababababababab\") == [16, 7, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]],labels = \"bbbbbbbbbbbbbbbbbbbb\") == [20, 7, 7, 5, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [8, 20], [9, 21], [10, 22], [11, 23], [12, 24], [13, 25], [14, 26], [15, 27], [16, 28], [17, 29]],labels = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == [2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],labels = \"abcdefghij\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 100,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [4, 40], [4, 41], [4, 42], [4, 43], [4, 44], [4, 45], [4, 46], [4, 47], [4, 48], [4, 49], [5, 50], [5, 51], [5, 52], [5, 53], [5, 54], [5, 55], [5, 56], [5, 57], [5, 58], [5, 59], [6, 60], [6, 61], [6, 62], [6, 63], [6, 64], [6, 65], [6, 66], [6, 67], [6, 68], [6, 69], [7, 70], [7, 71], [7, 72], [7, 73], [7, 74], [7, 75], [7, 76], [7, 77], [7, 78], [7, 79], [8, 80], [8, 81], [8, 82], [8, 83], [8, 84], [8, 85], [8, 86], [8, 87], [8, 88], [8, 89], [9, 90], [9, 91], [9, 92], [9, 93], [9, 94], [9, 95], [9, 96], [9, 97], [9, 98], [9, 99]],labels = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == [4, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14]],labels = \"bababbababababa\") == [8, 2, 3, 3, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 40,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [1, 7], [2, 8], [2, 9], [2, 10], [3, 11], [3, 12], [3, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 18], [5, 19], [6, 20], [6, 21], [6, 22], [7, 23], [7, 24], [8, 25], [8, 26], [8, 27], [9, 28], [9, 29], [10, 30], [10, 31], [11, 32], [11, 33], [11, 34], [12, 35], [12, 36], [13, 37], [13, 38], [13, 39]],labels = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == [40, 11, 11, 12, 5, 3, 4, 3, 4, 3, 3, 4, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [10, 22], [10, 23], [11, 24]],labels = \"abcdefghijklmnopqrstuvwxyzabcde\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29]],labels = \"abcdefghijklmnopqrstuvwxyzabcde\") == [2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [7, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [10, 26], [11, 27], [11, 28], [12, 29]],labels = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == [2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14]],labels = \"abcabcabcabcabc\") == [5, 4, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [3, 8], [4, 9]],labels = \"aaaaaaaaaa\") == [10, 3, 2, 2, 2, 1, 1, 1, 1, 1]\n assert candidate(n = 50,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [9, 22], [10, 23], [10, 24], [11, 25], [11, 26], [12, 27], [12, 28], [13, 29], [13, 30], [14, 31], [14, 32], [15, 33], [15, 34], [16, 35], [16, 36], [17, 37], [17, 38], [18, 39], [18, 40], [19, 41], [19, 42], [20, 43], [20, 44], [21, 45], [21, 46], [22, 47], [22, 48], [23, 49]],labels = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 26,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25]],labels = \"abcdefghijklmnopqrstuvwxyz\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 26,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]],labels = \"abcdefghijklmnopqrstuvwxyz\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 100,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [9, 22], [10, 23], [10, 24], [11, 25], [11, 26], [12, 27], [12, 28], [13, 29], [13, 30], [14, 31], [14, 32], [15, 33], [15, 34], [16, 35], [16, 36], [17, 37], [17, 38], [18, 39], [18, 40], [19, 41], [19, 42], [20, 43], [20, 44], [21, 45], [21, 46], [22, 47], [22, 48], [23, 49], [23, 50], [24, 51], [24, 52], [25, 53], [25, 54], [26, 55], [26, 56], [27, 57], [27, 58], [28, 59], [28, 60], [29, 61], [29, 62], [30, 63], [30, 64], [31, 65], [31, 66], [32, 67], [32, 68], [33, 69], [33, 70], [34, 71], [34, 72], [35, 73], [35, 74], [36, 75], [36, 76], [37, 77], [37, 78], [38, 79], [38, 80], [39, 81], [39, 82], [40, 83], [40, 84], [41, 85], [41, 86], [42, 87], [42, 88], [43, 89], [43, 90], [44, 91], [44, 92], [45, 93], [45, 94], [46, 95], [46, 96], [47, 97], [47, 98], [48, 99]],labels = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == [50, 9, 16, 3, 8, 5, 8, 3, 8, 5, 4, 1, 4, 3, 4, 2, 4, 3, 4, 1, 4, 3, 3, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 27,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26]],labels = \"abcdefghijklmnopqrstuvwxyzabcdef\") == [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 16,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15]],labels = \"aabbccddeeffgghh\") == [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19]],labels = \"aaaaaaaaaabbbbbbbbbb\") == [10, 6, 3, 3, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 40,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [5, 16], [5, 17], [5, 18], [6, 19], [6, 20], [6, 21], [7, 22], [7, 23], [7, 24], [8, 25], [8, 26], [8, 27], [9, 28], [9, 29], [9, 30], [10, 31], [10, 32], [10, 33], [11, 34], [11, 35], [11, 36], [12, 37], [12, 38], [12, 39]],labels = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == [40, 13, 13, 13, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]],labels = \"abababababababababab\") == [10, 4, 4, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29]],labels = \"cccccccccccccccccccccccccccccc\") == [30, 15, 14, 7, 7, 7, 6, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]],labels = \"aaaaaaaaaaaaaaaaaaaa\") == [20, 7, 7, 5, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 18,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [8, 17]],labels = \"abcdefghijklmnopqr\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 27,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26]],labels = \"abcdefghijklmnopqrstuvwxyzabc\") == [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "labels"], "leetcode_dataset_entry_point": "Solution().countSubTrees", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countSubTrees(self, n: int, edges: list[list[int]], labels: str) -> list[int]:", "container": "Solution", "callable": "countSubTrees", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "labels", "type": "str"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1520, "task_id": "maximum-number-of-non-overlapping-substrings", "difficulty": "Hard", "problem_description": "Given a string s of lowercase letters, you need to find the maximum number of non-empty substrings of s that meet the following conditions:\n\nThe substrings do not overlap, that is for any two substrings s[i..j] and s[x..y], either j < x or i > y is true.\nA substring that contains a certain character c must also contain all occurrences of c.\n\nFind the maximum number of substrings that meet the above conditions. If there are multiple solutions with the same number of substrings, return the one with minimum total length. It can be shown that there exists a unique solution of minimum total length.\nNotice that you can return the substrings in any order.\n \nExample 1:\n\nInput: s = \"adefaddaccc\"\nOutput: [\"e\",\"f\",\"ccc\"]\nExplanation: The following are all the possible substrings that meet the conditions:\n[\n  \"adefaddaccc\"\n  \"adefadda\",\n  \"ef\",\n  \"e\",\n \"f\",\n  \"ccc\",\n]\nIf we choose the first string, we cannot choose anything else and we'd get only 1. If we choose \"adefadda\", we are left with \"ccc\" which is the only one that doesn't overlap, thus obtaining 2 substrings. Notice also, that it's not optimal to choose \"ef\" since it can be split into two. Therefore, the optimal way is to choose [\"e\",\"f\",\"ccc\"] which gives us 3 substrings. No other solution of the same number of substrings exist.\n\nExample 2:\n\nInput: s = \"abbaccd\"\nOutput: [\"d\",\"bb\",\"cc\"]\nExplanation: Notice that while the set of substrings [\"d\",\"abba\",\"cc\"] also has length 3, it's considered incorrect since it has larger total length.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zazbzczdzezfzgzhzi\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\n assert candidate(s = \"aabbccaaaabbbbcccc\") == ['aabbccaaaabbbbcccc']\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']\n assert candidate(s = \"abcdcba\") == ['d']\n assert candidate(s = \"aaaabaaaabaaaabaaaabaaaa\") == ['aaaabaaaabaaaabaaaabaaaa']\n assert candidate(s = \"abababab\") == ['abababab']\n assert candidate(s = \"aaaaa\") == ['aaaaa']\n assert candidate(s = \"zzzzzzz\") == ['zzzzzzz']\n assert candidate(s = \"abcdaabcdabdcabc\") == ['abcdaabcdabdcabc']\n assert candidate(s = \"abcabcabc\") == ['abcabcabc']\n assert candidate(s = \"adefaddaccc\") == ['e', 'f', 'ccc']\n assert candidate(s = \"abcde\") == ['a', 'b', 'c', 'd', 'e']\n assert candidate(s = \"aaa\") == ['aaa']\n assert candidate(s = \"abcdabcdeabcd\") == ['e']\n assert candidate(s = \"xyz\") == ['x', 'y', 'z']\n assert candidate(s = \"ababababa\") == ['ababababa']\n assert candidate(s = \"xyzxyzxyz\") == ['xyzxyzxyz']\n assert candidate(s = \"mnopqrstuvmnopqrstuvmnopqrstuv\") == ['mnopqrstuvmnopqrstuvmnopqrstuv']\n assert candidate(s = \"zzzzzzzzzz\") == ['zzzzzzzzzz']\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']\n assert candidate(s = \"cacaca\") == ['cacaca']\n assert candidate(s = \"abbaccd\") == ['bb', 'cc', 'd']\n assert candidate(s = \"zzzzyzxyz\") == ['x']\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz']\n assert candidate(s = \"abcdefg\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g']\n assert candidate(s = \"aaaaaaaaaaabbbbbbbbbbccccccccccdddddddddeeeeeeeeeeffffffffffgggggggggg\") == ['aaaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc', 'ddddddddd', 'eeeeeeeeee', 'ffffffffff', 'gggggggggg']\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == ['abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc']\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == ['abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc']\n assert candidate(s = \"aaaabbbbccccaaaabbbbccccaaaabbbbccccaaaabbbbccccaaaabbbbcccc\") == ['aaaabbbbccccaaaabbbbccccaaaabbbbccccaaaabbbbccccaaaabbbbcccc']\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == ['abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd']\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == ['abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc']\n assert candidate(s = \"zzzzzyyyyyxxxxwwwwvvvuuutttsssrqqppoonnnmmlkkjjiihhggffeedcba\") == ['zzzzz', 'yyyyy', 'xxxx', 'wwww', 'vvv', 'uuu', 'ttt', 'sss', 'r', 'qq', 'pp', 'oo', 'nnn', 'mm', 'l', 'kk', 'jj', 'ii', 'hh', 'gg', 'ff', 'ee', 'd', 'c', 'b', 'a']\n assert candidate(s = \"mnopqrstuvwxyzyxwvutsrqponmlkjihgfedcbamnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == ['mnopqrstuvwxyzyxwvutsrqponmlkjihgfedcbamnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba']\n assert candidate(s = \"abracadabraacadabra\") == ['abracadabraacadabra']\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == ['abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz']\n assert candidate(s = \"abacabadabcabaabacabadabcaba\") == ['abacabadabcabaabacabadabcaba']\n assert candidate(s = \"abacabadabcabaabacabadabcabaabacabadabcabaabacabadabcabaabacabadabcabaabacabadabcaba\") == ['abacabadabcabaabacabadabcabaabacabadabcabaabacabadabcabaabacabadabcabaabacabadabcaba']\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\") == ['aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb']\n assert candidate(s = \"mnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuv\") == ['mnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuv']\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababab\") == ['abababababababababababababababababababababababababababababababababababababababababababababababab']\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == ['abcabcabcabcabcabcabcabc']\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == ['zz']\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == ['abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz']\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\") == ['abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef']\n assert candidate(s = \"aababbabacabcabcadabcdeabcdeafaghafaiabakabalacamadanaeafaagaagaa\") == ['h', 'i', 'k', 'l', 'm', 'n']\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == ['xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz']\n assert candidate(s = \"aabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeff\") == ['aabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeff']\n assert candidate(s = \"aaaaaabbbbbccccdddddeeeee\") == ['aaaaaa', 'bbbbb', 'cccc', 'ddddd', 'eeeee']\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeffffffffgggggggghhhhhhhhiiiiiiiiijjjjjjjjkkkkkkkkkllllllllmmmmmmmmnnnnnnnnooooooooppppppppqqqqqqqqrrrrrrrrssssssssttttttttuuuuuuuuvvvvvvvvwwwwwwwwwxxxxxxxxxyyyyyyyyyzzzzzzzzz\") == ['aaaaaaaaaa', 'bbbbbbbb', 'cccccccc', 'dddddddd', 'eeeeeeee', 'ffffffff', 'gggggggg', 'hhhhhhhh', 'iiiiiiiii', 'jjjjjjjj', 'kkkkkkkkk', 'llllllll', 'mmmmmmmm', 'nnnnnnnn', 'oooooooo', 'pppppppp', 'qqqqqqqq', 'rrrrrrrr', 'ssssssss', 'tttttttt', 'uuuuuuuu', 'vvvvvvvv', 'wwwwwwwww', 'xxxxxxxxx', 'yyyyyyyyy', 'zzzzzzzzz']\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\") == ['aa']\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == ['xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz']\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == ['abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd']\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabad\") == ['abacabadabacabadabacabadabacabadabacabadabacabad']\n assert candidate(s = \"zzzzzyyyyyxxxxwwwwvvvvuuuuttttssssrrrrqqqqpppplllloooonnnnmmmm\") == ['zzzzz', 'yyyyy', 'xxxx', 'wwww', 'vvvv', 'uuuu', 'tttt', 'ssss', 'rrrr', 'qqqq', 'pppp', 'llll', 'oooo', 'nnnn', 'mmmm']\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxNumOfSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxNumOfSubstrings(self, s: str) -> list[str]:", "container": "Solution", "callable": "maxNumOfSubstrings", "parameters": [{"name": "s", "type": "str"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1521, "task_id": "find-a-value-of-a-mysterious-function-closest-to-target", "difficulty": "Hard", "problem_description": "\nWinston was given the above mysterious function func. He has an integer array arr and an integer target and he wants to find the values l and r that make the value |func(arr, l, r) - target| minimum possible.\nReturn the minimum possible value of |func(arr, l, r) - target|.\nNotice that func should be called with the values l and r where 0 <= l, r < arr.length.\n \nExample 1:\n\nInput: arr = [9,12,3,7,15], target = 5\nOutput: 2\nExplanation: Calling func with all the pairs of [l,r] = [[0,0],[1,1],[2,2],[3,3],[4,4],[0,1],[1,2],[2,3],[3,4],[0,2],[1,3],[2,4],[0,3],[1,4],[0,4]], Winston got the following results [9,12,3,7,15,8,0,3,7,0,0,3,0,0,0]. The value closest to 5 is 7 and 3, thus the minimum difference is 2.\n\nExample 2:\n\nInput: arr = [1000000,1000000,1000000], target = 1\nOutput: 999999\nExplanation: Winston called the func with all possible values of [l,r] and he always got 1000000, thus the min difference is 999999.\n\nExample 3:\n\nInput: arr = [1,2,4,8,16], target = 0\nOutput: 0\n\n \nConstraints:\n\n1 <= arr.length <= 105\n1 <= arr[i] <= 106\n0 <= target <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [7, 7, 7, 7, 7, 7],target = 8) == 1\n assert candidate(arr = [1000000],target = 1000000) == 0\n assert candidate(arr = [2, 4, 6, 8, 10],target = 7) == 1\n assert candidate(arr = [5, 5, 5, 5, 5],target = 5) == 0\n assert candidate(arr = [1, 1, 1, 1, 1],target = 2) == 1\n assert candidate(arr = [1, 2, 4, 8, 16],target = 0) == 0\n assert candidate(arr = [10, 20, 30, 40, 50],target = 25) == 5\n assert candidate(arr = [9, 12, 3, 7, 15],target = 5) == 2\n assert candidate(arr = [5, 5, 5, 5, 5],target = 3) == 2\n assert candidate(arr = [3, 6, 9, 12, 15],target = 13) == 1\n assert candidate(arr = [1000000, 1000000, 1000000],target = 1) == 999999\n assert candidate(arr = [2, 4, 6, 8, 10],target = 5) == 1\n assert candidate(arr = [1, 3, 5, 7, 9],target = 6) == 1\n assert candidate(arr = [10, 20, 30, 40, 50],target = 0) == 0\n assert candidate(arr = [7, 14, 21, 28, 35],target = 20) == 0\n assert candidate(arr = [3, 6, 9, 12, 15],target = 7) == 1\n assert candidate(arr = [1, 1, 1, 1, 1],target = 0) == 1\n assert candidate(arr = [10, 20, 30, 40, 50],target = 15) == 5\n assert candidate(arr = [100, 200, 300, 400, 500],target = 250) == 6\n assert candidate(arr = [2, 4, 8, 16, 32],target = 10) == 2\n assert candidate(arr = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230],target = 150) == 10\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 100) == 28\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 7) == 0\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],target = 50000) == 15536\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],target = 100) == 53\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180],target = 100) == 0\n assert candidate(arr = [16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1],target = 15) == 1\n assert candidate(arr = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],target = 1) == 999983\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],target = 500000000) == 400000000\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995],target = 1000000) == 0\n assert candidate(arr = [4294967295, 2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607],target = 1000000) == 7388607\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 100) == 28\n assert candidate(arr = [5, 3, 8, 12, 14, 2, 11],target = 10) == 1\n assert candidate(arr = [5, 3, 8, 6, 2, 7, 4, 1],target = 5) == 0\n assert candidate(arr = [9, 12, 3, 7, 15, 8, 6, 4, 2, 1],target = 5) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 10) == 1\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],target = 512) == 1\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],target = 1) == 0\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],target = 10000) == 1809\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],target = 1000) == 24\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],target = 100000) == 1696\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 3) == 2\n assert candidate(arr = [1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125],target = 1000000) == 609375\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56],target = 30) == 2\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40],target = 22) == 2\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],target = 1000) == 24\n assert candidate(arr = [1234567, 2345678, 3456789, 4567890, 5678901, 6789012, 7890123, 8901234, 9012345],target = 5000000) == 377900\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],target = 20) == 1\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 1000) == 24\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 500) == 12\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],target = 500) == 11\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21],target = 10) == 1\n assert candidate(arr = [83552, 83552, 83552, 83552, 83552, 83552, 83552, 83552],target = 50000) == 33552\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 1) == 2\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],target = 50) == 1\n assert candidate(arr = [2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046],target = 1024) == 2\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 5) == 2\n assert candidate(arr = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048],target = 100000) == 31072\n assert candidate(arr = [13, 23, 33, 43, 53, 63, 73, 83, 93, 103, 113, 123, 133, 143, 153],target = 75) == 2\n assert candidate(arr = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],target = 500000) == 499984\n assert candidate(arr = [111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999, 1111111],target = 500000) == 24320\n assert candidate(arr = [31, 15, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 16) == 1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 1) == 2\n assert candidate(arr = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015, 1014, 1013, 1012, 1011, 1010, 1009, 1008, 1007, 1006, 1005, 1004, 1003, 1002, 1001, 1000],target = 500) == 492\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],target = 500) == 11\n assert candidate(arr = [31, 13, 7, 1, 9, 15, 8, 10, 18, 6],target = 12) == 1\n assert candidate(arr = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000],target = 5000) == 0\n assert candidate(arr = [987654, 321654, 654321, 123456, 654123, 321987, 987321, 123654, 456789, 789123],target = 500000) == 43211\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],target = 8190) == 2\n assert candidate(arr = [100000, 200000, 300000, 400000, 500000],target = 350000) == 43216\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],target = 50) == 1\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],target = 50000000) == 23736448\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 0) == 0\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],target = 1000) == 24\n assert candidate(arr = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876, 98765],target = 500000) == 24288\n assert candidate(arr = [8, 4, 2, 1, 16, 32, 64, 128, 256, 512],target = 100) == 28\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],target = 10) == 1\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],target = 100000) == 1696\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],target = 200) == 55\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 511) == 1\n assert candidate(arr = [123456, 654321, 111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888],target = 333333) == 0\n assert candidate(arr = [31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 15, 7, 3, 1],target = 10) == 3\n assert candidate(arr = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 100000) == 31072\n assert candidate(arr = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],target = 1000000) == 0\n assert candidate(arr = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 1000000) == 48576\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575],target = 1000000) == 48575\n assert candidate(arr = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 1023) == 1\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 27) == 2\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 4) == 3\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],target = 100000) == 1112\n assert candidate(arr = [1000000, 1000000, 1000000, 1, 1, 1, 2, 3, 4, 5],target = 1000005) == 5\n assert candidate(arr = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643, 2147483642, 2147483641, 2147483640],target = 2147483640) == 0\n assert candidate(arr = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31],target = 15) == 2\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],target = 123456789) == 23456789\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33],target = 32) == 1\n assert candidate(arr = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 300) == 44\n assert candidate(arr = [999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999],target = 1) == 999998\n assert candidate(arr = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],target = 3) == 3\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 5) == 0\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 10) == 2\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],target = 50) == 4\n assert candidate(arr = [123, 456, 789, 101, 112, 131, 44, 55, 66, 77, 88, 99],target = 200) == 56\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 20) == 1\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256],target = 100) == 28\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],target = 10) == 3\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 75) == 5\n assert candidate(arr = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876],target = 300000) == 3480\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],target = 750) == 18\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255],target = 123) == 4\n assert candidate(arr = [255, 127, 63, 31, 15, 7, 3, 1],target = 10) == 3\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],target = 1000) == 24\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],target = 50) == 4\n assert candidate(arr = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 45000) == 4728\n assert candidate(arr = [123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234, 101234],target = 400000) == 54322\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],target = 1024) == 1\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 85) == 5\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],target = 50) == 50\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 7) == 0\n"}, "metadata": {"canonical_parameter_names": ["arr", "target"], "leetcode_dataset_entry_point": "Solution().closestToTarget", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def closestToTarget(self, arr: list[int], target: int) -> int:", "container": "Solution", "callable": "closestToTarget", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1523, "task_id": "count-odd-numbers-in-an-interval-range", "difficulty": "Easy", "problem_description": "Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive).\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: low = 3, high = 7\\r\nOutput: 3\\r\nExplanation: The odd numbers between 3 and 7 are [3,5,7].\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: low = 8, high = 10\\r\nOutput: 1\\r\nExplanation: The odd numbers between 8 and 10 are [9].\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t0 <= low <= high <= 10^9\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(low = 3,high = 7) == 3\n assert candidate(low = 0,high = 1000000000) == 500000000\n assert candidate(low = 0,high = 1) == 1\n assert candidate(low = 500000000,high = 500000000) == 0\n assert candidate(low = 1,high = 1000000000) == 500000000\n assert candidate(low = 8,high = 10) == 1\n assert candidate(low = 1000000000,high = 1000000000) == 0\n assert candidate(low = 1,high = 2) == 1\n assert candidate(low = 2,high = 3) == 1\n assert candidate(low = 0,high = 0) == 0\n assert candidate(low = 2,high = 2) == 0\n assert candidate(low = 1,high = 1) == 1\n assert candidate(low = 450000000,high = 450000010) == 5\n assert candidate(low = 3,high = 5) == 2\n assert candidate(low = 16,high = 17) == 1\n assert candidate(low = 500000001,high = 1000000000) == 250000000\n assert candidate(low = 2,high = 999999999) == 499999999\n assert candidate(low = 2,high = 4) == 1\n assert candidate(low = 500000000,high = 1500000000) == 500000000\n assert candidate(low = 2,high = 1999999999) == 999999999\n assert candidate(low = 15,high = 15) == 1\n assert candidate(low = 14,high = 24) == 5\n assert candidate(low = 499999998,high = 500000002) == 2\n assert candidate(low = 234567890,high = 987654321) == 376543216\n assert candidate(low = 20,high = 29) == 5\n assert candidate(low = 100000000,high = 999999999) == 450000000\n assert candidate(low = 99,high = 101) == 2\n assert candidate(low = 1,high = 10) == 5\n assert candidate(low = 1,high = 1000000001) == 500000001\n assert candidate(low = 800000000,high = 850000000) == 25000000\n assert candidate(low = 300,high = 400) == 50\n assert candidate(low = 1000000000,high = 1000000001) == 1\n assert candidate(low = 25,high = 75) == 26\n assert candidate(low = 100,high = 200) == 50\n assert candidate(low = 123456,high = 654321) == 265433\n assert candidate(low = 500000001,high = 1500000001) == 500000001\n assert candidate(low = 1000000001,high = 9999999999) == 4500000000\n assert candidate(low = 45,high = 100) == 28\n assert candidate(low = 1,high = 999999999) == 500000000\n assert candidate(low = 1,high = 2000000000) == 1000000000\n assert candidate(low = 9,high = 11) == 2\n assert candidate(low = 8,high = 1000000008) == 500000000\n assert candidate(low = 15,high = 25) == 6\n assert candidate(low = 333333333,high = 666666666) == 166666667\n assert candidate(low = 2,high = 21) == 10\n assert candidate(low = 0,high = 2) == 1\n assert candidate(low = 25,high = 35) == 6\n assert candidate(low = 11,high = 21) == 6\n assert candidate(low = 123456789,high = 987654321) == 432098767\n assert candidate(low = 1,high = 20) == 10\n assert candidate(low = 21,high = 31) == 6\n assert candidate(low = 1000000000,high = 1000000002) == 1\n assert candidate(low = 100000001,high = 100000001) == 1\n assert candidate(low = 3,high = 1800000001) == 900000000\n assert candidate(low = 500000000,high = 500000002) == 1\n assert candidate(low = 10,high = 20) == 5\n assert candidate(low = 999999998,high = 999999999) == 1\n assert candidate(low = 5,high = 99) == 48\n assert candidate(low = 789012345,high = 789012345) == 1\n assert candidate(low = 15,high = 16) == 1\n assert candidate(low = 20,high = 30) == 5\n assert candidate(low = 1000000001,high = 2000000000) == 500000000\n assert candidate(low = 5,high = 7) == 2\n assert candidate(low = 1,high = 3) == 2\n assert candidate(low = 4,high = 1700000002) == 849999999\n assert candidate(low = 999999999,high = 1000000000) == 1\n assert candidate(low = 500,high = 1500) == 500\n assert candidate(low = 500,high = 500000005) == 249999753\n assert candidate(low = 4,high = 6) == 1\n assert candidate(low = 100000000,high = 100000010) == 5\n assert candidate(low = 12,high = 22) == 5\n assert candidate(low = 9,high = 9) == 1\n assert candidate(low = 100000000,high = 900000000) == 400000000\n assert candidate(low = 100,high = 1000) == 450\n assert candidate(low = 1000000,high = 2000000) == 500000\n assert candidate(low = 5,high = 5) == 1\n assert candidate(low = 500000001,high = 500000005) == 3\n assert candidate(low = 123456,high = 789012) == 332778\n assert candidate(low = 5,high = 500000005) == 250000001\n assert candidate(low = 1000000001,high = 1000000001) == 1\n assert candidate(low = 500,high = 600) == 50\n assert candidate(low = 888888888,high = 999999999) == 55555556\n assert candidate(low = 100000000,high = 200000000) == 50000000\n assert candidate(low = 13,high = 23) == 6\n assert candidate(low = 500000001,high = 600000000) == 50000000\n assert candidate(low = 10,high = 19) == 5\n assert candidate(low = 2000000000,high = 3000000000) == 500000000\n assert candidate(low = 500000000,high = 1000000000) == 250000000\n assert candidate(low = 999999998,high = 1000000000) == 1\n assert candidate(low = 250000000,high = 750000000) == 250000000\n assert candidate(low = 499999999,high = 500000001) == 2\n assert candidate(low = 1000000000,high = 2000000000) == 500000000\n assert candidate(low = 500000001,high = 500000001) == 1\n"}, "metadata": {"canonical_parameter_names": ["low", "high"], "leetcode_dataset_entry_point": "Solution().countOdds", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countOdds(self, low: int, high: int) -> int:", "container": "Solution", "callable": "countOdds", "parameters": [{"name": "low", "type": "int"}, {"name": "high", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1524, "task_id": "number-of-sub-arrays-with-odd-sum", "difficulty": "Medium", "problem_description": "Given an array of integers arr, return the number of subarrays with an odd sum.\nSince the answer can be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: arr = [1,3,5]\nOutput: 4\nExplanation: All subarrays are [[1],[1,3],[1,3,5],[3],[3,5],[5]]\nAll sub-arrays sum are [1,4,9,3,8,5].\nOdd sums are [1,9,3,5] so the answer is 4.\n\nExample 2:\n\nInput: arr = [2,4,6]\nOutput: 0\nExplanation: All subarrays are [[2],[2,4],[2,4,6],[4],[4,6],[6]]\nAll sub-arrays sum are [2,6,12,4,10,6].\nAll sub-arrays have even sum and the answer is 0.\n\nExample 3:\n\nInput: arr = [1,2,3,4,5,6,7]\nOutput: 16\n\n \nConstraints:\n\n1 <= arr.length <= 105\n1 <= arr[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 4, 6, 8, 10]) == 0\n assert candidate(arr = [100, 100, 100, 100, 100]) == 0\n assert candidate(arr = [50, 50, 50, 50, 50]) == 0\n assert candidate(arr = [1, 2, 3]) == 4\n assert candidate(arr = [2, 2, 2, 2, 2]) == 0\n assert candidate(arr = [1, 2]) == 2\n assert candidate(arr = [99, 100, 101]) == 4\n assert candidate(arr = [100, 100, 100]) == 0\n assert candidate(arr = [2, 4, 6]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7]) == 16\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1]) == 9\n assert candidate(arr = [100, 99, 98, 97, 96]) == 8\n assert candidate(arr = [101, 102, 103, 104, 105]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5]) == 9\n assert candidate(arr = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 24\n assert candidate(arr = [2]) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4]) == 14\n assert candidate(arr = [1, 3, 5]) == 4\n assert candidate(arr = [97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78]) == 110\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 0\n assert candidate(arr = [99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1]) == 110\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 462\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 30\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 30\n assert candidate(arr = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 30\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 64\n assert candidate(arr = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == 30\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15]) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 30\n assert candidate(arr = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 30\n assert candidate(arr = [97, 2, 83, 4, 81, 6, 79, 8, 77, 10, 75, 12, 73, 14, 71, 16, 69, 18, 67, 20]) == 110\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 110\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 0\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 110\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 30\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 0\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 64\n assert candidate(arr = [99, 199, 299, 399, 499, 599, 699, 799, 899, 999]) == 30\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 0\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 63\n assert candidate(arr = [1, 3, 5, 7, 9, 11]) == 12\n assert candidate(arr = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 30\n assert candidate(arr = [97, 98, 99, 100, 1, 2, 3, 4, 5, 6]) == 30\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 30\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]) == 60\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 10\n assert candidate(arr = [50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51]) == 110\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 240\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 240\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == 28\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 240\n assert candidate(arr = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750]) == 0\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 110\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 0\n assert candidate(arr = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 36\n assert candidate(arr = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == 98\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 0\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 110\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 110\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 63\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 110\n assert candidate(arr = [99, 100, 98, 97, 101, 96, 102, 95, 103, 94, 104, 93, 105, 92, 106]) == 48\n assert candidate(arr = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]) == 64\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 30\n assert candidate(arr = [101, 201, 301, 401, 501, 601, 701, 801, 901, 1001]) == 30\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 64\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(arr = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 110\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 0\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 64\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60]) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 310\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 52\n assert candidate(arr = [100, 99, 1, 2, 98, 3, 4, 97, 5, 6]) == 30\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 110\n assert candidate(arr = [1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21]) == 110\n assert candidate(arr = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 110\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 420\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 15\n assert candidate(arr = [100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100]) == 0\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1, 0, 0, 0]) == 28\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().numOfSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numOfSubarrays(self, arr: list[int]) -> int:", "container": "Solution", "callable": "numOfSubarrays", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1525, "task_id": "number-of-good-ways-to-split-a-string", "difficulty": "Medium", "problem_description": "You are given a string s.\nA split is called good if you can split s into two non-empty strings sleft and sright where their concatenation is equal to s (i.e., sleft + sright = s) and the number of distinct letters in sleft and sright is the same.\nReturn the number of good splits you can make in s.\n \nExample 1:\n\nInput: s = \"aacaba\"\nOutput: 2\nExplanation: There are 5 ways to split \"aacaba\" and 2 of them are good. \n(\"a\", \"acaba\") Left string and right string contains 1 and 3 different letters respectively.\n(\"aa\", \"caba\") Left string and right string contains 1 and 3 different letters respectively.\n(\"aac\", \"aba\") Left string and right string contains 2 and 2 different letters respectively (good split).\n(\"aaca\", \"ba\") Left string and right string contains 2 and 2 different letters respectively (good split).\n(\"aacab\", \"a\") Left string and right string contains 3 and 1 different letters respectively.\n\nExample 2:\n\nInput: s = \"abcd\"\nOutput: 1\nExplanation: Split the string as follows (\"ab\", \"cd\").\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"xyzxyzxyz\") == 4\n assert candidate(s = \"aabbcc\") == 1\n assert candidate(s = \"abcde\") == 0\n assert candidate(s = \"abcdefghij\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijj\") == 1\n assert candidate(s = \"abacaba\") == 0\n assert candidate(s = \"aacaba\") == 2\n assert candidate(s = \"aabbbcc\") == 2\n assert candidate(s = \"aaa\") == 2\n assert candidate(s = \"abcd\") == 1\n assert candidate(s = \"aaaaa\") == 4\n assert candidate(s = \"xyz\") == 0\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"aabbccddeeff\") == 1\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 45\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzxywvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"aabacadaeafagahaiajakalalamanaoaopapaqaraasatauavaawaxayaza\") == 0\n assert candidate(s = \"ababababababababababababababababababababababababab\") == 47\n assert candidate(s = \"abacabadabacabadabacabad\") == 12\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 1\n assert candidate(s = \"aaaaaabbccdddeeffggghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababab\") == 77\n assert candidate(s = \"nnnnaaaaccccbbbbbddddnnnnaaaaccccbbbbbdddd\") == 7\n assert candidate(s = \"thisisaverylongstringwithavarietyofcharactersandrepeatpatterns\") == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 3\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 27\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzqqqqqqqq\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"abbaccddeeffaabbccddeeff\") == 3\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\") == 1\n assert candidate(s = \"abacabadabacaba\") == 0\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadab\") == 84\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 89\n assert candidate(s = \"abracadabra\") == 2\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 25\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppppppp\") == 47\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 73\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyxwvutsrqponmlkjihgfedcba\") == 2\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 63\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyyxwwvvuutsrrqponmlkjihgfedcba\") == 2\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\") == 25\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyz\") == 1\n assert candidate(s = \"mississississississippi\") == 16\n assert candidate(s = \"abcdefghihgfedcba\") == 0\n assert candidate(s = \"abracadabraabracadabraabracadabra\") == 20\n assert candidate(s = \"pppppppppppppppppppppppppppppp\") == 29\n assert candidate(s = \"11223344556677889900112233445566778899001122334455667788990011223344556677889900\") == 43\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 61\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewqasdfghjklzxcvbnmmnbvcxzlkjhgfdsapoiuytrewq\") == 17\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 68\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaedcba\") == 1\n assert candidate(s = \"mississippimississippimississippimississippimississippi\") == 36\n assert candidate(s = \"bacaabacababacaacbacaaacaaacaacbaaaacaacaaacaacaaacaaacaa\") == 29\n assert candidate(s = \"abcdefghijklnmopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 77\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 51\n assert candidate(s = \"abracadabraabracadabraabracadabraabracadabraabracadabraabracadabra\") == 53\n assert candidate(s = \"abbaccddeeffaabbccddeeffaabbccddeeff\") == 15\n assert candidate(s = \"nnnnaaaaccccbbbbbdddd\") == 3\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 79\n assert candidate(s = \"mississippi\") == 4\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"aaabbbcccddd\") == 1\n assert candidate(s = \"abababababababababababababababababababababababababababa\") == 52\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 81\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcde\") == 1\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 73\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcd\") == 21\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 49\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 53\n assert candidate(s = \"aabbaabbaabbaabb\") == 11\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numSplits", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numSplits(self, s: str) -> int:", "container": "Solution", "callable": "numSplits", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1526, "task_id": "minimum-number-of-increments-on-subarrays-to-form-a-target-array", "difficulty": "Hard", "problem_description": "You are given an integer array target. You have an integer array initial of the same size as target with all elements initially zeros.\nIn one operation you can choose any subarray from initial and increment each value by one.\nReturn the minimum number of operations to form a target array from initial.\nThe test cases are generated so that the answer fits in a 32-bit integer.\n \nExample 1:\n\nInput: target = [1,2,3,2,1]\nOutput: 3\nExplanation: We need at least 3 operations to form the target array from the initial array.\n[0,0,0,0,0] increment 1 from index 0 to 4 (inclusive).\n[1,1,1,1,1] increment 1 from index 1 to 3 (inclusive).\n[1,2,2,2,1] increment 1 at index 2.\n[1,2,3,2,1] target array is formed.\n\nExample 2:\n\nInput: target = [3,1,1,2]\nOutput: 4\nExplanation: [0,0,0,0] -> [1,1,1,1] -> [1,1,1,2] -> [2,1,1,2] -> [3,1,1,2]\n\nExample 3:\n\nInput: target = [3,1,5,4,2]\nOutput: 7\nExplanation: [0,0,0,0,0] -> [1,1,1,1,1] -> [2,1,1,1,1] -> [3,1,1,1,1] -> [3,1,2,2,2] -> [3,1,3,3,2] -> [3,1,4,4,2] -> [3,1,5,4,2].\n\n \nConstraints:\n\n1 <= target.length <= 105\n1 <= target[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(target = [1, 2, 3, 4, 5]) == 5\n assert candidate(target = [5, 4, 3, 2, 1]) == 5\n assert candidate(target = [100000]) == 100000\n assert candidate(target = [1, 1, 1, 1, 1]) == 1\n assert candidate(target = [1, 3, 2, 4, 5]) == 6\n assert candidate(target = [10, 10, 10, 10, 10]) == 10\n assert candidate(target = [3, 1, 5, 4, 2]) == 7\n assert candidate(target = [1, 100000, 1]) == 100000\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(target = [3, 1, 1, 2]) == 4\n assert candidate(target = [1, 3, 5, 7, 9]) == 9\n assert candidate(target = [100000, 100000, 100000, 100000, 100000]) == 100000\n assert candidate(target = [1, 2, 3, 2, 1]) == 3\n assert candidate(target = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 5\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(target = [9, 7, 5, 3, 1]) == 9\n assert candidate(target = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 13\n assert candidate(target = [1, 3, 5, 7, 9, 7, 5, 3, 1]) == 9\n assert candidate(target = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(target = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1]) == 3\n assert candidate(target = [10, 10, 10, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == 19\n assert candidate(target = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 7\n assert candidate(target = [3, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28]) == 41\n assert candidate(target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(target = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(target = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 10\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(target = [3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 13\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(target = [1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 1, 1]) == 5\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(target = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]) == 10\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(target = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 14\n assert candidate(target = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5]) == 9\n assert candidate(target = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(target = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 5\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 15\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(target = [100, 50, 100, 50, 100, 50, 100, 50, 100, 50]) == 300\n assert candidate(target = [1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1]) == 7\n assert candidate(target = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 5\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 3, 3, 2, 2, 1, 1]) == 4\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 50, 100, 50, 100, 50]) == 200\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 30\n assert candidate(target = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 50\n assert candidate(target = [5, 10, 15, 20, 25, 20, 15, 10, 5]) == 25\n assert candidate(target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(target = [10, 20, 30, 20, 10, 5, 0, 5, 10, 20, 30, 20, 10]) == 60\n assert candidate(target = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3]) == 15\n assert candidate(target = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1]) == 3\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 100\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(target = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 13\n assert candidate(target = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 10\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(target = [1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 2, 1]) == 13\n assert candidate(target = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5]) == 10\n assert candidate(target = [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2]) == 4\n assert candidate(target = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 11\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 11, 9, 7, 5, 3, 1]) == 13\n assert candidate(target = [3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 9\n assert candidate(target = [5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]) == 15\n assert candidate(target = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10]) == 19\n assert candidate(target = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 7\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(target = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 11\n assert candidate(target = [10, 1, 20, 30, 40, 50, 40, 30, 20, 10]) == 59\n assert candidate(target = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10]) == 51\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(target = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 90\n assert candidate(target = [1, 2, 3, 2, 3, 4, 5, 4, 3, 2, 1]) == 6\n assert candidate(target = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(target = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 10\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(target = [1, 5, 2, 5, 1, 5, 2, 5, 1, 5, 2, 5, 1, 5, 2, 5, 1]) == 29\n assert candidate(target = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 5\n assert candidate(target = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 46\n assert candidate(target = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 46\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 6\n assert candidate(target = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 5\n assert candidate(target = [100, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50]) == 100\n assert candidate(target = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == 90\n assert candidate(target = [1, 2, 3, 4, 5, 4, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 11\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(target = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5]) == 7\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 19\n assert candidate(target = [1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1]) == 25\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(target = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 14\n"}, "metadata": {"canonical_parameter_names": ["target"], "leetcode_dataset_entry_point": "Solution().minNumberOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minNumberOperations(self, target: list[int]) -> int:", "container": "Solution", "callable": "minNumberOperations", "parameters": [{"name": "target", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1528, "task_id": "shuffle-string", "difficulty": "Easy", "problem_description": "You are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.\nReturn the shuffled string.\n \nExample 1:\n\n\nInput: s = \"codeleet\", indices = [4,5,6,7,0,2,1,3]\nOutput: \"leetcode\"\nExplanation: As shown, \"codeleet\" becomes \"leetcode\" after shuffling.\n\nExample 2:\n\nInput: s = \"abc\", indices = [0,1,2]\nOutput: \"abc\"\nExplanation: After shuffling, each character remains in its position.\n\n \nConstraints:\n\ns.length == indices.length == n\n1 <= n <= 100\ns consists of only lowercase English letters.\n0 <= indices[i] < n\nAll values of indices are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"codeleet\",indices = [4, 5, 6, 7, 0, 2, 1, 3]) == \"leetcode\"\n assert candidate(s = \"aaiougrt\",indices = [4, 0, 2, 6, 7, 3, 1, 5]) == \"arigatou\"\n assert candidate(s = \"aiohn\",indices = [3, 1, 4, 2, 0]) == \"nihao\"\n assert candidate(s = \"abc\",indices = [0, 1, 2]) == \"abc\"\n assert candidate(s = \"art\",indices = [1, 0, 2]) == \"rat\"\n assert candidate(s = \"abcdefgh\",indices = [7, 6, 5, 4, 3, 2, 1, 0]) == \"hgfedcba\"\n assert candidate(s = \"permutation\",indices = [8, 5, 4, 10, 0, 9, 2, 6, 3, 1, 7]) == \"uoairetnptm\"\n assert candidate(s = \"development\",indices = [3, 6, 5, 1, 0, 4, 8, 9, 2, 7, 10]) == \"leedovenpmt\"\n assert candidate(s = \"exampleinput\",indices = [11, 2, 5, 0, 8, 1, 6, 7, 4, 3, 9, 10]) == \"mlxpnaeipute\"\n assert candidate(s = \"abcdefghij\",indices = [5, 8, 1, 6, 7, 0, 3, 2, 9, 4]) == \"fchgjadebi\"\n assert candidate(s = \"abcdefgxyz\",indices = [6, 1, 7, 5, 8, 0, 9, 4, 3, 2]) == \"fbzyxdaceg\"\n assert candidate(s = \"pneumonia\",indices = [2, 8, 7, 6, 5, 4, 3, 1, 0]) == \"aipnomuen\"\n assert candidate(s = \"randomization\",indices = [4, 1, 5, 0, 2, 7, 8, 6, 3, 9, 10, 11, 12]) == \"daoarnzmition\"\n assert candidate(s = \"character\",indices = [8, 4, 2, 5, 6, 1, 0, 7, 3]) == \"tcarhraec\"\n assert candidate(s = \"fqtv\",indices = [1, 3, 2, 0]) == \"vftq\"\n assert candidate(s = \"visualization\",indices = [10, 1, 9, 12, 0, 2, 8, 4, 6, 7, 11, 3, 5]) == \"ailoznatisviu\"\n assert candidate(s = \"waterbottle\",indices = [8, 7, 6, 5, 4, 3, 2, 1, 9, 0, 10]) == \"ltobretawte\"\n assert candidate(s = \"shuffle\",indices = [4, 2, 5, 1, 6, 3, 0]) == \"efhlsuf\"\n assert candidate(s = \"intermediate\",indices = [11, 8, 2, 0, 7, 3, 4, 9, 1, 6, 5, 10]) == \"eitmetarndei\"\n assert candidate(s = \"programming\",indices = [10, 2, 1, 7, 8, 6, 5, 3, 0, 9, 4]) == \"iormgmagrnp\"\n assert candidate(s = \"alphabet\",indices = [5, 6, 7, 4, 3, 2, 1, 0]) == \"tebahalp\"\n assert candidate(s = \"permutation\",indices = [1, 10, 9, 0, 8, 6, 3, 5, 4, 2, 7]) == \"mpoaittnure\"\n assert candidate(s = \"shuffling\",indices = [8, 4, 3, 5, 7, 2, 6, 1, 0]) == \"gnluhfifs\"\n assert candidate(s = \"exampleinput\",indices = [11, 4, 0, 7, 8, 3, 5, 6, 2, 9, 1, 10]) == \"aunlxeimppte\"\n assert candidate(s = \"generation\",indices = [5, 3, 6, 7, 2, 1, 8, 0, 4, 9]) == \"iareognetn\"\n assert candidate(s = \"xylophone\",indices = [1, 4, 8, 2, 7, 5, 3, 6, 0]) == \"exooyhnpl\"\n assert candidate(s = \"uniquecharacters\",indices = [12, 1, 13, 2, 0, 15, 5, 14, 4, 7, 11, 6, 8, 10, 9, 3]) == \"unqsaccrtreauihe\"\n assert candidate(s = \"complexstringshuffle\",indices = [15, 6, 11, 19, 8, 1, 0, 12, 18, 5, 2, 3, 10, 13, 17, 14, 4, 16, 7, 9]) == \"xeinfrollegmssucfhtp\"\n assert candidate(s = \"alphanumeric\",indices = [9, 5, 7, 3, 4, 8, 10, 0, 11, 2, 1, 6]) == \"mirhalcpnaue\"\n assert candidate(s = \"abracadabra\",indices = [10, 6, 5, 3, 0, 9, 7, 8, 2, 1, 4]) == \"crbaarbdaaa\"\n assert candidate(s = \"python\",indices = [4, 0, 1, 5, 3, 2]) == \"ytnoph\"\n assert candidate(s = \"algorithm\",indices = [1, 2, 3, 0, 4, 5, 6, 7, 8]) == \"oalgrithm\"\n assert candidate(s = \"characters\",indices = [9, 3, 0, 7, 5, 2, 1, 6, 4, 8]) == \"atchraersc\"\n assert candidate(s = \"python\",indices = [5, 1, 2, 4, 0, 3]) == \"oytnhp\"\n assert candidate(s = \"algorithmdesign\",indices = [8, 12, 1, 10, 9, 13, 0, 5, 2, 4, 3, 6, 7, 11, 14]) == \"tgmedhsiaroglin\"\n assert candidate(s = \"randomized\",indices = [7, 1, 8, 2, 0, 4, 5, 9, 6, 3]) == \"oaddmiernz\"\n assert candidate(s = \"shufflethis\",indices = [8, 2, 0, 5, 3, 7, 4, 1, 6, 9, 10, 11]) == \"uthfefhlsis\"\n assert candidate(s = \"complex\",indices = [6, 4, 1, 2, 5, 0, 3]) == \"empxolc\"\n assert candidate(s = \"jumble\",indices = [3, 0, 5, 4, 2, 1]) == \"ueljbm\"\n assert candidate(s = \"rearrange\",indices = [8, 4, 3, 0, 5, 2, 7, 6, 1]) == \"reaaergnr\"\n assert candidate(s = \"algorithm\",indices = [5, 1, 4, 0, 2, 7, 6, 8, 3]) == \"olrmgatih\"\n assert candidate(s = \"randomization\",indices = [12, 1, 6, 5, 0, 11, 10, 9, 8, 7, 4, 3, 2]) == \"oanoidntazimr\"\n assert candidate(s = \"continuous\",indices = [1, 6, 5, 9, 0, 3, 7, 4, 8, 2]) == \"icsnonouut\"\n assert candidate(s = \"programming\",indices = [2, 4, 5, 0, 1, 6, 3, 7, 8, 9, 10, 11, 12]) == \"grpmroaming\"\n assert candidate(s = \"shufflingstring\",indices = [11, 7, 9, 6, 13, 2, 0, 10, 1, 12, 3, 4, 5, 8, 14]) == \"igltrifhnunssfg\"\n assert candidate(s = \"complexity\",indices = [3, 6, 1, 5, 2, 0, 7, 4, 9, 8]) == \"emlcipoxyt\"\n assert candidate(s = \"rearrange\",indices = [3, 7, 5, 2, 8, 0, 4, 1, 6]) == \"agrrnaeer\"\n assert candidate(s = \"python\",indices = [3, 1, 5, 0, 2, 4]) == \"hyopnt\"\n assert candidate(s = \"algorithm\",indices = [1, 0, 6, 4, 2, 5, 3, 7, 8]) == \"lartoighm\"\n assert candidate(s = \"algorithm\",indices = [6, 4, 3, 0, 5, 2, 1, 8, 7]) == \"otiglramh\"\n assert candidate(s = \"permutation\",indices = [8, 5, 1, 6, 7, 3, 9, 2, 0, 4, 10]) == \"irttoemupan\"\n assert candidate(s = \"scrambled\",indices = [3, 2, 0, 6, 7, 4, 1, 5, 8]) == \"rlcsbeamd\"\n assert candidate(s = \"shuffling\",indices = [1, 3, 6, 8, 0, 2, 5, 4, 7]) == \"fslhniugf\"\n assert candidate(s = \"vivid\",indices = [2, 0, 4, 3, 1]) == \"idviv\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",indices = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"zkrw\",indices = [2, 3, 0, 1]) == \"rwzk\"\n assert candidate(s = \"randomize\",indices = [3, 8, 0, 5, 4, 7, 2, 6, 1]) == \"neirodzma\"\n assert candidate(s = \"jumbledtext\",indices = [9, 0, 5, 3, 8, 6, 1, 2, 7, 4, 10]) == \"udtbxmeeljt\"\n assert candidate(s = \"environment\",indices = [1, 7, 4, 6, 2, 0, 3, 8, 10, 5, 9]) == \"oernvninmte\"\n assert candidate(s = \"characters\",indices = [6, 2, 9, 5, 7, 4, 1, 0, 3, 8]) == \"ethrcrcasa\"\n assert candidate(s = \"jfbm\",indices = [3, 0, 1, 2]) == \"fbmj\"\n"}, "metadata": {"canonical_parameter_names": ["s", "indices"], "leetcode_dataset_entry_point": "Solution().restoreString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def restoreString(self, s: str, indices: list[int]) -> str:", "container": "Solution", "callable": "restoreString", "parameters": [{"name": "s", "type": "str"}, {"name": "indices", "type": "list[int]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1529, "task_id": "minimum-suffix-flips", "difficulty": "Medium", "problem_description": "You are given a 0-indexed binary string target of length n. You have another binary string s of length n that is initially set to all zeros. You want to make s equal to target.\nIn one operation, you can pick an index i where 0 <= i < n and flip all bits in the inclusive range [i, n - 1]. Flip means changing '0' to '1' and '1' to '0'.\nReturn the minimum number of operations needed to make s equal to target.\n \nExample 1:\n\nInput: target = \"10111\"\nOutput: 3\nExplanation: Initially, s = \"00000\".\nChoose index i = 2: \"00000\" -> \"00111\"\nChoose index i = 0: \"00111\" -> \"11000\"\nChoose index i = 1: \"11000\" -> \"10111\"\nWe need at least 3 flip operations to form target.\n\nExample 2:\n\nInput: target = \"101\"\nOutput: 3\nExplanation: Initially, s = \"000\".\nChoose index i = 0: \"000\" -> \"111\"\nChoose index i = 1: \"111\" -> \"100\"\nChoose index i = 2: \"100\" -> \"101\"\nWe need at least 3 flip operations to form target.\n\nExample 3:\n\nInput: target = \"00000\"\nOutput: 0\nExplanation: We do not need any operations since the initial s already equals target.\n\n \nConstraints:\n\nn == target.length\n1 <= n <= 105\ntarget[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = \"00000\") == 0\n assert candidate(target = \"00110\") == 2\n assert candidate(target = \"1100110011\") == 5\n assert candidate(target = \"000111000111\") == 3\n assert candidate(target = \"001100\") == 2\n assert candidate(target = \"10001\") == 3\n assert candidate(target = \"010101010101010101\") == 17\n assert candidate(target = \"001001001\") == 5\n assert candidate(target = \"1111111111\") == 1\n assert candidate(target = \"0000000000\") == 0\n assert candidate(target = \"01010\") == 4\n assert candidate(target = \"101\") == 3\n assert candidate(target = \"11001100\") == 4\n assert candidate(target = \"10010\") == 4\n assert candidate(target = \"11001\") == 3\n assert candidate(target = \"10111\") == 3\n assert candidate(target = \"001100110011\") == 5\n assert candidate(target = \"111100001111\") == 3\n assert candidate(target = \"11111\") == 1\n assert candidate(target = \"1001010\") == 6\n assert candidate(target = \"010101\") == 5\n assert candidate(target = \"1001001\") == 5\n assert candidate(target = \"0101010101\") == 9\n assert candidate(target = \"110011\") == 3\n assert candidate(target = \"111000111\") == 3\n assert candidate(target = \"10101010101010101010\") == 20\n assert candidate(target = \"000011110000111100001111\") == 5\n assert candidate(target = \"011010101010101010101010\") == 22\n assert candidate(target = \"10101010101010101010101010101010\") == 32\n assert candidate(target = \"110011001100110\") == 8\n assert candidate(target = \"000000000000000000000000000000000000000000000000\") == 0\n assert candidate(target = \"10001000100010001000\") == 10\n assert candidate(target = \"101010101010101010101010101010101010101010101010\") == 48\n assert candidate(target = \"000111000111000\") == 4\n assert candidate(target = \"1001001001\") == 7\n assert candidate(target = \"1111111111111111111111111111111111111111111111111111111111111111\") == 1\n assert candidate(target = \"01010101010101010101\") == 19\n assert candidate(target = \"1001001001001001001001001001001001001001\") == 27\n assert candidate(target = \"1010101010101010101010101010\") == 28\n assert candidate(target = \"00000111110000011111\") == 3\n assert candidate(target = \"0000000000111111111100000000001111111111\") == 3\n assert candidate(target = \"11111111111111111111111111\") == 1\n assert candidate(target = \"1010101010101010101010101010101010101010101010101010\") == 52\n assert candidate(target = \"000000000000000000000001\") == 1\n assert candidate(target = \"1100110011001100110011001100\") == 14\n assert candidate(target = \"00000000000000000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(target = \"00000000000000000000000000\") == 0\n assert candidate(target = \"00110011001100110011\") == 9\n assert candidate(target = \"1111111111111111111111111111\") == 1\n assert candidate(target = \"11111111111111111110\") == 2\n assert candidate(target = \"11000000000000000001\") == 3\n assert candidate(target = \"111111111111111111111111111111111111111111111111\") == 1\n assert candidate(target = \"101010101010101010101010101010101010\") == 36\n assert candidate(target = \"0101010101010101010101010101\") == 27\n assert candidate(target = \"110110110110110110110110110110\") == 20\n assert candidate(target = \"111100001111000011110000\") == 6\n assert candidate(target = \"000111000111000111000111\") == 7\n assert candidate(target = \"100110011001100110011001\") == 13\n assert candidate(target = \"01010101010101010101010101010101010101\") == 37\n assert candidate(target = \"000000000000000000000000000000000000\") == 0\n assert candidate(target = \"10010010010010010010010010010010010010010010010010\") == 34\n assert candidate(target = \"1001001001001001001001001001001001001001001001001\") == 33\n assert candidate(target = \"01100110011001100110\") == 10\n assert candidate(target = \"11110000111100001111\") == 5\n assert candidate(target = \"111000111000111000111000\") == 8\n assert candidate(target = \"11111000001111100000111110000011111000001111100000\") == 10\n assert candidate(target = \"00000000000000000000000000000000000000000000000000\") == 0\n assert candidate(target = \"10101010101010101010101010\") == 26\n assert candidate(target = \"11001100110011001100110011\") == 13\n assert candidate(target = \"00110011001100110011001100110011001100110011001100\") == 24\n assert candidate(target = \"0111111111111111111111111111\") == 1\n assert candidate(target = \"01010101010101010101010101\") == 25\n assert candidate(target = \"11111000000000000000\") == 2\n assert candidate(target = \"1000000000000000000000000000\") == 2\n assert candidate(target = \"11111111111111111111111111111111111111111111\") == 1\n assert candidate(target = \"00000111110000011111000001111100000111110000011111\") == 9\n assert candidate(target = \"01001001001001001001001001001001\") == 21\n assert candidate(target = \"11111000001111100000\") == 4\n assert candidate(target = \"00000000000000000001\") == 1\n assert candidate(target = \"11011011011011011011\") == 13\n assert candidate(target = \"001001001001001001001001\") == 15\n assert candidate(target = \"11001100110011001100110011001100110011001100110011\") == 25\n assert candidate(target = \"001100110011001100110011001100110011001100110011\") == 23\n assert candidate(target = \"11001100110011001100110011001100\") == 16\n assert candidate(target = \"1001001001001001001001001001\") == 19\n assert candidate(target = \"00001111000011110000\") == 4\n assert candidate(target = \"111000111000111000111000111000111000111000111000111000111000111000\") == 22\n assert candidate(target = \"111111111111111111111111111111111111\") == 1\n assert candidate(target = \"0101010101010101010101010101010101010101010101010101\") == 51\n assert candidate(target = \"00000000000000000000000000000000000000000000\") == 0\n assert candidate(target = \"01110111011101110111\") == 9\n assert candidate(target = \"0110110110\") == 6\n assert candidate(target = \"00000111111111111111\") == 1\n assert candidate(target = \"000111000111000111\") == 5\n assert candidate(target = \"000011110000\") == 2\n assert candidate(target = \"11111111111111111111111111111111111111111111111110\") == 2\n assert candidate(target = \"01001001001001001001\") == 13\n assert candidate(target = \"111111111111111111111110\") == 2\n assert candidate(target = \"101010101010101010\") == 18\n assert candidate(target = \"100101010101010101010101\") == 23\n assert candidate(target = \"00000000001111111111000000000011111111110000000000\") == 4\n assert candidate(target = \"010101010101010101010101010101\") == 29\n assert candidate(target = \"0101010101010101010101010101010101\") == 33\n assert candidate(target = \"000000000000000000000000000000\") == 0\n assert candidate(target = \"01010101010101010101010101010101010101010101010101\") == 49\n assert candidate(target = \"0011001100110011001100110011\") == 13\n assert candidate(target = \"11001100110011001100\") == 10\n assert candidate(target = \"00001111111111110000\") == 2\n assert candidate(target = \"01001001001001001001001001001001001001001001001001\") == 33\n assert candidate(target = \"00000000001111111111\") == 1\n assert candidate(target = \"01001001001001001001001001001001001001001001\") == 29\n assert candidate(target = \"01010101010101010101010101010101\") == 31\n assert candidate(target = \"0000000000000000000000000000\") == 0\n assert candidate(target = \"11111111110000000000\") == 2\n assert candidate(target = \"110011001100110011\") == 9\n assert candidate(target = \"10010010010010010010\") == 14\n assert candidate(target = \"11111111111111111111\") == 1\n"}, "metadata": {"canonical_parameter_names": ["target"], "leetcode_dataset_entry_point": "Solution().minFlips", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minFlips(self, target: str) -> int:", "container": "Solution", "callable": "minFlips", "parameters": [{"name": "target", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1530, "task_id": "number-of-good-leaf-nodes-pairs", "difficulty": "Medium", "problem_description": "You are given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance.\nReturn the number of good leaf node pairs in the tree.\n \nExample 1:\n\n\nInput: root = [1,2,3,null,4], distance = 3\nOutput: 1\nExplanation: The leaf nodes of the tree are 3 and 4 and the length of the shortest path between them is 3. This is the only good pair.\n\nExample 2:\n\n\nInput: root = [1,2,3,4,5,6,7], distance = 3\nOutput: 2\nExplanation: The good pairs are [4,5] and [6,7] with shortest path = 2. The pair [4,6] is not good because the length of ther shortest path between them is 4.\n\nExample 3:\n\nInput: root = [7,1,4,6,null,5,3,null,null,null,null,null,2], distance = 3\nOutput: 1\nExplanation: The only good pair is [2,5].\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 210].\n1 <= Node.val <= 100\n1 <= distance <= 10\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([1]),distance = 1) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),distance = 5) == 6\n assert candidate(root = tree_node([1, 2, 3, None, 4]),distance = 3) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),distance = 3) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),distance = 1) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),distance = 2) == 4\n assert candidate(root = tree_node([7, 1, 4, 6, None, 5, 3, None, None, None, None, None, 2]),distance = 3) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, 6, None, 7, None, 8, None, 9]),distance = 3) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, 7, None, None, 8, None, None, None, 9]),distance = 4) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]),distance = 7) == 56\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, None, None, 6, 7, None, None, None, None, 8, 9, None, None, None, None, 10, 11, None, None, None, None, 12, 13, None, None, None, None, 14, 15, None, None, None, None, 16, 17, None, None, None, None, 18, 19, None, None, None, None, 20, 21]),distance = 8) == 3\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, None, None, 8, 9]),distance = 5) == 6\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, None, 6, 7, None, None, None, 8, None, 9, None, None, 10, None, None, None, None, None, None, None, None, None, 11, None, None, None, None, None, None, None, None, None, 12, None, None, None, None, None, None, None, None, None, 13, None, None, None, None, None, None, None, None, None, 14, None, None, None, None, None, None, None, None, None, 15]),distance = 6) == 2\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12]),distance = 6) == 0\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25, None, 26, None, 27, None, 28, None, 29, None, 30]),distance = 4) == 0\n assert candidate(root = tree_node([2, 1, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9]),distance = 6) == 0\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11]),distance = 6) == 0\n assert candidate(root = tree_node([8, 5, 9, 4, 6, 10, 11, 3, 7, None, None, None, None, None, None, None, 2, None, None, None, None, None, None, None]),distance = 3) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, None, None, None, None, 6, None, None, None, None, None, 7]),distance = 6) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, 6, 7, 8, 9, 10, None, None, None, None, None, 11, None, 12, 13, None, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20]),distance = 6) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]),distance = 3) == 10\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]),distance = 3) == 7\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25]),distance = 6) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, 7, 8, None, None, 9, 10, 11, 12, None, None, 13, 14, None, None, 15, 16]),distance = 5) == 14\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, 7, None, None, None, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15]),distance = 3) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]),distance = 5) == 45\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13]),distance = 7) == 0\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6, 9, None, None, 12, 14]),distance = 5) == 8\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, None, None, None, 10, 11, None, None, None, None, None, None, None, None, 12]),distance = 4) == 6\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]),distance = 6) == 38\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, None, 7, None, 8, None, 9]),distance = 5) == 1\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20]),distance = 5) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, 7, 8, 9, None, None, 10, 11, None, None, None, None, None, None, 12, 13, None, None, None, None, None, None, 14, 15]),distance = 3) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),distance = 2) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, None, None, None, None, None, None, None, None, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20]),distance = 5) == 6\n assert candidate(root = tree_node([1, 2, None, 3, 4, None, 5, 6, 7, None, None, None, 8, 9, 10, None, None, None, None, None, None, None, None, None, None, 11]),distance = 5) == 6\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20]),distance = 10) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),distance = 5) == 0\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),distance = 2) == 0\n assert candidate(root = tree_node([5, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),distance = 4) == 12\n assert candidate(root = tree_node([5, 1, 4, None, 2, None, 3, 6, 7, None, 8, None, 9, 10, 11, None, None, None, None, None, None]),distance = 5) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, 6, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15]),distance = 5) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25, None, 26, None, 27, None, 28, None, 29, None, 30, None, 31, None, 32, None, 33, None, 34, None, 35, None, 36, None, 37, None, 38, None, 39, None, 40, None, 41, None, 42, None, 43, None, 44, None, 45, None, 46, None, 47, None, 48, None, 49, None, 50]),distance = 6) == 0\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, 1, 4, 6, 8, 11, 13, 17, 19, None, None, None, None, None, None, None, None, 2, None, 9]),distance = 4) == 8\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, 6, None, None, 7, 8, None, None, 9, None, 10, None, None, 11]),distance = 5) == 0\n assert candidate(root = tree_node([5, 4, 8, 11, None, 17, 4, 7, 1, None, None, 5, 3]),distance = 6) == 10\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, None, 6, 7, None, None, 8, 9]),distance = 3) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]),distance = 3) == 25\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, None, None, 5, None, 6, None, 7, None, 8, None, 9]),distance = 5) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),distance = 4) == 12\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, 6, 7, None, None, None, None, 8, 9, None, None, None, None, None, None, None, None, None, 10]),distance = 5) == 10\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]),distance = 4) == 24\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, None, 6, 7, None, None, 8, 9, None, None, None, None, 10, None, 11, None, None, None, None, None, None, None, None, None]),distance = 4) == 3\n assert candidate(root = tree_node([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4, None, None, 10, None, None, 11, None, None, 12, None, None, 13, None, None, 14, None, None, 15]),distance = 4) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, None, None, None, 10, None, None, 11, None, None, 12]),distance = 4) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),distance = 5) == 17\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, None, 41, None, 42]),distance = 4) == 26\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]),distance = 10) == 300\n assert candidate(root = tree_node([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4, None, None, None, None, None, None]),distance = 3) == 4\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, None, None, 6, None, None, 7]),distance = 5) == 3\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9]),distance = 7) == 0\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, None, 5, 6, None, None, None, None, None, None, None, None, None, None, 7, 8, None, None, None, None, None, None, None, None, 9, 10, None, None, None, None, None, None, None, None, None, 11, 12, None, None, None, None, None, None, None, None, None, 13, 14, None, None, None, None, None, None, None, None, None, 15, 16, None, None, None, None, None, None, None, None, None, 17, 18]),distance = 5) == 3\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9]),distance = 4) == 8\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 63, 87, 6, 18, 31, 43, 55, 70, 81, 93, 3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 61, 67, 73, 77, 83, 89, 95, None, 10, 19, 28, 35, 41, 47, 53, 59, 65, 71, 75, 79, 85, 91, 97, None, 13, 23, 32, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 100, None, None, None, 16, 22, 29, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, None, None, None, None, None, 20, 26, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, None, None, None, None, None, None, None, None, 24, 30, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, None, None, None, None, None, None, None, None, None, 28, 33, 38, 44, 50, 56, 62, 68, 74, 80, 86, 92, 98, None, None, None, None, None, None, None, None, None, None, None, 32, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, None, None, None, None, None, None, None, None, None, None, None, None, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 100]),distance = 5) == 118\n assert candidate(root = tree_node([31, 30, 48, 29, 38, 39, 49, 27, None, None, None, None, None, None, None, 28, None, 26, None, None, None, None, None, None]),distance = 2) == 1\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16]),distance = 7) == 0\n"}, "metadata": {"canonical_parameter_names": ["root", "distance"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countPairs(self, root: TreeNode | None, distance: int) -> int:", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "root", "type": "TreeNode | None"}, {"name": "distance", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1531, "task_id": "string-compression-ii", "difficulty": "Hard", "problem_description": "Run-length encoding is a string compression method that works by replacing consecutive identical characters (repeated 2 or more times) with the concatenation of the character and the number marking the count of the characters (length of the run). For example, to compress the string \"aabccc\" we replace \"aa\" by \"a2\" and replace \"ccc\" by \"c3\". Thus the compressed string becomes \"a2bc3\".\nNotice that in this problem, we are not adding '1' after single characters.\nGiven a string s and an integer k. You need to delete at most k characters from s such that the run-length encoded version of s has minimum length.\nFind the minimum length of the run-length encoded version of s after deleting at most k characters.\n \nExample 1:\n\nInput: s = \"aaabcccd\", k = 2\nOutput: 4\nExplanation: Compressing s without deleting anything will give us \"a3bc3d\" of length 6. Deleting any of the characters 'a' or 'c' would at most decrease the length of the compressed string to 5, for instance delete 2 'a' then we will have s = \"abcccd\" which compressed is abc3d. Therefore, the optimal way is to delete 'b' and 'd', then the compressed version of s will be \"a3c3\" of length 4.\nExample 2:\n\nInput: s = \"aabbaa\", k = 2\nOutput: 2\nExplanation: If we delete both 'b' characters, the resulting compressed string would be \"a4\" of length 2.\n\nExample 3:\n\nInput: s = \"aaaaaaaaaaa\", k = 0\nOutput: 3\nExplanation: Since k is zero, we cannot delete anything. The compressed string is \"a11\" of length 3.\n\n \nConstraints:\n\n1 <= s.length <= 100\n0 <= k <= s.length\ns contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcabcabc\",k = 5) == 3\n assert candidate(s = \"aaabcccd\",k = 2) == 4\n assert candidate(s = \"aabcc\",k = 1) == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 20) == 32\n assert candidate(s = \"aabccabcc\",k = 2) == 5\n assert candidate(s = \"nnnhoorq\",k = 2) == 5\n assert candidate(s = \"aaaaaaaaaaa\",k = 0) == 3\n assert candidate(s = \"aabbaa\",k = 2) == 2\n assert candidate(s = \"abbbcccaaaa\",k = 3) == 5\n assert candidate(s = \"abbbabbbcabbbabbbb\",k = 3) == 6\n assert candidate(s = \"aabbccddeeff\",k = 6) == 6\n assert candidate(s = \"abababababababababababababababababababab\",k = 15) == 12\n assert candidate(s = \"a\",k = 0) == 1\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 10) == 3\n assert candidate(s = \"aabbbcccbbaa\",k = 3) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 3\n assert candidate(s = \"abcdabcdabcd\",k = 6) == 5\n assert candidate(s = \"a\",k = 1) == 0\n assert candidate(s = \"aabbcc\",k = 1) == 5\n assert candidate(s = \"aabcccccaaa\",k = 2) == 5\n assert candidate(s = \"abcde\",k = 2) == 3\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 15) == 21\n assert candidate(s = \"aabbccddeeff\",k = 4) == 8\n assert candidate(s = \"abcdefghijaaaaaaaaaaaaaa\",k = 5) == 8\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzz\",k = 30) == 23\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",k = 25) == 64\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 30) == 14\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",k = 35) == 18\n assert candidate(s = \"mississippi\",k = 3) == 6\n assert candidate(s = \"aaaaaabbbbccccddddeeeeffffgggghhhh\",k = 8) == 12\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 15) == 58\n assert candidate(s = \"abacabadabacaba\",k = 5) == 6\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyx\",k = 30) == 25\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 25) == 3\n assert candidate(s = \"aaabbbcccddddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwww\",k = 30) == 26\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbcccccccccccdddddddddd\",k = 20) == 6\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\",k = 5) == 8\n assert candidate(s = \"mnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopq\",k = 10) == 75\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzz\",k = 10) == 18\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 25) == 53\n assert candidate(s = \"aaabaaaacaaadaaaeaaafaaagaaahaaaiaaa\",k = 10) == 3\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 25) == 26\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 30) == 3\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcde\",k = 25) == 60\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",k = 10) == 16\n assert candidate(s = \"abababababab\",k = 3) == 7\n assert candidate(s = \"zzzzzyyyyyxxxyyyxxxxzzzzzzz\",k = 15) == 3\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 20) == 55\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 26) == 26\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\",k = 15) == 15\n assert candidate(s = \"ppppppppppqqqqqqqqqqrrrrrrrrrrsssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\",k = 50) == 3\n assert candidate(s = \"abbbcccdddeeeeeffgggghhhiiijjjjj\",k = 10) == 12\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 25) == 3\n assert candidate(s = \"aabbaacccaaadd\",k = 4) == 6\n assert candidate(s = \"abbbccccddee\",k = 4) == 5\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababab\",k = 20) == 50\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbccccccccddddddddeeeeeeeeeffffffffgggggggghhhhhhhhiiiiiiiiijjjjjjj\",k = 25) == 14\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\",k = 30) == 3\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 25) == 27\n assert candidate(s = \"ababababababababababababababababababababab\",k = 10) == 24\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\",k = 15) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 30) == 3\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 5) == 24\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 30) == 26\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",k = 20) == 59\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcd\",k = 12) == 13\n assert candidate(s = \"wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\",k = 45) == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 0) == 52\n assert candidate(s = \"abcdefg\",k = 3) == 4\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 3\n assert candidate(s = \"aabbaabbaabbaabbaabbaabb\",k = 10) == 4\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 50) == 0\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 20) == 52\n assert candidate(s = \"abababababababababababababab\",k = 10) == 10\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\",k = 50) == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzz\",k = 40) == 13\n assert candidate(s = \"aaaaabbbbbaaaaabbbbbaaaaabbbbbaaaaabbbbbaaaaa\",k = 10) == 11\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbcccccdddddeeeeeeeeeeee\",k = 20) == 5\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 15) == 37\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeee\",k = 10) == 10\n assert candidate(s = \"ppppppqqqqqqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrsssssssssssttttttttttt\",k = 30) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 3\n assert candidate(s = \"aaaaaaaaaaabbbbbbbbbbbccccccccccdddddddddd\",k = 10) == 8\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggg\",k = 25) == 10\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().getLengthOfOptimalCompression", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getLengthOfOptimalCompression(self, s: str, k: int) -> int:", "container": "Solution", "callable": "getLengthOfOptimalCompression", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1534, "task_id": "count-good-triplets", "difficulty": "Easy", "problem_description": "Given an array of integers arr, and three integers a, b and c. You need to find the number of good triplets.\\r\n\\r\nA triplet (arr[i], arr[j], arr[k]) is good if the following conditions are true:\\r\n\\r\n\\r\n\t0 <= i < j < k < arr.length\\r\n\t|arr[i] - arr[j]| <= a\\r\n\t|arr[j] - arr[k]| <= b\\r\n\t|arr[i] - arr[k]| <= c\\r\n\\r\n\\r\nWhere |x| denotes the absolute value of x.\\r\n\\r\nReturn the number of good triplets.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: arr = [3,0,1,1,9,7], a = 7, b = 2, c = 3\\r\nOutput: 4\\r\nExplanation: There are 4 good triplets: [(3,0,1), (3,0,1), (3,1,1), (0,1,1)].\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: arr = [1,1,2,2,3], a = 0, b = 0, c = 1\\r\nOutput: 0\\r\nExplanation: No triplet satisfies all conditions.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t3 <= arr.length <= 100\\r\n\t0 <= arr[i] <= 1000\\r\n\t0 <= a, b, c <= 1000\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [3, 0, 1, 1, 9, 7],a = 7,b = 2,c = 3) == 4\n assert candidate(arr = [1, 3, 5, 7, 9],a = 2,b = 3,c = 4) == 3\n assert candidate(arr = [1, 1, 2, 2, 3],a = 0,b = 0,c = 1) == 0\n assert candidate(arr = [10, 20, 30, 40, 50],a = 5,b = 10,c = 15) == 0\n assert candidate(arr = [10, 20, 30, 40, 50],a = 15,b = 25,c = 35) == 5\n assert candidate(arr = [0, 0, 0, 0, 0],a = 0,b = 0,c = 0) == 10\n assert candidate(arr = [10, 20, 30, 40, 50],a = 15,b = 15,c = 15) == 0\n assert candidate(arr = [10, 20, 30, 40, 50],a = 10,b = 10,c = 10) == 0\n assert candidate(arr = [1, 3, 5, 7, 9],a = 2,b = 2,c = 2) == 0\n assert candidate(arr = [0, 0, 0, 0, 0],a = 1,b = 1,c = 1) == 10\n assert candidate(arr = [0, 0, 0, 0],a = 1,b = 1,c = 1) == 4\n assert candidate(arr = [1, 5, 6, 8, 10, 14, 15, 18, 20, 22],a = 4,b = 3,c = 5) == 8\n assert candidate(arr = [5, 8, 12, 15, 19, 22, 25, 28, 31, 34],a = 5,b = 7,c = 10) == 14\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],a = 1,b = 1,c = 2) == 88\n assert candidate(arr = [5, 8, 12, 15, 18, 22, 25, 28, 31],a = 5,b = 5,c = 10) == 7\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],a = 2,b = 2,c = 4) == 44\n assert candidate(arr = [10, 20, 20, 20, 30, 40, 50, 60, 70, 80],a = 5,b = 5,c = 10) == 1\n assert candidate(arr = [7, 1, 5, 3, 6, 4, 2, 8, 9],a = 2,b = 3,c = 4) == 20\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],a = 2,b = 2,c = 2) == 8\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],a = 0,b = 0,c = 0) == 1140\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900],a = 150,b = 250,c = 350) == 13\n assert candidate(arr = [5, 8, 12, 15, 20, 22, 25],a = 5,b = 6,c = 7) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],a = 0,b = 0,c = 0) == 120\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],a = 10,b = 20,c = 30) == 25\n assert candidate(arr = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],a = 5,b = 10,c = 15) == 25\n assert candidate(arr = [5, 8, 8, 10, 15, 17],a = 5,b = 3,c = 8) == 5\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33],a = 4,b = 4,c = 8) == 7\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4],a = 1,b = 1,c = 2) == 54\n assert candidate(arr = [15, 10, 15, 10, 15, 10, 15],a = 5,b = 5,c = 10) == 35\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 200,c = 300) == 15\n assert candidate(arr = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0],a = 100,b = 200,c = 300) == 17\n assert candidate(arr = [9, 7, 5, 3, 1, 2, 4, 6, 8, 0],a = 1,b = 2,c = 3) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],a = 2,b = 2,c = 3) == 37\n assert candidate(arr = [7, 3, 19, 5, 11, 13, 17, 15, 2, 9],a = 6,b = 5,c = 10) == 24\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],a = 1,b = 1,c = 2) == 132\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],a = 0,b = 0,c = 0) == 120\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],a = 2,b = 3,c = 4) == 58\n assert candidate(arr = [5, 8, 2, 3, 6, 9, 10, 12],a = 3,b = 4,c = 5) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],a = 1,b = 2,c = 3) == 25\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900],a = 100,b = 100,c = 100) == 0\n assert candidate(arr = [100, 200, 150, 300, 250, 400, 350, 500, 450, 600],a = 50,b = 100,c = 150) == 6\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 150,b = 200,c = 250) == 8\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],a = 20,b = 30,c = 40) == 64\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],a = 5,b = 5,c = 5) == 120\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],a = 0,b = 0,c = 0) == 120\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 0,b = 0,c = 1) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 3,b = 3,c = 3) == 324\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],a = 1,b = 1,c = 2) == 120\n assert candidate(arr = [4, 9, 1, 3, 13, 12, 7],a = 6,b = 4,c = 10) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 2,c = 4) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 1,b = 1,c = 2) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [8, 12, 15, 20, 25, 30, 35, 40, 45, 50],a = 5,b = 10,c = 15) == 15\n assert candidate(arr = [5, 8, 12, 15, 16, 20, 25, 30],a = 7,b = 5,c = 10) == 12\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],a = 4,b = 8,c = 12) == 15\n assert candidate(arr = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],a = 0,b = 0,c = 0) == 455\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],a = 4,b = 8,c = 12) == 25\n assert candidate(arr = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50],a = 15,b = 25,c = 35) == 17\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4],a = 0,b = 0,c = 0) == 84\n assert candidate(arr = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],a = 1,b = 1,c = 2) == 9\n assert candidate(arr = [2, 5, 1, 2, 10, 9, 10, 6],a = 4,b = 4,c = 7) == 15\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],a = 0,b = 0,c = 0) == 455\n assert candidate(arr = [5, 3, 7, 8, 2, 1, 9, 6, 4, 10],a = 5,b = 5,c = 5) == 60\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],a = 10,b = 20,c = 30) == 166\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],a = 9,b = 19,c = 29) == 0\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],a = 4,b = 5,c = 6) == 0\n assert candidate(arr = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],a = 5,b = 5,c = 5) == 60\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],a = 15,b = 15,c = 20) == 8\n assert candidate(arr = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],a = 10,b = 10,c = 10) == 120\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 2,b = 3,c = 5) == 8\n assert candidate(arr = [1, 5, 3, 2, 4, 8, 7, 6, 9, 0],a = 3,b = 3,c = 5) == 34\n assert candidate(arr = [34, 23, 54, 28, 90, 56, 78, 45, 12, 67],a = 20,b = 25,c = 30) == 15\n assert candidate(arr = [50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],a = 5,b = 10,c = 15) == 17\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],a = 1,b = 1,c = 1) == 120\n assert candidate(arr = [7, 3, 8, 1, 4, 6, 5, 2, 9, 0],a = 1,b = 1,c = 2) == 3\n assert candidate(arr = [15, 15, 15, 20, 20, 20, 25, 25, 25],a = 5,b = 5,c = 10) == 66\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],a = 0,b = 0,c = 0) == 1140\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],a = 1,b = 1,c = 2) == 100\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],a = 10,b = 20,c = 30) == 15\n assert candidate(arr = [5, 8, 2, 4, 3, 7, 6, 9, 1],a = 3,b = 4,c = 5) == 35\n assert candidate(arr = [30, 40, 50, 60, 70, 80, 90, 100, 110],a = 10,b = 10,c = 20) == 7\n assert candidate(arr = [2, 2, 2, 2, 2],a = 0,b = 0,c = 0) == 10\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],a = 15,b = 25,c = 35) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [1, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 4,b = 5,c = 6) == 214\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],a = 10,b = 10,c = 20) == 8\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49],a = 4,b = 6,c = 8) == 11\n assert candidate(arr = [8, 1, 3, 2, 10, 1, 4],a = 1,b = 2,c = 3) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 150,c = 200) == 8\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10],a = 3,b = 3,c = 4) == 152\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],a = 15,b = 20,c = 25) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10],a = 1,b = 1,c = 2) == 112\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],a = 3,b = 4,c = 5) == 0\n assert candidate(arr = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],a = 1,b = 2,c = 3) == 15\n assert candidate(arr = [0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],a = 1,b = 1,c = 2) == 124\n assert candidate(arr = [5, 1, 4, 1, 3, 6, 2],a = 2,b = 3,c = 5) == 14\n assert candidate(arr = [5, 8, 12, 15, 16, 23, 42],a = 5,b = 7,c = 10) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 0,b = 0,c = 0) == 0\n"}, "metadata": {"canonical_parameter_names": ["arr", "a", "b", "c"], "leetcode_dataset_entry_point": "Solution().countGoodTriplets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countGoodTriplets(self, arr: List[int], a: int, b: int, c: int) -> int:", "container": "Solution", "callable": "countGoodTriplets", "parameters": [{"name": "arr", "type": "List[int]"}, {"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1535, "task_id": "find-the-winner-of-an-array-game", "difficulty": "Medium", "problem_description": "Given an integer array arr of distinct integers and an integer k.\nA game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0, and the smaller integer moves to the end of the array. The game ends when an integer wins k consecutive rounds.\nReturn the integer which will win the game.\nIt is guaranteed that there will be a winner of the game.\n \nExample 1:\n\nInput: arr = [2,1,3,5,4,6,7], k = 2\nOutput: 5\nExplanation: Let's see the rounds of the game:\nRound | arr | winner | win_count\n 1 | [2,1,3,5,4,6,7] | 2 | 1\n 2 | [2,3,5,4,6,7,1] | 3 | 1\n 3 | [3,5,4,6,7,1,2] | 5 | 1\n 4 | [5,4,6,7,1,2,3] | 5 | 2\nSo we can see that 4 rounds will be played and 5 is the winner because it wins 2 consecutive games.\n\nExample 2:\n\nInput: arr = [3,2,1], k = 10\nOutput: 3\nExplanation: 3 will win the first 10 rounds consecutively.\n\n \nConstraints:\n\n2 <= arr.length <= 105\n1 <= arr[i] <= 106\narr contains distinct integers.\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 1, 3, 5, 4, 6, 7],k = 2) == 5\n assert candidate(arr = [7, 10, 5, 3, 8],k = 3) == 10\n assert candidate(arr = [5, 4, 3, 2, 1],k = 1) == 5\n assert candidate(arr = [3, 2, 1],k = 10) == 3\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 4) == 100\n assert candidate(arr = [5, 1, 4, 2, 3],k = 4) == 5\n assert candidate(arr = [1, 2, 3, 4, 5],k = 1) == 2\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5],k = 3) == 5\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1],k = 3) == 7\n assert candidate(arr = [7, 6, 5, 8, 4, 3, 2, 1],k = 4) == 8\n assert candidate(arr = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10],k = 7) == 10\n assert candidate(arr = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],k = 7) == 999999\n assert candidate(arr = [5, 1, 9, 3, 7, 2, 8, 4, 6],k = 4) == 9\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 6) == 19\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10],k = 2) == 7\n assert candidate(arr = [500000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 10) == 500000\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 1) == 3\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 50) == 100\n assert candidate(arr = [2, 1, 3, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 20\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 3) == 20\n assert candidate(arr = [7, 14, 28, 8, 16, 32, 4, 2, 1],k = 6) == 32\n assert candidate(arr = [1000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 1000000\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1000000) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 200\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 1) == 3\n assert candidate(arr = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 19\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19],k = 3) == 20\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 10) == 10\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 7) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 10\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 8) == 20\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5) == 19\n assert candidate(arr = [5, 8, 4, 9, 3, 2, 1, 6, 7, 10],k = 6) == 9\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 100\n assert candidate(arr = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 100\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 100) == 100\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995, 999994],k = 6) == 1000000\n assert candidate(arr = [4, 8, 6, 2, 7, 3, 9, 1, 5, 10],k = 6) == 10\n assert candidate(arr = [50, 20, 30, 10, 40],k = 3) == 50\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 3) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 500000],k = 10) == 500000\n assert candidate(arr = [5, 1, 4, 3, 2],k = 4) == 5\n assert candidate(arr = [5, 2, 9, 1, 7, 8, 3, 6, 4],k = 5) == 9\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10],k = 7) == 9\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 7) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 30\n assert candidate(arr = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5],k = 3) == 50\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 7) == 30\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 20\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 4) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 10\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 10) == 1000000\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 5) == 1000000\n assert candidate(arr = [9, 3, 5, 2, 8, 1, 7, 6, 4, 10],k = 2) == 9\n assert candidate(arr = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],k = 3) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 19\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 2) == 9\n assert candidate(arr = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989],k = 10) == 100000\n assert candidate(arr = [5, 1, 4, 2, 3],k = 4) == 5\n assert candidate(arr = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],k = 4) == 5\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15],k = 8) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 30\n assert candidate(arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 20) == 30\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10],k = 4) == 7\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 3) == 100\n assert candidate(arr = [5, 3, 8, 6, 7, 2, 4, 9, 1],k = 4) == 8\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10],k = 1) == 9\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 3) == 10\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1, 12, 11, 10, 9, 8],k = 5) == 7\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97],k = 3) == 100\n assert candidate(arr = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11],k = 5) == 89\n assert candidate(arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],k = 3) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 2\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],k = 5) == 20\n assert candidate(arr = [1, 25, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 25\n assert candidate(arr = [7, 14, 4, 14, 13, 2, 6, 13],k = 3) == 14\n assert candidate(arr = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 2) == 2\n assert candidate(arr = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10],k = 3) == 5\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 5) == 10\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == 1000\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 25) == 100\n assert candidate(arr = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5],k = 10) == 99\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == 15\n assert candidate(arr = [23, 11, 45, 78, 90, 67, 34, 21, 56, 89],k = 4) == 90\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 9) == 1000\n assert candidate(arr = [7, 10, 4, 3, 20, 15, 6, 1, 2, 8, 5, 9],k = 4) == 20\n assert candidate(arr = [100, 200, 50, 150, 250, 500, 400, 300, 600, 700],k = 7) == 700\n assert candidate(arr = [7, 8, 9, 10, 11, 5, 6, 1, 2, 3, 4],k = 3) == 11\n assert candidate(arr = [500, 400, 300, 200, 100, 101, 102, 103, 104, 105],k = 3) == 500\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19],k = 10) == 20\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 1) == 10\n assert candidate(arr = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10],k = 2) == 3\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 9\n assert candidate(arr = [1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16, 17, 19, 18, 20],k = 5) == 20\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 4) == 100\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 10\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 12) == 75\n"}, "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().getWinner", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getWinner(self, arr: list[int], k: int) -> int:", "container": "Solution", "callable": "getWinner", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1536, "task_id": "minimum-swaps-to-arrange-a-binary-grid", "difficulty": "Medium", "problem_description": "Given an n x n binary grid, in one step you can choose two adjacent rows of the grid and swap them.\nA grid is said to be valid if all the cells above the main diagonal are zeros.\nReturn the minimum number of steps needed to make the grid valid, or -1 if the grid cannot be valid.\nThe main diagonal of a grid is the diagonal that starts at cell (1, 1) and ends at cell (n, n).\n \nExample 1:\n\n\nInput: grid = [[0,0,1],[1,1,0],[1,0,0]]\nOutput: 3\n\nExample 2:\n\n\nInput: grid = [[0,1,1,0],[0,1,1,0],[0,1,1,0],[0,1,1,0]]\nOutput: -1\nExplanation: All rows are similar, swaps have no effect on the grid.\n\nExample 3:\n\n\nInput: grid = [[1,0,0],[1,1,0],[1,1,1]]\nOutput: 0\n\n \nConstraints:\n\nn == grid.length == grid[i].length\n1 <= n <= 200\ngrid[i][j] is either 0 or 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 1], [1, 1, 0], [1, 0, 0]]) == 3\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0]]) == 3\n assert candidate(grid = [[0, 0, 0], [0, 0, 1], [0, 1, 0]]) == 1\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 0, 0], [1, 1, 0], [1, 1, 1]]) == 0\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 28\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1], [0, 0, 1, 1, 1], [0, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == 6\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1], [1, 1, 0, 1, 1, 1], [1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 0, 1], [1, 1, 1, 1, 1, 0]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 55\n assert candidate(grid = [[0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0]]) == 2\n assert candidate(grid = [[0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[0, 1, 1, 1, 1], [1, 0, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 0, 1], [1, 1, 1, 1, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 1], [0, 0, 1, 1, 1], [0, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 1, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 1], [0, 0, 1, 1, 0], [0, 1, 1, 0, 0], [1, 1, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 1, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 0, 0], [1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 1, 1, 0], [1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0]]) == 8\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minSwaps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minSwaps(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "minSwaps", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1537, "task_id": "get-the-maximum-score", "difficulty": "Hard", "problem_description": "You are given two sorted arrays of distinct integers nums1 and nums2.\nA valid path is defined as follows:\n\nChoose array nums1 or nums2 to traverse (from index-0).\nTraverse the current array from left to right.\nIf you are reading any value that is present in nums1 and nums2 you are allowed to change your path to the other array. (Only one repeated value is considered in the valid path).\n\nThe score is defined as the sum of unique values in a valid path.\nReturn the maximum score you can obtain of all possible valid paths. Since the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: nums1 = [2,4,5,8,10], nums2 = [4,6,8,9]\nOutput: 30\nExplanation: Valid paths:\n[2,4,5,8,10], [2,4,5,8,9], [2,4,6,8,9], [2,4,6,8,10], (starting from nums1)\n[4,6,8,9], [4,5,8,10], [4,5,8,9], [4,6,8,10] (starting from nums2)\nThe maximum is obtained with the path in green [2,4,6,8,10].\n\nExample 2:\n\nInput: nums1 = [1,3,5,7,9], nums2 = [3,5,100]\nOutput: 109\nExplanation: Maximum sum is obtained with the path [1,3,5,100].\n\nExample 3:\n\nInput: nums1 = [1,2,3,4,5], nums2 = [6,7,8,9,10]\nOutput: 40\nExplanation: There are no common elements between nums1 and nums2.\nMaximum sum is obtained with the path [6,7,8,9,10].\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 105\n1 <= nums1[i], nums2[i] <= 107\nnums1 and nums2 are strictly increasing.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [10000000],nums2 = [10000000]) == 10000000\n assert candidate(nums1 = [2, 4, 5, 8, 10],nums2 = [4, 6, 8, 9]) == 30\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6, 7, 8, 9, 10]) == 49\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 155\n assert candidate(nums1 = [1, 4, 6, 8, 10],nums2 = [2, 4, 6, 8, 12]) == 32\n assert candidate(nums1 = [5, 10, 15, 20],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [3, 5, 100]) == 109\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10]) == 40\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 4, 5]) == 15\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45, 55]) == 180\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [3, 4, 5, 6, 7, 8]) == 36\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [5, 15, 25, 35, 45]) == 125\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 15\n assert candidate(nums1 = [1, 10000000],nums2 = [2, 9999999]) == 10000001\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 150\n assert candidate(nums1 = [1],nums2 = [1]) == 1\n assert candidate(nums1 = [1, 4, 6, 8],nums2 = [2, 3, 5, 7]) == 19\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],nums2 = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 4095\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 605\n assert candidate(nums1 = [9999991, 9999992, 9999993, 9999994, 9999995, 9999996, 9999997, 9999998, 9999999, 10000000],nums2 = [10000001, 10000002, 10000003, 10000004, 10000005, 10000006, 10000007, 10000008, 10000009, 10000010]) == 100000055\n assert candidate(nums1 = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 551\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [5, 15, 25, 35, 45]) == 275\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 135\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 240\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 550\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1300\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 195\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums1 = [1, 4, 6, 7, 10, 20, 30],nums2 = [2, 4, 5, 7, 11, 12, 15, 20]) == 107\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 100\n assert candidate(nums1 = [1, 4, 6, 7, 8, 10, 15, 20],nums2 = [2, 4, 5, 7, 9, 10, 13, 18]) == 73\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(nums1 = [2, 3, 6, 7, 11, 15],nums2 = [1, 2, 3, 8, 12, 16, 20]) == 62\n assert candidate(nums1 = [1, 2, 3, 5, 7, 9, 11, 13, 15, 17],nums2 = [4, 6, 8, 10, 12, 14, 16, 18, 20]) == 108\n assert candidate(nums1 = [1000000, 2000000, 3000000, 4000000, 5000000],nums2 = [1500000, 2500000, 3500000, 4500000, 5500000]) == 17500000\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums1 = [5, 15, 25, 35, 45],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 225\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5]) == 55\n assert candidate(nums1 = [10000000, 20000000, 30000000, 40000000, 50000000],nums2 = [15000000, 20000000, 25000000, 35000000, 40000000, 45000000, 55000000]) == 235000000\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 110\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],nums2 = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44]) == 990\n assert candidate(nums1 = [1, 4, 5, 6, 10, 15, 20, 25],nums2 = [2, 4, 7, 10, 12, 15, 22]) == 99\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],nums2 = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == 3069\n assert candidate(nums1 = [1, 10000000],nums2 = [5000000, 10000000]) == 15000000\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 3, 5, 8, 9, 10, 12, 15, 18, 20]) == 104\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 120\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],nums2 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 208\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == 6000\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 240\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],nums2 = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98]) == 1250\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 240\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 550\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 420\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 420\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45, 55]) == 180\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 121\n assert candidate(nums1 = [1, 10000000],nums2 = [2, 9999999]) == 10000001\n assert candidate(nums1 = [1, 100, 1000, 10000, 100000],nums2 = [10, 100, 1000, 10000, 100000, 1000000]) == 1111110\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000],nums2 = [2, 20, 200, 2000, 20000, 200000, 2000000, 20000000]) == 22222222\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [15, 20, 25, 35, 40, 45, 55, 65, 70, 75, 85, 95]) == 640\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000],nums2 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 11111111\n assert candidate(nums1 = [1, 2, 4, 5, 7, 8, 10, 12],nums2 = [3, 4, 6, 7, 9, 10, 11, 13]) == 63\n assert candidate(nums1 = [1, 3, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 3, 5, 7, 11, 13, 17, 18, 19]) == 119\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 365\n assert candidate(nums1 = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 306\n assert candidate(nums1 = [10000000],nums2 = [9999999, 10000000, 10000001]) == 30000000\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 145\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],nums2 = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29]) == 155\n assert candidate(nums1 = [2, 6, 10, 14, 18],nums2 = [3, 6, 9, 12, 15, 18, 21]) == 84\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40],nums2 = [10, 20, 30, 40, 50, 60, 70]) == 360\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 435\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 300\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18, 21, 24],nums2 = [2, 5, 8, 11, 14, 17, 20, 23, 26]) == 126\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [1, 3, 5, 7, 9, 10, 12]) == 47\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [2, 5, 8, 11, 14, 17, 20]) == 77\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 730\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],nums2 = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58]) == 450\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1300\n assert candidate(nums1 = [10000000],nums2 = [5000000, 10000000, 15000000]) == 30000000\n assert candidate(nums1 = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 500\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [2, 4, 6, 8, 10, 12, 14]) == 78\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 490\n assert candidate(nums1 = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45],nums2 = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44]) == 345\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 365\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 10, 15, 20, 25]) == 115\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],nums2 = [512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456]) == 536870911\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 605\n assert candidate(nums1 = [1, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 435\n assert candidate(nums1 = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 2500\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 105\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],nums2 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 1290\n assert candidate(nums1 = [1, 5, 10, 20, 30, 40, 50],nums2 = [3, 10, 15, 25, 35, 45, 55]) == 191\n assert candidate(nums1 = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000],nums2 = [250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2250, 2500]) == 33750\n assert candidate(nums1 = [1000000, 2000000, 3000000, 4000000, 5000000],nums2 = [500000, 1000000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000, 4500000, 5000000]) == 27500000\n assert candidate(nums1 = [1, 10, 20, 30, 40],nums2 = [5, 15, 25, 35, 45]) == 125\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [3, 4, 9, 10, 15, 16, 20]) == 77\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [1, 5, 9, 13, 17, 21]) == 73\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18]) == 91\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 335\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],nums2 = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98]) == 1250\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maxSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxSum(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "maxSum", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1539, "task_id": "kth-missing-positive-number", "difficulty": "Easy", "problem_description": "Given an array arr of positive integers sorted in a strictly increasing order, and an integer k.\nReturn the kth positive integer that is missing from this array.\n \nExample 1:\n\nInput: arr = [2,3,4,7,11], k = 5\nOutput: 9\nExplanation: The missing positive integers are [1,5,6,8,9,10,12,13,...]. The 5th missing positive integer is 9.\n\nExample 2:\n\nInput: arr = [1,2,3,4], k = 2\nOutput: 6\nExplanation: The missing positive integers are [5,6,7,...]. The 2nd missing positive integer is 6.\n\n \nConstraints:\n\n1 <= arr.length <= 1000\n1 <= arr[i] <= 1000\n1 <= k <= 1000\narr[i] < arr[j] for 1 <= i < j <= arr.length\n\n \nFollow up:\nCould you solve this problem in less than O(n) complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 20\n assert candidate(arr = [10, 20, 30],k = 15) == 16\n assert candidate(arr = [2, 3, 4, 7, 11],k = 5) == 9\n assert candidate(arr = [5, 6, 7, 8, 9],k = 1) == 1\n assert candidate(arr = [5, 6, 8, 9, 10],k = 3) == 3\n assert candidate(arr = [1, 3, 5, 7],k = 3) == 6\n assert candidate(arr = [1, 3, 5, 7, 9],k = 4) == 8\n assert candidate(arr = [10, 20, 30],k = 5) == 5\n assert candidate(arr = [1, 2, 3, 4, 8, 10, 11],k = 5) == 12\n assert candidate(arr = [1, 2, 3, 4],k = 2) == 6\n assert candidate(arr = [10, 20, 30, 40],k = 15) == 16\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58],k = 60) == 80\n assert candidate(arr = [2, 5, 9, 11, 15, 18, 22, 25],k = 15) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 120\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 500) == 509\n assert candidate(arr = [5, 6, 8, 9, 11, 14, 17, 18, 21],k = 10) == 16\n assert candidate(arr = [5, 10, 15, 20, 25],k = 15) == 18\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 20) == 24\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],k = 25) == 29\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127],k = 200) == 207\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],k = 120) == 145\n assert candidate(arr = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59],k = 30) == 40\n assert candidate(arr = [2, 5, 10, 17, 26, 37, 49, 62, 76, 91, 107, 124, 142, 161, 181],k = 25) == 30\n assert candidate(arr = [1, 4, 6, 8, 11, 13, 15, 17, 19, 22, 24, 26, 28, 30, 32],k = 20) == 35\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 30) == 55\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1000],k = 1000) == 1011\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 15) == 25\n assert candidate(arr = [1, 4, 8, 13, 18, 23, 28, 33, 38],k = 20) == 26\n assert candidate(arr = [1, 4, 6, 9, 11, 15, 17, 20, 23],k = 10) == 16\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 200) == 221\n assert candidate(arr = [1, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 25) == 35\n assert candidate(arr = [5, 10, 15, 20, 25],k = 10) == 12\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 100) == 110\n assert candidate(arr = [2, 5, 10, 15, 20, 25, 30, 35, 40, 45],k = 15) == 19\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 75) == 94\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],k = 150) == 164\n assert candidate(arr = [1, 2, 5, 8, 10, 13, 16, 19, 22, 25],k = 18) == 28\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 60\n assert candidate(arr = [2, 6, 10, 14, 18, 22, 26],k = 15) == 20\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 75) == 84\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 30) == 40\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 30) == 34\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120],k = 150) == 165\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],k = 25) == 28\n assert candidate(arr = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14],k = 25) == 35\n assert candidate(arr = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71],k = 50) == 63\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100],k = 100) == 134\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 25) == 45\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 50) == 54\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],k = 30) == 40\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],k = 100) == 110\n assert candidate(arr = [25, 50, 75, 100, 125, 150, 175, 200],k = 50) == 52\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 75) == 90\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 19\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 7) == 10\n assert candidate(arr = [3, 7, 11, 15, 19, 23, 27, 31, 35],k = 20) == 26\n assert candidate(arr = [3, 8, 12, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79],k = 50) == 66\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],k = 30) == 34\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 50) == 57\n assert candidate(arr = [2, 5, 9, 12, 15, 18, 21, 24, 27, 30],k = 20) == 29\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],k = 50) == 58\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 30\n assert candidate(arr = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99],k = 40) == 48\n assert candidate(arr = [1, 2, 3, 5, 6, 7, 9, 10, 12, 13, 15, 16, 18, 19, 21],k = 30) == 45\n assert candidate(arr = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597],k = 100) == 109\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 10) == 19\n assert candidate(arr = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 15) == 26\n assert candidate(arr = [1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 14, 15, 16, 18, 19, 20],k = 15) == 31\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45],k = 30) == 38\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 7) == 10\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 450) == 454\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 500) == 550\n assert candidate(arr = [5, 10, 15, 20, 25, 30],k = 12) == 14\n assert candidate(arr = [2, 5, 7, 11, 14, 17, 20, 23, 26, 29],k = 40) == 50\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 150) == 171\n assert candidate(arr = [1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 17, 18, 20],k = 50) == 64\n assert candidate(arr = [4, 9, 14, 19, 24, 29, 34, 39, 44, 49],k = 25) == 31\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55],k = 10) == 16\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],k = 100) == 150\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 500) == 505\n assert candidate(arr = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],k = 50) == 58\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25],k = 25) == 34\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220],k = 75) == 82\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 15) == 18\n assert candidate(arr = [2, 5, 8, 11, 15],k = 10) == 14\n assert candidate(arr = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255],k = 60) == 64\n assert candidate(arr = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 30) == 51\n assert candidate(arr = [300, 600, 900],k = 1000) == 1003\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],k = 1000) == 1015\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 100) == 110\n assert candidate(arr = [1, 2, 3, 5, 6, 9, 11, 12, 15],k = 15) == 24\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165],k = 40) == 43\n assert candidate(arr = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],k = 100) == 102\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 150) == 175\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 50) == 58\n assert candidate(arr = [2, 3, 5, 8, 12, 17, 23, 30, 38, 47],k = 35) == 44\n assert candidate(arr = [5, 6, 8, 10, 13, 14],k = 7) == 11\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 25) == 35\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42],k = 20) == 29\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 500) == 505\n assert candidate(arr = [5, 8, 12, 14, 20, 25],k = 8) == 10\n assert candidate(arr = [5, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 17\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 20) == 35\n assert candidate(arr = [1, 2, 4, 7, 11, 15, 19, 24, 29, 35],k = 20) == 28\n assert candidate(arr = [11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50],k = 27) == 36\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],k = 25) == 32\n assert candidate(arr = [1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26],k = 50) == 64\n assert candidate(arr = [2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 102, 112, 122, 132, 142, 152, 162, 172, 182, 192, 202, 212, 222, 232, 242, 252, 262, 272, 282, 292, 302],k = 150) == 167\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],k = 13) == 15\n"}, "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().findKthPositive", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findKthPositive(self, arr: list[int], k: int) -> int:", "container": "Solution", "callable": "findKthPositive", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1540, "task_id": "can-convert-string-in-k-moves", "difficulty": "Medium", "problem_description": "Given two strings s and t, your goal is to convert s into t in k moves or less.\nDuring the ith (1 <= i <= k) move you can:\n\nChoose any index j (1-indexed) from s, such that 1 <= j <= s.length and j has not been chosen in any previous move, and shift the character at that index i times.\nDo nothing.\n\nShifting a character means replacing it by the next letter in the alphabet (wrapping around so that 'z' becomes 'a'). Shifting a character by i means applying the shift operations i times.\nRemember that any index j can be picked at most once.\nReturn true if it's possible to convert s into t in no more than k moves, otherwise return false.\n \nExample 1:\n\nInput: s = \"input\", t = \"ouput\", k = 9\nOutput: true\nExplanation: In the 6th move, we shift 'i' 6 times to get 'o'. And in the 7th move we shift 'n' to get 'u'.\n\nExample 2:\n\nInput: s = \"abc\", t = \"bcd\", k = 10\nOutput: false\nExplanation: We need to shift each character in s one time to convert it into t. We can shift 'a' to 'b' during the 1st move. However, there is no way to shift the other characters in the remaining moves to obtain t from s.\n\nExample 3:\n\nInput: s = \"aab\", t = \"bbb\", k = 27\nOutput: true\nExplanation: In the 1st move, we shift the first 'a' 1 time to get 'b'. In the 27th move, we shift the second 'a' 27 times to get 'b'.\n\n \nConstraints:\n\n1 <= s.length, t.length <= 10^5\n0 <= k <= 10^9\ns, t contain only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abc\",t = \"abc\",k = 0) == True\n assert candidate(s = \"aaa\",t = \"zzz\",k = 702) == True\n assert candidate(s = \"abc\",t = \"bcd\",k = 10) == False\n assert candidate(s = \"abc\",t = \"xyz\",k = 702) == True\n assert candidate(s = \"abcd\",t = \"pqrs\",k = 100) == True\n assert candidate(s = \"zzz\",t = \"aaa\",k = 78) == True\n assert candidate(s = \"abcd\",t = \"pqrs\",k = 78) == False\n assert candidate(s = \"aaa\",t = \"abc\",k = 3) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcdefghijklmnopqrstuvwxyza\",k = 25) == False\n assert candidate(s = \"zzz\",t = \"aaa\",k = 25) == False\n assert candidate(s = \"aab\",t = \"bbb\",k = 27) == True\n assert candidate(s = \"a\",t = \"z\",k = 25) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"abcdefghijklmnopqrstuvwxyz\",k = 0) == True\n assert candidate(s = \"input\",t = \"ouput\",k = 9) == True\n assert candidate(s = \"repeatedchars\",t = \"sfpqeueftdsft\",k = 150) == True\n assert candidate(s = \"zzzzz\",t = \"aaaaa\",k = 122) == True\n assert candidate(s = \"aaaaaaaaaa\",t = \"zzzzzzzzzz\",k = 260) == True\n assert candidate(s = \"abcde\",t = \"edcba\",k = 155) == True\n assert candidate(s = \"wraparound\",t = \"xqcsbpsboe\",k = 150) == True\n assert candidate(s = \"abcdef\",t = \"fedcba\",k = 50) == True\n assert candidate(s = \"z\",t = \"a\",k = 1) == True\n assert candidate(s = \"xylophone\",t = \"xylophone\",k = 1) == True\n assert candidate(s = \"testcase\",t = \"testcase\",k = 0) == True\n assert candidate(s = \"pqrs\",t = \"abcd\",k = 76) == False\n assert candidate(s = \"xyz\",t = \"abc\",k = 25) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\",k = 104) == True\n assert candidate(s = \"longstringexample\",t = \"mpjutjvqygfqfcqpf\",k = 300) == True\n assert candidate(s = \"xyzzxyzz\",t = \"abcdabcd\",k = 156) == True\n assert candidate(s = \"zzz\",t = \"abc\",k = 78) == True\n assert candidate(s = \"hello\",t = \"tqxxa\",k = 100) == False\n assert candidate(s = \"abcabcabc\",t = \"defdefdef\",k = 24) == False\n assert candidate(s = \"aaaaabbbbb\",t = \"bbbbbccccc\",k = 250) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",t = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 900) == True\n assert candidate(s = \"hello\",t = \"worry\",k = 100) == True\n assert candidate(s = \"python\",t = \"pythom\",k = 100) == True\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\",t = \"zptjhoqznbmmktgdobnkszemgsvx\",k = 1000) == False\n assert candidate(s = \"abcd\",t = \"dcba\",k = 10) == False\n assert candidate(s = \"mississippi\",t = \"ssissippi\",k = 100) == False\n assert candidate(s = \"hello\",t = \"khoor\",k = 15) == False\n assert candidate(s = \"almostthere\",t = \"bnmpsuusfsf\",k = 99) == False\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\",k = 260) == True\n assert candidate(s = \"shifting\",t = \"zmtxlqjq\",k = 300) == True\n assert candidate(s = \"abcde\",t = \"edcba\",k = 156) == True\n assert candidate(s = \"abc\",t = \"bcd\",k = 2) == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"bcccdddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzza\",k = 1000) == False\n assert candidate(s = \"conversion\",t = \"cvqfvkzqpo\",k = 100) == True\n assert candidate(s = \"xyz\",t = \"abc\",k = 24) == False\n assert candidate(s = \"abcxyz\",t = \"bcdyza\",k = 27) == False\n assert candidate(s = \"zzzzzzzzzz\",t = \"aaaaaaaaaa\",k = 259) == True\n assert candidate(s = \"hello\",t = \"uifsf\",k = 100) == True\n assert candidate(s = \"abc\",t = \"xyz\",k = 100) == True\n assert candidate(s = \"thisisatest\",t = \"ujkjkfbtftu\",k = 150) == True\n assert candidate(s = \"aaaaaaa\",t = \"zzzzzzz\",k = 702) == True\n assert candidate(s = \"abcd\",t = \"abcd\",k = 0) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1000) == True\n assert candidate(s = \"abcdabcdabcd\",t = \"efghefghijkl\",k = 100) == False\n assert candidate(s = \"aaaabbbb\",t = \"bbbbcccc\",k = 26) == False\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",t = \"bcdebcdebcdebcdebcdebcdebcdebcdebcdebcde\",k = 100) == False\n assert candidate(s = \"aaaaaaaaaaa\",t = \"bbbbbbbbbbb\",k = 1000) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",t = \"aaaaaaaaaaaaaaaaaaaa\",k = 260) == False\n assert candidate(s = \"ab\",t = \"yz\",k = 51) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zabcdefghijklmnopqrstuvwxy\",k = 51) == False\n assert candidate(s = \"abcdabcdabcd\",t = \"efefefefefef\",k = 80) == False\n assert candidate(s = \"hello\",t = \"world\",k = 20) == False\n assert candidate(s = \"aabbaabb\",t = \"bbccbbcc\",k = 25) == False\n assert candidate(s = \"aaaabbbb\",t = \"bbbbcccc\",k = 100) == False\n assert candidate(s = \"aaaa\",t = \"bbbb\",k = 26) == False\n assert candidate(s = \"abcabcabcabcabcabc\",t = \"defdefdefdefdefdef\",k = 260) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcdefghijklmnopqrstuvwxyza\",k = 200) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcdefghijklmnopqrstuvwxyza\",k = 26) == False\n assert candidate(s = \"azazaz\",t = \"bbbbbb\",k = 78) == True\n assert candidate(s = \"aabbcc\",t = \"bbccdd\",k = 29) == False\n assert candidate(s = \"abcdabcd\",t = \"bcdebcde\",k = 10) == False\n assert candidate(s = \"hello\",t = \"world\",k = 51) == True\n assert candidate(s = \"zzzz\",t = \"aaaa\",k = 104) == True\n assert candidate(s = \"aaaaaaaaaa\",t = \"bbbbbbbbbb\",k = 100) == False\n assert candidate(s = \"hello\",t = \"ifmmp\",k = 5) == False\n assert candidate(s = \"abcd\",t = \"dcba\",k = 104) == True\n assert candidate(s = \"abcd\",t = \"dcba\",k = 100) == True\n assert candidate(s = \"abacabadabacaba\",t = \"bcbbcadbbcbcbbc\",k = 200) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 675) == True\n assert candidate(s = \"aaaaaaaaaaaa\",t = \"bbbbbbbbbbbb\",k = 12) == False\n assert candidate(s = \"python\",t = \"python\",k = 0) == True\n assert candidate(s = \"abcabcabc\",t = \"defdefdef\",k = 26) == False\n assert candidate(s = \"hello\",t = \"world\",k = 52) == True\n assert candidate(s = \"abcdef\",t = \"ghijkl\",k = 18) == False\n assert candidate(s = \"xyz\",t = \"abc\",k = 77) == True\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\",k = 100) == True\n assert candidate(s = \"same\",t = \"same\",k = 10) == True\n assert candidate(s = \"programming\",t = \"qpsxstjnnqj\",k = 200) == True\n assert candidate(s = \"programming\",t = \"programming\",k = 1000) == True\n assert candidate(s = \"conversion\",t = \"wxvqivlxnt\",k = 500) == True\n assert candidate(s = \"thisisatest\",t = \"ytnsytyfyty\",k = 150) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\",t = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 1325) == True\n assert candidate(s = \"aaa\",t = \"zzz\",k = 701) == True\n assert candidate(s = \"a\",t = \"a\",k = 0) == True\n assert candidate(s = \"aaa\",t = \"zzz\",k = 78) == True\n assert candidate(s = \"conversion\",t = \"hxqzsrqvok\",k = 200) == True\n assert candidate(s = \"aaa\",t = \"abc\",k = 2) == True\n assert candidate(s = \"abcdefgh\",t = \"hgfedcba\",k = 50) == True\n assert candidate(s = \"abcabcabc\",t = \"defdefdef\",k = 78) == False\n assert candidate(s = \"mississippi\",t = \"vvvttttpppp\",k = 260) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcdefghijklmnopqrstuvwxyza\",k = 260) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zabcdefghijklmnopqrstuvwxy\",k = 100) == False\n assert candidate(s = \"racecar\",t = \"racecar\",k = 100) == True\n assert candidate(s = \"aabbcc\",t = \"bbccdd\",k = 30) == False\n assert candidate(s = \"aabbaabb\",t = \"bbccbbcc\",k = 26) == False\n assert candidate(s = \"aaaa\",t = \"zzzz\",k = 103) == True\n assert candidate(s = \"python\",t = \"qzuipo\",k = 65) == False\n assert candidate(s = \"zzzzz\",t = \"aaaab\",k = 130) == True\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",t = \"bcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdcb\",k = 260) == False\n assert candidate(s = \"mississippi\",t = \"aaaaaaaaaaa\",k = 130) == True\n assert candidate(s = \"yzyzyzyzyz\",t = \"acacacacac\",k = 520) == True\n assert candidate(s = \"hello\",t = \"world\",k = 50) == True\n assert candidate(s = \"quickbrownfox\",t = \"rvjdlqpsqfy\",k = 200) == False\n assert candidate(s = \"leetcode\",t = \"leetcode\",k = 0) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"bbaacceeggiikkmmppttuuwwyyzzeeddfgghhjjoonnuuxx\",k = 1000) == False\n assert candidate(s = \"longstringwithmultiplecharacters\",t = \"nqprxuixwqywwpdqfhhcifqtf\",k = 500) == False\n"}, "metadata": {"canonical_parameter_names": ["s", "t", "k"], "leetcode_dataset_entry_point": "Solution().canConvertString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canConvertString(self, s: str, t: str, k: int) -> bool:", "container": "Solution", "callable": "canConvertString", "parameters": [{"name": "s", "type": "str"}, {"name": "t", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1541, "task_id": "minimum-insertions-to-balance-a-parentheses-string", "difficulty": "Medium", "problem_description": "Given a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if:\n\nAny left parenthesis '(' must have a corresponding two consecutive right parenthesis '))'.\nLeft parenthesis '(' must go before the corresponding two consecutive right parenthesis '))'.\n\nIn other words, we treat '(' as an opening parenthesis and '))' as a closing parenthesis.\n\nFor example, \"())\", \"())(())))\" and \"(())())))\" are balanced, \")()\", \"()))\" and \"(()))\" are not balanced.\n\nYou can insert the characters '(' and ')' at any position of the string to balance it if needed.\nReturn the minimum number of insertions needed to make s balanced.\n \nExample 1:\n\nInput: s = \"(()))\"\nOutput: 1\nExplanation: The second '(' has two matching '))', but the first '(' has only ')' matching. We need to add one more ')' at the end of the string to be \"(())))\" which is balanced.\n\nExample 2:\n\nInput: s = \"())\"\nOutput: 0\nExplanation: The string is already balanced.\n\nExample 3:\n\nInput: s = \"))())(\"\nOutput: 3\nExplanation: Add '(' to match the first '))', Add '))' to match the last '('.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of '(' and ')' only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(()))\") == 1\n assert candidate(s = \"))())(\") == 3\n assert candidate(s = \"())\") == 0\n assert candidate(s = \"(()(())))))))))))()()\") == 6\n assert candidate(s = \"(()))(()))(()))(()))(())))()\") == 5\n assert candidate(s = \"(()(()(()(()(())))))\") == 10\n assert candidate(s = \"()(()(()))())(()(()))()\") == 10\n assert candidate(s = \"(()(()(())))()(()(()(())))()()\") == 15\n assert candidate(s = \"(((()(()(()(()(())))))()))))))))))))))))))))\") == 10\n assert candidate(s = \"(()(()(())))()(()(()(())))\") == 13\n assert candidate(s = \"((((((())\") == 12\n assert candidate(s = \"(()(()(()(()(())))))))()(()))(())))()\") == 11\n assert candidate(s = \")((((()))))))))))))\") == 5\n assert candidate(s = \"(()(()))())\") == 4\n assert candidate(s = \"((((((())))))\") == 8\n assert candidate(s = \"(((((())))))))\") == 4\n assert candidate(s = \"(()())()(()(()(())))\") == 10\n assert candidate(s = \"((((((())))))))))\") == 4\n assert candidate(s = \"(()(()(())))()()(()(()(()))))(()))(()))(()))\") == 16\n assert candidate(s = \"()()()()()()()()()()()()()()()()\") == 16\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))(()))(()))\") == 9\n assert candidate(s = \"((())()())\") == 5\n assert candidate(s = \"(()))(()(()))\") == 5\n assert candidate(s = \"()(()(()(()(()(()))))())()()\") == 14\n assert candidate(s = \"())()(()))\") == 2\n assert candidate(s = \"((((()))))(()(()))()(()(()))()()\") == 16\n assert candidate(s = \"(()(()))(()(()))(()(()))(()(()))\") == 16\n assert candidate(s = \"))))))))))))))))\") == 8\n assert candidate(s = \"(()(((()(()))())()()(())))\") == 13\n assert candidate(s = \"(((((())))(((((())))\") == 16\n assert candidate(s = \"((((((((()))))))))\") == 9\n assert candidate(s = \"(()(()(()(()(())))))))\") == 8\n assert candidate(s = \"(((()))))()(()(()))(()(()))()\") == 13\n assert candidate(s = \"((((((()))))))\") == 7\n assert candidate(s = \"(()))(()))(()())\") == 5\n assert candidate(s = \"((())))))((()))))\") == 1\n assert candidate(s = \"(()(()(())))()()(()(()(())))()()(()(()(())))\") == 22\n assert candidate(s = \"(((((())))))()(()))(()))(()))(()))(()))\") == 12\n assert candidate(s = \"()(()(()(()(()(()))))())()\") == 13\n assert candidate(s = \"()(()(()(()(()))))(())))\") == 9\n assert candidate(s = \")(((((((((((((())))))))))))\") == 18\n assert candidate(s = \"((((()))))(()(()))()(()(()))\") == 14\n assert candidate(s = \"()(()(()(()(()(()(())))))()()()()()()()()()\") == 23\n assert candidate(s = \"(((((())))(((((())))))))\") == 12\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))(()))\") == 8\n assert candidate(s = \")(()))(()(()))\") == 7\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))(()))(()))(()))(()))(()))\") == 12\n assert candidate(s = \"(()(()(())))()()(()(()(()))))(()))\") == 14\n assert candidate(s = \"()(()(()(()(()(()))))())()()()\") == 15\n assert candidate(s = \"()()()()()()()()()()\") == 10\n assert candidate(s = \"(((((()))(()))()))\") == 9\n assert candidate(s = \"(((()))))()(()(()))(()(()))\") == 12\n assert candidate(s = \"(((((((((())))))))\") == 12\n assert candidate(s = \"(()((())(()))\") == 8\n assert candidate(s = \"((((((((((((((())))))))))))))()()()()()()()()()()()()()()()()()()()()()()()\") == 39\n assert candidate(s = \"(()))(()(()))())\") == 5\n assert candidate(s = \"(()))())\") == 1\n assert candidate(s = \"()()()()\") == 4\n assert candidate(s = \"(()))(()))(()(()()(())))\") == 9\n assert candidate(s = \"(()))(()))(()))(()))\") == 4\n assert candidate(s = \"(((((((((((((())))))))))))\") == 16\n assert candidate(s = \"(()(()(()(()(())))))))()(()))\") == 10\n assert candidate(s = \"((((()))))))\") == 3\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))\") == 6\n assert candidate(s = \"(()(()(()(())))()())\") == 10\n assert candidate(s = \"())(()))(()(()))\") == 5\n assert candidate(s = \"(()(()(()(()(())))))))()(()))(())))\") == 10\n assert candidate(s = \"(()(()(())))\") == 6\n assert candidate(s = \"(()))(()))(()))\") == 3\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))\") == 7\n assert candidate(s = \"((()))()()()()()()()\") == 10\n assert candidate(s = \"(()))())(())))\") == 1\n assert candidate(s = \")()()()()()()()()()()()()()()()()()()()()()\") == 23\n assert candidate(s = \"(((((()))())(()(((()))())))\") == 15\n assert candidate(s = \"()(()(()(()(()(()(())))))()()()()()()()()()()()()()()\") == 28\n assert candidate(s = \"(((((())))))()(()))(()))(()))(()))(()))()(()))(()))(()))()(()))(()))()(()))\") == 21\n assert candidate(s = \"()(()(()(()(()))))\") == 9\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))(()))(()))(()))\") == 10\n assert candidate(s = \"()(()(()(()(()(()))())))\") == 12\n assert candidate(s = \"()((((()))))))((((()))))))\") == 7\n assert candidate(s = \"(()(()))(()\") == 7\n assert candidate(s = \"(((())))\") == 4\n assert candidate(s = \"(((((())))))()(()))(()))(()))(()))(()))()(()))(()))(()))\") == 16\n assert candidate(s = \"(()(()(()(()(())))))))()()\") == 10\n assert candidate(s = \"()(()(()(()(()(()))())))()()\") == 14\n assert candidate(s = \"(()(()(()(()(())))))))()())\") == 9\n assert candidate(s = \"())()(()(()(()(()))))\") == 9\n assert candidate(s = \"))))(((\") == 8\n assert candidate(s = \"(()(()(()(()))))())\") == 8\n assert candidate(s = \"(()))(()))(())))\") == 2\n assert candidate(s = \"()(()(()(())))()\") == 8\n assert candidate(s = \"(()(()(())))()()(()(()(()))))(()))(()))(()))(()))\") == 17\n assert candidate(s = \"()()()()()()()()()()(()(()(()(()(())))))\") == 20\n assert candidate(s = \"(()(()(()(()(()))))(())))\") == 11\n assert candidate(s = \")()()()()()()\") == 8\n assert candidate(s = \"()(()(()(()(()(()))))())\") == 12\n assert candidate(s = \"(()))(()))(()))(()))(()))\") == 5\n assert candidate(s = \"(()(()(())))()()(()(()(())))\") == 14\n assert candidate(s = \"(()))(()(()(())))()()(()(()(()))))(()))(()))\") == 16\n assert candidate(s = \"(((((()))))(()(()))(()(()))()()()()\") == 19\n assert candidate(s = \"((((((((((((()))))))))))))))))\") == 9\n assert candidate(s = \"(()(()))())(()))\") == 5\n assert candidate(s = \"(()))(()))\") == 2\n assert candidate(s = \"()()()()()()\") == 6\n assert candidate(s = \"(()))(((())))((()))(()))()()(()(())))\") == 14\n assert candidate(s = \"()))))(((()))(()))\") == 9\n assert candidate(s = \"(()))(()(()(()))())\") == 8\n assert candidate(s = \"(()(()(()(()(()))))))))))))))\") == 7\n assert candidate(s = \"((()))))\") == 1\n assert candidate(s = \"())(()(()(()))())\") == 7\n assert candidate(s = \"((((((()))))))))\") == 5\n assert candidate(s = \"()()()()()()()()()\") == 9\n assert candidate(s = \"()(()(()(()(()(()(())))))()()()()()()\") == 20\n assert candidate(s = \"((((()))))(()(()))()(()(()))()()()\") == 17\n assert candidate(s = \"(()(()(()(()(())))))))()(()))(()))\") == 11\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minInsertions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minInsertions(self, s: str) -> int:", "container": "Solution", "callable": "minInsertions", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1542, "task_id": "find-longest-awesome-substring", "difficulty": "Hard", "problem_description": "You are given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it a palindrome.\nReturn the length of the maximum length awesome substring of s.\n \nExample 1:\n\nInput: s = \"3242415\"\nOutput: 5\nExplanation: \"24241\" is the longest awesome substring, we can form the palindrome \"24142\" with some swaps.\n\nExample 2:\n\nInput: s = \"12345678\"\nOutput: 1\n\nExample 3:\n\nInput: s = \"213123\"\nOutput: 6\nExplanation: \"213123\" is the longest awesome substring, we can form the palindrome \"231132\" with some swaps.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists only of digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == 4\n assert candidate(s = \"1000000001\") == 10\n assert candidate(s = \"9876543210\") == 1\n assert candidate(s = \"213123\") == 6\n assert candidate(s = \"9437493749\") == 9\n assert candidate(s = \"1221\") == 4\n assert candidate(s = \"1232112321\") == 10\n assert candidate(s = \"122112211\") == 9\n assert candidate(s = \"123454321\") == 9\n assert candidate(s = \"98765432100123456789\") == 20\n assert candidate(s = \"1111111111\") == 10\n assert candidate(s = \"0000000000000000000\") == 19\n assert candidate(s = \"2020202020\") == 9\n assert candidate(s = \"1111111\") == 7\n assert candidate(s = \"0123456789\") == 1\n assert candidate(s = \"3242415\") == 5\n assert candidate(s = \"2002\") == 4\n assert candidate(s = \"0123210\") == 7\n assert candidate(s = \"1234567890987654321\") == 19\n assert candidate(s = \"00\") == 2\n assert candidate(s = \"12321\") == 5\n assert candidate(s = \"202020202\") == 9\n assert candidate(s = \"12345678\") == 1\n assert candidate(s = \"12345432101234543210\") == 20\n assert candidate(s = \"123454321123454321\") == 18\n assert candidate(s = \"2211001122110011221\") == 19\n assert candidate(s = \"12345678901234567890123456789012345678901234567890\") == 41\n assert candidate(s = \"1234321987897898765456543213212345654321234321\") == 27\n assert candidate(s = \"99887766554433221100000000112233445566778899\") == 44\n assert candidate(s = \"9876543211234567890\") == 19\n assert candidate(s = \"1111111111111111111\") == 19\n assert candidate(s = \"111112222233333444445555566666777778888899999\") == 13\n assert candidate(s = \"999999999999999999999999999999999999999999999999999\") == 51\n assert candidate(s = \"123321122132123321122132123321122132123321\") == 39\n assert candidate(s = \"1232100000000000000012321\") == 25\n assert candidate(s = \"123456543210101\") == 15\n assert candidate(s = \"000000111111222222333333\") == 24\n assert candidate(s = \"112233445566778899\") == 18\n assert candidate(s = \"1122334455667788990000998877665544332211\") == 40\n assert candidate(s = \"0000000000\") == 10\n assert candidate(s = \"5959595959595959595\") == 19\n assert candidate(s = \"2211221133443344\") == 16\n assert candidate(s = \"1221333122133312213331221\") == 25\n assert candidate(s = \"99887766554433221100112233445566778899\") == 38\n assert candidate(s = \"123456789098765432101234567890\") == 21\n assert candidate(s = \"1234543210987654321\") == 9\n assert candidate(s = \"54321098765432109876543210987654321098765432109876\") == 41\n assert candidate(s = \"1234567890123456789012345678901234567890\") == 40\n assert candidate(s = \"01234567890987654321\") == 20\n assert candidate(s = \"987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210\") == 81\n assert candidate(s = \"22221111000033334444\") == 20\n assert candidate(s = \"12345678900000000001\") == 11\n assert candidate(s = \"9090909090909090909090909090909090909090909090909090\") == 52\n assert candidate(s = \"123123123123123123123123123123123123123123123123123\") == 49\n assert candidate(s = \"99999999999999999999\") == 20\n assert candidate(s = \"1234567898765432112345678987654321\") == 34\n assert candidate(s = \"11111111111111111111\") == 20\n assert candidate(s = \"11223344556677889900\") == 20\n assert candidate(s = \"1122334455667788990099887766554433221100001100\") == 46\n assert candidate(s = \"1221122112211221122112211221122112211221122112211221\") == 52\n assert candidate(s = \"999988887777666655554444333322221111\") == 36\n assert candidate(s = \"5555555555\") == 10\n assert candidate(s = \"32165498798546123\") == 17\n assert candidate(s = \"00000000000000000000000000000000000000000000000\") == 47\n assert candidate(s = \"2468024680246802468\") == 19\n assert candidate(s = \"123432101234321\") == 15\n assert candidate(s = \"98765432109876543210\") == 20\n assert candidate(s = \"3332222211111000000\") == 15\n assert candidate(s = \"12345678909876543210123456789098765432101234567890\") == 41\n assert candidate(s = \"111222333444555666777888999\") == 7\n assert candidate(s = \"020406080080604020\") == 18\n assert candidate(s = \"98765432123456789\") == 17\n assert candidate(s = \"1122334455667788990011\") == 22\n assert candidate(s = \"01234567898765432101234567890\") == 21\n assert candidate(s = \"1221122112211\") == 13\n assert candidate(s = \"111222333444555666777\") == 7\n assert candidate(s = \"12213332211233333312\") == 19\n assert candidate(s = \"998877665544332211000112233445566778899\") == 39\n assert candidate(s = \"11112222333344445555\") == 20\n assert candidate(s = \"12345432112345432100\") == 20\n assert candidate(s = \"0246802468024680246\") == 19\n assert candidate(s = \"101010101010101010101010101010101010101010101010101\") == 51\n assert candidate(s = \"0121021012321012321\") == 19\n assert candidate(s = \"9999888877776666555544443333222211110000\") == 40\n assert candidate(s = \"9876543210987654321\") == 19\n assert candidate(s = \"98765432109876543210987654321098765432109876543210\") == 41\n assert candidate(s = \"12321232123212321\") == 17\n assert candidate(s = \"0101010101010101010\") == 19\n assert candidate(s = \"789789789\") == 7\n assert candidate(s = \"12332145654\") == 11\n assert candidate(s = \"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\") == 81\n assert candidate(s = \"111222333444555666777888999000\") == 7\n assert candidate(s = \"98765432100000000009\") == 11\n assert candidate(s = \"9999999999\") == 10\n assert candidate(s = \"0000000000111111111122222222223333333333\") == 40\n assert candidate(s = \"1357913579135791357\") == 19\n assert candidate(s = \"10203040504030201\") == 17\n assert candidate(s = \"123454321012321\") == 9\n assert candidate(s = \"55555555555555555555\") == 20\n assert candidate(s = \"12345678900987654321\") == 20\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101\") == 52\n assert candidate(s = \"00000000000000000000\") == 20\n assert candidate(s = \"123123123123123123\") == 18\n assert candidate(s = \"111222333444555666\") == 7\n assert candidate(s = \"12213332122133321\") == 17\n assert candidate(s = \"01010101010101\") == 13\n assert candidate(s = \"1122334455667788990011223344556677889900\") == 40\n assert candidate(s = \"555555555555555555555555555555555555\") == 36\n assert candidate(s = \"9876543210123456789\") == 19\n assert candidate(s = \"001122334455667788990099887766554433221100\") == 42\n assert candidate(s = \"5555555555555555555555\") == 22\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 40\n assert candidate(s = \"9988776655443322110099887766554433221100\") == 40\n assert candidate(s = \"1122334455667788990099887766554433221100000000\") == 46\n assert candidate(s = \"00112233445566778899\") == 20\n assert candidate(s = \"122112333211\") == 11\n assert candidate(s = \"00000000000000000001\") == 19\n assert candidate(s = \"1223344556677889900998877665544332211\") == 37\n assert candidate(s = \"1234567890098765432112345678900987654321\") == 40\n assert candidate(s = \"111122223333444455556666\") == 24\n assert candidate(s = \"00000111112222233333444445555566666777778888899999\") == 13\n assert candidate(s = \"10000000000000000001\") == 20\n assert candidate(s = \"000111222333444555666\") == 7\n assert candidate(s = \"12345678900987654321012345678998765432101234567890\") == 41\n assert candidate(s = \"12345678900000000000\") == 11\n assert candidate(s = \"0220220120\") == 7\n assert candidate(s = \"123123123123123\") == 13\n assert candidate(s = \"10101010101010101010\") == 20\n assert candidate(s = \"1122334455667788991111222233334444\") == 34\n assert candidate(s = \"98765432100123456789987654321001234567899876543210\") == 41\n assert candidate(s = \"121312131213121312131213121312131213\") == 35\n assert candidate(s = \"5554443332221110000\") == 9\n assert candidate(s = \"010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\") == 96\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().longestAwesome", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def longestAwesome(self, s: str) -> int:", "container": "Solution", "callable": "longestAwesome", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1544, "task_id": "make-the-string-great", "difficulty": "Easy", "problem_description": "Given a string s of lower and upper case English letters.\nA good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where:\n\n0 <= i <= s.length - 2\ns[i] is a lower-case letter and s[i + 1] is the same letter but in upper-case or vice-versa.\n\nTo make the string good, you can choose two adjacent characters that make the string bad and remove them. You can keep doing this until the string becomes good.\nReturn the string after making it good. The answer is guaranteed to be unique under the given constraints.\nNotice that an empty string is also good.\n \nExample 1:\n\nInput: s = \"leEeetcode\"\nOutput: \"leetcode\"\nExplanation: In the first step, either you choose i = 1 or i = 2, both will result \"leEeetcode\" to be reduced to \"leetcode\".\n\nExample 2:\n\nInput: s = \"abBAcC\"\nOutput: \"\"\nExplanation: We have many possible scenarios, and all lead to the same answer. For example:\n\"abBAcC\" --> \"aAcC\" --> \"cC\" --> \"\"\n\"abBAcC\" --> \"abBA\" --> \"aA\" --> \"\"\n\nExample 3:\n\nInput: s = \"s\"\nOutput: \"s\"\n\n \nConstraints:\n\n1 <= s.length <= 100\ns contains only lower and upper case English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefg\") == \"abcdefg\"\n assert candidate(s = \"ABCDEFG\") == \"ABCDEFG\"\n assert candidate(s = \"vVtTkKsSiIdDgGhHjJfFcCrRlLpPoOeEaAqQzZxXcCvVbBnNmM\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgG\") == \"\"\n assert candidate(s = \"Ab\") == \"Ab\"\n assert candidate(s = \"abBAcC\") == \"\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"aBbAcC\") == \"\"\n assert candidate(s = \"aabAAB\") == \"aabAAB\"\n assert candidate(s = \"\") == \"\"\n assert candidate(s = \"AbcCdEfGhIjKlMnOpQrStUvWxYz\") == \"AbdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"aBbAcCdDeEfFgG\") == \"\"\n assert candidate(s = \"ZyXwVuTsRqPoNmLkJiHgFeDcBa\") == \"ZyXwVuTsRqPoNmLkJiHgFeDcBa\"\n assert candidate(s = \"abcABC\") == \"abcABC\"\n assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\") == \"QwErTyUiOpAsDfGhJkLzXcVbNm\"\n assert candidate(s = \"aA\") == \"\"\n assert candidate(s = \"leEeetcode\") == \"leetcode\"\n assert candidate(s = \"AaAaAa\") == \"\"\n assert candidate(s = \"s\") == \"s\"\n assert candidate(s = \"abcAbC\") == \"abcAbC\"\n assert candidate(s = \"AbcabcABC\") == \"AbcabcABC\"\n assert candidate(s = \"aBcAdBeCfD\") == \"aBcAdBeCfD\"\n assert candidate(s = \"AaBbCc\") == \"\"\n assert candidate(s = \"aB\") == \"aB\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == \"AbCdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"aAbB\") == \"\"\n assert candidate(s = \"aaBBccDDeeFFggHHiiJJkkLLmmNNooppQQrrSSttuuVVwwXXyyZZ\") == \"aaBBccDDeeFFggHHiiJJkkLLmmNNooppQQrrSSttuuVVwwXXyyZZ\"\n assert candidate(s = \"ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJjIiHhGgFfEeDdCcBbAa\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaB\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaB\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZzYxWvUtSrQpOnMlKjIhGfEdCbA\") == \"\"\n assert candidate(s = \"aBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcD\") == \"aBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcD\"\n assert candidate(s = \"abABabABabABabABabAB\") == \"abABabABabABabABabAB\"\n assert candidate(s = \"ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJiHhGgFfEeDdCcBbAa\") == \"Ji\"\n assert candidate(s = \"XyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"XyZ\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYz\") == \"AbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYz\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAa\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGfEdCbAaB\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGfEdC\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKiIjJhHgGfFeEdDcCbBaA\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzYxWVuTsRqPoNlKjIhGfEdCbAaBc\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzYxWVuTsRqPoNlKjIhGfEd\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJ\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aBcCdDeEfFgGHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"aB\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBc\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBc\"\n assert candidate(s = \"AbCDefGhIjKlMnOpQrStUvWxYzZyXwVuTsRqPoNlKjIhGfEdCbAaBcDe\") == \"AbCDefGhIjKlMlKjIhGf\"\n assert candidate(s = \"aBcAbCDefEDfGhIGhIJkIkJlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcAbCDefEDfGhIGhIJkIkJ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCd\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZd\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCd\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCd\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStVuWxYzABcDEfGHijKLmNoPQRSTuvWXyZ\") == \"AbCdEfGhIjKlMnOpQrStVuWxYzABcDEfGHijKLmNoPQRSTuvWXyZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGfEdCbAaBcDeFaGbHcIeJfKgHlIjKlM\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGaGbHcIeJfKgHlIjKlM\"\n assert candidate(s = \"bBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBb\") == \"b\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890\"\n assert candidate(s = \"mNbvCxzlKjHgfDsApoiuYtrewqQ\") == \"mNbvCxzlKjHgfDsApoiuYtrew\"\n assert candidate(s = \"aAbBcCdDeEfFgGHh\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZzYxWvUtSrQpOnMlKjIgFeDcBa\") == \"aBcDeFgHgFeDcBa\"\n assert candidate(s = \"aBcAbCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\") == \"aBcAbC\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"\"\n assert candidate(s = \"abcdEfghIjklMNopQRstUVwxYZ\") == \"abcdEfghIjklMNopQRstUVwxYZ\"\n assert candidate(s = \"AbCdeFgHijklmNoPQRstUvWxYz\") == \"AbCdeFgHijklmNoPQRstUvWxYz\"\n assert candidate(s = \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAb\") == \"b\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzABcdEFghIJklMNopQRstUVwxYZ\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzABcdEFghIJklMNopQRstUVwxYZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDe\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZe\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzZyXwVuTsRqPoNlKjIhGfEdCbA\") == \"AbCdEfGhIjKlMlKjIhGfEdCbA\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEf\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZf\"\n assert candidate(s = \"abcdefgHIJKLMnopqrstuvwxyz\") == \"abcdefgHIJKLMnopqrstuvwxyz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"AbcDefGhIjKlMnOpQrStVuWxYzabcDEFghijKLMnopqrSTUVwxyZ\") == \"AbcDefGhIjKlMnOpQrStVuWxYzabcDEFghijKLMnopqrSTUVwxyZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgG\") == \"\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA\") == \"zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhH\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890!@#$%^&*()\") == \"a1234567890!@#$%^&*()\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGfEdCbAaBcDeFaGbHcIeJfKgHlIjKlMnOpQrStUvWxYzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGaGbHcIeJfKgHlIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"AbCbaBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"AbCbaB\"\n assert candidate(s = \"mNnMoPpQqRrSsTtUuVvWwXxYyZz\") == \"o\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"\"\n assert candidate(s = \"aBbAcCcAdDdAeEeAfFfAgGgAhHhAiIiAjJjAkKkAlLlAmMmAnNnAoOoApPpAqQqArRrAsStTuUuAvVvAwWwAxXxAyYyAzZz\") == \"cAdAeAfAgAhAiAjAkAlAmAnAoApAqArAuAvAwAxAyAz\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"aBbAcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"\"\n assert candidate(s = \"abcABCabcABC\") == \"abcABCabcABC\"\n assert candidate(s = \"xYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZ\") == \"xYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZ\"\n assert candidate(s = \"abcABCabcABCabcABCabcABC\") == \"abcABCabcABCabcABCabcABC\"\n assert candidate(s = \"ThisIsATestStringToCheckTheFunctionalityOfTheGivenCode\") == \"ThisIsATestStringToCheckTheFunctionalityOfTheGivenCode\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzZyXwVuTsRqPoNlKjIhGfEdCbAaBcDeFaGbHcIeJfKgHlIjKlMnOpQrStUvWxYz\") == \"AbCdEfGhIjKlMlKjIhGaGbHcIeJfKgHlIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"abcdefGHIJKLmnopQRSTuvwXYZ\") == \"abcdefGHIJKLmnopQRSTuvwXYZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgG\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGfEdCbAaBcDeFaGbHcIeJ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGaGbHcIeJ\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYz\") == \"AbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZzYxWvUtSrQpOnMlKjIhGfEdCbAaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aaaaAAaaAAaaaAAaAaaaAA\") == \"aaaa\"\n assert candidate(s = \"ZyXwVuTsRqPoNmLkJiHgFeDcBaCbAdCdEfFgHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"ZyXwVuTsRqPoNmLkJiHgFeDcBaCbAdCdEgH\"\n assert candidate(s = \"XyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYz\") == \"XyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYz\"\n assert candidate(s = \"aBcCdEfFgHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\") == \"aBdEgH\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().makeGood", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def makeGood(self, s: str) -> str:", "container": "Solution", "callable": "makeGood", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1545, "task_id": "find-kth-bit-in-nth-binary-string", "difficulty": "Medium", "problem_description": "Given two positive integers n and k, the binary string Sn is formed as follows:\n\nS1 = \"0\"\nSi = Si - 1 + \"1\" + reverse(invert(Si - 1)) for i > 1\n\nWhere + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).\nFor example, the first four strings in the above sequence are:\n\nS1 = \"0\"\nS2 = \"011\"\nS3 = \"0111001\"\nS4 = \"011100110110001\"\n\nReturn the kth bit in Sn. It is guaranteed that k is valid for the given n.\n \nExample 1:\n\nInput: n = 3, k = 1\nOutput: \"0\"\nExplanation: S3 is \"0111001\".\nThe 1st bit is \"0\".\n\nExample 2:\n\nInput: n = 4, k = 11\nOutput: \"1\"\nExplanation: S4 is \"011100110110001\".\nThe 11th bit is \"1\".\n\n \nConstraints:\n\n1 <= n <= 20\n1 <= k <= 2n - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,k = 31) == \"1\"\n assert candidate(n = 4,k = 11) == \"1\"\n assert candidate(n = 14,k = 511) == \"1\"\n assert candidate(n = 15,k = 545) == \"0\"\n assert candidate(n = 17,k = 65536) == \"1\"\n assert candidate(n = 18,k = 131071) == \"1\"\n assert candidate(n = 10,k = 127) == \"1\"\n assert candidate(n = 19,k = 262144) == \"1\"\n assert candidate(n = 13,k = 289) == \"0\"\n assert candidate(n = 12,k = 2047) == \"1\"\n assert candidate(n = 7,k = 40) == \"1\"\n assert candidate(n = 11,k = 148) == \"1\"\n assert candidate(n = 10,k = 511) == \"1\"\n assert candidate(n = 20,k = 524287) == \"1\"\n assert candidate(n = 16,k = 1023) == \"1\"\n assert candidate(n = 11,k = 1024) == \"1\"\n assert candidate(n = 9,k = 85) == \"0\"\n assert candidate(n = 14,k = 8191) == \"1\"\n assert candidate(n = 15,k = 16384) == \"1\"\n assert candidate(n = 16,k = 32767) == \"1\"\n assert candidate(n = 20,k = 4095) == \"1\"\n assert candidate(n = 20,k = 1048575) == \"1\"\n assert candidate(n = 12,k = 255) == \"1\"\n assert candidate(n = 5,k = 16) == \"1\"\n assert candidate(n = 8,k = 63) == \"1\"\n assert candidate(n = 17,k = 1057) == \"0\"\n assert candidate(n = 3,k = 1) == \"0\"\n assert candidate(n = 8,k = 127) == \"1\"\n assert candidate(n = 9,k = 256) == \"1\"\n assert candidate(n = 13,k = 4096) == \"1\"\n assert candidate(n = 19,k = 2081) == \"0\"\n assert candidate(n = 18,k = 2047) == \"1\"\n assert candidate(n = 7,k = 64) == \"1\"\n assert candidate(n = 19,k = 262143) == \"1\"\n assert candidate(n = 9,k = 128) == \"1\"\n assert candidate(n = 17,k = 32767) == \"1\"\n assert candidate(n = 10,k = 1023) == \"1\"\n assert candidate(n = 12,k = 4096) == \"1\"\n assert candidate(n = 18,k = 262144) == \"1\"\n assert candidate(n = 14,k = 8192) == \"1\"\n assert candidate(n = 14,k = 4096) == \"1\"\n assert candidate(n = 13,k = 2048) == \"1\"\n assert candidate(n = 13,k = 8191) == \"1\"\n assert candidate(n = 11,k = 1023) == \"1\"\n assert candidate(n = 17,k = 131071) == \"1\"\n assert candidate(n = 16,k = 65535) == \"1\"\n assert candidate(n = 18,k = 65536) == \"1\"\n assert candidate(n = 19,k = 4096) == \"1\"\n assert candidate(n = 19,k = 524288) == \"1\"\n assert candidate(n = 9,k = 255) == \"1\"\n assert candidate(n = 20,k = 524288) == \"1\"\n assert candidate(n = 17,k = 131072) == \"1\"\n assert candidate(n = 11,k = 2048) == \"1\"\n assert candidate(n = 14,k = 16383) == \"1\"\n assert candidate(n = 15,k = 32767) == \"1\"\n assert candidate(n = 19,k = 524287) == \"1\"\n assert candidate(n = 19,k = 4095) == \"1\"\n assert candidate(n = 5,k = 32) == \"1\"\n assert candidate(n = 10,k = 512) == \"1\"\n assert candidate(n = 3,k = 5) == \"0\"\n assert candidate(n = 8,k = 256) == \"1\"\n assert candidate(n = 16,k = 65536) == \"1\"\n assert candidate(n = 15,k = 32768) == \"1\"\n assert candidate(n = 6,k = 64) == \"1\"\n assert candidate(n = 17,k = 16385) == \"0\"\n assert candidate(n = 11,k = 2047) == \"1\"\n assert candidate(n = 9,k = 511) == \"1\"\n assert candidate(n = 8,k = 255) == \"1\"\n assert candidate(n = 7,k = 128) == \"1\"\n assert candidate(n = 3,k = 7) == \"1\"\n assert candidate(n = 8,k = 128) == \"1\"\n assert candidate(n = 19,k = 327679) == \"1\"\n assert candidate(n = 13,k = 8192) == \"1\"\n assert candidate(n = 18,k = 262143) == \"1\"\n assert candidate(n = 16,k = 32768) == \"1\"\n assert candidate(n = 9,k = 512) == \"1\"\n assert candidate(n = 14,k = 16384) == \"1\"\n assert candidate(n = 19,k = 511999) == \"1\"\n assert candidate(n = 2,k = 2) == \"1\"\n assert candidate(n = 17,k = 65535) == \"1\"\n assert candidate(n = 13,k = 4095) == \"1\"\n assert candidate(n = 8,k = 64) == \"1\"\n assert candidate(n = 20,k = 1) == \"0\"\n assert candidate(n = 10,k = 256) == \"1\"\n assert candidate(n = 10,k = 1024) == \"1\"\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().findKthBit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findKthBit(self, n: int, k: int) -> str:", "container": "Solution", "callable": "findKthBit", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1546, "task_id": "maximum-number-of-non-overlapping-subarrays-with-sum-equals-target", "difficulty": "Medium", "problem_description": "Given an array nums and an integer target, return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target.\n \nExample 1:\n\nInput: nums = [1,1,1,1,1], target = 2\nOutput: 2\nExplanation: There are 2 non-overlapping subarrays [1,1,1,1,1] with sum equals to target(2).\n\nExample 2:\n\nInput: nums = [-1,3,5,1,4,2,-9], target = 6\nOutput: 2\nExplanation: There are 3 subarrays with sum equal to 6.\n([5,1], [4,2], [3,5,1,4,2,-9]) but only the first 2 are non-overlapping.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n-104 <= nums[i] <= 104\n0 <= target <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],target = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],target = 9) == 1\n assert candidate(nums = [-1, 3, 5, 1, 4, 2, -9],target = 6) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5],target = 15) == 2\n assert candidate(nums = [0, 0, 0, 0, 0],target = 0) == 5\n assert candidate(nums = [1, -1, 2, -2, 3, -3],target = 0) == 3\n assert candidate(nums = [1, 1, 1, 1, 1],target = 2) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],target = 15) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 3\n assert candidate(nums = [10, -5, 5, -3, 2, 3, -1, 7],target = 5) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == 1\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 38) == 1\n assert candidate(nums = [-2, 2, -2, 2, -2, 2, -2, 2, -2, 2],target = 0) == 5\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],target = 0) == 5\n assert candidate(nums = [-1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5],target = -15) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 2\n assert candidate(nums = [100, -25, 25, -50, 50, 150, -150, 200, -200],target = 100) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 0, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],target = 5) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 1, 2, 3, 4, 5, -10, 1, 2, 3],target = 10) == 2\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 0) == 10\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],target = -15) == 2\n assert candidate(nums = [1000, -500, 500, -300, 200, 300, -100, 700],target = 500) == 3\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 9) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1) == 30\n assert candidate(nums = [5, -2, 5, -2, 5, -2, 5, -2, 5, -2],target = 3) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1) == 10\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 6) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 1) == 1\n assert candidate(nums = [100, -50, 50, -25, 25, 125, -125, 62, -62, 31, -31],target = 50) == 2\n assert candidate(nums = [5, 1, 3, 7, 8, 2, 4, 6, 9, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9],target = 5) == 2\n assert candidate(nums = [10, 5, 5, 15, 10, 10, 5, 5, 20, 15],target = 20) == 3\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000],target = 10000) == 3\n assert candidate(nums = [3, 4, -2, 3, -2, 5, -5, 1, 1, 1],target = 3) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 10\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 2) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 4\n assert candidate(nums = [2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],target = 9) == 3\n assert candidate(nums = [10, 5, -5, 10, 15, -25, 30, -30, 35, -35, 40, -40, 45, -45, 50, -50, 55, -55, 60, -60],target = 10) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],target = 55) == 2\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],target = -5) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5],target = 9) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1500) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 3\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],target = -30) == 2\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],target = 0) == 10\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],target = 100) == 5\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 0) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1) == 20\n assert candidate(nums = [100, -25, 25, -50, 50, -75, 75, -100, 100, -125, 125],target = 50) == 2\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 0) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == 3\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 9) == 3\n assert candidate(nums = [100, -25, 25, -25, 25, 25, -50, 25, -25, 25, 25, -50, 100, -200, 100],target = 25) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 30) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 1, 2, 3, 4, 5],target = 5) == 4\n assert candidate(nums = [5, 1, 3, 7, 2, 8, 6, 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10) == 5\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10],target = 0) == 10\n assert candidate(nums = [9, 3, 6, 9, 3, 6, 9, 3, 6, 9],target = 12) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 10\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 0) == 10\n assert candidate(nums = [1, -1, 0, 1, 0, -1, 1],target = 0) == 4\n assert candidate(nums = [3, 2, 1, 6, 3, 3, 2, 1, 6, 3, 3, 2, 1, 6, 3],target = 9) == 4\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],target = 0) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 55) == 1\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],target = 3) == 5\n assert candidate(nums = [100, -50, 50, -25, 25, -10, 10, 5, -5, 15, -15],target = 25) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5, 10, 5, 0, -5, -10, 1, 2, 3, 4, 5],target = 0) == 3\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 0) == 10\n assert candidate(nums = [1000, -500, 500, -250, 250, -125, 125, 0, 0, 0, 0, 0, 0, 0, 0],target = 250) == 2\n assert candidate(nums = [-2, 2, 3, -3, 4, 5, -5, 4, 6, -6, 7, -7, 8, -8],target = 0) == 6\n assert candidate(nums = [5, 1, 3, 2, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 6) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 8\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 0) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 150) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 8\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],target = 75) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 0) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 20) == 1\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5],target = 5) == 5\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120, 130, -140, 150, -160, 170, -180, 190, -200],target = 100) == 1\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 100) == 2\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1, -1],target = 0) == 6\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6],target = 10) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 0) == 20\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000, -10000],target = 10000) == 3\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 75) == 2\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],target = -15) == 3\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10],target = 0) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == 3\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5],target = 0) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 0) == 15\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],target = 100) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 28) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().maxNonOverlapping", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxNonOverlapping(self, nums: list[int], target: int) -> int:", "container": "Solution", "callable": "maxNonOverlapping", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1547, "task_id": "minimum-cost-to-cut-a-stick", "difficulty": "Hard", "problem_description": "Given a wooden stick of length n units. The stick is labelled from 0 to n. For example, a stick of length 6 is labelled as follows:\n\nGiven an integer array cuts where cuts[i] denotes a position you should perform a cut at.\nYou should perform the cuts in order, you can change the order of the cuts as you wish.\nThe cost of one cut is the length of the stick to be cut, the total cost is the sum of costs of all cuts. When you cut a stick, it will be split into two smaller sticks (i.e. the sum of their lengths is the length of the stick before the cut). Please refer to the first example for a better explanation.\nReturn the minimum total cost of the cuts.\n \nExample 1:\n\n\nInput: n = 7, cuts = [1,3,4,5]\nOutput: 16\nExplanation: Using cuts order = [1, 3, 4, 5] as in the input leads to the following scenario:\n\nThe first cut is done to a rod of length 7 so the cost is 7. The second cut is done to a rod of length 6 (i.e. the second part of the first cut), the third is done to a rod of length 4 and the last cut is to a rod of length 3. The total cost is 7 + 6 + 4 + 3 = 20.\nRearranging the cuts to be [3, 5, 1, 4] for example will lead to a scenario with total cost = 16 (as shown in the example photo 7 + 4 + 3 + 2 = 16).\nExample 2:\n\nInput: n = 9, cuts = [5,6,1,4,2]\nOutput: 22\nExplanation: If you try the given cuts ordering the cost will be 25.\nThere are much ordering with total cost <= 25, for example, the order [4, 6, 5, 2, 1] has total cost = 22 which is the minimum possible.\n\n \nConstraints:\n\n2 <= n <= 106\n1 <= cuts.length <= min(n - 1, 100)\n1 <= cuts[i] <= n - 1\nAll the integers in cuts array are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 15,cuts = [3, 5, 10]) == 30\n assert candidate(n = 100,cuts = [50, 25, 75, 10, 90, 60, 30, 40, 80]) == 330\n assert candidate(n = 15,cuts = [1, 5, 9, 13]) == 35\n assert candidate(n = 7,cuts = [1, 3, 4, 5]) == 16\n assert candidate(n = 10,cuts = [2, 4, 7]) == 20\n assert candidate(n = 8,cuts = [1, 3, 5, 7]) == 19\n assert candidate(n = 8,cuts = [1, 3, 6]) == 16\n assert candidate(n = 6,cuts = [3, 1, 5]) == 12\n assert candidate(n = 6,cuts = [1, 2, 3, 4, 5]) == 16\n assert candidate(n = 15,cuts = [3, 5, 12, 10]) == 35\n assert candidate(n = 12,cuts = [1, 3, 5, 7, 9]) == 31\n assert candidate(n = 12,cuts = [2, 3, 10, 11]) == 26\n assert candidate(n = 12,cuts = [1, 5, 8, 10]) == 28\n assert candidate(n = 10,cuts = [1, 2, 3, 4, 5]) == 22\n assert candidate(n = 5,cuts = [1, 4]) == 9\n assert candidate(n = 15,cuts = [2, 7, 10, 13]) == 35\n assert candidate(n = 8,cuts = [2, 5]) == 13\n assert candidate(n = 9,cuts = [5, 6, 1, 4, 2]) == 22\n assert candidate(n = 12,cuts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 44\n assert candidate(n = 8,cuts = [2, 3, 5, 6]) == 19\n assert candidate(n = 20,cuts = [3, 8, 10, 12, 15]) == 51\n assert candidate(n = 20,cuts = [3, 6, 9, 12, 15]) == 52\n assert candidate(n = 8,cuts = [3, 5]) == 13\n assert candidate(n = 50,cuts = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 170\n assert candidate(n = 400,cuts = [120, 240, 60, 180, 300, 360, 90, 210, 330, 390]) == 1360\n assert candidate(n = 150,cuts = [20, 40, 60, 80, 100, 120, 140]) == 450\n assert candidate(n = 512,cuts = [64, 128, 192, 256, 320, 384, 448]) == 1536\n assert candidate(n = 300,cuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290]) == 1480\n assert candidate(n = 1024,cuts = [128, 256, 384, 512, 640, 768, 896]) == 3072\n assert candidate(n = 200,cuts = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190]) == 700\n assert candidate(n = 500,cuts = [100, 150, 200, 250, 300, 350, 400, 450]) == 1600\n assert candidate(n = 10000,cuts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 34000\n assert candidate(n = 900,cuts = [100, 200, 300, 400, 500, 600, 700, 800, 450, 350, 250, 150, 50]) == 3400\n assert candidate(n = 300,cuts = [50, 100, 150, 200, 250, 125, 175, 225, 275, 75, 25, 200, 250, 150, 100, 300, 50]) == 1250\n assert candidate(n = 30,cuts = [29, 1, 28, 14, 22, 19, 3, 7, 11, 25, 26, 9, 21, 15, 6, 23, 17, 2, 18, 5, 24, 20, 12, 16, 8, 10, 4, 27, 13]) == 148\n assert candidate(n = 750,cuts = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500, 520, 540, 560, 580, 600, 620, 640, 660, 680, 700, 720, 740]) == 3980\n assert candidate(n = 600,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 580]) == 2250\n assert candidate(n = 35,cuts = [3, 7, 11, 15, 19, 23, 27, 31]) == 112\n assert candidate(n = 20,cuts = [2, 5, 8, 11, 14, 17]) == 57\n assert candidate(n = 150,cuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 590\n assert candidate(n = 750,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 125, 275, 425, 575, 325, 475, 625, 225, 375, 525, 675]) == 3550\n assert candidate(n = 900,cuts = [90, 180, 270, 360, 450, 540, 630, 720, 810, 900, 45, 135, 225, 315, 405, 495, 585, 675, 765, 855, 945]) == 4275\n assert candidate(n = 729,cuts = [27, 54, 81, 108, 135, 162, 189, 216, 243, 270, 297, 324, 351, 378, 405, 432, 459, 486, 513, 540, 567, 594, 621, 648, 675, 702]) == 3510\n assert candidate(n = 120,cuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 440\n assert candidate(n = 1500,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350, 1400, 1450]) == 7400\n assert candidate(n = 25,cuts = [5, 15, 20, 10]) == 60\n assert candidate(n = 500,cuts = [10, 25, 45, 70, 100, 150, 200, 250, 300, 350, 400]) == 1720\n assert candidate(n = 1000,cuts = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 3400\n assert candidate(n = 2500,cuts = [200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000, 2200, 2400]) == 9400\n assert candidate(n = 999,cuts = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 1565\n assert candidate(n = 50,cuts = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 170\n assert candidate(n = 750,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700]) == 2950\n assert candidate(n = 200,cuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 880\n assert candidate(n = 1000,cuts = [10, 50, 90, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 3640\n assert candidate(n = 700,cuts = [140, 280, 420, 560, 70, 210, 350, 490, 630, 175, 315, 455, 595]) == 2660\n assert candidate(n = 10000,cuts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 34000\n assert candidate(n = 250,cuts = [25, 50, 75, 100, 125, 150, 175, 200, 225]) == 850\n assert candidate(n = 500,cuts = [100, 200, 300, 400, 150, 250, 350, 450, 50, 450]) == 1750\n assert candidate(n = 1000,cuts = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 3400\n assert candidate(n = 70,cuts = [7, 14, 21, 28, 35, 42, 49, 56, 63]) == 238\n assert candidate(n = 100,cuts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 182\n assert candidate(n = 40,cuts = [10, 20, 30]) == 80\n assert candidate(n = 600,cuts = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500, 520, 540, 560, 580]) == 2960\n assert candidate(n = 600,cuts = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510, 540, 570]) == 2640\n assert candidate(n = 400,cuts = [50, 100, 150, 200, 250, 300, 350]) == 1200\n assert candidate(n = 2000,cuts = [100, 500, 800, 1500, 1900, 1600, 1200, 700, 300, 1100, 1700, 1800, 600, 900, 400, 200]) == 8100\n assert candidate(n = 500,cuts = [100, 200, 300, 400, 150, 250, 350]) == 1500\n assert candidate(n = 99,cuts = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97]) == 566\n assert candidate(n = 800,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750]) == 3200\n assert candidate(n = 800,cuts = [160, 320, 480, 640, 80, 240, 400, 560, 720, 110, 270, 430, 590, 750, 90, 250, 410, 570, 730]) == 3270\n assert candidate(n = 5000,cuts = [2000, 1000, 3000, 4000, 500, 1500, 2500, 3500, 4500, 1250, 1750, 2250, 2750, 3250, 3750, 4250, 4750, 625, 750, 1125, 1375, 1625, 1875, 2125, 2375, 2625, 2875, 3125, 3375, 3625, 3875, 4125, 4375, 4625, 4875]) == 25750\n assert candidate(n = 1200,cuts = [120, 240, 360, 480, 600, 720, 840, 960, 1080, 1200, 60, 180, 300, 420, 540, 660, 780, 900, 1020, 1140, 30, 90, 150, 210, 270, 330, 390, 450, 510, 570, 630, 690, 750, 810, 870, 930, 990, 1050, 1110, 1170]) == 6510\n assert candidate(n = 15,cuts = [1, 4, 7, 10, 13]) == 39\n assert candidate(n = 3000,cuts = [100, 300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900, 2100, 2300, 2500, 2700, 2900]) == 12000\n assert candidate(n = 50,cuts = [2, 25, 49, 23, 37, 17, 33, 9, 41, 35]) == 170\n assert candidate(n = 300,cuts = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275]) == 1100\n assert candidate(n = 900,cuts = [150, 300, 450, 600, 750, 100, 200, 500, 800, 90, 180, 270, 360, 450, 540, 630, 720, 810, 900]) == 3820\n assert candidate(n = 1200,cuts = [200, 400, 600, 800, 1000, 120, 320, 520, 720, 920]) == 4200\n assert candidate(n = 500,cuts = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475]) == 2200\n assert candidate(n = 256,cuts = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248]) == 1280\n assert candidate(n = 600,cuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590]) == 3560\n assert candidate(n = 1024,cuts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255]) == 3063\n assert candidate(n = 200,cuts = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195]) == 770\n assert candidate(n = 2000,cuts = [100, 300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800]) == 8800\n assert candidate(n = 800,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 550, 600, 650, 700, 750, 800]) == 3200\n assert candidate(n = 1500,cuts = [250, 500, 750, 1000, 1250, 1300, 1400, 1450, 1350, 1200]) == 4750\n assert candidate(n = 99,cuts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98]) == 664\n assert candidate(n = 50,cuts = [3, 10, 20, 30, 40]) == 130\n assert candidate(n = 150,cuts = [15, 30, 45, 60, 75, 90, 105, 120, 135, 105, 45, 15, 90, 75, 135, 60, 120]) == 630\n assert candidate(n = 55,cuts = [11, 22, 33, 44, 5]) == 143\n assert candidate(n = 60,cuts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 59]) == 225\n assert candidate(n = 300,cuts = [30, 60, 90, 120, 150, 180, 210, 240, 270]) == 1020\n assert candidate(n = 1000,cuts = [200, 400, 600, 800, 300, 700, 100, 900, 500]) == 3400\n assert candidate(n = 1200,cuts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100]) == 4400\n assert candidate(n = 20,cuts = [3, 6, 9, 12, 15, 18]) == 57\n assert candidate(n = 30,cuts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 148\n assert candidate(n = 1000,cuts = [200, 400, 600, 800, 100, 300, 500, 700, 900]) == 3400\n"}, "metadata": {"canonical_parameter_names": ["n", "cuts"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minCost(self, n: int, cuts: list[int]) -> int:", "container": "Solution", "callable": "minCost", "parameters": [{"name": "n", "type": "int"}, {"name": "cuts", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1550, "task_id": "three-consecutive-odds", "difficulty": "Easy", "problem_description": "Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false.\n \nExample 1:\n\nInput: arr = [2,6,4,1]\nOutput: false\nExplanation: There are no three consecutive odds.\n\nExample 2:\n\nInput: arr = [1,2,34,3,4,5,7,23,12]\nOutput: true\nExplanation: [5,7,23] are three consecutive odds.\n\n \nConstraints:\n\n1 <= arr.length <= 1000\n1 <= arr[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 3, 2, 5, 7, 9]) == True\n assert candidate(arr = [2, 4, 6, 8, 10]) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [1000, 999, 998, 997]) == False\n assert candidate(arr = [2, 3, 5, 7, 11, 13]) == True\n assert candidate(arr = [2, 6, 4, 1]) == False\n assert candidate(arr = [999, 997, 995, 993, 991]) == True\n assert candidate(arr = [11, 13, 15, 17, 19]) == True\n assert candidate(arr = [1, 3, 2, 3, 5, 7]) == True\n assert candidate(arr = [2, 4, 6, 8]) == False\n assert candidate(arr = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == False\n assert candidate(arr = [1, 2, 1, 2, 1, 2]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [999, 997, 995]) == True\n assert candidate(arr = [1001, 1003, 1005]) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(arr = [999, 1001, 1003, 1005]) == True\n assert candidate(arr = [1, 2, 34, 3, 4, 5, 7, 23, 12]) == True\n assert candidate(arr = [1, 1, 1, 1]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [2, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2]) == False\n assert candidate(arr = [1, 3, 5, 7, 9]) == True\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19]) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(arr = [11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [1, 3, 5]) == True\n assert candidate(arr = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 21, 23]) == True\n assert candidate(arr = [999, 1001, 1003, 1005, 1007, 1009, 1011, 1013, 1015, 1017, 1019, 1021]) == True\n assert candidate(arr = [1, 1, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1]) == True\n assert candidate(arr = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15]) == True\n assert candidate(arr = [101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169]) == True\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == False\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == True\n assert candidate(arr = [23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61]) == True\n assert candidate(arr = [8, 10, 12, 14, 16, 18, 20, 1, 3, 5]) == True\n assert candidate(arr = [1001, 1003, 1005, 1007, 1009, 1011, 1013, 1015]) == True\n assert candidate(arr = [1000, 1000, 1000, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == False\n assert candidate(arr = [101, 203, 305, 407, 509, 611, 713, 815, 917, 1019]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == True\n assert candidate(arr = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 1, 3, 5]) == True\n assert candidate(arr = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == False\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == False\n assert candidate(arr = [999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000]) == False\n assert candidate(arr = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 989, 987, 985, 983, 981, 979]) == True\n assert candidate(arr = [2, 4, 6, 8, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == False\n assert candidate(arr = [200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21, 23, 25]) == True\n assert candidate(arr = [89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191]) == True\n assert candidate(arr = [1, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 3, 5, 7]) == True\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10]) == True\n assert candidate(arr = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13]) == True\n assert candidate(arr = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139]) == True\n assert candidate(arr = [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25, 27, 29]) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13]) == True\n assert candidate(arr = [2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == False\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25, 27, 29, 31, 33]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == True\n assert candidate(arr = [21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == False\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == False\n assert candidate(arr = [1001, 1003, 1005, 2, 4, 6, 8, 1007, 1009, 1011]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 5, 5, 5, 7, 7, 7, 11, 11, 11, 13, 13, 13, 17, 17, 17, 19, 19, 19]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == True\n assert candidate(arr = [1000, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == True\n assert candidate(arr = [300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21, 23, 25]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 2, 4, 6, 8, 10]) == True\n assert candidate(arr = [5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 41, 43, 45]) == True\n assert candidate(arr = [999, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == False\n assert candidate(arr = [1, 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1]) == True\n assert candidate(arr = [999, 997, 995, 993, 991, 989, 987, 985, 983, 981, 979, 977, 975, 973, 971, 969, 967, 965, 963, 961, 959, 957, 955, 953, 951, 949, 947, 945, 943, 941, 939, 937, 935, 933, 931, 929, 927, 925, 923, 921, 919, 917, 915, 913, 911, 909, 907, 905, 903, 901, 899, 897, 895, 893, 891, 889, 887, 885, 883, 881]) == True\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19]) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 11, 13, 15, 17, 19]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == True\n assert candidate(arr = [499, 501, 503, 505, 507, 509, 511, 513, 515, 517, 519, 521, 523, 525, 527, 529]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == False\n assert candidate(arr = [1001, 1003, 1005, 1007, 1009, 1011, 1013, 1015, 1017, 1019]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19]) == True\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79]) == True\n assert candidate(arr = [5, 3, 1, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == False\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109]) == True\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 7, 9, 11, 13, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == True\n assert candidate(arr = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == False\n assert candidate(arr = [5, 3, 1, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27]) == True\n assert candidate(arr = [2, 4, 6, 8, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989]) == False\n assert candidate(arr = [1, 2, 1, 3, 1, 5, 1, 7, 1, 9, 1, 11, 1, 13, 1, 15]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987]) == False\n assert candidate(arr = [1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 10, 11, 12, 13, 12, 13, 14, 15, 14, 15, 16, 17, 16, 17, 18, 19, 18, 19, 20]) == False\n assert candidate(arr = [1, 3, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25]) == True\n assert candidate(arr = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == True\n assert candidate(arr = [999, 1001, 1003, 1005, 1007, 1009, 1011, 1013, 1015, 1017, 1019]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == False\n assert candidate(arr = [42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 71]) == False\n assert candidate(arr = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == True\n assert candidate(arr = [101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209]) == True\n assert candidate(arr = [1001, 1003, 1005, 1007, 1009, 1011, 1013, 1015, 1017]) == True\n assert candidate(arr = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45]) == True\n assert candidate(arr = [3, 5, 7, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == False\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().threeConsecutiveOdds", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def threeConsecutiveOdds(self, arr: list[int]) -> bool:", "container": "Solution", "callable": "threeConsecutiveOdds", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1551, "task_id": "minimum-operations-to-make-array-equal", "difficulty": "Medium", "problem_description": "You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e., 0 <= i < n).\nIn one operation, you can select two indices x and y where 0 <= x, y < n and subtract 1 from arr[x] and add 1 to arr[y] (i.e., perform arr[x] -=1 and arr[y] += 1). The goal is to make all the elements of the array equal. It is guaranteed that all the elements of the array can be made equal using some operations.\nGiven an integer n, the length of the array, return the minimum number of operations needed to make all the elements of arr equal.\n \nExample 1:\n\nInput: n = 3\nOutput: 2\nExplanation: arr = [1, 3, 5]\nFirst operation choose x = 2 and y = 0, this leads arr to be [2, 3, 4]\nIn the second operation choose x = 2 and y = 0 again, thus arr = [3, 3, 3].\n\nExample 2:\n\nInput: n = 6\nOutput: 9\n\n \nConstraints:\n\n1 <= n <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 2\n assert candidate(n = 100) == 2500\n assert candidate(n = 10000) == 25000000\n assert candidate(n = 6) == 9\n assert candidate(n = 1) == 0\n assert candidate(n = 1000) == 250000\n assert candidate(n = 10) == 25\n assert candidate(n = 15000) == 56250000\n assert candidate(n = 12345) == 38099756\n assert candidate(n = 7000) == 12250000\n assert candidate(n = 49) == 600\n assert candidate(n = 2000) == 1000000\n assert candidate(n = 7500) == 14062500\n assert candidate(n = 8888) == 19749136\n assert candidate(n = 50) == 625\n assert candidate(n = 3333) == 2777222\n assert candidate(n = 5) == 6\n assert candidate(n = 3000) == 2250000\n assert candidate(n = 6789) == 11522630\n assert candidate(n = 1200) == 360000\n assert candidate(n = 99) == 2450\n assert candidate(n = 5001) == 6252500\n assert candidate(n = 1001) == 250500\n assert candidate(n = 2) == 1\n assert candidate(n = 101) == 2550\n assert candidate(n = 8) == 16\n assert candidate(n = 9998) == 24990001\n assert candidate(n = 20000) == 100000000\n assert candidate(n = 999) == 249500\n assert candidate(n = 5555) == 7714506\n assert candidate(n = 8000) == 16000000\n assert candidate(n = 5000) == 6250000\n assert candidate(n = 9999) == 24995000\n assert candidate(n = 19) == 90\n assert candidate(n = 77) == 1482\n assert candidate(n = 12000) == 36000000\n assert candidate(n = 6667) == 11112222\n assert candidate(n = 150) == 5625\n assert candidate(n = 13) == 42\n assert candidate(n = 7654) == 14645929\n assert candidate(n = 11111) == 30863580\n assert candidate(n = 11) == 30\n assert candidate(n = 15) == 56\n assert candidate(n = 2500) == 1562500\n assert candidate(n = 9000) == 20250000\n assert candidate(n = 4999) == 6247500\n assert candidate(n = 200) == 10000\n assert candidate(n = 6000) == 9000000\n assert candidate(n = 499) == 62250\n assert candidate(n = 500) == 62500\n assert candidate(n = 7) == 12\n assert candidate(n = 25) == 156\n assert candidate(n = 1500) == 562500\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minOperations(self, n: int) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1552, "task_id": "magnetic-force-between-two-balls", "difficulty": "Medium", "problem_description": "In the universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has n empty baskets, the ith basket is at position[i], Morty has m balls and needs to distribute the balls into the baskets such that the minimum magnetic force between any two balls is maximum.\nRick stated that magnetic force between two different balls at positions x and y is |x - y|.\nGiven the integer array position and the integer m. Return the required force.\n \nExample 1:\n\n\nInput: position = [1,2,3,4,7], m = 3\nOutput: 3\nExplanation: Distributing the 3 balls into baskets 1, 4 and 7 will make the magnetic force between ball pairs [3, 3, 6]. The minimum magnetic force is 3. We cannot achieve a larger minimum magnetic force than 3.\n\nExample 2:\n\nInput: position = [5,4,3,2,1,1000000000], m = 2\nOutput: 999999999\nExplanation: We can use baskets 1 and 1000000000.\n\n \nConstraints:\n\nn == position.length\n2 <= n <= 105\n1 <= position[i] <= 109\nAll integers in position are distinct.\n2 <= m <= position.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5) == 2\n assert candidate(position = [5, 4, 3, 2, 1, 1000000000],m = 2) == 999999999\n assert candidate(position = [1, 3, 5, 7, 9],m = 4) == 2\n assert candidate(position = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],m = 5) == 4\n assert candidate(position = [10, 20, 30, 40, 50],m = 4) == 10\n assert candidate(position = [10, 15, 20, 25, 30],m = 3) == 10\n assert candidate(position = [1, 1000000000],m = 2) == 999999999\n assert candidate(position = [10, 20, 30, 40, 50],m = 3) == 20\n assert candidate(position = [1, 2, 3, 4, 7],m = 3) == 3\n assert candidate(position = [1, 2, 8, 4, 9],m = 3) == 3\n assert candidate(position = [1, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],m = 11) == 99\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],m = 10) == 30\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 12) == 10\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 10) == 3\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],m = 7) == 20\n assert candidate(position = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],m = 6) == 31\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 25) == 1\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == 1\n assert candidate(position = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],m = 20) == 2\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],m = 25) == 2\n assert candidate(position = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],m = 15) == 5\n assert candidate(position = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],m = 5) == 999999\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 10) == 2\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500],m = 7) == 40\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],m = 50) == 2\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 10) == 20\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250],m = 12) == 20\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],m = 20) == 10\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500],m = 8) == 30\n assert candidate(position = [1, 2, 8, 4, 9, 15, 22, 28, 34, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 100],m = 6) == 18\n assert candidate(position = [1, 4, 10, 15, 20, 26, 30, 40],m = 5) == 9\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],m = 20) == 10\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 5) == 20\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 15) == 2\n assert candidate(position = [1, 1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000],m = 5) == 2000000000\n assert candidate(position = [1, 500000000, 1000000000, 1500000000, 2000000000],m = 3) == 999999999\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 6) == 19\n assert candidate(position = [1, 2, 3, 6, 7, 8, 10, 12, 13, 15],m = 6) == 2\n assert candidate(position = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],m = 25) == 4\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 7) == 2\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 300, 400, 500, 600],m = 15) == 19\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 17) == 1\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 15) == 10\n assert candidate(position = [1, 1000000000],m = 2) == 999999999\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 200, 300, 400, 500, 600, 700, 800, 900, 1000],m = 10) == 100\n assert candidate(position = [1, 100, 1000, 10000, 100000, 1000000, 10000000],m = 4) == 99999\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],m = 10) == 20\n assert candidate(position = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],m = 15) == 127\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 10) == 20\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 6) == 19\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 10) == 2\n assert candidate(position = [1, 5, 9, 15, 22, 30],m = 5) == 6\n assert candidate(position = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],m = 15) == 4\n assert candidate(position = [1, 3, 6, 8, 12, 15, 18, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],m = 15) == 5\n assert candidate(position = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024],m = 15) == 57\n assert candidate(position = [1, 3, 6, 8, 11, 14, 17, 20, 25, 30, 35, 40, 45, 50],m = 8) == 5\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500],m = 25) == 20\n assert candidate(position = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125],m = 7) == 20\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 6) == 10\n assert candidate(position = [1, 1000000000, 2, 500000000, 750000000],m = 3) == 499999999\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 5) == 20\n assert candidate(position = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82],m = 5) == 18\n assert candidate(position = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],m = 6) == 20\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 8) == 2\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],m = 8) == 20\n assert candidate(position = [1, 5, 9, 14, 20, 25, 30],m = 5) == 5\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 5) == 20\n assert candidate(position = [1, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],m = 5) == 999999\n assert candidate(position = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],m = 7) == 9999\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],m = 5) == 20\n assert candidate(position = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900],m = 5) == 200\n assert candidate(position = [1, 2, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120],m = 5) == 6\n assert candidate(position = [1, 3, 6, 8, 12, 15, 18, 20, 22, 25, 28, 30],m = 7) == 3\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 15) == 2\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],m = 20) == 2\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],m = 8) == 20\n assert candidate(position = [5, 18, 23, 42, 57, 62, 75, 80],m = 5) == 18\n assert candidate(position = [1, 2, 1000000000, 2000000000, 3000000000, 4000000000, 5000000000],m = 4) == 1000000000\n assert candidate(position = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210],m = 15) == 10\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],m = 15) == 20\n assert candidate(position = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61],m = 8) == 8\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 20) == 1\n assert candidate(position = [2, 6, 8, 12, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 100, 102, 104, 106, 108, 110],m = 25) == 4\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],m = 13) == 2\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 11) == 19\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],m = 15) == 1\n assert candidate(position = [1, 100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000],m = 6) == 199999999\n"}, "metadata": {"canonical_parameter_names": ["position", "m"], "leetcode_dataset_entry_point": "Solution().maxDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxDistance(self, position: list[int], m: int) -> int:", "container": "Solution", "callable": "maxDistance", "parameters": [{"name": "position", "type": "list[int]"}, {"name": "m", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1553, "task_id": "minimum-number-of-days-to-eat-n-oranges", "difficulty": "Hard", "problem_description": "There are n oranges in the kitchen and you decided to eat some of these oranges every day as follows:\n\nEat one orange.\nIf the number of remaining oranges n is divisible by 2 then you can eat n / 2 oranges.\nIf the number of remaining oranges n is divisible by 3 then you can eat 2 * (n / 3) oranges.\n\nYou can only choose one of the actions per day.\nGiven the integer n, return the minimum number of days to eat n oranges.\n \nExample 1:\n\nInput: n = 10\nOutput: 4\nExplanation: You have 10 oranges.\nDay 1: Eat 1 orange, 10 - 1 = 9. \nDay 2: Eat 6 oranges, 9 - 2*(9/3) = 9 - 6 = 3. (Since 9 is divisible by 3)\nDay 3: Eat 2 oranges, 3 - 2*(3/3) = 3 - 2 = 1. \nDay 4: Eat the last orange 1 - 1 = 0.\nYou need at least 4 days to eat the 10 oranges.\n\nExample 2:\n\nInput: n = 6\nOutput: 3\nExplanation: You have 6 oranges.\nDay 1: Eat 3 oranges, 6 - 6/2 = 6 - 3 = 3. (Since 6 is divisible by 2).\nDay 2: Eat 2 oranges, 3 - 2*(3/3) = 3 - 2 = 1. (Since 3 is divisible by 3)\nDay 3: Eat the last orange 1 - 1 = 0.\nYou need at least 3 days to eat the 6 oranges.\n\n \nConstraints:\n\n1 <= n <= 2 * 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 2\n assert candidate(n = 2000000000) == 32\n assert candidate(n = 100) == 8\n assert candidate(n = 1000) == 10\n assert candidate(n = 5) == 4\n assert candidate(n = 4) == 3\n assert candidate(n = 2) == 2\n assert candidate(n = 8) == 4\n assert candidate(n = 27) == 4\n assert candidate(n = 20) == 5\n assert candidate(n = 1000000000) == 31\n assert candidate(n = 18017459) == 28\n assert candidate(n = 15) == 5\n assert candidate(n = 9) == 3\n assert candidate(n = 1000000) == 20\n assert candidate(n = 6) == 3\n assert candidate(n = 1) == 1\n assert candidate(n = 10) == 4\n assert candidate(n = 25) == 6\n assert candidate(n = 619) == 12\n assert candidate(n = 239) == 11\n assert candidate(n = 53) == 8\n assert candidate(n = 2147483647) == 35\n assert candidate(n = 587) == 12\n assert candidate(n = 787) == 11\n assert candidate(n = 1000000019) == 34\n assert candidate(n = 971) == 13\n assert candidate(n = 43) == 7\n assert candidate(n = 887) == 13\n assert candidate(n = 983) == 11\n assert candidate(n = 523) == 10\n assert candidate(n = 379) == 9\n assert candidate(n = 103) == 9\n assert candidate(n = 37) == 6\n assert candidate(n = 937) == 11\n assert candidate(n = 487) == 8\n assert candidate(n = 223) == 9\n assert candidate(n = 211) == 11\n assert candidate(n = 23) == 7\n assert candidate(n = 73) == 7\n assert candidate(n = 941) == 12\n assert candidate(n = 827) == 13\n assert candidate(n = 547) == 10\n assert candidate(n = 251) == 10\n assert candidate(n = 181) == 8\n assert candidate(n = 333333333) == 29\n assert candidate(n = 193) == 9\n assert candidate(n = 1048576) == 21\n assert candidate(n = 131) == 10\n assert candidate(n = 241) == 9\n assert candidate(n = 263) == 10\n assert candidate(n = 347) == 11\n assert candidate(n = 1000000013) == 34\n assert candidate(n = 857) == 13\n assert candidate(n = 383) == 11\n assert candidate(n = 997) == 11\n assert candidate(n = 569) == 10\n assert candidate(n = 929) == 12\n assert candidate(n = 571) == 10\n assert candidate(n = 491) == 10\n assert candidate(n = 11) == 5\n assert candidate(n = 643) == 12\n assert candidate(n = 246813579) == 30\n assert candidate(n = 1048575) == 23\n assert candidate(n = 823543) == 23\n assert candidate(n = 500000000) == 31\n assert candidate(n = 353) == 10\n assert candidate(n = 313) == 10\n assert candidate(n = 829) == 11\n assert candidate(n = 167) == 9\n assert candidate(n = 1111111111) == 31\n assert candidate(n = 467) == 12\n assert candidate(n = 54321) == 20\n assert candidate(n = 97) == 8\n assert candidate(n = 29) == 6\n assert candidate(n = 317) == 11\n assert candidate(n = 433) == 9\n assert candidate(n = 131071) == 21\n assert candidate(n = 789456123) == 31\n assert candidate(n = 1999999998) == 31\n assert candidate(n = 271) == 8\n assert candidate(n = 797) == 12\n assert candidate(n = 107) == 10\n assert candidate(n = 163) == 7\n assert candidate(n = 557) == 12\n assert candidate(n = 653) == 10\n assert candidate(n = 631) == 12\n assert candidate(n = 991) == 10\n assert candidate(n = 617) == 12\n assert candidate(n = 389) == 11\n assert candidate(n = 751) == 11\n assert candidate(n = 625000000) == 28\n assert candidate(n = 401) == 11\n assert candidate(n = 1000000002) == 31\n assert candidate(n = 44) == 7\n assert candidate(n = 137) == 9\n assert candidate(n = 919) == 11\n assert candidate(n = 17) == 6\n assert candidate(n = 257) == 10\n assert candidate(n = 811) == 9\n assert candidate(n = 509) == 11\n assert candidate(n = 16777215) == 24\n assert candidate(n = 777777777) == 33\n assert candidate(n = 101) == 9\n assert candidate(n = 907) == 12\n assert candidate(n = 821) == 11\n assert candidate(n = 421) == 12\n assert candidate(n = 479) == 12\n assert candidate(n = 89) == 9\n assert candidate(n = 953) == 13\n assert candidate(n = 877) == 11\n assert candidate(n = 71) == 10\n assert candidate(n = 1000000001) == 32\n assert candidate(n = 599) == 12\n assert candidate(n = 81) == 5\n assert candidate(n = 593) == 11\n assert candidate(n = 151) == 9\n assert candidate(n = 293) == 10\n assert candidate(n = 691) == 11\n assert candidate(n = 41) == 7\n assert candidate(n = 647) == 13\n assert candidate(n = 727) == 11\n assert candidate(n = 209) == 10\n assert candidate(n = 83) == 7\n assert candidate(n = 661) == 10\n assert candidate(n = 123456789) == 28\n assert candidate(n = 283) == 10\n assert candidate(n = 499) == 10\n assert candidate(n = 577) == 10\n assert candidate(n = 1000000011) == 32\n assert candidate(n = 739) == 9\n assert candidate(n = 881) == 11\n assert candidate(n = 659) == 11\n assert candidate(n = 79) == 8\n assert candidate(n = 63) == 6\n assert candidate(n = 269) == 11\n assert candidate(n = 61) == 7\n assert candidate(n = 373) == 10\n assert candidate(n = 999999999) == 30\n assert candidate(n = 227) == 10\n assert candidate(n = 563) == 12\n assert candidate(n = 47) == 8\n assert candidate(n = 4096) == 13\n assert candidate(n = 113) == 8\n assert candidate(n = 233) == 10\n assert candidate(n = 911) == 13\n assert candidate(n = 863) == 15\n assert candidate(n = 859) == 13\n assert candidate(n = 359) == 12\n assert candidate(n = 443) == 11\n assert candidate(n = 135792468) == 28\n assert candidate(n = 78125) == 18\n assert candidate(n = 191) == 9\n assert candidate(n = 125000000) == 29\n assert candidate(n = 311) == 12\n assert candidate(n = 457) == 10\n assert candidate(n = 179) == 11\n assert candidate(n = 337) == 9\n assert candidate(n = 773) == 12\n assert candidate(n = 733) == 9\n assert candidate(n = 419) == 12\n assert candidate(n = 314159265) == 28\n assert candidate(n = 65536) == 17\n assert candidate(n = 967) == 12\n assert candidate(n = 127) == 8\n assert candidate(n = 1000000007) == 34\n assert candidate(n = 947) == 13\n assert candidate(n = 987654321) == 29\n assert candidate(n = 1234567890) == 29\n assert candidate(n = 307) == 10\n assert candidate(n = 503) == 12\n assert candidate(n = 397) == 10\n assert candidate(n = 3125000000) == 30\n assert candidate(n = 26) == 6\n assert candidate(n = 281) == 10\n assert candidate(n = 743) == 11\n assert candidate(n = 1800000000) == 31\n assert candidate(n = 3125) == 15\n assert candidate(n = 1999999999) == 32\n assert candidate(n = 899999999) == 36\n assert candidate(n = 13) == 5\n assert candidate(n = 719) == 14\n assert candidate(n = 222222222) == 29\n assert candidate(n = 59049) == 11\n assert candidate(n = 601) == 11\n assert candidate(n = 1000000003) == 32\n assert candidate(n = 367) == 10\n assert candidate(n = 125) == 9\n assert candidate(n = 839) == 11\n assert candidate(n = 277) == 10\n assert candidate(n = 19683) == 10\n assert candidate(n = 613) == 11\n assert candidate(n = 89123456) == 27\n assert candidate(n = 197) == 10\n assert candidate(n = 157) == 9\n assert candidate(n = 769) == 11\n assert candidate(n = 673) == 10\n assert candidate(n = 439) == 10\n assert candidate(n = 1500000000) == 32\n assert candidate(n = 331) == 9\n assert candidate(n = 173) == 9\n assert candidate(n = 67) == 8\n assert candidate(n = 607) == 12\n assert candidate(n = 349) == 10\n assert candidate(n = 431) == 14\n assert candidate(n = 666666666) == 30\n assert candidate(n = 683) == 12\n assert candidate(n = 449) == 10\n assert candidate(n = 677) == 11\n assert candidate(n = 809) == 13\n assert candidate(n = 977) == 10\n assert candidate(n = 897654321) == 30\n assert candidate(n = 463) == 11\n assert candidate(n = 757) == 9\n assert candidate(n = 521) == 12\n assert candidate(n = 853) == 13\n assert candidate(n = 1024) == 11\n assert candidate(n = 883) == 11\n assert candidate(n = 709) == 11\n assert candidate(n = 701) == 12\n assert candidate(n = 823) == 11\n assert candidate(n = 149) == 9\n assert candidate(n = 19) == 5\n assert candidate(n = 139) == 9\n assert candidate(n = 461) == 11\n assert candidate(n = 541) == 9\n assert candidate(n = 641) == 11\n assert candidate(n = 761) == 11\n assert candidate(n = 109) == 7\n assert candidate(n = 31) == 6\n assert candidate(n = 229) == 9\n assert candidate(n = 199) == 9\n assert candidate(n = 7) == 4\n assert candidate(n = 409) == 10\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minDays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minDays(self, n: int) -> int:", "container": "Solution", "callable": "minDays", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1556, "task_id": "thousand-separator", "difficulty": "Easy", "problem_description": "Given an integer n, add a dot (\".\") as the thousands separator and return it in string format.\n \nExample 1:\n\nInput: n = 987\nOutput: \"987\"\n\nExample 2:\n\nInput: n = 1234\nOutput: \"1.234\"\n\n \nConstraints:\n\n0 <= n <= 231 - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == \"0\"\n assert candidate(n = 1234) == \"1.234\"\n assert candidate(n = 1000000) == \"1.000.000\"\n assert candidate(n = 2147483647) == \"2.147.483.647\"\n assert candidate(n = 123456789) == \"123.456.789\"\n assert candidate(n = 1234567) == \"1.234.567\"\n assert candidate(n = 123456) == \"123.456\"\n assert candidate(n = 56789) == \"56.789\"\n assert candidate(n = 1000) == \"1.000\"\n assert candidate(n = 987) == \"987\"\n assert candidate(n = 111222333444555666777888999) == \"111.222.333.444.555.666.777.888.999\"\n assert candidate(n = 123456789012) == \"123.456.789.012\"\n assert candidate(n = 999999999) == \"999.999.999\"\n assert candidate(n = 1000000000000000) == \"1.000.000.000.000.000\"\n assert candidate(n = 1234567890123456789) == \"1.234.567.890.123.456.789\"\n assert candidate(n = 123456789123456789) == \"123.456.789.123.456.789\"\n assert candidate(n = 999999999999) == \"999.999.999.999\"\n assert candidate(n = 100) == \"100\"\n assert candidate(n = 456789012) == \"456.789.012\"\n assert candidate(n = 1000000000000) == \"1.000.000.000.000\"\n assert candidate(n = 123) == \"123\"\n assert candidate(n = 1) == \"1\"\n assert candidate(n = 1001001) == \"1.001.001\"\n assert candidate(n = 1234567890123456) == \"1.234.567.890.123.456\"\n assert candidate(n = 10000) == \"10.000\"\n assert candidate(n = 111111111111111) == \"111.111.111.111.111\"\n assert candidate(n = 1001) == \"1.001\"\n assert candidate(n = 9876543210987654321) == \"9.876.543.210.987.654.321\"\n assert candidate(n = 101010101) == \"101.010.101\"\n assert candidate(n = 10000000000) == \"10.000.000.000\"\n assert candidate(n = 100000) == \"100.000\"\n assert candidate(n = 98765432109876543210987654321) == \"98.765.432.109.876.543.210.987.654.321\"\n assert candidate(n = 9876543210) == \"9.876.543.210\"\n assert candidate(n = 999) == \"999\"\n assert candidate(n = 1000000000) == \"1.000.000.000\"\n assert candidate(n = 1234567890123) == \"1.234.567.890.123\"\n assert candidate(n = 111111111) == \"111.111.111\"\n assert candidate(n = 1010101010) == \"1.010.101.010\"\n assert candidate(n = 456789012345) == \"456.789.012.345\"\n assert candidate(n = 1234567890) == \"1.234.567.890\"\n assert candidate(n = 567890123) == \"567.890.123\"\n assert candidate(n = 987654321) == \"987.654.321\"\n assert candidate(n = 987654321098) == \"987.654.321.098\"\n assert candidate(n = 123456789012345) == \"123.456.789.012.345\"\n assert candidate(n = 123456789123) == \"123.456.789.123\"\n assert candidate(n = 999999) == \"999.999\"\n assert candidate(n = 987654321098765) == \"987.654.321.098.765\"\n assert candidate(n = 1111111111) == \"1.111.111.111\"\n assert candidate(n = 54321) == \"54.321\"\n assert candidate(n = 10) == \"10\"\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().thousandSeparator", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def thousandSeparator(self, n: int) -> str:", "container": "Solution", "callable": "thousandSeparator", "parameters": [{"name": "n", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1557, "task_id": "minimum-number-of-vertices-to-reach-all-nodes", "difficulty": "Medium", "problem_description": "Given a directed acyclic graph, with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [fromi, toi] represents a directed edge from node fromi to node toi.\nFind the smallest set of vertices from which all nodes in the graph are reachable. It's guaranteed that a unique solution exists.\nNotice that you can return the vertices in any order.\n \nExample 1:\n\n\nInput: n = 6, edges = [[0,1],[0,2],[2,5],[3,4],[4,2]]\nOutput: [0,3]\nExplanation: It's not possible to reach all the nodes from a single vertex. From 0 we can reach [0,1,2,5]. From 3 we can reach [3,4,2,5]. So we output [0,3].\nExample 2:\n\n\nInput: n = 5, edges = [[0,1],[2,1],[3,1],[1,4],[2,4]]\nOutput: [0,2,3]\nExplanation: Notice that vertices 0, 3 and 2 are not reachable from any other node, so we must include them. Also any of these vertices can reach nodes 1 and 4.\n\n \nConstraints:\n\n2 <= n <= 10^5\n1 <= edges.length <= min(10^5, n * (n - 1) / 2)\nedges[i].length == 2\n0 <= fromi, toi < n\nAll pairs (fromi, toi) are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 7,edges = [[1, 2], [3, 4], [5, 6]]) == [0, 1, 3, 5]\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [2, 5], [3, 4], [4, 2]]) == [0, 3]\n assert candidate(n = 4,edges = [[2, 0], [2, 1], [1, 3]]) == [2]\n assert candidate(n = 3,edges = [[0, 1], [0, 2]]) == [0]\n assert candidate(n = 5,edges = [[0, 1], [2, 1], [3, 1], [1, 4], [2, 4]]) == [0, 2, 3]\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9]]) == [0, 5]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14]]) == [0]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 19], [17, 19], [18, 19]]) == [0]\n assert candidate(n = 16,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 13], [14, 15]]) == [0]\n assert candidate(n = 11,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]]) == [0]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19]]) == [0]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17], [15, 18], [16, 19]]) == [0]\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [0]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14]]) == [0]\n assert candidate(n = 14,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [8, 13]]) == [0]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == [0]\n assert candidate(n = 14,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 13], [11, 12]]) == [0]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9]]) == [0]\n assert candidate(n = 13,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == [0]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [0, 9]]) == [0]\n assert candidate(n = 13,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12]]) == [0]\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24]]) == [0]\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [3, 6], [4, 7], [5, 8]]) == []\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [5, 7], [6, 8]]) == [0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [3, 4], [4, 5], [6, 7], [8, 9]]) == [0, 1, 6, 8]\n assert candidate(n = 16,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15]]) == [0]\n assert candidate(n = 11,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9], [8, 10]]) == [0]\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 8]]) == [0]\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 1]]) == []\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 0], [11, 0]]) == []\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 9], [7, 9], [8, 9]]) == [0]\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 0], [6, 1], [7, 2]]) == []\n assert candidate(n = 30,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == [0]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 7], [7, 8], [8, 9], [9, 7]]) == [0]\n assert candidate(n = 14,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13]]) == [0]\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24]]) == [0]\n assert candidate(n = 8,edges = [[0, 2], [1, 2], [2, 3], [4, 5], [6, 7]]) == [0, 1, 4, 6]\n assert candidate(n = 10,edges = [[0, 2], [0, 3], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7]]) == [0, 1, 8, 9]\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 5], [1, 6], [2, 7], [3, 8], [4, 0], [5, 1], [6, 2], [7, 3], [8, 4]]) == []\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19]]) == [0]\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 8]]) == [0]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11]]) == [0]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19]]) == [0]\n assert candidate(n = 18,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17]]) == [0]\n assert candidate(n = 11,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == [0]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 11]]) == [0]\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [0]\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 4], [3, 4]]) == [0, 5]\n assert candidate(n = 10,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == [0, 2, 4, 6, 8]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11]]) == [0]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [0]\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 6], [6, 7]]) == [0]\n assert candidate(n = 8,edges = [[0, 2], [1, 2], [2, 3], [2, 4], [3, 5], [4, 5], [5, 6], [5, 7]]) == [0, 1]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 0], [9, 1]]) == []\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == [0]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [0]\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7]]) == [0]\n assert candidate(n = 16,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15]]) == [0]\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]]) == []\n assert candidate(n = 20,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [0, 4], [4, 8], [8, 12], [12, 16], [16, 0], [1, 5], [5, 9], [9, 13], [13, 17], [17, 1]]) == [2, 6, 10, 14, 18]\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == [0]\n assert candidate(n = 20,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 16], [16, 18], [1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19]]) == [0]\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [10, 11], [11, 12], [12, 13], [13, 14]]) == [0, 10]\n assert candidate(n = 13,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [0, 5], [2, 7], [4, 9]]) == [0]\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 8], [8, 4]]) == []\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24]]) == [0]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 12], [12, 13], [13, 14]]) == [0]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9], [8, 9]]) == [0]\n assert candidate(n = 16,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15]]) == [0]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9]]) == [0]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [7, 11]]) == [0]\n assert candidate(n = 15,edges = [[0, 5], [2, 3], [3, 4], [5, 14], [1, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [0, 1, 2]\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]]) == [0]\n assert candidate(n = 30,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21], [22, 23], [24, 25], [26, 27], [28, 29]]) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 7]]) == [0]\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8]]) == [0]\n assert candidate(n = 12,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [0]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().findSmallestSetOfVertices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findSmallestSetOfVertices(self, n: int, edges: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "findSmallestSetOfVertices", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1558, "task_id": "minimum-numbers-of-function-calls-to-make-target-array", "difficulty": "Medium", "problem_description": "You are given an integer array nums. You have an integer array arr of the same length with all values set to 0 initially. You also have the following modify function:\n\nYou want to use the modify function to convert arr to nums using the minimum number of calls.\nReturn the minimum number of function calls to make nums from arr.\nThe test cases are generated so that the answer fits in a 32-bit signed integer.\n \nExample 1:\n\nInput: nums = [1,5]\nOutput: 5\nExplanation: Increment by 1 (second element): [0, 0] to get [0, 1] (1 operation).\nDouble all the elements: [0, 1] -> [0, 2] -> [0, 4] (2 operations).\nIncrement by 1 (both elements) [0, 4] -> [1, 4] -> [1, 5] (2 operations).\nTotal of operations: 1 + 2 + 2 = 5.\n\nExample 2:\n\nInput: nums = [2,2]\nOutput: 3\nExplanation: Increment by 1 (both elements) [0, 0] -> [0, 1] -> [1, 1] (2 operations).\nDouble all the elements: [1, 1] -> [2, 2] (1 operation).\nTotal of operations: 2 + 1 = 3.\n\nExample 3:\n\nInput: nums = [4,2,5]\nOutput: 6\nExplanation: (initial)[0,0,0] -> [1,0,0] -> [1,0,1] -> [2,0,2] -> [2,1,2] -> [4,2,4] -> [4,2,5](nums).\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1000000000]) == 43\n assert candidate(nums = [10, 20, 30]) == 12\n assert candidate(nums = [10, 15, 20]) == 12\n assert candidate(nums = [1, 1, 1, 1]) == 4\n assert candidate(nums = [3, 3, 3, 3]) == 9\n assert candidate(nums = [2, 4, 6, 8, 10]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9]) == 13\n assert candidate(nums = [1, 5]) == 5\n assert candidate(nums = [1, 3, 7, 15, 31]) == 19\n assert candidate(nums = [1000000000, 1000000000]) == 55\n assert candidate(nums = [4, 2, 5]) == 6\n assert candidate(nums = [1000000000, 1000000000, 1000000000]) == 68\n assert candidate(nums = [3, 6, 9, 12, 15]) == 15\n assert candidate(nums = [5, 10, 15, 20, 25, 30]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5]) == 9\n assert candidate(nums = [1023, 511, 255]) == 36\n assert candidate(nums = [16, 8, 4, 2, 1]) == 9\n assert candidate(nums = [0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [9, 9, 9, 9, 9]) == 13\n assert candidate(nums = [2, 2]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 84\n assert candidate(nums = [81, 27, 9, 3, 1]) == 18\n assert candidate(nums = [100, 200, 300, 400]) == 21\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 40\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 41\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(nums = [1000000000]) == 42\n assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 41\n assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144]) == 29\n assert candidate(nums = [1, 1000000000]) == 43\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 229\n assert candidate(nums = [1048575, 1048574, 1048573, 1048572, 1048571, 1048570, 1048569, 1048568, 1048567, 1048566, 1048565, 1048564, 1048563, 1048562, 1048561, 1048560]) == 307\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 37\n assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560]) == 29\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 20\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [63, 127, 255, 511, 1023]) == 49\n assert candidate(nums = [2147483647, 2147483647, 2147483647, 2147483647, 2147483647]) == 185\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 10\n assert candidate(nums = [8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15]) == 292\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336, 28672, 57344, 114688]) == 61\n assert candidate(nums = [31, 15, 7, 3, 1]) == 19\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 21\n assert candidate(nums = [987654321, 123456789, 98765432, 12345678, 9876543, 1234567]) == 112\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 47\n assert candidate(nums = [987654321, 876543210, 765432109, 654321098, 543210987, 432109876, 321098765, 210987654, 109876543, 98765432, 87654321, 76543210, 65432109, 54321098, 43210987, 32109876, 21098765, 10987654, 9876543, 8765432]) == 320\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260]) == 87\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000]) == 94\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 229\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 224\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383]) == 118\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31]) == 54\n assert candidate(nums = [1000000000, 1000000000, 1000000000]) == 68\n assert candidate(nums = [16, 8, 4, 2, 1, 0, 0, 0, 0, 0]) == 9\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 159\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512]) == 29\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 16\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 29\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 15\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000]) == 81\n assert candidate(nums = [1000000000, 0, 1000000000, 0, 1000000000, 0, 1000000000, 0, 1000000000, 0]) == 94\n assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048]) == 30\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 92\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 29\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 32\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == 23\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907, 953, 476, 238, 119, 59, 29, 14, 7, 3, 1]) == 303\n assert candidate(nums = [29, 14, 7, 3, 1]) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 31\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 64\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 23\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 73\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0]) == 8\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == 57\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == 86\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 35\n assert candidate(nums = [1023, 512, 256, 128, 64]) == 23\n assert candidate(nums = [16, 8, 4, 2, 1, 32, 64, 128, 256, 512]) == 19\n assert candidate(nums = [1073741824, 536870912, 268435456, 134217728, 67108864]) == 35\n assert candidate(nums = [5, 15, 25, 35, 45, 55]) == 26\n assert candidate(nums = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 29\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 25\n assert candidate(nums = [84, 126, 189, 252, 315, 378, 441, 504, 567, 630]) == 66\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995]) == 129\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579, 111222333]) == 100\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 35\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 21\n assert candidate(nums = [13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 82\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [299999999, 299999999, 299999999, 299999999, 299999999]) == 113\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 54\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 91\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 106\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minOperations(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1559, "task_id": "detect-cycles-in-2d-grid", "difficulty": "Medium", "problem_description": "Given a 2D array of characters grid of size m x n, you need to find if there exists any cycle consisting of the same value in grid.\nA cycle is a path of length 4 or more in the grid that starts and ends at the same cell. From a given cell, you can move to one of the cells adjacent to it - in one of the four directions (up, down, left, or right), if it has the same value of the current cell.\nAlso, you cannot move to the cell that you visited in your last move. For example, the cycle (1, 1) -> (1, 2) -> (1, 1) is invalid because from (1, 2) we visited (1, 1) which was the last visited cell.\nReturn true if any cycle of the same value exists in grid, otherwise, return false.\n \nExample 1:\n\n\nInput: grid = [[\"a\",\"a\",\"a\",\"a\"],[\"a\",\"b\",\"b\",\"a\"],[\"a\",\"b\",\"b\",\"a\"],[\"a\",\"a\",\"a\",\"a\"]]\nOutput: true\nExplanation: There are two valid cycles shown in different colors in the image below:\n\n\nExample 2:\n\n\nInput: grid = [[\"c\",\"c\",\"c\",\"a\"],[\"c\",\"d\",\"c\",\"c\"],[\"c\",\"c\",\"e\",\"c\"],[\"f\",\"c\",\"c\",\"c\"]]\nOutput: true\nExplanation: There is only one valid cycle highlighted in the image below:\n\n\nExample 3:\n\n\nInput: grid = [[\"a\",\"b\",\"b\"],[\"b\",\"z\",\"b\"],[\"b\",\"b\",\"a\"]]\nOutput: false\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 500\ngrid consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [['a', 'b', 'c'], ['b', 'c', 'a'], ['c', 'a', 'b']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b'], ['b', 'a']]) == False\n assert candidate(grid = [['c', 'c', 'c', 'a'], ['c', 'd', 'c', 'c'], ['c', 'c', 'e', 'c'], ['f', 'c', 'c', 'c']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a'], ['a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'b'], ['b', 'z', 'b'], ['b', 'b', 'a']]) == False\n assert candidate(grid = [['a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'b', 'a'], ['a', 'a', 'b', 'b', 'a', 'a'], ['a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['a', 'a', 'a', 'a', 'a'], ['b', 'b', 'b', 'b', 'b'], ['c', 'c', 'c', 'c', 'c'], ['d', 'd', 'd', 'd', 'd']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['p', 'q', 'r'], ['q', 'r', 'p'], ['r', 'p', 'q'], ['p', 'q', 'r']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a'], ['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'a'], ['b', 'c', 'a', 'b'], ['c', 'a', 'b', 'c'], ['a', 'b', 'c', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'a', 'e', 'd', 'c'], ['c', 'e', 'a', 'b', 'd'], ['d', 'c', 'b', 'a', 'e'], ['e', 'd', 'c', 'e', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'b', 'b'], ['a', 'a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a', 'a'], ['b', 'b', 'a', 'a', 'a'], ['b', 'a', 'a', 'a', 'b']]) == True\n assert candidate(grid = [['z', 'y', 'x', 'w', 'v', 'u', 't'], ['y', 'x', 'w', 'v', 'u', 't', 's'], ['x', 'w', 'v', 'u', 't', 's', 'r'], ['w', 'v', 'u', 't', 's', 'r', 'q'], ['v', 'u', 't', 's', 'r', 'q', 'p'], ['u', 't', 's', 'r', 'q', 'p', 'o'], ['t', 's', 'r', 'q', 'p', 'o', 'n']]) == False\n assert candidate(grid = [['c', 'c', 'c', 'c', 'c'], ['c', 'd', 'd', 'd', 'c'], ['c', 'd', 'c', 'd', 'c'], ['c', 'd', 'd', 'd', 'c'], ['c', 'c', 'c', 'c', 'c']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'a', 'b', 'c', 'd', 'e'], ['e', 'f', 'a', 'b', 'c', 'd'], ['d', 'e', 'f', 'a', 'b', 'c'], ['c', 'd', 'e', 'f', 'a', 'b'], ['b', 'c', 'd', 'e', 'f', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a', 'a'], ['a', 'b', 'b', 'a', 'a'], ['a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'e', 'f']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['b', 'c', 'd', 'e', 'f', 'a'], ['c', 'd', 'e', 'f', 'a', 'b'], ['d', 'e', 'f', 'a', 'b', 'c'], ['e', 'f', 'a', 'b', 'c', 'd'], ['f', 'a', 'b', 'c', 'd', 'e']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a'], ['a', 'b', 'a'], ['a', 'a', 'a'], ['a', 'b', 'a'], ['a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'c', 'd', 'e', 'f'], ['c', 'd', 'e', 'f', 'g'], ['d', 'e', 'f', 'g', 'h'], ['e', 'f', 'g', 'h', 'i']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == False\n assert candidate(grid = [['x', 'y', 'z', 'x'], ['y', 'z', 'x', 'y'], ['z', 'x', 'y', 'z'], ['x', 'y', 'z', 'x']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'a', 'b', 'c'], ['b', 'c', 'a', 'b', 'c', 'a'], ['c', 'a', 'b', 'c', 'a', 'b'], ['a', 'b', 'c', 'a', 'b', 'c'], ['b', 'c', 'a', 'b', 'c', 'a'], ['c', 'a', 'b', 'c', 'a', 'b']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'b', 'a'], ['a', 'b', 'b', 'b', 'a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a', 'a', 'a'], ['a', 'a', 'a', 'b', 'a', 'b', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a', 'a', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'c', 'b', 'a'], ['a', 'b', 'c', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['x', 'y', 'z'], ['y', 'x', 'y'], ['z', 'y', 'x'], ['y', 'x', 'y'], ['x', 'y', 'z']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'a', 'b', 'c', 'd'], ['c', 'b', 'a', 'b', 'c'], ['d', 'c', 'b', 'a', 'b'], ['e', 'd', 'c', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['x', 'x', 'x', 'x', 'x', 'x'], ['x', 'y', 'y', 'y', 'y', 'x'], ['x', 'y', 'z', 'z', 'y', 'x'], ['x', 'y', 'z', 'z', 'y', 'x'], ['x', 'y', 'y', 'y', 'y', 'x'], ['x', 'x', 'x', 'x', 'x', 'x']]) == True\n assert candidate(grid = [['x', 'x', 'x', 'x'], ['x', 'y', 'y', 'x'], ['x', 'y', 'y', 'x'], ['x', 'x', 'x', 'x']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['a', 'a', 'a', 'a', 'a', 'a'], ['b', 'c', 'd', 'e', 'f', 'g'], ['g', 'f', 'e', 'd', 'c', 'b'], ['a', 'a', 'a', 'a', 'a', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c'], ['b', 'a', 'b'], ['c', 'b', 'a']]) == False\n assert candidate(grid = [['p', 'p', 'q', 'p', 'p'], ['p', 'q', 'q', 'q', 'p'], ['q', 'q', 'r', 'q', 'q'], ['p', 'q', 'q', 'q', 'p'], ['p', 'p', 'q', 'p', 'p']]) == True\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a'], ['b', 'b', 'b'], ['a', 'a', 'a'], ['b', 'b', 'b'], ['a', 'a', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'c', 'd', 'e', 'a'], ['c', 'd', 'e', 'a', 'b'], ['d', 'e', 'a', 'b', 'c'], ['e', 'a', 'b', 'c', 'd']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'd', 'c', 'b'], ['a', 'b', 'c', 'd', 'd', 'c', 'b'], ['a', 'b', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'a', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'a'], ['b', 'a', 'b', 'c', 'b'], ['c', 'b', 'a', 'b', 'c'], ['d', 'c', 'b', 'a', 'd'], ['a', 'b', 'c', 'd', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'a'], ['b', 'a', 'b', 'c'], ['c', 'b', 'c', 'b'], ['a', 'c', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'c', 'd', 'e', 'a'], ['c', 'd', 'e', 'a', 'b'], ['d', 'e', 'a', 'b', 'c'], ['e', 'a', 'b', 'c', 'd']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['b', 'b', 'b', 'b'], ['c', 'c', 'c', 'c'], ['d', 'd', 'd', 'd'], ['e', 'e', 'e', 'e'], ['f', 'f', 'f', 'f']]) == False\n assert candidate(grid = [['m', 'm', 'm', 'm'], ['m', 'n', 'n', 'm'], ['m', 'n', 'o', 'm'], ['m', 'n', 'n', 'm'], ['m', 'm', 'm', 'm']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o']]) == False\n assert candidate(grid = [['a', 'a', 'b', 'b'], ['a', 'c', 'c', 'a'], ['b', 'c', 'd', 'b'], ['a', 'c', 'c', 'a']]) == False\n assert candidate(grid = [['x', 'y', 'z', 'x'], ['y', 'x', 'y', 'x'], ['z', 'y', 'z', 'y'], ['x', 'z', 'x', 'z']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd'], ['e', 'f', 'g', 'h'], ['i', 'j', 'k', 'l'], ['m', 'n', 'o', 'p']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f', 'g'], ['h', 'i', 'j', 'k', 'l', 'm', 'n'], ['o', 'p', 'q', 'r', 's', 't', 'u'], ['v', 'w', 'x', 'y', 'z', 'v', 'w'], ['x', 'y', 'z', 'v', 'w', 'x', 'y'], ['z', 'v', 'w', 'x', 'y', 'z', 'v']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'c', 'c', 'a', 'b', 'a'], ['a', 'b', 'a', 'c', 'c', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c'], ['b', 'c', 'b'], ['c', 'b', 'a'], ['b', 'c', 'b'], ['a', 'b', 'c']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'b', 'b', 'b'], ['a', 'c', 'a', 'b', 'a', 'b'], ['a', 'a', 'a', 'b', 'b', 'b']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd'], ['b', 'a', 'd', 'c'], ['c', 'd', 'a', 'b'], ['d', 'c', 'b', 'a']]) == False\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().containsCycle", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def containsCycle(self, grid: list[list[str]]) -> bool:", "container": "Solution", "callable": "containsCycle", "parameters": [{"name": "grid", "type": "list[list[str]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1560, "task_id": "most-visited-sector-in-a-circular-track", "difficulty": "Easy", "problem_description": "Given an integer n and an integer array rounds. We have a circular track which consists of n sectors labeled from 1 to n. A marathon will be held on this track, the marathon consists of m rounds. The ith round starts at sector rounds[i - 1] and ends at sector rounds[i]. For example, round 1 starts at sector rounds[0] and ends at sector rounds[1]\nReturn an array of the most visited sectors sorted in ascending order.\nNotice that you circulate the track in ascending order of sector numbers in the counter-clockwise direction (See the first example).\n \nExample 1:\n\n\nInput: n = 4, rounds = [1,3,1,2]\nOutput: [1,2]\nExplanation: The marathon starts at sector 1. The order of the visited sectors is as follows:\n1 --> 2 --> 3 (end of round 1) --> 4 --> 1 (end of round 2) --> 2 (end of round 3 and the marathon)\nWe can see that both sectors 1 and 2 are visited twice and they are the most visited sectors. Sectors 3 and 4 are visited only once.\nExample 2:\n\nInput: n = 2, rounds = [2,1,2,1,2,1,2,1,2]\nOutput: [2]\n\nExample 3:\n\nInput: n = 7, rounds = [1,3,5,7]\nOutput: [1,2,3,4,5,6,7]\n\n \nConstraints:\n\n2 <= n <= 100\n1 <= m <= 100\nrounds.length == m + 1\n1 <= rounds[i] <= n\nrounds[i] != rounds[i + 1] for 0 <= i < m\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,rounds = [1, 3, 1, 2]) == [1, 2]\n assert candidate(n = 7,rounds = [1, 3, 5, 7]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 6,rounds = [3, 6, 2, 4, 1]) == [1, 3, 4, 5, 6]\n assert candidate(n = 6,rounds = [3, 6, 2, 5]) == [3, 4, 5]\n assert candidate(n = 10,rounds = [3, 8, 3]) == [3]\n assert candidate(n = 2,rounds = [2, 1, 2, 1, 2, 1, 2, 1, 2]) == [2]\n assert candidate(n = 5,rounds = [1, 5, 1]) == [1]\n assert candidate(n = 6,rounds = [6, 2, 6, 5]) == [1, 2, 3, 4, 5, 6]\n assert candidate(n = 6,rounds = [3, 6, 2, 5, 1]) == [1, 3, 4, 5, 6]\n assert candidate(n = 3,rounds = [1, 2, 3, 1]) == [1]\n assert candidate(n = 8,rounds = [5, 4, 3, 2, 1, 8, 7, 6, 5]) == [5]\n assert candidate(n = 10,rounds = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 10]\n assert candidate(n = 10,rounds = [3, 8, 3, 10, 3]) == [3]\n assert candidate(n = 10,rounds = [1, 5, 9, 4, 8, 2, 6, 3, 7, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 8,rounds = [4, 8, 1, 5, 9, 2, 6, 3, 7]) == [4, 5, 6, 7]\n assert candidate(n = 15,rounds = [10, 1, 12, 7, 14, 2, 15, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15]\n assert candidate(n = 7,rounds = [3, 6, 2, 5, 3, 6, 2, 5, 3, 6, 2, 5]) == [3, 4, 5]\n assert candidate(n = 12,rounds = [2, 7, 1, 11, 6, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(n = 16,rounds = [8, 16, 10, 4, 12, 2, 14, 6, 1, 9, 17, 3, 11, 5, 13, 7]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(n = 100,rounds = [1, 50, 25, 75, 100, 50, 25, 75, 100, 1, 50, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 20,rounds = [3, 7, 12, 18, 20, 5, 10, 15, 1]) == [1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 30,rounds = [15, 25, 5, 15, 25, 10, 5, 20, 10, 25, 15, 20, 5, 10, 15, 20, 25, 1, 6, 11, 16, 21, 26, 30, 4, 9, 14, 19, 24, 29]) == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\n assert candidate(n = 25,rounds = [10, 20, 5, 15, 25, 1, 11, 16, 6, 21, 12, 22, 7, 23, 13, 24, 8, 2, 18, 9, 3, 19, 4, 24, 25, 17]) == [10, 11, 12, 13, 14, 15, 16, 17]\n assert candidate(n = 10,rounds = [1, 5, 3, 8, 10, 4]) == [1, 2, 3, 4]\n assert candidate(n = 20,rounds = [10, 15, 5, 20, 1, 6, 11, 16, 1, 11]) == [10, 11]\n assert candidate(n = 15,rounds = [15, 5, 10, 12, 3, 14, 8, 6, 1]) == [1, 15]\n assert candidate(n = 20,rounds = [10, 20, 15, 5, 1, 15, 10, 5, 20, 15, 10, 5, 1]) == [1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 8,rounds = [5, 1, 4, 7, 2, 6, 3]) == [1, 2, 3, 5, 6, 7, 8]\n assert candidate(n = 100,rounds = [50, 25, 75, 100, 1, 50, 25, 75, 100, 1, 50, 25, 75, 100, 1]) == [1, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]\n assert candidate(n = 25,rounds = [1, 13, 24, 7, 18, 12, 22, 5, 17, 11, 21, 4, 16, 10, 20, 3, 15, 9, 19, 2, 14, 8, 1, 13, 24, 7]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 90,rounds = [1, 45, 90, 45, 1, 60, 30, 90, 60, 30, 1, 45, 60, 90, 30, 45, 1, 60, 90, 30]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(n = 10,rounds = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1]\n assert candidate(n = 18,rounds = [18, 10, 3, 12, 6, 15, 9, 2, 14, 7, 1, 13, 5, 16, 8, 4, 17, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 18]\n assert candidate(n = 60,rounds = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210, 230, 250, 270, 290, 310, 330, 350, 370, 390, 410, 430, 450, 470, 490, 510, 530, 550, 570, 590]) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590]\n assert candidate(n = 9,rounds = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 9]\n assert candidate(n = 11,rounds = [1, 3, 5, 7, 9, 11, 1, 3, 5, 7, 9, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 40,rounds = [1, 20, 40, 20, 1, 30, 20, 10, 30, 40, 10, 20, 30, 40, 1, 10, 20, 30, 40]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(n = 11,rounds = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 25,rounds = [15, 20, 25, 5, 10, 1, 16, 21, 2, 17, 22, 3, 18, 23, 4, 19, 24, 6, 20, 25, 7, 1, 8, 16, 9, 12]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 25,rounds = [25, 15, 10, 20, 5, 2, 17, 12, 7, 22, 1, 16, 11, 6, 21, 13, 8, 3, 18, 14, 9, 23, 4, 19, 24]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 7,rounds = [7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == [1, 7]\n assert candidate(n = 12,rounds = [12, 3, 6, 9, 12, 3, 6, 9, 12, 3, 6, 9, 12]) == [12]\n assert candidate(n = 9,rounds = [9, 1, 3, 5, 7, 2, 4, 6, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 15,rounds = [5, 10, 15, 1, 6, 11, 13, 8]) == [5, 6, 7, 8]\n assert candidate(n = 12,rounds = [1, 12, 4, 8, 11, 2, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 50,rounds = [25, 45, 5, 30, 40, 50, 10, 35, 45, 20, 40, 50, 25, 50, 15, 45, 25, 50, 35, 50, 45, 50, 10, 40, 20, 50, 30, 50, 40, 50]) == [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n assert candidate(n = 22,rounds = [11, 22, 7, 17, 2, 12, 8, 18, 3, 13, 9, 19, 4, 14, 10, 20, 5, 15, 6, 16, 1, 21]) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(n = 9,rounds = [3, 6, 9, 2, 5, 8, 1, 4, 7]) == [3, 4, 5, 6, 7]\n assert candidate(n = 12,rounds = [1, 7, 12, 4, 9, 2, 8, 5, 10, 3, 11, 6, 1]) == [1]\n assert candidate(n = 20,rounds = [10, 15, 5, 18, 12, 20, 14, 8, 17, 11, 6, 19, 13, 9, 4, 16, 10, 3, 1, 7, 2]) == [1, 2, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 8,rounds = [7, 1, 4, 8, 2, 6, 3, 5]) == [1, 2, 3, 4, 5, 7, 8]\n assert candidate(n = 30,rounds = [30, 10, 20, 3, 13, 23, 6, 16, 26, 9, 19, 29, 12, 22, 3, 13, 23, 6, 16, 26, 9, 19, 29, 12, 22]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 30]\n assert candidate(n = 75,rounds = [1, 38, 75, 38, 1, 50, 25, 75, 50, 25, 1, 38, 50, 75, 25, 38, 1, 50, 75, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 15,rounds = [1, 15, 5, 10, 3, 8, 13, 2]) == [1, 2]\n assert candidate(n = 40,rounds = [20, 30, 40, 10, 20, 30, 10, 40, 20, 30, 10, 40, 20, 30, 10, 40, 20, 30, 10, 40, 20, 30, 10, 40, 20, 30, 10, 40]) == [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(n = 11,rounds = [11, 4, 8, 1, 7, 10, 3, 9, 6, 2, 5, 11, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 11]\n assert candidate(n = 15,rounds = [1, 15, 5, 10, 1, 6, 11, 3, 8, 13]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(n = 8,rounds = [7, 3, 6, 2, 5, 1, 8, 4]) == [1, 2, 3, 4, 7, 8]\n assert candidate(n = 14,rounds = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 50,rounds = [1, 25, 50, 1, 25, 50, 1, 25, 50, 1, 25, 50, 1, 25, 50, 1, 25, 50, 1, 25, 50]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n assert candidate(n = 9,rounds = [3, 6, 2, 8, 4, 1, 9, 5, 7, 3, 6, 2, 8, 4, 1, 9, 5, 7]) == [3, 4, 5, 6, 7]\n assert candidate(n = 50,rounds = [1, 25, 50, 25, 1, 25, 50, 25, 1, 25, 50, 25, 1, 25, 50, 25, 1, 25, 50, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 15,rounds = [14, 3, 12, 8, 5, 2, 15, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 14, 15]\n assert candidate(n = 8,rounds = [8, 1, 4, 7, 2, 5, 8, 3, 6]) == [1, 2, 3, 4, 5, 6, 8]\n assert candidate(n = 12,rounds = [5, 9, 1, 11, 7, 3, 12, 6, 2, 8, 4, 10]) == [5, 6, 7, 8, 9, 10]\n assert candidate(n = 8,rounds = [7, 3, 5, 2, 8, 6, 1, 4]) == [1, 2, 3, 4, 7, 8]\n assert candidate(n = 10,rounds = [1, 5, 3, 9, 2, 8, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 18,rounds = [1, 9, 18, 7, 15, 5, 13, 3, 11, 1, 9, 18, 7, 15, 5, 13, 3, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 50,rounds = [25, 30, 15, 40, 5, 20, 35, 45, 10, 4, 34, 29]) == [25, 26, 27, 28, 29]\n assert candidate(n = 15,rounds = [3, 10, 15, 5, 12, 7, 13, 2, 9, 14, 4, 11, 6, 1, 8]) == [3, 4, 5, 6, 7, 8]\n assert candidate(n = 6,rounds = [6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6]\n assert candidate(n = 20,rounds = [1, 10, 15, 20, 1, 5, 10, 15, 20, 1, 10, 15]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(n = 12,rounds = [12, 6, 3, 9, 1, 7, 4, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12]\n assert candidate(n = 10,rounds = [1, 4, 7, 2, 8, 3, 9, 5, 10, 6]) == [1, 2, 3, 4, 5, 6]\n assert candidate(n = 12,rounds = [4, 8, 1, 7, 11, 5, 9, 12, 6, 10, 2]) == [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(n = 9,rounds = [9, 4, 8, 3, 7, 2, 6, 1, 5]) == [1, 2, 3, 4, 5, 9]\n assert candidate(n = 25,rounds = [12, 17, 22, 2, 7, 12, 17, 22, 2, 7, 12, 17]) == [12, 13, 14, 15, 16, 17]\n assert candidate(n = 7,rounds = [1, 4, 7, 2, 5, 3, 6, 1, 4, 7]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 15,rounds = [1, 14, 8, 11, 5, 13, 9, 2, 7, 15, 4, 12, 6, 3, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 10,rounds = [5, 8, 3, 10, 2, 6]) == [5, 6]\n assert candidate(n = 18,rounds = [18, 13, 8, 3, 17, 12, 7, 2, 16, 11, 6, 1, 15, 10, 5, 14, 9, 4]) == [1, 2, 3, 4, 18]\n assert candidate(n = 8,rounds = [7, 1, 4, 7, 3, 6, 2, 8]) == [7, 8]\n assert candidate(n = 9,rounds = [3, 6, 9, 3, 6, 9, 3]) == [3]\n assert candidate(n = 20,rounds = [1, 15, 5, 10, 20, 12, 7, 18, 3, 16, 8, 13, 2, 19, 6, 14, 4, 17, 9, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 20,rounds = [1, 10, 20, 5, 15, 1, 11, 16, 6, 12, 17, 7, 13, 18, 8, 14, 19, 9, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 15,rounds = [5, 10, 15, 1, 6, 11, 2, 7, 12, 3, 8, 13, 4, 9, 14]) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 9,rounds = [3, 9, 2, 8, 1, 7, 4, 6, 5]) == [3, 4, 5]\n assert candidate(n = 12,rounds = [1, 4, 7, 10, 1, 4, 7, 10, 1]) == [1]\n assert candidate(n = 10,rounds = [10, 3, 5, 7, 9, 2]) == [1, 2, 10]\n assert candidate(n = 12,rounds = [7, 3, 9, 12, 4, 10, 5, 11, 6, 1, 8, 2]) == [1, 2, 7, 8, 9, 10, 11, 12]\n assert candidate(n = 20,rounds = [1, 10, 20, 5, 15, 10, 1, 16, 6, 11, 1, 17, 7, 12, 1, 18, 8, 13, 1, 19]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 10,rounds = [1, 5, 10, 3, 7, 1]) == [1]\n assert candidate(n = 14,rounds = [1, 7, 14, 2, 8, 13, 3, 9, 12, 4, 10, 11, 5, 6, 1]) == [1]\n assert candidate(n = 10,rounds = [5, 10, 3, 8, 1]) == [1, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 25,rounds = [5, 15, 25, 10, 20, 1, 11, 16, 6, 16, 11, 1, 20, 10, 25, 15, 5]) == [5]\n assert candidate(n = 8,rounds = [5, 8, 2, 7, 3, 6, 4, 1]) == [1, 5, 6, 7, 8]\n assert candidate(n = 20,rounds = [1, 10, 20, 5, 15, 3, 9, 18, 7, 12, 19]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 8,rounds = [4, 8, 1, 5, 2, 6, 3, 7]) == [4, 5, 6, 7]\n"}, "metadata": {"canonical_parameter_names": ["n", "rounds"], "leetcode_dataset_entry_point": "Solution().mostVisited", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def mostVisited(self, n: int, rounds: list[int]) -> list[int]:", "container": "Solution", "callable": "mostVisited", "parameters": [{"name": "n", "type": "int"}, {"name": "rounds", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1561, "task_id": "maximum-number-of-coins-you-can-get", "difficulty": "Medium", "problem_description": "There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:\n\nIn each step, you will choose any 3 piles of coins (not necessarily consecutive).\nOf your choice, Alice will pick the pile with the maximum number of coins.\nYou will pick the next pile with the maximum number of coins.\nYour friend Bob will pick the last pile.\nRepeat until there are no more piles of coins.\n\nGiven an array of integers piles where piles[i] is the number of coins in the ith pile.\nReturn the maximum number of coins that you can have.\n \nExample 1:\n\nInput: piles = [2,4,1,2,7,8]\nOutput: 9\nExplanation: Choose the triplet (2, 7, 8), Alice Pick the pile with 8 coins, you the pile with 7 coins and Bob the last one.\nChoose the triplet (1, 2, 4), Alice Pick the pile with 4 coins, you the pile with 2 coins and Bob the last one.\nThe maximum number of coins which you can have are: 7 + 2 = 9.\nOn the other hand if we choose this arrangement (1, 2, 8), (2, 4, 7) you only get 2 + 4 = 6 coins which is not optimal.\n\nExample 2:\n\nInput: piles = [2,4,5]\nOutput: 4\n\nExample 3:\n\nInput: piles = [9,8,7,6,5,1,2,3,4]\nOutput: 18\n\n \nConstraints:\n\n3 <= piles.length <= 105\npiles.length % 3 == 0\n1 <= piles[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(piles = [1, 12, 2, 11, 3, 10, 4, 9, 5, 8, 6, 7]) == 32\n assert candidate(piles = [2, 4, 1, 2, 7, 8]) == 9\n assert candidate(piles = [9, 8, 7, 6, 5, 1, 2, 3, 4]) == 18\n assert candidate(piles = [10000, 10000, 10000, 1, 1, 1, 2, 2, 2]) == 10004\n assert candidate(piles = [1, 12, 3, 11, 5, 10, 7, 4, 8, 6, 9, 2]) == 32\n assert candidate(piles = [1, 12, 3, 10, 5, 8, 7, 4, 6, 9, 11, 2]) == 32\n assert candidate(piles = [2, 4, 5]) == 4\n assert candidate(piles = [10000, 1, 10000, 1, 10000, 1]) == 10001\n assert candidate(piles = [3000, 1000, 2000, 4000, 5000, 6000]) == 8000\n assert candidate(piles = [10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 32\n assert candidate(piles = [10000, 1, 10000, 2, 10000, 3]) == 10003\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 18\n assert candidate(piles = [1, 12, 3, 11, 5, 6, 7, 9, 8]) == 25\n assert candidate(piles = [3, 3, 3, 3, 3, 3]) == 6\n assert candidate(piles = [3, 3, 3, 3, 3, 3, 3, 3, 3]) == 9\n assert candidate(piles = [10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 10200\n assert candidate(piles = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 316\n assert candidate(piles = [9999, 1, 9998, 2, 9997, 3, 9996, 4, 9995, 5, 9994, 6, 9993, 7, 9992, 8, 9991, 9, 9990, 10, 9989, 11, 9988, 12, 9987, 13, 9986, 14, 9985, 15, 9984, 16, 9983, 17, 9982, 18, 9981, 19]) == 89974\n assert candidate(piles = [3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2999, 2998, 2997, 2996, 2995, 2994, 2993, 2992, 2991, 2990, 2989, 2988, 2987, 2986, 2985, 2984, 2983, 2982, 2981, 2980, 2979, 2978, 2977, 2976, 2975, 2974, 2973, 2972, 2971, 2970, 2969, 2968, 2967, 2966, 2965, 2964, 2963, 2962, 2961, 2960]) == 64980\n assert candidate(piles = [8, 1, 3, 9, 2, 4, 10, 5, 6, 11, 7, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 2278\n assert candidate(piles = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991, 11, 990, 12, 989, 13, 988, 14, 987, 15, 986]) == 6990\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 50\n assert candidate(piles = [33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 242\n assert candidate(piles = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(piles = [33, 29, 45, 17, 67, 78, 54, 90, 12, 34, 56, 78, 89, 90, 100, 200, 300, 400]) == 689\n assert candidate(piles = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 50\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 50\n assert candidate(piles = [500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 4, 3, 2, 1]) == 1100\n assert candidate(piles = [42, 23, 36, 17, 55, 87, 31, 69, 90, 14, 78, 52, 25, 63, 91, 19, 82, 46, 11, 73, 58, 39, 97, 15, 89, 44, 18, 76, 59, 41, 99, 12, 81, 45, 20, 75, 60, 42, 94, 13, 80, 43, 21, 74, 61, 47, 98, 16, 79, 48, 22, 72, 62, 50, 92, 24, 77, 51, 26, 71, 64, 53, 93, 27, 70, 54, 28, 67, 65, 56, 96, 29, 68, 57, 30, 66, 69, 58, 95, 32, 31, 34, 33, 38, 37, 40, 39, 44, 43, 46, 45, 48, 47, 50, 49, 52, 51]) == 2165\n assert candidate(piles = [20, 30, 10, 40, 50, 15, 60, 70, 25, 80, 90, 5, 100, 110, 35, 120, 130, 45, 140]) == 580\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 320\n assert candidate(piles = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980]) == 69951\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27]) == 162\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500]) == 5610\n assert candidate(piles = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 651\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 20000\n assert candidate(piles = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980, 9979, 9978, 9977, 9976, 9975, 9974, 9973, 9972, 9971]) == 99900\n assert candidate(piles = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18]) == 91\n assert candidate(piles = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000]) == 32000\n assert candidate(piles = [9, 7, 5, 3, 1, 8, 6, 4, 2]) == 18\n assert candidate(piles = [15, 18, 12, 3, 6, 9, 14, 17, 5, 10, 13, 7, 2, 16, 1, 8, 11, 4, 19, 20]) == 91\n assert candidate(piles = [50, 25, 75, 100, 200, 150, 175, 300, 225, 400, 125, 350, 500, 600, 800, 700, 900, 1000, 2000, 1500, 1100, 1300, 1600, 1400]) == 6775\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350]) == 2760\n assert candidate(piles = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 561\n assert candidate(piles = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981]) == 69951\n assert candidate(piles = [3, 1, 2, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13, 18, 17, 16, 21, 20, 19, 24, 23, 22, 27, 26, 25, 30, 29, 28]) == 200\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 561\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 180\n assert candidate(piles = [10, 12, 34, 33, 5, 7, 6, 11, 13, 15, 17, 19]) == 74\n assert candidate(piles = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == 890\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 910\n assert candidate(piles = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2569\n assert candidate(piles = [1, 3, 2, 4, 5, 6, 8, 7, 9, 11, 10, 12, 14, 13, 15, 17, 16, 18, 20, 19, 21, 22, 23, 24, 25]) == 153\n assert candidate(piles = [3, 1, 2, 5, 7, 8, 9, 4, 6]) == 18\n assert candidate(piles = [42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 392\n assert candidate(piles = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 644\n assert candidate(piles = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000, 21000, 22000, 23000, 24000, 25000, 26000, 27000]) == 162000\n assert candidate(piles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 25\n assert candidate(piles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 105\n assert candidate(piles = [5000, 4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 4985, 4984, 4983, 4982, 4981, 4980, 4979, 4978, 4977, 4976, 4975, 4974, 4973, 4972, 4971]) == 49900\n assert candidate(piles = [23, 45, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 11, 22, 33, 44, 55, 66]) == 357\n assert candidate(piles = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992]) == 29991\n assert candidate(piles = [3, 1, 2, 5, 4, 6, 9, 7, 8, 12, 10, 11, 15, 13, 14, 18, 16, 17, 21, 19, 20, 24, 22, 23, 27, 25, 26, 30, 28, 29]) == 200\n assert candidate(piles = [300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1000, 950, 900]) == 1490\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 200\n assert candidate(piles = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14]) == 33\n assert candidate(piles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(piles = [10, 11, 12, 13, 14, 15, 16, 17, 18]) == 45\n assert candidate(piles = [8, 5, 2, 12, 3, 7, 11, 6, 10, 4, 9, 1, 15, 14, 13, 18, 17, 16, 21, 20, 19, 24, 23, 22, 27, 26, 25, 30, 29, 28]) == 200\n assert candidate(piles = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9]) == 2016\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 20000\n assert candidate(piles = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2278\n assert candidate(piles = [3, 1, 2, 6, 4, 5, 9, 7, 8, 12, 10, 11, 15, 13, 14, 18, 16, 17, 21, 19, 20, 24, 22, 23, 27, 25, 26, 30, 28, 29, 33, 31, 32, 36, 34, 35, 39, 37, 38, 42, 40, 41, 45, 43, 44, 48, 46, 47, 51, 49, 50, 54, 52, 53, 57, 55, 56, 60, 58, 59, 63, 61, 62, 66, 64, 65]) == 968\n assert candidate(piles = [8, 6, 7, 5, 3, 0, 9, 1, 4, 2, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28]) == 190\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(piles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 145\n assert candidate(piles = [3333, 3332, 3331, 3330, 3329, 3328, 3327, 3326, 3325, 3324, 3323, 3322, 3321, 3320, 3319, 3318, 3317, 3316, 3315, 3314, 3313, 3312, 3311, 3310, 3309, 3308, 3307, 3306, 3305]) == 33230\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45]) == 450\n assert candidate(piles = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996, 6, 9995, 7, 9994, 8, 9993, 9, 9992, 10, 9991, 11, 9990, 12, 9989, 13, 9988, 14, 9987, 15, 9986]) == 69990\n assert candidate(piles = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]) == 50000\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 153\n assert candidate(piles = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 31\n assert candidate(piles = [8, 1, 3, 5, 7, 2, 6, 4, 9, 12, 11, 10, 18, 17, 15, 16, 14, 13, 21, 20, 19, 24, 23, 22, 30, 29, 27, 28, 26]) == 192\n assert candidate(piles = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5]) == 2640\n assert candidate(piles = [3000, 2999, 2998, 2997, 2996, 2995, 2994, 2993, 2992, 2991, 2990, 2989, 2988, 2987, 2986, 2985, 2984, 2983, 2982, 2981]) == 20951\n assert candidate(piles = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 200\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 1530\n assert candidate(piles = [1, 2, 3, 100, 99, 98, 97, 96, 95, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94]) == 2278\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 3200\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 1105\n assert candidate(piles = [1, 3, 2, 4, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29]) == 200\n assert candidate(piles = [50, 25, 75, 100, 200, 150, 300, 400, 350, 275, 175, 225]) == 975\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 200\n assert candidate(piles = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16]) == 91\n assert candidate(piles = [5, 3, 8, 1, 9, 4, 2, 7, 6, 15, 10, 11, 14, 12, 13, 20, 16, 17, 19, 18, 25, 21, 22, 24, 23, 30, 26, 27, 29, 28]) == 200\n assert candidate(piles = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 189\n assert candidate(piles = [10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40, 50, 50, 50]) == 180\n assert candidate(piles = [30, 20, 10, 50, 40, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 500\n assert candidate(piles = [10000, 10000, 10000, 9999, 9999, 9999, 9998, 9998, 9998, 9997, 9997, 9997, 9996, 9996, 9996, 9995, 9995, 9995, 9994, 9994, 9994, 9993, 9993, 9993, 9992, 9992, 9992, 9991, 9991, 9991, 9990, 9990, 9990, 9989, 9989, 9989, 9988, 9988, 9988, 9987, 9987, 9987, 9986, 9986, 9986, 9985, 9985, 9985, 9984, 9984, 9984, 9983, 9983, 9983, 9982, 9982, 9982, 9981, 9981, 9981, 9980, 9980, 9980, 9979, 9979, 9979, 9978, 9978, 9978]) == 229831\n"}, "metadata": {"canonical_parameter_names": ["piles"], "leetcode_dataset_entry_point": "Solution().maxCoins", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxCoins(self, piles: list[int]) -> int:", "container": "Solution", "callable": "maxCoins", "parameters": [{"name": "piles", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1562, "task_id": "find-latest-group-of-size-m", "difficulty": "Medium", "problem_description": "Given an array arr that represents a permutation of numbers from 1 to n.\nYou have a binary string of size n that initially has all its bits set to zero. At each step i (assuming both the binary string and arr are 1-indexed) from 1 to n, the bit at position arr[i] is set to 1.\nYou are also given an integer m. Find the latest step at which there exists a group of ones of length m. A group of ones is a contiguous substring of 1's such that it cannot be extended in either direction.\nReturn the latest step at which there exists a group of ones of length exactly m. If no such group exists, return -1.\n \nExample 1:\n\nInput: arr = [3,5,1,2,4], m = 1\nOutput: 4\nExplanation: \nStep 1: \"00100\", groups: [\"1\"]\nStep 2: \"00101\", groups: [\"1\", \"1\"]\nStep 3: \"10101\", groups: [\"1\", \"1\", \"1\"]\nStep 4: \"11101\", groups: [\"111\", \"1\"]\nStep 5: \"11111\", groups: [\"11111\"]\nThe latest step at which there exists a group of size 1 is step 4.\n\nExample 2:\n\nInput: arr = [3,1,5,4,2], m = 2\nOutput: -1\nExplanation: \nStep 1: \"00100\", groups: [\"1\"]\nStep 2: \"10100\", groups: [\"1\", \"1\"]\nStep 3: \"10101\", groups: [\"1\", \"1\", \"1\"]\nStep 4: \"10111\", groups: [\"1\", \"111\"]\nStep 5: \"11111\", groups: [\"11111\"]\nNo group of size 2 exists during any step.\n\n \nConstraints:\n\nn == arr.length\n1 <= m <= n <= 105\n1 <= arr[i] <= n\nAll integers in arr are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 5],m = 3) == 3\n assert candidate(arr = [1, 3, 5, 2, 4],m = 1) == 4\n assert candidate(arr = [2, 1, 3, 5, 4],m = 1) == 4\n assert candidate(arr = [3, 5, 1, 2, 4],m = 1) == 4\n assert candidate(arr = [5, 4, 3, 2, 1],m = 1) == 1\n assert candidate(arr = [5, 4, 3, 2, 1],m = 2) == 2\n assert candidate(arr = [3, 1, 5, 4, 2],m = 2) == -1\n assert candidate(arr = [1, 3, 2, 5, 4],m = 1) == 4\n assert candidate(arr = [1, 3, 5, 2, 4],m = 2) == -1\n assert candidate(arr = [2, 5, 8, 1, 4, 7, 10, 3, 6, 9],m = 3) == -1\n assert candidate(arr = [15, 1, 13, 2, 14, 3, 12, 4, 11, 5, 10, 6, 9, 7, 8],m = 5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6],m = 3) == 3\n assert candidate(arr = [8, 5, 10, 1, 9, 3, 6, 7, 4, 2],m = 2) == 7\n assert candidate(arr = [3, 2, 5, 1, 4, 6, 7, 8],m = 3) == 4\n assert candidate(arr = [3, 6, 2, 8, 1, 9, 4, 7, 5, 10],m = 3) == 6\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 6) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 3) == 3\n assert candidate(arr = [5, 10, 1, 2, 6, 8, 4, 7, 9, 3],m = 5) == 8\n assert candidate(arr = [1, 2, 4, 3, 6, 5, 8, 7, 10, 9],m = 3) == -1\n assert candidate(arr = [1, 10, 5, 6, 7, 8, 9, 2, 3, 4],m = 3) == 9\n assert candidate(arr = [5, 3, 1, 2, 4, 9, 7, 6, 8, 10],m = 1) == 8\n assert candidate(arr = [1, 2, 5, 6, 3, 4, 7, 8, 10, 9],m = 3) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],m = 2) == -1\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5) == 5\n assert candidate(arr = [1, 4, 7, 10, 2, 5, 8, 11, 3, 6, 9, 12],m = 2) == 10\n assert candidate(arr = [5, 1, 9, 2, 6, 3, 7, 4, 8, 10],m = 3) == 7\n assert candidate(arr = [10, 1, 20, 2, 19, 3, 18, 4, 17, 5, 16, 6, 15, 7, 14, 8, 13, 9, 12, 11],m = 7) == 16\n assert candidate(arr = [1, 5, 9, 2, 6, 3, 7, 4, 8, 10],m = 2) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 1) == 1\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 6) == 6\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],m = 2) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 1) == 1\n assert candidate(arr = [2, 4, 1, 6, 5, 3],m = 2) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5) == 5\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 4) == 4\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10) == 10\n assert candidate(arr = [6, 2, 5, 9, 7, 8, 3, 1, 10, 4],m = 5) == 8\n assert candidate(arr = [1, 6, 4, 3, 2, 5],m = 1) == 5\n assert candidate(arr = [5, 1, 6, 3, 8, 2, 7, 10, 4, 9],m = 3) == 8\n assert candidate(arr = [1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8],m = 7) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 2) == 2\n assert candidate(arr = [10, 5, 2, 7, 1, 8, 3, 6, 9, 4],m = 3) == 9\n assert candidate(arr = [10, 8, 6, 4, 2, 1, 3, 5, 7, 9],m = 1) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5) == 5\n assert candidate(arr = [6, 5, 4, 3, 2, 1],m = 3) == 3\n assert candidate(arr = [7, 3, 10, 8, 6, 9, 1, 5, 4, 2],m = 4) == -1\n assert candidate(arr = [1, 2, 5, 4, 3, 6, 7, 8, 9, 10],m = 2) == 4\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 9) == -1\n assert candidate(arr = [3, 6, 1, 9, 7, 8, 2, 5, 10, 4],m = 3) == 9\n assert candidate(arr = [3, 1, 7, 5, 9, 2, 8, 6, 10, 4],m = 4) == -1\n assert candidate(arr = [6, 7, 8, 1, 2, 3, 4, 5, 12, 11, 9, 10],m = 6) == -1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 1) == 1\n assert candidate(arr = [10, 5, 1, 6, 3, 8, 9, 2, 7, 4],m = 2) == 8\n assert candidate(arr = [3, 5, 2, 1, 4, 6, 8, 7, 10, 9],m = 1) == 9\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],m = 4) == 9\n assert candidate(arr = [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20],m = 10) == -1\n assert candidate(arr = [3, 1, 5, 7, 6, 2, 8, 4, 9, 10],m = 2) == -1\n assert candidate(arr = [1, 2, 5, 6, 3, 4, 9, 10, 7, 8],m = 2) == 9\n assert candidate(arr = [1, 10, 3, 8, 5, 12, 7, 2, 9, 4, 6, 11],m = 4) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5) == 5\n assert candidate(arr = [6, 5, 8, 4, 7, 10, 9, 1, 2, 3],m = 3) == 4\n assert candidate(arr = [9, 5, 10, 1, 2, 3, 4, 6, 7, 8],m = 4) == -1\n assert candidate(arr = [3, 1, 4, 2, 5, 6, 7, 8, 9, 10],m = 3) == -1\n assert candidate(arr = [6, 2, 3, 1, 5, 4],m = 2) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],m = 1) == 8\n assert candidate(arr = [6, 3, 1, 5, 4, 2],m = 1) == 5\n assert candidate(arr = [5, 1, 9, 3, 7, 2, 8, 6, 4, 10],m = 2) == -1\n assert candidate(arr = [5, 2, 1, 8, 3, 4, 7, 6, 10, 9],m = 2) == 7\n assert candidate(arr = [10, 2, 8, 4, 6, 3, 9, 5, 7, 1],m = 3) == 8\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 5) == 5\n assert candidate(arr = [5, 1, 6, 3, 4, 2],m = 1) == 5\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 4) == 5\n assert candidate(arr = [5, 1, 9, 10, 3, 7, 4, 6, 8, 2],m = 3) == 7\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3) == 3\n assert candidate(arr = [6, 4, 2, 8, 10, 1, 3, 5, 7, 9],m = 2) == 6\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 1) == 1\n assert candidate(arr = [3, 1, 4, 2, 6, 5, 7, 10, 9, 8],m = 4) == 5\n assert candidate(arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],m = 2) == 6\n assert candidate(arr = [5, 1, 7, 10, 3, 8, 4, 6, 9, 2],m = 4) == -1\n assert candidate(arr = [3, 6, 1, 8, 2, 7, 4, 9, 5, 10],m = 1) == 5\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16],m = 8) == -1\n assert candidate(arr = [1, 2, 4, 5, 3, 7, 6, 8, 10, 9],m = 2) == 4\n assert candidate(arr = [6, 3, 5, 1, 2, 4, 9, 7, 8, 10],m = 4) == -1\n assert candidate(arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],m = 5) == -1\n assert candidate(arr = [1, 5, 3, 9, 7, 2, 6, 10, 4, 8],m = 1) == 7\n assert candidate(arr = [7, 5, 3, 1, 9, 10, 8, 6, 4, 2],m = 5) == -1\n assert candidate(arr = [5, 3, 8, 6, 2, 4, 1, 7, 9, 10],m = 3) == -1\n assert candidate(arr = [3, 2, 5, 4, 8, 7, 10, 9, 6, 1],m = 4) == 8\n assert candidate(arr = [1, 6, 10, 3, 5, 9, 2, 4, 8, 7],m = 4) == -1\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],m = 4) == 9\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 2) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 4) == 4\n assert candidate(arr = [5, 3, 1, 2, 4, 6, 7, 8, 9, 10],m = 3) == 4\n assert candidate(arr = [5, 1, 9, 3, 7, 2, 8, 10, 4, 6],m = 5) == 9\n assert candidate(arr = [3, 6, 9, 2, 5, 8, 1, 4, 7, 10],m = 2) == 8\n assert candidate(arr = [10, 2, 6, 4, 7, 9, 1, 8, 5, 3],m = 5) == 8\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4],m = 3) == 9\n assert candidate(arr = [5, 2, 8, 10, 3, 7, 4, 6, 9, 1],m = 2) == 7\n assert candidate(arr = [10, 8, 6, 4, 2, 1, 3, 5, 7, 9],m = 2) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 4) == 4\n assert candidate(arr = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5],m = 4) == 9\n assert candidate(arr = [1, 2, 5, 4, 7, 3, 8, 6, 9, 10],m = 2) == 7\n assert candidate(arr = [5, 3, 1, 7, 9, 10, 8, 6, 4, 2],m = 3) == -1\n assert candidate(arr = [6, 1, 4, 5, 3, 7, 9, 8, 10, 2],m = 2) == -1\n"}, "metadata": {"canonical_parameter_names": ["arr", "m"], "leetcode_dataset_entry_point": "Solution().findLatestStep", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findLatestStep(self, arr: list[int], m: int) -> int:", "container": "Solution", "callable": "findLatestStep", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "m", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1563, "task_id": "stone-game-v", "difficulty": "Hard", "problem_description": "There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.\nIn each round of the game, Alice divides the row into two non-empty rows (i.e. left row and right row), then Bob calculates the value of each row which is the sum of the values of all the stones in this row. Bob throws away the row which has the maximum value, and Alice's score increases by the value of the remaining row. If the value of the two rows are equal, Bob lets Alice decide which row will be thrown away. The next round starts with the remaining row.\nThe game ends when there is only one stone remaining. Alice's is initially zero.\nReturn the maximum score that Alice can obtain.\n \nExample 1:\n\nInput: stoneValue = [6,2,3,4,5,5]\nOutput: 18\nExplanation: In the first round, Alice divides the row to [6,2,3], [4,5,5]. The left row has the value 11 and the right row has value 14. Bob throws away the right row and Alice's score is now 11.\nIn the second round Alice divides the row to [6], [2,3]. This time Bob throws away the left row and Alice's score becomes 16 (11 + 5).\nThe last round Alice has only one choice to divide the row which is [2], [3]. Bob throws away the right row and Alice's score is now 18 (16 + 2). The game ends because only one stone is remaining in the row.\n\nExample 2:\n\nInput: stoneValue = [7,7,7,7,7,7,7]\nOutput: 28\n\nExample 3:\n\nInput: stoneValue = [4]\nOutput: 0\n\n \nConstraints:\n\n1 <= stoneValue.length <= 500\n1 <= stoneValue[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stoneValue = [1, 2, 3, 4, 5]) == 10\n assert candidate(stoneValue = [5, 3, 1, 4, 2]) == 9\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13]) == 35\n assert candidate(stoneValue = [3, 6, 2, 8, 7, 4, 5]) == 23\n assert candidate(stoneValue = [3, 2, 4, 1, 4, 1, 3, 2]) == 17\n assert candidate(stoneValue = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 40\n assert candidate(stoneValue = [3, 1, 5, 4, 2]) == 8\n assert candidate(stoneValue = [4]) == 0\n assert candidate(stoneValue = [1, 100, 1]) == 1\n assert candidate(stoneValue = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 35\n assert candidate(stoneValue = [6, 2, 3, 4, 5, 5]) == 18\n assert candidate(stoneValue = [7, 7, 7, 7, 7, 7, 7]) == 28\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(stoneValue = [10, 10, 10, 10, 10, 10]) == 40\n assert candidate(stoneValue = [3, 6, 1, 2, 5, 4]) == 13\n assert candidate(stoneValue = [1000000, 1000000]) == 1000000\n assert candidate(stoneValue = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 37\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 84\n assert candidate(stoneValue = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 35\n assert candidate(stoneValue = [1000000, 1000000]) == 1000000\n assert candidate(stoneValue = [10, 10, 10, 10, 10]) == 30\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 277\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 400, 300, 200, 100]) == 1400\n assert candidate(stoneValue = [8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 366\n assert candidate(stoneValue = [15, 20, 5, 10, 25, 30, 5]) == 70\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 92\n assert candidate(stoneValue = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 125\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 1179\n assert candidate(stoneValue = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000]) == 3700000\n assert candidate(stoneValue = [1000000, 1, 1000000, 1, 1000000]) == 1000002\n assert candidate(stoneValue = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 35\n assert candidate(stoneValue = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 194\n assert candidate(stoneValue = [1000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 35\n assert candidate(stoneValue = [5, 1, 4, 9, 7, 2, 8, 6, 3]) == 31\n assert candidate(stoneValue = [5, 3, 8, 2, 7, 9, 1, 4, 6, 10]) == 36\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 184\n assert candidate(stoneValue = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(stoneValue = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 137\n assert candidate(stoneValue = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 35\n assert candidate(stoneValue = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 26\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 92\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 920\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 79\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 80\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 150, 250, 350, 450, 550]) == 2500\n assert candidate(stoneValue = [1, 2, 3, 4, 3, 2, 1]) == 10\n assert candidate(stoneValue = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 184\n assert candidate(stoneValue = [1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000]) == 7000004\n assert candidate(stoneValue = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5]) == 55\n assert candidate(stoneValue = [1000000, 500000, 750000, 250000, 600000, 400000]) == 2000000\n assert candidate(stoneValue = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 74\n assert candidate(stoneValue = [1000000, 999999, 999998, 999997, 999996, 999995]) == 3999985\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 357\n assert candidate(stoneValue = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 21\n assert candidate(stoneValue = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 460\n assert candidate(stoneValue = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 35\n assert candidate(stoneValue = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 800\n assert candidate(stoneValue = [10, 5, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 945\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 189\n assert candidate(stoneValue = [100, 50, 30, 20, 10, 5, 1]) == 100\n assert candidate(stoneValue = [8, 6, 4, 2, 1, 3, 5, 7, 9]) == 32\n assert candidate(stoneValue = [23, 45, 12, 67, 89, 34, 56, 78, 90, 12, 34, 56, 78, 90]) == 606\n assert candidate(stoneValue = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 90\n assert candidate(stoneValue = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000]) == 3700000\n assert candidate(stoneValue = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 1780\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 25\n assert candidate(stoneValue = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 3700\n assert candidate(stoneValue = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 555\n assert candidate(stoneValue = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41]) == 165\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1890\n assert candidate(stoneValue = [20, 30, 10, 40, 50, 15, 25, 35]) == 170\n assert candidate(stoneValue = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 278\n assert candidate(stoneValue = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 35\n assert candidate(stoneValue = [50, 25, 75, 100, 200, 150, 300, 50, 25, 75, 100, 200, 150, 300, 50]) == 1625\n assert candidate(stoneValue = [42, 33, 24, 15, 6, 3, 12, 21, 30, 39, 48, 57, 66]) == 327\n assert candidate(stoneValue = [1, 3, 2, 4, 7, 6, 5, 8, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == 189\n assert candidate(stoneValue = [500000, 400000, 300000, 200000, 100000, 50000, 40000, 30000, 20000, 10000]) == 1140000\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 59\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 3700\n assert candidate(stoneValue = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]) == 92000\n assert candidate(stoneValue = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 89\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 800\n assert candidate(stoneValue = [50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1980\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55]) == 355\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 18900\n assert candidate(stoneValue = [9, 1, 9, 1, 9, 1, 9, 1, 9, 1]) == 32\n assert candidate(stoneValue = [5, 12, 8, 4, 9, 2, 7]) == 33\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 40, 30, 20, 10]) == 140\n assert candidate(stoneValue = [5, 3, 8, 7, 1, 9, 4, 6, 2, 10]) == 36\n assert candidate(stoneValue = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 11000000\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 37\n assert candidate(stoneValue = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2]) == 76\n"}, "metadata": {"canonical_parameter_names": ["stoneValue"], "leetcode_dataset_entry_point": "Solution().stoneGameV", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def stoneGameV(self, stoneValue: list[int]) -> int:", "container": "Solution", "callable": "stoneGameV", "parameters": [{"name": "stoneValue", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1566, "task_id": "detect-pattern-of-length-m-repeated-k-or-more-times", "difficulty": "Easy", "problem_description": "Given an array of positive integers arr, find a pattern of length m that is repeated k or more times.\nA pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times consecutively without overlapping. A pattern is defined by its length and the number of repetitions.\nReturn true if there exists a pattern of length m that is repeated k or more times, otherwise return false.\n \nExample 1:\n\nInput: arr = [1,2,4,4,4,4], m = 1, k = 3\nOutput: true\nExplanation: The pattern (4) of length 1 is repeated 4 consecutive times. Notice that pattern can be repeated k or more times but not less.\n\nExample 2:\n\nInput: arr = [1,2,1,2,1,1,1,3], m = 2, k = 2\nOutput: true\nExplanation: The pattern (1,2) of length 2 is repeated 2 consecutive times. Another valid pattern (2,1) is also repeated 2 times.\n\nExample 3:\n\nInput: arr = [1,2,1,2,1,3], m = 2, k = 3\nOutput: false\nExplanation: The pattern (1,2) is of length 2 but is repeated only 2 times. There is no pattern of length 2 that is repeated 3 or more times.\n\n \nConstraints:\n\n2 <= arr.length <= 100\n1 <= arr[i] <= 100\n1 <= m <= 100\n2 <= k <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 4, 4, 4, 4],m = 1,k = 3) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2],m = 2,k = 2) == True\n assert candidate(arr = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3],m = 2,k = 5) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],m = 1,k = 10) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5],m = 7,k = 1) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1],m = 1,k = 6) == True\n assert candidate(arr = [1, 1, 1, 1],m = 1,k = 4) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3,k = 3) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],m = 2,k = 5) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1],m = 9,k = 1) == False\n assert candidate(arr = [5, 5, 5, 1, 5, 5, 5, 5],m = 3,k = 2) == False\n assert candidate(arr = [1, 2, 2, 1, 2, 2, 1, 2, 2],m = 2,k = 3) == False\n assert candidate(arr = [1, 2, 1, 2, 1, 3],m = 2,k = 3) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3],m = 5,k = 2) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 2) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 1,k = 10) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2],m = 2,k = 3) == True\n assert candidate(arr = [1, 1, 2, 2, 1, 1, 2, 2],m = 2,k = 2) == False\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3],m = 3,k = 2) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5],m = 3,k = 2) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 1, 1, 3],m = 2,k = 2) == True\n assert candidate(arr = [10, 20, 10, 20, 10, 20, 10],m = 2,k = 4) == False\n assert candidate(arr = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1],m = 2,k = 3) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1],m = 1,k = 2) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 1,k = 2) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 9,k = 2) == True\n assert candidate(arr = [1, 1, 1, 1, 1],m = 1,k = 5) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5],m = 4,k = 2) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 3) == True\n assert candidate(arr = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],m = 4,k = 2) == False\n assert candidate(arr = [3, 1, 3, 1, 3, 1, 3, 1],m = 2,k = 4) == True\n assert candidate(arr = [6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9],m = 4,k = 6) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1],m = 3,k = 3) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 6,k = 2) == True\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],m = 3,k = 5) == True\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],m = 3,k = 4) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],m = 2,k = 12) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5],m = 3,k = 3) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 2) == True\n assert candidate(arr = [4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 4, 5],m = 5,k = 3) == True\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],m = 4,k = 4) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 4) == True\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],m = 3,k = 4) == True\n assert candidate(arr = [100, 100, 99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91],m = 2,k = 5) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6],m = 5,k = 2) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 7,k = 2) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10,k = 2) == True\n assert candidate(arr = [5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7],m = 3,k = 10) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3,k = 6) == True\n assert candidate(arr = [4, 4, 4, 5, 5, 5, 4, 4, 4, 5, 5, 5, 4, 4, 4, 5, 5, 5],m = 2,k = 6) == False\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10,k = 2) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 5) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2],m = 3,k = 4) == False\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],m = 4,k = 2) == False\n assert candidate(arr = [6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],m = 2,k = 5) == False\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],m = 2,k = 10) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3,k = 7) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 4],m = 3,k = 3) == True\n assert candidate(arr = [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2],m = 2,k = 4) == False\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3],m = 3,k = 2) == False\n assert candidate(arr = [3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3],m = 5,k = 2) == False\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],m = 2,k = 13) == True\n assert candidate(arr = [2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1],m = 4,k = 2) == False\n assert candidate(arr = [4, 4, 5, 5, 5, 5, 5, 4, 4, 5, 5, 5, 5, 5],m = 5,k = 2) == False\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 5,k = 5) == True\n assert candidate(arr = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],m = 5,k = 3) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 1,k = 18) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3,k = 3) == True\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],m = 5,k = 5) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 6) == True\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],m = 5,k = 5) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],m = 2,k = 10) == True\n assert candidate(arr = [4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5],m = 2,k = 5) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 6,k = 3) == True\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],m = 2,k = 10) == True\n assert candidate(arr = [10, 10, 20, 20, 10, 10, 20, 20, 10, 10],m = 2,k = 3) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 9,k = 4) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 3) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],m = 2,k = 5) == True\n assert candidate(arr = [9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6],m = 5,k = 2) == False\n assert candidate(arr = [9, 8, 7, 6, 9, 8, 7, 6, 9, 8, 7, 6, 9, 8, 7, 6],m = 4,k = 3) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 5) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1],m = 3,k = 2) == False\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],m = 3,k = 7) == True\n assert candidate(arr = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],m = 3,k = 12) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7, 8],m = 4,k = 3) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5, 6],m = 3,k = 2) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3,k = 3) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 1, 1, 1, 2, 2, 2],m = 3,k = 2) == False\n assert candidate(arr = [5, 6, 7, 5, 6, 7, 5, 6, 8, 5, 6, 7, 5, 6, 7, 5, 6, 7],m = 3,k = 3) == True\n assert candidate(arr = [3, 3, 3, 3, 3, 1, 3, 3, 3, 3],m = 4,k = 2) == False\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 4],m = 2,k = 3) == False\n assert candidate(arr = [5, 6, 5, 6, 7, 8, 7, 8, 9, 10, 9, 10, 9, 10],m = 2,k = 2) == True\n assert candidate(arr = [3, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 4],m = 3,k = 2) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 2) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 1,k = 8) == True\n assert candidate(arr = [10, 10, 10, 20, 20, 20, 30, 30, 30, 10, 10, 10, 20, 20, 20, 30, 30, 30],m = 3,k = 2) == False\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 10,k = 3) == True\n assert candidate(arr = [6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9],m = 4,k = 4) == True\n assert candidate(arr = [4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7],m = 4,k = 5) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5, 6, 1, 2, 3],m = 3,k = 3) == True\n assert candidate(arr = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9],m = 3,k = 4) == True\n assert candidate(arr = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9],m = 3,k = 4) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 3,k = 4) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 3) == True\n assert candidate(arr = [9, 10, 11, 9, 10, 11, 9, 10, 11, 9, 10, 11, 9, 10, 11],m = 3,k = 5) == True\n assert candidate(arr = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20],m = 2,k = 5) == True\n assert candidate(arr = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],m = 2,k = 5) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 5) == True\n assert candidate(arr = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],m = 10,k = 3) == True\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20],m = 3,k = 3) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 5,k = 2) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2],m = 4,k = 2) == False\n assert candidate(arr = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1],m = 2,k = 4) == False\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 10,k = 1) == False\n assert candidate(arr = [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2],m = 2,k = 5) == False\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 5,k = 3) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 5) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 3) == False\n assert candidate(arr = [2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4],m = 2,k = 10) == True\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2],m = 4,k = 2) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2],m = 6,k = 2) == True\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],m = 5,k = 4) == True\n assert candidate(arr = [5, 5, 1, 1, 5, 5, 1, 1, 5, 5, 1, 1, 5, 5, 1, 1, 5, 5],m = 2,k = 4) == False\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],m = 10,k = 3) == True\n assert candidate(arr = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],m = 10,k = 3) == True\n assert candidate(arr = [8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 8, 8, 9, 9, 10, 10, 11, 11],m = 2,k = 4) == False\n assert candidate(arr = [1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2],m = 6,k = 2) == False\n"}, "metadata": {"canonical_parameter_names": ["arr", "m", "k"], "leetcode_dataset_entry_point": "Solution().containsPattern", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def containsPattern(self, arr: list[int], m: int, k: int) -> bool:", "container": "Solution", "callable": "containsPattern", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "m", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1567, "task_id": "maximum-length-of-subarray-with-positive-product", "difficulty": "Medium", "problem_description": "Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive.\nA subarray of an array is a consecutive sequence of zero or more values taken out of that array.\nReturn the maximum length of a subarray with positive product.\n \nExample 1:\n\nInput: nums = [1,-2,-3,4]\nOutput: 4\nExplanation: The array nums already has a positive product of 24.\n\nExample 2:\n\nInput: nums = [0,1,-2,-3,-4]\nOutput: 3\nExplanation: The longest subarray with positive product is [1,-2,-3] which has a product of 6.\nNotice that we cannot include 0 in the subarray since that'll make the product 0 which is not positive.\nExample 3:\n\nInput: nums = [-1,-2,-3,0,1]\nOutput: 2\nExplanation: The longest subarray with positive product is [-1,-2] or [-2,-3].\n\n \nConstraints:\n\n1 <= nums.length <= 105\n-109 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 2, -3, 4, -5]) == 4\n assert candidate(nums = [-1, -2, -3, 0, 1]) == 2\n assert candidate(nums = [-1]) == 0\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 2, 3, 0, -1, -2, -3]) == 3\n assert candidate(nums = [1, 0, -2, 3, -4, 0, 5, 6]) == 3\n assert candidate(nums = [-1, 0, 1, 0, -1]) == 1\n assert candidate(nums = [1, 2, 3, 0, -1, -2, -3, 4, 5, 0, 6, 7, 8]) == 4\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1]) == 5\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [-1, -1, -1, -1]) == 4\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, -4, 5, 0, -6, 7, 8, 9]) == 3\n assert candidate(nums = [-10, -20, -30, -40, -50]) == 4\n assert candidate(nums = [1, 0, -2, 3, 4, -5, 0, 6, 7, 8, 9, 0, -1]) == 4\n assert candidate(nums = [0, 1, -2, -3, -4]) == 3\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == 4\n assert candidate(nums = [1, 2, 0, 3, 4, -5, 6, 0, 7, 8]) == 2\n assert candidate(nums = [1, -2, -3, 4]) == 4\n assert candidate(nums = [1, 0, -2, 0, 3, 0, -4]) == 1\n assert candidate(nums = [1, 2, -1, -2, -1, 1, 2, -1, -2, -1]) == 10\n assert candidate(nums = [1, 2, 3, 0, -1, -2, -3, 0, 4, 5, 6, 0, -7, -8, -9, 0, 10, 11, 12]) == 3\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6]) == 1\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15]) == 15\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0, 1, 2, -3, 4, 5, 0, 0, -1, -2, -3, 0, 4, 5, 6]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 5\n assert candidate(nums = [0, 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 0, 21, -22, 23, -24, 25, -26, 27, -28, 29, -30, 0]) == 20\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, 0]) == 9\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(nums = [1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1]) == 1\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 20\n assert candidate(nums = [-1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1]) == 12\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25, -26, 27, -28, 29, -30]) == 29\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, -10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 0]) == 10\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 0, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5, 0, 1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5]) == 5\n assert candidate(nums = [1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0]) == 1\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 20\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60]) == 12\n assert candidate(nums = [1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 0, 1, 2, 3, 4, 5, -6, -7, -8, -9, -10]) == 14\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 13\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 40\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, -4, 5, 6, -7, 8, 9, 10]) == 10\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]) == 20\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 5\n assert candidate(nums = [1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1]) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 20\n assert candidate(nums = [1, -1, -1, 1, -1, -1, 1, -1, -1, 1]) == 10\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5, 0]) == 5\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 28\n assert candidate(nums = [0, 1, 2, 3, 0, -1, -2, -3, 0, 1, 2, 3]) == 3\n assert candidate(nums = [1, 2, 3, 0, 0, 0, 0, 0, 0, 4, 5, 6, 0, 7, 8, 9, 0, 10, 11, 12]) == 3\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11]) == 11\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 14\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 13\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 9\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 9\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30]) == 30\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1]) == 9\n assert candidate(nums = [0, 0, 0, 1, 2, 3, 0, -1, -2, -3, 0]) == 3\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 1]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 20\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [0, 0, 0, 0, 1, -1, 1, -1, 0, 0, 0, 1, 1, 1, -1, -1, -1, 0, 0, 0]) == 5\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5]) == 5\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5]) == 1\n assert candidate(nums = [1, 2, 3, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 11, 12, 13, 14, 15]) == 18\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1]) == 1\n assert candidate(nums = [1, -2, 0, 3, -4, 0, 5, -6, 0, 7, -8, 0, 9, -10, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0, 1, -2, 3, -4, 5]) == 5\n assert candidate(nums = [1, 2, 0, 3, 4, 0, 5, 6, 0, 7, 8, 9]) == 3\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 0, 10, 11, 12, 0, 13, 14, 15, 0]) == 5\n assert candidate(nums = [1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 9\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5, 0, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 25\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30]) == 29\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]) == 16\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [-2, -3, -5, 0, 5, 7, -2, -3, 1, 0, 12, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 12\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 9\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 9\n assert candidate(nums = [0, -1, 2, -3, 4, -5, 6, -7, 8, 0, -9, 10, -11]) == 8\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120]) == 12\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, -6, -7, -8, -9, -10, -11, -12]) == 11\n assert candidate(nums = [5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 10\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 10\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0]) == 20\n assert candidate(nums = [5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15, 16, 17, 18, 19, 20]) == 10\n assert candidate(nums = [1, 2, 3, 4, -5, 6, 7, 8, 9, -10]) == 10\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 16\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 40\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 0, 100, -200, 300]) == 9\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 20\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().getMaxLen", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getMaxLen(self, nums: list[int]) -> int:", "container": "Solution", "callable": "getMaxLen", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1568, "task_id": "minimum-number-of-days-to-disconnect-island", "difficulty": "Hard", "problem_description": "You are given an m x n binary grid grid where 1 represents land and 0 represents water. An island is a maximal 4-directionally (horizontal or vertical) connected group of 1's.\nThe grid is said to be connected if we have exactly one island, otherwise is said disconnected.\nIn one day, we are allowed to change any single land cell (1) into a water cell (0).\nReturn the minimum number of days to disconnect the grid.\n \nExample 1:\n\n\nInput: grid = [[0,1,1,0],[0,1,1,0],[0,0,0,0]]\n\nOutput: 2\nExplanation: We need at least 2 days to get a disconnected grid.\nChange land grid[1][1] and grid[0][2] to water and get 2 disconnected island.\n\nExample 2:\n\n\nInput: grid = [[1,1]]\nOutput: 2\nExplanation: Grid of full water is also disconnected ([[1,1]] -> [[0,0]]), 0 islands.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 30\ngrid[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1]]) == 2\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 1, 0], [0, 0, 0], [0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 1, 1, 0], [1, 0, 1, 1, 0, 1, 0], [0, 0, 0, 0, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [1, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [1, 1, 0, 1, 1], [1, 1, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1], [0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 1, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0], [1, 0, 1, 0, 0], [1, 1, 1, 1, 0], [0, 0, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 1, 1, 1, 0], [0, 0, 1, 0, 0, 0, 1], [0, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 0], [1, 0, 0, 1, 1, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 0], [0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 1, 1, 1], [0, 1, 0, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0], [1, 1, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 0, 1], [1, 0, 1, 1], [1, 0, 0, 1]]) == 1\n assert candidate(grid = [[1, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [1, 0, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [1, 0, 0, 0, 0, 1], [1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 1, 0, 1, 1], [0, 0, 0, 1, 1], [0, 1, 0, 0, 0], [0, 1, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 1, 0, 1, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [1, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == 2\n assert candidate(grid = [[1, 0, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1, 1], [0, 1, 0, 1, 0, 0, 1], [0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 1, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 1, 1], [1, 0, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]]) == 1\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 1, 0, 1, 1], [0, 0, 0, 0, 1]]) == 1\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [0, 1, 1, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 1, 0, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0], [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 0, 0, 0, 1], [1, 1, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 1, 1], [1, 1, 0, 0, 1], [0, 1, 1, 0, 0], [0, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 0], [1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 1, 0, 1], [0, 0, 1, 1, 0, 1, 0], [0, 0, 0, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1], [1, 0, 0, 1, 1, 0, 1], [0, 0, 1, 1, 1, 1, 0], [1, 0, 0, 1, 1, 0, 1], [1, 1, 0, 0, 0, 0, 1], [1, 1, 1, 0, 0, 1, 1]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minDays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minDays(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "minDays", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1569, "task_id": "number-of-ways-to-reorder-array-to-get-same-bst", "difficulty": "Hard", "problem_description": "Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nums in order into an initially empty BST. Find the number of different ways to reorder nums so that the constructed BST is identical to that formed from the original array nums.\n\nFor example, given nums = [2,1,3], we will have 2 as the root, 1 as a left child, and 3 as a right child. The array [2,3,1] also yields the same BST but [3,2,1] yields a different BST.\n\nReturn the number of ways to reorder nums such that the BST formed is identical to the original BST formed from nums.\nSince the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: nums = [2,1,3]\nOutput: 1\nExplanation: We can reorder nums to be [2,3,1] which will yield the same BST. There are no other ways to reorder nums which will yield the same BST.\n\nExample 2:\n\n\nInput: nums = [3,4,5,1,2]\nOutput: 5\nExplanation: The following 5 arrays will yield the same BST: \n[3,1,2,4,5]\n[3,1,4,2,5]\n[3,1,4,5,2]\n[3,4,1,2,5]\n[3,4,1,5,2]\n\nExample 3:\n\n\nInput: nums = [1,2,3]\nOutput: 0\nExplanation: There are no other orderings of nums that will yield the same BST.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= nums.length\nAll integers in nums are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 5, 15, 3, 7, 13, 18, 1, 4, 6, 8, 12, 14, 17, 19]) == 21964799\n assert candidate(nums = [1, 3, 2]) == 0\n assert candidate(nums = [10, 5, 15, 3, 7, 12, 18, 1, 4, 6, 8, 11, 13, 17, 19]) == 21964799\n assert candidate(nums = [8, 5, 12, 3, 7, 10, 15, 1, 4, 6, 9, 11, 13, 14, 16, 17, 18, 19, 20]) == 572970385\n assert candidate(nums = [9, 4, 10, 2, 5, 8, 11, 1, 3, 6, 7]) == 3149\n assert candidate(nums = [6, 2, 9, 1, 3, 8, 10, 4, 5, 7]) == 1511\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [2, 1, 3]) == 1\n assert candidate(nums = [8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15, 16]) == 108107999\n assert candidate(nums = [8, 5, 10, 3, 6, 9, 11, 1, 4, 7]) == 3359\n assert candidate(nums = [5, 3, 6, 2, 4, 1]) == 14\n assert candidate(nums = [3, 4, 5, 1, 2]) == 5\n assert candidate(nums = [4, 2, 5, 1, 3]) == 7\n assert candidate(nums = [5, 2, 6, 1, 3, 4]) == 14\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 22, 27, 32, 37, 2, 4, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 33, 36, 38, 1, 9, 14, 19, 24, 29, 34, 39]) == 447293125\n assert candidate(nums = [100, 50, 150, 25, 75, 125, 175, 12, 37, 62, 87, 112, 137, 162, 187, 6, 18, 28, 43, 53, 61, 68, 72, 82, 91, 3, 9, 14, 21, 26, 31, 36, 41, 46, 51, 56, 65, 70, 77, 84, 89, 94, 99]) == 7608543\n assert candidate(nums = [50, 25, 75, 12, 37, 62, 87, 6, 18, 29, 43, 56, 68, 81, 93, 3, 8, 14, 16, 23, 27, 33, 35, 41, 44, 48, 51, 55, 58, 60, 65, 67, 70, 73, 76, 78, 80, 83, 85, 88, 90, 91, 92, 95, 96, 97, 98, 99, 100]) == 346227338\n assert candidate(nums = [25, 15, 30, 10, 20, 28, 35, 5, 12, 18, 26, 32, 38, 2, 7, 11, 14, 17, 19, 22, 25, 29, 31, 34, 37, 39, 40, 41]) == 677042095\n assert candidate(nums = [64, 32, 96, 16, 48, 80, 112, 8, 24, 40, 56, 72, 88, 104, 120, 4, 12, 20, 28, 36, 44, 52, 60, 68, 76, 84, 92, 100, 108, 116, 124, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 102, 106, 110, 114, 118, 122, 126, 130, 134, 138, 142, 146, 150]) == 320734915\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(nums = [300, 150, 450, 75, 225, 375, 525, 38, 113, 188, 250, 325, 400, 475, 550, 19, 58, 87, 138, 175, 208, 238, 288, 306, 344, 363, 413, 442, 463, 488, 508, 538, 563, 588, 608, 2, 9, 20, 36, 51, 67, 79, 94, 107, 120, 133, 148, 163, 178, 193, 209, 224, 240, 256, 271, 287, 302, 318, 333, 349, 364, 380, 396, 412, 428, 443, 459, 474, 490, 505, 521, 536, 552, 568, 583, 599, 614, 629, 644, 659, 674, 689, 704, 719, 734, 749, 764, 779, 794, 809, 824, 839, 854, 869, 884, 899, 914, 929, 944, 959, 974, 989, 1004]) == 118530866\n assert candidate(nums = [50, 25, 75, 12, 37, 63, 87, 6, 18, 28, 43, 55, 61, 70, 80, 90, 1, 9, 15, 20, 29, 34, 38, 42, 48, 53, 58, 62, 68, 72, 78, 82, 85, 88, 95]) == 446421114\n assert candidate(nums = [50, 25, 75, 12, 37, 62, 87, 6, 18, 28, 43, 53, 61, 68, 72, 82, 91, 3, 9, 14, 21, 27, 31, 41, 46, 50, 57, 65, 70, 78, 85, 88, 94, 1, 5, 8, 11, 15, 19, 23, 26, 30, 35, 40, 45, 49, 52, 55, 58, 63, 66, 71, 74, 77, 80, 83, 86, 90, 93, 97, 99]) == 571657448\n assert candidate(nums = [5, 3, 8, 1, 4, 7, 9, 2, 6, 10, 11, 12, 13, 14, 15]) == 108107\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 18, 23, 27, 33, 37, 2, 4, 6, 8, 11, 13, 16, 19, 22, 24, 26, 28, 31, 32, 34, 36, 38, 39, 40]) == 479196662\n assert candidate(nums = [50, 25, 75, 12, 37, 63, 88, 6, 18, 30, 45, 55, 60, 70, 85, 90, 3, 9, 15, 21, 27, 33, 40, 48, 52, 58, 62, 68, 73, 77, 83, 87, 92, 95, 98]) == 668093717\n assert candidate(nums = [50, 25, 75, 12, 37, 63, 87, 6, 18, 30, 45, 55, 61, 65, 72, 81, 93, 3, 9, 15, 20, 27, 32, 40, 47, 52, 57, 60, 62, 64, 67, 70, 74, 78, 84, 86, 89, 90, 91, 92, 95, 96, 97, 98, 99]) == 194452240\n assert candidate(nums = [6, 4, 8, 2, 5, 7, 9, 1, 3, 10, 11]) == 8063\n assert candidate(nums = [10, 5, 15, 3, 7, 12, 18, 1, 4, 6, 8, 11, 13, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 372948988\n assert candidate(nums = [6, 3, 9, 1, 4, 7, 10, 2, 5, 8]) == 2267\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 1, 7, 12, 18, 22, 28, 33, 40, 2, 4, 6, 8, 9, 11, 13, 16, 17, 19, 21, 23, 24, 26, 27, 29, 31, 32, 34, 36, 37, 38, 39]) == 823462672\n assert candidate(nums = [15, 10, 20, 5, 12, 17, 25, 3, 7, 11, 14, 16, 18, 23, 28]) == 21964799\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 0\n assert candidate(nums = [256, 128, 384, 64, 192, 288, 448, 32, 96, 160, 224, 320, 352, 416, 480, 16, 48, 80, 112, 144, 176, 208, 240, 272, 304, 336, 368, 400, 432, 464, 496, 8, 24, 40, 56, 72, 88, 104, 120, 136, 152, 168, 184, 200, 216, 232, 248, 264, 280, 296, 312, 328, 344, 360, 376, 392, 408, 424, 440, 456, 472, 488, 512]) == 968800645\n assert candidate(nums = [5, 2, 7, 1, 3, 6, 8, 4]) == 209\n assert candidate(nums = [7, 2, 11, 1, 4, 8, 12, 3, 5, 6, 9, 10]) == 27719\n assert candidate(nums = [100, 50, 150, 25, 75, 125, 175, 12, 37, 63, 87, 112, 137, 163, 187, 6, 18, 28, 43, 55, 61, 70, 80, 90, 102, 117, 132, 142, 153, 168, 178, 182, 188, 195]) == 84315017\n assert candidate(nums = [15, 7, 20, 3, 11, 17, 25, 1, 5, 9, 13, 16, 19, 23, 27, 2, 4, 6, 8, 10, 12, 14, 18, 21, 22, 24, 26, 28, 29]) == 993050933\n assert candidate(nums = [50, 25, 75, 12, 37, 62, 88, 6, 18, 28, 43, 55, 60, 70, 80, 90, 3, 9, 15, 20, 24, 26, 32, 36, 39, 42, 45, 48, 53, 58, 61, 65, 68, 72, 74, 77, 82, 85, 87, 89, 92, 94, 96, 98, 100]) == 587907399\n assert candidate(nums = [25, 10, 30, 5, 15, 20, 35, 2, 7, 13, 18, 22, 28, 33, 38, 1, 4, 6, 8, 11, 14, 17, 19, 21, 23, 27, 31, 32, 34, 36, 37, 39, 40]) == 138112265\n assert candidate(nums = [60, 30, 90, 15, 45, 75, 105, 10, 20, 40, 50, 70, 80, 95, 100, 110, 5, 8, 12, 17, 25, 35, 42, 48, 55, 65, 72, 78, 85, 93, 98, 102, 108, 115, 120, 125, 130, 135, 140, 145, 150]) == 303275395\n assert candidate(nums = [30, 15, 45, 7, 22, 37, 52, 3, 11, 18, 26, 32, 40, 48, 55, 1, 2, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 19, 20, 21, 23, 24, 25, 27, 28, 29, 31, 33, 34, 35, 36, 38, 39, 41, 42, 43, 44, 46, 47, 49, 50, 51, 53, 54, 56, 57, 58, 59, 60]) == 443856139\n assert candidate(nums = [600, 300, 900, 150, 450, 750, 1050, 75, 225, 375, 525, 675, 825, 975, 1125, 1275, 38, 113, 188, 263, 338, 413, 488, 563, 638, 713, 788, 863, 938, 1013, 1088, 1163, 1238, 1313, 1388, 1463, 1538, 1613, 1688, 1763, 1838, 1913, 1988, 24, 69, 114, 159, 204, 249, 294, 339, 384, 429, 474, 519, 564, 609, 654, 699, 744, 789, 834, 879, 924, 969, 1014, 1059, 1104, 1149, 1194, 1239, 1284, 1329, 1374, 1419, 1464, 1509, 1554, 1599, 1644, 1689, 1734, 1779, 1824, 1869, 1914, 1959, 1994, 12, 36, 60, 84, 108, 132, 156, 180, 204, 228, 252, 276, 300, 324, 348, 372, 396, 420, 444, 468, 492, 516, 540, 564, 588, 612, 636, 660, 684, 708, 732, 756, 780, 804, 828, 852, 876, 900, 924, 948, 972, 996, 1020, 1044, 1068, 1092, 1116, 1140, 1164, 1188, 1212, 1236, 1260, 1284, 1308, 1332, 1356, 1380, 1404, 1428, 1452, 1476, 1500, 1524, 1548, 1572, 1596, 1620, 1644, 1668, 1692, 1716, 1740, 1764, 1788, 1812, 1836, 1860, 1884, 1908, 1932, 1956, 1980]) == 244403225\n assert candidate(nums = [7, 3, 11, 1, 5, 9, 13, 2, 4, 6, 8, 10, 12, 14, 15]) == 12612599\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 2, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38]) == 203434153\n assert candidate(nums = [15, 7, 24, 3, 11, 19, 28, 1, 5, 9, 13, 16, 22, 26, 31, 2, 4, 6, 8, 10, 12, 14, 17, 18, 20, 21, 23, 25, 27, 29, 30, 32, 33, 34, 35, 36, 37]) == 765197211\n assert candidate(nums = [15, 8, 21, 3, 12, 18, 25, 1, 5, 10, 13, 16, 20, 22, 24, 26, 27, 28, 29, 30]) == 935107010\n assert candidate(nums = [100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180]) == 21964799\n assert candidate(nums = [15, 8, 23, 4, 12, 19, 27, 2, 6, 10, 14, 17, 21, 25, 29, 1, 3, 5, 7, 9, 11, 13, 16, 18, 20, 22, 24, 26, 28, 30]) == 637714638\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 2, 7, 12, 18, 23, 27, 32, 37, 1, 4, 6, 8, 11, 13, 14, 16, 17, 19, 21, 22, 24, 26, 28, 29, 31, 33, 34, 36, 38, 39, 40]) == 327188662\n assert candidate(nums = [5, 3, 7, 2, 4, 6, 8, 1, 9, 10]) == 1511\n assert candidate(nums = [100, 50, 150, 25, 75, 125, 175, 12, 37, 62, 88, 112, 138, 162, 188, 6, 18, 31, 43, 56, 71, 83, 94, 106, 118, 129, 139, 150, 161, 172, 183, 194, 3, 9, 14, 20, 26, 33, 40, 47, 53, 60, 67, 74, 81, 87, 93, 99, 105, 111, 117, 123, 130, 136, 142, 148, 154, 160, 166, 173, 179, 185, 191, 197, 2, 5, 7, 11, 13, 16, 19, 22, 24, 27, 29, 32, 35, 38, 41, 44, 46, 49, 52, 55, 58, 61, 64, 66, 69, 72, 75, 78, 80, 84, 86, 89, 91, 95, 97, 101, 103, 107, 109, 113, 115, 119, 121, 124, 127, 131, 133, 137, 140, 144, 146, 149, 151, 155, 157, 163, 165, 168, 170, 174, 176, 178, 181, 184, 186, 189, 192, 196, 198, 199]) == 963420092\n assert candidate(nums = [10, 5, 15, 3, 7, 13, 18, 2, 4, 6, 8, 12, 14, 16, 17, 19, 20]) == 615014399\n assert candidate(nums = [70, 35, 105, 17, 53, 59, 88, 126, 9, 26, 44, 50, 56, 81, 93, 112, 120, 130, 140, 150, 5, 13, 20, 29, 39, 42, 48, 51, 58, 76, 80, 85, 89, 91, 97, 100, 102, 107, 109, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151]) == 583396661\n assert candidate(nums = [500, 250, 750, 125, 375, 625, 875, 63, 188, 292, 463, 532, 594, 656, 725, 788, 844, 913, 969, 1025, 1082, 1138, 1194, 1250, 1306, 1362, 1418, 1475, 1531, 1587, 1643, 1699, 1755, 1812, 1868, 1924, 1980, 31, 94, 148, 224, 299, 355, 400, 446, 482, 520, 556, 591, 626, 662, 697, 733, 769, 804, 840, 876, 911, 947, 982, 1018, 1054, 1089, 1125, 1161, 1196, 1232, 1268, 1303, 1339, 1375, 1410, 1446, 1482, 1517, 1553, 1589, 1624, 1660, 1695, 1731, 1767, 1802, 1838, 1874, 1909, 1945, 1981, 7, 26, 45, 64, 83, 102, 121, 140, 159, 178, 197, 216, 235, 254, 273, 292, 311, 330, 349, 368, 387, 406, 425, 444, 463, 482, 501, 520, 539, 558, 577, 596, 615, 634, 653, 672, 691, 710, 729, 748, 767, 786, 805, 824, 843, 862, 881, 900, 919, 938, 957, 976, 995]) == 126685497\n assert candidate(nums = [7, 4, 12, 2, 5, 9, 15, 1, 3, 6, 8, 11, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 240043756\n assert candidate(nums = [15, 9, 20, 7, 11, 18, 22, 5, 8, 10, 12, 16, 19, 21, 23, 3, 6, 13, 14, 17, 24]) == 290541228\n assert candidate(nums = [100, 50, 150, 25, 75, 125, 175, 12, 37, 62, 87, 112, 137, 162, 187, 6, 18, 27, 46, 57, 72, 81, 96, 107, 117, 127, 132, 147, 157, 167, 172, 182, 197, 1, 11, 15, 21, 33, 41, 51, 59, 61, 71, 77, 83, 89, 91, 97, 101, 109, 111, 118, 121, 129, 131, 138, 141, 149, 151, 159, 161, 168, 171, 179, 181, 188, 191, 199]) == 248577023\n assert candidate(nums = [15, 10, 20, 8, 12, 17, 22, 5, 9, 11, 13, 16, 19, 21, 23, 3, 7, 4, 6, 14, 18, 24, 25]) == 252477357\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 2, 7, 13, 18, 23, 27, 32, 33, 1, 3, 6, 8, 12, 14, 16, 17, 19, 21, 22, 24, 26, 28, 29, 31, 34, 36]) == 852994108\n assert candidate(nums = [12, 7, 15, 4, 8, 13, 16, 2, 5, 9, 14, 3, 6, 10, 11]) == 2270267\n assert candidate(nums = [1, 4, 2, 7, 3, 5, 8, 6, 9, 10, 11, 12, 13, 14, 15]) == 3509\n assert candidate(nums = [7, 3, 11, 1, 5, 9, 13, 2, 4, 6, 8, 10, 12, 14, 15]) == 12612599\n assert candidate(nums = [800, 400, 1200, 200, 600, 1000, 1400, 100, 300, 500, 700, 900, 1100, 1300, 1500, 50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550, 25, 75, 125, 175, 225, 275, 325, 375, 425, 475, 525, 575, 625, 675, 725, 775, 825, 875, 925, 975, 1025, 1075, 1125, 1175, 1225, 1275, 1325, 1375, 1425, 1475, 1525, 1575]) == 665258151\n assert candidate(nums = [80, 40, 120, 20, 60, 100, 140, 10, 30, 50, 70, 90, 110, 130, 150, 5, 9, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 348178224\n assert candidate(nums = [13, 7, 18, 3, 10, 15, 20, 1, 5, 8, 11, 14, 16, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 321724227\n assert candidate(nums = [25, 12, 30, 8, 18, 27, 32, 5, 10, 15, 22, 26, 31, 33, 3, 7, 9, 11, 13, 14, 16, 17, 19, 20, 21, 23, 24, 28, 29]) == 106594954\n assert candidate(nums = [1000, 500, 1500, 250, 750, 1250, 1750, 125, 375, 625, 875, 1125, 1375, 1625, 1875, 63, 188, 288, 313, 438, 563, 713, 813, 938, 1063, 1213, 1313, 1438, 1563, 1713, 1813, 1938, 2063, 2213, 2313, 2438, 2563, 2713, 2813, 2938, 3063, 3213, 3313, 3438, 3563, 3713, 3813, 3938, 4063, 4213, 4313, 4438, 4563, 4713, 4813, 4938, 5063, 5213, 5313, 5438, 5563, 5713, 5813, 5938, 6063, 6213, 6313, 6438, 6563, 6713, 6813, 6938, 7063, 7213, 7313, 7438, 7563, 7713, 7813, 7938, 8063, 8213, 8313, 8438, 8563, 8713, 8813, 8938, 9063, 9213, 9313, 9438, 9563, 9713, 9813, 9938, 10063, 10213, 10313, 10438, 10563, 10713, 10813, 10938, 11063, 11213, 11313, 11438, 11563, 11713, 11813, 11938, 12063, 12213, 12313, 12438, 12563, 12713, 12813, 12938, 13063, 13213, 13313, 13438, 13563, 13713, 13813, 13938, 14063, 14213, 14313, 14438, 14563, 14713, 14813, 14938, 15063, 15213, 15313, 15438, 15563, 15713, 15813, 15938, 16063, 16213, 16313, 16438, 16563, 16713, 16813, 16938, 17063, 17213, 17313, 17438, 17563, 17713, 17813, 17938, 18063, 18213, 18313, 18438, 18563, 18713, 18813, 18938, 19063, 19213, 19313, 19438, 19563, 19713, 19813, 19938]) == 998164136\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 2, 7, 12, 18, 23, 28, 33, 40]) == 21964799\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [25, 15, 35, 10, 20, 30, 40, 5, 12, 18, 23, 28, 33, 38, 43]) == 21964799\n assert candidate(nums = [25, 15, 35, 10, 20, 30, 40, 5, 12, 18, 22, 28, 32, 38, 45, 3, 7, 11, 14, 16, 19, 21, 24, 26, 29, 31, 33, 36, 37, 39, 41, 42, 43, 44, 46, 47, 48, 49, 50]) == 625852341\n assert candidate(nums = [50, 25, 75, 12, 37, 63, 87, 6, 18, 30, 42, 56, 70, 81, 93]) == 21964799\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numOfWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numOfWays(self, nums: list[int]) -> int:", "container": "Solution", "callable": "numOfWays", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1572, "task_id": "matrix-diagonal-sum", "difficulty": "Easy", "problem_description": "Given a square matrix mat, return the sum of the matrix diagonals.\nOnly include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal.\n \nExample 1:\n\n\nInput: mat = [[1,2,3],\n  [4,5,6],\n  [7,8,9]]\nOutput: 25\nExplanation: Diagonals sum: 1 + 5 + 9 + 3 + 7 = 25\nNotice that element mat[1][1] = 5 is counted only once.\n\nExample 2:\n\nInput: mat = [[1,1,1,1],\n  [1,1,1,1],\n  [1,1,1,1],\n  [1,1,1,1]]\nOutput: 8\n\nExample 3:\n\nInput: mat = [[5]]\nOutput: 5\n\n \nConstraints:\n\nn == mat.length == mat[i].length\n1 <= n <= 100\n1 <= mat[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[7, 3, 1, 9], [3, 4, 6, 9], [6, 9, 6, 6], [9, 5, 8, 5]]) == 55\n assert candidate(mat = [[5]]) == 5\n assert candidate(mat = [[10, 1, 1], [1, 0, 1], [1, 1, 10]]) == 22\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 25\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 8\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]]) == 520\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 117\n assert candidate(mat = [[5, 3, 1, 4, 2], [8, 6, 9, 7, 5], [3, 2, 8, 6, 4], [1, 4, 5, 2, 3], [7, 5, 4, 8, 6]]) == 47\n assert candidate(mat = [[100, 100, 100], [100, 99, 100], [100, 100, 100]]) == 499\n assert candidate(mat = [[50, 2, 3, 4, 5, 6, 7], [8, 50, 10, 11, 12, 13, 14], [15, 16, 50, 18, 19, 20, 21], [22, 23, 24, 50, 26, 27, 28], [29, 30, 31, 32, 50, 34, 35], [36, 37, 38, 39, 40, 50, 42], [43, 44, 45, 46, 47, 48, 50]]) == 500\n assert candidate(mat = [[5, 2, 3, 4, 5, 6, 7], [8, 5, 2, 3, 4, 5, 6], [7, 8, 5, 2, 3, 4, 5], [6, 7, 8, 5, 2, 3, 4], [5, 6, 7, 8, 5, 2, 3], [4, 5, 6, 7, 8, 5, 2], [3, 4, 5, 6, 7, 8, 5]]) == 65\n assert candidate(mat = [[10, 20, 30, 40, 50, 60], [1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]) == 225\n assert candidate(mat = [[2, 3, 4, 5, 6], [1, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 119\n assert candidate(mat = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [9, 8, 7, 6, 5]]) == 43\n assert candidate(mat = [[100, 200, 300, 400, 500, 600], [700, 800, 900, 1000, 1100, 1200], [1300, 1400, 1500, 1600, 1700, 1800], [1900, 2000, 2100, 2200, 2300, 2400], [2500, 2600, 2700, 2800, 2900, 3000], [3100, 3200, 3300, 3400, 3500, 3600]]) == 22200\n assert candidate(mat = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]]) == 680\n assert candidate(mat = [[1, 2], [3, 4]]) == 10\n assert candidate(mat = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [110, 120, 130, 140, 150], [160, 170, 180, 190, 200], [210, 220, 230, 240, 250]]) == 1170\n assert candidate(mat = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]) == 1010\n assert candidate(mat = [[100, 99, 98, 97, 96, 95, 94, 93, 92], [91, 90, 89, 88, 87, 86, 85, 84, 83], [82, 81, 80, 79, 78, 77, 76, 75, 74], [73, 72, 71, 70, 69, 68, 67, 66, 65], [64, 63, 62, 61, 60, 59, 58, 57, 56], [55, 54, 53, 52, 51, 50, 49, 48, 47], [46, 45, 44, 43, 42, 41, 40, 39, 38], [37, 36, 35, 34, 33, 32, 31, 30, 29], [28, 27, 26, 25, 24, 23, 22, 21, 20]]) == 1020\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]]) == 222\n assert candidate(mat = [[100, 99, 98, 97, 96, 95, 94], [93, 92, 91, 90, 89, 88, 87], [86, 85, 84, 83, 82, 81, 80], [79, 78, 77, 76, 75, 74, 73], [72, 71, 70, 69, 68, 67, 66], [65, 64, 63, 62, 61, 60, 59], [58, 57, 56, 55, 54, 53, 52]]) == 988\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3], [4, 5, 6, 7, 8, 9, 10, 11], [11, 12, 13, 14, 15, 16, 17, 18]]) == 110\n assert candidate(mat = [[9, 8, 7, 6, 5, 4], [3, 2, 1, 0, -1, -2], [-3, -4, -5, -6, -7, -8], [-9, -10, -11, -12, -13, -14], [-15, -16, -17, -18, -19, -20], [-21, -22, -23, -24, -25, -26]]) == -102\n assert candidate(mat = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == 25\n assert candidate(mat = [[5, 2, 1, 4, 3], [9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [3, 2, 1, 0, 3], [1, 0, 3, 2, 1]]) == 28\n assert candidate(mat = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 0], [3, 4, 5, 6, 7, 8, 9, 0, 1], [4, 5, 6, 7, 8, 9, 0, 1, 2], [5, 6, 7, 8, 9, 0, 1, 2, 3], [6, 7, 8, 9, 0, 1, 2, 3, 4], [7, 8, 9, 0, 1, 2, 3, 4, 5], [8, 9, 0, 1, 2, 3, 4, 5, 6], [9, 0, 1, 2, 3, 4, 5, 6, 7]]) == 113\n assert candidate(mat = [[9, 2, 3, 4, 5, 6, 7, 8, 9], [2, 8, 3, 4, 5, 6, 7, 8, 9], [3, 4, 8, 4, 5, 6, 7, 8, 9], [4, 5, 6, 8, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 6, 7, 8, 9], [6, 7, 8, 9, 6, 8, 7, 8, 9], [7, 8, 9, 6, 7, 8, 8, 8, 9], [8, 9, 6, 7, 8, 9, 6, 8, 9], [9, 6, 7, 8, 9, 6, 7, 8, 8]]) == 140\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22], [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33], [34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44], [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55], [56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66], [67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77], [78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88], [89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110], [111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121]]) == 1281\n assert candidate(mat = [[50, 20, 10, 5, 1], [40, 30, 15, 25, 3], [35, 28, 20, 30, 4], [29, 22, 18, 26, 5], [23, 16, 12, 21, 6]]) == 203\n assert candidate(mat = [[2, 0, 0, 0, 2], [0, 3, 0, 3, 0], [0, 0, 4, 0, 0], [0, 5, 0, 5, 0], [6, 0, 0, 0, 6]]) == 36\n assert candidate(mat = [[50, 51, 52, 53, 54, 55, 56, 57], [58, 59, 60, 61, 62, 63, 64, 65], [66, 67, 68, 69, 70, 71, 72, 73], [74, 75, 76, 77, 78, 79, 80, 81], [82, 83, 84, 85, 86, 87, 88, 89], [90, 91, 92, 93, 94, 95, 96, 97], [98, 99, 100, 101, 102, 103, 104, 105], [106, 107, 108, 109, 110, 111, 112, 113]]) == 1304\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]) == 1010\n assert candidate(mat = [[2, 5, 4, 1, 6], [9, 7, 3, 8, 5], [6, 2, 9, 1, 3], [1, 6, 5, 9, 2], [7, 8, 4, 6, 9]]) == 63\n assert candidate(mat = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == 9\n assert candidate(mat = [[1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 1, 0, 0, 1, 0], [1, 0, 0, 0, 0, 1]]) == 12\n assert candidate(mat = [[10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33], [34, 35, 36, 37, 38, 39], [40, 41, 42, 43, 44, 45]]) == 330\n assert candidate(mat = [[2, 3, 4, 5, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16], [17, 18, 19, 20, 21], [22, 23, 24, 25, 26]]) == 126\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]]) == 222\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 13\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2], [8, 9, 10, 11, 12, 13], [13, 14, 15, 16, 17, 18]]) == 84\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6]]) == 70\n assert candidate(mat = [[10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24], [25, 26, 27, 28, 29], [30, 31, 32, 33, 34]]) == 198\n assert candidate(mat = [[10, 15, 20, 25, 30], [5, 9, 12, 18, 22], [7, 11, 14, 17, 21], [4, 8, 13, 16, 23], [1, 2, 3, 6, 24]]) == 130\n assert candidate(mat = [[2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31], [32, 33, 34, 35, 36, 37]]) == 234\n assert candidate(mat = [[50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63], [64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77], [78, 79, 80, 81, 82, 83, 84], [85, 86, 87, 88, 89, 90, 91], [92, 93, 94, 95, 96, 97, 98]]) == 962\n assert candidate(mat = [[2, 4, 6, 8], [10, 12, 14, 16], [18, 20, 22, 24], [26, 28, 30, 32]]) == 136\n assert candidate(mat = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]) == 360\n assert candidate(mat = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == 9\n assert candidate(mat = [[9, 0, 9, 0, 9, 0, 9, 0, 9, 0], [0, 9, 0, 9, 0, 9, 0, 9, 0, 9], [9, 0, 9, 0, 9, 0, 9, 0, 9, 0], [0, 9, 0, 9, 0, 9, 0, 9, 0, 9], [9, 0, 9, 0, 9, 0, 9, 0, 9, 0], [0, 9, 0, 9, 0, 9, 0, 9, 0, 9], [9, 0, 9, 0, 9, 0, 9, 0, 9, 0], [0, 9, 0, 9, 0, 9, 0, 9, 0, 9], [9, 0, 9, 0, 9, 0, 9, 0, 9, 0], [0, 9, 0, 9, 0, 9, 0, 9, 0, 9]]) == 90\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 2, 0, 0, 0], [0, 0, 3, 0, 0], [0, 0, 0, 4, 0], [0, 0, 0, 0, 5]]) == 15\n assert candidate(mat = [[2, 3, 4, 5, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16], [17, 18, 19, 20, 21], [22, 23, 24, 25, 26]]) == 126\n assert candidate(mat = [[50, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 50, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 50, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 50, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 50, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 50, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 50, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 50, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 50, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 50]]) == 510\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]]) == 325\n"}, "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().diagonalSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def diagonalSum(self, mat: list[list[int]]) -> int:", "container": "Solution", "callable": "diagonalSum", "parameters": [{"name": "mat", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1573, "task_id": "number-of-ways-to-split-a-string", "difficulty": "Medium", "problem_description": "Given a binary string s, you can split s into 3 non-empty strings s1, s2, and s3 where s1 + s2 + s3 = s.\nReturn the number of ways s can be split such that the number of ones is the same in s1, s2, and s3. Since the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: s = \"10101\"\nOutput: 4\nExplanation: There are four ways to split s in 3 parts where each part contain the same number of letters '1'.\n\"1|010|1\"\n\"1|01|01\"\n\"10|10|1\"\n\"10|1|01\"\n\nExample 2:\n\nInput: s = \"1001\"\nOutput: 0\n\nExample 3:\n\nInput: s = \"0000\"\nOutput: 3\nExplanation: There are three ways to split s in 3 parts.\n\"0|0|00\"\n\"0|00|0\"\n\"00|0|0\"\n\n \nConstraints:\n\n3 <= s.length <= 105\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"101010101\") == 0\n assert candidate(s = \"10101010101\") == 4\n assert candidate(s = \"0000\") == 3\n assert candidate(s = \"0000000\") == 15\n assert candidate(s = \"010101010\") == 0\n assert candidate(s = \"111000\") == 1\n assert candidate(s = \"11111111111\") == 0\n assert candidate(s = \"111111\") == 1\n assert candidate(s = \"10101\") == 4\n assert candidate(s = \"001001001\") == 9\n assert candidate(s = \"1111111\") == 0\n assert candidate(s = \"1001001001\") == 0\n assert candidate(s = \"111000111000111\") == 16\n assert candidate(s = \"01010101010\") == 0\n assert candidate(s = \"1010101010\") == 0\n assert candidate(s = \"0000000000\") == 36\n assert candidate(s = \"1100110011\") == 9\n assert candidate(s = \"00000000000\") == 45\n assert candidate(s = \"1000000000001\") == 0\n assert candidate(s = \"0101010101\") == 0\n assert candidate(s = \"10100101010101\") == 0\n assert candidate(s = \"11011011011\") == 0\n assert candidate(s = \"111000111\") == 1\n assert candidate(s = \"100010001\") == 16\n assert candidate(s = \"1001\") == 0\n assert candidate(s = \"01010101010101010101010101010101\") == 0\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\") == 1176\n assert candidate(s = \"1001001001001001001001\") == 0\n assert candidate(s = \"111000111000111000111000111\") == 1\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"0000001110000011100000111\") == 36\n assert candidate(s = \"1000000010000000100000001\") == 0\n assert candidate(s = \"1110111011101110111011101110111\") == 1\n assert candidate(s = \"111111111111111111111111111111111111111111111111\") == 1\n assert candidate(s = \"101010101010101010101010101010101010101010101010\") == 4\n assert candidate(s = \"1000100010001000100010001000100010001000100010001\") == 0\n assert candidate(s = \"001001001001001001001001001001001001001\") == 0\n assert candidate(s = \"1001001001001\") == 0\n assert candidate(s = \"00001000010000100001000010000100001000010000100001\") == 0\n assert candidate(s = \"111000111000111000111000111000111000111000111\") == 1\n assert candidate(s = \"111111111111111111111111111111111111111111111111111\") == 1\n assert candidate(s = \"1001001001001001001001001001001001001001001001001\") == 0\n assert candidate(s = \"0010101010100\") == 0\n assert candidate(s = \"1111000011110000111100001111\") == 0\n assert candidate(s = \"10101010101010101010101010\") == 0\n assert candidate(s = \"101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001\") == 9\n assert candidate(s = \"100000000000000000000000000000000000000000000000000000001\") == 0\n assert candidate(s = \"001001001001001001001001001001001001001001001001001001\") == 9\n assert candidate(s = \"1100110011001100110011\") == 9\n assert candidate(s = \"0000111100001111000011110000111100001111\") == 0\n assert candidate(s = \"0011001100110011001100110011\") == 0\n assert candidate(s = \"110011001100110011001100110011\") == 0\n assert candidate(s = \"10000000001000000001\") == 90\n assert candidate(s = \"110011001100110\") == 0\n assert candidate(s = \"100000100000100000100000100000100000\") == 36\n assert candidate(s = \"10101010101010101010101010101010101010101010101\") == 4\n assert candidate(s = \"0101010101010101010101010101\") == 0\n assert candidate(s = \"10001000100010001000100010001000100010001000100010001000\") == 0\n assert candidate(s = \"111110000011111000001111100000111110000011111\") == 0\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100\") == 0\n assert candidate(s = \"000000000000000\") == 91\n assert candidate(s = \"101010101010101010101\") == 0\n assert candidate(s = \"00010001000100010001\") == 0\n assert candidate(s = \"100000000000100000000010000000001\") == 0\n assert candidate(s = \"1000000000000000000001\") == 0\n assert candidate(s = \"1001001001001001001001001001001001001001\") == 0\n assert candidate(s = \"101010101010101010101010101\") == 0\n assert candidate(s = \"000000000000000000000000000000000000000000000000000\") == 1225\n assert candidate(s = \"10100100100100100\") == 9\n assert candidate(s = \"0100100100100100100100100100100100100100100100100100\") == 0\n assert candidate(s = \"111111000000111111000000111111\") == 49\n assert candidate(s = \"00010001000100010001000100010001\") == 0\n assert candidate(s = \"0000000000000000000000\") == 210\n assert candidate(s = \"0000000000000000000000000\") == 276\n assert candidate(s = \"11011011011011011011011011011011\") == 0\n assert candidate(s = \"11111000001111100000111110000011111\") == 0\n assert candidate(s = \"111000111000111000111000\") == 1\n assert candidate(s = \"1000010000100001000010000100001\") == 0\n assert candidate(s = \"110011001100110011\") == 0\n assert candidate(s = \"101001010010100101001010010100101001010010100101001\") == 6\n assert candidate(s = \"0000000000000000000000000000\") == 351\n assert candidate(s = \"01001001001001\") == 0\n assert candidate(s = \"000000000000000000000000000000000000000000000\") == 946\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numWays(self, s: str) -> int:", "container": "Solution", "callable": "numWays", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1574, "task_id": "shortest-subarray-to-be-removed-to-make-array-sorted", "difficulty": "Medium", "problem_description": "Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing.\nReturn the length of the shortest subarray to remove.\nA subarray is a contiguous subsequence of the array.\n \nExample 1:\n\nInput: arr = [1,2,3,10,4,2,3,5]\nOutput: 3\nExplanation: The shortest subarray we can remove is [10,4,2] of length 3. The remaining elements after that will be [1,2,3,3,5] which are sorted.\nAnother correct solution is to remove the subarray [3,10,4].\n\nExample 2:\n\nInput: arr = [5,4,3,2,1]\nOutput: 4\nExplanation: Since the array is strictly decreasing, we can only keep a single element. Therefore we need to remove a subarray of length 4, either [5,4,3,2] or [4,3,2,1].\n\nExample 3:\n\nInput: arr = [1,2,3]\nOutput: 0\nExplanation: The array is already non-decreasing. We do not need to remove any elements.\n\n \nConstraints:\n\n1 <= arr.length <= 105\n0 <= arr[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 4, 3, 2, 1]) == 4\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == 9\n assert candidate(arr = [1, 2, 3]) == 0\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 5]) == 1\n assert candidate(arr = [1, 2, 2, 2, 3, 4, 5, 5, 5, 4, 3, 2, 1]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 1\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12]) == 6\n assert candidate(arr = [1]) == 0\n assert candidate(arr = [1, 3, 5, 4, 7]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1]) == 0\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 7]) == 2\n assert candidate(arr = [1, 2, 2, 3, 4, 5]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 5, 6, 7, 8, 9]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5]) == 0\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5]) == 3\n assert candidate(arr = [1, 2, 2, 3, 1, 4, 5]) == 1\n assert candidate(arr = [1, 2, 3, 2, 1]) == 2\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(arr = [1, 3, 2, 4, 5]) == 1\n assert candidate(arr = [1, 3, 2, 4, 3, 5]) == 2\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3]) == 5\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 13\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10]) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 14, 16, 15, 17, 19, 18, 20, 22, 21, 23, 25, 24, 26, 28, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80]) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 0, 1, 3, 5, 7, 9, 11, 13, 15]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 21\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 13\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 0]) == 8\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 8, 9, 10, 11, 12, 13, 14]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8]) == 23\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 29\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 15, 16, 17, 18, 19]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 7\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == 27\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(arr = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 9\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17]) == 13\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 18\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 5, 7, 9, 8, 10, 12, 11, 13, 15, 14, 16, 18, 17, 19, 21, 20, 22, 24, 23, 25]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 29\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9]) == 10\n assert candidate(arr = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 600]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 1\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2]) == 26\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 49\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(arr = [40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 39\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 14\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 20, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29, 32, 31, 34, 33, 36, 35]) == 23\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 29\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 14, 15, 16, 17, 18, 19, 20]) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 17\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 105, 110, 115, 120, 125, 130, 135, 140, 145]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 18\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 13\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(arr = [10, 20, 30, 25, 26, 27, 15, 16, 17, 18, 19]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 29\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 8\n assert candidate(arr = [1, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8]) == 16\n assert candidate(arr = [1, 2, 3, 10, 11, 12, 4, 5, 6, 7, 8, 9, 13, 14, 15]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 8\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 19\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(arr = [1, 10, 20, 15, 25, 30, 5, 10, 15, 20]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3]) == 27\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15]) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 18, 19]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 10, 11, 12, 13, 14, 15]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9]) == 22\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 1, 3, 5, 7, 9, 11]) == 23\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 29]) == 6\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 51\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5]) == 13\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(arr = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9]) == 5\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 18\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 29\n assert candidate(arr = [60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 59\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 4\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 14, 16, 15, 17, 19, 18, 20, 22, 21, 23, 25, 24, 26, 28, 27, 29]) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 23\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 15\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 15, 17, 16, 18, 20, 19, 21, 23, 22, 24, 26, 25]) == 18\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 14, 16, 15, 17, 19, 18, 20, 22, 21, 23, 25, 24, 26, 28, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == 33\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 3, 5, 7, 9, 11]) == 6\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 35\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 2\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 9\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().findLengthOfShortestSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findLengthOfShortestSubarray(self, arr: list[int]) -> int:", "container": "Solution", "callable": "findLengthOfShortestSubarray", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1575, "task_id": "count-all-possible-routes", "difficulty": "Hard", "problem_description": "You are given an array of distinct positive integers locations where locations[i] represents the position of city i. You are also given integers start, finish and fuel representing the starting city, ending city, and the initial amount of fuel you have, respectively.\nAt each step, if you are at city i, you can pick any city j such that j != i and 0 <= j < locations.length and move to city j. Moving from city i to city j reduces the amount of fuel you have by |locations[i] - locations[j]|. Please notice that |x| denotes the absolute value of x.\nNotice that fuel cannot become negative at any point in time, and that you are allowed to visit any city more than once (including start and finish).\nReturn the count of all possible routes from start to finish. Since the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: locations = [2,3,6,8,4], start = 1, finish = 3, fuel = 5\nOutput: 4\nExplanation: The following are all possible routes, each uses 5 units of fuel:\n1 -> 3\n1 -> 2 -> 3\n1 -> 4 -> 3\n1 -> 4 -> 2 -> 3\n\nExample 2:\n\nInput: locations = [4,3,1], start = 1, finish = 0, fuel = 6\nOutput: 5\nExplanation: The following are all possible routes:\n1 -> 0, used fuel = 1\n1 -> 2 -> 0, used fuel = 5\n1 -> 2 -> 1 -> 0, used fuel = 5\n1 -> 0 -> 1 -> 0, used fuel = 3\n1 -> 0 -> 1 -> 0 -> 1 -> 0, used fuel = 5\n\nExample 3:\n\nInput: locations = [5,2,1], start = 0, finish = 2, fuel = 3\nOutput: 0\nExplanation: It is impossible to get from 0 to 2 using only 3 units of fuel since the shortest route needs 4 units of fuel.\n\n \nConstraints:\n\n2 <= locations.length <= 100\n1 <= locations[i] <= 109\nAll integers in locations are distinct.\n0 <= start, finish < locations.length\n1 <= fuel <= 200\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(locations = [4, 3, 1],start = 1,finish = 0,fuel = 6) == 5\n assert candidate(locations = [1, 10, 100, 1000, 10000],start = 0,finish = 4,fuel = 5000) == 0\n assert candidate(locations = [1, 2, 3, 4, 5],start = 0,finish = 4,fuel = 10) == 1208\n assert candidate(locations = [5, 2, 1],start = 0,finish = 2,fuel = 3) == 0\n assert candidate(locations = [10, 20, 30, 40],start = 0,finish = 3,fuel = 50) == 16\n assert candidate(locations = [2, 3, 6, 8, 4],start = 1,finish = 3,fuel = 5) == 4\n assert candidate(locations = [1, 2, 3],start = 0,finish = 2,fuel = 3) == 2\n assert candidate(locations = [10, 20, 30, 40, 50],start = 0,finish = 4,fuel = 100) == 1208\n assert candidate(locations = [2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62],start = 2,finish = 9,fuel = 100) == 549504\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90],start = 3,finish = 8,fuel = 150) == 461824\n assert candidate(locations = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145, 160, 175, 190],start = 0,finish = 12,fuel = 300) == 23453696\n assert candidate(locations = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],start = 20,finish = 0,fuel = 300) == 984041497\n assert candidate(locations = [10, 25, 35, 45, 55],start = 0,finish = 4,fuel = 80) == 40\n assert candidate(locations = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 4,finish = 0,fuel = 150) == 179664\n assert candidate(locations = [5, 6, 8, 9, 11, 12, 14, 15, 17, 18],start = 0,finish = 9,fuel = 20) == 28672\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45],start = 0,finish = 8,fuel = 120) == 838699257\n assert candidate(locations = [1, 5, 9, 12, 18, 23],start = 0,finish = 5,fuel = 40) == 464\n assert candidate(locations = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550],start = 1,finish = 9,fuel = 1000) == 78931328\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 0,finish = 9,fuel = 100) == 11616768\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13],start = 0,finish = 6,fuel = 15) == 32\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],start = 15,finish = 0,fuel = 2500) == 886790116\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 0,finish = 9,fuel = 20) == 256\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],start = 0,finish = 14,fuel = 150) == 8192\n assert candidate(locations = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],start = 0,finish = 19,fuel = 150) == 505021546\n assert candidate(locations = [1, 10, 100, 1000, 10000, 100000, 1000000],start = 0,finish = 6,fuel = 1000000) == 32\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 0,finish = 19,fuel = 1000) == 762710068\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80],start = 2,finish = 5,fuel = 100) == 1952\n assert candidate(locations = [3, 7, 12, 18, 23, 29, 34, 39, 44],start = 1,finish = 8,fuel = 100) == 11186944\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 0,finish = 9,fuel = 1000) == 256\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 0,finish = 19,fuel = 200) == 262144\n assert candidate(locations = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],start = 6,finish = 11,fuel = 200) == 460940892\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13, 15],start = 7,finish = 0,fuel = 15) == 64\n assert candidate(locations = [5, 20, 15, 40, 25, 35, 10],start = 2,finish = 6,fuel = 80) == 225320\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 0,finish = 19,fuel = 1800) == 387985368\n assert candidate(locations = [2, 15, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],start = 1,finish = 17,fuel = 100) == 524288\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500],start = 49,finish = 0,fuel = 2000) == 430143451\n assert candidate(locations = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],start = 9,finish = 18,fuel = 300) == 279596282\n assert candidate(locations = [100, 200, 300, 400, 500],start = 1,finish = 3,fuel = 600) == 76\n assert candidate(locations = [1, 5, 10, 15, 20, 25, 30],start = 0,finish = 6,fuel = 40) == 224\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 0,finish = 9,fuel = 150) == 892249801\n assert candidate(locations = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210, 230, 250, 270, 290, 310, 330, 350, 370, 390, 410, 430, 450, 470, 490],start = 0,finish = 24,fuel = 1200) == 765380918\n assert candidate(locations = [7, 15, 22, 30, 35, 40, 45],start = 1,finish = 4,fuel = 70) == 12736\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 10,finish = 19,fuel = 150) == 290816\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 0,finish = 9,fuel = 25) == 563971037\n assert candidate(locations = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210, 230, 250, 270, 290, 310, 330, 350, 370, 390, 410, 430, 450, 470, 490],start = 0,finish = 24,fuel = 1500) == 191567701\n assert candidate(locations = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],start = 0,finish = 9,fuel = 150) == 1469184\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],start = 1,finish = 13,fuel = 40) == 344143577\n assert candidate(locations = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],start = 1,finish = 13,fuel = 100) == 569120129\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 9,finish = 10,fuel = 50) == 43\n assert candidate(locations = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 4,finish = 9,fuel = 1023) == 16\n assert candidate(locations = [1, 5, 10, 15, 20, 25, 30],start = 0,finish = 6,fuel = 30) == 32\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 0,finish = 9,fuel = 500) == 0\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 5,finish = 9,fuel = 150) == 179664\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],start = 0,finish = 19,fuel = 9900) == 762710068\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],start = 29,finish = 0,fuel = 50) == 593376807\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 1,finish = 8,fuel = 15) == 64\n assert candidate(locations = [5, 8, 12, 18, 25, 30, 35, 40, 45, 50, 55, 60],start = 11,finish = 0,fuel = 100) == 15490048\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],start = 5,finish = 10,fuel = 150) == 500736\n assert candidate(locations = [1000, 1005, 1010, 1015, 1020, 1025, 1030, 1035, 1040, 1045, 1050, 1055, 1060, 1065, 1070, 1075, 1080, 1085, 1090, 1095, 1100],start = 10,finish = 20,fuel = 600) == 512001622\n assert candidate(locations = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 0,finish = 20,fuel = 300) == 652750206\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800],start = 1,finish = 7,fuel = 1500) == 116544\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],start = 15,finish = 0,fuel = 100) == 802029339\n assert candidate(locations = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145],start = 0,finish = 9,fuel = 500) == 216449452\n assert candidate(locations = [1, 5, 10, 20, 30, 40],start = 0,finish = 5,fuel = 60) == 208\n assert candidate(locations = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],start = 0,finish = 29,fuel = 300) == 268435456\n assert candidate(locations = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],start = 7,finish = 15,fuel = 300) == 343225957\n assert candidate(locations = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 0,finish = 20,fuel = 190) == 0\n assert candidate(locations = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],start = 0,finish = 19,fuel = 524288) == 262144\n assert candidate(locations = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],start = 10,finish = 0,fuel = 150) == 759294305\n assert candidate(locations = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210],start = 19,finish = 0,fuel = 210) == 262144\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200],start = 0,finish = 39,fuel = 500) == 319204339\n assert candidate(locations = [3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151],start = 0,finish = 19,fuel = 2097150) == 262144\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 4,finish = 8,fuel = 30) == 277680\n assert candidate(locations = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],start = 0,finish = 14,fuel = 500) == 6482820\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],start = 0,finish = 29,fuel = 150) == 268435456\n assert candidate(locations = [1, 5, 10, 15, 20, 25],start = 0,finish = 5,fuel = 40) == 112\n assert candidate(locations = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],start = 0,finish = 19,fuel = 524287) == 262144\n assert candidate(locations = [100, 200, 300, 400, 500, 600],start = 0,finish = 5,fuel = 1500) == 149696\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],start = 7,finish = 14,fuel = 120) == 5760\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 0,finish = 9,fuel = 1500) == 183296\n assert candidate(locations = [1, 5, 10, 20, 50, 100, 200, 500, 1000, 2000],start = 0,finish = 9,fuel = 3000) == 149308961\n assert candidate(locations = [5, 15, 25, 35, 45, 55, 65],start = 0,finish = 6,fuel = 150) == 71872\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 9,finish = 0,fuel = 100) == 11616768\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],start = 0,finish = 19,fuel = 18) == 0\n assert candidate(locations = [100, 200, 300, 400, 500, 600],start = 5,finish = 0,fuel = 1500) == 149696\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],start = 0,finish = 11,fuel = 100) == 9483264\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13],start = 0,finish = 6,fuel = 20) == 1536\n assert candidate(locations = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 0,finish = 9,fuel = 100) == 256\n assert candidate(locations = [5, 10, 15, 20, 25, 30],start = 0,finish = 5,fuel = 50) == 592\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 0,finish = 9,fuel = 1800) == 1469184\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],start = 0,finish = 29,fuel = 150) == 996660885\n assert candidate(locations = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295],start = 29,finish = 0,fuel = 1500) == 996660885\n assert candidate(locations = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],start = 10,finish = 0,fuel = 50) == 636086244\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],start = 0,finish = 14,fuel = 50) == 928900893\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],start = 0,finish = 19,fuel = 190) == 533148385\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800, 900],start = 0,finish = 8,fuel = 2000) == 32131968\n"}, "metadata": {"canonical_parameter_names": ["locations", "start", "finish", "fuel"], "leetcode_dataset_entry_point": "Solution().countRoutes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countRoutes(self, locations: list[int], start: int, finish: int, fuel: int) -> int:", "container": "Solution", "callable": "countRoutes", "parameters": [{"name": "locations", "type": "list[int]"}, {"name": "start", "type": "int"}, {"name": "finish", "type": "int"}, {"name": "fuel", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1576, "task_id": "replace-all-s-to-avoid-consecutive-repeating-characters", "difficulty": "Easy", "problem_description": "Given a string s containing only lowercase English letters and the '?' character, convert all the '?' characters into lowercase letters such that the final string does not contain any consecutive repeating characters. You cannot modify the non '?' characters.\nIt is guaranteed that there are no consecutive repeating characters in the given string except for '?'.\nReturn the final string after all the conversions (possibly zero) have been made. If there is more than one solution, return any of them. It can be shown that an answer is always possible with the given constraints.\n \nExample 1:\n\nInput: s = \"?zs\"\nOutput: \"azs\"\nExplanation: There are 25 solutions for this problem. From \"azs\" to \"yzs\", all are valid. Only \"z\" is an invalid modification as the string will consist of consecutive repeating characters in \"zzs\".\n\nExample 2:\n\nInput: s = \"ubv?w\"\nOutput: \"ubvaw\"\nExplanation: There are 24 solutions for this problem. Only \"v\" and \"w\" are invalid modifications as the strings will consist of consecutive repeating characters in \"ubvvw\" and \"ubvww\".\n\n \nConstraints:\n\n1 <= s.length <= 100\ns consist of lowercase English letters and '?'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"?zs\") == \"azs\"\n assert candidate(s = \"b?a\") == \"bca\"\n assert candidate(s = \"a?b?\") == \"acba\"\n assert candidate(s = \"zz?z?zz\") == \"zzazazz\"\n assert candidate(s = \"z?z\") == \"zaz\"\n assert candidate(s = \"abc?de?\") == \"abcadea\"\n assert candidate(s = \"?abcd\") == \"babcd\"\n assert candidate(s = \"zyx?\") == \"zyxa\"\n assert candidate(s = \"z?a?a?a?z\") == \"zbabababz\"\n assert candidate(s = \"a?b?c?\") == \"acbaca\"\n assert candidate(s = \"a?c?e?\") == \"abcaea\"\n assert candidate(s = \"??a??\") == \"ababa\"\n assert candidate(s = \"abc?ef?\") == \"abcaefa\"\n assert candidate(s = \"b?a?c?\") == \"bcabca\"\n assert candidate(s = \"?a?a?a?\") == \"bababab\"\n assert candidate(s = \"????\") == \"abab\"\n assert candidate(s = \"a?b?c?d?\") == \"acbacada\"\n assert candidate(s = \"abcd?\") == \"abcda\"\n assert candidate(s = \"xyz?\") == \"xyza\"\n assert candidate(s = \"?\") == \"a\"\n assert candidate(s = \"a?b\") == \"acb\"\n assert candidate(s = \"?a?b?c?\") == \"bacbaca\"\n assert candidate(s = \"a?b?c\") == \"acbac\"\n assert candidate(s = \"?a?a?a\") == \"bababa\"\n assert candidate(s = \"a?c\") == \"abc\"\n assert candidate(s = \"a?a\") == \"aba\"\n assert candidate(s = \"ubv?w\") == \"ubvaw\"\n assert candidate(s = \"?????\") == \"ababa\"\n assert candidate(s = \"abc?\") == \"abca\"\n assert candidate(s = \"?a?b?c\") == \"bacbac\"\n assert candidate(s = \"????????????\") == \"abababababab\"\n assert candidate(s = \"??a??b??c??d??\") == \"ababababcabdab\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?abcdef?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcdefa\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbacbacadaeafagahaiajakalamanaoapaqarasatauavawaxayaz\"\n assert candidate(s = \"z?????????\") == \"zababababa\"\n assert candidate(s = \"a?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?f\") == \"acbacadaeafacbacadaeafacbacadaeafacbacadaeafacbacadaeaf\"\n assert candidate(s = \"x?y?z?x?y?\") == \"xayazaxaya\"\n assert candidate(s = \"?a?b?c?d?e\") == \"bacbacadae\"\n assert candidate(s = \"????????????????????\") == \"abababababababababab\"\n assert candidate(s = \"a?z?b?y?c?x?d?w?e?v?f?u?g?t?h?s?i?r?j?q?k?p?l?o?m?n?l?k?j?i?h?g?f?e?d?c?b?a\") == \"abzabayacaxadawaeavafauagatahasaiarajaqakapalaoamanalakajaiahagafaeadacabca\"\n assert candidate(s = \"abcd????efgh????ijkl????mnop????qrst????uvw????xyz????\") == \"abcdababefghababijklababmnopababqrstababuvwababxyzabab\"\n assert candidate(s = \"a?b?c?d?e?f?g?\") == \"acbacadaeafaga\"\n assert candidate(s = \"?b?a?b?a?b?a?b?a?b?\") == \"abcacbcacbcacbcacba\"\n assert candidate(s = \"a??????b??????c??????d??????e??????\") == \"abababababababcabababdabababeababab\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz????\") == \"abcdefghijklmnopqrstuvwxyzabab\"\n assert candidate(s = \"ab?cde?fg?hij?kl?mno?pqr?stu?vwx?yz?\") == \"abacdeafgahijaklamnoapqrastuavwxayza\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?ab?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbaba\"\n assert candidate(s = \"a????b????c????\") == \"abababababcabab\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?abcdefghijklmnopqrstuvwxyz\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba?\") == \"zyxwvutsrqponmlkjihgfedcbab\"\n assert candidate(s = \"x???x???\") == \"xabaxaba\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?abcde?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcdea\"\n assert candidate(s = \"abc????def????ghi????jkl????mno????pqr????stu????vwx????yz?\") == \"abcababdefababghiababjklababmnoababpqrababstuababvwxababyza\"\n assert candidate(s = \"a????b????c????d????e????\") == \"abababababcababdababeabab\"\n assert candidate(s = \"?????????\") == \"ababababa\"\n assert candidate(s = \"abcd?efg?hij?\") == \"abcdaefgahija\"\n assert candidate(s = \"a?z?b?y?c?x?d?w?e?v?f?u?g?t?h?s?i?r?j?q?k?p?l?o?m?n?l?k?j?i?h?g?f?e?d?c?b?a????\") == \"abzabayacaxadawaeavafauagatahasaiarajaqakapalaoamanalakajaiahagafaeadacabcababa\"\n assert candidate(s = \"?a?b?c?d?e?fg?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z\") == \"bacbacadaeafgahaiajakalamanaoapaqarasatauavawaxayaz\"\n assert candidate(s = \"a???????????????????????????????????????????????????????b\") == \"abababababababababababababababababababababababababababacb\"\n assert candidate(s = \"a?z?b?y?c?x?d?w?e?v?f?u?g?t?h?s?i?r?j?q?k?p?l?o?m?n?l?k?j?i?h?g?f?e?d?c?b?a?z?y?x?w?\") == \"abzabayacaxadawaeavafauagatahasaiarajaqakapalaoamanalakajaiahagafaeadacabcabzayaxawa\"\n assert candidate(s = \"xyz???uvw???stu???rst???qpo???nml???kji???hgf???edc???ba???\") == \"xyzabauvwabastuabarstabaqpoabanmlabakjiabahgfabaedcabababab\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz????\") == \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabab\"\n assert candidate(s = \"?a?b?c?d?e?f?g\") == \"bacbacadaeafag\"\n assert candidate(s = \"????a????\") == \"ababababa\"\n assert candidate(s = \"z?y?x?w?v?u?t?s?r?q?p?o?n?m?l?k?j?i?h?g?f?e?d?c?b?a?\") == \"zayaxawavauatasaraqapaoanamalakajaiahagafaeadacabcab\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z????\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazabab\"\n assert candidate(s = \"abc??xyz?\") == \"abcabxyza\"\n assert candidate(s = \"abc?de?fg?\") == \"abcadeafga\"\n assert candidate(s = \"????z\") == \"ababz\"\n assert candidate(s = \"a?????z\") == \"abababz\"\n assert candidate(s = \"abc????????de?????fg????hi????j????k????lm????n????op????qr????st????uv????wxyz????\") == \"abcababababdeababafgababhiababjababkabablmababnababopababqrababstababuvababwxyzabab\"\n assert candidate(s = \"a?????b?????c?????d?????e?????f?????g?????h?????i?????j?????\") == \"ababacbababacababadababaeababafababagababahababaiababajababa\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?a?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbab\"\n assert candidate(s = \"xyz???abc\") == \"xyzabcabc\"\n assert candidate(s = \"xyz?yxz?\") == \"xyzayxza\"\n assert candidate(s = \"?a?b?c?d?e?\") == \"bacbacadaea\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayaza\"\n assert candidate(s = \"ab?cd?ef?gh?ij?kl?mn?op?qr?st?uv?wx?yz?a?b?c?d?e?\") == \"abacdaefaghaijaklamnaopaqrastauvawxayzbacbacadaea\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?abcdefg?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcdefga\"\n assert candidate(s = \"????abc????def????ghi????jkl????mno????pqr????stu????vwx????yz????\") == \"abababcababdefababghiababjklababmnoababpqrababstuababvwxababyzabab\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?\") == \"acbacadaeafagahaiaja\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?a?b?c?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbacbaca\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?a?b?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbacba\"\n assert candidate(s = \"a?????????????????????????????????????????????b\") == \"ababababababababababababababababababababababacb\"\n assert candidate(s = \"????????\") == \"abababab\"\n assert candidate(s = \"????abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"abababcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"a????????????????????z\") == \"ababababababababababaz\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayaz\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?abcdefghijklmnopqrstuvwxyz?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z????\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcdefghijklmnopqrstuvwxyzbacbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazabab\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?abc?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabca\"\n assert candidate(s = \"?b?a?c?b?a?\") == \"abcabcabcab\"\n assert candidate(s = \"z??y?x?w?\") == \"zabyaxawa\"\n assert candidate(s = \"????abcdefghijklmnopqrstuvwxyz\") == \"abababcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxy?\") == \"abcdefghijklmnopqrstuvwxya\"\n assert candidate(s = \"a?b?c?d?e?\") == \"acbacadaea\"\n assert candidate(s = \"abc?def?ghi?jkl?mno?pqr?stu?vwx?yz?\") == \"abcadefaghiajklamnoapqrastuavwxayza\"\n assert candidate(s = \"a?b?a?b?a?b?a?b?a?\") == \"acbcacbcacbcacbcab\"\n assert candidate(s = \"ab?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?\") == \"abacadaeafagahaiajakalamanaoapaqarasatauavawaxayaza\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?abcd?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcda\"\n assert candidate(s = \"z?a?y?b?x?c?w?v?d?u?t?e?s?r?q?p?o?n?m?l?k?j?i?h?g?f?e?d?c?b?a?\") == \"zbabyabaxacawavadauataeasaraqapaoanamalakajaiahagafaeadacabcab\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z????\") == \"abcdefghijklmnopqrstuvwxyzbacbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazabab\"\n assert candidate(s = \"aaaa???bbbbb???ccccc???\") == \"aaaabacbbbbbabacccccaba\"\n assert candidate(s = \"?a?b?c?d?e?f?g?\") == \"bacbacadaeafaga\"\n assert candidate(s = \"z?y?x?w?v?u?t?s?r?q?p?o?n?m?l?k?j?i?h?g?f?e?d?c?b?a\") == \"zayaxawavauatasaraqapaoanamalakajaiahagafaeadacabca\"\n assert candidate(s = \"?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z\") == \"bacbacadaeafagahaiajakalamanaoapaqarasatauavawaxayaz\"\n assert candidate(s = \"a?a?a?a?a?a?a?a?a?a\") == \"abababababababababa\"\n assert candidate(s = \"a??b??c??d??\") == \"abababcabdab\"\n assert candidate(s = \"??a?b??c??\") == \"abacbabcab\"\n assert candidate(s = \"a?b??c?d\") == \"acbabcad\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz?\") == \"abcdefghijklmnopqrstuvwxyza\"\n assert candidate(s = \"abcd????????efgh????????ijkl????????mnop????????qrst????????uvwx????????yz??\") == \"abcdababababefghababababijklababababmnopababababqrstababababuvwxababababyzab\"\n assert candidate(s = \"z????z????z????z????z\") == \"zababzababzababzababz\"\n assert candidate(s = \"a?a?a?a?a?b?b?b?b?b?c?c?c?c?c?d?d?d?d?d?\") == \"ababababacbababababacacacacacadadadadada\"\n assert candidate(s = \"xyz?abc?def?ghi?\") == \"xyzbabcadefaghia\"\n assert candidate(s = \"xyz??abc\") == \"xyzababc\"\n assert candidate(s = \"abcd????efgh\") == \"abcdababefgh\"\n assert candidate(s = \"?ab?bc?cd?de?ef?fg?\") == \"bababcacdadeaefafga\"\n assert candidate(s = \"a?????z?????y?????x?????w?????v?????u?????t?????s?????r?????q?????p?????o?????n?????m?????l?????k?????j?????i?????h?????g?????f?????e?????d?????c?????b\") == \"abababzababayababaxababawababavababauababatababasababarababaqababapababaoababanababamababalababakababajababaiababahababagababafababaeababadababacababab\"\n assert candidate(s = \"abc???def\") == \"abcabadef\"\n assert candidate(s = \"b?a?b?a?b?a?\") == \"bcacbcacbcab\"\n assert candidate(s = \"abc?def?ghi?jkl?mno?pqr?stu?vwx?yz\") == \"abcadefaghiajklamnoapqrastuavwxayz\"\n assert candidate(s = \"abc?def?ghi?\") == \"abcadefaghia\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().modifyString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def modifyString(self, s: str) -> str:", "container": "Solution", "callable": "modifyString", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1577, "task_id": "number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers", "difficulty": "Medium", "problem_description": "Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:\n\nType 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.\nType 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where 0 <= i < nums2.length and 0 <= j < k < nums1.length.\n\n \nExample 1:\n\nInput: nums1 = [7,4], nums2 = [5,2,8,9]\nOutput: 1\nExplanation: Type 1: (1, 1, 2), nums1[1]2 = nums2[1] * nums2[2]. (42 = 2 * 8). \n\nExample 2:\n\nInput: nums1 = [1,1], nums2 = [1,1,1]\nOutput: 9\nExplanation: All Triplets are valid, because 12 = 1 * 1.\nType 1: (0,0,1), (0,0,2), (0,1,2), (1,0,1), (1,0,2), (1,1,2). nums1[i]2 = nums2[j] * nums2[k].\nType 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]2 = nums1[j] * nums1[k].\n\nExample 3:\n\nInput: nums1 = [7,7,8,3], nums2 = [1,2,9,7]\nOutput: 2\nExplanation: There are 2 valid triplets.\nType 1: (3,0,2). nums1[3]2 = nums2[0] * nums2[2].\nType 2: (3,0,1). nums2[3]2 = nums1[0] * nums1[1].\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 1000\n1 <= nums1[i], nums2[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [3, 5, 7],nums2 = [9, 25, 49]) == 0\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [25, 25, 25, 25]) == 0\n assert candidate(nums1 = [10, 5, 2],nums2 = [100, 25, 4]) == 1\n assert candidate(nums1 = [2, 3, 5],nums2 = [2, 5, 10]) == 0\n assert candidate(nums1 = [2, 2, 2, 2],nums2 = [4, 4, 4]) == 0\n assert candidate(nums1 = [7, 4],nums2 = [5, 2, 8, 9]) == 1\n assert candidate(nums1 = [3, 3, 3],nums2 = [3, 3, 3, 3]) == 30\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 4, 9, 16, 25]) == 4\n assert candidate(nums1 = [6, 10, 15],nums2 = [36, 100, 225]) == 0\n assert candidate(nums1 = [10, 10, 10],nums2 = [10, 10, 10, 10]) == 30\n assert candidate(nums1 = [5],nums2 = [5, 5, 5]) == 3\n assert candidate(nums1 = [7, 7, 8, 3],nums2 = [1, 2, 9, 7]) == 2\n assert candidate(nums1 = [3, 3, 3, 3],nums2 = [9, 9, 9, 9]) == 0\n assert candidate(nums1 = [1000],nums2 = [1, 10, 100, 1000]) == 0\n assert candidate(nums1 = [2, 3, 5],nums2 = [4, 9, 25]) == 0\n assert candidate(nums1 = [3, 15, 9],nums2 = [9, 25, 36]) == 1\n assert candidate(nums1 = [2, 3, 4],nums2 = [1, 5, 6, 10]) == 0\n assert candidate(nums1 = [10, 10, 10],nums2 = [10, 10, 10]) == 18\n assert candidate(nums1 = [1],nums2 = [1, 1, 1, 1, 1]) == 10\n assert candidate(nums1 = [10, 5, 3],nums2 = [2, 4, 8, 16]) == 0\n assert candidate(nums1 = [1, 1],nums2 = [1, 1, 1]) == 9\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 9, 25, 49, 81, 121, 169, 225, 289, 361]) == 10\n assert candidate(nums1 = [3, 9, 27, 81],nums2 = [9, 81, 243, 729, 2187, 6561]) == 3\n assert candidate(nums1 = [11, 22, 33, 44],nums2 = [121, 484, 726, 1936, 2904]) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [25, 25, 25, 25, 25, 25, 25]) == 0\n assert candidate(nums1 = [6, 10, 12, 15],nums2 = [36, 100, 144, 225, 150]) == 0\n assert candidate(nums1 = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [36, 49, 64, 81, 100, 121, 144, 169, 196, 225]) == 0\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [10000, 40000, 90000, 160000]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3],nums2 = [9, 9, 9, 9, 9, 9, 9]) == 0\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3],nums2 = [1, 4, 4, 9, 9, 9, 9]) == 16\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 900\n assert candidate(nums1 = [3, 9, 27, 81, 243, 729],nums2 = [9, 27, 81, 243, 729, 2187]) == 12\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [10000, 40000, 90000, 160000, 250000]) == 0\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],nums2 = [49, 196, 441, 784, 1225, 1764, 2401, 3136, 3969, 4900, 5929, 7056, 8281, 9604, 11025]) == 1\n assert candidate(nums1 = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13],nums2 = [169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169]) == 0\n assert candidate(nums1 = [4, 8, 12, 16, 20],nums2 = [16, 64, 144, 256, 400, 625, 1024]) == 0\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [4, 16, 36, 64, 100, 144, 196]) == 2\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [25, 25, 25, 25, 25, 25]) == 0\n assert candidate(nums1 = [6, 10, 15],nums2 = [36, 100, 150, 225]) == 0\n assert candidate(nums1 = [13, 169, 2197, 28561, 371293, 4826809, 62748517, 815730721, 10604499373],nums2 = [169, 2197, 28561, 371293, 4826809, 62748517, 815730721, 10604499373, 13841287201]) == 28\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 13\n assert candidate(nums1 = [6, 12, 18, 24],nums2 = [36, 144, 324, 576, 864, 1152, 1440]) == 0\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18],nums2 = [9, 36, 81, 144, 225, 324, 441]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1]) == 220\n assert candidate(nums1 = [8, 9, 12, 15, 18],nums2 = [64, 81, 144, 225, 324]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [25, 100, 225, 400, 625]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30],nums2 = [25, 100, 225, 400, 625, 900]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [1, 9, 25, 49, 81]) == 4\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4],nums2 = [1, 1, 4, 4, 9, 9, 16, 16]) == 32\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12],nums2 = [4, 16, 36, 64, 100, 144, 256]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144]) == 13\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [4, 16, 36, 64, 100, 144, 196, 256, 324, 400]) == 5\n assert candidate(nums1 = [10, 100, 1000, 10000, 100000],nums2 = [100, 10000, 1000000, 100000000, 10000000000]) == 6\n assert candidate(nums1 = [12, 15, 20, 25, 30],nums2 = [144, 225, 400, 625, 900]) == 0\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [25, 25, 25, 25, 25]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n assert candidate(nums1 = [11, 11, 121, 1331, 14641],nums2 = [121, 1331, 14641, 161051, 1771561]) == 6\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3],nums2 = [9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n assert candidate(nums1 = [7, 49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607, 282475249],nums2 = [49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607, 282475249, 2004761894]) == 36\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 9, 25, 49, 81, 121, 169, 225, 289, 361]) == 10\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18],nums2 = [9, 36, 81, 144, 225, 324]) == 1\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36]) == 0\n assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],nums2 = [1, 1, 1, 4, 4, 4, 9, 9, 9, 16, 16, 16, 1]) == 156\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [1000000, 4000000, 9000000, 16000000, 25000000]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 400, 900, 1600, 2500, 3600, 4900, 6400, 8100, 10000, 12100, 14400, 16900, 19600, 22500]) == 0\n assert candidate(nums1 = [1, 2, 2, 4, 8, 16, 32],nums2 = [1, 1, 4, 4, 16, 16, 64]) == 33\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [4, 16, 36, 64, 100, 144, 196, 256, 324, 400]) == 5\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [100, 400, 900, 1600, 2500, 50, 250, 1250, 6250]) == 0\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [10000, 40000, 90000, 160000]) == 0\n assert candidate(nums1 = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],nums2 = [4, 9, 25, 49, 121, 169, 289, 361, 529, 841]) == 0\n assert candidate(nums1 = [7, 49, 343, 2401],nums2 = [49, 343, 2401, 16807]) == 4\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 325\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [25, 50, 75, 100, 125, 150]) == 0\n assert candidate(nums1 = [8, 15, 17, 20],nums2 = [64, 225, 289, 400, 676, 841]) == 0\n assert candidate(nums1 = [2, 4, 8, 16, 32, 64, 128, 256, 512],nums2 = [4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576]) == 24\n assert candidate(nums1 = [6, 6, 6, 6, 6],nums2 = [36, 36, 36, 36, 36]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11550\n assert candidate(nums1 = [7, 11, 13, 17, 19, 23, 29, 31, 37],nums2 = [49, 121, 169, 289, 361, 529, 841, 961, 1369, 1681]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225]) == 22\n assert candidate(nums1 = [2, 4, 8, 16, 32, 64],nums2 = [4, 16, 64, 256, 1024, 4096, 16384]) == 9\n assert candidate(nums1 = [10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [100, 225, 400, 625, 900, 1225, 1600, 2025, 2500]) == 0\n assert candidate(nums1 = [7, 24, 25, 30],nums2 = [49, 576, 625, 900, 1440, 1800]) == 0\n assert candidate(nums1 = [2, 3, 5, 7, 11, 13, 17],nums2 = [4, 9, 25, 49, 121, 169, 289]) == 0\n assert candidate(nums1 = [7, 11, 13, 17, 19],nums2 = [49, 121, 169, 289, 361, 529]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 900\n assert candidate(nums1 = [1, 3, 3, 3, 1],nums2 = [1, 9, 9, 1, 1, 9]) == 36\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [10000, 40000, 90000, 160000, 250000, 360000, 490000, 640000, 810000, 1000000]) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 0\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3],nums2 = [1, 1, 2, 2, 3, 3]) == 14\n assert candidate(nums1 = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],nums2 = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 563\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [1, 1, 1, 4, 4, 9]) == 27\n assert candidate(nums1 = [3, 9, 27, 81, 243],nums2 = [27, 81, 243, 729, 2187]) == 6\n assert candidate(nums1 = [31, 37, 41, 43, 47, 53, 59],nums2 = [961, 1369, 1681, 1849, 2209, 2809, 3481]) == 0\n assert candidate(nums1 = [2, 4, 8, 16, 32, 64, 128, 256],nums2 = [4, 16, 64, 256, 1024, 4096]) == 17\n assert candidate(nums1 = [2, 2, 2, 2],nums2 = [4, 4, 4, 4, 4]) == 0\n assert candidate(nums1 = [2, 4, 8, 16, 32, 64],nums2 = [4, 16, 64, 256, 1024, 4096]) == 9\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [25, 100, 225, 400, 625, 900, 1225, 1600, 2025, 2500]) == 1\n assert candidate(nums1 = [3, 5, 8, 12, 15, 17, 20],nums2 = [9, 25, 64, 144, 225, 289, 400]) == 1\n assert candidate(nums1 = [15, 20, 25, 30],nums2 = [225, 400, 625, 900, 1200, 1800]) == 0\n assert candidate(nums1 = [10, 10, 10],nums2 = [100, 100, 100, 100]) == 0\n assert candidate(nums1 = [7, 11, 13, 17, 19],nums2 = [49, 121, 169, 289, 361]) == 0\n assert candidate(nums1 = [6, 7, 8],nums2 = [36, 49, 64, 84, 112]) == 0\n assert candidate(nums1 = [2, 3, 5, 7, 11],nums2 = [4, 6, 9, 10, 14, 15, 21, 22, 30, 33, 35, 55, 77, 105]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [100, 400, 900, 1600, 2500]) == 0\n assert candidate(nums1 = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],nums2 = [121, 484, 1089, 1936, 3025, 4356, 5929, 7744, 9801, 12100, 14641, 17424, 20736, 24336, 28081]) == 0\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [100, 400, 900, 1600, 2500]) == 0\n assert candidate(nums1 = [6, 8, 10, 12, 14],nums2 = [36, 64, 100, 144, 196, 256]) == 0\n assert candidate(nums1 = [15, 25, 35, 45, 55],nums2 = [225, 625, 1225, 2025, 3025, 450, 750, 1050, 1350, 1650]) == 0\n assert candidate(nums1 = [100000, 99999, 99998, 99997, 99996],nums2 = [10000000000, 9999800001, 9999600004, 9999400009, 9999200016]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 351\n assert candidate(nums1 = [6, 8, 10, 12, 14],nums2 = [36, 64, 100, 144, 196, 48, 72, 96, 112, 120]) == 0\n assert candidate(nums1 = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],nums2 = [64, 256, 576, 1024, 1600, 2304, 3136, 4096, 5184, 6400]) == 0\n assert candidate(nums1 = [6, 10, 14, 18, 22, 26, 30],nums2 = [36, 100, 196, 324, 484, 676, 900]) == 0\n assert candidate(nums1 = [3, 5, 7, 11, 13],nums2 = [9, 25, 49, 121, 169, 289]) == 0\n assert candidate(nums1 = [7, 11, 13, 17, 19, 23, 29],nums2 = [49, 121, 169, 289, 361, 529, 841]) == 0\n assert candidate(nums1 = [5, 12, 13, 15],nums2 = [25, 144, 169, 225, 441]) == 0\n assert candidate(nums1 = [11, 13, 17, 19],nums2 = [121, 169, 289, 361, 441, 529]) == 0\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 4],nums2 = [1, 4, 4, 9, 9, 16]) == 12\n assert candidate(nums1 = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],nums2 = [4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576]) == 30\n assert candidate(nums1 = [7, 11, 13, 17, 19],nums2 = [49, 121, 169, 289, 361, 441]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().numTriplets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numTriplets(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "numTriplets", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1578, "task_id": "minimum-time-to-make-rope-colorful", "difficulty": "Medium", "problem_description": "Alice has n balloons arranged on a rope. You are given a 0-indexed string colors where colors[i] is the color of the ith balloon.\nAlice wants the rope to be colorful. She does not want two consecutive balloons to be of the same color, so she asks Bob for help. Bob can remove some balloons from the rope to make it colorful. You are given a 0-indexed integer array neededTime where neededTime[i] is the time (in seconds) that Bob needs to remove the ith balloon from the rope.\nReturn the minimum time Bob needs to make the rope colorful.\n \nExample 1:\n\n\nInput: colors = \"abaac\", neededTime = [1,2,3,4,5]\nOutput: 3\nExplanation: In the above image, 'a' is blue, 'b' is red, and 'c' is green.\nBob can remove the blue balloon at index 2. This takes 3 seconds.\nThere are no longer two consecutive balloons of the same color. Total time = 3.\nExample 2:\n\n\nInput: colors = \"abc\", neededTime = [1,2,3]\nOutput: 0\nExplanation: The rope is already colorful. Bob does not need to remove any balloons from the rope.\n\nExample 3:\n\n\nInput: colors = \"aabaa\", neededTime = [1,2,3,4,1]\nOutput: 2\nExplanation: Bob will remove the balloons at indices 0 and 4. Each balloons takes 1 second to remove.\nThere are no longer two consecutive balloons of the same color. Total time = 1 + 1 = 2.\n\n \nConstraints:\n\nn == colors.length == neededTime.length\n1 <= n <= 105\n1 <= neededTime[i] <= 104\ncolors contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(colors = \"abcabc\",neededTime = [1, 2, 3, 1, 2, 3]) == 0\n assert candidate(colors = \"aaaaa\",neededTime = [5, 4, 3, 2, 1]) == 10\n assert candidate(colors = \"abacabadabacaba\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(colors = \"aabaa\",neededTime = [1, 2, 3, 4, 1]) == 2\n assert candidate(colors = \"zzzz\",neededTime = [1, 1, 1, 1]) == 3\n assert candidate(colors = \"aaaa\",neededTime = [10, 5, 4, 2]) == 11\n assert candidate(colors = \"abcdef\",neededTime = [1, 1, 1, 1, 1, 1]) == 0\n assert candidate(colors = \"abaac\",neededTime = [1, 2, 3, 4, 5]) == 3\n assert candidate(colors = \"abc\",neededTime = [1, 2, 3]) == 0\n assert candidate(colors = \"abcdefg\",neededTime = [1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(colors = \"aaabbb\",neededTime = [1, 2, 3, 4, 5, 6]) == 12\n assert candidate(colors = \"aabbcc\",neededTime = [1, 2, 3, 1, 2, 3]) == 4\n assert candidate(colors = \"abcd\",neededTime = [4, 3, 2, 1]) == 0\n assert candidate(colors = \"bbbaaa\",neededTime = [4, 9, 3, 8, 8, 9]) == 23\n assert candidate(colors = \"ababab\",neededTime = [1, 2, 3, 4, 5, 6]) == 0\n assert candidate(colors = \"a\",neededTime = [5]) == 0\n assert candidate(colors = \"aabab\",neededTime = [3, 5, 10, 7, 5]) == 3\n assert candidate(colors = \"aaabbb\",neededTime = [3, 5, 10, 7, 5, 3]) == 16\n assert candidate(colors = \"a\",neededTime = [1]) == 0\n assert candidate(colors = \"zzzz\",neededTime = [10, 1, 1, 100]) == 12\n assert candidate(colors = \"abcabcabcabc\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 0\n assert candidate(colors = \"ababababab\",neededTime = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 0\n assert candidate(colors = \"aaaaaaaaaabbbbbbbbbb\",neededTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 18\n assert candidate(colors = \"aaabbbcccdddeee\",neededTime = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 30\n assert candidate(colors = \"aaabaaaabaaaaaaaabaa\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 28\n assert candidate(colors = \"ababaababaaba\",neededTime = [1, 3, 5, 2, 4, 6, 3, 5, 7, 4, 6, 8, 5]) == 8\n assert candidate(colors = \"aabbaa\",neededTime = [1, 2, 3, 4, 5, 6]) == 9\n assert candidate(colors = \"aaaabbbbccccdddd\",neededTime = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 30\n assert candidate(colors = \"abacabadabacabadabacabadabacabadabacabad\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(colors = \"aabaaabbaaaabaaa\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 76\n assert candidate(colors = \"aaaabbbbcccc\",neededTime = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 18\n assert candidate(colors = \"abababababab\",neededTime = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4]) == 0\n assert candidate(colors = \"aabbccddeeff\",neededTime = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 9\n assert candidate(colors = \"aabccbaa\",neededTime = [3, 5, 10, 7, 5, 3, 5, 3]) == 11\n assert candidate(colors = \"aabbccddeeffgg\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 49\n assert candidate(colors = \"aaaaaaaaaa\",neededTime = [1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000]) == 12222\n assert candidate(colors = \"zzzzzzzzzz\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(colors = \"bbbaaabbb\",neededTime = [10, 1, 1, 1, 10, 10, 1, 1, 10]) == 15\n assert candidate(colors = \"xyzzzyx\",neededTime = [1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(colors = \"aaaaaaaaaaaa\",neededTime = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989]) == 109934\n assert candidate(colors = \"aabbbaaabbbaaa\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 65\n assert candidate(colors = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 0\n assert candidate(colors = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 180\n assert candidate(colors = \"abccbaabccba\",neededTime = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == 7\n assert candidate(colors = \"aabbaa\",neededTime = [10, 5, 1, 1, 5, 10]) == 11\n assert candidate(colors = \"abcabcabc\",neededTime = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(colors = \"abcdefghij\",neededTime = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 0\n assert candidate(colors = \"aabbccddeeffgghhiijjkk\",neededTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(colors = \"abcabcabcabc\",neededTime = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 0\n assert candidate(colors = \"aaabbbcccddd\",neededTime = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 20\n assert candidate(colors = \"aaaabbbb\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8]) == 24\n assert candidate(colors = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 676\n assert candidate(colors = \"abababababababababab\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(colors = \"aabccbaabccbaabc\",neededTime = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 13\n assert candidate(colors = \"abcabcabcabcabcabcabc\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 0\n assert candidate(colors = \"abababababababababab\",neededTime = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 4, 6, 3, 7, 2, 8, 1, 9, 1, 9]) == 0\n assert candidate(colors = \"aabaaaaba\",neededTime = [1, 2, 1, 1, 1, 1, 1, 2, 1]) == 4\n assert candidate(colors = \"ababababab\",neededTime = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4]) == 0\n assert candidate(colors = \"aabbaa\",neededTime = [10, 1, 10, 2, 10, 3]) == 6\n assert candidate(colors = \"abcabcabcabc\",neededTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3]) == 0\n assert candidate(colors = \"ababaababa\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(colors = \"abcabcabcabcabcabc\",neededTime = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(colors = \"aaaabbbbccccdddd\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 24\n assert candidate(colors = \"aabbccddeeffgg\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 49\n assert candidate(colors = \"aabbccddeeffgg\",neededTime = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 33\n assert candidate(colors = \"aaaaaaaaaabbbbbbbbbb\",neededTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 18\n assert candidate(colors = \"aabbaabbcc\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(colors = \"aaabaaaaba\",neededTime = [5, 5, 5, 1, 1, 5, 5, 1, 1, 5]) == 17\n assert candidate(colors = \"zzzzzzzzz\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 36\n assert candidate(colors = \"abcdabcde\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4, 5]) == 0\n assert candidate(colors = \"abcdefghijklmnopqrstuvwxyz\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == 0\n assert candidate(colors = \"aaabaaaabaaab\",neededTime = [3, 2, 1, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 11\n assert candidate(colors = \"abcdeffedcba\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(colors = \"aabbaaabbbaaa\",neededTime = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1]) == 9\n assert candidate(colors = \"zzzzzzzzzz\",neededTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(colors = \"abcabcabcabc\",neededTime = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30]) == 0\n assert candidate(colors = \"ababababab\",neededTime = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 0\n assert candidate(colors = \"abababababab\",neededTime = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10, 6, 1]) == 0\n assert candidate(colors = \"abcabcabcabcabcabcabcabcabcabc\",neededTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(colors = \"aabbbcccaabbcc\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 54\n assert candidate(colors = \"aabbaabbaabb\",neededTime = [10, 20, 30, 40, 10, 20, 30, 40, 10, 20, 30, 40]) == 120\n assert candidate(colors = \"aabbccddeeff\",neededTime = [10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(colors = \"abcabcabcabc\",neededTime = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 0\n assert candidate(colors = \"zzzzz\",neededTime = [1, 2, 3, 4, 5]) == 10\n assert candidate(colors = \"aabbccddeeffgg\",neededTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(colors = \"zzzzzzzzzz\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(colors = \"aabacbacba\",neededTime = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(colors = \"abcdabcda\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4, 1]) == 0\n assert candidate(colors = \"aabbccddeeff\",neededTime = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 6\n assert candidate(colors = \"aaaabbbb\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4]) == 12\n assert candidate(colors = \"abcdefghij\",neededTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n"}, "metadata": {"canonical_parameter_names": ["colors", "neededTime"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minCost(self, colors: str, neededTime: list[int]) -> int:", "container": "Solution", "callable": "minCost", "parameters": [{"name": "colors", "type": "str"}, {"name": "neededTime", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1579, "task_id": "remove-max-number-of-edges-to-keep-graph-fully-traversable", "difficulty": "Hard", "problem_description": "Alice and Bob have an undirected graph of n nodes and three types of edges:\n\nType 1: Can be traversed by Alice only.\nType 2: Can be traversed by Bob only.\nType 3: Can be traversed by both Alice and Bob.\n\nGiven an array edges where edges[i] = [typei, ui, vi] represents a bidirectional edge of type typei between nodes ui and vi, find the maximum number of edges you can remove so that after removing the edges, the graph can still be fully traversed by both Alice and Bob. The graph is fully traversed by Alice and Bob if starting from any node, they can reach all other nodes.\nReturn the maximum number of edges you can remove, or return -1 if Alice and Bob cannot fully traverse the graph.\n \nExample 1:\n\n\nInput: n = 4, edges = [[3,1,2],[3,2,3],[1,1,3],[1,2,4],[1,1,2],[2,3,4]]\nOutput: 2\nExplanation: If we remove the 2 edges [1,1,2] and [1,1,3]. The graph will still be fully traversable by Alice and Bob. Removing any additional edge will not make it so. So the maximum number of edges we can remove is 2.\n\nExample 2:\n\n\nInput: n = 4, edges = [[3,1,2],[3,2,3],[1,1,4],[2,1,4]]\nOutput: 0\nExplanation: Notice that removing any edge will not make the graph fully traversable by Alice and Bob.\n\nExample 3:\n\n\nInput: n = 4, edges = [[3,2,3],[1,1,2],[2,3,4]]\nOutput: -1\nExplanation: In the current graph, Alice cannot reach node 4 from the other nodes. Likewise, Bob cannot reach 1. Therefore it's impossible to make the graph fully traversable.\n \n \nConstraints:\n\n1 <= n <= 105\n1 <= edges.length <= min(105, 3 * n * (n - 1) / 2)\nedges[i].length == 3\n1 <= typei <= 3\n1 <= ui < vi <= n\nAll tuples (typei, ui, vi) are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,edges = [[1, 1, 2], [2, 2, 3], [3, 3, 4], [3, 4, 5], [1, 2, 3], [2, 3, 4]]) == -1\n assert candidate(n = 4,edges = [[3, 1, 2], [3, 2, 3], [1, 1, 3], [1, 2, 4], [1, 1, 2], [2, 3, 4]]) == 2\n assert candidate(n = 4,edges = [[3, 1, 2], [3, 2, 3], [1, 1, 4], [2, 1, 4]]) == 0\n assert candidate(n = 5,edges = [[3, 1, 2], [3, 2, 3], [3, 4, 5], [1, 1, 3], [1, 1, 4], [2, 3, 5]]) == 1\n assert candidate(n = 3,edges = [[1, 1, 2], [2, 1, 2], [3, 2, 3]]) == 0\n assert candidate(n = 4,edges = [[3, 2, 3], [1, 1, 2], [2, 3, 4]]) == -1\n assert candidate(n = 6,edges = [[1, 1, 2], [1, 2, 3], [2, 3, 4], [2, 4, 5], [3, 5, 6]]) == -1\n assert candidate(n = 3,edges = [[3, 1, 2], [1, 1, 3], [2, 2, 3]]) == 0\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 1, 5], [1, 5, 6], [1, 6, 7], [2, 4, 5], [2, 5, 8], [3, 7, 8], [1, 2, 8], [2, 3, 7]]) == -1\n assert candidate(n = 20,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [3, 15, 16], [3, 16, 17], [3, 17, 18], [3, 18, 19], [3, 19, 20], [1, 1, 20], [2, 2, 19], [1, 3, 18], [2, 4, 17], [1, 5, 16], [2, 6, 15], [1, 7, 14], [2, 8, 13], [1, 9, 12], [2, 10, 11]]) == 10\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 5, 6], [1, 6, 7], [2, 5, 7], [1, 1, 4], [2, 1, 2]]) == -1\n assert candidate(n = 15,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [1, 1, 15], [2, 2, 14], [1, 3, 13], [2, 4, 12], [1, 5, 11], [2, 6, 10], [1, 7, 9], [2, 8, 9]]) == 8\n assert candidate(n = 15,edges = [[3, 1, 2], [1, 2, 3], [2, 3, 4], [1, 4, 5], [2, 5, 6], [1, 6, 7], [2, 7, 8], [3, 8, 1], [3, 1, 3], [3, 2, 4], [3, 4, 6], [3, 5, 7], [1, 9, 10], [2, 10, 11], [3, 11, 12], [1, 12, 13], [2, 13, 14], [3, 14, 15], [1, 15, 1]]) == -1\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [1, 1, 12], [2, 1, 12], [1, 2, 3], [2, 3, 2], [1, 4, 5], [2, 5, 4], [1, 6, 7], [2, 7, 6], [1, 8, 9], [2, 9, 8]]) == 10\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [1, 1, 3], [1, 2, 4], [1, 4, 5], [2, 3, 4], [2, 5, 6], [3, 1, 4]]) == -1\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 6], [2, 1, 6]]) == 2\n assert candidate(n = 20,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [3, 15, 16], [3, 16, 17], [3, 17, 18], [3, 18, 19], [3, 19, 20], [1, 1, 6], [2, 6, 12], [1, 5, 7], [2, 5, 8], [1, 3, 9], [3, 2, 10], [1, 4, 11], [2, 7, 13], [3, 8, 14], [1, 9, 15], [2, 10, 14], [1, 11, 16], [2, 12, 17], [1, 13, 18], [2, 14, 19], [1, 15, 20], [2, 16, 18], [3, 17, 19]]) == 18\n assert candidate(n = 8,edges = [[3, 1, 2], [1, 1, 3], [2, 2, 3], [3, 3, 4], [1, 3, 4], [2, 3, 4], [3, 4, 5], [1, 4, 5], [2, 4, 5], [3, 5, 6], [1, 5, 6], [2, 5, 6], [3, 6, 7], [1, 6, 7], [2, 6, 7], [3, 7, 8], [1, 7, 8], [2, 7, 8], [1, 1, 8], [2, 1, 8]]) == 12\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 1, 4], [2, 4, 5], [1, 5, 6], [2, 6, 7], [1, 7, 8], [2, 1, 8], [1, 2, 5], [2, 3, 6], [1, 4, 7], [2, 5, 8]]) == 2\n assert candidate(n = 8,edges = [[1, 1, 2], [2, 2, 3], [1, 3, 4], [2, 4, 5], [1, 5, 6], [2, 6, 7], [1, 7, 8], [2, 8, 1], [3, 1, 5], [3, 2, 6], [3, 3, 7], [3, 4, 8]]) == -1\n assert candidate(n = 15,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [1, 1, 8], [1, 8, 15], [2, 2, 9], [2, 9, 14]]) == 4\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 2], [1, 3, 4], [1, 5, 6], [2, 2, 3], [2, 4, 5]]) == 5\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 4, 5], [1, 5, 6], [2, 6, 7], [2, 7, 8], [1, 8, 9], [2, 1, 2], [2, 1, 3], [1, 1, 9]]) == -1\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 6], [1, 6, 7], [2, 2, 4], [2, 4, 6], [2, 5, 7], [1, 2, 5], [2, 1, 3], [3, 1, 7]]) == 5\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 2], [1, 3, 4], [1, 5, 6], [1, 7, 8], [1, 9, 10], [2, 2, 3], [2, 4, 5], [2, 6, 7], [2, 8, 9]]) == 9\n assert candidate(n = 20,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [3, 15, 16], [3, 16, 17], [3, 17, 18], [3, 18, 19], [3, 19, 20], [1, 1, 20], [2, 20, 1], [1, 2, 3], [2, 3, 2], [1, 4, 5], [2, 5, 4], [1, 6, 7], [2, 7, 6], [1, 8, 9], [2, 9, 8], [1, 10, 11], [2, 11, 10], [1, 12, 13], [2, 13, 12], [1, 14, 15], [2, 15, 14], [1, 16, 17], [2, 17, 16], [1, 18, 19], [2, 19, 18]]) == 20\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 7], [1, 7, 8], [1, 8, 9], [2, 2, 5], [2, 5, 8], [2, 3, 6], [3, 1, 6], [1, 2, 8], [2, 3, 7]]) == -1\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [1, 1, 4], [1, 4, 7], [1, 7, 9], [2, 2, 5], [2, 5, 8]]) == 5\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [1, 1, 6], [1, 6, 11], [2, 2, 7], [2, 7, 12]]) == 4\n assert candidate(n = 6,edges = [[1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [3, 1, 3], [3, 2, 4], [3, 3, 5], [3, 4, 6]]) == 8\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [1, 8, 9], [1, 9, 10], [1, 10, 11], [1, 11, 12], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9], [2, 9, 10], [2, 10, 11], [2, 11, 12]]) == 22\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 7], [1, 7, 8], [1, 8, 9], [1, 9, 10], [2, 1, 10], [2, 2, 5], [2, 3, 6], [2, 4, 7]]) == -1\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [1, 7, 8], [1, 8, 9], [2, 9, 10], [1, 1, 10], [2, 1, 5], [1, 2, 3]]) == -1\n assert candidate(n = 11,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [1, 8, 9], [1, 9, 10], [1, 10, 11], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9], [2, 9, 10], [2, 10, 11]]) == 20\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 3], [2, 3, 5], [1, 5, 7], [2, 7, 9], [1, 2, 4], [2, 4, 6], [1, 6, 8], [2, 8, 10]]) == 8\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [1, 1, 2], [1, 3, 4], [1, 5, 6], [2, 2, 3], [2, 4, 5], [2, 6, 7], [1, 1, 7], [2, 2, 7]]) == 8\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [1, 1, 4], [1, 4, 5], [2, 2, 4], [2, 4, 6], [3, 3, 5], [3, 5, 6], [1, 1, 6], [2, 1, 2]]) == 4\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 4], [1, 4, 7], [1, 7, 10], [2, 2, 5], [2, 5, 8], [2, 8, 10]]) == 6\n assert candidate(n = 11,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [1, 1, 11], [2, 2, 10], [1, 3, 9], [2, 4, 8], [1, 5, 7], [2, 6, 6], [1, 7, 5], [2, 8, 4], [1, 9, 3], [2, 10, 2], [1, 11, 1]]) == 11\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [1, 8, 9], [1, 9, 10], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9], [2, 9, 10]]) == 18\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 6], [2, 6, 7], [1, 5, 7], [3, 2, 7]]) == 1\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [2, 2, 4], [2, 4, 6], [2, 6, 8]]) == -1\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6]]) == 10\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 1, 5], [1, 2, 6], [2, 4, 5], [2, 5, 6], [1, 3, 5], [2, 2, 4]]) == 2\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 1, 3], [1, 3, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9], [2, 9, 10], [2, 5, 7], [2, 7, 9]]) == -1\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [1, 1, 9], [2, 2, 8], [1, 3, 7], [2, 4, 6], [1, 5, 5], [2, 1, 3], [1, 2, 4], [2, 3, 6], [1, 4, 7], [2, 5, 8], [1, 6, 9]]) == 11\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 2], [2, 2, 3], [1, 3, 4], [2, 4, 5], [1, 5, 6], [2, 6, 7], [1, 7, 8], [2, 8, 9], [1, 9, 10], [1, 1, 10]]) == 10\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [1, 1, 4], [2, 2, 5], [1, 2, 3], [2, 3, 4], [1, 3, 6], [2, 4, 7], [1, 5, 6], [2, 5, 7], [1, 6, 7]]) == 9\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 5], [2, 5, 10]]) == 2\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 1, 5], [1, 5, 6], [1, 6, 7], [2, 4, 5], [2, 5, 8], [3, 7, 8], [1, 2, 8], [2, 3, 7], [1, 9, 10], [2, 10, 11], [3, 11, 12], [1, 1, 12], [2, 1, 11]]) == -1\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [1, 1, 3], [1, 2, 4], [1, 1, 2], [2, 3, 4], [3, 4, 5], [1, 5, 6], [2, 6, 7], [1, 7, 8], [2, 8, 9], [1, 9, 10], [2, 10, 1], [3, 1, 10]]) == -1\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 6], [2, 6, 7], [1, 5, 7], [2, 5, 8], [1, 3, 8], [3, 1, 5]]) == -1\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [1, 1, 6], [2, 6, 12], [1, 5, 7], [2, 5, 8], [1, 3, 9], [3, 2, 10]]) == 6\n assert candidate(n = 15,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [1, 1, 6], [2, 6, 12], [1, 5, 7], [2, 5, 8], [1, 3, 9], [3, 2, 10], [1, 4, 11], [2, 7, 13], [3, 8, 14], [1, 9, 15], [2, 10, 14]]) == 11\n assert candidate(n = 7,edges = [[1, 1, 2], [1, 2, 3], [1, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [3, 1, 7]]) == -1\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7]]) == 12\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [1, 8, 9], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9]]) == 16\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [1, 1, 2], [1, 3, 4], [1, 5, 6], [1, 7, 8], [2, 2, 3], [2, 4, 5], [2, 6, 7], [2, 8, 9], [1, 1, 9], [2, 2, 9]]) == 10\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 6, 7], [1, 7, 8], [2, 5, 7], [2, 6, 8], [1, 1, 3], [2, 1, 4]]) == 2\n assert candidate(n = 7,edges = [[1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [3, 1, 4], [3, 2, 5], [3, 3, 6], [3, 4, 7]]) == 8\n assert candidate(n = 8,edges = [[3, 1, 2], [1, 2, 3], [2, 3, 4], [1, 4, 5], [2, 5, 6], [1, 6, 7], [2, 7, 8], [3, 8, 1], [3, 1, 3], [3, 2, 4], [3, 4, 6], [3, 5, 7]]) == 4\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8]]) == 14\n assert candidate(n = 15,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [1, 1, 5], [2, 5, 9], [1, 9, 13], [2, 13, 15], [1, 2, 3], [2, 4, 6], [1, 6, 7], [2, 8, 10], [1, 10, 11], [2, 12, 14]]) == 10\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [1, 1, 3], [2, 3, 5], [1, 5, 7], [2, 7, 9], [1, 9, 11], [2, 1, 2], [1, 2, 4], [2, 4, 6], [1, 6, 8], [2, 8, 10], [1, 10, 12]]) == 11\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 3], [2, 2, 4], [1, 1, 2], [2, 3, 4], [1, 2, 5], [2, 4, 6]]) == 6\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().maxNumEdgesToRemove", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxNumEdgesToRemove(self, n: int, edges: list[list[int]]) -> int:", "container": "Solution", "callable": "maxNumEdgesToRemove", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1582, "task_id": "special-positions-in-a-binary-matrix", "difficulty": "Easy", "problem_description": "Given an m x n binary matrix mat, return the number of special positions in mat.\nA position (i, j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed).\n \nExample 1:\n\n\nInput: mat = [[1,0,0],[0,0,1],[1,0,0]]\nOutput: 1\nExplanation: (1, 2) is a special position because mat[1][2] == 1 and all other elements in row 1 and column 2 are 0.\n\nExample 2:\n\n\nInput: mat = [[1,0,0],[0,1,0],[0,0,1]]\nOutput: 3\nExplanation: (0, 0), (1, 1) and (2, 2) are special positions.\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n1 <= m, n <= 100\nmat[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 0], [0, 1]]) == 2\n assert candidate(mat = [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 0]]) == 2\n assert candidate(mat = [[1, 0, 0], [0, 0, 1], [1, 0, 0]]) == 1\n assert candidate(mat = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 3\n assert candidate(mat = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(mat = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == 3\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0]]) == 8\n assert candidate(mat = [[0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0]]) == 8\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0]]) == 1\n assert candidate(mat = [[1, 0, 1, 0], [0, 0, 0, 0], [1, 0, 1, 0], [0, 0, 0, 0]]) == 0\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [1, 0, 0, 0, 0]]) == 4\n assert candidate(mat = [[1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0]]) == 7\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0]]) == 2\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]]) == 5\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0]]) == 1\n assert candidate(mat = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0]]) == 3\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0]]) == 8\n assert candidate(mat = [[0, 1, 0, 0], [1, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0]]) == 1\n assert candidate(mat = [[0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0]]) == 6\n assert candidate(mat = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 0\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 5\n assert candidate(mat = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) == 4\n assert candidate(mat = [[0, 0, 1, 0, 0], [0, 0, 0, 0, 1], [1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0]]) == 5\n assert candidate(mat = [[0, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 0]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [0, 1, 0, 0, 0]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0]]) == 6\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == 5\n assert candidate(mat = [[0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 5\n assert candidate(mat = [[0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [1, 0, 0, 0, 1], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0]]) == 2\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]) == 4\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0]]) == 10\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 0\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1]]) == 7\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(mat = [[0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]]) == 5\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0]]) == 7\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0]]) == 6\n assert candidate(mat = [[1, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0]]) == 3\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == 1\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0, 0]]) == 7\n assert candidate(mat = [[0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [1, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 3\n assert candidate(mat = [[0, 0, 1, 0], [0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) == 3\n assert candidate(mat = [[1, 1, 0, 0], [0, 0, 0, 0], [1, 0, 1, 0], [0, 0, 0, 1]]) == 1\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == 2\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 1, 0, 0, 0]]) == 5\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 0\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0]]) == 2\n assert candidate(mat = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 0, 1]]) == 3\n assert candidate(mat = [[1, 0, 1, 0, 0], [0, 0, 0, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 0, 0], [0, 0, 1, 1, 0]]) == 1\n assert candidate(mat = [[0, 1, 1], [0, 0, 0], [1, 0, 0]]) == 1\n assert candidate(mat = [[1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1], [1, 1, 0, 0]]) == 0\n assert candidate(mat = [[0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 1], [0, 0, 1, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 1, 0]]) == 4\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 1], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0]]) == 5\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == 5\n"}, "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().numSpecial", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numSpecial(self, mat: list[list[int]]) -> int:", "container": "Solution", "callable": "numSpecial", "parameters": [{"name": "mat", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1583, "task_id": "count-unhappy-friends", "difficulty": "Medium", "problem_description": "You are given a list of preferences for n friends, where n is always even.\nFor each person i, preferences[i] contains a list of friends sorted in the order of preference. In other words, a friend earlier in the list is more preferred than a friend later in the list. Friends in each list are denoted by integers from 0 to n-1.\nAll the friends are divided into pairs. The pairings are given in a list pairs, where pairs[i] = [xi, yi] denotes xi is paired with yi and yi is paired with xi.\nHowever, this pairing may cause some of the friends to be unhappy. A friend x is unhappy if x is paired with y and there exists a friend u who is paired with v but:\n\nx prefers u over y, and\nu prefers x over v.\n\nReturn the number of unhappy friends.\n \nExample 1:\n\nInput: n = 4, preferences = [[1, 2, 3], [3, 2, 0], [3, 1, 0], [1, 2, 0]], pairs = [[0, 1], [2, 3]]\nOutput: 2\nExplanation:\nFriend 1 is unhappy because:\n- 1 is paired with 0 but prefers 3 over 0, and\n- 3 prefers 1 over 2.\nFriend 3 is unhappy because:\n- 3 is paired with 2 but prefers 1 over 2, and\n- 1 prefers 3 over 0.\nFriends 0 and 2 are happy.\n\nExample 2:\n\nInput: n = 2, preferences = [[1], [0]], pairs = [[1, 0]]\nOutput: 0\nExplanation: Both friends 0 and 1 are happy.\n\nExample 3:\n\nInput: n = 4, preferences = [[1, 3, 2], [2, 3, 0], [1, 3, 0], [0, 2, 1]], pairs = [[1, 3], [0, 2]]\nOutput: 4\n\n \nConstraints:\n\n2 <= n <= 500\nn is even.\npreferences.length == n\npreferences[i].length == n - 1\n0 <= preferences[i][j] <= n - 1\npreferences[i] does not contain i.\nAll values in preferences[i] are unique.\npairs.length == n/2\npairs[i].length == 2\nxi != yi\n0 <= xi, yi <= n - 1\nEach person is contained in exactly one pair.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,preferences = [[1, 3, 2], [2, 3, 0], [1, 3, 0], [0, 2, 1]],pairs = [[1, 3], [0, 2]]) == 4\n assert candidate(n = 8,preferences = [[7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0]],pairs = [[0, 7], [1, 6], [2, 5], [3, 4]]) == 7\n assert candidate(n = 8,preferences = [[3, 2, 5, 4, 7, 6, 0, 1], [6, 7, 0, 1, 5, 4, 2, 3], [4, 5, 6, 7, 1, 0, 2, 3], [5, 4, 3, 2, 7, 6, 1, 0], [2, 3, 0, 1, 6, 7, 4, 5], [3, 2, 1, 0, 6, 7, 4, 5], [7, 6, 5, 4, 1, 0, 2, 3], [6, 7, 4, 5, 2, 3, 0, 1]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7]]) == 5\n assert candidate(n = 6,preferences = [[1, 3, 5, 2, 4, 0], [0, 2, 4, 1, 3, 5], [1, 0, 3, 4, 5, 2], [2, 5, 4, 0, 3, 1], [5, 0, 1, 3, 2, 4], [3, 1, 4, 0, 2, 5]],pairs = [[1, 3], [2, 4], [0, 5]]) == 6\n assert candidate(n = 4,preferences = [[1, 2, 3], [3, 2, 0], [3, 1, 0], [1, 2, 0]],pairs = [[0, 1], [2, 3]]) == 2\n assert candidate(n = 2,preferences = [[1], [0]],pairs = [[1, 0]]) == 0\n assert candidate(n = 14,preferences = [[13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 10, 12, 1, 3, 5, 7, 9, 11, 13], [1, 3, 5, 7, 9, 11, 13, 0, 2, 4, 6, 8, 10, 12], [2, 4, 6, 8, 10, 12, 0, 1, 3, 5, 7, 9, 11, 13], [3, 5, 7, 9, 11, 13, 1, 2, 4, 6, 8, 10, 12, 0], [4, 6, 8, 10, 12, 0, 1, 2, 3, 5, 7, 9, 11, 13], [5, 7, 9, 11, 13, 1, 2, 3, 4, 6, 8, 10, 12, 0], [6, 8, 10, 12, 0, 1, 2, 3, 4, 5, 7, 9, 11, 13], [7, 9, 11, 13, 1, 2, 3, 4, 5, 6, 8, 10, 12, 0], [8, 10, 12, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13], [9, 11, 13, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 0], [10, 12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13], [11, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 0], [12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13]],pairs = [[0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == 12\n assert candidate(n = 10,preferences = [[1, 9, 7, 8, 4, 3, 6, 5, 2, 0], [0, 7, 8, 9, 3, 4, 6, 5, 2, 1], [9, 8, 1, 0, 5, 6, 7, 4, 3, 2], [6, 4, 5, 0, 1, 2, 3, 7, 8, 9], [7, 6, 0, 1, 2, 3, 4, 8, 9, 5], [1, 0, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 0, 1, 4, 5, 6, 7, 8, 9], [3, 2, 0, 1, 4, 5, 6, 7, 8, 9], [4, 3, 0, 1, 2, 5, 6, 7, 8, 9], [5, 4, 0, 1, 2, 3, 6, 7, 8, 9]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 8\n assert candidate(n = 12,preferences = [[11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11], [1, 3, 5, 7, 9, 11, 0, 2, 4, 6, 8, 10], [2, 4, 6, 8, 10, 0, 1, 3, 5, 7, 9, 11], [3, 5, 7, 9, 11, 1, 2, 4, 6, 8, 10, 0], [4, 6, 8, 10, 0, 2, 3, 5, 7, 9, 11, 1], [5, 7, 9, 11, 1, 3, 4, 6, 8, 10, 0, 2], [6, 8, 10, 0, 2, 4, 5, 7, 9, 11, 1, 3], [7, 9, 11, 1, 3, 5, 6, 8, 10, 0, 2, 4], [8, 10, 0, 2, 4, 6, 7, 9, 11, 1, 3, 5], [9, 11, 1, 3, 5, 7, 8, 10, 0, 2, 4, 6], [10, 0, 2, 4, 6, 8, 9, 11, 1, 3, 5, 7]],pairs = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 10\n assert candidate(n = 10,preferences = [[1, 3, 5, 7, 9, 2, 4, 6, 8, 0], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9], [1, 3, 5, 7, 9, 2, 4, 6, 8, 0], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9], [1, 3, 5, 7, 9, 2, 4, 6, 8, 0], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 5\n assert candidate(n = 6,preferences = [[5, 4, 2, 3, 0, 1], [4, 5, 1, 0, 3, 2], [2, 4, 5, 0, 1, 3], [3, 2, 0, 5, 4, 1], [0, 1, 2, 3, 4, 5], [1, 0, 3, 2, 5, 4]],pairs = [[0, 1], [2, 3], [4, 5]]) == 6\n assert candidate(n = 6,preferences = [[5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5], [1, 0, 3, 2, 5, 4], [4, 5, 2, 3, 0, 1], [2, 3, 0, 1, 4, 5], [5, 4, 1, 0, 3, 2]],pairs = [[0, 1], [2, 3], [4, 5]]) == 5\n assert candidate(n = 6,preferences = [[2, 3, 5, 1, 4, 0], [3, 5, 1, 4, 0, 2], [5, 1, 4, 0, 2, 3], [1, 4, 0, 2, 3, 5], [4, 0, 2, 3, 5, 1], [0, 2, 3, 5, 1, 4]],pairs = [[0, 3], [1, 4], [2, 5]]) == 3\n assert candidate(n = 14,preferences = [[2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13]]) == 7\n assert candidate(n = 8,preferences = [[1, 4, 7, 2, 5, 0, 6, 3], [4, 7, 2, 5, 0, 6, 3, 1], [2, 5, 0, 6, 3, 1, 4, 7], [5, 0, 6, 3, 1, 4, 7, 2], [0, 6, 3, 1, 4, 7, 2, 5], [6, 3, 1, 4, 7, 2, 5, 0], [3, 1, 4, 7, 2, 5, 0, 6], [1, 4, 7, 2, 5, 0, 6, 3]],pairs = [[0, 2], [1, 3], [4, 6], [5, 7]]) == 8\n assert candidate(n = 6,preferences = [[4, 5, 1, 0, 2, 3], [1, 3, 0, 2, 5, 4], [2, 0, 3, 1, 4, 5], [3, 4, 1, 0, 5, 2], [5, 3, 0, 1, 4, 2], [4, 1, 3, 2, 5, 0]],pairs = [[0, 3], [1, 4], [2, 5]]) == 6\n assert candidate(n = 10,preferences = [[3, 5, 2, 7, 6, 4, 1, 9, 8, 0], [2, 4, 6, 1, 0, 3, 5, 9, 8, 7], [5, 3, 7, 2, 8, 1, 0, 6, 9, 4], [7, 8, 4, 5, 3, 9, 2, 0, 6, 1], [9, 4, 5, 7, 8, 0, 3, 1, 2, 6], [6, 0, 8, 9, 4, 2, 5, 3, 1, 7], [8, 6, 4, 3, 1, 5, 9, 2, 7, 0], [4, 7, 2, 1, 8, 0, 5, 9, 3, 6], [0, 8, 1, 6, 7, 9, 4, 2, 5, 3], [1, 9, 6, 5, 3, 2, 4, 8, 0, 7]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 9\n assert candidate(n = 10,preferences = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 9, 7, 6, 5, 4, 3, 2, 1, 0], [7, 8, 9, 6, 5, 4, 3, 2, 1, 0], [6, 7, 8, 9, 5, 4, 3, 2, 1, 0], [5, 6, 7, 8, 9, 4, 3, 2, 1, 0], [4, 5, 6, 7, 8, 9, 3, 2, 1, 0], [3, 4, 5, 6, 7, 8, 9, 2, 1, 0], [2, 3, 4, 5, 6, 7, 8, 9, 1, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 8\n assert candidate(n = 10,preferences = [[7, 6, 5, 4, 3, 2, 1, 0, 9, 8], [6, 7, 0, 1, 2, 3, 4, 5, 8, 9], [5, 6, 7, 0, 1, 2, 3, 4, 9, 8], [4, 5, 6, 7, 0, 1, 2, 3, 8, 9], [3, 4, 5, 6, 7, 0, 1, 2, 9, 8], [2, 3, 4, 5, 6, 7, 0, 1, 8, 9], [1, 2, 3, 4, 5, 6, 7, 0, 9, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 0, 1, 2, 3, 4, 5, 6, 7], [8, 9, 0, 1, 2, 3, 4, 5, 6, 7]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 8\n assert candidate(n = 12,preferences = [[1, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8, 0], [0, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8, 1], [1, 0, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8], [0, 1, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8], [5, 9, 2, 6, 10, 3, 7, 11, 4, 8, 0, 1], [9, 2, 6, 10, 3, 7, 11, 4, 8, 0, 1, 5], [2, 6, 10, 3, 7, 11, 4, 8, 0, 1, 5, 9], [6, 10, 3, 7, 11, 4, 8, 0, 1, 5, 9, 2], [3, 7, 11, 4, 8, 0, 1, 5, 9, 2, 6, 10], [7, 11, 4, 8, 0, 1, 5, 9, 2, 6, 10, 3], [4, 8, 0, 1, 5, 9, 2, 6, 10, 3, 7, 11], [8, 0, 1, 5, 9, 2, 6, 10, 3, 7, 11, 4]],pairs = [[0, 4], [1, 5], [2, 6], [3, 7], [8, 11], [9, 10]]) == 8\n assert candidate(n = 12,preferences = [[5, 6, 7, 8, 9, 10, 11, 3, 2, 1, 0, 4], [6, 7, 8, 9, 10, 11, 0, 4, 3, 2, 1, 5], [7, 8, 9, 10, 11, 1, 0, 4, 3, 2, 5, 6], [8, 9, 10, 11, 2, 1, 0, 4, 3, 5, 6, 7], [9, 10, 11, 3, 2, 1, 0, 4, 5, 6, 7, 8], [10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2], [4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3]],pairs = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11]]) == 12\n assert candidate(n = 12,preferences = [[11, 9, 5, 7, 3, 1, 4, 6, 8, 10, 0, 2], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [2, 1, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 2, 1, 0, 4, 5, 6, 7, 8, 9, 10, 11], [4, 3, 2, 1, 0, 5, 6, 7, 8, 9, 10, 11], [5, 4, 3, 2, 1, 0, 6, 7, 8, 9, 10, 11], [6, 5, 4, 3, 2, 1, 0, 7, 8, 9, 10, 11], [7, 6, 5, 4, 3, 2, 1, 0, 8, 9, 10, 11], [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 10, 11], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 11], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11]],pairs = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [10, 11]]) == 9\n assert candidate(n = 8,preferences = [[5, 6, 7, 4, 3, 2, 1, 0], [6, 5, 7, 4, 3, 2, 1, 0], [7, 5, 6, 4, 3, 2, 1, 0], [0, 5, 6, 7, 3, 2, 1, 4], [1, 5, 6, 7, 4, 3, 2, 0], [2, 0, 6, 7, 4, 3, 1, 5], [3, 0, 1, 7, 4, 6, 2, 5], [4, 0, 1, 2, 3, 6, 7, 5]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7]]) == 8\n assert candidate(n = 10,preferences = [[3, 9, 4, 5, 6, 7, 8, 1, 0, 2], [8, 7, 6, 5, 4, 3, 2, 1, 0, 9], [5, 4, 3, 2, 1, 0, 9, 8, 7, 6], [4, 5, 6, 7, 8, 9, 0, 1, 2, 3], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [2, 1, 0, 9, 8, 7, 6, 5, 4, 3], [6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [7, 6, 5, 4, 3, 2, 1, 0, 9, 8], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 9\n assert candidate(n = 6,preferences = [[1, 2, 3, 4, 5], [0, 3, 2, 5, 4], [1, 4, 0, 5, 3], [0, 5, 2, 4, 1], [1, 2, 0, 3, 5], [0, 1, 2, 3, 4]],pairs = [[0, 1], [2, 3], [4, 5]]) == 4\n assert candidate(n = 10,preferences = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, 9], [7, 6, 5, 4, 3, 2, 1, 0, 9, 8], [6, 5, 4, 3, 2, 1, 0, 9, 8, 7], [5, 4, 3, 2, 1, 0, 9, 8, 7, 6], [4, 3, 2, 1, 0, 9, 8, 7, 6, 5], [3, 2, 1, 0, 9, 8, 7, 6, 5, 4], [2, 1, 0, 9, 8, 7, 6, 5, 4, 3], [1, 0, 9, 8, 7, 6, 5, 4, 3, 2], [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 8\n assert candidate(n = 6,preferences = [[1, 3, 5, 0, 4, 2], [2, 5, 4, 1, 0, 3], [4, 0, 5, 2, 3, 1], [5, 1, 4, 3, 0, 2], [0, 3, 2, 5, 1, 4], [3, 0, 1, 4, 2, 5]],pairs = [[0, 1], [2, 3], [4, 5]]) == 5\n assert candidate(n = 6,preferences = [[1, 3, 4, 0, 5, 2], [3, 4, 5, 1, 0, 2], [4, 5, 3, 2, 1, 0], [5, 4, 3, 2, 0, 1], [4, 3, 2, 1, 5, 0], [5, 4, 3, 2, 1, 0]],pairs = [[0, 2], [1, 4], [3, 5]]) == 4\n assert candidate(n = 10,preferences = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9], [1, 3, 5, 7, 9, 0, 2, 4, 6, 8], [2, 4, 6, 8, 0, 1, 3, 5, 7, 9], [3, 5, 7, 9, 1, 2, 4, 6, 8, 0], [4, 6, 8, 0, 2, 3, 5, 7, 9, 1], [5, 7, 9, 1, 3, 4, 6, 8, 0, 2], [6, 8, 0, 2, 4, 5, 7, 9, 1, 3], [7, 9, 1, 3, 5, 6, 8, 0, 2, 4], [8, 0, 2, 4, 6, 7, 9, 1, 3, 5]],pairs = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 8\n assert candidate(n = 10,preferences = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 9, 7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 9, 8, 5, 4, 3, 2, 1, 0], [6, 7, 8, 9, 5, 4, 3, 2, 1, 0], [5, 4, 3, 2, 9, 8, 7, 6, 1, 0], [4, 5, 3, 2, 8, 9, 7, 6, 1, 0], [3, 2, 1, 0, 9, 8, 7, 6, 5, 4], [2, 3, 1, 0, 8, 9, 7, 6, 5, 4], [1, 0, 2, 3, 8, 9, 7, 6, 5, 4], [0, 1, 2, 3, 9, 8, 7, 6, 5, 4]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 8\n assert candidate(n = 6,preferences = [[1, 2, 3, 4, 5], [0, 2, 3, 4, 1], [1, 0, 3, 5, 4], [2, 1, 0, 5, 4], [1, 2, 3, 0, 5], [0, 1, 2, 4, 3]],pairs = [[0, 5], [1, 2], [3, 4]]) == 3\n assert candidate(n = 10,preferences = [[1, 3, 5, 7, 9, 2, 4, 6, 8, 0], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9], [9, 7, 5, 3, 1, 8, 6, 4, 2, 0], [8, 6, 4, 2, 0, 9, 7, 5, 3, 1], [7, 5, 3, 1, 9, 0, 8, 6, 4, 2], [6, 4, 2, 0, 8, 1, 9, 7, 5, 3], [5, 3, 1, 9, 7, 2, 0, 8, 6, 4], [4, 2, 0, 8, 6, 3, 1, 9, 7, 5], [3, 1, 9, 7, 5, 4, 2, 0, 8, 6], [2, 0, 8, 6, 4, 5, 3, 1, 9, 7]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 8\n assert candidate(n = 20,preferences = [[19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [18, 19, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [17, 16, 19, 18, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [16, 17, 18, 19, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [15, 14, 13, 12, 19, 18, 17, 16, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [14, 15, 13, 12, 18, 19, 17, 16, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [13, 12, 11, 10, 9, 8, 7, 6, 19, 18, 17, 16, 15, 14, 5, 4, 3, 2, 1, 0], [12, 13, 11, 10, 8, 9, 7, 6, 18, 19, 17, 16, 15, 14, 5, 4, 3, 2, 1, 0], [11, 10, 12, 13, 7, 8, 9, 6, 17, 16, 19, 18, 15, 14, 5, 4, 3, 2, 1, 0], [10, 11, 12, 13, 6, 7, 8, 9, 16, 17, 18, 19, 15, 14, 5, 4, 3, 2, 1, 0], [9, 8, 7, 6, 5, 4, 3, 2, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 1, 0], [8, 9, 7, 6, 4, 5, 3, 2, 18, 19, 17, 16, 15, 14, 13, 12, 11, 10, 1, 0], [7, 6, 8, 9, 3, 4, 5, 2, 17, 16, 19, 18, 15, 14, 13, 12, 11, 10, 1, 0], [6, 7, 8, 9, 2, 3, 4, 5, 16, 17, 18, 19, 15, 14, 13, 12, 11, 10, 1, 0], [5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10], [4, 5, 3, 2, 0, 1, 8, 9, 7, 6, 18, 19, 17, 16, 15, 14, 13, 12, 11, 10], [3, 2, 1, 0, 5, 4, 7, 6, 9, 8, 17, 16, 19, 18, 15, 14, 13, 12, 11, 10], [2, 3, 1, 0, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 15, 14, 13, 12, 11, 10], [1, 0, 2, 3, 3, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 15, 14, 13, 12, 11], [0, 1, 2, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 16, 17, 18, 19, 15, 14, 13], [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]]) == 20\n assert candidate(n = 6,preferences = [[5, 1, 3, 2, 4], [4, 3, 5, 1, 2], [1, 4, 5, 3, 2], [5, 4, 2, 1, 3], [2, 1, 3, 4, 5], [1, 3, 4, 2, 0]],pairs = [[0, 5], [1, 4], [2, 3]]) == 4\n assert candidate(n = 10,preferences = [[5, 3, 8, 2, 7, 6, 9, 0, 1, 4], [9, 4, 2, 5, 8, 6, 3, 7, 1, 0], [4, 5, 6, 7, 8, 9, 0, 1, 2, 3], [7, 6, 5, 4, 3, 2, 1, 0, 8, 9], [1, 0, 3, 4, 2, 5, 6, 7, 8, 9], [2, 0, 1, 4, 3, 5, 6, 7, 8, 9], [6, 5, 4, 3, 2, 1, 0, 7, 8, 9], [3, 2, 1, 0, 4, 5, 6, 7, 8, 9], [8, 9, 0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]],pairs = [[0, 4], [1, 5], [2, 6], [3, 7], [8, 9]]) == 8\n assert candidate(n = 8,preferences = [[7, 6, 5, 4, 3, 2, 1, 0], [6, 7, 0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 0, 7, 6], [4, 5, 6, 7, 0, 1, 2, 3], [3, 2, 1, 0, 7, 6, 5, 4], [2, 3, 0, 1, 6, 7, 4, 5], [1, 0, 7, 6, 5, 4, 3, 2], [0, 1, 2, 3, 4, 5, 6, 7]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7]]) == 8\n assert candidate(n = 12,preferences = [[11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [10, 11, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [9, 10, 11, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 9, 10, 11, 7, 6, 5, 4, 3, 2, 1, 0], [7, 8, 9, 10, 11, 6, 5, 4, 3, 2, 1, 0], [6, 7, 8, 9, 10, 11, 5, 4, 3, 2, 1, 0], [5, 6, 7, 8, 9, 10, 11, 4, 3, 2, 1, 0], [4, 5, 6, 7, 8, 9, 10, 11, 3, 2, 1, 0], [3, 4, 5, 6, 7, 8, 9, 10, 11, 2, 1, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]]) == 12\n"}, "metadata": {"canonical_parameter_names": ["n", "preferences", "pairs"], "leetcode_dataset_entry_point": "Solution().unhappyFriends", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def unhappyFriends(self, n: int, preferences: list[list[int]], pairs: list[list[int]]) -> int:", "container": "Solution", "callable": "unhappyFriends", "parameters": [{"name": "n", "type": "int"}, {"name": "preferences", "type": "list[list[int]]"}, {"name": "pairs", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1584, "task_id": "min-cost-to-connect-all-points", "difficulty": "Medium", "problem_description": "You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].\nThe cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes the absolute value of val.\nReturn the minimum cost to make all points connected. All points are connected if there is exactly one simple path between any two points.\n \nExample 1:\n\n\nInput: points = [[0,0],[2,2],[3,10],[5,2],[7,0]]\nOutput: 20\nExplanation: \n\nWe can connect the points as shown above to get the minimum cost of 20.\nNotice that there is a unique path between every pair of points.\n\nExample 2:\n\nInput: points = [[3,12],[-2,5],[-4,1]]\nOutput: 18\n\n \nConstraints:\n\n1 <= points.length <= 1000\n-106 <= xi, yi <= 106\nAll pairs (xi, yi) are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[0, 0], [2, 2], [4, 4], [6, 6], [8, 8]]) == 16\n assert candidate(points = [[1, 1], [0, 0], [2, 2], [3, 3], [4, 4]]) == 8\n assert candidate(points = [[-1000000, 1000000], [1000000, -1000000], [0, 0]]) == 4000000\n assert candidate(points = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]) == 8\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [-1, 1]]) == 4\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 10\n assert candidate(points = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]]) == 40\n assert candidate(points = [[-1000000, -1000000], [1000000, 1000000]]) == 4000000\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 8\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 6\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4]]) == 6\n assert candidate(points = [[-1, 0], [0, 1], [1, 0], [0, -1]]) == 6\n assert candidate(points = [[3, 12], [-2, 5], [-4, 1]]) == 18\n assert candidate(points = [[1000000, -1000000], [-1000000, 1000000], [0, 0]]) == 4000000\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1]]) == 3\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [0, 1]]) == 3\n assert candidate(points = [[0, 0], [2, 2], [3, 10], [5, 2], [7, 0]]) == 20\n assert candidate(points = [[1, 1], [2, 2], [3, 3]]) == 4\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [0, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 19\n assert candidate(points = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000]]) == 1600\n assert candidate(points = [[0, 0], [0, 1000000], [1000000, 0], [1000000, 1000000], [500000, 500000], [250000, 750000], [750000, 250000], [100000, 100000], [900000, 900000], [100000, 900000], [900000, 100000]]) == 4000000\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [7, 8], [8, 7], [8, 8], [9, 9], [9, 10], [10, 9], [10, 10]]) == 23\n assert candidate(points = [[-1, 0], [0, -1], [1, 0], [0, 1], [-2, 0], [0, -2], [2, 0], [0, 2], [-3, 0], [0, -3], [3, 0], [0, 3], [-4, 0], [0, -4], [4, 0], [0, 4]]) == 18\n assert candidate(points = [[0, 0], [10, 0], [0, 10], [10, 10], [20, 0], [20, 10], [30, 0], [30, 10], [40, 0], [40, 10]]) == 90\n assert candidate(points = [[-5, 5], [0, 0], [5, -5], [10, 10], [-10, -10], [15, 15], [-15, -15]]) == 80\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1], [3, 0], [3, 1], [4, 0], [4, 1], [5, 0], [5, 1], [6, 0], [6, 1], [7, 0], [7, 1], [8, 0], [8, 1], [9, 0], [9, 1]]) == 19\n assert candidate(points = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == 18\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 18\n assert candidate(points = [[1, 1], [2, 3], [4, 5], [8, 10], [15, 20], [25, 30], [40, 50]]) == 88\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0]]) == 20\n assert candidate(points = [[1000000, 1000000], [-1000000, -1000000], [0, 0], [500000, 500000], [-500000, -500000]]) == 4000000\n assert candidate(points = [[-50, -100], [-150, -200], [-250, -300], [-350, -400], [-450, -500], [-550, -600], [-650, -700], [-750, -800], [-850, -900], [-950, -1000]]) == 1800\n assert candidate(points = [[1000000, -1000000], [0, 0], [-1000000, 1000000], [500000, 500000], [-500000, -500000]]) == 6000000\n assert candidate(points = [[0, 0], [1, 0], [0, 1], [1, 1], [-1, 0], [0, -1], [-1, -1], [-1, 1], [1, -1], [2, 0], [0, 2], [-2, 0], [0, -2], [-2, -1], [-1, -2], [-2, 1], [1, -2]]) == 16\n assert candidate(points = [[10, 10], [20, 10], [20, 20], [10, 20], [15, 15], [5, 5], [25, 25], [10, 5], [10, 15], [5, 10]]) == 60\n assert candidate(points = [[1, 2], [4, 6], [5, 7], [8, 9], [11, 10], [10, 11], [3, 5], [2, 3], [6, 8], [9, 4]]) == 26\n assert candidate(points = [[-1000000, 1000000], [1000000, -1000000], [0, 0], [-500000, 500000], [500000, -500000]]) == 4000000\n assert candidate(points = [[1, 1000000], [1000000, 1], [1, 2], [2, 1], [1000000, 2], [2, 1000000], [1000000, 1000000]]) == 2999998\n assert candidate(points = [[1, 2], [4, 8], [1, 7], [6, 1], [9, 7], [7, 4], [9, 1], [7, 9], [9, 2], [7, 6]]) == 29\n assert candidate(points = [[-500000, -500000], [0, 0], [500000, 500000], [1000000, 1000000], [1500000, 1500000]]) == 4000000\n assert candidate(points = [[-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 20\n assert candidate(points = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]]) == 90\n assert candidate(points = [[1, 2], [4, 6], [5, 7], [8, 4], [2, 1], [5, 5], [7, 8], [8, 9], [1, 4], [2, 8], [7, 1], [9, 5]]) == 32\n assert candidate(points = [[-1, -2], [-3, -4], [-5, -6], [-7, -8], [-9, -10], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 38\n assert candidate(points = [[-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14]]) == 34\n assert candidate(points = [[1, 1], [2, 3], [3, 1], [4, 3], [5, 1], [6, 3], [7, 1], [8, 3], [9, 1], [10, 3]]) == 19\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1], [3, 0], [3, 1], [4, 0], [4, 1]]) == 9\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [150, 250], [250, 150], [350, 450], [450, 350], [550, 450]]) == 1300\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [0, 1], [2, 2], [2, 0], [0, 2], [1, 2], [2, 1], [0, 3], [3, 0], [3, 3]]) == 12\n assert candidate(points = [[1, 2], [4, 8], [5, 0], [7, 3], [8, 9], [9, 6], [9, 7], [10, 4], [10, 8], [11, 2]]) == 32\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [0, 2], [1, 2], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2]]) == 11\n assert candidate(points = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000], [1100, 1200], [1300, 1400], [1500, 1600]]) == 2800\n assert candidate(points = [[1, 1], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [10, 10]]) == 26\n assert candidate(points = [[10, 10], [20, 10], [20, 20], [10, 20], [30, 10], [30, 20], [40, 10], [40, 20], [15, 15], [25, 15], [35, 15], [15, 25], [25, 25], [35, 25]]) == 130\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [11, 0], [12, 0], [13, 0], [14, 0]]) == 14\n assert candidate(points = [[-1, -1], [1, 1], [0, 0], [2, 2], [-2, -2], [3, 3], [-3, -3], [4, 4], [-4, -4], [5, 5], [-5, -5], [6, 6], [-6, -6]]) == 24\n assert candidate(points = [[-100, 0], [0, 100], [100, 0], [0, -100], [50, 50], [-50, -50], [50, -50], [-50, 50], [0, 0], [0, 0]]) == 800\n assert candidate(points = [[0, 0], [1, 2], [2, 4], [4, 8], [8, 16], [16, 32], [32, 64], [64, 128], [128, 256], [256, 512]]) == 768\n assert candidate(points = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20], [11, 22], [12, 24], [13, 26], [14, 28]]) == 42\n assert candidate(points = [[500000, 500000], [400000, 400000], [300000, 300000], [200000, 200000], [100000, 100000], [0, 0], [-100000, -100000], [-200000, -200000], [-300000, -300000], [-400000, -400000], [-500000, -500000]]) == 2000000\n assert candidate(points = [[0, 0], [1, 2], [3, 1], [2, 3], [4, 5], [6, 4], [5, 6], [7, 8], [9, 7], [8, 9], [10, 10], [12, 11], [11, 12], [13, 14], [15, 13], [14, 15], [16, 16], [18, 17], [17, 18], [19, 19]]) == 54\n assert candidate(points = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [110, 120], [130, 140], [150, 160], [170, 180], [190, 200]]) == 360\n assert candidate(points = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 20\n assert candidate(points = [[1000000, 0], [0, 1000000], [500000, 500000], [250000, 750000], [750000, 250000]]) == 2000000\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 21\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 36\n assert candidate(points = [[1000000, 1000000], [1000001, 1000001], [1000002, 1000002], [1000003, 1000003], [1000004, 1000004]]) == 8\n assert candidate(points = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 1100]]) == 1800\n assert candidate(points = [[0, 0], [1000000, 1000000], [500000, 500000], [250000, 250000], [750000, 750000], [125000, 125000], [875000, 875000], [312500, 312500], [687500, 687500], [437500, 437500]]) == 2000000\n assert candidate(points = [[-200000, 200000], [-400000, 400000], [-600000, 600000], [-800000, 800000], [-1000000, 1000000], [200000, -200000], [400000, -400000], [600000, -600000], [800000, -800000], [1000000, -1000000]]) == 4000000\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9], [11, 12], [12, 11]]) == 32\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [0, 1], [2, 2], [2, 0], [0, 2]]) == 7\n assert candidate(points = [[0, 0], [0, 1000000], [1000000, 0], [1000000, 1000000], [500000, 500000]]) == 4000000\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 1], [9, 2], [10, 3]]) == 42\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9], [-10, -10]]) == 18\n assert candidate(points = [[-1, 2], [-4, 6], [-5, 7], [-8, 9], [-11, 10], [-10, -11], [-3, -5], [-2, -3], [-6, -8], [-9, -4]]) == 47\n assert candidate(points = [[-1, 0], [0, 1], [1, 0], [0, -1], [2, 2], [-2, 2], [2, -2], [-2, -2], [3, 3], [-3, 3], [3, -3], [-3, -3]]) == 26\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [11, 0], [12, 0], [13, 0], [14, 0], [15, 0]]) == 15\n assert candidate(points = [[-1000000, 1000000], [1000000, -1000000], [-500000, -500000], [500000, 500000], [0, 0], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 5999999\n assert candidate(points = [[500000, 500000], [500001, 500001], [500002, 500002], [500003, 500003], [500004, 500004]]) == 8\n assert candidate(points = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18]]) == 27\n assert candidate(points = [[0, 0], [1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27], [10, 30], [11, 33], [12, 36], [13, 39], [14, 42]]) == 56\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 18\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [20, 10], [20, 20], [20, 30], [30, 10], [30, 20], [30, 30], [15, 15], [25, 25]]) == 100\n assert candidate(points = [[-3, -3], [3, 3], [0, 0], [-1, 1], [1, -1], [-2, 2], [2, -2], [-3, 0], [3, 0], [0, -3], [0, 3], [-2, -1], [2, 1], [1, 2], [-1, -2], [-2, 1], [2, -1], [1, -2], [-1, 2]]) == 32\n assert candidate(points = [[-1, -1], [-2, -2], [1, 1], [2, 2], [-3, -3], [3, 3], [-4, -4], [4, 4], [-5, -5], [5, 5], [-6, -6], [6, 6], [-7, -7], [7, 7], [-8, -8], [8, 8], [-9, -9], [9, 9]]) == 36\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [0, 2], [2, 0], [1, 2], [2, 1], [2, 2], [0, 3], [3, 0], [1, 3], [3, 1], [2, 3], [3, 2], [3, 3]]) == 15\n assert candidate(points = [[0, 0], [1, 1], [0, 1], [1, 0], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 19\n assert candidate(points = [[-500000, -500000], [-500001, -500001], [-500002, -500002], [-500003, -500003], [-500004, -500004]]) == 8\n assert candidate(points = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 38\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [11, 0], [12, 0], [13, 0], [14, 0], [15, 0], [16, 0], [17, 0], [18, 0], [19, 0]]) == 19\n assert candidate(points = [[1000000, 1000000], [999999, 1000000], [1000000, 999999], [1000000, 1000001], [999999, 999999], [999999, 1000001], [1000001, 999999], [1000001, 1000001]]) == 7\n assert candidate(points = [[0, 0], [0, 1000000], [1000000, 0], [1000000, 1000000], [500000, 500000], [250000, 250000], [750000, 750000], [250000, 750000], [750000, 250000]]) == 4000000\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == 19\n assert candidate(points = [[-100, -200], [-50, -50], [0, 0], [50, 50], [100, 200], [200, 400], [400, 800], [800, 1600], [1600, 3200], [3200, 6400]]) == 9900\n assert candidate(points = [[-1000000, -1000000], [-500000, -500000], [0, 0], [500000, 500000], [1000000, 1000000]]) == 4000000\n assert candidate(points = [[1, 2], [4, 6], [5, 7], [8, 4], [2, 1], [6, 9], [7, 8], [3, 5], [9, 2], [0, 3]]) == 26\n assert candidate(points = [[-500000, -500000], [500000, 500000], [-400000, -400000], [400000, 400000], [-300000, -300000], [300000, 300000], [-200000, -200000], [200000, 200000], [-100000, -100000], [100000, 100000]]) == 2000000\n assert candidate(points = [[500000, 500000], [100000, 100000], [900000, 900000], [200000, 200000], [800000, 800000], [300000, 300000], [700000, 700000], [400000, 400000], [600000, 600000], [550000, 550000]]) == 1600000\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]]) == 38\n assert candidate(points = [[3, 1], [1, 4], [1, 1], [1, 3], [2, 6], [3, 5], [6, 5], [4, 3], [7, 4], [4, 6], [5, 4], [5, 5], [6, 7], [8, 4], [2, 3]]) == 23\n assert candidate(points = [[-1, -1], [1, 1], [-2, -2], [2, 2], [-3, -3], [3, 3], [-4, -4], [4, 4], [-5, -5], [5, 5]]) == 20\n assert candidate(points = [[0, 0], [10, 0], [0, 10], [10, 10], [5, 5], [3, 7], [8, 2], [2, 8], [7, 3], [4, 6], [6, 4]]) == 40\n assert candidate(points = [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [2, 2], [8, 8], [3, 3], [7, 7], [6, 6]]) == 40\n"}, "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().minCostConnectPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minCostConnectPoints(self, points: list[list[int]]) -> int:", "container": "Solution", "callable": "minCostConnectPoints", "parameters": [{"name": "points", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1585, "task_id": "check-if-string-is-transformable-with-substring-sort-operations", "difficulty": "Hard", "problem_description": "Given two strings s and t, transform string s into string t using the following operation any number of times:\n\nChoose a non-empty substring in s and sort it in place so the characters are in ascending order.\n\n\t\nFor example, applying the operation on the underlined substring in \"14234\" results in \"12344\".\n\n\n\nReturn true if it is possible to transform s into t. Otherwise, return false.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"84532\", t = \"34852\"\nOutput: true\nExplanation: You can transform s into t using the following sort operations:\n\"84532\" (from index 2 to 3) -> \"84352\"\n\"84352\" (from index 0 to 2) -> \"34852\"\n\nExample 2:\n\nInput: s = \"34521\", t = \"23415\"\nOutput: true\nExplanation: You can transform s into t using the following sort operations:\n\"34521\" -> \"23451\"\n\"23451\" -> \"23415\"\n\nExample 3:\n\nInput: s = \"12345\", t = \"12435\"\nOutput: false\n\n \nConstraints:\n\ns.length == t.length\n1 <= s.length <= 105\ns and t consist of only digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"9876543210\",t = \"0123456789\") == True\n assert candidate(s = \"1221\",t = \"1122\") == True\n assert candidate(s = \"987654321\",t = \"123456789\") == True\n assert candidate(s = \"123\",t = \"321\") == False\n assert candidate(s = \"9876543210\",t = \"9876543211\") == False\n assert candidate(s = \"98765\",t = \"56789\") == True\n assert candidate(s = \"11111\",t = \"11111\") == True\n assert candidate(s = \"34521\",t = \"23415\") == True\n assert candidate(s = \"12345\",t = \"12435\") == False\n assert candidate(s = \"12\",t = \"21\") == False\n assert candidate(s = \"1\",t = \"1\") == True\n assert candidate(s = \"123\",t = \"132\") == False\n assert candidate(s = \"12345\",t = \"54321\") == False\n assert candidate(s = \"123456789\",t = \"123456789\") == True\n assert candidate(s = \"1234567890\",t = \"0987654321\") == False\n assert candidate(s = \"4321\",t = \"1234\") == True\n assert candidate(s = \"13579\",t = \"97531\") == False\n assert candidate(s = \"84532\",t = \"34852\") == True\n assert candidate(s = \"1221\",t = \"2112\") == False\n assert candidate(s = \"123123\",t = \"112233\") == True\n assert candidate(s = \"111222333\",t = \"333222111\") == False\n assert candidate(s = \"12345678909876543210\",t = \"12345678909876543210\") == True\n assert candidate(s = \"100200300400500600700800900\",t = \"0000000000000000000123456789\") == False\n assert candidate(s = \"12345678909876543210\",t = \"09876543210123456789\") == False\n assert candidate(s = \"111122223333\",t = \"123123123123\") == False\n assert candidate(s = \"31415926535\",t = \"11233455569\") == True\n assert candidate(s = \"000111222333444555666777888999\",t = \"111122223333444455556666777788889999\") == False\n assert candidate(s = \"555544443333222211110000\",t = \"000011112222333344445555\") == True\n assert candidate(s = \"321123\",t = \"112233\") == True\n assert candidate(s = \"987654321987654321\",t = \"111122223333444455556666777788889999\") == False\n assert candidate(s = \"987654321009876543210\",t = \"00112233445566778899\") == True\n assert candidate(s = \"44443333222211110000\",t = \"00001111222233334444\") == True\n assert candidate(s = \"56321456\",t = \"12345566\") == True\n assert candidate(s = \"5432167890\",t = \"1234567890\") == True\n assert candidate(s = \"112233445566778899\",t = \"98765432101234567890\") == False\n assert candidate(s = \"632541\",t = \"123456\") == True\n assert candidate(s = \"11111111112222222222\",t = \"22222222221111111111\") == False\n assert candidate(s = \"0000111122223333\",t = \"3333222211110000\") == False\n assert candidate(s = \"234234234\",t = \"222333444\") == True\n assert candidate(s = \"33322111\",t = \"11122333\") == True\n assert candidate(s = \"98765432100123456789\",t = \"01234567890987654321\") == False\n assert candidate(s = \"654321654321\",t = \"111222333444555666\") == False\n assert candidate(s = \"987654321098765432109876543210\",t = \"000111222333444555666777888999\") == True\n assert candidate(s = \"98765432101234567890\",t = \"09876543210123456789\") == True\n assert candidate(s = \"123454321\",t = \"122113454\") == False\n assert candidate(s = \"3211123123\",t = \"111223332\") == False\n assert candidate(s = \"1222222222\",t = \"2222222221\") == False\n assert candidate(s = \"9876543210\",t = \"1098765432\") == True\n assert candidate(s = \"122112211\",t = \"111222112\") == True\n assert candidate(s = \"123456789012345678901234567890\",t = \"000111222333444555666777888999\") == True\n assert candidate(s = \"5432112345\",t = \"1122334455\") == True\n assert candidate(s = \"012345678901234567890123456789\",t = \"0011223344556677889900112233445566778899\") == False\n assert candidate(s = \"6677889900\",t = \"0011223344\") == False\n assert candidate(s = \"1234512345\",t = \"1122334455\") == True\n assert candidate(s = \"543216789\",t = \"123456789\") == True\n assert candidate(s = \"12345678909876543210\",t = \"01234567890123456789\") == True\n assert candidate(s = \"999888777666555444333222111000\",t = \"000111222333444555666777888999\") == True\n assert candidate(s = \"765432109876543210\",t = \"00112233445566778899\") == False\n assert candidate(s = \"99887766554433221100\",t = \"00112233445566778899\") == True\n assert candidate(s = \"98765432109876543210\",t = \"00112233445566778899\") == True\n assert candidate(s = \"333333333\",t = \"333333333\") == True\n assert candidate(s = \"1332211\",t = \"1112233\") == True\n assert candidate(s = \"567891234\",t = \"123456789\") == True\n assert candidate(s = \"12341234\",t = \"11223344\") == True\n assert candidate(s = \"35421\",t = \"12345\") == True\n assert candidate(s = \"5432109876\",t = \"0123456789\") == True\n assert candidate(s = \"54321\",t = \"12345\") == True\n assert candidate(s = \"534987621\",t = \"123456789\") == True\n assert candidate(s = \"111122223333\",t = \"333322221111\") == False\n assert candidate(s = \"11111111112222222222\",t = \"11111111112222222222\") == True\n assert candidate(s = \"98765432100987654321\",t = \"00112233445566778899\") == True\n assert candidate(s = \"99887766554433221100\",t = \"0011223344556677889900112233445566778899\") == False\n assert candidate(s = \"54321098765432109876543210\",t = \"0000111122223333444455556666777788889999\") == False\n assert candidate(s = \"5555555555\",t = \"5555555555\") == True\n assert candidate(s = \"65432123456\",t = \"12345623456\") == True\n assert candidate(s = \"432143214321\",t = \"111222333\") == True\n assert candidate(s = \"102030405060708090\",t = \"0000000000123456789\") == False\n assert candidate(s = \"111111111111\",t = \"111111111111\") == True\n assert candidate(s = \"98765432109876543210\",t = \"01234567890123456789\") == True\n assert candidate(s = \"9876543210\",t = \"1234567890\") == True\n assert candidate(s = \"432143214321\",t = \"111222333444\") == True\n assert candidate(s = \"10987654321\",t = \"12345678901\") == False\n assert candidate(s = \"5931246870\",t = \"0123456789\") == True\n assert candidate(s = \"111222333444555666777888999000\",t = \"000111222333444555666777888999\") == True\n assert candidate(s = \"9999888877776666555544443333222211110000\",t = \"0000111122223333444455556666777788889999\") == True\n assert candidate(s = \"123456789012345678901234567890\",t = \"000111222333444555666777888999111222333444555666777888999000\") == False\n assert candidate(s = \"55554444333322221111\",t = \"11112222333344445555\") == True\n assert candidate(s = \"1011121314151617181920\",t = \"1011121314151617181920\") == True\n assert candidate(s = \"333222111\",t = \"111222333\") == True\n assert candidate(s = \"12345678900987654321\",t = \"01234567899876543210\") == False\n assert candidate(s = \"111222333\",t = \"312312312\") == False\n assert candidate(s = \"23232323232323232323\",t = \"22222222223333333333\") == True\n assert candidate(s = \"123321\",t = \"112233\") == True\n assert candidate(s = \"12345678901234567890\",t = \"09876543210987654321\") == False\n assert candidate(s = \"99999888887777766666555554444433333222221111100000\",t = \"00000111112222233333444445555566666777778888899999\") == True\n assert candidate(s = \"654321123456\",t = \"112233445566\") == True\n assert candidate(s = \"010203040506070809\",t = \"00112233445566778899\") == False\n assert candidate(s = \"333222111222333111222333\",t = \"111111222222333333222\") == True\n assert candidate(s = \"321321321\",t = \"111222333\") == True\n assert candidate(s = \"12345678900987654321\",t = \"00123456789123456789\") == True\n assert candidate(s = \"11111111111111111111\",t = \"11111111111111111111\") == True\n assert candidate(s = \"111222333\",t = \"123123123\") == False\n assert candidate(s = \"2121212121\",t = \"1212121212\") == True\n assert candidate(s = \"2222211111\",t = \"1111122222\") == True\n assert candidate(s = \"12345678909876543210\",t = \"000111222333444555666777888999\") == False\n assert candidate(s = \"1111111111\",t = \"1111111111\") == True\n assert candidate(s = \"628491375\",t = \"123456789\") == True\n assert candidate(s = \"5317246\",t = \"1234567\") == True\n assert candidate(s = \"12345678901234567890\",t = \"01234567890123456789\") == True\n assert candidate(s = \"11223344556677889900\",t = \"00112233445566778899\") == True\n assert candidate(s = \"654321098765\",t = \"012345657896\") == True\n assert candidate(s = \"1234567890987654321012345678909876543210\",t = \"000000111111222222333333444444555555666666777777888888999999\") == False\n assert candidate(s = \"989898989898989898\",t = \"88888888888888888899\") == False\n assert candidate(s = \"321456987\",t = \"123456789\") == True\n assert candidate(s = \"143425\",t = \"123445\") == True\n assert candidate(s = \"98765432100123456789\",t = \"00112233445566778899\") == True\n assert candidate(s = \"12345678901234567890\",t = \"01020304050607080919\") == False\n assert candidate(s = \"321321321321321321\",t = \"111112222233333333\") == False\n assert candidate(s = \"12345678900123456789\",t = \"01234567891234567890\") == False\n assert candidate(s = \"12332121321321321\",t = \"11112222333323333\") == False\n assert candidate(s = \"98765432109876543210\",t = \"0011223344556677889900112233445566778899\") == False\n assert candidate(s = \"312312312\",t = \"111222333\") == True\n assert candidate(s = \"5555555555555555555555\",t = \"5555555555555555555555\") == True\n assert candidate(s = \"987654321010203040506070809\",t = \"0000111122223333444455556666777788889999\") == False\n assert candidate(s = \"9345728160\",t = \"0123456789\") == True\n assert candidate(s = \"43214321\",t = \"11223344\") == True\n assert candidate(s = \"1357924680\",t = \"0123456789\") == True\n assert candidate(s = \"98765432100123456789\",t = \"00123456789876543210\") == False\n assert candidate(s = \"123123123\",t = \"111222333\") == True\n assert candidate(s = \"123123123\",t = \"312312312\") == False\n assert candidate(s = \"543215432154321\",t = \"11112222333344445555\") == False\n assert candidate(s = \"98765432101111111111\",t = \"0111111111123456789\") == True\n assert candidate(s = \"43211234\",t = \"11223344\") == True\n assert candidate(s = \"6543210987\",t = \"7890123456\") == False\n assert candidate(s = \"12345678901234567890\",t = \"00112233445566778899\") == True\n assert candidate(s = \"555444333222111000\",t = \"000111222333444555\") == True\n assert candidate(s = \"98765432100123456789\",t = \"00123456789987654321\") == False\n assert candidate(s = \"0123456789876543210123456789\",t = \"0011223344556677889900112233445566778899\") == False\n assert candidate(s = \"55555555555555555555\",t = \"55555555555555555555\") == True\n assert candidate(s = \"11223344556677889900\",t = \"00998877665544332211\") == False\n assert candidate(s = \"1234567890987654321\",t = \"1234567890123456789\") == True\n assert candidate(s = \"6666666666\",t = \"6666666666\") == True\n assert candidate(s = \"6543212132435465768798\",t = \"11223344556677889965432\") == False\n assert candidate(s = \"333322211\",t = \"112223333\") == True\n assert candidate(s = \"4321111111234\",t = \"1111111234432\") == False\n assert candidate(s = \"87654321098765432109876543210\",t = \"0000001111112222223333334444445555556666667777778888889999999\") == False\n assert candidate(s = \"53142\",t = \"12345\") == True\n"}, "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().isTransformable", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def isTransformable(self, s: str, t: str) -> bool:", "container": "Solution", "callable": "isTransformable", "parameters": [{"name": "s", "type": "str"}, {"name": "t", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1588, "task_id": "sum-of-all-odd-length-subarrays", "difficulty": "Easy", "problem_description": "Given an array of positive integers arr, return the sum of all possible odd-length subarrays of arr.\nA subarray is a contiguous subsequence of the array.\n \nExample 1:\n\nInput: arr = [1,4,2,5,3]\nOutput: 58\nExplanation: The odd-length subarrays of arr and their sums are:\n[1] = 1\n[4] = 4\n[2] = 2\n[5] = 5\n[3] = 3\n[1,4,2] = 7\n[4,2,5] = 11\n[2,5,3] = 10\n[1,4,2,5,3] = 15\nIf we add all these together we get 1 + 4 + 2 + 5 + 3 + 7 + 11 + 10 + 15 = 58\nExample 2:\n\nInput: arr = [1,2]\nOutput: 3\nExplanation: There are only 2 subarrays of odd length, [1] and [2]. Their sum is 3.\nExample 3:\n\nInput: arr = [10,11,12]\nOutput: 66\n\n \nConstraints:\n\n1 <= arr.length <= 100\n1 <= arr[i] <= 1000\n\n \nFollow up:\nCould you solve this problem in O(n) time complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 8760\n assert candidate(arr = [2, 4, 6, 8, 10]) == 114\n assert candidate(arr = [1, 2]) == 3\n assert candidate(arr = [5]) == 5\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 614\n assert candidate(arr = [5, 5, 5, 5, 5]) == 95\n assert candidate(arr = [100, 200, 300, 400, 500]) == 5700\n assert candidate(arr = [10, 11, 12]) == 66\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [7]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 605\n assert candidate(arr = [100, 200, 300]) == 1200\n assert candidate(arr = [1, 2, 3, 4, 5]) == 57\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 425\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13]) == 308\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 425\n assert candidate(arr = [1, 4, 2, 5, 3]) == 58\n assert candidate(arr = [1, 3, 5, 7, 9]) == 95\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16]) == 540\n assert candidate(arr = [7, 1, 14, 11]) == 81\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75]) == 127803\n assert candidate(arr = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 281775\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 281775\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 3003\n assert candidate(arr = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104, 108, 112, 116, 120]) == 153760\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 15400\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2752\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 19097\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19540\n assert candidate(arr = [999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000]) == 109945\n assert candidate(arr = [23, 45, 12, 67, 89, 34, 56, 78, 90, 11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 311940\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 13760\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == 18711\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 27520\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 8208\n assert candidate(arr = [250, 240, 230, 220, 210, 200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 190970\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 15400\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 74400\n assert candidate(arr = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160]) == 64680\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51]) == 13203\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700]) == 440100\n assert candidate(arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 38440\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 60792\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 13860\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275, 286, 297, 308, 319, 330]) == 422840\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7590\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9224\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 31648\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130]) == 110565\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 6050\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 3003\n assert candidate(arr = [101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123]) == 20384\n assert candidate(arr = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == 388680\n assert candidate(arr = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144]) == 43320\n assert candidate(arr = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96]) == 65000\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 93555\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 190970\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2752\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 80850\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2736\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 36725\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 40425\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 275200\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125]) == 95485\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 40425\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 19097\n assert candidate(arr = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500]) == 381940\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 60792\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 808500\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77]) == 101728\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120]) == 81250\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 3850\n assert candidate(arr = [150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170]) == 142560\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154]) == 81466\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75]) == 57291\n assert candidate(arr = [101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129]) == 39560\n assert candidate(arr = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 24050\n assert candidate(arr = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168]) == 176610\n assert candidate(arr = [50, 25, 75, 100, 200, 150, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000]) == 438225\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 275200\n assert candidate(arr = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 761915\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175]) == 133679\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 31570\n assert candidate(arr = [21, 34, 41, 53, 67, 71, 82, 95, 100, 121, 134, 141, 153, 167, 171, 182, 195]) == 52492\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275, 286, 297]) == 282436\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 4480\n assert candidate(arr = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50]) == 0\n assert candidate(arr = [1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 57040\n assert candidate(arr = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 51000\n assert candidate(arr = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330, 363, 396, 429, 462, 495, 528, 561, 594, 627, 660, 693, 726, 759, 792, 825]) == 630201\n assert candidate(arr = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == 70350\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]) == 161700\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 117670\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 8085\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 60500\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 5848\n assert candidate(arr = [50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 12770\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 5500\n assert candidate(arr = [300, 200, 100, 50, 25, 12, 6, 3, 1]) == 5364\n assert candidate(arr = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 109]) == 8614\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == 14700\n assert candidate(arr = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270]) == 184960\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 60500\n assert candidate(arr = [42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80]) == 46970\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().sumOddLengthSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def sumOddLengthSubarrays(self, arr: list[int]) -> int:", "container": "Solution", "callable": "sumOddLengthSubarrays", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1589, "task_id": "maximum-sum-obtained-of-any-permutation", "difficulty": "Medium", "problem_description": "We have an array of integers, nums, and an array of requests where requests[i] = [starti, endi]. The ith request asks for the sum of nums[starti] + nums[starti + 1] + ... + nums[endi - 1] + nums[endi]. Both starti and endi are 0-indexed.\nReturn the maximum total sum of all requests among all permutations of nums.\nSince the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5], requests = [[1,3],[0,1]]\nOutput: 19\nExplanation: One permutation of nums is [2,1,3,4,5] with the following result: \nrequests[0] -> nums[1] + nums[2] + nums[3] = 1 + 3 + 4 = 8\nrequests[1] -> nums[0] + nums[1] = 2 + 1 = 3\nTotal sum: 8 + 3 = 11.\nA permutation with a higher total sum is [3,5,4,2,1] with the following result:\nrequests[0] -> nums[1] + nums[2] + nums[3] = 5 + 4 + 2 = 11\nrequests[1] -> nums[0] + nums[1] = 3 + 5 = 8\nTotal sum: 11 + 8 = 19, which is the best that you can do.\n\nExample 2:\n\nInput: nums = [1,2,3,4,5,6], requests = [[0,1]]\nOutput: 11\nExplanation: A permutation with the max total sum is [6,5,4,3,2,1] with request sums [11].\nExample 3:\n\nInput: nums = [1,2,3,4,5,10], requests = [[0,2],[1,3],[1,1]]\nOutput: 47\nExplanation: A permutation with the max total sum is [4,10,5,3,2,1] with request sums [19,18,10].\n \nConstraints:\n\nn == nums.length\n1 <= n <= 105\n0 <= nums[i] <= 105\n1 <= requests.length <= 105\nrequests[i].length == 2\n0 <= starti <= endi < n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 10],requests = [[0, 2], [1, 3], [1, 1]]) == 47\n assert candidate(nums = [10, 20, 30, 40, 50],requests = [[0, 0], [1, 2], [2, 3], [3, 4]]) == 240\n assert candidate(nums = [0, 0, 0, 0, 0],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 0\n assert candidate(nums = [1, 2, 3],requests = [[0, 2], [0, 1], [1, 2]]) == 15\n assert candidate(nums = [5, 2, 4, 1, 3],requests = [[0, 4], [2, 3], [1, 2]]) == 32\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996],requests = [[0, 2], [2, 4], [0, 4]]) == 1099980\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 4], [4, 8], [0, 9]]) == 119\n assert candidate(nums = [1, 2, 3, 4, 5],requests = [[1, 3], [0, 1]]) == 19\n assert candidate(nums = [5, 2, 4, 1, 3],requests = [[0, 4], [1, 3], [0, 0], [3, 4]]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 6],requests = [[0, 1]]) == 11\n assert candidate(nums = [5, 2, 4, 1],requests = [[0, 1], [1, 2], [2, 3]]) == 21\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4]]) == 155\n assert candidate(nums = [100, 101, 102, 103, 104, 105],requests = [[0, 5], [1, 4], [2, 3]]) == 1238\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1]]) == 54\n assert candidate(nums = [10, 20, 30, 40, 50],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 150\n assert candidate(nums = [8, 9, 7, 6, 5],requests = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 59\n assert candidate(nums = [5, 3, 7, 2, 1],requests = [[0, 2], [1, 4], [2, 3]]) == 40\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 1], [1, 2], [2, 3], [3, 4], [0, 4]]) == 570\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 2050000\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 2], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 8], [7, 8], [0, 8]]) == 206\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 5500\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [0, 9], [10, 19], [5, 14], [9, 14]]) == 680\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 4]]) == 3499885\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [1, 2], [3, 4], [5, 6], [7, 8], [0, 9]]) == 296\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],requests = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5]]) == 5050000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 1485\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 2860\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 1025\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 1485\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 0],requests = [[0, 9], [1, 5], [3, 7], [2, 8], [4, 6]]) == 175\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],requests = [[0, 3], [2, 5], [1, 4], [3, 7]]) == 95\n assert candidate(nums = [5, 3, 2, 1, 4],requests = [[0, 2], [1, 4], [0, 3], [2, 4]]) == 47\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 2050\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],requests = [[0, 19], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 19]]) == 799\n assert candidate(nums = [5, 3, 8, 1, 4, 7],requests = [[0, 5], [2, 4], [1, 3]]) == 67\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 26000\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995],requests = [[0, 2], [1, 4], [0, 5], [2, 3]]) == 1499972\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],requests = [[0, 9], [0, 4], [5, 9], [2, 7]]) == 1550000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 19]]) == 627\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],requests = [[0, 19], [5, 15], [10, 20], [1, 2], [3, 4], [7, 8], [12, 13], [17, 18]]) == 1175\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],requests = [[0, 19], [5, 15], [10, 10], [15, 15], [0, 9], [10, 19]]) == 6240\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],requests = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == 6520\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9]]) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1]]) == 54\n assert candidate(nums = [2, 3, 1, 5, 4],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 4]]) == 42\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [3, 6], [6, 9]]) == 275000\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]]) == 210\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 9], [0, 9], [0, 9], [0, 9], [0, 9]]) == 50\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],requests = [[0, 9], [1, 2], [3, 4], [5, 6], [7, 8], [0, 4], [5, 9]]) == 16200\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],requests = [[0, 10], [10, 20], [20, 30], [0, 20], [10, 30], [0, 30]]) == 17290\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],requests = [[0, 9], [0, 0], [9, 9], [2, 2], [5, 5], [1, 8], [3, 7]]) == 1650\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],requests = [[0, 4], [5, 9], [0, 5], [4, 9], [0, 9]]) == 1840000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],requests = [[0, 9], [10, 19], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 8475\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],requests = [[0, 9], [1, 3], [2, 5], [4, 7], [0, 5], [3, 8]]) == 1533\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 430\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],requests = [[0, 4], [5, 9], [0, 9], [2, 7], [3, 8]]) == 398\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 50\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 1485\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],requests = [[0, 2], [2, 4], [4, 6], [6, 8], [0, 9], [1, 8], [3, 7], [5, 5]]) == 1165\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35],requests = [[0, 6], [1, 4], [2, 3], [0, 2], [4, 5]]) == 420\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 1944425\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [0, 9], [10, 19], [5, 15], [3, 17], [7, 13]]) == 899\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],requests = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 3430\n assert candidate(nums = [9, 1, 5, 3, 7, 2, 8, 4, 6, 0],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 175\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],requests = [[0, 5], [3, 7], [1, 4], [6, 9], [0, 2], [8, 10]]) == 1728\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],requests = [[0, 3], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [0, 9]]) == 2510\n assert candidate(nums = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],requests = [[0, 4], [5, 9], [2, 6], [3, 7], [1, 5], [6, 10]]) == 3380\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],requests = [[0, 19], [0, 9], [10, 19], [5, 14], [9, 14], [0, 5], [5, 10], [10, 15]]) == 1828\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 1300\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],requests = [[0, 10], [5, 15], [10, 20], [0, 20], [1, 19], [2, 18], [3, 17], [4, 16], [5, 15], [6, 14]]) == 8216\n assert candidate(nums = [100, 200, 300, 400, 500],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 4]]) == 3000\n assert candidate(nums = [5, 3, 7, 9, 1, 6, 4, 8, 2, 10],requests = [[0, 9], [2, 5], [3, 7], [1, 8], [0, 4], [5, 9]]) == 234\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [0, 9], [10, 19], [0, 10], [10, 20]]) == 650\n assert candidate(nums = [50, 40, 30, 20, 10],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 4], [1, 3], [2, 4]]) == 530\n assert candidate(nums = [23, 17, 54, 32, 45, 67, 89, 101, 120, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34],requests = [[0, 9], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18]]) == 7390\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == 179\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 417\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14]]) == 1135\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],requests = [[0, 4], [1, 3], [2, 2], [3, 9], [4, 8], [5, 7], [6, 6], [7, 9], [0, 9], [0, 0], [9, 9]]) == 23600\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],requests = [[0, 4], [1, 3], [2, 2], [0, 0], [4, 4], [3, 3]]) == 87\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],requests = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 760\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 550\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [0, 9], [10, 19], [0, 4], [5, 9], [10, 14], [15, 19]]) == 630\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],requests = [[0, 19], [0, 0], [19, 19], [5, 15], [10, 10]]) == 170\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 19], [0, 18], [0, 17], [0, 16], [0, 15], [0, 14], [0, 13], [0, 12], [0, 11], [0, 10]]) == 155\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == 110\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],requests = [[0, 12], [2, 5], [6, 9], [1, 4], [7, 10]]) == 449\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],requests = [[0, 9], [10, 19], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 3260\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 19], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [11, 10], [12, 11], [13, 12], [14, 13], [15, 14], [16, 15], [17, 16], [18, 17], [19, 18]]) == 627\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9], [0, 5], [5, 9], [3, 7], [2, 8]]) == 221\n assert candidate(nums = [100, 200, 300, 400, 500],requests = [[0, 4], [1, 3], [2, 2], [0, 0], [4, 4]]) == 3500\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],requests = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 9350\n"}, "metadata": {"canonical_parameter_names": ["nums", "requests"], "leetcode_dataset_entry_point": "Solution().maxSumRangeQuery", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxSumRangeQuery(self, nums: list[int], requests: list[list[int]]) -> int:", "container": "Solution", "callable": "maxSumRangeQuery", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "requests", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1590, "task_id": "make-sum-divisible-by-p", "difficulty": "Medium", "problem_description": "Given an array of positive integers nums, remove the smallest subarray (possibly empty) such that the sum of the remaining elements is divisible by p. It is not allowed to remove the whole array.\nReturn the length of the smallest subarray that you need to remove, or -1 if it's impossible.\nA subarray is defined as a contiguous block of elements in the array.\n \nExample 1:\n\nInput: nums = [3,1,4,2], p = 6\nOutput: 1\nExplanation: The sum of the elements in nums is 10, which is not divisible by 6. We can remove the subarray [4], and the sum of the remaining elements is 6, which is divisible by 6.\n\nExample 2:\n\nInput: nums = [6,3,5,2], p = 9\nOutput: 2\nExplanation: We cannot remove a single element to get a sum divisible by 9. The best way is to remove the subarray [5,2], leaving us with [6,3] with sum 9.\n\nExample 3:\n\nInput: nums = [1,2,3], p = 3\nOutput: 0\nExplanation: Here the sum is 6. which is already divisible by 3. Thus we do not need to remove anything.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n1 <= p <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5, 5],p = 3) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],p = 2) == 1\n assert candidate(nums = [7, 8, 9, 10, 11],p = 11) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],p = 10) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 5) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],p = 11) == 1\n assert candidate(nums = [1000000000],p = 1000000000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],p = 5) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],p = 5) == 0\n assert candidate(nums = [7, 1, 3, 5, 2, 9],p = 10) == 1\n assert candidate(nums = [10, 11, 12],p = 6) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 3) == 1\n assert candidate(nums = [6, 3, 5, 2],p = 9) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],p = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],p = 7) == 1\n assert candidate(nums = [1, 2, 3],p = 3) == 0\n assert candidate(nums = [1],p = 1) == 0\n assert candidate(nums = [5, 5, 5, 5, 5],p = 10) == 1\n assert candidate(nums = [3, 1, 4, 2],p = 6) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000],p = 3000000000) == 0\n assert candidate(nums = [11, 13, 17, 19, 23, 29],p = 101) == 1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],p = 13) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],p = 13) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66],p = 11) == 0\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],p = 3) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],p = 17) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],p = 13) == 1\n assert candidate(nums = [45, 54, 63, 72, 81, 90, 99, 108, 117, 126],p = 13) == 2\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],p = 3) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 3) == 1\n assert candidate(nums = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],p = 19) == 1\n assert candidate(nums = [8, 5, 6, 10, 8, 7, 3, 5, 8, 1, 2, 9, 4, 6, 5, 1, 3, 4, 7, 8],p = 5) == 0\n assert candidate(nums = [1000000007, 1000000007, 1000000007, 1000000007, 1000000007],p = 500000003) == -1\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],p = 5) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],p = 19) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],p = 1) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],p = 13) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],p = 101) == 6\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],p = 11) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],p = 7) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],p = 1000000007) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],p = 11) == 0\n assert candidate(nums = [8, 6, 4, 2, 0, 8, 6, 4, 2, 0, 8, 6, 4, 2, 0],p = 10) == 0\n assert candidate(nums = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],p = 26) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60],p = 25) == 1\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],p = 27) == 1\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],p = 5) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165],p = 17) == 1\n assert candidate(nums = [17, 23, 29, 31, 37, 41, 43, 47, 53, 59],p = 11) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],p = 11) == 0\n assert candidate(nums = [13, 23, 33, 43, 53, 63, 73, 83, 93, 103],p = 11) == 1\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1],p = 11) == 1\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10],p = 11) == 1\n assert candidate(nums = [2, 6, 3, 8, 7, 1, 5, 4, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],p = 17) == 1\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],p = 7) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 2) == 0\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444],p = 123456789) == 5\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111],p = 1000000007) == -1\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003],p = 4) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],p = 5) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 5) == 2\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],p = 100) == 5\n assert candidate(nums = [23, 32, 45, 65, 77, 88, 91, 103, 114, 125],p = 13) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 19) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 2) == 0\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993],p = 7) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],p = 13) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],p = 1000000007) == -1\n assert candidate(nums = [314159, 271828, 161803, 334993, 986264, 338327, 795028, 841971, 693993, 751058],p = 1234567) == -1\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000],p = 15000000000) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],p = 17) == -1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],p = 7) == 1\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],p = 5) == 0\n assert candidate(nums = [61, 57, 59, 55, 53, 67, 71, 61, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997],p = 53) == 1\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555],p = 1000000007) == -1\n assert candidate(nums = [123456789, 987654321, 246813579, 135792468, 111213141, 222324252, 333435363, 444546474, 555657585, 666768696],p = 1000000009) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums", "p"], "leetcode_dataset_entry_point": "Solution().minSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minSubarray(self, nums: list[int], p: int) -> int:", "container": "Solution", "callable": "minSubarray", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "p", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1591, "task_id": "strange-printer-ii", "difficulty": "Hard", "problem_description": "There is a strange printer with the following two special requirements:\n\nOn each turn, the printer will print a solid rectangular pattern of a single color on the grid. This will cover up the existing colors in the rectangle.\nOnce the printer has used a color for the above operation, the same color cannot be used again.\n\nYou are given a m x n matrix targetGrid, where targetGrid[row][col] is the color in the position (row, col) of the grid.\nReturn true if it is possible to print the matrix targetGrid, otherwise, return false.\n \nExample 1:\n\n\nInput: targetGrid = [[1,1,1,1],[1,2,2,1],[1,2,2,1],[1,1,1,1]]\nOutput: true\n\nExample 2:\n\n\nInput: targetGrid = [[1,1,1,1],[1,1,3,3],[1,1,3,4],[5,5,1,4]]\nOutput: true\n\nExample 3:\n\nInput: targetGrid = [[1,2,1],[2,1,2],[1,2,1]]\nOutput: false\nExplanation: It is impossible to form targetGrid because it is not allowed to print the same color in different turns.\n\n \nConstraints:\n\nm == targetGrid.length\nn == targetGrid[i].length\n1 <= m, n <= 60\n1 <= targetGrid[row][col] <= 60\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(targetGrid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 2, 1], [1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 1], [2, 1, 2], [1, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1], [1, 1, 3, 3], [1, 1, 3, 4], [5, 5, 1, 4]]) == True\n assert candidate(targetGrid = [[1, 2, 1, 4], [2, 1, 4, 1], [1, 4, 1, 2], [4, 1, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 1], [1, 1], [2, 2], [2, 2]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 2, 1], [2, 3, 4, 3, 2], [3, 4, 5, 4, 3], [2, 3, 4, 3, 2], [1, 2, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 3], [2, 3, 3, 4], [2, 3, 3, 4], [1, 2, 2, 3]]) == False\n assert candidate(targetGrid = [[1, 1, 2, 2, 3, 3, 4, 4], [1, 1, 2, 2, 3, 3, 4, 4], [1, 1, 2, 2, 3, 3, 4, 4], [5, 5, 6, 6, 7, 7, 8, 8], [5, 5, 6, 6, 7, 7, 8, 8], [5, 5, 6, 6, 7, 7, 8, 8], [5, 5, 6, 6, 7, 7, 8, 8], [5, 5, 6, 6, 7, 7, 8, 8]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 3], [1, 4, 1, 5, 2, 3], [1, 4, 6, 5, 2, 3], [1, 4, 6, 5, 2, 3], [1, 4, 1, 5, 2, 3], [1, 1, 1, 2, 2, 3]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1], [3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3], [5, 6, 1, 2, 3, 4], [6, 1, 2, 3, 4, 5]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 3, 4, 3, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7], [2, 1, 2, 3, 4, 5, 6], [3, 2, 1, 2, 3, 4, 5], [4, 3, 2, 1, 2, 3, 4], [5, 4, 3, 2, 1, 2, 3], [6, 5, 4, 3, 2, 1, 2], [7, 6, 5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6], [2, 1, 4, 5, 6, 3], [3, 4, 1, 6, 5, 2], [4, 5, 6, 1, 2, 3], [5, 6, 2, 3, 1, 4], [6, 3, 5, 4, 3, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7], [2, 1, 3, 4, 5, 6, 7], [3, 2, 1, 4, 5, 6, 7], [4, 3, 2, 1, 5, 6, 7], [5, 4, 3, 2, 1, 6, 7], [6, 5, 4, 3, 2, 1, 7], [7, 6, 5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 2], [1, 3, 1, 3, 3, 2], [1, 3, 1, 3, 3, 2], [1, 1, 1, 2, 2, 2], [1, 3, 3, 3, 3, 3], [1, 3, 3, 3, 3, 3]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5], [5, 1, 2, 3, 4], [4, 5, 1, 2, 3], [3, 4, 5, 1, 2], [2, 3, 4, 5, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 2, 2, 2], [2, 3, 3, 3, 3, 2], [2, 3, 4, 4, 3, 2], [2, 3, 4, 4, 3, 2], [2, 3, 3, 3, 3, 2], [2, 2, 2, 2, 2, 2]]) == True\n assert candidate(targetGrid = [[1, 2, 2, 1, 1], [2, 3, 3, 2, 2], [2, 3, 3, 2, 2], [1, 2, 2, 1, 1], [5, 5, 5, 5, 5]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 2, 3, 3, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [4, 4, 4, 5, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 5, 6, 6, 6], [7, 7, 7, 8, 8, 8, 9, 9, 9], [7, 7, 7, 8, 8, 8, 9, 9, 9]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1, 2, 2, 2, 2], [1, 2, 2, 2, 2, 2, 2, 2], [1, 2, 3, 3, 3, 3, 2, 2], [1, 2, 3, 4, 4, 3, 2, 2], [1, 2, 3, 4, 4, 3, 2, 2], [1, 2, 3, 3, 3, 3, 2, 2], [1, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 2, 2, 2, 2]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5], [2, 1, 4, 5, 3], [3, 4, 1, 2, 5], [4, 5, 2, 3, 1], [5, 3, 1, 4, 2]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 3], [2, 4, 4, 3], [2, 4, 4, 3], [1, 2, 2, 3]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 3, 1], [1, 2, 2, 3, 1], [4, 5, 5, 6, 4], [4, 5, 5, 6, 4], [7, 8, 8, 9, 7]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7]]) == True\n assert candidate(targetGrid = [[5, 5, 5, 5, 5], [5, 6, 6, 6, 5], [5, 6, 7, 6, 5], [5, 6, 6, 6, 5], [5, 5, 5, 5, 5]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7], [7, 1, 2, 3, 4, 5, 6], [6, 7, 1, 2, 3, 4, 5], [5, 6, 7, 1, 2, 3, 4], [4, 5, 6, 7, 1, 2, 3], [3, 4, 5, 6, 7, 1, 2], [2, 3, 4, 5, 6, 7, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 2, 2, 2], [2, 1, 3, 3, 3, 2], [2, 1, 3, 4, 3, 2], [2, 1, 3, 3, 3, 2], [2, 2, 2, 2, 2, 2]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 2, 1], [2, 3, 3, 2], [2, 3, 3, 2], [1, 2, 2, 1], [1, 2, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5], [2, 1, 2, 3, 4], [3, 2, 1, 2, 3], [4, 3, 2, 1, 2], [5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 2, 2, 3, 3], [1, 1, 2, 2, 3, 3], [1, 1, 4, 4, 5, 5], [1, 1, 4, 4, 5, 5], [6, 6, 6, 6, 6, 6], [6, 6, 6, 6, 6, 6]]) == True\n assert candidate(targetGrid = [[1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4], [3, 3, 3, 4, 4, 4], [5, 5, 5, 6, 6, 6], [5, 5, 5, 6, 6, 6]]) == True\n assert candidate(targetGrid = [[1, 1, 2, 2, 2, 3], [1, 4, 4, 4, 2, 3], [1, 4, 5, 4, 2, 3], [1, 4, 5, 4, 2, 3], [1, 1, 5, 5, 2, 3], [1, 1, 5, 5, 2, 3]]) == False\n assert candidate(targetGrid = [[5, 5, 5, 5, 5, 5], [5, 6, 6, 6, 6, 5], [5, 6, 7, 7, 6, 5], [5, 6, 7, 7, 6, 5], [5, 6, 6, 6, 6, 5], [5, 5, 5, 5, 5, 5]]) == True\n assert candidate(targetGrid = [[1, 2, 2, 1], [1, 1, 2, 2], [1, 2, 2, 1], [1, 1, 2, 2], [1, 2, 2, 1], [1, 1, 2, 2]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 2, 2, 2], [1, 2, 2, 2, 1, 2, 2, 2], [1, 2, 3, 3, 1, 2, 2, 2], [1, 2, 3, 3, 1, 2, 2, 2], [1, 1, 1, 1, 1, 2, 2, 2], [4, 4, 4, 4, 4, 5, 5, 5], [4, 4, 6, 6, 4, 5, 5, 5], [4, 4, 6, 6, 4, 5, 5, 5]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 1, 1], [2, 3, 3, 2, 1], [2, 3, 3, 2, 1], [1, 2, 2, 1, 1], [1, 1, 1, 1, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 1, 1, 1], [2, 1, 1, 1, 1, 2], [2, 1, 3, 3, 1, 2], [2, 1, 3, 3, 1, 2], [2, 1, 1, 1, 1, 2], [1, 2, 2, 1, 1, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 2, 2, 3, 3], [1, 1, 2, 2, 3, 3], [4, 4, 5, 5, 6, 6], [4, 4, 5, 5, 6, 6], [7, 7, 8, 8, 9, 9], [7, 7, 8, 8, 9, 9]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 2, 2, 2, 2], [1, 1, 1, 1, 2, 2, 2, 2], [1, 1, 1, 1, 2, 2, 2, 2], [1, 1, 1, 1, 2, 2, 2, 2], [3, 3, 3, 3, 4, 4, 4, 4], [3, 3, 3, 3, 4, 4, 4, 4], [3, 3, 3, 3, 4, 4, 4, 4], [3, 3, 3, 3, 4, 4, 4, 4]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2], [1, 1, 1, 2, 2], [1, 1, 1, 2, 2], [3, 3, 3, 4, 4], [3, 3, 3, 4, 4]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 2, 3, 3, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [4, 4, 4, 5, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 5, 6, 6, 6], [7, 7, 7, 8, 8, 8, 9, 9, 9], [7, 7, 7, 8, 8, 8, 9, 9, 9], [7, 7, 7, 8, 8, 8, 9, 9, 9]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4], [3, 3, 3, 4, 4, 4], [3, 3, 3, 4, 4, 4]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2], [1, 1, 1, 2, 2], [3, 3, 3, 4, 4], [3, 3, 3, 4, 4], [5, 5, 5, 6, 6], [5, 5, 5, 6, 6]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 3, 3, 3], [1, 1, 1, 2, 2, 3, 3, 3], [1, 1, 1, 2, 2, 3, 3, 3], [4, 4, 4, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 6, 6, 6], [7, 7, 7, 8, 8, 9, 9, 9], [7, 7, 7, 8, 8, 9, 9, 9]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6], [6, 1, 2, 3, 4, 5], [5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 2, 2, 2], [1, 1, 3, 3, 3, 1], [1, 1, 3, 4, 3, 1], [1, 1, 3, 3, 3, 1], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 1, 1, 2], [2, 1, 2, 1, 2, 1], [2, 1, 1, 2, 1, 2], [1, 2, 2, 1, 1, 2], [1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2]]) == False\n"}, "metadata": {"canonical_parameter_names": ["targetGrid"], "leetcode_dataset_entry_point": "Solution().isPrintable", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def isPrintable(self, targetGrid: list[list[int]]) -> bool:", "container": "Solution", "callable": "isPrintable", "parameters": [{"name": "targetGrid", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1592, "task_id": "rearrange-spaces-between-words", "difficulty": "Easy", "problem_description": "You are given a string text of words that are placed among some number of spaces. Each word consists of one or more lowercase English letters and are separated by at least one space. It's guaranteed that text contains at least one word.\nRearrange the spaces so that there is an equal number of spaces between every pair of adjacent words and that number is maximized. If you cannot redistribute all the spaces equally, place the extra spaces at the end, meaning the returned string should be the same length as text.\nReturn the string after rearranging the spaces.\n \nExample 1:\n\nInput: text = \" this is a sentence \"\nOutput: \"this is a sentence\"\nExplanation: There are a total of 9 spaces and 4 words. We can evenly divide the 9 spaces between the words: 9 / (4-1) = 3 spaces.\n\nExample 2:\n\nInput: text = \" practice makes perfect\"\nOutput: \"practice makes perfect \"\nExplanation: There are a total of 7 spaces and 3 words. 7 / (3-1) = 3 spaces plus 1 extra space. We place this extra space at the end of the string.\n\n \nConstraints:\n\n1 <= text.length <= 100\ntext consists of lowercase English letters and ' '.\ntext contains at least one word.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \" leading and trailing spaces \") == \"leading and trailing spaces \"\n assert candidate(text = \"one\") == \"one\"\n assert candidate(text = \" a \") == \"a \"\n assert candidate(text = \"hello world\") == \"hello world\"\n assert candidate(text = \"example example example\") == \"example example example\"\n assert candidate(text = \"a b c d e\") == \"a b c d e\"\n assert candidate(text = \" this is a sentence \") == \"this is a sentence\"\n assert candidate(text = \"one two three\") == \"one two three\"\n assert candidate(text = \" multiple spaces here \") == \"multiple spaces here \"\n assert candidate(text = \"the quick brown fox\") == \"the quick brown fox \"\n assert candidate(text = \" a \") == \"a \"\n assert candidate(text = \"uneven spacing in text\") == \"uneven spacing in text \"\n assert candidate(text = \" hello world \") == \"hello world\"\n assert candidate(text = \" practice makes perfect\") == \"practice makes perfect \"\n assert candidate(text = \"two words\") == \"two words\"\n assert candidate(text = \"one two three four\") == \"one two three four\"\n assert candidate(text = \"a b\") == \"a b\"\n assert candidate(text = \" one two three four \") == \"one two three four \"\n assert candidate(text = \"a b\") == \"a b\"\n assert candidate(text = \" welcome to the jungle \") == \"welcome to the jungle \"\n assert candidate(text = \"a\") == \"a\"\n assert candidate(text = \"equal spaces\") == \"equal spaces\"\n assert candidate(text = \"a b c d e f g h i j\") == \"a b c d e f g h i j\"\n assert candidate(text = \"longerwordwithnospaces\") == \"longerwordwithnospaces\"\n assert candidate(text = \"word\") == \"word\"\n assert candidate(text = \"consecutive spaces should be handled\") == \"consecutive spaces should be handled\"\n assert candidate(text = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\") == \"a b c d e f g h i j k l m n o p q r s t u v w x y z\"\n assert candidate(text = \"equal spaces between words\") == \"equal spaces between words\"\n assert candidate(text = \" spaces before and after and in between \") == \"spaces before and after and in between \"\n assert candidate(text = \"equal spaces should be here\") == \"equal spaces should be here\"\n assert candidate(text = \" spaces before and after and in between \") == \"spaces before and after and in between \"\n assert candidate(text = \"spaces at the beginning and end of the sentence\") == \"spaces at the beginning and end of the sentence \"\n assert candidate(text = \" uneven spaces distribution is tricky \") == \"uneven spaces distribution is tricky \"\n assert candidate(text = \" a\") == \"a \"\n assert candidate(text = \"onewordwith trailing\") == \"onewordwith trailing\"\n assert candidate(text = \" uneven spacing everywhere \") == \"uneven spacing everywhere\"\n assert candidate(text = \"evenly distributed spaces are good for readability\") == \"evenly distributed spaces are good for readability\"\n assert candidate(text = \"one verylongwordthatwillnotgetsplit\") == \"one verylongwordthatwillnotgetsplit\"\n assert candidate(text = \"a b c d e\") == \"a b c d e \"\n assert candidate(text = \" equal spacing here \") == \"equal spacing here\"\n assert candidate(text = \"short longword verylongwordwithnospaces\") == \"short longword verylongwordwithnospaces\"\n assert candidate(text = \"a long sentence with more words to test the functionality\") == \"a long sentence with more words to test the functionality\"\n assert candidate(text = \"one two three four\") == \"one two three four\"\n assert candidate(text = \" singlewordwithmanyspacesbeforeandafterspaces \") == \"singlewordwithmanyspacesbeforeandafterspaces \"\n assert candidate(text = \"one two three four five six seven eight nine ten\") == \"one two three four five six seven eight nine ten\"\n assert candidate(text = \"tiny gaps\") == \"tiny gaps\"\n assert candidate(text = \" one two three four five six seven eight nine ten \") == \"one two three four five six seven eight nine ten \"\n assert candidate(text = \"averylongwordwithnospaces\") == \"averylongwordwithnospaces\"\n assert candidate(text = \"unequal spaces should be here with extra\") == \"unequal spaces should be here with extra\"\n assert candidate(text = \" spacesbeforeand spacesafter \") == \"spacesbeforeand spacesafter\"\n assert candidate(text = \"averylongwordandanotherlongwordandafewmorewords\") == \"averylongwordandanotherlongwordandafewmorewords\"\n assert candidate(text = \"this is a test with multiple spaces\") == \"this is a test with multiple spaces \"\n assert candidate(text = \" one two three four five six seven eight nine ten \") == \"one two three four five six seven eight nine ten \"\n assert candidate(text = \"leading oneword\") == \"leading oneword\"\n assert candidate(text = \"many spaces in the middle\") == \"many spaces in the middle \"\n assert candidate(text = \" singleword \") == \"singleword \"\n assert candidate(text = \"equal spaces between each\") == \"equal spaces between each\"\n assert candidate(text = \"testcase with varied spacing\") == \"testcase with varied spacing\"\n assert candidate(text = \" uneven spacing in this sentence \") == \"uneven spacing in this sentence \"\n assert candidate(text = \" verylongwordwithnospaces \") == \"verylongwordwithnospaces \"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \"equal equal equal equal\") == \"equal equal equal equal\"\n assert candidate(text = \"a very long sentence with multiple spaces between words to test the algorithm\") == \"a very long sentence with multiple spaces between words to test the algorithm \"\n assert candidate(text = \"onetwothreefourfivesixseveneightnineten\") == \"onetwothreefourfivesixseveneightnineten\"\n assert candidate(text = \"words with uneven spaces\") == \"words with uneven spaces \"\n assert candidate(text = \" many spaces around each word \") == \"many spaces around each word \"\n assert candidate(text = \"spaces at the beginning and the end \") == \"spaces at the beginning and the end \"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \" onewordwithspacesonbothends\") == \"onewordwithspacesonbothends \"\n assert candidate(text = \"equal spaces between words\") == \"equal spaces between words\"\n assert candidate(text = \"uneven spacing between words\") == \"uneven spacing between words \"\n assert candidate(text = \"spaces at the beginning and end spaces\") == \"spaces at the beginning and end spaces\"\n assert candidate(text = \" a b c d e f g \") == \"a b c d e f g \"\n assert candidate(text = \"lastwordwithaspaceattheend \") == \"lastwordwithaspaceattheend \"\n assert candidate(text = \"equal spacing between words\") == \"equal spacing between words\"\n assert candidate(text = \" spaces at the start and end \") == \"spaces at the start and end\"\n assert candidate(text = \"short words in here\") == \"short words in here\"\n assert candidate(text = \"shortwords\") == \"shortwords\"\n assert candidate(text = \"equal spaces should be here\") == \"equal spaces should be here \"\n assert candidate(text = \"a b c d e f g\") == \"a b c d e f g\"\n assert candidate(text = \"one twothree four five six seven\") == \"one twothree four five six seven\"\n assert candidate(text = \" onebigwordwith manyspaces and a few words\") == \"onebigwordwith manyspaces and a few words \"\n assert candidate(text = \"averylongword withaverylongword\") == \"averylongword withaverylongword\"\n assert candidate(text = \"no extra spaces\") == \"no extra spaces\"\n assert candidate(text = \" spacesatthestart\") == \"spacesatthestart \"\n assert candidate(text = \" one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen\") == \"one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen \"\n assert candidate(text = \"spacesattheend \") == \"spacesattheend \"\n assert candidate(text = \"many many many spaces\") == \"many many many spaces\"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \"onlyone\") == \"onlyone\"\n assert candidate(text = \"a a a a a a\") == \"a a a a a a\"\n assert candidate(text = \" extra spaces should go to the end\") == \"extra spaces should go to the end \"\n assert candidate(text = \" a b c d \") == \"a b c d \"\n assert candidate(text = \" singlewordwithmanyspaces\") == \"singlewordwithmanyspaces \"\n assert candidate(text = \"averylongword with spaces\") == \"averylongword with spaces \"\n assert candidate(text = \"equal spaces between words\") == \"equal spaces between words\"\n assert candidate(text = \"uneven spacing is tricky\") == \"uneven spacing is tricky\"\n assert candidate(text = \" singleword \") == \"singleword \"\n assert candidate(text = \"beginning spaces are here\") == \"beginning spaces are here\"\n assert candidate(text = \"justoneverylongwordwithoutspaces\") == \"justoneverylongwordwithoutspaces\"\n assert candidate(text = \" a b c d e f g h i j \") == \"a b c d e f g h i j \"\n assert candidate(text = \" one two three four \") == \"one two three four\"\n assert candidate(text = \"only one space\") == \"only one space\"\n assert candidate(text = \"longwordssubstitutingforspaceswhicharespacious\") == \"longwordssubstitutingforspaceswhicharespacious\"\n assert candidate(text = \"a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a\") == \"a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a\"\n assert candidate(text = \"verylongwordwithoutspaces\") == \"verylongwordwithoutspaces\"\n assert candidate(text = \"multiple spaces between words\") == \"multiple spaces between words \"\n assert candidate(text = \"singleword\") == \"singleword\"\n assert candidate(text = \"onewordwithspacesonbothends \") == \"onewordwithspacesonbothends \"\n assert candidate(text = \"uneven spaces at the end\") == \"uneven spaces at the end \"\n assert candidate(text = \"shorttext\") == \"shorttext\"\n assert candidate(text = \" firstwordwithaspaceatthebeginning\") == \"firstwordwithaspaceatthebeginning \"\n assert candidate(text = \"singlewordwithmanyspaces \") == \"singlewordwithmanyspaces \"\n assert candidate(text = \"short words\") == \"short words\"\n assert candidate(text = \"just one word in here\") == \"just one word in here\"\n assert candidate(text = \"verylongwordwithnospaces\") == \"verylongwordwithnospaces\"\n assert candidate(text = \"thisisaverylongword\") == \"thisisaverylongword\"\n assert candidate(text = \"just one word but many spaces\") == \"just one word but many spaces \"\n assert candidate(text = \"a \") == \"a \"\n assert candidate(text = \" spaces at the beginning and the end \") == \"spaces at the beginning and the end \"\n assert candidate(text = \" spaces at the end of the sentence \") == \"spaces at the end of the sentence \"\n assert candidate(text = \"a single word surrounded by spaces\") == \"a single word surrounded by spaces\"\n assert candidate(text = \" \") == \"\"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \" word with multiple spaces in between words \") == \"word with multiple spaces in between words \"\n assert candidate(text = \" justone \") == \"justone \"\n assert candidate(text = \"short longword evenlongerword\") == \"short longword evenlongerword\"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \"just one more test case\") == \"just one more test case\"\n assert candidate(text = \"a b c d e f g\") == \"a b c d e f g \"\n assert candidate(text = \"many many many many many\") == \"many many many many many\"\n assert candidate(text = \"many spaces at the end \") == \"many spaces at the end\"\n assert candidate(text = \"word1 word2word3word4word5\") == \"word1 word2word3word4word5\"\n assert candidate(text = \"multiple spaces between words\") == \"multiple spaces between words\"\n assert candidate(text = \"multiple spaces between words\") == \"multiple spaces between words \"\n"}, "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().reorderSpaces", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def reorderSpaces(self, text: str) -> str:", "container": "Solution", "callable": "reorderSpaces", "parameters": [{"name": "text", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1593, "task_id": "split-a-string-into-the-max-number-of-unique-substrings", "difficulty": "Medium", "problem_description": "Given a string s, return the maximum number of unique substrings that the given string can be split into.\nYou can split string s into any list of non-empty substrings, where the concatenation of the substrings forms the original string. However, you must split the substrings such that all of them are unique.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"ababccc\"\nOutput: 5\nExplanation: One way to split maximally is ['a', 'b', 'ab', 'c', 'cc']. Splitting like ['a', 'b', 'a', 'b', 'c', 'cc'] is not valid as you have 'a' and 'b' multiple times.\n\nExample 2:\n\nInput: s = \"aba\"\nOutput: 2\nExplanation: One way to split maximally is ['a', 'ba'].\n\nExample 3:\n\nInput: s = \"aa\"\nOutput: 1\nExplanation: It is impossible to split the string any further.\n\n \nConstraints:\n\n\n1 <= s.length <= 16\n\n\ns contains only lower case English letters.\n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaaabbbb\") == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"abac\") == 3\n assert candidate(s = \"abcdef\") == 6\n assert candidate(s = \"aaaaaaaab\") == 4\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"zzzzzzz\") == 3\n assert candidate(s = \"abcabcabc\") == 6\n assert candidate(s = \"abcabcabcabc\") == 7\n assert candidate(s = \"ababccc\") == 5\n assert candidate(s = \"zzzzzzzzzzzzzzzz\") == 5\n assert candidate(s = \"aa\") == 1\n assert candidate(s = \"abcabc\") == 4\n assert candidate(s = \"abcdabcd\") == 6\n assert candidate(s = \"xyzxyzxyz\") == 6\n assert candidate(s = \"noon\") == 3\n assert candidate(s = \"abacabad\") == 5\n assert candidate(s = \"banana\") == 4\n assert candidate(s = \"aba\") == 2\n assert candidate(s = \"zzzzzz\") == 3\n assert candidate(s = \"aabbcc\") == 4\n assert candidate(s = \"zabac\") == 4\n assert candidate(s = \"abcdabcdabcdabcd\") == 9\n assert candidate(s = \"abacaba\") == 4\n assert candidate(s = \"aabbccdd\") == 6\n assert candidate(s = \"abcdefg\") == 7\n assert candidate(s = \"xyxyxyxyxyxyxyxy\") == 7\n assert candidate(s = \"ababcabcabc\") == 7\n assert candidate(s = \"abacabacabacabac\") == 8\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 13\n assert candidate(s = \"xyzzyxzyxzy\") == 7\n assert candidate(s = \"ababababababababababababababababab\") == 10\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\") == 20\n assert candidate(s = \"hellohellohello\") == 9\n assert candidate(s = \"abacabadabacabad\") == 9\n assert candidate(s = \"repaid\") == 6\n assert candidate(s = \"aaaaabbbbccccdddd\") == 10\n assert candidate(s = \"abccbaabccba\") == 7\n assert candidate(s = \"redder\") == 4\n assert candidate(s = \"aabaaaabbaabaaab\") == 7\n assert candidate(s = \"abacaxabacaxabacax\") == 10\n assert candidate(s = \"optimization\") == 10\n assert candidate(s = \"aaaaaaaaaaaaaaa\") == 5\n assert candidate(s = \"xyzzyxzyxzyzyxzyz\") == 9\n assert candidate(s = \"kayak\") == 4\n assert candidate(s = \"abcdabcde\") == 7\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 26\n assert candidate(s = \"abababababababab\") == 7\n assert candidate(s = \"ababababababab\") == 6\n assert candidate(s = \"abababababab\") == 6\n assert candidate(s = \"zzzyzxzyzzzzzzzzzz\") == 7\n assert candidate(s = \"abcdefghijkabcdefghijk\") == 16\n assert candidate(s = \"abcabcabcabcabcabc\") == 9\n assert candidate(s = \"abcdefghijklmnop\") == 16\n assert candidate(s = \"level\") == 4\n assert candidate(s = \"ababababababababababababababababa\") == 10\n assert candidate(s = \"abcabcdabcdeabcde\") == 10\n assert candidate(s = \"abcdefghijjihgfedcba\") == 15\n assert candidate(s = \"aaaaaabbbbbbaaaaabbbbbbbaaaa\") == 11\n assert candidate(s = \"aabbaabbccddeeff\") == 11\n assert candidate(s = \"abacabadabacaba\") == 8\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\") == 9\n assert candidate(s = \"abcdabcdeabcdeabcd\") == 11\n assert candidate(s = \"abcdabcdaabbcc\") == 9\n assert candidate(s = \"abcdefgabcdefg\") == 10\n assert candidate(s = \"abcdeabcdeabcdeabcde\") == 11\n assert candidate(s = \"aabbaabbccdd\") == 8\n assert candidate(s = \"aabbccddeeffgg\") == 10\n assert candidate(s = \"detartrated\") == 8\n assert candidate(s = \"abcdefghij\") == 10\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(s = \"aaaabbbbccccdddd\") == 10\n assert candidate(s = \"aabacabadaba\") == 7\n assert candidate(s = \"abacabadabacabadabacabad\") == 11\n assert candidate(s = \"deified\") == 5\n assert candidate(s = \"noonnoonnoon\") == 6\n assert candidate(s = \"repaper\") == 5\n assert candidate(s = \"abbaabbaabba\") == 6\n assert candidate(s = \"bcbcbcbcbcbcbcbc\") == 7\n assert candidate(s = \"aaaaaaaaaaaaaaaa\") == 5\n assert candidate(s = \"abacdfgdcaba\") == 8\n assert candidate(s = \"abcdeabcdeabcde\") == 10\n assert candidate(s = \"abcdabcabcda\") == 8\n assert candidate(s = \"ababababab\") == 5\n assert candidate(s = \"abcdefgabcdefgabcdefg\") == 14\n assert candidate(s = \"rotor\") == 4\n assert candidate(s = \"abcdefghihgfedcba\") == 13\n assert candidate(s = \"racecar\") == 5\n assert candidate(s = \"abcdefghijabcdefghij\") == 15\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 10\n assert candidate(s = \"aabbccddeeffggzzzz\") == 13\n assert candidate(s = \"abcdefabcdefabcdefabcdef\") == 14\n assert candidate(s = \"aaaaabbbbccccddddeeeefffggg\") == 16\n assert candidate(s = \"reviled\") == 6\n assert candidate(s = \"abcdefghabcdefgh\") == 12\n assert candidate(s = \"aabbccddeeffgghh\") == 12\n assert candidate(s = \"zzzzyyyxxxwwwvvvuuu\") == 12\n assert candidate(s = \"mississippi\") == 7\n assert candidate(s = \"abcdeabcdeabcdeabc\") == 11\n assert candidate(s = \"abcabcabcaabbcc\") == 9\n assert candidate(s = \"abcabcabcabcabc\") == 8\n assert candidate(s = \"xyzzzyxyzzzyxyzzzyxyzzzy\") == 11\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxUniqueSplit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxUniqueSplit(self, s: str) -> int:", "container": "Solution", "callable": "maxUniqueSplit", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1594, "task_id": "maximum-non-negative-product-in-a-matrix", "difficulty": "Medium", "problem_description": "You are given a m x n matrix grid. Initially, you are located at the top-left corner (0, 0), and in each step, you can only move right or down in the matrix.\nAmong all possible paths starting from the top-left corner (0, 0) and ending in the bottom-right corner (m - 1, n - 1), find the path with the maximum non-negative product. The product of a path is the product of all integers in the grid cells visited along the path.\nReturn the maximum non-negative product modulo 109 + 7. If the maximum product is negative, return -1.\nNotice that the modulo is performed after getting the maximum product.\n \nExample 1:\n\n\nInput: grid = [[-1,-2,-3],[-2,-3,-3],[-3,-3,-2]]\nOutput: -1\nExplanation: It is not possible to get non-negative product in the path from (0, 0) to (2, 2), so return -1.\n\nExample 2:\n\n\nInput: grid = [[1,-2,1],[1,-2,1],[3,-4,1]]\nOutput: 8\nExplanation: Maximum non-negative product is shown (1 * 1 * -2 * -4 * 1 = 8).\n\nExample 3:\n\n\nInput: grid = [[1,3],[0,-4]]\nOutput: 0\nExplanation: Maximum non-negative product is shown (1 * 0 * -4 = 0).\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 15\n-4 <= grid[i][j] <= 4\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[-1, -2, -3], [-2, -3, -3], [-3, -3, -2]]) == -1\n assert candidate(grid = [[-1, 0], [-8, -2]]) == 0\n assert candidate(grid = [[-1, 0], [-2, -1]]) == 0\n assert candidate(grid = [[-4, 3], [-3, -4]]) == 48\n assert candidate(grid = [[0, 0], [0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[2, 3, 4], [0, 1, 5]]) == 120\n assert candidate(grid = [[-1, 2, -3], [-4, 5, -6], [-7, -8, 9]]) == 2016\n assert candidate(grid = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]]) == -1\n assert candidate(grid = [[-1, 2], [-3, 4]]) == 12\n assert candidate(grid = [[2, -3, 4], [-1, -2, 3], [1, 2, -5]]) == 360\n assert candidate(grid = [[1, -2, 1], [1, -2, 1], [3, -4, 1]]) == 8\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1], [1, 1]]) == 1\n assert candidate(grid = [[-1, 0], [-2, -3]]) == 0\n assert candidate(grid = [[1, 2], [3, 4]]) == 12\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 3], [0, -4]]) == 0\n assert candidate(grid = [[-4, -4], [-4, -4]]) == -1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 2016\n assert candidate(grid = [[-1, -4, -7], [-2, -5, -8], [-3, -6, -9]]) == -1\n assert candidate(grid = [[-1, 2, -3], [4, -5, 6], [-7, 8, -9]]) == -1\n assert candidate(grid = [[2, 3, -1, 4], [1, -2, 3, -3], [-4, 5, -6, 7], [-8, -9, 10, 11]]) == 59400\n assert candidate(grid = [[-2, -3, 0, -4], [-1, -2, -3, 1], [0, -1, -2, -3], [2, 3, 4, -5]]) == 1440\n assert candidate(grid = [[-1, 0, 1], [0, 0, 0], [1, 0, -1]]) == 0\n assert candidate(grid = [[-1, 0, 0, 0], [-1, 0, 0, 0], [-1, 0, 0, 0], [-1, 0, 0, 0]]) == 0\n assert candidate(grid = [[-1, 2, -3, 4, -5], [6, -7, 8, -9, 10], [11, -12, 13, -14, 15], [16, -17, 18, -19, 20], [21, -22, 23, -24, 25]]) == 450227165\n assert candidate(grid = [[-1, -1, -1, -1], [1, 1, 1, 1], [-1, -1, -1, -1], [1, 1, 1, 1]]) == 1\n assert candidate(grid = [[-4, 3, -2, 1], [2, -1, 3, -4], [3, -4, 2, 1], [4, 1, -3, 2]]) == 576\n assert candidate(grid = [[-3, 3, -4, 1], [2, -1, 2, -3], [-2, 3, -2, 1], [4, -4, 3, -3]]) == 1728\n assert candidate(grid = [[-1, 2, -3, 4, -5], [5, -6, 7, -8, 9], [-10, 11, -12, 13, -14], [15, -16, 17, -18, 19], [-20, 21, -22, 23, -24]]) == -1\n assert candidate(grid = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == -1\n assert candidate(grid = [[-1, 0, 1, 0, -1], [-1, 1, 0, 1, -1], [0, -1, 1, -1, 0], [1, -1, 0, 1, -1], [-1, 0, 1, 0, -1]]) == 1\n assert candidate(grid = [[2, -2, 3, -3], [-3, 3, -2, 2], [2, -2, 3, -3], [-3, 3, -2, 2]]) == -1\n assert candidate(grid = [[-1, 3, -4, 2], [-2, 1, -1, 0], [3, -3, 2, -3], [4, 0, -1, 2]]) == 216\n assert candidate(grid = [[0, 1, 2, 3, 4, 5], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[-1, 0, 0, 0], [-2, 0, 0, 0], [-3, 0, 0, 0], [-4, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]) == 75000\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[-3, -2, 1], [-2, -1, 3], [-1, 3, -2]]) == 36\n assert candidate(grid = [[4, 3, 2, 1], [3, 2, 1, 0], [2, 1, 0, -1], [1, 0, -1, -2]]) == 0\n assert candidate(grid = [[-2, 0, 2, 0], [-1, -2, -3, -1], [0, 1, 0, 1], [2, -2, 1, -3]]) == 36\n assert candidate(grid = [[1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1]]) == 1\n assert candidate(grid = [[-1, 2, -3, 4], [-2, 3, -4, 5], [3, -4, 5, -6], [4, 5, -6, 7]]) == 5040\n assert candidate(grid = [[1, -1, 2, -3], [2, -2, 3, 4], [-3, 3, -4, 5], [0, -1, 2, -2]]) == 480\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == 1965600\n assert candidate(grid = [[-4, 3, 2, -1, 0], [0, 2, -3, 1, 4], [-1, 2, -1, 3, -2], [3, -2, 1, -1, 2], [1, -3, 2, -2, -4]]) == 4608\n assert candidate(grid = [[4, 3, 2, 1], [3, 2, 1, 0], [2, 1, 0, -1], [1, 0, -1, -2]]) == 0\n assert candidate(grid = [[-1, 2, 3, 4], [5, 6, -7, 8], [-9, 10, 11, -12], [13, -14, 15, 16]]) == 1188000\n assert candidate(grid = [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1]]) == -1\n assert candidate(grid = [[1, -2, 3, -4], [4, -1, 2, -3], [3, 2, -1, 4]]) == 144\n assert candidate(grid = [[4, -1, 2], [1, 2, -1], [2, -1, 4], [-1, 4, -1]]) == 32\n assert candidate(grid = [[1, -1, 0], [1, 0, 1], [0, 1, 1]]) == 0\n assert candidate(grid = [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0], [-1, -2, -3, -4, -5], [-5, -4, -3, -2, -1]]) == 0\n assert candidate(grid = [[0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, -1], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3]]) == 13608000\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 732633558\n assert candidate(grid = [[-1, 0, -1], [0, -1, 0], [-1, 0, -1]]) == 0\n assert candidate(grid = [[0, 0, 1], [0, -1, 0], [-1, 0, 0]]) == 0\n assert candidate(grid = [[-1, 0, 0, -1], [0, -1, 0, -1], [0, 0, -1, 0], [-1, 0, 0, -1]]) == 0\n assert candidate(grid = [[-1, -2, -3, -4], [-2, -3, -4, -5], [-3, -4, -5, -6], [-4, -5, -6, -7]]) == -1\n assert candidate(grid = [[-1, 2, -1, 3], [2, -3, 4, -2], [3, -1, -2, 2], [1, -3, 2, -1]]) == 96\n assert candidate(grid = [[4, -3, -2], [-2, 1, 0], [3, -5, 6]]) == 720\n assert candidate(grid = [[0, 3, 0, 4], [0, 0, 0, 0], [0, 4, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[-1, 2, -3, 4, -5], [2, -3, 4, -5, 6], [-3, 4, -5, 6, -7], [4, -5, 6, -7, 8], [-5, 6, -7, 8, -9]]) == -1\n assert candidate(grid = [[-1, 2, -3, 4], [-5, 6, -7, 8], [-9, 10, -11, 12], [-13, 14, -15, 16]]) == 1512000\n assert candidate(grid = [[1, -1, 0, 2], [-1, 2, 3, -1], [0, 1, -1, 1], [2, -2, 1, -3]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]) == 674358851\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[-4, -3, -2, -1], [-3, -2, -1, 0], [-2, -1, 0, 1], [-1, 0, 1, 2]]) == 0\n assert candidate(grid = [[-2, -3, -4], [-1, -5, -6], [-7, -8, -9]]) == -1\n assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]) == 362880\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == 5040\n assert candidate(grid = [[-1, -2, -3, -4, -5], [-2, -3, -4, -5, -6], [-3, -4, -5, -6, -7], [-4, -5, -6, -7, -8], [-5, -6, -7, -8, -9]]) == -1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == 36960\n assert candidate(grid = [[1, -1, 2, -2, 3, -3], [4, -4, 5, -5, 6, -6], [7, -7, 8, -8, 9, -9], [10, -10, 11, -11, 12, -12], [13, -13, 14, -14, 15, -15]]) == 605239993\n assert candidate(grid = [[-1, -2, -3, -4], [-2, -3, -3, -4], [-3, -4, -5, -6], [-4, -5, -6, -7]]) == -1\n assert candidate(grid = [[1, -2, 3, -4], [5, 6, -7, 8], [-9, 10, -11, 12], [13, -14, 15, -16]]) == 1008000\n assert candidate(grid = [[0, 1, 2, 3, 4], [1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8]]) == 0\n assert candidate(grid = [[-2, -3, 1, -4], [-3, -2, 1, 3], [-1, 2, -3, 1]]) == 72\n assert candidate(grid = [[4, -1, -2, 3], [-1, 2, 1, -1], [-2, -1, 3, 4], [1, -3, 2, 1]]) == 96\n assert candidate(grid = [[2, 3, 4, 5, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16], [17, 18, 19, 20, 21], [22, 23, 24, 25, 26]]) == 544121446\n assert candidate(grid = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]]) == 0\n assert candidate(grid = [[4, -4, 3, -3], [-3, 3, -2, 2], [2, -2, 3, -3], [-3, 3, -2, 2]]) == -1\n assert candidate(grid = [[-1, -2, -3, -4], [-4, -5, -6, -7], [-8, -9, -10, -11], [-12, -13, -14, -15]]) == -1\n assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]) == 362880\n assert candidate(grid = [[-4, -3, -2, -1], [1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]) == 8640\n assert candidate(grid = [[0, -1, 1], [1, -1, 0], [-1, 0, 1]]) == 0\n assert candidate(grid = [[-1, 2, -3, 4], [-4, 1, -2, 3], [2, -1, 4, -3], [3, 4, -1, 2]]) == 288\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 0\n assert candidate(grid = [[-2, -3, 0, -1], [-1, -2, -3, -4], [0, -1, -2, -3], [-3, -4, -5, -6]]) == 0\n assert candidate(grid = [[2, -1, 3, -4], [1, 0, 5, -1], [3, -2, 4, 1]]) == 30\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[4, -1, 2], [2, -3, 4], [-1, 2, -3]]) == 288\n assert candidate(grid = [[1, 2, 3], [-1, -2, -3], [1, 2, 3]]) == 36\n assert candidate(grid = [[-1, -2, -3], [-3, -4, -5], [-5, -6, -7]]) == -1\n assert candidate(grid = [[-1, 0, 1], [0, 1, 0], [1, 0, -1]]) == 0\n assert candidate(grid = [[-4, -3, -2], [-2, -1, 0], [3, -5, 6]]) == 360\n assert candidate(grid = [[-4, -4, -4, -4], [-4, -4, -4, -4], [-4, -4, -4, -4], [-4, -4, -4, -4]]) == -1\n assert candidate(grid = [[-2, 3, -1, 4], [-1, 2, -3, 5], [3, -4, 5, -6], [4, -5, 6, -7]]) == 10080\n assert candidate(grid = [[1, -1, 2, -4], [-2, 3, -1, 2], [4, -2, 3, -1], [-2, 1, -3, 4]]) == -1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 2016\n assert candidate(grid = [[2, -2, 3, 4, -1], [-1, 3, 2, 1, -2], [1, 2, -3, 2, -1], [3, 1, -2, -1, 2], [1, -2, 2, 1, -3]]) == 864\n assert candidate(grid = [[2, -3, 4, 5], [-1, 3, 2, -2], [2, -1, -2, -1], [1, 2, 3, -1]]) == 240\n assert candidate(grid = [[2, 3, 4], [1, 0, 1], [4, 3, 2], [3, 2, 1]]) == 48\n assert candidate(grid = [[-1, 3, -1, -4, 1], [-2, 1, 2, 3, -1], [3, -2, -1, 1, 2], [1, 2, -3, 4, -2]]) == 288\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == 5040\n assert candidate(grid = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15]]) == 674358851\n assert candidate(grid = [[-1, 2, -1, 3], [1, -2, 1, -1], [2, 1, -1, -3], [1, -1, -2, 1]]) == 18\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [1, 2, 3, 4, 5]]) == 72000\n assert candidate(grid = [[0, -1, -2, -3], [-1, 0, -1, -2], [-2, -1, 0, -1], [-3, -2, -1, 0]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maxProductPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxProductPath(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "maxProductPath", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1595, "task_id": "minimum-cost-to-connect-two-groups-of-points", "difficulty": "Hard", "problem_description": "You are given two groups of points where the first group has size1 points, the second group has size2 points, and size1 >= size2.\nThe cost of the connection between any two points are given in an size1 x size2 matrix where cost[i][j] is the cost of connecting point i of the first group and point j of the second group. The groups are connected if each point in both groups is connected to one or more points in the opposite group. In other words, each point in the first group must be connected to at least one point in the second group, and each point in the second group must be connected to at least one point in the first group.\nReturn the minimum cost it takes to connect the two groups.\n \nExample 1:\n\n\nInput: cost = [[15, 96], [36, 2]]\nOutput: 17\nExplanation: The optimal way of connecting the groups is:\n1--A\n2--B\nThis results in a total cost of 17.\n\nExample 2:\n\n\nInput: cost = [[1, 3, 5], [4, 1, 1], [1, 5, 3]]\nOutput: 4\nExplanation: The optimal way of connecting the groups is:\n1--A\n2--B\n2--C\n3--A\nThis results in a total cost of 4.\nNote that there are multiple points connected to point 2 in the first group and point A in the second group. This does not matter as there is no limit to the number of points that can be connected. We only care about the minimum total cost.\n\nExample 3:\n\nInput: cost = [[2, 5, 1], [3, 4, 7], [8, 1, 2], [6, 2, 4], [3, 8, 8]]\nOutput: 10\n\n \nConstraints:\n\nsize1 == cost.length\nsize2 == cost[i].length\n1 <= size1, size2 <= 12\nsize1 >= size2\n0 <= cost[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cost = [[2, 5, 1], [3, 4, 7], [8, 1, 2], [6, 2, 4], [3, 8, 8]]) == 10\n assert candidate(cost = [[1, 3, 5], [4, 1, 1], [1, 5, 3]]) == 4\n assert candidate(cost = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 16\n assert candidate(cost = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]) == 13\n assert candidate(cost = [[15, 96], [36, 2]]) == 17\n assert candidate(cost = [[10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]]) == 40\n assert candidate(cost = [[10, 20], [30, 40], [50, 60]]) == 100\n assert candidate(cost = [[5, 5, 5], [5, 5, 5]]) == 15\n"}, "metadata": {"canonical_parameter_names": ["cost"], "leetcode_dataset_entry_point": "Solution().connectTwoGroups", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def connectTwoGroups(self, cost: list[list[int]]) -> int:", "container": "Solution", "callable": "connectTwoGroups", "parameters": [{"name": "cost", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1598, "task_id": "crawler-log-folder", "difficulty": "Easy", "problem_description": "The Leetcode file system keeps a log each time some user performs a change folder operation.\nThe operations are described below:\n\n\"../\" : Move to the parent folder of the current folder. (If you are already in the main folder, remain in the same folder).\n\"./\" : Remain in the same folder.\n\"x/\" : Move to the child folder named x (This folder is guaranteed to always exist).\n\nYou are given a list of strings logs where logs[i] is the operation performed by the user at the ith step.\nThe file system starts in the main folder, then the operations in logs are performed.\nReturn the minimum number of operations needed to go back to the main folder after the change folder operations.\n \nExample 1:\n\n\nInput: logs = [\"d1/\",\"d2/\",\"../\",\"d21/\",\"./\"]\nOutput: 2\nExplanation: Use this change folder operation \"../\" 2 times and go back to the main folder.\n\nExample 2:\n\n\nInput: logs = [\"d1/\",\"d2/\",\"./\",\"d3/\",\"../\",\"d31/\"]\nOutput: 3\n\nExample 3:\n\nInput: logs = [\"d1/\",\"../\",\"../\",\"../\"]\nOutput: 0\n\n \nConstraints:\n\n1 <= logs.length <= 103\n2 <= logs[i].length <= 10\nlogs[i] contains lowercase English letters, digits, '.', and '/'.\nlogs[i] follows the format described in the statement.\nFolder names consist of lowercase English letters and digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(logs = ['d1/', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd21/', './']) == 2\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../', 'd4/', '../', 'd5/', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', '../', '../', '../', '../', 'd5/']) == 1\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', '../../..']) == 4\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../', 'd4/']) == 1\n assert candidate(logs = ['./', './', 'd1/']) == 1\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../', 'd4/', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', './', 'd3/', '../', 'd31/']) == 3\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd3/', 'd4/']) == 3\n assert candidate(logs = ['./', './', './']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/']) == 4\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', '../../../../']) == 5\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['../', '../', 'd1/']) == 1\n assert candidate(logs = ['./', './', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', '../', '../', '../', '../', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', './', './', 'd3/', 'd4/', 'd5/', '../', '../', '../', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['x1/', 'x2/', 'x3/', '../../', 'y1/', 'y2/', 'y3/', '../', 'z1/', 'z2/', '../', '../', '../']) == 4\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', '../../', '../', '../../', '../', '../../', '../', '../../', '../', '../', '../', '../']) == 2\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', './', './', './', '../', '../', '../', 'd6/', 'd7/', 'd8/', './', './', './', '../', '../', '../', 'd9/', 'd10/', 'd11/', './', './', './', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['./', './', './', 'folderA/', '../', 'folderB/', 'folderC/', '../', 'folderD/', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', './', 'd4/', '../', '../', 'd5/', '../', '../', 'd6/', '../', 'd7/', './', './', 'd8/', '../', '../', 'd9/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['deep1/', 'deep2/', 'deep3/', 'deep4/', 'deep5/', 'deep6/', 'deep7/', 'deep8/', 'deep9/', 'deep10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', '../', '../', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', 'd6/', 'd7/', '../', '../', 'd8/', 'd9/', '../', '../', 'd10/', 'd11/', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', '../', '../', '../', 'd6/', 'd7/', 'd8/', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['./', './', './', 'd1/', '../', 'd2/', '../', '../', 'd3/', '../', '../', 'd4/', '../', '../', 'd5/', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', './', './', './', '../', '../', '../', 'd5/', 'd6/', 'd7/', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', './', 'd4/', 'd5/', './', '../', 'd6/', 'd7/', './', '../', 'd8/', 'd9/', './', '../', 'd10/', 'd11/', './', '../', '../', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', 'd6/', '../', 'd7/', '../', '../', 'd8/', 'd9/', '../', '../', 'd10/', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', './', './', './', '../', '../', 'd6/', 'd7/', 'd8/', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', './', './', './', '../', 'd3/', 'd4/', '../', '../', '../', '../', '../', './', './', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', './', 'd3/', 'd4/', '../', '../', 'd5/', 'd6/', '../', '../', '../', 'd7/']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', 'd6/', 'd7/', '../', '../', '../', 'd8/']) == 2\n assert candidate(logs = ['folder1/', 'folder2/', '../', 'folder3/', 'folder4/', 'folder5/', 'folder6/', '../../', 'folder7/', 'folder8/', '../', '../', '../', '../', '../']) == 2\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', '../', 'd6/', 'd7/', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', 'd6/', 'd7/', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd21/', '../', 'd211/', '../', '../', 'd2111/', '../', '../', '../', '../', 'd21111/', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', 'd4/', 'd5/', '../', '../', 'd6/', 'd7/', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', './', './', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', './', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', 'd4/', 'd5/', '../', '../', 'd6/', 'd7/', '../', '../', '../', 'd8/', 'd9/', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', './', 'd2/', 'd3/', '../', 'd4/', 'd5/', 'd6/', 'd7/', '../', '../', '../', '../', '../', '../', 'd8/', 'd9/', 'd10/', 'd11/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', '../', '../', 'd4/', 'd5/', 'd6/', 'd7/', '../', '../', 'd8/', 'd9/', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', './', 'd4/', '../', 'd5/', '../', 'd6/', './', '../', 'd7/', '../', '../', 'd8/', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', '../../', '../../', '../', '../', '../', '../', '../']) == 4\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd1/', 'd2/', 'd3/', '../', '../', 'd1/', 'd2/', 'd3/', '../', '../', 'd1/', 'd2/', 'd3/', '../', '../', '../', '../']) == 2\n assert candidate(logs = ['a/', 'b/', '../', 'c/', './', 'd/', '../', 'e/', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', '../', '../', 'd1/', 'd2/', 'd3/', '../', '../', '../', '../', '../', 'd4/', 'd5/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../../', '../../', '../../', '../../', '../../', '../../', '../../', '../../', '../../', '../../']) == 10\n assert candidate(logs = ['main/', 'sub1/', 'sub2/', 'sub3/', 'sub4/', 'sub5/', 'sub6/', 'sub7/', 'sub8/', 'sub9/', 'sub10/', '../../../../../../', '../']) == 10\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', './', 'd2/', '../', 'd3/', './', 'd4/', '../', 'd5/', './', 'd6/', '../', 'd7/', './', 'd8/', '../', 'd9/', './', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', '../', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../']) == 0\n assert candidate(logs = ['alpha/', 'beta/', 'gamma/', './', 'delta/', 'epsilon/', 'zeta/', 'eta/', 'theta/', 'iota/', 'kappa/', 'lambda/', 'mu/', 'nu/', 'xi/', 'omicron/', 'pi/', 'rho/', 'sigma/', 'tau/', 'upsilon/', 'phi/', 'chi/', 'psi/', 'omega/', '../../../../../../../../../', '../', '../', '../', '../']) == 20\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../', 'd4/', '../', 'd5/', '../', 'd6/', '../', 'd7/', '../', 'd8/', '../', 'd9/', '../', 'd10/', '../', 'd11/', '../', 'd12/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', './', './', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', '../../', './', '../../', 'd9/', 'd10/', 'd11/', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../../../../..']) == 10\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', './', 'd6/', '../', 'd7/', 'd8/', 'd9/', 'd10/', './', './', '../', '../', '../', 'd11/', 'd12/', '../', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', '../', '../', '../', '../', '../', 'd6/', 'd7/', '../', 'd8/', '../', 'd9/', 'd10/', '../', '../', '../', '../', '../', 'd11/', 'd12/', 'd13/', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['./', '../', './', 'd1/', 'd2/', '../', './', 'd21/', '../', './', 'd211/', '../', './', 'd2111/', '../', './', 'd21111/', '../', './', '../', './']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', 'd6/', '../', '../', '../', '../', 'd7/', 'd8/', 'd9/']) == 4\n assert candidate(logs = ['d1/', 'd2/', '../', '../', './', 'd3/', 'd4/', '../', 'd5/', 'd6/', '../', 'd7/', './', '../', '../', '../', 'd8/']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', './', './', './', '../', '../', '../', '../', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', './', './', './', './', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', './', 'd4/', 'd5/', '../', '../', 'd6/', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n"}, "metadata": {"canonical_parameter_names": ["logs"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minOperations(self, logs: list[str]) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "logs", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1599, "task_id": "maximum-profit-of-operating-a-centennial-wheel", "difficulty": "Medium", "problem_description": "You are the operator of a Centennial Wheel that has four gondolas, and each gondola has room for up to four people. You have the ability to rotate the gondolas counterclockwise, which costs you runningCost dollars.\nYou are given an array customers of length n where customers[i] is the number of new customers arriving just before the ith rotation (0-indexed). This means you must rotate the wheel i times before the customers[i] customers arrive. You cannot make customers wait if there is room in the gondola. Each customer pays boardingCost dollars when they board on the gondola closest to the ground and will exit once that gondola reaches the ground again.\nYou can stop the wheel at any time, including before serving all customers. If you decide to stop serving customers, all subsequent rotations are free in order to get all the customers down safely. Note that if there are currently more than four customers waiting at the wheel, only four will board the gondola, and the rest will wait for the next rotation.\nReturn the minimum number of rotations you need to perform to maximize your profit. If there is no scenario where the profit is positive, return -1.\n \nExample 1:\n\n\nInput: customers = [8,3], boardingCost = 5, runningCost = 6\nOutput: 3\nExplanation: The numbers written on the gondolas are the number of people currently there.\n1. 8 customers arrive, 4 board and 4 wait for the next gondola, the wheel rotates. Current profit is 4 * $5 - 1 * $6 = $14.\n2. 3 customers arrive, the 4 waiting board the wheel and the other 3 wait, the wheel rotates. Current profit is 8 * $5 - 2 * $6 = $28.\n3. The final 3 customers board the gondola, the wheel rotates. Current profit is 11 * $5 - 3 * $6 = $37.\nThe highest profit was $37 after rotating the wheel 3 times.\n\nExample 2:\n\nInput: customers = [10,9,6], boardingCost = 6, runningCost = 4\nOutput: 7\nExplanation:\n1. 10 customers arrive, 4 board and 6 wait for the next gondola, the wheel rotates. Current profit is 4 * $6 - 1 * $4 = $20.\n2. 9 customers arrive, 4 board and 11 wait (2 originally waiting, 9 newly waiting), the wheel rotates. Current profit is 8 * $6 - 2 * $4 = $40.\n3. The final 6 customers arrive, 4 board and 13 wait, the wheel rotates. Current profit is 12 * $6 - 3 * $4 = $60.\n4. 4 board and 9 wait, the wheel rotates. Current profit is 16 * $6 - 4 * $4 = $80.\n5. 4 board and 5 wait, the wheel rotates. Current profit is 20 * $6 - 5 * $4 = $100.\n6. 4 board and 1 waits, the wheel rotates. Current profit is 24 * $6 - 6 * $4 = $120.\n7. 1 boards, the wheel rotates. Current profit is 25 * $6 - 7 * $4 = $122.\nThe highest profit was $122 after rotating the wheel 7 times.\n\nExample 3:\n\nInput: customers = [3,4,0,5,1], boardingCost = 1, runningCost = 92\nOutput: -1\nExplanation:\n1. 3 customers arrive, 3 board and 0 wait, the wheel rotates. Current profit is 3 * $1 - 1 * $92 = -$89.\n2. 4 customers arrive, 4 board and 0 wait, the wheel rotates. Current profit is 7 * $1 - 2 * $92 = -$177.\n3. 0 customers arrive, 0 board and 0 wait, the wheel rotates. Current profit is 7 * $1 - 3 * $92 = -$269.\n4. 5 customers arrive, 4 board and 1 waits, the wheel rotates. Current profit is 11 * $1 - 4 * $92 = -$357.\n5. 1 customer arrives, 2 board and 0 wait, the wheel rotates. Current profit is 13 * $1 - 5 * $92 = -$447.\nThe profit was never positive, so return -1.\n\n \nConstraints:\n\nn == customers.length\n1 <= n <= 105\n0 <= customers[i] <= 50\n1 <= boardingCost, runningCost <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(customers = [50, 50, 50, 50, 50],boardingCost = 100,runningCost = 1) == 63\n assert candidate(customers = [5, 5, 0, 8, 2],boardingCost = 6,runningCost = 3) == 6\n assert candidate(customers = [0, 0, 0, 0, 0],boardingCost = 1,runningCost = 1) == -1\n assert candidate(customers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boardingCost = 1,runningCost = 2) == -1\n assert candidate(customers = [0, 0, 0, 0],boardingCost = 10,runningCost = 5) == -1\n assert candidate(customers = [10, 9, 6],boardingCost = 6,runningCost = 4) == 7\n assert candidate(customers = [0, 0, 0, 0],boardingCost = 10,runningCost = 1) == -1\n assert candidate(customers = [8, 3],boardingCost = 5,runningCost = 6) == 3\n assert candidate(customers = [0, 0, 0, 0, 0],boardingCost = 1,runningCost = 10) == -1\n assert candidate(customers = [0, 0, 0, 0, 0],boardingCost = 5,runningCost = 1) == -1\n assert candidate(customers = [50, 50, 50, 50],boardingCost = 2,runningCost = 1) == 50\n assert candidate(customers = [50, 50, 50, 50, 50],boardingCost = 10,runningCost = 1) == 63\n assert candidate(customers = [3, 4, 0, 5, 1],boardingCost = 1,runningCost = 92) == -1\n assert candidate(customers = [5, 5, 0, 8, 7, 1, 4, 7, 3, 23],boardingCost = 43,runningCost = 59) == 16\n assert candidate(customers = [10, 10, 10, 10, 10],boardingCost = 5,runningCost = 4) == 13\n assert candidate(customers = [50, 50, 50, 50, 50],boardingCost = 100,runningCost = 50) == 63\n assert candidate(customers = [49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49],boardingCost = 1,runningCost = 1) == 343\n assert candidate(customers = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0],boardingCost = 5,runningCost = 3) == 13\n assert candidate(customers = [0, 10, 0, 10, 0, 10, 0, 10, 0, 10],boardingCost = 1,runningCost = 99) == -1\n assert candidate(customers = [50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0],boardingCost = 10,runningCost = 20) == 125\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],boardingCost = 1,runningCost = 2) == 54\n assert candidate(customers = [10, 0, 0, 10, 0, 0, 10, 0, 0, 10],boardingCost = 6,runningCost = 4) == 12\n assert candidate(customers = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],boardingCost = 3,runningCost = 15) == -1\n assert candidate(customers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],boardingCost = 2,runningCost = 1) == 13\n assert candidate(customers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 100],boardingCost = 5,runningCost = 4) == 34\n assert candidate(customers = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20],boardingCost = 5,runningCost = 8) == 50\n assert candidate(customers = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],boardingCost = 2,runningCost = 3) == 53\n assert candidate(customers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boardingCost = 1,runningCost = 1) == -1\n assert candidate(customers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boardingCost = 10,runningCost = 5) == 138\n assert candidate(customers = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100],boardingCost = 5,runningCost = 1) == 35\n assert candidate(customers = [10, 20, 30, 40, 50],boardingCost = 50,runningCost = 1) == 38\n assert candidate(customers = [10, 20, 15, 5, 25],boardingCost = 4,runningCost = 7) == 19\n assert candidate(customers = [20, 10, 0, 30, 10, 0, 40, 10, 0, 50],boardingCost = 20,runningCost = 10) == 43\n assert candidate(customers = [30, 0, 10, 40, 20],boardingCost = 3,runningCost = 5) == 25\n assert candidate(customers = [50, 0, 50, 0, 50, 0, 50, 0, 50, 0],boardingCost = 10,runningCost = 5) == 63\n assert candidate(customers = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 100, 95, 85, 75, 65, 55, 45, 35, 25, 15, 5],boardingCost = 10,runningCost = 20) == 337\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boardingCost = 1,runningCost = 5) == -1\n assert candidate(customers = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],boardingCost = 1,runningCost = 1) == 10\n assert candidate(customers = [30, 20, 10, 0, 0, 0, 0, 0, 0, 0],boardingCost = 3,runningCost = 10) == 15\n assert candidate(customers = [45, 50, 55, 60, 65, 70, 75, 80, 85, 90],boardingCost = 15,runningCost = 12) == 169\n assert candidate(customers = [100, 0, 0, 0, 0, 0, 0, 0, 0, 0],boardingCost = 1,runningCost = 2) == 25\n assert candidate(customers = [10, 20, 30, 40, 50],boardingCost = 1,runningCost = 95) == -1\n assert candidate(customers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],boardingCost = 5,runningCost = 4) == 145\n assert candidate(customers = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25],boardingCost = 2,runningCost = 3) == 63\n assert candidate(customers = [100, 0, 0, 0, 0, 0, 0, 0, 0, 0],boardingCost = 10,runningCost = 90) == -1\n assert candidate(customers = [4, 3, 2, 1, 0, 0, 0, 0, 0, 0],boardingCost = 50,runningCost = 2) == 4\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boardingCost = 10,runningCost = 20) == 15\n assert candidate(customers = [40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40],boardingCost = 1,runningCost = 1) == 200\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boardingCost = 2,runningCost = 3) == 15\n assert candidate(customers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],boardingCost = 5,runningCost = 4) == 25\n assert candidate(customers = [2, 5, 3, 1, 4, 6, 2, 3, 5, 1, 4, 2, 3, 6, 5, 1, 4, 2, 3, 6, 5],boardingCost = 3,runningCost = 5) == 22\n assert candidate(customers = [15, 25, 35, 45, 55],boardingCost = 10,runningCost = 8) == 44\n assert candidate(customers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boardingCost = 5,runningCost = 4) == 20\n assert candidate(customers = [50, 25, 50, 25, 50, 25, 50, 25, 50, 25],boardingCost = 4,runningCost = 10) == 94\n assert candidate(customers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],boardingCost = 5,runningCost = 6) == -1\n"}, "metadata": {"canonical_parameter_names": ["customers", "boardingCost", "runningCost"], "leetcode_dataset_entry_point": "Solution().minOperationsMaxProfit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minOperationsMaxProfit(self, customers: list[int], boardingCost: int, runningCost: int) -> int:", "container": "Solution", "callable": "minOperationsMaxProfit", "parameters": [{"name": "customers", "type": "list[int]"}, {"name": "boardingCost", "type": "int"}, {"name": "runningCost", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1601, "task_id": "maximum-number-of-achievable-transfer-requests", "difficulty": "Hard", "problem_description": "We have n buildings numbered from 0 to n - 1. Each building has a number of employees. It's transfer season, and some employees want to change the building they reside in.\nYou are given an array requests where requests[i] = [fromi, toi] represents an employee's request to transfer from building fromi to building toi.\nAll buildings are full, so a list of requests is achievable only if for each building, the net change in employee transfers is zero. This means the number of employees leaving is equal to the number of employees moving in. For example if n = 3 and two employees are leaving building 0, one is leaving building 1, and one is leaving building 2, there should be two employees moving to building 0, one employee moving to building 1, and one employee moving to building 2.\nReturn the maximum number of achievable requests.\n \nExample 1:\n\n\nInput: n = 5, requests = [[0,1],[1,0],[0,1],[1,2],[2,0],[3,4]]\nOutput: 5\nExplantion: Let's see the requests:\nFrom building 0 we have employees x and y and both want to move to building 1.\nFrom building 1 we have employees a and b and they want to move to buildings 2 and 0 respectively.\nFrom building 2 we have employee z and they want to move to building 0.\nFrom building 3 we have employee c and they want to move to building 4.\nFrom building 4 we don't have any requests.\nWe can achieve the requests of users x and b by swapping their places.\nWe can achieve the requests of users y, a and z by swapping the places in the 3 buildings.\n\nExample 2:\n\n\nInput: n = 3, requests = [[0,0],[1,2],[2,1]]\nOutput: 3\nExplantion: Let's see the requests:\nFrom building 0 we have employee x and they want to stay in the same building 0.\nFrom building 1 we have employee y and they want to move to building 2.\nFrom building 2 we have employee z and they want to move to building 1.\nWe can achieve all the requests. \nExample 3:\n\nInput: n = 4, requests = [[0,3],[3,1],[1,2],[2,0]]\nOutput: 4\n\n \nConstraints:\n\n1 <= n <= 20\n1 <= requests.length <= 16\nrequests[i].length == 2\n0 <= fromi, toi < n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == 6\n assert candidate(n = 4,requests = [[0, 1], [1, 0], [0, 2], [2, 0], [0, 3], [3, 0]]) == 6\n assert candidate(n = 4,requests = [[0, 3], [3, 1], [1, 2], [2, 0]]) == 4\n assert candidate(n = 3,requests = [[0, 1], [1, 0], [0, 2], [2, 0]]) == 4\n assert candidate(n = 3,requests = [[0, 1], [1, 2], [2, 0], [0, 2]]) == 3\n assert candidate(n = 6,requests = [[0, 3], [3, 4], [4, 2], [2, 5], [5, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 7\n assert candidate(n = 3,requests = [[0, 0], [1, 2], [2, 1]]) == 3\n assert candidate(n = 2,requests = [[0, 0], [1, 1]]) == 2\n assert candidate(n = 3,requests = [[0, 1], [1, 0], [1, 2], [2, 1], [0, 2], [2, 0]]) == 6\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == 5\n assert candidate(n = 5,requests = [[0, 1], [1, 0], [0, 1], [1, 2], [2, 0], [3, 4]]) == 5\n assert candidate(n = 2,requests = [[0, 1], [1, 0]]) == 2\n assert candidate(n = 6,requests = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3], [4, 5], [5, 4], [5, 0], [0, 5], [0, 2], [2, 0], [1, 3], [3, 1]]) == 16\n assert candidate(n = 4,requests = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [2, 1], [1, 3], [3, 2], [0, 3], [3, 1]]) == 8\n assert candidate(n = 8,requests = [[0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [0, 7], [1, 6], [2, 5], [3, 4]]) == 8\n assert candidate(n = 4,requests = [[0, 1], [1, 0], [0, 2], [2, 0], [1, 3], [3, 1], [2, 3], [3, 2], [0, 3], [3, 0]]) == 10\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 3], [3, 6], [6, 2], [2, 5], [5, 1], [1, 4], [4, 0]]) == 14\n assert candidate(n = 10,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 0], [1, 3], [3, 5], [5, 7], [7, 9], [9, 1]]) == 20\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3], [2, 4], [3, 0], [4, 1], [0, 3], [1, 4], [2, 0], [3, 1], [4, 2]]) == 15\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [3, 6], [6, 1], [1, 4], [4, 7], [7, 2], [2, 5], [5, 0]]) == 16\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == 16\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 0], [5, 1], [0, 3], [1, 4], [2, 5], [3, 0], [4, 1], [5, 2], [0, 4], [1, 5], [2, 0], [3, 1], [4, 2], [5, 3]]) == 24\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 0], [5, 1]]) == 12\n assert candidate(n = 10,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 3], [3, 6], [6, 9], [9, 2], [2, 5], [5, 8], [8, 1], [1, 4], [4, 7], [7, 0]]) == 20\n assert candidate(n = 12,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 5], [5, 10], [10, 3]]) == 12\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == 18\n assert candidate(n = 4,requests = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [2, 1], [1, 3], [3, 2]]) == 7\n assert candidate(n = 4,requests = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [1, 3], [2, 0], [3, 1], [0, 3], [1, 0], [2, 1], [3, 2]]) == 12\n assert candidate(n = 20,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0]]) == 20\n assert candidate(n = 15,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0], [0, 7], [7, 14], [14, 7], [7, 0], [0, 7]]) == 19\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 3], [3, 6], [6, 3], [3, 0], [0, 3], [3, 0], [0, 6], [6, 0], [0, 3], [3, 0]]) == 17\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [3, 6], [1, 4], [4, 7], [2, 5], [5, 0]]) == 10\n assert candidate(n = 10,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 0]]) == 15\n assert candidate(n = 4,requests = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 1], [1, 2], [2, 3], [3, 0], [0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [1, 3], [2, 0], [3, 1], [0, 3], [1, 0], [2, 1], [3, 2]]) == 20\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [3, 1], [1, 4], [4, 2], [2, 5], [5, 3], [3, 6], [6, 4], [4, 7], [7, 5]]) == 15\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 3], [3, 2], [1, 4], [4, 0]]) == 9\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [2, 4], [4, 1], [1, 3], [3, 0]]) == 10\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 6], [1, 5], [2, 4]]) == 7\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 2], [2, 4], [4, 6], [6, 1], [1, 3], [3, 5], [5, 0]]) == 14\n assert candidate(n = 9,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == 18\n assert candidate(n = 12,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 6], [6, 3], [3, 9], [9, 5], [5, 1], [1, 7], [7, 10], [10, 4], [4, 8], [8, 2], [2, 11], [11, 0]]) == 24\n assert candidate(n = 15,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]]) == 15\n assert candidate(n = 5,requests = [[0, 1], [1, 0], [0, 2], [2, 0], [0, 3], [3, 0], [0, 4], [4, 0], [1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [2, 3], [3, 2], [2, 4], [4, 2], [3, 4], [4, 3]]) == 20\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3], [2, 4], [3, 0], [4, 1]]) == 10\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 0], [5, 1], [6, 2]]) == 20\n assert candidate(n = 4,requests = [[0, 1], [1, 0], [0, 2], [2, 0], [0, 3], [3, 0], [1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2]]) == 12\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == 10\n assert candidate(n = 5,requests = [[0, 1], [0, 2], [1, 0], [2, 0], [1, 2], [2, 1], [3, 4], [4, 3]]) == 8\n assert candidate(n = 6,requests = [[0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [0, 3], [3, 0], [1, 4], [4, 1], [2, 5], [5, 2]]) == 12\n assert candidate(n = 4,requests = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [1, 3], [2, 0], [3, 1]]) == 8\n assert candidate(n = 3,requests = [[0, 1], [1, 2], [2, 0], [0, 2], [1, 0], [2, 1], [0, 1], [1, 2], [2, 0]]) == 9\n assert candidate(n = 10,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == 10\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 2], [2, 4], [4, 6], [6, 1], [1, 3], [3, 5], [5, 7], [7, 0]]) == 16\n assert candidate(n = 6,requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == 12\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 4], [1, 3], [2, 0]]) == 5\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 0], [6, 1]]) == 14\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 3], [3, 1], [1, 4], [4, 2], [2, 5], [5, 3]]) == 11\n assert candidate(n = 10,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 1], [1, 3], [3, 5], [5, 7], [7, 9], [9, 1]]) == 19\n assert candidate(n = 8,requests = [[0, 7], [7, 1], [1, 6], [6, 2], [2, 5], [5, 3], [3, 4], [4, 0], [0, 2], [2, 4], [4, 6], [6, 0]]) == 12\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 2], [1, 3], [2, 4], [3, 5]]) == 12\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 3], [3, 1], [1, 4], [4, 2], [2, 5], [5, 0]]) == 12\n assert candidate(n = 10,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 10\n assert candidate(n = 15,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0], [0, 7], [7, 12], [12, 5]]) == 15\n assert candidate(n = 5,requests = [[0, 1], [0, 1], [1, 0], [1, 0], [0, 2], [2, 0], [1, 2], [2, 1], [0, 3], [3, 0], [1, 3], [3, 1], [2, 3], [3, 2], [0, 4], [4, 0], [1, 4], [4, 1], [2, 4], [4, 2], [3, 4], [4, 3]]) == 22\n assert candidate(n = 18,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 0], [0, 9], [9, 15], [15, 3]]) == 18\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 1], [6, 2], [7, 3]]) == 15\n assert candidate(n = 10,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 3], [3, 6], [6, 9]]) == 10\n assert candidate(n = 12,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 1], [11, 2]]) == 23\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == 10\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]]) == 13\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 2], [2, 4], [4, 1], [1, 3], [3, 5], [5, 3]]) == 10\n"}, "metadata": {"canonical_parameter_names": ["n", "requests"], "leetcode_dataset_entry_point": "Solution().maximumRequests", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumRequests(self, n: int, requests: list[list[int]]) -> int:", "container": "Solution", "callable": "maximumRequests", "parameters": [{"name": "n", "type": "int"}, {"name": "requests", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1604, "task_id": "alert-using-same-key-card-three-or-more-times-in-a-one-hour-period", "difficulty": "Medium", "problem_description": "LeetCode company workers use key-cards to unlock office doors. Each time a worker uses their key-card, the security system saves the worker's name and the time when it was used. The system emits an alert if any worker uses the key-card three or more times in a one-hour period.\nYou are given a list of strings keyName and keyTime where [keyName[i], keyTime[i]] corresponds to a person's name and the time when their key-card was used in a single day.\nAccess times are given in the 24-hour time format \"HH:MM\", such as \"23:51\" and \"09:49\".\nReturn a list of unique worker names who received an alert for frequent keycard use. Sort the names in ascending order alphabetically.\nNotice that \"10:00\" - \"11:00\" is considered to be within a one-hour period, while \"22:51\" - \"23:52\" is not considered to be within a one-hour period.\n \nExample 1:\n\nInput: keyName = [\"daniel\",\"daniel\",\"daniel\",\"luis\",\"luis\",\"luis\",\"luis\"], keyTime = [\"10:00\",\"10:40\",\"11:00\",\"09:00\",\"11:00\",\"13:00\",\"15:00\"]\nOutput: [\"daniel\"]\nExplanation: \"daniel\" used the keycard 3 times in a one-hour period (\"10:00\",\"10:40\", \"11:00\").\n\nExample 2:\n\nInput: keyName = [\"alice\",\"alice\",\"alice\",\"bob\",\"bob\",\"bob\",\"bob\"], keyTime = [\"12:01\",\"12:00\",\"18:00\",\"21:00\",\"21:20\",\"21:30\",\"23:00\"]\nOutput: [\"bob\"]\nExplanation: \"bob\" used the keycard 3 times in a one-hour period (\"21:00\",\"21:20\", \"21:30\").\n\n \nConstraints:\n\n1 <= keyName.length, keyTime.length <= 105\nkeyName.length == keyTime.length\nkeyTime[i] is in the format \"HH:MM\".\n[keyName[i], keyTime[i]] is unique.\n1 <= keyName[i].length <= 10\nkeyName[i] contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(keyName = ['daniel', 'daniel', 'daniel', 'luis', 'luis', 'luis', 'luis'],keyTime = ['10:00', '10:40', '11:00', '09:00', '11:00', '13:00', '15:00']) == ['daniel']\n assert candidate(keyName = ['amy', 'amy', 'amy', 'adam', 'adam', 'adam', 'adam'],keyTime = ['12:00', '12:05', '12:10', '09:00', '09:15', '09:30', '09:45']) == ['adam', 'amy']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'bob', 'bob', 'bob', 'bob'],keyTime = ['12:01', '12:00', '18:00', '21:00', '21:20', '21:30', '23:00']) == ['bob']\n assert candidate(keyName = ['john', 'john', 'john'],keyTime = ['09:15', '09:30', '10:00']) == ['john']\n assert candidate(keyName = ['amy', 'david', 'david'],keyTime = ['12:00', '12:00', '13:00']) == []\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['08:00', '08:20', '08:40', '09:00', '09:20']) == ['eve']\n assert candidate(keyName = ['chris', 'chris', 'chris'],keyTime = ['09:00', '09:30', '10:00']) == ['chris']\n assert candidate(keyName = ['john', 'john', 'john', 'john'],keyTime = ['09:00', '09:15', '09:30', '10:00']) == ['john']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['01:00', '01:10', '01:20', '02:00', '02:10']) == ['eve']\n assert candidate(keyName = ['john'],keyTime = ['00:00']) == []\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['23:58', '23:59', '00:00', '00:01', '00:02']) == ['eve']\n assert candidate(keyName = ['john', 'john', 'john', 'john'],keyTime = ['09:15', '09:45', '10:00', '10:30']) == ['john']\n assert candidate(keyName = ['anna', 'anna', 'anna', 'anna'],keyTime = ['10:00', '10:10', '10:20', '10:30']) == ['anna']\n assert candidate(keyName = ['alice', 'bob', 'alice'],keyTime = ['10:00', '10:10', '10:20']) == []\n assert candidate(keyName = ['mike', 'mike', 'mike', 'mike'],keyTime = ['00:00', '00:05', '00:10', '00:15']) == ['mike']\n assert candidate(keyName = ['anna', 'anna', 'bob', 'bob', 'bob'],keyTime = ['12:00', '12:05', '12:00', '12:05', '12:10']) == ['bob']\n assert candidate(keyName = ['amy', 'amy', 'amy', 'adam'],keyTime = ['08:00', '08:10', '08:20', '08:30']) == ['amy']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20', '09:30', '09:40', '09:50']) == ['grace']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['23:50', '00:00', '00:10', '00:20', '00:30', '00:40', '00:50', '01:00', '01:10', '01:20']) == ['grace']\n assert candidate(keyName = ['amy', 'amy', 'amy', 'amy', 'amy'],keyTime = ['08:00', '08:30', '09:00', '09:30', '10:00']) == ['amy']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'alice', 'alice'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40']) == ['alice']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['12:00', '12:15', '12:30', '12:45', '13:00', '13:15', '13:30']) == ['grace']\n assert candidate(keyName = ['karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen'],keyTime = ['01:00', '01:10', '01:20', '01:30', '01:40', '01:50', '02:00', '02:10']) == ['karen']\n assert candidate(keyName = ['carol', 'carol', 'carol', 'carol', 'carol', 'carol', 'carol'],keyTime = ['23:00', '23:15', '23:30', '23:45', '00:00', '00:15', '00:30']) == ['carol']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['23:55', '00:00', '00:01', '00:02', '00:03', '00:04']) == ['grace']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['10:00', '10:05', '10:10', '10:15', '10:20', '10:25', '10:30', '10:35', '10:40', '10:45', '10:50', '10:55', '11:00', '11:05', '11:10', '11:15', '11:20', '11:25', '11:30', '11:35', '11:40', '11:45', '11:50', '11:55', '12:00']) == ['hank']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40', '10:50']) == ['ivan']\n assert candidate(keyName = ['dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave'],keyTime = ['09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30']) == ['dave']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'alice', 'alice'],keyTime = ['09:00', '09:15', '09:30', '09:45', '10:00']) == ['alice']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['09:00', '09:01', '09:02', '09:03', '09:04', '09:05', '09:06', '09:07', '09:08', '09:09', '09:10', '09:11', '09:12', '09:13', '09:14', '09:15', '09:16', '09:17', '09:18', '09:19', '09:20', '09:21', '09:22', '09:23', '09:24']) == ['ivan']\n assert candidate(keyName = ['karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40', '10:50', '11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00']) == ['karen']\n assert candidate(keyName = ['leo', 'leo', 'leo', 'leo', 'leo', 'leo', 'leo', 'leo', 'leo'],keyTime = ['22:00', '22:10', '22:20', '22:30', '22:40', '22:50', '23:00', '23:10', '23:20']) == ['leo']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10']) == ['eve']\n assert candidate(keyName = ['max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35', '09:40', '09:45', '09:50', '09:55', '10:00']) == ['max']\n assert candidate(keyName = ['lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy'],keyTime = ['16:00', '16:05', '16:10', '16:15', '16:20', '16:25', '16:30']) == ['lucy']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['12:00', '12:20', '12:40', '13:00', '13:20', '13:40', '14:00']) == ['eve']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'bob', 'bob', 'bob', 'charlie', 'charlie', 'charlie'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:35', '09:40', '09:00', '09:55', '10:05']) == ['alice', 'bob']\n assert candidate(keyName = ['tom', 'jerry', 'tom', 'jerry', 'tom', 'jerry', 'tom', 'jerry'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35']) == ['jerry', 'tom']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'bob', 'bob', 'bob', 'bob', 'bob', 'charlie', 'charlie', 'charlie', 'charlie'],keyTime = ['08:59', '09:00', '09:01', '23:59', '00:01', '00:02', '00:03', '00:04', '10:00', '10:59', '11:00', '11:01']) == ['alice', 'bob', 'charlie']\n assert candidate(keyName = ['amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy'],keyTime = ['08:00', '08:15', '08:30', '08:45', '09:00', '09:15', '09:30', '09:45', '10:00', '10:15', '10:30']) == ['amy']\n assert candidate(keyName = ['david', 'david', 'david', 'david', 'david'],keyTime = ['08:00', '08:05', '08:10', '08:55', '09:00']) == ['david']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20', '09:30']) == ['eve']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30']) == ['ivan']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20']) == ['frank']\n assert candidate(keyName = ['david', 'david', 'david', 'david', 'david', 'david'],keyTime = ['09:00', '09:10', '09:20', '10:00', '10:10', '10:20']) == ['david']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00', '12:10', '12:20', '12:30', '12:40', '12:50', '13:00', '13:10', '13:20', '13:30', '13:40', '13:50', '14:00', '14:10']) == ['hank']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['23:00', '23:30', '00:00', '00:30', '01:00', '01:30']) == ['eve']\n assert candidate(keyName = ['lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy'],keyTime = ['12:00', '12:15', '12:30', '12:45', '13:00', '13:15', '13:30', '13:45']) == ['lucy']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['10:00', '10:15', '10:30', '10:45', '11:00', '11:15', '11:30', '11:45', '12:00', '12:15', '12:30', '12:45', '13:00', '13:15', '13:30', '13:45', '14:00', '14:15', '14:30', '14:45']) == ['grace']\n assert candidate(keyName = ['jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20']) == ['jane']\n assert candidate(keyName = ['judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy'],keyTime = ['11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00', '12:10', '12:20', '12:30', '12:40', '12:50', '13:00', '13:10', '13:20', '13:30', '13:40', '13:50', '14:00', '14:10']) == ['judy']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['08:00', '08:30', '09:00', '09:30', '10:00', '10:30', '11:00', '11:30']) == ['hank']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['08:50', '08:55', '09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35']) == ['eve']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['06:00', '06:15', '06:30', '06:45', '07:00', '07:15', '07:30', '07:45', '08:00', '08:15', '08:30', '08:45', '09:00', '09:15', '09:30', '09:45', '10:00', '10:15', '10:30']) == ['ivan']\n assert candidate(keyName = ['dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20']) == ['dave']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['23:50', '00:00', '00:10', '00:20', '00:30', '00:40', '00:50', '01:00', '01:10', '01:20', '01:30', '01:40', '01:50', '02:00', '02:10', '02:20']) == ['ivan']\n assert candidate(keyName = ['bob', 'bob', 'bob', 'bob', 'bob', 'bob'],keyTime = ['23:50', '00:05', '00:10', '00:15', '00:20', '00:25']) == ['bob']\n assert candidate(keyName = ['chris', 'chris', 'chris', 'chris', 'chris', 'chris'],keyTime = ['23:45', '00:00', '00:15', '00:30', '00:45', '01:00']) == ['chris']\n assert candidate(keyName = ['dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave'],keyTime = ['23:55', '00:00', '00:01', '00:02', '00:03', '00:04', '00:05']) == ['dave']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['09:00', '09:01', '09:02', '09:03', '09:04', '09:05']) == ['grace']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['08:00', '08:15', '08:30', '08:45', '09:00', '09:15', '09:30', '09:45', '10:00', '10:15', '10:30', '10:45', '11:00', '11:15']) == ['grace']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35', '09:40', '09:45']) == ['eve']\n assert candidate(keyName = ['charlie', 'charlie', 'charlie', 'charlie', 'charlie', 'charlie', 'charlie'],keyTime = ['12:00', '12:20', '12:40', '13:00', '13:20', '13:40', '14:00']) == ['charlie']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10']) == ['frank']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['10:00', '10:10', '10:20', '10:30', '10:40', '10:50', '11:00', '11:10', '11:20', '11:30']) == ['frank']\n assert candidate(keyName = ['alice', 'alice', 'bob', 'bob', 'bob', 'bob', 'bob'],keyTime = ['08:00', '08:05', '08:00', '08:10', '08:15', '08:20', '08:25']) == ['bob']\n assert candidate(keyName = ['bob', 'bob', 'bob', 'bob', 'bob', 'bob'],keyTime = ['09:00', '09:20', '09:40', '10:00', '10:20', '10:40']) == ['bob']\n assert candidate(keyName = ['emma', 'emma', 'emma', 'emma', 'emma'],keyTime = ['09:00', '09:15', '09:30', '09:45', '10:00']) == ['emma']\n assert candidate(keyName = ['daniel', 'daniel', 'daniel', 'daniel', 'daniel', 'daniel'],keyTime = ['10:00', '10:15', '10:30', '11:00', '11:15', '11:30']) == ['daniel']\n assert candidate(keyName = ['alice', 'bob', 'charlie', 'alice', 'bob', 'charlie'],keyTime = ['08:00', '08:05', '08:10', '08:15', '08:20', '08:25']) == []\n assert candidate(keyName = ['jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane'],keyTime = ['09:00', '09:01', '09:02', '09:03', '09:04', '09:05', '09:06', '09:07', '09:08', '09:09']) == ['jane']\n assert candidate(keyName = ['charlie', 'charlie', 'charlie', 'dave', 'dave', 'dave', 'dave'],keyTime = ['08:00', '08:10', '08:20', '12:00', '12:05', '12:10', '12:15']) == ['charlie', 'dave']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20']) == ['eve']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['12:00', '12:20', '12:40', '13:00', '13:20', '13:40', '14:00', '14:20', '14:40', '15:00']) == ['eve']\n assert candidate(keyName = ['alice', 'alice', 'bob', 'bob', 'charlie', 'charlie'],keyTime = ['12:00', '12:59', '13:00', '13:59', '14:00', '14:59']) == []\n assert candidate(keyName = ['heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi'],keyTime = ['23:50', '23:55', '00:00', '00:05', '00:10', '00:15', '00:20']) == ['heidi']\n assert candidate(keyName = ['tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20']) == ['tim']\n assert candidate(keyName = ['jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40', '10:50', '11:00', '11:10', '11:20', '11:30', '11:40']) == ['jill']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['12:00', '12:10', '12:20', '12:30', '12:40', '12:50', '13:00', '13:10', '13:20', '13:30', '13:40', '13:50', '14:00', '14:10']) == ['hank']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['07:00', '07:10', '07:20', '07:30', '07:40', '07:50', '08:00']) == ['ivan']\n assert candidate(keyName = ['charlie', 'david', 'david', 'charlie', 'david'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:35']) == ['david']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['09:00', '09:01', '09:02', '09:03', '09:04', '09:05']) == ['frank']\n assert candidate(keyName = ['heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi'],keyTime = ['11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00', '12:10', '12:20', '12:30', '12:40']) == ['heidi']\n assert candidate(keyName = ['heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi'],keyTime = ['07:00', '07:30', '08:00', '08:30', '09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30', '13:00', '13:30', '14:00']) == ['heidi']\n assert candidate(keyName = ['dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave'],keyTime = ['08:00', '08:30', '09:00', '09:30', '10:00', '10:30', '11:00']) == ['dave']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['23:00', '23:10', '23:20', '23:30', '23:40', '23:50', '00:00', '00:10', '00:20', '00:30', '00:40', '00:50', '01:00', '01:10', '01:20', '01:30']) == ['grace']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'alice', 'alice'],keyTime = ['08:00', '08:30', '09:00', '09:30', '10:00']) == ['alice']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['10:00', '10:10', '10:20', '10:30', '10:40', '10:50']) == ['eve']\n assert candidate(keyName = ['jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane'],keyTime = ['18:00', '18:10', '18:20', '18:30', '18:40', '18:50', '19:00']) == ['jane']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['00:00', '00:15', '00:30', '00:45', '01:00', '01:15', '01:30', '01:45', '02:00', '02:15', '02:30', '02:45', '03:00']) == ['frank']\n assert candidate(keyName = ['mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35', '09:40', '09:45', '09:50', '09:55', '10:00', '10:05', '10:10', '10:15', '10:20']) == ['mike']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35', '09:40', '09:45']) == ['ivan']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00', '12:10']) == ['ivan']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['09:00', '09:15', '09:30', '09:45', '10:00', '10:15', '10:30', '10:45', '11:00', '11:15', '11:30', '11:45']) == ['frank']\n assert candidate(keyName = ['frank', 'grace', 'heidi', 'frank', 'grace', 'heidi', 'frank', 'grace', 'heidi'],keyTime = ['10:00', '10:00', '10:00', '10:05', '10:05', '10:05', '10:10', '10:10', '10:10']) == ['frank', 'grace', 'heidi']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['09:00', '09:01', '09:02', '09:03', '09:04', '09:05', '09:06', '09:07', '09:08', '09:09', '09:10', '09:11', '09:12', '09:13', '09:14', '09:15', '09:16', '09:17', '09:18', '09:19', '09:20', '09:21', '09:22', '09:23', '09:24', '09:25', '09:26', '09:27', '09:28', '09:29', '09:30']) == ['ivan']\n assert candidate(keyName = ['daniel', 'daniel', 'daniel', 'daniel', 'daniel', 'daniel'],keyTime = ['09:00', '09:15', '09:30', '10:00', '10:15', '10:30']) == ['daniel']\n assert candidate(keyName = ['sam', 'sam', 'sam', 'sam', 'sam', 'sam', 'sam', 'sam', 'sam', 'sam'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30']) == ['sam']\n assert candidate(keyName = ['jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill'],keyTime = ['09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30', '13:00', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00', '18:30', '19:00', '19:30', '20:00', '20:30', '21:00', '21:30', '22:00', '22:30', '23:00', '23:30', '00:00', '00:30', '01:00', '01:30', '02:00', '02:30', '03:00', '03:30', '04:00', '04:30']) == ['jill']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['23:45', '23:50', '23:55', '00:00', '00:05', '00:10', '00:15']) == ['frank']\n assert candidate(keyName = ['charlie', 'charlie', 'charlie', 'charlie', 'charlie', 'charlie', 'charlie'],keyTime = ['10:00', '10:10', '10:20', '10:30', '10:40', '11:00', '11:10']) == ['charlie']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['14:00', '14:30', '15:00', '15:30', '16:00', '16:30']) == ['hank']\n assert candidate(keyName = ['kyle', 'kyle', 'kyle', 'kyle', 'kyle', 'kyle', 'kyle'],keyTime = ['22:00', '22:15', '22:30', '22:45', '23:00', '23:15', '23:30']) == ['kyle']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20']) == ['frank']\n assert candidate(keyName = ['julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40']) == ['julia']\n assert candidate(keyName = ['julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia'],keyTime = ['12:00', '12:10', '12:20', '12:30', '12:40', '12:50', '13:00', '13:10']) == ['julia']\n assert candidate(keyName = ['karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40', '10:50']) == ['karen']\n assert candidate(keyName = ['bob', 'bob', 'bob', 'bob', 'bob', 'bob'],keyTime = ['12:00', '12:01', '12:02', '12:03', '12:04', '12:05']) == ['bob']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'alice', 'alice'],keyTime = ['09:00', '09:30', '10:00', '10:30', '11:00']) == ['alice']\n"}, "metadata": {"canonical_parameter_names": ["keyName", "keyTime"], "leetcode_dataset_entry_point": "Solution().alertNames", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def alertNames(self, keyName: list[str], keyTime: list[str]) -> list[str]:", "container": "Solution", "callable": "alertNames", "parameters": [{"name": "keyName", "type": "list[str]"}, {"name": "keyTime", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1605, "task_id": "find-valid-matrix-given-row-and-column-sums", "difficulty": "Medium", "problem_description": "You are given two arrays rowSum and colSum of non-negative integers where rowSum[i] is the sum of the elements in the ith row and colSum[j] is the sum of the elements of the jth column of a 2D matrix. In other words, you do not know the elements of the matrix, but you do know the sums of each row and column.\nFind any matrix of non-negative integers of size rowSum.length x colSum.length that satisfies the rowSum and colSum requirements.\nReturn a 2D array representing any matrix that fulfills the requirements. It's guaranteed that at least one matrix that fulfills the requirements exists.\n \nExample 1:\n\nInput: rowSum = [3,8], colSum = [4,7]\nOutput: [[3,0],\n [1,7]]\nExplanation: \n0th row: 3 + 0 = 3 == rowSum[0]\n1st row: 1 + 7 = 8 == rowSum[1]\n0th column: 3 + 1 = 4 == colSum[0]\n1st column: 0 + 7 = 7 == colSum[1]\nThe row and column sums match, and all matrix elements are non-negative.\nAnother possible matrix is: [[1,2],\n [3,5]]\n\nExample 2:\n\nInput: rowSum = [5,7,10], colSum = [8,6,8]\nOutput: [[0,5,0],\n [6,1,0],\n [2,0,8]]\n\n \nConstraints:\n\n1 <= rowSum.length, colSum.length <= 500\n0 <= rowSum[i], colSum[i] <= 108\nsum(rowSum) == sum(colSum)\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rowSum = [10, 15],colSum = [12, 13]) == [[10, 0], [2, 13]]\n assert candidate(rowSum = [5, 5, 5],colSum = [5, 5, 5]) == [[5, 0, 0], [0, 5, 0], [0, 0, 5]]\n assert candidate(rowSum = [10, 20],colSum = [15, 15]) == [[10, 0], [5, 15]]\n assert candidate(rowSum = [10, 15, 20],colSum = [15, 15, 15]) == [[10, 0, 0], [5, 10, 0], [0, 5, 15]]\n assert candidate(rowSum = [1, 2, 3, 4],colSum = [1, 2, 3, 4]) == [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]\n assert candidate(rowSum = [1, 1, 1],colSum = [1, 1, 1]) == [[1, 0, 0], [0, 1, 0], [0, 0, 1]]\n assert candidate(rowSum = [5, 7, 10],colSum = [8, 6, 8]) == [[5, 0, 0], [3, 4, 0], [0, 2, 8]]\n assert candidate(rowSum = [10, 15, 20],colSum = [5, 10, 20]) == [[5, 5, 0], [0, 5, 10], [0, 0, 10]]\n assert candidate(rowSum = [0, 0],colSum = [0, 0]) == [[0, 0], [0, 0]]\n assert candidate(rowSum = [1, 2],colSum = [3, 0]) == [[1, 0], [2, 0]]\n assert candidate(rowSum = [1, 2, 3],colSum = [3, 2, 1]) == [[1, 0, 0], [2, 0, 0], [0, 2, 1]]\n assert candidate(rowSum = [0, 0, 0],colSum = [0, 0, 0]) == [[0, 0, 0], [0, 0, 0], [0, 0, 0]]\n assert candidate(rowSum = [3, 8],colSum = [4, 7]) == [[3, 0], [1, 7]]\n assert candidate(rowSum = [25, 25, 25, 25, 25],colSum = [25, 25, 25, 25, 25]) == [[25, 0, 0, 0, 0], [0, 25, 0, 0, 0], [0, 0, 25, 0, 0], [0, 0, 0, 25, 0], [0, 0, 0, 0, 25]]\n assert candidate(rowSum = [9, 18, 27, 36, 45],colSum = [5, 10, 15, 20, 25]) == [[5, 4, 0, 0, 0], [0, 6, 12, 0, 0], [0, 0, 3, 20, 4], [0, 0, 0, 0, 21], [0, 0, 0, 0, 0]]\n assert candidate(rowSum = [10, 20, 30],colSum = [6, 9, 12, 15]) == [[6, 4, 0, 0], [0, 5, 12, 3], [0, 0, 0, 12]]\n assert candidate(rowSum = [5, 5, 5, 5],colSum = [4, 4, 4, 4]) == [[4, 1, 0, 0], [0, 3, 2, 0], [0, 0, 2, 3], [0, 0, 0, 1]]\n assert candidate(rowSum = [10, 20, 30],colSum = [6, 15, 29]) == [[6, 4, 0], [0, 11, 9], [0, 0, 20]]\n assert candidate(rowSum = [300, 400, 500, 600],colSum = [200, 300, 400, 700]) == [[200, 100, 0, 0], [0, 200, 200, 0], [0, 0, 200, 300], [0, 0, 0, 400]]\n assert candidate(rowSum = [12, 25, 30],colSum = [20, 15, 20]) == [[12, 0, 0], [8, 15, 2], [0, 0, 18]]\n assert candidate(rowSum = [12, 15, 20],colSum = [10, 10, 17]) == [[10, 2, 0], [0, 8, 7], [0, 0, 10]]\n assert candidate(rowSum = [1000, 2000, 3000],colSum = [1500, 2000, 2500]) == [[1000, 0, 0], [500, 1500, 0], [0, 500, 2500]]\n assert candidate(rowSum = [9, 18, 27],colSum = [12, 15, 18]) == [[9, 0, 0], [3, 15, 0], [0, 0, 18]]\n assert candidate(rowSum = [100, 100, 100, 100],colSum = [25, 25, 25, 25]) == [[25, 25, 25, 25], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n assert candidate(rowSum = [45, 55, 65, 75, 85],colSum = [50, 60, 70, 80, 90]) == [[45, 0, 0, 0, 0], [5, 50, 0, 0, 0], [0, 10, 55, 0, 0], [0, 0, 15, 60, 0], [0, 0, 0, 20, 65]]\n assert candidate(rowSum = [99, 100, 101, 102],colSum = [101, 102, 99, 100]) == [[99, 0, 0, 0], [2, 98, 0, 0], [0, 4, 97, 0], [0, 0, 2, 100]]\n assert candidate(rowSum = [50, 100, 150],colSum = [25, 75, 100, 150]) == [[25, 25, 0, 0], [0, 50, 50, 0], [0, 0, 50, 100]]\n assert candidate(rowSum = [25, 50, 75, 100],colSum = [10, 20, 30, 40, 95]) == [[10, 15, 0, 0, 0], [0, 5, 30, 15, 0], [0, 0, 0, 25, 50], [0, 0, 0, 0, 45]]\n assert candidate(rowSum = [100, 150, 200, 250],colSum = [100, 100, 150, 200]) == [[100, 0, 0, 0], [0, 100, 50, 0], [0, 0, 100, 100], [0, 0, 0, 100]]\n assert candidate(rowSum = [45, 55, 65, 75, 85],colSum = [30, 40, 50, 60, 70]) == [[30, 15, 0, 0, 0], [0, 25, 30, 0, 0], [0, 0, 20, 45, 0], [0, 0, 0, 15, 60], [0, 0, 0, 0, 10]]\n assert candidate(rowSum = [100, 200, 300, 400],colSum = [150, 250, 350, 450]) == [[100, 0, 0, 0], [50, 150, 0, 0], [0, 100, 200, 0], [0, 0, 150, 250]]\n assert candidate(rowSum = [300, 200, 100, 50],colSum = [150, 150, 150, 100, 50]) == [[150, 150, 0, 0, 0], [0, 0, 150, 50, 0], [0, 0, 0, 50, 50], [0, 0, 0, 0, 0]]\n assert candidate(rowSum = [20, 30, 40, 50],colSum = [10, 20, 30, 40]) == [[10, 10, 0, 0], [0, 10, 20, 0], [0, 0, 10, 30], [0, 0, 0, 10]]\n assert candidate(rowSum = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],colSum = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]\n assert candidate(rowSum = [100, 200, 300],colSum = [150, 100, 250]) == [[100, 0, 0], [50, 100, 50], [0, 0, 200]]\n assert candidate(rowSum = [50, 50, 50],colSum = [40, 40, 40, 40]) == [[40, 10, 0, 0], [0, 30, 20, 0], [0, 0, 20, 30]]\n assert candidate(rowSum = [10, 20, 30, 40, 50],colSum = [15, 15, 15, 15, 15]) == [[10, 0, 0, 0, 0], [5, 15, 0, 0, 0], [0, 0, 15, 15, 0], [0, 0, 0, 0, 15], [0, 0, 0, 0, 0]]\n assert candidate(rowSum = [500, 500, 500, 500, 500],colSum = [250, 250, 250, 250, 250]) == [[250, 250, 0, 0, 0], [0, 0, 250, 250, 0], [0, 0, 0, 0, 250], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]\n assert candidate(rowSum = [5, 6, 7, 8],colSum = [10, 8, 6, 4]) == [[5, 0, 0, 0], [5, 1, 0, 0], [0, 7, 0, 0], [0, 0, 6, 2]]\n assert candidate(rowSum = [100, 200, 300],colSum = [150, 250, 100]) == [[100, 0, 0], [50, 150, 0], [0, 100, 100]]\n assert candidate(rowSum = [25, 50, 75, 100],colSum = [40, 50, 60, 50]) == [[25, 0, 0, 0], [15, 35, 0, 0], [0, 15, 60, 0], [0, 0, 0, 50]]\n assert candidate(rowSum = [10, 20, 30, 40, 50],colSum = [50, 40, 30, 20, 10]) == [[10, 0, 0, 0, 0], [20, 0, 0, 0, 0], [20, 10, 0, 0, 0], [0, 30, 10, 0, 0], [0, 0, 20, 20, 10]]\n assert candidate(rowSum = [500, 300, 200],colSum = [400, 350, 250]) == [[400, 100, 0], [0, 250, 50], [0, 0, 200]]\n assert candidate(rowSum = [50, 75, 100],colSum = [120, 100, 30]) == [[50, 0, 0], [70, 5, 0], [0, 95, 5]]\n assert candidate(rowSum = [8, 16, 24, 32],colSum = [16, 24, 16, 24]) == [[8, 0, 0, 0], [8, 8, 0, 0], [0, 16, 8, 0], [0, 0, 8, 24]]\n assert candidate(rowSum = [8, 6, 4, 2, 0],colSum = [1, 2, 3, 4, 5]) == [[1, 2, 3, 2, 0], [0, 0, 0, 2, 4], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]\n assert candidate(rowSum = [88, 77, 66, 55, 44],colSum = [99, 88, 77, 66, 55]) == [[88, 0, 0, 0, 0], [11, 66, 0, 0, 0], [0, 22, 44, 0, 0], [0, 0, 33, 22, 0], [0, 0, 0, 44, 0]]\n assert candidate(rowSum = [150, 200, 250],colSum = [200, 150, 300]) == [[150, 0, 0], [50, 150, 0], [0, 0, 250]]\n assert candidate(rowSum = [88, 88, 88, 88, 88, 88],colSum = [77, 77, 77, 77, 77, 77]) == [[77, 11, 0, 0, 0, 0], [0, 66, 22, 0, 0, 0], [0, 0, 55, 33, 0, 0], [0, 0, 0, 44, 44, 0], [0, 0, 0, 0, 33, 55], [0, 0, 0, 0, 0, 22]]\n assert candidate(rowSum = [120, 110, 100, 90],colSum = [105, 95, 85, 75]) == [[105, 15, 0, 0], [0, 80, 30, 0], [0, 0, 55, 45], [0, 0, 0, 30]]\n assert candidate(rowSum = [50, 60, 70, 80, 90],colSum = [90, 80, 70, 60, 50]) == [[50, 0, 0, 0, 0], [40, 20, 0, 0, 0], [0, 60, 10, 0, 0], [0, 0, 60, 20, 0], [0, 0, 0, 40, 50]]\n assert candidate(rowSum = [123, 456, 789],colSum = [456, 789, 123]) == [[123, 0, 0], [333, 123, 0], [0, 666, 123]]\n assert candidate(rowSum = [10, 20, 30, 40, 50],colSum = [5, 10, 15, 20, 60]) == [[5, 5, 0, 0, 0], [0, 5, 15, 0, 0], [0, 0, 0, 20, 10], [0, 0, 0, 0, 40], [0, 0, 0, 0, 10]]\n assert candidate(rowSum = [8, 16, 24, 32],colSum = [16, 24, 32, 8]) == [[8, 0, 0, 0], [8, 8, 0, 0], [0, 16, 8, 0], [0, 0, 24, 8]]\n assert candidate(rowSum = [100, 200, 300, 400],colSum = [200, 300, 200, 400]) == [[100, 0, 0, 0], [100, 100, 0, 0], [0, 200, 100, 0], [0, 0, 100, 300]]\n assert candidate(rowSum = [120, 80, 40],colSum = [90, 70, 30, 10]) == [[90, 30, 0, 0], [0, 40, 30, 10], [0, 0, 0, 0]]\n assert candidate(rowSum = [10, 20, 30, 40],colSum = [15, 25, 25, 25]) == [[10, 0, 0, 0], [5, 15, 0, 0], [0, 10, 20, 0], [0, 0, 5, 25]]\n assert candidate(rowSum = [99, 98, 97, 96, 95],colSum = [95, 96, 97, 98, 99]) == [[95, 4, 0, 0, 0], [0, 92, 6, 0, 0], [0, 0, 91, 6, 0], [0, 0, 0, 92, 4], [0, 0, 0, 0, 95]]\n assert candidate(rowSum = [15, 25, 35, 45],colSum = [10, 20, 30, 40]) == [[10, 5, 0, 0], [0, 15, 10, 0], [0, 0, 20, 15], [0, 0, 0, 25]]\n assert candidate(rowSum = [75, 80, 85, 90, 95, 100],colSum = [60, 65, 70, 75, 80, 85]) == [[60, 15, 0, 0, 0, 0], [0, 50, 30, 0, 0, 0], [0, 0, 40, 45, 0, 0], [0, 0, 0, 30, 60, 0], [0, 0, 0, 0, 20, 75], [0, 0, 0, 0, 0, 10]]\n assert candidate(rowSum = [100, 150, 200],colSum = [200, 120, 130]) == [[100, 0, 0], [100, 50, 0], [0, 70, 130]]\n assert candidate(rowSum = [120, 140, 160, 180, 200],colSum = [200, 180, 160, 140, 120]) == [[120, 0, 0, 0, 0], [80, 60, 0, 0, 0], [0, 120, 40, 0, 0], [0, 0, 120, 60, 0], [0, 0, 0, 80, 120]]\n assert candidate(rowSum = [50, 60, 70, 80],colSum = [30, 40, 50, 60]) == [[30, 20, 0, 0], [0, 20, 40, 0], [0, 0, 10, 60], [0, 0, 0, 0]]\n assert candidate(rowSum = [30, 20, 10, 0],colSum = [10, 10, 10, 30]) == [[10, 10, 10, 0], [0, 0, 0, 20], [0, 0, 0, 10], [0, 0, 0, 0]]\n assert candidate(rowSum = [5, 10, 15, 20, 25],colSum = [25, 20, 15, 10, 5]) == [[5, 0, 0, 0, 0], [10, 0, 0, 0, 0], [10, 5, 0, 0, 0], [0, 15, 5, 0, 0], [0, 0, 10, 10, 5]]\n assert candidate(rowSum = [20, 40, 60, 80],colSum = [30, 30, 30, 30]) == [[20, 0, 0, 0], [10, 30, 0, 0], [0, 0, 30, 30], [0, 0, 0, 0]]\n assert candidate(rowSum = [1, 1, 1, 1, 1, 1],colSum = [1, 1, 1, 1, 1, 1]) == [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]]\n assert candidate(rowSum = [50, 45, 60],colSum = [40, 30, 35]) == [[40, 10, 0], [0, 20, 25], [0, 0, 10]]\n assert candidate(rowSum = [123, 456, 789],colSum = [321, 654, 987]) == [[123, 0, 0], [198, 258, 0], [0, 396, 393]]\n assert candidate(rowSum = [100, 200, 300],colSum = [150, 150, 150]) == [[100, 0, 0], [50, 150, 0], [0, 0, 150]]\n assert candidate(rowSum = [30, 40, 50, 60],colSum = [50, 40, 40, 30]) == [[30, 0, 0, 0], [20, 20, 0, 0], [0, 20, 30, 0], [0, 0, 10, 30]]\n assert candidate(rowSum = [1, 2, 3, 4, 5],colSum = [5, 4, 3, 2, 1]) == [[1, 0, 0, 0, 0], [2, 0, 0, 0, 0], [2, 1, 0, 0, 0], [0, 3, 1, 0, 0], [0, 0, 2, 2, 1]]\n assert candidate(rowSum = [30, 20, 10],colSum = [15, 20, 15]) == [[15, 15, 0], [0, 5, 15], [0, 0, 0]]\n assert candidate(rowSum = [20, 30, 40, 50],colSum = [15, 15, 15, 15, 20, 10]) == [[15, 5, 0, 0, 0, 0], [0, 10, 15, 5, 0, 0], [0, 0, 0, 10, 20, 10], [0, 0, 0, 0, 0, 0]]\n assert candidate(rowSum = [150, 200, 250, 300, 350, 400],colSum = [200, 250, 300, 350, 400, 450]) == [[150, 0, 0, 0, 0, 0], [50, 150, 0, 0, 0, 0], [0, 100, 150, 0, 0, 0], [0, 0, 150, 150, 0, 0], [0, 0, 0, 200, 150, 0], [0, 0, 0, 0, 250, 150]]\n assert candidate(rowSum = [7, 14, 21, 28],colSum = [7, 14, 21, 28]) == [[7, 0, 0, 0], [0, 14, 0, 0], [0, 0, 21, 0], [0, 0, 0, 28]]\n assert candidate(rowSum = [30, 60, 90, 120],colSum = [20, 40, 60, 80, 100]) == [[20, 10, 0, 0, 0], [0, 30, 30, 0, 0], [0, 0, 30, 60, 0], [0, 0, 0, 20, 100]]\n assert candidate(rowSum = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],colSum = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [2, 0, 0, 0, 0, 0, 0, 0, 0, 0], [3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [4, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 5, 0, 0, 0, 0, 0, 0, 0, 0], [0, 4, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 6, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 6, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 3, 2, 1]]\n assert candidate(rowSum = [10, 20, 30, 40, 50],colSum = [15, 25, 35, 25, 15]) == [[10, 0, 0, 0, 0], [5, 15, 0, 0, 0], [0, 10, 20, 0, 0], [0, 0, 15, 25, 0], [0, 0, 0, 0, 15]]\n assert candidate(rowSum = [33, 33, 33, 33, 33, 33],colSum = [22, 22, 22, 22, 22, 22]) == [[22, 11, 0, 0, 0, 0], [0, 11, 22, 0, 0, 0], [0, 0, 0, 22, 11, 0], [0, 0, 0, 0, 11, 22], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]\n assert candidate(rowSum = [100, 200, 300, 400, 500],colSum = [500, 400, 300, 200, 100]) == [[100, 0, 0, 0, 0], [200, 0, 0, 0, 0], [200, 100, 0, 0, 0], [0, 300, 100, 0, 0], [0, 0, 200, 200, 100]]\n assert candidate(rowSum = [10000, 20000, 30000],colSum = [15000, 20000, 25000]) == [[10000, 0, 0], [5000, 15000, 0], [0, 5000, 25000]]\n assert candidate(rowSum = [5, 15, 25, 35],colSum = [10, 10, 10, 30]) == [[5, 0, 0, 0], [5, 10, 0, 0], [0, 0, 10, 15], [0, 0, 0, 15]]\n assert candidate(rowSum = [1, 1, 1, 1, 1],colSum = [1, 1, 1, 1, 1]) == [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]\n assert candidate(rowSum = [7, 14, 21, 28, 35],colSum = [5, 10, 15, 20, 25]) == [[5, 2, 0, 0, 0], [0, 8, 6, 0, 0], [0, 0, 9, 12, 0], [0, 0, 0, 8, 20], [0, 0, 0, 0, 5]]\n assert candidate(rowSum = [12, 34, 56, 78, 90, 123],colSum = [23, 45, 67, 89, 101, 112]) == [[12, 0, 0, 0, 0, 0], [11, 23, 0, 0, 0, 0], [0, 22, 34, 0, 0, 0], [0, 0, 33, 45, 0, 0], [0, 0, 0, 44, 46, 0], [0, 0, 0, 0, 55, 68]]\n assert candidate(rowSum = [100, 200, 300, 400],colSum = [100, 150, 200, 350]) == [[100, 0, 0, 0], [0, 150, 50, 0], [0, 0, 150, 150], [0, 0, 0, 200]]\n assert candidate(rowSum = [100, 200, 300, 400, 500],colSum = [250, 250, 250, 250, 250]) == [[100, 0, 0, 0, 0], [150, 50, 0, 0, 0], [0, 200, 100, 0, 0], [0, 0, 150, 250, 0], [0, 0, 0, 0, 250]]\n assert candidate(rowSum = [25, 75],colSum = [100, 50]) == [[25, 0], [75, 0]]\n assert candidate(rowSum = [10, 20, 30, 40, 50],colSum = [5, 15, 25, 35, 45]) == [[5, 5, 0, 0, 0], [0, 10, 10, 0, 0], [0, 0, 15, 15, 0], [0, 0, 0, 20, 20], [0, 0, 0, 0, 25]]\n assert candidate(rowSum = [1000, 2000, 3000],colSum = [1500, 1500, 1500]) == [[1000, 0, 0], [500, 1500, 0], [0, 0, 1500]]\n assert candidate(rowSum = [5, 10, 15, 20],colSum = [20, 15, 10, 5]) == [[5, 0, 0, 0], [10, 0, 0, 0], [5, 10, 0, 0], [0, 5, 10, 5]]\n assert candidate(rowSum = [50, 50, 50, 50, 50],colSum = [25, 25, 25, 25, 25, 25, 25]) == [[25, 25, 0, 0, 0, 0, 0], [0, 0, 25, 25, 0, 0, 0], [0, 0, 0, 0, 25, 25, 0], [0, 0, 0, 0, 0, 0, 25], [0, 0, 0, 0, 0, 0, 0]]\n assert candidate(rowSum = [500, 1000, 1500, 2000],colSum = [600, 700, 800, 900]) == [[500, 0, 0, 0], [100, 700, 200, 0], [0, 0, 600, 900], [0, 0, 0, 0]]\n assert candidate(rowSum = [50, 50, 50, 50],colSum = [60, 60, 60, 60]) == [[50, 0, 0, 0], [10, 40, 0, 0], [0, 20, 30, 0], [0, 0, 30, 20]]\n assert candidate(rowSum = [40, 50, 60],colSum = [70, 60, 50]) == [[40, 0, 0], [30, 20, 0], [0, 40, 20]]\n assert candidate(rowSum = [12, 15, 7],colSum = [10, 10, 12]) == [[10, 2, 0], [0, 8, 7], [0, 0, 5]]\n assert candidate(rowSum = [100, 200, 300],colSum = [250, 250, 200]) == [[100, 0, 0], [150, 50, 0], [0, 200, 100]]\n assert candidate(rowSum = [9, 18, 27, 36],colSum = [12, 24, 36, 48]) == [[9, 0, 0, 0], [3, 15, 0, 0], [0, 9, 18, 0], [0, 0, 18, 18]]\n assert candidate(rowSum = [9, 9, 9, 9],colSum = [6, 6, 6, 6, 9]) == [[6, 3, 0, 0, 0], [0, 3, 6, 0, 0], [0, 0, 0, 6, 3], [0, 0, 0, 0, 6]]\n assert candidate(rowSum = [50, 50, 50, 50, 50, 50],colSum = [50, 50, 50, 50, 50, 50]) == [[50, 0, 0, 0, 0, 0], [0, 50, 0, 0, 0, 0], [0, 0, 50, 0, 0, 0], [0, 0, 0, 50, 0, 0], [0, 0, 0, 0, 50, 0], [0, 0, 0, 0, 0, 50]]\n assert candidate(rowSum = [33, 28, 44, 55],colSum = [30, 33, 25, 50]) == [[30, 3, 0, 0], [0, 28, 0, 0], [0, 2, 25, 17], [0, 0, 0, 33]]\n assert candidate(rowSum = [300, 200, 100],colSum = [150, 200, 150]) == [[150, 150, 0], [0, 50, 150], [0, 0, 0]]\n assert candidate(rowSum = [30, 40, 50],colSum = [20, 50, 20]) == [[20, 10, 0], [0, 40, 0], [0, 0, 20]]\n assert candidate(rowSum = [120, 90, 75, 60],colSum = [80, 100, 75, 60]) == [[80, 40, 0, 0], [0, 60, 30, 0], [0, 0, 45, 30], [0, 0, 0, 30]]\n assert candidate(rowSum = [5, 15, 25, 35],colSum = [10, 20, 30, 40]) == [[5, 0, 0, 0], [5, 10, 0, 0], [0, 10, 15, 0], [0, 0, 15, 20]]\n assert candidate(rowSum = [34, 78, 90, 123],colSum = [50, 60, 70, 80]) == [[34, 0, 0, 0], [16, 60, 2, 0], [0, 0, 68, 22], [0, 0, 0, 58]]\n assert candidate(rowSum = [120, 150, 180],colSum = [100, 130, 200]) == [[100, 20, 0], [0, 110, 40], [0, 0, 160]]\n assert candidate(rowSum = [10, 20, 30],colSum = [30, 20, 10]) == [[10, 0, 0], [20, 0, 0], [0, 20, 10]]\n assert candidate(rowSum = [10, 10, 10, 10, 10],colSum = [5, 5, 5, 5, 50]) == [[5, 5, 0, 0, 0], [0, 0, 5, 5, 0], [0, 0, 0, 0, 10], [0, 0, 0, 0, 10], [0, 0, 0, 0, 10]]\n assert candidate(rowSum = [12, 9, 6],colSum = [10, 10, 7]) == [[10, 2, 0], [0, 8, 1], [0, 0, 6]]\n assert candidate(rowSum = [15, 25, 35, 45],colSum = [20, 30, 25, 25]) == [[15, 0, 0, 0], [5, 20, 0, 0], [0, 10, 25, 0], [0, 0, 0, 25]]\n assert candidate(rowSum = [100, 150, 200, 250],colSum = [150, 200, 250, 100]) == [[100, 0, 0, 0], [50, 100, 0, 0], [0, 100, 100, 0], [0, 0, 150, 100]]\n"}, "metadata": {"canonical_parameter_names": ["rowSum", "colSum"], "leetcode_dataset_entry_point": "Solution().restoreMatrix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def restoreMatrix(self, rowSum: list[int], colSum: list[int]) -> list[list[int]]:", "container": "Solution", "callable": "restoreMatrix", "parameters": [{"name": "rowSum", "type": "list[int]"}, {"name": "colSum", "type": "list[int]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1606, "task_id": "find-servers-that-handled-most-number-of-requests", "difficulty": "Hard", "problem_description": "You have k servers numbered from 0 to k-1 that are being used to handle multiple requests simultaneously. Each server has infinite computational capacity but cannot handle more than one request at a time. The requests are assigned to servers according to a specific algorithm:\n\nThe ith (0-indexed) request arrives.\nIf all servers are busy, the request is dropped (not handled at all).\nIf the (i % k)th server is available, assign the request to that server.\nOtherwise, assign the request to the next available server (wrapping around the list of servers and starting from 0 if necessary). For example, if the ith server is busy, try to assign the request to the (i+1)th server, then the (i+2)th server, and so on.\n\nYou are given a strictly increasing array arrival of positive integers, where arrival[i] represents the arrival time of the ith request, and another array load, where load[i] represents the load of the ith request (the time it takes to complete). Your goal is to find the busiest server(s). A server is considered busiest if it handled the most number of requests successfully among all the servers.\nReturn a list containing the IDs (0-indexed) of the busiest server(s). You may return the IDs in any order.\n \nExample 1:\n\n\nInput: k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3] \nOutput: [1] \nExplanation: \nAll of the servers start out available.\nThe first 3 requests are handled by the first 3 servers in order.\nRequest 3 comes in. Server 0 is busy, so it's assigned to the next available server, which is 1.\nRequest 4 comes in. It cannot be handled since all servers are busy, so it is dropped.\nServers 0 and 2 handled one request each, while server 1 handled two requests. Hence server 1 is the busiest server.\n\nExample 2:\n\nInput: k = 3, arrival = [1,2,3,4], load = [1,2,1,2]\nOutput: [0]\nExplanation: \nThe first 3 requests are handled by first 3 servers.\nRequest 3 comes in. It is handled by server 0 since the server is available.\nServer 0 handled two requests, while servers 1 and 2 handled one request each. Hence server 0 is the busiest server.\n\nExample 3:\n\nInput: k = 3, arrival = [1,2,3], load = [10,12,11]\nOutput: [0,1,2]\nExplanation: Each server handles a single request, so they are all considered the busiest.\n\n \nConstraints:\n\n1 <= k <= 105\n1 <= arrival.length, load.length <= 105\narrival.length == load.length\n1 <= arrival[i], load[i] <= 109\narrival is strictly increasing.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 5,arrival = [1, 7, 8, 9, 10],load = [5, 2, 3, 3, 3]) == [0, 1, 2, 3, 4]\n assert candidate(k = 3,arrival = [1, 2, 3, 4],load = [1, 2, 1, 2]) == [0]\n assert candidate(k = 3,arrival = [1, 2, 3],load = [10, 12, 11]) == [0, 1, 2]\n assert candidate(k = 1,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0]\n assert candidate(k = 5,arrival = [1, 7, 8, 9, 10, 11, 12],load = [2, 3, 2, 1, 3, 2, 2]) == [0, 1]\n assert candidate(k = 10,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 4,arrival = [1, 10, 20, 30, 40],load = [2, 2, 2, 2, 2]) == [0]\n assert candidate(k = 1,arrival = [1, 2, 3, 4, 5],load = [1, 1, 1, 1, 1]) == [0]\n assert candidate(k = 3,arrival = [1, 2, 3, 4, 5],load = [5, 2, 3, 3, 3]) == [1]\n assert candidate(k = 5,arrival = [1, 7, 8, 9, 10],load = [5, 2, 10, 3, 1]) == [0, 1, 2, 3, 4]\n assert candidate(k = 5,arrival = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55],load = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 1, 2, 3, 4]\n assert candidate(k = 4,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],load = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2]) == [0, 1, 2]\n assert candidate(k = 4,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3]\n assert candidate(k = 20,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 9,arrival = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 1]\n assert candidate(k = 4,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0]\n assert candidate(k = 1000,arrival = [1, 1001, 2001, 3001, 4001, 5001, 6001, 7001, 8001, 9001, 10001],load = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(k = 10,arrival = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59],load = [3, 2, 5, 4, 3, 2, 5, 4, 3, 2, 5, 4, 3, 2, 5, 4, 3, 2, 5, 4]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 100,arrival = [1, 101, 201, 301, 401, 501, 601, 701, 801, 901, 1001],load = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(k = 8,arrival = [1, 4, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144],load = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [0, 1, 2, 3]\n assert candidate(k = 4,arrival = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95],load = [1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 7,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],load = [3, 6, 4, 2, 5, 7, 1, 8, 3, 5, 6, 4, 2, 7, 1]) == [0]\n assert candidate(k = 12,arrival = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90],load = [5, 2, 7, 3, 8, 4, 6, 1, 9, 5, 2, 7, 3, 8, 4, 6, 1, 9, 5, 2, 7, 3, 8, 4, 6, 1, 9, 5, 2, 7, 3]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(k = 12,arrival = [1, 13, 25, 37, 49, 61, 73, 85, 97, 109, 121, 133, 145, 157, 169, 181, 193, 205, 217, 229],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(k = 7,arrival = [1, 3, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50],load = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4]\n assert candidate(k = 4,arrival = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225],load = [3, 6, 2, 8, 5, 9, 3, 7, 1, 10, 4, 6, 8, 2, 9]) == [0, 1, 2]\n assert candidate(k = 10,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],load = [10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 20,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [0, 1]\n assert candidate(k = 5,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],load = [10, 5, 7, 6, 2, 4, 8, 3, 9, 1, 6]) == [0]\n assert candidate(k = 15,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(k = 3,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],load = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [0, 1, 2]\n assert candidate(k = 4,arrival = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040],load = [5, 3, 2, 8, 6, 4, 7, 9, 1, 10, 3, 5, 8, 6, 4, 7, 9, 1, 10, 3, 5, 8, 6, 4, 7, 9, 1, 10, 3]) == [0]\n assert candidate(k = 8,arrival = [1, 2, 3, 5, 10, 12, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(k = 7,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 1, 2]\n assert candidate(k = 10,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],load = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 8,arrival = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96, 101, 106, 111, 116, 121, 126, 131, 136, 141, 146, 151, 156, 161, 166, 171, 176, 181, 186, 191, 196, 201, 206],load = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1]\n assert candidate(k = 5,arrival = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95],load = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0, 1, 2, 3, 4]\n assert candidate(k = 10,arrival = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4]\n assert candidate(k = 8,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3]\n assert candidate(k = 11,arrival = [1, 12, 23, 34, 45, 56, 67, 78, 89, 100, 111, 122, 133, 144, 155, 166, 177, 188, 199, 210],load = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 10, 9, 8, 7, 6, 5, 4, 3]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(k = 15,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400],load = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(k = 7,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],load = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 20,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],load = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(k = 9,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],load = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98]) == [0, 1, 2]\n assert candidate(k = 7,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],load = [10, 8, 9, 7, 6, 5, 4, 3, 2, 1, 10, 8, 9, 7, 6, 5, 4, 3, 2, 1, 10, 8, 9, 7, 6, 5, 4, 3, 2, 1, 10, 8, 9, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 3, 4]\n assert candidate(k = 6,arrival = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],load = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 8,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109, 113, 117],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 8,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],load = [9, 1, 8, 2, 7, 3, 6, 4, 5, 6, 4, 5, 3, 7, 2, 8, 9, 1, 8, 2]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 9,arrival = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58],load = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8]) == [0, 1]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == [0, 1, 2, 3, 4]\n assert candidate(k = 7,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 1, 2]\n assert candidate(k = 10,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],load = [2, 4, 3, 5, 6, 2, 8, 7, 3, 4, 5, 2, 3, 1, 7, 4, 2, 8, 6, 5]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],load = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [0, 1, 2, 3, 4]\n assert candidate(k = 10,arrival = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58],load = [4, 7, 2, 9, 1, 8, 6, 5, 3, 2, 10, 5, 7, 9, 1]) == [0, 1, 2, 3, 4]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],load = [5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3, 4]\n assert candidate(k = 6,arrival = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],load = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3, 4]\n assert candidate(k = 6,arrival = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 1]\n assert candidate(k = 15,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],load = [5, 15, 10, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(k = 8,arrival = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],load = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [0, 1, 2]\n assert candidate(k = 8,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],load = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [0, 1, 2, 3]\n assert candidate(k = 12,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],load = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [0, 1]\n assert candidate(k = 7,arrival = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40],load = [2, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(k = 10,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500],load = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 8,arrival = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191],load = [8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5]) == [0, 1, 2, 3]\n assert candidate(k = 3,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],load = [80, 70, 60, 50, 40, 30, 20, 10, 5, 1]) == [0, 2]\n assert candidate(k = 7,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [2, 4, 3, 5, 1, 6, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 6,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 15,arrival = [1, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285],load = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11]) == [0, 1, 2, 3, 4]\n assert candidate(k = 15,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],load = [10, 8, 6, 4, 2, 10, 8, 6, 4, 2, 10, 8, 6, 4, 2, 10, 8, 6, 4, 2, 10, 8, 6, 4, 2, 10, 8, 6, 4, 2]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1]\n assert candidate(k = 10,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],load = [2, 4, 1, 3, 5, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 1, 2, 3, 4]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],load = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4]\n assert candidate(k = 7,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],load = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(k = 7,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 6,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == [0]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [2, 3, 1, 4, 2, 1, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == [0, 1, 2, 3]\n assert candidate(k = 20,arrival = [1, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400],load = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(k = 6,arrival = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],load = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == [0, 1, 2]\n assert candidate(k = 6,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 9,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],load = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8]) == [0, 1]\n assert candidate(k = 5,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == [0]\n assert candidate(k = 10,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 3, 5, 7, 9, 11, 13, 15],load = [2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2]\n assert candidate(k = 1,arrival = [1, 10, 20, 30],load = [5, 5, 5, 5]) == [0]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1]\n assert candidate(k = 6,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [0, 1, 2, 3]\n assert candidate(k = 4,arrival = [1, 3, 5, 7, 9, 11, 13, 15],load = [2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3]\n assert candidate(k = 7,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(k = 6,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 5, 9, 14, 18],load = [4, 3, 5, 2, 3]) == [0, 1, 2, 3, 4]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3, 4]\n assert candidate(k = 7,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [0, 1, 2, 3, 4]\n assert candidate(k = 1,arrival = [1, 10, 20, 30, 40],load = [1, 1, 1, 1, 1]) == [0]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [0, 1, 2, 3, 4]\n assert candidate(k = 3,arrival = [1, 2, 3, 4, 5, 6],load = [3, 2, 1, 1, 2, 3]) == [0, 1, 2]\n assert candidate(k = 5,arrival = [1, 7, 13, 19],load = [10, 10, 10, 10]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 2,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1]\n assert candidate(k = 2,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1]\n assert candidate(k = 4,arrival = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],load = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 1]\n assert candidate(k = 5,arrival = [1, 3, 5, 7, 9],load = [2, 2, 2, 2, 2]) == [0, 1, 2, 3, 4]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 3, 1, 5, 4, 2, 3, 1, 2, 1]) == [0, 1, 2, 3, 4]\n assert candidate(k = 7,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2]\n assert candidate(k = 10,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],load = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 6,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 2,arrival = [1, 3, 5, 7, 9],load = [2, 2, 2, 2, 2]) == [0]\n assert candidate(k = 100,arrival = [1, 101, 201, 301, 401, 501, 601, 701, 801, 901],load = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 2, 3, 8, 10, 13, 15, 16, 17, 20],load = [2, 3, 1, 4, 2, 3, 2, 1, 2, 3]) == [0, 1, 2, 3, 4]\n assert candidate(k = 1,arrival = [1, 10, 20, 30, 40],load = [5, 5, 5, 5, 5]) == [0]\n assert candidate(k = 2,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == [0, 1]\n assert candidate(k = 10000,arrival = [1, 10001, 20001, 30001, 40001],load = [10000, 10000, 10000, 10000, 10000]) == [0, 1, 2, 3, 4]\n assert candidate(k = 4,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],load = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 1]\n assert candidate(k = 10,arrival = [1, 5, 9, 13, 17],load = [3, 3, 3, 3, 3]) == [0, 1, 2, 3, 4]\n assert candidate(k = 1,arrival = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82],load = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [0]\n assert candidate(k = 6,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0, 1, 2, 3]\n assert candidate(k = 6,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],load = [20, 10, 20, 10, 20, 10, 20, 10, 20, 10]) == [0, 1, 2, 3]\n assert candidate(k = 4,arrival = [1, 5, 9, 13, 17, 21],load = [2, 2, 2, 2, 2, 2]) == [0, 1]\n assert candidate(k = 5,arrival = [1, 7, 13, 19, 25],load = [5, 6, 7, 8, 9]) == [0, 1, 2, 3, 4]\n assert candidate(k = 4,arrival = [1, 10, 20, 30, 40, 50],load = [3, 3, 3, 3, 3, 3]) == [0, 1]\n assert candidate(k = 5,arrival = [1, 7, 13, 19, 25],load = [5, 3, 8, 6, 2]) == [0, 1, 2, 3, 4]\n assert candidate(k = 100,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\n assert candidate(k = 1,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0]\n assert candidate(k = 6,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],load = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 2,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [0, 1]\n assert candidate(k = 1,arrival = [1, 2, 3, 4, 5],load = [5, 4, 3, 2, 1]) == [0]\n assert candidate(k = 7,arrival = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2]\n assert candidate(k = 1000,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 7,arrival = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2]\n assert candidate(k = 2,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [0, 1]\n assert candidate(k = 10,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 10,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 10,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1]\n assert candidate(k = 7,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 2,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0]\n assert candidate(k = 10,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 6,arrival = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],load = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0, 1, 2, 3]\n assert candidate(k = 7,arrival = [1, 3, 5, 7, 9, 11, 13, 15],load = [2, 2, 2, 2, 2, 2, 2, 2]) == [0]\n assert candidate(k = 100,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 7, 13, 19, 25, 31],load = [5, 5, 5, 5, 5, 5]) == [0]\n assert candidate(k = 5,arrival = [1, 7, 13, 19],load = [5, 5, 5, 5]) == [0, 1, 2, 3]\n assert candidate(k = 2,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1]\n assert candidate(k = 7,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 1, 3, 2, 1, 3, 2, 1, 3, 2]) == [0, 1]\n assert candidate(k = 6,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3, 4]\n assert candidate(k = 7,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2]\n assert candidate(k = 10,arrival = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91],load = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 4,arrival = [1, 5, 9, 13, 17],load = [4, 4, 4, 4, 4]) == [0]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 3, 4, 5, 6, 1, 2, 3, 4, 5]) == [0]\n assert candidate(k = 5,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],load = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 1, 2, 3, 4]\n assert candidate(k = 6,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [0, 1]\n assert candidate(k = 4,arrival = [1, 3, 5, 7, 9],load = [1, 2, 1, 2, 1]) == [0]\n assert candidate(k = 1,arrival = [1, 10, 100, 1000, 10000],load = [1, 2, 3, 4, 5]) == [0]\n assert candidate(k = 5,arrival = [1, 7, 13, 19, 25],load = [5, 5, 5, 5, 5]) == [0, 1, 2, 3, 4]\n assert candidate(k = 1,arrival = [1, 10, 100, 1000, 10000],load = [1, 1, 1, 1, 1]) == [0]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == [0, 1, 2, 3, 4]\n assert candidate(k = 7,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [4, 2, 6, 3, 5, 1, 7, 8, 2, 5]) == [0, 1, 2]\n assert candidate(k = 10,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 7,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],load = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 1, 2]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == [0, 1, 2, 3]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0]\n assert candidate(k = 2,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [0, 1]\n"}, "metadata": {"canonical_parameter_names": ["k", "arrival", "load"], "leetcode_dataset_entry_point": "Solution().busiestServers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def busiestServers(self, k: int, arrival: list[int], load: list[int]) -> list[int]:", "container": "Solution", "callable": "busiestServers", "parameters": [{"name": "k", "type": "int"}, {"name": "arrival", "type": "list[int]"}, {"name": "load", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1608, "task_id": "special-array-with-x-elements-greater-than-or-equal-x", "difficulty": "Easy", "problem_description": "You are given an array nums of non-negative integers. nums is considered special if there exists a number x such that there are exactly x numbers in nums that are greater than or equal to x.\nNotice that x does not have to be an element in nums.\nReturn x if the array is special, otherwise, return -1. It can be proven that if nums is special, the value for x is unique.\n \nExample 1:\n\nInput: nums = [3,5]\nOutput: 2\nExplanation: There are 2 values (3 and 5) that are greater than or equal to 2.\n\nExample 2:\n\nInput: nums = [0,0]\nOutput: -1\nExplanation: No numbers fit the criteria for x.\nIf x = 0, there should be 0 numbers >= x, but there are 2.\nIf x = 1, there should be 1 number >= x, but there are 0.\nIf x = 2, there should be 2 numbers >= x, but there are 0.\nx cannot be greater since there are only 2 numbers in nums.\n\nExample 3:\n\nInput: nums = [0,4,3,0,4]\nOutput: 3\nExplanation: There are 3 values that are greater than or equal to 3.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n0 <= nums[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 10\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 3\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500]) == 5\n assert candidate(nums = [0, 0]) == -1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5]) == 3\n assert candidate(nums = [1000]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [0]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500]) == 5\n assert candidate(nums = [0, 4, 3, 0, 4]) == 3\n assert candidate(nums = [3, 5]) == 2\n assert candidate(nums = [1000, 999, 998, 997, 996]) == 5\n assert candidate(nums = [1, 2, 3, 3, 3]) == 3\n assert candidate(nums = [1000, 1000, 1000]) == 3\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000, 1000, 1000, 1000]) == 14\n assert candidate(nums = [9, 30, 20, 10, 40, 50, 60, 70, 80, 90]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(nums = [0, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == -1\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 20\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 60\n assert candidate(nums = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 20\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10]) == 8\n assert candidate(nums = [999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999]) == 11\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 98\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == -1\n assert candidate(nums = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(nums = [1, 2, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960]) == 41\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == -1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 28\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960, 959, 958, 957, 956, 955, 954, 953, 952, 951, 950]) == 50\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1000]) == -1\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10]) == -1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(nums = [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == 34\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 14\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5]) == -1\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 14\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == 7\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2, 3, 4, 5]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 8\n assert candidate(nums = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == -1\n assert candidate(nums = [1, 0, 3, 0, 5, 0, 7, 0, 9, 0, 11, 0, 13, 0, 15, 0, 17, 0, 19, 0]) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().specialArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def specialArray(self, nums: list[int]) -> int:", "container": "Solution", "callable": "specialArray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1609, "task_id": "even-odd-tree", "difficulty": "Medium", "problem_description": "A binary tree is named Even-Odd if it meets the following conditions:\n\nThe root of the binary tree is at level index 0, its children are at level index 1, their children are at level index 2, etc.\nFor every even-indexed level, all nodes at the level have odd integer values in strictly increasing order (from left to right).\nFor every odd-indexed level, all nodes at the level have even integer values in strictly decreasing order (from left to right).\n\nGiven the root of a binary tree, return true if the binary tree is Even-Odd, otherwise return false.\n \nExample 1:\n\n\nInput: root = [1,10,4,3,null,7,9,12,8,6,null,null,2]\nOutput: true\nExplanation: The node values on each level are:\nLevel 0: [1]\nLevel 1: [10,4]\nLevel 2: [3,7,9]\nLevel 3: [12,8,6,2]\nSince levels 0 and 2 are all odd and increasing and levels 1 and 3 are all even and decreasing, the tree is Even-Odd.\n\nExample 2:\n\n\nInput: root = [5,4,2,3,3,7]\nOutput: false\nExplanation: The node values on each level are:\nLevel 0: [5]\nLevel 1: [4,2]\nLevel 2: [3,3,7]\nNode values in level 2 must be in strictly increasing order, so the tree is not Even-Odd.\n\nExample 3:\n\n\nInput: root = [5,9,1,3,5,7]\nOutput: false\nExplanation: Node values in the level 1 should be even integers.\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 105].\n1 <= Node.val <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7])) == False\n assert candidate(root = tree_node([1, 2, 3])) == False\n assert candidate(root = tree_node([2, 1, 3, 4, 7, 6, 8, None, None, None, None, 9])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2])) == True\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 7])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6])) == False\n assert candidate(root = tree_node([1, 3, 5, 7, 9])) == False\n assert candidate(root = tree_node([2, 2, 2])) == False\n assert candidate(root = tree_node([2, 1, 3, 4, 7, 6, 8])) == False\n assert candidate(root = tree_node([5, 9, 1, 3, 5, 7])) == False\n assert candidate(root = tree_node([2, 1, 3, 4, 7, 6, 8, None, None, None, None, None, None, 9])) == False\n assert candidate(root = tree_node([1])) == True\n assert candidate(root = tree_node([11, 8, 6, 1, 3, 9, 11, 30, 20, 18, 16, 12, 10, 4, 2, 17])) == True\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 14])) == False\n assert candidate(root = tree_node([1, 10, 5, 3, 8, None, 7, None, 4, None, None, 2, 6, 9, 11])) == False\n assert candidate(root = tree_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, 21])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, 18, None, None, None, None, None, None, 20, None, None, 21, None, 22, None, None, 23])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, 18, None, None, None, None, None, None, None, None, 19, None, None, None, None, 20])) == False\n assert candidate(root = tree_node([5, 2, 8, None, 11, None, 21, None, 35, 18, None, None, 47, None, 53, 27, None, 65])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 6, 8, 9, 11, 13, 12, 14])) == False\n assert candidate(root = tree_node([10, 9, 10, 5, 7, 8, 9, 2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47])) == False\n assert candidate(root = tree_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, 13, 15, 17, 19, 21, 23])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 14, 16, 13, 11, 15, None, None, 18, 17, None, None, 19, None, None, 20])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, None, None, None, None, 13])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, 13, 15])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 14, 13, 11, None, None, 15, 17, 18])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, None, None, 5, None, None, 11, None, None, 13, None, None, 15])) == False\n assert candidate(root = tree_node([1, 8, 6, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 11, 15, None, 5])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 6, 1, 8, 9, 10, 11, 12, 13, 14])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, 16, 17, 18, 19, 20, 21, 22])) == False\n assert candidate(root = tree_node([5, 9, 1, 3, 5, 7, None, None, 8, 6, None, 10, 11, 12, None, 14, None, None, None, 13])) == False\n assert candidate(root = tree_node([2, 6, 10, 4, 8, 12, 16, 2, 4, 6, 8, 10, 12, 14, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 14, 16, 13, 11, 15, None, None, 18, 17, None, None, 19])) == False\n assert candidate(root = tree_node([11, 6, 8, 9, 5, 14, 7, 12, None, 9, 15, None, None, None, 1, None, None, 13, None, None, 10])) == False\n assert candidate(root = tree_node([1, 3, 2, 4, 6, 5, None, None, None, None, None, None, 7])) == False\n assert candidate(root = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 11, None, 5])) == False\n assert candidate(root = tree_node([3, 12, 8, 10, 14, 2, 13, 7, 12, None, 6, 14, 9, 14, 9, 14, None, None, 12, None, 13, 13, 7, 12, None, 12, 13, None, None, None, 10, None, 6, None, None, None, None, None, None, 10, None, 14, 9, 3, None, 13, 13, None, None, None, 12, None, None, None, 14, None, None, None, None, None, None, 14])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 11, None, None, None, 5])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, 16])) == False\n assert candidate(root = tree_node([7, 4, 9, 6, 5, 8, 3, 1, None, 2, 6, 4, 5, None, None, None, None, None, 9, 3])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 11, None, 16, 5])) == False\n assert candidate(root = tree_node([9, 14, 4, 14, 2, 9, 5, None, None, 6, None, None, 12, None, None, 14, None, 7, 10])) == False\n assert candidate(root = tree_node([2, 8, 6, 10, 4, 3, 7, 1, 9, 5, 6, 12, None, 11, None, None, None, None, None, None, None, 13])) == False\n assert candidate(root = tree_node([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 51])) == False\n assert candidate(root = tree_node([5, 9, 1, 3, 5, 7, None, None, 8, 6, None, 10, 11, 12, None, None, None, None, 13])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 5, None, None, 11, 14, None, None, 13, None, None, 15])) == False\n assert candidate(root = tree_node([2, 1, 3, 4, 7, 6, 8, None, None, None, None, 9, 10, 11, 12])) == False\n assert candidate(root = tree_node([2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53])) == False\n assert candidate(root = tree_node([1, 8, 6, None, 9, 2, 5, None, 11, None, None, None, 7])) == False\n assert candidate(root = tree_node([1, 3, 2, 5, 7, 6, 8, 9, 11, 13, 15, 14, 12, 10, 8])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 7, 8, 9, None, 11, None, 13, None, None, 17, None, None, 19])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, 18, None, None, None, None, None, None, 20, None, None, 21, None, 22, None, None, 24])) == False\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5])) == True\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 5, None, None, 11])) == True\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 8, 6, 4, 2, None, 9, 11, 13, 15, 17, 19, 21, 23, 25])) == False\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5])) == True\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, 13, 15, 17, 19, 21])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == False\n assert candidate(root = tree_node([2, 6, 1, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41])) == False\n assert candidate(root = tree_node([5, 8, 6, 3, 5, 7, 8, 1, 6, None, 10, 9, None, None, 11, None, None, 12, None, None, 13, None, None, 14, None, None, 15, None, None, 16])) == False\n assert candidate(root = tree_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 11, None, None, 5, None])) == False\n assert candidate(root = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 31])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, None, None, None, 13])) == False\n assert candidate(root = tree_node([3, 5, 9, 7, 11, 13, 17, 19, 23, 27, 29, 31, 35, 37, 39, 41, 43, 47, 51, 53, 57, 59])) == False\n assert candidate(root = tree_node([15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, 13])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, 8, 7, 9, 12, 8, 6, 11, None, None, 2, 5])) == False\n assert candidate(root = tree_node([8, 6, 10, 5, 3, 7, 9, 2, None, None, 6, None, None, 11, None, None, 2, 5, 12, 11, 10])) == False\n assert candidate(root = tree_node([15, 9, 11, 7, 13, 17, 19, 3, 5, 12, 14, 18, 20, None, None, None, None, 10])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 11, None, 15, None, 5])) == False\n assert candidate(root = tree_node([2, 1, 3, 4, 7, 6, 8, None, None, 9, 10, None, None, 11, 12, None, None, 13, 14])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, 9, None, 11, 13, None, 15])) == False\n assert candidate(root = tree_node([7, 4, 6, 1, None, None, 8, None, 1, None, 3, 5, 9])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 1, 6, None, 8, 4, 5, None, None, None, None, None, 9, 10])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, 18, None, None, None, None, None, None, 20, None, None, 21, None, 22, None, None, 25])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 14, 13, 11, None, None, 15])) == False\n assert candidate(root = tree_node([7, 6, 5, 4, 3, 2, 1, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, None, None, 8, 6, None, 9, None, None, None, None, 10])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, None, None, 13])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, 26, None, None, None, None, None, None, None, 27])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, 16, None, None, None, None, None, None, None, None, 17])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, None, None, 11, None, 5])) == False\n assert candidate(root = tree_node([1, 8, 6, None, 9, 2, 5, None, None, None, None, None, 7])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, None, 7, None, 9, None, 11, None, 13, None, 15, None, 17, None, 19])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 8, 9, None, 11, None, 13, None, 15, None, 17, None, 19])) == False\n assert candidate(root = tree_node([31, 15, 16, 7, 9, 11, 13, 3, 5, 6, 8, 10, 12, 14, 18, 1, 2, 4, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 25, None, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 14, 16, 13, 11, 15, None, None, 18, 17])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 14, 13, 11, None, None, 15, 17, 18, 20])) == False\n assert candidate(root = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29])) == False\n assert candidate(root = tree_node([1, 2, 3, None, 4, 5, 6, None, None, 7, 8, 9, 10, None, None, 11, 12, 13, 14])) == False\n assert candidate(root = tree_node([7, 10, 5, 1, 1, None, 6, None, None, 3, 8, 2, 4, None, None, None, 9])) == False\n assert candidate(root = tree_node([1, 3, 2, 4, 6, 5, None, None, None, None, None, 8, None, 7])) == False\n assert candidate(root = tree_node([1, 14, 3, 7, None, 7, 9, 12, 8, 6, None, 10, None, None, None, None, 11])) == False\n assert candidate(root = tree_node([5, 8, 6, 12, 4, None, 10, None, 2, 0, 3, 9, 7, 5, 6])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, None, None, 14, 16, None, 13, None, 11, None, 15, None, None, 18, 17])) == False\n assert candidate(root = tree_node([2, 3, 4, 5, 6, 7, 8, None, None, 9, 10, None, None, 11, 12, None, None, 13, 14, None, None, 15, 16, None, None, 17, 18])) == False\n assert candidate(root = tree_node([1, 2, 3, None, 5, None, 7, None, 9, None, 11])) == False\n assert candidate(root = tree_node([5, 9, 1, 3, 5, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 8, 1, 1, 6, 6, 9, 10, None, None, None, None, None, None, 11, 12])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 5, None, None, 10])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 6, 1, None, 8, 9, 10, 11, 12, 13])) == False\n assert candidate(root = tree_node([5, 9, 1, 3, 5, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, 11, None, 13, None, None, 17, None, None, 19])) == False\n assert candidate(root = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 8, 1, 6, None, 10, 9, None, None, 11, None, None, 12, 13])) == False\n assert candidate(root = tree_node([11, 13, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, None, None, 26, 27, 28, 29, 30, 31, 32, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 33])) == False\n assert candidate(root = tree_node([15, 20, 17, 12, 8, 13, 11, 7, 5, 6, 14, 4, 3, 10, 2, 1, 18, 16, 9, 19])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 14, 13, 11, None, None, 15, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 5, None, None, None, 11])) == True\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, 18, None, 19, None, None, 22, None, None, 23, None, None, 26, None, None, 27])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, 13, 15, 17, 19])) == False\n assert candidate(root = tree_node([11, 6, 10, 8, 6, 6, 6, 10, 8, 2, 4, None, None, 10, 1, None, None, 6, 2, 4, 8, None, 10, 6, 2, 6, 4, 8, None, 4, None, None, 4, None, 8, 10, None, 6, None, None, None, None, 4, 8, None, 6, None, 2, 10, 6, None, None, 10, None, None, None, None, None, None, 6, None, None, None, None, None, None, None, None, None, None, None, None, 10])) == False\n assert candidate(root = tree_node([1, 8, 6, 3, 5, 7, 9, 2, 4, None, 6, None, 8, None, None, None, None, None, 10])) == False\n assert candidate(root = tree_node([3, 12, 8, 10, 14, 9, 5, 11, 13, None, None, 4, 6, None, None, 2, 7, None, None, 15, None, 1, 16])) == False\n assert candidate(root = tree_node([5, 9, 1, 3, 5, 7, 6, 2, 4, 8, 10, 12, 14, 16, 18])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 11, 14, None, 5])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, 13, 15, 17])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 5, None, None, None, None, 11])) == True\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, 13, 15, 17, 19, 21, 23, 25])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, None, None, 6, 8, 9, 12])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 8, 6, 5, 4, 3, 2, 1])) == False\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().isEvenOddTree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def isEvenOddTree(self, root: TreeNode | None) -> bool:", "container": "Solution", "callable": "isEvenOddTree", "parameters": [{"name": "root", "type": "TreeNode | None"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1610, "task_id": "maximum-number-of-visible-points", "difficulty": "Hard", "problem_description": "You are given an array points, an integer angle, and your location, where location = [posx, posy] and points[i] = [xi, yi] both denote integral coordinates on the X-Y plane.\nInitially, you are facing directly east from your position. You cannot move from your position, but you can rotate. In other words, posx and posy cannot be changed. Your field of view in degrees is represented by angle, determining how wide you can see from any given view direction. Let d be the amount in degrees that you rotate counterclockwise. Then, your field of view is the inclusive range of angles [d - angle/2, d + angle/2].\n\nYour browser does not support the video tag or this video format.\n\nYou can see some set of points if, for each point, the angle formed by the point, your position, and the immediate east direction from your position is in your field of view.\nThere can be multiple points at one coordinate. There may be points at your location, and you can always see these points regardless of your rotation. Points do not obstruct your vision to other points.\nReturn the maximum number of points you can see.\n \nExample 1:\n\n\nInput: points = [[2,1],[2,2],[3,3]], angle = 90, location = [1,1]\nOutput: 3\nExplanation: The shaded region represents your field of view. All points can be made visible in your field of view, including [3,3] even though [2,2] is in front and in the same line of sight.\n\nExample 2:\n\nInput: points = [[2,1],[2,2],[3,4],[1,1]], angle = 90, location = [1,1]\nOutput: 4\nExplanation: All points can be made visible in your field of view, including the one at your location.\n\nExample 3:\n\n\nInput: points = [[1,0],[2,1]], angle = 13, location = [1,1]\nOutput: 1\nExplanation: You can only see one of the two points, as shown above.\n\n \nConstraints:\n\n1 <= points.length <= 105\npoints[i].length == 2\nlocation.length == 2\n0 <= angle < 360\n0 <= posx, posy, xi, yi <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1]],angle = 90,location = [0, 0]) == 2\n assert candidate(points = [[100, 100], [100, 99], [99, 100], [99, 99]],angle = 45,location = [100, 100]) == 3\n assert candidate(points = [[0, 0], [5, 5], [10, 10]],angle = 90,location = [0, 0]) == 3\n assert candidate(points = [[2, 2], [3, 3], [4, 4], [1, 1]],angle = 45,location = [2, 2]) == 3\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1]],angle = 0,location = [0, 0]) == 2\n assert candidate(points = [[1, 0], [2, 1]],angle = 13,location = [1, 1]) == 1\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5]],angle = 45,location = [1, 1]) == 4\n assert candidate(points = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2]],angle = 90,location = [3, 2]) == 3\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3]],angle = 0,location = [0, 0]) == 4\n assert candidate(points = [[50, 50], [51, 50], [52, 50]],angle = 1,location = [50, 50]) == 3\n assert candidate(points = [[0, 0], [50, 50]],angle = 90,location = [25, 25]) == 1\n assert candidate(points = [[2, 1], [2, 2], [3, 3]],angle = 90,location = [1, 1]) == 3\n assert candidate(points = [[100, 100]],angle = 360,location = [100, 100]) == 1\n assert candidate(points = [[0, 0], [100, 100]],angle = 1,location = [50, 50]) == 1\n assert candidate(points = [[1, 1], [1, 1], [1, 1]],angle = 180,location = [1, 1]) == 3\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],angle = 360,location = [1, 1]) == 5\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],angle = 180,location = [3, 3]) == 5\n assert candidate(points = [[10, 10], [11, 10], [12, 10], [13, 10], [14, 10]],angle = 45,location = [10, 10]) == 5\n assert candidate(points = [[1, 1], [2, 2], [1, 2], [2, 1]],angle = 45,location = [1, 1]) == 3\n assert candidate(points = [[2, 1], [2, 2], [3, 4], [1, 1]],angle = 90,location = [1, 1]) == 4\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1]],angle = 90,location = [0, 0]) == 4\n assert candidate(points = [[0, 0], [0, 0], [0, 0]],angle = 180,location = [0, 0]) == 3\n assert candidate(points = [[1, 1], [1, 1], [1, 1]],angle = 360,location = [1, 1]) == 3\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],angle = 360,location = [1, 1]) == 17\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1], [2, 0], [0, 2], [-2, 0], [0, -2]],angle = 45,location = [0, 0]) == 2\n assert candidate(points = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15], [5, 5], [25, 25], [5, 25], [25, 5], [15, 5], [5, 15], [25, 15], [15, 25]],angle = 120,location = [15, 15]) == 6\n assert candidate(points = [[5, 5], [10, 5], [15, 5], [20, 5], [25, 5], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10]],angle = 45,location = [15, 15]) == 5\n assert candidate(points = [[0, 0], [10, 0], [20, 0], [30, 0], [40, 0], [50, 0], [60, 0], [70, 0], [80, 0], [90, 0]],angle = 10,location = [50, 0]) == 6\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 30,location = [5, 5]) == 5\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]],angle = 10,location = [1, 5]) == 5\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3], [4, 4]],angle = 180,location = [1, 1]) == 10\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4]],angle = 180,location = [2, 2]) == 12\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],angle = 30,location = [5, 1]) == 10\n assert candidate(points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],angle = 30,location = [5, 5]) == 6\n assert candidate(points = [[2, 1], [1, 2], [3, 1], [1, 3], [2, 2]],angle = 90,location = [2, 1]) == 4\n assert candidate(points = [[10, 0], [20, 0], [30, 0], [40, 0], [50, 0]],angle = 180,location = [25, 25]) == 5\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],angle = 359,location = [1, 1]) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],angle = 180,location = [5, 5]) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 5], [5, 1]],angle = 90,location = [3, 3]) == 4\n assert candidate(points = [[100, 100], [50, 50], [50, 100], [100, 50], [75, 75], [25, 25], [75, 25], [25, 75]],angle = 45,location = [50, 50]) == 4\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],angle = 90,location = [4, 4]) == 5\n assert candidate(points = [[2, 3], [3, 2], [4, 5], [5, 4], [6, 5], [5, 6]],angle = 45,location = [4, 4]) == 2\n assert candidate(points = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [5, 6], [6, 5], [5, 4], [4, 5]],angle = 90,location = [5, 5]) == 8\n assert candidate(points = [[2, 1], [3, 4], [5, 5], [4, 2], [1, 2], [3, 1]],angle = 45,location = [3, 3]) == 2\n assert candidate(points = [[2, 0], [2, 2], [1, 3], [3, 3], [0, 2]],angle = 60,location = [2, 1]) == 3\n assert candidate(points = [[5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],angle = 10,location = [5, 5]) == 6\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9]],angle = 90,location = [5, 1]) == 11\n assert candidate(points = [[10, 10], [10, 9], [9, 10], [9, 11], [11, 10], [11, 11], [8, 8], [8, 9], [9, 8], [11, 9]],angle = 45,location = [10, 10]) == 4\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]],angle = 30,location = [5, 5]) == 4\n assert candidate(points = [[1, 2], [2, 2], [4, 5], [5, 4], [3, 3]],angle = 45,location = [3, 3]) == 3\n assert candidate(points = [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [0, 1], [2, 1], [0, 2], [2, 2], [0, 3], [2, 3], [0, 4], [2, 4], [0, 5], [2, 5]],angle = 90,location = [1, 1]) == 17\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],angle = 45,location = [25, 25]) == 3\n assert candidate(points = [[5, 5], [5, 10], [5, 15], [5, 20], [5, 25]],angle = 90,location = [5, 15]) == 3\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],angle = 30,location = [3, 3]) == 3\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],angle = 90,location = [5, 1]) == 6\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],angle = 30,location = [5, 5]) == 4\n assert candidate(points = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15], [5, 5], [25, 25]],angle = 90,location = [15, 15]) == 4\n assert candidate(points = [[0, 1], [1, 0], [0, -1], [-1, 0], [0, 0], [1, 1], [-1, -1], [1, -1], [-1, 1]],angle = 90,location = [0, 0]) == 4\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 45,location = [5, 5]) == 6\n assert candidate(points = [[50, 50], [50, 40], [50, 30], [50, 20], [50, 10], [50, 0], [50, -10], [50, -20], [50, -30], [50, -40]],angle = 120,location = [50, 50]) == 10\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3]],angle = 60,location = [2, 2]) == 3\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5]],angle = 90,location = [3, 3]) == 9\n assert candidate(points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],angle = 45,location = [5, 5]) == 6\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 30,location = [0, 0]) == 10\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],angle = 60,location = [5, 1]) == 6\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70]],angle = 15,location = [10, 10]) == 7\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],angle = 30,location = [25, 25]) == 3\n assert candidate(points = [[100, 0], [0, 100], [100, 100], [50, 50], [25, 25], [75, 75]],angle = 60,location = [50, 50]) == 3\n assert candidate(points = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],angle = 180,location = [10, 5]) == 10\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1], [0, 0]],angle = 90,location = [0, 0]) == 3\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [11, 0]],angle = 90,location = [5, 0]) == 7\n assert candidate(points = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10]],angle = 15,location = [25, 10]) == 3\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2]],angle = 90,location = [3, 2]) == 6\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],angle = 90,location = [30, 30]) == 3\n assert candidate(points = [[1, 0], [0, 1], [1, 1], [0, 0], [2, 2], [3, 3], [4, 4], [5, 5]],angle = 90,location = [1, 1]) == 5\n assert candidate(points = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],angle = 60,location = [5, 5]) == 6\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],angle = 10,location = [5, 5]) == 6\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]],angle = 10,location = [5, 1]) == 5\n assert candidate(points = [[10, 10], [11, 11], [10, 11], [9, 10], [10, 9], [9, 9], [9, 11], [11, 9]],angle = 60,location = [10, 10]) == 3\n assert candidate(points = [[0, 1], [1, 0], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],angle = 60,location = [3, 3]) == 5\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [10, 10], [10, 11], [11, 10], [11, 11]],angle = 90,location = [8, 8]) == 4\n assert candidate(points = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15]],angle = 45,location = [15, 15]) == 2\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 2], [1, 3], [1, 3], [1, 3], [1, 4], [1, 4], [1, 4], [1, 5], [1, 5], [1, 5], [1, 1], [1, 1], [1, 1]],angle = 10,location = [1, 3]) == 12\n assert candidate(points = [[100, 0], [0, 100], [0, 0], [100, 100], [50, 50]],angle = 90,location = [50, 50]) == 3\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 10,location = [5, 5]) == 6\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [7, 8], [8, 7], [8, 8]],angle = 90,location = [6, 6]) == 5\n assert candidate(points = [[50, 50], [50, 49], [50, 51], [49, 50], [51, 50], [49, 49], [51, 51], [52, 52], [48, 48]],angle = 30,location = [50, 50]) == 3\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],angle = 5,location = [1, 5]) == 6\n assert candidate(points = [[2, 0], [0, 2], [2, 2], [1, 1], [0, 0], [1, 0]],angle = 45,location = [1, 1]) == 3\n assert candidate(points = [[10, 0], [0, 10], [10, 10], [5, 5], [2, 2], [8, 8]],angle = 30,location = [5, 5]) == 3\n assert candidate(points = [[1, 1], [2, 1], [2, 2], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [4, 4]],angle = 45,location = [3, 3]) == 6\n assert candidate(points = [[1, 2], [2, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],angle = 120,location = [1, 1]) == 10\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 90,location = [0, 0]) == 10\n assert candidate(points = [[100, 100], [100, 99], [99, 100], [99, 98], [101, 100], [100, 101]],angle = 10,location = [100, 100]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],angle = 90,location = [1, 1]) == 15\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 45,location = [5, 5]) == 5\n assert candidate(points = [[10, 10], [20, 10], [15, 20], [10, 15], [15, 15]],angle = 30,location = [15, 15]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],angle = 90,location = [5, 5]) == 6\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],angle = 360,location = [5, 5]) == 15\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],angle = 360,location = [3, 4]) == 11\n assert candidate(points = [[10, 10], [10, 11], [11, 10], [11, 11], [10, 9], [9, 10], [9, 9], [9, 11], [11, 9]],angle = 60,location = [10, 10]) == 3\n assert candidate(points = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3]],angle = 10,location = [2, 2]) == 1\n assert candidate(points = [[10, 0], [0, 10], [10, 10], [0, 0], [5, 5]],angle = 60,location = [5, 5]) == 2\n assert candidate(points = [[50, 50], [50, 40], [50, 60], [40, 50], [60, 50], [40, 40], [60, 60], [40, 60], [60, 40], [50, 30], [50, 70], [30, 50], [70, 50]],angle = 60,location = [50, 50]) == 4\n assert candidate(points = [[10, 10], [9, 10], [8, 10], [7, 10], [6, 10], [5, 10], [4, 10], [3, 10], [2, 10], [1, 10]],angle = 5,location = [5, 10]) == 6\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],angle = 20,location = [1, 5]) == 6\n assert candidate(points = [[90, 90], [91, 90], [90, 91], [91, 91], [100, 100]],angle = 10,location = [90, 90]) == 3\n assert candidate(points = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],angle = 30,location = [5, 5]) == 4\n assert candidate(points = [[10, 1], [1, 10], [10, 9], [9, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],angle = 60,location = [5, 5]) == 5\n assert candidate(points = [[5, 0], [5, 10], [10, 5], [0, 5]],angle = 180,location = [5, 5]) == 3\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 2], [1, 3], [1, 3], [1, 3], [1, 4], [1, 4], [1, 4], [1, 5], [1, 5], [1, 5]],angle = 10,location = [1, 3]) == 9\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70], [10, 80], [10, 90]],angle = 10,location = [10, 50]) == 5\n assert candidate(points = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]],angle = 10,location = [5, 0]) == 6\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],angle = 180,location = [1, 1]) == 10\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]],angle = 5,location = [5, 1]) == 5\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],angle = 30,location = [5, 50]) == 6\n assert candidate(points = [[5, 0], [0, 5], [5, 5], [0, 0], [2, 2], [3, 3], [1, 1], [4, 4]],angle = 90,location = [2, 2]) == 5\n assert candidate(points = [[1, 0], [2, 1], [3, 0], [4, 1], [5, 0], [6, 1], [7, 0], [8, 1], [9, 0], [10, 1]],angle = 15,location = [5, 0]) == 4\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7]],angle = 45,location = [5, 5]) == 4\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [20, 10], [20, 20], [20, 30], [30, 10], [30, 20], [30, 30]],angle = 30,location = [20, 20]) == 2\n assert candidate(points = [[1, 0], [2, 1], [1, 2], [0, 1], [0, 2], [1, 1], [2, 0], [2, 2], [0, 0]],angle = 45,location = [1, 1]) == 3\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0]],angle = 90,location = [2, 0]) == 4\n assert candidate(points = [[50, 50], [51, 50], [52, 50], [53, 50], [54, 50], [55, 50]],angle = 5,location = [52, 50]) == 4\n assert candidate(points = [[10, 10], [20, 10], [10, 20], [20, 20], [10, 30], [20, 30], [10, 40], [20, 40]],angle = 180,location = [15, 15]) == 7\n assert candidate(points = [[100, 0], [0, 100], [50, 50], [25, 25], [75, 75]],angle = 45,location = [50, 50]) == 2\n assert candidate(points = [[1, 2], [2, 2], [4, 5], [5, 4], [3, 3], [2, 1]],angle = 45,location = [3, 3]) == 4\n assert candidate(points = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]],angle = 180,location = [5, 0]) == 10\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]],angle = 180,location = [5, 1]) == 9\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],angle = 90,location = [1, 5]) == 6\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]],angle = 1,location = [5, 0]) == 6\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],angle = 40,location = [50, 50]) == 6\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],angle = 45,location = [1, 5]) == 6\n assert candidate(points = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40]],angle = 90,location = [20, 20]) == 5\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2]],angle = 90,location = [3, 1]) == 6\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 60,location = [5, 5]) == 6\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]],angle = 45,location = [50, 50]) == 5\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [8, 8], [9, 9], [5, 4], [4, 5], [4, 4], [6, 4], [4, 6], [7, 6], [6, 7], [8, 6], [6, 8]],angle = 45,location = [5, 5]) == 8\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],angle = 30,location = [1, 1]) == 10\n assert candidate(points = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],angle = 10,location = [5, 5]) == 6\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [2, 1], [2, 1], [2, 1], [3, 1], [3, 1], [3, 1], [4, 1], [4, 1], [4, 1], [5, 1], [5, 1], [5, 1]],angle = 90,location = [3, 1]) == 9\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [10, 10], [10, 10]],angle = 45,location = [15, 15]) == 3\n assert candidate(points = [[2, 2], [3, 2], [4, 2], [2, 3], [3, 3], [4, 3], [2, 4], [3, 4], [4, 4]],angle = 45,location = [3, 3]) == 3\n"}, "metadata": {"canonical_parameter_names": ["points", "angle", "location"], "leetcode_dataset_entry_point": "Solution().visiblePoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def visiblePoints(self, points: list[list[int]], angle: int, location: list[int]) -> int:", "container": "Solution", "callable": "visiblePoints", "parameters": [{"name": "points", "type": "list[list[int]]"}, {"name": "angle", "type": "int"}, {"name": "location", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1611, "task_id": "minimum-one-bit-operations-to-make-integers-zero", "difficulty": "Hard", "problem_description": "Given an integer n, you must transform it into 0 using the following operations any number of times:\n\nChange the rightmost (0th) bit in the binary representation of n.\nChange the ith bit in the binary representation of n if the (i-1)th bit is set to 1 and the (i-2)th through 0th bits are set to 0.\n\nReturn the minimum number of operations to transform n into 0.\n \nExample 1:\n\nInput: n = 3\nOutput: 2\nExplanation: The binary representation of 3 is \"11\".\n\"11\" -> \"01\" with the 2nd operation since the 0th bit is 1.\n\"01\" -> \"00\" with the 1st operation.\n\nExample 2:\n\nInput: n = 6\nOutput: 4\nExplanation: The binary representation of 6 is \"110\".\n\"110\" -> \"010\" with the 2nd operation since the 1st bit is 1 and 0th through 0th bits are 0.\n\"010\" -> \"011\" with the 1st operation.\n\"011\" -> \"001\" with the 2nd operation since the 0th bit is 1.\n\"001\" -> \"000\" with the 1st operation.\n\n \nConstraints:\n\n0 <= n <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 0\n assert candidate(n = 8) == 15\n assert candidate(n = 3) == 2\n assert candidate(n = 100) == 71\n assert candidate(n = 15) == 10\n assert candidate(n = 16) == 31\n assert candidate(n = 31) == 21\n assert candidate(n = 1000000000) == 756249599\n assert candidate(n = 32) == 63\n assert candidate(n = 6) == 4\n assert candidate(n = 1023) == 682\n assert candidate(n = 1) == 1\n assert candidate(n = 500) == 344\n assert candidate(n = 7) == 5\n assert candidate(n = 10) == 12\n assert candidate(n = 1024) == 2047\n assert candidate(n = 2097152) == 4194303\n assert candidate(n = 63) == 42\n assert candidate(n = 896) == 767\n assert candidate(n = 131071) == 87381\n assert candidate(n = 67108864) == 134217727\n assert candidate(n = 4096) == 8191\n assert candidate(n = 67108863) == 44739242\n assert candidate(n = 2147483647) == 1431655765\n assert candidate(n = 32767) == 21845\n assert candidate(n = 511) == 341\n assert candidate(n = 262143) == 174762\n assert candidate(n = 2047) == 1365\n assert candidate(n = 268435456) == 536870911\n assert candidate(n = 16383) == 10922\n assert candidate(n = 16384) == 32767\n assert candidate(n = 524287) == 349525\n assert candidate(n = 987654) == 662532\n assert candidate(n = 268435455) == 178956970\n assert candidate(n = 16777216) == 33554431\n assert candidate(n = 4194303) == 2796202\n assert candidate(n = 134217727) == 89478485\n assert candidate(n = 64) == 127\n assert candidate(n = 8388607) == 5592405\n assert candidate(n = 2097151) == 1398101\n assert candidate(n = 4194304) == 8388607\n assert candidate(n = 192) == 128\n assert candidate(n = 134217728) == 268435455\n assert candidate(n = 1073741823) == 715827882\n assert candidate(n = 33554432) == 67108863\n assert candidate(n = 16777215) == 11184810\n assert candidate(n = 1073741824) == 2147483647\n assert candidate(n = 4095) == 2730\n assert candidate(n = 128) == 255\n assert candidate(n = 100000) == 66752\n assert candidate(n = 255) == 170\n assert candidate(n = 1048576) == 2097151\n assert candidate(n = 8192) == 16383\n assert candidate(n = 8191) == 5461\n assert candidate(n = 2048) == 4095\n assert candidate(n = 65536) == 131071\n assert candidate(n = 256) == 511\n assert candidate(n = 262144) == 524287\n assert candidate(n = 65535) == 43690\n assert candidate(n = 127) == 85\n assert candidate(n = 987654321) == 747917089\n assert candidate(n = 1048575) == 699050\n assert candidate(n = 500000000) == 378124799\n assert candidate(n = 536870911) == 357913941\n assert candidate(n = 1000000) == 687231\n assert candidate(n = 512) == 1023\n assert candidate(n = 123456789) == 93489638\n assert candidate(n = 1047552) == 698368\n assert candidate(n = 123456) == 82816\n assert candidate(n = 33554431) == 22369621\n assert candidate(n = 54321) == 38945\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minimumOneBitOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumOneBitOperations(self, n: int) -> int:", "container": "Solution", "callable": "minimumOneBitOperations", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1614, "task_id": "maximum-nesting-depth-of-the-parentheses", "difficulty": "Easy", "problem_description": "Given a valid parentheses string s, return the nesting depth of s. The nesting depth is the maximum number of nested parentheses.\n \nExample 1:\n\nInput: s = \"(1+(2*3)+((8)/4))+1\"\nOutput: 3\nExplanation:\nDigit 8 is inside of 3 nested parentheses in the string.\n\nExample 2:\n\nInput: s = \"(1)+((2))+(((3)))\"\nOutput: 3\nExplanation:\nDigit 3 is inside of 3 nested parentheses in the string.\n\nExample 3:\n\nInput: s = \"()(())((()()))\"\nOutput: 3\n\n \nConstraints:\n\n1 <= s.length <= 100\ns consists of digits 0-9 and characters '+', '-', '*', '/', '(', and ')'.\nIt is guaranteed that parentheses expression s is a VPS.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(1+(2*3)+((8)/4))+1\") == 3\n assert candidate(s = \"(a+(b*c)+((d/e)+f))\") == 3\n assert candidate(s = \"()()()\") == 1\n assert candidate(s = \"(a+b)+((c*d)+e)\") == 2\n assert candidate(s = \"(1+2)\") == 1\n assert candidate(s = \"1+(2*3)\") == 1\n assert candidate(s = \"\") == 0\n assert candidate(s = \"(())\") == 2\n assert candidate(s = \"((1+3)*(2-4))\") == 2\n assert candidate(s = \"(1)\") == 1\n assert candidate(s = \"((())()())\") == 3\n assert candidate(s = \"((1+2)*3/(4-5))\") == 2\n assert candidate(s = \"(1)+((2))+(((3)))\") == 3\n assert candidate(s = \"()(())((()()))\") == 3\n assert candidate(s = \"()\") == 1\n assert candidate(s = \"(a+b+c)*(d/e/f)+((g-(h*i))+j)\") == 3\n assert candidate(s = \"(a)\") == 1\n assert candidate(s = \"((()))\") == 3\n assert candidate(s = \"((a+b)*c)+(((d+e)*f)+g)\") == 3\n assert candidate(s = \"(1+(2*(((3+4)*5)+(6/(7*((8-9)+10))))))\") == 7\n assert candidate(s = \"(a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+(p+(q+(r+(s+(t+(u+(v+(w+(x+(y+(z+(a+b))))))))))))))))))))))))))\") == 27\n assert candidate(s = \"(((((1+2)*(3+4))-((5+6)*(7+8)))+(((9+0)*(1+2))-((3+4)*(5+6))))\") == 5\n assert candidate(s = \"((a+(b*c))+((d+e)/(f-g)))+((h*(i-j)))\") == 3\n assert candidate(s = \"((a+b)+(((c+d)+((e+f)+((g+h)+((i+j)+((k+l)+((m+n)+((o+p)+((q+r)+((s+t)+u))))))))))\") == 12\n assert candidate(s = \"((x+y)+((z+w)*((a+b)*(c+d))))\") == 4\n assert candidate(s = \"(((a+b)+((c+d)*(e+f)))+((g-h)*((i+j)/(k-l))))\") == 4\n assert candidate(s = \"(1+(((2+((3+((4+((5+((6+((7+((8+((9+(10)))))))))))))))))))\") == 19\n assert candidate(s = \"(((a+b)+(c*d))+(((e-f)-(g*h)))+((i+j)*(k+l)))\") == 4\n assert candidate(s = \"(x+(y*(z+(w/(v+(u+((t)+s))))))\") == 8\n assert candidate(s = \"(((a+b)+c)+((d+e)+f))+(((g+h)+i)+(j+(k+l)))\") == 3\n assert candidate(s = \"(a+(b*(c+(d/(e+f)+g)+h)+i)\") == 5\n assert candidate(s = \"((a+b)+(c*(d+(e/(f+(g+(h+(i+(j))))))))\") == 9\n assert candidate(s = \"(1+(2*(3+(4*(5+(6+(7*(8+(9*(10)))))))))\") == 10\n assert candidate(s = \"(((((((a+b)*c)+d)+e)+f)+g)+h)\") == 7\n assert candidate(s = \"(1+(2*(3+(4*(5+(6+(7+(8+(9))))))))\") == 9\n assert candidate(s = \"(((a+(b*c))+((d+(e*f))+(g+(h*i))))+((j+(k*l))+((m+(n*o))+(p+(q+(r+(s+t))))))\") == 7\n assert candidate(s = \"(1+(2*((3+4)*(5+6)*((7+8)*(9+10))))+11)\") == 5\n assert candidate(s = \"((a+(b*(c+(d*(e+f)))))+(((g-h)+(i-j))*((k-l)+(m*n))))\") == 6\n assert candidate(s = \"((a+b)*((c-d)+e))+((f+(g/h))-((i*j)))\") == 3\n assert candidate(s = \"(1+((2+((3+((4+((5+6)+7))+8))+9))+10)+11\") == 9\n assert candidate(s = \"((a+b)+(((c+d)+((e+f)+((g+h)*(i+j))))*(k+l)))\") == 6\n assert candidate(s = \"((a+(b*c))+(d/((e+f)*(g-h))))\") == 4\n assert candidate(s = \"(((((x+(y*z))+(w*((a+b)*c)))+((d+e)+((f*g)+((h+i)+((j+k)*l)))))\") == 8\n assert candidate(s = \"((x+(y*z))+((u-(v*w))+(((p+q)*r)/s)))\") == 5\n assert candidate(s = \"(a+(b*(c+d)))+((e+f)*((g+h)*(i+j)))+(((k+l)*(m+n))+(o+(p*(q+r))))\") == 4\n assert candidate(s = \"(a+(b*(c+d)))+((e/f)-(g*h))\") == 3\n assert candidate(s = \"((1+(2*(3+(4*(5+(6*(7+(8*(9))))))))+10)\") == 10\n assert candidate(s = \"(a+(b*(c+d))+e+(f/(g-h)))\") == 3\n assert candidate(s = \"(((((1+2)*3)+4)*5)+((6+(7*(8+9)))/10))\") == 5\n assert candidate(s = \"(((((a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+p))))))))))))+q)+r)+s)+t)+u)+v\") == 19\n assert candidate(s = \"((a+b)+((c+d)+((e+f)+((g+h)+((i+j)+((k+l)+((m+n)+((o+p)+((q+r)+((s+t)+((u+v)+((w+x)+((y+z))))))))))))\") == 14\n assert candidate(s = \"((((a+b)+((c+d)*(e+f)))+((g+h)+((i+j)*(k+l))))+(m+(n*(o+p))))\") == 5\n assert candidate(s = \"((((a+b)*c)+((d+e)*f))+(((g+h)*i)+((j+k)*l)))+((((m+n)*o)+((p+q)*r))+(((s+t)*u)+((v+w)*x))))\") == 4\n assert candidate(s = \"(1+(2+(3+(4+(5+(6+(7+(8+(9))))))))\") == 9\n assert candidate(s = \"(((1+2)*3)+((4+5)*(6/7)))+(((8+9)*((10-11)/12)))+13\") == 4\n assert candidate(s = \"((x+(y*((z+w)*v)))+(((u-t)-s)+(((r-q)+(p-o))*(n-m))))\") == 5\n assert candidate(s = \"(1+((2*((3+4)*(5-6)))/(7+(8*(9-10)))))\") == 5\n assert candidate(s = \"(a+(b*(c+d)))+((e+f)/(g-h))\") == 3\n assert candidate(s = \"(1+((2+3)*(4/5)))+((6-(7+8))*(((9/10)-11)+(12*13)))\") == 4\n assert candidate(s = \"((1)+((2)+(((3)+((4)+(5)))+(6))))\") == 6\n assert candidate(s = \"((1+2)*((3/4)-5)+((6*7)+8))\") == 3\n assert candidate(s = \"(a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+p))))))))))))+q)+r)+s\") == 15\n assert candidate(s = \"((x+(y*z))+((u-(v*w))+(((p+q)*r)/s)))+((t+(u*v))+(((w+x)*y)/z))\") == 5\n assert candidate(s = \"((1+2)*((3+4)*((5+6)*((7+8)*((9+0))))))\") == 6\n assert candidate(s = \"(a+((b+((c+((d+e)*f))*g))*h))\") == 7\n assert candidate(s = \"(((((1+2)+3)+4)+5)+6)+7\") == 5\n assert candidate(s = \"((a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+(p+(q+(r+(s+(t+(u+(v+(w+(x+(y+(z*1))))))))))))))))))))))))\") == 27\n assert candidate(s = \"(a+(b*(c+(d*(e+(f*(g+(h*(i+(j)))))))))+(k+(l*(m+(n*(o+(p*(q+(r*(s+(t))))))))))\") == 11\n assert candidate(s = \"(((((1+2)*3)+4)*5)+6)\") == 5\n assert candidate(s = \"(((a+b)+((c+d)*(e/f)))+(((g-h)+(i/j))*((k+l)*(m-n))))\") == 4\n assert candidate(s = \"((1+((2+3)*4))+(((5-6)+7)+((8+9)*10)))+(((11+(12*13))+14)+15)\") == 4\n assert candidate(s = \"(a+((b+c)*(d+((e+f)*(g+(h+i)))))+((j-k)*((l-m)+((n-o)*(p+((q-r)+s)))))\") == 7\n assert candidate(s = \"(1+(2*(3+(4*(5+(6+(7+(8+(9+0))))))))\") == 9\n assert candidate(s = \"((1+2)*((3+(4*(5+(6/7))))+((8-(9*10))+((11*12)+((13/14)+15))))\") == 6\n assert candidate(s = \"1+((2+(3*(4+5)))/6)+(((7-8)*9)/10)\") == 4\n assert candidate(s = \"((1+(2+(3+(4+(5+(6+(7+(8+(9+(10+(11+(12+(13+(14+(15+(16+(17+(18+(19+(20+(21+(22+(23+(24+(25+(26+(27+(28+(29+(30)))))))))))))))))))))))))+31)+32)+33\") == 31\n assert candidate(s = \"(a+(b+(c+(d+(e+(f+(g+(h+(i+(j)))))))))\") == 10\n assert candidate(s = \"(((((a+b)+(c*d))-(e/f))*g)+(h-(i+j)))\") == 5\n assert candidate(s = \"(((a+(b*c))+((d+(e*f))+((g+(h*i))+((j+(k*l))+((m+(n*o))+((p+(q*r))+((s+(t*u))+((v+(w*x))+((y+(z*1))+2))))))))\") == 12\n assert candidate(s = \"(a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+(p+(q+(r+(s+(t+(u+(v+(w+(x+(y+(z+(a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+p))))))))))))))))))))))))))))))))+a)+b)+c)+d)+e)+f)+g)+h)+i)+j)+k)+l)+m)+n)+o)+p)+q)+r)+s)+t)+u)+v)+w)+x)+y)+z\") == 41\n assert candidate(s = \"(1+((2+(3*(4/5)))+((6-(7*8))))\") == 5\n assert candidate(s = \"(1+(2*((3+4)*(5+(6*(7+(8+9))))))+(10*((11-12)+(13*((14-15)+(16*(17+18))))))\") == 7\n assert candidate(s = \"((x+(y*z))+(u/(v-((w+x)*(y-z)))))+(a+b)-(c*d)\") == 5\n assert candidate(s = \"(((a+b)*(c-d))+(((e+f)*(g-h))+(((i+j)*(k-l))+(((m+n)*(o-p))+((q+r)*(s-t)))))\") == 6\n assert candidate(s = \"(((a+b)*((c-d)+e))-(((f+g)*h)-(i/j)))\") == 4\n assert candidate(s = \"(((((1+2)*3)+((4-5)*6))+(((7/8)+9)*10)))\") == 5\n assert candidate(s = \"(((((1)+2)*3)+(((((4)+5)*6)+((7)+8))))\") == 7\n assert candidate(s = \"(a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+(p+(q+(r+(s+(t+(u+(v+(w+(x+(y+z))))))))))))))))))))))\") == 25\n assert candidate(s = \"(((1+2)*((3-4)+(5/6)))+(((7*8)-9)+((10+11)*12)))\") == 4\n assert candidate(s = \"(a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+(p+(q+(r+(s+(t+(u+(v+(w+(x+(y+(z+(a+b)))))))))))))))))))))))))\") == 27\n assert candidate(s = \"((a+(b*c)+(d/e))-(((f+g)*(h-i))+((j/k)+(l*m))))\") == 4\n assert candidate(s = \"(a+(b*(c/(d-e))))+(((f+g)*((h-i)+j))+((k-l)/(m*(n-o))))\") == 4\n assert candidate(s = \"((a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+(p+(q+(r+(s+(t+(u+(v+(w+(x+(y+z))))))))))))))))))))))))\") == 26\n assert candidate(s = \"(a+(b*(c+d)))+((e+f)/(g-(h*i)))\") == 3\n assert candidate(s = \"(a+(b*(c+d)))+(((e+f)*(g-h)))+1\") == 3\n assert candidate(s = \"(a+(b*(c+(d/(e+(f*(g+(h/(i+j))))))))\") == 9\n assert candidate(s = \"(1+(2*(3+4)/(5-6))+((7+8)*9))\") == 3\n assert candidate(s = \"((((((((((1+2)+3)+4)+5)+6)+7)+8)+9)+10)\") == 10\n assert candidate(s = \"(((((x*y)+z)+((a*b)+c))+(((d*e)+f)+((g*h)+i))))\") == 5\n assert candidate(s = \"(a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+(p+(q+(r+(s+(t+(u+(v+(w+(x+(y+z)))))))))))))))))))))+a)+b)+c\") == 25\n assert candidate(s = \"((((1+(2+(3+(4+(5+(6+(7+(8+(9+(10+(11+(12+(13+(14+(15+(16+(17+(18+(19+(20))))))))))))))))+21)+22)+23)+24)+25)+26\") == 23\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxDepth", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxDepth(self, s: str) -> int:", "container": "Solution", "callable": "maxDepth", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1615, "task_id": "maximal-network-rank", "difficulty": "Medium", "problem_description": "There is an infrastructure of n cities with some number of roads connecting these cities. Each roads[i] = [ai, bi] indicates that there is a bidirectional road between cities ai and bi.\nThe network rank of two different cities is defined as the total number of directly connected roads to either city. If a road is directly connected to both cities, it is only counted once.\nThe maximal network rank of the infrastructure is the maximum network rank of all pairs of different cities.\nGiven the integer n and the array roads, return the maximal network rank of the entire infrastructure.\n \nExample 1:\n\n\nInput: n = 4, roads = [[0,1],[0,3],[1,2],[1,3]]\nOutput: 4\nExplanation: The network rank of cities 0 and 1 is 4 as there are 4 roads that are connected to either 0 or 1. The road between 0 and 1 is only counted once.\n\nExample 2:\n\n\nInput: n = 5, roads = [[0,1],[0,3],[1,2],[1,3],[2,3],[2,4]]\nOutput: 5\nExplanation: There are 5 roads that are connected to cities 1 or 2.\n\nExample 3:\n\nInput: n = 8, roads = [[0,1],[1,2],[2,3],[2,4],[5,6],[5,7]]\nOutput: 5\nExplanation: The network rank of 2 and 5 is 5. Notice that all the cities do not have to be connected.\n\n \nConstraints:\n\n2 <= n <= 100\n0 <= roads.length <= n * (n - 1) / 2\nroads[i].length == 2\n0 <= ai, bi <= n-1\nai != bi\nEach pair of cities has at most one road connecting them.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,roads = [[0, 1], [0, 3], [1, 2], [1, 3]]) == 4\n assert candidate(n = 100,roads = []) == 0\n assert candidate(n = 6,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == 5\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 9\n assert candidate(n = 5,roads = [[0, 1], [0, 3], [1, 2], [1, 3], [2, 3], [2, 4]]) == 5\n assert candidate(n = 3,roads = [[0, 1], [1, 2]]) == 2\n assert candidate(n = 6,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]]) == 5\n assert candidate(n = 10,roads = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 2\n assert candidate(n = 10,roads = []) == 0\n assert candidate(n = 8,roads = [[0, 1], [1, 2], [2, 3], [2, 4], [5, 6], [5, 7]]) == 5\n assert candidate(n = 10,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 4\n assert candidate(n = 7,roads = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6]]) == 4\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14]]) == 4\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14]]) == 5\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 12], [12, 13], [13, 14]]) == 6\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14]]) == 14\n assert candidate(n = 40,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15]]) == 6\n assert candidate(n = 7,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 6]]) == 11\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 6], [7, 8], [8, 9]]) == 7\n assert candidate(n = 60,roads = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21], [22, 23], [24, 25], [26, 27], [28, 29], [30, 31], [32, 33], [34, 35], [36, 37], [38, 39], [40, 41], [42, 43], [44, 45], [46, 47], [48, 49], [50, 51], [52, 53], [54, 55], [56, 57], [58, 59]]) == 2\n assert candidate(n = 20,roads = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [16, 17], [18, 19]]) == 4\n assert candidate(n = 20,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 7\n assert candidate(n = 25,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5], [10, 11], [11, 12], [12, 13], [13, 14], [14, 10], [15, 16], [16, 17], [17, 18], [18, 19], [19, 15], [20, 21], [21, 22], [22, 23], [23, 24], [24, 20], [0, 15], [5, 10], [10, 15], [20, 25]]) == 7\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]) == 7\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 7\n assert candidate(n = 70,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 13]]) == 10\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9]]) == 8\n assert candidate(n = 20,roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == 6\n assert candidate(n = 20,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 19]]) == 4\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [11, 12], [13, 14]]) == 5\n assert candidate(n = 20,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 4\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [7, 9], [8, 9]]) == 5\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 6\n assert candidate(n = 20,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14]]) == 8\n assert candidate(n = 30,roads = [[0, 1], [0, 2], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == 5\n assert candidate(n = 25,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 10], [2, 11], [2, 12], [3, 13], [3, 14], [4, 15], [4, 16], [5, 17], [5, 18], [6, 19], [6, 20], [7, 21], [7, 22], [8, 23], [8, 24], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24]]) == 9\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 5\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14]]) == 7\n assert candidate(n = 20,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [15, 18], [15, 19], [16, 17], [16, 18], [16, 19], [17, 18], [17, 19], [18, 19]]) == 8\n assert candidate(n = 60,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15]]) == 6\n"}, "metadata": {"canonical_parameter_names": ["n", "roads"], "leetcode_dataset_entry_point": "Solution().maximalNetworkRank", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximalNetworkRank(self, n: int, roads: list[list[int]]) -> int:", "container": "Solution", "callable": "maximalNetworkRank", "parameters": [{"name": "n", "type": "int"}, {"name": "roads", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1616, "task_id": "split-two-strings-to-make-palindrome", "difficulty": "Medium", "problem_description": "You are given two strings a and b of the same length. Choose an index and split both strings at the same index, splitting a into two strings: aprefix and asuffix where a = aprefix + asuffix, and splitting b into two strings: bprefix and bsuffix where b = bprefix + bsuffix. Check if aprefix + bsuffix or bprefix + asuffix forms a palindrome.\nWhen you split a string s into sprefix and ssuffix, either ssuffix or sprefix is allowed to be empty. For example, if s = \"abc\", then \"\" + \"abc\", \"a\" + \"bc\", \"ab\" + \"c\" , and \"abc\" + \"\" are valid splits.\nReturn true if it is possible to form a palindrome string, otherwise return false.\nNotice that x + y denotes the concatenation of strings x and y.\n \nExample 1:\n\nInput: a = \"x\", b = \"y\"\nOutput: true\nExplaination: If either a or b are palindromes the answer is true since you can split in the following way:\naprefix = \"\", asuffix = \"x\"\nbprefix = \"\", bsuffix = \"y\"\nThen, aprefix + bsuffix = \"\" + \"y\" = \"y\", which is a palindrome.\n\nExample 2:\n\nInput: a = \"xbdef\", b = \"xecab\"\nOutput: false\n\nExample 3:\n\nInput: a = \"ulacfd\", b = \"jizalu\"\nOutput: true\nExplaination: Split them at index 3:\naprefix = \"ula\", asuffix = \"cfd\"\nbprefix = \"jiz\", bsuffix = \"alu\"\nThen, aprefix + bsuffix = \"ula\" + \"alu\" = \"ulaalu\", which is a palindrome.\n\n \nConstraints:\n\n1 <= a.length, b.length <= 105\na.length == b.length\na and b consist of lowercase English letters\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = \"abcdefg\",b = \"gfedcba\") == True\n assert candidate(a = \"abcxxcba\",b = \"abcdcba\") == True\n assert candidate(a = \"aabbcc\",b = \"ccbbdd\") == True\n assert candidate(a = \"ulacfd\",b = \"jizalu\") == True\n assert candidate(a = \"aabbaa\",b = \"aabbaa\") == True\n assert candidate(a = \"abba\",b = \"abba\") == True\n assert candidate(a = \"abcba\",b = \"abcba\") == True\n assert candidate(a = \"x\",b = \"y\") == True\n assert candidate(a = \"xbdef\",b = \"xecab\") == False\n assert candidate(a = \"abccba\",b = \"abccba\") == True\n assert candidate(a = \"noon\",b = \"noon\") == True\n assert candidate(a = \"race\",b = \"ecar\") == True\n assert candidate(a = \"abcd\",b = \"dcba\") == True\n assert candidate(a = \"aabbcc\",b = \"ccbbaa\") == True\n assert candidate(a = \"abc\",b = \"def\") == False\n assert candidate(a = \"abcde\",b = \"edcba\") == True\n assert candidate(a = \"abacaba\",b = \"bacabab\") == True\n assert candidate(a = \"rotor\",b = \"rotor\") == True\n assert candidate(a = \"noonappapoon\",b = \"poongggnop\") == False\n assert candidate(a = \"abacax\",b = \"xananaba\") == False\n assert candidate(a = \"abcdedcba\",b = \"afghihgfa\") == True\n assert candidate(a = \"abcdefghijk\",b = \"kjihgfedcba\") == True\n assert candidate(a = \"xyzzzzzxy\",b = \"yxzzzzzxy\") == True\n assert candidate(a = \"abcdabcdabcd\",b = \"dcbaedcbadcb\") == False\n assert candidate(a = \"aaaaabaaaa\",b = \"bbbbabbbbb\") == False\n assert candidate(a = \"abcdeedcba\",b = \"fghijijihgf\") == True\n assert candidate(a = \"rotorabc\",b = \"abcrotor\") == True\n assert candidate(a = \"abcdeffedcba\",b = \"mnopqrstsrqponm\") == True\n assert candidate(a = \"abac\",b = \"cab\") == True\n assert candidate(a = \"abcdexyzabc\",b = \"cbazyxcdeba\") == True\n assert candidate(a = \"abcdefgxyz\",b = \"zyxgfedcba\") == True\n assert candidate(a = \"abcdef\",b = \"fedcba\") == True\n assert candidate(a = \"aabbccddeeffgghhiijj\",b = \"jjiihhggfeeddccbaa\") == True\n assert candidate(a = \"abcdefgh\",b = \"hgfedcba\") == True\n assert candidate(a = \"xyzzxy\",b = \"yxzzyx\") == True\n assert candidate(a = \"mnopqr\",b = \"rqponm\") == True\n assert candidate(a = \"abcdefghij\",b = \"utvwxzyabc\") == False\n assert candidate(a = \"levelupx\",b = \"xyzlevol\") == False\n assert candidate(a = \"abcdefghijkjihgfedcba\",b = \"nopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(a = \"abcdefggfedcba\",b = \"xyzzyxzyxzyx\") == True\n assert candidate(a = \"aabbccddeeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzyyxxwwvvuuttssrrqqponnmmllkkjjiihhggffeeddccbaabb\") == False\n assert candidate(a = \"abcdxyzabc\",b = \"cbazyxdcba\") == True\n assert candidate(a = \"abcxxy\",b = \"yxxcba\") == True\n assert candidate(a = \"abcdeedcba\",b = \"zzzzzzzzzz\") == True\n assert candidate(a = \"xyzzzzyx\",b = \"abcdef\") == True\n assert candidate(a = \"abcdefghijabc\",b = \"cbazyxwvut\") == False\n assert candidate(a = \"abcdedcba\",b = \"xyzdedcba\") == True\n assert candidate(a = \"abcdefg\",b = \"hgfedcb\") == False\n assert candidate(a = \"aabbccddeeefffggg\",b = \"gggfffeeeddccbbaa\") == True\n assert candidate(a = \"abcdefghij\",b = \"jihgfedcba\") == True\n assert candidate(a = \"abcdabcdeedcba\",b = \"zzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(a = \"abcdeffedcba\",b = \"xyzzyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(a = \"racecarx\",b = \"xmadam\") == True\n assert candidate(a = \"xyzzzzzyx\",b = \"abcdcba\") == True\n assert candidate(a = \"redivider\",b = \"repaidred\") == True\n assert candidate(a = \"aabbccddeeaabbccddee\",b = \"eeddccbbaaeeddccbbaa\") == True\n assert candidate(a = \"noon\",b = \"moon\") == True\n assert candidate(a = \"abababab\",b = \"babababa\") == True\n assert candidate(a = \"abacabadabacaba\",b = \"fedcbadcba\") == True\n assert candidate(a = \"zxcvbnm\",b = \"mlkjihg\") == False\n assert candidate(a = \"abcdefggfedcba\",b = \"abcdggfedcba\") == True\n assert candidate(a = \"qwertyuiop\",b = \"poiuytrewq\") == True\n assert candidate(a = \"zzzzzzzzzzz\",b = \"aaaaaaaaaaa\") == True\n assert candidate(a = \"aabbccddeeffgghhiijjkk\",b = \"kkjjiihhggfeeddccbaa\") == True\n assert candidate(a = \"noon\",b = \"racecar\") == True\n assert candidate(a = \"abcdex\",b = \"xcdeba\") == False\n assert candidate(a = \"zyxwvutsrqponmlkjihgfedcba\",b = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(a = \"abccba\",b = \"abcdef\") == True\n assert candidate(a = \"abccba\",b = \"xyzzyx\") == True\n assert candidate(a = \"aabbccdd\",b = \"aabbccdd\") == False\n assert candidate(a = \"abcdabc\",b = \"cbadacb\") == True\n assert candidate(a = \"xyxzyxzyx\",b = \"yzxzyxzyz\") == False\n assert candidate(a = \"abcdexyz\",b = \"zyxcdeba\") == False\n assert candidate(a = \"abacaxbacad\",b = \"dadcabaxbacba\") == False\n assert candidate(a = \"abacaba\",b = \"zzzazzz\") == True\n assert candidate(a = \"aabbccdd\",b = \"ddeebbaa\") == True\n assert candidate(a = \"racecar\",b = \"level\") == True\n assert candidate(a = \"abcdefghij\",b = \"abcdefghij\") == False\n assert candidate(a = \"aaaa\",b = \"bbbb\") == True\n assert candidate(a = \"level\",b = \"deified\") == True\n assert candidate(a = \"abacdfgdcaba\",b = \"abacdgfdcaba\") == True\n assert candidate(a = \"abcdeabcde\",b = \"edcbaedcba\") == True\n assert candidate(a = \"abcdexyzzyxcdeba\",b = \"mnopqrstuutsrqpomn\") == False\n assert candidate(a = \"abxyzyxcba\",b = \"cdyxzyxdc\") == False\n assert candidate(a = \"madam\",b = \"refer\") == True\n assert candidate(a = \"aabbcc\",b = \"ccbaab\") == True\n assert candidate(a = \"abcddcba\",b = \"xyzzyx\") == True\n assert candidate(a = \"abracadabra\",b = \"arbadacarba\") == True\n assert candidate(a = \"abcddcba\",b = \"efghihgf\") == True\n assert candidate(a = \"abcdefxyzzyxcba\",b = \"pqrstuvwzyxwvutsrqp\") == False\n assert candidate(a = \"aaaabaaa\",b = \"bbbbbabb\") == False\n assert candidate(a = \"abacdfgdcaba\",b = \"abaffghffaba\") == False\n assert candidate(a = \"abacabad\",b = \"daadacab\") == False\n assert candidate(a = \"abcdexyz\",b = \"zyxeabcd\") == True\n assert candidate(a = \"abcdef\",b = \"xyzzzzyx\") == True\n assert candidate(a = \"abacdfgdcaba\",b = \"abcdcba\") == True\n assert candidate(a = \"abccba\",b = \"defedf\") == True\n assert candidate(a = \"xyzyx\",b = \"xzyzx\") == True\n assert candidate(a = \"palindrome\",b = \"emordnilap\") == True\n assert candidate(a = \"zzzzzzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaaaa\") == True\n assert candidate(a = \"abccba\",b = \"defed\") == True\n assert candidate(a = \"abccba\",b = \"fghihgf\") == True\n assert candidate(a = \"tacocat\",b = \"racecar\") == True\n assert candidate(a = \"abcdef\",b = \"ghijkl\") == False\n assert candidate(a = \"aaaabbbb\",b = \"bbbbaaaa\") == True\n assert candidate(a = \"abcdefghihgfedcba\",b = \"abcdefghihgfedcba\") == True\n assert candidate(a = \"aabbccddeeff\",b = \"ffeeddccbbaa\") == True\n assert candidate(a = \"abcdexyzabcd\",b = \"dcbaxyzedcba\") == False\n assert candidate(a = \"abacabadabacaba\",b = \"abacabadabacaba\") == True\n assert candidate(a = \"abcxyzz\",b = \"zzzyxcba\") == True\n assert candidate(a = \"abacabadabacaba\",b = \"zzzzzzzzzzzzzzzzz\") == True\n assert candidate(a = \"abcabcabcabc\",b = \"cbacbacbacba\") == True\n assert candidate(a = \"abcxxa\",b = \"bxxcba\") == True\n assert candidate(a = \"racecar\",b = \"madam\") == True\n assert candidate(a = \"aaaaaaabbbbb\",b = \"bbbbbaaaaaaa\") == True\n assert candidate(a = \"abcdabcdabcd\",b = \"dcbaabcdabcd\") == False\n assert candidate(a = \"deifiedxx\",b = \"yytefified\") == True\n assert candidate(a = \"aaaaaaa\",b = \"bbbbbbb\") == True\n assert candidate(a = \"abab\",b = \"baba\") == True\n assert candidate(a = \"abcdeffedcba\",b = \"xyzzyxwxyzzyx\") == True\n assert candidate(a = \"abcdabcd\",b = \"dcbaabcd\") == True\n assert candidate(a = \"abcdeffedcba\",b = \"xyzzyxwvut\") == True\n assert candidate(a = \"abcdedcba\",b = \"mnopqrstuv\") == True\n assert candidate(a = \"abcdefghihgfedcba\",b = \"ijklmnopponmlkjihgf\") == True\n assert candidate(a = \"aabbcc\",b = \"zzxxzz\") == True\n assert candidate(a = \"abcdexyz\",b = \"zyxwvuts\") == False\n"}, "metadata": {"canonical_parameter_names": ["a", "b"], "leetcode_dataset_entry_point": "Solution().checkPalindromeFormation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def checkPalindromeFormation(self, a: str, b: str) -> bool:", "container": "Solution", "callable": "checkPalindromeFormation", "parameters": [{"name": "a", "type": "str"}, {"name": "b", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1617, "task_id": "count-subtrees-with-max-distance-between-cities", "difficulty": "Hard", "problem_description": "There are n cities numbered from 1 to n. You are given an array edges of size n-1, where edges[i] = [ui, vi] represents a bidirectional edge between cities ui and vi. There exists a unique path between each pair of cities. In other words, the cities form a tree.\\r\n\\r\nA subtree is a subset of cities where every city is reachable from every other city in the subset, where the path between each pair passes through only the cities from the subset. Two subtrees are different if there is a city in one subtree that is not present in the other.\\r\n\\r\nFor each d from 1 to n-1, find the number of subtrees in which the maximum distance between any two cities in the subtree is equal to d.\\r\n\\r\nReturn an array of size n-1 where the dth element (1-indexed) is the number of subtrees in which the maximum distance between any two cities is equal to d.\\r\n\\r\nNotice that the distance between the two cities is the number of edges in the path between them.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\n\\r\n\\r\nInput: n = 4, edges = [[1,2],[2,3],[2,4]]\\r\nOutput: [3,4,0]\\r\nExplanation:\\r\nThe subtrees with subsets {1,2}, {2,3} and {2,4} have a max distance of 1.\\r\nThe subtrees with subsets {1,2,3}, {1,2,4}, {2,3,4} and {1,2,3,4} have a max distance of 2.\\r\nNo subtree has two nodes where the max distance between them is 3.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: n = 2, edges = [[1,2]]\\r\nOutput: [1]\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: n = 3, edges = [[1,2],[2,3]]\\r\nOutput: [2,1]\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t2 <= n <= 15\\r\n\tedges.length == n-1\\r\n\tedges[i].length == 2\\r\n\t1 <= ui, vi <= n\\r\n\tAll pairs (ui, vi) are distinct.\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == [5, 8, 9, 0, 0]\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5]]) == [4, 3, 2, 1]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10]]) == [9, 14, 18, 26, 33, 0, 0, 0, 0]\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 6], [4, 7]]) == [6, 7, 9, 7, 0, 0]\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6]]) == [5, 6, 4, 3, 0]\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [1, 5]]) == [4, 11, 0, 0]\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [2, 4], [2, 5]]) == [4, 5, 3, 0]\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [2, 4]]) == [3, 4, 0]\n assert candidate(n = 3,edges = [[1, 2], [2, 3]]) == [2, 1]\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [5, 6]]) == [5, 4, 3, 2, 1]\n assert candidate(n = 2,edges = [[1, 2]]) == [1]\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12]]) == [11, 16, 24, 33, 48, 55, 0, 0, 0, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == [8, 9, 9, 9, 7, 4, 2, 0]\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11]]) == [10, 17, 24, 48, 63, 0, 0, 0, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9]]) == [8, 13, 15, 15, 18, 0, 0, 0]\n assert candidate(n = 13,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [7, 13]]) == [12, 19, 30, 43, 66, 121, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 11,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 14,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14]]) == [13, 38, 70, 649, 308, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == [10, 13, 18, 23, 30, 25, 0, 0, 0, 0]\n assert candidate(n = 13,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [6, 13]]) == [12, 29, 49, 120, 259, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 14,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14]]) == [13, 22, 36, 65, 96, 231, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8]]) == [7, 10, 9, 11, 6, 0, 0]\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]]) == [6, 9, 6, 9, 0, 0]\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11]]) == [10, 15, 21, 28, 39, 22, 0, 0, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]]) == [11, 20, 36, 99, 126, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == [8, 13, 21, 39, 0, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15]]) == [14, 25, 48, 168, 483, 210, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]]) == [14, 25, 42, 87, 126, 441, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8]]) == [7, 10, 9, 11, 6, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12]]) == [11, 18, 27, 50, 69, 42, 0, 0, 0, 0, 0]\n assert candidate(n = 6,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [5, 4, 3, 2, 1]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == [9, 16, 27, 81, 0, 0, 0, 0, 0]\n assert candidate(n = 13,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13]]) == [12, 21, 33, 54, 81, 126, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12]]) == [11, 14, 19, 26, 35, 34, 15, 0, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [4, 7], [5, 8]]) == [7, 8, 10, 10, 5, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9]]) == [8, 17, 13, 23, 14, 0, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9]]) == [8, 11, 12, 16, 15, 0, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12]]) == [11, 20, 36, 99, 126, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 13,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9]]) == [8, 13, 21, 24, 12, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [4, 14], [5, 15]]) == [14, 45, 154, 1995, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().countSubgraphsForEachDiameter", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countSubgraphsForEachDiameter(self, n: int, edges: List[List[int]]) -> List[int]:", "container": "Solution", "callable": "countSubgraphsForEachDiameter", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "List[List[int]]"}], "return_type": "List[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1619, "task_id": "mean-of-array-after-removing-some-elements", "difficulty": "Easy", "problem_description": "Given an integer array arr, return the mean of the remaining integers after removing the smallest 5% and the largest 5% of the elements.\nAnswers within 10-5 of the actual answer will be considered accepted.\n \nExample 1:\n\nInput: arr = [1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3]\nOutput: 2.00000\nExplanation: After erasing the minimum and the maximum values of this array, all elements are equal to 2, so the mean is 2.\n\nExample 2:\n\nInput: arr = [6,2,7,5,1,2,0,3,10,2,5,0,5,5,0,8,7,6,8,0]\nOutput: 4.00000\n\nExample 3:\n\nInput: arr = [6,0,7,0,7,5,7,8,3,4,0,7,8,1,6,8,1,1,2,4,8,1,9,5,4,3,8,5,10,8,6,6,1,0,6,10,8,2,3,4]\nOutput: 4.77778\n\n \nConstraints:\n\n20 <= arr.length <= 1000\narr.length is a multiple of 20.\n0 <= arr[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [6, 0, 7, 0, 7, 5, 7, 8, 3, 4, 0, 7, 8, 1, 6, 8, 1, 1, 2, 4, 8, 1, 9, 5, 4, 3, 8, 5, 10, 8, 6, 6, 1, 0, 6, 10, 8, 2, 3, 4]) == 4.77778\n assert candidate(arr = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 2.0\n assert candidate(arr = [6, 2, 7, 5, 1, 2, 0, 3, 10, 2, 5, 0, 5, 5, 0, 8, 7, 6, 8, 0]) == 4.0\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 105.0\n assert candidate(arr = [42, 85, 94, 12, 85, 74, 15, 7, 83, 52, 53, 87, 27, 30, 67, 94, 84, 90, 72, 18, 62, 85, 81, 69, 82, 69, 39, 72, 25, 90, 45, 88, 61, 53, 74, 69, 46, 12, 43, 96, 89, 90, 25, 46, 23, 88, 97, 30, 69, 58, 76, 67, 50, 87, 94, 82, 63, 30, 93, 50, 33, 98, 60, 69, 88, 75, 29, 11, 94, 47, 87, 93, 34, 97, 32, 96, 79, 97, 78, 77, 45, 35, 94, 66, 62, 58, 42, 23, 83, 82, 72, 58, 75, 86, 80, 94, 28, 44, 62, 40, 96, 97, 46, 28, 96, 37, 82, 96, 62, 98, 28, 37, 81, 74, 90, 98, 73, 72, 99, 40, 54, 34, 55, 65, 70, 71, 80, 92, 93]) == 65.75\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500]) == 250.0\n assert candidate(arr = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993, 9, 99992, 10, 99991, 11, 99990, 12, 99989, 13, 99988, 14, 99987, 15, 99986, 16, 99985, 17, 99984, 18, 99983, 19, 99982, 20, 99981]) == 50000.5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 25.0\n assert candidate(arr = [3, 1, 2, 4, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 29.5\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400]) == 205.0\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0.76056\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5.0\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 475.0\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 960, 970, 980, 990, 1000]) == 505.0\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 4, 9, 0, 3, 0, 1, 4, 1, 5]) == 4.44156\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109]) == 54.0\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 8.98182\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000]) == 2500.0\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40]) == 69.5\n assert candidate(arr = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0]) == 49122.80702\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10.5\n assert candidate(arr = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 500.0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 25.0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5.0\n assert candidate(arr = [100000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100000]) == 5555.55556\n assert candidate(arr = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 50000.0\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 42.0\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 13.01852\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 20.5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1.78082\n assert candidate(arr = [100000, 0, 50000, 25000, 75000, 30000, 80000, 10000, 90000, 40000, 60000, 20000, 95000, 55000, 85000, 15000, 99000, 65000, 70000, 35000, 100000, 0, 50000, 25000, 75000, 30000, 80000, 10000, 90000, 40000, 60000, 20000, 95000, 55000, 85000, 15000, 99000, 65000, 70000, 35000]) == 55500.0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 8.23529\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == 100.0\n assert candidate(arr = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0]) == 48780.4878\n assert candidate(arr = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995, 5, 99994, 6, 99993, 7, 99992, 8, 99991, 9, 99990, 10, 99989, 11, 99988, 12, 99987, 13, 99986, 14, 99985, 15, 99984, 16, 99983, 17, 99982, 18, 99981, 19, 99980, 20, 99979, 21, 99978, 22, 99977, 23, 99976, 24, 99975, 25]) == 48888.95556\n assert candidate(arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 50.0\n assert candidate(arr = [50000, 1, 20000, 2, 30000, 3, 40000, 4, 50000, 5, 60000, 6, 70000, 7, 80000, 8, 90000, 9, 100000, 10, 110000, 11, 120000, 12, 130000, 13, 140000, 14, 150000, 15, 160000, 16, 170000, 17, 180000, 18, 190000, 19, 200000, 20, 210000, 21, 220000, 22, 230000, 23, 240000, 24, 250000, 25, 260000, 26, 270000, 27, 280000, 28, 290000, 29, 300000]) == 70748.74074\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5.0\n assert candidate(arr = [15, 22, 10, 27, 18, 35, 40, 50, 60, 5, 90, 80, 75, 45, 30, 25, 65, 70, 100, 55]) == 45.11111\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10.0\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 42.0\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2.0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 50.5\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == 0.075\n assert candidate(arr = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995, 5, 99994, 6, 99993, 7, 99992, 8, 99991, 9, 99990, 10, 99989, 11, 99988, 12, 99987, 13, 99986, 14, 99985, 15, 99984, 16, 99983, 17, 99982, 18, 99981, 19, 99980, 20, 99979, 21, 99978, 22, 99977, 23, 99976, 24, 99975, 25, 99974, 26, 99973, 27, 99972, 28, 99971, 29, 99970]) == 49999.5\n assert candidate(arr = [99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1]) == 67567.51351\n assert candidate(arr = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0]) == 48717.94872\n assert candidate(arr = [3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13, 18, 17, 16, 21, 20, 25, 24, 23, 30, 29, 28, 33, 32, 31, 36, 35, 34, 39, 38, 37, 42, 41, 40, 45, 44, 43, 48, 47, 46, 51, 50, 49, 54, 53, 52, 57, 56, 55, 60, 59, 58, 63, 62, 61, 66, 65, 64, 69, 68, 67, 72, 71, 70]) == 36.81967\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 20.5\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 0, 0, 0, 0, 0]) == 17.14634\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().trimMean", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def trimMean(self, arr: list[int]) -> float:", "container": "Solution", "callable": "trimMean", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1620, "task_id": "coordinate-with-maximum-network-quality", "difficulty": "Medium", "problem_description": "You are given an array of network towers towers, where towers[i] = [xi, yi, qi] denotes the ith network tower with location (xi, yi) and quality factor qi. All the coordinates are integral coordinates on the X-Y plane, and the distance between the two coordinates is the Euclidean distance.\nYou are also given an integer radius where a tower is reachable if the distance is less than or equal to radius. Outside that distance, the signal becomes garbled, and the tower is not reachable.\nThe signal quality of the ith tower at a coordinate (x, y) is calculated with the formula ⌊qi / (1 + d)⌋, where d is the distance between the tower and the coordinate. The network quality at a coordinate is the sum of the signal qualities from all the reachable towers.\nReturn the array [cx, cy] representing the integral coordinate (cx, cy) where the network quality is maximum. If there are multiple coordinates with the same network quality, return the lexicographically minimum non-negative coordinate.\nNote:\n\nA coordinate (x1, y1) is lexicographically smaller than (x2, y2) if either:\n\n\t\nx1 < x2, or\nx1 == x2 and y1 < y2.\n\n\n⌊val⌋ is the greatest integer less than or equal to val (the floor function).\n\n \nExample 1:\n\n\nInput: towers = [[1,2,5],[2,1,7],[3,1,9]], radius = 2\nOutput: [2,1]\nExplanation: At coordinate (2, 1) the total quality is 13.\n- Quality of 7 from (2, 1) results in ⌊7 / (1 + sqrt(0)⌋ = ⌊7⌋ = 7\n- Quality of 5 from (1, 2) results in ⌊5 / (1 + sqrt(2)⌋ = ⌊2.07⌋ = 2\n- Quality of 9 from (3, 1) results in ⌊9 / (1 + sqrt(1)⌋ = ⌊4.5⌋ = 4\nNo other coordinate has a higher network quality.\nExample 2:\n\nInput: towers = [[23,11,21]], radius = 9\nOutput: [23,11]\nExplanation: Since there is only one tower, the network quality is highest right at the tower's location.\n\nExample 3:\n\nInput: towers = [[1,2,13],[2,1,7],[0,1,9]], radius = 2\nOutput: [1,2]\nExplanation: Coordinate (1, 2) has the highest network quality.\n\n \nConstraints:\n\n1 <= towers.length <= 50\ntowers[i].length == 3\n0 <= xi, yi, qi <= 50\n1 <= radius <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(towers = [[23, 11, 21]],radius = 9) == [23, 11]\n assert candidate(towers = [[5, 5, 15], [6, 6, 20], [7, 7, 25]],radius = 3) == [6, 6]\n assert candidate(towers = [[1, 2, 5], [2, 1, 7], [3, 1, 9]],radius = 2) == [2, 1]\n assert candidate(towers = [[0, 0, 10], [1, 1, 20], [2, 2, 30]],radius = 1) == [2, 2]\n assert candidate(towers = [[5, 5, 5], [5, 6, 5], [6, 5, 5], [6, 6, 5]],radius = 1) == [5, 5]\n assert candidate(towers = [[0, 0, 10], [5, 5, 20], [10, 10, 30]],radius = 15) == [10, 10]\n assert candidate(towers = [[0, 0, 1], [1, 1, 1], [2, 2, 1]],radius = 1) == [0, 0]\n assert candidate(towers = [[10, 0, 10], [0, 10, 10], [10, 10, 10]],radius = 15) == [0, 10]\n assert candidate(towers = [[0, 0, 10], [5, 5, 5]],radius = 6) == [0, 0]\n assert candidate(towers = [[0, 0, 10], [10, 10, 20]],radius = 15) == [10, 10]\n assert candidate(towers = [[10, 10, 5], [15, 15, 10], [20, 20, 15]],radius = 10) == [20, 20]\n assert candidate(towers = [[1, 2, 13], [2, 1, 7], [0, 1, 9]],radius = 2) == [1, 2]\n assert candidate(towers = [[1, 1, 1], [2, 2, 1], [3, 3, 1]],radius = 1) == [1, 1]\n assert candidate(towers = [[0, 0, 1], [1, 0, 1], [0, 1, 1], [1, 1, 1], [2, 2, 1], [2, 3, 1], [3, 2, 1], [3, 3, 1]],radius = 2) == [0, 0]\n assert candidate(towers = [[0, 0, 100], [1, 1, 99], [2, 2, 98], [3, 3, 97], [4, 4, 96], [5, 5, 95], [6, 6, 94], [7, 7, 93], [8, 8, 92], [9, 9, 91]],radius = 4) == [2, 2]\n assert candidate(towers = [[10, 10, 20], [15, 15, 10], [20, 20, 5], [5, 5, 15]],radius = 10) == [10, 10]\n assert candidate(towers = [[5, 5, 10], [15, 15, 20], [25, 25, 30], [35, 35, 40], [45, 45, 50]],radius = 10) == [45, 45]\n assert candidate(towers = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],radius = 1) == [13, 14]\n assert candidate(towers = [[5, 5, 15], [6, 6, 25], [7, 7, 35], [8, 8, 45], [9, 9, 55]],radius = 5) == [8, 8]\n assert candidate(towers = [[2, 2, 5], [4, 4, 10], [6, 6, 15], [8, 8, 20], [10, 10, 25], [12, 12, 30], [14, 14, 35]],radius = 7) == [12, 12]\n assert candidate(towers = [[10, 10, 1], [10, 11, 2], [10, 12, 3], [10, 13, 4], [10, 14, 5]],radius = 4) == [10, 14]\n assert candidate(towers = [[5, 5, 10], [10, 10, 20], [15, 15, 30], [20, 20, 40], [25, 25, 50]],radius = 10) == [25, 25]\n assert candidate(towers = [[0, 0, 1], [1, 0, 2], [2, 0, 3], [3, 0, 4], [4, 0, 5], [5, 0, 6], [6, 0, 7], [7, 0, 8], [8, 0, 9], [9, 0, 10]],radius = 2) == [7, 0]\n assert candidate(towers = [[1, 2, 5], [2, 1, 7], [3, 1, 9], [4, 3, 12], [5, 2, 8]],radius = 3) == [3, 1]\n assert candidate(towers = [[1, 1, 1], [1, 2, 1], [1, 3, 1], [2, 1, 1], [2, 2, 1], [2, 3, 1], [3, 1, 1], [3, 2, 1], [3, 3, 1]],radius = 1) == [1, 1]\n assert candidate(towers = [[1, 1, 5], [1, 2, 5], [2, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5], [5, 5, 5], [6, 6, 5]],radius = 2) == [2, 2]\n assert candidate(towers = [[10, 10, 50], [20, 10, 40], [10, 20, 30], [20, 20, 20], [10, 30, 10], [20, 30, 5]],radius = 15) == [10, 10]\n assert candidate(towers = [[10, 10, 50], [20, 20, 50], [30, 30, 50], [40, 40, 50], [50, 50, 50]],radius = 20) == [20, 20]\n assert candidate(towers = [[25, 25, 50], [10, 10, 30], [40, 40, 20], [30, 30, 40], [15, 15, 25], [45, 45, 10]],radius = 12) == [25, 25]\n assert candidate(towers = [[5, 5, 10], [15, 15, 15], [25, 25, 20], [35, 35, 25], [45, 45, 30]],radius = 15) == [45, 45]\n assert candidate(towers = [[0, 0, 1], [50, 0, 1], [0, 50, 1], [50, 50, 1], [25, 25, 100]],radius = 30) == [25, 25]\n assert candidate(towers = [[25, 25, 50], [24, 25, 49], [26, 25, 48], [25, 24, 47], [25, 26, 46], [24, 24, 45], [24, 26, 44], [26, 24, 43], [26, 26, 42]],radius = 2) == [25, 25]\n assert candidate(towers = [[0, 0, 10], [0, 10, 20], [10, 0, 30], [10, 10, 40], [5, 5, 50]],radius = 15) == [5, 5]\n assert candidate(towers = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]],radius = 1) == [10, 10]\n assert candidate(towers = [[5, 10, 20], [10, 5, 30], [15, 15, 40], [20, 10, 50], [25, 5, 60]],radius = 7) == [25, 5]\n assert candidate(towers = [[25, 25, 100], [30, 30, 200], [35, 35, 300], [40, 40, 400], [45, 45, 500], [50, 50, 600]],radius = 15) == [50, 50]\n assert candidate(towers = [[25, 25, 100], [15, 15, 90], [35, 15, 80], [15, 35, 70], [35, 35, 60], [25, 15, 50], [15, 25, 40], [35, 25, 30], [25, 35, 20], [15, 30, 10], [35, 30, 5], [20, 20, 25], [30, 30, 25]],radius = 15) == [25, 25]\n assert candidate(towers = [[0, 0, 1], [0, 1, 1], [1, 0, 1], [1, 1, 1], [0, 2, 1], [1, 2, 1], [2, 0, 1], [2, 1, 1], [2, 2, 1]],radius = 1) == [0, 0]\n assert candidate(towers = [[5, 5, 50], [10, 10, 50], [15, 15, 50], [20, 20, 50], [25, 25, 50]],radius = 5) == [5, 5]\n assert candidate(towers = [[1, 1, 100], [2, 2, 200], [3, 3, 300], [4, 4, 400], [5, 5, 500]],radius = 10) == [4, 4]\n assert candidate(towers = [[0, 0, 1], [0, 1, 1], [0, 2, 1], [1, 0, 1], [1, 1, 1], [1, 2, 1], [2, 0, 1], [2, 1, 1], [2, 2, 1]],radius = 1) == [0, 0]\n assert candidate(towers = [[10, 10, 10], [20, 10, 20], [30, 10, 30], [40, 10, 40], [50, 10, 50], [10, 20, 50], [20, 20, 40], [30, 20, 30], [40, 20, 20], [50, 20, 10]],radius = 10) == [10, 20]\n assert candidate(towers = [[1, 1, 5], [1, 2, 5], [1, 3, 5], [2, 1, 5], [2, 2, 5], [2, 3, 5], [3, 1, 5], [3, 2, 5], [3, 3, 5]],radius = 2) == [2, 2]\n assert candidate(towers = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40]],radius = 5) == [4, 4]\n assert candidate(towers = [[25, 25, 50], [24, 24, 40], [23, 23, 30], [22, 22, 20], [21, 21, 10], [20, 20, 5]],radius = 6) == [24, 24]\n assert candidate(towers = [[1, 2, 5], [3, 4, 5], [5, 6, 5], [7, 8, 5], [9, 10, 5]],radius = 5) == [3, 4]\n assert candidate(towers = [[25, 25, 10], [30, 30, 20], [35, 35, 30], [40, 40, 40], [45, 45, 50]],radius = 15) == [45, 45]\n assert candidate(towers = [[5, 5, 20], [10, 10, 30], [15, 15, 40], [20, 20, 50], [25, 25, 60], [30, 30, 70]],radius = 12) == [30, 30]\n assert candidate(towers = [[25, 25, 100], [25, 26, 100], [26, 25, 100], [26, 26, 100], [24, 25, 100], [25, 24, 100], [24, 24, 100], [26, 24, 100], [24, 26, 100], [26, 26, 100]],radius = 1) == [25, 25]\n assert candidate(towers = [[5, 5, 10], [10, 5, 10], [5, 10, 10], [10, 10, 10], [2, 2, 10], [8, 8, 10], [2, 8, 10], [8, 2, 10]],radius = 5) == [8, 8]\n assert candidate(towers = [[5, 5, 10], [10, 5, 20], [5, 10, 20], [10, 10, 30], [15, 15, 40], [20, 20, 50]],radius = 10) == [20, 20]\n assert candidate(towers = [[0, 0, 1], [5, 5, 10], [10, 10, 100], [15, 15, 1000], [20, 20, 10000]],radius = 20) == [20, 20]\n assert candidate(towers = [[0, 0, 100], [0, 50, 100], [50, 0, 100], [50, 50, 100], [25, 25, 100]],radius = 30) == [0, 0]\n assert candidate(towers = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [2, 1, 4], [2, 2, 5], [2, 3, 6], [3, 1, 7], [3, 2, 8], [3, 3, 9]],radius = 1) == [3, 2]\n assert candidate(towers = [[10, 10, 20], [20, 20, 30], [30, 30, 40], [40, 40, 50], [50, 50, 60]],radius = 25) == [50, 50]\n assert candidate(towers = [[3, 3, 3], [6, 6, 6], [9, 9, 9], [12, 12, 12], [15, 15, 15]],radius = 5) == [15, 15]\n assert candidate(towers = [[10, 10, 100], [20, 20, 200], [30, 30, 300], [40, 40, 400], [50, 50, 500]],radius = 20) == [50, 50]\n assert candidate(towers = [[10, 10, 30], [20, 20, 20], [30, 30, 10], [40, 40, 5]],radius = 10) == [10, 10]\n assert candidate(towers = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]],radius = 2) == [1, 1]\n assert candidate(towers = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [0, 0, 0], [5, 5, 5], [15, 15, 15]],radius = 10) == [50, 50]\n assert candidate(towers = [[10, 10, 20], [20, 20, 30], [15, 15, 15], [5, 5, 10]],radius = 10) == [20, 20]\n assert candidate(towers = [[5, 10, 5], [10, 5, 10], [15, 10, 15], [20, 5, 20], [25, 10, 25]],radius = 5) == [25, 10]\n assert candidate(towers = [[5, 5, 10], [10, 10, 20], [15, 15, 30], [20, 20, 40], [25, 25, 50]],radius = 15) == [25, 25]\n assert candidate(towers = [[5, 5, 20], [10, 10, 15], [15, 15, 10], [20, 20, 5], [25, 25, 1]],radius = 12) == [5, 5]\n assert candidate(towers = [[2, 3, 15], [5, 5, 10], [8, 7, 8], [10, 10, 20]],radius = 5) == [10, 10]\n assert candidate(towers = [[5, 0, 5], [10, 0, 5], [15, 0, 5], [20, 0, 5], [25, 0, 5]],radius = 10) == [5, 0]\n assert candidate(towers = [[0, 0, 1], [0, 1, 2], [0, 2, 3], [1, 0, 4], [1, 1, 5], [1, 2, 6], [2, 0, 7], [2, 1, 8], [2, 2, 9]],radius = 2) == [1, 1]\n assert candidate(towers = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],radius = 2) == [8, 8]\n assert candidate(towers = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1]],radius = 2) == [1, 1]\n assert candidate(towers = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]],radius = 5) == [9, 9]\n assert candidate(towers = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40]],radius = 3) == [4, 4]\n assert candidate(towers = [[10, 10, 10], [20, 10, 20], [30, 10, 30], [10, 20, 20], [20, 20, 30], [30, 20, 40]],radius = 10) == [30, 20]\n assert candidate(towers = [[10, 10, 50], [20, 20, 50], [30, 30, 50], [40, 40, 50], [50, 50, 50]],radius = 5) == [10, 10]\n assert candidate(towers = [[0, 0, 1], [1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5], [5, 5, 6]],radius = 2) == [4, 4]\n assert candidate(towers = [[10, 10, 10], [20, 20, 20], [15, 15, 15], [25, 25, 5]],radius = 10) == [20, 20]\n assert candidate(towers = [[0, 0, 1], [10, 0, 2], [20, 0, 3], [30, 0, 4], [40, 0, 5], [50, 0, 6]],radius = 15) == [50, 0]\n assert candidate(towers = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40], [5, 5, 50]],radius = 2) == [4, 4]\n assert candidate(towers = [[0, 0, 10], [50, 0, 10], [0, 50, 10], [50, 50, 10], [25, 25, 15]],radius = 20) == [25, 25]\n assert candidate(towers = [[0, 0, 50], [50, 0, 50], [50, 50, 50], [0, 50, 50], [25, 25, 50], [25, 0, 40], [25, 50, 40], [0, 25, 40], [50, 25, 40]],radius = 25) == [25, 25]\n assert candidate(towers = [[5, 5, 10], [10, 10, 20], [15, 15, 30], [20, 20, 40], [25, 25, 50]],radius = 10) == [25, 25]\n assert candidate(towers = [[10, 0, 100], [0, 10, 100], [10, 10, 100], [0, 0, 100]],radius = 15) == [0, 0]\n assert candidate(towers = [[10, 10, 50], [11, 10, 45], [12, 10, 40], [13, 10, 35], [14, 10, 30]],radius = 4) == [11, 10]\n assert candidate(towers = [[10, 10, 100], [20, 20, 200], [30, 30, 300], [40, 40, 400]],radius = 10) == [40, 40]\n assert candidate(towers = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [2, 1, 2], [2, 2, 4], [2, 3, 2], [3, 1, 3], [3, 2, 2], [3, 3, 1]],radius = 1) == [2, 2]\n assert candidate(towers = [[0, 0, 1], [1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5], [5, 5, 6]],radius = 2) == [4, 4]\n assert candidate(towers = [[10, 10, 50], [20, 20, 30], [30, 30, 10], [0, 0, 20]],radius = 15) == [10, 10]\n assert candidate(towers = [[25, 25, 50], [25, 26, 45], [26, 25, 40], [26, 26, 35], [24, 24, 30]],radius = 3) == [25, 25]\n assert candidate(towers = [[0, 0, 1], [1, 0, 2], [0, 1, 2], [1, 1, 3], [2, 2, 4], [3, 3, 5], [4, 4, 6], [5, 5, 7], [6, 6, 8]],radius = 1) == [6, 6]\n assert candidate(towers = [[2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25]],radius = 2) == [5, 5]\n assert candidate(towers = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],radius = 3) == [4, 4]\n assert candidate(towers = [[50, 50, 50], [40, 40, 40], [30, 30, 30], [20, 20, 20], [10, 10, 10]],radius = 10) == [50, 50]\n assert candidate(towers = [[20, 30, 40], [30, 40, 50], [40, 50, 60], [50, 60, 70], [60, 70, 80]],radius = 15) == [40, 50]\n assert candidate(towers = [[30, 30, 100], [25, 25, 50], [20, 20, 75], [15, 15, 60], [10, 10, 90]],radius = 10) == [30, 30]\n assert candidate(towers = [[10, 10, 100], [10, 11, 90], [11, 10, 90], [11, 11, 80], [12, 12, 70], [9, 9, 60], [9, 12, 50], [12, 9, 40], [8, 8, 30], [12, 12, 20]],radius = 3) == [10, 10]\n assert candidate(towers = [[0, 0, 5], [5, 5, 5], [10, 10, 5], [15, 15, 5], [20, 20, 5]],radius = 8) == [0, 0]\n assert candidate(towers = [[0, 0, 10], [10, 0, 10], [0, 10, 10], [10, 10, 10], [5, 5, 20]],radius = 10) == [5, 5]\n assert candidate(towers = [[20, 20, 30], [25, 25, 20], [15, 15, 40]],radius = 10) == [15, 15]\n assert candidate(towers = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]],radius = 0) == [5, 5]\n assert candidate(towers = [[1, 1, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 1, 10], [2, 2, 10], [2, 3, 10], [2, 4, 10], [3, 1, 10], [3, 2, 10], [3, 3, 10], [3, 4, 10], [4, 1, 10], [4, 2, 10], [4, 3, 10], [4, 4, 10]],radius = 3) == [2, 2]\n assert candidate(towers = [[25, 25, 25], [30, 30, 30], [20, 20, 20], [15, 15, 15], [5, 5, 5], [10, 10, 10]],radius = 5) == [30, 30]\n assert candidate(towers = [[0, 0, 5], [0, 10, 5], [10, 0, 5], [10, 10, 5], [5, 5, 10]],radius = 5) == [5, 5]\n assert candidate(towers = [[5, 5, 100], [15, 5, 90], [25, 5, 80], [35, 5, 70], [45, 5, 60], [55, 5, 50], [65, 5, 40], [75, 5, 30], [85, 5, 20], [95, 5, 10]],radius = 10) == [5, 5]\n assert candidate(towers = [[3, 3, 9], [6, 6, 12], [9, 9, 15], [12, 12, 18], [15, 15, 21]],radius = 5) == [12, 12]\n assert candidate(towers = [[10, 10, 20], [20, 20, 15], [30, 30, 25], [15, 25, 30], [25, 15, 20]],radius = 8) == [15, 25]\n assert candidate(towers = [[10, 10, 10], [10, 11, 20], [10, 12, 30], [11, 10, 40], [11, 11, 50], [11, 12, 60], [12, 10, 70], [12, 11, 80], [12, 12, 90]],radius = 3) == [12, 11]\n assert candidate(towers = [[0, 0, 1], [1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5]],radius = 10) == [3, 3]\n assert candidate(towers = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],radius = 2) == [4, 4]\n assert candidate(towers = [[25, 25, 50], [25, 26, 50], [26, 25, 50], [26, 26, 50], [24, 24, 50], [24, 25, 50], [25, 24, 50], [24, 26, 50], [26, 24, 50]],radius = 1) == [25, 25]\n"}, "metadata": {"canonical_parameter_names": ["towers", "radius"], "leetcode_dataset_entry_point": "Solution().bestCoordinate", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def bestCoordinate(self, towers: list[list[int]], radius: int) -> list[int]:", "container": "Solution", "callable": "bestCoordinate", "parameters": [{"name": "towers", "type": "list[list[int]]"}, {"name": "radius", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1621, "task_id": "number-of-sets-of-k-non-overlapping-line-segments", "difficulty": "Medium", "problem_description": "Given n points on a 1-D plane, where the ith point (from 0 to n-1) is at x = i, find the number of ways we can draw exactly k non-overlapping line segments such that each segment covers two or more points. The endpoints of each segment must have integral coordinates. The k line segments do not have to cover all n points, and they are allowed to share endpoints.\nReturn the number of ways we can draw k non-overlapping line segments. Since this number can be huge, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: n = 4, k = 2\nOutput: 5\nExplanation: The two line segments are shown in red and blue.\nThe image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),(2,3)}, {(1,2),(2,3)}, {(0,1),(1,2)}.\n\nExample 2:\n\nInput: n = 3, k = 1\nOutput: 3\nExplanation: The 3 ways are {(0,1)}, {(0,2)}, {(1,2)}.\n\nExample 3:\n\nInput: n = 30, k = 7\nOutput: 796297179\nExplanation: The total number of possible ways to draw 7 line segments is 3796297200. Taking this number modulo 109 + 7 gives us 796297179.\n\n \nConstraints:\n\n2 <= n <= 1000\n1 <= k <= n-1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,k = 1) == 3\n assert candidate(n = 1000,k = 500) == 70047606\n assert candidate(n = 30,k = 7) == 796297179\n assert candidate(n = 6,k = 3) == 28\n assert candidate(n = 8,k = 4) == 165\n assert candidate(n = 5,k = 2) == 15\n assert candidate(n = 7,k = 1) == 21\n assert candidate(n = 100,k = 50) == 237930091\n assert candidate(n = 4,k = 2) == 5\n assert candidate(n = 20,k = 10) == 10015005\n assert candidate(n = 9,k = 2) == 210\n assert candidate(n = 10,k = 3) == 924\n assert candidate(n = 400,k = 200) == 849395041\n assert candidate(n = 300,k = 150) == 188049093\n assert candidate(n = 250,k = 125) == 61117700\n assert candidate(n = 200,k = 100) == 412289370\n assert candidate(n = 150,k = 50) == 703668401\n assert candidate(n = 500,k = 200) == 89039524\n assert candidate(n = 80,k = 20) == 527894588\n assert candidate(n = 1000,k = 999) == 1\n assert candidate(n = 999,k = 998) == 1\n assert candidate(n = 750,k = 300) == 966786381\n assert candidate(n = 800,k = 350) == 811412361\n assert candidate(n = 950,k = 400) == 686452764\n assert candidate(n = 25,k = 10) == 391975633\n assert candidate(n = 1000,k = 300) == 535696304\n assert candidate(n = 50,k = 10) == 984308396\n assert candidate(n = 600,k = 250) == 917595427\n assert candidate(n = 400,k = 150) == 37130153\n assert candidate(n = 998,k = 499) == 990039585\n assert candidate(n = 700,k = 250) == 1718306\n assert candidate(n = 50,k = 20) == 875426906\n assert candidate(n = 700,k = 350) == 906610068\n assert candidate(n = 999,k = 499) == 970118741\n assert candidate(n = 900,k = 450) == 891508928\n assert candidate(n = 600,k = 100) == 945626632\n assert candidate(n = 8,k = 3) == 210\n assert candidate(n = 150,k = 75) == 937415442\n assert candidate(n = 250,k = 20) == 344905395\n assert candidate(n = 250,k = 100) == 47365034\n assert candidate(n = 25,k = 5) == 20030010\n assert candidate(n = 100,k = 10) == 697218647\n assert candidate(n = 100,k = 20) == 114267332\n assert candidate(n = 15,k = 5) == 92378\n assert candidate(n = 50,k = 15) == 188331431\n assert candidate(n = 100,k = 40) == 234333249\n assert candidate(n = 1000,k = 1) == 499500\n assert candidate(n = 600,k = 220) == 66442708\n assert candidate(n = 800,k = 300) == 374845297\n assert candidate(n = 750,k = 375) == 796219809\n assert candidate(n = 600,k = 300) == 508930020\n assert candidate(n = 50,k = 5) == 930713009\n assert candidate(n = 800,k = 400) == 530286193\n assert candidate(n = 250,k = 75) == 928665746\n assert candidate(n = 999,k = 500) == 688428127\n assert candidate(n = 350,k = 175) == 134369598\n assert candidate(n = 500,k = 100) == 698790075\n assert candidate(n = 500,k = 250) == 540818587\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().numberOfSets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numberOfSets(self, n: int, k: int) -> int:", "container": "Solution", "callable": "numberOfSets", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1624, "task_id": "largest-substring-between-two-equal-characters", "difficulty": "Easy", "problem_description": "Given a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring return -1.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"aa\"\nOutput: 0\nExplanation: The optimal substring here is an empty substring between the two 'a's.\nExample 2:\n\nInput: s = \"abca\"\nOutput: 2\nExplanation: The optimal substring here is \"bc\".\n\nExample 3:\n\nInput: s = \"cbzxy\"\nOutput: -1\nExplanation: There are no characters that appear twice in s.\n\n \nConstraints:\n\n1 <= s.length <= 300\ns contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbaa\") == 4\n assert candidate(s = \"xyzx\") == 2\n assert candidate(s = \"a\") == -1\n assert candidate(s = \"aa\") == 0\n assert candidate(s = \"abcda\") == 3\n assert candidate(s = \"abcabc\") == 2\n assert candidate(s = \"abcdabcd\") == 3\n assert candidate(s = \"xyz\") == -1\n assert candidate(s = \"abcabcbb\") == 5\n assert candidate(s = \"leetcode\") == 5\n assert candidate(s = \"mnopqrstuvmnop\") == 9\n assert candidate(s = \"zzzzzzzzzz\") == 8\n assert candidate(s = \"zabz\") == 2\n assert candidate(s = \"cbzxy\") == -1\n assert candidate(s = \"abcdeabcde\") == 4\n assert candidate(s = \"aabbcc\") == 0\n assert candidate(s = \"zabacdz\") == 5\n assert candidate(s = \"mnopqrlomn\") == 7\n assert candidate(s = \"abacaba\") == 5\n assert candidate(s = \"abca\") == 2\n assert candidate(s = \"abcdefg\") == -1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihggffeeddccbbaa\") == 102\n assert candidate(s = \"aaaabbbbccccdddd\") == 2\n assert candidate(s = \"abcabcabcabcabcabcabc\") == 17\n assert candidate(s = \"ababcabcab\") == 7\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzxywvutsrqponmlkjihgfedcba\") == 50\n assert candidate(s = \"abcdexyzabcdexyzabcdexyz\") == 15\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzza\") == 51\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 8\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 49\n assert candidate(s = \"deified\") == 5\n assert candidate(s = \"pqrstuvwxyzabcdefghijklmno\") == -1\n assert candidate(s = \"abcdefgahijklmnopqrstuvwxyz\") == 6\n assert candidate(s = \"rotorrotorrotor\") == 13\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbccccccccddddddddeeeeeeeeeffffffffggggggggghhhhhhhhiiiiiiiiiijjjjjjjjjjjjjjjjjkkkkkkkkkkkllllllllllllllllllmmmmmmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnnnooooooooooooooooppppppppppppppppppppqqqqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrrrsssssssssssssssssssssttttttttttttttttttttuuuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwwxxxyyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzz\") == 19\n assert candidate(s = \"aaaaabbbbbcccccdddddeeeee\") == 3\n assert candidate(s = \"kayak\") == 3\n assert candidate(s = \"abacabadabacaba\") == 13\n assert candidate(s = \"aabbccddeeaabbccddeeffgghheeffgghhii\") == 18\n assert candidate(s = \"abracadabra\") == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 54\n assert candidate(s = \"abcabcabcabc\") == 8\n assert candidate(s = \"abcdaebcdfeghifijkiljklmnopqrstuvswxyzxyzz\") == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 51\n assert candidate(s = \"xyzyxzyzyxzyzyxzyzyx\") == 18\n assert candidate(s = \"ab\") == -1\n assert candidate(s = \"xyzwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\") == 48\n assert candidate(s = \"aabcdefghijklmnopqrstuvwxyzabcde\") == 26\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzz\") == 16\n assert candidate(s = \"abcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\") == 113\n assert candidate(s = \"acbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcba\") == 110\n assert candidate(s = \"rotor\") == 3\n assert candidate(s = \"racecar\") == 5\n assert candidate(s = \"aaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaa\") == 105\n assert candidate(s = \"abcdefghijabcdefghij\") == 9\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 50\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\") == 19\n assert candidate(s = \"noon\") == 2\n assert candidate(s = \"aaabaaaacaaaaadaaaaaeaaaaa\") == 24\n assert candidate(s = \"abcdefgabcdefg\") == 6\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == 37\n assert candidate(s = \"lkjlkjlkjlkjlkjlkj\") == 14\n assert candidate(s = \"abcdeafghijaklmnopqrastuvwxyz\") == 19\n assert candidate(s = \"aabbaaabbbaaa\") == 11\n assert candidate(s = \"abcdaebcdfeghifijkiljklmnopqrstuvswxyzxyzzzyxwvutsrqponmlkjilfedcbazyxwvutsrqponmlkjihgfedcba\") == 91\n assert candidate(s = \"abcdefghijjihegfedcba\") == 19\n assert candidate(s = \"abacaxab\") == 5\n assert candidate(s = \"mississippi\") == 8\n assert candidate(s = \"xyzzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxz\") == 124\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(s = \"level\") == 3\n assert candidate(s = \"abcdefghijzyxwvutsrqponmlkjihgfedcba\") == 34\n assert candidate(s = \"abcdefgxyzgfedcba\") == 15\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxLengthBetweenEqualCharacters", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxLengthBetweenEqualCharacters(self, s: str) -> int:", "container": "Solution", "callable": "maxLengthBetweenEqualCharacters", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1625, "task_id": "lexicographically-smallest-string-after-applying-operations", "difficulty": "Medium", "problem_description": "You are given a string s of even length consisting of digits from 0 to 9, and two integers a and b.\nYou can apply either of the following two operations any number of times and in any order on s:\n\nAdd a to all odd indices of s (0-indexed). Digits post 9 are cycled back to 0. For example, if s = \"3456\" and a = 5, s becomes \"3951\".\nRotate s to the right by b positions. For example, if s = \"3456\" and b = 1, s becomes \"6345\".\n\nReturn the lexicographically smallest string you can obtain by applying the above operations any number of times on s.\nA string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b. For example, \"0158\" is lexicographically smaller than \"0190\" because the first position they differ is at the third letter, and '5' comes before '9'.\n \nExample 1:\n\nInput: s = \"5525\", a = 9, b = 2\nOutput: \"2050\"\nExplanation: We can apply the following operations:\nStart: \"5525\"\nRotate: \"2555\"\nAdd: \"2454\"\nAdd: \"2353\"\nRotate: \"5323\"\nAdd: \"5222\"\nAdd: \"5121\"\nRotate: \"2151\"\nAdd: \"2050\"​​​​​\nThere is no way to obtain a string that is lexicographically smaller than \"2050\".\n\nExample 2:\n\nInput: s = \"74\", a = 5, b = 1\nOutput: \"24\"\nExplanation: We can apply the following operations:\nStart: \"74\"\nRotate: \"47\"\n​​​​​​​Add: \"42\"\n​​​​​​​Rotate: \"24\"​​​​​​​​​​​​\nThere is no way to obtain a string that is lexicographically smaller than \"24\".\n\nExample 3:\n\nInput: s = \"0011\", a = 4, b = 2\nOutput: \"0011\"\nExplanation: There are no sequence of operations that will give us a lexicographically smaller string than \"0011\".\n\n \nConstraints:\n\n2 <= s.length <= 100\ns.length is even.\ns consists of digits from 0 to 9 only.\n1 <= a <= 9\n1 <= b <= s.length - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"5525\",a = 9,b = 2) == \"2050\"\n assert candidate(s = \"9876543210\",a = 7,b = 4) == \"1098765432\"\n assert candidate(s = \"74\",a = 5,b = 1) == \"24\"\n assert candidate(s = \"8900\",a = 3,b = 3) == \"0018\"\n assert candidate(s = \"1234567890\",a = 7,b = 3) == \"0022446688\"\n assert candidate(s = \"3456\",a = 5,b = 1) == \"0189\"\n assert candidate(s = \"0011\",a = 4,b = 2) == \"0011\"\n assert candidate(s = \"1234567890\",a = 3,b = 3) == \"0022446688\"\n assert candidate(s = \"9876543210\",a = 3,b = 4) == \"1098765432\"\n assert candidate(s = \"1234567890\",a = 1,b = 5) == \"0022446688\"\n assert candidate(s = \"5432109876\",a = 6,b = 7) == \"0189674523\"\n assert candidate(s = \"0246802468\",a = 4,b = 2) == \"0044882266\"\n assert candidate(s = \"908070605040302010\",a = 5,b = 7) == \"000908070604030201\"\n assert candidate(s = \"3692581470\",a = 4,b = 2) == \"1076329854\"\n assert candidate(s = \"1111111111\",a = 1,b = 2) == \"1010101010\"\n assert candidate(s = \"2222222222\",a = 5,b = 6) == \"2222222222\"\n assert candidate(s = \"0246813579\",a = 4,b = 2) == \"0044893377\"\n assert candidate(s = \"9999999999\",a = 2,b = 7) == \"1111111111\"\n assert candidate(s = \"8274635910\",a = 3,b = 3) == \"0017365544\"\n assert candidate(s = \"123412341234\",a = 2,b = 4) == \"103210321032\"\n assert candidate(s = \"2468024680\",a = 3,b = 3) == \"0044882266\"\n assert candidate(s = \"0987654321\",a = 7,b = 3) == \"0088664422\"\n assert candidate(s = \"9135791357\",a = 8,b = 12) == \"9135791357\"\n assert candidate(s = \"3333333333\",a = 3,b = 2) == \"3030303030\"\n assert candidate(s = \"9999999999\",a = 1,b = 4) == \"9090909090\"\n assert candidate(s = \"12345678901234567890\",a = 9,b = 10) == \"10325476981032547698\"\n assert candidate(s = \"1111111111\",a = 7,b = 9) == \"0000000000\"\n assert candidate(s = \"595959\",a = 3,b = 3) == \"000000\"\n assert candidate(s = \"9753186420\",a = 7,b = 6) == \"1066229955\"\n assert candidate(s = \"0246802468\",a = 5,b = 7) == \"0246802468\"\n assert candidate(s = \"1357924680\",a = 5,b = 10) == \"1357924680\"\n assert candidate(s = \"9999999999\",a = 2,b = 1) == \"1111111111\"\n assert candidate(s = \"5959595959\",a = 2,b = 1) == \"1111111111\"\n assert candidate(s = \"6420875319\",a = 9,b = 7) == \"0055117844\"\n assert candidate(s = \"6666666666\",a = 6,b = 8) == \"6060606060\"\n assert candidate(s = \"2828282828\",a = 3,b = 13) == \"2020202020\"\n assert candidate(s = \"8642086420\",a = 7,b = 25) == \"8046026824\"\n assert candidate(s = \"00000000000000000000\",a = 7,b = 15) == \"00000000000000000000\"\n assert candidate(s = \"3333333333\",a = 7,b = 11) == \"3030303030\"\n assert candidate(s = \"1212121212\",a = 4,b = 6) == \"1010101010\"\n assert candidate(s = \"5678901234\",a = 2,b = 3) == \"0123456789\"\n assert candidate(s = \"8642086420\",a = 5,b = 9) == \"0369258147\"\n assert candidate(s = \"11223344556677889900\",a = 7,b = 8) == \"10213243546576879809\"\n assert candidate(s = \"676767676767676767676767\",a = 9,b = 17) == \"000000000000000000000000\"\n assert candidate(s = \"9876543210\",a = 1,b = 3) == \"0088664422\"\n assert candidate(s = \"999999\",a = 5,b = 3) == \"444444\"\n assert candidate(s = \"0987654321\",a = 9,b = 10) == \"0088664422\"\n assert candidate(s = \"5937160482\",a = 4,b = 6) == \"0088553312\"\n assert candidate(s = \"8642086420\",a = 3,b = 3) == \"0066228844\"\n assert candidate(s = \"4321098765\",a = 6,b = 10) == \"4129078563\"\n assert candidate(s = \"112233445566778899\",a = 4,b = 8) == \"112233445566778899\"\n assert candidate(s = \"1212121212\",a = 5,b = 5) == \"1212121212\"\n assert candidate(s = \"3141592653589793238462643383\",a = 3,b = 10) == \"2057529197278866683787354553\"\n assert candidate(s = \"135791357913579135\",a = 6,b = 5) == \"115533771155993377\"\n assert candidate(s = \"86420\",a = 3,b = 2) == \"00000\"\n assert candidate(s = \"2468024680\",a = 9,b = 4) == \"0044882266\"\n assert candidate(s = \"0246813579\",a = 6,b = 3) == \"0044893377\"\n assert candidate(s = \"0123456789\",a = 9,b = 8) == \"0022446688\"\n assert candidate(s = \"8765432109\",a = 6,b = 7) == \"0189674523\"\n assert candidate(s = \"3692581470\",a = 4,b = 14) == \"3096521874\"\n assert candidate(s = \"020406080020406080020406\",a = 8,b = 11) == \"000204000204060828486888\"\n assert candidate(s = \"0123456789\",a = 9,b = 11) == \"0022446688\"\n assert candidate(s = \"4545454545\",a = 5,b = 15) == \"4040404040\"\n assert candidate(s = \"4949494949\",a = 2,b = 10) == \"4141414141\"\n assert candidate(s = \"1212121212\",a = 5,b = 6) == \"1212121212\"\n assert candidate(s = \"9360258174\",a = 5,b = 9) == \"0258174936\"\n assert candidate(s = \"2468024680\",a = 8,b = 4) == \"0044882266\"\n assert candidate(s = \"1122334455\",a = 6,b = 5) == \"1021379809\"\n assert candidate(s = \"246802468024680246802468\",a = 7,b = 13) == \"004400448822660044882266\"\n assert candidate(s = \"2244668800\",a = 3,b = 7) == \"0022446688\"\n assert candidate(s = \"1357913579\",a = 4,b = 2) == \"1155993377\"\n assert candidate(s = \"9999999999\",a = 3,b = 3) == \"0000000000\"\n assert candidate(s = \"0246813579\",a = 4,b = 3) == \"0044893377\"\n assert candidate(s = \"0000000000\",a = 9,b = 5) == \"0000000000\"\n assert candidate(s = \"8642097531\",a = 6,b = 8) == \"0177338844\"\n assert candidate(s = \"0918273645\",a = 2,b = 3) == \"0091827819\"\n assert candidate(s = \"0246813579\",a = 8,b = 2) == \"0044893377\"\n assert candidate(s = \"1122334455\",a = 7,b = 8) == \"1021324354\"\n assert candidate(s = \"7777777777\",a = 3,b = 2) == \"7070707070\"\n assert candidate(s = \"86420\",a = 9,b = 1) == \"00000\"\n assert candidate(s = \"1357924680\",a = 5,b = 1) == \"0135792468\"\n assert candidate(s = \"4826037195\",a = 2,b = 7) == \"0077599422\"\n assert candidate(s = \"5050505050\",a = 9,b = 6) == \"5050505050\"\n assert candidate(s = \"595959595959595959\",a = 4,b = 2) == \"515151515151515151\"\n assert candidate(s = \"7035298461\",a = 8,b = 5) == \"1068392574\"\n assert candidate(s = \"1928374655\",a = 3,b = 3) == \"0019283746\"\n assert candidate(s = \"5973159731\",a = 2,b = 7) == \"1135775993\"\n assert candidate(s = \"99887766554433221100\",a = 3,b = 6) == \"00998877665544332211\"\n assert candidate(s = \"9999999999\",a = 9,b = 3) == \"0000000000\"\n assert candidate(s = \"1231231231\",a = 8,b = 4) == \"1039103921\"\n assert candidate(s = \"2468035791\",a = 2,b = 8) == \"0155992266\"\n assert candidate(s = \"8642086420\",a = 5,b = 5) == \"3197531975\"\n assert candidate(s = \"2468024680\",a = 6,b = 5) == \"0044882266\"\n assert candidate(s = \"5319753197\",a = 6,b = 7) == \"1177339955\"\n assert candidate(s = \"9999999999\",a = 2,b = 10) == \"9191919191\"\n assert candidate(s = \"1357924680\",a = 2,b = 7) == \"0033771266\"\n assert candidate(s = \"0123456789\",a = 9,b = 9) == \"0022446688\"\n assert candidate(s = \"2468024680\",a = 5,b = 8) == \"0246802468\"\n assert candidate(s = \"1111111111\",a = 8,b = 1) == \"1111111111\"\n assert candidate(s = \"99999999999999999999999999\",a = 2,b = 19) == \"11111111111111111111111111\"\n assert candidate(s = \"1357924680\",a = 3,b = 3) == \"0033771266\"\n assert candidate(s = \"2736814950\",a = 3,b = 8) == \"2039844253\"\n assert candidate(s = \"1357913579\",a = 8,b = 6) == \"1155993377\"\n assert candidate(s = \"2468013579\",a = 7,b = 4) == \"0034782367\"\n assert candidate(s = \"1111111111\",a = 9,b = 9) == \"0000000000\"\n assert candidate(s = \"9182736450\",a = 4,b = 2) == \"5091827364\"\n assert candidate(s = \"5317902468\",a = 6,b = 4) == \"1194286257\"\n assert candidate(s = \"9080706050\",a = 8,b = 5) == \"0009030201\"\n assert candidate(s = \"4826093751\",a = 5,b = 10) == \"4321043256\"\n"}, "metadata": {"canonical_parameter_names": ["s", "a", "b"], "leetcode_dataset_entry_point": "Solution().findLexSmallestString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findLexSmallestString(self, s: str, a: int, b: int) -> str:", "container": "Solution", "callable": "findLexSmallestString", "parameters": [{"name": "s", "type": "str"}, {"name": "a", "type": "int"}, {"name": "b", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1626, "task_id": "best-team-with-no-conflicts", "difficulty": "Medium", "problem_description": "You are the manager of a basketball team. For the upcoming tournament, you want to choose the team with the highest overall score. The score of the team is the sum of scores of all the players in the team.\nHowever, the basketball team is not allowed to have conflicts. A conflict exists if a younger player has a strictly higher score than an older player. A conflict does not occur between players of the same age.\nGiven two lists, scores and ages, where each scores[i] and ages[i] represents the score and age of the ith player, respectively, return the highest overall score of all possible basketball teams.\n \nExample 1:\n\nInput: scores = [1,3,5,10,15], ages = [1,2,3,4,5]\nOutput: 34\nExplanation: You can choose all the players.\n\nExample 2:\n\nInput: scores = [4,5,6,5], ages = [2,1,2,1]\nOutput: 16\nExplanation: It is best to choose the last 3 players. Notice that you are allowed to choose multiple people of the same age.\n\nExample 3:\n\nInput: scores = [1,2,3,5], ages = [8,9,10,1]\nOutput: 6\nExplanation: It is best to choose the first 3 players. \n\n \nConstraints:\n\n1 <= scores.length, ages.length <= 1000\nscores.length == ages.length\n1 <= scores[i] <= 106\n1 <= ages[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(scores = [1000000, 999999, 999998],ages = [1, 2, 3]) == 1000000\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(scores = [50, 50, 50, 50],ages = [1, 2, 3, 4]) == 200\n assert candidate(scores = [10, 22, 35, 47, 55, 65],ages = [16, 19, 22, 25, 28, 31]) == 234\n assert candidate(scores = [5, 5, 5, 5],ages = [1, 2, 3, 4]) == 20\n assert candidate(scores = [1, 1, 1, 1, 1],ages = [1, 1, 1, 1, 1]) == 5\n assert candidate(scores = [100000, 100000, 100000],ages = [1000, 1000, 1000]) == 300000\n assert candidate(scores = [100, 200, 300, 400],ages = [4, 3, 2, 1]) == 400\n assert candidate(scores = [4, 5, 6, 5],ages = [2, 1, 2, 1]) == 16\n assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50\n assert candidate(scores = [1, 2, 3, 5],ages = [8, 9, 10, 1]) == 6\n assert candidate(scores = [10, 9, 8, 7],ages = [1, 2, 3, 4]) == 10\n assert candidate(scores = [5, 3, 7, 5, 2],ages = [5, 4, 8, 5, 2]) == 22\n assert candidate(scores = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(scores = [1000000, 1000000, 1000000],ages = [1, 1, 1]) == 3000000\n assert candidate(scores = [1, 3, 5, 10, 15],ages = [1, 2, 3, 4, 5]) == 34\n assert candidate(scores = [1, 2, 2, 1],ages = [3, 1, 1, 3]) == 4\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 30\n assert candidate(scores = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 550\n assert candidate(scores = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 150\n assert candidate(scores = [100, 90, 80, 70, 60],ages = [18, 17, 16, 15, 14]) == 400\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 550\n assert candidate(scores = [90, 85, 90, 100, 105, 110, 105, 115, 120],ages = [25, 30, 25, 30, 35, 40, 45, 50, 55]) == 730\n assert candidate(scores = [2, 5, 3, 1, 4],ages = [1, 2, 3, 4, 5]) == 9\n assert candidate(scores = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [20, 30, 20, 30, 20],ages = [2, 2, 3, 3, 4]) == 80\n assert candidate(scores = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 36\n assert candidate(scores = [10, 5, 7, 1, 9, 6, 8, 3, 4, 2],ages = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 55\n assert candidate(scores = [10, 20, 30, 20, 10, 40, 50],ages = [1, 2, 3, 1, 2, 3, 4]) == 170\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(scores = [25, 30, 5, 50, 40, 60, 70, 10, 80, 90],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 405\n assert candidate(scores = [4, 10, 4, 3, 8, 9],ages = [4, 1, 2, 4, 3, 1]) == 19\n assert candidate(scores = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],ages = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == 45\n assert candidate(scores = [5, 10, 15, 20, 25, 30, 35, 40],ages = [1, 3, 2, 5, 4, 7, 6, 8]) == 120\n assert candidate(scores = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 55\n assert candidate(scores = [40, 20, 30, 10, 50],ages = [2, 1, 3, 4, 5]) == 110\n assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5500\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 45\n assert candidate(scores = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],ages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 605\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 55\n assert candidate(scores = [10, 20, 30, 25, 40],ages = [4, 3, 5, 2, 6]) == 95\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 550\n assert candidate(scores = [20, 30, 25, 20, 40, 35, 30, 45, 50, 60],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 245\n assert candidate(scores = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1000000000\n assert candidate(scores = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],ages = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1000\n assert candidate(scores = [10, 6, 5, 7, 3, 8],ages = [4, 3, 2, 4, 1, 5]) == 31\n assert candidate(scores = [8, 5, 6, 10, 7, 9, 4, 2, 11, 3],ages = [8, 6, 6, 9, 7, 8, 5, 4, 10, 3]) == 63\n assert candidate(scores = [1000, 500, 250, 750, 100],ages = [20, 25, 30, 35, 40]) == 1250\n assert candidate(scores = [4, 1, 3, 2, 5],ages = [2, 1, 2, 3, 1]) == 8\n assert candidate(scores = [10, 20, 30, 40, 50],ages = [10, 20, 30, 40, 50]) == 150\n assert candidate(scores = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60],ages = [1, 2, 1, 3, 2, 4, 3, 5, 4, 5]) == 310\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],ages = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(scores = [10, 9, 2, 5, 3, 7, 1, 8, 6, 4],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 22\n assert candidate(scores = [1000000, 100000, 10000, 1000, 100, 10, 1],ages = [1, 2, 3, 4, 5, 6, 7]) == 1000000\n assert candidate(scores = [10, 20, 30, 40, 50],ages = [3, 2, 1, 2, 3]) == 120\n assert candidate(scores = [9, 2, 8, 5, 7, 6, 3, 4, 1, 10],ages = [4, 1, 6, 3, 5, 4, 2, 3, 1, 7]) == 46\n assert candidate(scores = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [100, 200, 300, 400, 500],ages = [5, 4, 3, 2, 1]) == 500\n assert candidate(scores = [100, 200, 300, 200, 100],ages = [1, 2, 3, 4, 5]) == 600\n assert candidate(scores = [9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 45\n assert candidate(scores = [20, 10, 20, 10, 20, 10, 20, 10, 20, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [4, 5, 6, 5, 7, 8, 6, 9],ages = [2, 1, 2, 1, 3, 4, 3, 5]) == 46\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 550\n assert candidate(scores = [20, 30, 10, 40, 50],ages = [10, 10, 10, 10, 10]) == 150\n assert candidate(scores = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 50\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(scores = [9, 2, 8, 8, 8, 2, 1, 1, 1, 4],ages = [6, 2, 4, 7, 7, 2, 2, 2, 4, 3]) == 34\n assert candidate(scores = [8, 2, 7, 5, 4, 3, 9],ages = [2, 3, 1, 2, 3, 4, 5]) == 24\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(scores = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1],ages = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1]) == 28\n assert candidate(scores = [15, 20, 5, 10, 25, 30],ages = [5, 5, 2, 3, 5, 5]) == 105\n assert candidate(scores = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(scores = [5, 10, 15, 20, 25, 30, 35],ages = [20, 20, 20, 20, 20, 20, 20]) == 140\n assert candidate(scores = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 95\n assert candidate(scores = [8, 6, 7, 5, 3, 0, 9],ages = [1, 2, 2, 3, 3, 3, 4]) == 22\n assert candidate(scores = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 550\n assert candidate(scores = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],ages = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == 20\n assert candidate(scores = [3, 10, 2, 1, 5, 7, 8, 6, 4, 9],ages = [1, 3, 2, 4, 2, 2, 3, 2, 2, 1]) == 43\n assert candidate(scores = [50, 40, 30, 20, 10, 100, 90, 80, 70, 60],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 150\n assert candidate(scores = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 275\n assert candidate(scores = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [10, 20, 20, 10, 30, 30, 40, 40],ages = [1, 1, 2, 2, 3, 3, 4, 4]) == 190\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(scores = [10, 20, 20, 10, 30],ages = [1, 2, 3, 4, 5]) == 80\n assert candidate(scores = [1000, 1000, 1000, 1000, 1000],ages = [1, 1, 1, 1, 1]) == 5000\n assert candidate(scores = [30, 10, 20, 40, 50, 15, 25, 35, 45, 55],ages = [3, 1, 2, 4, 5, 1, 2, 3, 4, 5]) == 325\n assert candidate(scores = [50, 40, 30, 20, 10],ages = [1, 1, 1, 1, 1]) == 150\n assert candidate(scores = [1, 3, 2, 5, 4, 6, 7, 8, 9, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(scores = [20, 20, 20, 20, 20],ages = [1, 2, 3, 4, 5]) == 100\n assert candidate(scores = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(scores = [5, 4, 3, 2, 1],ages = [1, 1, 1, 1, 1]) == 15\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 550\n assert candidate(scores = [100, 200, 150, 100, 50, 250],ages = [5, 4, 3, 2, 1, 6]) == 750\n assert candidate(scores = [3, 1, 2],ages = [1, 1, 1]) == 6\n assert candidate(scores = [3, 2, 3, 2, 3, 2, 3, 2, 3, 2],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 25\n assert candidate(scores = [4, 1, 6, 2, 5, 3],ages = [2, 1, 3, 1, 2, 3]) == 18\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n assert candidate(scores = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],ages = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 20\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 54\n assert candidate(scores = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],ages = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 11\n assert candidate(scores = [15, 30, 10, 20, 50],ages = [5, 10, 15, 20, 25]) == 95\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 350\n assert candidate(scores = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50],ages = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 200\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 55\n assert candidate(scores = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],ages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1000000\n assert candidate(scores = [20, 10, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 540\n assert candidate(scores = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 26\n assert candidate(scores = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 165\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 65\n assert candidate(scores = [2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1],ages = [2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1]) == 75\n assert candidate(scores = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(scores = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],ages = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == 23\n assert candidate(scores = [1000, 500, 200, 1000, 1000, 500, 200],ages = [2, 1, 3, 2, 3, 1, 3]) == 4000\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(scores = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 22\n assert candidate(scores = [100, 200, 300, 400, 500, 150, 250, 350, 450, 550],ages = [10, 9, 8, 7, 6, 1, 2, 3, 4, 5]) == 1750\n assert candidate(scores = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 550\n assert candidate(scores = [10, 20, 30, 40, 50],ages = [1, 3, 2, 5, 4]) == 90\n assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50\n assert candidate(scores = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [4, 10, 10, 6, 7, 1, 9],ages = [4, 1, 4, 2, 2, 3, 6]) == 23\n assert candidate(scores = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],ages = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 30\n assert candidate(scores = [1, 2, 3, 4, 5],ages = [5, 4, 3, 2, 1]) == 5\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 550\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(scores = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],ages = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 275\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 550\n assert candidate(scores = [5, 4, 3, 2, 1],ages = [1, 2, 3, 4, 5]) == 5\n assert candidate(scores = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 220\n assert candidate(scores = [100, 90, 80, 70, 60],ages = [5, 4, 3, 2, 1]) == 400\n assert candidate(scores = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 200\n assert candidate(scores = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],ages = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 1]) == 19\n assert candidate(scores = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1998046\n"}, "metadata": {"canonical_parameter_names": ["scores", "ages"], "leetcode_dataset_entry_point": "Solution().bestTeamScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def bestTeamScore(self, scores: list[int], ages: list[int]) -> int:", "container": "Solution", "callable": "bestTeamScore", "parameters": [{"name": "scores", "type": "list[int]"}, {"name": "ages", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1627, "task_id": "graph-connectivity-with-threshold", "difficulty": "Hard", "problem_description": "We have n cities labeled from 1 to n. Two different cities with labels x and y are directly connected by a bidirectional road if and only if x and y share a common divisor strictly greater than some threshold. More formally, cities with labels x and y have a road between them if there exists an integer z such that all of the following are true:\n\nx % z == 0,\ny % z == 0, and\nz > threshold.\n\nGiven the two integers, n and threshold, and an array of queries, you must determine for each queries[i] = [ai, bi] if cities ai and bi are connected directly or indirectly. (i.e. there is some path between them).\nReturn an array answer, where answer.length == queries.length and answer[i] is true if for the ith query, there is a path between ai and bi, or answer[i] is false if there is no path.\n \nExample 1:\n\n\nInput: n = 6, threshold = 2, queries = [[1,4],[2,5],[3,6]]\nOutput: [false,false,true]\nExplanation: The divisors for each number:\n1: 1\n2: 1, 2\n3: 1, 3\n4: 1, 2, 4\n5: 1, 5\n6: 1, 2, 3, 6\nUsing the underlined divisors above the threshold, only cities 3 and 6 share a common divisor, so they are the\nonly ones directly connected. The result of each query:\n[1,4] 1 is not connected to 4\n[2,5] 2 is not connected to 5\n[3,6] 3 is connected to 6 through path 3--6\n\nExample 2:\n\n\nInput: n = 6, threshold = 0, queries = [[4,5],[3,4],[3,2],[2,6],[1,3]]\nOutput: [true,true,true,true,true]\nExplanation: The divisors for each number are the same as the previous example. However, since the threshold is 0,\nall divisors can be used. Since all numbers share 1 as a divisor, all cities are connected.\n\nExample 3:\n\n\nInput: n = 5, threshold = 1, queries = [[4,5],[4,5],[3,2],[2,3],[3,4]]\nOutput: [false,false,false,false,false]\nExplanation: Only cities 2 and 4 share a common divisor 2 which is strictly greater than the threshold 1, so they are the only ones directly connected.\nPlease notice that there can be multiple queries for the same pair of nodes [x, y], and that the query [x, y] is equivalent to the query [y, x].\n\n \nConstraints:\n\n2 <= n <= 104\n0 <= threshold <= n\n1 <= queries.length <= 105\nqueries[i].length == 2\n1 <= ai, bi <= cities\nai != bi\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,threshold = 0,queries = [[4, 5], [3, 4], [3, 2], [2, 6], [1, 3]]) == [True, True, True, True, True]\n assert candidate(n = 10,threshold = 3,queries = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 50,queries = [[1, 2], [51, 100], [49, 99]]) == [False, False, False]\n assert candidate(n = 6,threshold = 2,queries = [[1, 4], [2, 5], [3, 6]]) == [False, False, True]\n assert candidate(n = 5,threshold = 1,queries = [[4, 5], [4, 5], [3, 2], [2, 3], [3, 4]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 50,queries = [[1, 99], [2, 98], [3, 97], [4, 96]]) == [False, False, False, False]\n assert candidate(n = 3000,threshold = 1500,queries = [[1501, 2250], [1502, 2251], [1503, 2252], [1504, 2253], [1505, 2254], [1506, 2255], [1507, 2256], [1508, 2257], [1509, 2258], [1510, 2259]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 1000,queries = [[1, 2000], [3000, 4000], [5000, 6000], [7000, 8000], [9000, 10000]]) == [False, True, True, True, True]\n assert candidate(n = 50,threshold = 5,queries = [[6, 12], [10, 20], [14, 28], [18, 36], [22, 44]]) == [True, True, True, True, True]\n assert candidate(n = 999,threshold = 333,queries = [[1, 334], [2, 335], [3, 336], [4, 337], [5, 338], [6, 339]]) == [False, False, False, False, False, False]\n assert candidate(n = 100,threshold = 0,queries = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96]]) == [True, True, True, True, True]\n assert candidate(n = 5000,threshold = 1000,queries = [[1000, 2000], [3000, 4000], [4999, 5000]]) == [False, False, False]\n assert candidate(n = 100,threshold = 25,queries = [[26, 52], [27, 54], [28, 56], [29, 58], [30, 60]]) == [True, True, True, True, True]\n assert candidate(n = 1000,threshold = 1,queries = [[2, 4], [3, 6], [5, 10], [7, 14], [8, 16], [9, 18], [10, 20], [11, 22], [12, 24], [13, 26]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 5000,queries = [[1, 6000], [2, 6001], [3, 6002], [4, 6003], [5, 6004], [6, 6005]]) == [False, False, False, False, False, False]\n assert candidate(n = 1000,threshold = 250,queries = [[150, 300], [200, 400], [500, 750], [800, 900], [100, 900]]) == [False, False, False, False, False]\n assert candidate(n = 1000,threshold = 250,queries = [[1, 500], [2, 501], [3, 502], [4, 503], [5, 504], [6, 505]]) == [False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 9999,queries = [[1, 10000], [2, 9999], [3, 9998], [4, 9997]]) == [False, False, False, False]\n assert candidate(n = 500,threshold = 250,queries = [[251, 500], [252, 499], [253, 498], [254, 497], [255, 496], [256, 495]]) == [False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 5000,queries = [[1000, 9000], [5000, 6000], [1, 2], [9999, 10000]]) == [False, False, False, False]\n assert candidate(n = 5000,threshold = 100,queries = [[100, 200], [50, 150], [300, 600], [1, 2], [4999, 5000]]) == [False, False, True, False, False]\n assert candidate(n = 1000,threshold = 250,queries = [[1, 500], [2, 750], [3, 900], [4, 950], [5, 999]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 2000,queries = [[1, 3000], [2, 4000], [3, 4500], [4, 4900], [5, 4999]]) == [False, False, False, False, False]\n assert candidate(n = 50,threshold = 10,queries = [[11, 22], [13, 26], [15, 30], [7, 14], [21, 42]]) == [True, True, True, False, True]\n assert candidate(n = 5000,threshold = 250,queries = [[125, 250], [375, 500], [625, 750], [875, 1000], [1125, 1250]]) == [False, True, True, True, True]\n assert candidate(n = 1000,threshold = 200,queries = [[500, 750], [250, 501], [750, 1000], [1, 999]]) == [True, False, True, False]\n assert candidate(n = 10000,threshold = 0,queries = [[1, 9999], [2, 9998], [3, 9997], [4, 9996], [5, 9995], [6, 9994], [7, 9993], [8, 9992], [9, 9991], [10, 9990]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 5000,queries = [[5100, 9900], [5200, 9800], [5300, 9700], [5400, 9600], [5500, 9500]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 1000,queries = [[1200, 2400], [1500, 3000], [2500, 4000], [3500, 4500], [1000, 4000]]) == [True, True, False, False, False]\n assert candidate(n = 1000,threshold = 5,queries = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 10,queries = [[1, 11], [2, 12], [3, 13], [4, 14], [5, 15]]) == [False, False, False, False, False]\n assert candidate(n = 1000,threshold = 50,queries = [[1, 50], [2, 50], [3, 50], [4, 50], [5, 50], [6, 50], [7, 50], [8, 50]]) == [False, False, False, False, False, False, False, False]\n assert candidate(n = 5000,threshold = 2500,queries = [[1, 2501], [1000, 3000], [2500, 5000]]) == [False, False, False]\n assert candidate(n = 2000,threshold = 100,queries = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000], [1100, 1200], [1300, 1400], [1500, 1600], [1700, 1800], [1900, 2000]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 100,threshold = 20,queries = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == [False, False, False, False, False]\n assert candidate(n = 20,threshold = 19,queries = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16]]) == [False, False, False, False, False]\n assert candidate(n = 2000,threshold = 1000,queries = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 1000,queries = [[2000, 3000], [1001, 2001], [4000, 5000], [999, 4999]]) == [False, False, False, False]\n assert candidate(n = 8000,threshold = 4000,queries = [[4001, 8000], [4002, 7999], [4003, 7998], [4004, 7997], [4005, 7996], [4006, 7995]]) == [False, False, False, False, False, False]\n assert candidate(n = 2000,threshold = 100,queries = [[50, 150], [100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500], [450, 550], [500, 600]]) == [False, False, True, True, True, True, True, True, True, True]\n assert candidate(n = 1000,threshold = 5,queries = [[1, 3], [2, 4], [5, 7], [8, 10], [11, 13], [14, 16], [17, 19], [20, 22], [23, 25], [26, 28], [29, 31], [32, 34], [35, 37], [38, 40], [41, 43], [44, 46], [47, 49], [50, 52], [53, 55], [56, 58], [59, 61], [62, 64], [65, 67], [68, 70], [71, 73], [74, 76], [77, 79], [80, 82], [83, 85], [86, 88], [89, 91], [92, 94], [95, 97], [98, 100]]) == [False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 50,queries = [[51, 101], [52, 102], [53, 103], [54, 104], [55, 105], [56, 106], [57, 107], [58, 108], [59, 109], [60, 110]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 1,queries = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 1000,threshold = 500,queries = [[10, 20], [30, 50], [25, 75], [500, 1000], [999, 1000]]) == [False, False, False, False, False]\n assert candidate(n = 1000,threshold = 50,queries = [[51, 100], [52, 99], [53, 98], [54, 97], [55, 96], [56, 95], [57, 94], [58, 93], [59, 92], [60, 91]]) == [True, True, False, False, True, True, False, False, False, True]\n assert candidate(n = 8000,threshold = 4000,queries = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [False, False, False, False, False]\n assert candidate(n = 3000,threshold = 1500,queries = [[1501, 2000], [1502, 2500], [1503, 3000], [2000, 3000], [1504, 1505], [1506, 1507]]) == [False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 2000,queries = [[2001, 4000], [2002, 4001], [2003, 4002], [2004, 4003], [2005, 4004], [2006, 4005], [2007, 4006], [2008, 4007], [2009, 4008], [2010, 4009]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 5000,queries = [[1, 7000], [2, 8000], [3, 9000], [4, 9500], [5, 9999]]) == [False, False, False, False, False]\n assert candidate(n = 10000,threshold = 5000,queries = [[1, 5001], [2, 5002], [3, 5003], [4, 5004], [5, 5005]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 99,queries = [[1, 100]]) == [False]\n assert candidate(n = 5000,threshold = 2,queries = [[3, 6], [5, 10], [7, 14], [9, 18], [11, 22], [13, 26], [15, 30], [17, 34], [19, 38], [21, 42]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 5000,queries = [[5001, 5002], [5003, 5004], [5005, 5006], [5007, 5008], [5009, 5010]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 2500,queries = [[1, 500], [1000, 1500], [2000, 2500], [3000, 3500], [4000, 4500], [4500, 5000]]) == [False, False, False, False, False, False]\n assert candidate(n = 1000,threshold = 300,queries = [[101, 202], [303, 404], [505, 606], [707, 808], [909, 1000]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 1,queries = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [False, True, True, True, True]\n assert candidate(n = 2000,threshold = 0,queries = [[1, 1999], [2, 1998], [3, 1997], [4, 1996], [5, 1995], [6, 1994], [7, 1993], [8, 1992], [9, 1991], [10, 1990]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 500,threshold = 250,queries = [[251, 500], [252, 499], [253, 498], [254, 497], [255, 496]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 2500,queries = [[1, 2501], [2, 2502], [3, 2503], [4, 2504], [5, 2505]]) == [False, False, False, False, False]\n assert candidate(n = 2000,threshold = 1,queries = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 150,threshold = 50,queries = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110], [110, 120], [120, 130], [130, 140], [140, 150]]) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False]\n assert candidate(n = 1000,threshold = 0,queries = [[1, 999], [2, 998], [3, 997], [4, 996], [5, 995], [10, 100], [50, 150], [200, 300], [700, 800], [900, 1000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 500,threshold = 250,queries = [[1, 251], [2, 252], [3, 253], [4, 254], [5, 255], [250, 499], [251, 498], [252, 497], [253, 496], [254, 495]]) == [False, False, False, False, False, False, False, False, False, False]\n"}, "metadata": {"canonical_parameter_names": ["n", "threshold", "queries"], "leetcode_dataset_entry_point": "Solution().areConnected", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def areConnected(self, n: int, threshold: int, queries: list[list[int]]) -> list[bool]:", "container": "Solution", "callable": "areConnected", "parameters": [{"name": "n", "type": "int"}, {"name": "threshold", "type": "int"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1629, "task_id": "slowest-key", "difficulty": "Easy", "problem_description": "A newly designed keypad was tested, where a tester pressed a sequence of n keys, one at a time.\nYou are given a string keysPressed of length n, where keysPressed[i] was the ith key pressed in the testing sequence, and a sorted list releaseTimes, where releaseTimes[i] was the time the ith key was released. Both arrays are 0-indexed. The 0th key was pressed at the time 0, and every subsequent key was pressed at the exact time the previous key was released.\nThe tester wants to know the key of the keypress that had the longest duration. The ith keypress had a duration of releaseTimes[i] - releaseTimes[i - 1], and the 0th keypress had a duration of releaseTimes[0].\nNote that the same key could have been pressed multiple times during the test, and these multiple presses of the same key may not have had the same duration.\nReturn the key of the keypress that had the longest duration. If there are multiple such keypresses, return the lexicographically largest key of the keypresses.\n \nExample 1:\n\nInput: releaseTimes = [9,29,49,50], keysPressed = \"cbcd\"\nOutput: \"c\"\nExplanation: The keypresses were as follows:\nKeypress for 'c' had a duration of 9 (pressed at time 0 and released at time 9).\nKeypress for 'b' had a duration of 29 - 9 = 20 (pressed at time 9 right after the release of the previous character and released at time 29).\nKeypress for 'c' had a duration of 49 - 29 = 20 (pressed at time 29 right after the release of the previous character and released at time 49).\nKeypress for 'd' had a duration of 50 - 49 = 1 (pressed at time 49 right after the release of the previous character and released at time 50).\nThe longest of these was the keypress for 'b' and the second keypress for 'c', both with duration 20.\n'c' is lexicographically larger than 'b', so the answer is 'c'.\n\nExample 2:\n\nInput: releaseTimes = [12,23,36,46,62], keysPressed = \"spuda\"\nOutput: \"a\"\nExplanation: The keypresses were as follows:\nKeypress for 's' had a duration of 12.\nKeypress for 'p' had a duration of 23 - 12 = 11.\nKeypress for 'u' had a duration of 36 - 23 = 13.\nKeypress for 'd' had a duration of 46 - 36 = 10.\nKeypress for 'a' had a duration of 62 - 46 = 16.\nThe longest of these was the keypress for 'a' with duration 16.\n \nConstraints:\n\nreleaseTimes.length == n\nkeysPressed.length == n\n2 <= n <= 1000\n1 <= releaseTimes[i] <= 109\nreleaseTimes[i] < releaseTimes[i+1]\nkeysPressed contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(releaseTimes = [2, 3, 7, 10, 15],keysPressed = \"zzzaa\") == \"a\"\n assert candidate(releaseTimes = [5, 10, 15, 20, 25],keysPressed = \"zabzc\") == \"z\"\n assert candidate(releaseTimes = [5, 15, 25, 35, 45, 55],keysPressed = \"abcdef\") == \"f\"\n assert candidate(releaseTimes = [50, 70, 80, 90],keysPressed = \"abcd\") == \"a\"\n assert candidate(releaseTimes = [9, 29, 49, 50],keysPressed = \"cbcd\") == \"c\"\n assert candidate(releaseTimes = [10, 15, 20, 25, 30],keysPressed = \"aabcd\") == \"a\"\n assert candidate(releaseTimes = [12, 23, 36, 46, 62],keysPressed = \"spuda\") == \"a\"\n assert candidate(releaseTimes = [1, 2, 3, 4, 5],keysPressed = \"abcde\") == \"e\"\n assert candidate(releaseTimes = [50, 75, 100, 125, 150],keysPressed = \"zzzzz\") == \"z\"\n assert candidate(releaseTimes = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],keysPressed = \"qwertyuiopz\") == \"z\"\n assert candidate(releaseTimes = [100, 200, 300, 400, 500],keysPressed = \"aaaaa\") == \"a\"\n assert candidate(releaseTimes = [2, 5, 10, 15, 20, 25, 30],keysPressed = \"zzzzzz\") == \"z\"\n assert candidate(releaseTimes = [1, 3, 5, 7, 9],keysPressed = \"abcde\") == \"e\"\n assert candidate(releaseTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],keysPressed = \"abcdefghij\") == \"j\"\n assert candidate(releaseTimes = [100, 200, 300, 400],keysPressed = \"abcd\") == \"d\"\n assert candidate(releaseTimes = [10, 20, 30, 40, 50],keysPressed = \"aaaaa\") == \"a\"\n assert candidate(releaseTimes = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41],keysPressed = \"abcdefghijk\") == \"k\"\n assert candidate(releaseTimes = [5, 10, 15, 20, 25, 30],keysPressed = \"ppppp\") == \"p\"\n assert candidate(releaseTimes = [10, 20, 30, 40],keysPressed = \"abcd\") == \"d\"\n assert candidate(releaseTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],keysPressed = \"abcdefghijklmnopqrstuvwxyz\") == \"z\"\n assert candidate(releaseTimes = [10, 30, 70, 150, 230, 320, 420, 530, 650, 780, 920, 1080, 1260, 1460, 1680, 1920],keysPressed = \"zzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(releaseTimes = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990, 1035, 1081, 1128, 1176, 1225, 1275, 1326, 1378, 1431, 1485, 1540, 1596, 1653, 1711, 1770, 1830, 1891, 1953, 2016, 2080, 2145, 2211, 2278, 2346, 2415, 2485, 2556, 2628, 2701, 2775, 2850, 2926, 3003, 3081, 3160, 3240, 3321, 3403, 3486, 3570, 3655, 3741, 3828, 3916, 4005, 4095, 4186, 4278, 4371, 4465, 4560, 4656, 4753, 4851, 4950],keysPressed = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == \"a\"\n assert candidate(releaseTimes = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145, 160, 175, 190, 205, 220, 235, 250, 265, 280, 295, 310, 325, 340, 355, 370, 385, 400, 415, 430, 445],keysPressed = \"zyxwvutsrqponmlkjihgfedcba\") == \"y\"\n assert candidate(releaseTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],keysPressed = \"abcdefghijklmno\") == \"o\"\n assert candidate(releaseTimes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],keysPressed = \"zzzzzzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(releaseTimes = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300],keysPressed = \"nopqrstuvwxyz\") == \"z\"\n assert candidate(releaseTimes = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],keysPressed = \"abcdefghijklmno\") == \"a\"\n assert candidate(releaseTimes = [10, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145],keysPressed = \"abcdefghijklmn\") == \"b\"\n assert candidate(releaseTimes = [20, 45, 60, 80, 100, 120, 140, 160, 180, 200],keysPressed = \"abcdefghij\") == \"b\"\n assert candidate(releaseTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60],keysPressed = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"z\"\n assert candidate(releaseTimes = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86, 89, 92, 95, 98, 101, 104, 107, 110, 113, 116, 119, 122, 125, 128, 131, 134, 137, 140, 143, 146, 149, 152, 155, 158, 161, 164, 167, 170, 173, 176, 179, 182, 185, 188, 191, 194, 197, 200],keysPressed = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"z\"\n assert candidate(releaseTimes = [5, 15, 30, 45, 60, 75, 90, 105, 120, 135],keysPressed = \"abcdefghij\") == \"j\"\n assert candidate(releaseTimes = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250, 255, 260, 265, 270, 275, 280, 285, 290, 295, 300],keysPressed = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"a\"\n assert candidate(releaseTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],keysPressed = \"zzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(releaseTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],keysPressed = \"abcdefghijklmnopqrst\") == \"t\"\n assert candidate(releaseTimes = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600],keysPressed = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\") == \"z\"\n assert candidate(releaseTimes = [5, 9, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253],keysPressed = \"mississippiissiippi\") == \"i\"\n assert candidate(releaseTimes = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],keysPressed = \"abcdefghijklmnopqrst\") == \"t\"\n"}, "metadata": {"canonical_parameter_names": ["releaseTimes", "keysPressed"], "leetcode_dataset_entry_point": "Solution().slowestKey", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def slowestKey(self, releaseTimes: list[int], keysPressed: str) -> str:", "container": "Solution", "callable": "slowestKey", "parameters": [{"name": "releaseTimes", "type": "list[int]"}, {"name": "keysPressed", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1630, "task_id": "arithmetic-subarrays", "difficulty": "Medium", "problem_description": "A sequence of numbers is called arithmetic if it consists of at least two elements, and the difference between every two consecutive elements is the same. More formally, a sequence s is arithmetic if and only if s[i+1] - s[i] == s[1] - s[0] for all valid i.\nFor example, these are arithmetic sequences:\n\n1, 3, 5, 7, 9\n7, 7, 7, 7\n3, -1, -5, -9\nThe following sequence is not arithmetic:\n\n1, 1, 2, 5, 7\nYou are given an array of n integers, nums, and two arrays of m integers each, l and r, representing the m range queries, where the ith query is the range [l[i], r[i]]. All the arrays are 0-indexed.\nReturn a list of boolean elements answer, where answer[i] is true if the subarray nums[l[i]], nums[l[i]+1], ... , nums[r[i]] can be rearranged to form an arithmetic sequence, and false otherwise.\n \nExample 1:\n\nInput: nums = [4,6,5,9,3,7], l = [0,0,2], r = [2,3,5]\nOutput: [true,false,true]\nExplanation:\nIn the 0th query, the subarray is [4,6,5]. This can be rearranged as [6,5,4], which is an arithmetic sequence.\nIn the 1st query, the subarray is [4,6,5,9]. This cannot be rearranged as an arithmetic sequence.\nIn the 2nd query, the subarray is [5,9,3,7]. This can be rearranged as [3,5,7,9], which is an arithmetic sequence.\nExample 2:\n\nInput: nums = [-12,-9,-3,-12,-6,15,20,-25,-20,-15,-10], l = [0,1,6,4,8,7], r = [4,4,9,7,9,10]\nOutput: [false,true,false,false,true,true]\n\n \nConstraints:\n\nn == nums.length\nm == l.length\nm == r.length\n2 <= n <= 500\n1 <= m <= 500\n0 <= l[i] < r[i] < n\n-105 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1],l = [0, 0, 2, 3],r = [1, 2, 4, 4]) == [True, True, True, True]\n assert candidate(nums = [5, 5, 5, 5, 5],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [0, 3, 5, 7, 9],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, True]\n assert candidate(nums = [0, 5, 10, 15, 20],l = [0, 0, 1, 2],r = [2, 3, 3, 4]) == [True, True, True, True]\n assert candidate(nums = [-12, -9, -3, -12, -6, 15, 20, -25, -20, -15, -10],l = [0, 1, 6, 4, 8, 7],r = [4, 4, 9, 7, 9, 10]) == [False, True, False, False, True, True]\n assert candidate(nums = [1, 2, 3, 5, 6],l = [0, 2],r = [2, 4]) == [True, False]\n assert candidate(nums = [10, 9, 8, 7, 6],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, True]\n assert candidate(nums = [1, 2, 4, 6, 8, 10],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [5, 3, 1, 7, 9],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, False]\n assert candidate(nums = [1, 2, 4, 6, 8],l = [0, 1, 2, 3],r = [2, 3, 4, 4]) == [False, True, True, True]\n assert candidate(nums = [1, 1, 2, 5, 7],l = [0, 2, 3],r = [2, 3, 4]) == [False, True, True]\n assert candidate(nums = [1, 2, 4, 6, 8],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, True]\n assert candidate(nums = [4, 6, 5, 9, 3, 7],l = [0, 0, 2],r = [2, 3, 5]) == [True, False, True]\n assert candidate(nums = [10, 5, 3, 7, 8],l = [0, 1, 2, 3],r = [1, 2, 3, 4]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1, 2],r = [2, 3, 4]) == [True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1, 2],r = [4, 3, 4]) == [True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50],l = [0, 2],r = [1, 3]) == [True, True]\n assert candidate(nums = [1, 1, 1, 1, 1],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600],l = [0, 1, 2],r = [2, 3, 4]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1, 2],r = [4, 3, 3]) == [True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1],l = [0, 1, 2],r = [4, 3, 3]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1],r = [2, 4]) == [True, True]\n assert candidate(nums = [-10, -7, -4, -1, 2, 5, 8, 11],l = [0, 1, 2, 3],r = [2, 4, 6, 7]) == [True, True, True, True]\n assert candidate(nums = [-5, -10, -15, -20, -25, -30],l = [0, 2, 4],r = [1, 3, 5]) == [True, True, True]\n assert candidate(nums = [20, 10, 30, 50, 40, 60, 70, 80, 90, 100],l = [0, 1, 2, 3, 4, 5],r = [2, 4, 6, 8, 9, 9]) == [True, False, True, True, False, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],l = [0, 3, 6, 9, 12],r = [2, 5, 8, 11, 14]) == [True, True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = [1, 3, 5, 7],r = [8, 9, 8, 9]) == [True, True, True, True]\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500],l = [0, 2, 4, 6],r = [2, 4, 6, 7]) == [False, False, False, True]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],l = [0, 1, 2, 3, 4, 5, 6],r = [1, 2, 3, 4, 5, 6, 9]) == [True, True, True, True, True, True, False]\n assert candidate(nums = [10, 5, 15, 20, 25, 30, 35, 40],l = [1, 0, 2, 5],r = [6, 4, 4, 7]) == [False, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],l = [0, 0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9, 9]) == [True, True, True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900],l = [0, 1, 3, 5],r = [2, 4, 6, 8]) == [True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],l = [0, 6, 12, 18],r = [5, 11, 17, 19]) == [True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],l = [0, 5, 10],r = [4, 9, 12]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],l = [0, 2, 4, 6, 8, 10],r = [1, 3, 5, 7, 9, 20]) == [True, True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],l = [0, 5, 10, 15],r = [4, 9, 14, 19]) == [True, True, True, True]\n assert candidate(nums = [5, 8, 11, 14, 17, 20, 23, 26, 29],l = [0, 2, 5, 6],r = [3, 5, 7, 8]) == [True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],l = [0, 3, 6, 9, 1],r = [2, 5, 8, 10, 4]) == [True, True, True, True, True]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],l = [0, 0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9, 9]) == [True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 10]) == [True, True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 0, 0, 0],r = [3, 4, 5, 6]) == [True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 1, 2, 3, 4],r = [4, 5, 6, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [10, 5, 0, -5, -10, -15, -20, -25, -30, -35],l = [0, 0, 0, 0],r = [4, 5, 6, 7]) == [True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = [0, 1, 2, 3, 4],r = [2, 3, 4, 5, 6]) == [True, True, True, True, True]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],l = [0, 4, 8, 12, 16],r = [3, 7, 11, 15, 19]) == [True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [2, 4, 6, 8, 9, 9, 9, 9, 9]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],l = [0, 3, 6, 9, 12, 15],r = [1, 4, 7, 10, 13, 16]) == [True, True, True, True, True, True]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],l = [0, 3, 6, 9],r = [2, 5, 8, 11]) == [True, True, True, True]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 10]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],l = [0, 2, 4, 6],r = [3, 5, 7, 9]) == [True, True, True, True]\n assert candidate(nums = [5, 3, 1, -1, -3, -5, -7, -9, -11, -13],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 11]) == [True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 5, 6, 8, 9, 10],l = [0, 2, 4, 1, 3],r = [1, 5, 7, 7, 6]) == [True, False, False, False, False]\n assert candidate(nums = [5, 8, 1, 3, 4, 9, 10],l = [0, 1, 2, 3],r = [2, 4, 5, 6]) == [False, False, False, False]\n assert candidate(nums = [5, 8, 3, 7, 10, 1, 2, 9, 4, 6],l = [0, 2, 5, 7],r = [3, 7, 9, 9]) == [False, False, False, False]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],l = [0, 1, 2, 3, 4],r = [2, 4, 6, 8, 9]) == [False, False, False, False, False]\n assert candidate(nums = [10, 5, 15, 20, 30, 25, 40, 35, 50, 45],l = [0, 1, 2, 3, 4, 5, 6],r = [3, 5, 7, 9, 9, 9, 9]) == [True, False, True, True, True, False, True]\n assert candidate(nums = [4, 3, 2, 1, 0, -1, -2, -3, -4],l = [0, 3, 4, 5],r = [8, 7, 6, 8]) == [True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = [0, 1, 2, 3, 4],r = [3, 4, 5, 6, 9]) == [True, True, True, True, True]\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],l = [0, 5, 10, 15, 20],r = [4, 9, 14, 19, 24]) == [False, True, True, True, True]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],l = [0, 1, 2, 3, 4, 5, 6],r = [1, 2, 3, 4, 5, 6, 9]) == [True, True, True, True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],l = [0, 1, 2, 3],r = [1, 2, 3, 8]) == [True, True, True, True]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 10]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50],l = [0, 1, 2, 3, 4, 5, 6],r = [3, 5, 7, 9, 9, 9, 9]) == [True, True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],l = [0, 2, 4, 6],r = [1, 3, 5, 9]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],l = [0, 5, 10, 15, 20],r = [4, 9, 14, 19, 24]) == [True, True, True, True, True]\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],l = [0, 5, 10],r = [4, 9, 13]) == [True, True, True]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],l = [0, 3, 6, 9, 12],r = [2, 5, 8, 11, 14]) == [True, True, True, True, True]\n assert candidate(nums = [5, 8, 11, 14, 17, 20, 23, 26, 29],l = [0, 3, 6],r = [2, 5, 8]) == [True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],l = [0, 5, 10],r = [4, 9, 14]) == [True, True, True]\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13],l = [0, 2, 4, 6],r = [1, 5, 7, 8]) == [True, False, False, False]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],l = [0, 5, 10, 15],r = [4, 9, 14, 19]) == [True, True, True, True]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61],l = [0, 3, 6, 9, 12, 15],r = [2, 5, 8, 11, 14, 17]) == [True, True, True, True, True, True]\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 10]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4],l = [0, 3, 6],r = [2, 5, 8]) == [True, False, False]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],l = [0, 1, 3, 5, 7],r = [2, 4, 6, 8, 9]) == [True, True, True, True, True]\n assert candidate(nums = [5, 3, 1, -1, -3, -5, -7, -9, -11, -13],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [9, 7, 5, 3, 1, 10, 8, 6, 4, 2],l = [0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9]) == [True, True, False, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 1, 2, 3],r = [2, 3, 4, 8]) == [True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9, 9]) == [True, True, True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 4, 6, 8],r = [3, 7, 9, 9]) == [True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700],l = [0, 1, 2, 3],r = [1, 2, 3, 4]) == [True, True, True, True]\n assert candidate(nums = [2, 10, 4, 5, 7, 6, 9],l = [0, 1, 2, 3, 4],r = [2, 3, 5, 5, 6]) == [False, False, True, True, False]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 1, 2, 3, 4],r = [1, 2, 3, 4, 9]) == [True, True, True, True, True]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],l = [0, 5, 2, 8],r = [4, 10, 6, 10]) == [True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],l = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],r = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == [True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],l = [0, 2, 4, 6],r = [3, 5, 7, 8]) == [True, True, True, True]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90],l = [0, 4, 8, 12, 16],r = [3, 7, 11, 15, 18]) == [True, True, True, True, False]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],l = [0, 1, 2, 3, 4, 5],r = [1, 2, 3, 4, 5, 8]) == [True, True, True, True, True, True]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35],l = [0, 2, 4],r = [2, 4, 6]) == [True, True, True]\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],l = [0, 2, 4, 6],r = [1, 3, 5, 9]) == [True, True, True, True]\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991],l = [0, 1, 2, 3, 4, 5, 6, 7],r = [1, 2, 3, 4, 5, 6, 7, 9]) == [True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 10]) == [True, True, True, True, True, True, True, True, False]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17],l = [0, 2, 4, 6],r = [2, 4, 6, 8]) == [True, True, True, True]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],l = [0, 5, 10, 15],r = [4, 9, 14, 19]) == [False, False, False, False]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],l = [0, 5, 7, 9],r = [4, 9, 10, 11]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],l = [0, 1, 2, 3, 4, 5, 6],r = [1, 2, 3, 4, 5, 6, 14]) == [True, True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],l = [0, 2, 4, 6],r = [1, 3, 5, 7]) == [True, True, True, True]\n assert candidate(nums = [10, 5, 15, 20, 25, 30, 35],l = [0, 2, 4],r = [4, 5, 6]) == [True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],l = [0, 2, 4, 6, 8],r = [1, 4, 7, 9, 9]) == [True, True, True, True, True]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],l = [0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9]) == [False, False, False, False, True]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25],l = [0, 1, 2, 3],r = [1, 2, 3, 6]) == [True, True, True, True]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],l = [0, 3, 6, 9, 12],r = [2, 5, 8, 11, 14]) == [True, True, True, True, True]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],l = [0, 1, 2, 3, 4, 5],r = [1, 2, 3, 4, 5, 9]) == [True, True, True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],l = [0, 2, 4, 6],r = [2, 4, 6, 8]) == [True, True, True, True]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],l = [0, 5, 10, 15],r = [4, 9, 14, 19]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],l = [0, 2, 4, 6],r = [1, 5, 7, 9]) == [True, True, True, True]\n assert candidate(nums = [5, 1, 3, 2, 4, 6, 8, 7, 9, 10],l = [0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9]) == [True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800],l = [0, 1, 2, 3, 4],r = [1, 3, 5, 7, 7]) == [True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],l = [0, 2, 4, 6, 8, 10],r = [1, 3, 5, 7, 9, 11]) == [True, True, True, True, True, True]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25],l = [0, 3, 5],r = [2, 5, 6]) == [True, True, True]\n assert candidate(nums = [-10, 0, 10, 20, 30, -20, -30],l = [0, 3, 4],r = [2, 5, 6]) == [True, False, False]\n assert candidate(nums = [1, 2, 3, 6, 5, 4, 9, 8, 7, 12, 11, 10],l = [0, 3, 6, 9],r = [2, 5, 8, 11]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 6, 5, 4, 7, 8, 9],l = [0, 1, 3],r = [2, 5, 8]) == [True, True, True]\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 10]) == [True, True, True, True, False]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],l = [0, 7, 12],r = [6, 11, 14]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],r = [1, 2, 3, 4, 5, 6, 7, 8, 9, 19]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21],l = [0, 1, 2, 3, 4],r = [1, 2, 3, 4, 6]) == [True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],l = [0, 3, 6, 9],r = [2, 5, 8, 10]) == [True, True, True, True]\n"}, "metadata": {"canonical_parameter_names": ["nums", "l", "r"], "leetcode_dataset_entry_point": "Solution().checkArithmeticSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def checkArithmeticSubarrays(self, nums: list[int], l: list[int], r: list[int]) -> list[bool]:", "container": "Solution", "callable": "checkArithmeticSubarrays", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "l", "type": "list[int]"}, {"name": "r", "type": "list[int]"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1631, "task_id": "path-with-minimum-effort", "difficulty": "Medium", "problem_description": "You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are situated in the top-left cell, (0, 0), and you hope to travel to the bottom-right cell, (rows-1, columns-1) (i.e., 0-indexed). You can move up, down, left, or right, and you wish to find a route that requires the minimum effort.\nA route's effort is the maximum absolute difference in heights between two consecutive cells of the route.\nReturn the minimum effort required to travel from the top-left cell to the bottom-right cell.\n \nExample 1:\n\n\nInput: heights = [[1,2,2],[3,8,2],[5,3,5]]\nOutput: 2\nExplanation: The route of [1,3,5,3,5] has a maximum absolute difference of 2 in consecutive cells.\nThis is better than the route of [1,2,2,2,5], where the maximum absolute difference is 3.\n\nExample 2:\n\n\nInput: heights = [[1,2,3],[3,8,4],[5,3,5]]\nOutput: 1\nExplanation: The route of [1,2,3,4,5] has a maximum absolute difference of 1 in consecutive cells, which is better than route [1,3,5,3,5].\n\nExample 3:\n\n\nInput: heights = [[1,2,1,1,1],[1,2,1,2,1],[1,2,1,2,1],[1,2,1,2,1],[1,1,1,2,1]]\nOutput: 0\nExplanation: This route does not require any effort.\n\n \nConstraints:\n\nrows == heights.length\ncolumns == heights[i].length\n1 <= rows, columns <= 100\n1 <= heights[i][j] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 8, 1, 10, 10, 7, 7, 2], [5, 10, 2, 8, 3, 9, 7, 9], [7, 6, 6, 8, 6, 6, 4, 4], [4, 9, 6, 10, 2, 1, 2, 7], [5, 10, 3, 7, 7, 5, 10, 10]]) == 4\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 8, 10, 10, 10, 7, 4, 2], [5, 1, 3, 1, 1, 3, 1, 9], [6, 4, 10, 6, 10, 9, 4, 6]]) == 5\n assert candidate(heights = [[7, 1, 4, 10, 10, 6, 9, 4, 10, 9, 7], [1, 2, 5, 9, 1, 5, 7, 5, 4, 10, 7], [6, 9, 8, 10, 9, 9, 9, 8, 10, 10, 8], [2, 7, 6, 8, 5, 5, 9, 9, 10, 10, 7], [5, 7, 6, 8, 3, 5, 6, 7, 1, 8, 6], [8, 8, 10, 10, 4, 3, 10, 7, 10, 10, 10], [9, 8, 9, 1, 2, 6, 3, 6, 8, 2, 2], [6, 9, 10, 9, 1, 6, 6, 6, 10, 8, 9], [4, 6, 10, 7, 9, 8, 3, 5, 6, 10, 2], [8, 1, 8, 5, 6, 5, 10, 8, 10, 10, 9]]) == 6\n assert candidate(heights = [[1, 10], [10, 1]]) == 9\n assert candidate(heights = [[1, 2, 1, 1, 1], [1, 2, 1, 2, 1], [1, 2, 1, 2, 1], [1, 2, 1, 2, 1], [1, 1, 1, 2, 1]]) == 0\n assert candidate(heights = [[1, 10, 6, 7, 9, 10, 4, 9]]) == 9\n assert candidate(heights = [[1, 2, 3], [3, 8, 4], [5, 3, 5]]) == 1\n assert candidate(heights = [[1, 1], [1, 1]]) == 0\n assert candidate(heights = [[1, 10, 6], [1, 3, 5], [4, 8, 2]]) == 3\n assert candidate(heights = [[1, 2, 2], [3, 8, 2], [5, 3, 5]]) == 2\n assert candidate(heights = [[1, 9, 20, 8, 15], [9, 10, 5, 11, 9], [8, 7, 2, 15, 12], [1, 11, 1, 1, 12], [20, 7, 11, 10, 2]]) == 8\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 8, 1, 10, 10, 7, 7, 2], [10, 1, 3, 1, 1, 6, 6, 9], [6, 10, 6, 3, 9, 4, 9, 7], [1, 10, 6, 1, 2, 3, 8, 1], [6, 6, 9, 2, 3, 8, 1, 7], [10, 4, 6, 10, 4, 3, 8, 1]]) == 6\n assert candidate(heights = [[5, 8, 4, 1], [9, 6, 6, 7], [1, 6, 1, 1], [4, 9, 9, 1]]) == 5\n assert candidate(heights = [[1, 2, 1, 3, 4, 5], [1, 2, 1, 2, 2, 2], [2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1], [3, 3, 3, 3, 3, 3]]) == 2\n assert candidate(heights = [[1, 2, 3, 4, 5], [4, 3, 2, 1, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16]]) == 5\n assert candidate(heights = [[4, 3, 4, 10, 5], [6, 7, 3, 9, 2], [3, 8, 1, 3, 4], [10, 6, 3, 2, 20], [6, 1, 1, 5, 4]]) == 3\n assert candidate(heights = [[1, 6, 5, 1, 3], [4, 7, 1, 4, 2], [6, 2, 5, 3, 1], [4, 1, 2, 1, 2], [2, 6, 3, 1, 1]]) == 3\n assert candidate(heights = [[1, 2, 100, 3, 4], [2, 3, 100, 4, 5], [3, 4, 100, 5, 6], [4, 5, 100, 6, 7], [5, 6, 100, 7, 8]]) == 94\n assert candidate(heights = [[5, 6, 2, 4, 6], [4, 8, 3, 3, 8], [8, 9, 4, 7, 10], [10, 9, 2, 3, 8], [5, 1, 5, 8, 1]]) == 7\n assert candidate(heights = [[4, 3, 2, 1], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == 4\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[1, 6, 3, 1, 2], [2, 2, 5, 1, 3], [6, 1, 1, 1, 1], [2, 1, 1, 2, 1], [3, 1, 1, 1, 1]]) == 1\n assert candidate(heights = [[1, 5, 9, 8, 11, 9, 4], [3, 9, 4, 8, 15, 9, 1], [2, 9, 2, 10, 15, 1, 6], [9, 10, 2, 10, 10, 2, 3], [10, 8, 2, 10, 7, 2, 8], [6, 8, 10, 10, 8, 10, 3], [1, 7, 5, 8, 3, 7, 1]]) == 5\n assert candidate(heights = [[1, 1, 1, 1, 1, 1], [1, 100000, 1, 100000, 1, 1], [1, 1, 1, 1, 1, 1], [1, 100000, 1, 100000, 1, 1], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[10, 1, 1, 1, 1], [1, 1, 1, 1, 10], [1, 1, 10, 1, 1], [1, 10, 1, 10, 1], [10, 1, 1, 1, 10]]) == 9\n assert candidate(heights = [[1, 6, 1, 1, 5], [1, 2, 9, 1, 5], [1, 3, 1, 8, 5], [1, 2, 1, 2, 5], [1, 2, 1, 2, 1]]) == 1\n assert candidate(heights = [[1000000, 999999, 999998, 999997], [999996, 999995, 999994, 999993], [999992, 999991, 999990, 999989], [999988, 999987, 999986, 999985]]) == 4\n assert candidate(heights = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [3, 5, 7, 9, 11, 13, 15], [4, 6, 8, 10, 12, 14, 16], [5, 7, 9, 11, 13, 15, 17]]) == 2\n assert candidate(heights = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 1\n assert candidate(heights = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 1\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]]) == 1\n assert candidate(heights = [[1, 10, 10, 10, 1], [10, 1, 1, 1, 1], [10, 10, 10, 1, 10], [10, 1, 1, 1, 10], [1, 1, 1, 10, 1]]) == 9\n assert candidate(heights = [[1, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 1]]) == 99\n assert candidate(heights = [[10, 15, 5], [20, 10, 5], [10, 10, 10]]) == 5\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 5, 4, 3, 1], [1, 2, 3, 4, 5, 6, 5, 4, 3, 1], [1, 2, 3, 4, 5, 5, 5, 4, 3, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1]]) == 0\n assert candidate(heights = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2, 1, 9], [7, 6, 5, 4, 3, 2, 1, 9, 8], [6, 5, 4, 3, 2, 1, 9, 8, 7], [5, 4, 3, 2, 1, 9, 8, 7, 6], [4, 3, 2, 1, 9, 8, 7, 6, 5], [3, 2, 1, 9, 8, 7, 6, 5, 4], [2, 1, 9, 8, 7, 6, 5, 4, 3], [1, 9, 8, 7, 6, 5, 4, 3, 2]]) == 8\n assert candidate(heights = [[1, 100, 1], [1, 100, 1], [1, 100, 1], [1, 100, 1], [1, 1, 1]]) == 0\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]]) == 1\n assert candidate(heights = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41]]) == 10\n assert candidate(heights = [[1, 6, 7, 5, 3, 1, 2, 6, 3, 10], [10, 1, 5, 8, 2, 10, 4, 10, 8, 7], [1, 9, 3, 5, 7, 4, 5, 10, 9, 8], [10, 8, 7, 5, 1, 10, 1, 10, 3, 7], [1, 10, 8, 1, 3, 8, 10, 7, 1, 10], [1, 5, 4, 4, 3, 2, 8, 3, 9, 9], [9, 6, 7, 4, 3, 2, 1, 8, 7, 6], [5, 2, 1, 3, 2, 3, 4, 5, 6, 7], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 9\n assert candidate(heights = [[1, 6, 3, 8, 5, 4, 2, 7, 9], [6, 3, 8, 5, 4, 2, 7, 9, 1], [3, 8, 5, 4, 2, 7, 9, 1, 6], [8, 5, 4, 2, 7, 9, 1, 6, 3], [5, 4, 2, 7, 9, 1, 6, 3, 8], [4, 2, 7, 9, 1, 6, 3, 8, 5], [2, 7, 9, 1, 6, 3, 8, 5, 4], [7, 9, 1, 6, 3, 8, 5, 4, 2], [9, 1, 6, 3, 8, 5, 4, 2, 7]]) == 8\n assert candidate(heights = [[5, 6, 7, 8, 9], [4, 3, 2, 1, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 5\n assert candidate(heights = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]]) == 3\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 5, 1, 3, 1, 3, 7, 6], [8, 1, 2, 1, 6, 8, 5, 1], [2, 1, 1, 8, 1, 5, 6, 1], [1, 1, 8, 1, 5, 9, 1, 4], [3, 1, 2, 5, 4, 8, 3, 1]]) == 4\n assert candidate(heights = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 5\n assert candidate(heights = [[1, 9, 9, 1], [9, 0, 0, 9], [9, 0, 0, 9], [1, 9, 9, 1]]) == 8\n assert candidate(heights = [[8, 5, 2], [6, 7, 3], [5, 1, 4], [6, 9, 8], [9, 3, 7]]) == 3\n assert candidate(heights = [[7, 9, 6, 9, 6], [6, 6, 8, 6, 6], [6, 9, 7, 9, 6], [9, 6, 9, 9, 6], [6, 9, 8, 9, 6], [6, 6, 9, 6, 6]]) == 2\n assert candidate(heights = [[5, 3, 1], [6, 4, 2], [7, 5, 3], [8, 6, 4], [9, 7, 5], [10, 8, 6]]) == 2\n assert candidate(heights = [[20, 21, 22, 23, 24, 25], [19, 18, 17, 16, 15, 14], [13, 12, 11, 10, 9, 8], [7, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 6]]) == 6\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]]) == 1\n assert candidate(heights = [[1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]]) == 1\n assert candidate(heights = [[1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[10, 8, 9, 10, 12], [13, 14, 15, 16, 17], [18, 19, 20, 21, 22], [23, 24, 25, 26, 27], [28, 29, 30, 31, 32]]) == 5\n assert candidate(heights = [[5, 8, 1, 3, 5, 6], [3, 5, 4, 5, 6, 6], [1, 3, 5, 8, 2, 2], [6, 6, 3, 3, 2, 6], [8, 5, 1, 1, 2, 5], [9, 5, 3, 3, 4, 1]]) == 3\n assert candidate(heights = [[10, 18, 16, 19], [6, 13, 8, 15], [7, 19, 18, 17], [4, 9, 9, 18], [3, 5, 12, 9]]) == 4\n assert candidate(heights = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9]]) == 2\n assert candidate(heights = [[1, 3, 1, 3, 1, 3], [2, 1, 2, 1, 2, 1], [3, 2, 3, 2, 3, 2], [1, 3, 1, 3, 1, 3], [2, 1, 2, 1, 2, 1]]) == 2\n assert candidate(heights = [[7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 1, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 1, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 1, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 1, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 1]]) == 6\n assert candidate(heights = [[10, 11, 12, 13, 14], [9, 8, 7, 6, 5], [4, 3, 2, 1, 100], [101, 102, 103, 104, 105], [106, 107, 108, 109, 110]]) == 95\n assert candidate(heights = [[5, 3, 1, 1, 1], [4, 2, 1, 1, 1], [4, 2, 1, 1, 1], [4, 2, 1, 1, 1], [4, 3, 2, 2, 1]]) == 1\n assert candidate(heights = [[1, 2, 2, 1, 2, 1, 2, 1], [2, 1, 1, 2, 1, 2, 1, 2], [1, 2, 2, 1, 2, 1, 2, 1], [2, 1, 1, 2, 1, 2, 1, 2], [1, 2, 2, 1, 2, 1, 2, 1]]) == 1\n assert candidate(heights = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27], [28, 29, 30]]) == 3\n assert candidate(heights = [[1, 2, 3, 4, 5], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7], [8, 7, 6, 5, 4], [9, 10, 11, 12, 13]]) == 1\n assert candidate(heights = [[1, 5, 5, 1], [5, 1, 5, 5], [1, 5, 1, 5], [5, 1, 5, 1]]) == 4\n assert candidate(heights = [[1, 6, 3, 7, 2, 8], [4, 5, 2, 6, 8, 5], [3, 9, 4, 10, 12, 1], [9, 3, 8, 11, 14, 6], [12, 11, 9, 13, 15, 7]]) == 5\n assert candidate(heights = [[1, 9, 3, 1, 2], [9, 9, 9, 1, 1], [1, 9, 9, 9, 1], [1, 1, 1, 1, 1], [2, 1, 1, 1, 3]]) == 8\n assert candidate(heights = [[5, 5, 5, 5, 5], [5, 4, 4, 4, 5], [5, 4, 3, 4, 5], [5, 4, 4, 4, 5], [5, 5, 5, 5, 5]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["heights"], "leetcode_dataset_entry_point": "Solution().minimumEffortPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumEffortPath(self, heights: list[list[int]]) -> int:", "container": "Solution", "callable": "minimumEffortPath", "parameters": [{"name": "heights", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1632, "task_id": "rank-transform-of-a-matrix", "difficulty": "Hard", "problem_description": "Given an m x n matrix, return a new matrix answer where answer[row][col] is the rank of matrix[row][col].\nThe rank is an integer that represents how large an element is compared to other elements. It is calculated using the following rules:\n\nThe rank is an integer starting from 1.\nIf two elements p and q are in the same row or column, then:\n\t\nIf p < q then rank(p) < rank(q)\nIf p == q then rank(p) == rank(q)\nIf p > q then rank(p) > rank(q)\n\n\nThe rank should be as small as possible.\n\nThe test cases are generated so that answer is unique under the given rules.\n \nExample 1:\n\n\nInput: matrix = [[1,2],[3,4]]\nOutput: [[1,2],[2,3]]\nExplanation:\nThe rank of matrix[0][0] is 1 because it is the smallest integer in its row and column.\nThe rank of matrix[0][1] is 2 because matrix[0][1] > matrix[0][0] and matrix[0][0] is rank 1.\nThe rank of matrix[1][0] is 2 because matrix[1][0] > matrix[0][0] and matrix[0][0] is rank 1.\nThe rank of matrix[1][1] is 3 because matrix[1][1] > matrix[0][1], matrix[1][1] > matrix[1][0], and both matrix[0][1] and matrix[1][0] are rank 2.\n\nExample 2:\n\n\nInput: matrix = [[7,7],[7,7]]\nOutput: [[1,1],[1,1]]\n\nExample 3:\n\n\nInput: matrix = [[20,-21,14],[-19,4,19],[22,-47,24],[-19,4,19]]\nOutput: [[4,2,3],[1,3,4],[5,1,6],[1,3,4]]\n\n \nConstraints:\n\nm == matrix.length\nn == matrix[i].length\n1 <= m, n <= 500\n-109 <= matrix[row][col] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[-1, -2], [-3, -4]]) == [[3, 2], [2, 1]]\n assert candidate(matrix = [[20, -21, 14], [-19, 4, 19], [22, -47, 24], [-19, 4, 19]]) == [[4, 2, 3], [1, 3, 4], [5, 1, 6], [1, 3, 4]]\n assert candidate(matrix = [[1, 2], [3, 4]]) == [[1, 2], [2, 3]]\n assert candidate(matrix = [[-3, -3], [1, -2], [2, -2], [1, 2]]) == [[1, 1], [3, 2], [4, 2], [3, 4]]\n assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[7, 7], [7, 7]]) == [[1, 1], [1, 1]]\n assert candidate(matrix = [[1, 2, 3], [3, 2, 1], [2, 1, 3]]) == [[1, 2, 3], [3, 2, 1], [2, 1, 3]]\n assert candidate(matrix = [[3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[-1, -1, -1], [-1, 0, -1], [-1, -1, -1]]) == [[1, 1, 1], [1, 2, 1], [1, 1, 1]]\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == [[5, 4, 3], [4, 3, 2], [3, 2, 1]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2], [3, 4, 5, 6, 1, 2], [2, 1, 6, 5, 4, 3]]) == [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2], [3, 4, 5, 6, 1, 2], [2, 1, 6, 5, 4, 3]]\n assert candidate(matrix = [[10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 20, 30]]) == [[1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3]]\n assert candidate(matrix = [[1, 0, -1], [0, 0, 0], [-1, 0, 1]]) == [[3, 2, 1], [2, 2, 2], [1, 2, 3]]\n assert candidate(matrix = [[-5, -4, -3, -2, -1], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[10, 9, 8, 7, 6], [9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2], [5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, 0, -1], [2, 1, 0, -1, -2], [1, 0, -1, -2, -3]]) == [[14, 13, 12, 11, 10], [13, 12, 11, 10, 9], [12, 11, 10, 9, 8], [11, 10, 9, 8, 7], [10, 9, 8, 7, 6], [9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2], [5, 4, 3, 2, 1]]\n assert candidate(matrix = [[-10, -10, -10], [-10, -10, -10], [-10, -10, -10]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[-1, 0, 1], [0, 0, 0], [1, 0, -1], [0, 1, 0]]) == [[1, 2, 3], [2, 2, 2], [3, 2, 1], [2, 3, 2]]\n assert candidate(matrix = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]\n assert candidate(matrix = [[10, 20, 30, 40, 50], [40, 50, 10, 20, 30], [30, 40, 50, 10, 20], [20, 30, 40, 50, 10], [50, 10, 20, 30, 40]]) == [[1, 2, 3, 4, 5], [4, 5, 1, 2, 3], [3, 4, 5, 1, 2], [2, 3, 4, 5, 1], [5, 1, 2, 3, 4]]\n assert candidate(matrix = [[9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [8, 8, 8, 8, 8, 8, 8, 8, 8, 8], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [8, 8, 8, 8, 8, 8, 8, 8, 8, 8], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(matrix = [[100, 90, 80], [70, 60, 50], [40, 30, 20], [10, 0, -10]]) == [[6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1]]\n assert candidate(matrix = [[10, 10, 10, 10], [10, 20, 20, 10], [10, 20, 30, 10], [10, 10, 10, 10]]) == [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 3, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8], [0, 3, 6, 9, 12], [0, 4, 8, 12, 16]]) == [[1, 1, 1, 1, 1], [1, 2, 3, 4, 5], [1, 3, 4, 5, 6], [1, 4, 5, 6, 7], [1, 5, 6, 7, 8]]\n assert candidate(matrix = [[7, -3, 10], [3, 7, 1], [-3, 10, 7], [10, 1, 3]]) == [[3, 1, 5], [2, 3, 1], [1, 5, 4], [4, 2, 3]]\n assert candidate(matrix = [[-10, -9, -8, -7, -6], [-9, -8, -7, -6, -5], [-8, -7, -6, -5, -4], [-7, -6, -5, -4, -3], [-6, -5, -4, -3, -2], [-5, -4, -3, -2, -1], [-4, -3, -2, -1, 0], [-3, -2, -1, 0, 1], [-2, -1, 0, 1, 2], [-1, 0, 1, 2, 3]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9], [6, 7, 8, 9, 10], [7, 8, 9, 10, 11], [8, 9, 10, 11, 12], [9, 10, 11, 12, 13], [10, 11, 12, 13, 14]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[-10, 5, 3, -5], [0, 0, 0, 0], [-10, 5, 3, -5], [10, -5, -3, 5]]) == [[1, 5, 4, 2], [3, 3, 3, 3], [1, 5, 4, 2], [5, 1, 2, 4]]\n assert candidate(matrix = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) == [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]\n assert candidate(matrix = [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [0, 2, 4, 6, 8]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 4, 5, 6, 7], [7, 6, 5, 4, 2], [1, 3, 4, 5, 6]]\n assert candidate(matrix = [[-10, 9, 6, 1, 6, 8, 3, -1, 5, 3, 0], [9, -10, -8, -10, 2, 3, 8, 10, 4, 5, -8], [6, -8, 10, -8, 10, 3, -8, 5, -9, 3, -10], [1, 10, -10, 3, -8, 8, 5, 10, -1, 2, -8], [6, -8, 10, -8, 10, 3, -8, 5, -9, 3, -10], [8, 3, -10, 8, 5, 10, -1, 2, -8, 1, 6], [-1, 5, -9, -1, 2, -8, 1, 6, 8, 3, 0], [5, 3, 8, -1, 6, 10, 3, -8, 1, 6, -8], [3, 0, 3, 5, -1, 6, 8, 3, 0, 3, 10], [3, -10, 3, -8, 10, -8, 5, 10, -1, 2, 6], [0, 3, 10, -8, 3, -10, 8, 5, -1, 2, 6]]) == [[1, 13, 11, 6, 11, 12, 8, 4, 10, 8, 5], [12, 1, 3, 1, 7, 8, 11, 14, 9, 10, 3], [10, 3, 14, 3, 14, 8, 3, 9, 2, 8, 1], [6, 14, 1, 8, 3, 12, 9, 14, 4, 7, 3], [10, 3, 14, 3, 14, 8, 3, 9, 2, 8, 1], [11, 8, 1, 11, 9, 13, 4, 6, 3, 5, 10], [4, 9, 2, 4, 7, 3, 6, 10, 11, 8, 5], [9, 8, 12, 4, 11, 13, 8, 3, 6, 11, 3], [8, 5, 8, 9, 4, 10, 11, 8, 5, 8, 12], [8, 1, 8, 3, 14, 3, 9, 14, 4, 7, 10], [5, 8, 14, 3, 8, 1, 11, 9, 4, 7, 10]]\n assert candidate(matrix = [[1, 2, 3], [3, 2, 1], [2, 1, 3]]) == [[1, 2, 3], [3, 2, 1], [2, 1, 3]]\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]\n assert candidate(matrix = [[1, 3, 1, 3, 1], [2, 4, 2, 4, 2], [1, 3, 1, 3, 1], [2, 4, 2, 4, 2]]) == [[1, 2, 1, 2, 1], [2, 3, 2, 3, 2], [1, 2, 1, 2, 1], [2, 3, 2, 3, 2]]\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [7, 8, 9, 10, 11], [10, 11, 12, 13, 14], [13, 14, 15, 16, 17]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10]]) == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[-10, 5, 0, 3], [6, -10, 8, 2], [1, 10, -5, 7], [4, -3, 9, -10]]) == [[1, 4, 2, 3], [4, 1, 5, 2], [2, 5, 1, 4], [3, 2, 6, 1]]\n assert candidate(matrix = [[-1, -1, -1, -1], [-1, 0, 0, -1], [-1, 0, 1, -1], [-1, -1, -1, 1]]) == [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 3, 1], [1, 1, 1, 2]]\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(matrix = [[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12], [5, 9, 13]]) == [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]\n assert candidate(matrix = [[1, 1000000000, -1000000000], [1000000000, 1, -1000000000], [-1000000000, -1000000000, 1]]) == [[2, 3, 1], [3, 2, 1], [1, 1, 2]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]\n assert candidate(matrix = [[-10, 0, 10], [0, 0, 0], [-10, 0, 10]]) == [[1, 2, 3], [2, 2, 2], [1, 2, 3]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 2, 4], [4, 2, 1, 5, 3], [2, 4, 6, 8, 10]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 2, 4], [4, 2, 1, 5, 3], [2, 4, 6, 7, 8]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[0, -1, 1000000000, 0], [1000000000, 0, -1, 0], [-1, 1000000000, 0, 0], [0, 0, 0, 0]]) == [[2, 1, 3, 2], [3, 2, 1, 2], [1, 3, 2, 2], [2, 2, 2, 2]]\n assert candidate(matrix = [[5, 1, 3, 2, 1], [5, 5, 4, 4, 5], [4, 2, 3, 3, 2], [5, 5, 5, 5, 5], [4, 4, 4, 4, 4]]) == [[5, 1, 3, 2, 1], [5, 5, 4, 4, 5], [4, 2, 3, 3, 2], [5, 5, 5, 5, 5], [4, 4, 4, 4, 4]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1], [1, 2, 3, 4, 5, 6]]) == [[1, 2, 3, 4, 5, 6], [5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1], [1, 2, 3, 4, 5, 6]]\n assert candidate(matrix = [[-1, -1, -1, -1, -1], [-1, 1, -1, 1, -1], [-1, -1, -1, -1, -1], [-1, 1, -1, 1, -1], [-1, -1, -1, -1, -1]]) == [[1, 1, 1, 1, 1], [1, 2, 1, 2, 1], [1, 1, 1, 1, 1], [1, 2, 1, 2, 1], [1, 1, 1, 1, 1]]\n assert candidate(matrix = [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0], [1, 3, 0, 2, 4], [2, 4, 1, 0, 3], [3, 0, 4, 1, 2]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 4, 1, 3, 5], [3, 5, 2, 1, 4], [4, 1, 5, 2, 3]]\n assert candidate(matrix = [[-1000000000, 1000000000], [1000000000, -1000000000]]) == [[1, 2], [2, 1]]\n assert candidate(matrix = [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]]) == [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]]\n assert candidate(matrix = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == [[1, 1, 1], [1, 2, 1], [1, 1, 1]]\n assert candidate(matrix = [[5, 3, 1], [-1, 7, 6], [8, 4, 2]]) == [[3, 2, 1], [1, 4, 3], [4, 3, 2]]\n assert candidate(matrix = [[5, 1, 9, 11], [2, 4, 6, 8], [13, 3, 7, 15], [16, 14, 12, 10]]) == [[2, 1, 6, 7], [1, 3, 4, 5], [6, 2, 5, 8], [9, 8, 7, 6]]\n assert candidate(matrix = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[1, 1, 1], [1, 2, 2], [1, 2, 3]]) == [[1, 1, 1], [1, 2, 2], [1, 2, 3]]\n assert candidate(matrix = [[-10, -10, -10, -10], [-10, 0, 0, -10], [-10, 0, 0, -10], [-10, -10, -10, -10]]) == [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 2, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]) == [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]\n assert candidate(matrix = [[5, -4, 5, -9, -1], [9, -1, 9, 5, -5], [5, -5, 5, 9, 9], [9, 9, 9, 5, -1], [5, -4, 5, -9, -1]]) == [[4, 2, 4, 1, 3], [5, 3, 5, 4, 1], [4, 1, 4, 5, 5], [5, 5, 5, 4, 3], [4, 2, 4, 1, 3]]\n assert candidate(matrix = [[-10, 20, 30, -40], [-10, 20, 30, -40], [-10, 20, 30, -40], [-10, 20, 30, -40]]) == [[2, 3, 4, 1], [2, 3, 4, 1], [2, 3, 4, 1], [2, 3, 4, 1]]\n assert candidate(matrix = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 3, 4, 1], [3, 4, 1, 2]]) == [[1, 2, 3, 4], [4, 3, 2, 1], [2, 3, 4, 1], [3, 4, 1, 2]]\n assert candidate(matrix = [[5, 1, 9, 11], [2, 4, 8, 10], [13, 3, 6, 7], [15, 14, 12, 16]]) == [[2, 1, 5, 6], [1, 3, 4, 5], [5, 2, 3, 4], [8, 7, 6, 9]]\n assert candidate(matrix = [[-1, -2, -3], [-2, -3, -4], [-3, -4, -5]]) == [[5, 4, 3], [4, 3, 2], [3, 2, 1]]\n assert candidate(matrix = [[10, 20, 30, 40], [40, 30, 20, 10], [10, 20, 30, 40], [40, 30, 20, 10]]) == [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]]\n assert candidate(matrix = [[-1, -2, -3, -4, -5], [-6, -7, -8, -9, -10], [-11, -12, -13, -14, -15], [-16, -17, -18, -19, -20], [-21, -22, -23, -24, -25]]) == [[9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2], [5, 4, 3, 2, 1]]\n assert candidate(matrix = [[-10, 100, 0], [5, -5, 5], [10, 10, 10], [0, 0, 0]]) == [[1, 5, 2], [3, 1, 3], [4, 4, 4], [2, 2, 2]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [2, 1, 4, 3, 5], [3, 4, 1, 2, 5], [4, 3, 2, 1, 5], [5, 5, 5, 5, 5]]) == [[1, 2, 3, 4, 5], [2, 1, 4, 3, 5], [3, 4, 1, 2, 5], [4, 3, 2, 1, 5], [5, 5, 5, 5, 5]]\n assert candidate(matrix = [[100, 200, 300, 400, 500], [500, 400, 300, 200, 100], [200, 300, 400, 500, 100], [400, 500, 100, 200, 300], [300, 100, 200, 300, 400]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [4, 5, 1, 2, 3], [3, 1, 2, 3, 4]]\n assert candidate(matrix = [[-10, 0, 10], [20, 30, 40], [50, 60, 70]]) == [[1, 2, 3], [2, 3, 4], [3, 4, 5]]\n assert candidate(matrix = [[-5, -5, -5], [-5, -5, -5], [-5, -5, -5], [-5, -5, -5]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2]]) == [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2]]\n assert candidate(matrix = [[-10, -20, -30], [-5, -15, -25], [-1, -11, -21]]) == [[3, 2, 1], [4, 3, 2], [5, 4, 3]]\n assert candidate(matrix = [[1], [2], [3], [4], [5]]) == [[1], [2], [3], [4], [5]]\n assert candidate(matrix = [[1, 1, 2], [2, 2, 1], [3, 3, 2]]) == [[1, 1, 2], [2, 2, 1], [3, 3, 2]]\n assert candidate(matrix = [[1, 3, 5], [2, 3, 6], [4, 6, 9]]) == [[1, 3, 4], [2, 3, 5], [3, 4, 6]]\n assert candidate(matrix = [[5, 3, 1, 4, 2], [10, 8, 6, 9, 7], [15, 13, 11, 14, 12], [20, 18, 16, 19, 17], [25, 23, 21, 24, 22]]) == [[5, 3, 1, 4, 2], [6, 4, 2, 5, 3], [7, 5, 3, 6, 4], [8, 6, 4, 7, 5], [9, 7, 5, 8, 6]]\n assert candidate(matrix = [[5, 1, 9, 5, 5], [1, 5, 5, 9, 1], [9, 5, 1, 1, 5], [5, 9, 5, 5, 1], [5, 5, 1, 5, 9]]) == [[2, 1, 3, 2, 2], [1, 2, 2, 3, 1], [3, 2, 1, 1, 2], [2, 3, 2, 2, 1], [2, 2, 1, 2, 3]]\n assert candidate(matrix = [[1000000000, 999999999, 999999998, 999999997], [999999996, 999999995, 999999994, 999999993], [999999992, 999999991, 999999990, 999999989], [999999988, 999999987, 999999986, 999999985]]) == [[7, 6, 5, 4], [6, 5, 4, 3], [5, 4, 3, 2], [4, 3, 2, 1]]\n assert candidate(matrix = [[-5, -4, -3, -2, -1], [-4, -3, -2, -1, 0], [-3, -2, -1, 0, 1], [-2, -1, 0, 1, 2], [-1, 0, 1, 2, 3]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[5, 1, 9, 1, 5, 9], [1, 5, 5, 1, 5, 1], [9, 5, 1, 9, 1, 9]]) == [[2, 1, 3, 1, 2, 3], [1, 2, 2, 1, 2, 1], [3, 2, 1, 3, 1, 3]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1], [3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3], [5, 6, 1, 2, 3, 4], [6, 1, 2, 3, 4, 5]]) == [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1], [3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3], [5, 6, 1, 2, 3, 4], [6, 1, 2, 3, 4, 5]]\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]\n assert candidate(matrix = [[-1, -10, 100, 50, 25], [-1, -20, 99, 49, 24], [0, 0, 0, 0, 0], [1, 2, 3, 4, 5], [10, 20, 30, 40, 50]]) == [[3, 2, 13, 12, 11], [3, 1, 12, 11, 10], [4, 4, 4, 4, 4], [5, 6, 7, 8, 9], [6, 7, 8, 9, 12]]\n assert candidate(matrix = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]\n assert candidate(matrix = [[9, 7, 5], [6, 8, 4], [3, 1, 2]]) == [[6, 5, 4], [4, 6, 3], [3, 1, 2]]\n assert candidate(matrix = [[-1, 0, 0, 1, 2], [-1, -1, 1, 1, 2], [1, 1, 1, 1, 1], [-1, 0, 0, 1, 1], [-1, -1, 1, 1, 1]]) == [[1, 2, 2, 3, 4], [1, 1, 3, 3, 4], [3, 3, 3, 3, 3], [1, 2, 2, 3, 3], [1, 1, 3, 3, 3]]\n assert candidate(matrix = [[0, 0, 0, 0], [0, 1, 1, 1], [0, 1, 2, 2], [0, 1, 2, 3]]) == [[1, 1, 1, 1], [1, 2, 2, 2], [1, 2, 3, 3], [1, 2, 3, 4]]\n assert candidate(matrix = [[10, 20, 30], [20, 30, 10], [30, 10, 20]]) == [[1, 2, 3], [2, 3, 1], [3, 1, 2]]\n assert candidate(matrix = [[5, 1, 3, 1], [2, 4, 6, 4], [7, 8, 9, 8], [1, 3, 5, 3]]) == [[3, 1, 2, 1], [2, 3, 4, 3], [4, 5, 6, 5], [1, 2, 3, 2]]\n assert candidate(matrix = [[-1, -2, -3], [-3, -1, -2], [-2, -3, -1]]) == [[3, 2, 1], [1, 3, 2], [2, 1, 3]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [4, 5, 1, 2, 3], [3, 1, 2, 4, 5]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [4, 5, 1, 2, 3], [3, 1, 2, 4, 5]]\n assert candidate(matrix = [[1000000000, -1000000000, 1000000000, -1000000000], [-1000000000, 1000000000, -1000000000, 1000000000], [1000000000, -1000000000, 1000000000, -1000000000], [-1000000000, 1000000000, -1000000000, 1000000000]]) == [[2, 1, 2, 1], [1, 2, 1, 2], [2, 1, 2, 1], [1, 2, 1, 2]]\n assert candidate(matrix = [[-5, -5, -5, -5], [-5, -5, -5, -5], [-5, -5, -5, -5], [-5, -5, -5, -5]]) == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [1, 10, 9, 8, 7, 6, 5, 4, 3, 2], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [4, 5, 6, 7, 8, 9, 10, 1, 2, 3], [5, 6, 7, 8, 9, 10, 1, 2, 3, 4], [6, 7, 8, 9, 10, 1, 2, 3, 4, 5], [7, 8, 9, 10, 1, 2, 3, 4, 5, 6], [8, 9, 10, 1, 2, 3, 4, 5, 6, 7]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [1, 10, 9, 8, 7, 6, 5, 4, 3, 2], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [4, 5, 6, 7, 8, 9, 10, 1, 2, 3], [5, 6, 7, 8, 9, 10, 1, 2, 3, 4], [6, 7, 8, 9, 10, 1, 2, 3, 4, 5], [7, 8, 9, 10, 1, 2, 3, 4, 5, 6], [8, 9, 10, 1, 2, 3, 4, 5, 6, 7]]\n assert candidate(matrix = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]]) == [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]]\n"}, "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().matrixRankTransform", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def matrixRankTransform(self, matrix: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "matrixRankTransform", "parameters": [{"name": "matrix", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1636, "task_id": "sort-array-by-increasing-frequency", "difficulty": "Easy", "problem_description": "Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, sort them in decreasing order.\nReturn the sorted array.\n \nExample 1:\n\nInput: nums = [1,1,2,2,2,3]\nOutput: [3,1,1,2,2,2]\nExplanation: '3' has a frequency of 1, '1' has a frequency of 2, and '2' has a frequency of 3.\n\nExample 2:\n\nInput: nums = [2,3,1,3,2]\nOutput: [1,3,3,2,2]\nExplanation: '2' and '3' both have a frequency of 2, so they are sorted in decreasing order.\n\nExample 3:\n\nInput: nums = [-1,1,-6,4,5,-6,1,4,1]\nOutput: [5,-1,4,4,-6,-6,1,1,1]\n \nConstraints:\n\n1 <= nums.length <= 100\n-100 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 2, 2, 2, 3]) == [3, 1, 1, 2, 2, 2]\n assert candidate(nums = [10, 10, 20, 20, 30]) == [30, 20, 20, 10, 10]\n assert candidate(nums = [7, 7, 7, 6, 6, 5, 5, 5, 5]) == [6, 6, 7, 7, 7, 5, 5, 5, 5]\n assert candidate(nums = [5, 5, 4, 6, 4, 4, 4]) == [6, 5, 5, 4, 4, 4, 4]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]\n assert candidate(nums = [7, 7, 7, 8, 8, 9]) == [9, 8, 8, 7, 7, 7]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [-1, -1, -1, -2, -2, -3]) == [-3, -2, -2, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1]) == [1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [2, 3, 1, 3, 2]) == [1, 3, 3, 2, 2]\n assert candidate(nums = [100, -100, 100, -100, 100]) == [-100, -100, 100, 100, 100]\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == [3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0]\n assert candidate(nums = [100, -100, 0, 0, 0, 0]) == [100, -100, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 4, 4, 3, 3, 3, 3]) == [4, 4, 5, 5, 5, 3, 3, 3, 3]\n assert candidate(nums = [-100, 100]) == [100, -100]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]\n assert candidate(nums = [5, 5, 4, 4, 4, 6, 6, 6, 6]) == [5, 5, 4, 4, 4, 6, 6, 6, 6]\n assert candidate(nums = [-5, -5, -4, -4, -3, -3, -2, -2, -1, -1]) == [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5]\n assert candidate(nums = [100, -100, 0, 0, 0]) == [100, -100, 0, 0, 0]\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 2, 2]) == [1, 1, 0, 0, 0, 2, 2, 2, 2]\n assert candidate(nums = [-1, 1, -6, 4, 5, -6, 1, 4, 1]) == [5, -1, 4, 4, -6, -6, 1, 1, 1]\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [4, 3, 2, 2, 1, 1, 1, 5, 5, 5, 5, 0, 0, 0, 0, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 10, 10, 10, 10, 10]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9]) == [8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5]) == [9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == [12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == [0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, 12, 12, -12, -12, -12]) == [100, 50, 25, -25, -50, -100, 12, 12, 12, -12, -12, -12]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [-1, -1, -1, -2, -2, -3, -3, -3, -3, -4, -4, -4, -4, -4, -5, -5, -5, -5, -5, -5]) == [-2, -2, -1, -1, -1, -3, -3, -3, -3, -4, -4, -4, -4, -4, -5, -5, -5, -5, -5, -5]\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99]) == [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == [10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 9]) == [8, 8, 7, 7, 7, 9, 9, 9, 9]\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8]) == [2, 3, 3, 1, 1, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11, 10, 9, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5]\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 10, 10]) == [8, 8, 9, 9, 9, 7, 7, 7, 7, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [2, 2, 3, 3, 3, 1, 1, 1, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [-5, -5, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3]) == [3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -5, -5]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10]) == [8, 8, 7, 7, 7, 9, 9, 9, 9, 10, 10, 10, 10, 10]\n assert candidate(nums = [-50, -50, -50, -50, -50, -49, -49, -49, -48, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -48, -48, -49, -49, -49, -50, -50, -50, -50, -50]\n assert candidate(nums = [7, 3, 7, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [7, 7, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6, 3, -3, 1, -1, 0]) == [100, 50, 25, 12, 6, 3, 1, 0, -1, -3, -6, -12, -25, -50, -100]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1]\n assert candidate(nums = [15, 15, 15, 15, 20, 20, 20, 25, 25, 30, 30, 30, 30, 30, 35, 35]) == [35, 35, 25, 25, 20, 20, 20, 15, 15, 15, 15, 30, 30, 30, 30, 30]\n assert candidate(nums = [7, 7, 7, 7, 6, 6, 6, 5, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == [4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, 5, 5, 6, 6, 6, 7, 7, 7, 7]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8, -8, -9, -9, -10, -10, -10]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]\n assert candidate(nums = [-5, -5, -5, -5, -4, -4, -3, -3, -2, -1, 0, 1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5]) == [2, 1, 0, -1, -2, 3, 3, -3, -3, -4, -4, 4, 4, 4, 5, 5, 5, 5, -5, -5, -5, -5]\n assert candidate(nums = [-10, -10, -10, -9, -9, -8, -8, -7, -6, -6, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -7, -8, -8, -9, -9, -6, -6, -6, -10, -10, -10]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == [2, 2, 1, 1, 1, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [100, -100, 100, 99, 99, 98, 98, 98, 97, 97, 97, 97]) == [-100, 100, 100, 99, 99, 98, 98, 98, 97, 97, 97, 97]\n assert candidate(nums = [5, 3, 8, 5, 8, 3, 9, 5, 3, 8, 8, 8, 8, 3, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [5, 5, 5, 3, 3, 3, 3, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5]) == [4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3]) == [3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [7, 7, 7, 3, 3, 5, 5, 5, 2, 2, 1]) == [1, 3, 3, 2, 2, 7, 7, 7, 5, 5, 5]\n assert candidate(nums = [0, -1, 0, -1, 0, -1, 1, 1, 1, 1, 1]) == [0, 0, 0, -1, -1, -1, 1, 1, 1, 1, 1]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100, 100, 90, 90, 80, 80, 70, 70, 60, 60, 50, 50, 40, 40, 30, 30, 20, 20, 10]) == [10, 10, 100, 100, 100, 90, 90, 90, 80, 80, 80, 70, 70, 70, 60, 60, 60, 50, 50, 50, 40, 40, 40, 30, 30, 30, 20, 20, 20]\n assert candidate(nums = [-1, -1, -1, -2, -2, -3, -3, -4, -4, -4, -5, -5, -5, -5, -5, -6, -6, -6, -6, -6, -6]) == [-2, -2, -3, -3, -1, -1, -1, -4, -4, -4, -5, -5, -5, -5, -5, -6, -6, -6, -6, -6, -6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == [50, 50, 50, 50, 50, 50, 40, 40, 40, 40, 40, 40, 30, 30, 30, 30, 30, 30, 20, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [10, 10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40, 50]) == [50, 10, 10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 6, 7]) == [7, 6, 5, 4, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100]) == [100, 100, 100, 100, 100, 100, 100, 100, -100, -100, -100, -100, -100, -100, -100, -100]\n assert candidate(nums = [100, -100, 100, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-100, 100, 100, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 0, 0, 0, 0, 0]) == [100, 50, 25, -25, -50, -100, 0, 0, 0, 0, 0]\n assert candidate(nums = [9, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4]) == [9, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1, 0, -1, -2, -2, -3, -3, -3, -4, -4, -4, -4, -5, -5, -5, -5, -5]) == [1, 0, -1, 2, 2, -2, -2, 3, 3, 3, -3, -3, -3, 4, 4, 4, 4, -4, -4, -4, -4, 5, 5, 5, 5, 5, -5, -5, -5, -5, -5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 10, 10, 10, 10]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 75, -75, 0, 0, 0, 0, 0, 0]) == [100, 75, 50, 25, -25, -50, -75, -100, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == [2, 2, 1, 1, 1, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n assert candidate(nums = [10, 10, 10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60]) == [20, 20, 30, 30, 30, 10, 10, 10, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -5, -5, -5, -5]) == [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -5, -5, -5, -5]\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10]) == [50, 50, 50, 50, 40, 40, 40, 40, 30, 30, 30, 30, 20, 20, 20, 20, 10, 10, 10, 10, 10]\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == [50, 50, 49, 49, 48, 48, 47, 47, 46, 46, 45, 45, 44, 44, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, 38, 38, 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [99, 99, 99, 99, 98, 98, 98, 97, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75]) == [96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 97, 97, 98, 98, 98, 99, 99, 99, 99]\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -48, -49, -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69, -70, -71, -72, -73, -74, -75, -76, -77, -78, -79, -80, -81, -82, -83, -84, -85, -86, -87, -88, -89, -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, -100]\n assert candidate(nums = [-5, -5, -5, -5, -5, -10, -10, -10, 0, 0, 0, 0, 0, 0, 0]) == [-10, -10, -10, -5, -5, -5, -5, -5, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == [2, 2, 3, 3, 3, 1, 1, 1, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8, -8, -9, -9, -10, -10, -11, -11, -12, -12, -13, -13, -14, -14, -15, -15]) == [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8, -8, -9, -9, -10, -10, -11, -11, -12, -12, -13, -13, -14, -14, -15, -15]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [0, 0, 0, 0, 0, -1, -1, -1, 1, 1, 1, 1, 1]) == [-1, -1, -1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 40, 40, 40, 40, 40, 40, 30, 30, 30, 20, 20, 10]) == [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [0, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, -1, -1]) == [1, 0, 2, 2, -1, -1, 3, 3, 3, 4, 4, 4, 4]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().frequencySort", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def frequencySort(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "frequencySort", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1637, "task_id": "widest-vertical-area-between-two-points-containing-no-points", "difficulty": "Easy", "problem_description": "Given n points on a 2D plane where points[i] = [xi, yi], Return the widest vertical area between two points such that no points are inside the area.\nA vertical area is an area of fixed-width extending infinitely along the y-axis (i.e., infinite height). The widest vertical area is the one with the maximum width.\nNote that points on the edge of a vertical area are not considered included in the area.\n \nExample 1:\n​\n\nInput: points = [[8,7],[9,9],[7,4],[9,7]]\nOutput: 1\nExplanation: Both the red and the blue area are optimal.\n\nExample 2:\n\nInput: points = [[3,1],[9,0],[1,0],[1,4],[5,3],[8,8]]\nOutput: 3\n\n \nConstraints:\n\nn == points.length\n2 <= n <= 105\npoints[i].length == 2\n0 <= xi, yi <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 1\n assert candidate(points = [[1, 10], [3, 3], [5, 5], [7, 7], [9, 9]]) == 2\n assert candidate(points = [[5, 1], [4, 1], [3, 1], [2, 1], [1, 1]]) == 1\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]]) == 10\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7]]) == 2\n assert candidate(points = [[3, 1], [9, 0], [1, 0], [1, 4], [5, 3], [8, 8]]) == 3\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 1\n assert candidate(points = [[0, 0], [1000000000, 1000000000]]) == 1000000000\n assert candidate(points = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600]]) == 100\n assert candidate(points = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3]]) == 1\n assert candidate(points = [[8, 7], [9, 9], [7, 4], [9, 7]]) == 1\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == 10\n assert candidate(points = [[5, 5], [15, 5], [25, 5], [35, 5], [45, 5]]) == 10\n assert candidate(points = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14]]) == 3\n assert candidate(points = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == 1\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40]]) == 10\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]]) == 100\n assert candidate(points = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512]]) == 256\n assert candidate(points = [[5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == 1\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 999999991\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 110]]) == 1\n assert candidate(points = [[2, 5], [2, 8], [3, 6], [5, 9], [7, 10], [9, 3], [11, 7], [13, 4]]) == 2\n assert candidate(points = [[1, 10], [10, 1], [100, 10], [1000, 1], [10000, 10], [100000, 1], [1000000, 10], [10000000, 1], [100000000, 10], [1000000000, 1]]) == 900000000\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [10, 10], [20, 20], [30, 30], [40, 40]]) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 1\n assert candidate(points = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19], [22, 21]]) == 2\n assert candidate(points = [[1, 999999999], [2, 999999998], [3, 999999997], [4, 999999996], [5, 999999995], [6, 999999994], [7, 999999993], [8, 999999992], [9, 999999991], [10, 999999990]]) == 1\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 1\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [11, 1], [12, 2], [13, 3], [14, 4], [15, 5], [16, 6], [17, 7], [18, 8], [19, 9]]) == 1\n assert candidate(points = [[1, 5], [3, 5], [5, 5], [7, 5], [9, 5], [11, 5], [13, 5], [15, 5], [17, 5], [19, 5], [21, 5], [23, 5], [25, 5], [27, 5], [29, 5], [31, 5], [33, 5], [35, 5]]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 1\n assert candidate(points = [[5, 2], [4, 3], [3, 4], [2, 5], [1, 6], [0, 7], [10, 8], [9, 9], [8, 10], [7, 11]]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [5, 5], [8, 8], [13, 13], [21, 21], [34, 34], [55, 55], [89, 89], [144, 144], [233, 233], [377, 377]]) == 144\n assert candidate(points = [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]]) == 2\n assert candidate(points = [[500000000, 500000000], [600000000, 500000000], [700000000, 500000000], [800000000, 500000000], [900000000, 500000000], [1000000000, 500000000], [1100000000, 500000000], [1200000000, 500000000], [1300000000, 500000000], [1400000000, 500000000]]) == 100000000\n assert candidate(points = [[1, 1], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [10, 11], [11, 10], [12, 13], [13, 12], [14, 15], [15, 14]]) == 1\n assert candidate(points = [[100, 1], [200, 1], [300, 1], [400, 1], [500, 1], [600, 1], [700, 1], [800, 1], [900, 1], [1000, 1]]) == 100\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600]]) == 100\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19], [21, 21], [23, 23], [25, 25], [27, 27], [29, 29], [31, 31]]) == 2\n assert candidate(points = [[1, 1000000000], [1000000000, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 999999991\n assert candidate(points = [[1000000000, 1], [2000000000, 2], [3000000000, 3], [4000000000, 4], [5000000000, 5]]) == 1000000000\n assert candidate(points = [[1, 1], [10, 10], [100, 100], [1000, 1000], [10000, 10000], [100000, 100000], [1000000, 1000000], [10000000, 10000000], [100000000, 100000000], [1000000000, 1000000000], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 900000000\n assert candidate(points = [[1000000000, 10], [500000000, 20], [250000000, 30], [125000000, 40], [62500000, 50]]) == 500000000\n assert candidate(points = [[10, 10], [20, 25], [30, 30], [40, 45], [50, 50], [60, 65], [70, 70], [80, 85], [90, 90], [100, 105]]) == 10\n assert candidate(points = [[100, 1], [200, 1], [300, 1], [400, 1], [500, 1], [600, 1], [700, 1], [800, 1], [900, 1], [1000, 1]]) == 100\n assert candidate(points = [[10, 10], [100, 20], [1000, 30], [10000, 40], [100000, 50], [1000000, 60], [10000000, 70], [100000000, 80], [1000000000, 90]]) == 900000000\n assert candidate(points = [[5, 5], [10, 5], [15, 5], [20, 5], [25, 5], [30, 5], [35, 5], [40, 5], [45, 5], [50, 5]]) == 5\n assert candidate(points = [[1, 1], [500000000, 1], [1000000000, 1], [1500000000, 1], [2000000000, 1], [2500000000, 1], [3000000000, 1], [3500000000, 1], [4000000000, 1], [4500000000, 1], [5000000000, 1], [5500000000, 1], [6000000000, 1], [6500000000, 1], [7000000000, 1], [7500000000, 1], [8000000000, 1], [8500000000, 1], [9000000000, 1], [9500000000, 1], [10000000000, 1]]) == 500000000\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19], [21, 21], [23, 23], [25, 25]]) == 2\n assert candidate(points = [[1, 1], [1000000000, 1], [500000000, 1], [750000000, 1], [250000000, 1], [125000000, 1], [375000000, 1], [625000000, 1], [875000000, 1]]) == 125000000\n assert candidate(points = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10], [110, 10], [120, 10], [130, 10], [140, 10], [150, 10], [160, 10], [170, 10], [180, 10], [190, 10], [200, 10], [210, 10], [220, 10], [230, 10], [240, 10], [250, 10], [260, 10], [270, 10], [280, 10], [290, 10], [300, 10], [310, 10], [320, 10], [330, 10], [340, 10], [350, 10], [360, 10], [370, 10], [380, 10], [390, 10], [400, 10], [410, 10], [420, 10], [430, 10], [440, 10], [450, 10], [460, 10], [470, 10], [480, 10], [490, 10], [500, 10]]) == 10\n assert candidate(points = [[1, 2], [4, 6], [7, 8], [10, 5], [13, 9], [16, 3], [19, 7]]) == 3\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]]) == 2\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]]) == 1\n assert candidate(points = [[1000000000, 1000000000], [999999999, 999999999], [999999998, 1000000000], [999999997, 999999999], [999999996, 1000000000], [999999995, 999999999], [999999994, 1000000000]]) == 1\n assert candidate(points = [[1, 10], [100, 100], [200, 100], [300, 100], [400, 100], [500, 100]]) == 100\n assert candidate(points = [[10, 20], [20, 10], [30, 30], [40, 20], [50, 10], [60, 30], [70, 20], [80, 10], [90, 30], [100, 20]]) == 10\n assert candidate(points = [[1, 2], [3, 4], [6, 5], [7, 8], [10, 9], [15, 1], [20, 6], [25, 3]]) == 5\n assert candidate(points = [[10, 1], [15, 2], [20, 3], [25, 4], [30, 5], [35, 6], [40, 7], [45, 8], [50, 9], [55, 10], [60, 11], [65, 12], [70, 13], [75, 14], [80, 15]]) == 5\n assert candidate(points = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110], [110, 120], [120, 130], [130, 140], [140, 150], [150, 160], [160, 170], [170, 180], [180, 190], [190, 200], [200, 210], [210, 220], [220, 230], [230, 240], [240, 250], [250, 260], [260, 270], [270, 280], [280, 290], [290, 300]]) == 10\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1]]) == 1\n assert candidate(points = [[100, 100], [101, 101], [102, 102], [200, 200], [201, 201], [300, 300], [301, 301]]) == 99\n assert candidate(points = [[1, 1], [10, 10], [100, 100], [1000, 1000], [10000, 10000], [100000, 100000], [1000000, 1000000], [10000000, 10000000], [100000000, 100000000]]) == 90000000\n assert candidate(points = [[10, 15], [25, 20], [5, 5], [35, 30], [40, 40], [50, 5], [60, 60], [75, 80], [80, 85], [90, 90]]) == 15\n assert candidate(points = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512], [1024, 1024]]) == 512\n assert candidate(points = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [2, 3]]) == 1\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [2, 2], [999999999, 999999999], [3, 3], [999999998, 999999998]]) == 999999995\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [750000000, 750000000]]) == 250000000\n assert candidate(points = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]]) == 1\n assert candidate(points = [[1, 9], [3, 8], [5, 7], [7, 6], [9, 5], [11, 4], [13, 3], [15, 2], [17, 1], [19, 0], [21, 9], [23, 8], [25, 7], [27, 6], [29, 5], [31, 4], [33, 3], [35, 2], [37, 1], [39, 0]]) == 2\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [11, 9], [12, 8], [13, 7], [14, 6], [15, 5], [16, 4], [17, 3], [18, 2], [19, 1], [20, 0]]) == 1\n assert candidate(points = [[5, 5], [5, 1], [5, 9], [10, 10], [10, 5], [10, 0], [15, 15], [15, 10], [15, 0]]) == 5\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 2\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]]) == 0\n assert candidate(points = [[100, 200], [200, 200], [300, 200], [400, 200], [500, 200], [600, 200], [700, 200], [800, 200], [900, 200], [1000, 200]]) == 100\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]]) == 50\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [10, 40], [11, 50], [20, 60], [21, 70]]) == 9\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]]) == 1\n assert candidate(points = [[1000000, 1], [2000000, 2], [3000000, 3], [4000000, 4], [5000000, 5], [6000000, 6], [7000000, 7], [8000000, 8], [9000000, 9], [10000000, 10]]) == 1000000\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [750000000, 750000000], [125000000, 125000000], [625000000, 625000000], [375000000, 375000000], [875000000, 875000000]]) == 125000000\n assert candidate(points = [[10, 20], [30, 20], [20, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]]) == 10\n assert candidate(points = [[500000000, 1], [500000001, 2], [500000002, 3], [500000003, 4], [500000004, 5]]) == 1\n assert candidate(points = [[1000000000, 0], [1000000000, 1000000000], [0, 0], [0, 1000000000], [500000000, 500000000]]) == 500000000\n assert candidate(points = [[1, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 1\n assert candidate(points = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95], [105, 105]]) == 10\n assert candidate(points = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8], [100000000, 9], [1000000000, 10]]) == 900000000\n assert candidate(points = [[1, 5], [2, 3], [3, 1], [4, 4], [5, 7], [6, 2], [7, 6], [8, 8], [9, 9], [10, 0]]) == 1\n assert candidate(points = [[0, 0], [1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [750000000, 750000000]]) == 250000000\n assert candidate(points = [[8, 1], [16, 2], [24, 3], [32, 4], [40, 5], [48, 6], [56, 7], [64, 8], [72, 9], [80, 10], [88, 11], [96, 12], [104, 13], [112, 14], [120, 15]]) == 8\n assert candidate(points = [[1, 10], [2, 20], [4, 30], [8, 40], [16, 50], [32, 60], [64, 70], [128, 80], [256, 90], [512, 100]]) == 256\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [550, 550], [600, 600]]) == 50\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11]]) == 10\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [11, 9], [12, 8], [13, 7], [14, 6], [15, 5]]) == 1\n assert candidate(points = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512], [1024, 1024], [2048, 2048], [4096, 4096], [8192, 8192], [16384, 16384]]) == 8192\n assert candidate(points = [[5, 9], [5, 8], [5, 7], [5, 6], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0]]) == 0\n assert candidate(points = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 1]]) == 10\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 1]]) == 1\n assert candidate(points = [[1, 1], [10, 1], [100, 1], [1000, 1], [10000, 1], [100000, 1], [1000000, 1], [10000000, 1], [100000000, 1], [1000000000, 1]]) == 900000000\n assert candidate(points = [[1, 10], [1, 20], [1, 30], [1, 40], [1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [1, 100], [1, 110], [1, 120], [1, 130], [1, 140], [1, 150]]) == 0\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11], [120, 12], [130, 13], [140, 14], [150, 15]]) == 10\n assert candidate(points = [[8, 7], [9, 9], [7, 4], [9, 7], [11, 11], [12, 12], [10, 10], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18]]) == 1\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 1\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().maxWidthOfVerticalArea", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxWidthOfVerticalArea(self, points: list[list[int]]) -> int:", "container": "Solution", "callable": "maxWidthOfVerticalArea", "parameters": [{"name": "points", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1638, "task_id": "count-substrings-that-differ-by-one-character", "difficulty": "Medium", "problem_description": "Given two strings s and t, find the number of ways you can choose a non-empty substring of s and replace a single character by a different character such that the resulting substring is a substring of t. In other words, find the number of substrings in s that differ from some substring in t by exactly one character.\nFor example, the underlined substrings in \"computer\" and \"computation\" only differ by the 'e'/'a', so this is a valid way.\nReturn the number of substrings that satisfy the condition above.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"aba\", t = \"baba\"\nOutput: 6\nExplanation: The following are the pairs of substrings from s and t that differ by exactly 1 character:\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\nThe underlined portions are the substrings that are chosen from s and t.\n\n​​Example 2:\n\nInput: s = \"ab\", t = \"bb\"\nOutput: 3\nExplanation: The following are the pairs of substrings from s and t that differ by 1 character:\n(\"ab\", \"bb\")\n(\"ab\", \"bb\")\n(\"ab\", \"bb\")\n​​​​The underlined portions are the substrings that are chosen from s and t.\n\n \nConstraints:\n\n1 <= s.length, t.length <= 100\ns and t consist of lowercase English letters only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abc\",t = \"abcd\") == 9\n assert candidate(s = \"abcde\",t = \"bcdef\") == 21\n assert candidate(s = \"aaaa\",t = \"bbbb\") == 16\n assert candidate(s = \"xyz\",t = \"xya\") == 9\n assert candidate(s = \"python\",t = \"typhon\") == 40\n assert candidate(s = \"xyz\",t = \"xyy\") == 9\n assert candidate(s = \"zzz\",t = \"zzz\") == 0\n assert candidate(s = \"same\",t = \"same\") == 12\n assert candidate(s = \"abcd\",t = \"abcf\") == 16\n assert candidate(s = \"abcde\",t = \"fghij\") == 25\n assert candidate(s = \"abcabc\",t = \"abcabc\") == 24\n assert candidate(s = \"aaaa\",t = \"aaab\") == 10\n assert candidate(s = \"mississippi\",t = \"misissippi\") == 126\n assert candidate(s = \"xyz\",t = \"xyw\") == 9\n assert candidate(s = \"a\",t = \"a\") == 0\n assert candidate(s = \"abcd\",t = \"dcba\") == 16\n assert candidate(s = \"abc\",t = \"def\") == 9\n assert candidate(s = \"a\",t = \"b\") == 1\n assert candidate(s = \"test\",t = \"tast\") == 16\n assert candidate(s = \"aba\",t = \"baba\") == 6\n assert candidate(s = \"aaa\",t = \"aaa\") == 0\n assert candidate(s = \"test\",t = \"text\") == 16\n assert candidate(s = \"abcd\",t = \"abce\") == 16\n assert candidate(s = \"hello\",t = \"hallo\") == 30\n assert candidate(s = \"code\",t = \"cide\") == 18\n assert candidate(s = \"ab\",t = \"bb\") == 3\n assert candidate(s = \"same\",t = \"sane\") == 18\n assert candidate(s = \"abcdefg\",t = \"abcdxyz\") == 49\n assert candidate(s = \"aaaaaab\",t = \"aaaaaac\") == 49\n assert candidate(s = \"qwertyuiop\",t = \"qwertuiopq\") == 99\n assert candidate(s = \"banana\",t = \"banane\") == 38\n assert candidate(s = \"asdfghjkl\",t = \"asdfghjkl\") == 72\n assert candidate(s = \"substring\",t = \"substrung\") == 94\n assert candidate(s = \"aaaaabbbbb\",t = \"bbbbbbaaaa\") == 91\n assert candidate(s = \"banana\",t = \"anana\") == 21\n assert candidate(s = \"algorithm\",t = \"algorihm\") == 72\n assert candidate(s = \"racecar\",t = \"racecdr\") == 55\n assert candidate(s = \"abacaba\",t = \"abacabb\") == 50\n assert candidate(s = \"aabbcc\",t = \"aabbcz\") == 41\n assert candidate(s = \"abcdefg\",t = \"gfedcba\") == 52\n assert candidate(s = \"aabbccddeeff\",t = \"aaabccddeeff\") == 177\n assert candidate(s = \"hellohello\",t = \"hellohelll\") == 101\n assert candidate(s = \"aabbccdd\",t = \"bbccddaa\") == 64\n assert candidate(s = \"racecar\",t = \"racecars\") == 52\n assert candidate(s = \"xyzxyzxyz\",t = \"zyxzyxzyx\") == 96\n assert candidate(s = \"programming\",t = \"programminh\") == 125\n assert candidate(s = \"banana\",t = \"bandana\") == 44\n assert candidate(s = \"abcdefg\",t = \"abcdefgh\") == 49\n assert candidate(s = \"qwert\",t = \"qwqrt\") == 29\n assert candidate(s = \"abcdefg\",t = \"abcdeff\") == 49\n assert candidate(s = \"abcdefghij\",t = \"abcdefghjk\") == 100\n assert candidate(s = \"abcabcabc\",t = \"abcabcabd\") == 72\n assert candidate(s = \"aaaaabbbbb\",t = \"aaaabbbbbb\") == 123\n assert candidate(s = \"abcdefghij\",t = \"abcdefghib\") == 100\n assert candidate(s = \"abcdefghi\",t = \"abcfghi\") == 63\n assert candidate(s = \"hellohello\",t = \"hallohallo\") == 134\n assert candidate(s = \"abcdefgh\",t = \"abcdefgha\") == 63\n assert candidate(s = \"qwert\",t = \"qwera\") == 25\n assert candidate(s = \"programming\",t = \"progrcmming\") == 150\n assert candidate(s = \"banana\",t = \"banama\") == 42\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",t = \"pneumonoultramicroscopicsilicovolcanoconiosus\") == 2250\n assert candidate(s = \"abcdabcd\",t = \"abceabcd\") == 72\n assert candidate(s = \"abcdefghij\",t = \"abcdefghix\") == 100\n assert candidate(s = \"example\",t = \"exampel\") == 48\n assert candidate(s = \"abcdefgh\",t = \"abxdefgh\") == 74\n assert candidate(s = \"abcabcabc\",t = \"defdefdef\") == 81\n assert candidate(s = \"programming\",t = \"prognamming\") == 149\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\") == 106\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",t = \"pneumonoultramicroscopicsilicovolcanoconiosi\") == 2118\n assert candidate(s = \"abcdef\",t = \"fedcba\") == 38\n assert candidate(s = \"abcdabcd\",t = \"dcbaabcd\") == 66\n assert candidate(s = \"abcdefgh\",t = \"fedcbagh\") == 68\n assert candidate(s = \"abcdefgh\",t = \"abcdexyz\") == 64\n assert candidate(s = \"abcdefg\",t = \"fghijkl\") == 47\n assert candidate(s = \"abcdefg\",t = \"abcdefh\") == 49\n assert candidate(s = \"abcdefghij\",t = \"abcdefghia\") == 99\n assert candidate(s = \"abcdef\",t = \"abcxef\") == 42\n assert candidate(s = \"abcdeabcde\",t = \"abcdeabcda\") == 94\n assert candidate(s = \"xyzzyx\",t = \"zyxzyx\") == 38\n assert candidate(s = \"zxcvbnm\",t = \"zxsvbnm\") == 57\n assert candidate(s = \"abcdabcd\",t = \"abxdabcd\") == 72\n assert candidate(s = \"mississippi\",t = \"misssissippi\") == 155\n assert candidate(s = \"longerstring\",t = \"longerstirng\") == 148\n assert candidate(s = \"pqrstuvw\",t = \"pqrsvwxy\") == 64\n assert candidate(s = \"zzzzzzzzzz\",t = \"zzzzzzzzza\") == 55\n assert candidate(s = \"abcdefg\",t = \"abcdefi\") == 49\n assert candidate(s = \"substring\",t = \"substrang\") == 93\n assert candidate(s = \"abacaba\",t = \"abaxaba\") == 56\n assert candidate(s = \"abcabcabc\",t = \"abcabcab\") == 48\n assert candidate(s = \"abcdefgh\",t = \"abcefgih\") == 67\n assert candidate(s = \"abcdefgabcdefg\",t = \"abcdefgabcdeff\") == 189\n assert candidate(s = \"python\",t = \"pythpn\") == 40\n assert candidate(s = \"abcdabcd\",t = \"abcddcba\") == 66\n assert candidate(s = \"abcdefg\",t = \"abcdefj\") == 49\n assert candidate(s = \"testtest\",t = \"tasttest\") == 68\n assert candidate(s = \"algorithm\",t = \"algorithr\") == 81\n assert candidate(s = \"aaaaab\",t = \"aaaabb\") == 35\n assert candidate(s = \"programming\",t = \"programming\") == 114\n assert candidate(s = \"banana\",t = \"bananas\") == 40\n assert candidate(s = \"testcase\",t = \"tastcase\") == 73\n assert candidate(s = \"aabbcc\",t = \"aabbbcc\") == 54\n assert candidate(s = \"qwertyuiop\",t = \"qwertuiop\") == 90\n assert candidate(s = \"programming\",t = \"programmimg\") == 136\n assert candidate(s = \"aabbccddeeff\",t = \"aabbccddeegg\") == 160\n assert candidate(s = \"abcdefg\",t = \"abcdefa\") == 48\n assert candidate(s = \"abcabcabc\",t = \"abcababc\") == 66\n assert candidate(s = \"abcabcabc\",t = \"abcabcbca\") == 71\n assert candidate(s = \"abcdefghij\",t = \"abcdefghja\") == 99\n assert candidate(s = \"testtest\",t = \"settsett\") == 83\n assert candidate(s = \"abcdefgh\",t = \"efghabcd\") == 56\n assert candidate(s = \"abacaba\",t = \"abacaba\") == 40\n assert candidate(s = \"abcdxyz\",t = \"xyzabcd\") == 42\n assert candidate(s = \"zzzzzz\",t = \"zzzzzz\") == 0\n assert candidate(s = \"pqrstuv\",t = \"qrsuvwp\") == 48\n assert candidate(s = \"abcabcabc\",t = \"ababcabc\") == 63\n assert candidate(s = \"abcdefghijk\",t = \"abcdefghijx\") == 121\n assert candidate(s = \"algorithm\",t = \"algorihtm\") == 83\n assert candidate(s = \"abcdabcd\",t = \"abacabad\") == 74\n assert candidate(s = \"zzzzz\",t = \"zzzzz\") == 0\n assert candidate(s = \"xyzz\",t = \"xyyz\") == 18\n assert candidate(s = \"banana\",t = \"bananna\") == 44\n assert candidate(s = \"programming\",t = \"progrMming\") == 118\n assert candidate(s = \"aaaaabbbb\",t = \"aaaabbbbb\") == 98\n assert candidate(s = \"pattern\",t = \"patterr\") == 51\n assert candidate(s = \"abacax\",t = \"abacay\") == 40\n assert candidate(s = \"mississippi\",t = \"mississippa\") == 141\n assert candidate(s = \"programming\",t = \"progranning\") == 125\n assert candidate(s = \"substrings\",t = \"substraings\") == 108\n assert candidate(s = \"abcdefgh\",t = \"abcdefga\") == 63\n assert candidate(s = \"mississippi\",t = \"mississipp\") == 119\n assert candidate(s = \"zzzzzzzzzz\",t = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"abcdefghij\",t = \"abcegijhif\") == 104\n assert candidate(s = \"aaaaaaaaaa\",t = \"bbbbbbbbbb\") == 100\n assert candidate(s = \"programming\",t = \"programminq\") == 125\n assert candidate(s = \"xyzzyx\",t = \"zyxzyz\") == 39\n assert candidate(s = \"aabbcc\",t = \"bbaacc\") == 38\n assert candidate(s = \"abcabcabcabc\",t = \"abababababab\") == 166\n assert candidate(s = \"mnopqr\",t = \"mnopqs\") == 36\n assert candidate(s = \"abacabadabacaba\",t = \"abacabadabacaba\") == 272\n assert candidate(s = \"racecar\",t = \"racecer\") == 56\n assert candidate(s = \"abacaba\",t = \"babcaba\") == 47\n assert candidate(s = \"abcdefgh\",t = \"abcdefgi\") == 64\n assert candidate(s = \"abababa\",t = \"bababab\") == 25\n assert candidate(s = \"abcd\",t = \"abdc\") == 16\n assert candidate(s = \"qwerty\",t = \"qwertyuiop\") == 54\n assert candidate(s = \"interview\",t = \"interviww\") == 89\n assert candidate(s = \"mississippi\",t = \"mississipxy\") == 140\n assert candidate(s = \"qwertyuiop\",t = \"poiuytrewq\") == 106\n assert candidate(s = \"abcdefg\",t = \"abacdef\") == 49\n assert candidate(s = \"abcdefg\",t = \"abcxefg\") == 58\n assert candidate(s = \"aaaaabbbbb\",t = \"aaaabbbbba\") == 128\n assert candidate(s = \"aaaaab\",t = \"aaabaa\") == 39\n assert candidate(s = \"aaaaaaab\",t = \"aaaaaaax\") == 64\n assert candidate(s = \"abcdefgh\",t = \"hgfedcba\") == 68\n assert candidate(s = \"abababab\",t = \"babababa\") == 32\n assert candidate(s = \"abcdef\",t = \"abcdeg\") == 36\n"}, "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().countSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countSubstrings(self, s: str, t: str) -> int:", "container": "Solution", "callable": "countSubstrings", "parameters": [{"name": "s", "type": "str"}, {"name": "t", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1639, "task_id": "number-of-ways-to-form-a-target-string-given-a-dictionary", "difficulty": "Hard", "problem_description": "You are given a list of strings of the same length words and a string target.\nYour task is to form target using the given words under the following rules:\n\ntarget should be formed from left to right.\nTo form the ith character (0-indexed) of target, you can choose the kth character of the jth string in words if target[i] = words[j][k].\nOnce you use the kth character of the jth string of words, you can no longer use the xth character of any string in words where x <= k. In other words, all characters to the left of or at index k become unusuable for every string.\nRepeat the process until you form the string target.\n\nNotice that you can use multiple characters from the same string in words provided the conditions above are met.\nReturn the number of ways to form target from words. Since the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: words = [\"acca\",\"bbbb\",\"caca\"], target = \"aba\"\nOutput: 6\nExplanation: There are 6 ways to form target.\n\"aba\" -> index 0 (\"acca\"), index 1 (\"bbbb\"), index 3 (\"caca\")\n\"aba\" -> index 0 (\"acca\"), index 2 (\"bbbb\"), index 3 (\"caca\")\n\"aba\" -> index 0 (\"acca\"), index 1 (\"bbbb\"), index 3 (\"acca\")\n\"aba\" -> index 0 (\"acca\"), index 2 (\"bbbb\"), index 3 (\"acca\")\n\"aba\" -> index 1 (\"caca\"), index 2 (\"bbbb\"), index 3 (\"acca\")\n\"aba\" -> index 1 (\"caca\"), index 2 (\"bbbb\"), index 3 (\"caca\")\n\nExample 2:\n\nInput: words = [\"abba\",\"baab\"], target = \"bab\"\nOutput: 4\nExplanation: There are 4 ways to form target.\n\"bab\" -> index 0 (\"baab\"), index 1 (\"baab\"), index 2 (\"abba\")\n\"bab\" -> index 0 (\"baab\"), index 1 (\"baab\"), index 3 (\"baab\")\n\"bab\" -> index 0 (\"baab\"), index 2 (\"baab\"), index 3 (\"baab\")\n\"bab\" -> index 1 (\"abba\"), index 2 (\"baab\"), index 3 (\"baab\")\n\n \nConstraints:\n\n1 <= words.length <= 1000\n1 <= words[i].length <= 1000\nAll strings in words have the same length.\n1 <= target.length <= 1000\nwords[i] and target contain only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['a', 'b', 'c'],target = \"abc\") == 0\n assert candidate(words = ['abc', 'def'],target = \"ad\") == 0\n assert candidate(words = ['mississippi'],target = \"issi\") == 15\n assert candidate(words = ['aaa', 'aaa', 'aaa'],target = \"aaa\") == 27\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'],target = \"abc\") == 8\n assert candidate(words = ['abc', 'bcd', 'cde'],target = \"abc\") == 1\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"miss\") == 567\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"issi\") == 1215\n assert candidate(words = ['acca', 'bbbb', 'caca'],target = \"aba\") == 6\n assert candidate(words = ['leetcode', 'leetcode', 'leetcode'],target = \"leet\") == 81\n assert candidate(words = ['aaa', 'aaa', 'aaa'],target = \"a\") == 9\n assert candidate(words = ['zzz', 'zzz', 'zzz'],target = \"zzz\") == 27\n assert candidate(words = ['abc', 'bcd', 'cde'],target = \"aab\") == 0\n assert candidate(words = ['abc', 'bcd', 'cde'],target = \"abd\") == 1\n assert candidate(words = ['aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa'],target = \"aaaa\") == 17010\n assert candidate(words = ['abc', 'def', 'ghi'],target = \"adg\") == 0\n assert candidate(words = ['abba', 'baab'],target = \"bab\") == 4\n assert candidate(words = ['mississippi'],target = \"sip\") == 12\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghijk\") == 0\n assert candidate(words = ['abcdef', 'bcadef', 'cdefgh'],target = \"abcd\") == 2\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"mnop\") == 1\n assert candidate(words = ['abcdefgh', 'ijklmnop', 'qrstuvwx', 'yzabcdef'],target = \"aceg\") == 1\n assert candidate(words = ['abcdefg', 'xyzabc', 'mnopqr', 'stuvwx'],target = \"abc\") == 4\n assert candidate(words = ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd'],target = \"abcd\") == 15\n assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd'],target = \"abcd\") == 1\n assert candidate(words = ['xyzxyz', 'yzxyzy', 'zxyzxy', 'yzyxzy'],target = \"zyx\") == 26\n assert candidate(words = ['thisisanexample', 'thisisanexample', 'thisisanexample'],target = \"example\") == 2187\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi', 'mississippi'],target = \"miss\") == 1792\n assert candidate(words = ['hello', 'hello', 'hello', 'hello', 'hello'],target = \"hello\") == 3125\n assert candidate(words = ['xylophone', 'xylophone', 'xylophone'],target = \"xylo\") == 162\n assert candidate(words = ['hellohellohello', 'worldworldworld', 'hellohellohello'],target = \"helloworld\") == 2496\n assert candidate(words = ['ababababab', 'bababababa', 'ababababab'],target = \"ababab\") == 4339\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"aceg\") == 81\n assert candidate(words = ['lloremipsumdolorsitamet', 'lloremipsumdolorsitamet', 'lloremipsumdolorsitamet'],target = \"lorem\") == 1458\n assert candidate(words = ['abacabadabacaba', 'bacabadabacabab', 'acabadabacababa'],target = \"abacaba\") == 13252\n assert candidate(words = ['abcabc', 'bcabca', 'cababc'],target = \"abc\") == 39\n assert candidate(words = ['aabbccddeeff', 'bbaacceeddff', 'ccaabbeedddf', 'ddaabbccdeff'],target = \"abcde\") == 1496\n assert candidate(words = ['zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz'],target = \"zz\") == 150\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abcd\") == 5\n assert candidate(words = ['zzzzzz', 'yyyyyy', 'xxxxxx', 'wwwwww', 'vvvvvv'],target = \"zyxwv\") == 6\n assert candidate(words = ['abcabcabcabc', 'defdefdefdef', 'ghighighighi', 'jkljkljkljkl'],target = \"adgj\") == 1\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 999999937\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst'],target = \"afkp\") == 0\n assert candidate(words = ['zzzz', 'zzzz', 'zzzz', 'zzzz'],target = \"zzz\") == 256\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"ijkl\") == 1\n assert candidate(words = ['xyzxyzxyzxyz', 'yzxyzyzyzx', 'zxyzxyzxyz'],target = \"xyzxyz\") == 770\n assert candidate(words = ['aabbccddeeff', 'bbccddeeffgg', 'ccddeeffgghh'],target = \"abcdeffg\") == 414\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"acfi\") == 256\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"mnopqr\") == 1\n assert candidate(words = ['hello', 'hello', 'hello', 'hello', 'hello'],target = \"hello\") == 3125\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccaabb'],target = \"abc\") == 40\n assert candidate(words = ['banana', 'banana', 'banana', 'banana'],target = \"ban\") == 192\n assert candidate(words = ['abcdefghi', 'jklmnopqr', 'stuvwxyz'],target = \"adgt\") == 0\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij'],target = \"abcde\") == 1\n assert candidate(words = ['abcabcabc', 'abcabcabc', 'abcabcabc'],target = \"abc\") == 270\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"mississippi\") == 177147\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi', 'mississippi', 'mississippi', 'mississippi'],target = \"issipi\") == 746496\n assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz'],target = \"zzzz\") == 131250\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhii', 'jjkkll', 'mmnnoo'],target = \"abcd\") == 0\n assert candidate(words = ['aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa'],target = \"aaaa\") == 53760\n assert candidate(words = ['zzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzz'],target = \"zzzz\") == 392445\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"afg\") == 0\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"acegi\") == 3125\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij'],target = \"efghij\") == 1\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba'],target = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(words = ['abacaba', 'bacabab', 'cacabac', 'dacabad'],target = \"abac\") == 81\n assert candidate(words = ['zzzzzzzzzz', 'yyyyyyyyyy', 'xxxxxxxxxx', 'wwwwwwwwww', 'vvvvvvvvvv'],target = \"zyxwv\") == 252\n assert candidate(words = ['aaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc'],target = \"abc\") == 120\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij'],target = \"defg\") == 15\n assert candidate(words = ['target', 'target', 'target', 'target', 'target'],target = \"target\") == 15625\n assert candidate(words = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'jihgfedcba'],target = \"abcdefghij\") == 1024\n assert candidate(words = ['abcdefghij', 'klmnopqr', 'stuvwxyz', 'abcdefghij', 'klmnopqr'],target = \"mnop\") == 16\n assert candidate(words = ['banana', 'banana', 'banana', 'banana', 'banana'],target = \"ban\") == 375\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 59049\n assert candidate(words = ['aaaa', 'abbb', 'accc', 'addd'],target = \"abcd\") == 4\n assert candidate(words = ['aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz', 'aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz'],target = \"abcdefghijklmnopqrstu\") == 46480318\n assert candidate(words = ['abcdefg', 'abcdefg', 'abcdefg', 'abcdefg', 'abcdefg'],target = \"abcdefg\") == 78125\n assert candidate(words = ['abcdefghijklmnop', 'qrstuvwxyzab', 'cdefghijklmnop', 'qrstuvwxyzab'],target = \"abcde\") == 1\n assert candidate(words = ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd'],target = \"abcd\") == 15\n assert candidate(words = ['abcdefghijk', 'abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc'],target = \"abcdefg\") == 1224720\n assert candidate(words = ['aabbccdd', 'aabbccdd', 'aabbccdd', 'aabbccdd'],target = \"abcd\") == 4096\n assert candidate(words = ['abcd', 'abcf', 'acdf', 'adef'],target = \"ace\") == 4\n assert candidate(words = ['abcdefghij', 'klmnopqr', 'stuvwxyz', 'abcdefghij', 'klmnopqr'],target = \"mnopqrst\") == 0\n assert candidate(words = ['aaaaaaaabaaaaaa', 'baaaaaaaabaaaaa', 'caaaaaaabaaaaaa'],target = \"aaaaaabaaaaaa\") == 9920232\n assert candidate(words = ['abacabadabacaba', 'bcbdbecbdbecb', 'dcdcdcddcdcdc'],target = \"abc\") == 110\n assert candidate(words = ['abababababababab', 'bababababababa', 'abababababababab'],target = \"abab\") == 9394\n assert candidate(words = ['abcdef', 'fedcba', 'abcdef'],target = \"abcdef\") == 64\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"stuvwx\") == 1\n assert candidate(words = ['qwerty', 'qwerty', 'qwerty', 'qwerty', 'qwerty'],target = \"qwe\") == 125\n assert candidate(words = ['abcabcabc', 'defdefdef', 'ghighighi'],target = \"adg\") == 1\n assert candidate(words = ['abcdefghijk', 'abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc'],target = \"abc\") == 729\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghijabcdefghij\") == 0\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhii', 'jjkkgg'],target = \"abgi\") == 4\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba'],target = \"zyxwvutsrqponmlkjihgfedcba\") == 67108864\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz'],target = \"abcdefghijklmnopqrstuvwxyz\") == 67108864\n assert candidate(words = ['aaaa', 'abab', 'acac', 'adad', 'aeae'],target = \"aa\") == 46\n assert candidate(words = ['programming', 'is', 'fun'],target = \"pin\") == 1\n assert candidate(words = ['sequence', 'sequence', 'sequence', 'sequence', 'sequence'],target = \"seq\") == 125\n assert candidate(words = ['abcd', 'abcd', 'abcd', 'abcd', 'abcd'],target = \"abcd\") == 625\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"ssss\") == 81\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abc\") == 4\n assert candidate(words = ['abcdefghijkl', 'mnopqrstuv', 'wxyzabcdef', 'ghijklmnop'],target = \"mnop\") == 5\n assert candidate(words = ['abcdefghijabcdefghij', 'jihgfedcbaabcdef', 'abcdefghijjihgfe'],target = \"abcdefghij\") == 3536\n assert candidate(words = ['abacaba', 'bcbcbcb', 'cacacac'],target = \"abcabc\") == 10\n assert candidate(words = ['aabbccddeeff', 'gghhiijjkkll', 'mmnnooppqqrr', 'ssttuuvvwwxx'],target = \"abcdefff\") == 0\n assert candidate(words = ['abcde', 'abfgh', 'acjkl'],target = \"abac\") == 0\n assert candidate(words = ['algorithm', 'algorithm', 'algorithm', 'algorithm', 'algorithm'],target = \"algo\") == 625\n assert candidate(words = ['aaaaaaaaaa', 'aaaaaaaaab', 'aaaaaaaaac', 'aaaaaaaaad'],target = \"aaa\") == 5952\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"yzabcd\") == 1\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 9765625\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abcde\") == 1\n assert candidate(words = ['abcdefg', 'bcdefgh', 'cdefghi'],target = \"efg\") == 10\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 9765625\n assert candidate(words = ['racecar', 'racecar', 'racecar', 'racecar', 'racecar'],target = \"race\") == 625\n assert candidate(words = ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'],target = \"zzzzzzzzzz\") == 277520636\n assert candidate(words = ['abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd'],target = \"abcdabcd\") == 0\n assert candidate(words = ['abcabcabcabc', 'bcabcabcabca', 'cabcabcabcab'],target = \"abcabc\") == 924\n assert candidate(words = ['aabbccdd', 'bbaaddcc', 'ccddaabb', 'ddbbaacc'],target = \"abcd\") == 77\n assert candidate(words = ['aaaaaaaaa', 'bbbbbbbbb', 'ccccccccc', 'ddddddddd', 'eeeeeeeee', 'fffffff', 'ggggggggg', 'hhhhhhhhh', 'iiiiiiiii'],target = \"abcdefghi\") == 1\n assert candidate(words = ['zzzzzz', 'zzzzzz', 'zzzzzz'],target = \"zzz\") == 540\n assert candidate(words = ['quickbrownfox', 'quickbrownfox', 'quickbrownfox'],target = \"quickfox\") == 6561\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 59049\n assert candidate(words = ['abacabadabacaba', 'bcbdbecbdbecb', 'dcdcdcddcdcdc', 'efefegfefegfe', 'ghighighihighi'],target = \"abcdefg\") == 40\n assert candidate(words = ['abcdabcdabcd', 'abcdabcdabcd', 'abcdabcdabcd'],target = \"abcd\") == 1215\n assert candidate(words = ['abcdabcdabcd', 'bcdbcdbcdb', 'cdcdcdcdcd'],target = \"abcdabcd\") == 184\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abcdef\") == 1\n assert candidate(words = ['abcabcabc', 'defdefdef', 'ghighighi'],target = \"adg\") == 1\n assert candidate(words = ['abcdefg', 'hijklmn', 'opqrstu', 'vwxyzab', 'cdefghi'],target = \"abcde\") == 1\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr'],target = \"abcghi\") == 0\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zabcd'],target = \"ace\") == 4\n assert candidate(words = ['aaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc', 'dddddddddd', 'eeeeeeeeee'],target = \"abcde\") == 252\n assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz'],target = \"zzz\") == 7680\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhii', 'jjkkll'],target = \"abcd\") == 0\n assert candidate(words = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee'],target = \"abcde\") == 1\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"efgh\") == 5\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],target = \"zyxwvut\") == 0\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst'],target = \"afk\") == 0\n assert candidate(words = ['leetcode', 'leetcode', 'leetcode', 'leetcode'],target = \"leet\") == 256\n assert candidate(words = ['abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh'],target = \"abcdefgh\") == 390625\n assert candidate(words = ['thisisalongstring', 'thisisalongstring', 'thisisalongstring', 'thisisalongstring'],target = \"thisisalongstring\") == 179869065\n assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz'],target = \"zzzz\") == 53760\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"afik\") == 0\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 1048576\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abc\") == 125\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"missi\") == 3645\n assert candidate(words = ['abracadabra', 'abracadabra', 'abracadabra', 'abracadabra'],target = \"abrac\") == 1024\n assert candidate(words = ['ababababab', 'bababababa', 'ababababab', 'bababababa'],target = \"abab\") == 3360\n assert candidate(words = ['xylophone', 'xylophone', 'xylophone', 'xylophone', 'xylophone'],target = \"xyl\") == 125\n"}, "metadata": {"canonical_parameter_names": ["words", "target"], "leetcode_dataset_entry_point": "Solution().numWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numWays(self, words: list[str], target: str) -> int:", "container": "Solution", "callable": "numWays", "parameters": [{"name": "words", "type": "list[str]"}, {"name": "target", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1640, "task_id": "check-array-formation-through-concatenation", "difficulty": "Easy", "problem_description": "You are given an array of distinct integers arr and an array of integer arrays pieces, where the integers in pieces are distinct. Your goal is to form arr by concatenating the arrays in pieces in any order. However, you are not allowed to reorder the integers in each array pieces[i].\nReturn true if it is possible to form the array arr from pieces. Otherwise, return false.\n \nExample 1:\n\nInput: arr = [15,88], pieces = [[88],[15]]\nOutput: true\nExplanation: Concatenate [15] then [88]\n\nExample 2:\n\nInput: arr = [49,18,16], pieces = [[16,18,49]]\nOutput: false\nExplanation: Even though the numbers match, we cannot reorder pieces[0].\n\nExample 3:\n\nInput: arr = [91,4,64,78], pieces = [[78],[4,64],[91]]\nOutput: true\nExplanation: Concatenate [91] then [4,64] then [78]\n\n \nConstraints:\n\n1 <= pieces.length <= arr.length <= 100\nsum(pieces[i].length) == arr.length\n1 <= pieces[i].length <= arr.length\n1 <= arr[i], pieces[i][j] <= 100\nThe integers in arr are distinct.\nThe integers in pieces are distinct (i.e., If we flatten pieces in a 1D array, all the integers in this array are distinct).\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [10, 20, 30, 40, 50],pieces = [[10, 20], [30, 40, 50]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5],pieces = [[2, 3], [1, 4], [5]]) == False\n assert candidate(arr = [91, 4, 64, 78],pieces = [[78], [4, 64], [91]]) == True\n assert candidate(arr = [49, 18, 16],pieces = [[16, 18, 49]]) == False\n assert candidate(arr = [15, 88],pieces = [[88], [15]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5],pieces = [[2], [4, 5], [3], [1]]) == True\n assert candidate(arr = [5, 9, 13, 17, 21, 25],pieces = [[5, 9, 13], [17, 21, 25]]) == True\n assert candidate(arr = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110],pieces = [[101, 102], [103, 104], [105, 106], [107, 108], [109, 110]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14],pieces = [[2, 4], [6, 8], [10, 12], [14]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],pieces = [[100, 99], [98, 97], [96, 95, 94], [93, 92], [91]]) == True\n assert candidate(arr = [91, 4, 64, 78, 100, 50],pieces = [[78, 100], [91, 4], [64], [50]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],pieces = [[1, 3, 5, 7], [9, 11], [13, 15, 17, 19], [21, 23, 25], [27, 29]]) == True\n assert candidate(arr = [8, 16, 24, 32, 40, 48, 56, 64],pieces = [[8, 16, 24], [32, 40, 48], [56, 64]]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600],pieces = [[100, 200], [300, 400], [500, 600]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99],pieces = [[11, 22], [33, 44, 55], [66, 77, 88, 99]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40],pieces = [[5, 10, 15], [20, 25], [30, 35, 40]]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pieces = [[100], [200, 300], [400, 500, 600], [700, 800], [900, 1000]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pieces = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1, 3, 5], [7, 9, 11], [13, 15, 17, 19]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2, 3], [4, 5], [6, 7, 8, 9, 10]]) == True\n assert candidate(arr = [23, 32, 45, 54, 67, 76, 89, 98],pieces = [[23, 32], [45, 54, 67], [76, 89], [98]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1, 3], [5, 7, 9], [11, 13], [15, 17, 19]]) == True\n assert candidate(arr = [3, 1, 2, 5, 4],pieces = [[3, 1], [2, 5], [4]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],pieces = [[1, 2], [3, 4, 5], [6], [7, 8, 9]]) == True\n assert candidate(arr = [8, 6, 7, 5, 3, 0, 9],pieces = [[8, 6], [7, 5], [3, 0], [9]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pieces = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],pieces = [[100, 99], [98, 97, 96], [95, 94, 93], [92, 91]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pieces = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11], [12, 13, 14, 15]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4], [6, 8, 10], [12, 14], [16, 18, 20]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pieces = [[1, 2, 3], [4, 5], [6, 7, 8], [9, 10, 11], [12, 13, 14, 15]]) == True\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],pieces = [[9], [8], [7], [6], [5], [4], [3], [2], [1]]) == True\n assert candidate(arr = [42, 13, 56, 78, 91, 100],pieces = [[42], [13, 56], [78], [91, 100]]) == True\n assert candidate(arr = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30],pieces = [[21, 22], [23, 24], [25, 26], [27, 28], [29, 30]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90],pieces = [[10, 20, 30], [40, 50], [60, 70, 80, 90]]) == True\n assert candidate(arr = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30],pieces = [[12, 14, 16], [18, 20], [22, 24, 26, 28, 30]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == True\n assert candidate(arr = [99, 88, 77, 66, 55, 44, 33, 22, 11],pieces = [[99], [88], [77], [66], [55], [44], [33], [22], [11]]) == True\n assert candidate(arr = [20, 30, 10, 50, 40],pieces = [[20, 30], [10, 50], [40]]) == True\n assert candidate(arr = [7, 14, 28, 21, 42],pieces = [[7, 14, 28], [21, 42]]) == True\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],pieces = [[100, 90], [80, 70, 60, 50], [40, 30, 20, 10]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[3, 4], [1, 2], [7, 8], [5, 6], [9, 10]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],pieces = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == True\n assert candidate(arr = [42, 43, 44, 45, 46, 47, 48, 49, 50],pieces = [[42, 43], [44, 45, 46], [47, 48], [49, 50]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1, 3, 5], [7, 9], [11, 13], [15, 17, 19]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40],pieces = [[5], [10, 15], [20, 25, 30], [35, 40]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15],pieces = [[1, 3, 5], [7, 9], [11, 13, 15]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1], [3, 5], [7, 9], [11, 13], [15, 17, 19]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90],pieces = [[10], [20], [30], [40], [50], [60], [70], [80], [90]]) == True\n assert candidate(arr = [101, 102, 103, 104, 105, 106],pieces = [[101, 102, 103], [104, 105], [106]]) == True\n assert candidate(arr = [2, 5, 3, 8, 9, 4],pieces = [[2, 5], [3], [8, 9], [4]]) == True\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],pieces = [[99, 98, 97], [96, 95, 94], [93, 92, 91, 90]]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27],pieces = [[3, 6, 9], [12, 15], [18, 21, 24, 27]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],pieces = [[1, 2], [3, 4, 5], [6, 7, 8], [9]]) == True\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15],pieces = [[3, 5, 7], [9, 11], [13, 15]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4, 5], [6, 7], [8, 9, 10]]) == True\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15],pieces = [[3, 5, 7], [9], [11, 13, 15]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96],pieces = [[97, 98], [96], [99], [100]]) == False\n assert candidate(arr = [7, 14, 21, 28, 35, 42],pieces = [[7], [14], [21], [28], [35], [42]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30],pieces = [[10, 15], [5], [20, 25, 30]]) == True\n assert candidate(arr = [5, 6, 1, 2, 3, 4],pieces = [[5, 6], [1, 2], [3, 4]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95],pieces = [[100], [99, 98], [97, 96, 95]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4, 5], [6, 7, 8, 9, 10]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95],pieces = [[100, 99], [98, 97], [96, 95]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],pieces = [[1, 3, 5], [7, 9, 11], [13, 15, 17], [19, 21]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35],pieces = [[5, 10, 15], [20], [25, 30, 35]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99],pieces = [[11, 22, 33], [44, 55], [66, 77, 88, 99]]) == True\n assert candidate(arr = [70, 80, 90, 100, 110, 120],pieces = [[70, 80], [90, 100], [110, 120]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70],pieces = [[10, 20], [30, 40, 50], [60, 70]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],pieces = [[10, 20, 30], [40, 50, 60], [70, 80, 90], [100, 110], [120, 130, 140, 150]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pieces = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == True\n assert candidate(arr = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34],pieces = [[25, 26], [27, 28, 29], [30, 31, 32, 33], [34]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],pieces = [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16],pieces = [[2, 4], [6, 8, 10], [12, 14, 16]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4], [6, 8, 10], [12, 14], [16, 18, 20]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4, 6], [8, 10, 12], [14, 16, 18], [20]]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21],pieces = [[3, 6], [9, 12], [15, 18], [21]]) == True\n assert candidate(arr = [5, 4, 3, 2, 1],pieces = [[5], [4, 3], [2, 1]]) == True\n assert candidate(arr = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40],pieces = [[31, 32], [33, 34], [35, 36], [37, 38], [39, 40]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],pieces = [[100, 99], [98, 97], [96, 95], [94, 93], [92, 91]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4, 6], [8, 10], [12, 14, 16, 18, 20]]) == True\n assert candidate(arr = [23, 29, 20, 32, 45, 67],pieces = [[23, 29, 20], [32], [45, 67]]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56],pieces = [[7, 14, 21, 28], [35, 42], [49, 56]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],pieces = [[1, 2], [3, 4], [5, 6], [7, 8], [9]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],pieces = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]) == True\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],pieces = [[9, 8, 7], [6, 5], [4, 3, 2], [1]]) == True\n assert candidate(arr = [5, 1, 3, 7, 8, 2, 4, 9, 6],pieces = [[1, 3], [5], [7, 8], [2, 4], [9, 6]]) == True\n assert candidate(arr = [100, 200, 300, 400, 500],pieces = [[100], [200, 300], [400, 500]]) == True\n assert candidate(arr = [5, 3, 8, 9, 10, 15, 20],pieces = [[5], [3, 8, 9], [10, 15], [20]]) == True\n assert candidate(arr = [4, 2, 5, 3, 6, 1, 7],pieces = [[4, 2], [5], [3, 6], [1, 7]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99],pieces = [[11, 22], [33, 44], [55, 66], [77, 88, 99]]) == True\n assert candidate(arr = [42, 24, 66, 33, 55, 77],pieces = [[42], [24, 66], [33, 55], [77]]) == True\n assert candidate(arr = [8, 6, 7, 5, 3, 0, 9],pieces = [[8, 6], [7, 5, 3], [0, 9]]) == True\n assert candidate(arr = [5, 1, 3, 9, 7, 6],pieces = [[5, 1], [3, 9], [7, 6]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100],pieces = [[11, 22], [33, 44], [55, 66], [77, 88], [99, 100]]) == True\n assert candidate(arr = [60, 70, 80, 90, 100, 110, 120],pieces = [[60, 70, 80], [90, 100], [110, 120]]) == True\n assert candidate(arr = [8, 6, 7, 5, 3, 0, 9],pieces = [[8, 6, 7], [5, 3], [0, 9]]) == True\n assert candidate(arr = [23, 45, 67, 89, 90, 12, 34, 56],pieces = [[23, 45], [67, 89, 90], [12, 34, 56]]) == True\n"}, "metadata": {"canonical_parameter_names": ["arr", "pieces"], "leetcode_dataset_entry_point": "Solution().canFormArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canFormArray(self, arr: list[int], pieces: list[list[int]]) -> bool:", "container": "Solution", "callable": "canFormArray", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "pieces", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1641, "task_id": "count-sorted-vowel-strings", "difficulty": "Medium", "problem_description": "Given an integer n, return the number of strings of length n that consist only of vowels (a, e, i, o, u) and are lexicographically sorted.\nA string s is lexicographically sorted if for all valid i, s[i] is the same as or comes before s[i+1] in the alphabet.\n \nExample 1:\n\nInput: n = 1\nOutput: 5\nExplanation: The 5 sorted strings that consist of vowels only are [\"a\",\"e\",\"i\",\"o\",\"u\"].\n\nExample 2:\n\nInput: n = 2\nOutput: 15\nExplanation: The 15 sorted strings that consist of vowels only are\n[\"aa\",\"ae\",\"ai\",\"ao\",\"au\",\"ee\",\"ei\",\"eo\",\"eu\",\"ii\",\"io\",\"iu\",\"oo\",\"ou\",\"uu\"].\nNote that \"ea\" is not a valid string since 'e' comes after 'a' in the alphabet.\n\nExample 3:\n\nInput: n = 33\nOutput: 66045\n\n \nConstraints:\n\n1 <= n <= 50 \n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 35\n assert candidate(n = 4) == 70\n assert candidate(n = 33) == 66045\n assert candidate(n = 2) == 15\n assert candidate(n = 20) == 10626\n assert candidate(n = 1) == 5\n assert candidate(n = 50) == 316251\n assert candidate(n = 10) == 1001\n assert candidate(n = 5) == 126\n assert candidate(n = 45) == 211876\n assert candidate(n = 49) == 292825\n assert candidate(n = 12) == 1820\n assert candidate(n = 28) == 35960\n assert candidate(n = 30) == 46376\n assert candidate(n = 40) == 135751\n assert candidate(n = 8) == 495\n assert candidate(n = 22) == 14950\n assert candidate(n = 27) == 31465\n assert candidate(n = 35) == 82251\n assert candidate(n = 15) == 3876\n assert candidate(n = 9) == 715\n assert candidate(n = 6) == 210\n assert candidate(n = 7) == 330\n assert candidate(n = 25) == 23751\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countVowelStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countVowelStrings(self, n: int) -> int:", "container": "Solution", "callable": "countVowelStrings", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1642, "task_id": "furthest-building-you-can-reach", "difficulty": "Medium", "problem_description": "You are given an integer array heights representing the heights of buildings, some bricks, and some ladders.\nYou start your journey from building 0 and move to the next building by possibly using bricks or ladders.\nWhile moving from building i to building i+1 (0-indexed),\n\nIf the current building's height is greater than or equal to the next building's height, you do not need a ladder or bricks.\nIf the current building's height is less than the next building's height, you can either use one ladder or (h[i+1] - h[i]) bricks.\n\nReturn the furthest building index (0-indexed) you can reach if you use the given ladders and bricks optimally.\n \nExample 1:\n\n\nInput: heights = [4,2,7,6,9,14,12], bricks = 5, ladders = 1\nOutput: 4\nExplanation: Starting at building 0, you can follow these steps:\n- Go to building 1 without using ladders nor bricks since 4 >= 2.\n- Go to building 2 using 5 bricks. You must use either bricks or ladders because 2 < 7.\n- Go to building 3 without using ladders nor bricks since 7 >= 6.\n- Go to building 4 using your only ladder. You must use either bricks or ladders because 6 < 9.\nIt is impossible to go beyond building 4 because you do not have any more bricks or ladders.\n\nExample 2:\n\nInput: heights = [4,12,2,7,3,18,20,3,19], bricks = 10, ladders = 2\nOutput: 7\n\nExample 3:\n\nInput: heights = [14,3,19,3], bricks = 17, ladders = 0\nOutput: 3\n\n \nConstraints:\n\n1 <= heights.length <= 105\n1 <= heights[i] <= 106\n0 <= bricks <= 109\n0 <= ladders <= heights.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(heights = [10, 15, 20, 25, 30],bricks = 0,ladders = 2) == 2\n assert candidate(heights = [3, 1, 2, 1, 5],bricks = 2,ladders = 1) == 4\n assert candidate(heights = [5, 5, 5, 5, 5],bricks = 0,ladders = 0) == 4\n assert candidate(heights = [1, 1000000, 1, 1000000, 1],bricks = 1000000,ladders = 1) == 4\n assert candidate(heights = [10, 15, 20, 25, 30],bricks = 30,ladders = 2) == 4\n assert candidate(heights = [1, 1000000],bricks = 999999,ladders = 0) == 1\n assert candidate(heights = [14, 3, 19, 3],bricks = 17,ladders = 0) == 3\n assert candidate(heights = [1, 2, 3, 4, 5],bricks = 10,ladders = 0) == 4\n assert candidate(heights = [5, 4, 3, 2, 1],bricks = 0,ladders = 0) == 4\n assert candidate(heights = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],bricks = 100,ladders = 5) == 9\n assert candidate(heights = [100, 90, 80, 70, 60],bricks = 50,ladders = 0) == 4\n assert candidate(heights = [10, 15, 20, 25, 30],bricks = 30,ladders = 0) == 4\n assert candidate(heights = [1, 3, 5, 7, 9],bricks = 20,ladders = 2) == 4\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bricks = 0,ladders = 5) == 5\n assert candidate(heights = [3, 14, 3, 14, 3, 3, 14, 3, 14],bricks = 1,ladders = 1) == 2\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15],bricks = 20,ladders = 3) == 7\n assert candidate(heights = [1, 3, 5, 7, 9],bricks = 10,ladders = 0) == 4\n assert candidate(heights = [1, 1, 1, 1, 1],bricks = 0,ladders = 0) == 4\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bricks = 18,ladders = 1) == 9\n assert candidate(heights = [4, 2, 7, 6, 9, 14, 12],bricks = 5,ladders = 1) == 4\n assert candidate(heights = [1, 5, 1, 2, 3, 4, 10000],bricks = 4,ladders = 1) == 5\n assert candidate(heights = [5, 1, 3, 4, 2],bricks = 0,ladders = 1) == 2\n assert candidate(heights = [4, 2, 3],bricks = 0,ladders = 1) == 2\n assert candidate(heights = [5, 18, 22, 33, 8, 26, 48, 29, 55, 46],bricks = 83,ladders = 3) == 9\n assert candidate(heights = [1, 2],bricks = 0,ladders = 0) == 0\n assert candidate(heights = [4, 12, 2, 7, 3, 18, 20, 3, 19],bricks = 10,ladders = 2) == 7\n assert candidate(heights = [1, 3, 5, 7, 9],bricks = 100,ladders = 0) == 4\n assert candidate(heights = [9, 8, 7, 6, 5],bricks = 0,ladders = 5) == 4\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],bricks = 100,ladders = 2) == 13\n assert candidate(heights = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],bricks = 10,ladders = 0) == 10\n assert candidate(heights = [1, 3, 5, 4, 2, 1, 3, 5, 4, 2, 1, 3, 5, 4, 2, 1, 3, 5, 4, 2, 1],bricks = 20,ladders = 3) == 20\n assert candidate(heights = [5, 18, 3, 14, 5, 19, 2, 13, 11, 18, 23, 25, 28, 30, 35],bricks = 30,ladders = 4) == 14\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bricks = 200,ladders = 3) == 9\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 10,ladders = 0) == 9\n assert candidate(heights = [1, 2, 3, 100, 101, 102, 103, 104, 105],bricks = 10,ladders = 3) == 8\n assert candidate(heights = [1, 5, 3, 6, 7, 3, 8, 4, 9, 2, 10, 6, 11, 7, 12, 8, 13, 9, 14, 10],bricks = 20,ladders = 4) == 17\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],bricks = 50,ladders = 2) == 9\n assert candidate(heights = [4, 12, 2, 7, 3, 18, 20, 3, 19, 10, 5, 21, 17, 8, 15],bricks = 15,ladders = 3) == 13\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],bricks = 100,ladders = 3) == 15\n assert candidate(heights = [5, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],bricks = 50,ladders = 5) == 19\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bricks = 0,ladders = 0) == 19\n assert candidate(heights = [4, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50],bricks = 20,ladders = 4) == 10\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bricks = 100,ladders = 3) == 9\n assert candidate(heights = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 0,ladders = 0) == 49\n assert candidate(heights = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],bricks = 100,ladders = 10) == 59\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bricks = 0,ladders = 0) == 9\n assert candidate(heights = [5, 8, 17, 14, 12, 19, 21, 16, 18, 25, 27, 22, 24, 26, 30],bricks = 30,ladders = 4) == 14\n assert candidate(heights = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],bricks = 50,ladders = 5) == 9\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],bricks = 100,ladders = 5) == 24\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 50,ladders = 5) == 19\n assert candidate(heights = [10, 15, 20, 25, 30, 35, 40],bricks = 30,ladders = 2) == 6\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000],bricks = 0,ladders = 0) == 8\n assert candidate(heights = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],bricks = 15,ladders = 3) == 19\n assert candidate(heights = [3, 17, 9, 16, 14, 3, 17, 13, 19, 20, 15, 2, 18, 12, 1, 12, 14, 9, 1, 19],bricks = 20,ladders = 3) == 14\n assert candidate(heights = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],bricks = 25,ladders = 3) == 9\n assert candidate(heights = [5, 18, 3, 14, 5, 19, 2, 13, 11, 18],bricks = 20,ladders = 3) == 9\n assert candidate(heights = [40, 20, 30, 10, 50, 60, 70, 80, 90],bricks = 100,ladders = 2) == 8\n assert candidate(heights = [1, 2, 3, 4, 5, 15, 20, 25, 30, 35],bricks = 10,ladders = 0) == 4\n assert candidate(heights = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],bricks = 0,ladders = 0) == 29\n assert candidate(heights = [1, 1, 2, 1, 1, 2, 1, 1, 2, 1],bricks = 1,ladders = 1) == 7\n assert candidate(heights = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],bricks = 10,ladders = 0) == 19\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1],bricks = 10,ladders = 5) == 10\n assert candidate(heights = [10, 16, 18, 15, 12, 19, 20, 18, 17, 16],bricks = 15,ladders = 2) == 9\n assert candidate(heights = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],bricks = 0,ladders = 5) == 10\n assert candidate(heights = [5, 4, 3, 2, 1, 0],bricks = 10,ladders = 1) == 5\n assert candidate(heights = [1, 3, 6, 7, 8, 10, 12, 13, 14, 15, 17],bricks = 15,ladders = 2) == 10\n assert candidate(heights = [1, 3, 6, 7, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54],bricks = 100,ladders = 5) == 19\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 30,ladders = 5) == 19\n assert candidate(heights = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],bricks = 30,ladders = 1) == 8\n assert candidate(heights = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],bricks = 5,ladders = 0) == 9\n assert candidate(heights = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],bricks = 100,ladders = 5) == 9\n assert candidate(heights = [4, 10, 15, 20, 25, 30, 35, 40, 45, 50],bricks = 50,ladders = 2) == 9\n assert candidate(heights = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],bricks = 50,ladders = 4) == 9\n assert candidate(heights = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 0,ladders = 0) == 24\n assert candidate(heights = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],bricks = 10,ladders = 1) == 9\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],bricks = 100,ladders = 3) == 19\n assert candidate(heights = [100, 150, 200, 250, 300, 350, 400, 450, 500],bricks = 1000,ladders = 3) == 8\n assert candidate(heights = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5],bricks = 20,ladders = 3) == 9\n assert candidate(heights = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],bricks = 100,ladders = 2) == 9\n assert candidate(heights = [1, 5, 20, 30, 40, 50, 60, 70, 80, 90],bricks = 150,ladders = 2) == 9\n assert candidate(heights = [1, 100, 2, 101, 3, 102, 4, 103, 5],bricks = 100,ladders = 2) == 6\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],bricks = 100,ladders = 5) == 24\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],bricks = 100,ladders = 5) == 13\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 50,ladders = 5) == 9\n assert candidate(heights = [1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000],bricks = 1000000,ladders = 4) == 9\n assert candidate(heights = [5, 18, 12, 15, 20, 10, 19, 21],bricks = 50,ladders = 3) == 7\n assert candidate(heights = [4, 4, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 20,ladders = 2) == 19\n assert candidate(heights = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],bricks = 1,ladders = 1) == 29\n assert candidate(heights = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9],bricks = 30,ladders = 5) == 15\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],bricks = 150,ladders = 5) == 29\n assert candidate(heights = [10, 15, 20, 25, 30, 35, 40, 45, 50],bricks = 30,ladders = 2) == 8\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bricks = 45,ladders = 0) == 9\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],bricks = 100,ladders = 1) == 13\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],bricks = 50,ladders = 5) == 14\n assert candidate(heights = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],bricks = 20,ladders = 3) == 16\n assert candidate(heights = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11],bricks = 50,ladders = 3) == 19\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],bricks = 100,ladders = 3) == 9\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],bricks = 200,ladders = 15) == 39\n assert candidate(heights = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],bricks = 25,ladders = 2) == 8\n assert candidate(heights = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1],bricks = 15,ladders = 2) == 19\n assert candidate(heights = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],bricks = 20,ladders = 3) == 19\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],bricks = 100,ladders = 10) == 19\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 30,ladders = 2) == 19\n assert candidate(heights = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],bricks = 4000,ladders = 5) == 9\n assert candidate(heights = [5, 8, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],bricks = 50,ladders = 3) == 19\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 50,ladders = 4) == 19\n assert candidate(heights = [1, 5, 7, 8, 10, 12, 15, 20, 25, 30],bricks = 15,ladders = 3) == 9\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],bricks = 150,ladders = 10) == 29\n assert candidate(heights = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bricks = 55,ladders = 3) == 8\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 50,ladders = 2) == 19\n assert candidate(heights = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],bricks = 20,ladders = 2) == 6\n assert candidate(heights = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119],bricks = 50,ladders = 5) == 19\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bricks = 50,ladders = 3) == 9\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bricks = 0,ladders = 0) == 31\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bricks = 100,ladders = 0) == 9\n assert candidate(heights = [5, 10, 15, 10, 5, 10, 15, 20, 25, 30],bricks = 40,ladders = 1) == 9\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bricks = 150,ladders = 3) == 9\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],bricks = 100,ladders = 4) == 24\n"}, "metadata": {"canonical_parameter_names": ["heights", "bricks", "ladders"], "leetcode_dataset_entry_point": "Solution().furthestBuilding", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def furthestBuilding(self, heights: list[int], bricks: int, ladders: int) -> int:", "container": "Solution", "callable": "furthestBuilding", "parameters": [{"name": "heights", "type": "list[int]"}, {"name": "bricks", "type": "int"}, {"name": "ladders", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1643, "task_id": "kth-smallest-instructions", "difficulty": "Hard", "problem_description": "Bob is standing at cell (0, 0), and he wants to reach destination: (row, column). He can only travel right and down. You are going to help Bob by providing instructions for him to reach destination.\nThe instructions are represented as a string, where each character is either:\n\n'H', meaning move horizontally (go right), or\n'V', meaning move vertically (go down).\n\nMultiple instructions will lead Bob to destination. For example, if destination is (2, 3), both \"HHHVV\" and \"HVHVH\" are valid instructions.\nHowever, Bob is very picky. Bob has a lucky number k, and he wants the kth lexicographically smallest instructions that will lead him to destination. k is 1-indexed.\nGiven an integer array destination and an integer k, return the kth lexicographically smallest instructions that will take Bob to destination.\n \nExample 1:\n\n\nInput: destination = [2,3], k = 1\nOutput: \"HHHVV\"\nExplanation: All the instructions that reach (2, 3) in lexicographic order are as follows:\n[\"HHHVV\", \"HHVHV\", \"HHVVH\", \"HVHHV\", \"HVHVH\", \"HVVHH\", \"VHHHV\", \"VHHVH\", \"VHVHH\", \"VVHHH\"].\n\nExample 2:\n\n\nInput: destination = [2,3], k = 2\nOutput: \"HHVHV\"\n\nExample 3:\n\n\nInput: destination = [2,3], k = 3\nOutput: \"HHVVH\"\n\n \nConstraints:\n\ndestination.length == 2\n1 <= row, column <= 15\n1 <= k <= nCr(row + column, row), where nCr(a, b) denotes a choose b​​​​​.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(destination = [3, 3],k = 5) == \"HVHHVV\"\n assert candidate(destination = [2, 3],k = 1) == \"HHHVV\"\n assert candidate(destination = [4, 4],k = 10) == \"HHVVHHVV\"\n assert candidate(destination = [3, 3],k = 10) == \"HVVVHH\"\n assert candidate(destination = [2, 3],k = 2) == \"HHVHV\"\n assert candidate(destination = [2, 3],k = 3) == \"HHVVH\"\n assert candidate(destination = [4, 4],k = 20) == \"HVHVHHVV\"\n assert candidate(destination = [4, 5],k = 10) == \"HHHVVHHVV\"\n assert candidate(destination = [15, 15],k = 1) == \"HHHHHHHHHHHHHHHVVVVVVVVVVVVVVV\"\n assert candidate(destination = [3, 2],k = 4) == \"HVVVH\"\n assert candidate(destination = [3, 4],k = 5) == \"HHVHHVV\"\n assert candidate(destination = [5, 5],k = 100) == \"HVVHHVVHVH\"\n assert candidate(destination = [3, 2],k = 1) == \"HHVVV\"\n assert candidate(destination = [3, 10],k = 175) == \"HVHHHHHHVVHHH\"\n assert candidate(destination = [7, 8],k = 1716) == \"HHVVVVVVVHHHHHH\"\n assert candidate(destination = [12, 12],k = 50000) == \"HHHHHVVVVVVVHVVHHVHHVVHH\"\n assert candidate(destination = [15, 5],k = 2000) == \"HVVHVVVVVVVHVVVVVVHH\"\n assert candidate(destination = [9, 5],k = 252) == \"HVHHVVVVHVHVVV\"\n assert candidate(destination = [5, 7],k = 1000) == \"VVVVVVVVVVVV\"\n assert candidate(destination = [7, 9],k = 300) == \"HHHHHVVVVHHVHHVV\"\n assert candidate(destination = [9, 7],k = 5678) == \"VHHVHVHVVHVHVVVH\"\n assert candidate(destination = [10, 10],k = 5000) == \"HHHHVHVVVVVVVVHHHHHV\"\n assert candidate(destination = [9, 9],k = 1000) == \"HHHHVHVHVVVVVVVHHH\"\n assert candidate(destination = [3, 4],k = 15) == \"HVHVHVH\"\n assert candidate(destination = [14, 10],k = 5000) == \"HHHHHVHVVVVVHVHVHVHVVVVV\"\n assert candidate(destination = [15, 15],k = 10000) == \"HHHHHHHHHHVVVHVHVVVHVVVHVVVVVH\"\n assert candidate(destination = [15, 15],k = 500000) == \"HHHHHHVHHHHVVVVVHHVHHVVVVHVVVV\"\n assert candidate(destination = [8, 12],k = 250) == \"HHHHHHHHVHVVHVVVVVHH\"\n assert candidate(destination = [15, 15],k = 40116600) == \"HVHHHVHVHVVHHVVHHVVVVHVHHHVVHV\"\n assert candidate(destination = [10, 5],k = 200) == \"HHVVVHVVVVVVHHV\"\n assert candidate(destination = [12, 5],k = 1234) == \"HVVVHVVHVVVVHVVHV\"\n assert candidate(destination = [5, 15],k = 3003) == \"HHHHHVVVVVHHHHHHHHHH\"\n assert candidate(destination = [12, 8],k = 500) == \"HHHHVHHVVVVHVVHVVVVV\"\n assert candidate(destination = [7, 6],k = 150) == \"HHVHVHHVHVVVV\"\n assert candidate(destination = [3, 7],k = 123) == \"VVVVVVVVVV\"\n assert candidate(destination = [13, 7],k = 4000) == \"HHVHVVVVVVHHVHVVHVVV\"\n assert candidate(destination = [12, 12],k = 100000) == \"HHHHVVHVVVVHHHHVVHVHVHVV\"\n assert candidate(destination = [2, 13],k = 150) == \"VVVVVVVVVVVVVVV\"\n assert candidate(destination = [10, 10],k = 500) == \"HHHHHHVHVVVVVVVHVHHV\"\n assert candidate(destination = [10, 10],k = 1000) == \"HHHHHHVVVVVVVVVHVHHH\"\n assert candidate(destination = [7, 5],k = 30) == \"HHHVVVVHVVVH\"\n assert candidate(destination = [6, 6],k = 500) == \"VHHHVVHHVHVV\"\n assert candidate(destination = [9, 9],k = 10000) == \"HHVVVHHVHVHHVVHHVV\"\n assert candidate(destination = [6, 7],k = 120) == \"HHHVHVHVVVVHH\"\n assert candidate(destination = [8, 9],k = 500) == \"HHHHVHHHHVVVVHVVV\"\n assert candidate(destination = [15, 15],k = 1000000) == \"HHHHHHVVHVVVVHVVVVHHHVHVVVHHHV\"\n assert candidate(destination = [1, 15],k = 1) == \"HHHHHHHHHHHHHHHV\"\n assert candidate(destination = [10, 10],k = 10000) == \"HHHVHHVVVVVVVHVHHHHV\"\n assert candidate(destination = [10, 10],k = 1000) == \"HHHHHHVVVVVVVVVHVHHH\"\n assert candidate(destination = [7, 8],k = 3000) == \"HVVHVHVVHHHHVVH\"\n assert candidate(destination = [3, 10],k = 100) == \"HHHVHHVHHHHHV\"\n assert candidate(destination = [12, 8],k = 5000) == \"HHHVVVVHHVVHVVHVVVVH\"\n assert candidate(destination = [10, 5],k = 200) == \"HHVVVHVVVVVVHHV\"\n assert candidate(destination = [10, 10],k = 50000) == \"HVHHVHHVVVVVHHHVHVHV\"\n assert candidate(destination = [7, 7],k = 343) == \"HHVHHHVHVVVVVH\"\n assert candidate(destination = [7, 8],k = 1000) == \"HHVHHVVVVVHHVHH\"\n assert candidate(destination = [5, 4],k = 50) == \"HVVVHVHHV\"\n assert candidate(destination = [7, 8],k = 2000) == \"HVHHVHVHVHHVVHV\"\n assert candidate(destination = [3, 12],k = 200) == \"HHHVHHVHVHHHHHH\"\n assert candidate(destination = [6, 14],k = 10000) == \"HHHVHHVVVHVVHHHHHHHH\"\n assert candidate(destination = [8, 9],k = 15000) == \"VHHVHHVVVHHHVVHHV\"\n assert candidate(destination = [12, 4],k = 250) == \"HVVVHVHVVVVHVVVV\"\n assert candidate(destination = [7, 8],k = 1234) == \"HHVHVVVVHHHHHVV\"\n assert candidate(destination = [8, 7],k = 3456) == \"VHHVHVHVVHHVVHV\"\n assert candidate(destination = [13, 2],k = 100) == \"VVVVVVVVVVVHHVV\"\n assert candidate(destination = [11, 11],k = 6000) == \"HHHHHVHVHVVVVHVVHVHVHV\"\n assert candidate(destination = [7, 7],k = 200) == \"HHHVHVVVVHVVHH\"\n assert candidate(destination = [15, 15],k = 12345) == \"HHHHHHHHHHVVVVHVVVVVHVVHHVVVVH\"\n assert candidate(destination = [8, 12],k = 3456) == \"HHHHHVHHVHVHVVHHVVHV\"\n assert candidate(destination = [6, 9],k = 300) == \"HHHHVHVHVVVHVHH\"\n assert candidate(destination = [14, 6],k = 5000) == \"HVHVVVVVHVHVHVHVVVVV\"\n assert candidate(destination = [10, 6],k = 8316) == \"VVVVVVVVVVVVVVVV\"\n assert candidate(destination = [15, 15],k = 10000) == \"HHHHHHHHHHVVVHVHVVVHVVVHVVVVVH\"\n assert candidate(destination = [12, 12],k = 123456) == \"HHHHVVVVVVHHVHHHVHVHHVVV\"\n assert candidate(destination = [10, 10],k = 12870) == \"HHHVHVVVVVHHVVVHHHVH\"\n assert candidate(destination = [14, 6],k = 98765) == \"VVVVVVVVVVVVVVVVVVVV\"\n assert candidate(destination = [8, 6],k = 150) == \"HHHVVVVVHVHHVV\"\n assert candidate(destination = [7, 6],k = 300) == \"HHVVVVHHVHHVV\"\n assert candidate(destination = [12, 8],k = 2500) == \"HHHVHVVHHVVVHVVHVVVV\"\n assert candidate(destination = [5, 6],k = 120) == \"HHVVVHVHVHH\"\n assert candidate(destination = [6, 7],k = 500) == \"HVHHHVVHHVHVV\"\n assert candidate(destination = [9, 7],k = 200) == \"HHHHVVVVVHVVVVHH\"\n assert candidate(destination = [8, 6],k = 500) == \"HVHHHHVVVVHVVV\"\n assert candidate(destination = [15, 15],k = 6435678) == \"HHHHVVVHHHVHHVVVVHVVHHHVHVHVVV\"\n assert candidate(destination = [4, 12],k = 500) == \"HHHVHHHHHHHVHHVV\"\n assert candidate(destination = [8, 7],k = 650) == \"HHVHVHVHVHHVVVV\"\n assert candidate(destination = [6, 7],k = 123) == \"HHHVHVVHHVVHV\"\n assert candidate(destination = [12, 3],k = 200) == \"VVHVVVHHVVVVVVV\"\n assert candidate(destination = [5, 12],k = 500) == \"HHHHHVHHHVHHHVVHV\"\n assert candidate(destination = [5, 7],k = 30) == \"HHHHVHVHVVVH\"\n assert candidate(destination = [6, 4],k = 45) == \"HVHVVVHVHV\"\n assert candidate(destination = [15, 1],k = 1) == \"HVVVVVVVVVVVVVVV\"\n assert candidate(destination = [6, 8],k = 300) == \"HHHVHVHVVVHVHH\"\n"}, "metadata": {"canonical_parameter_names": ["destination", "k"], "leetcode_dataset_entry_point": "Solution().kthSmallestPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def kthSmallestPath(self, destination: list[int], k: int) -> str:", "container": "Solution", "callable": "kthSmallestPath", "parameters": [{"name": "destination", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1646, "task_id": "get-maximum-in-generated-array", "difficulty": "Easy", "problem_description": "You are given an integer n. A 0-indexed integer array nums of length n + 1 is generated in the following way:\n\nnums[0] = 0\nnums[1] = 1\nnums[2 * i] = nums[i] when 2 <= 2 * i <= n\nnums[2 * i + 1] = nums[i] + nums[i + 1] when 2 <= 2 * i + 1 <= n\n\nReturn the maximum integer in the array nums​​​.\n \nExample 1:\n\nInput: n = 7\nOutput: 3\nExplanation: According to the given rules:\n nums[0] = 0\n nums[1] = 1\n nums[(1 * 2) = 2] = nums[1] = 1\n nums[(1 * 2) + 1 = 3] = nums[1] + nums[2] = 1 + 1 = 2\n nums[(2 * 2) = 4] = nums[2] = 1\n nums[(2 * 2) + 1 = 5] = nums[2] + nums[3] = 1 + 2 = 3\n nums[(3 * 2) = 6] = nums[3] = 2\n nums[(3 * 2) + 1 = 7] = nums[3] + nums[4] = 2 + 1 = 3\nHence, nums = [0,1,1,2,1,3,2,3], and the maximum is max(0,1,1,2,1,3,2,3) = 3.\n\nExample 2:\n\nInput: n = 2\nOutput: 1\nExplanation: According to the given rules, nums = [0,1,1]. The maximum is max(0,1,1) = 1.\n\nExample 3:\n\nInput: n = 3\nOutput: 2\nExplanation: According to the given rules, nums = [0,1,1,2]. The maximum is max(0,1,1,2) = 2.\n\n \nConstraints:\n\n0 <= n <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 0\n assert candidate(n = 3) == 2\n assert candidate(n = 100) == 21\n assert candidate(n = 99) == 21\n assert candidate(n = 2) == 1\n assert candidate(n = 20) == 7\n assert candidate(n = 1) == 1\n assert candidate(n = 50) == 13\n assert candidate(n = 7) == 3\n assert candidate(n = 10) == 4\n assert candidate(n = 88) == 21\n assert candidate(n = 97) == 21\n assert candidate(n = 63) == 13\n assert candidate(n = 45) == 13\n assert candidate(n = 49) == 13\n assert candidate(n = 47) == 13\n assert candidate(n = 60) == 13\n assert candidate(n = 64) == 13\n assert candidate(n = 37) == 11\n assert candidate(n = 17) == 5\n assert candidate(n = 42) == 11\n assert candidate(n = 90) == 21\n assert candidate(n = 22) == 8\n assert candidate(n = 89) == 21\n assert candidate(n = 75) == 18\n assert candidate(n = 81) == 18\n assert candidate(n = 24) == 8\n assert candidate(n = 11) == 5\n assert candidate(n = 15) == 5\n assert candidate(n = 31) == 8\n assert candidate(n = 25) == 8\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().getMaximumGenerated", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getMaximumGenerated(self, n: int) -> int:", "container": "Solution", "callable": "getMaximumGenerated", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1647, "task_id": "minimum-deletions-to-make-character-frequencies-unique", "difficulty": "Medium", "problem_description": "A string s is called good if there are no two different characters in s that have the same frequency.\nGiven a string s, return the minimum number of characters you need to delete to make s good.\nThe frequency of a character in a string is the number of times it appears in the string. For example, in the string \"aab\", the frequency of 'a' is 2, while the frequency of 'b' is 1.\n \nExample 1:\n\nInput: s = \"aab\"\nOutput: 0\nExplanation: s is already good.\n\nExample 2:\n\nInput: s = \"aaabbbcc\"\nOutput: 2\nExplanation: You can delete two 'b's resulting in the good string \"aaabcc\".\nAnother way it to delete one 'b' and one 'c' resulting in the good string \"aaabbc\".\nExample 3:\n\nInput: s = \"ceabaacb\"\nOutput: 2\nExplanation: You can delete both 'c's resulting in the good string \"eabaab\".\nNote that we only care about characters that are still in the string at the end (i.e. frequency of 0 is ignored).\n\n \nConstraints:\n\n1 <= s.length <= 105\ns contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aab\") == 0\n assert candidate(s = \"aabacabadabaeabafabagabahabaiabajabakabalabamabanabaoabapabaqabarabasabataabuabavabawabaxabayabajabaz\") == 22\n assert candidate(s = \"abcabcabc\") == 3\n assert candidate(s = \"aabbbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiii\") == 2\n assert candidate(s = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzz\") == 24\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 49\n assert candidate(s = \"ceabaacb\") == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aaabbbcc\") == 2\n assert candidate(s = \"aabbccddeeffgghhii\") == 15\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(s = \"a\") == 0\n assert candidate(s = \"zzzzzzzzzzyyyyyyyyyxxxxxxxwwwwwwvvvvuuuuutttttsssssrrrrqqqqppppooooonnnnmmmmlllkkkjjjiii\") == 41\n assert candidate(s = \"aabbccddeeefffggg\") == 11\n assert candidate(s = \"aabbccddeeefffhhhiiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 48\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 47\n assert candidate(s = \"pppppppppooooooonnnnnmmmllllllkkkkjjjjiiiiiiiihhhhhhhggggggg\") == 15\n assert candidate(s = \"aabbbccccddddeeeee\") == 3\n assert candidate(s = \"abababababababababab\") == 1\n assert candidate(s = \"zzzzzzzzzzzyyyyyyyxxxxxxxwwwwwwvvvvuuuutttssrrqponmlkjihgfedcba\") == 24\n assert candidate(s = \"aabbbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiiijjjjjjjjjj\") == 2\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minDeletions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minDeletions(self, s: str) -> int:", "container": "Solution", "callable": "minDeletions", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1648, "task_id": "sell-diminishing-valued-colored-balls", "difficulty": "Medium", "problem_description": "You have an inventory of different colored balls, and there is a customer that wants orders balls of any color.\nThe customer weirdly values the colored balls. Each colored ball's value is the number of balls of that color you currently have in your inventory. For example, if you own 6 yellow balls, the customer would pay 6 for the first yellow ball. After the transaction, there are only 5 yellow balls left, so the next yellow ball is then valued at 5 (i.e., the value of the balls decreases as you sell more to the customer).\nYou are given an integer array, inventory, where inventory[i] represents the number of balls of the ith color that you initially own. You are also given an integer orders, which represents the total number of balls that the customer wants. You can sell the balls in any order.\nReturn the maximum total value that you can attain after selling orders colored balls. As the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: inventory = [2,5], orders = 4\nOutput: 14\nExplanation: Sell the 1st color 1 time (2) and the 2nd color 3 times (5 + 4 + 3).\nThe maximum total value is 2 + 5 + 4 + 3 = 14.\n\nExample 2:\n\nInput: inventory = [3,5], orders = 6\nOutput: 19\nExplanation: Sell the 1st color 2 times (3 + 2) and the 2nd color 4 times (5 + 4 + 3 + 2).\nThe maximum total value is 3 + 2 + 5 + 4 + 3 + 2 = 19.\n\n \nConstraints:\n\n1 <= inventory.length <= 105\n1 <= inventory[i] <= 109\n1 <= orders <= min(sum(inventory[i]), 109)\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(inventory = [10, 10, 10],orders = 5) == 48\n assert candidate(inventory = [3, 5],orders = 6) == 19\n assert candidate(inventory = [1, 2, 3, 4, 5],orders = 10) == 30\n assert candidate(inventory = [1, 1, 1, 1, 1],orders = 3) == 3\n assert candidate(inventory = [7],orders = 7) == 28\n assert candidate(inventory = [1000000000, 1000000000],orders = 1000000000) == 250000035\n assert candidate(inventory = [1000000000],orders = 1) == 1000000000\n assert candidate(inventory = [5, 5, 5, 5, 5],orders = 20) == 70\n assert candidate(inventory = [1000000000],orders = 1000000000) == 21\n assert candidate(inventory = [2, 5],orders = 4) == 14\n assert candidate(inventory = [100],orders = 10) == 955\n assert candidate(inventory = [9, 9, 9, 9, 9, 9],orders = 25) == 185\n assert candidate(inventory = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20],orders = 350) == 4110\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 5) == 5\n assert candidate(inventory = [100, 90, 80, 70, 60],orders = 200) == 12600\n assert candidate(inventory = [1000000, 2000000, 3000000],orders = 5000000) == 335785502\n assert candidate(inventory = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],orders = 100) == 500\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 50) == 215\n assert candidate(inventory = [1000, 2000, 3000, 4000, 5000],orders = 10000) == 25005000\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 55) == 220\n assert candidate(inventory = [5, 15, 25, 35, 45],orders = 35) == 1138\n assert candidate(inventory = [100000000, 100000000, 100000000],orders = 299999997) == 44999997\n assert candidate(inventory = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],orders = 50) == 150\n assert candidate(inventory = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],orders = 900) == 70200\n assert candidate(inventory = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],orders = 500) == 37750\n assert candidate(inventory = [1000000000, 500000000, 250000000, 125000000, 62500000],orders = 999999999) == 312500027\n assert candidate(inventory = [500000000, 400000000, 300000000, 200000000, 100000000],orders = 1500000000) == 825000014\n assert candidate(inventory = [100, 200, 300, 400, 500],orders = 1000) == 250500\n assert candidate(inventory = [100000000, 200000000, 300000000, 400000000, 500000000],orders = 900000000) == 778750014\n assert candidate(inventory = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],orders = 50) == 400\n assert candidate(inventory = [999999999, 999999999, 999999999, 999999999, 999999999],orders = 500000000) == 425000028\n assert candidate(inventory = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],orders = 500) == 37750\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],orders = 190) == 1520\n assert candidate(inventory = [50, 40, 30, 20, 10],orders = 100) == 2550\n assert candidate(inventory = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],orders = 1500) == 134972\n assert candidate(inventory = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],orders = 5000) == 1915000\n assert candidate(inventory = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20],orders = 500) == 6080\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 10) == 10\n assert candidate(inventory = [3, 5, 7, 9],orders = 15) == 79\n assert candidate(inventory = [1000000000, 1000000000, 1000000000, 1000000000],orders = 3000000000) == 375000084\n assert candidate(inventory = [500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000],orders = 4500000) == 502241341\n assert candidate(inventory = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],orders = 550) == 19525\n assert candidate(inventory = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],orders = 10000) == 6071070\n assert candidate(inventory = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],orders = 1000) == 66330\n assert candidate(inventory = [1, 3, 5, 7, 9],orders = 15) == 79\n assert candidate(inventory = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],orders = 7500) == 5500000\n assert candidate(inventory = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],orders = 50) == 110\n assert candidate(inventory = [999999999, 999999999, 999999999, 999999999, 999999999],orders = 4999999995) == 140\n assert candidate(inventory = [10, 10, 20, 20, 30, 30],orders = 50) == 1012\n assert candidate(inventory = [30, 25, 20, 15, 10, 5, 0],orders = 75) == 1100\n assert candidate(inventory = [10, 20, 30, 40, 50],orders = 100) == 2550\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 20) == 20\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 10) == 10\n assert candidate(inventory = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],orders = 300) == 16124\n assert candidate(inventory = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],orders = 200) == 9100\n assert candidate(inventory = [10, 20, 30, 40, 50],orders = 50) == 1708\n assert candidate(inventory = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],orders = 1500) == 94500\n assert candidate(inventory = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],orders = 40) == 110\n assert candidate(inventory = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],orders = 100) == 715\n assert candidate(inventory = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],orders = 25000) == 144369642\n assert candidate(inventory = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],orders = 1000000000) == 46\n assert candidate(inventory = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],orders = 40) == 200\n assert candidate(inventory = [10, 8, 6, 4, 2],orders = 15) == 94\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 45) == 210\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],orders = 50) == 465\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 50) == 50\n assert candidate(inventory = [50, 20, 10, 5, 1],orders = 50) == 1375\n assert candidate(inventory = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],orders = 500) == 19375\n assert candidate(inventory = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],orders = 100) == 1155\n assert candidate(inventory = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],orders = 100) == 800\n assert candidate(inventory = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],orders = 10000) == 75005000\n assert candidate(inventory = [1000000000, 500000000, 250000000, 125000000, 62500000],orders = 1000000000) == 562500028\n assert candidate(inventory = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],orders = 1000000) == 499475\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 30) == 174\n assert candidate(inventory = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990],orders = 1000000000) == 350000124\n assert candidate(inventory = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],orders = 50) == 460\n assert candidate(inventory = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],orders = 1000) == 750500\n assert candidate(inventory = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],orders = 200) == 14627\n assert candidate(inventory = [1000000000, 1000000000, 1000000000, 1000000000],orders = 4000000000) == 84\n assert candidate(inventory = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],orders = 45) == 145\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],orders = 190) == 1520\n assert candidate(inventory = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],orders = 1000) == 175234\n assert candidate(inventory = [50, 40, 30, 20, 10],orders = 150) == 2825\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],orders = 150) == 1416\n assert candidate(inventory = [10, 20, 30, 40, 50],orders = 100) == 2550\n assert candidate(inventory = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],orders = 4999999995) == 100\n assert candidate(inventory = [500000000, 500000000, 500000000, 500000000, 500000000],orders = 2000000000) == 800000028\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 55) == 220\n"}, "metadata": {"canonical_parameter_names": ["inventory", "orders"], "leetcode_dataset_entry_point": "Solution().maxProfit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxProfit(self, inventory: list[int], orders: int) -> int:", "container": "Solution", "callable": "maxProfit", "parameters": [{"name": "inventory", "type": "list[int]"}, {"name": "orders", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1649, "task_id": "create-sorted-array-through-instructions", "difficulty": "Hard", "problem_description": "Given an integer array instructions, you are asked to create a sorted array from the elements in instructions. You start with an empty container nums. For each element from left to right in instructions, insert it into nums. The cost of each insertion is the minimum of the following:\\r\n\\r\n\\r\n\tThe number of elements currently in nums that are strictly less than instructions[i].\\r\n\tThe number of elements currently in nums that are strictly greater than instructions[i].\\r\n\\r\n\\r\nFor example, if inserting element 3 into nums = [1,2,3,5], the cost of insertion is min(2, 1) (elements 1 and 2 are less than 3, element 5 is greater than 3) and nums will become [1,2,3,3,5].\\r\n\\r\nReturn the total cost to insert all elements from instructions into nums. Since the answer may be large, return it modulo 109 + 7\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: instructions = [1,5,6,2]\\r\nOutput: 1\\r\nExplanation: Begin with nums = [].\\r\nInsert 1 with cost min(0, 0) = 0, now nums = [1].\\r\nInsert 5 with cost min(1, 0) = 0, now nums = [1,5].\\r\nInsert 6 with cost min(2, 0) = 0, now nums = [1,5,6].\\r\nInsert 2 with cost min(1, 2) = 1, now nums = [1,2,5,6].\\r\nThe total cost is 0 + 0 + 0 + 1 = 1.\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: instructions = [1,2,3,6,5,4]\\r\nOutput: 3\\r\nExplanation: Begin with nums = [].\\r\nInsert 1 with cost min(0, 0) = 0, now nums = [1].\\r\nInsert 2 with cost min(1, 0) = 0, now nums = [1,2].\\r\nInsert 3 with cost min(2, 0) = 0, now nums = [1,2,3].\\r\nInsert 6 with cost min(3, 0) = 0, now nums = [1,2,3,6].\\r\nInsert 5 with cost min(3, 1) = 1, now nums = [1,2,3,5,6].\\r\nInsert 4 with cost min(3, 2) = 2, now nums = [1,2,3,4,5,6].\\r\nThe total cost is 0 + 0 + 0 + 0 + 1 + 2 = 3.\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: instructions = [1,3,3,3,2,4,2,1,2]\\r\nOutput: 4\\r\nExplanation: Begin with nums = [].\\r\nInsert 1 with cost min(0, 0) = 0, now nums = [1].\\r\nInsert 3 with cost min(1, 0) = 0, now nums = [1,3].\\r\nInsert 3 with cost min(1, 0) = 0, now nums = [1,3,3].\\r\nInsert 3 with cost min(1, 0) = 0, now nums = [1,3,3,3].\\r\nInsert 2 with cost min(1, 3) = 1, now nums = [1,2,3,3,3].\\r\nInsert 4 with cost min(5, 0) = 0, now nums = [1,2,3,3,3,4].\\r\n​​​​​​​Insert 2 with cost min(1, 4) = 1, now nums = [1,2,2,3,3,3,4].\\r\n​​​​​​​Insert 1 with cost min(0, 6) = 0, now nums = [1,1,2,2,3,3,3,4].\\r\n​​​​​​​Insert 2 with cost min(2, 4) = 2, now nums = [1,1,2,2,2,3,3,3,4].\\r\nThe total cost is 0 + 0 + 0 + 0 + 1 + 0 + 1 + 0 + 2 = 4.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= instructions.length <= 105\\r\n\t1 <= instructions[i] <= 105\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(instructions = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(instructions = [50000, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009]) == 0\n assert candidate(instructions = [1, 2, 3, 6, 5, 4]) == 3\n assert candidate(instructions = [1, 5, 6, 2]) == 1\n assert candidate(instructions = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 20\n assert candidate(instructions = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 20\n assert candidate(instructions = [1, 3, 3, 3, 2, 4, 2, 1, 2]) == 4\n assert candidate(instructions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(instructions = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(instructions = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9]) == 5\n assert candidate(instructions = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == 10\n assert candidate(instructions = [50000, 40000, 30000, 20000, 10000, 60000, 70000, 80000, 90000, 100000]) == 0\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 27\n assert candidate(instructions = [5, 3, 8, 6, 2, 7, 4, 1, 10, 9]) == 5\n assert candidate(instructions = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 10\n assert candidate(instructions = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 32\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 75\n assert candidate(instructions = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 4\n assert candidate(instructions = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 0\n assert candidate(instructions = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 27\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 75\n assert candidate(instructions = [9, 3, 8, 3, 7, 3, 6, 3, 5, 3, 4, 3, 2, 3, 1, 3]) == 18\n assert candidate(instructions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 24\n assert candidate(instructions = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 75\n assert candidate(instructions = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(instructions = [1, 2, 3, 6, 5, 4, 1, 2, 3, 6, 5, 4]) == 14\n assert candidate(instructions = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15]) == 10\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 75\n assert candidate(instructions = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 30\n assert candidate(instructions = [5, 4, 3, 2, 1]) == 0\n assert candidate(instructions = [1, 3, 2, 6, 5, 4, 9, 8, 7, 10, 1, 3, 2, 6, 5, 4, 9, 8, 7, 10, 1, 3, 2, 6, 5, 4, 9, 8, 7, 10]) == 88\n assert candidate(instructions = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 0\n assert candidate(instructions = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 60\n assert candidate(instructions = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10]) == 16\n assert candidate(instructions = [10, 20, 30, 40, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == 22\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 75\n assert candidate(instructions = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 27\n assert candidate(instructions = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 0\n assert candidate(instructions = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(instructions = [100000, 99999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 33\n assert candidate(instructions = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 27\n assert candidate(instructions = [50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 14\n assert candidate(instructions = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 36\n assert candidate(instructions = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993]) == 56\n assert candidate(instructions = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1]) == 0\n assert candidate(instructions = [10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9]) == 0\n assert candidate(instructions = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(instructions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 0\n assert candidate(instructions = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 20\n assert candidate(instructions = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 10\n assert candidate(instructions = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == 60\n assert candidate(instructions = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16]) == 25\n assert candidate(instructions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\n assert candidate(instructions = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(instructions = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n assert candidate(instructions = [1, 3, 2, 4, 2, 3, 1, 4, 2, 3]) == 7\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 0\n assert candidate(instructions = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 75\n assert candidate(instructions = [3, 1, 2, 5, 4, 6, 9, 7, 10, 8]) == 5\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 30\n assert candidate(instructions = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 0\n assert candidate(instructions = [50000, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009, 50000, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009]) == 27\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 30\n assert candidate(instructions = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 45\n assert candidate(instructions = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 27\n assert candidate(instructions = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 0\n assert candidate(instructions = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 317\n assert candidate(instructions = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(instructions = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9]) == 9\n assert candidate(instructions = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 0\n assert candidate(instructions = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 27\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(instructions = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 21\n assert candidate(instructions = [100000, 50000, 75000, 25000, 62500, 37500, 87500, 12500, 93750, 43750, 68750, 31250, 81250, 18750, 90625, 46875, 71875, 28125, 89062, 40625, 65625, 34375, 84375, 21875, 82812, 45312, 70312, 29687, 88281, 49218, 74218, 32187, 86171, 42187, 67187, 35156, 83125, 23437, 85937, 50312, 75312, 37812, 81562, 44531, 69531, 33437, 87968, 47968, 72968, 30937, 90468, 52968, 77968, 38906, 85468, 55468, 80468, 43437, 92460, 57460, 82460, 47460, 91718, 61718, 86718, 52656, 94359, 66359, 91359, 57359, 93671, 69671, 94671, 73671, 86913, 64406, 93406, 68406, 92406, 65406, 95507, 70507, 90507, 67507, 92753, 75253, 87753, 62753, 94753, 78753, 83753, 71753, 88281, 53281, 88281, 58281, 83281, 50281, 81281, 45281, 86281, 51281, 82281, 46281, 84281, 48281, 85281, 50281, 87281, 52281, 89281, 54281, 90281, 56281, 91281, 58281, 92281, 60281, 93281, 62281, 94281, 64281, 95281, 66281, 96281, 68281, 97281, 70281, 98281, 72281, 99281, 74281, 100000]) == 2291\n assert candidate(instructions = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 65\n assert candidate(instructions = [5, 1, 4, 2, 3, 8, 6, 7, 10, 9, 5, 5, 5, 5, 5]) == 27\n assert candidate(instructions = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 0\n assert candidate(instructions = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 27\n assert candidate(instructions = [7, 7, 7, 7, 7, 7, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 27\n assert candidate(instructions = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 84\n assert candidate(instructions = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 15\n assert candidate(instructions = [2, 3, 1, 4, 5, 1, 3, 2, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 27\n assert candidate(instructions = [100000, 100000, 100000, 1, 1, 1, 50000, 50000, 50000, 25000]) == 12\n assert candidate(instructions = [1, 2, 3, 4, 5, 100000, 99999, 99998, 99997, 99996]) == 10\n assert candidate(instructions = [5, 4, 3, 2, 1, 100000, 99999, 99998, 99997, 99996]) == 10\n assert candidate(instructions = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 0\n assert candidate(instructions = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9, 1000, 10]) == 45\n assert candidate(instructions = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 27\n assert candidate(instructions = [50000, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009]) == 0\n assert candidate(instructions = [5, 3, 1, 2, 4, 6, 8, 7, 10, 9]) == 4\n assert candidate(instructions = [100, 200, 300, 400, 500, 500, 400, 300, 200, 100]) == 5\n assert candidate(instructions = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 95000, 92500, 90000, 87500, 85000, 82500, 80000, 77500, 75000, 72500]) == 52\n assert candidate(instructions = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 1]) == 0\n assert candidate(instructions = [5, 1, 9, 2, 8, 3, 7, 4, 6, 10]) == 12\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 32\n"}, "metadata": {"canonical_parameter_names": ["instructions"], "leetcode_dataset_entry_point": "Solution().createSortedArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def createSortedArray(self, instructions: List[int]) -> int:", "container": "Solution", "callable": "createSortedArray", "parameters": [{"name": "instructions", "type": "List[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1652, "task_id": "defuse-the-bomb", "difficulty": "Easy", "problem_description": "You have a bomb to defuse, and your time is running out! Your informer will provide you with a circular array code of length of n and a key k.\nTo decrypt the code, you must replace every number. All the numbers are replaced simultaneously.\n\nIf k > 0, replace the ith number with the sum of the next k numbers.\nIf k < 0, replace the ith number with the sum of the previous k numbers.\nIf k == 0, replace the ith number with 0.\n\nAs code is circular, the next element of code[n-1] is code[0], and the previous element of code[0] is code[n-1].\nGiven the circular array code and an integer key k, return the decrypted code to defuse the bomb!\n \nExample 1:\n\nInput: code = [5,7,1,4], k = 3\nOutput: [12,10,16,13]\nExplanation: Each number is replaced by the sum of the next 3 numbers. The decrypted code is [7+1+4, 1+4+5, 4+5+7, 5+7+1]. Notice that the numbers wrap around.\n\nExample 2:\n\nInput: code = [1,2,3,4], k = 0\nOutput: [0,0,0,0]\nExplanation: When k is zero, the numbers are replaced by 0. \n\nExample 3:\n\nInput: code = [2,4,9,3], k = -2\nOutput: [12,5,6,13]\nExplanation: The decrypted code is [3+9, 2+3, 4+2, 9+4]. Notice that the numbers wrap around again. If k is negative, the sum is of the previous numbers.\n\n \nConstraints:\n\nn == code.length\n1 <= n <= 100\n1 <= code[i] <= 100\n-(n - 1) <= k <= n - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(code = [7, 8, 9, 10],k = 4) == [34, 34, 34, 34]\n assert candidate(code = [7, 8, 9],k = 1) == [8, 9, 7]\n assert candidate(code = [6, 5, 4, 3, 2, 1],k = -1) == [1, 6, 5, 4, 3, 2]\n assert candidate(code = [1, 2, 3],k = -3) == [6, 6, 6]\n assert candidate(code = [1, 1, 1, 1, 1],k = -1) == [1, 1, 1, 1, 1]\n assert candidate(code = [5, 7, 1, 4],k = 3) == [12, 10, 16, 13]\n assert candidate(code = [1, 1, 1, 1, 1],k = -5) == [5, 5, 5, 5, 5]\n assert candidate(code = [8, 9, 4, 7],k = 4) == [28, 28, 28, 28]\n assert candidate(code = [8, 6, 4, 2],k = -3) == [12, 14, 16, 18]\n assert candidate(code = [6, 5, 4, 3, 2, 1],k = -3) == [6, 9, 12, 15, 12, 9]\n assert candidate(code = [2, 4, 9, 3],k = -2) == [12, 5, 6, 13]\n assert candidate(code = [10, 20, 30, 40, 50],k = -1) == [50, 10, 20, 30, 40]\n assert candidate(code = [3, 3, 3, 3],k = 1) == [3, 3, 3, 3]\n assert candidate(code = [5, 5, 5, 5, 5],k = -1) == [5, 5, 5, 5, 5]\n assert candidate(code = [10, 20, 30, 40, 50],k = 2) == [50, 70, 90, 60, 30]\n assert candidate(code = [15, 20, 25],k = 0) == [0, 0, 0]\n assert candidate(code = [1, 2, 3, 4],k = 0) == [0, 0, 0, 0]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = -3) == [6, 12, 18, 24, 21, 18, 15, 12, 9]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = -5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(code = [3, 3, 3, 3],k = 0) == [0, 0, 0, 0]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = -20) == [410, 400, 390, 380, 370, 360, 350, 340, 330, 320, 310, 300, 290, 280, 270, 260, 250, 240, 230, 220, 210, 230, 250, 270, 290, 310, 330, 350, 370, 390]\n assert candidate(code = [7, 14, 21, 28, 35, 42],k = 3) == [63, 84, 105, 84, 63, 42]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = -4) == [170, 140, 110, 80, 50, 70, 90, 110, 130, 150]\n assert candidate(code = [50, 40, 30, 20, 10],k = -4) == [100, 110, 120, 130, 140]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == [20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 75, 60, 45, 30, 15]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = -18) == [396, 392, 388, 384, 380, 376, 372, 368, 364, 360, 356, 352, 348, 344, 340, 336, 332, 328, 324, 360]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == [14, 18, 22, 26, 30, 34, 28, 22, 16, 10]\n assert candidate(code = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = -10) == [385, 385, 385, 385, 385, 385, 385, 385, 385, 385]\n assert candidate(code = [7, 8, 9, 10, 11, 12, 13, 14, 15],k = -4) == [54, 49, 44, 39, 34, 38, 42, 46, 50]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == [5, 7, 9, 11, 13, 15, 17, 19, 11, 3]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == [450, 460, 470, 480, 490, 500, 510, 520, 530, 540]\n assert candidate(code = [10, 20, 30, 40, 50],k = -5) == [150, 150, 150, 150, 150]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 5) == [35, 45, 55, 65, 75, 85, 95, 81, 67, 53, 39, 25]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = -10) == [105, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 65, 75, 85, 95]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == [20, 25, 30, 35, 40, 35, 30, 25, 20, 15]\n assert candidate(code = [12, 24, 36, 48, 60, 72, 84, 96, 108],k = -6) == [468, 432, 396, 360, 324, 288, 252, 324, 396]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 3) == [45, 60, 75, 90, 105, 120, 135, 100, 65, 30]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = -5) == [80, 70, 60, 50, 40, 30, 40, 50, 60, 70]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26],k = -6) == [126, 112, 98, 84, 70, 56, 42, 54, 66, 78, 90, 102, 114]\n assert candidate(code = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9) == [540, 530, 520, 510, 500, 490, 480, 470, 460, 450]\n assert candidate(code = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = -9) == [594, 583, 572, 561, 550, 539, 528, 517, 506, 495]\n assert candidate(code = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4) == [140, 180, 220, 260, 300, 340, 280, 220, 160, 100]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == [240, 210, 180, 150, 120, 90, 60, 130, 200, 270]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = -5) == [150, 200, 250, 300, 350, 400, 350, 300, 250, 200]\n assert candidate(code = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 0) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = -2) == [3, 10, 17, 15, 13, 11, 9, 7, 5]\n assert candidate(code = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325],k = -6) == [1575, 1400, 1225, 1050, 875, 700, 525, 675, 825, 975, 1125, 1275, 1425]\n assert candidate(code = [7, 14, 21, 28, 35],k = -4) == [98, 91, 84, 77, 70]\n assert candidate(code = [9, 18, 27, 36, 45, 54, 63, 72, 81],k = 6) == [243, 297, 351, 324, 297, 270, 243, 216, 189]\n assert candidate(code = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 6) == [240, 300, 360, 420, 480, 430, 380, 330, 280, 230, 180]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = -4) == [34, 28, 22, 16, 10, 14, 18, 22, 26, 30]\n assert candidate(code = [10, 20, 30, 40, 50],k = 2) == [50, 70, 90, 60, 30]\n assert candidate(code = [97, 98, 99, 100],k = -1) == [100, 97, 98, 99]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 19) == [1045, 1040, 1035, 1030, 1025, 1020, 1015, 1010, 1005, 1000, 995, 990, 985, 980, 975, 970, 965, 960, 955, 950]\n assert candidate(code = [10, 20, 30, 40, 50],k = 4) == [140, 130, 120, 110, 100]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19) == [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = -2) == [3, 10, 17, 15, 13, 11, 9, 7, 5]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5) == [350, 300, 250, 200, 150, 200, 250, 300, 350, 400]\n assert candidate(code = [42, 84, 126, 168, 210, 252, 294, 336],k = 4) == [588, 756, 924, 1092, 924, 756, 588, 420]\n assert candidate(code = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == [900, 1200, 1500, 1800, 2100, 2400, 2700, 2000, 1300, 600]\n assert candidate(code = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = -4) == [102, 84, 66, 48, 30, 42, 54, 66, 78, 90]\n assert candidate(code = [10, 20, 30, 40, 50],k = -2) == [90, 60, 30, 50, 70]\n assert candidate(code = [26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12],k = -9) == [144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 189, 180, 171, 162, 153]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = -5) == [150, 200, 250, 300, 350, 400, 350, 300, 250, 200]\n assert candidate(code = [3, 6, 9, 12, 15, 18, 21, 24, 27],k = -4) == [90, 75, 60, 45, 30, 42, 54, 66, 78]\n assert candidate(code = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 7) == [75, 95, 119, 114, 106, 98, 88, 80, 70, 58]\n assert candidate(code = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75],k = -20) == [1690, 1695, 1700, 1705, 1710, 1715, 1720, 1725, 1730, 1735, 1740, 1745, 1750, 1755, 1760, 1765, 1770, 1775, 1780, 1785, 1790, 1770, 1750, 1730, 1710]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40],k = 7) == [175, 170, 165, 160, 155, 150, 145, 140]\n assert candidate(code = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 8) == [124, 132, 140, 148, 156, 164, 172, 165, 158, 151, 144, 137, 130, 123, 116]\n assert candidate(code = [100, 100, 100, 100, 100, 100, 100, 100],k = 3) == [300, 300, 300, 300, 300, 300, 300, 300]\n assert candidate(code = [50, 40, 30, 20, 10],k = 0) == [0, 0, 0, 0, 0]\n assert candidate(code = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = -5) == [400, 350, 300, 250, 200, 150, 200, 250, 300, 350]\n assert candidate(code = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180],k = -7) == [1008, 912, 816, 720, 624, 528, 432, 336, 420, 504, 588, 672, 756, 840, 924]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(code = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],k = 0) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(code = [5, 15, 25, 35, 45, 55],k = -6) == [180, 180, 180, 180, 180, 180]\n assert candidate(code = [31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],k = -8) == [77, 89, 101, 111, 119, 129, 137, 145, 150, 124, 98]\n assert candidate(code = [23, 45, 12, 67, 34, 89, 23, 56, 78, 90, 12, 34, 56, 78, 90, 23, 45, 67, 89, 10],k = 10) == [506, 495, 539, 550, 606, 540, 562, 573, 584, 504, 515, 526, 482, 471, 415, 481, 459, 448, 437, 517]\n assert candidate(code = [11, 22, 33, 44, 55, 66],k = 0) == [0, 0, 0, 0, 0, 0]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13],k = 4) == [24, 32, 40, 34, 28, 22, 16]\n assert candidate(code = [30, 20, 10, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = -5) == [35, 60, 74, 77, 74, 66, 38, 21, 15, 15, 20, 25, 30]\n assert candidate(code = [9, 1, 2, 3, 4, 5, 6, 7, 8, 10],k = 4) == [10, 14, 18, 22, 26, 31, 34, 28, 22, 15]\n assert candidate(code = [3, 6, 9, 12, 15, 18, 21],k = -2) == [39, 24, 9, 15, 21, 27, 33]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40],k = -4) == [130, 110, 90, 70, 50, 70, 90, 110]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == [26, 22, 18, 14, 10, 15, 20, 25, 30]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 19) == [418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40],k = 5) == [100, 125, 150, 135, 120, 105, 90, 75]\n assert candidate(code = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [200, 250, 300, 350, 400, 350, 300, 250, 200, 150]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 9) == [99, 117, 135, 153, 171, 189, 207, 225, 243, 261, 279, 257, 235, 213, 191, 169, 147, 125, 103, 81]\n assert candidate(code = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 15) == [1275, 1425, 1575, 1725, 1875, 1825, 1775, 1725, 1675, 1625, 1575, 1525, 1475, 1425, 1375, 1325, 1275, 1225, 1175, 1125]\n assert candidate(code = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = -7) == [455, 425, 395, 365, 335, 305, 275, 245, 315, 385]\n assert candidate(code = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 10) == [165, 165, 165, 165, 165, 165, 165, 165, 165, 165]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == [36, 37, 38, 39, 40, 41, 42, 43, 44]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = -15) == [390, 380, 370, 360, 350, 340, 330, 320, 310, 300, 290, 280, 270, 260, 250, 240, 270, 300, 330, 360]\n assert candidate(code = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == [20, 21, 23, 27, 25, 21, 22, 17, 16, 14, 14]\n assert candidate(code = [50, 40, 30, 20, 10],k = -2) == [30, 60, 90, 70, 50]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40],k = 0) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(code = [7, 14, 21, 28, 35, 42, 49],k = -3) == [126, 98, 70, 42, 63, 84, 105]\n assert candidate(code = [7, 14, 21, 28, 35, 42],k = -5) == [140, 133, 126, 119, 112, 105]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 6) == [48, 60, 72, 84, 96, 108, 96, 84, 72, 60, 48, 36]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == [15, 13, 11, 9, 7, 5, 3, 10, 17]\n assert candidate(code = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 8) == [4400, 5200, 5000, 4800, 4600, 4400, 4200, 4000, 3800, 3600]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22],k = 7) == [70, 84, 98, 112, 104, 96, 88, 80, 72, 64, 56]\n assert candidate(code = [10, 20, 30, 40, 50, 60],k = 2) == [50, 70, 90, 110, 70, 30]\n assert candidate(code = [23, 45, 12, 67, 34, 89, 23, 56, 78, 90, 12, 34, 56, 78, 90, 23, 45, 67, 89, 10],k = -10) == [504, 515, 526, 482, 471, 415, 481, 459, 448, 437, 517, 506, 495, 539, 550, 606, 540, 562, 573, 584]\n assert candidate(code = [2, 4, 8, 16, 32, 64, 128, 256],k = 3) == [28, 56, 112, 224, 448, 386, 262, 14]\n assert candidate(code = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 5) == [485, 480, 475, 470, 465, 470, 475, 480, 485, 490]\n assert candidate(code = [7, 14, 21, 28, 35, 42, 49],k = 3) == [63, 84, 105, 126, 98, 70, 42]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = -5) == [95, 81, 67, 53, 39, 25, 35, 45, 55, 65, 75, 85]\n assert candidate(code = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = -8) == [64, 70, 76, 82, 88, 94, 100, 106, 112, 96, 80]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 7) == [63, 77, 91, 105, 97, 89, 81, 73, 65, 57, 49]\n assert candidate(code = [23, 17, 15, 9, 2],k = 1) == [17, 15, 9, 2, 23]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(code = [3, 6, 9, 12, 15, 18, 21, 24],k = -2) == [45, 27, 9, 15, 21, 27, 33, 39]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = -19) == [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = -4) == [10, 15, 20, 25, 30, 26, 22, 18, 14]\n"}, "metadata": {"canonical_parameter_names": ["code", "k"], "leetcode_dataset_entry_point": "Solution().decrypt", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def decrypt(self, code: list[int], k: int) -> list[int]:", "container": "Solution", "callable": "decrypt", "parameters": [{"name": "code", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1653, "task_id": "minimum-deletions-to-make-string-balanced", "difficulty": "Medium", "problem_description": "You are given a string s consisting only of characters 'a' and 'b'​​​​.\nYou can delete any number of characters in s to make s balanced. s is balanced if there is no pair of indices (i,j) such that i < j and s[i] = 'b' and s[j]= 'a'.\nReturn the minimum number of deletions needed to make s balanced.\n \nExample 1:\n\nInput: s = \"aababbab\"\nOutput: 2\nExplanation: You can either:\nDelete the characters at 0-indexed positions 2 and 6 (\"aababbab\" -> \"aaabbb\"), or\nDelete the characters at 0-indexed positions 3 and 6 (\"aababbab\" -> \"aabbbb\").\n\nExample 2:\n\nInput: s = \"bbaaaaabb\"\nOutput: 2\nExplanation: The only solution is to delete the first two characters.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns[i] is 'a' or 'b'​​.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaaaaabbbb\") == 0\n assert candidate(s = \"bbbaaaaa\") == 3\n assert candidate(s = \"bbbaaaaabbbb\") == 3\n assert candidate(s = \"aabbaa\") == 2\n assert candidate(s = \"abababab\") == 3\n assert candidate(s = \"aaaaa\") == 0\n assert candidate(s = \"aabbaabb\") == 2\n assert candidate(s = \"aababbaa\") == 3\n assert candidate(s = \"baabbaab\") == 3\n assert candidate(s = \"abababa\") == 3\n assert candidate(s = \"aabbaaab\") == 2\n assert candidate(s = \"aabbbbbaa\") == 2\n assert candidate(s = \"bbaabb\") == 2\n assert candidate(s = \"babababababababab\") == 8\n assert candidate(s = \"bbbbb\") == 0\n assert candidate(s = \"bababab\") == 3\n assert candidate(s = \"aababbab\") == 2\n assert candidate(s = \"ababababa\") == 4\n assert candidate(s = \"baabbaabba\") == 4\n assert candidate(s = \"bbaaaaabb\") == 2\n assert candidate(s = \"bbbbaaaa\") == 4\n assert candidate(s = \"aabbaaabbbaaabbb\") == 5\n assert candidate(s = \"baababababa\") == 5\n assert candidate(s = \"aaaa\") == 0\n assert candidate(s = \"bbbb\") == 0\n assert candidate(s = \"bbaabbaabbaa\") == 6\n assert candidate(s = \"aabbaaabbbaa\") == 4\n assert candidate(s = \"baba\") == 2\n assert candidate(s = \"abbaaabbbbba\") == 3\n assert candidate(s = \"aabbabba\") == 2\n assert candidate(s = \"bbbbbaaaaa\") == 5\n assert candidate(s = \"bbabbaab\") == 3\n assert candidate(s = \"aaabbbba\") == 1\n assert candidate(s = \"aaaaaaaa\") == 0\n assert candidate(s = \"bbbbbbbb\") == 0\n assert candidate(s = \"baabaa\") == 2\n assert candidate(s = \"bbbbbaaaaaabbbbaaaaabbbbbbaaaabbbaaaaabbbb\") == 18\n assert candidate(s = \"aaaaaaaaaabbbaaabbbbaaaaaaaaa\") == 7\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbb\") == 0\n assert candidate(s = \"aaaaabbbbaaaaabbbb\") == 4\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababababababab\") == 53\n assert candidate(s = \"babababababababa\") == 8\n assert candidate(s = \"abbbbbaaaabbbab\") == 5\n assert candidate(s = \"abbbabbaabbbaabaaabababbbaaabbbaaaabbbabbbaaabbabbaabbaabaabbabbaabbabbaabbbaabb\") == 36\n assert candidate(s = \"abbbbbaaaabbbb\") == 4\n assert candidate(s = \"abababababababa\") == 7\n assert candidate(s = \"bbbbaaaaabbbbbbbba\") == 5\n assert candidate(s = \"aaaaaaaaaabbbabb\") == 1\n assert candidate(s = \"bababababababababab\") == 9\n assert candidate(s = \"ababababaababababa\") == 8\n assert candidate(s = \"baabbabababaabbabababaabbabababaabb\") == 16\n assert candidate(s = \"bbbbbbaaaaaa\") == 6\n assert candidate(s = \"bbbbbbaaaaaabbbb\") == 6\n assert candidate(s = \"aaaabbbaaaaabbbb\") == 3\n assert candidate(s = \"aaaaabbbbbbbbbaaaa\") == 4\n assert candidate(s = \"abbaabbaabbaabbaabbaabba\") == 11\n assert candidate(s = \"baabbaabbaabbaabba\") == 8\n assert candidate(s = \"baaaabbbbaaabbbbaaaaabbbbbaaaaaabbbbbbaaaaabbbbbaaaaaabbbbbbaaaaabbbbbaaaaaabbbbbbaaaaabbbbbaaaaaabbbbbbaaaaabbbbbaaaaaabbbbbbaaaaabb\") == 63\n assert candidate(s = \"baaabbaaabbaabab\") == 6\n assert candidate(s = \"abababababababababababababababababababababababababababababababab\") == 31\n assert candidate(s = \"abbbabbbabbbabbbabbbabbbabbbabbbab\") == 8\n assert candidate(s = \"baaaababababbbabba\") == 6\n assert candidate(s = \"abbbabaaaababbbaaaabbaaababbabaaaabbabaaaaabaa\") == 18\n assert candidate(s = \"bbbbbaaaaabbbbbaaaa\") == 9\n assert candidate(s = \"abababababbababb\") == 6\n assert candidate(s = \"bababababababababababababababababababa\") == 19\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbbb\") == 0\n assert candidate(s = \"bbbbabbaaababbaaababbaaababbaaababbaaab\") == 18\n assert candidate(s = \"bbbbbbbbbaaaaaaaaa\") == 9\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbbbaaaaaaabbbbaaaaaaa\") == 14\n assert candidate(s = \"aaaaaabbbbbbaaaaaaabbbbbaaaaabbbbb\") == 11\n assert candidate(s = \"aaabbaabbaabbaabbaabbaabbaabbaabbaa\") == 16\n assert candidate(s = \"baaaaaabbbbbbb\") == 1\n assert candidate(s = \"bbbbbaaaabbbbaaabbbbaa\") == 9\n assert candidate(s = \"aabbbbaaaabbbbbb\") == 4\n assert candidate(s = \"aababbabbaababba\") == 6\n assert candidate(s = \"bbaabbabbaabbabbaa\") == 8\n assert candidate(s = \"abababbababababa\") == 7\n assert candidate(s = \"aabbaaababababba\") == 6\n assert candidate(s = \"aabbaabbaabbaabb\") == 6\n assert candidate(s = \"aaaaaabbbbbbaaabbb\") == 3\n assert candidate(s = \"bbbbbaaaaaabbbbbbaaaaaaabbbbbbbaaaaaaaaa\") == 18\n assert candidate(s = \"bbbaaabbaaabbaabbaaabbaaabbaabbaabbaa\") == 17\n assert candidate(s = \"bbaababbabababbababaababababababaababababababaababababababaababababababaababababababaabababaabababa\") == 47\n assert candidate(s = \"bbaaaaabaaaaabaaaaabaaaaabaaaaabaaaa\") == 7\n assert candidate(s = \"aabbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaa\") == 25\n assert candidate(s = \"abbaabbaabbaabba\") == 7\n assert candidate(s = \"bbbbbbbaaaabbbbbbbaa\") == 6\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbaabbbbaaaaaaaaa\") == 11\n assert candidate(s = \"bbabbababbaaab\") == 6\n assert candidate(s = \"bababababa\") == 5\n assert candidate(s = \"ababababababab\") == 6\n assert candidate(s = \"aabbbabbbabbbabbbabba\") == 5\n assert candidate(s = \"abababababab\") == 5\n assert candidate(s = \"ababababababababab\") == 8\n assert candidate(s = \"bbbbbaaaaabbbbb\") == 5\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaa\") == 17\n assert candidate(s = \"aaaaaaaaaabbbbbb\") == 0\n assert candidate(s = \"baaaaaaaaaaaaaaaaaab\") == 1\n assert candidate(s = \"bbbbaaaabaaaab\") == 5\n assert candidate(s = \"baaaaaabbbbb\") == 1\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 21\n assert candidate(s = \"bbbbbbbbbaaaaaa\") == 6\n assert candidate(s = \"aaaaaaaaabbbbbbbbbbbaa\") == 2\n assert candidate(s = \"bbbbbaaaaabbaaab\") == 7\n assert candidate(s = \"abbaababbaababbaababbaababbaababbaabab\") == 18\n assert candidate(s = \"aaaaaabbbbbbaaaaaabbbbbbaaaaaabbbbbb\") == 12\n assert candidate(s = \"bbbbaaaabbbbba\") == 5\n assert candidate(s = \"bbbbbbbbbaaaabbb\") == 4\n assert candidate(s = \"baababababaabbaa\") == 7\n assert candidate(s = \"aaaaaaaaaabbbbba\") == 1\n assert candidate(s = \"aabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbb\") == 14\n assert candidate(s = \"abababababababababab\") == 9\n assert candidate(s = \"aaaaabbbbaaaaabbbbbaaa\") == 7\n assert candidate(s = \"aaaaaaaaaabbbaaaaaaaaa\") == 3\n assert candidate(s = \"aababababababababa\") == 8\n assert candidate(s = \"bababababababa\") == 7\n assert candidate(s = \"babbaabbbaabbaabbbaabbaabbbaabbaabba\") == 16\n assert candidate(s = \"aaabbaabbaabbbbb\") == 4\n assert candidate(s = \"aabbaaabbbabbaaabb\") == 6\n assert candidate(s = \"bbbbbbbbbaaaaaaaaaaa\") == 9\n assert candidate(s = \"aaabbbbaaaaabba\") == 5\n assert candidate(s = \"baaaaaabbaaabbbaaa\") == 6\n assert candidate(s = \"bbbaaaaabbbaaaa\") == 6\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbb\") == 0\n assert candidate(s = \"aabbaabbbaaabb\") == 5\n assert candidate(s = \"babababababababababa\") == 10\n assert candidate(s = \"bababababababababababababababab\") == 15\n assert candidate(s = \"baaababbababab\") == 5\n assert candidate(s = \"baabababababababababab\") == 10\n assert candidate(s = \"bbbbbbbbbaaaaaaaaaa\") == 9\n assert candidate(s = \"bbbbbbbbbaaaaa\") == 5\n assert candidate(s = \"bbbbbbbbbbbbbaaaaaaaaa\") == 9\n assert candidate(s = \"baaaaaabbbbbbbaaaaaaaaaabbbbbbbaaaaaaaaaaabbbbbbbaaaaaaaaaaabbbbbbbaaaaaaaaaa\") == 29\n assert candidate(s = \"baaaaaabbbbbbbbba\") == 2\n assert candidate(s = \"abbaabbaabbaabbaab\") == 8\n assert candidate(s = \"babbabbabbabbabbabba\") == 7\n assert candidate(s = \"aababababababababababababababababababababababa\") == 22\n assert candidate(s = \"bbbbbaaaaabbbb\") == 5\n assert candidate(s = \"baabababaabababa\") == 7\n assert candidate(s = \"aaaaabbbbbabbbbb\") == 1\n assert candidate(s = \"babababababababaab\") == 8\n assert candidate(s = \"bbbbbbbbbaaaaaaabbbbbbbbbaaaaaaa\") == 14\n assert candidate(s = \"aaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 0\n assert candidate(s = \"bbbbaaaaabbaaabb\") == 6\n assert candidate(s = \"aaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaa\") == 36\n assert candidate(s = \"bbbbbbaaabaaabbaab\") == 8\n assert candidate(s = \"aabbaabbbaabba\") == 5\n assert candidate(s = \"abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\") == 46\n assert candidate(s = \"abbaabbaabba\") == 5\n assert candidate(s = \"baaabbbbaaabbbbaaabbbbaaabbbbaaabbb\") == 13\n assert candidate(s = \"aaaaaaaaaabbbbbbaa\") == 2\n assert candidate(s = \"aabbaaabbaabbaa\") == 6\n assert candidate(s = \"ababbababbabab\") == 5\n assert candidate(s = \"bbbbbaaabbaabb\") == 5\n assert candidate(s = \"abababababababababa\") == 9\n assert candidate(s = \"babbbbbaaabbbbaabb\") == 6\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaa\") == 20\n assert candidate(s = \"abbbbaaababaaaabbaaabaaabbaaaabbbaaabbaaaabbaaabbaaabbbbaaaaa\") == 24\n assert candidate(s = \"bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbaaaaaaaaa\") == 26\n assert candidate(s = \"bbaaabbaaabbaaabbaaabbaaabbaaabbaaab\") == 14\n assert candidate(s = \"aaabbbaaababba\") == 5\n assert candidate(s = \"ababababab\") == 4\n assert candidate(s = \"aaaaabbbbaaaabbbba\") == 5\n assert candidate(s = \"bbbbaaaaabbaaaab\") == 6\n assert candidate(s = \"aabbaaabbaaabbaaabbaa\") == 8\n assert candidate(s = \"bbbbbbaaabbbbaaaa\") == 7\n assert candidate(s = \"bbbbbaaaaaaaaaaa\") == 5\n assert candidate(s = \"baabaaabbaabaaabbaabaa\") == 8\n assert candidate(s = \"aabbbbbbaabbaaaabb\") == 6\n assert candidate(s = \"aababbbaaababbab\") == 6\n assert candidate(s = \"bbbbabbbbbaaaaa\") == 6\n assert candidate(s = \"bbaaaaaaaaaabbbbaaaabbbba\") == 7\n assert candidate(s = \"aabbaabbabbaabbabbbaaabbaa\") == 11\n assert candidate(s = \"aaaaaaaaaabbbaaa\") == 3\n assert candidate(s = \"aaaaaaaaaabbbaaaabbbbbaaabbbbaaabbbbbaaa\") == 12\n assert candidate(s = \"babababaabab\") == 5\n assert candidate(s = \"bbbbbbbbbaaaaabbbb\") == 5\n assert candidate(s = \"aabbaaabbbaaabbbaaabbbaaabbaa\") == 13\n assert candidate(s = \"aaaabababababbbbba\") == 5\n assert candidate(s = \"aaabbaaabbaaabba\") == 5\n assert candidate(s = \"bbbbbbaaaaaabbbbaaa\") == 9\n assert candidate(s = \"bbbbbbbbaaaaabaaaaabbaaaabbaaaabbbaaaabbbbbbb\") == 16\n assert candidate(s = \"baaaaabbbbaaaaabba\") == 6\n assert candidate(s = \"abababaabababaab\") == 6\n assert candidate(s = \"bbbaaabbaaabbaab\") == 7\n assert candidate(s = \"aaaabaaaabaaaa\") == 2\n assert candidate(s = \"ababababababababababababababababababab\") == 18\n assert candidate(s = \"bbabbbbaaabbbbaaab\") == 7\n assert candidate(s = \"abbaabbaabbbaabb\") == 6\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumDeletions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumDeletions(self, s: str) -> int:", "container": "Solution", "callable": "minimumDeletions", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1654, "task_id": "minimum-jumps-to-reach-home", "difficulty": "Medium", "problem_description": "A certain bug's home is on the x-axis at position x. Help them get there from position 0.\nThe bug jumps according to the following rules:\n\nIt can jump exactly a positions forward (to the right).\nIt can jump exactly b positions backward (to the left).\nIt cannot jump backward twice in a row.\nIt cannot jump to any forbidden positions.\n\nThe bug may jump forward beyond its home, but it cannot jump to positions numbered with negative integers.\nGiven an array of integers forbidden, where forbidden[i] means that the bug cannot jump to the position forbidden[i], and integers a, b, and x, return the minimum number of jumps needed for the bug to reach its home. If there is no possible sequence of jumps that lands the bug on position x, return -1.\n \nExample 1:\n\nInput: forbidden = [14,4,18,1,15], a = 3, b = 15, x = 9\nOutput: 3\nExplanation: 3 jumps forward (0 -> 3 -> 6 -> 9) will get the bug home.\n\nExample 2:\n\nInput: forbidden = [8,3,16,6,12,20], a = 15, b = 13, x = 11\nOutput: -1\n\nExample 3:\n\nInput: forbidden = [1,6,2,14,5,17,4], a = 16, b = 9, x = 7\nOutput: 2\nExplanation: One jump forward (0 -> 16) then one jump backward (16 -> 7) will get the bug home.\n\n \nConstraints:\n\n1 <= forbidden.length <= 1000\n1 <= a, b, forbidden[i] <= 2000\n0 <= x <= 2000\nAll the elements in forbidden are distinct.\nPosition x is not forbidden.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(forbidden = [2, 4, 6, 8, 10],a = 2,b = 1,x = 1) == -1\n assert candidate(forbidden = [],a = 1,b = 1,x = 0) == 0\n assert candidate(forbidden = [5, 6, 7],a = 1,b = 1,x = 10) == -1\n assert candidate(forbidden = [1, 6, 2, 14, 5, 17, 4],a = 16,b = 9,x = 7) == 2\n assert candidate(forbidden = [8, 3, 16, 6, 12, 20],a = 15,b = 13,x = 11) == -1\n assert candidate(forbidden = [14, 4, 18, 1, 15],a = 3,b = 15,x = 9) == 3\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],a = 3,b = 5,x = 20) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],a = 1,b = 3,x = 50) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 1,b = 2,x = 25) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],a = 2,b = 4,x = 58) == 29\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200],a = 5,b = 10,x = 195) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],a = 2,b = 1,x = 51) == -1\n assert candidate(forbidden = [300, 600, 900, 1200, 1500, 1800],a = 300,b = 150,x = 2100) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],a = 2,b = 4,x = 41) == -1\n assert candidate(forbidden = [200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000],a = 100,b = 50,x = 1950) == 21\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 3,x = 20) == 10\n assert candidate(forbidden = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900],a = 100,b = 200,x = 1999) == -1\n assert candidate(forbidden = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1536, 2048],a = 1,b = 2,x = 1500) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 20,x = 210) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 1,x = 21) == 12\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 1,b = 2,x = 21) == -1\n assert candidate(forbidden = [200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000],a = 100,b = 200,x = 2100) == -1\n assert candidate(forbidden = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 50,x = 1000) == -1\n assert candidate(forbidden = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000],a = 500,b = 100,x = 5500) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 5,x = 199) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],a = 2,b = 1,x = 28) == 14\n assert candidate(forbidden = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519],a = 100,b = 50,x = 600) == 9\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 5,x = 210) == -1\n assert candidate(forbidden = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],a = 25,b = 50,x = 600) == -1\n assert candidate(forbidden = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],a = 15,b = 25,x = 100) == -1\n assert candidate(forbidden = [1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990],a = 1,b = 2,x = 2000) == -1\n assert candidate(forbidden = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1500],a = 250,b = 125,x = 2000) == 11\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],a = 2,b = 4,x = 50) == 25\n assert candidate(forbidden = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],a = 5,b = 3,x = 20) == -1\n assert candidate(forbidden = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 50,x = 1001) == -1\n assert candidate(forbidden = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],a = 3,b = 6,x = 63) == -1\n assert candidate(forbidden = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],a = 100,b = 50,x = 2100) == -1\n assert candidate(forbidden = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],a = 10,b = 5,x = 195) == 21\n assert candidate(forbidden = [199, 399, 599, 799, 999, 1199, 1399, 1599, 1799, 1999],a = 200,b = 100,x = 1998) == -1\n assert candidate(forbidden = [500, 1000, 1500],a = 100,b = 50,x = 2000) == 23\n assert candidate(forbidden = [2000],a = 1000,b = 500,x = 1500) == 3\n assert candidate(forbidden = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],a = 10,b = 5,x = 200) == 20\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 2,b = 4,x = 30) == -1\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 1,b = 2,x = 25) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 4,x = 21) == -1\n assert candidate(forbidden = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130],a = 5,b = 3,x = 140) == -1\n assert candidate(forbidden = [500, 1000, 1500, 2000],a = 500,b = 250,x = 2500) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],a = 5,b = 10,x = 135) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],a = 50,b = 100,x = 350) == -1\n assert candidate(forbidden = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000],a = 500,b = 1000,x = 6000) == -1\n assert candidate(forbidden = [],a = 1000,b = 500,x = 2000) == 2\n assert candidate(forbidden = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 200,x = 1500) == -1\n assert candidate(forbidden = [5, 15, 25, 35, 45],a = 10,b = 5,x = 100) == 10\n assert candidate(forbidden = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90],a = 3,b = 9,x = 88) == -1\n assert candidate(forbidden = [100, 150, 200, 250, 300],a = 50,b = 20,x = 180) == 5\n assert candidate(forbidden = [101, 201, 301, 401, 501, 601, 701, 801, 901, 1001, 1101, 1201, 1301, 1401, 1501, 1601, 1701, 1801, 1901],a = 100,b = 50,x = 1899) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 5,x = 195) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 4,x = 20) == 10\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],a = 1,b = 2,x = 31) == -1\n assert candidate(forbidden = [150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, 1800, 1950],a = 150,b = 100,x = 1000) == -1\n assert candidate(forbidden = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597],a = 7,b = 5,x = 400) == 64\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 1,b = 3,x = 21) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],a = 20,b = 10,x = 199) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50],a = 5,b = 10,x = 15) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],a = 10,b = 20,x = 200) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 5,x = 210) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],a = 5,b = 10,x = 105) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 2,b = 1,x = 19) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],a = 5,b = 3,x = 48) == -1\n assert candidate(forbidden = [3, 6, 9, 12, 15, 18, 21, 24, 27],a = 3,b = 2,x = 30) == -1\n assert candidate(forbidden = [300, 600, 900, 1200, 1500, 1800, 2000],a = 100,b = 200,x = 1900) == -1\n assert candidate(forbidden = [150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, 1800, 1950],a = 150,b = 75,x = 1995) == -1\n assert candidate(forbidden = [199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180],a = 1,b = 2,x = 175) == 175\n assert candidate(forbidden = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],a = 10,b = 5,x = 199) == -1\n assert candidate(forbidden = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, 103, 107, 111, 115, 119, 123, 127, 131, 135, 139, 143, 147, 151, 155, 159, 163, 167, 171, 175, 179, 183, 187, 191, 195, 199],a = 4,b = 8,x = 197) == -1\n assert candidate(forbidden = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],a = 2,b = 3,x = 50) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],a = 5,b = 10,x = 150) == -1\n assert candidate(forbidden = [50, 100, 150, 200],a = 50,b = 25,x = 200) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],a = 10,b = 5,x = 145) == -1\n assert candidate(forbidden = [100, 200, 300, 400, 500],a = 100,b = 200,x = 600) == -1\n assert candidate(forbidden = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145, 160, 175, 190, 205, 220, 235, 250, 265, 280, 295],a = 15,b = 30,x = 290) == -1\n assert candidate(forbidden = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],a = 1,b = 1,x = 110) == -1\n assert candidate(forbidden = [10, 15, 20, 25, 30],a = 5,b = 10,x = 40) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],a = 5,b = 10,x = 55) == -1\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],a = 3,b = 1,x = 45) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],a = 2,b = 4,x = 62) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],a = 10,b = 5,x = 185) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],a = 2,b = 1,x = 39) == -1\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 1,b = 2,x = 21) == -1\n assert candidate(forbidden = [2, 5, 7, 10, 15, 20],a = 2,b = 4,x = 25) == -1\n assert candidate(forbidden = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],a = 1,b = 2,x = 2048) == -1\n assert candidate(forbidden = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119],a = 1,b = 1,x = 120) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90],a = 10,b = 5,x = 100) == -1\n assert candidate(forbidden = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],a = 10,b = 20,x = 105) == -1\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 1,b = 2,x = 30) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],a = 2,b = 3,x = 42) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],a = 10,b = 5,x = 195) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290],a = 10,b = 20,x = 299) == -1\n"}, "metadata": {"canonical_parameter_names": ["forbidden", "a", "b", "x"], "leetcode_dataset_entry_point": "Solution().minimumJumps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumJumps(self, forbidden: list[int], a: int, b: int, x: int) -> int:", "container": "Solution", "callable": "minimumJumps", "parameters": [{"name": "forbidden", "type": "list[int]"}, {"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "x", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1655, "task_id": "distribute-repeating-integers", "difficulty": "Hard", "problem_description": "You are given an array of n integers, nums, where there are at most 50 unique values in the array. You are also given an array of m customer order quantities, quantity, where quantity[i] is the amount of integers the ith customer ordered. Determine if it is possible to distribute nums such that:\n\nThe ith customer gets exactly quantity[i] integers,\nThe integers the ith customer gets are all equal, and\nEvery customer is satisfied.\n\nReturn true if it is possible to distribute nums according to the above conditions.\n \nExample 1:\n\nInput: nums = [1,2,3,4], quantity = [2]\nOutput: false\nExplanation: The 0th customer cannot be given two different integers.\n\nExample 2:\n\nInput: nums = [1,2,3,3], quantity = [2]\nOutput: true\nExplanation: The 0th customer is given [3,3]. The integers [1,2] are not used.\n\nExample 3:\n\nInput: nums = [1,1,2,2], quantity = [2,2]\nOutput: true\nExplanation: The 0th customer is given [1,1], and the 1st customer is given [2,2].\n\n \nConstraints:\n\nn == nums.length\n1 <= n <= 105\n1 <= nums[i] <= 1000\nm == quantity.length\n1 <= m <= 10\n1 <= quantity[i] <= 105\nThere are at most 50 unique values in nums.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 2, 2],quantity = [2, 2]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],quantity = [3, 3]) == True\n assert candidate(nums = [10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40, 50, 50, 50, 60, 60, 60, 70, 70, 70],quantity = [3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1],quantity = [5]) == True\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],quantity = [2, 2, 2, 2]) == True\n assert candidate(nums = [1, 2, 3, 4],quantity = [2]) == False\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4],quantity = [4, 4, 4]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],quantity = [2, 2, 2]) == True\n assert candidate(nums = [1, 2, 3, 3],quantity = [2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],quantity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50],quantity = [2, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4],quantity = [3, 3, 3, 4]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],quantity = [3, 3, 3]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],quantity = [2, 2, 3, 4, 5]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 3],quantity = [2, 3]) == True\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],quantity = [10]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [3, 3, 3, 4]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [2, 3, 3, 4, 4]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [10, 10, 10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6],quantity = [5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],quantity = [3, 3, 3, 5, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],quantity = [5, 7, 4]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],quantity = [7, 7, 7, 7]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [10, 10, 10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],quantity = [2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20],quantity = [10, 10, 10]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],quantity = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [3, 4, 5, 3]) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],quantity = [4, 6, 6, 8]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],quantity = [3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [5, 5, 5, 10, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],quantity = [2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],quantity = [4, 4, 4, 4]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [15, 15, 15, 15]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10],quantity = [6, 6, 6, 6, 6]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [10, 10, 10, 10, 10]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6],quantity = [5, 5, 6]) == True\n assert candidate(nums = [7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10],quantity = [3, 3, 4, 4]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5, 10]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],quantity = [3, 4, 5, 6]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],quantity = [10, 10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],quantity = [10, 10, 10]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5]) == False\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [10, 10, 10, 10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [7, 7, 7, 5]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],quantity = [5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6],quantity = [2, 2, 3, 3, 3]) == True\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],quantity = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6],quantity = [2, 2, 3, 3, 4]) == True\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50],quantity = [2, 4, 6]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5],quantity = [3, 5, 4]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums", "quantity"], "leetcode_dataset_entry_point": "Solution().canDistribute", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canDistribute(self, nums: list[int], quantity: list[int]) -> bool:", "container": "Solution", "callable": "canDistribute", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "quantity", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1657, "task_id": "determine-if-two-strings-are-close", "difficulty": "Medium", "problem_description": "Two strings are considered close if you can attain one from the other using the following operations:\n\nOperation 1: Swap any two existing characters.\n\n\t\nFor example, abcde -> aecdb\n\n\nOperation 2: Transform every occurrence of one existing character into another existing character, and do the same with the other character.\n\t\nFor example, aacabb -> bbcbaa (all a's turn into b's, and all b's turn into a's)\n\n\n\nYou can use the operations on either string as many times as necessary.\nGiven two strings, word1 and word2, return true if word1 and word2 are close, and false otherwise.\n \nExample 1:\n\nInput: word1 = \"abc\", word2 = \"bca\"\nOutput: true\nExplanation: You can attain word2 from word1 in 2 operations.\nApply Operation 1: \"abc\" -> \"acb\"\nApply Operation 1: \"acb\" -> \"bca\"\n\nExample 2:\n\nInput: word1 = \"a\", word2 = \"aa\"\nOutput: false\nExplanation: It is impossible to attain word2 from word1, or vice versa, in any number of operations.\n\nExample 3:\n\nInput: word1 = \"cabbba\", word2 = \"abbccc\"\nOutput: true\nExplanation: You can attain word2 from word1 in 3 operations.\nApply Operation 1: \"cabbba\" -> \"caabbb\"\nApply Operation 2: \"caabbb\" -> \"baaccc\"\nApply Operation 2: \"baaccc\" -> \"abbccc\"\n\n \nConstraints:\n\n1 <= word1.length, word2.length <= 105\nword1 and word2 contain only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"leetcode\",word2 = \"coeddlet\") == False\n assert candidate(word1 = \"aaa\",word2 = \"bbb\") == False\n assert candidate(word1 = \"aaabbbbccdddd\",word2 = \"bbbbaacdddd\") == False\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"ccbbaa\") == True\n assert candidate(word1 = \"abc\",word2 = \"bca\") == True\n assert candidate(word1 = \"abcabcabc\",word2 = \"bcbcbcbcb\") == False\n assert candidate(word1 = \"abcde\",word2 = \"edcba\") == True\n assert candidate(word1 = \"cabbba\",word2 = \"abbccc\") == True\n assert candidate(word1 = \"xyzz\",word2 = \"zzxy\") == True\n assert candidate(word1 = \"xyz\",word2 = \"zyx\") == True\n assert candidate(word1 = \"abcd\",word2 = \"abce\") == False\n assert candidate(word1 = \"aaabbbbcc\",word2 = \"bbbcccaaa\") == False\n assert candidate(word1 = \"uau\",word2 = \"ssx\") == False\n assert candidate(word1 = \"aaabbbbccddd\",word2 = \"bbbccdddcccc\") == False\n assert candidate(word1 = \"aabbbbccc\",word2 = \"bbcccaaaa\") == True\n assert candidate(word1 = \"abab\",word2 = \"baba\") == True\n assert candidate(word1 = \"aaabbbbcc\",word2 = \"aaaabbbcc\") == True\n assert candidate(word1 = \"a\",word2 = \"aa\") == False\n assert candidate(word1 = \"aab\",word2 = \"bba\") == True\n assert candidate(word1 = \"abcd\",word2 = \"dcba\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\") == False\n assert candidate(word1 = \"aaaabbbbccccdddd\",word2 = \"ddddeeeeffffgggg\") == False\n assert candidate(word1 = \"aaabbcccddeeefffggghhhhiiiii\",word2 = \"iiiiihhhgggfffeeedddcccbbaaa\") == False\n assert candidate(word1 = \"xyzxyzxyz\",word2 = \"zyxzyxzyx\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"bbacabadabacaba\") == False\n assert candidate(word1 = \"aaabbcccddddeeeeeffffffgggggghhhhhiiiijjjjkkkkklllllmmmmnnooooppqqrrsstttuuuuuvvvvvvvwwxxxxxyyyyzzzzz\",word2 = \"zzzzzyyyyxxxwwwvvvvvvuuuuutttssrrqqppoonnmmllkkjjiihhhgggfffddddccccbbbbaaa\") == False\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"ffeeddccbbaa\") == True\n assert candidate(word1 = \"aaabbbcccdddeeefff\",word2 = \"ffeeeedddcccbbbaaa\") == False\n assert candidate(word1 = \"mississippi\",word2 = \"ppissimissi\") == True\n assert candidate(word1 = \"abcdabcabcabcd\",word2 = \"dcbaababdcbaabab\") == False\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"bacabacababacab\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxyywwvvuuttssrrqqppoonnmmllkkjjiihhggffeeeeddccbbaa\") == False\n assert candidate(word1 = \"ppppoooonnnnmmmlllkkeeeeeddcccbbbaaa\",word2 = \"aaaaaaaaabbbbbbccccdddddeeeeeeeekkkkkklllllmmmmmmmnnnnnnnnoooooooooppppppp\") == False\n assert candidate(word1 = \"qqqwwwweeerrrttt\",word2 = \"tttwwweerrrqqq\") == False\n assert candidate(word1 = \"abcabcabc\",word2 = \"ccbbbaaa\") == False\n assert candidate(word1 = \"qwertypoiuytrewq\",word2 = \"poiuytrewqqwertypo\") == False\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(word1 = \"abcdefabcdefabcdef\",word2 = \"fedcbafedcbafedcba\") == True\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcba\") == True\n assert candidate(word1 = \"abcdefgh\",word2 = \"hgfedcba\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"cbacbacbcacbacb\") == False\n assert candidate(word1 = \"abcdefg\",word2 = \"gfedcba\") == True\n assert candidate(word1 = \"loooooonnnngggggwwwoooorrrrddddsssaaammmmeeeerrttttyyyyyyyyyyyynnnnnnnnnn\",word2 = \"nnnnnnnnnnyyyyyyyyyyyttttyyyyymmmeeraatttddddsssaaawwwggggnnnllllloooooo\") == False\n assert candidate(word1 = \"xylophone\",word2 = \"phonexylo\") == True\n assert candidate(word1 = \"abcdefghijklopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(word1 = \"abcdefabcabc\",word2 = \"abcabcabcdef\") == True\n assert candidate(word1 = \"aaaaabbbbcccccccdddddddd\",word2 = \"ddddddddcccccccbbbbaaaaa\") == True\n assert candidate(word1 = \"mnopqr\",word2 = \"rpqomn\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"ppiimssisss\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttssrrqppoonnmlkkjjiihhggffeeeeddccbbaa\") == False\n assert candidate(word1 = \"anotherexample\",word2 = \"mpleaxarnothee\") == True\n assert candidate(word1 = \"aaaaabbbbbccccc\",word2 = \"bbbbbcccccaaaaa\") == True\n assert candidate(word1 = \"zzzzzzyyyxxx\",word2 = \"yyyxxxzzzzzy\") == False\n assert candidate(word1 = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"yzxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\") == False\n assert candidate(word1 = \"xyzxyzxyzxyzxyzxyzxyz\",word2 = \"zyxzyxzyxzyxzyxzyxzyxzyxzyx\") == False\n assert candidate(word1 = \"aabccddddeeeeefffffff\",word2 = \"eeeeeeffffffdddddcccbaaa\") == False\n assert candidate(word1 = \"mnopqr\",word2 = \"rstuvw\") == False\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == False\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"abcdeffedcba\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"abcdefghijklmnopqrstuvxyzmnopqrstuvwxyzabcdefg\") == False\n assert candidate(word1 = \"uniqueletters\",word2 = \"letterniquesu\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxyywwvvuuttssrrqqlloonnmmllkkjjiihhggeeddbbaa\") == False\n assert candidate(word1 = \"abcabcabcabcabcabcabcabcabcabc\",word2 = \"bcabacabcabacabcabacabcabacabcabac\") == False\n assert candidate(word1 = \"abcdefghijk\",word2 = \"abcdefghijl\") == False\n assert candidate(word1 = \"thisisatest\",word2 = \"esttasisthi\") == True\n assert candidate(word1 = \"qqwweerrttyyuuiiooppllaaassddffgg\",word2 = \"ggffddssaallooppuiiyyttreeewwqq\") == False\n assert candidate(word1 = \"abacabadaba\",word2 = \"dabacababad\") == False\n assert candidate(word1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",word2 = \"oconsinolpnacirosccvilcooimmutapernovulcrosmicn\") == False\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"cccbbbaaabbb\") == False\n assert candidate(word1 = \"leetcode\",word2 = \"codeleet\") == True\n assert candidate(word1 = \"z\",word2 = \"z\") == True\n assert candidate(word1 = \"aabbaa\",word2 = \"bbaabb\") == True\n assert candidate(word1 = \"aaabbbccc\",word2 = \"bbbaaacc\") == False\n assert candidate(word1 = \"transform\",word2 = \"rmorfnapt\") == False\n assert candidate(word1 = \"aaaabbbbccccddddeeeeeffffffgggggg\",word2 = \"ggggggffffffeeeeeeeeeccccbbbbaaaa\") == False\n assert candidate(word1 = \"abacabadabacabad\",word2 = \"badacabdacabad\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"hello\",word2 = \"ollhe\") == True\n assert candidate(word1 = \"uniquestring\",word2 = \"stringunique\") == True\n assert candidate(word1 = \"abcdef\",word2 = \"gfedcb\") == False\n assert candidate(word1 = \"xyxyxyxyxyxyxyxyxyxy\",word2 = \"yyxyxyxyxyxyxyxyxyxxyx\") == False\n assert candidate(word1 = \"aaaaabbbbccccdddd\",word2 = \"ddddccccbbbbaaa\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(word1 = \"abcde\",word2 = \"fghij\") == False\n assert candidate(word1 = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",word2 = \"ddddccccbbbbaaaaaaddddccccbbbbaaaaaa\") == False\n assert candidate(word1 = \"aabbbcccc\",word2 = \"cccbbbaaa\") == False\n assert candidate(word1 = \"aabbccddeee\",word2 = \"eeeedddccbbbaaa\") == False\n assert candidate(word1 = \"thisisatest\",word2 = \"esttisita\") == False\n assert candidate(word1 = \"aaabbbcccddd\",word2 = \"ddddcccbbbbaaa\") == False\n assert candidate(word1 = \"abcdefghijabcdefghijabcdefghij\",word2 = \"abcdefghijabcdefghijabcdefghij\") == True\n assert candidate(word1 = \"zzzzzzzzzz\",word2 = \"zzzzzzzzzz\") == True\n assert candidate(word1 = \"abcdeabcde\",word2 = \"edcbaedcba\") == True\n assert candidate(word1 = \"abcdabcdabcdabcdabcdabcd\",word2 = \"dcbaabcdabcdabcdabcdabcd\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzzyyxwwvvuuttrrqqppoonnmmllkkiijjgghhffeeeeddccbbaa\") == False\n assert candidate(word1 = \"abcdexyz\",word2 = \"zyxwvuts\") == False\n assert candidate(word1 = \"qqwweerrttyyuuiiooppaassddffgg\",word2 = \"ggffddssaappoouuiittyyerrrwwqq\") == False\n assert candidate(word1 = \"abcdefg\",word2 = \"ghijklm\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwwvvuuttssrrqqlloonnmmllkkjjiihhggeeddbbaa\") == False\n assert candidate(word1 = \"aaaabbbbccccddddeee\",word2 = \"eeedddccccbbbbaaaa\") == False\n assert candidate(word1 = \"abcdabcd\",word2 = \"dcbaabcd\") == True\n assert candidate(word1 = \"closestrings\",word2 = \"stringsclose\") == True\n assert candidate(word1 = \"aaaabbbbccccdddd\",word2 = \"ddddccccbbbbaaaa\") == True\n assert candidate(word1 = \"xyzzzz\",word2 = \"zzzzxy\") == True\n"}, "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().closeStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def closeStrings(self, word1: str, word2: str) -> bool:", "container": "Solution", "callable": "closeStrings", "parameters": [{"name": "word1", "type": "str"}, {"name": "word2", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1658, "task_id": "minimum-operations-to-reduce-x-to-zero", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer x. In one operation, you can either remove the leftmost or the rightmost element from the array nums and subtract its value from x. Note that this modifies the array for future operations.\nReturn the minimum number of operations to reduce x to exactly 0 if it is possible, otherwise, return -1.\n \nExample 1:\n\nInput: nums = [1,1,4,2,3], x = 5\nOutput: 2\nExplanation: The optimal solution is to remove the last two elements to reduce x to zero.\n\nExample 2:\n\nInput: nums = [5,6,7,8,9], x = 4\nOutput: -1\n\nExample 3:\n\nInput: nums = [3,2,20,1,1,3], x = 10\nOutput: 5\nExplanation: The optimal solution is to remove the last three elements and the first two elements (5 operations in total) to reduce x to zero.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 104\n1 <= x <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],x = 15) == 5\n assert candidate(nums = [1, 1, 4, 2, 3],x = 5) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],x = 100) == 3\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000],x = 30000) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 10) == 10\n assert candidate(nums = [3, 2, 20, 1, 1, 3],x = 10) == 5\n assert candidate(nums = [1, 1, 1, 1, 1],x = 5) == 5\n assert candidate(nums = [1, 1, 1, 1, 1],x = 3) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 15) == 5\n assert candidate(nums = [2, 3, 1, 2, 4, 3],x = 7) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 11) == 2\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000],x = 50000) == 5\n assert candidate(nums = [5, 6, 7, 8, 9],x = 4) == -1\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],x = 25000) == 5\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],x = 15) == 10\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],x = 5000) == 5\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],x = 1400000) == -1\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],x = 10) == 7\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],x = 1111111111) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],x = 1000) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 190) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 190) == 15\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],x = 55000) == 10\n assert candidate(nums = [3, 5, 10, 7, 15, 1, 4, 2, 8, 6],x = 29) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 21) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 5) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 95) == 15\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],x = 55000) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 30) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 25) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],x = 55) == 7\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 15) == 4\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],x = 15) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 85) == 8\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 100) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 10) == 10\n assert candidate(nums = [1, 2, 3, 4, 5],x = 15) == 5\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],x = 35000) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 10) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 50) == 50\n assert candidate(nums = [3, 2, 20, 1, 1, 3, 5, 10, 1, 1],x = 29) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 1000) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 150) == 5\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],x = 50000) == 5\n assert candidate(nums = [5, 3, 2, 5, 3, 2, 5, 3, 2, 5, 3, 2, 5, 3, 2],x = 20) == 6\n assert candidate(nums = [1, 3, 2, 4, 5, 2, 3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 150) == 12\n assert candidate(nums = [5, 2, 3, 1, 1, 2, 3, 4, 5],x = 9) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],x = 1225) == 45\n assert candidate(nums = [2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3],x = 15) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 100) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 100) == 20\n assert candidate(nums = [3, 5, 2, 1, 4, 7, 8, 9, 6, 10],x = 18) == 3\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],x = 45000) == 6\n assert candidate(nums = [3, 2, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 3, 2, 2, 3, 3, 3, 3, 2, 3, 3, 2, 3, 2, 2, 3, 3, 3, 3],x = 30) == 11\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],x = 370) == 6\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],x = 50) == 5\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 9) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],x = 1500) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 210) == 20\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],x = 55000) == 10\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000],x = 120000) == 3\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000],x = 120000) == 3\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 90) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],x = 45) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],x = 275) == 20\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],x = 60) == 20\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],x = 100000) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 55) == 10\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],x = 30) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 50) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 100) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 15) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 55) == 10\n assert candidate(nums = [10000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9000],x = 20000) == -1\n assert candidate(nums = [10000, 9999, 10000, 9999, 10000, 9999],x = 59996) == -1\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],x = 3000) == 5\n assert candidate(nums = [9, 1, 2, 3, 9, 3, 2, 1, 9],x = 18) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],x = 80) == 14\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 25) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 105) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],x = 1275) == 50\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 50) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],x = 435) == 25\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 550) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 65) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 100) == 9\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],x = 100) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 45) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 20) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 120) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 450) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 55) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],x = 5500) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 55) == 10\n assert candidate(nums = [9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999],x = 49995) == 5\n assert candidate(nums = [5, 2, 3, 1, 1, 5, 5, 3, 2, 5],x = 10) == 2\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],x = 90) == 30\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],x = 80) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],x = 950) == 10\n assert candidate(nums = [3, 5, 2, 4, 1, 9, 6, 7, 8, 10],x = 25) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 100) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],x = 120) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 15) == 15\n assert candidate(nums = [1, 2, 3, 4, 5],x = 0) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 20) == 20\n assert candidate(nums = [5000, 3000, 2000, 4000, 1000, 6000],x = 21000) == 6\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],x = 70000) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums", "x"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minOperations(self, nums: list[int], x: int) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "x", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1659, "task_id": "maximize-grid-happiness", "difficulty": "Hard", "problem_description": "You are given four integers, m, n, introvertsCount, and extrovertsCount. You have an m x n grid, and there are two types of people: introverts and extroverts. There are introvertsCount introverts and extrovertsCount extroverts.\nYou should decide how many people you want to live in the grid and assign each of them one grid cell. Note that you do not have to have all the people living in the grid.\nThe happiness of each person is calculated as follows:\n\nIntroverts start with 120 happiness and lose 30 happiness for each neighbor (introvert or extrovert).\nExtroverts start with 40 happiness and gain 20 happiness for each neighbor (introvert or extrovert).\n\nNeighbors live in the directly adjacent cells north, east, south, and west of a person's cell.\nThe grid happiness is the sum of each person's happiness. Return the maximum possible grid happiness.\n \nExample 1:\n\n\nInput: m = 2, n = 3, introvertsCount = 1, extrovertsCount = 2\nOutput: 240\nExplanation: Assume the grid is 1-indexed with coordinates (row, column).\nWe can put the introvert in cell (1,1) and put the extroverts in cells (1,3) and (2,3).\n- Introvert at (1,1) happiness: 120 (starting happiness) - (0 * 30) (0 neighbors) = 120\n- Extrovert at (1,3) happiness: 40 (starting happiness) + (1 * 20) (1 neighbor) = 60\n- Extrovert at (2,3) happiness: 40 (starting happiness) + (1 * 20) (1 neighbor) = 60\nThe grid happiness is 120 + 60 + 60 = 240.\nThe above figure shows the grid in this example with each person's happiness. The introvert stays in the light green cell while the extroverts live on the light purple cells.\n\nExample 2:\n\nInput: m = 3, n = 1, introvertsCount = 2, extrovertsCount = 1\nOutput: 260\nExplanation: Place the two introverts in (1,1) and (3,1) and the extrovert at (2,1).\n- Introvert at (1,1) happiness: 120 (starting happiness) - (1 * 30) (1 neighbor) = 90\n- Extrovert at (2,1) happiness: 40 (starting happiness) + (2 * 20) (2 neighbors) = 80\n- Introvert at (3,1) happiness: 120 (starting happiness) - (1 * 30) (1 neighbor) = 90\nThe grid happiness is 90 + 80 + 90 = 260.\n\nExample 3:\n\nInput: m = 2, n = 2, introvertsCount = 4, extrovertsCount = 0\nOutput: 240\n\n \nConstraints:\n\n1 <= m, n <= 5\n0 <= introvertsCount, extrovertsCount <= min(m * n, 6)\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(m = 5,n = 5,introvertsCount = 6,extrovertsCount = 6) == 1240\n assert candidate(m = 1,n = 1,introvertsCount = 0,extrovertsCount = 1) == 40\n assert candidate(m = 5,n = 1,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 2,n = 3,introvertsCount = 1,extrovertsCount = 2) == 240\n assert candidate(m = 1,n = 1,introvertsCount = 1,extrovertsCount = 0) == 120\n assert candidate(m = 4,n = 4,introvertsCount = 6,extrovertsCount = 0) == 720\n assert candidate(m = 2,n = 2,introvertsCount = 4,extrovertsCount = 0) == 240\n assert candidate(m = 3,n = 1,introvertsCount = 2,extrovertsCount = 1) == 260\n assert candidate(m = 1,n = 1,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 5,n = 1,introvertsCount = 0,extrovertsCount = 5) == 360\n assert candidate(m = 4,n = 4,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 5,n = 5,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 1,n = 5,introvertsCount = 5,extrovertsCount = 0) == 360\n assert candidate(m = 4,n = 5,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 2,n = 5,introvertsCount = 5,extrovertsCount = 5) == 770\n assert candidate(m = 3,n = 5,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 2,n = 5,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 2,n = 2,introvertsCount = 6,extrovertsCount = 0) == 240\n assert candidate(m = 5,n = 2,introvertsCount = 4,extrovertsCount = 2) == 590\n assert candidate(m = 3,n = 3,introvertsCount = 4,extrovertsCount = 1) == 520\n assert candidate(m = 4,n = 3,introvertsCount = 4,extrovertsCount = 3) == 680\n assert candidate(m = 5,n = 2,introvertsCount = 5,extrovertsCount = 1) == 620\n assert candidate(m = 5,n = 2,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 5,n = 5,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 4,n = 4,introvertsCount = 3,extrovertsCount = 4) == 680\n assert candidate(m = 4,n = 4,introvertsCount = 1,extrovertsCount = 6) == 640\n assert candidate(m = 4,n = 4,introvertsCount = 6,extrovertsCount = 6) == 1140\n assert candidate(m = 3,n = 2,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 5,n = 5,introvertsCount = 6,extrovertsCount = 5) == 1120\n assert candidate(m = 4,n = 4,introvertsCount = 2,extrovertsCount = 2) == 360\n assert candidate(m = 1,n = 5,introvertsCount = 1,extrovertsCount = 4) == 390\n assert candidate(m = 4,n = 4,introvertsCount = 4,extrovertsCount = 4) == 800\n assert candidate(m = 2,n = 5,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 5,n = 2,introvertsCount = 4,extrovertsCount = 1) == 520\n assert candidate(m = 3,n = 5,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 2,n = 5,introvertsCount = 2,extrovertsCount = 2) == 360\n assert candidate(m = 3,n = 3,introvertsCount = 4,extrovertsCount = 3) == 640\n assert candidate(m = 3,n = 4,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 5,n = 3,introvertsCount = 1,extrovertsCount = 4) == 440\n assert candidate(m = 4,n = 3,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 3,n = 2,introvertsCount = 0,extrovertsCount = 3) == 200\n assert candidate(m = 5,n = 4,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 3,n = 3,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 3,n = 3,introvertsCount = 5,extrovertsCount = 1) == 610\n assert candidate(m = 5,n = 1,introvertsCount = 5,extrovertsCount = 1) == 380\n assert candidate(m = 5,n = 5,introvertsCount = 5,extrovertsCount = 1) == 640\n assert candidate(m = 4,n = 4,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 4,n = 3,introvertsCount = 5,extrovertsCount = 1) == 640\n assert candidate(m = 4,n = 2,introvertsCount = 4,extrovertsCount = 2) == 520\n assert candidate(m = 5,n = 3,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 4,n = 3,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 3,n = 5,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 3,n = 3,introvertsCount = 3,extrovertsCount = 3) == 550\n assert candidate(m = 4,n = 2,introvertsCount = 3,extrovertsCount = 2) == 470\n assert candidate(m = 5,n = 3,introvertsCount = 4,extrovertsCount = 2) == 600\n assert candidate(m = 4,n = 2,introvertsCount = 2,extrovertsCount = 4) == 550\n assert candidate(m = 5,n = 3,introvertsCount = 6,extrovertsCount = 0) == 720\n assert candidate(m = 5,n = 2,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 4,n = 2,introvertsCount = 1,extrovertsCount = 5) == 520\n assert candidate(m = 4,n = 5,introvertsCount = 1,extrovertsCount = 4) == 440\n assert candidate(m = 4,n = 4,introvertsCount = 4,extrovertsCount = 3) == 680\n assert candidate(m = 4,n = 1,introvertsCount = 2,extrovertsCount = 2) == 340\n assert candidate(m = 4,n = 3,introvertsCount = 5,extrovertsCount = 2) == 710\n assert candidate(m = 5,n = 3,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 2,n = 5,introvertsCount = 1,extrovertsCount = 5) == 520\n assert candidate(m = 5,n = 3,introvertsCount = 3,extrovertsCount = 4) == 680\n assert candidate(m = 4,n = 4,introvertsCount = 4,extrovertsCount = 2) == 600\n assert candidate(m = 4,n = 5,introvertsCount = 6,extrovertsCount = 2) == 840\n assert candidate(m = 3,n = 4,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 3,n = 4,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 3,n = 3,introvertsCount = 4,extrovertsCount = 4) == 700\n assert candidate(m = 2,n = 2,introvertsCount = 2,extrovertsCount = 2) == 280\n assert candidate(m = 5,n = 4,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 3,n = 3,introvertsCount = 6,extrovertsCount = 0) == 600\n assert candidate(m = 4,n = 3,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 5,n = 1,introvertsCount = 5,extrovertsCount = 0) == 360\n assert candidate(m = 2,n = 4,introvertsCount = 3,extrovertsCount = 2) == 470\n assert candidate(m = 2,n = 2,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 3,n = 3,introvertsCount = 1,extrovertsCount = 1) == 160\n assert candidate(m = 1,n = 5,introvertsCount = 3,extrovertsCount = 3) == 420\n assert candidate(m = 3,n = 3,introvertsCount = 2,extrovertsCount = 2) == 360\n assert candidate(m = 3,n = 3,introvertsCount = 2,extrovertsCount = 4) == 550\n assert candidate(m = 2,n = 2,introvertsCount = 0,extrovertsCount = 1) == 40\n assert candidate(m = 2,n = 2,introvertsCount = 0,extrovertsCount = 2) == 120\n assert candidate(m = 3,n = 3,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 3,n = 3,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 5,n = 2,introvertsCount = 5,extrovertsCount = 5) == 770\n assert candidate(m = 5,n = 1,introvertsCount = 3,extrovertsCount = 3) == 420\n assert candidate(m = 5,n = 2,introvertsCount = 5,extrovertsCount = 0) == 600\n assert candidate(m = 4,n = 4,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 5,n = 1,introvertsCount = 1,extrovertsCount = 0) == 120\n assert candidate(m = 2,n = 2,introvertsCount = 1,extrovertsCount = 1) == 160\n assert candidate(m = 1,n = 5,introvertsCount = 0,extrovertsCount = 5) == 360\n assert candidate(m = 4,n = 4,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 4,n = 4,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 4,n = 5,introvertsCount = 5,extrovertsCount = 4) == 920\n assert candidate(m = 1,n = 1,introvertsCount = 1,extrovertsCount = 1) == 120\n assert candidate(m = 5,n = 5,introvertsCount = 1,extrovertsCount = 1) == 160\n assert candidate(m = 1,n = 5,introvertsCount = 1,extrovertsCount = 0) == 120\n assert candidate(m = 1,n = 5,introvertsCount = 0,extrovertsCount = 1) == 40\n assert candidate(m = 5,n = 1,introvertsCount = 0,extrovertsCount = 1) == 40\n assert candidate(m = 2,n = 5,introvertsCount = 3,extrovertsCount = 2) == 480\n"}, "metadata": {"canonical_parameter_names": ["m", "n", "introvertsCount", "extrovertsCount"], "leetcode_dataset_entry_point": "Solution().getMaxGridHappiness", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getMaxGridHappiness(self, m: int, n: int, introvertsCount: int, extrovertsCount: int) -> int:", "container": "Solution", "callable": "getMaxGridHappiness", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "introvertsCount", "type": "int"}, {"name": "extrovertsCount", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1662, "task_id": "check-if-two-string-arrays-are-equivalent", "difficulty": "Easy", "problem_description": "Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise.\nA string is represented by an array if the array elements concatenated in order forms the string.\n \nExample 1:\n\nInput: word1 = [\"ab\", \"c\"], word2 = [\"a\", \"bc\"]\nOutput: true\nExplanation:\nword1 represents string \"ab\" + \"c\" -> \"abc\"\nword2 represents string \"a\" + \"bc\" -> \"abc\"\nThe strings are the same, so return true.\nExample 2:\n\nInput: word1 = [\"a\", \"cb\"], word2 = [\"ab\", \"c\"]\nOutput: false\n\nExample 3:\n\nInput: word1 = [\"abc\", \"d\", \"defg\"], word2 = [\"abcddefg\"]\nOutput: true\n\n \nConstraints:\n\n1 <= word1.length, word2.length <= 103\n1 <= word1[i].length, word2[i].length <= 103\n1 <= sum(word1[i].length), sum(word2[i].length) <= 103\nword1[i] and word2[i] consist of lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = ['abc', 'd', 'defg'],word2 = ['abcddefg']) == True\n assert candidate(word1 = ['x'],word2 = ['y']) == False\n assert candidate(word1 = ['different'],word2 = ['string']) == False\n assert candidate(word1 = ['hello', 'world'],word2 = ['helloworld']) == True\n assert candidate(word1 = ['one', 'two', 'three'],word2 = ['onetwothree']) == True\n assert candidate(word1 = ['abc'],word2 = ['a', 'b', 'c']) == True\n assert candidate(word1 = ['abc'],word2 = ['ab', 'c']) == True\n assert candidate(word1 = ['xyz'],word2 = ['x', 'y', 'z']) == True\n assert candidate(word1 = ['hello', 'world'],word2 = ['helloWorld']) == False\n assert candidate(word1 = ['ab', 'c'],word2 = ['a', 'bc']) == True\n assert candidate(word1 = ['a'],word2 = ['a']) == True\n assert candidate(word1 = ['a', 'cb'],word2 = ['ab', 'c']) == False\n assert candidate(word1 = ['hello'],word2 = ['hello']) == True\n assert candidate(word1 = ['test'],word2 = ['t', 'es', 't']) == True\n assert candidate(word1 = ['a', 'b'],word2 = ['ab']) == True\n assert candidate(word1 = ['same', 'string'],word2 = ['same', 'string']) == True\n assert candidate(word1 = ['a', 'b', 'c'],word2 = ['a', 'b', 'c']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g'],word2 = ['abcdefg']) == True\n assert candidate(word1 = ['split', 'in', 'pieces'],word2 = ['spli', 'tin', 'pi', 'eces']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd', 'e', 'f'],word2 = ['abcdef']) == True\n assert candidate(word1 = ['complex', 'string', 'example'],word2 = ['com', 'plex', 'string', 'ex', 'ample']) == True\n assert candidate(word1 = ['a', 'b', 'c'],word2 = ['ab', 'c']) == True\n assert candidate(word1 = ['same', 'same', 'same'],word2 = ['same', 'same', 'same']) == True\n assert candidate(word1 = ['split', 'this', 'up'],word2 = ['splitthis', 'up']) == True\n assert candidate(word1 = ['a', 'b', 'c'],word2 = ['d', 'e', 'f']) == False\n assert candidate(word1 = ['xyz', '123', 'abc'],word2 = ['xyz1', '23abc']) == True\n assert candidate(word1 = ['abcdef'],word2 = ['abc', 'd', 'e', 'f']) == True\n assert candidate(word1 = ['abcd', 'efgh', 'ijkl'],word2 = ['abcdefgh', 'ijkl']) == True\n assert candidate(word1 = ['abc', 'def'],word2 = ['abcdefg']) == False\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abc', 'd', 'efghi']) == True\n assert candidate(word1 = ['complex', 'word'],word2 = ['c', 'o', 'm', 'p', 'l', 'e', 'x', 'word']) == True\n assert candidate(word1 = ['partial', 'match'],word2 = ['partialm', 'atch']) == True\n assert candidate(word1 = ['a', 'bc', 'def', 'ghij'],word2 = ['abc', 'defghij']) == True\n assert candidate(word1 = ['equal', 'strings'],word2 = ['equalstrings']) == True\n assert candidate(word1 = ['example'],word2 = ['ex', 'ample']) == True\n assert candidate(word1 = ['complex', 'example'],word2 = ['com', 'plexex', 'ample']) == True\n assert candidate(word1 = ['abcdefg', 'hijklmn'],word2 = ['abc', 'defghijklmn']) == True\n assert candidate(word1 = ['same'],word2 = ['s', 'a', 'm', 'e']) == True\n assert candidate(word1 = ['long', 'word', 'sequence'],word2 = ['l', 'ongw', 'ordsequ', 'ence']) == True\n assert candidate(word1 = ['a', 'very', 'long', 'string', 'here'],word2 = ['averylongstringhere']) == True\n assert candidate(word1 = ['same', 'string'],word2 = ['sam', 'e', 'string']) == True\n assert candidate(word1 = ['abc', 'defg', 'hijkl'],word2 = ['abcdefg', 'hijkl']) == True\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abcdef', 'ghi']) == True\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abcdefg', 'hi']) == True\n assert candidate(word1 = ['long', 'string', 'here'],word2 = ['longstring', 'here']) == True\n assert candidate(word1 = ['x', 'y', 'z'],word2 = ['xyz']) == True\n assert candidate(word1 = ['z'],word2 = ['z']) == True\n assert candidate(word1 = ['one', 'two', 'three', 'four'],word2 = ['onetwo', 'three', 'four']) == True\n assert candidate(word1 = ['one', 'two', 'three', 'four'],word2 = ['onetwo', 'threefour']) == True\n assert candidate(word1 = ['x', 'y', 'z'],word2 = ['x', 'yz']) == True\n assert candidate(word1 = ['xyz', 'uvw'],word2 = ['xy', 'zu', 'vw']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd', 'e'],word2 = ['abcd', 'e']) == True\n assert candidate(word1 = ['longerstring', 'here'],word2 = ['longerstringhere']) == True\n assert candidate(word1 = ['onetwothree'],word2 = ['one', 'two', 'three']) == True\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['ab', 'cdef', 'ghi']) == True\n assert candidate(word1 = ['abcd'],word2 = ['ab', 'c', 'd']) == True\n assert candidate(word1 = ['one', 'two', 'three', 'four'],word2 = ['onetwothreefour']) == True\n assert candidate(word1 = ['almost', 'thesame'],word2 = ['almostthesame', 'extra']) == False\n assert candidate(word1 = ['split', 'into', 'multiple', 'parts'],word2 = ['splitint', 'omulti', 'pleparts']) == True\n assert candidate(word1 = ['ab', 'cde', 'f'],word2 = ['abc', 'def']) == True\n assert candidate(word1 = ['same', 'string', 'here'],word2 = ['samestringhere']) == True\n assert candidate(word1 = ['xyz', 'uvw', 'mnop'],word2 = ['xyzu', 'vw', 'mnop']) == True\n assert candidate(word1 = ['xyz', 'uvw', 'qrst'],word2 = ['xyzuvw', 'qrst']) == True\n assert candidate(word1 = ['same', 'string', 'here'],word2 = ['sam', 'e', 'stringhere']) == True\n assert candidate(word1 = ['longstringhere', 'another'],word2 = ['longstringhereanother']) == True\n assert candidate(word1 = ['this', 'is', 'a', 'test'],word2 = ['thi', 'sisa', 'test']) == True\n assert candidate(word1 = ['abc', 'defg', 'hijk', 'lmnop'],word2 = ['abcdefg', 'hijklmnop']) == True\n assert candidate(word1 = ['longstringhere', 'anotherlongstringhere'],word2 = ['longstringhereanotherlongstringhere']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd', 'e'],word2 = ['abcde']) == True\n assert candidate(word1 = ['part1', 'part2', 'part3'],word2 = ['part', '1part2', 'part3']) == True\n assert candidate(word1 = ['a', 'longer', 'string', 'here'],word2 = ['a', 'longerstring', 'here']) == True\n assert candidate(word1 = ['part1', 'part2'],word2 = ['part1part2']) == True\n assert candidate(word1 = ['a', 'b', 'c'],word2 = ['abc']) == True\n assert candidate(word1 = ['different', 'length'],word2 = ['differentlen', 'gth']) == True\n assert candidate(word1 = ['longstringone', 'longstringtwo'],word2 = ['longstringone', 'long', 'string', 'two']) == True\n assert candidate(word1 = ['same', 'string', 'here'],word2 = ['samestring', 'here']) == True\n assert candidate(word1 = ['short'],word2 = ['loooooooonger']) == False\n assert candidate(word1 = ['hello', 'world'],word2 = ['he', 'll', 'o', 'wor', 'ld']) == True\n assert candidate(word1 = ['hello', 'world', 'python'],word2 = ['hello', 'wor', 'ldpy', 'thon']) == True\n assert candidate(word1 = ['another', 'example', 'with', 'spaces'],word2 = ['anotherexam', 'plewithspaces']) == True\n assert candidate(word1 = ['xyz', 'uvw', 'rst'],word2 = ['xyzuvw', 'rst']) == True\n assert candidate(word1 = ['abc', 'def'],word2 = ['a', 'bc', 'd', 'ef']) == True\n assert candidate(word1 = ['this', 'is', 'a', 'test'],word2 = ['thisisatest']) == True\n assert candidate(word1 = ['samestringhere'],word2 = ['same', 'string', 'here']) == True\n assert candidate(word1 = ['abcd'],word2 = ['a', 'b', 'c', 'd']) == True\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abcdefghi']) == True\n assert candidate(word1 = ['a', 'a', 'a', 'a', 'a'],word2 = ['a', 'a', 'a', 'a', 'a']) == True\n assert candidate(word1 = ['a', 'a', 'a', 'a', 'a'],word2 = ['aaaaa']) == True\n assert candidate(word1 = ['mismatch', 'here'],word2 = ['mismatch', 'there']) == False\n assert candidate(word1 = ['one', 'two', 'three'],word2 = ['on', 'etwothree']) == True\n assert candidate(word1 = ['part', 'one'],word2 = ['p', 'artone']) == True\n assert candidate(word1 = ['equal', 'length', 'words'],word2 = ['equal', 'length', 'word']) == False\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abc', 'def', 'ghi']) == True\n assert candidate(word1 = ['equal', 'length'],word2 = ['equal', 'length']) == True\n assert candidate(word1 = ['longwordhere'],word2 = ['l', 'on', 'g', 'wo', 'rd', 'here']) == True\n assert candidate(word1 = ['longer', 'string', 'example'],word2 = ['longerstringexample']) == True\n assert candidate(word1 = ['singleword'],word2 = ['single', 'word']) == True\n assert candidate(word1 = ['different', 'sizes'],word2 = ['different', 'siz', 'es']) == True\n assert candidate(word1 = ['a'],word2 = ['b']) == False\n assert candidate(word1 = ['one', 'two', 'three'],word2 = ['one', 'twothree']) == True\n assert candidate(word1 = ['split', 'this', 'way'],word2 = ['sp', 'lit', 'thi', 'sway']) == True\n assert candidate(word1 = ['one', 'two', 'three'],word2 = ['onetwo', 'three']) == True\n assert candidate(word1 = ['this', 'is', 'a', 'test'],word2 = ['thisis', 'atest']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd'],word2 = ['abcd']) == True\n assert candidate(word1 = ['split', 'across', 'multiple', 'parts'],word2 = ['splitacrossmultip', 'leparts']) == True\n"}, "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().arrayStringsAreEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def arrayStringsAreEqual(self, word1: list[str], word2: list[str]) -> bool:", "container": "Solution", "callable": "arrayStringsAreEqual", "parameters": [{"name": "word1", "type": "list[str]"}, {"name": "word2", "type": "list[str]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1663, "task_id": "smallest-string-with-a-given-numeric-value", "difficulty": "Medium", "problem_description": "The numeric value of a lowercase character is defined as its position (1-indexed) in the alphabet, so the numeric value of a is 1, the numeric value of b is 2, the numeric value of c is 3, and so on.\nThe numeric value of a string consisting of lowercase characters is defined as the sum of its characters' numeric values. For example, the numeric value of the string \"abe\" is equal to 1 + 2 + 5 = 8.\nYou are given two integers n and k. Return the lexicographically smallest string with length equal to n and numeric value equal to k.\nNote that a string x is lexicographically smaller than string y if x comes before y in dictionary order, that is, either x is a prefix of y, or if i is the first position such that x[i] != y[i], then x[i] comes before y[i] in alphabetic order.\n \nExample 1:\n\nInput: n = 3, k = 27\nOutput: \"aay\"\nExplanation: The numeric value of the string is 1 + 1 + 25 = 27, and it is the smallest string with such a value and length equal to 3.\n\nExample 2:\n\nInput: n = 5, k = 73\nOutput: \"aaszz\"\n\n \nConstraints:\n\n1 <= n <= 105\nn <= k <= 26 * n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 7,k = 100) == \"aaaszzz\"\n assert candidate(n = 1,k = 26) == \"z\"\n assert candidate(n = 4,k = 40) == \"aalz\"\n assert candidate(n = 5,k = 73) == \"aaszz\"\n assert candidate(n = 10,k = 260) == \"zzzzzzzzzz\"\n assert candidate(n = 2,k = 2) == \"aa\"\n assert candidate(n = 1,k = 1) == \"a\"\n assert candidate(n = 2,k = 26) == \"ay\"\n assert candidate(n = 4,k = 52) == \"aaxz\"\n assert candidate(n = 3,k = 27) == \"aay\"\n assert candidate(n = 10,k = 100) == \"aaaaaapzzz\"\n assert candidate(n = 50,k = 650) == \"aaaaaaaaaaaaaaaaaaaaaaaaaazzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 100,k = 1000) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 6,k = 161) == \"zzzzz\"\n assert candidate(n = 12,k = 300) == \"nzzzzzzzzzzz\"\n assert candidate(n = 6,k = 156) == \"zzzzzz\"\n assert candidate(n = 10,k = 131) == \"aaaaavzzzz\"\n assert candidate(n = 5,k = 67) == \"aamzz\"\n assert candidate(n = 15,k = 350) == \"akzzzzzzzzzzzzz\"\n assert candidate(n = 25,k = 650) == \"zzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 12,k = 150) == \"aaaaaanzzzzz\"\n assert candidate(n = 7,k = 145) == \"anzzzzz\"\n assert candidate(n = 6,k = 45) == \"aaaaoz\"\n assert candidate(n = 6,k = 160) == \"zzzzz~\"\n assert candidate(n = 3,k = 51) == \"axz\"\n assert candidate(n = 11,k = 260) == \"ayzzzzzzzzz\"\n assert candidate(n = 30,k = 800) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzŽ\"\n assert candidate(n = 15,k = 180) == \"aaaaaaaapzzzzzz\"\n assert candidate(n = 9,k = 150) == \"aaaqzzzzz\"\n assert candidate(n = 7,k = 104) == \"aaawzzz\"\n assert candidate(n = 7,k = 150) == \"aszzzzz\"\n assert candidate(n = 8,k = 175) == \"arzzzzzz\"\n assert candidate(n = 10,k = 150) == \"aaaapzzzzz\"\n assert candidate(n = 20,k = 400) == \"aaaafzzzzzzzzzzzzzzz\"\n assert candidate(n = 10,k = 52) == \"aaaaaaaarz\"\n assert candidate(n = 6,k = 180) == \"zzzzz’\"\n assert candidate(n = 6,k = 100) == \"aatzzz\"\n assert candidate(n = 12,k = 200) == \"aaaanzzzzzzz\"\n assert candidate(n = 8,k = 208) == \"zzzzzzzz\"\n assert candidate(n = 3,k = 25) == \"aaw\"\n assert candidate(n = 20,k = 200) == \"aaaaaaaaaaaafzzzzzzz\"\n assert candidate(n = 15,k = 150) == \"aaaaaaaaakzzzzz\"\n assert candidate(n = 100,k = 2600) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 6,k = 78) == \"aaawzz\"\n assert candidate(n = 15,k = 225) == \"aaaaaakzzzzzzzz\"\n assert candidate(n = 26,k = 676) == \"zzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 3,k = 30) == \"acz\"\n assert candidate(n = 12,k = 312) == \"zzzzzzzzzzzz\"\n assert candidate(n = 9,k = 182) == \"aaxzzzzzz\"\n assert candidate(n = 7,k = 91) == \"aaajzzz\"\n assert candidate(n = 5,k = 130) == \"zzzzz\"\n assert candidate(n = 8,k = 120) == \"aaamzzzz\"\n assert candidate(n = 9,k = 234) == \"zzzzzzzzz\"\n assert candidate(n = 5,k = 125) == \"uzzzz\"\n assert candidate(n = 30,k = 780) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 20,k = 520) == \"zzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 50,k = 1300) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 4,k = 50) == \"aavz\"\n assert candidate(n = 11,k = 286) == \"zzzzzzzzzzz\"\n assert candidate(n = 15,k = 200) == \"aaaaaaakzzzzzzz\"\n assert candidate(n = 9,k = 230) == \"vzzzzzzzz\"\n assert candidate(n = 4,k = 10) == \"aaag\"\n assert candidate(n = 2,k = 27) == \"az\"\n assert candidate(n = 7,k = 42) == \"aaaaakz\"\n assert candidate(n = 4,k = 90) == \"lzzz\"\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().getSmallestString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getSmallestString(self, n: int, k: int) -> str:", "container": "Solution", "callable": "getSmallestString", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1664, "task_id": "ways-to-make-a-fair-array", "difficulty": "Medium", "problem_description": "You are given an integer array nums. You can choose exactly one index (0-indexed) and remove the element. Notice that the index of the elements may change after the removal.\nFor example, if nums = [6,1,7,4,1]:\n\nChoosing to remove index 1 results in nums = [6,7,4,1].\nChoosing to remove index 2 results in nums = [6,1,4,1].\nChoosing to remove index 4 results in nums = [6,1,7,4].\n\nAn array is fair if the sum of the odd-indexed values equals the sum of the even-indexed values.\nReturn the number of indices that you could choose such that after the removal, nums is fair. \n \nExample 1:\n\nInput: nums = [2,1,6,4]\nOutput: 1\nExplanation:\nRemove index 0: [1,6,4] -> Even sum: 1 + 4 = 5. Odd sum: 6. Not fair.\nRemove index 1: [2,6,4] -> Even sum: 2 + 4 = 6. Odd sum: 6. Fair.\nRemove index 2: [2,1,4] -> Even sum: 2 + 4 = 6. Odd sum: 1. Not fair.\nRemove index 3: [2,1,6] -> Even sum: 2 + 6 = 8. Odd sum: 1. Not fair.\nThere is 1 index that you can remove to make nums fair.\n\nExample 2:\n\nInput: nums = [1,1,1]\nOutput: 3\nExplanation: You can remove any index and the remaining array is fair.\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: 0\nExplanation: You cannot make a fair array after removing any index.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 0\n assert candidate(nums = [1, 2]) == 0\n assert candidate(nums = [2, 1, 6, 4]) == 1\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000]) == 5\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [1, 1, 1]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50]) == 0\n assert candidate(nums = [4, 5, 6, 7, 8]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 0\n assert candidate(nums = [9999, 1, 9999, 1, 9999, 1, 9999, 1, 9999, 1]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [23, 17, 14, 6, 9, 4, 3, 10, 13, 2, 11, 1, 5, 15, 7, 12, 8, 16, 19, 18]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 0\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11, 33, 55, 77, 99, 22, 44, 66, 88, 10]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 0\n assert candidate(nums = [7, 10, 5, 8, 6, 3, 2, 9, 4, 1]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 0\n assert candidate(nums = [10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 0\n assert candidate(nums = [10000]) == 1\n assert candidate(nums = [5, 3, 2, 4, 1, 6, 7, 8, 9, 10, 11, 12]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(nums = [10000, 9999, 10000, 9999, 10000, 9999, 10000, 9999, 10000, 9999]) == 0\n assert candidate(nums = [42]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 0\n assert candidate(nums = [5, 3, 5, 3, 5, 3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == 0\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 999999999, 99999999, 9999999, 999999, 99999, 9999, 999, 99, 9, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [2468, 1357, 2468, 1357, 2468, 1357, 2468, 1357, 2468, 1357, 2468, 1357, 2468, 1357, 2468]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(nums = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 13\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 0\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(nums = [2, 1, 6, 4, 3, 5, 7, 8]) == 0\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 91\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\n assert candidate(nums = [10000, 1, 10000, 1, 10000, 1]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().waysToMakeFair", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def waysToMakeFair(self, nums: list[int]) -> int:", "container": "Solution", "callable": "waysToMakeFair", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1665, "task_id": "minimum-initial-energy-to-finish-tasks", "difficulty": "Hard", "problem_description": "You are given an array tasks where tasks[i] = [actuali, minimumi]:\n\nactuali is the actual amount of energy you spend to finish the ith task.\nminimumi is the minimum amount of energy you require to begin the ith task.\n\nFor example, if the task is [10, 12] and your current energy is 11, you cannot start this task. However, if your current energy is 13, you can complete this task, and your energy will be 3 after finishing it.\nYou can finish the tasks in any order you like.\nReturn the minimum initial amount of energy you will need to finish all the tasks.\n \nExample 1:\n\nInput: tasks = [[1,2],[2,4],[4,8]]\nOutput: 8\nExplanation:\nStarting with 8 energy, we finish the tasks in the following order:\n - 3rd task. Now energy = 8 - 4 = 4.\n - 2nd task. Now energy = 4 - 2 = 2.\n - 1st task. Now energy = 2 - 1 = 1.\nNotice that even though we have leftover energy, starting with 7 energy does not work because we cannot do the 3rd task.\nExample 2:\n\nInput: tasks = [[1,3],[2,4],[10,11],[10,12],[8,9]]\nOutput: 32\nExplanation:\nStarting with 32 energy, we finish the tasks in the following order:\n - 1st task. Now energy = 32 - 1 = 31.\n - 2nd task. Now energy = 31 - 2 = 29.\n - 3rd task. Now energy = 29 - 10 = 19.\n - 4th task. Now energy = 19 - 10 = 9.\n - 5th task. Now energy = 9 - 8 = 1.\nExample 3:\n\nInput: tasks = [[1,7],[2,8],[3,9],[4,10],[5,11],[6,12]]\nOutput: 27\nExplanation:\nStarting with 27 energy, we finish the tasks in the following order:\n - 5th task. Now energy = 27 - 5 = 22.\n - 2nd task. Now energy = 22 - 2 = 20.\n - 3rd task. Now energy = 20 - 3 = 17.\n - 1st task. Now energy = 17 - 1 = 16.\n - 4th task. Now energy = 16 - 4 = 12.\n - 6th task. Now energy = 12 - 6 = 6.\n\n \nConstraints:\n\n1 <= tasks.length <= 105\n1 <= actual​i <= minimumi <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [[10, 15], [20, 25], [30, 35]]) == 65\n assert candidate(tasks = [[10, 15], [5, 10], [3, 7]]) == 22\n assert candidate(tasks = [[10, 10], [15, 15], [5, 5]]) == 30\n assert candidate(tasks = [[1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12]]) == 27\n assert candidate(tasks = [[5, 10], [1, 2], [3, 4]]) == 10\n assert candidate(tasks = [[1, 2], [2, 4], [4, 8]]) == 8\n assert candidate(tasks = [[3, 3], [2, 5], [1, 4]]) == 6\n assert candidate(tasks = [[1, 100], [2, 99], [3, 98]]) == 101\n assert candidate(tasks = [[10, 10], [10, 10], [10, 10], [10, 10]]) == 40\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3]]) == 6\n assert candidate(tasks = [[1, 3], [2, 4], [10, 11], [10, 12], [8, 9]]) == 32\n assert candidate(tasks = [[1, 50], [2, 51], [3, 52], [4, 53], [5, 54], [6, 55], [7, 56], [8, 57], [9, 58], [10, 59], [11, 60], [12, 61], [13, 62], [14, 63], [15, 64], [16, 65], [17, 66], [18, 67], [19, 68], [20, 69], [21, 70], [22, 71], [23, 72], [24, 73], [25, 74]]) == 374\n assert candidate(tasks = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995]]) == 10010\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 191\n assert candidate(tasks = [[1, 2], [2, 4], [4, 8], [8, 16], [16, 32]]) == 32\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 56\n assert candidate(tasks = [[1, 10000], [10000, 10000], [1, 10000], [10000, 10000], [1, 10000]]) == 20003\n assert candidate(tasks = [[10000, 10000], [1, 2], [10000, 10000], [1, 2], [10000, 10000], [1, 2]]) == 30003\n assert candidate(tasks = [[100, 150], [50, 100], [30, 70], [20, 50], [10, 30], [5, 15]]) == 230\n assert candidate(tasks = [[10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10]]) == 100\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25]]) == 45\n assert candidate(tasks = [[100, 120], [200, 220], [300, 320], [400, 420], [500, 520]]) == 1520\n assert candidate(tasks = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 59\n assert candidate(tasks = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 100\n assert candidate(tasks = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 110], [12, 120], [13, 130], [14, 140], [15, 150]]) == 165\n assert candidate(tasks = [[100, 100], [90, 90], [80, 80], [70, 70], [60, 60], [50, 50], [40, 40], [30, 30], [20, 20], [10, 10], [5, 5]]) == 555\n assert candidate(tasks = [[9999, 10000], [9998, 10001], [9997, 10002], [9996, 10003], [9995, 10004], [9994, 10005], [9993, 10006], [9992, 10007], [9991, 10008], [9990, 10009]]) == 99946\n assert candidate(tasks = [[100, 105], [10, 15], [1, 2], [5, 7], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65], [70, 75]]) == 387\n assert candidate(tasks = [[5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19]]) == 79\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 55\n assert candidate(tasks = [[9999, 10000], [9998, 9999], [9997, 9998], [9996, 9997], [9995, 9996]]) == 49986\n assert candidate(tasks = [[100, 101], [99, 100], [98, 99], [97, 98], [96, 97], [95, 96]]) == 586\n assert candidate(tasks = [[1000, 1000], [900, 950], [800, 850], [700, 750], [600, 650]]) == 4000\n assert candidate(tasks = [[100, 200], [100, 300], [100, 400], [100, 500], [100, 600], [100, 700], [100, 800], [100, 900], [100, 1000]]) == 1000\n assert candidate(tasks = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]]) == 55\n assert candidate(tasks = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == 136\n assert candidate(tasks = [[1000, 1001], [2000, 2002], [3000, 3003], [4000, 4004], [5000, 5005], [6000, 6006], [7000, 7007], [8000, 8008], [9000, 9009], [10000, 10001]]) == 55001\n assert candidate(tasks = [[500, 1000], [400, 900], [300, 800], [200, 700], [100, 600], [50, 500], [25, 400], [12, 300], [7, 200], [5, 100], [3, 50]]) == 2000\n assert candidate(tasks = [[1, 10000], [10000, 10000], [1, 10000], [10000, 10000], [1, 10000], [10000, 10000]]) == 30003\n assert candidate(tasks = [[10000, 10000], [9999, 9999], [9998, 9998], [9997, 9997], [9996, 9996], [9995, 9995], [9994, 9994], [9993, 9993], [9992, 9992], [9991, 9991]]) == 99955\n assert candidate(tasks = [[1000, 1001], [999, 1002], [998, 1003], [997, 1004], [996, 1005], [995, 1006], [994, 1007], [993, 1008], [992, 1009], [991, 1010], [990, 1011], [989, 1012], [988, 1013], [987, 1014], [986, 1015], [985, 1016], [984, 1017], [983, 1018], [982, 1019], [981, 1020]]) == 19811\n assert candidate(tasks = [[1, 2], [100, 101], [1, 2], [100, 101], [1, 2], [100, 101]]) == 304\n assert candidate(tasks = [[500, 500], [500, 500], [500, 500], [500, 500], [500, 500]]) == 2500\n assert candidate(tasks = [[5, 10], [2, 8], [3, 5], [4, 7]]) == 16\n assert candidate(tasks = [[5000, 5000], [4999, 4999], [4998, 4998], [4997, 4997], [4996, 4996], [4995, 4995], [4994, 4994], [4993, 4993], [4992, 4992], [4991, 4991], [4990, 4990], [4989, 4989], [4988, 4988], [4987, 4987], [4986, 4986], [4985, 4985], [4984, 4984], [4983, 4983], [4982, 4982], [4981, 4981], [4980, 4980], [4979, 4979], [4978, 4978], [4977, 4977], [4976, 4976], [4975, 4975], [4974, 4974], [4973, 4973], [4972, 4972], [4971, 4971], [4970, 4970], [4969, 4969], [4968, 4968], [4967, 4967], [4966, 4966], [4965, 4965], [4964, 4964], [4963, 4963], [4962, 4962], [4961, 4961], [4960, 4960]]) == 204180\n assert candidate(tasks = [[5, 10], [4, 9], [3, 8], [2, 7], [1, 6], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15]]) == 60\n assert candidate(tasks = [[10, 11], [20, 21], [30, 31], [40, 41], [50, 51], [60, 61], [70, 71]]) == 281\n assert candidate(tasks = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65], [70, 75], [80, 85], [90, 95], [100, 105]]) == 555\n assert candidate(tasks = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120]]) == 780\n assert candidate(tasks = [[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000]]) == 10000\n assert candidate(tasks = [[1, 10000], [10000, 10000], [1, 10000], [10000, 10000], [1, 10000], [10000, 10000], [1, 10000], [10000, 10000]]) == 40004\n assert candidate(tasks = [[100, 150], [50, 100], [25, 75], [12, 60], [7, 35], [5, 25], [3, 15]]) == 235\n assert candidate(tasks = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 10\n assert candidate(tasks = [[100, 101], [102, 203], [204, 305], [306, 407], [408, 509], [510, 611], [612, 713], [714, 815], [816, 917], [918, 1019]]) == 4691\n assert candidate(tasks = [[9, 10], [8, 9], [7, 8], [6, 7], [5, 6], [4, 5], [3, 4], [2, 3], [1, 2]]) == 46\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 56\n assert candidate(tasks = [[9000, 10000], [8000, 9000], [7000, 8000], [6000, 7000], [5000, 6000], [4000, 5000]]) == 40000\n assert candidate(tasks = [[100, 110], [50, 60], [30, 40], [10, 20], [5, 15], [1, 3]]) == 205\n assert candidate(tasks = [[100, 200], [50, 150], [25, 125], [12, 112], [6, 106], [3, 103], [1, 101], [7, 107], [8, 108], [9, 109], [10, 110]]) == 331\n assert candidate(tasks = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996]]) == 10006\n assert candidate(tasks = [[500, 510], [400, 410], [300, 310], [200, 210], [100, 110], [50, 60], [10, 20], [1, 2], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 1658\n assert candidate(tasks = [[100, 200], [150, 250], [50, 100], [300, 400], [200, 300], [1000, 1200], [500, 600]]) == 2350\n assert candidate(tasks = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995], [7, 9994], [8, 9993], [9, 9992], [10, 9991], [11, 9990], [12, 9989], [13, 9988], [14, 9987], [15, 9986]]) == 10091\n assert candidate(tasks = [[5, 10], [10, 15], [20, 25], [30, 35], [40, 45]]) == 110\n assert candidate(tasks = [[10000, 10000], [9000, 9000], [8000, 8000], [7000, 7000], [6000, 6000], [5000, 5000], [4000, 4000], [3000, 3000], [2000, 2000], [1000, 1000]]) == 55000\n assert candidate(tasks = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995]]) == 10010\n assert candidate(tasks = [[8, 12], [15, 20], [5, 7], [10, 15], [3, 6]]) == 43\n assert candidate(tasks = [[7, 10], [4, 8], [6, 12], [2, 5], [1, 3]]) == 22\n assert candidate(tasks = [[1, 2], [3, 6], [5, 10], [7, 14], [9, 18], [11, 22], [13, 26], [15, 30], [17, 34], [19, 38], [21, 42], [23, 46], [25, 50], [27, 54], [29, 58], [31, 62], [33, 66], [35, 70], [37, 74], [39, 78]]) == 402\n assert candidate(tasks = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 75\n assert candidate(tasks = [[1000, 2000], [500, 1500], [250, 750], [125, 375], [63, 188], [31, 95], [16, 48], [8, 25], [4, 13], [2, 7], [1, 4]]) == 2500\n assert candidate(tasks = [[1000, 1010], [999, 1009], [998, 1008], [997, 1007], [996, 1006], [995, 1005], [994, 1004], [993, 1003], [992, 1002], [991, 1001]]) == 9965\n assert candidate(tasks = [[100, 200], [50, 200], [30, 200], [10, 200], [5, 200], [1, 200], [100, 300], [50, 300], [30, 300], [10, 300], [5, 300], [1, 300]]) == 492\n assert candidate(tasks = [[20, 25], [10, 13], [5, 6], [15, 20], [2, 3], [7, 10]]) == 60\n assert candidate(tasks = [[100, 150], [50, 100], [25, 50], [10, 20], [5, 10]]) == 200\n assert candidate(tasks = [[50, 60], [40, 70], [30, 80], [20, 90], [10, 100], [5, 110], [1, 120]]) == 166\n assert candidate(tasks = [[1000, 1010], [900, 910], [800, 810], [700, 710], [600, 610], [500, 510], [400, 410], [300, 310], [200, 210], [100, 110], [50, 60], [10, 20], [1, 2]]) == 5570\n assert candidate(tasks = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95]]) == 110\n assert candidate(tasks = [[500, 1000], [400, 900], [300, 800], [200, 700], [100, 600], [50, 500], [40, 400], [30, 300], [20, 200], [10, 100]]) == 2000\n assert candidate(tasks = [[1000, 2000], [500, 1500], [300, 1200], [200, 1100], [100, 1000]]) == 3000\n assert candidate(tasks = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30]]) == 226\n assert candidate(tasks = [[5, 7], [8, 10], [12, 14], [15, 18], [20, 22]]) == 62\n assert candidate(tasks = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]]) == 37\n assert candidate(tasks = [[1, 20], [2, 21], [3, 22], [4, 23], [5, 24], [6, 25]]) == 40\n assert candidate(tasks = [[2, 5], [3, 6], [4, 7], [5, 8], [1, 3]]) == 17\n assert candidate(tasks = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0]]) == 55\n assert candidate(tasks = [[100, 200], [150, 250], [200, 300], [50, 100], [25, 50], [75, 150], [30, 60], [40, 80], [60, 120], [80, 160]]) == 835\n assert candidate(tasks = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]) == 460\n assert candidate(tasks = [[10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70], [10, 80], [10, 90], [10, 100], [10, 110], [10, 120]]) == 120\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16]]) == 16\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 121\n assert candidate(tasks = [[5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20]]) == 60\n assert candidate(tasks = [[5, 7], [8, 12], [10, 15], [3, 4], [6, 9], [2, 3]]) == 35\n assert candidate(tasks = [[2, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30]]) == 80\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 10\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]]) == 210\n assert candidate(tasks = [[5000, 5005], [4000, 4007], [3000, 3009], [2000, 2011], [1000, 1013], [500, 517], [100, 121], [50, 130], [10, 140], [1, 150]]) == 15666\n assert candidate(tasks = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]]) == 160\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 191\n assert candidate(tasks = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]]) == 1036\n assert candidate(tasks = [[7, 10], [5, 7], [4, 5], [3, 6], [2, 4]]) == 22\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [100, 100]]) == 115\n assert candidate(tasks = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]]) == 25\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]]) == 91\n"}, "metadata": {"canonical_parameter_names": ["tasks"], "leetcode_dataset_entry_point": "Solution().minimumEffort", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumEffort(self, tasks: list[list[int]]) -> int:", "container": "Solution", "callable": "minimumEffort", "parameters": [{"name": "tasks", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1668, "task_id": "maximum-repeating-substring", "difficulty": "Easy", "problem_description": "For a string sequence, a string word is k-repeating if word concatenated k times is a substring of sequence. The word's maximum k-repeating value is the highest value k where word is k-repeating in sequence. If word is not a substring of sequence, word's maximum k-repeating value is 0.\nGiven strings sequence and word, return the maximum k-repeating value of word in sequence.\n \nExample 1:\n\nInput: sequence = \"ababc\", word = \"ab\"\nOutput: 2\nExplanation: \"abab\" is a substring in \"ababc\".\n\nExample 2:\n\nInput: sequence = \"ababc\", word = \"ba\"\nOutput: 1\nExplanation: \"ba\" is a substring in \"ababc\". \"baba\" is not a substring in \"ababc\".\n\nExample 3:\n\nInput: sequence = \"ababc\", word = \"ac\"\nOutput: 0\nExplanation: \"ac\" is not a substring in \"ababc\". \n\n \nConstraints:\n\n1 <= sequence.length <= 100\n1 <= word.length <= 100\nsequence and word contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sequence = \"ababc\",word = \"ac\") == 0\n assert candidate(sequence = \"banana\",word = \"ana\") == 1\n assert candidate(sequence = \"abcabcabc\",word = \"abc\") == 3\n assert candidate(sequence = \"aaaa\",word = \"aa\") == 2\n assert candidate(sequence = \"abc\",word = \"d\") == 0\n assert candidate(sequence = \"ababc\",word = \"ab\") == 2\n assert candidate(sequence = \"mississippi\",word = \"issi\") == 1\n assert candidate(sequence = \"aaaabaaa\",word = \"aa\") == 2\n assert candidate(sequence = \"ababc\",word = \"ba\") == 1\n assert candidate(sequence = \"a\",word = \"a\") == 1\n assert candidate(sequence = \"abcabcabc\",word = \"abcd\") == 0\n assert candidate(sequence = \"hellohellohello\",word = \"llohe\") == 2\n assert candidate(sequence = \"abababababab\",word = \"abab\") == 3\n assert candidate(sequence = \"abababababababab\",word = \"ababab\") == 2\n assert candidate(sequence = \"aabbccddeeff\",word = \"aabbcc\") == 1\n assert candidate(sequence = \"ababababab\",word = \"ababab\") == 1\n assert candidate(sequence = \"xyxxyxyxyxyxyxyxyxyxyx\",word = \"xyxxy\") == 1\n assert candidate(sequence = \"abcabcabcabc\",word = \"abcd\") == 0\n assert candidate(sequence = \"ababababab\",word = \"ab\") == 5\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcdabcdabcd\",word = \"abcd\") == 8\n assert candidate(sequence = \"abacabadabacaba\",word = \"dab\") == 1\n assert candidate(sequence = \"abcabcabcabcabcabc\",word = \"abcabcabc\") == 2\n assert candidate(sequence = \"abababababababababab\",word = \"ababab\") == 3\n assert candidate(sequence = \"banana\",word = \"ban\") == 1\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"cab\") == 4\n assert candidate(sequence = \"abacabadabacaba\",word = \"cab\") == 1\n assert candidate(sequence = \"hellohellohellohello\",word = \"hello\") == 4\n assert candidate(sequence = \"banana\",word = \"na\") == 2\n assert candidate(sequence = \"abababababab\",word = \"baba\") == 2\n assert candidate(sequence = \"ababababababababab\",word = \"ababab\") == 3\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcd\") == 0\n assert candidate(sequence = \"xyzyzyzyzyzyzyzy\",word = \"zyzyzyzyzyzyzyzy\") == 0\n assert candidate(sequence = \"zzzxxzzzxxzzzxx\",word = \"zzzxx\") == 3\n assert candidate(sequence = \"aabbccddeeffgghhiijj\",word = \"ccdd\") == 1\n assert candidate(sequence = \"xyzxyzxyzxyzxyz\",word = \"zyx\") == 0\n assert candidate(sequence = \"abcabcabcabc\",word = \"cab\") == 3\n assert candidate(sequence = \"ababababababababab\",word = \"bab\") == 1\n assert candidate(sequence = \"bananaananabana\",word = \"ana\") == 2\n assert candidate(sequence = \"aaaaabaaa\",word = \"aaaa\") == 1\n assert candidate(sequence = \"abacabadabacaba\",word = \"bac\") == 1\n assert candidate(sequence = \"aaaaabbbbbcccc\",word = \"abc\") == 0\n assert candidate(sequence = \"aaaaaaa\",word = \"aaa\") == 2\n assert candidate(sequence = \"zzzzzzzzzzzz\",word = \"zzzz\") == 3\n assert candidate(sequence = \"ababababa\",word = \"aba\") == 1\n assert candidate(sequence = \"abababcabababc\",word = \"ababc\") == 1\n assert candidate(sequence = \"ababababababababababababababab\",word = \"abab\") == 7\n assert candidate(sequence = \"aaaabaaaabaaaab\",word = \"aaab\") == 1\n assert candidate(sequence = \"abababababababab\",word = \"baba\") == 3\n assert candidate(sequence = \"xyzyzyzyzyzyzyzy\",word = \"zyzy\") == 3\n assert candidate(sequence = \"abcabcabcabc\",word = \"abcabc\") == 2\n assert candidate(sequence = \"aaaabaaaabaaaabaaaab\",word = \"aaaab\") == 4\n assert candidate(sequence = \"abcabcabc\",word = \"cab\") == 2\n assert candidate(sequence = \"abababababababababab\",word = \"abab\") == 5\n assert candidate(sequence = \"abacabadabacaba\",word = \"abaca\") == 1\n assert candidate(sequence = \"aaaaaaa\",word = \"a\") == 7\n assert candidate(sequence = \"aabbccddeeff\",word = \"abc\") == 0\n assert candidate(sequence = \"abcabcabcabcabcabcabc\",word = \"abca\") == 1\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcabcab\") == 1\n assert candidate(sequence = \"abcdefabcdefabcdef\",word = \"defabc\") == 2\n assert candidate(sequence = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word = \"aabbccddeeffgghhiijjkkll\") == 1\n assert candidate(sequence = \"abcdefabcdefabcdef\",word = \"abcdef\") == 3\n assert candidate(sequence = \"zzzzzzzzzzzzzzzzzzzz\",word = \"zzzzzz\") == 3\n assert candidate(sequence = \"xyzxyzxyzxyzxyzxyz\",word = \"xyzxyzxyz\") == 2\n assert candidate(sequence = \"abababab\",word = \"ab\") == 4\n assert candidate(sequence = \"abacabacabacabacabac\",word = \"abac\") == 5\n assert candidate(sequence = \"aaaaab\",word = \"aaa\") == 1\n assert candidate(sequence = \"aaaaaaa\",word = \"aaaa\") == 1\n assert candidate(sequence = \"ababababababababababab\",word = \"babab\") == 1\n assert candidate(sequence = \"abababab\",word = \"aba\") == 1\n assert candidate(sequence = \"aaaaaabaaa\",word = \"aaa\") == 2\n assert candidate(sequence = \"aaaaabaaaa\",word = \"aaa\") == 1\n assert candidate(sequence = \"ababababab\",word = \"aba\") == 1\n assert candidate(sequence = \"hellohellohellohellohello\",word = \"hellohello\") == 2\n assert candidate(sequence = \"abcabcabcabcabcabcabcabcabcabc\",word = \"abcabcabc\") == 3\n assert candidate(sequence = \"aabbccddeeefffggghhh\",word = \"eefffggg\") == 1\n assert candidate(sequence = \"mississippi\",word = \"iss\") == 2\n assert candidate(sequence = \"abacabacabac\",word = \"abac\") == 3\n assert candidate(sequence = \"xyxyxyxyxyxyxyxy\",word = \"xyxyxyxyxyxyxy\") == 1\n assert candidate(sequence = \"abcabcabcabcabcabcabcabc\",word = \"abcabcabc\") == 2\n assert candidate(sequence = \"aabbccddeeffgghhiijj\",word = \"aabbcc\") == 1\n assert candidate(sequence = \"xyxyxyxyxyxyxyxyxyxy\",word = \"xyxy\") == 5\n assert candidate(sequence = \"xyxyxyxyxyxyxy\",word = \"xyxy\") == 3\n assert candidate(sequence = \"zzzzzzzzzzzzzzzzzzzz\",word = \"zzzz\") == 5\n assert candidate(sequence = \"mississippi\",word = \"miss\") == 1\n assert candidate(sequence = \"ababababababababab\",word = \"ab\") == 9\n assert candidate(sequence = \"hellohellohellohello\",word = \"hellohello\") == 2\n assert candidate(sequence = \"banana\",word = \"nan\") == 1\n assert candidate(sequence = \"abababaaba\",word = \"aba\") == 2\n assert candidate(sequence = \"hellohellohello\",word = \"lohel\") == 2\n assert candidate(sequence = \"qqqqqqqqqqqq\",word = \"qqqq\") == 3\n assert candidate(sequence = \"xyxxyxyxyxyxyx\",word = \"xyxyx\") == 1\n assert candidate(sequence = \"abcdabcdabcdabcd\",word = \"abcdabcd\") == 2\n assert candidate(sequence = \"sequencewordsequenceword\",word = \"word\") == 1\n assert candidate(sequence = \"abababa\",word = \"aba\") == 1\n assert candidate(sequence = \"xyxyxyxyxyxyxyxy\",word = \"xyxy\") == 4\n assert candidate(sequence = \"abcdefgabcdefgabcdefg\",word = \"abcdefg\") == 3\n assert candidate(sequence = \"abababababababababababab\",word = \"abababab\") == 3\n assert candidate(sequence = \"aaaabaaaabaaaabaaaab\",word = \"aaab\") == 1\n assert candidate(sequence = \"ababababababababab\",word = \"abab\") == 4\n assert candidate(sequence = \"abcdefghijabcdefghij\",word = \"cde\") == 1\n assert candidate(sequence = \"mamamamamamama\",word = \"mama\") == 3\n assert candidate(sequence = \"ababababababab\",word = \"abab\") == 3\n assert candidate(sequence = \"hellohellohello\",word = \"hello\") == 3\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcabcabcabc\") == 1\n assert candidate(sequence = \"xyzxyzxyzxyz\",word = \"xyz\") == 4\n assert candidate(sequence = \"abcabcabcabcabcabc\",word = \"bcabc\") == 1\n assert candidate(sequence = \"abababababababab\",word = \"abab\") == 4\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcdabcdabcd\",word = \"dabc\") == 7\n assert candidate(sequence = \"mississippiissippi\",word = \"issi\") == 1\n assert candidate(sequence = \"xyzxyzxyz\",word = \"xy\") == 1\n assert candidate(sequence = \"abcabcabcabcabcabcabc\",word = \"abcabcabcabcabc\") == 1\n assert candidate(sequence = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word = \"zzzz\") == 7\n assert candidate(sequence = \"abcabcabcabcabcabc\",word = \"abcabc\") == 3\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcdabcdabcd\",word = \"dcba\") == 0\n assert candidate(sequence = \"qwertyqwertyqwerty\",word = \"qwerty\") == 3\n assert candidate(sequence = \"acacacacacac\",word = \"acac\") == 3\n assert candidate(sequence = \"ababababa\",word = \"bab\") == 1\n assert candidate(sequence = \"ababcabcababc\",word = \"abcab\") == 1\n assert candidate(sequence = \"aaaaaaaaaa\",word = \"aaa\") == 3\n assert candidate(sequence = \"aaaaaaaaaa\",word = \"aaaa\") == 2\n assert candidate(sequence = \"mississippi\",word = \"sip\") == 1\n assert candidate(sequence = \"aaaaaaa\",word = \"aa\") == 3\n assert candidate(sequence = \"aaaaaabaaaaa\",word = \"aaaaa\") == 1\n assert candidate(sequence = \"xyzxyzxyzxyz\",word = \"xyzxyz\") == 2\n assert candidate(sequence = \"ababababc\",word = \"aba\") == 1\n assert candidate(sequence = \"abcabcabcabcabcabc\",word = \"cab\") == 5\n assert candidate(sequence = \"abacabacabacabac\",word = \"abacabac\") == 2\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcabcabc\") == 1\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcabc\") == 2\n assert candidate(sequence = \"xyzxyzyzyzxzyzyzxzyzyz\",word = \"zyz\") == 1\n assert candidate(sequence = \"xyzxyzxyzxyz\",word = \"zyxzyx\") == 0\n assert candidate(sequence = \"xyzxyzxyzxyz\",word = \"xyzxyzxyz\") == 1\n assert candidate(sequence = \"aaaaaa\",word = \"aa\") == 3\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcdabcdabcd\",word = \"abcdabcdabcdabcd\") == 2\n assert candidate(sequence = \"abcdabcdabcdabcd\",word = \"cdab\") == 3\n assert candidate(sequence = \"zzzzzzzz\",word = \"zzzz\") == 2\n assert candidate(sequence = \"abcdefgabcdefgabcdefg\",word = \"efg\") == 1\n assert candidate(sequence = \"zzzzzzzzzzzzzzzzzzzz\",word = \"zzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(sequence = \"abcdefgabcdefg\",word = \"abcdefg\") == 2\n assert candidate(sequence = \"bananaananabananananabanananananana\",word = \"anana\") == 2\n assert candidate(sequence = \"qwertyqwertyqwerty\",word = \"erty\") == 1\n assert candidate(sequence = \"pqrspqrspqrspqrspqr\",word = \"pqrs\") == 4\n assert candidate(sequence = \"ababababababa\",word = \"bab\") == 1\n assert candidate(sequence = \"abcbabcabcbabcabc\",word = \"abcabc\") == 1\n assert candidate(sequence = \"qwertyqwertyqwerty\",word = \"qwertyqwerty\") == 1\n assert candidate(sequence = \"zzzzzzzzzzzz\",word = \"zzz\") == 4\n assert candidate(sequence = \"zzzzzzzzzzzzzzz\",word = \"zzzz\") == 3\n assert candidate(sequence = \"xyzxyzxyz\",word = \"xyz\") == 3\n assert candidate(sequence = \"aabbccddeeff\",word = \"eeff\") == 1\n assert candidate(sequence = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word = \"mmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(sequence = \"ababababab\",word = \"abab\") == 2\n assert candidate(sequence = \"xyxyxyxyxyxyxyxy\",word = \"xyxyxyxyxyxyxyxy\") == 1\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcd\",word = \"abcdabcd\") == 3\n assert candidate(sequence = \"qwertyqwertyqwertyqwerty\",word = \"qwertyqwerty\") == 2\n"}, "metadata": {"canonical_parameter_names": ["sequence", "word"], "leetcode_dataset_entry_point": "Solution().maxRepeating", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxRepeating(self, sequence: str, word: str) -> int:", "container": "Solution", "callable": "maxRepeating", "parameters": [{"name": "sequence", "type": "str"}, {"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1669, "task_id": "merge-in-between-linked-lists", "difficulty": "Medium", "problem_description": "You are given two linked lists: list1 and list2 of sizes n and m respectively.\nRemove list1's nodes from the ath node to the bth node, and put list2 in their place.\nThe blue edges and nodes in the following figure indicate the result:\n\nBuild the result list and return its head.\n \nExample 1:\n\n\nInput: list1 = [10,1,13,6,9,5], a = 3, b = 4, list2 = [1000000,1000001,1000002]\nOutput: [10,1,13,1000000,1000001,1000002,5]\nExplanation: We remove the nodes 3 and 4 and put the entire list2 in their place. The blue edges and nodes in the above figure indicate the result.\n\nExample 2:\n\n\nInput: list1 = [0,1,2,3,4,5,6], a = 2, b = 5, list2 = [1000000,1000001,1000002,1000003,1000004]\nOutput: [0,1,1000000,1000001,1000002,1000003,1000004,6]\nExplanation: The blue edges and nodes in the above figure indicate the result.\n\n \nConstraints:\n\n3 <= list1.length <= 104\n1 <= a <= b < list1.length - 1\n1 <= list2.length <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5]),a = 1,b = 2,list2 = list_node([10, 20])), list_node([1, 10, 20, 4, 5]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13]),a = 2,b = 4,list2 = list_node([20, 30])), list_node([1, 3, 20, 30, 11, 13]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800]),a = 3,b = 5,list2 = list_node([10, 20, 30, 40])), list_node([100, 200, 300, 10, 20, 30, 40, 700, 800]))\n assert is_same_list(candidate(list1 = list_node([6, 7, 8, 9, 10, 11, 12]),a = 2,b = 4,list2 = list_node([13, 14, 15, 16])), list_node([6, 7, 13, 14, 15, 16, 11, 12]))\n assert is_same_list(candidate(list1 = list_node([0, 1, 2, 3, 4, 5, 6]),a = 2,b = 5,list2 = list_node([1000000, 1000001, 1000002, 1000003, 1000004])), list_node([0, 1, 1000000, 1000001, 1000002, 1000003, 1000004, 6]))\n assert is_same_list(candidate(list1 = list_node([5, 7, 9, 11, 13, 15, 17]),a = 3,b = 4,list2 = list_node([8, 10, 12])), list_node([5, 7, 9, 8, 10, 12, 15, 17]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5]),a = 1,b = 2,list2 = list_node([10, 20, 30])), list_node([1, 10, 20, 30, 4, 5]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11]),a = 2,b = 3,list2 = list_node([2, 4, 6, 8])), list_node([1, 3, 2, 4, 6, 8, 9, 11]))\n assert is_same_list(candidate(list1 = list_node([10, 1, 13, 6, 9, 5]),a = 3,b = 4,list2 = list_node([1000000, 1000001, 1000002])), list_node([10, 1, 13, 1000000, 1000001, 1000002, 5]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5]),a = 1,b = 2,list2 = list_node([9, 8])), list_node([1, 9, 8, 4, 5]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9]),a = 2,b = 6,list2 = list_node([100, 200, 300])), list_node([1, 2, 100, 200, 300, 8, 9]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70]),a = 2,b = 4,list2 = list_node([100, 200, 300])), list_node([10, 20, 100, 200, 300, 60, 70]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),a = 4,b = 10,list2 = list_node([999, 888, 777])), list_node([1, 2, 3, 4, 999, 888, 777, 12, 13, 14, 15]))\n assert is_same_list(candidate(list1 = list_node([1000, 2000, 3000, 4000, 5000, 6000, 7000]),a = 1,b = 5,list2 = list_node([100, 200, 300, 400, 500, 600, 700])), list_node([1000, 100, 200, 300, 400, 500, 600, 700, 7000]))\n assert is_same_list(candidate(list1 = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1]),a = 2,b = 6,list2 = list_node([20, 21, 22, 23, 24, 25])), list_node([9, 8, 20, 21, 22, 23, 24, 25, 2, 1]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]),a = 15,b = 28,list2 = list_node([3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900])), list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 3000]))\n assert is_same_list(candidate(list1 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]),a = 3,b = 12,list2 = list_node([999, 888, 777, 666, 555, 444])), list_node([2, 4, 6, 999, 888, 777, 666, 555, 444, 28, 30]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]),a = 6,b = 14,list2 = list_node([1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000])), list_node([5, 10, 15, 20, 25, 30, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 80, 85, 90, 95, 100]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]),a = 2,b = 11,list2 = list_node([160, 170, 180, 190, 200, 210, 220, 230])), list_node([10, 20, 160, 170, 180, 190, 200, 210, 220, 230, 130, 140, 150]))\n assert is_same_list(candidate(list1 = list_node([15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115]),a = 3,b = 9,list2 = list_node([200, 300, 400, 500, 600, 700])), list_node([15, 25, 35, 200, 300, 400, 500, 600, 700, 115]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),a = 2,b = 7,list2 = list_node([100, 200, 300, 400, 500])), list_node([1, 2, 100, 200, 300, 400, 500, 9, 10]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19]),a = 2,b = 7,list2 = list_node([200, 201, 202, 203, 204])), list_node([1, 3, 200, 201, 202, 203, 204, 17, 19]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),a = 8,b = 16,list2 = list_node([9999, 9998, 9997, 9996, 9995, 9994])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9999, 9998, 9997, 9996, 9995, 9994, 18, 19, 20]))\n assert is_same_list(candidate(list1 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]),a = 5,b = 12,list2 = list_node([31, 33, 35, 37, 39, 41, 43, 45])), list_node([2, 4, 6, 8, 10, 31, 33, 35, 37, 39, 41, 43, 45, 28, 30]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]),a = 7,b = 15,list2 = list_node([105, 110, 115, 120, 125, 130, 135, 140])), list_node([5, 10, 15, 20, 25, 30, 35, 105, 110, 115, 120, 125, 130, 135, 140, 85, 90, 95, 100]))\n assert is_same_list(candidate(list1 = list_node([250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000, 3250, 3500, 3750, 4000, 4250, 4500, 4750, 5000]),a = 7,b = 13,list2 = list_node([5100, 5200, 5300, 5400, 5500, 5600, 5700, 5800, 5900])), list_node([250, 500, 750, 1000, 1250, 1500, 1750, 5100, 5200, 5300, 5400, 5500, 5600, 5700, 5800, 5900, 3750, 4000, 4250, 4500, 4750, 5000]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]),a = 2,b = 8,list2 = list_node([50, 60, 70, 80, 90, 100, 110, 120, 130])), list_node([100, 200, 50, 60, 70, 80, 90, 100, 110, 120, 130, 1000]))\n assert is_same_list(candidate(list1 = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),a = 5,b = 12,list2 = list_node([20, 21, 22, 23, 24, 25])), list_node([0, 1, 2, 3, 4, 20, 21, 22, 23, 24, 25, 13, 14, 15, 16, 17, 18, 19]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90]),a = 1,b = 6,list2 = list_node([100, 200, 300, 400, 500])), list_node([10, 100, 200, 300, 400, 500, 80, 90]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]),a = 7,b = 11,list2 = list_node([750, 850, 950, 1050, 1150, 1250])), list_node([100, 200, 300, 400, 500, 600, 700, 750, 850, 950, 1050, 1150, 1250, 1300, 1400, 1500]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),a = 6,b = 14,list2 = list_node([100, 200, 300, 400, 500, 600, 700, 800])), list_node([1, 2, 3, 4, 5, 6, 100, 200, 300, 400, 500, 600, 700, 800, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),a = 3,b = 7,list2 = list_node([11, 12, 13, 14, 15])), list_node([1, 2, 3, 11, 12, 13, 14, 15, 9, 10]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]),a = 2,b = 18,list2 = list_node([500, 600, 700, 800, 900])), list_node([10, 20, 500, 600, 700, 800, 900, 200]))\n assert is_same_list(candidate(list1 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60]),a = 10,b = 25,list2 = list_node([62, 64, 66, 68, 70, 72, 74, 76, 78, 80])), list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 54, 56, 58, 60]))\n assert is_same_list(candidate(list1 = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),a = 3,b = 9,list2 = list_node([13, 14, 15, 16, 17, 18, 19, 20])), list_node([0, 1, 2, 13, 14, 15, 16, 17, 18, 19, 20, 10, 11, 12]))\n assert is_same_list(candidate(list1 = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]),a = 8,b = 20,list2 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000])), list_node([0, 1, 2, 3, 4, 5, 6, 7, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 21, 22, 23, 24, 25, 26, 27, 28, 29]))\n assert is_same_list(candidate(list1 = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),a = 15,b = 30,list2 = list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(list1 = list_node([3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]),a = 8,b = 15,list2 = list_node([99, 199, 299, 399, 499, 599, 699, 799, 899, 999])), list_node([3, 6, 9, 12, 15, 18, 21, 24, 99, 199, 299, 399, 499, 599, 699, 799, 899, 999, 51, 54, 57, 60]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45]),a = 6,b = 18,list2 = list_node([101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125])), list_node([1, 3, 5, 7, 9, 11, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 39, 41, 43, 45]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]),a = 5,b = 15,list2 = list_node([550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550, 1650])), list_node([100, 200, 300, 400, 500, 550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550, 1650, 1700, 1800, 1900, 2000]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]),a = 5,b = 12,list2 = list_node([10000, 20000, 30000])), list_node([100, 200, 300, 400, 500, 10000, 20000, 30000, 1400, 1500]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]),a = 6,b = 12,list2 = list_node([100, 200, 300, 400, 500])), list_node([1, 3, 5, 7, 9, 11, 100, 200, 300, 400, 500, 27, 29, 31]))\n assert is_same_list(candidate(list1 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]),a = 4,b = 19,list2 = list_node([20000, 20001, 20002, 20003, 20004, 20005, 20006, 20007, 20008, 20009, 20010, 20011, 20012, 20013, 20014])), list_node([2, 4, 6, 8, 20000, 20001, 20002, 20003, 20004, 20005, 20006, 20007, 20008, 20009, 20010, 20011, 20012, 20013, 20014]))\n assert is_same_list(candidate(list1 = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),a = 2,b = 18,list2 = list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])), list_node([1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),a = 3,b = 8,list2 = list_node([13, 14, 15, 16, 17, 18, 19])), list_node([1, 2, 3, 13, 14, 15, 16, 17, 18, 19, 10, 11, 12]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]),a = 1,b = 9,list2 = list_node([500, 600, 700])), list_node([10, 500, 600, 700]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]),a = 1,b = 8,list2 = list_node([1000, 2000, 3000])), list_node([10, 1000, 2000, 3000, 100]))\n assert is_same_list(candidate(list1 = list_node([0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]),a = 4,b = 8,list2 = list_node([100, 101, 102, 103, 104, 105, 106, 107])), list_node([0, 2, 4, 6, 100, 101, 102, 103, 104, 105, 106, 107, 18, 20]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]),a = 5,b = 10,list2 = list_node([151, 152, 153, 154, 155, 156])), list_node([10, 20, 30, 40, 50, 151, 152, 153, 154, 155, 156, 120, 130, 140, 150]))\n assert is_same_list(candidate(list1 = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),a = 10,b = 19,list2 = list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(list1 = list_node([11, 22, 33, 44, 55, 66, 77, 88, 99, 111, 222, 333, 444, 555, 666, 777, 888, 999, 1111, 2222, 3333, 4444, 5555]),a = 3,b = 18,list2 = list_node([6666, 7777, 8888, 9999, 10000, 11000])), list_node([11, 22, 33, 6666, 7777, 8888, 9999, 10000, 11000, 2222, 3333, 4444, 5555]))\n assert is_same_list(candidate(list1 = list_node([0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]),a = 3,b = 7,list2 = list_node([3, 5, 7, 9, 11])), list_node([0, 2, 4, 3, 5, 7, 9, 11, 16, 18, 20]))\n assert is_same_list(candidate(list1 = list_node([101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515]),a = 6,b = 12,list2 = list_node([9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111])), list_node([101, 202, 303, 404, 505, 606, 9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1414, 1515]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]),a = 5,b = 14,list2 = list_node([500, 600, 700, 800, 900, 1000, 1100, 1200, 1300])), list_node([10, 20, 30, 40, 50, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 160, 170, 180, 190, 200]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]),a = 4,b = 8,list2 = list_node([22, 24, 26, 28, 30, 32, 34])), list_node([1, 3, 5, 7, 22, 24, 26, 28, 30, 32, 34, 19, 21]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]),a = 5,b = 12,list2 = list_node([1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007])), list_node([1, 3, 5, 7, 9, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 27, 29]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]),a = 15,b = 24,list2 = list_node([31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 26, 27, 28, 29, 30]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]),a = 8,b = 20,list2 = list_node([31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 22, 23, 24, 25, 26, 27, 28, 29, 30]))\n assert is_same_list(candidate(list1 = list_node([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),a = 2,b = 13,list2 = list_node([21, 22, 23, 24, 25, 26, 27])), list_node([5, 6, 21, 22, 23, 24, 25, 26, 27, 19, 20]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),a = 7,b = 13,list2 = list_node([10000, 20000, 30000, 40000, 50000, 60000, 70000])), list_node([1, 2, 3, 4, 5, 6, 7, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),a = 2,b = 7,list2 = list_node([11, 12, 13, 14, 15, 16])), list_node([1, 2, 11, 12, 13, 14, 15, 16, 9, 10]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]),a = 3,b = 17,list2 = list_node([10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009])), list_node([1, 3, 5, 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 37, 39]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]),a = 3,b = 17,list2 = list_node([2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015])), list_node([10, 20, 30, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 190, 200]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]),a = 8,b = 20,list2 = list_node([51, 53, 55, 57, 59, 61, 63, 65])), list_node([1, 3, 5, 7, 9, 11, 13, 15, 51, 53, 55, 57, 59, 61, 63, 65, 43, 45, 47, 49]))\n assert is_same_list(candidate(list1 = list_node([11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132]),a = 5,b = 10,list2 = list_node([2000, 3000, 4000, 5000, 6000, 7000, 8000])), list_node([11, 22, 33, 44, 55, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 132]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65]),a = 5,b = 9,list2 = list_node([1000, 2000, 3000, 4000])), list_node([5, 10, 15, 20, 25, 1000, 2000, 3000, 4000, 55, 60, 65]))\n assert is_same_list(candidate(list1 = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),a = 4,b = 15,list2 = list_node([2, 2, 2, 2, 2, 2, 2, 2, 2])), list_node([1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]),a = 5,b = 9,list2 = list_node([1400, 1500, 1600])), list_node([100, 200, 300, 400, 500, 1400, 1500, 1600, 1100, 1200, 1300]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]),a = 4,b = 8,list2 = list_node([100, 200, 300, 400, 500, 600, 700])), list_node([5, 10, 15, 20, 100, 200, 300, 400, 500, 600, 700, 50, 55]))\n assert is_same_list(candidate(list1 = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),a = 2,b = 7,list2 = list_node([100, 200, 300, 400, 500, 600])), list_node([0, 1, 100, 200, 300, 400, 500, 600, 8, 9, 10]))\n assert is_same_list(candidate(list1 = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),a = 5,b = 10,list2 = list_node([100, 200, 300, 400, 500, 600])), list_node([0, 1, 2, 3, 4, 100, 200, 300, 400, 500, 600, 11, 12, 13, 14, 15, 16, 17, 18, 19]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]),a = 6,b = 13,list2 = list_node([65, 75, 85, 95, 105, 115, 125, 135, 145, 155])), list_node([10, 20, 30, 40, 50, 60, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 150, 160, 170, 180, 190, 200]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50]),a = 1,b = 6,list2 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 40, 45, 50]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]),a = 5,b = 8,list2 = list_node([55, 65, 75, 85, 95])), list_node([10, 20, 30, 40, 50, 55, 65, 75, 85, 95, 100, 110, 120]))\n assert is_same_list(candidate(list1 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]),a = 7,b = 18,list2 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21])), list_node([2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 40, 42, 44, 46, 48, 50]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]),a = 10,b = 20,list2 = list_node([500, 501, 502, 503, 504, 505, 506, 507, 508, 509])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 22, 23, 24, 25, 26, 27, 28, 29, 30]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]),a = 4,b = 8,list2 = list_node([111, 121, 131, 141])), list_node([10, 20, 30, 40, 111, 121, 131, 141, 100, 110]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]),a = 4,b = 9,list2 = list_node([100, 200, 300, 400, 500, 600])), list_node([1, 3, 5, 7, 100, 200, 300, 400, 500, 600, 21, 23, 25]))\n assert is_same_list(candidate(list1 = list_node([99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]),a = 5,b = 15,list2 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([99, 98, 97, 96, 95, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 83, 82, 81, 80]))\n assert is_same_list(candidate(list1 = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1]),a = 2,b = 6,list2 = list_node([0, 0, 0, 0, 0, 0])), list_node([9, 8, 0, 0, 0, 0, 0, 0, 2, 1]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]),a = 3,b = 7,list2 = list_node([1010, 1020, 1030, 1040, 1050])), list_node([100, 200, 300, 1010, 1020, 1030, 1040, 1050, 900, 1000]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]),a = 3,b = 6,list2 = list_node([1000, 2000, 3000, 4000, 5000])), list_node([10, 20, 30, 1000, 2000, 3000, 4000, 5000, 80, 90, 100]))\n assert is_same_list(candidate(list1 = list_node([101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]),a = 5,b = 15,list2 = list_node([121, 122, 123, 124, 125, 126, 127, 128, 129, 130])), list_node([101, 102, 103, 104, 105, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 117, 118, 119, 120]))\n assert is_same_list(candidate(list1 = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),a = 5,b = 12,list2 = list_node([1000, 1001, 1002, 1003, 1004])), list_node([0, 1, 2, 3, 4, 1000, 1001, 1002, 1003, 1004, 13, 14, 15, 16, 17, 18, 19]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),a = 3,b = 11,list2 = list_node([20, 21, 22, 23, 24, 25, 26])), list_node([1, 2, 3, 20, 21, 22, 23, 24, 25, 26, 13, 14, 15]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]),a = 10,b = 15,list2 = list_node([101, 102, 103, 104, 105, 106, 107, 108, 109, 110])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 17, 18, 19, 20, 21, 22, 23, 24, 25]))\n assert is_same_list(candidate(list1 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]),a = 9,b = 14,list2 = list_node([21, 23, 25, 27, 29, 31, 33])), list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 21, 23, 25, 27, 29, 31, 33, 32, 34, 36, 38, 40]))\n assert is_same_list(candidate(list1 = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]),a = 3,b = 17,list2 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500])), list_node([9, 8, 7, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, -9, -10]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65]),a = 4,b = 9,list2 = list_node([1000, 1001, 1002, 1003, 1004, 1005])), list_node([5, 10, 15, 20, 1000, 1001, 1002, 1003, 1004, 1005, 55, 60, 65]))\n assert is_same_list(candidate(list1 = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),a = 3,b = 10,list2 = list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])), list_node([1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]),a = 4,b = 16,list2 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20])), list_node([1, 3, 5, 7, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 35, 37, 39]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]),a = 7,b = 20,list2 = list_node([1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015])), list_node([1, 3, 5, 7, 9, 11, 13, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 43, 45, 47, 49]))\n assert is_same_list(candidate(list1 = list_node([1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]),a = 4,b = 10,list2 = list_node([16000, 17000, 18000, 19000])), list_node([1000, 2000, 3000, 4000, 16000, 17000, 18000, 19000, 12000, 13000, 14000, 15000]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]),a = 6,b = 15,list2 = list_node([1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009])), list_node([5, 10, 15, 20, 25, 30, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 85, 90, 95, 100]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900]),a = 2,b = 7,list2 = list_node([1000, 1001, 1002, 1003, 1004])), list_node([100, 200, 1000, 1001, 1002, 1003, 1004, 900]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]),a = 2,b = 9,list2 = list_node([65, 70, 75, 80, 85, 90, 95, 100])), list_node([5, 10, 65, 70, 75, 80, 85, 90, 95, 100, 55, 60]))\n assert is_same_list(candidate(list1 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26]),a = 4,b = 10,list2 = list_node([50, 100, 150, 200, 250])), list_node([2, 4, 6, 8, 50, 100, 150, 200, 250, 24, 26]))\n"}, "metadata": {"canonical_parameter_names": ["list1", "a", "b", "list2"], "leetcode_dataset_entry_point": "Solution().mergeInBetween", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode:", "container": "Solution", "callable": "mergeInBetween", "parameters": [{"name": "list1", "type": "ListNode"}, {"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "list2", "type": "ListNode"}], "return_type": "ListNode", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1671, "task_id": "minimum-number-of-removals-to-make-mountain-array", "difficulty": "Hard", "problem_description": "You may recall that an array arr is a mountain array if and only if:\n\narr.length >= 3\nThere exists some index i (0-indexed) with 0 < i < arr.length - 1 such that:\n\t\narr[0] < arr[1] < ... < arr[i - 1] < arr[i]\narr[i] > arr[i + 1] > ... > arr[arr.length - 1]\n\n\n\nGiven an integer array nums​​​, return the minimum number of elements to remove to make nums​​​ a mountain array.\n \nExample 1:\n\nInput: nums = [1,3,1]\nOutput: 0\nExplanation: The array itself is a mountain array so we do not need to remove any elements.\n\nExample 2:\n\nInput: nums = [2,1,1,5,6,2,3,1]\nOutput: 3\nExplanation: One solution is to remove the elements at indices 0, 1, and 5, making the array nums = [1,5,6,3,1].\n\n \nConstraints:\n\n3 <= nums.length <= 1000\n1 <= nums[i] <= 109\nIt is guaranteed that you can make a mountain array out of nums.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 1]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [100, 92, 89, 77, 74, 66, 64, 66, 64]) == 6\n assert candidate(nums = [1, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [4, 3, 2, 1, 1, 2, 3, 1]) == 4\n assert candidate(nums = [2, 1, 1, 5, 6, 2, 3, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 1, 5, 7, 6, 3, 2]) == 1\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [9, 8, 1, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 3, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 2, 1, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 10, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12]) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 3, 5, 7, 9, 11]) == 5\n assert candidate(nums = [20, 40, 30, 50, 60, 70, 35, 10, 5, 45, 65, 75, 25, 55, 85, 95, 15, 25, 35, 45]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 8, 6, 4, 2]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 3, 2, 1, 0]) == 1\n assert candidate(nums = [10, 20, 15, 20, 25, 30, 25, 20, 15, 10, 5, 10, 15, 20]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 54\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 40\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 14\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 2, 1, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 27\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1]) == 8\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 15, 25, 35, 45, 55, 65, 75, 85, 95, 100, 5, 10, 15]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 24\n assert candidate(nums = [4, 3, 2, 1, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 0\n assert candidate(nums = [2, 3, 1, 4, 3, 2, 5, 4, 3, 2, 1, 6, 7, 8, 7, 6, 5, 4, 3]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3]) == 3\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -1, 0, 1, 2, 3, 4, 5]) == 46\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 29\n assert candidate(nums = [1, 5, 3, 7, 5, 9, 7, 11, 9, 13, 11, 15, 13, 17, 15, 19, 17]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 14\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 20\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 11\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15]) == 13\n assert candidate(nums = [1, 5, 3, 4, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 13\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 0\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91, 11, 90, 12, 89, 13, 88]) == 12\n assert candidate(nums = [1, 5, 3, 4, 6, 7, 8, 9, 10, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [3, 5, 4, 5, 4, 3, 5, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 5]) == 12\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 125, 120, 115, 110, 105, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15]) == 7\n assert candidate(nums = [1, 1000000000, 999999999, 1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumMountainRemovals", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumMountainRemovals(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minimumMountainRemovals", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1672, "task_id": "richest-customer-wealth", "difficulty": "Easy", "problem_description": "You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the i​​​​​​​​​​​th​​​​ customer has in the j​​​​​​​​​​​th​​​​ bank. Return the wealth that the richest customer has.\nA customer's wealth is the amount of money they have in all their bank accounts. The richest customer is the customer that has the maximum wealth.\n \nExample 1:\n\nInput: accounts = [[1,2,3],[3,2,1]]\nOutput: 6\nExplanation:\n1st customer has wealth = 1 + 2 + 3 = 6\n2nd customer has wealth = 3 + 2 + 1 = 6\nBoth customers are considered the richest with a wealth of 6 each, so return 6.\n\nExample 2:\n\nInput: accounts = [[1,5],[7,3],[3,5]]\nOutput: 10\nExplanation: \n1st customer has wealth = 6\n2nd customer has wealth = 10 \n3rd customer has wealth = 8\nThe 2nd customer is the richest with a wealth of 10.\nExample 3:\n\nInput: accounts = [[2,8,7],[7,1,3],[1,9,5]]\nOutput: 17\n\n \nConstraints:\n\nm == accounts.length\nn == accounts[i].length\n1 <= m, n <= 50\n1 <= accounts[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(accounts = [[10, 20, 30], [1, 2, 3], [100, 200, 300]]) == 600\n assert candidate(accounts = [[10, 10], [20, 20], [30, 30], [40, 40]]) == 80\n assert candidate(accounts = [[100, 100], [50, 50, 50, 50]]) == 200\n assert candidate(accounts = [[100], [100], [100]]) == 100\n assert candidate(accounts = [[5, 5, 5], [15], [10, 10]]) == 20\n assert candidate(accounts = [[10, 20, 30], [5, 15, 25], [1, 2, 3]]) == 60\n assert candidate(accounts = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 3\n assert candidate(accounts = [[50, 50], [25, 75], [75, 25], [100]]) == 100\n assert candidate(accounts = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == 25\n assert candidate(accounts = [[50, 50], [50, 50], [50, 50]]) == 100\n assert candidate(accounts = [[10, 20, 30], [5, 15, 25], [1, 2, 3, 4, 5]]) == 60\n assert candidate(accounts = [[1, 2], [3, 4], [5, 6], [7, 8]]) == 15\n assert candidate(accounts = [[1, 5], [7, 3], [3, 5]]) == 10\n assert candidate(accounts = [[10, 10, 10], [5, 5, 5], [1, 1, 1]]) == 30\n assert candidate(accounts = [[1], [2], [3]]) == 3\n assert candidate(accounts = [[2, 8, 7], [7, 1, 3], [1, 9, 5]]) == 17\n assert candidate(accounts = [[100, 100], [50, 50, 50], [25, 25, 25, 25]]) == 200\n assert candidate(accounts = [[1, 2, 3], [3, 2, 1]]) == 6\n assert candidate(accounts = [[1], [2], [3], [4], [5]]) == 5\n assert candidate(accounts = [[45, 45, 10], [30, 30, 30], [20, 20, 20, 20], [10, 10, 10, 10, 10]]) == 100\n assert candidate(accounts = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == 190\n assert candidate(accounts = [[1, 100, 1], [10, 50, 10], [100, 1, 100], [50, 10, 50]]) == 201\n assert candidate(accounts = [[100, 100, 100, 100, 100], [50, 50, 50, 50], [25, 25, 25, 25, 25], [125, 125]]) == 500\n assert candidate(accounts = [[1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 7\n assert candidate(accounts = [[99, 1, 2, 3], [4, 5, 6, 99], [7, 8, 9, 10]]) == 114\n assert candidate(accounts = [[5, 5, 5, 5, 5], [1, 1, 1, 1, 100], [10, 10, 10, 10, 10], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 104\n assert candidate(accounts = [[10, 20, 30, 40, 50], [90, 80, 70, 60, 50], [1, 2, 3, 4, 5]]) == 350\n assert candidate(accounts = [[50, 1, 50], [1, 50, 50], [50, 50, 1], [50, 1, 50], [1, 50, 50], [50, 50, 1]]) == 101\n assert candidate(accounts = [[10, 10, 10, 10, 10], [9, 9, 9, 9, 9, 9], [8, 8, 8, 8, 8, 8, 8], [7, 7, 7, 7, 7, 7, 7, 7]]) == 56\n assert candidate(accounts = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 150\n assert candidate(accounts = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 2, 3, 4, 5]]) == 150\n assert candidate(accounts = [[99, 1, 1, 1, 1], [1, 99, 1, 1, 1], [1, 1, 99, 1, 1], [1, 1, 1, 99, 1], [1, 1, 1, 1, 99]]) == 103\n assert candidate(accounts = [[90, 5], [5, 90], [45, 55], [55, 45], [75, 25], [25, 75], [60, 40], [40, 60]]) == 100\n assert candidate(accounts = [[50, 50, 50], [25, 25, 25, 25], [100], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 150\n assert candidate(accounts = [[100], [100, 100], [100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 100, 100], [100, 100, 100, 100, 100, 100], [100, 100, 100, 100, 100, 100, 100]]) == 700\n assert candidate(accounts = [[10, 20, 30], [50, 10, 20], [30, 30, 30], [25, 25, 25, 25]]) == 100\n assert candidate(accounts = [[1, 100], [100, 1], [50, 50], [25, 25, 25, 25]]) == 101\n assert candidate(accounts = [[50, 100, 150, 200, 250], [1, 2, 3, 4, 5], [99, 98, 97, 96, 95], [500, 400, 300, 200, 100]]) == 1500\n assert candidate(accounts = [[100, 100, 100, 100, 100], [99, 99, 99, 99, 99], [98, 98, 98, 98, 98], [97, 97, 97, 97, 97], [96, 96, 96, 96, 96]]) == 500\n assert candidate(accounts = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == 30\n assert candidate(accounts = [[90, 10, 10], [10, 90, 10], [10, 10, 90], [30, 30, 30], [20, 20, 20, 20, 10]]) == 110\n assert candidate(accounts = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4], [5, 5, 5, 5, 5]]) == 25\n assert candidate(accounts = [[99, 1], [1, 99], [50, 50], [25, 25, 25, 25]]) == 100\n assert candidate(accounts = [[10, 20, 30], [50, 60, 70], [80, 90, 100], [10, 10, 10]]) == 270\n assert candidate(accounts = [[50, 50, 50, 50], [100, 200, 300, 400], [5, 10, 15, 20, 25]]) == 1000\n assert candidate(accounts = [[45, 45, 45, 45, 45, 45], [90, 90, 90], [22, 22, 22, 22, 22, 22, 22, 22, 22, 22]]) == 270\n assert candidate(accounts = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [60, 60, 60], [70, 70, 70], [80, 80, 80], [90, 90, 90], [100, 100, 100]]) == 300\n assert candidate(accounts = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == 190\n assert candidate(accounts = [[42], [42, 42], [42, 42, 42], [42, 42, 42, 42], [42, 42, 42, 42, 42]]) == 210\n assert candidate(accounts = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == 30\n assert candidate(accounts = [[90, 10, 1], [1, 99, 1], [50, 50, 50], [75, 25, 0], [25, 25, 25, 25]]) == 150\n assert candidate(accounts = [[99, 1], [1, 99], [49, 51], [51, 49], [50, 50]]) == 100\n assert candidate(accounts = [[30, 20, 10], [10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 30, 20]]) == 60\n assert candidate(accounts = [[50, 50, 50], [50, 50, 50], [50, 50, 50], [50, 50, 50], [50, 50, 50]]) == 150\n assert candidate(accounts = [[50, 50], [25, 25, 25, 25], [100, 0], [0, 100], [20, 20, 20, 20, 20]]) == 100\n assert candidate(accounts = [[100], [200], [300], [400], [500], [600], [700], [800], [900], [1000]]) == 1000\n assert candidate(accounts = [[99, 1], [98, 2], [97, 3], [96, 4], [95, 5], [94, 6], [93, 7], [92, 8], [91, 9], [90, 10]]) == 100\n assert candidate(accounts = [[99, 1], [100, 100], [50, 50, 1], [25, 25, 25, 25]]) == 200\n assert candidate(accounts = [[50], [50, 50], [50, 50, 50], [50, 50, 50, 50], [50, 50, 50, 50, 50]]) == 250\n assert candidate(accounts = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]]) == 90\n assert candidate(accounts = [[1, 99], [2, 98], [3, 97], [4, 96], [5, 95]]) == 100\n assert candidate(accounts = [[50, 50, 50], [25, 25, 25, 25], [10, 10, 10, 10, 10, 10]]) == 150\n assert candidate(accounts = [[45, 55], [46, 54], [47, 53], [48, 52], [49, 51]]) == 100\n assert candidate(accounts = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [10, 9, 8, 7, 6], [6, 7, 8, 9, 10]]) == 40\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 55\n assert candidate(accounts = [[99, 1, 100], [100, 1, 99], [50, 50, 50]]) == 200\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 55\n assert candidate(accounts = [[100, 100, 100, 100, 100], [90, 90, 90, 90, 90, 90], [80, 80, 80, 80, 80, 80, 80], [70, 70, 70, 70, 70, 70, 70, 70]]) == 560\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 120\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]]) == 500\n assert candidate(accounts = [[1], [1, 1], [1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(accounts = [[100, 0, 0, 0, 0], [0, 100, 0, 0, 0], [0, 0, 100, 0, 0], [0, 0, 0, 100, 0], [0, 0, 0, 0, 100]]) == 100\n assert candidate(accounts = [[100, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 100, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 100, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 100, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 100, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 100, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 100, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 100, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 100, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 100]]) == 109\n assert candidate(accounts = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15]]) == 65\n assert candidate(accounts = [[100, 200, 300, 400], [99, 88, 77, 66], [1, 2, 3, 4]]) == 1000\n assert candidate(accounts = [[100, 100, 100, 100, 100], [99, 99, 99, 99, 99, 99], [50, 50, 50, 50, 50, 50, 50], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 594\n assert candidate(accounts = [[90, 90, 90, 90, 90], [80, 80, 80, 80, 80], [70, 70, 70, 70, 70], [60, 60, 60, 60, 60], [50, 50, 50, 50, 50]]) == 450\n assert candidate(accounts = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]]) == 20\n assert candidate(accounts = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 40\n assert candidate(accounts = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 2, 3, 4, 5], [50, 40, 30, 20, 10]]) == 150\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 100\n assert candidate(accounts = [[10, 10, 10, 10], [20, 20, 20, 20], [30, 30, 30, 30], [40, 40, 40, 40]]) == 160\n assert candidate(accounts = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 100\n assert candidate(accounts = [[50, 50, 50], [25, 25, 25, 25, 25], [100, 0], [0, 100, 0], [33, 33, 33, 1]]) == 150\n assert candidate(accounts = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [20, 20, 20, 20, 20], [30, 30, 30, 30, 30, 30]]) == 180\n"}, "metadata": {"canonical_parameter_names": ["accounts"], "leetcode_dataset_entry_point": "Solution().maximumWealth", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumWealth(self, accounts: list[list[int]]) -> int:", "container": "Solution", "callable": "maximumWealth", "parameters": [{"name": "accounts", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1673, "task_id": "find-the-most-competitive-subsequence", "difficulty": "Medium", "problem_description": "Given an integer array nums and a positive integer k, return the most competitive subsequence of nums of size k.\nAn array's subsequence is a resulting sequence obtained by erasing some (possibly zero) elements from the array.\nWe define that a subsequence a is more competitive than a subsequence b (of the same length) if in the first position where a and b differ, subsequence a has a number less than the corresponding number in b. For example, [1,3,4] is more competitive than [1,3,5] because the first position they differ is at the final number, and 4 is less than 5.\n \nExample 1:\n\nInput: nums = [3,5,2,6], k = 2\nOutput: [2,6]\nExplanation: Among the set of every possible subsequence: {[3,5], [3,2], [3,6], [5,2], [5,6], [2,6]}, [2,6] is the most competitive.\n\nExample 2:\n\nInput: nums = [2,4,3,3,5,4,9,6], k = 4\nOutput: [2,3,3,4]\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 109\n1 <= k <= nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 9, 8, 7, 6, 5, 4, 3, 2],k = 1) == [1]\n assert candidate(nums = [2, 4, 3, 3, 5, 4, 9, 6],k = 4) == [2, 3, 3, 4]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == [5, 4, 3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7],k = 3) == [1, 2, 3]\n assert candidate(nums = [1, 3, 1, 1, 2, 3, 1],k = 4) == [1, 1, 1, 1]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],k = 3) == [3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == [1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == [1, 2, 3]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],k = 2) == [1, 1]\n assert candidate(nums = [3, 5, 2, 6],k = 2) == [2, 6]\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 2) == [1, 2]\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1],k = 2) == [1, 1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10],k = 5) == [2, 1, 8, 9, 10]\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5) == [50, 40, 30, 20, 10]\n assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [100, 200, 150, 250, 300, 100, 200, 300, 100, 200],k = 6) == [100, 100, 200, 300, 100, 200]\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2],k = 5) == [1, 1, 2, 1, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 6) == [1, 1, 2, 3, 4, 5]\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10],k = 10) == [5, 6, 7, 8, 9, 1, 2, 3, 4, 10]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 8, 9],k = 5) == [3, 2, 1, 8, 9]\n assert candidate(nums = [5, 1, 4, 3, 2, 6, 7, 8, 9, 10],k = 5) == [1, 2, 6, 7, 8]\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10],k = 7) == [5, 6, 1, 2, 3, 4, 10]\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1],k = 4) == [1, 1, 1, 1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [10, 20, 30, 40, 50]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 3) == [10, 10, 10]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 4) == [1, 1, 2, 3]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == [2, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == [1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],k = 3) == [1, 1, 1]\n assert candidate(nums = [9, 1, 9, 2, 9, 3, 9, 4, 9, 5],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [10, 5, 6, 3, 2, 1, 8, 7],k = 3) == [1, 8, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],k = 5) == [1, 2, 3, 4, 0]\n assert candidate(nums = [5, 3, 1, 2, 4, 6, 8, 7, 9, 0],k = 5) == [1, 2, 4, 6, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [8, 6, 9, 2, 5, 7, 8, 8],k = 4) == [2, 5, 7, 8]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 3) == [1, 2, 3]\n assert candidate(nums = [1, 3, 1, 1, 2, 3, 4, 1, 5, 6],k = 3) == [1, 1, 1]\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 5) == [3, 3, 3, 3, 3]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == [3, 2, 1]\n assert candidate(nums = [1, 3, 1, 1, 2, 3, 1, 2, 3, 1],k = 4) == [1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1],k = 4) == [1, 1, 1, 1]\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10],k = 5) == [1, 6, 7, 8, 9]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],k = 6) == [1, 1, 2, 3, 5, 9]\n assert candidate(nums = [1, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == [1, 2, 1]\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10],k = 7) == [1, 2, 3, 4, 6, 5, 10]\n assert candidate(nums = [5, 3, 1, 2, 4, 1, 3, 2, 1, 4, 2, 3],k = 6) == [1, 1, 1, 4, 2, 3]\n assert candidate(nums = [5, 1, 4, 3, 5, 9, 2, 1, 4, 7, 8, 1],k = 7) == [1, 2, 1, 4, 7, 8, 1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 8) == [1, 1, 2, 2, 3, 3, 4, 4]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7],k = 8) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [100, 200, 150, 100, 50, 250, 300, 200, 150],k = 5) == [50, 250, 300, 200, 150]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == [0, 0, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == [1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 10) == [0, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 7) == [10, 20, 30, 40, 50, 60, 70]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 5) == [10, 10, 10, 10, 10]\n assert candidate(nums = [1, 5, 4, 3, 2, 6],k = 3) == [1, 2, 6]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 7) == [3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [5, 6, 1, 2, 3, 4, 10, 9, 8, 7],k = 4) == [1, 2, 3, 4]\n assert candidate(nums = [8, 9, 7, 6, 5, 4, 3, 2, 1],k = 4) == [4, 3, 2, 1]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 6) == [1, 1, 1, 1, 2, 3]\n assert candidate(nums = [5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5],k = 6) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == [5, 5, 5, 5, 5]\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 0],k = 5) == [1, 2, 3, 4, 0]\n assert candidate(nums = [7, 1, 5, 3, 6, 4],k = 3) == [1, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [7, 14, 4, 14, 13, 2, 6, 13],k = 5) == [4, 13, 2, 6, 13]\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 4, 3, 2, 1],k = 4) == [1, 1, 2, 1]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 6) == [1, 2, 4, 6, 8, 10]\n assert candidate(nums = [5, 1, 9, 7, 3, 8, 2, 4, 6],k = 4) == [1, 2, 4, 6]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 5) == [1, 1, 2, 2, 3]\n assert candidate(nums = [8, 6, 5, 7, 3, 4, 1, 2, 9, 0],k = 4) == [1, 2, 9, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 4) == [1, 1, 2, 2]\n assert candidate(nums = [4, 3, 5, 1, 2, 3, 6, 7, 8, 9],k = 5) == [1, 2, 3, 6, 7]\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9],k = 5) == [1, 6, 7, 8, 9]\n assert candidate(nums = [4, 3, 2, 1, 2, 3, 4, 3, 2, 1],k = 5) == [1, 2, 3, 2, 1]\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 0],k = 6) == [1, 2, 3, 4, 5, 0]\n assert candidate(nums = [1, 3, 2, 1, 2, 1, 3, 2, 1],k = 3) == [1, 1, 1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5],k = 10) == [4, 3, 2, 1, 0, 9, 8, 7, 6, 5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 15) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9],k = 3) == [1, 1, 1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 6) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == [100, 200, 300, 400, 500]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],k = 3) == [1, 2, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 10) == [0, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 8, 9],k = 5) == [2, 1, 0, 8, 9]\n assert candidate(nums = [1, 3, 2, 4, 1, 2, 3, 1, 2, 3],k = 4) == [1, 1, 1, 2]\n assert candidate(nums = [5, 2, 6, 3, 4, 1],k = 2) == [2, 1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 5) == [7, 7, 7, 7, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],k = 12) == [1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(nums = [5, 3, 1, 4, 2, 6, 8, 7, 9, 0, 11, 10, 12, 13, 14],k = 10) == [1, 2, 6, 7, 0, 11, 10, 12, 13, 14]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().mostCompetitive", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def mostCompetitive(self, nums: list[int], k: int) -> list[int]:", "container": "Solution", "callable": "mostCompetitive", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1674, "task_id": "minimum-moves-to-make-array-complementary", "difficulty": "Medium", "problem_description": "You are given an integer array nums of even length n and an integer limit. In one move, you can replace any integer from nums with another integer between 1 and limit, inclusive.\nThe array nums is complementary if for all indices i (0-indexed), nums[i] + nums[n - 1 - i] equals the same number. For example, the array [1,2,3,4] is complementary because for all indices i, nums[i] + nums[n - 1 - i] = 5.\nReturn the minimum number of moves required to make nums complementary.\n \nExample 1:\n\nInput: nums = [1,2,4,3], limit = 4\nOutput: 1\nExplanation: In 1 move, you can change nums to [1,2,2,3] (underlined elements are changed).\nnums[0] + nums[3] = 1 + 3 = 4.\nnums[1] + nums[2] = 2 + 2 = 4.\nnums[2] + nums[1] = 2 + 2 = 4.\nnums[3] + nums[0] = 3 + 1 = 4.\nTherefore, nums[i] + nums[n-1-i] = 4 for every i, so nums is complementary.\n\nExample 2:\n\nInput: nums = [1,2,2,1], limit = 2\nOutput: 2\nExplanation: In 2 moves, you can change nums to [2,2,2,2]. You cannot change any number to 3 since 3 > limit.\n\nExample 3:\n\nInput: nums = [1,2,1,2], limit = 2\nOutput: 0\nExplanation: nums is already complementary.\n\n \nConstraints:\n\nn == nums.length\n2 <= n <= 105\n1 <= nums[i] <= limit <= 105\nn is even.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 3, 3, 3],limit = 5) == 0\n assert candidate(nums = [1, 1, 1, 1],limit = 10) == 0\n assert candidate(nums = [5, 3, 5, 3],limit = 10) == 0\n assert candidate(nums = [1, 5, 5, 1],limit = 5) == 2\n assert candidate(nums = [1, 2, 2, 1],limit = 2) == 2\n assert candidate(nums = [100000, 1, 100000, 1],limit = 100000) == 0\n assert candidate(nums = [100000, 1, 1, 100000],limit = 100000) == 2\n assert candidate(nums = [100000, 1, 1, 100000, 1, 1, 100000, 1],limit = 100000) == 1\n assert candidate(nums = [3, 5, 5, 3],limit = 5) == 1\n assert candidate(nums = [1, 1, 1, 1],limit = 1) == 0\n assert candidate(nums = [1, 5, 9, 13],limit = 15) == 0\n assert candidate(nums = [1, 3, 5, 7],limit = 10) == 0\n assert candidate(nums = [2, 5, 6, 5, 2, 2],limit = 7) == 2\n assert candidate(nums = [1, 9, 9, 1, 1, 9, 9, 1],limit = 9) == 4\n assert candidate(nums = [10, 1, 10, 1],limit = 10) == 0\n assert candidate(nums = [100000, 100000, 100000, 100000],limit = 100000) == 0\n assert candidate(nums = [10, 15, 15, 10],limit = 20) == 1\n assert candidate(nums = [2, 3, 4, 3, 2, 1],limit = 6) == 2\n assert candidate(nums = [1, 9, 9, 1],limit = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6],limit = 6) == 0\n assert candidate(nums = [10, 1, 1, 10],limit = 10) == 2\n assert candidate(nums = [5, 5, 5, 5],limit = 10) == 0\n assert candidate(nums = [50000, 50000, 50000, 50000],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6],limit = 7) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5],limit = 5) == 0\n assert candidate(nums = [1, 3, 2, 4],limit = 5) == 0\n assert candidate(nums = [1, 2, 4, 3],limit = 4) == 1\n assert candidate(nums = [5, 5, 5, 5],limit = 5) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3],limit = 6) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3],limit = 3) == 0\n assert candidate(nums = [1, 2, 1, 2],limit = 2) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 20) == 0\n assert candidate(nums = [1, 100000, 50000, 50000, 100000, 1],limit = 100000) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 2) == 0\n assert candidate(nums = [30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000],limit = 60000) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],limit = 6) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],limit = 16) == 0\n assert candidate(nums = [25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000],limit = 50000) == 0\n assert candidate(nums = [100000, 1, 2, 99999, 3, 99998, 4, 99997],limit = 100000) == 3\n assert candidate(nums = [1, 100000, 1, 100000, 2, 99999, 2, 99999],limit = 100000) == 2\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1],limit = 100000) == 0\n assert candidate(nums = [1, 100000, 100000, 1],limit = 100000) == 2\n assert candidate(nums = [10000, 90000, 20000, 80000, 30000, 70000],limit = 100000) == 2\n assert candidate(nums = [25000, 25001, 25002, 24999, 25003, 24998, 25004, 24997],limit = 50000) == 3\n assert candidate(nums = [30000, 70000, 40000, 60000, 50000, 50000, 40000, 60000, 30000, 70000],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],limit = 30) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 21) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 100) == 0\n assert candidate(nums = [99999, 1, 99999, 1, 99999, 1],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],limit = 12) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],limit = 10) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80],limit = 80) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 100000) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 50, 40, 30, 20, 10, 1],limit = 100) == 5\n assert candidate(nums = [1, 99999, 99999, 1, 1, 99999, 99999, 1, 1, 99999, 99999, 1],limit = 100000) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4],limit = 4) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 10) == 0\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 30) == 0\n assert candidate(nums = [5, 3, 5, 3, 2, 8, 8, 2],limit = 10) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1) == 0\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3],limit = 6) == 0\n assert candidate(nums = [1, 2, 3, 3, 2, 1, 4, 4, 3, 3, 2, 2, 1, 1],limit = 5) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 2) == 0\n assert candidate(nums = [25, 75, 25, 75, 25, 75, 25, 75, 25, 75, 25, 75, 25, 75, 25, 75],limit = 100) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],limit = 100) == 0\n assert candidate(nums = [50000, 1, 50000, 1, 50000, 1, 50000, 1],limit = 100000) == 0\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],limit = 84) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 5) == 0\n assert candidate(nums = [1, 100000, 1, 100000],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],limit = 15) == 0\n assert candidate(nums = [10000, 20000, 30000, 40000, 40000, 30000, 20000, 10000],limit = 50000) == 3\n assert candidate(nums = [99999, 1, 1, 99999],limit = 100000) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6],limit = 10) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],limit = 13) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100],limit = 500) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],limit = 20) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 11) == 9\n assert candidate(nums = [90000, 10000, 80000, 20000, 70000, 30000, 60000, 40000],limit = 100000) == 3\n assert candidate(nums = [1, 5, 9, 13, 17, 21],limit = 22) == 0\n assert candidate(nums = [50000, 40000, 30000, 20000, 10000, 10000, 20000, 30000, 40000, 50000],limit = 100000) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 110) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],limit = 5) == 0\n assert candidate(nums = [1, 99999, 99998, 2, 99997, 3, 99996, 4],limit = 100000) == 3\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],limit = 12) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 20) == 0\n assert candidate(nums = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5],limit = 100000) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 0\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],limit = 50000) == 0\n assert candidate(nums = [99999, 99998, 1, 2, 3, 4, 5, 6],limit = 100000) == 3\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],limit = 5) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 0\n assert candidate(nums = [50, 51, 52, 49, 53, 48, 54, 47],limit = 100) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],limit = 16) == 0\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996],limit = 100000) == 3\n assert candidate(nums = [100000, 1, 2, 99998, 3, 99997, 4, 99996],limit = 100000) == 3\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 2, 3, 2, 3, 2, 3, 2],limit = 5) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],limit = 25) == 0\n assert candidate(nums = [10000, 90000, 10000, 90000, 10000, 90000, 10000, 90000],limit = 100000) == 0\n assert candidate(nums = [10, 20, 30, 40, 40, 30, 20, 10],limit = 50) == 3\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40],limit = 50) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],limit = 110) == 9\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],limit = 21) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],limit = 15) == 0\n assert candidate(nums = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],limit = 100000) == 0\n assert candidate(nums = [3, 7, 11, 11, 7, 3],limit = 14) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],limit = 15) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800],limit = 900) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 20) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "limit"], "leetcode_dataset_entry_point": "Solution().minMoves", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minMoves(self, nums: list[int], limit: int) -> int:", "container": "Solution", "callable": "minMoves", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "limit", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1675, "task_id": "minimize-deviation-in-array", "difficulty": "Hard", "problem_description": "You are given an array nums of n positive integers.\nYou can perform two types of operations on any element of the array any number of times:\n\nIf the element is even, divide it by 2.\n\n\t\nFor example, if the array is [1,2,3,4], then you can do this operation on the last element, and the array will be [1,2,3,2].\n\n\nIf the element is odd, multiply it by 2.\n\t\nFor example, if the array is [1,2,3,4], then you can do this operation on the first element, and the array will be [2,2,3,4].\n\n\n\nThe deviation of the array is the maximum difference between any two elements in the array.\nReturn the minimum deviation the array can have after performing some number of operations.\n \nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: 1\nExplanation: You can transform the array to [1,2,3,2], then to [2,2,3,2], then the deviation will be 3 - 2 = 1.\n\nExample 2:\n\nInput: nums = [4,1,5,20,3]\nOutput: 3\nExplanation: You can transform the array after two operations to [4,2,5,5,3], then the deviation will be 5 - 2 = 3.\n\nExample 3:\n\nInput: nums = [2,10,8]\nOutput: 3\n\n \nConstraints:\n\nn == nums.length\n2 <= n <= 5 * 104\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1000000000]) == 1953123\n assert candidate(nums = [3, 9, 6, 12]) == 3\n assert candidate(nums = [3, 9, 7, 3]) == 3\n assert candidate(nums = [2, 10, 8]) == 3\n assert candidate(nums = [5, 3, 11, 24, 2]) == 9\n assert candidate(nums = [1000000000, 1, 1000000000]) == 1953123\n assert candidate(nums = [1, 3, 5, 7, 9]) == 7\n assert candidate(nums = [15, 15, 15, 15]) == 0\n assert candidate(nums = [1, 2, 3, 4]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50]) == 15\n assert candidate(nums = [6, 1, 3, 4, 2, 8]) == 1\n assert candidate(nums = [8, 12, 24, 6]) == 1\n assert candidate(nums = [6, 10, 18, 24]) == 4\n assert candidate(nums = [4, 1, 5, 20, 3]) == 3\n assert candidate(nums = [7, 4, 1, 8, 12]) == 5\n assert candidate(nums = [10, 10, 10]) == 0\n assert candidate(nums = [3, 5, 6, 10, 15]) == 9\n assert candidate(nums = [10, 4, 3, 5]) == 2\n assert candidate(nums = [7, 4, 3, 7]) == 3\n assert candidate(nums = [1, 2, 9, 16]) == 7\n assert candidate(nums = [5, 17, 100, 1]) == 23\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 29\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 29\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 10\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 275\n assert candidate(nums = [1024, 2048, 3072, 4096, 5120, 6144, 7168, 8192, 9216, 10240, 11264, 12288, 13312, 14336, 15360, 16384, 17408, 18432, 19456, 20480]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020]) == 1717\n assert candidate(nums = [999999999, 1000000000, 999999998, 1000000001, 999999997, 1000000002]) == 5\n assert candidate(nums = [1000000001, 1000000002, 1000000003, 1000000004, 1000000005]) == 4\n assert candidate(nums = [17, 23, 31, 37, 41, 43, 47, 53, 59, 61]) == 28\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 13\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 27\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555]) == 765432099\n assert candidate(nums = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000]) == 12500\n assert candidate(nums = [2, 14, 18, 26, 34, 42, 50, 58, 66, 74]) == 35\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == 135\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 105\n assert candidate(nums = [64, 32, 16, 8, 4, 2, 1, 2, 4, 8, 16, 32, 64]) == 0\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997]) == 3\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78]) == 37\n assert candidate(nums = [1, 1000000000, 2, 500000000, 3, 333333333, 4, 250000000, 5, 200000000]) == 333333331\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000]) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 187\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 45\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 17\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 9\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000]) == 31250\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 69\n assert candidate(nums = [123456789, 987654321, 456789123, 321987654, 654321987, 789123456]) == 740740743\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165]) == 143\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 0\n assert candidate(nums = [1, 1000000000, 2, 2000000000, 3, 3000000000, 4, 4000000000, 5, 5000000000, 6, 6000000000, 7, 7000000000, 8, 8000000000, 9, 9000000000]) == 17578123\n assert candidate(nums = [1, 1000000000, 2, 500000000, 3, 1500000000]) == 5859373\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 51\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195]) == 169\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == 13\n assert candidate(nums = [2, 6, 18, 54, 162, 486, 1458, 4374, 13122, 39366, 118098, 354294, 1062882, 3188646, 9565938]) == 4782967\n assert candidate(nums = [13579, 24681, 35791, 46813, 57915, 68137, 79159, 81379, 91591, 113791]) == 86633\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500]) == 525\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383]) == 14337\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625]) == 9765615\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 17\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 59043\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 275\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 39\n assert candidate(nums = [13, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 71\n assert candidate(nums = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 65\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287]) == 522241\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 4\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 21\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996]) == 999999997\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 85\n assert candidate(nums = [5, 15, 25, 35, 45, 55]) == 45\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 37\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643]) == 4\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995]) == 4\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5]) == 1953123\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 63\n assert candidate(nums = [1024, 2048, 512, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5]) == 1953123\n assert candidate(nums = [1023, 2046, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1021\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(nums = [9, 18, 27, 36, 45, 54]) == 27\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums = [83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181]) == 84\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34]) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824]) == 0\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == 707\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 65\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumDeviation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumDeviation(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minimumDeviation", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1678, "task_id": "goal-parser-interpretation", "difficulty": "Easy", "problem_description": "You own a Goal Parser that can interpret a string command. The command consists of an alphabet of \"G\", \"()\" and/or \"(al)\" in some order. The Goal Parser will interpret \"G\" as the string \"G\", \"()\" as the string \"o\", and \"(al)\" as the string \"al\". The interpreted strings are then concatenated in the original order.\nGiven the string command, return the Goal Parser's interpretation of command.\n \nExample 1:\n\nInput: command = \"G()(al)\"\nOutput: \"Goal\"\nExplanation: The Goal Parser interprets the command as follows:\nG -> G\n() -> o\n(al) -> al\nThe final concatenated result is \"Goal\".\n\nExample 2:\n\nInput: command = \"G()()()()(al)\"\nOutput: \"Gooooal\"\n\nExample 3:\n\nInput: command = \"(al)G(al)()()G\"\nOutput: \"alGalooG\"\n\n \nConstraints:\n\n1 <= command.length <= 100\ncommand consists of \"G\", \"()\", and/or \"(al)\" in some order.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(command = \"G()()()()(al)\") == \"Gooooal\"\n assert candidate(command = \"G\") == \"G\"\n assert candidate(command = \"()\") == \"o\"\n assert candidate(command = \"(al)G(al)()()G\") == \"alGalooG\"\n assert candidate(command = \"G()(G)()\") == \"Go(G)o\"\n assert candidate(command = \"G(al)G(al)\") == \"GalGal\"\n assert candidate(command = \"G()(al)\") == \"Goal\"\n assert candidate(command = \"()()()()\") == \"oooo\"\n assert candidate(command = \"G()G(al)G()\") == \"GoGalGo\"\n assert candidate(command = \"G(al)G(al)G(al)\") == \"GalGalGal\"\n assert candidate(command = \"(al)(al)(al)\") == \"alalal\"\n assert candidate(command = \"(al)\") == \"al\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGalGalGal\"\n assert candidate(command = \"G(al)()()G(al)()()G(al)()()\") == \"GalooGalooGaloo\"\n assert candidate(command = \"G(al)(al)G(al)(al)G(al)(al)\") == \"GalalGalalGalal\"\n assert candidate(command = \"()()()()G(al)G(al)G(al)G(al)\") == \"ooooGalGalGalGal\"\n assert candidate(command = \"()()()G(al)G(al)G(al)G(al)G(al)G(al)\") == \"oooGalGalGalGalGalGal\"\n assert candidate(command = \"()G(al)G()G(al)()\") == \"oGalGoGalo\"\n assert candidate(command = \"()G(al)()G(al)()G(al)()\") == \"oGaloGaloGalo\"\n assert candidate(command = \"G()G()G()G()G()G()G()G()G()G()G()G()G()G()G(al)\") == \"GoGoGoGoGoGoGoGoGoGoGoGoGoGoGal\"\n assert candidate(command = \"G(al)(al)(al)\") == \"Galalal\"\n assert candidate(command = \"()(G(al)G(al))(G(al)G(al))\") == \"o(GalGal)(GalGal)\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGalGal\"\n assert candidate(command = \"()G(al)G(al)G(al)G(al)G(al)G(al)\") == \"oGalGalGalGalGalGal\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGal\"\n assert candidate(command = \"G(al)G()G(al)G()G(al)\") == \"GalGoGalGoGal\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"G()(al)G()(al)G()(al)\") == \"GoalGoalGoal\"\n assert candidate(command = \"(al)G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"alGaloGaloGaloGaloGalo\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGalGal\"\n assert candidate(command = \"()G(al)G()G(al)\") == \"oGalGoGal\"\n assert candidate(command = \"(al)G(al)()()G(al)G(al)()()G(al)G(al)()()G\") == \"alGalooGalGalooGalGalooG\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGal\"\n assert candidate(command = \"G(al)(al)(al)(al)\") == \"Galalalal\"\n assert candidate(command = \"(al)G(al)(G(al)(G(al)G(al)))G(al)\") == \"alGal(Gal(GalGal))Gal\"\n assert candidate(command = \"G()()G()()G()()\") == \"GooGooGoo\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"GaloGaloGaloGaloGalo\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"GaloGaloGaloGaloGaloGaloGaloGaloGaloGaloGalo\"\n assert candidate(command = \"G()G()G(al)(al)G()\") == \"GoGoGalalGo\"\n assert candidate(command = \"G(al)G(al)()()G(al)G(al)G(al)\") == \"GalGalooGalGalGal\"\n assert candidate(command = \"G()(G()(G()(G())))\") == \"Go(Go(Go(Go)))\"\n assert candidate(command = \"()G()G(al)()G(al)()G(al)\") == \"oGoGaloGaloGal\"\n assert candidate(command = \"()G()()G()()G()()G(al)G()\") == \"oGooGooGooGalGo\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)\") == \"GalGalGalGal\"\n assert candidate(command = \"G()(al)G()(al)G()(al)G()(al)\") == \"GoalGoalGoalGoal\"\n assert candidate(command = \"G()()()()(al)G(al)G(al)G(al)\") == \"GooooalGalGalGal\"\n assert candidate(command = \"G(al)G(al)()()G(al)G(al)()()\") == \"GalGalooGalGaloo\"\n assert candidate(command = \"G()(G(al))(G(al))G()(G(al))(G(al))\") == \"Go(Gal)(Gal)Go(Gal)(Gal)\"\n assert candidate(command = \"(al)(al)G(al)(al)G(al)(al)\") == \"alalGalalGalal\"\n assert candidate(command = \"G(al)(al)(al)G\") == \"GalalalG\"\n assert candidate(command = \"(al)G(al)()G(al)()G(al)()G(al)()\") == \"alGaloGaloGaloGalo\"\n assert candidate(command = \"G(al)(al)(al)G(al)(al)(al)G(al)(al)(al)G\") == \"GalalalGalalalGalalalG\"\n assert candidate(command = \"G(al)(G(al)G(al))(G(al))\") == \"Gal(GalGal)(Gal)\"\n assert candidate(command = \"G()(G(al))G()(G(al))\") == \"Go(Gal)Go(Gal)\"\n assert candidate(command = \"G()G()G()G()G()G()G()G()\") == \"GoGoGoGoGoGoGoGo\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"GaloGaloGaloGaloGaloGalo\"\n assert candidate(command = \"()()()G(al)G(al)G(al)()()()\") == \"oooGalGalGalooo\"\n assert candidate(command = \"(al)()G(al)()G(al)G(al)\") == \"aloGaloGalGal\"\n assert candidate(command = \"(al)(al)(al)(al)G(al)G()\") == \"alalalalGalGo\"\n assert candidate(command = \"(al)(G)(al)(G)(al)(G)(al)\") == \"al(G)al(G)al(G)al\"\n assert candidate(command = \"G(al)(al)G(al)\") == \"GalalGal\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGal\"\n assert candidate(command = \"()G(al)G(al)G(al)G(al)G(al)\") == \"oGalGalGalGalGal\"\n assert candidate(command = \"G(al)G()(al)G()(al)G()(al)G()\") == \"GalGoalGoalGoalGo\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"G()(G()(G)())\") == \"Go(Go(G)o)\"\n assert candidate(command = \"()()()()()()()()()()()()()()()()()()()()()G(al)\") == \"oooooooooooooooooooooGal\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)\") == \"GaloGaloGaloGaloGal\"\n assert candidate(command = \"(al)G(al)(al)G(al)G\") == \"alGalalGalG\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGal\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"(al)()G(al)()G(al)()G(al)()\") == \"aloGaloGaloGalo\"\n assert candidate(command = \"G(al)(G()(G)(G)())G(al)\") == \"Gal(Go(G)(G)o)Gal\"\n assert candidate(command = \"G()G(al)G()G(al)\") == \"GoGalGoGal\"\n assert candidate(command = \"(al)(al)(al)G(al)\") == \"alalalGal\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGal\"\n assert candidate(command = \"(al)(G(al))(G(al))(G(al))(G(al))(G(al))\") == \"al(Gal)(Gal)(Gal)(Gal)(Gal)\"\n assert candidate(command = \"()()()()()G(al)()()\") == \"oooooGaloo\"\n assert candidate(command = \"()G(al)()G(al)()\") == \"oGaloGalo\"\n assert candidate(command = \"(al)(al)(al)(al)(al)(al)(al)(al)\") == \"alalalalalalalal\"\n assert candidate(command = \"()()()()(al)()()()(al)()()()\") == \"ooooaloooalooo\"\n assert candidate(command = \"G(al)G()G(al)G()G(al)G()\") == \"GalGoGalGoGalGo\"\n assert candidate(command = \"G()(G()(G()(G)())())\") == \"Go(Go(Go(G)o)o)\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"GaloGaloGaloGaloGaloGaloGaloGalo\"\n assert candidate(command = \"G(al)(al)G(al)G(al)\") == \"GalalGalGal\"\n assert candidate(command = \"G(al)(G(al))(G(al))(G(al))G(al)\") == \"Gal(Gal)(Gal)(Gal)Gal\"\n assert candidate(command = \"G()()()()(al)G(al)G(al)G(al)G(al)\") == \"GooooalGalGalGalGal\"\n assert candidate(command = \"G()(G()(G()(G()())))\") == \"Go(Go(Go(Goo)))\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)G(al)\") == \"GaloGaloGaloGaloGalGal\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"G()G()G()G()G()G()G()G()G()G()G()G()G()G()G()G()\") == \"GoGoGoGoGoGoGoGoGoGoGoGoGoGoGoGo\"\n assert candidate(command = \"(al)()()()()()()()()()()()()()()()()()()()()()()()()()()()()\") == \"aloooooooooooooooooooooooooooo\"\n assert candidate(command = \"G()G()G()G()G(al)G(al)G(al)\") == \"GoGoGoGoGalGalGal\"\n assert candidate(command = \"()()()()()()()()()()G(al)G(al)G(al)G(al)G(al)\") == \"ooooooooooGalGalGalGalGal\"\n"}, "metadata": {"canonical_parameter_names": ["command"], "leetcode_dataset_entry_point": "Solution().interpret", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def interpret(self, command: str) -> str:", "container": "Solution", "callable": "interpret", "parameters": [{"name": "command", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1679, "task_id": "max-number-of-k-sum-pairs", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer k.\nIn one operation, you can pick two numbers from the array whose sum equals k and remove them from the array.\nReturn the maximum number of operations you can perform on the array.\n \nExample 1:\n\nInput: nums = [1,2,3,4], k = 5\nOutput: 2\nExplanation: Starting with nums = [1,2,3,4]:\n- Remove numbers 1 and 4, then nums = [2,3]\n- Remove numbers 2 and 3, then nums = []\nThere are no more pairs that sum up to 5, hence a total of 2 operations.\nExample 2:\n\nInput: nums = [3,1,3,4,3], k = 6\nOutput: 1\nExplanation: Starting with nums = [3,1,3,4,3]:\n- Remove the first two 3's, then nums = [1,4,3]\nThere are no more pairs that sum up to 6, hence a total of 1 operation.\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 1, 3, 4, 3],k = 6) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 5\n assert candidate(nums = [1000000000],k = 1000000000) == 0\n assert candidate(nums = [1, 5, 4, 2, 9, 6, 5, 3, 4, 7, 8, 10],k = 11) == 5\n assert candidate(nums = [1, 3, 5, 7, 9],k = 10) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 10) == 3\n assert candidate(nums = [1, 5, 7, 8, 2, 6, 3, 4],k = 9) == 4\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1000000000],k = 2000000000) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11) == 5\n assert candidate(nums = [5, 5, 5, 5, 5],k = 10) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 4) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 4\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],k = 3) == 3\n assert candidate(nums = [1, 2, 3, 4],k = 5) == 2\n assert candidate(nums = [1, 3, 2, 2, 2, 3, 1],k = 4) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 10) == 4\n assert candidate(nums = [1, 3, 2, 2, 2, 3, 1],k = 4) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 26) == 12\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 30) == 7\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 42) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],k = 15) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 21) == 20\n assert candidate(nums = [1, 3, 3, 5, 7, 7, 5, 9, 9, 11, 11, 13],k = 12) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 21) == 10\n assert candidate(nums = [1, 5, 7, 3, 5, 7, 9, 11, 13, 15],k = 12) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 7\n assert candidate(nums = [1, 3, 2, 2, 2, 2, 2, 3, 1, 3, 3, 2, 2, 2, 3, 2, 2, 1, 3, 2],k = 4) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 11) == 10\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1000000000],k = 1000000001) == 1\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 100) == 5\n assert candidate(nums = [1, 5, 7, 1, 5, 7, 1, 5, 7, 1, 5, 7, 1, 5, 7, 1, 5, 7, 1, 5, 7],k = 6) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 300) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 16) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 6) == 25\n assert candidate(nums = [999999999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1000000000) == 1\n assert candidate(nums = [1, 5, 7, 1, 5, 9, 5, 5, 5, 5],k = 10) == 4\n assert candidate(nums = [5, 1, 4, 8, 6, 9, 7, 2, 3, 10],k = 15) == 3\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 200) == 10\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8],k = 6) == 6\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 20) == 7\n assert candidate(nums = [1000000000, 1000000000, 1, 1, 2, 2, 999999999, 999999999],k = 2000000000) == 1\n assert candidate(nums = [1, 5, 4, 2, 8, 6, 7, 3, 9],k = 10) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 300) == 11\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 400) == 21\n assert candidate(nums = [1000000000, 1, 1000000000, 2, 3, 999999999, 3, 2],k = 2000000000) == 1\n assert candidate(nums = [2, 5, 4, 4, 1, 3, 4, 4, 1, 4, 4, 1, 2, 1, 2, 2, 3, 2, 4, 2],k = 6) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 21) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 21) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 300) == 11\n assert candidate(nums = [2, 4, 3, 5, 7, 8, 1, 9, 10, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 31) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 32) == 8\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 27) == 7\n assert candidate(nums = [3, 6, 3, 3, 6, 6, 3, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6],k = 9) == 15\n assert candidate(nums = [10, 15, 3, 7, 11, 15, 0, 7, 6, 10, 3, 11, 1],k = 15) == 1\n assert candidate(nums = [1, 5, 7, 1, 5, 9, 7, 5, 11, 1],k = 10) == 2\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 12) == 7\n assert candidate(nums = [1000000000, 1, 999999999, 2, 999999998, 3, 999999997, 4],k = 1000000001) == 4\n assert candidate(nums = [1000000000, 1000000000, 1, 1, 2, 2, 3, 3],k = 2000000000) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 16\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 11) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 41) == 20\n assert candidate(nums = [3, 1, 3, 4, 3, 5, 6, 2, 3, 1],k = 6) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],k = 50) == 12\n assert candidate(nums = [1, 5, 7, -1, 5],k = 6) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 16) == 7\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 18) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 20) == 5\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 1000000000, 999999999, 1],k = 2000000000) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxOperations(self, nums: List[int], k: int) -> int:", "container": "Solution", "callable": "maxOperations", "parameters": [{"name": "nums", "type": "List[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1680, "task_id": "concatenation-of-consecutive-binary-numbers", "difficulty": "Medium", "problem_description": "Given an integer n, return the decimal value of the binary string formed by concatenating the binary representations of 1 to n in order, modulo 109 + 7.\n \nExample 1:\n\nInput: n = 1\nOutput: 1\nExplanation: \"1\" in binary corresponds to the decimal value 1. \n\nExample 2:\n\nInput: n = 3\nOutput: 27\nExplanation: In binary, 1, 2, and 3 corresponds to \"1\", \"10\", and \"11\".\nAfter concatenating them, we have \"11011\", which corresponds to the decimal value 27.\n\nExample 3:\n\nInput: n = 12\nOutput: 505379714\nExplanation: The concatenation results in \"1101110010111011110001001101010111100\".\nThe decimal value of that is 118505380540.\nAfter modulo 109 + 7, the result is 505379714.\n\n \nConstraints:\n\n1 <= n <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 27\n assert candidate(n = 100000) == 757631812\n assert candidate(n = 100) == 310828084\n assert candidate(n = 12) == 505379714\n assert candidate(n = 10000) == 356435599\n assert candidate(n = 20) == 632668867\n assert candidate(n = 1) == 1\n assert candidate(n = 1000) == 499361981\n assert candidate(n = 10) == 462911642\n assert candidate(n = 5) == 1765\n assert candidate(n = 15000) == 760107204\n assert candidate(n = 99999) == 880407397\n assert candidate(n = 12345) == 836722104\n assert candidate(n = 67890) == 121883656\n assert candidate(n = 32767) == 351669993\n assert candidate(n = 90000) == 333354001\n assert candidate(n = 50000) == 305317209\n assert candidate(n = 60000) == 841047212\n assert candidate(n = 30000) == 789968936\n assert candidate(n = 80000) == 801174769\n assert candidate(n = 8192) == 853721666\n assert candidate(n = 65536) == 273282097\n assert candidate(n = 5000) == 754628255\n assert candidate(n = 75000) == 363627085\n assert candidate(n = 40000) == 162370743\n assert candidate(n = 65535) == 183542430\n assert candidate(n = 500) == 715412131\n assert candidate(n = 25000) == 110872861\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().concatenatedBinary", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def concatenatedBinary(self, n: int) -> int:", "container": "Solution", "callable": "concatenatedBinary", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1681, "task_id": "minimum-incompatibility", "difficulty": "Hard", "problem_description": "You are given an integer array nums​​​ and an integer k. You are asked to distribute this array into k subsets of equal size such that there are no two equal elements in the same subset.\nA subset's incompatibility is the difference between the maximum and minimum elements in that array.\nReturn the minimum possible sum of incompatibilities of the k subsets after distributing the array optimally, or return -1 if it is not possible.\nA subset is a group integers that appear in the array with no particular order.\n \nExample 1:\n\nInput: nums = [1,2,1,4], k = 2\nOutput: 4\nExplanation: The optimal distribution of subsets is [1,2] and [1,4].\nThe incompatibility is (2-1) + (4-1) = 4.\nNote that [1,1] and [2,4] would result in a smaller sum, but the first subset contains 2 equal elements.\nExample 2:\n\nInput: nums = [6,3,8,1,3,1,2,2], k = 4\nOutput: 6\nExplanation: The optimal distribution of subsets is [1,2], [2,3], [6,8], and [1,3].\nThe incompatibility is (2-1) + (3-2) + (8-6) + (3-1) = 6.\n\nExample 3:\n\nInput: nums = [5,3,3,6,3,3], k = 3\nOutput: -1\nExplanation: It is impossible to distribute nums into 3 subsets where no two elements are equal in the same subset.\n\n \nConstraints:\n\n1 <= k <= nums.length <= 16\nnums.length is divisible by k\n1 <= nums[i] <= nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 1) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 8) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8],k = 4) == 4\n assert candidate(nums = [6, 3, 8, 1, 3, 1, 2, 2],k = 4) == 6\n assert candidate(nums = [1, 2, 1, 4],k = 2) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8],k = 2) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 4) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 16) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4],k = 4) == 4\n assert candidate(nums = [5, 3, 3, 6, 3, 3],k = 3) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],k = 1) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 2) == 14\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4],k = 8) == 0\n assert candidate(nums = [1, 2, 3, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14],k = 2) == 18\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 12\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7],k = 4) == 14\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],k = 4) == 12\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3],k = 3) == -1\n assert candidate(nums = [1, 2, 3, 4, 4, 4, 5, 6, 6, 7, 7, 8, 9, 10, 11, 12],k = 3) == -1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 6) == 10\n assert candidate(nums = [1, 2, 3, 3, 3, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9, 10],k = 2) == -1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 6) == 9\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9],k = 7) == 9\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6],k = 4) == 14\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 1],k = 2) == 14\n assert candidate(nums = [2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],k = 6) == 9\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],k = 8) == 8\n assert candidate(nums = [3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],k = 4) == 12\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11],k = 4) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 2) == 14\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7],k = 2) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15],k = 5) == -1\n assert candidate(nums = [1, 3, 2, 6, 4, 5, 7, 8, 10, 9, 12, 11, 14, 13, 16, 15],k = 4) == 12\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 20\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5, 5, 6, 6, 6, 7, 8, 8, 9, 9],k = 3) == -1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9],k = 4) == 13\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14],k = 4) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 14, 15, 16],k = 6) == 9\n assert candidate(nums = [1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 7, 8, 8, 9, 10, 11],k = 3) == -1\n assert candidate(nums = [1, 3, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 10, 10, 11, 12],k = 4) == 15\n assert candidate(nums = [1, 3, 3, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17, 17],k = 8) == 16\n assert candidate(nums = [1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17],k = 4) == 24\n assert candidate(nums = [1, 2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 12],k = 8) == 11\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6],k = 4) == -1\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 13],k = 4) == 17\n assert candidate(nums = [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5],k = 5) == -1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],k = 4) == 13\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 4) == 13\n assert candidate(nums = [1, 1, 1, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 11, 11],k = 4) == 22\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],k = 4) == 13\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 4) == 12\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 6) == 8\n assert candidate(nums = [2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 8, 8, 9],k = 3) == -1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],k = 8) == 8\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16],k = 4) == 16\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7],k = 8) == 8\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == -1\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6],k = 4) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 8) == 8\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 3) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8],k = 8) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 9, 10, 11, 12, 13, 13],k = 4) == 16\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 10],k = 5) == -1\n assert candidate(nums = [3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],k = 2) == -1\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 2) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13],k = 4) == 15\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 8) == 9\n assert candidate(nums = [6, 3, 8, 1, 3, 1, 2, 2, 4, 5, 7, 9, 10, 11, 12, 13],k = 4) == 13\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],k = 2) == 14\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == 17\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 4) == 12\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 9) == 10\n assert candidate(nums = [1, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 13],k = 4) == 16\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 2) == -1\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 9) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15],k = 8) == 9\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10, 11],k = 4) == 14\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 4) == 16\n assert candidate(nums = [2, 2, 3, 4, 5, 5, 6, 6, 7, 8, 9, 10, 10, 11, 12, 12],k = 8) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7],k = 4) == 12\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4],k = 4) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == -1\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],k = 2) == 14\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6],k = 3) == -1\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],k = 3) == -1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],k = 3) == -1\n assert candidate(nums = [1, 3, 3, 3, 3, 5, 5, 5, 7, 7, 7, 7, 9, 9, 9, 9],k = 2) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 12, 13, 14, 15, 16],k = 8) == 9\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 1) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8],k = 4) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 9, 10, 10, 11, 12, 13],k = 4) == 13\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minimumIncompatibility", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumIncompatibility(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "minimumIncompatibility", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1684, "task_id": "count-the-number-of-consistent-strings", "difficulty": "Easy", "problem_description": "You are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string appear in the string allowed.\nReturn the number of consistent strings in the array words.\n \nExample 1:\n\nInput: allowed = \"ab\", words = [\"ad\",\"bd\",\"aaab\",\"baa\",\"badab\"]\nOutput: 2\nExplanation: Strings \"aaab\" and \"baa\" are consistent since they only contain characters 'a' and 'b'.\n\nExample 2:\n\nInput: allowed = \"abc\", words = [\"a\",\"b\",\"c\",\"ab\",\"ac\",\"bc\",\"abc\"]\nOutput: 7\nExplanation: All strings are consistent.\n\nExample 3:\n\nInput: allowed = \"cad\", words = [\"cc\",\"acd\",\"b\",\"ba\",\"bac\",\"bad\",\"ac\",\"d\"]\nOutput: 4\nExplanation: Strings \"cc\", \"acd\", \"ac\", and \"d\" are consistent.\n\n \nConstraints:\n\n1 <= words.length <= 104\n1 <= allowed.length <= 26\n1 <= words[i].length <= 10\nThe characters in allowed are distinct.\nwords[i] and allowed contain only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(allowed = \"ijkl\",words = ['i', 'j', 'k', 'l', 'ij', 'ik', 'il', 'jk', 'jl', 'kl', 'ijkl']) == 11\n assert candidate(allowed = \"abcdef\",words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef']) == 6\n assert candidate(allowed = \"cad\",words = ['cc', 'acd', 'b', 'ba', 'bac', 'bad', 'ac', 'd']) == 4\n assert candidate(allowed = \"gh\",words = ['g', 'h', 'gh']) == 3\n assert candidate(allowed = \"xyz\",words = ['xy', 'yz', 'xzy', 'zxy', 'zyx', 'xyz']) == 6\n assert candidate(allowed = \"xyz\",words = ['x', 'y', 'z', 'xy', 'xz', 'yz', 'xyz']) == 7\n assert candidate(allowed = \"uvw\",words = ['u', 'v', 'w', 'uv', 'uw', 'vw', 'uvw']) == 7\n assert candidate(allowed = \"mnop\",words = ['m', 'n', 'o', 'p', 'mn', 'mo', 'mp', 'no', 'np', 'op', 'mno', 'mnp', 'mop', 'nop', 'mnop']) == 15\n assert candidate(allowed = \"mnop\",words = ['m', 'n', 'o', 'p', 'mn', 'mo', 'mp', 'no', 'np', 'op', 'mno', 'mnp', 'mop', 'nop', 'mnop']) == 15\n assert candidate(allowed = \"ab\",words = ['ad', 'bd', 'aaab', 'baa', 'badab']) == 2\n assert candidate(allowed = \"abc\",words = ['a', 'b', 'c', 'ab', 'ac', 'bc', 'abc']) == 7\n assert candidate(allowed = \"qrst\",words = ['qr', 'qs', 'qt', 'rs', 'rt', 'st', 'qrs', 'qrt', 'qst', 'rst', 'qrst']) == 11\n assert candidate(allowed = \"qwerty\",words = ['q', 'w', 'e', 'r', 't', 'y', 'qw', 'we', 'er', 'rt', 'ty', 'yq', 'qr', 're', 'et', 'ty', 'yr', 're', 'et', 'ty', 'qwer', 'wert', 'erty', 'rtye', 'tyer', 'yert', 'erty', 'rtye', 'tyer', 'yert']) == 30\n assert candidate(allowed = \"xyz\",words = ['xzy', 'zyx', 'xyzz', 'zyzzx', 'xzyzyx', 'zyzxzy', 'xyzxyz', 'zyxzyxzyx']) == 8\n assert candidate(allowed = \"abcdef\",words = ['abc', 'bcd', 'cde', 'def', 'abcf', 'bcde', 'cdef', 'abcdef', 'af', 'bf', 'cf', 'df', 'ef', 'f', 'a', 'b', 'c', 'd', 'e']) == 19\n assert candidate(allowed = \"abcdefg\",words = ['abc', 'def', 'ghi', 'abcd', 'efg', 'abdefg', 'abcdef', 'abcdefg', 'xyz']) == 7\n assert candidate(allowed = \"mnopqr\",words = ['mnop', 'opqr', 'mnqr', 'mpqr', 'mnoq', 'mnpq', 'mnopq', 'mnopqr', 'mnoqr', 'mnopqr', 'qrmpno', 'rpmnqo', 'qrmp', 'mnpqr', 'pqmno']) == 15\n assert candidate(allowed = \"xyz\",words = ['x', 'y', 'z', 'xy', 'xz', 'yz', 'xyz', 'xyzz', 'zxy', 'yxz', 'zyx', 'zzz']) == 12\n assert candidate(allowed = \"abcdef\",words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'fedcba', 'defabc', 'cbadef', 'abcdefg', 'abcdefh', 'abcdefi', 'abcdefj', 'abcdefk', 'abcdefl', 'abcdefm', 'abef', 'acd', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'ab', 'bc', 'cd', 'de', 'ef', 'fg', 'gh', 'hi', 'ij', 'jk', 'kl', 'lm', 'mn', 'no', 'op', 'pq', 'qr', 'rs', 'st', 'tu', 'uv', 'vw', 'wx', 'xy', 'yz', 'za', 'abab', 'acac', 'adad', 'aeae', 'afaf', 'agag', 'ahah', 'aiai', 'ajaj', 'akak', 'alal', 'amam', 'anan', 'aoao', 'apap', 'aqaq', 'arar', 'asas', 'atat', 'auau', 'avav', 'awaw', 'axax', 'ayay', 'azaz']) == 24\n assert candidate(allowed = \"tuvwxy\",words = ['tuv', 'uvw', 'vwx', 'wxy', 'tuvw', 'uvwx', 'vwx', 'wxy', 'tuvwx', 'uvwxy', 'tuvwxy', 'tuvwxyu', 'tuvwxyv', 'tuvwxyw', 'tuvwxyx', 'tuvwxyy']) == 16\n assert candidate(allowed = \"ijklmno\",words = ['ijkl', 'ijkm', 'ilkn', 'ijln', 'ikln', 'jklm', 'jkmn', 'jlmn', 'klnm', 'ijklmnop', 'ijklmnoi', 'ijklmnopq', 'ijklmnopqrstuvwxyz', 'ijklmnolikj', 'ijklmnlijklmn', 'mnopijk', 'mnopilkmn']) == 12\n assert candidate(allowed = \"mnopqrstuvw\",words = ['mnop', 'qrstuv', 'w', 'mnopqr', 'stuvw', 'mnopqrstuvw', 'mnopqrstuvww', 'mnopqrstuvwww', 'mnopqrstuvwq', 'mnopqrstuvwqq', 'mnopqrstuvwrr', 'mnopqrstuvwsss', 'mnopqrstuvwttt', 'mnopqrstuvwuuu', 'mnopqrstuvwvvv', 'mnopqrstuvwwww']) == 16\n assert candidate(allowed = \"qrstuv\",words = ['qrst', 'uv', 'qrs', 'tu', 'rqs', 'vut', 'qrtuv', 'tuvqr', 'usvrtq', 'rqstuv', 'uvtqrs', 'qrsutv', 'rqvstu']) == 13\n assert candidate(allowed = \"pqrs\",words = ['pq', 'qr', 'rs', 'sp', 'pqrs', 'prqs', 'psrq', 'sqrp', 'rqps', 'rspq', 'pqs', 'qsr', 'rsq', 'spq', 'qrp', 'rps', 'sqr', 'prq', 'qsp', 'rqs', 'spr', 'psr', 'qrs', 'rsq', 'spq', 'pqr', 'qrs', 'rsp', 'spr', 'psr', 'srp', 'rps', 'qsp', 'psq']) == 34\n assert candidate(allowed = \"mnopqr\",words = ['mno', 'mnp', 'mqr', 'npr', 'opq', 'orq', 'pqr', 'mnop', 'mnoq', 'mnopqr', 'pqor', 'nopr', 'mnopq', 'nopqr', 'mnopqrs', 'mnoprq', 'mnopqrr', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs']) == 16\n assert candidate(allowed = \"jklm\",words = ['jj', 'kk', 'll', 'mm', 'jk', 'jl', 'jm', 'kl', 'km', 'lm', 'jkl', 'jkm', 'jlm', 'klm', 'jklm', 'jkll', 'jjkkllmm', 'klmklm', 'jkljkl', 'mnop', 'qrst', 'uvwxy', 'z']) == 19\n assert candidate(allowed = \"klmnopqrstuvwxyz\",words = ['klmnopqrstuvwxyzz', 'klmnopqrstuvwxzz', 'klmnopqrstuvwxxz', 'klmnopqrstuvvvvv', 'klmnopqrsssssss', 'klmnopqqqqqqqq', 'klllllllllll', 'kkkkkkkkkkkk', 'jjjjjjjjjjjj', 'iiiiiiiiiiii', 'hhhhhhhhhhhh', 'gggggggggggg', 'ffffffffffff', 'eeeeeeeeeeee', 'dddddddddddd', 'cccccccccc', 'bbbbbbbbbb', 'aaaaaaaaaa']) == 8\n assert candidate(allowed = \"mno\",words = ['m', 'n', 'o', 'mn', 'no', 'om', 'mno', 'mon', 'nom', 'omn', 'nmo', 'nom', 'omn', 'mon', 'mno', 'mno', 'nom', 'omn', 'mon', 'mno', 'nom', 'omn', 'mon', 'mno', 'nom', 'omn', 'mon', 'mno', 'nom', 'omn', 'mon', 'mno']) == 32\n assert candidate(allowed = \"abcdefghij\",words = ['abcdefghij', 'abcdefghijk', 'abcdefghi', 'abcdefg', 'abcde', 'abcd', 'abc', 'ab', 'a', 'jihgfedcba', 'abcdefghijabcdefghij', 'abcdefghijabcdefghijk', 'abcdefghijabcdefghi', 'abcdefghijabcdefg', 'abcdefghijabcde', 'abcdefghijabcd', 'abcdefghijabc', 'abcdefghijab', 'abcdefghija']) == 17\n assert candidate(allowed = \"ijkl\",words = ['ij', 'kl', 'ik', 'jl', 'ikl', 'jkl', 'ijk', 'ijkl', 'ijl', 'ikjl', 'likj', 'ljk', 'lkij', 'lijk', 'ilkj', 'lkji']) == 16\n assert candidate(allowed = \"xyz\",words = ['xy', 'yz', 'xz', 'xyz', 'zyx', 'yxz', 'xzy', 'zy', 'yx', 'zx']) == 10\n assert candidate(allowed = \"xyz\",words = ['x', 'y', 'z', 'xy', 'xz', 'yz', 'xyz', 'xzy', 'yzx', 'zyx', 'zyz', 'zxz', 'yzy', 'xyx', 'xxy', 'xxz', 'xyy', 'xzz', 'yyy', 'yzz', 'zzz']) == 21\n assert candidate(allowed = \"abcdefghij\",words = ['abcdefghij', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'ab', 'cd', 'ef', 'gh', 'ij', 'abcd', 'efgh', 'ijkl', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'abcdefghijk', 'abcdefghijj', 'abcdefghiij', 'abcdefghhij', 'abcdefghiiij']) == 31\n assert candidate(allowed = \"xyz\",words = ['xyzzy', 'zyx', 'zxyx', 'zzyzxzy', 'xyzabc', 'xzyz']) == 5\n assert candidate(allowed = \"fv\",words = ['f', 'v', 'fv', 'vf', 'ff', 'vv', 'ffff', 'vvvv', 'fvfv', 'vfvf', 'fvvf', 'vvff', 'fvff', 'vvvf', 'fvvv', 'ffvv', 'f', 'v', 'fv', 'vf', 'ff', 'vv', 'ffff', 'vvvv', 'fvfv', 'vfvf', 'fvvf', 'vvff', 'fvff', 'vvvf', 'fvvv', 'ffvv', 'f', 'v', 'fv', 'vf', 'ff', 'vv', 'ffff', 'vvvv']) == 40\n assert candidate(allowed = \"qrst\",words = ['qqqq', 'rrrr', 'ssss', 'tttt', 'qqrr', 'qqss', 'qqtt', 'rrss', 'rrtt', 'sstt', 'qqrrss', 'qqrrtt', 'qqsstt', 'rrsstt', 'qqrrsstt', 'qqrrssttt']) == 16\n assert candidate(allowed = \"abcdefghij\",words = ['abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'abcdefghijabcdefghij', 'abcdefghijabcdefgh', 'abcdefghijabcdef', 'abcdefghijabcd', 'abcdefghijabc', 'abcdefghijab', 'abcdefghija']) == 17\n assert candidate(allowed = \"xyz\",words = ['xy', 'xz', 'yz', 'xyz', 'xx', 'yy', 'zz', 'xyx', 'yzy', 'zxz', 'xyxy', 'xzyz', 'yzxy', 'xyzx', 'xzyzx', 'yzxyz', 'xyzyx', 'zxyxz', 'yxzyz', 'zyxzy']) == 20\n assert candidate(allowed = \"abcdef\",words = ['a', 'b', 'c', 'd', 'e', 'f', 'ab', 'cd', 'ef', 'abc', 'def', 'abcdef', 'abcdefg', 'abcdefabc']) == 13\n assert candidate(allowed = \"qrstuv\",words = ['qrst', 'qrsu', 'rstuv', 'qrstu', 'quv', 'qrs', 'qrtuv', 'qru', 'quvtsr', 'quvz']) == 9\n assert candidate(allowed = \"abcdef\",words = ['abc', 'def', 'abcdef', 'aabbcc', 'ddeeff', 'abcdeff', 'abcdefg']) == 6\n assert candidate(allowed = \"ijklmnop\",words = ['ijkl', 'mnop', 'ijkm', 'klnm', 'ijlmo', 'ijkmnop', 'ijklmnopq', 'ijklmno', 'ijklnop']) == 8\n assert candidate(allowed = \"jklmno\",words = ['jk', 'kl', 'lm', 'mn', 'no', 'jkl', 'klm', 'lmn', 'mno', 'jklm', 'klmn', 'lmno', 'jklmo', 'klmno', 'jklmno', 'jklmnou', 'klmnop', 'jklmnop']) == 15\n assert candidate(allowed = \"abcdef\",words = ['abc', 'def', 'abcd', 'abef', 'acdf', 'bcde', 'acde', 'bcdf', 'abcf', 'abcdef', 'afecbd', 'fedcba']) == 12\n assert candidate(allowed = \"qrst\",words = ['q', 'r', 's', 't', 'qr', 'qs', 'qt', 'rs', 'rt', 'st', 'qrs', 'qrt', 'qst', 'rst', 'qrst']) == 15\n assert candidate(allowed = \"wxyz\",words = ['w', 'x', 'y', 'z', 'wx', 'wxyz', 'xy', 'yz', 'wxy', 'wxyz', 'wxzy', 'xywz', 'yzwx', 'zxyw']) == 14\n assert candidate(allowed = \"abcd\",words = ['a', 'b', 'c', 'd', 'ab', 'bc', 'cd', 'da', 'abc', 'bcd', 'cda', 'dab', 'abcd', 'bcda', 'cdab', 'dabc', 'abdc', 'bacd', 'cabd', 'dabc', 'acbd', 'badc', 'cabd', 'dacb', 'acdb', 'bdac', 'cadb', 'dbac', 'dcab', 'dcba']) == 30\n assert candidate(allowed = \"xyz\",words = ['xyzz', 'zyx', 'zxy', 'xxxyyyzzz', 'zzzz', 'yyyxxx', 'abc', 'xyzzyx', 'zzzxxx', 'xyxyxy']) == 9\n assert candidate(allowed = \"abcdef\",words = ['abc', 'def', 'abcdef', 'abcd', 'abcf', 'defa', 'bcde', 'fabc', 'aabbccdd', 'fedcba']) == 10\n assert candidate(allowed = \"qz\",words = ['qqqz', 'zqq', 'q', 'z', 'zzzz', 'qqqq', 'qzqz', 'zqzq', 'zzzq', 'zqqz']) == 10\n assert candidate(allowed = \"xyz\",words = ['xy', 'yz', 'xz', 'xyz', 'xzy', 'yxz', 'zxy', 'zyx', 'yzz', 'zzz']) == 10\n assert candidate(allowed = \"jkl\",words = ['j', 'k', 'l', 'jk', 'kl', 'lj', 'jkl', 'klj', 'lkj', 'kjl', 'jlk', 'lk', 'kj', 'jl', 'kl', 'jk', 'lj', 'kl', 'jl', 'kj', 'jl', 'kj', 'lk', 'jk', 'kl', 'jl', 'kj', 'lk', 'jk', 'kl', 'jl', 'kj']) == 32\n assert candidate(allowed = \"mnopqr\",words = ['mnop', 'mnopqr', 'mnopq', 'mnopqrs', 'mnopqrst', 'mnopqrstuv', 'mnopqrstu', 'mnopqrst', 'mnopqrstuvw', 'mnopqrstuvwx', 'mnopqrstuvwxy', 'mnopqrstuvwxyz', 'mno', 'pqrs', 'qrst', 'uvwx', 'vwxyz']) == 4\n assert candidate(allowed = \"uvw\",words = ['uvw', 'uv', 'uw', 'vw', 'u', 'v', 'w', 'uvvw', 'uwwv', 'vwwu', 'vvvuuuwww', 'wuvuvuvuv']) == 12\n assert candidate(allowed = \"mnopqr\",words = ['mnop', 'nopq', 'opqr', 'mnopq', 'nopqr', 'mnopqr', 'mnopqr', 'mnopqrs', 'mnopqrst', 'mnopqrstu', 'mnopqrstuv', 'mnopqrstuvw', 'mnopqrstuvwx', 'mnopqrstuvwxy', 'mnopqrstuvwxyz']) == 7\n assert candidate(allowed = \"abcdefghij\",words = ['abcde', 'fghij', 'abcdefghij', 'abcdefghi', 'efgij', 'hijabc', 'defghij', 'bcdefghij', 'abcdefghijk', 'ijabcdefgh', 'abcdeffghij', 'abcdefghijj', 'jihgfedcba', 'abcdefghijkk', 'abcdefghijjj']) == 13\n assert candidate(allowed = \"abcdef\",words = ['abc', 'def', 'abcdef', 'abcd', 'defg', 'fedcba', 'aabbccddeeff', 'zzzzz']) == 6\n assert candidate(allowed = \"abcdefghij\",words = ['abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'abcdefghijk', 'abcdefghijj', 'abcdefghiij', 'abcdefghhij', 'abcdefghiiij', 'abcdefghijjj', 'abcdefghiiijj', 'abcdefghijjjj', 'abcdefghiiijjj', 'abcdefghijjjjj', 'abcdefghijjjjjj', 'abcdefghijjjjjjj', 'abcdefghijjjjjjjj', 'abcdefghijjjjjjjjj', 'abcdefghijjjjjjjjjj', 'abcdefghijjjjjjjjjjj', 'abcdefghijjjjjjjjjjjj', 'abcdefghijjjjjjjjjjjjj']) == 27\n assert candidate(allowed = \"abcdefg\",words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgi', 'abcdefgh', 'abcdefgabcdefg']) == 8\n assert candidate(allowed = \"pqrstuvw\",words = ['pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'pqrsrstuvw', 'uvws', 'uvwpqr', 'rstuvwq', 'pqrstuvwz', 'uvwstu', 'qrpstu', 'vwstupqr']) == 12\n assert candidate(allowed = \"pqrst\",words = ['p', 'q', 'r', 's', 't', 'pq', 'qr', 'rs', 'st', 'pqrs', 'qrst', 'pqrst', 'pqrs', 'pqst', 'prst', 'qrstu', 'pqrstv']) == 15\n assert candidate(allowed = \"tuvwxy\",words = ['tu', 'tv', 'tw', 'tx', 'ty', 'tvwxy', 'uwxyt', 'wxtyv', 'xytuw', 'tuvxy', 'wxytv', 'xyzut', 'ytuvwx', 'uvxtyw', 'tuvwxyuvwx', 'txyuvw', 'ytxwuv', 'utxwvy', 'wxuytv', 'tvxyw', 'tuvwxytvwx', 'tuvwxytuvwxy']) == 21\n assert candidate(allowed = \"lmnopq\",words = ['lmn', 'opq', 'lmnop', 'lmnopq', 'pqonm', 'qlmnp', 'pqlno', 'opqmn', 'nopql', 'mnopq', 'lmnopqrr', 'plmqon', 'opqlnm', 'qponml', 'mnopql']) == 14\n assert candidate(allowed = \"xyz\",words = ['xx', 'yy', 'zz', 'xy', 'yz', 'zx', 'xyz', 'zxy', 'yxz']) == 9\n assert candidate(allowed = \"xyz\",words = ['xzy', 'zyx', 'zyzx', 'xxxyyyzzz', 'xzyxzyxzy']) == 5\n assert candidate(allowed = \"mnopqrstuvwxyz\",words = ['mnopqrstuvwxyz', 'mnopqrstuvwxy', 'mnopqrstuvwx', 'mnopqrstuvw', 'mnopqrstu', 'mnopqrst', 'mnopqrs', 'mnopqr', 'mnopq', 'mnop', 'mno', 'mn', 'm', 'nopqrstuvwxyz', 'opqrstuvwxy', 'pqrstuvwx', 'qrstuvw', 'rstuv', 'stuv', 'tuv', 'uv', 'v', 'mnopqrstuvwxyza', 'nopqrstuvwxyzb', 'mnopqrstuvwxc', 'mnopqrstuvxd', 'mnopqrstvxe', 'mnopqrsvxf', 'mnopqrvxg', 'mnopqruxh', 'mnopquxi', 'mnopqxi', 'mnopxi', 'mnoxi', 'moxi', 'moxi', 'oxi', 'oxi', 'oxiz', 'mnoxyz', 'mnopxyz', 'mnopqxyz', 'mnopqrxyz', 'mnopqrstxyz', 'mnopqrstuxyz', 'mnopqrstuvxyz', 'mnopqrstuvwxyz', 'mnopqrstuvwxyzabc', 'mnopqrstuvwxyzabcd', 'mnopqrstuvwxyzabcde', 'mnopqrstuvwxyzabcdef', 'mnopqrstuvwxyzabcdefg']) == 30\n"}, "metadata": {"canonical_parameter_names": ["allowed", "words"], "leetcode_dataset_entry_point": "Solution().countConsistentStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countConsistentStrings(self, allowed: str, words: List[str]) -> int:", "container": "Solution", "callable": "countConsistentStrings", "parameters": [{"name": "allowed", "type": "str"}, {"name": "words", "type": "List[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1685, "task_id": "sum-of-absolute-differences-in-a-sorted-array", "difficulty": "Medium", "problem_description": "You are given an integer array nums sorted in non-decreasing order.\nBuild and return an integer array result with the same length as nums such that result[i] is equal to the summation of absolute differences between nums[i] and all the other elements in the array.\nIn other words, result[i] is equal to sum(|nums[i]-nums[j]|) where 0 <= j < nums.length and j != i (0-indexed).\n \nExample 1:\n\nInput: nums = [2,3,5]\nOutput: [4,3,5]\nExplanation: Assuming the arrays are 0-indexed, then\nresult[0] = |2-2| + |2-3| + |2-5| = 0 + 1 + 3 = 4,\nresult[1] = |3-2| + |3-3| + |3-5| = 1 + 0 + 2 = 3,\nresult[2] = |5-2| + |5-3| + |5-5| = 3 + 2 + 0 = 5.\n\nExample 2:\n\nInput: nums = [1,4,6,8,10]\nOutput: [24,15,13,15,21]\n\n \nConstraints:\n\n2 <= nums.length <= 105\n1 <= nums[i] <= nums[i + 1] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [100, 200, 300, 400, 500]) == [1000, 700, 600, 700, 1000]\n assert candidate(nums = [1, 1, 1, 1]) == [0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 4, 6, 8, 10]) == [24, 15, 13, 15, 21]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(nums = [2, 3, 5]) == [4, 3, 5]\n assert candidate(nums = [1, 100, 1000, 10000, 100000]) == [111096, 110799, 109899, 118899, 388899]\n assert candidate(nums = [1, 2, 3, 100, 101, 102, 103, 104, 105, 106]) == [717, 709, 703, 315, 313, 313, 315, 319, 325, 333]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000]) == [1111104, 1111059, 1110789, 1109889, 1118889, 1388889, 5888889]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 10, 10, 15, 15, 15, 20, 20, 20, 20]) == [100, 100, 100, 70, 70, 60, 60, 60, 80, 80, 80, 80]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == [19000, 17200, 15600, 14200, 13000, 12000, 11200, 10600, 10200, 10000, 10000, 10200, 10600, 11200, 12000, 13000, 14200, 15600, 17200, 19000]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [1111111101, 1111111029, 1111110489, 1111106889, 1111088889, 1111088889, 1112888889, 1148888889, 1688888889, 8888888889]\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == [441, 369, 309, 269, 249, 249, 269, 309, 369, 449]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [45000, 37000, 31000, 27000, 25000, 25000, 27000, 31000, 37000, 45000]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [950, 860, 780, 710, 650, 600, 560, 530, 510, 500, 500, 510, 530, 560, 600, 650, 710, 780, 860, 950]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == [570, 516, 468, 426, 390, 360, 336, 318, 306, 300, 300, 306, 318, 336, 360, 390, 426, 468, 516, 570]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [135, 117, 101, 87, 75, 65, 57, 51, 47, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45]\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, 10, 10, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == [137, 137, 137, 123, 123, 113, 105, 99, 95, 93, 93, 95, 99, 105, 113, 123, 135, 149, 165, 183]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [380, 344, 312, 284, 260, 240, 224, 212, 204, 200, 200, 204, 212, 224, 240, 260, 284, 312, 344, 380]\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101]) == [816, 726, 648, 582, 528, 486, 456, 438, 432, 438, 456, 486, 528, 582, 648, 726, 816]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == [30, 30, 30, 30, 30, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [1900, 1720, 1560, 1420, 1300, 1200, 1120, 1060, 1020, 1000, 1000, 1020, 1060, 1120, 1200, 1300, 1420, 1560, 1720, 1900]\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [210, 194, 176, 160, 150, 150, 164, 196, 250, 330]\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [5490, 4599, 3899, 3399, 3099, 2999, 3099, 3399, 3899, 4599, 5499]\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [210, 194, 176, 160, 150, 150, 164, 196, 250, 330]\n assert candidate(nums = [3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 9, 9, 9, 9, 11, 11, 11, 11]) == [80, 80, 80, 80, 56, 56, 56, 56, 48, 48, 48, 48, 56, 56, 56, 56, 80, 80, 80, 80]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == [32752, 32739, 32717, 32681, 32625, 32545, 32449, 32385, 32513, 33281, 35841, 43009, 61441, 106497, 212993]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [20, 20, 14, 14, 12, 12, 14, 14, 20, 20]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [210, 184, 162, 144, 130, 120, 114, 112, 114, 120, 130, 144, 162, 184, 210]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [210, 184, 162, 144, 130, 120, 114, 112, 114, 120, 130, 144, 162, 184, 210]\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]) == [2567, 2554, 2543, 2525, 2504, 2479, 2455, 2442, 2463, 2565, 2840, 3463, 4759, 7322, 12223]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [450, 370, 310, 270, 250, 250, 270, 310, 370, 450]\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == [2850, 2796, 2716, 2618, 2510, 2400, 2296, 2206, 2138, 2100, 2100, 2146, 2246, 2408, 2640, 2950, 3346, 3836, 4428, 5130]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7]) == [15, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == [130, 102, 102, 78, 78, 78, 60, 60, 60, 60, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 80, 80, 80, 80, 80]\n assert candidate(nums = [5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7]) == [12, 12, 12, 12, 8, 8, 8, 8, 12, 12, 12, 12]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [90, 74, 62, 54, 50, 50, 54, 62, 74, 90]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000]) == [111105, 111069, 110889, 110889, 128889, 488889]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5]) == [24, 15, 15, 10, 10, 10, 11, 11, 11, 11, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [2026, 2010, 1986, 1954, 1922, 1922, 2050, 2562, 4098, 8194]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [1900, 1720, 1560, 1420, 1300, 1200, 1120, 1060, 1020, 1000, 1000, 1020, 1060, 1120, 1200, 1300, 1420, 1560, 1720, 1900]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [380, 344, 312, 284, 260, 240, 224, 212, 204, 200, 200, 204, 212, 224, 240, 260, 284, 312, 344, 380]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [300, 277, 256, 237, 220, 205, 192, 181, 172, 165, 160, 157, 156, 157, 160, 165, 172, 181, 192, 205, 220, 237, 256, 277, 300]\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 5, 6]) == [24, 17, 17, 14, 13, 14, 14, 14, 21]\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [540, 459, 389, 339, 309, 299, 309, 339, 389, 459, 549]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == [2175, 2035, 1905, 1785, 1675, 1575, 1485, 1405, 1335, 1275, 1225, 1185, 1155, 1135, 1125, 1125, 1135, 1155, 1185, 1225, 1275, 1335, 1405, 1485, 1575, 1675, 1785, 1905, 2035, 2175]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == [15, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [20, 12, 12, 8, 8, 8, 10, 10, 10, 10]\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011, 5012, 5013, 5014, 5015, 5016, 5017, 5018, 5019]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [275, 230, 195, 170, 155, 150, 155, 170, 195, 230, 275]\n assert candidate(nums = [1, 2, 5, 7, 9, 11, 13, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49]) == [437, 419, 371, 343, 319, 299, 283, 265, 257, 253, 253, 259, 271, 289, 313, 343, 379, 421, 469, 523]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [1050, 920, 810, 720, 650, 600, 570, 560, 570, 600, 650, 720, 810, 920, 1050]\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [540, 459, 389, 339, 309, 299, 309, 339, 389, 459, 549]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [45000, 37000, 31000, 27000, 25000, 25000, 27000, 31000, 37000, 45000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [1013, 1005, 993, 977, 961, 961, 1025, 1281, 2049, 4097]\n assert candidate(nums = [1, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == [549990, 459999, 389999, 339999, 309999, 299999, 309999, 339999, 389999, 459999, 549999]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [105, 92, 81, 72, 65, 60, 57, 56, 57, 60, 65, 72, 81, 92, 105]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().getSumAbsoluteDifferences", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getSumAbsoluteDifferences(self, nums: List[int]) -> List[int]:", "container": "Solution", "callable": "getSumAbsoluteDifferences", "parameters": [{"name": "nums", "type": "List[int]"}], "return_type": "List[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1686, "task_id": "stone-game-vi", "difficulty": "Medium", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\nThere are n stones in a pile. On each player's turn, they can remove a stone from the pile and receive points based on the stone's value. Alice and Bob may value the stones differently.\nYou are given two integer arrays of length n, aliceValues and bobValues. Each aliceValues[i] and bobValues[i] represents how Alice and Bob, respectively, value the ith stone.\nThe winner is the person with the most points after all the stones are chosen. If both players have the same amount of points, the game results in a draw. Both players will play optimally. Both players know the other's values.\nDetermine the result of the game, and:\n\nIf Alice wins, return 1.\nIf Bob wins, return -1.\nIf the game results in a draw, return 0.\n\n \nExample 1:\n\nInput: aliceValues = [1,3], bobValues = [2,1]\nOutput: 1\nExplanation:\nIf Alice takes stone 1 (0-indexed) first, Alice will receive 3 points.\nBob can only choose stone 0, and will only receive 2 points.\nAlice wins.\n\nExample 2:\n\nInput: aliceValues = [1,2], bobValues = [3,1]\nOutput: 0\nExplanation:\nIf Alice takes stone 0, and Bob takes stone 1, they will both have 1 point.\nDraw.\n\nExample 3:\n\nInput: aliceValues = [2,4,3], bobValues = [1,6,7]\nOutput: -1\nExplanation:\nRegardless of how Alice plays, Bob will be able to have more points than Alice.\nFor example, if Alice takes stone 1, Bob can take stone 2, and Alice takes stone 0, Alice will have 6 points to Bob's 7.\nBob wins.\n\n \nConstraints:\n\nn == aliceValues.length == bobValues.length\n1 <= n <= 105\n1 <= aliceValues[i], bobValues[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(aliceValues = [1, 2],bobValues = [3, 1]) == 0\n assert candidate(aliceValues = [1, 2, 3, 4, 5],bobValues = [5, 4, 3, 2, 1]) == 1\n assert candidate(aliceValues = [9, 9, 9, 9, 9],bobValues = [1, 1, 1, 1, 1]) == 1\n assert candidate(aliceValues = [5, 3, 1, 4],bobValues = [4, 1, 2, 3]) == 1\n assert candidate(aliceValues = [10, 20, 30],bobValues = [30, 20, 10]) == 1\n assert candidate(aliceValues = [1, 3],bobValues = [2, 1]) == 1\n assert candidate(aliceValues = [2, 2, 2, 2, 2],bobValues = [3, 3, 3, 3, 3]) == 0\n assert candidate(aliceValues = [1, 1, 1, 1],bobValues = [1, 1, 1, 1]) == 0\n assert candidate(aliceValues = [1, 1, 1, 1, 1],bobValues = [9, 9, 9, 9, 9]) == -1\n assert candidate(aliceValues = [7, 8, 9],bobValues = [9, 8, 7]) == 1\n assert candidate(aliceValues = [2, 4, 3],bobValues = [1, 6, 7]) == -1\n assert candidate(aliceValues = [10, 10, 10, 10],bobValues = [10, 10, 10, 10]) == 0\n assert candidate(aliceValues = [5, 3, 8, 2],bobValues = [4, 1, 7, 3]) == 1\n assert candidate(aliceValues = [100, 100, 100],bobValues = [100, 100, 100]) == 1\n assert candidate(aliceValues = [99, 98, 97],bobValues = [1, 2, 3]) == 1\n assert candidate(aliceValues = [100, 1, 1, 1],bobValues = [1, 100, 1, 1]) == 0\n assert candidate(aliceValues = [30, 20, 10],bobValues = [10, 20, 30]) == 1\n assert candidate(aliceValues = [5, 5, 5, 5],bobValues = [5, 5, 5, 5]) == 0\n assert candidate(aliceValues = [1, 1, 1, 1, 1],bobValues = [1, 1, 1, 1, 1]) == 1\n assert candidate(aliceValues = [99, 1, 99, 1, 99, 1],bobValues = [1, 99, 1, 99, 1, 99]) == 0\n assert candidate(aliceValues = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],bobValues = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 0\n assert candidate(aliceValues = [80, 70, 60, 50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50, 60, 70, 80]) == 0\n assert candidate(aliceValues = [99, 50, 25, 10, 5],bobValues = [1, 1, 1, 1, 1]) == 1\n assert candidate(aliceValues = [100, 50, 25, 12, 6],bobValues = [5, 20, 40, 60, 80]) == 1\n assert candidate(aliceValues = [100, 1, 100, 1, 100],bobValues = [1, 100, 1, 100, 1]) == 1\n assert candidate(aliceValues = [5, 8, 7, 12, 9],bobValues = [4, 6, 5, 10, 7]) == 1\n assert candidate(aliceValues = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],bobValues = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],bobValues = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 1\n assert candidate(aliceValues = [3, 2, 3, 4, 5],bobValues = [5, 4, 3, 2, 3]) == 1\n assert candidate(aliceValues = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],bobValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(aliceValues = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1],bobValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == 0\n assert candidate(aliceValues = [50, 30, 20],bobValues = [1, 20, 30]) == 1\n assert candidate(aliceValues = [100, 99, 98, 97, 96],bobValues = [95, 94, 93, 92, 91]) == 1\n assert candidate(aliceValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bobValues = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(aliceValues = [5, 5, 5, 5],bobValues = [6, 6, 6, 6]) == -1\n assert candidate(aliceValues = [1, 5, 9, 13, 17],bobValues = [16, 12, 8, 4, 0]) == 1\n assert candidate(aliceValues = [23, 45, 67, 89, 10],bobValues = [10, 89, 67, 45, 23]) == 1\n assert candidate(aliceValues = [23, 45, 67, 89, 12],bobValues = [12, 89, 67, 45, 23]) == 1\n assert candidate(aliceValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bobValues = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(aliceValues = [50, 30, 20, 10, 1],bobValues = [10, 20, 30, 40, 50]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],bobValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(aliceValues = [99, 98, 97, 96, 95],bobValues = [1, 2, 3, 4, 5]) == 1\n assert candidate(aliceValues = [50, 50, 50, 50, 50],bobValues = [50, 50, 50, 50, 50]) == 1\n assert candidate(aliceValues = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],bobValues = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == 0\n assert candidate(aliceValues = [5, 2, 3, 3, 4],bobValues = [4, 3, 2, 3, 5]) == 1\n assert candidate(aliceValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],bobValues = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n assert candidate(aliceValues = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],bobValues = [75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 1\n assert candidate(aliceValues = [100, 50, 25, 10, 5],bobValues = [5, 10, 25, 50, 100]) == 1\n assert candidate(aliceValues = [30, 20, 10, 50, 40, 60, 70],bobValues = [70, 60, 50, 40, 30, 20, 10]) == 1\n assert candidate(aliceValues = [50, 50, 50],bobValues = [100, 100, 100]) == 0\n assert candidate(aliceValues = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5],bobValues = [5, 95, 4, 96, 3, 97, 2, 98, 1, 99]) == 0\n assert candidate(aliceValues = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86],bobValues = [86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 1\n assert candidate(aliceValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bobValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(aliceValues = [100, 100, 100, 100, 100],bobValues = [99, 99, 99, 99, 99]) == 1\n assert candidate(aliceValues = [80, 20, 60, 40, 100, 50, 70],bobValues = [70, 50, 100, 60, 20, 40, 80]) == 1\n assert candidate(aliceValues = [7, 14, 21, 28, 35, 42],bobValues = [6, 12, 18, 24, 30, 36]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10],bobValues = [20, 20, 20, 20]) == -1\n assert candidate(aliceValues = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(aliceValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bobValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(aliceValues = [100, 90, 80, 70, 60],bobValues = [60, 70, 80, 90, 100]) == 1\n assert candidate(aliceValues = [100, 100, 1, 1, 1],bobValues = [1, 1, 100, 100, 100]) == 1\n assert candidate(aliceValues = [2, 4, 6, 8, 10],bobValues = [1, 3, 5, 7, 9]) == 1\n assert candidate(aliceValues = [5, 15, 25, 35, 45, 55],bobValues = [55, 45, 35, 25, 15, 5]) == 0\n assert candidate(aliceValues = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],bobValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(aliceValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],bobValues = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(aliceValues = [100, 100, 100, 100, 100],bobValues = [50, 50, 50, 50, 50]) == 1\n assert candidate(aliceValues = [90, 20, 30, 10, 50],bobValues = [50, 90, 10, 30, 20]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10, 10, 10],bobValues = [9, 9, 9, 9, 9, 9]) == 1\n assert candidate(aliceValues = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],bobValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],bobValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(aliceValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],bobValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(aliceValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],bobValues = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(aliceValues = [100, 1, 2, 3, 4],bobValues = [1, 100, 2, 3, 4]) == 1\n assert candidate(aliceValues = [100, 1, 50, 25, 75],bobValues = [90, 99, 5, 20, 70]) == 1\n assert candidate(aliceValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bobValues = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(aliceValues = [90, 90, 90, 90, 90, 90, 90, 90, 90, 90],bobValues = [91, 91, 91, 91, 91, 91, 91, 91, 91, 91]) == -1\n assert candidate(aliceValues = [2, 3, 5, 7, 11],bobValues = [11, 7, 5, 3, 2]) == 1\n assert candidate(aliceValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],bobValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(aliceValues = [30, 30, 30, 30, 30],bobValues = [30, 30, 30, 30, 30]) == 1\n assert candidate(aliceValues = [30, 20, 10],bobValues = [10, 20, 30]) == 1\n assert candidate(aliceValues = [10, 1, 10, 1, 10, 1, 10, 1],bobValues = [1, 10, 1, 10, 1, 10, 1, 10]) == 0\n assert candidate(aliceValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bobValues = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(aliceValues = [1, 3, 5, 7, 9, 11, 13],bobValues = [2, 4, 6, 8, 10, 12, 14]) == 1\n assert candidate(aliceValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bobValues = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(aliceValues = [10, 20, 30, 40, 50],bobValues = [50, 40, 30, 20, 10]) == 1\n assert candidate(aliceValues = [50, 50, 50, 50, 50],bobValues = [40, 40, 40, 40, 60]) == 1\n assert candidate(aliceValues = [50, 40, 30, 20, 10, 10, 20, 30, 40, 50],bobValues = [10, 20, 30, 40, 50, 50, 40, 30, 20, 10]) == 0\n assert candidate(aliceValues = [99, 1, 2, 3, 4],bobValues = [4, 3, 2, 1, 99]) == 1\n assert candidate(aliceValues = [50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50]) == 1\n assert candidate(aliceValues = [10, 30, 20, 50, 40],bobValues = [40, 20, 30, 10, 50]) == 1\n assert candidate(aliceValues = [50, 50, 50, 50, 50],bobValues = [50, 50, 50, 50, 51]) == 1\n assert candidate(aliceValues = [5, 15, 25, 35, 45, 55, 65],bobValues = [65, 55, 45, 35, 25, 15, 5]) == 1\n assert candidate(aliceValues = [10, 20, 30, 40, 50],bobValues = [50, 40, 30, 20, 10]) == 1\n assert candidate(aliceValues = [50, 25, 50, 75, 25],bobValues = [75, 50, 25, 25, 50]) == 1\n assert candidate(aliceValues = [1, 1, 1, 2, 2, 2, 3, 3, 3],bobValues = [3, 3, 3, 2, 2, 2, 1, 1, 1]) == 1\n assert candidate(aliceValues = [100, 1, 1, 1, 1],bobValues = [1, 1, 1, 1, 100]) == 1\n assert candidate(aliceValues = [90, 80, 70, 60, 50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 1\n assert candidate(aliceValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],bobValues = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(aliceValues = [90, 10, 90, 10, 90],bobValues = [10, 90, 10, 90, 10]) == 1\n assert candidate(aliceValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],bobValues = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(aliceValues = [42, 23, 17, 5, 99],bobValues = [99, 5, 17, 23, 42]) == 1\n assert candidate(aliceValues = [100, 50, 1, 1, 1, 1, 1, 1, 1, 1],bobValues = [1, 1, 99, 99, 99, 99, 99, 99, 99, 99]) == -1\n assert candidate(aliceValues = [30, 40, 50, 60, 70, 80, 90, 100, 110, 120],bobValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(aliceValues = [70, 60, 50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50, 60, 70]) == 1\n assert candidate(aliceValues = [90, 10, 20, 30, 40, 50, 60, 70, 80],bobValues = [10, 90, 80, 70, 60, 50, 40, 30, 20]) == 1\n assert candidate(aliceValues = [100],bobValues = [1]) == 1\n"}, "metadata": {"canonical_parameter_names": ["aliceValues", "bobValues"], "leetcode_dataset_entry_point": "Solution().stoneGameVI", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def stoneGameVI(self, aliceValues: list[int], bobValues: list[int]) -> int:", "container": "Solution", "callable": "stoneGameVI", "parameters": [{"name": "aliceValues", "type": "list[int]"}, {"name": "bobValues", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1687, "task_id": "delivering-boxes-from-storage-to-ports", "difficulty": "Hard", "problem_description": "You have the task of delivering some boxes from storage to their ports using only one ship. However, this ship has a limit on the number of boxes and the total weight that it can carry.\nYou are given an array boxes, where boxes[i] = [ports​​i​, weighti], and three integers portsCount, maxBoxes, and maxWeight.\n\nports​​i is the port where you need to deliver the ith box and weightsi is the weight of the ith box.\nportsCount is the number of ports.\nmaxBoxes and maxWeight are the respective box and weight limits of the ship.\n\nThe boxes need to be delivered in the order they are given. The ship will follow these steps:\n\nThe ship will take some number of boxes from the boxes queue, not violating the maxBoxes and maxWeight constraints.\nFor each loaded box in order, the ship will make a trip to the port the box needs to be delivered to and deliver it. If the ship is already at the correct port, no trip is needed, and the box can immediately be delivered.\nThe ship then makes a return trip to storage to take more boxes from the queue.\n\nThe ship must end at storage after all the boxes have been delivered.\nReturn the minimum number of trips the ship needs to make to deliver all boxes to their respective ports.\n \nExample 1:\n\nInput: boxes = [[1,1],[2,1],[1,1]], portsCount = 2, maxBoxes = 3, maxWeight = 3\nOutput: 4\nExplanation: The optimal strategy is as follows: \n- The ship takes all the boxes in the queue, goes to port 1, then port 2, then port 1 again, then returns to storage. 4 trips.\nSo the total number of trips is 4.\nNote that the first and third boxes cannot be delivered together because the boxes need to be delivered in order (i.e. the second box needs to be delivered at port 2 before the third box).\n\nExample 2:\n\nInput: boxes = [[1,2],[3,3],[3,1],[3,1],[2,4]], portsCount = 3, maxBoxes = 3, maxWeight = 6\nOutput: 6\nExplanation: The optimal strategy is as follows: \n- The ship takes the first box, goes to port 1, then returns to storage. 2 trips.\n- The ship takes the second, third and fourth boxes, goes to port 3, then returns to storage. 2 trips.\n- The ship takes the fifth box, goes to port 2, then returns to storage. 2 trips.\nSo the total number of trips is 2 + 2 + 2 = 6.\n\nExample 3:\n\nInput: boxes = [[1,4],[1,2],[2,1],[2,1],[3,2],[3,4]], portsCount = 3, maxBoxes = 6, maxWeight = 7\nOutput: 6\nExplanation: The optimal strategy is as follows:\n- The ship takes the first and second boxes, goes to port 1, then returns to storage. 2 trips.\n- The ship takes the third and fourth boxes, goes to port 2, then returns to storage. 2 trips.\n- The ship takes the fifth and sixth boxes, goes to port 3, then returns to storage. 2 trips.\nSo the total number of trips is 2 + 2 + 2 = 6.\n\n \nConstraints:\n\n1 <= boxes.length <= 105\n1 <= portsCount, maxBoxes, maxWeight <= 105\n1 <= ports​​i <= portsCount\n1 <= weightsi <= maxWeight\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 5,maxWeight = 5) == 4\n assert candidate(boxes = [[2, 2], [2, 2], [3, 3], [3, 3], [4, 4], [4, 4]],portsCount = 4,maxBoxes = 2,maxWeight = 4) == 10\n assert candidate(boxes = [[1, 2], [2, 2], [1, 2], [2, 2], [1, 2]],portsCount = 2,maxBoxes = 3,maxWeight = 6) == 7\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],portsCount = 5,maxBoxes = 1,maxWeight = 5) == 10\n assert candidate(boxes = [[1, 5], [1, 5], [1, 5], [2, 5], [2, 5], [2, 5]],portsCount = 2,maxBoxes = 2,maxWeight = 10) == 7\n assert candidate(boxes = [[1, 5], [2, 5], [1, 5], [2, 5], [1, 5], [2, 5]],portsCount = 2,maxBoxes = 2,maxWeight = 10) == 9\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],portsCount = 15,maxBoxes = 5,maxWeight = 15) == 18\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 12\n assert candidate(boxes = [[1, 2], [2, 2], [1, 2], [2, 2], [1, 2], [2, 2], [1, 2], [2, 2], [1, 2], [2, 2]],portsCount = 2,maxBoxes = 4,maxWeight = 10) == 13\n assert candidate(boxes = [[1, 1], [2, 1], [1, 1]],portsCount = 2,maxBoxes = 3,maxWeight = 3) == 4\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1]],portsCount = 5,maxBoxes = 5,maxWeight = 5) == 6\n assert candidate(boxes = [[1, 100], [2, 100], [3, 100], [4, 100], [5, 100]],portsCount = 5,maxBoxes = 5,maxWeight = 500) == 6\n assert candidate(boxes = [[2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3]],portsCount = 5,maxBoxes = 3,maxWeight = 10) == 10\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 3,maxWeight = 30) == 7\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],portsCount = 9,maxBoxes = 3,maxWeight = 15) == 13\n assert candidate(boxes = [[1, 5], [2, 3], [3, 2], [2, 1], [1, 4]],portsCount = 3,maxBoxes = 5,maxWeight = 15) == 6\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 2,maxWeight = 2) == 6\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 3,maxWeight = 5) == 4\n assert candidate(boxes = [[1, 4], [1, 2], [2, 1], [2, 1], [3, 2], [3, 4]],portsCount = 3,maxBoxes = 6,maxWeight = 7) == 6\n assert candidate(boxes = [[1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3], [4, 4], [4, 4], [5, 5], [5, 5]],portsCount = 5,maxBoxes = 3,maxWeight = 5) == 16\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],portsCount = 10,maxBoxes = 10,maxWeight = 55) == 11\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10]],portsCount = 3,maxBoxes = 2,maxWeight = 20) == 5\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],portsCount = 5,maxBoxes = 2,maxWeight = 10) == 8\n assert candidate(boxes = [[1, 3], [1, 3], [1, 3], [1, 3], [1, 3]],portsCount = 1,maxBoxes = 3,maxWeight = 9) == 4\n assert candidate(boxes = [[1, 3], [2, 5], [3, 7], [4, 9]],portsCount = 4,maxBoxes = 2,maxWeight = 12) == 7\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],portsCount = 5,maxBoxes = 2,maxWeight = 5) == 9\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 5,maxWeight = 50) == 6\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 5,maxWeight = 25) == 8\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],portsCount = 5,maxBoxes = 2,maxWeight = 5) == 10\n assert candidate(boxes = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 6\n assert candidate(boxes = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2]],portsCount = 5,maxBoxes = 2,maxWeight = 4) == 8\n assert candidate(boxes = [[1, 5], [2, 2], [3, 3], [1, 1]],portsCount = 3,maxBoxes = 3,maxWeight = 11) == 6\n assert candidate(boxes = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3]],portsCount = 10,maxBoxes = 10,maxWeight = 30) == 11\n assert candidate(boxes = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 6\n assert candidate(boxes = [[1, 3], [2, 2], [3, 1]],portsCount = 3,maxBoxes = 5,maxWeight = 6) == 4\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],portsCount = 10,maxBoxes = 1,maxWeight = 1) == 20\n assert candidate(boxes = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 12\n assert candidate(boxes = [[1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3], [4, 4], [4, 4], [5, 5], [5, 5]],portsCount = 5,maxBoxes = 2,maxWeight = 4) == 0\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 5,maxWeight = 10) == 4\n assert candidate(boxes = [[1, 3], [2, 2], [1, 4], [2, 2], [3, 1]],portsCount = 3,maxBoxes = 3,maxWeight = 10) == 7\n assert candidate(boxes = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5]],portsCount = 1,maxBoxes = 5,maxWeight = 25) == 2\n assert candidate(boxes = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],portsCount = 10,maxBoxes = 5,maxWeight = 10) == 12\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 5,maxWeight = 30) == 7\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5]],portsCount = 4,maxBoxes = 4,maxWeight = 20) == 5\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [1, 10], [2, 10], [3, 10]],portsCount = 3,maxBoxes = 3,maxWeight = 20) == 9\n assert candidate(boxes = [[1, 5], [1, 5], [2, 5], [2, 5], [3, 5], [3, 5]],portsCount = 3,maxBoxes = 3,maxWeight = 15) == 6\n assert candidate(boxes = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],portsCount = 5,maxBoxes = 2,maxWeight = 100) == 8\n assert candidate(boxes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],portsCount = 1,maxBoxes = 5,maxWeight = 15) == 2\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 5,maxWeight = 5) == 2\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 5,maxWeight = 40) == 7\n assert candidate(boxes = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5]],portsCount = 10,maxBoxes = 5,maxWeight = 15) == 2\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],portsCount = 7,maxBoxes = 4,maxWeight = 8) == 12\n assert candidate(boxes = [[1, 3], [1, 3], [2, 3], [2, 3], [3, 3], [3, 3]],portsCount = 3,maxBoxes = 4,maxWeight = 9) == 6\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 1,maxWeight = 10) == 10\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 6\n assert candidate(boxes = [[2, 3], [2, 3], [3, 2], [3, 2], [3, 2]],portsCount = 3,maxBoxes = 2,maxWeight = 5) == 7\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],portsCount = 5,maxBoxes = 10,maxWeight = 50) == 11\n assert candidate(boxes = [[1, 5], [2, 2], [3, 1], [4, 4], [5, 3]],portsCount = 5,maxBoxes = 2,maxWeight = 10) == 8\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [2, 10], [1, 10]],portsCount = 3,maxBoxes = 2,maxWeight = 20) == 8\n assert candidate(boxes = [[1, 3], [2, 3], [3, 3], [2, 3], [1, 3]],portsCount = 3,maxBoxes = 2,maxWeight = 9) == 8\n assert candidate(boxes = [[1, 2], [3, 3], [3, 1], [3, 1], [2, 4]],portsCount = 3,maxBoxes = 3,maxWeight = 6) == 6\n assert candidate(boxes = [[1, 5], [2, 5], [1, 5], [2, 5], [1, 5], [2, 5], [1, 5], [2, 5], [1, 5], [2, 5]],portsCount = 2,maxBoxes = 5,maxWeight = 25) == 12\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 2,maxWeight = 20) == 8\n assert candidate(boxes = [[1, 5], [2, 3], [3, 2], [4, 1], [2, 2]],portsCount = 4,maxBoxes = 5,maxWeight = 10) == 7\n assert candidate(boxes = [[1, 3], [2, 2], [3, 2], [4, 2], [5, 2]],portsCount = 5,maxBoxes = 3,maxWeight = 5) == 8\n assert candidate(boxes = [[1, 5], [2, 5], [1, 5], [2, 5], [1, 5]],portsCount = 2,maxBoxes = 3,maxWeight = 15) == 7\n assert candidate(boxes = [[1, 5], [2, 6], [3, 7]],portsCount = 3,maxBoxes = 2,maxWeight = 12) == 5\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],portsCount = 10,maxBoxes = 10,maxWeight = 10) == 11\n assert candidate(boxes = [[2, 5], [2, 4], [5, 1], [5, 1], [5, 1], [1, 5], [1, 5], [1, 5], [1, 5], [5, 1]],portsCount = 5,maxBoxes = 5,maxWeight = 10) == 10\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 2,maxWeight = 2) == 6\n assert candidate(boxes = [[1, 5], [2, 3], [3, 2], [4, 1], [2, 2]],portsCount = 4,maxBoxes = 4,maxWeight = 10) == 7\n assert candidate(boxes = [[1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3]],portsCount = 3,maxBoxes = 3,maxWeight = 10) == 6\n assert candidate(boxes = [[1, 10], [1, 10], [1, 10], [1, 10]],portsCount = 1,maxBoxes = 2,maxWeight = 20) == 4\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],portsCount = 10,maxBoxes = 5,maxWeight = 5) == 12\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],portsCount = 5,maxBoxes = 1,maxWeight = 5) == 10\n assert candidate(boxes = [[2, 10], [2, 10], [3, 10], [3, 10]],portsCount = 3,maxBoxes = 3,maxWeight = 20) == 4\n"}, "metadata": {"canonical_parameter_names": ["boxes", "portsCount", "maxBoxes", "maxWeight"], "leetcode_dataset_entry_point": "Solution().boxDelivering", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def boxDelivering(self, boxes: list[list[int]], portsCount: int, maxBoxes: int, maxWeight: int) -> int:", "container": "Solution", "callable": "boxDelivering", "parameters": [{"name": "boxes", "type": "list[list[int]]"}, {"name": "portsCount", "type": "int"}, {"name": "maxBoxes", "type": "int"}, {"name": "maxWeight", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1688, "task_id": "count-of-matches-in-tournament", "difficulty": "Easy", "problem_description": "You are given an integer n, the number of teams in a tournament that has strange rules:\n\nIf the current number of teams is even, each team gets paired with another team. A total of n / 2 matches are played, and n / 2 teams advance to the next round.\nIf the current number of teams is odd, one team randomly advances in the tournament, and the rest gets paired. A total of (n - 1) / 2 matches are played, and (n - 1) / 2 + 1 teams advance to the next round.\n\nReturn the number of matches played in the tournament until a winner is decided.\n \nExample 1:\n\nInput: n = 7\nOutput: 6\nExplanation: Details of the tournament: \n- 1st Round: Teams = 7, Matches = 3, and 4 teams advance.\n- 2nd Round: Teams = 4, Matches = 2, and 2 teams advance.\n- 3rd Round: Teams = 2, Matches = 1, and 1 team is declared the winner.\nTotal number of matches = 3 + 2 + 1 = 6.\n\nExample 2:\n\nInput: n = 14\nOutput: 13\nExplanation: Details of the tournament:\n- 1st Round: Teams = 14, Matches = 7, and 7 teams advance.\n- 2nd Round: Teams = 7, Matches = 3, and 4 teams advance.\n- 3rd Round: Teams = 4, Matches = 2, and 2 teams advance.\n- 4th Round: Teams = 2, Matches = 1, and 1 team is declared the winner.\nTotal number of matches = 7 + 3 + 2 + 1 = 13.\n\n \nConstraints:\n\n1 <= n <= 200\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 2\n assert candidate(n = 100) == 99\n assert candidate(n = 14) == 13\n assert candidate(n = 200) == 199\n assert candidate(n = 17) == 16\n assert candidate(n = 2) == 1\n assert candidate(n = 199) == 198\n assert candidate(n = 1) == 0\n assert candidate(n = 7) == 6\n assert candidate(n = 13) == 12\n assert candidate(n = 97) == 96\n assert candidate(n = 63) == 62\n assert candidate(n = 29) == 28\n assert candidate(n = 45) == 44\n assert candidate(n = 135) == 134\n assert candidate(n = 183) == 182\n assert candidate(n = 49) == 48\n assert candidate(n = 130) == 129\n assert candidate(n = 163) == 162\n assert candidate(n = 111) == 110\n assert candidate(n = 10) == 9\n assert candidate(n = 197) == 196\n assert candidate(n = 50) == 49\n assert candidate(n = 157) == 156\n assert candidate(n = 5) == 4\n assert candidate(n = 123) == 122\n assert candidate(n = 59) == 58\n assert candidate(n = 87) == 86\n assert candidate(n = 173) == 172\n assert candidate(n = 4) == 3\n assert candidate(n = 99) == 98\n assert candidate(n = 16) == 15\n assert candidate(n = 177) == 176\n assert candidate(n = 64) == 63\n assert candidate(n = 33) == 32\n assert candidate(n = 143) == 142\n assert candidate(n = 98) == 97\n assert candidate(n = 73) == 72\n assert candidate(n = 133) == 132\n assert candidate(n = 175) == 174\n assert candidate(n = 128) == 127\n assert candidate(n = 101) == 100\n assert candidate(n = 181) == 180\n assert candidate(n = 8) == 7\n assert candidate(n = 131) == 130\n assert candidate(n = 27) == 26\n assert candidate(n = 169) == 168\n assert candidate(n = 32) == 31\n assert candidate(n = 149) == 148\n assert candidate(n = 127) == 126\n assert candidate(n = 81) == 80\n assert candidate(n = 150) == 149\n assert candidate(n = 151) == 150\n assert candidate(n = 198) == 197\n assert candidate(n = 11) == 10\n assert candidate(n = 15) == 14\n assert candidate(n = 189) == 188\n assert candidate(n = 85) == 84\n assert candidate(n = 31) == 30\n assert candidate(n = 25) == 24\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().numberOfMatches", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numberOfMatches(self, n: int) -> int:", "container": "Solution", "callable": "numberOfMatches", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1689, "task_id": "partitioning-into-minimum-number-of-deci-binary-numbers", "difficulty": "Medium", "problem_description": "A decimal number is called deci-binary if each of its digits is either 0 or 1 without any leading zeros. For example, 101 and 1100 are deci-binary, while 112 and 3001 are not.\nGiven a string n that represents a positive decimal integer, return the minimum number of positive deci-binary numbers needed so that they sum up to n.\n \nExample 1:\n\nInput: n = \"32\"\nOutput: 3\nExplanation: 10 + 11 + 11 = 32\n\nExample 2:\n\nInput: n = \"82734\"\nOutput: 8\n\nExample 3:\n\nInput: n = \"27346209830709182346\"\nOutput: 9\n\n \nConstraints:\n\n1 <= n.length <= 105\nn consists of only digits.\nn does not contain any leading zeros and represents a positive integer.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = \"9876543210\") == 9\n assert candidate(n = \"111\") == 1\n assert candidate(n = \"123456789\") == 9\n assert candidate(n = \"1\") == 1\n assert candidate(n = \"82734\") == 8\n assert candidate(n = \"32\") == 3\n assert candidate(n = \"11111\") == 1\n assert candidate(n = \"555555555\") == 5\n assert candidate(n = \"9\") == 9\n assert candidate(n = \"27346209830709182346\") == 9\n assert candidate(n = \"1000000000\") == 1\n assert candidate(n = \"55555\") == 5\n assert candidate(n = \"987654321\") == 9\n assert candidate(n = \"987654321098765432109876543210\") == 9\n assert candidate(n = \"1999199919991999199919991999199919991999199919991999\") == 9\n assert candidate(n = \"11111111112222222222333333333333444444444444555555555\") == 5\n assert candidate(n = \"111999888777666555444333222111\") == 9\n assert candidate(n = \"8888888888888888888888888888888888888888\") == 8\n assert candidate(n = \"87654321098765432109\") == 9\n assert candidate(n = \"999999999\") == 9\n assert candidate(n = \"11111111111111111111\") == 1\n assert candidate(n = \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111\") == 1\n assert candidate(n = \"999999999999999999999999999999\") == 9\n assert candidate(n = \"44444444444444444444444444444444444444444444444444\") == 4\n assert candidate(n = \"101010101010101010101010101010\") == 1\n assert candidate(n = \"5432105432105432105432105432105432105432105432105432\") == 5\n assert candidate(n = \"10000000000000000000\") == 1\n assert candidate(n = \"19191919191919191919\") == 9\n assert candidate(n = \"77777777777777777777777777777777777777777777777777\") == 7\n assert candidate(n = \"222222222222222222222222222222222222222222222222222\") == 2\n assert candidate(n = \"99999999999999999999\") == 9\n assert candidate(n = \"8456391728391657813265813265\") == 9\n assert candidate(n = \"9999999999\") == 9\n assert candidate(n = \"918273645091827364509182736450\") == 9\n assert candidate(n = \"12345678901234567890\") == 9\n assert candidate(n = \"9999111199991111999911119999111199991111999911119999\") == 9\n assert candidate(n = \"19191919191919191919191919191919191919191919191919191919191919191919191919191919\") == 9\n assert candidate(n = \"10000000000000000000000000000000000000000000\") == 1\n assert candidate(n = \"55555555555555555555\") == 5\n assert candidate(n = \"888888888888888888888888888888888888888888888888888\") == 8\n assert candidate(n = \"99999\") == 9\n assert candidate(n = \"1111111111\") == 1\n assert candidate(n = \"987654321012345678987654321\") == 9\n assert candidate(n = \"10101010101010101010101010101010\") == 1\n assert candidate(n = \"24681357924681357924\") == 9\n assert candidate(n = \"123456789876543210000000000000000000000000000000000\") == 9\n assert candidate(n = \"12345678987654321\") == 9\n assert candidate(n = \"10101010101010101010\") == 1\n assert candidate(n = \"111222333444555666777888999\") == 9\n assert candidate(n = \"18181818181818181818\") == 8\n assert candidate(n = \"13579135791357913579\") == 9\n assert candidate(n = \"101010101010101010101010101\") == 1\n assert candidate(n = \"100000000000000000000000000000\") == 1\n assert candidate(n = \"765432101023456765432101023456765432101023456765432\") == 7\n assert candidate(n = \"8765432109876543210987654321\") == 9\n assert candidate(n = \"918273645432187654321\") == 9\n assert candidate(n = \"2468135791113151719\") == 9\n assert candidate(n = \"1234567890\") == 9\n assert candidate(n = \"22222222222222222222\") == 2\n assert candidate(n = \"98765432109876543210\") == 9\n assert candidate(n = \"123123123123123123123123123\") == 3\n assert candidate(n = \"191919191919191919191919191919191919191919191919191\") == 9\n assert candidate(n = \"24680246802468024680\") == 8\n assert candidate(n = \"111122223333444455556666777788889999\") == 9\n assert candidate(n = \"50505050505050505050505050505050505050505050\") == 5\n assert candidate(n = \"123456789012345678901234567890\") == 9\n assert candidate(n = \"50000000000000000005\") == 5\n assert candidate(n = \"5555555555\") == 5\n assert candidate(n = \"192837465056473829109876543210\") == 9\n assert candidate(n = \"87654321987654321098\") == 9\n assert candidate(n = \"90000000000000000000900000000000000000000009\") == 9\n assert candidate(n = \"987654321987654321987654321987654321\") == 9\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minPartitions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minPartitions(self, n: str) -> int:", "container": "Solution", "callable": "minPartitions", "parameters": [{"name": "n", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1690, "task_id": "stone-game-vii", "difficulty": "Medium", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\nThere are n stones arranged in a row. On each player's turn, they can remove either the leftmost stone or the rightmost stone from the row and receive points equal to the sum of the remaining stones' values in the row. The winner is the one with the higher score when there are no stones left to remove.\nBob found that he will always lose this game (poor Bob, he always loses), so he decided to minimize the score's difference. Alice's goal is to maximize the difference in the score.\nGiven an array of integers stones where stones[i] represents the value of the ith stone from the left, return the difference in Alice and Bob's score if they both play optimally.\n \nExample 1:\n\nInput: stones = [5,3,1,4,2]\nOutput: 6\nExplanation: \n- Alice removes 2 and gets 5 + 3 + 1 + 4 = 13 points. Alice = 13, Bob = 0, stones = [5,3,1,4].\n- Bob removes 5 and gets 3 + 1 + 4 = 8 points. Alice = 13, Bob = 8, stones = [3,1,4].\n- Alice removes 3 and gets 1 + 4 = 5 points. Alice = 18, Bob = 8, stones = [1,4].\n- Bob removes 1 and gets 4 points. Alice = 18, Bob = 12, stones = [4].\n- Alice removes 4 and gets 0 points. Alice = 18, Bob = 12, stones = [].\nThe score difference is 18 - 12 = 6.\n\nExample 2:\n\nInput: stones = [7,90,5,1,100,10,10,2]\nOutput: 122\n \nConstraints:\n\nn == stones.length\n2 <= n <= 1000\n1 <= stones[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 30\n assert candidate(stones = [2, 3, 4, 1, 5, 6, 7, 8, 9, 10]) == 28\n assert candidate(stones = [1, 2, 3, 4, 5]) == 6\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(stones = [7, 90, 5, 1, 100, 10, 10, 2]) == 122\n assert candidate(stones = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9]) == 123\n assert candidate(stones = [10, 20, 30, 40, 50]) == 60\n assert candidate(stones = [1, 100, 1, 100, 1, 100]) == 300\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(stones = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 30\n assert candidate(stones = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 5000\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 15\n assert candidate(stones = [3, 9, 4, 2, 10, 3, 2, 5]) == 22\n assert candidate(stones = [5, 3, 1, 4, 2]) == 6\n assert candidate(stones = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 210\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 210\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 105\n assert candidate(stones = [500, 250, 750, 1000, 125, 375, 875, 625, 300, 700, 150, 450, 900, 550, 200, 600, 800, 400, 950, 100]) == 5950\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 40\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 156\n assert candidate(stones = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 110\n assert candidate(stones = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9, 1000, 10]) == 5500\n assert candidate(stones = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 56\n assert candidate(stones = [500, 2, 100, 400, 3, 800, 7, 600, 9, 50]) == 1852\n assert candidate(stones = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 9900\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1100\n assert candidate(stones = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993]) == 7972\n assert candidate(stones = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 2000\n assert candidate(stones = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 650\n assert candidate(stones = [5, 2, 9, 4, 6, 3, 8, 1, 7, 10]) == 35\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 450\n assert candidate(stones = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975]) == 11844\n assert candidate(stones = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 600\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 420\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 5600\n assert candidate(stones = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9, 1000, 10, 1100, 11, 1200, 12, 1300, 13, 1400, 14, 1500, 15]) == 12000\n assert candidate(stones = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 136\n assert candidate(stones = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 1010101010\n assert candidate(stones = [500, 400, 300, 200, 100, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5]) == 696\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 650\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 650\n assert candidate(stones = [2, 1, 3, 4, 1, 5, 7, 8, 1, 9, 6, 10, 12, 11, 13, 14, 15, 16, 17, 18]) == 96\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000]) == 7\n assert candidate(stones = [500, 250, 750, 125, 625, 375, 875, 125, 625, 375, 875, 125, 625, 375, 875, 125, 625, 375, 875, 125]) == 7250\n assert candidate(stones = [500, 250, 750, 200, 1000, 150, 300, 850, 600, 400]) == 3150\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 3000\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 110\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 7200\n assert candidate(stones = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == 9990\n assert candidate(stones = [200, 300, 100, 400, 500, 150, 250, 350, 450, 550]) == 1850\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 450\n assert candidate(stones = [50, 20, 30, 10, 40, 60, 70, 80, 90, 100]) == 280\n assert candidate(stones = [1, 10, 100, 1000, 10, 1, 1000, 100, 10, 1, 10, 100, 1000, 10, 1, 100, 100, 10, 1, 10, 100]) == 1342\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 830\n assert candidate(stones = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15]) == 72\n assert candidate(stones = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 1]) == 1010101010\n assert candidate(stones = [5, 25, 5, 25, 5, 25, 5, 25, 5, 25, 5, 25, 5, 25, 5]) == 35\n assert candidate(stones = [100, 50, 25, 12, 6, 3, 1, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 5526\n assert candidate(stones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 699050\n assert candidate(stones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 75\n assert candidate(stones = [100, 200, 300, 400, 500, 400, 300, 200, 100, 50, 40, 30, 20, 10, 1]) == 1090\n assert candidate(stones = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991, 11, 990, 12, 989, 13, 988, 14, 987, 15, 986]) == 14895\n assert candidate(stones = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == 14\n assert candidate(stones = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 1, 3, 6, 12, 25, 50, 100, 200, 300, 400, 500]) == 1597\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(stones = [50, 10, 50, 10, 50, 10, 50, 10, 50, 10]) == 250\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 30\n assert candidate(stones = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(stones = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996]) == 4990\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 4500\n assert candidate(stones = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 490\n assert candidate(stones = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 17710\n assert candidate(stones = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991]) == 9955\n assert candidate(stones = [100, 50, 25, 12, 6, 3, 1, 0, 1, 3, 6, 12, 25, 50, 100]) == 130\n assert candidate(stones = [1000, 1, 999, 2, 998, 3, 997, 4, 996, 5, 995, 6, 994, 7, 993, 8, 992, 9, 991, 10]) == 9955\n assert candidate(stones = [1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000]) == 10000\n assert candidate(stones = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 8]) == 28\n assert candidate(stones = [300, 100, 250, 150, 200, 50, 100, 300, 250, 150, 200, 50, 100]) == 800\n assert candidate(stones = [100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100]) == 350\n assert candidate(stones = [5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2]) == 48\n assert candidate(stones = [1000, 1, 2, 1000, 3, 1000, 4, 1000, 5, 1000, 6, 1000, 7, 1000, 8, 1000, 9, 1000, 10, 1000]) == 9001\n assert candidate(stones = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 560\n assert candidate(stones = [1, 10, 100, 1000, 10, 100, 1000, 10, 100, 1000, 10, 100, 1000, 10, 100]) == 2230\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3030\n assert candidate(stones = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 105\n assert candidate(stones = [145, 135, 125, 115, 105, 95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 525\n assert candidate(stones = [100, 200, 300, 400, 500, 1, 2, 3, 4, 5, 1000, 2000, 3000, 4000, 5000]) == 6609\n assert candidate(stones = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5]) == 4985\n assert candidate(stones = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 10101010\n assert candidate(stones = [100, 50, 200, 150, 250, 100, 300, 50, 200, 150, 250, 100, 300]) == 600\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 16\n assert candidate(stones = [700, 100, 500, 200, 600, 300, 400, 800, 900, 100, 200, 300, 400, 500, 600]) == 2300\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 410\n assert candidate(stones = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992]) == 28\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 560\n assert candidate(stones = [50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 141\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 60\n assert candidate(stones = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145]) == 525\n assert candidate(stones = [1500, 1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 5600\n assert candidate(stones = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 10\n assert candidate(stones = [314, 159, 265, 358, 979, 323, 846, 264, 338, 327, 950, 288, 419, 716, 939]) == 2435\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 105\n assert candidate(stones = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 29\n assert candidate(stones = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 1, 2, 4, 8, 16]) == 674\n"}, "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().stoneGameVII", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def stoneGameVII(self, stones: List[int]) -> int:", "container": "Solution", "callable": "stoneGameVII", "parameters": [{"name": "stones", "type": "List[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1691, "task_id": "maximum-height-by-stacking-cuboids", "difficulty": "Hard", "problem_description": "Given n cuboids where the dimensions of the ith cuboid is cuboids[i] = [widthi, lengthi, heighti] (0-indexed). Choose a subset of cuboids and place them on each other.\nYou can place cuboid i on cuboid j if widthi <= widthj and lengthi <= lengthj and heighti <= heightj. You can rearrange any cuboid's dimensions by rotating it to put it on another cuboid.\nReturn the maximum height of the stacked cuboids.\n \nExample 1:\n\n\nInput: cuboids = [[50,45,20],[95,37,53],[45,23,12]]\nOutput: 190\nExplanation:\nCuboid 1 is placed on the bottom with the 53x37 side facing down with height 95.\nCuboid 0 is placed next with the 45x20 side facing down with height 50.\nCuboid 2 is placed next with the 23x12 side facing down with height 45.\nThe total height is 95 + 50 + 45 = 190.\n\nExample 2:\n\nInput: cuboids = [[38,25,45],[76,35,3]]\nOutput: 76\nExplanation:\nYou can't place any of the cuboids on the other.\nWe choose cuboid 1 and rotate it so that the 35x3 side is facing down and its height is 76.\n\nExample 3:\n\nInput: cuboids = [[7,11,17],[7,17,11],[11,7,17],[11,17,7],[17,7,11],[17,11,7]]\nOutput: 102\nExplanation:\nAfter rearranging the cuboids, you can see that all cuboids have the same dimension.\nYou can place the 11x7 side down on all cuboids so their heights are 17.\nThe maximum height of stacked cuboids is 6 * 17 = 102.\n\n \nConstraints:\n\nn == cuboids.length\n1 <= n <= 100\n1 <= widthi, lengthi, heighti <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cuboids = [[4, 6, 7], [1, 2, 3], [4, 5, 6], [10, 12, 32]]) == 48\n assert candidate(cuboids = [[10, 10, 10], [5, 5, 5], [20, 20, 20]]) == 35\n assert candidate(cuboids = [[1, 1, 1], [2, 2, 2], [3, 3, 3]]) == 6\n assert candidate(cuboids = [[50, 45, 20], [95, 37, 53], [45, 23, 12]]) == 190\n assert candidate(cuboids = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 18\n assert candidate(cuboids = [[38, 25, 45], [76, 35, 3]]) == 76\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6]]) == 40\n assert candidate(cuboids = [[100, 100, 1], [100, 100, 1], [100, 100, 1]]) == 300\n assert candidate(cuboids = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 4\n assert candidate(cuboids = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) == 10\n assert candidate(cuboids = [[1, 2, 2], [3, 4, 4], [5, 6, 6]]) == 12\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8], [7, 7, 7]]) == 34\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8]]) == 27\n assert candidate(cuboids = [[7, 11, 17], [7, 17, 11], [11, 7, 17], [11, 17, 7], [17, 7, 11], [17, 11, 7]]) == 102\n assert candidate(cuboids = [[1, 1, 100], [1, 1, 100], [1, 1, 100]]) == 300\n assert candidate(cuboids = [[100, 100, 100], [99, 99, 99], [98, 98, 98]]) == 297\n assert candidate(cuboids = [[10, 20, 30], [30, 20, 10], [20, 10, 30]]) == 90\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [60, 60, 60]]) == 210\n assert candidate(cuboids = [[3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11]]) == 56\n assert candidate(cuboids = [[9, 8, 7], [6, 5, 4], [3, 2, 1], [12, 11, 10], [15, 14, 13]]) == 45\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [15, 15, 15], [25, 25, 25], [30, 30, 30]]) == 100\n assert candidate(cuboids = [[20, 20, 20], [20, 20, 15], [20, 15, 10], [15, 10, 5]]) == 75\n assert candidate(cuboids = [[3, 4, 5], [1, 2, 6], [4, 5, 3], [5, 3, 4], [6, 2, 1]]) == 15\n assert candidate(cuboids = [[50, 50, 50], [49, 49, 49], [48, 48, 48], [47, 47, 47], [46, 46, 46], [45, 45, 45], [44, 44, 44]]) == 329\n assert candidate(cuboids = [[10, 1, 1], [9, 2, 2], [8, 3, 3], [7, 4, 4], [6, 5, 5], [5, 6, 6], [4, 7, 7], [3, 8, 8], [2, 9, 9], [1, 10, 10], [10, 9, 8], [9, 8, 7], [8, 7, 6], [7, 6, 5], [6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1], [2, 1, 10], [1, 10, 9]]) == 64\n assert candidate(cuboids = [[30, 20, 10], [20, 10, 5], [10, 5, 2], [5, 2, 1], [2, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 70\n assert candidate(cuboids = [[20, 30, 40], [40, 30, 20], [10, 5, 15], [5, 10, 15]]) == 110\n assert candidate(cuboids = [[1, 3, 5], [1, 4, 6], [1, 5, 7], [2, 4, 8], [2, 5, 9], [3, 5, 11]]) == 39\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]]) == 55\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [60, 60, 60], [70, 70, 70], [80, 80, 80]]) == 360\n assert candidate(cuboids = [[60, 50, 40], [50, 40, 30], [40, 30, 20], [30, 20, 10], [20, 10, 5], [10, 5, 2], [5, 2, 1]]) == 215\n assert candidate(cuboids = [[1, 3, 2], [2, 1, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]]) == 33\n assert candidate(cuboids = [[1, 2, 2], [2, 2, 1], [2, 1, 2], [2, 2, 3], [3, 2, 2], [2, 3, 2]]) == 15\n assert candidate(cuboids = [[10, 20, 30], [15, 25, 40], [20, 30, 50], [25, 40, 60], [30, 50, 70]]) == 250\n assert candidate(cuboids = [[10, 11, 12], [12, 10, 11], [11, 12, 10], [10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40]]) == 136\n assert candidate(cuboids = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 1, 2], [2, 3, 1]]) == 18\n assert candidate(cuboids = [[3, 6, 5], [4, 4, 7], [5, 6, 7], [3, 5, 8], [2, 3, 4]]) == 18\n assert candidate(cuboids = [[99, 99, 99], [98, 98, 98], [97, 97, 97], [96, 96, 96], [95, 95, 95], [94, 94, 94]]) == 579\n assert candidate(cuboids = [[50, 40, 30], [40, 30, 20], [30, 20, 10], [20, 10, 5], [10, 5, 1], [9, 8, 7], [8, 7, 6], [7, 6, 5], [6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1]]) == 165\n assert candidate(cuboids = [[20, 30, 40], [10, 20, 30], [15, 25, 35], [5, 10, 15], [25, 35, 45]]) == 165\n assert candidate(cuboids = [[8, 8, 8], [9, 9, 9], [7, 7, 7], [6, 6, 6], [10, 10, 10]]) == 40\n assert candidate(cuboids = [[10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 10, 10]]) == 100\n assert candidate(cuboids = [[10, 20, 30], [5, 15, 25], [40, 60, 70], [15, 25, 5]]) == 150\n assert candidate(cuboids = [[2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]]) == 30\n assert candidate(cuboids = [[40, 50, 60], [20, 30, 40], [10, 20, 30], [5, 10, 15], [25, 35, 45]]) == 190\n assert candidate(cuboids = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 1, 1], [2, 2, 2], [3, 3, 3]]) == 22\n assert candidate(cuboids = [[50, 30, 20], [40, 25, 15], [60, 35, 25], [70, 40, 30], [80, 45, 35]]) == 300\n assert candidate(cuboids = [[10, 20, 30], [30, 20, 10], [20, 30, 10], [10, 30, 20], [30, 10, 20], [20, 10, 30]]) == 180\n assert candidate(cuboids = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [3, 1, 2], [1, 3, 2], [2, 3, 1], [4, 5, 6], [6, 5, 4], [5, 4, 6], [6, 4, 5], [5, 6, 4], [4, 6, 5]]) == 54\n assert candidate(cuboids = [[20, 20, 20], [19, 19, 19], [18, 18, 18], [17, 17, 17], [16, 16, 16], [15, 15, 15]]) == 105\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50]]) == 150\n assert candidate(cuboids = [[1, 1, 100], [1, 100, 1], [100, 1, 1], [1, 1, 50], [1, 50, 1], [50, 1, 1]]) == 450\n assert candidate(cuboids = [[5, 5, 5], [5, 5, 6], [5, 5, 7], [5, 5, 8], [5, 5, 9]]) == 35\n assert candidate(cuboids = [[7, 8, 9], [9, 10, 11], [12, 13, 14], [15, 16, 17], [18, 19, 20]]) == 71\n assert candidate(cuboids = [[10, 10, 10], [10, 10, 5], [10, 5, 10], [5, 10, 10], [10, 5, 5], [5, 10, 5], [5, 5, 10]]) == 70\n assert candidate(cuboids = [[50, 45, 20], [95, 37, 53], [45, 23, 12], [53, 37, 95], [23, 12, 45], [12, 45, 23]]) == 375\n assert candidate(cuboids = [[90, 10, 10], [10, 90, 10], [10, 10, 90], [45, 45, 45], [60, 60, 60], [80, 80, 80]]) == 270\n assert candidate(cuboids = [[5, 12, 2], [2, 9, 12], [12, 3, 4], [8, 6, 10], [7, 12, 5], [1, 15, 15], [15, 1, 15], [15, 15, 1]]) == 45\n assert candidate(cuboids = [[5, 3, 1], [7, 5, 3], [9, 7, 5], [11, 9, 7], [13, 11, 9], [15, 13, 11]]) == 60\n assert candidate(cuboids = [[7, 3, 1], [8, 4, 2], [9, 5, 3], [10, 6, 4], [11, 7, 5], [12, 8, 6]]) == 57\n assert candidate(cuboids = [[10, 10, 10], [15, 15, 15], [20, 20, 20], [25, 25, 25], [30, 30, 30], [35, 35, 35], [40, 40, 40], [45, 45, 45]]) == 220\n assert candidate(cuboids = [[8, 1, 6], [3, 5, 7], [4, 9, 2], [2, 6, 8], [5, 7, 3], [9, 4, 1]]) == 18\n assert candidate(cuboids = [[30, 20, 10], [25, 20, 10], [20, 15, 5], [15, 10, 5], [10, 6, 3], [5, 3, 1]]) == 105\n assert candidate(cuboids = [[50, 45, 20], [95, 37, 53], [45, 23, 12], [60, 60, 60], [10, 10, 10], [20, 20, 20], [30, 30, 30]]) == 200\n assert candidate(cuboids = [[5, 12, 17], [3, 8, 9], [1, 2, 3], [6, 7, 8], [4, 10, 11], [2, 5, 6]]) == 46\n assert candidate(cuboids = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [3, 1, 2], [2, 3, 1], [1, 3, 2]]) == 18\n assert candidate(cuboids = [[100, 1, 1], [99, 2, 2], [98, 3, 3], [97, 4, 4], [96, 5, 5], [95, 6, 6], [94, 7, 7], [93, 8, 8], [92, 9, 9], [91, 10, 10]]) == 100\n assert candidate(cuboids = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 30\n assert candidate(cuboids = [[8, 8, 8], [7, 7, 9], [6, 6, 10], [5, 5, 11], [4, 4, 12], [3, 3, 13], [2, 2, 14], [1, 1, 15]]) == 15\n assert candidate(cuboids = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60], [50, 60, 70]]) == 250\n assert candidate(cuboids = [[100, 50, 25], [50, 25, 12], [25, 12, 6], [12, 6, 3], [6, 3, 1], [3, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 199\n assert candidate(cuboids = [[10, 20, 30], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 57\n assert candidate(cuboids = [[4, 6, 7], [1, 2, 3], [4, 5, 6], [10, 12, 32], [1, 1, 4]]) == 49\n assert candidate(cuboids = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6]]) == 21\n assert candidate(cuboids = [[7, 11, 17], [11, 7, 17], [17, 11, 7], [7, 17, 11], [11, 17, 7], [17, 7, 11], [7, 11, 17], [11, 7, 17], [17, 11, 7]]) == 153\n assert candidate(cuboids = [[20, 20, 20], [10, 10, 10], [30, 30, 30], [15, 15, 15]]) == 75\n assert candidate(cuboids = [[1, 1, 100], [2, 2, 99], [3, 3, 98], [4, 4, 97], [5, 5, 96], [6, 6, 95]]) == 100\n assert candidate(cuboids = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]]) == 33\n assert candidate(cuboids = [[8, 8, 8], [8, 8, 7], [8, 7, 6], [7, 6, 5], [6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1]]) == 49\n assert candidate(cuboids = [[3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]]) == 52\n assert candidate(cuboids = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [1, 3, 2], [3, 1, 2], [2, 1, 3]]) == 18\n assert candidate(cuboids = [[10, 12, 3], [1, 3, 5], [6, 7, 8], [5, 4, 3], [7, 8, 9], [8, 9, 10]]) == 37\n assert candidate(cuboids = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 40\n assert candidate(cuboids = [[9, 8, 7], [8, 7, 6], [7, 6, 5], [6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1]]) == 42\n assert candidate(cuboids = [[23, 28, 32], [28, 32, 23], [32, 23, 28], [11, 29, 31], [29, 31, 11], [31, 11, 29], [12, 16, 24], [16, 24, 12], [24, 12, 16], [16, 24, 14]]) == 192\n assert candidate(cuboids = [[15, 12, 8], [8, 12, 15], [12, 15, 8], [9, 10, 7], [7, 10, 9], [10, 7, 9]]) == 75\n assert candidate(cuboids = [[1, 1, 10], [1, 2, 9], [1, 3, 8], [1, 4, 7], [1, 5, 6], [1, 6, 5], [1, 7, 4], [1, 8, 3], [1, 9, 2], [1, 10, 1]]) == 20\n assert candidate(cuboids = [[30, 50, 70], [20, 40, 60], [10, 30, 50], [5, 15, 25], [1, 2, 3]]) == 208\n assert candidate(cuboids = [[9, 18, 36], [18, 36, 72], [36, 72, 144], [72, 144, 288], [144, 288, 576], [288, 576, 1152]]) == 2268\n assert candidate(cuboids = [[25, 15, 10], [15, 10, 5], [10, 5, 2], [5, 3, 1], [3, 2, 1], [2, 1, 1], [1, 1, 1]]) == 61\n assert candidate(cuboids = [[12, 34, 56], [34, 12, 78], [56, 78, 12], [78, 12, 34]]) == 290\n assert candidate(cuboids = [[100, 1, 1], [1, 100, 1], [1, 1, 100], [99, 2, 2], [2, 99, 2], [2, 2, 99], [50, 50, 50], [75, 75, 75]]) == 300\n assert candidate(cuboids = [[3, 4, 5], [3, 3, 3], [3, 5, 5], [2, 3, 4], [2, 2, 2], [1, 1, 1], [1, 2, 3]]) == 18\n assert candidate(cuboids = [[15, 10, 5], [10, 8, 4], [5, 4, 2], [30, 20, 10], [20, 15, 5], [10, 6, 3]]) == 90\n assert candidate(cuboids = [[5, 4, 3], [4, 3, 2], [3, 2, 1], [2, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 18\n assert candidate(cuboids = [[1, 1, 1], [1, 2, 2], [2, 2, 2], [1, 3, 3], [2, 3, 3], [3, 3, 3], [1, 4, 4], [2, 4, 4], [3, 4, 4], [4, 4, 4]]) == 22\n assert candidate(cuboids = [[10, 20, 30], [30, 20, 10], [20, 10, 30], [10, 30, 20], [30, 10, 20], [20, 30, 10]]) == 180\n assert candidate(cuboids = [[5, 5, 5], [10, 10, 10], [15, 15, 15], [20, 20, 20], [25, 25, 25]]) == 75\n assert candidate(cuboids = [[5, 20, 30], [20, 30, 5], [30, 5, 20], [5, 30, 20], [30, 20, 5], [20, 5, 30]]) == 180\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]]) == 55\n assert candidate(cuboids = [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) == 26\n assert candidate(cuboids = [[4, 5, 6], [6, 5, 4], [7, 8, 9], [9, 8, 7], [1, 2, 3], [3, 2, 1]]) == 36\n assert candidate(cuboids = [[40, 40, 40], [30, 30, 30], [20, 20, 20], [10, 10, 10], [5, 5, 5], [1, 1, 1], [40, 30, 20], [30, 20, 10], [20, 10, 5], [10, 5, 1]]) == 141\n assert candidate(cuboids = [[9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]]) == 45\n assert candidate(cuboids = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9]]) == 42\n assert candidate(cuboids = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24]]) == 108\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [60, 60, 60], [70, 70, 70], [80, 80, 80], [90, 90, 90], [100, 100, 100]]) == 550\n assert candidate(cuboids = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60], [50, 60, 70], [60, 70, 80], [70, 80, 90], [80, 90, 100]]) == 520\n"}, "metadata": {"canonical_parameter_names": ["cuboids"], "leetcode_dataset_entry_point": "Solution().maxHeight", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxHeight(self, cuboids: List[List[int]]) -> int:", "container": "Solution", "callable": "maxHeight", "parameters": [{"name": "cuboids", "type": "List[List[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1694, "task_id": "reformat-phone-number", "difficulty": "Easy", "problem_description": "You are given a phone number as a string number. number consists of digits, spaces ' ', and/or dashes '-'.\nYou would like to reformat the phone number in a certain manner. Firstly, remove all spaces and dashes. Then, group the digits from left to right into blocks of length 3 until there are 4 or fewer digits. The final digits are then grouped as follows:\n\n2 digits: A single block of length 2.\n3 digits: A single block of length 3.\n4 digits: Two blocks of length 2 each.\n\nThe blocks are then joined by dashes. Notice that the reformatting process should never produce any blocks of length 1 and produce at most two blocks of length 2.\nReturn the phone number after formatting.\n \nExample 1:\n\nInput: number = \"1-23-45 6\"\nOutput: \"123-456\"\nExplanation: The digits are \"123456\".\nStep 1: There are more than 4 digits, so group the next 3 digits. The 1st block is \"123\".\nStep 2: There are 3 digits remaining, so put them in a single block of length 3. The 2nd block is \"456\".\nJoining the blocks gives \"123-456\".\n\nExample 2:\n\nInput: number = \"123 4-567\"\nOutput: \"123-45-67\"\nExplanation: The digits are \"1234567\".\nStep 1: There are more than 4 digits, so group the next 3 digits. The 1st block is \"123\".\nStep 2: There are 4 digits left, so split them into two blocks of length 2. The blocks are \"45\" and \"67\".\nJoining the blocks gives \"123-45-67\".\n\nExample 3:\n\nInput: number = \"123 4-5678\"\nOutput: \"123-456-78\"\nExplanation: The digits are \"12345678\".\nStep 1: The 1st block is \"123\".\nStep 2: The 2nd block is \"456\".\nStep 3: There are 2 digits left, so put them in a single block of length 2. The 3rd block is \"78\".\nJoining the blocks gives \"123-456-78\".\n\n \nConstraints:\n\n2 <= number.length <= 100\nnumber consists of digits and the characters '-' and ' '.\nThere are at least two digits in number.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(number = \"12 345 678\") == \"123-456-78\"\n assert candidate(number = \"1234-5678-9012\") == \"123-456-789-012\"\n assert candidate(number = \"12 345 678 90\") == \"123-456-78-90\"\n assert candidate(number = \"123456789\") == \"123-456-789\"\n assert candidate(number = \"12 345 678 901\") == \"123-456-789-01\"\n assert candidate(number = \"12 345-6789\") == \"123-456-789\"\n assert candidate(number = \"123456789012\") == \"123-456-789-012\"\n assert candidate(number = \"1234567890123\") == \"123-456-789-01-23\"\n assert candidate(number = \"12-345 67-89--01\") == \"123-456-789-01\"\n assert candidate(number = \"1234\") == \"12-34\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0\") == \"123-456-78-90\"\n assert candidate(number = \"1234567\") == \"123-45-67\"\n assert candidate(number = \"1 234 567 8901\") == \"123-456-789-01\"\n assert candidate(number = \"123 4567\") == \"123-45-67\"\n assert candidate(number = \"12 345 6789\") == \"123-456-789\"\n assert candidate(number = \"1-23-45 6\") == \"123-456\"\n assert candidate(number = \"12\") == \"12\"\n assert candidate(number = \"1234567890\") == \"123-456-78-90\"\n assert candidate(number = \"123 4-5678\") == \"123-456-78\"\n assert candidate(number = \"123 4-567\") == \"123-45-67\"\n assert candidate(number = \"123-4567890123\") == \"123-456-789-01-23\"\n assert candidate(number = \"1 234-567 890\") == \"123-456-78-90\"\n assert candidate(number = \"123-456-7890\") == \"123-456-78-90\"\n assert candidate(number = \"123\") == \"123\"\n assert candidate(number = \"123-456-789-012-345-678-901-234-567-890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"12 34-56-78-90\") == \"123-456-78-90\"\n assert candidate(number = \"12345 67890 123456 7890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12345678901234567890123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3\") == \"123-456-789-01-23\"\n assert candidate(number = \"1234-5678-9012-3456-7890-12\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"1234-5678-9012-3456-7890-1234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \" 1-23-45-67-89-01-23 \") == \"123-456-789-01-23\"\n assert candidate(number = \"12345678-90123456-78901234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 1234567890 12\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-90-12\"\n assert candidate(number = \"123 4567 890 1234 56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123-456-789-012-345-678-901-234-56\") == \"123-456-789-012-345-678-901-234-56\"\n assert candidate(number = \"123 456 7890 1234567890 1234567890 123\") == \"123-456-789-012-345-678-901-234-567-890-123\"\n assert candidate(number = \"12345678901234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12345678901234567890123456789012345\") == \"123-456-789-012-345-678-901-234-567-890-123-45\"\n assert candidate(number = \"12 34 56 78 90 12 34 56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"1234567890-12345-678-9\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"1-234-56789-012345\") == \"123-456-789-012-345\"\n assert candidate(number = \"123 456 7890 12345 678 90\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1234567890123456789012\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"12-345-6789-012345-6789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"12 3456 789 012 3456 78\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"1-23-45-67-89-01-23-45-67-89-01-23\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1 2345678901234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"123 456 789 012 345 678 901 234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9-0-1\") == \"123-456-789-012-345-678-901\"\n assert candidate(number = \"12 345 678 901 234 567\") == \"123-456-789-012-345-67\"\n assert candidate(number = \"12345678901234567890123456789012345678\") == \"123-456-789-012-345-678-901-234-567-890-123-456-78\"\n assert candidate(number = \"12345678901234567890123456789012\") == \"123-456-789-012-345-678-901-234-567-890-12\"\n assert candidate(number = \"1234 5678 9012 3456 7890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1 234 567 890 123 456 789 012 345\") == \"123-456-789-012-345-678-901-23-45\"\n assert candidate(number = \"123-45678901234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-78-90\"\n assert candidate(number = \"123-45 67-89 01 2\") == \"123-456-789-012\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0 1 2 3 4 5\") == \"123-456-789-012-345\"\n assert candidate(number = \"1234567890 123 4567 890 1234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"1234-567890-1234567890-12345\") == \"123-456-789-012-345-678-901-23-45\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"123456789012345678901234567890123456\") == \"123-456-789-012-345-678-901-234-567-890-123-456\"\n assert candidate(number = \"1234567890-1234567890-1234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"12345-6789-0123-456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12-345-678-90\") == \"123-456-78-90\"\n assert candidate(number = \"-12 34 56 78 90 -\") == \"123-456-78-90\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890-123-456-78-90\"\n assert candidate(number = \"123 456-789-0123-4567-8901\") == \"123-456-789-012-345-678-901\"\n assert candidate(number = \"12-345-678-901-234\") == \"123-456-789-012-34\"\n assert candidate(number = \"1234567890-1234567890-1234567890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"12 345 678 901 234 56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123-456-7890-1234-567\") == \"123-456-789-012-345-67\"\n assert candidate(number = \"123 4567 8901 2345\") == \"123-456-789-012-345\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234\") == \"123-456-789-012-345-678-901-234-567-890-12-34\"\n assert candidate(number = \"1-23-456-7890-1234\") == \"123-456-789-012-34\"\n assert candidate(number = \"123456789-0123456789-0123456789-0123\") == \"123-456-789-012-345-678-901-234-567-890-123\"\n assert candidate(number = \"123 456 7890 1234567890 123456\") == \"123-456-789-012-345-678-901-234-56\"\n assert candidate(number = \"123-4567890123456789012345678901234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-78-90\"\n assert candidate(number = \"12-345-67890123456789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"1 23 456 7890 1234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"1234567890-1234567890-1234567890-1234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-78-90\"\n assert candidate(number = \"1234-56789-012345-678\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"-1-23-456-7890-12345-6789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"-1-2-3-4-5-6-7-8-9-0-\") == \"123-456-78-90\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 1234567890 123\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-23\"\n assert candidate(number = \"12-34-56-78-90-12-34-56-78-90-12-34\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"1234567890 1234567890 1234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"123-4567-8901-2345-6789-012\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"123 456 7890 123 456 7890 123 456 7890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 123\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-01-23\"\n assert candidate(number = \"-12- 345-678-9012-3456-\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"1-23-45-67-89-01\") == \"123-456-789-01\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 12\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012\"\n assert candidate(number = \"12345 67890 1234 56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"12-345-67-89-01-23\") == \"123-456-789-01-23\"\n assert candidate(number = \"1234567890-123456-789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"1-23-45 67-890\") == \"123-456-78-90\"\n assert candidate(number = \"-1--2--3--4--5--6--7--8--9--0-\") == \"123-456-78-90\"\n assert candidate(number = \"123-456-789-012-345-678\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"123 456 789 012\") == \"123-456-789-012\"\n assert candidate(number = \"123456789012345678901234567890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"123-456 789-012 345-678\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"1-23-45-67-89-01-23-45-67-89-01\") == \"123-456-789-012-345-678-901\"\n assert candidate(number = \"123456789-0123456789012345\") == \"123-456-789-012-345-678-901-23-45\"\n assert candidate(number = \"123 456789 01234 567\") == \"123-456-789-012-345-67\"\n assert candidate(number = \"123-4567-8901-2345-6789-0123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1234-5678-9012-3456-7890-1234-56\") == \"123-456-789-012-345-678-901-234-56\"\n assert candidate(number = \"1-234 567-89 0\") == \"123-456-78-90\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0 1 2 3\") == \"123-456-789-01-23\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9-0\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1234-5678-9012-3456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123456789-0123456789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"123 456 7890 1234567890 123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"-123-456-789-012-345-678-90\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12 34 56 78 90 12 34 56 78\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"123-456-789-012-3456-7890-123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1234567890 1234567890 1234567890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"12-34-56-78-90-12-34\") == \"123-456-789-012-34\"\n assert candidate(number = \"1234567890123456789012345678901234\") == \"123-456-789-012-345-678-901-234-567-890-12-34\"\n assert candidate(number = \"123-4567-89012345-6789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3-4\") == \"123-456-789-012-34\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9\") == \"123-456-789\"\n assert candidate(number = \"123-4567-89012-3456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"12 34 56 78 90 12 34\") == \"123-456-789-012-34\"\n assert candidate(number = \"123-456-789-012-345-6789-0123-4567-8901\") == \"123-456-789-012-345-678-901-234-567-89-01\"\n assert candidate(number = \"123456789012345678901234567890123\") == \"123-456-789-012-345-678-901-234-567-890-123\"\n assert candidate(number = \"123 456 789 012 345 678 9012\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"123-456-789-012-345-678-90\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"-123-456-789-012-345-678-901-\") == \"123-456-789-012-345-678-901\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"1234567890-1234567890-1234567890-1234\") == \"123-456-789-012-345-678-901-234-567-890-12-34\"\n assert candidate(number = \"123 456 7890 1234 5678\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"123 4567 8901 2345 6789 0123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1234 5678 9012 3456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"12345 67890 123 456 7890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0\") == \"123-456-78-90\"\n assert candidate(number = \"1 234 567 890 123 456 789 012\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"12345-67890-12345-67890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12-345 678 901-234\") == \"123-456-789-012-34\"\n assert candidate(number = \"123-4567-8901-2345-6789-0123-4567-8901-2345\") == \"123-456-789-012-345-678-901-234-567-890-123-45\"\n assert candidate(number = \"12 34 56 78 90 12 34 56 78 90 12 34 56 78 90\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"1234-567890-1234567-890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"123 4567 89012 3456 789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"12 34 567 890 123-4\") == \"123-456-789-012-34\"\n assert candidate(number = \"123 456 789 012 345\") == \"123-456-789-012-345\"\n assert candidate(number = \"123 4567 890 123 45 6789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"12-34-56-78-90-12-34-56-78\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"1234567890-1234-5678901234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"123-45-678901234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12-34-56-78-90-12-34-56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123 456 789 012 345 678 901 234 567 890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"1-23-45-67-89-01-23-45-67\") == \"123-456-789-012-345-67\"\n assert candidate(number = \"12-345-678-9012-34\") == \"123-456-789-012-34\"\n assert candidate(number = \"12-345-6789-0123-4567-8901-2345-6789\") == \"123-456-789-012-345-678-901-234-567-89\"\n assert candidate(number = \"12345-6789-01234-5678-90123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1234567890123456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123-456-7890-123456\") == \"123-456-789-012-34-56\"\n"}, "metadata": {"canonical_parameter_names": ["number"], "leetcode_dataset_entry_point": "Solution().reformatNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def reformatNumber(self, number: str) -> str:", "container": "Solution", "callable": "reformatNumber", "parameters": [{"name": "number", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1695, "task_id": "maximum-erasure-value", "difficulty": "Medium", "problem_description": "You are given an array of positive integers nums and want to erase a subarray containing unique elements. The score you get by erasing the subarray is equal to the sum of its elements.\nReturn the maximum score you can get by erasing exactly one subarray.\nAn array b is called to be a subarray of a if it forms a contiguous subsequence of a, that is, if it is equal to a[l],a[l+1],...,a[r] for some (l,r).\n \nExample 1:\n\nInput: nums = [4,2,4,5,6]\nOutput: 17\nExplanation: The optimal subarray here is [2,4,5,6].\n\nExample 2:\n\nInput: nums = [5,2,1,2,5,2,1,2,5]\nOutput: 8\nExplanation: The optimal subarray here is [5,2,1] or [1,2,5].\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 18\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1]) == 55\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 6]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [10, 5, 2, 7, 8, 7, 4, 5]) == 32\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 6, 5, 7, 8, 9, 8, 10]) == 35\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996]) == 49990\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7, 8, 9]) == 42\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [9, 9, 9, 9, 10, 9, 9, 9]) == 19\n assert candidate(nums = [4, 2, 4, 5, 6]) == 17\n assert candidate(nums = [5, 2, 1, 2, 5, 2, 1, 2, 5]) == 8\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 11\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 2500\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 19\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 21\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 99955\n assert candidate(nums = [400, 300, 200, 100, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 12000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1]) == 595\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 15, 15]) == 54\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 55\n assert candidate(nums = [3, 1, 2, 4, 5, 6, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 324\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 1810\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 210\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 99955\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 10000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5]) == 45\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 3\n assert candidate(nums = [1, 2, 3, 1, 4, 5, 6, 2, 3, 7, 8, 9, 10, 1, 2, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 450\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 210\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 5, 7, 8, 9, 8, 10, 11, 10, 12, 13, 12, 14, 15]) == 54\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 639\n assert candidate(nums = [1, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 324\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996, 6, 9995, 7, 9994, 8, 9993, 9, 9992, 10, 9991]) == 100010\n assert candidate(nums = [2, 3, 1, 4, 5, 6, 1, 2, 3, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 3, 5, 7, 9, 1]) == 55\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 1810\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 10000]) == 99955\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12]) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(nums = [9999, 10000, 9999, 10000, 9999, 10000, 9999, 10000, 9999, 10000, 9999, 10000]) == 19999\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 66\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7]) == 34\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 204\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [3, 1, 2, 4, 5, 3, 6, 7, 8, 9, 1, 2, 3, 4]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 55\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 39\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 19\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7]) == 55\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 1275\n assert candidate(nums = [100, 200, 100, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 12000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [2, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 2, 2, 2, 2]) == 819\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 300\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == 5000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5000]) == 50045\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981]) == 199810\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [3, 1, 2, 4, 2, 3, 5, 6, 7, 8, 9, 1]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 55\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 3, 2, 1, 4, 2, 3, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 820\n assert candidate(nums = [1, 10, 100, 1000, 10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 10, 100, 1000, 10000, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11155\n assert candidate(nums = [5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2]) == 7\n assert candidate(nums = [10, 9, 8, 7, 6, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumUniqueSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumUniqueSubarray(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maximumUniqueSubarray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1696, "task_id": "jump-game-vi", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums and an integer k.\nYou are initially standing at index 0. In one move, you can jump at most k steps forward without going outside the boundaries of the array. That is, you can jump from index i to any index in the range [i + 1, min(n - 1, i + k)] inclusive.\nYou want to reach the last index of the array (index n - 1). Your score is the sum of all nums[j] for each index j you visited in the array.\nReturn the maximum score you can get.\n \nExample 1:\n\nInput: nums = [1,-1,-2,4,-7,3], k = 2\nOutput: 7\nExplanation: You can choose your jumps forming the subsequence [1,-1,4,3] (underlined above). The sum is 7.\n\nExample 2:\n\nInput: nums = [10,-5,-2,4,0,3], k = 3\nOutput: 17\nExplanation: You can choose your jumps forming the subsequence [10,4,3] (underlined above). The sum is 17.\n\nExample 3:\n\nInput: nums = [1,-5,-20,4,-1,3,-6,-3], k = 2\nOutput: 0\n\n \nConstraints:\n\n1 <= nums.length, k <= 105\n-104 <= nums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 55\n assert candidate(nums = [1, -1, -2, 4, -7, 3],k = 2) == 7\n assert candidate(nums = [10, -5, -2, 4, 0, 3],k = 3) == 17\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 4) == -6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 50\n assert candidate(nums = [-10000, -10000, -10000, -10000, -10000],k = 2) == -30000\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 2) == -9\n assert candidate(nums = [5, -1, 5],k = 2) == 10\n assert candidate(nums = [1],k = 1) == 1\n assert candidate(nums = [5, 4, 3, 2, 1],k = 1) == 15\n assert candidate(nums = [100, -100, 100, -100, 100],k = 2) == 300\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000],k = 5) == 50000\n assert candidate(nums = [5, 6, -4, 2, 1],k = 3) == 14\n assert candidate(nums = [1, -5, -20, 4, -1, 3, -6, -3],k = 2) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 15\n assert candidate(nums = [-5, -1, -5],k = 1) == -11\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],k = 2) == 4000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 9\n assert candidate(nums = [1000, -500, 2000, -100, 4000, -200, 3000, -300, 5000, -400],k = 5) == 14600\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == -16\n assert candidate(nums = [1, -10, 5, 6, -4, -5, 10, 1, 2],k = 4) == 25\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 55\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 4) == -19\n assert candidate(nums = [5, -1, -2, -3, -4, -5, 6, -1, 2, -3, -4, -5, 10],k = 5) == 22\n assert candidate(nums = [1000, -2000, 3000, -4000, 5000, -6000, 7000, -8000, 9000],k = 6) == 25000\n assert candidate(nums = [10, 20, 30, 40, 50, -60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 4) == 1140\n assert candidate(nums = [3, 2, -6, 5, 0, -3, 2, 1],k = 3) == 13\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == 5500\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 550\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 55\n assert candidate(nums = [10000, -5000, 5000, 6000, -2000, 3000, 7000, -8000, 4000, 10000],k = 5) == 45000\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],k = 4) == 29\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 5) == 9\n assert candidate(nums = [1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000],k = 10) == 2000\n assert candidate(nums = [-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000],k = 5) == 40000\n assert candidate(nums = [1, -10, 5, 6, -2, 3, 7, -8, 4, 10],k = 3) == 36\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1) == 550\n assert candidate(nums = [10000, -9999, 10000, -9999, 10000, -9999, 10000, -9999, 10000, -9999],k = 2) == 40001\n assert candidate(nums = [5, -1, 3, -2, 7, 1, -4, 8, -3, 2],k = 4) == 26\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 0\n assert candidate(nums = [3, -2, -2, 2, -1, 2, 1, -5, 4],k = 3) == 12\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100],k = 2) == 400\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],k = 5) == 4000\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 3) == 1000\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 4) == 7\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 10) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 210\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 15) == 1\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10],k = 2) == 55\n assert candidate(nums = [3, -1, 2, -5, 6, 2, -1, 4],k = 4) == 17\n assert candidate(nums = [1, -5, 4, 2, -2, -1, 3, 1, -1, 2, -3, 4, -5, 6],k = 3) == 23\n assert candidate(nums = [5, -10, 4, -2, 3, 100, -100, 200, -200, 300],k = 4) == 612\n assert candidate(nums = [10, 5, 2, 7, 8, 9, 3, 5, 2, 1, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5],k = 3) == 102\n assert candidate(nums = [10, -5, -20, 4, -1, 3, -6, -3, 5, 2],k = 4) == 24\n assert candidate(nums = [1, -10, 100, -1000, 10000],k = 3) == 10101\n assert candidate(nums = [-1, -5, -2, -4, -10, -20],k = 2) == -27\n assert candidate(nums = [5, -10, 15, -20, 25, -30, 35, -40, 45, -50, 55, -60, 65, -70, 75, -80],k = 5) == 240\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 15\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 3) == -220\n assert candidate(nums = [3, -1, -1, -1, 10, 5],k = 2) == 17\n assert candidate(nums = [10, -1, 10, -1, 10, -1, 10, -1, 10, -1],k = 5) == 49\n assert candidate(nums = [3, -1, 2, 1, -4, 2, 3, -5, 4],k = 4) == 15\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6],k = 4) == 187\n assert candidate(nums = [1, -5, 10, 20, -30, 5, 15],k = 4) == 51\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 55\n assert candidate(nums = [1000, -1000, 500, -500, 250, -250, 125, -125, 62, -62, 31, -31],k = 5) == 1937\n assert candidate(nums = [5, 3, 2, 1, 7, 6, 4, 8, 9],k = 3) == 45\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 10) == -110\n assert candidate(nums = [1, -10, 2, -20, 3, -30, 4, -40, 5, -50],k = 4) == -35\n assert candidate(nums = [100, -50, 200, -300, 400, -500, 600, -700, 800],k = 3) == 2100\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 4\n assert candidate(nums = [100, -50, -100, 200, -300, 400, 500],k = 3) == 1200\n assert candidate(nums = [10000, -5000, 2000, -1000, 5000, 2000, -2000, 3000, 4000, -1000],k = 3) == 25000\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20],k = 5) == 109\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 20\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 210\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 5) == 50\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 20) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 55\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10],k = 2) == 40\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 4) == 10\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150],k = 3) == -460\n assert candidate(nums = [100, 200, 300, 400, 500],k = 5) == 1500\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 5) == 1000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 55\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxResult", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxResult(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "maxResult", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1697, "task_id": "checking-existence-of-edge-length-limited-paths", "difficulty": "Hard", "problem_description": "An undirected graph of n nodes is defined by edgeList, where edgeList[i] = [ui, vi, disi] denotes an edge between nodes ui and vi with distance disi. Note that there may be multiple edges between two nodes.\nGiven an array queries, where queries[j] = [pj, qj, limitj], your task is to determine for each queries[j] whether there is a path between pj and qj such that each edge on the path has a distance strictly less than limitj .\nReturn a boolean array answer, where answer.length == queries.length and the jth value of answer is true if there is a path for queries[j] is true, and false otherwise.\n \nExample 1:\n\n\nInput: n = 3, edgeList = [[0,1,2],[1,2,4],[2,0,8],[1,0,16]], queries = [[0,1,2],[0,2,5]]\nOutput: [false,true]\nExplanation: The above figure shows the given graph. Note that there are two overlapping edges between 0 and 1 with distances 2 and 16.\nFor the first query, between 0 and 1 there is no path where each distance is less than 2, thus we return false for this query.\nFor the second query, there is a path (0 -> 1 -> 2) of two edges with distances less than 5, thus we return true for this query.\n\nExample 2:\n\n\nInput: n = 5, edgeList = [[0,1,10],[1,2,5],[2,3,9],[3,4,13]], queries = [[0,4,14],[1,4,13]]\nOutput: [true,false]\nExplanation: The above figure shows the given graph.\n\n \nConstraints:\n\n2 <= n <= 105\n1 <= edgeList.length, queries.length <= 105\nedgeList[i].length == 3\nqueries[j].length == 3\n0 <= ui, vi, pj, qj <= n - 1\nui != vi\npj != qj\n1 <= disi, limitj <= 109\nThere may be multiple edges between two nodes.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,edgeList = [[0, 1, 2], [1, 2, 4], [2, 0, 8], [1, 0, 16]],queries = [[0, 1, 2], [0, 2, 5]]) == [False, True]\n assert candidate(n = 7,edgeList = [[0, 1, 5], [1, 2, 7], [2, 3, 10], [3, 4, 3], [4, 5, 2], [5, 6, 6], [6, 0, 1]],queries = [[0, 6, 8], [3, 5, 4]]) == [True, True]\n assert candidate(n = 6,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5]],queries = [[0, 5, 6], [0, 5, 10], [0, 5, 3]]) == [True, True, False]\n assert candidate(n = 7,edgeList = [[0, 1, 9], [0, 2, 3], [1, 3, 2], [2, 3, 8], [2, 4, 6], [3, 4, 5], [3, 5, 7], [4, 5, 1]],queries = [[0, 4, 8], [1, 2, 4], [3, 5, 6]]) == [True, False, True]\n assert candidate(n = 6,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5]],queries = [[0, 5, 6], [1, 4, 5], [2, 3, 4]]) == [True, True, True]\n assert candidate(n = 4,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 0, 20]],queries = [[0, 3, 15], [1, 2, 8]]) == [False, False]\n assert candidate(n = 2,edgeList = [[0, 1, 1]],queries = [[0, 1, 2], [0, 1, 1]]) == [True, False]\n assert candidate(n = 6,edgeList = [[0, 1, 4], [1, 2, 3], [2, 3, 1], [3, 4, 5], [4, 5, 6]],queries = [[0, 5, 10], [1, 4, 8]]) == [True, True]\n assert candidate(n = 4,edgeList = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 0, 1]],queries = [[0, 3, 2], [1, 2, 1]]) == [True, False]\n assert candidate(n = 4,edgeList = [[0, 1, 3], [1, 2, 1], [2, 3, 2], [3, 0, 4]],queries = [[0, 2, 4], [1, 3, 5]]) == [True, True]\n assert candidate(n = 5,edgeList = [[0, 1, 10], [1, 2, 5], [2, 3, 9], [3, 4, 13]],queries = [[0, 4, 14], [1, 4, 13]]) == [True, False]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 5]],queries = [[0, 9, 4], [0, 9, 5], [0, 9, 6], [0, 9, 7], [0, 9, 8]]) == [False, False, True, True, True]\n assert candidate(n = 12,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 0, 1200], [0, 2, 150], [2, 4, 250], [4, 6, 350], [6, 8, 450], [8, 10, 550], [10, 1, 650], [1, 3, 750], [3, 5, 850], [5, 7, 950], [7, 9, 1050], [9, 11, 1150], [11, 3, 1250]],queries = [[0, 11, 700], [2, 10, 550], [4, 8, 400], [6, 0, 250]]) == [False, False, False, False]\n assert candidate(n = 6,edgeList = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 0, 5], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 0, 10], [5, 1, 10]],queries = [[0, 3, 6], [1, 4, 7], [2, 5, 8]]) == [True, True, True]\n assert candidate(n = 50,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 12, 1200], [12, 13, 1300], [13, 14, 1400], [14, 15, 1500], [15, 16, 1600], [16, 17, 1700], [17, 18, 1800], [18, 19, 1900], [19, 20, 2000], [20, 21, 2100], [21, 22, 2200], [22, 23, 2300], [23, 24, 2400], [24, 25, 2500], [25, 26, 2600], [26, 27, 2700], [27, 28, 2800], [28, 29, 2900], [29, 30, 3000], [30, 31, 3100], [31, 32, 3200], [32, 33, 3300], [33, 34, 3400], [34, 35, 3500], [35, 36, 3600], [36, 37, 3700], [37, 38, 3800], [38, 39, 3900], [39, 40, 4000], [40, 41, 4100], [41, 42, 4200], [42, 43, 4300], [43, 44, 4400], [44, 45, 4500], [45, 46, 4600], [46, 47, 4700], [47, 48, 4800], [48, 49, 4900], [49, 0, 5000]],queries = [[0, 49, 5010], [1, 48, 5020], [2, 47, 5030], [3, 46, 5040], [4, 45, 5050], [5, 44, 5060], [6, 43, 5070], [7, 42, 5080], [8, 41, 5090], [9, 40, 5100], [10, 39, 5110], [11, 38, 5120], [12, 37, 5130], [13, 36, 5140], [14, 35, 5150], [15, 34, 5160], [16, 33, 5170], [17, 32, 5180], [18, 31, 5190], [19, 30, 5200], [20, 29, 5210], [21, 28, 5220], [22, 27, 5230], [23, 26, 5240], [24, 25, 5250], [0, 25, 2600], [1, 24, 2700], [2, 23, 2800], [3, 22, 2900], [4, 21, 3000], [5, 20, 3100], [6, 19, 3200], [7, 18, 3300], [8, 17, 3400], [9, 16, 3500], [10, 15, 3600], [11, 14, 3700], [12, 13, 3800]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 2], [1, 2, 4], [2, 3, 6], [3, 4, 8], [4, 5, 10], [5, 6, 12], [6, 7, 14], [7, 8, 16], [8, 9, 18], [9, 10, 20], [10, 11, 22], [11, 12, 24], [12, 13, 26], [13, 14, 28], [14, 15, 30], [15, 16, 32], [16, 17, 34], [17, 18, 36], [18, 19, 38]],queries = [[0, 19, 40], [1, 18, 39], [2, 17, 38], [3, 16, 37], [4, 15, 36], [5, 14, 35], [6, 13, 34], [7, 12, 33], [8, 11, 32], [9, 10, 31]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 12, 1200], [12, 13, 1300], [13, 14, 1400], [14, 0, 1500]],queries = [[0, 14, 1200], [1, 13, 1100], [2, 12, 1000], [3, 11, 900], [4, 10, 800]]) == [False, False, False, False, False]\n assert candidate(n = 6,edgeList = [[0, 1, 100], [0, 2, 200], [1, 3, 300], [2, 3, 400], [1, 4, 500], [2, 5, 600], [3, 5, 700]],queries = [[0, 5, 800], [0, 5, 400], [0, 3, 350], [0, 4, 600]]) == [True, False, True, True]\n assert candidate(n = 12,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [0, 4, 10], [4, 5, 20], [5, 6, 25], [6, 7, 30], [7, 8, 35], [8, 9, 40], [9, 10, 45], [10, 11, 50], [0, 11, 60]],queries = [[0, 11, 65], [0, 11, 55], [0, 5, 25], [5, 10, 45]]) == [True, True, True, False]\n assert candidate(n = 8,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 0, 80], [0, 3, 5], [1, 4, 15], [2, 5, 25], [3, 6, 35], [4, 7, 45], [5, 0, 55], [6, 1, 65], [7, 2, 75]],queries = [[0, 7, 40], [2, 6, 35], [4, 0, 60], [1, 5, 75]]) == [False, False, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 10]],queries = [[0, 9, 5], [0, 9, 15], [2, 7, 6]]) == [False, True, False]\n assert candidate(n = 8,edgeList = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [0, 7, 9], [0, 6, 10], [1, 5, 11], [2, 4, 12]],queries = [[0, 7, 8], [1, 5, 9], [2, 4, 10], [3, 6, 11], [0, 5, 12], [1, 6, 13], [2, 7, 14], [0, 4, 15], [3, 5, 16], [0, 6, 17]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 2], [0, 2, 3], [1, 2, 4], [2, 3, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8], [6, 7, 9], [7, 8, 10], [8, 9, 11], [9, 0, 12]],queries = [[0, 9, 13], [1, 8, 15], [2, 7, 17], [3, 6, 19], [4, 5, 21]]) == [True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],queries = [[0, 9, 10], [0, 5, 6], [3, 7, 5]]) == [True, True, False]\n assert candidate(n = 25,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 12, 120], [12, 13, 130], [13, 14, 140], [14, 15, 150], [15, 16, 160], [16, 17, 170], [17, 18, 180], [18, 19, 190], [19, 20, 200], [20, 21, 210], [21, 22, 220], [22, 23, 230], [23, 24, 240], [0, 24, 250]],queries = [[0, 24, 200], [0, 24, 251], [2, 23, 225], [5, 20, 160]]) == [False, True, False, False]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10]],queries = [[0, 9, 11], [2, 6, 6], [1, 8, 15]]) == [True, False, True]\n assert candidate(n = 15,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 150], [3, 4, 250], [4, 5, 300], [5, 6, 350], [6, 7, 400], [7, 8, 450], [8, 9, 500], [9, 10, 550], [10, 11, 600], [11, 12, 650], [12, 13, 700], [13, 14, 750]],queries = [[0, 14, 800], [1, 13, 900], [2, 12, 1000], [3, 11, 1100], [4, 10, 1200], [5, 9, 1300]]) == [True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 1]],queries = [[0, 9, 15], [2, 6, 8], [4, 7, 12]]) == [True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 15, 75], [15, 16, 80], [16, 17, 85], [17, 18, 90], [18, 19, 95], [19, 0, 100]],queries = [[0, 19, 200], [5, 15, 150], [10, 15, 100]]) == [True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 5, 11], [5, 1, 12]],queries = [[0, 9, 11], [1, 8, 10], [2, 7, 9], [3, 6, 8], [4, 5, 7]]) == [True, True, True, True, True]\n assert candidate(n = 11,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [0, 10, 11]],queries = [[0, 10, 12], [0, 10, 6], [0, 5, 8], [5, 10, 7], [2, 8, 9], [3, 7, 10]]) == [True, False, True, False, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20]],queries = [[0, 19, 15], [1, 18, 14], [2, 17, 13], [3, 16, 12], [4, 15, 11]]) == [False, False, False, False, False]\n assert candidate(n = 50,edgeList = [[0, 1, 5], [1, 2, 15], [2, 3, 25], [3, 4, 35], [4, 5, 45], [5, 6, 55], [6, 7, 65], [7, 8, 75], [8, 9, 85], [9, 10, 95], [10, 11, 105], [11, 12, 115], [12, 13, 125], [13, 14, 135], [14, 15, 145], [15, 16, 155], [16, 17, 165], [17, 18, 175], [18, 19, 185], [19, 20, 195], [20, 21, 205], [21, 22, 215], [22, 23, 225], [23, 24, 235], [24, 25, 245], [25, 26, 255], [26, 27, 265], [27, 28, 275], [28, 29, 285], [29, 30, 295], [30, 31, 305], [31, 32, 315], [32, 33, 325], [33, 34, 335], [34, 35, 345], [35, 36, 355], [36, 37, 365], [37, 38, 375], [38, 39, 385], [39, 40, 395], [40, 41, 405], [41, 42, 415], [42, 43, 425], [43, 44, 435], [44, 45, 445], [45, 46, 455], [46, 47, 465], [47, 48, 475], [48, 49, 485]],queries = [[0, 49, 500], [10, 30, 310], [20, 40, 410]]) == [True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [0, 19, 20]],queries = [[0, 19, 10], [0, 19, 21], [2, 18, 15], [5, 15, 10]]) == [False, True, False, False]\n assert candidate(n = 50,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 20, 20], [20, 21, 21], [21, 22, 22], [22, 23, 23], [23, 24, 24], [24, 25, 25], [25, 26, 26], [26, 27, 27], [27, 28, 28], [28, 29, 29], [29, 30, 30], [30, 31, 31], [31, 32, 32], [32, 33, 33], [33, 34, 34], [34, 35, 35], [35, 36, 36], [36, 37, 37], [37, 38, 38], [38, 39, 39], [39, 40, 40], [40, 41, 41], [41, 42, 42], [42, 43, 43], [43, 44, 44], [44, 45, 45], [45, 46, 46], [46, 47, 47], [47, 48, 48], [48, 49, 49], [0, 49, 50]],queries = [[0, 49, 40], [0, 49, 51], [2, 48, 45], [5, 45, 30]]) == [False, True, False, False]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15], [0, 2, 16], [2, 4, 17], [4, 6, 18], [6, 8, 19], [8, 10, 20], [10, 12, 21], [12, 14, 22], [14, 1, 23], [1, 3, 24], [3, 5, 25], [5, 7, 26], [7, 9, 27], [9, 11, 28], [11, 13, 29], [13, 0, 30]],queries = [[0, 14, 15], [2, 12, 13], [4, 10, 11], [6, 8, 9], [8, 6, 8], [10, 4, 10], [12, 2, 16], [14, 0, 14]]) == [True, True, True, True, False, False, True, False]\n assert candidate(n = 20,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 12, 1200], [12, 13, 1300], [13, 14, 1400], [14, 15, 1500], [15, 16, 1600], [16, 17, 1700], [17, 18, 1800], [18, 19, 1900], [0, 19, 2000]],queries = [[0, 19, 1900], [0, 19, 2000], [1, 18, 3800], [2, 17, 5400], [3, 16, 6900]]) == [False, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15], [0, 7, 20], [1, 8, 21], [2, 9, 22], [3, 10, 23], [4, 11, 24], [5, 12, 25], [6, 13, 26], [7, 14, 27], [8, 0, 28], [9, 1, 29], [10, 2, 30], [11, 3, 31], [12, 4, 32], [13, 5, 33], [14, 6, 34]],queries = [[0, 14, 16], [1, 13, 17], [2, 12, 18], [3, 11, 19], [4, 10, 20], [5, 9, 21], [6, 8, 22], [7, 0, 23], [8, 1, 24], [9, 2, 25], [10, 3, 26], [11, 4, 27], [12, 5, 28], [13, 6, 29], [0, 7, 35], [1, 8, 36], [2, 9, 37], [3, 10, 38], [4, 11, 39], [5, 12, 40], [6, 13, 41], [7, 14, 42]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [0, 14, 15]],queries = [[0, 14, 10], [0, 14, 16], [2, 12, 8]]) == [False, True, False]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [0, 2, 3], [1, 2, 2], [3, 4, 5], [4, 5, 4], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],queries = [[0, 9, 10], [2, 5, 5], [4, 7, 12], [1, 8, 15]]) == [False, False, True, False]\n assert candidate(n = 8,edgeList = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 4], [1, 5, 5], [2, 6, 6], [2, 7, 7], [3, 4, 8], [3, 5, 9], [4, 6, 10], [5, 7, 11]],queries = [[0, 7, 12], [1, 6, 10], [2, 5, 9], [3, 4, 8], [0, 4, 7]]) == [True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 12, 1200], [12, 13, 1300], [13, 14, 1400]],queries = [[0, 14, 1500], [5, 10, 800], [3, 7, 600]]) == [True, False, False]\n assert candidate(n = 15,edgeList = [[0, 1, 20], [1, 2, 30], [2, 3, 40], [3, 4, 50], [4, 5, 60], [5, 6, 70], [6, 7, 80], [7, 8, 90], [8, 9, 100], [9, 10, 110], [10, 11, 120], [11, 12, 130], [12, 13, 140], [13, 14, 150], [14, 0, 160]],queries = [[0, 14, 300], [3, 7, 200], [6, 10, 150]]) == [True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15]],queries = [[0, 7, 8], [1, 8, 9], [2, 9, 10], [3, 10, 11], [4, 11, 12], [5, 12, 13], [6, 13, 14]]) == [True, True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 3], [1, 2, 2], [2, 3, 1], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 10]],queries = [[0, 9, 9], [0, 9, 11], [1, 8, 15], [2, 7, 20]]) == [False, True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20]],queries = [[0, 10, 11], [1, 11, 12], [2, 12, 13], [3, 13, 14], [4, 14, 15], [5, 15, 16], [6, 16, 17], [7, 17, 18], [8, 18, 19], [9, 19, 20]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 0, 1], [0, 9, 2], [1, 8, 2], [2, 7, 2], [3, 6, 2], [4, 5, 2]],queries = [[0, 4, 2], [5, 9, 2], [3, 7, 2]]) == [True, True, True]\n assert candidate(n = 8,edgeList = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 3, 4], [1, 4, 5], [2, 5, 6], [3, 6, 7], [4, 7, 8], [5, 7, 9]],queries = [[0, 7, 15], [1, 6, 10], [2, 5, 7], [3, 4, 4]]) == [True, True, True, False]\n assert candidate(n = 7,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]],queries = [[0, 6, 7], [0, 5, 6], [0, 4, 5], [0, 3, 4], [0, 2, 3], [0, 1, 2]]) == [True, True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14]],queries = [[0, 14, 15], [1, 13, 25], [2, 12, 30], [3, 11, 35], [4, 10, 40]]) == [True, True, True, True, True]\n assert candidate(n = 8,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 2, 3], [1, 3, 4], [2, 4, 5], [3, 5, 6], [4, 6, 7], [5, 7, 8]],queries = [[0, 7, 9], [1, 6, 10], [2, 5, 11]]) == [True, True, True]\n assert candidate(n = 12,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12]],queries = [[0, 6, 7], [1, 7, 8], [2, 8, 9], [3, 9, 10], [4, 10, 11], [5, 11, 12]]) == [True, True, True, True, True, True]\n assert candidate(n = 9,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [0, 8, 9], [1, 7, 10], [2, 6, 11], [3, 5, 12]],queries = [[0, 8, 13], [1, 7, 11], [2, 6, 9], [3, 5, 7]]) == [True, True, True, True]\n assert candidate(n = 12,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 0, 120], [0, 6, 130], [1, 7, 140], [2, 8, 150], [3, 9, 160], [4, 10, 170], [5, 11, 180]],queries = [[0, 11, 125], [1, 10, 135], [2, 9, 145], [3, 8, 155], [4, 7, 165], [5, 6, 175], [0, 7, 185], [1, 8, 195], [2, 11, 205], [3, 0, 215]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 12, 120], [12, 13, 130], [13, 14, 140], [14, 15, 150], [15, 16, 160], [16, 17, 170], [17, 18, 180], [18, 19, 190], [19, 0, 200]],queries = [[0, 19, 210], [1, 18, 220], [2, 17, 230], [3, 16, 240], [4, 15, 250], [5, 14, 260], [6, 13, 270], [7, 12, 280], [8, 11, 290], [9, 10, 300]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 3], [1, 2, 1], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 2]],queries = [[0, 9, 15], [2, 5, 12], [1, 8, 6]]) == [True, True, False]\n assert candidate(n = 20,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 12, 120], [12, 13, 130], [13, 14, 140], [14, 15, 150], [15, 16, 160], [16, 17, 170], [17, 18, 180], [18, 19, 190]],queries = [[0, 19, 200], [5, 15, 120], [3, 10, 80]]) == [True, False, False]\n assert candidate(n = 10,edgeList = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]],queries = [[0, 9, 11], [0, 9, 5], [0, 4, 10]]) == [True, False, True]\n assert candidate(n = 10,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 0, 50], [0, 5, 55], [5, 1, 60], [1, 6, 65], [6, 2, 70], [2, 7, 75]],queries = [[0, 9, 60], [1, 8, 55], [2, 7, 50], [3, 6, 45], [4, 5, 40]]) == [True, True, True, True, True]\n assert candidate(n = 18,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 15, 75], [15, 16, 80], [16, 17, 85], [17, 0, 90], [0, 8, 95], [1, 9, 100], [2, 10, 105], [3, 11, 110], [4, 12, 115], [5, 13, 120], [6, 14, 125], [7, 15, 130], [8, 16, 135], [9, 17, 140], [10, 0, 145], [11, 1, 150], [12, 2, 155], [13, 3, 160], [14, 4, 165], [15, 5, 170], [16, 6, 175], [17, 7, 180]],queries = [[0, 17, 175], [1, 16, 180], [2, 15, 185], [3, 14, 190], [4, 13, 195], [5, 12, 200], [6, 11, 205], [7, 10, 210], [8, 9, 215], [0, 15, 220], [1, 14, 225], [2, 13, 230], [3, 12, 235], [4, 11, 240], [5, 10, 245], [6, 9, 250], [7, 8, 255], [0, 14, 260], [1, 13, 265], [2, 12, 270], [3, 11, 275], [4, 10, 280], [5, 9, 285], [6, 8, 290], [0, 13, 295], [1, 12, 300], [2, 11, 305], [3, 10, 310], [4, 9, 315], [5, 8, 320], [0, 12, 325], [1, 11, 330], [2, 10, 335], [3, 9, 340], [4, 8, 345], [0, 11, 350], [1, 10, 355], [2, 9, 360], [3, 8, 365], [0, 10, 370], [1, 9, 375], [2, 8, 380], [0, 9, 385], [1, 8, 390], [0, 8, 395]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 4, 40], [3, 5, 50], [4, 6, 60], [5, 7, 70], [6, 8, 80], [7, 9, 90], [8, 10, 100], [9, 11, 110], [10, 12, 120], [11, 13, 130], [12, 14, 140]],queries = [[0, 14, 150], [0, 14, 75], [0, 7, 85], [7, 14, 110]]) == [True, False, True, False]\n assert candidate(n = 6,edgeList = [[0, 1, 20], [1, 2, 30], [2, 3, 40], [3, 4, 50], [4, 5, 60], [5, 0, 70], [0, 2, 15], [2, 4, 25], [4, 1, 35], [1, 3, 45], [3, 5, 55], [5, 2, 65]],queries = [[0, 5, 50], [1, 4, 40], [2, 3, 30]]) == [False, True, False]\n"}, "metadata": {"canonical_parameter_names": ["n", "edgeList", "queries"], "leetcode_dataset_entry_point": "Solution().distanceLimitedPathsExist", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def distanceLimitedPathsExist(self, n: int, edgeList: list[list[int]], queries: list[list[int]]) -> list[bool]:", "container": "Solution", "callable": "distanceLimitedPathsExist", "parameters": [{"name": "n", "type": "int"}, {"name": "edgeList", "type": "list[list[int]]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1700, "task_id": "number-of-students-unable-to-eat-lunch", "difficulty": "Easy", "problem_description": "The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers square or circular sandwiches.\nThe number of sandwiches in the cafeteria is equal to the number of students. The sandwiches are placed in a stack. At each step:\n\nIf the student at the front of the queue prefers the sandwich on the top of the stack, they will take it and leave the queue.\nOtherwise, they will leave it and go to the queue's end.\n\nThis continues until none of the queue students want to take the top sandwich and are thus unable to eat.\nYou are given two integer arrays students and sandwiches where sandwiches[i] is the type of the i​​​​​​th sandwich in the stack (i = 0 is the top of the stack) and students[j] is the preference of the j​​​​​​th student in the initial queue (j = 0 is the front of the queue). Return the number of students that are unable to eat.\n \nExample 1:\n\nInput: students = [1,1,0,0], sandwiches = [0,1,0,1]\nOutput: 0 \nExplanation:\n- Front student leaves the top sandwich and returns to the end of the line making students = [1,0,0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [0,0,1,1].\n- Front student takes the top sandwich and leaves the line making students = [0,1,1] and sandwiches = [1,0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [1,1,0].\n- Front student takes the top sandwich and leaves the line making students = [1,0] and sandwiches = [0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [0,1].\n- Front student takes the top sandwich and leaves the line making students = [1] and sandwiches = [1].\n- Front student takes the top sandwich and leaves the line making students = [] and sandwiches = [].\nHence all students are able to eat.\n\nExample 2:\n\nInput: students = [1,1,1,0,0,1], sandwiches = [1,0,0,0,1,1]\nOutput: 3\n\n \nConstraints:\n\n1 <= students.length, sandwiches.length <= 100\nstudents.length == sandwiches.length\nsandwiches[i] is 0 or 1.\nstudents[i] is 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(students = [0, 1, 0, 1],sandwiches = [1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 0, 0, 1],sandwiches = [1, 0, 0, 0, 1, 1]) == 3\n assert candidate(students = [0, 0, 1, 1],sandwiches = [1, 1, 0, 0]) == 0\n assert candidate(students = [1, 0, 1, 0],sandwiches = [0, 1, 0, 1]) == 0\n assert candidate(students = [0, 0, 0, 0],sandwiches = [0, 0, 0, 0]) == 0\n assert candidate(students = [0, 1, 0, 1],sandwiches = [0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 0, 0],sandwiches = [0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 1, 1],sandwiches = [1, 1, 1, 1]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 0, 0, 0, 0, 1, 1],sandwiches = [0, 0, 0, 1, 1, 1, 0, 1, 1]) == 0\n assert candidate(students = [1, 0, 0, 1, 1, 0, 0, 1],sandwiches = [1, 1, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 0, 0, 1, 0, 1, 1, 0],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0],sandwiches = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(students = [0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 1, 0, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 1, 0],sandwiches = [0, 0, 1, 0, 1, 1, 0, 1]) == 0\n assert candidate(students = [0, 1, 1, 1, 0, 1, 0, 0, 1, 0],sandwiches = [0, 1, 0, 1, 1, 1, 1, 0, 0, 0]) == 0\n assert candidate(students = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],sandwiches = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 2\n assert candidate(students = [1, 0, 0, 1, 1, 0, 1, 0, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0],sandwiches = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1]) == 0\n assert candidate(students = [1, 1, 1, 0, 0, 0, 0, 1, 1],sandwiches = [1, 0, 0, 0, 1, 0, 0, 1, 0]) == 3\n assert candidate(students = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1],sandwiches = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 2\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0],sandwiches = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 1, 0, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],sandwiches = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(students = [1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1],sandwiches = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 0, 0, 1, 1, 1, 1, 0, 0, 0],sandwiches = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0]) == 3\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],sandwiches = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sandwiches = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(students = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 2\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0],sandwiches = [0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 0, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 0]) == 0\n assert candidate(students = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1],sandwiches = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0],sandwiches = [1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0],sandwiches = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 0, 1, 0, 0, 1, 1, 0, 1],sandwiches = [0, 1, 1, 0, 1, 1, 0, 1, 0, 0]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 0, 1, 1, 0, 0, 1, 1],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 0, 1, 1, 0],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 1\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],sandwiches = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == 4\n assert candidate(students = [1, 1, 0, 0, 0, 0, 1, 1],sandwiches = [1, 1, 0, 0, 0, 0, 1, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1],sandwiches = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],sandwiches = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 1, 1, 0, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 0, 0, 1, 1, 0, 0, 1],sandwiches = [1, 0, 1, 0, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1],sandwiches = [1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0]) == 1\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(students = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],sandwiches = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(students = [1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1],sandwiches = [1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0]) == 1\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 1]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 1, 0, 0, 1],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 0, 1, 1, 0, 0, 0, 1],sandwiches = [0, 1, 1, 0, 0, 0, 1, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],sandwiches = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1],sandwiches = [1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 1, 0, 0],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],sandwiches = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0],sandwiches = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0],sandwiches = [1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sandwiches = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 69\n assert candidate(students = [1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0],sandwiches = [0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1]) == 0\n assert candidate(students = [0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0]) == 1\n"}, "metadata": {"canonical_parameter_names": ["students", "sandwiches"], "leetcode_dataset_entry_point": "Solution().countStudents", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countStudents(self, students: list[int], sandwiches: list[int]) -> int:", "container": "Solution", "callable": "countStudents", "parameters": [{"name": "students", "type": "list[int]"}, {"name": "sandwiches", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1701, "task_id": "average-waiting-time", "difficulty": "Medium", "problem_description": "There is a restaurant with a single chef. You are given an array customers, where customers[i] = [arrivali, timei]:\n\narrivali is the arrival time of the ith customer. The arrival times are sorted in non-decreasing order.\ntimei is the time needed to prepare the order of the ith customer.\n\nWhen a customer arrives, he gives the chef his order, and the chef starts preparing it once he is idle. The customer waits till the chef finishes preparing his order. The chef does not prepare food for more than one customer at a time. The chef prepares food for customers in the order they were given in the input.\nReturn the average waiting time of all customers. Solutions within 10-5 from the actual answer are considered accepted.\n \nExample 1:\n\nInput: customers = [[1,2],[2,5],[4,3]]\nOutput: 5.00000\nExplanation:\n1) The first customer arrives at time 1, the chef takes his order and starts preparing it immediately at time 1, and finishes at time 3, so the waiting time of the first customer is 3 - 1 = 2.\n2) The second customer arrives at time 2, the chef takes his order and starts preparing it at time 3, and finishes at time 8, so the waiting time of the second customer is 8 - 2 = 6.\n3) The third customer arrives at time 4, the chef takes his order and starts preparing it at time 8, and finishes at time 11, so the waiting time of the third customer is 11 - 4 = 7.\nSo the average waiting time = (2 + 6 + 7) / 3 = 5.\n\nExample 2:\n\nInput: customers = [[5,2],[5,4],[10,3],[20,1]]\nOutput: 3.25000\nExplanation:\n1) The first customer arrives at time 5, the chef takes his order and starts preparing it immediately at time 5, and finishes at time 7, so the waiting time of the first customer is 7 - 5 = 2.\n2) The second customer arrives at time 5, the chef takes his order and starts preparing it at time 7, and finishes at time 11, so the waiting time of the second customer is 11 - 5 = 6.\n3) The third customer arrives at time 10, the chef takes his order and starts preparing it at time 11, and finishes at time 14, so the waiting time of the third customer is 14 - 10 = 4.\n4) The fourth customer arrives at time 20, the chef takes his order and starts preparing it immediately at time 20, and finishes at time 21, so the waiting time of the fourth customer is 21 - 20 = 1.\nSo the average waiting time = (2 + 6 + 4 + 1) / 4 = 3.25.\n\n \nConstraints:\n\n1 <= customers.length <= 105\n1 <= arrivali, timei <= 104\narrivali <= arrivali+1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(customers = [[5, 2], [5, 4], [10, 3], [20, 1]]) == 3.25\n assert candidate(customers = [[1, 1], [1, 1], [1, 1], [1, 1]]) == 2.5\n assert candidate(customers = [[1, 1], [1, 1], [1, 1]]) == 2.0\n assert candidate(customers = [[1, 3], [2, 3], [6, 3], [10, 3]]) == 3.75\n assert candidate(customers = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 5.0\n assert candidate(customers = [[1, 3], [2, 3], [6, 3]]) == 4.0\n assert candidate(customers = [[1, 2], [2, 5], [4, 3]]) == 5.0\n assert candidate(customers = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == 28.0\n assert candidate(customers = [[2, 3], [6, 3], [10, 3], [15, 3]]) == 3.0\n assert candidate(customers = [[1, 5], [2, 2], [3, 3], [4, 4], [5, 5]]) == 9.0\n assert candidate(customers = [[1, 10], [10, 10], [20, 10], [30, 10], [40, 10]]) == 10.8\n assert candidate(customers = [[1, 3], [2, 2], [3, 1]]) == 3.6666666666666665\n assert candidate(customers = [[10, 5], [15, 2], [20, 3], [30, 1]]) == 2.75\n assert candidate(customers = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 5.5\n assert candidate(customers = [[1, 1000], [1010, 500], [1510, 250], [1760, 125], [1885, 62], [1947, 31], [1978, 15], [1993, 7], [1999, 3], [2001, 1]]) == 199.7\n assert candidate(customers = [[1, 1], [3, 1], [5, 1], [7, 1], [9, 1], [11, 1], [13, 1], [15, 1], [17, 1], [19, 1], [21, 1], [23, 1], [25, 1], [27, 1], [29, 1]]) == 1.0\n assert candidate(customers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 35.0\n assert candidate(customers = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]]) == 1.0\n assert candidate(customers = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11], [120, 12], [130, 13], [140, 14], [150, 15]]) == 9.333333333333334\n assert candidate(customers = [[1, 100], [101, 50], [151, 200], [251, 100], [351, 300], [451, 150], [601, 50], [651, 100], [751, 250], [851, 50]]) == 320.0\n assert candidate(customers = [[1, 5], [2, 3], [3, 4], [10, 2], [15, 5], [20, 1], [25, 3], [30, 4], [35, 2], [40, 5]]) == 4.7\n assert candidate(customers = [[1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 2], [4, 3], [4, 4], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 13.692307692307692\n assert candidate(customers = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 14.0\n assert candidate(customers = [[1, 5], [2, 3], [3, 4], [4, 2], [5, 6], [6, 1]]) == 10.833333333333334\n assert candidate(customers = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 2], [12, 2], [13, 2], [14, 2], [15, 2], [16, 2], [17, 2], [18, 2], [19, 2], [20, 2]]) == 11.5\n assert candidate(customers = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 10], [12, 10], [13, 10], [14, 10], [15, 10], [16, 10], [17, 10], [18, 10], [19, 10], [20, 10], [21, 10], [22, 10], [23, 10], [24, 10], [25, 10], [26, 10], [27, 10], [28, 10], [29, 10], [30, 10]]) == 140.5\n assert candidate(customers = [[1, 10000], [10001, 10000], [20001, 10000], [30001, 10000], [40001, 10000], [50001, 10000], [60001, 10000], [70001, 10000], [80001, 10000], [90001, 10000]]) == 10000.0\n assert candidate(customers = [[1, 1000], [2000, 1000], [3000, 1000], [4000, 1000], [5000, 1000], [6000, 1000]]) == 1000.0\n assert candidate(customers = [[1, 2], [2, 3], [3, 2], [4, 3], [5, 2], [6, 3], [7, 2], [8, 3], [9, 2], [10, 3], [11, 2], [12, 3], [13, 2], [14, 3], [15, 2], [16, 3], [17, 2], [18, 3], [19, 2], [20, 3]]) == 16.5\n assert candidate(customers = [[1, 3], [2, 4], [5, 2], [6, 1], [8, 6], [10, 3], [11, 2]]) == 7.0\n assert candidate(customers = [[1, 3], [2, 2], [4, 3], [5, 4], [6, 2], [8, 1], [10, 5]]) == 6.857142857142857\n assert candidate(customers = [[10, 30], [20, 20], [30, 10], [40, 5], [50, 2], [60, 1], [70, 3], [80, 4], [90, 2], [100, 5], [110, 1], [120, 3], [130, 4], [140, 2], [150, 5]]) == 15.2\n assert candidate(customers = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25], [26, 26], [27, 27], [28, 28], [29, 29], [30, 30]]) == 150.83333333333334\n assert candidate(customers = [[100, 50], [150, 20], [200, 30], [250, 10], [300, 40], [350, 5], [400, 15]]) == 24.285714285714285\n assert candidate(customers = [[1, 1], [3, 3], [3, 3], [3, 3], [5, 5], [5, 5], [7, 7], [7, 7], [9, 9], [9, 9]]) == 18.0\n assert candidate(customers = [[5, 3], [6, 4], [8, 2], [9, 5], [12, 3], [15, 1], [18, 2], [20, 4], [25, 3], [30, 1]]) == 6.9\n assert candidate(customers = [[100, 100], [200, 50], [300, 25], [400, 12], [500, 6]]) == 38.6\n assert candidate(customers = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70], [10, 80], [10, 90], [10, 100]]) == 220.0\n assert candidate(customers = [[1, 100], [101, 50], [151, 25], [201, 10], [251, 5], [301, 1]]) == 31.833333333333332\n assert candidate(customers = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 8.0\n assert candidate(customers = [[5, 10], [10, 10], [15, 10], [20, 10], [25, 10], [30, 10], [35, 10], [40, 10], [45, 10], [50, 10]]) == 32.5\n assert candidate(customers = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20]]) == 77.0\n assert candidate(customers = [[1, 1], [2, 1], [2, 1], [3, 1], [3, 1], [4, 1], [4, 1], [5, 1], [5, 1]]) == 2.7777777777777777\n assert candidate(customers = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]]) == 34.0\n assert candidate(customers = [[1, 20], [1, 15], [2, 10], [2, 5], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == 45.0\n assert candidate(customers = [[1, 1], [100, 100], [200, 100], [300, 100], [400, 100], [500, 100], [600, 100], [700, 100], [800, 100], [900, 100]]) == 90.1\n assert candidate(customers = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == 6.5\n assert candidate(customers = [[1, 1000], [2, 1000], [3, 1000], [4, 1000], [5, 1000], [6, 1000], [7, 1000], [8, 1000], [9, 1000], [10, 1000]]) == 5495.5\n assert candidate(customers = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == 529.0\n assert candidate(customers = [[1, 5], [3, 7], [5, 2], [10, 1], [12, 3], [15, 2], [18, 5]]) == 7.428571428571429\n assert candidate(customers = [[5, 10], [15, 15], [25, 20], [35, 25], [45, 30], [55, 35], [65, 40], [75, 45], [85, 50]]) == 76.66666666666667\n assert candidate(customers = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1]]) == 1.0\n assert candidate(customers = [[1, 10000], [10001, 1], [20002, 1], [30003, 1], [40004, 1], [50005, 1], [60006, 1], [70007, 1], [80008, 1], [90009, 1]]) == 1000.9\n assert candidate(customers = [[1, 100], [1, 90], [1, 80], [1, 70], [1, 60], [1, 50], [1, 40], [1, 30], [1, 20], [1, 10]]) == 385.0\n assert candidate(customers = [[5, 3], [5, 2], [5, 4], [5, 1], [5, 5]]) == 8.4\n assert candidate(customers = [[2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5]]) == 27.5\n assert candidate(customers = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 17.5\n assert candidate(customers = [[1, 100], [20, 50], [40, 30], [60, 20], [80, 10], [100, 5], [120, 3], [140, 2], [160, 1]]) == 111.33333333333333\n assert candidate(customers = [[1, 10], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10], [30, 10], [35, 10], [40, 10], [45, 10], [50, 10], [55, 10], [60, 10], [65, 10], [70, 10], [75, 10], [80, 10], [85, 10], [90, 10], [95, 10]]) == 58.45\n assert candidate(customers = [[1, 5], [6, 10], [12, 15], [18, 20], [24, 25], [30, 30], [36, 35], [42, 40], [48, 45], [54, 50]]) == 83.9\n assert candidate(customers = [[1, 1], [2, 2], [3, 2], [4, 1], [5, 2], [6, 3], [7, 1], [8, 2], [9, 3], [10, 1], [11, 2], [12, 3], [13, 1], [14, 2], [15, 3]]) == 7.466666666666667\n assert candidate(customers = [[1, 100], [101, 100], [201, 100], [301, 100], [401, 100], [501, 100], [601, 100], [701, 100], [801, 100], [901, 100]]) == 100.0\n assert candidate(customers = [[100, 50], [200, 25], [300, 12], [400, 6], [500, 3], [600, 1], [700, 2], [800, 4], [900, 1]]) == 11.555555555555555\n assert candidate(customers = [[1, 1000], [1001, 1000], [2001, 1000], [3001, 1000], [4001, 1000], [5001, 1000]]) == 1000.0\n assert candidate(customers = [[1, 1], [3, 2], [6, 3], [10, 4], [15, 5], [21, 6], [28, 7], [36, 8], [45, 9], [55, 10]]) == 5.5\n assert candidate(customers = [[1, 10], [10, 10], [20, 10], [30, 10], [40, 10], [50, 10]]) == 10.833333333333334\n assert candidate(customers = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 21.0\n assert candidate(customers = [[1, 5], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5]]) == 8.333333333333334\n assert candidate(customers = [[1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000]]) == 55000.0\n assert candidate(customers = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512]]) == 102.3\n assert candidate(customers = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 22.0\n assert candidate(customers = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600]]) == 800.0\n assert candidate(customers = [[1, 100], [101, 50], [151, 20], [201, 10], [251, 5], [301, 1], [351, 2], [401, 3], [451, 4]]) == 21.666666666666668\n assert candidate(customers = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 215.5\n assert candidate(customers = [[1, 1000], [1001, 1000], [2001, 1000], [3001, 1000], [4001, 1000]]) == 1000.0\n assert candidate(customers = [[1, 5000], [100, 2000], [2000, 3000], [3000, 1000], [4000, 4000], [5000, 5000], [6000, 6000], [7000, 7000], [8000, 8000], [9000, 9000], [10000, 10000]]) == 20355.454545454544\n assert candidate(customers = [[1, 2], [3, 3], [6, 2], [8, 1], [10, 3], [15, 4]]) == 2.5\n assert candidate(customers = [[1, 1], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 2], [12, 2], [13, 2], [14, 2], [15, 2], [16, 2], [17, 2], [18, 2], [19, 2], [20, 2]]) == 10.5\n assert candidate(customers = [[1, 1000], [1001, 500], [1501, 250], [2001, 125], [2501, 62], [3001, 31], [3501, 15], [4001, 7], [4501, 3], [5001, 1]]) == 199.4\n assert candidate(customers = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]]) == 50.0\n assert candidate(customers = [[1000, 1], [2000, 1], [3000, 1], [4000, 1], [5000, 1], [6000, 1], [7000, 1], [8000, 1], [9000, 1], [10000, 1]]) == 1.0\n assert candidate(customers = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 31.0\n assert candidate(customers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22]]) == 42.0\n assert candidate(customers = [[1, 10], [11, 10], [21, 10], [31, 10], [41, 10], [51, 10], [61, 10], [71, 10], [81, 10], [91, 10]]) == 10.0\n assert candidate(customers = [[1000, 100], [2000, 200], [3000, 300], [4000, 400], [5000, 500], [6000, 600], [7000, 700], [8000, 800], [9000, 900], [10000, 1000]]) == 550.0\n assert candidate(customers = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21]]) == 40.5\n assert candidate(customers = [[1, 1], [2, 100], [3, 200], [4, 300], [5, 400], [6, 500], [7, 600], [8, 700], [9, 800], [10, 900]]) == 1646.5\n assert candidate(customers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30]]) == 76.66666666666667\n assert candidate(customers = [[1, 1000], [2000, 500], [3000, 300], [4000, 200], [5000, 100], [6000, 50], [7000, 30], [8000, 20], [9000, 10], [10000, 5], [11000, 3], [12000, 2], [13000, 1]]) == 170.84615384615384\n assert candidate(customers = [[100, 100], [200, 100], [300, 100], [400, 100], [500, 100], [600, 100], [700, 100], [800, 100], [900, 100], [1000, 100]]) == 100.0\n assert candidate(customers = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 38.333333333333336\n assert candidate(customers = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]]) == 27.5\n"}, "metadata": {"canonical_parameter_names": ["customers"], "leetcode_dataset_entry_point": "Solution().averageWaitingTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def averageWaitingTime(self, customers: list[list[int]]) -> float:", "container": "Solution", "callable": "averageWaitingTime", "parameters": [{"name": "customers", "type": "list[list[int]]"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1702, "task_id": "maximum-binary-string-after-change", "difficulty": "Medium", "problem_description": "You are given a binary string binary consisting of only 0's or 1's. You can apply each of the following operations any number of times:\n\nOperation 1: If the number contains the substring \"00\", you can replace it with \"10\".\n\n\t\nFor example, \"00010\" -> \"10010\"\n\n\nOperation 2: If the number contains the substring \"10\", you can replace it with \"01\".\n\t\nFor example, \"00010\" -> \"00001\"\n\n\n\nReturn the maximum binary string you can obtain after any number of operations. Binary string x is greater than binary string y if x's decimal representation is greater than y's decimal representation.\n \nExample 1:\n\nInput: binary = \"000110\"\nOutput: \"111011\"\nExplanation: A valid transformation sequence can be:\n\"000110\" -> \"000101\" \n\"000101\" -> \"100101\" \n\"100101\" -> \"110101\" \n\"110101\" -> \"110011\" \n\"110011\" -> \"111011\"\n\nExample 2:\n\nInput: binary = \"01\"\nOutput: \"01\"\nExplanation: \"01\" cannot be transformed any further.\n\n \nConstraints:\n\n1 <= binary.length <= 105\nbinary consist of '0' and '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(binary = \"01010101010\") == \"11111011111\"\n assert candidate(binary = \"01\") == \"01\"\n assert candidate(binary = \"000001\") == \"111101\"\n assert candidate(binary = \"1111\") == \"1111\"\n assert candidate(binary = \"10101010101010101010\") == \"11111111110111111111\"\n assert candidate(binary = \"000000000\") == \"111111110\"\n assert candidate(binary = \"010101\") == \"110111\"\n assert candidate(binary = \"111000011\") == \"111111011\"\n assert candidate(binary = \"00110011\") == \"11101111\"\n assert candidate(binary = \"00000\") == \"11110\"\n assert candidate(binary = \"000000\") == \"111110\"\n assert candidate(binary = \"1100101\") == \"1111011\"\n assert candidate(binary = \"001001\") == \"111011\"\n assert candidate(binary = \"101010\") == \"111011\"\n assert candidate(binary = \"0000\") == \"1110\"\n assert candidate(binary = \"0101010101\") == \"1111011111\"\n assert candidate(binary = \"000111000\") == \"111110111\"\n assert candidate(binary = \"10101010\") == \"11110111\"\n assert candidate(binary = \"1100110011\") == \"1111101111\"\n assert candidate(binary = \"0101010\") == \"1110111\"\n assert candidate(binary = \"111000\") == \"111110\"\n assert candidate(binary = \"0001010101\") == \"1111101111\"\n assert candidate(binary = \"000001111\") == \"111101111\"\n assert candidate(binary = \"111111\") == \"111111\"\n assert candidate(binary = \"00001111\") == \"11101111\"\n assert candidate(binary = \"11001000101\") == \"11111110111\"\n assert candidate(binary = \"0010101\") == \"1110111\"\n assert candidate(binary = \"11001100\") == \"11111011\"\n assert candidate(binary = \"11110000\") == \"11111110\"\n assert candidate(binary = \"011110\") == \"101111\"\n assert candidate(binary = \"110010\") == \"111101\"\n assert candidate(binary = \"000110\") == \"111011\"\n assert candidate(binary = \"100100100\") == \"111111011\"\n assert candidate(binary = \"1000000\") == \"1111110\"\n assert candidate(binary = \"11111\") == \"11111\"\n assert candidate(binary = \"100000000001\") == \"111111111101\"\n assert candidate(binary = \"10101001010100101\") == \"11111111101111111\"\n assert candidate(binary = \"00000000000000000000111111111111\") == \"11111111111111111110111111111111\"\n assert candidate(binary = \"01111111111111111111111111111111\") == \"01111111111111111111111111111111\"\n assert candidate(binary = \"00000000000000000\") == \"11111111111111110\"\n assert candidate(binary = \"01001001001001001\") == \"11111111110111111\"\n assert candidate(binary = \"0000000000\") == \"1111111110\"\n assert candidate(binary = \"0000111100001111\") == \"1111111011111111\"\n assert candidate(binary = \"000001111000001111000001111000001111000001111\") == \"111111111111111111111111011111111111111111111\"\n assert candidate(binary = \"001001001001001001001001001001001001001001001001001001\") == \"111111111111111111111111111111111110111111111111111111\"\n assert candidate(binary = \"000000000000\") == \"111111111110\"\n assert candidate(binary = \"11111011111011111011111011111011111011111011111\") == \"11111111111011111111111111111111111111111111111\"\n assert candidate(binary = \"10010010010010010\") == \"11111111111011111\"\n assert candidate(binary = \"111001001001001000\") == \"111111111111101111\"\n assert candidate(binary = \"00000011100000\") == \"11111111110111\"\n assert candidate(binary = \"111111111111111111111111111111111111111111111111111111111111111111111111\") == \"111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(binary = \"00011001100110011\") == \"11111111011111111\"\n assert candidate(binary = \"010101010101010101010\") == \"111111111101111111111\"\n assert candidate(binary = \"00010101010100\") == \"11111111011111\"\n assert candidate(binary = \"000000000000000000000000000000000000000000000000000000000000000000000000\") == \"111111111111111111111111111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111\") == \"111111111111111111111111111111111111111111111111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(binary = \"1010101010101010101010101010101010101010101010101010101010101010\") == \"1111111111111111111111111111111101111111111111111111111111111111\"\n assert candidate(binary = \"11111100000000111\") == \"11111111111110111\"\n assert candidate(binary = \"01010101010101010101\") == \"11111111101111111111\"\n assert candidate(binary = \"10101010101010101010101010101010\") == \"11111111111111110111111111111111\"\n assert candidate(binary = \"0000111111110000\") == \"1111111011111111\"\n assert candidate(binary = \"00000000000011111111111111111111\") == \"11111111111011111111111111111111\"\n assert candidate(binary = \"001010101010\") == \"111111011111\"\n assert candidate(binary = \"1111111111111111\") == \"1111111111111111\"\n assert candidate(binary = \"1010101010\") == \"1111101111\"\n assert candidate(binary = \"0101010101010101\") == \"1111111011111111\"\n assert candidate(binary = \"00001111000011110000111100001111\") == \"11111111111111101111111111111111\"\n assert candidate(binary = \"0000000000000000000000000001\") == \"1111111111111111111111111101\"\n assert candidate(binary = \"11111111111111111111\") == \"11111111111111111111\"\n assert candidate(binary = \"000011110000\") == \"111111101111\"\n assert candidate(binary = \"000010101010101010101010101010101010101010101010\") == \"111111111111111111111111101111111111111111111111\"\n assert candidate(binary = \"11011011011011011\") == \"11111101111111111\"\n assert candidate(binary = \"00000010000000100000001000000010000000100000001\") == \"11111111111111111111111111111111111111110111111\"\n assert candidate(binary = \"11111100000000000000000000000000\") == \"11111111111111111111111111111110\"\n assert candidate(binary = \"11000000000000000000\") == \"11111111111111111110\"\n assert candidate(binary = \"1010101010101010\") == \"1111111101111111\"\n assert candidate(binary = \"110011001100\") == \"111111101111\"\n assert candidate(binary = \"00001111000011110000\") == \"11111111111011111111\"\n assert candidate(binary = \"00011110101010101010101010101010101010101010101\") == \"11111111111111111111110111111111111111111111111\"\n assert candidate(binary = \"11100001010101010100001111100001111000011110000\") == \"11111111111111111111111111101111111111111111111\"\n assert candidate(binary = \"001100110011\") == \"111110111111\"\n assert candidate(binary = \"01001001001001001001\") == \"11111111111101111111\"\n assert candidate(binary = \"0000001111110000001111\") == \"1111111111101111111111\"\n assert candidate(binary = \"111111111110\") == \"111111111110\"\n assert candidate(binary = \"00000000000001111\") == \"11111111111101111\"\n assert candidate(binary = \"101010100000\") == \"111111110111\"\n assert candidate(binary = \"11111111111111111\") == \"11111111111111111\"\n assert candidate(binary = \"00000000000000000000000000000000000000000000\") == \"11111111111111111111111111111111111111111110\"\n assert candidate(binary = \"00001010101010100\") == \"11111111110111111\"\n assert candidate(binary = \"01010101010101010\") == \"11111111011111111\"\n assert candidate(binary = \"10101010101010101\") == \"11111111011111111\"\n assert candidate(binary = \"0101010101010101010101010101010101010101010101010101\") == \"1111111111111111111111111011111111111111111111111111\"\n assert candidate(binary = \"00000000000000000000000000000001\") == \"11111111111111111111111111111101\"\n assert candidate(binary = \"010101010101010101010101010101010101010101010101\") == \"111111111111111111111110111111111111111111111111\"\n assert candidate(binary = \"1100000000000011\") == \"1111111111111011\"\n assert candidate(binary = \"11111111111111111111111111111111111111111111\") == \"11111111111111111111111111111111111111111111\"\n assert candidate(binary = \"00000000010000000000000000000000\") == \"11111111111111111111111111111101\"\n assert candidate(binary = \"11001100110011001\") == \"11111111101111111\"\n assert candidate(binary = \"101010101010101010101\") == \"111111111101111111111\"\n assert candidate(binary = \"111100001111\") == \"111111101111\"\n assert candidate(binary = \"00000000000000000000000000000000000000000000000000000000\") == \"11111111111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"1100110011001100\") == \"1111111110111111\"\n assert candidate(binary = \"111111111111\") == \"111111111111\"\n assert candidate(binary = \"0001100010001000\") == \"1111111111101111\"\n assert candidate(binary = \"0000000000000111111\") == \"1111111111110111111\"\n assert candidate(binary = \"1110000110001100\") == \"1111111111101111\"\n assert candidate(binary = \"111111111\") == \"111111111\"\n assert candidate(binary = \"0000000000000000000000000000000000000000000000000000000000000000000000000000\") == \"1111111111111111111111111111111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"11111111111111111111111111111111111111111111111111111111\") == \"11111111111111111111111111111111111111111111111111111111\"\n assert candidate(binary = \"1001001001001\") == \"1111111101111\"\n assert candidate(binary = \"000000000000000000000000000000000000000000000000\") == \"111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"010101010101\") == \"111110111111\"\n assert candidate(binary = \"00100100100100100100100100100100\") == \"11111111111111111111101111111111\"\n assert candidate(binary = \"11110000000000000\") == \"11111111111111110\"\n assert candidate(binary = \"11110000111100001111000011110000111100001111\") == \"11111111111111111111111011111111111111111111\"\n assert candidate(binary = \"0011001100110011\") == \"1111111011111111\"\n assert candidate(binary = \"11000000110000001100000011000000\") == \"11111111111111111111111110111111\"\n assert candidate(binary = \"01010101010101010101010101010101\") == \"11111111111111101111111111111111\"\n assert candidate(binary = \"111111111111111111111111111111111111111111111111\") == \"111111111111111111111111111111111111111111111111\"\n assert candidate(binary = \"00000000000000000000\") == \"11111111111111111110\"\n assert candidate(binary = \"110101010101\") == \"111111011111\"\n assert candidate(binary = \"01001010100101001\") == \"11111111101111111\"\n assert candidate(binary = \"1010101010101010101010101010101010101010101010101010\") == \"1111111111111111111111111101111111111111111111111111\"\n assert candidate(binary = \"0110110110110\") == \"1111011111111\"\n assert candidate(binary = \"00000000000000000000000000000000000000000000000000000000000000000000000\") == \"11111111111111111111111111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"11111111111111111111111111111110\") == \"11111111111111111111111111111110\"\n assert candidate(binary = \"0000000000000000\") == \"1111111111111110\"\n assert candidate(binary = \"1100101010100001\") == \"1111111111011111\"\n assert candidate(binary = \"01101101101101101\") == \"11111011111111111\"\n assert candidate(binary = \"11111111111111111111000000000000\") == \"11111111111111111111111111111110\"\n assert candidate(binary = \"11111111111111110\") == \"11111111111111110\"\n assert candidate(binary = \"000100010001\") == \"111111110111\"\n assert candidate(binary = \"1111111111\") == \"1111111111\"\n"}, "metadata": {"canonical_parameter_names": ["binary"], "leetcode_dataset_entry_point": "Solution().maximumBinaryString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumBinaryString(self, binary: str) -> str:", "container": "Solution", "callable": "maximumBinaryString", "parameters": [{"name": "binary", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1703, "task_id": "minimum-adjacent-swaps-for-k-consecutive-ones", "difficulty": "Hard", "problem_description": "You are given an integer array, nums, and an integer k. nums comprises of only 0's and 1's. In one move, you can choose two adjacent indices and swap their values.\nReturn the minimum number of moves required so that nums has k consecutive 1's.\n \nExample 1:\n\nInput: nums = [1,0,0,1,0,1], k = 2\nOutput: 1\nExplanation: In 1 move, nums could be [1,0,0,0,1,1] and have 2 consecutive 1's.\n\nExample 2:\n\nInput: nums = [1,0,0,0,0,0,1,1], k = 3\nOutput: 5\nExplanation: In 5 moves, the leftmost 1 can be shifted right until nums = [0,0,0,0,0,1,1,1].\n\nExample 3:\n\nInput: nums = [1,1,0,1], k = 2\nOutput: 0\nExplanation: nums already has 2 consecutive 1's.\n\n \nConstraints:\n\n1 <= nums.length <= 105\nnums[i] is 0 or 1.\n1 <= k <= sum(nums)\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 1, 1, 1, 0, 0, 1, 1, 1],k = 4) == 2\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == 6\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 1],k = 3) == 5\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1],k = 4) == 4\n assert candidate(nums = [1, 1, 1, 1, 1],k = 3) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 6\n assert candidate(nums = [0, 0, 1, 0, 1, 0, 1, 0, 1],k = 3) == 2\n assert candidate(nums = [0, 0, 1, 0, 1, 1, 0, 0, 1],k = 3) == 1\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1],k = 5) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1],k = 3) == 2\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 3) == 2\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 4) == 4\n assert candidate(nums = [1, 1, 0, 1],k = 2) == 0\n assert candidate(nums = [0, 0, 1, 0, 1, 0, 1, 0, 1],k = 4) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1],k = 4) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0],k = 2) == 1\n assert candidate(nums = [1, 0, 0, 1, 0, 1],k = 2) == 1\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 6) == 18\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 7) == 33\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1],k = 4) == 6\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],k = 3) == 12\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],k = 9) == 54\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0],k = 7) == 16\n assert candidate(nums = [0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1],k = 4) == 6\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],k = 4) == 28\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 10) == 75\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],k = 3) == 0\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 3) == 10\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],k = 3) == 6\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 5) == 24\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1],k = 6) == 9\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0],k = 5) == 5\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1],k = 6) == 14\n assert candidate(nums = [1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1],k = 6) == 13\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1],k = 4) == 6\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 5) == 12\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 6) == inf\n assert candidate(nums = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 5) == 12\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1],k = 6) == 20\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 8) == 16\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0],k = 5) == 15\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 7) == 12\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 12) == 36\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 6\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 8) == 32\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 4) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 25\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 4) == 4\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1],k = 9) == 18\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == 20\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 5) == 24\n assert candidate(nums = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 5\n assert candidate(nums = [0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0],k = 5) == 12\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0],k = 4) == 5\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 9) == 20\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2) == 9\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == 20\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 4) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 5) == 12\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1],k = 6) == 15\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],k = 6) == 24\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 7) == 24\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 3) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 7) == 12\n assert candidate(nums = [1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 10) == 25\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 7) == 24\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 7) == 24\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],k = 5) == 36\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1],k = 4) == 3\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 3) == 51\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1],k = 9) == 40\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 5) == 12\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 6) == 27\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 7) == 36\n assert candidate(nums = [1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 8) == 46\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 15) == 56\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0],k = 5) == 15\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 5) == 27\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1],k = 5) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2) == 14\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 11) == 30\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 7) == 24\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],k = 6) == 26\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 8) == 16\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 9) == 20\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 8) == inf\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 25\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 10) == 50\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 4) == 8\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 5) == 15\n assert candidate(nums = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 8) == 15\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0],k = 3) == 10\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minMoves", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minMoves(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "minMoves", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1704, "task_id": "determine-if-string-halves-are-alike", "difficulty": "Easy", "problem_description": "You are given a string s of even length. Split this string into two halves of equal lengths, and let a be the first half and b be the second half.\nTwo strings are alike if they have the same number of vowels ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'). Notice that s contains uppercase and lowercase letters.\nReturn true if a and b are alike. Otherwise, return false.\n \nExample 1:\n\nInput: s = \"book\"\nOutput: true\nExplanation: a = \"bo\" and b = \"ok\". a has 1 vowel and b has 1 vowel. Therefore, they are alike.\n\nExample 2:\n\nInput: s = \"textbook\"\nOutput: false\nExplanation: a = \"text\" and b = \"book\". a has 1 vowel whereas b has 2. Therefore, they are not alike.\nNotice that the vowel o is counted twice.\n\n \nConstraints:\n\n2 <= s.length <= 1000\ns.length is even.\ns consists of uppercase and lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"UFO\") == False\n assert candidate(s = \"aAeEiIoOuU\") == True\n assert candidate(s = \"Leetcode\") == True\n assert candidate(s = \"abcdefgihjklmno\") == False\n assert candidate(s = \"Regal\") == True\n assert candidate(s = \"Reinholdmes\") == True\n assert candidate(s = \"AbCdEfGh\") == True\n assert candidate(s = \"textbook\") == False\n assert candidate(s = \"cOdInGQuEsTiOn\") == False\n assert candidate(s = \"pYthOnPrOgRaMmInG\") == False\n assert candidate(s = \"AaEeIiOoUu\") == True\n assert candidate(s = \"leetcode\") == True\n assert candidate(s = \"Eve\") == False\n assert candidate(s = \"racecar\") == False\n assert candidate(s = \"VoIcE\") == True\n assert candidate(s = \"Madam\") == True\n assert candidate(s = \"abcdefgH\") == True\n assert candidate(s = \"Margelet\") == False\n assert candidate(s = \"book\") == True\n assert candidate(s = \"Uncopyrightable\") == True\n assert candidate(s = \"DAD\") == False\n assert candidate(s = \"MerryChristmas\") == False\n assert candidate(s = \"ComputerScience\") == False\n assert candidate(s = \"ArtificialIntelligence\") == False\n assert candidate(s = \"aAbBcCdDeEfFgG\") == True\n assert candidate(s = \"Supercalifragilisticexpialidocious\") == False\n assert candidate(s = \"InDiCoRn\") == False\n assert candidate(s = \"vowelvowelvowelvowelvowelvowel\") == True\n assert candidate(s = \"LyoPHiNiC\") == False\n assert candidate(s = \"VowelCOnsonAnt\") == False\n assert candidate(s = \"SyNtHeSiS\") == False\n assert candidate(s = \"CoMpUterScIeNcE\") == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == True\n assert candidate(s = \"Pneumonoultramicroscopicsilicovolcanoconiosis\") == False\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\") == False\n assert candidate(s = \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == True\n assert candidate(s = \"Supercalifragilisticexpialidocioussuper\") == False\n assert candidate(s = \"EqUiVaLeNt\") == False\n assert candidate(s = \"unevenNumberOfVowels\") == True\n assert candidate(s = \"MachineLearning\") == True\n assert candidate(s = \"QuantumComputing\") == True\n assert candidate(s = \"Pneumonoultramicroscopicsilicovolcanoconioses\") == False\n assert candidate(s = \"DeViScIoN\") == True\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == False\n assert candidate(s = \"CoRaL\") == True\n assert candidate(s = \"Internationalization\") == True\n assert candidate(s = \"CaSeInSeNsItIvE\") == True\n assert candidate(s = \"EvEnAnDdOuD\") == False\n assert candidate(s = \"CoMpLeX\") == True\n assert candidate(s = \"AbcDeFgHiJkLmNoPqRsTuVwXyZ\") == False\n assert candidate(s = \"Electroencephalographies\") == True\n assert candidate(s = \"fAcEtImE\") == True\n assert candidate(s = \"AnALoGuIzAtIoN\") == True\n assert candidate(s = \"sImPlEVoWaElStRiNg\") == True\n assert candidate(s = \"OpenAIChatGPT\") == False\n assert candidate(s = \"Incomprehensibility\") == False\n assert candidate(s = \"ThEoReTiCaL\") == False\n assert candidate(s = \"VoWaElCoUnTiNg\") == True\n assert candidate(s = \"SiMpLy\") == False\n assert candidate(s = \"Electroencephalography\") == False\n assert candidate(s = \"Honorificabilitudinitatibus\") == False\n assert candidate(s = \"ConsonantsToo\") == True\n assert candidate(s = \"abcdefghijABCDEFGHIJ\") == True\n assert candidate(s = \"METHINKSITISLIKEALITTLEIODEUCALYPTUS\") == False\n assert candidate(s = \"Alphabetization\") == False\n assert candidate(s = \"HumanComputerInteraction\") == True\n assert candidate(s = \"AmOrAnGe\") == True\n assert candidate(s = \"balancedString\") == False\n assert candidate(s = \"EuPoCrAtIc\") == False\n assert candidate(s = \"MississippiRiverOdd\") == False\n assert candidate(s = \"RoMaNiCa\") == True\n assert candidate(s = \"aAaAaAaAaAbBbBbBbB\") == False\n assert candidate(s = \"MiwEldrom\") == False\n assert candidate(s = \"AQuickBrownFoxJumpsOverTheLazyDog\") == False\n assert candidate(s = \"MaRiNo\") == False\n assert candidate(s = \"CloudComputing\") == False\n assert candidate(s = \"DataScienceAndML\") == False\n assert candidate(s = \"Hippopotomonstrosesquippedaliophobia\") == False\n assert candidate(s = \"ImAgInAtIoN\") == True\n assert candidate(s = \"Pseudopseudohypoparathyroidism\") == True\n assert candidate(s = \"PaLInDoRoMa\") == True\n assert candidate(s = \"DatabaseManagement\") == True\n assert candidate(s = \"ComplexExample\") == False\n assert candidate(s = \"sYmMeTrIcVoWaEl\") == False\n assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\") == False\n assert candidate(s = \"cOmPlExStRiNgWitHaLoTOfVoWels\") == False\n assert candidate(s = \"AlEpInAtIoN\") == True\n assert candidate(s = \"AEIOUaeiouAEIOUaeiou\") == True\n assert candidate(s = \"Environmental\") == False\n assert candidate(s = \"SyMmEtrY\") == False\n assert candidate(s = \"PaLInDrOmE\") == True\n assert candidate(s = \"Interpolation\") == False\n assert candidate(s = \"Floccinaucinihilipilifications\") == True\n assert candidate(s = \"AlphabetSymmetry\") == False\n assert candidate(s = \"BiChRoChO\") == True\n assert candidate(s = \"SoftwareEngineering\") == True\n assert candidate(s = \"Mississippi\") == False\n assert candidate(s = \"NaturalLanguageProcessing\") == True\n assert candidate(s = \"VowelsInBoth\") == True\n assert candidate(s = \"FLUtTuAtIoNs\") == False\n assert candidate(s = \"SuPeRaLpHaBeT\") == False\n assert candidate(s = \"MaLiNoUs\") == True\n assert candidate(s = \"InternetOfThings\") == False\n assert candidate(s = \"PeRuKkIa\") == True\n assert candidate(s = \"TrAnSaPoRt\") == False\n assert candidate(s = \"OddAndEven\") == True\n assert candidate(s = \"aEiOuUoIeA\") == True\n assert candidate(s = \"Alphabetical\") == False\n assert candidate(s = \"VowelsAEIOUaeiou\") == False\n assert candidate(s = \"aEiOuUeIoA\") == True\n assert candidate(s = \"SeNtEnCe\") == False\n assert candidate(s = \"RepetitionRepetition\") == True\n assert candidate(s = \"MississippiRiver\") == True\n assert candidate(s = \"Vowelsareeverywhere\") == False\n assert candidate(s = \"vowelvowelvowelvowel\") == True\n assert candidate(s = \"DataStructure\") == True\n assert candidate(s = \"MississippiRiverside\") == False\n assert candidate(s = \"aeiouAEIOUaeiouAEIOU\") == True\n assert candidate(s = \"XiLoPhOnE\") == False\n assert candidate(s = \"Floccinaucinihilipilification\") == False\n assert candidate(s = \"PythonCoding\") == False\n assert candidate(s = \"VowelsAreVowels\") == True\n assert candidate(s = \"aEiOuUaEiO\") == True\n assert candidate(s = \"NotSoBalanced\") == False\n assert candidate(s = \"Engineering\") == False\n assert candidate(s = \"SuBiT\") == True\n assert candidate(s = \"ProgrammingIsFun\") == False\n assert candidate(s = \"aEiOuAeIoU\") == True\n assert candidate(s = \"Alphabetically\") == False\n assert candidate(s = \"PyThOnIsFuN\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == False\n assert candidate(s = \"AnNiHaLiLaToR\") == True\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(s = \"consonantsAEIOUconsonants\") == False\n assert candidate(s = \"Thyroparathyroidectomized\") == False\n assert candidate(s = \"EvenlyDistributed\") == True\n assert candidate(s = \"DataAnalysis\") == False\n assert candidate(s = \"CyberSecurity\") == False\n assert candidate(s = \"VoCaBuLaRy\") == True\n assert candidate(s = \"AEIOUaeiou\") == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s = \"CaThODoRiC\") == True\n assert candidate(s = \"AlGoRiThM\") == False\n assert candidate(s = \"Antidisestablishmentarianism\") == False\n assert candidate(s = \"CoNtRoVeRtEdbUt\") == False\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == False\n assert candidate(s = \"BaLaNcEd\") == False\n assert candidate(s = \"BlockchainTechnology\") == True\n assert candidate(s = \"SystemAnalysis\") == True\n assert candidate(s = \"VowelsAndConsonants\") == True\n assert candidate(s = \"hAlFVaLuEs\") == False\n assert candidate(s = \"AlphabetSoup\") == False\n assert candidate(s = \"Unbelievable\") == True\n assert candidate(s = \"SplittingStrings\") == False\n assert candidate(s = \"GrApHiTe\") == False\n assert candidate(s = \"AnAgrAm\") == False\n assert candidate(s = \"evenNumberOfVowels\") == False\n assert candidate(s = \"RoTiCoRn\") == False\n assert candidate(s = \"bYtEcOdE\") == False\n assert candidate(s = \"BigDataAnalytics\") == False\n assert candidate(s = \"FLYINGDUCK\") == True\n assert candidate(s = \"ComplexityAnalysis\") == True\n assert candidate(s = \"VowelsAreEven\") == False\n assert candidate(s = \"cHiCaGo\") == True\n assert candidate(s = \"PythonIsAwesome\") == False\n assert candidate(s = \"FeBrIfIoN\") == False\n assert candidate(s = \"Electroencephalographically\") == True\n assert candidate(s = \"mIxEdCaSeTeStStRiNg\") == False\n assert candidate(s = \"ProgrammingLanguage\") == True\n assert candidate(s = \"MississippiUniversity\") == False\n assert candidate(s = \"equalvowelcounts\") == False\n assert candidate(s = \"EnvironmentalStudies\") == True\n assert candidate(s = \"InDeXeS\") == False\n assert candidate(s = \"Supercalifragilisticexpialidociousxyz\") == False\n assert candidate(s = \"xyzXYZxyzXYZ\") == True\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().halvesAreAlike", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def halvesAreAlike(self, s: str) -> bool:", "container": "Solution", "callable": "halvesAreAlike", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1705, "task_id": "maximum-number-of-eaten-apples", "difficulty": "Medium", "problem_description": "There is a special kind of apple tree that grows apples every day for n days. On the ith day, the tree grows apples[i] apples that will rot after days[i] days, that is on day i + days[i] the apples will be rotten and cannot be eaten. On some days, the apple tree does not grow any apples, which are denoted by apples[i] == 0 and days[i] == 0.\nYou decided to eat at most one apple a day (to keep the doctors away). Note that you can keep eating after the first n days.\nGiven two integer arrays days and apples of length n, return the maximum number of apples you can eat.\n \nExample 1:\n\nInput: apples = [1,2,3,5,2], days = [3,2,1,4,2]\nOutput: 7\nExplanation: You can eat 7 apples:\n- On the first day, you eat an apple that grew on the first day.\n- On the second day, you eat an apple that grew on the second day.\n- On the third day, you eat an apple that grew on the second day. After this day, the apples that grew on the third day rot.\n- On the fourth to the seventh days, you eat apples that grew on the fourth day.\n\nExample 2:\n\nInput: apples = [3,0,0,0,0,2], days = [3,0,0,0,0,2]\nOutput: 5\nExplanation: You can eat 5 apples:\n- On the first to the third day you eat apples that grew on the first day.\n- Do nothing on the fouth and fifth days.\n- On the sixth and seventh days you eat apples that grew on the sixth day.\n\n \nConstraints:\n\nn == apples.length == days.length\n1 <= n <= 2 * 104\n0 <= apples[i], days[i] <= 2 * 104\ndays[i] = 0 if and only if apples[i] = 0.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(apples = [0, 0, 0, 0],days = [0, 0, 0, 0]) == 0\n assert candidate(apples = [1, 3, 2],days = [3, 5, 2]) == 6\n assert candidate(apples = [5, 5, 5, 5, 5],days = [1, 2, 3, 4, 5]) == 9\n assert candidate(apples = [5, 5, 5, 5, 5],days = [1, 1, 1, 1, 1]) == 5\n assert candidate(apples = [0, 0, 0, 5, 0, 6],days = [0, 0, 0, 5, 0, 4]) == 6\n assert candidate(apples = [5, 4, 3, 2, 1],days = [1, 2, 3, 4, 5]) == 8\n assert candidate(apples = [1, 2, 3, 5, 2],days = [3, 2, 1, 4, 2]) == 7\n assert candidate(apples = [3, 0, 0, 0, 0, 2],days = [3, 0, 0, 0, 0, 2]) == 5\n assert candidate(apples = [2, 1, 10],days = [2, 10, 1]) == 4\n assert candidate(apples = [4, 2, 2, 3, 1],days = [3, 2, 10, 1, 2]) == 7\n assert candidate(apples = [0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [20, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 10\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(apples = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0],days = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0]) == 10\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == 20\n assert candidate(apples = [3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0],days = [10, 9, 8, 0, 0, 0, 0, 0, 0, 0, 0]) == 6\n assert candidate(apples = [10, 20, 30, 40, 50],days = [1, 2, 3, 4, 5]) == 9\n assert candidate(apples = [3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0],days = [5, 4, 3, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5]) == 12\n assert candidate(apples = [10, 0, 20, 0, 30, 0, 40, 0, 50, 0],days = [5, 0, 4, 0, 3, 0, 2, 0, 1, 0]) == 9\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(apples = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],days = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0]) == 5\n assert candidate(apples = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],days = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0]) == 10\n assert candidate(apples = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],days = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 79\n assert candidate(apples = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(apples = [10, 20, 0, 0, 15, 10],days = [5, 5, 0, 0, 3, 3]) == 8\n assert candidate(apples = [3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1],days = [2, 0, 0, 5, 0, 0, 0, 0, 0, 0, 2, 2]) == 6\n assert candidate(apples = [0, 0, 10, 0, 0, 0, 0, 0, 10, 0],days = [0, 0, 1, 0, 0, 0, 0, 0, 2, 0]) == 3\n assert candidate(apples = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(apples = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(apples = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],days = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(apples = [1, 3, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 4\n assert candidate(apples = [5, 4, 3, 2, 1],days = [5, 4, 3, 2, 1]) == 5\n assert candidate(apples = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],days = [20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 2\n assert candidate(apples = [3, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7],days = [2, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6]) == 17\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 29\n assert candidate(apples = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],days = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(apples = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],days = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(apples = [10, 15, 0, 20, 25, 0, 0, 30],days = [3, 4, 0, 5, 6, 0, 0, 7]) == 14\n assert candidate(apples = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10],days = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10]) == 27\n assert candidate(apples = [10, 0, 10, 0, 10, 0, 10],days = [3, 0, 3, 0, 3, 0, 3]) == 9\n assert candidate(apples = [3, 2, 1, 0, 0, 4, 2, 1, 0, 1],days = [2, 2, 2, 0, 0, 3, 2, 2, 0, 1]) == 9\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(apples = [4, 0, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0],days = [5, 0, 4, 3, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0]) == 9\n assert candidate(apples = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0],days = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == 13\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 100, 100],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 15, 15]) == 17\n assert candidate(apples = [2, 4, 6, 8, 10],days = [1, 2, 3, 4, 5]) == 9\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(apples = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],days = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 13\n assert candidate(apples = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 5\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(apples = [10, 0, 5, 0, 0, 15],days = [10, 0, 4, 0, 0, 3]) == 10\n assert candidate(apples = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(apples = [5, 0, 0, 5, 0, 5, 0, 5, 0, 5],days = [1, 0, 0, 2, 0, 3, 0, 4, 0, 5]) == 12\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(apples = [2, 3, 1, 0, 0, 0, 0, 4, 5, 6, 0, 0, 0, 0, 7],days = [2, 2, 2, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 4]) == 13\n assert candidate(apples = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0],days = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 12\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [10, 20, 0, 0, 15, 10, 5],days = [5, 4, 0, 0, 6, 3, 2]) == 10\n assert candidate(apples = [10, 0, 20, 0, 30, 0, 40, 0, 50, 0, 60, 0, 70, 0, 80, 0, 90, 0, 100, 0],days = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == 23\n assert candidate(apples = [0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0]) == 7\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 32\n assert candidate(apples = [1, 2, 0, 4, 5, 0, 0, 6, 7, 0, 0, 8, 9],days = [3, 2, 0, 4, 5, 0, 0, 2, 3, 0, 0, 2, 3]) == 15\n assert candidate(apples = [100, 100, 100, 100, 100],days = [5, 5, 5, 5, 5]) == 9\n assert candidate(apples = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(apples = [2, 3, 1, 5, 4, 2, 3, 1, 1, 1, 1],days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 17\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n"}, "metadata": {"canonical_parameter_names": ["apples", "days"], "leetcode_dataset_entry_point": "Solution().eatenApples", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def eatenApples(self, apples: list[int], days: list[int]) -> int:", "container": "Solution", "callable": "eatenApples", "parameters": [{"name": "apples", "type": "list[int]"}, {"name": "days", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1706, "task_id": "where-will-the-ball-fall", "difficulty": "Medium", "problem_description": "You have a 2-D grid of size m x n representing a box, and you have n balls. The box is open on the top and bottom sides.\nEach cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left.\n\nA board that redirects the ball to the right spans the top-left corner to the bottom-right corner and is represented in the grid as 1.\nA board that redirects the ball to the left spans the top-right corner to the bottom-left corner and is represented in the grid as -1.\n\nWe drop one ball at the top of each column of the box. Each ball can get stuck in the box or fall out of the bottom. A ball gets stuck if it hits a \"V\" shaped pattern between two boards or if a board redirects the ball into either wall of the box.\nReturn an array answer of size n where answer[i] is the column that the ball falls out of at the bottom after dropping the ball from the ith column at the top, or -1 if the ball gets stuck in the box.\n \nExample 1:\n\n\nInput: grid = [[1,1,1,-1,-1],[1,1,1,-1,-1],[-1,-1,-1,1,1],[1,1,1,1,-1],[-1,-1,-1,-1,-1]]\nOutput: [1,-1,-1,-1,-1]\nExplanation: This example is shown in the photo.\nBall b0 is dropped at column 0 and falls out of the box at column 1.\nBall b1 is dropped at column 1 and will get stuck in the box between column 2 and 3 and row 1.\nBall b2 is dropped at column 2 and will get stuck on the box between column 2 and 3 and row 0.\nBall b3 is dropped at column 3 and will get stuck on the box between column 2 and 3 and row 0.\nBall b4 is dropped at column 4 and will get stuck on the box between column 2 and 3 and row 1.\n\nExample 2:\n\nInput: grid = [[-1]]\nOutput: [-1]\nExplanation: The ball gets stuck against the left wall.\n\nExample 3:\n\nInput: grid = [[1,1,1,1,1,1],[-1,-1,-1,-1,-1,-1],[1,1,1,1,1,1],[-1,-1,-1,-1,-1,-1]]\nOutput: [0,1,2,3,4,-1]\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 100\ngrid[i][j] is 1 or -1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == [-1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]]) == [-1, -1, -1]\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [-1, -1, -1]]) == [1, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1], [1, 1, 1, -1, -1], [-1, -1, -1, 1, 1], [1, 1, 1, 1, -1], [-1, -1, -1, -1, -1]]) == [1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1], [1, 1, -1, 1, 1], [-1, 1, 1, -1, 1], [1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1]\n assert candidate(grid = [[-1]]) == [-1]\n assert candidate(grid = [[1, 1, -1, -1], [1, 1, -1, -1], [-1, -1, 1, 1], [-1, -1, 1, 1]]) == [-1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, -1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, 1, -1, -1, -1, -1], [1, 1, 1, 1, -1, 1, 1, 1, 1, 1], [1, -1, -1, 1, 1, -1, 1, -1, -1, 1]]) == [-1, 1, 4, -1, -1, -1, -1, 7, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, -1, -1], [-1, -1, -1, 1, 1, -1], [1, 1, -1, -1, 1, 1], [1, -1, 1, -1, -1, 1], [-1, 1, -1, 1, 1, -1]]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1]]) == [-1, -1, -1, 2, -1, -1, -1, 6, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, -1, 1, -1], [1, -1, 1, -1, 1, 1, 1], [-1, 1, 1, -1, 1, 1, -1], [1, -1, 1, 1, -1, 1, 1], [-1, 1, -1, -1, 1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, -1, 1, 1, 1, -1], [-1, -1, -1, 1, 1, 1, -1, -1, -1, 1], [1, 1, 1, -1, -1, -1, 1, 1, 1, -1], [-1, -1, -1, 1, 1, 1, -1, -1, -1, 1]]) == [0, 1, -1, -1, 4, 5, 6, 7, -1, -1]\n assert candidate(grid = [[-1, -1, 1, 1, -1, -1, 1, 1, -1, -1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1]]) == [-1, 1, 2, -1, -1, 5, 6, -1, -1, 9]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1]\n assert candidate(grid = [[-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, 1, 1, 1, -1, -1, -1, -1, 1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, -1, 1, 1, -1, -1, 1, 1, -1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, 8, -1, -1]\n assert candidate(grid = [[-1, -1, -1, 1, 1, 1, 1, 1, 1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]]) == [4, 5, -1, -1, -1, -1, -1, -1, -1, -1, 6]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, 1, -1], [1, -1, 1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, 1, -1, 1, -1], [1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [-1, 0, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1], [1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, 1, -1, -1, 1, 1, -1, 1], [-1, 1, -1, 1, -1, -1, 1, 1, -1, 1], [1, -1, 1, 1, -1, -1, 1, 1, -1, 1], [-1, 1, -1, 1, -1, -1, 1, 1, -1, 1], [1, -1, 1, 1, -1, -1, 1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1]]) == [-1, -1, -1, 2, -1, -1, -1, 6, -1, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, -1, -1, 1, 1, 1, 1], [-1, -1, -1, 1, 1, -1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, 1, 1, -1, -1], [1, -1, 1, -1, -1, 1, 1, -1, 1, -1]]) == [-1, -1, 6, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, -1, 1], [1, -1, 1, -1, 1, 1], [-1, 1, 1, -1, 1, 1], [1, -1, 1, 1, -1, 1], [-1, 1, -1, -1, 1, 1]]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1]]) == [-1, 2, -1, -1, 3, 6, 7, -1, -1, -1, 11, -1, -1, -1, -1, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, -1, -1, -1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, -1, -1, -1, -1, 1, 1], [-1, -1, -1, -1, 1, 1, 1, 1, -1, -1], [1, 1, 1, 1, -1, -1, -1, -1, 1, 1], [-1, -1, -1, -1, 1, 1, 1, 1, -1, -1]]) == [-1, 0, 1, 2, 5, 6, 7, 8, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, -1, -1, -1, -1, 1, 1], [1, -1, -1, -1, 1, 1, 1, 1, -1, -1], [-1, 1, 1, 1, -1, -1, -1, -1, 1, 1], [1, -1, -1, -1, 1, 1, 1, 1, -1, -1]]) == [-1, 1, 2, -1, -1, 5, 6, 7, 8, -1]\n assert candidate(grid = [[1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1], [-1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1], [1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1], [-1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, -1, -1, -1, -1, -1, -1, -1, -1, 18]\n assert candidate(grid = [[1, 1, 1, -1, -1, -1, 1, 1, 1], [1, -1, -1, 1, 1, -1, -1, 1, -1], [-1, 1, -1, -1, 1, -1, 1, -1, 1], [1, 1, -1, 1, -1, 1, -1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]]) == [4, -1, -1, -1, -1, -1, -1, -1, -1, 5]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1], [1, -1, 1, 1, -1, -1, 1, 1, -1], [-1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, 1, -1, 1, -1, 1, 1, -1], [-1, 1, -1, -1, 1, -1, 1, -1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, 1, -1, 1, -1, 1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, -1, -1, -1, 1, 1, 1, 1, -1, -1], [-1, -1, 1, 1, 1, 1, -1, -1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, 0, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [-1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1], [1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [-1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1]]) == [0, 1, -1, -1, 4, 5, 6, -1, -1, 9, 10, 11, -1, -1, 14, 15, 16, -1, -1, 19]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, -1, 1, 1, 1, -1], [-1, -1, -1, 1, 1, 1, -1, -1, -1, 1], [1, 1, 1, -1, -1, -1, 1, 1, 1, -1], [-1, -1, -1, 1, 1, 1, -1, -1, -1, 1], [1, 1, 1, -1, -1, -1, 1, 1, 1, -1]]) == [1, 2, -1, -1, 3, 4, 7, 8, -1, -1]\n assert candidate(grid = [[1, -1, 1, 1, -1, -1, 1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, -1, 1, 1, -1, 1, -1, -1, 1, -1], [1, 1, -1, -1, 1, -1, 1, -1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().findBall", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findBall(self, grid: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "findBall", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1707, "task_id": "maximum-xor-with-an-element-from-array", "difficulty": "Hard", "problem_description": "You are given an array nums consisting of non-negative integers. You are also given a queries array, where queries[i] = [xi, mi].\nThe answer to the ith query is the maximum bitwise XOR value of xi and any element of nums that does not exceed mi. In other words, the answer is max(nums[j] XOR xi) for all j such that nums[j] <= mi. If all elements in nums are larger than mi, then the answer is -1.\nReturn an integer array answer where answer.length == queries.length and answer[i] is the answer to the ith query.\n \nExample 1:\n\nInput: nums = [0,1,2,3,4], queries = [[3,1],[1,3],[5,6]]\nOutput: [3,3,7]\nExplanation:\n1) 0 and 1 are the only two integers not greater than 1. 0 XOR 3 = 3 and 1 XOR 3 = 2. The larger of the two is 3.\n2) 1 XOR 2 = 3.\n3) 5 XOR 2 = 7.\n\nExample 2:\n\nInput: nums = [5,2,4,6,6,3], queries = [[12,4],[8,1],[6,3]]\nOutput: [15,-1,5]\n\n \nConstraints:\n\n1 <= nums.length, queries.length <= 105\nqueries[i].length == 2\n0 <= nums[j], xi, mi <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 4, 8, 16],queries = [[10, 15], [30, 20], [5, 5]]) == [14, 31, 7]\n assert candidate(nums = [100, 200, 300, 400],queries = [[150, 250], [10, 100], [450, 500]]) == [242, 110, 422]\n assert candidate(nums = [7, 8, 9],queries = [[1, 5], [6, 8], [10, 12]]) == [-1, 14, 13]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[1, 10], [2, 5], [3, 3], [4, 4], [5, 2], [6, 6], [7, 7], [8, 8], [9, 9], [10, 1]]) == [11, 7, 2, 7, 7, 7, 6, 15, 15, 11]\n assert candidate(nums = [1000000000],queries = [[1000000000, 1000000000], [999999999, 999999999]]) == [0, -1]\n assert candidate(nums = [5, 2, 4, 6, 6, 3],queries = [[12, 4], [8, 1], [6, 3]]) == [15, -1, 5]\n assert candidate(nums = [0, 1, 2, 3, 4],queries = [[3, 1], [1, 3], [5, 6]]) == [3, 3, 7]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [[9, 10], [99, 100], [999, 1000], [9999, 10000], [99999, 100000], [999999, 1000000], [9999999, 10000000], [99999999, 100000000], [999999999, 1000000000], [0, 1]]) == [8, 105, 1005, 10091, 106895, 1008943, 10031327, 100311743, 1047472383, 1]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],queries = [[1000000000, 999999999], [999999998, 999999997], [999999996, 999999995], [999999995, 1000000000]]) == [1023, 3, -1, 1019]\n assert candidate(nums = [1, 1, 1, 1, 1],queries = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 0], [1, 0], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == [-1, -1, 3, 2, 5, 4, 7, 6, 9, 8]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],queries = [[7, 7], [7, 6], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15]]) == [0, -1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384],queries = [[1024, 2047], [2048, 4095], [4096, 8191], [8192, 16383], [16384, 32767], [32768, 16384], [65536, 8192]]) == [0, 3072, 6144, 12288, 24576, 49152, 73728]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],queries = [[1000000000, 999999999], [999999998, 999999997], [999999996, 999999995], [999999994, 999999993], [999999992, 999999991], [999999990, 999999989], [999999988, 999999987], [999999986, 999999985], [999999984, 999999983], [999999982, 999999981]]) == [1023, 9, 11, 13, 15, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400],queries = [[10, 100], [150, 200], [250, 300], [350, 400], [400, 450], [500, 550]]) == [110, 242, 470, 456, 500, 400]\n assert candidate(nums = [1024, 2048, 3072, 4096, 5120, 6144, 7168, 8192, 9216],queries = [[512, 1024], [1536, 2048], [2560, 3072], [3584, 4096], [4608, 5120], [5632, 6144], [6656, 7168], [7680, 8192], [8704, 9216]]) == [1536, 3584, 3584, 7680, 7680, 7680, 7680, 15872, 15872]\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643],queries = [[2147483647, 2147483647], [2147483646, 2147483646], [2147483645, 2147483645], [2147483644, 2147483644], [2147483643, 2147483643]]) == [4, 5, 6, 7, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10], [100, 0]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],queries = [[0, 31], [1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21], [11, 20], [12, 19], [13, 18], [14, 17], [15, 16]]) == [31, 28, 31, 26, 31, 28, 31, 22, 31, 28, 31, 26, 31, 28, 31, 14]\n assert candidate(nums = [1000000000, 900000000, 800000000, 700000000, 600000000],queries = [[1000000000, 1000000000], [900000000, 900000000], [800000000, 800000000], [700000000, 700000000], [600000000, 600000000], [500000000, 500000000]]) == [408521728, 471715328, 208424448, 175792384, 0, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[50, 350], [150, 450], [250, 550], [350, 650], [450, 750], [550, 850], [650, 950], [750, 1050], [850, 1150], [950, 1250]]) == [286, 442, 470, 774, 922, 978, 934, 962, 922, 978]\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003, 1000000004],queries = [[1000000000, 1000000004], [1000000001, 1000000002], [1000000002, 1000000001], [1000000003, 1000000003], [1000000004, 1000000000]]) == [4, 3, 3, 3, 4]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],queries = [[1024, 512], [512, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1], [1, 1]]) == [1536, 768, 384, 192, 96, 48, 24, 12, 6, 3, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [0, 3, 2, 7, 6, 7, 6, 15, 14, 15]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19]]) == [3, 7, 7, 15, 15, 15, 15, 31, 31, 31]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],queries = [[0, 1], [1, 2], [3, 4], [7, 8], [15, 16], [31, 32], [63, 64], [127, 128], [255, 256], [511, 512], [1023, 1024], [2047, 2048], [4095, 4096], [8191, 8192], [16383, 16384], [32767, 32768], [65535, 65536], [131071, 131072], [262143, 262144], [524287, 524288], [1048575, 1048576]]) == [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],queries = [[1, 2], [3, 4], [7, 8], [15, 16], [31, 32], [63, 64], [127, 128], [255, 256], [511, 512], [1023, 1024]]) == [3, 7, 15, 31, 63, 127, 255, 511, 1023, 1022]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],queries = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19], [22, 21], [24, 23], [26, 25], [28, 27], [30, 29], [32, 31]]) == [3, 7, 7, 15, 15, 15, 15, 31, 31, 31, 31, 31, 31, 31, 31, 63]\n assert candidate(nums = [23, 31, 12, 22, 19, 30, 27, 14, 29, 25],queries = [[10, 30], [35, 35], [23, 23], [19, 20], [30, 31]]) == [29, 62, 27, 31, 18]\n assert candidate(nums = [1000000000, 900000000, 800000000, 700000000, 600000000, 500000000, 400000000, 300000000, 200000000, 100000000],queries = [[1100000000, 1000000000], [950000000, 900000000], [850000000, 800000000], [750000000, 700000000], [650000000, 600000000], [550000000, 500000000], [450000000, 400000000], [350000000, 300000000], [250000000, 200000000], [150000000, 100000000]]) == [2047500544, 1030371456, 960641664, 1029026944, 997413760, 1023750272, 522687872, 523719040, 185815936, 218443904]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[5, 10], [15, 25], [25, 35], [35, 45], [45, 55], [55, 65], [65, 75], [75, 85], [85, 95], [95, 105]]) == [15, 27, 19, 61, 57, 61, 125, 121, 125, 119]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[50, 150], [250, 350], [450, 550], [650, 750], [850, 950], [1050, 1150]]) == [86, 470, 422, 934, 922, 2034]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],queries = [[1, 5], [10, 50], [100, 500], [1000, 5000], [10000, 50000], [100000, 500000], [1000000, 1500000]]) == [0, 11, 110, 1001, 10100, 106928, 1008976]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19]]) == [-1, 1, 7, 5, 15, 15, 15, 13, 31, 31]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [5, 100], [105, 100]]) == [0, 30, 20, 60, 56, 54, 122, 120, 114, 122, 97, 125]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[2, 10], [4, 20], [6, 30], [8, 40], [10, 50], [12, 60], [14, 70], [16, 80], [18, 90], [20, 100]]) == [11, 23, 23, 27, 27, 31, 31, 31, 31, 31]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == [0, 2, 6, 6, 14, 14, 14, 14, 30, 30]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [[1, 1], [5, 10], [50, 100], [500, 1000], [5000, 10000], [50000, 100000], [500000, 1000000], [5000000, 10000000], [50000000, 100000000], [500000000, 1000000000]]) == [0, 15, 86, 540, 13464, 83440, 582496, 13950400, 118428032, 643280640]\n assert candidate(nums = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22],queries = [[32, 31], [33, 30], [34, 29], [35, 28], [36, 27], [37, 26], [38, 25], [39, 24], [40, 23], [41, 22]]) == [63, 63, 63, 63, 63, 63, 63, 63, 63, 63]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],queries = [[100, 100], [101, 101], [102, 102], [103, 103], [104, 104], [105, 105], [106, 106], [107, 107], [108, 108], [109, 109]]) == [0, 1, 3, 3, 15, 15, 15, 15, 11, 11]\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505],queries = [[100, 200], [300, 400], [500, 600], [700, 800], [800, 700], [900, 1000]]) == [31, 486, 401, 915, 1002, 1023]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[5, 50], [15, 30], [25, 40], [35, 60], [45, 70], [55, 80], [65, 90], [75, 100], [85, 20], [95, 10]]) == [55, 27, 49, 61, 107, 113, 125, 121, 95, 85]\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],queries = [[500, 1024], [256, 256], [1025, 1025], [10, 20], [2, 3]]) == [1524, 384, 1537, 26, 3]\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643],queries = [[1, 2147483647], [2, 2147483646], [3, 2147483645], [4, 2147483644], [5, 2147483643]]) == [2147483647, 2147483647, 2147483647, 2147483647, 2147483646]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],queries = [[1, 1], [2, 2], [3, 4], [5, 8], [9, 16], [17, 32], [33, 64], [65, 128], [129, 256], [257, 512], [513, 1024], [1025, 2048], [2049, 4096], [4097, 8192], [8193, 16384], [16385, 32768]]) == [0, 3, 7, 13, 25, 49, 97, 193, 385, 769, 1537, 3073, 6145, 12289, 24577, 49153]\n assert candidate(nums = [50, 40, 30, 20, 10],queries = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70], [75, 80], [85, 90], [95, 100]]) == [15, 27, 19, 61, 57, 61, 115, 121, 125, 119]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[101, 99], [201, 199], [301, 299], [401, 399], [501, 499], [601, 599], [701, 699], [801, 799], [901, 899], [1001, 999]]) == [-1, 173, 485, 501, 401, 969, 913, 1001, 993, 909]\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384],queries = [[512, 1024], [1536, 2048], [2560, 4096], [4608, 8192], [8704, 16384], [32768, 65536]]) == [1536, 3584, 6656, 12800, 25088, 49152]\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],queries = [[100, 123], [400, 456], [700, 789], [100000, 101112], [130000, 131415], [160000, 161718], [190000, 192021], [220000, 222324], [250000, 252627], [280000, 282930]]) == [31, 491, 884, 100200, 260743, 261112, 224456, 219931, 250757, 499475]\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500],queries = [[50, 100], [250, 350], [375, 400], [500, 500], [100, 99]]) == [86, 470, 481, 400, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [1, 3, 3, 7, 7, 7, 7, 15, 15, 15]\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99],queries = [[8, 9], [17, 18], [26, 27], [35, 36], [44, 45], [53, 54], [62, 63], [71, 72], [80, 81], [89, 90], [98, 99]]) == [1, 24, 19, 56, 62, 60, 55, 120, 125, 125, 121]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],queries = [[999, 1000], [1999, 2000], [2999, 3000], [3999, 4000], [4999, 5000], [5999, 6000], [6999, 7000], [7999, 8000], [8999, 9000], [9999, 10000]]) == [15, 1063, 3175, 3191, 7207, 7383, 7303, 7383, 15463, 15447]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 100], [12, 100], [13, 100], [14, 100], [15, 100], [16, 100], [17, 100], [18, 100], [19, 100], [20, 100]]) == [11, 22, 29, 44, 55, 58, 65, 88, 89, 110, 111, 104, 105, 106, 107, 116, 117, 118, 119, 112]\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],queries = [[8, 9], [17, 18], [26, 27], [35, 36], [44, 45], [53, 54], [62, 63], [71, 72], [80, 81], [89, 90], [91, 90]]) == [1, 24, 19, 56, 62, 60, 55, 120, 125, 125, 127]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[2, 5], [4, 9], [6, 13], [8, 17], [10, 19], [12, 21], [14, 23], [16, 25], [18, 27], [20, 29]]) == [7, 13, 15, 25, 27, 31, 31, 31, 31, 31]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],queries = [[10, 9], [7, 6], [1, 10], [8, 5], [0, 0]]) == [15, 6, 8, 13, -1]\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021],queries = [[122, 123], [455, 456], [788, 789], [101111, 101112], [131414, 131415], [161717, 161718], [192020, 192021], [200000, 210000]]) == [1, 444, 879, 101183, 232366, 261453, 222444, 200277]\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000],queries = [[1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [125000000, 125000000], [62500000, 62500000], [31250000, 31250000], [15625000, 15625000]]) == [1021940544, 510970272, 255485136, 127742568, 56084360, 20102520, 0]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[1, 15], [2, 14], [3, 13], [4, 12], [5, 11], [6, 10], [7, 9], [8, 8], [9, 7], [10, 6], [11, 5], [12, 4], [13, 3], [14, 2], [15, 1]]) == [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],queries = [[2, 10], [4, 12], [6, 14], [8, 16], [10, 18], [12, 20], [14, 22], [16, 24], [18, 26], [20, 28], [22, 30], [24, 10], [26, 12], [28, 14], [30, 16]]) == [11, 15, 15, 15, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31]\n assert candidate(nums = [100, 200, 300, 400, 500],queries = [[150, 200], [250, 350], [350, 450], [50, 150], [450, 500]]) == [242, 470, 406, 86, 422]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [[1, 1000000000], [2, 100000000], [3, 10000000], [4, 1000000], [5, 100000], [6, 10000], [7, 1000], [8, 100], [9, 10], [10, 1]]) == [1000000001, 100000002, 10000003, 1000004, 100005, 10006, 1007, 108, 8, 11]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],queries = [[1000000000, 1000000000], [1, 1000000000], [1000000000, 999999999], [1, 999999999], [1000000000, 999999998]]) == [1023, 1000000001, 1023, 999999999, 1022]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],queries = [[1, 2], [2, 4], [3, 8], [4, 16], [5, 32], [6, 64], [7, 128], [8, 256], [9, 512], [10, 1024], [11, 2048], [12, 4096], [13, 8192], [14, 16384], [15, 32768]]) == [3, 6, 11, 20, 37, 70, 135, 264, 521, 1034, 2059, 4108, 8205, 16398, 16399]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],queries = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512], [1024, 1024], [2048, 2048], [4096, 4096], [8192, 8192], [16384, 16384], [32768, 16384]]) == [0, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152]\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109],queries = [[11, 30], [22, 40], [33, 50], [44, 60], [55, 70], [66, 80], [77, 90], [88, 100], [99, 110], [100, 120]]) == [30, 54, 52, 57, 118, 116, 123, 120, 118, 113]\n assert candidate(nums = [8, 4, 2, 1, 16, 32, 64, 128, 256, 512],queries = [[7, 8], [3, 4], [1, 2], [15, 16], [31, 32], [63, 64], [127, 128], [255, 256], [511, 512], [1023, 1024]]) == [15, 7, 3, 31, 63, 127, 255, 511, 1023, 1022]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],queries = [[2, 3], [5, 6], [8, 9], [11, 12], [14, 15], [17, 18], [20, 21], [23, 24], [26, 27], [29, 30], [31, 32]]) == [1, 6, 14, 13, 13, 30, 29, 30, 28, 30, 28]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[15, 10], [25, 20], [35, 30], [45, 40], [55, 50], [65, 60], [75, 70], [85, 80], [95, 90], [105, 100]]) == [5, 19, 61, 57, 61, 125, 121, 125, 119, 125]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],queries = [[1, 1], [2, 2], [3, 4], [5, 8], [9, 16], [17, 32], [33, 64], [65, 128], [129, 256], [257, 512]]) == [0, 3, 7, 13, 25, 49, 97, 193, 385, 769]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],queries = [[1000000000, 999999999], [999999998, 999999998], [999999997, 999999996], [999999996, 999999995]]) == [1023, 3, 1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],queries = [[2, 10], [4, 12], [6, 14], [8, 16], [10, 18], [12, 20], [14, 22], [16, 24], [18, 26], [20, 28], [22, 30], [24, 32], [26, 34], [28, 36], [30, 38]]) == [11, 15, 15, 15, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31]\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666],queries = [[100000000, 300000000], [200000000, 400000000], [300000000, 500000000], [400000000, 600000000], [500000000, 700000000], [600000000, 800000000], [700000000, 900000000], [800000000, 1000000000], [900000000, 1100000000], [1000000000, 1200000000]]) == [233694804, 406159701, 525840523, 919248611, 1020297187, 968812828, 979854421, 1014057813, 1035791956, 1023779271]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 1], [2, 1], [0, 1], [10, 1], [100, 1]]) == [0, 3, 1, 11, 101]\n assert candidate(nums = [23, 45, 67, 89, 111, 135, 159, 183, 207, 231],queries = [[22, 23], [44, 45], [66, 67], [88, 89], [110, 111], [134, 135], [158, 159], [182, 183], [206, 207], [230, 231]]) == [1, 59, 111, 117, 121, 233, 241, 245, 227, 241]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],queries = [[100, 105], [101, 101], [102, 103], [103, 107], [104, 104], [105, 108], [106, 106], [107, 109], [108, 110], [109, 100], [110, 102]]) == [13, 1, 3, 15, 15, 15, 15, 15, 11, 9, 11]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[99, 100], [150, 300], [250, 250], [350, 400], [450, 500], [550, 600], [650, 700], [750, 800], [850, 900], [950, 1000]]) == [7, 442, 158, 406, 422, 978, 934, 962, 922, 978]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],queries = [[1, 2], [2, 3], [3, 5], [4, 7], [5, 11], [6, 13], [7, 17], [8, 19], [9, 23], [10, 29]]) == [3, 1, 6, 7, 14, 13, 22, 27, 30, 29]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23]]) == [7, 7, 15, 15, 15, 15, 31, 31, 31, 31]\n"}, "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().maximizeXor", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximizeXor(self, nums: list[int], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "maximizeXor", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1710, "task_id": "maximum-units-on-a-truck", "difficulty": "Easy", "problem_description": "You are assigned to put some amount of boxes onto one truck. You are given a 2D array boxTypes, where boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]:\n\nnumberOfBoxesi is the number of boxes of type i.\nnumberOfUnitsPerBoxi is the number of units in each box of the type i.\n\nYou are also given an integer truckSize, which is the maximum number of boxes that can be put on the truck. You can choose any boxes to put on the truck as long as the number of boxes does not exceed truckSize.\nReturn the maximum total number of units that can be put on the truck.\n \nExample 1:\n\nInput: boxTypes = [[1,3],[2,2],[3,1]], truckSize = 4\nOutput: 8\nExplanation: There are:\n- 1 box of the first type that contains 3 units.\n- 2 boxes of the second type that contain 2 units each.\n- 3 boxes of the third type that contain 1 unit each.\nYou can take all the boxes of the first and second types, and one box of the third type.\nThe total number of units will be = (1 * 3) + (2 * 2) + (1 * 1) = 8.\n\nExample 2:\n\nInput: boxTypes = [[5,10],[2,5],[4,7],[3,9]], truckSize = 10\nOutput: 91\n\n \nConstraints:\n\n1 <= boxTypes.length <= 1000\n1 <= numberOfBoxesi, numberOfUnitsPerBoxi <= 1000\n1 <= truckSize <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(boxTypes = [[1, 3], [2, 2], [3, 1]],truckSize = 4) == 8\n assert candidate(boxTypes = [[1, 1], [2, 2], [3, 3], [4, 4]],truckSize = 1) == 4\n assert candidate(boxTypes = [[2, 1], [4, 4], [3, 3]],truckSize = 5) == 19\n assert candidate(boxTypes = [[10, 1], [20, 2], [30, 3]],truckSize = 50) == 130\n assert candidate(boxTypes = [[5, 10], [2, 5], [4, 7], [3, 9]],truckSize = 10) == 91\n assert candidate(boxTypes = [[1, 100], [2, 99], [3, 98], [4, 97]],truckSize = 10) == 980\n assert candidate(boxTypes = [[10, 1], [5, 2], [3, 3]],truckSize = 10) == 21\n assert candidate(boxTypes = [[100, 1], [99, 2], [98, 3], [97, 4]],truckSize = 200) == 692\n assert candidate(boxTypes = [[10, 1]],truckSize = 10) == 10\n assert candidate(boxTypes = [[1, 1000], [1000, 1]],truckSize = 500) == 1499\n assert candidate(boxTypes = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60]],truckSize = 10) == 800\n assert candidate(boxTypes = [[5, 5], [5, 5], [5, 5], [5, 5]],truckSize = 15) == 75\n assert candidate(boxTypes = [[2, 1], [3, 2], [4, 3], [5, 4], [6, 5]],truckSize = 15) == 62\n assert candidate(boxTypes = [[2, 1000], [1, 900], [2, 800], [1, 700], [2, 600], [1, 500], [2, 400], [1, 300], [2, 200], [1, 100]],truckSize = 10) == 7300\n assert candidate(boxTypes = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]],truckSize = 20) == 115\n assert candidate(boxTypes = [[5, 10], [1, 15], [3, 12], [2, 14], [4, 8]],truckSize = 15) == 161\n assert candidate(boxTypes = [[7, 10], [5, 3], [2, 6], [8, 1]],truckSize = 20) == 103\n assert candidate(boxTypes = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5]],truckSize = 15) == 35\n assert candidate(boxTypes = [[5, 10], [4, 20], [3, 30], [2, 40], [1, 50]],truckSize = 15) == 350\n assert candidate(boxTypes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],truckSize = 5) == 40\n assert candidate(boxTypes = [[9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],truckSize = 30) == 174\n assert candidate(boxTypes = [[999, 1], [1, 999], [500, 500], [250, 250], [125, 125]],truckSize = 1000) == 329248\n assert candidate(boxTypes = [[1, 5], [2, 3], [3, 2], [4, 1]],truckSize = 10) == 21\n assert candidate(boxTypes = [[50, 10], [100, 9], [150, 8], [200, 7], [250, 6], [300, 5]],truckSize = 800) == 5750\n assert candidate(boxTypes = [[50, 5], [30, 6], [20, 7]],truckSize = 100) == 570\n assert candidate(boxTypes = [[3, 100], [2, 200], [1, 300], [5, 400]],truckSize = 5) == 2000\n assert candidate(boxTypes = [[20, 5], [15, 10], [10, 15], [5, 20], [1, 25]],truckSize = 35) == 445\n assert candidate(boxTypes = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],truckSize = 20) == 18900\n assert candidate(boxTypes = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50]],truckSize = 40) == 1400\n assert candidate(boxTypes = [[50, 10], [30, 20], [20, 30], [10, 40], [5, 50]],truckSize = 120) == 2350\n assert candidate(boxTypes = [[200, 1], [100, 2], [150, 3], [50, 4], [250, 5]],truckSize = 500) == 2000\n assert candidate(boxTypes = [[100, 1], [50, 2], [25, 3], [10, 4], [5, 5], [1, 6]],truckSize = 150) == 305\n assert candidate(boxTypes = [[20, 25], [15, 30], [10, 35], [5, 40]],truckSize = 50) == 1500\n assert candidate(boxTypes = [[10, 10], [5, 7], [15, 5], [20, 3]],truckSize = 25) == 185\n assert candidate(boxTypes = [[50, 10], [30, 20], [20, 30], [10, 40]],truckSize = 100) == 2000\n assert candidate(boxTypes = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],truckSize = 150) == 5500\n assert candidate(boxTypes = [[1, 900], [2, 800], [3, 700], [4, 600], [5, 500], [6, 400], [7, 300], [8, 200], [9, 100]],truckSize = 15) == 9500\n assert candidate(boxTypes = [[1, 999], [2, 998], [3, 997], [4, 996], [5, 995], [6, 994], [7, 993], [8, 992], [9, 991], [10, 990]],truckSize = 20) == 19915\n assert candidate(boxTypes = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],truckSize = 55) == 220\n assert candidate(boxTypes = [[30, 20], [20, 15], [10, 10], [40, 5], [50, 2]],truckSize = 100) == 1200\n assert candidate(boxTypes = [[10, 30], [20, 20], [30, 10], [40, 5], [50, 1]],truckSize = 60) == 1000\n assert candidate(boxTypes = [[50, 10], [40, 20], [30, 30], [20, 40], [10, 50]],truckSize = 120) == 3200\n assert candidate(boxTypes = [[500, 1000], [400, 900], [300, 800], [200, 700], [100, 600]],truckSize = 1200) == 1100000\n assert candidate(boxTypes = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],truckSize = 150) == 1450\n assert candidate(boxTypes = [[100, 10], [200, 9], [150, 8], [50, 7], [25, 6]],truckSize = 300) == 2800\n assert candidate(boxTypes = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],truckSize = 50) == 215\n assert candidate(boxTypes = [[500, 100], [300, 200], [200, 300], [100, 400]],truckSize = 800) == 180000\n assert candidate(boxTypes = [[50, 100], [25, 200], [75, 50], [100, 250]],truckSize = 200) == 36250\n assert candidate(boxTypes = [[1, 999], [999, 1]],truckSize = 1000) == 1998\n assert candidate(boxTypes = [[7, 9], [7, 8], [7, 7], [7, 6], [7, 5], [7, 4], [7, 3], [7, 2], [7, 1]],truckSize = 20) == 161\n assert candidate(boxTypes = [[3, 8], [5, 7], [2, 9], [6, 10], [4, 5]],truckSize = 15) == 130\n assert candidate(boxTypes = [[5, 10], [4, 20], [3, 30], [2, 40], [1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [1, 100]],truckSize = 20) == 750\n assert candidate(boxTypes = [[50, 20], [100, 15], [150, 10], [200, 5], [250, 1]],truckSize = 500) == 5000\n assert candidate(boxTypes = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996]],truckSize = 15) == 14960\n assert candidate(boxTypes = [[5, 10], [5, 20], [5, 30], [5, 40], [5, 50], [5, 60], [5, 70], [5, 80], [5, 90], [5, 100]],truckSize = 25) == 2000\n assert candidate(boxTypes = [[10, 1000], [9, 900], [8, 800], [7, 700], [6, 600], [5, 500], [4, 400], [3, 300], [2, 200], [1, 100]],truckSize = 25) == 22900\n assert candidate(boxTypes = [[100, 5], [200, 2], [50, 10], [150, 3]],truckSize = 350) == 1550\n assert candidate(boxTypes = [[50, 100], [40, 99], [30, 98], [20, 97], [10, 96], [5, 95]],truckSize = 160) == 15275\n assert candidate(boxTypes = [[1, 500], [1, 400], [1, 300], [1, 200], [1, 100]],truckSize = 2) == 900\n assert candidate(boxTypes = [[3, 9], [2, 8], [5, 7], [1, 6], [4, 5]],truckSize = 15) == 104\n assert candidate(boxTypes = [[10, 20], [20, 10], [30, 5], [40, 2], [50, 1]],truckSize = 100) == 630\n assert candidate(boxTypes = [[300, 1], [200, 2], [100, 3], [50, 4], [25, 5]],truckSize = 700) == 1325\n assert candidate(boxTypes = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996]],truckSize = 15) == 14960\n assert candidate(boxTypes = [[5, 15], [10, 12], [20, 9], [30, 7], [40, 5], [50, 3]],truckSize = 150) == 920\n assert candidate(boxTypes = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],truckSize = 500) == 3740\n assert candidate(boxTypes = [[5, 15], [20, 3], [5, 20], [10, 7]],truckSize = 25) == 260\n assert candidate(boxTypes = [[100, 10], [50, 20], [20, 30], [10, 40]],truckSize = 200) == 3000\n assert candidate(boxTypes = [[100, 2], [200, 3], [300, 4], [400, 5], [500, 6]],truckSize = 1000) == 5400\n assert candidate(boxTypes = [[100, 1], [50, 2], [25, 3], [12, 4], [6, 5], [3, 6], [1, 7]],truckSize = 200) == 378\n assert candidate(boxTypes = [[50, 10], [40, 9], [30, 8], [20, 7], [10, 6], [5, 5], [1, 4]],truckSize = 160) == 1329\n assert candidate(boxTypes = [[100, 500], [50, 1000], [10, 2000]],truckSize = 200) == 120000\n assert candidate(boxTypes = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],truckSize = 50) == 374\n assert candidate(boxTypes = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],truckSize = 500) == 37400\n assert candidate(boxTypes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],truckSize = 10) == 55\n assert candidate(boxTypes = [[1, 500], [2, 400], [3, 300], [4, 200], [5, 100]],truckSize = 10) == 3000\n assert candidate(boxTypes = [[30, 4], [10, 20], [15, 5]],truckSize = 50) == 375\n assert candidate(boxTypes = [[100, 10], [200, 9], [300, 8], [400, 7]],truckSize = 1000) == 8000\n assert candidate(boxTypes = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],truckSize = 1) == 50\n assert candidate(boxTypes = [[10, 100], [5, 200], [3, 300], [2, 400], [1, 500]],truckSize = 20) == 4100\n assert candidate(boxTypes = [[10, 5], [5, 10], [15, 3]],truckSize = 18) == 109\n assert candidate(boxTypes = [[10, 5], [20, 8], [30, 2], [5, 9]],truckSize = 40) == 265\n assert candidate(boxTypes = [[10, 10], [20, 9], [30, 8], [40, 7], [50, 6], [60, 5], [70, 4], [80, 3], [90, 2], [100, 1]],truckSize = 250) == 1560\n assert candidate(boxTypes = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5]],truckSize = 30) == 120\n assert candidate(boxTypes = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]],truckSize = 15) == 11000\n assert candidate(boxTypes = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700], [80, 800], [90, 900]],truckSize = 300) == 230000\n assert candidate(boxTypes = [[500, 500], [500, 500], [500, 500]],truckSize = 1000) == 500000\n assert candidate(boxTypes = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],truckSize = 1000) == 4400\n assert candidate(boxTypes = [[50, 20], [30, 15], [40, 10], [20, 5]],truckSize = 100) == 1650\n assert candidate(boxTypes = [[10, 5], [20, 3], [30, 4], [40, 2], [50, 1]],truckSize = 100) == 310\n assert candidate(boxTypes = [[10, 500], [20, 450], [30, 400], [40, 350], [50, 300], [60, 250], [70, 200], [80, 150], [90, 100], [100, 50]],truckSize = 200) == 67500\n assert candidate(boxTypes = [[3, 2], [2, 5], [6, 1], [10, 3]],truckSize = 12) == 40\n assert candidate(boxTypes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],truckSize = 30) == 266\n assert candidate(boxTypes = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [10, 6], [9, 7], [8, 8], [7, 9], [6, 10]],truckSize = 50) == 340\n assert candidate(boxTypes = [[100, 10], [200, 5], [300, 1]],truckSize = 500) == 2200\n assert candidate(boxTypes = [[1, 100], [10, 90], [100, 80], [1000, 70], [10000, 60]],truckSize = 5000) == 312340\n assert candidate(boxTypes = [[10, 5], [9, 4], [8, 3], [7, 2], [6, 1]],truckSize = 20) == 89\n assert candidate(boxTypes = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5]],truckSize = 250) == 1050\n assert candidate(boxTypes = [[50, 10], [50, 20], [50, 30], [50, 40], [50, 50]],truckSize = 150) == 6000\n assert candidate(boxTypes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],truckSize = 15) == 145\n assert candidate(boxTypes = [[50, 1], [200, 2], [100, 3], [30, 4], [10, 5]],truckSize = 250) == 690\n assert candidate(boxTypes = [[1, 1000], [1, 999], [1, 998], [1, 997], [1, 996], [1, 995], [1, 994], [1, 993], [1, 992], [1, 991]],truckSize = 10) == 9955\n assert candidate(boxTypes = [[10, 100], [20, 90], [30, 80], [40, 70], [50, 60]],truckSize = 200) == 11000\n assert candidate(boxTypes = [[100, 100], [90, 90], [80, 80], [70, 70], [60, 60], [50, 50]],truckSize = 500) == 35500\n assert candidate(boxTypes = [[20, 1], [20, 2], [20, 3], [20, 4], [20, 5], [20, 6], [20, 7], [20, 8], [20, 9], [20, 10]],truckSize = 100) == 800\n"}, "metadata": {"canonical_parameter_names": ["boxTypes", "truckSize"], "leetcode_dataset_entry_point": "Solution().maximumUnits", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumUnits(self, boxTypes: list[list[int]], truckSize: int) -> int:", "container": "Solution", "callable": "maximumUnits", "parameters": [{"name": "boxTypes", "type": "list[list[int]]"}, {"name": "truckSize", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1711, "task_id": "count-good-meals", "difficulty": "Medium", "problem_description": "A good meal is a meal that contains exactly two different food items with a sum of deliciousness equal to a power of two.\nYou can pick any two different foods to make a good meal.\nGiven an array of integers deliciousness where deliciousness[i] is the deliciousness of the i​​​​​​th​​​​​​​​ item of food, return the number of different good meals you can make from this list modulo 109 + 7.\nNote that items with different indices are considered different even if they have the same deliciousness value.\n \nExample 1:\n\nInput: deliciousness = [1,3,5,7,9]\nOutput: 4\nExplanation: The good meals are (1,3), (1,7), (3,5) and, (7,9).\nTheir respective sums are 4, 8, 8, and 16, all of which are powers of 2.\n\nExample 2:\n\nInput: deliciousness = [1,1,1,3,3,3,7]\nOutput: 15\nExplanation: The good meals are (1,1) with 3 ways, (1,3) with 9 ways, and (1,7) with 3 ways.\n \nConstraints:\n\n1 <= deliciousness.length <= 105\n0 <= deliciousness[i] <= 220\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(deliciousness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(deliciousness = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 15\n assert candidate(deliciousness = [0, 0, 0, 0, 0, 0]) == 0\n assert candidate(deliciousness = [0, 0]) == 0\n assert candidate(deliciousness = [2, 2, 2, 3, 3, 3, 4, 4, 4]) == 6\n assert candidate(deliciousness = [1048576, 1048576, 524288, 524288, 262144, 262144]) == 3\n assert candidate(deliciousness = [1]) == 0\n assert candidate(deliciousness = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(deliciousness = [1048576, 1048576]) == 1\n assert candidate(deliciousness = [13, 100, 13]) == 0\n assert candidate(deliciousness = [1, 3, 5, 7, 9]) == 4\n assert candidate(deliciousness = [1, 1, 1, 3, 3, 3, 7]) == 15\n assert candidate(deliciousness = [1, 0, 0, 0, 0]) == 4\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32]) == 0\n assert candidate(deliciousness = [1023, 1024, 512, 512, 256, 256, 128, 128, 64, 64, 32, 32, 16, 16, 8, 8, 4, 4, 2, 2, 1, 1]) == 12\n assert candidate(deliciousness = [1048576, 1, 1, 1, 1]) == 6\n assert candidate(deliciousness = [1, 1048575, 1048575, 1048576]) == 2\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 0\n assert candidate(deliciousness = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]) == 5\n assert candidate(deliciousness = [1, 100000, 200000, 300000, 400000]) == 0\n assert candidate(deliciousness = [220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220]) == 0\n assert candidate(deliciousness = [0, 0, 0, 0]) == 0\n assert candidate(deliciousness = [1048576, 1048576]) == 1\n assert candidate(deliciousness = [2, 2, 2, 2, 2]) == 10\n assert candidate(deliciousness = [1, 1048575]) == 1\n assert candidate(deliciousness = [0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 9]) == 10\n assert candidate(deliciousness = [31, 1, 4, 3, 12, 13, 8, 16, 7]) == 5\n assert candidate(deliciousness = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(deliciousness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(deliciousness = [1048575, 1048576, 524287, 524288, 262143, 262144, 131071, 131072, 65535, 65536, 32767, 32768, 16383, 16384, 8191, 8192, 4095, 4096, 2047, 2048, 1023, 1024, 511, 512, 255, 256, 127, 128, 63, 64, 31, 32, 15, 16, 7, 8, 3, 4, 1, 2, 0, 0, 0, 0, 0, 0]) == 145\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(deliciousness = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(deliciousness = [1048575, 1048574, 1048573, 1048572, 1048571, 1048570]) == 0\n assert candidate(deliciousness = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 28\n assert candidate(deliciousness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 11\n assert candidate(deliciousness = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31]) == 249\n assert candidate(deliciousness = [2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 20\n assert candidate(deliciousness = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]) == 3\n assert candidate(deliciousness = [5, 1, 4, 3, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 15\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 0\n assert candidate(deliciousness = [21, 1, 17, 3, 9, 18, 25, 33]) == 1\n assert candidate(deliciousness = [1023, 1024, 2047, 2048, 3071, 3072, 4095, 4096]) == 1\n assert candidate(deliciousness = [1023, 1024, 1025, 2047, 2048, 2049, 4095, 4096, 4097]) == 3\n assert candidate(deliciousness = [1, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455]) == 9\n assert candidate(deliciousness = [1023, 1024, 2047, 2048, 4095, 4096, 8191, 8192]) == 0\n assert candidate(deliciousness = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127]) == 0\n assert candidate(deliciousness = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 14\n assert candidate(deliciousness = [5, 15, 1, 3, 7, 9, 11, 13]) == 7\n assert candidate(deliciousness = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047]) == 0\n assert candidate(deliciousness = [1048575, 1048576, 2097151, 2097152, 4194303, 4194304]) == 0\n assert candidate(deliciousness = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 19\n assert candidate(deliciousness = [1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575]) == 0\n assert candidate(deliciousness = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == 10\n assert candidate(deliciousness = [1023, 1024, 2047, 2048, 4095, 4096]) == 0\n assert candidate(deliciousness = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151]) == 21\n assert candidate(deliciousness = [21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845]) == 0\n assert candidate(deliciousness = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]) == 0\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n assert candidate(deliciousness = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 0\n assert candidate(deliciousness = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 16\n assert candidate(deliciousness = [1, 1048575, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 1\n assert candidate(deliciousness = [0, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845]) == 0\n assert candidate(deliciousness = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 15\n assert candidate(deliciousness = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512]) == 10\n assert candidate(deliciousness = [1, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 13\n assert candidate(deliciousness = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 3\n assert candidate(deliciousness = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(deliciousness = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 100\n assert candidate(deliciousness = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128]) == 0\n assert candidate(deliciousness = [3, 5, 7, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 154\n assert candidate(deliciousness = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) == 5\n assert candidate(deliciousness = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 90\n assert candidate(deliciousness = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 0\n assert candidate(deliciousness = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 12\n assert candidate(deliciousness = [220, 440, 880, 1760, 3520, 7040, 14080, 28160, 56320, 112640, 225280, 450560, 901120, 1802240, 3604480, 7208960, 14417920, 28835840, 57671680, 115343360]) == 0\n assert candidate(deliciousness = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 0\n assert candidate(deliciousness = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(deliciousness = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]) == 61\n assert candidate(deliciousness = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 0\n assert candidate(deliciousness = [1, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 11\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n assert candidate(deliciousness = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 19\n assert candidate(deliciousness = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 26\n assert candidate(deliciousness = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 65\n assert candidate(deliciousness = [1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == 41\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 0\n assert candidate(deliciousness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 26\n assert candidate(deliciousness = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == 8\n assert candidate(deliciousness = [15, 9, 8, 7, 3, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 135\n assert candidate(deliciousness = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1, 1, 1]) == 6\n assert candidate(deliciousness = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n assert candidate(deliciousness = [22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22]) == 0\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 0\n assert candidate(deliciousness = [524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == 20\n assert candidate(deliciousness = [65535, 65536, 131071, 131072, 262143, 262144]) == 0\n assert candidate(deliciousness = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(deliciousness = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]) == 3\n assert candidate(deliciousness = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 12\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]) == 0\n"}, "metadata": {"canonical_parameter_names": ["deliciousness"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countPairs(self, deliciousness: list[int]) -> int:", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "deliciousness", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1712, "task_id": "ways-to-split-array-into-three-subarrays", "difficulty": "Medium", "problem_description": "A split of an integer array is good if:\n\nThe array is split into three non-empty contiguous subarrays - named left, mid, right respectively from left to right.\nThe sum of the elements in left is less than or equal to the sum of the elements in mid, and the sum of the elements in mid is less than or equal to the sum of the elements in right.\n\nGiven nums, an array of non-negative integers, return the number of good ways to split nums. As the number may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [1,1,1]\nOutput: 1\nExplanation: The only good way to split nums is [1] [1] [1].\nExample 2:\n\nInput: nums = [1,2,2,2,5,0]\nOutput: 3\nExplanation: There are three good ways of splitting nums:\n[1] [2] [2,2,5,0]\n[1] [2,2] [2,5,0]\n[1,2] [2,2] [5,0]\n\nExample 3:\n\nInput: nums = [3,2,1]\nOutput: 0\nExplanation: There is no good way to split nums.\n \nConstraints:\n\n3 <= nums.length <= 105\n0 <= nums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10000, 10000, 10000]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 12\n assert candidate(nums = [1, 3, 2, 3, 1, 1, 1, 3, 2, 3]) == 9\n assert candidate(nums = [9, 4, 2, 5, 1]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 15\n assert candidate(nums = [1, 3, 2, 4, 1, 2, 3, 4]) == 6\n assert candidate(nums = [1, 1, 1]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 8\n assert candidate(nums = [10, 4, -8, 7]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10]) == 2\n assert candidate(nums = [1, 3, 1, 1, 2]) == 1\n assert candidate(nums = [3, 2, 1]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 6\n assert candidate(nums = [1, 2, 2, 2, 5, 0]) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 2]) == 0\n assert candidate(nums = [1, 3, 2, 2, 1, 1]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 160\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 74\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 36\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 292\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 37\n assert candidate(nums = [1000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000]) == 34\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 463\n assert candidate(nums = [10000, 10000, 10000, 10000, 0, 10000, 10000, 10000, 10000]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 184\n assert candidate(nums = [10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 4\n assert candidate(nums = [15000, 14000, 13000, 12000, 11000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 4\n assert candidate(nums = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 28\n assert candidate(nums = [1, 3, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 163\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 171\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 16\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]) == 37\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 320\n assert candidate(nums = [1, 3, 2, 4, 2, 3, 4, 2, 5, 1]) == 9\n assert candidate(nums = [9, 3, 5, 7, 3, 5, 7, 3, 5, 7, 3, 5, 7, 3, 5, 7, 3, 5, 7, 3]) == 26\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 33\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 108\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 33\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 1\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 36\n assert candidate(nums = [50000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 33\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 110\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 24\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 16\n assert candidate(nums = [100, 50, 50, 25, 25, 25, 25, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 3\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000, 180000, 190000, 200000]) == 70\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 53\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 71\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 406\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 33\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 8\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 184\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 16\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 171\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 71\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 50000]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 33\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 385\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 91\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 36\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 163\n assert candidate(nums = [1, 3, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 39\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 31\n assert candidate(nums = [5, 1, 4, 2, 2, 1]) == 1\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 75\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 75\n assert candidate(nums = [1, 10000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 31\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 17\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 154\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980]) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 70\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 16\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 21\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 161\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 70\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 19\n assert candidate(nums = [100, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 46\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 37\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 21\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().waysToSplit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def waysToSplit(self, nums: list[int]) -> int:", "container": "Solution", "callable": "waysToSplit", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1713, "task_id": "minimum-operations-to-make-a-subsequence", "difficulty": "Hard", "problem_description": "You are given an array target that consists of distinct integers and another integer array arr that can have duplicates.\nIn one operation, you can insert any integer at any position in arr. For example, if arr = [1,4,1,2], you can add 3 in the middle and make it [1,4,3,1,2]. Note that you can insert the integer at the very beginning or end of the array.\nReturn the minimum number of operations needed to make target a subsequence of arr.\nA subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the remaining elements' relative order. For example, [2,7,4] is a subsequence of [4,2,3,7,2,1,4] (the underlined elements), while [2,4,2] is not.\n \nExample 1:\n\nInput: target = [5,1,3], arr = [9,4,2,3,4]\nOutput: 2\nExplanation: You can add 5 and 1 in such a way that makes arr = [5,9,4,1,2,3,4], then target will be a subsequence of arr.\n\nExample 2:\n\nInput: target = [6,4,8,1,3,2], arr = [4,7,6,2,3,8,6,1]\nOutput: 3\n\n \nConstraints:\n\n1 <= target.length, arr.length <= 105\n1 <= target[i], arr[i] <= 109\ntarget contains no duplicates.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 4, 3, 2, 1]) == 4\n assert candidate(target = [3, 1, 5, 8, 9],arr = [1, 5, 3, 8, 9]) == 1\n assert candidate(target = [1],arr = [1, 1, 1, 1]) == 0\n assert candidate(target = [6, 4, 8, 1, 3, 2],arr = [4, 7, 6, 2, 3, 8, 6, 1]) == 3\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [1, 2, 3],arr = [1, 2, 3, 1, 2, 3]) == 0\n assert candidate(target = [1, 3, 5, 7],arr = [2, 4, 6, 8]) == 4\n assert candidate(target = [1, 2, 3, 4, 5],arr = [1, 2, 3, 4, 5]) == 0\n assert candidate(target = [1, 3, 5, 7, 9],arr = [2, 4, 6, 8, 10]) == 5\n assert candidate(target = [1, 2, 3],arr = [4, 5, 6]) == 3\n assert candidate(target = [10, 20, 30],arr = [10, 15, 20, 25, 30]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 4\n assert candidate(target = [1],arr = [1]) == 0\n assert candidate(target = [10, 20, 30, 40],arr = [10, 20, 5, 30, 40]) == 0\n assert candidate(target = [100, 200, 300],arr = [1, 2, 3, 100, 200, 300]) == 0\n assert candidate(target = [1, 2, 3],arr = [3, 2, 1]) == 2\n assert candidate(target = [5, 1, 3],arr = [9, 4, 2, 3, 4]) == 2\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [100, 200, 300, 400, 500],arr = [100, 500, 200, 400, 300, 100, 500, 200, 400, 300]) == 1\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 12\n assert candidate(target = [1, 2, 3, 4, 5],arr = [2, 3, 1, 4, 5, 2, 3, 1, 4, 5, 2, 3, 1, 4, 5]) == 0\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [100, 200, 300, 400, 500],arr = [50, 150, 250, 350, 450, 550, 650, 100, 200, 300, 400, 500]) == 0\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [7, 14, 21, 28, 35],arr = [35, 28, 21, 14, 7, 35, 28, 21, 14, 7]) == 3\n assert candidate(target = [1, 2, 3, 4, 5],arr = [3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(target = [1, 3, 5, 7, 9],arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == 0\n assert candidate(target = [1, 3, 2, 4],arr = [4, 3, 2, 1, 1, 2, 3, 4]) == 1\n assert candidate(target = [7, 11, 13, 17, 19, 23, 29, 31],arr = [19, 23, 31, 7, 11, 13, 17, 29, 37, 41, 43, 47]) == 3\n assert candidate(target = [7, 11, 15, 20, 25, 30, 35, 40, 45, 50],arr = [50, 45, 40, 35, 30, 25, 20, 15, 11, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49]) == 9\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(target = [1, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41],arr = [41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 1, 43, 45, 47, 49, 51]) == 19\n assert candidate(target = [5, 3, 8, 12, 9, 11],arr = [3, 5, 8, 12, 9, 11, 14, 15, 16, 17, 18, 19]) == 1\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr = [10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996],arr = [999999998, 999999997, 999999996, 1000000000, 999999999]) == 2\n assert candidate(target = [7, 5, 3, 1],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 10, 20, 30, 40, 50]) == 5\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 2\n assert candidate(target = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],arr = [1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 10\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],arr = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 9\n assert candidate(target = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 1, 9, 7, 3, 2, 8]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 1, 3, 2, 4]) == 2\n assert candidate(target = [5, 3, 8, 6, 2, 7, 4, 1],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 1\n assert candidate(target = [1, 10, 100, 1000, 10000, 100000],arr = [10, 100, 1000, 10000, 100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(target = [1, 5, 9, 13, 17, 21],arr = [21, 17, 13, 9, 5, 1, 14, 10, 6, 2, 18, 12, 8, 4]) == 5\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [10, 90, 20, 80, 30, 70, 40, 60, 50, 100]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(target = [5, 1, 4, 2, 3],arr = [1, 5, 4, 2, 3, 1, 5, 4, 2, 3, 1, 5, 4, 2, 3, 1, 5, 4, 2, 3]) == 0\n assert candidate(target = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 0\n assert candidate(target = [10, 20, 30, 40, 50, 60],arr = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 0\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],arr = [1000000000, 999999998, 999999996, 999999994, 999999992, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, 12, 13, 14, 15, 0, 16, 17]) == 4\n assert candidate(target = [1, 10, 100, 1000, 10000],arr = [1, 1, 1, 1, 10, 10, 10, 10, 100, 100, 100, 100, 1000, 1000, 1000, 1000, 10000, 10000, 10000, 10000]) == 0\n assert candidate(target = [1, 5, 10, 15, 20],arr = [1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 10, 10, 10, 15, 15, 20]) == 0\n assert candidate(target = [100, 200, 300, 400, 500],arr = [500, 400, 300, 200, 100, 150, 250, 350, 450, 550]) == 4\n assert candidate(target = [100, 200, 300, 400, 500],arr = [100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 300, 300, 300, 400, 500]) == 0\n assert candidate(target = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]) == 0\n assert candidate(target = [1, 5, 3, 4, 2],arr = [2, 3, 1, 4, 5, 1, 2, 3, 4, 5]) == 1\n assert candidate(target = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],arr = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 40, 35, 30, 25, 20, 15, 10, 5, 2, 1]) == 1\n assert candidate(target = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],arr = [9, 7, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 5]) == 6\n assert candidate(target = [7, 5, 3, 1],arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 3\n assert candidate(target = [1, 3, 5, 7, 9],arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(target = [1, 4, 7, 10, 13, 16, 19],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 0\n assert candidate(target = [1, 2, 3, 4, 5],arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 0\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],arr = [59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 0\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr = [100, 300, 500, 700, 200, 400, 600, 800, 100, 300, 500, 700]) == 5\n assert candidate(target = [5, 1, 2, 6, 3, 7, 4, 8, 9],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(target = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],arr = [3, 5, 1, 6, 2, 9, 4, 1, 5, 3, 5]) == 7\n assert candidate(target = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 1, 2, 3, 4, 5]) == 0\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 8\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [10, 20, 30, 40, 50],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 0\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],arr = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 9\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 10\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(target = [23, 1, 7, 11, 2, 14, 6],arr = [7, 14, 4, 14, 13, 2, 6, 1, 23, 13]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(target = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],arr = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 2, 91, 87, 85, 81, 77, 75, 74, 72, 69, 65, 64, 62, 58, 57, 55, 52, 50, 49, 48, 46, 45, 44, 42, 40, 39, 38, 36, 35, 34, 33, 32, 30, 28, 27, 26, 25, 24, 22, 21, 20, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(target = [5, 3, 8, 12, 7],arr = [12, 8, 3, 7, 5, 12, 8, 3, 7, 5]) == 2\n assert candidate(target = [2, 1, 4, 3, 6, 5, 8, 7],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],arr = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 24\n assert candidate(target = [5, 1, 3, 2, 4, 6],arr = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == 1\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900],arr = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 9\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr = [500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 1, 4, 2, 3, 1, 5, 2, 4, 3, 1, 5, 2, 4, 3]) == 0\n assert candidate(target = [100, 200, 300, 400, 500],arr = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 200, 300, 400, 500]) == 0\n assert candidate(target = [1, 2, 3, 4, 5],arr = [3, 1, 2, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 9\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],arr = [5, 6, 10, 11, 15, 16, 20, 21, 25, 26, 30, 31, 35, 36, 40, 41, 45, 46, 50, 51]) == 0\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],arr = [5, 15, 25, 35, 45, 55, 65, 10, 20, 30, 40, 50]) == 4\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 1, 4, 2, 3, 5, 1, 4, 2, 3, 5, 1, 4, 2, 3, 5, 1, 4, 2, 3]) == 0\n assert candidate(target = [10, 20, 30, 40, 50],arr = [10, 25, 30, 35, 50, 40]) == 2\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14]) == 7\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 8, 6, 4, 2, 1, 3, 5, 7, 9]) == 5\n assert candidate(target = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],arr = [27, 24, 21, 18, 15, 12, 9, 6, 3, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3]) == 8\n assert candidate(target = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],arr = [1, 9, 17, 25, 33, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 5, 13, 21, 29, 37]) == 4\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 110, 120]) == 9\n"}, "metadata": {"canonical_parameter_names": ["target", "arr"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minOperations(self, target: list[int], arr: list[int]) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "target", "type": "list[int]"}, {"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1716, "task_id": "calculate-money-in-leetcode-bank", "difficulty": "Easy", "problem_description": "Hercy wants to save money for his first car. He puts money in the Leetcode bank every day.\nHe starts by putting in $1 on Monday, the first day. Every day from Tuesday to Sunday, he will put in $1 more than the day before. On every subsequent Monday, he will put in $1 more than the previous Monday. \nGiven n, return the total amount of money he will have in the Leetcode bank at the end of the nth day.\n \nExample 1:\n\nInput: n = 4\nOutput: 10\nExplanation: After the 4th day, the total is 1 + 2 + 3 + 4 = 10.\n\nExample 2:\n\nInput: n = 10\nOutput: 37\nExplanation: After the 10th day, the total is (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4) = 37. Notice that on the 2nd Monday, Hercy only puts in $2.\n\nExample 3:\n\nInput: n = 20\nOutput: 96\nExplanation: After the 20th day, the total is (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4 + 5 + 6 + 7 + 8) + (3 + 4 + 5 + 6 + 7 + 8) = 96.\n\n \nConstraints:\n\n1 <= n <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 30) == 165\n assert candidate(n = 4) == 10\n assert candidate(n = 20) == 96\n assert candidate(n = 1) == 1\n assert candidate(n = 1000) == 74926\n assert candidate(n = 7) == 28\n assert candidate(n = 10) == 37\n assert candidate(n = 29) == 159\n assert candidate(n = 63) == 504\n assert candidate(n = 210) == 3885\n assert candidate(n = 49) == 343\n assert candidate(n = 125) == 1551\n assert candidate(n = 21) == 105\n assert candidate(n = 70) == 595\n assert candidate(n = 100) == 1060\n assert candidate(n = 50) == 351\n assert candidate(n = 300) == 7476\n assert candidate(n = 28) == 154\n assert candidate(n = 60) == 462\n assert candidate(n = 56) == 420\n assert candidate(n = 40) == 250\n assert candidate(n = 600) == 27810\n assert candidate(n = 99) == 1044\n assert candidate(n = 98) == 1029\n assert candidate(n = 2) == 3\n assert candidate(n = 365) == 10791\n assert candidate(n = 80) == 732\n assert candidate(n = 700) == 37450\n assert candidate(n = 8) == 30\n assert candidate(n = 250) == 5335\n assert candidate(n = 777) == 45843\n assert candidate(n = 999) == 74778\n assert candidate(n = 22) == 109\n assert candidate(n = 35) == 210\n assert candidate(n = 140) == 1890\n assert candidate(n = 91) == 910\n assert candidate(n = 150) == 2127\n assert candidate(n = 15) == 66\n assert candidate(n = 180) == 2940\n assert candidate(n = 899) == 60870\n assert candidate(n = 85) == 811\n assert candidate(n = 200) == 3552\n assert candidate(n = 14) == 63\n assert candidate(n = 400) == 12826\n assert candidate(n = 120) == 1446\n assert candidate(n = 500) == 19602\n assert candidate(n = 52) == 370\n assert candidate(n = 90) == 891\n assert candidate(n = 25) == 127\n assert candidate(n = 84) == 798\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().totalMoney", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def totalMoney(self, n: int) -> int:", "container": "Solution", "callable": "totalMoney", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1717, "task_id": "maximum-score-from-removing-substrings", "difficulty": "Medium", "problem_description": "You are given a string s and two integers x and y. You can perform two types of operations any number of times.\n\nRemove substring \"ab\" and gain x points.\n\n\t\nFor example, when removing \"ab\" from \"cabxbae\" it becomes \"cxbae\".\n\n\nRemove substring \"ba\" and gain y points.\n\t\nFor example, when removing \"ba\" from \"cabxbae\" it becomes \"cabxe\".\n\n\n\nReturn the maximum points you can gain after applying the above operations on s.\n \nExample 1:\n\nInput: s = \"cdbcbbaaabab\", x = 4, y = 5\nOutput: 19\nExplanation:\n- Remove the \"ba\" underlined in \"cdbcbbaaabab\". Now, s = \"cdbcbbaaab\" and 5 points are added to the score.\n- Remove the \"ab\" underlined in \"cdbcbbaaab\". Now, s = \"cdbcbbaa\" and 4 points are added to the score.\n- Remove the \"ba\" underlined in \"cdbcbbaa\". Now, s = \"cdbcba\" and 5 points are added to the score.\n- Remove the \"ba\" underlined in \"cdbcba\". Now, s = \"cdbc\" and 5 points are added to the score.\nTotal score = 5 + 4 + 5 + 5 = 19.\nExample 2:\n\nInput: s = \"aabbaaxybbaabb\", x = 5, y = 4\nOutput: 20\n\n \nConstraints:\n\n1 <= s.length <= 105\n1 <= x, y <= 104\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"ababababababababababababababababababababab\",x = 1,y = 1) == 21\n assert candidate(s = \"abbaabba\",x = 7,y = 8) == 31\n assert candidate(s = \"abababab\",x = 10,y = 10) == 40\n assert candidate(s = \"ababab\",x = 10,y = 10) == 30\n assert candidate(s = \"babaabab\",x = 3,y = 2) == 11\n assert candidate(s = \"aabbcc\",x = 2,y = 2) == 4\n assert candidate(s = \"babaabab\",x = 10,y = 5) == 35\n assert candidate(s = \"abcde\",x = 1,y = 2) == 1\n assert candidate(s = \"baabaa\",x = 3,y = 2) == 5\n assert candidate(s = \"aaaaabbbbb\",x = 7,y = 8) == 35\n assert candidate(s = \"ba\",x = 1,y = 1) == 1\n assert candidate(s = \"aabbcc\",x = 1,y = 1) == 2\n assert candidate(s = \"ab\",x = 1,y = 1) == 1\n assert candidate(s = \"abbaabba\",x = 7,y = 3) == 24\n assert candidate(s = \"abcabcabcabc\",x = 2,y = 3) == 8\n assert candidate(s = \"abababab\",x = 1,y = 1) == 4\n assert candidate(s = \"aabbaaxybbaabb\",x = 5,y = 4) == 20\n assert candidate(s = \"ababababab\",x = 1,y = 1) == 5\n assert candidate(s = \"abcde\",x = 10,y = 20) == 10\n assert candidate(s = \"\",x = 100,y = 200) == 0\n assert candidate(s = \"babaabab\",x = 2,y = 3) == 11\n assert candidate(s = \"cdbcbbaaabab\",x = 4,y = 5) == 19\n assert candidate(s = \"abcde\",x = 100,y = 200) == 100\n assert candidate(s = \"baabbaabba\",x = 500,y = 500) == 2500\n assert candidate(s = \"\",x = 100,y = 100) == 0\n assert candidate(s = \"\",x = 1,y = 1) == 0\n assert candidate(s = \"bbbbbbaaaa\",x = 8,y = 7) == 28\n assert candidate(s = \"ababababab\",x = 1000,y = 1000) == 5000\n assert candidate(s = \"babaab\",x = 10,y = 5) == 25\n assert candidate(s = \"aaaabbbbbaaaaabbbb\",x = 10,y = 15) == 115\n assert candidate(s = \"babababababababababababab\",x = 7,y = 3) == 84\n assert candidate(s = \"abababababababab\",x = 10000,y = 10000) == 80000\n assert candidate(s = \"babbbabbbabbbabbbabbbabb\",x = 15,y = 25) == 150\n assert candidate(s = \"ababbaabababababab\",x = 6,y = 7) == 62\n assert candidate(s = \"aabbaabbaabbba\",x = 1000,y = 1000) == 7000\n assert candidate(s = \"bbabaabababbabaabababbba\",x = 100,y = 50) == 1050\n assert candidate(s = \"babababababa\",x = 10,y = 15) == 90\n assert candidate(s = \"abbaabbaabba\",x = 3,y = 2) == 17\n assert candidate(s = \"bbbbbaaaabbbbbaaaabbbb\",x = 4,y = 6) == 48\n assert candidate(s = \"bbaabbbaaabbba\",x = 10,y = 5) == 55\n assert candidate(s = \"babababababa\",x = 7,y = 7) == 42\n assert candidate(s = \"baabababababab\",x = 5,y = 5) == 35\n assert candidate(s = \"bababababababababababa\",x = 20,y = 20) == 220\n assert candidate(s = \"bababababababababababababababababababababa\",x = 2,y = 3) == 63\n assert candidate(s = \"babababaabababababababab\",x = 1000,y = 1000) == 12000\n assert candidate(s = \"aaaabbbbbaaaaabbbb\",x = 6,y = 9) == 69\n assert candidate(s = \"babaabababab\",x = 1000,y = 500) == 5500\n assert candidate(s = \"abbbabbaaa\",x = 10,y = 5) == 35\n assert candidate(s = \"ababababababababababababababababababababababababa\",x = 1,y = 10000) == 240000\n assert candidate(s = \"aaaaaabbaaabbaaa\",x = 5,y = 5) == 20\n assert candidate(s = \"babbbbabbbbabbbbabbb\",x = 12,y = 15) == 60\n assert candidate(s = \"abababababbababbaabab\",x = 4,y = 4) == 40\n assert candidate(s = \"ababbbbaababba\",x = 100,y = 200) == 1100\n assert candidate(s = \"bbabababababababbaa\",x = 8,y = 6) == 68\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbb\",x = 100,y = 100) == 1000\n assert candidate(s = \"abababababababababababababababab\",x = 10000,y = 1) == 160000\n assert candidate(s = \"abbaabbaabba\",x = 10,y = 20) == 110\n assert candidate(s = \"zazbzabzbabzbabz\",x = 5,y = 6) == 17\n assert candidate(s = \"bababbbabababa\",x = 1,y = 10000) == 60000\n assert candidate(s = \"abababababababababababababababababab\",x = 2,y = 1) == 36\n assert candidate(s = \"aabbbaaabbbaaabbbaaabbbaa\",x = 15,y = 5) == 170\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaa\",x = 1000,y = 500) == 12000\n assert candidate(s = \"bbaabbabababbaabba\",x = 10,y = 5) == 75\n assert candidate(s = \"ababababababababababababababababababababababababababababa\",x = 10000,y = 10000) == 280000\n assert candidate(s = \"xyzababxyzbaaxyzbaxyz\",x = 15,y = 10) == 50\n assert candidate(s = \"zababxyzab\",x = 4,y = 5) == 13\n assert candidate(s = \"abbbabbbabbbabbbabbbabbb\",x = 20,y = 10) == 120\n assert candidate(s = \"aabbbaaabbbaaabbbaab\",x = 7,y = 3) == 66\n assert candidate(s = \"abababababababababababababababab\",x = 10,y = 10) == 160\n assert candidate(s = \"babababababababa\",x = 1,y = 2) == 16\n assert candidate(s = \"ababababababababababababab\",x = 1,y = 1) == 13\n assert candidate(s = \"abababababababababababababababab\",x = 90,y = 100) == 1590\n assert candidate(s = \"abbbbaabbbbaabbbbaab\",x = 200,y = 300) == 2000\n assert candidate(s = \"abababababababababababababababababababababababababababab\",x = 1,y = 1) == 28\n assert candidate(s = \"abababababababababababababababab\",x = 50,y = 50) == 800\n assert candidate(s = \"babaabababab\",x = 10,y = 15) == 85\n assert candidate(s = \"abbbabababba\",x = 500,y = 400) == 2400\n assert candidate(s = \"babaababbaab\",x = 10,y = 5) == 55\n assert candidate(s = \"xyxzyzyzxzyz\",x = 100,y = 200) == 0\n assert candidate(s = \"ababbaababba\",x = 3,y = 2) == 17\n assert candidate(s = \"ababababababababababababababababab\",x = 1,y = 1) == 17\n assert candidate(s = \"xyxyxyxyxy\",x = 3,y = 3) == 0\n assert candidate(s = \"ababababababababababababababababababababababababababababa\",x = 2,y = 3) == 84\n assert candidate(s = \"babababababababababababababababa\",x = 1000,y = 500) == 15500\n assert candidate(s = \"abbaabbaabbaabbaabbaabbaabbaabba\",x = 25,y = 30) == 475\n assert candidate(s = \"ababababababababababab\",x = 5,y = 5) == 55\n assert candidate(s = \"abababababababababababababababab\",x = 1,y = 100) == 1501\n assert candidate(s = \"abaabbaabbabab\",x = 10000,y = 1) == 70000\n assert candidate(s = \"babbababbababbababbababb\",x = 5,y = 4) == 45\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",x = 1000,y = 2000) == 0\n assert candidate(s = \"bababababababababa\",x = 1,y = 2) == 18\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbbaaaaaaaaaaabbbbbbbbbbbbb\",x = 15,y = 25) == 425\n assert candidate(s = \"bbaabbababababababababab\",x = 1,y = 9999) == 109989\n assert candidate(s = \"abbaabbaabbaabba\",x = 10,y = 10) == 80\n assert candidate(s = \"aabbaaabaabbaaabaabbaabb\",x = 1,y = 1) == 10\n assert candidate(s = \"bbbababbaabbababbaabbbaabababbbabababababababa\",x = 8000,y = 9000) == 180000\n assert candidate(s = \"babababababababababababababababa\",x = 7,y = 7) == 112\n assert candidate(s = \"babababababababababababababababababababababababababababa\",x = 1000,y = 1000) == 28000\n assert candidate(s = \"abababababababababababababababab\",x = 10,y = 9) == 160\n assert candidate(s = \"bbababababababababababababababab\",x = 100,y = 90) == 1500\n assert candidate(s = \"abbaabbaabbaabbaabbaabbaabbaabba\",x = 6,y = 4) == 94\n assert candidate(s = \"ababbbababababba\",x = 20,y = 15) == 135\n assert candidate(s = \"babbbbabbbbabbaa\",x = 8,y = 6) == 36\n assert candidate(s = \"abbaabbaabbaabbaabba\",x = 8,y = 3) == 75\n assert candidate(s = \"aabababababa\",x = 20,y = 15) == 100\n assert candidate(s = \"ababbaababbaababba\",x = 7,y = 9) == 79\n assert candidate(s = \"ababbbabababbaababababab\",x = 20,y = 10) == 210\n assert candidate(s = \"ababbbbaabab\",x = 5,y = 10) == 45\n assert candidate(s = \"bbbbbaaaaabbbbbbaaaaabbbbb\",x = 1000,y = 500) == 10000\n assert candidate(s = \"baaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbb\",x = 500,y = 1000) == 12500\n assert candidate(s = \"babababababababa\",x = 1,y = 100) == 800\n assert candidate(s = \"bbaaabaaaaba\",x = 20,y = 10) == 60\n assert candidate(s = \"ababababababababababababab\",x = 7,y = 8) == 103\n assert candidate(s = \"aabbbaababaababbbbababba\",x = 3,y = 2) == 32\n assert candidate(s = \"baaababababababaabaababb\",x = 10,y = 20) == 200\n assert candidate(s = \"babababababababaabab\",x = 3,y = 2) == 29\n assert candidate(s = \"bababababababababababababababa\",x = 1,y = 2) == 30\n assert candidate(s = \"abbbbbbbbbaaaaaaaa\",x = 20,y = 18) == 164\n assert candidate(s = \"baabbaabbaabbaabbaabbaabbaabbaab\",x = 30,y = 25) == 475\n assert candidate(s = \"abcabcabcabc\",x = 5,y = 5) == 20\n assert candidate(s = \"ababababababababab\",x = 100,y = 1) == 900\n assert candidate(s = \"baabbaabbaabbaabbaab\",x = 4,y = 3) == 39\n assert candidate(s = \"bbaaabbaaabbaa\",x = 1,y = 10000) == 60000\n assert candidate(s = \"bbbbbaaaaabbbbbaaaaabbbbbaaaaa\",x = 100,y = 1) == 1005\n assert candidate(s = \"abababababababababababa\",x = 50,y = 25) == 550\n assert candidate(s = \"aababababaab\",x = 100,y = 100) == 500\n assert candidate(s = \"babababababa\",x = 2000,y = 2000) == 12000\n assert candidate(s = \"babbbabbaabababbababbaabbbbaabab\",x = 20,y = 15) == 255\n assert candidate(s = \"babababababaab\",x = 8,y = 7) == 55\n assert candidate(s = \"babababababababa\",x = 100,y = 90) == 790\n assert candidate(s = \"aabbbaabbaabbbaabbaabbba\",x = 2,y = 3) == 31\n assert candidate(s = \"babababababababababababababababababa\",x = 1,y = 2) == 36\n assert candidate(s = \"aabbaabbccddeeffgg\",x = 10,y = 20) == 60\n assert candidate(s = \"aaaabbbbbaaaaabbb\",x = 5,y = 3) == 38\n assert candidate(s = \"ababbaababbaab\",x = 6,y = 4) == 40\n assert candidate(s = \"babaababababba\",x = 3,y = 2) == 20\n assert candidate(s = \"abababababababababababab\",x = 9999,y = 1) == 119988\n assert candidate(s = \"baabaabaabaabaabaabaabaabaabaabaab\",x = 5000,y = 4000) == 59000\n assert candidate(s = \"abababababababababab\",x = 1,y = 2) == 19\n assert candidate(s = \"bababababa\",x = 2,y = 3) == 15\n assert candidate(s = \"abbaabbaabbaabbaabbaabba\",x = 10,y = 15) == 175\n assert candidate(s = \"babababababababababababababababababababababababa\",x = 5000,y = 4000) == 119000\n assert candidate(s = \"bbaabaaaabbbbbaaaab\",x = 3,y = 2) == 25\n assert candidate(s = \"ababababababababababababababababababababababababa\",x = 2000,y = 2000) == 48000\n assert candidate(s = \"baababababababababababababababab\",x = 4,y = 4) == 64\n assert candidate(s = \"babababababababababababababababababababababababababababa\",x = 3,y = 2) == 83\n assert candidate(s = \"ababbbabaabbbbab\",x = 7,y = 3) == 42\n assert candidate(s = \"abbaabbaabbaabbaabbaabbaabbaabba\",x = 1000,y = 1000) == 16000\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",x = 1000,y = 2000) == 2000\n assert candidate(s = \"abbbabaababaabbaaaabbbbaaabbabab\",x = 5,y = 6) == 93\n assert candidate(s = \"abababababababababababababababab\",x = 1000,y = 1000) == 16000\n assert candidate(s = \"babababababababababababa\",x = 5,y = 5) == 60\n assert candidate(s = \"ababaababbabbaab\",x = 3,y = 4) == 30\n assert candidate(s = \"babababababababababababababababababababababababababababa\",x = 8,y = 5) == 221\n"}, "metadata": {"canonical_parameter_names": ["s", "x", "y"], "leetcode_dataset_entry_point": "Solution().maximumGain", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumGain(self, s: str, x: int, y: int) -> int:", "container": "Solution", "callable": "maximumGain", "parameters": [{"name": "s", "type": "str"}, {"name": "x", "type": "int"}, {"name": "y", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1718, "task_id": "construct-the-lexicographically-largest-valid-sequence", "difficulty": "Medium", "problem_description": "Given an integer n, find a sequence with elements in the range [1, n] that satisfies all of the following:\n\nThe integer 1 occurs once in the sequence.\nEach integer between 2 and n occurs twice in the sequence.\nFor every integer i between 2 and n, the distance between the two occurrences of i is exactly i.\n\nThe distance between two numbers on the sequence, a[i] and a[j], is the absolute difference of their indices, |j - i|.\nReturn the lexicographically largest sequence. It is guaranteed that under the given constraints, there is always a solution. \nA sequence a is lexicographically larger than a sequence b (of the same length) if in the first position where a and b differ, sequence a has a number greater than the corresponding number in b. For example, [0,1,9,0] is lexicographically larger than [0,1,5,6] because the first position they differ is at the third number, and 9 is greater than 5.\n \nExample 1:\n\nInput: n = 3\nOutput: [3,1,2,3,2]\nExplanation: [2,3,2,1,3] is also a valid sequence, but [3,1,2,3,2] is the lexicographically largest valid sequence.\n\nExample 2:\n\nInput: n = 5\nOutput: [5,3,1,4,3,5,2,4,2]\n\n \nConstraints:\n\n1 <= n <= 20\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == [3, 1, 2, 3, 2]\n assert candidate(n = 15) == [15, 13, 14, 10, 8, 12, 5, 3, 11, 9, 3, 5, 8, 10, 13, 15, 14, 12, 9, 11, 7, 4, 6, 1, 2, 4, 2, 7, 6]\n assert candidate(n = 4) == [4, 2, 3, 2, 4, 3, 1]\n assert candidate(n = 20) == [20, 18, 19, 15, 13, 17, 10, 16, 7, 5, 3, 14, 12, 3, 5, 7, 10, 13, 15, 18, 20, 19, 17, 16, 12, 14, 11, 9, 4, 6, 8, 2, 4, 2, 1, 6, 9, 11, 8]\n assert candidate(n = 2) == [2, 1, 2]\n assert candidate(n = 1) == [1]\n assert candidate(n = 10) == [10, 8, 6, 9, 3, 1, 7, 3, 6, 8, 10, 5, 9, 7, 4, 2, 5, 2, 4]\n assert candidate(n = 5) == [5, 3, 1, 4, 3, 5, 2, 4, 2]\n assert candidate(n = 8) == [8, 6, 4, 2, 7, 2, 4, 6, 8, 5, 3, 7, 1, 3, 5]\n assert candidate(n = 11) == [11, 9, 10, 6, 4, 1, 7, 8, 4, 6, 9, 11, 10, 7, 5, 8, 2, 3, 2, 5, 3]\n assert candidate(n = 12) == [12, 10, 11, 7, 5, 3, 8, 9, 3, 5, 7, 10, 12, 11, 8, 6, 9, 2, 4, 2, 1, 6, 4]\n assert candidate(n = 16) == [16, 14, 15, 11, 9, 13, 6, 4, 12, 10, 1, 4, 6, 9, 11, 14, 16, 15, 13, 10, 12, 8, 5, 7, 2, 3, 2, 5, 3, 8, 7]\n assert candidate(n = 14) == [14, 12, 13, 9, 7, 11, 4, 1, 10, 8, 4, 7, 9, 12, 14, 13, 11, 8, 10, 6, 3, 5, 2, 3, 2, 6, 5]\n assert candidate(n = 17) == [17, 15, 16, 12, 10, 14, 7, 5, 3, 13, 11, 3, 5, 7, 10, 12, 15, 17, 16, 14, 9, 11, 13, 8, 6, 2, 1, 2, 4, 9, 6, 8, 4]\n assert candidate(n = 18) == [18, 16, 17, 13, 11, 15, 8, 14, 4, 2, 12, 2, 4, 10, 8, 11, 13, 16, 18, 17, 15, 14, 12, 10, 9, 7, 5, 3, 6, 1, 3, 5, 7, 9, 6]\n assert candidate(n = 13) == [13, 11, 12, 8, 6, 4, 9, 10, 1, 4, 6, 8, 11, 13, 12, 9, 7, 10, 3, 5, 2, 3, 2, 7, 5]\n assert candidate(n = 6) == [6, 4, 2, 5, 2, 4, 6, 3, 5, 1, 3]\n assert candidate(n = 7) == [7, 5, 3, 6, 4, 3, 5, 7, 4, 6, 2, 1, 2]\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().constructDistancedSequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def constructDistancedSequence(self, n: int) -> list[int]:", "container": "Solution", "callable": "constructDistancedSequence", "parameters": [{"name": "n", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1719, "task_id": "number-of-ways-to-reconstruct-a-tree", "difficulty": "Hard", "problem_description": "You are given an array pairs, where pairs[i] = [xi, yi], and:\n\nThere are no duplicates.\nxi < yi\n\nLet ways be the number of rooted trees that satisfy the following conditions:\n\nThe tree consists of nodes whose values appeared in pairs.\nA pair [xi, yi] exists in pairs if and only if xi is an ancestor of yi or yi is an ancestor of xi.\nNote: the tree does not have to be a binary tree.\n\nTwo ways are considered to be different if there is at least one node that has different parents in both ways.\nReturn:\n\n0 if ways == 0\n1 if ways == 1\n2 if ways > 1\n\nA rooted tree is a tree that has a single root node, and all edges are oriented to be outgoing from the root.\nAn ancestor of a node is any node on the path from the root to that node (excluding the node itself). The root has no ancestors.\n \nExample 1:\n\n\nInput: pairs = [[1,2],[2,3]]\nOutput: 1\nExplanation: There is exactly one valid rooted tree, which is shown in the above figure.\n\nExample 2:\n\n\nInput: pairs = [[1,2],[2,3],[1,3]]\nOutput: 2\nExplanation: There are multiple valid rooted trees. Three of them are shown in the above figures.\n\nExample 3:\n\nInput: pairs = [[1,2],[2,3],[2,4],[1,5]]\nOutput: 0\nExplanation: There are no valid rooted trees.\n \nConstraints:\n\n1 <= pairs.length <= 105\n1 <= xi < yi <= 500\nThe elements in pairs are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [4, 5]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 5]]) == 0\n assert candidate(pairs = [[1, 3], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(pairs = [[1, 2], [3, 4]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3]]) == 1\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [3, 5]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(pairs = [[1, 3], [2, 3], [4, 5]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [1, 4]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]) == 2\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5]]) == 1\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [4, 5]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [1, 3]]) == 2\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [1, 5]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [3, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 18], [5, 19], [5, 20], [5, 21], [6, 22], [6, 23], [6, 24], [7, 25], [7, 26], [7, 27], [8, 28], [8, 29], [8, 30], [9, 31], [9, 32], [9, 33], [10, 34], [10, 35], [10, 36], [11, 37], [11, 38], [11, 39], [12, 40], [12, 41], [12, 42], [13, 43], [13, 44], [13, 45], [14, 46], [14, 47], [14, 48], [15, 49], [15, 50], [15, 51]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19], [12, 20]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16], [9, 17], [9, 18], [10, 19], [10, 20], [11, 21], [11, 22], [12, 23], [12, 24], [13, 25], [13, 26], [14, 27], [14, 28], [15, 29], [15, 30], [16, 31], [16, 32], [17, 33], [17, 34], [18, 35], [18, 36], [19, 37], [19, 38], [20, 39], [20, 40], [21, 41], [21, 42], [22, 43], [22, 44], [23, 45], [23, 46], [24, 47], [24, 48]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [4, 16], [5, 17], [5, 18], [5, 19], [5, 20], [6, 21], [6, 22], [6, 23], [6, 24], [7, 25], [7, 26]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16], [9, 17], [9, 18], [10, 19], [10, 20], [11, 21], [11, 22], [12, 23], [12, 24]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 0\n assert candidate(pairs = [[1, 12], [1, 11], [1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2]]) == 1\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [4, 14], [5, 15], [5, 16], [5, 17], [6, 18], [6, 19], [7, 20], [7, 21], [8, 22], [8, 23], [9, 24], [9, 25], [10, 26], [10, 27], [11, 28], [11, 29], [12, 30], [12, 31], [13, 32], [13, 33], [14, 34], [14, 35], [15, 36], [15, 37], [16, 38], [16, 39], [17, 40], [17, 41]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8], [6, 9], [7, 10], [7, 11]]) == 0\n assert candidate(pairs = [[1, 6], [6, 7], [6, 8], [1, 9], [9, 10], [9, 11], [1, 12], [12, 13], [12, 14]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [4, 5], [1, 6], [6, 7], [6, 8], [8, 9], [9, 10], [1, 11], [11, 12], [12, 13]]) == 0\n assert candidate(pairs = [[1, 3], [3, 5], [5, 7], [3, 6], [6, 8], [1, 2], [2, 4], [4, 9], [9, 10]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27], [13, 28], [13, 29], [14, 30], [14, 31], [15, 32], [15, 33]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20], [16, 21], [17, 22], [18, 23], [19, 24], [20, 25], [21, 26], [22, 27], [23, 28], [24, 29], [25, 30], [26, 31], [27, 32], [28, 33], [29, 34], [30, 35], [31, 36], [32, 37], [33, 38], [34, 39], [35, 40], [36, 41], [37, 42], [38, 43], [39, 44], [40, 45], [41, 46], [42, 47], [43, 48], [44, 49], [45, 50]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16], [9, 17], [9, 18], [10, 19], [11, 20], [11, 21], [12, 22], [12, 23], [13, 24], [13, 25], [14, 26], [14, 27], [15, 28], [15, 29], [16, 30], [16, 31], [17, 32], [17, 33], [18, 34], [18, 35], [19, 36], [19, 37], [20, 38], [20, 39], [21, 40], [21, 41], [22, 42], [22, 43], [23, 44], [23, 45]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [7, 22], [8, 23], [8, 24], [8, 25], [9, 26], [9, 27], [9, 28], [10, 29], [10, 30], [10, 31]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [4, 16], [5, 17], [5, 18], [5, 19], [5, 20], [6, 21], [6, 22], [6, 23], [6, 24], [7, 25], [7, 26], [7, 27], [7, 28], [8, 29], [8, 30], [8, 31], [8, 32]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [8, 17]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [3, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 18], [5, 19], [5, 20], [5, 21]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35], [18, 36], [18, 37], [19, 38], [19, 39], [20, 40], [20, 41], [21, 42], [21, 43]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25], [22, 26], [23, 27], [24, 28], [25, 29], [26, 30], [27, 31], [28, 32], [29, 33], [30, 34]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [1, 5], [5, 6], [6, 7], [1, 8], [8, 9], [9, 10], [10, 11]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [3, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 18], [5, 19], [5, 20], [5, 21], [6, 22], [6, 23], [6, 24], [6, 25], [7, 26], [7, 27], [7, 28], [7, 29], [8, 30], [8, 31], [8, 32], [8, 33], [9, 34], [9, 35], [9, 36], [9, 37], [10, 38], [10, 39], [10, 40], [10, 41]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [10, 19], [11, 20], [12, 21], [13, 22], [14, 23], [15, 24], [16, 25], [17, 26], [18, 27], [19, 28], [20, 29], [21, 30], [22, 31], [23, 32], [24, 33], [25, 34], [26, 35], [27, 36], [28, 37], [29, 38], [30, 39], [31, 40]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30], [15, 31], [15, 32], [16, 33], [16, 34], [17, 35], [17, 36], [18, 37], [18, 38], [19, 39], [19, 40], [20, 41], [20, 42], [21, 43], [21, 44], [22, 45], [22, 46], [23, 47], [23, 48], [24, 49], [24, 50]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [7, 22], [8, 23], [8, 24]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20], [16, 21], [17, 22], [18, 23], [19, 24], [20, 25]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8], [6, 9], [7, 10], [7, 11], [10, 12], [11, 13]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [14, 27], [15, 28], [16, 29], [17, 30], [18, 31], [19, 32], [20, 33]]) == 0\n assert candidate(pairs = [[1, 3], [1, 2], [3, 5], [3, 6], [3, 7], [2, 4], [2, 8], [2, 9], [4, 10], [4, 11], [8, 12], [8, 13], [9, 14], [9, 15], [14, 16], [15, 17]]) == 0\n assert candidate(pairs = [[1, 6], [1, 7], [1, 8], [2, 6], [3, 7], [4, 8], [5, 8], [5, 6], [5, 7]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [5, 13]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == 0\n assert candidate(pairs = [[1, 6], [6, 7], [1, 2], [1, 3], [1, 4], [1, 5], [5, 8], [8, 9]]) == 0\n assert candidate(pairs = [[1, 3], [3, 5], [5, 7], [7, 9], [1, 4], [4, 6], [6, 8], [8, 10], [1, 11], [11, 12], [12, 13], [13, 14]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35], [18, 36], [18, 37], [19, 38], [19, 39], [20, 40], [20, 41], [21, 42], [21, 43], [22, 44], [22, 45], [23, 46], [23, 47], [24, 48], [24, 49], [25, 50], [25, 51]]) == 0\n assert candidate(pairs = [[1, 15], [1, 14], [1, 13], [1, 12], [1, 11], [1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["pairs"], "leetcode_dataset_entry_point": "Solution().checkWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def checkWays(self, pairs: list[list[int]]) -> int:", "container": "Solution", "callable": "checkWays", "parameters": [{"name": "pairs", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1720, "task_id": "decode-xored-array", "difficulty": "Easy", "problem_description": "There is a hidden integer array arr that consists of n non-negative integers.\nIt was encoded into another integer array encoded of length n - 1, such that encoded[i] = arr[i] XOR arr[i + 1]. For example, if arr = [1,0,2,1], then encoded = [1,2,3].\nYou are given the encoded array. You are also given an integer first, that is the first element of arr, i.e. arr[0].\nReturn the original array arr. It can be proved that the answer exists and is unique.\n \nExample 1:\n\nInput: encoded = [1,2,3], first = 1\nOutput: [1,0,2,1]\nExplanation: If arr = [1,0,2,1], then first = 1 and encoded = [1 XOR 0, 0 XOR 2, 2 XOR 1] = [1,2,3]\n\nExample 2:\n\nInput: encoded = [6,2,7,3], first = 4\nOutput: [4,2,0,7,4]\n\n \nConstraints:\n\n2 <= n <= 104\nencoded.length == n - 1\n0 <= encoded[i] <= 105\n0 <= first <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(encoded = [10, 5, 15],first = 0) == [0, 10, 15, 0]\n assert candidate(encoded = [0, 0, 0],first = 7) == [7, 7, 7, 7]\n assert candidate(encoded = [9, 5, 6],first = 0) == [0, 9, 12, 10]\n assert candidate(encoded = [10, 5, 15, 20],first = 0) == [0, 10, 15, 0, 20]\n assert candidate(encoded = [3, 1, 2],first = 0) == [0, 3, 2, 0]\n assert candidate(encoded = [12345, 67890, 13579, 24680],first = 98765) == [98765, 111092, 47302, 36301, 60837]\n assert candidate(encoded = [1, 2, 3],first = 1) == [1, 0, 2, 1]\n assert candidate(encoded = [6, 2, 7, 3],first = 4) == [4, 2, 0, 7, 4]\n assert candidate(encoded = [0, 0, 0, 0],first = 5) == [5, 5, 5, 5, 5]\n assert candidate(encoded = [3, 1],first = 5) == [5, 6, 7]\n assert candidate(encoded = [10, 5, 15],first = 3) == [3, 9, 12, 3]\n assert candidate(encoded = [0, 0, 0],first = 5) == [5, 5, 5, 5]\n assert candidate(encoded = [3, 1],first = 2) == [2, 1, 0]\n assert candidate(encoded = [7, 9, 14, 2, 6],first = 8) == [8, 15, 6, 8, 10, 12]\n assert candidate(encoded = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],first = 0) == [0, 65535, 32768, 49151, 40960, 45055, 43008, 44031, 43520, 43775, 43648, 43711, 43680, 43695, 43688, 43691, 43690]\n assert candidate(encoded = [255, 128, 64, 32, 16, 8, 4, 2, 1],first = 255) == [255, 0, 128, 192, 224, 240, 248, 252, 254, 255]\n assert candidate(encoded = [255, 0, 255, 0, 255],first = 1) == [1, 254, 254, 1, 1, 254]\n assert candidate(encoded = [88, 99, 22, 15, 77, 44, 55, 11, 33, 66],first = 3) == [3, 91, 56, 46, 33, 108, 64, 119, 124, 93, 31]\n assert candidate(encoded = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],first = 1) == [1, 0, 2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046, 4094]\n assert candidate(encoded = [5, 5, 5, 5, 5],first = 10) == [10, 15, 10, 15, 10, 15]\n assert candidate(encoded = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],first = 1) == [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]\n assert candidate(encoded = [255, 128, 64, 32, 16, 8, 4, 2, 1],first = 0) == [0, 255, 127, 63, 31, 15, 7, 3, 1, 0]\n assert candidate(encoded = [8, 12, 5, 10, 15],first = 7) == [7, 15, 3, 6, 12, 3]\n assert candidate(encoded = [99, 142, 55, 231, 78, 102, 184, 33, 201, 127],first = 23) == [23, 116, 250, 205, 42, 100, 2, 186, 155, 82, 45]\n assert candidate(encoded = [15, 9, 12, 5, 6, 3, 14, 10],first = 8) == [8, 7, 14, 2, 7, 1, 2, 12, 6]\n assert candidate(encoded = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],first = 1) == [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]\n assert candidate(encoded = [123, 246, 369, 492, 615, 738, 861, 984],first = 100) == [100, 31, 233, 408, 116, 531, 241, 940, 116]\n assert candidate(encoded = [7, 9, 3, 10, 8],first = 2) == [2, 5, 12, 15, 5, 13]\n assert candidate(encoded = [12, 4, 6, 5, 11, 3],first = 8) == [8, 4, 0, 6, 3, 8, 11]\n assert candidate(encoded = [13, 26, 52, 104, 208, 416, 832, 1664, 3328, 6656],first = 7) == [7, 10, 16, 36, 76, 156, 316, 636, 1276, 2556, 5116]\n assert candidate(encoded = [15, 6, 9, 12, 23, 45],first = 10) == [10, 5, 3, 10, 6, 17, 60]\n assert candidate(encoded = [123456, 987654, 13579, 24680],first = 111111) == [111111, 20551, 1000001, 1013578, 988962]\n assert candidate(encoded = [100000, 50000, 25000, 12500, 6250, 3125],first = 15625) == [15625, 113577, 96505, 72017, 76165, 78319, 81370]\n assert candidate(encoded = [4, 13, 5, 10, 3, 7, 1],first = 9) == [9, 13, 0, 5, 15, 12, 11, 10]\n assert candidate(encoded = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768],first = 128) == [128, 384, 896, 1920, 3968, 8064, 16256, 32640, 65408]\n assert candidate(encoded = [100, 200, 50, 250, 10, 300, 150, 225],first = 42) == [42, 78, 134, 180, 78, 68, 360, 510, 287]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35, 40, 45],first = 0) == [0, 5, 15, 0, 20, 13, 19, 48, 24, 53]\n assert candidate(encoded = [0, 0, 0, 0, 0],first = 0) == [0, 0, 0, 0, 0, 0]\n assert candidate(encoded = [255, 128, 64, 32, 16],first = 1) == [1, 254, 126, 62, 30, 14]\n assert candidate(encoded = [10, 10, 10, 10, 10, 10, 10, 10, 10],first = 10) == [10, 0, 10, 0, 10, 0, 10, 0, 10, 0]\n assert candidate(encoded = [0, 1, 0, 1, 0],first = 1) == [1, 1, 0, 0, 1, 1]\n assert candidate(encoded = [8, 3, 12, 5, 9],first = 6) == [6, 14, 13, 1, 4, 13]\n assert candidate(encoded = [99, 101, 97, 95, 103, 109, 100, 98, 94, 96, 92],first = 100) == [100, 7, 98, 3, 92, 59, 86, 50, 80, 14, 110, 50]\n assert candidate(encoded = [14, 7, 11, 12],first = 3) == [3, 13, 10, 1, 13]\n assert candidate(encoded = [31, 41, 59, 26, 53, 58, 97, 93, 23, 84, 62, 64, 33, 83, 27, 95, 8, 4],first = 271) == [271, 272, 313, 258, 280, 301, 279, 374, 299, 316, 360, 342, 278, 311, 356, 383, 288, 296, 300]\n assert candidate(encoded = [2, 3, 1, 4, 5],first = 7) == [7, 5, 6, 7, 3, 6]\n assert candidate(encoded = [231, 45, 67, 89, 101, 123, 145],first = 99) == [99, 132, 169, 234, 179, 214, 173, 60]\n assert candidate(encoded = [7, 5, 3, 1, 9, 11, 13, 15, 17, 19],first = 2) == [2, 5, 0, 3, 2, 11, 0, 13, 2, 19, 0]\n assert candidate(encoded = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],first = 2048) == [2048, 3072, 3584, 3840, 3968, 4032, 4064, 4080, 4088, 4092, 4094, 4095]\n assert candidate(encoded = [8, 6, 10, 12, 14, 16, 18, 20],first = 4) == [4, 12, 10, 0, 12, 2, 18, 0, 20]\n assert candidate(encoded = [2, 3, 2, 3, 2, 3],first = 1) == [1, 3, 0, 2, 1, 3, 0]\n assert candidate(encoded = [8, 13, 7, 10, 15],first = 2) == [2, 10, 7, 0, 10, 5]\n assert candidate(encoded = [7, 7, 7, 7, 7, 7, 7, 7],first = 3) == [3, 4, 3, 4, 3, 4, 3, 4, 3]\n assert candidate(encoded = [14, 11, 7, 15],first = 2) == [2, 12, 7, 0, 15]\n assert candidate(encoded = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],first = 3) == [3, 0, 6, 15, 3, 12, 30, 11, 19, 8, 22, 55, 19]\n assert candidate(encoded = [98765, 43210, 12345, 67890, 54321, 89012, 21043],first = 78901) == [78901, 46584, 7474, 11531, 74809, 126984, 43964, 63887]\n assert candidate(encoded = [7, 13, 14, 12, 17],first = 9) == [9, 14, 3, 13, 1, 16]\n assert candidate(encoded = [16, 32, 64, 128, 256, 512],first = 8) == [8, 24, 56, 120, 248, 504, 1016]\n assert candidate(encoded = [25, 15, 10, 13, 7, 4],first = 8) == [8, 17, 30, 20, 25, 30, 26]\n assert candidate(encoded = [128, 64, 32, 16, 8, 4, 2, 1],first = 255) == [255, 127, 63, 31, 15, 7, 3, 1, 0]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],first = 5) == [5, 0, 10, 5, 17, 8, 22, 53, 29, 48, 2]\n assert candidate(encoded = [255, 128, 64, 32, 16, 8, 4, 2, 1],first = 0) == [0, 255, 127, 63, 31, 15, 7, 3, 1, 0]\n assert candidate(encoded = [1000, 500, 250, 125, 62, 31, 15],first = 1) == [1, 1001, 541, 743, 666, 676, 699, 692]\n assert candidate(encoded = [15, 24, 32, 16, 8, 4, 2],first = 1) == [1, 14, 22, 54, 38, 46, 42, 40]\n assert candidate(encoded = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0],first = 65536) == [65536, 131071, 98304, 114687, 106496, 110591, 108544, 109567, 109056, 109311, 109184, 109247, 109216, 109231, 109224, 109227, 109226, 109226]\n assert candidate(encoded = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],first = 0) == [0, 1, 2, 5, 10, 21, 42, 85, 170, 341, 682]\n assert candidate(encoded = [101010, 101010, 101010, 101010, 101010, 101010],first = 101010) == [101010, 0, 101010, 0, 101010, 0, 101010]\n assert candidate(encoded = [1, 2, 4, 8, 16, 32, 64, 128],first = 256) == [256, 257, 259, 263, 271, 287, 319, 383, 511]\n assert candidate(encoded = [8, 2, 6, 4, 2, 6, 4],first = 7) == [7, 15, 13, 11, 15, 13, 11, 15]\n assert candidate(encoded = [1023, 2047, 4095, 8191, 16383, 32767, 65535],first = 1) == [1, 1022, 1025, 3070, 5121, 11262, 21505, 44030]\n assert candidate(encoded = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42],first = 1) == [1, 3, 5, 15, 1, 19, 5, 31, 1, 35, 5, 47]\n assert candidate(encoded = [100000, 50000, 25000, 12500, 6250, 3125],first = 1) == [1, 100001, 83441, 74841, 70797, 68839, 65746]\n assert candidate(encoded = [123, 456, 789, 101112, 131415, 161718, 192021],first = 222324) == [222324, 222223, 222663, 222930, 191530, 60797, 170699, 29918]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],first = 1) == [1, 4, 14, 1, 21, 12, 18, 49, 25, 52, 6, 49, 13, 76, 10, 65, 17]\n assert candidate(encoded = [1, 0, 1, 0, 1, 0, 1, 0],first = 0) == [0, 1, 1, 0, 0, 1, 1, 0, 0]\n assert candidate(encoded = [3, 5, 6, 1, 7, 4, 2, 8, 0],first = 3) == [3, 0, 5, 3, 2, 5, 1, 3, 11, 11]\n assert candidate(encoded = [9, 5, 7, 3, 8, 6, 2, 4, 1, 0],first = 11) == [11, 2, 7, 0, 3, 11, 13, 15, 11, 10, 10]\n assert candidate(encoded = [0, 1, 0, 1, 0, 1, 0, 1],first = 1) == [1, 1, 0, 0, 1, 1, 0, 0, 1]\n assert candidate(encoded = [2, 3, 1, 4, 5, 6, 7, 8, 9],first = 1) == [1, 3, 0, 1, 5, 0, 6, 1, 9, 0]\n assert candidate(encoded = [30, 15, 25, 35, 45, 55, 65],first = 5) == [5, 27, 20, 13, 46, 3, 52, 117]\n assert candidate(encoded = [23, 54, 12, 9, 17, 33, 20],first = 15) == [15, 24, 46, 34, 43, 58, 27, 15]\n assert candidate(encoded = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97],first = 1) == [1, 100001, 83441, 74841, 70797, 68839, 65746, 67272, 67013, 66627, 66688, 66785]\n assert candidate(encoded = [4, 6, 5, 7, 10, 13],first = 2) == [2, 6, 0, 5, 2, 8, 5]\n assert candidate(encoded = [100000, 90000, 80000, 70000, 60000],first = 50000) == [50000, 83440, 6752, 74464, 13200, 55792]\n assert candidate(encoded = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],first = 3) == [3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6]\n assert candidate(encoded = [12345, 67890, 12345, 67890, 12345],first = 98765) == [98765, 111092, 47302, 35071, 98765, 111092]\n assert candidate(encoded = [98765, 43210, 67890, 12345, 54321, 90123],first = 65432) == [65432, 97877, 120479, 57261, 61332, 15269, 89006]\n assert candidate(encoded = [25, 17, 31, 18, 29, 14],first = 10) == [10, 19, 2, 29, 15, 18, 28]\n assert candidate(encoded = [13, 11, 7, 14, 28, 16, 32],first = 8) == [8, 5, 14, 9, 7, 27, 11, 43]\n assert candidate(encoded = [14, 22, 36, 52, 72, 96, 124],first = 1) == [1, 15, 25, 61, 9, 65, 33, 93]\n assert candidate(encoded = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111],first = 10000) == [10000, 106895, 64183, 120166, 53516, 2063, 42387, 10150, 29032, 23055]\n assert candidate(encoded = [12, 15, 2, 8, 17, 5],first = 3) == [3, 15, 0, 2, 10, 27, 30]\n assert candidate(encoded = [4, 3, 2, 1],first = 5) == [5, 1, 2, 0, 1]\n assert candidate(encoded = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],first = 1) == [1, 0, 3, 4, 11, 20, 43, 84, 171, 340, 683]\n assert candidate(encoded = [2047, 4094, 2047, 4094, 2047, 4094, 2047],first = 4095) == [4095, 2048, 2046, 1, 4095, 2048, 2046, 1]\n assert candidate(encoded = [13, 9, 16, 22, 10, 19, 7, 12],first = 4) == [4, 9, 0, 16, 6, 12, 31, 24, 20]\n assert candidate(encoded = [32767, 16383, 8191, 4095, 2047],first = 1024) == [1024, 31743, 17408, 23551, 21504, 21503]\n"}, "metadata": {"canonical_parameter_names": ["encoded", "first"], "leetcode_dataset_entry_point": "Solution().decode", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def decode(self, encoded: list[int], first: int) -> list[int]:", "container": "Solution", "callable": "decode", "parameters": [{"name": "encoded", "type": "list[int]"}, {"name": "first", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1721, "task_id": "swapping-nodes-in-a-linked-list", "difficulty": "Medium", "problem_description": "You are given the head of a linked list, and an integer k.\nReturn the head of the linked list after swapping the values of the kth node from the beginning and the kth node from the end (the list is 1-indexed).\n \nExample 1:\n\n\nInput: head = [1,2,3,4,5], k = 2\nOutput: [1,4,3,2,5]\n\nExample 2:\n\nInput: head = [7,9,6,6,7,8,3,0,9,5], k = 5\nOutput: [7,9,6,6,8,7,3,0,9,5]\n\n \nConstraints:\n\nThe number of nodes in the list is n.\n1 <= k <= n <= 105\n0 <= Node.val <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_list(candidate(head = list_node([100, 0, 1, 0, 100]),k = 3), list_node([100, 0, 1, 0, 100]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]),k = 10), list_node([100, 20, 30, 40, 50, 60, 70, 80, 90, 10]))\n assert is_same_list(candidate(head = list_node([100, 99, 98, 97, 96, 95]),k = 3), list_node([100, 99, 97, 98, 96, 95]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),k = 10), list_node([10, 2, 3, 4, 5, 6, 7, 8, 9, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3]),k = 3), list_node([3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5]),k = 2), list_node([1, 4, 3, 2, 5]))\n assert is_same_list(candidate(head = list_node([7, 9, 6, 6, 7, 8, 3, 0, 9, 5]),k = 5), list_node([7, 9, 6, 6, 8, 7, 3, 0, 9, 5]))\n assert is_same_list(candidate(head = list_node([1, 2]),k = 1), list_node([2, 1]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]),k = 3), list_node([10, 20, 80, 40, 50, 60, 70, 30, 90, 100]))\n assert is_same_list(candidate(head = list_node([1]),k = 1), list_node([1]))\n assert is_same_list(candidate(head = list_node([100, 90]),k = 1), list_node([90, 100]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 5), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 20), list_node([1, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 20]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1]),k = 5), list_node([1, 4, 3, 2, 5]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]),k = 9), list_node([10, 20, 30, 40, 90, 60, 70, 80, 50, 100, 110, 120, 130]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]),k = 15), list_node([29, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 6), list_node([1, 2, 3, 4, 5, 15, 7, 8, 9, 10, 11, 12, 13, 14, 6, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 15), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([42]),k = 1), list_node([42]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]),k = 6), list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 10), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),k = 5), list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))\n assert is_same_list(candidate(head = list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]),k = 10), list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 2), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 0, 2, 0, 3, 0, 4, 0, 5, 0]),k = 4), list_node([1, 0, 2, 4, 3, 0, 0, 0, 5, 0]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 10), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),k = 11), list_node([11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),k = 1), list_node([11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 20), list_node([20, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 5), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]),k = 15), list_node([1, 29, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 3, 31]))\n assert is_same_list(candidate(head = list_node([21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 5), list_node([21, 20, 19, 18, 5, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 17, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 10), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]),k = 10), list_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]),k = 10), list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 21, 19, 23, 25, 27, 29, 31, 33, 35, 37, 39]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]),k = 1), list_node([150, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 10]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]),k = 10), list_node([10, 1, 8, 7, 6, 5, 4, 3, 2, 9, 0]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1]),k = 1), list_node([1, 4, 3, 2, 5]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 7), list_node([1, 2, 3, 4, 5, 6, 9, 8, 7, 10, 11, 12, 13, 14, 15]))\n assert is_same_list(candidate(head = list_node([50, 40, 30, 20, 10]),k = 3), list_node([50, 40, 30, 20, 10]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 16), list_node([1, 2, 3, 4, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]),k = 5), list_node([1, 3, 5, 7, 31, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 9, 33, 35, 37, 39]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]),k = 9), list_node([10, 20, 30, 40, 50, 60, 90, 80, 70, 100, 110, 120, 130, 140, 150]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 2, 0, 3, 0, 4, 0, 5]),k = 3), list_node([0, 1, 4, 2, 0, 3, 0, 0, 0, 5]))\n assert is_same_list(candidate(head = list_node([50, 50, 50, 50, 50, 50, 50, 50, 50, 50]),k = 5), list_node([50, 50, 50, 50, 50, 50, 50, 50, 50, 50]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 9), list_node([1, 8, 7, 6, 5, 4, 3, 2, 9]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]),k = 14), list_node([10, 140, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 20, 150]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 5), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([2, 3, 1, 4, 5, 6, 7, 8, 9]),k = 7), list_node([2, 3, 7, 4, 5, 6, 1, 8, 9]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),k = 3), list_node([1, 2, 9, 4, 5, 6, 7, 8, 3, 10, 11]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 1), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([42, 42, 42, 42, 42, 42]),k = 3), list_node([42, 42, 42, 42, 42, 42]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]),k = 20), list_node([1, 20, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 21]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1]),k = 5), list_node([1, 4, 3, 2, 5]))\n assert is_same_list(candidate(head = list_node([1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1]),k = 5), list_node([1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19]),k = 10), list_node([19, 3, 5, 7, 9, 11, 13, 15, 17, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),k = 8), list_node([1, 2, 8, 4, 5, 6, 7, 3, 9, 10]))\n assert is_same_list(candidate(head = list_node([5, 3, 1, 4, 2]),k = 4), list_node([5, 4, 1, 3, 2]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]),k = 7), list_node([10, 20, 30, 40, 50, 60, 90, 80, 70, 100, 110, 120, 130, 140, 150]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]),k = 10), list_node([9, 8, 7, 6, 5, 0, 3, 2, 1, 4, -1, -2, -3, -4, -5]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),k = 3), list_node([1, 2, 9, 4, 5, 6, 7, 8, 3, 10, 11]))\n assert is_same_list(candidate(head = list_node([8, 6, 4, 2, 0, 2, 4, 6, 8]),k = 5), list_node([8, 6, 4, 2, 0, 2, 4, 6, 8]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]),k = 16), list_node([1, 3, 5, 7, 31, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 9, 33, 35, 37, 39]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 5), list_node([1, 2, 3, 4, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),k = 10), list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]),k = 5), list_node([9, 8, 7, 6, -6, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, 5, -7, -8, -9, -10]))\n assert is_same_list(candidate(head = list_node([5]),k = 1), list_node([5]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]),k = 7), list_node([10, 20, 30, 40, 50, 60, 90, 80, 70, 100, 110, 120, 130, 140, 150]))\n assert is_same_list(candidate(head = list_node([99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]),k = 1), list_node([85, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 99]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),k = 1), list_node([10, 2, 3, 4, 5, 6, 7, 8, 9, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),k = 5), list_node([1, 2, 3, 4, 6, 5, 7, 8, 9, 10]))\n assert is_same_list(candidate(head = list_node([50, 40, 30, 20, 10]),k = 5), list_node([10, 40, 30, 20, 50]))\n assert is_same_list(candidate(head = list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),k = 15), list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))\n assert is_same_list(candidate(head = list_node([5, 1, 9, 7, 4, 6, 2, 3]),k = 4), list_node([5, 1, 9, 4, 7, 6, 2, 3]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),k = 3), list_node([1, 2, 8, 4, 5, 6, 7, 3, 9, 10]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 20), list_node([0, 19, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 1, 20]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 15), list_node([10, 9, 8, 7, 6, 6, 4, 3, 2, 1, 10, 9, 8, 7, 5, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]),k = 20), list_node([1, 2, 3, 4, 5, 20, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 6, 21, 22, 23, 24, 25]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 15), list_node([15, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 10), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3]),k = 2), list_node([1, 2, 3]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20]),k = 5), list_node([2, 4, 6, 8, 12, 10, 14, 16, 18, 20]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]),k = 20), list_node([2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90]),k = 4), list_node([10, 20, 30, 60, 50, 40, 70, 80, 90]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 1), list_node([15, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 3), list_node([1, 2, 13, 4, 5, 6, 7, 8, 9, 10, 11, 12, 3, 14, 15]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 7), list_node([1, 2, 3, 4, 5, 6, 9, 8, 7, 10, 11, 12, 13, 14, 15]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]),k = 7), list_node([10, 9, 8, 7, 6, 5, 1, 3, 2, 4, 0, -1, -2, -3, -4, -5]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),k = 6), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]))\n assert is_same_list(candidate(head = list_node([23, 12, 34, 45, 56, 67, 78, 89, 90, 101, 112, 123]),k = 12), list_node([123, 12, 34, 45, 56, 67, 78, 89, 90, 101, 112, 23]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 15), list_node([1, 2, 3, 4, 5, 15, 7, 8, 9, 10, 11, 12, 13, 14, 6, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]),k = 13), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]),k = 15), list_node([-5, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, 9]))\n assert is_same_list(candidate(head = list_node([50, 40, 30, 20, 10]),k = 1), list_node([10, 40, 30, 20, 50]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 3), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 1), list_node([1, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 20]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]),k = 5), list_node([10, 20, 30, 40, 60, 50, 70, 80, 90, 100]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 3), list_node([9, 8, 3, 6, 5, 4, 7, 2, 1]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]),k = 4), list_node([10, 20, 30, 100, 50, 60, 70, 80, 90, 40, 110, 120, 130]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 8), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]))\n assert is_same_list(candidate(head = list_node([25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 12), list_node([25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 12, 13, 14, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]),k = 10), list_node([100, 99, 98, 97, 96, 95, 94, 93, 92, 90, 91, 89, 88, 87, 86, 85, 84, 83, 82, 81]))\n"}, "metadata": {"canonical_parameter_names": ["head", "k"], "leetcode_dataset_entry_point": "Solution().swapNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def swapNodes(self, head: Optional[ListNode], k: int) -> Optional[ListNode]:", "container": "Solution", "callable": "swapNodes", "parameters": [{"name": "head", "type": "Optional[ListNode]"}, {"name": "k", "type": "int"}], "return_type": "Optional[ListNode]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1722, "task_id": "minimize-hamming-distance-after-swap-operations", "difficulty": "Medium", "problem_description": "You are given two integer arrays, source and target, both of length n. You are also given an array allowedSwaps where each allowedSwaps[i] = [ai, bi] indicates that you are allowed to swap the elements at index ai and index bi (0-indexed) of array source. Note that you can swap elements at a specific pair of indices multiple times and in any order.\nThe Hamming distance of two arrays of the same length, source and target, is the number of positions where the elements are different. Formally, it is the number of indices i for 0 <= i <= n-1 where source[i] != target[i] (0-indexed).\nReturn the minimum Hamming distance of source and target after performing any amount of swap operations on array source.\n \nExample 1:\n\nInput: source = [1,2,3,4], target = [2,1,4,5], allowedSwaps = [[0,1],[2,3]]\nOutput: 1\nExplanation: source can be transformed the following way:\n- Swap indices 0 and 1: source = [2,1,3,4]\n- Swap indices 2 and 3: source = [2,1,4,3]\nThe Hamming distance of source and target is 1 as they differ in 1 position: index 3.\n\nExample 2:\n\nInput: source = [1,2,3,4], target = [1,3,2,4], allowedSwaps = []\nOutput: 2\nExplanation: There are no allowed swaps.\nThe Hamming distance of source and target is 2 as they differ in 2 positions: index 1 and index 2.\n\nExample 3:\n\nInput: source = [5,1,2,4,3], target = [1,5,4,2,3], allowedSwaps = [[0,4],[4,2],[1,3],[1,4]]\nOutput: 0\n\n \nConstraints:\n\nn == source.length == target.length\n1 <= n <= 105\n1 <= source[i], target[i] <= 105\n0 <= allowedSwaps.length <= 105\nallowedSwaps[i].length == 2\n0 <= ai, bi <= n - 1\nai != bi\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(source = [4, 3, 2, 1],target = [1, 2, 3, 4],allowedSwaps = [[0, 3], [1, 2], [0, 1], [2, 3]]) == 0\n assert candidate(source = [4, 3, 2, 1],target = [1, 2, 3, 4],allowedSwaps = [[0, 2], [1, 3]]) == 4\n assert candidate(source = [1, 1, 1, 1],target = [1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3]]) == 0\n assert candidate(source = [1, 2, 3, 4],target = [1, 3, 2, 4],allowedSwaps = []) == 2\n assert candidate(source = [1, 2, 3, 4],target = [2, 1, 4, 5],allowedSwaps = [[0, 1], [2, 3]]) == 1\n assert candidate(source = [5, 1, 2, 4, 3],target = [1, 5, 4, 2, 3],allowedSwaps = [[0, 4], [4, 2], [1, 3], [1, 4]]) == 0\n assert candidate(source = [4, 5, 6],target = [6, 4, 5],allowedSwaps = [[0, 1], [1, 2]]) == 0\n assert candidate(source = [10, 20, 30],target = [30, 20, 10],allowedSwaps = [[0, 2]]) == 0\n assert candidate(source = [1, 1, 1, 1],target = [2, 2, 2, 2],allowedSwaps = [[0, 1], [1, 2], [2, 3]]) == 4\n assert candidate(source = [1, 2, 2, 1],target = [2, 1, 1, 2],allowedSwaps = [[0, 1], [2, 3], [1, 2]]) == 0\n assert candidate(source = [1, 3, 5, 7, 9],target = [9, 7, 5, 3, 1],allowedSwaps = [[0, 4], [1, 3], [2, 2]]) == 0\n assert candidate(source = [1, 2, 2, 1, 3, 3, 4, 4],target = [4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 6], [1, 7], [2, 5], [3, 4], [0, 1], [2, 3], [4, 5], [6, 7]]) == 2\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],allowedSwaps = [[0, 2], [2, 4], [4, 6], [6, 8], [1, 3], [3, 5], [5, 7], [7, 9]]) == 4\n assert candidate(source = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],target = [5, 9, 2, 6, 5, 3, 5, 3, 1, 4, 1],allowedSwaps = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5]]) == 8\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(source = [7, 8, 9, 10, 11, 12, 13],target = [13, 12, 11, 10, 9, 8, 7],allowedSwaps = [[0, 6], [1, 5], [2, 4], [3, 3]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 5], [1, 6], [2, 3], [3, 2], [4, 1], [5, 0]]) == 0\n assert candidate(source = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],target = [99991, 99992, 99993, 99994, 99995, 99996, 99997, 99998, 99999, 100000],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 2], [1, 3]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 0\n assert candidate(source = [7, 8, 9, 10, 11, 12],target = [12, 11, 10, 9, 8, 7],allowedSwaps = [[0, 5], [1, 4], [2, 3]]) == 0\n assert candidate(source = [1, 3, 5, 7, 9, 11],target = [11, 9, 7, 5, 3, 1],allowedSwaps = [[0, 5], [1, 4], [2, 3]]) == 0\n assert candidate(source = [1, 3, 5, 7, 9, 11, 13, 15],target = [15, 13, 11, 9, 7, 5, 3, 1],allowedSwaps = [[0, 7], [1, 6], [2, 5], [3, 4]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = [90, 80, 70, 60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4]]) == 0\n assert candidate(source = [5, 5, 5, 5, 5, 5],target = [5, 5, 5, 5, 5, 5],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = []) == 10\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 3], [4, 6]]) == 0\n assert candidate(source = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],target = [8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8], [0, 7], [1, 6], [2, 5], [3, 4]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],allowedSwaps = [[0, 1]]) == 9\n assert candidate(source = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 4], [1, 3], [2, 8], [5, 7], [6, 9]]) == 8\n assert candidate(source = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7]]) == 8\n assert candidate(source = [10, 20, 30, 40, 50, 60],target = [60, 20, 50, 40, 30, 10],allowedSwaps = [[0, 5], [2, 4], [0, 2]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = [9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 8], [1, 7], [2, 6], [3, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50],target = [50, 40, 30, 20, 10],allowedSwaps = [[0, 4], [1, 3], [2, 2]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 6\n assert candidate(source = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],allowedSwaps = []) == 0\n assert candidate(source = [7, 8, 9, 10, 11, 12, 13],target = [13, 12, 11, 10, 9, 8, 7],allowedSwaps = [[0, 6], [1, 5], [2, 4], [0, 3]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50],target = [50, 40, 30, 20, 10],allowedSwaps = [[0, 4], [1, 3]]) == 0\n assert candidate(source = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],allowedSwaps = []) == 10\n assert candidate(source = [1, 1, 2, 2, 3, 3],target = [3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 2], [0, 4], [1, 3], [1, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 20\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 7], [1, 6], [2, 5], [3, 4]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 10\n assert candidate(source = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [1, 5], [2, 6], [3, 7], [0, 8], [1, 9], [2, 5], [3, 6], [4, 7]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],allowedSwaps = [[0, 1], [1, 9], [9, 8]]) == 7\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 3], [4, 6], [7, 8]]) == 0\n assert candidate(source = [3, 2, 1, 4, 5],target = [5, 4, 3, 2, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 1, 19, 2, 18, 3, 17, 4, 16, 5, 15, 6, 14, 7, 13, 8, 12, 9, 11, 10],allowedSwaps = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 16\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(source = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [4, 1, 3, 2],target = [2, 3, 1, 4],allowedSwaps = [[0, 1], [1, 2], [2, 3], [0, 2], [1, 3]]) == 0\n assert candidate(source = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 3], [4, 6], [7, 8]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],allowedSwaps = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == 0\n assert candidate(source = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],target = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 12\n assert candidate(source = [7, 8, 9, 10, 11, 12],target = [10, 11, 12, 7, 8, 9],allowedSwaps = [[0, 3], [1, 4], [2, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 10\n assert candidate(source = [1, 1, 1, 1, 1],target = [1, 1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [1, 5], [2, 6], [3, 7]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],target = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50, 60],target = [60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 5], [1, 4], [2, 3]]) == 0\n assert candidate(source = [1, 1, 2, 2, 3, 3, 4, 4],target = [4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 6], [1, 7], [2, 5], [3, 4]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = [9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 8], [1, 7], [2, 6], [3, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],target = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8]]) == 0\n assert candidate(source = [100000, 90000, 80000, 70000],target = [70000, 80000, 90000, 100000],allowedSwaps = [[0, 3], [1, 2], [0, 1], [2, 3]]) == 0\n assert candidate(source = [4, 4, 4, 4, 4],target = [1, 2, 3, 4, 5],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 4\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 2, 9, 3, 8, 4, 7, 5, 6, 1],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 5\n assert candidate(source = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == 10\n assert candidate(source = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],target = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 3], [4, 8], [5, 7]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],allowedSwaps = []) == 0\n assert candidate(source = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n"}, "metadata": {"canonical_parameter_names": ["source", "target", "allowedSwaps"], "leetcode_dataset_entry_point": "Solution().minimumHammingDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumHammingDistance(self, source: list[int], target: list[int], allowedSwaps: list[list[int]]) -> int:", "container": "Solution", "callable": "minimumHammingDistance", "parameters": [{"name": "source", "type": "list[int]"}, {"name": "target", "type": "list[int]"}, {"name": "allowedSwaps", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1723, "task_id": "find-minimum-time-to-finish-all-jobs", "difficulty": "Hard", "problem_description": "You are given an integer array jobs, where jobs[i] is the amount of time it takes to complete the ith job.\nThere are k workers that you can assign jobs to. Each job should be assigned to exactly one worker. The working time of a worker is the sum of the time it takes to complete all jobs assigned to them. Your goal is to devise an optimal assignment such that the maximum working time of any worker is minimized.\nReturn the minimum possible maximum working time of any assignment. \n \nExample 1:\n\nInput: jobs = [3,2,3], k = 3\nOutput: 3\nExplanation: By assigning each person one job, the maximum time is 3.\n\nExample 2:\n\nInput: jobs = [1,2,4,7,8], k = 2\nOutput: 11\nExplanation: Assign the jobs the following way:\nWorker 1: 1, 2, 8 (working time = 1 + 2 + 8 = 11)\nWorker 2: 4, 7 (working time = 4 + 7 = 11)\nThe maximum working time is 11.\n \nConstraints:\n\n1 <= k <= jobs.length <= 12\n1 <= jobs[i] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(jobs = [1, 2, 4, 7, 8],k = 2) == 11\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 4) == 20\n assert candidate(jobs = [6, 5, 4, 3, 2, 1],k = 6) == 6\n assert candidate(jobs = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 20\n assert candidate(jobs = [10, 20, 30, 40, 50, 60],k = 3) == 70\n assert candidate(jobs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 12) == 10\n assert candidate(jobs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 4) == 3\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 6) == 13\n assert candidate(jobs = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 6) == 18\n assert candidate(jobs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 6) == 10\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 12) == 120\n assert candidate(jobs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 12) == 1\n assert candidate(jobs = [3, 2, 3],k = 3) == 3\n assert candidate(jobs = [5, 5, 3, 2, 4, 1],k = 3) == 7\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 3) == 26\n assert candidate(jobs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 15\n assert candidate(jobs = [12, 3, 5, 8, 9, 4, 7, 6, 2, 10, 11, 1],k = 5) == 16\n assert candidate(jobs = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 6) == 100\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 5) == 160\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 7) == 12\n assert candidate(jobs = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000],k = 2) == 39000\n assert candidate(jobs = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 0],k = 4) == 140\n assert candidate(jobs = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 2) == 18\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 7) == 120\n assert candidate(jobs = [10000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],k = 4) == 10000000\n assert candidate(jobs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],k = 4) == 40\n assert candidate(jobs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 3) == 130\n assert candidate(jobs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 4) == 36\n assert candidate(jobs = [3, 7, 1, 10, 5, 2, 8, 6, 4, 9, 11, 12],k = 5) == 16\n assert candidate(jobs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 4) == 11\n assert candidate(jobs = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000],k = 6) == 20000000\n assert candidate(jobs = [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12],k = 6) == 24\n assert candidate(jobs = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 1) == 36\n assert candidate(jobs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 5) == 1600\n assert candidate(jobs = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 8) == 12\n assert candidate(jobs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 12) == 23\n assert candidate(jobs = [30, 15, 40, 10, 25, 5, 60, 45, 20, 50, 55, 35],k = 5) == 80\n assert candidate(jobs = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 1) == 12000000\n assert candidate(jobs = [20, 10, 30, 25, 15, 5, 40, 35, 50, 100, 200, 50],k = 3) == 200\n assert candidate(jobs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14],k = 3) == 28\n assert candidate(jobs = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],k = 6) == 56\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 4) == 200\n assert candidate(jobs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 6) == 65\n assert candidate(jobs = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],k = 4) == 38\n assert candidate(jobs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 6) == 4\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 2) == 390\n assert candidate(jobs = [9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11, 10],k = 4) == 20\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 2) == 39\n assert candidate(jobs = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],k = 4) == 140\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 1) == 78\n assert candidate(jobs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 11) == 1200\n assert candidate(jobs = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 7) == 12\n assert candidate(jobs = [1000, 1000, 1000, 1000, 2000, 2000, 2000, 2000, 3000, 3000, 3000, 3000],k = 8) == 3000\n assert candidate(jobs = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 4) == 200\n assert candidate(jobs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 3) == 8\n assert candidate(jobs = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],k = 4) == 60\n assert candidate(jobs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 5) == 30\n assert candidate(jobs = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 12\n assert candidate(jobs = [2, 5, 10, 17, 26, 37, 50, 65, 82, 101, 122, 145],k = 4) == 168\n assert candidate(jobs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 8) == 4\n assert candidate(jobs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 12) == 1200\n assert candidate(jobs = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000],k = 2) == 39000\n assert candidate(jobs = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],k = 6) == 91\n assert candidate(jobs = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == 13\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 2) == 390\n assert candidate(jobs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],k = 5) == 2048\n assert candidate(jobs = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 11],k = 6) == 13\n assert candidate(jobs = [1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000],k = 4) == 5000\n assert candidate(jobs = [7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1],k = 2) == 17\n assert candidate(jobs = [10000000, 10000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 10000000\n assert candidate(jobs = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37],k = 3) == 66\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 3) == 260\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 4) == 200\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 12) == 12\n assert candidate(jobs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 8) == 20\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 3) == 260\n assert candidate(jobs = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 8) == 14\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 4) == 20\n assert candidate(jobs = [3, 5, 7, 12, 4, 8, 9, 11, 6, 10, 2, 1],k = 3) == 26\n assert candidate(jobs = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3],k = 5) == 11\n assert candidate(jobs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 3) == 14\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 12) == 120\n assert candidate(jobs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 4) == 36\n assert candidate(jobs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 6) == 1300\n assert candidate(jobs = [10000000, 1000000, 100000, 10000, 1000, 100, 10, 1, 1, 1, 1, 1],k = 7) == 10000000\n assert candidate(jobs = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5],k = 6) == 7\n assert candidate(jobs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 4) == 11\n assert candidate(jobs = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115],k = 5) == 150\n assert candidate(jobs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],k = 3) == 2048\n assert candidate(jobs = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1],k = 5) == 10\n assert candidate(jobs = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 26\n assert candidate(jobs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11],k = 4) == 20\n assert candidate(jobs = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 6) == 14\n assert candidate(jobs = [7, 2, 8, 9, 4, 3, 6, 1, 5, 10, 11, 12],k = 3) == 26\n assert candidate(jobs = [10000000, 1000000, 100000, 10000, 1000, 100, 10, 1, 1, 1, 1, 1],k = 3) == 10000000\n assert candidate(jobs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 3) == 40\n assert candidate(jobs = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],k = 4) == 8\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 12) == 12\n assert candidate(jobs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 8) == 60\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 6) == 130\n assert candidate(jobs = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 5) == 18\n assert candidate(jobs = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],k = 4) == 14\n assert candidate(jobs = [9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 20, 25],k = 5) == 25\n assert candidate(jobs = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],k = 3) == 56\n assert candidate(jobs = [5, 7, 12, 18, 23, 30, 37, 40, 45, 50, 55, 60],k = 3) == 128\n assert candidate(jobs = [10000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],k = 5) == 10000000\n assert candidate(jobs = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000, 100000, 10000],k = 6) == 10000000\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 1) == 78\n assert candidate(jobs = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144],k = 9) == 144\n assert candidate(jobs = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37],k = 5) == 40\n assert candidate(jobs = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062, 19531, 9765, 4882],k = 3) == 10000000\n"}, "metadata": {"canonical_parameter_names": ["jobs", "k"], "leetcode_dataset_entry_point": "Solution().minimumTimeRequired", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumTimeRequired(self, jobs: list[int], k: int) -> int:", "container": "Solution", "callable": "minimumTimeRequired", "parameters": [{"name": "jobs", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1725, "task_id": "number-of-rectangles-that-can-form-the-largest-square", "difficulty": "Easy", "problem_description": "You are given an array rectangles where rectangles[i] = [li, wi] represents the ith rectangle of length li and width wi.\\r\n\\r\nYou can cut the ith rectangle to form a square with a side length of k if both k <= li and k <= wi. For example, if you have a rectangle [4,6], you can cut it to get a square with a side length of at most 4.\\r\n\\r\nLet maxLen be the side length of the largest square you can obtain from any of the given rectangles.\\r\n\\r\nReturn the number of rectangles that can make a square with a side length of maxLen.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: rectangles = [[5,8],[3,9],[5,12],[16,5]]\\r\nOutput: 3\\r\nExplanation: The largest squares you can get from each rectangle are of lengths [5,3,5,5].\\r\nThe largest possible square is of length 5, and you can get it out of 3 rectangles.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: rectangles = [[2,3],[3,7],[4,3],[3,7]]\\r\nOutput: 3\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= rectangles.length <= 1000\\r\n\trectangles[i].length == 2\\r\n\t1 <= li, wi <= 109\\r\n\tli != wi\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rectangles = [[1, 2], [2, 1], [3, 4], [4, 3]]) == 2\n assert candidate(rectangles = [[2, 3], [3, 7], [4, 3], [3, 7]]) == 3\n assert candidate(rectangles = [[1000000000, 1000000000], [999999999, 999999999], [1, 1]]) == 1\n assert candidate(rectangles = [[5, 8], [3, 9], [5, 12], [16, 5]]) == 3\n assert candidate(rectangles = [[10, 20], [20, 10], [5, 5], [15, 15]]) == 1\n assert candidate(rectangles = [[100, 200], [200, 100], [150, 150], [250, 250], [50, 50], [250, 300], [300, 250], [300, 300], [350, 350]]) == 1\n assert candidate(rectangles = [[7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 1\n assert candidate(rectangles = [[10, 1], [1, 10], [20, 2], [2, 20], [30, 3], [3, 30], [40, 4], [4, 40], [50, 5], [5, 50]]) == 2\n assert candidate(rectangles = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]]) == 1\n assert candidate(rectangles = [[100, 200], [200, 100], [150, 150], [140, 160], [160, 140], [130, 170], [120, 180], [180, 120], [170, 130]]) == 1\n assert candidate(rectangles = [[500000000, 500000000], [400000000, 600000000], [600000000, 400000000], [300000000, 700000000], [700000000, 300000000], [200000000, 800000000], [800000000, 200000000]]) == 1\n assert candidate(rectangles = [[100, 100], [101, 101], [102, 102], [103, 103], [104, 104], [105, 105], [106, 106], [107, 107], [108, 108], [109, 109]]) == 1\n assert candidate(rectangles = [[50, 20], [20, 50], [40, 40], [30, 30], [25, 25], [25, 35], [35, 25], [30, 20]]) == 1\n assert candidate(rectangles = [[5, 10], [10, 5], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 1\n assert candidate(rectangles = [[8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 1\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10], [10, 1]]) == 1\n assert candidate(rectangles = [[999999999, 1], [1, 999999999], [500000000, 500000000], [500000000, 500000000], [500000000, 500000000], [100000000, 100000000], [100000000, 100000000], [100000000, 100000000], [100000000, 100000000]]) == 3\n assert candidate(rectangles = [[5, 5], [5, 4], [4, 5], [3, 3], [2, 2], [1, 1]]) == 1\n assert candidate(rectangles = [[10, 10], [15, 5], [20, 20], [5, 15]]) == 1\n assert candidate(rectangles = [[10, 20], [20, 10], [15, 15], [12, 12], [18, 18], [18, 19], [19, 18]]) == 3\n assert candidate(rectangles = [[1, 999999999], [2, 999999998], [3, 999999997], [4, 999999996], [5, 999999995]]) == 1\n assert candidate(rectangles = [[1, 999999999], [2, 999999998], [3, 999999997], [4, 999999996], [5, 999999995]]) == 1\n assert candidate(rectangles = [[2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]]) == 20\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [2, 2], [3, 3]]) == 1\n assert candidate(rectangles = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10]]) == 1\n assert candidate(rectangles = [[10, 15], [12, 12], [8, 8], [12, 12], [15, 10], [11, 11]]) == 2\n assert candidate(rectangles = [[1000, 999], [999, 1000], [998, 998], [997, 997], [996, 996], [995, 995], [994, 994], [993, 993], [992, 992], [991, 991]]) == 2\n assert candidate(rectangles = [[2, 4], [4, 2], [3, 6], [6, 3], [4, 8], [8, 4], [5, 10], [10, 5], [6, 12], [12, 6], [7, 14], [14, 7], [8, 16], [16, 8], [9, 18], [18, 9], [10, 20], [20, 10]]) == 2\n assert candidate(rectangles = [[100, 200], [200, 100], [150, 150], [250, 250], [250, 200], [200, 250], [300, 300]]) == 1\n assert candidate(rectangles = [[1, 1000000000], [1000000000, 1], [2, 500000000], [500000000, 2]]) == 2\n assert candidate(rectangles = [[3, 1], [1, 3], [4, 2], [2, 4], [5, 3], [3, 5], [6, 4], [4, 6], [7, 5], [5, 7], [8, 6], [6, 8]]) == 2\n assert candidate(rectangles = [[7, 3], [3, 7], [4, 4], [5, 5], [5, 6], [6, 5]]) == 3\n assert candidate(rectangles = [[1, 1000000000], [1000000000, 1], [500000000, 500000000], [1000000000, 1000000000], [500000000, 1000000000]]) == 1\n assert candidate(rectangles = [[10, 20], [20, 10], [15, 15], [12, 12], [8, 8], [8, 12], [12, 8]]) == 1\n assert candidate(rectangles = [[10, 20], [20, 10], [15, 15], [12, 18], [18, 12]]) == 1\n assert candidate(rectangles = [[5, 5], [3, 3], [2, 2], [4, 4], [6, 6], [6, 6], [6, 7], [7, 6]]) == 4\n assert candidate(rectangles = [[500000000, 500000000], [600000000, 600000000], [500000000, 400000000], [400000000, 500000000]]) == 1\n assert candidate(rectangles = [[1000, 1000], [999, 999], [998, 998], [997, 997], [996, 996], [995, 995], [994, 994], [993, 993], [992, 992], [991, 991]]) == 1\n assert candidate(rectangles = [[500, 400], [300, 300], [450, 500], [400, 400], [450, 450], [400, 500]]) == 2\n assert candidate(rectangles = [[1, 1000000000], [1000000000, 1], [500000000, 500000000], [500000000, 500000001], [500000001, 500000000]]) == 3\n assert candidate(rectangles = [[2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [10, 11], [11, 10]]) == 2\n assert candidate(rectangles = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == 3\n assert candidate(rectangles = [[100, 200], [101, 199], [102, 198], [103, 197], [104, 196], [105, 195], [106, 194], [107, 193], [108, 192], [109, 191], [110, 190]]) == 1\n assert candidate(rectangles = [[10, 1], [1, 10], [5, 5], [5, 5], [2, 2]]) == 2\n assert candidate(rectangles = [[10, 20], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]]) == 1\n assert candidate(rectangles = [[500, 500], [499, 501], [498, 502], [497, 503], [496, 504], [495, 505], [494, 506], [493, 507], [492, 508], [491, 509]]) == 1\n assert candidate(rectangles = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 1\n assert candidate(rectangles = [[10, 5], [9, 4], [8, 3], [7, 2], [6, 1], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10], [11, 11], [12, 12]]) == 1\n assert candidate(rectangles = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 20\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]]) == 1\n assert candidate(rectangles = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 5\n assert candidate(rectangles = [[8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8]]) == 12\n assert candidate(rectangles = [[1, 1000000000], [1000000000, 1], [2, 999999998], [999999998, 2], [3, 999999996], [999999996, 3], [4, 999999994], [999999994, 4], [5, 999999992], [999999992, 5]]) == 2\n assert candidate(rectangles = [[10, 20], [15, 15], [20, 10], [30, 30], [25, 25]]) == 1\n assert candidate(rectangles = [[300, 400], [400, 300], [250, 250], [250, 250], [250, 250], [250, 250], [100, 100]]) == 2\n assert candidate(rectangles = [[500000000, 500000000], [400000000, 400000000], [300000000, 300000000], [200000000, 200000000], [100000000, 100000000]]) == 1\n assert candidate(rectangles = [[999999999, 1000000000], [1000000000, 999999999], [1, 1000000000], [1000000000, 1], [2, 999999999], [999999999, 2], [3, 999999998], [999999998, 3], [4, 999999997], [999999997, 4]]) == 2\n assert candidate(rectangles = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 2\n assert candidate(rectangles = [[7, 10], [10, 7], [8, 10], [10, 8], [9, 9], [6, 11], [11, 6], [5, 12], [12, 5], [4, 13], [13, 4]]) == 1\n assert candidate(rectangles = [[10, 20], [20, 10], [15, 15], [25, 25], [5, 5], [25, 30], [30, 25]]) == 3\n assert candidate(rectangles = [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(rectangles = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [100, 100], [200, 200], [300, 300]]) == 1\n assert candidate(rectangles = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 15\n assert candidate(rectangles = [[100, 200], [50, 50], [50, 50], [75, 75], [75, 75], [75, 75]]) == 1\n assert candidate(rectangles = [[2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [11, 10], [12, 11], [13, 12], [1, 12], [12, 1]]) == 1\n assert candidate(rectangles = [[1000, 1000], [999, 1001], [1001, 999], [1002, 1002], [1003, 1003], [1004, 1004]]) == 1\n assert candidate(rectangles = [[500000000, 1000000000], [1000000000, 500000000], [300000000, 300000000], [200000000, 200000000]]) == 2\n assert candidate(rectangles = [[11, 12], [12, 11], [13, 14], [14, 13], [15, 16], [16, 15], [17, 18], [18, 17], [19, 20], [20, 19]]) == 2\n assert candidate(rectangles = [[10, 20], [20, 10], [15, 15], [15, 15], [15, 15], [5, 5], [5, 5], [5, 5], [5, 5]]) == 3\n assert candidate(rectangles = [[10, 20], [20, 10], [30, 40], [40, 30], [50, 60], [60, 50], [70, 80], [80, 70], [90, 100], [100, 90]]) == 2\n assert candidate(rectangles = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == 1\n assert candidate(rectangles = [[200000000, 200000000], [199999999, 200000001], [199999998, 200000002], [199999997, 200000003], [199999996, 200000004]]) == 1\n assert candidate(rectangles = [[20, 20], [19, 19], [18, 18], [17, 17], [16, 16], [15, 15], [14, 14], [13, 13], [12, 12], [11, 11], [10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 1\n assert candidate(rectangles = [[50, 70], [70, 50], [60, 60], [40, 80], [80, 40]]) == 1\n assert candidate(rectangles = [[999999999, 1000000000], [1000000000, 999999999], [999999998, 999999998], [1000000001, 1000000001], [999999997, 999999997]]) == 1\n assert candidate(rectangles = [[15, 20], [20, 15], [25, 30], [30, 25], [35, 40], [40, 35], [45, 50], [50, 45]]) == 2\n assert candidate(rectangles = [[5, 10], [10, 5], [15, 20], [20, 15], [25, 30], [30, 25], [35, 40], [40, 35]]) == 2\n assert candidate(rectangles = [[1000000000, 1000000000], [999999999, 999999999], [999999998, 999999998], [999999997, 999999997], [999999996, 999999996]]) == 1\n assert candidate(rectangles = [[3, 4], [4, 3], [5, 5], [5, 5], [5, 5], [5, 6], [6, 5], [6, 6], [6, 6], [6, 6], [7, 7], [7, 7], [7, 7], [7, 7], [7, 7], [7, 8], [8, 7], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8]]) == 7\n assert candidate(rectangles = [[10, 20], [20, 10], [15, 15], [14, 16], [16, 14], [13, 17]]) == 1\n assert candidate(rectangles = [[10, 10], [9, 11], [11, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2]]) == 1\n assert candidate(rectangles = [[1000000000, 1], [1000000000, 2], [1000000000, 3], [1000000000, 4], [1000000000, 5]]) == 1\n assert candidate(rectangles = [[8, 9], [9, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 2\n"}, "metadata": {"canonical_parameter_names": ["rectangles"], "leetcode_dataset_entry_point": "Solution().countGoodRectangles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countGoodRectangles(self, rectangles: List[List[int]]) -> int:", "container": "Solution", "callable": "countGoodRectangles", "parameters": [{"name": "rectangles", "type": "List[List[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1726, "task_id": "tuple-with-same-product", "difficulty": "Medium", "problem_description": "Given an array nums of distinct positive integers, return the number of tuples (a, b, c, d) such that a * b = c * d where a, b, c, and d are elements of nums, and a != b != c != d.\n \nExample 1:\n\nInput: nums = [2,3,4,6]\nOutput: 8\nExplanation: There are 8 valid tuples:\n(2,6,3,4) , (2,6,4,3) , (6,2,3,4) , (6,2,4,3)\n(3,4,2,6) , (4,3,2,6) , (3,4,6,2) , (4,3,6,2)\n\nExample 2:\n\nInput: nums = [1,2,4,5,10]\nOutput: 16\nExplanation: There are 16 valid tuples:\n(1,10,2,5) , (1,10,5,2) , (10,1,2,5) , (10,1,5,2)\n(2,5,1,10) , (2,5,10,1) , (5,2,1,10) , (5,2,10,1)\n(2,10,4,5) , (2,10,5,4) , (10,2,4,5) , (10,2,5,4)\n(4,5,2,10) , (4,5,10,2) , (5,4,2,10) , (5,4,10,2)\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 104\nAll elements in nums are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 16\n assert candidate(nums = [7, 8, 9, 14, 21]) == 0\n assert candidate(nums = [7, 11, 13, 19, 23, 29, 31]) == 0\n assert candidate(nums = [2, 5, 10, 15, 20]) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64]) == 56\n assert candidate(nums = [7, 8, 14, 21]) == 0\n assert candidate(nums = [2, 3, 4, 6]) == 8\n assert candidate(nums = [8, 12, 16, 20, 24]) == 8\n assert candidate(nums = [1, 2, 4, 5, 10]) == 16\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 72\n assert candidate(nums = [1, 10, 100, 1000]) == 8\n assert candidate(nums = [2, 3, 5, 7, 11, 13]) == 0\n assert candidate(nums = [10, 20, 30, 60]) == 8\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 72\n assert candidate(nums = [10, 15, 20, 30, 40, 50, 60, 75, 100, 150, 200, 300, 500, 1000]) == 600\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == 536\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 72\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 72\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729]) == 104\n assert candidate(nums = [1, 6, 9, 18, 27, 54, 81]) == 48\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 560\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120]) == 784\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 136\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240]) == 1664\n assert candidate(nums = [3, 5, 15, 25, 45, 75, 125, 150, 225, 250, 375, 500, 625, 750, 1125, 1250, 1875, 2500, 3125, 3750, 5625, 6250, 9375, 12500, 18750, 31250, 93750]) == 4624\n assert candidate(nums = [3, 6, 9, 12, 18, 27, 36, 54, 72, 108]) == 256\n assert candidate(nums = [10, 20, 40, 50, 80, 100, 160, 200, 250, 400, 500, 800, 1000, 1600, 2000, 2500, 4000, 5000, 8000, 10000]) == 2784\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == 184\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == 400\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225]) == 248\n assert candidate(nums = [5, 10, 15, 25, 50, 75, 125, 250, 375, 625]) == 176\n assert candidate(nums = [12, 15, 20, 25, 30, 60, 100, 150]) == 40\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90]) == 240\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 136\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == 272\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 536\n assert candidate(nums = [2, 6, 12, 18, 36, 72, 108, 216, 324, 432, 648, 1296]) == 472\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 400\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969]) == 1288\n assert candidate(nums = [13, 169, 182, 221, 260, 299, 338, 416, 507, 520, 598, 754, 780, 952, 1098, 1170, 1232, 1300, 1595, 1638, 1904, 2196, 2340, 2600, 3190, 3276, 3808, 4392, 4680, 5200, 6380, 6552, 7616, 8784, 9360, 10400, 12760, 13104, 15232, 17568, 18720, 20800, 25520, 26208, 30464, 35136, 37440, 41600, 51040, 52416, 60928, 70272, 74880, 83200, 102080, 104832, 121856, 140544, 149760, 166400, 204160, 209664, 243712, 281088, 299520, 332800, 408320, 419328, 487424, 562176, 599040, 665600, 816640, 838656, 974848, 1124352, 1198080, 1331200, 1633280, 1677312, 1949696, 2248704, 2396160, 2662400, 3266560, 3354624, 3899392, 4497408, 4792320, 5324800, 6533120, 6709248, 7798784, 8994816, 9584640, 10649600, 13066240, 13418496, 15597568, 17989632, 19169280, 21299200, 26132480, 26836992, 31195136, 35979264, 38338560, 42598400, 52264960, 53673984, 62390272, 71958528, 76677120, 85196800, 104529920, 107347968, 124780544, 143917056, 153354240, 170393600, 209059840, 214695936, 249561088, 287834112, 306708480, 340787200, 418119680, 429391872, 499122176, 575668224, 613416960, 681574400, 836239360, 858783744, 998244352, 1151336448, 1226833920, 1363148800]) == 359800\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 400\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 32, 48, 64]) == 112\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120]) == 248\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]) == 0\n assert candidate(nums = [2, 5, 10, 25, 50, 125, 250, 625, 1250, 3125, 6250]) == 400\n assert candidate(nums = [1, 2, 3, 4, 6, 8, 12, 24]) == 128\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907]) == 1624\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132]) == 136\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729]) == 104\n assert candidate(nums = [1, 2, 3, 4, 6, 8, 12, 24]) == 128\n assert candidate(nums = [2, 3, 6, 12, 24, 48, 96, 192, 384, 768]) == 272\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175]) == 968\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 72\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96]) == 304\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100]) == 968\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625]) == 968\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209]) == 408\n assert candidate(nums = [2, 3, 5, 6, 10, 15, 30]) == 48\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154]) == 184\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 2464\n assert candidate(nums = [12, 15, 20, 24, 30, 36, 40, 45, 48, 60, 72, 80, 90, 120, 144, 180, 240, 360, 720]) == 1592\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 400\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275, 286, 297, 308, 319, 330, 341, 352, 363, 374, 385, 396, 407, 418, 429, 440, 451, 462, 473, 484, 495]) == 4592\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180]) == 1664\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 60, 100]) == 56\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 536\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 248\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 1288\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 253, 276, 299, 322, 345, 368, 391, 414, 437, 460, 483, 506, 529, 552, 575, 598, 621, 644, 667, 690, 713, 736, 759, 782, 805, 828, 851, 874, 897, 920, 943, 966, 989, 1012]) == 4200\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == 400\n assert candidate(nums = [10, 15, 30, 45, 60, 90, 120, 135, 180, 225]) == 144\n assert candidate(nums = [1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625]) == 1000\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260]) == 536\n assert candidate(nums = [5, 10, 15, 25, 50, 75, 125, 250, 375, 625]) == 176\n assert candidate(nums = [12, 15, 18, 20, 24, 30, 36, 40, 45, 48, 60, 72, 80, 90, 120, 144, 150, 180, 200, 240, 300, 360, 400, 450, 720, 900]) == 4112\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625]) == 400\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75]) == 968\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561]) == 176\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 248\n assert candidate(nums = [5, 10, 15, 20, 25, 50, 100, 200]) == 72\n assert candidate(nums = [5, 10, 15, 20, 25, 50, 75, 100]) == 64\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == 184\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 20, 24, 30, 40, 60, 120]) == 1168\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == 72\n assert candidate(nums = [2, 5, 10, 20, 25, 50, 100, 125, 250, 500, 1000, 2500, 5000]) == 608\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 209, 228, 247, 266, 285, 304, 323, 342, 361, 380, 399, 418, 437, 456, 475, 494, 513, 532, 551, 570, 589, 608, 627, 646, 665, 684, 703, 722, 741, 760]) == 3432\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132]) == 136\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 560\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608]) == 4920\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290, 319, 348, 377, 406, 435, 464, 493, 522, 551, 580, 609, 638, 667, 696, 725, 754, 783, 812, 841, 870, 899, 928, 957, 986, 1015, 1044, 1073, 1102, 1131, 1160, 1189, 1218, 1247, 1276, 1305, 1334, 1363, 1392, 1421, 1450, 1479, 1508, 1537, 1566, 1595, 1624]) == 7912\n assert candidate(nums = [2, 5, 10, 20, 25, 50, 100, 125, 200, 250, 500, 1000]) == 472\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208]) == 304\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340, 357, 374, 391, 408, 425]) == 968\n assert candidate(nums = [2, 5, 10, 20, 25, 50, 100, 125, 200, 250, 500, 1000, 1250, 2000, 2500, 5000, 10000]) == 1584\n assert candidate(nums = [12, 18, 24, 36, 48, 72, 96, 144, 216, 288, 432, 576, 720, 864, 1152, 1728, 2160, 2592, 3456, 4320]) == 1840\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 3552\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 1000\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 400\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260, 273, 286, 299, 312, 325, 338, 351, 364, 377, 390]) == 1664\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340]) == 536\n assert candidate(nums = [2, 5, 10, 25, 50, 125, 250, 625]) == 128\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60]) == 248\n assert candidate(nums = [5, 10, 15, 20, 25, 50, 100, 200]) == 72\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().tupleSameProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def tupleSameProduct(self, nums: list[int]) -> int:", "container": "Solution", "callable": "tupleSameProduct", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1727, "task_id": "largest-submatrix-with-rearrangements", "difficulty": "Medium", "problem_description": "You are given a binary matrix matrix of size m x n, and you are allowed to rearrange the columns of the matrix in any order.\nReturn the area of the largest submatrix within matrix where every element of the submatrix is 1 after reordering the columns optimally.\n \nExample 1:\n\n\nInput: matrix = [[0,0,1],[1,1,1],[1,0,1]]\nOutput: 4\nExplanation: You can rearrange the columns as shown above.\nThe largest submatrix of 1s, in bold, has an area of 4.\n\nExample 2:\n\n\nInput: matrix = [[1,0,1,0,1]]\nOutput: 3\nExplanation: You can rearrange the columns as shown above.\nThe largest submatrix of 1s, in bold, has an area of 3.\n\nExample 3:\n\nInput: matrix = [[1,1,0],[1,0,1]]\nOutput: 2\nExplanation: Notice that you must rearrange entire columns, and there is no way to make a submatrix of 1s larger than an area of 2.\n\n \nConstraints:\n\nm == matrix.length\nn == matrix[i].length\n1 <= m * n <= 105\nmatrix[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[0, 1], [1, 0]]) == 1\n assert candidate(matrix = [[1, 1, 0], [1, 0, 1]]) == 2\n assert candidate(matrix = [[0, 0, 1], [1, 1, 1], [1, 0, 1]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(matrix = [[1, 0, 1, 0, 1]]) == 3\n assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0]]) == 6\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1], [1, 0, 1, 1, 0, 1], [0, 1, 1, 0, 1, 1], [1, 1, 0, 1, 1, 0], [0, 0, 1, 1, 0, 1]]) == 4\n assert candidate(matrix = [[1, 0, 1, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 4\n assert candidate(matrix = [[1, 0, 0, 0, 0, 0, 1, 0, 1, 1], [0, 1, 1, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 15\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 20\n assert candidate(matrix = [[1, 1, 1, 0, 1, 1, 1], [0, 1, 1, 1, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1], [1, 1, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 1], [1, 0, 0, 1, 0, 1]]) == 4\n assert candidate(matrix = [[1, 0, 1, 0, 1, 1], [1, 1, 1, 0, 1, 0], [1, 0, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1], [1, 0, 0, 0], [1, 1, 0, 1], [0, 0, 1, 1], [1, 1, 1, 1]]) == 4\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 0, 0]]) == 8\n assert candidate(matrix = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 0, 1, 1]]) == 4\n assert candidate(matrix = [[1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1]]) == 5\n assert candidate(matrix = [[1, 1, 1, 0, 0], [0, 1, 1, 1, 0], [1, 0, 1, 1, 1]]) == 4\n assert candidate(matrix = [[0, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 16\n assert candidate(matrix = [[1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 1, 1, 1, 0], [1, 0, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 0, 0, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [1, 1, 1, 0, 1]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 1, 1], [0, 0, 1, 1, 1], [1, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 1, 0, 0, 1], [0, 1, 1, 1, 1, 0], [1, 1, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0]]) == 6\n assert candidate(matrix = [[1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 1, 1, 0, 0, 1]]) == 6\n assert candidate(matrix = [[0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1]]) == 4\n assert candidate(matrix = [[0, 1, 1, 1], [1, 1, 0, 1], [1, 0, 1, 1], [1, 1, 1, 0]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 12\n assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1], [0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 0, 1]]) == 5\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 15\n assert candidate(matrix = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1], [1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 0, 1], [0, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[0, 1, 1, 0], [1, 1, 1, 1], [1, 0, 1, 1]]) == 6\n assert candidate(matrix = [[0, 0, 0, 0], [0, 1, 1, 0], [1, 1, 1, 1], [0, 1, 1, 0], [1, 1, 1, 1]]) == 8\n assert candidate(matrix = [[0, 0, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]]) == 4\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 5\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1], [1, 0, 1, 1, 1, 0], [1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 0, 0, 1], [0, 1, 1, 1, 1], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 30\n assert candidate(matrix = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 1\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]]) == 6\n assert candidate(matrix = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 3\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 4\n assert candidate(matrix = [[1, 0, 0, 1], [0, 1, 1, 0], [1, 1, 1, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 0, 1, 1], [1, 0, 1, 0, 1], [0, 1, 1, 1, 0]]) == 6\n assert candidate(matrix = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1]]) == 6\n assert candidate(matrix = [[0, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 0, 1], [0, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[0, 0, 0, 1, 1, 1], [0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 0, 1], [1, 1, 1, 1, 0, 0]]) == 4\n assert candidate(matrix = [[1, 1, 1], [1, 0, 1], [1, 1, 1], [1, 0, 1], [1, 1, 1], [1, 0, 1]]) == 12\n assert candidate(matrix = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 1, 0, 1, 0, 1], [0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 1], [0, 1, 1, 1, 0, 1], [1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1], [1, 1, 0, 1, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 0, 1]]) == 6\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 3\n assert candidate(matrix = [[1, 0, 1, 1, 1], [1, 1, 1, 0, 1], [0, 1, 1, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 8\n assert candidate(matrix = [[1, 0, 1, 1], [0, 1, 0, 1], [1, 1, 0, 0], [1, 1, 1, 1]]) == 4\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 20\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 0, 0, 1, 1], [1, 1, 1, 1, 0], [0, 1, 1, 1, 1], [1, 1, 0, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 1, 0, 0, 0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[0, 1, 1, 1, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [1, 0, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 0, 1]]) == 9\n assert candidate(matrix = [[0, 0, 0, 1, 1], [1, 1, 1, 1, 1], [0, 1, 0, 1, 1], [1, 0, 1, 0, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 1, 1, 1], [1, 0, 1, 0], [0, 1, 1, 1], [1, 1, 0, 1]]) == 4\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0]]) == 7\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 1, 1], [1, 0, 1, 0]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 1, 0, 0, 1], [1, 1, 1, 0, 1], [1, 0, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1], [1, 1, 0, 1, 1, 1], [1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 0, 1]]) == 12\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 5\n assert candidate(matrix = [[0, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1, 0, 1]]) == 5\n"}, "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().largestSubmatrix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def largestSubmatrix(self, matrix: list[list[int]]) -> int:", "container": "Solution", "callable": "largestSubmatrix", "parameters": [{"name": "matrix", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1728, "task_id": "cat-and-mouse-ii", "difficulty": "Hard", "problem_description": "A game is played by a cat and a mouse named Cat and Mouse.\nThe environment is represented by a grid of size rows x cols, where each element is a wall, floor, player (Cat, Mouse), or food.\n\nPlayers are represented by the characters 'C'(Cat),'M'(Mouse).\nFloors are represented by the character '.' and can be walked on.\nWalls are represented by the character '#' and cannot be walked on.\nFood is represented by the character 'F' and can be walked on.\nThere is only one of each character 'C', 'M', and 'F' in grid.\n\nMouse and Cat play according to the following rules:\n\nMouse moves first, then they take turns to move.\nDuring each turn, Cat and Mouse can jump in one of the four directions (left, right, up, down). They cannot jump over the wall nor outside of the grid.\ncatJump, mouseJump are the maximum lengths Cat and Mouse can jump at a time, respectively. Cat and Mouse can jump less than the maximum length.\nStaying in the same position is allowed.\nMouse can jump over Cat.\n\nThe game can end in 4 ways:\n\nIf Cat occupies the same position as Mouse, Cat wins.\nIf Cat reaches the food first, Cat wins.\nIf Mouse reaches the food first, Mouse wins.\nIf Mouse cannot get to the food within 1000 turns, Cat wins.\n\nGiven a rows x cols matrix grid and two integers catJump and mouseJump, return true if Mouse can win the game if both Cat and Mouse play optimally, otherwise return false.\n \nExample 1:\n\n\nInput: grid = [\"####F\",\"#C...\",\"M....\"], catJump = 1, mouseJump = 2\nOutput: true\nExplanation: Cat cannot catch Mouse on its turn nor can it get the food before Mouse.\n\nExample 2:\n\n\nInput: grid = [\"M.C...F\"], catJump = 1, mouseJump = 4\nOutput: true\n\nExample 3:\n\nInput: grid = [\"M.C...F\"], catJump = 1, mouseJump = 3\nOutput: false\n\n \nConstraints:\n\nrows == grid.length\ncols = grid[i].length\n1 <= rows, cols <= 8\ngrid[i][j] consist only of characters 'C', 'M', 'F', '.', and '#'.\nThere is only one of each character 'C', 'M', and 'F' in grid.\n1 <= catJump, mouseJump <= 8\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = ['...M.', '.F#C.', '.....'],catJump = 2,mouseJump = 2) == True\n assert candidate(grid = ['M....', '.....', 'C.F..'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['C.......', '........', '........', '........', '........', '........', '........', '.......M'],catJump = 5,mouseJump = 5) == False\n assert candidate(grid = ['M......', '#F.C.#.'],catJump = 2,mouseJump = 3) == False\n assert candidate(grid = ['M....', '.F.C.', '.....'],catJump = 1,mouseJump = 1) == True\n assert candidate(grid = ['M....', '.#C..', '..#F.', '.....'],catJump = 3,mouseJump = 1) == False\n assert candidate(grid = ['M....', '.....', '.F.C.'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M.C...F'],catJump = 1,mouseJump = 4) == True\n assert candidate(grid = ['####F', '#C...', 'M....'],catJump = 1,mouseJump = 2) == True\n assert candidate(grid = ['M......', '.......', '..F....', '....C..'],catJump = 3,mouseJump = 4) == True\n assert candidate(grid = ['MC..F', '.....', '.....'],catJump = 2,mouseJump = 2) == False\n assert candidate(grid = ['M.C...F'],catJump = 1,mouseJump = 3) == False\n assert candidate(grid = ['M...F', '#..C.', '......'],catJump = 2,mouseJump = 1) == False\n assert candidate(grid = ['MC..F', '#####'],catJump = 2,mouseJump = 2) == False\n assert candidate(grid = ['.......', '.#....#', '.#....#', '.#.....', '.#....#', '.#....#', 'C......'],catJump = 5,mouseJump = 3) == True\n assert candidate(grid = ['M...', '....', '#...', 'C.F.'],catJump = 1,mouseJump = 3) == True\n assert candidate(grid = ['M....', '.....', '#C.F.', '.....', '.....'],catJump = 3,mouseJump = 2) == False\n assert candidate(grid = ['M...#', '...C.', '.....', '.....', '..F..'],catJump = 2,mouseJump = 2) == True\n assert candidate(grid = ['M....', '.....', '.....', '..C..', '...F.'],catJump = 1,mouseJump = 4) == True\n assert candidate(grid = ['M.....', '......', '......', '......', '......', '......', '...F..', '....C.'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M...F', '.#C.#', '...#.', '.....', '....#'],catJump = 2,mouseJump = 3) == True\n assert candidate(grid = ['M......', '.......', '.......', '....#..', '....C..', '.......', '....F..'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M....', '.....', '.....', '...C.', '..#F.'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M......', '.......', '.......', '......#', '....C..', '.......', '....F..'],catJump = 2,mouseJump = 4) == False\n assert candidate(grid = ['M......', '.......', '.....#C', '......#', '.......', '#F.....', '.......'],catJump = 3,mouseJump = 3) == True\n assert candidate(grid = ['.......', '.M.....', '.#C..#.', '.#F..#.', '.#.....', '.#.....', '.......'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M.......', '........', '........', '........', '........', '.....C..', '........', '........', '.......F'],catJump = 4,mouseJump = 4) == False\n assert candidate(grid = ['M...F', '..#C.', '.....', '.....', '.....'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M........', '........#', '.........', '#........', '........C', '.........', '.......F.'],catJump = 7,mouseJump = 2) == False\n assert candidate(grid = ['.......', '.#....#', '.#....#', '.#C.M#.', '.#....#', '.#....#', '.......'],catJump = 3,mouseJump = 3) == False\n assert candidate(grid = ['M......', '.#....#', '..#F...', '#......', '......C'],catJump = 4,mouseJump = 1) == False\n assert candidate(grid = ['######', '#M...#', '#.#F#.', '#.....', '######'],catJump = 2,mouseJump = 3) == False\n assert candidate(grid = ['M.......', '........', '.####...', '.....#..', '......#F', '........', '........', '.....C..'],catJump = 2,mouseJump = 1) == False\n assert candidate(grid = ['M......', '.......', '.......', '......#', '....C..', '.......', '....F..'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M........', '.........', '.........', '.........', '.........', '.........', '......C..', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'F........'],catJump = 7,mouseJump = 7) == True\n assert candidate(grid = ['M....', '.....', '...C.', '#####', '....F'],catJump = 2,mouseJump = 1) == False\n assert candidate(grid = ['M....', '.....', '.....', '.....', '#....', 'C....', '..F..'],catJump = 4,mouseJump = 3) == False\n assert candidate(grid = ['M....', '.....', '....C', '....F', '.....'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M........', '.........', '.........', '.........', '.........', '.........', '........C', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'F........'],catJump = 5,mouseJump = 5) == True\n assert candidate(grid = ['M.....', '......', '......', '......', '......', '......', '...F..', '..C...'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M....#.', '.#....#', '.#....#', '.#.....', '.#....#', '.#....#', '.F....C'],catJump = 3,mouseJump = 4) == False\n assert candidate(grid = ['M....', '.#C..', '..#F.', '.....'],catJump = 3,mouseJump = 2) == False\n assert candidate(grid = ['.......', '.......', '.......', '...C...', '...M...', '.......', '...F...'],catJump = 5,mouseJump = 5) == True\n assert candidate(grid = ['M..#....', '......#.', '......#C', '......#.', '......#.', '......F.', '........'],catJump = 3,mouseJump = 3) == False\n assert candidate(grid = ['M....', '.####', '..F..', '....C'],catJump = 2,mouseJump = 1) == False\n assert candidate(grid = ['M....F...', '.#..#....', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M.F....', '......C', '......#', '........', '........'],catJump = 3,mouseJump = 2) == True\n assert candidate(grid = ['M....', '.####', '..F..', '....C'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'F........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'C........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........'],catJump = 8,mouseJump = 8) == False\n assert candidate(grid = ['M....', '.....', '.F.C.', '.....', '.....'],catJump = 3,mouseJump = 3) == False\n assert candidate(grid = ['M....', '#....', '..C..', '....F', '.....'],catJump = 2,mouseJump = 2) == False\n assert candidate(grid = ['.......', '.#....#', '.#....#', '.#.....', '.#....#', '.#....#', 'F......'],catJump = 3,mouseJump = 3) == False\n assert candidate(grid = ['M......', '.......', '.......', '....C..', '.......', '.......', '......F'],catJump = 2,mouseJump = 3) == False\n assert candidate(grid = ['.........', '.........', '.........', '.........', '........C', '........M', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'F........'],catJump = 6,mouseJump = 6) == True\n assert candidate(grid = ['M.......', '........', '........', '...F....', '........', '........', '........', '.......C'],catJump = 6,mouseJump = 2) == False\n assert candidate(grid = ['M....', '#..C.', '...#F', '....#', '.....'],catJump = 2,mouseJump = 2) == False\n assert candidate(grid = ['M....', '.....', '#....', '..C..', '...F.'],catJump = 3,mouseJump = 1) == False\n"}, "metadata": {"canonical_parameter_names": ["grid", "catJump", "mouseJump"], "leetcode_dataset_entry_point": "Solution().canMouseWin", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canMouseWin(self, grid: list[str], catJump: int, mouseJump: int) -> bool:", "container": "Solution", "callable": "canMouseWin", "parameters": [{"name": "grid", "type": "list[str]"}, {"name": "catJump", "type": "int"}, {"name": "mouseJump", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1732, "task_id": "find-the-highest-altitude", "difficulty": "Easy", "problem_description": "There is a biker going on a road trip. The road trip consists of n + 1 points at different altitudes. The biker starts his trip on point 0 with altitude equal 0.\nYou are given an integer array gain of length n where gain[i] is the net gain in altitude between points i​​​​​​ and i + 1 for all (0 <= i < n). Return the highest altitude of a point.\n \nExample 1:\n\nInput: gain = [-5,1,5,0,-7]\nOutput: 1\nExplanation: The altitudes are [0,-5,-4,1,1,-6]. The highest is 1.\n\nExample 2:\n\nInput: gain = [-4,-3,-2,-1,4,3,2]\nOutput: 0\nExplanation: The altitudes are [0,-4,-7,-9,-10,-6,-3,-1]. The highest is 0.\n\n \nConstraints:\n\nn == gain.length\n1 <= n <= 100\n-100 <= gain[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(gain = [4, 3, 2, 1, 0, -1, -2, -3, -4]) == 10\n assert candidate(gain = [-1, -2, -3, -4]) == 0\n assert candidate(gain = [-10, -20, -30, -40, -50]) == 0\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 100]) == 145\n assert candidate(gain = [-1, 1, -1, 1, -1, 1]) == 0\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [-5, -4, -3, -2, -1]) == 0\n assert candidate(gain = [5, 5, 5, 5]) == 20\n assert candidate(gain = [-100, 50, -50, 100, -100]) == 0\n assert candidate(gain = [-100, 100, -100, 100, -100]) == 0\n assert candidate(gain = [100, -100, 100, -100, 100]) == 100\n assert candidate(gain = [1, 2, 3, 4, 5]) == 15\n assert candidate(gain = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -100]) == 0\n assert candidate(gain = [-1, -2, -3, -4, -5]) == 0\n assert candidate(gain = [1, -1, 1, -1, 1, -1]) == 1\n assert candidate(gain = [-50, 50, -25, 25, -12, 12]) == 0\n assert candidate(gain = [10, 20, 30, 40, 50]) == 150\n assert candidate(gain = [0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [100, -50, 50, -100, 50]) == 100\n assert candidate(gain = [100, -100, 50, -50, 25, -25]) == 100\n assert candidate(gain = [100, -100, 100, -100]) == 100\n assert candidate(gain = [-5, 1, 5, 0, -7]) == 1\n assert candidate(gain = [0, 0, 0, 0]) == 0\n assert candidate(gain = [50, 50, 50, 50, 50]) == 250\n assert candidate(gain = [-4, -3, -2, -1, 4, 3, 2]) == 0\n assert candidate(gain = [23, -15, 42, -5, 0, 17, -30, 29]) == 62\n assert candidate(gain = [-10, -20, 30, 40, -50, 60, -70, 80, -90, 100]) == 70\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [10, -5, 15, -20, 25, -30, 35, -40]) == 30\n assert candidate(gain = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(gain = [100, -100, 100, -100, 100, -100, 100, -100]) == 100\n assert candidate(gain = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5]) == 50\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 10\n assert candidate(gain = [100, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -98]) == 100\n assert candidate(gain = [10, -5, 3, 2, -3, 4, -2, 5, -6, 1]) == 14\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [100, -1, 99, -2, 98, -3, 97, -4, 96, -5, 95, -6, 94, -7, 93, -8, 92, -9, 91, -10]) == 910\n assert candidate(gain = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 15\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 55\n assert candidate(gain = [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1]) == 0\n assert candidate(gain = [10, -5, 3, 2, -3, 4, -1, -2, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16]) == 18\n assert candidate(gain = [5, -3, 20, -20, 30, -10, 15, -5, 25, -15, 10, -5, 30, -30, 40]) == 87\n assert candidate(gain = [10, 15, 20, 25, 30, 35, 40, 45, 50, -100]) == 270\n assert candidate(gain = [50, -20, 30, -10, 40, -5, 60, -25, 70, -10]) == 190\n assert candidate(gain = [0, 25, -25, 50, -50, 100, -100]) == 100\n assert candidate(gain = [20, 30, -10, -40, 50, 10, -20, 30, -40, 50]) == 80\n assert candidate(gain = [5, 10, 15, 20, 25, -5, -10, -15, -20, -25, 5, 10, 15, 20, 25, -5, -10, -15, -20, -25]) == 75\n assert candidate(gain = [99, -50, 50, -100, 100, -99, 99, -49, 49, -51, 51, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == 99\n assert candidate(gain = [100, -25, 25, -50, 50, -75, 75, -100, 100]) == 100\n assert candidate(gain = [10, -5, 3, -2, 8, -4, 6, -3, 5, -1, 7, -2, 9, -4, 11, -5, 13, -6, 15, -7]) == 55\n assert candidate(gain = [5, 5, 5, 5, 5, -5, -5, -5, -5, -5, 10, 10, -10, -10, 15]) == 25\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11]) == 210\n assert candidate(gain = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(gain = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 5\n assert candidate(gain = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100]) == 100\n assert candidate(gain = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5]) == 0\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 10\n assert candidate(gain = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 15\n assert candidate(gain = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, 50, -50, 40, -40, 30, -30, 20, -20, 10, -10]) == 150\n assert candidate(gain = [-5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5]) == 0\n assert candidate(gain = [0, 20, -10, 5, -3, 15, -10]) == 27\n assert candidate(gain = [10, -5, 3, 8, -2, 15, -7, 20]) == 42\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(gain = [-10, -20, -30, -40, -50, 10, 20, 30, 40, 50, -1, -2, -3, -4, -5, 1, 2, 3, 4, 5]) == 0\n assert candidate(gain = [-5, -10, -15, 20, 25, -30, 35, -40, 45, -50, 55, -60, 65, -70, 75, -80, 85, -90, 95]) == 50\n assert candidate(gain = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 50\n assert candidate(gain = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120, -130, 140, -150]) == 70\n assert candidate(gain = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 50\n assert candidate(gain = [99, -99, 98, -98, 97, -97, 96, -96, 95, -95]) == 99\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30]) == 15\n assert candidate(gain = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(gain = [5, 10, 15, 20, 25, 30, -5, -10, -15, -20, -25, -30]) == 105\n assert candidate(gain = [100, -50, 50, -100, 100, -100, 50, -50, 25, -25, 75, -75, 125, -125, 62, -62, 31, -31, 15, -15]) == 125\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 5\n assert candidate(gain = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120, 130, -140, 150, -160, 170, -180, 190, -200]) == 100\n assert candidate(gain = [100, -50, 25, -12, 50, -25, 60, -30, 70, -35, 80, -40, 90, -45, 100]) == 338\n assert candidate(gain = [-10, 10, -10, 10, -10, 10, -10, 10, -10, 10]) == 0\n assert candidate(gain = [20, -10, 30, -15, 40, -20, 50, -25, 60, -30, 70, -35, 80, -40, 90]) == 265\n assert candidate(gain = [10, -10, 20, -20, 30, -30, 40, -40, 50]) == 50\n assert candidate(gain = [2, 3, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25]) == 17\n assert candidate(gain = [-50, 25, -25, 50, -50, 75, -100, 125]) == 50\n assert candidate(gain = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -15, -20, -25, -30, -35, -40, -45, -50]) == 275\n assert candidate(gain = [-10, -20, -30, -40, -50, 50, 40, 30, 20, 10]) == 0\n assert candidate(gain = [1, 1, 1, 1, 1, 1, 1, 1, 1, -10]) == 9\n assert candidate(gain = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(gain = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 10\n assert candidate(gain = [-50, 0, 50, 0, -50, 0, 50, 0, -50, 0, 50, 0, -50, 0, 50]) == 0\n assert candidate(gain = [0, 20, -10, 30, -20, 10, -30, 40, -50, 60]) == 50\n assert candidate(gain = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 50\n assert candidate(gain = [100, -50, 50, -50, 100, -50, 50, -50, 100]) == 200\n assert candidate(gain = [100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99]) == 114\n assert candidate(gain = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9]) == 9\n assert candidate(gain = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 10\n assert candidate(gain = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25, -26, 27, -28, 29, -30]) == 15\n assert candidate(gain = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25]) == 25\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 210\n assert candidate(gain = [10, -20, 30, -40, 50, -60, 70]) == 40\n assert candidate(gain = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 50\n assert candidate(gain = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 15\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 55\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30, -30]) == 15\n assert candidate(gain = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 10\n assert candidate(gain = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(gain = [100, -99, 98, -97, 96, -95, 94, -93, 92, -91, 90, -89, 88, -87, 86, -85, 84, -83, 82, -81, 80]) == 100\n assert candidate(gain = [2, 4, -3, 1, -2, 1, 5, -4, 3, -1, 0, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 12\n assert candidate(gain = [100, -50, 50, -100, 50, -50, 100, -100, 50, -50]) == 100\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 100\n assert candidate(gain = [-50, 50, -50, 50, -50, 50, -50, 50]) == 0\n assert candidate(gain = [-1, 3, -2, 4, -3, 5, -4, 6, -5, 7]) == 10\n"}, "metadata": {"canonical_parameter_names": ["gain"], "leetcode_dataset_entry_point": "Solution().largestAltitude", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def largestAltitude(self, gain: list[int]) -> int:", "container": "Solution", "callable": "largestAltitude", "parameters": [{"name": "gain", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1733, "task_id": "minimum-number-of-people-to-teach", "difficulty": "Medium", "problem_description": "On a social network consisting of m users and some friendships between users, two users can communicate with each other if they know a common language.\nYou are given an integer n, an array languages, and an array friendships where:\n\nThere are n languages numbered 1 through n,\nlanguages[i] is the set of languages the i​​​​​​th​​​​ user knows, and\nfriendships[i] = [u​​​​​​i​​​, v​​​​​​i] denotes a friendship between the users u​​​​​​​​​​​i​​​​​ and vi.\n\nYou can choose one language and teach it to some users so that all friends can communicate with each other. Return the minimum number of users you need to teach.\nNote that friendships are not transitive, meaning if x is a friend of y and y is a friend of z, this doesn't guarantee that x is a friend of z.\n \nExample 1:\n\nInput: n = 2, languages = [[1],[2],[1,2]], friendships = [[1,2],[1,3],[2,3]]\nOutput: 1\nExplanation: You can either teach user 1 the second language or user 2 the first language.\n\nExample 2:\n\nInput: n = 3, languages = [[2],[1,3],[1,2],[3]], friendships = [[1,4],[1,2],[3,4],[2,3]]\nOutput: 2\nExplanation: Teach the third language to users 1 and 3, yielding two users to teach.\n\n \nConstraints:\n\n2 <= n <= 500\nlanguages.length == m\n1 <= m <= 500\n1 <= languages[i].length <= n\n1 <= languages[i][j] <= n\n1 <= u​​​​​​i < v​​​​​​i <= languages.length\n1 <= friendships.length <= 500\nAll tuples (u​​​​​i, v​​​​​​i) are unique\nlanguages[i] contains only unique values\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,languages = [[1], [2], [3], [4]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 3\n assert candidate(n = 3,languages = [[1, 2], [2, 3], [3, 1]],friendships = [[1, 2], [2, 3], [3, 1]]) == 0\n assert candidate(n = 5,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(n = 2,languages = [[1], [2], [1, 2]],friendships = [[1, 2], [1, 3], [2, 3]]) == 1\n assert candidate(n = 4,languages = [[1, 3], [2, 4], [1, 2], [3, 4]],friendships = [[1, 2], [2, 3], [3, 4]]) == 2\n assert candidate(n = 4,languages = [[1], [2], [3], [4]],friendships = [[1, 2], [2, 3], [3, 4], [1, 4]]) == 3\n assert candidate(n = 5,languages = [[1], [2], [3], [4], [5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 4\n assert candidate(n = 3,languages = [[2], [1, 3], [1, 2], [3]],friendships = [[1, 4], [1, 2], [3, 4], [2, 3]]) == 2\n assert candidate(n = 2,languages = [[1, 2], [1, 2]],friendships = [[1, 2]]) == 0\n assert candidate(n = 3,languages = [[1, 2, 3], [2, 3], [1, 3]],friendships = [[1, 2], [2, 3], [1, 3]]) == 0\n assert candidate(n = 5,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 0\n assert candidate(n = 4,languages = [[1, 2], [3, 4], [1, 3], [2, 4]],friendships = [[1, 2], [1, 3], [2, 3], [3, 4]]) == 2\n assert candidate(n = 5,languages = [[1], [2], [3], [4], [5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 4\n assert candidate(n = 4,languages = [[1], [2], [3], [4]],friendships = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]) == 3\n assert candidate(n = 10,languages = [[1, 2, 3], [4, 5], [6, 7], [8, 9], [10]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5]]) == 4\n assert candidate(n = 6,languages = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]],friendships = [[1, 2], [3, 4], [5, 6]]) == 4\n assert candidate(n = 4,languages = [[1, 2], [2, 3], [3, 4], [4, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1], [1, 3], [2, 4], [1, 4], [2, 3], [1, 2], [3, 4]]) == 2\n assert candidate(n = 10,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 1], [10, 1, 2]],friendships = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 3\n assert candidate(n = 12,languages = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 1]]) == 11\n assert candidate(n = 6,languages = [[1], [2], [3], [4], [5], [6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]]) == 5\n assert candidate(n = 3,languages = [[1, 3], [2], [1, 2], [3, 2]],friendships = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4]]) == 1\n assert candidate(n = 9,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 1], [9, 2]]) == 7\n assert candidate(n = 5,languages = [[1, 2, 3], [4, 5], [1, 4], [2, 5], [3]],friendships = [[1, 4], [2, 5], [3, 5], [1, 3], [2, 4]]) == 1\n assert candidate(n = 3,languages = [[1], [2], [3], [1, 2], [2, 3], [1, 3]],friendships = [[1, 2], [2, 3], [1, 3], [4, 5], [5, 6], [4, 6]]) == 2\n assert candidate(n = 10,languages = [[1, 2, 3], [4, 5], [6, 7, 8], [9, 10], [1, 5, 9], [2, 6, 10], [3, 7, 4], [8, 1]],friendships = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 5], [2, 6], [3, 7], [4, 8], [5, 7], [6, 8]]) == 5\n assert candidate(n = 8,languages = [[1], [2], [3], [4], [5], [6], [7], [8]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 1], [8, 2]]) == 7\n assert candidate(n = 8,languages = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 3], [2, 4], [5, 7], [6, 8]],friendships = [[1, 3], [2, 4], [5, 7], [6, 8], [1, 5], [2, 6], [3, 7], [4, 8]]) == 6\n assert candidate(n = 8,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 1], [8, 2]]) == 6\n assert candidate(n = 4,languages = [[1, 2], [3, 4], [2, 3], [1, 4]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 2\n assert candidate(n = 9,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]) == 0\n assert candidate(n = 5,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 0\n assert candidate(n = 7,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 1], [7, 1, 2]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 1], [7, 2]]) == 0\n assert candidate(n = 10,languages = [[1, 3, 5], [2, 4, 6], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [1, 4], [2, 5], [3, 6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 7\n assert candidate(n = 10,languages = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 9\n assert candidate(n = 5,languages = [[1], [2], [3], [4], [5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5], [4, 1], [5, 2]]) == 4\n assert candidate(n = 3,languages = [[1], [1, 3], [2], [2, 3], [3]],friendships = [[1, 3], [2, 3], [4, 5]]) == 1\n assert candidate(n = 10,languages = [[1, 3, 5], [2, 4, 6], [1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 1], [2, 3, 4]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 6\n assert candidate(n = 10,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 0\n assert candidate(n = 15,languages = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9], [6, 7, 8, 9, 10], [7, 8, 9, 10, 11], [8, 9, 10, 11, 12], [9, 10, 11, 12, 13], [10, 11, 12, 13, 14], [11, 12, 13, 14, 15], [1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 1], [15, 2]]) == 2\n assert candidate(n = 5,languages = [[1], [2], [3], [4], [5], [1, 2], [3, 4], [4, 5], [1, 3], [2, 5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 7\n assert candidate(n = 7,languages = [[1, 2], [3, 4], [5, 6], [7], [1, 3], [2, 4], [5, 7]],friendships = [[1, 3], [1, 5], [1, 7], [2, 4], [2, 6], [3, 5], [3, 7], [4, 6], [4, 7], [5, 6]]) == 5\n assert candidate(n = 5,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5], [4, 1], [5, 2]]) == 3\n assert candidate(n = 10,languages = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],friendships = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 9\n assert candidate(n = 7,languages = [[1, 2, 3, 4], [5, 6], [7], [1, 2], [3, 4], [5, 6], [7]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]]) == 5\n assert candidate(n = 4,languages = [[1, 2], [2, 3], [3, 4], [4, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 0\n assert candidate(n = 7,languages = [[1], [2], [3], [4], [5], [6], [7]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 1], [7, 2]]) == 6\n assert candidate(n = 8,languages = [[1], [1], [1], [1], [2], [2], [2], [2]],friendships = [[1, 5], [2, 6], [3, 7], [4, 8]]) == 4\n assert candidate(n = 7,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]],friendships = [[1, 3], [3, 5], [5, 7], [7, 2], [2, 4], [4, 6]]) == 5\n assert candidate(n = 7,languages = [[1], [2], [3], [1, 4], [5, 6], [6, 7], [7]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]]) == 4\n assert candidate(n = 5,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 1], [5, 1, 2]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 0\n assert candidate(n = 7,languages = [[1, 3, 5], [2, 4, 6], [1, 2, 3], [4, 5, 6], [1, 4, 7], [2, 5, 7], [3, 6, 7]],friendships = [[1, 2], [3, 4], [5, 6], [7, 1], [2, 5], [4, 7], [6, 3]]) == 2\n assert candidate(n = 6,languages = [[1], [2], [3], [4], [5], [6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == 5\n assert candidate(n = 4,languages = [[1, 2], [2, 3], [3, 4], [1, 4]],friendships = [[1, 2], [2, 3], [3, 4], [1, 4]]) == 0\n assert candidate(n = 6,languages = [[1], [2], [3], [4], [5], [6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == 5\n assert candidate(n = 6,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == 0\n assert candidate(n = 3,languages = [[1, 2], [2, 3], [1, 3]],friendships = [[1, 2], [2, 3], [1, 3], [1, 2], [2, 3], [1, 3]]) == 0\n assert candidate(n = 3,languages = [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 0\n assert candidate(n = 4,languages = [[1, 2], [3, 4], [2, 3], [1, 4], [1, 3]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 5]]) == 2\n assert candidate(n = 4,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 1], [4, 1, 2]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 0\n assert candidate(n = 5,languages = [[1, 2, 3, 4, 5]],friendships = [[1, 1], [1, 1], [1, 1]]) == 0\n assert candidate(n = 4,languages = [[1, 2], [2, 3], [3, 4], [1, 4]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1], [1, 3], [2, 4]]) == 2\n assert candidate(n = 10,languages = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],friendships = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 9\n assert candidate(n = 8,languages = [[1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [1, 8]]) == 1\n assert candidate(n = 6,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6], [1, 3], [2, 4], [3, 5], [4, 6], [1, 5], [2, 6]]) == 4\n assert candidate(n = 5,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [1, 2], [4, 5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 5]]) == 2\n assert candidate(n = 5,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 1], [5, 1, 2]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 0\n assert candidate(n = 10,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 0\n assert candidate(n = 6,languages = [[1, 2, 3], [4, 5, 6], [1, 4], [2, 5], [3, 6], [1, 2, 3, 4, 5, 6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 3], [2, 4], [3, 5], [4, 6], [1, 5], [2, 6]]) == 3\n assert candidate(n = 6,languages = [[1], [2], [3], [4], [5], [6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]]) == 5\n assert candidate(n = 12,languages = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [1, 4, 7, 10], [2, 5, 8, 11], [3, 6, 9, 12], [1, 5, 9, 12], [2, 6, 10, 11], [3, 4, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]],friendships = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 10], [8, 11], [8, 12], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12]]) == 7\n assert candidate(n = 7,languages = [[1], [2], [3], [4], [5], [6], [7]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 1], [7, 2]]) == 6\n assert candidate(n = 8,languages = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 3], [2, 4], [5, 7], [6, 8]],friendships = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 3], [2, 4], [5, 7], [6, 8]]) == 6\n assert candidate(n = 5,languages = [[1, 2], [3, 4], [1, 3], [2, 5], [4, 5]],friendships = [[1, 2], [3, 4], [2, 3], [4, 5], [1, 3]]) == 2\n"}, "metadata": {"canonical_parameter_names": ["n", "languages", "friendships"], "leetcode_dataset_entry_point": "Solution().minimumTeachings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumTeachings(self, n: int, languages: list[list[int]], friendships: list[list[int]]) -> int:", "container": "Solution", "callable": "minimumTeachings", "parameters": [{"name": "n", "type": "int"}, {"name": "languages", "type": "list[list[int]]"}, {"name": "friendships", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1734, "task_id": "decode-xored-permutation", "difficulty": "Medium", "problem_description": "There is an integer array perm that is a permutation of the first n positive integers, where n is always odd.\nIt was encoded into another integer array encoded of length n - 1, such that encoded[i] = perm[i] XOR perm[i + 1]. For example, if perm = [1,3,2], then encoded = [2,1].\nGiven the encoded array, return the original array perm. It is guaranteed that the answer exists and is unique.\n \nExample 1:\n\nInput: encoded = [3,1]\nOutput: [1,2,3]\nExplanation: If perm = [1,2,3], then encoded = [1 XOR 2,2 XOR 3] = [3,1]\n\nExample 2:\n\nInput: encoded = [6,5,4,6]\nOutput: [2,4,1,5,3]\n\n \nConstraints:\n\n3 <= n < 105\nn is odd.\nencoded.length == n - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(encoded = [15, 8, 12, 4, 1]) == [11, 4, 12, 0, 4, 5]\n assert candidate(encoded = [1, 7, 6, 5, 4, 3]) == [1, 0, 7, 1, 4, 0, 3]\n assert candidate(encoded = [6, 5, 4, 6]) == [2, 4, 1, 5, 3]\n assert candidate(encoded = [8, 12, 4, 6, 1, 3, 5]) == [1, 9, 5, 1, 7, 6, 5, 0]\n assert candidate(encoded = [2, 3, 1, 4, 7]) == [0, 2, 1, 0, 4, 3]\n assert candidate(encoded = [8, 13, 10, 3, 7, 12, 9]) == [10, 2, 15, 5, 6, 1, 13, 4]\n assert candidate(encoded = [2, 3, 1, 6, 7, 0]) == [5, 7, 4, 5, 3, 4, 4]\n assert candidate(encoded = [1, 5, 7]) == [1, 0, 5, 2]\n assert candidate(encoded = [8, 9, 10, 11, 12, 13, 14]) == [7, 15, 6, 12, 7, 11, 6, 8]\n assert candidate(encoded = [7, 8, 9, 10, 11, 12]) == [14, 9, 1, 8, 2, 9, 5]\n assert candidate(encoded = [15, 10, 5, 2, 1, 4]) == [12, 3, 9, 12, 14, 15, 11]\n assert candidate(encoded = [2, 3, 2]) == [7, 5, 6, 4]\n assert candidate(encoded = [1, 0, 1, 0, 1]) == [7, 6, 6, 7, 7, 6]\n assert candidate(encoded = [7, 3, 5]) == [7, 0, 3, 6]\n assert candidate(encoded = [1, 6, 5, 4, 3, 2]) == [0, 1, 7, 2, 6, 5, 7]\n assert candidate(encoded = [2, 3, 1, 4, 5]) == [0, 2, 1, 0, 4, 1]\n assert candidate(encoded = [3, 1]) == [1, 2, 3]\n assert candidate(encoded = [123, 234, 345, 456, 567, 678, 789, 890, 901, 1002]) == [788, 879, 901, 732, 788, 291, 901, 144, 1002, 111, 901]\n assert candidate(encoded = [14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58]) == [9, 7, 21, 3, 25, 7, 37, 3, 41, 7, 53, 3, 57]\n assert candidate(encoded = [15, 10, 5, 3, 2, 1, 4]) == [0, 15, 5, 0, 3, 1, 0, 4]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35]) == [8, 13, 7, 8, 28, 5, 27, 56]\n assert candidate(encoded = [2, 15, 18, 17, 20, 23, 22, 25, 28]) == [27, 25, 22, 4, 21, 1, 22, 0, 25, 5]\n assert candidate(encoded = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [3, 2, 0, 3, 7, 2, 4, 3, 11, 2, 8, 3, 15, 2, 12, 3, 19, 2, 16, 3, 23, 2, 20, 3, 27, 2]\n assert candidate(encoded = [77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198]) == [95, 18, 74, 41, 71, 62, 186, 53, 175, 10, 186, 1, 199]\n assert candidate(encoded = [9, 20, 27, 34, 41, 48, 55]) == [14, 7, 19, 8, 42, 3, 51, 4]\n assert candidate(encoded = [7, 2, 5, 8, 3, 6, 1, 4, 9]) == [3, 4, 6, 3, 11, 8, 14, 15, 11, 2]\n assert candidate(encoded = [65, 131, 263, 527, 1055, 2111, 4223, 8447, 16895, 33791, 67583, 135167]) == [173645, 173580, 173711, 173960, 173447, 172440, 174503, 178648, 170279, 186584, 154407, 220376, 86823]\n assert candidate(encoded = [7, 18, 27, 34, 41, 48, 55]) == [8, 15, 29, 6, 36, 13, 61, 10]\n assert candidate(encoded = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323]) == [583287, 583284, 583293, 583270, 583223, 583364, 582685, 584854, 587063, 571860, 548733, 715910, 194423, 1746084]\n assert candidate(encoded = [2, 7, 13, 18, 24, 30, 36, 42, 48, 54, 60]) == [27, 25, 30, 19, 1, 25, 7, 35, 9, 57, 15, 51]\n assert candidate(encoded = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39]) == [39, 36, 35, 40, 39, 52, 35, 56, 39, 4, 35]\n assert candidate(encoded = [31, 34, 37, 40, 43, 46, 49]) == [44, 51, 17, 52, 28, 55, 25, 40]\n assert candidate(encoded = [255, 222, 199, 176, 153, 130, 107, 84]) == [185, 70, 152, 95, 239, 118, 244, 159, 203]\n assert candidate(encoded = [19, 22, 25, 28, 31, 34, 37]) == [32, 51, 37, 60, 32, 63, 29, 56]\n assert candidate(encoded = [15, 22, 13, 20, 9, 16, 11]) == [26, 21, 3, 14, 26, 19, 3, 8]\n assert candidate(encoded = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650]) == [93, 57, 175, 103, 157, 433, 239, 383, 189, 329, 879, 311, 957]\n assert candidate(encoded = [15, 22, 3, 26, 11, 28, 7, 30, 13, 32, 9, 34, 5, 36, 1]) == [56, 55, 33, 34, 56, 51, 47, 40, 54, 59, 27, 18, 48, 53, 17, 16]\n assert candidate(encoded = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [3267, 4924, 7363, 6972, 6339, 6460, 6595, 6588, 6531, 6556, 6547, 6548, 6551, 6550]\n assert candidate(encoded = [4, 12, 8, 16, 10, 18, 14]) == [6, 2, 14, 6, 22, 28, 14, 0]\n assert candidate(encoded = [42, 35, 26, 15, 4, 17, 38, 67, 114, 181, 278, 399]) == [325, 367, 332, 342, 345, 349, 332, 362, 297, 347, 494, 248, 375]\n assert candidate(encoded = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [968, 940, 868, 584, 984, 556, 116, 712, 488, 620, 388]\n assert candidate(encoded = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245]) == [250, 5, 251, 6, 250, 1, 251, 2, 250, 13, 251, 14]\n assert candidate(encoded = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304]) == [2796223, 2796219, 2796211, 2796195, 2796163, 2796227, 2796099, 2796355, 2795843, 2796867, 2794819, 2798915, 2790723, 2807107, 2774339, 2839875, 2708803, 2970947, 2446659, 3495235, 1398083, 5592387]\n assert candidate(encoded = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78]) == [14, 2, 12, 28, 14, 26, 12, 20, 14, 18, 12, 44, 14, 42, 12, 36, 14, 34, 12, 60, 14, 58, 12, 52, 14, 50, 12, 76, 14, 74, 12, 68, 14, 66, 12]\n assert candidate(encoded = [24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64]) == [16, 8, 20, 52, 16, 56, 20, 36, 16, 40, 20, 84]\n assert candidate(encoded = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == [11, 14, 9, 0, 11, 6, 9, 24, 11, 30, 9, 16]\n assert candidate(encoded = [5, 8, 11, 14, 17, 20, 23, 26, 29, 32]) == [40, 45, 37, 46, 32, 49, 37, 50, 40, 53, 21]\n assert candidate(encoded = [17, 19, 21, 23, 25, 27, 29, 31]) == [1, 16, 3, 22, 1, 24, 3, 30, 1]\n assert candidate(encoded = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [19, 22, 17, 24, 19, 30, 17, 0, 19, 6, 17, 8, 19, 14]\n assert candidate(encoded = [99, 198, 297, 396, 495, 594, 693, 792, 891, 990, 1089]) == [978, 945, 887, 606, 978, 573, 111, 730, 450, 697, 359, 1318]\n assert candidate(encoded = [2047, 4094, 2047, 4094, 2047, 4094, 2047, 4094, 2047, 4094, 2047]) == [4082, 2061, 2035, 12, 4082, 2061, 2035, 12, 4082, 2061, 2035, 12]\n assert candidate(encoded = [2, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432, 1572864]) == [2097151, 2097149, 2097147, 2097143, 2097135, 2097119, 2097087, 2097023, 2096895, 2096639, 2096127, 2095103, 2093055, 2088959, 2080767, 2064383, 2031615, 1966079, 1835007, 1572863, 1048575]\n assert candidate(encoded = [30, 10, 20, 15, 25, 12, 22, 17, 27, 14, 24, 19, 29, 16, 26]) == [5, 27, 17, 5, 10, 19, 31, 9, 24, 3, 13, 21, 6, 27, 11, 17]\n assert candidate(encoded = [255, 128, 64, 32, 16, 8, 4, 2, 1]) == [161, 94, 222, 158, 190, 174, 166, 162, 160, 161]\n assert candidate(encoded = [15, 22, 33, 46, 59, 74, 91, 110, 131, 154]) == [134, 137, 159, 190, 144, 171, 225, 186, 212, 87, 205]\n assert candidate(encoded = [14, 11, 12, 15, 16, 19, 20, 23, 24, 27]) == [27, 21, 30, 18, 29, 13, 30, 10, 29, 5, 30]\n assert candidate(encoded = [31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == [838849, 838878, 838881, 838814, 838753, 839070, 839265, 838046, 837217, 842142, 845409, 825758, 812641, 891294, 943713, 629150, 419425]\n assert candidate(encoded = [11, 24, 29, 36, 43, 50, 57]) == [6, 13, 21, 8, 44, 7, 53, 12]\n assert candidate(encoded = [13, 22, 31, 40, 49, 58, 67]) == [12, 1, 23, 8, 32, 17, 43, 104]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85]) == [35, 38, 44, 35, 55, 46, 48, 19, 59, 22, 36, 19, 47, 110, 40, 99, 51, 102]\n assert candidate(encoded = [14, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [5, 11, 29, 9, 27, 11, 5, 9, 3, 11, 13, 9, 11]\n assert candidate(encoded = [7, 14, 21, 28, 35, 42, 49]) == [48, 55, 57, 44, 48, 19, 57, 8]\n assert candidate(encoded = [127, 63, 31, 15, 7, 3, 1]) == [59, 68, 123, 100, 107, 108, 111, 110]\n assert candidate(encoded = [27, 24, 21, 18, 15, 12, 9, 6, 3]) == [11, 16, 8, 29, 15, 0, 12, 5, 3, 0]\n assert candidate(encoded = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [409, 614, 921, 870, 793, 806, 825, 822, 817, 818, 819]\n assert candidate(encoded = [31, 28, 33, 30, 35, 32, 37]) == [42, 53, 41, 8, 22, 53, 21, 48]\n assert candidate(encoded = [15, 23, 19, 21, 17, 13, 9, 5, 1]) == [1, 14, 25, 10, 31, 14, 3, 10, 15, 14]\n assert candidate(encoded = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 6, 14, 7, 13, 6, 10, 7, 9, 6, 22, 7, 21, 6, 18, 7, 17, 6, 30, 7, 29, 6, 26, 7, 25]\n assert candidate(encoded = [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77]) == [29, 24, 17, 28, 13, 24, 1, 28, 61, 24, 49, 28, 45, 24, 33, 28, 93, 24, 81, 28]\n assert candidate(encoded = [4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [1639, 2456, 3687, 3480, 3175, 3224, 3303, 3288, 3271, 3272, 3279, 3276, 3277]\n assert candidate(encoded = [25, 30, 35, 40, 45, 50, 55]) == [12, 21, 11, 40, 0, 45, 31, 40]\n assert candidate(encoded = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34]) == [33, 37, 35, 43, 33, 45, 35, 51, 33, 53, 35, 59, 33, 61, 35, 3, 33]\n assert candidate(encoded = [32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [13091, 19676, 29475, 27868, 25379, 25820, 26403, 26332, 26147, 26204, 26211, 26236, 26227, 26228, 26231, 26230]\n assert candidate(encoded = [3, 10, 17, 24, 31, 38, 45]) == [60, 63, 53, 36, 60, 35, 5, 40]\n assert candidate(encoded = [13, 23, 37, 55, 77, 103, 133, 167, 205, 247, 293, 343, 397]) == [335, 322, 341, 368, 327, 266, 365, 488, 335, 386, 373, 80, 263, 138]\n assert candidate(encoded = [14, 23, 32, 41, 50, 59, 68]) == [13, 3, 20, 52, 29, 47, 20, 80]\n assert candidate(encoded = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [3, 26, 2, 21, 3, 22, 2, 17, 3, 18, 2, 13, 3, 14, 2, 9, 3, 10, 2, 5, 3, 6, 2, 1, 3, 2]\n assert candidate(encoded = [10, 20, 15, 25, 30, 22, 28, 19, 29, 12]) == [4, 14, 26, 21, 12, 18, 4, 24, 11, 22, 26]\n assert candidate(encoded = [23, 45, 12, 34, 56, 78, 90, 112, 134]) == [58, 45, 0, 12, 46, 22, 88, 2, 114, 244]\n assert candidate(encoded = [15, 22, 30, 39, 45, 51, 57, 63, 69]) == [54, 57, 47, 49, 22, 59, 8, 49, 14, 75]\n assert candidate(encoded = [3, 9, 15, 21, 27, 33, 39]) == [53, 54, 63, 48, 37, 62, 31, 56]\n assert candidate(encoded = [13, 26, 52, 104, 208, 416, 832, 1664, 3328, 6656, 13312, 26624, 53248, 106496, 212992, 425984, 851968, 1703936, 3407872, 6815744, 13631488, 27262976, 54525952, 109051904, 218103808, 436207616, 872415232, 1744830464, 3489660928, 6979321856, 13958643712, 27917287424, 55834574848, 111669149696, 223338299392, 446676598784, 893353197568, 1786706395136, 3573412790272]) == [2015771317626, 2015771317623, 2015771317613, 2015771317593, 2015771317553, 2015771317729, 2015771317313, 2015771318017, 2015771316609, 2015771319425, 2015771313793, 2015771325057, 2015771302529, 2015771347585, 2015771257473, 2015771437697, 2015771077249, 2015771798145, 2015770356353, 2015773239937, 2015767472769, 2015779007105, 2015755938433, 2015802075777, 2015709801089, 2015894350465, 2015525251713, 2016263449217, 2014787054209, 2017739844225, 2011834264193, 2023645424257, 2000023104129, 2047267744385, 1952778463873, 2141757024897, 1763799902849, 1420202519169, 1007885658753, 4031542635137]\n assert candidate(encoded = [5, 12, 19, 26, 33, 40, 47]) == [54, 51, 63, 44, 54, 23, 63, 16]\n assert candidate(encoded = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [8, 10, 14, 8, 0, 10, 6, 8, 24, 10, 30, 8]\n assert candidate(encoded = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143]) == [197, 206, 216, 249, 213, 226, 160, 237, 181, 214, 184, 193, 69, 202]\n assert candidate(encoded = [63, 66, 69, 72, 75, 78, 81]) == [76, 115, 49, 116, 60, 119, 57, 104]\n assert candidate(encoded = [29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == [109, 112, 111, 74, 99, 72, 103, 82, 105, 84, 23, 80]\n assert candidate(encoded = [1023, 511, 255, 127, 63, 31, 15, 7]) == [409, 614, 921, 870, 793, 806, 825, 822, 817]\n assert candidate(encoded = [31, 30, 29, 28, 27, 26, 25, 24, 23]) == [11, 20, 10, 23, 11, 16, 10, 19, 11, 28]\n assert candidate(encoded = [13, 29, 61, 125, 253, 509, 1021, 2045, 4093, 8189, 16381, 32765, 65533, 131077, 262149]) == [157301, 157304, 157285, 157272, 157221, 157400, 157477, 156888, 156453, 158936, 160549, 150744, 144165, 183512, 52445, 314584]\n assert candidate(encoded = [9, 19, 31, 45, 61, 79, 99, 121, 145, 171, 199, 229, 261, 295, 331]) == [369, 376, 363, 372, 345, 356, 299, 328, 305, 416, 267, 460, 297, 44, 267, 64]\n assert candidate(encoded = [31, 14, 17, 9, 22, 15, 26, 11, 24]) == [8, 23, 25, 8, 1, 23, 24, 2, 9, 17]\n assert candidate(encoded = [4, 13, 12, 15, 10, 19, 18, 21, 14, 23, 22]) == [31, 27, 22, 26, 21, 31, 12, 30, 11, 5, 18, 4]\n assert candidate(encoded = [7, 13, 21, 31, 43, 57, 73, 91, 111, 133, 157, 183, 211, 241, 273]) == [163, 164, 169, 188, 163, 136, 177, 248, 163, 204, 73, 212, 99, 176, 65, 336]\n assert candidate(encoded = [15, 22, 17, 24, 19, 26, 21, 28, 23]) == [3, 12, 26, 11, 19, 0, 26, 15, 19, 4]\n assert candidate(encoded = [2, 3, 1, 6, 5, 4, 11, 10, 9, 16, 15, 14, 21, 20, 19]) == [17, 19, 16, 17, 23, 18, 22, 29, 23, 30, 14, 1, 15, 26, 14, 29]\n assert candidate(encoded = [15, 20, 17, 23, 18, 24, 19]) == [19, 28, 8, 25, 14, 28, 4, 23]\n assert candidate(encoded = [31, 29, 27, 25, 23, 21, 19, 17, 15]) == [11, 20, 9, 18, 11, 28, 9, 26, 11, 4]\n assert candidate(encoded = [65, 68, 71, 74, 77, 80, 83]) == [86, 23, 83, 20, 94, 19, 67, 16]\n assert candidate(encoded = [15, 20, 25, 30, 35, 40, 45, 50, 55]) == [27, 20, 0, 25, 7, 36, 12, 33, 19, 36]\n assert candidate(encoded = [100, 200, 50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == [639, 539, 723, 737, 631, 653, 979, 529, 55, 701, 83, 769, 183]\n assert candidate(encoded = [127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101]) == [122, 5, 123, 6, 122, 1, 123, 2, 122, 13, 123, 14, 122, 9, 123, 10, 122, 21, 123, 22, 122, 17, 123, 18, 122, 29, 123, 30]\n assert candidate(encoded = [16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [6553, 9830, 14745, 13926, 12697, 12902, 13209, 13158, 13081, 13094, 13113, 13110, 13105, 13106, 13107]\n assert candidate(encoded = [127, 130, 133, 136, 139, 142, 145]) == [140, 243, 113, 244, 124, 247, 121, 232]\n assert candidate(encoded = [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45]) == [5, 0, 9, 4, 21, 0, 25, 4, 37, 0, 41, 4]\n assert candidate(encoded = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120]) == [1, 2, 4, 13, 1, 14, 28, 9, 17, 10, 20, 53, 17, 54, 28, 49, 1, 50, 4, 61, 1, 62, 124, 57, 113, 58, 116, 37, 113, 38, 124, 33, 65, 34, 68, 45, 65, 46, 92, 41, 81]\n assert candidate(encoded = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047]) == [831, 830, 829, 826, 821, 810, 789, 874, 917, 618, 405, 1642]\n assert candidate(encoded = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == [1, 101, 6, 100, 5, 101, 58, 100, 57, 101, 62, 100, 61, 101, 50, 100, 49]\n assert candidate(encoded = [31, 14, 7, 3, 1, 0, 2, 6, 14, 30, 62, 126, 254]) == [100, 123, 117, 114, 113, 112, 112, 114, 116, 122, 100, 90, 36, 218]\n assert candidate(encoded = [15, 27, 18, 23, 31, 45, 56, 67, 78]) == [105, 102, 125, 111, 120, 103, 74, 114, 49, 127]\n"}, "metadata": {"canonical_parameter_names": ["encoded"], "leetcode_dataset_entry_point": "Solution().decode", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def decode(self, encoded: list[int]) -> list[int]:", "container": "Solution", "callable": "decode", "parameters": [{"name": "encoded", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1736, "task_id": "latest-time-by-replacing-hidden-digits", "difficulty": "Easy", "problem_description": "You are given a string time in the form of hh:mm, where some of the digits in the string are hidden (represented by ?).\nThe valid times are those inclusively between 00:00 and 23:59.\nReturn the latest valid time you can get from time by replacing the hidden digits.\n \nExample 1:\n\nInput: time = \"2?:?0\"\nOutput: \"23:50\"\nExplanation: The latest hour beginning with the digit '2' is 23 and the latest minute ending with the digit '0' is 50.\n\nExample 2:\n\nInput: time = \"0?:3?\"\nOutput: \"09:39\"\n\nExample 3:\n\nInput: time = \"1?:22\"\nOutput: \"19:22\"\n\n \nConstraints:\n\ntime is in the format hh:mm.\nIt is guaranteed that you can produce a valid time from the given string.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(time = \"?3:?0\") == \"23:50\"\n assert candidate(time = \"1?:22\") == \"19:22\"\n assert candidate(time = \"1?:??\") == \"19:59\"\n assert candidate(time = \"0?:59\") == \"09:59\"\n assert candidate(time = \"23:?9\") == \"23:59\"\n assert candidate(time = \"00:?0\") == \"00:50\"\n assert candidate(time = \"2?:5?\") == \"23:59\"\n assert candidate(time = \"2?:?0\") == \"23:50\"\n assert candidate(time = \"?:?:??\") == \"2:?:9?\"\n assert candidate(time = \"00:??\") == \"00:59\"\n assert candidate(time = \"1?:?5\") == \"19:55\"\n assert candidate(time = \"?9:5?\") == \"19:59\"\n assert candidate(time = \"??:??\") == \"23:59\"\n assert candidate(time = \"12:3?\") == \"12:39\"\n assert candidate(time = \"??:00\") == \"23:00\"\n assert candidate(time = \"0?:3?\") == \"09:39\"\n assert candidate(time = \"1?:?9\") == \"19:59\"\n assert candidate(time = \"00:?5\") == \"00:55\"\n assert candidate(time = \"?9:59\") == \"19:59\"\n assert candidate(time = \"2?:59\") == \"23:59\"\n assert candidate(time = \"12:?5\") == \"12:55\"\n assert candidate(time = \"1?:3?\") == \"19:39\"\n assert candidate(time = \"20:??\") == \"20:59\"\n assert candidate(time = \"?4:2?\") == \"14:29\"\n assert candidate(time = \"2?:3?\") == \"23:39\"\n assert candidate(time = \"??:45\") == \"23:45\"\n assert candidate(time = \"23:?0\") == \"23:50\"\n assert candidate(time = \"??:09\") == \"23:09\"\n assert candidate(time = \"0?:2?\") == \"09:29\"\n assert candidate(time = \"?4:?4\") == \"14:54\"\n assert candidate(time = \"23:?5\") == \"23:55\"\n assert candidate(time = \"23:?7\") == \"23:57\"\n assert candidate(time = \"20:?9\") == \"20:59\"\n assert candidate(time = \"?3:?2\") == \"23:52\"\n assert candidate(time = \"0?:?4\") == \"09:54\"\n assert candidate(time = \"?3:?8\") == \"23:58\"\n assert candidate(time = \"???:59\") == \"23?:59\"\n assert candidate(time = \"2??:5?\") == \"23?:5?\"\n assert candidate(time = \"2?:1?\") == \"23:19\"\n assert candidate(time = \"22:?8\") == \"22:58\"\n assert candidate(time = \"0?:?9\") == \"09:59\"\n assert candidate(time = \"2?:??\") == \"23:59\"\n assert candidate(time = \"0?:?2\") == \"09:52\"\n assert candidate(time = \"02:?7\") == \"02:57\"\n assert candidate(time = \"1?:?8\") == \"19:58\"\n assert candidate(time = \"09:?5\") == \"09:55\"\n assert candidate(time = \"???:??\") == \"23?:9?\"\n assert candidate(time = \"09:?3\") == \"09:53\"\n assert candidate(time = \"?2:?7\") == \"22:57\"\n assert candidate(time = \"1?:4?\") == \"19:49\"\n assert candidate(time = \"2?:0?\") == \"23:09\"\n assert candidate(time = \"??:59\") == \"23:59\"\n assert candidate(time = \"23:?4\") == \"23:54\"\n assert candidate(time = \"2??:3?\") == \"23?:3?\"\n assert candidate(time = \"0??:30\") == \"09?:30\"\n assert candidate(time = \"0?:?5\") == \"09:55\"\n assert candidate(time = \"0?:4?\") == \"09:49\"\n assert candidate(time = \"09:5?\") == \"09:59\"\n assert candidate(time = \"1?:?0\") == \"19:50\"\n assert candidate(time = \"00:?9\") == \"00:59\"\n assert candidate(time = \"2?:?5\") == \"23:55\"\n assert candidate(time = \"1?:5?\") == \"19:59\"\n assert candidate(time = \"19:?9\") == \"19:59\"\n assert candidate(time = \"1?:?4\") == \"19:54\"\n assert candidate(time = \"1?:0?\") == \"19:09\"\n assert candidate(time = \"2?:4?\") == \"23:49\"\n assert candidate(time = \"?0:?5\") == \"20:55\"\n assert candidate(time = \"??:?9\") == \"23:59\"\n assert candidate(time = \"???:00\") == \"23?:00\"\n assert candidate(time = \"?9:?8\") == \"19:58\"\n assert candidate(time = \"?3:?9\") == \"23:59\"\n assert candidate(time = \"0?:5?\") == \"09:59\"\n assert candidate(time = \"2?:?4\") == \"23:54\"\n assert candidate(time = \"?9:?9\") == \"19:59\"\n assert candidate(time = \"2?:00\") == \"23:00\"\n assert candidate(time = \"?2:3?\") == \"22:39\"\n assert candidate(time = \"0?:??\") == \"09:59\"\n assert candidate(time = \"?4:?8\") == \"14:58\"\n assert candidate(time = \"0?:?0\") == \"09:50\"\n assert candidate(time = \"20:?4\") == \"20:54\"\n assert candidate(time = \"1?:59\") == \"19:59\"\n assert candidate(time = \"0?:0?\") == \"09:09\"\n assert candidate(time = \"23:??\") == \"23:59\"\n assert candidate(time = \"?0:?0\") == \"20:50\"\n assert candidate(time = \"0?:1?\") == \"09:19\"\n assert candidate(time = \"1?:2?\") == \"19:29\"\n assert candidate(time = \"0?:?8\") == \"09:58\"\n assert candidate(time = \"19:?8\") == \"19:58\"\n assert candidate(time = \"?2:?5\") == \"22:55\"\n assert candidate(time = \"0?:45\") == \"09:45\"\n assert candidate(time = \"2?:?9\") == \"23:59\"\n assert candidate(time = \"?3:5?\") == \"23:59\"\n assert candidate(time = \"23:?8\") == \"23:58\"\n assert candidate(time = \"09:??\") == \"09:59\"\n assert candidate(time = \"2?:?8\") == \"23:58\"\n assert candidate(time = \"2?:2?\") == \"23:29\"\n"}, "metadata": {"canonical_parameter_names": ["time"], "leetcode_dataset_entry_point": "Solution().maximumTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumTime(self, time: str) -> str:", "container": "Solution", "callable": "maximumTime", "parameters": [{"name": "time", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1737, "task_id": "change-minimum-characters-to-satisfy-one-of-three-conditions", "difficulty": "Medium", "problem_description": "You are given two strings a and b that consist of lowercase letters. In one operation, you can change any character in a or b to any lowercase letter.\nYour goal is to satisfy one of the following three conditions:\n\nEvery letter in a is strictly less than every letter in b in the alphabet.\nEvery letter in b is strictly less than every letter in a in the alphabet.\nBoth a and b consist of only one distinct letter.\n\nReturn the minimum number of operations needed to achieve your goal.\n \nExample 1:\n\nInput: a = \"aba\", b = \"caa\"\nOutput: 2\nExplanation: Consider the best way to make each condition true:\n1) Change b to \"ccc\" in 2 operations, then every letter in a is less than every letter in b.\n2) Change a to \"bbb\" and b to \"aaa\" in 3 operations, then every letter in b is less than every letter in a.\n3) Change a to \"aaa\" and b to \"aaa\" in 2 operations, then a and b consist of one distinct letter.\nThe best way was done in 2 operations (either condition 1 or condition 3).\n\nExample 2:\n\nInput: a = \"dabadd\", b = \"cda\"\nOutput: 3\nExplanation: The best way is to make condition 1 true by changing b to \"eee\".\n\n \nConstraints:\n\n1 <= a.length, b.length <= 105\na and b consist only of lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = \"abc\",b = \"bcd\") == 2\n assert candidate(a = \"aba\",b = \"caa\") == 2\n assert candidate(a = \"xyzz\",b = \"zzzz\") == 2\n assert candidate(a = \"abcd\",b = \"dcba\") == 4\n assert candidate(a = \"aaaabbbb\",b = \"ccccdddd\") == 0\n assert candidate(a = \"xyz\",b = \"abc\") == 0\n assert candidate(a = \"abc\",b = \"def\") == 0\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(a = \"zzz\",b = \"aaa\") == 0\n assert candidate(a = \"abc\",b = \"abc\") == 3\n assert candidate(a = \"a\",b = \"z\") == 0\n assert candidate(a = \"aaa\",b = \"zzz\") == 0\n assert candidate(a = \"abacabadabacaba\",b = \"zzzyzxzyzxzyzxz\") == 0\n assert candidate(a = \"aabbcc\",b = \"bbccdd\") == 4\n assert candidate(a = \"xyz\",b = \"xyz\") == 3\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(a = \"xyz\",b = \"zyx\") == 3\n assert candidate(a = \"aaa\",b = \"bbb\") == 0\n assert candidate(a = \"dabadd\",b = \"cda\") == 3\n assert candidate(a = \"a\",b = \"b\") == 0\n assert candidate(a = \"aaaa\",b = \"bbbb\") == 0\n assert candidate(a = \"aaaaabbbbbccccc\",b = \"cccccbbaaaa\") == 11\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaa\") == 0\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zyxwvutsrqponmlkjihgfedcba\") == 27\n assert candidate(a = \"qwert\",b = \"asdfg\") == 2\n assert candidate(a = \"ababababababababababababababab\",b = \"bababababababababababababababa\") == 30\n assert candidate(a = \"algorithm\",b = \"datastructure\") == 7\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabc\",b = \"zzzzyyyxxxwwwwvvvvuuuuttttssssrrrrqqqqppppooooonnnnmmmmmlllllkkkkkjjjjjiiiii\") == 0\n assert candidate(a = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",b = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 0\n assert candidate(a = \"abcdabcdabcdabcdabcd\",b = \"dcbaabcdabcdabcdabcd\") == 20\n assert candidate(a = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\",b = \"abadabadabadabadabadabadabadabadabadabadabadabadabadabadabadabadabadabadabadab\") == 39\n assert candidate(a = \"aaabbbcccddd\",b = \"eefffgggg\") == 0\n assert candidate(a = \"aaaaaaaaaabbbbbbbbbbbccccccccc\",b = \"zzzzzzzzzzzyyyyyyyyyyxxxxxxxxxx\") == 0\n assert candidate(a = \"abababababababababab\",b = \"babababababababababa\") == 20\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 25\n assert candidate(a = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",b = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 52\n assert candidate(a = \"mnopmnopmnopmnopmnop\",b = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 0\n assert candidate(a = \"abacabadabacabadabacaba\",b = \"zyxzyxzyxzyxzyxzyxzyxzyx\") == 0\n assert candidate(a = \"aaaaa\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"aaaaaabbbbccccdddd\",b = \"eeeeefffffggggghhhhh\") == 0\n assert candidate(a = \"abcdefg\",b = \"hijklmnopqrstuvwxyz\") == 0\n assert candidate(a = \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\",b = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 0\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 2\n assert candidate(a = \"mississippi\",b = \"bababababa\") == 0\n assert candidate(a = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",b = \"pppppppppppppppppppppppppppppppppppppppppp\") == 0\n assert candidate(a = \"mnop\",b = \"qrst\") == 0\n assert candidate(a = \"qazwsxedcrfvtgbyhnujmikolp\",b = \"ploikmjhunbygvtfredcxswqaz\") == 26\n assert candidate(a = \"hello\",b = \"world\") == 3\n assert candidate(a = \"mno\",b = \"jkl\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"hellohellohello\",b = \"worldworldworld\") == 9\n assert candidate(a = \"mmmmmmmmmmmmmmmmmmmmmm\",b = \"nnnnnnnnnnnnnnnnnnnnnn\") == 0\n assert candidate(a = \"aabaaaacaba\",b = \"bcdef\") == 2\n assert candidate(a = \"zzzzzzzzzz\",b = \"aaaaaaaaaa\") == 0\n assert candidate(a = \"aaaaaaaaaaaaaabbbbbbbbbbbbbbcccccccccccccccccdddddddddddddddd\",b = \"eeeeeeeeeeeeeeeeffffffffgggggggggggggggggghhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiii\") == 0\n assert candidate(a = \"qwertqwertqwert\",b = \"mnbvmnbvmnbv\") == 6\n assert candidate(a = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\",b = \"jkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 0\n assert candidate(a = \"qwertyuiop\",b = \"poiuytrewq\") == 10\n assert candidate(a = \"mno\",b = \"mnpq\") == 2\n assert candidate(a = \"llllllllllllllllllllllllllllllllllllllll\",b = \"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk\") == 0\n assert candidate(a = \"programming\",b = \"contest\") == 4\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzxxwwvvutssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 48\n assert candidate(a = \"xyzzzzzxyzzzzz\",b = \"zzzzzxyzzzzzxy\") == 8\n assert candidate(a = \"zzzzz\",b = \"aaaaa\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"ababababababababababababababababab\",b = \"bababababababababababababababababa\") == 34\n assert candidate(a = \"ppppqqqqqqrrrrrrsssssss\",b = \"tttttuuuuuuuuvvvvvvvvvvvvv\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"qwerttyuiiopasdfghjklzzxcvbnm\",b = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 26\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 2\n assert candidate(a = \"python\",b = \"java\") == 2\n assert candidate(a = \"pqrstuv\",b = \"mnopq\") == 2\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(a = \"acabcbacbacbacbaca\",b = \"bdadbdadbdadbdad\") == 8\n assert candidate(a = \"abcdefghijklmnopqrstu\",b = \"vwxyzvwxyzvwxyzvwxyz\") == 0\n assert candidate(a = \"abcdefghijklmnop\",b = \"zyxwvutsrqponmlkjihgfedcba\") == 16\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"abcdefghijklmnopqrstuvwxy\") == 25\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",b = \"defdefdefdefdefdefdefdefdefdefdefdefdefdefdefdefdefdef\") == 0\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabc\",b = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 0\n assert candidate(a = \"aabbaacc\",b = \"zzzzyyxx\") == 0\n assert candidate(a = \"aaaabbbbcccc\",b = \"ccccbbbbaaaa\") == 12\n assert candidate(a = \"abcdefg\",b = \"zzzzzzz\") == 0\n assert candidate(a = \"abcdefghijklmnopqrstuvwxy\",b = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(a = \"acacacacacacacacacacacacacacaca\",b = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\") == 15\n assert candidate(a = \"mnop\",b = \"qrstuvwxyza\") == 1\n assert candidate(a = \"abcdabcdabcd\",b = \"xyzxyzxyzxyz\") == 0\n assert candidate(a = \"abacabadabacaba\",b = \"zyxzyxzyxzyxzyxzyx\") == 0\n assert candidate(a = \"same\",b = \"same\") == 4\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"mnopqrstu\",b = \"vwxyzijkl\") == 4\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"abcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(a = \"mnopqrstuvwxy\",b = \"abcdefghijklmnopqrstuvwxyz\") == 14\n assert candidate(a = \"abcdabcabc\",b = \"zyxzxyzxyz\") == 0\n assert candidate(a = \"abacabadabacabad\",b = \"zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx\") == 0\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabc\",b = \"abcabcabcabcabcabcabcabcabcabc\") == 30\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"abcdefghijklm\",b = \"nopqrstuvwxyz\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"mnopqrstuvwxyzmnopqrstu\",b = \"abcdefghijklmnopqrstuabcdefghijklmnopqrstu\") == 18\n assert candidate(a = \"aaabbbcccdddeeefffggghhhhiiiiijjjjjjkkkkkkkllllllllmmmmmmmmmmm\",b = \"mnopqrstuvwxyzmnopqrstuvwxyzmnopqrstuvwxyzmnopqrstuvwxyz\") == 4\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccdddddddddddddddddddddd\",b = \"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\") == 0\n assert candidate(a = \"xyxzyzxzyzxzyzxzyz\",b = \"zyxzyzxzyzxzyzxzyx\") == 18\n assert candidate(a = \"abcdefghijklmnop\",b = \"qrstuvwxyz\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"xyzz\",b = \"abcd\") == 0\n assert candidate(a = \"racecar\",b = \"madam\") == 5\n assert candidate(a = \"abcdefghijklmnopqrstu\",b = \"vwxyzabcdefghijklmnopqrstu\") == 21\n assert candidate(a = \"qwe\",b = \"qwer\") == 3\n assert candidate(a = \"pppppppppppppppppppppppppppppppppppppppppp\",b = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 0\n assert candidate(a = \"mnbvcxzlkjhgfdsapoiuytrewq\",b = \"qwertyuiopasdfghjklzxcvbnm\") == 26\n assert candidate(a = \"abcdabcdabcd\",b = \"dcbaabcdabcd\") == 12\n assert candidate(a = \"aaaaabbbbb\",b = \"bbbbbccccc\") == 5\n assert candidate(a = \"aaabbbcccdddeeefffggghhhiii\",b = \"kkklllmmmnnnooopppqqqrrrssstttuuuvvv\") == 0\n assert candidate(a = \"aaaaaaaaaaaaaaaaaaaaaaa\",b = \"bbbbbbbbbbbbbbbbbbbbbbbbb\") == 0\n assert candidate(a = \"abacabadabacabadabacabad\",b = \"zzzzyyyyxxxxyyyyzzzz\") == 0\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeeeddccbbbaa\") == 52\n assert candidate(a = \"abacabadabacaba\",b = \"zzzyyyxxxwwwwvvvvuuuuuuttttttsssssrrrrrqqqqqqpppppoonnnnmmmllllkkkkjjjjiiiihhhhhgggggffffffeeeeeeeedddddccccbbbaaaa\") == 10\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 52\n assert candidate(a = \"mnopqrstuvwxyz\",b = \"abcdefghijklm\") == 1\n assert candidate(a = \"one\",b = \"two\") == 1\n assert candidate(a = \"qwertyuiopasdfghjklzxcvbnm\",b = \"qwertyuiopasdfghjklzxcvbnm\") == 26\n assert candidate(a = \"mississippi\",b = \"delaware\") == 3\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 1\n assert candidate(a = \"abc\",b = \"xyz\") == 0\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"abcdefghijklmnopqrstuvwxyz\") == 27\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",b = \"mnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnop\") == 0\n"}, "metadata": {"canonical_parameter_names": ["a", "b"], "leetcode_dataset_entry_point": "Solution().minCharacters", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minCharacters(self, a: str, b: str) -> int:", "container": "Solution", "callable": "minCharacters", "parameters": [{"name": "a", "type": "str"}, {"name": "b", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1738, "task_id": "find-kth-largest-xor-coordinate-value", "difficulty": "Medium", "problem_description": "You are given a 2D matrix of size m x n, consisting of non-negative integers. You are also given an integer k.\nThe value of coordinate (a, b) of the matrix is the XOR of all matrix[i][j] where 0 <= i <= a < m and 0 <= j <= b < n (0-indexed).\nFind the kth largest value (1-indexed) of all the coordinates of matrix.\n \nExample 1:\n\nInput: matrix = [[5,2],[1,6]], k = 1\nOutput: 7\nExplanation: The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value.\n\nExample 2:\n\nInput: matrix = [[5,2],[1,6]], k = 2\nOutput: 5\nExplanation: The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value.\n\nExample 3:\n\nInput: matrix = [[5,2],[1,6]], k = 3\nOutput: 4\nExplanation: The value of coordinate (1,0) is 5 XOR 1 = 4, which is the 3rd largest value.\n \nConstraints:\n\nm == matrix.length\nn == matrix[i].length\n1 <= m, n <= 1000\n0 <= matrix[i][j] <= 106\n1 <= k <= m * n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[5, 2, 3], [1, 6, 4]],k = 5) == 4\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],k = 9) == 0\n assert candidate(matrix = [[5, 2, 3], [1, 6, 4], [7, 8, 9]],k = 9) == 0\n assert candidate(matrix = [[10, 12, 3], [1, 6, 4], [7, 8, 9]],k = 4) == 10\n assert candidate(matrix = [[10, 20], [30, 40]],k = 1) == 40\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 5) == 2\n assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],k = 4) == 1\n assert candidate(matrix = [[0, 0], [0, 0]],k = 1) == 0\n assert candidate(matrix = [[5, 2], [1, 6]],k = 1) == 7\n assert candidate(matrix = [[5, 2, 3], [1, 6, 4]],k = 1) == 7\n assert candidate(matrix = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],k = 9) == 0\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6]],k = 6) == 1\n assert candidate(matrix = [[5, 2], [1, 6]],k = 3) == 4\n assert candidate(matrix = [[5, 2], [1, 6]],k = 2) == 5\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6]],k = 4) == 3\n assert candidate(matrix = [[1000000, 999999, 999998], [999997, 999996, 999995], [999994, 999993, 999992]],k = 6) == 126\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 4, 3, 2]],k = 25) == 2\n assert candidate(matrix = [[5, 8, 9, 12, 15], [14, 11, 10, 7, 4], [3, 6, 7, 10, 13], [12, 15, 14, 11, 8], [1, 4, 5, 8, 11]],k = 18) == 5\n assert candidate(matrix = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],k = 5) == 1\n assert candidate(matrix = [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200]],k = 10) == 172\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],k = 25) == 0\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 10) == 0\n assert candidate(matrix = [[9, 10, 11], [12, 13, 14], [15, 16, 17], [18, 19, 20]],k = 8) == 8\n assert candidate(matrix = [[8, 6, 2, 5, 8, 4, 9], [4, 5, 5, 6, 9, 8, 9], [7, 3, 8, 7, 5, 6, 2], [4, 3, 1, 2, 3, 4, 5], [5, 6, 7, 8, 9, 0, 1]],k = 15) == 11\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 50) == 0\n assert candidate(matrix = [[1, 3, 5, 7, 9, 11, 13], [15, 17, 19, 21, 23, 25, 27], [29, 31, 33, 35, 37, 39, 41]],k = 12) == 14\n assert candidate(matrix = [[25, 10, 15, 20], [5, 30, 35, 40], [45, 50, 55, 60], [65, 70, 75, 80]],k = 15) == 8\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],k = 13) == 0\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 25) == 1\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64]],k = 30) == 7\n assert candidate(matrix = [[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5], [3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4], [3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9], [7, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5]],k = 18) == 9\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 1) == 0\n assert candidate(matrix = [[9, 18, 27, 36, 45], [44, 35, 26, 17, 8], [7, 16, 25, 34, 43], [42, 33, 24, 15, 6], [5, 14, 23, 32, 41]],k = 20) == 8\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 10) == 3\n assert candidate(matrix = [[1000000, 999999, 999998], [999997, 999996, 999995], [999994, 999993, 999992]],k = 9) == 123\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 30) == 0\n assert candidate(matrix = [[5, 2, 15, 6, 3], [10, 1, 4, 7, 8], [3, 1, 9, 2, 12], [6, 14, 11, 13, 5], [1, 15, 8, 6, 7]],k = 20) == 6\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 16) == 0\n assert candidate(matrix = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]],k = 8) == 20\n assert candidate(matrix = [[7, 1, 4, 2], [9, 6, 3, 8], [5, 0, 10, 12], [15, 11, 14, 13]],k = 7) == 8\n assert candidate(matrix = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30], [32, 34, 36, 38, 40], [42, 44, 46, 48, 50]],k = 14) == 8\n assert candidate(matrix = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4], [5, 5, 5, 5, 5]],k = 12) == 1\n assert candidate(matrix = [[5, 2, 15, 10], [1, 6, 8, 3], [12, 4, 7, 9], [14, 11, 13, 5]],k = 10) == 6\n assert candidate(matrix = [[8, 12, 7, 3, 15], [9, 6, 11, 14, 4], [13, 8, 2, 5, 9], [1, 10, 7, 12, 8], [6, 4, 14, 3, 13]],k = 13) == 7\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],k = 1) == 0\n assert candidate(matrix = [[999999, 999999, 999999], [999999, 999999, 999999], [999999, 999999, 999999]],k = 9) == 0\n assert candidate(matrix = [[13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],k = 14) == 12\n assert candidate(matrix = [[15, 9, 12, 3], [11, 6, 4, 14], [7, 8, 9, 13], [2, 5, 10, 1]],k = 7) == 8\n assert candidate(matrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],k = 10) == 1\n assert candidate(matrix = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]],k = 10) == 8\n assert candidate(matrix = [[3, 4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14], [15, 16, 17, 18]],k = 15) == 0\n assert candidate(matrix = [[1, 0, 0, 1, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],k = 12) == 1\n assert candidate(matrix = [[31, 41, 59, 26, 53], [58, 97, 93, 23, 84], [62, 64, 33, 83, 27], [95, 25, 43, 30, 48], [67, 47, 54, 90, 88]],k = 17) == 31\n assert candidate(matrix = [[256, 512, 1024], [128, 256, 512], [64, 128, 256]],k = 5) == 640\n assert candidate(matrix = [[3, 1, 2], [4, 1, 1], [5, 10, 6]],k = 6) == 3\n assert candidate(matrix = [[3, 6, 9, 12], [4, 7, 10, 13], [5, 8, 11, 14]],k = 7) == 5\n assert candidate(matrix = [[3, 8, 1], [9, 11, 13], [4, 7, 12]],k = 6) == 10\n assert candidate(matrix = [[1000000, 0, 0, 0, 0, 0, 0], [0, 1000000, 0, 0, 0, 0, 0], [0, 0, 1000000, 0, 0, 0, 0], [0, 0, 0, 1000000, 0, 0, 0], [0, 0, 0, 0, 1000000, 0, 0], [0, 0, 0, 0, 0, 1000000, 0], [0, 0, 0, 0, 0, 0, 1000000]],k = 25) == 1000000\n assert candidate(matrix = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]],k = 25) == 0\n assert candidate(matrix = [[9, 8, 7, 6, 5, 4], [3, 2, 1, 0, 9, 8], [7, 6, 5, 4, 3, 2], [1, 0, 9, 8, 7, 6], [5, 4, 3, 2, 1, 0]],k = 30) == 0\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 25) == 0\n assert candidate(matrix = [[9, 11, 13, 15, 17, 19, 21], [23, 25, 27, 29, 31, 33, 35], [37, 39, 41, 43, 45, 47, 49]],k = 25) == 0\n assert candidate(matrix = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],k = 14) == 0\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 20) == 1\n assert candidate(matrix = [[1000000, 999999, 999998, 999997], [999996, 999995, 999994, 999993], [999992, 999991, 999990, 999989]],k = 6) == 124\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 1) == 1\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 20) == 7\n assert candidate(matrix = [[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]],k = 15) == 5\n assert candidate(matrix = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]],k = 13) == 4\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 25) == 0\n assert candidate(matrix = [[1000000, 999999, 999998, 999997, 999996], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 15) == 1000000\n assert candidate(matrix = [[7, 7, 7], [7, 7, 7], [7, 7, 7]],k = 4) == 7\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 1) == 15\n assert candidate(matrix = [[1000000, 999999, 999998, 999997], [999996, 999995, 999994, 999993], [999992, 999991, 999990, 999989], [999988, 999987, 999986, 999985]],k = 10) == 120\n assert candidate(matrix = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],k = 3) == 7\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15]],k = 10) == 4\n assert candidate(matrix = [[1000000, 200000, 30000], [4000, 5000, 6000], [70, 80, 900]],k = 8) == 799482\n assert candidate(matrix = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [60, 70, 80, 90, 100], [55, 65, 75, 85, 95]],k = 15) == 10\n assert candidate(matrix = [[42, 42, 42, 42, 42], [42, 42, 42, 42, 42], [42, 42, 42, 42, 42], [42, 42, 42, 42, 42], [42, 42, 42, 42, 42]],k = 15) == 0\n assert candidate(matrix = [[2, 4, 6, 8, 10, 12], [14, 16, 18, 20, 22, 24], [26, 28, 30, 32, 34, 36]],k = 17) == 2\n assert candidate(matrix = [[15, 14, 13, 12], [11, 10, 9, 8], [7, 6, 5, 4], [3, 2, 1, 0]],k = 10) == 0\n assert candidate(matrix = [[23, 56, 12, 78], [34, 89, 56, 45], [12, 34, 56, 78], [89, 56, 23, 12]],k = 10) == 47\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 25) == 0\n assert candidate(matrix = [[100, 200, 300], [400, 500, 600], [700, 800, 900]],k = 5) == 384\n assert candidate(matrix = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [20, 22, 24, 26, 28]],k = 12) == 7\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 16) == 0\n assert candidate(matrix = [[3, 5, 11, 13], [8, 2, 12, 7], [4, 6, 9, 15], [1, 10, 3, 8]],k = 6) == 11\n"}, "metadata": {"canonical_parameter_names": ["matrix", "k"], "leetcode_dataset_entry_point": "Solution().kthLargestValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def kthLargestValue(self, matrix: list[list[int]], k: int) -> int:", "container": "Solution", "callable": "kthLargestValue", "parameters": [{"name": "matrix", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1739, "task_id": "building-boxes", "difficulty": "Hard", "problem_description": "You have a cubic storeroom where the width, length, and height of the room are all equal to n units. You are asked to place n boxes in this room where each box is a cube of unit side length. There are however some rules to placing the boxes:\n\nYou can place the boxes anywhere on the floor.\nIf box x is placed on top of the box y, then each side of the four vertical sides of the box y must either be adjacent to another box or to a wall.\n\nGiven an integer n, return the minimum possible number of boxes touching the floor.\n \nExample 1:\n\n\nInput: n = 3\nOutput: 3\nExplanation: The figure above is for the placement of the three boxes.\nThese boxes are placed in the corner of the room, where the corner is on the left side.\n\nExample 2:\n\n\nInput: n = 4\nOutput: 3\nExplanation: The figure above is for the placement of the four boxes.\nThese boxes are placed in the corner of the room, where the corner is on the left side.\n\nExample 3:\n\n\nInput: n = 10\nOutput: 6\nExplanation: The figure above is for the placement of the ten boxes.\nThese boxes are placed in the corner of the room, where the corner is on the back side.\n \nConstraints:\n\n1 <= n <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 6\n assert candidate(n = 3) == 3\n assert candidate(n = 100) == 34\n assert candidate(n = 15) == 9\n assert candidate(n = 4) == 3\n assert candidate(n = 1000000) == 16443\n assert candidate(n = 20) == 10\n assert candidate(n = 1) == 1\n assert candidate(n = 1000000000) == 1650467\n assert candidate(n = 1000) == 161\n assert candidate(n = 10) == 6\n assert candidate(n = 329) == 75\n assert candidate(n = 344) == 77\n assert candidate(n = 729) == 130\n assert candidate(n = 567890) == 11279\n assert candidate(n = 324) == 75\n assert candidate(n = 300) == 71\n assert candidate(n = 333) == 76\n assert candidate(n = 316) == 74\n assert candidate(n = 23) == 12\n assert candidate(n = 303) == 72\n assert candidate(n = 334) == 76\n assert candidate(n = 35) == 15\n assert candidate(n = 347) == 77\n assert candidate(n = 5000) == 474\n assert candidate(n = 567890123) == 1131581\n assert candidate(n = 4913) == 464\n assert candidate(n = 200) == 53\n assert candidate(n = 500000000) == 1039682\n assert candidate(n = 313) == 73\n assert candidate(n = 500) == 100\n assert candidate(n = 317) == 74\n assert candidate(n = 3375) == 365\n assert candidate(n = 897543210) == 1535456\n assert candidate(n = 341) == 76\n assert candidate(n = 216) == 55\n assert candidate(n = 50000) == 2210\n assert candidate(n = 987654) == 16287\n assert candidate(n = 314) == 73\n assert candidate(n = 318) == 74\n assert candidate(n = 100000) == 3536\n assert candidate(n = 25) == 13\n assert candidate(n = 350) == 77\n assert candidate(n = 5000000) == 48159\n assert candidate(n = 325) == 75\n assert candidate(n = 305) == 72\n assert candidate(n = 123456789) == 408968\n assert candidate(n = 999999) == 16443\n assert candidate(n = 308) == 73\n assert candidate(n = 12167) == 857\n assert candidate(n = 342) == 77\n assert candidate(n = 666) == 120\n assert candidate(n = 315) == 74\n assert candidate(n = 999999999) == 1650467\n assert candidate(n = 2000) == 252\n assert candidate(n = 250000000) == 654763\n assert candidate(n = 30) == 14\n assert candidate(n = 23456789) == 135151\n assert candidate(n = 345) == 77\n assert candidate(n = 336) == 76\n assert candidate(n = 9261) == 719\n assert candidate(n = 311) == 73\n assert candidate(n = 310) == 73\n assert candidate(n = 337) == 76\n assert candidate(n = 343) == 77\n assert candidate(n = 339) == 76\n assert candidate(n = 320) == 74\n assert candidate(n = 332) == 76\n assert candidate(n = 987654321) == 1636751\n assert candidate(n = 307) == 72\n assert candidate(n = 309) == 73\n assert candidate(n = 500000) == 10365\n assert candidate(n = 328) == 75\n assert candidate(n = 348) == 77\n assert candidate(n = 304) == 72\n assert candidate(n = 1500) == 208\n assert candidate(n = 2197) == 272\n assert candidate(n = 1331) == 191\n assert candidate(n = 319) == 74\n assert candidate(n = 125) == 39\n assert candidate(n = 321) == 74\n assert candidate(n = 6859) == 586\n assert candidate(n = 50) == 20\n assert candidate(n = 323) == 75\n assert candidate(n = 331) == 75\n assert candidate(n = 40) == 18\n assert candidate(n = 327) == 75\n assert candidate(n = 349) == 77\n assert candidate(n = 10000) == 756\n assert candidate(n = 335) == 76\n assert candidate(n = 302) == 72\n assert candidate(n = 312) == 73\n assert candidate(n = 330) == 75\n assert candidate(n = 322) == 74\n assert candidate(n = 338) == 76\n assert candidate(n = 306) == 72\n assert candidate(n = 326) == 75\n assert candidate(n = 301) == 71\n assert candidate(n = 123456) == 4068\n assert candidate(n = 346) == 77\n assert candidate(n = 340) == 76\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minimumBoxes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumBoxes(self, n: int) -> int:", "container": "Solution", "callable": "minimumBoxes", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1742, "task_id": "maximum-number-of-balls-in-a-box", "difficulty": "Easy", "problem_description": "You are working in a ball factory where you have n balls numbered from lowLimit up to highLimit inclusive (i.e., n == highLimit - lowLimit + 1), and an infinite number of boxes numbered from 1 to infinity.\nYour job at this factory is to put each ball in the box with a number equal to the sum of digits of the ball's number. For example, the ball number 321 will be put in the box number 3 + 2 + 1 = 6 and the ball number 10 will be put in the box number 1 + 0 = 1.\nGiven two integers lowLimit and highLimit, return the number of balls in the box with the most balls.\n \nExample 1:\n\nInput: lowLimit = 1, highLimit = 10\nOutput: 2\nExplanation:\nBox Number: 1 2 3 4 5 6 7 8 9 10 11 ...\nBall Count: 2 1 1 1 1 1 1 1 1 0 0 ...\nBox 1 has the most number of balls with 2 balls.\nExample 2:\n\nInput: lowLimit = 5, highLimit = 15\nOutput: 2\nExplanation:\nBox Number: 1 2 3 4 5 6 7 8 9 10 11 ...\nBall Count: 1 1 1 1 2 2 1 1 1 0 0 ...\nBoxes 5 and 6 have the most number of balls with 2 balls in each.\n\nExample 3:\n\nInput: lowLimit = 19, highLimit = 28\nOutput: 2\nExplanation:\nBox Number: 1 2 3 4 5 6 7 8 9 10 11 12 ...\nBall Count: 0 1 1 1 1 1 1 1 1 2 0 0 ...\nBox 10 has the most number of balls with 2 balls.\n\n \nConstraints:\n\n1 <= lowLimit <= highLimit <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(lowLimit = 999,highLimit = 1000) == 1\n assert candidate(lowLimit = 1000,highLimit = 10000) == 615\n assert candidate(lowLimit = 50000,highLimit = 50500) == 44\n assert candidate(lowLimit = 99,highLimit = 999) == 70\n assert candidate(lowLimit = 500,highLimit = 550) == 6\n assert candidate(lowLimit = 9999,highLimit = 100000) == 5520\n assert candidate(lowLimit = 1,highLimit = 10) == 2\n assert candidate(lowLimit = 100,highLimit = 200) == 10\n assert candidate(lowLimit = 99,highLimit = 199) == 10\n assert candidate(lowLimit = 1,highLimit = 100) == 10\n assert candidate(lowLimit = 1,highLimit = 20) == 3\n assert candidate(lowLimit = 10,highLimit = 100) == 9\n assert candidate(lowLimit = 50,highLimit = 150) == 10\n assert candidate(lowLimit = 5,highLimit = 15) == 2\n assert candidate(lowLimit = 19,highLimit = 28) == 2\n assert candidate(lowLimit = 45678,highLimit = 98765) == 3544\n assert candidate(lowLimit = 40000,highLimit = 50000) == 670\n assert candidate(lowLimit = 10000,highLimit = 20000) == 670\n assert candidate(lowLimit = 33333,highLimit = 44444) == 782\n assert candidate(lowLimit = 67890,highLimit = 67990) == 11\n assert candidate(lowLimit = 54321,highLimit = 54421) == 10\n assert candidate(lowLimit = 88888,highLimit = 88988) == 10\n assert candidate(lowLimit = 100,highLimit = 100) == 1\n assert candidate(lowLimit = 99999,highLimit = 100000) == 1\n assert candidate(lowLimit = 9995,highLimit = 10005) == 1\n assert candidate(lowLimit = 43210,highLimit = 43250) == 5\n assert candidate(lowLimit = 99995,highLimit = 100005) == 1\n assert candidate(lowLimit = 30000,highLimit = 35000) == 365\n assert candidate(lowLimit = 98765,highLimit = 98865) == 10\n assert candidate(lowLimit = 54321,highLimit = 54341) == 3\n assert candidate(lowLimit = 11111,highLimit = 11115) == 1\n assert candidate(lowLimit = 10000,highLimit = 99999) == 5520\n assert candidate(lowLimit = 66666,highLimit = 66766) == 10\n assert candidate(lowLimit = 77777,highLimit = 77800) == 3\n assert candidate(lowLimit = 99990,highLimit = 100000) == 1\n assert candidate(lowLimit = 11111,highLimit = 11200) == 9\n assert candidate(lowLimit = 5000,highLimit = 6000) == 75\n assert candidate(lowLimit = 56789,highLimit = 56800) == 2\n assert candidate(lowLimit = 55555,highLimit = 66666) == 782\n assert candidate(lowLimit = 9990,highLimit = 10000) == 1\n assert candidate(lowLimit = 12345,highLimit = 54321) == 2854\n assert candidate(lowLimit = 50000,highLimit = 50100) == 10\n assert candidate(lowLimit = 23456,highLimit = 23460) == 1\n assert candidate(lowLimit = 500,highLimit = 5000) == 340\n assert candidate(lowLimit = 5000,highLimit = 5100) == 10\n assert candidate(lowLimit = 90000,highLimit = 95000) == 365\n assert candidate(lowLimit = 10000,highLimit = 100000) == 5520\n assert candidate(lowLimit = 9999,highLimit = 10000) == 1\n assert candidate(lowLimit = 999,highLimit = 1009) == 1\n assert candidate(lowLimit = 12345,highLimit = 12395) == 6\n assert candidate(lowLimit = 1,highLimit = 99999) == 6000\n assert candidate(lowLimit = 12345,highLimit = 12345) == 1\n assert candidate(lowLimit = 1,highLimit = 1000) == 75\n assert candidate(lowLimit = 22222,highLimit = 22322) == 10\n assert candidate(lowLimit = 12345,highLimit = 67890) == 3699\n assert candidate(lowLimit = 56789,highLimit = 56799) == 2\n assert candidate(lowLimit = 100,highLimit = 1000) == 70\n assert candidate(lowLimit = 11111,highLimit = 22222) == 754\n assert candidate(lowLimit = 77777,highLimit = 77877) == 10\n assert candidate(lowLimit = 100000,highLimit = 100000) == 1\n assert candidate(lowLimit = 250,highLimit = 750) == 46\n assert candidate(lowLimit = 30000,highLimit = 40000) == 670\n assert candidate(lowLimit = 99900,highLimit = 100100) == 10\n assert candidate(lowLimit = 100000,highLimit = 100050) == 6\n assert candidate(lowLimit = 12345,highLimit = 12445) == 11\n assert candidate(lowLimit = 5000,highLimit = 5050) == 6\n assert candidate(lowLimit = 995,highLimit = 1005) == 1\n assert candidate(lowLimit = 1000,highLimit = 1050) == 6\n assert candidate(lowLimit = 33333,highLimit = 33433) == 10\n assert candidate(lowLimit = 1234,highLimit = 5678) == 344\n assert candidate(lowLimit = 8888,highLimit = 8900) == 2\n assert candidate(lowLimit = 11111,highLimit = 11211) == 10\n assert candidate(lowLimit = 999,highLimit = 1001) == 1\n assert candidate(lowLimit = 67890,highLimit = 78900) == 749\n assert candidate(lowLimit = 20000,highLimit = 30000) == 670\n assert candidate(lowLimit = 50000,highLimit = 51000) == 75\n assert candidate(lowLimit = 99,highLimit = 101) == 1\n assert candidate(lowLimit = 88888,highLimit = 99999) == 736\n assert candidate(lowLimit = 1234,highLimit = 1244) == 2\n assert candidate(lowLimit = 44444,highLimit = 55555) == 785\n assert candidate(lowLimit = 300,highLimit = 600) == 28\n assert candidate(lowLimit = 12345,highLimit = 12355) == 2\n assert candidate(lowLimit = 70000,highLimit = 80000) == 670\n assert candidate(lowLimit = 88888,highLimit = 88999) == 11\n assert candidate(lowLimit = 20000,highLimit = 25000) == 365\n assert candidate(lowLimit = 123,highLimit = 456) == 33\n"}, "metadata": {"canonical_parameter_names": ["lowLimit", "highLimit"], "leetcode_dataset_entry_point": "Solution().countBalls", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countBalls(self, lowLimit: int, highLimit: int) -> int:", "container": "Solution", "callable": "countBalls", "parameters": [{"name": "lowLimit", "type": "int"}, {"name": "highLimit", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1743, "task_id": "restore-the-array-from-adjacent-pairs", "difficulty": "Medium", "problem_description": "There is an integer array nums that consists of n unique elements, but you have forgotten it. However, you do remember every pair of adjacent elements in nums.\nYou are given a 2D integer array adjacentPairs of size n - 1 where each adjacentPairs[i] = [ui, vi] indicates that the elements ui and vi are adjacent in nums.\nIt is guaranteed that every adjacent pair of elements nums[i] and nums[i+1] will exist in adjacentPairs, either as [nums[i], nums[i+1]] or [nums[i+1], nums[i]]. The pairs can appear in any order.\nReturn the original array nums. If there are multiple solutions, return any of them.\n \nExample 1:\n\nInput: adjacentPairs = [[2,1],[3,4],[3,2]]\nOutput: [1,2,3,4]\nExplanation: This array has all its adjacent pairs in adjacentPairs.\nNotice that adjacentPairs[i] may not be in left-to-right order.\n\nExample 2:\n\nInput: adjacentPairs = [[4,-2],[1,4],[-3,1]]\nOutput: [-2,4,1,-3]\nExplanation: There can be negative numbers.\nAnother solution is [-3,1,4,-2], which would also be accepted.\n\nExample 3:\n\nInput: adjacentPairs = [[100000,-100000]]\nOutput: [100000,-100000]\n\n \nConstraints:\n\nnums.length == n\nadjacentPairs.length == n - 1\nadjacentPairs[i].length == 2\n2 <= n <= 105\n-105 <= nums[i], ui, vi <= 105\nThere exists some nums that has adjacentPairs as its pairs.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, -2]]) == [-1, 0, 1, 2, 3, -2]\n assert candidate(adjacentPairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]]) == [10, 20, 30, 40, 50, 60]\n assert candidate(adjacentPairs = [[2, 1], [3, 4], [3, 2]]) == [1, 2, 3, 4]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700]]) == [100, 200, 300, 400, 500, 600, 700]\n assert candidate(adjacentPairs = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6]]) == [-1, -2, -3, -4, -5, -6]\n assert candidate(adjacentPairs = [[-1, 2], [2, 3], [3, 4], [4, 5]]) == [-1, 2, 3, 4, 5]\n assert candidate(adjacentPairs = [[5, 1], [1, 2], [2, 3], [3, 4]]) == [5, 1, 2, 3, 4]\n assert candidate(adjacentPairs = [[100000, -100000]]) == [100000, -100000]\n assert candidate(adjacentPairs = [[5, 3], [3, 1], [1, 2], [2, 4], [4, 6]]) == [5, 3, 1, 2, 4, 6]\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [-2, -1]]) == [2, 1, 0, -1, -2]\n assert candidate(adjacentPairs = [[4, -2], [1, 4], [-3, 1]]) == [-2, 4, 1, -3]\n assert candidate(adjacentPairs = [[1, 6], [2, 3], [3, 4], [4, 5], [5, 6]]) == [1, 6, 5, 4, 3, 2]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [1, 2, 3, 4, 5, 6]\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4]]) == [-1, 0, 1, 2, 3, 4]\n assert candidate(adjacentPairs = [[1, 6], [6, 8], [8, 3], [3, 7], [7, 2], [2, 5], [5, 4]]) == [1, 6, 8, 3, 7, 2, 5, 4]\n assert candidate(adjacentPairs = [[-1, 1], [-2, -1], [-3, -2], [4, -3], [5, 4], [6, 5], [7, 6]]) == [1, -1, -2, -3, 4, 5, 6, 7]\n assert candidate(adjacentPairs = [[-10, -20], [-20, -30], [-30, -40], [-40, -50], [-50, -60]]) == [-10, -20, -30, -40, -50, -60]\n assert candidate(adjacentPairs = [[-10000, 10000], [10000, 20000], [20000, -10000], [-20000, -10000], [30000, 20000], [30000, 40000]]) == [-20000, -10000, 20000, 10000, -10000, 20000, 10000]\n assert candidate(adjacentPairs = [[-5, -4], [-4, -3], [-3, -2], [-2, -1], [-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]\n assert candidate(adjacentPairs = [[100000, -100000], [99999, 100000], [-99999, -100000], [88888, 99999], [-88888, -99999]]) == [88888, 99999, 100000, -100000, -99999, -88888]\n assert candidate(adjacentPairs = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6], [-6, -7], [-7, -8], [-8, -9], [-9, -10]]) == [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]\n assert candidate(adjacentPairs = [[-5, 0], [0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 65], [65, 70], [70, 75], [75, 80], [80, 85], [85, 90]]) == [-5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90]\n assert candidate(adjacentPairs = [[-10, -20], [-20, -30], [-30, -40], [-40, -50], [-50, -60], [-60, -70], [-70, -80], [-80, -90], [-90, -100]]) == [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]\n assert candidate(adjacentPairs = [[-10, -9], [-9, -8], [-8, -7], [-7, -6], [-6, -5], [-5, -4], [-4, -3], [-3, -2], [-2, -1], [-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 1100], [1100, 1200], [1200, 1300], [1300, 1400], [1400, 1500]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(adjacentPairs = [[1, 2], [3, 4], [5, 6], [1, 3], [4, 5]]) == [2, 1, 3, 4, 5, 6]\n assert candidate(adjacentPairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110], [110, 120]]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]\n assert candidate(adjacentPairs = [[100000, -100000], [-99999, 100000], [-99998, -99999], [-99997, -99998], [-99996, -99997], [-99995, -99996], [-99994, -99995], [-99993, -99994], [-99992, -99993], [-99991, -99992]]) == [-100000, 100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991]\n assert candidate(adjacentPairs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(adjacentPairs = [[5, 15], [15, 25], [25, 35], [35, 45], [45, 55], [55, 65], [65, 75], [75, 85], [85, 95], [95, 105]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]\n assert candidate(adjacentPairs = [[50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110], [110, 120], [120, 130], [130, 140], [140, 150]]) == [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]\n assert candidate(adjacentPairs = [[-5, 0], [0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [-5, -10], [-10, -15], [-15, -20], [-20, -25], [-25, -30], [-30, -35], [-35, -40], [-40, -45], [-45, -50]]) == [50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50]\n assert candidate(adjacentPairs = [[-5, -4], [-4, -3], [-3, -2], [-2, -1], [-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]\n assert candidate(adjacentPairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23], [23, 25], [25, 27], [27, 29], [29, 31], [31, 33], [33, 35], [35, 37], [37, 39]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]\n assert candidate(adjacentPairs = [[100000, 99999], [99998, 99999], [99997, 99998], [99996, 99997], [99995, 99996]]) == [100000, 99999, 99998, 99997, 99996, 99995]\n assert candidate(adjacentPairs = [[-10, -20], [-20, -30], [-30, -40], [-40, -50], [-50, -60], [-60, -70], [-70, -80], [-80, -90]]) == [-10, -20, -30, -40, -50, -60, -70, -80, -90]\n assert candidate(adjacentPairs = [[-1, 1], [-2, -1], [-3, -2], [-4, -3], [-5, -4], [-6, -5], [-7, -6], [-8, -7], [-9, -8], [-10, -9]]) == [1, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]\n assert candidate(adjacentPairs = [[10, 5], [5, -10], [-10, 15], [15, -15], [20, 10], [25, 20], [30, 25], [35, 30], [40, 35], [45, 40], [50, 45]]) == [-15, 15, -10, 5, 10, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(adjacentPairs = [[1, 2], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [11, 10], [12, 11], [13, 12], [14, 13], [15, 14], [16, 15], [17, 16], [18, 17], [19, 18], [20, 19]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(adjacentPairs = [[1, 2], [3, 2], [5, 4], [4, 3], [7, 6], [6, 5], [9, 8], [8, 7], [11, 10], [10, 9]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(adjacentPairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(adjacentPairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23], [23, 25], [25, 27], [27, 29]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]\n assert candidate(adjacentPairs = [[5, 3], [3, 1], [1, -2], [-2, -4], [-4, -6], [-6, -8], [-8, -10], [-10, -12], [-12, -14], [-14, -16], [-16, -18], [-18, -20], [-20, -22], [-22, -24], [-24, -26]]) == [5, 3, 1, -2, -4, -6, -8, -10, -12, -14, -16, -18, -20, -22, -24, -26]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(adjacentPairs = [[1, -1], [-1, 2], [2, -2], [-2, 3], [3, -3], [-3, 4], [4, -4], [-4, 5], [5, -5], [-5, 6], [6, -6], [-6, 7], [7, -7], [-7, 8], [8, -8], [-8, 9], [9, -9], [-9, 10], [10, -10]]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\n assert candidate(adjacentPairs = [[-1, 100], [100, 200], [200, -300], [-300, 400], [400, 500]]) == [-1, 100, 200, -300, 400, 500]\n assert candidate(adjacentPairs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0]]) == [0, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(adjacentPairs = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6], [-6, -7], [-7, -8], [-8, -9], [-9, -10], [-10, -11], [-11, -12]]) == [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12]\n assert candidate(adjacentPairs = [[500, 1000], [1000, 1500], [1500, 2000], [2000, 2500], [2500, 3000], [3000, 3500], [3500, 4000], [4000, 4500], [4500, 5000], [5000, 5500], [5500, 6000], [6000, 6500], [6500, 7000], [7000, 7500], [7500, 8000], [8000, 8500], [8500, 9000], [9000, 9500], [9500, 10000]]) == [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000]\n assert candidate(adjacentPairs = [[1, 5], [5, 9], [9, 13], [13, 17], [17, 21], [21, 25], [25, 29], [29, 33], [33, 37], [37, 41]]) == [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41]\n assert candidate(adjacentPairs = [[-10, -20], [-20, -30], [-30, -40], [-40, -50], [-50, -60], [-60, -70], [-70, -80], [-80, -90], [-90, -100]]) == [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]\n assert candidate(adjacentPairs = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]\n assert candidate(adjacentPairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23], [23, 25], [25, 27], [27, 29], [29, 31], [31, 33], [33, 35], [35, 37], [37, 39], [39, 41]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [100, 150], [150, 250], [250, 350], [350, 450], [450, 550], [550, 650], [650, 750], [750, 850], [850, 950], [950, 1050]]) == [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]\n assert candidate(adjacentPairs = [[10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 65], [65, 70]]) == [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(adjacentPairs = [[100000, 90000], [80000, 90000], [70000, 80000], [60000, 70000], [50000, 60000]]) == [100000, 90000, 80000, 70000, 60000, 50000]\n assert candidate(adjacentPairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(adjacentPairs = [[-50000, -40000], [-30000, -40000], [-20000, -30000], [-10000, -20000], [0, -10000]]) == [-50000, -40000, -30000, -20000, -10000, 0]\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(adjacentPairs = [[-99999, 99999], [99999, -99998], [-99998, 99998], [99998, -99997], [-99997, 99997], [99997, -99996], [-99996, 99996], [99996, -99995]]) == [-99999, 99999, -99998, 99998, -99997, 99997, -99996, 99996, -99995]\n assert candidate(adjacentPairs = [[-5, 0], [-4, -5], [-3, -4], [-2, -3], [-1, -2], [0, -1], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4]]) == [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, 0]\n assert candidate(adjacentPairs = [[0, 1], [2, 1], [4, 3], [3, 2], [6, 5], [5, 4], [8, 7], [7, 6], [10, 9], [9, 8], [12, 11], [11, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(adjacentPairs = [[-1, 2], [2, -3], [-3, 4], [4, -5], [-5, 6], [6, -7], [-7, 8], [8, -9], [-9, 10], [10, -11], [-11, 12], [12, -13], [-13, 14], [14, -15], [-15, 16], [16, -17], [-17, 18], [18, -19], [-19, 20]]) == [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [2, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2]\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(adjacentPairs = [[-100, -99], [-99, -98], [-98, -97], [-97, -96], [-96, -95], [-95, -94], [-94, -93], [-93, -92], [-92, -91], [-91, -90], [-90, -89], [-89, -88], [-88, -87], [-87, -86], [-86, -85], [-85, -84], [-84, -83], [-83, -82], [-82, -81], [-81, -80]]) == [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80]\n assert candidate(adjacentPairs = [[1, 6], [6, 11], [11, 16], [16, 21], [21, 26], [26, 31], [31, 36], [36, 41], [41, 46], [46, 51]]) == [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51]\n assert candidate(adjacentPairs = [[-100000, -90000], [-90000, -80000], [-80000, -70000], [-70000, -60000], [-60000, -50000], [-50000, -40000], [-40000, -30000], [-30000, -20000], [-20000, -10000], [-10000, 0], [0, 10000], [10000, 20000], [20000, 30000], [30000, 40000], [40000, 50000], [50000, 60000], [60000, 70000], [70000, 80000], [80000, 90000], [90000, 100000]]) == [-100000, -90000, -80000, -70000, -60000, -50000, -40000, -30000, -20000, -10000, 0, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(adjacentPairs = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [2, 3], [4, 5], [6, 7], [8, 9]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(adjacentPairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110]]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n"}, "metadata": {"canonical_parameter_names": ["adjacentPairs"], "leetcode_dataset_entry_point": "Solution().restoreArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def restoreArray(self, adjacentPairs: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "restoreArray", "parameters": [{"name": "adjacentPairs", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1744, "task_id": "can-you-eat-your-favorite-candy-on-your-favorite-day", "difficulty": "Medium", "problem_description": "You are given a (0-indexed) array of positive integers candiesCount where candiesCount[i] represents the number of candies of the ith type you have. You are also given a 2D array queries where queries[i] = [favoriteTypei, favoriteDayi, dailyCapi].\nYou play a game with the following rules:\n\nYou start eating candies on day 0.\nYou cannot eat any candy of type i unless you have eaten all candies of type i - 1.\nYou must eat at least one candy per day until you have eaten all the candies.\n\nConstruct a boolean array answer such that answer.length == queries.length and answer[i] is true if you can eat a candy of type favoriteTypei on day favoriteDayi without eating more than dailyCapi candies on any day, and false otherwise. Note that you can eat different types of candy on the same day, provided that you follow rule 2.\nReturn the constructed array answer.\n \nExample 1:\n\nInput: candiesCount = [7,4,5,3,8], queries = [[0,2,2],[4,2,4],[2,13,1000000000]]\nOutput: [true,false,true]\nExplanation:\n1- If you eat 2 candies (type 0) on day 0 and 2 candies (type 0) on day 1, you will eat a candy of type 0 on day 2.\n2- You can eat at most 4 candies each day.\n If you eat 4 candies every day, you will eat 4 candies (type 0) on day 0 and 4 candies (type 0 and type 1) on day 1.\n On day 2, you can only eat 4 candies (type 1 and type 2), so you cannot eat a candy of type 4 on day 2.\n3- If you eat 1 candy each day, you will eat a candy of type 2 on day 13.\n\nExample 2:\n\nInput: candiesCount = [5,2,6,4,1], queries = [[3,1,2],[4,10,3],[3,10,100],[4,100,30],[1,3,1]]\nOutput: [false,true,true,false,false]\n\n \nConstraints:\n\n1 <= candiesCount.length <= 105\n1 <= candiesCount[i] <= 105\n1 <= queries.length <= 105\nqueries[i].length == 3\n0 <= favoriteTypei < candiesCount.length\n0 <= favoriteDayi <= 109\n1 <= dailyCapi <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(candiesCount = [7, 4, 5, 3, 8],queries = [[0, 2, 2], [4, 2, 4], [2, 13, 1000000000]]) == [True, False, True]\n assert candidate(candiesCount = [5, 2, 6, 4, 1],queries = [[3, 1, 2], [4, 10, 3], [3, 10, 100], [4, 100, 30], [1, 3, 1]]) == [False, True, True, False, False]\n assert candidate(candiesCount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 0, 1], [1, 1, 2], [2, 3, 3], [3, 6, 4], [4, 10, 5], [5, 15, 6], [6, 21, 7], [7, 28, 8], [8, 36, 9], [9, 45, 10]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [1000000, 500000, 250000, 125000, 62500],queries = [[0, 999999, 1000000], [1, 1499999, 500000], [2, 1999999, 250000], [3, 2499999, 125000], [4, 2999999, 62500]]) == [True, True, False, False, False]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[0, 0, 10], [1, 1, 20], [2, 2, 30], [3, 3, 40], [4, 4, 50], [0, 5, 5], [1, 10, 10], [2, 15, 15], [3, 20, 20], [4, 25, 25]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]]) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 1, 1], [1, 3, 2], [2, 6, 3], [3, 10, 4], [4, 15, 5], [5, 21, 6], [6, 28, 7], [7, 36, 8], [8, 45, 9], [9, 55, 10]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [999999, 999999, 999999, 999999],queries = [[0, 100000, 999999], [1, 200000, 999999], [2, 300000, 999999], [3, 400000, 999999], [0, 300000, 333333], [1, 400000, 333333], [2, 500000, 333333], [3, 600000, 333333]]) == [True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 0, 10], [1, 10, 20], [2, 30, 30], [3, 60, 40], [4, 100, 50], [5, 150, 60], [6, 210, 70], [7, 280, 80], [8, 360, 90], [9, 450, 100]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [100000, 200000, 300000, 400000, 500000],queries = [[0, 50000, 1000], [1, 100000, 2000], [2, 150000, 3000], [3, 200000, 4000], [4, 250000, 5000]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 0, 1], [1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5], [5, 5, 6], [6, 6, 7], [7, 7, 8], [8, 8, 9], [9, 9, 10]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [5, 4, 3, 2, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [0, 4, 10], [1, 3, 10], [2, 2, 10], [3, 1, 10], [4, 0, 10]]) == [True, False, False, False, False, True, True, True, True, False]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[4, 49, 50], [3, 29, 40], [2, 19, 30], [1, 9, 20], [0, 9, 10]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 5, 5], [1, 15, 15], [2, 30, 25], [3, 45, 35], [4, 60, 45], [5, 75, 55], [6, 90, 65], [7, 105, 75], [8, 120, 85], [9, 135, 95]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500],queries = [[0, 99, 100], [1, 199, 200], [2, 299, 300], [3, 399, 400], [4, 499, 500], [0, 1, 50], [1, 1, 100], [2, 1, 150], [3, 1, 200], [4, 1, 250]]) == [True, True, True, True, True, True, True, False, False, False]\n assert candidate(candiesCount = [100, 200, 300, 400, 500],queries = [[0, 99, 100], [1, 199, 200], [2, 299, 300], [3, 399, 400], [4, 499, 500]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [100000000, 200000000, 300000000, 400000000, 500000000],queries = [[0, 100000000, 150000000], [4, 900000000, 1000000000], [2, 500000000, 350000000]]) == [False, True, True]\n assert candidate(candiesCount = [1000000, 500000, 250000, 125000, 62500, 31250],queries = [[0, 500000, 100000], [5, 500000, 100000], [2, 750000, 50000], [4, 875000, 31250]]) == [True, True, True, True]\n assert candidate(candiesCount = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],queries = [[0, 1000000000, 1000000000], [4, 4000000000, 1000000000], [2, 2500000000, 500000000]]) == [False, True, True]\n assert candidate(candiesCount = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],queries = [[0, 10000, 1000], [1, 20000, 2000], [2, 30000, 3000], [3, 40000, 4000], [4, 50000, 5000], [5, 60000, 6000], [6, 70000, 7000], [7, 80000, 8000], [8, 90000, 9000], [9, 100000, 10000]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 0, 10], [1, 1, 10], [2, 2, 10], [3, 3, 10], [4, 4, 10], [5, 5, 10], [6, 6, 10], [7, 7, 10], [8, 8, 10], [9, 9, 10]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000],queries = [[0, 499999, 500000], [1, 999999, 500000], [2, 1499999, 500000], [3, 1999999, 500000], [4, 2499999, 500000], [5, 2999999, 500000], [6, 3499999, 500000], [7, 3999999, 500000], [8, 4499999, 500000], [9, 4999999, 500000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [1000000, 999999, 1000000, 999999, 1000000],queries = [[0, 1000000, 500000], [1, 1999998, 999999], [2, 2999999, 1000000], [3, 3999997, 1000000], [4, 4999999, 1000000]]) == [False, True, False, True, False]\n assert candidate(candiesCount = [100000000, 200000000, 150000000, 300000000, 250000000],queries = [[0, 50000000, 50000000], [1, 100000000, 100000000], [2, 150000000, 150000000], [3, 200000000, 200000000], [4, 250000000, 250000000]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [50000, 100000, 150000, 200000, 250000, 300000, 350000, 400000, 450000, 500000],queries = [[0, 0, 100000], [1, 100000, 200000], [2, 300000, 300000], [3, 600000, 400000], [4, 1000000, 500000], [5, 1500000, 600000], [6, 2100000, 700000], [7, 2800000, 800000], [8, 3600000, 900000], [9, 4500000, 1000000]]) == [True, True, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [[0, 0, 1], [1, 1, 10], [2, 11, 100], [3, 111, 1000], [4, 1111, 10000], [5, 11111, 100000], [6, 111111, 1000000], [7, 1111111, 10000000], [8, 11111111, 100000000], [9, 111111111, 1000000000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [0, 99, 1000], [1, 199, 1000], [2, 299, 1000], [3, 399, 1000], [4, 499, 1000], [5, 599, 1000], [6, 699, 1000], [7, 799, 1000], [8, 899, 1000], [9, 999, 1000]]) == [True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[0, 5, 10], [1, 15, 10], [2, 25, 10], [3, 35, 10], [4, 45, 10], [0, 9, 9], [1, 19, 9], [2, 29, 9], [3, 39, 9], [4, 49, 9], [0, 1, 1], [1, 11, 1], [2, 21, 1], [3, 31, 1], [4, 41, 1]]) == [True, True, True, True, True, True, True, True, True, True, True, True, False, False, False]\n assert candidate(candiesCount = [100000000, 200000000, 300000000, 400000000, 500000000],queries = [[0, 99999999, 100000000], [4, 1499999999, 150000000], [2, 299999999, 300000000]]) == [True, True, True]\n assert candidate(candiesCount = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [13, 13, 1], [14, 14, 1], [15, 15, 1], [16, 16, 1], [17, 17, 1], [18, 18, 1], [19, 19, 1]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [1, 10, 100, 1000, 10000],queries = [[0, 0, 1], [1, 1, 10], [2, 2, 100], [3, 3, 1000], [4, 4, 10000], [0, 5, 5], [1, 10, 10], [2, 15, 15], [3, 20, 20], [4, 25, 25]]) == [True, True, True, True, True, False, True, True, True, False]\n assert candidate(candiesCount = [1000000, 1000000, 1000000, 1000000, 1000000],queries = [[0, 100000, 200000], [1, 200000, 300000], [2, 300000, 400000], [3, 400000, 500000], [4, 500000, 600000]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1000, 1000, 1000, 1000, 1000],queries = [[0, 0, 1], [1, 500, 1000], [2, 1000, 1000], [3, 1500, 1000], [4, 2000, 1000]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]]) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 0, 1], [1, 1, 2], [2, 3, 3], [3, 6, 4], [4, 10, 5], [5, 15, 6], [6, 21, 7], [7, 28, 8], [8, 36, 9]]) == [True, False, False, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 3, 1], [3, 6, 1], [4, 10, 1], [5, 15, 1], [6, 21, 1], [7, 28, 1], [8, 36, 1], [9, 45, 1]]) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, 99, 100], [1, 199, 200], [2, 299, 300], [3, 399, 400], [4, 499, 500], [5, 599, 600], [6, 699, 700], [7, 799, 800], [8, 899, 900], [9, 999, 1000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 0, 10], [9, 494, 100], [5, 150, 60], [2, 30, 30], [8, 315, 90]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 0, 1], [9, 44, 10], [3, 9, 4], [5, 14, 5], [8, 35, 9]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1000000000, 1000000000, 1000000000],queries = [[0, 500000000, 500000000], [1, 1500000000, 500000000], [2, 2500000000, 500000000]]) == [True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500],queries = [[0, 0, 100], [1, 100, 200], [2, 300, 300], [3, 600, 400], [4, 1000, 500]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],queries = [[0, 500000, 2000000], [1, 1000000, 2000000], [2, 1500000, 2000000], [3, 2000000, 2000000], [4, 2500000, 2000000], [5, 3000000, 2000000], [6, 3500000, 2000000], [7, 4000000, 2000000], [8, 4500000, 2000000], [9, 5000000, 2000000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, 1, 50], [1, 51, 100], [2, 151, 150], [3, 301, 200], [4, 501, 250], [5, 751, 300], [6, 1051, 350], [7, 1401, 400], [8, 1801, 450], [9, 2251, 500]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[0, 0, 5], [1, 4, 10], [2, 19, 15], [3, 34, 20], [4, 49, 25]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1000000000, 999999999, 888888888, 777777777, 666666666],queries = [[0, 1000000000, 500000000], [4, 1000000000, 200000000], [2, 500000000, 100000000]]) == [False, True, True]\n assert candidate(candiesCount = [1000000, 1000000, 1000000],queries = [[0, 100000, 1000], [1, 200000, 500000], [2, 500000, 1]]) == [True, True, False]\n assert candidate(candiesCount = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [50, 50, 50, 50, 50],queries = [[0, 24, 50], [1, 49, 50], [2, 74, 50], [3, 99, 50], [4, 124, 50], [0, 25, 25], [1, 50, 25], [2, 75, 25], [3, 100, 25], [4, 125, 25]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, 0, 100], [1, 199, 200], [2, 399, 300], [3, 599, 400], [4, 799, 500], [5, 999, 600], [6, 1199, 700], [7, 1399, 800], [8, 1599, 900], [9, 1799, 1000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[0, 0, 10], [1, 10, 20], [2, 30, 30], [3, 60, 40], [4, 100, 50]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1000000, 500000, 250000, 125000, 62500],queries = [[0, 999999, 1000000], [1, 1499999, 500000], [2, 374999, 250000], [3, 499999, 125000], [4, 593749, 62500]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500],queries = [[0, 0, 1], [1, 100, 100], [2, 200, 150], [3, 300, 200], [4, 400, 250]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1, 1, 1, 1, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],queries = [[0, 1000, 500], [1, 3000, 1000], [2, 5000, 1500], [3, 7000, 2000], [4, 9000, 2500], [5, 11000, 3000], [6, 13000, 3500], [7, 15000, 4000], [8, 17000, 4500], [9, 19000, 5000]]) == [False, False, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [[0, 0, 1], [1, 10, 10], [2, 110, 100], [3, 1110, 1000], [4, 11110, 10000], [5, 111110, 100000], [6, 1111110, 1000000], [7, 11111110, 10000000], [8, 111111110, 100000000], [9, 1111111110, 1000000000]]) == [True, True, True, True, True, True, True, True, True, True]\n"}, "metadata": {"canonical_parameter_names": ["candiesCount", "queries"], "leetcode_dataset_entry_point": "Solution().canEat", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canEat(self, candiesCount: list[int], queries: list[list[int]]) -> list[bool]:", "container": "Solution", "callable": "canEat", "parameters": [{"name": "candiesCount", "type": "list[int]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1745, "task_id": "palindrome-partitioning-iv", "difficulty": "Hard", "problem_description": "Given a string s, return true if it is possible to split the string s into three non-empty palindromic substrings. Otherwise, return false.​​​​​\nA string is said to be palindrome if it the same string when reversed.\n \nExample 1:\n\nInput: s = \"abcbdd\"\nOutput: true\nExplanation: \"abcbdd\" = \"a\" + \"bcb\" + \"dd\", and all three substrings are palindromes.\n\nExample 2:\n\nInput: s = \"bcbddxy\"\nOutput: false\nExplanation: s cannot be split into 3 palindromes.\n\n \nConstraints:\n\n3 <= s.length <= 2000\ns​​​​​​ consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcba\") == True\n assert candidate(s = \"abcdcba\") == True\n assert candidate(s = \"aabbaa\") == True\n assert candidate(s = \"aaaaa\") == True\n assert candidate(s = \"abacdfgdcaba\") == False\n assert candidate(s = \"aabbbaa\") == True\n assert candidate(s = \"noonnoon\") == True\n assert candidate(s = \"aaa\") == True\n assert candidate(s = \"aabb\") == True\n assert candidate(s = \"racecar\") == True\n assert candidate(s = \"abba\") == True\n assert candidate(s = \"noon\") == True\n assert candidate(s = \"deeee\") == True\n assert candidate(s = \"abc\") == True\n assert candidate(s = \"abcbdd\") == True\n assert candidate(s = \"abcd\") == False\n assert candidate(s = \"aabbcc\") == True\n assert candidate(s = \"madamimadam\") == True\n assert candidate(s = \"aabaacaab\") == True\n assert candidate(s = \"bcbddxy\") == False\n assert candidate(s = \"aabbccddeeeffgghhii\") == False\n assert candidate(s = \"aabbccddeeefffggghhhiiii\") == False\n assert candidate(s = \"kayakmadamracecar\") == True\n assert candidate(s = \"levelracecar\") == False\n assert candidate(s = \"civicnooncivicnoon\") == False\n assert candidate(s = \"aaaaaabbaaaaa\") == True\n assert candidate(s = \"madamnoonmadamnoonmadam\") == True\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == True\n assert candidate(s = \"rotordetartratedrotor\") == True\n assert candidate(s = \"tattarrattatmadamracecar\") == True\n assert candidate(s = \"abcabcabc\") == False\n assert candidate(s = \"rotorlevelrotor\") == True\n assert candidate(s = \"deifiedcivicdeified\") == True\n assert candidate(s = \"rotorrefer\") == False\n assert candidate(s = \"madamadam\") == True\n assert candidate(s = \"aaaabbbbcccc\") == True\n assert candidate(s = \"levellevellevellevellevellevel\") == True\n assert candidate(s = \"deifieddeifieddeified\") == True\n assert candidate(s = \"xyzzyxabcba\") == False\n assert candidate(s = \"tacocatdeified\") == False\n assert candidate(s = \"leveloneone\") == False\n assert candidate(s = \"aabbccddeeefffggghhhhiiiiijjjjkkkkllllmmmmnnnnoooo\") == False\n assert candidate(s = \"levelmadamrotor\") == True\n assert candidate(s = \"abccbaabccba\") == True\n assert candidate(s = \"abcdmadamracecar\") == False\n assert candidate(s = \"levellevellevellevel\") == True\n assert candidate(s = \"repaperdeified\") == False\n assert candidate(s = \"noonnoonnoonnoon\") == True\n assert candidate(s = \"racecarlevel\") == False\n assert candidate(s = \"revilerleveldeified\") == False\n assert candidate(s = \"aabbaabbaa\") == True\n assert candidate(s = \"deifieddeifieddeifieddeifieddeified\") == True\n assert candidate(s = \"kayakracecarkayak\") == True\n assert candidate(s = \"abbbcbbaabbcbba\") == False\n assert candidate(s = \"levelrotorabcddcba\") == True\n assert candidate(s = \"aabbccddeeeffgghhiiiii\") == False\n assert candidate(s = \"leveldeifiedlevel\") == True\n assert candidate(s = \"noonnoonnoonnoonnoonnoon\") == True\n assert candidate(s = \"abacabaabacabaabacabaabacaba\") == True\n assert candidate(s = \"rotorreferrotorrefer\") == False\n assert candidate(s = \"abccbaabccbaabccba\") == True\n assert candidate(s = \"abacdfgdcabaaa\") == False\n assert candidate(s = \"aabbaccd\") == False\n assert candidate(s = \"aabbccddeeefffggghhhiiiiijjjjkkkkllllmmmmnnnnooooppppqqqrrrssstttuuuuvvvwwwxxxxyyyyzzzz\") == False\n assert candidate(s = \"madammadammadam\") == True\n assert candidate(s = \"racecarracecarracecar\") == True\n assert candidate(s = \"madammadam\") == True\n assert candidate(s = \"aibohphobiamadamaibohphobia\") == True\n assert candidate(s = \"racecarbanana\") == True\n assert candidate(s = \"abaabbab\") == True\n assert candidate(s = \"racecarabacaba\") == False\n assert candidate(s = \"abcdeedcba\") == True\n assert candidate(s = \"aabbccddeeeeddcbaabbccdd\") == False\n assert candidate(s = \"deeeeefeee\") == True\n assert candidate(s = \"rotorleveldeifiedleveldeifiedrotor\") == False\n assert candidate(s = \"aabbccddeeeeedddccbbaa\") == False\n assert candidate(s = \"abccbaabccbaabccbaabccbaabccbaabccbaabccbaabccba\") == True\n assert candidate(s = \"deifiedcivic\") == False\n assert candidate(s = \"abcbaabcbabcba\") == True\n assert candidate(s = \"civicracecar\") == False\n assert candidate(s = \"wasitacaroracatisaw\") == True\n assert candidate(s = \"rotorcentralpalindromerotor\") == False\n assert candidate(s = \"abcdcbaabdcbaabcdcba\") == False\n assert candidate(s = \"aibohphobia\") == True\n assert candidate(s = \"leveldeifiedcivic\") == True\n assert candidate(s = \"referredder\") == False\n assert candidate(s = \"level\") == True\n assert candidate(s = \"aabbccdd\") == False\n assert candidate(s = \"rotorleveltwol\") == False\n assert candidate(s = \"levellevellevel\") == True\n assert candidate(s = \"rotorpusher\") == False\n assert candidate(s = \"abccbaabc\") == False\n assert candidate(s = \"referreferrefer\") == True\n assert candidate(s = \"xyzyzyxyz\") == True\n assert candidate(s = \"madamrotorlevel\") == True\n assert candidate(s = \"madam\") == True\n assert candidate(s = \"mammadmam\") == False\n assert candidate(s = \"ababababababa\") == True\n assert candidate(s = \"racecarlevelmadam\") == True\n assert candidate(s = \"abababab\") == False\n assert candidate(s = \"civiccivicciviccivicciviccivic\") == True\n assert candidate(s = \"wasitacaroracitisawreferredder\") == False\n assert candidate(s = \"xxyyxyyxxyyxyyxxyyxyy\") == True\n assert candidate(s = \"abababa\") == True\n assert candidate(s = \"racecarracecarracecarracecarracecar\") == True\n assert candidate(s = \"referredderreferredderreferredder\") == False\n assert candidate(s = \"levelonevenflow\") == False\n assert candidate(s = \"referreferreferreferreferrefer\") == True\n assert candidate(s = \"deifiedrotor\") == False\n assert candidate(s = \"abcbaababcbcabcba\") == False\n assert candidate(s = \"banana\") == False\n assert candidate(s = \"levelonevenone\") == False\n assert candidate(s = \"rotorrotorrotorrotorrotor\") == True\n assert candidate(s = \"aabbccddeeffgg\") == False\n assert candidate(s = \"detartrated\") == True\n assert candidate(s = \"abbcbba\") == True\n assert candidate(s = \"aabbabba\") == True\n assert candidate(s = \"racecarannakayak\") == True\n assert candidate(s = \"amanaplanacanalpanama\") == True\n assert candidate(s = \"refermadamrefermadam\") == False\n assert candidate(s = \"racecarleveldadlevel\") == False\n assert candidate(s = \"abbaeaeabba\") == True\n assert candidate(s = \"racecarracecar\") == True\n assert candidate(s = \"rotorreferredder\") == True\n assert candidate(s = \"noonnoonnoon\") == True\n assert candidate(s = \"levelrefercivic\") == True\n assert candidate(s = \"deified\") == True\n assert candidate(s = \"abbaabbaabba\") == True\n assert candidate(s = \"levelmadamatadammadam\") == False\n assert candidate(s = \"abcdedcba\") == True\n assert candidate(s = \"rotormadamrotor\") == True\n assert candidate(s = \"rotorrotorrotor\") == True\n assert candidate(s = \"xyxzyxyxzyx\") == False\n assert candidate(s = \"rotorresistor\") == False\n assert candidate(s = \"xylophonelevel\") == False\n assert candidate(s = \"deifiedrotordeified\") == True\n assert candidate(s = \"racecarrotorrotorcarcerac\") == False\n assert candidate(s = \"abccbaabcba\") == False\n assert candidate(s = \"noonnoonnoonnoonnoonnoonnoonnoonnoonnoonnoonnoonnoon\") == True\n assert candidate(s = \"abcddcba\") == True\n assert candidate(s = \"civic\") == True\n assert candidate(s = \"rotor\") == True\n assert candidate(s = \"civicnoon\") == False\n assert candidate(s = \"madamatadammadam\") == False\n assert candidate(s = \"repaperrepaperrepaper\") == True\n assert candidate(s = \"rotorracecarracecar\") == True\n assert candidate(s = \"civicciviccivic\") == True\n assert candidate(s = \"rotorabanana\") == False\n assert candidate(s = \"aabbccddeeefff\") == False\n assert candidate(s = \"referdeifiedrefer\") == True\n assert candidate(s = \"rotorotator\") == True\n assert candidate(s = \"aabbccddeeffgghh\") == False\n assert candidate(s = \"leveltwol\") == False\n assert candidate(s = \"rotorresistorresistor\") == False\n assert candidate(s = \"levelracecarlevel\") == True\n assert candidate(s = \"rotordetartratedleveldeifiedrotor\") == False\n assert candidate(s = \"madammadammadammadammadam\") == True\n assert candidate(s = \"deifiedrotorlevel\") == True\n assert candidate(s = \"refercivicrefer\") == True\n assert candidate(s = \"abccbaabccbaabccbaabccbaabccba\") == True\n assert candidate(s = \"leveldeified\") == False\n assert candidate(s = \"rotorlevelmadam\") == True\n assert candidate(s = \"neveroddoreven\") == True\n assert candidate(s = \"redividerleveldeified\") == True\n assert candidate(s = \"refer\") == True\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().checkPartitioning", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def checkPartitioning(self, s: str) -> bool:", "container": "Solution", "callable": "checkPartitioning", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1748, "task_id": "sum-of-unique-elements", "difficulty": "Easy", "problem_description": "You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array.\nReturn the sum of all the unique elements of nums.\n \nExample 1:\n\nInput: nums = [1,2,3,2]\nOutput: 4\nExplanation: The unique elements are [1,3], and the sum is 4.\n\nExample 2:\n\nInput: nums = [1,1,1,1,1]\nOutput: 0\nExplanation: There are no unique elements, and the sum is 0.\n\nExample 3:\n\nInput: nums = [1,2,3,4,5]\nOutput: 15\nExplanation: The unique elements are [1,2,3,4,5], and the sum is 15.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == 54\n assert candidate(nums = [10, 20, 20, 10, 30]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 100, 99, 98, 97, 96, 95]) == 485\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 955\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 8, 8, 8]) == 0\n assert candidate(nums = [1, 2]) == 3\n assert candidate(nums = [1, 2, 3, 2]) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6]) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == 1\n assert candidate(nums = [7]) == 7\n assert candidate(nums = [5]) == 5\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 100]) == 4895\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 594\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 155\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 650\n assert candidate(nums = [50, 50, 50, 50, 50, 51, 52, 52, 53, 53, 53, 54, 55, 55, 55, 55]) == 105\n assert candidate(nums = [10, 20, 20, 30, 30, 40, 50, 60, 60, 70, 80, 80, 90, 100]) == 360\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5050\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 5050\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10]) == 37\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 0\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 40\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9, 10, 10, 11]) == 42\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == 400\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75]) == 2175\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10]) == 40\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 52, 53, 54, 55]) == 265\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 6, 7, 6, 5, 8, 9, 10, 9, 8, 11, 12, 13, 12, 11, 14, 15, 16, 15, 14, 17, 18, 19, 18, 17, 20, 21, 22, 21, 20, 23, 24, 25, 24, 23]) == 119\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 955\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 195\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == 0\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 13]) == 0\n assert candidate(nums = [50, 50, 50, 51, 52, 53, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70]) == 1157\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 650\n assert candidate(nums = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30]) == 490\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 465\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 1050\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 0\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90]) == 855\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15, 15, 14, 13, 12, 11]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [50, 50, 50, 50, 50, 51, 52, 53, 54, 55]) == 265\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 195\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 6, 7]) == 22\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 400\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 7, 8, 8, 9, 10, 11, 12, 12, 13]) == 56\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 14, 15, 15, 16, 16, 17, 18, 18, 19, 20, 20]) == 85\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5050\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 100, 99]) == 756\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 200\n assert candidate(nums = [10, 10, 10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 1\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20]) == 100\n assert candidate(nums = [10, 20, 10, 20, 30, 40, 30, 40, 50, 60, 50, 60, 70, 80, 70, 80, 90, 100, 90, 100]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 40\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 60, 70]) == 130\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80]) == 2015\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 0\n assert candidate(nums = [50, 50, 50, 50, 50, 49, 48, 47, 46, 45]) == 235\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumOfUnique", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def sumOfUnique(self, nums: list[int]) -> int:", "container": "Solution", "callable": "sumOfUnique", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1749, "task_id": "maximum-absolute-sum-of-any-subarray", "difficulty": "Medium", "problem_description": "You are given an integer array nums. The absolute sum of a subarray [numsl, numsl+1, ..., numsr-1, numsr] is abs(numsl + numsl+1 + ... + numsr-1 + numsr).\nReturn the maximum absolute sum of any (possibly empty) subarray of nums.\nNote that abs(x) is defined as follows:\n\nIf x is a negative integer, then abs(x) = -x.\nIf x is a non-negative integer, then abs(x) = x.\n\n \nExample 1:\n\nInput: nums = [1,-3,2,3,-4]\nOutput: 5\nExplanation: The subarray [2,3] has absolute sum = abs(2+3) = abs(5) = 5.\n\nExample 2:\n\nInput: nums = [2,-5,1,-4,3,-2]\nOutput: 8\nExplanation: The subarray [-5,1,-4] has absolute sum = abs(-5+1-4) = abs(-8) = 8.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n-104 <= nums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [-10000, 10000, -10000, 10000]) == 10000\n assert candidate(nums = [1, -3, 2, 3, -4]) == 5\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [2, -5, 1, -4, 3, -2]) == 8\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000]) == 10000\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 15\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [-1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [-10000, 10000, -10000, 10000, -10000]) == 10000\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 6, 7, 8, 9, 10, -25, 11, 12, 13, 14, 15]) == 80\n assert candidate(nums = [10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 100\n assert candidate(nums = [5, 1, -2, 4, -1, -3, 6, -2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [-100, 101, -102, 103, -104, 105, -106, 107]) == 107\n assert candidate(nums = [100, -50, 25, -10, 5, -2, 1]) == 100\n assert candidate(nums = [-1, -2, -3, -4, -5, 5, 4, 3, 2, 1, -1, -2, -3, -4, -5, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums = [5, -1, 3, -2, 4, -3, 6, -4, 7, -5]) == 15\n assert candidate(nums = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1]) == 1000\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000]) == 1000\n assert candidate(nums = [1, 2, 3, -6, 1, 2, 3, -6, 1, 2, 3, -6]) == 6\n assert candidate(nums = [5000, 4000, 3000, 2000, 1000, -5000, -4000, -3000, -2000, -1000]) == 15000\n assert candidate(nums = [10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, -10000]) == 10000\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 55\n assert candidate(nums = [43, 44, -87, 45, 46, 47, -135, 48, 49, 50, 51, -195, 52, 53, 54, 55, 56, -260, 57, 58]) == 276\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500]) == 500\n assert candidate(nums = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 15\n assert candidate(nums = [10, 20, 30, -60, 40, 50, -100, 60, 70, 80, -230, 90, 100, 110, -340, 120]) == 340\n assert candidate(nums = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [5000, -1200, 3000, -1500, 2000, -1000, 4000]) == 10300\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 20\n assert candidate(nums = [10000, -9999, 10000, -9999, 10000, -9999, 10000, -9999]) == 10003\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 20\n assert candidate(nums = [5, -1, 4, -2, 3, -3, 2, -2, 1, -1, 0, 1, -1, 2, -2, 3, -3, 4, -4, 5]) == 11\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [-5, 10, -15, 20, -25, 30, -35, 40]) == 40\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [-5, 4, -3, 7, -8, 2, -6, 1, 9, -4]) == 12\n assert candidate(nums = [26, -27, 28, -29, 30, -31, 32, -33, 34, -35, 36, -37, 38, -39, 40, -41, 42, -43, 44, -45, 46, -47, 48, -49, 50]) == 50\n assert candidate(nums = [10, -3, 20, -40, 50, -60, 70, -80, 90]) == 90\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 50\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16]) == 16\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120, -130, 140, -150, 160, -170, 180, -190, 200]) == 200\n assert candidate(nums = [1, -10, 100, -1000, 10000, -100000, 1000000, -10000000, 100000000, -1000000000]) == 1000000000\n assert candidate(nums = [23, -24, 25, -26, 27, -28, 29, -30, 31, -32, 33, -34, 35, -36, 37, -38, 39, -40, 41, -42]) == 42\n assert candidate(nums = [1, -100, 100, -50, 50, -25, 25, -12, 12, -6, 6]) == 100\n assert candidate(nums = [2, 3, -5, 4, 2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12]) == 13\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 100\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400]) == 400\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 15\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 5\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7]) == 7\n assert candidate(nums = [5000, -2000, 1500, -1000, 800, -700, 600, -500, 400, -300]) == 5000\n assert candidate(nums = [-10000, -10000, 20000, -10000, -10000, 20000, -10000, -10000, 20000, -10000, -10000, 20000]) == 20000\n assert candidate(nums = [-3000, 4500, -5000, 6000, -7000, 8000, -9000]) == 9000\n assert candidate(nums = [-100, 200, -300, 400, -500, 600, -700, 800, -900, 1000]) == 1000\n assert candidate(nums = [500, -500, 500, -500, 500, -500, 500, -500, 500, -500]) == 500\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13]) == 13\n assert candidate(nums = [0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 20\n assert candidate(nums = [1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 10\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 10\n assert candidate(nums = [3, 2, 1, 0, -1, -2, -3, 0, 3, 2, 1, 0, -1, -2, -3]) == 6\n assert candidate(nums = [9999, -9998, 9997, -9996, 9995, -9994, 9993, -9992, 9991, -9990]) == 9999\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [10000, 9000, 8000, -7000, -6000, -5000, 4000, 3000, 2000, -1000]) == 27000\n assert candidate(nums = [10000, 10000, -20000, 10000, 10000, -20000, 10000, 10000, -20000, 10000, 10000, -20000]) == 20000\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 10\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 5\n assert candidate(nums = [5, -1, 3, -2, 7, -8, 2, -6, 4]) == 12\n assert candidate(nums = [100, 200, 300, -600, 400, 500, -1400, 600, 700, 800, 900, 1000]) == 4000\n assert candidate(nums = [-10, -20, -30, 60, -40, -50, 100, -60, -70, -80, 230, -90, -100, -110, 340, -120]) == 340\n assert candidate(nums = [-100, -200, -300, -400, -500, 1500, -600, -700, -800, -900, -1000]) == 4000\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, 100, 200, 300, 400, 500]) == 5500\n assert candidate(nums = [5, -1, 4, -2, 3, -3, 2, -4, 1, -5, 0, 6, -6, 7, -7, 8, -8, 9, -9, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 100, -200, 300, -400, 500]) == 1200\n assert candidate(nums = [9000, 9000, -18000, 9000, 9000, -18000, 9000, 9000]) == 18000\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [10000, -9000, 8000, -7000, 6000, -5000, 4000, -3000, 2000, -1000]) == 10000\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 10\n assert candidate(nums = [-5000, 6000, -7000, 8000, -9000, 10000, -11000, 12000, -13000, 14000]) == 14000\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 10\n assert candidate(nums = [-5000, 5000, 0, -5000, 5000, 0, -5000, 5000, 0]) == 5000\n assert candidate(nums = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 15\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000, -10000]) == 10000\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, 20, -21, 22, -23, 24, -25]) == 41\n assert candidate(nums = [5000, -2000, 1000, -500, 250, -125, 62, -31, 15, -7, 3, -1]) == 5000\n assert candidate(nums = [10000, 10000, 10000, -10000, -10000, -10000, 10000]) == 30000\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 6, 7, 8, 9, 10]) == 40\n assert candidate(nums = [1000, -2000, 3000, -4000, 5000]) == 5000\n assert candidate(nums = [100, 200, 300, 400, 500, -1500, 600, 700, 800, 900, 1000]) == 4000\n assert candidate(nums = [-9999, 9998, -9997, 9996, -9995, 9994]) == 9999\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 5\n assert candidate(nums = [-20, 19, -18, 17, -16, 15, -14, 13, -12, 11, -10, 9, -8, 7, -6, 5, -4, 3, -2, 1]) == 20\n assert candidate(nums = [100, -1, 200, -2, 300, -3, 400, -4, 500, -5]) == 1490\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110]) == 110\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 15\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, 20, -21, 22]) == 40\n assert candidate(nums = [10000, -9999, 9998, -9997, 9996, -9995, 9994, -9993, 9992, -9991]) == 10000\n assert candidate(nums = [5, -3, 8, -1, 4, -7, 9, -2, 6, -10]) == 19\n assert candidate(nums = [10000, -9999, 9998, -9997, 9996, -9995, 9994]) == 10000\n assert candidate(nums = [5, -3, 8, -6, 2, -4, 7, -9, 1, -1]) == 10\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxAbsoluteSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxAbsoluteSum(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maxAbsoluteSum", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1750, "task_id": "minimum-length-of-string-after-deleting-similar-ends", "difficulty": "Medium", "problem_description": "Given a string s consisting only of characters 'a', 'b', and 'c'. You are asked to apply the following algorithm on the string any number of times:\n\nPick a non-empty prefix from the string s where all the characters in the prefix are equal.\nPick a non-empty suffix from the string s where all the characters in this suffix are equal.\nThe prefix and the suffix should not intersect at any index.\nThe characters from the prefix and suffix must be the same.\nDelete both the prefix and the suffix.\n\nReturn the minimum length of s after performing the above operation any number of times (possibly zero times).\n \nExample 1:\n\nInput: s = \"ca\"\nOutput: 2\nExplanation: You can't remove any characters, so the string stays as is.\n\nExample 2:\n\nInput: s = \"cabaabac\"\nOutput: 0\nExplanation: An optimal sequence of operations is:\n- Take prefix = \"c\" and suffix = \"c\" and remove them, s = \"abaaba\".\n- Take prefix = \"a\" and suffix = \"a\" and remove them, s = \"baab\".\n- Take prefix = \"b\" and suffix = \"b\" and remove them, s = \"aa\".\n- Take prefix = \"a\" and suffix = \"a\" and remove them, s = \"\".\nExample 3:\n\nInput: s = \"aabccabba\"\nOutput: 3\nExplanation: An optimal sequence of operations is:\n- Take prefix = \"aa\" and suffix = \"a\" and remove them, s = \"bccabb\".\n- Take prefix = \"b\" and suffix = \"bb\" and remove them, s = \"cca\".\n\n \nConstraints:\n\n1 <= s.length <= 105\ns only consists of characters 'a', 'b', and 'c'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcba\") == 1\n assert candidate(s = \"ca\") == 2\n assert candidate(s = \"abac\") == 4\n assert candidate(s = \"aabccabba\") == 3\n assert candidate(s = \"aabbaa\") == 0\n assert candidate(s = \"aaaaa\") == 0\n assert candidate(s = \"aababbaa\") == 1\n assert candidate(s = \"cabaabac\") == 0\n assert candidate(s = \"aabbccbaa\") == 0\n assert candidate(s = \"aaa\") == 0\n assert candidate(s = \"abcabc\") == 6\n assert candidate(s = \"aabbbcccbbaa\") == 0\n assert candidate(s = \"aababa\") == 1\n assert candidate(s = \"aabcccbaa\") == 0\n assert candidate(s = \"abc\") == 3\n assert candidate(s = \"abbaccaa\") == 5\n assert candidate(s = \"aaaa\") == 0\n assert candidate(s = \"abccba\") == 0\n assert candidate(s = \"aaabaaa\") == 1\n assert candidate(s = \"aabbcc\") == 6\n assert candidate(s = \"abca\") == 2\n assert candidate(s = \"cccccc\") == 0\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababab\") == 76\n assert candidate(s = \"aabacccbaa\") == 4\n assert candidate(s = \"abacabacabacabacabacabacabacabacabacabacab\") == 42\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\") == 36\n assert candidate(s = \"aabbbcccbbbbaa\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\") == 66\n assert candidate(s = \"ccabbbcccabbbcccabbbcc\") == 18\n assert candidate(s = \"abccbaabccbaabccbaabccba\") == 0\n assert candidate(s = \"acabacabacabacabacabacabacabacab\") == 32\n assert candidate(s = \"cccaaaaabbb\") == 11\n assert candidate(s = \"aaaabbbbccccaaaabbbbcccc\") == 24\n assert candidate(s = \"aaabbbbbbbbccccccaaa\") == 14\n assert candidate(s = \"cbabcbabcb\") == 10\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\") == 76\n assert candidate(s = \"bbbbbbaaaaa\") == 11\n assert candidate(s = \"abcabcabc\") == 9\n assert candidate(s = \"aaaabaaaabaaa\") == 0\n assert candidate(s = \"abcabcabcabc\") == 12\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbccccc\") == 24\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiiiiiiiiiiiiii\") == 56\n assert candidate(s = \"abccbaabcbaabccba\") == 1\n assert candidate(s = \"abacabacabaacaba\") == 1\n assert candidate(s = \"aaabaaaabbaaaabaa\") == 0\n assert candidate(s = \"abacaabacaabaca\") == 13\n assert candidate(s = \"aabbbccccdddeeeccccbbbaaa\") == 6\n assert candidate(s = \"abacbacbacbacbacba\") == 14\n assert candidate(s = \"aaaabaaaabaaaabaaa\") == 1\n assert candidate(s = \"aabccccbbaa\") == 0\n assert candidate(s = \"aaaabbbbcccc\") == 12\n assert candidate(s = \"aabccbaaab\") == 10\n assert candidate(s = \"aaabbbcccbbbbaaa\") == 0\n assert candidate(s = \"aabbccddeeffeeddccbaabbaaabcabcabc\") == 34\n assert candidate(s = \"aabbbcccbbaaaabbbcccbbaaa\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiii\") == 41\n assert candidate(s = \"abbbbaaaaabbbaaaaabbbb\") == 22\n assert candidate(s = \"cccaaaaabbbcccbaaabccbaaabccbaaabccbaa\") == 38\n assert candidate(s = \"bbbbaaaaabbbb\") == 0\n assert candidate(s = \"abccbaabccba\") == 0\n assert candidate(s = \"aaabaaaabbbaaa\") == 0\n assert candidate(s = \"aaaabbbbbbccccccdddddd\") == 22\n assert candidate(s = \"abacabacaba\") == 1\n assert candidate(s = \"aaabaaaabaaaabaaa\") == 1\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\") == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\") == 36\n assert candidate(s = \"abacaba\") == 1\n assert candidate(s = \"cccbbbaaa\") == 9\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbccccccccccdddddddddd\") == 41\n assert candidate(s = \"abcbaabcbacba\") == 7\n assert candidate(s = \"aaabaaaabba\") == 0\n assert candidate(s = \"aabbaabbaabbaabb\") == 16\n assert candidate(s = \"aaaabbbbccccddddccccdddd\") == 24\n assert candidate(s = \"abcabcabcabcabcabcabc\") == 21\n assert candidate(s = \"ccabbbccbbbbcabcabbbccabc\") == 22\n assert candidate(s = \"cccccccccccccccccccccc\") == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 99\n assert candidate(s = \"acaacacaacac\") == 12\n assert candidate(s = \"aaabbbcccbbbaaa\") == 0\n assert candidate(s = \"abcbaabcbaabcbaabcbaabcbaabcbaabcba\") == 1\n assert candidate(s = \"abccbaabccbaabccba\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\") == 71\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 30\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabb\") == 32\n assert candidate(s = \"aaaaabbbbbcccccaaaa\") == 10\n assert candidate(s = \"aabbbccccdddddeeecccbbbbaaa\") == 8\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 48\n assert candidate(s = \"ababbababbababb\") == 15\n assert candidate(s = \"aabbbcccdddeeeeeeccccbbbaa\") == 9\n assert candidate(s = \"aabbccddeedccbbaa\") == 0\n assert candidate(s = \"aabbbcccbaa\") == 0\n assert candidate(s = \"acaacaaca\") == 1\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 93\n assert candidate(s = \"aabbaaabbbaaabbbaaabbaa\") == 0\n assert candidate(s = \"accbabcbaccbacc\") == 15\n assert candidate(s = \"abcabcabcabcabcabc\") == 18\n assert candidate(s = \"abcbaabcba\") == 0\n assert candidate(s = \"aabbccbbccbbccaa\") == 12\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(s = \"aaaabbbcccbbbaaa\") == 0\n assert candidate(s = \"cbbccbbcc\") == 0\n assert candidate(s = \"abacbacbacbacbacbacbac\") == 22\n assert candidate(s = \"aaaaabccccbaaaa\") == 0\n assert candidate(s = \"aaaabbbbccccddddeee\") == 19\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiii\") == 45\n assert candidate(s = \"ccccaaaabbbbaaaa\") == 16\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeeeeeefffffffff\") == 65\n assert candidate(s = \"aaabbbcccbbbbaaabbbcccbbbbaaa\") == 0\n assert candidate(s = \"ababababababababababab\") == 22\n assert candidate(s = \"aaaabbbbccccccaaaabbbb\") == 22\n assert candidate(s = \"aabbaaabbbaaabbbaaabbaaa\") == 0\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeeeeeefffffffffgggggggggghhhhhhhhhhhiiiiiiiiiii\") == 97\n assert candidate(s = \"aabbaabbccddeeffeeddccbaabbaa\") == 0\n assert candidate(s = \"abababababababababab\") == 20\n assert candidate(s = \"aaaabccccbbbbaaaa\") == 0\n assert candidate(s = \"aabbbbccccbbbbaaa\") == 0\n assert candidate(s = \"aabbccddeedccbbaaa\") == 0\n assert candidate(s = \"abacabadabacaba\") == 1\n assert candidate(s = \"aabaaabaaa\") == 0\n assert candidate(s = \"aabbccddeeeedddccbaabb\") == 22\n assert candidate(s = \"aabccccbaa\") == 0\n assert candidate(s = \"acccba\") == 4\n assert candidate(s = \"abacbacbacbacbaba\") == 11\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 42\n assert candidate(s = \"aaaabbbaaabbbbaaaabbbaaaa\") == 0\n assert candidate(s = \"abacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabac\") == 96\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 90\n assert candidate(s = \"aaabbbcccbbaaa\") == 0\n assert candidate(s = \"aabbccddeeffgg\") == 14\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\") == 82\n assert candidate(s = \"ccbaaaabbbcccbaaaabbbccc\") == 0\n assert candidate(s = \"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\") == 0\n assert candidate(s = \"aabbaabbccddccbbbaa\") == 10\n assert candidate(s = \"cccccccccccccccccc\") == 0\n assert candidate(s = \"aaaabbaaabbbaaaa\") == 0\n assert candidate(s = \"aabbaabbaabbaabbaabb\") == 20\n assert candidate(s = \"aaaaabbbbbccccdddddccccbbbaaaaa\") == 0\n assert candidate(s = \"ababaababa\") == 0\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(s = \"abcbaabcbaabcba\") == 1\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 0\n assert candidate(s = \"aabbaaccbbbaa\") == 4\n assert candidate(s = \"ccccccc\") == 0\n assert candidate(s = \"aaabbbcccdddeeecccccbbbaaa\") == 6\n assert candidate(s = \"aabbccddeeecccbbbaa\") == 5\n assert candidate(s = \"abccbaabcba\") == 0\n assert candidate(s = \"ababababab\") == 10\n assert candidate(s = \"aaaabbbbccccddddccccddddeeeeffff\") == 32\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiiiiiiiiiiiiiiiiiii\") == 61\n assert candidate(s = \"ccccaaaabbbbcccc\") == 8\n assert candidate(s = \"aabbccddeedccbbaaabbccddeedccbbaa\") == 0\n assert candidate(s = \"babbacabacababb\") == 1\n assert candidate(s = \"ccccccabbbbbbbcc\") == 8\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 24\n assert candidate(s = \"aabbaabbccbbccbbccaa\") == 16\n assert candidate(s = \"aaabbbcccbaabbbcccbaaabbb\") == 25\n assert candidate(s = \"ababa\") == 1\n assert candidate(s = \"acaabaaaca\") == 1\n assert candidate(s = \"aabbccbbccbbccbbccaa\") == 16\n assert candidate(s = \"ccccbaaaabbbcccbaaaabbbccc\") == 0\n assert candidate(s = \"aaaabbbcccdddeeecccbbbbaaaa\") == 6\n assert candidate(s = \"aaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaab\") == 72\n assert candidate(s = \"aaaaabbbbbccccccccbbbbbbaaaaa\") == 0\n assert candidate(s = \"ccabbaacc\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiiiiiiiii\") == 51\n assert candidate(s = \"aabbccddeedccbbaaacccccccccccbbbbaaa\") == 12\n assert candidate(s = \"acbacbacbacbacba\") == 14\n assert candidate(s = \"abcabcabcabcabc\") == 15\n assert candidate(s = \"ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\") == 0\n assert candidate(s = \"caabaccaabaaccaaa\") == 17\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumLength(self, s: str) -> int:", "container": "Solution", "callable": "minimumLength", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1751, "task_id": "maximum-number-of-events-that-can-be-attended-ii", "difficulty": "Hard", "problem_description": "You are given an array of events where events[i] = [startDayi, endDayi, valuei]. The ith event starts at startDayi and ends at endDayi, and if you attend this event, you will receive a value of valuei. You are also given an integer k which represents the maximum number of events you can attend.\nYou can only attend one event at a time. If you choose to attend an event, you must attend the entire event. Note that the end day is inclusive: that is, you cannot attend two events where one of them starts and the other ends on the same day.\nReturn the maximum sum of values that you can receive by attending events.\n \nExample 1:\n\n\nInput: events = [[1,2,4],[3,4,3],[2,3,1]], k = 2\nOutput: 7\nExplanation: Choose the green events, 0 and 1 (0-indexed) for a total value of 4 + 3 = 7.\nExample 2:\n\n\nInput: events = [[1,2,4],[3,4,3],[2,3,10]], k = 2\nOutput: 10\nExplanation: Choose event 2 for a total value of 10.\nNotice that you cannot attend any other event as they overlap, and that you do not have to attend k events.\nExample 3:\n\n\nInput: events = [[1,1,1],[2,2,2],[3,3,3],[4,4,4]], k = 3\nOutput: 9\nExplanation: Although the events do not overlap, you can only attend 3 events. Pick the highest valued three.\n \nConstraints:\n\n1 <= k <= events.length\n1 <= k * events.length <= 106\n1 <= startDayi <= endDayi <= 109\n1 <= valuei <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(events = [[1, 5, 4], [11, 15, 1], [8, 10, 2], [2, 11, 6]],k = 3) == 7\n assert candidate(events = [[2, 8, 6], [4, 9, 10], [6, 8, 3]],k = 2) == 10\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [6, 10, 5], [2, 9, 4]],k = 2) == 11\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500]],k = 3) == 900\n assert candidate(events = [[1, 2, 7], [2, 3, 10], [3, 4, 3], [1, 5, 5], [6, 7, 1]],k = 4) == 11\n assert candidate(events = [[1, 2, 4], [3, 5, 1], [5, 6, 2], [6, 7, 3]],k = 3) == 8\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [6, 10, 5], [2, 9, 8]],k = 2) == 11\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [6, 10, 5], [2, 7, 8], [9, 10, 4]],k = 3) == 12\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [6, 6, 5], [2, 7, 9]],k = 3) == 11\n assert candidate(events = [[2, 8, 6], [2, 9, 9], [1, 6, 1], [3, 5, 5], [1, 5, 3]],k = 2) == 9\n assert candidate(events = [[1, 2, 100], [2, 3, 100], [3, 4, 100]],k = 1) == 100\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [1, 5, 5], [2, 3, 5], [2, 3, 5]],k = 1) == 6\n assert candidate(events = [[1, 2, 4], [3, 4, 3], [2, 3, 1]],k = 2) == 7\n assert candidate(events = [[1, 2, 3], [4, 5, 4], [1, 5, 5]],k = 2) == 7\n assert candidate(events = [[1, 2, 4], [3, 4, 3], [2, 3, 10]],k = 2) == 10\n assert candidate(events = [[1, 3, 5], [2, 4, 6], [3, 5, 7], [4, 6, 8]],k = 2) == 13\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [1, 5, 5]],k = 2) == 6\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]],k = 3) == 9\n assert candidate(events = [[1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10]],k = 5) == 50\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9], [2, 11, 10], [3, 12, 11], [4, 13, 12], [5, 14, 13], [6, 15, 14]],k = 5) == 18\n assert candidate(events = [[1, 3, 10], [2, 4, 20], [3, 5, 30], [4, 6, 40], [5, 7, 50], [6, 8, 60], [7, 9, 70], [8, 10, 80], [9, 11, 90], [10, 12, 100], [11, 13, 110], [12, 14, 120]],k = 4) == 300\n assert candidate(events = [[1, 1000000000, 1], [1, 1000000000, 2], [1, 1000000000, 3], [1, 1000000000, 4], [1, 1000000000, 5]],k = 5) == 5\n assert candidate(events = [[1, 2, 10], [10, 11, 10], [20, 21, 10], [30, 31, 10], [40, 41, 10], [50, 51, 10], [60, 61, 10], [70, 71, 10], [80, 81, 10], [90, 91, 10]],k = 5) == 50\n assert candidate(events = [[1, 1000000000, 1000000], [2, 999999999, 999999], [3, 888888888, 888888], [4, 777777777, 777777], [5, 666666666, 666666]],k = 3) == 1000000\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [15, 25, 150], [26, 35, 250]],k = 4) == 600\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900], [10, 11, 1000], [11, 12, 1100], [12, 13, 1200], [13, 14, 1300]],k = 7) == 4900\n assert candidate(events = [[1, 10, 10], [2, 9, 8], [3, 8, 6], [4, 7, 4], [5, 6, 2]],k = 5) == 10\n assert candidate(events = [[1, 1, 1000000], [2, 2, 999999], [3, 3, 999998], [4, 4, 999997], [5, 5, 999996], [6, 6, 999995], [7, 7, 999994], [8, 8, 999993], [9, 9, 999992], [10, 10, 999991]],k = 5) == 4999990\n assert candidate(events = [[1, 2, 10], [3, 4, 20], [2, 3, 15], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55]],k = 4) == 160\n assert candidate(events = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9], [1, 10, 10]],k = 1) == 10\n assert candidate(events = [[1, 1, 1000], [2, 2, 2000], [3, 3, 3000], [4, 4, 4000], [5, 5, 5000], [6, 6, 6000], [7, 7, 7000], [8, 8, 8000], [9, 9, 9000]],k = 5) == 35000\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120], [13, 14, 130], [14, 15, 140]],k = 7) == 560\n assert candidate(events = [[1, 10, 5], [2, 9, 6], [3, 8, 7], [4, 7, 8], [5, 6, 9], [11, 20, 10], [12, 19, 11], [13, 18, 12], [14, 17, 13], [15, 16, 14]],k = 4) == 23\n assert candidate(events = [[1, 3, 1000], [2, 5, 1000], [3, 7, 1000], [4, 8, 1000], [5, 10, 1000], [6, 11, 1000], [7, 12, 1000], [8, 13, 1000], [9, 14, 1000], [10, 15, 1000]],k = 5) == 3000\n assert candidate(events = [[1, 2, 1000000], [2, 3, 999999], [3, 4, 999998], [4, 5, 999997], [5, 6, 999996], [6, 7, 999995], [7, 8, 999994], [8, 9, 999993], [9, 10, 999992]],k = 5) == 4999980\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600]],k = 3) == 1500\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110]],k = 6) == 360\n assert candidate(events = [[1, 10, 10], [2, 9, 20], [3, 8, 30], [4, 7, 40], [5, 6, 50], [1, 10, 60], [2, 9, 70], [3, 8, 80], [4, 7, 90], [5, 6, 100]],k = 5) == 100\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100]],k = 5) == 300\n assert candidate(events = [[1, 1000000000, 1000000], [2, 999999999, 900000], [3, 999999998, 800000], [4, 999999997, 700000], [5, 999999996, 600000], [6, 999999995, 500000], [7, 999999994, 400000], [8, 999999993, 300000], [9, 999999992, 200000], [10, 999999991, 100000]],k = 5) == 1000000\n assert candidate(events = [[1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10]],k = 5) == 10\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9]],k = 2) == 9\n assert candidate(events = [[1, 2, 5], [3, 5, 10], [5, 7, 15], [7, 9, 20], [9, 11, 25], [11, 13, 30]],k = 4) == 65\n assert candidate(events = [[1, 3, 50], [2, 4, 60], [3, 5, 70], [4, 6, 80], [5, 7, 90], [6, 8, 100], [7, 9, 110], [8, 10, 120], [9, 11, 130], [10, 12, 140]],k = 3) == 330\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7], [15, 16, 8], [17, 18, 9], [19, 20, 10], [21, 22, 11], [23, 24, 12]],k = 6) == 57\n assert candidate(events = [[1, 10, 5], [2, 9, 10], [3, 8, 15], [4, 7, 20], [5, 6, 25], [6, 5, 30], [7, 4, 35], [8, 3, 40], [9, 2, 45], [10, 1, 50]],k = 5) == 200\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13]],k = 13) == 91\n assert candidate(events = [[1, 10, 1], [2, 10, 2], [3, 10, 3], [4, 10, 4], [5, 10, 5], [6, 10, 6], [7, 10, 7], [8, 10, 8], [9, 10, 9], [1, 20, 10], [11, 20, 11], [21, 30, 12], [31, 40, 13], [41, 50, 14]],k = 5) == 59\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900]],k = 4) == 2400\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]],k = 5) == 40\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900], [10, 11, 1000], [11, 12, 1100], [12, 13, 1200], [13, 14, 1300]],k = 6) == 4800\n assert candidate(events = [[1, 10, 100], [2, 5, 200], [3, 8, 300], [6, 12, 400], [9, 15, 500]],k = 3) == 800\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]],k = 10) == 30\n assert candidate(events = [[1, 10, 1], [11, 20, 2], [21, 30, 3], [31, 40, 4], [41, 50, 5], [51, 60, 6], [61, 70, 7], [71, 80, 8], [81, 90, 9]],k = 9) == 45\n assert candidate(events = [[1, 1000000000, 1000000], [2, 999999999, 2000000], [3, 999999998, 3000000], [4, 999999997, 4000000]],k = 2) == 4000000\n assert candidate(events = [[1, 2, 4], [1, 2, 3], [1, 2, 2], [1, 2, 1], [3, 4, 5], [3, 4, 6], [5, 6, 7], [5, 6, 8]],k = 3) == 18\n assert candidate(events = [[1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10]],k = 9) == 50\n assert candidate(events = [[1, 1000000000, 1], [2, 1000000000, 2], [3, 1000000000, 3], [4, 1000000000, 4], [5, 1000000000, 5]],k = 3) == 5\n assert candidate(events = [[1, 2, 1000000], [10, 11, 999999], [20, 21, 999998], [30, 31, 999997], [40, 41, 999996], [50, 51, 999995], [60, 61, 999994], [70, 71, 999993], [80, 81, 999992], [90, 91, 999991]],k = 10) == 9999955\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9], [1, 11, 10], [1, 12, 11], [1, 13, 12], [1, 14, 13], [1, 15, 14]],k = 7) == 14\n assert candidate(events = [[1, 5, 1], [1, 5, 2], [1, 5, 3], [1, 5, 4], [1, 5, 5], [1, 5, 6], [1, 5, 7], [1, 5, 8], [1, 5, 9], [1, 5, 10], [1, 5, 11], [1, 5, 12], [1, 5, 13], [1, 5, 14], [1, 5, 15]],k = 5) == 15\n assert candidate(events = [[1, 10, 10], [11, 20, 20], [21, 30, 30], [31, 40, 40], [41, 50, 50], [51, 60, 60], [61, 70, 70], [71, 80, 80], [81, 90, 90], [91, 100, 100]],k = 10) == 550\n assert candidate(events = [[1, 3, 100], [2, 5, 200], [3, 6, 300], [4, 7, 400], [5, 8, 500], [6, 9, 600]],k = 3) == 800\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7], [15, 16, 8], [17, 18, 9], [19, 20, 10]],k = 5) == 40\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120]],k = 10) == 420\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [2, 3, 6], [2, 4, 7], [2, 5, 8], [2, 6, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [5, 6, 15]],k = 3) == 26\n assert candidate(events = [[1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1]],k = 5) == 1\n assert candidate(events = [[1, 1, 100], [1, 1, 200], [1, 1, 300], [1, 1, 400], [1, 1, 500], [1, 1, 600], [1, 1, 700], [1, 1, 800], [1, 1, 900], [1, 1, 1000]],k = 5) == 1000\n assert candidate(events = [[1, 5, 5], [5, 10, 10], [10, 15, 15], [15, 20, 20], [20, 25, 25], [25, 30, 30], [30, 35, 35]],k = 3) == 75\n assert candidate(events = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [2, 2, 1], [2, 3, 2], [2, 4, 3], [2, 5, 4], [3, 3, 1], [3, 4, 2], [3, 5, 3], [4, 4, 1], [4, 5, 2], [5, 5, 1]],k = 3) == 5\n assert candidate(events = [[5, 10, 15], [5, 7, 10], [7, 12, 20], [9, 15, 18], [10, 17, 12], [13, 20, 30], [14, 20, 25]],k = 3) == 50\n assert candidate(events = [[1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5], [11, 20, 6], [12, 19, 7], [13, 18, 8], [14, 17, 9], [15, 16, 10]],k = 5) == 15\n assert candidate(events = [[1, 3, 100], [2, 5, 200], [3, 6, 300], [4, 7, 400], [5, 8, 500], [6, 9, 600]],k = 4) == 800\n assert candidate(events = [[1, 1000000000, 1000000], [1000000001, 2000000000, 2000000], [2000000001, 3000000000, 3000000]],k = 2) == 5000000\n assert candidate(events = [[1, 1, 100], [2, 2, 200], [3, 3, 300], [4, 4, 400], [5, 5, 500], [6, 6, 600], [7, 7, 700], [8, 8, 800], [9, 9, 900], [10, 10, 1000]],k = 10) == 5500\n assert candidate(events = [[1, 5, 5], [6, 10, 10], [11, 15, 15], [16, 20, 20], [21, 25, 25], [26, 30, 30], [31, 35, 35], [36, 40, 40], [41, 45, 45], [46, 50, 50]],k = 5) == 200\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120]],k = 6) == 420\n assert candidate(events = [[1, 1000000000, 1], [1, 1000000000, 2], [1, 1000000000, 3], [1, 1000000000, 4], [1, 1000000000, 5]],k = 2) == 5\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]],k = 5) == 25\n assert candidate(events = [[1, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 10, 10], [7, 11, 11], [8, 12, 12], [9, 13, 13], [10, 14, 14]],k = 3) == 23\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]],k = 7) == 63\n assert candidate(events = [[1, 1000000000, 1], [1000000000, 1000000000, 1000000]],k = 1) == 1000000\n assert candidate(events = [[1, 2, 1], [1, 2, 2], [1, 2, 3], [2, 3, 4], [2, 3, 5], [2, 3, 6], [3, 4, 7], [3, 4, 8], [3, 4, 9], [4, 5, 10]],k = 3) == 16\n assert candidate(events = [[1, 10, 5], [2, 9, 10], [3, 8, 15], [4, 7, 20], [5, 6, 25], [6, 5, 30]],k = 3) == 30\n assert candidate(events = [[1, 3, 50], [2, 5, 20], [4, 6, 40], [6, 9, 60], [8, 11, 80], [10, 12, 30]],k = 3) == 170\n assert candidate(events = [[1, 2, 1000000], [2, 3, 1000000], [3, 4, 1000000], [4, 5, 1000000], [5, 6, 1000000], [6, 7, 1000000]],k = 3) == 3000000\n assert candidate(events = [[1, 2, 100], [3, 4, 200], [5, 6, 300], [7, 8, 400], [9, 10, 500], [11, 12, 600], [13, 14, 700], [15, 16, 800], [17, 18, 900]],k = 5) == 3500\n assert candidate(events = [[1, 3, 10], [2, 5, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50], [6, 10, 60], [7, 11, 70], [8, 12, 80], [9, 13, 90]],k = 4) == 140\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600], [61, 70, 700], [71, 80, 800], [81, 90, 900], [91, 100, 1000]],k = 5) == 4000\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9], [1, 11, 10]],k = 5) == 10\n assert candidate(events = [[1, 2, 1000], [2, 3, 2000], [3, 4, 3000], [4, 5, 4000], [5, 6, 5000], [6, 7, 6000], [7, 8, 7000], [8, 9, 8000], [9, 10, 9000]],k = 9) == 25000\n assert candidate(events = [[1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5], [6, 5, 6], [7, 4, 7], [8, 3, 8], [9, 2, 9], [10, 1, 10]],k = 5) == 40\n assert candidate(events = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9], [1, 10, 10], [1, 11, 11], [1, 12, 12], [1, 13, 13], [1, 14, 14], [1, 15, 15]],k = 15) == 15\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600], [61, 70, 700], [71, 80, 800], [81, 90, 900], [91, 100, 1000]],k = 3) == 2700\n assert candidate(events = [[1, 20, 100], [2, 15, 80], [3, 10, 60], [4, 5, 40], [5, 6, 20], [6, 7, 10], [7, 8, 5], [8, 9, 3], [9, 10, 2], [10, 11, 1], [11, 12, 2], [12, 13, 3], [13, 14, 5], [14, 15, 10], [15, 16, 20], [16, 17, 40], [17, 18, 60], [18, 19, 80], [19, 20, 100]],k = 10) == 247\n assert candidate(events = [[1, 10, 10], [2, 9, 11], [3, 8, 12], [4, 7, 13], [5, 6, 14], [6, 5, 15], [7, 4, 16], [8, 3, 17], [9, 2, 18], [10, 1, 19]],k = 5) == 85\n assert candidate(events = [[1, 3, 5], [2, 5, 8], [4, 6, 6], [6, 8, 3], [5, 7, 10], [7, 9, 4]],k = 4) == 15\n assert candidate(events = [[1, 2, 100], [3, 5, 150], [6, 8, 200], [9, 11, 250], [12, 14, 300], [15, 17, 350]],k = 4) == 1100\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]],k = 5) == 30\n assert candidate(events = [[1, 100, 1000], [2, 99, 900], [3, 98, 800], [4, 97, 700], [5, 96, 600], [6, 95, 500], [7, 94, 400], [8, 93, 300], [9, 92, 200], [10, 91, 100]],k = 5) == 1000\n assert candidate(events = [[1, 100, 1], [50, 150, 10], [100, 200, 50], [150, 250, 100], [200, 300, 200], [250, 350, 500], [300, 400, 1000], [350, 450, 2000], [400, 500, 5000]],k = 5) == 5550\n assert candidate(events = [[1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5]],k = 4) == 5\n assert candidate(events = [[1, 50, 500], [51, 100, 400], [101, 150, 300], [151, 200, 200], [201, 250, 100]],k = 3) == 1200\n assert candidate(events = [[1, 10, 50], [11, 20, 100], [21, 30, 150], [31, 40, 200], [41, 50, 250]],k = 3) == 600\n assert candidate(events = [[1, 3, 5], [2, 4, 6], [3, 5, 7], [4, 6, 8], [5, 7, 9], [6, 8, 10], [7, 9, 11], [8, 10, 12], [9, 11, 13]],k = 4) == 30\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13], [14, 14, 14]],k = 7) == 77\n assert candidate(events = [[1, 2, 50], [1, 3, 40], [1, 4, 30], [1, 5, 20], [1, 6, 10], [2, 7, 60], [3, 8, 70], [4, 9, 80], [5, 10, 90], [6, 11, 100]],k = 4) == 150\n assert candidate(events = [[1, 2, 10], [1, 2, 20], [1, 2, 30], [1, 2, 40], [1, 2, 50], [1, 2, 60], [1, 2, 70], [1, 2, 80], [1, 2, 90], [1, 2, 100]],k = 3) == 100\n"}, "metadata": {"canonical_parameter_names": ["events", "k"], "leetcode_dataset_entry_point": "Solution().maxValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxValue(self, events: list[list[int]], k: int) -> int:", "container": "Solution", "callable": "maxValue", "parameters": [{"name": "events", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1752, "task_id": "check-if-array-is-sorted-and-rotated", "difficulty": "Easy", "problem_description": "Given an array nums, return true if the array was originally sorted in non-decreasing order, then rotated some number of positions (including zero). Otherwise, return false.\nThere may be duplicates in the original array.\nNote: An array A rotated by x positions results in an array B of the same length such that B[i] == A[(i+x) % A.length] for every valid index i.\n \nExample 1:\n\nInput: nums = [3,4,5,1,2]\nOutput: true\nExplanation: [1,2,3,4,5] is the original sorted array.\nYou can rotate the array by x = 3 positions to begin on the element of value 3: [3,4,5,1,2].\n\nExample 2:\n\nInput: nums = [2,1,3,4]\nOutput: false\nExplanation: There is no sorted array once rotated that can make nums.\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: true\nExplanation: [1,2,3] is the original sorted array.\nYou can rotate the array by x = 0 positions (i.e. no rotation) to make nums.\n\n\n\n \n\n\n \n\n \n \n\n\n\n\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 5, 6, 7, 0, 1, 2]) == True\n assert candidate(nums = [2, 1, 3, 4]) == False\n assert candidate(nums = [1, 3, 2]) == False\n assert candidate(nums = [4, 5, 6, 1, 2, 3]) == True\n assert candidate(nums = [1, 3, 5, 7, 2, 4, 6, 8]) == False\n assert candidate(nums = [2, 2, 1, 1, 1]) == True\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [2, 1, 2]) == True\n assert candidate(nums = [1, 2, 3]) == True\n assert candidate(nums = [1, 1, 1]) == True\n assert candidate(nums = [2, 3, 4, 5, 1]) == True\n assert candidate(nums = [0, 1, 2, 4, 5, 6, 7]) == True\n assert candidate(nums = [5, 1, 2, 3, 4]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [100, 1, 100, 100]) == True\n assert candidate(nums = [3, 4, 5, 1, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 3, 2, 4, 5]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 1, 3]) == False\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == True\n assert candidate(nums = [3, 3, 4, 4, 5, 5, 1, 1, 2, 2]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [1, 3, 4, 5, 6, 7, 8, 9, 10, 2]) == False\n assert candidate(nums = [5, 5, 5, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == True\n assert candidate(nums = [3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == False\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3]) == True\n assert candidate(nums = [7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [2, 3, 4, 5, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 1, 2, 3, 3, 3]) == True\n assert candidate(nums = [6, 7, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [2, 3, 4, 5, 1, 2, 3, 4, 5]) == False\n assert candidate(nums = [1, 2, 1]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 1, 2, 3, 4, 5]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == False\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == True\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2]) == True\n assert candidate(nums = [7, 8, 9, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == True\n assert candidate(nums = [1, 3, 2, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == False\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(nums = [1, 2, 3, 2, 1]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 1, 2]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1]) == True\n assert candidate(nums = [8, 9, 1, 2, 3, 4, 5, 6, 7]) == True\n assert candidate(nums = [30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(nums = [99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 98]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 2]) == False\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1]) == True\n assert candidate(nums = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5]) == False\n assert candidate(nums = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4]) == True\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == True\n assert candidate(nums = [5, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == True\n assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == True\n assert candidate(nums = [9, 10, 11, 12, 13, 5, 6, 7, 8]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == False\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 1, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 1, 2, 3]) == False\n assert candidate(nums = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(nums = [2, 3, 1, 2, 3]) == False\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 2, 3]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == True\n assert candidate(nums = [1, 3, 2, 2, 3, 4, 5]) == False\n assert candidate(nums = [100, 1, 100, 100, 100]) == True\n assert candidate(nums = [5, 6, 7, 8, 1, 2, 3, 4, 5, 6]) == False\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 99]) == True\n assert candidate(nums = [99, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == False\n assert candidate(nums = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1]) == True\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2]) == False\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3]) == False\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 1, 1]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 1, 3, 3, 3]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 1]) == True\n assert candidate(nums = [9, 10, 1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1]) == False\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) == True\n assert candidate(nums = [4, 5, 6, 7, 0, 1, 2, 3]) == True\n assert candidate(nums = [99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == True\n assert candidate(nums = [3, 4, 5, 2, 1]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 3, 3, 3, 3]) == False\n assert candidate(nums = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [8, 9, 9, 9, 1, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [3, 1, 2]) == True\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]) == True\n assert candidate(nums = [2, 2, 2, 2, 1, 2, 2, 2, 2]) == True\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == False\n assert candidate(nums = [3, 4, 5, 1, 1, 2, 2]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1]) == True\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == True\n assert candidate(nums = [6, 7, 8, 9, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [2, 2, 2, 2, 1, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [4, 5, 6, 7, 8, 1, 2, 3]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == False\n assert candidate(nums = [6, 10, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [8, 9, 10, 1, 2, 3, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [100, 1, 100, 100, 100, 100]) == True\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == False\n assert candidate(nums = [5, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().check", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def check(self, nums: list[int]) -> bool:", "container": "Solution", "callable": "check", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1753, "task_id": "maximum-score-from-removing-stones", "difficulty": "Medium", "problem_description": "You are playing a solitaire game with three piles of stones of sizes a​​​​​​, b,​​​​​​ and c​​​​​​ respectively. Each turn you choose two different non-empty piles, take one stone from each, and add 1 point to your score. The game stops when there are fewer than two non-empty piles (meaning there are no more available moves).\nGiven three integers a​​​​​, b,​​​​​ and c​​​​​, return the maximum score you can get.\n \nExample 1:\n\nInput: a = 2, b = 4, c = 6\nOutput: 6\nExplanation: The starting state is (2, 4, 6). One optimal set of moves is:\n- Take from 1st and 3rd piles, state is now (1, 4, 5)\n- Take from 1st and 3rd piles, state is now (0, 4, 4)\n- Take from 2nd and 3rd piles, state is now (0, 3, 3)\n- Take from 2nd and 3rd piles, state is now (0, 2, 2)\n- Take from 2nd and 3rd piles, state is now (0, 1, 1)\n- Take from 2nd and 3rd piles, state is now (0, 0, 0)\nThere are fewer than two non-empty piles, so the game ends. Total: 6 points.\n\nExample 2:\n\nInput: a = 4, b = 4, c = 6\nOutput: 7\nExplanation: The starting state is (4, 4, 6). One optimal set of moves is:\n- Take from 1st and 2nd piles, state is now (3, 3, 6)\n- Take from 1st and 3rd piles, state is now (2, 3, 5)\n- Take from 1st and 3rd piles, state is now (1, 3, 4)\n- Take from 1st and 3rd piles, state is now (0, 3, 3)\n- Take from 2nd and 3rd piles, state is now (0, 2, 2)\n- Take from 2nd and 3rd piles, state is now (0, 1, 1)\n- Take from 2nd and 3rd piles, state is now (0, 0, 0)\nThere are fewer than two non-empty piles, so the game ends. Total: 7 points.\n\nExample 3:\n\nInput: a = 1, b = 8, c = 8\nOutput: 8\nExplanation: One optimal set of moves is to take from the 2nd and 3rd piles for 8 turns until they are empty.\nAfter that, there are fewer than two non-empty piles, so the game ends.\n\n \nConstraints:\n\n1 <= a, b, c <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = 10,b = 10,c = 1) == 10\n assert candidate(a = 5,b = 7,c = 9) == 10\n assert candidate(a = 5,b = 5,c = 5) == 7\n assert candidate(a = 1,b = 8,c = 8) == 8\n assert candidate(a = 3,b = 3,c = 3) == 4\n assert candidate(a = 100000,b = 1,c = 1) == 2\n assert candidate(a = 100000,b = 100000,c = 100000) == 150000\n assert candidate(a = 4,b = 4,c = 6) == 7\n assert candidate(a = 30,b = 60,c = 90) == 90\n assert candidate(a = 1,b = 1,c = 100000) == 2\n assert candidate(a = 50000,b = 50000,c = 1) == 50000\n assert candidate(a = 10,b = 10,c = 10) == 15\n assert candidate(a = 2,b = 4,c = 6) == 6\n assert candidate(a = 5,b = 10,c = 15) == 15\n assert candidate(a = 20,b = 30,c = 40) == 45\n assert candidate(a = 7,b = 7,c = 14) == 14\n assert candidate(a = 10,b = 1,c = 1) == 2\n assert candidate(a = 7,b = 14,c = 10) == 15\n assert candidate(a = 1,b = 1,c = 2) == 2\n assert candidate(a = 7,b = 8,c = 9) == 12\n assert candidate(a = 33333,b = 33333,c = 33334) == 50000\n assert candidate(a = 50000,b = 50000,c = 50001) == 75000\n assert candidate(a = 1000,b = 1000,c = 1000) == 1500\n assert candidate(a = 80,b = 80,c = 40) == 100\n assert candidate(a = 7,b = 14,c = 21) == 21\n assert candidate(a = 10,b = 15,c = 20) == 22\n assert candidate(a = 150000,b = 50000,c = 100000) == 150000\n assert candidate(a = 5000,b = 5001,c = 5002) == 7501\n assert candidate(a = 33333,b = 66666,c = 100000) == 99999\n assert candidate(a = 50000,b = 1,c = 1) == 2\n assert candidate(a = 60000,b = 20000,c = 20000) == 40000\n assert candidate(a = 99999,b = 1,c = 1) == 2\n assert candidate(a = 5,b = 5,c = 100) == 10\n assert candidate(a = 80000,b = 80000,c = 1) == 80000\n assert candidate(a = 99998,b = 99999,c = 100000) == 149998\n assert candidate(a = 20,b = 20,c = 20) == 30\n assert candidate(a = 50000,b = 40000,c = 30000) == 60000\n assert candidate(a = 10000,b = 10000,c = 1) == 10000\n assert candidate(a = 5,b = 5,c = 10) == 10\n assert candidate(a = 10000,b = 10000,c = 10000) == 15000\n assert candidate(a = 42,b = 27,c = 19) == 44\n assert candidate(a = 45000,b = 45000,c = 10000) == 50000\n assert candidate(a = 2,b = 2,c = 100000) == 4\n assert candidate(a = 25,b = 25,c = 24) == 37\n assert candidate(a = 500,b = 500,c = 1500) == 1000\n assert candidate(a = 100,b = 200,c = 300) == 300\n assert candidate(a = 15,b = 15,c = 15) == 22\n assert candidate(a = 25,b = 75,c = 125) == 100\n assert candidate(a = 20,b = 20,c = 21) == 30\n assert candidate(a = 20000,b = 30000,c = 10000) == 30000\n assert candidate(a = 20,b = 40,c = 60) == 60\n assert candidate(a = 12345,b = 67890,c = 11111) == 23456\n assert candidate(a = 80000,b = 10000,c = 10000) == 20000\n assert candidate(a = 12345,b = 67890,c = 54321) == 66666\n assert candidate(a = 5,b = 15,c = 20) == 20\n assert candidate(a = 2,b = 2,c = 3) == 3\n assert candidate(a = 1,b = 1,c = 200000) == 2\n assert candidate(a = 100,b = 100,c = 101) == 150\n assert candidate(a = 3,b = 3,c = 9) == 6\n assert candidate(a = 15,b = 25,c = 35) == 37\n assert candidate(a = 50000,b = 50000,c = 99999) == 99999\n assert candidate(a = 10000,b = 20000,c = 30000) == 30000\n assert candidate(a = 10000,b = 5000,c = 5000) == 10000\n assert candidate(a = 25000,b = 25000,c = 50000) == 50000\n assert candidate(a = 99999,b = 99998,c = 99997) == 149997\n assert candidate(a = 75,b = 25,c = 50) == 75\n assert candidate(a = 1,b = 2,c = 3) == 3\n assert candidate(a = 10,b = 20,c = 30) == 30\n assert candidate(a = 3,b = 9,c = 9) == 10\n assert candidate(a = 15,b = 10,c = 5) == 15\n assert candidate(a = 30,b = 5,c = 25) == 30\n assert candidate(a = 50,b = 50,c = 100) == 100\n assert candidate(a = 100,b = 100,c = 100) == 150\n assert candidate(a = 99999,b = 99999,c = 99999) == 149998\n assert candidate(a = 100,b = 100,c = 1) == 100\n assert candidate(a = 50000,b = 49999,c = 49998) == 74998\n assert candidate(a = 50,b = 25,c = 25) == 50\n assert candidate(a = 98765,b = 43210,c = 54321) == 97531\n assert candidate(a = 5000,b = 5000,c = 10000) == 10000\n assert candidate(a = 55,b = 15,c = 35) == 50\n assert candidate(a = 33333,b = 33334,c = 33335) == 50001\n assert candidate(a = 10000,b = 10000,c = 5000) == 12500\n assert candidate(a = 30,b = 50,c = 20) == 50\n assert candidate(a = 30,b = 30,c = 30) == 45\n assert candidate(a = 60000,b = 40000,c = 20000) == 60000\n assert candidate(a = 1,b = 1,c = 1) == 1\n assert candidate(a = 8,b = 8,c = 8) == 12\n assert candidate(a = 100000,b = 50000,c = 50000) == 100000\n"}, "metadata": {"canonical_parameter_names": ["a", "b", "c"], "leetcode_dataset_entry_point": "Solution().maximumScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumScore(self, a: int, b: int, c: int) -> int:", "container": "Solution", "callable": "maximumScore", "parameters": [{"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1754, "task_id": "largest-merge-of-two-strings", "difficulty": "Medium", "problem_description": "You are given two strings word1 and word2. You want to construct a string merge in the following way: while either word1 or word2 are non-empty, choose one of the following options:\n\nIf word1 is non-empty, append the first character in word1 to merge and delete it from word1.\n\n\t\nFor example, if word1 = \"abc\" and merge = \"dv\", then after choosing this operation, word1 = \"bc\" and merge = \"dva\".\n\n\nIf word2 is non-empty, append the first character in word2 to merge and delete it from word2.\n\t\nFor example, if word2 = \"abc\" and merge = \"\", then after choosing this operation, word2 = \"bc\" and merge = \"a\".\n\n\n\nReturn the lexicographically largest merge you can construct.\nA string a is lexicographically larger than a string b (of the same length) if in the first position where a and b differ, a has a character strictly larger than the corresponding character in b. For example, \"abcd\" is lexicographically larger than \"abcc\" because the first position they differ is at the fourth character, and d is greater than c.\n \nExample 1:\n\nInput: word1 = \"cabaa\", word2 = \"bcaaa\"\nOutput: \"cbcabaaaaa\"\nExplanation: One way to get the lexicographically largest merge is:\n- Take from word1: merge = \"c\", word1 = \"abaa\", word2 = \"bcaaa\"\n- Take from word2: merge = \"cb\", word1 = \"abaa\", word2 = \"caaa\"\n- Take from word2: merge = \"cbc\", word1 = \"abaa\", word2 = \"aaa\"\n- Take from word1: merge = \"cbca\", word1 = \"baa\", word2 = \"aaa\"\n- Take from word1: merge = \"cbcab\", word1 = \"aa\", word2 = \"aaa\"\n- Append the remaining 5 a's from word1 and word2 at the end of merge.\n\nExample 2:\n\nInput: word1 = \"abcabc\", word2 = \"abdcaba\"\nOutput: \"abdcabcabcaba\"\n\n \nConstraints:\n\n1 <= word1.length, word2.length <= 3000\nword1 and word2 consist only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"lexicographically\",word2 = \"largestmerge\") == \"llexicogrargestmergeaphically\"\n assert candidate(word1 = \"zyxw\",word2 = \"abcd\") == \"zyxwabcd\"\n assert candidate(word1 = \"abcdabcd\",word2 = \"zyxwzyxw\") == \"zyxwzyxwabcdabcd\"\n assert candidate(word1 = \"leetcode\",word2 = \"challenge\") == \"leetcodechallenge\"\n assert candidate(word1 = \"aaaab\",word2 = \"aaabb\") == \"aaabbaaaab\"\n assert candidate(word1 = \"lexicographic\",word2 = \"merge\") == \"mlexiergecographic\"\n assert candidate(word1 = \"aaaa\",word2 = \"bbbb\") == \"bbbbaaaa\"\n assert candidate(word1 = \"abcabc\",word2 = \"abdcaba\") == \"abdcabcabcaba\"\n assert candidate(word1 = \"abc\",word2 = \"defghijklmnopqrstuvwxyz\") == \"defghijklmnopqrstuvwxyzabc\"\n assert candidate(word1 = \"z\",word2 = \"z\") == \"zz\"\n assert candidate(word1 = \"hello\",word2 = \"world\") == \"worlhellod\"\n assert candidate(word1 = \"abcd\",word2 = \"zyxw\") == \"zyxwabcd\"\n assert candidate(word1 = \"leetcode\",word2 = \"etco\") == \"leteetcodeco\"\n assert candidate(word1 = \"xy\",word2 = \"xy\") == \"xyxy\"\n assert candidate(word1 = \"cabaa\",word2 = \"bcaaa\") == \"cbcabaaaaa\"\n assert candidate(word1 = \"aabbcc\",word2 = \"bbccdd\") == \"bbccddaabbcc\"\n assert candidate(word1 = \"zzz\",word2 = \"zzz\") == \"zzzzzz\"\n assert candidate(word1 = \"a\",word2 = \"b\") == \"ba\"\n assert candidate(word1 = \"aaaaa\",word2 = \"bbbbb\") == \"bbbbbaaaaa\"\n assert candidate(word1 = \"aabbcc\",word2 = \"abcabc\") == \"abcabcaabbcc\"\n assert candidate(word1 = \"xyz\",word2 = \"xyz\") == \"xyzxyz\"\n assert candidate(word1 = \"abcd\",word2 = \"efgh\") == \"efghabcd\"\n assert candidate(word1 = \"abcd\",word2 = \"dcba\") == \"dcbabcda\"\n assert candidate(word1 = \"same\",word2 = \"same\") == \"ssameame\"\n assert candidate(word1 = \"abcdabcd\",word2 = \"abcde\") == \"abcdeabcdabcd\"\n assert candidate(word1 = \"bca\",word2 = \"cab\") == \"cbcaba\"\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcbabcdefghijklmnopqrstuvwxyza\"\n assert candidate(word1 = \"mississippi\",word2 = \"missouri\") == \"mmissourississippii\"\n assert candidate(word1 = \"zzzzzzzz\",word2 = \"zzzzzzzz\") == \"zzzzzzzzzzzzzzzz\"\n assert candidate(word1 = \"complexity\",word2 = \"similarity\") == \"similcomplexityarity\"\n assert candidate(word1 = \"xyzzzzzzzzzzzzzzzz\",word2 = \"xyzzzzzzzzzzzzzz\") == \"xyzzzzzzzzzzzzzzzzxyzzzzzzzzzzzzzz\"\n assert candidate(word1 = \"aaaabbbbccccdddd\",word2 = \"aaaabbbbccccdddd\") == \"aaaabbbbccccddddaaaabbbbccccdddd\"\n assert candidate(word1 = \"zzzzzzz\",word2 = \"zzzzzzzz\") == \"zzzzzzzzzzzzzzz\"\n assert candidate(word1 = \"aaaaaaa\",word2 = \"bbbbbbb\") == \"bbbbbbbaaaaaaa\"\n assert candidate(word1 = \"zzzzz\",word2 = \"zzzz\") == \"zzzzzzzzz\"\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzzyyxxwwvvuuttssrrqqponmlkjihgfedcbbaa\") == \"zzzyyxxwwvvuuttssrrqqponmlkjihgfedcbbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaa\"\n assert candidate(word1 = \"zyxwvut\",word2 = \"utsrqponmlkjihgfedcba\") == \"zyxwvuuttsrqponmlkjihgfedcba\"\n assert candidate(word1 = \"pqrstuvwxyz\",word2 = \"nopqrstuvwxyz\") == \"pqrstuvwxyznopqrstuvwxyz\"\n assert candidate(word1 = \"zzzzzz\",word2 = \"zzzzzz\") == \"zzzzzzzzzzzz\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"feebdccbaa\") == \"feebdccbaabbccddeeffaa\"\n assert candidate(word1 = \"cccccccc\",word2 = \"dddddddd\") == \"ddddddddcccccccc\"\n assert candidate(word1 = \"a\",word2 = \"z\") == \"za\"\n assert candidate(word1 = \"aabbcc\",word2 = \"aaabbb\") == \"aabbccaaabbb\"\n assert candidate(word1 = \"abcdxyz\",word2 = \"xyzabcd\") == \"xyzabcdxyzabcd\"\n assert candidate(word1 = \"python\",word2 = \"java\") == \"pytjhonava\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"abcabcabc\") == \"abcdabcdabcdabcabcabc\"\n assert candidate(word1 = \"sameprefix\",word2 = \"sameprefixsuffix\") == \"ssameprefixsuffixameprefix\"\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcba\") == \"jihgfedcbabcdefghija\"\n assert candidate(word1 = \"onetwothreefour\",word2 = \"fivesixseveneightnine\") == \"onfivetwothresixseveneightnineefoure\"\n assert candidate(word1 = \"racecar\",word2 = \"racecar\") == \"rracecaracecar\"\n assert candidate(word1 = \"abcdabcdabcdabcdabcdabcd\",word2 = \"zyxwzyxwzyxwzyxwzyxwzyxw\") == \"zyxwzyxwzyxwzyxwzyxwzyxwabcdabcdabcdabcdabcdabcd\"\n assert candidate(word1 = \"xyxzyzyzyx\",word2 = \"zyzyzyzyxz\") == \"zyzyzyzyxzxyxzyzyzyx\"\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"xyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyzabacabadabacaba\"\n assert candidate(word1 = \"xyzz\",word2 = \"yxzz\") == \"yxzzxyzz\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"zyxwzyxwzyxw\") == \"zyxwzyxwzyxwabcdabcdabcd\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"zzzzyyyxxx\") == \"zzzzyyyxxxaabbccddeeff\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"zzyyxxwwvvuu\") == \"zzyyxxwwvvuuaabbccddeeff\"\n assert candidate(word1 = \"abcdefg\",word2 = \"hijklmnop\") == \"hijklmnopabcdefg\"\n assert candidate(word1 = \"banana\",word2 = \"bandana\") == \"bbandanananaa\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"dcbaabcdabcd\") == \"dcbabcdabcdabcdaabcdabcd\"\n assert candidate(word1 = \"abracadabra\",word2 = \"alakazam\") == \"alakazamabracadabra\"\n assert candidate(word1 = \"aaaabbbbcccc\",word2 = \"bbbbaaaacccc\") == \"bbbbaaaaccccaaaabbbbcccc\"\n assert candidate(word1 = \"leetcode\",word2 = \"edocteel\") == \"leetedocteelcode\"\n assert candidate(word1 = \"aaaaaaaabbbbbbbbcccccccc\",word2 = \"ccccccccbbbbbbbbbaaaaaaa\") == \"ccccccccbbbbbbbbbaaaaaaaabbbbbbbbccccccccaaaaaaa\"\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxcba\") == \"zyxcbabcdxyza\"\n assert candidate(word1 = \"ababababab\",word2 = \"bababababa\") == \"babababababababababa\"\n assert candidate(word1 = \"equalequal\",word2 = \"equal\") == \"equequalequalal\"\n assert candidate(word1 = \"abcabcabc\",word2 = \"abcabcabc\") == \"abcabcabcabcabcabc\"\n assert candidate(word1 = \"zzzzzzyyyy\",word2 = \"yyyyzzzzzz\") == \"zzzzzzyyyyzzzzzzyyyy\"\n assert candidate(word1 = \"racecar\",word2 = \"race\") == \"rracecarace\"\n assert candidate(word1 = \"programming\",word2 = \"challenges\") == \"progrchammingallenges\"\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzza\"\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxwvut\") == \"zyxwvutabcdxyz\"\n assert candidate(word1 = \"abacaxi\",word2 = \"abacax\") == \"abacaxiabacax\"\n assert candidate(word1 = \"aaaaaabbbbb\",word2 = \"cccccdddddeeeee\") == \"cccccdddddeeeeeaaaaaabbbbb\"\n assert candidate(word1 = \"abcdefg\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcbabcdefga\"\n assert candidate(word1 = \"samecharacters\",word2 = \"samecharacters\") == \"ssamecharamecharactersacters\"\n assert candidate(word1 = \"abababababab\",word2 = \"babababababa\") == \"babababababababababababa\"\n assert candidate(word1 = \"aaaaab\",word2 = \"bbbaaa\") == \"bbbaaaaabaaa\"\n assert candidate(word1 = \"aabbbccc\",word2 = \"aabbcc\") == \"aabbccaabbbccc\"\n assert candidate(word1 = \"zzzzz\",word2 = \"zzzzzz\") == \"zzzzzzzzzzz\"\n assert candidate(word1 = \"\",word2 = \"abc\") == \"abc\"\n assert candidate(word1 = \"abcdefghijk\",word2 = \"abcdefghijl\") == \"abcdefghijlabcdefghijk\"\n assert candidate(word1 = \"nestednested\",word2 = \"nested\") == \"nnestesteednestedd\"\n assert candidate(word1 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",word2 = \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(word1 = \"abcde\",word2 = \"edcba\") == \"edcbabcdea\"\n assert candidate(word1 = \"supercalifragilisticexpialidocious\",word2 = \"antidisestablishmentarianism\") == \"supercantidisestalifragilisticexpialidociousablishmentarianism\"\n assert candidate(word1 = \"xyzz\",word2 = \"zzxy\") == \"zzxyzzxy\"\n assert candidate(word1 = \"xyzz\",word2 = \"zzx\") == \"zzxyzzx\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"zzzzyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihghffeeddccbbaa\") == \"zzzzyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihghffeeddccbbaabbccddeeffaa\"\n assert candidate(word1 = \"abababab\",word2 = \"babababa\") == \"babababababababa\"\n assert candidate(word1 = \"xylophone\",word2 = \"xylophon\") == \"xyxyloplophonhone\"\n assert candidate(word1 = \"abc\",word2 = \"\") == \"abc\"\n assert candidate(word1 = \"abcdabcdabcdabcd\",word2 = \"zyxwzyxwzyxwzyxw\") == \"zyxwzyxwzyxwzyxwabcdabcdabcdabcd\"\n assert candidate(word1 = \"zzzz\",word2 = \"zzzz\") == \"zzzzzzzz\"\n assert candidate(word1 = \"longwordone\",word2 = \"longwordtwo\") == \"lonlongworgwordtwodone\"\n assert candidate(word1 = \"aaaaaaaaaaaa\",word2 = \"bbbbbbbbbbba\") == \"bbbbbbbbbbbaaaaaaaaaaaaa\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"dcba\") == \"dcbabcdabcdabcda\"\n assert candidate(word1 = \"aaaabbbbcccc\",word2 = \"ddddccccbbbaaaa\") == \"ddddccccbbbaaaabbbbccccaaaa\"\n assert candidate(word1 = \"leetcode\",word2 = \"contest\") == \"leetcontestcode\"\n assert candidate(word1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",word2 = \"zoology\") == \"zpoonlogyeumonoultramicroscopicsilicovolcanoconiosis\"\n assert candidate(word1 = \"abcdabcdb\",word2 = \"abcdabcdb\") == \"abcdabcdbabcdabcdb\"\n assert candidate(word1 = \"amazing\",word2 = \"algorithm\") == \"amazingalgorithm\"\n assert candidate(word1 = \"b\",word2 = \"a\") == \"ba\"\n assert candidate(word1 = \"qwerqwerqwer\",word2 = \"qwertyuiop\") == \"qwqwertyuioperqwerqwer\"\n assert candidate(word1 = \"onesmallstring\",word2 = \"averylongstringwithmanycharactersandvariouslengthsandcombinations\") == \"onesmaverylongstringwithmanycharallstringactersandvariouslengthsandcombinations\"\n assert candidate(word1 = \"banana\",word2 = \"apple\") == \"bappleanana\"\n assert candidate(word1 = \"abcde\",word2 = \"fghij\") == \"fghijabcde\"\n assert candidate(word1 = \"zyxwvutsrqponmlkjihgfedcba\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == \"zyxwvutsrqponmlkjihgfedcbabcdefghijklmnopqrstuvwxyza\"\n assert candidate(word1 = \"zzyzxzyzxzy\",word2 = \"xyxyxyxyxyx\") == \"zzyzxzyzxzyxyxyxyxyxyx\"\n assert candidate(word1 = \"aabbcc\",word2 = \"bbccaa\") == \"bbccaabbccaa\"\n assert candidate(word1 = \"appleapple\",word2 = \"banana\") == \"bappleappleanana\"\n assert candidate(word1 = \"abcdef\",word2 = \"fghijk\") == \"fghijkabcdef\"\n assert candidate(word1 = \"zzzzyyyyxxx\",word2 = \"zzzyyyyxx\") == \"zzzzzzzyyyyyyyyxxxxx\"\n assert candidate(word1 = \"aaaaaabbbb\",word2 = \"bbbbbaaaa\") == \"bbbbbaaaaaabbbbaaaa\"\n assert candidate(word1 = \"aaaaaa\",word2 = \"bbbbbbbb\") == \"bbbbbbbbaaaaaa\"\n assert candidate(word1 = \"lexicographically\",word2 = \"mergeable\") == \"mlexiergecographicallyable\"\n assert candidate(word1 = \"abcabcabc\",word2 = \"cbacbacba\") == \"cbacbacbabcabcabca\"\n assert candidate(word1 = \"samestart\",word2 = \"samestart\") == \"ssamestartamestart\"\n assert candidate(word1 = \"zzzzzzzzzz\",word2 = \"zzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzz\"\n assert candidate(word1 = \"abcdexyz\",word2 = \"zyxwvuts\") == \"zyxwvutsabcdexyz\"\n assert candidate(word1 = \"abcdefg\",word2 = \"ghijklm\") == \"ghijklmabcdefg\"\n assert candidate(word1 = \"longwordone\",word2 = \"evenlongerwordtwo\") == \"longworevenlongerwordtwodone\"\n assert candidate(word1 = \"aaaab\",word2 = \"aaabaaa\") == \"aaabaaaabaaa\"\n assert candidate(word1 = \"abcdabcd\",word2 = \"dcbaabcd\") == \"dcbabcdabcdaabcd\"\n assert candidate(word1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",word2 = \"supercalifragilisticexpialidocious\") == \"suppneumonoultrercamicroscopicsilicovolcanoconiosisalifragilisticexpialidocious\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"aabbccddeegf\") == \"aabbccddeegfaabbccddeeff\"\n assert candidate(word1 = \"zyxzyxzyx\",word2 = \"zyxzyxzyx\") == \"zzyyxzyxzyxzyxzyxx\"\n assert candidate(word1 = \"overlapover\",word2 = \"overlap\") == \"ovoverlerlapoverap\"\n assert candidate(word1 = \"aebcdefghijklmnopqrstuvwxyz\",word2 = \"zxcvbnmlkjihgfedcbaeb\") == \"zxcvbnmlkjihgfedcbaebcdefghijklmnopqrstuvwxyzaeb\"\n assert candidate(word1 = \"abcdef\",word2 = \"fedcba\") == \"fedcbabcdefa\"\n assert candidate(word1 = \"aaaabbbbcccc\",word2 = \"ddddeeeeffff\") == \"ddddeeeeffffaaaabbbbcccc\"\n assert candidate(word1 = \"hellohellohello\",word2 = \"worldworld\") == \"worlhellohellohellodworld\"\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"abcabc\") == \"abcabcabcabcabcabc\"\n assert candidate(word1 = \"zzzz\",word2 = \"zzz\") == \"zzzzzzz\"\n assert candidate(word1 = \"xyzzzzzzzzzzzz\",word2 = \"yyyyyyyyyyyyyy\") == \"yyyyyyyyyyyyyyxyzzzzzzzzzzzz\"\n assert candidate(word1 = \"aabaaa\",word2 = \"baabaa\") == \"baabaabaaaaa\"\n assert candidate(word1 = \"aaaaaaaaaabbbbbbbbbbcccccccccc\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzaaaaaaaaaabbbbbbbbbbcccccccccc\"\n"}, "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().largestMerge", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def largestMerge(self, word1: str, word2: str) -> str:", "container": "Solution", "callable": "largestMerge", "parameters": [{"name": "word1", "type": "str"}, {"name": "word2", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1755, "task_id": "closest-subsequence-sum", "difficulty": "Hard", "problem_description": "You are given an integer array nums and an integer goal.\nYou want to choose a subsequence of nums such that the sum of its elements is the closest possible to goal. That is, if the sum of the subsequence's elements is sum, then you want to minimize the absolute difference abs(sum - goal).\nReturn the minimum possible value of abs(sum - goal).\nNote that a subsequence of an array is an array formed by removing some elements (possibly all or none) of the original array.\n \nExample 1:\n\nInput: nums = [5,-7,3,5], goal = 6\nOutput: 0\nExplanation: Choose the whole array as a subsequence, with a sum of 6.\nThis is equal to the goal, so the absolute difference is 0.\n\nExample 2:\n\nInput: nums = [7,-9,15,-2], goal = -5\nOutput: 1\nExplanation: Choose the subsequence [7,-9,-2], with a sum of -4.\nThe absolute difference is abs(-4 - (-5)) = abs(1) = 1, which is the minimum.\n\nExample 3:\n\nInput: nums = [1,2,3], goal = -7\nOutput: 7\n\n \nConstraints:\n\n1 <= nums.length <= 40\n-107 <= nums[i] <= 107\n-109 <= goal <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],goal = 10) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50],goal = -100) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],goal = 100) == 0\n assert candidate(nums = [10, 22, 9, -24, -33, 21, 4, 19, 29, -14, 34, 10, -11, 8, -8, -7, 13, 24, -29, -10, -28, 10, -32, -23, 7, 31, 2, 25, -31, -40, -4, -23],goal = 100) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],goal = 15) == 0\n assert candidate(nums = [7, -9, 15, -2],goal = -5) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],goal = 25) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],goal = 10) == 0\n assert candidate(nums = [10000000, -10000000, 10000000, -10000000],goal = 0) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000],goal = 0) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],goal = -255) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],goal = 20) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],goal = 0) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5],goal = -15) == 0\n assert candidate(nums = [1, 2, 3],goal = -7) == 7\n assert candidate(nums = [5, -7, 3, 5],goal = 6) == 0\n assert candidate(nums = [10000000, -10000000],goal = 0) == 0\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16],goal = 0) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],goal = 0) == 0\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50, -60, 60, -70, 70, -80, 80, -90, 90, -100, 100],goal = -500) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40],goal = -1000) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 900) == 80\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80],goal = 5) == 5\n assert candidate(nums = [-1000, 1000, -500, 500, -250, 250, -125, 125, -62, 62, -31, 31, -15, 15, -7, 7, -3, 3, -1, 1],goal = -1000) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],goal = -450) == 0\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],goal = 0) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000],goal = 3000000) == 500000\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],goal = 50) == 0\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, -1000000, -2000000, -3000000, -4000000, -5000000, -6000000, -7000000, -8000000, -9000000, -10000000],goal = 20000000) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],goal = 500) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],goal = 100) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000],goal = 10000) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],goal = 10000) == 0\n assert candidate(nums = [10000000, -5000000, 3000000, -2000000, 1500000, -1000000, 750000, -500000, 250000, -125000, 62500, -31250, 15625, -7812, 3906, -1953, 976, -488, 244, -122],goal = 0) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100],goal = 50) == 0\n assert candidate(nums = [-10000, -20000, -30000, -40000, -50000, 10000, 20000, 30000, 40000, 50000],goal = -50000) == 0\n assert candidate(nums = [7, 3, 8, 4, 6, 2, 5, 1, 10, 9],goal = 42) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],goal = 100) == 0\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],goal = 5000) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],goal = 1500) == 0\n assert candidate(nums = [5, -3, 1, 7, -9, 10, -20, 15, -1, 4, 8, -6, 2, 11, -7, 13, -5, 9, -12, 6, 14, -4, 16, -8, 12, -11, 17, -13, 18, -9, 19, -14, 20, -15, 21, -16, 22, -17, 23, -18],goal = 50) == 0\n assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500, -600, 600, -700, 700, -800, 800, -900, 900, -1000, 1000],goal = 0) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],goal = -15) == 0\n assert candidate(nums = [-10000000, 20000000, -10000000, 20000000, -10000000, 20000000, -10000000, 20000000, -10000000, 20000000, -10000000, 20000000, -10000000, 20000000, -10000000, 20000000, -10000000, 20000000, -10000000, 20000000],goal = 15000000) == 5000000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8],goal = 1) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50],goal = 0) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 800) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60],goal = 5) == 5\n assert candidate(nums = [5, -7, 3, 5, 9, -1, 2, -3, 8],goal = 6) == 0\n assert candidate(nums = [10000000, -10000000, 20000000, -20000000, 30000000, -30000000, 40000000, -40000000],goal = 0) == 0\n assert candidate(nums = [10000000, -5000000, 2500000, -1250000, 625000, -312500, 156250, -78125, 39062, -19531, 9765, -4882, 2441, -1220, 610, -305, 152, -76, 38, -19, 9, -4, 2, -1],goal = 5000000) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, -5, -15, -25, -35, -45, -55, -65, -75, -85, -95, -105],goal = 250) == 0\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],goal = 0) == 0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0],goal = 123) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 300) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20],goal = -100) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20],goal = 5) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000, 1250000, -1250000, 625000, -625000, 312500, -312500, 156250, -156250, 78125, -78125],goal = 0) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 1) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],goal = 2000) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],goal = 1) == 0\n assert candidate(nums = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000, -1000000, -2000000, -3000000, -4000000, -5000000, -6000000, -7000000, -8000000, -9000000, -10000000],goal = 5000000) == 0\n assert candidate(nums = [3, -1, 4, 1, 5, -9, 2, 6, 5, 3, -5, 7, -7, 8, -8, 9, -9, 10, -10],goal = 0) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],goal = 1000000) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],goal = 50) == 30\n assert candidate(nums = [-10000000, 10000000, -5000000, 5000000, 2500000, -2500000, 1250000, -1250000],goal = 1234567) == 15433\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, -14, 14, -15, 15, -16, 16, -17, 17, -18, 18, -19, 19, -20, 20],goal = 0) == 0\n assert candidate(nums = [1000000, -1000000, 2000000, -2000000, 3000000, -3000000, 4000000, -4000000, 5000000, -5000000, 6000000, -6000000, 7000000, -7000000, 8000000, -8000000, 9000000, -9000000, 10000000, -10000000],goal = 5000000) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],goal = 0) == 0\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000],goal = 500) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 1000) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = -1000) == 1000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20],goal = 0) == 0\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, -14, 14, -15, 15],goal = 50) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],goal = 0) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],goal = -30) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],goal = -50) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000, 1250000, -1250000],goal = 0) == 0\n assert candidate(nums = [-10000, 10000, -20000, 20000, -30000, 30000, -40000, 40000, -50000, 50000, -60000, 60000, -70000, 70000, -80000, 80000, -90000, 90000, -100000, 100000],goal = 0) == 0\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30, -31, 32, -33, 34, -35, 36, -37, 38, -39, 40],goal = 0) == 0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0],goal = 150) == 0\n assert candidate(nums = [9999999, 8888888, 7777777, 6666666, 5555555, 4444444, 3333333, 2222222, 1111111, -1111111, -2222222, -3333333, -4444444, -5555555, -6666666, -7777777, -8888888, -9999999],goal = 123456789) == 73456794\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],goal = 10000) == 0\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20],goal = 5) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],goal = 1000) == 100\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40],goal = -1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],goal = 1234) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],goal = 1) == 0\n assert candidate(nums = [10000000, -10000000, 20000000, -20000000, 30000000],goal = 15000000) == 5000000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],goal = 10) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000],goal = 0) == 0\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30],goal = -150) == 0\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000],goal = 0) == 0\n assert candidate(nums = [10000, -10000, 20000, -20000, 30000, -30000, 40000, -40000, 50000, -50000],goal = 25000) == 5000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],goal = 500) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],goal = 450) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],goal = 999) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],goal = 500) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "goal"], "leetcode_dataset_entry_point": "Solution().minAbsDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minAbsDifference(self, nums: list[int], goal: int) -> int:", "container": "Solution", "callable": "minAbsDifference", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "goal", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1758, "task_id": "minimum-changes-to-make-alternating-binary-string", "difficulty": "Easy", "problem_description": "You are given a string s consisting only of the characters '0' and '1'. In one operation, you can change any '0' to '1' or vice versa.\nThe string is called alternating if no two adjacent characters are equal. For example, the string \"010\" is alternating, while the string \"0100\" is not.\nReturn the minimum number of operations needed to make s alternating.\n \nExample 1:\n\nInput: s = \"0100\"\nOutput: 1\nExplanation: If you change the last character to '1', s will be \"0101\", which is alternating.\n\nExample 2:\n\nInput: s = \"10\"\nOutput: 0\nExplanation: s is already alternating.\n\nExample 3:\n\nInput: s = \"1111\"\nOutput: 2\nExplanation: You need two operations to reach \"0101\" or \"1010\".\n\n \nConstraints:\n\n1 <= s.length <= 104\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == 2\n assert candidate(s = \"101010\") == 0\n assert candidate(s = \"111000\") == 2\n assert candidate(s = \"1101101101\") == 4\n assert candidate(s = \"001100\") == 3\n assert candidate(s = \"10\") == 0\n assert candidate(s = \"110011\") == 3\n assert candidate(s = \"0100\") == 1\n assert candidate(s = \"0110101010\") == 2\n assert candidate(s = \"010101\") == 0\n assert candidate(s = \"0000\") == 2\n assert candidate(s = \"000111\") == 2\n assert candidate(s = \"101010101010101010\") == 0\n assert candidate(s = \"1100110011001100110011001100110011\") == 17\n assert candidate(s = \"01010101010101010\") == 0\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111\") == 30\n assert candidate(s = \"10101101010110101010\") == 7\n assert candidate(s = \"00000000000000000000000000000000\") == 16\n assert candidate(s = \"111110000111110000111110000111110000111110000111110000\") == 27\n assert candidate(s = \"1100110011001100\") == 8\n assert candidate(s = \"010101010101010101010101\") == 0\n assert candidate(s = \"111000111000111\") == 5\n assert candidate(s = \"0110101010101010\") == 2\n assert candidate(s = \"101010101010101010101010\") == 0\n assert candidate(s = \"1010101010101001\") == 2\n assert candidate(s = \"101010101010101010101\") == 0\n assert candidate(s = \"1000111010010101\") == 8\n assert candidate(s = \"0000000000\") == 5\n assert candidate(s = \"1100110011\") == 5\n assert candidate(s = \"111000111000111000111000111000\") == 10\n assert candidate(s = \"11110000000000001111\") == 10\n assert candidate(s = \"0000000000000000\") == 8\n assert candidate(s = \"11001100110011001100110011001100\") == 16\n assert candidate(s = \"1010101010101010\") == 0\n assert candidate(s = \"110011001100\") == 6\n assert candidate(s = \"110011001100110011\") == 9\n assert candidate(s = \"010101010110\") == 2\n assert candidate(s = \"0011001100110011\") == 8\n assert candidate(s = \"000001111000001111000011110000111100001111000011110000\") == 27\n assert candidate(s = \"1010100101010101010101010101010101\") == 6\n assert candidate(s = \"11111000001111100000\") == 8\n assert candidate(s = \"0101010101010101010101010101010101\") == 0\n assert candidate(s = \"100100100100100100100100\") == 12\n assert candidate(s = \"00110011001100110011001100110011\") == 16\n assert candidate(s = \"0110110110110110\") == 8\n assert candidate(s = \"10110101010101010101\") == 3\n assert candidate(s = \"1010010101010101\") == 4\n assert candidate(s = \"0101011010101010\") == 6\n assert candidate(s = \"010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"0011001100110\") == 6\n assert candidate(s = \"11111111111111111111\") == 10\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001\") == 26\n assert candidate(s = \"00001111111111110000\") == 10\n assert candidate(s = \"1111111111111111\") == 8\n assert candidate(s = \"01010101010\") == 0\n assert candidate(s = \"111000111000111000111000111000111000111000111000111000111\") == 19\n assert candidate(s = \"001100110011\") == 6\n assert candidate(s = \"11010011\") == 3\n assert candidate(s = \"00011100011100011100011100011100\") == 11\n assert candidate(s = \"011011011011011011011011\") == 12\n assert candidate(s = \"00000111110000011111\") == 8\n assert candidate(s = \"111000111000111000111\") == 7\n assert candidate(s = \"11001100110011001100\") == 10\n assert candidate(s = \"01010101010101010101010101010101\") == 0\n assert candidate(s = \"10010010010010010010\") == 9\n assert candidate(s = \"1010101010101010101010101010\") == 0\n assert candidate(s = \"1110000111000011\") == 8\n assert candidate(s = \"01110111011101110111\") == 5\n assert candidate(s = \"111100001111\") == 6\n assert candidate(s = \"1101101101101101\") == 7\n assert candidate(s = \"01100110011001100110\") == 10\n assert candidate(s = \"00110011001100\") == 7\n assert candidate(s = \"010101010101\") == 0\n assert candidate(s = \"1111111111111111111111111111\") == 14\n assert candidate(s = \"0101010101010101\") == 0\n assert candidate(s = \"0001110001\") == 3\n assert candidate(s = \"11111111111111111111111111111111\") == 16\n assert candidate(s = \"00000000\") == 4\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"01100110011001100110011001100110011\") == 17\n assert candidate(s = \"0101010101\") == 0\n assert candidate(s = \"1001001001001001001001001001001001\") == 17\n assert candidate(s = \"00001111000011110000111100001111\") == 16\n assert candidate(s = \"10101010101010101\") == 0\n assert candidate(s = \"111000111\") == 3\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000000000\") == 30\n assert candidate(s = \"0111000111000111\") == 5\n assert candidate(s = \"0001111000111100\") == 8\n assert candidate(s = \"1010101010101\") == 0\n assert candidate(s = \"00000000000000000000\") == 10\n assert candidate(s = \"1111000011110000\") == 8\n assert candidate(s = \"10101010101010101010101010101010\") == 0\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"010010010010\") == 6\n assert candidate(s = \"0111000101101010\") == 8\n assert candidate(s = \"0110110110110\") == 6\n assert candidate(s = \"01010101010101\") == 0\n assert candidate(s = \"001100110011001100110\") == 10\n assert candidate(s = \"1001001001001\") == 6\n assert candidate(s = \"010101010101010101010\") == 0\n assert candidate(s = \"1111111111\") == 5\n assert candidate(s = \"0110011001100110\") == 8\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011001100\") == 32\n assert candidate(s = \"1001100110011001\") == 8\n assert candidate(s = \"01010101010101010101\") == 0\n assert candidate(s = \"11111111\") == 4\n assert candidate(s = \"1101001100\") == 4\n assert candidate(s = \"0001110001110001110001\") == 7\n assert candidate(s = \"110000111100001111000011110000\") == 15\n assert candidate(s = \"01101101101101101101\") == 9\n assert candidate(s = \"10101010101010101010\") == 0\n assert candidate(s = \"01010010101001010101\") == 7\n assert candidate(s = \"1101010101\") == 1\n assert candidate(s = \"111000111000111000111000\") == 8\n assert candidate(s = \"0000000000000000000000000000\") == 14\n assert candidate(s = \"000111000111000\") == 5\n assert candidate(s = \"0000111100001111\") == 8\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minOperations(self, s: str) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1759, "task_id": "count-number-of-homogenous-substrings", "difficulty": "Medium", "problem_description": "Given a string s, return the number of homogenous substrings of s. Since the answer may be too large, return it modulo 109 + 7.\nA string is homogenous if all the characters of the string are the same.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"abbcccaa\"\nOutput: 13\nExplanation: The homogenous substrings are listed as below:\n\"a\" appears 3 times.\n\"aa\" appears 1 time.\n\"b\" appears 2 times.\n\"bb\" appears 1 time.\n\"c\" appears 3 times.\n\"cc\" appears 2 times.\n\"ccc\" appears 1 time.\n3 + 1 + 2 + 1 + 3 + 2 + 1 = 13.\nExample 2:\n\nInput: s = \"xy\"\nOutput: 2\nExplanation: The homogenous substrings are \"x\" and \"y\".\nExample 3:\n\nInput: s = \"zzzzz\"\nOutput: 15\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaabbbccc\") == 18\n assert candidate(s = \"aabbccddeeefffggghhhiiii\") == 46\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"xy\") == 2\n assert candidate(s = \"aabbaa\") == 9\n assert candidate(s = \"aaaaa\") == 15\n assert candidate(s = \"pppppppppp\") == 55\n assert candidate(s = \"abcdeffffff\") == 26\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"qqqqqwwweeeerrrrtttttyyyyyuuuuuiooooo\") == 102\n assert candidate(s = \"abcabcabc\") == 9\n assert candidate(s = \"ababababab\") == 10\n assert candidate(s = \"abcde\") == 5\n assert candidate(s = \"ababababa\") == 9\n assert candidate(s = \"zzzzyyyyxxxwwwwvvvvuuuuttttsrrrqqqppoonnmlkjihgfedcba\") == 101\n assert candidate(s = \"ccccccccc\") == 45\n assert candidate(s = \"abbcccaa\") == 13\n assert candidate(s = \"abcd\") == 4\n assert candidate(s = \"zzzzz\") == 15\n assert candidate(s = \"ababab\") == 6\n assert candidate(s = \"aaaaaabb\") == 24\n assert candidate(s = \"aabbccddeeeeffff\") == 32\n assert candidate(s = \"abcabcabcabcabcabcabc\") == 21\n assert candidate(s = \"aabbbccccdddd\") == 29\n assert candidate(s = \"mmmmmlllllkkkkkkjjjjjjjjiiiiiiiiiiiihhhhhhhhhhhh\") == 243\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1326\n assert candidate(s = \"aaabaaaabaaaaabaaaaaaabaaaaaaaabaaaaaaaaabaaaaaaaaaabaaaaaaaaaa\") == 257\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeee\") == 208\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 903\n assert candidate(s = \"aabbcccddddeeeee\") == 37\n assert candidate(s = \"pppppqqqqqqrrrrrrsssssstttttuuuuuuvvvvvvvvvwwwwwwwww\") == 204\n assert candidate(s = \"aabbbcccc\") == 19\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 676\n assert candidate(s = \"aaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaa\") == 252\n assert candidate(s = \"mmmmmmmmmmmmmmmnnnnnnnnnnnnnnnoooooooooooopppppppppppp\") == 396\n assert candidate(s = \"aabbccddeeefffggg\") == 30\n assert candidate(s = \"abcabcabcabc\") == 12\n assert candidate(s = \"aaabbaaaabbaaa\") == 28\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\") == 165\n assert candidate(s = \"aabbccddeeefffggghhhh\") == 40\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 277140\n assert candidate(s = \"zzzzyyyyzzzz\") == 30\n assert candidate(s = \"aaaaabbbbccccc\") == 40\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 29403\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\") == 24\n assert candidate(s = \"aabbccddeeeeffffggggghhhhiiiii\") == 72\n assert candidate(s = \"pppppppppppppppppppppppppppppppppp\") == 595\n assert candidate(s = \"ababababababababababababababab\") == 30\n assert candidate(s = \"aaaaabbbbccccdddddeeeee\") == 65\n assert candidate(s = \"aabbccddeeefffggghhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\") == 145\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 1892\n assert candidate(s = \"ppppppppppppppppppppppp\") == 276\n assert candidate(s = \"xyzzyzxzyzxyz\") == 14\n assert candidate(s = \"ababababababab\") == 14\n assert candidate(s = \"aabbccddeeeefffghhhiiiijjjjkkkkllllmmmmmnnnnnooooo\") == 120\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\") == 27\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjjkkkkllllmmmmmnnnnnooooooo\") == 134\n assert candidate(s = \"aaaaaaaaabbbbbbbbbbcccccccccc\") == 155\n assert candidate(s = \"zzzzzyyyxxxwwwwvvvvuuuuu\") == 62\n assert candidate(s = \"aabbccddeeeeffffggggghhhiiijjjkkklllmmnnooopppqqqrrsssttuuuvvvwwwwwxxxxxyyyyyzzzz\") == 180\n assert candidate(s = \"abcdefffffffffffffffffffffffffghijklmnopqrstuvwxyz\") == 350\n assert candidate(s = \"abcdabcdbcdabcd\") == 15\n assert candidate(s = \"aabbbbccccc\") == 28\n assert candidate(s = \"aaaaaaaaaaaabbaaaaaaa\") == 109\n assert candidate(s = \"aabbbccccc\") == 24\n assert candidate(s = \"xyxyxyxyxyxyxyx\") == 15\n assert candidate(s = \"aabbaaabbbaaa\") == 24\n assert candidate(s = \"aabbaaabbcccddeee\") == 30\n assert candidate(s = \"aabbccddeeffgg\") == 21\n assert candidate(s = \"aaaaabbbbbbbbbbcccccccccc\") == 125\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppp\") == 820\n assert candidate(s = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 84\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 160\n assert candidate(s = \"qwerqwerqwerqwerqwerqwerqwer\") == 28\n assert candidate(s = \"aaabbaaa\") == 15\n assert candidate(s = \"aaabbaaabbaaa\") == 24\n assert candidate(s = \"abcabcabcabcabc\") == 15\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 21736\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1275\n assert candidate(s = \"abcdefg\") == 7\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().countHomogenous", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countHomogenous(self, s: str) -> int:", "container": "Solution", "callable": "countHomogenous", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1760, "task_id": "minimum-limit-of-balls-in-a-bag", "difficulty": "Medium", "problem_description": "You are given an integer array nums where the ith bag contains nums[i] balls. You are also given an integer maxOperations.\nYou can perform the following operation at most maxOperations times:\n\nTake any bag of balls and divide it into two new bags with a positive number of balls.\n\n\t\nFor example, a bag of 5 balls can become two new bags of 1 and 4 balls, or two new bags of 2 and 3 balls.\n\n\n\nYour penalty is the maximum number of balls in a bag. You want to minimize your penalty after the operations.\nReturn the minimum possible penalty after performing the operations.\n \nExample 1:\n\nInput: nums = [9], maxOperations = 2\nOutput: 3\nExplanation: \n- Divide the bag with 9 balls into two bags of sizes 6 and 3. [9] -> [6,3].\n- Divide the bag with 6 balls into two bags of sizes 3 and 3. [6,3] -> [3,3,3].\nThe bag with the most number of balls has 3 balls, so your penalty is 3 and you should return 3.\n\nExample 2:\n\nInput: nums = [2,4,8,2], maxOperations = 4\nOutput: 2\nExplanation:\n- Divide the bag with 8 balls into two bags of sizes 4 and 4. [2,4,8,2] -> [2,4,4,4,2].\n- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,4,4,4,2] -> [2,2,2,4,4,2].\n- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,2,2,4,4,2] -> [2,2,2,2,2,4,2].\n- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,2,2,2,2,4,2] -> [2,2,2,2,2,2,2,2].\nThe bag with the most number of balls has 2 balls, so your penalty is 2, and you should return 2.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= maxOperations, nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],maxOperations = 10) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],maxOperations = 9) == 5\n assert candidate(nums = [1000000000],maxOperations = 1) == 500000000\n assert candidate(nums = [3, 3, 3, 3],maxOperations = 0) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],maxOperations = 5) == 2\n assert candidate(nums = [100, 100, 100, 100],maxOperations = 10) == 34\n assert candidate(nums = [1, 1, 1, 1, 1],maxOperations = 0) == 1\n assert candidate(nums = [1000000000],maxOperations = 999999999) == 1\n assert candidate(nums = [1000000000],maxOperations = 1000000000) == 1\n assert candidate(nums = [7, 17],maxOperations = 2) == 7\n assert candidate(nums = [9],maxOperations = 2) == 3\n assert candidate(nums = [10, 20, 30, 40, 50],maxOperations = 10) == 10\n assert candidate(nums = [2, 4, 8, 2],maxOperations = 4) == 2\n assert candidate(nums = [1000000000, 1000000000],maxOperations = 1) == 1000000000\n assert candidate(nums = [10, 10, 10],maxOperations = 6) == 4\n assert candidate(nums = [10, 10, 10],maxOperations = 3) == 5\n assert candidate(nums = [7, 14, 21, 28],maxOperations = 3) == 14\n assert candidate(nums = [1, 1, 1, 1],maxOperations = 2) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],maxOperations = 5) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 5) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],maxOperations = 5) == 50\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000],maxOperations = 9) == 100000000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],maxOperations = 25) == 180\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000],maxOperations = 30) == 3449\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 29) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000],maxOperations = 3) == 500000000\n assert candidate(nums = [999999999, 1],maxOperations = 1) == 500000000\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],maxOperations = 9) == 100\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000],maxOperations = 10) == 142857143\n assert candidate(nums = [999, 999, 999, 999, 999, 999, 999, 999, 999, 999],maxOperations = 5) == 999\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000],maxOperations = 3) == 333333334\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000],maxOperations = 5) == 250000000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],maxOperations = 20) == 44\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],maxOperations = 9) == 100000000\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],maxOperations = 15) == 10\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995],maxOperations = 10) == 333333333\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],maxOperations = 10) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],maxOperations = 14) == 5\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],maxOperations = 50) == 18\n assert candidate(nums = [1000000000],maxOperations = 0) == 1000000000\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],maxOperations = 50) == 3\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],maxOperations = 19) == 1000\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],maxOperations = 10) == 500\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],maxOperations = 9) == 50\n assert candidate(nums = [1000000000, 500000000, 250000000],maxOperations = 3) == 333333334\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],maxOperations = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],maxOperations = 15) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],maxOperations = 30) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 0) == 1\n assert candidate(nums = [1, 1000000000, 1],maxOperations = 1000000000) == 1\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999],maxOperations = 5) == 500000000\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],maxOperations = 5) == 166666667\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],maxOperations = 19) == 7\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999],maxOperations = 10) == 333333333\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],maxOperations = 50) == 10000\n assert candidate(nums = [1, 1, 1, 1, 1000000000],maxOperations = 999999) == 1000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],maxOperations = 30) == 6\n assert candidate(nums = [1000000000, 1000000000, 1000000000],maxOperations = 2999999997) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],maxOperations = 20) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],maxOperations = 20) == 20\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999],maxOperations = 4999999995) == 2\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],maxOperations = 10) == 142857143\n assert candidate(nums = [500000000, 500000000, 500000000, 500000000, 500000000],maxOperations = 1000000) == 2500\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],maxOperations = 15) == 7\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],maxOperations = 50) == 9\n assert candidate(nums = [500000000, 500000000, 500000000, 500000000, 500000000],maxOperations = 10) == 166666667\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],maxOperations = 30) == 50\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],maxOperations = 45) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],maxOperations = 10) == 4\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],maxOperations = 20) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],maxOperations = 15) == 114\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999],maxOperations = 4) == 500000000\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],maxOperations = 20) == 5\n assert candidate(nums = [2, 3, 6, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],maxOperations = 100) == 6\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],maxOperations = 50) == 1171\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],maxOperations = 20) == 19\n assert candidate(nums = [100, 200, 300, 400, 500],maxOperations = 15) == 84\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],maxOperations = 10) == 74\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 5) == 1\n assert candidate(nums = [999999999, 999999998, 999999997],maxOperations = 2) == 999999997\n assert candidate(nums = [100, 200, 300, 400, 500],maxOperations = 50) == 29\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],maxOperations = 5) == 5\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999, 999999999],maxOperations = 10) == 500000000\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000],maxOperations = 5) == 500000\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],maxOperations = 9999999990) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],maxOperations = 45) == 100\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000],maxOperations = 10) == 10000000\n assert candidate(nums = [500000000, 500000000, 500000000, 500000000],maxOperations = 3) == 500000000\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000],maxOperations = 50) == 28572\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],maxOperations = 100) == 500\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],maxOperations = 20) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],maxOperations = 0) == 10\n assert candidate(nums = [1000000000, 1000000000, 1000000000],maxOperations = 2) == 1000000000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 30) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],maxOperations = 10) == 350\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],maxOperations = 9) == 8\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],maxOperations = 25) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 9) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],maxOperations = 10) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums", "maxOperations"], "leetcode_dataset_entry_point": "Solution().minimumSize", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumSize(self, nums: list[int], maxOperations: int) -> int:", "container": "Solution", "callable": "minimumSize", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "maxOperations", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1761, "task_id": "minimum-degree-of-a-connected-trio-in-a-graph", "difficulty": "Hard", "problem_description": "You are given an undirected graph. You are given an integer n which is the number of nodes in the graph and an array edges, where each edges[i] = [ui, vi] indicates that there is an undirected edge between ui and vi.\nA connected trio is a set of three nodes where there is an edge between every pair of them.\nThe degree of a connected trio is the number of edges where one endpoint is in the trio, and the other is not.\nReturn the minimum degree of a connected trio in the graph, or -1 if the graph has no connected trios.\n \nExample 1:\n\n\nInput: n = 6, edges = [[1,2],[1,3],[3,2],[4,1],[5,2],[3,6]]\nOutput: 3\nExplanation: There is exactly one trio, which is [1,2,3]. The edges that form its degree are bolded in the figure above.\n\nExample 2:\n\n\nInput: n = 7, edges = [[1,3],[4,1],[4,3],[2,5],[5,6],[6,7],[7,5],[2,6]]\nOutput: 0\nExplanation: There are exactly three trios:\n1) [1,4,3] with degree 0.\n2) [2,5,6] with degree 2.\n3) [5,6,7] with degree 2.\n\n \nConstraints:\n\n2 <= n <= 400\nedges[i].length == 2\n1 <= edges.length <= n * (n-1) / 2\n1 <= ui, vi <= n\nui != vi\nThere are no repeated edges.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[1, 2], [1, 3], [2, 3]]) == 0\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 3\n assert candidate(n = 400,edges = [[1, 2], [2, 3], [3, 1]]) == 0\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [8, 9], [9, 7], [10, 1]]) == 0\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 4], [7, 8]]) == 0\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8]]) == 0\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [3, 2], [4, 1], [5, 2], [3, 6]]) == 3\n assert candidate(n = 3,edges = [[1, 2], [2, 3], [3, 1]]) == 0\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 1], [1, 4], [4, 5], [5, 1]]) == 2\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5]]) == -1\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8]]) == 0\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5]]) == 4\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 4]]) == -1\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == -1\n assert candidate(n = 7,edges = [[1, 3], [4, 1], [4, 3], [2, 5], [5, 6], [6, 7], [7, 5], [2, 6]]) == 0\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 1], [3, 4], [4, 5]]) == 1\n assert candidate(n = 3,edges = [[1, 2], [2, 3]]) == -1\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 1], [1, 4], [2, 4], [3, 4]]) == 3\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [6, 7], [7, 8], [5, 7], [6, 8], [4, 7], [4, 8]]) == 0\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [1, 10], [2, 11], [3, 12]]) == 9\n assert candidate(n = 100,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 19], [1, 100], [100, 50], [50, 25], [25, 75], [75, 50], [50, 1], [2, 50], [3, 50], [4, 50], [5, 50], [6, 50], [7, 50], [8, 50], [9, 50], [10, 50], [11, 50], [12, 50], [13, 50], [14, 50], [15, 50], [16, 50], [17, 50], [18, 50], [19, 50], [21, 50], [22, 50], [23, 50], [24, 50], [25, 50], [26, 50], [27, 50], [28, 50], [29, 50], [30, 50], [31, 50], [32, 50], [33, 50], [34, 50], [35, 50], [36, 50], [37, 50], [38, 50], [39, 50], [40, 50], [41, 50], [42, 50], [43, 50], [44, 50], [45, 50], [46, 50], [47, 50], [48, 50], [49, 50], [51, 50], [52, 50], [53, 50], [54, 50], [55, 50], [56, 50], [57, 50], [58, 50], [59, 50], [60, 50], [61, 50], [62, 50], [63, 50], [64, 50], [65, 50], [66, 50], [67, 50], [68, 50], [69, 50], [70, 50], [71, 50], [72, 50], [73, 50], [74, 50], [75, 50], [76, 50], [77, 50], [78, 50], [79, 50], [80, 50], [81, 50], [82, 50], [83, 50], [84, 50], [85, 50], [86, 50], [87, 50], [88, 50], [89, 50], [90, 50], [91, 50], [92, 50], [93, 50], [94, 50], [95, 50], [96, 50], [97, 50], [98, 50], [99, 50], [100, 99]]) == 3\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 1], [2, 5], [3, 5]]) == 5\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 6], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 10], [8, 11], [8, 12], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [14, 15], [14, 16], [14, 17], [14, 18], [15, 16], [15, 17], [15, 18], [16, 17], [16, 18], [17, 18], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [20, 21], [20, 22], [20, 23], [20, 24], [21, 22], [21, 23], [21, 24], [22, 23], [22, 24], [23, 24], [1, 13], [2, 14], [3, 15], [4, 16], [5, 17], [6, 18], [7, 19], [8, 20], [9, 21], [10, 22], [11, 23], [12, 24]]) == 12\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19], [11, 20], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20]]) == 9\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]) == 6\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10]]) == 3\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [14, 15], [14, 16], [15, 16], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [19, 20], [1, 5], [2, 6], [3, 7], [4, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20]]) == 6\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1], [1, 3], [4, 6], [2, 7], [5, 8]]) == 3\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [14, 15], [14, 16], [15, 16], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [19, 20], [21, 22], [21, 23], [21, 24], [22, 23], [22, 24], [23, 24], [25, 26], [25, 27], [25, 28], [26, 27], [26, 28], [27, 28], [29, 30]]) == 3\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8]]) == 3\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [14, 15], [14, 16], [15, 16], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [19, 20], [21, 22], [21, 23], [21, 24], [22, 23], [22, 24], [23, 24], [25, 26], [25, 27], [25, 28], [26, 27], [26, 28], [27, 28], [29, 30], [1, 5], [2, 6], [3, 7], [4, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25], [22, 26], [23, 27], [24, 28], [25, 29], [26, 30]]) == 7\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 1], [20, 2]]) == 6\n assert candidate(n = 35,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [17, 18], [17, 19], [17, 20], [17, 21], [18, 19], [18, 20], [18, 21], [19, 20], [19, 21], [20, 21], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [24, 25], [24, 26], [24, 27], [24, 28], [25, 26], [25, 27], [25, 28], [26, 27], [26, 28], [27, 28], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 35], [30, 31], [30, 32], [30, 33], [30, 34], [30, 35], [31, 32], [31, 33], [31, 34], [31, 35], [32, 33], [32, 34], [32, 35], [33, 34], [33, 35], [34, 35], [1, 15], [2, 16], [3, 17], [4, 18], [5, 19], [6, 20], [7, 21], [8, 22], [9, 23], [10, 24], [11, 25], [12, 26], [13, 27], [14, 28], [15, 29], [16, 30], [17, 31], [18, 32], [19, 33], [20, 34], [21, 35]]) == 15\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [2, 5], [3, 5], [4, 7], [5, 7], [6, 9], [7, 9], [8, 11], [9, 11], [10, 13], [11, 13], [12, 14], [13, 14]]) == 5\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15], [16, 17], [16, 18], [16, 19], [17, 18], [17, 19], [18, 19], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]]) == 3\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 19], [1, 4], [2, 5], [3, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 19], [14, 20], [1, 16], [2, 17], [3, 18], [4, 19], [5, 20]]) == 5\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]) == 3\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5]]) == 5\n assert candidate(n = 40,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 21], [21, 19], [22, 23], [23, 24], [24, 22], [25, 26], [26, 27], [27, 25], [28, 29], [29, 30], [30, 28], [31, 32], [32, 33], [33, 31], [34, 35], [35, 36], [36, 34], [37, 38], [38, 39], [39, 37], [40, 1]]) == 0\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20]]) == 12\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [14, 15], [14, 16], [15, 16], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [19, 20]]) == 3\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [1, 4], [2, 5], [3, 6], [1, 7], [2, 8], [3, 8]]) == 3\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 1], [20, 19]]) == 0\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [14, 15]]) == 3\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 1], [9, 2], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 1], [8, 2], [9, 3]]) == 12\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [9, 10]]) == 6\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [3, 5], [4, 5]]) == 4\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15]]) == 6\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20], [21, 2], [22, 3], [23, 4], [24, 5], [25, 1]]) == -1\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [4, 8], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [6, 10], [7, 8], [7, 9], [7, 10], [7, 11], [8, 9], [8, 10], [8, 11], [8, 12], [9, 10], [9, 11], [9, 12], [9, 13], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [11, 15], [12, 13], [12, 14], [12, 15], [12, 16], [13, 14], [13, 15], [13, 16], [13, 17], [14, 15], [14, 16], [14, 17], [14, 18], [15, 16], [15, 17], [15, 18], [15, 19], [16, 17], [16, 18], [16, 19], [16, 20], [17, 18], [17, 19], [17, 20], [17, 21], [18, 19], [18, 20], [18, 21], [18, 22], [19, 20], [19, 21], [19, 22], [19, 23], [20, 21], [20, 22], [20, 23], [20, 24], [21, 22], [21, 23], [21, 24], [21, 25], [22, 23], [22, 24], [22, 25], [23, 24], [23, 25], [24, 25], [25, 1]]) == 10\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 1], [10, 2]]) == 4\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [9, 10], [11, 12], [11, 13], [12, 13], [1, 5], [3, 6], [4, 8], [7, 11]]) == 1\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [26, 27], [26, 28], [26, 29], [26, 30], [27, 28], [27, 29], [27, 30], [28, 29], [28, 30], [29, 30], [30, 1]]) == 13\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [1, 4], [2, 5], [3, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 13], [11, 14], [12, 15]]) == 6\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 6], [4, 5], [5, 6], [6, 7], [7, 8], [8, 4]]) == 4\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 21], [21, 19], [22, 23], [23, 24], [24, 22], [25, 26], [26, 27], [27, 25], [28, 29], [29, 30], [30, 28]]) == 0\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 6], [3, 4], [3, 7], [4, 8], [5, 6], [6, 7], [7, 8]]) == 6\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 21], [21, 19], [22, 23], [23, 24], [24, 22], [25, 26], [26, 27], [27, 25], [28, 29], [29, 30], [30, 28], [1, 13], [2, 14], [3, 15], [4, 16], [5, 17], [6, 18], [7, 19], [8, 20], [9, 21], [10, 22], [11, 23], [12, 24], [1, 25], [2, 26], [3, 27], [4, 28], [5, 29], [6, 30]]) == 3\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 1], [20, 19], [21, 22], [22, 23], [23, 21], [24, 25], [25, 26], [26, 24], [27, 28], [28, 29], [29, 27], [30, 21], [30, 25]]) == 0\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [1, 5], [2, 6], [3, 7], [4, 8], [1, 9], [2, 10], [3, 11], [4, 12]]) == 6\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [14, 15], [14, 16], [14, 17], [15, 16], [15, 17], [16, 17], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [1, 14], [2, 15], [3, 16], [4, 17], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17]]) == 11\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 1]]) == 5\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 1], [2, 5], [3, 5], [4, 7], [5, 7], [6, 9], [7, 9], [8, 11], [9, 11]]) == 5\n assert candidate(n = 40,edges = [[1, 2], [2, 3], [1, 3], [4, 5], [5, 6], [4, 6], [7, 8], [8, 9], [7, 9], [10, 11], [11, 12], [10, 12], [13, 14], [14, 15], [13, 15], [16, 17], [17, 18], [16, 18], [19, 20], [20, 21], [19, 21], [22, 23], [23, 24], [22, 24], [25, 26], [26, 27], [25, 27], [28, 29], [29, 30], [28, 30], [31, 32], [32, 33], [31, 33], [34, 35], [35, 36], [34, 36], [37, 38], [38, 39], [37, 39], [40, 1], [2, 4], [3, 5], [6, 8], [7, 9], [10, 12], [11, 13], [14, 16], [15, 17], [18, 20], [19, 21], [22, 24], [23, 25], [26, 28], [27, 29], [30, 32], [31, 33], [34, 36], [35, 37], [38, 40], [39, 1]]) == 3\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().minTrioDegree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minTrioDegree(self, n: int, edges: list[list[int]]) -> int:", "container": "Solution", "callable": "minTrioDegree", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1763, "task_id": "longest-nice-substring", "difficulty": "Easy", "problem_description": "A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, \"abABB\" is nice because 'A' and 'a' appear, and 'B' and 'b' appear. However, \"abA\" is not because 'b' appears, but 'B' does not.\nGiven a string s, return the longest substring of s that is nice. If there are multiple, return the substring of the earliest occurrence. If there are none, return an empty string.\n \nExample 1:\n\nInput: s = \"YazaAay\"\nOutput: \"aAa\"\nExplanation: \"aAa\" is a nice string because 'A/a' is the only letter of the alphabet in s, and both 'A' and 'a' appear.\n\"aAa\" is the longest nice substring.\n\nExample 2:\n\nInput: s = \"Bb\"\nOutput: \"Bb\"\nExplanation: \"Bb\" is a nice string because both 'B' and 'b' appear. The whole string is a substring.\n\nExample 3:\n\nInput: s = \"c\"\nOutput: \"\"\nExplanation: There are no nice substrings.\n\n \nConstraints:\n\n1 <= s.length <= 100\ns consists of uppercase and lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"Bb\") == \"Bb\"\n assert candidate(s = \"aAbBcCdDeEfFgG\") == \"aAbBcCdDeEfFgG\"\n assert candidate(s = \"c\") == \"\"\n assert candidate(s = \"aBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"BbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"abcdefgHIJKlmnopQRStuVwxYZ\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"\") == \"\"\n assert candidate(s = \"aAaBbCc\") == \"aAaBbCc\"\n assert candidate(s = \"QwertyuiopASDFGHJKLzxcvbnmMNBVCXZLKJHGFDSAPOIUYTREWq\") == \"zxcvbnmMNBVCXZ\"\n assert candidate(s = \"aaAAbbBBccCC\") == \"aaAAbbBBccCC\"\n assert candidate(s = \"aA\") == \"aA\"\n assert candidate(s = \"dDcCbBaA\") == \"dDcCbBaA\"\n assert candidate(s = \"AabbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"CcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"aAb\") == \"aA\"\n assert candidate(s = \"aAbBcC\") == \"aAbBcC\"\n assert candidate(s = \"YazaAay\") == \"aAa\"\n assert candidate(s = \"dDfFgG\") == \"dDfFgG\"\n assert candidate(s = \"mnopQRstuvQR\") == \"\"\n assert candidate(s = \"aBcDef\") == \"\"\n assert candidate(s = \"abABB\") == \"abABB\"\n assert candidate(s = \"AbcDEdEfghIjklmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"\"\n assert candidate(s = \"abABcdCDefEF\") == \"abABcdCDefEF\"\n assert candidate(s = \"aabBcC\") == \"bBcC\"\n assert candidate(s = \"AaBbCcDd\") == \"AaBbCcDd\"\n assert candidate(s = \"xyzXYZ\") == \"xyzXYZ\"\n assert candidate(s = \"abcD\") == \"\"\n assert candidate(s = \"abcABCdefDEFghGHijIJklKLmnopMNOPqrstQRSTuvUVwxWXyzYZ\") == \"abcABCdefDEFghGHijIJklKLmnopMNOPqrstQRSTuvUVwxWXyzYZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZzZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaAxyzXYZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZzZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaAxyzXYZ\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefgHIJKLmnopQRstuvWxyz\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbB\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbB\"\n assert candidate(s = \"aBcD\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdEFGH\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdEFGH\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmM\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmM\"\n assert candidate(s = \"xyzXYZaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"xyzXYZaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"xyzXYZaBcDedCbAz\") == \"xyzXYZ\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeE\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeE\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyzaA\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyzaA\"\n assert candidate(s = \"aabbCCddEEffGGhhIIjjKKllMMnnOOppQQrrSSttuUvVwWxXyYzZ\") == \"uUvVwWxXyYzZ\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == \"\"\n assert candidate(s = \"abcdEFGHijklMNOpQRstUVwxyzZ\") == \"zZ\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAxyzXYZ\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAxyzXYZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"abABcdCDefEFGghHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"abABcdCDefEFGghHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"abcdEFGhijKLMnopQRStuVwXYz\") == \"\"\n assert candidate(s = \"abcdefGhijklMnopqrstuvwxyz\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzXYZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzXYZ\"\n assert candidate(s = \"abcdefABCDefghijklmnoMNOPQRSTuvwxyXYZ\") == \"mnoMNO\"\n assert candidate(s = \"abcdEFGHijklMNOPqrstUVWXyzABCDefghIJKLmnopQRstuVWXyz\") == \"\"\n assert candidate(s = \"aBcDabcdABCD\") == \"aBcDabcdABCD\"\n assert candidate(s = \"xYzZyXaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwW\") == \"xYzZyXaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwW\"\n assert candidate(s = \"aBcDEfGhIjKlMnOpQrStUvWxYz\") == \"\"\n assert candidate(s = \"xyzXYZabcABCdefDEFghijGHIJklmnopqrQRSTUVWstuvUVW\") == \"xyzXYZabcABCdefDEFghijGHIJ\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopQRstuVWXyz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopQRstuVWXyz\"\n assert candidate(s = \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\") == \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\"\n assert candidate(s = \"abcdefABCDefgHIJKlMNOPqrSTUVwxYZaBcDefGhIjKlMnoPqrStUvWxYz\") == \"\"\n assert candidate(s = \"abABcdCDefEFghGHijIJklKLmnopMNOPqrstuvwxyzZXYwvuUVtsrSRQPONMLKJIHgfedcbaABab\") == \"abABcdCDefEFghGHijIJklKLmnopMNOP\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAxyzXYZabcABCdefDEFghGHIjklKLmnopqrQRstuvUVwxyzXYZ\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAxyzXYZabcABCdefDEFghGHIjklKLmnopqrQRstuvUVwxyzXYZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\") == \"\"\n assert candidate(s = \"abcdefghijABCDEFGHIJKLmnopqrstuvwxyz\") == \"abcdefghijABCDEFGHIJ\"\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\") == \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZxyzXYZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZxyzXYZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbB\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbB\"\n assert candidate(s = \"aaabBBcccAAbbbCCC\") == \"aaabBBcccAAbbbCCC\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZzZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZzZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"abcdefgHIJKLmnopQRstuvWxyzabcdefgHIJKLmnopQRstuvWxyz\") == \"\"\n assert candidate(s = \"aBcDabcdABCDzzZZyyYYxxXXwwWWvvVVuuUUttTTssSSrrQQppOOmmLLkkJJiiHHggFFddBBAA\") == \"aBcDabcdABCDzzZZyyYYxxXXwwWWvvVVuuUUttTTssSS\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbB\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbB\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"aaAaAaBbBbBbCcCcCc\") == \"aaAaAaBbBbBbCcCcCc\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZabcdEFGHijklMNOPqrstUVWXyz\") == \"\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaaBBccDDeeffGghhiiJjkkLLmmNnoopPqqRrssTtuUvvWwXxyYzz\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaaBBccDDeeffGghhiiJjkkLLmmNnoopPqqRrssTtuUvvWwXxyYzz\"\n assert candidate(s = \"bAcBdCd\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZxyzXYZabcABCdefDEFghiGHIjklJKLmnoMNOpqrPQRstuSTUvVwWxyXYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZxyzXYZabcABCdefDEFghiGHIjklJKLmnoMNOpqrPQRstuSTUvVwWxyXYzZ\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"abcABCxyzXYZdefDEF\") == \"abcABCxyzXYZdefDEF\"\n assert candidate(s = \"abAcBdCdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"EeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZabcDEF\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZabcDEF\"\n assert candidate(s = \"aAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzABCdef\") == \"aAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzABCdef\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbB\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbB\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeEfffGgHHiiJjKKllMMnnOOPPqqRRsstttUUvvWWxxYYzzZZ\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeE\"\n assert candidate(s = \"abcABCdefDEFghGHIjklKLmnopqrQRstuvUVwxyzXYZ\") == \"abcABCdefDEFghGH\"\n assert candidate(s = \"abABcdCDefEFghGHijIJklKLmnopMNOPqrstuvwxyzZXYwvuUVtsrSRQPONMLKJIHgfedcba\") == \"abABcdCDefEFghGHijIJklKLmnopMNOP\"\n assert candidate(s = \"abcdefABCDefgHIJKlMNOPqrSTUVwxYZ\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopqrQRST\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopqrQRST\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZabcdEfghijklmnopqrstuVwxy\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZabcdEfghijklmnopqrstuVwxy\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZa\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZa\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZcC\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZcC\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbBaAcCdD\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbBaAcCdD\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"zZyYxXwWvVuUtTsSrRpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"xYzZyXaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"xYzZyXaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCc\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCc\"\n assert candidate(s = \"abcABCdefDEFgGhHijIJklKLmMnopNOPqrQRstSTuUVwWXyYzZ\") == \"abcABCdefDEFgGhHijIJklKLmMnopNOPqrQRstSTuU\"\n assert candidate(s = \"AbcDeFgHiJklMnopqrStuvWxyzZ\") == \"zZ\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzXxYyZz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzXxYyZz\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeEfffGg\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeE\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"abcdefABCDEFxyzXYZuvwUVWqQrRsStTuUvVwWxXyYzZ\") == \"abcdefABCDEFxyzXYZuvwUVWqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"abcdEFGHijklMNOPqrSTUVwxyz\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"abcXYZabcXYZabcXYZ\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"abcdEFGHijklMNOPqrstUVWXyzabcdEFGHijklMNOPqrstUVWXyz\") == \"\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAA\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopQRstuVWXyzABCdefGHIjklMNOpQRstuVWXyz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopQRstuVWXyzABCdefGHIjklMNOpQRstuVWXyz\"\n assert candidate(s = \"aaBBccDDeeFFggHHiiJJKkllMMnnOoPPqqRRssTTuuVVwwXXyyZZ\") == \"Kk\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAbCdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"xyzXYZabcABCdefDEFghiGHIjklJKLmnoMNOpqrPQRstuSTUvVwWxyXYzZ\") == \"xyzXYZabcABCdefDEFghiGHIjklJKLmnoMNOpqrPQRstuSTUvVwWxyXYzZ\"\n assert candidate(s = \"AbcDefGhiJklMnoPqrStuVwxYzABCdefGHIjklMNOpQRstuVWXyz\") == \"\"\n assert candidate(s = \"abcdEFGHijklMNOPqrstUVWXyz\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefgHIJKLmnopQRstuvWxyz\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbC\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbC\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzABCD\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"abcdefgHIJKLmnopQRstUVwXYZ\") == \"\"\n assert candidate(s = \"abcdEFGHijkLmnopQRstUVwxYZ\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZab\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZab\"\n assert candidate(s = \"abcdefgHIJKLmnopQRstuvWxyz\") == \"\"\n assert candidate(s = \"abcdefgHIJKLmnopQRstuvWxyzab\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyza\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyza\"\n assert candidate(s = \"aaBBccDDeeFFggHHiiJJKkllMMnnOoPPqqRRssTTuuVVwwXXyyZZaaBBccDDeeFFggHHiiJJKkllMMnnOoPPqqRRssTTuuVVwwXXyyZZ\") == \"Kk\"\n assert candidate(s = \"abcdefGHIJkLmnopQRstuvWXYZ\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzABCDEF\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzABCDEF\"\n assert candidate(s = \"xXyYzZwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"xXyYzZwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"\"\n assert candidate(s = \"aBcDcBaEeFfEgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"EeFfEgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaabbCCddeeffGG\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaabbCCddeeffGG\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().longestNiceSubstring", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def longestNiceSubstring(self, s: str) -> str:", "container": "Solution", "callable": "longestNiceSubstring", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1764, "task_id": "form-array-by-concatenating-subarrays-of-another-array", "difficulty": "Medium", "problem_description": "You are given a 2D integer array groups of length n. You are also given an integer array nums.\nYou are asked if you can choose n disjoint subarrays from the array nums such that the ith subarray is equal to groups[i] (0-indexed), and if i > 0, the (i-1)th subarray appears before the ith subarray in nums (i.e. the subarrays must be in the same order as groups).\nReturn true if you can do this task, and false otherwise.\nNote that the subarrays are disjoint if and only if there is no index k such that nums[k] belongs to more than one subarray. A subarray is a contiguous sequence of elements within an array.\n \nExample 1:\n\nInput: groups = [[1,-1,-1],[3,-2,0]], nums = [1,-1,0,1,-1,-1,3,-2,0]\nOutput: true\nExplanation: You can choose the 0th subarray as [1,-1,0,1,-1,-1,3,-2,0] and the 1st one as [1,-1,0,1,-1,-1,3,-2,0].\nThese subarrays are disjoint as they share no common nums[k] element.\n\nExample 2:\n\nInput: groups = [[10,-2],[1,2,3,4]], nums = [1,2,3,4,10,-2]\nOutput: false\nExplanation: Note that choosing the subarrays [1,2,3,4,10,-2] and [1,2,3,4,10,-2] is incorrect because they are not in the same order as in groups.\n[10,-2] must come before [1,2,3,4].\n\nExample 3:\n\nInput: groups = [[1,2,3],[3,4]], nums = [7,7,1,2,3,4,7,7]\nOutput: false\nExplanation: Note that choosing the subarrays [7,7,1,2,3,4,7,7] and [7,7,1,2,3,4,7,7] is invalid because they are not disjoint.\nThey share a common elements nums[4] (0-indexed).\n\n \nConstraints:\n\ngroups.length == n\n1 <= n <= 103\n1 <= groups[i].length, sum(groups[i].length) <= 103\n1 <= nums.length <= 103\n-107 <= groups[i][j], nums[k] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(groups = [[1, 2, 3]],nums = [1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2], [3, 4]],nums = [1, 2, 4, 3]) == False\n assert candidate(groups = [[5, 5, 5], [5]],nums = [5, 5, 5, 5]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1]],nums = [1, 1, 1, 1]) == False\n assert candidate(groups = [[1, 2], [3, 4]],nums = [1, 2, 3, 4]) == True\n assert candidate(groups = [[1, 2], [2, 1]],nums = [1, 2, 2, 1]) == True\n assert candidate(groups = [[-1, -2, -3], [-3, -2, -1]],nums = [-1, -2, -3, -3, -2, -1]) == True\n assert candidate(groups = [[1, -1, -1], [3, -2, 0]],nums = [1, -1, 0, 1, -1, -1, 3, -2, 0]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[1]],nums = [1]) == True\n assert candidate(groups = [[1, 2], [3, 4]],nums = [1, 2, 5, 3, 4]) == True\n assert candidate(groups = [[1], [2], [3]],nums = [3, 2, 1]) == False\n assert candidate(groups = [[1, 1, 1, 1], [1, 1]],nums = [1, 1, 1, 1]) == False\n assert candidate(groups = [[1], [2], [3]],nums = [1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4]],nums = [7, 7, 1, 2, 3, 4, 7, 7]) == False\n assert candidate(groups = [[5, 5]],nums = [5, 5, 5, 5]) == True\n assert candidate(groups = [[10, -2], [1, 2, 3, 4]],nums = [1, 2, 3, 4, 10, -2]) == False\n assert candidate(groups = [[1]],nums = [2]) == False\n assert candidate(groups = [[1, 2], [2, 3]],nums = [1, 2, 2, 3]) == True\n assert candidate(groups = [[1, 2], [3, 4]],nums = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4]],nums = [1, 2, 3, 4]) == False\n assert candidate(groups = [[1, 2], [3, 4], [5, 6]],nums = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[100, 200], [200, 300], [300, 400]],nums = [100, 200, 200, 300, 300, 400]) == True\n assert candidate(groups = [[100, 200], [300, 400], [500, 600]],nums = [100, 200, 300, 400, 500, 600, 100, 200]) == True\n assert candidate(groups = [[0, 0, 0, 0], [0]],nums = [0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(groups = [[10, 20, 30], [30, 40, 50], [50, 60, 70]],nums = [10, 20, 30, 40, 50, 60, 70]) == False\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 8, 9, 7, 8, 9]) == True\n assert candidate(groups = [[9, 8, 7], [8, 7, 6], [7, 6, 5]],nums = [9, 8, 7, 8, 7, 6, 7, 6, 5]) == True\n assert candidate(groups = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],nums = [1, 2, 3, 4, 5, 6, 7]) == False\n assert candidate(groups = [[1, 1, 1], [1, 1, 1]],nums = [1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[-1, -2, -3], [-3, -4, -5], [-5, -6, -7]],nums = [-1, -2, -3, -3, -4, -5, -5, -6, -7]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1]) == False\n assert candidate(groups = [[0, 1], [1, 2], [2, 3], [3, 4]],nums = [0, 1, 1, 2, 2, 3, 3, 4]) == True\n assert candidate(groups = [[-1, -2, -3], [-4, -5], [-6, -7, -8, -9]],nums = [-1, -2, -3, 0, -4, -5, 1, -6, -7, -8, -9]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5]],nums = [1, 2, 3, 99, 3, 4, 5]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 4, 5, 1, 2, 3, 6, 7, 8, 1, 2, 3]) == True\n assert candidate(groups = [[-1, -2, -3], [-3, -2, -1], [0, 0, 0]],nums = [-1, -2, -3, 0, 0, 0, -3, -2, -1]) == False\n assert candidate(groups = [[1, 2, 3], [1, 2, 3, 4], [4, 5]],nums = [1, 2, 3, 1, 2, 3, 4, 4, 5]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [2, 3, 4], [3, 4, 5, 6]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 2, 3, 3, 4, 4, 5]) == True\n assert candidate(groups = [[-1, -2, -3], [-4, -5, -6]],nums = [-1, -2, -3, -4, -5, -6, -1, -2, -3, -4, -5, -6]) == True\n assert candidate(groups = [[1, 2, 3], [3, 2, 1], [2, 1, 3]],nums = [1, 2, 3, 3, 2, 1, 2, 1, 3]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]],nums = [1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9]) == True\n assert candidate(groups = [[10, 20, 30], [40, 50], [60, 70, 80]],nums = [5, 10, 20, 30, 15, 40, 50, 25, 60, 70, 80]) == True\n assert candidate(groups = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],nums = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 2, 3, 3, 4, 99, 4, 5]) == True\n assert candidate(groups = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7]],nums = [1, 2, 3, 3, 4, 5, 5, 6, 7]) == True\n assert candidate(groups = [[9, 8, 7], [6, 5, 4], [3, 2, 1]],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(groups = [[1, 2, 3], [2, 3, 4], [3, 4, 5]],nums = [1, 2, 3, 2, 3, 4, 3, 4, 5]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5]],nums = [1, 0, 2, 0, 3, 0, 4, 0, 5]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2], [1]],nums = [1, 2, 3, 1, 2, 1]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]],nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4]],nums = [1, 2, 3, 4, 5, 3, 4]) == False\n assert candidate(groups = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [1, 1, 1]],nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1]) == True\n assert candidate(groups = [[1, 1], [2, 2], [1, 1], [2, 2]],nums = [1, 1, 2, 2, 1, 1, 2, 2]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[-10, -20, -30], [-40, -50, -60], [-70, -80, -90]],nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == True\n assert candidate(groups = [[1, 2, 3, 4], [5, 6, 7], [8, 9]],nums = [1, 2, 3, 4, 10, 11, 5, 6, 7, 12, 8, 9]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 3, 4, 5, 2, 3, 4, 5]) == False\n assert candidate(groups = [[1, 2, 3, 4, 5], [5, 6, 7], [8, 9]],nums = [1, 2, 3, 4, 5, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[-1, -2, -3], [-3, -2, -1], [1, 2, 3]],nums = [-1, -2, -3, -3, -2, -1, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [9, 10, 11, 12, 13]],nums = [1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9, 10, 11, 12, 13]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == True\n assert candidate(groups = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5]],nums = [1, 2, 3, 3, 4, 5]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4]],nums = [1, 2, 3, 4, 5]) == False\n assert candidate(groups = [[-1, -2, -3], [-4, -5], [-6, -7, -8]],nums = [-1, -2, -3, 0, -4, -5, 0, -6, -7, -8]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]],nums = [1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9]) == True\n assert candidate(groups = [[10, 20, 30], [20, 30, 40], [30, 40, 50]],nums = [10, 20, 30, 20, 30, 40, 30, 40, 50]) == True\n assert candidate(groups = [[1, 2], [3, 4], [5, 6], [7, 8]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[100, 200], [200, 300], [300, 400], [400, 500]],nums = [100, 200, 200, 300, 300, 400, 400, 500]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [1, 2, 3], [4, 5, 6]],nums = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[-1, -2, -3], [-2, -3, -4], [-3, -4, -5]],nums = [-1, -2, -3, -2, -3, -4, -3, -4, -5]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 3, 4, 5]) == False\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 10, 4, 5, 6, 11, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7]],nums = [1, 2, 3, 4, 5, 6, 7]) == False\n assert candidate(groups = [[100, 200], [300, 400, 500], [600]],nums = [50, 100, 200, 150, 300, 400, 500, 200, 600]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4]],nums = [1, 2, 2, 3, 3, 4, 4]) == True\n assert candidate(groups = [[1, 2], [3, 4], [1, 2]],nums = [1, 2, 3, 4, 1, 2]) == True\n assert candidate(groups = [[1, 1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2], [2, 3]],nums = [1, 2, 3, 1, 2, 2, 3]) == True\n assert candidate(groups = [[9, 8, 7], [6, 5, 4], [3, 2, 1]],nums = [9, 8, 7, 0, 6, 5, 4, 0, 3, 2, 1]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7]],nums = [1, 2, 3, 3, 4, 5, 5, 6, 7]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 9, 8, 7, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(groups = [[10000000], [9999999], [8888888], [7777777]],nums = [10000000, 9999999, 8888888, 7777777]) == True\n assert candidate(groups = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(groups = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]],nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n assert candidate(groups = [[5, 5, 5, 5], [5, 5, 5], [5, 5], [5]],nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5]],nums = [1, 2, 3, 4, 5]) == True\n assert candidate(groups = [[-10, -20, -30], [-40, -50], [-60, -70, -80]],nums = [-10, -20, -30, -40, -50, -60, -70, -80]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5]],nums = [1, 2, 3, 4, 5]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],nums = [1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(groups = [[1, 2], [3, 4, 5, 6], [7, 8]],nums = [1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[10, 20, 30, 40], [50, 60, 70, 80]],nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(groups = [[1, 2], [2, 1], [1, 2], [2, 1]],nums = [1, 2, 2, 1, 1, 2, 2, 1]) == True\n assert candidate(groups = [[-10, -20, -30], [-30, -20, -10]],nums = [-10, -20, -30, -30, -20, -10]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == True\n assert candidate(groups = [[-1, 0, 1], [-2, 0, 2]],nums = [-1, 0, 1, -2, 0, 2, -1, 0, 1]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7]],nums = [99, 1, 2, 3, 99, 3, 4, 5, 99, 5, 6, 7]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5]],nums = [1, 2, 3, 3, 4, 5]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3], [3, 2, 1], [1, 2, 3]],nums = [1, 2, 3, 3, 2, 1, 1, 2, 3]) == True\n assert candidate(groups = [[7, 8, 9], [1, 2, 3], [4, 5, 6]],nums = [7, 8, 9, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6]],nums = [1, 2, 3, 0, 0, 4, 5, 6]) == True\n assert candidate(groups = [[-1, -2, -3], [0, 1, 2], [-3, -2, -1]],nums = [-1, -2, -3, 0, 1, 2, -3, -2, -1]) == True\n assert candidate(groups = [[1, 2, 3], [2, 3, 4]],nums = [1, 2, 3, 4]) == False\n assert candidate(groups = [[9, 8, 7, 6, 5], [4, 3, 2, 1], [0, -1, -2, -3, -4]],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == True\n assert candidate(groups = [[100, 200, 300], [400, 500], [600]],nums = [100, 200, 300, 400, 500, 600]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6]],nums = [1, 2, 3, 99, 4, 5, 6]) == True\n assert candidate(groups = [[1, 1, 1, 1], [1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(groups = [[1, 2, 3], [3, 2, 1]],nums = [1, 2, 3, 3, 2, 1, 1, 2, 3, 3, 2, 1]) == True\n assert candidate(groups = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],nums = [0, 1, 2, 3, 4, 0, 5, 6, 7, 8, 0, 9, 10, 11, 12]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]],nums = [1, 2, 3, 4, 5, 11, 12, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, -1], [1, -1]],nums = [1, -1, 1, -1, 1, -1]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 4, 5, 6, 7, 8, 9, 10], [3, 4, 5, 6, 7, 8, 9, 10, 11]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 3, 4, 5]) == False\n assert candidate(groups = [[1, 2, 3], [4, 5, 6]],nums = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5], [6]],nums = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [0, 1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9]) == True\n assert candidate(groups = [[100, 200, 300], [400, 500], [600, 700, 800, 900]],nums = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == True\n assert candidate(groups = [[1, 1], [1, 1], [1, 1]],nums = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [6, 7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(groups = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n"}, "metadata": {"canonical_parameter_names": ["groups", "nums"], "leetcode_dataset_entry_point": "Solution().canChoose", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canChoose(self, groups: List[List[int]], nums: List[int]) -> bool:", "container": "Solution", "callable": "canChoose", "parameters": [{"name": "groups", "type": "List[List[int]]"}, {"name": "nums", "type": "List[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1765, "task_id": "map-of-highest-peak", "difficulty": "Medium", "problem_description": "You are given an integer matrix isWater of size m x n that represents a map of land and water cells.\n\nIf isWater[i][j] == 0, cell (i, j) is a land cell.\nIf isWater[i][j] == 1, cell (i, j) is a water cell.\n\nYou must assign each cell a height in a way that follows these rules:\n\nThe height of each cell must be non-negative.\nIf the cell is a water cell, its height must be 0.\nAny two adjacent cells must have an absolute height difference of at most 1. A cell is adjacent to another cell if the former is directly north, east, south, or west of the latter (i.e., their sides are touching).\n\nFind an assignment of heights such that the maximum height in the matrix is maximized.\nReturn an integer matrix height of size m x n where height[i][j] is cell (i, j)'s height. If there are multiple solutions, return any of them.\n \nExample 1:\n\n\nInput: isWater = [[0,1],[0,0]]\nOutput: [[1,0],[2,1]]\nExplanation: The image shows the assigned heights of each cell.\nThe blue cell is the water cell, and the green cells are the land cells.\n\nExample 2:\n\n\nInput: isWater = [[0,0,1],[1,0,0],[0,0,0]]\nOutput: [[1,1,0],[0,1,1],[1,2,2]]\nExplanation: A height of 2 is the maximum possible height of any assignment.\nAny height assignment that has a maximum height of 2 while still meeting the rules will also be accepted.\n\n \nConstraints:\n\nm == isWater.length\nn == isWater[i].length\n1 <= m, n <= 1000\nisWater[i][j] is 0 or 1.\nThere is at least one water cell.\n\n \nNote: This question is the same as 542: https://leetcode.com/problems/01-matrix/\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(isWater = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == [[2, 1, 2], [1, 0, 1], [2, 1, 2]]\n assert candidate(isWater = [[0, 1], [0, 0]]) == [[1, 0], [2, 1]]\n assert candidate(isWater = [[1, 1], [1, 1]]) == [[0, 0], [0, 0]]\n assert candidate(isWater = [[0, 0, 1], [1, 0, 0], [0, 0, 0]]) == [[1, 1, 0], [0, 1, 1], [1, 2, 2]]\n assert candidate(isWater = [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\n assert candidate(isWater = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == [[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 3, 2, 3, 4], [3, 2, 1, 2, 1, 2, 3], [2, 1, 0, 1, 0, 1, 2], [3, 2, 1, 2, 1, 2, 3], [4, 3, 2, 3, 2, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[4, 3, 2, 1, 0, 1, 2, 3, 4], [3, 4, 3, 2, 1, 2, 3, 4, 3], [2, 3, 4, 3, 2, 3, 4, 3, 2], [1, 2, 3, 4, 3, 4, 3, 2, 1], [0, 1, 2, 3, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == [[3, 2, 1, 2, 3], [2, 1, 0, 1, 2], [1, 0, 1, 0, 1], [2, 1, 0, 1, 2], [3, 2, 1, 2, 3]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 4], [1, 2, 1, 2, 3, 3], [2, 1, 0, 1, 2, 2], [3, 2, 1, 2, 2, 1], [4, 3, 2, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]]) == [[0, 1, 2, 1, 0, 1, 2, 1, 0], [1, 2, 3, 2, 1, 2, 3, 2, 1], [2, 3, 4, 3, 2, 3, 4, 3, 2], [3, 4, 5, 4, 3, 4, 5, 4, 3], [4, 5, 6, 5, 4, 5, 6, 5, 4], [3, 4, 5, 4, 3, 4, 5, 4, 3], [2, 3, 4, 3, 2, 3, 4, 3, 2], [1, 2, 3, 2, 1, 2, 3, 2, 1], [0, 1, 2, 1, 0, 1, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[5, 4, 3, 2, 1, 0, 1, 2, 3, 4], [6, 5, 4, 3, 2, 1, 2, 3, 4, 5], [7, 6, 5, 4, 3, 2, 3, 4, 5, 6], [8, 7, 6, 5, 4, 3, 4, 5, 6, 7], [9, 8, 7, 6, 5, 4, 5, 6, 7, 8], [10, 9, 8, 7, 6, 5, 6, 7, 8, 9], [11, 10, 9, 8, 7, 6, 7, 8, 9, 10], [12, 11, 10, 9, 8, 7, 8, 9, 10, 11]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[7, 6, 5, 4, 5, 6, 7, 8, 9, 10], [6, 5, 4, 3, 4, 5, 6, 7, 8, 9], [5, 4, 3, 2, 3, 4, 5, 6, 7, 8], [4, 3, 2, 1, 2, 3, 4, 5, 6, 7], [3, 2, 1, 0, 1, 2, 3, 4, 5, 6], [4, 3, 2, 1, 2, 3, 4, 5, 6, 7], [5, 4, 3, 2, 3, 4, 5, 6, 7, 8], [6, 5, 4, 3, 4, 5, 6, 7, 8, 9], [7, 6, 5, 4, 5, 6, 7, 8, 9, 10], [8, 7, 6, 5, 6, 7, 8, 9, 10, 11]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 8], [2, 3, 4, 5, 6, 7, 8, 9, 8, 7], [3, 4, 5, 6, 7, 8, 9, 8, 7, 6], [4, 5, 6, 7, 8, 9, 8, 7, 6, 5], [5, 6, 7, 8, 9, 8, 7, 6, 5, 4], [6, 7, 8, 9, 8, 7, 6, 5, 4, 3], [7, 8, 9, 8, 7, 6, 5, 4, 3, 2], [8, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[8, 7, 6, 5, 4, 5, 6, 7, 8, 9], [7, 6, 5, 4, 3, 4, 5, 6, 7, 8], [6, 5, 4, 3, 2, 3, 4, 5, 6, 7], [5, 4, 3, 2, 1, 2, 3, 4, 5, 6], [4, 3, 2, 1, 0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 4, 5, 6, 7, 8]]\n assert candidate(isWater = [[0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[3, 2, 1, 0, 1, 2, 3, 4, 5, 6], [2, 1, 0, 1, 2, 3, 4, 5, 6, 7], [1, 0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0]]) == [[2, 1, 2, 1, 2], [1, 0, 1, 0, 1], [2, 1, 2, 1, 2], [1, 0, 1, 0, 1], [2, 1, 2, 1, 2]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == [[10, 9, 8, 7, 6, 7, 8, 9], [9, 8, 7, 6, 5, 6, 7, 8], [8, 7, 6, 5, 4, 5, 6, 7], [7, 6, 5, 4, 3, 4, 5, 6], [6, 5, 4, 3, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4], [4, 3, 2, 1, 0, 1, 2, 3], [5, 4, 3, 2, 1, 2, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[2, 1, 2, 1, 2, 3], [1, 0, 1, 0, 1, 2], [2, 1, 2, 1, 2, 3], [1, 0, 1, 0, 1, 2], [2, 1, 2, 1, 2, 3]]\n assert candidate(isWater = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4], [1, 2, 3, 4, 3], [2, 3, 4, 3, 2], [3, 4, 3, 2, 1], [4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 3, 2, 3], [3, 2, 1, 2, 1, 2], [2, 1, 0, 1, 0, 1], [3, 2, 1, 2, 1, 2], [4, 3, 2, 3, 2, 3], [5, 4, 3, 4, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 3, 4, 3, 2, 3, 4, 5], [3, 2, 1, 2, 3, 2, 1, 2, 3, 4], [2, 1, 0, 1, 2, 1, 0, 1, 2, 3], [3, 2, 1, 2, 3, 2, 1, 2, 3, 4], [3, 2, 1, 2, 3, 2, 1, 2, 3, 4], [2, 1, 0, 1, 2, 1, 0, 1, 2, 3], [3, 2, 1, 2, 3, 2, 1, 2, 3, 4], [4, 3, 2, 3, 2, 3, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4, 5, 6], [4, 3, 2, 1, 0, 1, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5, 4, 3, 4, 5], [5, 4, 3, 2, 3, 4, 3, 2, 3, 4], [4, 3, 2, 1, 2, 3, 2, 1, 2, 3], [3, 2, 1, 0, 1, 2, 1, 0, 1, 2], [4, 3, 2, 1, 2, 3, 2, 1, 2, 3], [4, 3, 2, 1, 2, 3, 2, 1, 2, 3], [3, 2, 1, 0, 1, 2, 1, 0, 1, 2], [4, 3, 2, 1, 2, 3, 2, 1, 2, 3]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 4], [1, 2, 3, 4, 4, 3], [2, 3, 4, 4, 3, 2], [3, 4, 4, 3, 2, 1], [4, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 3, 4, 5, 6], [5, 4, 3, 2, 2, 3, 4, 5], [4, 3, 2, 1, 1, 2, 3, 4], [3, 2, 1, 0, 0, 1, 2, 3], [3, 2, 1, 0, 0, 1, 2, 3], [4, 3, 2, 1, 1, 2, 3, 4], [5, 4, 3, 2, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, 1], [7, 6, 5, 4, 3, 2, 1, 0, 1, 2], [6, 5, 4, 3, 2, 1, 0, 1, 2, 3], [5, 4, 3, 2, 1, 0, 1, 2, 3, 4], [4, 3, 2, 1, 0, 1, 2, 3, 4, 5], [3, 2, 1, 0, 1, 2, 3, 4, 5, 6], [2, 1, 0, 1, 2, 3, 4, 5, 6, 7], [1, 0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 2, 3, 4], [1, 2, 1, 2, 1, 2, 3], [2, 1, 0, 1, 0, 1, 2], [3, 2, 1, 0, 1, 2, 3], [2, 1, 0, 1, 0, 1, 2], [3, 2, 1, 2, 1, 2, 1], [4, 3, 2, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 3, 4, 5, 6, 7], [2, 3, 4, 3, 2, 3, 4, 5, 6], [3, 4, 3, 2, 1, 2, 3, 4, 5], [4, 3, 2, 1, 0, 1, 2, 3, 4], [5, 4, 3, 2, 1, 2, 3, 4, 3], [6, 5, 4, 3, 2, 3, 4, 3, 2], [7, 6, 5, 4, 3, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 4], [2, 3, 4, 5, 4, 3], [3, 4, 5, 4, 3, 2], [4, 5, 4, 3, 2, 1], [5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 4], [1, 2, 3, 4, 5, 4, 3], [2, 3, 4, 5, 4, 3, 2], [3, 4, 5, 4, 3, 2, 1], [4, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0]]) == [[2, 1, 0, 1, 2, 2], [1, 2, 1, 2, 2, 1], [0, 1, 2, 2, 1, 0], [1, 2, 1, 2, 2, 1], [2, 1, 0, 1, 2, 2]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5], [5, 4, 3, 2, 3, 4], [4, 3, 2, 1, 2, 3], [3, 2, 1, 0, 1, 2], [4, 3, 2, 1, 2, 3], [5, 4, 3, 2, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == [[5, 4, 3, 2, 1, 0], [4, 3, 2, 1, 0, 1], [3, 2, 1, 0, 1, 2], [2, 1, 0, 1, 2, 3], [1, 0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[5, 4, 3, 2, 1, 0, 1, 2, 3, 4], [5, 4, 3, 2, 2, 1, 2, 3, 4, 5], [4, 3, 2, 1, 2, 2, 3, 4, 5, 4], [3, 2, 1, 0, 1, 2, 3, 4, 4, 3], [4, 3, 2, 1, 2, 3, 4, 4, 3, 2], [5, 4, 3, 2, 3, 4, 4, 3, 2, 1], [6, 5, 4, 3, 4, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 3, 4, 5], [3, 2, 1, 2, 3, 4], [2, 1, 0, 1, 2, 3], [3, 2, 1, 2, 3, 4], [4, 3, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5, 6, 7, 8], [5, 4, 3, 2, 3, 4, 5, 6, 7], [4, 3, 2, 1, 2, 3, 4, 5, 6], [3, 2, 1, 0, 1, 2, 3, 4, 5], [4, 3, 2, 1, 2, 3, 4, 5, 6], [5, 4, 3, 2, 3, 4, 5, 6, 7], [6, 5, 4, 3, 4, 5, 6, 7, 8], [7, 6, 5, 4, 5, 6, 7, 8, 9], [8, 7, 6, 5, 6, 7, 8, 9, 10]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2], [18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3], [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5], [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6], [22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7], [23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8], [24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9], [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10], [26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12], [28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13], [29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14], [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0]]) == [[2, 1, 2, 3, 4], [1, 0, 1, 2, 3], [2, 1, 2, 1, 2], [3, 2, 1, 0, 1], [4, 3, 2, 1, 2]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 4, 3, 2, 1, 0], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 7, 6, 5, 4, 3], [3, 4, 5, 6, 7, 7, 6, 5, 4, 3], [2, 3, 4, 5, 6, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [0, 1, 2, 3, 4, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == [[2, 1, 2, 3, 3, 2, 1, 2], [1, 0, 1, 2, 2, 1, 0, 1], [2, 1, 2, 3, 3, 2, 1, 2], [3, 2, 3, 4, 4, 3, 2, 3], [2, 1, 2, 3, 3, 2, 1, 2], [1, 0, 1, 2, 2, 1, 0, 1], [2, 1, 2, 3, 3, 2, 1, 2], [3, 2, 3, 4, 4, 3, 2, 3]]\n assert candidate(isWater = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == [[5, 4, 3, 4, 5], [4, 3, 2, 3, 4], [3, 2, 1, 2, 3], [2, 1, 0, 1, 2], [3, 2, 1, 2, 3]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == [[3, 2, 1, 2, 3], [2, 1, 0, 1, 2], [3, 2, 1, 2, 3], [4, 3, 2, 3, 4], [5, 4, 3, 4, 5]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 3, 2, 1, 0], [1, 2, 3, 4, 4, 3, 2, 1], [2, 3, 4, 5, 5, 4, 3, 2], [3, 4, 5, 6, 6, 5, 4, 3], [3, 4, 5, 6, 6, 5, 4, 3], [2, 3, 4, 5, 5, 4, 3, 2], [1, 2, 3, 4, 4, 3, 2, 1], [0, 1, 2, 3, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 6], [2, 3, 4, 5, 6, 7, 6, 5], [3, 4, 5, 6, 7, 6, 5, 4], [4, 5, 6, 7, 6, 5, 4, 3], [5, 6, 7, 6, 5, 4, 3, 2], [6, 7, 6, 5, 4, 3, 2, 1], [7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == [[2, 1, 1, 1, 1, 2], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [2, 1, 1, 1, 1, 2]]\n assert candidate(isWater = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]]) == [[0, 1, 2, 1, 0], [1, 2, 3, 2, 1], [1, 2, 3, 2, 1], [0, 1, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7], [6, 5, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8], [5, 4, 3, 4, 5, 4, 3, 4, 5, 6, 7, 8, 9], [4, 3, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 10], [3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [4, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [5, 4, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [6, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2], [9, 8, 7, 6, 5, 4, 3], [10, 9, 8, 7, 6, 5, 4], [11, 10, 9, 8, 7, 6, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 2, 3, 4], [3, 2, 1, 1, 2, 3], [2, 1, 0, 0, 1, 2], [2, 1, 0, 0, 1, 2], [3, 2, 1, 1, 2, 3], [4, 3, 2, 2, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5, 6], [5, 4, 3, 2, 3, 4, 5], [4, 3, 2, 1, 2, 3, 4], [3, 2, 1, 0, 1, 2, 3], [4, 3, 2, 1, 2, 3, 4], [5, 4, 3, 2, 3, 4, 5]]\n assert candidate(isWater = [[1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1]]) == [[0, 1, 0, 1, 0, 1, 0], [1, 2, 1, 2, 1, 2, 1], [0, 1, 0, 1, 0, 1, 0], [1, 2, 1, 2, 1, 2, 1], [0, 1, 0, 1, 0, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 1, 0, 1], [3, 2, 3, 2, 1, 2], [2, 1, 2, 3, 2, 3], [1, 0, 1, 2, 3, 4], [2, 1, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0]]) == [[4, 3, 2, 1, 0, 1], [3, 2, 1, 0, 1, 2], [2, 1, 0, 1, 0, 1], [1, 0, 1, 2, 1, 0], [0, 1, 0, 1, 2, 1], [1, 2, 1, 0, 1, 2]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 3, 3, 4, 5, 6], [5, 4, 3, 2, 2, 2, 3, 4, 5], [4, 3, 2, 1, 1, 1, 2, 3, 4], [3, 2, 1, 0, 0, 0, 1, 2, 3], [3, 2, 1, 0, 0, 0, 1, 2, 3], [3, 2, 1, 0, 0, 0, 1, 2, 3], [4, 3, 2, 1, 1, 1, 2, 3, 4], [5, 4, 3, 2, 2, 2, 3, 4, 5], [6, 5, 4, 3, 3, 3, 4, 5, 6]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 4, 3, 2, 1, 0], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 7, 6, 5, 4, 3], [4, 5, 6, 7, 8, 8, 7, 6, 5, 4], [4, 5, 6, 7, 8, 8, 7, 6, 5, 4], [3, 4, 5, 6, 7, 7, 6, 5, 4, 3], [2, 3, 4, 5, 6, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [0, 1, 2, 3, 4, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[3, 2, 3, 2, 3, 4], [2, 1, 2, 1, 2, 3], [1, 0, 1, 0, 1, 2], [2, 1, 2, 1, 2, 3], [3, 2, 3, 2, 3, 4]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0], [1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3], [4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4], [5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5], [6, 7, 8, 9, 10, 11, 12, 13, 12, 11, 10, 9, 8, 7, 6], [7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 8, 7], [6, 7, 8, 9, 10, 11, 12, 13, 12, 11, 10, 9, 8, 7, 6], [5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5], [4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4], [3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3], [2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1], [0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == [[1, 0, 1, 2, 3, 3, 4], [2, 1, 2, 3, 3, 2, 3], [3, 2, 3, 3, 2, 1, 2], [4, 3, 3, 2, 1, 0, 1], [5, 4, 4, 3, 2, 1, 2], [6, 5, 5, 4, 3, 2, 3]]\n assert candidate(isWater = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == [[3, 2, 1, 2, 3], [2, 1, 0, 1, 2], [3, 2, 1, 2, 3], [4, 3, 2, 3, 4]]\n assert candidate(isWater = [[0, 1, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == [[1, 0, 1, 2, 3], [1, 1, 2, 3, 3], [0, 1, 2, 3, 2], [1, 2, 3, 2, 1], [2, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 2, 1, 0, 1, 2, 3], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4], [8, 7, 6, 5, 4, 3, 2, 3, 4, 5], [9, 8, 7, 6, 5, 4, 3, 4, 5, 6], [10, 9, 8, 7, 6, 5, 4, 5, 6, 7], [11, 10, 9, 8, 7, 6, 5, 6, 7, 8], [12, 11, 10, 9, 8, 7, 6, 7, 8, 9], [13, 12, 11, 10, 9, 8, 7, 8, 9, 10]]\n assert candidate(isWater = [[0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0]]) == [[4, 3, 2, 1, 0, 1, 2, 3, 4], [3, 4, 3, 2, 1, 2, 3, 4, 3], [2, 3, 4, 3, 2, 3, 4, 3, 2], [1, 2, 3, 4, 3, 4, 3, 2, 1], [0, 1, 2, 3, 4, 3, 2, 1, 0], [1, 2, 3, 4, 3, 4, 3, 2, 1], [2, 3, 4, 3, 2, 3, 4, 3, 2], [3, 4, 3, 2, 1, 2, 3, 4, 3], [4, 3, 2, 1, 0, 1, 2, 3, 4]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 7], [1, 2, 3, 4, 5, 6, 7, 8, 7, 6], [2, 3, 4, 5, 6, 7, 8, 7, 6, 5], [3, 4, 5, 6, 7, 8, 7, 6, 5, 4], [4, 5, 6, 7, 8, 7, 6, 5, 4, 3], [5, 6, 7, 8, 7, 6, 5, 4, 3, 2], [6, 7, 8, 7, 6, 5, 4, 3, 2, 1], [7, 8, 7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]]) == [[0, 1, 2, 1, 0], [1, 2, 3, 2, 1], [2, 3, 4, 3, 2], [1, 2, 3, 2, 1], [0, 1, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[10, 9, 8, 7, 6, 5, 4, 5, 6, 7, 6, 5, 4, 5, 6, 7, 8, 9, 10, 11], [9, 8, 7, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 9, 10], [8, 7, 6, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8], [6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8], [6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 5, 6, 7, 6, 5, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 6, 7, 8, 7, 6, 5, 6, 7, 8, 9, 10, 11, 12], [12, 11, 10, 9, 8, 7, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9, 10, 11, 12, 13], [13, 12, 11, 10, 9, 8, 7, 8, 9, 10, 9, 8, 7, 8, 9, 10, 11, 12, 13, 14], [14, 13, 12, 11, 10, 9, 8, 9, 10, 11, 10, 9, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 10, 11, 12, 11, 10, 9, 10, 11, 12, 13, 14, 15, 16], [16, 15, 14, 13, 12, 11, 10, 11, 12, 13, 12, 11, 10, 11, 12, 13, 14, 15, 16, 17], [17, 16, 15, 14, 13, 12, 11, 12, 13, 14, 13, 12, 11, 12, 13, 14, 15, 16, 17, 18]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5, 6, 7], [5, 4, 3, 2, 3, 4, 5, 6], [4, 3, 2, 1, 2, 3, 4, 5], [3, 2, 1, 0, 1, 2, 3, 4], [4, 3, 2, 1, 2, 3, 4, 5], [5, 4, 3, 2, 3, 4, 5, 6], [6, 5, 4, 3, 4, 5, 6, 7], [7, 6, 5, 4, 5, 6, 7, 8]]\n"}, "metadata": {"canonical_parameter_names": ["isWater"], "leetcode_dataset_entry_point": "Solution().highestPeak", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def highestPeak(self, isWater: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "highestPeak", "parameters": [{"name": "isWater", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1766, "task_id": "tree-of-coprimes", "difficulty": "Hard", "problem_description": "There is a tree (i.e., a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. Each node has a value associated with it, and the root of the tree is node 0.\nTo represent this tree, you are given an integer array nums and a 2D array edges. Each nums[i] represents the ith node's value, and each edges[j] = [uj, vj] represents an edge between nodes uj and vj in the tree.\nTwo values x and y are coprime if gcd(x, y) == 1 where gcd(x, y) is the greatest common divisor of x and y.\nAn ancestor of a node i is any other node on the shortest path from node i to the root. A node is not considered an ancestor of itself.\nReturn an array ans of size n, where ans[i] is the closest ancestor to node i such that nums[i] and nums[ans[i]] are coprime, or -1 if there is no such ancestor.\n \nExample 1:\n\n\nInput: nums = [2,3,3,2], edges = [[0,1],[1,2],[1,3]]\nOutput: [-1,0,0,1]\nExplanation: In the above figure, each node's value is in parentheses.\n- Node 0 has no coprime ancestors.\n- Node 1 has only one ancestor, node 0. Their values are coprime (gcd(2,3) == 1).\n- Node 2 has two ancestors, nodes 1 and 0. Node 1's value is not coprime (gcd(3,3) == 3), but node 0's\n value is (gcd(2,3) == 1), so node 0 is the closest valid ancestor.\n- Node 3 has two ancestors, nodes 1 and 0. It is coprime with node 1 (gcd(3,2) == 1), so node 1 is its\n closest valid ancestor.\n\nExample 2:\n\n\nInput: nums = [5,6,10,2,3,6,15], edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]]\nOutput: [-1,0,-1,0,0,0,-1]\n\n \nConstraints:\n\nnums.length == n\n1 <= nums[i] <= 50\n1 <= n <= 105\nedges.length == n - 1\nedges[j].length == 2\n0 <= uj, vj < n\nuj != vj\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 3, 3, 2],edges = [[0, 1], [1, 2], [1, 3]]) == [-1, 0, 0, 1]\n assert candidate(nums = [5, 6, 10, 2, 3, 6, 15],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == [-1, 0, -1, 0, 0, 0, -1]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4]\n assert candidate(nums = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 5, 1, 11],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]\n assert candidate(nums = [15, 10, 5, 2, 3, 6, 15, 30, 45, 60],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [5, 8], [6, 9]]) == [-1, -1, -1, 0, 1, 2, -1, -1, -1, -1]\n assert candidate(nums = [49, 42, 35, 28, 21, 14, 7, 1, 49, 42],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8], [6, 9]]) == [-1, -1, -1, -1, -1, -1, -1, 3, -1, -1]\n assert candidate(nums = [7, 11, 13, 5, 3, 2, 8, 9, 10, 12],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 4, 2]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30], [15, 31], [15, 32], [16, 33], [16, 34], [17, 35], [17, 36], [18, 37], [18, 38], [19, 39], [19, 40]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14]]) == [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, -1, -1, -1]\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [3, 9, 27, 81, 3, 9, 27, 3, 9, 27],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [4, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [15, 10, 6, 9, 12, 18, 21, 30, 24, 33],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [41, 37, 43, 47, 29, 31, 37, 41, 43, 47, 29, 31, 37, 41, 43, 47, 29, 31, 37, 41],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 1, 2, 5, 6, 6, 7, 7, 8, 8, 9]\n assert candidate(nums = [47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]\n assert candidate(nums = [31, 37, 41, 43, 47, 53, 59, 61, 67, 71],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [5, 8], [6, 9]]) == [-1, 0, 0, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [47, 37, 41, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6]\n assert candidate(nums = [2, 3, 5, 2, 3, 5, 2, 3, 5, 2, 3, 5, 2, 3, 5, 2, 3, 5, 2, 3, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20]]) == [-1, 0, 0, 1, 0, 0, 2, 3, 3, 4, 0, 0, 5, 6, 6, 7, 3, 3, 8, 9, 9]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30], [15, 31], [15, 32], [16, 33], [16, 34], [17, 35], [17, 36], [18, 37], [18, 38], [19, 39], [19, 40], [20, 41], [20, 42], [21, 43], [21, 44], [22, 45], [22, 46], [23, 47], [23, 48], [24, 49], [24, 50]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [7, 5, 6, 3, 5, 3, 7, 11, 13, 17],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [5, 8], [6, 9]]) == [-1, 0, 0, 1, 0, 0, 2, 3, 5, 6]\n assert candidate(nums = [30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4]\n assert candidate(nums = [29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19]]) == [-1, 0, 0, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11]]) == [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [5, 8], [6, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [41, 43, 47, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14]]) == [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6]\n"}, "metadata": {"canonical_parameter_names": ["nums", "edges"], "leetcode_dataset_entry_point": "Solution().getCoprimes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getCoprimes(self, nums: list[int], edges: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "getCoprimes", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1768, "task_id": "merge-strings-alternately", "difficulty": "Easy", "problem_description": "You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string.\\r\n\\r\nReturn the merged string.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: word1 = \"abc\", word2 = \"pqr\"\\r\nOutput: \"apbqcr\"\\r\nExplanation: The merged string will be merged as so:\\r\nword1: a b c\\r\nword2: p q r\\r\nmerged: a p b q c r\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: word1 = \"ab\", word2 = \"pqrs\"\\r\nOutput: \"apbqrs\"\\r\nExplanation: Notice that as word2 is longer, \"rs\" is appended to the end.\\r\nword1: a b \\r\nword2: p q r s\\r\nmerged: a p b q r s\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: word1 = \"abcd\", word2 = \"pq\"\\r\nOutput: \"apbqcd\"\\r\nExplanation: Notice that as word1 is longer, \"cd\" is appended to the end.\\r\nword1: a b c d\\r\nword2: p q \\r\nmerged: a p b q c d\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= word1.length, word2.length <= 100\\r\n\tword1 and word2 consist of lowercase English letters.\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"a\",word2 = \"b\") == \"ab\"\n assert candidate(word1 = \"abcd\",word2 = \"pq\") == \"apbqcd\"\n assert candidate(word1 = \"ab\",word2 = \"pqrs\") == \"apbqrs\"\n assert candidate(word1 = \"\",word2 = \"uvw\") == \"uvw\"\n assert candidate(word1 = \"x\",word2 = \"y\") == \"xy\"\n assert candidate(word1 = \"hello\",word2 = \"world\") == \"hweolrllod\"\n assert candidate(word1 = \"a\",word2 = \"bcd\") == \"abcd\"\n assert candidate(word1 = \"abcde\",word2 = \"fgh\") == \"afbgchde\"\n assert candidate(word1 = \"abc\",word2 = \"pqr\") == \"apbqcr\"\n assert candidate(word1 = \"abcd\",word2 = \"e\") == \"aebcd\"\n assert candidate(word1 = \"xyz\",word2 = \"\") == \"xyz\"\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(word1 = \"a\",word2 = \"bcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(word1 = \"thisisateststring\",word2 = \"anotheronehere\") == \"tahniostihseartoensethsetrreing\"\n assert candidate(word1 = \"aabbccdd\",word2 = \"eeffgg\") == \"aeaebfbfcgcgdd\"\n assert candidate(word1 = \"complex\",word2 = \"strings\") == \"csotmrpilnegxs\"\n assert candidate(word1 = \"xyz\",word2 = \"abcde\") == \"xaybzcde\"\n assert candidate(word1 = \"abcdefgh\",word2 = \"ijkl\") == \"aibjckdlefgh\"\n assert candidate(word1 = \"abcdefghijk\",word2 = \"lmnopqrstuvwxyz\") == \"albmcndoepfqgrhsitjukvwxyz\"\n assert candidate(word1 = \"abcdefghij\",word2 = \"klmnopqrstuvwxyz\") == \"akblcmdneofpgqhrisjtuvwxyz\"\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxy\",word2 = \"z\") == \"azbcdefghijklmnopqrstuvwxy\"\n assert candidate(word1 = \"quick\",word2 = \"brownfox\") == \"qburiocwknfox\"\n assert candidate(word1 = \"onetwothreefour\",word2 = \"five\") == \"ofnievtewothreefour\"\n assert candidate(word1 = \"overlap\",word2 = \"lapping\") == \"olvaeprplianpg\"\n assert candidate(word1 = \"\",word2 = \"\") == \"\"\n assert candidate(word1 = \"python\",word2 = \"java\") == \"pjyatvhaon\"\n assert candidate(word1 = \"abcdefgh\",word2 = \"ijklmnopqrstuv\") == \"aibjckdlemfngohpqrstuv\"\n assert candidate(word1 = \"different\",word2 = \"length\") == \"dliefnfgetrhent\"\n assert candidate(word1 = \"abcdefghij\",word2 = \"klmnopqrst\") == \"akblcmdneofpgqhrisjt\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"zyxwzyxwzyxw\") == \"azbycxdwazbycxdwazbycxdw\"\n assert candidate(word1 = \"longerfirstword\",word2 = \"short\") == \"lsohnogretrfirstword\"\n assert candidate(word1 = \"abcdefg\",word2 = \"hijklmnop\") == \"ahbicjdkelfmgnop\"\n assert candidate(word1 = \"abcdef\",word2 = \"ghijklmnopqrstuvwxyz\") == \"agbhcidjekflmnopqrstuvwxyz\"\n assert candidate(word1 = \"xyz\",word2 = \"abcdefg\") == \"xaybzcdefg\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"efghefghefghefgh\") == \"aebfcgdhaebfcgdhaebfcgdhefgh\"\n assert candidate(word1 = \"short\",word2 = \"longersecondword\") == \"slhoonrgtersecondword\"\n assert candidate(word1 = \"\",word2 = \"notempty\") == \"notempty\"\n assert candidate(word1 = \"notempty\",word2 = \"\") == \"notempty\"\n assert candidate(word1 = \"\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"gggghhhhiiii\") == \"agagbgbgchchdhdheieififi\"\n assert candidate(word1 = \"\",word2 = \"abcde\") == \"abcde\"\n assert candidate(word1 = \"a1b2c3d4\",word2 = \"e5f6g7\") == \"ae15bf26cg37d4\"\n assert candidate(word1 = \"oddlength\",word2 = \"evenlengths\") == \"oedvdelnelnegntghths\"\n assert candidate(word1 = \"same\",word2 = \"size\") == \"ssaimzee\"\n assert candidate(word1 = \"abcdefg\",word2 = \"hijklmnopqrstuvwxyz\") == \"ahbicjdkelfmgnopqrstuvwxyz\"\n assert candidate(word1 = \"aabbccddeeffgghhiijj\",word2 = \"kkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"akakblblcmcmdndneoeofpfpgqgqhrhrisisjtjtuuvvwwxxyyzz\"\n assert candidate(word1 = \"hello\",word2 = \"worldwide\") == \"hweolrllodwide\"\n assert candidate(word1 = \"xyzxyzxyz\",word2 = \"abcabcabc\") == \"xaybzcxaybzcxaybzc\"\n assert candidate(word1 = \"abcdxyz\",word2 = \"efghwvu\") == \"aebfcgdhxwyvzu\"\n assert candidate(word1 = \"short\",word2 = \"averylongstring\") == \"sahvoerrtylongstring\"\n assert candidate(word1 = \"hello\",word2 = \"worldthisisaverylongstring\") == \"hweolrllodthisisaverylongstring\"\n assert candidate(word1 = \"abcdefg\",word2 = \"hijkl\") == \"ahbicjdkelfg\"\n assert candidate(word1 = \"abcdef\",word2 = \"ghijklmnop\") == \"agbhcidjekflmnop\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"xyzxyzxyzxyz\") == \"axbyczdxaybzcxdyazbxcydz\"\n assert candidate(word1 = \"averyveryverylongword\",word2 = \"short\") == \"asvheorrytveryverylongword\"\n assert candidate(word1 = \"longerword\",word2 = \"short\") == \"lsohnogretrword\"\n assert candidate(word1 = \"hello\",word2 = \"world!\") == \"hweolrllod!\"\n assert candidate(word1 = \"nonempty\",word2 = \"\") == \"nonempty\"\n assert candidate(word1 = \"longstringwithmorecharacters\",word2 = \"shortstr\") == \"lsohnogrsttsrtirngwithmorecharacters\"\n assert candidate(word1 = \"abcdef\",word2 = \"zyxwvu\") == \"azbycxdwevfu\"\n assert candidate(word1 = \"onlyone\",word2 = \"\") == \"onlyone\"\n assert candidate(word1 = \"xyz\",word2 = \"uvw\") == \"xuyvzw\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"zzzzyyyxxww\") == \"azazbzbzcycydydxexewfwf\"\n assert candidate(word1 = \"abcdefgh\",word2 = \"ijklmnop\") == \"aibjckdlemfngohp\"\n assert candidate(word1 = \"onetwothree\",word2 = \"four\") == \"ofnoeutrwothree\"\n assert candidate(word1 = \"aabbcc\",word2 = \"ddeeff\") == \"adadbebecfcf\"\n assert candidate(word1 = \"aabbccddeeffgghhiijj\",word2 = \"zzzzzzzzzz\") == \"azazbzbzczczdzdzezezffgghhiijj\"\n assert candidate(word1 = \"abacaxi\",word2 = \"manga\") == \"ambaancgaaxi\"\n assert candidate(word1 = \"onetwothreefour\",word2 = \"fivesix\") == \"ofnievtewsoitxhreefour\"\n assert candidate(word1 = \"one\",word2 = \"twothreefour\") == \"otnweothreefour\"\n assert candidate(word1 = \"alphanumeric123\",word2 = \"characters!@#\") == \"aclhpahraancutmeerrsi!c@1#23\"\n assert candidate(word1 = \"\",word2 = \"nonempty\") == \"nonempty\"\n assert candidate(word1 = \"xyz\",word2 = \"wvutsrqponmlkjihgfedcba\") == \"xwyvzutsrqponmlkjihgfedcba\"\n assert candidate(word1 = \"abcde\",word2 = \"\") == \"abcde\"\n assert candidate(word1 = \"short\",word2 = \"averyverylongwordindeed\") == \"sahvoerrtyverylongwordindeed\"\n assert candidate(word1 = \"xy\",word2 = \"abcdefghijk\") == \"xaybcdefghijk\"\n assert candidate(word1 = \"onetwothree\",word2 = \"fourfivesix\") == \"ofnoeutrwfoitvherseiex\"\n assert candidate(word1 = \"python\",word2 = \"programming\") == \"ppyrtohgornamming\"\n assert candidate(word1 = \"verylongwordthatgoesonandone\",word2 = \"short\") == \"vsehroyrltongwordthatgoesonandone\"\n assert candidate(word1 = \"xyz\",word2 = \"abcdef\") == \"xaybzcdef\"\n assert candidate(word1 = \"merge\",word2 = \"these\") == \"mtehregsee\"\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"z\") == \"azbcdefghijklmnopqrstuvwxyz\"\n assert candidate(word1 = \"xyzlmnop\",word2 = \"qrstuvwx\") == \"xqyrzsltmunvowpx\"\n assert candidate(word1 = \"abcdefgh\",word2 = \"ijklmno\") == \"aibjckdlemfngoh\"\n assert candidate(word1 = \"short\",word2 = \"averyveryverylongword\") == \"sahvoerrtyveryverylongword\"\n assert candidate(word1 = \"averyverylongwordindeed\",word2 = \"short\") == \"asvheorrytverylongwordindeed\"\n assert candidate(word1 = \"equal\",word2 = \"equal\") == \"eeqquuaall\"\n assert candidate(word1 = \"ab\",word2 = \"cd\") == \"acbd\"\n assert candidate(word1 = \"short\",word2 = \"averylongstringthatweneedtocheck\") == \"sahvoerrtylongstringthatweneedtocheck\"\n assert candidate(word1 = \"same\",word2 = \"same\") == \"ssaammee\"\n assert candidate(word1 = \"abcd\",word2 = \"\") == \"abcd\"\n assert candidate(word1 = \"thisisaverylongstring\",word2 = \"hello\") == \"thheilsliosaverylongstring\"\n"}, "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().mergeAlternately", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def mergeAlternately(self, word1: str, word2: str) -> str:", "container": "Solution", "callable": "mergeAlternately", "parameters": [{"name": "word1", "type": "str"}, {"name": "word2", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1769, "task_id": "minimum-number-of-operations-to-move-all-balls-to-each-box", "difficulty": "Medium", "problem_description": "You have n boxes. You are given a binary string boxes of length n, where boxes[i] is '0' if the ith box is empty, and '1' if it contains one ball.\nIn one operation, you can move one ball from a box to an adjacent box. Box i is adjacent to box j if abs(i - j) == 1. Note that after doing so, there may be more than one ball in some boxes.\nReturn an array answer of size n, where answer[i] is the minimum number of operations needed to move all the balls to the ith box.\nEach answer[i] is calculated considering the initial state of the boxes.\n \nExample 1:\n\nInput: boxes = \"110\"\nOutput: [1,1,3]\nExplanation: The answer for each box is as follows:\n1) First box: you will have to move one ball from the second box to the first box in one operation.\n2) Second box: you will have to move one ball from the first box to the second box in one operation.\n3) Third box: you will have to move one ball from the first box to the third box in two operations, and move one ball from the second box to the third box in one operation.\n\nExample 2:\n\nInput: boxes = \"001011\"\nOutput: [11,8,5,4,3,4]\n \nConstraints:\n\nn == boxes.length\n1 <= n <= 2000\nboxes[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(boxes = \"0101010101\") == [25, 20, 17, 14, 13, 12, 13, 14, 17, 20]\n assert candidate(boxes = \"001011\") == [11, 8, 5, 4, 3, 4]\n assert candidate(boxes = \"000111000\") == [12, 9, 6, 3, 2, 3, 6, 9, 12]\n assert candidate(boxes = \"111000\") == [3, 2, 3, 6, 9, 12]\n assert candidate(boxes = \"01010101\") == [16, 12, 10, 8, 8, 8, 10, 12]\n assert candidate(boxes = \"1000000001\") == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(boxes = \"1010101010\") == [20, 17, 14, 13, 12, 13, 14, 17, 20, 25]\n assert candidate(boxes = \"1001001001001\") == [30, 27, 24, 21, 20, 19, 18, 19, 20, 21, 24, 27, 30]\n assert candidate(boxes = \"101010\") == [6, 5, 4, 5, 6, 9]\n assert candidate(boxes = \"1001001\") == [9, 8, 7, 6, 7, 8, 9]\n assert candidate(boxes = \"010101010101\") == [36, 30, 26, 22, 20, 18, 18, 18, 20, 22, 26, 30]\n assert candidate(boxes = \"11111\") == [10, 7, 6, 7, 10]\n assert candidate(boxes = \"1111\") == [6, 4, 4, 6]\n assert candidate(boxes = \"111100001111\") == [44, 38, 34, 32, 32, 32, 32, 32, 32, 34, 38, 44]\n assert candidate(boxes = \"111000111\") == [24, 20, 18, 18, 18, 18, 18, 20, 24]\n assert candidate(boxes = \"0000\") == [0, 0, 0, 0]\n assert candidate(boxes = \"1111111111\") == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(boxes = \"110\") == [1, 1, 3]\n assert candidate(boxes = \"00000\") == [0, 0, 0, 0, 0]\n assert candidate(boxes = \"1000001\") == [6, 6, 6, 6, 6, 6, 6]\n assert candidate(boxes = \"000111\") == [12, 9, 6, 3, 2, 3]\n assert candidate(boxes = \"0000011111000001111100000\") == [120, 110, 100, 90, 80, 70, 62, 56, 52, 50, 50, 50, 50, 50, 50, 50, 52, 56, 62, 70, 80, 90, 100, 110, 120]\n assert candidate(boxes = \"000000111111000000111111\") == [174, 162, 150, 138, 126, 114, 102, 92, 84, 78, 74, 72, 72, 72, 72, 72, 72, 72, 72, 74, 78, 84, 92, 102]\n assert candidate(boxes = \"0101010101010101010101010101\") == [196, 182, 170, 158, 148, 138, 130, 122, 116, 110, 106, 102, 100, 98, 98, 98, 100, 102, 106, 110, 116, 122, 130, 138, 148, 158, 170, 182]\n assert candidate(boxes = \"0101010101010101010101010101010101010101010101010101\") == [676, 650, 626, 602, 580, 558, 538, 518, 500, 482, 466, 450, 436, 422, 410, 398, 388, 378, 370, 362, 356, 350, 346, 342, 340, 338, 338, 338, 340, 342, 346, 350, 356, 362, 370, 378, 388, 398, 410, 422, 436, 450, 466, 482, 500, 518, 538, 558, 580, 602, 626, 650]\n assert candidate(boxes = \"01010101010101010101010101010101010101010101010101\") == [625, 600, 577, 554, 533, 512, 493, 474, 457, 440, 425, 410, 397, 384, 373, 362, 353, 344, 337, 330, 325, 320, 317, 314, 313, 312, 313, 314, 317, 320, 325, 330, 337, 344, 353, 362, 373, 384, 397, 410, 425, 440, 457, 474, 493, 512, 533, 554, 577, 600]\n assert candidate(boxes = \"1001001001001001001001001001001001001001001001001001\") == [459, 443, 427, 411, 397, 383, 369, 357, 345, 333, 323, 313, 303, 295, 287, 279, 273, 267, 261, 257, 253, 249, 247, 245, 243, 243, 243, 243, 245, 247, 249, 253, 257, 261, 267, 273, 279, 287, 295, 303, 313, 323, 333, 345, 357, 369, 383, 397, 411, 427, 443, 459]\n assert candidate(boxes = \"1000100010001\") == [24, 22, 20, 18, 16, 16, 16, 16, 16, 18, 20, 22, 24]\n assert candidate(boxes = \"111000111000111000111\") == [120, 110, 102, 96, 90, 84, 78, 74, 72, 72, 72, 72, 72, 74, 78, 84, 90, 96, 102, 110, 120]\n assert candidate(boxes = \"1101100110011001\") == [61, 54, 49, 44, 41, 40, 39, 38, 39, 42, 45, 48, 53, 60, 67, 74]\n assert candidate(boxes = \"111101010101010101010101010101010101010101010101\") == [578, 554, 532, 512, 494, 476, 460, 444, 430, 416, 404, 392, 382, 372, 364, 356, 350, 344, 340, 336, 334, 332, 332, 332, 334, 336, 340, 344, 350, 356, 364, 372, 382, 392, 404, 416, 430, 444, 460, 476, 494, 512, 532, 552, 574, 596, 620, 644]\n assert candidate(boxes = \"00001111110000\") == [39, 33, 27, 21, 15, 11, 9, 9, 11, 15, 21, 27, 33, 39]\n assert candidate(boxes = \"0000000000000000000000000000000000000000000000001\") == [48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(boxes = \"111000111000111\") == [63, 56, 51, 48, 45, 42, 39, 38, 39, 42, 45, 48, 51, 56, 63]\n assert candidate(boxes = \"00000000000000000000000100000000000000000000000\") == [23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]\n assert candidate(boxes = \"0001000100010001000100010001\") == [105, 98, 91, 84, 79, 74, 69, 64, 61, 58, 55, 52, 51, 50, 49, 48, 49, 50, 51, 52, 55, 58, 61, 64, 69, 74, 79, 84]\n assert candidate(boxes = \"100000000000000000000000000000000000000000000000001\") == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(boxes = \"0000000000000000000000000000000000000000000000000001\") == [51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(boxes = \"10101010101010101010101010101010101010101010\") == [462, 442, 422, 404, 386, 370, 354, 340, 326, 314, 302, 292, 282, 274, 266, 260, 254, 250, 246, 244, 242, 242, 242, 244, 246, 250, 254, 260, 266, 274, 282, 292, 302, 314, 326, 340, 354, 370, 386, 404, 422, 442, 462, 484]\n assert candidate(boxes = \"000010001000100010001\") == [60, 55, 50, 45, 40, 37, 34, 31, 28, 27, 26, 25, 24, 25, 26, 27, 28, 31, 34, 37, 40]\n assert candidate(boxes = \"00101010101010101010101010101\") == [210, 196, 182, 170, 158, 148, 138, 130, 122, 116, 110, 106, 102, 100, 98, 98, 98, 100, 102, 106, 110, 116, 122, 130, 138, 148, 158, 170, 182]\n assert candidate(boxes = \"011100000111000001110000011100000\") == [168, 156, 146, 138, 132, 126, 120, 114, 108, 102, 98, 96, 96, 96, 96, 96, 96, 96, 98, 102, 108, 114, 120, 126, 132, 138, 146, 156, 168, 180, 192, 204, 216]\n assert candidate(boxes = \"110001100011000\") == [33, 29, 27, 25, 23, 21, 21, 23, 25, 27, 29, 33, 39, 45, 51]\n assert candidate(boxes = \"10101010101010101010\") == [90, 82, 74, 68, 62, 58, 54, 52, 50, 50, 50, 52, 54, 58, 62, 68, 74, 82, 90, 100]\n assert candidate(boxes = \"010010001000010000010000001000000000\") == [71, 65, 61, 57, 53, 51, 49, 47, 45, 45, 45, 45, 45, 45, 47, 49, 51, 53, 55, 57, 61, 65, 69, 73, 77, 81, 85, 91, 97, 103, 109, 115, 121, 127, 133, 139]\n assert candidate(boxes = \"11100000000111100000001111\") == [147, 138, 131, 126, 121, 116, 111, 106, 101, 96, 91, 86, 83, 82, 83, 86, 89, 92, 95, 98, 101, 104, 107, 112, 119, 128]\n assert candidate(boxes = \"0010001000100010001\") == [50, 45, 40, 37, 34, 31, 28, 27, 26, 25, 24, 25, 26, 27, 28, 31, 34, 37, 40]\n assert candidate(boxes = \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\") == [112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112]\n assert candidate(boxes = \"1010101010101010101010101\") == [156, 145, 134, 125, 116, 109, 102, 97, 92, 89, 86, 85, 84, 85, 86, 89, 92, 97, 102, 109, 116, 125, 134, 145, 156]\n assert candidate(boxes = \"111100000011110000001111\") == [138, 128, 120, 114, 110, 106, 102, 98, 94, 90, 86, 84, 84, 86, 90, 94, 98, 102, 106, 110, 114, 120, 128, 138]\n assert candidate(boxes = \"1010101010101010101010101010101010101010\") == [380, 362, 344, 328, 312, 298, 284, 272, 260, 250, 240, 232, 224, 218, 212, 208, 204, 202, 200, 200, 200, 202, 204, 208, 212, 218, 224, 232, 240, 250, 260, 272, 284, 298, 312, 328, 344, 362, 380, 400]\n assert candidate(boxes = \"101010101010101010101010101010101010101010101010101010101010\") == [870, 842, 814, 788, 762, 738, 714, 692, 670, 650, 630, 612, 594, 578, 562, 548, 534, 522, 510, 500, 490, 482, 474, 468, 462, 458, 454, 452, 450, 450, 450, 452, 454, 458, 462, 468, 474, 482, 490, 500, 510, 522, 534, 548, 562, 578, 594, 612, 630, 650, 670, 692, 714, 738, 762, 788, 814, 842, 870, 900]\n assert candidate(boxes = \"001001001001001001001001001001001001001001001001001001001\") == [551, 532, 513, 496, 479, 462, 447, 432, 417, 404, 391, 378, 367, 356, 345, 336, 327, 318, 311, 304, 297, 292, 287, 282, 279, 276, 273, 272, 271, 270, 271, 272, 273, 276, 279, 282, 287, 292, 297, 304, 311, 318, 327, 336, 345, 356, 367, 378, 391, 404, 417, 432, 447, 462, 479, 496, 513]\n assert candidate(boxes = \"1101101101101101101101101101101101101101101101101101101101101101101101101101101101101101\") == [2552, 2495, 2440, 2385, 2332, 2281, 2230, 2181, 2134, 2087, 2042, 1999, 1956, 1915, 1876, 1837, 1800, 1765, 1730, 1697, 1666, 1635, 1606, 1579, 1552, 1527, 1504, 1481, 1460, 1441, 1422, 1405, 1390, 1375, 1362, 1351, 1340, 1331, 1324, 1317, 1312, 1309, 1306, 1305, 1306, 1307, 1310, 1315, 1320, 1327, 1336, 1345, 1356, 1369, 1382, 1397, 1414, 1431, 1450, 1471, 1492, 1515, 1540, 1565, 1592, 1621, 1650, 1681, 1714, 1747, 1782, 1819, 1856, 1895, 1936, 1977, 2020, 2065, 2110, 2157, 2206, 2255, 2306, 2359, 2412, 2467, 2524, 2581]\n assert candidate(boxes = \"10100101001010010100101001010010\") == [192, 181, 170, 161, 152, 143, 136, 129, 124, 119, 114, 111, 108, 107, 106, 105, 106, 107, 110, 113, 116, 121, 126, 133, 140, 147, 156, 165, 176, 187, 198, 211]\n assert candidate(boxes = \"1001001001001001001001001001\") == [135, 127, 119, 111, 105, 99, 93, 89, 85, 81, 79, 77, 75, 75, 75, 75, 77, 79, 81, 85, 89, 93, 99, 105, 111, 119, 127, 135]\n assert candidate(boxes = \"0001000010000100001\") == [42, 38, 34, 30, 28, 26, 24, 22, 20, 20, 20, 20, 20, 20, 22, 24, 26, 28, 30]\n assert candidate(boxes = \"0000100000000100000001\") == [38, 35, 32, 29, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(boxes = \"100000000000000000001\") == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(boxes = \"101001010010100101001010\") == [110, 102, 94, 88, 82, 76, 72, 68, 66, 64, 62, 62, 62, 64, 66, 68, 72, 76, 82, 88, 94, 102, 110, 120]\n assert candidate(boxes = \"1111000011110000111100001111\") == [216, 202, 190, 180, 172, 164, 156, 148, 140, 134, 130, 128, 128, 128, 128, 128, 128, 130, 134, 140, 148, 156, 164, 172, 180, 190, 202, 216]\n assert candidate(boxes = \"110100100100110\") == [44, 39, 36, 33, 32, 31, 30, 31, 32, 33, 36, 39, 42, 47, 54]\n assert candidate(boxes = \"1111111111111111111111111111111111111111111111111111\") == [1326, 1276, 1228, 1182, 1138, 1096, 1056, 1018, 982, 948, 916, 886, 858, 832, 808, 786, 766, 748, 732, 718, 706, 696, 688, 682, 678, 676, 676, 678, 682, 688, 696, 706, 718, 732, 748, 766, 786, 808, 832, 858, 886, 916, 948, 982, 1018, 1056, 1096, 1138, 1182, 1228, 1276, 1326]\n assert candidate(boxes = \"0000000000101010101010101010101010100000000\") == [286, 273, 260, 247, 234, 221, 208, 195, 182, 169, 156, 145, 134, 125, 116, 109, 102, 97, 92, 89, 86, 85, 84, 85, 86, 89, 92, 97, 102, 109, 116, 125, 134, 145, 156, 169, 182, 195, 208, 221, 234, 247, 260]\n assert candidate(boxes = \"10011001100110011001100110011\") == [217, 204, 191, 178, 167, 158, 149, 140, 133, 128, 123, 118, 115, 114, 113, 112, 113, 116, 119, 122, 127, 134, 141, 148, 157, 168, 179, 190, 203]\n assert candidate(boxes = \"11111111100000000111111110000000011111111\") == [492, 469, 448, 429, 412, 397, 384, 373, 364, 357, 350, 343, 336, 329, 322, 315, 308, 301, 296, 293, 292, 293, 296, 301, 308, 317, 326, 335, 344, 353, 362, 371, 380, 389, 400, 413, 428, 445, 464, 485, 508]\n assert candidate(boxes = \"1010101010101010\") == [56, 50, 44, 40, 36, 34, 32, 32, 32, 34, 36, 40, 44, 50, 56, 64]\n assert candidate(boxes = \"0000110000000000110000000000110000000000110000000000110000000000110000000000110000000000\") == [567, 553, 539, 525, 511, 499, 489, 479, 469, 459, 449, 439, 429, 419, 409, 399, 389, 381, 375, 369, 363, 357, 351, 345, 339, 333, 327, 321, 315, 311, 309, 307, 305, 303, 301, 299, 297, 295, 293, 291, 289, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 315, 321, 327, 333, 339, 345, 351, 357, 363, 369, 375, 381, 389, 399, 409, 419, 429, 439, 449, 459, 469, 479, 489, 499, 511, 525, 539, 553, 567, 581, 595, 609, 623, 637, 651]\n assert candidate(boxes = \"00000000000111111111100000000000\") == [155, 145, 135, 125, 115, 105, 95, 85, 75, 65, 55, 45, 37, 31, 27, 25, 25, 27, 31, 37, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]\n assert candidate(boxes = \"01001010010100101001010010100101001010010100101001\") == [500, 480, 462, 444, 426, 410, 394, 380, 366, 352, 340, 328, 318, 308, 298, 290, 282, 276, 270, 264, 260, 256, 254, 252, 250, 250, 250, 252, 254, 256, 260, 264, 270, 276, 282, 290, 298, 308, 318, 328, 340, 352, 366, 380, 394, 410, 426, 444, 462, 480]\n assert candidate(boxes = \"101010101010101010101010\") == [132, 122, 112, 104, 96, 90, 84, 80, 76, 74, 72, 72, 72, 74, 76, 80, 84, 90, 96, 104, 112, 122, 132, 144]\n assert candidate(boxes = \"11110000111100001111000011110000111100001111000011110000\") == [714, 688, 664, 642, 622, 602, 582, 562, 542, 524, 508, 494, 482, 470, 458, 446, 434, 424, 416, 410, 406, 402, 398, 394, 390, 388, 388, 390, 394, 398, 402, 406, 410, 416, 424, 434, 446, 458, 470, 482, 494, 508, 524, 542, 562, 582, 602, 622, 642, 664, 688, 714, 742, 770, 798, 826]\n assert candidate(boxes = \"10000000001000000000100000000010000000001\") == [100, 97, 94, 91, 88, 85, 82, 79, 76, 73, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100]\n assert candidate(boxes = \"0000011111100000\") == [45, 39, 33, 27, 21, 15, 11, 9, 9, 11, 15, 21, 27, 33, 39, 45]\n assert candidate(boxes = \"11100000000000000000000000000000000000001\") == [43, 41, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117]\n assert candidate(boxes = \"110011001100110011001100110011001100\") == [297, 281, 267, 253, 239, 227, 217, 207, 197, 189, 183, 177, 171, 167, 165, 163, 161, 161, 163, 165, 167, 171, 177, 183, 189, 197, 207, 217, 227, 239, 253, 267, 281, 297, 315, 333]\n assert candidate(boxes = \"01010101010101010101010101010101\") == [256, 240, 226, 212, 200, 188, 178, 168, 160, 152, 146, 140, 136, 132, 130, 128, 128, 128, 130, 132, 136, 140, 146, 152, 160, 168, 178, 188, 200, 212, 226, 240]\n assert candidate(boxes = \"11111111111111111111111111111111\") == [496, 466, 438, 412, 388, 366, 346, 328, 312, 298, 286, 276, 268, 262, 258, 256, 256, 258, 262, 268, 276, 286, 298, 312, 328, 346, 366, 388, 412, 438, 466, 496]\n assert candidate(boxes = \"111111111111111111111111111111111111111111111111\") == [1128, 1082, 1038, 996, 956, 918, 882, 848, 816, 786, 758, 732, 708, 686, 666, 648, 632, 618, 606, 596, 588, 582, 578, 576, 576, 578, 582, 588, 596, 606, 618, 632, 648, 666, 686, 708, 732, 758, 786, 816, 848, 882, 918, 956, 996, 1038, 1082, 1128]\n assert candidate(boxes = \"10000001000001\") == [20, 19, 18, 17, 16, 15, 14, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(boxes = \"00000000000000000000000000000000000000000000000000000000000000000000000000000001\") == [79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(boxes = \"10000000000000000000000000000001\") == [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31]\n assert candidate(boxes = \"1000010000100001000010000100001\") == [105, 100, 95, 90, 85, 80, 77, 74, 71, 68, 65, 64, 63, 62, 61, 60, 61, 62, 63, 64, 65, 68, 71, 74, 77, 80, 85, 90, 95, 100, 105]\n assert candidate(boxes = \"111000111000111000111000111000111000\") == [288, 272, 258, 246, 234, 222, 210, 200, 192, 186, 180, 174, 168, 164, 162, 162, 162, 162, 162, 164, 168, 174, 180, 186, 192, 200, 210, 222, 234, 246, 258, 272, 288, 306, 324, 342]\n assert candidate(boxes = \"00000000000000000001111111111111111111\") == [532, 513, 494, 475, 456, 437, 418, 399, 380, 361, 342, 323, 304, 285, 266, 247, 228, 209, 190, 171, 154, 139, 126, 115, 106, 99, 94, 91, 90, 91, 94, 99, 106, 115, 126, 139, 154, 171]\n"}, "metadata": {"canonical_parameter_names": ["boxes"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minOperations(self, boxes: str) -> list[int]:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "boxes", "type": "str"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1770, "task_id": "maximum-score-from-performing-multiplication-operations", "difficulty": "Hard", "problem_description": "You are given two 0-indexed integer arrays nums and multipliers of size n and m respectively, where n >= m.\nYou begin with a score of 0. You want to perform exactly m operations. On the ith operation (0-indexed) you will:\n\nChoose one integer x from either the start or the end of the array nums.\nAdd multipliers[i] * x to your score.\n \nNote that multipliers[0] corresponds to the first operation, multipliers[1] to the second operation, and so on.\n\n\nRemove x from nums.\n\nReturn the maximum score after performing m operations.\n \nExample 1:\n\nInput: nums = [1,2,3], multipliers = [3,2,1]\nOutput: 14\nExplanation: An optimal solution is as follows:\n- Choose from the end, [1,2,3], adding 3 * 3 = 9 to the score.\n- Choose from the end, [1,2], adding 2 * 2 = 4 to the score.\n- Choose from the end, [1], adding 1 * 1 = 1 to the score.\nThe total score is 9 + 4 + 1 = 14.\nExample 2:\n\nInput: nums = [-5,-3,-3,-2,7,1], multipliers = [-10,-5,3,4,6]\nOutput: 102\nExplanation: An optimal solution is as follows:\n- Choose from the start, [-5,-3,-3,-2,7,1], adding -5 * -10 = 50 to the score.\n- Choose from the start, [-3,-3,-2,7,1], adding -3 * -5 = 15 to the score.\n- Choose from the start, [-3,-2,7,1], adding -3 * 3 = -9 to the score.\n- Choose from the end, [-2,7,1], adding 1 * 4 = 4 to the score.\n- Choose from the end, [-2,7], adding 7 * 6 = 42 to the score. \nThe total score is 50 + 15 - 9 + 4 + 42 = 102.\n\n \nConstraints:\n\nn == nums.length\nm == multipliers.length\n1 <= m <= 300\nm <= n <= 105 \n-1000 <= nums[i], multipliers[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 385\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],multipliers = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 385\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [10, 9, 8, 7, 6]) == 330\n assert candidate(nums = [-1, -2, -3, -4, -5, -6],multipliers = [-1, -2, -3, -4, -5, -6]) == 91\n assert candidate(nums = [-3, -2, -1, 1, 2, 3],multipliers = [1, -1, 1, -1, 1, -1]) == 12\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],multipliers = [1, 2, 3, 4, 5]) == 101\n assert candidate(nums = [100, 200, 300],multipliers = [1, 2]) == 700\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],multipliers = [9, 8, 7]) == 194\n assert candidate(nums = [5, -2, 5, -3, 5, 5],multipliers = [-1, 1, -1, 1, -1, 1]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [1, 2, 3, 4]) == 80\n assert candidate(nums = [-5, -3, -3, -2, 7, 1],multipliers = [-10, -5, 3, 4, 6]) == 102\n assert candidate(nums = [1],multipliers = [1]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5],multipliers = [-1, -2, -3]) == 23\n assert candidate(nums = [-1, -2, -3, -4, -5],multipliers = [1, 2, 3, 4, 5]) == -35\n assert candidate(nums = [10, 20, 30, 40, 50],multipliers = [5, 4, 3, 2, 1]) == 550\n assert candidate(nums = [10, 20, 30, 40, 50],multipliers = [1, 2, 3, 4, 5]) == 550\n assert candidate(nums = [1, 2, 3, 4, 5, 6],multipliers = [1, 2, 3]) == 28\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],multipliers = [1, 2, 3, 4]) == 71\n assert candidate(nums = [1, 2, 3],multipliers = [3, 2, 1]) == 14\n assert candidate(nums = [9, 8, 7, 6, 5],multipliers = [-1, -2, -3]) == -37\n assert candidate(nums = [-1, -2, -3, -4, -5],multipliers = [-1, -2, -3, -4, -5]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5],multipliers = [1, 2, 3]) == 23\n assert candidate(nums = [5, 7, 3, 8, 6],multipliers = [3, 2, 4]) == 60\n assert candidate(nums = [5, 3, 8, 4, 9, 2, 7, 1, 6, 0],multipliers = [10, -20, 30, -40, 50]) == 540\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],multipliers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == -10\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],multipliers = [10, -20, 30, -40, 50]) == 115000\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12],multipliers = [10, 9, 8, 7, 6, 5]) == 105\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 38500\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250],multipliers = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55250\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [5, 3, 8, 1, 6, 9, 2, 7, 4, 10],multipliers = [-1, 2, -3, 4, -5, 6]) == 75\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],multipliers = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 75\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],multipliers = [10, -9, 8, -7, 6, -5, 4, -3, 2, -1]) == 205\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],multipliers = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == -5550\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],multipliers = [-1, -2, -3, -4, -5]) == 185\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],multipliers = [-1, 1, -1, 1, -1, 1]) == 6000\n assert candidate(nums = [1, 100, 1000, 10000, 100000, 1000000],multipliers = [10, 20, 30, 40, 50]) == 50432010\n assert candidate(nums = [5, -3, 8, 2, -7, 6, 1, 4, -9, 11],multipliers = [3, -2, 7, 5, -8, 6]) == 234\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 21250\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [5, 4, 3, 2, 1]) == -350\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],multipliers = [10, -20, 30, -40, 50]) == 115000\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -220\n assert candidate(nums = [-100, -200, -300, 400, 500, 600, -700, 800, -900],multipliers = [10, 20, 30, 40, 50, 60, 70]) == 77000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],multipliers = [-1, -1, -1, -1, -1]) == -5\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],multipliers = [1, 2, 3, 4, 5, 6, 7]) == 52\n assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500],multipliers = [1, -1, 1, -1, 1, -1]) == 2400\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],multipliers = [1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],multipliers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 800\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],multipliers = [1, -1, 1, -1, 1]) == 240\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],multipliers = [5, 10, 15, 20, 25]) == 925\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],multipliers = [29, 27, 25, 23, 21]) == 3165\n assert candidate(nums = [5, 3, 8, 10, 15, 1, 4, 7],multipliers = [10, 20, 30, 40, 50]) == 1500\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],multipliers = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == -30500\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],multipliers = [-1, 2, -3, 4, -5]) == 110\n assert candidate(nums = [5, 2, 1, 4, 3],multipliers = [-1, -2, -3]) == -12\n assert candidate(nums = [500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, 1000, 900, 800, 700],multipliers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 35400\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == -22000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 2485\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [10, 20, 30, 40, 50]) == -5000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],multipliers = [-10, 9, -8, 7, -6, 5, -4, 3, -2, 1]) == 480\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10],multipliers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 85\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],multipliers = [10, 20, 30, 40, 50]) == 2150\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -22000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],multipliers = [1, -1, 1, -1, 1, -1, 1]) == 48\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],multipliers = [-5, 10, -15, 20, -25, 30]) == 4625\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 155\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],multipliers = [15, 14, 13, 12, 11]) == 855\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50],multipliers = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 300\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [20, 19, 18, 17, 16, 15, 14]) == 2051\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],multipliers = [1, 2, 3, 4, 5, 6]) == 15300\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700],multipliers = [1, -2, 3, -4, 5]) == 7500\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],multipliers = [1, 2, -3, 4, -5]) == 1030\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],multipliers = [100, -50, 25, -12, 6]) == 9630\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 821\n assert candidate(nums = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 1925\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],multipliers = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 200\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],multipliers = [1, 2, 3, 4, 5]) == 7000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],multipliers = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 700\n assert candidate(nums = [-5, 3, -1, 2, -4, 6, -7, 8, -9, 10],multipliers = [1, -1, 1, -1, 1, -1]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2670\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -8\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],multipliers = [1, -1, 2, -2, 3]) == 4700\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [1, 2, 3, 4, 5, 6]) == 161\n assert candidate(nums = [5, 1, 4, 3, 2, 6, 7, 8, 9, 10],multipliers = [10, -10, 20, -20, 30]) == 450\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],multipliers = [1, -1, 1, -1, 1, -1]) == 4100\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000, 6000, -6000, 7000, -7000, 8000, -8000, 9000, -9000, 10000, -10000],multipliers = [100, -99, 98, -97, 96, -95, 94, -93, 92, -91, 90, -89, 88, -87, 86, -85, 84, -83, 82, -81]) == 10195000\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 26800\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 0\n assert candidate(nums = [5, 3, 8, -2, 6, 7, -4, 10, 15, -20],multipliers = [1, 2, 3, 4, 5, 6, 7, 8]) == 242\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 75\n assert candidate(nums = [300, -100, 200, -200, 500, -300, 400, -400, 600, -500],multipliers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 61000\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],multipliers = [-30, -29, -28, -27, -26, -25, -24, -23, -22, -21]) == -1320\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [2, -3, 4, -5, 6]) == 211\n assert candidate(nums = [50, 25, 75, 100, -50, -25, -75, -100, 200, 150, 175, 200],multipliers = [10, -5, 2, -1, 3, -2]) == 2750\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],multipliers = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == -220\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 3850\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],multipliers = [-1, -2, -3, -4, -5]) == -550\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],multipliers = [-1, 1, -1, 1, -1, 1, -1, 1]) == 50\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],multipliers = [5, -5, 4, -4, 3, -3]) == 87\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -334\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],multipliers = [100, -100, 100, -100, 100]) == 500000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],multipliers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == -120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1081\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1540\n assert candidate(nums = [5, 3, 8, -2, 6, 7, -4, 10],multipliers = [1, 2, 3, 4, 5]) == 77\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],multipliers = [1, 2, 3, 4, 5]) == 1850\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 54666\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [-1, -2, -3, -4, -5]) == 1150\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100],multipliers = [1, 2, 3, 4, 5]) == 600\n"}, "metadata": {"canonical_parameter_names": ["nums", "multipliers"], "leetcode_dataset_entry_point": "Solution().maximumScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumScore(self, nums: list[int], multipliers: list[int]) -> int:", "container": "Solution", "callable": "maximumScore", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "multipliers", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1771, "task_id": "maximize-palindrome-length-from-subsequences", "difficulty": "Hard", "problem_description": "You are given two strings, word1 and word2. You want to construct a string in the following manner:\n\nChoose some non-empty subsequence subsequence1 from word1.\nChoose some non-empty subsequence subsequence2 from word2.\nConcatenate the subsequences: subsequence1 + subsequence2, to make the string.\n\nReturn the length of the longest palindrome that can be constructed in the described manner. If no palindromes can be constructed, return 0.\nA subsequence of a string s is a string that can be made by deleting some (possibly none) characters from s without changing the order of the remaining characters.\nA palindrome is a string that reads the same forward as well as backward.\n \nExample 1:\n\nInput: word1 = \"cacb\", word2 = \"cbba\"\nOutput: 5\nExplanation: Choose \"ab\" from word1 and \"cba\" from word2 to make \"abcba\", which is a palindrome.\nExample 2:\n\nInput: word1 = \"ab\", word2 = \"ab\"\nOutput: 3\nExplanation: Choose \"ab\" from word1 and \"a\" from word2 to make \"aba\", which is a palindrome.\nExample 3:\n\nInput: word1 = \"aa\", word2 = \"bb\"\nOutput: 0\nExplanation: You cannot construct a palindrome from the described method, so return 0.\n \nConstraints:\n\n1 <= word1.length, word2.length <= 1000\nword1 and word2 consist of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"race\",word2 = \"car\") == 7\n assert candidate(word1 = \"a\",word2 = \"a\") == 2\n assert candidate(word1 = \"aabb\",word2 = \"bbcc\") == 4\n assert candidate(word1 = \"race\",word2 = \"care\") == 7\n assert candidate(word1 = \"abcde\",word2 = \"edcba\") == 10\n assert candidate(word1 = \"madam\",word2 = \"madam\") == 10\n assert candidate(word1 = \"aabb\",word2 = \"bbaa\") == 8\n assert candidate(word1 = \"xyz\",word2 = \"zyx\") == 6\n assert candidate(word1 = \"palindrome\",word2 = \"emordnilap\") == 20\n assert candidate(word1 = \"abcabc\",word2 = \"cbacba\") == 12\n assert candidate(word1 = \"aa\",word2 = \"bb\") == 0\n assert candidate(word1 = \"hello\",word2 = \"world\") == 5\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxcba\") == 12\n assert candidate(word1 = \"cacb\",word2 = \"cbba\") == 5\n assert candidate(word1 = \"mnop\",word2 = \"pqrs\") == 2\n assert candidate(word1 = \"noon\",word2 = \"noon\") == 8\n assert candidate(word1 = \"level\",word2 = \"deified\") == 5\n assert candidate(word1 = \"a\",word2 = \"b\") == 0\n assert candidate(word1 = \"noon\",word2 = \"moon\") == 7\n assert candidate(word1 = \"abcba\",word2 = \"abcba\") == 10\n assert candidate(word1 = \"abcd\",word2 = \"dcba\") == 8\n assert candidate(word1 = \"abc\",word2 = \"def\") == 0\n assert candidate(word1 = \"ab\",word2 = \"ab\") == 3\n assert candidate(word1 = \"xyzzxyzzxyzz\",word2 = \"zzzyzxzzzyzxzzzyx\") == 25\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == 52\n assert candidate(word1 = \"abacax\",word2 = \"xcabab\") == 10\n assert candidate(word1 = \"deeee\",word2 = \"eee\") == 7\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcbajihgfedcba\") == 21\n assert candidate(word1 = \"madam\",word2 = \"rotor\") == 0\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"ffeeddccbbaa\") == 24\n assert candidate(word1 = \"level\",word2 = \"leve\") == 8\n assert candidate(word1 = \"palindrome\",word2 = \"emordnilapracecar\") == 20\n assert candidate(word1 = \"longestpalindrome\",word2 = \"emordnilapstgnol\") == 30\n assert candidate(word1 = \"racecar\",word2 = \"level\") == 3\n assert candidate(word1 = \"step on no pets\",word2 = \"step on no pets\") == 30\n assert candidate(word1 = \"aabbaa\",word2 = \"ccddeee\") == 0\n assert candidate(word1 = \"abc\",word2 = \"cba\") == 6\n assert candidate(word1 = \"xyzzyx\",word2 = \"zyxzyz\") == 7\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxcdb\") == 10\n assert candidate(word1 = \"xyx\",word2 = \"xyx\") == 6\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcba\") == 20\n assert candidate(word1 = \"racecar\",word2 = \"racecar\") == 14\n assert candidate(word1 = \"b\",word2 = \"b\") == 2\n assert candidate(word1 = \"abcdefgh\",word2 = \"hgfedcba\") == 16\n assert candidate(word1 = \"level\",word2 = \"level\") == 10\n assert candidate(word1 = \"aabbccddeeffgg\",word2 = \"ggffeeddccbbaa\") == 28\n assert candidate(word1 = \"aabaaa\",word2 = \"aaabaa\") == 12\n assert candidate(word1 = \"abacaxaba\",word2 = \"xyzzyx\") == 6\n assert candidate(word1 = \"abcdefg\",word2 = \"gfedcba\") == 14\n assert candidate(word1 = \"uniqueletters\",word2 = \"stretteleunik\") == 20\n assert candidate(word1 = \"aaa\",word2 = \"bbb\") == 0\n assert candidate(word1 = \"abcxyz\",word2 = \"zyxcba\") == 12\n assert candidate(word1 = \"abacdfgdcaba\",word2 = \"abacdfgdcaba\") == 22\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"dcbaabcdabcd\") == 14\n assert candidate(word1 = \"aabbaa\",word2 = \"aaabba\") == 11\n assert candidate(word1 = \"aabbccdd\",word2 = \"ddccbbaa\") == 16\n assert candidate(word1 = \"aaaaaa\",word2 = \"bbbbbb\") == 0\n assert candidate(word1 = \"ababababab\",word2 = \"bababababa\") == 20\n assert candidate(word1 = \"step\",word2 = \"onests\") == 7\n assert candidate(word1 = \"abcd\",word2 = \"zyxw\") == 0\n assert candidate(word1 = \"ababab\",word2 = \"bababa\") == 12\n assert candidate(word1 = \"abacaba\",word2 = \"bcbcbcb\") == 9\n assert candidate(word1 = \"palindromeconstruction\",word2 = \"noitcitsnocemordnilap\") == 40\n assert candidate(word1 = \"abcd\",word2 = \"dcbaabcd\") == 8\n assert candidate(word1 = \"racecar\",word2 = \"car\") == 7\n assert candidate(word1 = \"deified\",word2 = \"deified\") == 14\n assert candidate(word1 = \"abcdefg\",word2 = \"hgfedcba\") == 15\n assert candidate(word1 = \"complexstring\",word2 = \"gnirtsxlpmoc\") == 24\n assert candidate(word1 = \"noonnoon\",word2 = \"noonnoon\") == 16\n assert candidate(word1 = \"thisisatest\",word2 = \"tsetasitisth\") == 18\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxwvut\") == 6\n assert candidate(word1 = \"mnopqr\",word2 = \"rstuvw\") == 2\n assert candidate(word1 = \"racecar\",word2 = \"carrace\") == 9\n assert candidate(word1 = \"aabbccdd\",word2 = \"aabbccdd\") == 6\n assert candidate(word1 = \"abababa\",word2 = \"bababab\") == 13\n assert candidate(word1 = \"aaaaabbbbb\",word2 = \"bbbbbbaaaa\") == 19\n assert candidate(word1 = \"xyzz\",word2 = \"zzxy\") == 6\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"cbacbacbacba\") == 24\n assert candidate(word1 = \"ab\",word2 = \"bbaa\") == 5\n assert candidate(word1 = \"qwertyuiop\",word2 = \"poiuytrewq\") == 20\n assert candidate(word1 = \"aaaaabbbbb\",word2 = \"bbbbbbaaaaa\") == 21\n assert candidate(word1 = \"zzzz\",word2 = \"zzzz\") == 8\n assert candidate(word1 = \"xyx\",word2 = \"yxy\") == 5\n assert candidate(word1 = \"repaper\",word2 = \"repaper\") == 14\n assert candidate(word1 = \"reviled\",word2 = \"devil\") == 6\n assert candidate(word1 = \"abcdef\",word2 = \"fedcbaxyz\") == 12\n assert candidate(word1 = \"mississippi\",word2 = \"ississippim\") == 18\n assert candidate(word1 = \"abcdabc\",word2 = \"cbadcbad\") == 14\n assert candidate(word1 = \"rotor\",word2 = \"rotor\") == 10\n assert candidate(word1 = \"abcdabc\",word2 = \"cbadacb\") == 12\n assert candidate(word1 = \"zyxwvutsrqponmlkjihgfedcba\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == 52\n assert candidate(word1 = \"aabbccddeeffgg\",word2 = \"ggffeeddccbaa\") == 26\n assert candidate(word1 = \"xxyyzz\",word2 = \"zzxyyx\") == 10\n assert candidate(word1 = \"xyzyx\",word2 = \"xzyyx\") == 8\n assert candidate(word1 = \"aabbcc\",word2 = \"ccbbaa\") == 12\n assert candidate(word1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",word2 = \"sinoconiovacolcosilicropicoviscounmoneup\") == 49\n assert candidate(word1 = \"aaaabbbb\",word2 = \"bbbbcccc\") == 8\n assert candidate(word1 = \"pqrstu\",word2 = \"utsrqp\") == 12\n assert candidate(word1 = \"mamad\",word2 = \"adam\") == 7\n assert candidate(word1 = \"abcabcabc\",word2 = \"cbacbacba\") == 18\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"abacabadabacaba\") == 30\n assert candidate(word1 = \"refer\",word2 = \"refer\") == 10\n assert candidate(word1 = \"redder\",word2 = \"redder\") == 12\n assert candidate(word1 = \"abacdfgdcaba\",word2 = \"gfdcbba\") == 15\n assert candidate(word1 = \"abcdefghijk\",word2 = \"kjihgfedcba\") == 22\n assert candidate(word1 = \"mnopqr\",word2 = \"rqponm\") == 12\n assert candidate(word1 = \"aabbaa\",word2 = \"bbccbb\") == 6\n assert candidate(word1 = \"thisisaverylongwordtoseetifthelongestpalindrome\",word2 = \"emordnilapelongethtofeesavaloydnevasiht\") == 58\n assert candidate(word1 = \"xyzzxy\",word2 = \"zyxzyxzyx\") == 13\n assert candidate(word1 = \"overlappingword\",word2 = \"drowgnalppero\") == 20\n assert candidate(word1 = \"ab\",word2 = \"ba\") == 4\n assert candidate(word1 = \"zxcvbnmasdfghjkl\",word2 = \"lkjhgfdsamnbvcxz\") == 32\n assert candidate(word1 = \"aaaaa\",word2 = \"bbbbb\") == 0\n assert candidate(word1 = \"racecar\",word2 = \"civic\") == 5\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zz yy xx ww vv uu tt ss rr qq pp oo nn mm ll kk jj ii hh gg ff ee dd cc bb aa\") == 104\n assert candidate(word1 = \"abcdef\",word2 = \"fedcba\") == 12\n assert candidate(word1 = \"pqr\",word2 = \"rstuv\") == 2\n assert candidate(word1 = \"xyz\",word2 = \"zyxcba\") == 6\n assert candidate(word1 = \"c\",word2 = \"c\") == 2\n assert candidate(word1 = \"abcabcabcabcabc\",word2 = \"cbacbacbacbacba\") == 30\n"}, "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().longestPalindrome", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def longestPalindrome(self, word1: str, word2: str) -> int:", "container": "Solution", "callable": "longestPalindrome", "parameters": [{"name": "word1", "type": "str"}, {"name": "word2", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1773, "task_id": "count-items-matching-a-rule", "difficulty": "Easy", "problem_description": "You are given an array items, where each items[i] = [typei, colori, namei] describes the type, color, and name of the ith item. You are also given a rule represented by two strings, ruleKey and ruleValue.\nThe ith item is said to match the rule if one of the following is true:\n\nruleKey == \"type\" and ruleValue == typei.\nruleKey == \"color\" and ruleValue == colori.\nruleKey == \"name\" and ruleValue == namei.\n\nReturn the number of items that match the given rule.\n \nExample 1:\n\nInput: items = [[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"lenovo\"],[\"phone\",\"gold\",\"iphone\"]], ruleKey = \"color\", ruleValue = \"silver\"\nOutput: 1\nExplanation: There is only one item matching the given rule, which is [\"computer\",\"silver\",\"lenovo\"].\n\nExample 2:\n\nInput: items = [[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"phone\"],[\"phone\",\"gold\",\"iphone\"]], ruleKey = \"type\", ruleValue = \"phone\"\nOutput: 2\nExplanation: There are only two items matching the given rule, which are [\"phone\",\"blue\",\"pixel\"] and [\"phone\",\"gold\",\"iphone\"]. Note that the item [\"computer\",\"silver\",\"phone\"] does not match.\n \nConstraints:\n\n1 <= items.length <= 104\n1 <= typei.length, colori.length, namei.length, ruleValue.length <= 10\nruleKey is equal to either \"type\", \"color\", or \"name\".\nAll strings consist only of lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'harley'], ['car', 'green', 'lambo']],ruleKey = \"color\",ruleValue = \"red\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'phone'], ['phone', 'gold', 'iphone']],ruleKey = \"type\",ruleValue = \"phone\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['phone', 'black', 'samsung'], ['tablet', 'black', 'ipad']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['phone', 'white', 'samsung'], ['tablet', 'gray', 'apple']],ruleKey = \"name\",ruleValue = \"apple\") == 1\n assert candidate(items = [['shirt', 'white', 't-shirt'], ['pants', 'black', 'jeans'], ['shirt', 'white', 'dress-shirt']],ruleKey = \"type\",ruleValue = \"shirt\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['tablet', 'white', 'samsung'], ['laptop', 'silver', 'macbook']],ruleKey = \"name\",ruleValue = \"dell\") == 1\n assert candidate(items = [['shoe', 'white', 'nike'], ['shirt', 'black', 'adidas'], ['shoe', 'black', 'puma']],ruleKey = \"type\",ruleValue = \"shoe\") == 2\n assert candidate(items = [['book', 'red', 'novel'], ['pen', 'blue', 'ballpoint'], ['notebook', 'red', 'blank']],ruleKey = \"name\",ruleValue = \"blank\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone']],ruleKey = \"color\",ruleValue = \"silver\") == 1\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini']],ruleKey = \"color\",ruleValue = \"red\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['laptop', 'gray', 'hp'], ['desktop', 'black', 'asus']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['book', 'brown', 'alice'], ['pen', 'blue', 'bic'], ['notebook', 'white', 'staples']],ruleKey = \"type\",ruleValue = \"book\") == 1\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'harley'], ['car', 'red', 'lamborghini']],ruleKey = \"name\",ruleValue = \"ferrari\") == 1\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'red', 'yamaha'], ['truck', 'blue', 'ford']],ruleKey = \"type\",ruleValue = \"red\") == 0\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini']],ruleKey = \"name\",ruleValue = \"ferrari\") == 1\n assert candidate(items = [['book', 'red', 'novel'], ['pen', 'blue', 'ballpoint'], ['book', 'brown', 'textbook']],ruleKey = \"type\",ruleValue = \"book\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['smartphone', 'blue', 'samsung galaxy s20'], ['smartphone', 'black', 'iphone 12'], ['smartphone', 'red', 'huawei p30'], ['smartphone', 'black', 'google pixel 4'], ['smartphone', 'blue', 'oneplus 8t']],ruleKey = \"name\",ruleValue = \"iphone 12\") == 1\n assert candidate(items = [['camera', 'black', 'canon'], ['camera', 'silver', 'nikon'], ['camera', 'black', 'sony'], ['camera', 'gold', 'fujifilm'], ['camera', 'black', 'olympus']],ruleKey = \"name\",ruleValue = \"sony\") == 1\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'blue', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'black', 'apple'], ['smartphone', 'red', 'motorola']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['electronics', 'black', 'headphone'], ['electronics', 'silver', 'earbuds'], ['electronics', 'white', 'speakers'], ['electronics', 'blue', 'microphone']],ruleKey = \"type\",ruleValue = \"electronics\") == 4\n assert candidate(items = [['toys', 'yellow', 'balloon'], ['toys', 'red', 'car'], ['toys', 'blue', 'doll'], ['toys', 'green', 'teddy'], ['toys', 'yellow', 'block']],ruleKey = \"color\",ruleValue = \"yellow\") == 2\n assert candidate(items = [['computer', 'silver', 'dell'], ['computer', 'black', 'apple'], ['computer', 'silver', 'hp'], ['computer', 'black', 'asus'], ['computer', 'silver', 'lenovo'], ['computer', 'black', 'microsoft']],ruleKey = \"color\",ruleValue = \"silver\") == 3\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['bicycle', 'black', 'trek'], ['motorcycle', 'green', 'harley'], ['car', 'blue', 'porsche'], ['bike', 'red', 'giagiua']],ruleKey = \"color\",ruleValue = \"red\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'blue', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'black', 'apple'], ['laptop', 'gray', 'hp']],ruleKey = \"type\",ruleValue = \"laptop\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['truck', 'black', 'volvo'], ['motorcycle', 'red', 'honda'], ['car', 'blue', 'tesla']],ruleKey = \"color\",ruleValue = \"red\") == 3\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shoes', 'blue', 'puma'], ['hat', 'blue', 'reebok'], ['shirt', 'blue', 'nike']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['electronics', 'black', 'smartphone'], ['electronics', 'blue', 'laptop'], ['electronics', 'black', 'tablet'], ['electronics', 'red', 'smartwatch'], ['electronics', 'black', 'television']],ruleKey = \"type\",ruleValue = \"electronics\") == 5\n assert candidate(items = [['book', 'brown', 'tolkien'], ['book', 'blue', 'harry_potter'], ['magazine', 'black', 'national_geographic'], ['book', 'blue', 'twilight'], ['magazine', 'white', 'forbes']],ruleKey = \"name\",ruleValue = \"blue\") == 0\n assert candidate(items = [['chair', 'brown', 'ikea'], ['table', 'white', 'ikea'], ['couch', 'gray', 'ikea'], ['desk', 'black', 'ikea'], ['lamp', 'silver', 'ikea']],ruleKey = \"brand\",ruleValue = \"ikea\") == 5\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['motorcycle', 'black', 'honda'], ['car', 'red', 'tesla']],ruleKey = \"type\",ruleValue = \"car\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp']],ruleKey = \"type\",ruleValue = \"laptop\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['bike', 'red', 'ducati'], ['car', 'blue', 'toyota'], ['bike', 'white', 'honda']],ruleKey = \"name\",ruleValue = \"red\") == 0\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp'], ['laptop', 'black', 'macbook']],ruleKey = \"type\",ruleValue = \"laptop\") == 3\n assert candidate(items = [['book', 'blue', 'fiction'], ['book', 'red', 'nonfiction'], ['book', 'blue', 'science'], ['book', 'green', 'history'], ['book', 'blue', 'fantasy']],ruleKey = \"name\",ruleValue = \"nonfiction\") == 1\n assert candidate(items = [['smartphone', 'blue', 'samsung'], ['smartphone', 'blue', 'googlepixel'], ['smartphone', 'black', 'iphone'], ['smartphone', 'blue', 'oneplus']],ruleKey = \"name\",ruleValue = \"googlepixel\") == 1\n assert candidate(items = [['chair', 'white', 'ikea'], ['sofa', 'brown', 'ikea'], ['table', 'brown', 'ikea'], ['lamp', 'white', 'ikea'], ['shelf', 'brown', 'ikea'], ['cabinet', 'white', 'ikea']],ruleKey = \"type\",ruleValue = \"ikea\") == 0\n assert candidate(items = [['television', 'black', 'samsung'], ['refrigerator', 'white', 'whirlpool'], ['microwave', 'black', 'frigidaire'], ['washer', 'stainless', 'lg']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['apparel', 'black', 'jacket'], ['apparel', 'white', 'shirt'], ['apparel', 'red', 'pants'], ['apparel', 'blue', 'hat']],ruleKey = \"type\",ruleValue = \"apparel\") == 4\n assert candidate(items = [['camera', 'black', 'nikon'], ['camera', 'silver', 'canon'], ['camera', 'gold', 'leica'], ['camera', 'black', 'olympus'], ['camera', 'white', 'fujifilm']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['toy', 'green', 'car'], ['toy', 'red', 'doll'], ['toy', 'blue', 'block'], ['toy', 'green', 'train'], ['toy', 'red', 'helicopter'], ['toy', 'blue', 'truck']],ruleKey = \"type\",ruleValue = \"toy\") == 6\n assert candidate(items = [['laptop', 'silver', 'macbook'], ['smartphone', 'gold', 'iphone'], ['tablet', 'rose gold', 'ipad'], ['watch', 'black', 'apple watch'], ['charger', 'white', 'anker']],ruleKey = \"type\",ruleValue = \"laptop\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone'], ['tablet', 'black', 'samsung'], ['smartwatch', 'black', 'fitbit'], ['laptop', 'blue', 'macbook']],ruleKey = \"color\",ruleValue = \"blue\") == 2\n assert candidate(items = [['smartphone', 'red', 'iphone'], ['smartphone', 'black', 'galaxy'], ['smartphone', 'white', 'nokia'], ['smartphone', 'black', 'oneplus'], ['smartphone', 'red', 'motorola'], ['smartphone', 'blue', 'huawei'], ['smartphone', 'red', 'oppo'], ['smartphone', 'green', 'realme']],ruleKey = \"name\",ruleValue = \"red\") == 0\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp'], ['laptop', 'black', 'macbook'], ['laptop', 'gray', 'asus']],ruleKey = \"name\",ruleValue = \"laptop\") == 0\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['laptop', 'white', 'macbook'], ['smartphone', 'blue', 'googlepixel']],ruleKey = \"type\",ruleValue = \"laptop\") == 2\n assert candidate(items = [['book', 'blue', 'harry_potter'], ['book', 'green', 'the_lord_of_the_rings'], ['book', 'blue', 'pride_and_prejudice'], ['book', 'red', 'the_hobbit'], ['book', 'blue', '1984']],ruleKey = \"color\",ruleValue = \"blue\") == 3\n assert candidate(items = [['dress', 'pink', 'prada'], ['shoes', 'black', 'gucci'], ['bag', 'brown', 'lv'], ['jacket', 'blue', 'dolce_gabbana'], ['hat', 'black', 'versace']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['watch', 'black', 'rolex'], ['watch', 'white', 'omega'], ['watch', 'gold', 'patekphilippue'], ['watch', 'silver', 'seiko'], ['watch', 'black', 'titan']],ruleKey = \"name\",ruleValue = \"seiko\") == 1\n assert candidate(items = [['house', 'white', 'mansions'], ['house', 'blue', 'cottages'], ['apartment', 'gray', 'flats'], ['condo', 'white', 'duplex'], ['townhouse', 'blue', 'terraced'], ['house', 'white', 'bungalows'], ['apartment', 'gray', 'penthouse'], ['condo', 'blue', 'villa'], ['townhouse', 'white', 'villas'], ['house', 'gray', 'detached']],ruleKey = \"type\",ruleValue = \"house\") == 4\n assert candidate(items = [['smartphone', 'red', 'iphone'], ['smartphone', 'black', 'galaxy'], ['smartphone', 'white', 'nokia'], ['smartphone', 'black', 'oneplus'], ['smartphone', 'red', 'motorola']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['motorcycle', 'green', 'harley'], ['truck', 'black', 'ford']],ruleKey = \"type\",ruleValue = \"car\") == 2\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shirt', 'blue', 'reebok']],ruleKey = \"color\",ruleValue = \"blue\") == 5\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'red', 'adidas'], ['hat', 'blue', 'reebok'], ['jacket', 'green', 'nike'], ['shoes', 'black', 'puma']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['television', 'black', 'samsung'], ['television', 'silver', 'lg'], ['television', 'gray', 'tcl'], ['television', 'black', 'sony'], ['television', 'red', 'panasonic']],ruleKey = \"type\",ruleValue = \"television\") == 5\n assert candidate(items = [['car', 'red', 'ferrari'], ['car', 'blue', 'ford'], ['car', 'red', 'lamborghini'], ['truck', 'black', 'mercedes'], ['car', 'red', 'tesla']],ruleKey = \"color\",ruleValue = \"red\") == 3\n assert candidate(items = [['kitchenware', 'white', 'plate'], ['kitchenware', 'blue', 'spoon'], ['kitchenware', 'white', 'bowl'], ['kitchenware', 'red', 'fork'], ['kitchenware', 'white', 'knife']],ruleKey = \"color\",ruleValue = \"white\") == 3\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shoes', 'black', 'reebok'], ['hat', 'red', 'nike'], ['jacket', 'blue', 'puma'], ['watch', 'silver', 'rolex'], ['belt', 'brown', 'gucci'], ['scarf', 'red', 'h&m'], ['glasses', 'black', 'rayban'], ['sunglasses', 'red', 'polo'], ['boots', 'blue', 'converse'], ['sandals', 'white', 'havaianas'], ['t-shirt', 'red', 'nike'], ['bag', 'black', 'louisvuitton'], ['cap', 'gray', 'nike']],ruleKey = \"name\",ruleValue = \"nike\") == 4\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas']],ruleKey = \"name\",ruleValue = \"nike\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone'], ['tv', 'black', 'samsung'], ['monitor', 'silver', 'dell'], ['laptop', 'gray', 'hp'], ['phone', 'black', 'nokia'], ['tablet', 'gold', 'ipad']],ruleKey = \"type\",ruleValue = \"phone\") == 3\n assert candidate(items = [['book', 'red', 'pride_and_prejudice'], ['book', 'blue', 'the_little_prince'], ['book', 'green', 'to_kill_a_mockingbird'], ['book', 'red', '1984'], ['book', 'yellow', 'moby_dick']],ruleKey = \"color\",ruleValue = \"red\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['truck', 'white', 'ford'], ['car', 'black', 'tesla'], ['car', 'red', 'bmw']],ruleKey = \"color\",ruleValue = \"red\") == 3\n assert candidate(items = [['electronics', 'white', 'samsung'], ['electronics', 'black', 'lg'], ['electronics', 'silver', 'sony'], ['electronics', 'black', 'toshiba'], ['electronics', 'white', 'panasonic']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['truck', 'white', 'ford'], ['car', 'black', 'tesla']],ruleKey = \"color\",ruleValue = \"red\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp']],ruleKey = \"name\",ruleValue = \"dell\") == 1\n assert candidate(items = [['tv', 'black', 'samsung'], ['tv', 'white', 'lg'], ['tv', 'silver', 'sony'], ['tv', 'black', 'toshiba'], ['tv', 'white', 'vizio']],ruleKey = \"color\",ruleValue = \"white\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['truck', 'white', 'ford'], ['car', 'black', 'tesla'], ['car', 'red', 'bmw'], ['truck', 'black', 'chevrolet']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['toy', 'red', 'car'], ['toy', 'blue', 'doll'], ['toy', 'green', 'car'], ['toy', 'red', 'ball'], ['toy', 'green', 'doll'], ['toy', 'blue', 'ball']],ruleKey = \"name\",ruleValue = \"car\") == 2\n assert candidate(items = [['dog', 'black', 'labrador'], ['cat', 'white', 'siamese'], ['dog', 'brown', 'golden_retriever'], ['bird', 'blue', 'parakeet'], ['fish', 'red', 'goldfish']],ruleKey = \"type\",ruleValue = \"dog\") == 2\n assert candidate(items = [['clothing', 'blue', 'shirt'], ['clothing', 'red', 't-shirt'], ['clothing', 'blue', 'jeans'], ['clothing', 'green', 'pants'], ['clothing', 'blue', 'jacket'], ['clothing', 'yellow', 'shorts'], ['clothing', 'blue', 'hat']],ruleKey = \"color\",ruleValue = \"blue\") == 4\n assert candidate(items = [['chair', 'brown', 'leather'], ['table', 'white', 'wood'], ['lamp', 'black', 'glass'], ['sofa', 'gray', 'cotton'], ['rug', 'blue', 'carpet'], ['cabinet', 'black', 'oak'], ['bed', 'white', 'sheets'], ['mirror', 'silver', 'frame'], ['shelf', 'black', 'metal']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['shirt', 'blue', 'nike'], ['shirt', 'red', 'adidas'], ['shirt', 'blue', 'puma'], ['shirt', 'green', 'reebok'], ['shirt', 'blue', 'underarmour']],ruleKey = \"name\",ruleValue = \"puma\") == 1\n assert candidate(items = [['book', 'red', 'harrypotter'], ['pen', 'blue', 'bic'], ['book', 'red', 'twilight'], ['notebook', 'white', 'blank'], ['book', 'green', 'thehobbit'], ['book', 'red', 'catch22'], ['marker', 'blue', 'sharpie'], ['book', 'red', 'prideandprejudice']],ruleKey = \"name\",ruleValue = \"red\") == 0\n assert candidate(items = [['mouse', 'black', 'logitech'], ['mouse', 'white', 'razer'], ['mouse', 'blue', 'corsair'], ['mouse', 'black', 'microsoft'], ['mouse', 'black', 'steelseries']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['shirt', 'white', 'nike'], ['pants', 'blue', 'adidas'], ['shoes', 'black', 'puma'], ['hat', 'white', 'reebok'], ['socks', 'blue', 'nike']],ruleKey = \"color\",ruleValue = \"blue\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'red', 'ducati'], ['motorcycle', 'red', 'harley_davidson'], ['scooter', 'red', 'vespa'], ['convertible', 'red', 'porsche']],ruleKey = \"color\",ruleValue = \"red\") == 5\n assert candidate(items = [['couch', 'brown', 'sofa'], ['chair', 'black', 'office'], ['table', 'brown', 'dining'], ['lamp', 'black', 'reading'], ['cabinet', 'brown', 'kitchen']],ruleKey = \"color\",ruleValue = \"brown\") == 3\n assert candidate(items = [['keyboard', 'black', 'logitech'], ['keyboard', 'white', 'razer'], ['keyboard', 'blue', 'corsair'], ['keyboard', 'black', 'microsoft'], ['keyboard', 'black', 'filco']],ruleKey = \"type\",ruleValue = \"keyboard\") == 5\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shoes', 'black', 'reebok'], ['hat', 'red', 'nike'], ['jacket', 'blue', 'puma'], ['watch', 'silver', 'rolex'], ['belt', 'brown', 'gucci']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['laptop', 'gray', 'hp'], ['desktop', 'black', 'asus'], ['monitor', 'black', 'dell'], ['laptop', 'silver', 'lenovo']],ruleKey = \"type\",ruleValue = \"laptop\") == 3\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas']],ruleKey = \"color\",ruleValue = \"blue\") == 4\n assert candidate(items = [['camera', 'black', 'canon'], ['smartphone', 'white', 'iphone'], ['tablet', 'gold', 'ipad'], ['smartwatch', 'black', 'applewatch'], ['laptop', 'silver', 'macbook']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['furniture', 'brown', 'table'], ['furniture', 'white', 'sofa'], ['furniture', 'brown', 'chair'], ['furniture', 'black', 'cabinet'], ['furniture', 'white', 'lamp'], ['furniture', 'brown', 'dresser']],ruleKey = \"color\",ruleValue = \"brown\") == 3\n assert candidate(items = [['computer', 'black', 'macbook'], ['smartwatch', 'silver', 'apple'], ['tablet', 'white', 'samsung'], ['laptop', 'blue', 'dell'], ['desktop', 'black', 'asus'], ['computer', 'silver', 'lenovo'], ['smartwatch', 'white', 'fitbit'], ['tablet', 'black', 'xiaomi']],ruleKey = \"color\",ruleValue = \"white\") == 2\n assert candidate(items = [['camera', 'black', 'canon'], ['camera', 'silver', 'nikon'], ['lens', 'black', 'canon'], ['camera', 'white', 'sony'], ['tripod', 'gray', 'benro'], ['camera', 'black', 'fujifilm']],ruleKey = \"brand\",ruleValue = \"canon\") == 2\n assert candidate(items = [['book', 'green', 'encyclopedia'], ['book', 'red', 'dictionary'], ['book', 'blue', 'novel'], ['book', 'green', 'textbook'], ['book', 'red', 'guide']],ruleKey = \"color\",ruleValue = \"green\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['bicycle', 'black', 'trek'], ['motorcycle', 'green', 'harley']],ruleKey = \"color\",ruleValue = \"red\") == 2\n assert candidate(items = [['headphones', 'black', 'sony'], ['headphones', 'black', 'apple'], ['headphones', 'black', 'sennheiser'], ['headphones', 'black', 'bose'], ['headphones', 'black', 'jaybird']],ruleKey = \"color\",ruleValue = \"black\") == 5\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['truck', 'black', 'ford'], ['bicycle', 'green', 'giant']],ruleKey = \"color\",ruleValue = \"red\") == 2\n assert candidate(items = [['toy', 'red', 'car'], ['toy', 'blue', 'doll'], ['toy', 'red', 'truck'], ['toy', 'yellow', 'balloon'], ['toy', 'blue', 'teddybear'], ['toy', 'red', 'firetruck']],ruleKey = \"type\",ruleValue = \"toy\") == 6\n assert candidate(items = [['camera', 'black', 'nikon'], ['phone', 'black', 'iphone'], ['tablet', 'black', 'ipad'], ['smartwatch', 'black', 'applewatch'], ['laptop', 'black', 'macbook']],ruleKey = \"color\",ruleValue = \"black\") == 5\n assert candidate(items = [['sneakers', 'white', 'nike'], ['tshirt', 'blue', 'adidas'], ['jeans', 'black', 'puma'], ['hat', 'red', 'nike'], ['pants', 'blue', 'reebok']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['bike', 'red', 'ducati'], ['car', 'blue', 'toyota'], ['bike', 'white', 'honda'], ['car', 'red', 'mustang'], ['bike', 'black', 'ktm']],ruleKey = \"type\",ruleValue = \"bike\") == 4\n assert candidate(items = [['computer', 'black', 'macbook'], ['smartwatch', 'silver', 'apple'], ['tablet', 'white', 'samsung'], ['laptop', 'blue', 'dell'], ['desktop', 'black', 'asus']],ruleKey = \"type\",ruleValue = \"computer\") == 1\n assert candidate(items = [['monitor', 'black', 'asus'], ['monitor', 'white', 'dell'], ['monitor', 'blue', 'benq'], ['monitor', 'silver', 'acer'], ['monitor', 'black', 'lg']],ruleKey = \"type\",ruleValue = \"monitor\") == 5\n assert candidate(items = [['smartphone', 'black', 'samsung'], ['smartphone', 'blue', 'iphone'], ['smartphone', 'black', 'google'], ['smartphone', 'red', 'oneplus'], ['smartphone', 'black', 'zte']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['shirt', 'black', 'nike'], ['jeans', 'blue', 'levis'], ['jacket', 'brown', 'adidas'], ['shoes', 'white', 'nike'], ['hat', 'black', 'nike'], ['socks', 'blue', 'addidas'], ['gloves', 'brown', 'adidas'], ['shorts', 'white', 'levis']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartphone', 'blue', 'huawei'], ['laptop', 'red', 'macbook']],ruleKey = \"type\",ruleValue = \"smartphone\") == 2\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone'], ['phone', 'black', 'samsung'], ['laptop', 'gray', 'hp'], ['tablet', 'silver', 'ipad']],ruleKey = \"type\",ruleValue = \"phone\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['laptop', 'gray', 'hp'], ['desktop', 'black', 'asus'], ['laptop', 'black', 'lenovo'], ['desktop', 'black', 'acer']],ruleKey = \"color\",ruleValue = \"black\") == 4\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['truck', 'white', 'ford'], ['car', 'black', 'tesla']],ruleKey = \"name\",ruleValue = \"tesla\") == 1\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shirt', 'blue', 'reebok'], ['shirt', 'blue', 'puma']],ruleKey = \"name\",ruleValue = \"blue\") == 0\n assert candidate(items = [['tv', 'black', 'samsung'], ['fridge', 'white', 'lg'], ['microwave', 'black', 'whirlpool'], ['stove', 'black', 'bosch']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['vehicle', 'red', 'ferrari'], ['vehicle', 'blue', 'lamborghini'], ['vehicle', 'red', 'porsche'], ['vehicle', 'black', 'ferrari'], ['vehicle', 'red', 'mustang']],ruleKey = \"name\",ruleValue = \"ferrari\") == 2\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['hat', 'blue', 'puma'], ['socks', 'green', 'reebok'], ['jacket', 'blue', 'the north face']],ruleKey = \"color\",ruleValue = \"blue\") == 4\n assert candidate(items = [['bed', 'wood', 'ikea'], ['sofa', 'leather', 'furniture_king'], ['chair', 'plastic', 'home_decor'], ['lamp', 'metal', 'ikea'], ['table', 'glass', 'ikea']],ruleKey = \"brand\",ruleValue = \"ikea\") == 3\n assert candidate(items = [['phone', 'blue', 'pixel'], ['phone', 'blue', 'galaxy'], ['phone', 'blue', 'nokia'], ['phone', 'blue', 'oneplus'], ['phone', 'blue', 'google'], ['phone', 'blue', 'xiaomi'], ['phone', 'blue', 'htc']],ruleKey = \"name\",ruleValue = \"google\") == 1\n assert candidate(items = [['smartwatch', 'silver', 'apple'], ['smartwatch', 'gold', 'rolex'], ['bracelet', 'silver', 'tissot'], ['pendant', 'gold', 'omega'], ['bracelet', 'silver', 'casio']],ruleKey = \"name\",ruleValue = \"silver\") == 0\n"}, "metadata": {"canonical_parameter_names": ["items", "ruleKey", "ruleValue"], "leetcode_dataset_entry_point": "Solution().countMatches", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countMatches(self, items: list[list[str]], ruleKey: str, ruleValue: str) -> int:", "container": "Solution", "callable": "countMatches", "parameters": [{"name": "items", "type": "list[list[str]]"}, {"name": "ruleKey", "type": "str"}, {"name": "ruleValue", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1774, "task_id": "closest-dessert-cost", "difficulty": "Medium", "problem_description": "You would like to make dessert and are preparing to buy the ingredients. You have n ice cream base flavors and m types of toppings to choose from. You must follow these rules when making your dessert:\n\nThere must be exactly one ice cream base.\nYou can add one or more types of topping or have no toppings at all.\nThere are at most two of each type of topping.\n\nYou are given three inputs:\n\nbaseCosts, an integer array of length n, where each baseCosts[i] represents the price of the ith ice cream base flavor.\ntoppingCosts, an integer array of length m, where each toppingCosts[i] is the price of one of the ith topping.\ntarget, an integer representing your target price for dessert.\n\nYou want to make a dessert with a total cost as close to target as possible.\nReturn the closest possible cost of the dessert to target. If there are multiple, return the lower one.\n \nExample 1:\n\nInput: baseCosts = [1,7], toppingCosts = [3,4], target = 10\nOutput: 10\nExplanation: Consider the following combination (all 0-indexed):\n- Choose base 1: cost 7\n- Take 1 of topping 0: cost 1 x 3 = 3\n- Take 0 of topping 1: cost 0 x 4 = 0\nTotal: 7 + 3 + 0 = 10.\n\nExample 2:\n\nInput: baseCosts = [2,3], toppingCosts = [4,5,100], target = 18\nOutput: 17\nExplanation: Consider the following combination (all 0-indexed):\n- Choose base 1: cost 3\n- Take 1 of topping 0: cost 1 x 4 = 4\n- Take 2 of topping 1: cost 2 x 5 = 10\n- Take 0 of topping 2: cost 0 x 100 = 0\nTotal: 3 + 4 + 10 + 0 = 17. You cannot make a dessert with a total cost of 18.\n\nExample 3:\n\nInput: baseCosts = [3,10], toppingCosts = [2,5], target = 9\nOutput: 8\nExplanation: It is possible to make desserts with cost 8 and 10. Return 8 as it is the lower cost.\n\n \nConstraints:\n\nn == baseCosts.length\nm == toppingCosts.length\n1 <= n, m <= 10\n1 <= baseCosts[i], toppingCosts[i] <= 104\n1 <= target <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(baseCosts = [10, 20],toppingCosts = [1, 2, 3],target = 15) == 15\n assert candidate(baseCosts = [5, 9],toppingCosts = [2, 3, 7],target = 15) == 15\n assert candidate(baseCosts = [1, 7],toppingCosts = [3, 4],target = 10) == 10\n assert candidate(baseCosts = [10, 20, 30],toppingCosts = [1, 2, 3, 4, 5],target = 25) == 25\n assert candidate(baseCosts = [4, 8],toppingCosts = [1, 3],target = 15) == 15\n assert candidate(baseCosts = [5],toppingCosts = [1, 2, 3],target = 8) == 8\n assert candidate(baseCosts = [4],toppingCosts = [1, 2, 3],target = 8) == 8\n assert candidate(baseCosts = [10, 20],toppingCosts = [5, 15, 25],target = 50) == 50\n assert candidate(baseCosts = [1],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 10\n assert candidate(baseCosts = [5, 8],toppingCosts = [6, 1, 2],target = 20) == 20\n assert candidate(baseCosts = [10],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 20) == 20\n assert candidate(baseCosts = [2, 3],toppingCosts = [4, 5, 100],target = 18) == 17\n assert candidate(baseCosts = [3, 10],toppingCosts = [2, 5],target = 9) == 8\n assert candidate(baseCosts = [4, 8, 12, 16, 20],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 30) == 30\n assert candidate(baseCosts = [50, 75, 100, 125],toppingCosts = [10, 15, 20, 25, 30],target = 300) == 300\n assert candidate(baseCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],toppingCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1023) == 1023\n assert candidate(baseCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 1500) == 1500\n assert candidate(baseCosts = [1234, 5678, 9101],toppingCosts = [111, 222, 333, 444, 555, 666],target = 10000) == 10007\n assert candidate(baseCosts = [5000, 7500, 10000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 15000) == 15000\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000],toppingCosts = [50, 100, 150, 200, 250, 300, 350],target = 10000) == 7800\n assert candidate(baseCosts = [15, 25, 35, 45],toppingCosts = [2, 4, 6, 8, 10],target = 50) == 49\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [10, 20, 30, 40, 50],target = 500) == 500\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [987, 654, 321, 654, 321, 987],target = 1000) == 1086\n assert candidate(baseCosts = [10, 20, 30, 40, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 150) == 150\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 7500) == 7500\n assert candidate(baseCosts = [1, 5, 10, 15],toppingCosts = [3, 6, 9, 12],target = 30) == 30\n assert candidate(baseCosts = [7, 14, 21],toppingCosts = [3, 6, 9, 12, 15, 18],target = 30) == 30\n assert candidate(baseCosts = [500, 1000, 1500],toppingCosts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],target = 3000) == 3000\n assert candidate(baseCosts = [1000, 2000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 5000) == 5000\n assert candidate(baseCosts = [8, 16, 24],toppingCosts = [2, 4, 6, 8, 10, 12, 14, 16],target = 35) == 34\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000],toppingCosts = [100, 200, 300, 400, 500],target = 12345) == 8000\n assert candidate(baseCosts = [3, 6, 9, 12, 15],toppingCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1024) == 1024\n assert candidate(baseCosts = [300, 600, 900],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 1200) == 1200\n assert candidate(baseCosts = [1, 2, 3, 4, 5],toppingCosts = [5, 10, 15, 20, 25],target = 50) == 50\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 50) == 50\n assert candidate(baseCosts = [100, 200, 300],toppingCosts = [50, 75, 100, 125, 150],target = 600) == 600\n assert candidate(baseCosts = [1, 10000],toppingCosts = [5000, 3000, 2000, 1000, 500, 100],target = 9000) == 9001\n assert candidate(baseCosts = [15, 25, 35],toppingCosts = [5, 7, 11, 13, 17],target = 50) == 50\n assert candidate(baseCosts = [100, 150, 200, 250],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 750) == 750\n assert candidate(baseCosts = [999, 1999, 2999],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 5000) == 3109\n assert candidate(baseCosts = [1, 1, 1, 1, 1],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 25) == 25\n assert candidate(baseCosts = [150, 250, 350],toppingCosts = [5, 15, 25, 35, 45, 55],target = 400) == 400\n assert candidate(baseCosts = [2000, 4000, 6000],toppingCosts = [100, 200, 300, 400, 500],target = 7000) == 7000\n assert candidate(baseCosts = [1, 10, 100],toppingCosts = [9, 90, 900, 9000],target = 10000) == 10000\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 1000) == 1000\n assert candidate(baseCosts = [7500, 8000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 15000) == 15000\n assert candidate(baseCosts = [15, 25, 35, 45],toppingCosts = [1, 2, 3, 4, 5, 6, 7],target = 30) == 30\n assert candidate(baseCosts = [10, 20, 30],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 45) == 45\n assert candidate(baseCosts = [1, 1, 1, 1, 1],toppingCosts = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 100) == 101\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 10000) == 10000\n assert candidate(baseCosts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 100) == 100\n assert candidate(baseCosts = [5000, 7000, 9000],toppingCosts = [1000, 2000, 3000, 4000],target = 18000) == 18000\n assert candidate(baseCosts = [500, 250],toppingCosts = [100, 200, 300, 400, 500],target = 1000) == 1000\n assert candidate(baseCosts = [10000],toppingCosts = [10000, 10000, 10000, 10000, 10000],target = 50000) == 50000\n assert candidate(baseCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 500) == 210\n assert candidate(baseCosts = [100, 200, 300],toppingCosts = [10, 20, 30, 40, 50, 60],target = 500) == 500\n assert candidate(baseCosts = [1000, 2000, 3000],toppingCosts = [500, 100, 250, 125, 75],target = 4500) == 4500\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [11, 22, 33, 44, 55, 66, 77, 88, 99],target = 1000) == 998\n assert candidate(baseCosts = [5, 10, 15, 20, 25],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == 20\n assert candidate(baseCosts = [9999],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10000) == 10000\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [987, 654, 321, 123, 456, 789, 100, 200, 300],target = 2000) == 2000\n assert candidate(baseCosts = [500, 501, 502],toppingCosts = [250, 251, 252, 253],target = 1000) == 1000\n assert candidate(baseCosts = [777, 888],toppingCosts = [55, 44, 33, 22, 11, 1, 2, 3, 4, 5],target = 2000) == 1248\n assert candidate(baseCosts = [10, 20, 30, 40, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 25) == 25\n assert candidate(baseCosts = [10, 20, 30, 40, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 50) == 50\n assert candidate(baseCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 10\n assert candidate(baseCosts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 30) == 30\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [11, 22, 33, 44, 55],target = 700) == 698\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [10, 20, 30, 40, 50, 60],target = 750) == 750\n assert candidate(baseCosts = [100, 200],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 500) == 310\n assert candidate(baseCosts = [1000, 1001, 1002, 1003],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10000) == 1113\n assert candidate(baseCosts = [23, 45, 67, 89, 10],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 200) == 199\n assert candidate(baseCosts = [5, 10, 15, 20],toppingCosts = [1, 3, 5, 7, 9, 11, 13],target = 40) == 40\n assert candidate(baseCosts = [100, 200, 300, 400, 500],toppingCosts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 1000) == 1000\n assert candidate(baseCosts = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],toppingCosts = [2, 4, 6, 8, 10],target = 50) == 49\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [10, 20, 30, 40, 50, 60],target = 1500) == 820\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [50, 10, 15, 20, 25, 30, 35, 40, 45, 55],target = 1500) == 1050\n assert candidate(baseCosts = [1, 2, 3, 4, 5],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 100) == 101\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],toppingCosts = [500, 1500, 2500, 3500],target = 7500) == 7500\n assert candidate(baseCosts = [2000, 3000, 4000, 5000],toppingCosts = [50, 100, 150, 200, 250],target = 8500) == 6500\n assert candidate(baseCosts = [50, 100, 150, 200, 250, 300],toppingCosts = [5, 10, 15, 20, 25, 30],target = 750) == 510\n assert candidate(baseCosts = [100, 200],toppingCosts = [50, 25, 10, 5, 1],target = 300) == 300\n assert candidate(baseCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 5000) == 5001\n assert candidate(baseCosts = [1000, 2000, 3000],toppingCosts = [500, 1000, 1500, 2000, 2500],target = 6000) == 6000\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 50) == 50\n assert candidate(baseCosts = [800, 1600, 2400],toppingCosts = [100, 200, 300, 400, 500, 600],target = 3000) == 3000\n assert candidate(baseCosts = [5000, 10000],toppingCosts = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000],target = 20000) == 20000\n assert candidate(baseCosts = [1000, 2000, 3000],toppingCosts = [500, 100, 250, 150, 200],target = 4500) == 4500\n assert candidate(baseCosts = [4, 8, 12, 16, 20],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 45) == 45\n assert candidate(baseCosts = [1, 2, 3, 4, 5],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 500) == 501\n assert candidate(baseCosts = [50, 60, 70, 80, 90],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 150) == 150\n assert candidate(baseCosts = [100, 200, 300],toppingCosts = [50, 75, 100, 125, 150],target = 500) == 500\n assert candidate(baseCosts = [5000],toppingCosts = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000],target = 20000) == 20000\n assert candidate(baseCosts = [10, 20],toppingCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1000) == 1000\n assert candidate(baseCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 500) == 210\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [9999],target = 10000) == 10000\n assert candidate(baseCosts = [5, 10],toppingCosts = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 15) == 15\n assert candidate(baseCosts = [500, 1000, 1500],toppingCosts = [5, 10, 15, 20, 25, 30, 35, 40],target = 2000) == 1860\n assert candidate(baseCosts = [999, 1000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 4000) == 4000\n"}, "metadata": {"canonical_parameter_names": ["baseCosts", "toppingCosts", "target"], "leetcode_dataset_entry_point": "Solution().closestCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def closestCost(self, baseCosts: list[int], toppingCosts: list[int], target: int) -> int:", "container": "Solution", "callable": "closestCost", "parameters": [{"name": "baseCosts", "type": "list[int]"}, {"name": "toppingCosts", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1775, "task_id": "equal-sum-arrays-with-minimum-number-of-operations", "difficulty": "Medium", "problem_description": "You are given two arrays of integers nums1 and nums2, possibly of different lengths. The values in the arrays are between 1 and 6, inclusive.\nIn one operation, you can change any integer's value in any of the arrays to any value between 1 and 6, inclusive.\nReturn the minimum number of operations required to make the sum of values in nums1 equal to the sum of values in nums2. Return -1​​​​​ if it is not possible to make the sum of the two arrays equal.\n \nExample 1:\n\nInput: nums1 = [1,2,3,4,5,6], nums2 = [1,1,2,2,2,2]\nOutput: 3\nExplanation: You can make the sums of nums1 and nums2 equal with 3 operations. All indices are 0-indexed.\n- Change nums2[0] to 6. nums1 = [1,2,3,4,5,6], nums2 = [6,1,2,2,2,2].\n- Change nums1[5] to 1. nums1 = [1,2,3,4,5,1], nums2 = [6,1,2,2,2,2].\n- Change nums1[2] to 2. nums1 = [1,2,2,4,5,1], nums2 = [6,1,2,2,2,2].\n\nExample 2:\n\nInput: nums1 = [1,1,1,1,1,1,1], nums2 = [6]\nOutput: -1\nExplanation: There is no way to decrease the sum of nums1 or to increase the sum of nums2 to make them equal.\n\nExample 3:\n\nInput: nums1 = [6,6], nums2 = [1]\nOutput: 3\nExplanation: You can make the sums of nums1 and nums2 equal with 3 operations. All indices are 0-indexed. \n- Change nums1[0] to 2. nums1 = [2,6], nums2 = [1].\n- Change nums1[1] to 2. nums1 = [2,2], nums2 = [1].\n- Change nums2[0] to 4. nums1 = [2,2], nums2 = [4].\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 105\n1 <= nums1[i], nums2[i] <= 6\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [3, 3, 3, 3],nums2 = [2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1, 1],nums2 = [6, 6]) == 2\n assert candidate(nums1 = [6, 6, 6],nums2 = [1, 1]) == 4\n assert candidate(nums1 = [1, 1, 2],nums2 = [6, 6, 6]) == 3\n assert candidate(nums1 = [1, 1],nums2 = [6, 6, 6]) == 4\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums1 = [1, 2],nums2 = [5, 6]) == 2\n assert candidate(nums1 = [6, 6, 6],nums2 = [1, 1, 1]) == 3\n assert candidate(nums1 = [3, 3, 3],nums2 = [3, 3, 3]) == 0\n assert candidate(nums1 = [2, 3, 4],nums2 = [5, 5, 5]) == 2\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1],nums2 = [6]) == -1\n assert candidate(nums1 = [6],nums2 = [1]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [1, 1, 2, 2, 2, 2]) == 3\n assert candidate(nums1 = [3, 3, 3],nums2 = [2, 2, 2]) == 1\n assert candidate(nums1 = [6, 6],nums2 = [1]) == 3\n assert candidate(nums1 = [2, 2, 2],nums2 = [5, 5, 5]) == 3\n assert candidate(nums1 = [3, 3, 3],nums2 = [2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1],nums2 = [6]) == 1\n assert candidate(nums1 = [1, 1, 1],nums2 = [6, 6, 6]) == 3\n assert candidate(nums1 = [3],nums2 = [3]) == 0\n assert candidate(nums1 = [1, 3, 5],nums2 = [2, 4, 6]) == 1\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 2\n assert candidate(nums1 = [5, 5],nums2 = [1, 1]) == 2\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1]) == 4\n assert candidate(nums1 = [3, 3, 3, 3],nums2 = [1, 6, 1, 6]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 6\n assert candidate(nums1 = [1, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2]) == 5\n assert candidate(nums1 = [6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 2, 3, 4, 5, 6]) == 3\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [1, 6, 1, 6, 1, 6],nums2 = [6, 1, 6, 1, 6, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 58\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [4, 5, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 8\n assert candidate(nums1 = [1, 3, 5, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == -1\n assert candidate(nums1 = [2, 3, 4, 5, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 9\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6]) == 5\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5]) == 11\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 5\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 18\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 7\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 12\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2],nums2 = [2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3]) == 1\n assert candidate(nums1 = [1, 3, 5, 1, 3, 5, 1, 3, 5],nums2 = [2, 4, 6, 2, 4, 6, 2, 4, 6]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums1 = [1, 6, 1, 6, 1, 6],nums2 = [2, 5, 2, 5, 2, 5]) == 0\n assert candidate(nums1 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4],nums2 = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 7\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 10\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 2, 3, 4, 5, 6, 6, 6, 6]) == 3\n assert candidate(nums1 = [2, 3, 4, 5, 6],nums2 = [1, 1, 1, 1]) == 4\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 131\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5]) == 2\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 6, 6, 6],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 15\n assert candidate(nums1 = [1, 6, 1, 6, 1, 6, 1, 6, 1, 6],nums2 = [6, 1, 6, 1, 6, 1, 6, 1, 6, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 6]) == 2\n assert candidate(nums1 = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 9\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 30\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 28\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 14\n assert candidate(nums1 = [2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6]) == 3\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 11\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 8\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == 5\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 3\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [3, 3, 3, 3, 3, 3]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 33\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 21\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [2, 3, 4, 5, 6, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 15\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4, 4],nums2 = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums1 = [6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums1 = [6, 4, 2, 6, 4, 2, 6, 4, 2],nums2 = [1, 3, 5, 1, 3, 5, 1, 3, 5]) == 2\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5]) == 3\n assert candidate(nums1 = [1, 3, 5, 1, 3, 5, 1, 3, 5, 1, 3, 5],nums2 = [2, 4, 6, 2, 4, 6, 2, 4, 6, 2, 4, 6]) == 3\n assert candidate(nums1 = [2, 3, 4],nums2 = [1, 5, 6, 6]) == 2\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [6, 6, 6, 6, 6]) == 2\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 6, 6, 6, 6, 6]) == 5\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(nums1 = [1, 3, 5],nums2 = [2, 4, 6]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 7\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 20\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 8\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1]) == 5\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6]) == 7\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [4, 4, 5, 5, 6, 6]) == 4\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6]) == -1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 8\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [4, 5, 6, 6, 6, 6, 6]) == 5\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1]) == 6\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minOperations(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1776, "task_id": "car-fleet-ii", "difficulty": "Hard", "problem_description": "There are n cars traveling at different speeds in the same direction along a one-lane road. You are given an array cars of length n, where cars[i] = [positioni, speedi] represents:\n\npositioni is the distance between the ith car and the beginning of the road in meters. It is guaranteed that positioni < positioni+1.\nspeedi is the initial speed of the ith car in meters per second.\n\nFor simplicity, cars can be considered as points moving along the number line. Two cars collide when they occupy the same position. Once a car collides with another car, they unite and form a single car fleet. The cars in the formed fleet will have the same position and the same speed, which is the initial speed of the slowest car in the fleet.\nReturn an array answer, where answer[i] is the time, in seconds, at which the ith car collides with the next car, or -1 if the car does not collide with the next car. Answers within 10-5 of the actual answers are accepted.\n \nExample 1:\n\nInput: cars = [[1,2],[2,1],[4,3],[7,2]]\nOutput: [1.00000,-1.00000,3.00000,-1.00000]\nExplanation: After exactly one second, the first car will collide with the second car, and form a car fleet with speed 1 m/s. After exactly 3 seconds, the third car will collide with the fourth car, and form a car fleet with speed 2 m/s.\n\nExample 2:\n\nInput: cars = [[3,4],[5,4],[6,3],[9,1]]\nOutput: [2.00000,1.00000,1.50000,-1.00000]\n\n \nConstraints:\n\n1 <= cars.length <= 105\n1 <= positioni, speedi <= 106\npositioni < positioni+1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cars = [[1, 4], [2, 3], [3, 2], [4, 1]]) == [1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 5], [3, 2], [5, 1]]) == [0.6666666666666666, 2.0, -1]\n assert candidate(cars = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [-1, -1, -1, -1, -1]\n assert candidate(cars = [[3, 4], [5, 4], [6, 3], [9, 1]]) == [2.0, 1.0, 1.5, -1]\n assert candidate(cars = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [-1, -1, -1, -1, -1]\n assert candidate(cars = [[5, 10], [10, 5], [15, 2], [20, 1]]) == [1.0, 1.6666666666666667, 5.0, -1]\n assert candidate(cars = [[1, 10], [3, 8], [5, 6], [7, 4], [9, 2]]) == [1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]]) == [-1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 2], [2, 1], [4, 3], [7, 2]]) == [1.0, -1, 3.0, -1]\n assert candidate(cars = [[10, 10], [8, 5], [6, 3], [4, 2], [2, 1]]) == [-0.8888888888888888, -1.5, -2.0, -2.0, -1]\n assert candidate(cars = [[10, 2], [20, 1], [30, 3], [40, 2]]) == [10.0, -1, 10.0, -1]\n assert candidate(cars = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[5, 10], [15, 8], [20, 7], [25, 6], [30, 5]]) == [5.0, 5.0, 5.0, 5.0, -1]\n assert candidate(cars = [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]]) == [10.0, 10.0, 10.0, 10.0, -1]\n assert candidate(cars = [[10, 5], [15, 3], [20, 2], [25, 1]]) == [2.5, 5.0, 5.0, -1]\n assert candidate(cars = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 10], [3, 6], [5, 5], [7, 4]]) == [0.5, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 20], [2, 18], [3, 16], [4, 14], [5, 12], [6, 10], [7, 8], [8, 6], [9, 4], [10, 2]]) == [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1]\n assert candidate(cars = [[2, 9], [5, 7], [8, 6], [11, 4], [14, 2], [17, 1]]) == [1.5, 1.8, 1.5, 1.5, 3.0, -1]\n assert candidate(cars = [[10, 5], [20, 15], [30, 10], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45]]) == [-1, 2.0, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10], [100, 1]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.1111111111111112, -1]\n assert candidate(cars = [[1, 100], [10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10]]) == [0.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[50, 100], [150, 90], [250, 80], [350, 70], [450, 60], [550, 50], [650, 40], [750, 30], [850, 20], [950, 10]]) == [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1]\n assert candidate(cars = [[1, 100], [5, 80], [10, 60], [15, 40], [20, 20], [25, 0], [30, 20], [35, 40], [40, 60], [45, 80]]) == [0.2, 0.25, 0.25, 0.25, 0.25, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 25], [3, 24], [5, 23], [7, 22], [9, 21], [11, 20], [13, 19], [15, 18], [17, 17], [19, 16], [21, 15]]) == [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 10], [10, 9], [19, 8], [28, 7], [37, 6], [46, 5], [55, 4], [64, 3], [73, 2], [82, 1]]) == [9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, -1]\n assert candidate(cars = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [11, 10], [12, 9], [13, 8], [14, 7], [15, 6], [16, 5], [17, 4], [18, 3], [19, 2], [20, 1]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [12, 10], [14, 9], [16, 8], [18, 7], [20, 6], [22, 5], [24, 4], [26, 3], [28, 2], [30, 1]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]]) == [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -1]\n assert candidate(cars = [[1, 50], [10, 45], [20, 40], [30, 35], [40, 30], [50, 25], [60, 20], [70, 15], [80, 10], [90, 5]]) == [1.8, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 5], [2, 10], [3, 15], [4, 20], [5, 25], [6, 30], [7, 35], [8, 40], [9, 45], [10, 50]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 10], [4, 8], [7, 6], [10, 4], [13, 2], [16, 1]]) == [1.5, 1.5, 1.5, 1.5, 3.0, -1]\n assert candidate(cars = [[1, 8], [3, 7], [5, 6], [7, 5], [9, 4], [11, 3], [13, 2], [15, 1]]) == [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 30], [4, 20], [7, 15], [10, 10], [13, 8], [16, 6], [19, 4], [22, 2], [25, 1]]) == [0.3, 0.6, 0.6, 1.5, 1.5, 1.5, 1.5, 3.0, -1]\n assert candidate(cars = [[1, 100], [10, 95], [20, 90], [30, 85], [40, 80], [50, 75], [60, 70], [70, 65], [80, 60], [90, 55]]) == [1.8, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 15], [2, 25], [3, 35], [4, 45], [5, 55], [6, 65], [7, 75], [8, 85], [9, 95], [10, 105]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 5], [4, 4], [7, 3], [10, 2], [13, 1]]) == [3.0, 3.0, 3.0, 3.0, -1]\n assert candidate(cars = [[1, 100], [20, 50], [30, 30], [40, 20], [50, 10], [60, 1]]) == [0.38, 0.5, 1.0, 1.0, 1.1111111111111112, -1]\n assert candidate(cars = [[1, 15], [2, 10], [4, 5], [6, 4], [8, 3], [10, 2], [12, 1]]) == [0.2, 0.4, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 3], [2, 2], [3, 1], [4, 4], [5, 5], [6, 6]]) == [1.0, 1.0, -1, -1, -1, -1]\n assert candidate(cars = [[1, 200], [11, 180], [21, 160], [31, 140], [41, 120], [51, 100], [61, 80], [71, 60], [81, 40], [91, 20]]) == [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1]\n assert candidate(cars = [[1, 5], [3, 4], [5, 3], [7, 2], [9, 1], [11, 10], [13, 9], [15, 8], [17, 7], [19, 6]]) == [2.0, 2.0, 2.0, 2.0, -1, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 9], [2, 8], [3, 7], [5, 6], [8, 5], [13, 4], [20, 3], [28, 2], [37, 1], [46, 0]]) == [1.0, 1.0, 2.0, 3.0, 5.0, 7.0, 8.0, 9.0, 9.0, -1]\n assert candidate(cars = [[1, 20], [4, 18], [7, 16], [10, 14], [13, 12], [16, 10], [19, 8], [22, 6], [25, 4], [28, 2], [31, 1]]) == [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 3.0, -1]\n assert candidate(cars = [[1, 100000], [2, 99000], [3, 98000], [4, 97000], [5, 96000], [6, 95000], [7, 94000], [8, 93000], [9, 92000], [10, 91000]]) == [0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, -1]\n assert candidate(cars = [[1, 100], [5, 80], [10, 60], [15, 40], [20, 20], [25, 10]]) == [0.2, 0.25, 0.25, 0.25, 0.5, -1]\n assert candidate(cars = [[1, 30], [2, 25], [3, 20], [5, 15], [8, 10], [13, 5], [20, 2], [28, 1]]) == [0.2, 0.2, 0.4, 0.6, 1.0, 2.3333333333333335, 8.0, -1]\n assert candidate(cars = [[1, 12], [3, 10], [5, 8], [7, 6], [9, 4], [11, 2]]) == [1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 50], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44], [8, 43], [9, 42], [10, 41]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 5], [6, 10], [11, 5], [16, 10], [21, 5], [26, 10], [31, 5], [36, 10], [41, 5], [46, 10]]) == [-1, 1.0, -1, 1.0, -1, 1.0, -1, 1.0, -1, -1]\n assert candidate(cars = [[1, 200], [2, 190], [3, 180], [4, 170], [5, 160], [6, 150], [7, 140], [8, 130], [9, 120], [10, 110]]) == [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -1]\n assert candidate(cars = [[1, 6], [3, 5], [5, 4], [7, 3], [9, 2], [11, 1], [13, 5], [15, 4], [17, 3], [19, 2], [21, 1]]) == [2.0, 2.0, 2.0, 2.0, 2.0, -1, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 15], [5, 14], [10, 13], [15, 12], [20, 11], [25, 10], [30, 9], [35, 8], [40, 7], [45, 6], [50, 5], [55, 4], [60, 3], [65, 2], [70, 1]]) == [4.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, -1]\n assert candidate(cars = [[1, 10], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10], [30, 10], [35, 10], [40, 10], [45, 10]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 3], [5, 2], [10, 1], [15, 4], [20, 3], [25, 2], [30, 1]]) == [4.0, 5.0, -1, 5.0, 5.0, 5.0, -1]\n assert candidate(cars = [[1, 10], [2, 9], [5, 8], [8, 7], [13, 6], [18, 5], [24, 4], [30, 3], [36, 2], [42, 1]]) == [1.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0, 6.0, 6.0, -1]\n assert candidate(cars = [[1, 2], [2, 3], [3, 5], [4, 8], [5, 13], [6, 21], [7, 34], [8, 55], [9, 89], [10, 144]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 2], [3, 5], [5, 10], [7, 3], [9, 8], [11, 6], [13, 7], [15, 4]]) == [-1, 2.0, 0.2857142857142857, -1, 1.0, 2.0, 0.6666666666666666, -1]\n assert candidate(cars = [[3, 12], [6, 10], [9, 8], [12, 6], [15, 4], [18, 2], [21, 1]]) == [1.5, 1.5, 1.5, 1.5, 1.5, 3.0, -1]\n assert candidate(cars = [[1, 10], [4, 9], [10, 8], [15, 7], [20, 6], [25, 5], [30, 4], [35, 3], [40, 2], [45, 1]]) == [3.0, 5.125, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, -1]\n assert candidate(cars = [[1, 20], [4, 18], [10, 16], [15, 14], [20, 12], [25, 10], [30, 8], [35, 6], [40, 4], [45, 2]]) == [1.5, 2.5625, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, -1]\n assert candidate(cars = [[1, 1], [10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 50], [5, 40], [10, 30], [16, 20], [23, 10], [31, 5], [40, 3], [50, 1]]) == [0.4, 0.5, 0.6, 0.7, 1.6, 4.5, 5.0, -1]\n assert candidate(cars = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]]) == [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, -1]\n assert candidate(cars = [[1, 20], [2, 18], [3, 16], [5, 14], [8, 12], [13, 10], [20, 8], [28, 6], [37, 4], [46, 2]]) == [0.5, 0.5, 1.0, 1.5, 2.5, 3.5, 4.0, 4.5, 4.5, -1]\n assert candidate(cars = [[1, 10], [2, 20], [3, 15], [4, 25], [5, 20], [6, 30], [7, 25], [8, 35], [9, 30], [10, 40]]) == [-1, 0.2, -1, 0.2, -1, 0.2, -1, 0.2, -1, -1]\n assert candidate(cars = [[1, 10], [3, 9], [5, 8], [7, 7], [9, 6], [11, 5], [13, 4], [15, 3], [17, 2], [19, 1], [21, 0.5]]) == [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 4.0, -1]\n assert candidate(cars = [[10, 10], [20, 9], [30, 8], [40, 7], [50, 6], [60, 5], [70, 4], [80, 3], [90, 2], [100, 1]]) == [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1]\n assert candidate(cars = [[1, 10], [11, 9], [21, 8], [31, 7], [41, 6], [51, 5], [61, 4], [71, 3], [81, 2], [91, 1]]) == [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1]\n assert candidate(cars = [[1, 10], [3, 10], [5, 10], [7, 10], [9, 10], [11, 10], [13, 10], [15, 10], [17, 10], [19, 10], [21, 10]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0.5], [7, 0.25]]) == [1.0, 1.0, 1.0, 1.0, 2.0, 4.0, -1]\n assert candidate(cars = [[1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[10, 10], [25, 9], [40, 8], [55, 7], [70, 6], [85, 5], [100, 4], [115, 3], [130, 2], [145, 1]]) == [15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, -1]\n assert candidate(cars = [[1, 2], [5, 4], [9, 6], [13, 8], [17, 10], [21, 12], [25, 14], [29, 16], [33, 18], [37, 20]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 1], [100000, 100000], [200000, 99999], [300000, 99998], [400000, 99997], [500000, 99996]]) == [-1, 100000.0, 100000.0, 100000.0, 100000.0, -1]\n assert candidate(cars = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 50], [3, 45], [6, 40], [10, 35], [15, 30], [21, 25], [28, 20], [36, 15], [45, 10], [55, 5]]) == [0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, -1]\n assert candidate(cars = [[1, 100], [5, 90], [10, 80], [15, 70], [20, 60], [25, 50], [30, 40], [35, 30], [40, 20], [45, 10]]) == [0.4, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1]\n assert candidate(cars = [[1, 10], [11, 9.99999], [21, 9.99998], [31, 9.99997], [41, 9.99996], [51, 9.99995], [61, 9.99994], [71, 9.99993], [81, 9.99992], [91, 9.99991]]) == [999999.9999786458, 999999.9999490399, 999999.999860222, 1000000.0000023306, 999999.9999934488, 999999.9999786458, 999999.9999490399, 999999.999860222, 1000000.0000378577, -1]\n assert candidate(cars = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86], [16, 85], [17, 84], [18, 83], [19, 82], [20, 81]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 15], [5, 10], [9, 7], [13, 4], [17, 2], [21, 1], [25, 3], [29, 6], [33, 9], [37, 12]]) == [0.8, 1.3333333333333333, 1.3333333333333333, 2.0, 4.0, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10]]) == [1.1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[10, 5], [20, 5], [30, 5], [40, 5], [50, 5], [60, 5], [70, 5], [80, 5], [90, 5], [100, 5]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 150], [4, 130], [7, 110], [10, 90], [13, 70], [16, 50], [19, 30], [22, 10]]) == [0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, -1]\n assert candidate(cars = [[1, 10], [3, 9], [6, 8], [10, 7], [15, 6], [21, 5], [28, 4], [36, 3], [45, 2], [55, 1]]) == [2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, -1]\n assert candidate(cars = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86], [16, 85], [17, 84], [18, 83], [19, 82], [20, 81], [21, 80], [22, 79], [23, 78], [24, 77], [25, 76], [26, 75], [27, 74], [28, 73], [29, 72], [30, 71]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 30], [4, 28], [7, 26], [10, 24], [13, 22], [16, 20], [19, 18], [22, 16], [25, 14], [28, 12], [31, 10], [34, 8], [37, 6], [40, 4], [43, 2]]) == [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, -1]\n assert candidate(cars = [[1, 5], [5, 10], [9, 5], [13, 10], [17, 5], [21, 10], [25, 5], [29, 10], [33, 5], [37, 10]]) == [-1, 0.8, -1, 0.8, -1, 0.8, -1, 0.8, -1, -1]\n assert candidate(cars = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 10], [2, 9.5], [3, 9], [4, 8.5], [5, 8], [6, 7.5], [7, 7], [8, 6.5], [9, 6], [10, 5.5], [11, 5]]) == [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 15], [4, 12], [7, 9], [10, 6], [13, 3], [16, 2], [19, 1]]) == [1.0, 1.0, 1.0, 1.0, 3.0, 3.0, -1]\n"}, "metadata": {"canonical_parameter_names": ["cars"], "leetcode_dataset_entry_point": "Solution().getCollisionTimes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getCollisionTimes(self, cars: list[list[int]]) -> list[float]:", "container": "Solution", "callable": "getCollisionTimes", "parameters": [{"name": "cars", "type": "list[list[int]]"}], "return_type": "list[float]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1779, "task_id": "find-nearest-point-that-has-the-same-x-or-y-coordinate", "difficulty": "Easy", "problem_description": "You are given two integers, x and y, which represent your current location on a Cartesian grid: (x, y). You are also given an array points where each points[i] = [ai, bi] represents that a point exists at (ai, bi). A point is valid if it shares the same x-coordinate or the same y-coordinate as your location.\nReturn the index (0-indexed) of the valid point with the smallest Manhattan distance from your current location. If there are multiple, return the valid point with the smallest index. If there are no valid points, return -1.\nThe Manhattan distance between two points (x1, y1) and (x2, y2) is abs(x1 - x2) + abs(y1 - y2).\n \nExample 1:\n\nInput: x = 3, y = 4, points = [[1,2],[3,1],[2,4],[2,3],[4,4]]\nOutput: 2\nExplanation: Of all the points, only [3,1], [2,4] and [4,4] are valid. Of the valid points, [2,4] and [4,4] have the smallest Manhattan distance from your current location, with a distance of 1. [2,4] has the smallest index, so return 2.\nExample 2:\n\nInput: x = 3, y = 4, points = [[3,4]]\nOutput: 0\nExplanation: The answer is allowed to be on the same location as your current location.\nExample 3:\n\nInput: x = 3, y = 4, points = [[2,3]]\nOutput: -1\nExplanation: There are no valid points.\n \nConstraints:\n\n1 <= points.length <= 104\npoints[i].length == 2\n1 <= x, y, ai, bi <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(x = 3,y = 4,points = [[3, 4]]) == 0\n assert candidate(x = 5,y = 5,points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4]]) == 3\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4]]) == -1\n assert candidate(x = 3,y = 4,points = [[2, 3]]) == -1\n assert candidate(x = 1,y = 1,points = [[1, 1], [1, 2], [1, 3], [2, 1], [3, 1]]) == 0\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == -1\n assert candidate(x = 1,y = 1,points = [[1, 1], [1, 2], [2, 1], [2, 2]]) == 0\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5]]) == -1\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 9\n assert candidate(x = 100,y = 100,points = [[50, 100], [100, 50], [150, 100], [100, 150]]) == 0\n assert candidate(x = 5,y = 5,points = [[1, 1], [5, 5], [3, 3], [4, 4]]) == 1\n assert candidate(x = 5,y = 5,points = [[5, 5], [5, 6], [6, 5], [6, 6]]) == 0\n assert candidate(x = 1,y = 10,points = [[1, 1], [1, 2], [1, 3], [1, 4]]) == 3\n assert candidate(x = 5,y = 5,points = [[1, 5], [5, 1], [5, 9], [9, 5], [5, 5]]) == 4\n assert candidate(x = 5,y = 5,points = [[5, 1], [5, 2], [5, 3], [5, 4], [1, 5], [2, 5], [3, 5], [4, 5]]) == 3\n assert candidate(x = 5,y = 5,points = [[10, 10], [5, 5], [1, 1]]) == 1\n assert candidate(x = 1,y = 1,points = [[1, 2], [1, 3], [1, 4], [2, 1], [3, 1]]) == 0\n assert candidate(x = 5,y = 5,points = [[5, 5], [6, 6], [7, 7]]) == 0\n assert candidate(x = 10,y = 10,points = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == -1\n assert candidate(x = 2,y = 3,points = [[2, 3], [1, 1], [3, 3], [4, 4]]) == 0\n assert candidate(x = 10,y = 1,points = [[1, 1], [2, 1], [3, 1], [4, 1]]) == 3\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [4, 4]]) == -1\n assert candidate(x = 3,y = 4,points = [[1, 2], [3, 1], [2, 4], [2, 3], [4, 4]]) == 2\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [10, 10]]) == 3\n assert candidate(x = 5,y = 5,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 4\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 1], [1, 1], [1, 1], [1, 1]]) == 0\n assert candidate(x = 7,y = 7,points = [[6, 7], [7, 6], [7, 8], [8, 7]]) == 0\n assert candidate(x = 3,y = 3,points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 7\n assert candidate(x = 50,y = 50,points = [[49, 50], [51, 50], [50, 49], [50, 51], [48, 50], [52, 50], [50, 48], [50, 52]]) == 0\n assert candidate(x = 7,y = 8,points = [[7, 1], [1, 8], [7, 9], [9, 8], [7, 7], [8, 8]]) == 2\n assert candidate(x = 100,y = 100,points = [[99, 100], [100, 99], [101, 100], [100, 101], [98, 100], [100, 98]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 1], [4, 4], [5, 5], [1, 3], [3, 1]]) == 2\n assert candidate(x = 1,y = 2,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 2]]) == 9\n assert candidate(x = 7,y = 7,points = [[1, 1], [1, 7], [7, 1], [7, 7], [2, 2], [6, 6], [3, 3], [5, 5], [4, 4], [8, 8]]) == 3\n assert candidate(x = 2000,y = 2000,points = [[2000, 1999], [1999, 2000], [2000, 2001], [2001, 2000], [2000, 2000], [2000, 2002], [2002, 2000]]) == 4\n assert candidate(x = 20,y = 20,points = [[20, 19], [19, 20], [21, 20], [20, 21], [20, 20], [19, 19]]) == 4\n assert candidate(x = 5,y = 5,points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 3\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1]]) == 0\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [1, 1]]) == 5\n assert candidate(x = 7,y = 7,points = [[1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [8, 7], [9, 7], [10, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 8], [7, 9], [7, 10]]) == 5\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [1, 2], [2, 1]]) == 9\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 10], [10, 2], [5, 5], [10, 10], [1, 10], [10, 1]]) == 4\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [10, 1], [10, 2], [10, 3], [1, 10], [2, 10], [3, 10]]) == 5\n assert candidate(x = 100,y = 100,points = [[100, 100], [100, 99], [99, 100], [100, 101], [101, 100], [99, 99], [101, 101]]) == 0\n assert candidate(x = 5000,y = 5000,points = [[5000, 4999], [4999, 5000], [5000, 5001], [5001, 5000], [4999, 4999], [5001, 5001]]) == 0\n assert candidate(x = 5000,y = 5000,points = [[4999, 5000], [5000, 4999], [5001, 5000], [5000, 5001], [5000, 5000]]) == 4\n assert candidate(x = 2000,y = 3000,points = [[2000, 2999], [2000, 3001], [1999, 3000], [2001, 3000], [2000, 3000]]) == 4\n assert candidate(x = 20,y = 20,points = [[20, 1], [1, 20], [19, 20], [20, 19], [20, 18], [20, 17], [20, 16], [20, 15], [20, 14], [20, 13], [20, 12], [20, 11], [20, 10], [20, 9], [20, 8], [20, 7], [20, 6], [20, 5], [20, 4], [20, 3], [20, 2]]) == 2\n assert candidate(x = 20,y = 20,points = [[15, 20], [20, 15], [25, 20], [20, 25], [10, 10], [30, 30]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 0\n assert candidate(x = 7,y = 7,points = [[7, 1], [1, 7], [7, 2], [2, 7], [7, 3], [3, 7], [7, 4], [4, 7], [7, 5], [5, 7], [7, 6], [6, 7], [7, 7]]) == 12\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [1, 2], [2, 1]]) == 4\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == 4\n assert candidate(x = 2,y = 2,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 1\n assert candidate(x = 1,y = 100,points = [[1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [2, 100], [3, 100], [4, 100], [5, 100], [6, 100]]) == 5\n assert candidate(x = 5,y = 5,points = [[5, 6], [6, 5], [5, 4], [4, 5], [5, 5], [5, 3], [3, 5], [5, 7], [7, 5]]) == 4\n assert candidate(x = 1000,y = 1000,points = [[1000, 1000], [999, 1000], [1000, 999], [999, 999], [998, 998], [997, 997], [996, 996], [995, 995], [994, 994], [993, 993]]) == 0\n assert candidate(x = 12,y = 15,points = [[10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]]) == 2\n assert candidate(x = 1,y = 10000,points = [[1, 1], [1, 2], [1, 3], [1, 9999], [1, 10000], [1, 10001], [1, 9998]]) == 4\n assert candidate(x = 7,y = 7,points = [[7, 8], [8, 7], [6, 7], [7, 6], [7, 9], [9, 7], [7, 7], [7, 5], [5, 7]]) == 6\n assert candidate(x = 20,y = 25,points = [[15, 25], [25, 20], [20, 15], [20, 30], [30, 20], [20, 20]]) == 0\n assert candidate(x = 10,y = 10,points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [10, 9], [8, 7], [6, 5], [4, 3], [2, 1]]) == 4\n assert candidate(x = 30,y = 40,points = [[30, 35], [25, 40], [30, 45], [35, 40], [30, 40], [25, 35]]) == 4\n assert candidate(x = 10,y = 10,points = [[5, 10], [15, 10], [10, 5], [10, 15], [10, 10]]) == 4\n assert candidate(x = 1,y = 1,points = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2]]) == -1\n assert candidate(x = 1,y = 1,points = [[2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20]]) == 0\n assert candidate(x = 9,y = 9,points = [[9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [9, 10]]) == 8\n assert candidate(x = 3,y = 3,points = [[1, 3], [3, 1], [2, 3], [3, 2], [3, 3], [4, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9]]) == 4\n assert candidate(x = 9999,y = 9999,points = [[9998, 9998], [9997, 9997], [9996, 9996], [9995, 9995], [9994, 9994], [9999, 9998], [9999, 9997], [9999, 9996], [9999, 9995], [9999, 9994], [9998, 9999], [9997, 9999], [9996, 9999], [9995, 9999], [9994, 9999]]) == 5\n assert candidate(x = 5,y = 5,points = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [1, 5], [2, 5], [3, 5], [4, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 3\n assert candidate(x = 10000,y = 1,points = [[9999, 1], [10001, 1], [10000, 2], [10000, 100], [10000, 99], [10000, 10000], [10000, 9999]]) == 0\n assert candidate(x = 5000,y = 5000,points = [[1, 1], [10000, 10000], [5000, 1], [1, 5000], [5000, 5000], [4999, 4999], [5001, 5001]]) == 4\n assert candidate(x = 100,y = 1,points = [[50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6]]) == 5\n assert candidate(x = 5000,y = 5000,points = [[4999, 5000], [5001, 5000], [5000, 4999], [5000, 5001], [4998, 5000], [5002, 5000], [5000, 4998], [5000, 5002]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1]]) == 0\n assert candidate(x = 50,y = 50,points = [[50, 50], [50, 49], [49, 50], [50, 48], [48, 50], [50, 47], [47, 50], [50, 46], [46, 50], [50, 45], [45, 50]]) == 0\n assert candidate(x = 2500,y = 7500,points = [[2500, 7499], [2500, 7501], [2499, 7500], [2501, 7500], [2498, 7500], [2502, 7500], [2500, 7498], [2500, 7502]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 1]]) == 4\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 1], [2, 2], [3, 3]]) == 4\n assert candidate(x = 10,y = 10,points = [[5, 10], [10, 5], [10, 15], [15, 10], [10, 10], [11, 10], [10, 11], [9, 10], [10, 9]]) == 4\n assert candidate(x = 5,y = 5,points = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 3\n assert candidate(x = 6,y = 6,points = [[5, 6], [6, 5], [7, 6], [6, 7], [6, 6], [5, 5], [7, 7], [5, 7], [7, 5]]) == 4\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1]]) == 9\n assert candidate(x = 1,y = 10000,points = [[1, 1], [1, 9999], [1, 10001], [2, 10000], [1, 2], [1, 100], [1, 99], [1, 9998], [1, 10002]]) == 1\n assert candidate(x = 10,y = 10,points = [[10, 1], [1, 10], [10, 10], [5, 5], [10, 9], [9, 10]]) == 2\n assert candidate(x = 15,y = 20,points = [[10, 20], [15, 10], [20, 15], [15, 20], [10, 10], [20, 20]]) == 3\n assert candidate(x = 2,y = 2,points = [[2, 1], [1, 2], [3, 2], [2, 3], [1, 1], [3, 1], [1, 3], [3, 3], [2, 4], [4, 2], [4, 3], [3, 4], [4, 4]]) == 0\n assert candidate(x = 5,y = 5,points = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 5], [7, 5], [8, 5], [9, 5]]) == 0\n assert candidate(x = 3,y = 3,points = [[1, 3], [2, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3], [3, 1], [3, 2], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]]) == 1\n assert candidate(x = 7,y = 7,points = [[5, 7], [6, 8], [7, 9], [8, 6], [9, 5], [7, 7], [7, 8], [8, 7]]) == 5\n assert candidate(x = 100,y = 100,points = [[100, 50], [50, 100], [100, 60], [60, 100], [100, 70], [70, 100], [100, 80], [80, 100], [100, 90], [90, 100]]) == 8\n assert candidate(x = 10000,y = 1,points = [[1, 1], [2, 1], [3, 1], [9999, 1], [10000, 1], [10001, 1], [9998, 1]]) == 4\n assert candidate(x = 7,y = 7,points = [[1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [8, 7], [9, 7], [10, 7]]) == 5\n assert candidate(x = 5000,y = 5000,points = [[5000, 5000], [5001, 5000], [4999, 5000], [5000, 5001], [5000, 4999]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 1], [1, 0], [0, 1]]) == 2\n assert candidate(x = 100,y = 100,points = [[99, 100], [100, 99], [100, 101], [101, 100], [98, 100], [100, 98], [99, 99], [101, 101]]) == 0\n assert candidate(x = 100,y = 100,points = [[50, 100], [100, 50], [150, 100], [100, 150], [100, 100]]) == 4\n assert candidate(x = 500,y = 500,points = [[500, 1], [1, 500], [500, 499], [499, 500], [10, 10], [490, 490], [50, 50], [1, 1], [500, 500]]) == 8\n assert candidate(x = 100,y = 100,points = [[100, 1], [1, 100], [99, 100], [100, 99], [10, 10], [90, 90], [50, 50], [1, 1], [100, 100]]) == 8\n assert candidate(x = 50,y = 50,points = [[50, 1], [50, 99], [1, 50], [99, 50], [50, 2], [2, 50], [50, 3], [3, 50], [50, 4], [4, 50]]) == 8\n assert candidate(x = 5000,y = 5000,points = [[4999, 4999], [5001, 5001], [4998, 5000], [5000, 4998], [5000, 5001], [5001, 5000], [4999, 5001], [5001, 4999]]) == 4\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [10, 5], [5, 10], [10, 10]]) == 5\n assert candidate(x = 100,y = 100,points = [[99, 100], [100, 99], [98, 100], [100, 98], [99, 99], [101, 100], [100, 101]]) == 0\n assert candidate(x = 5000,y = 5000,points = [[1, 1], [10000, 10000], [5000, 1], [1, 5000], [5000, 5001], [5001, 5000]]) == 4\n assert candidate(x = 100,y = 100,points = [[100, 99], [99, 100], [101, 100], [100, 101], [100, 100]]) == 4\n assert candidate(x = 10,y = 10,points = [[10, 10], [9, 10], [10, 9], [11, 10], [10, 11], [9, 9], [11, 11]]) == 0\n assert candidate(x = 7,y = 7,points = [[6, 7], [8, 7], [7, 6], [7, 8], [5, 7], [7, 5], [9, 7], [7, 9], [7, 7], [6, 6], [8, 8]]) == 8\n assert candidate(x = 7,y = 3,points = [[7, 8], [7, 2], [6, 3], [8, 3], [7, 0], [7, 6], [5, 3], [9, 3]]) == 1\n assert candidate(x = 10000,y = 1,points = [[9999, 1], [10000, 2], [10001, 1], [1, 10000], [10000, 1], [10000, 3], [9998, 1]]) == 4\n assert candidate(x = 5000,y = 5000,points = [[5000, 5001], [5001, 5000], [4999, 5000], [5000, 4999], [5000, 5000], [1, 1], [10000, 10000]]) == 4\n assert candidate(x = 50,y = 50,points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == 4\n assert candidate(x = 3,y = 3,points = [[1, 3], [2, 3], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 3], [5, 3]]) == 4\n assert candidate(x = 10000,y = 10000,points = [[10000, 9999], [9999, 10000], [10000, 10000], [5000, 5000]]) == 2\n assert candidate(x = 25,y = 25,points = [[25, 10], [10, 25], [25, 15], [15, 25], [25, 20], [20, 25], [25, 5], [5, 25], [25, 30], [30, 25]]) == 4\n assert candidate(x = 15,y = 20,points = [[15, 1], [1, 20], [15, 3], [3, 20], [15, 4], [4, 20], [15, 5], [5, 20], [15, 6], [6, 20]]) == 9\n assert candidate(x = 1,y = 10000,points = [[1, 9999], [2, 10000], [1, 10001], [10000, 1], [1, 1], [10000, 10000], [1, 9998]]) == 0\n assert candidate(x = 20,y = 15,points = [[15, 20], [20, 15], [10, 10], [25, 25], [5, 5], [30, 30], [15, 15], [20, 20]]) == 1\n assert candidate(x = 3,y = 3,points = [[3, 2], [2, 3], [3, 4], [4, 3], [3, 1], [1, 3], [3, 5], [5, 3], [3, 6], [6, 3], [3, 0], [0, 3], [3, 7], [7, 3]]) == 0\n assert candidate(x = 10,y = 10,points = [[10, 1], [1, 10], [10, 10], [9, 10], [10, 9]]) == 2\n assert candidate(x = 8,y = 7,points = [[8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9], [8, 10]]) == 6\n"}, "metadata": {"canonical_parameter_names": ["x", "y", "points"], "leetcode_dataset_entry_point": "Solution().nearestValidPoint", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def nearestValidPoint(self, x: int, y: int, points: list[list[int]]) -> int:", "container": "Solution", "callable": "nearestValidPoint", "parameters": [{"name": "x", "type": "int"}, {"name": "y", "type": "int"}, {"name": "points", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1780, "task_id": "check-if-number-is-a-sum-of-powers-of-three", "difficulty": "Medium", "problem_description": "Given an integer n, return true if it is possible to represent n as the sum of distinct powers of three. Otherwise, return false.\nAn integer y is a power of three if there exists an integer x such that y == 3x.\n \nExample 1:\n\nInput: n = 12\nOutput: true\nExplanation: 12 = 31 + 32\n\nExample 2:\n\nInput: n = 91\nOutput: true\nExplanation: 91 = 30 + 32 + 34\n\nExample 3:\n\nInput: n = 21\nOutput: false\n\n \nConstraints:\n\n1 <= n <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 59049) == True\n assert candidate(n = 3) == True\n assert candidate(n = 729) == True\n assert candidate(n = 12) == True\n assert candidate(n = 243) == True\n assert candidate(n = 21) == False\n assert candidate(n = 4782969) == True\n assert candidate(n = 19683) == True\n assert candidate(n = 1594323) == True\n assert candidate(n = 40) == True\n assert candidate(n = 59048) == False\n assert candidate(n = 1093) == True\n assert candidate(n = 10000000) == False\n assert candidate(n = 100000) == False\n assert candidate(n = 27) == True\n assert candidate(n = 6561) == True\n assert candidate(n = 3645) == False\n assert candidate(n = 2187) == True\n assert candidate(n = 177147) == True\n assert candidate(n = 91) == True\n assert candidate(n = 81) == True\n assert candidate(n = 531441) == True\n assert candidate(n = 1000000) == False\n assert candidate(n = 1000001) == False\n assert candidate(n = 9) == True\n assert candidate(n = 98415) == False\n assert candidate(n = 1) == True\n assert candidate(n = 10) == True\n assert candidate(n = 89076) == False\n assert candidate(n = 9999999) == False\n assert candidate(n = 98416) == False\n assert candidate(n = 39856) == False\n assert candidate(n = 1640261) == False\n assert candidate(n = 59050) == True\n assert candidate(n = 9876543) == False\n assert candidate(n = 32804) == False\n assert candidate(n = 819) == True\n assert candidate(n = 14348907) == True\n assert candidate(n = 9841) == True\n assert candidate(n = 8) == False\n assert candidate(n = 810000) == False\n assert candidate(n = 8191) == False\n assert candidate(n = 72900) == False\n assert candidate(n = 524880) == False\n assert candidate(n = 7290) == True\n assert candidate(n = 11) == False\n assert candidate(n = 1048575) == False\n assert candidate(n = 59250) == False\n assert candidate(n = 109355) == False\n assert candidate(n = 10935) == False\n assert candidate(n = 98414) == False\n assert candidate(n = 2391484) == True\n assert candidate(n = 88572) == True\n assert candidate(n = 32805) == False\n assert candidate(n = 88573) == True\n assert candidate(n = 50000) == False\n assert candidate(n = 1049755) == False\n assert candidate(n = 590490) == True\n assert candidate(n = 4) == True\n assert candidate(n = 98411) == False\n assert candidate(n = 6560) == False\n assert candidate(n = 4100) == False\n assert candidate(n = 19684) == True\n assert candidate(n = 531442) == True\n assert candidate(n = 49308) == False\n assert candidate(n = 39858) == False\n assert candidate(n = 59047) == False\n assert candidate(n = 99018) == False\n assert candidate(n = 98409) == False\n assert candidate(n = 58324) == False\n assert candidate(n = 48619) == False\n assert candidate(n = 69192) == False\n assert candidate(n = 369059) == False\n assert candidate(n = 4052555) == False\n assert candidate(n = 1291401) == False\n assert candidate(n = 98413) == False\n assert candidate(n = 3486784400) == False\n assert candidate(n = 14348908) == True\n assert candidate(n = 131220) == False\n assert candidate(n = 437400) == False\n assert candidate(n = 2) == False\n assert candidate(n = 4000000) == False\n assert candidate(n = 981) == True\n assert candidate(n = 97656) == False\n assert candidate(n = 3986) == False\n assert candidate(n = 19682) == False\n assert candidate(n = 797162) == False\n assert candidate(n = 656100) == False\n assert candidate(n = 3486784401) == True\n assert candidate(n = 45927) == False\n assert candidate(n = 79134) == False\n assert candidate(n = 1234567) == False\n assert candidate(n = 3125) == False\n assert candidate(n = 2097152) == False\n assert candidate(n = 98410) == False\n assert candidate(n = 99999) == False\n assert candidate(n = 728997) == False\n assert candidate(n = 405224) == False\n assert candidate(n = 31259) == False\n assert candidate(n = 119050) == False\n assert candidate(n = 104976) == False\n assert candidate(n = 546789) == False\n assert candidate(n = 39366) == False\n assert candidate(n = 40000) == False\n assert candidate(n = 29524) == True\n assert candidate(n = 98412) == False\n assert candidate(n = 400) == False\n assert candidate(n = 32806) == False\n assert candidate(n = 3188646) == False\n assert candidate(n = 123456) == False\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().checkPowersOfThree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def checkPowersOfThree(self, n: int) -> bool:", "container": "Solution", "callable": "checkPowersOfThree", "parameters": [{"name": "n", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1781, "task_id": "sum-of-beauty-of-all-substrings", "difficulty": "Medium", "problem_description": "The beauty of a string is the difference in frequencies between the most frequent and least frequent characters.\n\nFor example, the beauty of \"abaacc\" is 3 - 1 = 2.\n\nGiven a string s, return the sum of beauty of all of its substrings.\n \nExample 1:\n\nInput: s = \"aabcb\"\nOutput: 5\nExplanation: The substrings with non-zero beauty are [\"aab\",\"aabc\",\"aabcb\",\"abcb\",\"bcb\"], each with beauty equal to 1.\nExample 2:\n\nInput: s = \"aabcbaa\"\nOutput: 17\n\n \nConstraints:\n\n1 <= s.length <= 500\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"xyzzxyzzxyzz\") == 87\n assert candidate(s = \"aaabbbccc\") == 29\n assert candidate(s = \"aabcb\") == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(s = \"abcdedcba\") == 16\n assert candidate(s = \"a\") == 0\n assert candidate(s = \"abcabcabc\") == 16\n assert candidate(s = \"zzzz\") == 0\n assert candidate(s = \"aabcbaa\") == 17\n assert candidate(s = \"pqrspqrspqrspqrs\") == 63\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 0\n assert candidate(s = \"xyzxyzxyz\") == 16\n assert candidate(s = \"abcdabcdabcd\") == 30\n assert candidate(s = \"abc\") == 0\n assert candidate(s = \"xyzzxyzz\") == 25\n assert candidate(s = \"abcd\") == 0\n assert candidate(s = \"aabbccddeeff\") == 40\n assert candidate(s = \"zzzzz\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 950\n assert candidate(s = \"abcdefg\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\") == 1112\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 432\n assert candidate(s = \"pqrstuvwxyzabcdefghijklmno\") == 0\n assert candidate(s = \"abccbaabccbaabccbaabccba\") == 222\n assert candidate(s = \"verycomplicatedstringwithrepeatedcharactersrepeatedrepeated\") == 5556\n assert candidate(s = \"mississippimississippimississippimississippi\") == 4387\n assert candidate(s = \"abracadabra\") == 64\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 2236\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacaba\") == 11131\n assert candidate(s = \"abcabcabcabc\") == 33\n assert candidate(s = \"xzyxzxyzxyz\") == 34\n assert candidate(s = \"abcdefabcdeabcdeabcde\") == 183\n assert candidate(s = \"aabacababa\") == 66\n assert candidate(s = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"abcdefghijklmabcdefghijklm\") == 90\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 1170\n assert candidate(s = \"abababababababababababababababab\") == 240\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabc\") == 456\n assert candidate(s = \"mississippiissiippiisppiiiiiiii\") == 1732\n assert candidate(s = \"abacabadabacabadabacabadabacaba\") == 2047\n assert candidate(s = \"thisisaverylongandcomplicatedstringwithvariouscharacters\") == 2645\n assert candidate(s = \"mnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 325\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 513\n assert candidate(s = \"kayak\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 261\n assert candidate(s = \"xyzzzzxyzzzzxyzzzzxyzzzz\") == 1254\n assert candidate(s = \"ababababababab\") == 42\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\") == 1\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdef\") == 400\n assert candidate(s = \"abcdabcdabcdabcd\") == 63\n assert candidate(s = \"level\") == 4\n assert candidate(s = \"ppppppppppppppppppppppppppppppppppqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 13090\n assert candidate(s = \"xyzzyxzyxzyzyx\") == 87\n assert candidate(s = \"pqrsrstsrqpqrs\") == 102\n assert candidate(s = \"madam\") == 4\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 1053\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwerty\") == 21\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 2450\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggg\") == 630\n assert candidate(s = \"abacabadabacaba\") == 231\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\") == 702\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 44628\n assert candidate(s = \"xyzzazxzy\") == 45\n assert candidate(s = \"abababababababababababababababababababababababab\") == 552\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\") == 1275\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 1350\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjaabbccddeeffgghhiijjaabbccddeeffgghhiijj\") == 2118\n assert candidate(s = \"bananaananabananananabananananananananananananana\") == 7610\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"banana\") == 8\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzz\") == 11722\n assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrs\") == 1071\n assert candidate(s = \"aabbccddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxxyyyzzz\") == 4312\n assert candidate(s = \"aaaaabbbbccccddddeeeffffggghhh\") == 782\n assert candidate(s = \"nnnnoonnmnmlmllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll\") == 33629\n assert candidate(s = \"aaaabbbbccccdddd\") == 162\n assert candidate(s = \"abacabadabacabadabacabad\") == 948\n assert candidate(s = \"deified\") == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"repaper\") == 9\n assert candidate(s = \"xyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzz\") == 17541\n assert candidate(s = \"aabbaaabbbaaabbaaaabbbaaabbaaaabbbaaabbaaaabbbaaabbaaaab\") == 5129\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzz\") == 11950\n assert candidate(s = \"aabbccddeeffgghhiijjanmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 1979\n assert candidate(s = \"abababababababababababab\") == 132\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 350\n assert candidate(s = \"rotor\") == 4\n assert candidate(s = \"racecar\") == 9\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 320\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 161\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 350\n assert candidate(s = \"reviled\") == 4\n assert candidate(s = \"mnopqrnopqmonmnopq\") == 145\n assert candidate(s = \"abacabadaba\") == 85\n assert candidate(s = \"mississippi\") == 64\n assert candidate(s = \"aaaaabbbbccccddddeeeffffgggghhhhiiiiijjjjkkkkllllmmmmmnnnnnooooo\") == 4941\n assert candidate(s = \"abcabcabcabcabc\") == 56\n assert candidate(s = \"xyzzzzzxyzzzzzxyzzzzz\") == 936\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"refer\") == 4\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().beautySum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def beautySum(self, s: str) -> int:", "container": "Solution", "callable": "beautySum", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1782, "task_id": "count-pairs-of-nodes", "difficulty": "Hard", "problem_description": "You are given an undirected graph defined by an integer n, the number of nodes, and a 2D integer array edges, the edges in the graph, where edges[i] = [ui, vi] indicates that there is an undirected edge between ui and vi. You are also given an integer array queries.\nLet incident(a, b) be defined as the number of edges that are connected to either node a or b.\nThe answer to the jth query is the number of pairs of nodes (a, b) that satisfy both of the following conditions:\n\na < b\nincident(a, b) > queries[j]\n\nReturn an array answers such that answers.length == queries.length and answers[j] is the answer of the jth query.\nNote that there can be multiple edges between the same two nodes.\n \nExample 1:\n\n\nInput: n = 4, edges = [[1,2],[2,4],[1,3],[2,3],[2,1]], queries = [2,3]\nOutput: [6,5]\nExplanation: The calculations for incident(a, b) are shown in the table above.\nThe answers for each of the queries are as follows:\n- answers[0] = 6. All the pairs have an incident(a, b) value greater than 2.\n- answers[1] = 5. All the pairs except (3, 4) have an incident(a, b) value greater than 3.\n\nExample 2:\n\nInput: n = 5, edges = [[1,5],[1,5],[3,4],[2,5],[1,3],[5,1],[2,3],[2,5]], queries = [1,2,3,4,5]\nOutput: [10,10,9,8,6]\n\n \nConstraints:\n\n2 <= n <= 2 * 104\n1 <= edges.length <= 105\n1 <= ui, vi <= n\nui != vi\n1 <= queries.length <= 20\n0 <= queries[j] < edges.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[1, 2], [2, 4], [1, 3], [2, 3], [2, 1]],queries = [2, 3]) == [6, 5]\n assert candidate(n = 5,edges = [[1, 5], [1, 5], [3, 4], [2, 5], [1, 3], [5, 1], [2, 3], [2, 5]],queries = [1, 2, 3, 4, 5]) == [10, 10, 9, 8, 6]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [9, 10]],queries = [5, 10, 15]) == [45, 8, 0]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20]],queries = [3, 4, 5, 6]) == [190, 187, 183, 148]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15]],queries = [7, 8, 9, 10, 11]) == [75, 69, 24, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]],queries = [3, 5, 7, 9]) == [41, 33, 1, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10]],queries = [5, 6, 7]) == [16, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]],queries = [1, 5, 9]) == [45, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 6], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 7]],queries = [3, 8, 13]) == [176, 15, 0]\n assert candidate(n = 100,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 1], [10, 2], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 1], [9, 2], [10, 3], [1, 4], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 1], [8, 2], [9, 3], [10, 4]],queries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [945, 945, 945, 945, 945, 945, 945, 765, 45, 45, 45]\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20]],queries = [5, 15, 25, 35, 45]) == [190, 85, 10, 10, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14], [8, 15]],queries = [10, 12, 14]) == [12, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30], [29, 1], [30, 2]],queries = [15, 20, 25, 30, 35]) == [0, 0, 0, 0, 0]\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [1, 25], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25]],queries = [4, 9, 14]) == [300, 0, 0]\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15], [14, 16], [15, 16], [15, 17], [16, 17], [16, 18], [17, 18], [17, 19], [18, 19], [19, 20], [19, 21], [20, 21], [20, 22], [20, 23], [21, 22], [21, 23], [22, 23], [22, 24], [22, 25], [23, 24], [23, 25], [24, 25]],queries = [6, 12, 18, 24]) == [283, 0, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10], [2, 5], [3, 7], [4, 8], [5, 9], [6, 10]],queries = [4, 5, 6, 7, 8]) == [43, 28, 4, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [2, 30], [3, 29], [4, 28], [5, 27], [6, 26], [7, 25], [8, 24], [9, 23], [10, 22], [11, 21], [12, 20], [13, 19], [14, 18], [15, 17], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]],queries = [20, 25, 30, 35, 40, 45]) == [29, 29, 14, 0, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21], [11, 20], [12, 19], [13, 18], [14, 17], [15, 16]],queries = [0, 5, 10, 15, 20, 25, 30]) == [435, 338, 0, 0, 0, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [13, 14], [13, 15], [14, 15], [14, 16], [15, 16], [15, 17], [16, 17], [16, 18], [17, 18], [17, 19], [18, 19], [19, 20], [20, 1]],queries = [5, 10, 15, 20]) == [184, 0, 0, 0]\n assert candidate(n = 50,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30], [29, 31], [30, 32], [31, 33], [32, 34], [33, 35], [34, 36], [35, 37], [36, 38], [37, 39], [38, 40], [39, 41], [40, 42], [41, 43], [42, 44], [43, 45], [44, 46], [45, 47], [46, 48], [47, 49], [48, 50]],queries = [10, 20, 30, 40, 50]) == [0, 0, 0, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 1], [12, 2]],queries = [3, 4, 5, 6, 7]) == [66, 66, 66, 66, 42]\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 1], [25, 2], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17], [15, 18], [16, 19], [17, 20], [18, 21], [19, 22], [20, 23], [21, 24], [22, 25], [23, 1], [24, 2], [25, 3]],queries = [10, 15, 20, 25, 30]) == [300, 0, 0, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 1], [1, 13], [2, 14], [3, 15], [4, 16], [5, 17], [6, 18], [7, 19], [8, 20], [9, 21], [10, 22], [11, 23], [12, 24], [13, 25], [14, 26], [15, 27], [16, 28], [17, 29], [18, 30], [19, 1], [20, 2], [21, 3], [22, 4], [23, 5], [24, 6], [25, 7], [26, 8], [27, 9], [28, 10], [29, 11], [30, 12]],queries = [20, 40, 60, 80, 100]) == [0, 0, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14], [8, 15], [9, 1], [10, 2], [11, 3], [12, 4], [13, 5], [14, 6], [15, 7]],queries = [10, 15, 20, 25]) == [0, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 2], [1, 3], [2, 3], [2, 3], [2, 4], [3, 4], [3, 5], [4, 5], [4, 6], [5, 6], [5, 7], [6, 7], [6, 8], [7, 8], [7, 9], [8, 9], [8, 10], [9, 10], [9, 11], [10, 11], [10, 12], [11, 12], [11, 13], [12, 13], [12, 14], [13, 14], [13, 15], [14, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [105, 105, 105, 104, 102, 89, 51, 17, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],queries = [3, 4, 5, 6, 7, 8]) == [136, 0, 0, 0, 0, 0]\n assert candidate(n = 18,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 1], [18, 2]],queries = [5, 10, 15, 20]) == [153, 0, 0, 0]\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [1, 25], [1, 24], [2, 23], [2, 22], [3, 21], [3, 20], [4, 19], [4, 18], [5, 17], [5, 16], [6, 15], [6, 14], [7, 13], [7, 12], [8, 11], [8, 10], [9, 9], [10, 8], [11, 7], [12, 6], [13, 5], [14, 4], [15, 3], [16, 2], [17, 1]],queries = [15, 20, 25, 30, 35]) == [0, 0, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 15], [1, 15], [2, 15], [3, 15], [4, 15]],queries = [8, 9, 10, 11]) == [6, 0, 0, 0]\n assert candidate(n = 100,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 5], [2, 6], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50], [50, 51], [51, 52], [52, 53], [53, 54], [54, 55], [55, 56], [56, 57], [57, 58], [58, 59], [59, 60], [60, 61], [61, 62], [62, 63], [63, 64], [64, 65], [65, 66], [66, 67], [67, 68], [68, 69], [69, 70], [70, 71], [71, 72], [72, 73], [73, 74], [74, 75], [75, 76], [76, 77], [77, 78], [78, 79], [79, 80], [80, 81], [81, 82], [82, 83], [83, 84], [84, 85], [85, 86], [86, 87], [87, 88], [88, 89], [89, 90], [90, 91], [91, 92], [92, 93], [93, 94], [94, 95], [95, 96], [96, 97], [97, 98], [98, 99], [99, 100]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1], [1, 12], [2, 13], [3, 14], [4, 15], [5, 16], [6, 17], [7, 18], [8, 19], [9, 20], [10, 21], [11, 22], [12, 23], [13, 24], [14, 25], [15, 1], [16, 2], [17, 3], [18, 4], [19, 5], [20, 6], [21, 7], [22, 8], [23, 9], [24, 10], [25, 11]],queries = [15, 30, 45, 60, 75]) == [0, 0, 0, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20]],queries = [5, 10, 15, 20, 25]) == [187, 0, 0, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [9, 10]],queries = [5, 10, 15]) == [45, 8, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [5, 6, 7]) == [8, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20]],queries = [10, 20, 30, 40]) == [0, 0, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],queries = [10, 15, 20, 25, 30]) == [0, 0, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [4, 8], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [6, 10], [7, 8], [7, 9], [7, 10], [7, 11], [8, 9], [8, 10], [8, 11], [8, 12], [9, 10], [9, 11], [9, 12], [9, 13], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [11, 15], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15]],queries = [10, 20, 30, 40]) == [91, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8]],queries = [1, 2, 3, 4, 5]) == [28, 28, 28, 28, 28]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [1, 12], [2, 13], [3, 14], [4, 15], [5, 16], [6, 17], [7, 18], [8, 19], [9, 20]],queries = [10, 15, 20, 25]) == [0, 0, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15], [14, 16], [15, 16], [15, 17], [16, 17], [16, 18], [17, 18], [17, 19], [18, 19], [19, 20], [19, 21], [20, 21], [20, 22], [20, 23], [21, 22], [21, 23], [22, 23], [22, 24], [22, 25], [23, 24], [23, 25], [24, 25], [24, 26], [24, 27], [25, 26], [25, 27], [26, 27], [26, 28], [26, 29], [27, 28], [27, 29], [28, 29], [28, 30], [29, 30]],queries = [7, 14, 21, 28]) == [360, 0, 0, 0]\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 1], [25, 2]],queries = [15, 20, 25, 30]) == [0, 0, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],queries = [5, 10, 15]) == [36, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]],queries = [4, 8, 12, 16]) == [76, 1, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30]],queries = [5, 10, 15]) == [432, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [1, 15]],queries = [2, 7, 12]) == [105, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 5], [2, 6], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]],queries = [5, 6, 7]) == [19, 4, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]],queries = [5, 10, 15]) == [24, 7, 0]\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 1], [15, 2], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 1], [14, 2], [15, 3]],queries = [10, 15, 20, 25, 30]) == [105, 0, 0, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],queries = [0, 5, 10, 15, 20]) == [190, 128, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [1, 15], [2, 14], [3, 13], [4, 12], [5, 11], [6, 10], [7, 9]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [105, 105, 104, 98, 50, 0, 0, 0, 0, 0]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "queries"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countPairs(self, n: int, edges: list[list[int]], queries: list[int]) -> list[int]:", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "queries", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1784, "task_id": "check-if-binary-string-has-at-most-one-segment-of-ones", "difficulty": "Easy", "problem_description": "Given a binary string s ​​​​​without leading zeros, return true​​​ if s contains at most one contiguous segment of ones. Otherwise, return false.\n \nExample 1:\n\nInput: s = \"1001\"\nOutput: false\nExplanation: The ones do not form a contiguous segment.\n\nExample 2:\n\nInput: s = \"110\"\nOutput: true\n \nConstraints:\n\n1 <= s.length <= 100\ns[i]​​​​ is either '0' or '1'.\ns[0] is '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == True\n assert candidate(s = \"1000001\") == False\n assert candidate(s = \"111\") == True\n assert candidate(s = \"11110000\") == True\n assert candidate(s = \"100000\") == True\n assert candidate(s = \"11000\") == True\n assert candidate(s = \"111000\") == True\n assert candidate(s = \"1001001\") == False\n assert candidate(s = \"1111111111\") == True\n assert candidate(s = \"100001\") == False\n assert candidate(s = \"1000000000\") == True\n assert candidate(s = \"101\") == False\n assert candidate(s = \"10\") == True\n assert candidate(s = \"110\") == True\n assert candidate(s = \"110001\") == False\n assert candidate(s = \"1010101010\") == False\n assert candidate(s = \"1\") == True\n assert candidate(s = \"1100111\") == False\n assert candidate(s = \"101010\") == False\n assert candidate(s = \"111110000\") == True\n assert candidate(s = \"1001\") == False\n assert candidate(s = \"11001\") == False\n assert candidate(s = \"101010101010101\") == False\n assert candidate(s = \"1000000000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"11110000001\") == False\n assert candidate(s = \"111000111000111000111000111000111000111000111000111\") == False\n assert candidate(s = \"111000111000111000\") == False\n assert candidate(s = \"1000000000000000000000000001\") == False\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"1000010001000100\") == False\n assert candidate(s = \"10000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"1111111\") == True\n assert candidate(s = \"111000111000111\") == False\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"111111111111111111111\") == True\n assert candidate(s = \"1100110011\") == False\n assert candidate(s = \"11100000000000\") == True\n assert candidate(s = \"1010101010101010\") == False\n assert candidate(s = \"10000000000000000000\") == True\n assert candidate(s = \"111100000000\") == True\n assert candidate(s = \"11110001\") == False\n assert candidate(s = \"1111111111111110000000000001111111111111\") == False\n assert candidate(s = \"11110000111100001111\") == False\n assert candidate(s = \"101010101010\") == False\n assert candidate(s = \"111000000000000000000\") == True\n assert candidate(s = \"111111111111110000000000000\") == True\n assert candidate(s = \"100000000000100000\") == False\n assert candidate(s = \"100000000000\") == True\n assert candidate(s = \"1110001\") == False\n assert candidate(s = \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"1111111111111111\") == True\n assert candidate(s = \"1001001001\") == False\n assert candidate(s = \"1000000000000000000000000000000000000001\") == False\n assert candidate(s = \"100000000000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"1111111000000\") == True\n assert candidate(s = \"111011101110111011101\") == False\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001\") == False\n assert candidate(s = \"100000000000000000001\") == False\n assert candidate(s = \"11100000000111\") == False\n assert candidate(s = \"100000000001\") == False\n assert candidate(s = \"1001001001001001\") == False\n assert candidate(s = \"100000000000000\") == True\n assert candidate(s = \"1100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011\") == False\n assert candidate(s = \"10000000001\") == False\n assert candidate(s = \"111000111000\") == False\n assert candidate(s = \"10111000110\") == False\n assert candidate(s = \"111100001111\") == False\n assert candidate(s = \"100010001000100010001\") == False\n assert candidate(s = \"1000000000000000\") == True\n assert candidate(s = \"111110111111\") == False\n assert candidate(s = \"111111000000\") == True\n assert candidate(s = \"11011011011011011011\") == False\n assert candidate(s = \"1000000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"11010101010101\") == False\n assert candidate(s = \"11111000001\") == False\n assert candidate(s = \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"1000100010\") == False\n assert candidate(s = \"1110000000000001\") == False\n assert candidate(s = \"10000000100000001\") == False\n assert candidate(s = \"100000010000001000000\") == False\n assert candidate(s = \"10000100001\") == False\n assert candidate(s = \"1110000000\") == True\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"10101010101010101\") == False\n assert candidate(s = \"11100000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"1111000011110000\") == False\n assert candidate(s = \"10101010101010101010101010101010\") == False\n assert candidate(s = \"1111100000\") == True\n assert candidate(s = \"1111000000001111\") == False\n assert candidate(s = \"11110000100001110000\") == False\n assert candidate(s = \"111000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000111\") == False\n assert candidate(s = \"1101101101\") == False\n assert candidate(s = \"1001001001001\") == False\n assert candidate(s = \"1110111100001\") == False\n assert candidate(s = \"110001000000\") == False\n assert candidate(s = \"111111111100\") == True\n assert candidate(s = \"1100000000000001\") == False\n assert candidate(s = \"10000000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"11001100110011\") == False\n assert candidate(s = \"1110000000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"11000001111\") == False\n assert candidate(s = \"11111111110000000000000000000000000000000000000000\") == True\n assert candidate(s = \"1111000011\") == False\n assert candidate(s = \"10101010101010101010\") == False\n assert candidate(s = \"10000111111110\") == False\n assert candidate(s = \"10000111110001\") == False\n assert candidate(s = \"10101010101010\") == False\n assert candidate(s = \"1000001000001000001\") == False\n assert candidate(s = \"1000000010000\") == False\n assert candidate(s = \"10000000000001\") == False\n assert candidate(s = \"11100001\") == False\n assert candidate(s = \"1000000000000001\") == False\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().checkOnesSegment", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def checkOnesSegment(self, s: str) -> bool:", "container": "Solution", "callable": "checkOnesSegment", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1785, "task_id": "minimum-elements-to-add-to-form-a-given-sum", "difficulty": "Medium", "problem_description": "You are given an integer array nums and two integers limit and goal. The array nums has an interesting property that abs(nums[i]) <= limit.\nReturn the minimum number of elements you need to add to make the sum of the array equal to goal. The array must maintain its property that abs(nums[i]) <= limit.\nNote that abs(x) equals x if x >= 0, and -x otherwise.\n \nExample 1:\n\nInput: nums = [1,-1,1], limit = 3, goal = -4\nOutput: 2\nExplanation: You can add -2 and -3, then the sum of the array will be 1 - 1 + 1 - 2 - 3 = -4.\n\nExample 2:\n\nInput: nums = [1,-10,9,1], limit = 100, goal = 0\nOutput: 1\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= limit <= 106\n-limit <= nums[i] <= limit\n-109 <= goal <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, -1, 1],limit = 3,goal = -4) == 2\n assert candidate(nums = [1, 2, 3],limit = 1,goal = 6) == 0\n assert candidate(nums = [1, -10, 9, 1],limit = 100,goal = 0) == 1\n assert candidate(nums = [0, 0, 0],limit = 1,goal = 3) == 3\n assert candidate(nums = [0, 0, 0, 0],limit = 5,goal = 10) == 2\n assert candidate(nums = [2, 2, 2],limit = 2,goal = 6) == 0\n assert candidate(nums = [-3, -2, -1],limit = 1,goal = -9) == 3\n assert candidate(nums = [-5, -5, -5],limit = 5,goal = 15) == 6\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],limit = 5,goal = 50) == 10\n assert candidate(nums = [10, -10, 20, -20, 30, -30],limit = 15,goal = 0) == 0\n assert candidate(nums = [500000, -250000, 125000, -62500, 31250, -15625],limit = 100000,goal = 1000000) == 7\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000],limit = 100000,goal = 1500000) == 0\n assert candidate(nums = [999999, -999999, 999998, -999998, 999997, -999997],limit = 1000000,goal = -1000000) == 1\n assert candidate(nums = [1000000, -1000000, 500000, -500000],limit = 1000000,goal = 0) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 2,goal = -15) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = -10) == 20\n assert candidate(nums = [5, 10, 15, 20, 25],limit = 10,goal = 100) == 3\n assert candidate(nums = [1, -2, 3, -4, 5],limit = 2,goal = -10) == 7\n assert candidate(nums = [100, -100, 200, -200, 300, -300],limit = 100,goal = -1500) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 3,goal = 0) == 19\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000],limit = 1000000,goal = 0) == 5\n assert candidate(nums = [5, -5, 5, -5, 5, -5],limit = 5,goal = 10) == 2\n assert candidate(nums = [999999, 999999, 999999],limit = 1000000,goal = -2999997) == 6\n assert candidate(nums = [5, 10, -15, 20, -25, 30, -35, 40, -45, 50],limit = 10,goal = 100) == 7\n assert candidate(nums = [999999, -999999, 999999, -999999, 999999, -999999],limit = 1000000,goal = 0) == 0\n assert candidate(nums = [-5, -4, -3, -2, -1],limit = 3,goal = 15) == 10\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 1,goal = -20) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 1,goal = 55) == 0\n assert candidate(nums = [1000000, -1000000, 1000000],limit = 1000000,goal = 3000000) == 2\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],limit = 3,goal = -50) == 2\n assert candidate(nums = [123456, -654321, 111111, -222222, 333333, -444444],limit = 500000,goal = -1000000) == 1\n assert candidate(nums = [999999, 999998, 999997, 999996],limit = 999999,goal = 3999990) == 0\n assert candidate(nums = [1000000, -1000000, 500000],limit = 1000000,goal = 0) == 1\n assert candidate(nums = [1000, -1000, 1000, -1000],limit = 1000,goal = 1000) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 10,goal = 55) == 0\n assert candidate(nums = [5, -5, 5, -5, 5],limit = 10,goal = -15) == 2\n assert candidate(nums = [10, -10, 20, -20, 30, -30],limit = 5,goal = 15) == 3\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000],limit = 100000,goal = 1000000) == 5\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 1,goal = -5) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 1,goal = -15) == 30\n assert candidate(nums = [-1000000, -2000000, -3000000],limit = 1000000,goal = -10000000) == 4\n assert candidate(nums = [100, -50, 25],limit = 100,goal = 200) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = 15) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 50,goal = 500) == 1\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],limit = 5,goal = -10) == 2\n assert candidate(nums = [100, -100, 50, -50],limit = 50,goal = 0) == 0\n assert candidate(nums = [1000000, -1000000, 500000],limit = 1000000,goal = 1000000) == 1\n assert candidate(nums = [123456, -123456, 234567, -234567],limit = 100000,goal = -345678) == 4\n assert candidate(nums = [-1, -2, -3, -4, -5],limit = 3,goal = -15) == 0\n assert candidate(nums = [123456, -654321, 789012, -321098],limit = 100000,goal = 500000) == 6\n assert candidate(nums = [-100, 100, -100, 100],limit = 100,goal = 0) == 0\n assert candidate(nums = [-100000, 100000, -100000, 100000, -100000],limit = 100000,goal = 50000) == 2\n assert candidate(nums = [1000000, -1000000, 500000, -500000],limit = 100000,goal = 0) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],limit = 100,goal = 1500) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5,goal = 50) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 1,goal = 5) == 5\n assert candidate(nums = [-100000, 50000, 25000, -12500, 6250],limit = 10000,goal = -100000) == 7\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],limit = 100000,goal = 600000) == 1\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000],limit = 1000,goal = 5000) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = 10) == 0\n assert candidate(nums = [5, -5, 5, -5],limit = 5,goal = 10) == 2\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 1,goal = 1) == 1\n assert candidate(nums = [-5, 5, -5, 5, -5],limit = 5,goal = 0) == 1\n assert candidate(nums = [1000000],limit = 500000,goal = 2000000) == 2\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 10,goal = 0) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 5,goal = 10) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],limit = 10,goal = 0) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 1,goal = 0) == 0\n assert candidate(nums = [-999999, -999999, -999999],limit = 1000000,goal = 2999997) == 6\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 1,goal = -15) == 5\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],limit = 3,goal = 0) == 19\n assert candidate(nums = [-1, -1, -1, -1, -1],limit = 3,goal = 5) == 4\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 2,goal = 0) == 0\n assert candidate(nums = [1, -1, 1, -1, 1],limit = 1,goal = -1) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 50,goal = 0) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5,goal = 55) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 2,goal = 20) == 3\n assert candidate(nums = [-5, 3, 2, -4, 1],limit = 5,goal = -10) == 2\n assert candidate(nums = [999999, -999999, 999999, -999999, 999999],limit = 1000000,goal = 4999995) == 4\n assert candidate(nums = [-100, 100, -100, 100, -100],limit = 50,goal = 0) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 2,goal = 0) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 3,goal = 55) == 0\n assert candidate(nums = [1000000, 1000000, 1000000],limit = 500000,goal = 500000) == 5\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],limit = 5,goal = -55) == 0\n assert candidate(nums = [-1, 0, 1],limit = 1,goal = -1000000) == 1000000\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 2,goal = -30) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 3,goal = 20) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = 5) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = 20) == 10\n assert candidate(nums = [-999999, -999999, -999999, -999999, -999999],limit = 1000000,goal = -5000000) == 1\n assert candidate(nums = [1, -2, 3, -4, 5],limit = 5,goal = 0) == 1\n assert candidate(nums = [999999, 999999, 999999, 999999, 999999],limit = 1000000,goal = 5000000) == 1\n assert candidate(nums = [-1000000, -1000000, -1000000, -1000000, -1000000],limit = 1000000,goal = 0) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 10,goal = 5) == 1\n assert candidate(nums = [123456, -234567, 345678, -456789, 567890],limit = 100000,goal = 123456789) == 1232\n assert candidate(nums = [-999999, -999998, -999997, -999996],limit = 999999,goal = -3999990) == 0\n assert candidate(nums = [-10, 20, -30, 40],limit = 15,goal = 0) == 2\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],limit = 10,goal = -55) == 0\n assert candidate(nums = [1000000, 2000000, 3000000],limit = 1000000,goal = 10000000) == 4\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000],limit = 1000000,goal = 500000) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],limit = 1000000,goal = 10000000) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],limit = 100,goal = 500) == 5\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 2,goal = -20) == 5\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5,goal = 0) == 11\n assert candidate(nums = [-10, -20, -30, -40, -50],limit = 10,goal = 150) == 30\n assert candidate(nums = [10, 20, 30, 40, 50],limit = 5,goal = 150) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "limit", "goal"], "leetcode_dataset_entry_point": "Solution().minElements", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minElements(self, nums: list[int], limit: int, goal: int) -> int:", "container": "Solution", "callable": "minElements", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "limit", "type": "int"}, {"name": "goal", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1786, "task_id": "number-of-restricted-paths-from-first-to-last-node", "difficulty": "Medium", "problem_description": "There is an undirected weighted connected graph. You are given a positive integer n which denotes that the graph has n nodes labeled from 1 to n, and an array edges where each edges[i] = [ui, vi, weighti] denotes that there is an edge between nodes ui and vi with weight equal to weighti.\nA path from node start to node end is a sequence of nodes [z0, z1, z2, ..., zk] such that z0 = start and zk = end and there is an edge between zi and zi+1 where 0 <= i <= k-1.\nThe distance of a path is the sum of the weights on the edges of the path. Let distanceToLastNode(x) denote the shortest distance of a path between node n and node x. A restricted path is a path that also satisfies that distanceToLastNode(zi) > distanceToLastNode(zi+1) where 0 <= i <= k-1.\nReturn the number of restricted paths from node 1 to node n. Since that number may be too large, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: n = 5, edges = [[1,2,3],[1,3,3],[2,3,1],[1,4,2],[5,2,2],[3,5,1],[5,4,10]]\nOutput: 3\nExplanation: Each circle contains the node number in black and its distanceToLastNode value in blue. The three restricted paths are:\n1) 1 --> 2 --> 5\n2) 1 --> 2 --> 3 --> 5\n3) 1 --> 3 --> 5\n\nExample 2:\n\n\nInput: n = 7, edges = [[1,3,1],[4,1,2],[7,3,4],[2,5,3],[5,6,1],[6,7,2],[7,5,3],[2,6,4]]\nOutput: 1\nExplanation: Each circle contains the node number in black and its distanceToLastNode value in blue. The only restricted path is 1 --> 3 --> 7.\n\n \nConstraints:\n\n1 <= n <= 2 * 104\nn - 1 <= edges.length <= 4 * 104\nedges[i].length == 3\n1 <= ui, vi <= n\nui != vi\n1 <= weighti <= 105\nThere is at most one edge between any two nodes.\nThere is at least one path between any two nodes.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 1, 4]]) == 1\n assert candidate(n = 3,edges = [[1, 2, 5], [1, 3, 6], [2, 3, 1]]) == 2\n assert candidate(n = 7,edges = [[1, 3, 1], [4, 1, 2], [7, 3, 4], [2, 5, 3], [5, 6, 1], [6, 7, 2], [7, 5, 3], [2, 6, 4]]) == 1\n assert candidate(n = 6,edges = [[1, 2, 2], [1, 3, 4], [2, 4, 3], [3, 4, 1], [4, 5, 2], [5, 6, 1]]) == 2\n assert candidate(n = 5,edges = [[1, 2, 3], [1, 3, 3], [2, 3, 1], [1, 4, 2], [5, 2, 2], [3, 5, 1], [5, 4, 10]]) == 3\n assert candidate(n = 25,edges = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1], [20, 21, 1], [21, 22, 1], [22, 23, 1], [23, 24, 1], [24, 25, 1], [1, 25, 5], [2, 24, 5], [3, 23, 5], [4, 22, 5], [5, 21, 5], [6, 20, 5], [7, 19, 5], [8, 18, 5], [9, 17, 5], [10, 16, 5], [11, 15, 5], [12, 14, 5], [13, 13, 5]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [1, 15, 15]]) == 1\n assert candidate(n = 12,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [1, 3, 12], [2, 4, 13], [3, 5, 14], [4, 6, 15], [5, 7, 16], [6, 8, 17], [7, 9, 18], [8, 10, 19], [9, 11, 20], [10, 12, 21], [1, 4, 22], [2, 5, 23], [3, 6, 24], [4, 7, 25], [5, 8, 26], [6, 9, 27], [7, 10, 28], [8, 11, 29], [9, 12, 30]]) == 504\n assert candidate(n = 10,edges = [[1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1], [6, 7, 6], [7, 8, 5], [8, 9, 4], [9, 10, 3]]) == 1\n assert candidate(n = 20,edges = [[1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 20, 20], [1, 20, 10], [2, 19, 10], [3, 18, 10], [4, 17, 10], [5, 16, 10], [6, 15, 10], [7, 14, 10], [8, 13, 10], [9, 12, 10], [10, 11, 10]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 1], [1, 3, 4], [2, 4, 2], [3, 4, 1], [4, 5, 3], [5, 6, 2], [6, 7, 1], [7, 8, 2], [8, 9, 3], [9, 10, 1]]) == 2\n assert candidate(n = 8,edges = [[1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1], [6, 7, 6], [7, 8, 7], [8, 1, 8], [2, 5, 9], [3, 6, 10], [4, 7, 11], [1, 8, 12]]) == 2\n assert candidate(n = 10,edges = [[1, 2, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 1], [6, 7, 3], [7, 8, 2], [8, 9, 1], [9, 10, 2], [1, 10, 5]]) == 1\n assert candidate(n = 50,edges = [[1, 2, 1000], [2, 3, 2000], [3, 4, 3000], [4, 5, 4000], [5, 6, 5000], [6, 7, 6000], [7, 8, 7000], [8, 9, 8000], [9, 10, 9000], [10, 11, 10000], [11, 12, 11000], [12, 13, 12000], [13, 14, 13000], [14, 15, 14000], [15, 16, 15000], [16, 17, 16000], [17, 18, 17000], [18, 19, 18000], [19, 20, 19000], [20, 21, 20000], [21, 22, 21000], [22, 23, 22000], [23, 24, 23000], [24, 25, 24000], [25, 26, 25000], [26, 27, 26000], [27, 28, 27000], [28, 29, 28000], [29, 30, 29000], [30, 31, 30000], [31, 32, 31000], [32, 33, 32000], [33, 34, 33000], [34, 35, 34000], [35, 36, 35000], [36, 37, 36000], [37, 38, 37000], [38, 39, 38000], [39, 40, 39000], [40, 41, 40000], [41, 42, 41000], [42, 43, 42000], [43, 44, 43000], [44, 45, 44000], [45, 46, 45000], [46, 47, 46000], [47, 48, 47000], [48, 49, 48000], [49, 50, 49000]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 15, 75]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 5], [1, 3, 3], [2, 4, 7], [3, 4, 2], [4, 5, 5], [5, 6, 4], [6, 7, 8], [7, 8, 2], [8, 9, 1], [9, 10, 2], [10, 11, 3], [11, 12, 1], [12, 13, 5], [13, 14, 4], [14, 15, 6]]) == 1\n assert candidate(n = 8,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [1, 3, 8], [2, 4, 9], [3, 5, 10], [4, 6, 11], [5, 7, 12], [6, 8, 13]]) == 21\n assert candidate(n = 10,edges = [[1, 2, 4], [1, 3, 3], [2, 4, 2], [3, 4, 1], [4, 5, 5], [5, 6, 3], [6, 7, 2], [7, 8, 1], [8, 9, 4], [9, 10, 5], [2, 5, 3], [3, 6, 4], [5, 8, 2], [6, 9, 1]]) == 4\n assert candidate(n = 15,edges = [[1, 2, 2], [1, 3, 3], [2, 4, 5], [3, 5, 4], [4, 6, 1], [5, 7, 2], [6, 8, 3], [7, 9, 4], [8, 10, 5], [9, 11, 1], [10, 12, 2], [11, 13, 3], [12, 14, 4], [13, 15, 5], [4, 7, 2], [5, 8, 1], [6, 9, 4], [7, 10, 3], [8, 11, 2], [9, 12, 1], [10, 13, 4], [11, 14, 5], [12, 15, 1]]) == 7\n assert candidate(n = 30,edges = [[1, 2, 5], [2, 3, 4], [3, 4, 1], [4, 5, 3], [5, 6, 2], [6, 7, 4], [7, 8, 3], [8, 9, 5], [9, 10, 4], [10, 11, 2], [11, 12, 1], [12, 13, 3], [13, 14, 2], [14, 15, 4], [15, 16, 1], [16, 17, 2], [17, 18, 3], [18, 19, 2], [19, 20, 1], [20, 21, 5], [21, 22, 4], [22, 23, 3], [23, 24, 2], [24, 25, 4], [25, 26, 3], [26, 27, 5], [27, 28, 1], [28, 29, 2], [29, 30, 3], [30, 1, 4]]) == 1\n assert candidate(n = 25,edges = [[1, 2, 20], [1, 3, 10], [2, 4, 5], [2, 5, 15], [3, 6, 1], [3, 7, 20], [4, 8, 25], [4, 9, 1], [5, 9, 30], [5, 10, 1], [6, 11, 10], [6, 12, 25], [7, 12, 15], [7, 13, 1], [8, 14, 20], [9, 14, 5], [10, 14, 10], [11, 15, 25], [11, 16, 1], [12, 16, 30], [12, 17, 5], [13, 17, 10], [14, 18, 15], [15, 18, 1], [16, 19, 20], [17, 19, 30], [18, 20, 10], [19, 20, 25], [20, 21, 1], [21, 22, 5], [22, 23, 10], [23, 24, 15], [24, 25, 20]]) == 2\n assert candidate(n = 30,edges = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900], [10, 11, 1000], [11, 12, 1100], [12, 13, 1200], [13, 14, 1300], [14, 15, 1400], [15, 16, 1500], [16, 17, 1600], [17, 18, 1700], [18, 19, 1800], [19, 20, 1900], [20, 21, 2000], [21, 22, 2100], [22, 23, 2200], [23, 24, 2300], [24, 25, 2400], [25, 26, 2500], [26, 27, 2600], [27, 28, 2700], [28, 29, 2800], [29, 30, 2900]]) == 1\n assert candidate(n = 8,edges = [[1, 2, 5], [1, 3, 6], [2, 4, 2], [3, 5, 4], [4, 5, 3], [4, 6, 1], [5, 7, 2], [6, 8, 3], [7, 8, 1], [2, 3, 4], [4, 7, 6], [5, 6, 2], [3, 8, 5], [2, 6, 3]]) == 8\n assert candidate(n = 20,edges = [[1, 2, 2], [1, 3, 1], [2, 4, 3], [2, 5, 4], [3, 6, 5], [3, 7, 6], [4, 8, 7], [4, 9, 8], [5, 10, 9], [5, 11, 10], [6, 12, 11], [6, 13, 12], [7, 14, 13], [7, 15, 14], [8, 16, 15], [9, 17, 16], [10, 18, 17], [11, 19, 18], [12, 20, 19], [13, 18, 20], [14, 19, 11], [15, 20, 12], [16, 17, 13], [17, 18, 14], [18, 19, 15], [19, 20, 16]]) == 2\n assert candidate(n = 15,edges = [[1, 2, 10], [2, 3, 5], [3, 4, 15], [4, 5, 20], [5, 6, 25], [6, 7, 30], [7, 8, 35], [8, 9, 40], [9, 10, 45], [10, 11, 50], [11, 12, 55], [12, 13, 60], [13, 14, 65], [14, 15, 70], [1, 3, 5], [2, 4, 5], [3, 5, 5], [4, 6, 5], [5, 7, 5], [6, 8, 5], [7, 9, 5], [8, 10, 5], [9, 11, 5], [10, 12, 5], [11, 13, 5], [12, 14, 5], [13, 15, 5]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 4], [1, 3, 2], [2, 4, 1], [2, 5, 6], [3, 5, 3], [4, 6, 2], [5, 6, 1], [6, 7, 5], [6, 8, 3], [7, 9, 4], [8, 9, 2], [9, 10, 1]]) == 6\n assert candidate(n = 20,edges = [[1, 2, 2], [1, 3, 1], [2, 4, 3], [2, 5, 4], [3, 5, 2], [4, 6, 5], [4, 7, 6], [5, 6, 7], [5, 8, 8], [6, 9, 1], [7, 9, 2], [8, 10, 3], [9, 10, 4], [10, 11, 5], [11, 12, 6], [11, 13, 7], [12, 14, 8], [13, 14, 9], [14, 15, 10], [15, 16, 1], [16, 17, 2], [16, 18, 3], [17, 19, 4], [18, 19, 5], [19, 20, 6]]) == 24\n assert candidate(n = 20,edges = [[1, 2, 10], [2, 3, 9], [3, 4, 8], [4, 5, 7], [5, 6, 6], [6, 7, 5], [7, 8, 4], [8, 9, 3], [9, 10, 2], [10, 11, 1], [11, 12, 2], [12, 13, 3], [13, 14, 4], [14, 15, 5], [15, 16, 6], [16, 17, 7], [17, 18, 8], [18, 19, 9], [19, 20, 10], [1, 20, 15], [2, 19, 16], [3, 18, 17], [4, 17, 18], [5, 16, 19], [6, 15, 20]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120], [13, 14, 130], [14, 15, 140], [1, 3, 15], [3, 5, 25], [5, 7, 35], [7, 9, 45], [9, 11, 55], [11, 13, 65], [13, 15, 75], [2, 4, 25], [4, 6, 35], [6, 8, 45], [8, 10, 55], [10, 12, 65], [12, 14, 75], [2, 5, 30], [5, 8, 40], [8, 11, 50], [11, 14, 60], [3, 6, 35], [6, 9, 45], [9, 12, 55], [12, 15, 65], [4, 7, 45], [7, 10, 55], [10, 13, 65], [4, 8, 50], [8, 12, 60], [8, 13, 65], [10, 14, 75], [10, 15, 80], [5, 9, 55], [9, 13, 70], [5, 10, 60], [10, 15, 90]]) == 174\n assert candidate(n = 12,edges = [[1, 2, 5], [1, 3, 3], [2, 4, 2], [3, 4, 1], [4, 5, 4], [5, 6, 5], [6, 7, 4], [7, 8, 3], [8, 9, 2], [9, 10, 1], [10, 11, 6], [11, 12, 7]]) == 2\n assert candidate(n = 10,edges = [[1, 2, 5], [2, 3, 10], [3, 4, 15], [4, 5, 20], [5, 6, 25], [6, 7, 30], [7, 8, 35], [8, 9, 40], [9, 10, 45], [1, 3, 2], [3, 5, 3], [5, 7, 4], [7, 9, 5], [2, 4, 7], [4, 6, 8], [6, 8, 9], [8, 10, 11], [1, 4, 6], [4, 7, 7], [7, 10, 8]]) == 3\n assert candidate(n = 20,edges = [[1, 2, 10], [1, 3, 20], [2, 4, 15], [3, 4, 5], [4, 5, 25], [5, 6, 10], [6, 7, 30], [7, 8, 15], [8, 9, 5], [9, 10, 25], [10, 11, 10], [11, 12, 30], [12, 13, 15], [13, 14, 5], [14, 15, 25], [15, 16, 10], [16, 17, 30], [17, 18, 15], [18, 19, 5], [19, 20, 25]]) == 2\n assert candidate(n = 50,edges = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1], [20, 21, 1], [21, 22, 1], [22, 23, 1], [23, 24, 1], [24, 25, 1], [25, 26, 1], [26, 27, 1], [27, 28, 1], [28, 29, 1], [29, 30, 1], [30, 31, 1], [31, 32, 1], [32, 33, 1], [33, 34, 1], [34, 35, 1], [35, 36, 1], [36, 37, 1], [37, 38, 1], [38, 39, 1], [39, 40, 1], [40, 41, 1], [41, 42, 1], [42, 43, 1], [43, 44, 1], [44, 45, 1], [45, 46, 1], [46, 47, 1], [47, 48, 1], [48, 49, 1], [49, 50, 1], [1, 50, 10], [2, 49, 10], [3, 48, 10], [4, 47, 10], [5, 46, 10], [6, 45, 10], [7, 44, 10], [8, 43, 10], [9, 42, 10], [10, 41, 10], [11, 40, 10], [12, 39, 10], [13, 38, 10], [14, 37, 10], [15, 36, 10], [16, 35, 10], [17, 34, 10], [18, 33, 10], [19, 32, 10], [20, 31, 10], [21, 30, 10], [22, 29, 10], [23, 28, 10], [24, 27, 10], [25, 26, 10]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 10], [1, 3, 20], [2, 4, 5], [2, 5, 7], [3, 5, 3], [4, 6, 2], [4, 7, 8], [5, 7, 1], [5, 8, 6], [6, 9, 4], [7, 9, 3], [8, 10, 1], [9, 10, 5], [10, 11, 3], [11, 12, 4], [12, 13, 1], [12, 14, 7], [13, 15, 2], [14, 15, 6]]) == 5\n assert candidate(n = 20,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 1], [4, 5, 3], [5, 6, 2], [6, 7, 4], [7, 8, 1], [8, 9, 2], [9, 10, 3], [10, 11, 2], [11, 12, 1], [12, 13, 3], [13, 14, 2], [14, 15, 4], [15, 16, 1], [16, 17, 2], [17, 18, 3], [18, 19, 2], [19, 20, 1], [20, 1, 5]]) == 1\n assert candidate(n = 20,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [1, 3, 3], [3, 5, 5], [5, 7, 7], [7, 9, 9], [9, 11, 11], [11, 13, 13], [13, 15, 15], [15, 17, 17], [17, 19, 19], [2, 4, 4], [4, 6, 6], [6, 8, 8], [8, 10, 10], [10, 12, 12], [12, 14, 14], [14, 16, 16], [16, 18, 18], [2, 5, 5], [5, 8, 8], [8, 11, 11], [11, 14, 14], [14, 17, 17], [3, 6, 6], [6, 9, 9], [9, 12, 12], [12, 15, 15], [12, 16, 16], [15, 18, 18], [4, 7, 7], [7, 10, 10], [10, 13, 13], [10, 14, 14], [13, 16, 16], [6, 11, 11], [11, 16, 16], [11, 17, 17], [7, 12, 12], [12, 17, 17], [12, 18, 18]]) == 494\n assert candidate(n = 20,edges = [[1, 2, 2], [1, 3, 3], [2, 4, 1], [2, 5, 4], [3, 6, 5], [3, 7, 7], [4, 8, 8], [4, 9, 9], [5, 9, 2], [5, 10, 3], [6, 11, 6], [6, 12, 10], [7, 12, 4], [7, 13, 5], [8, 14, 3], [9, 14, 4], [10, 14, 7], [11, 15, 1], [11, 16, 2], [12, 16, 3], [12, 17, 8], [13, 17, 9], [14, 18, 6], [15, 18, 5], [16, 19, 4], [17, 19, 3], [18, 20, 10], [19, 20, 7]]) == 6\n assert candidate(n = 20,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 5], [1, 3, 3], [2, 4, 2], [2, 5, 6], [3, 4, 1], [3, 6, 4], [4, 7, 7], [5, 7, 8], [5, 8, 2], [6, 8, 3], [7, 9, 5], [8, 9, 6], [8, 10, 9], [9, 10, 10]]) == 2\n assert candidate(n = 50,edges = [[1, 2, 5], [2, 3, 4], [3, 4, 1], [4, 5, 3], [5, 6, 2], [6, 7, 4], [7, 8, 3], [8, 9, 5], [9, 10, 4], [10, 11, 2], [11, 12, 1], [12, 13, 3], [13, 14, 2], [14, 15, 4], [15, 16, 1], [16, 17, 2], [17, 18, 3], [18, 19, 2], [19, 20, 1], [20, 21, 5], [21, 22, 4], [22, 23, 3], [23, 24, 2], [24, 25, 4], [25, 26, 3], [26, 27, 5], [27, 28, 1], [28, 29, 2], [29, 30, 3], [30, 31, 4], [31, 32, 5], [32, 33, 4], [33, 34, 3], [34, 35, 2], [35, 36, 1], [36, 37, 2], [37, 38, 3], [38, 39, 2], [39, 40, 1], [40, 41, 5], [41, 42, 4], [42, 43, 3], [43, 44, 2], [44, 45, 4], [45, 46, 3], [46, 47, 5], [47, 48, 1], [48, 49, 2], [49, 50, 3], [50, 1, 4]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 10], [1, 3, 5], [2, 4, 3], [2, 5, 4], [3, 6, 2], [3, 7, 6], [4, 8, 7], [4, 9, 8], [5, 9, 3], [5, 10, 1], [6, 11, 5], [6, 12, 3], [7, 12, 2], [7, 13, 9], [8, 14, 5], [9, 14, 6], [10, 14, 4], [11, 15, 7], [12, 15, 8], [13, 15, 3]]) == 4\n assert candidate(n = 50,edges = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1], [20, 21, 1], [21, 22, 1], [22, 23, 1], [23, 24, 1], [24, 25, 1], [25, 26, 1], [26, 27, 1], [27, 28, 1], [28, 29, 1], [29, 30, 1], [30, 31, 1], [31, 32, 1], [32, 33, 1], [33, 34, 1], [34, 35, 1], [35, 36, 1], [36, 37, 1], [37, 38, 1], [38, 39, 1], [39, 40, 1], [40, 41, 1], [41, 42, 1], [42, 43, 1], [43, 44, 1], [44, 45, 1], [45, 46, 1], [46, 47, 1], [47, 48, 1], [48, 49, 1], [49, 50, 1], [1, 50, 50]]) == 2\n assert candidate(n = 15,edges = [[1, 2, 2], [2, 3, 3], [3, 4, 2], [4, 5, 1], [5, 6, 2], [6, 7, 3], [7, 8, 4], [8, 9, 2], [9, 10, 1], [10, 11, 3], [11, 12, 2], [12, 13, 1], [13, 14, 3], [14, 15, 2], [15, 1, 5]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 2], [1, 3, 4], [2, 4, 3], [3, 4, 1], [4, 5, 2], [5, 6, 1], [6, 7, 5], [7, 8, 1], [8, 9, 4], [9, 10, 3], [10, 1, 7]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [1, 10, 5], [2, 8, 4], [3, 9, 3], [4, 7, 2], [5, 6, 1]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().countRestrictedPaths", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countRestrictedPaths(self, n: int, edges: list[list[int]]) -> int:", "container": "Solution", "callable": "countRestrictedPaths", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1787, "task_id": "make-the-xor-of-all-segments-equal-to-zero", "difficulty": "Hard", "problem_description": "You are given an array nums​​​ and an integer k​​​​​. The XOR of a segment [left, right] where left <= right is the XOR of all the elements with indices between left and right, inclusive: nums[left] XOR nums[left+1] XOR ... XOR nums[right].\nReturn the minimum number of elements to change in the array such that the XOR of all segments of size k​​​​​​ is equal to zero.\n \nExample 1:\n\nInput: nums = [1,2,0,3,0], k = 1\nOutput: 3\nExplanation: Modify the array from [1,2,0,3,0] to from [0,0,0,0,0].\n\nExample 2:\n\nInput: nums = [3,4,5,2,1,7,3,4,7], k = 3\nOutput: 3\nExplanation: Modify the array from [3,4,5,2,1,7,3,4,7] to [3,4,7,3,4,7,3,4,7].\n\nExample 3:\n\nInput: nums = [1,2,4,1,2,5,1,2,6], k = 3\nOutput: 3\nExplanation: Modify the array from [1,2,4,1,2,5,1,2,6] to [1,2,3,1,2,3,1,2,3].\n \nConstraints:\n\n1 <= k <= nums.length <= 2000\n​​​​​​0 <= nums[i] < 210\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 0\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 5) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],k = 5) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],k = 4) == 4\n assert candidate(nums = [3, 4, 5, 2, 1, 7, 3, 4, 7],k = 3) == 3\n assert candidate(nums = [0, 0, 0, 0, 0],k = 2) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 10\n assert candidate(nums = [1, 2, 4, 1, 2, 5, 1, 2, 6],k = 3) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1],k = 6) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 2) == 9\n assert candidate(nums = [1, 1, 1, 1, 1],k = 5) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 1) == 10\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 2) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 9) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17],k = 3) == 7\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 6) == 0\n assert candidate(nums = [1, 3, 5, 7, 9],k = 5) == 1\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 10) == 0\n assert candidate(nums = [1, 2, 0, 3, 0],k = 1) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 4) == 11\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 5\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 11\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 5\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 12\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19],k = 8) == 30\n assert candidate(nums = [3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1],k = 2) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 3) == 24\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n assert candidate(nums = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240],k = 5) == 12\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 15) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 5) == 10\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31],k = 15) == 2\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 5) == 16\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],k = 5) == 14\n assert candidate(nums = [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 13, 12, 11],k = 4) == 24\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 15\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7],k = 8) == 26\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],k = 15) == 1\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6],k = 3) == 22\n assert candidate(nums = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 3) == 9\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4],k = 7) == 21\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 17) == 5\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 8\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0],k = 3) == 42\n assert candidate(nums = [511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540],k = 15) == 16\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 18) == 5\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 10) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4],k = 5) == 24\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 6, 7, 9],k = 13) == 69\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 7) == 23\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],k = 10) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3],k = 5) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 10) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 15) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 20) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11) == 69\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 20) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 6) == 7\n assert candidate(nums = [5, 7, 9, 11, 13, 5, 7, 9, 11, 13],k = 5) == 2\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],k = 5) == 27\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 8, 7, 6, 5, 4, 3, 2, 1, 0, 8, 7, 6, 5, 4, 3, 2, 1, 0, 8, 7, 6],k = 5) == 25\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 10) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15],k = 5) == 23\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 10) == 11\n assert candidate(nums = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 5) == 12\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 6\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 8) == 24\n assert candidate(nums = [8, 4, 2, 1, 0, 1, 2, 4, 8, 4, 2, 1, 0, 1, 2, 4, 8, 4, 2, 1],k = 5) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 20) == 20\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 7) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 5) == 26\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 3) == 15\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 3) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 4) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200],k = 17) == 184\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],k = 15) == 16\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 0, 255, 128, 64, 32, 16, 8, 4, 2, 1, 0, 255, 128, 64, 32, 16, 8, 4, 2, 1, 0],k = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 11\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 7) == 13\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],k = 7) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 15\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 12) == 38\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 10) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],k = 6) == 22\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 182, 189, 196, 203, 210],k = 15) == 15\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12],k = 10) == 11\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2],k = 7) == 19\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 8) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 3) == 10\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9],k = 10) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0],k = 10) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390],k = 15) == 24\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 0, 255, 128, 64, 32, 16, 8, 4, 2, 1, 0, 255, 128, 64, 32, 16, 8, 4, 2, 1, 0],k = 7) == 23\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 25) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 16\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30],k = 8) == 52\n assert candidate(nums = [17, 255, 8, 19, 7, 23, 15, 42, 99, 1023, 22, 31, 56, 78, 90, 111, 132, 153, 174, 195],k = 7) == 13\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],k = 10) == 21\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0],k = 6) == 5\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 7) == 24\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511],k = 10) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 5) == 25\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minChanges", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minChanges(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "minChanges", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1790, "task_id": "check-if-one-string-swap-can-make-strings-equal", "difficulty": "Easy", "problem_description": "You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices.\nReturn true if it is possible to make both strings equal by performing at most one string swap on exactly one of the strings. Otherwise, return false.\n \nExample 1:\n\nInput: s1 = \"bank\", s2 = \"kanb\"\nOutput: true\nExplanation: For example, swap the first character with the last character of s2 to make \"bank\".\n\nExample 2:\n\nInput: s1 = \"attack\", s2 = \"defend\"\nOutput: false\nExplanation: It is impossible to make them equal with one string swap.\n\nExample 3:\n\nInput: s1 = \"kelb\", s2 = \"kelb\"\nOutput: true\nExplanation: The two strings are already equal, so no string swap operation is required.\n\n \nConstraints:\n\n1 <= s1.length, s2.length <= 100\ns1.length == s2.length\ns1 and s2 consist of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"attack\",s2 = \"defend\") == False\n assert candidate(s1 = \"bank\",s2 = \"kanb\") == True\n assert candidate(s1 = \"abcde\",s2 = \"abced\") == True\n assert candidate(s1 = \"abcd\",s2 = \"abdc\") == True\n assert candidate(s1 = \"aaa\",s2 = \"aaa\") == True\n assert candidate(s1 = \"kelb\",s2 = \"kelb\") == True\n assert candidate(s1 = \"aabb\",s2 = \"abab\") == True\n assert candidate(s1 = \"abcd\",s2 = \"dcba\") == False\n assert candidate(s1 = \"algorithm\",s2 = \"logarithm\") == False\n assert candidate(s1 = \"almost\",s2 = \"almost\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"ghfedcb\") == False\n assert candidate(s1 = \"xyzabc\",s2 = \"yzabxc\") == False\n assert candidate(s1 = \"abcdefg\",s2 = \"fedcbag\") == False\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdefx\") == False\n assert candidate(s1 = \"aaaaabbbb\",s2 = \"bbbbaaaa\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"ccbaab\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"aabbbc\") == False\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"babacabadabacab\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"missisppi\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"ccbbaa\") == False\n assert candidate(s1 = \"programming\",s2 = \"programminj\") == False\n assert candidate(s1 = \"samestr\",s2 = \"strsame\") == False\n assert candidate(s1 = \"hello\",s2 = \"hlelo\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"gfedcba\") == False\n assert candidate(s1 = \"abababab\",s2 = \"babababa\") == False\n assert candidate(s1 = \"abracadabra\",s2 = \"abracadabrb\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"mississipsp\") == False\n assert candidate(s1 = \"palindrome\",s2 = \"lpadnrimoe\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"ccabba\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"mississipip\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdefg\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"bbaacc\") == False\n assert candidate(s1 = \"abcdexyz\",s2 = \"xyzabcde\") == False\n assert candidate(s1 = \"abcdxyz\",s2 = \"abczyxd\") == False\n assert candidate(s1 = \"abcdefgh\",s2 = \"hgfedcba\") == False\n assert candidate(s1 = \"abcde\",s2 = \"abcde\") == True\n assert candidate(s1 = \"banana\",s2 = \"anana\") == False\n assert candidate(s1 = \"ab\",s2 = \"ba\") == True\n assert candidate(s1 = \"hello\",s2 = \"olleh\") == False\n assert candidate(s1 = \"hello\",s2 = \"hallo\") == False\n assert candidate(s1 = \"abcdef\",s2 = \"abcfed\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdefgh\") == True\n assert candidate(s1 = \"qwertyuiop\",s2 = \"qewrtyuipo\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"mississippa\") == False\n assert candidate(s1 = \"programming\",s2 = \"prorgamming\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"abdecfg\") == False\n assert candidate(s1 = \"noon\",s2 = \"nnon\") == False\n assert candidate(s1 = \"hello\",s2 = \"ohell\") == False\n assert candidate(s1 = \"hello\",s2 = \"hxllo\") == False\n assert candidate(s1 = \"aaaabbbb\",s2 = \"bbbbaaaa\") == False\n assert candidate(s1 = \"abc\",s2 = \"acb\") == True\n assert candidate(s1 = \"hello\",s2 = \"lehho\") == False\n assert candidate(s1 = \"abcdexyz\",s2 = \"abcdefyz\") == False\n assert candidate(s1 = \"python\",s2 = \"pythno\") == True\n assert candidate(s1 = \"abracadabra\",s2 = \"abracadabra\") == True\n assert candidate(s1 = \"abcdefgh\",s2 = \"bcadefgh\") == False\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"abacabadabacaba\") == True\n assert candidate(s1 = \"hello\",s2 = \"bello\") == False\n assert candidate(s1 = \"hello\",s2 = \"heoll\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghjk\") == False\n assert candidate(s1 = \"unique\",s2 = \"unqieu\") == False\n assert candidate(s1 = \"abcdabcd\",s2 = \"dcbaabcd\") == False\n assert candidate(s1 = \"abacax\",s2 = \"abacxa\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghij\") == True\n assert candidate(s1 = \"algorithm\",s2 = \"algorithn\") == False\n assert candidate(s1 = \"algorithm\",s2 = \"aloritghm\") == False\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdegf\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"aaccbb\") == False\n assert candidate(s1 = \"almost\",s2 = \"alosmt\") == False\n assert candidate(s1 = \"racecar\",s2 = \"racecar\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"mmissisippi\") == False\n assert candidate(s1 = \"abcdefgh\",s2 = \"efghabcd\") == False\n assert candidate(s1 = \"xyzz\",s2 = \"zzxy\") == False\n assert candidate(s1 = \"palindrome\",s2 = \"palindorme\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"abcdef\") == True\n assert candidate(s1 = \"ab\",s2 = \"ab\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"abcdeg\") == False\n assert candidate(s1 = \"oneone\",s2 = \"noonoe\") == False\n assert candidate(s1 = \"abcxyz\",s2 = \"xyzabc\") == False\n assert candidate(s1 = \"abac\",s2 = \"caba\") == False\n assert candidate(s1 = \"xyz\",s2 = \"zyx\") == True\n assert candidate(s1 = \"abracadabra\",s2 = \"abracadbrba\") == False\n assert candidate(s1 = \"abac\",s2 = \"abca\") == True\n assert candidate(s1 = \"same\",s2 = \"same\") == True\n assert candidate(s1 = \"abcdefgh\",s2 = \"abcdefgh\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"fedcba\") == False\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghji\") == True\n assert candidate(s1 = \"abcde\",s2 = \"edcba\") == False\n assert candidate(s1 = \"swapping\",s2 = \"swapgnip\") == False\n assert candidate(s1 = \"aabbccdd\",s2 = \"ddccbbaa\") == False\n assert candidate(s1 = \"xyzz\",s2 = \"zyzz\") == False\n assert candidate(s1 = \"algorithm\",s2 = \"algorjthm\") == False\n assert candidate(s1 = \"xyzz\",s2 = \"zyxz\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"aabbdc\") == False\n assert candidate(s1 = \"abcdefghijk\",s2 = \"abcdefghijl\") == False\n assert candidate(s1 = \"ababab\",s2 = \"bababa\") == False\n assert candidate(s1 = \"abab\",s2 = \"baba\") == False\n assert candidate(s1 = \"mambo\",s2 = \"mambp\") == False\n assert candidate(s1 = \"abcdef\",s2 = \"abcdfe\") == True\n assert candidate(s1 = \"abdc\",s2 = \"abcd\") == True\n assert candidate(s1 = \"xyzz\",s2 = \"zyzx\") == True\n assert candidate(s1 = \"aabb\",s2 = \"bbaa\") == False\n assert candidate(s1 = \"same\",s2 = \"emsa\") == False\n assert candidate(s1 = \"abcdxyz\",s2 = \"abcdzyx\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"mmississippi\") == False\n assert candidate(s1 = \"python\",s2 = \"ytonph\") == False\n assert candidate(s1 = \"xyzxyz\",s2 = \"zyxzyx\") == False\n assert candidate(s1 = \"aaaa\",s2 = \"aaaa\") == True\n"}, "metadata": {"canonical_parameter_names": ["s1", "s2"], "leetcode_dataset_entry_point": "Solution().areAlmostEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def areAlmostEqual(self, s1: str, s2: str) -> bool:", "container": "Solution", "callable": "areAlmostEqual", "parameters": [{"name": "s1", "type": "str"}, {"name": "s2", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1791, "task_id": "find-center-of-star-graph", "difficulty": "Easy", "problem_description": "There is an undirected star graph consisting of n nodes labeled from 1 to n. A star graph is a graph where there is one center node and exactly n - 1 edges that connect the center node with every other node.\nYou are given a 2D integer array edges where each edges[i] = [ui, vi] indicates that there is an edge between the nodes ui and vi. Return the center of the given star graph.\n \nExample 1:\n\n\nInput: edges = [[1,2],[2,3],[4,2]]\nOutput: 2\nExplanation: As shown in the figure above, node 2 is connected to every other node, so 2 is the center.\n\nExample 2:\n\nInput: edges = [[1,2],[5,1],[1,3],[1,4]]\nOutput: 1\n\n \nConstraints:\n\n3 <= n <= 105\nedges.length == n - 1\nedges[i].length == 2\n1 <= ui, vi <= n\nui != vi\nThe given edges represent a valid star graph.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [[10, 20], [10, 30], [10, 40], [10, 50], [10, 60]]) == 10\n assert candidate(edges = [[3, 1], [1, 2], [1, 4], [1, 5]]) == 1\n assert candidate(edges = [[7, 3], [7, 4], [7, 2], [7, 5], [7, 6], [7, 1]]) == 7\n assert candidate(edges = [[10, 5], [10, 8], [10, 3], [10, 1]]) == 10\n assert candidate(edges = [[4, 3], [5, 3], [2, 3], [1, 3]]) == 3\n assert candidate(edges = [[1, 2], [2, 3], [4, 2]]) == 2\n assert candidate(edges = [[1, 2], [5, 1], [1, 3], [1, 4]]) == 1\n assert candidate(edges = [[3, 1], [2, 1]]) == 1\n assert candidate(edges = [[3, 1], [3, 2], [3, 4], [3, 5]]) == 3\n assert candidate(edges = [[7, 4], [7, 5], [7, 3], [7, 1], [7, 2]]) == 7\n assert candidate(edges = [[3, 5], [3, 1], [3, 2], [3, 6]]) == 3\n assert candidate(edges = [[5, 1], [1, 2], [1, 3], [1, 4], [7, 1]]) == 1\n assert candidate(edges = [[6, 4], [6, 5], [6, 2], [6, 3]]) == 6\n assert candidate(edges = [[10, 3], [10, 2], [10, 5], [10, 1], [10, 4]]) == 10\n assert candidate(edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]]) == 1\n assert candidate(edges = [[100000, 1], [100000, 2], [100000, 3], [100000, 4], [100000, 5], [100000, 6], [100000, 7], [100000, 8], [100000, 9], [100000, 10], [100000, 11], [100000, 12], [100000, 13], [100000, 14], [100000, 15]]) == 100000\n assert candidate(edges = [[99999, 1], [99999, 2], [99999, 3], [99999, 4], [99999, 5], [99999, 6], [99999, 7], [99999, 8], [99999, 9], [99999, 10], [99999, 11], [99999, 12], [99999, 13], [99999, 14], [99999, 15], [99999, 16], [99999, 17], [99999, 18], [99999, 19], [99999, 20]]) == 99999\n assert candidate(edges = [[55555, 1], [55555, 2], [55555, 3], [55555, 4], [55555, 5], [55555, 6], [55555, 7], [55555, 8], [55555, 9], [55555, 10], [55555, 11], [55555, 12], [55555, 13], [55555, 14], [55555, 15], [55555, 16], [55555, 17], [55555, 18], [55555, 19], [55555, 20], [55555, 21], [55555, 22], [55555, 23], [55555, 24], [55555, 25]]) == 55555\n assert candidate(edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50], [50, 1]]) == 2\n assert candidate(edges = [[2, 1], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 35], [2, 36], [2, 37], [2, 38], [2, 39], [2, 40], [2, 41], [2, 42], [2, 43], [2, 44], [2, 45], [2, 46], [2, 47], [2, 48], [2, 49], [2, 50], [2, 51], [2, 52], [2, 53], [2, 54], [2, 55], [2, 56], [2, 57], [2, 58], [2, 59], [2, 60]]) == 2\n assert candidate(edges = [[1, 200000], [200000, 2], [200000, 3], [200000, 4], [200000, 5], [200000, 6], [200000, 7], [200000, 8], [200000, 9], [200000, 10], [200000, 11], [200000, 12], [200000, 13], [200000, 14], [200000, 15], [200000, 16], [200000, 17], [200000, 18], [200000, 19], [200000, 20]]) == 200000\n assert candidate(edges = [[10, 100], [100, 11], [100, 12], [100, 13], [100, 14], [100, 15], [100, 16], [100, 17], [100, 18], [100, 19], [100, 20], [100, 21], [100, 22], [100, 23], [100, 24], [100, 25], [100, 26], [100, 27], [100, 28], [100, 29], [100, 30], [100, 31], [100, 32], [100, 33], [100, 34], [100, 35], [100, 36], [100, 37], [100, 38], [100, 39], [100, 40], [100, 41], [100, 42], [100, 43], [100, 44], [100, 45], [100, 46], [100, 47], [100, 48], [100, 49], [100, 50], [100, 51], [100, 52], [100, 53], [100, 54], [100, 55], [100, 56], [100, 57], [100, 58], [100, 59], [100, 60], [100, 61], [100, 62], [100, 63], [100, 64], [100, 65], [100, 66], [100, 67], [100, 68], [100, 69], [100, 70], [100, 71], [100, 72], [100, 73], [100, 74], [100, 75], [100, 76], [100, 77], [100, 78], [100, 79], [100, 80], [100, 81], [100, 82], [100, 83], [100, 84], [100, 85], [100, 86], [100, 87], [100, 88], [100, 89], [100, 90], [100, 91], [100, 92], [100, 93], [100, 94], [100, 95], [100, 96], [100, 97], [100, 98], [100, 99], [100, 100]]) == 100\n assert candidate(edges = [[1000, 2], [1000, 3], [1000, 4], [1000, 5], [1000, 6], [1000, 7], [1000, 8], [1000, 9], [1000, 10], [1000, 11], [1000, 12], [1000, 13], [1000, 14], [1000, 15], [1000, 16], [1000, 17], [1000, 18], [1000, 19], [1000, 20], [1000, 21], [1000, 22], [1000, 23], [1000, 24], [1000, 25], [1000, 26], [1000, 27], [1000, 28], [1000, 29], [1000, 30]]) == 1000\n assert candidate(edges = [[25000, 24999], [25000, 24998], [25000, 24997], [25000, 24996], [25000, 24995], [25000, 24994], [25000, 24993], [25000, 24992], [25000, 24991], [25000, 24990], [25000, 24989], [25000, 24988], [25000, 24987], [25000, 24986], [25000, 24985], [25000, 24984], [25000, 24983], [25000, 24982], [25000, 24981], [25000, 24980]]) == 25000\n assert candidate(edges = [[500, 250], [500, 125], [500, 375], [500, 625], [500, 875], [500, 150], [500, 300], [500, 450], [500, 600], [500, 750], [500, 900], [500, 275], [500, 325], [500, 375], [500, 425], [500, 475]]) == 500\n assert candidate(edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30]]) == 1\n assert candidate(edges = [[99999, 1], [99999, 2], [99999, 3], [99999, 4], [99999, 5], [99999, 6], [99999, 7], [99999, 8], [99999, 9], [99999, 10], [99999, 11], [99999, 12], [99999, 13], [99999, 14], [99999, 15]]) == 99999\n assert candidate(edges = [[99999, 1], [99999, 2], [99999, 3], [99999, 4], [99999, 5], [99999, 6], [99999, 7], [99999, 8], [99999, 9], [99999, 10], [99999, 11], [99999, 12], [99999, 13], [99999, 14], [99999, 15], [99999, 16], [99999, 17], [99999, 18], [99999, 19], [99999, 20], [99999, 21], [99999, 22], [99999, 23], [99999, 24], [99999, 25], [99999, 26], [99999, 27], [99999, 28], [99999, 29], [99999, 30], [99999, 31], [99999, 32], [99999, 33], [99999, 34], [99999, 35], [99999, 36], [99999, 37], [99999, 38], [99999, 39], [99999, 40], [99999, 41], [99999, 42], [99999, 43], [99999, 44], [99999, 45], [99999, 46], [99999, 47], [99999, 48], [99999, 49], [99999, 50]]) == 99999\n assert candidate(edges = [[100000, 1], [100000, 2], [100000, 3], [100000, 4], [100000, 5], [100000, 6], [100000, 7], [100000, 8], [100000, 9], [100000, 10], [100000, 11], [100000, 12], [100000, 13], [100000, 14], [100000, 15], [100000, 16], [100000, 17], [100000, 18], [100000, 19], [100000, 20]]) == 100000\n assert candidate(edges = [[99, 1], [99, 2], [99, 3], [99, 4], [99, 5], [99, 6], [99, 7], [99, 8], [99, 9], [99, 10]]) == 99\n assert candidate(edges = [[1, 99999], [2, 99999], [3, 99999], [4, 99999], [5, 99999], [6, 99999], [7, 99999], [8, 99999], [9, 99999]]) == 99999\n assert candidate(edges = [[1000, 500], [1000, 600], [1000, 700], [1000, 800], [1000, 900], [1000, 200], [1000, 300], [1000, 400], [1000, 100], [1000, 150], [1000, 250], [1000, 350], [1000, 450], [1000, 550], [1000, 650], [1000, 750], [1000, 850], [1000, 950], [1000, 1000], [1000, 1100], [1000, 1200], [1000, 1300], [1000, 1400]]) == 1000\n assert candidate(edges = [[23456, 12345], [23456, 22345], [23456, 32345], [23456, 42345], [23456, 52345], [23456, 62345], [23456, 72345], [23456, 82345], [23456, 92345], [23456, 102345]]) == 23456\n assert candidate(edges = [[3, 1], [3, 2], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [3, 40], [3, 41], [3, 42], [3, 43], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 52], [3, 53], [3, 54], [3, 55], [3, 56], [3, 57], [3, 58], [3, 59], [3, 60], [3, 61], [3, 62], [3, 63], [3, 64], [3, 65], [3, 66], [3, 67], [3, 68], [3, 69], [3, 70], [3, 71], [3, 72], [3, 73], [3, 74], [3, 75], [3, 76], [3, 77], [3, 78], [3, 79], [3, 80], [3, 81], [3, 82], [3, 83], [3, 84], [3, 85], [3, 86], [3, 87], [3, 88], [3, 89], [3, 90], [3, 91], [3, 92], [3, 93], [3, 94], [3, 95], [3, 96], [3, 97], [3, 98], [3, 99], [3, 100]]) == 3\n assert candidate(edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]) == 2\n assert candidate(edges = [[10000, 9999], [10000, 5000], [10000, 2500], [10000, 7500], [10000, 6250], [10000, 8750], [10000, 3125], [10000, 6875], [10000, 1875], [10000, 8125], [10000, 9375], [10000, 1250], [10000, 3750], [10000, 6250], [10000, 8750], [10000, 4375], [10000, 7500], [10000, 21875], [10000, 8125], [10000, 5625]]) == 10000\n assert candidate(edges = [[67890, 54321], [67890, 23456], [67890, 34567], [67890, 45678], [67890, 56789], [67890, 68901], [67890, 79012], [67890, 80123], [67890, 91234], [67890, 10234], [67890, 11345], [67890, 12456], [67890, 13567], [67890, 14678], [67890, 15789], [67890, 16890], [67890, 17901], [67890, 18012], [67890, 19123], [67890, 20234]]) == 67890\n assert candidate(edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30]]) == 1\n assert candidate(edges = [[2, 1], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15]]) == 2\n assert candidate(edges = [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [50, 11], [50, 12], [50, 13], [50, 14], [50, 15]]) == 50\n assert candidate(edges = [[50000, 1], [50000, 50001], [50000, 50002], [50000, 50003], [50000, 50004]]) == 50000\n assert candidate(edges = [[100, 50], [100, 25], [100, 75], [100, 20], [100, 80], [100, 90], [100, 10], [100, 40], [100, 60], [100, 30]]) == 100\n assert candidate(edges = [[100, 50], [100, 99], [100, 23], [100, 75], [100, 1000], [100, 10], [100, 30], [100, 60], [100, 40], [100, 80]]) == 100\n assert candidate(edges = [[99999, 99998], [99999, 99997], [99999, 99996], [99999, 99995], [99999, 99994], [99999, 99993], [99999, 99992], [99999, 99991], [99999, 99990], [99999, 99989], [99999, 99988], [99999, 99987], [99999, 99986], [99999, 99985], [99999, 99984], [99999, 99983], [99999, 99982], [99999, 99981], [99999, 99980]]) == 99999\n assert candidate(edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 2\n assert candidate(edges = [[50000, 50001], [50000, 50002], [50000, 50003], [50000, 50004], [50000, 50005], [50000, 50006], [50000, 50007], [50000, 50008], [50000, 50009], [50000, 50010]]) == 50000\n assert candidate(edges = [[50, 1], [50, 51], [50, 52], [50, 53], [50, 54], [50, 55], [50, 56], [50, 57], [50, 58], [50, 59], [50, 60], [50, 61], [50, 62], [50, 63], [50, 64], [50, 65]]) == 50\n assert candidate(edges = [[50000, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 47], [1, 48], [1, 49], [1, 50]]) == 1\n assert candidate(edges = [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [50, 11], [50, 12], [50, 13], [50, 14], [50, 15], [50, 16], [50, 17], [50, 18], [50, 19], [50, 20]]) == 50\n assert candidate(edges = [[100000, 99999], [100000, 99998], [100000, 99997], [100000, 99996], [100000, 99995], [100000, 1], [100000, 2], [100000, 3], [100000, 4]]) == 100000\n assert candidate(edges = [[50000, 1], [50000, 2], [50000, 3], [50000, 4], [50000, 5], [50000, 6], [50000, 7], [50000, 8], [50000, 9], [50000, 10]]) == 50000\n assert candidate(edges = [[500, 1000], [1000, 1500], [1000, 2000], [1000, 3000], [1000, 4000], [1000, 5000], [1000, 6000], [1000, 7000], [1000, 8000], [1000, 9000], [1000, 11000]]) == 1000\n assert candidate(edges = [[100000, 99999], [100000, 99998], [100000, 99997], [100000, 1]]) == 100000\n assert candidate(edges = [[30, 1], [30, 2], [30, 3], [30, 4], [30, 5], [30, 6], [30, 7], [30, 8], [30, 9], [30, 10], [30, 11], [30, 12], [30, 13], [30, 14], [30, 15], [30, 16], [30, 17], [30, 18], [30, 19], [30, 20], [30, 21], [30, 22], [30, 23], [30, 24], [30, 25], [30, 26], [30, 27], [30, 28], [30, 29]]) == 30\n assert candidate(edges = [[200000, 1], [200000, 2], [200000, 3], [200000, 4], [200000, 5], [200000, 6], [200000, 7], [200000, 8], [200000, 9], [200000, 10], [200000, 11], [200000, 12], [200000, 13], [200000, 14], [200000, 15], [200000, 16], [200000, 17], [200000, 18], [200000, 19], [200000, 20], [200000, 21], [200000, 22], [200000, 23], [200000, 24], [200000, 25], [200000, 26], [200000, 27], [200000, 28], [200000, 29], [200000, 30], [200000, 31], [200000, 32], [200000, 33], [200000, 34], [200000, 35], [200000, 36], [200000, 37], [200000, 38], [200000, 39], [200000, 40]]) == 200000\n assert candidate(edges = [[2, 1], [2, 4], [3, 2], [2, 6], [5, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == 2\n assert candidate(edges = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [100, 9], [100, 10], [100, 11], [100, 12], [100, 13], [100, 14], [100, 15], [100, 16], [100, 17], [100, 18], [100, 19], [100, 20], [100, 21], [100, 22], [100, 23], [100, 24], [100, 25], [100, 26], [100, 27], [100, 28], [100, 29], [100, 30], [100, 31], [100, 32], [100, 33], [100, 34], [100, 35], [100, 36], [100, 37], [100, 38], [100, 39], [100, 40], [100, 41], [100, 42], [100, 43], [100, 44], [100, 45], [100, 46], [100, 47], [100, 48], [100, 49], [100, 50]]) == 100\n assert candidate(edges = [[100000, 1], [100000, 2], [100000, 3], [100000, 4], [100000, 5], [100000, 6], [100000, 7], [100000, 8], [100000, 9], [100000, 10]]) == 100000\n"}, "metadata": {"canonical_parameter_names": ["edges"], "leetcode_dataset_entry_point": "Solution().findCenter", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findCenter(self, edges: list[list[int]]) -> int:", "container": "Solution", "callable": "findCenter", "parameters": [{"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1792, "task_id": "maximum-average-pass-ratio", "difficulty": "Medium", "problem_description": "There is a school that has classes of students and each class will be having a final exam. You are given a 2D integer array classes, where classes[i] = [passi, totali]. You know beforehand that in the ith class, there are totali total students, but only passi number of students will pass the exam.\nYou are also given an integer extraStudents. There are another extraStudents brilliant students that are guaranteed to pass the exam of any class they are assigned to. You want to assign each of the extraStudents students to a class in a way that maximizes the average pass ratio across all the classes.\nThe pass ratio of a class is equal to the number of students of the class that will pass the exam divided by the total number of students of the class. The average pass ratio is the sum of pass ratios of all the classes divided by the number of the classes.\nReturn the maximum possible average pass ratio after assigning the extraStudents students. Answers within 10-5 of the actual answer will be accepted.\n \nExample 1:\n\nInput: classes = [[1,2],[3,5],[2,2]], extraStudents = 2\nOutput: 0.78333\nExplanation: You can assign the two extra students to the first class. The average pass ratio will be equal to (3/4 + 3/5 + 2/2) / 3 = 0.78333.\n\nExample 2:\n\nInput: classes = [[2,4],[3,9],[4,5],[2,10]], extraStudents = 4\nOutput: 0.53485\n\n \nConstraints:\n\n1 <= classes.length <= 105\nclasses[i].length == 2\n1 <= passi <= totali <= 105\n1 <= extraStudents <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(classes = [[5, 10], [6, 10], [7, 10]],extraStudents = 1) == 0.6151515151515151\n assert candidate(classes = [[2, 4], [3, 9], [4, 5], [2, 10]],extraStudents = 4) == 0.5348484848484849\n assert candidate(classes = [[1, 1], [1, 1], [1, 1]],extraStudents = 1) == 1.0\n assert candidate(classes = [[1, 2], [3, 5], [2, 2]],extraStudents = 2) == 0.7833333333333333\n assert candidate(classes = [[10, 20], [20, 30], [30, 40]],extraStudents = 5) == 0.6722222222222222\n assert candidate(classes = [[5, 5], [10, 10]],extraStudents = 10) == 1.0\n assert candidate(classes = [[1, 1], [1, 2], [1, 3]],extraStudents = 3) == 0.7555555555555555\n assert candidate(classes = [[99, 100], [999, 1000], [9999, 10000]],extraStudents = 1000) == 0.999331746031746\n assert candidate(classes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],extraStudents = 10) == 1.0\n assert candidate(classes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],extraStudents = 10) == 0.6842857142857143\n assert candidate(classes = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000]],extraStudents = 45) == 0.7958742756361804\n assert candidate(classes = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],extraStudents = 15) == 0.2273449131513648\n assert candidate(classes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],extraStudents = 15) == 0.8571428571428571\n assert candidate(classes = [[1, 100], [10, 1000], [100, 10000], [1000, 100000]],extraStudents = 1000) == 0.3008176852167975\n assert candidate(classes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],extraStudents = 50) == 0.6412325174825175\n assert candidate(classes = [[99, 100], [999, 1000], [9999, 10000], [99999, 100000]],extraStudents = 10) == 0.9974497727272728\n assert candidate(classes = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50]],extraStudents = 25) == 0.5977592214345788\n assert candidate(classes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],extraStudents = 1000) == 1.0\n assert candidate(classes = [[1000, 2000], [1500, 3000], [2000, 4000], [2500, 5000], [3000, 6000]],extraStudents = 1000) == 0.5350170085037467\n assert candidate(classes = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15]],extraStudents = 10) == 0.4884670884670885\n assert candidate(classes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],extraStudents = 10) == 0.4164285714285715\n assert candidate(classes = [[1, 100], [10, 100], [50, 100]],extraStudents = 50) == 0.3296191939890711\n assert candidate(classes = [[100, 200], [150, 250], [200, 300], [250, 350]],extraStudents = 50) == 0.6452380952380952\n assert candidate(classes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]],extraStudents = 5) == 0.4371428571428571\n assert candidate(classes = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],extraStudents = 50) == 1.0\n assert candidate(classes = [[10000, 10001], [20000, 20001], [30000, 30001], [40000, 40001]],extraStudents = 1000) == 0.9999501925188506\n assert candidate(classes = [[50, 100], [75, 150], [125, 250], [200, 400], [300, 600], [450, 900]],extraStudents = 300) == 0.5992478200634347\n assert candidate(classes = [[5, 8], [5, 8], [5, 8], [5, 8], [5, 8]],extraStudents = 20) == 0.75\n assert candidate(classes = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],extraStudents = 100) == 0.8541887125220459\n assert candidate(classes = [[99, 100], [98, 100], [97, 100], [96, 100], [95, 100]],extraStudents = 5) == 0.9704761904761904\n assert candidate(classes = [[99999, 100000], [50000, 100000], [25000, 50000], [10000, 20000]],extraStudents = 5000) == 0.6499975\n assert candidate(classes = [[1, 100000], [2, 100000], [3, 100000]],extraStudents = 100000) == 0.2500150000093752\n assert candidate(classes = [[100, 200], [200, 500], [300, 800], [400, 1000]],extraStudents = 100) == 0.4604967738352485\n assert candidate(classes = [[1, 2], [3, 6], [5, 10], [7, 14], [9, 18]],extraStudents = 15) == 0.6531926406926407\n assert candidate(classes = [[1, 100000], [2, 100000], [3, 100000], [4, 100000], [5, 100000]],extraStudents = 100000) == 0.16669166670370508\n assert candidate(classes = [[10000, 20000], [5000, 10000], [2500, 5000], [1000, 2000], [500, 1000], [250, 500], [100, 200], [50, 100], [25, 50], [10, 20]],extraStudents = 10000) == 0.7885364227868774\n assert candidate(classes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],extraStudents = 5) == 1.0\n assert candidate(classes = [[50, 100], [150, 300], [250, 500], [350, 700]],extraStudents = 150) == 0.5803610885401075\n assert candidate(classes = [[1, 1], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],extraStudents = 20) == 0.9074074074074074\n assert candidate(classes = [[9, 10], [99, 100], [999, 1000], [9999, 10000], [99999, 100000]],extraStudents = 50000) == 0.9999456354114968\n assert candidate(classes = [[99, 100], [98, 100], [97, 100], [96, 100], [95, 100], [94, 100], [93, 100], [92, 100], [91, 100], [90, 100]],extraStudents = 10) == 0.945917211328976\n assert candidate(classes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11]],extraStudents = 10) == 0.3255194805194805\n assert candidate(classes = [[50, 100], [100, 200], [150, 300], [200, 400]],extraStudents = 100) == 0.567861188343116\n assert candidate(classes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],extraStudents = 9) == 0.341005291005291\n assert candidate(classes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],extraStudents = 5) == 0.7966666666666666\n assert candidate(classes = [[10, 11], [20, 22], [30, 33], [40, 44]],extraStudents = 5) == 0.9161931818181818\n assert candidate(classes = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]],extraStudents = 15) == 0.7535606060606062\n assert candidate(classes = [[1, 3], [2, 5], [3, 7], [4, 9]],extraStudents = 5) == 0.528968253968254\n assert candidate(classes = [[1, 1000], [10, 1000], [100, 1000], [1000, 1000]],extraStudents = 100) == 0.30143093489681594\n assert candidate(classes = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65]],extraStudents = 100) == 0.9114219114219114\n assert candidate(classes = [[1, 100], [20, 50], [30, 40], [40, 60]],extraStudents = 10) == 0.4822964571623233\n assert candidate(classes = [[1, 100000], [100000, 100000], [100000, 100000], [100000, 100000], [1, 100000]],extraStudents = 100000) == 0.733336\n assert candidate(classes = [[5, 6], [10, 12], [15, 18], [20, 24], [25, 30]],extraStudents = 50) == 0.8996095210091154\n assert candidate(classes = [[1, 2], [2, 4], [3, 8], [4, 16], [5, 32], [6, 64], [7, 128], [8, 256], [9, 512]],extraStudents = 256) == 0.56112903154186\n assert candidate(classes = [[99999, 100000], [99998, 100000], [99997, 100000]],extraStudents = 3) == 0.999980000299991\n assert candidate(classes = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],extraStudents = 100) == 0.29977994676131325\n assert candidate(classes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],extraStudents = 45) == 0.5812816812816812\n assert candidate(classes = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11]],extraStudents = 5) == 0.5140836940836941\n assert candidate(classes = [[100, 200], [200, 300], [50, 150], [250, 500], [100, 250]],extraStudents = 50) == 0.5133333333333333\n assert candidate(classes = [[1, 2], [1, 3], [1, 4], [1, 5]],extraStudents = 5) == 0.5\n assert candidate(classes = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]],extraStudents = 5) == 0.5488095238095239\n assert candidate(classes = [[1000, 10000], [2000, 20000], [3000, 30000], [4000, 40000]],extraStudents = 2000) == 0.1375\n assert candidate(classes = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],extraStudents = 200) == 0.638637428727642\n assert candidate(classes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],extraStudents = 50) == 0.9128787878787878\n assert candidate(classes = [[100, 101], [200, 201], [300, 301], [400, 401], [500, 501]],extraStudents = 500) == 0.9974701296361822\n assert candidate(classes = [[1, 100000], [2, 100000], [3, 100000], [4, 100000], [5, 100000]],extraStudents = 500000) == 0.5000150000250008\n assert candidate(classes = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],extraStudents = 5) == 0.5833333333333333\n assert candidate(classes = [[1, 100000], [100000, 200000], [1, 100000], [1, 100000]],extraStudents = 50000) == 0.23214928570379018\n assert candidate(classes = [[50, 100], [40, 80], [30, 60], [20, 40], [10, 20]],extraStudents = 20) == 0.554287556415216\n assert candidate(classes = [[1, 2], [2, 5], [3, 10], [4, 20], [5, 50], [6, 100], [7, 200], [8, 500], [9, 1000], [10, 10000]],extraStudents = 5000) == 0.7736090641036538\n assert candidate(classes = [[1, 1000], [1, 2000], [1, 3000], [1, 4000], [1, 5000]],extraStudents = 1500) == 0.14190236063451128\n assert candidate(classes = [[10, 20], [20, 40], [30, 60], [40, 80]],extraStudents = 20) == 0.56785944551902\n assert candidate(classes = [[99, 100], [199, 200], [299, 300], [399, 400], [499, 500]],extraStudents = 1000) == 0.998\n assert candidate(classes = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],extraStudents = 4500) == 0.5002246672081883\n assert candidate(classes = [[10000, 100000], [20000, 100000], [30000, 100000], [40000, 100000]],extraStudents = 10000) == 0.27058853870831734\n assert candidate(classes = [[1, 100], [1, 100], [1, 100], [1, 100], [1, 100]],extraStudents = 500) == 0.505\n assert candidate(classes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],extraStudents = 5) == 1.0\n assert candidate(classes = [[1, 10], [2, 15], [3, 20], [4, 25], [5, 30]],extraStudents = 15) == 0.2816248934356351\n assert candidate(classes = [[10, 20], [15, 25], [20, 30], [25, 35]],extraStudents = 10) == 0.6633597883597884\n assert candidate(classes = [[1, 100], [10, 100], [100, 100], [1000, 1000], [10000, 10000]],extraStudents = 10000) == 0.9925924392888745\n assert candidate(classes = [[1, 100000], [100000, 100000], [50000, 100000]],extraStudents = 50000) == 0.6114404678259185\n assert candidate(classes = [[10, 20], [15, 30], [5, 15], [25, 50]],extraStudents = 15) == 0.55\n assert candidate(classes = [[10000, 100000], [20000, 100000], [30000, 100000], [40000, 100000], [50000, 100000], [60000, 100000], [70000, 100000], [80000, 100000], [90000, 100000], [100000, 100000]],extraStudents = 10000) == 0.5582354154833269\n assert candidate(classes = [[50, 100], [40, 80], [30, 60], [20, 40], [10, 20]],extraStudents = 30) == 0.5707749766573296\n assert candidate(classes = [[1, 100000], [1, 100000], [1, 100000], [1, 100000], [1, 100000]],extraStudents = 100000) == 0.166675\n assert candidate(classes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],extraStudents = 100) == 0.9415395787944808\n assert candidate(classes = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500]],extraStudents = 50) == 0.16025231286795627\n assert candidate(classes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]],extraStudents = 15) == 0.5976190476190476\n assert candidate(classes = [[50, 100], [75, 150], [25, 75], [10, 50]],extraStudents = 20) == 0.44060351413292587\n assert candidate(classes = [[1, 100], [2, 100], [3, 100], [4, 100], [5, 100]],extraStudents = 250) == 0.3533647454875556\n assert candidate(classes = [[50000, 100000], [40000, 100000], [30000, 100000], [20000, 100000], [10000, 100000]],extraStudents = 50000) == 0.3696598823228846\n assert candidate(classes = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]],extraStudents = 100) == 0.7595597403486419\n assert candidate(classes = [[3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],extraStudents = 3) == 0.8464285714285715\n assert candidate(classes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],extraStudents = 9) == 0.8504850088183421\n assert candidate(classes = [[10, 12], [20, 25], [30, 35], [40, 45], [50, 55]],extraStudents = 30) == 0.8916472416472416\n assert candidate(classes = [[1, 2], [2, 4], [4, 8], [8, 16], [16, 32]],extraStudents = 64) == 0.7993434343434344\n assert candidate(classes = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],extraStudents = 100) == 0.49407730392552046\n assert candidate(classes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7]],extraStudents = 21) == 0.5919612794612795\n assert candidate(classes = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],extraStudents = 500) == 0.5672899020682859\n assert candidate(classes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],extraStudents = 10) == 0.8541887125220459\n assert candidate(classes = [[999, 1000], [998, 1000], [997, 1000], [996, 1000], [995, 1000]],extraStudents = 10) == 0.997009900990099\n"}, "metadata": {"canonical_parameter_names": ["classes", "extraStudents"], "leetcode_dataset_entry_point": "Solution().maxAverageRatio", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxAverageRatio(self, classes: list[list[int]], extraStudents: int) -> float:", "container": "Solution", "callable": "maxAverageRatio", "parameters": [{"name": "classes", "type": "list[list[int]]"}, {"name": "extraStudents", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1793, "task_id": "maximum-score-of-a-good-subarray", "difficulty": "Hard", "problem_description": "You are given an array of integers nums (0-indexed) and an integer k.\nThe score of a subarray (i, j) is defined as min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1). A good subarray is a subarray where i <= k <= j.\nReturn the maximum possible score of a good subarray.\n \nExample 1:\n\nInput: nums = [1,4,3,7,4,5], k = 3\nOutput: 15\nExplanation: The optimal subarray is (1, 5) with a score of min(4,3,7,4,5) * (5-1+1) = 3 * 5 = 15. \n\nExample 2:\n\nInput: nums = [5,5,4,5,4,1,1,1], k = 0\nOutput: 20\nExplanation: The optimal subarray is (0, 4) with a score of min(5,5,4,5,4) * (4-0+1) = 4 * 5 = 20.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 2 * 104\n0 <= k < nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 4, 5, 4, 1, 1, 1],k = 0) == 20\n assert candidate(nums = [10, 10, 10, 10, 10],k = 2) == 50\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 25\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],k = 4) == 10\n assert candidate(nums = [9, 7, 5, 3, 1],k = 2) == 15\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 30\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == 9\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9],k = 2) == 21\n assert candidate(nums = [1, 4, 3, 7, 4, 5],k = 3) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1],k = 4) == 25\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100],k = 4) == 1500\n assert candidate(nums = [10, 20, 30, 40, 50],k = 2) == 90\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 30\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 54\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],k = 3) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 30\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 30\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10, 1, 2, 3, 4, 5],k = 9) == 18\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 7) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],k = 25) == 69\n assert candidate(nums = [1, 20000, 2, 19999, 3, 19998, 4, 19997, 5, 19996, 6],k = 5) == 19998\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 200\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 110\n assert candidate(nums = [5, 15, 10, 20, 25, 30, 35, 40, 45, 50],k = 3) == 140\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 12) == 150\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 9) == 200000\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == 110\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 4) == 1000\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 19\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 110\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 20\n assert candidate(nums = [20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000],k = 10) == 400000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 300\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5],k = 15) == 44\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5],k = 4) == 19\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9],k = 9) == 30\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 10) == 1000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 6) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1],k = 9) == 10\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 7) == 64\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5],k = 5) == 150\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 55\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 15) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 7) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == 300\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 5) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 6) == 420\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 11) == 55\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 44\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12],k = 5) == 24\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10) == 200\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 1) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 9) == 99\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 2, 1, 2, 3, 6, 12, 25, 50, 100],k = 7) == 15\n assert candidate(nums = [5, 5, 4, 4, 4, 5, 5, 4, 4, 4, 5, 5, 4, 4, 4, 5, 5, 4, 4, 4, 5, 5, 4, 4, 4, 5, 5, 4, 4, 4],k = 12) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 14) == 55\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],k = 4) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 10) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10],k = 4) == 150\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5],k = 10) == 55\n assert candidate(nums = [10, 10, 10, 10, 10, 1, 1, 1, 1, 1],k = 5) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100],k = 9) == 100\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],k = 10) == 66\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 20) == 169\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 12) == 128\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 100],k = 4) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5, 10, 20, 30, 40, 50, 40, 30, 20, 10, 5],k = 15) == 150\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],k = 10) == 1620\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 5) == 10\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10],k = 9) == 39\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 8) == 18\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 64\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],k = 5) == 109890\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 20) == 38\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 5) == 910\n assert candidate(nums = [60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5],k = 5) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 20) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4],k = 10) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 15) == 100\n assert candidate(nums = [3, 3, 3, 1, 2, 3, 2, 1, 3, 3, 3, 3],k = 5) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 110\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 5) == 21\n assert candidate(nums = [20000, 19000, 18000, 17000, 16000, 15000, 14000, 13000, 12000, 11000, 10000],k = 10) == 110000\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],k = 15) == 1620\n assert candidate(nums = [1, 5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5],k = 25) == 30\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6],k = 4) == 10\n assert candidate(nums = [10000, 20000, 10000, 20000, 10000, 20000, 10000, 20000, 10000, 20000, 10000],k = 7) == 110000\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 8) == 18\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 80\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],k = 15) == 210\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 4) == 300\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumScore(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "maximumScore", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1796, "task_id": "second-largest-digit-in-a-string", "difficulty": "Easy", "problem_description": "Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist.\nAn alphanumeric string is a string consisting of lowercase English letters and digits.\n \nExample 1:\n\nInput: s = \"dfa12321afd\"\nOutput: 2\nExplanation: The digits that appear in s are [1, 2, 3]. The second largest digit is 2.\n\nExample 2:\n\nInput: s = \"abc1111\"\nOutput: -1\nExplanation: The digits that appear in s are [1]. There is no second largest digit. \n\n \nConstraints:\n\n1 <= s.length <= 500\ns consists of only lowercase English letters and digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"9876543210\") == 8\n assert candidate(s = \"same1same1same1\") == -1\n assert candidate(s = \"abcdefghij0\") == -1\n assert candidate(s = \"abc1111\") == -1\n assert candidate(s = \"1a\") == -1\n assert candidate(s = \"1234567890\") == 8\n assert candidate(s = \"dfa12321afd\") == 2\n assert candidate(s = \"a1\") == -1\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0\") == 8\n assert candidate(s = \"11223344556677889900\") == 8\n assert candidate(s = \"noDigitsHere\") == -1\n assert candidate(s = \"unique9\") == -1\n assert candidate(s = \"a1a2a3a4a5a6a7a8a9a0\") == 8\n assert candidate(s = \"no digits here\") == -1\n assert candidate(s = \"0000000000\") == -1\n assert candidate(s = \"9999999999\") == -1\n assert candidate(s = \"00000000001111111111\") == 0\n assert candidate(s = \"1001\") == 0\n assert candidate(s = \"abcdefg\") == -1\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0\") == 8\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz0\") == -1\n assert candidate(s = \"0a0b0c0d0e0f0g0h0i0j0k0l0m0n0o0p0q0r0s0t0u0v0w0x0y0z0\") == -1\n assert candidate(s = \"abcd1abcd2abcd3abcd4abcd5abcd6abcd7abcd8abcd9abcd0\") == 8\n assert candidate(s = \"9a8b7c6d5e4f3g2h1i0\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == 8\n assert candidate(s = \"abc123xyz123\") == 2\n assert candidate(s = \"9876543210abc9876543210\") == 8\n assert candidate(s = \"9223372036854775807\") == 8\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p9o8n7m6l5k4j3i2h1g0f9e8d7c6b5a4\") == 8\n assert candidate(s = \"1234567890abcdefghijklmnopqrstuvwxyz\") == 8\n assert candidate(s = \"1234567890abcdefghij0123456789\") == 8\n assert candidate(s = \"99887766554433221100\") == 8\n assert candidate(s = \"abcdefghij01234567890\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == 8\n assert candidate(s = \"abc123abc123abc123\") == 2\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == -1\n assert candidate(s = \"abc123xyz123abc123\") == 2\n assert candidate(s = \"1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz\") == 8\n assert candidate(s = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == -1\n assert candidate(s = \"123abc456def789ghi123\") == 8\n assert candidate(s = \"1\") == -1\n assert candidate(s = \"a1b1c2d2e3f3g4h4i5j5k6l6m7n7o8p8q9r0\") == 8\n assert candidate(s = \"1223344556677889900\") == 8\n assert candidate(s = \"1234123412341234\") == 3\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\") == 0\n assert candidate(s = \"abc123123123abc123123\") == 2\n assert candidate(s = \"000000000000000000000\") == -1\n assert candidate(s = \"123456789098765432101234567890\") == 8\n assert candidate(s = \"a1b1c2d2e3f3g4h4i5j5\") == 4\n assert candidate(s = \"1111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\") == 8\n assert candidate(s = \"1234567890123456789012345678901234567890\") == 8\n assert candidate(s = \"999888777666555444333222111000\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0\") == 8\n assert candidate(s = \"9876543210abcdefghijklmnopqrstuvwxyz\") == 8\n assert candidate(s = \"99999999999999999999\") == -1\n assert candidate(s = \"012345678901234567890123456789\") == 8\n assert candidate(s = \"10011001100110011001100110011001100110011001\") == 0\n assert candidate(s = \"1234567890abcdefghijk\") == 8\n assert candidate(s = \"abcdefghij0123456789\") == 8\n assert candidate(s = \"5555555555\") == -1\n assert candidate(s = \"55555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555\") == -1\n assert candidate(s = \"987654321009876543210987654321098765432109876543210\") == 8\n assert candidate(s = \"1234567890abcdefghij1234567890\") == 8\n assert candidate(s = \"12345678901234567890\") == 8\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij012345678901234567890123456789\") == 8\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz1234567890\") == 8\n assert candidate(s = \"98765432109876543210\") == 8\n assert candidate(s = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z11\") == -1\n assert candidate(s = \"111222333444555666777888999\") == 8\n assert candidate(s = \"999999999999999999999999999999999999999999999999\") == -1\n assert candidate(s = \"abcdefg1234567890\") == 8\n assert candidate(s = \"5555555555555\") == -1\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij012345678901234567890123456789\") == 8\n assert candidate(s = \"a1b2c2d3e3f4g4h5i5j6k6l7m7n8o8p9q9r0\") == 8\n assert candidate(s = \"zzzzz99999\") == -1\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1\") == -1\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p\") == 8\n assert candidate(s = \"9876543210abcdefg\") == 8\n assert candidate(s = \"98765432100123456789\") == 8\n assert candidate(s = \"0000000000000000000000000000000000000000000000000\") == -1\n assert candidate(s = \"abc123xyz456\") == 5\n assert candidate(s = \"123456789012345678901234567890123456789012345678901234567890\") == 8\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7\") == 8\n assert candidate(s = \"zzzzzzzzzzzzzzzzz9zzzzzzzzzzzzzzzz8\") == 8\n assert candidate(s = \"aabbccddeeffgghhii123456789\") == 8\n assert candidate(s = \"0123456789\") == 8\n assert candidate(s = \"abcdefghij1234567890\") == 8\n assert candidate(s = \"abcabcabc123123123\") == 2\n assert candidate(s = \"zzz9zzz8zzz7zzz6zzz5zzz4zzz3zzz2zzz1zzz0zzz\") == 8\n assert candidate(s = \"5555555555555555\") == -1\n assert candidate(s = \"a1b\") == -1\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t\") == 8\n assert candidate(s = \"111222333444555666777888999000\") == 8\n assert candidate(s = \"zzz999zzz888zzz\") == 8\n assert candidate(s = \"0000000000000111111111111222222222222333333333\") == 2\n assert candidate(s = \"abcd1234567890abcd\") == 8\n assert candidate(s = \"123abc123abc123\") == 2\n assert candidate(s = \"123abc456def789ghi0jkl\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0\") == 8\n assert candidate(s = \"00000000000000000000\") == -1\n assert candidate(s = \"abcdefghij012345678909876543210\") == 8\n assert candidate(s = \"123456789012345678901234567890\") == 8\n assert candidate(s = \"9999999999999999999999999999\") == -1\n assert candidate(s = \"987654321098765432109876543210\") == 8\n assert candidate(s = \"abc123xyz987\") == 8\n assert candidate(s = \"0000111122223333444455556666777788889999\") == 8\n assert candidate(s = \"555555555555555555555555555555555555\") == -1\n assert candidate(s = \"1a1b2c2d3e3f4g4h5i5j6k6l7m7n8o8p9q9r0s0t1u2v3w4x5y6z7\") == 8\n assert candidate(s = \"1122334455667788990011223344556677889900\") == 8\n assert candidate(s = \"0123456789abcdefghij0123456789\") == 8\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j\") == 8\n assert candidate(s = \"1111111111111111111112\") == 1\n assert candidate(s = \"1234567890abcdefghijabcdefghijabcdefghijabcdefghij012345678901234567890123456789\") == 8\n assert candidate(s = \"1234567890abcdefghij\") == 8\n assert candidate(s = \"122222222222222222222\") == 1\n assert candidate(s = \"123123123123123123123123123123123\") == 2\n assert candidate(s = \"9999999999888888888877777777766666666555555554444444433333333222222221111111100000000\") == 8\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz9876543210\") == 8\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1\") == 8\n assert candidate(s = \"111122223333444455556666777788889999\") == 8\n assert candidate(s = \"abcdefghij9876543210\") == 8\n assert candidate(s = \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\") == -1\n assert candidate(s = \"abcd1234efgh5678ijkl90mnop\") == 8\n assert candidate(s = \"123123123123123\") == 2\n assert candidate(s = \"9876543210abcdefghij0123456789\") == 8\n assert candidate(s = \"5555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555\") == -1\n assert candidate(s = \"zz9zz8zz7zz6zz5zz4zz3zz2zz1zz0zz\") == 8\n assert candidate(s = \"12345678901234567890abcdefghijabcdefghijabcdefghijabcdefghij012345678901234567890123456789\") == 8\n assert candidate(s = \"0102030405060708090\") == 8\n assert candidate(s = \"abc1234567890\") == 8\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().secondHighest", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def secondHighest(self, s: str) -> int:", "container": "Solution", "callable": "secondHighest", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1798, "task_id": "maximum-number-of-consecutive-values-you-can-make", "difficulty": "Medium", "problem_description": "You are given an integer array coins of length n which represents the n coins that you own. The value of the ith coin is coins[i]. You can make some value x if you can choose some of your n coins such that their values sum up to x.\nReturn the maximum number of consecutive integer values that you can make with your coins starting from and including 0.\nNote that you may have multiple coins of the same value.\n \nExample 1:\n\nInput: coins = [1,3]\nOutput: 2\nExplanation: You can make the following values:\n- 0: take []\n- 1: take [1]\nYou can make 2 consecutive integer values starting from 0.\nExample 2:\n\nInput: coins = [1,1,1,4]\nOutput: 8\nExplanation: You can make the following values:\n- 0: take []\n- 1: take [1]\n- 2: take [1,1]\n- 3: take [1,1,1]\n- 4: take [4]\n- 5: take [4,1]\n- 6: take [4,1,1]\n- 7: take [4,1,1,1]\nYou can make 8 consecutive integer values starting from 0.\nExample 3:\n\nInput: coins = [1,4,10,3,1]\nOutput: 20\n \nConstraints:\n\ncoins.length == n\n1 <= n <= 4 * 104\n1 <= coins[i] <= 4 * 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(coins = [1, 3]) == 2\n assert candidate(coins = [1, 2, 5]) == 4\n assert candidate(coins = [2, 2, 2, 2]) == 1\n assert candidate(coins = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 56\n assert candidate(coins = [1]) == 2\n assert candidate(coins = [1, 4, 10, 3, 1]) == 20\n assert candidate(coins = [40000, 40000, 40000, 40000]) == 1\n assert candidate(coins = [4, 3, 2, 1]) == 11\n assert candidate(coins = [100, 200, 300, 400, 500]) == 1\n assert candidate(coins = [1, 2, 3, 4, 5]) == 16\n assert candidate(coins = [1, 1, 1, 1, 1]) == 6\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1024\n assert candidate(coins = [1, 1, 3, 4]) == 10\n assert candidate(coins = [1, 2, 5, 10]) == 4\n assert candidate(coins = [100, 400, 200, 300]) == 1\n assert candidate(coins = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 1\n assert candidate(coins = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 21\n assert candidate(coins = [2]) == 1\n assert candidate(coins = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(coins = [10000, 20000, 30000, 40000]) == 1\n assert candidate(coins = [100, 400, 1, 1, 1]) == 4\n assert candidate(coins = [2, 2, 3, 3, 3, 4]) == 1\n assert candidate(coins = [1, 1, 3, 4, 10]) == 20\n assert candidate(coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 56\n assert candidate(coins = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 84\n assert candidate(coins = [1, 1, 1, 4]) == 8\n assert candidate(coins = [2, 4, 6, 8]) == 1\n assert candidate(coins = [1, 1, 2, 2, 3, 3]) == 13\n assert candidate(coins = [40000]) == 1\n assert candidate(coins = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 2\n assert candidate(coins = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 1\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100]) == 4\n assert candidate(coins = [5, 7, 11, 13, 17, 19, 23, 29, 31]) == 1\n assert candidate(coins = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 31\n assert candidate(coins = [2, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144]) == 1\n assert candidate(coins = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 1\n assert candidate(coins = [1, 2, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == 3073\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000]) == 4\n assert candidate(coins = [1, 5, 10, 25, 50, 100, 200, 500, 1000]) == 2\n assert candidate(coins = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 1\n assert candidate(coins = [3, 6, 9, 12, 15, 18, 21, 24, 27]) == 1\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2048\n assert candidate(coins = [2, 3, 6, 12, 24, 48, 96, 192, 384, 768]) == 1\n assert candidate(coins = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 111\n assert candidate(coins = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 5, 5, 5, 5, 5]) == 41\n assert candidate(coins = [1, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576]) == 2\n assert candidate(coins = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 1\n assert candidate(coins = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 73\n assert candidate(coins = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256]) == 1023\n assert candidate(coins = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n assert candidate(coins = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]) == 1597\n assert candidate(coins = [1, 2, 3, 6, 11, 20, 37, 68, 129, 254]) == 532\n assert candidate(coins = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(coins = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 1\n assert candidate(coins = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 821\n assert candidate(coins = [100, 200, 200, 300, 400, 400, 400, 500, 600, 600, 700, 800, 800, 900, 1000]) == 1\n assert candidate(coins = [2, 2, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 7]) == 1\n assert candidate(coins = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 46\n assert candidate(coins = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(coins = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 56\n assert candidate(coins = [1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(coins = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 2\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1048576\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 8192\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000]) == 4\n assert candidate(coins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1\n assert candidate(coins = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2\n assert candidate(coins = [10, 25, 50, 100, 200, 500, 1000, 2000, 5000, 10000]) == 1\n assert candidate(coins = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) == 144\n assert candidate(coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 121\n assert candidate(coins = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 1\n assert candidate(coins = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n assert candidate(coins = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 166\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64]) == 128\n assert candidate(coins = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 111\n assert candidate(coins = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 2\n assert candidate(coins = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 2\n assert candidate(coins = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(coins = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 1\n assert candidate(coins = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 2\n assert candidate(coins = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 28656\n assert candidate(coins = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 213\n assert candidate(coins = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 26\n assert candidate(coins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 32768\n assert candidate(coins = [1, 2, 3, 4, 5, 10, 20, 50, 100, 200]) == 46\n assert candidate(coins = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == 511\n assert candidate(coins = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 4, 9, 6, 2, 4, 9]) == 395\n assert candidate(coins = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16]) == 63\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128]) == 256\n assert candidate(coins = [1, 10, 100, 1000, 10000, 100000]) == 2\n assert candidate(coins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(coins = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 164\n assert candidate(coins = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 151\n assert candidate(coins = [4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == 1\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000]) == 4\n assert candidate(coins = [1, 5, 10, 25, 50, 100, 200, 500, 1000, 2000, 5000, 10000]) == 2\n"}, "metadata": {"canonical_parameter_names": ["coins"], "leetcode_dataset_entry_point": "Solution().getMaximumConsecutive", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getMaximumConsecutive(self, coins: list[int]) -> int:", "container": "Solution", "callable": "getMaximumConsecutive", "parameters": [{"name": "coins", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1800, "task_id": "maximum-ascending-subarray-sum", "difficulty": "Easy", "problem_description": "Given an array of positive integers nums, return the maximum possible sum of an strictly increasing subarray in nums.\nA subarray is defined as a contiguous sequence of numbers in an array.\n \nExample 1:\n\nInput: nums = [10,20,30,5,10,50]\nOutput: 65\nExplanation: [5,10,50] is the ascending subarray with the maximum sum of 65.\n\nExample 2:\n\nInput: nums = [10,20,30,40,50]\nOutput: 150\nExplanation: [10,20,30,40,50] is the ascending subarray with the maximum sum of 150.\n\nExample 3:\n\nInput: nums = [12,17,15,13,10,11,12]\nOutput: 33\nExplanation: [10,11,12] is the ascending subarray with the maximum sum of 33.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 99, 98, 97, 96]) == 100\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18]) == 111\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [10]) == 10\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [100, 1, 2, 3, 100, 2, 3, 100]) == 106\n assert candidate(nums = [100]) == 100\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 1, 2, 1, 2]) == 3\n assert candidate(nums = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [10, 20, 30, 5, 10, 50]) == 65\n assert candidate(nums = [100, 99, 100, 98, 97, 96, 95, 101, 102, 103]) == 401\n assert candidate(nums = [12, 17, 15, 13, 10, 11, 12]) == 33\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 5]) == 14\n assert candidate(nums = [100, 100, 100]) == 100\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 175\n assert candidate(nums = [5, 10, 9, 15, 20, 25, 20, 30, 40, 50]) == 140\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 40, 41, 42, 43, 44]) == 605\n assert candidate(nums = [5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7]) == 18\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 166\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [50, 1, 2, 3, 4, 50, 5, 6, 7, 8, 9, 50, 10, 11, 12, 13, 14, 15, 50, 16, 17, 18, 19, 20]) == 125\n assert candidate(nums = [30, 20, 10, 21, 22, 23, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [10, 20, 15, 25, 30, 22, 35, 40, 38, 45, 50]) == 133\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 240\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 7, 8, 6, 9, 10, 11, 10]) == 36\n assert candidate(nums = [10, 20, 10, 20, 30, 20, 30, 40, 50, 40, 60]) == 140\n assert candidate(nums = [1, 2, 3, 4, 3, 4, 5, 6, 5, 7, 8, 9, 10, 8, 9, 10, 11]) == 39\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 10, 100, 1000, 10, 1, 2, 3, 4, 5]) == 1111\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 400\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92]) == 100\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12]) == 23\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 3, 5, 7, 4, 6, 8, 5, 7, 9]) == 21\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 100\n assert candidate(nums = [20, 30, 25, 35, 40, 35, 45, 50, 45, 55, 60, 55, 65, 70, 65, 75, 80]) == 220\n assert candidate(nums = [5, 10, 15, 20, 25, 1, 2, 3, 4, 5, 30, 35, 40, 45, 50, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 215\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125]) == 2925\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 18\n assert candidate(nums = [1, 2, 3, 2, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5]) == 41\n assert candidate(nums = [10, 20, 30, 25, 35, 40, 35, 45, 50, 45, 55, 60, 55, 65, 70, 65, 75, 80, 75, 85, 90]) == 250\n assert candidate(nums = [1, 10, 11, 2, 20, 21, 3, 30, 31, 4, 40, 41, 5, 50, 51, 6, 60, 61, 7, 70, 71]) == 148\n assert candidate(nums = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 747\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1]) == 55\n assert candidate(nums = [3, 2, 1, 10, 20, 30, 25, 35, 45, 55]) == 160\n assert candidate(nums = [10, 20, 15, 25, 30, 20, 35, 40, 50, 45, 60]) == 145\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == 30\n assert candidate(nums = [10, 20, 15, 30, 40, 25, 50, 60, 35, 70, 80, 45, 90, 100, 55, 110, 120, 65, 130, 140, 75]) == 335\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 624\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 225\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 110\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 10, 20, 15, 25, 30, 20, 35, 40]) == 95\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [10, 20, 15, 25, 30, 20, 35, 40, 30, 45, 50]) == 125\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 550\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 100\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [100, 99, 98, 97, 96, 101, 102, 103, 104, 105]) == 611\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 100\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 1, 2, 3, 4, 5, 10, 15, 20]) == 105\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30]) == 50\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 165\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 156\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 100\n assert candidate(nums = [9, 10, 11, 8, 12, 13, 14, 7, 15, 16, 17, 18, 6, 19, 20, 21, 22, 23, 5, 24, 25, 26, 27, 28]) == 135\n assert candidate(nums = [5, 6, 3, 8, 9, 10, 7, 8, 9]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(nums = [30, 31, 32, 33, 34, 35, 15, 16, 17, 18, 19, 20, 21]) == 195\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 22\n assert candidate(nums = [5, 6, 7, 8, 9, 5, 6, 7, 10, 11, 12, 13]) == 64\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10, 11, 12, 13, 14, 1, 2, 3, 4, 5]) == 70\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [50, 40, 30, 20, 10, 20, 30, 40, 50, 60]) == 210\n assert candidate(nums = [10, 20, 10, 20, 30, 40, 30, 40, 50, 60]) == 180\n assert candidate(nums = [10, 20, 30, 25, 40, 50, 60, 55, 70, 80]) == 205\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 14]) == 39\n assert candidate(nums = [5, 1, 2, 3, 4, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [2, 3, 6, 6, 5, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 11, 12, 5, 6, 7]) == 68\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [5, 3, 7, 8, 2, 6, 9, 11, 10, 15]) == 28\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 1, 2, 3, 4, 5]) == 605\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 110\n assert candidate(nums = [10, 20, 30, 25, 26, 27, 28, 29, 30, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 275\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16]) == 72\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 8, 9, 10, 11, 12]) == 50\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 11, 10]) == 32\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 315\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 12, 11, 12]) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 11]) == 51\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 20, 30]) == 61\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 200\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 200\n assert candidate(nums = [10, 15, 20, 25, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(nums = [100, 99, 98, 97, 96, 1, 2, 3, 4, 5]) == 100\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 10, 11, 12, 13, 12, 13, 14, 15]) == 54\n assert candidate(nums = [3, 5, 4, 6, 7, 8, 6, 7, 8, 9, 10, 8, 9, 10, 11, 12, 10, 11, 12, 13, 14]) == 60\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxAscendingSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxAscendingSum(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maxAscendingSum", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1801, "task_id": "number-of-orders-in-the-backlog", "difficulty": "Medium", "problem_description": "You are given a 2D integer array orders, where each orders[i] = [pricei, amounti, orderTypei] denotes that amounti orders have been placed of type orderTypei at the price pricei. The orderTypei is:\\r\n\\r\n\\r\n\t0 if it is a batch of buy orders, or\\r\n\t1 if it is a batch of sell orders.\\r\n\\r\n\\r\nNote that orders[i] represents a batch of amounti independent orders with the same price and order type. All orders represented by orders[i] will be placed before all orders represented by orders[i+1] for all valid i.\\r\n\\r\nThere is a backlog that consists of orders that have not been executed. The backlog is initially empty. When an order is placed, the following happens:\\r\n\\r\n\\r\n\tIf the order is a buy order, you look at the sell order with the smallest price in the backlog. If that sell order's price is smaller than or equal to the current buy order's price, they will match and be executed, and that sell order will be removed from the backlog. Else, the buy order is added to the backlog.\\r\n\tVice versa, if the order is a sell order, you look at the buy order with the largest price in the backlog. If that buy order's price is larger than or equal to the current sell order's price, they will match and be executed, and that buy order will be removed from the backlog. Else, the sell order is added to the backlog.\\r\n\\r\n\\r\nReturn the total amount of orders in the backlog after placing all the orders from the input. Since this number can be large, return it modulo 109 + 7.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: orders = [[10,5,0],[15,2,1],[25,1,1],[30,4,0]]\\r\nOutput: 6\\r\nExplanation: Here is what happens with the orders:\\r\n- 5 orders of type buy with price 10 are placed. There are no sell orders, so the 5 orders are added to the backlog.\\r\n- 2 orders of type sell with price 15 are placed. There are no buy orders with prices larger than or equal to 15, so the 2 orders are added to the backlog.\\r\n- 1 order of type sell with price 25 is placed. There are no buy orders with prices larger than or equal to 25 in the backlog, so this order is added to the backlog.\\r\n- 4 orders of type buy with price 30 are placed. The first 2 orders are matched with the 2 sell orders of the least price, which is 15 and these 2 sell orders are removed from the backlog. The 3rd order is matched with the sell order of the least price, which is 25 and this sell order is removed from the backlog. Then, there are no more sell orders in the backlog, so the 4th order is added to the backlog.\\r\nFinally, the backlog has 5 buy orders with price 10, and 1 buy order with price 30. So the total number of orders in the backlog is 6.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: orders = [[7,1000000000,1],[15,3,0],[5,999999995,0],[5,1,1]]\\r\nOutput: 999999984\\r\nExplanation: Here is what happens with the orders:\\r\n- 109 orders of type sell with price 7 are placed. There are no buy orders, so the 109 orders are added to the backlog.\\r\n- 3 orders of type buy with price 15 are placed. They are matched with the 3 sell orders with the least price which is 7, and those 3 sell orders are removed from the backlog.\\r\n- 999999995 orders of type buy with price 5 are placed. The least price of a sell order is 7, so the 999999995 orders are added to the backlog.\\r\n- 1 order of type sell with price 5 is placed. It is matched with the buy order of the highest price, which is 5, and that buy order is removed from the backlog.\\r\nFinally, the backlog has (1000000000-3) sell orders with price 7, and (999999995-1) buy orders with price 5. So the total number of orders = 1999999991, which is equal to 999999984 % (109 + 7).\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= orders.length <= 105\\r\n\torders[i].length == 3\\r\n\t1 <= pricei, amounti <= 109\\r\n\torderTypei is either 0 or 1.\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(orders = [[7, 1000000000, 1], [15, 3, 0], [5, 999999995, 0], [5, 1, 1]]) == 999999984\n assert candidate(orders = [[1, 10, 0], [1, 10, 1], [1, 10, 0], [1, 10, 1]]) == 0\n assert candidate(orders = [[100, 1, 0], [200, 2, 0], [300, 3, 1], [400, 4, 1]]) == 10\n assert candidate(orders = [[1, 1, 0], [1, 1, 1], [1, 1, 0], [1, 1, 1]]) == 0\n assert candidate(orders = [[5, 5, 0], [5, 5, 1], [5, 5, 0], [5, 5, 1]]) == 0\n assert candidate(orders = [[100, 100, 0], [100, 100, 1], [101, 100, 0], [99, 100, 1]]) == 0\n assert candidate(orders = [[1, 10, 0], [2, 10, 0], [3, 10, 1], [4, 10, 1]]) == 40\n assert candidate(orders = [[5, 5, 0], [4, 4, 1], [3, 3, 0], [2, 2, 1], [1, 1, 0]]) == 3\n assert candidate(orders = [[100, 10, 0], [200, 15, 0], [100, 5, 1], [200, 20, 1]]) == 20\n assert candidate(orders = [[5, 5, 0], [5, 5, 1]]) == 0\n assert candidate(orders = [[10, 5, 0], [15, 2, 1], [25, 1, 1], [30, 4, 0]]) == 6\n assert candidate(orders = [[100, 1, 0], [99, 2, 0], [98, 3, 0], [97, 4, 1], [96, 5, 1]]) == 3\n assert candidate(orders = [[5, 10, 0], [5, 5, 1], [5, 5, 0], [5, 3, 1]]) == 7\n assert candidate(orders = [[1, 10, 0], [2, 20, 1], [3, 30, 0], [4, 40, 1]]) == 60\n assert candidate(orders = [[100, 10, 0], [99, 9, 1], [98, 8, 0], [97, 7, 1], [96, 6, 0]]) == 8\n assert candidate(orders = [[10, 10, 0], [10, 10, 0], [10, 10, 1], [10, 10, 1]]) == 0\n assert candidate(orders = [[50, 10, 0], [40, 15, 0], [30, 20, 0], [20, 25, 1], [10, 30, 1], [5, 35, 1], [3, 40, 1], [2, 45, 1], [1, 50, 1]]) == 180\n assert candidate(orders = [[10, 5, 0], [20, 5, 0], [30, 5, 0], [40, 5, 0], [10, 5, 1], [20, 5, 1], [30, 5, 1], [40, 5, 1], [5, 5, 0], [35, 5, 1]]) == 30\n assert candidate(orders = [[1, 1000000000, 0], [1, 1000000000, 0], [1, 1000000000, 1], [1, 1000000000, 1], [1, 1000000000, 0], [1, 1000000000, 1]]) == 0\n assert candidate(orders = [[1000000000, 1, 0], [1000000000, 1, 0], [1000000000, 1, 0], [1000000000, 1, 1], [1000000000, 1, 1], [1000000000, 1, 1]]) == 0\n assert candidate(orders = [[10, 5, 0], [9, 5, 0], [8, 5, 0], [7, 5, 0], [6, 5, 0], [6, 5, 1], [7, 5, 1], [8, 5, 1], [9, 5, 1], [10, 5, 1]]) == 20\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 2, 0], [999999998, 3, 0], [999999997, 4, 1], [999999996, 5, 1], [999999995, 6, 1]]) == 9\n assert candidate(orders = [[1, 1000000000, 0], [1000000000, 1, 1], [2, 999999999, 0], [999999999, 2, 1], [3, 999999998, 0], [999999998, 3, 1], [4, 999999997, 0], [999999997, 4, 1]]) == 999999983\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 2, 0], [999999998, 3, 0], [999999997, 4, 1], [999999996, 5, 1]]) == 3\n assert candidate(orders = [[1, 1000, 0], [2, 2000, 1], [3, 3000, 0], [4, 4000, 1], [5, 5000, 0], [6, 6000, 1], [7, 7000, 0], [8, 8000, 1], [9, 9000, 0], [10, 10000, 1]]) == 15000\n assert candidate(orders = [[1000, 1, 0], [1000, 2, 0], [1000, 3, 0], [1000, 1, 1], [1000, 2, 1], [1000, 3, 1]]) == 0\n assert candidate(orders = [[10, 100, 0], [20, 50, 1], [15, 30, 0], [25, 20, 1], [5, 10, 0], [30, 5, 1]]) == 215\n assert candidate(orders = [[100, 10, 0], [90, 5, 1], [80, 15, 0], [70, 20, 1], [60, 25, 0], [50, 30, 1]]) == 5\n assert candidate(orders = [[999999999, 50000, 0], [1, 50000, 1], [999999998, 50000, 0], [2, 50000, 1], [999999997, 50000, 0], [3, 50000, 1]]) == 0\n assert candidate(orders = [[1, 1000000000, 0], [2, 999999999, 0], [3, 999999998, 0], [4, 999999997, 0], [5, 999999996, 0], [5, 999999996, 1], [4, 999999997, 1], [3, 999999998, 1], [2, 999999999, 1], [1, 1000000000, 1]]) == 0\n assert candidate(orders = [[10, 10, 0], [20, 20, 1], [15, 15, 0], [16, 16, 1], [14, 14, 0], [17, 17, 1]]) == 92\n assert candidate(orders = [[10, 1, 0], [9, 2, 0], [8, 3, 0], [7, 4, 0], [6, 5, 1], [5, 6, 1], [4, 7, 1], [3, 8, 1], [2, 9, 1], [1, 10, 1]]) == 35\n assert candidate(orders = [[1000, 1000000, 0], [1001, 1000000, 0], [1002, 1000000, 0], [999, 1000000, 1], [998, 1000000, 1], [997, 1000000, 1]]) == 0\n assert candidate(orders = [[10, 10, 0], [20, 10, 1], [15, 10, 0], [25, 10, 1], [10, 10, 0], [20, 10, 1], [15, 10, 0], [25, 10, 1], [10, 10, 0], [20, 10, 1], [15, 10, 0], [25, 10, 1], [10, 10, 0], [20, 10, 1], [15, 10, 0], [25, 10, 1]]) == 160\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 1], [3, 1000000000, 0], [4, 1000000000, 1], [5, 1000000000, 0], [6, 1000000000, 1]]) == 999999993\n assert candidate(orders = [[10, 1000, 0], [20, 1000, 0], [30, 1000, 0], [40, 1000, 1], [50, 1000, 1], [60, 1000, 1], [70, 1000, 0], [80, 1000, 1], [90, 1000, 0]]) == 5000\n assert candidate(orders = [[10, 5, 0], [20, 10, 0], [30, 15, 0], [40, 20, 0], [50, 25, 0], [10, 5, 1], [20, 10, 1], [30, 15, 1], [40, 20, 1], [50, 25, 1]]) == 60\n assert candidate(orders = [[10, 5, 0], [20, 5, 0], [30, 5, 0], [40, 5, 0], [15, 5, 1], [25, 5, 1], [35, 5, 1], [45, 5, 1]]) == 20\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 0], [3, 1000000000, 0], [1, 1000000000, 1], [2, 1000000000, 1], [3, 1000000000, 1]]) == 999999993\n assert candidate(orders = [[10, 1, 0], [11, 2, 0], [12, 3, 0], [13, 4, 1], [14, 5, 1], [15, 6, 1], [16, 7, 1], [17, 8, 0], [18, 9, 0], [19, 10, 0]]) == 11\n assert candidate(orders = [[10, 1, 0], [10, 2, 0], [10, 3, 0], [10, 4, 1], [10, 5, 1], [10, 6, 1], [10, 7, 1], [10, 8, 0], [10, 9, 0], [10, 10, 0]]) == 11\n assert candidate(orders = [[5, 1, 0], [5, 2, 0], [5, 3, 0], [5, 4, 0], [5, 5, 1], [5, 4, 1], [5, 3, 1], [5, 2, 1], [5, 1, 1]]) == 5\n assert candidate(orders = [[100, 5, 0], [90, 10, 0], [80, 15, 0], [70, 20, 0], [60, 25, 0], [50, 30, 1], [40, 35, 1], [30, 40, 1], [20, 45, 1], [10, 50, 1]]) == 125\n assert candidate(orders = [[10, 1000, 0], [10, 900, 0], [10, 800, 0], [10, 700, 1], [10, 600, 1], [10, 500, 1], [10, 400, 1]]) == 500\n assert candidate(orders = [[10, 5, 0], [10, 5, 1], [10, 5, 0], [10, 5, 1], [10, 5, 0], [10, 5, 1], [10, 5, 0], [10, 5, 1]]) == 0\n assert candidate(orders = [[1, 999999999, 0], [1, 999999999, 0], [1, 999999999, 0], [1, 999999999, 0], [2, 999999999, 1], [2, 999999999, 1], [2, 999999999, 1], [2, 999999999, 1]]) == 999999943\n assert candidate(orders = [[10, 1, 0], [9, 2, 0], [8, 3, 0], [7, 4, 1], [6, 5, 1], [5, 6, 0], [4, 7, 0], [3, 8, 1], [2, 9, 1], [1, 10, 0]]) == 17\n assert candidate(orders = [[5, 100, 0], [10, 100, 1], [15, 100, 0], [20, 100, 1], [25, 100, 0], [30, 100, 1]]) == 200\n assert candidate(orders = [[10, 5, 0], [10, 5, 0], [10, 5, 0], [10, 5, 1], [10, 5, 1], [10, 5, 1], [10, 5, 0], [10, 5, 1], [10, 5, 0], [10, 5, 1]]) == 0\n assert candidate(orders = [[100, 100, 1], [90, 200, 1], [80, 300, 1], [70, 400, 0], [60, 500, 0], [50, 600, 0]]) == 2100\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 1, 0], [999999998, 1, 0], [999999997, 1, 1], [999999996, 1, 1], [999999995, 1, 1]]) == 0\n assert candidate(orders = [[10, 1, 0], [20, 2, 0], [30, 3, 0], [40, 4, 0], [50, 5, 0], [10, 1, 1], [20, 2, 1], [30, 3, 1], [40, 4, 1], [50, 5, 1]]) == 12\n assert candidate(orders = [[1, 1000000000, 0], [1000000000, 1, 1], [500000000, 2, 0], [1000000000, 999999999, 1], [1, 1, 0]]) == 999999996\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 1], [3, 1000000000, 0], [4, 1000000000, 1], [5, 1000000000, 0], [6, 1000000000, 1]]) == 999999993\n assert candidate(orders = [[100, 1000, 0], [999, 500, 1], [998, 750, 1], [1000, 1000, 0], [999, 250, 0]]) == 1000\n assert candidate(orders = [[100, 1, 0], [99, 2, 0], [98, 3, 0], [97, 4, 1], [96, 5, 1], [95, 6, 0], [94, 7, 1], [93, 8, 0], [92, 9, 1]]) == 5\n assert candidate(orders = [[1, 1000000000, 0], [1, 1000000000, 0], [1, 1000000000, 0], [1, 1000000000, 1], [1, 1000000000, 1], [1, 1000000000, 1]]) == 0\n assert candidate(orders = [[100, 1, 0], [99, 2, 0], [98, 3, 0], [97, 4, 1], [96, 5, 1], [95, 6, 0], [94, 7, 0], [93, 8, 1], [92, 9, 1]]) == 7\n assert candidate(orders = [[100, 100, 0], [200, 200, 0], [300, 300, 0], [400, 400, 0], [500, 500, 1], [600, 600, 1], [700, 700, 1], [800, 800, 1], [900, 900, 1], [1000, 1000, 1]]) == 5500\n assert candidate(orders = [[10, 5, 0], [20, 10, 0], [30, 15, 0], [5, 1, 1], [15, 2, 1], [25, 3, 1]]) == 24\n assert candidate(orders = [[100, 100, 0], [99, 150, 0], [98, 200, 0], [97, 250, 1], [96, 300, 1], [95, 350, 1]]) == 450\n assert candidate(orders = [[1, 1, 0], [2, 1, 0], [3, 1, 0], [4, 1, 0], [5, 1, 0], [6, 1, 0], [7, 1, 0], [8, 1, 0], [9, 1, 0], [10, 1, 0], [1, 1, 1], [2, 1, 1], [3, 1, 1], [4, 1, 1], [5, 1, 1], [6, 1, 1], [7, 1, 1], [8, 1, 1], [9, 1, 1], [10, 1, 1]]) == 10\n assert candidate(orders = [[1000000000, 1, 0], [1, 1, 1], [500000000, 1, 0], [500000000, 1, 1], [1000000000, 1, 0], [1, 1, 1]]) == 0\n assert candidate(orders = [[100, 100, 0], [90, 200, 0], [80, 300, 0], [70, 400, 1], [60, 500, 1], [50, 600, 1]]) == 900\n assert candidate(orders = [[10, 1, 0], [20, 2, 0], [10, 1, 1], [20, 2, 1], [30, 3, 0], [25, 2, 1], [15, 1, 0], [5, 1, 1]]) == 1\n assert candidate(orders = [[100, 5, 0], [200, 10, 0], [150, 5, 1], [160, 5, 1], [200, 20, 0], [150, 10, 1]]) == 15\n assert candidate(orders = [[10, 10, 0], [20, 10, 0], [30, 10, 0], [40, 10, 0], [50, 10, 0], [10, 10, 1], [20, 10, 1], [30, 10, 1], [40, 10, 1], [50, 10, 1], [10, 10, 0], [20, 10, 0], [30, 10, 0], [40, 10, 0], [50, 10, 0], [10, 10, 1], [20, 10, 1], [30, 10, 1], [40, 10, 1], [50, 10, 1]]) == 60\n assert candidate(orders = [[100, 1, 0], [90, 2, 0], [80, 3, 0], [70, 4, 1], [60, 5, 1], [50, 6, 1], [40, 7, 1], [30, 8, 1], [20, 9, 1], [10, 10, 1]]) == 43\n assert candidate(orders = [[1, 1, 0], [2, 1, 0], [3, 1, 0], [4, 1, 0], [5, 1, 0], [5, 1, 1], [4, 1, 1], [3, 1, 1], [2, 1, 1], [1, 1, 1]]) == 0\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 2, 0], [999999998, 3, 0], [999999997, 4, 1], [999999996, 5, 1], [999999995, 6, 0], [999999994, 7, 0], [999999993, 8, 1], [999999992, 9, 1]]) == 7\n assert candidate(orders = [[10, 100, 0], [20, 50, 0], [30, 200, 1], [15, 150, 1], [25, 100, 0], [35, 100, 1]]) == 400\n assert candidate(orders = [[1, 1, 0], [1, 1, 1], [1, 1, 0], [1, 1, 1], [1, 1, 0], [1, 1, 1]]) == 0\n assert candidate(orders = [[1, 1, 0], [2, 2, 0], [3, 3, 0], [4, 4, 0], [5, 5, 0], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1]]) == 12\n assert candidate(orders = [[100, 5, 0], [100, 5, 0], [100, 5, 1], [100, 5, 1], [100, 5, 0], [100, 5, 1]]) == 0\n assert candidate(orders = [[5, 1, 0], [6, 1, 0], [7, 1, 0], [8, 1, 0], [9, 1, 0], [10, 1, 1], [11, 1, 1], [12, 1, 1], [13, 1, 1], [14, 1, 1]]) == 10\n assert candidate(orders = [[10, 10, 0], [20, 20, 0], [30, 30, 0], [40, 40, 0], [50, 50, 0], [10, 1, 1], [20, 2, 1], [30, 3, 1], [40, 4, 1], [50, 5, 1]]) == 135\n assert candidate(orders = [[50, 10, 0], [50, 15, 0], [50, 20, 0], [50, 25, 1], [50, 30, 1], [50, 35, 1], [50, 40, 1], [50, 45, 1], [50, 50, 1]]) == 180\n assert candidate(orders = [[100, 50, 0], [100, 50, 0], [100, 50, 0], [100, 50, 1], [100, 50, 1], [100, 50, 1]]) == 0\n assert candidate(orders = [[10, 5, 0], [20, 5, 0], [30, 5, 0], [10, 5, 1], [20, 5, 1], [30, 5, 1], [15, 5, 0], [25, 5, 0], [35, 5, 0]]) == 15\n assert candidate(orders = [[10, 1, 0], [10, 1, 1], [11, 1, 0], [9, 1, 1], [12, 1, 0], [8, 1, 1], [13, 1, 0], [7, 1, 1]]) == 0\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 0], [3, 1000000000, 0], [4, 1000000000, 1], [5, 1000000000, 1], [6, 1000000000, 1]]) == 999999965\n assert candidate(orders = [[10, 10, 0], [10, 10, 1], [10, 10, 0], [10, 10, 1], [10, 10, 0], [10, 10, 1], [10, 10, 0], [10, 10, 1], [10, 10, 0], [10, 10, 1]]) == 0\n assert candidate(orders = [[1, 1000000000, 0], [2, 999999999, 0], [3, 999999998, 0], [4, 999999997, 1], [5, 999999996, 1], [6, 999999995, 1], [7, 999999994, 1], [8, 999999993, 0], [9, 999999992, 0], [10, 999999991, 0]]) == 999999982\n assert candidate(orders = [[50, 10, 0], [40, 20, 0], [30, 30, 0], [20, 40, 0], [10, 50, 0], [10, 60, 1], [20, 70, 1], [30, 80, 1], [40, 90, 1], [50, 100, 1], [15, 5, 0], [25, 5, 0], [35, 5, 0], [45, 5, 0], [55, 5, 0]]) == 335\n assert candidate(orders = [[100, 10, 0], [90, 10, 0], [80, 10, 0], [70, 10, 0], [60, 10, 0], [50, 10, 1], [40, 10, 1], [30, 10, 1], [20, 10, 1], [10, 10, 1]]) == 0\n assert candidate(orders = [[10, 5, 0], [20, 5, 0], [30, 5, 0], [15, 10, 1], [25, 10, 1], [35, 10, 1], [10, 5, 0], [20, 5, 0], [30, 5, 0], [15, 10, 1], [25, 10, 1], [35, 10, 1]]) == 50\n assert candidate(orders = [[100, 100000000, 0], [90, 200000000, 0], [80, 300000000, 1], [70, 400000000, 1], [60, 500000000, 0]]) == 900000000\n assert candidate(orders = [[100, 500, 0], [90, 500, 0], [80, 500, 0], [70, 500, 1], [60, 500, 1], [50, 500, 1]]) == 0\n assert candidate(orders = [[10, 1, 0], [10, 2, 1], [10, 3, 0], [10, 4, 1], [10, 5, 0]]) == 3\n assert candidate(orders = [[1, 1000000000, 0], [2, 500000000, 1], [3, 300000000, 0], [4, 200000000, 1], [5, 400000000, 0]]) == 1000000000\n assert candidate(orders = [[100, 5, 0], [101, 3, 0], [102, 2, 0], [99, 5, 1], [98, 6, 1], [97, 7, 1]]) == 8\n assert candidate(orders = [[500, 10, 0], [500, 10, 1], [500, 5, 0], [500, 5, 1], [500, 3, 0], [500, 3, 1]]) == 0\n assert candidate(orders = [[50, 10, 0], [60, 15, 0], [70, 20, 0], [40, 5, 1], [55, 10, 1], [65, 15, 1], [50, 10, 1], [60, 15, 1], [70, 20, 1]]) == 50\n assert candidate(orders = [[10, 1, 0], [20, 1, 1], [30, 1, 0], [40, 1, 1], [50, 1, 0], [60, 1, 1], [70, 1, 0], [80, 1, 1], [90, 1, 0]]) == 1\n assert candidate(orders = [[10, 10, 0], [9, 20, 0], [8, 30, 0], [7, 40, 1], [6, 50, 1], [5, 60, 1]]) == 90\n assert candidate(orders = [[20, 5, 0], [15, 3, 0], [10, 2, 1], [5, 1, 1], [15, 4, 0], [10, 6, 1]]) == 3\n assert candidate(orders = [[100, 1, 0], [200, 1, 0], [300, 1, 0], [400, 1, 0], [500, 1, 0], [150, 1, 1], [250, 1, 1], [350, 1, 1], [450, 1, 1], [550, 1, 1]]) == 6\n assert candidate(orders = [[999999999, 1, 0], [999999998, 2, 0], [999999997, 3, 0], [999999996, 4, 1], [999999995, 5, 1]]) == 3\n assert candidate(orders = [[10, 1, 0], [10, 1, 1], [10, 1, 0], [10, 1, 1], [10, 1, 0], [10, 1, 1], [10, 1, 0], [10, 1, 1], [10, 1, 0], [10, 1, 1]]) == 0\n assert candidate(orders = [[100, 500, 0], [90, 400, 0], [80, 300, 0], [70, 200, 1], [60, 100, 1], [50, 50, 1], [40, 50, 1], [30, 100, 1], [20, 200, 1]]) == 500\n assert candidate(orders = [[100, 100000, 0], [200, 200000, 0], [150, 50000, 1], [175, 75000, 1]]) == 175000\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 1, 0], [999999998, 1, 0], [999999997, 1, 0], [999999996, 1, 0], [999999995, 1, 1], [999999994, 1, 1], [999999993, 1, 1], [999999992, 1, 1], [999999991, 1, 1]]) == 0\n assert candidate(orders = [[1, 1, 0], [2, 2, 0], [3, 3, 0], [4, 4, 0], [5, 5, 0], [6, 6, 0], [7, 7, 0], [8, 8, 0], [9, 9, 0], [10, 10, 0], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1]]) == 54\n assert candidate(orders = [[5, 10, 0], [10, 20, 0], [15, 30, 0], [20, 10, 1], [25, 20, 1], [30, 30, 1]]) == 120\n assert candidate(orders = [[100, 10, 0], [90, 5, 1], [80, 3, 0], [70, 2, 1], [60, 4, 0], [50, 1, 1]]) == 9\n assert candidate(orders = [[10, 1, 0], [20, 1, 0], [30, 1, 0], [40, 1, 0], [50, 1, 0], [10, 1, 1], [20, 1, 1], [30, 1, 1], [40, 1, 1], [50, 1, 1]]) == 4\n assert candidate(orders = [[1, 1000000000, 1], [1000000000, 1, 0], [2, 1000000000, 1], [999999999, 1, 0], [3, 1000000000, 1]]) == 999999984\n assert candidate(orders = [[1, 10, 0], [2, 10, 0], [3, 10, 0], [4, 10, 1], [5, 10, 1], [6, 10, 1], [7, 10, 1], [8, 10, 1], [9, 10, 1]]) == 90\n assert candidate(orders = [[100, 1, 0], [100, 1, 0], [100, 1, 0], [100, 1, 1], [100, 1, 1], [100, 1, 1], [100, 1, 0], [100, 1, 0], [100, 1, 0], [100, 1, 1], [100, 1, 1], [100, 1, 1], [100, 1, 0], [100, 1, 0], [100, 1, 0], [100, 1, 1], [100, 1, 1], [100, 1, 1]]) == 0\n assert candidate(orders = [[100, 10, 0], [90, 20, 0], [80, 30, 0], [70, 40, 0], [60, 50, 0], [50, 60, 1], [40, 70, 1], [30, 80, 1], [20, 90, 1], [10, 100, 1]]) == 250\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 0], [3, 1000000000, 1], [4, 1000000000, 1], [5, 1000000000, 0]]) == 999999986\n assert candidate(orders = [[1, 1, 0], [2, 2, 1], [3, 3, 0], [4, 4, 1], [5, 5, 0], [6, 6, 1], [7, 7, 0], [8, 8, 1], [9, 9, 0], [10, 10, 1]]) == 15\n assert candidate(orders = [[50, 10, 0], [40, 15, 0], [30, 20, 0], [20, 25, 1], [10, 30, 1], [15, 35, 0], [25, 40, 1]]) == 65\n"}, "metadata": {"canonical_parameter_names": ["orders"], "leetcode_dataset_entry_point": "Solution().getNumberOfBacklogOrders", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getNumberOfBacklogOrders(self, orders: List[List[int]]) -> int:", "container": "Solution", "callable": "getNumberOfBacklogOrders", "parameters": [{"name": "orders", "type": "List[List[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1802, "task_id": "maximum-value-at-a-given-index-in-a-bounded-array", "difficulty": "Medium", "problem_description": "You are given three positive integers: n, index, and maxSum. You want to construct an array nums (0-indexed) that satisfies the following conditions:\n\nnums.length == n\nnums[i] is a positive integer where 0 <= i < n.\nabs(nums[i] - nums[i+1]) <= 1 where 0 <= i < n-1.\nThe sum of all the elements of nums does not exceed maxSum.\nnums[index] is maximized.\n\nReturn nums[index] of the constructed array.\nNote that abs(x) equals x if x >= 0, and -x otherwise.\n \nExample 1:\n\nInput: n = 4, index = 2, maxSum = 6\nOutput: 2\nExplanation: nums = [1,2,2,1] is one array that satisfies all the conditions.\nThere are no arrays that satisfy all the conditions and have nums[2] == 3, so 2 is the maximum nums[2].\n\nExample 2:\n\nInput: n = 6, index = 1, maxSum = 10\nOutput: 3\n\n \nConstraints:\n\n1 <= n <= maxSum <= 109\n0 <= index < n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,index = 0,maxSum = 1) == 1\n assert candidate(n = 10,index = 5,maxSum = 50) == 7\n assert candidate(n = 6,index = 1,maxSum = 10) == 3\n assert candidate(n = 1000000000,index = 500000000,maxSum = 1000000000) == 1\n assert candidate(n = 4,index = 2,maxSum = 6) == 2\n assert candidate(n = 20,index = 10,maxSum = 210) == 15\n assert candidate(n = 1000000000,index = 999999999,maxSum = 2000000000) == 44721\n assert candidate(n = 7,index = 3,maxSum = 20) == 4\n assert candidate(n = 1000000000,index = 1,maxSum = 1200000000) == 19999\n assert candidate(n = 100000,index = 0,maxSum = 10000000) == 4450\n assert candidate(n = 9,index = 4,maxSum = 25) == 5\n assert candidate(n = 1000,index = 500,maxSum = 500000) == 750\n assert candidate(n = 1000000000,index = 999999999,maxSum = 1000000000) == 1\n assert candidate(n = 20,index = 10,maxSum = 200) == 15\n assert candidate(n = 999999999,index = 999999998,maxSum = 2000000000) == 44721\n assert candidate(n = 100,index = 50,maxSum = 5000) == 75\n assert candidate(n = 1000000000,index = 500000000,maxSum = 2500000000) == 38730\n assert candidate(n = 4,index = 1,maxSum = 10) == 3\n assert candidate(n = 1000,index = 500,maxSum = 100000) == 315\n assert candidate(n = 750000000,index = 375000000,maxSum = 1500000000) == 27387\n assert candidate(n = 100000,index = 99999,maxSum = 10000000) == 4450\n assert candidate(n = 1000000,index = 500000,maxSum = 10000000) == 3001\n assert candidate(n = 500000000,index = 499999999,maxSum = 1500000000) == 44721\n assert candidate(n = 999999999,index = 0,maxSum = 999999999) == 1\n assert candidate(n = 999999999,index = 499999999,maxSum = 10000000000) == 94869\n assert candidate(n = 1000000000,index = 0,maxSum = 1000000000) == 1\n assert candidate(n = 50,index = 24,maxSum = 1225) == 37\n assert candidate(n = 100,index = 50,maxSum = 5050) == 75\n assert candidate(n = 9,index = 4,maxSum = 45) == 7\n assert candidate(n = 35,index = 17,maxSum = 3000) == 94\n assert candidate(n = 10000,index = 4999,maxSum = 1000000) == 995\n assert candidate(n = 9,index = 4,maxSum = 100) == 13\n assert candidate(n = 20,index = 0,maxSum = 50) == 8\n assert candidate(n = 1000000000,index = 1,maxSum = 2500000000) == 54771\n assert candidate(n = 750000000,index = 375000000,maxSum = 1800000000) == 32404\n assert candidate(n = 50,index = 25,maxSum = 500) == 22\n assert candidate(n = 500,index = 250,maxSum = 150000) == 425\n assert candidate(n = 2000000000,index = 1000000000,maxSum = 3000000000) == 31623\n assert candidate(n = 100,index = 50,maxSum = 10000) == 125\n assert candidate(n = 300000000,index = 150000000,maxSum = 1500000000) == 34642\n assert candidate(n = 5,index = 2,maxSum = 15) == 4\n assert candidate(n = 1000000000,index = 0,maxSum = 2000000000) == 44721\n assert candidate(n = 50,index = 24,maxSum = 1275) == 38\n assert candidate(n = 200,index = 100,maxSum = 2000) == 43\n assert candidate(n = 1,index = 0,maxSum = 1000000000) == 1000000000\n assert candidate(n = 1000000000,index = 500000000,maxSum = 10000000000) == 94869\n assert candidate(n = 8,index = 3,maxSum = 30) == 5\n assert candidate(n = 12,index = 6,maxSum = 75) == 9\n assert candidate(n = 10,index = 0,maxSum = 36) == 7\n assert candidate(n = 50,index = 24,maxSum = 5000) == 112\n assert candidate(n = 20,index = 19,maxSum = 50) == 8\n assert candidate(n = 500000000,index = 250000000,maxSum = 1000000000) == 22361\n assert candidate(n = 2,index = 1,maxSum = 3) == 2\n assert candidate(n = 1000000000,index = 1,maxSum = 2000000000) == 44720\n assert candidate(n = 15,index = 7,maxSum = 120) == 11\n assert candidate(n = 500000000,index = 1,maxSum = 1500000000) == 44720\n assert candidate(n = 500000000,index = 250000000,maxSum = 1500000000) == 31623\n assert candidate(n = 10,index = 0,maxSum = 100) == 14\n assert candidate(n = 15,index = 7,maxSum = 500) == 37\n assert candidate(n = 50,index = 25,maxSum = 1000) == 32\n assert candidate(n = 3,index = 1,maxSum = 15) == 5\n assert candidate(n = 25,index = 12,maxSum = 1500) == 66\n assert candidate(n = 7,index = 3,maxSum = 25) == 5\n assert candidate(n = 10,index = 9,maxSum = 100) == 14\n assert candidate(n = 3,index = 1,maxSum = 1000000000) == 333333334\n assert candidate(n = 500,index = 250,maxSum = 2000) == 39\n assert candidate(n = 20,index = 19,maxSum = 200) == 19\n assert candidate(n = 500000,index = 250000,maxSum = 100000000) == 9975\n assert candidate(n = 800000000,index = 400000000,maxSum = 1600000000) == 28285\n assert candidate(n = 15,index = 7,maxSum = 100) == 10\n assert candidate(n = 200,index = 100,maxSum = 20100) == 150\n assert candidate(n = 999999999,index = 499999999,maxSum = 999999999) == 1\n assert candidate(n = 200000000,index = 100000000,maxSum = 500000000) == 17321\n assert candidate(n = 1000000,index = 999999,maxSum = 2000000) == 1414\n assert candidate(n = 1000000000,index = 1,maxSum = 1000000000) == 1\n assert candidate(n = 500000000,index = 0,maxSum = 1200000000) == 37417\n assert candidate(n = 999999999,index = 0,maxSum = 1500000000) == 31623\n assert candidate(n = 10,index = 4,maxSum = 55) == 8\n assert candidate(n = 100,index = 50,maxSum = 1000) == 31\n assert candidate(n = 10,index = 9,maxSum = 25) == 6\n assert candidate(n = 10,index = 9,maxSum = 36) == 7\n assert candidate(n = 100000,index = 50000,maxSum = 5000000) == 2214\n assert candidate(n = 10,index = 0,maxSum = 50) == 9\n assert candidate(n = 2,index = 1,maxSum = 6) == 3\n assert candidate(n = 10,index = 0,maxSum = 25) == 6\n assert candidate(n = 150,index = 75,maxSum = 100000) == 704\n assert candidate(n = 2,index = 1,maxSum = 1000000000) == 500000000\n assert candidate(n = 5,index = 2,maxSum = 17) == 4\n assert candidate(n = 1000000000,index = 500000000,maxSum = 1000000001) == 2\n assert candidate(n = 500000000,index = 250000000,maxSum = 800000000) == 17321\n assert candidate(n = 5,index = 2,maxSum = 20) == 5\n assert candidate(n = 7,index = 3,maxSum = 50) == 8\n"}, "metadata": {"canonical_parameter_names": ["n", "index", "maxSum"], "leetcode_dataset_entry_point": "Solution().maxValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxValue(self, n: int, index: int, maxSum: int) -> int:", "container": "Solution", "callable": "maxValue", "parameters": [{"name": "n", "type": "int"}, {"name": "index", "type": "int"}, {"name": "maxSum", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1803, "task_id": "count-pairs-with-xor-in-a-range", "difficulty": "Hard", "problem_description": "Given a (0-indexed) integer array nums and two integers low and high, return the number of nice pairs.\\r\n\\r\nA nice pair is a pair (i, j) where 0 <= i < j < nums.length and low <= (nums[i] XOR nums[j]) <= high.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: nums = [1,4,2,7], low = 2, high = 6\\r\nOutput: 6\\r\nExplanation: All nice pairs (i, j) are as follows:\\r\n - (0, 1): nums[0] XOR nums[1] = 5 \\r\n - (0, 2): nums[0] XOR nums[2] = 3\\r\n - (0, 3): nums[0] XOR nums[3] = 6\\r\n - (1, 2): nums[1] XOR nums[2] = 6\\r\n - (1, 3): nums[1] XOR nums[3] = 3\\r\n - (2, 3): nums[2] XOR nums[3] = 5\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: nums = [9,8,4,2,1], low = 5, high = 14\\r\nOutput: 8\\r\nExplanation: All nice pairs (i, j) are as follows:\\r\n​​​​​ - (0, 2): nums[0] XOR nums[2] = 13\\r\n  - (0, 3): nums[0] XOR nums[3] = 11\\r\n  - (0, 4): nums[0] XOR nums[4] = 8\\r\n  - (1, 2): nums[1] XOR nums[2] = 12\\r\n  - (1, 3): nums[1] XOR nums[3] = 10\\r\n  - (1, 4): nums[1] XOR nums[4] = 9\\r\n  - (2, 3): nums[2] XOR nums[3] = 6\\r\n  - (2, 4): nums[2] XOR nums[4] = 5\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= nums.length <= 2 * 104\\r\n\t1 <= nums[i] <= 2 * 104\\r\n\t1 <= low <= high <= 2 * 104\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 7, 9],low = 1,high = 10) == 8\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9],low = 3,high = 7) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],low = 15,high = 25) == 1\n assert candidate(nums = [9, 8, 4, 2, 1],low = 5,high = 14) == 8\n assert candidate(nums = [1, 4, 2, 7],low = 2,high = 6) == 6\n assert candidate(nums = [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000],low = 5000,high = 15000) == 6\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324],low = 1000,high = 20000) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80],low = 2,high = 60) == 486\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],low = 1,high = 524288) == 0\n assert candidate(nums = [2468, 3579, 4682, 5793, 6824, 7935, 8246, 9357, 24689, 35790, 46821, 57932, 68243, 79354, 82465, 93576, 24687, 35798, 46829, 57930],low = 1000,high = 7000) == 20\n assert candidate(nums = [31415, 92653, 58979, 32384, 62643, 38327],low = 10000,high = 50000) == 8\n assert candidate(nums = [8, 14, 23, 41, 56, 72],low = 10,high = 50) == 7\n assert candidate(nums = [8, 15, 3, 11, 2, 9, 13],low = 4,high = 12) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],low = 3,high = 12) == 70\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],low = 1,high = 10000) == 89\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000],low = 1000,high = 12000) == 77\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],low = 2,high = 10) == 60\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],low = 5,high = 1000) == 36\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1024, 512, 256, 128],low = 1,high = 256) == 35\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],low = 2,high = 16) == 64\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993],low = 1,high = 10) == 21\n assert candidate(nums = [32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],low = 100,high = 20000) == 82\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],low = 2,high = 6) == 35\n assert candidate(nums = [1023, 2047, 3071, 4095, 5119, 6143, 7167, 8191, 9215, 10239],low = 500,high = 5000) == 17\n assert candidate(nums = [82, 164, 328, 656, 1312, 2624, 5248, 10496, 20992, 41984, 83968, 167936, 335872, 671744],low = 20000,high = 100000) == 16\n assert candidate(nums = [54321, 12345, 67890, 98765, 43210, 24680, 13579, 86420, 75310, 97531],low = 10000,high = 50000) == 31\n assert candidate(nums = [2, 3, 1, 6, 7, 5, 4, 8],low = 3,high = 9) == 16\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999],low = 2000,high = 8000) == 18\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],low = 3,high = 15) == 18\n assert candidate(nums = [15000, 20000, 25000, 30000, 35000, 40000],low = 5000,high = 15000) == 3\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],low = 10,high = 50) == 102\n assert candidate(nums = [6, 2, 3, 8, 10, 12, 15, 18],low = 1,high = 10) == 14\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],low = 20,high = 80) == 92\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],low = 5,high = 35) == 336\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31],low = 5,high = 20) == 15\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],low = 10,high = 2000) == 51\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225],low = 50,high = 200) == 63\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],low = 0,high = 1) == 45\n assert candidate(nums = [16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],low = 1,high = 1000) == 45\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],low = 50000,high = 150000) == -24\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],low = 1,high = 20) == 86\n assert candidate(nums = [15, 3, 8, 7, 10, 12, 13, 14],low = 5,high = 15) == 18\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400],low = 50,high = 200) == 7\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 10101, 20202, 30303, 40404, 50505],low = 500,high = 2000) == 20\n assert candidate(nums = [31, 14, 7, 28, 21, 1, 2, 4, 8, 16],low = 5,high = 25) == 33\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],low = 5,high = 25) == 125\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],low = 0,high = 0) == 190\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],low = 5,high = 25) == 42\n assert candidate(nums = [20000, 19999, 19998, 19997, 19996, 19995, 19994, 19993, 19992, 19991],low = 100,high = 200) == 0\n assert candidate(nums = [10000, 20000, 15000, 25000, 12000, 18000, 22000, 16000, 14000, 21000],low = 5000,high = 15000) == 12\n assert candidate(nums = [12345, 67890, 13579, 24680, 98765],low = 50000,high = 100000) == -3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],low = 1,high = 10) == 80\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],low = 1,high = 512) == 36\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],low = 2,high = 15) == 13\n assert candidate(nums = [1234, 2345, 3456, 4567, 5678, 6789, 7890],low = 1000,high = 5000) == 11\n assert candidate(nums = [32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63],low = 5000,high = 15000) == 9\n assert candidate(nums = [16384, 8192, 4096, 2048, 1024],low = 2000,high = 7000) == 3\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072],low = 10000,high = 100000) == 11\n assert candidate(nums = [123, 456, 789, 101112, 131415],low = 100,high = 500) == 3\n assert candidate(nums = [24, 48, 72, 96, 120, 144, 168, 192, 216, 240],low = 20,high = 100) == 16\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],low = 5,high = 200) == 27\n assert candidate(nums = [8191, 4095, 2047, 1023, 511],low = 1500,high = 3000) == 2\n assert candidate(nums = [123, 456, 789, 101, 112, 134, 156, 178, 190, 212],low = 50,high = 150) == 6\n assert candidate(nums = [10001, 20002, 30003, 40004, 50005, 60006, 70007, 80008, 90009],low = 10000,high = 90000) == 10\n assert candidate(nums = [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000],low = 10000,high = 40000) == 23\n assert candidate(nums = [16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],low = 1,high = 10000) == 89\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],low = 1,high = 30) == 211\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],low = 0,high = 0) == 45\n assert candidate(nums = [11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999, 100000],low = 20000,high = 80000) == 0\n assert candidate(nums = [1024, 2048, 3072, 4096, 5120, 6144, 7168],low = 1024,high = 6144) == 18\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127],low = 1000,high = 20000) == 23\n assert candidate(nums = [9876, 5432, 10987, 6543, 2019, 8765, 4321, 7654, 3210, 1111],low = 1000,high = 5000) == 14\n assert candidate(nums = [20000, 15000, 10000, 5000, 2500, 1250, 625],low = 1000,high = 5000) == 4\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901, 1012, 1113, 1214, 1315, 1416, 1517, 1618, 1719, 1820, 1921, 2022],low = 100,high = 500) == 41\n assert candidate(nums = [12345, 12346, 12347, 12348, 12349, 12350, 12351, 12352, 12353, 12354],low = 1,high = 5) == 18\n assert candidate(nums = [23, 5, 7, 9, 11, 13, 17, 19, 21, 23],low = 3,high = 15) == 14\n assert candidate(nums = [5000, 10000, 15000, 20000, 500, 1000, 1500, 2000],low = 100,high = 5000) == 8\n assert candidate(nums = [8, 13, 14, 30, 15, 17, 9],low = 3,high = 12) == 7\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160],low = 10,high = 70) == 149\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],low = 10,high = 40) == 37\n assert candidate(nums = [12345, 67890, 24680, 13579, 86420, 97531, 43210, 54321, 65432, 76543],low = 10000,high = 19000) == 6\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],low = 500,high = 1000) == 9\n assert candidate(nums = [12345, 67890, 13579, 24680, 97531, 86420, 11111, 22222, 33333, 44444],low = 10000,high = 50000) == 31\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],low = 10,high = 100) == 17\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],low = 100,high = 1000) == 90\n assert candidate(nums = [32768, 65535, 1, 2, 3, 4, 5, 6, 7, 8],low = 100,high = 1000) == 0\n assert candidate(nums = [32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63],low = 128,high = 256) == 3\n assert candidate(nums = [1023, 511, 255, 127, 63],low = 100,high = 500) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],low = 1,high = 5000) == 76\n assert candidate(nums = [20000, 19000, 18000, 17000, 16000, 15000, 14000, 13000, 12000, 11000, 10000, 9000, 8000, 7000, 6000],low = 500,high = 10000) == 43\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901, 1012, 1113, 1214, 1315, 1416, 1517],low = 100,high = 1000) == 51\n assert candidate(nums = [9876, 6543, 3210, 1234, 5678, 8765, 5432, 2109, 4321],low = 1000,high = 10000) == 23\n assert candidate(nums = [1234, 5678, 91011, 121314, 151617, 181920, 212223],low = 5000,high = 15000) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],low = 15,high = 55) == 21\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],low = 2,high = 18) == 28\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],low = 1,high = 15) == 24\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],low = 2,high = 10) == 63\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],low = 100,high = 500) == 20\n assert candidate(nums = [18, 17, 32, 31, 16, 15, 8, 7, 4, 3, 2, 1],low = 4,high = 12) == 14\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],low = 20,high = 100) == 15\n"}, "metadata": {"canonical_parameter_names": ["nums", "low", "high"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countPairs(self, nums: List[int], low: int, high: int) -> int:", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "nums", "type": "List[int]"}, {"name": "low", "type": "int"}, {"name": "high", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1805, "task_id": "number-of-different-integers-in-a-string", "difficulty": "Easy", "problem_description": "You are given a string word that consists of digits and lowercase English letters.\nYou will replace every non-digit character with a space. For example, \"a123bc34d8ef34\" will become \" 123  34 8  34\". Notice that you are left with some integers that are separated by at least one space: \"123\", \"34\", \"8\", and \"34\".\nReturn the number of different integers after performing the replacement operations on word.\nTwo integers are considered different if their decimal representations without any leading zeros are different.\n \nExample 1:\n\nInput: word = \"a123bc34d8ef34\"\nOutput: 3\nExplanation: The three different integers are \"123\", \"34\", and \"8\". Notice that \"34\" is only counted once.\n\nExample 2:\n\nInput: word = \"leet1234code234\"\nOutput: 2\n\nExample 3:\n\nInput: word = \"a1b01c001\"\nOutput: 1\nExplanation: The three integers \"1\", \"01\", and \"001\" all represent the same integer because\nthe leading zeros are ignored when comparing their decimal values.\n\n \nConstraints:\n\n1 <= word.length <= 1000\nword consists of digits and lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0\") == 10\n assert candidate(word = \"a123bc34d8ef34\") == 3\n assert candidate(word = \"a1a2a3a4a5a6a7a8a9a0\") == 10\n assert candidate(word = \"100leetcode\") == 1\n assert candidate(word = \"a1a1a1\") == 1\n assert candidate(word = \"0a001b002\") == 3\n assert candidate(word = \"12345\") == 1\n assert candidate(word = \"1a2b3c4d5e6f7g8h9i0j\") == 10\n assert candidate(word = \"00000\") == 1\n assert candidate(word = \"0a001b1c1\") == 2\n assert candidate(word = \"111222333444555666777888999000\") == 1\n assert candidate(word = \"leet1234code234\") == 2\n assert candidate(word = \"1234567890\") == 1\n assert candidate(word = \"000111222333444555666777888999000\") == 1\n assert candidate(word = \"11223344556677889900\") == 1\n assert candidate(word = \"a1b1c1\") == 1\n assert candidate(word = \"1a2b3c4d5e6f7g8h9i0j1\") == 10\n assert candidate(word = \"abc\") == 0\n assert candidate(word = \"22o22o22o\") == 1\n assert candidate(word = \"a1b01c001\") == 1\n assert candidate(word = \"a001b002c003\") == 3\n assert candidate(word = \"a001001b1001c001001\") == 1\n assert candidate(word = \"1a2b3c4d5\") == 5\n assert candidate(word = \"0a0b0c0\") == 1\n assert candidate(word = \"0abc00abc000abc0000abc\") == 1\n assert candidate(word = \"1a10a100a1000a10000a1\") == 5\n assert candidate(word = \"123abc456def789ghi123jkl456mno789pqr\") == 3\n assert candidate(word = \"abc123xyz456abc123xyz456abc123xyz456\") == 2\n assert candidate(word = \"0001abc002def03ghi0004\") == 4\n assert candidate(word = \"same123same123same123same\") == 1\n assert candidate(word = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == 1\n assert candidate(word = \"mixed123with456numbers789\") == 3\n assert candidate(word = \"000111000222000333000444000555000\") == 1\n assert candidate(word = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t\") == 10\n assert candidate(word = \"123abc456def789ghi123jkl456mno789pqr001s002t003u\") == 6\n assert candidate(word = \"123abc321def234ghi432jkl543mno654pqrs765tuvw876xyz987\") == 9\n assert candidate(word = \"1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0a\") == 10\n assert candidate(word = \"1a11a111a1111a11111a111111\") == 6\n assert candidate(word = \"9876543210a123456789b0987654321c\") == 3\n assert candidate(word = \"aaa123bbb123ccc123ddd123eee123\") == 1\n assert candidate(word = \"a0b00c000d0000e00000f000000g0000000h00000000i00000000j000000000\") == 1\n assert candidate(word = \"z9z8z7z6z5z4z3z2z1z0z9z8z7z6z5z4z3z2z1z0\") == 10\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0a01b02c03d04e05f06g07h08i09j00\") == 10\n assert candidate(word = \"a10000b1000c100d10e1f0g00h000i0000j00000k\") == 6\n assert candidate(word = \"1a10a100a1000a10000a100000a1000000a10000000a100000000\") == 9\n assert candidate(word = \"1000000000000000000000000000000\") == 1\n assert candidate(word = \"123xyz456xyz789xyz123xyz\") == 3\n assert candidate(word = \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111\") == 1\n assert candidate(word = \"100000a200000b300000c400000d500000e600000f700000g800000h900000\") == 9\n assert candidate(word = \"leading0s123trailing0s456\") == 3\n assert candidate(word = \"0001000200030004000500060007000800090000000100020003\") == 1\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\") == 10\n assert candidate(word = \"same123same123same123\") == 1\n assert candidate(word = \"1a001b0001c00001d000001e0000001f00000001g000000001\") == 1\n assert candidate(word = \"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010\") == 1\n assert candidate(word = \"aaaa111bbbb222cccc333dddd444\") == 4\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0\") == 10\n assert candidate(word = \"a0b00c000d0000\") == 1\n assert candidate(word = \"abc0abc00abc000abc0000abc000000abc0000000abc00000000abc000000000abc0000000000\") == 1\n assert candidate(word = \"leading000trailing\") == 1\n assert candidate(word = \"many000123manymany000456many000789many\") == 3\n assert candidate(word = \"a1000b1000c1000d1000e1000f1000g1000h1000i1000j1000\") == 1\n assert candidate(word = \"abc0def00ghi000jkl0000mno00000pqr000000stu\") == 1\n assert candidate(word = \"0000123456789000000000123456789000000012345678900000001234567890\") == 1\n assert candidate(word = \"0abc00abc000abc0000abc00000\") == 1\n assert candidate(word = \"0001000000001000000001\") == 1\n assert candidate(word = \"12345abc54321abc12345\") == 2\n assert candidate(word = \"repeated000repeated000repeated\") == 1\n assert candidate(word = \"z999y999x999w998v997u996\") == 4\n assert candidate(word = \"123abc321def456ghi654jkl789mno987pqr012stu210vwx321yz456\") == 8\n assert candidate(word = \"a1b01c001d0001e00001f10g100\") == 3\n assert candidate(word = \"000000000000000001\") == 1\n assert candidate(word = \"9a8b7c6d5e4f3g2h1i0j9k8l7m6n5o4p3q2r1s0\") == 10\n assert candidate(word = \"9876543210abcdefgh0987654321\") == 2\n assert candidate(word = \"9876543210zyxwvutsrqponmlkjihgfedcba9876543210\") == 1\n assert candidate(word = \"xyz001abc002def003ghi004jkl005\") == 5\n assert candidate(word = \"000000000012345678900000000\") == 1\n assert candidate(word = \"000abc0000def1234gh5678\") == 3\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0a00b002c003d004e005f006g007h008i009j000\") == 10\n assert candidate(word = \"a1b01c001d0001e00001f000001g0000001h00000001\") == 1\n assert candidate(word = \"1a01b002c0003d00004e000005f0000006g00000007h000000008i0000000009j0\") == 10\n assert candidate(word = \"123abc456def789ghi0jklm00nopqr000stu0000vwx00000yz\") == 4\n assert candidate(word = \"abc123xyz456def789ghi10jkl11mno12pqr13stu14vwx15\") == 9\n assert candidate(word = \"000001000002000003000004000005000006000007000008000009\") == 1\n assert candidate(word = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == 1\n assert candidate(word = \"abc123xyz456def789ghi001jkl234mno567pqr890stu0vwx123y0z456\") == 8\n assert candidate(word = \"abc123xyz456def456ghi789\") == 3\n assert candidate(word = \"a0b00c000d0000e00000f\") == 1\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0a000b0002c0003d0004e0005f0006g0007h0008i0009j0000\") == 10\n assert candidate(word = \"99999zzz88888xxx7777yyy6666\") == 4\n assert candidate(word = \"12345678901234567890123456789012345678901234567890123456789012345678901234567890\") == 1\n assert candidate(word = \"abc123xyz456abc123\") == 2\n assert candidate(word = \"abc123xyz456def123\") == 2\n assert candidate(word = \"a1b10c100d1000e10000f100000g1000000h10000000i100000000j1000000000\") == 10\n assert candidate(word = \"1234567890abcdefghijklmnopqrstuvwxyz0987654321\") == 2\n assert candidate(word = \"0000000000000000000000000\") == 1\n assert candidate(word = \"00000000000000000000000000000000000000000000000001\") == 1\n assert candidate(word = \"010abc0010def00010ghi\") == 1\n assert candidate(word = \"123abc123def123ghi123jkl123mno123pqrs123tuvw123xyz123\") == 1\n assert candidate(word = \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000\") == 1\n assert candidate(word = \"abc123def456ghi789jkl0123\") == 3\n assert candidate(word = \"123456789a987654321b123456789c987654321d123456789e987654321f123456789g\") == 2\n assert candidate(word = \"00123456789000\") == 1\n assert candidate(word = \"0a00b000c0000d00000e000000f0000000g00000000h000000000i000000000j0\") == 1\n assert candidate(word = \"a0b00c000d0000e00000f000000g0000000h00000000i0\") == 1\n assert candidate(word = \"a1b01c001d100e0001f10\") == 3\n assert candidate(word = \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999\") == 1\n assert candidate(word = \"abc001abc01abc1\") == 1\n assert candidate(word = \"a100000000b100000001c100000002d100000003e100000004f100000005\") == 6\n assert candidate(word = \"100000000000000000000000000000000000000000000000000000001\") == 1\n assert candidate(word = \"0012300abc045600def0123\") == 3\n assert candidate(word = \"00123004560078900100000000000000000000000000000000\") == 1\n assert candidate(word = \"9876543210qwertyuiopasdfghjklzxcvbnm\") == 1\n assert candidate(word = \"a0b0c00d000e0000f00000g000000h0000000i00000000j000000000\") == 1\n assert candidate(word = \"123abc456def789ghi0jkl123mno456pqr789stu0vwxyz\") == 4\n assert candidate(word = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7\") == 10\n assert candidate(word = \"abc123456def654321ghi123456\") == 2\n assert candidate(word = \"abc1def2ghi3jkl4mno5pqr6stu7vwx8yz90123456789\") == 9\n assert candidate(word = \"0a123b456c789d0123\") == 4\n assert candidate(word = \"a123b456c789d012e345f678g901\") == 7\n assert candidate(word = \"00100a001b001c\") == 2\n assert candidate(word = \"abc1abc01abc001abc0001abc00001abc000001abc0000001\") == 1\n assert candidate(word = \"abc001xyz01abc100\") == 2\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == 10\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().numDifferentIntegers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numDifferentIntegers(self, word: str) -> int:", "container": "Solution", "callable": "numDifferentIntegers", "parameters": [{"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1806, "task_id": "minimum-number-of-operations-to-reinitialize-a-permutation", "difficulty": "Medium", "problem_description": "You are given an even integer n​​​​​​. You initially have a permutation perm of size n​​ where perm[i] == i​ (0-indexed)​​​​.\nIn one operation, you will create a new array arr, and for each i:\n\nIf i % 2 == 0, then arr[i] = perm[i / 2].\nIf i % 2 == 1, then arr[i] = perm[n / 2 + (i - 1) / 2].\n\nYou will then assign arr​​​​ to perm.\nReturn the minimum non-zero number of operations you need to perform on perm to return the permutation to its initial value.\n \nExample 1:\n\nInput: n = 2\nOutput: 1\nExplanation: perm = [0,1] initially.\nAfter the 1st operation, perm = [0,1]\nSo it takes only 1 operation.\n\nExample 2:\n\nInput: n = 4\nOutput: 2\nExplanation: perm = [0,1,2,3] initially.\nAfter the 1st operation, perm = [0,2,1,3]\nAfter the 2nd operation, perm = [0,1,2,3]\nSo it takes only 2 operations.\n\nExample 3:\n\nInput: n = 6\nOutput: 4\n\n \nConstraints:\n\n2 <= n <= 1000\nn​​​​​​ is even.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 3\n assert candidate(n = 4) == 2\n assert candidate(n = 12) == 10\n assert candidate(n = 14) == 12\n assert candidate(n = 16) == 4\n assert candidate(n = 18) == 8\n assert candidate(n = 6) == 4\n assert candidate(n = 2) == 1\n assert candidate(n = 20) == 18\n assert candidate(n = 100) == 30\n assert candidate(n = 500) == 166\n assert candidate(n = 1000) == 36\n assert candidate(n = 10) == 6\n assert candidate(n = 896) == 356\n assert candidate(n = 992) == 495\n assert candidate(n = 988) == 138\n assert candidate(n = 50) == 21\n assert candidate(n = 300) == 132\n assert candidate(n = 384) == 191\n assert candidate(n = 600) == 299\n assert candidate(n = 64) == 6\n assert candidate(n = 72) == 35\n assert candidate(n = 192) == 95\n assert candidate(n = 888) == 443\n assert candidate(n = 1024) == 10\n assert candidate(n = 128) == 7\n assert candidate(n = 22) == 6\n assert candidate(n = 46) == 12\n assert candidate(n = 256) == 8\n assert candidate(n = 768) == 348\n assert candidate(n = 32) == 5\n assert candidate(n = 48) == 23\n assert candidate(n = 800) == 184\n assert candidate(n = 200) == 99\n assert candidate(n = 400) == 18\n assert candidate(n = 512) == 9\n assert candidate(n = 750) == 318\n assert candidate(n = 998) == 332\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().reinitializePermutation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def reinitializePermutation(self, n: int) -> int:", "container": "Solution", "callable": "reinitializePermutation", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1807, "task_id": "evaluate-the-bracket-pairs-of-a-string", "difficulty": "Medium", "problem_description": "You are given a string s that contains some bracket pairs, with each pair containing a non-empty key.\n\nFor example, in the string \"(name)is(age)yearsold\", there are two bracket pairs that contain the keys \"name\" and \"age\".\n\nYou know the values of a wide range of keys. This is represented by a 2D string array knowledge where each knowledge[i] = [keyi, valuei] indicates that key keyi has a value of valuei.\nYou are tasked to evaluate all of the bracket pairs. When you evaluate a bracket pair that contains some key keyi, you will:\n\nReplace keyi and the bracket pair with the key's corresponding valuei.\nIf you do not know the value of the key, you will replace keyi and the bracket pair with a question mark \"?\" (without the quotation marks).\n\nEach key will appear at most once in your knowledge. There will not be any nested brackets in s.\nReturn the resulting string after evaluating all of the bracket pairs.\n \nExample 1:\n\nInput: s = \"(name)is(age)yearsold\", knowledge = [[\"name\",\"bob\"],[\"age\",\"two\"]]\nOutput: \"bobistwoyearsold\"\nExplanation:\nThe key \"name\" has a value of \"bob\", so replace \"(name)\" with \"bob\".\nThe key \"age\" has a value of \"two\", so replace \"(age)\" with \"two\".\n\nExample 2:\n\nInput: s = \"hi(name)\", knowledge = [[\"a\",\"b\"]]\nOutput: \"hi?\"\nExplanation: As you do not know the value of the key \"name\", replace \"(name)\" with \"?\".\n\nExample 3:\n\nInput: s = \"(a)(a)(a)aaa\", knowledge = [[\"a\",\"yes\"]]\nOutput: \"yesyesyesaaa\"\nExplanation: The same key can appear multiple times.\nThe key \"a\" has a value of \"yes\", so replace all occurrences of \"(a)\" with \"yes\".\nNotice that the \"a\"s not in a bracket pair are not evaluated.\n\n \nConstraints:\n\n1 <= s.length <= 105\n0 <= knowledge.length <= 105\nknowledge[i].length == 2\n1 <= keyi.length, valuei.length <= 10\ns consists of lowercase English letters and round brackets '(' and ')'.\nEvery open bracket '(' in s will have a corresponding close bracket ')'.\nThe key in each bracket pair of s will be non-empty.\nThere will not be any nested bracket pairs in s.\nkeyi and valuei consist of lowercase English letters.\nEach keyi in knowledge is unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(a)(a)(a)aaa\",knowledge = [['a', 'yes']]) == \"yesyesyesaaa\"\n assert candidate(s = \"(a)(b)(c)(d)\",knowledge = [['a', '1'], ['b', '2'], ['c', '3']]) == \"123?\"\n assert candidate(s = \"hi(name)\",knowledge = [['a', 'b']]) == \"hi?\"\n assert candidate(s = \"(a)(a)(a)aaa\",knowledge = [['a', 'yes']]) == \"yesyesyesaaa\"\n assert candidate(s = \"\",knowledge = []) == \"\"\n assert candidate(s = \"noknowledgehere\",knowledge = []) == \"noknowledgehere\"\n assert candidate(s = \"no(brackets)here\",knowledge = []) == \"no?here\"\n assert candidate(s = \"hi(name)\",knowledge = [['a', 'b']]) == \"hi?\"\n assert candidate(s = \"(nested)but(not)really\",knowledge = [['nested', 'nested'], ['not', 'not']]) == \"nestedbutnotreally\"\n assert candidate(s = \"(key1)(key2)(key3)\",knowledge = [['key1', 'value1'], ['key2', 'value2']]) == \"value1value2?\"\n assert candidate(s = \"this(is)a(test)\",knowledge = [['is', 'was'], ['test', 'trial']]) == \"thiswasatrial\"\n assert candidate(s = \"(name)is(age)yearsold\",knowledge = [['name', 'bob'], ['age', 'two']]) == \"bobistwoyearsold\"\n assert candidate(s = \"(key1)(key2)\",knowledge = [['key1', 'value1'], ['key2', 'value2']]) == \"value1value2\"\n assert candidate(s = \"(single)\",knowledge = [['single', 'one']]) == \"one\"\n assert candidate(s = \"(last)one\",knowledge = [['last', 'final']]) == \"finalone\"\n assert candidate(s = \"single\",knowledge = [['single', 'word']]) == \"single\"\n assert candidate(s = \"hello\",knowledge = []) == \"hello\"\n assert candidate(s = \"(unknown)key\",knowledge = [['known', 'value']]) == \"?key\"\n assert candidate(s = \"(name)is(age)yearsold\",knowledge = [['name', 'bob'], ['age', 'two']]) == \"bobistwoyearsold\"\n assert candidate(s = \"(key1)(key2)(key3)\",knowledge = [['key1', 'val1'], ['key2', 'val2'], ['key3', 'val3']]) == \"val1val2val3\"\n assert candidate(s = \"(book)written(by)(author)\",knowledge = [['book', '1984'], ['author', 'George']]) == \"1984written?George\"\n assert candidate(s = \"(city)(in)(country)\",knowledge = [['city', 'Tokyo'], ['country', 'Japan']]) == \"Tokyo?Japan\"\n assert candidate(s = \"(nested)(key)(nested)\",knowledge = [['key', 'value'], ['nested', 'deep']]) == \"deepvaluedeep\"\n assert candidate(s = \"(ingredient)requiresto(cooktime)mins\",knowledge = [['ingredient', 'Cookies'], ['cooktime', '15']]) == \"Cookiesrequiresto15mins\"\n assert candidate(s = \"(one)(two)(three)(four)(five)\",knowledge = [['one', '1'], ['two', '2'], ['three', '3'], ['four', '4']]) == \"1234?\"\n assert candidate(s = \"(customer)(order)at(store)\",knowledge = [['customer', 'Alice'], ['order', 'Order123']]) == \"AliceOrder123at?\"\n assert candidate(s = \"(keyA)and(keyB)and(keyC)and(keyD)\",knowledge = [['keyA', 'valA'], ['keyB', 'valB']]) == \"valAandvalBand?and?\"\n assert candidate(s = \"(key)with(missing)knowledge\",knowledge = [['key', 'value1'], ['missing', 'value2'], ['knowledge', 'value3']]) == \"value1withvalue2knowledge\"\n assert candidate(s = \"(greeting)(world)(planet)\",knowledge = [['greeting', 'hello'], ['world', 'earth'], ['planet', 'mars']]) == \"helloearthmars\"\n assert candidate(s = \"(this)(is)(a)(test)(string)(with)(multiple)(keys)\",knowledge = [['this', 'it'], ['is', 'be'], ['a', 'an'], ['test', 'example'], ['string', 'sequence'], ['with', 'having'], ['multiple', 'several'], ['keys', 'identifiers']]) == \"itbeanexamplesequencehavingseveralidentifiers\"\n assert candidate(s = \"(language)programmingis(fun)\",knowledge = [['language', 'python'], ['fun', 'awesome']]) == \"pythonprogrammingisawesome\"\n assert candidate(s = \"(fruit)(vegetable)\",knowledge = [['fruit', 'apple'], ['vegetable', 'carrot']]) == \"applecarrot\"\n assert candidate(s = \"(animal)lives(in)(habitat)\",knowledge = [['animal', 'tiger'], ['habitat', 'jungle']]) == \"tigerlives?jungle\"\n assert candidate(s = \"(name)has(age)yearsand(occupation)\",knowledge = [['name', 'Alice'], ['age', '30']]) == \"Alicehas30yearsand?\"\n assert candidate(s = \"(longkey)(anotherkey)(yetanotherkey)\",knowledge = [['longkey', 'averylongvalue'], ['anotherkey', 'shortval'], ['yetanotherkey', 'value']]) == \"averylongvalueshortvalvalue\"\n assert candidate(s = \"(language)is(cool)\",knowledge = [['language', 'Python'], ['cool', 'awesome']]) == \"Pythonisawesome\"\n assert candidate(s = \"(first)and(last)name\",knowledge = [['first', 'john'], ['last', 'doe']]) == \"johnanddoename\"\n assert candidate(s = \"(name)is(living)(in)(city)\",knowledge = [['name', 'bob'], ['in', 'at'], ['city', 'london']]) == \"bobis?atlondon\"\n assert candidate(s = \"(animal)(eats)(food)\",knowledge = [['animal', 'lion'], ['food', 'meat']]) == \"lion?meat\"\n assert candidate(s = \"(user)likes(to)(eat)(food)\",knowledge = [['user', 'alice'], ['eat', 'enjoy'], ['food', 'pizza']]) == \"alicelikes?enjoypizza\"\n assert candidate(s = \"(prefix)middle(suffix)\",knowledge = [['prefix', 'start'], ['suffix', 'end']]) == \"startmiddleend\"\n assert candidate(s = \"(flower)grows(in)(soil)\",knowledge = [['flower', 'rose'], ['soil', 'dirt']]) == \"rosegrows?dirt\"\n assert candidate(s = \"(first)nameis(last)name\",knowledge = [['first', 'john'], ['last', 'doe']]) == \"johnnameisdoename\"\n assert candidate(s = \"(longkey1)and(longkey2)and(longkey3)and(longkey4)\",knowledge = [['longkey1', 'value1'], ['longkey2', 'value2'], ['longkey3', 'value3'], ['longkey4', 'value4']]) == \"value1andvalue2andvalue3andvalue4\"\n assert candidate(s = \"(department)islocatedat(address)\",knowledge = [['department', 'Sales'], ['address', '123BusinessSt']]) == \"Salesislocatedat123BusinessSt\"\n assert candidate(s = \"(name)has(a)(pet)\",knowledge = [['name', 'Mary'], ['pet', 'dog']]) == \"Maryhas?dog\"\n assert candidate(s = \"(drink)is(served)in(glass)\",knowledge = [['drink', 'water'], ['glass', 'big']]) == \"wateris?inbig\"\n assert candidate(s = \"prefix(key1)middle(key2)suffix\",knowledge = [['key1', 'value1'], ['key2', 'value2']]) == \"prefixvalue1middlevalue2suffix\"\n assert candidate(s = \"(key1)(key2)(key1)\",knowledge = [['key1', 'value1'], ['key2', 'value2']]) == \"value1value2value1\"\n assert candidate(s = \"(item1)(item2)(item3)(item4)\",knowledge = [['item1', 'itemA'], ['item2', 'itemB'], ['item4', 'itemD']]) == \"itemAitemB?itemD\"\n assert candidate(s = \"(greeting)world\",knowledge = [['greeting', 'hello'], ['farewell', 'bye']]) == \"helloworld\"\n assert candidate(s = \"(user)(name)livesin(city)with(zip)\",knowledge = [['user', 'John'], ['city', 'San Francisco'], ['zip', '94111']]) == \"John?livesinSan Franciscowith94111\"\n assert candidate(s = \"(person)(from)(place)isvisiting(placeofinterest)\",knowledge = [['person', 'Bob'], ['from', 'LosAngeles'], ['place', 'SanFrancisco'], ['placeofinterest', 'Alcatraz']]) == \"BobLosAngelesSanFranciscoisvisitingAlcatraz\"\n assert candidate(s = \"(longkeyname)is(longervaluename)\",knowledge = [['longkeyname', 'longervaluename']]) == \"longervaluenameis?\"\n assert candidate(s = \"(name)has(a)(pet)(dog)\",knowledge = [['name', 'john'], ['pet', 'dog'], ['dog', 'buddy']]) == \"johnhas?dogbuddy\"\n assert candidate(s = \"(key1)and(key2)and(key3)and(key4)and(key5)\",knowledge = [['key1', 'value1'], ['key2', 'value2'], ['key3', 'value3'], ['key4', 'value4']]) == \"value1andvalue2andvalue3andvalue4and?\"\n assert candidate(s = \"(prefix)_(suffix)\",knowledge = [['prefix', 'start'], ['suffix', 'end']]) == \"start_end\"\n assert candidate(s = \"(number)plus(number)equals(twice_number)\",knowledge = [['number', '10'], ['twice_number', '20']]) == \"10plus10equals20\"\n assert candidate(s = \"(name)livesat(address)andworksat(company)\",knowledge = [['name', 'Alice'], ['address', 'Wonderland'], ['company', 'TechCorp']]) == \"AlicelivesatWonderlandandworksatTechCorp\"\n assert candidate(s = \"(repeated)(key)(repeated)(key)\",knowledge = [['key', 'value']]) == \"?value?value\"\n assert candidate(s = \"(planet)(orbits)around(star)\",knowledge = [['planet', 'Earth'], ['star', 'Sun']]) == \"Earth?aroundSun\"\n assert candidate(s = \"(item)isavaliablefrom(date)\",knowledge = [['item', 'Smartphone'], ['date', '2023-12-15']]) == \"Smartphoneisavaliablefrom2023-12-15\"\n assert candidate(s = \"(conference)heldon(date)\",knowledge = [['conference', 'GDC'], ['date', '2024-03-19']]) == \"GDCheldon2024-03-19\"\n assert candidate(s = \"(first)(second)(third)(fourth)\",knowledge = [['first', 'one'], ['second', 'two'], ['third', 'three']]) == \"onetwothree?\"\n assert candidate(s = \"(color)(animal)\",knowledge = [['color', 'blue'], ['animal', 'dog'], ['bird', 'sparrow']]) == \"bluedog\"\n assert candidate(s = \"(firstName)(lastName)isfrom(city)in(country)\",knowledge = [['firstName', 'Alice'], ['lastName', 'Wonderland'], ['city', 'Wonderland'], ['country', 'Fantasia']]) == \"AliceWonderlandisfromWonderlandinFantasia\"\n assert candidate(s = \"(product)costs(dollars)and(euros)\",knowledge = [['product', 'Laptop'], ['dollars', '1200'], ['euros', '1020']]) == \"Laptopcosts1200and1020\"\n assert candidate(s = \"(nested)but(notreally)nested\",knowledge = [['nested', 'deep'], ['notreally', 'shallow']]) == \"deepbutshallownested\"\n assert candidate(s = \"(first)(last)(age)\",knowledge = [['first', 'john'], ['last', 'doe'], ['age', 'thirty']]) == \"johndoethirty\"\n assert candidate(s = \"(city)(has)(many)(buildings)\",knowledge = [['city', 'newyork'], ['many', 'lots']]) == \"newyork?lots?\"\n assert candidate(s = \"(language)(framework)\",knowledge = [['language', 'Python'], ['framework', 'Django'], ['version', '3.9']]) == \"PythonDjango\"\n assert candidate(s = \"(model)releasedon(year)\",knowledge = [['model', 'iPhone15'], ['year', '2023']]) == \"iPhone15releasedon2023\"\n assert candidate(s = \"(multiple)(keys)(here)\",knowledge = [['multiple', 'many'], ['keys', 'some'], ['here', 'there']]) == \"manysomethere\"\n assert candidate(s = \"(username)lastloggedin(on)\",knowledge = [['username', 'Alice'], ['on', '2023-10-01']]) == \"Alicelastloggedin2023-10-01\"\n assert candidate(s = \"(planet)is(almost)full\",knowledge = [['planet', 'Earth'], ['almost', 'not'], ['full', 'occupied']]) == \"Earthisnotfull\"\n assert candidate(s = \"(person)loves(to)(eat)\",knowledge = [['person', 'John'], ['eat', 'pizza']]) == \"Johnloves?pizza\"\n assert candidate(s = \"(car)is(fast)and(economical)\",knowledge = [['car', 'Ferrari'], ['fast', 'very'], ['economical', 'not']]) == \"Ferrariisveryandnot\"\n assert candidate(s = \"(key1)and(key2)and(key3)and(key4)\",knowledge = [['key1', 'value1'], ['key2', 'value2'], ['key4', 'value4']]) == \"value1andvalue2and?andvalue4\"\n assert candidate(s = \"(part1)(part2)(part3)\",knowledge = [['part1', 'first'], ['part2', 'second'], ['part3', 'third']]) == \"firstsecondthird\"\n assert candidate(s = \"(color)(is)(used)in(art)\",knowledge = [['color', 'red'], ['used', 'frequently']]) == \"red?frequentlyin?\"\n assert candidate(s = \"(key1)is(key2)and(key3)is(key4)\",knowledge = [['key1', 'value1'], ['key2', 'value2'], ['key3', 'value3']]) == \"value1isvalue2andvalue3is?\"\n assert candidate(s = \"(name)from(country)is(visitor)\",knowledge = [['name', 'Bob'], ['country', 'USA']]) == \"BobfromUSAis?\"\n assert candidate(s = \"(prefix)example(suffix)\",knowledge = [['prefix', 'pre'], ['suffix', 'post']]) == \"preexamplepost\"\n assert candidate(s = \"(unknown)(key)(not)(present)\",knowledge = [['present', 'available']]) == \"???available\"\n assert candidate(s = \"(unknown)(key1)(unknown)(key2)(unknown)\",knowledge = [['key1', 'value1'], ['key2', 'value2']]) == \"?value1?value2?\"\n assert candidate(s = \"(book)writtenby(author)publishedby(publisher)\",knowledge = [['book', 'GreatExpectations'], ['author', 'CharlesDickens'], ['publisher', 'ChapmanandHall']]) == \"GreatExpectationswrittenbyCharlesDickenspublishedbyChapmanandHall\"\n assert candidate(s = \"(instrument)plays(music)\",knowledge = [['instrument', 'guitar'], ['music', 'beautiful']]) == \"guitarplaysbeautiful\"\n assert candidate(s = \"(prefix)(middle)(suffix)\",knowledge = [['prefix', 'pre'], ['middle', 'mid'], ['suffix', 'suf']]) == \"premidsuf\"\n assert candidate(s = \"(fruit)are(sweet)and(healthy)\",knowledge = [['fruit', 'apples'], ['sweet', 'very'], ['healthy', 'indeed']]) == \"applesareveryandindeed\"\n assert candidate(s = \"(repeated)repeated(repeated)\",knowledge = [['repeated', 'again']]) == \"againrepeatedagain\"\n assert candidate(s = \"(planet)(moon)orbiting(planet)\",knowledge = [['planet', 'Earth'], ['moon', 'Moon']]) == \"EarthMoonorbitingEarth\"\n assert candidate(s = \"(key1)(key1)(key1)(key1)(key1)\",knowledge = [['key1', 'repeat']]) == \"repeatrepeatrepeatrepeatrepeat\"\n assert candidate(s = \"(key1)is(key2)yearsold(key3)\",knowledge = [['key1', 'bob'], ['key2', 'two']]) == \"bobistwoyearsold?\"\n assert candidate(s = \"(greeting)everyone(my)name(is)(unknown)\",knowledge = [['greeting', 'hi'], ['my', 'my']]) == \"hieveryonemyname??\"\n assert candidate(s = \"(bird)can(fly)high\",knowledge = [['bird', 'eagle'], ['fly', 'soar']]) == \"eaglecansoarhigh\"\n assert candidate(s = \"(country)has(a)(capital)\",knowledge = [['country', 'India'], ['capital', 'Delhi']]) == \"Indiahas?Delhi\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)\",knowledge = [['a', 'one'], ['b', 'two'], ['c', 'three'], ['d', 'four'], ['e', 'five'], ['f', 'six']]) == \"onetwothreefourfivesix\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)(q)(r)(s)(t)(u)(v)(w)(x)(y)(z)\",knowledge = [['a', 'A'], ['b', 'B'], ['c', 'C'], ['d', 'D'], ['e', 'E'], ['f', 'F'], ['g', 'G'], ['h', 'H'], ['i', 'I'], ['j', 'J'], ['k', 'K'], ['l', 'L'], ['m', 'M'], ['n', 'N'], ['o', 'O'], ['p', 'P'], ['q', 'Q'], ['r', 'R'], ['s', 'S'], ['t', 'T'], ['u', 'U'], ['v', 'V'], ['w', 'W'], ['x', 'X'], ['y', 'Y'], ['z', 'Z']]) == \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"(color)(of)the(sky)\",knowledge = [['color', 'blue'], ['sky', 'beautiful']]) == \"blue?thebeautiful\"\n assert candidate(s = \"(name)is(unknown)but(age)yearsold\",knowledge = [['name', 'alice'], ['age', '30']]) == \"aliceis?but30yearsold\"\n assert candidate(s = \"(product)priceis(price)and(quantity)itemsareavailable\",knowledge = [['product', 'laptop'], ['price', '1000'], ['quantity', '5']]) == \"laptoppriceis1000and5itemsareavailable\"\n assert candidate(s = \"(item)costs(amount)currency\",knowledge = [['item', 'book'], ['amount', '10'], ['currency', 'dollars']]) == \"bookcosts10currency\"\n assert candidate(s = \"(a)(b)(c)(d)(e)\",knowledge = [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma'], ['d', 'delta'], ['e', 'epsilon']]) == \"alphabetagammadeltaepsilon\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)(q)(r)(s)(t)(u)(v)(w)(x)(y)(z)\",knowledge = [['a', 'a'], ['b', 'b'], ['c', 'c'], ['d', 'd'], ['e', 'e'], ['f', 'f'], ['g', 'g'], ['h', 'h'], ['i', 'i'], ['j', 'j'], ['k', 'k'], ['l', 'l'], ['m', 'm'], ['n', 'n'], ['o', 'o'], ['p', 'p'], ['q', 'q'], ['r', 'r'], ['s', 's'], ['t', 't'], ['u', 'u'], ['v', 'v'], ['w', 'w'], ['x', 'x'], ['y', 'y'], ['z', 'z']]) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"(repeated)(repeated)(repeated)\",knowledge = [['repeated', 'rep']]) == \"repreprep\"\n assert candidate(s = \"(key1)and(key2)and(key3)and(key4)and(key5)and(key6)and(key7)\",knowledge = [['key1', 'value1'], ['key2', 'value2'], ['key3', 'value3'], ['key4', 'value4'], ['key5', 'value5'], ['key6', 'value6'], ['key7', 'value7']]) == \"value1andvalue2andvalue3andvalue4andvalue5andvalue6andvalue7\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)\",knowledge = [['a', 'one'], ['b', 'two'], ['c', 'three'], ['d', 'four'], ['e', 'five'], ['f', 'six'], ['g', 'seven'], ['h', 'eight'], ['i', 'nine'], ['j', 'ten']]) == \"onetwothreefourfivesixseveneightnineten\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)\",knowledge = [['a', 'yes'], ['b', 'no'], ['c', 'maybe'], ['d', 'sure'], ['e', 'never'], ['f', 'always'], ['g', 'often'], ['h', 'rarely'], ['i', 'sometimes'], ['j', 'usually']]) == \"yesnomaybesureneveralwaysoftenrarelysometimesusually\"\n assert candidate(s = \"(user)hasposted(numberofposts)times\",knowledge = [['user', 'Charlie'], ['numberofposts', '250']]) == \"Charliehasposted250times\"\n assert candidate(s = \"(complex)(string)(with)(multiple)(keys)\",knowledge = [['complex', 'com'], ['string', 'str'], ['with', 'wi'], ['multiple', 'mul'], ['keys', 'ke']]) == \"comstrwimulke\"\n assert candidate(s = \"(key1)is(key2)yearsold(key3)and(key4)livesin(key5)\",knowledge = [['key1', 'bob'], ['key2', 'two'], ['key5', 'NYC']]) == \"bobistwoyearsold?and?livesinNYC\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)\",knowledge = [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma'], ['d', 'delta'], ['e', 'epsilon']]) == \"alphabetagammadeltaepsilon?\"\n assert candidate(s = \"(nested)brackets(are)not(allowed)\",knowledge = [['nested', 'nested'], ['brackets', 'brackets'], ['not', 'not']]) == \"nestedbrackets?not?\"\n"}, "metadata": {"canonical_parameter_names": ["s", "knowledge"], "leetcode_dataset_entry_point": "Solution().evaluate", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def evaluate(self, s: str, knowledge: list[list[str]]) -> str:", "container": "Solution", "callable": "evaluate", "parameters": [{"name": "s", "type": "str"}, {"name": "knowledge", "type": "list[list[str]]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1808, "task_id": "maximize-number-of-nice-divisors", "difficulty": "Hard", "problem_description": "You are given a positive integer primeFactors. You are asked to construct a positive integer n that satisfies the following conditions:\\r\n\\r\n\\r\n The number of prime factors of n (not necessarily distinct) is at most primeFactors.\\r\n The number of nice divisors of n is maximized. Note that a divisor of n is nice if it is divisible by every prime factor of n. For example, if n = 12, then its prime factors are [2,2,3], then 6 and 12 are nice divisors, while 3 and 4 are not.\\r\n\\r\n\\r\nReturn the number of nice divisors of n. Since that number can be too large, return it modulo 109 + 7.\\r\n\\r\nNote that a prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. The prime factors of a number n is a list of prime numbers such that their product equals n.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: primeFactors = 5\\r\nOutput: 6\\r\nExplanation: 200 is a valid value of n.\\r\nIt has 5 prime factors: [2,2,2,5,5], and it has 6 nice divisors: [10,20,40,50,100,200].\\r\nThere is not other value of n that has at most 5 prime factors and more nice divisors.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: primeFactors = 8\\r\nOutput: 18\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= primeFactors <= 109\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(primeFactors = 1) == 1\n assert candidate(primeFactors = 3) == 3\n assert candidate(primeFactors = 2) == 2\n"}, "metadata": {"canonical_parameter_names": ["primeFactors"], "leetcode_dataset_entry_point": "Solution().maxNiceDivisors", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxNiceDivisors(self, primeFactors: int) -> int:", "container": "Solution", "callable": "maxNiceDivisors", "parameters": [{"name": "primeFactors", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1812, "task_id": "determine-color-of-a-chessboard-square", "difficulty": "Easy", "problem_description": "You are given coordinates, a string that represents the coordinates of a square of the chessboard. Below is a chessboard for your reference.\n\nReturn true if the square is white, and false if the square is black.\nThe coordinate will always represent a valid chessboard square. The coordinate will always have the letter first, and the number second.\n \nExample 1:\n\nInput: coordinates = \"a1\"\nOutput: false\nExplanation: From the chessboard above, the square with coordinates \"a1\" is black, so return false.\n\nExample 2:\n\nInput: coordinates = \"h3\"\nOutput: true\nExplanation: From the chessboard above, the square with coordinates \"h3\" is white, so return true.\n\nExample 3:\n\nInput: coordinates = \"c7\"\nOutput: false\n\n \nConstraints:\n\ncoordinates.length == 2\n'a' <= coordinates[0] <= 'h'\n'1' <= coordinates[1] <= '8'\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(coordinates = \"d5\") == True\n assert candidate(coordinates = \"e4\") == True\n assert candidate(coordinates = \"b8\") == False\n assert candidate(coordinates = \"b2\") == False\n assert candidate(coordinates = \"a1\") == False\n assert candidate(coordinates = \"g8\") == True\n assert candidate(coordinates = \"e5\") == False\n assert candidate(coordinates = \"d4\") == False\n assert candidate(coordinates = \"g2\") == True\n assert candidate(coordinates = \"e6\") == True\n assert candidate(coordinates = \"f6\") == False\n assert candidate(coordinates = \"h3\") == True\n assert candidate(coordinates = \"f4\") == False\n assert candidate(coordinates = \"c7\") == False\n assert candidate(coordinates = \"d3\") == True\n assert candidate(coordinates = \"g7\") == False\n assert candidate(coordinates = \"a7\") == False\n assert candidate(coordinates = \"c8\") == True\n assert candidate(coordinates = \"f2\") == False\n assert candidate(coordinates = \"f1\") == True\n assert candidate(coordinates = \"g1\") == False\n assert candidate(coordinates = \"b3\") == True\n assert candidate(coordinates = \"h5\") == True\n assert candidate(coordinates = \"e1\") == False\n assert candidate(coordinates = \"p2\") == False\n assert candidate(coordinates = \"a5\") == False\n assert candidate(coordinates = \"d7\") == True\n assert candidate(coordinates = \"g5\") == False\n assert candidate(coordinates = \"b6\") == False\n assert candidate(coordinates = \"f5\") == True\n assert candidate(coordinates = \"h1\") == True\n assert candidate(coordinates = \"j7\") == True\n assert candidate(coordinates = \"e3\") == False\n assert candidate(coordinates = \"c3\") == False\n assert candidate(coordinates = \"g4\") == True\n assert candidate(coordinates = \"a4\") == True\n assert candidate(coordinates = \"v1\") == True\n assert candidate(coordinates = \"d6\") == False\n assert candidate(coordinates = \"b1\") == True\n assert candidate(coordinates = \"g6\") == True\n assert candidate(coordinates = \"h6\") == False\n assert candidate(coordinates = \"c1\") == False\n assert candidate(coordinates = \"h7\") == True\n assert candidate(coordinates = \"r8\") == False\n assert candidate(coordinates = \"b7\") == True\n assert candidate(coordinates = \"c4\") == True\n assert candidate(coordinates = \"c2\") == True\n assert candidate(coordinates = \"f3\") == True\n assert candidate(coordinates = \"h4\") == False\n assert candidate(coordinates = \"n5\") == True\n assert candidate(coordinates = \"d8\") == False\n assert candidate(coordinates = \"b4\") == False\n assert candidate(coordinates = \"a8\") == True\n assert candidate(coordinates = \"a3\") == False\n assert candidate(coordinates = \"e2\") == True\n assert candidate(coordinates = \"e7\") == False\n assert candidate(coordinates = \"f7\") == True\n assert candidate(coordinates = \"d2\") == False\n assert candidate(coordinates = \"a2\") == True\n assert candidate(coordinates = \"b5\") == True\n assert candidate(coordinates = \"c5\") == False\n assert candidate(coordinates = \"h8\") == False\n assert candidate(coordinates = \"a6\") == True\n assert candidate(coordinates = \"m4\") == True\n assert candidate(coordinates = \"z9\") == True\n assert candidate(coordinates = \"h2\") == False\n assert candidate(coordinates = \"t3\") == True\n assert candidate(coordinates = \"x5\") == True\n assert candidate(coordinates = \"g3\") == False\n assert candidate(coordinates = \"l6\") == False\n assert candidate(coordinates = \"d1\") == True\n assert candidate(coordinates = \"f8\") == False\n assert candidate(coordinates = \"e8\") == True\n assert candidate(coordinates = \"c6\") == True\n"}, "metadata": {"canonical_parameter_names": ["coordinates"], "leetcode_dataset_entry_point": "Solution().squareIsWhite", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def squareIsWhite(self, coordinates: str) -> bool:", "container": "Solution", "callable": "squareIsWhite", "parameters": [{"name": "coordinates", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1813, "task_id": "sentence-similarity-iii", "difficulty": "Medium", "problem_description": "You are given two strings sentence1 and sentence2, each representing a sentence composed of words. A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of only uppercase and lowercase English characters.\nTwo sentences s1 and s2 are considered similar if it is possible to insert an arbitrary sentence (possibly empty) inside one of these sentences such that the two sentences become equal. Note that the inserted sentence must be separated from existing words by spaces.\nFor example,\n\ns1 = \"Hello Jane\" and s2 = \"Hello my name is Jane\" can be made equal by inserting \"my name is\" between \"Hello\" and \"Jane\" in s1.\ns1 = \"Frog cool\" and s2 = \"Frogs are cool\" are not similar, since although there is a sentence \"s are\" inserted into s1, it is not separated from \"Frog\" by a space.\n\nGiven two sentences sentence1 and sentence2, return true if sentence1 and sentence2 are similar. Otherwise, return false.\n \nExample 1:\n\nInput: sentence1 = \"My name is Haley\", sentence2 = \"My Haley\"\nOutput: true\nExplanation:\nsentence2 can be turned to sentence1 by inserting \"name is\" between \"My\" and \"Haley\".\n\nExample 2:\n\nInput: sentence1 = \"of\", sentence2 = \"A lot of words\"\nOutput: false\nExplanation:\nNo single sentence can be inserted inside one of the sentences to make it equal to the other.\n\nExample 3:\n\nInput: sentence1 = \"Eating right now\", sentence2 = \"Eating\"\nOutput: true\nExplanation:\nsentence2 can be turned to sentence1 by inserting \"right now\" at the end of the sentence.\n\n \nConstraints:\n\n1 <= sentence1.length, sentence2.length <= 100\nsentence1 and sentence2 consist of lowercase and uppercase English letters and spaces.\nThe words in sentence1 and sentence2 are separated by a single space.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Similar similar sentences\") == True\n assert candidate(sentence1 = \"Start end\",sentence2 = \"Start middle end\") == True\n assert candidate(sentence1 = \"Eating right now\",sentence2 = \"Eating\") == True\n assert candidate(sentence1 = \"A quick brown fox\",sentence2 = \"A quick brown fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"Quick brown fox\",sentence2 = \"Quick brown fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"of\",sentence2 = \"A lot of words\") == False\n assert candidate(sentence1 = \"Similarity check\",sentence2 = \"check Similarity\") == False\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Sentences Similar\") == False\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Similar very very similar sentences\") == True\n assert candidate(sentence1 = \"Python is great\",sentence2 = \"Python is very very great\") == True\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One three\") == True\n assert candidate(sentence1 = \"Python is great\",sentence2 = \"is great\") == True\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Sentences that are Similar\") == False\n assert candidate(sentence1 = \"One\",sentence2 = \"One two three\") == True\n assert candidate(sentence1 = \"One\",sentence2 = \"One\") == True\n assert candidate(sentence1 = \"Test\",sentence2 = \"Test test\") == True\n assert candidate(sentence1 = \"Single\",sentence2 = \"Single word\") == True\n assert candidate(sentence1 = \"Test test test\",sentence2 = \"Test test test test\") == True\n assert candidate(sentence1 = \"Python programming\",sentence2 = \"programming\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is\") == True\n assert candidate(sentence1 = \"A B C\",sentence2 = \"A B X C\") == True\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One two three four\") == True\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Similar very similar sentences\") == True\n assert candidate(sentence1 = \"My name is Haley\",sentence2 = \"My Haley\") == True\n assert candidate(sentence1 = \"Same Same Same\",sentence2 = \"Same\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is a dummy test\") == True\n assert candidate(sentence1 = \"Same same\",sentence2 = \"Same same same\") == True\n assert candidate(sentence1 = \"Overlap here\",sentence2 = \"Overlap word here\") == True\n assert candidate(sentence1 = \"Hello World\",sentence2 = \"World\") == True\n assert candidate(sentence1 = \"Hello World\",sentence2 = \"Hello\") == True\n assert candidate(sentence1 = \"Same same\",sentence2 = \"Same same\") == True\n assert candidate(sentence1 = \"Hello World\",sentence2 = \"Hello amazing World\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is a simple test\") == True\n assert candidate(sentence1 = \"First Second Third\",sentence2 = \"First Third\") == True\n assert candidate(sentence1 = \"Match here\",sentence2 = \"Match something here\") == True\n assert candidate(sentence1 = \"Hello World\",sentence2 = \"Hello from the World\") == True\n assert candidate(sentence1 = \"Alice in Wonderland\",sentence2 = \"Alice is in Wonderland\") == True\n assert candidate(sentence1 = \"Left Right\",sentence2 = \"Left Middle Right\") == True\n assert candidate(sentence1 = \"The quick brown fox\",sentence2 = \"The quick brown fox jumps over\") == True\n assert candidate(sentence1 = \"To be or not to be that is the question\",sentence2 = \"To be that is the question\") == True\n assert candidate(sentence1 = \"The world is a stage\",sentence2 = \"The world is a stage and all the men and women merely players\") == True\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One two insert three\") == True\n assert candidate(sentence1 = \"The quick brown fox\",sentence2 = \"The quick brown fox jumps\") == True\n assert candidate(sentence1 = \"No pain no gain\",sentence2 = \"No pain no gain but sometimes the pain is not worth the gain\") == True\n assert candidate(sentence1 = \"Let us play\",sentence2 = \"Let us play a game\") == True\n assert candidate(sentence1 = \"Mary had a little lamb\",sentence2 = \"Mary lamb\") == True\n assert candidate(sentence1 = \"All roads lead to Rome\",sentence2 = \"All roads lead to Rome but not all roads are the same\") == True\n assert candidate(sentence1 = \"Unique words only\",sentence2 = \"Unique unique words only\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over the lazy dog\",sentence2 = \"Quick brown fox jumps over the lazy quick brown dog\") == True\n assert candidate(sentence1 = \"a b c d e f g h i j\",sentence2 = \"a b c X Y Z d e f g h i j\") == True\n assert candidate(sentence1 = \"OnlyOneWordHere\",sentence2 = \"Only One Word Here\") == False\n assert candidate(sentence1 = \"Actions speak louder than words\",sentence2 = \"Actions speak\") == True\n assert candidate(sentence1 = \"One two three four five\",sentence2 = \"One two four five\") == True\n assert candidate(sentence1 = \"Python programming is fun\",sentence2 = \"Python programming is very fun\") == True\n assert candidate(sentence1 = \"Actions speak louder than words\",sentence2 = \"Actions speak louder than words but intentions matter\") == True\n assert candidate(sentence1 = \"Python is fun\",sentence2 = \"Python programming is really fun\") == False\n assert candidate(sentence1 = \"OpenAI is great\",sentence2 = \"OpenAI is indeed indeed great\") == True\n assert candidate(sentence1 = \"Do or do not there is no try\",sentence2 = \"Do or do not there is no no try\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over the lazy dog\",sentence2 = \"Quick fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"Time flies when you are having fun\",sentence2 = \"Time flies\") == True\n assert candidate(sentence1 = \"The world is a book and those who do not travel read only one page\",sentence2 = \"The world is a book and those who do not travel read only one chapter\") == False\n assert candidate(sentence1 = \"Python programming is fun and effective\",sentence2 = \"Python programming effective\") == True\n assert candidate(sentence1 = \"Complex complex case\",sentence2 = \"Complex even more complex case\") == True\n assert candidate(sentence1 = \"Time heals all wounds\",sentence2 = \"Time heals all wounds but time is also a thief\") == True\n assert candidate(sentence1 = \"SingleWord\",sentence2 = \"SingleWord\") == True\n assert candidate(sentence1 = \"The cat sat on the mat\",sentence2 = \"The cat sat on the blue mat\") == True\n assert candidate(sentence1 = \"First and last\",sentence2 = \"First something in the middle last\") == False\n assert candidate(sentence1 = \"Once upon a time\",sentence2 = \"Once upon a time in a land far far away\") == True\n assert candidate(sentence1 = \"I think therefore I am\",sentence2 = \"I think therefore I am six\") == True\n assert candidate(sentence1 = \"Single word match\",sentence2 = \"Single word match\") == True\n assert candidate(sentence1 = \"Silence is golden\",sentence2 = \"Silence is golden in the morning\") == True\n assert candidate(sentence1 = \"A quick brown fox jumps\",sentence2 = \"A quick brown fox quick brown fox jumps\") == True\n assert candidate(sentence1 = \"Complex problem solving\",sentence2 = \"Complex problem problem solving\") == True\n assert candidate(sentence1 = \"Short\",sentence2 = \"Short and sweet\") == True\n assert candidate(sentence1 = \"a\",sentence2 = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\") == True\n assert candidate(sentence1 = \"Overlap at end\",sentence2 = \"Continue overlap at end\") == False\n assert candidate(sentence1 = \"Happy birthday\",sentence2 = \"Happy birthday dear\") == True\n assert candidate(sentence1 = \"First word last word\",sentence2 = \"First first word last word\") == True\n assert candidate(sentence1 = \"To be or not to be\",sentence2 = \"To be or not to be that is the question\") == True\n assert candidate(sentence1 = \"May the force be with you\",sentence2 = \"May the force\") == True\n assert candidate(sentence1 = \"Python programming is fun\",sentence2 = \"Python programming is really really fun\") == True\n assert candidate(sentence1 = \"Alibaba Cloud offers various cloud services\",sentence2 = \"Alibaba Cloud offers cloud computing and storage services\") == False\n assert candidate(sentence1 = \"The early morning sun was a beautiful sight\",sentence2 = \"The early morning sun was a beautiful golden sight\") == True\n assert candidate(sentence1 = \"This is a long sentence with multiple words in it\",sentence2 = \"This long sentence with multiple words in it\") == True\n assert candidate(sentence1 = \"Lorem ipsum dolor sit amet\",sentence2 = \"Lorem ipsum dolor sit amet consectetur adipiscing elit\") == True\n assert candidate(sentence1 = \"Hello from the other side\",sentence2 = \"Hello from this side\") == False\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One two X Y Z three\") == True\n assert candidate(sentence1 = \"Beginning middle end\",sentence2 = \"Beginning middle middle middle end\") == True\n assert candidate(sentence1 = \"Unique sentence\",sentence2 = \"Unique special sentence\") == True\n assert candidate(sentence1 = \"The quick brown fox jumps over the lazy dog\",sentence2 = \"The quick brown fox jumps over the lazy\") == True\n assert candidate(sentence1 = \"Start with a sentence\",sentence2 = \"Start with a really long sentence\") == True\n assert candidate(sentence1 = \"Python is fun\",sentence2 = \"Python is an amazing and fun language\") == False\n assert candidate(sentence1 = \"All your base are belong to us\",sentence2 = \"All base are belong to us\") == True\n assert candidate(sentence1 = \"Longer sentence with multiple words\",sentence2 = \"Longer sentence with even more multiple words\") == True\n assert candidate(sentence1 = \"She sells sea shells by the sea shore\",sentence2 = \"She sells green sea shells by the sea shore\") == True\n assert candidate(sentence1 = \"Complex algorithm design and analysis\",sentence2 = \"Complex algorithm\") == True\n assert candidate(sentence1 = \"In the middle\",sentence2 = \"In the middle of nowhere\") == True\n assert candidate(sentence1 = \"First Last\",sentence2 = \"First in between Last\") == True\n assert candidate(sentence1 = \"I love to code\",sentence2 = \"I love to code code code\") == True\n assert candidate(sentence1 = \"Unique words only\",sentence2 = \"Unique words in between only\") == True\n assert candidate(sentence1 = \"The quick brown fox\",sentence2 = \"The quick brown fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"Single\",sentence2 = \"Single single single\") == True\n assert candidate(sentence1 = \"Life is a journey\",sentence2 = \"Life is a journey not a destination\") == True\n assert candidate(sentence1 = \"A B C D E\",sentence2 = \"A B X Y Z C D E\") == True\n assert candidate(sentence1 = \"The rain in Spain stays mainly in the plain\",sentence2 = \"The rain in Spain falls mainly in the plain\") == False\n assert candidate(sentence1 = \"A quick movement of the enemy will jeopardize six gunboats\",sentence2 = \"A quick movement of the enemy will jeopardize\") == True\n assert candidate(sentence1 = \"Short\",sentence2 = \"Very very short\") == False\n assert candidate(sentence1 = \"Do or do not there is no try\",sentence2 = \"Do or do not there is no other way\") == False\n assert candidate(sentence1 = \"Python programming is fun\",sentence2 = \"Python programming is very very fun\") == True\n assert candidate(sentence1 = \"Start coding\",sentence2 = \"Start coding today\") == True\n assert candidate(sentence1 = \"Happy new year\",sentence2 = \"Happy new new new year\") == True\n assert candidate(sentence1 = \"I love programming in Python\",sentence2 = \"I love programming in Java Python\") == True\n assert candidate(sentence1 = \"Actions speak louder than words\",sentence2 = \"Actions speak louder than words but words can inspire actions\") == True\n assert candidate(sentence1 = \"Python is great\",sentence2 = \"Programming in Python is great\") == True\n assert candidate(sentence1 = \"Data engineering and data science\",sentence2 = \"Data engineering\") == True\n assert candidate(sentence1 = \"One two three four\",sentence2 = \"One two five six seven eight three four\") == True\n assert candidate(sentence1 = \"I love coding\",sentence2 = \"I love coding in Python\") == True\n assert candidate(sentence1 = \"Prefix and suffix\",sentence2 = \"Prefix and more words suffix\") == True\n assert candidate(sentence1 = \"One two three four\",sentence2 = \"One two three four five six\") == True\n assert candidate(sentence1 = \"The quick brown fox jumps over the lazy dog\",sentence2 = \"The quick brown fox jumps over lazy dog\") == True\n assert candidate(sentence1 = \"Catch me if you can\",sentence2 = \"Catch me\") == True\n assert candidate(sentence1 = \"This is a complex example\",sentence2 = \"This is an extremely complex example\") == False\n assert candidate(sentence1 = \"Match start\",sentence2 = \"Match start middle\") == True\n assert candidate(sentence1 = \"x y z\",sentence2 = \"a b c x y z\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is only a test\") == True\n assert candidate(sentence1 = \"The quick brown fox jumps over the lazy dog\",sentence2 = \"The quick brown fox jumps high over the lazy dog\") == True\n assert candidate(sentence1 = \"Python is great\",sentence2 = \"Python is the best language great\") == True\n assert candidate(sentence1 = \"The cat in the hat sat on the mat\",sentence2 = \"The cat sat on the mat\") == True\n assert candidate(sentence1 = \"The pen is mightier than the sword\",sentence2 = \"The pen is mightier than the sword but silence is golden\") == True\n assert candidate(sentence1 = \"Machine learning is transforming industries\",sentence2 = \"Machine learning transforming industries\") == True\n assert candidate(sentence1 = \"The quick brown fox\",sentence2 = \"The quick brown lazy dog\") == False\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One two two three\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is a longer test sentence\") == False\n assert candidate(sentence1 = \"Insert this sentence\",sentence2 = \"Insert some words this sentence\") == True\n assert candidate(sentence1 = \"An apple a day keeps the doctor away\",sentence2 = \"An apple a day\") == True\n assert candidate(sentence1 = \"Learning new things every day\",sentence2 = \"Learning new things every single day\") == True\n assert candidate(sentence1 = \"Match end\",sentence2 = \"Middle match end\") == False\n assert candidate(sentence1 = \"Silence is golden\",sentence2 = \"Silence is golden but sometimes it's better to speak your mind\") == True\n assert candidate(sentence1 = \"Test\",sentence2 = \"Test test test\") == True\n assert candidate(sentence1 = \"A B C D E\",sentence2 = \"A B C X Y Z D E\") == True\n assert candidate(sentence1 = \"Start with this\",sentence2 = \"Start with something in the middle this\") == True\n assert candidate(sentence1 = \"Qwen is a large language model\",sentence2 = \"Qwen is a language model\") == True\n assert candidate(sentence1 = \"The cat sat on the mat\",sentence2 = \"The cat sat on the brown mat\") == True\n assert candidate(sentence1 = \"Last word\",sentence2 = \"Last last last word\") == True\n assert candidate(sentence1 = \"Python is great for data science\",sentence2 = \"Python is great\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over the lazy dog\",sentence2 = \"Quick brown fox quickly jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"It is a truth universally acknowledged\",sentence2 = \"It is a universally acknowledged\") == True\n assert candidate(sentence1 = \"Start and finish\",sentence2 = \"Start middle and finish\") == True\n assert candidate(sentence1 = \"SingleWord\",sentence2 = \"SingleWordInserted\") == False\n assert candidate(sentence1 = \"End with a sentence\",sentence2 = \"End with a sentence and more words\") == True\n assert candidate(sentence1 = \"Overlap at start\",sentence2 = \"Overlap at start and continue\") == True\n assert candidate(sentence1 = \"We hold these truths to be self evident\",sentence2 = \"We hold these self evident\") == True\n assert candidate(sentence1 = \"Once upon a time in a land far far away\",sentence2 = \"Once upon a time\") == True\n assert candidate(sentence1 = \"Java is a high level programming language\",sentence2 = \"Java is a high level programming language that is platform independent\") == True\n assert candidate(sentence1 = \"Similar beginning and end\",sentence2 = \"Similar beginning with extra words and end\") == True\n assert candidate(sentence1 = \"Hello from the other side\",sentence2 = \"Hello from the very very other side\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over lazy dog\",sentence2 = \"Quick brown fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"Silence is golden\",sentence2 = \"Silence\") == True\n assert candidate(sentence1 = \"Middle insertion is key\",sentence2 = \"Middle insertion of some text is key\") == True\n assert candidate(sentence1 = \"To be or not to be that is the question\",sentence2 = \"To be or not to be\") == True\n assert candidate(sentence1 = \"This is a simple test\",sentence2 = \"This is an extremely simple and detailed test\") == False\n assert candidate(sentence1 = \"It was the best of times it was the worst of times\",sentence2 = \"It was the best of times\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over the lazy dog\",sentence2 = \"Quick brown fox jumps over the lazy brown dog\") == True\n assert candidate(sentence1 = \"Learning new things is fun\",sentence2 = \"Learning fun\") == True\n assert candidate(sentence1 = \"Life is a journey not a destination\",sentence2 = \"Life is a journey of ups and downs not a destination\") == True\n assert candidate(sentence1 = \"She sells sea shells by the sea shore\",sentence2 = \"She sells sea\") == True\n assert candidate(sentence1 = \"In the beginning God created the heaven and the earth\",sentence2 = \"In the beginning God created the earth\") == True\n assert candidate(sentence1 = \"Insert sentence here\",sentence2 = \"Insert sentence in the middle sentence here\") == True\n assert candidate(sentence1 = \"End with this\",sentence2 = \"End with this and something more\") == True\n assert candidate(sentence1 = \"Python is fun\",sentence2 = \"Python is very very fun\") == True\n assert candidate(sentence1 = \"Advanced machine learning techniques\",sentence2 = \"Advanced machine learning deep learning techniques\") == True\n assert candidate(sentence1 = \"Hello from the other side\",sentence2 = \"Hello from the other side my old friend\") == True\n assert candidate(sentence1 = \"Single word\",sentence2 = \"Single single word\") == True\n assert candidate(sentence1 = \"Time heals all wounds\",sentence2 = \"Time heals all wounds but sometimes it's better to face them head on\") == True\n assert candidate(sentence1 = \"One two three four five\",sentence2 = \"One two six seven eight nine five\") == False\n assert candidate(sentence1 = \"Same at the start\",sentence2 = \"Same at the start but different end\") == True\n assert candidate(sentence1 = \"All animals are equal\",sentence2 = \"All animals are equal but some animals are more equal than others\") == True\n assert candidate(sentence1 = \"The rain in Spain stays mainly in the plain\",sentence2 = \"The rain in Spain stays\") == True\n assert candidate(sentence1 = \"Multiple words in between\",sentence2 = \"Multiple multiple words in between\") == True\n assert candidate(sentence1 = \"Natural language processing is fascinating\",sentence2 = \"Natural language processing\") == True\n assert candidate(sentence1 = \"Hello my friend\",sentence2 = \"Hello my dear friend\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is an amazing test\") == False\n assert candidate(sentence1 = \"Front and back\",sentence2 = \"Front middle back\") == False\n assert candidate(sentence1 = \"Complex sentences are fun\",sentence2 = \"Complex sentences with more words in between are fun\") == True\n assert candidate(sentence1 = \"Alice went to the market\",sentence2 = \"Alice went to the market to buy apples\") == True\n assert candidate(sentence1 = \"The early morning light\",sentence2 = \"The early morning light is so peaceful\") == True\n assert candidate(sentence1 = \"Same same same\",sentence2 = \"Same Same\") == False\n assert candidate(sentence1 = \"Same at the end\",sentence2 = \"Different start same at the end\") == False\n assert candidate(sentence1 = \"Beautiful day in the neighborhood\",sentence2 = \"Beautiful day in the beautiful neighborhood\") == True\n assert candidate(sentence1 = \"First second third\",sentence2 = \"First first first second third\") == True\n assert candidate(sentence1 = \"Hello from the other side\",sentence2 = \"Hello\") == True\n assert candidate(sentence1 = \"I have a dream\",sentence2 = \"I have a dream that one day this nation will rise up and live out the true meaning of its creed\") == True\n assert candidate(sentence1 = \"May the force be with you\",sentence2 = \"May the be with you\") == True\n assert candidate(sentence1 = \"OpenAI develops AI models\",sentence2 = \"OpenAI develops cutting edge AI models\") == True\n assert candidate(sentence1 = \"May the Force be with you\",sentence2 = \"May the Force be with you always\") == True\n assert candidate(sentence1 = \"Keep it simple\",sentence2 = \"Keep it simple stupid\") == True\n assert candidate(sentence1 = \"A short sentence\",sentence2 = \"A very very very short sentence\") == True\n"}, "metadata": {"canonical_parameter_names": ["sentence1", "sentence2"], "leetcode_dataset_entry_point": "Solution().areSentencesSimilar", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def areSentencesSimilar(self, sentence1: str, sentence2: str) -> bool:", "container": "Solution", "callable": "areSentencesSimilar", "parameters": [{"name": "sentence1", "type": "str"}, {"name": "sentence2", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1814, "task_id": "count-nice-pairs-in-an-array", "difficulty": "Medium", "problem_description": "You are given an array nums that consists of non-negative integers. Let us define rev(x) as the reverse of the non-negative integer x. For example, rev(123) = 321, and rev(120) = 21. A pair of indices (i, j) is nice if it satisfies all of the following conditions:\n\n0 <= i < j < nums.length\nnums[i] + rev(nums[j]) == nums[j] + rev(nums[i])\n\nReturn the number of nice pairs of indices. Since that number can be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [42,11,1,97]\nOutput: 2\nExplanation: The two pairs are:\n - (0,3) : 42 + rev(97) = 42 + 79 = 121, 97 + rev(42) = 97 + 24 = 121.\n - (1,2) : 11 + rev(1) = 11 + 1 = 12, 1 + rev(11) = 1 + 11 = 12.\n\nExample 2:\n\nInput: nums = [13,10,35,24,76]\nOutput: 4\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 45\n assert candidate(nums = [100, 200, 300, 400]) == 0\n assert candidate(nums = [123, 321, 213, 132, 231, 312]) == 2\n assert candidate(nums = [123, 321, 213, 132]) == 1\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333]) == 3\n assert candidate(nums = [987654321, 123456789, 234567890, 345678901]) == 0\n assert candidate(nums = [123, 321, 120, 21]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500]) == 0\n assert candidate(nums = [13, 10, 35, 24, 76]) == 4\n assert candidate(nums = [1, 1, 1, 1]) == 6\n assert candidate(nums = [10, 100, 1000, 10000]) == 0\n assert candidate(nums = [0, 0, 0, 0]) == 6\n assert candidate(nums = [100, 10, 1]) == 0\n assert candidate(nums = [42, 11, 1, 97]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5]) == 10\n assert candidate(nums = [100000, 100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009]) == 0\n assert candidate(nums = [1234, 2341, 3412, 4123, 5678, 6785, 7856, 8567]) == 8\n assert candidate(nums = [123, 132, 213, 231, 312, 321, 111, 222, 333, 444, 555, 666, 777, 888, 999, 101, 202, 303, 404, 505]) == 93\n assert candidate(nums = [11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111]) == 36\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 0\n assert candidate(nums = [123, 321, 213, 132, 231, 312, 123, 321]) == 4\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 0]) == 45\n assert candidate(nums = [1122, 2211, 3344, 4433, 5566, 6655, 7788, 8877]) == 12\n assert candidate(nums = [1001, 1010, 1100, 1111, 2002, 2020, 2200, 2222]) == 6\n assert candidate(nums = [564, 465, 654, 645, 546, 456]) == 2\n assert candidate(nums = [101010101, 202020202, 303030303, 404040404, 505050505, 606060606, 707070707, 808080808, 909090909]) == 36\n assert candidate(nums = [123, 456, 789, 1234, 5678, 9012, 3456, 7890, 12345, 67890]) == 7\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == 36\n assert candidate(nums = [101, 101, 101, 101, 101, 101, 101, 101, 101, 101]) == 45\n assert candidate(nums = [111111, 222222, 333333, 444444, 555555, 666666]) == 15\n assert candidate(nums = [1001, 1101, 1201, 1301, 1401, 1501, 1601, 1701, 1801, 1901]) == 0\n assert candidate(nums = [123456789, 234567890, 345678901, 456789012, 567890123, 678901234, 789012345, 890123456, 901234567, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == 40\n assert candidate(nums = [121, 131, 141, 151, 161, 171, 181, 191, 202, 212, 222, 232, 242, 252, 262, 272, 282, 292, 303, 313, 323, 333, 343, 353, 363, 373, 383, 393, 404, 414, 424, 434, 444, 454, 464, 474, 484, 494, 505, 515, 525, 535, 545, 555, 565, 575, 585, 595, 606, 616, 626, 636, 646, 656, 666, 676, 686, 696, 707, 717, 727, 737, 747, 757, 767, 777, 787, 797, 808, 818, 828, 838, 848, 858, 868, 878, 888, 898, 909, 919, 929, 939, 949, 959, 969, 979, 989, 999]) == 3828\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555]) == 10\n assert candidate(nums = [123456789, 234567890, 345678901, 456789012, 567890123, 678901234, 789012345, 890123456, 901234567, 101234567]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 45\n assert candidate(nums = [1001, 1010, 1100, 1, 10, 100]) == 1\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003, 1000000004]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 45\n assert candidate(nums = [1000000007, 7000000001, 123456789, 987654321, 1000000000]) == 0\n assert candidate(nums = [12345, 54321, 1234, 4321, 123, 321, 12, 21, 1, 0]) == 1\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == 36\n assert candidate(nums = [12345, 54321, 12345, 54321, 12345, 54321, 12345, 54321]) == 12\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == 36\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]) == 0\n assert candidate(nums = [987, 789, 897, 798, 978, 879, 987, 789, 897, 798]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 36\n assert candidate(nums = [500000000, 400000000, 300000000, 200000000, 100000000, 50000000, 40000000, 30000000, 20000000, 10000000, 5000000, 4000000, 3000000, 2000000, 1000000, 500000, 400000, 300000, 200000, 100000]) == 0\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 0]) == 45\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == 36\n assert candidate(nums = [1234, 4321, 1111, 2222, 3333, 4444, 5555]) == 10\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901]) == 22\n assert candidate(nums = [121, 1221, 12221, 122221, 1222221, 12222221, 122222221, 1222222221, 12222222221]) == 36\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999]) == 28\n assert candidate(nums = [120, 210, 102, 201, 321, 123, 312, 213, 432, 234]) == 8\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]) == 36\n assert candidate(nums = [1, 11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 45\n assert candidate(nums = [123, 321, 213, 132, 312, 231]) == 2\n assert candidate(nums = [123456789, 987654321, 12345678, 87654321, 1234567, 7654321, 123456, 654321, 12345, 54321, 1234, 4321, 123, 321, 12, 21, 1, 0]) == 1\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009, 11011, 22022, 33033, 44044, 55055, 66066, 77077, 88088, 99099, 11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999]) == 351\n assert candidate(nums = [10001, 10101, 11001, 11111, 20002, 20202, 22002, 22222]) == 15\n assert candidate(nums = [1230, 3210, 2130, 1320, 3120, 2310]) == 0\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999, 1]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 45\n assert candidate(nums = [123, 321, 213, 312, 132, 231, 456, 654, 546, 465, 789, 987, 897, 798, 101, 11, 22, 33, 44, 55, 66, 77, 88, 99]) == 64\n assert candidate(nums = [999999999, 100000000, 111111111, 222222222, 333333333, 444444444, 555555555]) == 15\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999, 123456789]) == 36\n assert candidate(nums = [1001, 1010, 1100, 100, 10, 1, 11, 111, 1111]) == 10\n assert candidate(nums = [1234, 4321, 5678, 8765, 9012, 2109, 3456, 6543]) == 6\n assert candidate(nums = [123456, 654321, 123456, 654321, 123456, 654321]) == 6\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993]) == 0\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999, 1000000000]) == 36\n assert candidate(nums = [12321, 13231, 21312, 31213, 41114, 51015, 60906, 70807, 80708, 90609]) == 45\n assert candidate(nums = [12345, 54321, 23451, 123456, 654321, 213456, 111111, 222222, 333333, 444444]) == 6\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 171\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == 36\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 153\n assert candidate(nums = [1234, 4321, 3412, 2143, 2341, 3142, 1324, 4231, 4123, 2413, 3214, 1423]) == 1\n assert candidate(nums = [1, 21, 12, 11, 22, 202, 220, 101, 110, 111, 2002, 2200, 2020, 1001, 1100, 1010, 10001, 10101, 11001]) == 45\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 0\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000]) == 0\n assert candidate(nums = [123, 321, 456, 654, 789, 987, 101, 110, 111]) == 7\n assert candidate(nums = [123, 321, 213, 132, 231, 312, 4321, 1234, 1111, 2222, 3333]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 45\n assert candidate(nums = [1001, 1010, 1100, 2002, 2020, 2200, 3003, 3030, 3300]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 435\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 0\n assert candidate(nums = [1000001, 2000002, 3000003, 4000004, 5000005, 6000006, 7000007, 8000008, 9000009]) == 36\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 36\n assert candidate(nums = [100001, 100010, 100100, 101000, 110000, 100002, 100020, 100200, 102000, 120000]) == 0\n assert candidate(nums = [123456789, 987654321, 234567890, 890123456, 345678901, 765432109, 456789012, 654321098, 567890123, 345678901]) == 3\n assert candidate(nums = [112233, 332211, 221133, 113322, 445566, 665544, 556644]) == 3\n assert candidate(nums = [1000000007, 7000000001, 1100000001, 1000000011, 1000001001]) == 0\n assert candidate(nums = [1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 0\n assert candidate(nums = [12, 21, 13, 31, 23, 32, 14, 41, 24, 42, 34, 43]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 0\n assert candidate(nums = [100001, 100101, 101001, 101101, 110001, 110101, 111001, 111101]) == 2\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995]) == 0\n assert candidate(nums = [900000000, 800000000, 700000000, 600000000, 500000000, 400000000, 300000000, 200000000, 100000000]) == 0\n assert candidate(nums = [123456789, 123456790, 123456788, 123456791, 123456787, 123456792, 123456786, 123456793, 123456785, 123456794]) == 0\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == 36\n assert candidate(nums = [1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 0\n assert candidate(nums = [123, 321, 213, 132, 312, 231, 101, 110, 10, 1]) == 5\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == 36\n assert candidate(nums = [123456789, 987654321, 234567890, 345678901, 456789012, 567890123, 678901234, 789012345, 890123456, 901234567]) == 4\n assert candidate(nums = [1122334455, 2233445566, 3344556677, 4455667788, 5566778899, 6677889900, 7788990011, 8899001122, 9900112233, 1011223344, 2122334455, 3222334455, 4322334455, 5422334455, 6522334455, 7622334455, 8722334455, 9822334455, 10922334455]) == 13\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countNicePairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countNicePairs(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countNicePairs", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1815, "task_id": "maximum-number-of-groups-getting-fresh-donuts", "difficulty": "Hard", "problem_description": "There is a donuts shop that bakes donuts in batches of batchSize. They have a rule where they must serve all of the donuts of a batch before serving any donuts of the next batch. You are given an integer batchSize and an integer array groups, where groups[i] denotes that there is a group of groups[i] customers that will visit the shop. Each customer will get exactly one donut.\nWhen a group visits the shop, all customers of the group must be served before serving any of the following groups. A group will be happy if they all get fresh donuts. That is, the first customer of the group does not receive a donut that was left over from the previous group.\nYou can freely rearrange the ordering of the groups. Return the maximum possible number of happy groups after rearranging the groups.\n \nExample 1:\n\nInput: batchSize = 3, groups = [1,2,3,4,5,6]\nOutput: 4\nExplanation: You can arrange the groups as [6,2,4,5,1,3]. Then the 1st, 2nd, 4th, and 6th groups will be happy.\n\nExample 2:\n\nInput: batchSize = 4, groups = [1,3,2,5,2,2,1,6]\nOutput: 4\n\n \nConstraints:\n\n1 <= batchSize <= 9\n1 <= groups.length <= 30\n1 <= groups[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49]) == 7\n assert candidate(batchSize = 2,groups = [2, 2, 2, 2, 2, 2]) == 6\n assert candidate(batchSize = 7,groups = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 12\n assert candidate(batchSize = 4,groups = [4, 8, 12, 16, 20]) == 5\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 5\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42]) == 6\n assert candidate(batchSize = 3,groups = [1, 2, 3, 4, 5, 6]) == 4\n assert candidate(batchSize = 4,groups = [1, 3, 2, 5, 2, 2, 1, 6]) == 4\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15]) == 5\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25]) == 5\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72]) == 9\n assert candidate(batchSize = 1,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(batchSize = 5,groups = [1, 2, 3, 4, 5]) == 3\n assert candidate(batchSize = 5,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81]) == 9\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 10\n assert candidate(batchSize = 8,groups = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 15\n assert candidate(batchSize = 5,groups = [5, 5, 5, 5, 5, 5]) == 6\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49, 56]) == 8\n assert candidate(batchSize = 9,groups = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(batchSize = 9,groups = [9, 9, 9, 9, 9, 9, 9, 9, 9]) == 9\n assert candidate(batchSize = 2,groups = [1, 2, 3, 4, 5]) == 4\n assert candidate(batchSize = 6,groups = [6, 12, 18, 24, 30, 36, 42, 48, 54]) == 9\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64]) == 8\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == 30\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 11\n assert candidate(batchSize = 8,groups = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 8\n assert candidate(batchSize = 3,groups = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000]) == 3\n assert candidate(batchSize = 7,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 11\n assert candidate(batchSize = 6,groups = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == 10\n assert candidate(batchSize = 5,groups = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 30\n assert candidate(batchSize = 4,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 19\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 10\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147]) == 21\n assert candidate(batchSize = 8,groups = [4, 7, 9, 12, 14, 15, 18, 20, 22, 23, 25, 26, 27, 29, 31, 32]) == 8\n assert candidate(batchSize = 2,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(batchSize = 5,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(batchSize = 7,groups = [14, 28, 42, 56, 70, 84, 98, 112, 126, 140, 154, 168, 182]) == 13\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126]) == 14\n assert candidate(batchSize = 6,groups = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336, 348, 360]) == 30\n assert candidate(batchSize = 5,groups = [8, 9, 10, 11, 12, 13, 14, 15]) == 5\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40]) == 8\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225, 234, 243, 252, 261, 270]) == 30\n assert candidate(batchSize = 5,groups = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 6\n assert candidate(batchSize = 6,groups = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90]) == 15\n assert candidate(batchSize = 4,groups = [5, 8, 10, 11, 13, 16, 17, 19, 21, 22, 25, 28, 30]) == 8\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80]) == 10\n assert candidate(batchSize = 2,groups = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 21\n assert candidate(batchSize = 5,groups = [2, 3, 7, 8, 10, 12, 15, 17]) == 5\n assert candidate(batchSize = 3,groups = [9, 15, 2, 7, 8, 11, 13, 4, 1]) == 6\n assert candidate(batchSize = 4,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 13\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 20\n assert candidate(batchSize = 6,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 7\n assert candidate(batchSize = 5,groups = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165]) == 9\n assert candidate(batchSize = 8,groups = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 3\n assert candidate(batchSize = 9,groups = [1, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112]) == 8\n assert candidate(batchSize = 5,groups = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 6\n assert candidate(batchSize = 5,groups = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 10\n assert candidate(batchSize = 7,groups = [1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92]) == 2\n assert candidate(batchSize = 9,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 20\n assert candidate(batchSize = 5,groups = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 6\n assert candidate(batchSize = 5,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 30\n assert candidate(batchSize = 3,groups = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40]) == 5\n assert candidate(batchSize = 7,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(batchSize = 4,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 8\n assert candidate(batchSize = 8,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119]) == 10\n assert candidate(batchSize = 6,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(batchSize = 4,groups = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 6\n assert candidate(batchSize = 5,groups = [2, 4, 6, 8, 10, 12, 14, 16]) == 5\n assert candidate(batchSize = 9,groups = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 6\n assert candidate(batchSize = 9,groups = [8, 7, 6, 5, 4, 3, 2, 1, 9, 18, 27, 36, 45, 54, 63, 72, 81]) == 13\n assert candidate(batchSize = 4,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9\n assert candidate(batchSize = 4,groups = [13, 19, 22, 29, 31, 37, 41, 43, 47, 53, 59]) == 6\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 8\n assert candidate(batchSize = 3,groups = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 14\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104]) == 13\n assert candidate(batchSize = 8,groups = [15, 22, 33, 44, 55, 66, 77, 88, 99]) == 5\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96]) == 12\n assert candidate(batchSize = 6,groups = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 30\n assert candidate(batchSize = 4,groups = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == 10\n assert candidate(batchSize = 6,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65]) == 8\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120]) == 15\n assert candidate(batchSize = 5,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 9\n assert candidate(batchSize = 6,groups = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72]) == 12\n assert candidate(batchSize = 9,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 7\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 182, 189, 196, 203, 210]) == 30\n assert candidate(batchSize = 9,groups = [81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93]) == 7\n assert candidate(batchSize = 5,groups = [2, 3, 4, 1, 5, 6, 7, 8, 9]) == 5\n assert candidate(batchSize = 8,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(batchSize = 3,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(batchSize = 9,groups = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 8\n assert candidate(batchSize = 5,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9\n assert candidate(batchSize = 6,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 18\n assert candidate(batchSize = 8,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112]) == 9\n assert candidate(batchSize = 6,groups = [12, 24, 36, 48, 60, 72, 84, 96, 108]) == 9\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39]) == 13\n assert candidate(batchSize = 7,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75]) == 14\n assert candidate(batchSize = 9,groups = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91]) == 2\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240]) == 30\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 5\n assert candidate(batchSize = 6,groups = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51]) == 7\n assert candidate(batchSize = 6,groups = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]) == 6\n assert candidate(batchSize = 3,groups = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 7\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 30\n assert candidate(batchSize = 4,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 10\n assert candidate(batchSize = 3,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 16\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85]) == 17\n assert candidate(batchSize = 6,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 7\n assert candidate(batchSize = 7,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9\n assert candidate(batchSize = 7,groups = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4]) == 10\n assert candidate(batchSize = 3,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 20\n assert candidate(batchSize = 7,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 9\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 15\n assert candidate(batchSize = 3,groups = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 8\n assert candidate(batchSize = 4,groups = [9, 13, 17, 21, 25, 29, 33, 37, 41, 45]) == 3\n assert candidate(batchSize = 4,groups = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 8\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112]) == 16\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180]) == 20\n assert candidate(batchSize = 9,groups = [8, 17, 26, 35, 44, 53, 62, 71, 80, 89, 98, 107, 116, 125, 134, 143, 152]) == 2\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 11\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 20\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]) == 12\n assert candidate(batchSize = 5,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n"}, "metadata": {"canonical_parameter_names": ["batchSize", "groups"], "leetcode_dataset_entry_point": "Solution().maxHappyGroups", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxHappyGroups(self, batchSize: int, groups: list[int]) -> int:", "container": "Solution", "callable": "maxHappyGroups", "parameters": [{"name": "batchSize", "type": "int"}, {"name": "groups", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1816, "task_id": "truncate-sentence", "difficulty": "Easy", "problem_description": "A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of only uppercase and lowercase English letters (no punctuation).\n\nFor example, \"Hello World\", \"HELLO\", and \"hello world hello world\" are all sentences.\n\nYou are given a sentence s​​​​​​ and an integer k​​​​​​. You want to truncate s​​​​​​ such that it contains only the first k​​​​​​ words. Return s​​​​​​ after truncating it.\n \nExample 1:\n\nInput: s = \"Hello how are you Contestant\", k = 4\nOutput: \"Hello how are you\"\nExplanation:\nThe words in s are [\"Hello\", \"how\" \"are\", \"you\", \"Contestant\"].\nThe first 4 words are [\"Hello\", \"how\", \"are\", \"you\"].\nHence, you should return \"Hello how are you\".\n\nExample 2:\n\nInput: s = \"What is the solution to this problem\", k = 4\nOutput: \"What is the solution\"\nExplanation:\nThe words in s are [\"What\", \"is\" \"the\", \"solution\", \"to\", \"this\", \"problem\"].\nThe first 4 words are [\"What\", \"is\", \"the\", \"solution\"].\nHence, you should return \"What is the solution\".\nExample 3:\n\nInput: s = \"chopper is not a tanuki\", k = 5\nOutput: \"chopper is not a tanuki\"\n\n \nConstraints:\n\n1 <= s.length <= 500\nk is in the range [1, the number of words in s].\ns consist of only lowercase and uppercase English letters and spaces.\nThe words in s are separated by a single space.\nThere are no leading or trailing spaces.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"I love to code\",k = 3) == \"I love to\"\n assert candidate(s = \"Python is great\",k = 2) == \"Python is\"\n assert candidate(s = \"Python programming is fun\",k = 2) == \"Python programming\"\n assert candidate(s = \"A quick brown fox jumps over the lazy dog\",k = 3) == \"A quick brown\"\n assert candidate(s = \"I love programming in Python\",k = 3) == \"I love programming\"\n assert candidate(s = \"Hello how are you Contestant\",k = 4) == \"Hello how are you\"\n assert candidate(s = \"Python is a great programming language\",k = 2) == \"Python is\"\n assert candidate(s = \"chopper is not a tanuki\",k = 5) == \"chopper is not a tanuki\"\n assert candidate(s = \"Python is fun\",k = 2) == \"Python is\"\n assert candidate(s = \"I love programming\",k = 1) == \"I\"\n assert candidate(s = \"What is the solution to this problem\",k = 4) == \"What is the solution\"\n assert candidate(s = \"I love solving problems\",k = 3) == \"I love solving\"\n assert candidate(s = \"It does not matter how slowly you go as long as you do not stop\",k = 9) == \"It does not matter how slowly you go as\"\n assert candidate(s = \"The road to success is always under construction\",k = 7) == \"The road to success is always under\"\n assert candidate(s = \"The best way to predict your future is to create it\",k = 8) == \"The best way to predict your future is\"\n assert candidate(s = \"This is a test sentence to check the functionality of the code\",k = 9) == \"This is a test sentence to check the functionality\"\n assert candidate(s = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",k = 5) == \"a b c d e\"\n assert candidate(s = \"In computer science, the art of programming is the science of abstraction\",k = 8) == \"In computer science, the art of programming is\"\n assert candidate(s = \"A journey of a thousand miles begins with a single step\",k = 8) == \"A journey of a thousand miles begins with\"\n assert candidate(s = \"Believe you can and you're halfway there\",k = 5) == \"Believe you can and you're\"\n assert candidate(s = \"Keep it simple stupid\",k = 5) == \"Keep it simple stupid\"\n assert candidate(s = \"To be or not to be that is the question\",k = 10) == \"To be or not to be that is the question\"\n assert candidate(s = \"May the Force be with you young Jedi\",k = 6) == \"May the Force be with you\"\n assert candidate(s = \"Short sentence\",k = 2) == \"Short sentence\"\n assert candidate(s = \"The only way to do great work is to love what you do\",k = 7) == \"The only way to do great work\"\n assert candidate(s = \"Honesty is the best policy\",k = 4) == \"Honesty is the best\"\n assert candidate(s = \"In the middle of difficulty lies opportunity\",k = 4) == \"In the middle of\"\n assert candidate(s = \"Natural language processing has become a cornerstone of modern technology\",k = 9) == \"Natural language processing has become a cornerstone of modern\"\n assert candidate(s = \"One two three four five six seven eight nine ten\",k = 10) == \"One two three four five six seven eight nine ten\"\n assert candidate(s = \"You miss 100 percent of the shots you don t take Wayne Gretzky\",k = 11) == \"You miss 100 percent of the shots you don t take\"\n assert candidate(s = \"OpenAI GPT-4 can generate human-like text based on the input it receives\",k = 7) == \"OpenAI GPT-4 can generate human-like text based\"\n assert candidate(s = \"One two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen\",k = 10) == \"One two three four five six seven eight nine ten\"\n assert candidate(s = \"What you get by achieving your goals is not as important as what you become by achieving your goals\",k = 12) == \"What you get by achieving your goals is not as important as\"\n assert candidate(s = \"Debugging is twice as hard as writing the code in the first place\",k = 7) == \"Debugging is twice as hard as writing\"\n assert candidate(s = \"Python programming is fun and challenging\",k = 10) == \"Python programming is fun and challenging\"\n assert candidate(s = \"A journey of a thousand miles begins with a single step\",k = 7) == \"A journey of a thousand miles begins\"\n assert candidate(s = \"Success is not final success is to be able to continue to try\",k = 8) == \"Success is not final success is to be\"\n assert candidate(s = \"OneWordOnly\",k = 1) == \"OneWordOnly\"\n assert candidate(s = \"Data Science and Machine Learning\",k = 3) == \"Data Science and\"\n assert candidate(s = \"Life is what happens when you are busy making other plans\",k = 7) == \"Life is what happens when you are\"\n assert candidate(s = \"The early morning sun is warm and welcoming\",k = 7) == \"The early morning sun is warm and\"\n assert candidate(s = \"To be or not to be that is the question\",k = 7) == \"To be or not to be that\"\n assert candidate(s = \"Short but tricky\",k = 2) == \"Short but\"\n assert candidate(s = \"The early bird catches the worm\",k = 5) == \"The early bird catches the\"\n assert candidate(s = \"Final complex sentence with multiple words indeed\",k = 7) == \"Final complex sentence with multiple words indeed\"\n assert candidate(s = \"The best way to predict the future is to invent it\",k = 9) == \"The best way to predict the future is to\"\n assert candidate(s = \"VeryLongWordWithoutSpacesIsAlsoAcceptedButNotTypicalInSentences\",k = 1) == \"VeryLongWordWithoutSpacesIsAlsoAcceptedButNotTypicalInSentences\"\n assert candidate(s = \"Do not judge a book by its cover\",k = 7) == \"Do not judge a book by its\"\n assert candidate(s = \"All that glitters is not gold only the good do well by gold\",k = 9) == \"All that glitters is not gold only the good\"\n assert candidate(s = \"All that glitters is not gold\",k = 5) == \"All that glitters is not\"\n assert candidate(s = \"To be or not to be that is the question\",k = 5) == \"To be or not to\"\n assert candidate(s = \"Edge case with k equal to the number of words here\",k = 9) == \"Edge case with k equal to the number of\"\n assert candidate(s = \"Multiple words with mixed CASE Words\",k = 4) == \"Multiple words with mixed\"\n assert candidate(s = \"Programming in Python is both fun and educational\",k = 6) == \"Programming in Python is both fun\"\n assert candidate(s = \"A journey of a thousand miles begins with a single step\",k = 6) == \"A journey of a thousand miles\"\n assert candidate(s = \"Success is not final success is courage to continue\",k = 7) == \"Success is not final success is courage\"\n assert candidate(s = \"In the beginning God created the heavens and the earth\",k = 6) == \"In the beginning God created the\"\n assert candidate(s = \"Programming in Python is very rewarding\",k = 5) == \"Programming in Python is very\"\n assert candidate(s = \"You can lead a horse to water but you cannot make it drink\",k = 11) == \"You can lead a horse to water but you cannot make\"\n assert candidate(s = \"Another example with different words\",k = 3) == \"Another example with\"\n assert candidate(s = \"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\",k = 10) == \"A B C D E F G H I J\"\n assert candidate(s = \"The quick brown fox jumps over the lazy dog\",k = 9) == \"The quick brown fox jumps over the lazy dog\"\n assert candidate(s = \"MixedCASE Words In Sentences Should Be Handled\",k = 5) == \"MixedCASE Words In Sentences Should\"\n assert candidate(s = \"Well done is better than well said\",k = 5) == \"Well done is better than\"\n assert candidate(s = \"The quick brown fox jumps over the lazy dog\",k = 7) == \"The quick brown fox jumps over the\"\n assert candidate(s = \"Yet another test to ensure correctness\",k = 5) == \"Yet another test to ensure\"\n assert candidate(s = \"Edge case test with exact words count\",k = 6) == \"Edge case test with exact words\"\n assert candidate(s = \"SingleWord\",k = 1) == \"SingleWord\"\n assert candidate(s = \"Hello World from the other side of the universe\",k = 8) == \"Hello World from the other side of the\"\n assert candidate(s = \"In the middle of every difficulty lies opportunity\",k = 8) == \"In the middle of every difficulty lies opportunity\"\n assert candidate(s = \"One two three four five six seven eight nine ten\",k = 5) == \"One two three four five\"\n assert candidate(s = \"With great power comes great responsibility\",k = 5) == \"With great power comes great\"\n assert candidate(s = \"Multiple Spaces Between Words Are Not Allowed\",k = 5) == \"Multiple Spaces Between Words Are\"\n assert candidate(s = \"Multiple spaces should not be here but for testing purposes we will add them\",k = 10) == \"Multiple spaces should not be here but for testing purposes\"\n assert candidate(s = \"An apple a day keeps the doctor away\",k = 8) == \"An apple a day keeps the doctor away\"\n assert candidate(s = \"Sometimes the journey is more important than the destination\",k = 9) == \"Sometimes the journey is more important than the destination\"\n assert candidate(s = \"Sometimes you just want to have a long sentence to test the truncation functionality of the code\",k = 15) == \"Sometimes you just want to have a long sentence to test the truncation functionality of\"\n assert candidate(s = \"A quick brown fox jumps over the lazy dog\",k = 9) == \"A quick brown fox jumps over the lazy dog\"\n assert candidate(s = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",k = 26) == \"a b c d e f g h i j k l m n o p q r s t u v w x y z\"\n assert candidate(s = \"This is a very long sentence that we need to truncate to the first few words\",k = 7) == \"This is a very long sentence that\"\n assert candidate(s = \"May the force be with you\",k = 5) == \"May the force be with\"\n assert candidate(s = \"In the heart of the night the fireflies dance\",k = 8) == \"In the heart of the night the fireflies\"\n assert candidate(s = \"ManyManyWordsInOneSentenceWithoutSpacesButAllowedByConstraintsIfWeRemoveSpacesThenThisWillBeAVeryLongListofWords\",k = 5) == \"ManyManyWordsInOneSentenceWithoutSpacesButAllowedByConstraintsIfWeRemoveSpacesThenThisWillBeAVeryLongListofWords\"\n assert candidate(s = \"To be or not to be that is the question\",k = 6) == \"To be or not to be\"\n assert candidate(s = \"Better late than never\",k = 4) == \"Better late than never\"\n assert candidate(s = \"Actions speak louder than words\",k = 4) == \"Actions speak louder than\"\n assert candidate(s = \"Keep calm and carry on\",k = 3) == \"Keep calm and\"\n assert candidate(s = \"Lorem ipsum dolor sit amet consectetur adipiscing elit\",k = 7) == \"Lorem ipsum dolor sit amet consectetur adipiscing\"\n assert candidate(s = \"This is a longer sentence to test the functionality\",k = 7) == \"This is a longer sentence to test\"\n assert candidate(s = \"Software design is all about managing complexity\",k = 7) == \"Software design is all about managing complexity\"\n assert candidate(s = \"May the Force be with you\",k = 3) == \"May the Force\"\n assert candidate(s = \"Data structures and algorithms are the building blocks of software development\",k = 8) == \"Data structures and algorithms are the building blocks\"\n assert candidate(s = \"An algorithm must be seen to be believed\",k = 5) == \"An algorithm must be seen\"\n assert candidate(s = \"This is a test for truncating the sentence at exactly the word limit\",k = 10) == \"This is a test for truncating the sentence at exactly\"\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().truncateSentence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def truncateSentence(self, s: str, k: int) -> str:", "container": "Solution", "callable": "truncateSentence", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1817, "task_id": "finding-the-users-active-minutes", "difficulty": "Medium", "problem_description": "You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented by a 2D integer array logs where each logs[i] = [IDi, timei] indicates that the user with IDi performed an action at the minute timei.\nMultiple users can perform actions simultaneously, and a single user can perform multiple actions in the same minute.\nThe user active minutes (UAM) for a given user is defined as the number of unique minutes in which the user performed an action on LeetCode. A minute can only be counted once, even if multiple actions occur during it.\nYou are to calculate a 1-indexed array answer of size k such that, for each j (1 <= j <= k), answer[j] is the number of users whose UAM equals j.\nReturn the array answer as described above.\n \nExample 1:\n\nInput: logs = [[0,5],[1,2],[0,2],[0,5],[1,3]], k = 5\nOutput: [0,2,0,0,0]\nExplanation:\nThe user with ID=0 performed actions at minutes 5, 2, and 5 again. Hence, they have a UAM of 2 (minute 5 is only counted once).\nThe user with ID=1 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.\nSince both users have a UAM of 2, answer[2] is 2, and the remaining answer[j] values are 0.\n\nExample 2:\n\nInput: logs = [[1,1],[2,2],[2,3]], k = 4\nOutput: [1,1,0,0]\nExplanation:\nThe user with ID=1 performed a single action at minute 1. Hence, they have a UAM of 1.\nThe user with ID=2 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.\nThere is one user with a UAM of 1 and one with a UAM of 2.\nHence, answer[1] = 1, answer[2] = 1, and the remaining values are 0.\n\n \nConstraints:\n\n1 <= logs.length <= 104\n0 <= IDi <= 109\n1 <= timei <= 105\nk is in the range [The maximum UAM for a user, 105].\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],k = 3) == [0, 0, 3]\n assert candidate(logs = [[10, 1], [11, 2], [10, 2], [11, 3], [10, 3], [11, 4]],k = 4) == [0, 0, 2, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],k = 5) == [0, 0, 0, 0, 1]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3]],k = 3) == [0, 0, 2]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1]],k = 1) == [4]\n assert candidate(logs = [[1, 1], [2, 2], [2, 3]],k = 4) == [1, 1, 0, 0]\n assert candidate(logs = [[10, 10], [10, 10], [10, 11], [11, 12]],k = 3) == [1, 1, 0]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 5) == [5, 0, 0, 0, 0]\n assert candidate(logs = [[0, 10], [0, 10], [1, 10], [1, 11], [1, 12]],k = 3) == [1, 0, 1]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4]],k = 4) == [4, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],k = 5) == [5, 0, 0, 0, 0]\n assert candidate(logs = [[0, 5], [1, 2], [0, 2], [0, 5], [1, 3]],k = 5) == [0, 2, 0, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],k = 1) == [1]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1]],k = 1) == [5]\n assert candidate(logs = [[10, 10], [10, 10], [10, 11], [10, 12], [11, 10], [11, 11]],k = 3) == [0, 1, 1]\n assert candidate(logs = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10], [110, 10], [120, 10], [130, 10], [140, 10], [150, 10]],k = 1) == [15]\n assert candidate(logs = [[100, 1], [101, 1], [102, 2], [103, 2], [104, 3], [105, 3], [106, 4], [107, 4], [108, 5], [109, 5]],k = 5) == [10, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [0, 16], [1, 17], [2, 18], [3, 19], [4, 20]],k = 15) == [10, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15]],k = 5) == [5, 5, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],k = 5) == [5, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],k = 3) == [0, 0, 4]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],k = 5) == [0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 10) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [5, 1], [5, 2], [5, 3]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]],k = 2) == [0, 5]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [0, 4], [1, 5], [2, 6], [0, 7], [1, 8], [2, 9], [0, 10], [1, 11], [2, 12], [0, 13], [1, 14], [2, 15]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[5, 1], [5, 1], [5, 1], [5, 1], [5, 1], [6, 2], [6, 2], [6, 2], [6, 3], [6, 4], [6, 5], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4]],k = 5) == [3, 0, 0, 1, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]],k = 5) == [0, 0, 1, 1, 1]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 1, 1]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]],k = 15) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[100, 1], [101, 1], [102, 2], [103, 2], [104, 2], [105, 3], [106, 3], [107, 3], [108, 4], [109, 4]],k = 4) == [10, 0, 0, 0]\n assert candidate(logs = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15]],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(logs = [[0, 10], [1, 20], [0, 10], [1, 25], [2, 30], [3, 35], [4, 40], [5, 45], [6, 50], [7, 55], [8, 60], [9, 65]],k = 10) == [9, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 3], [12, 3], [13, 3], [14, 3], [15, 3]],k = 3) == [15, 0, 0]\n assert candidate(logs = [[9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [9, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 2]\n assert candidate(logs = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [0, 1100], [1, 1200], [2, 1300], [3, 1400], [4, 1500], [5, 1600], [6, 1700], [7, 1800], [8, 1900], [9, 2000]],k = 10) == [0, 10, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[10, 5], [10, 5], [10, 6], [10, 7], [11, 5], [11, 6], [11, 7], [12, 5], [12, 6], [12, 7], [13, 5], [13, 6], [13, 7]],k = 3) == [0, 0, 4]\n assert candidate(logs = [[0, 10], [1, 10], [2, 10], [0, 11], [1, 11], [2, 11], [0, 12], [1, 12], [2, 12]],k = 3) == [0, 0, 3]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]],k = 1) == [10]\n assert candidate(logs = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [101, 1], [101, 2], [101, 3], [101, 4], [101, 5], [102, 1], [102, 2], [102, 3], [102, 4], [102, 5], [103, 1], [103, 2], [103, 3], [103, 4], [103, 5]],k = 5) == [0, 0, 0, 0, 4]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 11], [1, 12], [2, 13], [3, 14], [4, 15], [5, 16], [6, 17], [7, 18], [8, 19], [9, 20]],k = 10) == [0, 10, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 5], [0, 5], [0, 5], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 1], [2, 1], [2, 2]],k = 5) == [1, 1, 0, 1, 0]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8]],k = 5) == [0, 0, 0, 5, 0]\n assert candidate(logs = [[99, 99], [99, 100], [99, 101], [99, 102], [99, 103], [99, 104], [99, 105]],k = 7) == [0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11], [120, 12], [130, 13], [140, 14], [150, 15]],k = 15) == [15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(logs = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [0, 3], [1, 3], [2, 3], [3, 3], [4, 3]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15]],k = 15) == [0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[10, 100], [11, 101], [10, 101], [11, 102], [12, 102], [13, 103], [13, 104], [14, 104], [14, 105], [15, 106], [15, 106], [15, 107]],k = 5) == [1, 5, 0, 0, 0]\n assert candidate(logs = [[0, 10], [0, 10], [0, 11], [1, 12], [1, 12], [1, 13], [2, 14], [2, 15], [2, 15], [2, 16]],k = 4) == [0, 2, 1, 0]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],k = 2) == [0, 11]\n assert candidate(logs = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1]],k = 1) == [1]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],k = 20) == [20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [0, 2], [1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2]],k = 2) == [0, 6]\n assert candidate(logs = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5], [11, 5], [12, 5], [13, 5], [14, 5]],k = 1) == [15]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 11]],k = 11) == [9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [0, 3], [1, 3], [2, 3], [3, 3], [4, 3], [0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [0, 6], [1, 6], [2, 6], [3, 6], [4, 6]],k = 6) == [0, 0, 0, 0, 0, 5]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2], [0, 3], [1, 3], [2, 3], [0, 4], [1, 4], [2, 4], [0, 5], [1, 5], [2, 5], [0, 6], [1, 6], [2, 6]],k = 6) == [0, 0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 1, 1, 1]\n assert candidate(logs = [[10, 1], [10, 2], [10, 3], [20, 1], [20, 2], [30, 1], [30, 2], [30, 3], [40, 1], [40, 2], [40, 3], [50, 1], [50, 2], [50, 3], [60, 1], [60, 2]],k = 3) == [0, 2, 4]\n assert candidate(logs = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [1, 12], [2, 12], [3, 12], [4, 12], [5, 12]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[0, 1], [0, 2], [0, 1], [0, 2], [0, 1], [0, 2], [0, 1], [0, 2], [0, 1], [0, 2], [0, 3], [0, 4]],k = 5) == [0, 0, 0, 1, 0]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 2) == [5, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [5, 1], [5, 2], [5, 3], [6, 1], [6, 2], [6, 3]],k = 3) == [0, 0, 7]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(logs = [[1, 1], [2, 2], [2, 2], [2, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],k = 4) == [4, 1, 0, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4]],k = 4) == [0, 0, 0, 4]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],k = 1) == [15]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20]],k = 20) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]],k = 1) == [1]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [5, 6], [5, 7], [5, 8], [6, 9]],k = 5) == [4, 1, 1, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],k = 1) == [5]\n assert candidate(logs = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5]],k = 1) == [10]\n assert candidate(logs = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16]],k = 6) == [0, 2, 1, 1, 1, 0]\n assert candidate(logs = [[10, 10], [10, 10], [20, 20], [20, 21], [20, 22], [30, 30], [30, 30], [30, 31]],k = 3) == [1, 1, 1]\n assert candidate(logs = [[0, 1], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6]],k = 6) == [1, 0, 1, 1, 1, 1]\n assert candidate(logs = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2], [6, 1], [6, 2], [7, 1], [7, 2], [8, 1], [8, 2], [9, 1], [9, 2], [10, 1], [10, 2]],k = 2) == [0, 10]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8]],k = 8) == [0, 0, 0, 0, 1, 0, 1, 1]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [1, 16]],k = 6) == [0, 0, 4, 1, 0, 0]\n assert candidate(logs = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [10, 11], [20, 12], [30, 13], [40, 14], [50, 15], [60, 16], [70, 17], [80, 18], [90, 19], [100, 20]],k = 10) == [0, 10, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[0, 1], [0, 1], [0, 1], [0, 2], [0, 2], [0, 2], [0, 3], [0, 3], [0, 3], [0, 4], [0, 4], [0, 4], [0, 5], [0, 5], [0, 5]],k = 5) == [0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [0, 11], [1, 12], [2, 13], [3, 14], [4, 15]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],k = 15) == [15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [4, 18], [4, 19], [4, 20]],k = 7) == [1, 0, 2, 0, 0, 1, 1]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]],k = 5) == [0, 0, 1, 1, 1]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [0, 11], [1, 12], [2, 13], [3, 14], [4, 15]],k = 5) == [0, 0, 5, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 2], [2, 1], [2, 1], [2, 2], [2, 3], [3, 1], [3, 1], [3, 2], [3, 3], [3, 4]],k = 4) == [0, 1, 1, 1]\n assert candidate(logs = [[0, 1], [0, 1], [1, 1], [1, 1], [2, 1], [2, 1], [3, 1], [3, 1], [4, 1], [4, 1]],k = 1) == [5]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[10, 10], [20, 10], [10, 20], [20, 20], [10, 30], [20, 40], [30, 50]],k = 5) == [1, 0, 2, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 2], [4, 1], [4, 2], [4, 3], [4, 4]],k = 4) == [1, 1, 1, 1]\n assert candidate(logs = [[100, 1], [101, 2], [102, 3], [103, 4], [104, 5], [105, 6], [106, 7], [107, 8], [108, 9], [109, 10]],k = 10) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],k = 3) == [0, 1, 3]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1]],k = 1) == [20]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20]],k = 20) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],k = 1) == [11]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3], [1, 4], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [1, 6], [2, 6], [3, 6], [1, 7], [2, 7], [3, 7]],k = 7) == [0, 0, 0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 0, 0, 3]\n"}, "metadata": {"canonical_parameter_names": ["logs", "k"], "leetcode_dataset_entry_point": "Solution().findingUsersActiveMinutes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findingUsersActiveMinutes(self, logs: list[list[int]], k: int) -> list[int]:", "container": "Solution", "callable": "findingUsersActiveMinutes", "parameters": [{"name": "logs", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1818, "task_id": "minimum-absolute-sum-difference", "difficulty": "Medium", "problem_description": "You are given two positive integer arrays nums1 and nums2, both of length n.\nThe absolute sum difference of arrays nums1 and nums2 is defined as the sum of |nums1[i] - nums2[i]| for each 0 <= i < n (0-indexed).\nYou can replace at most one element of nums1 with any other element in nums1 to minimize the absolute sum difference.\nReturn the minimum absolute sum difference after replacing at most one element in the array nums1. Since the answer may be large, return it modulo 109 + 7.\n|x| is defined as:\n\nx if x >= 0, or\n-x if x < 0.\n\n \nExample 1:\n\nInput: nums1 = [1,7,5], nums2 = [2,3,5]\nOutput: 3\nExplanation: There are two possible optimal solutions:\n- Replace the second element with the first: [1,7,5] => [1,1,5], or\n- Replace the second element with the third: [1,7,5] => [1,5,5].\nBoth will yield an absolute sum difference of |1-2| + (|1-3| or |5-3|) + |5-5| = 3.\n\nExample 2:\n\nInput: nums1 = [2,4,6,8,10], nums2 = [2,4,6,8,10]\nOutput: 0\nExplanation: nums1 is equal to nums2 so no replacement is needed. This will result in an \nabsolute sum difference of 0.\n\nExample 3:\n\nInput: nums1 = [1,10,4,4,2,7], nums2 = [9,3,5,1,7,4]\nOutput: 20\nExplanation: Replace the first element with the second: [1,10,4,4,2,7] => [10,10,4,4,2,7].\nThis yields an absolute sum difference of |10-9| + |10-3| + |4-5| + |4-1| + |2-7| + |7-4| = 20\n\n \nConstraints:\n\nn == nums1.length\nn == nums2.length\n1 <= n <= 105\n1 <= nums1[i], nums2[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [1, 1, 1]) == 299997\n assert candidate(nums1 = [1, 7, 5],nums2 = [2, 3, 5]) == 3\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1]) == 16\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [1, 1, 1]) == 299997\n assert candidate(nums1 = [1, 10, 4, 4, 2, 7],nums2 = [9, 3, 5, 1, 7, 4]) == 20\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [2, 4, 6, 8, 10]) == 0\n assert candidate(nums1 = [1, 2, 3],nums2 = [6, 5, 4]) == 7\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 8\n assert candidate(nums1 = [100000, 1, 100000],nums2 = [1, 100000, 1]) == 199998\n assert candidate(nums1 = [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000],nums2 = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == 899991\n assert candidate(nums1 = [100000, 99999, 99998, 99997],nums2 = [1, 2, 3, 4]) == 399981\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1]) == 15\n assert candidate(nums1 = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 999881\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 999945\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 90\n assert candidate(nums1 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 945\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums1 = [100000, 99999, 99998, 99997, 99996],nums2 = [1, 2, 3, 4, 5]) == 499971\n assert candidate(nums1 = [100000, 100000, 100000, 100000],nums2 = [1, 100000, 100000, 1]) == 199998\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 41\n assert candidate(nums1 = [50000, 50000, 50000, 50000, 50000],nums2 = [1, 2, 3, 4, 5]) == 249985\n assert candidate(nums1 = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996],nums2 = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == 899951\n assert candidate(nums1 = [100000, 1, 50000, 75000],nums2 = [50000, 99999, 1, 100000]) == 125000\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums1 = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],nums2 = [90, 80, 70, 60, 50, 40, 30, 20, 10, 1]) == 409\n assert candidate(nums1 = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996],nums2 = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == 899951\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [45, 40, 35, 30, 25, 20, 15, 10, 5, 1]) == 204\n assert candidate(nums1 = [50000, 50000, 50000, 50000, 50000],nums2 = [1, 1, 1, 1, 1]) == 249995\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 10\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [1, 3, 6, 8, 11, 13, 16, 18, 21, 23]) == 130\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 98\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999]) == 999980\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 499936\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5]) == 95\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 36\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 16\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [90000, 90000, 90000]) == 30000\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 210\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == 500\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 41\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 50\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 32\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 41\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 181\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 82\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 25\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 8\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000],nums2 = [100000, 10000, 1000, 100, 10, 1]) == 121779\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 486\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 410\n assert candidate(nums1 = [100, 100, 100, 100, 100],nums2 = [10, 90, 110, 10, 90]) == 210\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 999990\n assert candidate(nums1 = [100000, 100000, 100000, 100000],nums2 = [1, 1, 1, 1]) == 399996\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 50\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 67\n assert candidate(nums1 = [1, 10, 100, 1000, 10000],nums2 = [2, 11, 101, 1001, 10001]) == 5\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 405\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 549990\n assert candidate(nums1 = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 999891\n assert candidate(nums1 = [100000, 200000, 300000, 400000, 500000],nums2 = [1, 2, 3, 4, 5]) == 1099985\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 20\n assert candidate(nums1 = [99999, 99998, 99997, 99996, 99995],nums2 = [1, 100, 200, 300, 400]) == 498980\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 9\n assert candidate(nums1 = [50000, 40000, 30000, 20000, 10000],nums2 = [1, 2, 3, 4, 5]) == 109985\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 171\n assert candidate(nums1 = [100000, 90000, 80000, 70000, 60000],nums2 = [50000, 40000, 30000, 20000, 10000]) == 210000\n assert candidate(nums1 = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 99943\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [101, 201, 301, 401, 501]) == 5\n assert candidate(nums1 = [5, 25, 45, 65, 85],nums2 = [10, 30, 50, 70, 90]) == 25\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 82\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 891\n assert candidate(nums1 = [100000, 100000, 100000, 100000, 100000],nums2 = [1, 1, 1, 1, 1]) == 499995\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 540\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55]) == 25\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 999882\n assert candidate(nums1 = [100000, 50000, 25000, 12500, 6250],nums2 = [99999, 49999, 24999, 12499, 6249]) == 5\n assert candidate(nums1 = [1, 100000, 200000, 300000],nums2 = [50000, 250000, 150000, 350000]) == 199999\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 55\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minAbsoluteSumDiff", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minAbsoluteSumDiff(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "minAbsoluteSumDiff", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1819, "task_id": "number-of-different-subsequences-gcds", "difficulty": "Hard", "problem_description": "You are given an array nums that consists of positive integers.\nThe GCD of a sequence of numbers is defined as the greatest integer that divides all the numbers in the sequence evenly.\n\nFor example, the GCD of the sequence [4,6,16] is 2.\n\nA subsequence of an array is a sequence that can be formed by removing some elements (possibly none) of the array.\n\nFor example, [2,5,10] is a subsequence of [1,2,1,2,4,1,5,10].\n\nReturn the number of different GCDs among all non-empty subsequences of nums.\n \nExample 1:\n\n\nInput: nums = [6,10,3]\nOutput: 5\nExplanation: The figure shows all the non-empty subsequences and their GCDs.\nThe different GCDs are 6, 10, 3, 2, and 1.\n\nExample 2:\n\nInput: nums = [5,15,40,5,6]\nOutput: 7\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 2 * 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [6, 10, 3]) == 5\n assert candidate(nums = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [5, 15, 40, 5, 6]) == 7\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500]) == 5\n assert candidate(nums = [7, 14, 21, 28, 35]) == 5\n assert candidate(nums = [100000]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 11\n assert candidate(nums = [100000, 200000, 150000]) == 4\n assert candidate(nums = [7, 7, 7, 7]) == 1\n assert candidate(nums = [30, 15, 60, 90, 180]) == 5\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840, 882, 924, 966, 1008, 1050]) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 50\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 20\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 15\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 10\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 10\n assert candidate(nums = [37, 74, 111, 148, 185, 222, 259, 296, 333, 370, 407, 444, 481, 518, 555, 592, 629, 666, 703, 740, 777, 814, 851, 888, 925, 962, 999]) == 27\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630]) == 15\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020]) == 20\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175]) == 18\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 30\n assert candidate(nums = [10, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 22\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]) == 15\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 15\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120]) == 20\n assert candidate(nums = [5, 25, 45, 65, 85, 105, 125, 145, 165, 185, 205, 225, 245, 265, 285, 305, 325, 345, 365, 385]) == 23\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225, 234, 243, 252, 261, 270]) == 30\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197]) == 21\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30]) == 34\n assert candidate(nums = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111]) == 25\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 10\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 10\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993]) == 16\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 20\n assert candidate(nums = [12, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 26\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260, 273, 286, 299, 312, 325, 338, 351, 364, 377, 390]) == 30\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225]) == 25\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == 16\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 20\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96]) == 24\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515]) == 15\n assert candidate(nums = [37, 74, 111, 148, 185, 222, 259, 296, 333, 370, 407, 444, 481, 518, 555, 592, 629, 666, 703, 740]) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 25\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 25\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275, 286, 297, 308, 319, 330]) == 30\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 20\n assert candidate(nums = [104729, 104728, 104727, 104726, 104725, 104724, 104723, 104722, 104721, 104720, 104719, 104718, 104717, 104716, 104715]) == 25\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 20\n assert candidate(nums = [97, 194, 291, 388, 485, 582, 679, 776, 873, 970, 1067, 1164, 1261, 1358, 1455, 1552, 1649, 1746, 1843, 1940]) == 20\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 16\n assert candidate(nums = [15, 21, 25, 33, 35, 39, 45, 51, 55, 57, 63, 65, 69, 75, 77, 81, 85, 87, 91, 93, 95, 99]) == 31\n assert candidate(nums = [37, 74, 111, 148, 185, 222, 259, 296, 333, 370, 407, 444, 481, 518, 555]) == 15\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54]) == 18\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == 21\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600]) == 10\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300]) == 25\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 15\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 26\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == 14\n assert candidate(nums = [99995, 99996, 99997, 99998, 99999, 100000, 100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009]) == 26\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 20\n assert candidate(nums = [71, 142, 213, 284, 355, 426, 497, 568, 639, 710, 781, 852, 923, 994, 1065, 1136, 1207, 1278, 1349]) == 19\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510, 540, 570, 600]) == 20\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 15\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 900, 960, 1020, 1080, 1140, 1200]) == 20\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 30\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == 20\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 10\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300, 315, 330, 345, 360, 375, 390, 405, 420, 435, 450]) == 30\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 1\n assert candidate(nums = [120, 240, 360, 480, 600, 720, 840, 960, 1080, 1200, 1320, 1440, 1560, 1680, 1800, 1920, 2040]) == 17\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 18\n assert candidate(nums = [21, 35, 49, 63, 77, 91, 105, 119, 133, 147]) == 11\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99]) == 33\n assert candidate(nums = [200000, 199999, 199998, 199997, 199996, 199995, 199994, 199993, 199992, 199991]) == 17\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300]) == 20\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 1\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340]) == 20\n assert candidate(nums = [30, 42, 54, 60, 72, 84, 90, 102, 105, 108, 120, 126, 132, 144, 150, 156, 162, 168, 180, 192]) == 29\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015]) == 27\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countDifferentSubsequenceGCDs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countDifferentSubsequenceGCDs(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countDifferentSubsequenceGCDs", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1822, "task_id": "sign-of-the-product-of-an-array", "difficulty": "Easy", "problem_description": "Implement a function signFunc(x) that returns:\n\n1 if x is positive.\n-1 if x is negative.\n0 if x is equal to 0.\n\nYou are given an integer array nums. Let product be the product of all values in the array nums.\nReturn signFunc(product).\n \nExample 1:\n\nInput: nums = [-1,-2,-3,-4,3,2,1]\nOutput: 1\nExplanation: The product of all values in the array is 144, and signFunc(144) = 1\n\nExample 2:\n\nInput: nums = [1,5,0,2,-3]\nOutput: 0\nExplanation: The product of all values in the array is 0, and signFunc(0) = 0\n\nExample 3:\n\nInput: nums = [-1,1,-1,1,-1]\nOutput: -1\nExplanation: The product of all values in the array is -1, and signFunc(-1) = -1\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n-100 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1]) == -1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [0, 0, 0]) == 0\n assert candidate(nums = [-99, -98, -97, -96, -95, -94, -93, -92, -91, -90]) == 1\n assert candidate(nums = [100, -100, 100]) == -1\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [100, -100, 1]) == -1\n assert candidate(nums = [-100, 0, 100]) == 0\n assert candidate(nums = [-1, -2, -3, -4, 3, 2, 1]) == 1\n assert candidate(nums = [100, -100, 100, -100]) == 1\n assert candidate(nums = [-1, -2, -3, -4]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [1, 5, 0, 2, -3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [-1, -2, -3]) == -1\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == 0\n assert candidate(nums = [100, -50, 25, -10, 5]) == 1\n assert candidate(nums = [100, -50, 25, -12.5, 6.25]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 0\n assert candidate(nums = [-1, 1, 0, -1, 1, 0, -1, 1, 0]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 0, 60, 70, 80, 90]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, -1]) == -1\n assert candidate(nums = [1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1]) == 0\n assert candidate(nums = [-50, 50, -50, 50, -50, 50, -50, 50, -50, 50]) == -1\n assert candidate(nums = [50, 25, -10, 4, -2, 0.5, 0.2]) == 1\n assert candidate(nums = [-100, 0, 100, -100, 100, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, -6, -7, -8, -9, -10]) == -1\n assert candidate(nums = [-1, -1, -1, -1, -1]) == -1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1]) == -1\n assert candidate(nums = [99, -99, 100, -100, 101, -101]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 0\n assert candidate(nums = [1, -10, 100, -1000, 10000, -100000, 1000000, -10000000, 100000000, -1000000000]) == -1\n assert candidate(nums = [0, 1, 2, 3]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == -1\n assert candidate(nums = [10, -10, 100, -100, 1000, -1000, 10000, -10000]) == 1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == -1\n assert candidate(nums = [100, -50, 25, -12.5, 0.5]) == 1\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0]) == 0\n assert candidate(nums = [100, -100, 50, -50, 25, -25]) == -1\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6]) == -1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 1\n assert candidate(nums = [1, 0, -1, 2, 0, -2, 3, 0, -3, 4, 0, -4]) == 0\n assert candidate(nums = [100, -50, 0, 25, -10]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [99, 98, 97, -96, -95, -94]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0]) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [99, -99, 98, -98, 97, -97, 96, -96, 95, -95]) == -1\n assert candidate(nums = [-10, 10, -10, 10]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 1\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, -1]) == -1\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == -1\n assert candidate(nums = [-10, -20, -30, -40, -50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]) == 0\n assert candidate(nums = [100, -50, 20, -10, 5]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -16]) == -1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 1\n assert candidate(nums = [100, 200, 300, -400, -500, 600, -700, 800, -900, 1000]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [100, -100, 100, -100, 100]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == -1\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, 0]) == 0\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100]) == 1\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 1\n assert candidate(nums = [-100, 100, -10, 10, -1, 1]) == -1\n assert candidate(nums = [-100, -200, -300, -400, -500, 1]) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().arraySign", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def arraySign(self, nums: list[int]) -> int:", "container": "Solution", "callable": "arraySign", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1823, "task_id": "find-the-winner-of-the-circular-game", "difficulty": "Medium", "problem_description": "There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwise from the ith friend brings you to the (i+1)th friend for 1 <= i < n, and moving clockwise from the nth friend brings you to the 1st friend.\nThe rules of the game are as follows:\n\nStart at the 1st friend.\nCount the next k friends in the clockwise direction including the friend you started at. The counting wraps around the circle and may count some friends more than once.\nThe last friend you counted leaves the circle and loses the game.\nIf there is still more than one friend in the circle, go back to step 2 starting from the friend immediately clockwise of the friend who just lost and repeat.\nElse, the last friend in the circle wins the game.\n\nGiven the number of friends, n, and an integer k, return the winner of the game.\n \nExample 1:\n\n\nInput: n = 5, k = 2\nOutput: 3\nExplanation: Here are the steps of the game:\n1) Start at friend 1.\n2) Count 2 friends clockwise, which are friends 1 and 2.\n3) Friend 2 leaves the circle. Next start is friend 3.\n4) Count 2 friends clockwise, which are friends 3 and 4.\n5) Friend 4 leaves the circle. Next start is friend 5.\n6) Count 2 friends clockwise, which are friends 5 and 1.\n7) Friend 1 leaves the circle. Next start is friend 3.\n8) Count 2 friends clockwise, which are friends 3 and 5.\n9) Friend 5 leaves the circle. Only friend 3 is left, so they are the winner.\nExample 2:\n\nInput: n = 6, k = 5\nOutput: 1\nExplanation: The friends leave in this order: 5, 4, 6, 2, 3. The winner is friend 1.\n\n \nConstraints:\n\n1 <= k <= n <= 500\n\n \nFollow up:\nCould you solve this problem in linear time with constant space?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,k = 1) == 3\n assert candidate(n = 3,k = 3) == 2\n assert candidate(n = 5,k = 2) == 3\n assert candidate(n = 7,k = 3) == 4\n assert candidate(n = 7,k = 1) == 7\n assert candidate(n = 6,k = 5) == 1\n assert candidate(n = 7,k = 7) == 5\n assert candidate(n = 1,k = 1) == 1\n assert candidate(n = 4,k = 4) == 2\n assert candidate(n = 10,k = 4) == 5\n assert candidate(n = 10,k = 3) == 4\n assert candidate(n = 250,k = 125) == 173\n assert candidate(n = 300,k = 150) == 152\n assert candidate(n = 250,k = 150) == 76\n assert candidate(n = 200,k = 100) == 189\n assert candidate(n = 150,k = 50) == 138\n assert candidate(n = 300,k = 300) == 265\n assert candidate(n = 450,k = 450) == 87\n assert candidate(n = 123,k = 123) == 94\n assert candidate(n = 499,k = 250) == 134\n assert candidate(n = 300,k = 200) == 139\n assert candidate(n = 100,k = 13) == 70\n assert candidate(n = 500,k = 1) == 500\n assert candidate(n = 37,k = 37) == 16\n assert candidate(n = 500,k = 250) == 384\n assert candidate(n = 20,k = 19) == 11\n assert candidate(n = 200,k = 199) == 163\n assert candidate(n = 100,k = 99) == 88\n assert candidate(n = 30,k = 15) == 4\n assert candidate(n = 50,k = 7) == 1\n assert candidate(n = 30,k = 29) == 25\n assert candidate(n = 50,k = 2) == 37\n assert candidate(n = 250,k = 89) == 225\n assert candidate(n = 250,k = 3) == 41\n assert candidate(n = 50,k = 10) == 36\n assert candidate(n = 100,k = 37) == 45\n assert candidate(n = 40,k = 7) == 24\n assert candidate(n = 45,k = 23) == 36\n assert candidate(n = 45,k = 19) == 14\n assert candidate(n = 100,k = 50) == 95\n assert candidate(n = 123,k = 45) == 116\n assert candidate(n = 45,k = 13) == 36\n assert candidate(n = 500,k = 2) == 489\n assert candidate(n = 499,k = 300) == 36\n assert candidate(n = 200,k = 1) == 200\n assert candidate(n = 300,k = 299) == 145\n assert candidate(n = 400,k = 399) == 30\n assert candidate(n = 125,k = 124) == 31\n assert candidate(n = 150,k = 75) == 125\n assert candidate(n = 20,k = 7) == 3\n assert candidate(n = 350,k = 7) == 211\n assert candidate(n = 150,k = 2) == 45\n assert candidate(n = 123,k = 57) == 77\n assert candidate(n = 150,k = 41) == 79\n assert candidate(n = 200,k = 67) == 163\n assert candidate(n = 499,k = 499) == 122\n assert candidate(n = 500,k = 499) == 121\n assert candidate(n = 500,k = 500) == 69\n assert candidate(n = 400,k = 100) == 313\n assert candidate(n = 499,k = 5) == 327\n assert candidate(n = 200,k = 50) == 23\n assert candidate(n = 20,k = 5) == 7\n assert candidate(n = 250,k = 249) == 204\n assert candidate(n = 40,k = 13) == 14\n assert candidate(n = 50,k = 11) == 10\n assert candidate(n = 450,k = 3) == 286\n assert candidate(n = 450,k = 449) == 143\n assert candidate(n = 50,k = 13) == 5\n assert candidate(n = 15,k = 11) == 12\n assert candidate(n = 37,k = 13) == 14\n assert candidate(n = 15,k = 7) == 5\n assert candidate(n = 30,k = 11) == 28\n assert candidate(n = 300,k = 100) == 59\n assert candidate(n = 40,k = 19) == 6\n assert candidate(n = 120,k = 1) == 120\n assert candidate(n = 299,k = 299) == 146\n assert candidate(n = 50,k = 17) == 8\n assert candidate(n = 150,k = 1) == 150\n assert candidate(n = 250,k = 100) == 23\n assert candidate(n = 45,k = 20) == 29\n assert candidate(n = 373,k = 186) == 14\n assert candidate(n = 499,k = 2) == 487\n assert candidate(n = 50,k = 25) == 5\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().findTheWinner", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findTheWinner(self, n: int, k: int) -> int:", "container": "Solution", "callable": "findTheWinner", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1824, "task_id": "minimum-sideway-jumps", "difficulty": "Medium", "problem_description": "There is a 3 lane road of length n that consists of n + 1 points labeled from 0 to n. A frog starts at point 0 in the second lane and wants to jump to point n. However, there could be obstacles along the way.\nYou are given an array obstacles of length n + 1 where each obstacles[i] (ranging from 0 to 3) describes an obstacle on the lane obstacles[i] at point i. If obstacles[i] == 0, there are no obstacles at point i. There will be at most one obstacle in the 3 lanes at each point.\n\nFor example, if obstacles[2] == 1, then there is an obstacle on lane 1 at point 2.\n\nThe frog can only travel from point i to point i + 1 on the same lane if there is not an obstacle on the lane at point i + 1. To avoid obstacles, the frog can also perform a side jump to jump to another lane (even if they are not adjacent) at the same point if there is no obstacle on the new lane.\n\nFor example, the frog can jump from lane 3 at point 3 to lane 1 at point 3.\n\nReturn the minimum number of side jumps the frog needs to reach any lane at point n starting from lane 2 at point 0.\nNote: There will be no obstacles on points 0 and n.\n \nExample 1:\n\n\nInput: obstacles = [0,1,2,3,0]\nOutput: 2 \nExplanation: The optimal solution is shown by the arrows above. There are 2 side jumps (red arrows).\nNote that the frog can jump over obstacles only when making side jumps (as shown at point 2).\n\nExample 2:\n\n\nInput: obstacles = [0,1,1,3,3,0]\nOutput: 0\nExplanation: There are no obstacles on lane 2. No side jumps are required.\n\nExample 3:\n\n\nInput: obstacles = [0,2,1,0,3,0]\nOutput: 2\nExplanation: The optimal solution is shown by the arrows above. There are 2 side jumps.\n\n \nConstraints:\n\nobstacles.length == n + 1\n1 <= n <= 5 * 105\n0 <= obstacles[i] <= 3\nobstacles[0] == obstacles[n] == 0\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(obstacles = [0, 1, 0, 0, 2, 0, 0, 3, 0, 0]) == 1\n assert candidate(obstacles = [0, 0, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 1, 0, 3, 2, 1, 0]) == 4\n assert candidate(obstacles = [0, 0, 1, 0, 0, 2, 0, 0, 3, 0]) == 1\n assert candidate(obstacles = [0, 1, 3, 2, 3, 1, 0, 0, 0, 0]) == 2\n assert candidate(obstacles = [0, 3, 0, 0, 2, 0, 0, 1, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 0, 0]) == 5\n assert candidate(obstacles = [0, 2, 1, 0, 3, 0]) == 2\n assert candidate(obstacles = [0, 1, 2, 0, 2, 1, 0, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 2, 0, 0, 0, 3, 0, 0, 1, 0]) == 2\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 0]) == 1\n assert candidate(obstacles = [0, 1, 1, 3, 3, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 1, 3, 0]) == 3\n assert candidate(obstacles = [0, 0, 1, 2, 3, 0]) == 2\n assert candidate(obstacles = [0, 3, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 2, 0, 2, 0, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 0, 3, 0, 3, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 3, 0]) == 2\n assert candidate(obstacles = [0, 1, 0, 0, 2, 0]) == 1\n assert candidate(obstacles = [0, 2, 3, 2, 1, 2, 3, 0]) == 3\n assert candidate(obstacles = [0, 3, 2, 1, 0, 0]) == 2\n assert candidate(obstacles = [0, 1, 2, 0, 3, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 1, 0, 0]) == 2\n assert candidate(obstacles = [0, 2, 2, 2, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 2, 1, 3, 2, 1, 0]) == 5\n assert candidate(obstacles = [0, 3, 0, 1, 2, 0, 0, 0, 0, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 16\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 11\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 12\n assert candidate(obstacles = [0, 3, 3, 3, 3, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0]) == 10\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 8\n assert candidate(obstacles = [0, 1, 1, 1, 1, 0, 2, 2, 2, 2, 0, 3, 3, 3, 3, 0, 1, 1, 1, 1, 0]) == 2\n assert candidate(obstacles = [0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 20\n assert candidate(obstacles = [0, 1, 2, 0, 3, 0, 1, 2, 0, 3, 0, 1, 2, 0, 3, 0, 1, 2, 0]) == 7\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 4\n assert candidate(obstacles = [0, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 0]) == 5\n assert candidate(obstacles = [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]) == 10\n assert candidate(obstacles = [0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 3\n assert candidate(obstacles = [0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]) == 1\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 10\n assert candidate(obstacles = [0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 0, 1, 0, 3, 2, 0, 1, 0, 3, 0]) == 4\n assert candidate(obstacles = [0, 1, 0, 0, 2, 0, 3, 0, 0, 1, 0, 0, 0, 3, 0, 2, 0]) == 3\n assert candidate(obstacles = [0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 3, 3, 2, 2, 1, 1, 3, 3, 2, 2, 1, 1, 0]) == 5\n assert candidate(obstacles = [0, 1, 3, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 10\n assert candidate(obstacles = [0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0]) == 10\n assert candidate(obstacles = [0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0]) == 4\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 18\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 13\n assert candidate(obstacles = [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 12\n assert candidate(obstacles = [0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 1\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0]) == 7\n assert candidate(obstacles = [0, 3, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 1]) == 2\n assert candidate(obstacles = [0, 3, 2, 1, 0, 2, 1, 0, 3, 2, 1, 0, 2, 1, 3, 0]) == 5\n assert candidate(obstacles = [0, 1, 3, 2, 3, 1, 2, 3, 0, 1, 2, 3, 0]) == 6\n assert candidate(obstacles = [0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 30\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 27\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 0, 3, 2, 1]) == 8\n assert candidate(obstacles = [0, 2, 1, 3, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 26\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1]) == 5\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 11\n assert candidate(obstacles = [0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 25\n assert candidate(obstacles = [0, 2, 3, 1, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 26\n assert candidate(obstacles = [0, 2, 2, 0, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 0]) == 5\n assert candidate(obstacles = [0, 3, 0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0]) == 6\n assert candidate(obstacles = [0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 0]) == 7\n assert candidate(obstacles = [0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0]) == 8\n assert candidate(obstacles = [0, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 8\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 6\n assert candidate(obstacles = [0, 1, 3, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 18\n assert candidate(obstacles = [0, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 0, 3, 3, 3, 3, 3, 0]) == 1\n assert candidate(obstacles = [0, 1, 2, 0, 3, 0, 1, 2, 0, 3, 0, 1, 0]) == 4\n assert candidate(obstacles = [0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0]) == 2\n assert candidate(obstacles = [0, 3, 2, 1, 0, 2, 1, 0, 3, 1, 0, 2, 1, 0, 3, 1, 0, 2, 1, 0]) == 6\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 19\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 31\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 0, 3, 2, 1, 0, 2, 1, 3, 2, 1, 0]) == 11\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 2, 3, 2, 1, 0]) == 5\n assert candidate(obstacles = [0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 23\n assert candidate(obstacles = [0, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 0]) == 1\n assert candidate(obstacles = [0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0]) == 3\n assert candidate(obstacles = [0, 3, 2, 1, 2, 3, 1, 2, 3, 1, 0]) == 7\n assert candidate(obstacles = [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]) == 1\n assert candidate(obstacles = [0, 2, 1, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 17\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 3, 3, 3, 3, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]) == 1\n assert candidate(obstacles = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 0\n assert candidate(obstacles = [0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 0]) == 12\n assert candidate(obstacles = [0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 1, 2, 3, 0, 2, 1, 3, 0, 1, 2, 3, 0]) == 6\n assert candidate(obstacles = [0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3]) == 0\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 11\n assert candidate(obstacles = [0, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 17\n assert candidate(obstacles = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 0\n assert candidate(obstacles = [0, 0, 0, 2, 3, 1, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3]) == 6\n assert candidate(obstacles = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 7\n assert candidate(obstacles = [0, 3, 0, 1, 0, 3, 0, 1, 0, 3, 0, 1, 0, 3, 0]) == 0\n assert candidate(obstacles = [0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0]) == 3\n assert candidate(obstacles = [0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 2, 1, 0]) == 2\n assert candidate(obstacles = [0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 17\n assert candidate(obstacles = [0, 1, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 6\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 7\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0]) == 4\n assert candidate(obstacles = [0, 3, 2, 3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 9\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 9\n assert candidate(obstacles = [0, 3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(obstacles = [0, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 11\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 9\n assert candidate(obstacles = [0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 11\n"}, "metadata": {"canonical_parameter_names": ["obstacles"], "leetcode_dataset_entry_point": "Solution().minSideJumps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minSideJumps(self, obstacles: list[int]) -> int:", "container": "Solution", "callable": "minSideJumps", "parameters": [{"name": "obstacles", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1827, "task_id": "minimum-operations-to-make-the-array-increasing", "difficulty": "Easy", "problem_description": "You are given an integer array nums (0-indexed). In one operation, you can choose an element of the array and increment it by 1.\\r\n\\r\n\\r\n\tFor example, if nums = [1,2,3], you can choose to increment nums[1] to make nums = [1,3,3].\\r\n\\r\n\\r\nReturn the minimum number of operations needed to make nums strictly increasing.\\r\n\\r\nAn array nums is strictly increasing if nums[i] < nums[i+1] for all 0 <= i < nums.length - 1. An array of length 1 is trivially strictly increasing.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: nums = [1,1,1]\\r\nOutput: 3\\r\nExplanation: You can do the following operations:\\r\n1) Increment nums[2], so nums becomes [1,1,2].\\r\n2) Increment nums[1], so nums becomes [1,2,2].\\r\n3) Increment nums[2], so nums becomes [1,2,3].\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: nums = [1,5,2,4,1]\\r\nOutput: 14\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: nums = [8]\\r\nOutput: 0\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= nums.length <= 5000\\r\n\t1 <= nums[i] <= 104\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [10000, 1, 1, 1, 1]) == 40006\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 25\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == 109\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 25\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 16\n assert candidate(nums = [8]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 1, 1]) == 3\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000]) == 10\n assert candidate(nums = [10000, 10000, 10000, 10000]) == 6\n assert candidate(nums = [1, 5, 2, 4, 1]) == 14\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000]) == 100010\n assert candidate(nums = [1, 100, 1000, 10000, 100000]) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 400\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 66\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 10\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 380\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4095\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 45045\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 380\n assert candidate(nums = [3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, -1, -1, -1, -1]) == 230\n assert candidate(nums = [1, 100, 50, 200, 100, 300, 150, 400, 200, 500]) == 504\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 0\n assert candidate(nums = [1, 5, 10, 15, 20, 25, 20, 25, 30, 35]) == 8\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 90\n assert candidate(nums = [5, 6, 6, 10, 8, 11, 11, 11]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [100, 200, 300, 200, 100, 200, 300, 400, 500]) == 410\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15]) == 273\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == 380\n assert candidate(nums = [10, 9, 10, 8, 10, 7, 10, 6, 10, 5, 10, 4, 10, 3, 10, 2, 10, 1, 10]) == 216\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 870\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 300\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 0\n assert candidate(nums = [5, 3, 2, 1, 0]) == 24\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 6215\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 225\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(nums = [59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 1305\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 21, 20, 22, 21, 23, 22, 24, 23, 25]) == 35\n assert candidate(nums = [10000, 1000, 100, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 189064\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21]) == 18\n assert candidate(nums = [5000, 4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 4985, 4984, 4983, 4982, 4981, 4980, 4979, 4978, 4977, 4976, 4975, 4974, 4973, 4972, 4971, 4970]) == 930\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 375\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 480\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 100\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 25\n assert candidate(nums = [5, 6, 6, 8, 8, 9, 9, 10, 10, 10, 11]) == 18\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 3, 2, 1]) == 930\n assert candidate(nums = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == 55\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 172\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 65\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 189\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5]) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 36\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 81\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 80\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9]) == 486\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990]) == 110\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 24\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 5055\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 45045\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 4000, 3000, 2000, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 1, 1, 1, 1, 1, 1, 1]) == 89209\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 280\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 260\n assert candidate(nums = [2, 3, 3, 5, 5, 5, 6, 7, 8, 8, 9, 9, 9]) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11]) == 2\n assert candidate(nums = [1, 2, 10, 11, 10, 12, 11, 13, 12, 14]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 464\n assert candidate(nums = [10, 9, 10, 9, 10, 9, 10, 9, 10, 9]) == 50\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7]) == 133\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 212\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 189\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 7, 8, 9, 10]) == 17\n assert candidate(nums = [100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50]) == 690\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 99\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1128\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 22935\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 4140\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 171\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 14\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 100, 100, 100]) == 7278\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 72\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [100, 100, 100, 100, 100, 101, 101, 101, 101, 101, 102, 102, 102, 102, 102, 103, 103, 103, 103, 103, 104, 104, 104, 104, 104, 105, 105, 105, 105, 105]) == 360\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 155\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 75\n assert candidate(nums = [1, 1, 10, 10, 100, 100, 1000, 1000, 10000, 10000]) == 5\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6]) == 36\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 280\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 45\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 40\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 496\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 1325\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 99\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 180\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 495\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 105\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 252\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minOperations(self, nums: List[int]) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "List[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1828, "task_id": "queries-on-number-of-points-inside-a-circle", "difficulty": "Medium", "problem_description": "You are given an array points where points[i] = [xi, yi] is the coordinates of the ith point on a 2D plane. Multiple points can have the same coordinates.\nYou are also given an array queries where queries[j] = [xj, yj, rj] describes a circle centered at (xj, yj) with a radius of rj.\nFor each query queries[j], compute the number of points inside the jth circle. Points on the border of the circle are considered inside.\nReturn an array answer, where answer[j] is the answer to the jth query.\n \nExample 1:\n\n\nInput: points = [[1,3],[3,3],[5,3],[2,2]], queries = [[2,3,1],[4,3,1],[1,1,2]]\nOutput: [3,2,2]\nExplanation: The points and circles are shown above.\nqueries[0] is the green circle, queries[1] is the red circle, and queries[2] is the blue circle.\n\nExample 2:\n\n\nInput: points = [[1,1],[2,2],[3,3],[4,4],[5,5]], queries = [[1,2,2],[2,2,2],[4,3,2],[4,3,3]]\nOutput: [2,3,2,4]\nExplanation: The points and circles are shown above.\nqueries[0] is green, queries[1] is red, queries[2] is blue, and queries[3] is purple.\n\n \nConstraints:\n\n1 <= points.length <= 500\npoints[i].length == 2\n0 <= x​​​​​​i, y​​​​​​i <= 500\n1 <= queries.length <= 500\nqueries[j].length == 3\n0 <= xj, yj <= 500\n1 <= rj <= 500\nAll coordinates are integers.\n\n \nFollow up: Could you find the answer for each query in better complexity than O(n)?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 2, 2], [2, 2, 2], [4, 3, 2], [4, 3, 3]]) == [2, 3, 2, 4]\n assert candidate(points = [[1, 3], [3, 3], [5, 3], [2, 2]],queries = [[2, 3, 1], [4, 3, 1], [1, 1, 2]]) == [3, 2, 2]\n assert candidate(points = [[50, 50], [50, 150], [50, 250], [150, 50], [150, 150], [150, 250], [250, 50], [250, 150], [250, 250], [50, 100], [100, 100], [150, 100], [200, 100], [250, 100], [100, 150], [150, 150], [200, 150], [250, 150], [100, 200], [150, 200], [200, 200], [250, 200]],queries = [[100, 100, 50], [150, 150, 75], [200, 200, 100]]) == [4, 10, 12]\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],queries = [[5, 5, 5], [2, 2, 3], [7, 7, 2], [0, 0, 10]]) == [7, 5, 3, 8]\n assert candidate(points = [[250, 250], [260, 260], [270, 270], [280, 280], [290, 290]],queries = [[250, 250, 10], [250, 250, 20], [250, 250, 30], [250, 250, 40], [250, 250, 50]]) == [1, 2, 3, 3, 4]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[100, 100, 150], [200, 200, 150], [300, 300, 150], [400, 400, 150], [500, 500, 150]]) == [2, 3, 3, 3, 2]\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25]],queries = [[1, 1, 2], [10, 10, 5], [20, 20, 8], [15, 15, 10]]) == [2, 7, 11, 15]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[150, 150, 100], [350, 350, 150], [250, 250, 200], [450, 450, 250]]) == [2, 2, 2, 3]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],queries = [[25, 25, 10], [15, 15, 5], [35, 35, 20]]) == [2, 0, 2]\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [20, 10], [20, 20], [20, 30], [20, 40], [20, 50], [30, 10], [30, 20], [30, 30], [30, 40], [30, 50]],queries = [[15, 15, 5], [15, 25, 5], [15, 35, 5], [15, 45, 5], [15, 55, 5], [25, 15, 5], [25, 25, 5], [25, 35, 5], [25, 45, 5], [25, 55, 5], [35, 15, 5], [35, 25, 5], [35, 35, 5], [35, 45, 5], [35, 55, 5]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(points = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450], [50, 450], [450, 50]],queries = [[100, 100, 50], [200, 200, 50], [300, 300, 50], [400, 400, 50], [50, 50, 100], [450, 450, 100]]) == [0, 0, 0, 0, 1, 1]\n assert candidate(points = [[250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [550, 550], [600, 600], [650, 650], [700, 700], [750, 750], [800, 800], [850, 850], [900, 900], [950, 950]],queries = [[500, 500, 100], [600, 600, 150], [750, 750, 200], [850, 850, 250]]) == [3, 5, 5, 6]\n assert candidate(points = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [150, 250], [250, 350]],queries = [[200, 300, 50], [300, 400, 100], [400, 500, 150], [500, 600, 200]]) == [1, 2, 3, 2]\n assert candidate(points = [[0, 0], [500, 500], [250, 250], [100, 100], [400, 400]],queries = [[250, 250, 200], [100, 100, 100], [400, 400, 150]]) == [1, 1, 2]\n assert candidate(points = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [110, 120]],queries = [[50, 50, 25], [70, 70, 30], [10, 10, 15], [90, 90, 20]]) == [2, 2, 1, 1]\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],queries = [[3, 3, 5], [6, 6, 10], [9, 9, 15]]) == [6, 13, 15]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],queries = [[5, 5, 15], [15, 15, 25], [25, 25, 35], [35, 35, 45], [45, 45, 55]]) == [1, 3, 4, 5, 5]\n assert candidate(points = [[25, 25], [26, 26], [27, 27], [28, 28], [29, 29]],queries = [[10, 10, 20], [20, 20, 20], [30, 30, 20], [40, 40, 20], [50, 50, 20]]) == [0, 5, 5, 4, 0]\n assert candidate(points = [[50, 100], [100, 150], [150, 200], [200, 250], [250, 300]],queries = [[75, 125, 50], [125, 175, 50], [175, 225, 50], [225, 275, 50], [275, 325, 50]]) == [2, 2, 2, 2, 1]\n assert candidate(points = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450]],queries = [[100, 100, 50], [100, 100, 100], [100, 100, 150], [100, 100, 200], [100, 100, 250]]) == [0, 2, 2, 2, 3]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [[15, 15, 10], [25, 25, 15], [35, 35, 20], [45, 45, 25], [55, 55, 30]]) == [2, 2, 2, 4, 4]\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [[5, 5, 5], [10, 10, 10], [15, 15, 15], [20, 20, 20], [25, 25, 25], [30, 30, 30], [35, 35, 35], [40, 40, 40], [45, 45, 45], [50, 50, 50]]) == [4, 7, 8, 7, 7, 6, 5, 4, 4, 3]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [[15, 15, 10], [25, 25, 15], [35, 35, 20], [45, 45, 25], [55, 55, 30], [65, 65, 35], [75, 75, 40], [85, 85, 45], [95, 95, 50], [105, 105, 55]]) == [2, 2, 2, 4, 4, 4, 6, 5, 5, 4]\n assert candidate(points = [[400, 400], [450, 450], [500, 500], [550, 550], [600, 600]],queries = [[400, 400, 100], [450, 450, 150], [500, 500, 200], [550, 550, 250], [600, 600, 300]]) == [2, 4, 5, 5, 5]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250]],queries = [[50, 50, 50], [100, 100, 50], [150, 150, 50], [200, 200, 50], [250, 250, 50]]) == [1, 1, 1, 1, 1]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [50, 50], [150, 150], [250, 250], [350, 350], [450, 450]],queries = [[250, 250, 100], [150, 150, 50], [450, 450, 150], [50, 50, 200]]) == [3, 1, 4, 3]\n assert candidate(points = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95]],queries = [[10, 10, 10], [20, 20, 15], [30, 30, 20], [40, 40, 25], [50, 50, 30], [60, 60, 35], [70, 70, 40], [80, 80, 45], [90, 90, 50], [100, 100, 55]]) == [2, 2, 2, 4, 4, 4, 6, 5, 5, 4]\n assert candidate(points = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450], [100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[200, 200, 100], [100, 100, 50], [300, 300, 150], [400, 400, 200], [500, 500, 250]]) == [3, 1, 5, 5, 4]\n assert candidate(points = [[0, 0], [500, 0], [0, 500], [500, 500], [250, 250], [125, 125], [375, 125], [125, 375], [375, 375]],queries = [[250, 250, 200], [0, 0, 150], [500, 500, 150], [125, 125, 50], [375, 375, 50], [250, 0, 100], [250, 500, 100]]) == [5, 1, 1, 1, 1, 0, 0]\n assert candidate(points = [[10, 10], [10, 30], [10, 50], [10, 70], [10, 90], [30, 10], [30, 30], [30, 50], [30, 70], [30, 90], [50, 10], [50, 30], [50, 50], [50, 70], [50, 90]],queries = [[20, 20, 20], [40, 40, 20], [60, 60, 20], [20, 60, 20], [60, 20, 20]]) == [4, 4, 2, 4, 2]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]],queries = [[250, 250, 100], [300, 300, 150], [350, 350, 200], [400, 400, 250], [450, 450, 300]]) == [3, 5, 5, 6, 6]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120], [130, 130], [140, 140], [150, 150]],queries = [[50, 50, 40], [100, 100, 50], [150, 150, 60], [20, 20, 30], [130, 130, 70]]) == [5, 7, 5, 4, 7]\n assert candidate(points = [[100, 100], [150, 100], [200, 100], [250, 100], [300, 100], [100, 150], [150, 150], [200, 150], [250, 150], [300, 150]],queries = [[150, 100, 50], [200, 150, 75], [100, 100, 100]]) == [4, 6, 5]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [100, 200], [200, 300], [300, 400], [400, 500], [500, 100]],queries = [[150, 150, 50], [250, 250, 75], [350, 350, 100], [450, 450, 125], [550, 550, 150], [150, 250, 60], [250, 350, 85], [350, 450, 110], [450, 550, 135], [550, 150, 160]]) == [0, 3, 3, 3, 1, 0, 3, 3, 2, 1]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120], [130, 130], [140, 140], [150, 150], [160, 160], [170, 170], [180, 180], [190, 190], [200, 200]],queries = [[100, 100, 50], [150, 150, 60], [200, 200, 70], [125, 125, 80]]) == [7, 9, 5, 12]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [50, 100], [100, 150], [150, 200], [200, 250], [250, 300], [300, 350], [350, 400], [400, 450], [450, 500], [500, 550]],queries = [[75, 75, 25], [125, 125, 50], [175, 175, 75], [225, 225, 100], [275, 275, 125], [325, 325, 150], [375, 375, 175], [425, 425, 200], [475, 475, 225], [525, 525, 250]]) == [0, 3, 3, 5, 7, 9, 9, 10, 9, 8]\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5, 5], [2, 2, 3], [8, 8, 4]]) == [7, 4, 5]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [50, 50], [150, 150], [250, 250], [350, 350], [450, 450]],queries = [[100, 100, 50], [300, 300, 100], [400, 400, 150], [200, 200, 200], [50, 50, 25]]) == [1, 3, 5, 5, 1]\n assert candidate(points = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110]],queries = [[15, 25, 5], [25, 35, 10], [35, 45, 15], [45, 55, 20], [55, 65, 25], [65, 75, 30], [75, 85, 35], [85, 95, 40], [95, 105, 45], [105, 115, 50]]) == [0, 2, 2, 2, 4, 4, 4, 5, 4, 4]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120], [130, 130], [140, 140], [150, 150]],queries = [[75, 75, 25], [50, 50, 30], [125, 125, 40], [100, 100, 50]]) == [4, 5, 6, 7]\n assert candidate(points = [[250, 250], [260, 260], [270, 270], [280, 280], [290, 290], [300, 300], [310, 310], [320, 320], [330, 330], [340, 340]],queries = [[270, 270, 20], [300, 300, 40], [320, 320, 60]]) == [3, 5, 7]\n assert candidate(points = [[25, 25], [26, 26], [27, 27], [28, 28], [29, 29], [30, 30], [31, 31], [32, 32], [33, 33], [34, 34]],queries = [[25, 25, 10], [25, 25, 20], [25, 25, 30], [25, 25, 40], [25, 25, 50], [25, 25, 60], [25, 25, 70], [25, 25, 80], [25, 25, 90], [25, 25, 100]]) == [8, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]],queries = [[25, 25, 30], [75, 75, 40], [125, 125, 50], [175, 175, 60], [225, 225, 70], [275, 275, 80], [325, 325, 90], [375, 375, 100], [425, 425, 110], [475, 475, 120]]) == [0, 2, 2, 2, 2, 2, 2, 2, 4, 3]\n assert candidate(points = [[10, 10], [10, 20], [20, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80]],queries = [[15, 15, 10], [50, 50, 30], [75, 75, 15], [45, 45, 25]]) == [4, 5, 2, 4]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]],queries = [[250, 250, 100], [50, 50, 50], [450, 450, 150], [300, 300, 200]]) == [3, 1, 4, 5]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]],queries = [[250, 250, 100], [100, 100, 50], [300, 300, 150], [400, 400, 200]]) == [3, 1, 5, 5]\n assert candidate(points = [[0, 0], [500, 500], [250, 250], [100, 400], [400, 100], [200, 300], [300, 200], [150, 350], [350, 150], [50, 450]],queries = [[250, 250, 200], [100, 100, 50], [400, 400, 150], [200, 200, 100]]) == [5, 0, 1, 3]\n assert candidate(points = [[50, 50], [100, 50], [150, 50], [200, 50], [250, 50], [300, 50], [350, 50], [400, 50], [450, 50], [500, 50]],queries = [[75, 50, 25], [125, 50, 25], [175, 50, 25], [225, 50, 25], [275, 50, 25], [325, 50, 25], [375, 50, 25], [425, 50, 25], [475, 50, 25]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(points = [[100, 100], [100, 200], [100, 300], [100, 400], [100, 500]],queries = [[100, 100, 50], [100, 200, 50], [100, 300, 50], [100, 400, 50], [100, 500, 50]]) == [1, 1, 1, 1, 1]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[250, 250, 150], [150, 150, 50], [350, 350, 100]]) == [2, 0, 2]\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]],queries = [[5, 5, 5], [10, 10, 10], [15, 15, 15]]) == [7, 15, 15]\n"}, "metadata": {"canonical_parameter_names": ["points", "queries"], "leetcode_dataset_entry_point": "Solution().countPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countPoints(self, points: list[list[int]], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "countPoints", "parameters": [{"name": "points", "type": "list[list[int]]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1829, "task_id": "maximum-xor-for-each-query", "difficulty": "Medium", "problem_description": "You are given a sorted array nums of n non-negative integers and an integer maximumBit. You want to perform the following query n times:\n\nFind a non-negative integer k < 2maximumBit such that nums[0] XOR nums[1] XOR ... XOR nums[nums.length-1] XOR k is maximized. k is the answer to the ith query.\nRemove the last element from the current array nums.\n\nReturn an array answer, where answer[i] is the answer to the ith query.\n \nExample 1:\n\nInput: nums = [0,1,1,3], maximumBit = 2\nOutput: [0,3,2,3]\nExplanation: The queries are answered as follows:\n1st query: nums = [0,1,1,3], k = 0 since 0 XOR 1 XOR 1 XOR 3 XOR 0 = 3.\n2nd query: nums = [0,1,1], k = 3 since 0 XOR 1 XOR 1 XOR 3 = 3.\n3rd query: nums = [0,1], k = 2 since 0 XOR 1 XOR 2 = 3.\n4th query: nums = [0], k = 3 since 0 XOR 3 = 3.\n\nExample 2:\n\nInput: nums = [2,3,4,7], maximumBit = 3\nOutput: [5,2,6,5]\nExplanation: The queries are answered as follows:\n1st query: nums = [2,3,4,7], k = 5 since 2 XOR 3 XOR 4 XOR 7 XOR 5 = 7.\n2nd query: nums = [2,3,4], k = 2 since 2 XOR 3 XOR 4 XOR 2 = 7.\n3rd query: nums = [2,3], k = 6 since 2 XOR 3 XOR 6 = 7.\n4th query: nums = [2], k = 5 since 2 XOR 5 = 7.\n\nExample 3:\n\nInput: nums = [0,1,2,2,5,7], maximumBit = 3\nOutput: [4,3,6,4,6,7]\n\n \nConstraints:\n\nnums.length == n\n1 <= n <= 105\n1 <= maximumBit <= 20\n0 <= nums[i] < 2maximumBit\nnums​​​ is sorted in ascending order.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 3, 4, 7],maximumBit = 3) == [5, 2, 6, 5]\n assert candidate(nums = [0, 1, 1, 3],maximumBit = 2) == [0, 3, 2, 3]\n assert candidate(nums = [1, 2, 4, 8, 16],maximumBit = 5) == [0, 16, 24, 28, 30]\n assert candidate(nums = [31, 31, 31, 31, 31],maximumBit = 5) == [0, 31, 0, 31, 0]\n assert candidate(nums = [0, 1, 2, 2, 5, 7],maximumBit = 3) == [4, 3, 6, 4, 6, 7]\n assert candidate(nums = [1, 1, 1, 1, 1],maximumBit = 1) == [0, 1, 0, 1, 0]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],maximumBit = 20) == [434696, 813064, 624904, 73608, 941512, 1039208, 1047672, 1048464, 1048564, 1048574]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109, 113, 117],maximumBit = 7) == [123, 14, 127, 18, 123, 30, 127, 34, 123, 46, 127, 50, 123, 62, 127, 66, 123, 78, 127, 82, 123, 94, 127, 98, 123, 110, 127, 114, 123, 126]\n assert candidate(nums = [1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575],maximumBit = 20) == [1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],maximumBit = 4) == [14, 7, 15, 8, 14, 11, 15, 12, 14, 15]\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],maximumBit = 14) == [5056, 14594, 9071, 13114, 14626, 16159, 15556, 16038, 16351, 16182, 16294, 16383, 16328, 16362, 16383, 16370, 16378, 16383, 16380, 16382]\n assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maximumBit = 1) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]\n assert candidate(nums = [0, 2, 6, 14, 30, 62, 126, 254, 510, 1022],maximumBit = 10) == [341, 683, 853, 939, 981, 1003, 1013, 1019, 1021, 1023]\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],maximumBit = 15) == [10922, 21845, 27306, 30037, 31402, 32085, 32426, 32597, 32682, 32725, 32746, 32757, 32762, 32765, 32766]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],maximumBit = 5) == [31, 0, 29, 6, 31, 8, 29, 14, 31, 16, 29, 22, 31, 24, 29, 30]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],maximumBit = 4) == [15, 15, 14, 12, 15, 11, 14, 8, 15, 7, 14, 4, 15, 3, 14, 0]\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50],maximumBit = 6) == [29, 47, 0, 44, 5, 35, 0, 32, 61, 39, 48, 36, 53, 59, 48, 56, 61]\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049],maximumBit = 16) == [18165, 41052, 60607, 62750, 64917, 65356, 65471, 65518, 65525, 65532]\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],maximumBit = 10) == [1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],maximumBit = 5) == [29, 14, 31, 16, 29, 22, 31, 24, 29, 30]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],maximumBit = 5) == [31, 0, 30, 3, 31, 4, 30, 7, 31, 8, 30, 11, 31, 12, 30, 15, 31, 16, 30, 19, 31, 20, 30, 23, 31, 24, 30, 27, 31, 28, 30]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],maximumBit = 6) == [61, 6, 63, 8, 61, 14, 63, 16, 61, 22, 63, 24, 61, 30, 63, 32, 61, 38, 63, 40, 61, 46, 63, 48, 61, 54, 63, 56, 61, 62]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],maximumBit = 20) == [0, 524288, 786432, 917504, 983040, 1015808, 1032192, 1040384, 1044480, 1046528, 1047552, 1048064, 1048320, 1048448, 1048512, 1048544, 1048560, 1048568, 1048572, 1048574]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],maximumBit = 5) == [11, 10, 8, 11, 15, 10, 12, 11, 3, 10, 0, 11, 7, 10, 4, 11, 27, 10, 24, 11]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],maximumBit = 3) == [7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2]\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38],maximumBit = 6) == [63, 25, 61, 31, 63, 33, 61, 39, 63, 41, 61, 47, 63, 49, 61, 55, 63, 57, 61, 63]\n assert candidate(nums = [3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151],maximumBit = 21) == [699051, 1398100, 1747627, 1922388, 2009771, 2053460, 2075307, 2086228, 2091691, 2094420, 2095787, 2096468, 2096811, 2096980, 2097067, 2097108, 2097131, 2097140, 2097147, 2097148]\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58],maximumBit = 6) == [61, 7, 63, 9, 61, 15, 63, 17, 61, 23, 63, 25, 61, 31, 63, 33, 61, 39, 63, 41, 61, 47, 63, 49, 61, 55, 63, 57, 61, 63]\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400],maximumBit = 9) == [99, 499, 154, 478, 255, 511, 286, 474, 371, 483, 410, 510, 431, 495, 478, 506, 483, 499, 506, 510]\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576],maximumBit = 15) == [16382, 24574, 28670, 30718, 31742, 32254, 32510, 32638, 32702, 32734, 32750, 32758, 32762, 32764]\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765],maximumBit = 13) == [6403, 878, 4923, 6435, 7966, 7365, 7847, 8158, 7991, 8103, 8190, 8137, 8171, 8190, 8179, 8187, 8190, 8189, 8191, 8190]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],maximumBit = 11) == [0, 1024, 1536, 1792, 1920, 1984, 2016, 2032, 2040, 2044, 2046]\n assert candidate(nums = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015],maximumBit = 10) == [8, 1023, 7, 1022, 4, 1023, 3, 1022, 0]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],maximumBit = 4) == [15, 0, 14, 3, 15, 4, 14, 7, 15, 8, 14, 11, 15, 12, 14, 15]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],maximumBit = 7) == [63, 116, 50, 115, 79, 120, 74, 103, 79, 108, 114, 107, 127, 112, 122]\n assert candidate(nums = [12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288],maximumBit = 14) == [8187, 12283, 14331, 15355, 15867, 16123, 16251, 16315, 16347, 16363, 16371]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],maximumBit = 6) == [1, 61, 7, 63, 9, 61, 15, 63, 17, 61, 23, 63, 25, 61, 31, 63, 33, 61, 39, 63, 41, 61, 47, 63, 49, 61, 55, 63, 57, 61]\n assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maximumBit = 1) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maximumBit = 1) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35],maximumBit = 6) == [15, 44, 50, 43, 63, 48, 58]\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095],maximumBit = 13) == [5461, 6826, 7509, 7850, 8021, 8106, 8149, 8170, 8181, 8186, 8189, 8190]\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64],maximumBit = 7) == [63, 127, 71, 119, 95, 127, 103, 119]\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],maximumBit = 10) == [341, 682, 853, 938, 981, 1002, 1013, 1018, 1021, 1022]\n assert candidate(nums = [0, 2, 3, 5, 6, 8, 10, 12],maximumBit = 4) == [3, 15, 5, 13, 11, 14, 13, 15]\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18],maximumBit = 5) == [31, 13, 30, 14, 31, 17, 30, 18, 31, 21, 30, 22, 31, 25, 30, 26, 31, 29, 30, 30]\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127],maximumBit = 7) == [42, 85, 106, 117, 122, 125, 126]\n assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310],maximumBit = 10) == [990, 744, 1023, 775, 990, 868, 1023, 899, 990, 992]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],maximumBit = 1) == [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]\n assert candidate(nums = [7, 15, 23, 31, 39, 47, 55, 63, 71, 79, 87, 95],maximumBit = 7) == [127, 32, 119, 56, 127, 64, 119, 88, 127, 96, 119, 120]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],maximumBit = 8) == [183, 127, 193, 117, 223, 127, 233, 101, 231, 159, 241, 149, 207, 159, 217, 229, 215, 255, 225, 245]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],maximumBit = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],maximumBit = 10) == [0, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022]\n assert candidate(nums = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287],maximumBit = 20) == [699050, 873813, 961194, 1004885, 1026730, 1037653, 1043114, 1045845, 1047210, 1047893, 1048234, 1048405, 1048490, 1048533, 1048554, 1048565, 1048570, 1048573, 1048574, 1048575]\n assert candidate(nums = [0, 1, 3, 7, 15, 31, 63],maximumBit = 6) == [21, 42, 53, 58, 61, 62, 63]\n assert candidate(nums = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144],maximumBit = 18) == [0, 0, 131072, 196608, 229376, 245760, 253952, 258048, 260096, 261120, 261632, 261888, 262016, 262080, 262112, 262128, 262136, 262140, 262142, 262143]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],maximumBit = 4) == [15, 0, 14, 3, 15, 4, 14, 7, 15, 8, 14, 11, 15, 12, 14, 15]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],maximumBit = 20) == [0, 524288, 786432, 917504, 983040, 1015808, 1032192, 1040384, 1044480, 1046528, 1047552, 1048064, 1048320, 1048448, 1048512, 1048544, 1048560, 1048568, 1048572, 1048574]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],maximumBit = 6) == [14, 63, 16, 61, 22, 63, 24, 61, 30, 63, 32, 61, 38, 63, 40, 61, 46, 63, 48, 61, 54, 63, 56, 61, 62]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],maximumBit = 2) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],maximumBit = 10) == [1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],maximumBit = 7) == [113, 21, 79, 31, 89, 101, 87, 127, 97, 117]\n assert candidate(nums = [1, 3, 4, 7, 10, 12, 15, 19, 22],maximumBit = 5) == [18, 4, 23, 24, 20, 30, 25, 29, 30]\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],maximumBit = 10) == [1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0]\n assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120],maximumBit = 13) == [2041, 5113, 6649, 7417, 7801, 7993, 8089, 8137, 8161, 8181]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],maximumBit = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],maximumBit = 5) == [11, 31, 12, 30, 15, 31, 16, 30, 19, 31, 20, 30, 23, 31, 24, 30, 27, 31, 28, 30]\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],maximumBit = 7) == [26, 126, 47, 111, 94, 122, 99, 115, 122, 126]\n assert candidate(nums = [0, 1, 3, 7, 15, 31, 63, 127],maximumBit = 7) == [42, 85, 106, 117, 122, 125, 126, 127]\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],maximumBit = 3) == [7, 4, 7, 4, 7, 4, 6, 4, 6, 4, 6, 7, 6, 7, 6, 7, 7, 7, 7, 7]\n assert candidate(nums = [127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117],maximumBit = 7) == [11, 126, 8, 127, 7, 126, 4, 127, 3, 126, 0]\n assert candidate(nums = [5, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383],maximumBit = 14) == [5458, 10925, 13650, 15021, 15698, 16045, 16210, 16301, 16338, 16365, 16370, 16381, 16378]\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],maximumBit = 20) == [349525, 349524, 349527, 349520, 349535, 349504, 349567, 349440, 349695, 349184, 350207, 348160, 352255, 344064, 360447, 327680, 393215, 262144, 524287, 0]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],maximumBit = 10) == [0, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022]\n assert candidate(nums = [8, 10, 12, 14, 16, 18, 20, 22],maximumBit = 5) == [31, 9, 29, 15, 31, 17, 29, 23]\n assert candidate(nums = [2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575],maximumBit = 20) == [350207, 698368, 874495, 960512, 1005567, 1026048, 1038335, 1042432, 1046527, 1046528]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],maximumBit = 6) == [63, 3, 58, 12, 63, 15, 34, 8, 47, 11, 42, 52, 47, 55, 34, 48, 63, 51, 58, 60]\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],maximumBit = 8) == [255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0]\n assert candidate(nums = [0, 2, 3, 5, 8, 13, 21, 34, 55, 89],maximumBit = 7) == [39, 126, 73, 107, 126, 115, 123, 126, 125, 127]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],maximumBit = 6) == [63, 24, 61, 30, 63, 32, 61, 38, 63, 40, 61, 46, 63, 48, 61, 54, 63, 56, 61, 62]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1023],maximumBit = 10) == [1023, 0, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022]\n assert candidate(nums = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512],maximumBit = 10) == [0, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022, 1023]\n"}, "metadata": {"canonical_parameter_names": ["nums", "maximumBit"], "leetcode_dataset_entry_point": "Solution().getMaximumXor", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getMaximumXor(self, nums: list[int], maximumBit: int) -> list[int]:", "container": "Solution", "callable": "getMaximumXor", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "maximumBit", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1832, "task_id": "check-if-the-sentence-is-pangram", "difficulty": "Easy", "problem_description": "A pangram is a sentence where every letter of the English alphabet appears at least once.\nGiven a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise.\n \nExample 1:\n\nInput: sentence = \"thequickbrownfoxjumpsoverthelazydog\"\nOutput: true\nExplanation: sentence contains at least one of every letter of the English alphabet.\n\nExample 2:\n\nInput: sentence = \"leetcode\"\nOutput: false\n\n \nConstraints:\n\n1 <= sentence.length <= 1000\nsentence consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(sentence = \"quickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"aaaaabbbbbccccc\") == False\n assert candidate(sentence = \"a\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogandmorelettersjusttoextendthelengthofthesentenceevenmorejustformeasurements\") == True\n assert candidate(sentence = \"hellothere\") == False\n assert candidate(sentence = \"hello\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazy\") == False\n assert candidate(sentence = \"abcdefghijjklmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"hello world\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzzzzz\") == True\n assert candidate(sentence = \"leetcode\") == False\n assert candidate(sentence = \"thisisaverylongsentencebutnotapangram\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzabc\") == True\n assert candidate(sentence = \"mississippi\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelaz\") == False\n assert candidate(sentence = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(sentence = \"abcdefghijlkmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogandthenomeofthezebra\") == True\n assert candidate(sentence = \"aquickmovementsoftheenemywilljeopardizethesecurityofthefort\") == False\n assert candidate(sentence = \"neverjumpoveraslydogquicklyasmyfastcat\") == False\n assert candidate(sentence = \"jumpedoverthelazybrownfoxquickly\") == False\n assert candidate(sentence = \"thisisaverylongsentencethatwantsyoumakesurethatispangram\") == False\n assert candidate(sentence = \"everygoodboydoesfine\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthefly\") == False\n assert candidate(sentence = \"thefoxjumpedoveralazydogandquicklymunchedberries\") == False\n assert candidate(sentence = \"aquickmovofjumpsbxngthevlackdwarf\") == False\n assert candidate(sentence = \"abcdefghijklnopqrstuvwxyz\") == False\n assert candidate(sentence = \"sphinxofblackquartzjudgemyvowels\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydozzzzzzzzzz\") == False\n assert candidate(sentence = \"aabbbcccdddeeefffggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == True\n assert candidate(sentence = \"thisisaverylongsentencethatshouldcontainalllettersquickly\") == False\n assert candidate(sentence = \"thebrownfoxjumpsovertheleazydog\") == False\n assert candidate(sentence = \"phinxofquizzingjudgesbringsmywonder\") == False\n assert candidate(sentence = \"packmyboxwithfivedozenliquorjugsquicklyandjudgeeachvowel\") == True\n assert candidate(sentence = \"vowelsaeiouyzqjfdxhcntrbplsmkgw\") == True\n assert candidate(sentence = \"jumpsquickonthisbrownfox\") == False\n assert candidate(sentence = \"fivexwiseguysjumpquicklyonthiszanyboat\") == False\n assert candidate(sentence = \"aquickmovewiththiszestyjuicebringsvexflation\") == False\n assert candidate(sentence = \"quickbrownfoxjumpsoverthelazydogquickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"pythonprogramminglanguage\") == False\n assert candidate(sentence = \"xylophonesarefunbutquickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogy\") == True\n assert candidate(sentence = \"qwertypoiuytrewqasdfghjklzxcvbnmasdfghjklzxcvbnmqwertyuiopcvbnm\") == True\n assert candidate(sentence = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"thesixfatfingersjumpquicklyonthisverylazydog\") == False\n assert candidate(sentence = \"jumpsfoxoverthelazydogquickb\") == False\n assert candidate(sentence = \"sixjovialfellowshavequicklyzippedanddrunkmanybeers\") == False\n assert candidate(sentence = \"abacaxypromiseyouanelephantwhoxylophones\") == False\n assert candidate(sentence = \"jumpedoverthelazydogthequickbrownfox\") == False\n assert candidate(sentence = \"sphinxofblackquartzjudgemyvexzwift\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpedoverthelazydogquickly\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxy\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzz\") == True\n assert candidate(sentence = \"foxjumpsoverthelazydogquickbrown\") == True\n assert candidate(sentence = \"thisquestionaboutpangramsissomewhatredundant\") == False\n assert candidate(sentence = \"aquickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"jumpedoverthelazydogquickbrownfox\") == False\n assert candidate(sentence = \"aquickmovingtonafleetofsixgreyhounds\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogg\") == True\n assert candidate(sentence = \"howvexinglyquickdaftzebrasjump\") == True\n assert candidate(sentence = \"quickbrownfoxjumpsoverthelazydogzzzzzzzzzz\") == True\n assert candidate(sentence = \"aquickmovementsofthejaguarzephyr\") == False\n assert candidate(sentence = \"quicklyjudginghowvexingzebraflowscanbeverytricky\") == False\n assert candidate(sentence = \"aquickbrownfoxjumpsoverthelazydogandbackagain\") == True\n assert candidate(sentence = \"abcdefghijklnopqrstuvwxyzabcdefghijklnopqrstuvwxyz\") == False\n assert candidate(sentence = \"jellyoftheplumlovesmeandthemonkeyrinsesupwithgrapejuicequickly\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(sentence = \"thebrownfoxjumpedoveralazylazydog\") == False\n assert candidate(sentence = \"packmyboxwithfivedozenliquorjugs\") == True\n assert candidate(sentence = \"foxjumpsoverthelazydogquickbrownzzzzzzzzzz\") == True\n assert candidate(sentence = \"althoughsomehumansareabsolutelyastonishing\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"jovialwaltzsexemplifiesquickbymyflyfriend\") == False\n assert candidate(sentence = \"aquickbrownfoxjumpsoverthelazydogs\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydo\") == False\n assert candidate(sentence = \"abcdefghjklmnopqrstuvwxyz\") == False\n assert candidate(sentence = \"veryfewlazydogslikejumpingoverthebigbrownfox\") == False\n assert candidate(sentence = \"therearemanysmallpacksofdifferentbooksinthelibrary\") == False\n assert candidate(sentence = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(sentence = \"jimquicklyzippedvexedfowlsbymyplushog\") == False\n assert candidate(sentence = \"quickbrownfoxjumpsoverthelazydogs\") == True\n assert candidate(sentence = \"abcdefghijkllllmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogandmore\") == True\n assert candidate(sentence = \"everygoodboydoesfinejustkickslovingmonkeysnearpianoquicksly\") == False\n assert candidate(sentence = \"pqrsghijklmnabcdefwxyzotuvcd\") == True\n assert candidate(sentence = \"pangramsarefunnywordsusedinyogamatclasses\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpedoverthelazydogandthenranoff\") == False\n assert candidate(sentence = \"fourxsixtwoseveneleveneightfivenineninetwozero\") == False\n assert candidate(sentence = \"abracadabracabracadabra\") == False\n assert candidate(sentence = \"mjklqrswxzytfpuhncideaoxbgvlozmt\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogandcat\") == True\n assert candidate(sentence = \"thisisaverylongstringsentencethatwillnotbepangram\") == False\n assert candidate(sentence = \"quovadis\") == False\n assert candidate(sentence = \"thisisaverylongsentencethatjustmightcontainallthelettersofthealphabet\") == False\n assert candidate(sentence = \"everygoodboydoesfineandzestfullyjumpoverlazysnails\") == False\n"}, "metadata": {"canonical_parameter_names": ["sentence"], "leetcode_dataset_entry_point": "Solution().checkIfPangram", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def checkIfPangram(self, sentence: str) -> bool:", "container": "Solution", "callable": "checkIfPangram", "parameters": [{"name": "sentence", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1833, "task_id": "maximum-ice-cream-bars", "difficulty": "Medium", "problem_description": "It is a sweltering summer day, and a boy wants to buy some ice cream bars.\nAt the store, there are n ice cream bars. You are given an array costs of length n, where costs[i] is the price of the ith ice cream bar in coins. The boy initially has coins coins to spend, and he wants to buy as many ice cream bars as possible. \nNote: The boy can buy the ice cream bars in any order.\nReturn the maximum number of ice cream bars the boy can buy with coins coins.\nYou must solve the problem by counting sort.\n \nExample 1:\n\nInput: costs = [1,3,2,4,1], coins = 7\nOutput: 4\nExplanation: The boy can buy ice cream bars at indices 0,1,2,4 for a total price of 1 + 3 + 2 + 1 = 7.\n\nExample 2:\n\nInput: costs = [10,6,8,7,7,8], coins = 5\nOutput: 0\nExplanation: The boy cannot afford any of the ice cream bars.\n\nExample 3:\n\nInput: costs = [1,6,3,1,2,5], coins = 20\nOutput: 6\nExplanation: The boy can buy all the ice cream bars for a total price of 1 + 6 + 3 + 1 + 2 + 5 = 18.\n\n \nConstraints:\n\ncosts.length == n\n1 <= n <= 105\n1 <= costs[i] <= 105\n1 <= coins <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(costs = [1, 3, 2, 4, 1],coins = 7) == 4\n assert candidate(costs = [10, 6, 8, 7, 7, 8],coins = 5) == 0\n assert candidate(costs = [1],coins = 1) == 1\n assert candidate(costs = [1, 6, 3, 1, 2, 5],coins = 20) == 6\n assert candidate(costs = [100000],coins = 100000) == 1\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 10) == 4\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 55) == 10\n assert candidate(costs = [5, 5, 5, 5, 5],coins = 15) == 3\n assert candidate(costs = [10, 20, 30, 40, 50],coins = 100) == 4\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 15) == 5\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 50) == 9\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 19) == 19\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 5) == 5\n assert candidate(costs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],coins = 15) == 6\n assert candidate(costs = [5, 4, 2, 3, 1, 6, 7, 8, 9, 10],coins = 15) == 5\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],coins = 250) == 6\n assert candidate(costs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],coins = 25) == 12\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],coins = 210) == 20\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],coins = 55) == 2\n assert candidate(costs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],coins = 40) == 8\n assert candidate(costs = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],coins = 100) == 13\n assert candidate(costs = [100000, 99999, 99998, 99997, 99996, 99995],coins = 599985) == 6\n assert candidate(costs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],coins = 50) == 13\n assert candidate(costs = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996],coins = 1000000) == 5\n assert candidate(costs = [50, 25, 75, 100, 200, 300, 400, 500, 600, 700],coins = 2000) == 8\n assert candidate(costs = [1, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],coins = 800) == 12\n assert candidate(costs = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996],coins = 5000000) == 9\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [5, 1, 4, 2, 3],coins = 10) == 4\n assert candidate(costs = [1000, 500, 200, 100, 50, 20, 10, 5, 2, 1],coins = 1000) == 9\n assert candidate(costs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],coins = 8000) == 12\n assert candidate(costs = [5, 7, 8, 6, 3, 2, 1, 4, 9, 10],coins = 20) == 5\n assert candidate(costs = [50, 20, 30, 10, 40],coins = 100) == 4\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],coins = 1000) == 10\n assert candidate(costs = [100000, 100000, 100000, 100000, 100000],coins = 500000) == 5\n assert candidate(costs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],coins = 50) == 5\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],coins = 300) == 24\n assert candidate(costs = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],coins = 25) == 6\n assert candidate(costs = [99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1],coins = 5) == 5\n assert candidate(costs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],coins = 20) == 4\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 50) == 9\n assert candidate(costs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],coins = 50) == 10\n assert candidate(costs = [9, 8, 7, 6, 5, 4, 3, 2, 1],coins = 25) == 6\n assert candidate(costs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],coins = 55) == 10\n assert candidate(costs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],coins = 1500) == 5\n assert candidate(costs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],coins = 15) == 7\n assert candidate(costs = [5, 1, 3, 1, 2, 5, 3, 1, 2, 5],coins = 15) == 7\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],coins = 55) == 2\n assert candidate(costs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],coins = 20) == 4\n assert candidate(costs = [1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4],coins = 10) == 7\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],coins = 550) == 10\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],coins = 190) == 19\n assert candidate(costs = [3, 1, 2, 1, 4, 2, 2, 3, 2, 1, 2, 3, 4, 1, 2],coins = 20) == 11\n assert candidate(costs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],coins = 300) == 10\n assert candidate(costs = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31],coins = 100) == 8\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],coins = 1000) == 13\n assert candidate(costs = [100000, 1, 100000, 1, 100000, 1, 100000],coins = 100003) == 4\n assert candidate(costs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],coins = 100) == 10\n assert candidate(costs = [5, 1, 3, 2, 4, 1],coins = 10) == 4\n assert candidate(costs = [5, 3, 3, 2, 7, 8, 9],coins = 15) == 4\n assert candidate(costs = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],coins = 500000) == 9\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],coins = 100) == 13\n assert candidate(costs = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],coins = 1000000) == 10\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 5) == 5\n assert candidate(costs = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],coins = 150000) == 9\n assert candidate(costs = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],coins = 250) == 18\n assert candidate(costs = [5, 2, 3, 1, 4, 2, 3, 5, 1, 2],coins = 15) == 7\n assert candidate(costs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],coins = 2500) == 6\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 30) == 7\n assert candidate(costs = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],coins = 60) == 10\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],coins = 100) == 13\n"}, "metadata": {"canonical_parameter_names": ["costs", "coins"], "leetcode_dataset_entry_point": "Solution().maxIceCream", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxIceCream(self, costs: list[int], coins: int) -> int:", "container": "Solution", "callable": "maxIceCream", "parameters": [{"name": "costs", "type": "list[int]"}, {"name": "coins", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1834, "task_id": "single-threaded-cpu", "difficulty": "Medium", "problem_description": "You are given n​​​​​​ tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTimei, processingTimei] means that the i​​​​​​th​​​​ task will be available to process at enqueueTimei and will take processingTimei to finish processing.\nYou have a single-threaded CPU that can process at most one task at a time and will act in the following way:\n\nIf the CPU is idle and there are no available tasks to process, the CPU remains idle.\nIf the CPU is idle and there are available tasks, the CPU will choose the one with the shortest processing time. If multiple tasks have the same shortest processing time, it will choose the task with the smallest index.\nOnce a task is started, the CPU will process the entire task without stopping.\nThe CPU can finish a task then start a new one instantly.\n\nReturn the order in which the CPU will process the tasks.\n \nExample 1:\n\nInput: tasks = [[1,2],[2,4],[3,2],[4,1]]\nOutput: [0,2,3,1]\nExplanation: The events go as follows: \n- At time = 1, task 0 is available to process. Available tasks = {0}.\n- Also at time = 1, the idle CPU starts processing task 0. Available tasks = {}.\n- At time = 2, task 1 is available to process. Available tasks = {1}.\n- At time = 3, task 2 is available to process. Available tasks = {1, 2}.\n- Also at time = 3, the CPU finishes task 0 and starts processing task 2 as it is the shortest. Available tasks = {1}.\n- At time = 4, task 3 is available to process. Available tasks = {1, 3}.\n- At time = 5, the CPU finishes task 2 and starts processing task 3 as it is the shortest. Available tasks = {1}.\n- At time = 6, the CPU finishes task 3 and starts processing task 1. Available tasks = {}.\n- At time = 10, the CPU finishes task 1 and becomes idle.\n\nExample 2:\n\nInput: tasks = [[7,10],[7,12],[7,5],[7,4],[7,2]]\nOutput: [4,3,2,0,1]\nExplanation: The events go as follows:\n- At time = 7, all the tasks become available. Available tasks = {0,1,2,3,4}.\n- Also at time = 7, the idle CPU starts processing task 4. Available tasks = {0,1,2,3}.\n- At time = 9, the CPU finishes task 4 and starts processing task 3. Available tasks = {0,1,2}.\n- At time = 13, the CPU finishes task 3 and starts processing task 2. Available tasks = {0,1}.\n- At time = 18, the CPU finishes task 2 and starts processing task 0. Available tasks = {1}.\n- At time = 28, the CPU finishes task 0 and starts processing task 1. Available tasks = {}.\n- At time = 40, the CPU finishes task 1 and becomes idle.\n\n \nConstraints:\n\ntasks.length == n\n1 <= n <= 105\n1 <= enqueueTimei, processingTimei <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [[1, 3], [2, 2], [3, 1], [4, 4]]) == [0, 2, 1, 3]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 3], [2, 5], [8, 2], [7, 4], [10, 2]]) == [0, 1, 2, 4, 3]\n assert candidate(tasks = [[1, 3], [2, 2], [3, 1], [4, 4], [5, 5]]) == [0, 2, 1, 3, 4]\n assert candidate(tasks = [[3, 1], [1, 2], [2, 4], [1, 4]]) == [1, 0, 2, 3]\n assert candidate(tasks = [[5, 2], [3, 1], [1, 4], [4, 3], [2, 5]]) == [2, 1, 0, 3, 4]\n assert candidate(tasks = [[5, 5], [8, 2], [1, 9], [3, 8]]) == [2, 1, 0, 3]\n assert candidate(tasks = [[9, 3], [3, 7], [8, 10], [4, 3], [5, 3]]) == [1, 0, 3, 4, 2]\n assert candidate(tasks = [[2, 1], [3, 1], [1, 2], [7, 3], [8, 4], [9, 5]]) == [2, 0, 1, 3, 4, 5]\n assert candidate(tasks = [[19, 13], [16, 9], [21, 10], [32, 25], [37, 4], [49, 24], [2, 15], [38, 41], [37, 34], [33, 6], [45, 4], [18, 18], [46, 39], [12, 24]]) == [6, 1, 2, 9, 4, 10, 0, 11, 5, 13, 3, 8, 12, 7]\n assert candidate(tasks = [[5, 2], [7, 2], [9, 4], [6, 3], [8, 2]]) == [0, 1, 4, 3, 2]\n assert candidate(tasks = [[7, 10], [7, 12], [7, 5], [7, 4], [7, 2]]) == [4, 3, 2, 0, 1]\n assert candidate(tasks = [[5, 2], [1, 2], [3, 1], [2, 1]]) == [1, 2, 3, 0]\n assert candidate(tasks = [[1, 2], [2, 4], [3, 2], [4, 1]]) == [0, 2, 3, 1]\n assert candidate(tasks = [[1, 3], [2, 5], [8, 2], [7, 4], [6, 1], [5, 6], [4, 3], [3, 2], [9, 5], [10, 4]]) == [0, 7, 4, 6, 2, 3, 9, 1, 8, 5]\n assert candidate(tasks = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 10]]) == [0, 8, 7, 6, 5, 4, 3, 2, 1, 9]\n assert candidate(tasks = [[100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[1, 2], [2, 3], [4, 5], [8, 9], [16, 17], [32, 33], [64, 65], [128, 129], [256, 257], [512, 513], [1024, 1025], [2048, 2049], [4096, 4097], [8192, 8193], [16384, 16385]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 100], [101, 1], [201, 10], [301, 100], [401, 10], [501, 1], [601, 100], [701, 10], [801, 1], [901, 100]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [1, 3], [2, 4], [1, 5], [2, 6], [1, 7], [2, 8], [1, 9], [2, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [0, 10, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19]\n assert candidate(tasks = [[1, 1000000000], [2, 1000000000], [3, 1000000000], [4, 1000000000], [5, 1000000000]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 100], [200, 1], [300, 1], [400, 1], [500, 1], [600, 1], [700, 1], [800, 1], [900, 1], [1000, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 1], [7, 2], [8, 3], [9, 4], [10, 5]]) == [0, 4, 5, 3, 6, 2, 7, 1, 8, 9]\n assert candidate(tasks = [[1, 10], [10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[2, 5], [1, 3], [2, 2], [4, 1], [5, 10], [7, 1], [8, 2], [9, 3], [10, 4]]) == [1, 3, 2, 5, 6, 7, 8, 0, 4]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]]) == [5, 6, 3, 4, 10, 2, 7, 11, 15, 1, 8, 12, 16, 0, 9, 13, 17, 14, 18, 19]\n assert candidate(tasks = [[1, 10], [10, 1], [100, 1], [1000, 1], [10000, 1], [100000, 1], [1000000, 1], [10000000, 1], [100000000, 1], [1000000000, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[10, 100], [100, 10], [200, 20], [300, 30], [400, 40], [500, 50], [600, 60], [700, 70], [800, 80], [900, 90]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 5], [1, 4], [1, 3], [1, 2], [1, 1], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]]) == [4, 5, 3, 6, 2, 7, 1, 8, 0, 9]\n assert candidate(tasks = [[1, 3], [1, 2], [1, 1], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [2, 1, 0, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [1, 2], [1, 2], [2, 1], [2, 1], [2, 1], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5]]) == [0, 3, 4, 5, 1, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 1], [1000000000, 1000000000], [2, 2], [999999999, 999999999], [3, 3], [999999998, 999999998], [4, 4], [999999997, 999999997], [5, 5], [999999996, 999999996]]) == [0, 2, 4, 6, 8, 9, 7, 5, 3, 1]\n assert candidate(tasks = [[10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [2, 1], [3, 2], [4, 1], [5, 2], [6, 1], [7, 2], [8, 1], [9, 2], [10, 1], [1, 2], [2, 1], [3, 2], [4, 1], [5, 2], [6, 1], [7, 2], [8, 1], [9, 2], [10, 1]]) == [0, 1, 3, 11, 5, 13, 7, 15, 9, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18]\n assert candidate(tasks = [[1, 1], [10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[1000000000, 1], [1000000000, 2], [1000000000, 3], [1000000000, 4], [1000000000, 5]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0]]) == [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[1, 1], [1, 2], [1, 4], [1, 8], [1, 16], [1, 32], [1, 64], [1, 128], [1, 256], [1, 512]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]\n assert candidate(tasks = [[5, 10], [10, 5], [15, 1], [20, 2], [25, 8], [30, 3], [35, 4], [40, 9], [45, 6], [50, 7]]) == [0, 2, 1, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1000000000], [2, 1000000000], [3, 1000000000], [4, 1000000000], [5, 1000000000], [6, 1000000000], [7, 1000000000], [8, 1000000000], [9, 1000000000], [10, 1000000000]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [1000000000, 1], [999999999, 2], [2, 2], [999999998, 3], [3, 3], [999999997, 4], [4, 4], [999999996, 5], [5, 5]]) == [0, 3, 5, 7, 9, 8, 1, 2, 4, 6]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(tasks = [[1, 2], [1, 3], [2, 1], [2, 2], [3, 3], [3, 4], [4, 1], [4, 2], [5, 3], [5, 4], [6, 1], [6, 2], [7, 3], [7, 4], [8, 1], [8, 2], [9, 3], [9, 4], [10, 1], [10, 2]]) == [0, 2, 6, 3, 10, 14, 7, 18, 11, 15, 19, 1, 4, 8, 12, 16, 5, 9, 13, 17]\n assert candidate(tasks = [[1, 100], [2, 50], [3, 25], [4, 12], [5, 6], [6, 3], [7, 2], [8, 1]]) == [0, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[1, 20], [5, 10], [10, 5], [15, 2], [20, 1], [25, 1], [30, 1], [35, 1], [40, 1], [45, 1]]) == [0, 4, 3, 2, 5, 6, 1, 7, 8, 9]\n assert candidate(tasks = [[100, 100], [150, 100], [200, 100], [250, 100], [300, 100], [350, 100], [400, 100], [450, 100], [500, 100]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 1], [3, 1], [5, 1], [7, 1], [9, 1], [11, 1], [13, 1], [15, 1], [17, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [4, 1]]) == [0, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[2, 1], [4, 1], [6, 1], [8, 1], [10, 1], [1, 2], [3, 2], [5, 2], [7, 2], [9, 2], [11, 2], [13, 2], [15, 2], [17, 2], [19, 2]]) == [5, 0, 1, 6, 2, 3, 7, 4, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10]]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(tasks = [[10, 10], [15, 5], [20, 1], [25, 2], [30, 3], [35, 4], [40, 5], [45, 6], [50, 7]]) == [0, 2, 1, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 100], [10, 100], [20, 100], [30, 100], [40, 100], [50, 100], [60, 100], [70, 100], [80, 100], [90, 100]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(tasks = [[1, 5], [3, 3], [5, 1], [7, 2], [9, 4], [11, 6], [13, 5], [15, 3], [17, 2], [19, 1]]) == [0, 2, 3, 1, 4, 7, 9, 8, 6, 5]\n assert candidate(tasks = [[1000000000, 1], [1000000000, 1], [1000000000, 1], [1000000000, 1], [1000000000, 1]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 10], [11, 1], [21, 1], [31, 1], [41, 1], [51, 1], [61, 1], [71, 1], [81, 1], [91, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[10, 1], [11, 2], [12, 3], [13, 4], [14, 5], [15, 6], [16, 7], [17, 8], [18, 9], [19, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1]]) == [0, 5, 6, 7, 8, 9, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 2], [10, 3], [20, 4], [30, 5], [40, 6], [50, 7], [60, 8], [70, 9], [80, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 1], [1, 10], [1, 100], [1, 1000], [1, 10000], [1, 100000], [1, 1000000], [1, 10000000], [1, 100000000], [1, 1000000000]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [3, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(tasks = [[1, 2], [3, 1], [5, 3], [7, 4], [9, 2], [11, 1], [13, 5], [15, 3], [17, 2], [19, 1]]) == [0, 1, 2, 3, 5, 4, 7, 8, 9, 6]\n assert candidate(tasks = [[9, 5], [1, 5], [8, 5], [3, 5], [2, 5], [4, 5], [6, 5], [7, 5], [10, 5], [11, 5]]) == [1, 3, 0, 2, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [2, 1], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8], [100000000, 9], [1000000000, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[10, 3], [20, 2], [30, 1], [40, 4], [50, 5], [60, 6]]) == [0, 1, 2, 3, 4, 5]\n assert candidate(tasks = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [2, 2], [4, 4], [6, 6], [8, 8], [10, 10]]) == [0, 5, 1, 6, 2, 7, 3, 8, 4, 9]\n assert candidate(tasks = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [0, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1], [2, 10], [2, 9], [2, 8], [2, 7], [2, 6], [2, 5], [2, 4], [2, 3], [2, 2], [2, 1]]) == [9, 19, 8, 18, 7, 17, 6, 16, 5, 15, 4, 14, 3, 13, 2, 12, 1, 11, 0, 10]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [2, 4], [3, 8], [4, 16], [5, 32], [6, 64], [7, 128], [8, 256], [9, 512], [10, 1024]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(tasks = [[1, 10], [10, 10], [20, 10], [30, 10], [40, 10], [50, 10]]) == [0, 1, 2, 3, 4, 5]\n assert candidate(tasks = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]]) == [0, 1, 3, 5, 7, 9, 2, 4, 6, 8]\n assert candidate(tasks = [[10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2]]) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]\n assert candidate(tasks = [[1, 1], [1, 1], [1, 2], [1, 2], [1, 3], [1, 3], [1, 4], [1, 4], [1, 5], [1, 5]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(tasks = [[1, 10], [2, 5], [3, 15], [4, 20], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [0, 4, 5, 6, 7, 8, 9, 1, 2, 3]\n assert candidate(tasks = [[1000000000, 1000000000], [1000000001, 1000000000], [1000000002, 1000000000], [1000000003, 1000000000], [1000000004, 1000000000]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 2], [3, 3], [5, 2], [7, 1], [9, 2], [11, 3], [13, 1], [15, 2], [17, 3], [19, 1], [21, 2], [23, 3], [25, 1], [27, 2], [29, 3]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 10], [5, 1], [3, 2], [2, 3], [7, 4], [6, 5], [8, 6], [9, 7], [10, 8]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 1000000000], [2, 900000000], [3, 800000000], [4, 700000000], [5, 600000000], [6, 500000000], [7, 400000000], [8, 300000000], [9, 200000000], [10, 100000000]]) == [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[10, 10], [20, 5], [30, 15], [40, 1], [50, 20]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 1], [2, 1], [1, 2], [2, 2], [1, 3], [2, 3], [1, 4], [2, 4], [1, 5], [2, 5]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1]]) == [8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(tasks = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [11, 10], [12, 9], [13, 8], [14, 7], [15, 6], [16, 5], [17, 4], [18, 3], [19, 2], [20, 1]]) == [0, 9, 8, 7, 6, 19, 18, 17, 16, 5, 15, 4, 14, 3, 13, 2, 12, 1, 11, 10]\n"}, "metadata": {"canonical_parameter_names": ["tasks"], "leetcode_dataset_entry_point": "Solution().getOrder", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getOrder(self, tasks: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "getOrder", "parameters": [{"name": "tasks", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1835, "task_id": "find-xor-sum-of-all-pairs-bitwise-and", "difficulty": "Hard", "problem_description": "The XOR sum of a list is the bitwise XOR of all its elements. If the list only contains one element, then its XOR sum will be equal to this element.\n\nFor example, the XOR sum of [1,2,3,4] is equal to 1 XOR 2 XOR 3 XOR 4 = 4, and the XOR sum of [3] is equal to 3.\n\nYou are given two 0-indexed arrays arr1 and arr2 that consist only of non-negative integers.\nConsider the list containing the result of arr1[i] AND arr2[j] (bitwise AND) for every (i, j) pair where 0 <= i < arr1.length and 0 <= j < arr2.length.\nReturn the XOR sum of the aforementioned list.\n \nExample 1:\n\nInput: arr1 = [1,2,3], arr2 = [6,5]\nOutput: 0\nExplanation: The list = [1 AND 6, 1 AND 5, 2 AND 6, 2 AND 5, 3 AND 6, 3 AND 5] = [0,1,2,0,2,1].\nThe XOR sum = 0 XOR 1 XOR 2 XOR 0 XOR 2 XOR 1 = 0.\n\nExample 2:\n\nInput: arr1 = [12], arr2 = [4]\nOutput: 4\nExplanation: The list = [12 AND 4] = [4]. The XOR sum = 4.\n\n \nConstraints:\n\n1 <= arr1.length, arr2.length <= 105\n0 <= arr1[i], arr2[j] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr1 = [1, 2, 3],arr2 = [6, 5]) == 0\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1]) == 1\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10]) == 0\n assert candidate(arr1 = [1000000000],arr2 = [1000000000]) == 1000000000\n assert candidate(arr1 = [0, 0, 0],arr2 = [0, 0, 0]) == 0\n assert candidate(arr1 = [255, 128, 64],arr2 = [32, 16, 8]) == 56\n assert candidate(arr1 = [1000000000, 500000000],arr2 = [500000000, 1000000000]) == 643280640\n assert candidate(arr1 = [255, 128, 64, 32, 16],arr2 = [1, 3, 7, 15, 31]) == 5\n assert candidate(arr1 = [0, 1, 2, 3, 4],arr2 = [0, 1, 2, 3, 4]) == 4\n assert candidate(arr1 = [255, 128, 64, 32],arr2 = [1, 2, 4, 8]) == 15\n assert candidate(arr1 = [0, 1, 2, 3, 4],arr2 = [4, 3, 2, 1, 0]) == 4\n assert candidate(arr1 = [12],arr2 = [4]) == 4\n assert candidate(arr1 = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],arr2 = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 13\n assert candidate(arr1 = [8, 16, 32, 64, 128, 256, 512],arr2 = [1024, 2048, 4096, 8192]) == 0\n assert candidate(arr1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15],arr2 = [2, 4, 6, 8, 10, 12, 14, 16]) == 0\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 484\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(arr1 = [1023, 2047, 4095],arr2 = [8191, 16383, 32767]) == 3071\n assert candidate(arr1 = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127],arr2 = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 640\n assert candidate(arr1 = [123456789, 987654321, 1122334455, 5544332211],arr2 = [123, 456, 789, 987, 654, 321]) == 160\n assert candidate(arr1 = [5, 10, 15, 20, 25],arr2 = [30, 35, 40, 45, 50]) == 8\n assert candidate(arr1 = [7, 14, 21, 28, 35],arr2 = [42, 49, 56, 63, 70]) == 2\n assert candidate(arr1 = [11235813, 21345589, 34558914, 55891442],arr2 = [832040, 1346269, 2178309, 3524578]) == 279040\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(arr1 = [1023, 512, 256, 128, 64],arr2 = [32, 16, 8, 4, 2, 1]) == 63\n assert candidate(arr1 = [987654321, 234567890],arr2 = [135792468, 864201357]) == 855638081\n assert candidate(arr1 = [13, 29, 42, 57, 71],arr2 = [88, 99, 101, 113, 131]) == 4\n assert candidate(arr1 = [1],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 0\n assert candidate(arr1 = [1000000000, 500000000, 250000000, 125000000, 62500000],arr2 = [1, 3, 5, 7, 9]) == 0\n assert candidate(arr1 = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(arr1 = [23, 45, 67, 89, 101],arr2 = [113, 131, 149, 167]) == 64\n assert candidate(arr1 = [29, 18, 7, 2, 11],arr2 = [19, 23, 31, 37, 41]) == 1\n assert candidate(arr1 = [1000000, 2000000, 3000000],arr2 = [1000, 2000, 3000, 4000, 5000]) == 0\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32],arr2 = [64, 128, 256, 512, 1024]) == 0\n assert candidate(arr1 = [1, 3, 7, 15, 31, 63, 127, 255],arr2 = [255, 127, 63, 31, 15, 7, 3, 1]) == 170\n assert candidate(arr1 = [15, 31, 63, 127, 255],arr2 = [255, 127, 63, 31, 15]) == 175\n assert candidate(arr1 = [7, 14, 21, 28, 35],arr2 = [8, 16, 24, 32, 40]) == 0\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32, 64, 128],arr2 = [128, 64, 32, 16, 8, 4, 2, 1]) == 255\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr1 = [999999999, 999999998, 999999997, 999999996, 999999995],arr2 = [999999994, 999999993, 999999992, 999999991, 999999990]) == 999999994\n assert candidate(arr1 = [314159265, 271828182, 8675309],arr2 = [161803398, 141421356, 423606797]) == 403842\n assert candidate(arr1 = [17, 34, 51, 68, 85],arr2 = [1, 2, 4, 8, 16]) == 17\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0],arr2 = [1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(arr1 = [123456789, 987654321, 1122334455, 5544332211, 9876543210],arr2 = [123, 456, 789, 101112, 131415]) == 198664\n assert candidate(arr1 = [2147483647, 2147483646, 2147483645],arr2 = [2147483644, 2147483643, 2147483642]) == 2147483644\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],arr2 = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 682\n assert candidate(arr1 = [123456789, 987654321],arr2 = [111111111, 222222222, 333333333]) == 403023108\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [1]) == 1\n assert candidate(arr1 = [255, 192, 128, 64, 32],arr2 = [16, 8, 4, 2, 1]) == 31\n assert candidate(arr1 = [134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152],arr2 = [512, 256, 128, 64, 32, 16]) == 0\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(arr1 = [1, 1, 1, 1],arr2 = [2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(arr1 = [1023, 511, 255, 127, 63],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 703\n assert candidate(arr1 = [13, 14, 15],arr2 = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 12\n assert candidate(arr1 = [1000000000, 2000000000, 3000000000],arr2 = [4000000000, 5000000000]) == 3295543296\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],arr2 = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2047\n assert candidate(arr1 = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 2097151\n assert candidate(arr1 = [1000000000, 500000000, 250000000, 125000000],arr2 = [2, 3, 5, 7]) == 0\n assert candidate(arr1 = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 682\n assert candidate(arr1 = [2, 4, 6, 8, 10],arr2 = [3, 6, 9, 12, 15]) == 2\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(arr1 = [1023, 2047, 4095, 8191],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1024\n assert candidate(arr1 = [0, 0, 0, 0, 0],arr2 = [1, 3, 5, 7, 9]) == 0\n assert candidate(arr1 = [29, 31, 37, 41, 43],arr2 = [47, 53, 59, 61, 67, 71]) == 0\n assert candidate(arr1 = [31, 63, 127, 255],arr2 = [255, 127, 63, 31]) == 160\n assert candidate(arr1 = [2, 4, 6, 8, 10, 12, 14, 16],arr2 = [1, 3, 5, 7, 9, 11, 13, 15]) == 0\n assert candidate(arr1 = [2147483647, 2147483647],arr2 = [2147483647, 2147483647]) == 0\n assert candidate(arr1 = [234, 456, 789, 1024],arr2 = [123, 234, 345, 456]) == 0\n assert candidate(arr1 = [987654321, 123456789, 456789123],arr2 = [987654321, 123456789, 456789123]) == 650094887\n assert candidate(arr1 = [123456, 654321, 987654, 321654],arr2 = [789456, 123789, 456789]) == 196608\n assert candidate(arr1 = [0, 0, 0, 0, 0],arr2 = [0, 0, 0, 0, 0]) == 0\n assert candidate(arr1 = [23, 45, 67, 89, 123],arr2 = [56, 78, 90, 101, 112]) == 25\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [600, 700, 800, 900, 1000]) == 416\n assert candidate(arr1 = [1000000007, 1000000008, 1000000009, 1000000010, 1000000011],arr2 = [1000000012, 1000000013, 1000000014, 1000000015, 1000000016]) == 1000000000\n assert candidate(arr1 = [7, 8, 9, 10, 11],arr2 = [12, 13, 14, 15, 16]) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(arr1 = [15, 30, 45, 60, 75, 90],arr2 = [10, 20, 30, 40, 50, 60]) == 0\n assert candidate(arr1 = [15, 27, 45, 63],arr2 = [31, 63, 95, 127]) == 0\n assert candidate(arr1 = [4294967295, 2147483647, 1073741823, 536870911],arr2 = [268435455, 134217727, 67108863, 33554431]) == 0\n assert candidate(arr1 = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],arr2 = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17]) == 16\n assert candidate(arr1 = [2147483647, 1073741823, 536870911, 268435455, 134217727],arr2 = [858993459, 429496729, 214748364, 107374182, 53687091]) == 53687091\n assert candidate(arr1 = [1000000000, 999999999, 888888888],arr2 = [777777777, 666666666, 555555555]) == 553274368\n assert candidate(arr1 = [123456789, 987654321, 111111111],arr2 = [222222222, 333333333, 444444444]) == 1575491\n assert candidate(arr1 = [13, 21, 34, 55, 89, 144, 233, 377, 610, 987],arr2 = [1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393]) == 1\n assert candidate(arr1 = [1048576, 2097152, 4194304],arr2 = [1, 3, 5, 7]) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 0\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(arr1 = [255, 0, 127, 63, 31],arr2 = [255, 128, 64, 32, 16]) == 0\n assert candidate(arr1 = [314159265],arr2 = [271828182]) == 271679616\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15],arr2 = [1, 2, 4, 8, 16, 32, 64, 128]) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n assert candidate(arr1 = [1000000000, 500000000, 250000000],arr2 = [1000000000, 500000000, 250000000]) == 682696064\n assert candidate(arr1 = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],arr2 = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 682\n assert candidate(arr1 = [123456789, 987654321, 135792468],arr2 = [246813579, 864204864, 975318642]) == 85229744\n assert candidate(arr1 = [1048575, 524287, 262143, 131071, 65535],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 720895\n assert candidate(arr1 = [1000000000, 999999999, 999999998],arr2 = [999999997, 999999996, 999999995]) == 999999488\n assert candidate(arr1 = [123456789, 987654321],arr2 = [234567891, 123456789]) == 142648708\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr1 = [1000000000, 500000000, 250000000, 125000000],arr2 = [2, 4, 8, 16]) == 0\n assert candidate(arr1 = [256, 512, 768, 1024],arr2 = [1, 2, 4, 8, 16]) == 0\n assert candidate(arr1 = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 682\n"}, "metadata": {"canonical_parameter_names": ["arr1", "arr2"], "leetcode_dataset_entry_point": "Solution().getXORSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getXORSum(self, arr1: list[int], arr2: list[int]) -> int:", "container": "Solution", "callable": "getXORSum", "parameters": [{"name": "arr1", "type": "list[int]"}, {"name": "arr2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1837, "task_id": "sum-of-digits-in-base-k", "difficulty": "Easy", "problem_description": "Given an integer n (in base 10) and a base k, return the sum of the digits of n after converting n from base 10 to base k.\nAfter converting, each digit should be interpreted as a base 10 number, and the sum should be returned in base 10.\n \nExample 1:\n\nInput: n = 34, k = 6\nOutput: 9\nExplanation: 34 (base 10) expressed in base 6 is 54. 5 + 4 = 9.\n\nExample 2:\n\nInput: n = 10, k = 10\nOutput: 1\nExplanation: n is already in base 10. 1 + 0 = 1.\n\n \nConstraints:\n\n1 <= n <= 100\n2 <= k <= 10\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 64,k = 2) == 1\n assert candidate(n = 7,k = 3) == 3\n assert candidate(n = 42,k = 5) == 6\n assert candidate(n = 50,k = 4) == 5\n assert candidate(n = 100,k = 3) == 4\n assert candidate(n = 10,k = 10) == 1\n assert candidate(n = 50,k = 7) == 2\n assert candidate(n = 99,k = 9) == 3\n assert candidate(n = 81,k = 9) == 1\n assert candidate(n = 34,k = 6) == 9\n assert candidate(n = 8,k = 2) == 1\n assert candidate(n = 45,k = 3) == 3\n assert candidate(n = 25,k = 2) == 3\n assert candidate(n = 81,k = 3) == 1\n assert candidate(n = 64,k = 10) == 10\n assert candidate(n = 27,k = 5) == 3\n assert candidate(n = 100,k = 2) == 3\n assert candidate(n = 1,k = 2) == 1\n assert candidate(n = 100,k = 4) == 4\n assert candidate(n = 72,k = 8) == 2\n assert candidate(n = 50,k = 5) == 2\n assert candidate(n = 17,k = 8) == 3\n assert candidate(n = 91,k = 8) == 7\n assert candidate(n = 73,k = 4) == 4\n assert candidate(n = 85,k = 7) == 7\n assert candidate(n = 63,k = 9) == 7\n assert candidate(n = 100,k = 7) == 4\n assert candidate(n = 63,k = 5) == 7\n assert candidate(n = 37,k = 5) == 5\n assert candidate(n = 95,k = 9) == 7\n assert candidate(n = 63,k = 7) == 3\n assert candidate(n = 55,k = 7) == 7\n assert candidate(n = 31,k = 5) == 3\n assert candidate(n = 32,k = 2) == 1\n assert candidate(n = 42,k = 4) == 6\n assert candidate(n = 19,k = 4) == 4\n assert candidate(n = 55,k = 6) == 5\n assert candidate(n = 100,k = 5) == 4\n assert candidate(n = 15,k = 6) == 5\n assert candidate(n = 45,k = 7) == 9\n assert candidate(n = 84,k = 4) == 3\n assert candidate(n = 31,k = 10) == 4\n assert candidate(n = 45,k = 6) == 5\n assert candidate(n = 97,k = 5) == 9\n assert candidate(n = 45,k = 10) == 9\n assert candidate(n = 50,k = 8) == 8\n assert candidate(n = 67,k = 5) == 7\n assert candidate(n = 37,k = 2) == 3\n assert candidate(n = 67,k = 7) == 7\n assert candidate(n = 29,k = 3) == 3\n assert candidate(n = 50,k = 6) == 5\n assert candidate(n = 72,k = 5) == 8\n assert candidate(n = 37,k = 6) == 2\n assert candidate(n = 85,k = 3) == 3\n assert candidate(n = 88,k = 3) == 4\n assert candidate(n = 64,k = 3) == 4\n assert candidate(n = 64,k = 4) == 1\n assert candidate(n = 95,k = 6) == 10\n assert candidate(n = 67,k = 3) == 5\n assert candidate(n = 100,k = 10) == 1\n assert candidate(n = 81,k = 5) == 5\n assert candidate(n = 55,k = 5) == 3\n assert candidate(n = 98,k = 2) == 3\n assert candidate(n = 58,k = 7) == 4\n assert candidate(n = 48,k = 4) == 3\n assert candidate(n = 31,k = 2) == 5\n assert candidate(n = 81,k = 8) == 4\n assert candidate(n = 42,k = 7) == 6\n assert candidate(n = 27,k = 9) == 3\n assert candidate(n = 77,k = 7) == 5\n assert candidate(n = 29,k = 8) == 8\n assert candidate(n = 97,k = 10) == 16\n assert candidate(n = 77,k = 4) == 5\n assert candidate(n = 13,k = 6) == 3\n assert candidate(n = 49,k = 9) == 9\n assert candidate(n = 55,k = 10) == 10\n assert candidate(n = 41,k = 4) == 5\n assert candidate(n = 98,k = 6) == 8\n assert candidate(n = 50,k = 3) == 6\n assert candidate(n = 85,k = 5) == 5\n assert candidate(n = 73,k = 8) == 3\n assert candidate(n = 100,k = 9) == 4\n assert candidate(n = 77,k = 8) == 7\n assert candidate(n = 85,k = 4) == 4\n assert candidate(n = 99,k = 3) == 3\n assert candidate(n = 29,k = 4) == 5\n assert candidate(n = 72,k = 6) == 2\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().sumBase", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def sumBase(self, n: int, k: int) -> int:", "container": "Solution", "callable": "sumBase", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1838, "task_id": "frequency-of-the-most-frequent-element", "difficulty": "Medium", "problem_description": "The frequency of an element is the number of times it occurs in an array.\nYou are given an integer array nums and an integer k. In one operation, you can choose an index of nums and increment the element at that index by 1.\nReturn the maximum possible frequency of an element after performing at most k operations.\n \nExample 1:\n\nInput: nums = [1,2,4], k = 5\nOutput: 3\nExplanation: Increment the first element three times and the second element two times to make nums = [4,4,4].\n4 has a frequency of 3.\nExample 2:\n\nInput: nums = [1,4,8,13], k = 5\nOutput: 2\nExplanation: There are multiple optimal solutions:\n- Increment the first element three times to make nums = [4,4,8,13]. 4 has a frequency of 2.\n- Increment the second element four times to make nums = [1,8,8,13]. 8 has a frequency of 2.\n- Increment the third element five times to make nums = [1,4,13,13]. 13 has a frequency of 2.\n\nExample 3:\n\nInput: nums = [3,9,6], k = 2\nOutput: 1\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 105\n1 <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 4],k = 5) == 3\n assert candidate(nums = [100000, 100000, 100000],k = 300000) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 25) == 7\n assert candidate(nums = [1, 1, 1, 1],k = 0) == 4\n assert candidate(nums = [5, 5, 5, 5, 5],k = 10) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4],k = 7) == 6\n assert candidate(nums = [1, 1, 1, 1, 1],k = 10) == 5\n assert candidate(nums = [3, 9, 6],k = 2) == 1\n assert candidate(nums = [1, 1, 1, 1, 1],k = 5) == 5\n assert candidate(nums = [1, 1, 1],k = 0) == 3\n assert candidate(nums = [1, 100000],k = 100000) == 2\n assert candidate(nums = [1, 2, 2, 4],k = 6) == 3\n assert candidate(nums = [1, 4, 8, 13],k = 5) == 2\n assert candidate(nums = [1, 100000],k = 99999) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],k = 0) == 5\n assert candidate(nums = [100000, 100000, 100000],k = 100000) == 3\n assert candidate(nums = [5, 9, 11, 13, 15],k = 10) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],k = 10) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 3],k = 6) == 6\n assert candidate(nums = [1, 2, 2, 4],k = 3) == 3\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 10) == 10\n assert candidate(nums = [1, 1, 1, 1],k = 10) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],k = 15) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 50) == 20\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 200) == 9\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 150) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 50) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 45) == 10\n assert candidate(nums = [2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5],k = 150) == 21\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9],k = 50) == 15\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 15) == 10\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 75) == 20\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],k = 40) == 19\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 1000) == 14\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 55) == 7\n assert candidate(nums = [1, 3, 6, 10, 15],k = 25) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 6\n assert candidate(nums = [5, 7, 7, 8, 8, 10, 10, 10, 10],k = 30) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 50) == 10\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 100) == 20\n assert candidate(nums = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],k = 500000) == 10\n assert candidate(nums = [5, 7, 7, 8, 8, 10, 10, 10, 12, 12, 12, 12],k = 30) == 11\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 10) == 7\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 100) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100000],k = 199999) == 19\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],k = 500000) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 150) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 50) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5],k = 10) == 10\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9],k = 30) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 60) == 25\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 20\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1000) == 10\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 60) == 20\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 100) == 10\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 30) == 17\n assert candidate(nums = [10, 20, 30, 40, 50],k = 100) == 5\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],k = 100000) == 5\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 0) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == 10\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 50) == 10\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],k = 100) == 7\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 200) == 14\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 50) == 18\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 100) == 20\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 1500) == 17\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4],k = 50) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 200) == 20\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 100) == 10\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101],k = 500) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 200) == 20\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 15\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 20) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3000) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1000) == 20\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 100) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 50) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 100) == 10\n assert candidate(nums = [1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 100) == 40\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 300) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 14\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 150) == 17\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50],k = 100) == 6\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7],k = 100) == 21\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 200) == 30\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 20) == 14\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 50000) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],k = 200) == 29\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 15) == 13\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 250) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 100) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 500) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 14\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],k = 500000) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5],k = 50) == 20\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 12\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxFrequency", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxFrequency(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "maxFrequency", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1839, "task_id": "longest-substring-of-all-vowels-in-order", "difficulty": "Medium", "problem_description": "A string is considered beautiful if it satisfies the following conditions:\n\nEach of the 5 English vowels ('a', 'e', 'i', 'o', 'u') must appear at least once in it.\nThe letters must be sorted in alphabetical order (i.e. all 'a's before 'e's, all 'e's before 'i's, etc.).\n\nFor example, strings \"aeiou\" and \"aaaaaaeiiiioou\" are considered beautiful, but \"uaeio\", \"aeoiu\", and \"aaaeeeooo\" are not beautiful.\nGiven a string word consisting of English vowels, return the length of the longest beautiful substring of word. If no such substring exists, return 0.\nA substring is a contiguous sequence of characters in a string.\n \nExample 1:\n\nInput: word = \"aeiaaioaaaaeiiiiouuuooaauuaeiu\"\nOutput: 13\nExplanation: The longest beautiful substring in word is \"aaaaeiiiiouuu\" of length 13.\nExample 2:\n\nInput: word = \"aeeeiiiioooauuuaeiou\"\nOutput: 5\nExplanation: The longest beautiful substring in word is \"aeiou\" of length 5.\n\nExample 3:\n\nInput: word = \"a\"\nOutput: 0\nExplanation: There is no beautiful substring, so return 0.\n\n \nConstraints:\n\n1 <= word.length <= 5 * 105\nword consists of characters 'a', 'e', 'i', 'o', and 'u'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuooaauuaeiuuuuuuuuuuuuuuuuuuuuaaa\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuaauuaeiu\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuuuuuuuuuuuuuuuuuuaaaaaaeiou\") == 10\n assert candidate(word = \"aeiaaioaaaaeiioooaeiouuuaeiouuu\") == 7\n assert candidate(word = \"aeeeiiiioooauuuaeiou\") == 5\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuuuaaaaaaaaaeeeeiiiioooouuuuuu\") == 27\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuooaaeiouaaaaaaaaaaeiouuuuuuuuuuuuuuuuuuuu\") == 33\n assert candidate(word = \"aeiaaioaaaaeiioooaeiouuuaeiouuuaeiouuu\") == 7\n assert candidate(word = \"aeiaaioaaaaeiiaaaouuuooauuaeiu\") == 0\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiou\") == 5\n assert candidate(word = \"aaaaaaaaaeeeeeeeeeeiiiiiiioooooouuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\") == 68\n assert candidate(word = \"aeiaaioaaaaeiioooaeiouuu\") == 7\n assert candidate(word = \"aeiaaioaaaaeiiooouuuaeiou\") == 13\n assert candidate(word = \"a\") == 0\n assert candidate(word = \"aeiou\") == 5\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuuuuuuuuuuuuuuuuuu\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiaaaouuuooaauuaeiaaioaaaaeiiiiouuuooaauuaeiu\") == 13\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiu\") == 13\n assert candidate(word = \"aeiaaioaaaaeiiooouuuooauuaeiu\") == 13\n assert candidate(word = \"uuuuuuuuuuuuuuuuuuuu\") == 0\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().longestBeautifulSubstring", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def longestBeautifulSubstring(self, word: str) -> int:", "container": "Solution", "callable": "longestBeautifulSubstring", "parameters": [{"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1840, "task_id": "maximum-building-height", "difficulty": "Hard", "problem_description": "You want to build n new buildings in a city. The new buildings will be built in a line and are labeled from 1 to n.\nHowever, there are city restrictions on the heights of the new buildings:\n\nThe height of each building must be a non-negative integer.\nThe height of the first building must be 0.\nThe height difference between any two adjacent buildings cannot exceed 1.\n\nAdditionally, there are city restrictions on the maximum height of specific buildings. These restrictions are given as a 2D integer array restrictions where restrictions[i] = [idi, maxHeighti] indicates that building idi must have a height less than or equal to maxHeighti.\nIt is guaranteed that each building will appear at most once in restrictions, and building 1 will not be in restrictions.\nReturn the maximum possible height of the tallest building.\n \nExample 1:\n\n\nInput: n = 5, restrictions = [[2,1],[4,1]]\nOutput: 2\nExplanation: The green area in the image indicates the maximum allowed height for each building.\nWe can build the buildings with heights [0,1,2,1,2], and the tallest building has a height of 2.\nExample 2:\n\n\nInput: n = 6, restrictions = []\nOutput: 5\nExplanation: The green area in the image indicates the maximum allowed height for each building.\nWe can build the buildings with heights [0,1,2,3,4,5], and the tallest building has a height of 5.\n\nExample 3:\n\n\nInput: n = 10, restrictions = [[5,3],[2,5],[7,4],[10,3]]\nOutput: 5\nExplanation: The green area in the image indicates the maximum allowed height for each building.\nWe can build the buildings with heights [0,1,2,3,3,4,4,5,4,3], and the tallest building has a height of 5.\n\n \nConstraints:\n\n2 <= n <= 109\n0 <= restrictions.length <= min(n - 1, 105)\n2 <= idi <= n\nidi is unique.\n0 <= maxHeighti <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,restrictions = []) == 5\n assert candidate(n = 5,restrictions = [[2, 1], [4, 1]]) == 2\n assert candidate(n = 100,restrictions = [[10, 5], [50, 25], [90, 10]]) == 37\n assert candidate(n = 1000000,restrictions = [[500000, 500000]]) == 999999\n assert candidate(n = 10,restrictions = [[5, 3], [2, 5], [7, 4], [10, 3]]) == 5\n assert candidate(n = 100000,restrictions = [[1000, 50], [2000, 100], [3000, 150], [4000, 200], [5000, 250], [6000, 300], [7000, 350], [8000, 400], [9000, 450]]) == 91450\n assert candidate(n = 20,restrictions = [[5, 3], [6, 2], [7, 1], [8, 0], [9, 1], [10, 2], [11, 3], [12, 4], [13, 5], [14, 6], [15, 7]]) == 12\n assert candidate(n = 1000,restrictions = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9]]) == 109\n assert candidate(n = 200,restrictions = [[20, 100], [40, 50], [60, 75], [80, 25], [100, 100], [120, 75], [140, 50], [160, 25], [180, 0], [200, 100]]) == 62\n assert candidate(n = 100,restrictions = [[10, 5], [30, 5], [50, 5], [70, 5], [90, 5]]) == 15\n assert candidate(n = 1000000,restrictions = [[500000, 1], [500001, 1], [500002, 1], [500003, 1], [500004, 1], [500005, 1], [500006, 1], [500007, 1], [500008, 1]]) == 499993\n assert candidate(n = 10000,restrictions = [[2000, 1000], [4000, 1500], [6000, 2000], [8000, 2500]]) == 4500\n assert candidate(n = 200,restrictions = [[5, 3], [10, 2], [15, 1], [20, 2], [25, 3], [30, 2], [35, 1], [40, 2], [45, 3], [50, 2], [55, 1], [60, 2], [65, 3], [70, 2], [75, 1], [80, 2], [85, 3], [90, 2], [95, 1], [100, 2], [105, 3], [110, 2], [115, 1], [120, 2], [125, 3], [130, 2], [135, 1], [140, 2], [145, 3], [150, 2], [155, 1], [160, 2], [165, 3], [170, 2], [175, 1], [180, 2], [185, 3], [190, 2], [195, 1]]) == 6\n assert candidate(n = 100,restrictions = [[10, 9], [20, 8], [30, 7], [40, 6], [50, 5], [60, 4], [70, 3], [80, 2], [90, 1]]) == 13\n assert candidate(n = 5000,restrictions = [[50, 1000], [100, 900], [150, 800], [200, 700], [250, 600], [300, 500], [350, 400], [400, 300], [450, 200], [500, 100]]) == 4600\n assert candidate(n = 20,restrictions = [[2, 3], [5, 4], [8, 1], [15, 5], [18, 2]]) == 6\n assert candidate(n = 100,restrictions = [[10, 5], [20, 10], [30, 3], [40, 15], [50, 5], [60, 20], [70, 7], [80, 12], [90, 10], [100, 2]]) == 16\n assert candidate(n = 20,restrictions = [[3, 2], [6, 3], [9, 2], [15, 5], [18, 4]]) == 6\n assert candidate(n = 10000,restrictions = [[1000, 5000], [2000, 10000], [3000, 15000], [4000, 20000], [5000, 25000], [6000, 30000], [7000, 35000], [8000, 40000], [9000, 45000], [10000, 50000]]) == 9999\n assert candidate(n = 999,restrictions = [[999, 1]]) == 499\n assert candidate(n = 1000000000,restrictions = [[100000000, 10000000], [200000000, 20000000], [300000000, 30000000], [400000000, 40000000]]) == 640000000\n assert candidate(n = 1000000,restrictions = [[999999, 999999]]) == 999999\n assert candidate(n = 50,restrictions = [[3, 2], [5, 3], [10, 5], [15, 7], [20, 9], [25, 11], [30, 13], [35, 15], [40, 17], [45, 19], [50, 21]]) == 22\n assert candidate(n = 20,restrictions = [[3, 3], [6, 2], [9, 5], [15, 4]]) == 9\n assert candidate(n = 1000,restrictions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]]) == 950\n assert candidate(n = 500000,restrictions = [[50000, 100000], [100000, 150000], [150000, 200000], [200000, 250000], [250000, 300000]]) == 499999\n assert candidate(n = 10000,restrictions = [[1000, 500], [2000, 1000], [3000, 1500], [4000, 2000], [5000, 2500], [6000, 3000], [7000, 3500], [8000, 4000], [9000, 4500], [10000, 5000]]) == 5250\n assert candidate(n = 1000000,restrictions = [[2, 1], [4, 1], [6, 1], [8, 1], [10, 1], [12, 1], [14, 1], [16, 1], [18, 1], [20, 1]]) == 999981\n assert candidate(n = 100000,restrictions = [[10000, 5000], [30000, 15000], [50000, 25000], [70000, 30000], [90000, 35000]]) == 45000\n assert candidate(n = 1000000,restrictions = [[2, 500000], [3, 500000], [4, 500000], [5, 500000], [6, 500000], [7, 500000], [8, 500000], [9, 500000], [10, 500000]]) == 999999\n assert candidate(n = 50000000,restrictions = [[10000000, 20000000], [20000000, 10000000], [30000000, 15000000], [40000000, 5000000], [50000000, 25000000]]) == 17500000\n assert candidate(n = 500000,restrictions = [[100000, 150000], [200000, 250000], [300000, 350000], [400000, 450000]]) == 499999\n assert candidate(n = 150,restrictions = [[15, 15], [30, 30], [45, 45], [60, 60], [75, 75], [90, 90], [105, 105], [120, 120], [135, 135], [150, 150]]) == 149\n assert candidate(n = 1000,restrictions = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [550, 550], [600, 600], [650, 650], [700, 700], [750, 750], [800, 800], [850, 850], [900, 900], [950, 950], [1000, 1000]]) == 999\n assert candidate(n = 5000,restrictions = [[1000, 500], [2000, 1000], [3000, 1500], [4000, 2000]]) == 3000\n assert candidate(n = 1000,restrictions = [[100, 900], [200, 800], [300, 700], [400, 600], [500, 500], [600, 400], [700, 300], [800, 200], [900, 100]]) == 499\n assert candidate(n = 100,restrictions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25]]) == 75\n assert candidate(n = 50,restrictions = [[5, 4], [10, 3], [15, 2], [20, 1], [25, 0], [30, 1], [35, 2], [40, 3], [45, 4], [50, 5]]) == 7\n assert candidate(n = 1000,restrictions = [[50, 100], [150, 100], [250, 100], [350, 100], [450, 100], [550, 100], [650, 100], [750, 100], [850, 100], [950, 100]]) == 150\n assert candidate(n = 1000,restrictions = [[500, 500], [250, 250], [750, 750], [100, 100], [900, 900]]) == 999\n assert candidate(n = 100000,restrictions = [[1000, 500], [5000, 2500], [10000, 5000], [25000, 10000], [50000, 15000], [75000, 10000], [90000, 5000], [95000, 1000]]) == 25000\n assert candidate(n = 100,restrictions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45]]) == 55\n assert candidate(n = 100,restrictions = [[10, 10], [20, 15], [30, 20], [40, 10], [50, 25], [60, 20], [70, 15], [80, 10], [90, 5]]) == 25\n assert candidate(n = 100,restrictions = [[3, 20], [50, 10], [90, 5]]) == 29\n assert candidate(n = 100,restrictions = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1]]) == 11\n assert candidate(n = 10000,restrictions = [[500, 1000], [2500, 2000], [5000, 3000], [7500, 2000], [9500, 1000]]) == 3750\n assert candidate(n = 100,restrictions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]]) == 52\n assert candidate(n = 1000000000,restrictions = [[100000000, 99999999], [200000000, 88888888], [300000000, 77777777], [400000000, 66666666], [500000000, 55555555]]) == 555555555\n assert candidate(n = 20,restrictions = [[2, 3], [4, 2], [6, 3], [8, 2], [10, 3], [12, 2], [14, 3], [16, 2], [18, 3]]) == 5\n assert candidate(n = 200,restrictions = [[20, 1], [40, 3], [60, 5], [80, 7], [100, 9], [120, 11], [140, 13], [160, 15], [180, 17]]) == 37\n assert candidate(n = 50,restrictions = [[5, 25], [10, 15], [20, 30], [35, 20], [45, 10]]) == 27\n assert candidate(n = 1000000,restrictions = [[100000, 50000], [200000, 100000], [300000, 75000], [400000, 25000], [500000, 100000]]) == 600000\n assert candidate(n = 1000000,restrictions = [[50000, 100000], [100000, 200000], [150000, 300000], [200000, 400000], [250000, 500000], [300000, 400000], [350000, 300000], [400000, 200000], [450000, 100000]]) == 650000\n assert candidate(n = 15,restrictions = [[3, 2], [6, 3], [9, 1], [12, 4]]) == 7\n assert candidate(n = 1000000,restrictions = [[10000, 1000], [20000, 2000], [30000, 3000], [40000, 4000], [50000, 5000], [60000, 6000], [70000, 7000], [80000, 8000], [90000, 9000]]) == 919000\n assert candidate(n = 100,restrictions = [[10, 10], [20, 5], [30, 15], [40, 20], [50, 10], [60, 25], [70, 30], [80, 5], [90, 40]]) == 25\n assert candidate(n = 50,restrictions = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45]]) == 49\n assert candidate(n = 100,restrictions = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]]) == 14\n assert candidate(n = 10000,restrictions = [[2, 9999], [4, 9998], [6, 9997], [8, 9996], [10, 9995], [12, 9994], [14, 9993], [16, 9992], [18, 9991], [20, 9990]]) == 9999\n assert candidate(n = 100,restrictions = [[2, 99], [4, 98], [6, 97], [8, 96], [10, 95], [12, 94], [14, 93], [16, 92], [18, 91], [20, 90], [22, 89], [24, 88], [26, 87], [28, 86], [30, 85], [32, 84], [34, 83], [36, 82], [38, 81], [40, 80], [42, 79], [44, 78], [46, 77], [48, 76], [50, 75], [52, 74], [54, 73], [56, 72], [58, 71], [60, 70], [62, 69], [64, 68], [66, 67], [68, 66], [70, 65], [72, 64], [74, 63], [76, 62], [78, 61], [80, 60], [82, 59], [84, 58], [86, 57], [88, 56], [90, 55], [92, 54], [94, 53], [96, 52], [98, 51], [100, 50]]) == 66\n assert candidate(n = 200,restrictions = [[2, 1], [50, 50], [150, 20], [100, 30], [180, 10]]) == 64\n assert candidate(n = 1000000,restrictions = [[200000, 300000], [400000, 100000], [600000, 200000], [800000, 400000], [1000000, 500000]]) == 550000\n assert candidate(n = 1000,restrictions = [[10, 900], [20, 800], [30, 700], [40, 600], [50, 500], [60, 400], [70, 300], [80, 200], [90, 100]]) == 999\n assert candidate(n = 10000,restrictions = [[100, 50], [200, 40], [300, 30], [400, 20], [500, 10], [600, 0], [700, 10], [800, 20], [900, 30]]) == 9130\n assert candidate(n = 200,restrictions = [[10, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10], [110, 20], [120, 30], [130, 40], [140, 50], [150, 60], [160, 70], [170, 80], [180, 90], [190, 100], [200, 110]]) == 110\n assert candidate(n = 500,restrictions = [[50, 10], [100, 20], [150, 10], [200, 20], [250, 10], [300, 20], [350, 10], [400, 20], [450, 10], [500, 20]]) == 40\n assert candidate(n = 50,restrictions = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]]) == 12\n assert candidate(n = 5000,restrictions = [[500, 500], [1000, 400], [1500, 600], [2000, 500], [2500, 700], [3000, 400], [3500, 600], [4000, 500], [4500, 700], [5000, 400]]) == 850\n assert candidate(n = 500,restrictions = [[100, 10], [200, 200], [300, 150], [400, 100], [500, 50]]) == 180\n assert candidate(n = 300,restrictions = [[30, 2], [60, 4], [90, 6], [120, 8], [150, 10], [180, 12], [210, 14], [240, 16], [270, 18]]) == 48\n assert candidate(n = 100,restrictions = [[10, 5], [30, 10], [50, 5], [70, 10], [90, 5]]) == 17\n assert candidate(n = 100,restrictions = [[20, 15], [30, 25], [40, 35], [50, 45], [60, 55], [70, 65], [80, 75], [90, 85]]) == 95\n assert candidate(n = 1000,restrictions = [[10, 5], [20, 15], [30, 10], [40, 20], [50, 15], [60, 25], [70, 20], [80, 30], [90, 25], [100, 35]]) == 935\n assert candidate(n = 20,restrictions = [[3, 2], [6, 3], [15, 5], [18, 4]]) == 8\n assert candidate(n = 1000,restrictions = [[100, 100], [200, 900], [300, 300], [400, 700], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900]]) == 999\n assert candidate(n = 10000000,restrictions = [[1000000, 500000], [2000000, 1000000], [3000000, 1500000], [4000000, 2000000], [5000000, 2500000], [6000000, 3000000], [7000000, 3500000], [8000000, 4000000], [9000000, 4500000]]) == 5500000\n assert candidate(n = 500,restrictions = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]]) == 460\n assert candidate(n = 2000,restrictions = [[500, 500], [1000, 500], [1500, 500]]) == 1000\n assert candidate(n = 2000,restrictions = [[500, 100], [1000, 500], [1500, 200], [2000, 1000]]) == 700\n assert candidate(n = 200,restrictions = [[2, 198], [4, 196], [6, 194], [8, 192], [10, 190], [12, 188], [14, 186], [16, 184], [18, 182], [20, 180]]) == 199\n assert candidate(n = 10000000,restrictions = [[1000000, 1000000], [3000000, 3000000], [5000000, 5000000], [7000000, 7000000], [9000000, 9000000]]) == 9999999\n assert candidate(n = 500000,restrictions = [[100000, 100000], [200000, 200000], [300000, 300000], [400000, 400000], [500000, 500000]]) == 499999\n assert candidate(n = 100000,restrictions = [[5000, 1000], [15000, 2000], [25000, 3000], [35000, 4000], [45000, 5000], [55000, 6000], [65000, 7000], [75000, 8000], [85000, 9000], [95000, 10000]]) == 15000\n assert candidate(n = 10000,restrictions = [[500, 5000], [1000, 10000], [1500, 15000], [2000, 20000], [2500, 25000], [3000, 30000]]) == 9999\n assert candidate(n = 1000000,restrictions = [[1000, 500], [2000, 1000], [3000, 750], [4000, 1500], [5000, 1250], [6000, 2000], [7000, 1750], [8000, 2500], [9000, 2250], [10000, 3000]]) == 993000\n assert candidate(n = 10000,restrictions = [[1000, 500], [2000, 750], [3000, 1000], [4000, 1250], [5000, 1500]]) == 6500\n assert candidate(n = 1000000,restrictions = [[100000, 100000], [200000, 200000], [300000, 300000], [400000, 400000], [500000, 500000], [600000, 600000], [700000, 700000], [800000, 800000], [900000, 900000]]) == 999999\n"}, "metadata": {"canonical_parameter_names": ["n", "restrictions"], "leetcode_dataset_entry_point": "Solution().maxBuilding", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxBuilding(self, n: int, restrictions: list[list[int]]) -> int:", "container": "Solution", "callable": "maxBuilding", "parameters": [{"name": "n", "type": "int"}, {"name": "restrictions", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1844, "task_id": "replace-all-digits-with-characters", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string s that has lowercase English letters in its even indices and digits in its odd indices.\nYou must perform an operation shift(c, x), where c is a character and x is a digit, that returns the xth character after c.\n\nFor example, shift('a', 5) = 'f' and shift('x', 0) = 'x'.\n\nFor every odd index i, you want to replace the digit s[i] with the result of the shift(s[i-1], s[i]) operation.\nReturn s after replacing all digits. It is guaranteed that shift(s[i-1], s[i]) will never exceed 'z'.\nNote that shift(c, x) is not a preloaded function, but an operation to be implemented as part of the solution.\n \nExample 1:\n\nInput: s = \"a1c1e1\"\nOutput: \"abcdef\"\nExplanation: The digits are replaced as follows:\n- s[1] -> shift('a',1) = 'b'\n- s[3] -> shift('c',1) = 'd'\n- s[5] -> shift('e',1) = 'f'\nExample 2:\n\nInput: s = \"a1b2c3d4e\"\nOutput: \"abbdcfdhe\"\nExplanation: The digits are replaced as follows:\n- s[1] -> shift('a',1) = 'b'\n- s[3] -> shift('b',2) = 'd'\n- s[5] -> shift('c',3) = 'f'\n- s[7] -> shift('d',4) = 'h'\n \nConstraints:\n\n1 <= s.length <= 100\ns consists only of lowercase English letters and digits.\nshift(s[i-1], s[i]) <= 'z' for all odd indices i.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"x1y2z3a4b5c6d7e8f9g0\") == \"xyy{z}aebgcidkemfogg\"\n assert candidate(s = \"x5y5z5\") == \"x}y~z\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0\") == \"ajbjcjdjejfjgjhjijjj\"\n assert candidate(s = \"a9b9c9d9\") == \"ajbkcldm\"\n assert candidate(s = \"z0y0x0w0\") == \"zzyyxxww\"\n assert candidate(s = \"a0b0c0d0\") == \"aabbccdd\"\n assert candidate(s = \"m9l8k7j6\") == \"mvltkrjp\"\n assert candidate(s = \"z0y1x2w3\") == \"zzyzxzwz\"\n assert candidate(s = \"z0y0x0w0v0\") == \"zzyyxxwwvv\"\n assert candidate(s = \"a0b0c0d0e0f0g0h0i0j0\") == \"aabbccddeeffgghhiijj\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1\") == \"ajbjcjdjejfjgjhjij\"\n assert candidate(s = \"t1s2r3q4p5o6n7m8l9k0\") == \"tusuruqupuounumulukk\"\n assert candidate(s = \"s9r8q7p6o5n4m3l2k1j0\") == \"s|rzqxpvotnrmplnkljj\"\n assert candidate(s = \"p2r4t6v8\") == \"prrvtzv~\"\n assert candidate(s = \"m0n1o2p3\") == \"mmnooqps\"\n assert candidate(s = \"q2w3e4r5\") == \"qswzeirw\"\n assert candidate(s = \"t1t2t3t4\") == \"tutvtwtx\"\n assert candidate(s = \"a1b2c3d4e\") == \"abbdcfdhe\"\n assert candidate(s = \"p1q2r3s4t\") == \"pqqsruswt\"\n assert candidate(s = \"a1c1e1\") == \"abcdef\"\n assert candidate(s = \"z0y2x3w4v\") == \"zzy{x{w{v\"\n assert candidate(s = \"q9r8s7t6u5\") == \"qzrzsztzuz\"\n assert candidate(s = \"x2y3z4\") == \"xzy|z~\"\n assert candidate(s = \"q9r8s7t6\") == \"qzrzsztz\"\n assert candidate(s = \"s0t1u2v3w4x5y6z7\") == \"sstuuwvyw{x}yz\"\n assert candidate(s = \"m9l8k7j6i5h4g3f2e1d0\") == \"mvltkrjpinhlgjfhefdd\"\n assert candidate(s = \"s9s8s7s6\") == \"s|s{szsy\"\n assert candidate(s = \"p2o3n4m5l6\") == \"prornrmrlr\"\n assert candidate(s = \"t2r3e4w5q6p7o8i9u0y1t2r3e4w\") == \"tvrueiw|qwpwowiruuyztvrueiw\"\n assert candidate(s = \"m4n3o2p1q0r9s8t7u6v5w4x3y2z1\") == \"mqnqoqpqqqr{s{t{u{v{w{x{y{z{\"\n assert candidate(s = \"z1y2x3w4v5u6t7s8r9q0p1o2n3m4l5k6j7i8h9g0f1e2d3c4b5a6\") == \"z{y{x{w{v{u{t{s{r{qqpqoqnqmqlqkqjqiqhqggfgegdgcgbgag\"\n assert candidate(s = \"n9m8l7k6j5i4h3g2f1e0d9c8b7a6z5y4x3w2v1u0t9s8r7q6p5\") == \"nwmulskqjoimhkgifgeedmckbiagzy}x{wyvwuut}s{ryqwpu\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p0o0n0m0l0k0j0i0h0g0f0e0d0c0b0a0\") == \"zƒyxw}v{uytwsursqqppoonnmmllkkjjiihhggffeeddccbbaa\"\n assert candidate(s = \"z8y6x4w2v0u8t6s4r2q0p8o6n4m2l0k8j6i4h2g0f8e6d4c2b0a8\") == \"z‚yx|wyvvu}tzswrtqqpxounrmollksjpimhjggfnekdhcebbai\"\n assert candidate(s = \"b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9u0v1w2x3y4z5\") == \"bccedgeifkgmhoiqjskklmmonqospuqwrys{t}uuvwwyx{y}z\"\n assert candidate(s = \"m3n5o7p9q1r3s5t7u9v1w3x5y7z9a1b3c5d7e9f1g3h5i7j9\") == \"mpnsovpyqrrusxt{u~vwwzx}y€zƒabbechdkenfggjhmipjs\"\n assert candidate(s = \"c3d2e1f0g9h8i7j6k5l4m3n2o1p0q9r8\") == \"cfdfefffgphpipjpkplpmpnpopppqzrz\"\n assert candidate(s = \"d3c2b1a0z9y8x7w6v5u4t3s2r1q0p9o8n7m6l5k4j3i2h1g0f9\") == \"dgcebcaazƒyxw}v{uytwsursqqpyownumslqkojmikhiggfo\"\n assert candidate(s = \"a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7\") == \"acbecgdiekfmgohqiijkkmlomqnsoupwqyr{sstuuwvyw{x}yz\"\n assert candidate(s = \"d3f5h7j9l1n3p5r7t9v1x3z5b7d9f1h3j5l7n9p1r3t5v7x9\") == \"dgfkhojslmnqpuryt}vwx{zbidmfghkjolsnwpqrutyv}x\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p9o8n7m6l5k4j3i2h1g0f9e8d7c6b5a4\") == \"zƒyxw}v{uytwsursqqpyownumslqkojmikhiggfoemdkcibgae\"\n assert candidate(s = \"z1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4\") == \"z{acbecgdiekfmgohqiijkkmlomqnsoupwqyr{sstuuwvyw{\"\n assert candidate(s = \"v1u2t3s4r5q6p7o8n9m0l1k2j3i4h5g6f7e8d9c0b1a2z3y4x5\") == \"vwuwtwswrwqwpwownwmmlmkmjmimhmgmfmemdmccbcacz}y}x}\"\n assert candidate(s = \"b2c4d6e8f0g2h4i6j8k0l2m4n6o8p0q2r4s6t8u0v2w4x6y8z0a2\") == \"bdcgdjemffgihliojrkklnmqntowppqsrvsyt|uuvxw{x~yzzac\"\n assert candidate(s = \"a9z8y7x6w5v4u3t2s1r0\") == \"ajz‚y€x~w|vzuxtvstrr\"\n assert candidate(s = \"n7m6l5k4j3i2h1g0f5e4d3\") == \"numslqkojmikhiggfkeidg\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == \"abbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{\"\n assert candidate(s = \"b5c6d7e8f9g0h1i2j3k4l5m6n7o8p9q0r1s2t3u4v5w6x7y8z9\") == \"bgcidkemfogghiikjmkolqmsnuowpyqqrssutwuyv{w}xyzƒ\"\n assert candidate(s = \"q0r2s4t6u8v0w2x4y6z8\") == \"qqrtswtzu}vvwyx|yz‚\"\n assert candidate(s = \"s5r4q3p2o1n0m9l8k7j6i5h4g3f2e1d0c9b8a7z6y5x4w3v2u1t0s9\") == \"sxrvqtpropnnmvltkrjpinhlgjfhefddclbjahz€y~x|wzvxuvtts|\"\n assert candidate(s = \"x2y3z2a3b4c5d6e7f8g9h0i1j2k3l4m5n6o7p8q9r0s1t2u3v4w5x6y7z8a9\") == \"xzy|z|adbfchdjelfngphhijjlknlpmrntovpxqzrrsttvuxvzw|x~y€z‚aj\"\n assert candidate(s = \"s1t2u3v4w5x6y7z8a9b0c1d2e3f4g5h6i7j8k9l0m1n2o3p4q5r6\") == \"sttvuxvzw|x~y€z‚ajbbcddfehfjglhnipjrktllmnnporptqvrx\"\n assert candidate(s = \"t4r2q0p8o6n4m2l0k8j6i4h2g0f8e6d4c2b0a8y6x4w2v0u8t6s4\") == \"txrtqqpxounrmollksjpimhjggfnekdhcebbaiyx|wyvvu}tzsw\"\n assert candidate(s = \"a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0\") == \"acbecgdiekfmgohqiijkkmlomqnsoupwqyr{ss\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9\") == \"abbdcfdhejflgnhpirjjkllnmpnrotpvqxrzs|ttuvvxwzx|y~z€ahbjcl\"\n assert candidate(s = \"x2y4z6a8b0c2d4e6f8g0h2i4j6k8l0m2n4o6p8q0r2s4t6u8v0\") == \"xzy}z€aibbcedhekfngghjimjpksllmonroupxqqrtswtzu}vv\"\n assert candidate(s = \"t4s3r2q1p0o9n8m7l6k5j4i3h2g1f0\") == \"txsvrtqrppoxnvmtlrkpjnilhjghff\"\n assert candidate(s = \"a2c4e6g8i0k2m4o6q8s0u2w4y6b8d0f2h4j6l8n0p2r4t6v8x0\") == \"accgekgoiikmmqouqyssuww{ybjddfhhljpltnnprrvtzv~xx\"\n assert candidate(s = \"m1n2o3p4q5r6s7t8u9v0w1x2y3z4\") == \"mnnporptqvrxszt|u~vvwxxzy|z~\"\n assert candidate(s = \"m7l6k5j4i3h2g1f0e9d8c7b6a5\") == \"mtlrkpjnilhjghffendlcjbhaf\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j8i7h6g5f4e3d2c1b0a9\") == \"abbdcfdhejflgnhpirjriphnglfjehdfcdbbaj\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0\") == \"zƒyxw}v{uytwsursqq\"\n assert candidate(s = \"y7x6w5v4u3t2s1r0q9p8o7n6m5l4k3j2i1h0g9f8e7d6c5b4a3z2y1x0w9v8u7t6s5r4q3p2o1n0\") == \"y€x~w|vzuxtvstrrqzpxovntmrlpknjlijhhgpfneldjchbfadz|yzxxw€v~u|tzsxrvqtpropnn\"\n assert candidate(s = \"z2y4x6w8v0u2t4s6r8q0p2o4n6m8l0k2j4i6h8g0f2e4d6c8b0\") == \"z|y}x~wvvuwtxsyrzqqprosntmullkmjniohpggfheidjckbb\"\n assert candidate(s = \"a2b4c6d8e0f1g3h5i7j9\") == \"acbfcidleefggjhmipjs\"\n assert candidate(s = \"b2d3f4h5j6l7n8p9r0t1v2x3z4\") == \"bddgfjhmjplsnvpyrrtuvxx{z~\"\n assert candidate(s = \"q2r3s4t5u6v7w8x9y0z1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7\") == \"qsruswtyu{v}wxyyz{acbecgdiekfmgohqiijkkmlomqnsoupw\"\n assert candidate(s = \"x9y8z7a6b5c4d3e2f1g0h9i8j7k6l5m4n3o2p1q0r9s8t7u6\") == \"xyzagbgcgdgegfggghqiqjqkqlqmqnqoqpqqqr{s{t{u{\"\n assert candidate(s = \"t2h4n6m8g0p2r4l6t8s0q2e4v6s8g0t2l4m6b8c0t2r4l6n8m0\") == \"tvhlntmuggprrvlrt|ssqseiv|s{ggtvlpmsbjcctvrvlrnvmm\"\n assert candidate(s = \"x2y3z4a5b6c7d8e9f0g1h2i3j4\") == \"xzy|z~afbhcjdlenffghhjiljn\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0k9l8m7n6\") == \"ajbjcjdjejfjgjhjijjjktltmtnt\"\n assert candidate(s = \"n5n4n3n2n1n0n9n8n7n6\") == \"nsnrnqnpnonnnwnvnunt\"\n assert candidate(s = \"d7c6b5a4z3y2x1w0v9u8t7s6r5q4p3o2n1\") == \"dkcibgaez}y{xywwvu}t{syrwqupsoqno\"\n assert candidate(s = \"q7r5s3t1u9v7w5x3y1z9a7b5c3d1e9f7g5h3i1j9k7l5m3n1o9p7\") == \"qxrwsvtuu~v}w|x{yzzƒahbgcfdeenfmglhkijjskrlqmpnooxpw\"\n assert candidate(s = \"x2y4z6a8b0c2d4e6f8g0h2i4j6k8l0m2n4o6p8q0r2s4t6u8v0w2y4z6\") == \"xzy}z€aibbcedhekfngghjimjpksllmonroupxqqrtswtzu}vvwyy}z€\"\n assert candidate(s = \"n5m4l3k2j1i0h9g8f7e6d5c4b3a2z1y0x9w8v7u6t5s4r3q2p1o0\") == \"nsmqlokmjkiihqgofmekdicgbeacz{yyxwv}u{tyswruqspqoo\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1\") == \"abbccddeeffgghhiijjk\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p\") == \"zƒyxw}v{uytwsursqqp\"\n assert candidate(s = \"a1z2y3x4w5v6u7t8s9r0q1p2o3n4m5l6k7j8i9h0g1f2e3d4c5b6a7\") == \"abz|y|x|w|v|u|t|s|rrqrprornrmrlrkrjrirhhghfhehdhchbhah\"\n assert candidate(s = \"n9m8l7k6j5i4h3g2f1e0d9c8b7a6n9m8l7k6j5i4h3g2f1e0\") == \"nwmulskqjoimhkgifgeedmckbiagnwmulskqjoimhkgifgee\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0a1b2c3d4\") == \"abbdcfdhejflgnhpirjjabbdcfdhejflgnhpirjjabbdcfdh\"\n assert candidate(s = \"b5c3d7e2f4g6h1i5j3k7l2m4n6o1p5q3r7s2t4u6v1w5x3y7z2\") == \"bgcfdkegfjgmhiinjmkrlnmqntoppuqtrysutxu{vww|x{y€z|\"\n assert candidate(s = \"l8k7j6i5h4g3f2e1d0c9b8a7z6y5x4w3v2u1t0s9r8q7p6o5n4m3l2\") == \"ltkrjpinhlgjfhefddclbjahz€y~x|wzvxuvtts|rzqxpvotnrmpln\"\n assert candidate(s = \"z1y2x3w4v5u6t7s8r9q0p1o2n3m4\") == \"z{y{x{w{v{u{t{s{r{qqpqoqnqmq\"\n assert candidate(s = \"t2r3q4p5o6n7m8l9k0j1i2h3g4f5e6d7c8b9a0\") == \"tvruqupuounumulukkjkikhkgkfkekdkckbkaa\"\n assert candidate(s = \"t8r7e6w5q4u3i2o1p0l9k8j7h6g5f4d3c2b1a0\") == \"t|ryekw|quuxikopppluksjqhnglfjdgcebcaa\"\n assert candidate(s = \"a1c2e3g4i5k6m7o8q9s0u1w2y3\") == \"abceehgkinkqmtowqzssuvwyy|\"\n assert candidate(s = \"q9r8s7t6u5v4w3x2y1z0a9b8c7d6e5f4g3h2i1j0k9l8m7n6o5p4\") == \"qzrzsztzuzvzwzxzyzzzajbjcjdjejfjgjhjijjjktltmtntotpt\"\n assert candidate(s = \"t0u2v4w6x8y0z2a4b6c8d0e2f4g6h8i0j2k4l6m8n0o2p4q6r8s0t2u4v6w8x0y2z4\") == \"ttuwvzw}x€yyz|aebhckddegfjgmhpiijlkolrmunnoqptqwrzsstvuyv|wxxy{z~\"\n assert candidate(s = \"q2r3s4t5u6v7w8x9y0z1\") == \"qsruswtyu{v}wxyyz{\"\n assert candidate(s = \"s1t2u3v4w5x6y7z8a9b0c1d2e3f4g5h6i7j8k9l0m1n2o3p4q5\") == \"sttvuxvzw|x~y€z‚ajbbcddfehfjglhnipjrktllmnnporptqv\"\n assert candidate(s = \"b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6\") == \"bccedgeifkgmhoiqjskklmmonqospuqw\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0k9l8\") == \"ajbjcjdjejfjgjhjijjjktlt\"\n assert candidate(s = \"v9w8x7y6z5a4b3c2d1e0f9g8h7\") == \"vwxyzaebecedeeefogoho\"\n assert candidate(s = \"b5c7d9e2f0g1h3i5j7k9l1m3n5o7p9q1r3s5t7u9\") == \"bgcjdmegffghhkinjqktlmmpnsovpyqrrusxt{u~\"\n assert candidate(s = \"x9y8z7a6b5c4d3e2f1g0h9i8j7k6l5m4n3o2p1q0r9\") == \"xyzagbgcgdgegfggghqiqjqkqlqmqnqoqpqqqr{\"\n assert candidate(s = \"z0y0x0w0v0u0t0s0r0q0p0o0n0m0l0k0j0i0h0g0f0e0d0c0b0a0z0y0x0w0v0u0t0s0r0q0p0o0n0m0l0k0j0i0h0g0f0e0d0c0b0a0\") == \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaazzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\"\n assert candidate(s = \"a9z8y7x6w5v4u3t2s1r0q9p8o7n6m5l4k3j2i1h0g9f8e7d6c5b4a3\") == \"ajz‚y€x~w|vzuxtvstrrqzpxovntmrlpknjlijhhgpfneldjchbfad\"\n assert candidate(s = \"y0x1w2v3u4t5s6r7q8p9o0n1m2l3k4j5i6h7g8f9e0d1c2b3a4\") == \"yyxywyvyuytysyryqypyoonomolokojoiohogofoeedecebeae\"\n assert candidate(s = \"n5m4l3k2j1i0h9g8f7e6d5c4b3a2\") == \"nsmqlokmjkiihqgofmekdicgbeac\"\n assert candidate(s = \"a2b4c6d8e0f2g4h6i8j0k2l4m6n8o0p2q4r6s8t0u2v4w6x8y0z2\") == \"acbfcidleefhgkhniqjjkmlpmsnvooprqurxs{ttuwvzw}x€yyz|\"\n assert candidate(s = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z2\") == \"acbdcedfegfhgihjikjlkmlnmonpoqprqsrtsutvuwvxwyxzy{z|\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0k9l8m7n6o5p4q3r2s1t0u9v8w7x6y5z4\") == \"ajbjcjdjejfjgjhjijjjktltmtntotptqtrtstttu~v~w~x~y~z~\"\n assert candidate(s = \"t1s2r3q4p5o6n7m8l9k0j1i2h3g4f5e6d7c8b9a0z1y2x3w4v5u\") == \"tusuruqupuounumulukkjkikhkgkfkekdkckbkaaz{y{x{w{v{u\"\n assert candidate(s = \"z1y2x3w4v5u6t7s8r9q0p1o2n3\") == \"z{y{x{w{v{u{t{s{r{qqpqoqnq\"\n assert candidate(s = \"y2x3w4v5u6t7s8r9q0p1o2n3m4l5k6j7i8h9g0f1e2d3c4b5a6\") == \"y{x{w{v{u{t{s{r{qqpqoqnqmqlqkqjqiqhqggfgegdgcgbgag\"\n assert candidate(s = \"y3x5w7v9u1t3s5r7q9p1o3n5m7l9k1j3i5h7g9f1e3d5c7b9a1\") == \"y|x}w~vuvtwsxryqzpqornsmtlukljminhogpfgehdicjbkab\"\n assert candidate(s = \"s9r8q7p6o5n4m3l2k1j0i9h8g7f6e5d4c3b2a1z0y9x8w7v6u5t4s3r2q1p0\") == \"s|rzqxpvotnrmplnkljjirhpgnflejdhcfbdabzzy‚x€w~v|uztxsvrtqrpp\"\n assert candidate(s = \"m8n7o6p5q4r3s2t1u0v9w8x7y6z5a4b3c2d1e0f9g8h7i6j5k4l3m2\") == \"munuoupuqurusutuuuvwxyzaebecedeeefogohoiojokolomo\"\n assert candidate(s = \"q2w3e4r5t6y7u8i9o0p1a2s3d4f5g6h7j8k9l0\") == \"qswzeirwtzy€u}iroopqacsvdhfkgmhojrktll\"\n assert candidate(s = \"b5c6d7e8f9g0h1i2j3k4l5\") == \"bgcidkemfogghiikjmkolq\"\n assert candidate(s = \"m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2g3h4i5j6k7l8\") == \"mpnrotpvqxrzs|ttuvvxwzx|y~z€ahbjclddeffhgjhlinjpkrlt\"\n assert candidate(s = \"q1w2e3r4t5y6u7i8o9p0a1s2d3f4g5\") == \"qrwyehrvtyyu|iqoxppabsudgfjgl\"\n assert candidate(s = \"q2w3e4r5t6y7u8i9o0p1a2s3d4f5g6h7j8k9l0z1x2c3v4b5n6m7\") == \"qswzeirwtzy€u}iroopqacsvdhfkgmhojrktllz{xzcfvzbgntmt\"\n assert candidate(s = \"n4m3l2k1j0i9h8g7f6e5d4c3b2a1z0y9x8w7v6u5t4s3r2q1p0\") == \"nrmplnkljjirhpgnflejdhcfbdabzzy‚x€w~v|uztxsvrtqrpp\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().replaceDigits", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def replaceDigits(self, s: str) -> str:", "container": "Solution", "callable": "replaceDigits", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1846, "task_id": "maximum-element-after-decreasing-and-rearranging", "difficulty": "Medium", "problem_description": "You are given an array of positive integers arr. Perform some operations (possibly none) on arr so that it satisfies these conditions:\n\nThe value of the first element in arr must be 1.\nThe absolute difference between any 2 adjacent elements must be less than or equal to 1. In other words, abs(arr[i] - arr[i - 1]) <= 1 for each i where 1 <= i < arr.length (0-indexed). abs(x) is the absolute value of x.\n\nThere are 2 types of operations that you can perform any number of times:\n\nDecrease the value of any element of arr to a smaller positive integer.\nRearrange the elements of arr to be in any order.\n\nReturn the maximum possible value of an element in arr after performing the operations to satisfy the conditions.\n \nExample 1:\n\nInput: arr = [2,2,1,2,1]\nOutput: 2\nExplanation: \nWe can satisfy the conditions by rearranging arr so it becomes [1,2,2,2,1].\nThe largest element in arr is 2.\n\nExample 2:\n\nInput: arr = [100,1,1000]\nOutput: 3\nExplanation: \nOne possible way to satisfy the conditions is by doing the following:\n1. Rearrange arr so it becomes [1,100,1000].\n2. Decrease the value of the second element to 2.\n3. Decrease the value of the third element to 3.\nNow arr = [1,2,3], which satisfies the conditions.\nThe largest element in arr is 3.\n\nExample 3:\n\nInput: arr = [1,2,3,4,5]\nOutput: 5\nExplanation: The array already satisfies the conditions, and the largest element is 5.\n\n \nConstraints:\n\n1 <= arr.length <= 105\n1 <= arr[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [3, 2, 1]) == 3\n assert candidate(arr = [5, 4, 3, 2, 1]) == 5\n assert candidate(arr = [1, 1000000000, 2, 3, 4]) == 5\n assert candidate(arr = [9, 7, 5, 3, 1]) == 5\n assert candidate(arr = [5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [1000000000, 1, 1000000000, 1, 1000000000]) == 4\n assert candidate(arr = [1, 10, 20, 30, 40]) == 5\n assert candidate(arr = [1, 1000000000, 2, 1000000000, 3]) == 5\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [100, 1, 1000]) == 3\n assert candidate(arr = [1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [1, 10, 100, 1000, 10000]) == 5\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [2, 3, 4, 5, 6]) == 5\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [2, 2, 1, 2, 1]) == 2\n assert candidate(arr = [1, 3, 5, 7, 9]) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 4\n assert candidate(arr = [999999999, 1, 999999998, 2, 999999997, 3, 999999996, 4, 999999995, 5]) == 10\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 4\n assert candidate(arr = [1, 3, 6, 10, 15, 21]) == 6\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10]) == 10\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1]) == 7\n assert candidate(arr = [1000000000, 1, 1000000000, 1, 1000000000]) == 4\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(arr = [1, 100, 2, 101, 3, 102, 4, 103, 5, 104]) == 10\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 9]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [50, 25, 75, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 13\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 5\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1]) == 5\n assert candidate(arr = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997]) == 8\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 16\n assert candidate(arr = [1, 1000000000, 2, 999999999, 3, 999999998]) == 6\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 20\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 10\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 20\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 20\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(arr = [5, 3, 1, 4, 2]) == 5\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 15\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 5\n assert candidate(arr = [100, 50, 20, 10, 5, 2, 1, 2, 5, 10, 20, 50, 100, 150, 200, 250, 300]) == 16\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(arr = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 13\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]) == 15\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(arr = [10, 1, 2, 2, 3, 4, 5]) == 6\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 10\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 15\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n assert candidate(arr = [10, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 20\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 20\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [50, 40, 30, 20, 10, 5, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 2\n assert candidate(arr = [5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(arr = [2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7]) == 8\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 10\n assert candidate(arr = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 3\n assert candidate(arr = [50, 40, 30, 20, 10, 1, 2, 3, 4, 5]) == 10\n assert candidate(arr = [1, 999999999, 999999998, 999999997, 999999996, 999999995]) == 6\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 10\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000]) == 5\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1, 1, 1]) == 4\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(arr = [1000000000, 999999999, 1000000001, 2, 3]) == 5\n assert candidate(arr = [999999999, 999999998, 999999997, 999999996, 999999995, 1]) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]) == 10\n assert candidate(arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(arr = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1]) == 5\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10]) == 10\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 20\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [5, 4, 3, 2, 1, 1, 1]) == 5\n assert candidate(arr = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 11\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 100, 1000]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 30\n assert candidate(arr = [10, 5, 15, 20, 1, 3, 8]) == 7\n assert candidate(arr = [5, 4, 3, 2, 1]) == 5\n assert candidate(arr = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == 10\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5]) == 15\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 20\n assert candidate(arr = [1000000000, 1, 1000000000, 2, 1000000000, 3]) == 6\n assert candidate(arr = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 5\n assert candidate(arr = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [3, 3, 3, 3, 3, 2, 2, 2, 1, 1]) == 3\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 10\n assert candidate(arr = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(arr = [1, 1000000000, 2, 999999999, 3]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [1, 1000000000, 2, 999999999, 3, 999999998]) == 6\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 2\n assert candidate(arr = [5, 4, 3, 2, 1, 1, 1]) == 5\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 15\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5]) == 5\n assert candidate(arr = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 15\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 21\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 15\n assert candidate(arr = [1, 2, 3, 100, 200, 300, 400, 500]) == 8\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().maximumElementAfterDecrementingAndRearranging", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumElementAfterDecrementingAndRearranging(self, arr: list[int]) -> int:", "container": "Solution", "callable": "maximumElementAfterDecrementingAndRearranging", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1847, "task_id": "closest-room", "difficulty": "Hard", "problem_description": "There is a hotel with n rooms. The rooms are represented by a 2D integer array rooms where rooms[i] = [roomIdi, sizei] denotes that there is a room with room number roomIdi and size equal to sizei. Each roomIdi is guaranteed to be unique.\nYou are also given k queries in a 2D array queries where queries[j] = [preferredj, minSizej]. The answer to the jth query is the room number id of a room such that:\n\nThe room has a size of at least minSizej, and\nabs(id - preferredj) is minimized, where abs(x) is the absolute value of x.\n\nIf there is a tie in the absolute difference, then use the room with the smallest such id. If there is no such room, the answer is -1.\nReturn an array answer of length k where answer[j] contains the answer to the jth query.\n \nExample 1:\n\nInput: rooms = [[2,2],[1,2],[3,2]], queries = [[3,1],[3,3],[5,2]]\nOutput: [3,-1,3]\nExplanation: The answers to the queries are as follows:\nQuery = [3,1]: Room number 3 is the closest as abs(3 - 3) = 0, and its size of 2 is at least 1. The answer is 3.\nQuery = [3,3]: There are no rooms with a size of at least 3, so the answer is -1.\nQuery = [5,2]: Room number 3 is the closest as abs(3 - 5) = 2, and its size of 2 is at least 2. The answer is 3.\nExample 2:\n\nInput: rooms = [[1,4],[2,3],[3,5],[4,1],[5,2]], queries = [[2,3],[2,4],[2,5]]\nOutput: [2,1,3]\nExplanation: The answers to the queries are as follows:\nQuery = [2,3]: Room number 2 is the closest as abs(2 - 2) = 0, and its size of 3 is at least 3. The answer is 2.\nQuery = [2,4]: Room numbers 1 and 3 both have sizes of at least 4. The answer is 1 since it is smaller.\nQuery = [2,5]: Room number 3 is the only room with a size of at least 5. The answer is 3.\n \nConstraints:\n\nn == rooms.length\n1 <= n <= 105\nk == queries.length\n1 <= k <= 104\n1 <= roomIdi, preferredj <= 107\n1 <= sizei, minSizej <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8]],queries = [[15, 4], [25, 7], [35, 2]]) == [10, 30, 30]\n assert candidate(rooms = [[5, 5], [10, 5], [15, 5], [20, 5]],queries = [[7, 5], [12, 5], [17, 5], [22, 5]]) == [5, 10, 15, 20]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == [1, 2, 3, 4, 5, -1]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3]],queries = [[15, 3], [25, 4], [35, 5]]) == [10, 20, 10]\n assert candidate(rooms = [[2, 2], [1, 2], [3, 2]],queries = [[3, 1], [3, 3], [5, 2]]) == [3, -1, 3]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3]],queries = [[10, 5], [25, 3], [15, 4]]) == [10, 20, 10]\n assert candidate(rooms = [[5, 10], [10, 10], [15, 10]],queries = [[5, 10], [10, 10], [15, 10], [20, 10]]) == [5, 10, 15, 15]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300]],queries = [[150, 150], [250, 250], [350, 350]]) == [200, 300, -1]\n assert candidate(rooms = [[7, 10], [6, 9], [5, 8], [4, 7], [3, 6]],queries = [[7, 10], [6, 9], [5, 8], [4, 7], [3, 6]]) == [7, 6, 5, 4, 3]\n assert candidate(rooms = [[7, 10], [15, 7], [25, 12]],queries = [[10, 10], [15, 7], [30, 10]]) == [7, 15, 25]\n assert candidate(rooms = [[1, 4], [2, 3], [3, 5], [4, 1], [5, 2]],queries = [[2, 3], [2, 4], [2, 5]]) == [2, 1, 3]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],queries = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 7]],queries = [[10, 5], [25, 4], [40, 8]]) == [10, 30, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5], [15, 10], [25, 15], [35, 20], [45, 25], [55, 30], [65, 35], [75, 40], [85, 45], [95, 50]]) == [5, 10, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998]],queries = [[10000000, 10000000], [9999999, 9999999], [9999998, 9999998]]) == [1, 2, 3]\n assert candidate(rooms = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]],queries = [[1, 1500], [2, 1400], [3, 1300], [4, 1200], [5, 1100], [6, 1000], [7, 900], [8, 800], [9, 700], [10, 600]]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [[10, 5], [9, 15], [8, 25], [7, 35], [6, 45], [5, 55], [4, 65], [3, 75], [2, 85], [1, 95]]) == [10, 9, 8, 7, 6, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996], [6, 9999995], [7, 9999994], [8, 9999993], [9, 9999992], [10, 9999991]],queries = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996], [6, 9999995], [7, 9999994], [8, 9999993], [9, 9999992], [10, 9999991], [11, 9999990]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]\n assert candidate(rooms = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997], [5, 999996], [6, 999995], [7, 999994], [8, 999993], [9, 999992], [10, 999991]],queries = [[1, 1000000], [2, 1000000], [3, 1000000], [4, 1000000], [5, 1000000], [6, 1000000], [7, 1000000], [8, 1000000], [9, 1000000], [10, 1000000]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rooms = [[10000, 5000], [20000, 4000], [30000, 3000], [40000, 2000], [50000, 1000]],queries = [[5000, 3000], [15000, 2000], [25000, 1000], [35000, 500], [45000, 1]]) == [10000, 10000, 20000, 30000, 40000]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]],queries = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]\n assert candidate(rooms = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95]],queries = [[1, 1], [10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, -1]\n assert candidate(rooms = [[1, 1], [10000000, 10000000]],queries = [[5000000, 1], [5000000, 10000000], [1, 1], [10000000, 10000000], [5000000, 5000000]]) == [1, 10000000, 1, 10000000, 10000000]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],queries = [[150, 100], [250, 200], [350, 300], [450, 400], [550, 500], [650, 600], [750, 700], [850, 800], [950, 900], [1050, 1000]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(rooms = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]],queries = [[3, 1], [6, 2], [9, 3], [12, 4], [15, 5], [18, 6], [21, 7], [24, 8], [27, 9], [30, 10], [33, 11]]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, -1]\n assert candidate(rooms = [[5, 10], [10, 9], [15, 8], [20, 7], [25, 6], [30, 5], [35, 4]],queries = [[8, 7], [13, 6], [18, 5], [23, 4], [28, 3], [33, 2], [38, 1]]) == [10, 15, 20, 25, 30, 35, 35]\n assert candidate(rooms = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70], [75, 80], [85, 90], [95, 100]],queries = [[10, 5], [20, 15], [30, 25], [40, 35], [50, 45], [60, 55], [70, 65], [80, 75], [90, 85], [100, 95], [110, 105]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, -1]\n assert candidate(rooms = [[10000, 10000], [20000, 20000], [30000, 30000], [40000, 40000], [50000, 50000]],queries = [[5000, 9000], [15000, 19000], [25000, 29000], [35000, 39000], [45000, 49000]]) == [10000, 20000, 30000, 40000, 50000]\n assert candidate(rooms = [[1, 1], [10000000, 10000000], [5000000, 5000000], [1000000, 1000000], [100000, 100000], [10000, 10000], [1000, 1000], [100, 100], [10, 10], [100000000, 100000000]],queries = [[1, 1], [10000000, 10000000], [5000000, 5000000], [1000000, 1000000], [100000, 100000], [10000, 10000], [1000, 1000], [100, 100], [10, 10], [100000000, 100000000]]) == [1, 10000000, 5000000, 1000000, 100000, 10000, 1000, 100, 10, 100000000]\n assert candidate(rooms = [[1000, 5000], [2000, 4000], [3000, 3000], [4000, 2000], [5000, 1000]],queries = [[1500, 3000], [2500, 2000], [3500, 1000], [4500, 500], [5500, 1]]) == [1000, 2000, 3000, 4000, 5000]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450], [550, 550]]) == [100, 200, 300, 400, 500, -1]\n assert candidate(rooms = [[100000, 1], [100001, 1], [100002, 1], [100003, 1], [100004, 1], [100005, 1], [100006, 1], [100007, 1], [100008, 1], [100009, 1]],queries = [[100000, 2], [100001, 2], [100002, 2], [100003, 2], [100004, 2], [100005, 2], [100006, 2], [100007, 2], [100008, 2], [100009, 2]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1]\n assert candidate(rooms = [[1, 10], [10, 20], [100, 30], [1000, 40], [10000, 50]],queries = [[5, 5], [50, 15], [500, 25], [5000, 35], [50000, 45]]) == [1, 10, 100, 1000, 10000]\n assert candidate(rooms = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8]],queries = [[5, 1], [50, 2], [500, 3], [5000, 4], [50000, 5], [500000, 6], [5000000, 7], [50000000, 8], [50000000, 9], [50000000, 10]]) == [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, -1, -1]\n assert candidate(rooms = [[10000000, 10000000], [1, 1], [5000000, 5000000], [2, 2], [9999999, 9999999]],queries = [[10000000, 10000000], [5000000, 5000000], [2, 1], [10000000, 1], [1, 10000000]]) == [10000000, 5000000, 2, 10000000, 10000000]\n assert candidate(rooms = [[500, 1000], [1000, 900], [1500, 800], [2000, 700], [2500, 600], [3000, 500], [3500, 400], [4000, 300], [4500, 200], [5000, 100]],queries = [[100, 500], [600, 400], [1100, 300], [1600, 200], [2100, 100], [2600, 50], [3100, 1], [3600, 1], [4100, 1], [4600, 1]]) == [500, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500]\n assert candidate(rooms = [[1, 10], [10, 9], [100, 8], [1000, 7], [10000, 6]],queries = [[1, 10], [10, 9], [100, 8], [1000, 7], [10000, 6], [5, 5], [50, 5], [500, 5], [5000, 5], [50000, 5]]) == [1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95]]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996], [6, 9999995]]) == [1, 2, 3, 4, 5, 5]\n assert candidate(rooms = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == [5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, -1]\n assert candidate(rooms = [[1, 5], [10, 15], [20, 25], [30, 35], [40, 45], [50, 55]],queries = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65]]) == [1, 10, 20, 30, 40, 50, -1]\n assert candidate(rooms = [[100, 100], [200, 90], [300, 80], [400, 70], [500, 60], [600, 50], [700, 40], [800, 30], [900, 20], [1000, 10]],queries = [[150, 80], [250, 70], [350, 60], [450, 50], [550, 40], [650, 30], [750, 20], [850, 10], [950, 5], [1050, 1]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(rooms = [[1, 10], [20, 9], [30, 8], [40, 7], [50, 6], [60, 5], [70, 4], [80, 3], [90, 2], [100, 1]],queries = [[15, 3], [25, 4], [35, 5], [45, 6], [55, 7], [65, 8], [75, 9], [85, 10], [95, 11], [105, 12]]) == [20, 20, 30, 40, 40, 30, 20, 1, -1, -1]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]],queries = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[10000000, 1], [9999999, 2], [9999998, 3], [9999997, 4], [9999996, 5], [9999995, 6], [9999994, 7], [9999993, 8], [9999992, 9], [9999991, 10]],queries = [[9999995, 3], [9999994, 4], [9999993, 5], [9999992, 6], [9999991, 7], [9999990, 8], [9999989, 9], [9999988, 10]]) == [9999995, 9999994, 9999993, 9999992, 9999991, 9999991, 9999991, 9999991]\n assert candidate(rooms = [[1, 10], [10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10]],queries = [[5, 10], [15, 10], [25, 10], [35, 10], [45, 10], [55, 10], [65, 10], [75, 10], [85, 10], [95, 10]]) == [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]\n assert candidate(rooms = [[10000, 100], [20000, 200], [30000, 300], [40000, 400], [50000, 500], [60000, 600], [70000, 700], [80000, 800], [90000, 900], [100000, 1000]],queries = [[5000, 50], [15000, 150], [25000, 250], [35000, 350], [45000, 450], [55000, 550], [65000, 650], [75000, 750], [85000, 850], [95000, 950]]) == [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]\n assert candidate(rooms = [[1, 10000000], [2, 9000000], [3, 8000000], [4, 7000000], [5, 6000000]],queries = [[1, 10000000], [2, 9000000], [3, 8000000], [4, 7000000], [5, 6000000], [10000000, 1]]) == [1, 2, 3, 4, 5, 5]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]]) == [5, 5, 5, 5, 5, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [[1, 9999999], [2, 9999998], [3, 9999997], [4, 9999996], [5, 9999995]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[100, 100], [200, 90], [300, 80], [400, 70], [500, 60]],queries = [[150, 85], [250, 75], [350, 65], [450, 55], [550, 45]]) == [100, 200, 300, 400, 500]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [100, 9], [100, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rooms = [[1, 1], [10000000, 10000000]],queries = [[5000000, 1], [5000000, 10000000], [1, 1], [10000000, 10000000], [5000000, 5000000]]) == [1, 10000000, 1, 10000000, 10000000]\n assert candidate(rooms = [[5, 1000], [15, 900], [25, 800], [35, 700], [45, 600], [55, 500], [65, 400], [75, 300], [85, 200], [95, 100]],queries = [[10, 900], [20, 800], [30, 700], [40, 600], [50, 500], [60, 400], [70, 300], [80, 200], [90, 100], [100, 90]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [[5, 15], [15, 25], [25, 35], [35, 45], [45, 55], [55, 65], [65, 75], [75, 85], [85, 95], [95, 105]]) == [20, 30, 40, 50, 60, 70, 80, 90, 100, -1]\n assert candidate(rooms = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997], [5, 999996], [6, 999995], [7, 999994], [8, 999993], [9, 999992], [10, 999991]],queries = [[500000, 999998], [1000000, 999997], [1500000, 999996], [2000000, 999995], [2500000, 999994], [3000000, 999993], [3500000, 999992], [4000000, 999991], [4500000, 999990], [5000000, 999989]]) == [3, 4, 5, 6, 7, 8, 9, 10, 10, 10]\n assert candidate(rooms = [[10, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10]],queries = [[15, 50], [25, 40], [35, 30], [45, 20], [55, 10], [65, 5], [75, 15], [85, 25], [95, 35], [105, 45]]) == [10, 20, 30, 40, 50, 60, 70, 80, 70, 60]\n assert candidate(rooms = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50]],queries = [[3, 3], [8, 8], [13, 13], [18, 18], [23, 23], [28, 28], [33, 33], [38, 38], [43, 43], [48, 48]]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5], [1, 6]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]\n assert candidate(rooms = [[1, 1], [10000000, 10000000]],queries = [[5000000, 1], [5000000, 5000000], [5000000, 10000000], [15000000, 1]]) == [1, 10000000, 10000000, 10000000]\n assert candidate(rooms = [[100000, 10000], [200000, 9000], [300000, 8000], [400000, 7000], [500000, 6000]],queries = [[100000, 10000], [200000, 9000], [300000, 8000], [400000, 7000], [500000, 6000], [500000, 11000]]) == [100000, 200000, 300000, 400000, 500000, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]\n assert candidate(rooms = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, -1]\n assert candidate(rooms = [[10000000, 10000000], [1, 1], [5000000, 5000000]],queries = [[9999999, 9999999], [1, 1], [5000000, 5000000]]) == [10000000, 1, 5000000]\n assert candidate(rooms = [[5, 10], [15, 12], [25, 9], [35, 8], [45, 11], [55, 7]],queries = [[10, 8], [20, 9], [30, 10], [40, 11], [50, 12]]) == [5, 15, 15, 45, 15]\n assert candidate(rooms = [[100000, 10], [200000, 20], [300000, 30], [400000, 40], [500000, 50], [600000, 60], [700000, 70], [800000, 80], [900000, 90], [1000000, 100]],queries = [[50000, 10], [150000, 20], [250000, 30], [350000, 40], [450000, 50], [550000, 60], [650000, 70], [750000, 80], [850000, 90], [950000, 100]]) == [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]\n assert candidate(rooms = [[1, 10000], [2, 10000], [3, 10000], [4, 10000], [5, 10000]],queries = [[1, 9000], [2, 9000], [3, 9000], [4, 9000], [5, 9000], [6, 9000], [7, 9000], [8, 9000], [9, 9000]]) == [1, 2, 3, 4, 5, 5, 5, 5, 5]\n assert candidate(rooms = [[1000000, 1000000], [999999, 999999], [999998, 999998], [999997, 999997], [999996, 999996], [999995, 999995]],queries = [[1000000, 1000000], [1000000, 999999], [1000000, 999998], [1000000, 999997], [1000000, 999996], [1000000, 999995], [1000000, 1], [1000000, 2], [1000000, 3], [1000000, 4]]) == [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]\n assert candidate(rooms = [[100, 50], [200, 60], [300, 70], [400, 80], [500, 90]],queries = [[150, 55], [250, 65], [350, 75], [450, 85], [550, 95]]) == [200, 300, 400, 500, -1]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [[5, 15], [6, 25], [7, 35], [8, 45], [9, 55], [10, 65], [11, 75], [12, 85], [13, 95], [14, 105], [15, 115]]) == [5, 6, 7, 8, 9, 10, 10, 10, 10, -1, -1]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [[1, 5], [2, 15], [3, 25], [4, 35], [5, 45], [6, 55], [7, 65], [8, 75], [9, 85], [10, 95]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[150, 150], [250, 250], [350, 350], [450, 450], [550, 550]]) == [200, 300, 400, 500, -1]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]\n assert candidate(rooms = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9], [1000, 10]],queries = [[50, 1], [150, 2], [250, 3], [350, 4], [450, 5], [550, 6], [650, 7], [750, 8], [850, 9], [950, 10], [1050, 11]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 1]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50], [600, 60], [700, 70], [800, 80], [900, 90], [1000, 100]],queries = [[50, 10], [150, 20], [250, 30], [350, 40], [450, 50], [550, 60], [650, 70], [750, 80], [850, 90], [950, 100], [1050, 10]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000]\n assert candidate(rooms = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5], [11, 5], [12, 5], [13, 5], [14, 5], [15, 5]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]\n assert candidate(rooms = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]],queries = [[3, 1], [8, 2], [13, 3], [18, 4], [23, 5], [28, 6], [33, 7], [38, 8], [43, 9], [48, 10], [55, 11]]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5], [5, 6], [5, 4], [5, 7], [5, 3]]) == [5, 6, 5, 7, 5]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[10, 20], [20, 20], [30, 20], [40, 20], [50, 20], [60, 20], [70, 20], [80, 20], [90, 20], [100, 20]],queries = [[5, 10], [15, 10], [25, 10], [35, 10], [45, 10], [55, 10], [65, 10], [75, 10], [85, 10], [95, 10]]) == [10, 10, 20, 30, 40, 50, 60, 70, 80, 90]\n assert candidate(rooms = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9], [1000, 10]],queries = [[50, 5], [150, 15], [250, 25], [350, 35], [450, 45], [550, 55], [650, 65], [750, 75], [850, 85], [950, 95]]) == [500, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],queries = [[10, 1], [9, 1], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1]]) == [9, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rooms = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997], [5, 999996], [6, 999995], [7, 999994], [8, 999993], [9, 999992], [10, 999991]],queries = [[1, 999991], [2, 999992], [3, 999993], [4, 999994], [5, 999995], [6, 999996], [7, 999997], [8, 999998], [9, 999999], [10, 1000000]]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]) == [1, 2, 3, 4, 5, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [1, 2, 3, 2, 1, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [[1, 9999999], [2, 9999998], [3, 9999997], [4, 9999996], [5, 9999995], [6, 9999994], [7, 9999993]]) == [1, 2, 3, 4, 5, 5, 5]\n assert candidate(rooms = [[1000, 1], [2000, 2], [3000, 3], [4000, 4], [5000, 5], [6000, 6], [7000, 7], [8000, 8], [9000, 9], [10000, 10]],queries = [[500, 1], [1500, 2], [2500, 3], [3500, 4], [4500, 5], [5500, 6], [6500, 7], [7500, 8], [8500, 9], [9500, 10]]) == [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]\n assert candidate(rooms = [[10000000, 1], [9000000, 2], [8000000, 3], [7000000, 4], [6000000, 5], [5000000, 6], [4000000, 7], [3000000, 8], [2000000, 9], [1000000, 10]],queries = [[500000, 1], [1500000, 2], [2500000, 3], [3500000, 4], [4500000, 5], [5500000, 6], [6500000, 7], [7500000, 8], [8500000, 9], [9500000, 10], [10500000, 1]]) == [1000000, 1000000, 2000000, 3000000, 4000000, 5000000, 4000000, 3000000, 2000000, 1000000, 10000000]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10]]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1]\n assert candidate(rooms = [[1, 10000], [2, 9000], [3, 8000], [4, 7000], [5, 6000], [6, 5000], [7, 4000], [8, 3000], [9, 2000], [10, 1000]],queries = [[1, 10000], [2, 9000], [3, 8000], [4, 7000], [5, 6000], [6, 5000], [7, 4000], [8, 3000], [9, 2000], [10, 1000], [11, 500]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]\n assert candidate(rooms = [[1000, 10], [2000, 20], [3000, 30], [4000, 40], [5000, 50]],queries = [[1500, 5], [2500, 15], [3500, 25], [4500, 35], [5500, 45]]) == [1000, 2000, 3000, 4000, 5000]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[1, 1], [3, 3], [5, 5]],queries = [[2, 2], [4, 4]]) == [3, 5]\n assert candidate(rooms = [[10, 5], [20, 5], [30, 5], [40, 5], [50, 5]],queries = [[15, 5], [25, 5], [35, 5], [45, 5], [55, 5]]) == [10, 20, 30, 40, 50]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30]],queries = [[1, 10], [2, 20], [3, 30]]) == [1, 2, 3]\n assert candidate(rooms = [[5, 10], [10, 10], [15, 10]],queries = [[7, 5], [12, 5], [17, 5]]) == [5, 10, 15]\n assert candidate(rooms = [[7, 10], [15, 20], [25, 30]],queries = [[10, 10], [20, 20], [30, 30], [40, 40]]) == [7, 15, 25, -1]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[15, 10], [25, 20], [35, 30]]) == [10, 20, 30]\n assert candidate(rooms = [[5, 5], [15, 15], [25, 25], [35, 35]],queries = [[10, 5], [20, 15], [30, 25], [40, 35]]) == [5, 15, 25, 35]\n assert candidate(rooms = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5]],queries = [[1, 1], [6, 2], [11, 3], [16, 4], [21, 5], [26, 6]]) == [5, 10, 15, 20, 25, -1]\n assert candidate(rooms = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5]],queries = [[3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == [3, 3, 3, 2, 1]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[7, 7], [14, 14], [21, 21], [28, 28]],queries = [[7, 7], [14, 14], [21, 21], [28, 28], [35, 35]]) == [7, 14, 21, 28, -1]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [[3, 5], [3, 15], [3, 25], [3, 35], [3, 45]]) == [3, 3, 3, 4, 5]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8]],queries = [[15, 3], [25, 7], [10, 5]]) == [10, 30, 10]\n assert candidate(rooms = [[1, 10000000]],queries = [[1, 10000000], [1, 9999999], [1, 10000001]]) == [1, 1, -1]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[15, 10], [25, 15], [35, 25]]) == [10, 20, 30]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 5000000], [10000000, 1], [1, 10000000]]) == [1, 10000000, 1]\n assert candidate(rooms = [[7, 7], [17, 17], [27, 27], [37, 37]],queries = [[5, 7], [15, 17], [25, 27], [35, 37]]) == [7, 17, 27, 37]\n assert candidate(rooms = [[1, 10], [10, 1], [2, 9], [9, 2], [3, 8], [8, 3]],queries = [[5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [3, 3, 8, 8, 9]\n assert candidate(rooms = [[7, 10], [5, 15], [12, 20], [3, 25]],queries = [[6, 15], [8, 10], [15, 20]]) == [5, 7, 12]\n assert candidate(rooms = [[5, 10], [6, 11], [7, 12]],queries = [[5, 10], [6, 11], [7, 12]]) == [5, 6, 7]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300]],queries = [[150, 150], [250, 250], [50, 50]]) == [200, 300, 100]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],queries = [[3, 5], [3, 10], [3, 15]]) == [3, 3, -1]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50]],queries = [[150, 15], [250, 25], [350, 35], [450, 45], [550, 55]]) == [200, 300, 400, 500, -1]\n assert candidate(rooms = [[5, 10], [15, 8], [25, 12], [35, 9]],queries = [[10, 10], [20, 8], [30, 12], [40, 9]]) == [5, 15, 25, 35]\n assert candidate(rooms = [[100, 100], [200, 100], [300, 100]],queries = [[150, 100], [250, 100], [50, 100]]) == [100, 200, 100]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 5000000], [10000000, 10000000], [1, 1]]) == [1, 1, 1]\n assert candidate(rooms = [[7, 7], [8, 8], [9, 9]],queries = [[10, 10], [11, 11], [12, 12]]) == [-1, -1, -1]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30]],queries = [[150, 15], [250, 25], [50, 5], [350, 35]]) == [200, 300, 100, -1]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [[1, 5], [2, 15], [3, 25], [4, 35], [5, 45]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],queries = [[15, 1], [25, 2], [35, 3], [45, 4]]) == [10, 20, 30, 40]\n assert candidate(rooms = [[10, 5], [20, 5], [30, 5]],queries = [[25, 5], [15, 5], [5, 5], [35, 5]]) == [20, 10, 10, 30]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[1, 1], [10000000, 10000000], [5000000, 5000000]]) == [1, 1, 1]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998]],queries = [[2, 9999999], [1, 10000000], [3, 9999998]]) == [2, 1, 3]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(rooms = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],queries = [[3, 3], [2, 2], [1, 1], [6, 6], [0, 0]]) == [3, 2, 1, -1, 1]\n assert candidate(rooms = [[1, 1]],queries = [[1, 1], [2, 1], [3, 1]]) == [1, 1, 1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6]]) == [3, 3, 3, 4, 5, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 7]],queries = [[15, 3], [25, 6], [35, 8]]) == [10, 30, -1]\n assert candidate(rooms = [[100000, 100000], [1, 1], [50000, 50000]],queries = [[100000, 100000], [1, 1], [50000, 50000], [25000, 50000]]) == [100000, 1, 50000, 50000]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998]],queries = [[1, 10000000], [2, 9999999], [3, 9999998]]) == [1, 2, 3]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [[3, 15], [3, 25], [3, 35], [3, 45], [3, 55]]) == [3, 3, 4, 5, -1]\n assert candidate(rooms = [[5, 10], [15, 10], [25, 10]],queries = [[10, 10], [20, 10], [30, 10]]) == [5, 15, 25]\n assert candidate(rooms = [[5, 5], [5, 5], [5, 5]],queries = [[5, 5], [5, 5], [5, 5]]) == [5, 5, 5]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],queries = [[3, 10], [3, 11], [3, 9]]) == [3, -1, 3]\n assert candidate(rooms = [[10000000, 1], [9999999, 2], [9999998, 3]],queries = [[10000000, 1], [9999999, 2], [9999998, 3]]) == [10000000, 9999999, 9999998]\n assert candidate(rooms = [[10, 5], [20, 7], [30, 9]],queries = [[15, 6], [25, 8], [35, 10]]) == [20, 30, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 7], [40, 2], [50, 6]],queries = [[15, 4], [25, 3], [35, 5], [45, 2]]) == [10, 20, 30, 40]\n assert candidate(rooms = [[5, 5], [6, 6], [7, 7]],queries = [[5, 6], [6, 7], [7, 8]]) == [6, 7, -1]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[1, 10000000], [2, 10000000], [3, 10000000]],queries = [[1, 10000000], [2, 10000000], [3, 10000000]]) == [1, 2, 3]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [5, 6, 7, 8, 9]\n assert candidate(rooms = [[7, 7], [8, 8], [9, 9]],queries = [[7, 7], [8, 8], [9, 9], [10, 10]]) == [7, 8, 9, -1]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 1], [5000000, 10000000], [1, 1], [10000000, 1]]) == [1, 1, 1, 10000000]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 5000000], [10000000, 10000000]]) == [1, 1]\n assert candidate(rooms = [[5, 5], [3, 3], [1, 1], [7, 7]],queries = [[4, 4], [6, 6], [2, 2], [8, 8]]) == [5, 7, 3, -1]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30]],queries = [[150, 15], [250, 25], [350, 35]]) == [200, 300, -1]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]],queries = [[15, 4], [25, 3], [35, 2], [45, 1], [55, 1]]) == [10, 20, 30, 40, 50]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],queries = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10]]) == [1, 2, 3, 4, 5, 5]\n assert candidate(rooms = [[100, 100], [200, 90], [300, 80], [400, 70], [500, 60]],queries = [[150, 90], [250, 80], [350, 70]]) == [100, 200, 300]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 3], [1, 1], [2, 2], [4, 4], [5, 5]]) == [3, 1, 2, 4, 5]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 4], [40, 2]],queries = [[25, 3], [15, 5], [35, 4]]) == [20, 10, 30]\n assert candidate(rooms = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9]],queries = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9]]) == [1, 3, 5, 7, 9]\n assert candidate(rooms = [[1, 100], [100, 1], [50, 50]],queries = [[50, 1], [50, 50], [50, 100]]) == [50, 50, 1]\n assert candidate(rooms = [[5, 10], [10, 10], [15, 10], [20, 10], [25, 10]],queries = [[7, 5], [12, 8], [17, 11], [22, 14], [27, 17]]) == [5, 10, -1, -1, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 4], [40, 6]],queries = [[25, 3], [15, 5], [35, 4]]) == [20, 10, 30]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30], [400, 40]],queries = [[150, 5], [250, 15], [350, 25], [450, 35]]) == [100, 200, 300, 400]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 6], [40, 4]],queries = [[15, 4], [25, 5], [35, 6]]) == [10, 30, 30]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[15, 5], [25, 25], [35, 15]]) == [10, 30, 30]\n assert candidate(rooms = [[1000, 1000], [2000, 1000], [3000, 1000]],queries = [[1500, 1000], [2500, 1000], [500, 1000]]) == [1000, 2000, 1000]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30]],queries = [[1, 5], [2, 15], [3, 25]]) == [1, 2, 3]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5]],queries = [[1, 6], [2, 6], [3, 6]]) == [-1, -1, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 4], [40, 2]],queries = [[15, 3], [25, 4], [35, 5]]) == [10, 30, 10]\n assert candidate(rooms = [[10, 5], [20, 6], [30, 7]],queries = [[15, 5], [25, 6], [35, 7]]) == [10, 20, 30]\n assert candidate(rooms = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],queries = [[5, 5], [15, 4], [25, 3], [35, 2], [45, 1], [55, 6]]) == [50, 40, 30, 30, 40, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8], [40, 7]],queries = [[15, 4], [25, 6], [35, 7]]) == [10, 30, 30]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],queries = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [1, 2, 3, 3, 2]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == [5, 4, 3, 4, 5]\n assert candidate(rooms = [[100, 1], [200, 2], [300, 3]],queries = [[99, 1], [199, 2], [299, 3]]) == [100, 200, 300]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[15, 5], [25, 15], [35, 25]]) == [10, 20, 30]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 5000000], [1, 1], [10000000, 10000000]]) == [1, 1, 1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8]],queries = [[15, 4], [25, 3], [35, 9]]) == [10, 20, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == [3, 3, 3, 4, 5]\n assert candidate(rooms = [[5, 10], [15, 20], [25, 30]],queries = [[10, 15], [20, 25], [30, 35]]) == [15, 25, -1]\n assert candidate(rooms = [[1, 5], [3, 5], [5, 5], [7, 5], [9, 5]],queries = [[2, 5], [4, 5], [6, 5], [8, 5]]) == [1, 3, 5, 7]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30]],queries = [[50, 5], [150, 15], [250, 25]]) == [100, 200, 300]\n assert candidate(rooms = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50]],queries = [[10, 5], [20, 15], [30, 25], [40, 35], [50, 45]]) == [5, 15, 25, 35, 45]\n assert candidate(rooms = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],queries = [[5, 1], [15, 2], [25, 3], [35, 4], [45, 5]]) == [10, 20, 30, 40, 50]\n assert candidate(rooms = [[5, 10], [15, 15], [25, 20], [35, 25], [45, 30]],queries = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == [5, 25, 45, -1, -1]\n assert candidate(rooms = [[1, 1], [10, 10], [100, 100]],queries = [[5, 1], [50, 10], [500, 100], [5000, 50]]) == [1, 10, 100, 100]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8]],queries = [[15, 3], [25, 6], [35, 10]]) == [10, 30, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[10000000, 10000000]],queries = [[10000000, 10000000], [9999999, 10000000], [10000001, 10000000]]) == [10000000, 10000000, 10000000]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]],queries = [[15, 2], [25, 3], [35, 4]]) == [10, 20, 20]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400]],queries = [[150, 100], [250, 200], [350, 300], [450, 400]]) == [100, 200, 300, 400]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 1], [4, 2], [5, 3], [6, 4], [7, 5]]) == [3, 4, 5, 5, 5]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [[1, 1], [5, 5], [10, 10]]) == [1, 5, 1]\n assert candidate(rooms = [[1, 5], [2, 6], [3, 7]],queries = [[1, 6], [2, 7], [3, 8]]) == [2, 3, -1]\n assert candidate(rooms = [[5, 5], [15, 15], [25, 25], [35, 35]],queries = [[10, 10], [20, 20], [30, 30], [40, 40]]) == [15, 25, 35, -1]\n assert candidate(rooms = [[7, 7], [8, 8], [9, 9]],queries = [[7, 7], [8, 8], [9, 9], [6, 6], [10, 10]]) == [7, 8, 9, 7, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [1, 2, 3, 2, 1]\n assert candidate(rooms = [[1, 10000000], [2, 10000000], [3, 10000000]],queries = [[1, 10000000], [2, 10000000], [3, 10000000], [4, 10000000]]) == [1, 2, 3, 3]\n assert candidate(rooms = [[10000000, 10000000]],queries = [[10000000, 10000000], [9999999, 9999999], [10000001, 10000001]]) == [10000000, 10000000, -1]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10]],queries = [[1, 5], [2, 10], [3, 15]]) == [1, 2, -1]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400]],queries = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450]]) == [100, 200, 300, 400, -1]\n assert candidate(rooms = [[1000, 100], [2000, 200], [3000, 300], [4000, 400]],queries = [[1500, 50], [2500, 150], [3500, 250], [4500, 350]]) == [1000, 2000, 3000, 4000]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 2], [4, 3], [5, 4]]) == [3, 4, 5]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3]],queries = [[15, 4], [25, 3], [5, 6]]) == [10, 20, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[6, 1], [7, 2], [8, 3], [9, 4], [10, 5]]) == [5, 5, 5, 5, 5]\n assert candidate(rooms = [[10, 5], [20, 5], [30, 5]],queries = [[15, 5], [25, 5], [5, 5]]) == [10, 20, 10]\n assert candidate(rooms = [[1, 10000000], [2, 10000000], [3, 10000000], [4, 10000000], [5, 10000000]],queries = [[3, 10000000], [3, 10000001], [3, 9999999]]) == [3, -1, 3]\n assert candidate(rooms = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],queries = [[50, 1], [150, 2], [250, 3], [350, 4], [450, 5]]) == [100, 200, 300, 400, 500]\n assert candidate(rooms = [[10000000, 10000000]],queries = [[10000000, 10000000]]) == [10000000]\n assert candidate(rooms = [[10000000, 10000000], [1, 1]],queries = [[10000000, 10000000], [2, 1]]) == [10000000, 1]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[25, 15], [15, 10], [35, 25]]) == [20, 10, 30]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 3], [3, 4], [3, 5], [3, 6], [3, 2], [3, 1]]) == [3, 4, 5, -1, 3, 3]\n assert candidate(rooms = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]],queries = [[7, 6], [12, 11], [17, 16], [22, 21], [27, 26]]) == [10, 15, 20, 25, -1]\n"}, "metadata": {"canonical_parameter_names": ["rooms", "queries"], "leetcode_dataset_entry_point": "Solution().closestRoom", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def closestRoom(self, rooms: list[list[int]], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "closestRoom", "parameters": [{"name": "rooms", "type": "list[list[int]]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1848, "task_id": "minimum-distance-to-the-target-element", "difficulty": "Easy", "problem_description": "Given an integer array nums (0-indexed) and two integers target and start, find an index i such that nums[i] == target and abs(i - start) is minimized. Note that abs(x) is the absolute value of x.\nReturn abs(i - start).\nIt is guaranteed that target exists in nums.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5], target = 5, start = 3\nOutput: 1\nExplanation: nums[4] = 5 is the only value equal to target, so the answer is abs(4 - 3) = 1.\n\nExample 2:\n\nInput: nums = [1], target = 1, start = 0\nOutput: 0\nExplanation: nums[0] = 1 is the only value equal to target, so the answer is abs(0 - 0) = 0.\n\nExample 3:\n\nInput: nums = [1,1,1,1,1,1,1,1,1,1], target = 1, start = 0\nOutput: 0\nExplanation: Every value of nums is 1, but nums[0] minimizes abs(i - start), which is abs(0 - 0) = 0.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 104\n0 <= start < nums.length\ntarget is in nums.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 1, 4, 1],target = 1,start = 2) == 1\n assert candidate(nums = [1, 5, 3, 4, 5],target = 5,start = 2) == 1\n assert candidate(nums = [4, 1, 3, 5, 2],target = 2,start = 1) == 3\n assert candidate(nums = [4, 1, 3, 5, 6],target = 3,start = 1) == 1\n assert candidate(nums = [4, 1, 3, 5, 2],target = 1,start = 2) == 1\n assert candidate(nums = [5, 1, 4, 1, 2],target = 1,start = 0) == 1\n assert candidate(nums = [1],target = 1,start = 0) == 0\n assert candidate(nums = [4, 1, 3, 5, 6],target = 1,start = 2) == 1\n assert candidate(nums = [5, 1, 4, 1, 2],target = 1,start = 1) == 0\n assert candidate(nums = [5, 1, 4, 1, 2],target = 1,start = 2) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1,start = 0) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],target = 5,start = 3) == 1\n assert candidate(nums = [7, 8, 9, 5, 6, 5, 4, 5, 3, 5],target = 5,start = 4) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15,start = 9) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5,start = 9) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 500,start = 3) == 1\n assert candidate(nums = [7, 2, 5, 8, 3, 9, 1, 5],target = 5,start = 4) == 2\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],target = 18,start = 8) == 3\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],target = 3,start = 5) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 19,start = 4) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 30,start = 0) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 2,start = 15) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],target = 6,start = 9) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 10,start = 19) == 10\n assert candidate(nums = [1, 3, 5, 2, 4, 3, 2, 1, 3],target = 3,start = 5) == 0\n assert candidate(nums = [10, 23, 56, 78, 90, 12, 34, 56, 78, 90],target = 56,start = 5) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2,start = 10) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],target = 15,start = 20) == 6\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 700,start = 0) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 60,start = 5) == 0\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 20,start = 15) == 15\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],target = -3,start = 8) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 7,start = 9) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 10,start = 14) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 1,start = 9) == 9\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 15,start = 9) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 15,start = 4) == 3\n assert candidate(nums = [5, 3, 8, 6, 2, 10, 1, 4],target = 10,start = 3) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 12,start = 10) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15,start = 0) == 14\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 1,start = 5) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 50,start = 2) == 2\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, -1],target = 0,start = 4) == 4\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],target = 997,start = 2) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 35,start = 9) == 3\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 3,start = 15) == 0\n assert candidate(nums = [2, 5, 4, 7, 8, 6, 1, 3, 9, 0],target = 3,start = 8) == 1\n assert candidate(nums = [5, 2, 3, 4, 5, 1, 5],target = 5,start = 3) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 16,start = 0) == 7\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 7],target = 7,start = 5) == 4\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5],target = 1,start = 4) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 2,start = 9) == 9\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],target = 4,start = 10) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 10,start = 7) == 2\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],target = 93,start = 8) == 2\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 12,start = 3) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 13,start = 19) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],target = 15,start = 0) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 39,start = 0) == 19\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],target = 65,start = 5) == 1\n assert candidate(nums = [1000, 500, 250, 125, 63, 31, 16, 8, 4, 2, 1],target = 16,start = 5) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 500,start = 9) == 5\n assert candidate(nums = [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59],target = 50,start = 14) == 9\n assert candidate(nums = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3],target = 1,start = 4) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2],target = 10,start = 9) == 5\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 10,start = 0) == 10\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 60,start = 4) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 7,start = 7) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 40,start = 0) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 5,start = 10) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 19,start = 9) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10,start = 0) == 9\n assert candidate(nums = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],target = 1,start = 19) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1],target = 9,start = 4) == 0\n assert candidate(nums = [5, 3, 2, 5, 3, 5, 2, 5, 3, 5],target = 3,start = 4) == 0\n assert candidate(nums = [1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2,start = 7) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = 19,start = 12) == 3\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981],target = 985,start = 15) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 500,start = 9) == 5\n assert candidate(nums = [3, 4, 2, 5, 1, 5, 3, 2, 5],target = 5,start = 4) == 1\n assert candidate(nums = [7, 1, 3, 4, 2, 5, 7, 6, 7, 8],target = 7,start = 5) == 1\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 9, 8],target = 0,start = 5) == 2\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10,start = 5) == 8\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5,start = 10) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15,start = 10) == 4\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7],target = 2,start = 6) == 1\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],target = 4,start = 9) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009],target = 1009,start = 2) == 7\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],target = 0,start = 9) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 18,start = 10) == 2\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5],target = 2,start = 4) == 1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7],target = 5,start = 10) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 1,start = 19) == 19\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 7,start = 15) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 13,start = 5) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],target = 23,start = 0) == 8\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],target = 15,start = 5) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 10,start = 7) == 2\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15],target = 12,start = 3) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 30,start = 5) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 7,start = 0) == 6\n assert candidate(nums = [8, 6, 4, 2, 0, 2, 4, 6, 8],target = 0,start = 4) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],target = 0,start = 10) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 3,start = 8) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],target = 25,start = 15) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 10,start = 0) == 9\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],target = 3,start = 6) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5,start = 5) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 1,start = 19) == 19\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9],target = -4,start = 8) == 5\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 18,start = 9) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 18,start = 12) == 4\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 7,start = 3) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],target = 5,start = 5) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],target = 5,start = 9) == 5\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29],target = 20,start = 4) == 2\n assert candidate(nums = [10, 22, 33, 44, 55, 66, 77, 88, 99],target = 88,start = 0) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums", "target", "start"], "leetcode_dataset_entry_point": "Solution().getMinDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getMinDistance(self, nums: list[int], target: int, start: int) -> int:", "container": "Solution", "callable": "getMinDistance", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "target", "type": "int"}, {"name": "start", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1849, "task_id": "splitting-a-string-into-descending-consecutive-values", "difficulty": "Medium", "problem_description": "You are given a string s that consists of only digits.\nCheck if we can split s into two or more non-empty substrings such that the numerical values of the substrings are in descending order and the difference between numerical values of every two adjacent substrings is equal to 1.\n\nFor example, the string s = \"0090089\" can be split into [\"0090\", \"089\"] with numerical values [90,89]. The values are in descending order and adjacent values differ by 1, so this way is valid.\nAnother example, the string s = \"001\" can be split into [\"0\", \"01\"], [\"00\", \"1\"], or [\"0\", \"0\", \"1\"]. However all the ways are invalid because they have numerical values [0,1], [0,1], and [0,0,1] respectively, all of which are not in descending order.\n\nReturn true if it is possible to split s​​​​​​ as described above, or false otherwise.\nA substring is a contiguous sequence of characters in a string.\n \nExample 1:\n\nInput: s = \"1234\"\nOutput: false\nExplanation: There is no valid way to split s.\n\nExample 2:\n\nInput: s = \"050043\"\nOutput: true\nExplanation: s can be split into [\"05\", \"004\", \"3\"] with numerical values [5,4,3].\nThe values are in descending order with adjacent values differing by 1.\n\nExample 3:\n\nInput: s = \"9080701\"\nOutput: false\nExplanation: There is no valid way to split s.\n\n \nConstraints:\n\n1 <= s.length <= 20\ns only consists of digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"21\") == True\n assert candidate(s = \"9876543210\") == True\n assert candidate(s = \"050043\") == True\n assert candidate(s = \"989796959493929190\") == True\n assert candidate(s = \"1009998\") == True\n assert candidate(s = \"2120191817\") == True\n assert candidate(s = \"1201100009\") == False\n assert candidate(s = \"212120\") == False\n assert candidate(s = \"10010\") == False\n assert candidate(s = \"0000\") == False\n assert candidate(s = \"1234\") == False\n assert candidate(s = \"11110\") == False\n assert candidate(s = \"111121111\") == False\n assert candidate(s = \"1111111111\") == False\n assert candidate(s = \"989796\") == True\n assert candidate(s = \"1010\") == False\n assert candidate(s = \"9080701\") == False\n assert candidate(s = \"98765432109\") == False\n assert candidate(s = \"999988887777666655554444333322221111\") == False\n assert candidate(s = \"1001000\") == False\n assert candidate(s = \"543210\") == True\n assert candidate(s = \"1\") == False\n assert candidate(s = \"101010\") == False\n assert candidate(s = \"1000999898\") == False\n assert candidate(s = \"00000\") == False\n assert candidate(s = \"001\") == False\n assert candidate(s = \"2222222221222222211222221022221922218\") == False\n assert candidate(s = \"5432109876543210\") == False\n assert candidate(s = \"545454545454545454545454545454545454\") == False\n assert candidate(s = \"89888786858483828180797877767574737271706968676665646362616059585756555453525150494847464544434241403938373635343332313029282726252423222120191817161514131211109876543210\") == True\n assert candidate(s = \"100999989876543210\") == False\n assert candidate(s = \"10101010101010101010100999999999999999\") == False\n assert candidate(s = \"444444444344444443344444324444314444304443294442844417444064435442444134440244314420441944084397428641754064\") == False\n assert candidate(s = \"99888877776666555544443333222211110000\") == False\n assert candidate(s = \"22222222222222222221\") == True\n assert candidate(s = \"99887766554433221100\") == False\n assert candidate(s = \"1121112111110101001000\") == False\n assert candidate(s = \"10099988877766655544433322211100\") == False\n assert candidate(s = \"100009999888877776666555544443333222211110000\") == False\n assert candidate(s = \"11111111111111111112\") == False\n assert candidate(s = \"987876757473727170\") == False\n assert candidate(s = \"1232109876543210987654321\") == False\n assert candidate(s = \"191817161514131211109876543210987654321\") == False\n assert candidate(s = \"987654321987654320\") == True\n assert candidate(s = \"09080706050403020100\") == True\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"111111111111111111101111111111111110\") == False\n assert candidate(s = \"100999888777666555444333222111000\") == False\n assert candidate(s = \"000011110000222200003333000044440000555500006666000077770000888800009999\") == False\n assert candidate(s = \"123432109876543210\") == False\n assert candidate(s = \"1234567898765432109876543210\") == False\n assert candidate(s = \"00009999888877776666555544443333\") == False\n assert candidate(s = \"00010020030040050060070080090100110012001300140015\") == False\n assert candidate(s = \"98765432100987654321\") == False\n assert candidate(s = \"999888777666555444333222111000123456789000987654321\") == False\n assert candidate(s = \"100000111110000011111000001111100000\") == False\n assert candidate(s = \"5432154320543195430853975296519509498487476465454443424140\") == False\n assert candidate(s = \"98979695949392919089888786858483828180797877767574737271706968676665646362616059585756555453525150\") == True\n assert candidate(s = \"20191817161514131211109876543210\") == True\n assert candidate(s = \"987654321009876543209\") == True\n assert candidate(s = \"999888777666555444333222111000\") == False\n assert candidate(s = \"21201918171615141312111009080706050403020100\") == True\n assert candidate(s = \"123321123321123321123321123321123321\") == False\n assert candidate(s = \"9897969594939291908988878685848382818079\") == True\n assert candidate(s = \"1098765432110987654\") == False\n assert candidate(s = \"9080706050403020100\") == True\n assert candidate(s = \"807978777675747372717069686766656463626160\") == True\n assert candidate(s = \"98798765432109876543210\") == False\n assert candidate(s = \"987654321010987654321010987654321010\") == False\n assert candidate(s = \"99999999999999999999\") == False\n assert candidate(s = \"11111111111111111111\") == False\n assert candidate(s = \"2120191817161514131211109876543210\") == True\n assert candidate(s = \"555555555555555555544444444444444443\") == False\n assert candidate(s = \"101009988776655443322110\") == False\n assert candidate(s = \"11111011110111101110110\") == False\n assert candidate(s = \"10000999988887777666655554444333322221111\") == False\n assert candidate(s = \"9999888877776666555544443333222211110000111122223333444455556666777788889999\") == False\n assert candidate(s = \"191817161514131211109876543210\") == True\n assert candidate(s = \"9876543210987654321098765432109876543210\") == False\n assert candidate(s = \"98765432109876543210\") == False\n assert candidate(s = \"100000000000000000010000000000000000\") == False\n assert candidate(s = \"56555453525150494847464544434241403938373635343332313029282726252423222120191817161514131211109876543210\") == True\n assert candidate(s = \"101010109101010810101071010106101010510101041010103101010210101011010100101009101008101007101006101005\") == False\n assert candidate(s = \"10010010010010010010\") == False\n assert candidate(s = \"76543210987654321098765432109876543210987654320\") == False\n assert candidate(s = \"8070605040302010\") == True\n assert candidate(s = \"987654321987654321\") == False\n assert candidate(s = \"222222222222222222222222222222222222\") == False\n assert candidate(s = \"9876543210109876543210\") == False\n assert candidate(s = \"2021222324252627282930\") == False\n assert candidate(s = \"65432165431654306542965418654076436642564146403639262816170\") == False\n assert candidate(s = \"123456789876543210987654321\") == False\n assert candidate(s = \"32313029282726252423222120191817161514131211109876543210\") == True\n assert candidate(s = \"111110000099999888887777766666555554444433333222221111100000\") == False\n assert candidate(s = \"987654321000000\") == True\n assert candidate(s = \"11211110110109108107106105104103102101100\") == False\n assert candidate(s = \"87654321098765432109876543210987\") == False\n assert candidate(s = \"1000100100200300400500600700800900\") == False\n assert candidate(s = \"9999888877776666555544443333222211110000\") == False\n assert candidate(s = \"9876543210987654321\") == False\n assert candidate(s = \"545352515049484746454443424140393837363534\") == True\n assert candidate(s = \"10010009999897969594939291908988878685848382818079787776757473727170696867666564636261605958575655545352515049484746454443424140393837363534333231302928272625242322212019181716151413121110987654321\") == False\n assert candidate(s = \"543211098765432109876543210\") == False\n assert candidate(s = \"0102030405060708091011121314151617181920\") == False\n assert candidate(s = \"111122223333444455556666777788889999000000001111\") == False\n assert candidate(s = \"54321543215432154321\") == False\n assert candidate(s = \"12345678909876543210\") == False\n assert candidate(s = \"999888777666555444333222111\") == False\n assert candidate(s = \"10010020030040050060070080090101011012013014015016017018019020\") == False\n assert candidate(s = \"987654321009876543210\") == False\n assert candidate(s = \"12321231230231231230231230231023\") == False\n assert candidate(s = \"2222222222222222222222222222222222222222222111111111111111111111111111111111111111111111111111111111\") == False\n assert candidate(s = \"1121111101091081071061051041031021011009998979695949392919089888786858483828180797877767574737271706968676665646362616059585756555453525150\") == True\n assert candidate(s = \"00000000000000000000\") == False\n assert candidate(s = \"123432100999888777666555444333222111000123\") == False\n assert candidate(s = \"9876556789\") == False\n assert candidate(s = \"987654321098765432109876543210\") == False\n assert candidate(s = \"123212321232123212321\") == False\n assert candidate(s = \"0000111122223333444455556666777788889999\") == False\n assert candidate(s = \"876543210987654321098765432109876543210987654321\") == False\n assert candidate(s = \"987654321011121314151617181920\") == False\n assert candidate(s = \"9876543210123456789\") == False\n assert candidate(s = \"151413121110090807060504030201000000000000000000000000000000000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"12321211110100998877665544332211\") == False\n assert candidate(s = \"1009999888777666555444333222111\") == False\n assert candidate(s = \"10987654321098765432109876543210\") == False\n assert candidate(s = \"00000000000000000001\") == False\n assert candidate(s = \"12341233123212311230\") == True\n assert candidate(s = \"11111111110111111110011111109999988888\") == False\n assert candidate(s = \"111122223333444455556666777788889999\") == False\n assert candidate(s = \"9879876543210\") == False\n assert candidate(s = \"1000000000000000000010000000000000000001\") == False\n assert candidate(s = \"10109080706050403020100\") == False\n assert candidate(s = \"999898979695949392919089888786858483828180\") == False\n assert candidate(s = \"000000001000000000\") == True\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().splitString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def splitString(self, s: str) -> bool:", "container": "Solution", "callable": "splitString", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1850, "task_id": "minimum-adjacent-swaps-to-reach-the-kth-smallest-number", "difficulty": "Medium", "problem_description": "You are given a string num, representing a large integer, and an integer k.\nWe call some integer wonderful if it is a permutation of the digits in num and is greater in value than num. There can be many wonderful integers. However, we only care about the smallest-valued ones.\n\nFor example, when num = \"5489355142\":\n\n\t\nThe 1st smallest wonderful integer is \"5489355214\".\nThe 2nd smallest wonderful integer is \"5489355241\".\nThe 3rd smallest wonderful integer is \"5489355412\".\nThe 4th smallest wonderful integer is \"5489355421\".\n\n\n\nReturn the minimum number of adjacent digit swaps that needs to be applied to num to reach the kth smallest wonderful integer.\nThe tests are generated in such a way that kth smallest wonderful integer exists.\n \nExample 1:\n\nInput: num = \"5489355142\", k = 4\nOutput: 2\nExplanation: The 4th smallest wonderful number is \"5489355421\". To get this number:\n- Swap index 7 with index 8: \"5489355142\" -> \"5489355412\"\n- Swap index 8 with index 9: \"5489355412\" -> \"5489355421\"\n\nExample 2:\n\nInput: num = \"11112\", k = 4\nOutput: 4\nExplanation: The 4th smallest wonderful number is \"21111\". To get this number:\n- Swap index 3 with index 4: \"11112\" -> \"11121\"\n- Swap index 2 with index 3: \"11121\" -> \"11211\"\n- Swap index 1 with index 2: \"11211\" -> \"12111\"\n- Swap index 0 with index 1: \"12111\" -> \"21111\"\n\nExample 3:\n\nInput: num = \"00123\", k = 1\nOutput: 1\nExplanation: The 1st smallest wonderful number is \"00132\". To get this number:\n- Swap index 3 with index 4: \"00123\" -> \"00132\"\n\n \nConstraints:\n\n2 <= num.length <= 1000\n1 <= k <= 1000\nnum only consists of digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"111222333\",k = 10) == 3\n assert candidate(num = \"1234567890\",k = 5) == 2\n assert candidate(num = \"1111111111\",k = 5) == 0\n assert candidate(num = \"9876543210\",k = 3) == 0\n assert candidate(num = \"5489355142\",k = 4) == 2\n assert candidate(num = \"321\",k = 2) == 0\n assert candidate(num = \"1000001\",k = 2) == 2\n assert candidate(num = \"343123\",k = 3) == 2\n assert candidate(num = \"00123\",k = 1) == 1\n assert candidate(num = \"12345678901234567890\",k = 10) == 5\n assert candidate(num = \"9999999999\",k = 1) == 0\n assert candidate(num = \"9876543210\",k = 5) == 0\n assert candidate(num = \"1234567890\",k = 3) == 3\n assert candidate(num = \"321\",k = 1) == 0\n assert candidate(num = \"11112\",k = 4) == 4\n assert candidate(num = \"000000000000000000000000000000000000000000000000\",k = 1) == 0\n assert candidate(num = \"12345678901234567890123456789012345678901234567890\",k = 500) == 11\n assert candidate(num = \"00000000001111111111\",k = 500) == 28\n assert candidate(num = \"12345678901234567890\",k = 1000) == 9\n assert candidate(num = \"111112222233333\",k = 500) == 9\n assert candidate(num = \"123456789012345678901234567890\",k = 50) == 3\n assert candidate(num = \"1234567890987654321012345678909876543210\",k = 100) == 39\n assert candidate(num = \"00000000000000000000000000000000000000000000000001\",k = 1) == 1\n assert candidate(num = \"01234567890123456789\",k = 500) == 8\n assert candidate(num = \"5555555555555555555555555555555555555555555555555\",k = 10) == 0\n assert candidate(num = \"3333333333\",k = 1) == 0\n assert candidate(num = \"1212121212121212121212121212\",k = 500) == 6\n assert candidate(num = \"9876543210\",k = 10) == 0\n assert candidate(num = \"5678987656789\",k = 250) == 10\n assert candidate(num = \"12345678909876543210\",k = 500) == 37\n assert candidate(num = \"55667788990011223344\",k = 500) == 11\n assert candidate(num = \"3456789012\",k = 10) == 2\n assert candidate(num = \"123123123123123123123123123123123123123123\",k = 200) == 6\n assert candidate(num = \"123321123321\",k = 50) == 3\n assert candidate(num = \"9876543210\",k = 15) == 0\n assert candidate(num = \"1000000000000000000000000000000000000000000000000001\",k = 10) == 10\n assert candidate(num = \"12345678901234567890\",k = 100) == 8\n assert candidate(num = \"3214567890\",k = 10) == 5\n assert candidate(num = \"123321123321\",k = 100) == 5\n assert candidate(num = \"987654321098765432109876543210\",k = 1000) == 37\n assert candidate(num = \"01234567890123456789\",k = 1000) == 8\n assert candidate(num = \"3333333333\",k = 500) == 0\n assert candidate(num = \"3333222211110000\",k = 100) == 0\n assert candidate(num = \"9876543210987654321098765432109876543210\",k = 50) == 42\n assert candidate(num = \"987654321987654321987654321\",k = 500) == 28\n assert candidate(num = \"33333333333333333333\",k = 1) == 0\n assert candidate(num = \"01010101010101010101\",k = 250) == 3\n assert candidate(num = \"987654321987654321\",k = 100) == 30\n assert candidate(num = \"22222222222222222223\",k = 500) == 19\n assert candidate(num = \"333333333333333333333333333333333333333333333333\",k = 10) == 0\n assert candidate(num = \"987654321098765432109876543210987654321098765432109876543210\",k = 500) == 37\n assert candidate(num = \"1010101010101010\",k = 50) == 5\n assert candidate(num = \"1221112222211122222211111222222211111111122222222222222\",k = 100) == 19\n assert candidate(num = \"99887766554433221100\",k = 500) == 0\n assert candidate(num = \"1234554321\",k = 10) == 13\n assert candidate(num = \"0000000001\",k = 1) == 1\n assert candidate(num = \"44444444444444444444\",k = 100) == 0\n assert candidate(num = \"111122223333444455556666777788889999\",k = 1000) == 15\n assert candidate(num = \"90876543210987654321\",k = 50) == 34\n assert candidate(num = \"1234321234321\",k = 50) == 6\n assert candidate(num = \"111111111111111111112\",k = 1000) == 20\n assert candidate(num = \"98765432109876543210\",k = 10) == 42\n assert candidate(num = \"1234567890\",k = 100) == 8\n assert candidate(num = \"55555555555555555555\",k = 100) == 0\n assert candidate(num = \"555444333222111000\",k = 300) == 0\n assert candidate(num = \"123123123123123123123\",k = 200) == 6\n assert candidate(num = \"0000000000000000000000000000000000000000000000000001\",k = 1) == 1\n assert candidate(num = \"33333333332222222222111111111111\",k = 500) == 0\n assert candidate(num = \"9876543210\",k = 50) == 0\n assert candidate(num = \"33333333333333333333333333333333333333333333333333\",k = 1) == 0\n assert candidate(num = \"102030405060708090\",k = 50) == 8\n assert candidate(num = \"989796959493929190898887868584838281807978777675747372717069686766656463626160595857565554535251504948474645444342414039383736353433323130292827262524232221201918171615141312111009080706050403020100\",k = 1000) == 15\n assert candidate(num = \"00000000000000000001\",k = 10) == 10\n assert candidate(num = \"23456789012345678901\",k = 500) == 10\n assert candidate(num = \"0000000000000000000000000000000000001\",k = 1) == 1\n assert candidate(num = \"13579135791357913579\",k = 500) == 7\n assert candidate(num = \"876543210123456789\",k = 500) == 8\n assert candidate(num = \"10000000001\",k = 5) == 5\n assert candidate(num = \"3333333333\",k = 100) == 0\n assert candidate(num = \"1111111111111111111111111111111111111111\",k = 100) == 0\n assert candidate(num = \"98765432101234567890\",k = 20) == 7\n assert candidate(num = \"98765432109876543210\",k = 1000) == 37\n assert candidate(num = \"1221122112211221\",k = 100) == 13\n assert candidate(num = \"222111333000444555666777888999\",k = 500) == 10\n assert candidate(num = \"123456789876543210\",k = 100) == 39\n assert candidate(num = \"11223344556677889900\",k = 50) == 12\n assert candidate(num = \"12345678900987654321\",k = 200) == 31\n assert candidate(num = \"432111111111111111111111111111\",k = 100) == 0\n assert candidate(num = \"9999999999999999999999999999999999999999999999999999\",k = 5) == 0\n assert candidate(num = \"12345678909876543210\",k = 5) == 43\n assert candidate(num = \"11223344556677889900\",k = 100) == 9\n assert candidate(num = \"11111111112222222222\",k = 100) == 11\n assert candidate(num = \"12345678901234567890\",k = 5) == 2\n assert candidate(num = \"133221100998877665544332211\",k = 1000) == 133\n assert candidate(num = \"12345678901234567890\",k = 20) == 7\n assert candidate(num = \"000000000011111111112222222222\",k = 100) == 11\n assert candidate(num = \"55555555555555555555555555555555555555555555555555555\",k = 5) == 0\n assert candidate(num = \"11223344556677889900\",k = 1000) == 11\n assert candidate(num = \"1111222233334444\",k = 1000) == 15\n assert candidate(num = \"9999999999888888888877777777776666666666\",k = 1000) == 0\n assert candidate(num = \"11223344556677889900\",k = 200) == 9\n assert candidate(num = \"99999999999999999999\",k = 1000) == 0\n assert candidate(num = \"2233445566\",k = 300) == 4\n assert candidate(num = \"99999999999999999999\",k = 100) == 0\n assert candidate(num = \"98765432109876543210987654321098765432109876543210\",k = 1000) == 37\n"}, "metadata": {"canonical_parameter_names": ["num", "k"], "leetcode_dataset_entry_point": "Solution().getMinSwaps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getMinSwaps(self, num: str, k: int) -> int:", "container": "Solution", "callable": "getMinSwaps", "parameters": [{"name": "num", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1851, "task_id": "minimum-interval-to-include-each-query", "difficulty": "Hard", "problem_description": "You are given a 2D integer array intervals, where intervals[i] = [lefti, righti] describes the ith interval starting at lefti and ending at righti (inclusive). The size of an interval is defined as the number of integers it contains, or more formally righti - lefti + 1.\nYou are also given an integer array queries. The answer to the jth query is the size of the smallest interval i such that lefti <= queries[j] <= righti. If no such interval exists, the answer is -1.\nReturn an array containing the answers to the queries.\n \nExample 1:\n\nInput: intervals = [[1,4],[2,4],[3,6],[4,4]], queries = [2,3,4,5]\nOutput: [3,3,1,4]\nExplanation: The queries are processed as follows:\n- Query = 2: The interval [2,4] is the smallest interval containing 2. The answer is 4 - 2 + 1 = 3.\n- Query = 3: The interval [2,4] is the smallest interval containing 3. The answer is 4 - 2 + 1 = 3.\n- Query = 4: The interval [4,4] is the smallest interval containing 4. The answer is 4 - 4 + 1 = 1.\n- Query = 5: The interval [3,6] is the smallest interval containing 5. The answer is 6 - 3 + 1 = 4.\n\nExample 2:\n\nInput: intervals = [[2,3],[2,5],[1,8],[20,25]], queries = [2,19,5,22]\nOutput: [2,-1,4,6]\nExplanation: The queries are processed as follows:\n- Query = 2: The interval [2,3] is the smallest interval containing 2. The answer is 3 - 2 + 1 = 2.\n- Query = 19: None of the intervals contain 19. The answer is -1.\n- Query = 5: The interval [2,5] is the smallest interval containing 5. The answer is 5 - 2 + 1 = 4.\n- Query = 22: The interval [20,25] is the smallest interval containing 22. The answer is 25 - 20 + 1 = 6.\n\n \nConstraints:\n\n1 <= intervals.length <= 105\n1 <= queries.length <= 105\nintervals[i].length == 2\n1 <= lefti <= righti <= 107\n1 <= queries[j] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(intervals = [[1, 1], [2, 2]],queries = [1, 2, 3]) == [1, 1, -1]\n assert candidate(intervals = [[1, 10], [10, 20], [15, 25]],queries = [5, 10, 15, 20, 25]) == [10, 10, 11, 11, 11]\n assert candidate(intervals = [[1, 1]],queries = [1]) == [1]\n assert candidate(intervals = [[5, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [-1, -1, -1, -1, 6, 6, 6, 6, 6, 6, -1]\n assert candidate(intervals = [[2, 3], [2, 5], [1, 8], [20, 25]],queries = [2, 19, 5, 22]) == [2, -1, 4, 6]\n assert candidate(intervals = [[5, 5], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [-1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1]\n assert candidate(intervals = [[1, 10000000]],queries = [1, 5000000, 10000000]) == [10000000, 10000000, 10000000]\n assert candidate(intervals = [[1, 4], [2, 4], [3, 6], [4, 4]],queries = [2, 3, 4, 5]) == [3, 3, 1, 4]\n assert candidate(intervals = [[1, 3], [4, 5]],queries = [2, 3, 4, 5]) == [3, 3, 2, 2]\n assert candidate(intervals = [[10000000, 10000000]],queries = [10000000]) == [1]\n assert candidate(intervals = [[5, 5], [1, 2], [3, 4]],queries = [1, 5, 2, 3]) == [2, 1, 2, 2]\n assert candidate(intervals = [[1, 10], [2, 9], [3, 8]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 8, 6, 6, 6, 6, 6, 6, 8, 10]\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300]],queries = [1, 50, 100, 150, 200, 250, 300, 301]) == [100, 100, 100, 101, 101, 101, 101, -1]\n assert candidate(intervals = [[1000, 2000], [500, 1500], [100, 1000], [50, 500], [1, 50]],queries = [1, 50, 100, 500, 1000, 1500, 2000]) == [50, 50, 451, 451, 901, 1001, 1001]\n assert candidate(intervals = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40]],queries = [10, 15, 20, 25, 30, 35, 40, 45]) == [11, 11, 11, 11, 11, 11, 11, -1]\n assert candidate(intervals = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 3, 5, 7, 9]) == [1, 1, 1, 1, 1]\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -1]\n assert candidate(intervals = [[1, 10000000], [5000000, 7500000], [2500000, 3750000], [6250000, 8750000]],queries = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == [10000000, 10000000, 1250001, 10000000, 2500001, 2500001, 2500001, 2500001, 10000000, 10000000]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == [2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 5], [6, 10], [11, 15], [16, 20]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(intervals = [[1, 10], [10, 20], [15, 25], [25, 35], [30, 40], [35, 45]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == [10, 10, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(intervals = [[1000000, 10000000], [2000000, 10000000], [3000000, 10000000], [4000000, 10000000]],queries = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == [9000001, 8000001, 7000001, 6000001, 6000001, 6000001, 6000001, 6000001, 6000001, 6000001]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8]],queries = [1, 2, 3, 4, 5, 6, 7, 8]) == [3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1]\n assert candidate(intervals = [[1, 500000], [500000, 1000000], [1000000, 1500000], [1500000, 2000000], [2000000, 2500000]],queries = [250000, 750000, 1250000, 1750000, 2250000]) == [500000, 500001, 500001, 500001, 500001]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1]\n assert candidate(intervals = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(intervals = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [10, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(intervals = [[1, 5000], [2, 4999], [3, 4998], [4, 4997], [5, 4996], [6, 4995], [7, 4994], [8, 4993], [9, 4992], [10, 4991]],queries = [2500, 3500, 4500, 5500]) == [4982, 4982, 4982, -1]\n assert candidate(intervals = [[1, 1000], [2, 1001], [3, 1002], [4, 1003], [5, 1004], [6, 1005], [7, 1006], [8, 1007], [9, 1008], [10, 1009]],queries = [1, 500, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, -1]\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [1, 19, 10, 2, 9, 18, 7, 16, 5, 15, 3, 14, 11, 13, 6, 12, 8, 17, 4]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70]],queries = [15, 25, 35, 45, 55, 65, 75]) == [11, 11, 11, 11, 11, 11, -1]\n assert candidate(intervals = [[1, 50000], [2, 30000], [3, 20000], [4, 10000]],queries = [1, 2, 3, 4, 5, 10000, 20000, 30000, 50000]) == [50000, 29999, 19998, 9997, 9997, 9997, 19998, 29999, 50000]\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 10000000], [1000000, 2000000], [2000000, 3000000], [3000000, 4000000], [4000000, 5000000], [5000000, 6000000], [6000000, 7000000], [7000000, 8000000], [8000000, 9000000], [9000000, 10000000]],queries = [1, 5000000, 1000000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000, 4500000, 5500000, 6000000, 6500000, 7000000, 7500000, 8000000, 8500000, 9000000, 9500000, 10000000]) == [10000000, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1]\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]],queries = [1, 5, 9, 13, 17]) == [2, 2, 2, 2, -1]\n assert candidate(intervals = [[1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(intervals = [[1, 2000], [2, 1999], [3, 1998], [4, 1997], [5, 1996], [6, 1995], [7, 1994], [8, 1993], [9, 1992], [10, 1991]],queries = [1, 1000, 2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991]) == [2000, 1982, 2000, 1998, 1996, 1994, 1992, 1990, 1988, 1986, 1984, 1982]\n assert candidate(intervals = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30]],queries = [3, 7, 13, 19, 23, 27, 10, 21, 31]) == [5, 5, 5, 5, 5, 5, 5, 5, -1]\n assert candidate(intervals = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70], [75, 80], [85, 90], [95, 100]],queries = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96, 101]) == [-1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1]\n assert candidate(intervals = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11], [6, 13], [7, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]\n assert candidate(intervals = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],queries = [50, 60, 70, 80, 90, 100]) == [82, 82, 82, 82, 82, 100]\n assert candidate(intervals = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]],queries = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90]) == [-1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 10000000]],queries = [1, 1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000]) == [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, -1]\n assert candidate(intervals = [[1, 1000000], [1, 999999], [1, 999998], [1, 999997], [1, 999996]],queries = [500000, 250000, 750000, 125000, 375000]) == [999996, 999996, 999996, 999996, 999996]\n assert candidate(intervals = [[1, 3], [1, 5], [1, 7], [1, 9], [1, 11], [1, 13], [1, 15], [1, 17], [1, 19], [1, 21]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == [3, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17, 17, 19, 19, 21, 21, -1]\n assert candidate(intervals = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996]],queries = [1, 50000, 100000, 99999, 99998]) == [100000, 99992, 100000, 99998, 99996]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(intervals = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [1, 2, 3, 4, 5]) == [10000000, 9999998, 9999996, 9999994, 9999992]\n assert candidate(intervals = [[5, 500], [6, 499], [7, 498], [8, 497], [9, 496]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 500]) == [488, 488, 488, 488, 488, 488, 488, 488, 488, 488, 496]\n assert candidate(intervals = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997]],queries = [1, 2, 3, 4, 5, 9999999, 10000000]) == [10000000, 9999998, 9999996, 9999994, 9999994, 9999998, 10000000]\n assert candidate(intervals = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23]],queries = [1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24]) == [3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1]\n assert candidate(intervals = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [5, 5, 5, 5, 5, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, -1]\n assert candidate(intervals = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15]],queries = [1, 5, 7, 11, 13, 16]) == [3, 3, 3, 3, 3, -1]\n assert candidate(intervals = [[1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3]],queries = [1, 2, 3]) == [3, 3, 3]\n assert candidate(intervals = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],queries = [5, 15, 25, 35, 45]) == [10, 10, 10, 10, 10]\n assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],queries = [3, 4, 5, 6, 7, 8, 9, 1, 2, 10]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997], [5, 999996]],queries = [500000, 250000, 750000, 125000, 375000]) == [999992, 999992, 999992, 999992, 999992]\n assert candidate(intervals = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50]],queries = [3, 7, 12, 18, 23, 28, 33, 38, 43, 48]) == [-1, 6, -1, 6, -1, 6, -1, 6, -1, 6]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [11, 20], [12, 19], [13, 18], [14, 17], [15, 16]],queries = [5, 15, 25, 35, 45]) == [2, 2, -1, -1, -1]\n assert candidate(intervals = [[1, 1], [10000000, 10000000], [2, 9999999], [9999998, 9999998], [3, 9999997], [9999996, 9999996]],queries = [1, 5000000, 10000000, 9999999, 9999998, 9999997, 9999996, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 9999995, 1, 9999998, 1, 9999995, 1, 1, 9999998, 9999995, 9999995, 9999995, 9999995, 9999995, 9999995, 9999995, 9999995]\n assert candidate(intervals = [[1, 2], [4, 6], [8, 10], [12, 14], [16, 18], [20, 22], [24, 26], [28, 30], [32, 34], [36, 38], [40, 42], [44, 46], [48, 50], [52, 54], [56, 58], [60, 62], [64, 66], [68, 70], [72, 74], [76, 78]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79]) == [2, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1]\n assert candidate(intervals = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, -1]\n assert candidate(intervals = [[1, 100000], [50000, 100000], [1, 50000], [100000, 100000]],queries = [1, 25000, 50000, 75000, 100000]) == [50000, 50000, 50000, 50001, 1]\n assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(intervals = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995], [7, 9994]],queries = [1, 2, 3, 4, 5, 6, 7, 10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993]) == [10000, 9998, 9996, 9994, 9992, 9990, 9988, 10000, 9998, 9996, 9994, 9992, 9990, 9988, 9988]\n assert candidate(intervals = [[1, 5000], [1000, 5000], [2000, 5000], [3000, 5000], [4000, 5000]],queries = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000]) == [5000, 4001, 4001, 3001, 3001, 2001, 2001, 1001, 1001, 1001]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [1, 11, 6, 3, 8, 5, 10, 2, 7, 4, 9]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [1, 5, 9, 13, 17, 21]) == [2, 2, 2, 2, 2, -1]\n assert candidate(intervals = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]],queries = [500, 600, 700, 800, 900, 1000]) == [982, 982, 982, 982, 982, 1000]\n assert candidate(intervals = [[1, 1000000], [1000000, 2000000], [2000000, 3000000], [3000000, 4000000], [4000000, 5000000], [5000000, 6000000]],queries = [500000, 1500000, 2500000, 3500000, 4500000, 5500000]) == [1000000, 1000001, 1000001, 1000001, 1000001, 1000001]\n assert candidate(intervals = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 8, 6, 4, 2, 2, 4, 6, 8, 10]\n assert candidate(intervals = [[1, 100000], [2, 99999], [50, 100], [101, 200], [201, 300]],queries = [1, 50, 101, 201, 500, 1000, 100000]) == [100000, 51, 100, 100, 99998, 99998, 100000]\n assert candidate(intervals = [[1, 1000000], [500000, 1500000], [750000, 2000000]],queries = [1, 500000, 1000000, 1500000, 2000000]) == [1000000, 1000000, 1000000, 1000001, 1250001]\n assert candidate(intervals = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]],queries = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(intervals = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -1]\n assert candidate(intervals = [[1000000, 2000000], [1500000, 2500000], [2000000, 3000000]],queries = [1000000, 1500000, 2000000, 2500000, 3000000]) == [1000001, 1000001, 1000001, 1000001, 1000001]\n assert candidate(intervals = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [1, 5000000, 10000000, 9999999, 9999998]) == [10000000, 9999992, 10000000, 9999998, 9999996]\n assert candidate(intervals = [[10, 200], [20, 190], [30, 180], [40, 170], [50, 160]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210]) == [191, 171, 151, 131, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 131, 151, 171, 191, -1]\n assert candidate(intervals = [[1, 100000], [50000, 150000], [75000, 250000]],queries = [10000, 50000, 75000, 150000, 250000]) == [100000, 100000, 100000, 100001, 175001]\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300]],queries = [25, 75, 125, 175, 225]) == [100, 100, 101, 101, 101]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500], [450, 550], [500, 600]],queries = [150, 250, 350, 450, 550, 600, 100, 200, 300, 400, 500]) == [101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101]\n assert candidate(intervals = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],queries = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59]) == [82, 82, 82, 82, 82, 82, 82, 82, 82, 82]\n assert candidate(intervals = [[1, 500], [501, 1000], [1001, 1500], [1501, 2000]],queries = [1, 500, 501, 1000, 1001, 1500, 1501, 2000]) == [500, 500, 500, 500, 500, 500, 500, 500]\n assert candidate(intervals = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [1, 9999998, 5000000, 9999997, 10000000]) == [10000000, 9999996, 9999992, 9999994, 10000000]\n assert candidate(intervals = [[1, 100000], [50000, 150000], [100000, 200000], [250000, 300000], [1, 1000000]],queries = [50000, 150000, 250000, 500000, 999999]) == [100000, 100001, 50001, 1000000, 1000000]\n assert candidate(intervals = [[1, 3], [4, 7], [8, 10], [11, 15], [16, 20], [21, 25], [26, 30]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1]\n assert candidate(intervals = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],queries = [3, 7, 12, 17, 22, 27]) == [5, 5, 5, 5, 5, -1]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]],queries = [1, 3, 5, 7, 9, 11]) == [1, 1, 1, 1, 1, 1]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 3, 5, 7, 9, 11]) == [1, 1, 1, 1, 1, -1]\n assert candidate(intervals = [[1, 10000000], [5000001, 10000000], [5000001, 7500000], [5000001, 6250000], [5000001, 5625000]],queries = [1, 5000000, 5625000, 6250000, 7500000, 10000000]) == [10000000, 10000000, 625000, 1250000, 2500000, 5000000]\n assert candidate(intervals = [[1, 3], [2, 6], [5, 9], [8, 12], [11, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(intervals = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350]],queries = [1, 50, 100, 150, 200, 250, 300, 350]) == [100, 100, 100, 101, 101, 101, 101, 101]\n"}, "metadata": {"canonical_parameter_names": ["intervals", "queries"], "leetcode_dataset_entry_point": "Solution().minInterval", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minInterval(self, intervals: list[list[int]], queries: list[int]) -> list[int]:", "container": "Solution", "callable": "minInterval", "parameters": [{"name": "intervals", "type": "list[list[int]]"}, {"name": "queries", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1854, "task_id": "maximum-population-year", "difficulty": "Easy", "problem_description": "You are given a 2D integer array logs where each logs[i] = [birthi, deathi] indicates the birth and death years of the ith person.\nThe population of some year x is the number of people alive during that year. The ith person is counted in year x's population if x is in the inclusive range [birthi, deathi - 1]. Note that the person is not counted in the year that they die.\nReturn the earliest year with the maximum population.\n \nExample 1:\n\nInput: logs = [[1993,1999],[2000,2010]]\nOutput: 1993\nExplanation: The maximum population is 1, and 1993 is the earliest year with this population.\n\nExample 2:\n\nInput: logs = [[1950,1961],[1960,1971],[1970,1981]]\nOutput: 1960\nExplanation: \nThe maximum population is 2, and it had happened in years 1960 and 1970.\nThe earlier year between them is 1960.\n \nConstraints:\n\n1 <= logs.length <= 100\n1950 <= birthi < deathi <= 2050\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(logs = [[2000, 2005], [2005, 2010], [2010, 2015]]) == 2000\n assert candidate(logs = [[1980, 1985], [1985, 1990], [1990, 1995], [1995, 2000]]) == 1980\n assert candidate(logs = [[2000, 2010], [1990, 2000], [2000, 2020]]) == 2000\n assert candidate(logs = [[1993, 1999], [2000, 2010]]) == 1993\n assert candidate(logs = [[1950, 1960], [1960, 1970], [1970, 1980], [1980, 1990]]) == 1950\n assert candidate(logs = [[1991, 1992], [1992, 1993], [1993, 1994], [1994, 1995]]) == 1991\n assert candidate(logs = [[1950, 2050]]) == 1950\n assert candidate(logs = [[1950, 1961], [1960, 1971], [1970, 1981], [1960, 1980]]) == 1960\n assert candidate(logs = [[1975, 1985], [1985, 1995], [1995, 2005], [2005, 2015]]) == 1975\n assert candidate(logs = [[1990, 1995], [1991, 1996], [1992, 1997]]) == 1992\n assert candidate(logs = [[1950, 1961], [1960, 1971], [1970, 1981]]) == 1960\n assert candidate(logs = [[2000, 2010], [2010, 2020], [2020, 2030]]) == 2000\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005]]) == 1985\n assert candidate(logs = [[1995, 2005], [2005, 2015], [2015, 2025]]) == 1995\n assert candidate(logs = [[2000, 2010], [1990, 2000], [1980, 1990]]) == 1980\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025], [2020, 2030]]) == 1985\n assert candidate(logs = [[1993, 1995], [1994, 1996], [1995, 1997], [1996, 1998], [1997, 1999], [1998, 2000], [1999, 2001], [2000, 2002], [2001, 2003], [2002, 2004], [2003, 2005]]) == 1994\n assert candidate(logs = [[2000, 2005], [2001, 2006], [2002, 2007], [2003, 2008], [2004, 2009], [2005, 2010]]) == 2004\n assert candidate(logs = [[1965, 1980], [1970, 1985], [1975, 1990], [1980, 1995], [1985, 2000]]) == 1975\n assert candidate(logs = [[1950, 1960], [1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010], [2010, 2020], [2020, 2030]]) == 1950\n assert candidate(logs = [[1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025]]) == 1990\n assert candidate(logs = [[1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990]]) == 1960\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005]]) == 1955\n assert candidate(logs = [[1955, 1975], [1960, 1980], [1965, 1985], [1970, 1990], [1975, 1995], [1980, 2000], [1985, 2005], [1990, 2010], [1995, 2015], [2000, 2020]]) == 1970\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015]]) == 1985\n assert candidate(logs = [[1980, 1990], [1981, 1991], [1982, 1992], [1983, 1993], [1984, 1994], [1985, 1995], [1986, 1996], [1987, 1997], [1988, 1998], [1989, 1999]]) == 1989\n assert candidate(logs = [[1950, 2000], [1960, 1990], [1970, 1995], [1980, 2005], [1990, 2010], [2000, 2020]]) == 1980\n assert candidate(logs = [[1975, 1978], [1977, 1980], [1979, 1982], [1981, 1984], [1983, 1986], [1985, 1988], [1987, 1990], [1989, 1992], [1991, 1994], [1993, 1996]]) == 1977\n assert candidate(logs = [[1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025], [2020, 2030], [2025, 2035]]) == 1995\n assert candidate(logs = [[1990, 1991], [1991, 1992], [1992, 1993], [1993, 1994], [1994, 1995], [1995, 1996], [1996, 1997], [1997, 1998], [1998, 1999], [1999, 2000]]) == 1990\n assert candidate(logs = [[1960, 1970], [1961, 1971], [1962, 1972], [1963, 1973], [1964, 1974], [1965, 1975], [1966, 1976], [1967, 1977], [1968, 1978], [1969, 1979], [1970, 1980]]) == 1969\n assert candidate(logs = [[1950, 2050], [1960, 2040], [1970, 2030], [1980, 2020], [1990, 2010], [2000, 2005]]) == 2000\n assert candidate(logs = [[1980, 1985], [1982, 1987], [1984, 1989], [1986, 1991], [1988, 1993]]) == 1984\n assert candidate(logs = [[1950, 2050], [1951, 2049], [1952, 2048], [1953, 2047], [1954, 2046], [1955, 2045], [1956, 2044], [1957, 2043], [1958, 2042], [1959, 2041], [1960, 2040]]) == 1960\n assert candidate(logs = [[1950, 2050], [1960, 1980], [1970, 1990], [1980, 2000], [1990, 2010], [2000, 2020]]) == 1970\n assert candidate(logs = [[1950, 2000], [1960, 1990], [1970, 1980], [1980, 1970], [1990, 1960], [2000, 1950]]) == 1950\n assert candidate(logs = [[1990, 1995], [1991, 1996], [1992, 1997], [1993, 1998], [1994, 1999]]) == 1994\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985]]) == 1955\n assert candidate(logs = [[1950, 1961], [1955, 1966], [1960, 1971], [1965, 1976], [1970, 1981], [1975, 1986]]) == 1960\n assert candidate(logs = [[1980, 1990], [1982, 1992], [1984, 1994], [1986, 1996], [1988, 1998], [1990, 2000]]) == 1988\n assert candidate(logs = [[1955, 1966], [1961, 1971], [1966, 1976], [1971, 1981], [1976, 1986], [1981, 1991], [1986, 1996], [1991, 2001]]) == 1961\n assert candidate(logs = [[1965, 1985], [1970, 1990], [1975, 1995], [1980, 2000], [1985, 2005], [1990, 2010], [1995, 2015], [2000, 2020], [2005, 2025], [2010, 2030]]) == 1980\n assert candidate(logs = [[1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025], [2020, 2030], [2025, 2035], [2030, 2040], [2035, 2045], [2040, 2050]]) == 1975\n assert candidate(logs = [[1950, 1965], [1960, 1975], [1970, 1985], [1980, 1995], [1990, 2005], [2000, 2015], [2010, 2025], [2020, 2035]]) == 1960\n assert candidate(logs = [[1950, 1960], [1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010], [2010, 2020], [2020, 2030], [2030, 2040], [2040, 2050]]) == 1950\n assert candidate(logs = [[1950, 2050], [1955, 2045], [1960, 2040], [1965, 2035], [1970, 2030], [1975, 2025], [1980, 2020], [1985, 2015], [1990, 2010]]) == 1990\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2015], [2005, 2020]]) == 1985\n assert candidate(logs = [[1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015]]) == 1965\n assert candidate(logs = [[1960, 1965], [1961, 1966], [1962, 1967], [1963, 1968], [1964, 1969], [1965, 1970], [1966, 1971], [1967, 1972], [1968, 1973], [1969, 1974]]) == 1964\n assert candidate(logs = [[1950, 1960], [1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010]]) == 1950\n assert candidate(logs = [[1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005]]) == 1960\n assert candidate(logs = [[1993, 1999], [2000, 2010], [1995, 2000], [1985, 1995], [1990, 1998]]) == 1993\n assert candidate(logs = [[1955, 1965], [1950, 1960], [1960, 1970], [1970, 1980], [1965, 1975], [1975, 1985]]) == 1955\n assert candidate(logs = [[1955, 1965], [1965, 1975], [1975, 1985], [1985, 1995], [1995, 2005], [2005, 2015], [2015, 2025]]) == 1955\n assert candidate(logs = [[1970, 1975], [1971, 1976], [1972, 1977], [1973, 1978], [1974, 1979], [1975, 1980]]) == 1974\n assert candidate(logs = [[2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025], [2020, 2030], [2025, 2035], [2030, 2040]]) == 2005\n assert candidate(logs = [[1955, 1961], [1960, 1965], [1965, 1970], [1970, 1975], [1975, 1980], [1980, 1985], [1985, 1990]]) == 1960\n assert candidate(logs = [[1970, 1980], [1971, 1981], [1972, 1982], [1973, 1983], [1974, 1984], [1975, 1985], [1976, 1986], [1977, 1987], [1978, 1988], [1979, 1989], [1980, 1990]]) == 1979\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980]]) == 1955\n assert candidate(logs = [[1975, 1985], [1985, 1995], [1995, 2005], [2005, 2015], [2015, 2025], [2025, 2035]]) == 1975\n assert candidate(logs = [[1990, 2000], [1992, 2002], [1994, 2004], [1996, 2006], [1998, 2008]]) == 1998\n assert candidate(logs = [[1960, 1961], [1961, 1962], [1962, 1963], [1963, 1964], [1964, 1965], [1965, 1966], [1966, 1967], [1967, 1968], [1968, 1969], [1969, 1970], [1970, 1971]]) == 1960\n assert candidate(logs = [[1950, 1955], [1951, 1956], [1952, 1957], [1953, 1958], [1954, 1959], [1955, 1960], [1956, 1961], [1957, 1962], [1958, 1963], [1959, 1964], [1960, 1965]]) == 1954\n assert candidate(logs = [[1993, 1998], [1994, 1999], [1995, 2000], [1996, 2001], [1997, 2002], [1998, 2003], [1999, 2004]]) == 1997\n assert candidate(logs = [[1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995]]) == 1965\n assert candidate(logs = [[1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2000], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025]]) == 1975\n assert candidate(logs = [[1970, 1975], [1971, 1976], [1972, 1977], [1973, 1978], [1974, 1979], [1975, 1980], [1976, 1981], [1977, 1982], [1978, 1983], [1979, 1984]]) == 1974\n assert candidate(logs = [[1950, 2000], [1960, 2010], [1970, 2020], [1980, 2030], [1990, 2040], [2000, 2050]]) == 1990\n assert candidate(logs = [[1950, 1955], [1955, 1960], [1960, 1965], [1965, 1970], [1970, 1975], [1975, 1980], [1980, 1985], [1985, 1990], [1990, 1995], [1995, 2000], [2000, 2005], [2005, 2010], [2010, 2015], [2015, 2020], [2020, 2025], [2025, 2030], [2030, 2035], [2035, 2040], [2040, 2045], [2045, 2050]]) == 1950\n assert candidate(logs = [[1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025]]) == 1995\n assert candidate(logs = [[1950, 1951], [1951, 1952], [1952, 1953], [1953, 1954], [1954, 1955], [1955, 1956], [1956, 1957], [1957, 1958], [1958, 1959], [1959, 1960], [1960, 1961], [1961, 1962], [1962, 1963], [1963, 1964], [1964, 1965]]) == 1950\n assert candidate(logs = [[1950, 1961], [1955, 1966], [1960, 1971], [1965, 1976], [1970, 1981], [1975, 1986], [1980, 1991], [1985, 1996]]) == 1960\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025]]) == 1985\n assert candidate(logs = [[1955, 1975], [1960, 1980], [1965, 1985], [1970, 1990], [1975, 1995], [1980, 2000]]) == 1970\n assert candidate(logs = [[1990, 1995], [1992, 1997], [1994, 1999], [1996, 2001], [1998, 2003]]) == 1994\n assert candidate(logs = [[1955, 1965], [1965, 1975], [1975, 1985], [1985, 1995], [1995, 2005], [2005, 2015], [2015, 2025], [2025, 2035]]) == 1955\n assert candidate(logs = [[1975, 1980], [1978, 1985], [1980, 1985], [1982, 1990], [1985, 1995], [1988, 1995], [1990, 1998], [1992, 2000]]) == 1992\n assert candidate(logs = [[1950, 1980], [1960, 1990], [1970, 2000], [1980, 2010], [1990, 2020]]) == 1970\n assert candidate(logs = [[1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2000], [2000, 2010]]) == 1975\n assert candidate(logs = [[1960, 1970], [1961, 1971], [1962, 1972], [1963, 1973], [1964, 1974], [1965, 1975], [1966, 1976], [1967, 1977]]) == 1967\n assert candidate(logs = [[1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005]]) == 1965\n assert candidate(logs = [[1980, 1985], [1981, 1986], [1982, 1987], [1983, 1988], [1984, 1989], [1985, 1990], [1986, 1991], [1987, 1992]]) == 1984\n assert candidate(logs = [[1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020]]) == 1995\n assert candidate(logs = [[1993, 1995], [1994, 1996], [1995, 1997], [1996, 1998], [1997, 1999]]) == 1994\n assert candidate(logs = [[1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000]]) == 1960\n assert candidate(logs = [[1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010], [2010, 2020], [2020, 2030]]) == 1960\n assert candidate(logs = [[1990, 1995], [1990, 1995], [1990, 1995], [1995, 2000], [1995, 2000], [1995, 2000]]) == 1990\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000]]) == 1955\n assert candidate(logs = [[1980, 1990], [1982, 1992], [1984, 1994], [1986, 1996], [1988, 1998], [1990, 2000], [1992, 2002], [1994, 2004], [1996, 2006], [1998, 2008]]) == 1988\n assert candidate(logs = [[1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010], [2010, 2020]]) == 1960\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990]]) == 1955\n"}, "metadata": {"canonical_parameter_names": ["logs"], "leetcode_dataset_entry_point": "Solution().maximumPopulation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumPopulation(self, logs: list[list[int]]) -> int:", "container": "Solution", "callable": "maximumPopulation", "parameters": [{"name": "logs", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1855, "task_id": "maximum-distance-between-a-pair-of-values", "difficulty": "Medium", "problem_description": "You are given two non-increasing 0-indexed integer arrays nums1​​​​​​ and nums2​​​​​​.\nA pair of indices (i, j), where 0 <= i < nums1.length and 0 <= j < nums2.length, is valid if both i <= j and nums1[i] <= nums2[j]. The distance of the pair is j - i​​​​.\nReturn the maximum distance of any valid pair (i, j). If there are no valid pairs, return 0.\nAn array arr is non-increasing if arr[i-1] >= arr[i] for every 1 <= i < arr.length.\n \nExample 1:\n\nInput: nums1 = [55,30,5,4,2], nums2 = [100,20,10,10,5]\nOutput: 2\nExplanation: The valid pairs are (0,0), (2,2), (2,3), (2,4), (3,3), (3,4), and (4,4).\nThe maximum distance is 2 with pair (2,4).\n\nExample 2:\n\nInput: nums1 = [2,2,2], nums2 = [10,10,1]\nOutput: 1\nExplanation: The valid pairs are (0,0), (0,1), and (1,1).\nThe maximum distance is 1 with pair (0,1).\n\nExample 3:\n\nInput: nums1 = [30,29,19,5], nums2 = [25,25,25,25,25]\nOutput: 2\nExplanation: The valid pairs are (2,2), (2,3), (2,4), (3,3), and (3,4).\nThe maximum distance is 2 with pair (2,4).\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 105\n1 <= nums1[i], nums2[j] <= 105\nBoth nums1 and nums2 are non-increasing.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [100],nums2 = [101]) == 0\n assert candidate(nums1 = [30, 29, 19, 5],nums2 = [25, 25, 25, 25, 25]) == 2\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [10, 9, 8, 7, 6]) == 0\n assert candidate(nums1 = [5],nums2 = [10]) == 0\n assert candidate(nums1 = [10, 9, 8, 7],nums2 = [7, 7, 7, 7]) == 0\n assert candidate(nums1 = [5],nums2 = [5]) == 0\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == 3\n assert candidate(nums1 = [10],nums2 = [5]) == 0\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [100, 90],nums2 = [95, 85]) == 0\n assert candidate(nums1 = [100, 90, 80],nums2 = [100, 90, 80, 70, 60]) == 0\n assert candidate(nums1 = [99999, 99998, 99997],nums2 = [100000, 99999, 99998]) == 1\n assert candidate(nums1 = [1],nums2 = [2]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [5, 5, 5, 5, 5]) == 4\n assert candidate(nums1 = [2, 2, 2],nums2 = [10, 10, 1]) == 1\n assert candidate(nums1 = [100, 50, 25, 10],nums2 = [100, 100, 100, 100]) == 3\n assert candidate(nums1 = [55, 30, 5, 4, 2],nums2 = [100, 20, 10, 10, 5]) == 2\n assert candidate(nums1 = [1],nums2 = [1]) == 0\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [15, 14, 13, 12, 11]) == 4\n assert candidate(nums1 = [100000],nums2 = [100000]) == 0\n assert candidate(nums1 = [50, 40, 30, 20, 10],nums2 = [100, 80, 60, 40, 20]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums1 = [30, 29, 19, 5],nums2 = [25, 25, 25, 25, 25, 20, 15, 10, 5]) == 5\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 9\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 9\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 9\n assert candidate(nums1 = [95, 85, 75, 65, 55],nums2 = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 9\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [100000, 100000, 100000, 100000, 100000],nums2 = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 9\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 9\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 9\n assert candidate(nums1 = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 5\n assert candidate(nums1 = [1],nums2 = [100000]) == 0\n assert candidate(nums1 = [50, 40, 30, 20, 10],nums2 = [55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 5\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [99, 89, 79, 69, 59, 49, 39, 29, 19, 9]) == 0\n assert candidate(nums1 = [999, 888, 777, 666, 555, 444, 333, 222, 111, 0],nums2 = [999, 888, 777, 666, 555, 444, 333, 222, 111, 0]) == 0\n assert candidate(nums1 = [50, 25, 10, 1],nums2 = [50, 40, 30, 25, 20, 15, 10, 5, 1]) == 5\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1]) == 10\n assert candidate(nums1 = [90, 80, 70, 60, 50],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums1 = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],nums2 = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 1\n assert candidate(nums1 = [10, 5, 3, 2],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 4\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 4\n assert candidate(nums1 = [20, 10, 5, 2, 1],nums2 = [50, 40, 30, 20, 10, 5, 2, 1]) == 3\n assert candidate(nums1 = [50, 40, 30, 20, 10],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 5\n assert candidate(nums1 = [100],nums2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 9\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 10\n assert candidate(nums1 = [50, 30, 10],nums2 = [60, 50, 40, 30, 20, 10]) == 3\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [10, 9, 8, 7, 6]) == 0\n assert candidate(nums1 = [90, 70, 50, 30, 10],nums2 = [100, 80, 60, 40, 20]) == 0\n assert candidate(nums1 = [100, 50, 25],nums2 = [150, 120, 90, 70, 50, 30, 10]) == 3\n assert candidate(nums1 = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],nums2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 9\n assert candidate(nums1 = [1000, 900, 800, 700, 600],nums2 = [1000, 950, 900, 850, 800, 750, 700, 650, 600, 550, 500]) == 4\n assert candidate(nums1 = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 1],nums2 = [100000, 99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111]) == 1\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [10, 10, 10, 10, 10, 10],nums2 = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 14\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums1 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],nums2 = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 9\n assert candidate(nums1 = [100, 50, 25, 10, 1],nums2 = [200, 150, 100, 90, 80, 70, 60, 50, 40, 30, 25, 20, 15, 10, 5]) == 10\n assert candidate(nums1 = [10, 5, 5, 5, 5],nums2 = [20, 15, 15, 10, 10, 10, 5, 5, 5, 5]) == 8\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums1 = [5, 4, 4, 3, 3, 3, 2, 1],nums2 = [9, 8, 7, 6, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 9\n assert candidate(nums1 = [100, 50, 30, 20, 10],nums2 = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 10\n assert candidate(nums1 = [100, 50, 25, 10, 5],nums2 = [100, 75, 50, 25, 10, 5, 2]) == 1\n assert candidate(nums1 = [10, 10, 10, 10, 10],nums2 = [20, 20, 20, 20, 20]) == 4\n assert candidate(nums1 = [100000],nums2 = [1]) == 0\n assert candidate(nums1 = [100, 90, 80, 70, 60],nums2 = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maxDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxDistance(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "maxDistance", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1856, "task_id": "maximum-subarray-min-product", "difficulty": "Medium", "problem_description": "The min-product of an array is equal to the minimum value in the array multiplied by the array's sum.\n\nFor example, the array [3,2,5] (minimum value is 2) has a min-product of 2 * (3+2+5) = 2 * 10 = 20.\n\nGiven an array of integers nums, return the maximum min-product of any non-empty subarray of nums. Since the answer may be large, return it modulo 109 + 7.\nNote that the min-product should be maximized before performing the modulo operation. Testcases are generated such that the maximum min-product without modulo will fit in a 64-bit signed integer.\nA subarray is a contiguous part of an array.\n \nExample 1:\n\nInput: nums = [1,2,3,2]\nOutput: 14\nExplanation: The maximum min-product is achieved with the subarray [2,3,2] (minimum value is 2).\n2 * (2+3+2) = 2 * 7 = 14.\n\nExample 2:\n\nInput: nums = [2,3,3,1,2]\nOutput: 18\nExplanation: The maximum min-product is achieved with the subarray [3,3] (minimum value is 3).\n3 * (3+3) = 3 * 6 = 18.\n\nExample 3:\n\nInput: nums = [3,1,5,6,4,2]\nOutput: 60\nExplanation: The maximum min-product is achieved with the subarray [5,6,4] (minimum value is 4).\n4 * (5+6+4) = 4 * 15 = 60.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 9, 6, 8, 7]) == 180\n assert candidate(nums = [2, 1]) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 240\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [10000000]) == 999300007\n assert candidate(nums = [5, 9, 6, 8, 7, 4, 3, 2, 10, 1]) == 180\n assert candidate(nums = [2, 3, 3, 1, 2]) == 18\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996]) == 696500047\n assert candidate(nums = [5, 5, 5, 5, 5]) == 125\n assert candidate(nums = [7, 1, 5, 6, 4, 2]) == 60\n assert candidate(nums = [1, 2, 3, 4, 5]) == 36\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [3, 1, 5, 6, 4, 2]) == 60\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997]) == 817200025\n assert candidate(nums = [5, 4, 3, 2, 1]) == 36\n assert candidate(nums = [1, 2]) == 4\n assert candidate(nums = [1, 2, 3, 2]) == 14\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 72\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 135\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991]) == 643000419\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 2400000\n assert candidate(nums = [5, 8, 6, 7, 8, 9, 9, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 642\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1728\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1728\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 360\n assert candidate(nums = [10, 20, 10, 30, 20, 10, 40, 30, 20, 10]) == 2100\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1728\n assert candidate(nums = [9999999, 1, 9999999, 1, 9999999, 1, 9999999, 1, 9999999, 1]) == 979300008\n assert candidate(nums = [1, 3, 2, 5, 6, 2, 8, 4, 9, 1, 3]) == 84\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990]) == 342300564\n assert candidate(nums = [1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000]) == 999300007\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 756\n assert candidate(nums = [1, 1, 1, 1, 10000000, 1, 1, 1, 1, 10000000, 1, 1, 1, 1]) == 999300007\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [10000000, 10000000, 10000000, 10000000, 10000000]) == 996500007\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5]) == 3600\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 420\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7]) == 90\n assert candidate(nums = [7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == 238\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 420\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 10000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 420\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 240\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 480\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 420\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 480\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 999930007\n assert candidate(nums = [2, 3, 2, 4, 3, 2, 5, 4, 3, 2, 6, 5, 4, 3, 2, 7, 6, 5, 4, 3, 2, 8, 7, 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 10]) == 332\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1728\n assert candidate(nums = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000]) == 998320007\n assert candidate(nums = [3, 2, 1, 4, 3, 2, 5, 4, 3, 6, 5, 4, 7, 6, 5, 8, 7, 6, 9, 8, 7]) == 315\n assert candidate(nums = [10, 20, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1000\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 240\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994]) == 365100133\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1728\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [8, 2, 6, 5, 4, 1, 3, 7, 9]) == 112\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 24000\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 41\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 82\n assert candidate(nums = [10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1]) == 999300007\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 980\n assert candidate(nums = [2, 1, 3, 4, 1, 5, 1, 6, 1, 7]) == 49\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 420\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991]) == 643000419\n assert candidate(nums = [10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000]) == 999300007\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 3300\n assert candidate(nums = [3, 2, 5, 4, 7, 6, 8, 9, 1, 10, 2, 3, 4, 5, 6, 7, 8, 9, 1, 10, 2, 3, 4, 5, 6, 7, 8, 9, 1, 10, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 756\n assert candidate(nums = [1, 5, 4, 3, 6, 2, 8, 7, 9]) == 168\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 81\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 100\n assert candidate(nums = [5, 6, 1, 2, 8, 9, 3, 4, 7, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 240\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1728\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 180\n assert candidate(nums = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000]) == 993000007\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 144\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 148\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [10000000, 1, 10000000, 1, 10000000, 1, 10000000]) == 999300007\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 240\n assert candidate(nums = [1, 10000000, 2, 9999999, 3, 9999998, 4, 9999997, 5, 9999996]) == 999300007\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1]) == 36\n assert candidate(nums = [9999996, 9999997, 9999998, 9999999, 10000000, 9999999, 9999998, 9999997, 9999996]) == 433700087\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 30\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 33\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 24000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 999300007\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 375\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 25\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 999937007\n assert candidate(nums = [1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000]) == 999300007\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxSumMinProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxSumMinProduct(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maxSumMinProduct", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1857, "task_id": "largest-color-value-in-a-directed-graph", "difficulty": "Hard", "problem_description": "There is a directed graph of n colored nodes and m edges. The nodes are numbered from 0 to n - 1.\\r\n\\r\nYou are given a string colors where colors[i] is a lowercase English letter representing the color of the ith node in this graph (0-indexed). You are also given a 2D array edges where edges[j] = [aj, bj] indicates that there is a directed edge from node aj to node bj.\\r\n\\r\nA valid path in the graph is a sequence of nodes x1 -> x2 -> x3 -> ... -> xk such that there is a directed edge from xi to xi+1 for every 1 <= i < k. The color value of the path is the number of nodes that are colored the most frequently occurring color along that path.\\r\n\\r\nReturn the largest color value of any valid path in the given graph, or -1 if the graph contains a cycle.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\n\\r\n\\r\nInput: colors = \"abaca\", edges = [[0,1],[0,2],[2,3],[3,4]]\\r\nOutput: 3\\r\nExplanation: The path 0 -> 2 -> 3 -> 4 contains 3 nodes that are colored \"a\" (red in the above image).\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\n\\r\n\\r\nInput: colors = \"a\", edges = [[0,0]]\\r\nOutput: -1\\r\nExplanation: There is a cycle from 0 to 0.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\tn == colors.length\\r\n\tm == edges.length\\r\n\t1 <= n <= 105\\r\n\t0 <= m <= 105\\r\n\tcolors consists of lowercase English letters.\\r\n\t0 <= aj, bj < n\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(colors = \"abcde\",edges = []) == 1\n assert candidate(colors = \"abcdefghijklmnopqrstuvwxyz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]]) == 1\n assert candidate(colors = \"zzz\",edges = [[0, 1], [1, 2], [2, 0]]) == -1\n assert candidate(colors = \"abacabadabacaba\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 8\n assert candidate(colors = \"aaaaa\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 1\n assert candidate(colors = \"abcde\",edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 1\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5]]) == 1\n assert candidate(colors = \"abcde\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"aaaaa\",edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 5\n assert candidate(colors = \"xyzz\",edges = [[0, 1], [1, 2], [2, 3]]) == 2\n assert candidate(colors = \"abcabc\",edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3]]) == -1\n assert candidate(colors = \"abcdabcdabcd\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 3\n assert candidate(colors = \"xyz\",edges = [[0, 1], [1, 2]]) == 1\n assert candidate(colors = \"aabbcc\",edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3]]) == -1\n assert candidate(colors = \"abcabcabc\",edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3]]) == -1\n assert candidate(colors = \"aabbcc\",edges = [[0, 1], [2, 3], [4, 5]]) == 2\n assert candidate(colors = \"aaabbb\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 3\n assert candidate(colors = \"zzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"aaaa\",edges = [[0, 1], [1, 2], [2, 3], [3, 0]]) == -1\n assert candidate(colors = \"aabbcc\",edges = [[0, 1], [1, 2], [2, 0]]) == -1\n assert candidate(colors = \"a\",edges = []) == 1\n assert candidate(colors = \"abcd\",edges = [[0, 1], [0, 2], [1, 3], [2, 3]]) == 1\n assert candidate(colors = \"aabbbbcccc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 4\n assert candidate(colors = \"abcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 3\n assert candidate(colors = \"a\",edges = [[0, 0]]) == -1\n assert candidate(colors = \"abaca\",edges = [[0, 1], [0, 2], [2, 3], [3, 4]]) == 3\n assert candidate(colors = \"abcd\",edges = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [1, 3]]) == -1\n assert candidate(colors = \"ab\",edges = [[0, 1]]) == 1\n assert candidate(colors = \"aabbcc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 2\n assert candidate(colors = \"zzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0]]) == -1\n assert candidate(colors = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35]]) == 2\n assert candidate(colors = \"abcabcabcabcabcabcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 10]]) == -1\n assert candidate(colors = \"zzzzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == -1\n assert candidate(colors = \"abcbcbc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 2]]) == -1\n assert candidate(colors = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39]]) == 2\n assert candidate(colors = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 0]]) == -1\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == -1\n assert candidate(colors = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49]]) == 2\n assert candidate(colors = \"abacabadabe\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == -1\n assert candidate(colors = \"abcde\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3], [2, 4], [3, 0], [4, 1]]) == -1\n assert candidate(colors = \"aaaaaaaaaa\",edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9], [8, 9]]) == 5\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4], [2, 5], [3, 5], [4, 5]]) == 1\n assert candidate(colors = \"bbaaabbbaaabbbaaabbbaaa\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 8\n assert candidate(colors = \"abcdefghijklmnopqrstuvwx\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23]]) == 1\n assert candidate(colors = \"ababababa\",edges = [[0, 1], [1, 2], [2, 0], [1, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 3]]) == -1\n assert candidate(colors = \"xyzxyzxyz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 2], [1, 3], [4, 6], [5, 7]]) == -1\n assert candidate(colors = \"abcde\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [2, 0], [3, 1]]) == -1\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 2]]) == -1\n assert candidate(colors = \"abacabadabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 5\n assert candidate(colors = \"abcdefghijk\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0]]) == -1\n assert candidate(colors = \"abacabadabe\",edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 3]]) == -1\n assert candidate(colors = \"abcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 10]]) == -1\n assert candidate(colors = \"aaabbbccc\",edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 8], [8, 4], [1, 3], [3, 5], [5, 7]]) == -1\n assert candidate(colors = \"ababababc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0]]) == -1\n assert candidate(colors = \"abcdefghij\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 0], [9, 1]]) == -1\n assert candidate(colors = \"zzzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == -1\n assert candidate(colors = \"aaaabbbbccccdddd\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 4\n assert candidate(colors = \"zzzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(colors = \"aabbccddeeff\",edges = [[0, 1], [0, 5], [1, 2], [1, 3], [2, 4], [3, 4], [5, 6], [5, 7], [6, 8], [7, 8], [8, 9]]) == 2\n assert candidate(colors = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0]]) == -1\n assert candidate(colors = \"abacabadabe\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 5\n assert candidate(colors = \"abcde\",edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"abcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [1, 3], [3, 5], [5, 7]]) == -1\n assert candidate(colors = \"abcabcabcabcabcabcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 28]]) == -1\n assert candidate(colors = \"abcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0]]) == -1\n assert candidate(colors = \"abacbacba\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 4\n assert candidate(colors = \"abacabadabe\",edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9], [8, 9]]) == 4\n assert candidate(colors = \"abacabadaba\",edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 9]]) == 5\n assert candidate(colors = \"abacabadaba\",edges = [[0, 1], [1, 0], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == -1\n assert candidate(colors = \"ababababab\",edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 9], [8, 9]]) == 5\n assert candidate(colors = \"abacabadaba\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 5\n assert candidate(colors = \"abcabcabcabcabcabcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == 10\n assert candidate(colors = \"abcdefghij\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == -1\n assert candidate(colors = \"abacabadaba\",edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 5\n assert candidate(colors = \"aabbaabb\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]]) == -1\n assert candidate(colors = \"abcdefgabcdefgabcdefgabcdefg\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 7]]) == -1\n assert candidate(colors = \"aaabbbcccdddeeefffggghhh\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23]]) == 3\n assert candidate(colors = \"abcdefghijk\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(colors = \"aaaabbbbccccdddd\",edges = [[0, 1], [0, 4], [1, 2], [1, 5], [2, 3], [2, 6], [3, 7], [4, 5], [4, 8], [5, 6], [5, 9], [6, 7], [6, 10], [7, 11], [8, 9], [8, 12], [9, 10], [9, 13], [10, 11], [10, 14], [11, 15], [12, 13], [13, 14], [14, 15]]) == 4\n assert candidate(colors = \"abcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 5\n assert candidate(colors = \"abcde\",edges = [[0, 1], [0, 2], [2, 1], [1, 3], [2, 3], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"zzzzzzyyyyy\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 6\n assert candidate(colors = \"abacabadabacaba\",edges = [[0, 1], [0, 2], [2, 3], [3, 4], [1, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 6\n"}, "metadata": {"canonical_parameter_names": ["colors", "edges"], "leetcode_dataset_entry_point": "Solution().largestPathValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def largestPathValue(self, colors: str, edges: list[list[int]]) -> int:", "container": "Solution", "callable": "largestPathValue", "parameters": [{"name": "colors", "type": "str"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1859, "task_id": "sorting-the-sentence", "difficulty": "Easy", "problem_description": "A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase English letters.\nA sentence can be shuffled by appending the 1-indexed word position to each word then rearranging the words in the sentence.\n\nFor example, the sentence \"This is a sentence\" can be shuffled as \"sentence4 a3 is2 This1\" or \"is2 sentence4 This1 a3\".\n\nGiven a shuffled sentence s containing no more than 9 words, reconstruct and return the original sentence.\n \nExample 1:\n\nInput: s = \"is2 sentence4 This1 a3\"\nOutput: \"This is a sentence\"\nExplanation: Sort the words in s to their original positions \"This1 is2 a3 sentence4\", then remove the numbers.\n\nExample 2:\n\nInput: s = \"Myself2 Me1 I4 and3\"\nOutput: \"Me Myself and I\"\nExplanation: Sort the words in s to their original positions \"Me1 Myself2 and3 I4\", then remove the numbers.\n\n \nConstraints:\n\n2 <= s.length <= 200\ns consists of lowercase and uppercase English letters, spaces, and digits from 1 to 9.\nThe number of words in s is between 1 and 9.\nThe words in s are separated by a single space.\ns contains no leading or trailing spaces.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"eight8 seven7 six6 five5 four4 three3 two2 one1\") == \"one two three four five six seven eight\"\n assert candidate(s = \"seven7 six6 five5 four4 three3 two2 one1\") == \"one two three four five six seven\"\n assert candidate(s = \"nine9 eight8 seven7 six6 five5 four4 three3 two2 one1\") == \"one two three four five six seven eight nine\"\n assert candidate(s = \"three3 two2 one1\") == \"one two three\"\n assert candidate(s = \"is2 sentence4 This1 a3\") == \"This is a sentence\"\n assert candidate(s = \"five5 four4 three3 two2 one1\") == \"one two three four five\"\n assert candidate(s = \"A9 B8 C7 D6 E5 F4 G3 H2 I1\") == \"I H G F E D C B A\"\n assert candidate(s = \"Myself2 Me1 I4 and3\") == \"Me Myself and I\"\n assert candidate(s = \"nine9 eight8 seven7 six6 five5 four4 three3 two2 one1 zero0\") == \"one two three four five six seven eight nine zero\"\n assert candidate(s = \"six6 five5 four4 three3 two2 one1\") == \"one two three four five six\"\n assert candidate(s = \"one1\") == \"one\"\n assert candidate(s = \"two1 one2\") == \"two one\"\n assert candidate(s = \"four4 three3 two2 one1\") == \"one two three four\"\n assert candidate(s = \"quick5 brown3 fox2 jumps9 over8 lazy4 the7 dog6 a1\") == \"a fox brown lazy quick dog the over jumps\"\n assert candidate(s = \"Quick5 brown4 fox3 jumps2 over1\") == \"over jumps fox brown Quick\"\n assert candidate(s = \"big2 bigger3 biggest1\") == \"biggest big bigger\"\n assert candidate(s = \"order10 words9 in8 correct7 sequence6 is5 important4 for3 understanding2 this1\") == \"this understanding for important is sequence correct in words order1\"\n assert candidate(s = \"a1 bc2 def3 ghij4 klmno5 pqrstu6 vwxyz7 abcdefg8 hijklmno9\") == \"a bc def ghij klmno pqrstu vwxyz abcdefg hijklmno\"\n assert candidate(s = \"abc1 def2 ghi3 jkl4 mno5 pqr6 stu7 vwx8 yza9\") == \"abc def ghi jkl mno pqr stu vwx yza\"\n assert candidate(s = \"Data2 Science1\") == \"Science Data\"\n assert candidate(s = \"alpha10 beta9 gamma8 delta7 epsilon6 zeta5 eta4 theta3 iota2 kappa1\") == \"kappa iota theta eta zeta epsilon delta gamma beta alpha1\"\n assert candidate(s = \"Quick5 Brown4 Fox3 Jumps2 Over1\") == \"Over Jumps Fox Brown Quick\"\n assert candidate(s = \"Digital2 Transformation1\") == \"Transformation Digital\"\n assert candidate(s = \"zebra9 yellow8 xenon7 winter6 volcano5 umbrella4 tornado3 storm2 rainbow1\") == \"rainbow storm tornado umbrella volcano winter xenon yellow zebra\"\n assert candidate(s = \"short1 longerWord2 evenLongerWord3\") == \"short longerWord evenLongerWord\"\n assert candidate(s = \"one9 two8 three7 four6 five5 six4 seven3 eight2 nine1\") == \"nine eight seven six five four three two one\"\n assert candidate(s = \"apple8 banana7 cherry6 date5 elderberry4 fig3 grape2 huckleberry1\") == \"huckleberry grape fig elderberry date cherry banana apple\"\n assert candidate(s = \"apple9 banana8 cherry7 date6 elderberry5 fig4 grape3 honeydew2 ice1\") == \"ice honeydew grape fig elderberry date cherry banana apple\"\n assert candidate(s = \"MixedCASE1 Word2 with3 DIFFERENT4 cases5\") == \"MixedCASE Word with DIFFERENT cases\"\n assert candidate(s = \"Python1 is2 great3\") == \"Python is great\"\n assert candidate(s = \"a9 b8 c7 d6 e5 f4 g3 h2 i1\") == \"i h g f e d c b a\"\n assert candidate(s = \"single1\") == \"single\"\n assert candidate(s = \"one1 two2 three3 four4 five5 six6 seven7 eight8 nine9\") == \"one two three four five six seven eight nine\"\n assert candidate(s = \"reverse9 order8 words7 in6 a5 sentence4 for3 testing2 purposes1\") == \"purposes testing for sentence a in words order reverse\"\n assert candidate(s = \"sun8 moon7 stars6 galaxy5 universe4 planets3 asteroid2 comet1\") == \"comet asteroid planets universe galaxy stars moon sun\"\n assert candidate(s = \"two2 one1 three3 four4 five5 six6 seven7 eight8 nine9\") == \"one two three four five six seven eight nine\"\n assert candidate(s = \"complex1 testing2 cases3 with4 multiple5 digits6 and7 shuffled8 order9\") == \"complex testing cases with multiple digits and shuffled order\"\n assert candidate(s = \"Sustainability1\") == \"Sustainability\"\n assert candidate(s = \"Hard2 Work3 Makes1 Success4\") == \"Makes Hard Work Success\"\n assert candidate(s = \"A5 B4 C3 D2 E1 F6 G7 H8 I9\") == \"E D C B A F G H I\"\n assert candidate(s = \"Alphabetically9 Better8 Christmas7 Does6 Everyone5 Feel4 Good3 Happy2 Indeed1\") == \"Indeed Happy Good Feel Everyone Does Christmas Better Alphabetically\"\n assert candidate(s = \"sun9 moon8 star7 planet6 comet5 asteroid4 meteor3 satellite2 galaxy1\") == \"galaxy satellite meteor asteroid comet planet star moon sun\"\n assert candidate(s = \"The9 quick8 brown7 fox6 jumps5 over4 lazy3 dog2 one1\") == \"one dog lazy over jumps fox brown quick The\"\n assert candidate(s = \"short6 longer5 very4 much3 more2 words1\") == \"words more much very longer short\"\n assert candidate(s = \"first1 second2 third3 fourth4 fifth5 sixth6 seventh7 eighth8 ninth9\") == \"first second third fourth fifth sixth seventh eighth ninth\"\n assert candidate(s = \"Two2 Words1\") == \"Words Two\"\n assert candidate(s = \"Complicated1 Sorting2 becomes3 significantly4 more5 challenging6 when7 words8 overlap9\") == \"Complicated Sorting becomes significantly more challenging when words overlap\"\n assert candidate(s = \"Python10 Java9 C8 Cpp7 Rust6 Go5 Ruby4 Swift3 Kotlin2 TypeScript1\") == \"TypeScript Kotlin Swift Ruby Go Rust Cpp C Java Python1\"\n assert candidate(s = \"zZ9 yY8 xX7 wW6 vV5 uU4 tT3 sS2 rR1\") == \"rR sS tT uU vV wW xX yY zZ\"\n assert candidate(s = \"A9 lot8 of7 testing6 needs5 to4 be3 done2 always1\") == \"always done be to needs testing of lot A\"\n assert candidate(s = \"z9 y8 x7 w6 v5 u4 t3 s2 r1\") == \"r s t u v w x y z\"\n assert candidate(s = \"twoWords2 oneWord1\") == \"oneWord twoWords\"\n assert candidate(s = \"ab9 cd8 ef7 gh6 ij5 kl4 mn3 op2 qr1\") == \"qr op mn kl ij gh ef cd ab\"\n assert candidate(s = \"Open3 Source2 Software1\") == \"Software Source Open\"\n assert candidate(s = \"a9 quick8 brown7 fox6 jumps5 over4 lazy3 dogs2 one1\") == \"one dogs lazy over jumps fox brown quick a\"\n assert candidate(s = \"aA9 bB8 cC7 dD6 eE5 fF4 gG3 hH2 iI1\") == \"iI hH gG fF eE dD cC bB aA\"\n assert candidate(s = \"shuffle7 sentence6 original5 reconstruct4 and3 a2 is1\") == \"is a and reconstruct original sentence shuffle\"\n assert candidate(s = \"shuffle9 words8 correctly7 to6 get5 the4 right3 order2 one1\") == \"one order right the get to correctly words shuffle\"\n assert candidate(s = \"HELLO1 woRLD2\") == \"HELLO woRLD\"\n assert candidate(s = \"Short1 words2 can3 also4 be5 tricky6\") == \"Short words can also be tricky\"\n assert candidate(s = \"Python3 Java2 C1 Ruby4 Go5\") == \"C Java Python Ruby Go\"\n assert candidate(s = \"mixed8 case7 word6 CASE5 Mixed4 CASE3 mixed2 CASE1\") == \"CASE mixed CASE Mixed CASE word case mixed\"\n assert candidate(s = \"Python3 Java2 C1\") == \"C Java Python\"\n assert candidate(s = \"This8 is7 a6 sample5 sentence4 with3 various2 words1\") == \"words various with sentence sample a is This\"\n assert candidate(s = \"ninja9 samurai8 katana7 wakizashi6 tanto5 yoroi4 kusarigama3 tsurugi2 ninja1\") == \"ninja tsurugi kusarigama yoroi tanto wakizashi katana samurai ninja\"\n assert candidate(s = \"alpha9 beta8 gamma7 delta6 epsilon5 zeta4 eta3 theta2 iota1\") == \"iota theta eta zeta epsilon delta gamma beta alpha\"\n assert candidate(s = \"zebra9 yak8 xenon7 wolf6 vulture5 unicorn4 tiger3 snake2 rabbit1\") == \"rabbit snake tiger unicorn vulture wolf xenon yak zebra\"\n assert candidate(s = \"repeated1 same2 numbers3 in4 different5 words6 should7 not8 be9 valid10\") == \"repeated same numbers in different words should not be valid1\"\n assert candidate(s = \"reverse9 order8 words7 in6 this5 shuffled4 sentence3 into2 proper1\") == \"proper into sentence shuffled this in words order reverse\"\n assert candidate(s = \"Single1\") == \"Single\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().sortSentence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def sortSentence(self, s: str) -> str:", "container": "Solution", "callable": "sortSentence", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1860, "task_id": "incremental-memory-leak", "difficulty": "Medium", "problem_description": "You are given two integers memory1 and memory2 representing the available memory in bits on two memory sticks. There is currently a faulty program running that consumes an increasing amount of memory every second.\nAt the ith second (starting from 1), i bits of memory are allocated to the stick with more available memory (or from the first memory stick if both have the same available memory). If neither stick has at least i bits of available memory, the program crashes.\nReturn an array containing [crashTime, memory1crash, memory2crash], where crashTime is the time (in seconds) when the program crashed and memory1crash and memory2crash are the available bits of memory in the first and second sticks respectively.\n \nExample 1:\n\nInput: memory1 = 2, memory2 = 2\nOutput: [3,1,0]\nExplanation: The memory is allocated as follows:\n- At the 1st second, 1 bit of memory is allocated to stick 1. The first stick now has 1 bit of available memory.\n- At the 2nd second, 2 bits of memory are allocated to stick 2. The second stick now has 0 bits of available memory.\n- At the 3rd second, the program crashes. The sticks have 1 and 0 bits available respectively.\n\nExample 2:\n\nInput: memory1 = 8, memory2 = 11\nOutput: [6,0,4]\nExplanation: The memory is allocated as follows:\n- At the 1st second, 1 bit of memory is allocated to stick 2. The second stick now has 10 bit of available memory.\n- At the 2nd second, 2 bits of memory are allocated to stick 2. The second stick now has 8 bits of available memory.\n- At the 3rd second, 3 bits of memory are allocated to stick 1. The first stick now has 5 bits of available memory.\n- At the 4th second, 4 bits of memory are allocated to stick 2. The second stick now has 4 bits of available memory.\n- At the 5th second, 5 bits of memory are allocated to stick 1. The first stick now has 0 bits of available memory.\n- At the 6th second, the program crashes. The sticks have 0 and 4 bits available respectively.\n\n \nConstraints:\n\n0 <= memory1, memory2 <= 231 - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(memory1 = 0,memory2 = 0) == [1, 0, 0]\n assert candidate(memory1 = 2147483647,memory2 = 2147483647) == [92681, 88047, 41707]\n assert candidate(memory1 = 1000000000,memory2 = 1000000000) == [63245, 49116, 17494]\n assert candidate(memory1 = 15,memory2 = 10) == [7, 4, 0]\n assert candidate(memory1 = 100,memory2 = 100) == [20, 0, 10]\n assert candidate(memory1 = 10,memory2 = 10) == [6, 1, 4]\n assert candidate(memory1 = 1073741823,memory2 = 1073741823) == [65535, 65534, 32767]\n assert candidate(memory1 = 1,memory2 = 1) == [2, 0, 1]\n assert candidate(memory1 = 8,memory2 = 11) == [6, 0, 4]\n assert candidate(memory1 = 1073741824,memory2 = 1073741824) == [65536, 0, 32768]\n assert candidate(memory1 = 15,memory2 = 15) == [7, 6, 3]\n assert candidate(memory1 = 1,memory2 = 2) == [2, 1, 1]\n assert candidate(memory1 = 15,memory2 = 5) == [6, 0, 5]\n assert candidate(memory1 = 100,memory2 = 50) == [17, 3, 11]\n assert candidate(memory1 = 2,memory2 = 2) == [3, 1, 0]\n assert candidate(memory1 = 1000000000,memory2 = 500000000) == [54772, 3472, 37922]\n assert candidate(memory1 = 0,memory2 = 1000000) == [1414, 0, 1009]\n assert candidate(memory1 = 1024,memory2 = 512) == [55, 12, 39]\n assert candidate(memory1 = 123456789,memory2 = 987654321) == [47140, 11258, 33622]\n assert candidate(memory1 = 256,memory2 = 255) == [32, 15, 0]\n assert candidate(memory1 = 1000000000,memory2 = 999999999) == [63245, 17493, 49116]\n assert candidate(memory1 = 2048,memory2 = 512) == [71, 67, 8]\n assert candidate(memory1 = 5,memory2 = 1) == [3, 2, 1]\n assert candidate(memory1 = 500000000,memory2 = 499999999) == [44721, 8039, 30400]\n assert candidate(memory1 = 100000,memory2 = 100001) == [632, 460, 145]\n assert candidate(memory1 = 1073741823,memory2 = 1073741824) == [65536, 32767, 0]\n assert candidate(memory1 = 2147483647,memory2 = 1073741824) == [80264, 34153, 76602]\n assert candidate(memory1 = 1000000,memory2 = 0) == [1414, 1009, 0]\n assert candidate(memory1 = 5,memory2 = 5) == [4, 1, 3]\n assert candidate(memory1 = 0,memory2 = 100) == [14, 0, 9]\n assert candidate(memory1 = 1000000000,memory2 = 2000000000) == [77459, 17790, 72599]\n assert candidate(memory1 = 500000000,memory2 = 500000001) == [44721, 8040, 30401]\n assert candidate(memory1 = 500000,memory2 = 500000) == [1414, 151, 858]\n assert candidate(memory1 = 2000000000,memory2 = 1000000000) == [77459, 72599, 17790]\n assert candidate(memory1 = 1,memory2 = 0) == [2, 0, 0]\n assert candidate(memory1 = 4000000000,memory2 = 3000000000) == [118321, 102440, 27200]\n assert candidate(memory1 = 1000000,memory2 = 1000000) == [2000, 0, 1000]\n assert candidate(memory1 = 3000000000,memory2 = 1000000000) == [89442, 62751, 46288]\n assert candidate(memory1 = 2147483647,memory2 = 0) == [65536, 32767, 0]\n assert candidate(memory1 = 500000000,memory2 = 500000000) == [44721, 30400, 8040]\n assert candidate(memory1 = 1234567890,memory2 = 1234567890) == [70272, 29394, 64530]\n assert candidate(memory1 = 1024,memory2 = 1023) == [64, 31, 0]\n assert candidate(memory1 = 1023,memory2 = 1024) == [64, 31, 0]\n assert candidate(memory1 = 1048576,memory2 = 1048576) == [2048, 0, 1024]\n assert candidate(memory1 = 512,memory2 = 1024) == [55, 39, 12]\n assert candidate(memory1 = 1000000000,memory2 = 1000000001) == [63245, 17494, 49117]\n assert candidate(memory1 = 4,memory2 = 5) == [4, 2, 1]\n assert candidate(memory1 = 0,memory2 = 2147483647) == [65536, 0, 32767]\n assert candidate(memory1 = 512,memory2 = 2048) == [71, 8, 67]\n assert candidate(memory1 = 1000000,memory2 = 999999) == [2000, 999, 0]\n assert candidate(memory1 = 2147483647,memory2 = 2147483646) == [92681, 41706, 88047]\n assert candidate(memory1 = 4,memory2 = 4) == [4, 0, 2]\n assert candidate(memory1 = 4096,memory2 = 2048) == [110, 102, 47]\n assert candidate(memory1 = 1024,memory2 = 1024) == [64, 0, 32]\n assert candidate(memory1 = 2147483646,memory2 = 1) == [65536, 32766, 1]\n assert candidate(memory1 = 234567890,memory2 = 234567890) == [30631, 18665, 3350]\n assert candidate(memory1 = 2147483646,memory2 = 2147483646) == [92681, 88046, 41706]\n assert candidate(memory1 = 1,memory2 = 1000000000) == [44721, 1, 38440]\n assert candidate(memory1 = 999999999,memory2 = 1) == [44721, 38439, 1]\n assert candidate(memory1 = 500,memory2 = 500) == [44, 16, 38]\n assert candidate(memory1 = 2,memory2 = 1) == [2, 1, 1]\n assert candidate(memory1 = 128,memory2 = 256) == [27, 23, 10]\n assert candidate(memory1 = 1,memory2 = 1073741823) == [46341, 1, 20853]\n assert candidate(memory1 = 100000,memory2 = 100000) == [632, 144, 460]\n assert candidate(memory1 = 4294967295,memory2 = 4294967295) == [131071, 131070, 65535]\n assert candidate(memory1 = 0,memory2 = 1000) == [45, 0, 10]\n assert candidate(memory1 = 2147483646,memory2 = 2147483645) == [92681, 41705, 88046]\n assert candidate(memory1 = 10,memory2 = 1) == [5, 0, 1]\n assert candidate(memory1 = 0,memory2 = 1) == [2, 0, 0]\n assert candidate(memory1 = 1000000001,memory2 = 1000000000) == [63245, 17494, 49117]\n assert candidate(memory1 = 1,memory2 = 2147483647) == [65536, 1, 32767]\n assert candidate(memory1 = 100,memory2 = 0) == [14, 9, 0]\n assert candidate(memory1 = 2147483646,memory2 = 2147483647) == [92681, 41706, 88047]\n assert candidate(memory1 = 1073741823,memory2 = 1073741825) == [65536, 0, 32768]\n assert candidate(memory1 = 10,memory2 = 15) == [7, 0, 4]\n assert candidate(memory1 = 9,memory2 = 9) == [6, 0, 3]\n assert candidate(memory1 = 1000,memory2 = 1000) == [63, 39, 8]\n assert candidate(memory1 = 2048,memory2 = 4096) == [110, 47, 102]\n assert candidate(memory1 = 1000,memory2 = 0) == [45, 10, 0]\n assert candidate(memory1 = 1,memory2 = 5) == [3, 1, 2]\n assert candidate(memory1 = 1000000000,memory2 = 1) == [44721, 38440, 1]\n"}, "metadata": {"canonical_parameter_names": ["memory1", "memory2"], "leetcode_dataset_entry_point": "Solution().memLeak", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def memLeak(self, memory1: int, memory2: int) -> list[int]:", "container": "Solution", "callable": "memLeak", "parameters": [{"name": "memory1", "type": "int"}, {"name": "memory2", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1861, "task_id": "rotating-the-box", "difficulty": "Medium", "problem_description": "You are given an m x n matrix of characters boxGrid representing a side-view of a box. Each cell of the box is one of the following:\n\nA stone '#'\nA stationary obstacle '*'\nEmpty '.'\n\nThe box is rotated 90 degrees clockwise, causing some of the stones to fall due to gravity. Each stone falls down until it lands on an obstacle, another stone, or the bottom of the box. Gravity does not affect the obstacles' positions, and the inertia from the box's rotation does not affect the stones' horizontal positions.\nIt is guaranteed that each stone in boxGrid rests on an obstacle, another stone, or the bottom of the box.\nReturn an n x m matrix representing the box after the rotation described above.\n \nExample 1:\n\n\nInput: boxGrid = [[\"#\",\".\",\"#\"]]\nOutput: [[\".\"],\n  [\"#\"],\n  [\"#\"]]\n\nExample 2:\n\n\nInput: boxGrid = [[\"#\",\".\",\"*\",\".\"],\n  [\"#\",\"#\",\"*\",\".\"]]\nOutput: [[\"#\",\".\"],\n  [\"#\",\"#\"],\n  [\"*\",\"*\"],\n  [\".\",\".\"]]\n\nExample 3:\n\n\nInput: boxGrid = [[\"#\",\"#\",\"*\",\".\",\"*\",\".\"],\n  [\"#\",\"#\",\"#\",\"*\",\".\",\".\"],\n  [\"#\",\"#\",\"#\",\".\",\"#\",\".\"]]\nOutput: [[\".\",\"#\",\"#\"],\n  [\".\",\"#\",\"#\"],\n  [\"#\",\"#\",\"*\"],\n  [\"#\",\"*\",\".\"],\n  [\"#\",\".\",\"*\"],\n  [\"#\",\".\",\".\"]]\n\n \nConstraints:\n\nm == boxGrid.length\nn == boxGrid[i].length\n1 <= m, n <= 500\nboxGrid[i][j] is either '#', '*', or '.'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(boxGrid = [['#', '.', '*', '.'], ['#', '#', '*', '.']]) == [['#', '.'], ['#', '#'], ['*', '*'], ['.', '.']]\n assert candidate(boxGrid = [['#', '.', '#']]) == [['.'], ['#'], ['#']]\n assert candidate(boxGrid = [['#', '#', '*', '.', '*', '.'], ['#', '#', '#', '*', '.', '.'], ['#', '#', '#', '.', '#', '.']]) == [['.', '#', '#'], ['.', '#', '#'], ['#', '#', '*'], ['#', '*', '.'], ['#', '.', '*'], ['#', '.', '.']]\n assert candidate(boxGrid = [['*', '.', '.', '.', '#', '.', '*', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['#', '.', '.', '.', '.']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '*', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '*', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '#', '#', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '#', '*', '.'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '#'], ['.', '.', '#'], ['.', '#', '*'], ['#', '#', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '#', '.'], ['*', '.', '#', '.', '.', '#'], ['#', '.', '*', '.', '#', '.'], ['.', '#', '#', '*', '.', '.']]) == [['.', '.', '*', '.'], ['#', '#', '.', '.'], ['#', '*', '.', '.'], ['*', '.', '.', '.'], ['.', '.', '#', '#'], ['.', '#', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '#', '*'], ['*', '.', '.', '#'], ['.', '#', '.', '.'], ['#', '.', '.', '.']]) == [['.', '.', '*', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#'], ['#', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '*', '.', '.'], ['.', '#', '#', '.', '.', '#'], ['#', '.', '.', '.', '#', '.'], ['#', '.', '*', '.', '.', '*'], ['.', '.', '.', '#', '#', '.']]) == [['.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.'], ['.', '*', '.', '.', '#'], ['.', '.', '.', '#', '*'], ['#', '.', '#', '#', '.'], ['#', '*', '#', '#', '.']]\n assert candidate(boxGrid = [['*', '.', '.', '#'], ['.', '#', '#', '*'], ['.', '#', '.', '.'], ['.', '.', '.', '.']]) == [['.', '.', '.', '*'], ['.', '.', '#', '.'], ['.', '.', '#', '.'], ['.', '#', '*', '#']]\n assert candidate(boxGrid = [['#', '.', '*', '.', '#', '.', '*', '.'], ['.', '#', '.', '.', '.', '#', '.', '.'], ['.', '.', '#', '.', '.', '.', '#', '.']]) == [['.', '.', '.'], ['.', '.', '#'], ['.', '.', '*'], ['.', '.', '.'], ['.', '.', '.'], ['.', '.', '#'], ['#', '#', '*'], ['#', '#', '.']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '*'], ['.', '#', '#', '.', '.'], ['.', '.', '*', '.', '#'], ['#', '.', '.', '#', '.']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '*', '.', '#'], ['#', '.', '#', '#'], ['#', '#', '#', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#', '*', '.'], ['.', '.', '#', '*', '.', '.', '.'], ['#', '*', '.', '.', '.', '.', '.']]) == [['#', '.', '.', '.'], ['*', '.', '.', '.'], ['.', '#', '.', '.'], ['.', '*', '.', '.'], ['.', '.', '#', '.'], ['.', '.', '*', '.'], ['.', '.', '.', '#']]\n assert candidate(boxGrid = [['#', '#', '*', '#', '.', '.', '*', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '*', '.', '.'], ['.', '.', '.', '.', '#', '.', '.', '#', '.']]) == [['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '*', '.', '.', '*'], ['#', '.', '#', '.', '.'], ['#', '.', '#', '#', '.']]\n assert candidate(boxGrid = [['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '*'], ['.', '.', '#', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '#', '*', '#', '.', '#', '#']]\n assert candidate(boxGrid = [['#', '#', '#', '.', '.', '.', '*'], ['.', '.', '#', '#', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '.', '*', '.', '.', '.'], ['#', '.', '#', '.', '.', '.', '#'], ['.', '.', '.', '.', '#', '.', '.'], ['.', '*', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.', '.'], ['*', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '*', '.', '.', '#'], ['.', '.', '#', '.', '.', '.', '#'], ['.', '.', '#', '.', '#', '#', '#'], ['.', '#', '#', '.', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '#', '*', '.', '*', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['*', '.', '.', '.', '*', '.', '.'], ['.', '#', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#']]) == [['.', '.', '*', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['.', '.', '*', '.', '.'], ['.', '#', '.', '.', '*'], ['#', '#', '.', '.', '.']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['#', '#', '#', '.'], ['.', '.', '#', '.'], ['.', '#', '.', '.']]) == [['.', '.', '.', '.'], ['.', '.', '#', '.'], ['.', '.', '#', '.'], ['#', '#', '#', '.']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '*'], ['#', '#', '#', '#', '#']]) == [['#', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['#', '*', '.', '.', '.', '.']]\n assert candidate(boxGrid = [['#', '#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.', '.'], ['*', '*', '*', '*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#']]\n assert candidate(boxGrid = [['.', '.', '#', '*', '#'], ['#', '.', '#', '.', '.'], ['.', '*', '.', '#', '.']]) == [['.', '.', '.'], ['*', '.', '.'], ['.', '.', '#'], ['.', '#', '*'], ['#', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '*']]) == [['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['*', '#', '#', '#', '#', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '#', '.', '#', '.', '*', '.'], ['.', '.', '#', '.', '.', '.', '#', '.'], ['#', '.', '.', '.', '*', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['*', '.', '.', '.', '.', '.', '.', '*'], ['.', '#', '.', '.', '.', '.', '.', '.']]) == [['.', '*', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '#'], ['.', '.', '.', '*', '.', '#'], ['.', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#', '*'], ['#', '*', '.', '.', '#', '.']]\n assert candidate(boxGrid = [['#', '#', '#', '#', '*', '.'], ['.', '.', '*', '#', '.', '#'], ['*', '.', '#', '.', '.', '#'], ['#', '#', '#', '#', '.', '.']]) == [['.', '*', '.', '#'], ['.', '.', '.', '#'], ['#', '.', '*', '#'], ['#', '.', '.', '#'], ['#', '#', '#', '*'], ['#', '#', '#', '.']]\n assert candidate(boxGrid = [['*', '.', '.', '#', '.', '*'], ['.', '#', '.', '.', '.', '#'], ['.', '.', '#', '.', '*', '.'], ['#', '.', '.', '.', '.', '#'], ['.', '*', '.', '#', '.', '.']]) == [['.', '.', '.', '.', '*'], ['*', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '*', '#', '#'], ['#', '#', '.', '#', '*']]\n assert candidate(boxGrid = [['.', '.', '#', '.', '*', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['.', '#', '#', '*', '.', '.', '.'], ['.', '.', '.', '.', '.', '*', '.']]) == [['.', '.', '.', '.'], ['.', '#', '.', '.'], ['.', '#', '.', '.'], ['.', '*', '.', '#'], ['.', '.', '.', '*'], ['*', '.', '#', '.'], ['.', '.', '#', '#']]\n assert candidate(boxGrid = [['#', '*', '#', '*', '.', '#'], ['.', '#', '.', '.', '.', '.'], ['#', '.', '.', '*', '#', '.'], ['*', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '.']]) == [['.', '*', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['.', '.', '#', '.', '#'], ['.', '.', '*', '.', '*'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '#', '.', '.', '.', '#'], ['.', '.', '.', '#', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['#', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#'], ['.', '#', '.', '#'], ['#', '#', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['#', '#', '.', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '#']]) == [['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '.', '.', '#']]\n assert candidate(boxGrid = [['*', '*', '*', '*', '*'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['*', '*', '#', '#', '.'], ['#', '#', '.', '.', '.']]) == [['.', '*', '.', '#', '*'], ['.', '*', '.', '#', '*'], ['.', '.', '.', '#', '*'], ['#', '#', '.', '#', '*'], ['#', '#', '.', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '.', '.'], ['.', '#', '#', '.', '.', '.'], ['.', '.', '#', '#', '.', '.'], ['.', '.', '.', '#', '#', '.'], ['.', '.', '.', '.', '#', '#'], ['.', '.', '.', '.', '.', '#']]) == [['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#']]\n assert candidate(boxGrid = [['*', '.', '.', '.', '.', '.', '#', '.', '*'], ['.', '.', '#', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '#', '#', '#'], ['.', '.', '.', '#', '#', '#', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '*'], ['.', '#', '.', '.', '.'], ['.', '.', '#', '.', '.'], ['.', '.', '.', '#', '.'], ['.', '.', '.', '.', '#']]) == [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['#', '#', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '*', '.'], ['#', '.', '.', '#', '.', '.'], ['*', '#', '.', '.', '.', '#'], ['.', '.', '.', '#', '*', '.'], ['#', '.', '.', '.', '.', '.']]) == [['.', '.', '*', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '#', '.', '.', '#'], ['.', '*', '#', '#', '*'], ['#', '.', '#', '#', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '.', '.', '*'], ['#', '#', '.', '.', '.', '*', '.'], ['*', '.', '.', '#', '.', '.', '.'], ['.', '#', '#', '.', '.', '.', '#'], ['#', '.', '.', '.', '#', '.', '.'], ['.', '.', '#', '.', '.', '#', '.']]) == [['.', '.', '.', '*', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.'], ['#', '#', '#', '.', '*', '#'], ['#', '#', '#', '#', '.', '*']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '*', '.'], ['.', '#', '#', '*', '.', '#'], ['.', '.', '#', '#', '#', '.'], ['*', '.', '.', '#', '.', '.'], ['.', '#', '.', '.', '#', '*']]) == [['.', '*', '.', '.', '.'], ['.', '.', '.', '#', '.'], ['.', '.', '.', '#', '#'], ['#', '.', '#', '*', '#'], ['#', '.', '#', '.', '*'], ['*', '#', '#', '#', '.']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '*', '.'], ['#', '.', '#', '.', '.', '*'], ['.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '#', '.'], ['.', '*', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.'], ['*', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '#', '#'], ['.', '.', '#', '#', '*'], ['.', '#', '#', '*', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '#', '.', '.', '*', '.', '.', '#'], ['.', '#', '#', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.'], ['.', '#', '.', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '.', '.', '*', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '*', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.'], ['*', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['.', '.', '#', '#', '.']]\n assert candidate(boxGrid = [['#', '.', '#']]) == [['.'], ['#'], ['#']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['*', '*', '*', '*']]) == [['*', '.'], ['*', '.'], ['*', '.'], ['*', '.']]\n assert candidate(boxGrid = [['#', '.', '#']]) == [['.'], ['#'], ['#']]\n assert candidate(boxGrid = [['*'], ['.'], ['#']]) == [['#', '.', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['*', '*', '*', '*']]) == [['*', '.', '.'], ['*', '.', '.'], ['*', '.', '.'], ['*', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '#'], ['.', '#', '.', '.'], ['.', '.', '#', '.'], ['#', '.', '.', '*']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '.', '.', '#'], ['*', '#', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '*'], ['.', '#', '.', '*'], ['#', '.', '#', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['#', '#', '#'], ['#', '*', '*']]\n assert candidate(boxGrid = [['#', '#', '#'], ['*', '*', '*'], ['#', '#', '#']]) == [['#', '*', '#'], ['#', '*', '#'], ['#', '*', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '#', '*', '.'], ['#', '#', '#', '*']]) == [['#', '#', '.', '.'], ['#', '#', '.', '.'], ['#', '*', '.', '.'], ['*', '.', '.', '.']]\n assert candidate(boxGrid = [['#', '#', '#'], ['.', '.', '.'], ['*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#']]\n assert candidate(boxGrid = [['.', '#', '#', '*']]) == [['.'], ['#'], ['#'], ['*']]\n assert candidate(boxGrid = [['#', '.', '#']]) == [['.'], ['#'], ['#']]\n assert candidate(boxGrid = [['*', '*', '*', '*']]) == [['*'], ['*'], ['*'], ['*']]\n assert candidate(boxGrid = [['#', '#', '#', '#', '#', '*', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['*', '*', '*', '*', '*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '*'], ['*', '.', '.']]\n assert candidate(boxGrid = [['.', '#', '*', '#', '.', '*'], ['#', '.', '#', '.', '.', '#'], ['*', '.', '.', '#', '*', '.'], ['.', '#', '#', '*', '#', '.']]) == [['.', '*', '.', '.'], ['#', '.', '.', '#'], ['#', '.', '.', '*'], ['*', '#', '#', '.'], ['.', '*', '#', '#'], ['#', '.', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '*'], ['.', '#', '.', '.'], ['.', '.', '#', '*']]) == [['.', '.', '.'], ['.', '.', '.'], ['#', '.', '#'], ['*', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '*', '.', '*', '.'], ['#', '#', '#', '*', '.', '.'], ['#', '#', '#', '.', '#', '.']]) == [['.', '#', '#'], ['.', '#', '#'], ['#', '#', '*'], ['#', '*', '.'], ['#', '.', '*'], ['#', '.', '.']]\n assert candidate(boxGrid = [['#', '#'], ['*', '.'], ['#', '.']]) == [['.', '*', '#'], ['#', '.', '#']]\n assert candidate(boxGrid = [['#', '*'], ['#', '*']]) == [['#', '#'], ['*', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '*'], ['.', '#', '.', '.'], ['.', '.', '#', '.'], ['.', '.', '.', '*']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#'], ['*', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '#'], ['.', '.', '.'], ['*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#']]\n assert candidate(boxGrid = [['#', '.', '*', '#', '.', '*'], ['#', '#', '.', '.', '#', '.'], ['.', '#', '#', '*', '.', '.'], ['*', '.', '.', '.', '.', '*']]) == [['*', '.', '.', '.'], ['.', '#', '.', '#'], ['.', '#', '.', '*'], ['.', '*', '#', '.'], ['.', '.', '#', '#'], ['*', '.', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '*'], ['.', '#', '.'], ['*', '.', '#']]) == [['*', '.', '.'], ['.', '.', '#'], ['#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '*'], ['.', '#', '.', '#'], ['.', '.', '#', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['.', '#', '#'], ['#', '#', '*']]\n assert candidate(boxGrid = [['.', '#', '.'], ['*', '.', '#'], ['#', '#', '*']]) == [['#', '*', '.'], ['#', '.', '.'], ['*', '#', '#']]\n assert candidate(boxGrid = [['.', '#', '.', '*', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['*', '.', '#', '.', '.', '*']]) == [['*', '.', '.'], ['.', '.', '.'], ['.', '.', '#'], ['.', '.', '*'], ['#', '.', '.'], ['*', '.', '#']]\n assert candidate(boxGrid = [['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['*', '*', '*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#']]\n assert candidate(boxGrid = [['.', '#', '*'], ['.', '.', '#'], ['#', '.', '.']]) == [['.', '.', '.'], ['.', '.', '#'], ['#', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '.', '*'], ['.', '.', '.', '.'], ['.', '*', '.', '#'], ['#', '.', '#', '*']]) == [['.', '.', '.', '.'], ['#', '*', '.', '#'], ['#', '.', '.', '#'], ['*', '#', '.', '*']]\n assert candidate(boxGrid = [['*', '.', '.', '.'], ['#', '#', '#', '.'], ['*', '*', '#', '.']]) == [['*', '.', '*'], ['*', '#', '.'], ['.', '#', '.'], ['#', '#', '.']]\n assert candidate(boxGrid = [['#', '#', '#'], ['#', '#', '#'], ['#', '#', '#']]) == [['#', '#', '#'], ['#', '#', '#'], ['#', '#', '#']]\n assert candidate(boxGrid = [['#', '#', '#'], ['*', '*', '*'], ['.', '.', '.']]) == [['.', '*', '#'], ['.', '*', '#'], ['.', '*', '#']]\n assert candidate(boxGrid = [['*', '.', '.', '#'], ['*', '.', '.', '.'], ['#', '.', '.', '*']]) == [['.', '*', '*'], ['.', '.', '.'], ['#', '.', '.'], ['*', '.', '#']]\n assert candidate(boxGrid = [['*', '*', '*', '*'], ['#', '#', '#', '#'], ['*', '*', '*', '*'], ['#', '#', '#', '#']]) == [['#', '*', '#', '*'], ['#', '*', '#', '*'], ['#', '*', '#', '*'], ['#', '*', '#', '*']]\n assert candidate(boxGrid = [['#', '*'], ['#', '.'], ['#', '.'], ['#', '.']]) == [['.', '.', '.', '#'], ['#', '#', '#', '*']]\n assert candidate(boxGrid = [['#'], ['*'], ['.']]) == [['.', '*', '#']]\n assert candidate(boxGrid = [['.', '#', '*', '.', '#'], ['.', '.', '#', '.', '.'], ['#', '.', '.', '*', '.']]) == [['.', '.', '.'], ['.', '.', '#'], ['#', '.', '*'], ['*', '.', '.'], ['.', '#', '#']]\n assert candidate(boxGrid = [['#', '*', '.'], ['.', '#', '.'], ['.', '.', '#']]) == [['.', '.', '#'], ['.', '.', '*'], ['#', '#', '.']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['#', '#', '#', '#'], ['.', '*', '.', '*'], ['#', '.', '#', '.']]) == [['.', '.', '#', '.'], ['.', '*', '#', '.'], ['#', '.', '#', '.'], ['#', '*', '#', '.']]\n assert candidate(boxGrid = [['*', '*', '.', '*'], ['*', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#']]) == [['.', '.', '*', '*'], ['.', '.', '.', '*'], ['.', '.', '.', '.'], ['#', '.', '.', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['#', '#', '#', '#'], ['*', '.', '*', '.']]) == [['*', '#', '.'], ['.', '#', '.'], ['*', '#', '.'], ['.', '#', '.']]\n assert candidate(boxGrid = [['.', '#'], ['.', '*'], ['#', '.'], ['*', '.']]) == [['*', '.', '.', '.'], ['.', '#', '*', '#']]\n assert candidate(boxGrid = [['.', '.', '*', '.', '#'], ['#', '.', '#', '.', '.'], ['.', '#', '.', '*', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['#', '.', '*'], ['*', '#', '.'], ['.', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '#', '#', '#'], ['*', '.', '.', '*']]) == [['*', '#', '.', '.'], ['.', '#', '.', '.'], ['.', '#', '.', '.'], ['*', '#', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '*', '.'], ['#', '#', '*', '.']]) == [['#', '.'], ['#', '#'], ['*', '*'], ['.', '.']]\n assert candidate(boxGrid = [['#', '*', '#'], ['*', '#', '*'], ['#', '*', '#']]) == [['#', '*', '#'], ['*', '#', '*'], ['#', '*', '#']]\n assert candidate(boxGrid = [['.', '#', '*', '#', '.', '.', '#'], ['#', '.', '.', '.', '#', '.', '.'], ['.', '*', '.', '.', '.', '#', '#'], ['.', '.', '#', '.', '.', '.', '*']]) == [['.', '.', '.', '.'], ['.', '*', '.', '#'], ['.', '.', '.', '*'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '#', '#', '#'], ['*', '#', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '*', '.'], ['#', '#', '*', '.']]) == [['#', '.'], ['#', '#'], ['*', '*'], ['.', '.']]\n assert candidate(boxGrid = [['#'], ['.'], ['*']]) == [['*', '.', '#']]\n assert candidate(boxGrid = [['*', '.', '#'], ['.', '#', '.'], ['#', '.', '*']]) == [['.', '.', '*'], ['#', '.', '.'], ['*', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '#'], ['.', '.', '#', '.', '.'], ['#', '#', '#', '*', '.']]) == [['#', '.', '.'], ['#', '.', '.'], ['#', '.', '.'], ['*', '.', '#'], ['.', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '*'], ['#', '.', '.', '.', '.'], ['#', '.', '#', '.', '.'], ['#', '#', '.', '.', '.'], ['#', '.', '.', '#', '.'], ['#', '#', '#', '.', '.']]) == [['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['#', '#', '#', '#', '.', '#'], ['#', '#', '#', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '#'], ['.', '*', '.'], ['#', '#', '#']]) == [['#', '.', '.'], ['#', '*', '#'], ['#', '.', '#']]\n assert candidate(boxGrid = [['#', '#', '*', '.', '*', '.'], ['#', '#', '#', '*', '.', '.'], ['#', '#', '#', '.', '#', '.']]) == [['.', '#', '#'], ['.', '#', '#'], ['#', '#', '*'], ['#', '*', '.'], ['#', '.', '*'], ['#', '.', '.']]\n assert candidate(boxGrid = [['#', '#', '*', '.', '*', '.'], ['#', '#', '#', '*', '.', '.'], ['#', '#', '#', '.', '#', '.']]) == [['.', '#', '#'], ['.', '#', '#'], ['#', '#', '*'], ['#', '*', '.'], ['#', '.', '*'], ['#', '.', '.']]\n assert candidate(boxGrid = [['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*']]) == [['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*']]\n assert candidate(boxGrid = [['.', '.', '#'], ['.', '.', '.'], ['#', '.', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['#', '.', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '*'], ['#', '.', '#', '.'], ['.', '#', '.', '.'], ['#', '.', '.', '.']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '#', '.'], ['#', '#', '#', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['*', '*', '*', '*', '*']]) == [['*', '#', '.'], ['*', '#', '.'], ['*', '#', '.'], ['*', '#', '.'], ['*', '#', '.']]\n assert candidate(boxGrid = [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']]\n assert candidate(boxGrid = [['#', '#', '#', '*'], ['.', '.', '.', '.'], ['*', '.', '.', '*']]) == [['*', '.', '#'], ['.', '.', '#'], ['.', '.', '#'], ['*', '.', '*']]\n assert candidate(boxGrid = [['*', '*', '*', '*'], ['#', '#', '#', '#'], ['#', '#', '#', '#'], ['*', '*', '*', '*']]) == [['*', '#', '#', '*'], ['*', '#', '#', '*'], ['*', '#', '#', '*'], ['*', '#', '#', '*']]\n assert candidate(boxGrid = [['.', '.', '#', '*', '.'], ['#', '#', '.', '.', '#'], ['.', '*', '#', '.', '.']]) == [['.', '.', '.'], ['*', '.', '.'], ['.', '#', '#'], ['.', '#', '*'], ['#', '#', '.']]\n assert candidate(boxGrid = [['#', '.', '*', '.'], ['#', '#', '*', '.']]) == [['#', '.'], ['#', '#'], ['*', '*'], ['.', '.']]\n assert candidate(boxGrid = [['*', '*', '*', '*'], ['.', '.', '.', '.'], ['#', '#', '#', '#']]) == [['#', '.', '*'], ['#', '.', '*'], ['#', '.', '*'], ['#', '.', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '#'], ['.', '#', '#', '.'], ['.', '*', '.', '*']]) == [['.', '.', '.'], ['*', '.', '.'], ['.', '#', '#'], ['*', '#', '#']]\n assert candidate(boxGrid = [['#', '*', '*', '#'], ['#', '#', '#', '.'], ['*', '.', '.', '*']]) == [['*', '.', '#'], ['.', '#', '*'], ['.', '#', '*'], ['*', '#', '#']]\n assert candidate(boxGrid = [['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*']]) == [['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*']]\n assert candidate(boxGrid = [['#', '*', '.'], ['.', '.', '*'], ['*', '.', '.']]) == [['*', '.', '#'], ['.', '.', '*'], ['.', '*', '.']]\n assert candidate(boxGrid = [['*', '.', '.', '#'], ['#', '#', '#', '*'], ['#', '#', '.', '#']]) == [['.', '#', '*'], ['#', '#', '.'], ['#', '#', '.'], ['#', '*', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '*'], ['.', '#', '.', '.'], ['.', '#', '#', '.'], ['*', '#', '.', '*']]) == [['*', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '#', '.', '.'], ['*', '#', '#', '*']]\n"}, "metadata": {"canonical_parameter_names": ["boxGrid"], "leetcode_dataset_entry_point": "Solution().rotateTheBox", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def rotateTheBox(self, boxGrid: list[list[str]]) -> list[list[str]]:", "container": "Solution", "callable": "rotateTheBox", "parameters": [{"name": "boxGrid", "type": "list[list[str]]"}], "return_type": "list[list[str]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1862, "task_id": "sum-of-floored-pairs", "difficulty": "Hard", "problem_description": "Given an integer array nums, return the sum of floor(nums[i] / nums[j]) for all pairs of indices 0 <= i, j < nums.length in the array. Since the answer may be too large, return it modulo 109 + 7.\nThe floor() function returns the integer part of the division.\n \nExample 1:\n\nInput: nums = [2,5,9]\nOutput: 10\nExplanation:\nfloor(2 / 5) = floor(2 / 9) = floor(5 / 9) = 0\nfloor(2 / 2) = floor(5 / 5) = floor(9 / 9) = 1\nfloor(5 / 2) = 2\nfloor(9 / 2) = 4\nfloor(9 / 5) = 1\nWe calculate the floor of the division for every pair of indices in the array then sum them up.\n\nExample 2:\n\nInput: nums = [7,7,7,7,7,7,7]\nOutput: 49\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 49\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 100\n assert candidate(nums = [2, 5, 9]) == 10\n assert candidate(nums = [100000, 1, 100000]) == 200005\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250]) == 57\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 400\n assert candidate(nums = [10, 20, 30, 40, 50]) == 27\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 178\n assert candidate(nums = [1, 2, 3, 4, 5]) == 27\n assert candidate(nums = [100000, 100000, 100000]) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 65519\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980]) == 210\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 600\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 127\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3249\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 4194281\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 1492\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 127\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 2400\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 127\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 6268\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 834\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 2097130\n assert candidate(nums = [15, 15, 15, 30, 30, 45, 45, 60, 60, 75, 75, 90, 90, 105, 105]) == 287\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 55\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 100\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930]) == 15615\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 371\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 508\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 600\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 314\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000, 21000, 22000, 23000, 24000, 25000]) == 991\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 508\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 1650\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 623578\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000]) == 123456\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 127\n assert candidate(nums = [100000, 100000, 50000, 50000, 25000, 25000, 12500, 12500, 6250, 6250]) == 228\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 127\n assert candidate(nums = [50000, 40000, 30000, 20000, 10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1]) == 314353\n assert candidate(nums = [5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50]) == 508\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 513\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 400\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2036\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 127\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 2806\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 600\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 313945\n assert candidate(nums = [150000, 140000, 130000, 120000, 110000, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 314\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 949\n assert candidate(nums = [50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == 166591\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 6400\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225]) == 314\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 2841\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 65519\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1024\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 600\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 314\n assert candidate(nums = [3, 3, 3, 5, 5, 5, 7, 7, 7, 11, 11, 11, 13, 13, 13, 17, 17, 17, 19, 19]) == 412\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 1]) == 500096\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumOfFlooredPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def sumOfFlooredPairs(self, nums: list[int]) -> int:", "container": "Solution", "callable": "sumOfFlooredPairs", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1863, "task_id": "sum-of-all-subset-xor-totals", "difficulty": "Easy", "problem_description": "The XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty.\n\nFor example, the XOR total of the array [2,5,6] is 2 XOR 5 XOR 6 = 1.\n\nGiven an array nums, return the sum of all XOR totals for every subset of nums. \nNote: Subsets with the same elements should be counted multiple times.\nAn array a is a subset of an array b if a can be obtained from b by deleting some (possibly zero) elements of b.\n \nExample 1:\n\nInput: nums = [1,3]\nOutput: 6\nExplanation: The 4 subsets of [1,3] are:\n- The empty subset has an XOR total of 0.\n- [1] has an XOR total of 1.\n- [3] has an XOR total of 3.\n- [1,3] has an XOR total of 1 XOR 3 = 2.\n0 + 1 + 3 + 2 = 6\n\nExample 2:\n\nInput: nums = [5,1,6]\nOutput: 28\nExplanation: The 8 subsets of [5,1,6] are:\n- The empty subset has an XOR total of 0.\n- [5] has an XOR total of 5.\n- [1] has an XOR total of 1.\n- [6] has an XOR total of 6.\n- [5,1] has an XOR total of 5 XOR 1 = 4.\n- [5,6] has an XOR total of 5 XOR 6 = 3.\n- [1,6] has an XOR total of 1 XOR 6 = 7.\n- [5,1,6] has an XOR total of 5 XOR 1 XOR 6 = 2.\n0 + 5 + 1 + 6 + 4 + 3 + 7 + 2 = 28\n\nExample 3:\n\nInput: nums = [3,4,5,6,7,8]\nOutput: 480\nExplanation: The sum of all XOR totals for every subset is 480.\n\n \nConstraints:\n\n1 <= nums.length <= 12\n1 <= nums[i] <= 20\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 1, 6]) == 28\n assert candidate(nums = [10, 20, 30]) == 120\n assert candidate(nums = [1, 1, 1, 1]) == 8\n assert candidate(nums = [1, 2, 4, 8, 16]) == 496\n assert candidate(nums = [10, 11, 12]) == 60\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14]) == 896\n assert candidate(nums = [2, 3, 5]) == 28\n assert candidate(nums = [11, 2, 3, 14, 7]) == 240\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [7, 8, 9, 10, 11]) == 240\n assert candidate(nums = [1, 2, 3, 4]) == 56\n assert candidate(nums = [3, 4, 5, 6, 7, 8]) == 480\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 30720\n assert candidate(nums = [12, 34, 56]) == 248\n assert candidate(nums = [10, 15, 20, 25]) == 248\n assert candidate(nums = [2, 3, 5, 7]) == 56\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9]) == 63488\n assert candidate(nums = [1, 3]) == 6\n assert candidate(nums = [2, 2, 2, 2]) == 16\n assert candidate(nums = [1, 2, 4, 8, 16, 32]) == 2016\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 15360\n assert candidate(nums = [15, 16, 17, 18, 19, 20]) == 992\n assert candidate(nums = [1, 2, 3]) == 12\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2048\n assert candidate(nums = [6, 3, 5, 2, 1, 9]) == 480\n assert candidate(nums = [31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2, 1]) == 63488\n assert candidate(nums = [1, 2, 4, 8, 16, 32]) == 2016\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144]) == 516096\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 67092480\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 1984\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16252928\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095]) == 8386560\n assert candidate(nums = [15, 20, 25, 30]) == 248\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 129024\n assert candidate(nums = [128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144]) == 1073479680\n assert candidate(nums = [3, 3, 3, 5, 5, 5, 7, 7, 7, 11, 11, 11]) == 30720\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 130560\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64]) == 8128\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75]) == 8128\n assert candidate(nums = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8]) == 63488\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84]) == 260096\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70]) == 260096\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 245760\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 16773120\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125]) == 260096\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 1015808\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9]) == 63488\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144]) == 516096\n assert candidate(nums = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 63488\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 4186112\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 16773120\n assert candidate(nums = [13, 17, 19, 23, 29, 31, 37, 41]) == 8064\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]) == 129024\n assert candidate(nums = [13, 23, 33, 43, 53, 63, 73, 83, 93, 103, 113, 123]) == 260096\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 63488\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 30720\n assert candidate(nums = [14, 28, 42, 56, 70, 84, 98, 112, 126, 140, 154, 168]) == 520192\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 14336\n assert candidate(nums = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8]) == 63488\n assert candidate(nums = [14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91]) == 260096\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 4186112\n assert candidate(nums = [2, 3, 4, 5, 6]) == 112\n assert candidate(nums = [12, 14, 18, 22, 26, 30]) == 960\n assert candidate(nums = [10, 15, 20, 25]) == 248\n assert candidate(nums = [17, 19, 21, 23, 25, 27, 29, 31]) == 3968\n assert candidate(nums = [3, 5, 7, 9, 11, 13]) == 480\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 8386560\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 16128\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 8386560\n assert candidate(nums = [15, 25, 35, 45, 55]) == 1008\n assert candidate(nums = [10, 20, 30, 40, 50]) == 992\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 15360\n assert candidate(nums = [13, 17, 19, 23, 29, 31, 37, 41]) == 8064\n assert candidate(nums = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42]) == 129024\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]) == 129024\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 258048\n assert candidate(nums = [3, 11, 19, 27, 35, 43, 51, 59, 67, 75, 83, 91]) == 251904\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104]) == 16256\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14]) == 896\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 258048\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9]) == 63488\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 14336\n assert candidate(nums = [31, 33, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73]) == 260096\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == 129024\n assert candidate(nums = [17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61]) == 129024\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512]) == 65024\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132]) == 522240\n assert candidate(nums = [19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]) == 260096\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45]) == 4032\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 15360\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7]) == 1984\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96]) == 245760\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]) == 129024\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4]) == 30720\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 63488\n assert candidate(nums = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30720\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1]) == 30720\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63]) == 16128\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19]) == 3968\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().subsetXORSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def subsetXORSum(self, nums: list[int]) -> int:", "container": "Solution", "callable": "subsetXORSum", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1864, "task_id": "minimum-number-of-swaps-to-make-the-binary-string-alternating", "difficulty": "Medium", "problem_description": "Given a binary string s, return the minimum number of character swaps to make it alternating, or -1 if it is impossible.\nThe string is called alternating if no two adjacent characters are equal. For example, the strings \"010\" and \"1010\" are alternating, while the string \"0100\" is not.\nAny two characters may be swapped, even if they are not adjacent.\n \nExample 1:\n\nInput: s = \"111000\"\nOutput: 1\nExplanation: Swap positions 1 and 4: \"111000\" -> \"101010\"\nThe string is now alternating.\n\nExample 2:\n\nInput: s = \"010\"\nOutput: 0\nExplanation: The string is already alternating, no swaps are needed.\n\nExample 3:\n\nInput: s = \"1110\"\nOutput: -1\n\n \nConstraints:\n\n1 <= s.length <= 1000\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == -1\n assert candidate(s = \"1100110\") == 2\n assert candidate(s = \"110011\") == -1\n assert candidate(s = \"00110011\") == 2\n assert candidate(s = \"0101010\") == 0\n assert candidate(s = \"111\") == -1\n assert candidate(s = \"11110000\") == 2\n assert candidate(s = \"1110\") == -1\n assert candidate(s = \"0000\") == -1\n assert candidate(s = \"01010\") == 0\n assert candidate(s = \"111000\") == 1\n assert candidate(s = \"10101\") == 0\n assert candidate(s = \"1100\") == 1\n assert candidate(s = \"010\") == 0\n assert candidate(s = \"1010101\") == 0\n assert candidate(s = \"1010\") == 0\n assert candidate(s = \"0101\") == 0\n assert candidate(s = \"000111\") == 1\n assert candidate(s = \"000\") == -1\n assert candidate(s = \"01010101\") == 0\n assert candidate(s = \"10101010\") == 0\n assert candidate(s = \"110\") == 1\n assert candidate(s = \"1010101010\") == 0\n assert candidate(s = \"010101\") == 0\n assert candidate(s = \"101010\") == 0\n assert candidate(s = \"1101001\") == 2\n assert candidate(s = \"11001100\") == 2\n assert candidate(s = \"0011\") == 1\n assert candidate(s = \"0101010101\") == 0\n assert candidate(s = \"0011001\") == 2\n assert candidate(s = \"1001\") == 1\n assert candidate(s = \"101010101010101010\") == 0\n assert candidate(s = \"1110010011100100111001\") == -1\n assert candidate(s = \"010101101010101010101010101\") == 3\n assert candidate(s = \"110010110010\") == 2\n assert candidate(s = \"000110110001101100011011\") == 6\n assert candidate(s = \"00111111001111110011111100111111001111110011111100\") == -1\n assert candidate(s = \"101010101110\") == -1\n assert candidate(s = \"000000111111000000111111\") == 6\n assert candidate(s = \"0000000111111\") == 3\n assert candidate(s = \"000000000000000000111111111111111\") == -1\n assert candidate(s = \"11110000111100001111000011110000111100001111000011\") == -1\n assert candidate(s = \"010101010101010101010101010101010101010101010101011\") == 25\n assert candidate(s = \"101010101010101001010101010\") == 8\n assert candidate(s = \"1010101010101010101\") == 0\n assert candidate(s = \"010101010101010110101010101\") == 8\n assert candidate(s = \"0000000000000001111111111111\") == -1\n assert candidate(s = \"11010101010101010101010101010101\") == -1\n assert candidate(s = \"010101010101010101010101\") == 0\n assert candidate(s = \"10101010101010101010101010\") == 0\n assert candidate(s = \"000000000000111111111111\") == 6\n assert candidate(s = \"0000111110101010\") == 2\n assert candidate(s = \"1001100110011\") == 3\n assert candidate(s = \"0000000000111111111000\") == -1\n assert candidate(s = \"101010101001010101010101010\") == 5\n assert candidate(s = \"00001111000011110000\") == -1\n assert candidate(s = \"111000111000111\") == -1\n assert candidate(s = \"1011010010110100\") == 4\n assert candidate(s = \"000111000111000111\") == 3\n assert candidate(s = \"101010101010101010101010\") == 0\n assert candidate(s = \"1010010101001010100101010\") == -1\n assert candidate(s = \"111010101010\") == -1\n assert candidate(s = \"101010101010101010101\") == 0\n assert candidate(s = \"111111000000111111000000111111000000111111\") == -1\n assert candidate(s = \"010101010101010101\") == 0\n assert candidate(s = \"101010101010101010101010101\") == 0\n assert candidate(s = \"1010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"1100110011\") == -1\n assert candidate(s = \"111000111000111000111000111000\") == 5\n assert candidate(s = \"11000011000011000011\") == -1\n assert candidate(s = \"0101010101001011\") == 2\n assert candidate(s = \"111001100110011001100110011\") == -1\n assert candidate(s = \"1111111111111111111000000000000000\") == -1\n assert candidate(s = \"1010101010101010\") == 0\n assert candidate(s = \"111100001111000011110000111100001111\") == -1\n assert candidate(s = \"0000000111111100000000111111110000000011111111\") == 11\n assert candidate(s = \"111111000000111111000000\") == 6\n assert candidate(s = \"011111000000\") == -1\n assert candidate(s = \"111100001111000011110000\") == 6\n assert candidate(s = \"10101110101000\") == 1\n assert candidate(s = \"110011001100\") == 3\n assert candidate(s = \"11100101101000\") == 3\n assert candidate(s = \"0011001100110011\") == 4\n assert candidate(s = \"001100110011001100\") == -1\n assert candidate(s = \"000000111111\") == 3\n assert candidate(s = \"11111000001111100000\") == 4\n assert candidate(s = \"110010101001\") == 2\n assert candidate(s = \"111100000011\") == 3\n assert candidate(s = \"01010101011\") == 5\n assert candidate(s = \"0101010101010101010101010101010101\") == 0\n assert candidate(s = \"0000111100001111000011110000\") == -1\n assert candidate(s = \"1110001000\") == -1\n assert candidate(s = \"010101010101010101010101010\") == 0\n assert candidate(s = \"10100101010\") == 2\n assert candidate(s = \"000000000000000011111111111111\") == -1\n assert candidate(s = \"01010101010101010101010\") == 0\n assert candidate(s = \"11110000111100001111\") == -1\n assert candidate(s = \"01010101010101010101010101\") == 0\n assert candidate(s = \"01101101101101\") == -1\n assert candidate(s = \"111111111111111111000000000000000\") == -1\n assert candidate(s = \"101010101010\") == 0\n assert candidate(s = \"111111000000111111\") == -1\n assert candidate(s = \"111111111111111100000000000000\") == -1\n assert candidate(s = \"1111111111110000000000\") == -1\n assert candidate(s = \"0011001100110\") == 3\n assert candidate(s = \"01101010100\") == 4\n assert candidate(s = \"000111111000\") == 3\n assert candidate(s = \"0101010010101010\") == -1\n assert candidate(s = \"11111111111111111111\") == -1\n assert candidate(s = \"000011110000\") == -1\n assert candidate(s = \"1111111111100000000011\") == -1\n assert candidate(s = \"001001110010011\") == 4\n assert candidate(s = \"00001111111100\") == -1\n assert candidate(s = \"000111000111000\") == -1\n assert candidate(s = \"11111111000000001111111100000000\") == 8\n assert candidate(s = \"001100110011\") == 3\n assert candidate(s = \"1111111000000\") == 3\n assert candidate(s = \"10010010010010\") == -1\n assert candidate(s = \"111111111000000001111111100000000\") == 8\n assert candidate(s = \"00000000001111111111\") == 5\n assert candidate(s = \"101010101010101010101010101010101\") == 0\n assert candidate(s = \"1111111111000000000011111111110000000000\") == 10\n assert candidate(s = \"01010101010101010101010101010101010101010101010100\") == -1\n assert candidate(s = \"11001100110011001100\") == 5\n assert candidate(s = \"11111111110000000000\") == 5\n assert candidate(s = \"1111111000000011111111100000001111111110000000\") == -1\n assert candidate(s = \"01010101010101010101010101010101\") == 0\n assert candidate(s = \"0101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"1010101010101010101010101010\") == 0\n assert candidate(s = \"11110000111100\") == -1\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\") == -1\n assert candidate(s = \"111010101001\") == -1\n assert candidate(s = \"111000111000111000111000111\") == -1\n assert candidate(s = \"1110000011100000\") == -1\n assert candidate(s = \"111111101111111011111110\") == -1\n assert candidate(s = \"0000111111110000\") == 4\n assert candidate(s = \"111000111000\") == 2\n assert candidate(s = \"1111111100000000\") == 4\n assert candidate(s = \"1010101010110100\") == 2\n assert candidate(s = \"101110010110\") == -1\n assert candidate(s = \"0101101010101001\") == 3\n assert candidate(s = \"111100001111\") == -1\n assert candidate(s = \"000011111111\") == -1\n assert candidate(s = \"00000000000000000111111111111111\") == -1\n assert candidate(s = \"110110001101100\") == 4\n assert candidate(s = \"1100110011001100110011001100\") == 7\n assert candidate(s = \"11110000111100001111000011110000\") == 8\n assert candidate(s = \"110110110110110110110110\") == -1\n assert candidate(s = \"00110011001100\") == -1\n assert candidate(s = \"010101010101\") == 0\n assert candidate(s = \"111000100011\") == 2\n assert candidate(s = \"1111111111111111111111111111\") == -1\n assert candidate(s = \"0101010101010101\") == 0\n assert candidate(s = \"00001111\") == 2\n assert candidate(s = \"11111100000000\") == -1\n assert candidate(s = \"10100101001010010100101001010010100101001010\") == -1\n assert candidate(s = \"1111000010101010\") == 2\n assert candidate(s = \"11111111111111100000000000000000\") == -1\n assert candidate(s = \"11100111001110011100\") == -1\n assert candidate(s = \"1010101110001010\") == 1\n assert candidate(s = \"0101010101010101010101010101\") == 0\n assert candidate(s = \"11000000110000001100000011000000110000001100000011\") == -1\n assert candidate(s = \"0000000100000001000000010\") == -1\n assert candidate(s = \"111100001111000011\") == -1\n assert candidate(s = \"00000000000000000000000000000000000000000000000001\") == -1\n assert candidate(s = \"0101010101010101010\") == 0\n assert candidate(s = \"0000000000001111111111111111\") == -1\n assert candidate(s = \"000111000111000111000111000111\") == 5\n assert candidate(s = \"11111110000000\") == 3\n assert candidate(s = \"0000000000000001111111111111111\") == 8\n assert candidate(s = \"010100011101010\") == 1\n assert candidate(s = \"010101010001010101010101010\") == -1\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\") == -1\n assert candidate(s = \"000000111111000000111111000000111111000000\") == -1\n assert candidate(s = \"110101010101010101\") == -1\n assert candidate(s = \"100010001000\") == -1\n assert candidate(s = \"00001111000011110000111100001111\") == 8\n assert candidate(s = \"1111111111111110000000000000\") == -1\n assert candidate(s = \"101010101000\") == -1\n assert candidate(s = \"10101010010\") == 4\n assert candidate(s = \"10010010010\") == -1\n assert candidate(s = \"00110011001100110011\") == 5\n assert candidate(s = \"010110001110\") == 3\n assert candidate(s = \"011011010101010101010101010\") == 12\n assert candidate(s = \"010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"00000000000000000000\") == -1\n assert candidate(s = \"1010101010101\") == 0\n assert candidate(s = \"1111000011110000\") == 4\n assert candidate(s = \"0000000011111111\") == 4\n assert candidate(s = \"010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"1111000000001111\") == 4\n assert candidate(s = \"1111100000\") == 2\n assert candidate(s = \"11001100110011001100110011001100110011001100110011\") == -1\n assert candidate(s = \"00100100100100100100100100100100100100100100\") == -1\n assert candidate(s = \"000111000111000111000111000\") == -1\n assert candidate(s = \"01010101010101\") == 0\n assert candidate(s = \"111000010101\") == 2\n assert candidate(s = \"1001001001001\") == -1\n assert candidate(s = \"101011100010101\") == 1\n assert candidate(s = \"0100101101001011\") == 4\n assert candidate(s = \"0110110110110110110110110\") == -1\n assert candidate(s = \"11111111111111111000000000000000\") == -1\n assert candidate(s = \"1010101010101010101010\") == 0\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"00111100111100111100\") == -1\n assert candidate(s = \"100110011001\") == 3\n assert candidate(s = \"111001001001\") == 3\n assert candidate(s = \"11101110111011101110\") == -1\n assert candidate(s = \"00011100011100011100\") == -1\n assert candidate(s = \"1001100110011001\") == 4\n assert candidate(s = \"01010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"100100100100\") == -1\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"0011001100110011001100110011\") == 7\n assert candidate(s = \"01010101010101010101\") == 0\n assert candidate(s = \"110011001100110011001100110011\") == -1\n assert candidate(s = \"1100110011001\") == 3\n assert candidate(s = \"11001100110011\") == -1\n assert candidate(s = \"101010101010101010101010101010101010101010101010100\") == 25\n assert candidate(s = \"1001001001001001001001001001\") == -1\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"1101011010100010\") == 3\n assert candidate(s = \"0110011001100110011001100110011\") == 8\n assert candidate(s = \"101010010101010101010101010\") == 3\n assert candidate(s = \"1111111111110000000000000000\") == -1\n assert candidate(s = \"101010101010101010101010101010101010\") == 0\n assert candidate(s = \"000100100100\") == -1\n assert candidate(s = \"1111000000\") == -1\n assert candidate(s = \"0101010101010\") == 0\n assert candidate(s = \"111111111110000000000111111111110000000000\") == -1\n assert candidate(s = \"1111111000000011111110000000\") == 6\n assert candidate(s = \"11000011110000111100\") == 5\n assert candidate(s = \"10101010101010101010\") == 0\n assert candidate(s = \"0000000000000000000111111111111111\") == -1\n assert candidate(s = \"100110011001100110011001\") == 6\n assert candidate(s = \"11001100110011001100110011\") == -1\n assert candidate(s = \"000000111111000000111111000000\") == -1\n assert candidate(s = \"011011011011\") == -1\n assert candidate(s = \"0000000000000000000000000000\") == -1\n assert candidate(s = \"11111111111111111111111111111111111111111111111110\") == -1\n assert candidate(s = \"00001111000011110000111100001111000011110000111100\") == -1\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minSwaps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minSwaps(self, s: str) -> int:", "container": "Solution", "callable": "minSwaps", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1866, "task_id": "number-of-ways-to-rearrange-sticks-with-k-sticks-visible", "difficulty": "Hard", "problem_description": "There are n uniquely-sized sticks whose lengths are integers from 1 to n. You want to arrange the sticks such that exactly k sticks are visible from the left. A stick is visible from the left if there are no longer sticks to the left of it.\n\nFor example, if the sticks are arranged [1,3,2,5,4], then the sticks with lengths 1, 3, and 5 are visible from the left.\n\nGiven n and k, return the number of such arrangements. Since the answer may be large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: n = 3, k = 2\nOutput: 3\nExplanation: [1,3,2], [2,3,1], and [2,1,3] are the only arrangements such that exactly 2 sticks are visible.\nThe visible sticks are underlined.\n\nExample 2:\n\nInput: n = 5, k = 5\nOutput: 1\nExplanation: [1,2,3,4,5] is the only arrangement such that all 5 sticks are visible.\nThe visible sticks are underlined.\n\nExample 3:\n\nInput: n = 20, k = 11\nOutput: 647427950\nExplanation: There are 647427950 (mod 109 + 7) ways to rearrange the sticks such that exactly 11 sticks are visible.\n\n \nConstraints:\n\n1 <= n <= 1000\n1 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,k = 1) == 362880\n assert candidate(n = 1000,k = 500) == 761367694\n assert candidate(n = 7,k = 4) == 735\n assert candidate(n = 1,k = 1) == 1\n assert candidate(n = 3,k = 2) == 3\n assert candidate(n = 100,k = 50) == 768969154\n assert candidate(n = 5,k = 5) == 1\n assert candidate(n = 20,k = 11) == 647427950\n assert candidate(n = 4,k = 3) == 6\n assert candidate(n = 10,k = 3) == 1172700\n assert candidate(n = 400,k = 200) == 321592380\n assert candidate(n = 300,k = 150) == 266738846\n assert candidate(n = 500,k = 20) == 997277428\n assert candidate(n = 200,k = 100) == 515897308\n assert candidate(n = 75,k = 40) == 957213722\n assert candidate(n = 600,k = 400) == 156741878\n assert candidate(n = 90,k = 45) == 884068127\n assert candidate(n = 1000,k = 999) == 499500\n assert candidate(n = 300,k = 200) == 692591146\n assert candidate(n = 70,k = 35) == 834330443\n assert candidate(n = 25,k = 10) == 513911237\n assert candidate(n = 30,k = 15) == 439815546\n assert candidate(n = 900,k = 40) == 539248312\n assert candidate(n = 75,k = 35) == 48172892\n assert candidate(n = 400,k = 10) == 650177568\n assert candidate(n = 800,k = 200) == 252157911\n assert candidate(n = 50,k = 20) == 506372014\n assert candidate(n = 999,k = 999) == 1\n assert candidate(n = 500,k = 2) == 540925953\n assert candidate(n = 700,k = 350) == 411412946\n assert candidate(n = 999,k = 1) == 22779421\n assert candidate(n = 999,k = 499) == 23728871\n assert candidate(n = 900,k = 450) == 911433285\n assert candidate(n = 900,k = 900) == 1\n assert candidate(n = 150,k = 75) == 309130836\n assert candidate(n = 8,k = 4) == 6769\n assert candidate(n = 100,k = 10) == 451985432\n assert candidate(n = 30,k = 10) == 283914142\n assert candidate(n = 750,k = 100) == 677105109\n assert candidate(n = 25,k = 15) == 729045180\n assert candidate(n = 250,k = 249) == 31125\n assert candidate(n = 250,k = 200) == 168555168\n assert candidate(n = 1000,k = 1000) == 1\n assert candidate(n = 1000,k = 1) == 756641425\n assert candidate(n = 15,k = 7) == 409322830\n assert candidate(n = 600,k = 599) == 179700\n assert candidate(n = 800,k = 300) == 156733966\n assert candidate(n = 600,k = 300) == 326283128\n assert candidate(n = 750,k = 375) == 43563744\n assert candidate(n = 700,k = 30) == 785311933\n assert candidate(n = 800,k = 400) == 551599071\n assert candidate(n = 500,k = 50) == 982286335\n assert candidate(n = 999,k = 500) == 975713359\n assert candidate(n = 350,k = 175) == 62253251\n assert candidate(n = 400,k = 250) == 585657508\n assert candidate(n = 500,k = 250) == 112330193\n assert candidate(n = 50,k = 25) == 253549512\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().rearrangeSticks", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def rearrangeSticks(self, n: int, k: int) -> int:", "container": "Solution", "callable": "rearrangeSticks", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1869, "task_id": "longer-contiguous-segments-of-ones-than-zeros", "difficulty": "Easy", "problem_description": "Given a binary string s, return true if the longest contiguous segment of 1's is strictly longer than the longest contiguous segment of 0's in s, or return false otherwise.\n\nFor example, in s = \"110100010\" the longest continuous segment of 1s has length 2, and the longest continuous segment of 0s has length 3.\n\nNote that if there are no 0's, then the longest continuous segment of 0's is considered to have a length 0. The same applies if there is no 1's.\n \nExample 1:\n\nInput: s = \"1101\"\nOutput: true\nExplanation:\nThe longest contiguous segment of 1s has length 2: \"1101\"\nThe longest contiguous segment of 0s has length 1: \"1101\"\nThe segment of 1s is longer, so return true.\n\nExample 2:\n\nInput: s = \"111000\"\nOutput: false\nExplanation:\nThe longest contiguous segment of 1s has length 3: \"111000\"\nThe longest contiguous segment of 0s has length 3: \"111000\"\nThe segment of 1s is not longer, so return false.\n\nExample 3:\n\nInput: s = \"110100010\"\nOutput: false\nExplanation:\nThe longest contiguous segment of 1s has length 2: \"110100010\"\nThe longest contiguous segment of 0s has length 3: \"110100010\"\nThe segment of 1s is not longer, so return false.\n\n \nConstraints:\n\n1 <= s.length <= 100\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == True\n assert candidate(s = \"111000\") == False\n assert candidate(s = \"101010\") == False\n assert candidate(s = \"11100111\") == True\n assert candidate(s = \"11001100\") == False\n assert candidate(s = \"111001001\") == True\n assert candidate(s = \"1101\") == True\n assert candidate(s = \"0\") == False\n assert candidate(s = \"110100010\") == False\n assert candidate(s = \"01010101\") == False\n assert candidate(s = \"10101010\") == False\n assert candidate(s = \"1110011100010001111100000\") == False\n assert candidate(s = \"000111000\") == False\n assert candidate(s = \"001100110011\") == False\n assert candidate(s = \"0000\") == False\n assert candidate(s = \"1\") == True\n assert candidate(s = \"101010101010101010\") == False\n assert candidate(s = \"1110111011101110111\") == True\n assert candidate(s = \"000111000111000111000\") == False\n assert candidate(s = \"111111111111111111111111\") == True\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"111000111000111000\") == False\n assert candidate(s = \"001111001100110011110000111100001111100000\") == False\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"1111110000000000000000000000000000000000000000000000\") == False\n assert candidate(s = \"111100000110011000000111\") == False\n assert candidate(s = \"00000000000000000000000000000000\") == False\n assert candidate(s = \"000111000111000111000111000111000111000111000\") == False\n assert candidate(s = \"000011110000111100001111000011110000111100001111\") == False\n assert candidate(s = \"1111111111111111111\") == True\n assert candidate(s = \"1100110011001100\") == False\n assert candidate(s = \"111010101010101010101\") == True\n assert candidate(s = \"1010101010101010101\") == False\n assert candidate(s = \"111110000011111000001111100000\") == False\n assert candidate(s = \"11010101010101010101010101010101\") == True\n assert candidate(s = \"11110011000001111100110000011111001100000\") == False\n assert candidate(s = \"010101010101010101010101\") == False\n assert candidate(s = \"00000000111111110000000011111111\") == False\n assert candidate(s = \"0000000000000000000000001111111111111111111111111\") == True\n assert candidate(s = \"10101010101010101010101010\") == False\n assert candidate(s = \"111000000011111111111\") == True\n assert candidate(s = \"1010101010101010101010101010101\") == False\n assert candidate(s = \"1110000110000111\") == False\n assert candidate(s = \"00000000001111111111111111111111111111111\") == True\n assert candidate(s = \"1111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"111111110000000\") == True\n assert candidate(s = \"000000000000000000000001\") == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000011111\") == False\n assert candidate(s = \"000111000111000111\") == False\n assert candidate(s = \"111111111111111111110000000000000000111111111111\") == True\n assert candidate(s = \"10101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"10000111110000001111111110000000011111111111\") == True\n assert candidate(s = \"111111111111100000000000000011111111111111111111111111111\") == True\n assert candidate(s = \"111110000011111000001111100000111110000011111\") == False\n assert candidate(s = \"0001001001001001001001001\") == False\n assert candidate(s = \"000110001100011000110001100011\") == False\n assert candidate(s = \"0000000000\") == False\n assert candidate(s = \"111111111111111111111\") == True\n assert candidate(s = \"111110000001110000111111\") == False\n assert candidate(s = \"1010101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"111111010101010101010101010101010101010101010101010101\") == True\n assert candidate(s = \"0000000000000000\") == False\n assert candidate(s = \"000100010001000\") == False\n assert candidate(s = \"000111000111000111000111\") == False\n assert candidate(s = \"101010101010101010101010101010\") == False\n assert candidate(s = \"1001001001001001001001001001001001001001001\") == False\n assert candidate(s = \"111100001111000011110000111100001111\") == False\n assert candidate(s = \"111111000000111111000000\") == False\n assert candidate(s = \"111100001111000011110000\") == False\n assert candidate(s = \"101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"000000000000000000000\") == False\n assert candidate(s = \"111111110000000000000000000\") == False\n assert candidate(s = \"11111000001111100000\") == False\n assert candidate(s = \"11111111111111111111110000000000000000\") == True\n assert candidate(s = \"0011001100110011001100110011001100110011\") == False\n assert candidate(s = \"000000000000000011111111111\") == False\n assert candidate(s = \"00110011001100110011001100110011\") == False\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000000\") == False\n assert candidate(s = \"11110000111100001111\") == False\n assert candidate(s = \"11111000000000000000000000000000000000000000000000000\") == False\n assert candidate(s = \"110000000000000000000\") == False\n assert candidate(s = \"10101010101010101010101010101\") == False\n assert candidate(s = \"10101010101010101010101010101010101010\") == False\n assert candidate(s = \"010101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"000000011111111\") == True\n assert candidate(s = \"111111111100000000001111111111\") == False\n assert candidate(s = \"0011110000111100001111\") == False\n assert candidate(s = \"1111000001100100\") == False\n assert candidate(s = \"11111111111111111111\") == True\n assert candidate(s = \"1000000000000000000\") == False\n assert candidate(s = \"111001110011100\") == True\n assert candidate(s = \"1000111000111000111000111000111000111000\") == False\n assert candidate(s = \"1111111111111111\") == True\n assert candidate(s = \"111001110011100111001110011100\") == True\n assert candidate(s = \"101010101010101010101010101010101010101\") == False\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011\") == False\n assert candidate(s = \"00000111111111000000\") == True\n assert candidate(s = \"000000000000000000000000000000000000001\") == False\n assert candidate(s = \"110000111100001111000011110000111100001111\") == False\n assert candidate(s = \"100000011111111111100\") == True\n assert candidate(s = \"00000000001111111111\") == False\n assert candidate(s = \"010101010101010101010101010101\") == False\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"111000111000111000111\") == False\n assert candidate(s = \"11111000011111000011\") == True\n assert candidate(s = \"0000111111110000000\") == True\n assert candidate(s = \"111111111000000001111000000111110000\") == True\n assert candidate(s = \"11111111110000000000\") == False\n assert candidate(s = \"11111111110000000000000000000000000000000\") == False\n assert candidate(s = \"01010101010101010101010101010101\") == False\n assert candidate(s = \"111111000000000000000000000000\") == False\n assert candidate(s = \"000000000000000011111111111111111111000000000000\") == True\n assert candidate(s = \"11000001110000011100000111\") == False\n assert candidate(s = \"1010101010101010101010101010\") == False\n assert candidate(s = \"111100000000011111\") == False\n assert candidate(s = \"111000111000111000111000111\") == False\n assert candidate(s = \"0000111111110000\") == True\n assert candidate(s = \"0000000000000000000000000000000000000000000000000\") == False\n assert candidate(s = \"1111111111111111111111111111111111111110\") == True\n assert candidate(s = \"11110000011110000\") == False\n assert candidate(s = \"1110000111000111\") == False\n assert candidate(s = \"11111111111111111111111111111111\") == True\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"0000000000011111111111111100000000011111111111\") == True\n assert candidate(s = \"000000001010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"0101010101010101010101010101\") == False\n assert candidate(s = \"11100100010001000100010001000100\") == False\n assert candidate(s = \"000001111110000011111100000111111\") == True\n assert candidate(s = \"11001100110011001100110011001100110011\") == False\n assert candidate(s = \"00011100010001000100010001110001\") == False\n assert candidate(s = \"11001100110011001100110011001100110011001100\") == False\n assert candidate(s = \"111000011100001110000111\") == False\n assert candidate(s = \"001111110000000011111100000000\") == False\n assert candidate(s = \"010101010101010101010101010101010101010\") == False\n assert candidate(s = \"00000000000000000000\") == False\n assert candidate(s = \"1111000011110000\") == False\n assert candidate(s = \"10101010101010101010101010101010\") == False\n assert candidate(s = \"1001001001001001001001001\") == False\n assert candidate(s = \"1010101011111010\") == True\n assert candidate(s = \"0000000111111111111111111111111111111111111111100000\") == True\n assert candidate(s = \"000111000111000111000111000\") == False\n assert candidate(s = \"1010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"0110110110110110110110110\") == True\n assert candidate(s = \"1111111111111111111111110000000000000000000000000\") == False\n assert candidate(s = \"1111111111\") == True\n assert candidate(s = \"111111111100000000\") == True\n assert candidate(s = \"1001100110011001\") == False\n assert candidate(s = \"000000000000111111000000000011111\") == False\n assert candidate(s = \"001001001001001001001\") == False\n assert candidate(s = \"1100110011001100110011\") == False\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"111110000000000000000000000000000000000\") == False\n assert candidate(s = \"110110110110110110110\") == True\n assert candidate(s = \"0000000000000000000000001111111111111111111111111111\") == True\n assert candidate(s = \"10101010101010101010\") == False\n assert candidate(s = \"100110011001100110011001\") == False\n assert candidate(s = \"11001100110011001100110011\") == False\n assert candidate(s = \"010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"000000111111111111\") == True\n assert candidate(s = \"00011100010001000100010001000111\") == False\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().checkZeroOnes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def checkZeroOnes(self, s: str) -> bool:", "container": "Solution", "callable": "checkZeroOnes", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1870, "task_id": "minimum-speed-to-arrive-on-time", "difficulty": "Medium", "problem_description": "You are given a floating-point number hour, representing the amount of time you have to reach the office. To commute to the office, you must take n trains in sequential order. You are also given an integer array dist of length n, where dist[i] describes the distance (in kilometers) of the ith train ride.\nEach train can only depart at an integer hour, so you may need to wait in between each train ride.\n\nFor example, if the 1st train ride takes 1.5 hours, you must wait for an additional 0.5 hours before you can depart on the 2nd train ride at the 2 hour mark.\n\nReturn the minimum positive integer speed (in kilometers per hour) that all the trains must travel at for you to reach the office on time, or -1 if it is impossible to be on time.\nTests are generated such that the answer will not exceed 107 and hour will have at most two digits after the decimal point.\n \nExample 1:\n\nInput: dist = [1,3,2], hour = 6\nOutput: 1\nExplanation: At speed 1:\n- The first train ride takes 1/1 = 1 hour.\n- Since we are already at an integer hour, we depart immediately at the 1 hour mark. The second train takes 3/1 = 3 hours.\n- Since we are already at an integer hour, we depart immediately at the 4 hour mark. The third train takes 2/1 = 2 hours.\n- You will arrive at exactly the 6 hour mark.\n\nExample 2:\n\nInput: dist = [1,3,2], hour = 2.7\nOutput: 3\nExplanation: At speed 3:\n- The first train ride takes 1/3 = 0.33333 hours.\n- Since we are not at an integer hour, we wait until the 1 hour mark to depart. The second train ride takes 3/3 = 1 hour.\n- Since we are already at an integer hour, we depart immediately at the 2 hour mark. The third train takes 2/3 = 0.66667 hours.\n- You will arrive at the 2.66667 hour mark.\n\nExample 3:\n\nInput: dist = [1,3,2], hour = 1.9\nOutput: -1\nExplanation: It is impossible because the earliest the third train can depart is at the 2 hour mark.\n\n \nConstraints:\n\nn == dist.length\n1 <= n <= 105\n1 <= dist[i] <= 105\n1 <= hour <= 109\nThere will be at most two digits after the decimal point in hour.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(dist = [5, 4, 3, 2, 1],hour = 5.5) == 4\n assert candidate(dist = [5, 4, 1, 2],hour = 3.5) == 5\n assert candidate(dist = [1, 2, 3, 4, 5],hour = 9.0) == 2\n assert candidate(dist = [9],hour = 0.5) == 18\n assert candidate(dist = [1, 3, 2],hour = 1.9) == -1\n assert candidate(dist = [1, 1, 100000],hour = 2.01) == 10000000\n assert candidate(dist = [5, 5, 5, 5, 5],hour = 9.0) == 5\n assert candidate(dist = [100000],hour = 2.5) == 40000\n assert candidate(dist = [100000],hour = 1.0) == 100000\n assert candidate(dist = [10, 10, 10],hour = 3.5) == 10\n assert candidate(dist = [1, 3, 2],hour = 2.7) == 3\n assert candidate(dist = [1, 2, 3, 4, 5],hour = 10.0) == 2\n assert candidate(dist = [10, 10, 10],hour = 2.5) == 20\n assert candidate(dist = [1],hour = 1.0) == 1\n assert candidate(dist = [10, 10, 10],hour = 29.99) == 2\n assert candidate(dist = [1, 3, 2],hour = 6) == 1\n assert candidate(dist = [10, 10, 10],hour = 3.0) == 10\n assert candidate(dist = [5, 5, 5, 5],hour = 10.0) == 3\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 100000.0) == 1\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],hour = 19.99) == 11\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 4.5) == -1\n assert candidate(dist = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],hour = 50.0) == 20000\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],hour = 30.0) == 50\n assert candidate(dist = [100, 200, 300, 400, 500],hour = 15.5) == 100\n assert candidate(dist = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],hour = 15.0) == 100\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 10.1) == 1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 50.0) == 12\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 9.5) == 20\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],hour = 20.0) == 10\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],hour = 9.0) == -1\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],hour = 10.5) == 20\n assert candidate(dist = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],hour = 45.0) == 13334\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],hour = 15.0) == 25\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 30.5) == 20\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],hour = 14.0) == -1\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],hour = 10.0) == 100000\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000],hour = 25.0) == 20000\n assert candidate(dist = [100000, 1, 1, 1, 1],hour = 10.1) == 14286\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 9.99) == 11\n assert candidate(dist = [100000, 200000, 300000, 400000, 500000],hour = 100.0) == 15385\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 2.5) == -1\n assert candidate(dist = [100000, 200000, 300000, 400000],hour = 25.0) == 42858\n assert candidate(dist = [1, 2, 3, 4, 5],hour = 2.0) == -1\n assert candidate(dist = [99999, 99999, 99999, 99999],hour = 20.0) == 20000\n assert candidate(dist = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],hour = 50.0) == 1200\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],hour = 15.0) == 5\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 49.99) == 12\n assert candidate(dist = [1000, 2000, 3000],hour = 7.0) == 1000\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 5.5) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],hour = 25.5) == 14\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],hour = 15.0) == 5\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 5.5) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 25.0) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 20.0) == 4\n assert candidate(dist = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],hour = 9.99) == 101010\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 15.0) == 5\n assert candidate(dist = [1, 10, 100, 1000, 10000],hour = 12.0) == 1250\n assert candidate(dist = [10000, 20000, 30000, 40000, 50000],hour = 12.5) == 14286\n assert candidate(dist = [10, 20, 30, 40, 50],hour = 12.5) == 15\n assert candidate(dist = [10, 20, 30, 40, 50],hour = 12.5) == 15\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 10.0) == 1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 19.0) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 18.0) == 40\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 18.0) == 40\n assert candidate(dist = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],hour = 9.0) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 1.0) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 20.0) == 1\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],hour = 15.25) == 5\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],hour = 4.0) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 5.0) == -1\n assert candidate(dist = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],hour = 15.5) == 5\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],hour = 9.5) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 9.0) == -1\n assert candidate(dist = [99999, 99999, 99999, 99999, 99999],hour = 25.0) == 20000\n assert candidate(dist = [100, 200, 300, 400, 500],hour = 10.0) == 200\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],hour = 19.99) == 21\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],hour = 50.5) == 118\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],hour = 11.0) == 9\n assert candidate(dist = [100, 200, 300, 400, 500],hour = 14.0) == 125\n assert candidate(dist = [100, 200, 300, 400, 500],hour = 20.0) == 84\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 50.0) == -1\n assert candidate(dist = [1, 10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000],hour = 10.5) == 10000\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],hour = 10.0) == 19\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],hour = 25.0) == 70\n assert candidate(dist = [100000, 99999, 99998, 99997, 99996],hour = 5.0) == 100000\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],hour = 21.5) == 18\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 9.5) == 2\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 2.99) == -1\n assert candidate(dist = [5, 10, 15, 20, 25],hour = 9.0) == 10\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 9.99) == 102\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 5.0) == -1\n assert candidate(dist = [1, 100000, 1, 1, 1],hour = 10.1) == 14286\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 20.0) == 35\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],hour = 30.5) == 200\n assert candidate(dist = [99999, 99999, 99999],hour = 3.5) == 99999\n assert candidate(dist = [10000, 10000, 10000, 10000, 10000],hour = 25.0) == 2000\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],hour = 7.5) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 1.5) == -1\n"}, "metadata": {"canonical_parameter_names": ["dist", "hour"], "leetcode_dataset_entry_point": "Solution().minSpeedOnTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minSpeedOnTime(self, dist: list[int], hour: float) -> int:", "container": "Solution", "callable": "minSpeedOnTime", "parameters": [{"name": "dist", "type": "list[int]"}, {"name": "hour", "type": "float"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1871, "task_id": "jump-game-vii", "difficulty": "Medium", "problem_description": "You are given a 0-indexed binary string s and two integers minJump and maxJump. In the beginning, you are standing at index 0, which is equal to '0'. You can move from index i to index j if the following conditions are fulfilled:\n\ni + minJump <= j <= min(i + maxJump, s.length - 1), and\ns[j] == '0'.\n\nReturn true if you can reach index s.length - 1 in s, or false otherwise.\n \nExample 1:\n\nInput: s = \"011010\", minJump = 2, maxJump = 3\nOutput: true\nExplanation:\nIn the first step, move from index 0 to index 3. \nIn the second step, move from index 3 to index 5.\n\nExample 2:\n\nInput: s = \"01101110\", minJump = 2, maxJump = 3\nOutput: false\n\n \nConstraints:\n\n2 <= s.length <= 105\ns[i] is either '0' or '1'.\ns[0] == '0'\n1 <= minJump <= maxJump < s.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"0100100010001000\",minJump = 2,maxJump = 5) == True\n assert candidate(s = \"00001000\",minJump = 2,maxJump = 4) == True\n assert candidate(s = \"0010010010010010010010010010010010010010\",minJump = 2,maxJump = 4) == True\n assert candidate(s = \"011010\",minJump = 2,maxJump = 3) == True\n assert candidate(s = \"0100000\",minJump = 1,maxJump = 2) == True\n assert candidate(s = \"00001000\",minJump = 3,maxJump = 5) == True\n assert candidate(s = \"01010101\",minJump = 2,maxJump = 4) == False\n assert candidate(s = \"0101010101010101010101010101010101010101\",minJump = 5,maxJump = 10) == False\n assert candidate(s = \"0111111111111111111111111111111111111111\",minJump = 3,maxJump = 5) == False\n assert candidate(s = \"000000\",minJump = 1,maxJump = 2) == True\n assert candidate(s = \"001000\",minJump = 2,maxJump = 3) == True\n assert candidate(s = \"010101\",minJump = 1,maxJump = 2) == False\n assert candidate(s = \"00000000\",minJump = 1,maxJump = 2) == True\n assert candidate(s = \"00100\",minJump = 3,maxJump = 4) == True\n assert candidate(s = \"01101110\",minJump = 2,maxJump = 3) == False\n assert candidate(s = \"010000\",minJump = 1,maxJump = 3) == True\n assert candidate(s = \"00000000001000000000\",minJump = 4,maxJump = 7) == True\n assert candidate(s = \"0000011111000000000000000000\",minJump = 1,maxJump = 5) == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000000000000000000\",minJump = 5,maxJump = 10) == True\n assert candidate(s = \"0000000000000000000000000000\",minJump = 2,maxJump = 2) == False\n assert candidate(s = \"0111111111111111111111111110\",minJump = 10,maxJump = 20) == False\n assert candidate(s = \"0100000000000000000000000000\",minJump = 2,maxJump = 3) == True\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\",minJump = 10,maxJump = 20) == True\n assert candidate(s = \"01010101010101010101010101010101010101010101010101\",minJump = 5,maxJump = 15) == False\n assert candidate(s = \"0010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",minJump = 3,maxJump = 7) == False\n assert candidate(s = \"0000000000000000000000000001\",minJump = 5000,maxJump = 10000) == False\n assert candidate(s = \"0000000000000000000000000001\",minJump = 1,maxJump = 1) == False\n assert candidate(s = \"000001000001000001000001000001000001000001000001\",minJump = 6,maxJump = 12) == False\n assert candidate(s = \"000111000111000111000111000111000111000111000111\",minJump = 3,maxJump = 6) == False\n assert candidate(s = \"01001001001001001001001000\",minJump = 5,maxJump = 10) == True\n assert candidate(s = \"001001001000\",minJump = 2,maxJump = 4) == True\n assert candidate(s = \"0100000000000000000000000000\",minJump = 50000,maxJump = 50000) == False\n assert candidate(s = \"0000100100010001000100010001000100010001000100010000\",minJump = 5,maxJump = 15) == True\n assert candidate(s = \"0000000000000000000000000000000000000000000000000001000000000000000000000000\",minJump = 10,maxJump = 20) == True\n assert candidate(s = \"01001001001001001001001001001001001001001001001001\",minJump = 4,maxJump = 8) == False\n assert candidate(s = \"0000000000000000000000000000\",minJump = 5,maxJump = 5) == False\n assert candidate(s = \"010001000100010001000100010001000100010000\",minJump = 4,maxJump = 12) == True\n assert candidate(s = \"0000000000000000000000000000\",minJump = 1,maxJump = 10) == True\n assert candidate(s = \"0101010101010101010101010101\",minJump = 3,maxJump = 5) == False\n assert candidate(s = \"0100000000000000000000000000\",minJump = 10,maxJump = 10) == False\n assert candidate(s = \"0001010101010101010101010101010100\",minJump = 3,maxJump = 8) == True\n assert candidate(s = \"0000000000000000000000000000\",minJump = 50,maxJump = 100) == False\n assert candidate(s = \"0000000000\",minJump = 4,maxJump = 6) == True\n assert candidate(s = \"0000000000000000000000000000\",minJump = 1,maxJump = 99999) == True\n assert candidate(s = \"0100000000000000000000000000\",minJump = 10000,maxJump = 50000) == False\n assert candidate(s = \"0000000000000000000000000000\",minJump = 10000,maxJump = 10000) == False\n assert candidate(s = \"0000000000000000000000000000\",minJump = 100,maxJump = 100) == False\n assert candidate(s = \"0000000000000000000000000000\",minJump = 1,maxJump = 50000) == True\n assert candidate(s = \"0001000100010001000100010000\",minJump = 3,maxJump = 5) == True\n"}, "metadata": {"canonical_parameter_names": ["s", "minJump", "maxJump"], "leetcode_dataset_entry_point": "Solution().canReach", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canReach(self, s: str, minJump: int, maxJump: int) -> bool:", "container": "Solution", "callable": "canReach", "parameters": [{"name": "s", "type": "str"}, {"name": "minJump", "type": "int"}, {"name": "maxJump", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1872, "task_id": "stone-game-viii", "difficulty": "Hard", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\\r\n\\r\nThere are n stones arranged in a row. On each player's turn, while the number of stones is more than one, they will do the following:\\r\n\\r\n\\r\n\tChoose an integer x > 1, and remove the leftmost x stones from the row.\\r\n\tAdd the sum of the removed stones' values to the player's score.\\r\n\tPlace a new stone, whose value is equal to that sum, on the left side of the row.\\r\n\\r\n\\r\nThe game stops when only one stone is left in the row.\\r\n\\r\nThe score difference between Alice and Bob is (Alice's score - Bob's score). Alice's goal is to maximize the score difference, and Bob's goal is the minimize the score difference.\\r\n\\r\nGiven an integer array stones of length n where stones[i] represents the value of the ith stone from the left, return the score difference between Alice and Bob if they both play optimally.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: stones = [-1,2,-3,4,-5]\\r\nOutput: 5\\r\nExplanation:\\r\n- Alice removes the first 4 stones, adds (-1) + 2 + (-3) + 4 = 2 to her score, and places a stone of\\r\n value 2 on the left. stones = [2,-5].\\r\n- Bob removes the first 2 stones, adds 2 + (-5) = -3 to his score, and places a stone of value -3 on\\r\n the left. stones = [-3].\\r\nThe difference between their scores is 2 - (-3) = 5.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: stones = [7,-6,5,10,5,-2,-6]\\r\nOutput: 13\\r\nExplanation:\\r\n- Alice removes all stones, adds 7 + (-6) + 5 + 10 + 5 + (-2) + (-6) = 13 to her score, and places a\\r\n stone of value 13 on the left. stones = [13].\\r\nThe difference between their scores is 13 - 0 = 13.\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: stones = [-10,-12]\\r\nOutput: -22\\r\nExplanation:\\r\n- Alice can only make one move, which is to remove both stones. She adds (-10) + (-12) = -22 to her\\r\n score and places a stone of value -22 on the left. stones = [-22].\\r\nThe difference between their scores is (-22) - 0 = -22.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\tn == stones.length\\r\n\t2 <= n <= 105\\r\n\t-104 <= stones[i] <= 104\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(stones = [10, -10, 20, -20, 30, -30]) == 30\n assert candidate(stones = [100, 200, -300, 400, -500, 600, -700, 800]) == 600\n assert candidate(stones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(stones = [-1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000]) == 0\n assert candidate(stones = [1, 2, 3, 4, 5]) == 15\n assert candidate(stones = [100, -100, 100, -100, 100]) == 100\n assert candidate(stones = [10, -10, 20, -20, 30, -30, 40, -40]) == 40\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(stones = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(stones = [-1, -2, -3, -4, -5]) == 5\n assert candidate(stones = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 50\n assert candidate(stones = [-10, -12]) == -22\n assert candidate(stones = [-5, -4, -3, -2, -1]) == 1\n assert candidate(stones = [7, -6, 5, 10, 5, -2, -6]) == 13\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(stones = [-1, 2, -3, 4, -5]) == 5\n assert candidate(stones = [100, -50, 25, -12, 6, -3, 1, -1, 3, -2, 5, -4, 7, -6, 9]) == 78\n assert candidate(stones = [-10000, 0, 10000, 0, -10000, 0, 10000, 0, -10000, 0, 10000, 0, -10000, 0, 10000, 0, -10000, 0, 10000, 0]) == 0\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(stones = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300, -1400, 1500]) == 800\n assert candidate(stones = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, -10000, -9000, -8000, -7000, -6000, -5000, -4000, -3000, -2000, -1000]) == 30000\n assert candidate(stones = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == 11055\n assert candidate(stones = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000]) == 1000\n assert candidate(stones = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 250\n assert candidate(stones = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000]) == 1000\n assert candidate(stones = [5, 10, -5, 20, -10, 25, -15, 30, -20, 35, -25, 40, -30, 45, -35, 50, -40, 55, -45, 60]) == 150\n assert candidate(stones = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(stones = [-5, 15, -25, 35, -45, 55, -65, 75, -85, 95, -105]) == 105\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(stones = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 10\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(stones = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 210\n assert candidate(stones = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]) == 16\n assert candidate(stones = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 10\n assert candidate(stones = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(stones = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 10\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == 1000\n assert candidate(stones = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0, -1, -3, -7, -15, -31]) == 1937\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n assert candidate(stones = [10000, -10000, 9999, -9999, 9998, -9998, 9997, -9997, 9996, -9996]) == 9996\n assert candidate(stones = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11]) == 11\n assert candidate(stones = [-10000, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1]) == -1\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1000, -900, -800, -700, -600]) == 3100\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(stones = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 20\n assert candidate(stones = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == 15\n assert candidate(stones = [10000, -5000, 2000, -1000, 500, -200, 100, -50, 20, -10]) == 6360\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 28\n assert candidate(stones = [-1, -2, -4, -8, -16, -32, -64, -128, -256, -512, -1024, -2048, -4096, -8192, -16384, -32768, -65536, -131072, -262144, -524288]) == 524288\n assert candidate(stones = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 9\n assert candidate(stones = [10000, -5000, 5000, -2500, 2500, -1250, 1250, -625, 625, -312, 312, -156, 156, -78, 78, -39, 39, -19, 19, -9, 9]) == 10000\n assert candidate(stones = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(stones = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, 5]) == 10\n assert candidate(stones = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 550000\n assert candidate(stones = [10000, -9999, 9998, -9997, 9996, -9995, 9994, -9993, 9992, -9991, 9990]) == 9995\n assert candidate(stones = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 8\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1200\n assert candidate(stones = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40, 45, -45, 50, -50]) == 50\n assert candidate(stones = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000, 1100, -1100, 1200, -1200]) == 1200\n assert candidate(stones = [1, -10, 100, -1000, 10000, -100000, 1000000, -10000000, 100000000, -1000000000]) == 1000000000\n assert candidate(stones = [-150, -140, -130, -120, -110, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 10\n assert candidate(stones = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10]) == 10\n assert candidate(stones = [10000, -9999, 9998, -9997, 9996, -9995, 9994, -9993, 9992, -9991]) == 9991\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(stones = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 0\n assert candidate(stones = [100, 200, -300, 400, -500, 600, -700, 800, -900, 1000]) == 700\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 300\n assert candidate(stones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1048575\n assert candidate(stones = [10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000]) == 10000\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(stones = [1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1]) == 1\n assert candidate(stones = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10000]) == 10014\n assert candidate(stones = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 20\n assert candidate(stones = [-5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5]) == 5\n"}, "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().stoneGameVIII", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def stoneGameVIII(self, stones: list[int]) -> int:", "container": "Solution", "callable": "stoneGameVIII", "parameters": [{"name": "stones", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1876, "task_id": "substrings-of-size-three-with-distinct-characters", "difficulty": "Easy", "problem_description": "A string is good if there are no repeated characters.\nGiven a string s​​​​​, return the number of good substrings of length three in s​​​​​​.\nNote that if there are multiple occurrences of the same substring, every occurrence should be counted.\nA substring is a contiguous sequence of characters in a string.\n \nExample 1:\n\nInput: s = \"xyzzaz\"\nOutput: 1\nExplanation: There are 4 substrings of size 3: \"xyz\", \"yzz\", \"zza\", and \"zaz\". \nThe only good substring of length 3 is \"xyz\".\n\nExample 2:\n\nInput: s = \"aababcabc\"\nOutput: 4\nExplanation: There are 7 substrings of size 3: \"aab\", \"aba\", \"bab\", \"abc\", \"bca\", \"cab\", and \"abc\".\nThe good substrings are \"abc\", \"bca\", \"cab\", and \"abc\".\n\n \nConstraints:\n\n1 <= s.length <= 100\ns​​​​​​ consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"xyzxyzxyz\") == 7\n assert candidate(s = \"abcabcabc\") == 7\n assert candidate(s = \"xyzzaz\") == 1\n assert candidate(s = \"aabbcc\") == 0\n assert candidate(s = \"abacab\") == 2\n assert candidate(s = \"qqqppprrr\") == 0\n assert candidate(s = \"abac\") == 1\n assert candidate(s = \"abc\") == 1\n assert candidate(s = \"xyzxyz\") == 4\n assert candidate(s = \"abcdcba\") == 4\n assert candidate(s = \"aababcabc\") == 4\n assert candidate(s = \"abacaba\") == 2\n assert candidate(s = \"abca\") == 2\n assert candidate(s = \"pqr\") == 1\n assert candidate(s = \"aaa\") == 0\n assert candidate(s = \"aaaaa\") == 0\n assert candidate(s = \"xyz\") == 1\n assert candidate(s = \"abcdefg\") == 5\n assert candidate(s = \"pqrspqrs\") == 6\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 49\n assert candidate(s = \"abcdefghijkabcdefghijkabcdefghijkabcdefghijk\") == 42\n assert candidate(s = \"abcdabcdeabcdefabcdefg\") == 20\n assert candidate(s = \"abcdefghtijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"abcdefghijklijkijklmnopqrstuvwxyz\") == 31\n assert candidate(s = \"abcdefabcdefabcdef\") == 16\n assert candidate(s = \"abcabcabcabc\") == 10\n assert candidate(s = \"uniquecharacters\") == 13\n assert candidate(s = \"thisisateststringforcountinggoodsubstrings\") == 32\n assert candidate(s = \"mnopqrspqrspqrspqr\") == 16\n assert candidate(s = \"aaaabbbbcccc\") == 0\n assert candidate(s = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"abacabadabacabad\") == 7\n assert candidate(s = \"abababababababababababababababababab\") == 0\n assert candidate(s = \"mnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopq\") == 73\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\") == 34\n assert candidate(s = \"xyzzyxzyxzyxzyxzyxzyxzyxzyx\") == 23\n assert candidate(s = \"aaabbbcccddd\") == 0\n assert candidate(s = \"abcdbcefg\") == 7\n assert candidate(s = \"abacabadabcabcabcabc\") == 14\n assert candidate(s = \"pqrstuvwxyza\") == 10\n assert candidate(s = \"mnopqrstuvwxyzabcdefghijkl\") == 24\n assert candidate(s = \"abcdbca\") == 5\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 28\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzxyz\") == 2\n assert candidate(s = \"xyzabxyzabxyzabxyz\") == 16\n assert candidate(s = \"abcdefgabcdefgabcdefgabcdefgabcdefgabcdefg\") == 40\n assert candidate(s = \"abcababcbacbacbabc\") == 12\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 24\n assert candidate(s = \"ababababababababab\") == 0\n assert candidate(s = \"abcabcabcabcabcabc\") == 16\n assert candidate(s = \"aabbccddeeffgghhii\") == 0\n assert candidate(s = \"abacabacabacabacabacabacabacabacabacabac\") == 19\n assert candidate(s = \"abcdeffedcbaabcdeffedcbaabcdeffedcbaabcdeffedcba\") == 32\n assert candidate(s = \"abcdefgheijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"xyzzyxzyxzyxzyxzyx\") == 14\n assert candidate(s = \"zzzzzzzzz\") == 0\n assert candidate(s = \"xyzzyzzxyzzxyzzxyzzx\") == 7\n assert candidate(s = \"abcdexyz\") == 6\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaaa\") == 25\n assert candidate(s = \"abacabadabacaba\") == 6\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzz\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 76\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"abcdefgabcdefgabcdefgabcdefg\") == 26\n assert candidate(s = \"aabbccddeeffgghhiii\") == 0\n assert candidate(s = \"abacabadabcaba\") == 7\n assert candidate(s = \"mnopqmnopqmnopq\") == 13\n assert candidate(s = \"aabbccddeeffgg\") == 0\n assert candidate(s = \"uniquecharactersinthisstringareunique\") == 32\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzyyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggeeffddbbaa\") == 0\n assert candidate(s = \"aabcaabcdaabcaabcdaabc\") == 11\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 24\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooo\") == 0\n assert candidate(s = \"abcdeabcdeabcde\") == 13\n assert candidate(s = \"ababababab\") == 0\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(s = \"abcdefgabcdefgabcdefg\") == 19\n assert candidate(s = \"abacdefghijklmnopqrstuvwxyz\") == 24\n assert candidate(s = \"xyzzazxyzzazxyzzaz\") == 7\n assert candidate(s = \"abababababababababababababababababababab\") == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabcabc\") == 25\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 22\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 50\n assert candidate(s = \"abacabadabcabc\") == 8\n assert candidate(s = \"abacabadaba\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\") == 31\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"thisisaverylongstringwithvariouscharacters\") == 37\n assert candidate(s = \"mississippi\") == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"repeatedrepeatedrepeatedrepeatedrepeated\") == 33\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"allcharactersareuniquehere\") == 19\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().countGoodSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countGoodSubstrings(self, s: str) -> int:", "container": "Solution", "callable": "countGoodSubstrings", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1877, "task_id": "minimize-maximum-pair-sum-in-array", "difficulty": "Medium", "problem_description": "The pair sum of a pair (a,b) is equal to a + b. The maximum pair sum is the largest pair sum in a list of pairs.\\r\n\\r\n\\r\n\tFor example, if we have pairs (1,5), (2,3), and (4,4), the maximum pair sum would be max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8.\\r\n\\r\n\\r\nGiven an array nums of even length n, pair up the elements of nums into n / 2 pairs such that:\\r\n\\r\n\\r\n\tEach element of nums is in exactly one pair, and\\r\n\tThe maximum pair sum is minimized.\\r\n\\r\n\\r\nReturn the minimized maximum pair sum after optimally pairing up the elements.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: nums = [3,5,2,3]\\r\nOutput: 7\\r\nExplanation: The elements can be paired up into pairs (3,3) and (5,2).\\r\nThe maximum pair sum is max(3+3, 5+2) = max(6, 7) = 7.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: nums = [3,5,4,2,4,6]\\r\nOutput: 8\\r\nExplanation: The elements can be paired up into pairs (3,5), (4,4), and (6,2).\\r\nThe maximum pair sum is max(3+5, 4+4, 6+2) = max(8, 8, 8) = 8.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\tn == nums.length\\r\n\t2 <= n <= 105\\r\n\tn is even.\\r\n\t1 <= nums[i] <= 105\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 6, 2, 5, 3, 4]) == 7\n assert candidate(nums = [10, 10, 10, 10]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1]) == 100001\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 7\n assert candidate(nums = [1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [10, 10, 10, 10, 10, 10]) == 20\n assert candidate(nums = [3, 5, 4, 2, 4, 6]) == 8\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5]) == 10\n assert candidate(nums = [3, 5, 2, 3]) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 32\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 105\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 32\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994]) == 100001\n assert candidate(nums = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 99999]) == 100001\n assert candidate(nums = [5, 8, 12, 19, 22, 28, 33, 45, 50, 55]) == 60\n assert candidate(nums = [8, 3, 5, 7, 1, 9, 2, 6, 4, 10]) == 11\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [7, 3, 1, 4, 9, 8, 2, 5, 6, 10]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 17\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995]) == 100000\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 200000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 31\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [4, 1, 2, 3, 6, 5, 7, 8]) == 9\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995]) == 100000\n assert candidate(nums = [15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16]) == 17\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993]) == 100001\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 4, 6, 3, 7, 2, 8]) == 10\n assert candidate(nums = [34, 8, 64, 51, 32, 21]) == 72\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 55\n assert candidate(nums = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 100001\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 11\n assert candidate(nums = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100000]) == 100002\n assert candidate(nums = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == 100001\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 11\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 1991\n assert candidate(nums = [23, 34, 45, 56, 67, 78, 89, 90]) == 123\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [2, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 9\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 100000\n assert candidate(nums = [100, 1, 2, 99, 3, 98, 4, 97]) == 101\n assert candidate(nums = [9, 1, 4, 8, 5, 7, 6, 2]) == 11\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996]) == 100000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14, 16]) == 17\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(nums = [8, 3, 2, 1, 6, 5, 4, 7]) == 9\n assert candidate(nums = [100000, 1, 100000, 2, 100000, 3, 100000, 4]) == 100004\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 31\n assert candidate(nums = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 50\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]) == 12\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12]) == 13\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 100000\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 9, 8, 11, 10]) == 12\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 100\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85]) == 100\n assert candidate(nums = [7, 10, 4, 17, 15, 9, 2, 12]) == 19\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 182, 189, 196, 203, 210]) == 217\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 170\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]) == 12\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 130\n assert candidate(nums = [100000, 99999, 1, 2, 99998, 3, 99997, 4, 99996, 5, 99995, 6]) == 100001\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6]) == 3\n assert candidate(nums = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == 100005\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000]) == 200000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 130\n assert candidate(nums = [100000, 1, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 100001\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12]) == 13\n assert candidate(nums = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 21\n assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995, 5]) == 100000\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995, 6, 99994]) == 100000\n assert candidate(nums = [15, 21, 33, 44, 55, 60, 65, 70, 75, 80, 85, 90]) == 125\n assert candidate(nums = [9, 3, 2, 8, 6, 5, 7, 4, 1, 10]) == 11\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 18, 17, 16, 15, 14, 13, 12]) == 19\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1]) == 100001\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 17\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 100000\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 101\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 24\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n assert candidate(nums = [9, 2, 8, 4, 5, 1, 6, 3, 7, 10]) == 11\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minPairSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minPairSum(self, nums: List[int]) -> int:", "container": "Solution", "callable": "minPairSum", "parameters": [{"name": "nums", "type": "List[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1878, "task_id": "get-biggest-three-rhombus-sums-in-a-grid", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix grid​​​.\nA rhombus sum is the sum of the elements that form the border of a regular rhombus shape in grid​​​. The rhombus must have the shape of a square rotated 45 degrees with each of the corners centered in a grid cell. Below is an image of four valid rhombus shapes with the corresponding colored cells that should be included in each rhombus sum:\n\nNote that the rhombus can have an area of 0, which is depicted by the purple rhombus in the bottom right corner.\nReturn the biggest three distinct rhombus sums in the grid in descending order. If there are less than three distinct values, return all of them.\n \nExample 1:\n\n\nInput: grid = [[3,4,5,1,3],[3,3,4,2,3],[20,30,200,40,10],[1,5,5,4,1],[4,3,2,2,5]]\nOutput: [228,216,211]\nExplanation: The rhombus shapes for the three biggest distinct rhombus sums are depicted above.\n- Blue: 20 + 3 + 200 + 5 = 228\n- Red: 200 + 2 + 10 + 4 = 216\n- Green: 5 + 200 + 4 + 2 = 211\n\nExample 2:\n\n\nInput: grid = [[1,2,3],[4,5,6],[7,8,9]]\nOutput: [20,9,8]\nExplanation: The rhombus shapes for the three biggest distinct rhombus sums are depicted above.\n- Blue: 4 + 2 + 6 + 8 = 20\n- Red: 9 (area 0 rhombus in the bottom right corner)\n- Green: 8 (area 0 rhombus in the bottom middle)\n\nExample 3:\n\nInput: grid = [[7,7,7]]\nOutput: [7]\nExplanation: All three possible rhombus sums are the same, so return [7].\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 50\n1 <= grid[i][j] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [104, 76, 72]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == [56, 52, 48]\n assert candidate(grid = [[7, 7, 7]]) == [7]\n assert candidate(grid = [[3, 4, 5, 1, 3], [3, 3, 4, 2, 3], [20, 30, 200, 40, 10], [1, 5, 5, 4, 1], [4, 3, 2, 2, 5]]) == [228, 216, 211]\n assert candidate(grid = [[5, 3, 5, 8], [15, 25, 35, 45], [60, 70, 80, 90], [10, 20, 30, 40]]) == [225, 185, 155]\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == [40, 20, 5]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == [4, 1]\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == [20, 5]\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == [20, 9, 8]\n assert candidate(grid = [[5, 3, 5, 5, 5], [3, 3, 3, 3, 3], [5, 5, 5, 5, 5], [3, 3, 3, 3, 3], [5, 5, 5, 5, 5]]) == [32, 16, 14]\n assert candidate(grid = [[10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10]]) == [80, 40, 10]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 3, 4, 3, 1], [1, 2, 3, 3, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]) == [18, 17, 12]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == [40, 20, 5]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10], [6, 7, 8, 9, 10, 11]]) == [56, 48, 40]\n assert candidate(grid = [[9, 1, 3, 7, 5], [2, 6, 4, 8, 0], [5, 9, 1, 3, 7], [4, 8, 2, 6, 4], [3, 7, 5, 9, 1]]) == [48, 22, 20]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == [12, 8, 6]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [62, 61, 60]\n assert candidate(grid = [[10, 10, 10, 10, 10, 10, 10], [10, 9, 8, 7, 6, 5, 4], [10, 8, 6, 4, 2, 0, 2], [10, 7, 5, 3, 1, 3, 5], [10, 6, 4, 2, 0, 2, 4], [10, 5, 3, 1, 3, 5, 7], [10, 4, 2, 0, 2, 4, 6]]) == [61, 52, 42]\n assert candidate(grid = [[25, 16, 32, 8, 4], [12, 24, 18, 36, 27], [6, 12, 24, 18, 36], [3, 6, 12, 24, 18], [1, 3, 6, 12, 24]]) == [170, 120, 116]\n assert candidate(grid = [[20, 10, 20, 10, 20], [10, 20, 10, 20, 10], [20, 10, 20, 10, 20], [10, 20, 10, 20, 10], [20, 10, 20, 10, 20]]) == [160, 80, 40]\n assert candidate(grid = [[50, 40, 30, 20, 10], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]) == [320, 220, 200]\n assert candidate(grid = [[10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24], [25, 26, 27, 28, 29], [30, 31, 32, 33, 34]]) == [176, 112, 108]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]]) == [176, 168, 128]\n assert candidate(grid = [[1, 10, 100, 1000, 10000], [10000, 1000, 100, 10, 1], [1, 10, 100, 1000, 10000], [10000, 1000, 100, 10, 1], [1, 10, 100, 1000, 10000]]) == [12221, 10120, 10000]\n assert candidate(grid = [[10, 20, 30, 40], [40, 30, 20, 10], [10, 20, 30, 40], [40, 30, 20, 10]]) == [100, 40, 30]\n assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [5, 6, 7, 8, 9], [0, 1, 2, 3, 4], [9, 8, 7, 6, 5]]) == [36, 20, 18]\n assert candidate(grid = [[10, 15, 20, 25, 30], [5, 9, 12, 18, 22], [3, 6, 8, 10, 14], [1, 2, 3, 4, 5], [7, 11, 13, 17, 19]]) == [83, 69, 55]\n assert candidate(grid = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [13, 15, 17, 19, 21, 23], [25, 27, 29, 31, 33, 35], [37, 39, 41, 43, 45, 47], [49, 51, 53, 55, 57, 59]]) == [249, 233, 180]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 4, 6, 4, 2], [1, 5, 9, 5, 1]]) == [28, 22, 16]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == [176, 160, 156]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [20, 9, 8]\n assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == [46, 36, 32]\n assert candidate(grid = [[1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20], [5, 9, 13, 17, 21]]) == [88, 64, 60]\n assert candidate(grid = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12]]) == [60, 44, 38]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [88, 66, 44]\n assert candidate(grid = [[9, 8, 7, 6], [5, 4, 3, 2], [1, 0, 1, 2], [3, 4, 5, 6]]) == [16, 14, 10]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 3, 4, 3, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1]]) == [20, 18, 12]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [32, 30, 28]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == [127, 118, 109]\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8], [6, 7, 8, 9]]) == [28, 24, 20]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == [12, 8, 6]\n assert candidate(grid = [[5, 5, 5, 5], [5, 1, 1, 5], [5, 1, 1, 5], [5, 5, 5, 5]]) == [12, 5, 1]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 10, 10, 10, 10, 5], [5, 10, 15, 15, 10, 5], [5, 10, 15, 15, 10, 5], [5, 10, 10, 10, 10, 5], [5, 5, 5, 5, 5, 5]]) == [75, 50, 40]\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]) == [24, 20, 16]\n assert candidate(grid = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70], [40, 50, 60, 70, 80], [50, 60, 70, 80, 90]]) == [400, 280, 240]\n assert candidate(grid = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [3, 5, 7, 9, 11, 13], [4, 6, 8, 10, 12, 14], [5, 7, 9, 11, 13, 15], [6, 8, 10, 12, 14, 16]]) == [80, 72, 64]\n assert candidate(grid = [[1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1]]) == [8, 4, 2]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5], [5, 6, 6, 6, 6, 6, 5], [5, 6, 7, 7, 7, 6, 5], [5, 6, 7, 8, 7, 6, 5], [5, 6, 7, 7, 7, 6, 5], [5, 6, 6, 6, 6, 6, 5], [5, 5, 5, 5, 5, 5, 5]]) == [68, 52, 50]\n assert candidate(grid = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [110, 120, 130, 140, 150], [160, 170, 180, 190, 200], [210, 220, 230, 240, 250]]) == [1040, 760, 720]\n assert candidate(grid = [[100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000]]) == [400000, 100000]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == [80, 60, 40]\n assert candidate(grid = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [60, 70, 80, 90, 100], [55, 65, 75, 85, 95], [110, 120, 130, 140, 150]]) == [520, 400, 360]\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4], [3, 5, 7, 8, 1, 6, 4], [4, 6, 8, 3, 5, 7, 1], [9, 2, 5, 1, 8, 3, 6], [5, 7, 1, 6, 4, 9, 2], [6, 4, 9, 2, 7, 1, 5], [1, 8, 3, 7, 2, 5, 9]]) == [78, 55, 44]\n assert candidate(grid = [[8, 1, 2, 3, 4, 5], [6, 7, 8, 9, 1, 2], [3, 4, 5, 6, 7, 8], [9, 1, 2, 3, 4, 5], [5, 6, 7, 8, 9, 1], [2, 3, 4, 5, 6, 7]]) == [49, 48, 39]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [9, 7, 5, 3, 1, 3, 5, 7, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [9, 7, 5, 3, 1, 3, 5, 7, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == [80, 68, 67]\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3], [8, 7, 6, 5, 4, 3, 2], [7, 6, 5, 4, 3, 2, 1], [6, 5, 4, 3, 2, 1, 0], [5, 4, 3, 2, 1, 0, -1], [4, 3, 2, 1, 0, -1, -2], [3, 2, 1, 0, -1, -2, -3]]) == [40, 36, 32]\n assert candidate(grid = [[9, 9, 9, 9, 9, 9, 9], [9, 8, 8, 8, 8, 8, 9], [9, 8, 7, 7, 7, 8, 9], [9, 8, 7, 6, 7, 8, 9], [9, 8, 7, 7, 7, 8, 9], [9, 8, 8, 8, 8, 8, 9], [9, 9, 9, 9, 9, 9, 9]]) == [100, 62, 60]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 3, 4, 3, 2], [1, 2, 3, 3, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]) == [18, 17, 12]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [1, 2, 3, 4, 5]]) == [28, 15, 13]\n assert candidate(grid = [[5, 2, 1, 4, 3, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42]]) == [208, 200, 192]\n assert candidate(grid = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]) == [320, 220, 200]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [2, 3, 4, 5, 6, 7, 8, 9], [3, 4, 5, 6, 7, 8, 9, 10], [4, 5, 6, 7, 8, 9, 10, 11], [5, 6, 7, 8, 9, 10, 11, 12], [6, 7, 8, 9, 10, 11, 12, 13], [7, 8, 9, 10, 11, 12, 13, 14], [8, 9, 10, 11, 12, 13, 14, 15]]) == [108, 96, 88]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 8], [3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10, 11], [6, 7, 8, 9, 10, 11, 12], [7, 8, 9, 10, 11, 12, 13]]) == [84, 72, 64]\n assert candidate(grid = [[100000, 100000, 100000], [100000, 100000, 100000], [100000, 100000, 100000]]) == [400000, 100000]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [3, 4, 5, 6, 7, 8, 9, 10, 1, 2], [4, 5, 6, 7, 8, 9, 10, 1, 2, 3], [5, 6, 7, 8, 9, 10, 1, 2, 3, 4], [6, 7, 8, 9, 10, 1, 2, 3, 4, 5], [7, 8, 9, 10, 1, 2, 3, 4, 5, 6], [8, 9, 10, 1, 2, 3, 4, 5, 6, 7], [9, 10, 1, 2, 3, 4, 5, 6, 7, 8], [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == [90, 86, 84]\n assert candidate(grid = [[1, 10, 100, 1000, 10000], [10, 100, 1000, 10000, 1], [100, 1000, 10000, 1, 10], [1000, 10000, 1, 10, 100], [10000, 1, 10, 100, 1000]]) == [20330, 20200, 20020]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]]) == [300, 264, 256]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [32, 30, 28]\n assert candidate(grid = [[10, 1, 10, 1, 10], [1, 10, 1, 10, 1], [10, 1, 10, 1, 10], [1, 10, 1, 10, 1], [10, 1, 10, 1, 10]]) == [80, 40, 10]\n assert candidate(grid = [[5, 2, 3, 1, 4], [1, 5, 6, 2, 3], [4, 1, 7, 3, 2], [3, 8, 4, 6, 5], [9, 7, 6, 5, 4]]) == [36, 27, 24]\n assert candidate(grid = [[10, 11, 12], [13, 14, 15], [16, 17, 18]]) == [56, 18, 17]\n assert candidate(grid = [[8, 4, 2], [6, 2, 4], [1, 3, 6]]) == [17, 8, 6]\n assert candidate(grid = [[1, 2], [3, 4]]) == [4, 3, 2]\n assert candidate(grid = [[5, 9, 1, 9], [8, 7, 4, 8], [6, 6, 3, 2]]) == [27, 19, 9]\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == [20, 5]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [4, 2, 1, 2, 4], [1, 5, 9, 5, 1]]) == [24, 18, 14]\n assert candidate(grid = [[5, 1, 4, 3, 1], [2, 3, 5, 1, 4], [3, 4, 3, 4, 3], [4, 3, 5, 1, 3], [3, 4, 2, 4, 2]]) == [20, 18, 17]\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == [20, 16, 12]\n assert candidate(grid = [[10, 10, 10, 10, 10], [10, 20, 20, 20, 10], [10, 20, 30, 20, 10], [10, 20, 20, 20, 10], [10, 10, 10, 10, 10]]) == [120, 80, 60]\n assert candidate(grid = [[1, 2], [2, 3], [3, 4]]) == [4, 3, 2]\n assert candidate(grid = [[5, 3, 5, 3, 5], [3, 5, 3, 5, 3], [5, 3, 5, 3, 5], [3, 5, 3, 5, 3], [5, 3, 5, 3, 5]]) == [40, 20, 12]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24]]) == [68, 64, 60]\n assert candidate(grid = [[10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10]]) == [40, 10]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 4, 6, 4, 2], [3, 5, 7, 5, 3]]) == [26, 20, 16]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9]]) == [15, 14, 13]\n assert candidate(grid = [[5, 3, 2, 1], [4, 6, 7, 8], [1, 9, 10, 11], [12, 13, 14, 15]]) == [41, 30, 26]\n assert candidate(grid = [[100000, 100000], [100000, 100000]]) == [100000]\n assert candidate(grid = [[5, 3, 5, 5, 5], [3, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 3], [5, 5, 5, 3, 5]]) == [40, 20, 16]\n assert candidate(grid = [[5, 3, 5, 3], [5, 3, 5, 3], [5, 3, 5, 3], [5, 3, 5, 3]]) == [16, 5, 3]\n assert candidate(grid = [[5]]) == [5]\n assert candidate(grid = [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]]) == [36, 9]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [1, 1, 1, 1, 1]]) == [30, 19, 18]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == [12, 5, 4]\n assert candidate(grid = [[10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]]) == [40, 10]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]]) == [40, 20, 5]\n assert candidate(grid = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]]) == [440, 400, 280]\n assert candidate(grid = [[1, 2], [3, 4], [5, 6]]) == [6, 5, 4]\n assert candidate(grid = [[10, 10, 10], [10, 10, 10], [10, 10, 10]]) == [40, 10]\n assert candidate(grid = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == [20, 9, 8]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]) == [128, 120, 92]\n assert candidate(grid = [[5, 3, 2, 1], [9, 8, 7, 6], [5, 6, 7, 8], [1, 2, 3, 4]]) == [25, 24, 23]\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50]]) == [240, 120, 50]\n assert candidate(grid = [[9, 9, 9, 9, 9], [9, 8, 8, 8, 9], [9, 8, 7, 8, 9], [9, 8, 8, 8, 9], [9, 9, 9, 9, 9]]) == [68, 34, 32]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == [8, 4, 1]\n assert candidate(grid = [[10, 20, 30, 40], [15, 25, 35, 45], [20, 30, 40, 50], [25, 35, 45, 55]]) == [160, 140, 120]\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]) == [200, 90, 80]\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == [44, 40, 28]\n assert candidate(grid = [[5, 2, 10, 6], [8, 3, 9, 7], [1, 4, 8, 2], [7, 6, 5, 3]]) == [28, 23, 20]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]]) == [40, 20, 5]\n assert candidate(grid = [[8, 1, 6], [3, 5, 7], [4, 9, 2]]) == [20, 9, 8]\n assert candidate(grid = [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]]) == [72, 36, 9]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == [10, 9, 8]\n assert candidate(grid = [[1, 2], [2, 1]]) == [2, 1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == [8, 4, 1]\n assert candidate(grid = [[100000, 100000, 100000], [100000, 100000, 100000], [100000, 100000, 100000]]) == [400000, 100000]\n assert candidate(grid = [[9, 9, 9, 9], [9, 9, 9, 9], [9, 9, 9, 9], [9, 9, 9, 9]]) == [36, 9]\n assert candidate(grid = [[1]]) == [1]\n assert candidate(grid = [[5, 3, 8, 3, 7], [3, 2, 5, 7, 8], [1, 7, 3, 3, 2], [4, 8, 4, 2, 9], [6, 2, 3, 4, 8]]) == [33, 20, 19]\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().getBiggestThree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getBiggestThree(self, grid: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "getBiggestThree", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1879, "task_id": "minimum-xor-sum-of-two-arrays", "difficulty": "Hard", "problem_description": "You are given two integer arrays nums1 and nums2 of length n.\nThe XOR sum of the two integer arrays is (nums1[0] XOR nums2[0]) + (nums1[1] XOR nums2[1]) + ... + (nums1[n - 1] XOR nums2[n - 1]) (0-indexed).\n\nFor example, the XOR sum of [1,2,3] and [3,2,1] is equal to (1 XOR 3) + (2 XOR 2) + (3 XOR 1) = 2 + 0 + 2 = 4.\n\nRearrange the elements of nums2 such that the resulting XOR sum is minimized.\nReturn the XOR sum after the rearrangement.\n \nExample 1:\n\nInput: nums1 = [1,2], nums2 = [2,3]\nOutput: 2\nExplanation: Rearrange nums2 so that it becomes [3,2].\nThe XOR sum is (1 XOR 3) + (2 XOR 2) = 2 + 0 = 2.\nExample 2:\n\nInput: nums1 = [1,0,3], nums2 = [5,3,4]\nOutput: 8\nExplanation: Rearrange nums2 so that it becomes [5,4,3]. \nThe XOR sum is (1 XOR 5) + (0 XOR 4) + (3 XOR 3) = 4 + 4 + 0 = 8.\n\n \nConstraints:\n\nn == nums1.length\nn == nums2.length\n1 <= n <= 14\n0 <= nums1[i], nums2[i] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [3, 4, 2],nums2 = [4, 2, 2]) == 1\n assert candidate(nums1 = [1, 2],nums2 = [2, 3]) == 2\n assert candidate(nums1 = [2, 3, 4, 5],nums2 = [5, 4, 3, 2]) == 0\n assert candidate(nums1 = [4, 6, 2],nums2 = [9, 3, 5]) == 17\n assert candidate(nums1 = [5, 10, 15],nums2 = [15, 10, 5]) == 0\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 20, 10]) == 0\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 1, 1],nums2 = [1, 1, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == 0\n assert candidate(nums1 = [5, 3, 4],nums2 = [1, 0, 3]) == 8\n assert candidate(nums1 = [14, 15, 16],nums2 = [13, 14, 15]) == 29\n assert candidate(nums1 = [7, 8, 9],nums2 = [9, 8, 7]) == 0\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [2, 2, 2, 2]) == 12\n assert candidate(nums1 = [7, 8, 9],nums2 = [10, 11, 12]) == 15\n assert candidate(nums1 = [10000000, 10000000, 10000000],nums2 = [10000000, 10000000, 10000000]) == 0\n assert candidate(nums1 = [3, 5, 7, 9],nums2 = [9, 7, 5, 3]) == 0\n assert candidate(nums1 = [0, 1, 2],nums2 = [3, 4, 5]) == 9\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [14, 28, 19],nums2 = [28, 14, 19]) == 0\n assert candidate(nums1 = [1],nums2 = [1]) == 0\n assert candidate(nums1 = [1, 0, 3],nums2 = [5, 3, 4]) == 8\n assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 14\n assert candidate(nums1 = [12, 14, 16, 18, 20, 22],nums2 = [21, 19, 17, 15, 13, 11]) == 34\n assert candidate(nums1 = [4, 1, 3, 2],nums2 = [7, 6, 5, 8]) == 18\n assert candidate(nums1 = [9999999, 8888888, 7777777, 6666666, 5555555],nums2 = [4444444, 3333333, 2222222, 1111111, 0]) == 28302135\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128],nums2 = [128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums1 = [7, 23, 15, 4, 8],nums2 = [17, 9, 3, 20, 12]) == 30\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8],nums2 = [8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27]) == 115\n assert candidate(nums1 = [10000000, 10000001, 10000002, 10000003, 10000004],nums2 = [10000005, 10000006, 10000007, 10000008, 10000009]) == 25\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 36\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 119\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 9999999, 999999, 99999, 9999, 999, 99],nums2 = [99, 999, 9999, 99999, 999999, 9999999, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 45\n assert candidate(nums1 = [7, 8, 9, 10, 11, 12],nums2 = [12, 11, 10, 9, 8, 7]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 220\n assert candidate(nums1 = [7, 13, 21, 31],nums2 = [3, 8, 15, 28]) == 34\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],nums2 = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],nums2 = [70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],nums2 = [32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 32769\n assert candidate(nums1 = [13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41],nums2 = [43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71]) == 546\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums1 = [7, 8, 9, 10, 11],nums2 = [12, 13, 14, 15, 16]) == 39\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [10000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10000000]) == 0\n assert candidate(nums1 = [13, 17, 19, 23, 29, 31],nums2 = [31, 29, 23, 19, 17, 13]) == 0\n assert candidate(nums1 = [101, 202, 303, 404, 505, 606, 707, 808, 909],nums2 = [909, 808, 707, 606, 505, 404, 303, 202, 101]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [2, 4, 6, 8, 10, 12, 14, 16]) == 24\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 42\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],nums2 = [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800],nums2 = [800, 700, 600, 500, 400, 300, 200, 100]) == 0\n assert candidate(nums1 = [5, 8, 12, 7, 3],nums2 = [10, 6, 4, 15, 9]) == 15\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],nums2 = [16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000],nums2 = [140000, 130000, 120000, 110000, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 14\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],nums2 = [140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(nums1 = [1, 0, 0, 0],nums2 = [0, 1, 1, 1]) == 2\n assert candidate(nums1 = [21, 17, 34, 19, 28, 42],nums2 = [45, 39, 27, 51, 18, 32]) == 101\n assert candidate(nums1 = [8, 6, 4, 2, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18],nums2 = [18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 2, 4, 6, 8]) == 0\n assert candidate(nums1 = [5, 6, 7, 8, 9, 10, 11, 12, 13],nums2 = [13, 12, 11, 10, 9, 8, 7, 6, 5]) == 0\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192],nums2 = [8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums1 = [9, 11, 7, 13, 17, 19, 23],nums2 = [29, 25, 21, 15, 13, 11, 7]) == 30\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7],nums2 = [7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [7, 23, 45, 6, 78],nums2 = [89, 12, 34, 56, 78]) == 146\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 0\n assert candidate(nums1 = [8, 16, 24, 32, 40, 48, 56, 64],nums2 = [64, 56, 48, 40, 32, 24, 16, 8]) == 0\n assert candidate(nums1 = [10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000],nums2 = [10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 15\n assert candidate(nums1 = [9876543, 8765432, 7654321, 6543210, 5432109],nums2 = [4321098, 3210987, 2109876, 1098765, 987654]) == 28067535\n assert candidate(nums1 = [8, 16, 32, 64, 128, 256],nums2 = [256, 128, 64, 32, 16, 8]) == 0\n assert candidate(nums1 = [1234567, 7654321, 111222333, 444555666, 777888999],nums2 = [999888777, 666555444, 333222111, 210987654, 123456789]) == 1307758981\n assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000],nums2 = [50000, 40000, 30000, 20000, 10000]) == 0\n assert candidate(nums1 = [123456, 789012, 345678, 901234, 567890, 678901, 789012, 890123, 901234, 123456, 234567, 345678, 456789, 567890],nums2 = [567890, 456789, 345678, 234567, 123456, 901234, 890123, 789012, 678901, 567890, 456789, 345678, 234567, 123456]) == 1656438\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53],nums2 = [53, 49, 45, 41, 37, 33, 29, 25, 21, 17, 13, 9, 5, 1]) == 0\n assert candidate(nums1 = [16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],nums2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70],nums2 = [70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10]) == 0\n assert candidate(nums1 = [7, 8, 9, 10, 11],nums2 = [11, 10, 9, 8, 7]) == 0\n assert candidate(nums1 = [2, 3, 5, 7, 11, 13, 17, 19],nums2 = [19, 17, 13, 11, 7, 5, 3, 2]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [10, 8, 6, 4, 2]) == 15\n assert candidate(nums1 = [256, 512, 1024, 2048, 4096],nums2 = [8192, 4096, 2048, 1024, 512]) == 8448\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400],nums2 = [1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 0\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],nums2 = [98, 91, 84, 77, 70, 63, 56, 49, 42, 35, 28, 21, 14, 7]) == 0\n assert candidate(nums1 = [1, 10000000, 2, 9999999, 3, 9999998, 4, 9999997, 5, 9999996, 6, 9999995, 7, 9999994, 8],nums2 = [8, 7, 9999994, 9, 6, 9999995, 10, 9999996, 5, 9999997, 4, 9999998, 3, 9999999, 2]) == 10000018\n assert candidate(nums1 = [23, 34, 45, 56, 67],nums2 = [67, 56, 45, 34, 23]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13],nums2 = [13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700],nums2 = [700, 600, 500, 400, 300, 200, 100]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minimumXORSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumXORSum(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "minimumXORSum", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1880, "task_id": "check-if-word-equals-summation-of-two-words", "difficulty": "Easy", "problem_description": "The letter value of a letter is its position in the alphabet starting from 0 (i.e. 'a' -> 0, 'b' -> 1, 'c' -> 2, etc.).\nThe numerical value of some string of lowercase English letters s is the concatenation of the letter values of each letter in s, which is then converted into an integer.\n\nFor example, if s = \"acb\", we concatenate each letter's letter value, resulting in \"021\". After converting it, we get 21.\n\nYou are given three strings firstWord, secondWord, and targetWord, each consisting of lowercase English letters 'a' through 'j' inclusive.\nReturn true if the summation of the numerical values of firstWord and secondWord equals the numerical value of targetWord, or false otherwise.\n \nExample 1:\n\nInput: firstWord = \"acb\", secondWord = \"cba\", targetWord = \"cdb\"\nOutput: true\nExplanation:\nThe numerical value of firstWord is \"acb\" -> \"021\" -> 21.\nThe numerical value of secondWord is \"cba\" -> \"210\" -> 210.\nThe numerical value of targetWord is \"cdb\" -> \"231\" -> 231.\nWe return true because 21 + 210 == 231.\n\nExample 2:\n\nInput: firstWord = \"aaa\", secondWord = \"a\", targetWord = \"aab\"\nOutput: false\nExplanation: \nThe numerical value of firstWord is \"aaa\" -> \"000\" -> 0.\nThe numerical value of secondWord is \"a\" -> \"0\" -> 0.\nThe numerical value of targetWord is \"aab\" -> \"001\" -> 1.\nWe return false because 0 + 0 != 1.\n\nExample 3:\n\nInput: firstWord = \"aaa\", secondWord = \"a\", targetWord = \"aaaa\"\nOutput: true\nExplanation: \nThe numerical value of firstWord is \"aaa\" -> \"000\" -> 0.\nThe numerical value of secondWord is \"a\" -> \"0\" -> 0.\nThe numerical value of targetWord is \"aaaa\" -> \"0000\" -> 0.\nWe return true because 0 + 0 == 0.\n\n \nConstraints:\n\n1 <= firstWord.length, secondWord.length, targetWord.length <= 8\nfirstWord, secondWord, and targetWord consist of lowercase English letters from 'a' to 'j' inclusive.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(firstWord = \"ij\",secondWord = \"ji\",targetWord = \"ii\") == False\n assert candidate(firstWord = \"fgh\",secondWord = \"ghf\",targetWord = \"ggg\") == False\n assert candidate(firstWord = \"ij\",secondWord = \"ji\",targetWord = \"jjj\") == False\n assert candidate(firstWord = \"b\",secondWord = \"c\",targetWord = \"d\") == True\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"aaaaaaaaaa\") == False\n assert candidate(firstWord = \"i\",secondWord = \"j\",targetWord = \"ji\") == False\n assert candidate(firstWord = \"ab\",secondWord = \"ba\",targetWord = \"bb\") == True\n assert candidate(firstWord = \"j\",secondWord = \"j\",targetWord = \"i\") == False\n assert candidate(firstWord = \"a\",secondWord = \"a\",targetWord = \"b\") == False\n assert candidate(firstWord = \"aaa\",secondWord = \"a\",targetWord = \"aab\") == False\n assert candidate(firstWord = \"aaa\",secondWord = \"a\",targetWord = \"aaaa\") == True\n assert candidate(firstWord = \"acb\",secondWord = \"cba\",targetWord = \"cdb\") == True\n assert candidate(firstWord = \"j\",secondWord = \"j\",targetWord = \"jj\") == False\n assert candidate(firstWord = \"acacacac\",secondWord = \"bdbdbdbd\",targetWord = \"cececece\") == False\n assert candidate(firstWord = \"aaaabbbb\",secondWord = \"ccccdddd\",targetWord = \"aaaabbbbccccdddd\") == False\n assert candidate(firstWord = \"ijijijij\",secondWord = \"jijijiji\",targetWord = \"jjjjjjjjjj\") == False\n assert candidate(firstWord = \"ijijij\",secondWord = \"jijiji\",targetWord = \"jjjjjjjj\") == False\n assert candidate(firstWord = \"j\",secondWord = \"jj\",targetWord = \"jjj\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghi\",targetWord = \"aaaaaaaaaa\") == False\n assert candidate(firstWord = \"babcbabcba\",secondWord = \"cbabcbabcb\",targetWord = \"bbbbbbaaaa\") == False\n assert candidate(firstWord = \"jihgfedcba\",secondWord = \"abcdefghij\",targetWord = \"aaaaaaaaaa\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"jjjjjjjjjj\") == False\n assert candidate(firstWord = \"ijkl\",secondWord = \"lkji\",targetWord = \"jjjjjj\") == False\n assert candidate(firstWord = \"ijijij\",secondWord = \"ijijij\",targetWord = \"jjjjjjjj\") == False\n assert candidate(firstWord = \"hjihj\",secondWord = \"ihjih\",targetWord = \"jjjjj\") == False\n assert candidate(firstWord = \"aabbcc\",secondWord = \"ddeeff\",targetWord = \"gggggh\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"abcdefgh\",targetWord = \"hhhhhhhh\") == False\n assert candidate(firstWord = \"babababa\",secondWord = \"babababa\",targetWord = \"cacacaca\") == True\n assert candidate(firstWord = \"aaa\",secondWord = \"bbb\",targetWord = \"ccc\") == False\n assert candidate(firstWord = \"iiii\",secondWord = \"jjjj\",targetWord = \"jjjjjjjj\") == False\n assert candidate(firstWord = \"abcdefghi\",secondWord = \"j\",targetWord = \"abcdefghij\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghi\",targetWord = \"jjjjjjjjj\") == False\n assert candidate(firstWord = \"abcdefghijabcdefghij\",secondWord = \"abcdefghijabcdefghij\",targetWord = \"jjjjjjjjjjjjjjjjjjjj\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"hgfedcba\",targetWord = \"aaaaaaaaaa\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"hgfedcba\",targetWord = \"abcdefghhgfedcba\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"abcdefgh\",targetWord = \"ggggggggg\") == False\n assert candidate(firstWord = \"abc\",secondWord = \"def\",targetWord = \"defabc\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghi\",targetWord = \"abcdefghijj\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"abcdefgh\",targetWord = \"aaaaaaaaaaaaaaaa\") == False\n assert candidate(firstWord = \"aabbccddeeff\",secondWord = \"ffeeddccbbaa\",targetWord = \"feebbaaccdd\") == False\n assert candidate(firstWord = \"a\",secondWord = \"b\",targetWord = \"c\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"hgfedcba\",targetWord = \"jjjjjjjj\") == False\n assert candidate(firstWord = \"abcd\",secondWord = \"efgh\",targetWord = \"ijkl\") == False\n assert candidate(firstWord = \"jjjjj\",secondWord = \"jjjjj\",targetWord = \"jjjjjjj\") == False\n assert candidate(firstWord = \"aaaaaaaa\",secondWord = \"bbbbbbbb\",targetWord = \"cccccccc\") == False\n assert candidate(firstWord = \"aabbccdd\",secondWord = \"dccbbaaa\",targetWord = \"dddddddd\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"iiiiiiiiii\") == False\n assert candidate(firstWord = \"abcabcabc\",secondWord = \"cbacbacba\",targetWord = \"bbbcccbbb\") == False\n assert candidate(firstWord = \"iiii\",secondWord = \"jjjj\",targetWord = \"jjjjjj\") == False\n assert candidate(firstWord = \"abcdefghi\",secondWord = \"abcdefghj\",targetWord = \"jjjjjjjjj\") == False\n assert candidate(firstWord = \"ijijijijij\",secondWord = \"jijijijiji\",targetWord = \"jjjjjjjjjjj\") == False\n assert candidate(firstWord = \"abcde\",secondWord = \"edcba\",targetWord = \"abcdeedcba\") == False\n assert candidate(firstWord = \"ijijijij\",secondWord = \"hghghghg\",targetWord = \"gggggggg\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghija\",targetWord = \"jjjjjjjjjjj\") == False\n assert candidate(firstWord = \"jijij\",secondWord = \"ijiji\",targetWord = \"jjjjjjj\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"abcdefghijabcdefghij\") == False\n assert candidate(firstWord = \"ijijij\",secondWord = \"jijiji\",targetWord = \"jjjjjjjjjjjj\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"aaaaaaaaaab\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"hgfedcba\",targetWord = \"abcdefghij\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"aaaaaaaaaabbbbbbbbbb\") == False\n assert candidate(firstWord = \"abcdefghi\",secondWord = \"hgfedcba\",targetWord = \"jjjjjjjjj\") == False\n assert candidate(firstWord = \"jihgfedcba\",secondWord = \"abcdefghij\",targetWord = \"jjjjjjjjjj\") == True\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"ijijijijij\") == False\n assert candidate(firstWord = \"jijijijijij\",secondWord = \"jijijijijij\",targetWord = \"jjjjjjjjjjjjjjjjjjj\") == False\n assert candidate(firstWord = \"aabbccddeeffgg\",secondWord = \"hhiijjkkllmm\",targetWord = \"jjjjjjjjjjjj\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"aaaaaaaaaaab\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"hgfedcba\",targetWord = \"jjjjjjj\") == False\n assert candidate(firstWord = \"abcde\",secondWord = \"edcba\",targetWord = \"jjjjj\") == False\n assert candidate(firstWord = \"hgfedcba\",secondWord = \"abcdefgh\",targetWord = \"iiiiiiii\") == False\n assert candidate(firstWord = \"jijij\",secondWord = \"ijiji\",targetWord = \"jjjjj\") == False\n assert candidate(firstWord = \"j\",secondWord = \"ij\",targetWord = \"ji\") == True\n assert candidate(firstWord = \"aabbccdd\",secondWord = \"ddeeffgg\",targetWord = \"hhiijjkk\") == False\n assert candidate(firstWord = \"jij\",secondWord = \"iji\",targetWord = \"jjjj\") == False\n"}, "metadata": {"canonical_parameter_names": ["firstWord", "secondWord", "targetWord"], "leetcode_dataset_entry_point": "Solution().isSumEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:", "container": "Solution", "callable": "isSumEqual", "parameters": [{"name": "firstWord", "type": "str"}, {"name": "secondWord", "type": "str"}, {"name": "targetWord", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1881, "task_id": "maximum-value-after-insertion", "difficulty": "Medium", "problem_description": "You are given a very large integer n, represented as a string,​​​​​​ and an integer digit x. The digits in n and the digit x are in the inclusive range [1, 9], and n may represent a negative number.\nYou want to maximize n's numerical value by inserting x anywhere in the decimal representation of n​​​​​​. You cannot insert x to the left of the negative sign.\n\nFor example, if n = 73 and x = 6, it would be best to insert it between 7 and 3, making n = 763.\nIf n = -55 and x = 2, it would be best to insert it before the first 5, making n = -255.\n\nReturn a string representing the maximum value of n​​​​​​ after the insertion.\n \nExample 1:\n\nInput: n = \"99\", x = 9\nOutput: \"999\"\nExplanation: The result is the same regardless of where you insert 9.\n\nExample 2:\n\nInput: n = \"-13\", x = 2\nOutput: \"-123\"\nExplanation: You can make n one of {-213, -123, -132}, and the largest of those three is -123.\n\n \nConstraints:\n\n1 <= n.length <= 105\n1 <= x <= 9\nThe digits in n​​​ are in the range [1, 9].\nn is a valid representation of an integer.\nIn the case of a negative n,​​​​​​ it will begin with '-'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = \"5486\",x = 7) == \"75486\"\n assert candidate(n = \"-11111\",x = 1) == \"-111111\"\n assert candidate(n = \"-123456789\",x = 5) == \"-1234556789\"\n assert candidate(n = \"987654321\",x = 5) == \"9876554321\"\n assert candidate(n = \"-98765\",x = 3) == \"-398765\"\n assert candidate(n = \"-1000\",x = 1) == \"-10001\"\n assert candidate(n = \"-987654321\",x = 5) == \"-5987654321\"\n assert candidate(n = \"-54321\",x = 4) == \"-454321\"\n assert candidate(n = \"123456789\",x = 5) == \"5123456789\"\n assert candidate(n = \"5\",x = 9) == \"95\"\n assert candidate(n = \"-1000\",x = 5) == \"-10005\"\n assert candidate(n = \"1000\",x = 1) == \"11000\"\n assert candidate(n = \"54321\",x = 6) == \"654321\"\n assert candidate(n = \"12345\",x = 3) == \"312345\"\n assert candidate(n = \"1000\",x = 5) == \"51000\"\n assert candidate(n = \"-973\",x = 8) == \"-8973\"\n assert candidate(n = \"-13\",x = 2) == \"-123\"\n assert candidate(n = \"54823\",x = 7) == \"754823\"\n assert candidate(n = \"1\",x = 1) == \"11\"\n assert candidate(n = \"99\",x = 9) == \"999\"\n assert candidate(n = \"-64823\",x = 7) == \"-647823\"\n assert candidate(n = \"567\",x = 8) == \"8567\"\n assert candidate(n = \"-9\",x = 1) == \"-19\"\n assert candidate(n = \"-9\",x = 9) == \"-99\"\n assert candidate(n = \"54893\",x = 7) == \"754893\"\n assert candidate(n = \"-987\",x = 7) == \"-7987\"\n assert candidate(n = \"-222222222\",x = 2) == \"-2222222222\"\n assert candidate(n = \"1234567890\",x = 0) == \"12345678900\"\n assert candidate(n = \"-1\",x = 1) == \"-11\"\n assert candidate(n = \"1000000000\",x = 9) == \"91000000000\"\n assert candidate(n = \"123123123\",x = 3) == \"3123123123\"\n assert candidate(n = \"-101010101\",x = 5) == \"-1010101015\"\n assert candidate(n = \"999999999\",x = 1) == \"9999999991\"\n assert candidate(n = \"500000000\",x = 5) == \"5500000000\"\n assert candidate(n = \"555555555\",x = 5) == \"5555555555\"\n assert candidate(n = \"-595959595\",x = 5) == \"-5595959595\"\n assert candidate(n = \"-123456789\",x = 3) == \"-1233456789\"\n assert candidate(n = \"222222222\",x = 1) == \"2222222221\"\n assert candidate(n = \"876543210\",x = 0) == \"8765432100\"\n assert candidate(n = \"192837465\",x = 4) == \"4192837465\"\n assert candidate(n = \"-900000000\",x = 1) == \"-1900000000\"\n assert candidate(n = \"-999999999\",x = 9) == \"-9999999999\"\n assert candidate(n = \"-9876543210\",x = 1) == \"-19876543210\"\n assert candidate(n = \"-100000000\",x = 0) == \"-0100000000\"\n assert candidate(n = \"9876543210\",x = 9) == \"99876543210\"\n assert candidate(n = \"-5432109876\",x = 9) == \"-54321098769\"\n assert candidate(n = \"-123456789\",x = 4) == \"-1234456789\"\n assert candidate(n = \"-199999999\",x = 9) == \"-1999999999\"\n assert candidate(n = \"-101010101\",x = 0) == \"-0101010101\"\n assert candidate(n = \"-123123123\",x = 5) == \"-1231231235\"\n assert candidate(n = \"199999999\",x = 9) == \"9199999999\"\n assert candidate(n = \"123456789\",x = 9) == \"9123456789\"\n assert candidate(n = \"111111111\",x = 2) == \"2111111111\"\n assert candidate(n = \"53284769\",x = 5) == \"553284769\"\n assert candidate(n = \"9876543210\",x = 8) == \"98876543210\"\n assert candidate(n = \"1999999999\",x = 0) == \"19999999990\"\n assert candidate(n = \"9\",x = 1) == \"91\"\n assert candidate(n = \"987654321\",x = 9) == \"9987654321\"\n assert candidate(n = \"111000111\",x = 1) == \"1111000111\"\n assert candidate(n = \"-1000000000\",x = 9) == \"-10000000009\"\n assert candidate(n = \"-123456789\",x = 1) == \"-1123456789\"\n assert candidate(n = \"54321\",x = 3) == \"543321\"\n assert candidate(n = \"-9999999999\",x = 5) == \"-59999999999\"\n assert candidate(n = \"505050505\",x = 5) == \"5505050505\"\n assert candidate(n = \"121212121\",x = 3) == \"3121212121\"\n assert candidate(n = \"123454321\",x = 5) == \"5123454321\"\n assert candidate(n = \"333333333\",x = 3) == \"3333333333\"\n assert candidate(n = \"987654321\",x = 8) == \"9887654321\"\n assert candidate(n = \"11111111111111111111\",x = 2) == \"211111111111111111111\"\n assert candidate(n = \"-987654321\",x = 1) == \"-1987654321\"\n assert candidate(n = \"-500000000\",x = 5) == \"-5000000005\"\n assert candidate(n = \"-53284769\",x = 5) == \"-532584769\"\n assert candidate(n = \"101010101\",x = 5) == \"5101010101\"\n assert candidate(n = \"-9876543210\",x = 5) == \"-59876543210\"\n assert candidate(n = \"666666666\",x = 5) == \"6666666665\"\n assert candidate(n = \"111111111\",x = 1) == \"1111111111\"\n assert candidate(n = \"12345678901234567890\",x = 5) == \"512345678901234567890\"\n assert candidate(n = \"987654321\",x = 6) == \"9876654321\"\n assert candidate(n = \"-123456789\",x = 9) == \"-1234567899\"\n assert candidate(n = \"123456789\",x = 1) == \"1234567891\"\n assert candidate(n = \"-555555555\",x = 6) == \"-5555555556\"\n assert candidate(n = \"-333333333\",x = 2) == \"-2333333333\"\n assert candidate(n = \"595959595\",x = 9) == \"9595959595\"\n assert candidate(n = \"-54321\",x = 6) == \"-543216\"\n assert candidate(n = \"987654321\",x = 7) == \"9877654321\"\n assert candidate(n = \"9\",x = 9) == \"99\"\n assert candidate(n = \"-86420\",x = 1) == \"-186420\"\n assert candidate(n = \"-111111111\",x = 9) == \"-1111111119\"\n assert candidate(n = \"-54321\",x = 3) == \"-354321\"\n assert candidate(n = \"-505050505\",x = 5) == \"-5050505055\"\n assert candidate(n = \"-1000000001\",x = 0) == \"-01000000001\"\n assert candidate(n = \"100000000\",x = 9) == \"9100000000\"\n assert candidate(n = \"-9876543210987654321\",x = 9) == \"-98765432109876543219\"\n assert candidate(n = \"333333333\",x = 4) == \"4333333333\"\n assert candidate(n = \"-2222222222\",x = 1) == \"-12222222222\"\n assert candidate(n = \"122222222\",x = 2) == \"2122222222\"\n assert candidate(n = \"123456789\",x = 3) == \"3123456789\"\n assert candidate(n = \"-321321321\",x = 2) == \"-2321321321\"\n assert candidate(n = \"1122334455\",x = 6) == \"61122334455\"\n assert candidate(n = \"123456789\",x = 6) == \"6123456789\"\n assert candidate(n = \"1111111111\",x = 1) == \"11111111111\"\n assert candidate(n = \"-999999999\",x = 1) == \"-1999999999\"\n assert candidate(n = \"-333333333\",x = 3) == \"-3333333333\"\n assert candidate(n = \"-1122334455\",x = 3) == \"-11223334455\"\n assert candidate(n = \"-9876543210\",x = 8) == \"-89876543210\"\n assert candidate(n = \"98765432109876543210\",x = 5) == \"987655432109876543210\"\n assert candidate(n = \"123456789\",x = 0) == \"1234567890\"\n assert candidate(n = \"-12345678901234567890\",x = 5) == \"-123455678901234567890\"\n assert candidate(n = \"1\",x = 9) == \"91\"\n assert candidate(n = \"-2000000000\",x = 1) == \"-12000000000\"\n assert candidate(n = \"11111\",x = 1) == \"111111\"\n assert candidate(n = \"100000000\",x = 1) == \"1100000000\"\n assert candidate(n = \"1234567890\",x = 5) == \"51234567890\"\n assert candidate(n = \"-999000999\",x = 9) == \"-9990009999\"\n assert candidate(n = \"1111111111\",x = 2) == \"21111111111\"\n assert candidate(n = \"-876543210\",x = 0) == \"-0876543210\"\n assert candidate(n = \"-99999\",x = 1) == \"-199999\"\n assert candidate(n = \"-10000\",x = 0) == \"-010000\"\n assert candidate(n = \"555555555\",x = 6) == \"6555555555\"\n assert candidate(n = \"-98765432109876543210\",x = 5) == \"-598765432109876543210\"\n assert candidate(n = \"1999999999\",x = 2) == \"21999999999\"\n assert candidate(n = \"123123123\",x = 4) == \"4123123123\"\n assert candidate(n = \"86420\",x = 9) == \"986420\"\n assert candidate(n = \"-1\",x = 9) == \"-19\"\n assert candidate(n = \"-1000000000\",x = 1) == \"-10000000001\"\n assert candidate(n = \"989898989\",x = 7) == \"9898989897\"\n assert candidate(n = \"-222222222\",x = 3) == \"-2222222223\"\n assert candidate(n = \"192837465\",x = 8) == \"8192837465\"\n assert candidate(n = \"33333\",x = 3) == \"333333\"\n assert candidate(n = \"1000000000\",x = 1) == \"11000000000\"\n assert candidate(n = \"123456789\",x = 4) == \"4123456789\"\n assert candidate(n = \"-123456789\",x = 8) == \"-1234567889\"\n assert candidate(n = \"999999999\",x = 9) == \"9999999999\"\n"}, "metadata": {"canonical_parameter_names": ["n", "x"], "leetcode_dataset_entry_point": "Solution().maxValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxValue(self, n: str, x: int) -> str:", "container": "Solution", "callable": "maxValue", "parameters": [{"name": "n", "type": "str"}, {"name": "x", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1882, "task_id": "process-tasks-using-servers", "difficulty": "Medium", "problem_description": "You are given two 0-indexed integer arrays servers and tasks of lengths n​​​​​​ and m​​​​​​ respectively. servers[i] is the weight of the i​​​​​​th​​​​ server, and tasks[j] is the time needed to process the j​​​​​​th​​​​ task in seconds.\nTasks are assigned to the servers using a task queue. Initially, all servers are free, and the queue is empty.\nAt second j, the jth task is inserted into the queue (starting with the 0th task being inserted at second 0). As long as there are free servers and the queue is not empty, the task in the front of the queue will be assigned to a free server with the smallest weight, and in case of a tie, it is assigned to a free server with the smallest index.\nIf there are no free servers and the queue is not empty, we wait until a server becomes free and immediately assign the next task. If multiple servers become free at the same time, then multiple tasks from the queue will be assigned in order of insertion following the weight and index priorities above.\nA server that is assigned task j at second t will be free again at second t + tasks[j].\nBuild an array ans​​​​ of length m, where ans[j] is the index of the server the j​​​​​​th task will be assigned to.\nReturn the array ans​​​​.\n \nExample 1:\n\nInput: servers = [3,3,2], tasks = [1,2,3,2,1,2]\nOutput: [2,2,0,2,1,2]\nExplanation: Events in chronological order go as follows:\n- At second 0, task 0 is added and processed using server 2 until second 1.\n- At second 1, server 2 becomes free. Task 1 is added and processed using server 2 until second 3.\n- At second 2, task 2 is added and processed using server 0 until second 5.\n- At second 3, server 2 becomes free. Task 3 is added and processed using server 2 until second 5.\n- At second 4, task 4 is added and processed using server 1 until second 5.\n- At second 5, all servers become free. Task 5 is added and processed using server 2 until second 7.\nExample 2:\n\nInput: servers = [5,1,4,3,2], tasks = [2,1,2,4,5,2,1]\nOutput: [1,4,1,4,1,3,2]\nExplanation: Events in chronological order go as follows: \n- At second 0, task 0 is added and processed using server 1 until second 2.\n- At second 1, task 1 is added and processed using server 4 until second 2.\n- At second 2, servers 1 and 4 become free. Task 2 is added and processed using server 1 until second 4. \n- At second 3, task 3 is added and processed using server 4 until second 7.\n- At second 4, server 1 becomes free. Task 4 is added and processed using server 1 until second 9. \n- At second 5, task 5 is added and processed using server 3 until second 7.\n- At second 6, task 6 is added and processed using server 2 until second 7.\n\n \nConstraints:\n\nservers.length == n\ntasks.length == m\n1 <= n, m <= 2 * 105\n1 <= servers[i], tasks[j] <= 2 * 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(servers = [3, 3, 2],tasks = [1, 2, 3, 2, 1, 2]) == [2, 2, 0, 2, 1, 2]\n assert candidate(servers = [1, 1, 1],tasks = [10, 20, 30, 40, 50]) == [0, 1, 2, 0, 1]\n assert candidate(servers = [5, 1, 4, 3, 2],tasks = [2, 1, 2, 4, 5, 2, 1]) == [1, 4, 1, 4, 1, 3, 2]\n assert candidate(servers = [2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1],tasks = [10]) == [0]\n assert candidate(servers = [10, 20, 30],tasks = [3, 2, 1]) == [0, 1, 2]\n assert candidate(servers = [1, 2, 3],tasks = [3, 2, 1]) == [0, 1, 2]\n assert candidate(servers = [1, 2, 3, 4, 5],tasks = [5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4]\n assert candidate(servers = [10, 20, 30],tasks = [1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0]\n assert candidate(servers = [5, 4, 3, 2, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [4, 4, 3, 4, 2, 3, 1, 4, 0, 2]\n assert candidate(servers = [10, 20, 30],tasks = [1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0]\n assert candidate(servers = [2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 1, 1],tasks = [10, 10, 10, 10, 10]) == [0, 1, 2, 0, 1]\n assert candidate(servers = [1, 2, 3, 4, 5],tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7]\n assert candidate(servers = [5, 4, 3, 2, 1],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 5, 1, 3, 0, 5, 1, 4, 2, 3, 0, 3, 0, 5, 1, 3, 0, 4, 2]\n assert candidate(servers = [10, 15, 20, 25, 30],tasks = [5, 10, 15, 20, 25, 30, 35, 40]) == [0, 1, 2, 3, 4, 0, 1, 2]\n assert candidate(servers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [5, 15, 25, 35, 45, 55, 65]) == [0, 1, 2, 3, 4, 0, 1]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [1, 1, 1, 1, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],tasks = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 3, 6, 0, 9, 2, 4, 8, 10, 7, 5]\n assert candidate(servers = [3, 1, 2],tasks = [2, 3, 1, 2, 1, 3, 2, 1, 2, 3, 1, 2, 3]) == [1, 2, 1, 1, 2, 1, 2, 0, 1, 2, 1, 1, 2]\n assert candidate(servers = [3, 5, 2, 7, 6],tasks = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 0, 2, 1, 0, 4, 2, 3, 1]\n assert candidate(servers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(servers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],tasks = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 8, 9, 8, 9, 7, 8]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(servers = [5, 4, 3, 2, 1],tasks = [2, 3, 4, 5, 1, 2, 3, 4, 5]) == [4, 3, 4, 2, 3, 3, 4, 3, 2]\n assert candidate(servers = [100, 200, 150, 50],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2]\n assert candidate(servers = [100, 100, 100, 100, 100],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [20, 10, 30, 40, 50],tasks = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [1, 0, 2, 3, 4, 1, 0, 2, 3, 4]\n assert candidate(servers = [2, 3, 1, 4, 5, 2, 3, 1, 4, 5],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 7, 0, 5, 1, 6, 3, 8, 4, 9, 2, 7, 0, 5, 1, 6, 3, 8, 4, 9]\n assert candidate(servers = [15, 25, 5, 20, 10],tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [2, 4, 0, 3, 1, 2, 4, 0, 3, 1, 2, 4, 0, 3, 1, 2, 4, 0, 3, 1]\n assert candidate(servers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [2, 3, 5, 7, 11],tasks = [30, 10, 20, 40, 50, 15, 25, 35, 45, 55]) == [0, 1, 2, 3, 4, 1, 2, 1, 0, 3]\n assert candidate(servers = [7, 5, 3, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 3, 2, 3, 1, 2, 0, 3, 1, 2, 0, 3, 1, 2, 0]\n assert candidate(servers = [5, 3, 8, 6],tasks = [2, 6, 4, 1, 7, 3, 5]) == [1, 0, 1, 3, 3, 2, 1]\n assert candidate(servers = [3, 2, 1, 4, 5],tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [2, 1, 0, 3, 4, 2, 1, 0, 3, 4, 2, 1, 0, 3, 4]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [5, 3, 8, 6, 2],tasks = [2, 4, 1, 5, 7, 3, 6, 8, 9, 10]) == [4, 1, 4, 4, 0, 1, 3, 2, 4, 1]\n assert candidate(servers = [5, 1, 4, 3, 2, 6],tasks = [2, 1, 2, 4, 5, 2, 1, 3, 5, 7, 9, 11, 13, 15]) == [1, 4, 1, 4, 1, 3, 2, 4, 3, 1, 4, 2, 0, 3]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [7, 1, 1, 1, 1, 1],tasks = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]\n assert candidate(servers = [23, 45, 12, 67, 89, 34, 56, 78, 90, 10],tasks = [30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == [9, 2, 0, 5, 1, 6, 3, 7, 4, 8]\n assert candidate(servers = [100, 200, 300, 400, 500],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [3, 3, 3, 3, 3],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [100, 200, 300, 400, 500],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [3, 3, 3, 3, 3],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [10, 10, 10, 10],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0]\n assert candidate(servers = [100, 200, 300, 400, 500],tasks = [500, 400, 300, 200, 100, 500, 400, 300, 200, 100]) == [0, 1, 2, 3, 4, 4, 3, 2, 1, 0]\n assert candidate(servers = [2, 1, 3, 4],tasks = [4, 3, 2, 1, 5, 6, 7, 8, 9, 10]) == [1, 0, 2, 3, 1, 0, 2, 3, 1, 0]\n assert candidate(servers = [7, 8, 9, 10],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 0, 1, 2, 3, 3, 2]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [5, 5, 5, 5, 5],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [3, 5, 1, 4, 2],tasks = [15, 10, 5, 20, 25, 30, 5, 10, 15, 20]) == [2, 4, 0, 3, 1, 0, 4, 2, 4, 3]\n assert candidate(servers = [7, 8, 9, 10, 11],tasks = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 4]\n assert candidate(servers = [1, 10, 1, 10, 1, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 1, 1, 1, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [5, 10, 15, 20, 25],tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7]\n assert candidate(servers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],tasks = [29, 23, 19, 17, 13, 11, 7, 5, 3, 2]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [3, 2, 1, 4, 5],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [2, 1, 0, 3, 4, 2, 1, 0, 3, 4, 2, 1, 0, 3, 4]\n assert candidate(servers = [5, 3, 8, 6, 2],tasks = [2, 5, 7, 4, 9, 1, 3, 6, 8, 10]) == [4, 1, 4, 0, 3, 2, 1, 0, 2, 4]\n assert candidate(servers = [7, 11, 13, 17, 19, 23, 29],tasks = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == [0, 1, 0, 2, 1, 3, 4, 0, 5, 6, 2, 1, 3, 4, 0, 5, 6, 2, 1, 3]\n assert candidate(servers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [9, 9, 8, 9, 7, 8, 6, 9, 5, 7]\n assert candidate(servers = [1, 2, 3, 4, 5],tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [3, 2, 1],tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [2, 1, 0, 2, 1, 0, 2, 1, 0, 2]\n assert candidate(servers = [10, 20, 15, 25, 30],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 2, 0, 1, 2, 3, 0, 4, 1, 2, 3, 0, 4, 1]\n assert candidate(servers = [5, 3, 8, 6, 2],tasks = [4, 3, 6, 2, 5, 4, 3, 7]) == [4, 1, 0, 3, 4, 1, 3, 2]\n assert candidate(servers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [100, 200, 300, 400, 500],tasks = [500, 400, 300, 200, 100, 500, 400, 300, 200, 100]) == [0, 1, 2, 3, 4, 4, 3, 2, 1, 0]\n assert candidate(servers = [10, 5, 8, 3],tasks = [2, 8, 10, 3, 5, 7, 6, 4]) == [3, 1, 3, 2, 0, 2, 1, 0]\n assert candidate(servers = [5, 3, 7, 1, 4],tasks = [10, 5, 3, 8, 2, 1, 9, 6]) == [3, 1, 4, 0, 2, 4, 1, 4]\n assert candidate(servers = [1, 1, 1, 1, 1],tasks = [2, 3, 2, 4, 5, 2, 3, 1, 4, 5]) == [0, 1, 0, 2, 0, 1, 3, 1, 1, 0]\n assert candidate(servers = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [5, 5, 5, 5, 5],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [7, 7, 7, 7, 7],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [15, 10, 20, 5, 25],tasks = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]) == [3, 1, 0, 3, 2, 4, 1, 0, 3, 2, 4, 1, 0, 3]\n assert candidate(servers = [1, 2, 3, 4, 5],tasks = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 0, 1, 0, 2, 1, 1, 0, 1, 2]\n assert candidate(servers = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [1, 3, 5, 7, 9, 1, 3, 5, 7, 9]\n assert candidate(servers = [2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [1, 3, 2],tasks = [3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1]) == [0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [10, 1, 10, 1, 10, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 3, 1, 5, 3, 0, 1, 2, 5, 4, 3, 0, 1, 2]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [50, 25, 75, 100, 125],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [1, 0, 2, 3, 4, 1, 0, 2, 3, 4, 1, 0, 2, 3, 4]\n assert candidate(servers = [2, 4, 6, 8, 10],tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [0, 0, 1, 2, 0, 3, 4, 1, 2, 0]\n assert candidate(servers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],tasks = [97, 89, 83, 79, 73, 71, 67, 61, 59, 53, 47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 23]\n assert candidate(servers = [1, 1, 1, 1, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],tasks = [8, 9, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 3, 6, 0, 9, 2, 4, 8, 1, 1, 1, 3, 6, 0, 9, 2, 4, 8, 10, 7]\n"}, "metadata": {"canonical_parameter_names": ["servers", "tasks"], "leetcode_dataset_entry_point": "Solution().assignTasks", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def assignTasks(self, servers: list[int], tasks: list[int]) -> list[int]:", "container": "Solution", "callable": "assignTasks", "parameters": [{"name": "servers", "type": "list[int]"}, {"name": "tasks", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1883, "task_id": "minimum-skips-to-arrive-at-meeting-on-time", "difficulty": "Hard", "problem_description": "You are given an integer hoursBefore, the number of hours you have to travel to your meeting. To arrive at your meeting, you have to travel through n roads. The road lengths are given as an integer array dist of length n, where dist[i] describes the length of the ith road in kilometers. In addition, you are given an integer speed, which is the speed (in km/h) you will travel at.\nAfter you travel road i, you must rest and wait for the next integer hour before you can begin traveling on the next road. Note that you do not have to rest after traveling the last road because you are already at the meeting.\n\nFor example, if traveling a road takes 1.4 hours, you must wait until the 2 hour mark before traveling the next road. If traveling a road takes exactly 2 hours, you do not need to wait.\n\nHowever, you are allowed to skip some rests to be able to arrive on time, meaning you do not need to wait for the next integer hour. Note that this means you may finish traveling future roads at different hour marks.\n\nFor example, suppose traveling the first road takes 1.4 hours and traveling the second road takes 0.6 hours. Skipping the rest after the first road will mean you finish traveling the second road right at the 2 hour mark, letting you start traveling the third road immediately.\n\nReturn the minimum number of skips required to arrive at the meeting on time, or -1 if it is impossible.\n \nExample 1:\n\nInput: dist = [1,3,2], speed = 4, hoursBefore = 2\nOutput: 1\nExplanation:\nWithout skipping any rests, you will arrive in (1/4 + 3/4) + (3/4 + 1/4) + (2/4) = 2.5 hours.\nYou can skip the first rest to arrive in ((1/4 + 0) + (3/4 + 0)) + (2/4) = 1.5 hours.\nNote that the second rest is shortened because you finish traveling the second road at an integer hour due to skipping the first rest.\n\nExample 2:\n\nInput: dist = [7,3,5,5], speed = 2, hoursBefore = 10\nOutput: 2\nExplanation:\nWithout skipping any rests, you will arrive in (7/2 + 1/2) + (3/2 + 1/2) + (5/2 + 1/2) + (5/2) = 11.5 hours.\nYou can skip the first and third rest to arrive in ((7/2 + 0) + (3/2 + 0)) + ((5/2 + 0) + (5/2)) = 10 hours.\n\nExample 3:\n\nInput: dist = [7,3,5,5], speed = 1, hoursBefore = 10\nOutput: -1\nExplanation: It is impossible to arrive at the meeting on time even if you skip all the rests.\n\n \nConstraints:\n\nn == dist.length\n1 <= n <= 1000\n1 <= dist[i] <= 105\n1 <= speed <= 106\n1 <= hoursBefore <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(dist = [10, 10, 10],speed = 5,hoursBefore = 6) == 0\n assert candidate(dist = [1, 1, 1, 1, 1],speed = 1,hoursBefore = 3) == -1\n assert candidate(dist = [5, 5, 5, 5, 5],speed = 10,hoursBefore = 2) == -1\n assert candidate(dist = [1, 1, 1, 1],speed = 1,hoursBefore = 4) == 0\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 10) == 0\n assert candidate(dist = [7, 3, 5, 5],speed = 1,hoursBefore = 10) == -1\n assert candidate(dist = [1, 2, 3, 4, 5],speed = 1,hoursBefore = 20) == 0\n assert candidate(dist = [1, 1, 1, 1, 1],speed = 1,hoursBefore = 4) == -1\n assert candidate(dist = [10, 10, 10],speed = 10,hoursBefore = 3) == 0\n assert candidate(dist = [5, 5, 5, 5, 5],speed = 5,hoursBefore = 5) == 0\n assert candidate(dist = [1, 1, 1, 1],speed = 1,hoursBefore = 3) == -1\n assert candidate(dist = [7, 3, 5, 5],speed = 2,hoursBefore = 10) == 2\n assert candidate(dist = [1, 3, 2],speed = 4,hoursBefore = 2) == 1\n assert candidate(dist = [100000, 100000, 100000],speed = 100000,hoursBefore = 3) == 0\n assert candidate(dist = [10, 10, 10],speed = 5,hoursBefore = 5) == -1\n assert candidate(dist = [5, 5, 5, 5, 5],speed = 10,hoursBefore = 3) == 2\n assert candidate(dist = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],speed = 2,hoursBefore = 15) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],speed = 15,hoursBefore = 15) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 1000,hoursBefore = 5) == -1\n assert candidate(dist = [7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5],speed = 2,hoursBefore = 100) == -1\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],speed = 2,hoursBefore = 10) == -1\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],speed = 10000,hoursBefore = 99) == -1\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],speed = 5,hoursBefore = 20) == 8\n assert candidate(dist = [10, 20, 30, 40, 50],speed = 25,hoursBefore = 10) == 0\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],speed = 5,hoursBefore = 50) == -1\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],speed = 100000,hoursBefore = 9) == -1\n assert candidate(dist = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],speed = 10,hoursBefore = 40) == -1\n assert candidate(dist = [1, 2, 3, 4, 5],speed = 100,hoursBefore = 1) == 4\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 3,hoursBefore = 100) == -1\n assert candidate(dist = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],speed = 100,hoursBefore = 20) == 7\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],speed = 2,hoursBefore = 100) == -1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = 5,hoursBefore = 30) == 0\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],speed = 1,hoursBefore = 50) == -1\n assert candidate(dist = [10, 21, 30, 40, 50, 60, 70, 80, 90, 100],speed = 10,hoursBefore = 55) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = 2,hoursBefore = 50) == -1\n assert candidate(dist = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],speed = 100000,hoursBefore = 9) == -1\n assert candidate(dist = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],speed = 5,hoursBefore = 20) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 5,hoursBefore = 35) == -1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = 15,hoursBefore = 15) == 0\n assert candidate(dist = [100, 200, 300, 400, 500],speed = 100,hoursBefore = 10) == -1\n assert candidate(dist = [123, 456, 789, 101, 202, 303],speed = 100,hoursBefore = 15) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 29) == -1\n assert candidate(dist = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1],speed = 4,hoursBefore = 5) == 6\n assert candidate(dist = [3, 6, 9, 12, 15, 18, 21],speed = 5,hoursBefore = 15) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 3,hoursBefore = 12) == -1\n assert candidate(dist = [5, 10, 15, 20, 25],speed = 5,hoursBefore = 10) == -1\n assert candidate(dist = [9, 8, 7, 6, 5, 4, 3, 2, 1],speed = 3,hoursBefore = 10) == -1\n assert candidate(dist = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],speed = 100,hoursBefore = 9) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 15) == -1\n assert candidate(dist = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],speed = 2,hoursBefore = 30) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = 1,hoursBefore = 105) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 20) == 0\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 19) == -1\n assert candidate(dist = [7, 3, 5, 5, 3, 7, 5, 3, 5, 5, 3, 7, 5, 3, 5, 5, 3, 7, 5, 3, 5, 5, 3, 7, 5, 3, 5, 5, 3, 7, 5, 3, 5, 5],speed = 2,hoursBefore = 50) == -1\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],speed = 10,hoursBefore = 6) == 4\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 100) == -1\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],speed = 2,hoursBefore = 15) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],speed = 100,hoursBefore = 60) == -1\n assert candidate(dist = [7, 3, 5, 5, 7, 3, 5, 5],speed = 2,hoursBefore = 15) == -1\n assert candidate(dist = [100, 200, 300, 400],speed = 100,hoursBefore = 8) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 5,hoursBefore = 12) == 4\n assert candidate(dist = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980],speed = 99999,hoursBefore = 10) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = 3,hoursBefore = 20) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 1,hoursBefore = 1000) == 0\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 25,hoursBefore = 20) == -1\n assert candidate(dist = [9, 7, 5, 3, 1],speed = 4,hoursBefore = 5) == -1\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],speed = 7,hoursBefore = 25) == -1\n assert candidate(dist = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],speed = 10,hoursBefore = 13) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 25) == -1\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35],speed = 7,hoursBefore = 20) == 5\n assert candidate(dist = [10000, 20000, 30000, 40000, 50000],speed = 10000,hoursBefore = 15) == 0\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 15,hoursBefore = 30) == -1\n assert candidate(dist = [3, 8, 2, 7, 5],speed = 4,hoursBefore = 10) == 0\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 100,hoursBefore = 50) == -1\n assert candidate(dist = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],speed = 100000,hoursBefore = 5) == 5\n assert candidate(dist = [9, 8, 7, 6, 5, 4, 3, 2, 1],speed = 5,hoursBefore = 15) == 0\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],speed = 3,hoursBefore = 30) == 0\n assert candidate(dist = [1, 3, 2, 4, 5],speed = 3,hoursBefore = 5) == 3\n assert candidate(dist = [999, 1000, 1001, 1002, 1003],speed = 1,hoursBefore = 5000) == -1\n assert candidate(dist = [100000, 100000, 100000, 100000],speed = 100000,hoursBefore = 4) == 0\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000],speed = 100000,hoursBefore = 4) == -1\n assert candidate(dist = [1000, 2000, 3000, 4000],speed = 1000,hoursBefore = 10) == 0\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000],speed = 100000,hoursBefore = 5) == 0\n assert candidate(dist = [100000, 90000, 80000, 70000, 60000],speed = 50000,hoursBefore = 10) == 0\n assert candidate(dist = [10, 20, 30, 40, 50],speed = 15,hoursBefore = 12) == 0\n assert candidate(dist = [100000, 100000, 100000],speed = 100000,hoursBefore = 2) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 15,hoursBefore = 25) == -1\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],speed = 1,hoursBefore = 100) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 50,hoursBefore = 35) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 100,hoursBefore = 30) == -1\n assert candidate(dist = [5, 10, 15, 20, 25],speed = 5,hoursBefore = 15) == 0\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],speed = 3,hoursBefore = 25) == 0\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 100,hoursBefore = 45) == -1\n assert candidate(dist = [99999, 99998, 99997, 99996],speed = 100000,hoursBefore = 399990) == 0\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 10) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],speed = 5,hoursBefore = 25) == -1\n assert candidate(dist = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],speed = 9,hoursBefore = 8) == -1\n assert candidate(dist = [50, 100, 150, 200, 250],speed = 50,hoursBefore = 10) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 10,hoursBefore = 5) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],speed = 3,hoursBefore = 25) == -1\n assert candidate(dist = [5, 10, 15, 20, 25],speed = 5,hoursBefore = 14) == -1\n assert candidate(dist = [100, 200, 300, 400, 500],speed = 1,hoursBefore = 1500) == 0\n assert candidate(dist = [5, 4, 3, 2, 1],speed = 1,hoursBefore = 15) == 0\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 20) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 2,hoursBefore = 15) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 5,hoursBefore = 10) == -1\n assert candidate(dist = [5, 15, 25, 35, 45],speed = 10,hoursBefore = 12) == -1\n assert candidate(dist = [100, 200, 300, 400, 500],speed = 50,hoursBefore = 25) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 500,hoursBefore = 12) == 4\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],speed = 30,hoursBefore = 35) == -1\n assert candidate(dist = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200],speed = 50,hoursBefore = 20) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 100,hoursBefore = 55) == 0\n assert candidate(dist = [1000, 2000, 3000, 4000, 5000],speed = 1000,hoursBefore = 20) == 0\n assert candidate(dist = [1000, 2000, 3000, 4000, 5000],speed = 1000,hoursBefore = 15) == 0\n"}, "metadata": {"canonical_parameter_names": ["dist", "speed", "hoursBefore"], "leetcode_dataset_entry_point": "Solution().minSkips", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minSkips(self, dist: list[int], speed: int, hoursBefore: int) -> int:", "container": "Solution", "callable": "minSkips", "parameters": [{"name": "dist", "type": "list[int]"}, {"name": "speed", "type": "int"}, {"name": "hoursBefore", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1884, "task_id": "egg-drop-with-2-eggs-and-n-floors", "difficulty": "Medium", "problem_description": "You are given two identical eggs and you have access to a building with n floors labeled from 1 to n.\nYou know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor higher than f will break, and any egg dropped at or below floor f will not break.\nIn each move, you may take an unbroken egg and drop it from any floor x (where 1 <= x <= n). If the egg breaks, you can no longer use it. However, if the egg does not break, you may reuse it in future moves.\nReturn the minimum number of moves that you need to determine with certainty what the value of f is.\n \nExample 1:\n\nInput: n = 2\nOutput: 2\nExplanation: We can drop the first egg from floor 1 and the second egg from floor 2.\nIf the first egg breaks, we know that f = 0.\nIf the second egg breaks but the first egg didn't, we know that f = 1.\nOtherwise, if both eggs survive, we know that f = 2.\n\nExample 2:\n\nInput: n = 100\nOutput: 14\nExplanation: One optimal strategy is:\n- Drop the 1st egg at floor 9. If it breaks, we know f is between 0 and 8. Drop the 2nd egg starting from floor 1 and going up one at a time to find f within 8 more drops. Total drops is 1 + 8 = 9.\n- If the 1st egg does not break, drop the 1st egg again at floor 22. If it breaks, we know f is between 9 and 21. Drop the 2nd egg starting from floor 10 and going up one at a time to find f within 12 more drops. Total drops is 2 + 12 = 14.\n- If the 1st egg does not break again, follow a similar process dropping the 1st egg from floors 34, 45, 55, 64, 72, 79, 85, 90, 94, 97, 99, and 100.\nRegardless of the outcome, it takes at most 14 drops to determine f.\n\n \nConstraints:\n\n1 <= n <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 4\n assert candidate(n = 1000) == 45\n assert candidate(n = 5) == 3\n assert candidate(n = 81) == 13\n assert candidate(n = 999) == 45\n assert candidate(n = 15) == 5\n assert candidate(n = 64) == 11\n assert candidate(n = 450) == 30\n assert candidate(n = 600) == 35\n assert candidate(n = 6) == 3\n assert candidate(n = 2) == 2\n assert candidate(n = 100) == 14\n assert candidate(n = 500) == 32\n assert candidate(n = 50) == 10\n assert candidate(n = 1) == 1\n assert candidate(n = 10) == 4\n assert candidate(n = 300) == 24\n assert candidate(n = 990) == 44\n assert candidate(n = 850) == 41\n assert candidate(n = 125) == 16\n assert candidate(n = 900) == 42\n assert candidate(n = 995) == 45\n assert candidate(n = 505) == 32\n assert candidate(n = 650) == 36\n assert candidate(n = 550) == 33\n assert candidate(n = 460) == 30\n assert candidate(n = 99) == 14\n assert candidate(n = 501) == 32\n assert candidate(n = 250) == 22\n assert candidate(n = 75) == 12\n assert candidate(n = 997) == 45\n assert candidate(n = 925) == 43\n assert candidate(n = 504) == 32\n assert candidate(n = 350) == 26\n assert candidate(n = 503) == 32\n assert candidate(n = 150) == 17\n assert candidate(n = 800) == 40\n assert candidate(n = 200) == 20\n assert candidate(n = 400) == 28\n assert candidate(n = 750) == 39\n assert candidate(n = 502) == 32\n assert candidate(n = 950) == 44\n assert candidate(n = 700) == 37\n assert candidate(n = 366) == 27\n assert candidate(n = 998) == 45\n assert candidate(n = 25) == 7\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().twoEggDrop", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def twoEggDrop(self, n: int) -> int:", "container": "Solution", "callable": "twoEggDrop", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1886, "task_id": "determine-whether-matrix-can-be-obtained-by-rotation", "difficulty": "Easy", "problem_description": "Given two n x n binary matrices mat and target, return true if it is possible to make mat equal to target by rotating mat in 90-degree increments, or false otherwise.\n \nExample 1:\n\n\nInput: mat = [[0,1],[1,0]], target = [[1,0],[0,1]]\nOutput: true\nExplanation: We can rotate mat 90 degrees clockwise to make mat equal target.\n\nExample 2:\n\n\nInput: mat = [[0,1],[1,1]], target = [[1,0],[0,1]]\nOutput: false\nExplanation: It is impossible to make mat equal to target by rotating mat.\n\nExample 3:\n\n\nInput: mat = [[0,0,0],[0,1,0],[1,1,1]], target = [[1,1,1],[0,1,0],[0,0,0]]\nOutput: true\nExplanation: We can rotate mat 90 degrees clockwise two times to make mat equal target.\n\n \nConstraints:\n\nn == mat.length == target.length\nn == mat[i].length == target[i].length\n1 <= n <= 10\nmat[i][j] and target[i][j] are either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 0, 0], [0, 1, 0], [0, 0, 1]],target = [[0, 0, 1], [0, 1, 0], [1, 0, 0]]) == True\n assert candidate(mat = [[0, 1], [1, 0]],target = [[1, 0], [0, 1]]) == True\n assert candidate(mat = [[1, 1], [0, 0]],target = [[0, 1], [0, 1]]) == True\n assert candidate(mat = [[1, 0], [0, 1]],target = [[0, 1], [1, 0]]) == True\n assert candidate(mat = [[1, 1, 0], [0, 1, 0], [0, 1, 1]],target = [[0, 0, 1], [0, 1, 0], [1, 1, 0]]) == False\n assert candidate(mat = [[0, 1], [1, 1]],target = [[1, 0], [0, 1]]) == False\n assert candidate(mat = [[0, 0, 0], [0, 1, 0], [1, 1, 1]],target = [[1, 1, 1], [0, 1, 0], [0, 0, 0]]) == True\n assert candidate(mat = [[1, 1, 0], [0, 0, 0], [0, 1, 1]],target = [[0, 0, 0], [0, 1, 1], [1, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 0, 0], [1, 0, 0, 1], [0, 1, 1, 0], [0, 0, 1, 1]],target = [[0, 0, 1, 1], [0, 1, 1, 0], [1, 0, 0, 1], [1, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 1], [0, 0]],target = [[0, 0], [1, 1]]) == True\n assert candidate(mat = [[1, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1]],target = [[1, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1]]) == True\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 0, 0, 1, 1], [1, 0, 0, 1, 1], [0, 1, 1, 0, 0], [0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 1], [0, 1, 1, 0, 0], [0, 1, 1, 0, 0], [1, 0, 0, 1, 1], [1, 1, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 1]],target = [[1, 1, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 0, 1]]) == False\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 0, 0, 0, 1], [1, 0, 0, 1, 0], [1, 0, 1, 0, 0], [1, 1, 0, 0, 0]],target = [[0, 0, 0, 1, 1], [0, 0, 1, 0, 1], [0, 1, 0, 0, 1], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1]]) == False\n assert candidate(mat = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]],target = [[0, 0, 1, 1], [0, 0, 1, 1], [1, 1, 0, 0], [1, 1, 0, 0]]) == True\n assert candidate(mat = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],target = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == True\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1]]) == False\n assert candidate(mat = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]],target = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == True\n assert candidate(mat = [[1, 1, 0, 0], [0, 0, 1, 1], [0, 1, 0, 1], [1, 0, 1, 0]],target = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == False\n assert candidate(mat = [[0, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 1, 0]],target = [[0, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 0]]) == False\n assert candidate(mat = [[0, 1, 1, 0], [1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 0]],target = [[0, 1, 1, 0], [1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 0]]) == True\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],target = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == True\n assert candidate(mat = [[0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1]],target = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],target = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == True\n assert candidate(mat = [[0, 1, 1, 0], [1, 1, 1, 1], [1, 0, 0, 1], [0, 1, 1, 0]],target = [[0, 1, 0, 1], [1, 1, 1, 1], [0, 0, 1, 0], [1, 1, 1, 1]]) == False\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 0, 0, 1], [1, 0, 1, 0], [1, 0, 0, 1], [1, 0, 1, 0]],target = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [0, 1, 1, 0, 1], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0]],target = [[0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 0, 1], [1, 0, 0, 1], [0, 0, 1, 1], [1, 0, 1, 0]],target = [[0, 1, 0, 1], [1, 1, 0, 0], [1, 0, 0, 1], [0, 1, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 1], [1, 0, 1], [1, 1, 1]],target = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == True\n assert candidate(mat = [[0, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [1, 0, 0, 0]],target = [[1, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) == True\n assert candidate(mat = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1], [1, 1, 1, 1]],target = [[1, 1, 1, 1], [1, 1, 1, 0], [1, 1, 0, 0], [1, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 0, 0, 0], [0, 1, 1, 1], [0, 1, 0, 1], [0, 1, 1, 0]],target = [[0, 1, 1, 0], [1, 0, 1, 0], [1, 1, 0, 1], [0, 0, 0, 1]]) == False\n assert candidate(mat = [[0, 1, 0, 0], [1, 1, 1, 0], [0, 1, 1, 1], [0, 0, 0, 1]],target = [[1, 0, 0, 0], [1, 1, 0, 1], [1, 1, 1, 0], [1, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],target = [[1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1]]) == True\n assert candidate(mat = [[0, 0, 1, 1], [0, 1, 0, 0], [1, 0, 0, 1], [1, 1, 0, 0]],target = [[0, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 0, 0, 0], [1, 1, 1, 1]]) == False\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],target = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == True\n assert candidate(mat = [[1, 1, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 1, 1]],target = [[1, 0, 1, 0], [1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 1, 0]]) == False\n assert candidate(mat = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]],target = [[1, 0, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 1], [0, 0, 1], [0, 0, 1]],target = [[1, 1, 1], [1, 0, 0], [1, 0, 0]]) == True\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],target = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],target = [[1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 0, 0, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 0, 0, 0]],target = [[0, 0, 0, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 1, 1]]) == False\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0]]) == False\n assert candidate(mat = [[0, 1, 0, 0], [1, 0, 0, 1], [0, 0, 1, 0], [1, 0, 0, 1]],target = [[1, 0, 0, 1], [0, 0, 1, 0], [1, 0, 0, 1], [0, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],target = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == True\n assert candidate(mat = [[1, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 1]],target = [[0, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 0]]) == True\n assert candidate(mat = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],target = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1]],target = [[0, 0, 0, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0]]) == False\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]],target = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == True\n assert candidate(mat = [[0, 0, 0, 1, 0], [0, 0, 1, 1, 0], [0, 1, 1, 0, 0], [1, 1, 0, 0, 0], [0, 1, 1, 0, 0]],target = [[0, 0, 1, 1, 0], [0, 0, 0, 1, 0], [0, 1, 1, 0, 0], [0, 0, 1, 1, 0], [0, 1, 1, 0, 0]]) == False\n assert candidate(mat = [[0, 1, 1, 0], [1, 1, 1, 1], [0, 0, 1, 0], [1, 1, 1, 1]],target = [[1, 0, 0, 0], [1, 1, 0, 1], [1, 1, 1, 1], [0, 0, 1, 1]]) == False\n assert candidate(mat = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]],target = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == True\n assert candidate(mat = [[0, 0, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 1, 0]],target = [[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1]]) == False\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]]) == False\n assert candidate(mat = [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]],target = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == True\n assert candidate(mat = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],target = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == True\n assert candidate(mat = [[0, 1, 1, 1], [1, 1, 0, 0], [1, 0, 0, 1], [1, 1, 1, 0]],target = [[1, 1, 1, 0], [1, 0, 0, 1], [0, 0, 1, 1], [1, 1, 0, 0]]) == False\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 1, 0]],target = [[0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],target = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 0, 1, 1], [0, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0]],target = [[0, 0, 1, 1], [1, 1, 0, 0], [1, 0, 1, 1], [0, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 0, 1]],target = [[1, 0, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 0, 1]]) == False\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]],target = [[0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == True\n assert candidate(mat = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]],target = [[1, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [1, 0, 0, 0, 1]]) == False\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],target = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == False\n assert candidate(mat = [[0, 1, 1, 0, 0], [1, 0, 1, 0, 1], [1, 1, 0, 1, 1], [0, 0, 1, 0, 0], [1, 0, 1, 0, 1]],target = [[0, 0, 1, 0, 0], [1, 1, 0, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0]]) == False\n assert candidate(mat = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 0], [1, 1, 0, 0]],target = [[0, 0, 1, 0], [0, 1, 1, 0], [1, 1, 0, 0], [0, 0, 1, 0]]) == False\n assert candidate(mat = [[0, 0, 1, 1], [0, 0, 1, 1], [1, 1, 0, 0], [1, 1, 0, 0]],target = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]]) == True\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 1], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [1, 1, 0, 0, 0], [1, 1, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 0, 1], [0, 1, 0], [1, 0, 1]],target = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == True\n assert candidate(mat = [[0, 0, 1], [0, 1, 0], [1, 0, 0]],target = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == True\n assert candidate(mat = [[1, 0, 0, 1, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [1, 0, 0, 1, 0], [1, 1, 0, 0, 1]],target = [[1, 1, 0, 1, 1], [0, 0, 1, 0, 0], [1, 0, 0, 1, 0], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1]]) == False\n assert candidate(mat = [[0, 1, 1, 1], [1, 0, 0, 0], [1, 0, 1, 0], [1, 0, 0, 1]],target = [[1, 0, 0, 1], [0, 1, 0, 1], [0, 0, 0, 1], [1, 1, 1, 0]]) == True\n assert candidate(mat = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]],target = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],target = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == True\n"}, "metadata": {"canonical_parameter_names": ["mat", "target"], "leetcode_dataset_entry_point": "Solution().findRotation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findRotation(self, mat: list[list[int]], target: list[list[int]]) -> bool:", "container": "Solution", "callable": "findRotation", "parameters": [{"name": "mat", "type": "list[list[int]]"}, {"name": "target", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1887, "task_id": "reduction-operations-to-make-the-array-elements-equal", "difficulty": "Medium", "problem_description": "Given an integer array nums, your goal is to make all elements in nums equal. To complete one operation, follow these steps:\n\nFind the largest value in nums. Let its index be i (0-indexed) and its value be largest. If there are multiple elements with the largest value, pick the smallest i.\nFind the next largest value in nums strictly smaller than largest. Let its value be nextLargest.\nReduce nums[i] to nextLargest.\n\nReturn the number of operations to make all elements in nums equal.\n \nExample 1:\n\nInput: nums = [5,1,3]\nOutput: 3\nExplanation: It takes 3 operations to make all elements in nums equal:\n1. largest = 5 at index 0. nextLargest = 3. Reduce nums[0] to 3. nums = [3,1,3].\n2. largest = 3 at index 0. nextLargest = 1. Reduce nums[0] to 1. nums = [1,1,3].\n3. largest = 3 at index 2. nextLargest = 1. Reduce nums[2] to 1. nums = [1,1,1].\n\nExample 2:\n\nInput: nums = [1,1,1]\nOutput: 0\nExplanation: All elements in nums are already equal.\n\nExample 3:\n\nInput: nums = [1,1,2,2,3]\nOutput: 4\nExplanation: It takes 4 operations to make all elements in nums equal:\n1. largest = 3 at index 4. nextLargest = 2. Reduce nums[4] to 2. nums = [1,1,2,2,2].\n2. largest = 2 at index 2. nextLargest = 1. Reduce nums[2] to 1. nums = [1,1,1,2,2].\n3. largest = 2 at index 3. nextLargest = 1. Reduce nums[3] to 1. nums = [1,1,1,1,2].\n4. largest = 2 at index 4. nextLargest = 1. Reduce nums[4] to 1. nums = [1,1,1,1,1].\n\n \nConstraints:\n\n1 <= nums.length <= 5 * 104\n1 <= nums[i] <= 5 * 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996]) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 20\n assert candidate(nums = [4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 5, 2, 4, 3]) == 10\n assert candidate(nums = [1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3]) == 4\n assert candidate(nums = [3, 3, 2, 1, 2, 3, 3, 2, 1]) == 11\n assert candidate(nums = [4, 3, 2, 1, 4, 3, 2, 1]) == 12\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [5, 1, 3]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(nums = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == 18\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 60\n assert candidate(nums = [5, 3, 3, 3, 2, 2, 1, 1, 1, 1]) == 11\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 10\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9]) == 84\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 190\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 26\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 190\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5]) == 40\n assert candidate(nums = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 90\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 20\n assert candidate(nums = [4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 21\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 105\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 40\n assert candidate(nums = [4, 3, 3, 2, 2, 1, 1, 1, 1]) == 9\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991]) == 45\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]) == 32\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 140\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 435\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 50\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 85\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 435\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == 112\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991, 49990, 49989, 49988, 49987, 49986, 49985, 49984, 49983, 49982, 49981]) == 190\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 126\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3]) == 24\n assert candidate(nums = [30000, 20000, 10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1]) == 120\n assert candidate(nums = [5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 43\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 19\n assert candidate(nums = [10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 225\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 32\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4]) == 24\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 5, 5]) == 26\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 300\n assert candidate(nums = [1, 3, 2, 5, 4, 3, 2, 1, 4, 3, 2, 1, 3, 2, 1, 2, 1, 1]) == 23\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5]) == 30\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 174\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 190\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 20\n assert candidate(nums = [5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]) == 24\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 125\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 435\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 90\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 435\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 50\n assert candidate(nums = [1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 71\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 105\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(nums = [25000, 25000, 24999, 24998, 24997, 24996, 24995, 24994, 24993, 24992]) == 44\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 190\n assert candidate(nums = [5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1]) == 40\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 26\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 28\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991]) == 45\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 18\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 90\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 90\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5]) == 41\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 190\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 56\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 50\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]) == 24\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 50\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 25\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 135\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 20\n assert candidate(nums = [1, 3, 2, 3, 1, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 125\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2]) == 30\n assert candidate(nums = [5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1]) == 36\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().reductionOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def reductionOperations(self, nums: list[int]) -> int:", "container": "Solution", "callable": "reductionOperations", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1888, "task_id": "minimum-number-of-flips-to-make-the-binary-string-alternating", "difficulty": "Medium", "problem_description": "You are given a binary string s. You are allowed to perform two types of operations on the string in any sequence:\n\nType-1: Remove the character at the start of the string s and append it to the end of the string.\nType-2: Pick any character in s and flip its value, i.e., if its value is '0' it becomes '1' and vice-versa.\n\nReturn the minimum number of type-2 operations you need to perform such that s becomes alternating.\nThe string is called alternating if no two adjacent characters are equal.\n\nFor example, the strings \"010\" and \"1010\" are alternating, while the string \"0100\" is not.\n\n \nExample 1:\n\nInput: s = \"111000\"\nOutput: 2\nExplanation: Use the first operation two times to make s = \"100011\".\nThen, use the second operation on the third and sixth elements to make s = \"101010\".\n\nExample 2:\n\nInput: s = \"010\"\nOutput: 0\nExplanation: The string is already alternating.\n\nExample 3:\n\nInput: s = \"1110\"\nOutput: 1\nExplanation: Use the second operation on the second element to make s = \"1010\".\n\n \nConstraints:\n\n1 <= s.length <= 105\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"100100100\") == 3\n assert candidate(s = \"1111\") == 2\n assert candidate(s = \"110011\") == 3\n assert candidate(s = \"111000111000\") == 4\n assert candidate(s = \"11110000\") == 4\n assert candidate(s = \"1110\") == 1\n assert candidate(s = \"0000\") == 2\n assert candidate(s = \"010101010\") == 0\n assert candidate(s = \"01010\") == 0\n assert candidate(s = \"111000\") == 2\n assert candidate(s = \"111111\") == 3\n assert candidate(s = \"10101\") == 0\n assert candidate(s = \"010\") == 0\n assert candidate(s = \"00001111\") == 4\n assert candidate(s = \"000111\") == 2\n assert candidate(s = \"1001001001\") == 5\n assert candidate(s = \"11111\") == 2\n assert candidate(s = \"000000\") == 3\n assert candidate(s = \"010101\") == 0\n assert candidate(s = \"101010\") == 0\n assert candidate(s = \"00000\") == 2\n assert candidate(s = \"0001\") == 1\n assert candidate(s = \"111000111000111000\") == 6\n assert candidate(s = \"010101010101010101010101010101010101\") == 0\n assert candidate(s = \"0000000000111111111100000000001111111111\") == 20\n assert candidate(s = \"00011111000111110001111100011111\") == 12\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"00000000000000000000000000000000\") == 16\n assert candidate(s = \"0110110110110110110110110110\") == 14\n assert candidate(s = \"1010101010101010101010101\") == 0\n assert candidate(s = \"110100110100\") == 4\n assert candidate(s = \"1100110011001100\") == 8\n assert candidate(s = \"1010101010101010101\") == 0\n assert candidate(s = \"0101001101010011010100110101001101010011010100110101001\") == 12\n assert candidate(s = \"010101010101010101010101\") == 0\n assert candidate(s = \"11101001111010011110100111101001\") == 12\n assert candidate(s = \"00001111000011110000\") == 10\n assert candidate(s = \"000111000111000111\") == 6\n assert candidate(s = \"101010101010101010101010\") == 0\n assert candidate(s = \"11110101010101011111\") == 4\n assert candidate(s = \"0000000011111111000000001111\") == 14\n assert candidate(s = \"1100101010\") == 2\n assert candidate(s = \"101010101010101010101\") == 0\n assert candidate(s = \"1010101010\") == 0\n assert candidate(s = \"1010101010101010101010101010101011\") == 1\n assert candidate(s = \"010101010101010101\") == 0\n assert candidate(s = \"0000000000\") == 5\n assert candidate(s = \"101010101010101010101010101\") == 0\n assert candidate(s = \"1110011100\") == 5\n assert candidate(s = \"1100110011\") == 5\n assert candidate(s = \"111000111000111000111000111000\") == 10\n assert candidate(s = \"0000000000000000\") == 8\n assert candidate(s = \"000111000111000111000111\") == 8\n assert candidate(s = \"11100000111000001110000011100000111000001110000011100000\") == 21\n assert candidate(s = \"0101001101010011010100110101001101010011\") == 10\n assert candidate(s = \"1100110011001100110011001100110011001100\") == 20\n assert candidate(s = \"1010101010101010\") == 0\n assert candidate(s = \"010100010101\") == 1\n assert candidate(s = \"0101010101010101010101\") == 0\n assert candidate(s = \"111000111000111000111000111000111000\") == 12\n assert candidate(s = \"111101111011110111101111011110111101111011110111\") == 23\n assert candidate(s = \"01101010101010101011\") == 3\n assert candidate(s = \"01010101011\") == 0\n assert candidate(s = \"11111000001111100000\") == 8\n assert candidate(s = \"0101010101010101010101010101010101\") == 0\n assert candidate(s = \"000011110000111100001111000011110000\") == 18\n assert candidate(s = \"11001100110011001100110011001100110011001100110011001\") == 25\n assert candidate(s = \"111000011100001110000\") == 9\n assert candidate(s = \"0000111100001111000011110000\") == 14\n assert candidate(s = \"1110001110001110001110\") == 7\n assert candidate(s = \"11110000111100001111\") == 10\n assert candidate(s = \"01010101010101010101010101\") == 0\n assert candidate(s = \"10010010010010010010010010010\") == 12\n assert candidate(s = \"0101001101010011\") == 4\n assert candidate(s = \"1111111100000000111111110000\") == 14\n assert candidate(s = \"1000000000\") == 4\n assert candidate(s = \"11111111111111111111\") == 10\n assert candidate(s = \"000011110000\") == 6\n assert candidate(s = \"0011001100\") == 5\n assert candidate(s = \"1111111111111111\") == 8\n assert candidate(s = \"10101010101010101010101010101010101\") == 0\n assert candidate(s = \"00000000001111111111\") == 10\n assert candidate(s = \"101010101010101010101010101010101\") == 0\n assert candidate(s = \"00000111110000011111\") == 8\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111\") == 26\n assert candidate(s = \"1111100000111110000011111\") == 10\n assert candidate(s = \"111000111000111000111\") == 7\n assert candidate(s = \"11111111110000000000\") == 10\n assert candidate(s = \"11001100110011001100\") == 10\n assert candidate(s = \"11100011100011100011\") == 7\n assert candidate(s = \"01010101010101010101010101010101\") == 0\n assert candidate(s = \"10010010010010010010\") == 9\n assert candidate(s = \"1010101010101010101010101010\") == 0\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\") == 25\n assert candidate(s = \"1001001001001001001001\") == 11\n assert candidate(s = \"0000011111000001111100000\") == 10\n assert candidate(s = \"1111000011110000111100001111000011110000\") == 20\n assert candidate(s = \"111100001111\") == 6\n assert candidate(s = \"11110000111100001111000011110000\") == 16\n assert candidate(s = \"0000000000000000000000000111111111111111111111111\") == 23\n assert candidate(s = \"11001100110011001100110011001100110011001100110011001100110\") == 28\n assert candidate(s = \"101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"000111100011110001111\") == 9\n assert candidate(s = \"11111111111111111111111111111111\") == 16\n assert candidate(s = \"00011111000111110001111100011111000111110001111100011111\") == 21\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"00010110000101100001011000010110\") == 12\n assert candidate(s = \"0101010101010101010101010101\") == 0\n assert candidate(s = \"000111000111000111000111000111\") == 10\n assert candidate(s = \"11010101010101010110\") == 3\n assert candidate(s = \"111111111111111111111111111111111\") == 16\n assert candidate(s = \"0101010101\") == 0\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\") == 25\n assert candidate(s = \"00010001000100010001000\") == 6\n assert candidate(s = \"110011001100110011001100110011001\") == 15\n assert candidate(s = \"00110011001100110011\") == 10\n assert candidate(s = \"0111011101\") == 2\n assert candidate(s = \"010101010101010101010101010101010\") == 0\n assert candidate(s = \"00000000000000000000\") == 10\n assert candidate(s = \"1111000011110000\") == 8\n assert candidate(s = \"0101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"10101010101010101010101010101010\") == 0\n assert candidate(s = \"010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"1111100000\") == 4\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111111111111111\") == 33\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000\") == 26\n assert candidate(s = \"010101010101010101010\") == 0\n assert candidate(s = \"1111111111111111111111111000000000000000000000000\") == 23\n assert candidate(s = \"1010101010101010101010\") == 0\n assert candidate(s = \"1111111111\") == 5\n assert candidate(s = \"1111000011110000111100001111\") == 14\n assert candidate(s = \"00000000000000000000000000000\") == 14\n assert candidate(s = \"00011100011100011100\") == 7\n assert candidate(s = \"01010101010101010101\") == 0\n assert candidate(s = \"000000000000000000000000000000000\") == 16\n assert candidate(s = \"010101010101010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"11100000111000001110000011100000\") == 12\n assert candidate(s = \"101010101010101010101010101010101010\") == 0\n assert candidate(s = \"10101010100\") == 0\n assert candidate(s = \"11111111000000001111\") == 10\n assert candidate(s = \"01101101101101101101\") == 9\n assert candidate(s = \"10101010101010101010\") == 0\n assert candidate(s = \"00000000111111110000\") == 10\n assert candidate(s = \"11000011110000111100\") == 10\n assert candidate(s = \"11111111111111111111111111\") == 13\n assert candidate(s = \"111000111000111000111000\") == 8\n assert candidate(s = \"010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"10111011101110111011\") == 5\n assert candidate(s = \"001100110011\") == 6\n assert candidate(s = \"0000111100001111\") == 8\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minFlips", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minFlips(self, s: str) -> int:", "container": "Solution", "callable": "minFlips", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1889, "task_id": "minimum-space-wasted-from-packaging", "difficulty": "Hard", "problem_description": "You have n packages that you are trying to place in boxes, one package in each box. There are m suppliers that each produce boxes of different sizes (with infinite supply). A package can be placed in a box if the size of the package is less than or equal to the size of the box.\nThe package sizes are given as an integer array packages, where packages[i] is the size of the ith package. The suppliers are given as a 2D integer array boxes, where boxes[j] is an array of box sizes that the jth supplier produces.\nYou want to choose a single supplier and use boxes from them such that the total wasted space is minimized. For each package in a box, we define the space wasted to be size of the box - size of the package. The total wasted space is the sum of the space wasted in all the boxes.\n\nFor example, if you have to fit packages with sizes [2,3,5] and the supplier offers boxes of sizes [4,8], you can fit the packages of size-2 and size-3 into two boxes of size-4 and the package with size-5 into a box of size-8. This would result in a waste of (4-2) + (4-3) + (8-5) = 6.\n\nReturn the minimum total wasted space by choosing the box supplier optimally, or -1 if it is impossible to fit all the packages inside boxes. Since the answer may be large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: packages = [2,3,5], boxes = [[4,8],[2,8]]\nOutput: 6\nExplanation: It is optimal to choose the first supplier, using two size-4 boxes and one size-8 box.\nThe total waste is (4-2) + (4-3) + (8-5) = 6.\n\nExample 2:\n\nInput: packages = [2,3,5], boxes = [[1,4],[2,3],[3,4]]\nOutput: -1\nExplanation: There is no box that the package of size 5 can fit in.\n\nExample 3:\n\nInput: packages = [3,5,8,10,11,12], boxes = [[12],[11,9],[10,5,14]]\nOutput: 9\nExplanation: It is optimal to choose the third supplier, using two size-5 boxes, two size-10 boxes, and two size-14 boxes.\nThe total waste is (5-3) + (5-5) + (10-8) + (10-10) + (14-11) + (14-12) = 9.\n\n \nConstraints:\n\nn == packages.length\nm == boxes.length\n1 <= n <= 105\n1 <= m <= 105\n1 <= packages[i] <= 105\n1 <= boxes[j].length <= 105\n1 <= boxes[j][k] <= 105\nsum(boxes[j].length) <= 105\nThe elements in boxes[j] are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(packages = [10, 20, 30],boxes = [[10], [20], [30], [40]]) == 30\n assert candidate(packages = [100000],boxes = [[100000]]) == 0\n assert candidate(packages = [10, 20, 30],boxes = [[10, 20, 30], [15, 25, 35]]) == 0\n assert candidate(packages = [1, 100000],boxes = [[1], [100000]]) == 99999\n assert candidate(packages = [2, 3, 5],boxes = [[4, 8], [2, 8]]) == 6\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 45\n assert candidate(packages = [3, 5, 8, 10, 11, 12],boxes = [[12], [11, 9], [10, 5, 14]]) == 9\n assert candidate(packages = [1, 2, 3, 4, 5],boxes = [[5, 5, 5, 5, 5]]) == 10\n assert candidate(packages = [1, 3, 5, 7, 9],boxes = [[2, 4, 6, 8, 10]]) == 5\n assert candidate(packages = [5, 5, 5, 5],boxes = [[5, 5, 5, 5]]) == 0\n assert candidate(packages = [2, 3, 5],boxes = [[1, 4], [2, 3], [3, 4]]) == -1\n assert candidate(packages = [10000, 20000, 30000, 40000, 50000],boxes = [[20000, 30000, 50000], [10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 15, 25, 35, 45]]) == 0\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 5, 9, 13, 17], [3, 7, 11, 15, 19]]) == 10\n assert candidate(packages = [50000, 50000, 50000, 50000, 50000],boxes = [[50000, 50000], [100000], [25000, 75000]]) == 0\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [5, 10, 15, 20, 25, 30]]) == 10\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]]) == 0\n assert candidate(packages = [99999, 99998, 99997, 99996, 99995],boxes = [[100000], [99999], [99998], [99997], [99996], [99995]]) == 10\n assert candidate(packages = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],boxes = [[4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22], [3, 7, 11, 15, 19, 23, 27, 31]]) == 9\n assert candidate(packages = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900],boxes = [[500, 600, 700, 800, 900, 1000], [900, 1000, 1100, 1200, 1300, 1400, 1500], [100, 200, 300, 400, 500, 600, 700, 800, 900]]) == 99\n assert candidate(packages = [1, 10, 100, 1000, 10000, 100000],boxes = [[5, 10, 100, 1000, 10000, 100000, 500000], [1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],boxes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]]) == 0\n assert candidate(packages = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],boxes = [[3, 6, 9, 12, 15, 18, 21], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]]) == 10\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30], [1, 5, 9, 13, 17, 21, 25, 29]]) == 14\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 0\n assert candidate(packages = [5, 10, 15, 20, 25],boxes = [[5, 10, 15, 20, 25], [1, 2, 3, 4, 5], [26, 27, 28, 29, 30]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]]) == 0\n assert candidate(packages = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],boxes = [[5, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60]]) == 145\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1], [2], [3, 4, 5]]) == 0\n assert candidate(packages = [100000, 90000, 80000, 70000, 60000],boxes = [[95000, 100000], [85000, 90000, 95000], [75000, 80000, 85000], [65000, 70000, 75000, 80000]]) == 80000\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 11, 12], [9, 8, 7, 6, 5, 4, 3, 2, 1], [15, 20, 25, 30, 35]]) == 45\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1], [2], [1, 2, 3, 4, 5]]) == 0\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1], [2], [3]]) == 0\n assert candidate(packages = [100000],boxes = [[99999, 99998, 99997, 99996, 99995]]) == -1\n assert candidate(packages = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[5, 10, 15], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]) == 0\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1, 2, 3, 4, 5], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15]]) == 0\n assert candidate(packages = [25000, 50000, 75000, 100000],boxes = [[12500, 37500, 62500, 87500], [10000, 40000, 70000, 100000], [50000, 50000, 50000, 50000]]) == 60000\n assert candidate(packages = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],boxes = [[100], [200], [300], [400], [500], [600], [700], [800], [900], [1000]]) == 4500\n assert candidate(packages = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],boxes = [[100000], [100001], [99999], [99998], [99997], [99996], [99995], [99994], [99993], [99992], [99991]]) == 45\n assert candidate(packages = [1, 10, 100, 1000, 10000, 100000],boxes = [[1, 10, 100, 1000, 10000, 100000], [2, 20, 200, 2000, 20000, 200000], [5, 50, 500, 5000, 50000, 500000]]) == 0\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]]) == 0\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1], [2], [3]]) == 0\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],boxes = [[1, 3, 5, 7, 9, 11, 13, 15], [2, 4, 6, 8, 10, 12, 14], [16]]) == 7\n assert candidate(packages = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950],boxes = [[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], [50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]]) == 0\n assert candidate(packages = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10], [9, 10], [8, 9, 10], [7, 8, 9, 10], [6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10]]) == 10\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[1, 2, 3, 4, 5], [101, 102, 103, 104, 105], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]]) == 0\n assert candidate(packages = [20000, 10000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],boxes = [[50000, 70000, 90000, 110000], [30000, 60000, 90000, 120000], [25000, 50000, 75000, 100000, 125000]]) == 100000\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 0\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[15, 25, 35, 45, 55, 65, 75, 85, 95, 105], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]]) == 0\n assert candidate(packages = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]]) == 0\n assert candidate(packages = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],boxes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [3, 6, 9, 12, 15, 18], [4, 8, 12, 16, 20]]) == 0\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120], [50, 60, 70, 80, 90, 100, 110, 120, 130, 140]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(packages = [1, 100000],boxes = [[50000], [150000], [100000]]) == 99999\n assert candidate(packages = [1, 10, 100, 1000, 10000],boxes = [[5, 50, 500, 5000, 50000], [1, 2, 3, 4, 5], [9999, 99999]]) == 44444\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [10, 30, 50, 70, 90, 110], [20, 40, 60, 80, 100, 120]]) == 50\n assert candidate(packages = [1, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]]) == 14\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],boxes = [[1, 3, 5, 7, 9, 11, 13, 15], [2, 4, 6, 8, 10, 12, 14], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 0\n assert candidate(packages = [50000, 50000, 50000, 50000, 50000],boxes = [[49999], [50000], [50001]]) == 0\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [50, 50, 50, 50, 50, 50, 50, 50, 50, 50], [100, 100, 100, 100, 100, 100, 100, 100, 100, 100], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 450\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],boxes = [[20, 40], [10, 30], [5, 15, 25, 35]]) == 90\n assert candidate(packages = [100000, 100000, 100000],boxes = [[100000], [100001], [99999, 100000, 100001]]) == 0\n assert candidate(packages = [50000, 40000, 30000, 20000, 10000],boxes = [[10000, 20000, 30000, 40000, 50000], [15000, 25000, 35000, 45000, 55000], [55000]]) == 0\n assert candidate(packages = [50, 60, 70, 80, 90, 100],boxes = [[40, 90], [50, 60, 100], [80, 95, 110]]) == 60\n assert candidate(packages = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],boxes = [[50000, 60000, 70000, 80000, 90000, 100000], [90000, 100000, 110000, 120000, 130000, 140000, 150000]]) == 100000\n assert candidate(packages = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],boxes = [[100], [256, 512, 1024], [2, 4, 8, 16, 32, 64, 128]]) == 1793\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 10, 10], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 5\n assert candidate(packages = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],boxes = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]]) == 0\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(packages = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],boxes = [[110000, 120000, 130000], [90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000], [55000, 54000, 53000, 52000, 51000, 50000, 49000, 48000, 47000, 46000]]) == 550000\n assert candidate(packages = [10, 20, 30, 40, 50],boxes = [[5, 15, 25, 35, 45], [6, 16, 26, 36, 46], [7, 17, 27, 37, 47]]) == -1\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],boxes = [[1, 5, 9, 13, 17], [3, 7, 11, 15, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 10\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(packages = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]]) == 0\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [100, 100, 100, 100, 100, 100, 100, 100, 100, 100], [90, 80, 70, 60, 50, 40, 30, 20, 10, 0]]) == 450\n assert candidate(packages = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40], [1, 9, 17, 25, 33], [5, 10, 15, 20, 25, 30, 35]]) == 10\n assert candidate(packages = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]]) == 25\n assert candidate(packages = [10000, 20000, 30000, 40000, 50000],boxes = [[5000, 15000, 25000, 35000, 45000, 55000], [10000, 20000, 30000, 40000, 50000]]) == 0\n assert candidate(packages = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],boxes = [[500, 600, 700, 800, 900, 1000], [900, 1000, 1100, 1200, 1300, 1400, 1500]]) == 1000\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[2, 3, 5, 7, 11], [1, 4, 9], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 9\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 20, 30], [5, 10, 15, 20, 25, 30], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 5\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == -1\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 10, 15, 20, 25], [3, 6, 9, 12, 15]]) == 0\n assert candidate(packages = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],boxes = [[1000, 2000], [500, 1500], [300, 700, 1100]]) == 1500\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],boxes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 0\n assert candidate(packages = [50000, 50000, 50000, 50000, 50000],boxes = [[50000], [50001], [50002], [50003], [50004]]) == 0\n assert candidate(packages = [1000, 2000, 3000, 4000, 5000],boxes = [[1000, 2000, 3000, 4000, 5000], [1500, 2500, 3500, 4500, 5500], [900, 1900, 2900, 3900, 4900]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 20], [5, 15], [3, 7, 12]]) == 18\n"}, "metadata": {"canonical_parameter_names": ["packages", "boxes"], "leetcode_dataset_entry_point": "Solution().minWastedSpace", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minWastedSpace(self, packages: list[int], boxes: list[list[int]]) -> int:", "container": "Solution", "callable": "minWastedSpace", "parameters": [{"name": "packages", "type": "list[int]"}, {"name": "boxes", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1893, "task_id": "check-if-all-the-integers-in-a-range-are-covered", "difficulty": "Easy", "problem_description": "You are given a 2D integer array ranges and two integers left and right. Each ranges[i] = [starti, endi] represents an inclusive interval between starti and endi.\nReturn true if each integer in the inclusive range [left, right] is covered by at least one interval in ranges. Return false otherwise.\nAn integer x is covered by an interval ranges[i] = [starti, endi] if starti <= x <= endi.\n \nExample 1:\n\nInput: ranges = [[1,2],[3,4],[5,6]], left = 2, right = 5\nOutput: true\nExplanation: Every integer between 2 and 5 is covered:\n- 2 is covered by the first range.\n- 3 and 4 are covered by the second range.\n- 5 is covered by the third range.\n\nExample 2:\n\nInput: ranges = [[1,10],[10,20]], left = 21, right = 21\nOutput: false\nExplanation: 21 is not covered by any range.\n\n \nConstraints:\n\n1 <= ranges.length <= 50\n1 <= starti <= endi <= 50\n1 <= left <= right <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(ranges = [[5, 7], [1, 3]],left = 1,right = 7) == False\n assert candidate(ranges = [[5, 10], [15, 20]],left = 10,right = 15) == False\n assert candidate(ranges = [[1, 1], [2, 2], [3, 3]],left = 1,right = 3) == True\n assert candidate(ranges = [[1, 3], [3, 5], [5, 7]],left = 3,right = 5) == True\n assert candidate(ranges = [[10, 20], [21, 30]],left = 15,right = 25) == True\n assert candidate(ranges = [[1, 3], [5, 7]],left = 2,right = 6) == False\n assert candidate(ranges = [[1, 3], [5, 7], [9, 11]],left = 4,right = 6) == False\n assert candidate(ranges = [[5, 10], [15, 20]],left = 8,right = 12) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6]],left = 2,right = 5) == True\n assert candidate(ranges = [[1, 2], [4, 5]],left = 3,right = 4) == False\n assert candidate(ranges = [[1, 10], [10, 20]],left = 21,right = 21) == False\n assert candidate(ranges = [[1, 5], [6, 10]],left = 1,right = 10) == True\n assert candidate(ranges = [[1, 50]],left = 1,right = 50) == True\n assert candidate(ranges = [[5, 10], [10, 15]],left = 10,right = 10) == True\n assert candidate(ranges = [[5, 10], [11, 16], [17, 22], [23, 28]],left = 8,right = 25) == True\n assert candidate(ranges = [[3, 6], [7, 10], [11, 14], [15, 18]],left = 5,right = 17) == True\n assert candidate(ranges = [[1, 10], [15, 25], [30, 40]],left = 11,right = 14) == False\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],left = 5,right = 25) == True\n assert candidate(ranges = [[5, 15], [10, 20], [25, 35]],left = 7,right = 28) == False\n assert candidate(ranges = [[1, 2], [3, 5], [6, 8], [9, 11], [12, 14]],left = 1,right = 14) == True\n assert candidate(ranges = [[2, 5], [6, 9], [10, 15], [16, 20]],left = 3,right = 19) == True\n assert candidate(ranges = [[1, 3], [6, 8], [11, 13], [16, 18]],left = 5,right = 17) == False\n assert candidate(ranges = [[2, 6], [8, 12], [14, 18], [20, 24], [26, 30]],left = 3,right = 28) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],left = 1,right = 12) == True\n assert candidate(ranges = [[5, 5], [10, 10], [15, 15], [20, 20]],left = 5,right = 20) == False\n assert candidate(ranges = [[1, 50]],left = 1,right = 50) == True\n assert candidate(ranges = [[10, 20], [5, 15], [25, 35]],left = 12,right = 28) == False\n assert candidate(ranges = [[5, 7], [8, 10], [15, 20], [25, 30]],left = 7,right = 27) == False\n assert candidate(ranges = [[1, 4], [6, 9], [11, 14], [16, 19], [21, 24], [26, 29]],left = 1,right = 29) == False\n assert candidate(ranges = [[3, 6], [8, 11], [13, 16]],left = 4,right = 15) == False\n assert candidate(ranges = [[10, 15], [16, 20], [21, 25], [26, 30]],left = 12,right = 28) == True\n assert candidate(ranges = [[1, 5], [5, 10], [10, 15], [15, 20]],left = 6,right = 14) == True\n assert candidate(ranges = [[5, 8], [10, 13], [15, 18], [20, 23], [25, 28], [30, 33]],left = 3,right = 31) == False\n assert candidate(ranges = [[5, 10], [15, 25], [30, 35]],left = 25,right = 30) == False\n assert candidate(ranges = [[1, 20], [21, 40], [41, 50]],left = 1,right = 50) == True\n assert candidate(ranges = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],left = 1,right = 10) == True\n assert candidate(ranges = [[3, 7], [9, 13], [15, 19], [21, 25], [27, 31]],left = 6,right = 30) == False\n assert candidate(ranges = [[10, 15], [15, 20], [20, 25]],left = 12,right = 23) == True\n assert candidate(ranges = [[5, 5], [6, 6], [7, 7], [8, 8]],left = 5,right = 8) == True\n assert candidate(ranges = [[5, 8], [10, 15], [18, 23], [25, 30]],left = 8,right = 27) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],left = 1,right = 8) == True\n assert candidate(ranges = [[1, 2], [4, 6], [8, 10], [12, 14]],left = 3,right = 13) == False\n assert candidate(ranges = [[1, 3], [4, 6], [7, 9], [10, 12]],left = 1,right = 12) == True\n assert candidate(ranges = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],left = 1,right = 5) == True\n assert candidate(ranges = [[3, 7], [10, 14], [17, 21]],left = 5,right = 19) == False\n assert candidate(ranges = [[1, 2], [4, 8], [10, 15], [16, 20], [22, 25]],left = 1,right = 25) == False\n assert candidate(ranges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],left = 2,right = 5) == True\n assert candidate(ranges = [[2, 5], [7, 10], [12, 15], [17, 20], [22, 25], [27, 30]],left = 4,right = 29) == False\n assert candidate(ranges = [[2, 4], [5, 7], [8, 10], [11, 13]],left = 2,right = 13) == True\n assert candidate(ranges = [[1, 2], [4, 5], [7, 8], [10, 11]],left = 3,right = 9) == False\n assert candidate(ranges = [[10, 20], [21, 30], [31, 40], [41, 50]],left = 15,right = 45) == True\n assert candidate(ranges = [[10, 12], [15, 17], [20, 22]],left = 10,right = 22) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],left = 1,right = 10) == True\n assert candidate(ranges = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15]],left = 1,right = 15) == True\n assert candidate(ranges = [[5, 7], [7, 9], [9, 11], [11, 13]],left = 6,right = 12) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30]],left = 12,right = 17) == False\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30]],left = 1,right = 30) == True\n assert candidate(ranges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],left = 1,right = 6) == True\n assert candidate(ranges = [[3, 6], [8, 12], [15, 20], [22, 25], [27, 30]],left = 5,right = 28) == False\n assert candidate(ranges = [[5, 8], [10, 12], [15, 18]],left = 6,right = 17) == False\n assert candidate(ranges = [[1, 10], [12, 20], [22, 30]],left = 5,right = 25) == False\n assert candidate(ranges = [[5, 10], [12, 15], [16, 20], [22, 25]],left = 11,right = 21) == False\n assert candidate(ranges = [[1, 10], [15, 25], [30, 40]],left = 5,right = 35) == False\n assert candidate(ranges = [[1, 5], [10, 15], [20, 25], [30, 35]],left = 5,right = 30) == False\n assert candidate(ranges = [[3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13]],left = 3,right = 13) == False\n assert candidate(ranges = [[1, 10], [11, 20], [21, 30], [31, 40]],left = 5,right = 35) == True\n assert candidate(ranges = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],left = 25,right = 45) == True\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20]],left = 3,right = 19) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30], [35, 40]],left = 2,right = 38) == False\n assert candidate(ranges = [[2, 4], [6, 8], [10, 12], [14, 16], [18, 20], [22, 24]],left = 1,right = 24) == False\n assert candidate(ranges = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23]],left = 1,right = 23) == False\n assert candidate(ranges = [[2, 4], [5, 7], [8, 10], [11, 13], [14, 16]],left = 3,right = 15) == True\n assert candidate(ranges = [[2, 4], [5, 8], [9, 11], [12, 15], [16, 18], [19, 22]],left = 2,right = 22) == True\n assert candidate(ranges = [[2, 4], [6, 8], [10, 12], [14, 16], [18, 20]],left = 3,right = 19) == False\n assert candidate(ranges = [[10, 20], [20, 30], [30, 40]],left = 5,right = 45) == False\n assert candidate(ranges = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14], [16, 17], [19, 20]],left = 1,right = 20) == False\n assert candidate(ranges = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],left = 25,right = 45) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30]],left = 3,right = 28) == False\n assert candidate(ranges = [[3, 7], [8, 12], [13, 17], [18, 22]],left = 5,right = 20) == True\n assert candidate(ranges = [[1, 10], [20, 30], [40, 50]],left = 15,right = 35) == False\n assert candidate(ranges = [[1, 2], [4, 5], [7, 8], [10, 11]],left = 1,right = 11) == False\n assert candidate(ranges = [[2, 4], [7, 9], [12, 14], [17, 19]],left = 4,right = 19) == False\n assert candidate(ranges = [[1, 2], [2, 3], [3, 4], [4, 5]],left = 1,right = 5) == True\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],left = 1,right = 25) == True\n assert candidate(ranges = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],left = 5,right = 45) == True\n assert candidate(ranges = [[1, 3], [4, 7], [8, 10], [11, 15], [16, 20]],left = 5,right = 15) == True\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],left = 1,right = 10) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30], [35, 40]],left = 25,right = 35) == False\n assert candidate(ranges = [[5, 10], [11, 20], [21, 30]],left = 7,right = 29) == True\n assert candidate(ranges = [[1, 25], [26, 50]],left = 1,right = 50) == True\n assert candidate(ranges = [[3, 5], [8, 10], [13, 15], [18, 20]],left = 1,right = 20) == False\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30]],left = 1,right = 30) == False\n assert candidate(ranges = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15]],left = 2,right = 14) == True\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],left = 5,right = 10) == True\n assert candidate(ranges = [[2, 5], [6, 9], [10, 14]],left = 3,right = 13) == True\n assert candidate(ranges = [[1, 10], [15, 25], [30, 40]],left = 5,right = 20) == False\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20]],left = 1,right = 20) == True\n assert candidate(ranges = [[1, 3], [4, 6], [7, 9]],left = 1,right = 9) == True\n assert candidate(ranges = [[2, 4], [6, 8], [10, 12], [14, 16], [18, 20]],left = 1,right = 20) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],left = 2,right = 9) == True\n assert candidate(ranges = [[2, 5], [7, 10], [12, 15], [17, 20]],left = 3,right = 18) == False\n assert candidate(ranges = [[5, 9], [10, 14], [15, 19], [20, 24]],left = 8,right = 22) == True\n assert candidate(ranges = [[1, 4], [5, 8], [9, 12], [13, 16]],left = 3,right = 15) == True\n assert candidate(ranges = [[1, 10], [10, 20], [20, 30], [30, 40]],left = 1,right = 40) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30], [35, 40]],left = 10,right = 35) == False\n"}, "metadata": {"canonical_parameter_names": ["ranges", "left", "right"], "leetcode_dataset_entry_point": "Solution().isCovered", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def isCovered(self, ranges: list[list[int]], left: int, right: int) -> bool:", "container": "Solution", "callable": "isCovered", "parameters": [{"name": "ranges", "type": "list[list[int]]"}, {"name": "left", "type": "int"}, {"name": "right", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1894, "task_id": "find-the-student-that-will-replace-the-chalk", "difficulty": "Medium", "problem_description": "There are n students in a class numbered from 0 to n - 1. The teacher will give each student a problem starting with the student number 0, then the student number 1, and so on until the teacher reaches the student number n - 1. After that, the teacher will restart the process, starting with the student number 0 again.\nYou are given a 0-indexed integer array chalk and an integer k. There are initially k pieces of chalk. When the student number i is given a problem to solve, they will use chalk[i] pieces of chalk to solve that problem. However, if the current number of chalk pieces is strictly less than chalk[i], then the student number i will be asked to replace the chalk.\nReturn the index of the student that will replace the chalk pieces.\n \nExample 1:\n\nInput: chalk = [5,1,5], k = 22\nOutput: 0\nExplanation: The students go in turns as follows:\n- Student number 0 uses 5 chalk, so k = 17.\n- Student number 1 uses 1 chalk, so k = 16.\n- Student number 2 uses 5 chalk, so k = 11.\n- Student number 0 uses 5 chalk, so k = 6.\n- Student number 1 uses 1 chalk, so k = 5.\n- Student number 2 uses 5 chalk, so k = 0.\nStudent number 0 does not have enough chalk, so they will have to replace it.\nExample 2:\n\nInput: chalk = [3,4,1,2], k = 25\nOutput: 1\nExplanation: The students go in turns as follows:\n- Student number 0 uses 3 chalk so k = 22.\n- Student number 1 uses 4 chalk so k = 18.\n- Student number 2 uses 1 chalk so k = 17.\n- Student number 3 uses 2 chalk so k = 15.\n- Student number 0 uses 3 chalk so k = 12.\n- Student number 1 uses 4 chalk so k = 8.\n- Student number 2 uses 1 chalk so k = 7.\n- Student number 3 uses 2 chalk so k = 5.\n- Student number 0 uses 3 chalk so k = 2.\nStudent number 1 does not have enough chalk, so they will have to replace it.\n\n \nConstraints:\n\nchalk.length == n\n1 <= n <= 105\n1 <= chalk[i] <= 105\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(chalk = [1, 2, 3, 4, 5],k = 15) == 0\n assert candidate(chalk = [1],k = 1000000000) == 0\n assert candidate(chalk = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 999999999) == 9\n assert candidate(chalk = [10, 10, 10],k = 100) == 1\n assert candidate(chalk = [100000],k = 1000000000) == 0\n assert candidate(chalk = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1000000000) == 0\n assert candidate(chalk = [3, 4, 1, 2],k = 25) == 1\n assert candidate(chalk = [5, 1, 5],k = 22) == 0\n assert candidate(chalk = [5, 1, 5],k = 1000000000) == 2\n assert candidate(chalk = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],k = 1000000000) == 6\n assert candidate(chalk = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9999999999) == 19\n assert candidate(chalk = [100000, 200000, 300000],k = 1000000000) == 2\n assert candidate(chalk = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 123456789) == 1\n assert candidate(chalk = [5, 8, 12, 3, 7],k = 500000000) == 1\n assert candidate(chalk = [7, 3, 2, 8, 6, 4],k = 987654321) == 4\n assert candidate(chalk = [1, 10, 100, 1000, 10000, 100000],k = 123456789) == 5\n assert candidate(chalk = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000],k = 987654321) == 8\n assert candidate(chalk = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1200000000) == 4\n assert candidate(chalk = [100000, 200000, 300000, 400000, 500000],k = 1000000000) == 4\n assert candidate(chalk = [2, 3, 4, 5, 6, 7, 8, 9, 10],k = 100000000) == 8\n assert candidate(chalk = [10, 20, 30, 40, 50],k = 123456789) == 2\n assert candidate(chalk = [100, 200, 300, 400, 500],k = 999999999) == 3\n assert candidate(chalk = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 123456789) == 9\n assert candidate(chalk = [5, 1, 5, 2, 8],k = 1000000000) == 4\n assert candidate(chalk = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1000000000) == 9\n assert candidate(chalk = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 999999998) == 1\n assert candidate(chalk = [7, 14, 21, 28, 35],k = 123456789) == 4\n assert candidate(chalk = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 999999997) == 2\n assert candidate(chalk = [12345, 54321, 23456, 65432, 34567],k = 1234567890) == 3\n assert candidate(chalk = [5, 8, 3, 7, 2],k = 1000000001) == 0\n assert candidate(chalk = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31],k = 1000000000) == 0\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 543210) == 7\n assert candidate(chalk = [5, 1, 5, 2, 6],k = 1000000000) == 4\n assert candidate(chalk = [5, 8, 3, 7, 2],k = 500000000) == 0\n assert candidate(chalk = [5, 8, 15, 3],k = 1000000007) == 2\n assert candidate(chalk = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 8675309) == 6\n assert candidate(chalk = [5, 3, 7, 11],k = 50) == 3\n assert candidate(chalk = [987654321, 123456789, 987654321, 123456789],k = 2000000000) == 2\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 897654321) == 12\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 500000000) == 2\n assert candidate(chalk = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 900000000) == 5\n assert candidate(chalk = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1000000000) == 5\n assert candidate(chalk = [10, 20, 30, 40, 50],k = 999999999) == 3\n assert candidate(chalk = [100000, 100000, 100000, 100000, 100000],k = 950000000) == 0\n assert candidate(chalk = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 999999999) == 9\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1000000000) == 8\n assert candidate(chalk = [100, 200, 300, 400, 500],k = 1000000001) == 4\n assert candidate(chalk = [99999, 99998, 99997, 99996, 99995],k = 99999999999) == 0\n assert candidate(chalk = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 1700000000) == 26\n assert candidate(chalk = [2, 4, 6, 8, 10],k = 999999999) == 2\n assert candidate(chalk = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 987654321) == 1\n assert candidate(chalk = [100000, 200000, 300000, 400000],k = 1234567890) == 2\n assert candidate(chalk = [100000000, 200000000, 300000000],k = 1000000000) == 2\n assert candidate(chalk = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 999999999) == 7\n assert candidate(chalk = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9876543210) == 5\n assert candidate(chalk = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 1300000000) == 12\n assert candidate(chalk = [100, 200, 300, 400, 500],k = 9876543210) == 1\n assert candidate(chalk = [5, 8, 12, 3, 6],k = 1000000000) == 2\n assert candidate(chalk = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 800000000) == 8\n assert candidate(chalk = [99999, 99998, 99997, 99996, 99995],k = 1000000000) == 0\n assert candidate(chalk = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 987654321) == 2\n assert candidate(chalk = [1, 10, 100, 1000, 10000, 100000],k = 999999999) == 3\n assert candidate(chalk = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],k = 123456789) == 8\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 987654321) == 18\n assert candidate(chalk = [100, 200, 300, 400, 500],k = 1000000000) == 4\n assert candidate(chalk = [100000000, 200000000, 300000000, 400000000, 500000000],k = 1000000000) == 4\n assert candidate(chalk = [12345, 67890, 13579, 24680, 97531],k = 987654321) == 4\n assert candidate(chalk = [50000, 50000, 50000, 50000, 50000],k = 1000000000) == 0\n assert candidate(chalk = [3, 6, 1, 8, 4, 7],k = 999999999) == 3\n assert candidate(chalk = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100000000) == 9\n assert candidate(chalk = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 543210987) == 8\n assert candidate(chalk = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 1073741823) == 8\n assert candidate(chalk = [10, 15, 20, 25, 30],k = 123456789) == 4\n assert candidate(chalk = [3, 4, 1, 2, 5, 7, 8, 9, 10, 11],k = 987654321) == 5\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 1600000000) == 24\n assert candidate(chalk = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 500000000) == 0\n assert candidate(chalk = [100000, 200000, 300000, 400000],k = 1000000000000) == 0\n assert candidate(chalk = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 456789123) == 7\n assert candidate(chalk = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 999999999) == 8\n assert candidate(chalk = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 9876543210) == 7\n assert candidate(chalk = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 1000000000) == 2\n assert candidate(chalk = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 1000000000) == 0\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 876543210) == 12\n assert candidate(chalk = [100000, 100000, 100000, 100000, 100000],k = 999999999) == 4\n assert candidate(chalk = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 1800000000) == 13\n assert candidate(chalk = [5000, 10000, 15000, 20000, 25000],k = 500000000) == 4\n assert candidate(chalk = [10, 20, 30, 40, 50],k = 9999999999) == 3\n assert candidate(chalk = [100, 200, 300, 400, 500],k = 1500000000) == 0\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 500000000) == 2\n assert candidate(chalk = [100000000, 200000000, 300000000],k = 6000000000) == 0\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 123456789) == 11\n assert candidate(chalk = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995, 5],k = 1000000000) == 0\n"}, "metadata": {"canonical_parameter_names": ["chalk", "k"], "leetcode_dataset_entry_point": "Solution().chalkReplacer", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def chalkReplacer(self, chalk: list[int], k: int) -> int:", "container": "Solution", "callable": "chalkReplacer", "parameters": [{"name": "chalk", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1895, "task_id": "largest-magic-square", "difficulty": "Medium", "problem_description": "A k x k magic square is a k x k grid filled with integers such that every row sum, every column sum, and both diagonal sums are all equal. The integers in the magic square do not have to be distinct. Every 1 x 1 grid is trivially a magic square.\nGiven an m x n integer grid, return the size (i.e., the side length k) of the largest magic square that can be found within this grid.\n \nExample 1:\n\n\nInput: grid = [[7,1,4,5,6],[2,5,1,6,4],[1,5,4,3,2],[1,2,7,3,4]]\nOutput: 3\nExplanation: The largest magic square has a size of 3.\nEvery row sum, column sum, and diagonal sum of this magic square is equal to 12.\n- Row sums: 5+1+6 = 5+4+3 = 2+7+3 = 12\n- Column sums: 5+5+2 = 1+4+7 = 6+3+3 = 12\n- Diagonal sums: 5+4+3 = 6+4+2 = 12\n\nExample 2:\n\n\nInput: grid = [[5,1,3,1],[9,3,3,1],[1,3,3,8]]\nOutput: 2\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 50\n1 <= grid[i][j] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[10, 20], [15, 25]]) == 1\n assert candidate(grid = [[7, 1, 4, 5, 6], [2, 5, 1, 6, 4], [1, 5, 4, 3, 2], [1, 2, 7, 3, 4]]) == 3\n assert candidate(grid = [[6, 3, 2, 8, 1, 9, 3, 2], [4, 7, 5, 4, 5, 3, 4, 7], [8, 4, 6, 8, 7, 2, 8, 1], [2, 9, 1, 5, 8, 7, 7, 3], [5, 4, 3, 1, 9, 4, 6, 3], [2, 8, 4, 9, 7, 8, 4, 1], [7, 8, 4, 5, 3, 9, 6, 4], [6, 3, 5, 9, 8, 7, 1, 9]]) == 1\n assert candidate(grid = [[8]]) == 1\n assert candidate(grid = [[16, 23, 17], [78, 32, 21], [17, 26, 79]]) == 1\n assert candidate(grid = [[5, 1, 3, 1], [9, 3, 3, 1], [1, 3, 3, 8]]) == 2\n assert candidate(grid = [[4, 3, 8, 4], [9, 5, 1, 9], [2, 7, 6, 2]]) == 3\n assert candidate(grid = [[16, 23, 17], [78, 32, 21], [17, 26, 78]]) == 1\n assert candidate(grid = [[1, 2], [3, 4]]) == 1\n assert candidate(grid = [[4, 9, 2], [3, 5, 7], [8, 1, 6]]) == 3\n assert candidate(grid = [[8, 1, 6, 13, 10], [3, 5, 7, 14, 11], [4, 9, 2, 15, 12], [15, 17, 24, 4, 5], [16, 23, 19, 6, 18]]) == 3\n assert candidate(grid = [[47, 36, 19, 73], [60, 22, 43, 19], [71, 23, 44, 39], [82, 24, 45, 40]]) == 1\n assert candidate(grid = [[2, 15, 13, 9], [16, 4, 6, 12], [9, 14, 7, 8], [10, 5, 11, 3]]) == 1\n assert candidate(grid = [[1, 16, 15, 4, 12], [8, 9, 10, 11, 14], [17, 2, 13, 14, 3], [12, 7, 6, 5, 18], [13, 8, 1, 12, 17]]) == 1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 1\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == 5\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4, 9, 2], [3, 5, 7, 8, 1, 6, 3, 5, 7], [4, 9, 2, 3, 5, 7, 4, 9, 2], [3, 5, 7, 4, 9, 2, 3, 5, 7], [8, 1, 6, 4, 9, 2, 3, 5, 7], [3, 5, 7, 8, 1, 6, 3, 5, 7], [4, 9, 2, 3, 5, 7, 8, 1, 6], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 3, 5, 7, 3, 5, 7]]) == 3\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]) == 1\n assert candidate(grid = [[3, 8, 4, 6], [6, 5, 7, 10], [5, 7, 8, 9], [8, 4, 5, 10]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [4, 3, 8, 1, 6, 7, 2, 9, 5], [9, 5, 1, 8, 4, 2, 7, 6, 3], [7, 9, 4, 8, 5, 2, 6, 3, 1], [3, 6, 7, 2, 9, 5, 8, 1, 4], [5, 8, 1, 9, 3, 6, 4, 7, 2], [2, 4, 6, 3, 1, 8, 5, 9, 7], [8, 7, 5, 6, 4, 9, 1, 2, 3], [6, 1, 9, 7, 2, 3, 5, 8, 4]]) == 1\n assert candidate(grid = [[5, 15, 25, 35, 45], [10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65]]) == 1\n assert candidate(grid = [[3, 8, 1, 2, 7], [8, 1, 2, 7, 3], [1, 2, 7, 3, 8], [2, 7, 3, 8, 1], [7, 3, 8, 1, 2]]) == 1\n assert candidate(grid = [[17, 24, 1, 8, 15], [23, 5, 7, 14, 16], [4, 6, 13, 20, 22], [10, 12, 19, 21, 3], [11, 18, 25, 2, 9]]) == 5\n assert candidate(grid = [[37, 21, 15, 13, 31], [21, 37, 31, 15, 13], [15, 21, 37, 13, 31], [31, 13, 21, 37, 15], [13, 31, 15, 21, 37]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[16, 3, 2, 13], [5, 10, 11, 8], [9, 6, 7, 12], [4, 15, 14, 1]]) == 4\n assert candidate(grid = [[20, 30, 25, 15, 10], [35, 25, 30, 20, 15], [20, 25, 30, 15, 35], [15, 30, 20, 25, 20], [10, 15, 25, 30, 20]]) == 1\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2, 1, 9], [7, 6, 5, 4, 3, 2, 1, 9, 8], [6, 5, 4, 3, 2, 1, 9, 8, 7], [5, 4, 3, 2, 1, 9, 8, 7, 6], [4, 3, 2, 1, 9, 8, 7, 6, 5], [3, 2, 1, 9, 8, 7, 6, 5, 4], [2, 1, 9, 8, 7, 6, 5, 4, 3], [1, 9, 8, 7, 6, 5, 4, 3, 2]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[16, 3, 2, 13], [5, 10, 11, 8], [9, 6, 7, 12], [4, 15, 14, 1]]) == 4\n assert candidate(grid = [[2, 7, 6, 9, 5], [9, 5, 1, 9, 7], [4, 3, 8, 4, 6], [1, 8, 3, 8, 2], [5, 4, 7, 5, 9]]) == 3\n assert candidate(grid = [[2, 7, 6], [9, 5, 1], [4, 3, 8], [15, 16, 17], [18, 19, 20]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 1\n assert candidate(grid = [[16, 23, 17], [78, 32, 21], [17, 23, 29]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == 5\n assert candidate(grid = [[2, 7, 6, 1, 8], [9, 5, 1, 3, 4], [8, 1, 6, 7, 2], [4, 9, 2, 8, 5], [3, 4, 5, 9, 6]]) == 1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == 1\n assert candidate(grid = [[3, 8, 4], [1, 6, 7], [6, 7, 2], [8, 1, 6], [7, 5, 3], [4, 9, 2]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4], [1, 6, 7, 8, 5, 4, 3], [6, 7, 2, 1, 3, 4, 5], [3, 5, 7, 4, 6, 8, 1], [5, 7, 4, 6, 8, 1, 3], [7, 4, 6, 8, 1, 3, 5], [4, 6, 8, 1, 3, 5, 7]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 7, 6, 3, 5, 9, 4, 8, 1], [4, 9, 2, 3, 5, 7, 8, 1, 6], [3, 5, 7, 4, 9, 2, 1, 6, 8], [8, 1, 6, 7, 2, 9, 4, 3, 5], [5, 4, 3, 6, 9, 2, 7, 8, 1], [6, 8, 1, 5, 3, 7, 2, 9, 4], [7, 6, 3, 1, 8, 4, 5, 2, 9]]) == 3\n assert candidate(grid = [[20, 9, 17, 12, 15, 14], [13, 18, 8, 11, 7, 10], [16, 21, 2, 14, 18, 12], [4, 19, 15, 22, 10, 6], [1, 12, 20, 17, 9, 23], [5, 24, 11, 23, 16, 4]]) == 1\n assert candidate(grid = [[3, 7, 5, 9, 11, 12], [10, 6, 14, 3, 13, 15], [4, 16, 1, 8, 17, 18], [9, 20, 12, 15, 5, 2], [13, 11, 19, 2, 6, 16], [17, 4, 22, 18, 10, 7]]) == 1\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70], [40, 50, 60, 70, 80]]) == 1\n assert candidate(grid = [[17, 24, 1, 8, 15], [23, 5, 7, 14, 16], [4, 6, 13, 20, 22], [10, 12, 19, 21, 3], [11, 18, 25, 2, 9]]) == 5\n assert candidate(grid = [[3, 5, 7, 9, 11], [6, 12, 4, 8, 2], [15, 1, 13, 3, 17], [10, 14, 5, 19, 16], [21, 25, 23, 20, 22]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4, 9, 2], [3, 5, 7, 8, 1, 6, 9, 2, 4], [4, 9, 2, 5, 8, 1, 6, 3, 7], [9, 2, 4, 7, 3, 5, 1, 6, 8], [1, 6, 8, 2, 4, 9, 3, 7, 5], [2, 4, 9, 6, 8, 3, 7, 5, 1], [7, 3, 5, 4, 9, 2, 8, 1, 6], [5, 8, 1, 9, 6, 4, 2, 7, 3], [6, 7, 3, 1, 2, 8, 5, 4, 9]]) == 3\n assert candidate(grid = [[2, 7, 6, 9, 5, 3], [9, 5, 1, 4, 1, 1], [4, 3, 8, 2, 4, 1], [8, 1, 6, 3, 5, 2], [3, 5, 7, 5, 3, 1], [6, 9, 2, 1, 7, 5]]) == 3\n assert candidate(grid = [[8, 1, 6, 7, 10, 12], [3, 5, 7, 8, 1, 11], [4, 9, 2, 13, 6, 7], [15, 14, 13, 12, 11, 10], [9, 8, 7, 6, 5, 4], [1, 2, 3, 4, 3, 2]]) == 3\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[30, 20, 10, 40, 50], [25, 15, 5, 35, 45], [20, 10, 0, 30, 40], [15, 5, 40, 25, 35], [10, 0, 35, 20, 25]]) == 1\n assert candidate(grid = [[4, 3, 8, 4], [9, 5, 1, 9], [2, 7, 6, 2], [6, 1, 8, 6], [7, 5, 3, 7]]) == 3\n assert candidate(grid = [[30, 5, 25], [5, 25, 30], [25, 30, 5], [5, 30, 25], [30, 25, 5], [25, 5, 30]]) == 1\n assert candidate(grid = [[35, 1, 6, 26, 19, 24], [3, 32, 7, 21, 23, 25], [31, 9, 2, 22, 27, 20], [8, 28, 33, 17, 10, 15], [30, 5, 34, 12, 14, 18], [4, 36, 29, 13, 16, 11]]) == 3\n assert candidate(grid = [[7, 12, 1, 14, 11, 2, 5], [13, 8, 10, 3, 4, 6, 15], [1, 14, 11, 2, 5, 7, 12], [13, 8, 10, 3, 4, 6, 15], [7, 12, 1, 14, 11, 2, 5], [13, 8, 10, 3, 4, 6, 15], [1, 14, 11, 2, 5, 7, 12]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(grid = [[25, 7, 2, 17], [14, 20, 16, 15], [13, 9, 6, 19], [18, 8, 23, 12]]) == 1\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[3, 10, 6, 7, 9], [1, 5, 7, 12, 8], [8, 11, 2, 5, 10], [9, 4, 3, 11, 13], [6, 7, 8, 10, 4]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 1\n assert candidate(grid = [[4, 9, 2, 16], [3, 5, 7, 12], [8, 1, 6, 10], [13, 14, 15, 11]]) == 3\n assert candidate(grid = [[3, 8, 4, 7, 2, 9], [2, 7, 3, 8, 4, 1], [1, 6, 2, 7, 3, 5], [5, 1, 6, 2, 7, 4], [4, 5, 1, 6, 2, 8], [8, 4, 5, 1, 6, 3]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4], [1, 6, 7, 8, 5, 3, 4], [6, 7, 2, 1, 9, 4, 3], [1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 8], [3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 1]]) == 1\n assert candidate(grid = [[3, 10, 4, 2, 15], [6, 8, 12, 14, 1], [9, 11, 5, 13, 7], [14, 1, 10, 6, 12], [16, 15, 9, 11, 5]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4, 9, 2], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 8, 1, 6, 3, 5, 7], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 8, 1, 6, 3, 5, 7], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 8, 1, 6, 3, 5, 7], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 8, 1, 6, 3, 5, 7]]) == 3\n assert candidate(grid = [[4, 3, 8, 4], [9, 5, 1, 9], [2, 7, 6, 2], [6, 1, 8, 6]]) == 3\n assert candidate(grid = [[2, 7, 6, 9, 5, 1], [9, 5, 1, 4, 3, 8], [4, 3, 8, 2, 4, 9], [3, 8, 4, 8, 4, 3], [8, 1, 6, 6, 7, 2], [6, 7, 2, 9, 5, 1]]) == 3\n assert candidate(grid = [[3, 8, 4, 8, 4], [1, 1, 6, 7, 2], [2, 9, 6, 2, 7], [8, 2, 9, 1, 8], [4, 8, 9, 2, 8]]) == 1\n assert candidate(grid = [[47, 38, 29, 20, 11, 2], [46, 37, 30, 21, 12, 3], [45, 36, 31, 22, 13, 4], [44, 35, 32, 23, 14, 5], [43, 34, 33, 24, 15, 6], [42, 39, 40, 25, 16, 7]]) == 1\n assert candidate(grid = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 1, 4, 3, 5], [3, 5, 1, 4, 2], [4, 3, 5, 2, 1]]) == 1\n assert candidate(grid = [[15, 15, 15, 15], [15, 15, 15, 15], [15, 15, 15, 15], [15, 15, 15, 15]]) == 4\n assert candidate(grid = [[2, 7, 6, 1, 8, 1], [8, 1, 6, 7, 2, 8], [6, 7, 2, 8, 1, 6], [1, 8, 1, 6, 7, 2], [8, 1, 6, 7, 2, 8], [6, 7, 2, 8, 1, 6]]) == 1\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]]) == 1\n assert candidate(grid = [[10, 20, 30, 40], [15, 25, 35, 45], [20, 30, 40, 50], [25, 35, 45, 55], [30, 40, 50, 60]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().largestMagicSquare", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def largestMagicSquare(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "largestMagicSquare", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1896, "task_id": "minimum-cost-to-change-the-final-value-of-expression", "difficulty": "Hard", "problem_description": "You are given a valid boolean expression as a string expression consisting of the characters '1','0','&' (bitwise AND operator),'|' (bitwise OR operator),'(', and ')'.\n\nFor example, \"()1|1\" and \"(1)&()\" are not valid while \"1\", \"(((1))|(0))\", and \"1|(0&(1))\" are valid expressions.\n\nReturn the minimum cost to change the final value of the expression.\n\nFor example, if expression = \"1|1|(0&0)&1\", its value is 1|1|(0&0)&1 = 1|1|0&1 = 1|0&1 = 1&1 = 1. We want to apply operations so that the new expression evaluates to 0.\n\nThe cost of changing the final value of an expression is the number of operations performed on the expression. The types of operations are described as follows:\n\nTurn a '1' into a '0'.\nTurn a '0' into a '1'.\nTurn a '&' into a '|'.\nTurn a '|' into a '&'.\n\nNote: '&' does not take precedence over '|' in the order of calculation. Evaluate parentheses first, then in left-to-right order.\n \nExample 1:\n\nInput: expression = \"1&(0|1)\"\nOutput: 1\nExplanation: We can turn \"1&(0|1)\" into \"1&(0&1)\" by changing the '|' to a '&' using 1 operation.\nThe new expression evaluates to 0. \n\nExample 2:\n\nInput: expression = \"(0&0)&(0&0&0)\"\nOutput: 3\nExplanation: We can turn \"(0&0)&(0&0&0)\" into \"(0|1)|(0&0&0)\" using 3 operations.\nThe new expression evaluates to 1.\n\nExample 3:\n\nInput: expression = \"(0|(1|0&1))\"\nOutput: 1\nExplanation: We can turn \"(0|(1|0&1))\" into \"(0|(0|0&1))\" using 1 operation.\nThe new expression evaluates to 0.\n \nConstraints:\n\n1 <= expression.length <= 105\nexpression only contains '1','0','&','|','(', and ')'\nAll parentheses are properly matched.\nThere will be no empty parentheses (i.e: \"()\" is not a substring of expression).\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(expression = \"(1&(0|1&(0|1)))\") == 1\n assert candidate(expression = \"(0&1&1)|(0|1)\") == 1\n assert candidate(expression = \"(1&1)|(0&0)\") == 1\n assert candidate(expression = \"(1&((0&0)|(1|1)))\") == 1\n assert candidate(expression = \"1&(1&(1&(1&1)))\") == 1\n assert candidate(expression = \"((1|1)&(0|0))\") == 1\n assert candidate(expression = \"1&(0|1)\") == 1\n assert candidate(expression = \"((1&1)|(0&0))\") == 1\n assert candidate(expression = \"(1&1&1)|(1|1|1)\") == 2\n assert candidate(expression = \"1|1|0&1\") == 1\n assert candidate(expression = \"(0&0)|((1&1)|(0&1))\") == 1\n assert candidate(expression = \"(1&((1&1)&(1&1)))\") == 1\n assert candidate(expression = \"((1&0)|(1&1))\") == 1\n assert candidate(expression = \"(0&0&0)|(0|0|0)\") == 1\n assert candidate(expression = \"0|1&(1|0)&1\") == 1\n assert candidate(expression = \"1|1|(0&0)&1\") == 1\n assert candidate(expression = \"(((0|1)&1)|(0&0))\") == 1\n assert candidate(expression = \"(1&((0&1)|0))\") == 1\n assert candidate(expression = \"(0|(1|0&1))\") == 1\n assert candidate(expression = \"(0|((0|0)|(0|0)))\") == 1\n assert candidate(expression = \"(1&0)|(1&1)\") == 1\n assert candidate(expression = \"(0&0)&(0&0&0)\") == 3\n assert candidate(expression = \"(0|(0|(0|(0|0))))\") == 1\n assert candidate(expression = \"((1|0)&(0|1))\") == 1\n assert candidate(expression = \"(1|0|0)&(1&1)\") == 1\n assert candidate(expression = \"((1&0)|(1|0))\") == 1\n assert candidate(expression = \"(1&(1&(1&(1&1))))\") == 1\n assert candidate(expression = \"(1&1&1)|(0|0|0)\") == 1\n assert candidate(expression = \"(1|(0&(1|0)))\") == 1\n assert candidate(expression = \"(0&1)|((1|0)&(0|1))\") == 1\n assert candidate(expression = \"0|(0|(0|(0|0)))\") == 1\n assert candidate(expression = \"(1&(0|(1&0)))\") == 1\n assert candidate(expression = \"((1&(1|0))&(0|1))\") == 1\n assert candidate(expression = \"(0&(((0|1)&(1|0))|((1&0)|(0|1))))\") == 1\n assert candidate(expression = \"((0&(((1|0)|(0&1))&(1&1)))|((1|0)|(0|1)))&(1|0)\") == 1\n assert candidate(expression = \"((0&(1|0))&(0&(1|0))&(0&(1|0)))\") == 2\n assert candidate(expression = \"(0|((1&0)|(0|1)&((1|0)&(1|0))))\") == 1\n assert candidate(expression = \"((1&((1|0)|(0|1)))&((0&0)|(1&(1&(1&1)))))\") == 1\n assert candidate(expression = \"((0|1)&(1|(0|1&0))&(1|(0&(1|0))))\") == 1\n assert candidate(expression = \"((1&((0|1)&(0|1)))|((0&(1|0))&(1|0)))\") == 1\n assert candidate(expression = \"(((0|0)|(1|1))&((0|0)|(1|1))&((0|0)|(1|1))&((0|0)|(1|1)))\") == 1\n assert candidate(expression = \"(((1|0)|(0&1))&((0|1)|(0&1))&((1|0)|(0&1))&((0|1)|(0&1)))\") == 1\n assert candidate(expression = \"((0&0)&(0&0)&(1|1)&((0|0)|(1|1)))\") == 1\n assert candidate(expression = \"((1&0)|(0|1)&((1|0)&(1|0)))\") == 1\n assert candidate(expression = \"((1|0)&(1&0)|(0|1)&(1|0))\") == 1\n assert candidate(expression = \"((1|0)|(0&1)&(0|1))\") == 1\n assert candidate(expression = \"(1|(((1|0)&(0|1)))&(((0&1)|(1&1))&(1|0)))|(0|1)\") == 2\n assert candidate(expression = \"((0&(1|0)&(1|0))|(0&(0|1)&(0|1)))\") == 1\n assert candidate(expression = \"(((0|1)&(0|1))&((1&0)|(1&0))&((0|1)&(0|1))&((1&0)|(1&0)))\") == 2\n assert candidate(expression = \"(((1|1)|(0|0))&(1&(1&(1&1))))\") == 1\n assert candidate(expression = \"((1&0)|((0&1)|(1|((1&0)|(0|1)))))\") == 1\n assert candidate(expression = \"(((0&(1|0))&(1&((0&1)|(1|0))))|((1&0)|(0&((1&0)|(0&1)))))\") == 1\n assert candidate(expression = \"(((1|0)&(0|1))&((1|0)&(0|1)))|(1&(0|((1&1)|(0&0))))\") == 2\n assert candidate(expression = \"(((0|1)&(1|0))|((1&(0|1))|(0&1)))\") == 2\n assert candidate(expression = \"(0|((1&0)|(0|1)&((1|0)|(0|1)&(1|0))))\") == 1\n assert candidate(expression = \"(((0|1)|(1&0))&((0&1)|(1|0)))\") == 1\n assert candidate(expression = \"((1&0)|(1&0)|(0|1)&(0|1))\") == 1\n assert candidate(expression = \"(1|(((1|0)&(1|0))|((0&1)|(0&1))))\") == 2\n assert candidate(expression = \"(1&(0|((1&1)|(0|0))))\") == 1\n assert candidate(expression = \"(1&(((0|1)&(0|1))&((1|0)|(0|1)&(1|0))))\") == 1\n assert candidate(expression = \"((0&((0&1)|(1|0)))|((1&((0&1)|(1|0)))&(1&(0&(1|0)))))\") == 1\n assert candidate(expression = \"((1&0)|(0|1)&((1|0)|(0|1)&(1|0)))\") == 1\n assert candidate(expression = \"(1|(0&(1|0))|(0&1))\") == 1\n assert candidate(expression = \"(0|((1&1)|(0&0)))&(1&(0|((1&1)|(0&0))))\") == 1\n assert candidate(expression = \"(1|(((0&(1|0))|(1&0))&((1|0)&(0|1))))\") == 1\n assert candidate(expression = \"(((1|0)&(0|1))|((0&1)|(1|0))|((1|0)&(0|1))|((0&1)|(1|0)))\") == 2\n assert candidate(expression = \"(((1&0)|(0&1))&((0&(1|0))|(1&((0&1)|(1|0)))))\") == 1\n assert candidate(expression = \"(((1&0)|(0|1))&((1|0)|(0&1)))\") == 1\n assert candidate(expression = \"((1&0)|(1&1))&(1|0)\") == 1\n assert candidate(expression = \"(((1|1)|(0&0))&((1&1)|(0|0))|(1|0))\") == 2\n assert candidate(expression = \"((1|((0&0)|(1&1)))&(1|0))|((0|1)&(1&1))\") == 2\n assert candidate(expression = \"(((1|0)&1)|(0&(1|0)))\") == 1\n assert candidate(expression = \"((0&1)|(1&(0|1)))&((1&0)|(1|1))\") == 1\n assert candidate(expression = \"(1&((0|1)&(0|1))&(0|1))\") == 1\n assert candidate(expression = \"((0|1)|(1|0)&(0|1)&(0|1))&((0|1)|(0|1))\") == 1\n assert candidate(expression = \"(1&((0&1)|(0&(1|0))&(1|0)))\") == 1\n assert candidate(expression = \"(1|((1|0)&(0|1)))|(((0&1)|(1&1))&(1|0))\") == 2\n assert candidate(expression = \"((0&((1|0)&(0|1)))|((0&(1|0))&(1|0)))\") == 1\n assert candidate(expression = \"(((0|1)&(0|1))&((1|0)|(0|1)&(1|0)))\") == 1\n assert candidate(expression = \"(1&(((0&0)|(1|1))&(1&((0&0)|(1|1)))))|((1&(0|((1&1)|(0&0))))&(1|0))\") == 2\n assert candidate(expression = \"(((1&1)&(0|0))|(1|0)&((1&0)|(0|1))&(1|0))\") == 1\n assert candidate(expression = \"((1|(0&(1&0)))&(0|(1|0)))\") == 1\n assert candidate(expression = \"((1&(0|1))|(0&(1|0)))\") == 1\n assert candidate(expression = \"(((0|1)|(0&1))&(1|(0&0)&(1|0)))\") == 1\n assert candidate(expression = \"(1|((0|1)&(0&1))|(1&0))\") == 1\n assert candidate(expression = \"((1&0)|(1&(0|1))|(0&(1|0)))\") == 1\n assert candidate(expression = \"((0|(1&0))&(((1|0)&(0|1))|((0&1)|(1|0))))\") == 1\n assert candidate(expression = \"(1&(((0|1)|(1&0))&(0|1)))\") == 1\n assert candidate(expression = \"(((1&(0|1))&((1&0)|(0&1)))|((0&(1|0))&(1&((0&1)|(1|0)))))\") == 1\n assert candidate(expression = \"((0|1)|((1&(0|1))&(0|1)))\") == 2\n assert candidate(expression = \"((0&1)|(0&1)|(0&1)|(0&1))\") == 1\n assert candidate(expression = \"(0|(1&0)|(0|1)&(1|0))\") == 1\n assert candidate(expression = \"((1&(0|((1|0)&(1|0))))&((1&(0|((1|0)&(1|0))))&((1&(0|((1|0)&(1|0))))))\") == 1\n assert candidate(expression = \"(1|((0&0)|(1&(0|1))))\") == 2\n assert candidate(expression = \"(0|((1&((0|1)|(1|0)))&(1|0)))\") == 1\n assert candidate(expression = \"((0|((1&0)|(0|1)))&(((1|0)&(0|1))|((0&1)|(1|0))))\") == 1\n assert candidate(expression = \"(1&((0|0)|(1&0))&(0&(1|0))&(0|1))\") == 1\n assert candidate(expression = \"(((1|1)|(0|0))&(1&0))|(0|1)\") == 1\n assert candidate(expression = \"(1&(0|((0|0)&(0|0))))|((1|0)&(1&1))\") == 1\n assert candidate(expression = \"((1&(0|1))&(1|0))\") == 1\n assert candidate(expression = \"(1|((1|0)|(0|1))&(0&1))\") == 1\n assert candidate(expression = \"((1&1)|(0&(1|0)))\") == 1\n assert candidate(expression = \"(0|((1&0)|(0|1)&(1|0)))\") == 1\n assert candidate(expression = \"(1|((0&(1|0))&(1&(0|1&0))))\") == 1\n assert candidate(expression = \"((0&(1|1))|((1&0)|(0&1)))\") == 1\n assert candidate(expression = \"(1&(((1|0)|(0&1))&(1&1)))|((0|1)&(1&1))\") == 2\n assert candidate(expression = \"(((0|1)&(0|1))&((1|0)&(1|0)))\") == 1\n assert candidate(expression = \"(((0|1)&(1|0))&((1&0)|(0|1)))\") == 1\n assert candidate(expression = \"((1&((0&1)|(1|0)))&((1|0)|(0&(1|0))))|((1&(0|((1&1)|(0&0))))&(1|0))\") == 2\n assert candidate(expression = \"(((0&0)|(1&(0|1)))&((1|0)|(0&((0&1)|(1|0)))))\") == 1\n assert candidate(expression = \"(((0|1)&(1|0))|((1&0)|(0&1)))\") == 1\n assert candidate(expression = \"(1&((1|0)|(0|1))&(0&(1|0))&(0|1)&((0|0)&(1|1)))\") == 2\n assert candidate(expression = \"((1&(1&(1&0)))|((0|1)|(0&1)))\") == 1\n assert candidate(expression = \"((1|0)&(0|1)|(0&(1|0)))\") == 1\n assert candidate(expression = \"(0|((1|0)&(0|1))&(1|0))\") == 1\n assert candidate(expression = \"((1&(0|((1&0)|(0&1))))&((0&(1|0))|(1&(0|1))))\") == 1\n assert candidate(expression = \"((1&(0|1))&(1&(0|1))&(1&(0|1))&(1&(0|1)))\") == 1\n assert candidate(expression = \"(1|((0&(1|0))|(1&(0|1))))\") == 2\n assert candidate(expression = \"((1|((0&(1&0))|(0|1)))&(0&((0&(1|0))|(1&(0|1)))))\") == 1\n assert candidate(expression = \"(0&((1&0)|(1|(0&1&0))))\") == 1\n assert candidate(expression = \"(1|((0&0)&(0|0))|(0|(1&1)))\") == 2\n assert candidate(expression = \"(((1|1)&(0&0))|(1&0))\") == 1\n assert candidate(expression = \"(((0|1)&(0|1))&(1|0)&(1|0))\") == 1\n assert candidate(expression = \"((0|0)&(0|0)&(1|1)|(0|0)&(0|0))\") == 2\n assert candidate(expression = \"(0&(((1|0)|(0&1))&(1&1)))|((1|0)|(0|1))\") == 1\n assert candidate(expression = \"((0&(0|1))|(0&(0|1))|(0&(0|1))|(0&(0|1)))\") == 1\n assert candidate(expression = \"((1&0)|(0|1)&(1|0))\") == 1\n assert candidate(expression = \"((0&1)|(1&(1|0)))\") == 1\n assert candidate(expression = \"((1&(1&1))|((0|0)|(0&0)))\") == 1\n assert candidate(expression = \"((1|(0&0)&(1|0))|(0&(0|1)&(0|1))&(0&(0|1)&(0|1)))\") == 1\n assert candidate(expression = \"(((1&0)|(0&1))&((1&(0|1))|(0&1)))\") == 1\n assert candidate(expression = \"((0|((1&(0|1))|(0&(1|0))))&(1&((0&1)|(1|0))))\") == 1\n assert candidate(expression = \"(((0|0)&(0|0))&((0|0)|(0|0)))\") == 2\n assert candidate(expression = \"(1&((1&((0&0)|(1|1)))|((1|(0|1))&(0&0))))\") == 1\n assert candidate(expression = \"((0&((1|0)|(0|1)))|((1&(0|1))&(0|1)))\") == 1\n assert candidate(expression = \"(((0&(1|0))|(1&0))&((1|0)&(0|1)))\") == 1\n assert candidate(expression = \"(((1&(0|1))|(0&(1|0)))|((1&(0|1))&(0|1)))\") == 2\n assert candidate(expression = \"((0&(0&0))|((1|1)&(1|1)))\") == 1\n assert candidate(expression = \"((1&(0|1))|(0&(0|1)&(0|1)))\") == 1\n assert candidate(expression = \"(1&((0|1)|(0|1))&(0&((1|0)|(1|0))))\") == 1\n assert candidate(expression = \"(((1&(0|1))|(0&1))&(1&((0|1)|(0&(1|0)))))\") == 1\n assert candidate(expression = \"(((1|0)&(0|1))|(0&(1|0))&(1&(0|1&0)))\") == 1\n assert candidate(expression = \"((1&(0|1))|(1&0))\") == 1\n assert candidate(expression = \"(1&(((0|1)&(0|1))&((1|0)&(1|0))))\") == 1\n assert candidate(expression = \"(1&(0|1&(0|1&(1|0))))\") == 1\n assert candidate(expression = \"(((1|0)|(0&1))&((1|0)|(0&1))&((1|0)|(0&1))&((1|0)|(0&1)))\") == 1\n assert candidate(expression = \"((((0|0)|(1&1))&((0|1)&(1|0)))|((0&1)|(1|0)))\") == 2\n assert candidate(expression = \"(1|((0&0)|(1&0))&(0&(1|0))&(0|1)&((1|0)|(0|1)))\") == 1\n assert candidate(expression = \"(((0|1)&(1|0))&(0|1))\") == 1\n assert candidate(expression = \"(((1|0)|(0&1))&((1&0)|(0|1)))\") == 1\n assert candidate(expression = \"(1|(((0|1)&(1|0))|(0&(1|0))))\") == 2\n assert candidate(expression = \"(1|(((1|0)&(0|1))|(1&(0&1))))\") == 2\n assert candidate(expression = \"(((1&0)|(1|0))&((1&1)|(0|0)))\") == 1\n assert candidate(expression = \"((0|1)|((0&1)&(1|0))&(1&(0|((1&1)|(0&0)))))\") == 1\n assert candidate(expression = \"(1|(((0&0)&(0|0))|((1|1)|(1&1))))\") == 2\n assert candidate(expression = \"(0&(((1|0)|(0|1))&(0|1))&(1|0))\") == 1\n assert candidate(expression = \"((0|0)|(1&1))&(((1|0)&(0|1))|(1&1))\") == 1\n assert candidate(expression = \"((1&(0|1))|((0&1)|((1|0)&(0|1))))\") == 2\n assert candidate(expression = \"(((1&1)&(0|0))|((0|0)|(1&1)))\") == 1\n assert candidate(expression = \"(((1|0)|(1|0))&((0&1)|(0&1))&((0&1)|(0&1))&((1|0)|(1|0)))\") == 1\n assert candidate(expression = \"((1&(0|1))&((0|1)|(1&0)))\") == 1\n assert candidate(expression = \"((1&(0|1))&((0|1)&(1|0)))\") == 1\n assert candidate(expression = \"(1&((0|1)&(0|1))|(1&0)&(0&1))\") == 1\n assert candidate(expression = \"(1|((0&(1|0))|((0|1)&(1&0))))\") == 1\n assert candidate(expression = \"((1&(0|1))|((0|1)|(1&(0|1&0))))\") == 2\n assert candidate(expression = \"(((1&(0&(1|0)))|((0&(1|0))|(0&1)))&((0&1)|(1&(0&1))))\") == 2\n assert candidate(expression = \"(1&(1|(0&0)&(1|0))|(0&(0|1)&(0|1)))\") == 1\n assert candidate(expression = \"(0|((((1|0)&(0|1))|((1&0)|(0|1)))|((1&(0&0))|(0|1))))\") == 1\n assert candidate(expression = \"(((0&0)|(1|1))&((0|1)|(1|0))&((1&0)|(0|1))&((0&0)|(1|1)))\") == 1\n assert candidate(expression = \"((0&(0|1))|((1|0)&1))\") == 1\n assert candidate(expression = \"(((0|1)&(1|0))|(0&(1|0)))\") == 1\n assert candidate(expression = \"(((0&1)|(1&0))|((1&1)&(0|0)))\") == 1\n assert candidate(expression = \"((0&(1|0))|((0&1)|(1&1)))&(1|0)\") == 1\n"}, "metadata": {"canonical_parameter_names": ["expression"], "leetcode_dataset_entry_point": "Solution().minOperationsToFlip", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minOperationsToFlip(self, expression: str) -> int:", "container": "Solution", "callable": "minOperationsToFlip", "parameters": [{"name": "expression", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1897, "task_id": "redistribute-characters-to-make-all-strings-equal", "difficulty": "Easy", "problem_description": "You are given an array of strings words (0-indexed).\nIn one operation, pick two distinct indices i and j, where words[i] is a non-empty string, and move any character from words[i] to any position in words[j].\nReturn true if you can make every string in words equal using any number of operations, and false otherwise.\n \nExample 1:\n\nInput: words = [\"abc\",\"aabc\",\"bc\"]\nOutput: true\nExplanation: Move the first 'a' in words[1] to the front of words[2],\nto make words[1] = \"abc\" and words[2] = \"abc\".\nAll the strings are now equal to \"abc\", so return true.\n\nExample 2:\n\nInput: words = [\"ab\",\"a\"]\nOutput: false\nExplanation: It is impossible to make all the strings equal using the operation.\n\n \nConstraints:\n\n1 <= words.length <= 100\n1 <= words[i].length <= 100\nwords[i] consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl']) == False\n assert candidate(words = ['aabbcc', 'abc', 'abc', 'abc']) == False\n assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba']) == True\n assert candidate(words = ['abcd', 'bcad', 'acdb', 'bdac']) == True\n assert candidate(words = ['hello', 'olelh', 'loleh']) == True\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == False\n assert candidate(words = ['a', 'a', 'a', 'a']) == True\n assert candidate(words = ['test', 'sett', 'stte']) == True\n assert candidate(words = ['abc', 'def', 'ghi']) == False\n assert candidate(words = ['xyz', 'zyx', 'yzx']) == True\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy']) == False\n assert candidate(words = ['ab', 'a']) == False\n assert candidate(words = ['same', 'same', 'same']) == True\n assert candidate(words = ['abcd', 'abcd', 'abcd', 'abcd']) == True\n assert candidate(words = ['one', 'two', 'three']) == False\n assert candidate(words = ['abc', 'aabc', 'bc']) == True\n assert candidate(words = ['aabbcc', 'abc', 'abc']) == False\n assert candidate(words = ['abcd', 'abcd', 'abcd']) == True\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same']) == True\n assert candidate(words = ['aabb', 'bbcc', 'ccdd', 'aabb', 'bbcc', 'ccdd', 'aabb', 'bbcc', 'ccdd']) == False\n assert candidate(words = ['abcdefghijklmnop', 'abcdefghijklmnop', 'abcdefghijklmnop', 'abcdefghijklmnop']) == True\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'zxy', 'yxz', 'xzy']) == True\n assert candidate(words = ['zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz']) == True\n assert candidate(words = ['repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat']) == True\n assert candidate(words = ['abcdabcd', 'bacdbacd', 'cdabdcab', 'dcbadacb']) == True\n assert candidate(words = ['xyz', 'yzx', 'zxy', 'zyx', 'yxz', 'xzy']) == True\n assert candidate(words = ['abcdefg', 'ghfedcb', 'fedcbaa', 'bcaefgd', 'abcdefg', 'ghfedcb', 'fedcbaa', 'bcaefgd', 'abcdefg', 'ghfedcb']) == False\n assert candidate(words = ['abcde', 'bcdea', 'cdeab', 'deabc', 'eabcd', 'fghij', 'ghijf', 'hijfg', 'ijfgh', 'jfgih']) == False\n assert candidate(words = ['hello', 'bello', 'hallo', 'hellb', 'hella', 'bellh', 'hblla']) == False\n assert candidate(words = ['abcde', 'edcba', 'bcdea', 'decab', 'acdeb']) == True\n assert candidate(words = ['hello', 'lohel', 'ohell', 'llohe', 'elloh']) == True\n assert candidate(words = ['python', 'typhon', 'typhno', 'hypton', 'hptyon', 'phyton', 'ptyhno', 'thpyon', 'ptyhon', 'phytom']) == False\n assert candidate(words = ['abacabadabacaba', 'bacabacabadabacab', 'acabacabadabacaba', 'cabacabadabacabaa']) == False\n assert candidate(words = ['aabbcc', 'abcabc', 'ccbaab', 'bcaacb']) == True\n assert candidate(words = ['aabbcc', 'abcabc', 'baccab', 'cbbaca', 'acabcb', 'bcacab']) == True\n assert candidate(words = ['hello', 'world', 'owrld', 'dlrow', 'llhow']) == False\n assert candidate(words = ['abcdef', 'fedcba', 'defabc', 'cabdef', 'bacdef', 'fabcde']) == True\n assert candidate(words = ['xyx', 'yxy', 'xyx', 'xyx', 'xyx', 'xyx', 'xyx', 'xyx', 'xyx', 'xyx']) == False\n assert candidate(words = ['mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq', 'mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq', 'mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq']) == True\n assert candidate(words = ['equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal']) == True\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccaabb', 'aabbbc', 'bbccaa']) == False\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']) == False\n assert candidate(words = ['unique', 'queuni', 'neuqui', 'uqinue', 'unei qu', 'nueiqu', 'einuq', 'uiqune', 'inuqeu', 'uqneui']) == False\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'aaa', 'bbb', 'ccc', 'aaa', 'bbb', 'ccc']) == True\n assert candidate(words = ['qwertyuiop', 'poiuytrewq', 'oiuytrewqp', 'iuytrewqpo', 'uytrewqpoi', 'ytrewqpoiu']) == True\n assert candidate(words = ['abcdefg', 'bcdefga', 'cdefgab', 'defgabc', 'efgabcd', 'fgabcde', 'gabcdef']) == True\n assert candidate(words = ['aabb', 'bbaa', 'abab', 'abba', 'baab', 'baba', 'aaab', 'aaba', 'abaa', 'baaa', 'bbaa', 'abab', 'abba', 'baab', 'baba', 'aaab', 'aaba', 'abaa', 'baaa', 'bbaa']) == False\n assert candidate(words = ['aabbcc', 'abcabc', 'bcaabc', 'cababc']) == True\n assert candidate(words = ['apple', 'ppale', 'pleap', 'elppa', 'lappe']) == True\n assert candidate(words = ['aabbccddeeffgghhiijjooppllnnmmbbkkqqwwaass', 'aabbccddeeffgghhiijjooppllnnmmbbkkqqwwaass', 'aabbccddeeffgghhiijjooppllnnmmbbkkqqwwaass', 'aabbccddeeffgghhiijjooppllnnmmbbkkqqwwaass']) == True\n assert candidate(words = ['aabbcc', 'bbccaa', 'ccaabb']) == True\n assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == True\n assert candidate(words = ['xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx']) == True\n assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee']) == False\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same']) == True\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same']) == True\n assert candidate(words = ['aabbcc', 'abcabc', 'ccbaab']) == True\n assert candidate(words = ['unique', 'uniqueness', 'uniquely', 'uniques']) == False\n assert candidate(words = ['aaaaab', 'aaabbb', 'aabbbb', 'abbbbb', 'bbbbbz']) == False\n assert candidate(words = ['python', 'typhon', 'nothpy', 'hnotyp', 'npytho']) == True\n assert candidate(words = ['aabbcc', 'abcabc', 'ccbaab', 'baccab']) == True\n assert candidate(words = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']) == True\n assert candidate(words = ['abcdef', 'bcdefa', 'cdefab', 'defabc', 'efabcd', 'fabcde', 'abcdef', 'bcdefa', 'cdefab', 'defabc', 'efabcd', 'fabcde']) == True\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'xzy']) == True\n assert candidate(words = ['unique', 'characters', 'only', 'in', 'each', 'string', 'here']) == False\n assert candidate(words = ['abcdefgh', 'hgfedcba', 'abcdefg', 'gfedcba', 'abcdef', 'fedcba', 'abcde', 'edcba', 'abcd', 'dcba', 'abc', 'cba', 'ab', 'ba', 'a', 'b']) == False\n assert candidate(words = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm', 'qwertyuiop', 'asdfghjkl', 'zxcvbnm', 'qwertyuiop', 'asdfghjkl', 'zxcvbnm']) == False\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']) == False\n assert candidate(words = ['abracadabra', 'cadabraab', 'rabracada', 'abracadab', 'acadabrabr']) == False\n assert candidate(words = ['abcdef', 'bcdefa', 'cdefab', 'defabc', 'efabcd', 'fabcde']) == True\n assert candidate(words = ['qqq', 'www', 'eee', 'rrr', 'ttt', 'yyy', 'uuu', 'iii', 'ooo', 'ppp', 'lll', 'mmm', 'nnn', 'sss', 'ddd', 'fff', 'ggg', 'hhh', 'jjj', 'kkk']) == False\n assert candidate(words = ['apple', 'ppale', 'pplea', 'pelap', 'pepla']) == True\n assert candidate(words = ['racecar', 'carrace', 'ecarrac', 'rraceca', 'acecarr']) == True\n assert candidate(words = ['abcdefgh', 'hgfedcba', 'bacdefgh', 'defghabc', 'efghabcd']) == True\n assert candidate(words = ['abc', 'abcabc', 'abcabcabc', 'abcabcabcabc', 'abcabcabcabcabc', 'abcabcabcabcabcabc', 'abcabcabcabcabcabcabc', 'abcabcabcabcabcabcabcabc', 'abcabcabcabcabcabcabcabcabc', 'abcabcabcabcabcabcabcabcabcabc']) == False\n assert candidate(words = ['mississippi', 'ppiimiss', 'pisimmpi', 'ssippiim', 'pmissipi', 'iimpsspi', 'sspiimp', 'misipip', 'sipimp', 'impispi']) == False\n assert candidate(words = ['unique', 'enquie', 'unieqe', 'inequeu', 'niuquee', 'uqneiee', 'qnueiee']) == False\n assert candidate(words = ['aabbcc', 'abcabc', 'bcaabc', 'cababc', 'bcacab']) == True\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'xzy', 'yxz']) == True\n assert candidate(words = ['abcdabcd', 'dcbaabcd', 'abcdcdab', 'dcabcdab']) == True\n assert candidate(words = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'ffffff', 'gggggg', 'hhhhh', 'iiiii', 'jjjjj']) == False\n assert candidate(words = ['hello', 'world', 'world', 'hello']) == False\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'aab', 'bbc', 'cca']) == True\n assert candidate(words = ['aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz', 'zzxyyxwwvvttsrrqpponmlkjihgfedcba', 'abcdefghijlkmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba', 'zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba', 'qrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcd']) == False\n assert candidate(words = ['zzzz', 'zzz', 'zz', 'z']) == False\n assert candidate(words = ['python', 'programming', 'challenge', 'easy']) == False\n assert candidate(words = ['qwerty', 'wertyq', 'ertyqw', 'rtyqwe', 'tyqwre', 'yqwret', 'qwertyui', 'wertyuiq', 'ertyuiqw', 'rtyuiqwe', 'tyuiqwre', 'yuiqwret']) == False\n assert candidate(words = ['hello', 'olleh', 'loleh', 'elloh', 'lhleo', 'heoll']) == True\n assert candidate(words = ['abacabadabacaba', 'bacabacabacaba', 'cabacabacabacaba', 'dacabacabacaba', 'eacabacabacaba', 'facabacabacaba', 'gacabacabacaba', 'hacabacabacaba', 'iacabacabacaba', 'jacobacabacaba', 'kacabacabacaba']) == False\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().makeEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def makeEqual(self, words: list[str]) -> bool:", "container": "Solution", "callable": "makeEqual", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1898, "task_id": "maximum-number-of-removable-characters", "difficulty": "Medium", "problem_description": "You are given two strings s and p where p is a subsequence of s. You are also given a distinct 0-indexed integer array removable containing a subset of indices of s (s is also 0-indexed).\nYou want to choose an integer k (0 <= k <= removable.length) such that, after removing k characters from s using the first k indices in removable, p is still a subsequence of s. More formally, you will mark the character at s[removable[i]] for each 0 <= i < k, then remove all marked characters and check if p is still a subsequence.\nReturn the maximum k you can choose such that p is still a subsequence of s after the removals.\nA subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.\n \nExample 1:\n\nInput: s = \"abcacb\", p = \"ab\", removable = [3,1,0]\nOutput: 2\nExplanation: After removing the characters at indices 3 and 1, \"abcacb\" becomes \"accb\".\n\"ab\" is a subsequence of \"accb\".\nIf we remove the characters at indices 3, 1, and 0, \"abcacb\" becomes \"ccb\", and \"ab\" is no longer a subsequence.\nHence, the maximum k is 2.\n\nExample 2:\n\nInput: s = \"abcbddddd\", p = \"abcd\", removable = [3,2,1,4,5,6]\nOutput: 1\nExplanation: After removing the character at index 3, \"abcbddddd\" becomes \"abcddddd\".\n\"abcd\" is a subsequence of \"abcddddd\".\n\nExample 3:\n\nInput: s = \"abcab\", p = \"abc\", removable = [0,1,2,3,4]\nOutput: 0\nExplanation: If you remove the first index in the array removable, \"abc\" is no longer a subsequence.\n\n \nConstraints:\n\n1 <= p.length <= s.length <= 105\n0 <= removable.length < s.length\n0 <= removable[i] < s.length\np is a subsequence of s.\ns and p both consist of lowercase English letters.\nThe elements in removable are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"pqrstu\",p = \"psu\",removable = [5, 4, 3, 2, 1, 0]) == 0\n assert candidate(s = \"abcdefghij\",p = \"acegi\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(s = \"deeddeede\",p = \"dee\",removable = [5, 3, 4, 6]) == 4\n assert candidate(s = \"deeedbbcccbdaa\",p = \"ddccbb\",removable = [8, 2, 3, 0, 7]) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"acegikmoqsuwy\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 13\n assert candidate(s = \"zzzzzzzzzz\",p = \"zz\",removable = [1, 3, 5, 7]) == 4\n assert candidate(s = \"aaaabbbb\",p = \"ab\",removable = [2, 3, 4, 5]) == 4\n assert candidate(s = \"abcdef\",p = \"abc\",removable = [5, 4, 3, 2, 1, 0]) == 3\n assert candidate(s = \"aabcbcb\",p = \"abc\",removable = [3, 1, 0, 4]) == 2\n assert candidate(s = \"abcdxyz\",p = \"ad\",removable = [0, 1, 2, 3, 4, 5, 6]) == 0\n assert candidate(s = \"abcacb\",p = \"ab\",removable = [3, 1, 0]) == 2\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"acegikmoqsuwy\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 0\n assert candidate(s = \"ababababab\",p = \"aaaa\",removable = [0, 2, 4, 6, 8]) == 1\n assert candidate(s = \"mississippi\",p = \"issi\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(s = \"zpqom\",p = \"z\",removable = [0, 1, 2, 3, 4]) == 0\n assert candidate(s = \"abcab\",p = \"abc\",removable = [0, 1, 2, 3, 4]) == 0\n assert candidate(s = \"xyz\",p = \"xyz\",removable = [0, 1, 2]) == 0\n assert candidate(s = \"abcdef\",p = \"af\",removable = [1, 2, 3, 4]) == 4\n assert candidate(s = \"abcbddddd\",p = \"abcd\",removable = [3, 2, 1, 4, 5, 6]) == 1\n assert candidate(s = \"zazbzczdzezfzgzhzi\",p = \"abcdefg\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16]) == 9\n assert candidate(s = \"pythonprogramming\",p = \"ppn\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 0\n assert candidate(s = \"thisisaverylongstringthatweneedtoremovesomecharactersfrom\",p = \"thisisalong\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n assert candidate(s = \"mississippi\",p = \"miss\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(s = \"onetwothreefourfivesixseveneightnine\",p = \"onefivesix\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == 0\n assert candidate(s = \"abcdefghijklnmopqrstuvwxyz\",p = \"zyxwvutsrqponmlkjihgfedcba\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(s = \"abracadabra\",p = \"aca\",removable = [1, 3, 5, 7, 9, 10]) == 5\n assert candidate(s = \"leetcodeleetcodeleetcode\",p = \"leetcode\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]) == 16\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",p = \"qwerty\",removable = [0, 1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 20, 21, 22, 23, 24, 25, 30, 31, 32, 33, 34, 35]) == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",p = \"zzzz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 30\n assert candidate(s = \"abracadabra\",p = \"aa\",removable = [0, 2, 4, 6, 8, 10]) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",p = \"zzz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]) == 29\n assert candidate(s = \"abacabadabacaba\",p = \"abc\",removable = [2, 5, 8, 11, 14]) == 5\n assert candidate(s = \"abcdefghijklm\",p = \"abc\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(s = \"zzzzzzzzzz\",p = \"zz\",removable = [1, 3, 5, 7, 9]) == 5\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",p = \"quickbrownfox\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",p = \"abcdefghijklmnopqrstuvwxyz\",removable = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",p = \"zzzzz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 15\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"az\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 0\n assert candidate(s = \"abcdeffedcba\",p = \"abcdef\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 0\n assert candidate(s = \"mississippi\",p = \"issi\",removable = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(s = \"abcdefghijklmno\",p = \"def\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 3\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",p = \"zzzz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 16\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",p = \"pus\",removable = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]) == 7\n assert candidate(s = \"aaaaaaabbbbbbb\",p = \"aabbb\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 5\n assert candidate(s = \"abcdefghijklmnop\",p = \"mnop\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 12\n assert candidate(s = \"xyxzyzyzyxzyzyzyx\",p = \"xyz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 9\n assert candidate(s = \"banana\",p = \"ban\",removable = [0, 2, 4]) == 0\n assert candidate(s = \"aaaabbbbccccdddd\",p = \"abcd\",removable = [3, 7, 11, 15]) == 4\n assert candidate(s = \"abracadabra\",p = \"aca\",removable = [1, 3, 5, 7, 9]) == 5\n assert candidate(s = \"banana\",p = \"ban\",removable = [0, 1, 2, 3, 4, 5]) == 0\n assert candidate(s = \"abcdefffffghijklmnopqrstuvwxyz\",p = \"acegikmoqsuwy\",removable = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == 10\n assert candidate(s = \"aabbccddeeffgghhii\",p = \"abcdefghi\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == 9\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",p = \"abcdefghijklmnopqrstuvwxzy\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38]) == 0\n assert candidate(s = \"abcdabcdabcd\",p = \"abc\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 8\n assert candidate(s = \"thisisateststring\",p = \"tst\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 24]) == 5\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",p = \"qz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(s = \"abcabcabcabcabc\",p = \"abcabcabc\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == 4\n assert candidate(s = \"xyzzxyzzxyzz\",p = \"xyz\",removable = [0, 2, 4, 6, 8, 10]) == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",p = \"abcdefghijklmnopqrstuvwxyz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]) == 1\n assert candidate(s = \"aaaaaaaaaaa\",p = \"aaaaa\",removable = [1, 3, 5, 7, 9]) == 5\n assert candidate(s = \"abcdabcdabcdabcdabcdabcd\",p = \"abcd\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 20\n assert candidate(s = \"abababababababababab\",p = \"aabbaabb\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == 4\n assert candidate(s = \"hellohellohellohello\",p = \"heo\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 15\n assert candidate(s = \"xyzzxyzzxyzz\",p = \"xyz\",removable = [1, 3, 5, 7, 9, 11]) == 4\n assert candidate(s = \"mississippi\",p = \"issi\",removable = [3, 1, 0, 4, 5, 2, 6, 7, 8, 9, 10]) == 3\n assert candidate(s = \"abracadabra\",p = \"ac\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(s = \"bcaabcbabcabc\",p = \"abc\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",p = \"zzz\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"bdfhjlnprtvxz\",removable = [1, 5, 9, 13, 17, 21, 25]) == 0\n assert candidate(s = \"abcdeffedcba\",p = \"abcdef\",removable = [0, 2, 4, 6, 8, 10]) == 0\n assert candidate(s = \"findinganagrams\",p = \"anag\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == 3\n assert candidate(s = \"mississippi\",p = \"miss\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"adgjmpsvy\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 0\n assert candidate(s = \"hellotherehowareyou\",p = \"heoy\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == 4\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",p = \"xyz\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 0\n assert candidate(s = \"aaaaabbbbbcccc\",p = \"abc\",removable = [5, 6, 7, 8, 9, 10]) == 4\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",p = \"pneumo\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54]) == 0\n assert candidate(s = \"thisisaverylongstring\",p = \"tils\",removable = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 3\n assert candidate(s = \"leetcodeleetcodeleetcodeleetcode\",p = \"leetcodelt\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 16\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"acegikmoqsuwy\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 12\n assert candidate(s = \"abcdefghijabcdefghij\",p = \"acegik\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 0\n assert candidate(s = \"nnnnoooooommmm\",p = \"nom\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 3\n"}, "metadata": {"canonical_parameter_names": ["s", "p", "removable"], "leetcode_dataset_entry_point": "Solution().maximumRemovals", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumRemovals(self, s: str, p: str, removable: list[int]) -> int:", "container": "Solution", "callable": "maximumRemovals", "parameters": [{"name": "s", "type": "str"}, {"name": "p", "type": "str"}, {"name": "removable", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1899, "task_id": "merge-triplets-to-form-target-triplet", "difficulty": "Medium", "problem_description": "A triplet is an array of three integers. You are given a 2D integer array triplets, where triplets[i] = [ai, bi, ci] describes the ith triplet. You are also given an integer array target = [x, y, z] that describes the triplet you want to obtain.\nTo obtain target, you may apply the following operation on triplets any number of times (possibly zero):\n\nChoose two indices (0-indexed) i and j (i != j) and update triplets[j] to become [max(ai, aj), max(bi, bj), max(ci, cj)].\n\n\t\nFor example, if triplets[i] = [2, 5, 3] and triplets[j] = [1, 7, 5], triplets[j] will be updated to [max(2, 1), max(5, 7), max(3, 5)] = [2, 7, 5].\n\n\n\nReturn true if it is possible to obtain the target triplet [x, y, z] as an element of triplets, or false otherwise.\n \nExample 1:\n\nInput: triplets = [[2,5,3],[1,8,4],[1,7,5]], target = [2,7,5]\nOutput: true\nExplanation: Perform the following operations:\n- Choose the first and last triplets [[2,5,3],[1,8,4],[1,7,5]]. Update the last triplet to be [max(2,1), max(5,7), max(3,5)] = [2,7,5]. triplets = [[2,5,3],[1,8,4],[2,7,5]]\nThe target triplet [2,7,5] is now an element of triplets.\n\nExample 2:\n\nInput: triplets = [[3,4,5],[4,5,6]], target = [3,2,5]\nOutput: false\nExplanation: It is impossible to have [3,2,5] as an element because there is no 2 in any of the triplets.\n\nExample 3:\n\nInput: triplets = [[2,5,3],[2,3,4],[1,2,5],[5,2,3]], target = [5,5,5]\nOutput: true\nExplanation: Perform the following operations:\n- Choose the first and third triplets [[2,5,3],[2,3,4],[1,2,5],[5,2,3]]. Update the third triplet to be [max(2,1), max(5,2), max(3,5)] = [2,5,5]. triplets = [[2,5,3],[2,3,4],[2,5,5],[5,2,3]].\n- Choose the third and fourth triplets [[2,5,3],[2,3,4],[2,5,5],[5,2,3]]. Update the fourth triplet to be [max(2,5), max(5,2), max(5,3)] = [5,5,5]. triplets = [[2,5,3],[2,3,4],[2,5,5],[5,5,5]].\nThe target triplet [5,5,5] is now an element of triplets.\n\n \nConstraints:\n\n1 <= triplets.length <= 105\ntriplets[i].length == target.length == 3\n1 <= ai, bi, ci, x, y, z <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6]],target = [1, 2, 3]) == True\n assert candidate(triplets = [[3, 4, 5], [4, 5, 6]],target = [3, 2, 5]) == False\n assert candidate(triplets = [[2, 5, 3], [1, 8, 4], [1, 7, 5]],target = [2, 7, 5]) == True\n assert candidate(triplets = [[1000, 1000, 1000]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],target = [1, 2, 3]) == False\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [1, 2, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[2, 5, 3], [2, 3, 4], [1, 2, 5], [5, 2, 3]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 3, 3], [3, 1, 3], [3, 3, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 4], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1000, 1, 1], [1, 1000, 1], [1, 1, 1000], [500, 500, 500]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],target = [6, 6, 6]) == True\n assert candidate(triplets = [[1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 1, 3], [1, 3, 1], [3, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1]],target = [1, 2, 2]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]],target = [1, 2, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 1, 1], [10, 10, 10]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[100, 1, 1], [1, 100, 1], [1, 1, 100], [50, 50, 50], [10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40]],target = [50, 50, 50]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],target = [13, 14, 15]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10, 11]],target = [9, 10, 11]) == True\n assert candidate(triplets = [[999, 1, 1], [1, 999, 1], [1, 1, 999], [1000, 1000, 1000]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [3, 1, 2], [1, 3, 2], [2, 1, 3], [1, 1, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1], [1, 2, 1], [2, 1, 1]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[2, 5, 3], [1, 8, 4], [1, 7, 5], [3, 2, 1], [6, 6, 6], [9, 9, 9]],target = [3, 8, 9]) == False\n assert candidate(triplets = [[2, 5, 3], [1, 8, 4], [1, 7, 5], [3, 2, 1], [6, 6, 6], [9, 9, 9]],target = [2, 7, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]],target = [10, 10, 10]) == True\n assert candidate(triplets = [[2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]],target = [6, 7, 8]) == True\n assert candidate(triplets = [[1, 1000, 1], [2, 2, 999], [3, 3, 3], [4, 4, 4], [5, 5, 5]],target = [5, 1000, 999]) == True\n assert candidate(triplets = [[1000, 1, 1], [1, 1000, 1], [1, 1, 1000]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[999, 999, 999], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[1000, 1000, 1000], [999, 999, 999], [1, 1, 1]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 1], [10, 1, 2]],target = [10, 10, 10]) == True\n assert candidate(triplets = [[9, 8, 7], [6, 5, 4], [3, 2, 1], [10, 11, 12]],target = [10, 11, 12]) == True\n assert candidate(triplets = [[1000, 1000, 1000], [999, 999, 999], [998, 998, 998], [1, 2, 3]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [2, 2, 2], [2, 2, 2], [2, 2, 2], [3, 3, 3], [3, 3, 3], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [1, 3, 2]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [3, 2, 1]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1], [1, 1, 1], [2, 2, 2], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 3, 1], [2, 1, 2], [3, 2, 3], [4, 3, 4], [5, 4, 5]],target = [5, 5, 5]) == False\n assert candidate(triplets = [[1, 2, 3], [1, 2, 2], [2, 2, 3], [2, 2, 2], [3, 2, 3], [3, 2, 2], [3, 3, 3], [6, 6, 6], [9, 9, 9]],target = [9, 9, 9]) == True\n assert candidate(triplets = [[9, 5, 1], [5, 9, 1], [1, 9, 5], [5, 1, 9], [9, 1, 5]],target = [9, 9, 9]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1000, 1, 1], [1, 1000, 1], [1, 1, 1000], [1000, 1000, 1000]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 3, 2], [3, 2, 1], [2, 1, 3], [4, 4, 4]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 9, 1], [1, 1, 9], [9, 1, 1], [9, 9, 9], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[3, 3, 3], [3, 3, 3], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5]],target = [3, 3, 4]) == True\n assert candidate(triplets = [[1, 3, 1], [2, 1, 2], [3, 2, 1], [1, 2, 3], [2, 3, 1], [3, 1, 2]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 9, 9], [9, 1, 9], [9, 9, 1], [3, 3, 3], [2, 2, 2], [4, 4, 4]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [2, 3, 4], [5, 6, 7], [8, 9, 10], [3, 4, 5], [6, 7, 8], [9, 10, 11]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 3, 5], [3, 5, 1], [5, 1, 3], [2, 4, 6], [4, 6, 2], [6, 2, 4]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 3], [1, 2, 3], [2, 3, 4], [2, 3, 4]],target = [2, 3, 4]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 1, 1], [10, 10, 10], [2, 2, 2], [3, 3, 3], [5, 5, 5]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]],target = [7, 7, 7]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 4], [2, 3, 4], [3, 4, 5], [4, 5, 6]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 2], [2, 1, 1], [2, 1, 2], [1, 2, 1], [1, 2, 2], [2, 2, 1], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [1, 5, 1], [5, 1, 5], [1, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[10, 20, 30], [10, 25, 35], [15, 25, 30], [10, 20, 35], [10, 25, 30], [15, 20, 30]],target = [15, 25, 30]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [1, 5, 6], [4, 2, 6], [4, 5, 3]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 3, 5], [2, 2, 2], [3, 1, 4], [4, 4, 4], [5, 5, 5]],target = [5, 4, 5]) == False\n assert candidate(triplets = [[1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 2, 2], [2, 2, 1], [2, 1, 2], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],target = [15, 15, 15]) == False\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [999, 999, 999]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[2, 5, 3], [1, 8, 4], [1, 7, 5], [2, 7, 5], [5, 7, 5], [2, 7, 9]],target = [2, 7, 5]) == True\n assert candidate(triplets = [[1, 1, 2], [1, 2, 1], [2, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[5, 1, 1], [1, 5, 1], [1, 1, 5], [1, 1, 1], [1, 1, 1]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 2, 2], [2, 2, 2], [2, 3, 3], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [1, 2, 3], [2, 1, 3], [3, 2, 1]],target = [3, 3, 3]) == False\n assert candidate(triplets = [[500, 1, 1], [1, 500, 1], [1, 1, 500], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [500, 500, 500]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]],target = [6, 7, 8]) == True\n assert candidate(triplets = [[1, 100, 1], [100, 1, 1], [1, 1, 100], [100, 100, 1], [100, 1, 100], [1, 100, 100]],target = [100, 100, 100]) == True\n assert candidate(triplets = [[1, 5, 3], [1, 8, 4], [1, 7, 5], [1, 7, 9], [2, 5, 5], [1, 8, 8], [1, 7, 7]],target = [1, 8, 8]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 2, 1], [1, 1, 2], [2, 1, 1], [2, 2, 1], [2, 1, 2], [1, 2, 2], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],target = [10, 11, 12]) == True\n assert candidate(triplets = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50]],target = [30, 30, 30]) == True\n assert candidate(triplets = [[2, 1, 1], [1, 2, 1], [1, 1, 2], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[100, 200, 300], [300, 400, 500], [500, 600, 700], [700, 800, 900], [900, 1000, 100], [100, 300, 500], [200, 400, 600]],target = [100, 400, 600]) == False\n assert candidate(triplets = [[1000, 1000, 1000], [1000, 1000, 1000], [1000, 1000, 1000], [1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 2], [1, 2, 1], [2, 1, 1]],target = [1, 1, 2]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 2], [2, 2, 3], [2, 2, 2], [3, 2, 3], [3, 2, 2], [3, 3, 3], [6, 6, 6], [9, 9, 9]],target = [6, 6, 6]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]],target = [5, 6, 7]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [2, 1, 3], [3, 1, 2], [1, 3, 2], [1, 1, 1], [999, 999, 999]],target = [2, 2, 2]) == False\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],target = [9, 9, 9]) == True\n assert candidate(triplets = [[1, 999, 1], [999, 1, 1], [1, 1, 999], [999, 999, 1], [999, 1, 999], [1, 999, 999], [999, 999, 999]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[5, 1, 1], [1, 5, 1], [1, 1, 5], [5, 5, 1], [5, 1, 5], [1, 5, 5], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 1, 1], [10, 10, 10], [2, 2, 2], [3, 3, 3], [5, 5, 5]],target = [10, 10, 10]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [1, 3, 2], [3, 1, 2], [2, 1, 3], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 999], [1, 999, 1], [999, 1, 1], [999, 999, 1], [999, 1, 999], [999, 999, 999]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 2], [2, 2, 3], [2, 2, 2], [3, 2, 3], [3, 2, 2], [3, 3, 3], [6, 6, 6], [9, 9, 9]],target = [3, 2, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1], [2, 2, 2], [2, 2, 3]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1], [2, 1, 3], [1, 3, 2]],target = [1, 2, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[500, 500, 500], [1, 1, 1], [1000, 1000, 1000], [250, 250, 250], [750, 750, 750]],target = [500, 500, 500]) == True\n assert candidate(triplets = [[1, 1000, 1000], [1000, 1, 1000], [1000, 1000, 1], [250, 250, 250], [500, 500, 500], [750, 750, 750]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[3, 4, 5], [5, 6, 7], [8, 9, 10], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]],target = [8, 9, 10]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]],target = [5, 6, 7]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]],target = [5, 6, 7]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 2], [2, 2, 3], [2, 2, 2], [3, 2, 3], [3, 2, 2], [3, 3, 3]],target = [3, 2, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 3, 4], [5, 6, 7], [1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1], [2, 2, 2]],target = [2, 2, 2]) == True\n"}, "metadata": {"canonical_parameter_names": ["triplets", "target"], "leetcode_dataset_entry_point": "Solution().mergeTriplets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def mergeTriplets(self, triplets: list[list[int]], target: list[int]) -> bool:", "container": "Solution", "callable": "mergeTriplets", "parameters": [{"name": "triplets", "type": "list[list[int]]"}, {"name": "target", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1900, "task_id": "the-earliest-and-latest-rounds-where-players-compete", "difficulty": "Hard", "problem_description": "There is a tournament where n players are participating. The players are standing in a single row and are numbered from 1 to n based on their initial standing position (player 1 is the first player in the row, player 2 is the second player in the row, etc.).\nThe tournament consists of multiple rounds (starting from round number 1). In each round, the ith player from the front of the row competes against the ith player from the end of the row, and the winner advances to the next round. When the number of players is odd for the current round, the player in the middle automatically advances to the next round.\n\nFor example, if the row consists of players 1, 2, 4, 6, 7\n\nPlayer 1 competes against player 7.\nPlayer 2 competes against player 6.\nPlayer 4 automatically advances to the next round.\n\n\n\nAfter each round is over, the winners are lined back up in the row based on the original ordering assigned to them initially (ascending order).\nThe players numbered firstPlayer and secondPlayer are the best in the tournament. They can win against any other player before they compete against each other. If any two other players compete against each other, either of them might win, and thus you may choose the outcome of this round.\nGiven the integers n, firstPlayer, and secondPlayer, return an integer array containing two values, the earliest possible round number and the latest possible round number in which these two players will compete against each other, respectively.\n \nExample 1:\n\nInput: n = 11, firstPlayer = 2, secondPlayer = 4\nOutput: [3,4]\nExplanation:\nOne possible scenario which leads to the earliest round number:\nFirst round: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11\nSecond round: 2, 3, 4, 5, 6, 11\nThird round: 2, 3, 4\nOne possible scenario which leads to the latest round number:\nFirst round: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11\nSecond round: 1, 2, 3, 4, 5, 6\nThird round: 1, 2, 4\nFourth round: 2, 4\n\nExample 2:\n\nInput: n = 5, firstPlayer = 1, secondPlayer = 5\nOutput: [1,1]\nExplanation: The players numbered 1 and 5 compete in the first round.\nThere is no way to make them compete in any other round.\n\n \nConstraints:\n\n2 <= n <= 28\n1 <= firstPlayer < secondPlayer <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,firstPlayer = 4,secondPlayer = 9) == [2, 4]\n assert candidate(n = 28,firstPlayer = 5,secondPlayer = 24) == [1, 1]\n assert candidate(n = 16,firstPlayer = 5,secondPlayer = 12) == [1, 1]\n assert candidate(n = 5,firstPlayer = 1,secondPlayer = 5) == [1, 1]\n assert candidate(n = 28,firstPlayer = 10,secondPlayer = 20) == [2, 5]\n assert candidate(n = 8,firstPlayer = 2,secondPlayer = 7) == [1, 1]\n assert candidate(n = 28,firstPlayer = 3,secondPlayer = 26) == [1, 1]\n assert candidate(n = 10,firstPlayer = 3,secondPlayer = 8) == [1, 1]\n assert candidate(n = 7,firstPlayer = 2,secondPlayer = 6) == [1, 1]\n assert candidate(n = 8,firstPlayer = 3,secondPlayer = 6) == [1, 1]\n assert candidate(n = 11,firstPlayer = 2,secondPlayer = 4) == [3, 4]\n assert candidate(n = 16,firstPlayer = 3,secondPlayer = 14) == [1, 1]\n assert candidate(n = 22,firstPlayer = 4,secondPlayer = 19) == [1, 1]\n assert candidate(n = 19,firstPlayer = 1,secondPlayer = 19) == [1, 1]\n assert candidate(n = 15,firstPlayer = 7,secondPlayer = 13) == [2, 4]\n assert candidate(n = 18,firstPlayer = 6,secondPlayer = 13) == [1, 1]\n assert candidate(n = 18,firstPlayer = 5,secondPlayer = 16) == [2, 5]\n assert candidate(n = 27,firstPlayer = 12,secondPlayer = 18) == [2, 5]\n assert candidate(n = 20,firstPlayer = 7,secondPlayer = 16) == [2, 5]\n assert candidate(n = 25,firstPlayer = 10,secondPlayer = 20) == [2, 5]\n assert candidate(n = 20,firstPlayer = 5,secondPlayer = 15) == [2, 5]\n assert candidate(n = 18,firstPlayer = 2,secondPlayer = 17) == [1, 1]\n assert candidate(n = 15,firstPlayer = 2,secondPlayer = 14) == [1, 1]\n assert candidate(n = 19,firstPlayer = 7,secondPlayer = 16) == [2, 5]\n assert candidate(n = 24,firstPlayer = 6,secondPlayer = 19) == [1, 1]\n assert candidate(n = 27,firstPlayer = 8,secondPlayer = 20) == [1, 1]\n assert candidate(n = 19,firstPlayer = 8,secondPlayer = 17) == [2, 5]\n assert candidate(n = 13,firstPlayer = 3,secondPlayer = 10) == [2, 4]\n assert candidate(n = 23,firstPlayer = 10,secondPlayer = 19) == [2, 5]\n assert candidate(n = 28,firstPlayer = 10,secondPlayer = 22) == [2, 5]\n assert candidate(n = 25,firstPlayer = 7,secondPlayer = 19) == [1, 1]\n assert candidate(n = 22,firstPlayer = 7,secondPlayer = 18) == [2, 5]\n assert candidate(n = 20,firstPlayer = 5,secondPlayer = 16) == [1, 1]\n assert candidate(n = 27,firstPlayer = 11,secondPlayer = 23) == [2, 5]\n assert candidate(n = 13,firstPlayer = 4,secondPlayer = 10) == [1, 1]\n assert candidate(n = 19,firstPlayer = 3,secondPlayer = 17) == [1, 1]\n assert candidate(n = 21,firstPlayer = 9,secondPlayer = 18) == [2, 5]\n assert candidate(n = 24,firstPlayer = 10,secondPlayer = 23) == [2, 5]\n assert candidate(n = 22,firstPlayer = 7,secondPlayer = 17) == [3, 5]\n assert candidate(n = 15,firstPlayer = 7,secondPlayer = 9) == [1, 1]\n assert candidate(n = 27,firstPlayer = 9,secondPlayer = 20) == [3, 5]\n assert candidate(n = 24,firstPlayer = 10,secondPlayer = 15) == [1, 1]\n assert candidate(n = 24,firstPlayer = 8,secondPlayer = 17) == [1, 1]\n assert candidate(n = 18,firstPlayer = 6,secondPlayer = 15) == [2, 5]\n assert candidate(n = 24,firstPlayer = 9,secondPlayer = 15) == [2, 5]\n assert candidate(n = 23,firstPlayer = 9,secondPlayer = 15) == [1, 1]\n assert candidate(n = 12,firstPlayer = 5,secondPlayer = 8) == [1, 1]\n assert candidate(n = 25,firstPlayer = 7,secondPlayer = 18) == [2, 5]\n assert candidate(n = 25,firstPlayer = 2,secondPlayer = 24) == [1, 1]\n assert candidate(n = 27,firstPlayer = 12,secondPlayer = 24) == [2, 5]\n assert candidate(n = 15,firstPlayer = 3,secondPlayer = 13) == [1, 1]\n assert candidate(n = 21,firstPlayer = 6,secondPlayer = 16) == [1, 1]\n assert candidate(n = 19,firstPlayer = 4,secondPlayer = 18) == [2, 4]\n assert candidate(n = 22,firstPlayer = 6,secondPlayer = 19) == [2, 5]\n assert candidate(n = 28,firstPlayer = 2,secondPlayer = 27) == [1, 1]\n assert candidate(n = 25,firstPlayer = 4,secondPlayer = 22) == [1, 1]\n assert candidate(n = 13,firstPlayer = 3,secondPlayer = 11) == [1, 1]\n assert candidate(n = 13,firstPlayer = 3,secondPlayer = 9) == [2, 4]\n assert candidate(n = 28,firstPlayer = 1,secondPlayer = 28) == [1, 1]\n assert candidate(n = 23,firstPlayer = 11,secondPlayer = 20) == [2, 5]\n assert candidate(n = 17,firstPlayer = 3,secondPlayer = 15) == [1, 1]\n assert candidate(n = 14,firstPlayer = 3,secondPlayer = 10) == [2, 4]\n assert candidate(n = 12,firstPlayer = 3,secondPlayer = 9) == [2, 4]\n assert candidate(n = 25,firstPlayer = 8,secondPlayer = 19) == [2, 5]\n assert candidate(n = 28,firstPlayer = 12,secondPlayer = 18) == [2, 5]\n assert candidate(n = 22,firstPlayer = 9,secondPlayer = 14) == [1, 1]\n assert candidate(n = 24,firstPlayer = 9,secondPlayer = 21) == [2, 5]\n assert candidate(n = 19,firstPlayer = 9,secondPlayer = 17) == [2, 5]\n assert candidate(n = 17,firstPlayer = 4,secondPlayer = 15) == [2, 4]\n assert candidate(n = 19,firstPlayer = 6,secondPlayer = 14) == [1, 1]\n assert candidate(n = 21,firstPlayer = 7,secondPlayer = 15) == [1, 1]\n assert candidate(n = 27,firstPlayer = 2,secondPlayer = 25) == [3, 3]\n assert candidate(n = 17,firstPlayer = 6,secondPlayer = 12) == [1, 1]\n assert candidate(n = 17,firstPlayer = 5,secondPlayer = 13) == [1, 1]\n assert candidate(n = 18,firstPlayer = 4,secondPlayer = 15) == [1, 1]\n assert candidate(n = 21,firstPlayer = 10,secondPlayer = 12) == [1, 1]\n assert candidate(n = 15,firstPlayer = 4,secondPlayer = 11) == [3, 4]\n assert candidate(n = 21,firstPlayer = 6,secondPlayer = 19) == [2, 5]\n assert candidate(n = 19,firstPlayer = 8,secondPlayer = 15) == [2, 5]\n assert candidate(n = 20,firstPlayer = 7,secondPlayer = 14) == [1, 1]\n assert candidate(n = 25,firstPlayer = 8,secondPlayer = 20) == [2, 5]\n assert candidate(n = 27,firstPlayer = 4,secondPlayer = 23) == [3, 5]\n assert candidate(n = 20,firstPlayer = 3,secondPlayer = 18) == [1, 1]\n assert candidate(n = 26,firstPlayer = 13,secondPlayer = 22) == [2, 5]\n assert candidate(n = 18,firstPlayer = 5,secondPlayer = 14) == [1, 1]\n assert candidate(n = 21,firstPlayer = 6,secondPlayer = 15) == [3, 5]\n assert candidate(n = 28,firstPlayer = 10,secondPlayer = 25) == [2, 5]\n"}, "metadata": {"canonical_parameter_names": ["n", "firstPlayer", "secondPlayer"], "leetcode_dataset_entry_point": "Solution().earliestAndLatest", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def earliestAndLatest(self, n: int, firstPlayer: int, secondPlayer: int) -> list[int]:", "container": "Solution", "callable": "earliestAndLatest", "parameters": [{"name": "n", "type": "int"}, {"name": "firstPlayer", "type": "int"}, {"name": "secondPlayer", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1901, "task_id": "find-a-peak-element-ii", "difficulty": "Medium", "problem_description": "A peak element in a 2D grid is an element that is strictly greater than all of its adjacent neighbors to the left, right, top, and bottom.\nGiven a 0-indexed m x n matrix mat where no two adjacent cells are equal, find any peak element mat[i][j] and return the length 2 array [i,j].\nYou may assume that the entire matrix is surrounded by an outer perimeter with the value -1 in each cell.\nYou must write an algorithm that runs in O(m log(n)) or O(n log(m)) time.\n \nExample 1:\n\n\nInput: mat = [[1,4],[3,2]]\nOutput: [0,1]\nExplanation: Both 3 and 4 are peak elements so [1,0] and [0,1] are both acceptable answers.\n\nExample 2:\n\n\nInput: mat = [[10,20,15],[21,30,14],[7,16,32]]\nOutput: [1,1]\nExplanation: Both 30 and 32 are peak elements so [1,1] and [2,2] are both acceptable answers.\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n1 <= m, n <= 500\n1 <= mat[i][j] <= 105\nNo two adjacent cells are equal.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1]]) == [0, 0]\n assert candidate(mat = [[1, 2, 3, 4, 5], [16, 17, 18, 19, 6], [15, 24, 25, 20, 7], [14, 23, 22, 21, 8], [13, 12, 11, 10, 9]]) == [2, 2]\n assert candidate(mat = [[1, 2, 3, 4, 5], [16, 17, 24, 25, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 18]]) == [1, 3]\n assert candidate(mat = [[10, 20, 15], [21, 30, 14], [7, 16, 32]]) == [1, 1]\n assert candidate(mat = [[1, 3, 5, 7], [10, 11, 16, 20], [23, 30, 34, 60]]) == [2, 3]\n assert candidate(mat = [[1, 4], [3, 2]]) == [0, 1]\n assert candidate(mat = [[5, 25, 15, 10], [100, 101, 102, 103], [99, 98, 97, 96], [50, 49, 48, 47]]) == [1, 3]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]]) == [2, 9]\n assert candidate(mat = [[1, 10, 20, 10, 1], [10, 20, 30, 20, 10], [20, 30, 40, 30, 20], [10, 20, 30, 20, 10], [1, 10, 20, 10, 1]]) == [2, 2]\n assert candidate(mat = [[1, 5, 9, 12], [10, 20, 25, 16], [8, 18, 24, 13], [7, 17, 19, 21]]) == [1, 2]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [9, 21, 29, 39, 49, 59, 69, 79, 89, 101], [8, 22, 28, 38, 48, 58, 68, 78, 88, 102], [7, 23, 27, 37, 47, 57, 67, 77, 87, 103], [6, 24, 26, 36, 46, 56, 66, 76, 86, 104], [5, 25, 25, 35, 45, 55, 65, 75, 85, 105], [4, 26, 24, 34, 44, 54, 64, 74, 84, 106], [3, 27, 23, 33, 43, 53, 63, 73, 83, 107], [2, 28, 22, 32, 42, 52, 62, 72, 82, 108], [1, 29, 21, 31, 41, 51, 61, 71, 81, 109]]) == [9, 9]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [8, 7, 6, 5, 4, 3, 2, 1, 10], [9, 10, 11, 12, 13, 14, 15, 16, 17], [16, 15, 14, 13, 12, 11, 10, 9, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27], [26, 25, 24, 23, 22, 21, 20, 19, 28], [29, 30, 31, 32, 33, 34, 35, 36, 37]]) == [6, 8]\n assert candidate(mat = [[999, 998, 997], [996, 995, 994], [993, 992, 991], [990, 989, 988], [987, 986, 985], [984, 983, 982], [981, 980, 979], [978, 977, 976], [975, 974, 973], [972, 971, 970]]) == [0, 0]\n assert candidate(mat = [[30, 27, 24, 21, 18, 15], [29, 26, 23, 20, 17, 14], [28, 25, 22, 19, 16, 13], [27, 24, 21, 18, 15, 12], [26, 23, 20, 17, 14, 11], [25, 22, 19, 16, 13, 10]]) == [0, 0]\n assert candidate(mat = [[100000, 99999, 99998], [99997, 99996, 99995], [99994, 99993, 99992], [99991, 99990, 99989], [99988, 99987, 99986]]) == [0, 0]\n assert candidate(mat = [[1, 2, 3, 4, 5], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == [2, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [15, 16, 17, 18, 19, 7], [14, 23, 24, 25, 20, 8], [13, 22, 31, 32, 21, 9], [12, 21, 30, 33, 22, 10], [11, 20, 29, 28, 27, 16]]) == [4, 3]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [25, 26, 27, 28, 29, 30, 31, 32, 10], [24, 39, 40, 41, 42, 43, 44, 33, 11], [23, 38, 51, 52, 53, 54, 45, 34, 12], [22, 37, 50, 59, 60, 55, 46, 35, 13], [21, 36, 49, 58, 61, 56, 47, 36, 14], [20, 35, 48, 57, 62, 50, 40, 30, 15], [19, 34, 47, 56, 63, 49, 39, 29, 16], [18, 33, 46, 55, 64, 48, 38, 28, 17]]) == [8, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == [2, 19]\n assert candidate(mat = [[50, 1, 100, 200, 300, 400, 500], [600, 501, 101, 201, 301, 401, 501], [601, 602, 102, 202, 302, 402, 502], [603, 604, 103, 203, 303, 403, 503], [604, 605, 104, 204, 304, 404, 504], [605, 606, 105, 205, 305, 405, 505]]) == [5, 1]\n assert candidate(mat = [[3, 8, 4, 5, 7], [2, 9, 6, 10, 3], [5, 7, 11, 12, 8], [1, 6, 9, 13, 4]]) == [3, 3]\n assert candidate(mat = [[100, 101, 102, 103, 104], [109, 108, 107, 106, 105], [110, 111, 112, 113, 114], [119, 118, 117, 116, 115]]) == [3, 0]\n assert candidate(mat = [[5, 25, 20], [15, 30, 21], [10, 19, 22], [14, 28, 27], [9, 23, 24]]) == [3, 1]\n assert candidate(mat = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]]) == [0, 24]\n assert candidate(mat = [[1, 3, 5, 7, 9], [10, 8, 6, 4, 2], [3, 5, 7, 9, 11], [12, 10, 8, 6, 4], [5, 7, 9, 11, 13]]) == [0, 4]\n assert candidate(mat = [[100, 200, 300, 400], [150, 250, 350, 450], [125, 225, 325, 425], [175, 275, 375, 475]]) == [1, 3]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [18, 17, 16, 15, 14, 13, 12, 11, 10], [19, 20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42, 43, 44, 45]]) == [4, 8]\n assert candidate(mat = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [10, 9, 8, 7, 6, 5, 4, 3, 2], [11, 10, 9, 8, 7, 6, 5, 4, 3], [12, 11, 10, 9, 8, 7, 6, 5, 4], [13, 12, 11, 10, 9, 8, 7, 6, 5]]) == [4, 0]\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15]]) == [2, 4]\n assert candidate(mat = [[1, 3, 5, 7, 9, 11], [12, 14, 16, 18, 20, 19], [13, 15, 17, 19, 21, 22], [25, 24, 23, 22, 21, 20], [26, 27, 28, 29, 30, 31]]) == [2, 5]\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [3, 5, 7, 9, 11, 13, 15], [4, 6, 8, 10, 12, 14, 16], [5, 7, 9, 11, 13, 15, 17]]) == [4, 6]\n assert candidate(mat = [[1, 2, 3, 4, 5], [16, 17, 18, 19, 6], [15, 24, 25, 20, 7], [14, 23, 22, 21, 8], [13, 12, 11, 10, 9], [26, 27, 28, 29, 30]]) == [2, 2]\n assert candidate(mat = [[5, 2, 1, 6, 7, 8, 10, 4, 9, 1], [15, 14, 13, 16, 17, 18, 20, 19, 21, 2], [22, 23, 24, 25, 26, 27, 28, 29, 30, 31]]) == [2, 9]\n assert candidate(mat = [[1, 2, 3], [6, 5, 4], [7, 8, 9]]) == [2, 2]\n assert candidate(mat = [[5, 25, 9, 20, 15], [30, 35, 28, 33, 26], [29, 40, 31, 36, 27], [24, 39, 32, 37, 34], [23, 38, 21, 22, 16]]) == [2, 1]\n assert candidate(mat = [[20, 30, 25, 10, 15], [100, 120, 115, 80, 85], [75, 82, 87, 55, 60], [65, 70, 67, 78, 77]]) == [1, 1]\n assert candidate(mat = [[10, 100, 1000], [9, 99, 999], [8, 88, 888], [7, 77, 777], [6, 66, 666], [5, 55, 555], [4, 44, 444], [3, 33, 333], [2, 22, 222], [1, 11, 111]]) == [0, 2]\n assert candidate(mat = [[2, 1, 3, 4, 5, 6, 7, 8, 9], [1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [2, 0]\n assert candidate(mat = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == [9, 0]\n assert candidate(mat = [[5, 2, 15, 10, 20], [6, 21, 16, 14, 19], [7, 17, 25, 23, 18], [8, 18, 24, 30, 22], [9, 29, 26, 27, 31]]) == [0, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [1, 0]\n assert candidate(mat = [[5, 10, 15, 20, 25], [9, 14, 19, 24, 29], [13, 18, 23, 28, 33], [17, 22, 27, 32, 37], [21, 26, 31, 36, 41]]) == [4, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]) == [0, 9]\n assert candidate(mat = [[50, 51, 52, 53, 54, 55, 56, 57, 58, 59], [100, 101, 102, 103, 104, 105, 106, 107, 108, 109], [99, 98, 97, 96, 95, 94, 93, 92, 91, 90], [80, 81, 82, 83, 84, 85, 86, 87, 88, 89], [79, 78, 77, 76, 75, 74, 73, 72, 71, 70], [60, 61, 62, 63, 64, 65, 66, 67, 68, 69], [59, 58, 57, 56, 55, 54, 53, 52, 51, 50], [40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [39, 38, 37, 36, 35, 34, 33, 32, 31, 30]]) == [1, 9]\n assert candidate(mat = [[1, 2, 3, 4], [8, 7, 6, 5], [9, 10, 11, 12], [16, 15, 14, 13], [17, 18, 19, 20]]) == [4, 3]\n assert candidate(mat = [[9, 8, 7, 6], [8, 7, 6, 5], [7, 6, 5, 4], [6, 5, 4, 3], [5, 4, 3, 2]]) == [0, 0]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [20, 19, 18, 17, 16, 15], [21, 22, 23, 24, 25, 26], [32, 31, 30, 29, 28, 27], [33, 34, 35, 36, 37, 38], [44, 43, 42, 41, 40, 39]]) == [5, 0]\n assert candidate(mat = [[10, 100, 30, 200, 40, 300], [9, 190, 25, 210, 35, 310], [18, 180, 27, 220, 45, 320], [17, 170, 26, 230, 44, 330], [16, 160, 24, 240, 43, 340], [15, 150, 23, 250, 42, 350]]) == [5, 5]\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]]) == [4, 4]\n assert candidate(mat = [[50, 49, 48, 47, 46, 45, 44, 43, 42, 41], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90]]) == [4, 9]\n assert candidate(mat = [[1, 10, 8, 11, 9], [16, 17, 18, 19, 6], [15, 24, 25, 20, 7], [14, 23, 22, 21, 8], [13, 12, 11, 10, 15]]) == [2, 2]\n assert candidate(mat = [[1, 100, 200, 300, 400, 500], [600, 501, 502, 503, 504, 505], [700, 601, 701, 702, 703, 704], [800, 701, 801, 802, 803, 804], [900, 801, 901, 902, 903, 904]]) == [4, 5]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [30, 31, 32, 33, 34, 35, 36, 37, 38, 39], [49, 48, 47, 46, 45, 44, 43, 42, 41, 40]]) == [3, 0]\n assert candidate(mat = [[1000, 999, 998, 997, 996], [995, 994, 993, 992, 991], [990, 989, 988, 987, 986], [985, 984, 983, 982, 981], [980, 979, 978, 977, 976]]) == [0, 0]\n assert candidate(mat = [[30, 28, 19, 27, 22], [25, 31, 26, 23, 21], [24, 29, 32, 20, 18], [17, 22, 21, 16, 15], [13, 14, 12, 11, 10]]) == [0, 0]\n assert candidate(mat = [[100, 101, 102, 103, 104, 105], [99, 106, 107, 108, 109, 110], [98, 111, 112, 113, 114, 115], [97, 116, 117, 118, 119, 120], [96, 121, 122, 123, 124, 125], [95, 126, 127, 128, 129, 130]]) == [5, 5]\n assert candidate(mat = [[5, 3, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15], [19, 18, 17, 16, 23, 22], [27, 28, 29, 30, 25, 24], [34, 33, 32, 31, 38, 37], [43, 42, 41, 40, 47, 46]]) == [5, 4]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1]]) == [3, 0]\n assert candidate(mat = [[1, 3, 2], [4, 6, 5], [7, 9, 8], [10, 12, 11], [13, 15, 14]]) == [4, 1]\n assert candidate(mat = [[1, 5, 7, 4, 6], [9, 8, 2, 1, 3], [12, 15, 13, 11, 10], [17, 18, 16, 20, 21]]) == [3, 4]\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]]) == [0, 9]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [0, 19]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60, 70], [70, 60, 50, 40, 30, 20, 10], [10, 30, 50, 70, 90, 110, 130], [130, 110, 90, 70, 50, 30, 10]]) == [0, 6]\n assert candidate(mat = [[100, 200, 300, 400], [400, 300, 200, 100], [100, 200, 300, 400], [400, 300, 200, 100]]) == [0, 3]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]]) == [4, 9]\n assert candidate(mat = [[1, 5, 9, 4], [6, 7, 3, 8], [2, 11, 13, 12], [10, 14, 15, 16]]) == [3, 3]\n assert candidate(mat = [[5, 20, 15, 25], [9, 10, 12, 8], [14, 6, 30, 7], [13, 16, 11, 18]]) == [2, 2]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60], [61, 62, 63, 64, 65, 59], [70, 69, 68, 67, 66, 71], [72, 73, 74, 75, 76, 77], [78, 79, 80, 81, 82, 83]]) == [4, 5]\n assert candidate(mat = [[50, 49, 48, 47, 46], [45, 44, 43, 42, 41], [40, 39, 38, 37, 36], [35, 34, 33, 32, 31], [30, 29, 28, 27, 26]]) == [0, 0]\n assert candidate(mat = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [12, 11, 10]]) == [3, 0]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]]) == [6, 2]\n assert candidate(mat = [[100, 200, 300, 400, 500, 600, 700, 800, 900], [901, 801, 701, 601, 501, 401, 301, 201, 101], [102, 202, 302, 402, 502, 602, 702, 802, 902], [903, 803, 703, 603, 503, 403, 303, 203, 103], [104, 204, 304, 404, 504, 604, 704, 804, 904], [905, 805, 705, 605, 505, 405, 305, 205, 105], [106, 206, 306, 406, 506, 606, 706, 806, 906], [907, 807, 707, 607, 507, 407, 307, 207, 107]]) == [0, 8]\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7]]) == [0, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2]]) == [0, 8]\n assert candidate(mat = [[100, 200, 300, 400, 500], [501, 502, 503, 504, 505], [1000, 1001, 1002, 1003, 1004], [1501, 1502, 1503, 1504, 1505], [2000, 2001, 2002, 2003, 2004]]) == [4, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [4, 4]\n assert candidate(mat = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == [9, 0]\n assert candidate(mat = [[10, 11, 12, 13, 14, 15, 16], [9, 8, 7, 6, 5, 4, 3], [2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7]]) == [0, 6]\n assert candidate(mat = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70], [35, 45, 55, 65, 75]]) == [5, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]]) == [4, 4]\n assert candidate(mat = [[1, 1000, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [0, 1]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60], [5, 15, 25, 35, 45, 55], [40, 50, 60, 70, 80, 90], [35, 45, 55, 65, 75, 85], [25, 35, 45, 55, 65, 75], [15, 25, 35, 45, 55, 65]]) == [2, 5]\n assert candidate(mat = [[5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [4, 4]\n assert candidate(mat = [[5, 20, 3, 5, 6], [21, 22, 23, 24, 5], [1, 2, 3, 25, 26], [17, 18, 19, 28, 29], [30, 31, 32, 33, 34]]) == [4, 4]\n assert candidate(mat = [[20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [0, 0]\n"}, "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().findPeakGrid", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findPeakGrid(self, mat: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "findPeakGrid", "parameters": [{"name": "mat", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1903, "task_id": "largest-odd-number-in-string", "difficulty": "Easy", "problem_description": "You are given a string num, representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of num, or an empty string \"\" if no odd integer exists.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: num = \"52\"\nOutput: \"5\"\nExplanation: The only non-empty substrings are \"5\", \"2\", and \"52\". \"5\" is the only odd number.\n\nExample 2:\n\nInput: num = \"4206\"\nOutput: \"\"\nExplanation: There are no odd numbers in \"4206\".\n\nExample 3:\n\nInput: num = \"35427\"\nOutput: \"35427\"\nExplanation: \"35427\" is already an odd number.\n\n \nConstraints:\n\n1 <= num.length <= 105\nnum only consists of digits and does not contain any leading zeros.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"52\") == \"5\"\n assert candidate(num = \"9\") == \"9\"\n assert candidate(num = \"86420\") == \"\"\n assert candidate(num = \"1111111111\") == \"1111111111\"\n assert candidate(num = \"2468\") == \"\"\n assert candidate(num = \"1\") == \"1\"\n assert candidate(num = \"9876543210\") == \"987654321\"\n assert candidate(num = \"0\") == \"\"\n assert candidate(num = \"98765\") == \"98765\"\n assert candidate(num = \"2468013579\") == \"2468013579\"\n assert candidate(num = \"2222222222\") == \"\"\n assert candidate(num = \"8\") == \"\"\n assert candidate(num = \"987654321\") == \"987654321\"\n assert candidate(num = \"2\") == \"\"\n assert candidate(num = \"56789\") == \"56789\"\n assert candidate(num = \"321\") == \"321\"\n assert candidate(num = \"123\") == \"123\"\n assert candidate(num = \"1357924680\") == \"13579\"\n assert candidate(num = \"4206\") == \"\"\n assert candidate(num = \"123456789\") == \"123456789\"\n assert candidate(num = \"35427\") == \"35427\"\n assert candidate(num = \"24680\") == \"\"\n assert candidate(num = \"1234567890\") == \"123456789\"\n assert candidate(num = \"24681\") == \"24681\"\n assert candidate(num = \"11111\") == \"11111\"\n assert candidate(num = \"13579\") == \"13579\"\n assert candidate(num = \"13579135791357913577\") == \"13579135791357913577\"\n assert candidate(num = \"98765432109876543210\") == \"9876543210987654321\"\n assert candidate(num = \"10000000000000000000000000000000000000000000000002\") == \"1\"\n assert candidate(num = \"246802468024680246802468024680246802468024680\") == \"\"\n assert candidate(num = \"02468\") == \"\"\n assert candidate(num = \"9012345678\") == \"901234567\"\n assert candidate(num = \"0000000000\") == \"\"\n assert candidate(num = \"111222333444555\") == \"111222333444555\"\n assert candidate(num = \"135791357913579135791357913579135791357913579\") == \"135791357913579135791357913579135791357913579\"\n assert candidate(num = \"2468101214161820\") == \"2468101214161\"\n assert candidate(num = \"50505050505050505055\") == \"50505050505050505055\"\n assert candidate(num = \"902468013579\") == \"902468013579\"\n assert candidate(num = \"99999999999999999998\") == \"9999999999999999999\"\n assert candidate(num = \"987654321987654321987654321987654321987654321\") == \"987654321987654321987654321987654321987654321\"\n assert candidate(num = \"13579111315\") == \"13579111315\"\n assert candidate(num = \"0246802468024680246802468024680246802468024680\") == \"\"\n assert candidate(num = \"1234567890123456789012345678901234567890123456789\") == \"1234567890123456789012345678901234567890123456789\"\n assert candidate(num = \"1111111111111111111111111111111111111111111111111\") == \"1111111111111111111111111111111111111111111111111\"\n assert candidate(num = \"123456789012345678901\") == \"123456789012345678901\"\n assert candidate(num = \"246802468024680246805\") == \"246802468024680246805\"\n assert candidate(num = \"1000000000000000000000000000000000000000000000000\") == \"1\"\n assert candidate(num = \"5000000000000000000000000000000000000000000000003\") == \"5000000000000000000000000000000000000000000000003\"\n assert candidate(num = \"987654320\") == \"9876543\"\n assert candidate(num = \"111111111111111111111111111111111111111111111111\") == \"111111111111111111111111111111111111111111111111\"\n assert candidate(num = \"8642086420\") == \"\"\n assert candidate(num = \"10\") == \"1\"\n assert candidate(num = \"8080808080808080808080808080808080808080808080807\") == \"8080808080808080808080808080808080808080808080807\"\n assert candidate(num = \"1000000000000000000000000000000000000000000000001\") == \"1000000000000000000000000000000000000000000000001\"\n assert candidate(num = \"2468012345\") == \"2468012345\"\n assert candidate(num = \"0246802468\") == \"\"\n assert candidate(num = \"124\") == \"1\"\n assert candidate(num = \"246802468024680246802468024680\") == \"\"\n assert candidate(num = \"1000000000100000000010000000001000000000100000001\") == \"1000000000100000000010000000001000000000100000001\"\n assert candidate(num = \"1919191919191919191919191919191919191919191919\") == \"1919191919191919191919191919191919191919191919\"\n assert candidate(num = \"2000000002000000002\") == \"\"\n assert candidate(num = \"9999999998\") == \"999999999\"\n assert candidate(num = \"87654321\") == \"87654321\"\n assert candidate(num = \"10000000000000000001\") == \"10000000000000000001\"\n assert candidate(num = \"1357997531\") == \"1357997531\"\n assert candidate(num = \"987654321987654321987654321987654321987654321987654321\") == \"987654321987654321987654321987654321987654321987654321\"\n assert candidate(num = \"00000000000000000001\") == \"00000000000000000001\"\n assert candidate(num = \"987654321987654321987654321\") == \"987654321987654321987654321\"\n assert candidate(num = \"9999999999999999999999999999999999999999999999998\") == \"999999999999999999999999999999999999999999999999\"\n assert candidate(num = \"246801357924680\") == \"2468013579\"\n assert candidate(num = \"11111111111111111112\") == \"1111111111111111111\"\n assert candidate(num = \"20000000000000000000000000000000000000000000000002\") == \"\"\n assert candidate(num = \"13579111315171921\") == \"13579111315171921\"\n assert candidate(num = \"864200000\") == \"\"\n assert candidate(num = \"13579135791357913579\") == \"13579135791357913579\"\n assert candidate(num = \"2020202020202020202020202020202020202020202020\") == \"\"\n assert candidate(num = \"1001001001001001001001001001001001001001001001001\") == \"1001001001001001001001001001001001001001001001001\"\n assert candidate(num = \"24680246802468024689\") == \"24680246802468024689\"\n assert candidate(num = \"246810\") == \"24681\"\n assert candidate(num = \"999999999999999999\") == \"999999999999999999\"\n assert candidate(num = \"12345678909876543210\") == \"1234567890987654321\"\n assert candidate(num = \"99999999999999999999\") == \"99999999999999999999\"\n assert candidate(num = \"0123456789\") == \"0123456789\"\n assert candidate(num = \"1234567890123456789\") == \"1234567890123456789\"\n assert candidate(num = \"9876543210987654321098765432109876543210987654321\") == \"9876543210987654321098765432109876543210987654321\"\n assert candidate(num = \"101010101010101010101010101010101010101010101010101\") == \"101010101010101010101010101010101010101010101010101\"\n assert candidate(num = \"00000000000000000000000000000000000000000000000\") == \"\"\n assert candidate(num = \"2468024680246802468024680246802468024680246802468\") == \"\"\n assert candidate(num = \"9876543219\") == \"9876543219\"\n assert candidate(num = \"9876543210987654321098765432109876543210\") == \"987654321098765432109876543210987654321\"\n assert candidate(num = \"12345678901\") == \"12345678901\"\n assert candidate(num = \"2999999999999999999999999999999999999999999999998\") == \"299999999999999999999999999999999999999999999999\"\n assert candidate(num = \"999999999\") == \"999999999\"\n assert candidate(num = \"98765432101234567890\") == \"9876543210123456789\"\n assert candidate(num = \"11223344556677889900\") == \"112233445566778899\"\n assert candidate(num = \"543210987654321098765432109876543210987654321\") == \"543210987654321098765432109876543210987654321\"\n assert candidate(num = \"13579135791357913578\") == \"1357913579135791357\"\n assert candidate(num = \"100000000000000000001\") == \"100000000000000000001\"\n assert candidate(num = \"555555555555555555555555555555555555555555555555\") == \"555555555555555555555555555555555555555555555555\"\n assert candidate(num = \"123456789012345678902\") == \"1234567890123456789\"\n assert candidate(num = \"111222333444555666777888999\") == \"111222333444555666777888999\"\n assert candidate(num = \"864208642086420\") == \"\"\n assert candidate(num = \"024680246802468\") == \"\"\n assert candidate(num = \"9999999999\") == \"9999999999\"\n assert candidate(num = \"135791357913579135791357913579\") == \"135791357913579135791357913579\"\n assert candidate(num = \"9999999999999999999999999999999999999999999999999\") == \"9999999999999999999999999999999999999999999999999\"\n assert candidate(num = \"86420864208642086420\") == \"\"\n assert candidate(num = \"98765432109876543211\") == \"98765432109876543211\"\n assert candidate(num = \"01234567890123456789\") == \"01234567890123456789\"\n assert candidate(num = \"10000000000000000000\") == \"1\"\n assert candidate(num = \"1000000001\") == \"1000000001\"\n assert candidate(num = \"1999999999999999999999999999999999999999999999999\") == \"1999999999999999999999999999999999999999999999999\"\n assert candidate(num = \"24680246802468024680\") == \"\"\n assert candidate(num = \"222222222222222222222222222222222222222222222222\") == \"\"\n assert candidate(num = \"135790\") == \"13579\"\n assert candidate(num = \"8642097531\") == \"8642097531\"\n assert candidate(num = \"10000000000000000000000000000000000000000000000001\") == \"10000000000000000000000000000000000000000000000001\"\n assert candidate(num = \"123456789012345678901234567890\") == \"12345678901234567890123456789\"\n assert candidate(num = \"12345678901234567891\") == \"12345678901234567891\"\n assert candidate(num = \"1357913579135791357913579135791357913579135791357\") == \"1357913579135791357913579135791357913579135791357\"\n assert candidate(num = \"12345678901234567890123456789012345678901234567890\") == \"1234567890123456789012345678901234567890123456789\"\n assert candidate(num = \"246802468024680\") == \"\"\n assert candidate(num = \"987654321987654321\") == \"987654321987654321\"\n assert candidate(num = \"2222222222222222222222222222222222222222222222221\") == \"2222222222222222222222222222222222222222222222221\"\n assert candidate(num = \"9876543210987654321\") == \"9876543210987654321\"\n assert candidate(num = \"2222222222222222222222222222222222222222222222222\") == \"\"\n assert candidate(num = \"00000000000000000000\") == \"\"\n assert candidate(num = \"135791113151719\") == \"135791113151719\"\n assert candidate(num = \"987654321098765432\") == \"98765432109876543\"\n assert candidate(num = \"135791113151719111\") == \"135791113151719111\"\n assert candidate(num = \"11111111111111111111\") == \"11111111111111111111\"\n assert candidate(num = \"998877665544332211\") == \"998877665544332211\"\n assert candidate(num = \"12345678901234567890\") == \"1234567890123456789\"\n assert candidate(num = \"135791357913579\") == \"135791357913579\"\n assert candidate(num = \"09876543210987654321\") == \"09876543210987654321\"\n assert candidate(num = \"22222222221\") == \"22222222221\"\n assert candidate(num = \"10000000000000000000000000000000000000000001\") == \"10000000000000000000000000000000000000000001\"\n assert candidate(num = \"1357913579\") == \"1357913579\"\n assert candidate(num = \"22222222222222222222\") == \"\"\n assert candidate(num = \"9999999999999999999999999999999999999999998\") == \"999999999999999999999999999999999999999999\"\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().largestOddNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def largestOddNumber(self, num: str) -> str:", "container": "Solution", "callable": "largestOddNumber", "parameters": [{"name": "num", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1904, "task_id": "the-number-of-full-rounds-you-have-played", "difficulty": "Medium", "problem_description": "You are participating in an online chess tournament. There is a chess round that starts every 15 minutes. The first round of the day starts at 00:00, and after every 15 minutes, a new round starts.\n\nFor example, the second round starts at 00:15, the fourth round starts at 00:45, and the seventh round starts at 01:30.\n\nYou are given two strings loginTime and logoutTime where:\n\nloginTime is the time you will login to the game, and\nlogoutTime is the time you will logout from the game.\n\nIf logoutTime is earlier than loginTime, this means you have played from loginTime to midnight and from midnight to logoutTime.\nReturn the number of full chess rounds you have played in the tournament.\nNote: All the given times follow the 24-hour clock. That means the first round of the day starts at 00:00 and the last round of the day starts at 23:45.\n \nExample 1:\n\nInput: loginTime = \"09:31\", logoutTime = \"10:14\"\nOutput: 1\nExplanation: You played one full round from 09:45 to 10:00.\nYou did not play the full round from 09:30 to 09:45 because you logged in at 09:31 after it began.\nYou did not play the full round from 10:00 to 10:15 because you logged out at 10:14 before it ended.\n\nExample 2:\n\nInput: loginTime = \"21:30\", logoutTime = \"03:00\"\nOutput: 22\nExplanation: You played 10 full rounds from 21:30 to 00:00 and 12 full rounds from 00:00 to 03:00.\n10 + 12 = 22.\n\n \nConstraints:\n\nloginTime and logoutTime are in the format hh:mm.\n00 <= hh <= 23\n00 <= mm <= 59\nloginTime and logoutTime are not equal.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(loginTime = \"11:59\",logoutTime = \"12:01\") == 0\n assert candidate(loginTime = \"14:30\",logoutTime = \"15:30\") == 4\n assert candidate(loginTime = \"00:01\",logoutTime = \"00:14\") == 0\n assert candidate(loginTime = \"14:20\",logoutTime = \"15:50\") == 5\n assert candidate(loginTime = \"00:00\",logoutTime = \"23:59\") == 95\n assert candidate(loginTime = \"18:14\",logoutTime = \"18:46\") == 2\n assert candidate(loginTime = \"14:30\",logoutTime = \"14:45\") == 1\n assert candidate(loginTime = \"23:45\",logoutTime = \"00:15\") == 2\n assert candidate(loginTime = \"22:15\",logoutTime = \"23:45\") == 6\n assert candidate(loginTime = \"15:30\",logoutTime = \"15:30\") == 0\n assert candidate(loginTime = \"14:20\",logoutTime = \"14:59\") == 1\n assert candidate(loginTime = \"05:45\",logoutTime = \"06:00\") == 1\n assert candidate(loginTime = \"09:31\",logoutTime = \"10:14\") == 1\n assert candidate(loginTime = \"00:01\",logoutTime = \"23:59\") == 94\n assert candidate(loginTime = \"07:45\",logoutTime = \"08:00\") == 1\n assert candidate(loginTime = \"11:59\",logoutTime = \"12:00\") == 0\n assert candidate(loginTime = \"23:45\",logoutTime = \"00:00\") == 1\n assert candidate(loginTime = \"05:00\",logoutTime = \"06:00\") == 4\n assert candidate(loginTime = \"01:10\",logoutTime = \"01:55\") == 2\n assert candidate(loginTime = \"01:15\",logoutTime = \"01:45\") == 2\n assert candidate(loginTime = \"07:15\",logoutTime = \"07:30\") == 1\n assert candidate(loginTime = \"01:05\",logoutTime = \"01:40\") == 1\n assert candidate(loginTime = \"21:30\",logoutTime = \"03:00\") == 22\n assert candidate(loginTime = \"13:00\",logoutTime = \"13:01\") == 0\n assert candidate(loginTime = \"12:00\",logoutTime = \"12:15\") == 1\n assert candidate(loginTime = \"05:30\",logoutTime = \"06:00\") == 2\n assert candidate(loginTime = \"08:45\",logoutTime = \"09:00\") == 1\n assert candidate(loginTime = \"01:00\",logoutTime = \"02:30\") == 6\n assert candidate(loginTime = \"18:15\",logoutTime = \"18:44\") == 1\n assert candidate(loginTime = \"10:15\",logoutTime = \"11:14\") == 3\n assert candidate(loginTime = \"19:10\",logoutTime = \"20:50\") == 6\n assert candidate(loginTime = \"07:00\",logoutTime = \"07:01\") == 0\n assert candidate(loginTime = \"12:16\",logoutTime = \"12:44\") == 0\n assert candidate(loginTime = \"20:44\",logoutTime = \"21:00\") == 1\n assert candidate(loginTime = \"12:30\",logoutTime = \"14:45\") == 9\n assert candidate(loginTime = \"11:15\",logoutTime = \"11:16\") == 0\n assert candidate(loginTime = \"14:30\",logoutTime = \"14:30\") == 0\n assert candidate(loginTime = \"18:45\",logoutTime = \"19:45\") == 4\n assert candidate(loginTime = \"18:00\",logoutTime = \"07:00\") == 52\n assert candidate(loginTime = \"07:15\",logoutTime = \"07:15\") == 0\n assert candidate(loginTime = \"08:15\",logoutTime = \"08:30\") == 1\n assert candidate(loginTime = \"02:10\",logoutTime = \"05:50\") == 14\n assert candidate(loginTime = \"08:25\",logoutTime = \"09:50\") == 5\n assert candidate(loginTime = \"01:00\",logoutTime = \"01:14\") == 0\n assert candidate(loginTime = \"12:30\",logoutTime = \"13:15\") == 3\n assert candidate(loginTime = \"03:45\",logoutTime = \"05:10\") == 5\n assert candidate(loginTime = \"06:30\",logoutTime = \"06:30\") == 0\n assert candidate(loginTime = \"17:45\",logoutTime = \"18:00\") == 1\n assert candidate(loginTime = \"20:00\",logoutTime = \"20:14\") == 0\n assert candidate(loginTime = \"23:59\",logoutTime = \"00:01\") == 0\n assert candidate(loginTime = \"07:07\",logoutTime = \"07:32\") == 1\n assert candidate(loginTime = \"06:59\",logoutTime = \"07:01\") == 0\n assert candidate(loginTime = \"14:23\",logoutTime = \"14:24\") == 0\n assert candidate(loginTime = \"12:10\",logoutTime = \"12:20\") == 0\n assert candidate(loginTime = \"05:00\",logoutTime = \"05:00\") == 0\n assert candidate(loginTime = \"02:30\",logoutTime = \"02:31\") == 0\n assert candidate(loginTime = \"20:00\",logoutTime = \"04:00\") == 32\n assert candidate(loginTime = \"21:15\",logoutTime = \"21:45\") == 2\n assert candidate(loginTime = \"00:45\",logoutTime = \"01:00\") == 1\n assert candidate(loginTime = \"21:10\",logoutTime = \"21:14\") == 0\n assert candidate(loginTime = \"12:45\",logoutTime = \"13:45\") == 4\n assert candidate(loginTime = \"00:10\",logoutTime = \"01:05\") == 3\n assert candidate(loginTime = \"14:00\",logoutTime = \"14:14\") == 0\n assert candidate(loginTime = \"17:10\",logoutTime = \"18:55\") == 6\n assert candidate(loginTime = \"06:30\",logoutTime = \"07:30\") == 4\n assert candidate(loginTime = \"00:44\",logoutTime = \"00:59\") == 0\n assert candidate(loginTime = \"16:00\",logoutTime = \"16:01\") == 0\n assert candidate(loginTime = \"09:00\",logoutTime = \"21:15\") == 49\n assert candidate(loginTime = \"15:10\",logoutTime = \"15:15\") == 0\n assert candidate(loginTime = \"14:00\",logoutTime = \"18:30\") == 18\n assert candidate(loginTime = \"20:00\",logoutTime = \"21:00\") == 4\n assert candidate(loginTime = \"11:10\",logoutTime = \"11:10\") == 0\n assert candidate(loginTime = \"11:45\",logoutTime = \"12:44\") == 3\n assert candidate(loginTime = \"07:45\",logoutTime = \"08:15\") == 2\n assert candidate(loginTime = \"10:00\",logoutTime = \"10:14\") == 0\n assert candidate(loginTime = \"07:05\",logoutTime = \"08:10\") == 3\n assert candidate(loginTime = \"08:45\",logoutTime = \"09:15\") == 2\n assert candidate(loginTime = \"16:45\",logoutTime = \"17:45\") == 4\n assert candidate(loginTime = \"07:01\",logoutTime = \"07:14\") == 0\n assert candidate(loginTime = \"11:46\",logoutTime = \"12:44\") == 2\n assert candidate(loginTime = \"09:00\",logoutTime = \"16:45\") == 31\n assert candidate(loginTime = \"13:30\",logoutTime = \"14:00\") == 2\n assert candidate(loginTime = \"20:00\",logoutTime = \"20:15\") == 1\n assert candidate(loginTime = \"00:00\",logoutTime = \"04:00\") == 16\n assert candidate(loginTime = \"00:00\",logoutTime = \"00:15\") == 1\n assert candidate(loginTime = \"07:07\",logoutTime = \"07:47\") == 2\n assert candidate(loginTime = \"13:46\",logoutTime = \"13:47\") == 0\n assert candidate(loginTime = \"13:15\",logoutTime = \"14:15\") == 4\n assert candidate(loginTime = \"14:16\",logoutTime = \"15:14\") == 2\n assert candidate(loginTime = \"21:00\",logoutTime = \"21:59\") == 3\n assert candidate(loginTime = \"07:00\",logoutTime = \"07:14\") == 0\n assert candidate(loginTime = \"01:01\",logoutTime = \"24:00\") == 91\n assert candidate(loginTime = \"17:15\",logoutTime = \"17:45\") == 2\n assert candidate(loginTime = \"12:00\",logoutTime = \"12:00\") == 0\n assert candidate(loginTime = \"03:45\",logoutTime = \"04:15\") == 2\n assert candidate(loginTime = \"04:45\",logoutTime = \"05:00\") == 1\n assert candidate(loginTime = \"00:00\",logoutTime = \"23:45\") == 95\n assert candidate(loginTime = \"02:20\",logoutTime = \"02:25\") == 0\n assert candidate(loginTime = \"09:45\",logoutTime = \"10:45\") == 4\n assert candidate(loginTime = \"22:00\",logoutTime = \"01:30\") == 14\n assert candidate(loginTime = \"07:07\",logoutTime = \"07:45\") == 2\n assert candidate(loginTime = \"22:45\",logoutTime = \"23:59\") == 4\n assert candidate(loginTime = \"05:00\",logoutTime = \"24:00\") == 76\n assert candidate(loginTime = \"02:30\",logoutTime = \"03:30\") == 4\n assert candidate(loginTime = \"13:23\",logoutTime = \"14:22\") == 3\n assert candidate(loginTime = \"16:20\",logoutTime = \"18:55\") == 9\n assert candidate(loginTime = \"00:00\",logoutTime = \"00:14\") == 0\n assert candidate(loginTime = \"08:20\",logoutTime = \"09:20\") == 3\n assert candidate(loginTime = \"12:05\",logoutTime = \"12:20\") == 0\n assert candidate(loginTime = \"03:33\",logoutTime = \"04:48\") == 4\n assert candidate(loginTime = \"23:00\",logoutTime = \"23:15\") == 1\n assert candidate(loginTime = \"13:46\",logoutTime = \"14:14\") == 0\n assert candidate(loginTime = \"15:00\",logoutTime = \"15:15\") == 1\n assert candidate(loginTime = \"13:15\",logoutTime = \"13:30\") == 1\n assert candidate(loginTime = \"15:00\",logoutTime = \"16:00\") == 4\n assert candidate(loginTime = \"03:00\",logoutTime = \"03:01\") == 0\n assert candidate(loginTime = \"09:00\",logoutTime = \"09:00\") == 0\n assert candidate(loginTime = \"00:00\",logoutTime = \"24:00\") == 96\n assert candidate(loginTime = \"19:40\",logoutTime = \"20:05\") == 1\n assert candidate(loginTime = \"16:00\",logoutTime = \"17:00\") == 4\n assert candidate(loginTime = \"12:46\",logoutTime = \"13:14\") == 0\n assert candidate(loginTime = \"03:45\",logoutTime = \"03:45\") == 0\n assert candidate(loginTime = \"00:15\",logoutTime = \"00:30\") == 1\n assert candidate(loginTime = \"08:30\",logoutTime = \"09:00\") == 2\n assert candidate(loginTime = \"23:15\",logoutTime = \"00:14\") == 3\n assert candidate(loginTime = \"05:55\",logoutTime = \"06:05\") == 0\n assert candidate(loginTime = \"00:15\",logoutTime = \"23:59\") == 94\n assert candidate(loginTime = \"10:00\",logoutTime = \"10:00\") == 0\n assert candidate(loginTime = \"01:59\",logoutTime = \"02:01\") == 0\n assert candidate(loginTime = \"06:59\",logoutTime = \"07:00\") == 0\n assert candidate(loginTime = \"23:40\",logoutTime = \"00:10\") == 1\n assert candidate(loginTime = \"09:00\",logoutTime = \"09:59\") == 3\n assert candidate(loginTime = \"06:30\",logoutTime = \"07:00\") == 2\n assert candidate(loginTime = \"01:45\",logoutTime = \"02:44\") == 3\n assert candidate(loginTime = \"18:00\",logoutTime = \"18:00\") == 0\n assert candidate(loginTime = \"01:14\",logoutTime = \"01:46\") == 2\n assert candidate(loginTime = \"23:55\",logoutTime = \"00:05\") == 0\n assert candidate(loginTime = \"09:00\",logoutTime = \"18:45\") == 39\n assert candidate(loginTime = \"01:46\",logoutTime = \"02:14\") == 0\n assert candidate(loginTime = \"09:10\",logoutTime = \"09:20\") == 0\n assert candidate(loginTime = \"09:00\",logoutTime = \"09:14\") == 0\n assert candidate(loginTime = \"18:25\",logoutTime = \"19:50\") == 5\n assert candidate(loginTime = \"23:00\",logoutTime = \"23:45\") == 3\n assert candidate(loginTime = \"07:05\",logoutTime = \"08:05\") == 3\n assert candidate(loginTime = \"23:30\",logoutTime = \"00:30\") == 4\n assert candidate(loginTime = \"10:00\",logoutTime = \"24:00\") == 56\n assert candidate(loginTime = \"06:30\",logoutTime = \"09:15\") == 11\n assert candidate(loginTime = \"06:45\",logoutTime = \"07:00\") == 1\n assert candidate(loginTime = \"00:30\",logoutTime = \"00:45\") == 1\n assert candidate(loginTime = \"21:00\",logoutTime = \"22:15\") == 5\n assert candidate(loginTime = \"14:45\",logoutTime = \"15:00\") == 1\n assert candidate(loginTime = \"00:05\",logoutTime = \"00:30\") == 1\n assert candidate(loginTime = \"11:59\",logoutTime = \"12:14\") == 0\n assert candidate(loginTime = \"18:45\",logoutTime = \"19:10\") == 1\n assert candidate(loginTime = \"13:30\",logoutTime = \"16:45\") == 13\n assert candidate(loginTime = \"09:44\",logoutTime = \"09:45\") == 0\n assert candidate(loginTime = \"08:29\",logoutTime = \"08:40\") == 0\n assert candidate(loginTime = \"14:30\",logoutTime = \"16:30\") == 8\n assert candidate(loginTime = \"01:05\",logoutTime = \"02:30\") == 5\n assert candidate(loginTime = \"00:00\",logoutTime = \"01:00\") == 4\n assert candidate(loginTime = \"05:15\",logoutTime = \"05:15\") == 0\n assert candidate(loginTime = \"13:20\",logoutTime = \"13:59\") == 1\n assert candidate(loginTime = \"09:59\",logoutTime = \"10:00\") == 0\n assert candidate(loginTime = \"10:10\",logoutTime = \"11:09\") == 3\n assert candidate(loginTime = \"01:10\",logoutTime = \"01:40\") == 1\n assert candidate(loginTime = \"13:00\",logoutTime = \"13:14\") == 0\n assert candidate(loginTime = \"23:01\",logoutTime = \"23:14\") == 0\n assert candidate(loginTime = \"19:15\",logoutTime = \"20:00\") == 3\n"}, "metadata": {"canonical_parameter_names": ["loginTime", "logoutTime"], "leetcode_dataset_entry_point": "Solution().numberOfRounds", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numberOfRounds(self, loginTime: str, logoutTime: str) -> int:", "container": "Solution", "callable": "numberOfRounds", "parameters": [{"name": "loginTime", "type": "str"}, {"name": "logoutTime", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1905, "task_id": "count-sub-islands", "difficulty": "Medium", "problem_description": "You are given two m x n binary matrices grid1 and grid2 containing only 0's (representing water) and 1's (representing land). An island is a group of 1's connected 4-directionally (horizontal or vertical). Any cells outside of the grid are considered water cells.\nAn island in grid2 is considered a sub-island if there is an island in grid1 that contains all the cells that make up this island in grid2.\nReturn the number of islands in grid2 that are considered sub-islands.\n \nExample 1:\n\n\nInput: grid1 = [[1,1,1,0,0],[0,1,1,1,1],[0,0,0,0,0],[1,0,0,0,0],[1,1,0,1,1]], grid2 = [[1,1,1,0,0],[0,0,1,1,1],[0,1,0,0,0],[1,0,1,1,0],[0,1,0,1,0]]\nOutput: 3\nExplanation: In the picture above, the grid on the left is grid1 and the grid on the right is grid2.\nThe 1s colored red in grid2 are those considered to be part of a sub-island. There are three sub-islands.\n\nExample 2:\n\n\nInput: grid1 = [[1,0,1,0,1],[1,1,1,1,1],[0,0,0,0,0],[1,1,1,1,1],[1,0,1,0,1]], grid2 = [[0,0,0,0,0],[1,1,1,1,1],[0,1,0,1,0],[0,1,0,1,0],[1,0,0,0,1]]\nOutput: 2 \nExplanation: In the picture above, the grid on the left is grid1 and the grid on the right is grid2.\nThe 1s colored red in grid2 are those considered to be part of a sub-island. There are two sub-islands.\n\n \nConstraints:\n\nm == grid1.length == grid2.length\nn == grid1[i].length == grid2[i].length\n1 <= m, n <= 500\ngrid1[i][j] and grid2[i][j] are either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid1 = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 0, 0, 0]],grid2 = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1]]) == 2\n assert candidate(grid1 = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],grid2 = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid1 = [[1, 1, 1], [0, 0, 0], [0, 0, 0]],grid2 = [[1, 1, 1], [0, 0, 0], [0, 0, 0]]) == 1\n assert candidate(grid1 = [[1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == 2\n assert candidate(grid1 = [[0, 0, 0], [0, 0, 0]],grid2 = [[0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [1, 1, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0], [1, 0, 1, 1, 1], [0, 0, 0, 0, 1], [1, 1, 0, 1, 1]]) == 2\n assert candidate(grid1 = [[1, 1, 1, 0, 0], [0, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 0, 1, 1]],grid2 = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [0, 1, 0, 0, 0], [1, 0, 1, 1, 0], [0, 1, 0, 1, 0]]) == 3\n assert candidate(grid1 = [[1, 0, 1], [0, 1, 0], [1, 0, 1]],grid2 = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 1\n assert candidate(grid1 = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 1, 0, 1]]) == 0\n assert candidate(grid1 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],grid2 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 1\n assert candidate(grid1 = [[1, 1, 1], [1, 0, 1], [1, 1, 1]],grid2 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 0, 0, 1, 1], [0, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1]],grid2 = [[1, 0, 0, 1, 1], [0, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 0, 1], [1, 0, 1, 0, 1]]) == 4\n assert candidate(grid1 = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1]],grid2 = [[1, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 0, 1]]) == 2\n assert candidate(grid1 = [[1, 1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0]],grid2 = [[1, 1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0]]) == 3\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 1, 0], [0, 0, 1, 0, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]],grid2 = [[1, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 1, 0], [0, 0, 1, 0, 1, 0, 0], [1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 3\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0]]) == 5\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 1, 1, 1], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[1, 1, 0, 0, 1, 1, 1, 1], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid1 = [[0, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0]],grid2 = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 50\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],grid2 = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 13\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]],grid2 = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]]) == 23\n assert candidate(grid1 = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 0], [0, 1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1, 1], [1, 1, 0, 1, 1, 0, 1]],grid2 = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 0, 1, 0], [0, 1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 1, 1, 1], [1, 1, 0, 1, 0, 0, 1]]) == 5\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],grid2 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 19\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 14\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 3\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]],grid2 = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]]) == 5\n assert candidate(grid1 = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 1\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 1, 0], [1, 1, 1, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1]],grid2 = [[1, 0, 1, 0, 1, 1, 0], [1, 1, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1]]) == 6\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 1], [1, 0, 0, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 3\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 0, 1]],grid2 = [[0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 0, 1]]) == 2\n assert candidate(grid1 = [[1, 1, 0, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 0, 0, 1, 0], [0, 0, 1, 0, 0]],grid2 = [[1, 1, 0, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 1, 0], [1, 1, 0, 1, 0], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid1 = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],grid2 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[1, 0, 0, 0, 0, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 27\n assert candidate(grid1 = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]],grid2 = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 19\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]],grid2 = [[1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 7\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid1 = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 3\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 0, 1], [0, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 1, 1], [1, 1, 1, 0, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0, 0, 1], [1, 0, 0, 1, 0, 0, 1], [0, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 1]]) == 6\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]],grid2 = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 4\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 1, 0, 0, 1], [1, 1, 1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 1, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 0, 0], [1, 0, 0, 0, 0, 1, 0, 0, 1], [1, 1, 1, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 1, 0, 1, 0, 1]]) == 8\n assert candidate(grid1 = [[1, 1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1]],grid2 = [[1, 1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 1, 1, 1], [0, 0, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1]]) == 6\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 0, 0, 0, 1], [0, 1, 1, 1, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]],grid2 = [[0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0]]) == 11\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1]]) == 7\n assert candidate(grid1 = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid1 = [[1, 0, 0, 1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0, 1, 0], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [0, 1, 0, 0, 1, 0, 0, 1, 0, 0], [1, 0, 1, 1, 0, 1, 1, 0, 1, 1], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0, 1, 0], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 17\n assert candidate(grid1 = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0, 1], [0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 0, 1, 1], [1, 0, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1]],grid2 = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0, 1], [0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 0, 1, 1], [1, 0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 3\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 1], [1, 1, 0, 1, 1, 0]],grid2 = [[1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 1], [1, 1, 0, 1, 1, 0]]) == 6\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1]],grid2 = [[0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0]]) == 9\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0, 1, 1], [1, 0, 1, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 0], [1, 0, 1, 1, 1, 0, 1], [1, 1, 0, 0, 0, 1, 1]]) == 4\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]],grid2 = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 14\n assert candidate(grid1 = [[1, 0, 0, 1, 0, 1, 1, 0, 0, 1], [0, 1, 0, 1, 0, 1, 1, 0, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 1, 0, 1, 1, 0, 0, 1], [0, 1, 0, 1, 0, 1, 1, 0, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 33\n assert candidate(grid1 = [[1, 1, 0, 0, 1], [1, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 0, 1], [1, 1, 0, 0, 1]],grid2 = [[1, 1, 0, 0, 1], [1, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 0, 0, 1], [1, 1, 0, 0, 1]]) == 4\n assert candidate(grid1 = [[1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]],grid2 = [[1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 46\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 0, 1]],grid2 = [[1, 1, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 1, 0], [0, 0, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 0, 0, 1]]) == 10\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid1 = [[1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 0, 0, 1, 1], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 0]]) == 26\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid1 = [[1, 0, 0, 1, 1, 0, 1], [0, 0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1]],grid2 = [[1, 0, 0, 1, 0, 0, 1], [0, 0, 1, 1, 0, 0, 0], [1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1]]) == 5\n"}, "metadata": {"canonical_parameter_names": ["grid1", "grid2"], "leetcode_dataset_entry_point": "Solution().countSubIslands", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countSubIslands(self, grid1: list[list[int]], grid2: list[list[int]]) -> int:", "container": "Solution", "callable": "countSubIslands", "parameters": [{"name": "grid1", "type": "list[list[int]]"}, {"name": "grid2", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1906, "task_id": "minimum-absolute-difference-queries", "difficulty": "Medium", "problem_description": "The minimum absolute difference of an array a is defined as the minimum value of |a[i] - a[j]|, where 0 <= i < j < a.length and a[i] != a[j]. If all elements of a are the same, the minimum absolute difference is -1.\n\nFor example, the minimum absolute difference of the array [5,2,3,7,2] is |2 - 3| = 1. Note that it is not 0 because a[i] and a[j] must be different.\n\nYou are given an integer array nums and the array queries where queries[i] = [li, ri]. For each query i, compute the minimum absolute difference of the subarray nums[li...ri] containing the elements of nums between the 0-based indices li and ri (inclusive).\nReturn an array ans where ans[i] is the answer to the ith query.\nA subarray is a contiguous sequence of elements in an array.\nThe value of |x| is defined as:\n\nx if x >= 0.\n-x if x < 0.\n\n \nExample 1:\n\nInput: nums = [1,3,4,8], queries = [[0,1],[1,2],[2,3],[0,3]]\nOutput: [2,1,4,1]\nExplanation: The queries are processed as follows:\n- queries[0] = [0,1]: The subarray is [1,3] and the minimum absolute difference is |1-3| = 2.\n- queries[1] = [1,2]: The subarray is [3,4] and the minimum absolute difference is |3-4| = 1.\n- queries[2] = [2,3]: The subarray is [4,8] and the minimum absolute difference is |4-8| = 4.\n- queries[3] = [0,3]: The subarray is [1,3,4,8] and the minimum absolute difference is |3-4| = 1.\n\nExample 2:\n\nInput: nums = [4,5,2,2,7,10], queries = [[2,3],[0,2],[0,5],[3,5]]\nOutput: [-1,1,1,3]\nExplanation: The queries are processed as follows:\n- queries[0] = [2,3]: The subarray is [2,2] and the minimum absolute difference is -1 because all the\n elements are the same.\n- queries[1] = [0,2]: The subarray is [4,5,2] and the minimum absolute difference is |4-5| = 1.\n- queries[2] = [0,5]: The subarray is [4,5,2,2,7,10] and the minimum absolute difference is |4-5| = 1.\n- queries[3] = [3,5]: The subarray is [2,7,10] and the minimum absolute difference is |7-10| = 3.\n\n \nConstraints:\n\n2 <= nums.length <= 105\n1 <= nums[i] <= 100\n1 <= queries.length <= 2 * 104\n0 <= li < ri < nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50],queries = [[0, 0], [1, 1], [2, 2], [0, 4]]) == [-1, -1, -1, 10]\n assert candidate(nums = [1, 1, 1, 1, 1],queries = [[0, 4], [1, 3]]) == [-1, -1]\n assert candidate(nums = [5, 5, 5, 5],queries = [[0, 3], [1, 2], [2, 3], [0, 1]]) == [-1, -1, -1, -1]\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 5],queries = [[0, 3], [1, 2]]) == [-1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [[0, 4], [1, 3], [2, 2]]) == [1, 1, -1]\n assert candidate(nums = [4, 5, 2, 2, 7, 10],queries = [[2, 3], [0, 2], [0, 5], [3, 5]]) == [-1, 1, 1, 3]\n assert candidate(nums = [1, 3, 4, 8],queries = [[0, 1], [1, 2], [2, 3], [0, 3]]) == [2, 1, 4, 1]\n assert candidate(nums = [100, 1, 100, 1, 100],queries = [[0, 4], [1, 3], [2, 2]]) == [99, 99, -1]\n assert candidate(nums = [100, 1, 2, 3, 4, 100],queries = [[0, 5], [1, 4], [2, 3], [0, 1]]) == [1, 1, 1, 99]\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3],queries = [[0, 6], [1, 5], [2, 4]]) == [1, 1, 1]\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 5]\n assert candidate(nums = [9, 10, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 10], [2, 9], [5, 8], [1, 4], [3, 6]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [99, 99, 99, 99, 99]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 19], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [8, 8, 8, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8],queries = [[0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [0, 9], [10, 19], [5, 15], [1, 18]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == [-1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [1, 1, 1, 1, 3, 1, 1]\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [0, 19], [9, 10]]) == [99, 99, 99, 99, 99, 99]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],queries = [[0, 29], [1, 28], [2, 27], [3, 26], [4, 25]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [5, 1, 4, 8, 2, 3, 7, 6],queries = [[0, 2], [1, 6], [3, 7], [0, 7], [2, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[0, 9], [0, 4], [5, 9], [2, 8], [1, 7]]) == [2, 2, 2, 2, 2]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 8], [0, 4]]) == [-1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 10, 12, 11, 14, 13, 15],queries = [[0, 14], [0, 4], [5, 14], [2, 12], [1, 10]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [3, 6, 5, 4, 7, 8, 1, 2, 9],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4]]) == [1, 1, 1, 1, -1]\n assert candidate(nums = [50, 20, 30, 10, 40],queries = [[0, 4], [1, 3], [2, 4], [0, 3], [1, 4], [0, 2], [3, 4], [0, 1]]) == [10, 10, 10, 10, 10, 10, 30, 30]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 9], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [10, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],queries = [[0, 14], [1, 3], [5, 7], [9, 11], [0, 4], [6, 8]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [2, 5], [5, 8], [1, 1], [8, 9]]) == [1, 1, 1, -1, 1]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [0, 19], [9, 10]]) == [1, 1, 1, 1, 1, 2]\n assert candidate(nums = [3, 1, 2, 1, 3, 1, 2, 1],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2]]) == [1, 1, 1, 2, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [42, 21, 17, 36, 21, 21, 17, 42, 36, 21],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4]]) == [4, 4, 4, 4, -1, 4]\n assert candidate(nums = [1, 2, 1, 3, 4, 5, 4, 3, 2, 1],queries = [[0, 9], [0, 0], [9, 9], [1, 8], [3, 6]]) == [1, -1, -1, 1, 1]\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [10, 1, 2, 10, 1, 2, 10, 1, 2, 10],queries = [[0, 9], [0, 2], [3, 5], [6, 8], [1, 7]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 3, 2, 4, 3, 2, 1, 3, 2, 4],queries = [[0, 3], [1, 5], [2, 8], [3, 9], [0, 9]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],queries = [[0, 5], [5, 9], [0, 9], [2, 7], [1, 8]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 95]\n assert candidate(nums = [5, 2, 5, 2, 7, 5, 2, 2, 5, 7, 5, 2],queries = [[0, 10], [2, 8], [4, 7], [0, 11], [5, 5], [6, 6]]) == [2, 2, 2, 2, -1, -1]\n assert candidate(nums = [50, 40, 30, 20, 10, 20, 30, 40, 50, 60],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [10, 10, 10, 10, 10]\n assert candidate(nums = [3, 1, 5, 1, 3, 2, 5, 3, 2, 1],queries = [[0, 4], [4, 8], [0, 9], [1, 5], [5, 9]]) == [2, 1, 1, 1, 1]\n assert candidate(nums = [2, 5, 1, 4, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],queries = [[0, 9], [0, 4], [5, 9], [2, 8], [1, 7]]) == [10, 10, 10, 10, 10]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n assert candidate(nums = [5, 5, 1, 1, 9, 9, 5, 5, 1, 1, 9, 9],queries = [[0, 11], [0, 3], [2, 5], [4, 7], [6, 9], [8, 11]]) == [4, 4, 8, 4, 4, 8]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [0, 19], [9, 10]]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [20, 30, 10, 40, 50, 10, 20, 30, 40, 50],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [10, 10, 10, 10, 40]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == [1, 1, 1, 1, 1, 1, 1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 2], [2, 4], [4, 6], [6, 8], [1, 3], [3, 5], [5, 7], [7, 9]]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2],queries = [[0, 8], [1, 5], [2, 6], [3, 7], [4, 8], [0, 3], [5, 8], [0, 4]]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],queries = [[0, 9], [0, 4], [5, 9], [2, 8], [1, 7]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [10, 19], [0, 19], [5, 14], [1, 18]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [5, 2, 5, 2, 5, 2, 5, 2, 5, 2],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [3, 3, 3, 3, 3]\n assert candidate(nums = [50, 40, 30, 20, 10, 20, 30, 40, 50],queries = [[0, 4], [4, 8], [0, 8], [1, 7], [2, 6]]) == [10, 10, 10, 10, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 9], [1, 4], [5, 8], [2, 7], [0, 0], [9, 9]]) == [10, 10, 10, 10, -1, -1]\n assert candidate(nums = [1, 5, 3, 9, 7, 11, 13, 15, 17, 19],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 8], [0, 4], [1, 3], [2, 4], [1, 5], [3, 7], [0, 6]]) == [2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],queries = [[0, 10], [0, 5], [5, 10], [2, 8], [1, 9]]) == [5, 5, 5, 5, 5]\n assert candidate(nums = [7, 10, 4, 3, 20, 15],queries = [[0, 5], [1, 2], [2, 4], [3, 5], [0, 4], [1, 3], [2, 5], [0, 3]]) == [1, 6, 1, 5, 1, 1, 1, 1]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [4, 1, 3, 2, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 4], [2, 6], [0, 5], [3, 8], [4, 9], [0, 2], [7, 9]]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [10, 10, 10, 10, 10]\n assert candidate(nums = [50, 1, 51, 2, 52, 3, 53, 4, 54, 5, 55, 6, 56, 7, 57, 8, 58, 9, 59, 10],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 50]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [2, 4, 2, 4, 2, 4, 2, 4, 2, 4],queries = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [5, 6, 6, 5, 5, 6, 5, 6, 6, 5],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 8], [0, 4], [1, 3], [2, 4]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1],queries = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [2, 2, 2, 2, 2]\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 8], [0, 4], [1, 3], [2, 4], [1, 5], [3, 7], [0, 6], [4, 8], [0, 7], [2, 9]]) == [1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [-1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 95]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],queries = [[0, 14], [0, 4], [5, 14], [2, 12], [1, 10]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [10, 10, 10, 10, 10, 10, 10]\n"}, "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().minDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minDifference(self, nums: list[int], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "minDifference", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1909, "task_id": "remove-one-element-to-make-the-array-strictly-increasing", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums, return true if it can be made strictly increasing after removing exactly one element, or false otherwise. If the array is already strictly increasing, return true.\nThe array nums is strictly increasing if nums[i - 1] < nums[i] for each index (1 <= i < nums.length).\n \nExample 1:\n\nInput: nums = [1,2,10,5,7]\nOutput: true\nExplanation: By removing 10 at index 2 from nums, it becomes [1,2,5,7].\n[1,2,5,7] is strictly increasing, so return true.\n\nExample 2:\n\nInput: nums = [2,3,1,2]\nOutput: false\nExplanation:\n[3,1,2] is the result of removing the element at index 0.\n[2,1,2] is the result of removing the element at index 1.\n[2,3,2] is the result of removing the element at index 2.\n[2,3,1] is the result of removing the element at index 3.\nNo resulting array is strictly increasing, so return false.\nExample 3:\n\nInput: nums = [1,1,1]\nOutput: false\nExplanation: The result of removing any element is [1,1].\n[1,1] is not strictly increasing, so return false.\n\n \nConstraints:\n\n2 <= nums.length <= 1000\n1 <= nums[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 5]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 2, 2, 3]) == True\n assert candidate(nums = [1, 1, 1]) == False\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 3]) == True\n assert candidate(nums = [3, 5, 4, 6, 7]) == True\n assert candidate(nums = [1, 2, 10, 5, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5]) == True\n assert candidate(nums = [10, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [5, 2, 3, 4]) == True\n assert candidate(nums = [100, 20, 30]) == True\n assert candidate(nums = [3, 2, 1]) == False\n assert candidate(nums = [5, 7, 1, 8]) == True\n assert candidate(nums = [1, 2, 3, 3, 4]) == True\n assert candidate(nums = [5, 4, 3, 2, 1]) == False\n assert candidate(nums = [1, 2, 2, 3, 4]) == True\n assert candidate(nums = [1, 2, 3]) == True\n assert candidate(nums = [2, 3, 1, 2]) == False\n assert candidate(nums = [100, 200, 150, 300]) == True\n assert candidate(nums = [100, 200, 150, 300, 400]) == True\n assert candidate(nums = [1, 3, 2, 4]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 19]) == True\n assert candidate(nums = [1, 2, 3, 5, 4, 3, 2, 6, 7, 8]) == False\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 8, 9]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 3]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 5, 15, 16, 17]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 21]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 22]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 5, 18, 19]) == True\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 8, 7, 9]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 1000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 11, 12, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 0]) == True\n assert candidate(nums = [1, 5, 2, 3, 4, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9, 11]) == True\n assert candidate(nums = [1, 3, 2, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 5, 4, 3, 6, 7, 8]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 10, 8, 9, 11, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 14]) == True\n assert candidate(nums = [1, 2, 3, 5, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == False\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 20, 27]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 5]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 20, 23]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 11]) == True\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9, 11, 12]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == False\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 55]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 12, 13]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == True\n assert candidate(nums = [1, 3, 5, 4, 7, 9, 8, 10, 12, 14, 15]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 18]) == True\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 25]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 18, 21, 23, 25, 27, 29]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7, 8]) == True\n assert candidate(nums = [6, 7, 8, 9, 10, 5, 11, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 6, 7]) == True\n assert candidate(nums = [8, 9, 10, 2, 11, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 8, 10]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 2, 17, 19, 21]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 5, 19, 20]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 16, 17, 18]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 5, 21, 22]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 24]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 3]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 21]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 11, 12]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 12, 14]) == True\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [1, 2, 3, 10, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 15, 16, 17, 18, 19]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 7, 9, 10, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 23]) == True\n assert candidate(nums = [100, 200, 150, 250, 300]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 100, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 100, 4, 5, 6]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 25]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 4, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 15]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 10, 12, 14]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 3, 5, 7, 6, 8, 9]) == True\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 9, 8, 10, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 10, 5, 6]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10, 9, 11, 12]) == True\n assert candidate(nums = [1, 3, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 10, 11]) == False\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 9, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 8]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5]) == False\n assert candidate(nums = [3, 5, 6, 7, 8, 9, 10, 5, 11, 12]) == True\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 3, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 8, 9]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 3]) == True\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 3, 14]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 6]) == False\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 10, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 4, 11]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 5]) == True\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 17]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 11]) == True\n assert candidate(nums = [10, 20, 30, 25, 40, 50]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 5, 20, 21]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 16]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 20, 22]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 8, 9, 11, 12, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 10, 13, 14]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 6, 7, 8]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 10]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5, 6, 7, 8]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 4, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 20]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().canBeIncreasing", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canBeIncreasing(self, nums: list[int]) -> bool:", "container": "Solution", "callable": "canBeIncreasing", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1910, "task_id": "remove-all-occurrences-of-a-substring", "difficulty": "Medium", "problem_description": "Given two strings s and part, perform the following operation on s until all occurrences of the substring part are removed:\n\nFind the leftmost occurrence of the substring part and remove it from s.\n\nReturn s after removing all occurrences of part.\nA substring is a contiguous sequence of characters in a string.\n \nExample 1:\n\nInput: s = \"daabcbaabcbc\", part = \"abc\"\nOutput: \"dab\"\nExplanation: The following operations are done:\n- s = \"daabcbaabcbc\", remove \"abc\" starting at index 2, so s = \"dabaabcbc\".\n- s = \"dabaabcbc\", remove \"abc\" starting at index 4, so s = \"dababc\".\n- s = \"dababc\", remove \"abc\" starting at index 3, so s = \"dab\".\nNow s has no occurrences of \"abc\".\n\nExample 2:\n\nInput: s = \"axxxxyyyyb\", part = \"xy\"\nOutput: \"ab\"\nExplanation: The following operations are done:\n- s = \"axxxxyyyyb\", remove \"xy\" starting at index 4 so s = \"axxxyyyb\".\n- s = \"axxxyyyb\", remove \"xy\" starting at index 3 so s = \"axxyyb\".\n- s = \"axxyyb\", remove \"xy\" starting at index 2 so s = \"axyb\".\n- s = \"axyb\", remove \"xy\" starting at index 1 so s = \"ab\".\nNow s has no occurrences of \"xy\".\n\n \nConstraints:\n\n1 <= s.length <= 1000\n1 <= part.length <= 1000\ns​​​​​​ and part consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcd\",part = \"efg\") == \"abcd\"\n assert candidate(s = \"zzzz\",part = \"zz\") == \"\"\n assert candidate(s = \"abcdabcdabcd\",part = \"abcd\") == \"\"\n assert candidate(s = \"abcdefg\",part = \"xyz\") == \"abcdefg\"\n assert candidate(s = \"abcde\",part = \"f\") == \"abcde\"\n assert candidate(s = \"daabcbaabcbc\",part = \"abc\") == \"dab\"\n assert candidate(s = \"abcabcabc\",part = \"bca\") == \"abc\"\n assert candidate(s = \"axxxxyyyyb\",part = \"xy\") == \"ab\"\n assert candidate(s = \"hello\",part = \"ll\") == \"heo\"\n assert candidate(s = \"abcabcabc\",part = \"abc\") == \"\"\n assert candidate(s = \"aaaa\",part = \"aa\") == \"\"\n assert candidate(s = \"mississippi\",part = \"issi\") == \"mssippi\"\n assert candidate(s = \"abababab\",part = \"aba\") == \"bb\"\n assert candidate(s = \"aaaaaaa\",part = \"aa\") == \"a\"\n assert candidate(s = \"zzzzzzz\",part = \"zzz\") == \"z\"\n assert candidate(s = \"banana\",part = \"na\") == \"ba\"\n assert candidate(s = \"abcabcabc\",part = \"cab\") == \"abc\"\n assert candidate(s = \"aabababa\",part = \"aba\") == \"ba\"\n assert candidate(s = \"abababababababababab\",part = \"abab\") == \"\"\n assert candidate(s = \"qwertyuiopqwertyuiopqwertyuiop\",part = \"erty\") == \"qwuiopqwuiopqwuiop\"\n assert candidate(s = \"hellohellohellohellohello\",part = \"hello\") == \"\"\n assert candidate(s = \"abcdefghij\",part = \"xyz\") == \"abcdefghij\"\n assert candidate(s = \"abcdabcdabcdabcd\",part = \"dabc\") == \"abcd\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",part = \"xyz\") == \"abcdefghijklmnopqrstuvw\"\n assert candidate(s = \"aabbccddeeff\",part = \"bbcc\") == \"aaddeeff\"\n assert candidate(s = \"exampleexampleexampleexample\",part = \"exampleexample\") == \"\"\n assert candidate(s = \"aaaaaaabbbbbbbcccccc\",part = \"abc\") == \"aaaaaaabbbbbbbcccccc\"\n assert candidate(s = \"aaaaabbbbbcccc\",part = \"ab\") == \"cccc\"\n assert candidate(s = \"thisisaverylongstringthatwillbeusedtocheckthefunctionality\",part = \"is\") == \"thaverylongstringthatwillbeusedtocheckthefunctionality\"\n assert candidate(s = \"yyyyyyyyyyyyyyyyyyyy\",part = \"yyyy\") == \"\"\n assert candidate(s = \"lkjhgfedcba\",part = \"fe\") == \"lkjhgdcba\"\n assert candidate(s = \"hellohellohello\",part = \"lohe\") == \"hellllo\"\n assert candidate(s = \"abcdeabcdeabcdeabcde\",part = \"abc\") == \"dededede\"\n assert candidate(s = \"hellohellohellohello\",part = \"elloh\") == \"hello\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",part = \"abc\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"aaaaaaaaaabcdeeeeee\",part = \"aaa\") == \"abcdeeeeee\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\",part = \"qwerty\") == \"uiopasdfghjklzxcvbnmuiop\"\n assert candidate(s = \"zzzzzzzzzz\",part = \"zz\") == \"\"\n assert candidate(s = \"stackoverflow\",part = \"flow\") == \"stackover\"\n assert candidate(s = \"aaaaaaabaaaaa\",part = \"aaaa\") == \"aaaba\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",part = \"ghij\") == \"abcdefabcdefabcdef\"\n assert candidate(s = \"acabacabacabacabacab\",part = \"acab\") == \"\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",part = \"abcdefghij\") == \"\"\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccc\",part = \"abccba\") == \"aaaaaaaaaabbbbbbbbbbcccccc\"\n assert candidate(s = \"abcdefghij\",part = \"jihgfedcba\") == \"abcdefghij\"\n assert candidate(s = \"qwertyuiopqwertyuiop\",part = \"rty\") == \"qweuiopqweuiop\"\n assert candidate(s = \"ababababab\",part = \"aba\") == \"bbab\"\n assert candidate(s = \"aabbccddeeffgg\",part = \"bbcc\") == \"aaddeeffgg\"\n assert candidate(s = \"racecaracecaracecar\",part = \"aceca\") == \"rrrr\"\n assert candidate(s = \"xylophoneisfunxylophoneisfunxylophoneisfun\",part = \"xylophoneis\") == \"funfunfun\"\n assert candidate(s = \"abacabadabacaba\",part = \"abaca\") == \"badba\"\n assert candidate(s = \"supercalifragilisticexpialidocious\",part = \"cious\") == \"supercalifragilisticexpialido\"\n assert candidate(s = \"abababababababababab\",part = \"bab\") == \"aaaaa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",part = \"abcabc\") == \"\"\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\",part = \"defabc\") == \"abcdef\"\n assert candidate(s = \"abracadabra\",part = \"abra\") == \"cad\"\n assert candidate(s = \"aaabaaaabaaa\",part = \"aab\") == \"aaaaaa\"\n assert candidate(s = \"longstringwithsomerepeatedpatternpattern\",part = \"pattern\") == \"longstringwithsomerepeated\"\n assert candidate(s = \"programmingprogrammingprogramming\",part = \"gram\") == \"promingpromingproming\"\n assert candidate(s = \"abcabcabcabcabcabcabcabc\",part = \"abcabc\") == \"\"\n assert candidate(s = \"aaaaabaaaaabaaaaab\",part = \"ba\") == \"aaaaaaaaaaaaab\"\n assert candidate(s = \"hellohellohellohellohellohello\",part = \"ll\") == \"heoheoheoheoheoheo\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\",part = \"qwerty\") == \"uiopasdfghjklzxcvbnmuiopasdfghjklzxcvbnm\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\",part = \"xyzxyz\") == \"\"\n assert candidate(s = \"bananaapplebanana\",part = \"an\") == \"baappleba\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",part = \"mnop\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"xyxyxyxyxy\",part = \"xyx\") == \"yyxy\"\n assert candidate(s = \"hellohellohellohello\",part = \"llohe\") == \"hello\"\n assert candidate(s = \"aaaaabbbbbcccccd\",part = \"abc\") == \"aaaaabbbbbcccccd\"\n assert candidate(s = \"abcdabcdabcd\",part = \"cdab\") == \"abcd\"\n assert candidate(s = \"xyzxyzxyzxyz\",part = \"xyz\") == \"\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",part = \"nopqr\") == \"abcdefghijklmstuvwxyz\"\n assert candidate(s = \"xyzyxzyxzyxzyxzyxzyx\",part = \"zyx\") == \"xy\"\n assert candidate(s = \"zzzzzzzzzz\",part = \"zzz\") == \"z\"\n assert candidate(s = \"abcdefgabcdefgabcdefg\",part = \"efgabc\") == \"abcdddefg\"\n assert candidate(s = \"ababababab\",part = \"abab\") == \"ab\"\n assert candidate(s = \"xxxxxxxxxxxxxxxxxxxx\",part = \"xxx\") == \"xx\"\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",part = \"micro\") == \"pneumonoultrascopicsilicovolcanoconiosis\"\n assert candidate(s = \"abcdefgabcdefg\",part = \"def\") == \"abcgabcg\"\n assert candidate(s = \"aabbccddeeaabbccddeeaabbccddeeaabbccdd\",part = \"abcd\") == \"aabbccddeeaabbccddeeaabbccddeeaabbccdd\"\n assert candidate(s = \"abacabadabacabadabacaba\",part = \"abad\") == \"abacabacabacaba\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\",part = \"erty\") == \"qwuiopasdfghjklzxcvbnmqwuiop\"\n assert candidate(s = \"abcdabcdeabcdabcdeabcd\",part = \"bcde\") == \"abcdaabcdaabcd\"\n assert candidate(s = \"abcdabcdabcdabcd\",part = \"abcd\") == \"\"\n assert candidate(s = \"ababababababababababababababababababababababababababababababababab\",part = \"abab\") == \"ab\"\n assert candidate(s = \"abcdabcdabcdabcd\",part = \"abcdabcd\") == \"\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",part = \"zyx\") == \"wvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwerty\",part = \"erty\") == \"qwuiopasdfghjklzxcvbnmqw\"\n assert candidate(s = \"noonnoonnoonnoon\",part = \"noon\") == \"\"\n assert candidate(s = \"oneonetwoonethreeonefouronefiveonesixone\",part = \"oneone\") == \"twoonethreeonefouronefiveonesixone\"\n assert candidate(s = \"12345678901234567890\",part = \"345\") == \"12678901267890\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",part = \"def\") == \"abcghijklmnopqrstuvwxyz\"\n assert candidate(s = \"thisisaverylongstringwithrepeatedpatterns\",part = \"pattern\") == \"thisisaverylongstringwithrepeateds\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",part = \"mnop\") == \"qwertyuiopasdfghjklzxcvbnm\"\n assert candidate(s = \"abcdefghijabcdefghij\",part = \"cdefg\") == \"abhijabhij\"\n assert candidate(s = \"aaaaaaaaaaaabbbbbaaaaaaaaaaabbbbbaaaaaaaaaaabbbbbaaaaaaaaaaabbbbb\",part = \"aaaabbbb\") == \"aaaaaaaabaaaaaaabaaaaaaabaaaaaaab\"\n assert candidate(s = \"abcdefghabcdefghabcdefgh\",part = \"efgh\") == \"abcdabcdabcd\"\n assert candidate(s = \"thisisaverylongstringwithrepeatedpattern\",part = \"pattern\") == \"thisisaverylongstringwithrepeated\"\n assert candidate(s = \"abababababababab\",part = \"abab\") == \"\"\n assert candidate(s = \"abcdeabcdeabcdeabcde\",part = \"abcde\") == \"\"\n assert candidate(s = \"abababababababababab\",part = \"ababa\") == \"bbbab\"\n assert candidate(s = \"abcdeabcdeabcde\",part = \"bcde\") == \"aaa\"\n assert candidate(s = \"abcdefghij\",part = \"gh\") == \"abcdefij\"\n assert candidate(s = \"aabbccddeeff\",part = \"abc\") == \"aabbccddeeff\"\n assert candidate(s = \"xyxxyxyxyx\",part = \"xyx\") == \"y\"\n assert candidate(s = \"aaaaaa\",part = \"aa\") == \"\"\n assert candidate(s = \"abcdefabcdef\",part = \"defabc\") == \"abcdef\"\n assert candidate(s = \"zzzzzzzz\",part = \"zz\") == \"\"\n assert candidate(s = \"bananaanananasanananananana\",part = \"ana\") == \"bnnasnnna\"\n assert candidate(s = \"abcabcabcabcabcabc\",part = \"abcabc\") == \"\"\n assert candidate(s = \"aaaaaa\",part = \"a\") == \"\"\n assert candidate(s = \"abcdefghij\",part = \"efg\") == \"abcdhij\"\n assert candidate(s = \"onetwothreefourfivesixseveneightnineseven\",part = \"seven\") == \"onetwothreefourfivesixeightnine\"\n assert candidate(s = \"abcabcabcabcabcabc\",part = \"ab\") == \"cccccc\"\n assert candidate(s = \"mississippi\",part = \"iss\") == \"mippi\"\n assert candidate(s = \"aaaabbbbcccc\",part = \"bbcc\") == \"aaaa\"\n assert candidate(s = \"abracadabraabracadabra\",part = \"bracad\") == \"aabraaabra\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",part = \"abcdabcd\") == \"\"\n assert candidate(s = \"abababababababab\",part = \"aba\") == \"bbbb\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",part = \"zzzz\") == \"zz\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\",part = \"xyzxyz\") == \"\"\n assert candidate(s = \"aaaaaaaaaa\",part = \"aaa\") == \"a\"\n assert candidate(s = \"repeatedrepeatedrepeatedrepeated\",part = \"repeated\") == \"\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzz\",part = \"zzzz\") == \"zz\"\n assert candidate(s = \"repeatedsubstringrepeatedsubstring\",part = \"ted\") == \"repeasubstringrepeasubstring\"\n assert candidate(s = \"abcdefghijkabcdefghijkabcdefghijk\",part = \"efg\") == \"abcdhijkabcdhijkabcdhijk\"\n assert candidate(s = \"mnopqrsmnopqrsmnopqrs\",part = \"mnopqrs\") == \"\"\n assert candidate(s = \"ananasanananas\",part = \"ana\") == \"nasns\"\n assert candidate(s = \"zzzzz\",part = \"zz\") == \"z\"\n assert candidate(s = \"thisisaverylongstringwithrepeatedparts\",part = \"thisis\") == \"averylongstringwithrepeatedparts\"\n"}, "metadata": {"canonical_parameter_names": ["s", "part"], "leetcode_dataset_entry_point": "Solution().removeOccurrences", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def removeOccurrences(self, s: str, part: str) -> str:", "container": "Solution", "callable": "removeOccurrences", "parameters": [{"name": "s", "type": "str"}, {"name": "part", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1911, "task_id": "maximum-alternating-subsequence-sum", "difficulty": "Medium", "problem_description": "The alternating sum of a 0-indexed array is defined as the sum of the elements at even indices minus the sum of the elements at odd indices.\\r\n\\r\n\\r\n\tFor example, the alternating sum of [4,2,5,3] is (4 + 5) - (2 + 3) = 4.\\r\n\\r\n\\r\nGiven an array nums, return the maximum alternating sum of any subsequence of nums (after reindexing the elements of the subsequence).\\r\n\\r\n\\r\n\\r\n\\r\nA subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the remaining elements' relative order. For example, [2,7,4] is a subsequence of [4,2,3,7,2,1,4] (the underlined elements), while [2,4,2] is not.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: nums = [4,2,5,3]\\r\nOutput: 7\\r\nExplanation: It is optimal to choose the subsequence [4,2,5] with alternating sum (4 + 5) - 2 = 7.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: nums = [5,6,7,8]\\r\nOutput: 8\\r\nExplanation: It is optimal to choose the subsequence [8] with alternating sum 8.\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: nums = [6,2,1,2,4,5]\\r\nOutput: 10\\r\nExplanation: It is optimal to choose the subsequence [6,1,5] with alternating sum (6 + 5) - 1 = 10.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= nums.length <= 105\\r\n\t1 <= nums[i] <= 105\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996]) == 100000\n assert candidate(nums = [4, 2, 5, 3]) == 7\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [6, 2, 1, 2, 4, 5]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [100]) == 100\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50]) == 50\n assert candidate(nums = [1, 100000, 1, 100000, 1]) == 199999\n assert candidate(nums = [5, 6, 7, 8]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [100000, 1, 100000, 1, 100000]) == 299998\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5]) == 54\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 100000\n assert candidate(nums = [100, 0, 100, 0, 100]) == 300\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == 499996\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 991\n assert candidate(nums = [100, 50, 100, 50, 100, 50, 100]) == 250\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 24\n assert candidate(nums = [100, 10, 200, 20, 300, 30, 400, 40, 500, 50]) == 1400\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 499976\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15]) == 106\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1]) == 10\n assert candidate(nums = [100000, 50000, 100000, 50000, 100000, 50000, 100000, 50000, 100000, 50000]) == 300000\n assert candidate(nums = [5, 3, 8, 1, 4, 7, 2, 6, 9]) == 23\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1000\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70]) == 110\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 6\n assert candidate(nums = [9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9]) == 65\n assert candidate(nums = [120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 120\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == 499996\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 9\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5]) == 30\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 100000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 19\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 11\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 15\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 7\n assert candidate(nums = [5, 3, 8, 12, 4, 9, 2, 7, 6, 10]) == 28\n assert candidate(nums = [10, 15, 10, 5, 20, 25, 30, 35, 40, 45]) == 55\n assert candidate(nums = [100000, 99999, 100000, 99998, 100000, 99997, 100000, 99996, 100000, 99995]) == 100010\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9]) == 15\n assert candidate(nums = [5, 3, 8, 6, 7, 2, 9, 4, 1, 10]) == 27\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 140\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 11\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50]) == 100\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 29\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 28\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 17\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 17\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 0, 9, 1, 8, 2, 7, 3, 6, 4, 5, 0]) == 50\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [9, 7, 8, 5, 6, 3, 4, 1, 2, 10]) == 21\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 20\n assert candidate(nums = [5, 3, 8, 6, 11, 9, 14, 12, 17, 15, 20, 18, 23, 21, 25]) == 39\n assert candidate(nums = [5, 3, 6, 7, 2, 9, 4, 10, 1, 11]) == 32\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 11\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 13\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 20\n assert candidate(nums = [75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 75\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 21\n assert candidate(nums = [5, 1, 4, 2, 7, 3, 6, 8]) == 18\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]) == 46\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 13\n assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4]) == 399984\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 120\n assert candidate(nums = [10, 5, 15, 10, 20, 15, 25, 20, 30, 25]) == 50\n assert candidate(nums = [5, 1, 4, 2, 3]) == 9\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9, 1, 4, 2, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 38\n assert candidate(nums = [5, 1, 4, 2, 3, 1, 2, 1, 3, 2, 1]) == 12\n assert candidate(nums = [5, 3, 8, 12, 7, 10, 1, 15, 9, 20]) == 42\n assert candidate(nums = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == 499990\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 110\n assert candidate(nums = [100, 200, 150, 300, 250, 350, 400, 300, 450, 500]) == 700\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 5, 4, 6, 3, 7, 2, 8, 1, 9]) == 45\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 150\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 476\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 10000, 1000, 100, 10]) == 100000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 75\n assert candidate(nums = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 150\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxAlternatingSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxAlternatingSum(self, nums: List[int]) -> int:", "container": "Solution", "callable": "maxAlternatingSum", "parameters": [{"name": "nums", "type": "List[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1913, "task_id": "maximum-product-difference-between-two-pairs", "difficulty": "Easy", "problem_description": "The product difference between two pairs (a, b) and (c, d) is defined as (a * b) - (c * d).\\r\n\\r\n\\r\n\tFor example, the product difference between (5, 6) and (2, 7) is (5 * 6) - (2 * 7) = 16.\\r\n\\r\n\\r\nGiven an integer array nums, choose four distinct indices w, x, y, and z such that the product difference between pairs (nums[w], nums[x]) and (nums[y], nums[z]) is maximized.\\r\n\\r\nReturn the maximum such product difference.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: nums = [5,6,2,7,4]\\r\nOutput: 34\\r\nExplanation: We can choose indices 1 and 3 for the first pair (6, 7) and indices 2 and 4 for the second pair (2, 4).\\r\nThe product difference is (6 * 7) - (2 * 4) = 34.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: nums = [4,2,5,9,7,4,8]\\r\nOutput: 64\\r\nExplanation: We can choose indices 3 and 6 for the first pair (9, 8) and indices 1 and 5 for the second pair (2, 4).\\r\nThe product difference is (9 * 8) - (2 * 4) = 64.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t4 <= nums.length <= 104\\r\n\t1 <= nums[i] <= 104\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 6, 2, 7, 4]) == 34\n assert candidate(nums = [9, 5, 8, 6, 7, 3, 2, 1, 4]) == 70\n assert candidate(nums = [1, 2, 3, 4]) == 10\n assert candidate(nums = [4, 2, 5, 9, 7, 4, 8]) == 64\n assert candidate(nums = [10000, 1, 10000, 1]) == 99999999\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 72\n assert candidate(nums = [9, 5, 8, 6, 7, 3, 4, 2, 1]) == 70\n assert candidate(nums = [9, 5, 8, 3, 7]) == 57\n assert candidate(nums = [10000, 1, 10000, 1, 10000, 1]) == 99999999\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 88000000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 2080000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 896\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 880000\n assert candidate(nums = [2345, 1234, 5678, 6789, 3456, 4567, 7890, 8901]) == 67335160\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 11766\n assert candidate(nums = [5000, 5000, 5000, 5000, 1, 1, 1, 1]) == 24999999\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10000, 10000, 10000, 10000, 10000]) == 99999999\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 832\n assert candidate(nums = [10000, 10000, 10000, 10000, 9999, 9999, 9999, 9999]) == 19999\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 1, 9999]) == 49990000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 780\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 80\n assert candidate(nums = [10000, 1, 9999, 2, 9998, 3, 9997, 4, 9996, 5]) == 99989998\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996]) == 99989998\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 3258\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10000, 10000, 10000, 10000, 10000]) == 99999975\n assert candidate(nums = [10000, 9999, 1, 2]) == 99989998\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 159928\n assert candidate(nums = [8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 100, 200, 300, 400, 500, 600, 700, 800]) == 55980000\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19]) == 357\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 10, 20, 30, 40, 50]) == 899800\n assert candidate(nums = [5000, 5000, 5000, 5000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 24999999\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009]) == 16072\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 99\n assert candidate(nums = [10000, 10000, 10000, 10000, 1, 1, 1, 1]) == 99999999\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 2015\n assert candidate(nums = [3333, 6666, 4444, 7777, 2222, 8888, 1111, 9999]) == 86402470\n assert candidate(nums = [5000, 5000, 4999, 4999, 4998, 4998, 4997, 4997, 4996, 4996]) == 39984\n assert candidate(nums = [8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 500, 100, 50, 10, 5, 1, 2, 3, 4, 6, 7, 8]) == 55999998\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86]) == 2418\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996, 6, 9995, 7, 9994, 8, 9993, 9, 9992, 10, 9991]) == 99989998\n assert candidate(nums = [2, 3, 6, 7, 8, 10, 5, 4, 1, 9]) == 88\n assert candidate(nums = [10000, 10000, 10000, 1, 1, 1, 9999, 9999, 9999, 2]) == 99999999\n assert candidate(nums = [9999, 9998, 9997, 9996, 2, 3, 4, 5]) == 99969996\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 1672\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 378\n assert candidate(nums = [3, 9, 10, 2, 18, 15, 11, 1, 17, 7]) == 304\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996, 6, 9995, 7, 9994, 8]) == 99989998\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4]) == 899998\n assert candidate(nums = [1, 1, 1, 1, 10000, 10000, 10000, 10000, 9999, 9999, 9999, 9999]) == 99999999\n assert candidate(nums = [10000, 9999, 9998, 9997, 1, 2, 3, 4, 5, 6]) == 99989998\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997]) == 99989998\n assert candidate(nums = [5000, 5001, 4999, 4998, 5002, 5003]) == 40004\n assert candidate(nums = [1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000]) == 99999999\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 1, 2, 3, 4, 5]) == 25035010\n assert candidate(nums = [10000, 9999, 9998, 9997, 1, 2, 3, 4]) == 99989998\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 10000, 10000]) == 99999991\n assert candidate(nums = [1, 10000, 1, 10000, 1, 10000, 1, 10000]) == 99999999\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 8800\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 2080000\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 8627\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 208\n assert candidate(nums = [1500, 1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 2080000\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996]) == 99989998\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 880000\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97]) == 9898\n assert candidate(nums = [1, 2, 3, 4, 5, 10000, 9999, 9998, 9997, 9996]) == 99989998\n assert candidate(nums = [1, 1, 1, 1, 10000, 10000, 10000, 10000, 10000, 10000]) == 99999999\n assert candidate(nums = [2500, 2501, 2502, 2503, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 6262504\n assert candidate(nums = [5000, 4000, 3000, 2000, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 19999997\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 378\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 360\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10000, 9999]) == 99989999\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5]) == 899998\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985]) == 279790\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 8\n assert candidate(nums = [9999, 1, 9998, 2, 9997, 3, 9996, 4, 9995, 5, 9994, 6, 9993, 7, 9992, 8, 9991, 9, 9990, 10]) == 99970000\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011, 5012, 5013, 5014, 5015]) == 140210\n assert candidate(nums = [10000, 1, 9999, 2, 9998, 3, 9997, 4, 9996, 5]) == 99989998\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 99989998\n assert candidate(nums = [10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 189998\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 1, 2, 3, 4, 5]) == 24999998\n assert candidate(nums = [3000, 6000, 9000, 12000, 15000, 18000, 21000, 24000, 27000, 30000, 33000, 36000, 39000, 42000, 45000, 48000, 51000, 54000, 57000, 60000, 1, 2, 3, 4, 5]) == 3419999998\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 1, 2, 3, 4, 5]) == 99970000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 8800\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10000]) == 49975\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 1810\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == 2485\n assert candidate(nums = [9999, 9998, 9997, 9996, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 99970000\n assert candidate(nums = [2500, 5000, 7500, 10000, 12500, 15000, 17500, 20000, 22500, 25000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 562499998\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 89\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 661\n assert candidate(nums = [5000, 5001, 5002, 5003, 1, 2, 3, 4]) == 25025004\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 20800\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 5200\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10000]) == 89998\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxProductDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxProductDifference(self, nums: List[int]) -> int:", "container": "Solution", "callable": "maxProductDifference", "parameters": [{"name": "nums", "type": "List[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1914, "task_id": "cyclically-rotating-a-grid", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix grid​​​, where m and n are both even integers, and an integer k.\\r\n\\r\nThe matrix is composed of several layers, which is shown in the below image, where each color is its own layer:\\r\n\\r\n\\r\n\\r\nA cyclic rotation of the matrix is done by cyclically rotating each layer in the matrix. To cyclically rotate a layer once, each element in the layer will take the place of the adjacent element in the counter-clockwise direction. An example rotation is shown below:\\r\n\\r\nReturn the matrix after applying k cyclic rotations to it.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: grid = [[40,10],[30,20]], k = 1\\r\nOutput: [[10,20],[40,30]]\\r\nExplanation: The figures above represent the grid at every state.\\r\n\\r\n\\r\nExample 2:\\r\n \\r\n\\r\n\\r\nInput: grid = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]], k = 2\\r\nOutput: [[3,4,8,12],[2,11,10,16],[1,7,6,15],[5,9,13,14]]\\r\nExplanation: The figures above represent the grid at every state.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\tm == grid.length\\r\n\tn == grid[i].length\\r\n\t2 <= m, n <= 50\\r\n\tBoth m and n are even integers.\\r\n\t1 <= grid[i][j] <= 5000\\r\n\t1 <= k <= 109\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8]],k = 1) == [[2, 4], [1, 6], [3, 8], [5, 7]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 4) == [[5, 6, 7, 8, 16, 24, 32, 40], [4, 14, 15, 23, 31, 39, 47, 48], [3, 13, 30, 38, 46, 45, 55, 56], [2, 12, 22, 28, 29, 44, 54, 64], [1, 11, 21, 36, 37, 43, 53, 63], [9, 10, 20, 19, 27, 35, 52, 62], [17, 18, 26, 34, 42, 50, 51, 61], [25, 33, 41, 49, 57, 58, 59, 60]]\n assert candidate(grid = [[100, 200, 300, 400], [500, 600, 700, 800], [900, 1000, 1100, 1200], [1300, 1400, 1500, 1600]],k = 10) == [[900, 500, 100, 200], [1300, 1100, 1000, 300], [1400, 700, 600, 400], [1500, 1600, 1200, 800]]\n assert candidate(grid = [[100, 101, 102], [99, 103, 104], [98, 105, 106]],k = 4) == [[106, 105, 98], [104, 103, 99], [102, 101, 100]]\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8]],k = 5) == [[7, 5], [8, 3], [6, 1], [4, 2]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]],k = 3) == [[4, 5, 6, 12, 18, 24], [3, 11, 17, 23, 29, 30], [2, 10, 21, 15, 28, 36], [1, 9, 22, 16, 27, 35], [7, 8, 14, 20, 26, 34], [13, 19, 25, 31, 32, 33]]\n assert candidate(grid = [[5000, 5000, 5000, 5000], [5000, 1, 2, 5000], [5000, 4, 3, 5000], [5000, 5000, 5000, 5000]],k = 1000000000) == [[5000, 5000, 5000, 5000], [5000, 1, 2, 5000], [5000, 4, 3, 5000], [5000, 5000, 5000, 5000]]\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 1000000000) == [[8, 12, 16, 15], [4, 6, 7, 14], [3, 10, 11, 13], [2, 1, 5, 9]]\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 2) == [[3, 4, 8, 12], [2, 11, 10, 16], [1, 7, 6, 15], [5, 9, 13, 14]]\n assert candidate(grid = [[40, 10], [30, 20]],k = 1) == [[10, 20], [40, 30]]\n assert candidate(grid = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]],k = 7) == [[150, 140, 130, 90], [160, 100, 60, 50], [120, 110, 70, 10], [80, 40, 30, 20]]\n assert candidate(grid = [[100, 101, 102, 103, 104, 105, 106, 107], [108, 11, 12, 13, 14, 15, 16, 109], [110, 17, 18, 19, 20, 21, 22, 111], [112, 23, 24, 25, 26, 27, 28, 113], [114, 29, 30, 31, 32, 33, 34, 115], [116, 35, 36, 37, 38, 39, 40, 117], [118, 41, 42, 43, 44, 45, 46, 119], [120, 121, 122, 123, 124, 125, 126, 127]],k = 10) == [[113, 115, 117, 119, 127, 126, 125, 124], [111, 46, 45, 44, 43, 42, 41, 123], [109, 40, 30, 24, 18, 19, 35, 122], [107, 34, 36, 32, 31, 20, 29, 121], [106, 28, 37, 26, 25, 21, 23, 120], [105, 22, 38, 39, 33, 27, 17, 118], [104, 16, 15, 14, 13, 12, 11, 116], [103, 102, 101, 100, 108, 110, 112, 114]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2]],k = 50) == [[1, 1, 1, 1, 1, 1, 1, 2], [1, 7, 6, 5, 4, 3, 2, 3], [2, 7, 5, 6, 6, 6, 2, 4], [3, 7, 4, 5, 4, 6, 2, 5], [4, 7, 3, 5, 4, 5, 2, 6], [5, 7, 3, 3, 3, 4, 2, 7], [6, 7, 6, 5, 4, 3, 2, 8], [7, 2, 2, 2, 2, 2, 2, 2]]\n assert candidate(grid = [[6, 7, 8, 9], [5, 2, 3, 10], [4, 1, 12, 11], [13, 14, 15, 16]],k = 3) == [[9, 10, 11, 16], [8, 1, 2, 15], [7, 12, 3, 14], [6, 5, 4, 13]]\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24], [25, 26, 27, 28], [29, 30, 31, 32]],k = 500000000) == [[1, 2, 3, 4], [5, 22, 18, 8], [9, 26, 14, 12], [13, 27, 10, 16], [17, 23, 6, 20], [21, 19, 7, 24], [25, 15, 11, 28], [29, 30, 31, 32]]\n assert candidate(grid = [[5000, 5000, 5000, 5000, 5000, 5000], [5000, 1, 2, 3, 4, 5000], [5000, 6, 7, 8, 9, 5000], [5000, 10, 11, 12, 13, 5000], [5000, 14, 15, 16, 17, 5000], [5000, 5000, 5000, 5000, 5000, 5000]],k = 1000000000) == [[5000, 5000, 5000, 5000, 5000, 5000], [5000, 9, 13, 17, 16, 5000], [5000, 4, 7, 8, 15, 5000], [5000, 3, 11, 12, 14, 5000], [5000, 2, 1, 6, 10, 5000], [5000, 5000, 5000, 5000, 5000, 5000]]\n assert candidate(grid = [[100, 101, 102, 103, 104], [99, 49, 50, 51, 105], [98, 48, 1, 2, 106], [97, 47, 46, 3, 107], [96, 95, 94, 93, 108]],k = 7) == [[107, 108, 93, 94, 95], [106, 48, 49, 50, 96], [105, 47, 1, 51, 97], [104, 46, 3, 2, 98], [103, 102, 101, 100, 99]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 25) == [[25, 17, 9, 1, 2, 3, 4, 5], [33, 15, 23, 31, 39, 47, 55, 6], [41, 14, 20, 21, 22, 30, 54, 7], [49, 13, 19, 29, 37, 38, 53, 8], [57, 12, 27, 28, 36, 46, 52, 16], [58, 11, 35, 43, 44, 45, 51, 24], [59, 10, 18, 26, 34, 42, 50, 32], [60, 61, 62, 63, 64, 56, 48, 40]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]],k = 1000000001) == [[2, 3, 4, 5, 6, 12], [1, 23, 29, 28, 27, 18], [7, 17, 16, 22, 26, 24], [13, 11, 15, 21, 20, 30], [19, 10, 9, 8, 14, 36], [25, 31, 32, 33, 34, 35]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 13) == [[16, 11, 6, 1, 2], [21, 18, 17, 12, 3], [22, 19, 13, 7, 4], [23, 14, 9, 8, 5], [24, 25, 20, 15, 10]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 1]],k = 5) == [[1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 3, 2, 2, 1], [1, 2, 4, 3, 4, 4, 3, 1], [1, 2, 3, 4, 5, 3, 3, 2], [1, 2, 3, 4, 4, 3, 3, 2], [1, 2, 3, 3, 3, 3, 3, 2], [1, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 2, 2]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 10) == [[32, 40, 48, 56, 64, 63, 62, 61], [24, 55, 54, 53, 52, 51, 50, 60], [16, 47, 35, 27, 19, 20, 42, 59], [8, 39, 43, 37, 36, 21, 34, 58], [7, 31, 44, 29, 28, 22, 26, 57], [6, 23, 45, 46, 38, 30, 18, 49], [5, 15, 14, 13, 12, 11, 10, 41], [4, 3, 2, 1, 9, 17, 25, 33]]\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]],k = 100) == [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]\n assert candidate(grid = [[2, 3, 4, 5, 6, 7, 8], [1, 14, 13, 12, 11, 10, 9], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]],k = 25) == [[3, 4, 5, 6, 7, 8, 9], [2, 40, 39, 38, 37, 30, 21], [1, 41, 18, 19, 26, 23, 28], [15, 34, 17, 25, 33, 16, 35], [22, 27, 24, 31, 32, 14, 42], [29, 20, 10, 11, 12, 13, 49], [36, 43, 44, 45, 46, 47, 48]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48]],k = 100) == [[5, 6, 12, 18, 24, 30], [4, 17, 23, 29, 35, 36], [3, 11, 34, 33, 41, 42], [2, 10, 28, 27, 40, 48], [1, 9, 22, 21, 39, 47], [7, 8, 16, 15, 38, 46], [13, 14, 20, 26, 32, 45], [19, 25, 31, 37, 43, 44]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [21, 22, 23, 24, 25, 7], [20, 35, 36, 37, 26, 8], [19, 34, 39, 38, 27, 9], [18, 33, 32, 31, 28, 10], [17, 16, 15, 14, 13, 11]],k = 2000000000) == [[1, 2, 3, 4, 5, 6], [21, 32, 33, 34, 35, 7], [20, 31, 36, 37, 22, 8], [19, 28, 39, 38, 23, 9], [18, 27, 26, 25, 24, 10], [17, 16, 15, 14, 13, 11]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]],k = 5) == [[6, 12, 18, 24, 30, 36], [5, 23, 29, 28, 27, 35], [4, 17, 16, 22, 26, 34], [3, 11, 15, 21, 20, 33], [2, 10, 9, 8, 14, 32], [1, 7, 13, 19, 25, 31]]\n assert candidate(grid = [[9, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2]],k = 100) == [[6, 5, 4, 3, 2, 1, 1, 1], [7, 2, 3, 4, 5, 6, 7, 1], [2, 2, 6, 6, 6, 5, 7, 1], [2, 2, 6, 4, 5, 4, 7, 1], [2, 2, 5, 4, 5, 3, 7, 1], [2, 2, 4, 3, 3, 3, 7, 9], [2, 2, 3, 4, 5, 6, 7, 2], [2, 2, 8, 7, 6, 5, 4, 3]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80]],k = 1000000000) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 65, 64, 63, 62, 52, 42, 32, 22, 20], [21, 66, 23, 24, 25, 26, 27, 28, 12, 30], [31, 67, 33, 34, 35, 36, 37, 38, 13, 40], [41, 68, 43, 44, 45, 46, 47, 48, 14, 50], [51, 69, 53, 54, 55, 56, 57, 58, 15, 60], [61, 59, 49, 39, 29, 19, 18, 17, 16, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 20) == [[58, 57, 49, 41, 33, 25, 17, 9], [59, 10, 11, 12, 13, 14, 15, 1], [60, 18, 44, 43, 35, 27, 23, 2], [61, 26, 45, 28, 29, 19, 31, 3], [62, 34, 46, 36, 37, 20, 39, 4], [63, 42, 38, 30, 22, 21, 47, 5], [64, 50, 51, 52, 53, 54, 55, 6], [56, 48, 40, 32, 24, 16, 8, 7]]\n assert candidate(grid = [[9, 10, 11, 12, 13, 14], [8, 17, 18, 19, 20, 15], [7, 16, 25, 26, 21, 16], [6, 15, 24, 23, 22, 17], [5, 14, 13, 12, 11, 18], [4, 3, 2, 1, 0, 19]],k = 23) == [[12, 13, 14, 15, 16, 17], [11, 16, 17, 18, 19, 18], [10, 15, 24, 25, 20, 19], [9, 14, 23, 26, 21, 0], [8, 13, 12, 11, 22, 1], [7, 6, 5, 4, 3, 2]]\n assert candidate(grid = [[5000, 1, 2, 3, 4, 5, 6, 5000], [5000, 5000, 1, 2, 3, 4, 5000, 5000], [5000, 5000, 5000, 1, 2, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 1, 2, 5000, 5000, 5000], [5000, 5000, 1, 2, 3, 4, 5000, 5000], [5000, 1, 2, 3, 4, 5, 6, 5000], [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]],k = 1000000000) == [[5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 1, 2, 3, 4, 5000, 5000], [5000, 5000, 5000, 5000, 4, 3, 5000, 1], [5000, 5000, 5000, 5000, 5000, 2, 5000, 2], [5000, 5000, 2, 1, 2, 1, 5000, 3], [5000, 5000, 1, 5000, 5000, 5000, 5000, 4], [5000, 1, 2, 3, 4, 5, 6, 5], [5000, 5000, 5000, 5000, 5000, 5000, 5000, 6]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6]],k = 4) == [[1, 1, 2, 3, 4, 5], [1, 3, 4, 5, 5, 6], [1, 2, 3, 3, 5, 6], [1, 2, 4, 4, 5, 6], [1, 2, 2, 3, 4, 6], [2, 3, 4, 5, 6, 6]]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 1, 2, 3, 4, 5], [5, 6, 7, 8, 9, 5], [5, 10, 11, 12, 13, 5], [5, 14, 15, 16, 17, 5], [5, 5, 5, 5, 5, 5]],k = 15) == [[5, 5, 5, 5, 5, 5], [5, 4, 9, 13, 17, 5], [5, 3, 11, 7, 16, 5], [5, 2, 12, 8, 15, 5], [5, 1, 6, 10, 14, 5], [5, 5, 5, 5, 5, 5]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 50) == [[49, 41, 33, 25, 17, 9, 1, 2], [57, 55, 54, 53, 52, 51, 50, 3], [58, 47, 21, 22, 30, 38, 42, 4], [59, 39, 20, 37, 36, 46, 34, 5], [60, 31, 19, 29, 28, 45, 26, 6], [61, 23, 27, 35, 43, 44, 18, 7], [62, 15, 14, 13, 12, 11, 10, 8], [63, 64, 56, 48, 40, 32, 24, 16]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 15) == [[63, 62, 61, 60, 59, 58, 57, 49], [64, 50, 42, 34, 26, 18, 10, 41], [56, 51, 22, 30, 38, 46, 11, 33], [48, 52, 21, 36, 28, 45, 12, 25], [40, 53, 20, 37, 29, 44, 13, 17], [32, 54, 19, 27, 35, 43, 14, 9], [24, 55, 47, 39, 31, 23, 15, 1], [16, 8, 7, 6, 5, 4, 3, 2]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 5) == [[6, 7, 8, 16, 24, 32, 40, 48], [5, 15, 23, 31, 39, 47, 55, 56], [4, 14, 38, 46, 45, 44, 54, 64], [3, 13, 30, 29, 37, 43, 53, 63], [2, 12, 22, 28, 36, 35, 52, 62], [1, 11, 21, 20, 19, 27, 51, 61], [9, 10, 18, 26, 34, 42, 50, 60], [17, 25, 33, 41, 49, 57, 58, 59]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]],k = 15) == [[31, 25, 19, 13, 7, 1], [32, 11, 17, 23, 29, 2], [33, 10, 21, 15, 28, 3], [34, 9, 22, 16, 27, 4], [35, 8, 14, 20, 26, 5], [36, 30, 24, 18, 12, 6]]\n assert candidate(grid = [[1, 2, 3, 4], [12, 13, 14, 5], [11, 16, 15, 6], [10, 9, 8, 7]],k = 3) == [[4, 5, 6, 7], [3, 16, 13, 8], [2, 15, 14, 9], [1, 12, 11, 10]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48]],k = 1000000000) == [[44, 43, 37, 31, 25, 19], [45, 8, 9, 10, 11, 13], [46, 14, 15, 16, 17, 7], [47, 20, 21, 22, 23, 1], [48, 26, 27, 28, 29, 2], [42, 32, 33, 34, 35, 3], [36, 38, 39, 40, 41, 4], [30, 24, 18, 12, 6, 5]]\n assert candidate(grid = [[6, 7, 8, 9, 10], [5, 4, 3, 2, 11], [14, 13, 12, 1, 15], [19, 18, 17, 16, 20], [24, 23, 22, 21, 25]],k = 3) == [[9, 10, 11, 15, 20], [8, 1, 16, 17, 25], [7, 2, 12, 18, 21], [6, 3, 4, 13, 22], [5, 14, 19, 24, 23]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]],k = 15) == [[46, 45, 44, 43, 36, 29, 22], [47, 16, 9, 10, 11, 12, 15], [48, 23, 24, 17, 18, 13, 8], [49, 30, 31, 25, 19, 20, 1], [42, 37, 32, 33, 26, 27, 2], [35, 38, 39, 40, 41, 34, 3], [28, 21, 14, 7, 6, 5, 4]]\n assert candidate(grid = [[4, 3, 2, 1, 0], [9, 8, 7, 6, 5], [14, 13, 12, 11, 10], [19, 18, 17, 16, 15], [24, 23, 22, 21, 20]],k = 3) == [[1, 0, 5, 10, 15], [2, 11, 16, 17, 20], [3, 6, 12, 18, 21], [4, 7, 8, 13, 22], [9, 14, 19, 24, 23]]\n assert candidate(grid = [[10, 20, 30, 40, 50, 60], [70, 80, 90, 100, 110, 120], [130, 140, 150, 160, 170, 180], [190, 200, 210, 220, 230, 240], [250, 260, 270, 280, 290, 300], [310, 320, 330, 340, 350, 360]],k = 7) == [[180, 240, 300, 360, 350, 340], [120, 280, 270, 260, 200, 330], [60, 290, 210, 150, 140, 320], [50, 230, 220, 160, 80, 310], [40, 170, 110, 100, 90, 250], [30, 20, 10, 70, 130, 190]]\n assert candidate(grid = [[100, 101, 102, 103, 104, 105, 106, 107, 108, 109], [110, 1, 2, 3, 4, 5, 6, 7, 8, 111], [112, 9, 12, 13, 14, 15, 16, 17, 9, 113], [114, 8, 11, 18, 19, 20, 21, 10, 12, 115], [116, 7, 10, 19, 22, 23, 18, 11, 13, 117], [118, 6, 9, 20, 25, 24, 17, 12, 14, 119], [120, 5, 8, 21, 26, 27, 22, 13, 15, 121], [122, 4, 7, 28, 29, 30, 25, 14, 16, 123], [124, 3, 6, 31, 32, 33, 34, 26, 17, 125], [126, 2, 5, 35, 36, 37, 38, 39, 40, 127]],k = 15) == [[121, 123, 125, 127, 40, 39, 38, 37, 36, 35], [119, 26, 34, 33, 32, 31, 6, 3, 4, 5], [117, 17, 7, 8, 9, 10, 11, 12, 5, 2], [115, 16, 28, 21, 18, 17, 22, 13, 6, 126], [113, 15, 29, 20, 25, 22, 27, 14, 7, 124], [111, 14, 30, 19, 24, 23, 26, 15, 8, 122], [109, 13, 25, 18, 19, 20, 21, 16, 9, 120], [108, 12, 14, 13, 12, 11, 10, 17, 1, 118], [107, 9, 8, 7, 6, 5, 4, 3, 2, 116], [106, 105, 104, 103, 102, 101, 100, 110, 112, 114]]\n assert candidate(grid = [[100, 200, 300, 400], [201, 5, 6, 501], [202, 7, 8, 502], [303, 403, 503, 600]],k = 3) == [[400, 501, 502, 600], [300, 7, 5, 503], [200, 8, 6, 403], [100, 201, 202, 303]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]],k = 15) == [[31, 25, 19, 13, 7, 1], [32, 11, 17, 23, 29, 2], [33, 10, 21, 15, 28, 3], [34, 9, 22, 16, 27, 4], [35, 8, 14, 20, 26, 5], [36, 30, 24, 18, 12, 6]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [21, 22, 23, 24, 25, 7], [20, 35, 36, 37, 26, 8], [19, 34, 39, 38, 27, 9], [18, 33, 32, 31, 28, 10], [17, 16, 15, 14, 13, 11]],k = 3) == [[4, 5, 6, 7, 8, 9], [3, 25, 26, 27, 28, 10], [2, 24, 39, 36, 31, 11], [1, 23, 38, 37, 32, 13], [21, 22, 35, 34, 33, 14], [20, 19, 18, 17, 16, 15]]\n assert candidate(grid = [[5000, 1, 2, 5000, 3, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000]],k = 1000000000) == [[5000, 1, 2, 5000, 3, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000]]\n assert candidate(grid = [[100, 101, 102, 103], [104, 105, 106, 107], [108, 109, 110, 111], [112, 113, 114, 115]],k = 7) == [[114, 113, 112, 108], [115, 109, 105, 104], [111, 110, 106, 100], [107, 103, 102, 101]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 20) == [[58, 57, 49, 41, 33, 25, 17, 9], [59, 10, 11, 12, 13, 14, 15, 1], [60, 18, 44, 43, 35, 27, 23, 2], [61, 26, 45, 28, 29, 19, 31, 3], [62, 34, 46, 36, 37, 20, 39, 4], [63, 42, 38, 30, 22, 21, 47, 5], [64, 50, 51, 52, 53, 54, 55, 6], [56, 48, 40, 32, 24, 16, 8, 7]]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5], [5, 1, 2, 3, 4, 5, 6, 5], [5, 8, 9, 10, 11, 12, 7, 5], [5, 15, 14, 13, 16, 17, 8, 5], [5, 22, 21, 20, 19, 18, 9, 5], [5, 29, 28, 27, 26, 25, 10, 5], [5, 36, 35, 34, 33, 32, 31, 5], [5, 5, 5, 5, 5, 5, 5, 5]],k = 2000000000) == [[5, 5, 5, 5, 5, 5, 5, 5], [5, 1, 2, 3, 4, 5, 6, 5], [5, 8, 27, 28, 21, 14, 7, 5], [5, 15, 26, 13, 16, 9, 8, 5], [5, 22, 25, 20, 19, 10, 9, 5], [5, 29, 18, 17, 12, 11, 10, 5], [5, 36, 35, 34, 33, 32, 31, 5], [5, 5, 5, 5, 5, 5, 5, 5]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 50) == [[3, 4, 5, 10, 15], [2, 9, 14, 19, 20], [1, 8, 13, 18, 25], [6, 7, 12, 17, 24], [11, 16, 21, 22, 23]]\n assert candidate(grid = [[500, 501, 502, 503, 504], [505, 1, 2, 3, 506], [507, 4, 508, 509, 510], [511, 512, 513, 6, 514], [515, 516, 517, 518, 519]],k = 2000000000) == [[500, 501, 502, 503, 504], [505, 1, 2, 3, 506], [507, 4, 508, 509, 510], [511, 512, 513, 6, 514], [515, 516, 517, 518, 519]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 7) == [[8, 16, 24, 32, 40, 48, 56, 64], [7, 31, 39, 47, 55, 54, 53, 63], [6, 23, 45, 44, 43, 35, 52, 62], [5, 15, 46, 36, 28, 27, 51, 61], [4, 14, 38, 37, 29, 19, 50, 60], [3, 13, 30, 22, 21, 20, 42, 59], [2, 12, 11, 10, 18, 26, 34, 58], [1, 9, 17, 25, 33, 41, 49, 57]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]],k = 1000000000) == [[81, 71, 61, 51, 41, 31, 21, 11, 1, 2], [91, 83, 82, 72, 62, 52, 42, 32, 22, 3], [92, 84, 23, 24, 25, 26, 27, 28, 12, 4], [93, 85, 33, 47, 57, 67, 66, 38, 13, 5], [94, 86, 43, 37, 45, 46, 65, 48, 14, 6], [95, 87, 53, 36, 55, 56, 64, 58, 15, 7], [96, 88, 63, 35, 34, 44, 54, 68, 16, 8], [97, 89, 73, 74, 75, 76, 77, 78, 17, 9], [98, 79, 69, 59, 49, 39, 29, 19, 18, 10], [99, 100, 90, 80, 70, 60, 50, 40, 30, 20]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]],k = 50) == [[60, 70, 80, 90, 100, 99, 98, 97, 96, 95], [50, 72, 62, 52, 42, 32, 22, 12, 13, 94], [40, 82, 78, 77, 76, 75, 74, 73, 14, 93], [30, 83, 68, 36, 37, 47, 57, 63, 15, 92], [20, 84, 58, 35, 56, 55, 67, 53, 16, 91], [10, 85, 48, 34, 46, 45, 66, 43, 17, 81], [9, 86, 38, 44, 54, 64, 65, 33, 18, 71], [8, 87, 28, 27, 26, 25, 24, 23, 19, 61], [7, 88, 89, 79, 69, 59, 49, 39, 29, 51], [6, 5, 4, 3, 2, 1, 11, 21, 31, 41]]\n"}, "metadata": {"canonical_parameter_names": ["grid", "k"], "leetcode_dataset_entry_point": "Solution().rotateGrid", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def rotateGrid(self, grid: List[List[int]], k: int) -> List[List[int]]:", "container": "Solution", "callable": "rotateGrid", "parameters": [{"name": "grid", "type": "List[List[int]]"}, {"name": "k", "type": "int"}], "return_type": "List[List[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1915, "task_id": "number-of-wonderful-substrings", "difficulty": "Medium", "problem_description": "A wonderful string is a string where at most one letter appears an odd number of times.\\r\n\\r\n\\r\n\tFor example, \"ccjjc\" and \"abab\" are wonderful, but \"ab\" is not.\\r\n\\r\n\\r\nGiven a string word that consists of the first ten lowercase English letters ('a' through 'j'), return the number of wonderful non-empty substrings in word. If the same substring appears multiple times in word, then count each occurrence separately.\\r\n\\r\nA substring is a contiguous sequence of characters in a string.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: word = \"aba\"\\r\nOutput: 4\\r\nExplanation: The four wonderful substrings are underlined below:\\r\n- \"aba\" -> \"a\"\\r\n- \"aba\" -> \"b\"\\r\n- \"aba\" -> \"a\"\\r\n- \"aba\" -> \"aba\"\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: word = \"aabb\"\\r\nOutput: 9\\r\nExplanation: The nine wonderful substrings are underlined below:\\r\n- \"aabb\" -> \"a\"\\r\n- \"aabb\" -> \"aa\"\\r\n- \"aabb\" -> \"aab\"\\r\n- \"aabb\" -> \"aabb\"\\r\n- \"aabb\" -> \"a\"\\r\n- \"aabb\" -> \"abb\"\\r\n- \"aabb\" -> \"b\"\\r\n- \"aabb\" -> \"bb\"\\r\n- \"aabb\" -> \"b\"\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: word = \"he\"\\r\nOutput: 2\\r\nExplanation: The two wonderful substrings are underlined below:\\r\n- \"he\" -> \"h\"\\r\n- \"he\" -> \"e\"\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= word.length <= 105\\r\n\tword consists of lowercase English letters from 'a' to 'j'.\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aaaaaaaaaa\") == 55\n assert candidate(word = \"aabbccddeeffgghhiijj\") == 165\n assert candidate(word = \"aba\") == 4\n assert candidate(word = \"aaaabbbbcccc\") == 66\n assert candidate(word = \"babcbabcbab\") == 32\n assert candidate(word = \"abcdefghija\") == 11\n assert candidate(word = \"abcdcba\") == 10\n assert candidate(word = \"aaa\") == 6\n assert candidate(word = \"aabb\") == 9\n assert candidate(word = \"aabbccddeeffgg\") == 84\n assert candidate(word = \"abcdefghij\") == 10\n assert candidate(word = \"jihgfedcba\") == 10\n assert candidate(word = \"aabbccddeeff\") == 63\n assert candidate(word = \"abcabc\") == 9\n assert candidate(word = \"abacaba\") == 12\n assert candidate(word = \"jij\") == 4\n assert candidate(word = \"xyz\") == 0\n assert candidate(word = \"abcdefghijabcdefghij\") == 23\n assert candidate(word = \"abcde\") == 5\n assert candidate(word = \"ijji\") == 8\n assert candidate(word = \"jjjjj\") == 15\n assert candidate(word = \"jijijijiji\") == 40\n assert candidate(word = \"aabbaa\") == 19\n assert candidate(word = \"abcabcabc\") == 21\n assert candidate(word = \"he\") == 2\n assert candidate(word = \"a\") == 1\n assert candidate(word = \"abcdefghijabcdefghijabcdefghij\") == 63\n assert candidate(word = \"jijjjijijj\") == 41\n assert candidate(word = \"aaaaaaa\") == 28\n assert candidate(word = \"aaaaa\") == 15\n assert candidate(word = \"abacabadabacaba\") == 32\n assert candidate(word = \"aaaaaaaabbbbbbbbaaaaaaaabbbbbbbb\") == 464\n assert candidate(word = \"jihgfedcbajihgfedcbajihgfedcbajihgfedcbajihgfedcba\") == 176\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 1038\n assert candidate(word = \"jijijiijijijiijijijiijijijiijijijiijijijiijijiij\") == 879\n assert candidate(word = \"abcdefghijabcde\") == 15\n assert candidate(word = \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\") == 903\n assert candidate(word = \"acacacacacacacacacac\") == 155\n assert candidate(word = \"jijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjj\") == 5171\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 106\n assert candidate(word = \"aabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccdd\") == 4720\n assert candidate(word = \"aabbaaabbbaaabbaaa\") == 126\n assert candidate(word = \"jjiijjiijjjiiijjiiijjjijjjiiijjiiijjjijjjjj\") == 721\n assert candidate(word = \"aabbaabbaabbaabb\") == 120\n assert candidate(word = \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\") == 990\n assert candidate(word = \"aabbaabbaabbaabbccddeeffgghhiijj\") == 420\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabc\") == 225\n assert candidate(word = \"abcdeedcba\") == 23\n assert candidate(word = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjj\") == 640\n assert candidate(word = \"abcdabcdaabbccddeeffgghhiijj\") == 222\n assert candidate(word = \"ababababababababababababababababababababab\") == 672\n assert candidate(word = \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\") == 2485\n assert candidate(word = \"jijijiijjjijiiiiij\") == 132\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 176\n assert candidate(word = \"ababababababababababababab\") == 260\n assert candidate(word = \"aabbaaabbbaaabbaaabbba\") == 187\n assert candidate(word = \"acccabbbdcbaaaccbbaaccbbcdac\") == 161\n assert candidate(word = \"aabbaaabbbaaaabbbaaa\") == 159\n assert candidate(word = \"abcabcabcabcabc\") == 57\n assert candidate(word = \"jjjjjjjjjj\") == 55\n assert candidate(word = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 670\n assert candidate(word = \"abcdefghijkabcdefghijkabcdefghijk\") == 63\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 452\n assert candidate(word = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeee\") == 1025\n assert candidate(word = \"abcdefghijabcdeijfgh\") == 23\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 820\n assert candidate(word = \"aaaaaaaaaabbbbbbbbbbbbccccccccccdddddddddd\") == 738\n assert candidate(word = \"aabbccddeeaabbccddeeaabbccddeedcba\") == 403\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 715\n assert candidate(word = \"babababababababababa\") == 155\n assert candidate(word = \"aabbccddeeffgghhiijjijjiihhggeeffddccbbaa\") == 501\n assert candidate(word = \"aabbccddeeffgghhiijjabcdefghijabcdefghijabcdefghijabcdefghij\") == 363\n assert candidate(word = \"abcabccbaabccbaabcabccbaabccba\") == 225\n assert candidate(word = \"abcdefghijjihgfedcba\") == 48\n assert candidate(word = \"abacabadabacabadabacabad\") == 90\n assert candidate(word = \"abababababababababababababababab\") == 392\n assert candidate(word = \"abacabadabacabadabacabadabacabad\") == 154\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().wonderfulSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def wonderfulSubstrings(self, word: str) -> int:", "container": "Solution", "callable": "wonderfulSubstrings", "parameters": [{"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1916, "task_id": "count-ways-to-build-rooms-in-an-ant-colony", "difficulty": "Hard", "problem_description": "You are an ant tasked with adding n new rooms numbered 0 to n-1 to your colony. You are given the expansion plan as a 0-indexed integer array of length n, prevRoom, where prevRoom[i] indicates that you must build room prevRoom[i] before building room i, and these two rooms must be connected directly. Room 0 is already built, so prevRoom[0] = -1. The expansion plan is given such that once all the rooms are built, every room will be reachable from room 0.\\r\n\\r\nYou can only build one room at a time, and you can travel freely between rooms you have already built only if they are connected. You can choose to build any room as long as its previous room is already built.\\r\n\\r\nReturn the number of different orders you can build all the rooms in. Since the answer may be large, return it modulo 109 + 7.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: prevRoom = [-1,0,1]\\r\nOutput: 1\\r\nExplanation: There is only one way to build the additional rooms: 0 → 1 → 2\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\n\\r\nInput: prevRoom = [-1,0,0,1,2]\\r\nOutput: 6\\r\nExplanation:\\r\nThe 6 ways are:\\r\n0 → 1 → 3 → 2 → 4\\r\n0 → 2 → 4 → 1 → 3\\r\n0 → 1 → 2 → 3 → 4\\r\n0 → 1 → 2 → 4 → 3\\r\n0 → 2 → 1 → 3 → 4\\r\n0 → 2 → 1 → 4 → 3\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\tn == prevRoom.length\\r\n\t2 <= n <= 105\\r\n\tprevRoom[0] == -1\\r\n\t0 <= prevRoom[i] < n for all 1 <= i < n\\r\n\tEvery room is reachable from room 0 once all the rooms are built.\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9]) == 258365767\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2]) == 8\n assert candidate(prevRoom = [-1, 0, 0, 1, 2]) == 6\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2]) == 80\n assert candidate(prevRoom = [-1, 0, 1]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 0]) == 6\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 2, 2]) == 120\n assert candidate(prevRoom = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 896\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4]) == 1\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4]) == 3360\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 2, 2]) == 560\n assert candidate(prevRoom = [-1, 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12]) == 645120\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 203434154\n assert candidate(prevRoom = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 37717233\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8]) == 118354482\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14]) == 2\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 977384288\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 1\n assert candidate(prevRoom = [-1, 0, 1, 2, 1, 4, 2, 6, 5, 7, 5, 9, 8, 10, 9, 11, 12, 13, 14, 10]) == 245044800\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14]) == 645247453\n assert candidate(prevRoom = [-1, 0, 0, 2, 2, 1, 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 466985999\n assert candidate(prevRoom = [-1, 0, 1, 2, 0, 2, 3, 4, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 11, 12]) == 777509735\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 960269310\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12]) == 270200339\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == 815328371\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39]) == 558903913\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 1, 3, 4, 3, 5, 6, 7, 5, 8, 9, 10, 11, 12, 11, 13, 14, 15, 16, 17, 18]) == 574577861\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == 594293086\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 65279563\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 258365767\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6]) == 916824814\n assert candidate(prevRoom = [-1, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5]) == 499858301\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 144195955\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17]) == 977718734\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 927211300\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 214454105\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 881663664\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7]) == 182996126\n assert candidate(prevRoom = [-1, 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == 904828424\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 19170323\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 232266423\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10]) == 281601700\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 134837072\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35]) == 151296514\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == 580542770\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == 374254273\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 506880\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 4036032\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 457389881\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 862785756\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 259495482\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39]) == 104533170\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29]) == 944857254\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 185834123\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 0, 5, 6, 7, 8, 4, 11, 12, 13, 14, 10, 16, 17, 18, 19]) == 462\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 686400\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12]) == 846964197\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12]) == 839553459\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9]) == 864359005\n assert candidate(prevRoom = [-1, 0, 1, 0, 2, 3, 2, 4, 5, 6, 5, 7, 8, 9, 10, 11, 10, 11, 12, 13, 14, 15, 14, 15, 16, 17, 18, 19, 20]) == 696057029\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5]) == 495153778\n assert candidate(prevRoom = [-1, 0, 1, 2, 1, 4, 5, 6, 4, 8, 9, 5, 10, 11, 6, 12, 13, 7, 14, 15, 8, 16, 17, 9, 18, 19]) == 298444100\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 980653881\n assert candidate(prevRoom = [-1, 0, 1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 185998261\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 820019200\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 4, 4, 5, 6, 7, 7, 8, 8, 9, 9, 10, 11, 11, 12, 12, 13, 14, 15, 15, 16, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 316920121\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 645414306\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == 989258543\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 414301485\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7]) == 452706138\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 37717233\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 185998261\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34]) == 764478009\n assert candidate(prevRoom = [-1, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]) == 874133999\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 838387635\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 544962428\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 268444119\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 435629637\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11]) == 59583424\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29]) == 468972288\n assert candidate(prevRoom = [-1, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 930392109\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 466985999\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17]) == 715654985\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4]) == 199114634\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 1\n"}, "metadata": {"canonical_parameter_names": ["prevRoom"], "leetcode_dataset_entry_point": "Solution().waysToBuildRooms", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def waysToBuildRooms(self, prevRoom: List[int]) -> int:", "container": "Solution", "callable": "waysToBuildRooms", "parameters": [{"name": "prevRoom", "type": "List[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1920, "task_id": "build-array-from-permutation", "difficulty": "Easy", "problem_description": "Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it.\nA zero-based permutation nums is an array of distinct integers from 0 to nums.length - 1 (inclusive).\n \nExample 1:\n\nInput: nums = [0,2,1,5,3,4]\nOutput: [0,1,2,4,5,3]\nExplanation: The array ans is built as follows: \nans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]\n = [nums[0], nums[2], nums[1], nums[5], nums[3], nums[4]]\n = [0,1,2,4,5,3]\nExample 2:\n\nInput: nums = [5,0,1,2,3,4]\nOutput: [4,5,0,1,2,3]\nExplanation: The array ans is built as follows:\nans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]\n = [nums[5], nums[0], nums[1], nums[2], nums[3], nums[4]]\n = [4,5,0,1,2,3]\n \nConstraints:\n\n1 <= nums.length <= 1000\n0 <= nums[i] < nums.length\nThe elements in nums are distinct.\n\n \nFollow-up: Can you solve it without using an extra space (i.e., O(1) memory)?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 0, 2, 1, 3]) == [3, 4, 2, 0, 1]\n assert candidate(nums = [3, 2, 1, 0]) == [0, 1, 2, 3]\n assert candidate(nums = [5, 0, 1, 2, 3, 4]) == [4, 5, 0, 1, 2, 3]\n assert candidate(nums = [1, 0, 3, 2]) == [0, 1, 2, 3]\n assert candidate(nums = [0, 1, 2, 3]) == [0, 1, 2, 3]\n assert candidate(nums = [0, 2, 1, 5, 3, 4]) == [0, 1, 2, 4, 5, 3]\n assert candidate(nums = [1, 0, 2, 3]) == [0, 1, 2, 3]\n assert candidate(nums = [4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4]\n assert candidate(nums = [1, 0]) == [0, 1]\n assert candidate(nums = [1, 5, 4, 3, 2, 0, 8, 7, 6, 9]) == [5, 0, 2, 3, 4, 1, 6, 7, 8, 9]\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [15, 2, 12, 11, 9, 4, 8, 13, 10, 7, 5, 6, 3, 14, 1, 0]) == [0, 12, 3, 6, 7, 9, 10, 14, 5, 13, 4, 8, 11, 1, 2, 15]\n assert candidate(nums = [15, 10, 5, 0, 14, 9, 4, 13, 8, 3, 12, 7, 2, 11, 6, 1]) == [1, 12, 9, 15, 6, 3, 14, 11, 8, 0, 2, 13, 5, 7, 4, 10]\n assert candidate(nums = [1, 3, 0, 2, 6, 5, 4, 7, 9, 8]) == [3, 2, 1, 0, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [8, 0, 4, 1, 3, 7, 6, 2, 5, 9]) == [5, 8, 3, 0, 1, 2, 6, 4, 7, 9]\n assert candidate(nums = [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(nums = [1, 2, 3, 0, 4, 5, 6]) == [2, 3, 0, 1, 4, 5, 6]\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(nums = [6, 2, 0, 4, 5, 1, 3]) == [3, 0, 6, 5, 1, 2, 4]\n assert candidate(nums = [9, 3, 2, 8, 4, 5, 7, 0, 6, 1]) == [1, 8, 2, 6, 4, 5, 0, 9, 7, 3]\n assert candidate(nums = [7, 5, 9, 8, 6, 0, 1, 2, 4, 3]) == [2, 0, 3, 4, 1, 7, 5, 9, 6, 8]\n assert candidate(nums = [13, 9, 1, 15, 0, 14, 6, 10, 5, 2, 12, 4, 11, 7, 3, 8]) == [7, 2, 9, 8, 13, 3, 6, 12, 14, 1, 11, 0, 4, 10, 15, 5]\n assert candidate(nums = [7, 5, 2, 4, 6, 0, 3, 1]) == [1, 0, 2, 6, 3, 7, 4, 5]\n assert candidate(nums = [1, 3, 0, 2]) == [3, 2, 1, 0]\n assert candidate(nums = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [6, 2, 0, 5, 1, 4, 3]) == [3, 0, 6, 4, 2, 1, 5]\n assert candidate(nums = [2, 0, 1, 4, 3, 6, 5, 8, 7, 9, 10, 11]) == [1, 2, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [24, 25, 28, 0, 7, 12, 17, 29, 15, 9, 23, 21, 20, 22, 5, 27, 10, 13, 16, 3, 18, 8, 19, 11, 1, 6, 26, 4, 14, 2]) == [1, 6, 14, 24, 29, 20, 13, 2, 27, 9, 11, 8, 18, 19, 12, 4, 23, 22, 10, 0, 16, 15, 3, 21, 25, 17, 26, 7, 5, 28]\n assert candidate(nums = [2, 1, 0, 4, 3, 5, 9, 8, 6, 7]) == [0, 1, 2, 3, 4, 5, 7, 6, 9, 8]\n assert candidate(nums = [4, 5, 6, 7, 0, 1, 2, 3, 8, 9]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 0, 3, 2, 5, 4]) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [0, 3, 1, 4, 2, 5, 7, 6]) == [0, 4, 3, 2, 1, 5, 6, 7]\n assert candidate(nums = [10, 7, 8, 9, 1, 5, 6, 0, 3, 4, 2]) == [2, 0, 3, 4, 7, 5, 6, 10, 9, 1, 8]\n assert candidate(nums = [5, 8, 6, 3, 1, 0, 9, 2, 4, 7]) == [0, 4, 9, 3, 8, 5, 7, 6, 1, 2]\n assert candidate(nums = [33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]\n assert candidate(nums = [75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75]\n assert candidate(nums = [0, 5, 2, 1, 6, 4, 3]) == [0, 4, 2, 5, 3, 6, 1]\n assert candidate(nums = [3, 0, 1, 4, 2]) == [4, 3, 0, 2, 1]\n assert candidate(nums = [6, 1, 0, 2, 3, 5, 4]) == [4, 1, 6, 0, 2, 5, 3]\n assert candidate(nums = [6, 0, 3, 1, 8, 9, 7, 4, 2, 5]) == [7, 6, 1, 0, 2, 5, 4, 8, 3, 9]\n assert candidate(nums = [2, 0, 1]) == [1, 2, 0]\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(nums = [2, 4, 3, 0, 1, 5, 6, 7, 8, 9]) == [3, 1, 0, 2, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [8, 2, 3, 0, 4, 1, 7, 5, 9, 6]) == [9, 3, 0, 8, 4, 2, 5, 1, 6, 7]\n assert candidate(nums = [4, 8, 3, 1, 7, 10, 5, 6, 9, 0, 2, 11]) == [7, 9, 1, 8, 6, 2, 10, 5, 0, 4, 3, 11]\n assert candidate(nums = [9, 4, 3, 7, 8, 0, 2, 1, 5, 6]) == [6, 8, 7, 1, 5, 9, 3, 4, 0, 2]\n assert candidate(nums = [4, 3, 0, 1, 2]) == [2, 1, 4, 3, 0]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [0, 5, 1, 4, 6, 2, 3, 7, 8, 9]) == [0, 2, 5, 6, 3, 1, 4, 7, 8, 9]\n assert candidate(nums = [7, 5, 6, 3, 2, 1, 4, 0]) == [0, 1, 4, 3, 6, 5, 2, 7]\n assert candidate(nums = [1, 3, 0, 2, 7, 5, 8, 4, 9, 6]) == [3, 2, 1, 0, 4, 5, 9, 7, 6, 8]\n assert candidate(nums = [6, 1, 3, 5, 7, 0, 2, 4, 9, 8]) == [2, 1, 5, 0, 4, 6, 3, 7, 8, 9]\n assert candidate(nums = [34, 5, 11, 14, 2, 8, 1, 25, 16, 18, 20, 4, 0, 13, 31, 33, 10, 17, 3, 32, 23, 26, 15, 19, 6, 29, 7, 28, 24, 30, 9, 22, 12, 27, 5, 21]) == [5, 8, 4, 31, 11, 16, 5, 29, 10, 3, 23, 2, 34, 13, 22, 27, 20, 17, 14, 12, 19, 7, 33, 32, 1, 30, 25, 24, 6, 9, 18, 15, 0, 28, 8, 26]\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [6, 0, 1, 2, 3, 4, 5, 7, 8, 9]) == [5, 6, 0, 1, 2, 3, 4, 7, 8, 9]\n assert candidate(nums = [0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [59, 48, 54, 28, 74, 33, 85, 64, 80, 68, 47, 22, 25, 63, 98, 70, 19, 34, 6, 5, 82, 44, 73, 14, 72, 31, 32, 86, 3, 18, 92, 56, 53, 50, 49, 97, 90, 9, 93, 69, 37, 10, 84, 95, 35, 38, 52, 11, 62, 16, 88, 60, 42, 51, 15, 41, 77, 45, 67, 78, 46, 13, 20, 65, 87, 21, 7, 58, 36, 83, 17, 23, 29, 39, 91, 75, 61, 12, 99, 27, 94, 26, 40, 55, 1, 89, 79, 24, 57, 8, 30, 0, 43, 81, 96, 71, 66, 4, 76, 2, 59]) == [78, 62, 15, 3, 91, 50, 89, 87, 94, 36, 11, 73, 31, 65, 76, 17, 5, 49, 85, 33, 40, 35, 39, 98, 29, 56, 53, 79, 28, 6, 43, 77, 51, 88, 16, 4, 30, 68, 81, 83, 9, 47, 1, 71, 97, 93, 42, 22, 20, 19, 57, 46, 84, 60, 70, 10, 12, 38, 58, 99, 52, 63, 82, 21, 24, 44, 64, 67, 90, 55, 34, 14, 18, 69, 0, 75, 13, 25, 2, 86, 96, 32, 37, 41, 48, 8, 27, 72, 45, 80, 92, 59, 95, 26, 66, 23, 7, 74, 61, 54, 78]\n assert candidate(nums = [4, 0, 3, 1, 2]) == [2, 4, 1, 0, 3]\n assert candidate(nums = [5, 8, 4, 2, 0, 6, 7, 9, 1, 3]) == [6, 1, 0, 4, 5, 7, 9, 3, 8, 2]\n assert candidate(nums = [9, 7, 2, 3, 8, 6, 5, 0, 1, 4]) == [4, 0, 2, 3, 1, 5, 6, 9, 7, 8]\n assert candidate(nums = [10, 0, 2, 4, 1, 5, 6, 8, 3, 9, 7]) == [7, 10, 2, 1, 0, 5, 6, 3, 4, 9, 8]\n assert candidate(nums = [5, 1, 4, 8, 2, 9, 6, 0, 3, 7]) == [9, 1, 2, 3, 4, 7, 6, 5, 8, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == [0, 5, 9, 4, 1, 6, 8, 3, 2, 7]\n assert candidate(nums = [8, 11, 1, 0, 14, 9, 4, 13, 8, 3, 12, 7, 6, 10, 2, 5]) == [8, 7, 11, 8, 2, 3, 14, 10, 8, 0, 6, 13, 4, 12, 1, 9]\n assert candidate(nums = [8, 5, 2, 1, 6, 9, 7, 3, 0, 4]) == [0, 9, 2, 5, 7, 4, 3, 1, 8, 6]\n assert candidate(nums = [64, 5, 37, 49, 46, 17, 27, 47, 53, 39, 19, 35, 50, 1, 28, 58, 44, 0, 13, 20, 4, 30, 59, 10, 56, 63, 3, 31, 18, 48, 36, 24, 55, 26, 57, 34, 14, 6, 2, 40, 33, 16, 60, 25, 54, 52, 21, 62, 43, 61, 29, 38, 45, 41, 32, 51, 23, 11, 12, 42, 8, 7, 22, 15, 9, 5, 65, 37, 49, 46, 17, 27, 47, 53, 39, 19, 35, 50, 1, 28, 58, 44, 0, 13, 20, 4, 30, 59, 10, 56, 63, 3, 31, 18, 48, 36, 24, 55, 26, 57, 34, 14, 6, 2, 40, 33, 16, 60, 25, 54, 52, 21, 62, 43, 61, 29, 38, 45, 41, 32, 51, 23, 11, 12, 42, 8, 7, 22, 15, 9, 5]) == [9, 17, 6, 61, 21, 0, 31, 62, 41, 40, 20, 34, 29, 5, 18, 12, 54, 64, 1, 4, 46, 36, 42, 19, 23, 15, 49, 24, 13, 43, 14, 56, 51, 3, 11, 57, 28, 27, 37, 33, 26, 44, 8, 63, 32, 45, 30, 22, 25, 7, 48, 2, 52, 16, 55, 38, 10, 35, 50, 60, 53, 47, 59, 58, 39, 17, 5, 6, 61, 21, 0, 31, 62, 41, 40, 20, 34, 29, 5, 18, 12, 54, 64, 1, 4, 46, 36, 42, 19, 23, 15, 49, 24, 13, 43, 14, 56, 51, 3, 11, 57, 28, 27, 37, 33, 26, 44, 8, 63, 32, 45, 30, 22, 25, 7, 48, 2, 52, 16, 55, 38, 10, 35, 50, 60, 53, 47, 59, 58, 39, 17]\n assert candidate(nums = [1, 3, 5, 7, 9, 0, 2, 4, 6, 8]) == [3, 7, 0, 4, 8, 1, 5, 9, 2, 6]\n assert candidate(nums = [0, 5, 9, 1, 7, 2, 8, 4, 6, 3]) == [0, 2, 3, 5, 4, 9, 6, 7, 8, 1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [29, 22, 15, 8, 1, 28, 21, 14, 7, 0, 27, 20, 13, 6, 2, 26, 19, 12, 5, 3, 25, 18, 11, 4, 24, 17, 10, 16, 9, 23]) == [23, 11, 26, 7, 22, 9, 18, 2, 14, 29, 16, 25, 6, 21, 15, 10, 3, 13, 28, 8, 17, 5, 20, 1, 24, 12, 27, 19, 0, 4]\n assert candidate(nums = [0, 1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [7, 0, 5, 3, 6, 2, 4, 1]) == [1, 7, 2, 3, 4, 5, 6, 0]\n assert candidate(nums = [0, 10, 6, 7, 4, 3, 9, 1, 8, 2, 5]) == [0, 5, 9, 1, 4, 7, 2, 10, 8, 6, 3]\n assert candidate(nums = [4, 5, 0, 1, 2, 3]) == [2, 3, 4, 5, 0, 1]\n assert candidate(nums = [7, 9, 6, 3, 5, 8, 4, 0, 2, 1]) == [0, 1, 4, 3, 8, 2, 5, 7, 6, 9]\n assert candidate(nums = [7, 8, 9, 0, 3, 2, 5, 4, 6, 1]) == [4, 6, 1, 7, 0, 9, 2, 3, 5, 8]\n assert candidate(nums = [2, 7, 4, 5, 1, 9, 3, 6, 8, 0]) == [4, 6, 1, 9, 7, 0, 5, 3, 8, 2]\n assert candidate(nums = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(nums = [2, 5, 8, 3, 9, 6, 1, 7, 4, 0]) == [8, 6, 4, 3, 0, 1, 5, 7, 9, 2]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().buildArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def buildArray(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "buildArray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1921, "task_id": "eliminate-maximum-number-of-monsters", "difficulty": "Medium", "problem_description": "You are playing a video game where you are defending your city from a group of n monsters. You are given a 0-indexed integer array dist of size n, where dist[i] is the initial distance in kilometers of the ith monster from the city.\nThe monsters walk toward the city at a constant speed. The speed of each monster is given to you in an integer array speed of size n, where speed[i] is the speed of the ith monster in kilometers per minute.\nYou have a weapon that, once fully charged, can eliminate a single monster. However, the weapon takes one minute to charge. The weapon is fully charged at the very start.\nYou lose when any monster reaches your city. If a monster reaches the city at the exact moment the weapon is fully charged, it counts as a loss, and the game ends before you can use your weapon.\nReturn the maximum number of monsters that you can eliminate before you lose, or n if you can eliminate all the monsters before they reach the city.\n \nExample 1:\n\nInput: dist = [1,3,4], speed = [1,1,1]\nOutput: 3\nExplanation:\nIn the beginning, the distances of the monsters are [1,3,4]. You eliminate the first monster.\nAfter a minute, the distances of the monsters are [X,2,3]. You eliminate the second monster.\nAfter a minute, the distances of the monsters are [X,X,2]. You eliminate the third monster.\nAll 3 monsters can be eliminated.\nExample 2:\n\nInput: dist = [1,1,2,3], speed = [1,1,1,1]\nOutput: 1\nExplanation:\nIn the beginning, the distances of the monsters are [1,1,2,3]. You eliminate the first monster.\nAfter a minute, the distances of the monsters are [X,0,1,2], so you lose.\nYou can only eliminate 1 monster.\n\nExample 3:\n\nInput: dist = [3,2,4], speed = [5,3,2]\nOutput: 1\nExplanation:\nIn the beginning, the distances of the monsters are [3,2,4]. You eliminate the first monster.\nAfter a minute, the distances of the monsters are [X,0,2], so you lose.\nYou can only eliminate 1 monster.\n\n \nConstraints:\n\nn == dist.length == speed.length\n1 <= n <= 105\n1 <= dist[i], speed[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(dist = [6, 7, 8],speed = [2, 2, 2]) == 3\n assert candidate(dist = [1, 2, 3],speed = [3, 2, 1]) == 1\n assert candidate(dist = [100, 200, 300],speed = [1, 1, 1]) == 3\n assert candidate(dist = [7, 14, 21],speed = [1, 2, 3]) == 3\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [3, 5, 7, 9],speed = [1, 2, 3, 4]) == 3\n assert candidate(dist = [1, 1, 2, 3],speed = [1, 1, 1, 1]) == 1\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [50, 40, 30, 20, 10]) == 5\n assert candidate(dist = [6, 4, 5],speed = [1, 2, 1]) == 3\n assert candidate(dist = [1, 2, 3, 4, 5],speed = [1, 2, 3, 4, 5]) == 1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(dist = [1, 3, 4],speed = [1, 1, 1]) == 3\n assert candidate(dist = [10, 20, 30],speed = [1, 2, 3]) == 3\n assert candidate(dist = [5, 10, 15, 20],speed = [5, 4, 3, 2]) == 4\n assert candidate(dist = [3, 2, 4],speed = [5, 3, 2]) == 1\n assert candidate(dist = [1, 2, 3, 4, 5],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [10, 5, 6, 12, 3],speed = [2, 1, 1, 1, 1]) == 5\n assert candidate(dist = [5, 5, 5],speed = [1, 1, 1]) == 3\n assert candidate(dist = [2, 4, 6],speed = [2, 2, 2]) == 3\n assert candidate(dist = [1],speed = [1]) == 1\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [10, 20, 30, 40, 50]) == 5\n assert candidate(dist = [5, 5, 5, 5],speed = [1, 1, 1, 1]) == 4\n assert candidate(dist = [6, 7, 12, 13, 14],speed = [3, 3, 4, 4, 5]) == 3\n assert candidate(dist = [6, 3, 4, 1],speed = [2, 1, 2, 1]) == 3\n assert candidate(dist = [10, 20, 30],speed = [5, 10, 15]) == 2\n assert candidate(dist = [10, 15, 20],speed = [2, 3, 4]) == 3\n assert candidate(dist = [10, 20, 30],speed = [5, 5, 5]) == 3\n assert candidate(dist = [100, 200, 300],speed = [10, 20, 30]) == 3\n assert candidate(dist = [10, 20, 30, 40],speed = [10, 10, 10, 10]) == 4\n assert candidate(dist = [1, 2, 3, 4, 5],speed = [5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [10, 10, 10, 10, 10],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [500, 1000, 1500, 2000, 2500],speed = [50, 100, 150, 200, 250]) == 5\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [1000, 900, 800, 700, 600],speed = [100, 200, 300, 400, 500]) == 5\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [9, 8, 7, 6, 5, 4, 3, 2, 1],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(dist = [2, 3, 4, 5, 6],speed = [2, 2, 2, 2, 2]) == 2\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [2, 3, 4, 5, 6]) == 5\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(dist = [10, 25, 40, 55, 70, 85],speed = [5, 5, 5, 5, 5, 5]) == 6\n assert candidate(dist = [10, 15, 20, 25],speed = [5, 4, 3, 2]) == 4\n assert candidate(dist = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [99, 98, 97, 96, 95],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [1000, 1500, 2000, 2500, 3000],speed = [100, 200, 300, 400, 500]) == 5\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [50, 40, 30, 20, 10]) == 5\n assert candidate(dist = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(dist = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [10, 20, 30, 40, 50]) == 5\n assert candidate(dist = [15, 15, 20, 25, 30],speed = [1, 2, 1, 2, 1]) == 5\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],speed = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(dist = [5, 15, 25, 35, 45],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(dist = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [5, 5, 5, 5, 5]) == 5\n assert candidate(dist = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(dist = [2, 4, 6, 8, 10],speed = [1, 2, 3, 4, 5]) == 2\n assert candidate(dist = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],speed = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(dist = [5, 10, 15, 20, 25, 30],speed = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [25, 25, 25, 25, 25],speed = [5, 5, 5, 5, 5]) == 5\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [2, 4, 6, 8, 10],speed = [1, 2, 3, 4, 5]) == 2\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [5, 15, 25, 35, 45],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(dist = [5, 10, 15, 20, 25, 30],speed = [1, 2, 3, 4, 5, 6]) == 5\n assert candidate(dist = [99, 198, 297, 396, 495, 594, 693, 792, 891, 990],speed = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99]) == 10\n assert candidate(dist = [3, 5, 7, 9, 11],speed = [1, 2, 3, 4, 5]) == 3\n assert candidate(dist = [10000, 20000, 30000, 40000, 50000],speed = [100, 200, 300, 400, 500]) == 5\n assert candidate(dist = [3, 6, 9, 12, 15],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [1, 2, 3, 4, 5],speed = [5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [2, 4, 5, 6, 8]) == 5\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [1000, 2000, 3000],speed = [10, 20, 30]) == 3\n assert candidate(dist = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(dist = [10, 25, 30, 45, 50, 65, 70, 85, 90, 105],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [2, 3, 4, 5, 6],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 15\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 10\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [10, 20, 30, 40, 50]) == 1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [2, 2, 2, 2, 1]) == 5\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 1\n assert candidate(dist = [9, 9, 9, 9, 9],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [100, 150, 200, 250, 300],speed = [25, 50, 75, 100, 125]) == 3\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [10, 11, 12, 13, 14],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(dist = [15, 10, 20, 30, 40],speed = [2, 5, 3, 4, 1]) == 5\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(dist = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(dist = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [50, 100, 150, 200, 250]) == 2\n assert candidate(dist = [3, 6, 9, 12, 15, 18],speed = [1, 2, 3, 4, 5, 6]) == 3\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(dist = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [9, 18, 27, 36, 45],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [15, 25, 35, 45, 55],speed = [5, 5, 5, 5, 5]) == 5\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [50, 50, 50, 50, 50]) == 5\n assert candidate(dist = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(dist = [2, 4, 6, 8, 10],speed = [2, 2, 2, 2, 2]) == 5\n assert candidate(dist = [7, 14, 21, 28, 35],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [100, 150, 200, 250, 300],speed = [5, 10, 15, 20, 25]) == 5\n assert candidate(dist = [100, 150, 200, 250, 300, 350, 400, 450, 500],speed = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 9\n"}, "metadata": {"canonical_parameter_names": ["dist", "speed"], "leetcode_dataset_entry_point": "Solution().eliminateMaximum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def eliminateMaximum(self, dist: list[int], speed: list[int]) -> int:", "container": "Solution", "callable": "eliminateMaximum", "parameters": [{"name": "dist", "type": "list[int]"}, {"name": "speed", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1922, "task_id": "count-good-numbers", "difficulty": "Medium", "problem_description": "A digit string is good if the digits (0-indexed) at even indices are even and the digits at odd indices are prime (2, 3, 5, or 7).\n\nFor example, \"2582\" is good because the digits (2 and 8) at even positions are even and the digits (5 and 2) at odd positions are prime. However, \"3245\" is not good because 3 is at an even index but is not even.\n\nGiven an integer n, return the total number of good digit strings of length n. Since the answer may be large, return it modulo 109 + 7.\nA digit string is a string consisting of digits 0 through 9 that may contain leading zeros.\n \nExample 1:\n\nInput: n = 1\nOutput: 5\nExplanation: The good numbers of length 1 are \"0\", \"2\", \"4\", \"6\", \"8\".\n\nExample 2:\n\nInput: n = 4\nOutput: 400\n\nExample 3:\n\nInput: n = 50\nOutput: 564908303\n\n \nConstraints:\n\n1 <= n <= 1015\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1) == 5\n assert candidate(n = 4) == 400\n assert candidate(n = 50) == 564908303\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countGoodNumbers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countGoodNumbers(self, n: int) -> int:", "container": "Solution", "callable": "countGoodNumbers", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1923, "task_id": "longest-common-subpath", "difficulty": "Hard", "problem_description": "There is a country of n cities numbered from 0 to n - 1. In this country, there is a road connecting every pair of cities.\nThere are m friends numbered from 0 to m - 1 who are traveling through the country. Each one of them will take a path consisting of some cities. Each path is represented by an integer array that contains the visited cities in order. The path may contain a city more than once, but the same city will not be listed consecutively.\nGiven an integer n and a 2D integer array paths where paths[i] is an integer array representing the path of the ith friend, return the length of the longest common subpath that is shared by every friend's path, or 0 if there is no common subpath at all.\nA subpath of a path is a contiguous sequence of cities within that path.\n \nExample 1:\n\nInput: n = 5, paths = [[0,1,2,3,4],\n [2,3,4],\n [4,0,1,2,3]]\nOutput: 2\nExplanation: The longest common subpath is [2,3].\n\nExample 2:\n\nInput: n = 3, paths = [[0],[1],[2]]\nOutput: 0\nExplanation: There is no common subpath shared by the three paths.\n\nExample 3:\n\nInput: n = 5, paths = [[0,1,2,3,4],\n [4,3,2,1,0]]\nOutput: 1\nExplanation: The possible longest common subpaths are [0], [1], [2], [3], and [4]. All have a length of 1.\n \nConstraints:\n\n1 <= n <= 105\nm == paths.length\n2 <= m <= 105\nsum(paths[i].length) <= 105\n0 <= paths[i][j] < n\nThe same city is not listed multiple times consecutively in paths[i].\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,paths = [[0], [0], [0]]) == 1\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0]]) == 1\n assert candidate(n = 3,paths = [[0], [1], [2]]) == 0\n assert candidate(n = 10,paths = [[0, 1, 2], [1, 2, 3], [2, 3, 4]]) == 1\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 0, 1, 2, 3, 4], [3, 4, 5, 6, 7, 8, 9, 0, 1, 2]]) == 5\n assert candidate(n = 7,paths = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) == 0\n assert candidate(n = 6,paths = [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 0], [2, 3, 4, 5, 0, 1]]) == 4\n assert candidate(n = 10,paths = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5]]) == 0\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [2, 3, 4], [4, 0, 1, 2, 3]]) == 2\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3], [6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5]]) == 9\n assert candidate(n = 9,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 0], [2, 3, 4, 5, 6, 7, 8, 0, 1], [3, 4, 5, 6, 7, 8, 0, 1, 2]]) == 6\n assert candidate(n = 100,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79], [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44]]) == 45\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3]]) == 16\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 0], [2, 3, 4, 5, 6, 0, 1], [3, 4, 5, 6, 0, 1, 2], [4, 5, 6, 0, 1, 2, 3], [5, 6, 0, 1, 2, 3, 4], [6, 0, 1, 2, 3, 4, 5], [0, 6, 5, 4, 3, 2, 1]]) == 1\n assert candidate(n = 8,paths = [[0, 1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1, 0], [2, 1, 0, 7, 6, 5, 4, 3], [3, 2, 1, 0, 7, 6, 5, 4]]) == 1\n assert candidate(n = 100,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39], [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]]) == 50\n assert candidate(n = 8,paths = [[0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 0], [2, 3, 4, 5, 6, 7, 0, 1], [3, 4, 5, 6, 7, 0, 1, 2], [4, 5, 6, 7, 0, 1, 2, 3], [5, 6, 7, 0, 1, 2, 3, 4], [6, 7, 0, 1, 2, 3, 4, 5], [7, 0, 1, 2, 3, 4, 5, 6]]) == 1\n assert candidate(n = 25,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(n = 100,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 70\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 0], [2, 3, 4, 5, 6, 0, 1], [3, 4, 5, 6, 0, 1, 2], [4, 5, 6, 0, 1, 2, 3], [5, 6, 0, 1, 2, 3, 4], [6, 0, 1, 2, 3, 4, 5]]) == 1\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1]]) == 13\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4], [10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 5\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(n = 50,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48]]) == 25\n assert candidate(n = 25,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 15\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 10\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4]]) == 5\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4]]) == 10\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4], [1, 2, 3, 4, 0], [2, 3, 4, 0, 1], [3, 4, 0, 1, 2], [4, 0, 1, 2, 3], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 0, 1, 2, 3, 4], [6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [7, 8, 9, 0, 1, 2, 3, 4, 5, 6], [8, 9, 0, 1, 2, 3, 4, 5, 6, 7], [9, 0, 1, 2, 3, 4, 5, 6, 7, 8]]) == 1\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1]]) == 18\n assert candidate(n = 25,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [2, 3, 4, 5, 6, 7, 8, 9, 0, 1], [3, 4, 5, 6, 7, 8, 9, 0, 1, 2], [4, 5, 6, 7, 8, 9, 0, 1, 2, 3], [5, 6, 7, 8, 9, 0, 1, 2, 3, 4], [6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [7, 8, 9, 0, 1, 2, 3, 4, 5, 6], [8, 9, 0, 1, 2, 3, 4, 5, 6, 7], [9, 0, 1, 2, 3, 4, 5, 6, 7, 8]]) == 1\n assert candidate(n = 25,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 10\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [1, 2, 3, 0, 4], [2, 3, 0, 1, 4], [3, 0, 1, 2, 4], [0, 1, 2, 3, 4]]) == 1\n assert candidate(n = 50,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]]) == 20\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4]]) == 10\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [1, 2, 3, 4, 0], [2, 3, 4, 0, 1], [3, 4, 0, 1, 2], [4, 0, 1, 2, 3]]) == 1\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 2, 4, 6, 8, 0, 2, 4, 6, 8], [0, 3, 6, 9, 0, 3, 6, 9, 0, 3]]) == 1\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [2, 3, 4, 5, 6, 7, 8, 9, 0, 1], [8, 9, 0, 1, 2, 3, 4, 5, 6, 7]]) == 1\n assert candidate(n = 30,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 10\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3]]) == 11\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2]]) == 5\n assert candidate(n = 50,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 30\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2]]) == 17\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [3, 4, 5, 6, 0, 1, 2], [6, 0, 1, 2, 3, 4, 5], [4, 5, 6, 0, 1, 2, 3], [2, 3, 4, 5, 6, 0, 1]]) == 2\n assert candidate(n = 12,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2]]) == 9\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 0, 1], [4, 5, 6, 0, 1, 2, 3], [6, 0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6, 0]]) == 2\n assert candidate(n = 12,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1], [4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3], [6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5], [8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7]]) == 4\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8], [15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 9\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [2, 3, 4, 5, 6, 7, 8, 9, 0, 1], [3, 4, 5, 6, 7, 8, 9, 0, 1, 2]]) == 7\n assert candidate(n = 100,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 90\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [5, 4, 3, 2, 1, 0, 14, 13, 12, 11, 10, 9, 8, 7, 6]]) == 1\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [6, 0, 1, 2, 3, 4, 5], [5, 6, 0, 1, 2, 3, 4], [4, 5, 6, 0, 1, 2, 3]]) == 4\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [1, 2, 3, 4], [2, 3, 4], [3, 4], [4]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["n", "paths"], "leetcode_dataset_entry_point": "Solution().longestCommonSubpath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def longestCommonSubpath(self, n: int, paths: list[list[int]]) -> int:", "container": "Solution", "callable": "longestCommonSubpath", "parameters": [{"name": "n", "type": "int"}, {"name": "paths", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1925, "task_id": "count-square-sum-triples", "difficulty": "Easy", "problem_description": "A square triple (a,b,c) is a triple where a, b, and c are integers and a2 + b2 = c2.\nGiven an integer n, return the number of square triples such that 1 <= a, b, c <= n.\n \nExample 1:\n\nInput: n = 5\nOutput: 2\nExplanation: The square triples are (3,4,5) and (4,3,5).\n\nExample 2:\n\nInput: n = 10\nOutput: 4\nExplanation: The square triples are (3,4,5), (4,3,5), (6,8,10), and (8,6,10).\n\n \nConstraints:\n\n1 <= n <= 250\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 250) == 330\n assert candidate(n = 5) == 2\n assert candidate(n = 15) == 8\n assert candidate(n = 200) == 254\n assert candidate(n = 20) == 12\n assert candidate(n = 100) == 104\n assert candidate(n = 50) == 40\n assert candidate(n = 1) == 0\n assert candidate(n = 10) == 4\n assert candidate(n = 25) == 16\n assert candidate(n = 150) == 178\n assert candidate(n = 80) == 78\n assert candidate(n = 230) == 302\n assert candidate(n = 125) == 142\n assert candidate(n = 75) == 74\n assert candidate(n = 240) == 314\n assert candidate(n = 199) == 250\n assert candidate(n = 120) == 132\n assert candidate(n = 225) == 296\n assert candidate(n = 249) == 324\n assert candidate(n = 190) == 236\n assert candidate(n = 175) == 214\n assert candidate(n = 180) == 218\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countTriples", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countTriples(self, n: int) -> int:", "container": "Solution", "callable": "countTriples", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1926, "task_id": "nearest-exit-from-entrance-in-maze", "difficulty": "Medium", "problem_description": "You are given an m x n matrix maze (0-indexed) with empty cells (represented as '.') and walls (represented as '+'). You are also given the entrance of the maze, where entrance = [entrancerow, entrancecol] denotes the row and column of the cell you are initially standing at.\nIn one step, you can move one cell up, down, left, or right. You cannot step into a cell with a wall, and you cannot step outside the maze. Your goal is to find the nearest exit from the entrance. An exit is defined as an empty cell that is at the border of the maze. The entrance does not count as an exit.\nReturn the number of steps in the shortest path from the entrance to the nearest exit, or -1 if no such path exists.\n \nExample 1:\n\n\nInput: maze = [[\"+\",\"+\",\".\",\"+\"],[\".\",\".\",\".\",\"+\"],[\"+\",\"+\",\"+\",\".\"]], entrance = [1,2]\nOutput: 1\nExplanation: There are 3 exits in this maze at [1,0], [0,2], and [2,3].\nInitially, you are at the entrance cell [1,2].\n- You can reach [1,0] by moving 2 steps left.\n- You can reach [0,2] by moving 1 step up.\nIt is impossible to reach [2,3] from the entrance.\nThus, the nearest exit is [0,2], which is 1 step away.\n\nExample 2:\n\n\nInput: maze = [[\"+\",\"+\",\"+\"],[\".\",\".\",\".\"],[\"+\",\"+\",\"+\"]], entrance = [1,0]\nOutput: 2\nExplanation: There is 1 exit in this maze at [1,2].\n[1,0] does not count as an exit since it is the entrance cell.\nInitially, you are at the entrance cell [1,0].\n- You can reach [1,2] by moving 2 steps right.\nThus, the nearest exit is [1,2], which is 2 steps away.\n\nExample 3:\n\n\nInput: maze = [[\".\",\"+\"]], entrance = [0,0]\nOutput: -1\nExplanation: There are no exits in this maze.\n\n \nConstraints:\n\nmaze.length == m\nmaze[i].length == n\n1 <= m, n <= 100\nmaze[i][j] is either '.' or '+'.\nentrance.length == 2\n0 <= entrancerow < m\n0 <= entrancecol < n\nentrance will always be an empty cell.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(maze = [['.', '+']],entrance = [0, 0]) == -1\n assert candidate(maze = [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']],entrance = [0, 1]) == 1\n assert candidate(maze = [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.']],entrance = [0, 0]) == 1\n assert candidate(maze = [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']],entrance = [2, 2]) == 1\n assert candidate(maze = [['+)', '+)', '+'], ['.', '.', '.'], ['+)', '+)', '+']],entrance = [1, 0]) == 2\n assert candidate(maze = [['+)', '+)', '.'], ['.', '.', '.', '+'], ['+)', '+)', '+)', '.']],entrance = [1, 2]) == 1\n assert candidate(maze = [['+', '.', '+'], ['.', '.', '.'], ['+', '.', '+']],entrance = [1, 1]) == 1\n assert candidate(maze = [['.', '.', '+', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.']],entrance = [0, 3]) == 1\n assert candidate(maze = [['.', '.', '.', '.'], ['.', '+', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.']],entrance = [1, 1]) == 1\n assert candidate(maze = [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']],entrance = [1, 1]) == 1\n"}, "metadata": {"canonical_parameter_names": ["maze", "entrance"], "leetcode_dataset_entry_point": "Solution().nearestExit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def nearestExit(self, maze: list[list[str]], entrance: list[int]) -> int:", "container": "Solution", "callable": "nearestExit", "parameters": [{"name": "maze", "type": "list[list[str]]"}, {"name": "entrance", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1927, "task_id": "sum-game", "difficulty": "Medium", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\nYou are given a string num of even length consisting of digits and '?' characters. On each turn, a player will do the following if there is still at least one '?' in num:\n\nChoose an index i where num[i] == '?'.\nReplace num[i] with any digit between '0' and '9'.\n\nThe game ends when there are no more '?' characters in num.\nFor Bob to win, the sum of the digits in the first half of num must be equal to the sum of the digits in the second half. For Alice to win, the sums must not be equal.\n\nFor example, if the game ended with num = \"243801\", then Bob wins because 2+4+3 = 8+0+1. If the game ended with num = \"243803\", then Alice wins because 2+4+3 != 8+0+3.\n\nAssuming Alice and Bob play optimally, return true if Alice will win and false if Bob will win.\n \nExample 1:\n\nInput: num = \"5023\"\nOutput: false\nExplanation: There are no moves to be made.\nThe sum of the first half is equal to the sum of the second half: 5 + 0 = 2 + 3.\n\nExample 2:\n\nInput: num = \"25??\"\nOutput: true\nExplanation: Alice can replace one of the '?'s with '9' and it will be impossible for Bob to make the sums equal.\n\nExample 3:\n\nInput: num = \"?3295???\"\nOutput: false\nExplanation: It can be proven that Bob will always win. One possible outcome is:\n- Alice replaces the first '?' with '9'. num = \"93295???\".\n- Bob replaces one of the '?' in the right half with '9'. num = \"932959??\".\n- Alice replaces one of the '?' in the right half with '2'. num = \"9329592?\".\n- Bob replaces the last '?' in the right half with '7'. num = \"93295927\".\nBob wins because 9 + 3 + 2 + 9 = 5 + 9 + 2 + 7.\n\n \nConstraints:\n\n2 <= num.length <= 105\nnum.length is even.\nnum consists of only digits and '?'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"1???2???\") == True\n assert candidate(num = \"9?8?7?6?\") == True\n assert candidate(num = \"????2222\") == True\n assert candidate(num = \"98765432\") == True\n assert candidate(num = \"???45678\") == True\n assert candidate(num = \"9999????\") == True\n assert candidate(num = \"0000???\") == True\n assert candidate(num = \"12??34??\") == True\n assert candidate(num = \"?3295???\") == False\n assert candidate(num = \"0000????\") == True\n assert candidate(num = \"12345678\") == True\n assert candidate(num = \"12345678??\") == True\n assert candidate(num = \"00112233\") == True\n assert candidate(num = \"????567890\") == True\n assert candidate(num = \"5023\") == False\n assert candidate(num = \"????1234\") == True\n assert candidate(num = \"9999???\") == True\n assert candidate(num = \"????????\") == False\n assert candidate(num = \"00?0?0?0\") == True\n assert candidate(num = \"00000000\") == False\n assert candidate(num = \"1234?678?\") == True\n assert candidate(num = \"1234567890\") == True\n assert candidate(num = \"99?9?9?9\") == True\n assert candidate(num = \"25??\") == True\n assert candidate(num = \"1234????\") == True\n assert candidate(num = \"11112222\") == True\n assert candidate(num = \"????5000500050005000\") == True\n assert candidate(num = \"8888888888????????????????\") == True\n assert candidate(num = \"1234567890????\") == True\n assert candidate(num = \"00000000001234567890\") == True\n assert candidate(num = \"1234????5678\") == True\n assert candidate(num = \"1111111111111111????\") == True\n assert candidate(num = \"12345678901234567890????????????????????\") == False\n assert candidate(num = \"98765432109876543210\") == False\n assert candidate(num = \"1010101010??????????????????????\") == True\n assert candidate(num = \"9999999999999999999999999999????????????????????????????????????????????????????????????????????????????????????????????????????????\") == True\n assert candidate(num = \"12345678????????????????12345678\") == False\n assert candidate(num = \"1111111111111111????????????????\") == True\n assert candidate(num = \"2468013579????????????????\") == False\n assert candidate(num = \"99999999998765432100\") == True\n assert candidate(num = \"5555555555555555????\") == True\n assert candidate(num = \"50005000500050005000????\") == True\n assert candidate(num = \"1111111111????????????????\") == True\n assert candidate(num = \"1111????2222\") == True\n assert candidate(num = \"????????5432109876\") == True\n assert candidate(num = \"2222222222????????????????\") == True\n assert candidate(num = \"1234567890123456789012345678901234567890????\") == True\n assert candidate(num = \"1234567890????????\") == True\n assert candidate(num = \"555555555555555555550000000000000000????????\") == True\n assert candidate(num = \"00009999????\") == True\n assert candidate(num = \"2468024680??????????????????????\") == True\n assert candidate(num = \"98765432109876543210????????????\") == True\n assert candidate(num = \"1111222233334444????\") == True\n assert candidate(num = \"243801????????????????243801\") == False\n assert candidate(num = \"12345678901234567890????????????????????????????????????????????????????\") == False\n assert candidate(num = \"12345678901234561234567890???????\") == True\n assert candidate(num = \"222222222222222222222222222222222222222222222222????????????????????????????????????????????\") == True\n assert candidate(num = \"1234567890123456????\") == True\n assert candidate(num = \"12345678901234567890????????????????????????????????????????????????????????????????????????????????????????????????????????\") == False\n assert candidate(num = \"????????????\") == False\n assert candidate(num = \"502350235023????\") == True\n assert candidate(num = \"1234567890????????1234567890????????\") == False\n assert candidate(num = \"11111111????1111\") == True\n assert candidate(num = \"1111111111111111\") == False\n assert candidate(num = \"????????????????\") == False\n assert candidate(num = \"25??1234????????????????\") == True\n assert candidate(num = \"1234123412341234????\") == True\n assert candidate(num = \"0000000000000000000011111111111111111111\") == True\n assert candidate(num = \"55555555555555555555555555555555555555555555555555555555555555555????????????????????????????????????????????????????????????????????????????????????????????????\") == True\n assert candidate(num = \"5432109876????????\") == True\n assert candidate(num = \"????567890????567890\") == False\n assert candidate(num = \"1111111122222222????\") == True\n assert candidate(num = \"4444444444????????????????\") == True\n assert candidate(num = \"1234567890123456789012345678901234????\") == True\n assert candidate(num = \"999999999999????????????\") == True\n assert candidate(num = \"9876543210??????????????????????\") == False\n assert candidate(num = \"6666666666????????????????\") == True\n assert candidate(num = \"55555555555555555555555555555555\") == False\n assert candidate(num = \"9876543210????????????????\") == False\n assert candidate(num = \"0987654321????\") == True\n assert candidate(num = \"00000000000000001111111111111111????????????????\") == True\n assert candidate(num = \"0123456789????????\") == True\n assert candidate(num = \"0987654321098765\") == True\n assert candidate(num = \"1234567890????????????????\") == False\n assert candidate(num = \"????????1234567890\") == True\n assert candidate(num = \"9999999999999999999999999999????\") == True\n assert candidate(num = \"????0000????0000\") == False\n assert candidate(num = \"0000000000000000????????????????\") == True\n assert candidate(num = \"55555555555555555555555555555555????????????????\") == True\n assert candidate(num = \"0?????????????????????????????????\") == True\n assert candidate(num = \"9876987698769876????\") == True\n assert candidate(num = \"0000000000????????\") == True\n assert candidate(num = \"11111111111111111111????????????????\") == True\n assert candidate(num = \"1234567890????1234\") == True\n assert candidate(num = \"9999999999999999????\") == True\n assert candidate(num = \"1234567890??????????????????????\") == False\n assert candidate(num = \"9999????????\") == True\n assert candidate(num = \"1234567890????????1234567890????\") == False\n assert candidate(num = \"1010101010????????????????\") == True\n assert candidate(num = \"1234567890123456\") == True\n assert candidate(num = \"1234567890????????????????0123456789\") == False\n assert candidate(num = \"5555555555??????????????????????\") == True\n assert candidate(num = \"55555555????\") == True\n assert candidate(num = \"000000000000000000000000????????????????\") == True\n assert candidate(num = \"000099990000????????\") == False\n assert candidate(num = \"????????11111111\") == True\n assert candidate(num = \"1111111111????????????????????1111111111\") == False\n assert candidate(num = \"1234567890123456????????????????\") == True\n assert candidate(num = \"5023????5023????\") == False\n assert candidate(num = \"1234567890????????????????1234567890\") == False\n assert candidate(num = \"13579135791357913579????????????????????\") == True\n assert candidate(num = \"99999999999999991234\") == True\n assert candidate(num = \"????9876543210????\") == True\n assert candidate(num = \"99999999999999999999999999999999\") == False\n assert candidate(num = \"9999999999999999????????????????\") == True\n assert candidate(num = \"99999999999999999999\") == False\n assert candidate(num = \"9????9????\") == False\n assert candidate(num = \"99999999990000000000\") == True\n assert candidate(num = \"1122334455????????????????\") == True\n assert candidate(num = \"1111111122222222\") == True\n assert candidate(num = \"?????????????????????????????????1\") == True\n assert candidate(num = \"5555555544444444????\") == True\n assert candidate(num = \"1234567890123456789012345678901234567890????????????????????????????\") == True\n assert candidate(num = \"????1234567890??\") == True\n assert candidate(num = \"0000000000000000????\") == True\n assert candidate(num = \"00000000000000000000000000000000000000000000????????????????\") == True\n assert candidate(num = \"99999999????\") == True\n assert candidate(num = \"1020304050????????????????\") == True\n assert candidate(num = \"24680246802468024680????????????????????\") == True\n assert candidate(num = \"5000500050005000????\") == True\n assert candidate(num = \"0000000000000000000000000000????????????????????????????????\") == True\n assert candidate(num = \"9012345678????????????????8765432109\") == False\n assert candidate(num = \"????????9999999999\") == True\n assert candidate(num = \"98765432109876543210????????????????????\") == False\n assert candidate(num = \"9876543210????????????\") == False\n assert candidate(num = \"7777777777????????????????\") == True\n assert candidate(num = \"9753186420????????????????\") == False\n assert candidate(num = \"2222111144443333????\") == True\n assert candidate(num = \"5023????????????????????\") == True\n assert candidate(num = \"0000000000????????????????\") == True\n assert candidate(num = \"3333333333????????????????\") == True\n assert candidate(num = \"9876543210????????\") == True\n assert candidate(num = \"0000000000000000000000000000????\") == True\n assert candidate(num = \"12345678901234567890????????????\") == True\n assert candidate(num = \"123456789012345678901234567890\") == True\n assert candidate(num = \"5555555555????????????????\") == True\n assert candidate(num = \"9999????9999\") == False\n assert candidate(num = \"????2345????????????????5432????\") == False\n assert candidate(num = \"11223344556677889900????????????\") == False\n assert candidate(num = \"0000000099999999\") == True\n assert candidate(num = \"55555555555555555555555555555555????????????????????????????????????\") == True\n assert candidate(num = \"22222222222222222222222222222222????????????????????????????????????2222222222\") == True\n assert candidate(num = \"99999999????9999\") == True\n assert candidate(num = \"11111111111111111111\") == False\n assert candidate(num = \"20202020202020202020202020????????\") == True\n assert candidate(num = \"0101010101????????????????\") == True\n assert candidate(num = \"?9?8?7?6?5?4?3?2?1?\") == True\n assert candidate(num = \"12345678901234567890\") == False\n assert candidate(num = \"9876543210????\") == True\n assert candidate(num = \"5555555555????????\") == True\n assert candidate(num = \"33333333333333333333333333333333333333333333333333????????????????????????????????????????????????????????????????????????????????333333333333\") == True\n assert candidate(num = \"11111111111111112222222222222222\") == True\n assert candidate(num = \"1?????????????????????????????????\") == True\n assert candidate(num = \"88888888888888888888888888888888888888888888888888888888888888888????????????????????????????????????????????????????????????????????????????????????????????????888888888888\") == True\n assert candidate(num = \"1234567890????????????????0987654321\") == False\n assert candidate(num = \"0000000000000000\") == False\n assert candidate(num = \"9999999999????????????????\") == True\n assert candidate(num = \"50505050????\") == True\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().sumGame", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def sumGame(self, num: str) -> bool:", "container": "Solution", "callable": "sumGame", "parameters": [{"name": "num", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1928, "task_id": "minimum-cost-to-reach-destination-in-time", "difficulty": "Hard", "problem_description": "There is a country of n cities numbered from 0 to n - 1 where all the cities are connected by bi-directional roads. The roads are represented as a 2D integer array edges where edges[i] = [xi, yi, timei] denotes a road between cities xi and yi that takes timei minutes to travel. There may be multiple roads of differing travel times connecting the same two cities, but no road connects a city to itself.\nEach time you pass through a city, you must pay a passing fee. This is represented as a 0-indexed integer array passingFees of length n where passingFees[j] is the amount of dollars you must pay when you pass through city j.\nIn the beginning, you are at city 0 and want to reach city n - 1 in maxTime minutes or less. The cost of your journey is the summation of passing fees for each city that you passed through at some moment of your journey (including the source and destination cities).\nGiven maxTime, edges, and passingFees, return the minimum cost to complete your journey, or -1 if you cannot complete it within maxTime minutes.\n \nExample 1:\n\n\nInput: maxTime = 30, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3]\nOutput: 11\nExplanation: The path to take is 0 -> 1 -> 2 -> 5, which takes 30 minutes and has $11 worth of passing fees.\n\nExample 2:\n\n\nInput: maxTime = 29, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3]\nOutput: 48\nExplanation: The path to take is 0 -> 3 -> 4 -> 5, which takes 26 minutes and has $48 worth of passing fees.\nYou cannot take path 0 -> 1 -> 2 -> 5 since it would take too long.\n\nExample 3:\n\nInput: maxTime = 25, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3]\nOutput: -1\nExplanation: There is no way to reach city 5 from city 0 within 25 minutes.\n\n \nConstraints:\n\n1 <= maxTime <= 1000\nn == passingFees.length\n2 <= n <= 1000\nn - 1 <= edges.length <= 1000\n0 <= xi, yi <= n - 1\n1 <= timei <= 1000\n1 <= passingFees[j] <= 1000 \nThe graph may contain multiple edges between two nodes.\nThe graph does not contain self loops.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(maxTime = 50,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1]],passingFees = [1, 2, 3, 4, 5, 6]) == 21\n assert candidate(maxTime = 5,edges = [[0, 1, 5], [0, 2, 5], [1, 3, 5], [2, 3, 5], [3, 4, 5]],passingFees = [10, 10, 10, 10, 10]) == -1\n assert candidate(maxTime = 10,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [0, 3, 15]],passingFees = [10, 1, 1, 10]) == -1\n assert candidate(maxTime = 20,edges = [[0, 1, 10], [1, 0, 10], [0, 2, 5], [2, 0, 5], [1, 3, 10], [3, 1, 10], [2, 3, 10], [3, 2, 10]],passingFees = [1, 2, 3, 4]) == 7\n assert candidate(maxTime = 15,edges = [[0, 1, 10], [1, 2, 10], [0, 2, 1]],passingFees = [3, 1, 2]) == 5\n assert candidate(maxTime = 10,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 10]],passingFees = [3, 2, 1]) == 4\n assert candidate(maxTime = 5,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 10]],passingFees = [1, 2, 3]) == -1\n assert candidate(maxTime = 29,edges = [[0, 1, 10], [1, 2, 10], [2, 5, 10], [0, 3, 1], [3, 4, 10], [4, 5, 15]],passingFees = [5, 1, 2, 20, 20, 3]) == 48\n assert candidate(maxTime = 50,edges = [[0, 1, 1], [0, 2, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1]],passingFees = [1, 1, 1, 1]) == 3\n assert candidate(maxTime = 50,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1]],passingFees = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(maxTime = 5,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 10]],passingFees = [3, 2, 1]) == -1\n assert candidate(maxTime = 30,edges = [[0, 1, 10], [1, 2, 10], [2, 5, 10], [0, 3, 1], [3, 4, 10], [4, 5, 15]],passingFees = [5, 1, 2, 20, 20, 3]) == 11\n assert candidate(maxTime = 25,edges = [[0, 1, 10], [1, 2, 10], [2, 5, 10], [0, 3, 1], [3, 4, 10], [4, 5, 15]],passingFees = [5, 1, 2, 20, 20, 3]) == -1\n assert candidate(maxTime = 5,edges = [[0, 1, 6], [1, 2, 5], [0, 2, 10]],passingFees = [1, 2, 3]) == -1\n assert candidate(maxTime = 10,edges = [[0, 1, 3], [1, 2, 3], [0, 2, 5]],passingFees = [1, 2, 3]) == 4\n assert candidate(maxTime = 50,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [0, 3, 15]],passingFees = [10, 20, 30, 40]) == 50\n assert candidate(maxTime = 20,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [0, 2, 5], [1, 3, 6]],passingFees = [1, 2, 3, 4]) == 7\n assert candidate(maxTime = 10,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 10]],passingFees = [1, 2, 3]) == 4\n assert candidate(maxTime = 1,edges = [[0, 1, 1]],passingFees = [1, 1]) == 2\n assert candidate(maxTime = 45,edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [0, 2, 25], [1, 3, 30], [2, 4, 10], [3, 5, 15], [0, 3, 35], [1, 4, 40], [2, 5, 20], [0, 4, 50], [1, 5, 55]],passingFees = [5, 4, 3, 2, 1, 6]) == 14\n assert candidate(maxTime = 150,edges = [[0, 1, 20], [1, 2, 30], [0, 2, 40], [2, 3, 10], [3, 4, 50], [0, 3, 10], [1, 4, 30], [4, 5, 20], [5, 6, 40], [6, 7, 30], [7, 5, 15], [6, 8, 10], [8, 9, 50], [9, 0, 20], [9, 1, 10], [1, 3, 25]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 55\n assert candidate(maxTime = 500,edges = [[0, 1, 5], [0, 2, 10], [1, 2, 15], [1, 3, 20], [2, 3, 25], [2, 4, 30], [3, 4, 35], [3, 5, 40], [4, 5, 45], [4, 6, 50], [5, 6, 55], [5, 7, 60], [6, 7, 65], [6, 8, 70], [7, 8, 75], [7, 9, 80], [8, 9, 85], [0, 3, 30], [0, 4, 40], [0, 5, 50], [1, 4, 45], [1, 5, 55], [1, 6, 65], [2, 5, 50], [2, 6, 60], [2, 7, 70], [3, 6, 65], [3, 7, 75], [3, 8, 80], [4, 7, 70], [4, 8, 80], [4, 9, 85], [5, 8, 80], [5, 9, 85], [6, 9, 85]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 160\n assert candidate(maxTime = 50,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 10, 5], [0, 10, 10], [1, 9, 15], [2, 8, 20], [3, 7, 25], [4, 6, 30]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == 60\n assert candidate(maxTime = 100,edges = [[0, 1, 20], [1, 2, 30], [2, 3, 10], [3, 4, 50], [0, 2, 40], [1, 3, 10], [2, 4, 20]],passingFees = [10, 5, 15, 20, 25]) == 50\n assert candidate(maxTime = 300,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 9, 9], [1, 0, 1], [2, 1, 2], [3, 2, 3], [4, 3, 4], [5, 4, 5], [6, 5, 6], [7, 6, 7], [8, 7, 8], [9, 8, 9]],passingFees = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(maxTime = 15,edges = [[0, 1, 4], [1, 2, 3], [0, 2, 6], [2, 3, 5], [3, 4, 7], [0, 3, 8], [1, 3, 2]],passingFees = [2, 3, 4, 1, 5]) == 8\n assert candidate(maxTime = 100,edges = [[0, 1, 50], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 10], [0, 5, 90], [1, 3, 25], [2, 4, 15]],passingFees = [10, 20, 30, 40, 50, 60]) == 70\n assert candidate(maxTime = 25,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [0, 5, 10], [1, 3, 5], [2, 4, 5], [0, 3, 7], [0, 4, 8], [1, 4, 4], [2, 5, 3]],passingFees = [1, 2, 3, 4, 5, 6]) == 7\n assert candidate(maxTime = 600,edges = [[0, 1, 15], [0, 5, 15], [1, 2, 25], [1, 6, 25], [2, 3, 35], [2, 7, 35], [3, 4, 45], [3, 8, 45], [4, 9, 55], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [0, 6, 25], [1, 7, 35], [2, 8, 45], [3, 9, 55], [0, 7, 35], [1, 8, 45], [2, 9, 55], [0, 8, 45], [1, 9, 55], [0, 9, 55], [5, 10, 5], [10, 6, 5], [6, 10, 5], [7, 10, 5], [10, 8, 5], [8, 10, 5], [9, 10, 5]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 180\n assert candidate(maxTime = 60,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [0, 3, 15], [0, 2, 10], [1, 3, 10], [3, 4, 10], [2, 4, 10], [0, 4, 20]],passingFees = [3, 2, 1, 2, 3]) == 6\n assert candidate(maxTime = 10,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [0, 3, 5], [0, 2, 1], [1, 3, 1]],passingFees = [1, 2, 3, 4]) == 5\n assert candidate(maxTime = 5,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5]],passingFees = [1, 1, 1, 1, 1]) == -1\n assert candidate(maxTime = 220,edges = [[0, 1, 50], [1, 2, 40], [2, 3, 30], [3, 4, 20], [4, 0, 10], [0, 2, 60], [1, 3, 50], [2, 4, 40], [0, 4, 50], [3, 2, 40]],passingFees = [1, 1, 1, 1, 1]) == 2\n assert candidate(maxTime = 300,edges = [[0, 1, 50], [1, 2, 50], [2, 3, 50], [3, 4, 50], [0, 2, 60], [1, 3, 60], [2, 4, 60], [0, 3, 70], [1, 4, 70], [0, 4, 80]],passingFees = [10, 20, 30, 40, 50]) == 60\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [0, 2, 30], [1, 3, 20], [2, 3, 10], [3, 4, 40], [1, 2, 5]],passingFees = [10, 15, 20, 25, 30]) == 80\n assert candidate(maxTime = 100,edges = [[0, 1, 20], [1, 2, 20], [2, 3, 20], [3, 4, 20], [4, 5, 20], [0, 3, 50], [3, 5, 50]],passingFees = [5, 10, 15, 20, 25, 30]) == 55\n assert candidate(maxTime = 200,edges = [[0, 1, 50], [1, 2, 40], [2, 3, 30], [3, 4, 20], [4, 0, 10], [0, 2, 60], [1, 3, 50], [2, 4, 40]],passingFees = [100, 200, 150, 50, 300]) == 400\n assert candidate(maxTime = 250,edges = [[0, 1, 5], [1, 2, 15], [2, 3, 25], [3, 4, 35], [4, 5, 45], [0, 5, 55], [1, 3, 25], [2, 4, 35], [0, 4, 45], [1, 4, 15]],passingFees = [5, 5, 5, 5, 5, 5]) == 10\n assert candidate(maxTime = 600,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [0, 4, 40], [4, 5, 50], [1, 5, 60], [2, 6, 70], [3, 6, 80], [4, 7, 90], [5, 8, 100], [6, 8, 110], [0, 7, 120], [0, 3, 130], [1, 6, 140], [2, 7, 150], [3, 8, 160], [4, 6, 170], [5, 7, 180], [6, 7, 190]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 140\n assert candidate(maxTime = 150,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 10, 5]],passingFees = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10], [0, 5, 5], [1, 6, 5], [2, 7, 5], [3, 8, 5], [4, 9, 5]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 55\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 3, 25], [1, 4, 40], [3, 4, 15], [4, 5, 5], [5, 6, 30], [6, 1, 25], [2, 6, 10]],passingFees = [10, 15, 20, 25, 30, 35, 40]) == 65\n assert candidate(maxTime = 30,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],passingFees = [5, 1, 2, 20, 20, 3, 5, 1, 2, 3]) == -1\n assert candidate(maxTime = 120,edges = [[0, 1, 20], [0, 2, 30], [0, 3, 10], [1, 2, 15], [1, 3, 20], [1, 4, 10], [2, 3, 25], [2, 4, 5], [3, 4, 15], [2, 5, 10], [3, 5, 20], [4, 5, 5], [0, 5, 20]],passingFees = [15, 25, 35, 45, 55, 65]) == 80\n assert candidate(maxTime = 200,edges = [[0, 1, 30], [0, 2, 20], [1, 2, 10], [1, 3, 40], [2, 4, 20], [3, 4, 10], [3, 5, 50], [4, 5, 30], [2, 5, 25], [5, 6, 10], [6, 7, 20], [6, 8, 15], [7, 8, 5], [8, 9, 10], [9, 0, 10]],passingFees = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(maxTime = 20,edges = [[0, 1, 5], [1, 2, 10], [0, 3, 15], [3, 4, 20], [2, 4, 25], [4, 5, 30]],passingFees = [5, 10, 15, 20, 25, 30]) == -1\n assert candidate(maxTime = 50,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 15], [3, 4, 10], [4, 5, 10], [0, 3, 25], [1, 4, 20]],passingFees = [10, 20, 30, 40, 50, 60]) == 140\n assert candidate(maxTime = 60,edges = [[0, 1, 10], [0, 2, 15], [0, 3, 20], [1, 2, 5], [1, 3, 10], [2, 3, 25], [1, 4, 10], [2, 4, 5], [3, 4, 15], [2, 5, 10], [3, 5, 20], [4, 5, 5]],passingFees = [10, 20, 30, 40, 50, 60]) == 100\n assert candidate(maxTime = 50,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 0, 5], [0, 2, 10], [1, 3, 10], [2, 4, 10]],passingFees = [1, 2, 3, 4, 5]) == 6\n assert candidate(maxTime = 80,edges = [[0, 1, 10], [1, 2, 20], [0, 2, 30], [2, 3, 40], [0, 3, 50], [3, 4, 60], [0, 4, 70]],passingFees = [5, 5, 5, 5, 5]) == 10\n assert candidate(maxTime = 50,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [0, 2, 4], [1, 3, 3], [2, 4, 2], [3, 5, 1]],passingFees = [1, 2, 3, 4, 5, 6]) == 13\n assert candidate(maxTime = 120,edges = [[0, 1, 15], [1, 2, 25], [2, 3, 35], [3, 4, 45], [0, 3, 65], [1, 4, 75], [2, 4, 85], [0, 4, 95], [3, 1, 105], [4, 2, 115]],passingFees = [50, 20, 30, 40, 60]) == 110\n assert candidate(maxTime = 20,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [0, 5, 10]],passingFees = [5, 10, 15, 20, 25, 30]) == 35\n assert candidate(maxTime = 500,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [0, 4, 40], [4, 5, 50], [1, 5, 60], [2, 6, 70], [3, 6, 80], [4, 7, 90], [5, 8, 100], [6, 8, 110], [0, 7, 120]],passingFees = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 18\n assert candidate(maxTime = 200,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [0, 3, 30], [1, 3, 30], [2, 4, 30], [3, 4, 30], [0, 4, 50]],passingFees = [1, 2, 3, 4, 5]) == 6\n assert candidate(maxTime = 550,edges = [[0, 1, 20], [0, 5, 20], [1, 2, 30], [1, 6, 30], [2, 3, 40], [2, 7, 40], [3, 4, 50], [3, 8, 50], [4, 9, 60], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [0, 6, 40], [1, 7, 50], [2, 8, 60], [3, 9, 70], [0, 7, 50], [1, 8, 60], [2, 9, 70], [0, 8, 60], [1, 9, 70], [0, 9, 70]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 110\n assert candidate(maxTime = 400,edges = [[0, 1, 30], [1, 2, 30], [2, 3, 30], [3, 4, 30], [0, 2, 50], [1, 3, 50], [2, 4, 50], [0, 3, 70], [1, 4, 70], [0, 4, 90], [0, 5, 40], [5, 4, 10], [4, 6, 60], [6, 5, 10], [5, 3, 20]],passingFees = [5, 15, 25, 35, 45, 55, 65]) == 115\n assert candidate(maxTime = 350,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 3, 20], [3, 4, 40], [0, 3, 30], [1, 2, 20], [0, 4, 50], [1, 4, 30], [2, 4, 40]],passingFees = [10, 20, 30, 40, 50]) == 60\n assert candidate(maxTime = 350,edges = [[0, 1, 50], [1, 2, 100], [2, 3, 150], [3, 4, 200], [4, 5, 250], [5, 6, 300], [6, 7, 350], [7, 8, 400], [8, 9, 450], [0, 9, 500]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == -1\n assert candidate(maxTime = 30,edges = [[0, 1, 5], [0, 2, 10], [1, 2, 3], [1, 3, 15], [2, 3, 20], [3, 4, 25]],passingFees = [1, 2, 3, 4, 5]) == -1\n assert candidate(maxTime = 180,edges = [[0, 1, 20], [0, 2, 30], [1, 3, 40], [2, 3, 20], [3, 4, 50], [0, 3, 30], [1, 2, 30], [0, 4, 60], [1, 4, 40]],passingFees = [10, 10, 10, 10, 10]) == 20\n assert candidate(maxTime = 150,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 0, 5], [0, 3, 10], [1, 4, 10], [2, 5, 10], [3, 6, 10], [4, 7, 10], [5, 8, 10], [6, 9, 10], [7, 0, 10], [8, 1, 10], [9, 2, 10]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 110\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [0, 5, 50], [0, 2, 40], [1, 3, 30], [2, 4, 20], [3, 5, 10], [0, 4, 60], [1, 5, 50]],passingFees = [5, 1, 2, 3, 4, 5]) == 10\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [0, 2, 15], [1, 2, 10], [1, 3, 20], [2, 4, 15], [3, 4, 20], [4, 5, 30], [3, 5, 40]],passingFees = [5, 1, 2, 3, 4, 5]) == 14\n assert candidate(maxTime = 35,edges = [[0, 1, 5], [1, 2, 3], [0, 2, 9], [1, 3, 7], [2, 4, 4], [0, 3, 6], [1, 4, 8], [3, 4, 2], [0, 4, 12]],passingFees = [1, 2, 3, 4, 5]) == 6\n assert candidate(maxTime = 25,edges = [[0, 1, 10], [1, 2, 15], [0, 2, 20], [2, 3, 5], [3, 4, 10], [4, 5, 15], [5, 6, 20], [6, 7, 25], [7, 8, 30], [8, 9, 10], [0, 9, 35]],passingFees = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(maxTime = 300,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [0, 3, 60], [1, 4, 70], [2, 5, 80], [0, 2, 90], [3, 5, 100]],passingFees = [10, 20, 30, 40, 50, 60]) == 100\n assert candidate(maxTime = 30,edges = [[0, 1, 5], [1, 2, 7], [2, 3, 6], [0, 3, 10], [1, 3, 2], [2, 4, 5], [3, 4, 3], [0, 4, 8]],passingFees = [10, 20, 15, 25, 30]) == 40\n assert candidate(maxTime = 400,edges = [[0, 1, 100], [1, 2, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [0, 5, 100], [0, 2, 100], [1, 3, 100], [2, 4, 100], [3, 5, 100]],passingFees = [5, 5, 5, 5, 5, 5]) == 10\n assert candidate(maxTime = 200,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10], [0, 2, 20], [1, 3, 20], [2, 4, 20], [3, 5, 20], [4, 6, 20], [5, 7, 20], [6, 8, 20], [7, 9, 20], [8, 1, 20], [9, 2, 20], [0, 3, 30], [1, 4, 30], [2, 5, 30], [3, 6, 30], [4, 7, 30], [5, 8, 30], [6, 9, 30], [7, 0, 30], [8, 1, 30], [9, 2, 30], [0, 4, 40], [1, 5, 40], [2, 6, 40], [3, 7, 40], [4, 8, 40], [5, 9, 40], [6, 0, 40], [7, 1, 40], [8, 2, 40], [9, 3, 40]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 55\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [0, 2, 5], [1, 3, 5], [0, 3, 2], [2, 4, 20], [3, 4, 10]],passingFees = [10, 5, 3, 20, 1]) == 14\n assert candidate(maxTime = 30,edges = [[0, 1, 10], [1, 2, 10], [2, 5, 10], [0, 3, 1], [3, 4, 10], [4, 5, 15], [1, 3, 1], [2, 4, 5]],passingFees = [5, 1, 2, 20, 20, 3]) == 11\n assert candidate(maxTime = 50,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [0, 9, 40]],passingFees = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 19\n assert candidate(maxTime = 700,edges = [[0, 1, 50], [1, 2, 100], [2, 3, 150], [0, 4, 200], [4, 5, 250], [1, 5, 300], [2, 6, 350], [3, 6, 400], [4, 7, 450], [5, 8, 500], [6, 8, 550], [0, 7, 600], [0, 3, 650], [1, 6, 700], [2, 7, 750], [3, 8, 800], [4, 6, 850], [5, 7, 900], [6, 7, 950], [0, 8, 1000], [2, 5, 1050]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == -1\n assert candidate(maxTime = 200,edges = [[0, 1, 15], [0, 2, 20], [1, 3, 25], [2, 3, 15], [3, 4, 30], [0, 3, 15], [1, 2, 10]],passingFees = [10, 20, 30, 40, 50]) == 100\n assert candidate(maxTime = 180,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [0, 4, 50], [0, 2, 60], [1, 3, 70], [2, 4, 80], [3, 1, 90], [4, 0, 100]],passingFees = [50, 40, 30, 20, 10]) == 60\n assert candidate(maxTime = 300,edges = [[0, 1, 10], [1, 2, 20], [0, 3, 30], [3, 4, 40], [4, 5, 50], [0, 2, 60], [2, 3, 70], [1, 4, 80], [2, 5, 90]],passingFees = [5, 10, 15, 20, 25, 30]) == 50\n assert candidate(maxTime = 150,edges = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [0, 5, 50], [1, 3, 20], [2, 4, 25]],passingFees = [1, 1, 1, 1, 1, 1]) == 2\n assert candidate(maxTime = 220,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 20], [2, 3, 15], [3, 4, 25], [0, 3, 25], [1, 2, 15], [0, 4, 40], [1, 4, 25], [2, 4, 35]],passingFees = [5, 15, 25, 35, 45]) == 50\n assert candidate(maxTime = 15,edges = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [2, 3, 5], [0, 3, 1]],passingFees = [10, 20, 30, 40]) == 50\n assert candidate(maxTime = 40,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 15], [3, 4, 5], [4, 5, 5], [5, 6, 5], [0, 2, 25], [1, 3, 15], [2, 4, 25], [3, 5, 15], [0, 4, 40], [1, 5, 25]],passingFees = [3, 2, 1, 4, 2, 5, 3]) == 13\n assert candidate(maxTime = 200,edges = [[0, 1, 100], [1, 2, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [0, 3, 1], [3, 4, 1], [4, 5, 1], [0, 2, 1], [2, 4, 1]],passingFees = [5, 1, 2, 20, 20, 3]) == 30\n assert candidate(maxTime = 40,edges = [[0, 1, 3], [0, 2, 4], [1, 2, 2], [1, 3, 5], [2, 3, 6], [2, 4, 1], [3, 4, 7], [0, 4, 8], [1, 4, 3]],passingFees = [1, 2, 3, 4, 5]) == 6\n assert candidate(maxTime = 60,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],passingFees = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(maxTime = 150,edges = [[0, 1, 10], [1, 2, 20], [0, 2, 30], [2, 3, 10], [3, 0, 20], [1, 3, 10], [0, 3, 50], [1, 0, 20], [2, 1, 30], [3, 2, 40]],passingFees = [5, 15, 25, 35]) == 40\n assert candidate(maxTime = 60,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [0, 14, 60]],passingFees = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 18\n assert candidate(maxTime = 250,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [0, 9, 100]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 110\n assert candidate(maxTime = 500,edges = [[0, 1, 25], [1, 2, 25], [2, 3, 25], [3, 4, 25], [4, 5, 25], [5, 6, 25], [6, 7, 25], [7, 8, 25], [8, 9, 25], [9, 10, 25], [0, 9, 200], [9, 1, 200], [1, 10, 200], [10, 0, 200], [0, 10, 100], [1, 9, 100], [9, 2, 100], [2, 0, 100], [0, 8, 150], [8, 3, 150], [3, 1, 150], [1, 6, 150], [6, 4, 150], [4, 2, 150], [2, 7, 150], [7, 5, 150], [5, 8, 150]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 120\n assert candidate(maxTime = 400,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 4, 40], [3, 5, 50], [4, 6, 60], [1, 2, 70], [3, 4, 80], [2, 5, 90], [4, 5, 100]],passingFees = [5, 10, 15, 20, 25, 30, 35]) == 80\n assert candidate(maxTime = 100,edges = [[0, 1, 20], [1, 2, 20], [2, 3, 20], [3, 4, 20], [4, 5, 20], [5, 6, 20], [6, 7, 20], [7, 8, 20], [8, 9, 20], [9, 10, 20], [10, 11, 20], [11, 12, 20], [12, 13, 20], [13, 14, 20], [14, 15, 20], [15, 16, 20], [16, 17, 20], [17, 18, 20], [18, 19, 20], [0, 19, 90]],passingFees = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n assert candidate(maxTime = 80,edges = [[0, 1, 20], [0, 2, 30], [1, 3, 10], [2, 3, 10], [3, 4, 20], [0, 3, 10]],passingFees = [5, 5, 5, 5, 5]) == 15\n assert candidate(maxTime = 70,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 0, 5]],passingFees = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 20\n assert candidate(maxTime = 60,edges = [[0, 1, 20], [1, 2, 20], [2, 3, 20], [3, 4, 20], [0, 2, 10], [1, 3, 10], [2, 4, 10], [0, 3, 30], [1, 4, 30]],passingFees = [5, 15, 25, 35, 45]) == 65\n assert candidate(maxTime = 120,edges = [[0, 1, 10], [0, 2, 20], [1, 2, 30], [1, 3, 20], [2, 3, 10], [3, 4, 10], [0, 3, 20], [1, 2, 30]],passingFees = [5, 5, 5, 5, 5]) == 15\n assert candidate(maxTime = 800,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [0, 4, 40], [4, 5, 50], [1, 5, 60], [2, 6, 70], [3, 6, 80], [4, 7, 90], [5, 8, 100], [6, 8, 110], [0, 7, 120], [0, 3, 130], [1, 6, 140], [2, 7, 150], [3, 8, 160], [4, 6, 170], [5, 7, 180], [6, 7, 190], [1, 3, 200], [2, 4, 210], [3, 5, 220], [4, 8, 230], [5, 6, 240], [0, 8, 250], [1, 7, 260], [2, 8, 270], [3, 7, 280], [4, 7, 290], [0, 6, 300], [1, 8, 310], [2, 5, 320], [3, 4, 330]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 100\n assert candidate(maxTime = 20,edges = [[0, 1, 5], [1, 2, 3], [2, 3, 7], [0, 3, 12], [3, 4, 10], [2, 4, 2], [0, 4, 8]],passingFees = [4, 1, 2, 3, 5]) == 9\n assert candidate(maxTime = 200,edges = [[0, 1, 50], [1, 2, 50], [2, 3, 50], [3, 4, 50], [4, 5, 50], [0, 3, 60], [2, 4, 70]],passingFees = [10, 20, 30, 40, 50, 60]) == 160\n assert candidate(maxTime = 300,edges = [[0, 1, 50], [0, 2, 100], [1, 3, 200], [2, 3, 150], [3, 4, 250], [0, 3, 200], [1, 2, 100], [0, 4, 300], [1, 4, 150]],passingFees = [10, 20, 30, 40, 50]) == 60\n"}, "metadata": {"canonical_parameter_names": ["maxTime", "edges", "passingFees"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minCost(self, maxTime: int, edges: list[list[int]], passingFees: list[int]) -> int:", "container": "Solution", "callable": "minCost", "parameters": [{"name": "maxTime", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "passingFees", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1929, "task_id": "concatenation-of-array", "difficulty": "Easy", "problem_description": "Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n (0-indexed).\nSpecifically, ans is the concatenation of two nums arrays.\nReturn the array ans.\n \nExample 1:\n\nInput: nums = [1,2,1]\nOutput: [1,2,1,1,2,1]\nExplanation: The array ans is formed as follows:\n- ans = [nums[0],nums[1],nums[2],nums[0],nums[1],nums[2]]\n- ans = [1,2,1,1,2,1]\nExample 2:\n\nInput: nums = [1,3,2,1]\nOutput: [1,3,2,1,1,3,2,1]\nExplanation: The array ans is formed as follows:\n- ans = [nums[0],nums[1],nums[2],nums[3],nums[0],nums[1],nums[2],nums[3]]\n- ans = [1,3,2,1,1,3,2,1]\n\n \nConstraints:\n\nn == nums.length\n1 <= n <= 1000\n1 <= nums[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [5, 6, 7]) == [5, 6, 7, 5, 6, 7]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [1, 2, 1]) == [1, 2, 1, 1, 2, 1]\n assert candidate(nums = [1000, 999, 998, 997, 996]) == [1000, 999, 998, 997, 996, 1000, 999, 998, 997, 996]\n assert candidate(nums = [1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [999, 1000]) == [999, 1000, 999, 1000]\n assert candidate(nums = [1, 3, 2, 1]) == [1, 3, 2, 1, 1, 3, 2, 1]\n assert candidate(nums = [10, 20, 30, 40, 50]) == [10, 20, 30, 40, 50, 10, 20, 30, 40, 50]\n assert candidate(nums = [999, 1000, 999, 1000]) == [999, 1000, 999, 1000, 999, 1000, 999, 1000]\n assert candidate(nums = [5, 6, 7, 8, 9]) == [5, 6, 7, 8, 9, 5, 6, 7, 8, 9]\n assert candidate(nums = [5]) == [5, 5]\n assert candidate(nums = [1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10]) == [10, 10]\n assert candidate(nums = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992, 8, 991, 9, 990, 10]) == [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992, 8, 991, 9, 990, 10, 999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992, 8, 991, 9, 990, 10]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == [1, 2, 3, 2, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 2, 3, 2, 1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510]) == [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510]\n assert candidate(nums = [1000, 1, 999, 2, 998, 3, 997, 4, 996, 5]) == [1000, 1, 999, 2, 998, 3, 997, 4, 996, 5, 1000, 1, 999, 2, 998, 3, 997, 4, 996, 5]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [500, 250, 125, 62, 31, 15, 7, 3, 1]) == [500, 250, 125, 62, 31, 15, 7, 3, 1, 500, 250, 125, 62, 31, 15, 7, 3, 1]\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630]) == [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630]\n assert candidate(nums = [10, 200, 3000, 40000, 500000, 6, 7, 8, 9, 10]) == [10, 200, 3000, 40000, 500000, 6, 7, 8, 9, 10, 10, 200, 3000, 40000, 500000, 6, 7, 8, 9, 10]\n assert candidate(nums = [1000, 1, 200, 2, 300, 3, 400, 4]) == [1000, 1, 200, 2, 300, 3, 400, 4, 1000, 1, 200, 2, 300, 3, 400, 4]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209]) == [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209]\n assert candidate(nums = [999, 1000, 998, 999, 1000, 998, 999]) == [999, 1000, 998, 999, 1000, 998, 999, 999, 1000, 998, 999, 1000, 998, 999]\n assert candidate(nums = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]) == [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666]) == [333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666]\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970]) == [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]\n assert candidate(nums = [999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == [999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 998, 997, 996, 995, 994, 993, 992, 991, 990, 999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 998, 997, 996, 995, 994, 993, 992, 991, 990]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]\n assert candidate(nums = [500, 250, 125, 62, 31, 15, 7, 3, 1, 0]) == [500, 250, 125, 62, 31, 15, 7, 3, 1, 0, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 1]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991]) == [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991, 1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]\n assert candidate(nums = [999, 1000, 999, 1000, 999, 1000, 999, 1000]) == [999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115]\n assert candidate(nums = [1000, 1, 1000, 1, 1000, 1, 1000]) == [1000, 1, 1000, 1, 1000, 1, 1000, 1000, 1, 1000, 1, 1000, 1, 1000]\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505]) == [123, 456, 789, 101, 202, 303, 404, 505, 123, 456, 789, 101, 202, 303, 404, 505]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840]) == [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840, 42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().getConcatenation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getConcatenation(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "getConcatenation", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1930, "task_id": "unique-length-3-palindromic-subsequences", "difficulty": "Medium", "problem_description": "Given a string s, return the number of unique palindromes of length three that are a subsequence of s.\nNote that even if there are multiple ways to obtain the same subsequence, it is still only counted once.\nA palindrome is a string that reads the same forwards and backwards.\nA subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.\n\nFor example, \"ace\" is a subsequence of \"abcde\".\n\n \nExample 1:\n\nInput: s = \"aabca\"\nOutput: 3\nExplanation: The 3 palindromic subsequences of length 3 are:\n- \"aba\" (subsequence of \"aabca\")\n- \"aaa\" (subsequence of \"aabca\")\n- \"aca\" (subsequence of \"aabca\")\n\nExample 2:\n\nInput: s = \"adc\"\nOutput: 0\nExplanation: There are no palindromic subsequences of length 3 in \"adc\".\n\nExample 3:\n\nInput: s = \"bbcbaba\"\nOutput: 4\nExplanation: The 4 palindromic subsequences of length 3 are:\n- \"bbb\" (subsequence of \"bbcbaba\")\n- \"bcb\" (subsequence of \"bbcbaba\")\n- \"bab\" (subsequence of \"bbcbaba\")\n- \"aba\" (subsequence of \"bbcbaba\")\n\n \nConstraints:\n\n3 <= s.length <= 105\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcba\") == 3\n assert candidate(s = \"madam\") == 3\n assert candidate(s = \"abcdedcba\") == 10\n assert candidate(s = \"aaaaa\") == 1\n assert candidate(s = \"adc\") == 0\n assert candidate(s = \"abcabcabc\") == 9\n assert candidate(s = \"abracadabra\") == 13\n assert candidate(s = \"aaa\") == 1\n assert candidate(s = \"racecar\") == 6\n assert candidate(s = \"abba\") == 1\n assert candidate(s = \"noon\") == 1\n assert candidate(s = \"abccba\") == 3\n assert candidate(s = \"aaaa\") == 1\n assert candidate(s = \"aabbcc\") == 0\n assert candidate(s = \"mississippi\") == 5\n assert candidate(s = \"aabca\") == 3\n assert candidate(s = \"bbcbaba\") == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(s = \"xyzzyx\") == 3\n assert candidate(s = \"level\") == 3\n assert candidate(s = \"abcdefg\") == 0\n assert candidate(s = \"aabacbaabacba\") == 8\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(s = \"noonmoonnoonmoonnoonmoonnoonmoonnoonmoonnoonmoonnoon\") == 9\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyyxwwvvuuttssrrqqppoonnmmllkkjjiihhggeeffddccbbaa\") == 352\n assert candidate(s = \"zzzzzzzyyyyxxxwwvvuttsrrqqppoonnmmllkkjjiihhggffeeddccba\") == 3\n assert candidate(s = \"zzzazzaaz\") == 4\n assert candidate(s = \"abacabadabacaba\") == 11\n assert candidate(s = \"ababababababababababababababababababababab\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 9\n assert candidate(s = \"ababcab\") == 6\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 16\n assert candidate(s = \"racecarcarcarecarracecarcarcarecarracecarcarcarecarracecar\") == 16\n assert candidate(s = \"abacdfgdcaba\") == 16\n assert candidate(s = \"aabbbaaabbbaaa\") == 4\n assert candidate(s = \"aaabaaaabaaaaabaaaabaaaaaabaaaa\") == 4\n assert candidate(s = \"aaaabaaaabaaaab\") == 4\n assert candidate(s = \"abcbabcbabcbabcbabcbabcbabcba\") == 9\n assert candidate(s = \"bababababababababababababababababababababa\") == 4\n assert candidate(s = \"abcbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbac\") == 9\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 4\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 325\n assert candidate(s = \"xyzyxyzyxyzyx\") == 9\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 650\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaedcba\") == 20\n assert candidate(s = \"abbaabbbaabbaabbbaabbaabbbaabbaabbbaabbaabbba\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 9\n assert candidate(s = \"abcdefghihgfedcbaabcdefghihgfedcba\") == 80\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 26\n assert candidate(s = \"aaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaab\") == 4\n assert candidate(s = \"abcbacbacbacbacbacbacbacbacbacbacbacbacb\") == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"babababababababababababababababababababababababababababababa\") == 4\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\") == 4\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzzzz\") == 26\n assert candidate(s = \"mamamadadadmmadammaddada\") == 9\n assert candidate(s = \"aabbccddeeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"ababababababababababababababababababababababababababab\") == 4\n assert candidate(s = \"aaaaaaaaaaaabbbbbbbbbbbbccccccccccdddddddddd\") == 4\n assert candidate(s = \"racecarcarcarecarracecarcarcarecarracecar\") == 16\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 9\n assert candidate(s = \"abacbacbacbacba\") == 9\n assert candidate(s = \"ababababababababababababababababababababababababababababababab\") == 4\n assert candidate(s = \"mississippississippiississippiississippiississippiississippi\") == 9\n assert candidate(s = \"abcabcabcabcabc\") == 9\n assert candidate(s = \"noonmoonnoonmoon\") == 8\n assert candidate(s = \"noonmoonnoonmoonnoonmoonnoonmoonnoonmoonnoonmoonnoonnoonmoon\") == 9\n assert candidate(s = \"aaaaabbbbbccccc\") == 3\n assert candidate(s = \"mississippississippiississippiississippiississippi\") == 9\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabad\") == 16\n assert candidate(s = \"zzzzzyyyxxwwvvuttsrrqqppoonnmmllkkjjiihhggffeeddccba\") == 2\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 9\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\") == 4\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().countPalindromicSubsequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countPalindromicSubsequence(self, s: str) -> int:", "container": "Solution", "callable": "countPalindromicSubsequence", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1931, "task_id": "painting-a-grid-with-three-different-colors", "difficulty": "Hard", "problem_description": "You are given two integers m and n. Consider an m x n grid where each cell is initially white. You can paint each cell red, green, or blue. All cells must be painted.\nReturn the number of ways to color the grid with no two adjacent cells having the same color. Since the answer can be very large, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: m = 1, n = 1\nOutput: 3\nExplanation: The three possible colorings are shown in the image above.\n\nExample 2:\n\n\nInput: m = 1, n = 2\nOutput: 6\nExplanation: The six possible colorings are shown in the image above.\n\nExample 3:\n\nInput: m = 5, n = 5\nOutput: 580986\n\n \nConstraints:\n\n1 <= m <= 5\n1 <= n <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(m = 2,n = 4) == 162\n assert candidate(m = 4,n = 3) == 1122\n assert candidate(m = 5,n = 1) == 48\n assert candidate(m = 1,n = 2) == 6\n assert candidate(m = 5,n = 5) == 580986\n assert candidate(m = 3,n = 4) == 1122\n assert candidate(m = 1,n = 1) == 3\n assert candidate(m = 4,n = 2) == 162\n assert candidate(m = 3,n = 3) == 246\n assert candidate(m = 2,n = 3) == 54\n assert candidate(m = 5,n = 800) == 253729951\n assert candidate(m = 4,n = 4) == 7812\n assert candidate(m = 2,n = 800) == 351341125\n assert candidate(m = 5,n = 500) == 859596253\n assert candidate(m = 5,n = 250) == 385854418\n assert candidate(m = 1,n = 1000) == 32634808\n assert candidate(m = 4,n = 350) == 47085356\n assert candidate(m = 3,n = 10) == 10107954\n assert candidate(m = 4,n = 500) == 614795573\n assert candidate(m = 1,n = 5) == 48\n assert candidate(m = 1,n = 500) == 85724507\n assert candidate(m = 3,n = 50) == 151149117\n assert candidate(m = 4,n = 600) == 643128638\n assert candidate(m = 4,n = 750) == 346928514\n assert candidate(m = 3,n = 500) == 350959293\n assert candidate(m = 2,n = 100) == 772083415\n assert candidate(m = 5,n = 2) == 486\n assert candidate(m = 2,n = 900) == 360544652\n assert candidate(m = 2,n = 2) == 18\n assert candidate(m = 4,n = 1000) == 281273229\n assert candidate(m = 4,n = 998) == 16509421\n assert candidate(m = 3,n = 7) == 106494\n assert candidate(m = 3,n = 1000) == 650420578\n assert candidate(m = 5,n = 50) == 597561939\n assert candidate(m = 4,n = 100) == 80216004\n assert candidate(m = 4,n = 10) == 896895828\n assert candidate(m = 4,n = 999) == 772309689\n assert candidate(m = 4,n = 6) == 379602\n assert candidate(m = 2,n = 999) == 37925462\n assert candidate(m = 5,n = 100) == 714933866\n assert candidate(m = 2,n = 600) == 138487123\n assert candidate(m = 3,n = 1) == 12\n assert candidate(m = 5,n = 10) == 796884854\n assert candidate(m = 3,n = 800) == 314710698\n assert candidate(m = 4,n = 5) == 54450\n assert candidate(m = 5,n = 200) == 55054779\n assert candidate(m = 3,n = 750) == 493513580\n assert candidate(m = 5,n = 997) == 582030758\n assert candidate(m = 3,n = 900) == 999754739\n assert candidate(m = 3,n = 700) == 360760626\n assert candidate(m = 5,n = 300) == 194398079\n assert candidate(m = 4,n = 9) == 128643282\n assert candidate(m = 2,n = 1000) == 113776386\n assert candidate(m = 4,n = 700) == 795691966\n assert candidate(m = 4,n = 250) == 727847864\n assert candidate(m = 5,n = 3) == 5118\n assert candidate(m = 4,n = 800) == 197304781\n assert candidate(m = 3,n = 300) == 748221310\n assert candidate(m = 5,n = 1000) == 408208448\n assert candidate(m = 3,n = 20) == 690883140\n assert candidate(m = 2,n = 5) == 486\n"}, "metadata": {"canonical_parameter_names": ["m", "n"], "leetcode_dataset_entry_point": "Solution().colorTheGrid", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def colorTheGrid(self, m: int, n: int) -> int:", "container": "Solution", "callable": "colorTheGrid", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1935, "task_id": "maximum-number-of-words-you-can-type", "difficulty": "Easy", "problem_description": "There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly.\nGiven a string text of words separated by a single space (no leading or trailing spaces) and a string brokenLetters of all distinct letter keys that are broken, return the number of words in text you can fully type using this keyboard.\n \nExample 1:\n\nInput: text = \"hello world\", brokenLetters = \"ad\"\nOutput: 1\nExplanation: We cannot type \"world\" because the 'd' key is broken.\n\nExample 2:\n\nInput: text = \"leet code\", brokenLetters = \"lt\"\nOutput: 1\nExplanation: We cannot type \"leet\" because the 'l' and 't' keys are broken.\n\nExample 3:\n\nInput: text = \"leet code\", brokenLetters = \"e\"\nOutput: 0\nExplanation: We cannot type either word because the 'e' key is broken.\n\n \nConstraints:\n\n1 <= text.length <= 104\n0 <= brokenLetters.length <= 26\ntext consists of words separated by a single space without any leading or trailing spaces.\nEach word only consists of lowercase English letters.\nbrokenLetters consists of distinct lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"jumped over the lazy dog\",brokenLetters = \"zg\") == 3\n assert candidate(text = \"nopqrstuvwxyz\",brokenLetters = \"xyz\") == 0\n assert candidate(text = \"xyzzzz\",brokenLetters = \"x\") == 0\n assert candidate(text = \"leet code\",brokenLetters = \"lt\") == 1\n assert candidate(text = \"programming is fun\",brokenLetters = \"fn\") == 1\n assert candidate(text = \"this is a test\",brokenLetters = \"xyz\") == 4\n assert candidate(text = \"mississippi\",brokenLetters = \"sip\") == 0\n assert candidate(text = \"python java cplusplus\",brokenLetters = \"ypx\") == 1\n assert candidate(text = \"same same same\",brokenLetters = \"aem\") == 0\n assert candidate(text = \"a b c d e\",brokenLetters = \"\") == 5\n assert candidate(text = \"aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu vv ww xx yy zz\",brokenLetters = \"xyz\") == 23\n assert candidate(text = \"abcdefghijk\",brokenLetters = \"abcde\") == 0\n assert candidate(text = \"leet code\",brokenLetters = \"e\") == 0\n assert candidate(text = \"single\",brokenLetters = \"s\") == 0\n assert candidate(text = \"unique words\",brokenLetters = \"\") == 2\n assert candidate(text = \"single\",brokenLetters = \"\") == 1\n assert candidate(text = \"abc def ghi\",brokenLetters = \"xyz\") == 3\n assert candidate(text = \"python programming\",brokenLetters = \"p\") == 0\n assert candidate(text = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",brokenLetters = \"\") == 26\n assert candidate(text = \"a quick brown fox\",brokenLetters = \"\") == 4\n assert candidate(text = \"abcd efgh ijkl mnop qrst uvwx yz\",brokenLetters = \"aeiou\") == 2\n assert candidate(text = \"python programming\",brokenLetters = \"th\") == 1\n assert candidate(text = \"abcdefghij\",brokenLetters = \"\") == 1\n assert candidate(text = \"hello hello hello\",brokenLetters = \"lo\") == 0\n assert candidate(text = \"hello world\",brokenLetters = \"ad\") == 1\n assert candidate(text = \"every good boy does fine\",brokenLetters = \"f\") == 4\n assert candidate(text = \"hello world abcdefghijklmnopqrstuvwxyz\",brokenLetters = \"\") == 3\n assert candidate(text = \"a b c d e f g\",brokenLetters = \"xyz\") == 7\n assert candidate(text = \"extreme example with all letters\",brokenLetters = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(text = \"this is a simple test\",brokenLetters = \"sti\") == 1\n assert candidate(text = \"singleword\",brokenLetters = \"w\") == 0\n assert candidate(text = \"abcdefghij klmnopqrstuvwxyz\",brokenLetters = \"xyz\") == 1\n assert candidate(text = \"university of california berkeley\",brokenLetters = \"bcdfg\") == 1\n assert candidate(text = \"congratulations on your success\",brokenLetters = \"cns\") == 1\n assert candidate(text = \"every good boy does fine\",brokenLetters = \"bd\") == 2\n assert candidate(text = \"hello world from the other side\",brokenLetters = \"dfr\") == 2\n assert candidate(text = \"complexity arises from multiple factors\",brokenLetters = \"ae\") == 1\n assert candidate(text = \"all the letters of the alphabet\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"keyboard malfunctioning example\",brokenLetters = \"kmb\") == 0\n assert candidate(text = \"short long longer longestword\",brokenLetters = \"nlg\") == 1\n assert candidate(text = \"repeated letters letters letters\",brokenLetters = \"r\") == 0\n assert candidate(text = \"quick brown fox jumps over the lazy dog\",brokenLetters = \"xyz\") == 6\n assert candidate(text = \"data structures and algorithms\",brokenLetters = \"dts\") == 0\n assert candidate(text = \"abcdef ghijklm nopqrst uvwxyz\",brokenLetters = \"mnop\") == 2\n assert candidate(text = \"multiple broken letters test\",brokenLetters = \"mlpt\") == 1\n assert candidate(text = \"abcdefghij klmnopqrstuvwxyz\",brokenLetters = \"jkl\") == 0\n assert candidate(text = \"mississippi river\",brokenLetters = \"is\") == 0\n assert candidate(text = \"no broken letters here\",brokenLetters = \"qwxz\") == 4\n assert candidate(text = \"programming is fun\",brokenLetters = \"funs\") == 0\n assert candidate(text = \"all unique characters\",brokenLetters = \"\") == 3\n assert candidate(text = \"quick brown fox jumps over the lazy dog\",brokenLetters = \"\") == 8\n assert candidate(text = \"hello world hello universe\",brokenLetters = \"d\") == 3\n assert candidate(text = \"supercalifragilisticexpialidocious\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"special symbols are not included !@#$%^&*()\",brokenLetters = \"\") == 6\n assert candidate(text = \"brokenkeyboard faultydevice\",brokenLetters = \"bdf\") == 0\n assert candidate(text = \"sequential typing test\",brokenLetters = \"qseq\") == 1\n assert candidate(text = \"unique letters in words\",brokenLetters = \"aeiouy\") == 0\n assert candidate(text = \"python code implementation\",brokenLetters = \"py\") == 1\n assert candidate(text = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",brokenLetters = \"qz\") == 24\n assert candidate(text = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",brokenLetters = \"abcdefghijkl\") == 14\n assert candidate(text = \"complex words like supercalifragilisticexpialidocious\",brokenLetters = \"xyz\") == 2\n assert candidate(text = \"this is a simple test case\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"one two three four five six seven eight nine ten\",brokenLetters = \"on\") == 4\n assert candidate(text = \"lets write some code\",brokenLetters = \"wrs\") == 1\n assert candidate(text = \"multiple broken letters scenario\",brokenLetters = \"aeiouy\") == 0\n assert candidate(text = \"complex problem solving required\",brokenLetters = \"abc\") == 2\n assert candidate(text = \"this is a simple test\",brokenLetters = \"s\") == 1\n assert candidate(text = \"all characters must be checked\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"quick brown fox jumps over lazy dog\",brokenLetters = \"qz\") == 5\n assert candidate(text = \"various broken keys test\",brokenLetters = \"var\") == 2\n assert candidate(text = \"quick brown fox jumps over the lazy dog\",brokenLetters = \"qz\") == 6\n assert candidate(text = \"a quick brown fox jumps over the lazy dog\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"beautiful scenery on the mountain top\",brokenLetters = \"mnt\") == 0\n assert candidate(text = \"vowels are often omitted\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"mississippi river flows smoothly\",brokenLetters = \"m\") == 2\n assert candidate(text = \"hello world from another dimension\",brokenLetters = \"ad\") == 2\n assert candidate(text = \"singlewordwithoutspaces\",brokenLetters = \"s\") == 0\n assert candidate(text = \"abcdefghijklmnopqrstuvwxyz\",brokenLetters = \"xyz\") == 0\n assert candidate(text = \"fuzzy wuzzy was a bear\",brokenLetters = \"f\") == 4\n assert candidate(text = \"algorithms and data structures\",brokenLetters = \"da\") == 1\n assert candidate(text = \"make america great again\",brokenLetters = \"mag\") == 0\n assert candidate(text = \"hello hello hello world\",brokenLetters = \"d\") == 3\n assert candidate(text = \"a aa aaa aaaa aaaaa\",brokenLetters = \"a\") == 0\n assert candidate(text = \"mississippi river\",brokenLetters = \"m\") == 1\n assert candidate(text = \"many many words with many repeated letters\",brokenLetters = \"mny\") == 4\n assert candidate(text = \"abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz\",brokenLetters = \"\") == 2\n assert candidate(text = \"special characters are not considered\",brokenLetters = \"!@#$%^&*()\") == 5\n assert candidate(text = \"alibaba cloud is amazing\",brokenLetters = \"aim\") == 1\n assert candidate(text = \"boundary conditions and edge cases\",brokenLetters = \"bace\") == 0\n assert candidate(text = \"the quick brown fox jumps over the lazy dog\",brokenLetters = \"\") == 9\n assert candidate(text = \"algorithm data structures\",brokenLetters = \"abcde\") == 0\n assert candidate(text = \"xylophone xylophone xylophone\",brokenLetters = \"xy\") == 0\n assert candidate(text = \"complex problem solving\",brokenLetters = \"cps\") == 0\n assert candidate(text = \"longer words with various letters\",brokenLetters = \"wv\") == 2\n assert candidate(text = \"every good boy does fine\",brokenLetters = \"boyd\") == 1\n assert candidate(text = \"the quick brown fox jumps over the lazy dog\",brokenLetters = \"qxyz\") == 6\n assert candidate(text = \"programming in python is fun\",brokenLetters = \"pqf\") == 2\n assert candidate(text = \"this is a test case with many words\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"repeated letters in words\",brokenLetters = \"r\") == 1\n assert candidate(text = \"mississippi river\",brokenLetters = \"r\") == 1\n assert candidate(text = \"edge cases require attention\",brokenLetters = \"ecr\") == 0\n assert candidate(text = \"short words\",brokenLetters = \"aef\") == 2\n assert candidate(text = \"all characters are broken here\",brokenLetters = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(text = \"this is a simple test\",brokenLetters = \"st\") == 1\n assert candidate(text = \"multiple words with repeated letters\",brokenLetters = \"w\") == 3\n assert candidate(text = \"python is a versatile programming language\",brokenLetters = \"p\") == 4\n assert candidate(text = \"this is a simple test case\",brokenLetters = \"\") == 6\n assert candidate(text = \"short words\",brokenLetters = \"ow\") == 0\n assert candidate(text = \"distinct distinct letters letters\",brokenLetters = \"distnl\") == 0\n assert candidate(text = \"the quick brown fox jumps over the lazy dog\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"let us escape from this困境\",brokenLetters = \"et\") == 2\n assert candidate(text = \"broken keyboards are annoying sometimes\",brokenLetters = \"bks\") == 2\n assert candidate(text = \"various combinations\",brokenLetters = \"vbc\") == 0\n assert candidate(text = \"every good boy does fine and gets chocolate\",brokenLetters = \"xyz\") == 6\n assert candidate(text = \"hello world from mars\",brokenLetters = \"mr\") == 1\n assert candidate(text = \"various punctuations are missing\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"quick brown fox jumps over the lazy dog\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"unique words in this sentence\",brokenLetters = \"uie\") == 1\n assert candidate(text = \"multiple words with repeated letters\",brokenLetters = \"r\") == 2\n assert candidate(text = \"one two three four five\",brokenLetters = \"one\") == 0\n assert candidate(text = \"computer science\",brokenLetters = \"xyz\") == 2\n assert candidate(text = \"this is a simple test case\",brokenLetters = \"s\") == 1\n assert candidate(text = \"multiple spaces between words are not allowed\",brokenLetters = \"\") == 7\n assert candidate(text = \"special characters !@#$%^&*()\",brokenLetters = \"s\") == 1\n assert candidate(text = \"banana apple orange\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"abcdefghijklmnopqrstuvwxyz\",brokenLetters = \"nopqrstuvwxyz\") == 0\n assert candidate(text = \"abcdef ghijklm nopqrstuvwxyz\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"spaceship traveling fast\",brokenLetters = \"spfc\") == 1\n assert candidate(text = \"unique characters only\",brokenLetters = \"uqnc\") == 0\n assert candidate(text = \"every good boy does fine\",brokenLetters = \"egbf\") == 0\n assert candidate(text = \"repeated repeated words words\",brokenLetters = \"dpw\") == 0\n assert candidate(text = \"abcdefghijklmnopqrstuvwxy z\",brokenLetters = \"z\") == 1\n assert candidate(text = \"complex problems require careful thought\",brokenLetters = \"th\") == 4\n assert candidate(text = \"all words can be typed\",brokenLetters = \"\") == 5\n assert candidate(text = \"abcdefg hijklm nopqrstuvwxyz\",brokenLetters = \"xyz\") == 2\n"}, "metadata": {"canonical_parameter_names": ["text", "brokenLetters"], "leetcode_dataset_entry_point": "Solution().canBeTypedWords", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canBeTypedWords(self, text: str, brokenLetters: str) -> int:", "container": "Solution", "callable": "canBeTypedWords", "parameters": [{"name": "text", "type": "str"}, {"name": "brokenLetters", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1936, "task_id": "add-minimum-number-of-rungs", "difficulty": "Medium", "problem_description": "You are given a strictly increasing integer array rungs that represents the height of rungs on a ladder. You are currently on the floor at height 0, and you want to reach the last rung.\nYou are also given an integer dist. You can only climb to the next highest rung if the distance between where you are currently at (the floor or on a rung) and the next rung is at most dist. You are able to insert rungs at any positive integer height if a rung is not already there.\nReturn the minimum number of rungs that must be added to the ladder in order for you to climb to the last rung.\n \nExample 1:\n\nInput: rungs = [1,3,5,10], dist = 2\nOutput: 2\nExplanation:\nYou currently cannot reach the last rung.\nAdd rungs at heights 7 and 8 to climb this ladder. \nThe ladder will now have rungs at [1,3,5,7,8,10].\n\nExample 2:\n\nInput: rungs = [3,6,8,10], dist = 3\nOutput: 0\nExplanation:\nThis ladder can be climbed without adding additional rungs.\n\nExample 3:\n\nInput: rungs = [3,4,6,7], dist = 2\nOutput: 1\nExplanation:\nYou currently cannot reach the first rung from the ground.\nAdd a rung at height 1 to climb this ladder.\nThe ladder will now have rungs at [1,3,4,6,7].\n\n \nConstraints:\n\n1 <= rungs.length <= 105\n1 <= rungs[i] <= 109\n1 <= dist <= 109\nrungs is strictly increasing.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rungs = [1, 3, 5, 10],dist = 2) == 2\n assert candidate(rungs = [1, 2, 3, 4, 5],dist = 1) == 0\n assert candidate(rungs = [3, 6, 8, 10],dist = 3) == 0\n assert candidate(rungs = [10],dist = 10) == 0\n assert candidate(rungs = [1000000000],dist = 1) == 999999999\n assert candidate(rungs = [1, 1000000000],dist = 1) == 999999998\n assert candidate(rungs = [1, 5, 11, 20],dist = 4) == 3\n assert candidate(rungs = [3, 4, 6, 7],dist = 2) == 1\n assert candidate(rungs = [5],dist = 10) == 0\n assert candidate(rungs = [1, 5, 10, 16, 23, 31, 40, 50, 61, 73, 86, 100],dist = 14) == 0\n assert candidate(rungs = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 1) == 89\n assert candidate(rungs = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],dist = 10) == 0\n assert candidate(rungs = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],dist = 2) == 502\n assert candidate(rungs = [2, 8, 16, 32, 64, 128],dist = 15) == 7\n assert candidate(rungs = [100, 200, 300, 400, 500],dist = 150) == 0\n assert candidate(rungs = [2, 5, 10, 20, 35, 55, 80, 110, 145, 185, 230],dist = 5) == 36\n assert candidate(rungs = [1, 8, 15, 22, 29],dist = 5) == 4\n assert candidate(rungs = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],dist = 10) == 0\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],dist = 15) == 0\n assert candidate(rungs = [5, 10, 20, 40, 80, 160],dist = 10) == 11\n assert candidate(rungs = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],dist = 3) == 24\n assert candidate(rungs = [1, 7, 15, 30, 60],dist = 10) == 3\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],dist = 1) == 502\n assert candidate(rungs = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],dist = 20) == 47\n assert candidate(rungs = [10, 25, 45, 70, 100, 130, 160, 190, 220, 250],dist = 30) == 0\n assert candidate(rungs = [1, 6, 15, 30, 50],dist = 10) == 2\n assert candidate(rungs = [1, 1000000000],dist = 100000000) == 9\n assert candidate(rungs = [100, 200, 300, 400, 500],dist = 99) == 5\n assert candidate(rungs = [1, 8, 15, 22, 30],dist = 5) == 4\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 9) == 10\n assert candidate(rungs = [10, 15, 25, 40, 50],dist = 10) == 1\n assert candidate(rungs = [2, 5, 11, 21, 35, 50],dist = 5) == 6\n assert candidate(rungs = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59],dist = 6) == 0\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 1) == 90\n assert candidate(rungs = [1, 1000000000],dist = 100000000) == 9\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],dist = 14) == 0\n assert candidate(rungs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],dist = 1) == 0\n assert candidate(rungs = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],dist = 50) == 0\n assert candidate(rungs = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 100],dist = 10) == 0\n assert candidate(rungs = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190],dist = 20) == 0\n assert candidate(rungs = [10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],dist = 10) == 4\n assert candidate(rungs = [5, 10, 20, 40, 80, 160],dist = 25) == 4\n assert candidate(rungs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],dist = 1) == 10\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120],dist = 4) == 21\n assert candidate(rungs = [1, 4, 10, 20, 30],dist = 5) == 3\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],dist = 10) == 98\n assert candidate(rungs = [5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000],dist = 100000) == 6\n assert candidate(rungs = [3, 15, 25, 30, 45, 60, 85, 100],dist = 12) == 5\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28],dist = 3) == 5\n assert candidate(rungs = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],dist = 100) == 8\n assert candidate(rungs = [2, 6, 10, 14, 18, 22, 26],dist = 4) == 0\n assert candidate(rungs = [100, 200, 300, 400, 500],dist = 90) == 5\n assert candidate(rungs = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],dist = 100000) == 9995\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],dist = 1024) == 1013\n assert candidate(rungs = [5, 11, 19, 29, 41, 55, 71, 89, 109, 131],dist = 6) == 15\n assert candidate(rungs = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 9) == 9\n assert candidate(rungs = [2, 8, 14, 20, 26, 32, 38, 44, 50],dist = 6) == 0\n assert candidate(rungs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],dist = 3) == 0\n assert candidate(rungs = [1, 2, 4, 7, 13, 21],dist = 3) == 3\n assert candidate(rungs = [1000000000],dist = 500000000) == 1\n assert candidate(rungs = [1, 5, 15, 30, 50, 70, 100, 150, 200, 300],dist = 25) == 6\n assert candidate(rungs = [2, 8, 14, 22, 30, 40, 50],dist = 6) == 4\n assert candidate(rungs = [1, 1000000000],dist = 1) == 999999998\n assert candidate(rungs = [1, 100, 200, 300],dist = 50) == 3\n assert candidate(rungs = [3, 15, 35, 65, 100, 145, 195, 250, 310, 375],dist = 10) == 31\n assert candidate(rungs = [10, 25, 45, 60, 75, 90],dist = 15) == 1\n assert candidate(rungs = [10, 25, 45, 70, 100],dist = 15) == 3\n assert candidate(rungs = [1, 1000000000],dist = 500000000) == 1\n assert candidate(rungs = [5, 12, 24, 40, 60, 85, 100],dist = 10) == 6\n assert candidate(rungs = [1, 1000000000],dist = 1000000) == 999\n assert candidate(rungs = [2, 5, 9, 14, 20, 27, 35, 44, 54, 65],dist = 4) == 10\n assert candidate(rungs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],dist = 2) == 0\n assert candidate(rungs = [1, 9, 15, 25, 30],dist = 5) == 3\n assert candidate(rungs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],dist = 9) == 0\n assert candidate(rungs = [2, 8, 18, 32, 50, 72, 98],dist = 15) == 3\n assert candidate(rungs = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120],dist = 500) == 8\n assert candidate(rungs = [5, 10, 20, 40, 80, 160],dist = 10) == 11\n assert candidate(rungs = [1, 6, 11, 16, 21, 26],dist = 5) == 0\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 10) == 0\n assert candidate(rungs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],dist = 2) == 0\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],dist = 5) == 5\n assert candidate(rungs = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],dist = 1000000) == 996\n assert candidate(rungs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],dist = 3) == 0\n assert candidate(rungs = [1000000000],dist = 100000000) == 9\n assert candidate(rungs = [1, 1000000000],dist = 500000000) == 1\n assert candidate(rungs = [10, 1000000000],dist = 500000000) == 1\n assert candidate(rungs = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 9) == 9\n assert candidate(rungs = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56, 67, 79, 92, 106],dist = 5) == 13\n assert candidate(rungs = [2, 3, 6, 8, 15, 22, 30, 35, 40, 50],dist = 5) == 4\n assert candidate(rungs = [3, 9, 12, 21, 23, 29, 30],dist = 6) == 1\n assert candidate(rungs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],dist = 2) == 0\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],dist = 3) == 12\n assert candidate(rungs = [1, 10, 15, 20, 25, 30],dist = 5) == 1\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],dist = 15) == 0\n assert candidate(rungs = [5, 12, 22, 35, 50, 68, 89, 113, 141, 173, 209],dist = 7) == 23\n assert candidate(rungs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],dist = 1) == 0\n assert candidate(rungs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],dist = 1) == 10\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64],dist = 15) == 3\n assert candidate(rungs = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],dist = 2) == 38\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 9) == 10\n assert candidate(rungs = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],dist = 1000000) == 996\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],dist = 100) == 8\n"}, "metadata": {"canonical_parameter_names": ["rungs", "dist"], "leetcode_dataset_entry_point": "Solution().addRungs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def addRungs(self, rungs: list[int], dist: int) -> int:", "container": "Solution", "callable": "addRungs", "parameters": [{"name": "rungs", "type": "list[int]"}, {"name": "dist", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1937, "task_id": "maximum-number-of-points-with-cost", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix points (0-indexed). Starting with 0 points, you want to maximize the number of points you can get from the matrix.\nTo gain points, you must pick one cell in each row. Picking the cell at coordinates (r, c) will add points[r][c] to your score.\nHowever, you will lose points if you pick a cell too far from the cell that you picked in the previous row. For every two adjacent rows r and r + 1 (where 0 <= r < m - 1), picking cells at coordinates (r, c1) and (r + 1, c2) will subtract abs(c1 - c2) from your score.\nReturn the maximum number of points you can achieve.\nabs(x) is defined as:\n\nx for x >= 0.\n-x for x < 0.\n\n \nExample 1: \n\n\nInput: points = [[1,2,3],[1,5,1],[3,1,1]]\nOutput: 9\nExplanation:\nThe blue cells denote the optimal cells to pick, which have coordinates (0, 2), (1, 1), and (2, 0).\nYou add 3 + 5 + 3 = 11 to your score.\nHowever, you must subtract abs(2 - 1) + abs(1 - 0) = 2 from your score.\nYour final score is 11 - 2 = 9.\n\nExample 2:\n\n\nInput: points = [[1,5],[2,3],[4,2]]\nOutput: 11\nExplanation:\nThe blue cells denote the optimal cells to pick, which have coordinates (0, 1), (1, 1), and (2, 0).\nYou add 5 + 3 + 4 = 12 to your score.\nHowever, you must subtract abs(1 - 1) + abs(1 - 0) = 1 from your score.\nYour final score is 12 - 1 = 11.\n\n \nConstraints:\n\nm == points.length\nn == points[r].length\n1 <= m, n <= 105\n1 <= m * n <= 105\n0 <= points[r][c] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[5, 10], [10, 5]]) == 19\n assert candidate(points = [[5, 2], [1, 2]]) == 6\n assert candidate(points = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9]]) == 15\n assert candidate(points = [[1, 2, 3], [1, 5, 1], [3, 1, 1]]) == 9\n assert candidate(points = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == 6\n assert candidate(points = [[1, 5], [2, 3], [4, 2]]) == 11\n assert candidate(points = [[1]]) == 1\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 15\n assert candidate(points = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == 25\n assert candidate(points = [[5, 3, 8, 6, 7, 2], [9, 4, 1, 5, 3, 8], [2, 6, 4, 9, 1, 5], [7, 3, 5, 2, 8, 6]]) == 28\n assert candidate(points = [[1, 3, 2], [4, 6, 5], [7, 9, 8], [10, 12, 11], [13, 15, 14]]) == 45\n assert candidate(points = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]]) == 15\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 2, 4, 6, 8, 10], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 121\n assert candidate(points = [[9, 5, 3, 1, 7], [2, 8, 6, 4, 0], [5, 1, 9, 3, 6], [4, 7, 2, 8, 5], [3, 6, 4, 1, 9]]) == 39\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]]) == 21\n assert candidate(points = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 28\n assert candidate(points = [[5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 20\n assert candidate(points = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 40\n assert candidate(points = [[5, 10, 15, 20, 25], [25, 20, 15, 10, 5], [5, 5, 5, 5, 5], [10, 15, 20, 25, 30], [30, 25, 20, 15, 10]]) == 103\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 12\n assert candidate(points = [[10, 20, 30, 40, 50, 60, 70], [70, 60, 50, 40, 30, 20, 10], [10, 70, 20, 60, 30, 50, 40]]) == 203\n assert candidate(points = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 40\n assert candidate(points = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(points = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1]]) == 106\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 4, 6, 8, 10, 9, 7, 5, 3, 1]]) == 21\n assert candidate(points = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]]) == 51\n assert candidate(points = [[5, 3, 1, 4], [3, 1, 4, 5], [1, 4, 5, 3], [4, 5, 3, 1]]) == 17\n assert candidate(points = [[5, 3, 8, 6], [2, 4, 7, 1], [3, 6, 9, 2], [8, 5, 2, 4]]) == 30\n assert candidate(points = [[9, 1, 5, 3, 7], [3, 9, 1, 5, 3], [7, 3, 9, 1, 5], [5, 7, 3, 9, 1], [1, 5, 7, 3, 9]]) == 41\n assert candidate(points = [[5, 2, 3, 1, 4], [1, 3, 2, 5, 4], [3, 4, 5, 2, 1], [4, 1, 2, 3, 5], [2, 5, 4, 1, 3]]) == 18\n assert candidate(points = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]]) == 15\n assert candidate(points = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]) == 180\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]]) == 45\n assert candidate(points = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(points = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 5\n assert candidate(points = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]]) == 50\n assert candidate(points = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 6, 2, 5, 3, 4]]) == 13\n assert candidate(points = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [9, 8, 7, 6, 5]]) == 27\n assert candidate(points = [[50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50]]) == 250\n assert candidate(points = [[100000, 100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000, 100000]]) == 300000\n assert candidate(points = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 1, 9, 1, 9, 1, 9, 1, 9], [1, 9, 1, 9, 1, 9, 1, 9, 1]]) == 27\n assert candidate(points = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 100], [100, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 100, 0], [0, 0, 0, 0, 0, 0, 0, 100, 0, 0], [0, 0, 0, 0, 0, 0, 100, 0, 0, 0]]) == 481\n assert candidate(points = [[100, 200, 300, 400, 500], [90, 80, 70, 60, 50], [10, 20, 30, 40, 50], [5, 15, 25, 35, 45]]) == 677\n assert candidate(points = [[1, 10, 2, 9, 3, 8, 4, 7, 5, 6], [10, 1, 9, 2, 8, 3, 7, 4, 6, 5], [5, 6, 4, 7, 3, 8, 2, 9, 1, 10]]) == 24\n assert candidate(points = [[10, 10, 10, 10, 10], [1, 1, 1, 1, 1], [9, 9, 9, 9, 9], [2, 2, 2, 2, 2]]) == 22\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 30\n assert candidate(points = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]]) == 12\n assert candidate(points = [[10, 6, 3, 9, 7], [1, 4, 5, 8, 2], [9, 7, 4, 3, 6], [2, 8, 1, 5, 9]]) == 31\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 110\n assert candidate(points = [[100, 100, 100], [100, 100, 100], [100, 100, 100], [100, 100, 100], [100, 100, 100]]) == 500\n assert candidate(points = [[5, 3, 8, 6, 2, 9], [1, 7, 4, 8, 5, 3], [6, 2, 9, 4, 8, 1], [3, 6, 5, 7, 2, 8]]) == 29\n assert candidate(points = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 50, 10, 50, 10], [50, 10, 50, 10, 50], [10, 20, 30, 40, 50]]) == 242\n assert candidate(points = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 4\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13]]) == 22\n assert candidate(points = [[1, 1, 1, 1, 1], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == 7\n assert candidate(points = [[100000, 90000, 80000, 70000, 60000], [50000, 40000, 30000, 20000, 10000], [90000, 80000, 70000, 60000, 50000], [40000, 30000, 20000, 10000, 9000]]) == 280000\n assert candidate(points = [[90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [99, 98, 97, 96, 95, 94, 93, 92, 91, 90], [90, 92, 94, 96, 98, 100, 98, 96, 94, 92]]) == 289\n assert candidate(points = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 20, 30, 40, 50, 60, 70, 80, 90], [90, 80, 70, 60, 50, 40, 30, 20, 10]]) == 182\n assert candidate(points = [[1000, 500, 250, 125], [125, 250, 500, 1000], [1000, 500, 250, 125], [125, 250, 500, 1000]]) == 3991\n assert candidate(points = [[5, 3, 1, 4, 2], [8, 6, 7, 5, 3], [0, 9, 8, 7, 6], [2, 3, 4, 5, 1]]) == 24\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 42\n assert candidate(points = [[50, 50, 50, 50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]]) == 150\n assert candidate(points = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 45\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 112\n assert candidate(points = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]]) == 41\n assert candidate(points = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 30, 50, 70, 90], [90, 70, 50, 30, 10]]) == 268\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]]) == 10\n assert candidate(points = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 1\n assert candidate(points = [[5, 3, 8, 2, 1], [1, 4, 2, 3, 8], [8, 1, 4, 2, 3], [3, 8, 1, 4, 2]]) == 25\n assert candidate(points = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [1, 2, 3, 4, 5], [9, 8, 7, 6, 5]]) == 106\n assert candidate(points = [[100000, 100000, 100000], [100000, 100000, 100000], [100000, 100000, 100000]]) == 300000\n assert candidate(points = [[100, 200], [150, 250], [200, 150], [250, 100], [300, 50]]) == 1199\n assert candidate(points = [[100, 90, 80, 70, 60, 50, 40, 30, 20, 10], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 201\n assert candidate(points = [[5, 3, 1], [1, 5, 3], [3, 1, 5], [5, 3, 1], [1, 5, 3]]) == 20\n assert candidate(points = [[10, 3, 5, 1, 2], [4, 6, 7, 3, 8], [2, 9, 1, 4, 6], [5, 3, 7, 9, 1], [8, 2, 6, 4, 5]]) == 36\n assert candidate(points = [[10, 1, 3, 5, 20], [5, 10, 15, 20, 25], [25, 20, 15, 10, 5]]) == 66\n assert candidate(points = [[1, 3, 1, 5, 1, 3, 1], [3, 1, 3, 1, 3, 1, 3], [1, 5, 1, 5, 1, 5, 1], [5, 1, 5, 1, 5, 1, 5]]) == 15\n assert candidate(points = [[100, 200, 300], [300, 200, 100], [200, 300, 200], [100, 100, 100]]) == 997\n assert candidate(points = [[100, 90, 80, 70, 60], [60, 70, 80, 90, 100], [100, 100, 100, 100, 100], [1, 2, 3, 4, 5]]) == 301\n assert candidate(points = [[7, 6, 8, 5, 9, 10], [10, 9, 8, 7, 6, 5], [5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6]]) == 31\n assert candidate(points = [[10, 15, 20, 25, 30], [5, 10, 15, 20, 25], [30, 25, 20, 15, 10], [1, 2, 3, 4, 5]]) == 82\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 32\n assert candidate(points = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 11\n assert candidate(points = [[10, 20, 30], [30, 20, 10], [20, 30, 10], [10, 20, 30], [30, 10, 20]]) == 144\n assert candidate(points = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]]) == 45\n assert candidate(points = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(points = [[10, 15, 20, 25], [25, 20, 15, 10], [10, 20, 30, 40], [40, 30, 20, 10]]) == 121\n assert candidate(points = [[7, 8, 9, 10, 11], [11, 10, 9, 8, 7], [7, 9, 11, 10, 8], [8, 10, 7, 9, 11]]) == 38\n assert candidate(points = [[5, 1, 3, 2, 4], [2, 6, 1, 4, 5], [3, 3, 5, 1, 2], [1, 2, 4, 6, 3]]) == 19\n"}, "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().maxPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxPoints(self, points: list[list[int]]) -> int:", "container": "Solution", "callable": "maxPoints", "parameters": [{"name": "points", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1938, "task_id": "maximum-genetic-difference-query", "difficulty": "Hard", "problem_description": "There is a rooted tree consisting of n nodes numbered 0 to n - 1. Each node's number denotes its unique genetic value (i.e. the genetic value of node x is x). The genetic difference between two genetic values is defined as the bitwise-XOR of their values. You are given the integer array parents, where parents[i] is the parent for node i. If node x is the root of the tree, then parents[x] == -1.\nYou are also given the array queries where queries[i] = [nodei, vali]. For each query i, find the maximum genetic difference between vali and pi, where pi is the genetic value of any node that is on the path between nodei and the root (including nodei and the root). More formally, you want to maximize vali XOR pi.\nReturn an array ans where ans[i] is the answer to the ith query.\n \nExample 1:\n\n\nInput: parents = [-1,0,1,1], queries = [[0,2],[3,2],[2,5]]\nOutput: [2,3,7]\nExplanation: The queries are processed as follows:\n- [0,2]: The node with the maximum genetic difference is 0, with a difference of 2 XOR 0 = 2.\n- [3,2]: The node with the maximum genetic difference is 1, with a difference of 2 XOR 1 = 3.\n- [2,5]: The node with the maximum genetic difference is 2, with a difference of 5 XOR 2 = 7.\n\nExample 2:\n\n\nInput: parents = [3,7,-1,2,0,7,0,2], queries = [[4,6],[1,15],[0,5]]\nOutput: [6,14,7]\nExplanation: The queries are processed as follows:\n- [4,6]: The node with the maximum genetic difference is 0, with a difference of 6 XOR 0 = 6.\n- [1,15]: The node with the maximum genetic difference is 1, with a difference of 15 XOR 1 = 14.\n- [0,5]: The node with the maximum genetic difference is 2, with a difference of 5 XOR 2 = 7.\n\n \nConstraints:\n\n2 <= parents.length <= 105\n0 <= parents[i] <= parents.length - 1 for every node i that is not the root.\nparents[root] == -1\n1 <= queries.length <= 3 * 104\n0 <= nodei <= parents.length - 1\n0 <= vali <= 2 * 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(parents = [-1, 0, 0, 1, 1],queries = [[0, 3], [2, 1], [3, 4], [4, 5]]) == [3, 3, 7, 5]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3],queries = [[4, 5], [7, 10], [2, 15]]) == [5, 13, 15]\n assert candidate(parents = [3, 7, -1, 2, 0, 7, 0, 2],queries = [[4, 6], [1, 15], [0, 5]]) == [6, 14, 7]\n assert candidate(parents = [0, 0, 0, 1, 1, 2, 2, 3, 3],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70]]) == [10, 21, 30, 43, 54, 62, 70]\n assert candidate(parents = [-1, 0, 0, 1, 1],queries = [[2, 3], [4, 4], [3, 5]]) == [3, 5, 6]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7],queries = [[8, 1], [7, 2], [6, 3], [5, 4], [4, 5], [3, 6], [2, 7], [1, 8], [0, 9]]) == [9, 7, 7, 7, 7, 7, 7, 9, 9]\n assert candidate(parents = [-1, 0, 1, 1, 3, 3],queries = [[0, 10], [5, 15], [3, 20]]) == [10, 15, 23]\n assert candidate(parents = [-1, 0, 0, 1, 1],queries = [[0, 3], [1, 2], [2, 1], [3, 4], [4, 5]]) == [3, 3, 3, 7, 5]\n assert candidate(parents = [-1, 0, 1, 1],queries = [[0, 2], [3, 2], [2, 5]]) == [2, 3, 7]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == [1, 3, 3, 7, 7, 7, 7]\n assert candidate(parents = [-1, 0, 0, 1],queries = [[0, 3], [2, 5], [3, 4]]) == [3, 7, 7]\n assert candidate(parents = [-1, 0, 1, 2, 3],queries = [[4, 1], [1, 2], [2, 3], [3, 4]]) == [5, 3, 3, 7]\n assert candidate(parents = [3, 3, -1, 0, 0],queries = [[4, 100000], [3, 100001], [2, 100002], [1, 100003], [0, 100004]]) == [0, 0, 100000, 0, 0]\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9],queries = [[0, 25], [1, 50], [2, 75], [3, 100], [4, 125], [5, 150], [6, 175], [7, 200], [8, 225], [9, 250], [10, 275], [11, 300], [12, 325], [13, 350], [14, 375], [15, 400], [16, 425], [17, 450], [18, 475], [19, 500], [20, 525], [21, 550], [22, 575], [23, 600], [24, 625], [25, 650], [26, 675], [27, 700]]) == [25, 51, 75, 103, 125, 151, 175, 207, 233, 251, 281, 301, 329, 351, 377, 415, 441, 467, 477, 502, 537, 563, 575, 603, 633, 659, 697, 703]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39]]) == [1, 3, 3, 7, 5, 6, 7, 15, 10, 14, 15, 14, 15, 14, 15, 31, 22, 26, 27, 29, 28, 28, 29, 29, 28, 31, 30, 30, 31, 30, 31, 63, 46, 50, 51, 53, 52, 52, 53]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100], [10, 110], [11, 120], [12, 130], [13, 140], [14, 150], [15, 160], [16, 170], [17, 180], [18, 190], [19, 200], [20, 210], [21, 220], [22, 230], [23, 240], [24, 250], [25, 260], [26, 270], [27, 280], [28, 290], [29, 300]]) == [10, 21, 30, 43, 54, 61, 71, 87, 90, 109, 110, 123, 142, 141, 152, 175, 186, 181, 191, 219, 212, 221, 240, 247, 253, 285, 276, 282, 318, 305]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19],queries = [[0, 100000], [1, 50000], [2, 25000], [3, 12500], [4, 6250], [5, 3125], [6, 1562], [7, 781], [8, 390], [9, 195], [10, 97], [11, 48], [12, 24], [13, 12], [14, 6], [15, 3], [16, 1], [17, 0], [18, 0], [19, 0], [0, 100000]]) == [100000, 50001, 25002, 12503, 6254, 3127, 1564, 782, 398, 202, 107, 59, 29, 14, 8, 12, 17, 17, 18, 19, 100000]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49],queries = [[0, 10000], [1, 20000], [2, 30000], [3, 40000], [4, 50000], [5, 60000], [6, 70000], [7, 80000], [8, 90000], [9, 100000], [10, 110000], [11, 120000], [12, 130000], [13, 140000], [14, 150000], [15, 160000], [16, 170000], [17, 180000], [18, 190000], [19, 200000], [20, 210000], [21, 220000], [22, 230000], [23, 240000], [24, 250000], [25, 260000], [26, 270000], [27, 280000], [28, 290000], [29, 300000], [30, 310000], [31, 320000], [32, 330000], [33, 340000], [34, 350000], [35, 360000], [36, 370000], [37, 380000], [38, 390000], [39, 400000], [40, 410000], [41, 420000], [42, 430000], [43, 440000], [44, 450000], [45, 460000], [46, 470000], [47, 480000], [48, 490000], [49, 500000]]) == [10000, 20001, 30002, 40003, 50004, 60005, 70006, 80007, 90008, 100009, 110010, 120011, 130012, 140013, 150014, 160015, 170015, 180017, 190015, 200019, 210015, 220021, 230015, 240023, 250015, 260025, 7871, 17883, 27871, 37885, 47871, 57887, 67888, 77887, 87871, 97891, 107892, 117887, 127871, 137895, 147896, 157887, 167871, 177899, 187900, 197887, 207871, 217903, 227903, 237887]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24],queries = [[0, 10101], [1, 10102], [2, 10103], [3, 10104], [4, 10105], [5, 10106], [6, 10107], [7, 10108], [8, 10109], [9, 10110], [10, 10111], [11, 10112], [12, 10113], [13, 10114], [14, 10115], [15, 10116], [16, 10117], [17, 10118], [18, 10119], [19, 10120], [20, 10121], [21, 10122], [22, 10123], [23, 10124], [24, 10125], [25, 10126], [26, 10127], [27, 10128], [28, 10129], [29, 10130], [30, 10131], [31, 10132], [32, 10133], [33, 10134], [34, 10135], [35, 10136], [36, 10137], [37, 10138], [38, 10139], [39, 10140]]) == [10101, 10103, 10103, 10107, 10109, 10111, 10109, 10111, 10110, 10111, 10111, 10123, 10125, 10127, 10125, 10123, 10133, 10135, 10133, 10139, 10141, 10143, 10141, 10139, 10133, 10135, 10133, 10141, 10140, 10140, 10141, 10139, 10165, 10167, 10165, 10171, 10173, 10175, 10173, 10171]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39],queries = [[39, 1], [38, 2], [37, 3], [36, 4], [35, 5], [34, 6], [33, 7], [32, 8], [31, 9], [30, 10], [29, 11], [28, 12], [27, 13], [26, 14], [25, 15], [24, 16], [23, 17], [22, 18], [21, 19], [20, 20], [19, 21], [18, 22], [17, 23], [16, 24], [15, 25], [14, 26], [13, 27], [12, 28], [11, 29], [10, 30], [9, 31], [8, 32], [7, 33], [6, 34], [5, 35], [4, 36], [3, 37], [2, 38], [1, 39], [0, 40]]) == [38, 36, 38, 32, 38, 36, 38, 40, 22, 20, 22, 16, 22, 20, 22, 27, 26, 24, 25, 29, 28, 30, 31, 31, 30, 28, 29, 30, 31, 31, 31, 40, 38, 36, 38, 37, 38, 38, 39, 40]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],queries = [[0, 1], [1, 3], [2, 7], [3, 15], [4, 31], [5, 63], [6, 127], [7, 255], [8, 511], [9, 1023], [10, 2047], [11, 4095], [12, 8191], [13, 16383], [14, 32767], [15, 65535]]) == [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]\n assert candidate(parents = [-1, 0, 0, 1, 1, 3, 3, 4, 4, 5, 5],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100]]) == [100, 201, 302, 403, 501, 605, 703, 807, 908, 1005, 1103]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29],queries = [[0, 5000], [1, 5001], [2, 5002], [3, 5003], [4, 5004], [5, 5005], [6, 5006], [7, 5007], [8, 5008], [9, 5009], [10, 5010], [11, 5011], [12, 5012], [13, 5013], [14, 5014], [15, 5015], [16, 5016], [17, 5017], [18, 5018], [19, 5019], [20, 5020], [21, 5021], [22, 5022], [23, 5023], [24, 5024], [25, 5025], [26, 5026], [27, 5027], [28, 5028], [29, 5029], [30, 5030], [31, 5031], [32, 5032], [33, 5033], [34, 5034], [35, 5035], [36, 5036], [37, 5037], [38, 5038], [39, 5039]]) == [5000, 5001, 5002, 5003, 5005, 5007, 5006, 5007, 5016, 5016, 5016, 5016, 5016, 5016, 5016, 5016, 5023, 5018, 5019, 5023, 5021, 5021, 5023, 5023, 5048, 5048, 5048, 5048, 5048, 5048, 5048, 5048, 5039, 5049, 5050, 5050, 5053, 5055, 5052, 5052]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],queries = [[0, 1000], [1, 2000], [2, 3000], [3, 4000], [4, 5000], [5, 6000], [6, 7000], [7, 8000], [8, 9000], [9, 10000], [10, 11000], [11, 12000], [12, 13000], [13, 14000], [14, 15000], [15, 16000], [16, 17000], [17, 18000], [18, 19000], [19, 20000], [20, 21000], [21, 22000], [22, 23000], [23, 24000], [24, 25000], [25, 26000], [26, 27000], [27, 28000], [28, 29000], [29, 30000], [30, 31000], [31, 32000]]) == [1000, 2001, 3002, 4003, 5004, 6005, 7006, 8007, 9003, 10009, 11004, 12011, 13005, 14013, 15006, 16015, 17016, 18008, 19003, 20019, 21020, 22010, 23004, 24023, 25008, 26012, 27005, 28027, 29012, 30014, 31006, 32031]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4],queries = [[0, 123], [1, 456], [2, 789], [3, 101], [4, 202], [5, 303], [6, 404], [7, 505], [8, 606], [9, 707], [10, 808], [11, 909]]) == [123, 457, 791, 102, 206, 303, 406, 510, 606, 714, 812, 909]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800]]) == [100, 201, 302, 403, 501, 605, 702, 807, 908, 1003, 1101, 1211, 1304, 1405, 1502, 1615, 1716, 1817]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],queries = [[0, 500], [1, 1000], [2, 1500], [3, 2000], [4, 2500], [5, 3000], [6, 3500], [7, 4000], [8, 4500], [9, 5000], [10, 5500], [11, 6000], [12, 6500], [13, 7000], [14, 7500], [15, 8000], [16, 8500], [17, 9000], [18, 9500], [19, 10000], [20, 10500], [21, 11000], [22, 11500], [23, 12000], [24, 12500], [25, 13000], [26, 13500], [27, 14000], [28, 14500], [29, 15000]]) == [500, 1001, 1502, 2003, 2501, 3005, 3502, 4007, 4508, 5004, 5501, 6011, 6504, 7006, 7502, 8015, 8503, 9017, 9503, 10009, 10512, 11004, 11514, 12023, 12511, 13009, 13502, 14013, 14520, 15006]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15],queries = [[0, 30], [1, 60], [2, 90], [3, 120], [4, 150], [5, 180], [6, 210], [7, 240], [8, 270], [9, 300], [10, 330], [11, 360], [12, 390], [13, 420], [14, 450], [15, 480], [16, 510], [17, 540], [18, 570], [19, 600], [20, 630], [21, 660], [22, 690], [23, 720], [24, 750], [25, 780], [26, 810], [27, 840], [28, 870], [29, 900], [30, 930], [31, 960], [32, 990], [33, 1020], [34, 1050], [35, 1080], [36, 1110], [37, 1140], [38, 1170], [39, 1200], [40, 1230], [41, 1260], [42, 1290], [43, 1320], [44, 1350], [45, 1380], [46, 1410], [47, 1440], [48, 1470], [49, 1500]]) == [30, 61, 90, 123, 151, 181, 212, 247, 270, 302, 330, 363, 394, 425, 460, 495, 511, 541, 575, 606, 631, 661, 693, 727, 758, 789, 816, 851, 890, 921, 956, 991, 1022, 1023, 1080, 1083, 1138, 1144, 1204, 1212, 1254, 1261, 1312, 1324, 1386, 1386, 1452, 1455, 1471, 0]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800], [18, 1900]]) == [100, 201, 302, 403, 503, 605, 703, 807, 908, 1007, 1103, 1211, 1311, 1407, 1503, 1615, 1716, 1817, 1918]\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == [1, 3, 3, 7, 5, 7, 7, 15, 11, 11, 11, 15, 13, 15, 15, 31, 20, 23, 21, 22]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59],queries = [[0, 100000], [1, 200000], [2, 300000], [3, 400000], [4, 500000], [5, 600000], [6, 700000], [7, 800000], [8, 900000], [9, 1000000], [10, 1100000], [11, 1200000], [12, 1300000], [13, 1400000], [14, 1500000], [15, 1600000], [16, 1700000], [17, 1800000], [18, 1900000], [19, 2000000], [20, 2100000], [21, 2200000], [22, 2300000], [23, 2400000], [24, 2500000], [25, 2600000], [26, 2700000], [27, 2800000], [28, 2900000], [29, 3000000], [30, 3100000], [31, 3200000], [32, 3300000], [33, 3400000], [34, 3500000], [35, 3600000], [36, 3700000], [37, 3800000], [38, 3900000], [39, 4000000], [40, 4100000], [41, 4200000], [42, 4300000], [43, 4400000], [44, 4500000], [45, 4600000], [46, 4700000], [47, 4800000], [48, 4900000], [49, 5000000], [50, 5100000], [51, 5200000], [52, 5300000], [53, 5400000], [54, 5500000], [55, 5600000], [56, 5700000], [57, 5800000], [58, 5900000], [59, 6000000]]) == [100000, 200001, 37858, 137859, 237860, 75717, 175718, 13575, 113576, 213577, 51434, 151435, 251436, 89293, 189294, 27151, 127152, 227153, 65010, 165011, 2868, 102869, 202870, 40727, 140728, 240729, 78586, 178587, 16444, 116445, 216446, 54303, 154303, 254305, 92159, 192163, 30015, 130021, 230015, 67879, 167871, 5737, 105727, 205739, 43583, 143597, 243583, 81455, 181439, 19313, 119295, 219315, 57151, 157173, 257151, 95031, 195007, 32889, 132863, 232891]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800], [18, 1900], [19, 2000], [20, 2100], [21, 2200]]) == [100, 201, 302, 403, 501, 605, 702, 807, 908, 1003, 1101, 1211, 1304, 1405, 1502, 1615, 1716, 1817, 1918, 2008, 2109, 2203]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100], [10, 110], [11, 120], [12, 130], [13, 140], [14, 150], [15, 160], [16, 170], [17, 180], [18, 190], [19, 200], [20, 210], [21, 220], [22, 230], [23, 240], [24, 250], [25, 260], [26, 270], [27, 280], [28, 290], [29, 300]]) == [10, 21, 30, 43, 54, 62, 70, 87, 91, 109, 111, 125, 142, 142, 152, 175, 186, 188, 191, 219, 219, 221, 240, 251, 255, 285, 276, 286, 318, 305]\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800], [18, 1900], [19, 2000], [20, 2100], [21, 2200], [22, 2300], [23, 2400], [24, 2500], [25, 2600], [26, 2700], [27, 2800], [28, 2900], [29, 3000], [30, 3100], [31, 3200], [32, 3300], [33, 3400], [34, 3500], [35, 3600], [36, 3700], [37, 3800], [38, 3900], [39, 4000]]) == [100, 201, 302, 403, 500, 605, 701, 807, 908, 1002, 1102, 1211, 1304, 1403, 1503, 1615, 1716, 1817, 1918, 2004, 2100, 2205, 2301, 2423, 2524, 2609, 2710, 2806, 2901, 3007, 3101, 3231, 3301, 3433, 3501, 3635, 3708, 3837, 3902, 4009]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600]]) == [100, 201, 302, 403, 502, 605, 703, 807, 908, 1004, 1102, 1211, 1304, 1406, 1503, 1615]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],queries = [[0, 101], [1, 102], [2, 103], [3, 104], [4, 105], [5, 106], [6, 107], [7, 108], [8, 109], [9, 110], [10, 111], [11, 112], [12, 113], [13, 114], [14, 115], [15, 116], [16, 117], [17, 118], [18, 119], [19, 120]]) == [101, 103, 103, 107, 109, 111, 109, 111, 111, 111, 111, 123, 125, 127, 125, 123, 125, 126, 126, 124]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29],queries = [[0, 1000], [1, 2000], [2, 3000], [3, 4000], [4, 5000], [5, 6000], [6, 7000], [7, 8000], [8, 9000], [9, 10000], [10, 11000], [11, 12000], [12, 13000], [13, 14000], [14, 15000], [15, 16000], [16, 17000], [17, 18000], [18, 19000], [19, 20000], [20, 21000], [21, 22000], [22, 23000], [23, 24000], [24, 25000], [25, 26000], [26, 27000], [27, 28000], [28, 29000], [29, 30000], [30, 31000], [31, 32000], [32, 33000], [33, 34000], [34, 35000], [35, 36000], [36, 37000], [37, 38000], [38, 39000], [39, 40000], [40, 41000], [41, 42000], [42, 43000], [43, 44000], [44, 45000], [45, 46000], [46, 47000], [47, 48000], [48, 49000], [49, 50000], [50, 51000], [51, 52000], [52, 53000], [53, 54000], [54, 55000], [55, 56000], [56, 57000], [57, 58000], [58, 59000], [59, 60000]]) == [1000, 2001, 3002, 4003, 5004, 6005, 7006, 8007, 9002, 10009, 11003, 12011, 13003, 14013, 15004, 16015, 17016, 18005, 19005, 20019, 21020, 22006, 23007, 24023, 25008, 26008, 27002, 28027, 29012, 30009, 31002, 32031, 33003, 34033, 35003, 36011, 37036, 38012, 39038, 40039, 41004, 42041, 43004, 44014, 45028, 46014, 47030, 48047, 49004, 50017, 51005, 52016, 53052, 54005, 55022, 56055, 57018, 58025, 59006, 60019]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 1024], [1, 512], [2, 256], [3, 128], [4, 64], [5, 32], [6, 16], [7, 8], [8, 4], [9, 2], [10, 1], [11, 513], [12, 257], [13, 129], [14, 65], [15, 33]]) == [1024, 513, 258, 131, 68, 37, 22, 15, 12, 11, 11, 523, 269, 141, 79, 47]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49],queries = [[0, 3000], [1, 4000], [2, 5000], [3, 6000], [4, 7000], [5, 8000], [6, 9000], [7, 10000], [8, 11000], [9, 12000], [10, 13000], [11, 14000], [12, 15000], [13, 16000], [14, 17000], [15, 18000], [16, 19000], [17, 20000], [18, 21000], [19, 22000], [20, 23000], [21, 24000], [22, 25000], [23, 26000], [24, 27000], [25, 28000], [26, 29000], [27, 30000], [28, 31000], [29, 32000], [30, 33000], [31, 34000], [32, 35000], [33, 36000], [34, 37000], [35, 38000], [36, 39000], [37, 40000], [38, 41000], [39, 42000], [40, 43000], [41, 44000], [42, 45000], [43, 46000], [44, 47000], [45, 48000], [46, 49000], [47, 50000], [48, 51000], [49, 52000], [50, 53000], [51, 54000], [52, 55000], [53, 56000], [54, 57000], [55, 58000], [56, 59000], [57, 60000], [58, 61000], [59, 62000], [60, 63000], [61, 64000], [62, 65000], [63, 66000], [64, 67000], [65, 68000], [66, 69000], [67, 70000], [68, 71000], [69, 72000], [70, 73000], [71, 74000], [72, 75000], [73, 76000], [74, 77000], [75, 78000], [76, 79000], [77, 80000], [78, 81000], [79, 82000], [80, 83000], [81, 84000], [82, 85000], [83, 86000], [84, 87000], [85, 88000], [86, 89000], [87, 90000], [88, 91000], [89, 92000], [90, 93000], [91, 94000], [92, 95000], [93, 96000], [94, 97000], [95, 98000], [96, 99000], [97, 100000], [98, 101000], [99, 102000]]) == [3000, 4001, 5002, 6003, 7004, 8005, 9006, 10007, 11003, 12009, 13004, 14011, 15005, 16013, 17006, 18015, 19007, 20017, 21018, 22009, 23004, 24021, 25022, 26011, 27005, 28025, 29010, 30013, 31006, 32029, 33014, 34015, 35007, 36016, 37034, 38008, 39036, 40037, 41018, 42039, 43004, 44020, 45026, 46010, 47028, 48045, 49022, 50047, 51005, 52024, 53050, 54012, 55020, 56053, 57010, 58023, 59006, 60028, 61042, 62014, 63012, 64061, 65014, 66031, 67064, 68065, 69066, 70007, 71033, 72034, 73070, 74071, 75003, 76017, 77036, 78075, 79060, 80077, 81018, 82039, 83048, 84081, 85082, 86009, 87025, 88042, 89086, 90055, 91004, 92021, 93028, 94059, 95044, 96093, 97022, 98047, 99032, 100033, 101098, 102011]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],queries = [[0, 255], [1, 511], [2, 1023], [3, 2047], [4, 4095], [5, 8191], [6, 16383], [7, 32767], [8, 65535], [9, 131071], [10, 262143], [11, 524287], [12, 1048575], [13, 2097151], [14, 4194303], [15, 8388607], [16, 16777215], [17, 33554431], [18, 67108863], [19, 134217727], [20, 268435455], [21, 536870911], [22, 1073741823], [23, 2147483647], [24, 4294967295], [25, 8589934591], [26, 17179869183], [27, 34359738367], [28, 68719476735], [29, 137438953471]]) == [255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800], [18, 1900], [19, 2000]]) == [100, 201, 302, 403, 501, 605, 702, 807, 908, 1004, 1101, 1211, 1304, 1406, 1502, 1615, 1716, 1817, 1918, 2009]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49],queries = [[0, 2000], [1, 3000], [2, 4000], [3, 5000], [4, 6000], [5, 7000], [6, 8000], [7, 9000], [8, 10000], [9, 11000], [10, 12000], [11, 13000], [12, 14000], [13, 15000], [14, 16000], [15, 17000], [16, 18000], [17, 19000], [18, 20000], [19, 21000], [20, 22000], [21, 23000], [22, 24000], [23, 25000], [24, 26000], [25, 27000], [26, 28000], [27, 29000], [28, 30000], [29, 31000], [30, 32000], [31, 33000], [32, 34000], [33, 35000], [34, 36000], [35, 37000], [36, 38000], [37, 39000], [38, 40000], [39, 41000], [40, 42000], [41, 43000], [42, 44000], [43, 45000], [44, 46000], [45, 47000], [46, 48000], [47, 49000], [48, 50000], [49, 51000]]) == [2000, 3001, 4002, 5003, 6004, 7005, 8006, 9007, 10008, 11007, 12010, 13007, 14012, 15007, 16014, 17007, 18015, 19007, 20018, 21019, 22015, 23007, 24022, 25023, 26015, 27007, 28026, 29023, 30015, 31007, 32030, 33023, 34032, 35007, 36031, 37035, 38015, 39037, 40038, 41023, 42040, 43007, 44031, 45039, 46015, 47039, 48046, 49023, 50047, 51007]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],queries = [[0, 255], [1, 512], [2, 1024], [3, 2048], [4, 4096], [5, 8192], [6, 16384], [7, 32768], [8, 65536], [9, 131072], [10, 262144], [11, 524288], [12, 1048576], [13, 2097152], [14, 4194304], [15, 8388608], [16, 16777216], [17, 33554432], [18, 67108864], [19, 134217728]]) == [255, 513, 1026, 2051, 4100, 8197, 16390, 32775, 65544, 131081, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30],queries = [[0, 50], [1, 100], [2, 150], [3, 200], [4, 250], [5, 300], [6, 350], [7, 400], [8, 450], [9, 500], [10, 550], [11, 600], [12, 650], [13, 700], [14, 750], [15, 800], [16, 850], [17, 900], [18, 950], [19, 1000], [20, 1050], [21, 1100], [22, 1150], [23, 1200], [24, 1250], [25, 1300], [26, 1350], [27, 1400], [28, 1450], [29, 1500], [30, 1550], [31, 1600], [32, 1650], [33, 1700], [34, 1750], [35, 1800], [36, 1850], [37, 1900], [38, 1950], [39, 2000], [40, 2050], [41, 2100], [42, 2150], [43, 2200], [44, 2250], [45, 2300], [46, 2350], [47, 2400], [48, 2450], [49, 2500]]) == [50, 101, 150, 203, 254, 302, 350, 407, 458, 509, 556, 605, 655, 702, 750, 815, 853, 917, 958, 1019, 1054, 1113, 1151, 1211, 1274, 1304, 1372, 1406, 1462, 1502, 1552, 1631, 1661, 1716, 1780, 1835, 1851, 1918, 1976, 2039, 2090, 2109, 2162, 2227, 2278, 2301, 2360, 2423, 2466, 2549]\n assert candidate(parents = [-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50], [50, 51]]) == [1, 3, 3, 7, 5, 6, 7, 15, 9, 11, 11, 14, 15, 14, 15, 31, 18, 18, 19, 23, 22, 22, 23, 28, 29, 30, 30, 28, 29, 30, 31, 63, 39, 36, 37, 37, 37, 39, 39, 47, 46, 43, 43, 45, 45, 47, 47, 57, 56, 59, 58]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],queries = [[0, 1000], [1, 2000], [2, 3000], [3, 4000], [4, 5000], [5, 6000], [6, 7000], [7, 8000], [8, 9000], [9, 10000], [10, 11000], [11, 12000], [12, 13000], [13, 14000], [14, 15000]]) == [1000, 2001, 3002, 4003, 5004, 6005, 7006, 8007, 9007, 10009, 11007, 12011, 13007, 14013, 15007]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99],queries = [[0, 3000], [1, 4000], [2, 5000], [3, 6000], [4, 7000], [5, 8000], [6, 9000], [7, 10000], [8, 11000], [9, 12000], [10, 13000], [11, 14000], [12, 15000], [13, 16000], [14, 17000], [15, 18000], [16, 19000], [17, 20000], [18, 21000], [19, 22000], [20, 23000], [21, 24000], [22, 25000], [23, 26000], [24, 27000], [25, 28000], [26, 29000], [27, 30000], [28, 31000], [29, 32000], [30, 33000], [31, 34000], [32, 35000], [33, 36000], [34, 37000], [35, 38000], [36, 39000], [37, 40000], [38, 41000], [39, 42000], [40, 43000], [41, 44000], [42, 45000], [43, 46000], [44, 47000], [45, 48000], [46, 49000], [47, 50000], [48, 51000], [49, 52000], [50, 53000], [51, 54000], [52, 55000], [53, 56000], [54, 57000], [55, 58000], [56, 59000], [57, 60000], [58, 61000], [59, 62000], [60, 63000], [61, 64000], [62, 65000], [63, 66000], [64, 67000], [65, 68000], [66, 69000], [67, 70000], [68, 71000], [69, 72000], [70, 73000], [71, 74000], [72, 75000], [73, 76000], [74, 77000], [75, 78000], [76, 79000], [77, 80000], [78, 81000], [79, 82000], [80, 83000], [81, 84000], [82, 85000], [83, 86000], [84, 87000], [85, 88000], [86, 89000], [87, 90000], [88, 91000], [89, 92000], [90, 93000], [91, 94000], [92, 95000], [93, 96000], [94, 97000], [95, 98000], [96, 99000], [97, 100000], [98, 101000], [99, 102000]]) == [3000, 4001, 5002, 6003, 7004, 8005, 9006, 10007, 11007, 12009, 13007, 14011, 15007, 16013, 17007, 18015, 19007, 20017, 21018, 22015, 23007, 24021, 25022, 26015, 27007, 28025, 29023, 30015, 31007, 32029, 33023, 34015, 35007, 36031, 37034, 38015, 39036, 40037, 41023, 42039, 43007, 44031, 45039, 46015, 47039, 48045, 49023, 50047, 51007, 52031, 53050, 54015, 55039, 56053, 57023, 58047, 59007, 60031, 61055, 62015, 63039, 64061, 65023, 66047, 67064, 68065, 69066, 70015, 71039, 72063, 73070, 74071, 75007, 76031, 77055, 78075, 79071, 80077, 81023, 82047, 83071, 84081, 85082, 86015, 87039, 88063, 89086, 90079, 91007, 92031, 93055, 94079, 95071, 96093, 97023, 98047, 99071, 100095, 101098, 102015]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99],queries = [[0, 100000], [1, 100001], [2, 100002], [3, 100003], [4, 100004], [5, 100005], [6, 100006], [7, 100007], [8, 100008], [9, 100009], [10, 100010], [11, 100011], [12, 100012], [13, 100013], [14, 100014], [15, 100015], [16, 100016], [17, 100017], [18, 100018], [19, 100019], [20, 100020], [21, 100021], [22, 100022], [23, 100023], [24, 100024], [25, 100025], [26, 100026], [27, 100027], [28, 100028], [29, 100029], [30, 100030], [31, 100031], [32, 100032], [33, 100033], [34, 100034], [35, 100035], [36, 100036], [37, 100037], [38, 100038], [39, 100039], [40, 100040], [41, 100041], [42, 100042], [43, 100043], [44, 100044], [45, 100045], [46, 100046], [47, 100047], [48, 100048], [49, 100049], [50, 100050], [51, 100051], [52, 100052], [53, 100053], [54, 100054], [55, 100055], [56, 100056], [57, 100057], [58, 100058], [59, 100059], [60, 100060], [61, 100061], [62, 100062], [63, 100063], [64, 100064], [65, 100065], [66, 100066], [67, 100067], [68, 100068], [69, 100069], [70, 100070], [71, 100071], [72, 100072], [73, 100073], [74, 100074], [75, 100075], [76, 100076], [77, 100077], [78, 100078], [79, 100079], [80, 100080], [81, 100081], [82, 100082], [83, 100083], [84, 100084], [85, 100085], [86, 100086], [87, 100087], [88, 100088], [89, 100089], [90, 100090], [91, 100091], [92, 100092], [93, 100093], [94, 100094], [95, 100095], [96, 100096], [97, 100097], [98, 100098], [99, 100099]]) == [100000, 100001, 100003, 100003, 100007, 100007, 100007, 100007, 100015, 100015, 100015, 100015, 100015, 100015, 100015, 100015, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100064, 100065, 100067, 100067, 100071, 100071, 100071, 100071, 100079, 100079, 100079, 100079, 100079, 100079, 100079, 100079, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100192, 100193, 100195, 100195]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],queries = [[0, 100000], [1, 50000], [2, 25000], [3, 12500], [4, 6250], [5, 3125], [6, 1562], [7, 781], [8, 390], [9, 195], [10, 97], [11, 48], [12, 24], [13, 12], [14, 6], [15, 3], [16, 1], [17, 513], [18, 257], [19, 129], [20, 65], [21, 32], [22, 16], [23, 8], [24, 4], [25, 2], [26, 1], [27, 513], [28, 257], [29, 129], [30, 65]]) == [100000, 50001, 25002, 12503, 6254, 3127, 1567, 783, 398, 203, 107, 59, 31, 15, 15, 15, 17, 529, 275, 147, 85, 53, 31, 31, 28, 27, 27, 539, 285, 157, 95]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],queries = [[0, 2000], [1, 2001], [2, 2002], [3, 2003], [4, 2004], [5, 2005], [6, 2006], [7, 2007], [8, 2008], [9, 2009], [10, 2010], [11, 2011], [12, 2012], [13, 2013], [14, 2014], [15, 2015], [16, 2016], [17, 2017], [18, 2018], [19, 2019], [20, 2020], [21, 2021], [22, 2022], [23, 2023], [24, 2024], [25, 2025], [26, 2026], [27, 2027], [28, 2028], [29, 2029]]) == [2000, 2001, 2002, 2003, 2006, 2007, 2007, 2007, 2012, 2013, 2015, 2014, 2015, 2014, 2015, 2015, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],queries = [[0, 101], [1, 202], [2, 303], [3, 404], [4, 505], [5, 606], [6, 707], [7, 808], [8, 909], [9, 1010], [10, 1111], [11, 1212], [12, 1313], [13, 1414], [14, 1515], [15, 1616], [16, 1717], [17, 1818]]) == [101, 203, 303, 407, 509, 606, 709, 815, 911, 1019, 1117, 1214, 1325, 1419, 1516, 1631, 1725, 1822]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19],queries = [[19, 2], [18, 5], [17, 10], [16, 20], [15, 40], [14, 80], [13, 160], [12, 320], [11, 640], [10, 1280], [9, 2560], [8, 5120], [7, 10240], [6, 20480], [5, 40960], [4, 81920], [3, 163840], [2, 327680], [1, 655360], [0, 1310720]]) == [17, 23, 27, 23, 47, 94, 173, 332, 651, 1290, 2569, 5128, 10247, 20486, 40965, 81924, 163843, 65538, 131073, 0]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == [1, 3, 3, 7, 5, 7, 7, 15, 11, 10, 11, 15, 14, 15, 15, 31, 20, 23, 22, 21, 21, 23, 23, 31, 30, 26, 27, 30, 31, 30]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4],queries = [[0, 15], [1, 30], [2, 45], [3, 60], [4, 75], [5, 90], [6, 105], [7, 120], [8, 135], [9, 150]]) == [15, 31, 47, 63, 79, 95, 111, 127, 143, 159]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],queries = [[0, 10000], [1, 20000], [2, 30000], [3, 40000], [4, 50000], [5, 60000], [6, 70000], [7, 80000], [8, 90000], [9, 100000], [10, 110000], [11, 120000], [12, 130000], [13, 140000], [14, 150000], [15, 160000], [16, 170000], [17, 180000], [18, 190000], [19, 200000], [20, 210000], [21, 220000], [22, 230000], [23, 240000], [24, 250000], [25, 260000], [26, 270000], [27, 280000], [28, 290000], [29, 300000]]) == [10000, 20001, 30002, 40003, 50004, 60005, 70006, 80007, 90008, 100009, 110010, 120011, 130012, 140013, 150014, 160015, 170007, 180017, 190008, 200019, 210009, 220021, 230010, 240023, 250011, 260025, 7868, 17883, 27869, 37885]\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14],queries = [[0, 65535], [1, 65534], [2, 65533], [3, 65532], [4, 65531], [5, 65530], [6, 65529], [7, 65528], [8, 65527], [9, 65526], [10, 65525], [11, 65524], [12, 65523], [13, 65522], [14, 65521], [15, 65520], [16, 65519], [17, 65518], [18, 65517], [19, 65516], [20, 65515], [21, 65514], [22, 65513], [23, 65512], [24, 65511], [25, 65510], [26, 65509], [27, 65508], [28, 65507], [29, 65506], [30, 65505], [31, 65504], [32, 65503], [33, 65502], [34, 65501], [35, 65500], [36, 65499], [37, 65498], [38, 65497], [39, 65496], [40, 65495], [41, 65494], [42, 65493], [43, 65492], [44, 65491], [45, 65490], [46, 65489], [47, 65488], [48, 65487], [49, 65486]]) == [65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],queries = [[0, 65536], [1, 32768], [2, 16384], [3, 8192], [4, 4096], [5, 2048], [6, 1024], [7, 512], [8, 256], [9, 128], [10, 64], [11, 32], [12, 16], [13, 8], [14, 4], [15, 2], [14, 1], [13, 3], [12, 7], [11, 15], [10, 31], [9, 63], [8, 127], [7, 255], [6, 511], [5, 1023], [4, 2047], [3, 4095], [2, 8191], [1, 16383], [0, 32767]]) == [65536, 32769, 16386, 8195, 4100, 2053, 1030, 519, 264, 137, 74, 43, 28, 14, 10, 13, 15, 14, 11, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],queries = [[15, 65535], [14, 32767], [13, 16383], [12, 8191], [11, 4095], [10, 2047], [9, 1023], [8, 511], [7, 255], [6, 127], [5, 63], [4, 31], [3, 15], [2, 7], [1, 3], [0, 1]]) == [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]\n"}, "metadata": {"canonical_parameter_names": ["parents", "queries"], "leetcode_dataset_entry_point": "Solution().maxGeneticDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxGeneticDifference(self, parents: list[int], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "maxGeneticDifference", "parameters": [{"name": "parents", "type": "list[int]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1941, "task_id": "check-if-all-characters-have-equal-number-of-occurrences", "difficulty": "Easy", "problem_description": "Given a string s, return true if s is a good string, or false otherwise.\nA string s is good if all the characters that appear in s have the same number of occurrences (i.e., the same frequency).\n \nExample 1:\n\nInput: s = \"abacbc\"\nOutput: true\nExplanation: The characters that appear in s are 'a', 'b', and 'c'. All characters occur 2 times in s.\n\nExample 2:\n\nInput: s = \"aaabb\"\nOutput: false\nExplanation: The characters that appear in s are 'a' and 'b'.\n'a' occurs 3 times while 'b' occurs 2 times, which is not the same number of times.\n\n \nConstraints:\n\n1 <= s.length <= 1000\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbccc\") == False\n assert candidate(s = \"abacbc\") == True\n assert candidate(s = \"abcabcabc\") == True\n assert candidate(s = \"qqqq\") == True\n assert candidate(s = \"aabbcc\") == True\n assert candidate(s = \"zzzzzzzzzz\") == True\n assert candidate(s = \"aabbc\") == False\n assert candidate(s = \"a\") == True\n assert candidate(s = \"abc\") == True\n assert candidate(s = \"\") == False\n assert candidate(s = \"aabb\") == True\n assert candidate(s = \"aabbccddeeff\") == True\n assert candidate(s = \"abcdabcd\") == True\n assert candidate(s = \"zzz\") == True\n assert candidate(s = \"xyz\") == True\n assert candidate(s = \"aaabb\") == False\n assert candidate(s = \"hello\") == False\n assert candidate(s = \"thisisnotagoodstring\") == False\n assert candidate(s = \"aaaabbbbccccdddd\") == True\n assert candidate(s = \"almostgoodbutoneextrab\") == False\n assert candidate(s = \"mnopqrstuvwxyzz\") == False\n assert candidate(s = \"uniquecharactersabcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(s = \"qwertyuioplkjhgfdsazxcvbnm\") == True\n assert candidate(s = \"kjhgfdsazxcvbnmlpoiuytrewq\") == True\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == True\n assert candidate(s = \"llllkkkkjjjjiiiihhhhggggffffeeeeeeee\") == False\n assert candidate(s = \"repeatedcharsrepeatedcharsrepeatedchars\") == False\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\") == False\n assert candidate(s = \"samefrequencyforallcharacters\") == False\n assert candidate(s = \"lmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmno\") == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == False\n assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrsmnopqrs\") == True\n assert candidate(s = \"abcdefabcdefabcdef\") == True\n assert candidate(s = \"abacadaeafagahaibiciidieifigihiiijijikikililimimioinioipoipiqiririsititiuiujujukukululumiumiujujukvkvkwlwlxmxmylynzozp\") == False\n assert candidate(s = \"mnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzqqqq\") == False\n assert candidate(s = \"abracadabra\") == False\n assert candidate(s = \"mnopqrstuvwxymnopqrstuvwxymnopqrstuvwxymnopqrstuvwxyn\") == False\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == True\n assert candidate(s = \"qwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiop\") == True\n assert candidate(s = \"abcdefabcdef\") == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == True\n assert candidate(s = \"almostgoodbutoneextraa\") == False\n assert candidate(s = \"abcdefghijklmnopabcdefghijklmnopabcdefghijklmnopabcdefghijklmnopabcdefghijklmnopabcdefghijklmnop\") == True\n assert candidate(s = \"jjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzzaaaaaa\") == False\n assert candidate(s = \"zzzzzyyyyxxxwwvvuuttssrrqqlloommnnppekkaaiioouuyy\") == False\n assert candidate(s = \"racecar\") == False\n assert candidate(s = \"almostgoodbutoneextrac\") == False\n assert candidate(s = \"xyzxyzxyz\") == True\n assert candidate(s = \"qwerqwerqwer\") == True\n assert candidate(s = \"abababababababab\") == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\") == True\n assert candidate(s = \"ppppppqqqqqrrrrrssssstttttuuuuuvvvvvwwwwwooooo\") == False\n assert candidate(s = \"ababababc\") == False\n assert candidate(s = \"mmnnnmmmnnnmmmnnnmmmnnnmmmnnnmmmnnnmmmnnnmm\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == False\n assert candidate(s = \"pqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrs\") == True\n assert candidate(s = \"mmnnooppqqrrssttuuvvwwxxyyzzqqwweerrttyyuuiihhggffeeddccba\") == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxy\") == True\n assert candidate(s = \"ppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == True\n assert candidate(s = \"mnopmnopmnopmnopmnopmnopmnopmnop\") == True\n assert candidate(s = \"xyzzzzzyzx\") == False\n assert candidate(s = \"abacabadabacabad\") == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxzyabcdefghijklmnopqrstuvwxzy\") == True\n assert candidate(s = \"abcdefghijklmnop\") == True\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzz\") == False\n assert candidate(s = \"zzzyyyxxxwwwwvvvvuuuuuuuuutttttttsssssssrrrrrrqqqqpppooooonnnnmmmmllllkkkkjjjjiiiihhhhhgggggfffffeeeeeeeee\") == False\n assert candidate(s = \"mnopqrmpqrno\") == True\n assert candidate(s = \"qqwweerrttyyuuuiooppppllkkiijjhgffeeddccba\") == False\n assert candidate(s = \"qrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s = \"mississippi\") == False\n assert candidate(s = \"xyzzxyzzxyzzxyzz\") == False\n assert candidate(s = \"oneonetwoonetwothree\") == False\n assert candidate(s = \"zxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnm\") == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(s = \"xyzxyzxyzxyz\") == True\n assert candidate(s = \"zzzzyyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == False\n assert candidate(s = \"qqqqwweerrrrtttyyyy\") == False\n assert candidate(s = \"abcdabcdabcdabcd\") == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(s = \"almostgoodbutoneextrad\") == False\n assert candidate(s = \"almostgoodbutoneextrae\") == False\n assert candidate(s = \"programming\") == False\n assert candidate(s = \"equalfrequenciesequalfrequencies\") == False\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabc\") == False\n assert candidate(s = \"almostgoodbutoneextraf\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghij\") == False\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().areOccurrencesEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def areOccurrencesEqual(self, s: str) -> bool:", "container": "Solution", "callable": "areOccurrencesEqual", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1942, "task_id": "the-number-of-the-smallest-unoccupied-chair", "difficulty": "Medium", "problem_description": "There is a party where n friends numbered from 0 to n - 1 are attending. There is an infinite number of chairs in this party that are numbered from 0 to infinity. When a friend arrives at the party, they sit on the unoccupied chair with the smallest number.\n\nFor example, if chairs 0, 1, and 5 are occupied when a friend comes, they will sit on chair number 2.\n\nWhen a friend leaves the party, their chair becomes unoccupied at the moment they leave. If another friend arrives at that same moment, they can sit in that chair.\nYou are given a 0-indexed 2D integer array times where times[i] = [arrivali, leavingi], indicating the arrival and leaving times of the ith friend respectively, and an integer targetFriend. All arrival times are distinct.\nReturn the chair number that the friend numbered targetFriend will sit on.\n \nExample 1:\n\nInput: times = [[1,4],[2,3],[4,6]], targetFriend = 1\nOutput: 1\nExplanation: \n- Friend 0 arrives at time 1 and sits on chair 0.\n- Friend 1 arrives at time 2 and sits on chair 1.\n- Friend 1 leaves at time 3 and chair 1 becomes empty.\n- Friend 0 leaves at time 4 and chair 0 becomes empty.\n- Friend 2 arrives at time 4 and sits on chair 0.\nSince friend 1 sat on chair 1, we return 1.\n\nExample 2:\n\nInput: times = [[3,10],[1,5],[2,6]], targetFriend = 0\nOutput: 2\nExplanation: \n- Friend 1 arrives at time 1 and sits on chair 0.\n- Friend 2 arrives at time 2 and sits on chair 1.\n- Friend 0 arrives at time 3 and sits on chair 2.\n- Friend 1 leaves at time 5 and chair 0 becomes empty.\n- Friend 2 leaves at time 6 and chair 1 becomes empty.\n- Friend 0 leaves at time 10 and chair 2 becomes empty.\nSince friend 0 sat on chair 2, we return 2.\n\n \nConstraints:\n\nn == times.length\n2 <= n <= 104\ntimes[i].length == 2\n1 <= arrivali < leavingi <= 105\n0 <= targetFriend <= n - 1\nEach arrivali time is distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(times = [[5, 10], [1, 3], [2, 6], [7, 8]],targetFriend = 1) == 0\n assert candidate(times = [[5, 10], [1, 2], [3, 8]],targetFriend = 2) == 0\n assert candidate(times = [[2, 7], [7, 9], [1, 5]],targetFriend = 2) == 0\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5]],targetFriend = 3) == 0\n assert candidate(times = [[8, 12], [1, 6], [3, 5], [9, 10]],targetFriend = 2) == 1\n assert candidate(times = [[2, 5], [3, 7], [4, 9], [5, 10]],targetFriend = 2) == 2\n assert candidate(times = [[5, 15], [1, 20], [10, 25]],targetFriend = 2) == 2\n assert candidate(times = [[10, 20], [20, 30], [15, 25], [5, 15]],targetFriend = 2) == 0\n assert candidate(times = [[2, 5], [3, 9], [4, 7], [5, 8]],targetFriend = 2) == 2\n assert candidate(times = [[5, 10], [1, 3], [4, 8], [6, 9]],targetFriend = 3) == 2\n assert candidate(times = [[10, 20], [5, 10], [15, 25]],targetFriend = 1) == 0\n assert candidate(times = [[1, 4], [2, 3], [4, 6]],targetFriend = 1) == 1\n assert candidate(times = [[5, 10], [1, 3], [4, 6], [6, 7]],targetFriend = 1) == 0\n assert candidate(times = [[1, 3], [2, 5], [3, 6], [4, 7]],targetFriend = 2) == 0\n assert candidate(times = [[2, 5], [1, 3], [6, 7], [4, 8]],targetFriend = 1) == 0\n assert candidate(times = [[3, 10], [1, 5], [2, 6]],targetFriend = 0) == 2\n assert candidate(times = [[1, 2], [2, 5], [4, 7], [7, 9]],targetFriend = 0) == 0\n assert candidate(times = [[3, 4], [1, 5], [2, 6], [5, 7], [4, 8], [6, 9]],targetFriend = 3) == 0\n assert candidate(times = [[5, 8], [12, 15], [10, 14], [20, 25], [1, 4], [16, 18], [6, 9], [19, 22], [3, 7], [11, 13]],targetFriend = 8) == 1\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26]],targetFriend = 6) == 0\n assert candidate(times = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 110], [12, 120]],targetFriend = 11) == 10\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92]],targetFriend = 8) == 8\n assert candidate(times = [[1, 10], [2, 5], [3, 7], [8, 12], [6, 9], [11, 13]],targetFriend = 5) == 0\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86]],targetFriend = 7) == 7\n assert candidate(times = [[10, 20], [5, 15], [1, 10], [16, 30], [21, 40]],targetFriend = 3) == 1\n assert candidate(times = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14]],targetFriend = 2) == 2\n assert candidate(times = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]],targetFriend = 6) == 2\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],targetFriend = 8) == 0\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],targetFriend = 5) == 0\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28]],targetFriend = 7) == 0\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],targetFriend = 0) == 0\n assert candidate(times = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]],targetFriend = 9) == 0\n assert candidate(times = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],targetFriend = 9) == 0\n assert candidate(times = [[5, 10], [1, 6], [7, 12], [15, 20], [2, 8]],targetFriend = 4) == 1\n assert candidate(times = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],targetFriend = 3) == 3\n assert candidate(times = [[3, 20], [1, 5], [7, 15], [10, 18], [2, 8], [13, 17]],targetFriend = 3) == 1\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],targetFriend = 4) == 0\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30], [31, 32], [33, 34], [35, 36], [37, 38], [39, 40], [41, 42], [43, 44], [45, 46], [47, 48], [49, 50]],targetFriend = 22) == 0\n assert candidate(times = [[1, 5], [2, 3], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]],targetFriend = 5) == 1\n assert candidate(times = [[10, 20], [1, 6], [3, 11], [7, 14], [15, 25]],targetFriend = 4) == 0\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86], [16, 85], [17, 84], [18, 83], [19, 82], [20, 81]],targetFriend = 15) == 15\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86]],targetFriend = 10) == 10\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],targetFriend = 6) == 0\n assert candidate(times = [[1, 50], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44], [8, 43], [9, 42], [10, 41]],targetFriend = 9) == 9\n assert candidate(times = [[1, 10], [2, 5], [3, 4], [6, 9], [7, 11]],targetFriend = 4) == 2\n assert candidate(times = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100]],targetFriend = 9) == 0\n assert candidate(times = [[1, 10], [2, 12], [3, 14], [4, 16], [5, 18], [6, 20]],targetFriend = 2) == 2\n assert candidate(times = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]],targetFriend = 9) == 9\n assert candidate(times = [[3, 8], [1, 5], [2, 6], [7, 10], [4, 9], [6, 12], [8, 15]],targetFriend = 2) == 1\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30], [31, 32], [33, 34], [35, 36], [37, 38], [39, 40]],targetFriend = 19) == 0\n assert candidate(times = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]],targetFriend = 4) == 0\n assert candidate(times = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14]],targetFriend = 10) == 0\n assert candidate(times = [[10, 20], [5, 15], [1, 8], [21, 25], [11, 18]],targetFriend = 2) == 0\n assert candidate(times = [[2, 4], [6, 8], [10, 12], [1, 3], [5, 7], [9, 11]],targetFriend = 0) == 1\n assert candidate(times = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],targetFriend = 5) == 0\n assert candidate(times = [[1, 10], [2, 5], [6, 12], [3, 9], [7, 15]],targetFriend = 2) == 1\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95]],targetFriend = 5) == 5\n assert candidate(times = [[1, 5], [2, 3], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15]],targetFriend = 7) == 2\n assert candidate(times = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]],targetFriend = 5) == 2\n assert candidate(times = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40]],targetFriend = 5) == 0\n assert candidate(times = [[1, 30], [2, 25], [3, 20], [4, 15], [5, 10], [6, 28], [7, 24], [8, 22], [9, 29], [10, 18], [11, 21], [12, 27], [13, 23], [14, 26], [15, 19], [16, 17]],targetFriend = 4) == 4\n assert candidate(times = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995], [7, 9994], [8, 9993], [9, 9992], [10, 9991]],targetFriend = 9) == 9\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],targetFriend = 0) == 0\n assert candidate(times = [[10, 20], [30, 40], [20, 30], [5, 15], [45, 55], [50, 60]],targetFriend = 4) == 0\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],targetFriend = 9) == 9\n assert candidate(times = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12]],targetFriend = 9) == 1\n assert candidate(times = [[1, 500], [2, 499], [3, 498], [4, 497], [5, 496], [6, 495], [7, 494], [8, 493], [9, 492], [10, 491], [11, 490], [12, 489], [13, 488], [14, 487], [15, 486]],targetFriend = 13) == 13\n assert candidate(times = [[10, 20], [15, 25], [5, 15], [20, 30], [25, 35], [0, 10]],targetFriend = 2) == 1\n assert candidate(times = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80]],targetFriend = 3) == 0\n assert candidate(times = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110]],targetFriend = 4) == 0\n assert candidate(times = [[10, 30], [20, 40], [30, 50], [40, 60], [50, 70], [60, 80], [70, 90], [80, 100], [90, 110], [100, 120], [110, 130], [120, 140], [130, 150], [140, 160], [150, 170], [160, 180], [170, 190], [180, 200], [190, 210], [200, 220]],targetFriend = 9) == 1\n assert candidate(times = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50]],targetFriend = 0) == 0\n assert candidate(times = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40]],targetFriend = 3) == 0\n assert candidate(times = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]],targetFriend = 8) == 0\n assert candidate(times = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 10]],targetFriend = 10) == 0\n assert candidate(times = [[1, 100], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100]],targetFriend = 5) == 5\n assert candidate(times = [[1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21]],targetFriend = 5) == 5\n assert candidate(times = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],targetFriend = 6) == 6\n assert candidate(times = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995], [7, 9994]],targetFriend = 6) == 6\n assert candidate(times = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19]],targetFriend = 9) == 0\n assert candidate(times = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21]],targetFriend = 5) == 0\n assert candidate(times = [[1, 10], [11, 20], [2, 19], [12, 18], [3, 17]],targetFriend = 3) == 3\n assert candidate(times = [[1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12]],targetFriend = 4) == 4\n assert candidate(times = [[3, 8], [5, 10], [1, 4], [7, 12], [9, 15]],targetFriend = 3) == 2\n assert candidate(times = [[1, 10], [2, 12], [3, 14], [4, 16], [5, 18], [6, 20], [7, 22], [8, 24], [9, 26], [10, 28]],targetFriend = 9) == 0\n assert candidate(times = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]],targetFriend = 5) == 0\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],targetFriend = 5) == 0\n assert candidate(times = [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21]],targetFriend = 9) == 0\n assert candidate(times = [[1, 5], [1, 4], [1, 3], [1, 2], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7]],targetFriend = 8) == 0\n assert candidate(times = [[10, 25], [20, 30], [5, 15], [15, 20], [1, 10], [25, 35], [30, 40], [5, 10], [15, 20]],targetFriend = 5) == 0\n assert candidate(times = [[1, 10], [2, 5], [3, 6], [7, 12], [8, 9], [4, 11]],targetFriend = 2) == 2\n assert candidate(times = [[1, 100], [2, 50], [3, 30], [4, 20], [5, 10], [6, 5], [7, 3]],targetFriend = 0) == 0\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],targetFriend = 8) == 0\n assert candidate(times = [[1, 10], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]],targetFriend = 4) == 4\n assert candidate(times = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]],targetFriend = 7) == 3\n assert candidate(times = [[5, 10], [1, 6], [11, 16], [21, 26], [10, 15], [6, 11], [16, 21], [26, 31], [2, 7], [7, 12]],targetFriend = 8) == 1\n assert candidate(times = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [21, 40], [22, 39], [23, 38], [24, 37], [25, 36], [26, 35], [27, 34], [28, 33], [29, 32], [30, 31]],targetFriend = 15) == 5\n assert candidate(times = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60]],targetFriend = 5) == 0\n assert candidate(times = [[5, 10], [10, 20], [15, 25], [20, 30], [25, 35], [30, 40]],targetFriend = 3) == 0\n assert candidate(times = [[5, 10], [1, 2], [3, 4], [6, 7], [8, 9], [10, 11]],targetFriend = 1) == 0\n assert candidate(times = [[10, 20], [5, 15], [1, 11], [25, 35], [30, 40]],targetFriend = 4) == 1\n"}, "metadata": {"canonical_parameter_names": ["times", "targetFriend"], "leetcode_dataset_entry_point": "Solution().smallestChair", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def smallestChair(self, times: list[list[int]], targetFriend: int) -> int:", "container": "Solution", "callable": "smallestChair", "parameters": [{"name": "times", "type": "list[list[int]]"}, {"name": "targetFriend", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1943, "task_id": "describe-the-painting", "difficulty": "Medium", "problem_description": "There is a long and thin painting that can be represented by a number line. The painting was painted with multiple overlapping segments where each segment was painted with a unique color. You are given a 2D integer array segments, where segments[i] = [starti, endi, colori] represents the half-closed segment [starti, endi) with colori as the color.\nThe colors in the overlapping segments of the painting were mixed when it was painted. When two or more colors mix, they form a new color that can be represented as a set of mixed colors.\n\nFor example, if colors 2, 4, and 6 are mixed, then the resulting mixed color is {2,4,6}.\n\nFor the sake of simplicity, you should only output the sum of the elements in the set rather than the full set.\nYou want to describe the painting with the minimum number of non-overlapping half-closed segments of these mixed colors. These segments can be represented by the 2D array painting where painting[j] = [leftj, rightj, mixj] describes a half-closed segment [leftj, rightj) with the mixed color sum of mixj.\n\nFor example, the painting created with segments = [[1,4,5],[1,7,7]] can be described by painting = [[1,4,12],[4,7,7]] because:\n\n\t\n[1,4) is colored {5,7} (with a sum of 12) from both the first and second segments.\n[4,7) is colored {7} from only the second segment.\n\n\n\nReturn the 2D array painting describing the finished painting (excluding any parts that are not painted). You may return the segments in any order.\nA half-closed segment [a, b) is the section of the number line between points a and b including point a and not including point b.\n \nExample 1:\n\n\nInput: segments = [[1,4,5],[4,7,7],[1,7,9]]\nOutput: [[1,4,14],[4,7,16]]\nExplanation: The painting can be described as follows:\n- [1,4) is colored {5,9} (with a sum of 14) from the first and third segments.\n- [4,7) is colored {7,9} (with a sum of 16) from the second and third segments.\n\nExample 2:\n\n\nInput: segments = [[1,7,9],[6,8,15],[8,10,7]]\nOutput: [[1,6,9],[6,7,24],[7,8,15],[8,10,7]]\nExplanation: The painting can be described as follows:\n- [1,6) is colored 9 from the first segment.\n- [6,7) is colored {9,15} (with a sum of 24) from the first and second segments.\n- [7,8) is colored 15 from the second segment.\n- [8,10) is colored 7 from the third segment.\n\nExample 3:\n\n\nInput: segments = [[1,4,5],[1,4,7],[4,7,1],[4,7,11]]\nOutput: [[1,4,12],[4,7,12]]\nExplanation: The painting can be described as follows:\n- [1,4) is colored {5,7} (with a sum of 12) from the first and second segments.\n- [4,7) is colored {1,11} (with a sum of 12) from the third and fourth segments.\nNote that returning a single segment [1,7) is incorrect because the mixed color sets are different.\n\n \nConstraints:\n\n1 <= segments.length <= 2 * 104\nsegments[i].length == 3\n1 <= starti < endi <= 105\n1 <= colori <= 109\nEach colori is distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(segments = [[10, 20, 5], [15, 25, 3], [12, 18, 8]]) == [[10, 12, 5], [12, 15, 13], [15, 18, 16], [18, 20, 8], [20, 25, 3]]\n assert candidate(segments = [[1, 10, 100], [5, 15, 200], [12, 20, 300]]) == [[1, 5, 100], [5, 10, 300], [10, 12, 200], [12, 15, 500], [15, 20, 300]]\n assert candidate(segments = [[0, 1, 3], [2, 3, 4], [1, 2, 5]]) == [[0, 1, 3], [1, 2, 5], [2, 3, 4]]\n assert candidate(segments = [[2, 5, 10], [3, 8, 20], [5, 6, 30]]) == [[2, 3, 10], [3, 5, 30], [5, 6, 50], [6, 8, 20]]\n assert candidate(segments = [[2, 5, 10], [3, 8, 20], [6, 10, 30]]) == [[2, 3, 10], [3, 5, 30], [5, 6, 20], [6, 8, 50], [8, 10, 30]]\n assert candidate(segments = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]) == [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]\n assert candidate(segments = [[0, 2, 3], [2, 5, 4], [1, 3, 2]]) == [[0, 1, 3], [1, 2, 5], [2, 3, 6], [3, 5, 4]]\n assert candidate(segments = [[1, 4, 5], [1, 4, 7], [4, 7, 1], [4, 7, 11]]) == [[1, 4, 12], [4, 7, 12]]\n assert candidate(segments = [[5, 10, 1], [10, 15, 2], [15, 20, 3], [20, 25, 4]]) == [[5, 10, 1], [10, 15, 2], [15, 20, 3], [20, 25, 4]]\n assert candidate(segments = [[10, 20, 100], [15, 25, 200], [20, 30, 300]]) == [[10, 15, 100], [15, 20, 300], [20, 25, 500], [25, 30, 300]]\n assert candidate(segments = [[10, 20, 100], [20, 30, 200], [15, 25, 150]]) == [[10, 15, 100], [15, 20, 250], [20, 25, 350], [25, 30, 200]]\n assert candidate(segments = [[1, 3, 1], [3, 5, 2], [5, 7, 3], [7, 9, 4]]) == [[1, 3, 1], [3, 5, 2], [5, 7, 3], [7, 9, 4]]\n assert candidate(segments = [[1, 4, 5], [4, 7, 7], [1, 7, 9]]) == [[1, 4, 14], [4, 7, 16]]\n assert candidate(segments = [[1, 100000, 1000000000]]) == [[1, 100000, 1000000000]]\n assert candidate(segments = [[1, 7, 9], [6, 8, 15], [8, 10, 7]]) == [[1, 6, 9], [6, 7, 24], [7, 8, 15], [8, 10, 7]]\n assert candidate(segments = [[10, 15, 5], [12, 20, 15], [18, 25, 25]]) == [[10, 12, 5], [12, 15, 20], [15, 18, 15], [18, 20, 40], [20, 25, 25]]\n assert candidate(segments = [[1, 10, 5], [2, 9, 10], [3, 8, 15], [4, 7, 20]]) == [[1, 2, 5], [2, 3, 15], [3, 4, 30], [4, 7, 50], [7, 8, 30], [8, 9, 15], [9, 10, 5]]\n assert candidate(segments = [[1, 3, 1], [2, 5, 2], [3, 7, 3], [4, 8, 4], [5, 9, 5], [6, 10, 6]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 5], [4, 5, 9], [5, 6, 12], [6, 7, 18], [7, 8, 15], [8, 9, 11], [9, 10, 6]]\n assert candidate(segments = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5]]) == [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5]]\n assert candidate(segments = [[10, 20, 500], [15, 25, 700], [20, 30, 900], [5, 25, 300], [25, 35, 800]]) == [[5, 10, 300], [10, 15, 800], [15, 20, 1500], [20, 25, 1900], [25, 30, 1700], [30, 35, 800]]\n assert candidate(segments = [[10, 20, 1], [11, 19, 2], [12, 18, 3], [13, 17, 4], [14, 16, 5], [15, 15, 6]]) == [[10, 11, 1], [11, 12, 3], [12, 13, 6], [13, 14, 10], [14, 15, 15], [15, 16, 15], [16, 17, 10], [17, 18, 6], [18, 19, 3], [19, 20, 1]]\n assert candidate(segments = [[1000, 2000, 5000000], [1500, 2500, 10000000], [2000, 3000, 15000000], [1750, 2250, 12000000], [2250, 2750, 22000000], [2750, 3250, 25000000]]) == [[1000, 1500, 5000000], [1500, 1750, 15000000], [1750, 2000, 27000000], [2000, 2250, 37000000], [2250, 2500, 47000000], [2500, 2750, 37000000], [2750, 3000, 40000000], [3000, 3250, 25000000]]\n assert candidate(segments = [[1, 100, 1000000000], [50, 150, 1000000000], [100, 200, 1000000000], [150, 250, 1000000000], [200, 300, 1000000000]]) == [[1, 50, 1000000000], [50, 100, 2000000000], [100, 150, 2000000000], [150, 200, 2000000000], [200, 250, 2000000000], [250, 300, 1000000000]]\n assert candidate(segments = [[1, 4, 5], [2, 6, 7], [3, 7, 9], [4, 8, 11], [5, 9, 13], [6, 10, 15]]) == [[1, 2, 5], [2, 3, 12], [3, 4, 21], [4, 5, 27], [5, 6, 40], [6, 7, 48], [7, 8, 39], [8, 9, 28], [9, 10, 15]]\n assert candidate(segments = [[10000, 10005, 1], [10001, 10006, 2], [10002, 10007, 3], [10003, 10008, 4], [10004, 10009, 5]]) == [[10000, 10001, 1], [10001, 10002, 3], [10002, 10003, 6], [10003, 10004, 10], [10004, 10005, 15], [10005, 10006, 14], [10006, 10007, 12], [10007, 10008, 9], [10008, 10009, 5]]\n assert candidate(segments = [[5, 10, 10], [10, 15, 20], [15, 20, 30], [20, 25, 40], [25, 30, 50], [30, 35, 60], [35, 40, 70], [40, 45, 80], [45, 50, 90], [50, 55, 100]]) == [[5, 10, 10], [10, 15, 20], [15, 20, 30], [20, 25, 40], [25, 30, 50], [30, 35, 60], [35, 40, 70], [40, 45, 80], [45, 50, 90], [50, 55, 100]]\n assert candidate(segments = [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000]]) == [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000]]\n assert candidate(segments = [[1, 100000, 1], [50000, 100000, 2], [1, 50000, 3], [25000, 75000, 4]]) == [[1, 25000, 4], [25000, 50000, 8], [50000, 75000, 7], [75000, 100000, 3]]\n assert candidate(segments = [[1, 5, 10], [2, 4, 20], [3, 6, 30], [4, 8, 40], [5, 9, 50], [6, 10, 60], [7, 11, 70], [8, 12, 80], [9, 13, 90]]) == [[1, 2, 10], [2, 3, 30], [3, 4, 60], [4, 5, 80], [5, 6, 120], [6, 7, 150], [7, 8, 220], [8, 9, 260], [9, 10, 300], [10, 11, 240], [11, 12, 170], [12, 13, 90]]\n assert candidate(segments = [[1, 3, 1000000000], [3, 5, 1000000000], [5, 7, 1000000000], [7, 9, 1000000000], [9, 11, 1000000000], [11, 13, 1000000000], [13, 15, 1000000000], [15, 17, 1000000000], [17, 19, 1000000000], [19, 21, 1000000000]]) == [[1, 3, 1000000000], [3, 5, 1000000000], [5, 7, 1000000000], [7, 9, 1000000000], [9, 11, 1000000000], [11, 13, 1000000000], [13, 15, 1000000000], [15, 17, 1000000000], [17, 19, 1000000000], [19, 21, 1000000000]]\n assert candidate(segments = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1]]) == [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1]]\n assert candidate(segments = [[1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 2, 4], [1, 2, 5], [1, 2, 6], [1, 2, 7], [1, 2, 8], [1, 2, 9], [1, 2, 10]]) == [[1, 2, 55]]\n assert candidate(segments = [[5, 15, 100], [10, 20, 200], [15, 25, 300], [20, 30, 400], [25, 35, 500]]) == [[5, 10, 100], [10, 15, 300], [15, 20, 500], [20, 25, 700], [25, 30, 900], [30, 35, 500]]\n assert candidate(segments = [[1, 100000, 1000000], [50000, 100000, 900000], [1, 50000, 800000]]) == [[1, 50000, 1800000], [50000, 100000, 1900000]]\n assert candidate(segments = [[10, 20, 100], [15, 25, 50], [5, 30, 25], [20, 35, 75], [0, 40, 20]]) == [[0, 5, 20], [5, 10, 45], [10, 15, 145], [15, 20, 195], [20, 25, 170], [25, 30, 120], [30, 35, 95], [35, 40, 20]]\n assert candidate(segments = [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000], [6, 7, 1000000000], [7, 8, 1000000000], [8, 9, 1000000000], [9, 10, 1000000000], [10, 11, 1000000000]]) == [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000], [6, 7, 1000000000], [7, 8, 1000000000], [8, 9, 1000000000], [9, 10, 1000000000], [10, 11, 1000000000]]\n assert candidate(segments = [[1, 5, 1], [2, 4, 2], [3, 5, 3], [4, 6, 4], [5, 7, 5], [6, 8, 6]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 8], [5, 6, 9], [6, 7, 11], [7, 8, 6]]\n assert candidate(segments = [[100, 200, 500], [150, 250, 1000], [200, 300, 1500], [175, 225, 1200], [225, 275, 2200], [275, 325, 2500]]) == [[100, 150, 500], [150, 175, 1500], [175, 200, 2700], [200, 225, 3700], [225, 250, 4700], [250, 275, 3700], [275, 300, 4000], [300, 325, 2500]]\n assert candidate(segments = [[1, 20, 1], [2, 19, 2], [3, 18, 3], [4, 17, 4], [5, 16, 5], [6, 15, 6], [7, 14, 7], [8, 13, 8], [9, 12, 9], [10, 11, 10]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 15], [6, 7, 21], [7, 8, 28], [8, 9, 36], [9, 10, 45], [10, 11, 55], [11, 12, 45], [12, 13, 36], [13, 14, 28], [14, 15, 21], [15, 16, 15], [16, 17, 10], [17, 18, 6], [18, 19, 3], [19, 20, 1]]\n assert candidate(segments = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [20, 21, 20]]) == [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [20, 21, 20]]\n assert candidate(segments = [[100000, 100001, 1000000000], [1, 100000, 1], [2, 99999, 2], [3, 99998, 3], [4, 99997, 4]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 99997, 10], [99997, 99998, 6], [99998, 99999, 3], [99999, 100000, 1], [100000, 100001, 1000000000]]\n assert candidate(segments = [[1, 5, 1], [2, 6, 2], [3, 7, 3], [4, 8, 4], [5, 9, 5], [6, 10, 6], [7, 11, 7], [8, 12, 8], [9, 13, 9], [10, 14, 10]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 14], [6, 7, 18], [7, 8, 22], [8, 9, 26], [9, 10, 30], [10, 11, 34], [11, 12, 27], [12, 13, 19], [13, 14, 10]]\n assert candidate(segments = [[1, 5, 1], [1, 5, 2], [1, 5, 3], [1, 5, 4], [1, 5, 5], [1, 5, 6], [1, 5, 7], [1, 5, 8], [1, 5, 9], [1, 5, 10]]) == [[1, 5, 55]]\n assert candidate(segments = [[1, 5, 100], [2, 6, 200], [3, 7, 300], [4, 8, 400], [5, 9, 500], [6, 10, 600], [7, 11, 700], [8, 12, 800], [9, 13, 900], [10, 14, 1000]]) == [[1, 2, 100], [2, 3, 300], [3, 4, 600], [4, 5, 1000], [5, 6, 1400], [6, 7, 1800], [7, 8, 2200], [8, 9, 2600], [9, 10, 3000], [10, 11, 3400], [11, 12, 2700], [12, 13, 1900], [13, 14, 1000]]\n assert candidate(segments = [[1, 5, 1], [2, 4, 2], [3, 6, 3], [4, 8, 4], [5, 9, 5], [6, 10, 6]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 8], [5, 6, 12], [6, 8, 15], [8, 9, 11], [9, 10, 6]]\n assert candidate(segments = [[1, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 10, 10], [7, 11, 11], [8, 12, 12], [9, 13, 13], [10, 14, 14]]) == [[1, 2, 5], [2, 3, 11], [3, 4, 18], [4, 5, 26], [5, 6, 30], [6, 7, 34], [7, 8, 38], [8, 9, 42], [9, 10, 46], [10, 11, 50], [11, 12, 39], [12, 13, 27], [13, 14, 14]]\n assert candidate(segments = [[1, 10, 5], [5, 15, 7], [10, 20, 9], [1, 20, 3]]) == [[1, 5, 8], [5, 10, 15], [10, 15, 19], [15, 20, 12]]\n assert candidate(segments = [[1, 100000, 1], [2, 100001, 2], [3, 100002, 3], [4, 100003, 4], [5, 100004, 5], [6, 100005, 6], [7, 100006, 7], [8, 100007, 8], [9, 100008, 9], [10, 100009, 10]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 15], [6, 7, 21], [7, 8, 28], [8, 9, 36], [9, 10, 45], [10, 100000, 55], [100000, 100001, 54], [100001, 100002, 52], [100002, 100003, 49], [100003, 100004, 45], [100004, 100005, 40], [100005, 100006, 34], [100006, 100007, 27], [100007, 100008, 19], [100008, 100009, 10]]\n assert candidate(segments = [[1, 10, 10], [2, 8, 20], [5, 15, 30], [10, 20, 40], [15, 25, 50]]) == [[1, 2, 10], [2, 5, 30], [5, 8, 60], [8, 10, 40], [10, 15, 70], [15, 20, 90], [20, 25, 50]]\n assert candidate(segments = [[1, 3, 10], [2, 4, 20], [3, 5, 30], [4, 6, 40], [5, 7, 50], [6, 8, 60], [7, 9, 70], [8, 10, 80], [9, 11, 90], [10, 12, 100]]) == [[1, 2, 10], [2, 3, 30], [3, 4, 50], [4, 5, 70], [5, 6, 90], [6, 7, 110], [7, 8, 130], [8, 9, 150], [9, 10, 170], [10, 11, 190], [11, 12, 100]]\n assert candidate(segments = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]]) == [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]]\n assert candidate(segments = [[1, 10, 1000000000], [2, 9, 900000000], [3, 8, 800000000], [4, 7, 700000000], [5, 6, 600000000]]) == [[1, 2, 1000000000], [2, 3, 1900000000], [3, 4, 2700000000], [4, 5, 3400000000], [5, 6, 4000000000], [6, 7, 3400000000], [7, 8, 2700000000], [8, 9, 1900000000], [9, 10, 1000000000]]\n assert candidate(segments = [[1, 10, 5], [2, 8, 10], [3, 7, 15], [4, 6, 20]]) == [[1, 2, 5], [2, 3, 15], [3, 4, 30], [4, 6, 50], [6, 7, 30], [7, 8, 15], [8, 10, 5]]\n assert candidate(segments = [[2, 6, 7], [3, 8, 3], [5, 9, 5], [1, 4, 10], [6, 11, 2]]) == [[1, 2, 10], [2, 3, 17], [3, 4, 20], [4, 5, 10], [5, 6, 15], [6, 8, 10], [8, 9, 7], [9, 11, 2]]\n assert candidate(segments = [[5, 10, 1], [10, 15, 2], [15, 20, 3], [20, 25, 4], [25, 30, 5], [30, 35, 6], [35, 40, 7], [40, 45, 8], [45, 50, 9], [50, 55, 10]]) == [[5, 10, 1], [10, 15, 2], [15, 20, 3], [20, 25, 4], [25, 30, 5], [30, 35, 6], [35, 40, 7], [40, 45, 8], [45, 50, 9], [50, 55, 10]]\n assert candidate(segments = [[100, 200, 1], [150, 250, 2], [200, 300, 3], [250, 350, 4], [300, 400, 5], [350, 450, 6], [400, 500, 7], [450, 550, 8], [500, 600, 9], [550, 650, 10]]) == [[100, 150, 1], [150, 200, 3], [200, 250, 5], [250, 300, 7], [300, 350, 9], [350, 400, 11], [400, 450, 13], [450, 500, 15], [500, 550, 17], [550, 600, 19], [600, 650, 10]]\n assert candidate(segments = [[1, 100, 1], [50, 150, 2], [100, 200, 3], [150, 250, 4], [200, 300, 5]]) == [[1, 50, 1], [50, 100, 3], [100, 150, 5], [150, 200, 7], [200, 250, 9], [250, 300, 5]]\n assert candidate(segments = [[10, 20, 100], [15, 25, 200], [20, 30, 300], [12, 18, 150], [17, 23, 250]]) == [[10, 12, 100], [12, 15, 250], [15, 17, 450], [17, 18, 700], [18, 20, 550], [20, 23, 750], [23, 25, 500], [25, 30, 300]]\n assert candidate(segments = [[1, 3, 1000000000], [2, 4, 500000000], [3, 5, 300000000], [4, 6, 200000000], [5, 7, 100000000]]) == [[1, 2, 1000000000], [2, 3, 1500000000], [3, 4, 800000000], [4, 5, 500000000], [5, 6, 300000000], [6, 7, 100000000]]\n assert candidate(segments = [[10, 20, 5], [15, 25, 6], [20, 30, 7], [10, 30, 3], [25, 35, 8]]) == [[10, 15, 8], [15, 20, 14], [20, 25, 16], [25, 30, 18], [30, 35, 8]]\n assert candidate(segments = [[1, 50000, 1], [2, 50001, 2], [3, 50002, 3], [4, 50003, 4], [5, 50004, 5]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 50000, 15], [50000, 50001, 14], [50001, 50002, 12], [50002, 50003, 9], [50003, 50004, 5]]\n assert candidate(segments = [[1, 10, 5], [2, 9, 15], [3, 8, 25], [4, 7, 35], [5, 6, 45]]) == [[1, 2, 5], [2, 3, 20], [3, 4, 45], [4, 5, 80], [5, 6, 125], [6, 7, 80], [7, 8, 45], [8, 9, 20], [9, 10, 5]]\n assert candidate(segments = [[1, 10, 5], [5, 15, 10], [10, 20, 15]]) == [[1, 5, 5], [5, 10, 15], [10, 15, 25], [15, 20, 15]]\n assert candidate(segments = [[1, 100, 1], [50, 150, 2], [100, 200, 3], [150, 250, 4], [200, 300, 5], [250, 350, 6], [300, 400, 7], [350, 450, 8], [400, 500, 9], [450, 550, 10]]) == [[1, 50, 1], [50, 100, 3], [100, 150, 5], [150, 200, 7], [200, 250, 9], [250, 300, 11], [300, 350, 13], [350, 400, 15], [400, 450, 17], [450, 500, 19], [500, 550, 10]]\n assert candidate(segments = [[10, 20, 100], [15, 25, 50], [5, 15, 200]]) == [[5, 10, 200], [10, 15, 300], [15, 20, 150], [20, 25, 50]]\n assert candidate(segments = [[1, 10, 100], [5, 15, 200], [10, 20, 300], [15, 25, 400]]) == [[1, 5, 100], [5, 10, 300], [10, 15, 500], [15, 20, 700], [20, 25, 400]]\n assert candidate(segments = [[1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000]]) == [[1, 2, 10000000000]]\n assert candidate(segments = [[1, 10, 1], [2, 8, 2], [3, 7, 3], [4, 6, 4], [5, 5, 5]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 10], [6, 7, 6], [7, 8, 3], [8, 10, 1]]\n assert candidate(segments = [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000], [6, 7, 1000000000], [7, 8, 1000000000], [8, 9, 1000000000], [9, 10, 1000000000]]) == [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000], [6, 7, 1000000000], [7, 8, 1000000000], [8, 9, 1000000000], [9, 10, 1000000000]]\n assert candidate(segments = [[1, 100, 1], [1, 100, 2], [1, 100, 3], [1, 100, 4], [1, 100, 5], [1, 100, 6], [1, 100, 7], [1, 100, 8], [1, 100, 9], [1, 100, 10]]) == [[1, 100, 55]]\n assert candidate(segments = [[1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 15], [6, 7, 10], [7, 8, 6], [8, 9, 3], [9, 10, 1]]\n assert candidate(segments = [[10, 20, 5], [5, 15, 10], [20, 30, 15], [15, 25, 20], [25, 35, 25], [30, 40, 30]]) == [[5, 10, 10], [10, 15, 15], [15, 20, 25], [20, 25, 35], [25, 30, 40], [30, 35, 55], [35, 40, 30]]\n assert candidate(segments = [[1, 3, 10], [3, 5, 20], [5, 7, 30], [7, 9, 40], [9, 11, 50], [11, 13, 60], [13, 15, 70]]) == [[1, 3, 10], [3, 5, 20], [5, 7, 30], [7, 9, 40], [9, 11, 50], [11, 13, 60], [13, 15, 70]]\n assert candidate(segments = [[1, 10, 1], [1, 10, 2], [1, 10, 3], [1, 10, 4], [1, 10, 5], [1, 10, 6], [1, 10, 7], [1, 10, 8], [1, 10, 9], [1, 10, 10]]) == [[1, 10, 55]]\n assert candidate(segments = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]]) == [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]]\n assert candidate(segments = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9]]) == [[1, 2, 45], [2, 3, 44], [3, 4, 42], [4, 5, 39], [5, 6, 35], [6, 7, 30], [7, 8, 24], [8, 9, 17], [9, 10, 9]]\n assert candidate(segments = [[1, 10, 10], [2, 9, 9], [3, 8, 8], [4, 7, 7], [5, 6, 6], [6, 5, 5], [7, 4, 4], [8, 3, 3], [9, 2, 2], [10, 1, 1]]) == [[1, 2, 9], [2, 3, 16], [3, 4, 21], [4, 5, 24], [5, 6, 25], [6, 7, 24], [7, 8, 21], [8, 9, 16], [9, 10, 9]]\n assert candidate(segments = [[5, 10, 10], [10, 15, 10], [15, 20, 10], [20, 25, 10], [25, 30, 10], [30, 35, 10], [35, 40, 10], [40, 45, 10], [45, 50, 10], [50, 55, 10]]) == [[5, 10, 10], [10, 15, 10], [15, 20, 10], [20, 25, 10], [25, 30, 10], [30, 35, 10], [35, 40, 10], [40, 45, 10], [45, 50, 10], [50, 55, 10]]\n assert candidate(segments = [[1, 1000, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1], [20, 1000, 1]]) == [[1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 7, 2], [7, 8, 2], [8, 9, 2], [9, 10, 2], [10, 11, 2], [11, 12, 2], [12, 13, 2], [13, 14, 2], [14, 15, 2], [15, 16, 2], [16, 17, 2], [17, 18, 2], [18, 19, 2], [19, 20, 2], [20, 1000, 2]]\n assert candidate(segments = [[1, 100, 1], [2, 99, 2], [3, 98, 3], [4, 97, 4], [5, 96, 5], [6, 95, 6], [7, 94, 7], [8, 93, 8], [9, 92, 9], [10, 91, 10]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 15], [6, 7, 21], [7, 8, 28], [8, 9, 36], [9, 10, 45], [10, 91, 55], [91, 92, 45], [92, 93, 36], [93, 94, 28], [94, 95, 21], [95, 96, 15], [96, 97, 10], [97, 98, 6], [98, 99, 3], [99, 100, 1]]\n assert candidate(segments = [[1, 10, 10], [2, 8, 20], [5, 15, 30], [10, 20, 40]]) == [[1, 2, 10], [2, 5, 30], [5, 8, 60], [8, 10, 40], [10, 15, 70], [15, 20, 40]]\n assert candidate(segments = [[10, 20, 100], [20, 30, 200], [30, 40, 300], [40, 50, 400], [50, 60, 500], [60, 70, 600], [70, 80, 700], [80, 90, 800], [90, 100, 900], [100, 110, 1000]]) == [[10, 20, 100], [20, 30, 200], [30, 40, 300], [40, 50, 400], [50, 60, 500], [60, 70, 600], [70, 80, 700], [80, 90, 800], [90, 100, 900], [100, 110, 1000]]\n assert candidate(segments = [[1, 3, 1000000000], [2, 4, 1000000000], [3, 5, 1000000000], [4, 6, 1000000000], [5, 7, 1000000000]]) == [[1, 2, 1000000000], [2, 3, 2000000000], [3, 4, 2000000000], [4, 5, 2000000000], [5, 6, 2000000000], [6, 7, 1000000000]]\n assert candidate(segments = [[10, 20, 5], [15, 25, 7], [20, 30, 9], [25, 35, 11], [30, 40, 13], [35, 45, 15], [40, 50, 17], [45, 55, 19], [50, 60, 21], [55, 65, 23]]) == [[10, 15, 5], [15, 20, 12], [20, 25, 16], [25, 30, 20], [30, 35, 24], [35, 40, 28], [40, 45, 32], [45, 50, 36], [50, 55, 40], [55, 60, 44], [60, 65, 23]]\n assert candidate(segments = [[1, 10000, 1], [2, 9999, 2], [3, 9998, 3], [4, 9997, 4], [5, 9996, 5]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 9996, 15], [9996, 9997, 10], [9997, 9998, 6], [9998, 9999, 3], [9999, 10000, 1]]\n assert candidate(segments = [[1, 5, 10], [2, 6, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50]]) == [[1, 2, 10], [2, 3, 30], [3, 4, 60], [4, 5, 100], [5, 6, 140], [6, 7, 120], [7, 8, 90], [8, 9, 50]]\n assert candidate(segments = [[10, 20, 1], [15, 25, 2], [20, 30, 3], [25, 35, 4], [30, 40, 5], [35, 45, 6], [40, 50, 7], [45, 55, 8], [50, 60, 9], [55, 65, 10]]) == [[10, 15, 1], [15, 20, 3], [20, 25, 5], [25, 30, 7], [30, 35, 9], [35, 40, 11], [40, 45, 13], [45, 50, 15], [50, 55, 17], [55, 60, 19], [60, 65, 10]]\n assert candidate(segments = [[1, 2, 9], [2, 3, 8], [3, 4, 7], [4, 5, 6], [5, 6, 5], [6, 7, 4], [7, 8, 3], [8, 9, 2], [9, 10, 1]]) == [[1, 2, 9], [2, 3, 8], [3, 4, 7], [4, 5, 6], [5, 6, 5], [6, 7, 4], [7, 8, 3], [8, 9, 2], [9, 10, 1]]\n assert candidate(segments = [[1, 5, 1], [2, 4, 2], [3, 6, 3], [1, 3, 4], [2, 5, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8]]) == [[1, 2, 5], [2, 3, 12], [3, 4, 17], [4, 5, 16], [5, 6, 11]]\n assert candidate(segments = [[1, 10, 1], [10, 20, 2], [20, 30, 3], [30, 40, 4], [40, 50, 5], [50, 60, 6], [60, 70, 7], [70, 80, 8], [80, 90, 9], [90, 100, 10]]) == [[1, 10, 1], [10, 20, 2], [20, 30, 3], [30, 40, 4], [40, 50, 5], [50, 60, 6], [60, 70, 7], [70, 80, 8], [80, 90, 9], [90, 100, 10]]\n assert candidate(segments = [[1, 10, 10], [2, 9, 20], [3, 8, 30], [4, 7, 40], [5, 6, 50], [1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5]]) == [[1, 2, 11], [2, 3, 33], [3, 4, 66], [4, 5, 110], [5, 6, 165], [6, 7, 110], [7, 8, 66], [8, 9, 33], [9, 10, 11]]\n assert candidate(segments = [[1, 5, 1], [1, 5, 2], [1, 5, 3], [1, 5, 4], [1, 5, 5], [1, 5, 6], [1, 5, 7], [1, 5, 8], [1, 5, 9], [1, 5, 10]]) == [[1, 5, 55]]\n assert candidate(segments = [[1, 100000, 1], [1, 100000, 2], [1, 100000, 3], [1, 100000, 4], [1, 100000, 5]]) == [[1, 100000, 15]]\n assert candidate(segments = [[1, 100000, 1], [50000, 150000, 2], [25000, 75000, 3], [1, 50000, 4], [100000, 150000, 5]]) == [[1, 25000, 5], [25000, 50000, 8], [50000, 75000, 6], [75000, 100000, 3], [100000, 150000, 7]]\n assert candidate(segments = [[10, 20, 1], [20, 30, 2], [30, 40, 3], [40, 50, 4], [50, 60, 5], [60, 70, 6], [70, 80, 7], [80, 90, 8], [90, 100, 9], [100, 110, 10]]) == [[10, 20, 1], [20, 30, 2], [30, 40, 3], [40, 50, 4], [50, 60, 5], [60, 70, 6], [70, 80, 7], [80, 90, 8], [90, 100, 9], [100, 110, 10]]\n assert candidate(segments = [[1, 100, 100], [20, 50, 200], [30, 40, 300], [40, 60, 400], [50, 70, 500], [60, 80, 600], [70, 90, 700], [80, 100, 800]]) == [[1, 20, 100], [20, 30, 300], [30, 40, 600], [40, 50, 700], [50, 60, 1000], [60, 70, 1200], [70, 80, 1400], [80, 90, 1600], [90, 100, 900]]\n assert candidate(segments = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9], [1, 11, 10]]) == [[1, 2, 55], [2, 3, 54], [3, 4, 52], [4, 5, 49], [5, 6, 45], [6, 7, 40], [7, 8, 34], [8, 9, 27], [9, 10, 19], [10, 11, 10]]\n assert candidate(segments = [[1, 5, 1], [2, 4, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 3], [4, 5, 1], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]\n"}, "metadata": {"canonical_parameter_names": ["segments"], "leetcode_dataset_entry_point": "Solution().splitPainting", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def splitPainting(self, segments: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "splitPainting", "parameters": [{"name": "segments", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1944, "task_id": "number-of-visible-people-in-a-queue", "difficulty": "Hard", "problem_description": "There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers where heights[i] represents the height of the ith person.\nA person can see another person to their right in the queue if everybody in between is shorter than both of them. More formally, the ith person can see the jth person if i < j and min(heights[i], heights[j]) > max(heights[i+1], heights[i+2], ..., heights[j-1]).\nReturn an array answer of length n where answer[i] is the number of people the ith person can see to their right in the queue.\n \nExample 1:\n\n\nInput: heights = [10,6,8,5,11,9]\nOutput: [3,1,2,1,1,0]\nExplanation:\nPerson 0 can see person 1, 2, and 4.\nPerson 1 can see person 2.\nPerson 2 can see person 3 and 4.\nPerson 3 can see person 4.\nPerson 4 can see person 5.\nPerson 5 can see no one since nobody is to the right of them.\n\nExample 2:\n\nInput: heights = [5,1,2,3,10]\nOutput: [4,1,1,1,0]\n\n \nConstraints:\n\nn == heights.length\n1 <= n <= 105\n1 <= heights[i] <= 105\nAll the values of heights are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(heights = [1]) == [0]\n assert candidate(heights = [1, 2, 3, 6, 5, 4, 10, 9, 8, 7]) == [1, 1, 1, 2, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 1, 2, 3, 10]) == [4, 1, 1, 1, 0]\n assert candidate(heights = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [5, 4, 3, 2, 1]) == [1, 1, 1, 1, 0]\n assert candidate(heights = [10, 6, 8, 5, 11, 9]) == [3, 1, 2, 1, 1, 0]\n assert candidate(heights = [3, 1, 2]) == [2, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0]\n assert candidate(heights = [100, 80, 60, 70, 60, 75, 85]) == [2, 4, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5]) == [1, 1, 1, 1, 0]\n assert candidate(heights = [3, 1, 4, 2, 5]) == [2, 1, 2, 1, 0]\n assert candidate(heights = [100000]) == [0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 0]\n assert candidate(heights = [1, 9, 2, 8, 3, 7, 4, 6, 5, 14, 13, 12, 11, 10]) == [1, 3, 1, 3, 1, 3, 1, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6, 70, 7, 80, 8, 90, 9, 100, 10]) == [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [5, 9, 2, 8, 7, 6, 3, 4, 1, 10]) == [1, 3, 1, 2, 2, 3, 1, 2, 1, 0]\n assert candidate(heights = [10, 20, 15, 25, 30, 5, 35, 40, 45, 50]) == [1, 2, 1, 1, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 1, 7, 2, 6, 3, 5, 4, 8, 9, 10, 11, 12, 13, 14]) == [2, 1, 3, 1, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 12, 14, 16, 18, 20, 11, 13, 15, 17, 19]) == [1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 5, 2, 6, 3, 7, 4, 8, 9, 10]) == [1, 2, 1, 2, 1, 2, 1, 1, 1, 0]\n assert candidate(heights = [5, 1, 3, 2, 4, 6, 7, 8, 9, 10]) == [4, 1, 2, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == [2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [3, 6, 5, 4, 3, 2, 1, 7, 8, 9]) == [1, 2, 2, 2, 2, 2, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == [1, 1, 3, 2, 1, 1, 3, 2, 1, 1, 3, 2, 1, 1, 3, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993, 9, 99992, 10, 99991]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [5, 1, 3, 2, 6, 4, 8, 7, 10, 9]) == [3, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [50, 10, 51, 11, 52, 12, 53, 13, 54, 14]) == [2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [2, 1, 5, 4, 3, 8, 7, 6, 10, 9, 14, 13, 12, 18, 17, 16, 20, 19, 22, 21]) == [2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == [2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [5, 3, 8, 6, 11, 9, 14, 12, 17, 15, 20, 18, 23, 21, 26, 24, 29, 27, 32, 30, 35, 33, 38, 36, 39]) == [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10]) == [1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 0]\n assert candidate(heights = [15, 10, 5, 14, 9, 4, 13, 8, 3, 12, 7, 2, 11, 6, 1]) == [2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 5, 2, 6, 3, 7, 4, 8, 9, 10]) == [1, 2, 1, 2, 1, 2, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == [1, 1, 1, 3, 3, 2, 1, 1, 1, 0]\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 11, 12, 13, 14, 15]) == [3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0]\n assert candidate(heights = [5, 4, 3, 2, 1, 10]) == [2, 2, 2, 2, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 99999]) == [30, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [50000, 40000, 30000, 20000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == [1, 1, 1, 1, 5, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 10, 3, 9, 5, 8, 7, 2, 6, 4]) == [1, 2, 1, 2, 1, 1, 2, 1, 1, 0]\n assert candidate(heights = [10, 5, 6, 7, 1, 2, 3, 4, 8, 9]) == [5, 1, 1, 5, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == [1, 1, 3, 2, 1, 1, 3, 2, 1, 1, 3, 2, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 2, 3, 5, 4, 6, 7, 8, 9, 10]) == [1, 1, 1, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23]) == [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 8, 4, 9, 7, 6, 10, 3, 2, 1, 11, 14, 12, 13, 16, 15, 18, 17, 20, 19]) == [1, 2, 1, 2, 2, 1, 2, 2, 2, 1, 1, 3, 1, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 20, 2, 19, 3, 18, 4, 17, 5, 16, 6, 15, 7, 14, 8, 13, 9, 12, 10, 11]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 15, 11, 14, 12, 13, 20, 16, 19, 17, 18]) == [3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 3, 1, 3, 1, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [5, 3, 8, 6, 7, 2, 4, 1, 10, 9]) == [2, 1, 3, 1, 3, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 20, 15, 30, 25, 40, 35, 50, 45, 60, 55, 70, 65, 80, 75, 90, 85, 100, 95, 110]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16]) == [1, 3, 1, 3, 1, 3, 1, 3, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [10, 1, 20, 3, 40, 5, 60, 7, 80, 9, 100]) == [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9]) == [4, 1, 2, 1, 1, 1, 2, 1, 1, 0]\n assert candidate(heights = [100, 50, 75, 25, 60, 35, 80, 10, 90, 40]) == [4, 1, 3, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [10, 20, 15, 25, 30, 5, 10, 15, 20, 25]) == [1, 2, 1, 1, 5, 1, 1, 1, 1, 0]\n assert candidate(heights = [50, 20, 40, 10, 30, 60, 70, 80, 90, 100]) == [3, 1, 3, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 15, 4, 3, 2, 1, 16, 17, 18, 19]) == [2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 9, 1, 4, 6, 8, 2, 3, 7, 10]) == [1, 5, 1, 1, 1, 4, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 105, 95, 85, 75, 65, 55, 45, 35, 25, 15]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [77, 73, 69, 65, 61, 57, 53, 49, 45, 41, 37, 33, 29, 25, 21, 17, 13, 9, 5, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 1, 3, 2, 4, 6, 2, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == [4, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15, 20, 19, 18, 17, 16]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == [2, 2, 2, 2, 2, 2, 2, 2, 1, 0]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == [1, 3, 1, 3, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 1, 10, 2, 10, 3, 10, 4, 10, 5]) == [2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [100000, 99999, 99998, 99997, 99996, 99995]) == [1, 1, 1, 1, 1, 0]\n assert candidate(heights = [50, 40, 30, 20, 10, 5, 15, 25, 35, 45]) == [2, 3, 3, 3, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 20, 15, 25, 30, 5, 10, 35, 40, 45]) == [1, 2, 1, 1, 3, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 6, 5, 4, 10, 9, 8, 7, 14, 13, 12, 11, 20, 19, 18, 17, 16, 15]) == [1, 2, 1, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 3, 8, 6, 7, 2, 4, 9, 1, 10]) == [2, 1, 3, 1, 3, 1, 1, 2, 1, 0]\n assert candidate(heights = [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 18]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 5, 3, 7, 2, 8, 4, 9, 6, 10]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == [2, 2, 2, 2, 1, 1, 1, 1, 1, 0]\n"}, "metadata": {"canonical_parameter_names": ["heights"], "leetcode_dataset_entry_point": "Solution().canSeePersonsCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def canSeePersonsCount(self, heights: list[int]) -> list[int]:", "container": "Solution", "callable": "canSeePersonsCount", "parameters": [{"name": "heights", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1945, "task_id": "sum-of-digits-of-string-after-convert", "difficulty": "Easy", "problem_description": "You are given a string s consisting of lowercase English letters, and an integer k. Your task is to convert the string into an integer by a special process, and then transform it by summing its digits repeatedly k times. More specifically, perform the following steps:\n\nConvert s into an integer by replacing each letter with its position in the alphabet (i.e. replace 'a' with 1, 'b' with 2, ..., 'z' with 26).\nTransform the integer by replacing it with the sum of its digits.\nRepeat the transform operation (step 2) k times in total.\n\nFor example, if s = \"zbax\" and k = 2, then the resulting integer would be 8 by the following operations:\n\nConvert: \"zbax\" ➝ \"(26)(2)(1)(24)\" ➝ \"262124\" ➝ 262124\nTransform #1: 262124 ➝ 2 + 6 + 2 + 1 + 2 + 4 ➝ 17\nTransform #2: 17 ➝ 1 + 7 ➝ 8\n\nReturn the resulting integer after performing the operations described above.\n \nExample 1:\n\nInput: s = \"iiii\", k = 1\nOutput: 36\nExplanation:\nThe operations are as follows:\n- Convert: \"iiii\" ➝ \"(9)(9)(9)(9)\" ➝ \"9999\" ➝ 9999\n- Transform #1: 9999 ➝ 9 + 9 + 9 + 9 ➝ 36\nThus the resulting integer is 36.\n\nExample 2:\n\nInput: s = \"leetcode\", k = 2\nOutput: 6\nExplanation:\nThe operations are as follows:\n- Convert: \"leetcode\" ➝ \"(12)(5)(5)(20)(3)(15)(4)(5)\" ➝ \"12552031545\" ➝ 12552031545\n- Transform #1: 12552031545 ➝ 1 + 2 + 5 + 5 + 2 + 0 + 3 + 1 + 5 + 4 + 5 ➝ 33\n- Transform #2: 33 ➝ 3 + 3 ➝ 6\nThus the resulting integer is 6.\n\nExample 3:\n\nInput: s = \"zbax\", k = 2\nOutput: 8\n\n \nConstraints:\n\n1 <= s.length <= 100\n1 <= k <= 10\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzz\",k = 1) == 32\n assert candidate(s = \"zzz\",k = 10) == 6\n assert candidate(s = \"programming\",k = 1) == 68\n assert candidate(s = \"abz\",k = 5) == 2\n assert candidate(s = \"a\",k = 1) == 1\n assert candidate(s = \"aaa\",k = 3) == 3\n assert candidate(s = \"challenge\",k = 2) == 4\n assert candidate(s = \"iiii\",k = 1) == 36\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == 135\n assert candidate(s = \"hello\",k = 1) == 25\n assert candidate(s = \"python\",k = 2) == 8\n assert candidate(s = \"abc\",k = 3) == 6\n assert candidate(s = \"zbax\",k = 2) == 8\n assert candidate(s = \"abcxyz\",k = 3) == 9\n assert candidate(s = \"leetcode\",k = 2) == 6\n assert candidate(s = \"a\",k = 10) == 1\n assert candidate(s = \"zzzz\",k = 3) == 5\n assert candidate(s = \"zzzzzzzzzz\",k = 1) == 80\n assert candidate(s = \"algorithms\",k = 4) == 5\n assert candidate(s = \"repeatthisoverandover\",k = 7) == 8\n assert candidate(s = \"zzzzzzzzzz\",k = 6) == 8\n assert candidate(s = \"interview\",k = 5) == 8\n assert candidate(s = \"artificialintelligence\",k = 7) == 5\n assert candidate(s = \"zzyxwvutsrqponmlkjihgfedcba\",k = 4) == 8\n assert candidate(s = \"singleletterx\",k = 10) == 8\n assert candidate(s = \"thisisaverylongstringwhichshouldbeconverted\",k = 4) == 2\n assert candidate(s = \"zzzzzzzzzz\",k = 3) == 8\n assert candidate(s = \"hippopotamus\",k = 10) == 7\n assert candidate(s = \"qwen\",k = 5) == 5\n assert candidate(s = \"datastructure\",k = 4) == 9\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 3) == 8\n assert candidate(s = \"repeatedlettersqqqq\",k = 6) == 7\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 2) == 9\n assert candidate(s = \"programming\",k = 3) == 5\n assert candidate(s = \"unbelievable\",k = 9) == 2\n assert candidate(s = \"mississippi\",k = 7) == 4\n assert candidate(s = \"zebra\",k = 6) == 7\n assert candidate(s = \"zzzzzzzzzz\",k = 10) == 8\n assert candidate(s = \"xyzxyz\",k = 3) == 6\n assert candidate(s = \"supercalifragilisticexpialidocious\",k = 5) == 1\n assert candidate(s = \"onetwothreefourfivesixseveneightnine\",k = 5) == 8\n assert candidate(s = \"generateadditionalinputs\",k = 8) == 2\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 4) == 8\n assert candidate(s = \"multifarious\",k = 7) == 2\n assert candidate(s = \"consecutivesimilar\",k = 8) == 1\n assert candidate(s = \"neuralnetwork\",k = 8) == 6\n assert candidate(s = \"developerslovepython\",k = 9) == 3\n assert candidate(s = \"algorithm\",k = 1) == 49\n assert candidate(s = \"wearethebestprogrammers\",k = 7) == 4\n assert candidate(s = \"xylophone\",k = 3) == 8\n assert candidate(s = \"alibabacloud\",k = 7) == 2\n assert candidate(s = \"aaaaaaaaaa\",k = 10) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 5) == 9\n assert candidate(s = \"elephant\",k = 8) == 9\n assert candidate(s = \"supercalifragilisticexpialidocious\",k = 4) == 1\n assert candidate(s = \"abcdefghij\",k = 5) == 1\n assert candidate(s = \"repeatedletters\",k = 4) == 2\n assert candidate(s = \"datastructures\",k = 5) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 3) == 9\n assert candidate(s = \"facetious\",k = 8) == 9\n assert candidate(s = \"numericalsum\",k = 7) == 5\n assert candidate(s = \"expertise\",k = 2) == 13\n assert candidate(s = \"codingcontest\",k = 6) == 4\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 4) == 9\n assert candidate(s = \"alibabacloud\",k = 2) == 11\n assert candidate(s = \"manytimesk\",k = 10) == 4\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 6) == 8\n assert candidate(s = \"giraffe\",k = 9) == 7\n assert candidate(s = \"qwen\",k = 10) == 5\n assert candidate(s = \"mississippi\",k = 8) == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 10) == 9\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 10) == 8\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 4\n assert candidate(s = \"solution\",k = 7) == 8\n assert candidate(s = \"abacaxabacax\",k = 5) == 1\n assert candidate(s = \"algorithms\",k = 5) == 5\n assert candidate(s = \"zzzzzzzzzz\",k = 5) == 8\n assert candidate(s = \"transform\",k = 8) == 7\n assert candidate(s = \"congratulations\",k = 5) == 9\n assert candidate(s = \"xylophone\",k = 4) == 8\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 2) == 8\n assert candidate(s = \"qwen\",k = 4) == 5\n assert candidate(s = \"leetcodeisfun\",k = 9) == 3\n assert candidate(s = \"programmingisfun\",k = 3) == 2\n assert candidate(s = \"machinelearning\",k = 6) == 7\n assert candidate(s = \"abcdefg\",k = 10) == 1\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",k = 6) == 5\n assert candidate(s = \"thisisaverylongandcomplexstring\",k = 6) == 1\n assert candidate(s = \"xylophone\",k = 5) == 8\n assert candidate(s = \"thisisanexampletocheckthecomplexity\",k = 4) == 1\n assert candidate(s = \"datastructure\",k = 5) == 9\n assert candidate(s = \"abacaxi\",k = 3) == 5\n assert candidate(s = \"abcdabcdabcd\",k = 4) == 3\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().getLucky", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getLucky(self, s: str, k: int) -> int:", "container": "Solution", "callable": "getLucky", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1946, "task_id": "largest-number-after-mutating-substring", "difficulty": "Medium", "problem_description": "You are given a string num, which represents a large integer. You are also given a 0-indexed integer array change of length 10 that maps each digit 0-9 to another digit. More formally, digit d maps to digit change[d].\nYou may choose to mutate a single substring of num. To mutate a substring, replace each digit num[i] with the digit it maps to in change (i.e. replace num[i] with change[num[i]]).\nReturn a string representing the largest possible integer after mutating (or choosing not to) a single substring of num.\nA substring is a contiguous sequence of characters within the string.\n \nExample 1:\n\nInput: num = \"132\", change = [9,8,5,0,3,6,4,2,6,8]\nOutput: \"832\"\nExplanation: Replace the substring \"1\":\n- 1 maps to change[1] = 8.\nThus, \"132\" becomes \"832\".\n\"832\" is the largest number that can be created, so return it.\n\nExample 2:\n\nInput: num = \"021\", change = [9,4,3,5,7,2,1,9,0,6]\nOutput: \"934\"\nExplanation: Replace the substring \"021\":\n- 0 maps to change[0] = 9.\n- 2 maps to change[2] = 3.\n- 1 maps to change[1] = 4.\nThus, \"021\" becomes \"934\".\n\"934\" is the largest number that can be created, so return it.\n\nExample 3:\n\nInput: num = \"5\", change = [1,4,7,5,3,2,5,6,9,4]\nOutput: \"5\"\nExplanation: \"5\" is already the largest number that can be created, so return it.\n\n \nConstraints:\n\n1 <= num.length <= 105\nnum consists of only digits 0-9.\nchange.length == 10\n0 <= change[d] <= 9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"132\",change = [9, 8, 5, 0, 3, 6, 4, 2, 6, 8]) == \"832\"\n assert candidate(num = \"1111\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999\"\n assert candidate(num = \"5\",change = [1, 4, 7, 5, 3, 2, 5, 6, 9, 4]) == \"5\"\n assert candidate(num = \"9876543210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"9876543210\"\n assert candidate(num = \"3333\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"3333\"\n assert candidate(num = \"021\",change = [9, 4, 3, 5, 7, 2, 1, 9, 0, 6]) == \"934\"\n assert candidate(num = \"1234567890\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8765567890\"\n assert candidate(num = \"1001001001\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"8642086420\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9753197531\"\n assert candidate(num = \"1999999999\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"9999999999\"\n assert candidate(num = \"9999999999\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"9999999999\"\n assert candidate(num = \"1231231231\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"1231231231\"\n assert candidate(num = \"1001\",change = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == \"1111\"\n assert candidate(num = \"9000000009\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9111111119\"\n assert candidate(num = \"9876543210\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"9876543210\"\n assert candidate(num = \"0001112223\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"13579\",change = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == \"26579\"\n assert candidate(num = \"1357924680\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"1122334455\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1122334455\"\n assert candidate(num = \"5432109876\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"5567899876\"\n assert candidate(num = \"999888777666555444333222111000\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 9]) == \"999888777666555444333222111000\"\n assert candidate(num = \"11111111111111111111\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"99999999999999999999\"\n assert candidate(num = \"100100100\",change = [9, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"199100100\"\n assert candidate(num = \"100100\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"899899\"\n assert candidate(num = \"1234567890\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == \"2345678990\"\n assert candidate(num = \"99999\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 9]) == \"99999\"\n assert candidate(num = \"2468013579\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"7568013579\"\n assert candidate(num = \"1000000001\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"9000000009\"\n assert candidate(num = \"9876543210\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9876556789\"\n assert candidate(num = \"9009\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9999\"\n assert candidate(num = \"0123456789\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"0123456789\"\n assert candidate(num = \"13579246801357924680\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"13579246801357924680\"\n assert candidate(num = \"10987654321\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"99999999999\"\n assert candidate(num = \"1234567890\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"1234567890\"\n assert candidate(num = \"9087654321\",change = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"9187654321\"\n assert candidate(num = \"1919191919\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8919191919\"\n assert candidate(num = \"5555555555\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"6666666666\"\n assert candidate(num = \"4444444444\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"4444444444\"\n assert candidate(num = \"1111\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"1111\"\n assert candidate(num = \"9876543210\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"9090909090\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 9]) == \"9090909090\"\n assert candidate(num = \"12345678901234567890\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"12345678901234567890\"\n assert candidate(num = \"1234567890\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"1234567891\"\n assert candidate(num = \"98765432109876543210\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"98765567899876543210\"\n assert candidate(num = \"9898989898\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"9898989898\"\n assert candidate(num = \"5432109876\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"5432109876\"\n assert candidate(num = \"9999999999\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9999999999\"\n assert candidate(num = \"0000000000\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9999999999\"\n assert candidate(num = \"2222\",change = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == \"3333\"\n assert candidate(num = \"1123344556677889900\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1123344556677889900\"\n assert candidate(num = \"8765432109\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8765567899\"\n assert candidate(num = \"2468013579\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"2468013579\"\n assert candidate(num = \"1000100010\",change = [9, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"1999100010\"\n assert candidate(num = \"9999999999\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"123456789012345678901234567890\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"987656789012345678901234567890\"\n assert candidate(num = \"3214567890\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"6785567890\"\n assert candidate(num = \"11223344556677889900\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"99887766556677889900\"\n assert candidate(num = \"543210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"543210\"\n assert candidate(num = \"1234554321\",change = [0, 1, 2, 3, 4, 6, 5, 6, 7, 8]) == \"1234664321\"\n assert candidate(num = \"9080706050\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9191817161\"\n assert candidate(num = \"99999999999999999999\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"99999999999999999999\"\n assert candidate(num = \"5678943210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"5678943210\"\n assert candidate(num = \"11223344556677889900\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"11223344556677889900\"\n assert candidate(num = \"9090909090\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9190909090\"\n assert candidate(num = \"2222222222\",change = [0, 1, 9, 3, 4, 5, 6, 7, 8, 9]) == \"9999999999\"\n assert candidate(num = \"0000000000\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"1111111111\"\n assert candidate(num = \"239847362876\",change = [8, 9, 5, 7, 6, 5, 4, 3, 2, 1]) == \"579847362876\"\n assert candidate(num = \"00000000000000000000\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"99999999999999999999\"\n assert candidate(num = \"123123123\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"987987987\"\n assert candidate(num = \"2468024680\",change = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == \"4868024680\"\n assert candidate(num = \"0000000000\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"1111111111\"\n assert candidate(num = \"2345678901\",change = [0, 1, 2, 9, 4, 5, 6, 7, 8, 3]) == \"2945678901\"\n assert candidate(num = \"999999\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 9]) == \"999999\"\n assert candidate(num = \"3333\",change = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == \"3333\"\n assert candidate(num = \"00112233445566778899\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"99999999999999999999\"\n assert candidate(num = \"8888888888\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"8888888888\"\n assert candidate(num = \"1234567890\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"2345678990\"\n assert candidate(num = \"1212121212\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1212121212\"\n assert candidate(num = \"2727272727\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"2727272727\"\n assert candidate(num = \"111222333\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"222333444\"\n assert candidate(num = \"111000111\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"111000111\"\n assert candidate(num = \"1919191919\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"9919191919\"\n assert candidate(num = \"86420\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"86579\"\n assert candidate(num = \"4444444444\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"4444444444\"\n assert candidate(num = \"0000000000\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"0000000000\"\n assert candidate(num = \"1357924680\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1357924680\"\n assert candidate(num = \"109876543210987654321\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"219876543210987654321\"\n assert candidate(num = \"09876543210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"09876543210\"\n assert candidate(num = \"0000000000\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"01234567890123456789\",change = [9, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"91234567890123456789\"\n assert candidate(num = \"3456789\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"6556789\"\n assert candidate(num = \"2222222222\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"2222222222\"\n assert candidate(num = \"12345678901234567890\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"98765678901234567890\"\n assert candidate(num = \"0123456789\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9876556789\"\n assert candidate(num = \"1234567890\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"9876567890\"\n assert candidate(num = \"888888\",change = [1, 2, 3, 4, 5, 6, 7, 8, 8, 9]) == \"888888\"\n assert candidate(num = \"56789\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"56789\"\n assert candidate(num = \"99999\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"99999\"\n assert candidate(num = \"5643210987\",change = [0, 1, 2, 3, 4, 9, 6, 7, 8, 9]) == \"9643210987\"\n assert candidate(num = \"54321098765432109876\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"55678998765432109876\"\n assert candidate(num = \"9234567890\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9345678990\"\n assert candidate(num = \"98765432109876543210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"98765432109876543210\"\n assert candidate(num = \"1234567890\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"12345678901234567890\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"87655678901234567890\"\n assert candidate(num = \"1111111111\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"1111111111\"\n assert candidate(num = \"1999\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"2999\"\n assert candidate(num = \"2736419850\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"7736419850\"\n assert candidate(num = \"505050\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"505050\"\n assert candidate(num = \"1010101010\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"000000\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == \"000000\"\n assert candidate(num = \"1212121212\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8787878787\"\n assert candidate(num = \"1122334455\",change = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == \"6677889955\"\n assert candidate(num = \"5555555555\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"9876543210\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9987654321\"\n assert candidate(num = \"1122334455\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8877665555\"\n assert candidate(num = \"1111111111\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"532532532\",change = [8, 9, 0, 7, 6, 5, 4, 3, 2, 1]) == \"572532532\"\n assert candidate(num = \"9321876543\",change = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9]) == \"9567876543\"\n assert candidate(num = \"0000\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9999\"\n assert candidate(num = \"5678912345\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"5678998765\"\n assert candidate(num = \"543210\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"654321\"\n assert candidate(num = \"1234567890\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1234567890\"\n assert candidate(num = \"5555555555\",change = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == \"5555555555\"\n assert candidate(num = \"5555\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"5555\"\n assert candidate(num = \"8888888888\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8888888888\"\n"}, "metadata": {"canonical_parameter_names": ["num", "change"], "leetcode_dataset_entry_point": "Solution().maximumNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumNumber(self, num: str, change: list[int]) -> str:", "container": "Solution", "callable": "maximumNumber", "parameters": [{"name": "num", "type": "str"}, {"name": "change", "type": "list[int]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1947, "task_id": "maximum-compatibility-score-sum", "difficulty": "Medium", "problem_description": "There is a survey that consists of n questions where each question's answer is either 0 (no) or 1 (yes).\nThe survey was given to m students numbered from 0 to m - 1 and m mentors numbered from 0 to m - 1. The answers of the students are represented by a 2D integer array students where students[i] is an integer array that contains the answers of the ith student (0-indexed). The answers of the mentors are represented by a 2D integer array mentors where mentors[j] is an integer array that contains the answers of the jth mentor (0-indexed).\nEach student will be assigned to one mentor, and each mentor will have one student assigned to them. The compatibility score of a student-mentor pair is the number of answers that are the same for both the student and the mentor.\n\nFor example, if the student's answers were [1, 0, 1] and the mentor's answers were [0, 0, 1], then their compatibility score is 2 because only the second and the third answers are the same.\n\nYou are tasked with finding the optimal student-mentor pairings to maximize the sum of the compatibility scores.\nGiven students and mentors, return the maximum compatibility score sum that can be achieved.\n \nExample 1:\n\nInput: students = [[1,1,0],[1,0,1],[0,0,1]], mentors = [[1,0,0],[0,0,1],[1,1,0]]\nOutput: 8\nExplanation: We assign students to mentors in the following way:\n- student 0 to mentor 2 with a compatibility score of 3.\n- student 1 to mentor 0 with a compatibility score of 2.\n- student 2 to mentor 1 with a compatibility score of 3.\nThe compatibility score sum is 3 + 2 + 3 = 8.\n\nExample 2:\n\nInput: students = [[0,0],[0,0],[0,0]], mentors = [[1,1],[1,1],[1,1]]\nOutput: 0\nExplanation: The compatibility score of any student-mentor pair is 0.\n\n \nConstraints:\n\nm == students.length == mentors.length\nn == students[i].length == mentors[j].length\n1 <= m, n <= 8\nstudents[i][k] is either 0 or 1.\nmentors[j][k] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(students = [[1, 1, 0, 0], [0, 0, 1, 1]],mentors = [[1, 0, 1, 0], [0, 1, 0, 1]]) == 4\n assert candidate(students = [[1, 1], [0, 0]],mentors = [[0, 0], [1, 1]]) == 4\n assert candidate(students = [[1, 0], [0, 1]],mentors = [[1, 0], [0, 1]]) == 4\n assert candidate(students = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0]],mentors = [[1, 1, 1, 1], [0, 0, 0, 0], [0, 1, 0, 1]]) == 8\n assert candidate(students = [[1, 0, 1, 0], [0, 1, 0, 1]],mentors = [[0, 0, 1, 1], [1, 1, 0, 0]]) == 4\n assert candidate(students = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 1, 1]],mentors = [[0, 0, 0, 0], [1, 1, 1, 1], [0, 1, 0, 1]]) == 10\n assert candidate(students = [[1, 1, 0, 0], [0, 0, 1, 1]],mentors = [[0, 0, 1, 1], [1, 1, 0, 0]]) == 8\n assert candidate(students = [[1, 1, 1], [0, 0, 0]],mentors = [[1, 1, 1], [0, 0, 0]]) == 6\n assert candidate(students = [[0, 0], [0, 0], [0, 0]],mentors = [[1, 1], [1, 1], [1, 1]]) == 0\n assert candidate(students = [[1, 1, 1, 1], [0, 0, 0, 0]],mentors = [[1, 1, 1, 1], [0, 0, 0, 0]]) == 8\n assert candidate(students = [[0, 0, 0], [1, 1, 1], [0, 1, 0]],mentors = [[1, 1, 1], [0, 0, 0], [1, 0, 1]]) == 6\n assert candidate(students = [[1, 0, 1], [0, 1, 0]],mentors = [[0, 1, 0], [1, 0, 1]]) == 6\n assert candidate(students = [[1, 1, 0], [1, 0, 1], [0, 0, 1]],mentors = [[1, 0, 0], [0, 0, 1], [1, 1, 0]]) == 8\n assert candidate(students = [[1, 0], [0, 1]],mentors = [[0, 1], [1, 0]]) == 4\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]]) == 32\n assert candidate(students = [[1, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1]],mentors = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0], [1, 0, 1, 0, 0, 1, 1]]) == 40\n assert candidate(students = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 1, 0, 1, 0], [0, 0, 1, 0, 0]],mentors = [[0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 0, 1, 0, 0], [1, 1, 0, 1, 0]]) == 20\n assert candidate(students = [[1, 0, 1, 1, 0], [0, 1, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]],mentors = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 16\n assert candidate(students = [[1, 0, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0, 1, 1], [0, 0, 1, 0, 1, 1, 0, 0], [1, 0, 1, 0, 0, 1, 1, 0], [0, 1, 0, 1, 1, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]],mentors = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 0, 1, 1, 0], [0, 1, 0, 1, 1, 0, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1, 0, 1], [1, 1, 0, 1, 0, 0, 1, 1], [0, 0, 1, 0, 1, 1, 0, 0]]) == 64\n assert candidate(students = [[1, 1, 1], [0, 0, 0], [1, 0, 1], [0, 1, 0]],mentors = [[1, 0, 1], [0, 1, 0], [0, 0, 0], [1, 1, 1]]) == 12\n assert candidate(students = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],mentors = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 20\n assert candidate(students = [[1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],mentors = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0]]) == 28\n assert candidate(students = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1]],mentors = [[1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 1, 1]]) == 49\n assert candidate(students = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]],mentors = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 20\n assert candidate(students = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1]],mentors = [[1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == 20\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1]],mentors = [[1, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0]]) == 22\n assert candidate(students = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 24\n assert candidate(students = [[0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0]],mentors = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1]]) == 32\n assert candidate(students = [[0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]],mentors = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 20\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]],mentors = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 8\n assert candidate(students = [[1, 0, 1, 1, 0], [0, 1, 0, 0, 1], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0]],mentors = [[0, 1, 0, 0, 1], [1, 0, 1, 1, 0], [0, 0, 1, 1, 0], [1, 1, 0, 0, 1]]) == 20\n assert candidate(students = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 64\n assert candidate(students = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],mentors = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 20\n assert candidate(students = [[1, 0, 0, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [0, 1, 1, 0, 0]],mentors = [[0, 1, 1, 0, 0], [1, 0, 0, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0]]) == 20\n assert candidate(students = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 1]],mentors = [[0, 1, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1], [1, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 1]]) == 24\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],mentors = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]]) == 28\n assert candidate(students = [[1, 0, 1, 1, 0], [0, 1, 0, 0, 1], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1]],mentors = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 12\n assert candidate(students = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 1, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 0]],mentors = [[0, 1, 1, 0, 0, 1, 1, 0], [1, 0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 64\n assert candidate(students = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]]) == 24\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 64\n assert candidate(students = [[1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 1, 0, 1, 1, 0, 1]],mentors = [[0, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0, 1, 0]]) == 16\n assert candidate(students = [[0, 1, 1, 0, 1, 1], [1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1]],mentors = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 0, 1, 0, 0], [0, 1, 1, 0, 1, 1]]) == 24\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 64\n assert candidate(students = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 0, 0], [0, 0, 1, 1]],mentors = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1]]) == 12\n assert candidate(students = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]],mentors = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 64\n assert candidate(students = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0], [1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1]],mentors = [[0, 0, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1]]) == 28\n assert candidate(students = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],mentors = [[0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 24\n assert candidate(students = [[1, 0, 1, 1, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1], [1, 1, 1, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 0]],mentors = [[0, 0, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1]]) == 28\n assert candidate(students = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0]]) == 32\n assert candidate(students = [[1, 0, 1, 1, 0], [0, 1, 0, 1, 0], [1, 1, 1, 0, 1]],mentors = [[0, 1, 0, 0, 1], [1, 0, 1, 1, 0], [0, 1, 1, 0, 0]]) == 11\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 0, 1, 0, 1], [1, 0, 0, 1, 1, 0, 1, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0]]) == 60\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 28\n assert candidate(students = [[1, 1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 30\n assert candidate(students = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]],mentors = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 20\n assert candidate(students = [[1, 1, 0, 0, 1, 0, 1], [0, 0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0]],mentors = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 0, 1, 0], [1, 1, 0, 0, 1, 0, 1]]) == 42\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]],mentors = [[0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 48\n assert candidate(students = [[0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0]],mentors = [[1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1]]) == 36\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]],mentors = [[0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 48\n assert candidate(students = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]],mentors = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(students = [[0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]],mentors = [[1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == 30\n assert candidate(students = [[1, 0, 1, 1, 0, 1], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]],mentors = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 21\n assert candidate(students = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1]],mentors = [[1, 1, 0, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 15\n assert candidate(students = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],mentors = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 25\n assert candidate(students = [[1, 1, 0, 1], [1, 0, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]],mentors = [[0, 1, 1, 0], [1, 0, 0, 1], [1, 1, 0, 1], [0, 0, 1, 0]]) == 15\n assert candidate(students = [[0, 1, 1, 1, 1, 0], [1, 0, 0, 0, 1, 1], [1, 1, 0, 1, 0, 0], [0, 1, 0, 1, 1, 0], [0, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0]],mentors = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0]]) == 28\n assert candidate(students = [[1, 0, 0, 1, 1, 0, 1], [0, 1, 1, 0, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1]],mentors = [[0, 1, 1, 0, 0, 1, 0], [1, 0, 0, 1, 1, 0, 1], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0]]) == 28\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 1, 0, 1, 1, 0, 1]],mentors = [[0, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 48\n assert candidate(students = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 1], [1, 0, 0, 1, 0], [1, 1, 1, 0, 0]]) == 10\n"}, "metadata": {"canonical_parameter_names": ["students", "mentors"], "leetcode_dataset_entry_point": "Solution().maxCompatibilitySum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxCompatibilitySum(self, students: list[list[int]], mentors: list[list[int]]) -> int:", "container": "Solution", "callable": "maxCompatibilitySum", "parameters": [{"name": "students", "type": "list[list[int]]"}, {"name": "mentors", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1948, "task_id": "delete-duplicate-folders-in-system", "difficulty": "Hard", "problem_description": "Due to a bug, there are many duplicate folders in a file system. You are given a 2D array paths, where paths[i] is an array representing an absolute path to the ith folder in the file system.\n\nFor example, [\"one\", \"two\", \"three\"] represents the path \"/one/two/three\".\n\nTwo folders (not necessarily on the same level) are identical if they contain the same non-empty set of identical subfolders and underlying subfolder structure. The folders do not need to be at the root level to be identical. If two or more folders are identical, then mark the folders as well as all their subfolders.\n\nFor example, folders \"/a\" and \"/b\" in the file structure below are identical. They (as well as their subfolders) should all be marked:\n\n\t\n/a\n/a/x\n/a/x/y\n/a/z\n/b\n/b/x\n/b/x/y\n/b/z\n\n\nHowever, if the file structure also included the path \"/b/w\", then the folders \"/a\" and \"/b\" would not be identical. Note that \"/a/x\" and \"/b/x\" would still be considered identical even with the added folder.\n\nOnce all the identical folders and their subfolders have been marked, the file system will delete all of them. The file system only runs the deletion once, so any folders that become identical after the initial deletion are not deleted.\nReturn the 2D array ans containing the paths of the remaining folders after deleting all the marked folders. The paths may be returned in any order.\n \nExample 1:\n\n\nInput: paths = [[\"a\"],[\"c\"],[\"d\"],[\"a\",\"b\"],[\"c\",\"b\"],[\"d\",\"a\"]]\nOutput: [[\"d\"],[\"d\",\"a\"]]\nExplanation: The file structure is as shown.\nFolders \"/a\" and \"/c\" (and their subfolders) are marked for deletion because they both contain an empty\nfolder named \"b\".\n\nExample 2:\n\n\nInput: paths = [[\"a\"],[\"c\"],[\"a\",\"b\"],[\"c\",\"b\"],[\"a\",\"b\",\"x\"],[\"a\",\"b\",\"x\",\"y\"],[\"w\"],[\"w\",\"y\"]]\nOutput: [[\"c\"],[\"c\",\"b\"],[\"a\"],[\"a\",\"b\"]]\nExplanation: The file structure is as shown. \nFolders \"/a/b/x\" and \"/w\" (and their subfolders) are marked for deletion because they both contain an empty folder named \"y\".\nNote that folders \"/a\" and \"/c\" are identical after the deletion, but they are not deleted because they were not marked beforehand.\n\nExample 3:\n\n\nInput: paths = [[\"a\",\"b\"],[\"c\",\"d\"],[\"c\"],[\"a\"]]\nOutput: [[\"c\"],[\"c\",\"d\"],[\"a\"],[\"a\",\"b\"]]\nExplanation: All folders are unique in the file system.\nNote that the returned array can be in a different order as the order does not matter.\n\n \nConstraints:\n\n1 <= paths.length <= 2 * 104\n1 <= paths[i].length <= 500\n1 <= paths[i][j].length <= 10\n1 <= sum(paths[i][j].length) <= 2 * 105\npath[i][j] consists of lowercase English letters.\nNo two paths lead to the same folder.\nFor any folder not at the root level, its parent folder will also be in the input.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(paths = [['project'], ['project', 'src'], ['project', 'src', 'main'], ['project', 'src', 'test'], ['project', 'docs'], ['project', 'docs', 'api'], ['project', 'docs', 'user']]) == [['project', 'docs', 'api'], ['project', 'docs', 'user'], ['project', 'docs'], ['project', 'src', 'main'], ['project', 'src', 'test'], ['project', 'src'], ['project']]\n assert candidate(paths = [['x'], ['x', 'y'], ['x', 'z'], ['y'], ['y', 'x'], ['z'], ['z', 'x']]) == [['x', 'y'], ['x', 'z'], ['x']]\n assert candidate(paths = [['a', 'b'], ['c', 'd'], ['c'], ['a']]) == [['a', 'b'], ['a'], ['c', 'd'], ['c']]\n assert candidate(paths = [['home'], ['home', 'user'], ['home', 'user', 'documents'], ['home', 'guest'], ['home', 'guest', 'documents']]) == [['home']]\n assert candidate(paths = [['a'], ['a', 'b'], ['a', 'b', 'c'], ['a', 'b', 'c', 'd'], ['a', 'b', 'c', 'd', 'e'], ['f'], ['f', 'g'], ['f', 'g', 'h'], ['f', 'g', 'h', 'i'], ['f', 'g', 'h', 'i', 'j']]) == [['a', 'b', 'c', 'd', 'e'], ['a', 'b', 'c', 'd'], ['a', 'b', 'c'], ['a', 'b'], ['a'], ['f', 'g', 'h', 'i', 'j'], ['f', 'g', 'h', 'i'], ['f', 'g', 'h'], ['f', 'g'], ['f']]\n assert candidate(paths = [['root'], ['root', 'a'], ['root', 'b'], ['root', 'a', 'x'], ['root', 'b', 'x'], ['root', 'a', 'x', 'y'], ['root', 'b', 'x', 'y']]) == [['root']]\n assert candidate(paths = [['folder1'], ['folder1', 'sub1'], ['folder1', 'sub2'], ['folder2'], ['folder2', 'sub1'], ['folder2', 'sub2']]) == []\n assert candidate(paths = [['a'], ['c'], ['a', 'b'], ['c', 'b'], ['a', 'b', 'x'], ['a', 'b', 'x', 'y'], ['w'], ['w', 'y']]) == [['a', 'b'], ['a'], ['c', 'b'], ['c']]\n assert candidate(paths = [['x'], ['x', 'y'], ['x', 'y', 'z'], ['x', 'y', 'z', 'w'], ['u'], ['u', 'v'], ['u', 'v', 'w']]) == [['u'], ['x', 'y'], ['x']]\n assert candidate(paths = [['m'], ['m', 'n'], ['n'], ['n', 'm'], ['m', 'n', 'o'], ['n', 'm', 'o']]) == [['m'], ['n']]\n assert candidate(paths = [['root'], ['root', 'folder1'], ['root', 'folder2'], ['root', 'folder1', 'subfolder1'], ['root', 'folder2', 'subfolder1']]) == [['root']]\n assert candidate(paths = [['m'], ['m', 'n'], ['p'], ['p', 'n']]) == []\n assert candidate(paths = [['a'], ['c'], ['d'], ['a', 'b'], ['c', 'b'], ['d', 'a']]) == [['d', 'a'], ['d']]\n assert candidate(paths = [['x'], ['x', 'y'], ['x', 'y', 'z'], ['y'], ['y', 'z']]) == [['x']]\n assert candidate(paths = [['one'], ['one', 'two'], ['one', 'two', 'three'], ['two'], ['two', 'three']]) == [['one']]\n assert candidate(paths = [['p'], ['p', 'q'], ['p', 'q', 'r'], ['p', 'q', 'r', 's'], ['p', 'q', 'r', 't'], ['q'], ['q', 'r'], ['q', 'r', 's'], ['q', 'r', 't'], ['r'], ['r', 's'], ['r', 't'], ['s'], ['t'], ['u'], ['u', 'v'], ['u', 'v', 'w'], ['u', 'v', 'w', 'x'], ['u', 'v', 'w', 'y'], ['v'], ['v', 'w'], ['v', 'w', 'x'], ['v', 'w', 'y'], ['w'], ['w', 'x'], ['w', 'y'], ['x'], ['y']]) == [['p'], ['s'], ['t'], ['u'], ['x'], ['y']]\n assert candidate(paths = [['level1', 'level2', 'level3', 'level4'], ['level1', 'level2', 'level5', 'level4'], ['level1', 'level6', 'level3', 'level4'], ['level1', 'level6', 'level5', 'level4'], ['level1', 'level7', 'level8'], ['level1', 'level9', 'level10', 'level11'], ['level1', 'level9', 'level10', 'level12']]) == [['level1', 'level7', 'level8'], ['level1', 'level7'], ['level1', 'level9', 'level10', 'level11'], ['level1', 'level9', 'level10', 'level12'], ['level1', 'level9', 'level10'], ['level1', 'level9'], ['level1']]\n assert candidate(paths = [['system', 'folderA'], ['system', 'folderB'], ['system', 'folderA', 'subfolderA1'], ['system', 'folderB', 'subfolderA1'], ['system', 'folderA', 'subfolderA2'], ['system', 'folderB', 'subfolderA2'], ['system', 'folderA', 'subfolderA1', 'subsubfolderA1'], ['system', 'folderB', 'subfolderA1', 'subsubfolderA1'], ['system', 'folderA', 'subfolderA1', 'subsubfolderA2'], ['system', 'folderB', 'subfolderA1', 'subsubfolderA2'], ['system', 'folderA', 'subfolderA2', 'subsubfolderA1'], ['system', 'folderB', 'subfolderA2', 'subsubfolderA1'], ['system', 'folderA', 'subfolderA2', 'subsubfolderA2'], ['system', 'folderB', 'subfolderA2', 'subsubfolderA2']]) == [['system']]\n assert candidate(paths = [['home', 'user', 'docs'], ['home', 'user', 'photos'], ['home', 'guest', 'docs'], ['home', 'guest', 'photos'], ['home', 'user', 'docs', 'file1'], ['home', 'guest', 'docs', 'file1'], ['home', 'user', 'photos', 'image1'], ['home', 'guest', 'photos', 'image1'], ['home', 'user', 'docs', 'file2'], ['home', 'guest', 'docs', 'file2']]) == [['home']]\n assert candidate(paths = [['projects', 'proj1'], ['projects', 'proj2'], ['projects', 'proj1', 'src'], ['projects', 'proj2', 'src'], ['projects', 'proj1', 'src', 'main'], ['projects', 'proj2', 'src', 'main'], ['projects', 'proj1', 'src', 'test'], ['projects', 'proj2', 'src', 'test'], ['projects', 'proj1', 'src', 'main', 'file1'], ['projects', 'proj2', 'src', 'main', 'file1'], ['projects', 'proj1', 'src', 'test', 'test1'], ['projects', 'proj2', 'src', 'test', 'test1']]) == [['projects']]\n assert candidate(paths = [['alpha'], ['alpha', 'beta'], ['alpha', 'beta', 'gamma'], ['alpha', 'beta', 'delta'], ['alpha', 'epsilon'], ['alpha', 'epsilon', 'gamma'], ['alpha', 'epsilon', 'delta'], ['beta'], ['beta', 'gamma'], ['beta', 'delta'], ['epsilon'], ['epsilon', 'gamma'], ['epsilon', 'delta'], ['gamma'], ['delta'], ['charlie'], ['charlie', 'foxtrot'], ['charlie', 'foxtrot', 'gamma'], ['charlie', 'foxtrot', 'delta'], ['charlie', 'tango'], ['charlie', 'tango', 'gamma'], ['charlie', 'tango', 'delta']]) == [['alpha'], ['charlie'], ['delta'], ['gamma']]\n assert candidate(paths = [['project'], ['project', 'src'], ['project', 'docs'], ['project', 'src', 'main'], ['project', 'src', 'test'], ['project', 'docs', 'api'], ['project', 'docs', 'userguide'], ['project', 'src', 'main', 'java'], ['project', 'src', 'test', 'java'], ['project', 'docs', 'api', 'java'], ['project', 'docs', 'userguide', 'java'], ['project', 'src', 'main', 'java', 'utils'], ['project', 'src', 'test', 'java', 'utils'], ['project', 'docs', 'api', 'java', 'utils'], ['project', 'docs', 'userguide', 'java', 'utils']]) == [['project', 'docs'], ['project', 'src'], ['project']]\n assert candidate(paths = [['data', 'archive'], ['data', 'archive', '2021'], ['data', 'archive', '2022'], ['data', 'archive', '2023'], ['data', 'backup'], ['data', 'backup', '2021'], ['data', 'backup', '2022'], ['data', 'backup', '2023'], ['data', 'logs'], ['data', 'logs', 'server1'], ['data', 'logs', 'server2'], ['data', 'logs', 'server3'], ['data', 'temp'], ['data', 'temp', 'server1'], ['data', 'temp', 'server2'], ['data', 'temp', 'server3']]) == [['data']]\n assert candidate(paths = [['app'], ['app', 'module1'], ['app', 'module2'], ['app', 'module1', 'component1'], ['app', 'module2', 'component1'], ['app', 'module1', 'component2'], ['app', 'module2', 'component2'], ['app', 'module1', 'component1', 'subcomponent1'], ['app', 'module2', 'component1', 'subcomponent1'], ['app', 'module1', 'component2', 'subcomponent1'], ['app', 'module2', 'component2', 'subcomponent1'], ['app', 'module1', 'component1', 'subcomponent2'], ['app', 'module2', 'component1', 'subcomponent2'], ['app', 'module1', 'component2', 'subcomponent2'], ['app', 'module2', 'component2', 'subcomponent2'], ['app', 'module1', 'component1', 'subcomponent2', 'deep1'], ['app', 'module2', 'component1', 'subcomponent2', 'deep1']]) == [['app']]\n assert candidate(paths = [['root', 'a'], ['root', 'b'], ['root', 'a', 'c'], ['root', 'b', 'c'], ['root', 'a', 'd'], ['root', 'b', 'd'], ['root', 'a', 'c', 'e'], ['root', 'b', 'c', 'e']]) == [['root']]\n assert candidate(paths = [['root', 'folder1'], ['root', 'folder2'], ['root', 'folder1', 'subfolder1'], ['root', 'folder2', 'subfolder1'], ['root', 'folder1', 'subfolder1', 'subsubfolder1'], ['root', 'folder2', 'subfolder1', 'subsubfolder1'], ['root', 'unique', 'folder1'], ['root', 'unique', 'folder1', 'subfolder1'], ['root', 'unique', 'folder1', 'subfolder1', 'subsubfolder1']]) == [['root', 'unique'], ['root']]\n assert candidate(paths = [['home'], ['home', 'user1'], ['home', 'user2'], ['home', 'user1', 'files'], ['home', 'user2', 'files'], ['home', 'user1', 'files', 'docs'], ['home', 'user2', 'files', 'docs'], ['home', 'user1', 'files', 'docs', 'report1'], ['home', 'user2', 'files', 'docs', 'report1'], ['home', 'user1', 'files', 'docs', 'report2'], ['home', 'user2', 'files', 'docs', 'report2']]) == [['home']]\n assert candidate(paths = [['x'], ['y'], ['z'], ['x', 'a'], ['y', 'a'], ['z', 'a'], ['x', 'a', 'b'], ['y', 'a', 'b'], ['z', 'a', 'b'], ['x', 'a', 'b', 'c'], ['y', 'a', 'b', 'c'], ['z', 'a', 'b', 'c'], ['x', 'd'], ['y', 'e'], ['z', 'f']]) == [['x', 'd'], ['x'], ['y', 'e'], ['y'], ['z', 'f'], ['z']]\n assert candidate(paths = [['root', 'a', 'b', 'c', 'd'], ['root', 'x', 'y', 'z', 'w'], ['root', 'a', 'b', 'c', 'd', 'e'], ['root', 'x', 'y', 'z', 'w', 'v'], ['root', 'a', 'b', 'f'], ['root', 'x', 'y', 'f'], ['root', 'a', 'g'], ['root', 'x', 'g'], ['root', 'a', 'h'], ['root', 'x', 'h'], ['root', 'a', 'i', 'j'], ['root', 'x', 'i', 'j'], ['root', 'a', 'i', 'k'], ['root', 'x', 'i', 'k']]) == [['root', 'a', 'b', 'c', 'd', 'e'], ['root', 'a', 'b', 'c', 'd'], ['root', 'a', 'b', 'c'], ['root', 'a', 'b', 'f'], ['root', 'a', 'b'], ['root', 'a', 'g'], ['root', 'a', 'h'], ['root', 'a'], ['root', 'x', 'g'], ['root', 'x', 'h'], ['root', 'x', 'y', 'f'], ['root', 'x', 'y', 'z', 'w', 'v'], ['root', 'x', 'y', 'z', 'w'], ['root', 'x', 'y', 'z'], ['root', 'x', 'y'], ['root', 'x'], ['root']]\n assert candidate(paths = [['root'], ['root', 'folder1'], ['root', 'folder2'], ['root', 'folder1', 'sub1'], ['root', 'folder2', 'sub1'], ['root', 'folder1', 'sub1', 'subsub1'], ['root', 'folder2', 'sub1', 'subsub1']]) == [['root']]\n assert candidate(paths = [['base'], ['base', 'folder1'], ['base', 'folder1', 'subfolder1'], ['base', 'folder1', 'subfolder2'], ['base', 'folder2'], ['base', 'folder2', 'subfolder1'], ['base', 'folder2', 'subfolder2'], ['base', 'folder3'], ['base', 'folder3', 'subfolder1'], ['base', 'folder3', 'subfolder2'], ['base', 'folder1', 'subfolder1', 'deep1'], ['base', 'folder2', 'subfolder1', 'deep1'], ['base', 'folder3', 'subfolder1', 'deep1']]) == [['base']]\n assert candidate(paths = [['system'], ['system', 'app1'], ['system', 'app1', 'data'], ['system', 'app2'], ['system', 'app2', 'data'], ['system', 'app3'], ['system', 'app3', 'data'], ['system', 'app3', 'logs'], ['system', 'app4'], ['system', 'app4', 'data'], ['system', 'app4', 'logs'], ['system', 'app4', 'temp'], ['system', 'app5'], ['system', 'app5', 'data'], ['system', 'app5', 'logs'], ['system', 'app5', 'temp'], ['system', 'app6'], ['system', 'app6', 'data'], ['system', 'app6', 'logs'], ['system', 'app6', 'temp'], ['system', 'app6', 'config'], ['system', 'app7'], ['system', 'app7', 'data'], ['system', 'app7', 'logs'], ['system', 'app7', 'temp'], ['system', 'app7', 'config'], ['system', 'app8'], ['system', 'app8', 'data'], ['system', 'app8', 'logs'], ['system', 'app8', 'temp'], ['system', 'app8', 'config'], ['system', 'app8', 'bin']]) == [['system', 'app3', 'data'], ['system', 'app3', 'logs'], ['system', 'app3'], ['system', 'app8', 'bin'], ['system', 'app8', 'config'], ['system', 'app8', 'data'], ['system', 'app8', 'logs'], ['system', 'app8', 'temp'], ['system', 'app8'], ['system']]\n assert candidate(paths = [['root', 'x'], ['root', 'y'], ['root', 'x', 'z'], ['root', 'y', 'z'], ['root', 'x', 'a'], ['root', 'y', 'a'], ['root', 'x', 'a', 'b'], ['root', 'y', 'a', 'b']]) == [['root']]\n assert candidate(paths = [['root', 'level1', 'level2', 'level3'], ['root', 'level1', 'level2', 'level4'], ['root', 'level5', 'level6'], ['root', 'level1', 'level2', 'level3', 'level7'], ['root', 'level5', 'level6', 'level7'], ['root', 'level1', 'level2', 'level3', 'level7', 'level8'], ['root', 'level5', 'level6', 'level7', 'level8']]) == [['root', 'level1', 'level2', 'level4'], ['root', 'level1', 'level2'], ['root', 'level1'], ['root', 'level5'], ['root']]\n assert candidate(paths = [['data'], ['data', 'backup'], ['data', 'backup', '2021'], ['data', 'backup', '2022'], ['data', 'backup', '2021', 'month1'], ['data', 'backup', '2022', 'month1'], ['data', 'backup', '2021', 'month2'], ['data', 'backup', '2022', 'month2'], ['data', 'backup', '2021', 'month1', 'day1'], ['data', 'backup', '2022', 'month1', 'day1'], ['data', 'backup', '2021', 'month1', 'day2'], ['data', 'backup', '2022', 'month1', 'day2'], ['data', 'backup', '2021', 'month2', 'day1'], ['data', 'backup', '2022', 'month2', 'day1'], ['data', 'backup', '2021', 'month2', 'day2'], ['data', 'backup', '2022', 'month2', 'day2'], ['data', 'backup', '2021', 'month1', 'day1', 'file1'], ['data', 'backup', '2022', 'month1', 'day1', 'file1'], ['data', 'backup', '2021', 'month1', 'day2', 'file1'], ['data', 'backup', '2022', 'month1', 'day2', 'file1'], ['data', 'backup', '2021', 'month2', 'day1', 'file1'], ['data', 'backup', '2022', 'month2', 'day1', 'file1'], ['data', 'backup', '2021', 'month2', 'day2', 'file1'], ['data', 'backup', '2022', 'month2', 'day2', 'file1']]) == [['data', 'backup'], ['data']]\n assert candidate(paths = [['root', 'dir1', 'subdir1'], ['root', 'dir1', 'subdir2'], ['root', 'dir2', 'subdir1'], ['root', 'dir2', 'subdir3'], ['root', 'dir3', 'subdir2'], ['root', 'dir3', 'subdir4']]) == [['root', 'dir1', 'subdir1'], ['root', 'dir1', 'subdir2'], ['root', 'dir1'], ['root', 'dir2', 'subdir1'], ['root', 'dir2', 'subdir3'], ['root', 'dir2'], ['root', 'dir3', 'subdir2'], ['root', 'dir3', 'subdir4'], ['root', 'dir3'], ['root']]\n assert candidate(paths = [['x'], ['x', 'y'], ['x', 'y', 'z'], ['x', 'y', 'w'], ['y'], ['y', 'z'], ['y', 'w'], ['a'], ['a', 'b'], ['a', 'b', 'c'], ['b'], ['b', 'c'], ['b', 'd'], ['c'], ['c', 'd'], ['d']]) == [['a', 'b', 'c'], ['a', 'b'], ['a'], ['b', 'c'], ['b', 'd'], ['b'], ['c', 'd'], ['c'], ['d'], ['x']]\n assert candidate(paths = [['base', 'level1', 'level2', 'level3'], ['other', 'level1', 'level2', 'level3'], ['base', 'level1', 'level2', 'level3', 'level4'], ['other', 'level1', 'level2', 'level3', 'level4'], ['base', 'level1', 'level2', 'level3', 'level4', 'level5'], ['other', 'level1', 'level2', 'level3', 'level4', 'level5'], ['base', 'level1', 'level2', 'other'], ['other', 'level1', 'level2', 'other']]) == []\n assert candidate(paths = [['home', 'user1', 'documents'], ['home', 'user2', 'documents'], ['home', 'user1', 'documents', 'file1'], ['home', 'user2', 'documents', 'file1'], ['home', 'user1', 'pictures'], ['home', 'user2', 'pictures'], ['home', 'user1', 'pictures', 'photo1'], ['home', 'user2', 'pictures', 'photo1']]) == [['home']]\n assert candidate(paths = [['nested', 'folder1'], ['nested', 'folder2'], ['nested', 'folder1', 'subfolder1'], ['nested', 'folder2', 'subfolder1'], ['nested', 'folder1', 'subfolder1', 'subsubfolder1'], ['nested', 'folder2', 'subfolder1', 'subsubfolder1'], ['nested', 'folder1', 'subfolder2'], ['nested', 'folder2', 'subfolder2'], ['nested', 'folder1', 'subfolder2', 'subsubfolder2'], ['nested', 'folder2', 'subfolder2', 'subsubfolder2'], ['nested', 'folder1', 'subfolder2', 'subsubfolder2', 'file1'], ['nested', 'folder2', 'subfolder2', 'subsubfolder2', 'file1']]) == [['nested']]\n assert candidate(paths = [['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h'], ['a', 'b', 'c', 'd', 'f'], ['f', 'g', 'h', 'i'], ['a', 'b', 'c', 'd', 'j'], ['j', 'k'], ['f', 'g', 'h', 'i', 'k']]) == [['a', 'b', 'c', 'd', 'e'], ['a', 'b', 'c', 'd', 'f'], ['a', 'b', 'c', 'd', 'j'], ['a', 'b', 'c', 'd'], ['a', 'b', 'c'], ['a', 'b'], ['a'], ['f', 'g', 'h'], ['f', 'g'], ['f']]\n assert candidate(paths = [['root', 'a', 'b', 'c'], ['root', 'x', 'y', 'z'], ['root', 'a', 'b', 'd'], ['root', 'x', 'y', 'd'], ['root', 'a', 'b', 'c', 'e'], ['root', 'x', 'y', 'z', 'e'], ['root', 'a', 'b', 'c', 'f'], ['root', 'x', 'y', 'z', 'f'], ['root', 'a', 'g'], ['root', 'x', 'g'], ['root', 'a', 'h'], ['root', 'x', 'h']]) == [['root', 'a', 'b', 'd'], ['root', 'a', 'b'], ['root', 'a', 'g'], ['root', 'a', 'h'], ['root', 'a'], ['root', 'x', 'g'], ['root', 'x', 'h'], ['root', 'x', 'y', 'd'], ['root', 'x', 'y'], ['root', 'x'], ['root']]\n assert candidate(paths = [['library', 'books', 'genre1'], ['library', 'books', 'genre2'], ['library', 'books', 'genre3'], ['library', 'books', 'genre1', 'author1'], ['library', 'books', 'genre3', 'author1'], ['library', 'books', 'genre2', 'author2'], ['library', 'books', 'genre3', 'author2'], ['library', 'books', 'genre1', 'author1', 'book1'], ['library', 'books', 'genre3', 'author1', 'book1']]) == [['library', 'books', 'genre1'], ['library', 'books', 'genre2', 'author2'], ['library', 'books', 'genre2'], ['library', 'books', 'genre3', 'author2'], ['library', 'books', 'genre3'], ['library', 'books'], ['library']]\n assert candidate(paths = [['a'], ['a', 'b'], ['a', 'b', 'c'], ['a', 'b', 'c', 'd'], ['a', 'b', 'c', 'd', 'e'], ['b'], ['b', 'c'], ['b', 'c', 'd'], ['b', 'c', 'd', 'e'], ['c'], ['c', 'd'], ['c', 'd', 'e'], ['d'], ['d', 'e'], ['e']]) == [['a'], ['e']]\n assert candidate(paths = [['folder1'], ['folder1', 'folder2'], ['folder1', 'folder2', 'folder3'], ['folder1', 'folder2', 'folder3', 'folder4'], ['folder1', 'folder2', 'folder3', 'folder5'], ['folder1', 'folder2', 'folder6'], ['folder1', 'folder2', 'folder6', 'folder7'], ['folder1', 'folder2', 'folder6', 'folder8'], ['folder1', 'folder9'], ['folder1', 'folder9', 'folder10'], ['folder1', 'folder9', 'folder10', 'folder11'], ['folder1', 'folder9', 'folder10', 'folder12'], ['folder1', 'folder9', 'folder13'], ['folder1', 'folder9', 'folder13', 'folder14'], ['folder1', 'folder9', 'folder13', 'folder15']]) == [['folder1', 'folder2', 'folder3', 'folder4'], ['folder1', 'folder2', 'folder3', 'folder5'], ['folder1', 'folder2', 'folder3'], ['folder1', 'folder2', 'folder6', 'folder7'], ['folder1', 'folder2', 'folder6', 'folder8'], ['folder1', 'folder2', 'folder6'], ['folder1', 'folder2'], ['folder1', 'folder9', 'folder10', 'folder11'], ['folder1', 'folder9', 'folder10', 'folder12'], ['folder1', 'folder9', 'folder10'], ['folder1', 'folder9', 'folder13', 'folder14'], ['folder1', 'folder9', 'folder13', 'folder15'], ['folder1', 'folder9', 'folder13'], ['folder1', 'folder9'], ['folder1']]\n assert candidate(paths = [['projects', 'projectA'], ['projects', 'projectB'], ['projects', 'projectA', 'src'], ['projects', 'projectB', 'src'], ['projects', 'projectA', 'src', 'module1'], ['projects', 'projectB', 'src', 'module1'], ['projects', 'projectA', 'src', 'module2'], ['projects', 'projectB', 'src', 'module2'], ['projects', 'projectA', 'src', 'module1', 'file1'], ['projects', 'projectB', 'src', 'module1', 'file1'], ['projects', 'projectA', 'src', 'module2', 'file2'], ['projects', 'projectB', 'src', 'module2', 'file3'], ['projects', 'projectA', 'src', 'module1', 'file4'], ['projects', 'projectB', 'src', 'module1', 'file5']]) == [['projects', 'projectA', 'src', 'module1', 'file1'], ['projects', 'projectA', 'src', 'module1', 'file4'], ['projects', 'projectA', 'src', 'module1'], ['projects', 'projectA', 'src', 'module2', 'file2'], ['projects', 'projectA', 'src', 'module2'], ['projects', 'projectA', 'src'], ['projects', 'projectA'], ['projects', 'projectB', 'src', 'module1', 'file1'], ['projects', 'projectB', 'src', 'module1', 'file5'], ['projects', 'projectB', 'src', 'module1'], ['projects', 'projectB', 'src', 'module2', 'file3'], ['projects', 'projectB', 'src', 'module2'], ['projects', 'projectB', 'src'], ['projects', 'projectB'], ['projects']]\n assert candidate(paths = [['dir1'], ['dir2'], ['dir3'], ['dir1', 'sub1'], ['dir2', 'sub2'], ['dir3', 'sub1'], ['dir1', 'sub1', 'subsub1'], ['dir2', 'sub2', 'subsub2'], ['dir3', 'sub1', 'subsub1'], ['dir1', 'sub1', 'subsub1', 'deeper1'], ['dir3', 'sub1', 'subsub1', 'deeper1']]) == [['dir2', 'sub2', 'subsub2'], ['dir2', 'sub2'], ['dir2']]\n assert candidate(paths = [['a'], ['a', 'b'], ['a', 'b', 'c'], ['a', 'b', 'd'], ['b'], ['b', 'c'], ['b', 'd'], ['c'], ['c', 'a'], ['c', 'a', 'b'], ['d'], ['d', 'a'], ['d', 'a', 'b']]) == [['a']]\n assert candidate(paths = [['root', 'folder1', 'subfolder1', 'subsubfolder1'], ['root', 'folder2', 'subfolder2', 'subsubfolder1'], ['root', 'folder3', 'subfolder3'], ['root', 'folder1', 'subfolder1'], ['root', 'folder2', 'subfolder2']]) == [['root', 'folder1'], ['root', 'folder2'], ['root', 'folder3', 'subfolder3'], ['root', 'folder3'], ['root']]\n assert candidate(paths = [['folderA'], ['folderB'], ['folderA', 'subA'], ['folderB', 'subA'], ['folderA', 'subA', 'subsubA'], ['folderB', 'subA', 'subsubA'], ['folderC'], ['folderC', 'subB'], ['folderD'], ['folderD', 'subB', 'subsubB'], ['folderE'], ['folderE', 'subB', 'subsubB', 'deepB']]) == [['folderC', 'subB'], ['folderC'], ['folderD', 'subB', 'subsubB'], ['folderD', 'subB'], ['folderD'], ['folderE', 'subB', 'subsubB', 'deepB'], ['folderE', 'subB', 'subsubB'], ['folderE', 'subB'], ['folderE']]\n assert candidate(paths = [['main'], ['main', 'projects'], ['main', 'projects', 'project1'], ['main', 'projects', 'project2'], ['main', 'projects', 'project1', 'code'], ['main', 'projects', 'project2', 'code'], ['main', 'docs'], ['main', 'docs', 'project1'], ['main', 'docs', 'project2'], ['main', 'docs', 'project1', 'notes'], ['main', 'docs', 'project2', 'notes']]) == [['main', 'docs'], ['main', 'projects'], ['main']]\n assert candidate(paths = [['folder1', 'subfolder1', 'deepsub1'], ['folder2', 'subfolder2', 'deepsub2'], ['folder1', 'subfolder1', 'deepsub3'], ['folder2', 'subfolder2', 'deepsub3'], ['folder1', 'subfolder2'], ['folder2', 'subfolder2'], ['folder3', 'subfolder3']]) == [['folder1', 'subfolder1', 'deepsub1'], ['folder1', 'subfolder1', 'deepsub3'], ['folder1', 'subfolder1'], ['folder1', 'subfolder2'], ['folder1'], ['folder2', 'subfolder2', 'deepsub2'], ['folder2', 'subfolder2', 'deepsub3'], ['folder2', 'subfolder2'], ['folder2'], ['folder3', 'subfolder3'], ['folder3']]\n assert candidate(paths = [['parent', 'child1', 'grandchild1'], ['parent', 'child2', 'grandchild1'], ['parent', 'child1', 'grandchild2'], ['parent', 'child2', 'grandchild2'], ['parent', 'child1', 'grandchild3'], ['parent', 'child2', 'grandchild3'], ['parent', 'child1', 'subchild1', 'subsubchild1'], ['parent', 'child2', 'subchild1', 'subsubchild1'], ['parent', 'child1', 'subchild2', 'subsubchild2'], ['parent', 'child2', 'subchild2', 'subsubchild2']]) == [['parent']]\n assert candidate(paths = [['root', 'a', 'x'], ['root', 'b', 'x'], ['root', 'a', 'y'], ['root', 'b', 'y'], ['root', 'a', 'x', 'z'], ['root', 'b', 'x', 'z'], ['root', 'a', 'w'], ['root', 'b', 'w']]) == [['root']]\n assert candidate(paths = [['a', 'b', 'c'], ['a', 'd', 'e'], ['a', 'd', 'e', 'f'], ['g', 'h', 'i'], ['g', 'j', 'k'], ['g', 'j', 'l'], ['a', 'b', 'c', 'm'], ['g', 'h', 'i', 'm'], ['n', 'o', 'p'], ['n', 'o', 'q'], ['n', 'r', 's'], ['n', 'r', 's', 't']]) == [['a', 'b'], ['a', 'd', 'e', 'f'], ['a', 'd', 'e'], ['a', 'd'], ['a'], ['g', 'h'], ['g', 'j', 'k'], ['g', 'j', 'l'], ['g', 'j'], ['g'], ['n', 'o', 'p'], ['n', 'o', 'q'], ['n', 'o'], ['n', 'r', 's', 't'], ['n', 'r', 's'], ['n', 'r'], ['n']]\n assert candidate(paths = [['x'], ['x', 'y'], ['x', 'y', 'z'], ['x', 'y', 'z', 'w'], ['y'], ['y', 'z'], ['y', 'z', 'w'], ['z'], ['z', 'w'], ['w']]) == [['w'], ['x']]\n assert candidate(paths = [['main', 'branch1'], ['main', 'branch2'], ['main', 'branch1', 'sub1'], ['main', 'branch2', 'sub1'], ['main', 'branch1', 'sub2'], ['main', 'branch2', 'sub2'], ['main', 'branch1', 'sub1', 'subsub1'], ['main', 'branch2', 'sub1', 'subsub1'], ['main', 'branch1', 'sub1', 'subsub2'], ['main', 'branch2', 'sub1', 'subsub2']]) == [['main']]\n assert candidate(paths = [['x'], ['y'], ['z'], ['x', 'a'], ['y', 'a'], ['z', 'a'], ['x', 'a', 'b'], ['y', 'a', 'b'], ['x', 'a', 'b', 'c'], ['y', 'a', 'b', 'c'], ['w'], ['w', 'd'], ['w', 'd', 'e'], ['w', 'd', 'e', 'f'], ['v'], ['v', 'd'], ['v', 'd', 'e'], ['v', 'd', 'e', 'f']]) == [['z', 'a'], ['z']]\n assert candidate(paths = [['level1'], ['level1', 'level2'], ['level1', 'level2', 'level3'], ['level1', 'level2', 'level3', 'level4'], ['level1', 'level2', 'level3', 'level4', 'level5'], ['levelA'], ['levelA', 'level2'], ['levelA', 'level2', 'level3'], ['levelA', 'level2', 'level3', 'level4'], ['levelA', 'level2', 'level3', 'level4', 'level5']]) == []\n assert candidate(paths = [['root'], ['root', 'dir1'], ['root', 'dir1', 'subdir1'], ['root', 'dir2'], ['root', 'dir2', 'subdir1'], ['root', 'dir2', 'subdir2'], ['root', 'dir3'], ['root', 'dir3', 'subdir2'], ['root', 'dir4'], ['root', 'dir4', 'subdir1'], ['root', 'dir4', 'subdir2']]) == [['root', 'dir1', 'subdir1'], ['root', 'dir1'], ['root', 'dir3', 'subdir2'], ['root', 'dir3'], ['root']]\n assert candidate(paths = [['root', 'folder1', 'subfolder1'], ['root', 'folder2', 'subfolder1'], ['root', 'folder3', 'subfolder2'], ['root', 'folder3', 'subfolder2', 'deepsubfolder1'], ['root', 'folder4', 'subfolder2', 'deepsubfolder1'], ['root', 'folder5', 'subfolder2', 'deepsubfolder1', 'deeper1']]) == [['root', 'folder5', 'subfolder2', 'deepsubfolder1', 'deeper1'], ['root', 'folder5', 'subfolder2', 'deepsubfolder1'], ['root', 'folder5', 'subfolder2'], ['root', 'folder5'], ['root']]\n assert candidate(paths = [['home', 'user1', 'docs'], ['home', 'user2', 'docs'], ['home', 'user1', 'music'], ['home', 'user2', 'music'], ['home', 'user1', 'docs', 'report'], ['home', 'user2', 'docs', 'report'], ['home', 'user1', 'music', 'song1'], ['home', 'user2', 'music', 'song2'], ['home', 'user1', 'docs', 'report', 'summary'], ['home', 'user2', 'docs', 'report', 'summary'], ['home', 'user1', 'docs', 'report', 'summary', 'details'], ['home', 'user2', 'docs', 'report', 'summary', 'details']]) == [['home', 'user1', 'music', 'song1'], ['home', 'user1', 'music'], ['home', 'user1'], ['home', 'user2', 'music', 'song2'], ['home', 'user2', 'music'], ['home', 'user2'], ['home']]\n assert candidate(paths = [['main', 'project', 'src', 'module1'], ['main', 'project', 'src', 'module2'], ['main', 'project', 'src', 'module1', 'submodule1'], ['main', 'project', 'src', 'module2', 'submodule1'], ['main', 'project', 'src', 'module1', 'submodule2'], ['main', 'project', 'src', 'module2', 'submodule2'], ['main', 'project', 'src', 'module1', 'submodule1', 'subsubmodule1'], ['main', 'project', 'src', 'module2', 'submodule1', 'subsubmodule1'], ['main', 'unique', 'project', 'src', 'module1'], ['main', 'unique', 'project', 'src', 'module1', 'submodule1'], ['main', 'unique', 'project', 'src', 'module1', 'submodule1', 'subsubmodule1']]) == [['main', 'project', 'src'], ['main', 'project'], ['main', 'unique', 'project', 'src', 'module1'], ['main', 'unique', 'project', 'src'], ['main', 'unique', 'project'], ['main', 'unique'], ['main']]\n assert candidate(paths = [['projects', 'proj1', 'src'], ['projects', 'proj2', 'src'], ['projects', 'proj3'], ['projects', 'proj1', 'src', 'main'], ['projects', 'proj2', 'src', 'main'], ['projects', 'proj1', 'docs'], ['projects', 'proj2', 'docs'], ['projects', 'proj3', 'docs']]) == [['projects', 'proj3', 'docs'], ['projects', 'proj3'], ['projects']]\n assert candidate(paths = [['alpha'], ['beta'], ['gamma'], ['alpha', 'delta'], ['beta', 'delta'], ['gamma', 'epsilon'], ['alpha', 'delta', 'zeta'], ['beta', 'delta', 'zeta'], ['alpha', 'delta', 'zeta', 'eta'], ['beta', 'delta', 'zeta', 'eta'], ['alpha', 'theta'], ['beta', 'theta'], ['gamma', 'theta']]) == [['gamma', 'epsilon'], ['gamma', 'theta'], ['gamma']]\n assert candidate(paths = [['project'], ['project', 'module1'], ['project', 'module1', 'file1'], ['project', 'module2'], ['project', 'module2', 'file1'], ['project', 'module3'], ['project', 'module3', 'file2'], ['project', 'module4'], ['project', 'module4', 'file3'], ['project', 'module5'], ['project', 'module5', 'file3'], ['project', 'module6'], ['project', 'module6', 'file4'], ['project', 'module7'], ['project', 'module7', 'file4'], ['project', 'module8'], ['project', 'module8', 'file5'], ['project', 'module8', 'file6']]) == [['project', 'module3', 'file2'], ['project', 'module3'], ['project', 'module8', 'file5'], ['project', 'module8', 'file6'], ['project', 'module8'], ['project']]\n assert candidate(paths = [['app', 'module1', 'service1'], ['app', 'module2', 'service2'], ['app', 'module3', 'service1'], ['app', 'module4', 'service4'], ['app', 'module1', 'service1', 'endpoint1'], ['app', 'module3', 'service1', 'endpoint1'], ['app', 'module5'], ['app', 'module5', 'endpoint2']]) == [['app', 'module2', 'service2'], ['app', 'module2'], ['app', 'module4', 'service4'], ['app', 'module4'], ['app', 'module5', 'endpoint2'], ['app', 'module5'], ['app']]\n assert candidate(paths = [['root', 'dir1', 'subdir1'], ['root', 'dir2', 'subdir1'], ['root', 'dir1', 'subdir2'], ['root', 'dir2', 'subdir2'], ['root', 'dir1', 'subdir1', 'subsubdir1'], ['root', 'dir2', 'subdir1', 'subsubdir1'], ['root', 'dir1', 'subdir3'], ['root', 'dir2', 'subdir3']]) == [['root']]\n assert candidate(paths = [['root'], ['root', 'child1'], ['root', 'child2'], ['root', 'child1', 'sub1'], ['root', 'child2', 'sub1'], ['root', 'child1', 'sub1', 'subsub1'], ['root', 'child2', 'sub1', 'subsub1'], ['root', 'child1', 'sub2'], ['root', 'child2', 'sub2'], ['root', 'child1', 'sub2', 'subsub2'], ['root', 'child2', 'sub2', 'subsub2'], ['root', 'child3'], ['root', 'child3', 'sub1'], ['root', 'child3', 'sub1', 'subsub1'], ['root', 'child3', 'sub2'], ['root', 'child3', 'sub2', 'subsub2']]) == [['root']]\n assert candidate(paths = [['home'], ['home', 'user1'], ['home', 'user1', 'documents'], ['home', 'user1', 'pictures'], ['home', 'user2'], ['home', 'user2', 'documents'], ['home', 'user2', 'pictures'], ['home', 'user3'], ['home', 'user3', 'documents'], ['home', 'user3', 'pictures'], ['home', 'user3', 'videos'], ['home', 'user4'], ['home', 'user4', 'documents'], ['home', 'user4', 'pictures'], ['home', 'user4', 'videos'], ['home', 'user5'], ['home', 'user5', 'documents'], ['home', 'user5', 'pictures'], ['home', 'user5', 'videos'], ['home', 'user6'], ['home', 'user6', 'documents'], ['home', 'user6', 'pictures'], ['home', 'user6', 'videos'], ['home', 'user6', 'music']]) == [['home', 'user6', 'documents'], ['home', 'user6', 'music'], ['home', 'user6', 'pictures'], ['home', 'user6', 'videos'], ['home', 'user6'], ['home']]\n assert candidate(paths = [['documents', 'work', 'reports'], ['documents', 'work', 'reports', 'monthly'], ['documents', 'work', 'reports', 'monthly', 'jan'], ['documents', 'work', 'reports', 'monthly', 'feb'], ['documents', 'work', 'reports', 'monthly', 'mar'], ['documents', 'home', 'reports'], ['documents', 'home', 'reports', 'monthly'], ['documents', 'home', 'reports', 'monthly', 'jan'], ['documents', 'home', 'reports', 'monthly', 'feb'], ['documents', 'home', 'reports', 'monthly', 'mar'], ['documents', 'finance', 'reports'], ['documents', 'finance', 'reports', 'monthly'], ['documents', 'finance', 'reports', 'monthly', 'jan'], ['documents', 'finance', 'reports', 'monthly', 'feb'], ['documents', 'finance', 'reports', 'monthly', 'mar']]) == [['documents']]\n assert candidate(paths = [['root', 'folder1', 'sub1'], ['root', 'folder2', 'sub1'], ['root', 'folder1', 'sub2'], ['root', 'folder2', 'sub2'], ['root', 'folder3', 'sub1'], ['root', 'folder4', 'sub1'], ['root', 'folder3', 'sub3'], ['root', 'folder4', 'sub3']]) == [['root']]\n assert candidate(paths = [['home', 'user1', 'docs', 'work'], ['home', 'user2', 'docs', 'work'], ['home', 'user1', 'docs', 'projects'], ['home', 'user2', 'docs', 'projects'], ['home', 'user1', 'downloads', 'movies'], ['home', 'user2', 'downloads', 'movies'], ['home', 'user1', 'downloads', 'music'], ['home', 'user2', 'downloads', 'music'], ['home', 'user1', 'pictures', 'vacation'], ['home', 'user2', 'pictures', 'vacation'], ['home', 'user1', 'pictures', 'wedding'], ['home', 'user2', 'pictures', 'wedding']]) == [['home']]\n assert candidate(paths = [['library'], ['library', 'section1'], ['library', 'section1', 'shelf1'], ['library', 'section1', 'shelf2'], ['library', 'section1', 'shelf3'], ['library', 'section2'], ['library', 'section2', 'shelf1'], ['library', 'section2', 'shelf2'], ['library', 'section2', 'shelf4'], ['library', 'section3'], ['library', 'section3', 'shelf3'], ['library', 'section3', 'shelf4'], ['library', 'section4'], ['library', 'section4', 'shelf5'], ['library', 'section4', 'shelf6'], ['library', 'section5'], ['library', 'section5', 'shelf5'], ['library', 'section5', 'shelf6'], ['library', 'section6'], ['library', 'section6', 'shelf7'], ['library', 'section6', 'shelf8'], ['library', 'section7'], ['library', 'section7', 'shelf9'], ['library', 'section7', 'shelf10']]) == [['library', 'section1', 'shelf1'], ['library', 'section1', 'shelf2'], ['library', 'section1', 'shelf3'], ['library', 'section1'], ['library', 'section2', 'shelf1'], ['library', 'section2', 'shelf2'], ['library', 'section2', 'shelf4'], ['library', 'section2'], ['library', 'section3', 'shelf3'], ['library', 'section3', 'shelf4'], ['library', 'section3'], ['library', 'section6', 'shelf7'], ['library', 'section6', 'shelf8'], ['library', 'section6'], ['library', 'section7', 'shelf10'], ['library', 'section7', 'shelf9'], ['library', 'section7'], ['library']]\n assert candidate(paths = [['home'], ['home', 'user1'], ['home', 'user2'], ['home', 'user1', 'documents'], ['home', 'user2', 'documents'], ['home', 'user1', 'pictures'], ['home', 'user2', 'pictures'], ['home', 'user1', 'documents', 'work'], ['home', 'user2', 'documents', 'work'], ['home', 'user1', 'documents', 'personal'], ['home', 'user2', 'documents', 'personal'], ['home', 'user1', 'pictures', 'vacation'], ['home', 'user2', 'pictures', 'vacation'], ['home', 'user1', 'pictures', 'travel'], ['home', 'user2', 'pictures', 'travel'], ['home', 'user1', 'pictures', 'travel', '2022'], ['home', 'user2', 'pictures', 'travel', '2022']]) == [['home']]\n assert candidate(paths = [['root'], ['root', 'dir1'], ['root', 'dir2'], ['root', 'dir1', 'dir3'], ['root', 'dir2', 'dir4'], ['root', 'dir2', 'dir3'], ['root', 'dir1', 'dir3', 'dir5'], ['root', 'dir2', 'dir3', 'dir5']]) == [['root', 'dir1'], ['root', 'dir2', 'dir4'], ['root', 'dir2'], ['root']]\n"}, "metadata": {"canonical_parameter_names": ["paths"], "leetcode_dataset_entry_point": "Solution().deleteDuplicateFolder", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def deleteDuplicateFolder(self, paths: list[list[str]]) -> list[list[str]]:", "container": "Solution", "callable": "deleteDuplicateFolder", "parameters": [{"name": "paths", "type": "list[list[str]]"}], "return_type": "list[list[str]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1952, "task_id": "three-divisors", "difficulty": "Easy", "problem_description": "Given an integer n, return true if n has exactly three positive divisors. Otherwise, return false.\nAn integer m is a divisor of n if there exists an integer k such that n = k * m.\n \nExample 1:\n\nInput: n = 2\nOutput: false\nExplantion: 2 has only two divisors: 1 and 2.\n\nExample 2:\n\nInput: n = 4\nOutput: true\nExplantion: 4 has three divisors: 1, 2, and 4.\n\n \nConstraints:\n\n1 <= n <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 625) == False\n assert candidate(n = 3) == False\n assert candidate(n = 576) == False\n assert candidate(n = 729) == False\n assert candidate(n = 144) == False\n assert candidate(n = 49) == True\n assert candidate(n = 900) == False\n assert candidate(n = 324) == False\n assert candidate(n = 100) == False\n assert candidate(n = 841) == True\n assert candidate(n = 5) == False\n assert candidate(n = 289) == True\n assert candidate(n = 4) == True\n assert candidate(n = 64) == False\n assert candidate(n = 16) == False\n assert candidate(n = 10000) == False\n assert candidate(n = 484) == False\n assert candidate(n = 2) == False\n assert candidate(n = 225) == False\n assert candidate(n = 784) == False\n assert candidate(n = 1024) == False\n assert candidate(n = 101) == False\n assert candidate(n = 169) == True\n assert candidate(n = 256) == False\n assert candidate(n = 36) == False\n assert candidate(n = 529) == True\n assert candidate(n = 20) == False\n assert candidate(n = 676) == False\n assert candidate(n = 81) == False\n assert candidate(n = 15) == False\n assert candidate(n = 961) == True\n assert candidate(n = 400) == False\n assert candidate(n = 9) == True\n assert candidate(n = 196) == False\n assert candidate(n = 121) == True\n assert candidate(n = 361) == True\n assert candidate(n = 441) == False\n assert candidate(n = 7) == False\n assert candidate(n = 10) == False\n assert candidate(n = 25) == True\n assert candidate(n = 1089) == False\n assert candidate(n = 7225) == False\n assert candidate(n = 13689) == False\n assert candidate(n = 63841) == False\n assert candidate(n = 73081) == False\n assert candidate(n = 48601) == False\n assert candidate(n = 12544) == False\n assert candidate(n = 14400) == False\n assert candidate(n = 5929) == False\n assert candidate(n = 15625) == False\n assert candidate(n = 4761) == False\n assert candidate(n = 27) == False\n assert candidate(n = 90409) == False\n assert candidate(n = 34081) == False\n assert candidate(n = 66109) == False\n assert candidate(n = 6241) == True\n assert candidate(n = 8821) == False\n assert candidate(n = 16807) == False\n assert candidate(n = 2809) == True\n assert candidate(n = 10201) == True\n assert candidate(n = 11881) == True\n assert candidate(n = 823543) == False\n assert candidate(n = 57201) == False\n assert candidate(n = 1) == False\n assert candidate(n = 9604) == False\n assert candidate(n = 30025) == False\n assert candidate(n = 2601) == False\n assert candidate(n = 68401) == False\n assert candidate(n = 5329) == True\n assert candidate(n = 14641) == False\n assert candidate(n = 3025) == False\n assert candidate(n = 12321) == False\n assert candidate(n = 32041) == True\n assert candidate(n = 1009) == False\n assert candidate(n = 1681) == True\n assert candidate(n = 13456) == False\n assert candidate(n = 1225) == False\n assert candidate(n = 24025) == False\n assert candidate(n = 38161) == False\n assert candidate(n = 7921) == True\n assert candidate(n = 18769) == True\n assert candidate(n = 2401) == False\n assert candidate(n = 10609) == True\n assert candidate(n = 95657) == False\n assert candidate(n = 2025) == False\n assert candidate(n = 5625) == False\n assert candidate(n = 10404) == False\n assert candidate(n = 61609) == False\n assert candidate(n = 4489) == True\n assert candidate(n = 2209) == True\n assert candidate(n = 75469) == False\n assert candidate(n = 8388608) == False\n assert candidate(n = 12769) == True\n assert candidate(n = 52849) == False\n assert candidate(n = 55025) == False\n assert candidate(n = 4225) == False\n assert candidate(n = 3969) == False\n assert candidate(n = 16777216) == False\n assert candidate(n = 11236) == False\n assert candidate(n = 93019) == False\n assert candidate(n = 11449) == True\n assert candidate(n = 343) == False\n assert candidate(n = 42301) == False\n assert candidate(n = 6561) == False\n assert candidate(n = 98329) == False\n assert candidate(n = 36121) == False\n assert candidate(n = 101025) == False\n assert candidate(n = 12996) == False\n assert candidate(n = 12100) == False\n assert candidate(n = 77881) == False\n assert candidate(n = 44389) == False\n assert candidate(n = 14161) == False\n assert candidate(n = 5041) == True\n assert candidate(n = 8361) == False\n assert candidate(n = 85309) == False\n assert candidate(n = 80329) == False\n assert candidate(n = 82801) == False\n assert candidate(n = 2097152) == False\n assert candidate(n = 1849) == True\n assert candidate(n = 3481) == True\n assert candidate(n = 6889) == True\n assert candidate(n = 28099) == False\n assert candidate(n = 46489) == False\n assert candidate(n = 70729) == False\n assert candidate(n = 10816) == False\n assert candidate(n = 22201) == True\n assert candidate(n = 13924) == False\n assert candidate(n = 11025) == False\n assert candidate(n = 4194304) == False\n assert candidate(n = 87841) == False\n assert candidate(n = 1369) == True\n assert candidate(n = 59401) == False\n assert candidate(n = 13225) == False\n assert candidate(n = 40225) == False\n assert candidate(n = 11664) == False\n assert candidate(n = 50721) == False\n assert candidate(n = 7569) == False\n assert candidate(n = 3721) == True\n assert candidate(n = 3249) == False\n assert candidate(n = 20449) == False\n assert candidate(n = 9409) == True\n assert candidate(n = 9216) == False\n assert candidate(n = 26041) == False\n assert candidate(n = 1521) == False\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().isThree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def isThree(self, n: int) -> bool:", "container": "Solution", "callable": "isThree", "parameters": [{"name": "n", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1953, "task_id": "maximum-number-of-weeks-for-which-you-can-work", "difficulty": "Medium", "problem_description": "There are n projects numbered from 0 to n - 1. You are given an integer array milestones where each milestones[i] denotes the number of milestones the ith project has.\nYou can work on the projects following these two rules:\n\nEvery week, you will finish exactly one milestone of one project. You must work every week.\nYou cannot work on two milestones from the same project for two consecutive weeks.\n\nOnce all the milestones of all the projects are finished, or if the only milestones that you can work on will cause you to violate the above rules, you will stop working. Note that you may not be able to finish every project's milestones due to these constraints.\nReturn the maximum number of weeks you would be able to work on the projects without violating the rules mentioned above.\n \nExample 1:\n\nInput: milestones = [1,2,3]\nOutput: 6\nExplanation: One possible scenario is:\n​​​​- During the 1st week, you will work on a milestone of project 0.\n- During the 2nd week, you will work on a milestone of project 2.\n- During the 3rd week, you will work on a milestone of project 1.\n- During the 4th week, you will work on a milestone of project 2.\n- During the 5th week, you will work on a milestone of project 1.\n- During the 6th week, you will work on a milestone of project 2.\nThe total number of weeks is 6.\n\nExample 2:\n\nInput: milestones = [5,2,1]\nOutput: 7\nExplanation: One possible scenario is:\n- During the 1st week, you will work on a milestone of project 0.\n- During the 2nd week, you will work on a milestone of project 1.\n- During the 3rd week, you will work on a milestone of project 0.\n- During the 4th week, you will work on a milestone of project 1.\n- During the 5th week, you will work on a milestone of project 0.\n- During the 6th week, you will work on a milestone of project 2.\n- During the 7th week, you will work on a milestone of project 0.\nThe total number of weeks is 7.\nNote that you cannot work on the last milestone of project 0 on 8th week because it would violate the rules.\nThus, one milestone in project 0 will remain unfinished.\n\n \nConstraints:\n\nn == milestones.length\n1 <= n <= 105\n1 <= milestones[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(milestones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(milestones = [3, 3, 3]) == 9\n assert candidate(milestones = [1, 1, 1, 1, 1]) == 5\n assert candidate(milestones = [10, 5, 1]) == 13\n assert candidate(milestones = [1000000000, 1, 1]) == 5\n assert candidate(milestones = [1, 2, 3]) == 6\n assert candidate(milestones = [5, 2, 1]) == 7\n assert candidate(milestones = [1000000000, 1000000000, 1000000000]) == 3000000000\n assert candidate(milestones = [1, 1, 1000000000]) == 5\n assert candidate(milestones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(milestones = [1]) == 1\n assert candidate(milestones = [1, 1000000000]) == 3\n assert candidate(milestones = [5, 5, 5, 5, 5, 5]) == 30\n assert candidate(milestones = [10, 1, 1]) == 5\n assert candidate(milestones = [1, 1000000000, 1]) == 5\n assert candidate(milestones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1200\n assert candidate(milestones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(milestones = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 200\n assert candidate(milestones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\n assert candidate(milestones = [1000000000, 1000000000, 1000000000]) == 3000000000\n assert candidate(milestones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 150\n assert candidate(milestones = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(milestones = [1000000000, 500000000, 100000000, 50000000, 10000000, 5000000, 1000000, 500000, 100000, 50000, 10000, 5000, 1000, 500, 100, 50, 10, 5, 1]) == 1333333333\n assert candidate(milestones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(milestones = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 10000\n assert candidate(milestones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(milestones = [1000000000, 999999999, 1, 2, 3, 4, 5]) == 2000000014\n assert candidate(milestones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(milestones = [100, 200, 300, 400]) == 1000\n assert candidate(milestones = [1000000000, 999999999, 888888888]) == 2888888887\n assert candidate(milestones = [1, 2, 3, 4, 5]) == 15\n assert candidate(milestones = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]) == 1596\n assert candidate(milestones = [500000000, 500000000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000000009\n assert candidate(milestones = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 1000\n assert candidate(milestones = [10, 10, 10, 10, 10, 10, 10, 10, 10, 100]) == 181\n assert candidate(milestones = [10, 10, 10, 10, 10]) == 50\n assert candidate(milestones = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 550\n assert candidate(milestones = [999999999, 1, 1, 1]) == 7\n assert candidate(milestones = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 550000\n assert candidate(milestones = [1000000000, 1000000000, 1000000000, 1]) == 3000000001\n assert candidate(milestones = [10, 20, 30, 40, 50]) == 150\n assert candidate(milestones = [5, 5, 5, 5, 5, 5]) == 30\n assert candidate(milestones = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == 5000000001\n assert candidate(milestones = [10, 20, 30, 40, 50]) == 150\n assert candidate(milestones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(milestones = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(milestones = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == 10000000001\n assert candidate(milestones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 64\n assert candidate(milestones = [100, 99, 98, 97, 96, 95]) == 585\n assert candidate(milestones = [999999999, 999999999, 1]) == 1999999999\n assert candidate(milestones = [1000000000, 500000000, 250000000, 125000000]) == 1750000001\n assert candidate(milestones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 32767\n assert candidate(milestones = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 90\n assert candidate(milestones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5500\n assert candidate(milestones = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 5500\n assert candidate(milestones = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 9999999945\n assert candidate(milestones = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 39\n assert candidate(milestones = [1000000000, 1000000000, 1000000000, 1000000000, 1]) == 4000000001\n assert candidate(milestones = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 101\n assert candidate(milestones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 40\n assert candidate(milestones = [2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1]) == 35\n assert candidate(milestones = [500000000, 500000000, 1]) == 1000000001\n assert candidate(milestones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 80\n assert candidate(milestones = [999999999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 39\n assert candidate(milestones = [100, 150, 200, 250]) == 700\n assert candidate(milestones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 50\n assert candidate(milestones = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 77\n assert candidate(milestones = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 110\n assert candidate(milestones = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]) == 1597\n assert candidate(milestones = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000]) == 4000000003\n assert candidate(milestones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(milestones = [500000000, 500000000, 500000000, 500000000]) == 2000000000\n assert candidate(milestones = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(milestones = [1, 2, 4, 8, 16, 32, 64]) == 127\n assert candidate(milestones = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711]) == 46365\n assert candidate(milestones = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]) == 680\n assert candidate(milestones = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]) == 376\n assert candidate(milestones = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 30\n assert candidate(milestones = [333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333]) == 3333333330\n assert candidate(milestones = [100, 1, 100, 1, 100, 1]) == 303\n"}, "metadata": {"canonical_parameter_names": ["milestones"], "leetcode_dataset_entry_point": "Solution().numberOfWeeks", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numberOfWeeks(self, milestones: list[int]) -> int:", "container": "Solution", "callable": "numberOfWeeks", "parameters": [{"name": "milestones", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1954, "task_id": "minimum-garden-perimeter-to-collect-enough-apples", "difficulty": "Medium", "problem_description": "In a garden represented as an infinite 2D grid, there is an apple tree planted at every integer coordinate. The apple tree planted at an integer coordinate (i, j) has |i| + |j| apples growing on it.\nYou will buy an axis-aligned square plot of land that is centered at (0, 0).\nGiven an integer neededApples, return the minimum perimeter of a plot such that at least neededApples apples are inside or on the perimeter of that plot.\nThe value of |x| is defined as:\n\nx if x >= 0\n-x if x < 0\n\n \nExample 1:\n\n\nInput: neededApples = 1\nOutput: 8\nExplanation: A square plot of side length 1 does not contain any apples.\nHowever, a square plot of side length 2 has 12 apples inside (as depicted in the image above).\nThe perimeter is 2 * 4 = 8.\n\nExample 2:\n\nInput: neededApples = 13\nOutput: 16\n\nExample 3:\n\nInput: neededApples = 1000000000\nOutput: 5040\n\n \nConstraints:\n\n1 <= neededApples <= 1015\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(neededApples = 10000000000) == 10856\n assert candidate(neededApples = 10) == 8\n assert candidate(neededApples = 50) == 16\n assert candidate(neededApples = 1000000) == 504\n assert candidate(neededApples = 13) == 16\n assert candidate(neededApples = 1000000000) == 5040\n assert candidate(neededApples = 1000000000000000) == 503968\n assert candidate(neededApples = 1000) == 48\n assert candidate(neededApples = 987654321) == 5016\n assert candidate(neededApples = 1000000000000) == 50400\n assert candidate(neededApples = 999999999999999) == 503968\n assert candidate(neededApples = 100) == 24\n assert candidate(neededApples = 100000000) == 2336\n assert candidate(neededApples = 123456789) == 2512\n assert candidate(neededApples = 1) == 8\n assert candidate(neededApples = 2000000000) == 6352\n assert candidate(neededApples = 50000000000) == 18568\n assert candidate(neededApples = 123456789012345) == 250944\n assert candidate(neededApples = 1000000001) == 5040\n assert candidate(neededApples = 18014398509481984) == 1321120\n assert candidate(neededApples = 10000) == 112\n assert candidate(neededApples = 5000000000) == 8616\n assert candidate(neededApples = 50000) == 184\n assert candidate(neededApples = 120) == 24\n assert candidate(neededApples = 5) == 8\n assert candidate(neededApples = 6) == 8\n assert candidate(neededApples = 20) == 16\n assert candidate(neededApples = 2000000000000) == 63496\n assert candidate(neededApples = 100000000000) == 23392\n assert candidate(neededApples = 2147483647) == 6504\n assert candidate(neededApples = 100000) == 232\n assert candidate(neededApples = 123456789123) == 25096\n assert candidate(neededApples = 987654321987) == 50192\n assert candidate(neededApples = 2500000000) == 6840\n assert candidate(neededApples = 468) == 40\n assert candidate(neededApples = 500000000000) == 40000\n assert candidate(neededApples = 20736) == 136\n assert candidate(neededApples = 256) == 32\n assert candidate(neededApples = 500000000000000) == 400000\n assert candidate(neededApples = 111111111111111) == 242280\n assert candidate(neededApples = 99999999999999999) == 2339216\n assert candidate(neededApples = 8000000000) == 10080\n assert candidate(neededApples = 12) == 8\n assert candidate(neededApples = 122500) == 248\n assert candidate(neededApples = 25200) == 144\n assert candidate(neededApples = 598593750000) == 42472\n assert candidate(neededApples = 9261000) == 1056\n assert candidate(neededApples = 754321098) == 4584\n assert candidate(neededApples = 999999999999999999) == 5039688\n assert candidate(neededApples = 876543210987654) == 482312\n assert candidate(neededApples = 100000000000000000000) == 23392144\n assert candidate(neededApples = 100000000000000) == 233920\n assert candidate(neededApples = 400000000000000) == 371328\n assert candidate(neededApples = 1000000000000000000) == 5039688\n assert candidate(neededApples = 987654321098765) == 501888\n assert candidate(neededApples = 9999999999999999) == 1085768\n assert candidate(neededApples = 5000) == 88\n assert candidate(neededApples = 10000000000000) == 108576\n assert candidate(neededApples = 3500) == 80\n assert candidate(neededApples = 1024) == 48\n assert candidate(neededApples = 18) == 16\n assert candidate(neededApples = 30000000000000) == 156592\n assert candidate(neededApples = 2) == 8\n assert candidate(neededApples = 500) == 40\n assert candidate(neededApples = 4) == 8\n assert candidate(neededApples = 3) == 8\n assert candidate(neededApples = 10000000000000000000) == 10857672\n assert candidate(neededApples = 4608) == 80\n"}, "metadata": {"canonical_parameter_names": ["neededApples"], "leetcode_dataset_entry_point": "Solution().minimumPerimeter", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumPerimeter(self, neededApples: int) -> int:", "container": "Solution", "callable": "minimumPerimeter", "parameters": [{"name": "neededApples", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1955, "task_id": "count-number-of-special-subsequences", "difficulty": "Hard", "problem_description": "A sequence is special if it consists of a positive number of 0s, followed by a positive number of 1s, then a positive number of 2s.\n\nFor example, [0,1,2] and [0,0,1,1,1,2] are special.\nIn contrast, [2,1,0], [1], and [0,1,2,0] are not special.\n\nGiven an array nums (consisting of only integers 0, 1, and 2), return the number of different subsequences that are special. Since the answer may be very large, return it modulo 109 + 7.\nA subsequence of an array is a sequence that can be derived from the array by deleting some or no elements without changing the order of the remaining elements. Two subsequences are different if the set of indices chosen are different.\n \nExample 1:\n\nInput: nums = [0,1,2,2]\nOutput: 3\nExplanation: The special subsequences are bolded [0,1,2,2], [0,1,2,2], and [0,1,2,2].\n\nExample 2:\n\nInput: nums = [2,2,0,0]\nOutput: 0\nExplanation: There are no special subsequences in [2,2,0,0].\n\nExample 3:\n\nInput: nums = [0,1,2,0,1,2]\nOutput: 7\nExplanation: The special subsequences are bolded:\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 2\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 1, 1, 2]) == 9\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2]) == 0\n assert candidate(nums = [0, 0, 0, 1, 1, 2]) == 21\n assert candidate(nums = [2, 2, 0, 0]) == 0\n assert candidate(nums = [0, 1, 2, 2]) == 3\n assert candidate(nums = [0, 1, 2, 2, 2]) == 7\n assert candidate(nums = [1, 2, 2, 0, 0, 1]) == 0\n assert candidate(nums = [0, 1, 2, 1, 2, 0, 1, 2]) == 19\n assert candidate(nums = [0, 1, 0, 1, 2]) == 5\n assert candidate(nums = [0, 1, 1, 1, 2, 2, 2]) == 49\n assert candidate(nums = [2, 1, 0, 1, 0, 2, 0]) == 1\n assert candidate(nums = [0, 1, 2, 0, 1, 0, 1, 2]) == 19\n assert candidate(nums = [2, 0, 1, 2, 0, 1, 2]) == 7\n assert candidate(nums = [2, 0, 1, 0, 1, 2]) == 5\n assert candidate(nums = [2, 0, 1, 0, 1, 2, 0, 1, 2]) == 27\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 2]) == 63\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 0, 1, 2, 0, 1, 2, 0]) == 7\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2]) == 51\n assert candidate(nums = [0, 1, 2, 0, 1, 2]) == 7\n assert candidate(nums = [0, 1, 2]) == 1\n assert candidate(nums = [0, 0, 1, 2, 1, 2]) == 15\n assert candidate(nums = [0, 0, 1, 1, 2, 2]) == 27\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2, 2]) == 119\n assert candidate(nums = [0, 0, 0, 1, 2, 2]) == 21\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2]) == 343\n assert candidate(nums = [0, 1, 0, 1, 2, 0, 1, 2]) == 27\n assert candidate(nums = [0, 1, 1, 2, 2, 2]) == 21\n assert candidate(nums = [1, 2, 0]) == 0\n assert candidate(nums = [2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2]) == 735\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 375309442\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2]) == 21567\n assert candidate(nums = [0, 0, 0, 0, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2]) == 9975\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 554508028\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 25039\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 133432831\n assert candidate(nums = [0, 1, 0, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 207\n assert candidate(nums = [2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0]) == 351\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 14415\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]) == 2048383\n assert candidate(nums = [0, 1, 0, 2, 0, 1, 0, 2, 1, 2]) == 55\n assert candidate(nums = [0, 1, 1, 0, 2, 2, 1, 1, 0, 2, 0, 1, 2]) == 135\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 6399\n assert candidate(nums = [2, 1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2]) == 735\n assert candidate(nums = [0, 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2]) == 3519\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 14175\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2, 0, 1, 2, 0, 1, 2]) == 2335\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2]) == 3999\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 0, 1, 2, 2]) == 3279\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2]) == 1575\n assert candidate(nums = [2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0]) == 0\n assert candidate(nums = [0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2]) == 71\n assert candidate(nums = [2, 2, 2, 1, 1, 1, 0, 0, 0, 2, 2, 2, 1, 1, 1, 0, 0, 0]) == 0\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2, 2]) == 1647\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 2]) == 423\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2]) == 26775\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 29295\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 2, 2]) == 135\n assert candidate(nums = [2, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 0, 1, 2]) == 4047\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2]) == 31\n assert candidate(nums = [2, 2, 2, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 1023\n assert candidate(nums = [2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 70599160\n assert candidate(nums = [0, 0, 1, 1, 1, 1, 2, 2, 0, 0, 1, 1, 2]) == 495\n assert candidate(nums = [0, 1, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2]) == 63\n assert candidate(nums = [0, 1, 1, 2, 0, 1, 2, 2, 1, 2, 0, 1, 2, 2, 1, 0, 1, 2, 2]) == 2847\n assert candidate(nums = [0, 0, 1, 1, 1, 1, 2, 2, 2, 2]) == 675\n assert candidate(nums = [0, 1, 2, 2, 1, 0, 1, 2, 2, 1, 0, 1, 2]) == 127\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2]) == 1575\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 2, 2, 2, 2]) == 255\n assert candidate(nums = [2, 0, 0, 0, 1, 1, 1, 2, 2, 2]) == 343\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 250047\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2]) == 8575\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 2, 2]) == 651\n assert candidate(nums = [2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 18943\n assert candidate(nums = [0, 1, 2, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2]) == 4609\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 534776319\n assert candidate(nums = [0, 1, 2, 0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 303\n assert candidate(nums = [0, 1, 1, 2, 2, 2, 2, 2, 0, 1, 2, 0, 1, 2, 2]) == 855\n assert candidate(nums = [2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 2815\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2]) == 3375\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 4287\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 20223\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 2815\n assert candidate(nums = [2, 2, 0, 0, 0, 1, 1, 1, 2, 2]) == 147\n assert candidate(nums = [2, 0, 0, 1, 1, 1, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2]) == 1647\n assert candidate(nums = [0, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 831\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 29791\n assert candidate(nums = [2, 2, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 451143\n assert candidate(nums = [2, 2, 2, 0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 335\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 1, 2, 0, 1, 2]) == 1855\n assert candidate(nums = [0, 1, 1, 1, 2, 2, 2, 2, 0, 1, 2]) == 227\n assert candidate(nums = [0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0, 1, 2]) == 1447\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2, 2, 2]) == 16095\n assert candidate(nums = [0, 1, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 7039\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 351\n assert candidate(nums = [0, 1, 2, 0, 0, 1, 1, 1, 2, 2, 0, 1, 2]) == 479\n assert candidate(nums = [2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 2943\n assert candidate(nums = [2, 2, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2]) == 735\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 2, 2]) == 975\n assert candidate(nums = [2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 2, 2]) == 2239\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2]) == 6727\n assert candidate(nums = [0, 0, 0, 1, 2, 2, 2, 1, 1, 1, 0, 0, 0]) == 49\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 783\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 704511\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2]) == 527\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2, 2, 2]) == 28639\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 2]) == 735\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 2943\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 2]) == 315\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 1323\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2]) == 3375\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 1, 2, 2, 2]) == 3087\n assert candidate(nums = [0, 1, 2, 1, 2, 0, 1, 2, 1, 2, 0, 1, 2]) == 167\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 351\n assert candidate(nums = [2, 1, 0, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2]) == 7423\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2]) == 4335\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 0, 1, 2]) == 3151\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 18943\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 274431\n assert candidate(nums = [0, 0, 1, 1, 2, 0, 1, 2, 0, 1, 2]) == 151\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2]) == 3591\n assert candidate(nums = [2, 2, 2, 0, 0, 0, 1, 1, 1]) == 0\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 111\n assert candidate(nums = [0, 0, 0, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2]) == 3367\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countSpecialSubsequences", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countSpecialSubsequences(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countSpecialSubsequences", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1957, "task_id": "delete-characters-to-make-fancy-string", "difficulty": "Easy", "problem_description": "A fancy string is a string where no three consecutive characters are equal.\nGiven a string s, delete the minimum possible number of characters from s to make it fancy.\nReturn the final string after the deletion. It can be shown that the answer will always be unique.\n \nExample 1:\n\nInput: s = \"leeetcode\"\nOutput: \"leetcode\"\nExplanation:\nRemove an 'e' from the first group of 'e's to create \"leetcode\".\nNo three consecutive characters are equal, so return \"leetcode\".\n\nExample 2:\n\nInput: s = \"aaabaaaa\"\nOutput: \"aabaa\"\nExplanation:\nRemove an 'a' from the first group of 'a's to create \"aabaaaa\".\nRemove two 'a's from the second group of 'a's to create \"aabaa\".\nNo three consecutive characters are equal, so return \"aabaa\".\n\nExample 3:\n\nInput: s = \"aab\"\nOutput: \"aab\"\nExplanation: No three consecutive characters are equal, so return \"aab\".\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzzzzzz\") == \"zz\"\n assert candidate(s = \"aaabbbccc\") == \"aabbcc\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aabbaa\") == \"aabbaa\"\n assert candidate(s = \"leeetcode\") == \"leetcode\"\n assert candidate(s = \"aaaaa\") == \"aa\"\n assert candidate(s = \"ccccccaaa\") == \"ccaa\"\n assert candidate(s = \"aabbccddd\") == \"aabbccdd\"\n assert candidate(s = \"cccaaa\") == \"ccaa\"\n assert candidate(s = \"aaa\") == \"aa\"\n assert candidate(s = \"aababab\") == \"aababab\"\n assert candidate(s = \"aaaabbbcccaa\") == \"aabbccaa\"\n assert candidate(s = \"aaaabbbbcccc\") == \"aabbcc\"\n assert candidate(s = \"zzzzzzzzzz\") == \"zz\"\n assert candidate(s = \"ababababc\") == \"ababababc\"\n assert candidate(s = \"abacadaeafag\") == \"abacadaeafag\"\n assert candidate(s = \"abc\") == \"abc\"\n assert candidate(s = \"aabbaaabbbaaa\") == \"aabbaabbaa\"\n assert candidate(s = \"aab\") == \"aab\"\n assert candidate(s = \"aabbcc\") == \"aabbcc\"\n assert candidate(s = \"mississippi\") == \"mississippi\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"xyzzzxxzzzz\") == \"xyzzxxzz\"\n assert candidate(s = \"aaabaaaa\") == \"aabaa\"\n assert candidate(s = \"abcdefg\") == \"abcdefg\"\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwwwxxxxyyyzzz\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"abcabcabcabc\") == \"abcabcabcabc\"\n assert candidate(s = \"pppaaabbbcccddddeeeffffggghhhhiiiijjjjjkkkkklllllmmmmmnnnnnooooooopppppqqqqqrrrrrssssstttttuuuuuuvvvvvvvvvvwwwwwwxxxxxyyyyzzzzz\") == \"ppaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"xyzzzzzzzzzyx\") == \"xyzzyx\"\n assert candidate(s = \"mnonononojmnonononojmnonononoj\") == \"mnonononojmnonononojmnonononoj\"\n assert candidate(s = \"pppqqqrssstttuuuvvvwwwxxyyyzzz\") == \"ppqqrssttuuvvwwxxyyzz\"\n assert candidate(s = \"aabbccddeeefff\") == \"aabbccddeeff\"\n assert candidate(s = \"abcdefghijjjjjklmnopqrstuvwxyz\") == \"abcdefghijjklmnopqrstuvwxyz\"\n assert candidate(s = \"nnneennneennneennn\") == \"nneenneenneenn\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().makeFancyString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def makeFancyString(self, s: str) -> str:", "container": "Solution", "callable": "makeFancyString", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1958, "task_id": "check-if-move-is-legal", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 8 x 8 grid board, where board[r][c] represents the cell (r, c) on a game board. On the board, free cells are represented by '.', white cells are represented by 'W', and black cells are represented by 'B'.\nEach move in this game consists of choosing a free cell and changing it to the color you are playing as (either white or black). However, a move is only legal if, after changing it, the cell becomes the endpoint of a good line (horizontal, vertical, or diagonal).\nA good line is a line of three or more cells (including the endpoints) where the endpoints of the line are one color, and the remaining cells in the middle are the opposite color (no cells in the line are free). You can find examples for good lines in the figure below:\n\nGiven two integers rMove and cMove and a character color representing the color you are playing as (white or black), return true if changing cell (rMove, cMove) to color color is a legal move, or false if it is not legal.\n \nExample 1:\n\n\nInput: board = [[\".\",\".\",\".\",\"B\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"W\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"W\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"W\",\".\",\".\",\".\",\".\"],[\"W\",\"B\",\"B\",\".\",\"W\",\"W\",\"W\",\"B\"],[\".\",\".\",\".\",\"B\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"B\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"W\",\".\",\".\",\".\",\".\"]], rMove = 4, cMove = 3, color = \"B\"\nOutput: true\nExplanation: '.', 'W', and 'B' are represented by the colors blue, white, and black respectively, and cell (rMove, cMove) is marked with an 'X'.\nThe two good lines with the chosen cell as an endpoint are annotated above with the red rectangles.\n\nExample 2:\n\n\nInput: board = [[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\"B\",\".\",\".\",\"W\",\".\",\".\",\".\"],[\".\",\".\",\"W\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"W\",\"B\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\"B\",\"W\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\"W\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\"B\"]], rMove = 4, cMove = 4, color = \"W\"\nOutput: false\nExplanation: While there are good lines with the chosen cell as a middle cell, there are no good lines with the chosen cell as an endpoint.\n\n \nConstraints:\n\nboard.length == board[r].length == 8\n0 <= rMove, cMove < 8\nboard[rMove][cMove] == '.'\ncolor is either 'B' or 'W'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(board = [['.', 'W', '.', '.', '.', '.', '.', '.'], ['.', '.', 'W', '.', '.', '.', '.', '.'], ['W', '.', '.', 'W', '.', '.', '.', '.'], ['.', '.', 'W', '.', '.', '.', '.', '.'], ['.', 'W', 'W', 'W', '.', '.', '.', '.'], ['.', '.', 'W', '.', '.', '.', '.', '.'], ['.', '.', 'W', '.', '.', '.', '.', '.'], ['.', 'W', '.', '.', '.', '.', '.', '.']],rMove = 3,cMove = 3,color = \"W\") == False\n assert candidate(board = [['.', 'W', '.', '.', '.', '.', '.', '.'], ['.', 'W', '.', '.', '.', '.', '.', '.'], ['W', '.', '.', 'W', '.', '.', '.', '.'], ['.', 'W', 'W', 'W', '.', '.', '.', '.'], ['.', 'W', 'W', 'W', '.', '.', '.', '.'], ['.', 'W', 'W', 'W', '.', '.', '.', '.'], ['.', 'W', '.', '.', '.', '.', '.', '.'], ['W', '.', '.', '.', '.', '.', '.', '.']],rMove = 4,cMove = 3,color = \"B\") == False\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', 'W', '.', '.', '.'], ['.', '.', 'W', '.', '.', '.', '.', '.'], ['.', '.', '.', 'W', 'B', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'B', 'W', '.', '.'], ['.', '.', '.', '.', '.', '.', 'W', '.'], ['.', '.', '.', '.', '.', '.', '.', 'B']],rMove = 4,cMove = 4,color = \"W\") == False\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'W', '.', '.', '.', '.'], ['.', 'W', '.', 'W', '.', '.', '.', '.'], ['W', '.', 'W', '.', 'W', '.', '.', '.'], ['.', 'W', '.', 'W', '.', '.', '.', '.'], ['.', '.', 'W', '.', 'W', '.', '.', '.'], ['.', '.', '.', 'W', '.', '.', '.', '.'], ['.', '.', '.', 'W', '.', '.', '.', '.']],rMove = 2,cMove = 2,color = \"B\") == False\n assert candidate(board = [['.', '.', '.', 'B', '.', '.', '.', '.'], ['.', '.', '.', 'W', '.', '.', '.', '.'], ['.', '.', '.', 'W', '.', '.', '.', '.'], ['.', '.', '.', 'W', '.', '.', '.', '.'], ['W', 'B', 'B', '.', 'W', 'W', 'W', 'B'], ['.', '.', '.', 'B', '.', '.', '.', '.'], ['.', '.', '.', 'B', '.', '.', '.', '.'], ['.', '.', '.', 'W', '.', '.', '.', '.']],rMove = 4,cMove = 3,color = \"B\") == True\n assert candidate(board = [['.', 'B', '.', '.', '.', '.', '.', '.'], ['B', 'B', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', '.', '.', '.', '.']],rMove = 4,cMove = 1,color = \"W\") == False\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'W', 'B', '.', '.', '.'], ['.', '.', '.', 'B', 'W', '.', '.', '.'], ['.', '.', '.', 'B', 'B', '.', '.', '.'], ['.', '.', '.', 'B', 'W', '.', '.', '.'], ['.', '.', '.', 'W', 'B', '.', '.', '.']],rMove = 3,cMove = 3,color = \"W\") == True\n assert candidate(board = [['.', 'W', '.', '.', '.', '.', '.', '.'], ['.', 'W', '.', '.', '.', '.', '.', '.'], ['W', '.', '.', 'W', '.', '.', '.', '.'], ['.', 'W', 'W', 'W', '.', '.', '.', '.'], ['.', 'W', 'W', 'B', '.', '.', '.', '.'], ['.', 'W', 'W', 'W', '.', '.', '.', '.'], ['.', 'W', '.', '.', '.', '.', '.', '.'], ['W', '.', '.', '.', '.', '.', '.', '.']],rMove = 4,cMove = 3,color = \"W\") == False\n"}, "metadata": {"canonical_parameter_names": ["board", "rMove", "cMove", "color"], "leetcode_dataset_entry_point": "Solution().checkMove", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def checkMove(self, board: list[list[str]], rMove: int, cMove: int, color: str) -> bool:", "container": "Solution", "callable": "checkMove", "parameters": [{"name": "board", "type": "list[list[str]]"}, {"name": "rMove", "type": "int"}, {"name": "cMove", "type": "int"}, {"name": "color", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1959, "task_id": "minimum-total-space-wasted-with-k-resizing-operations", "difficulty": "Medium", "problem_description": "You are currently designing a dynamic array. You are given a 0-indexed integer array nums, where nums[i] is the number of elements that will be in the array at time i. In addition, you are given an integer k, the maximum number of times you can resize the array (to any size).\nThe size of the array at time t, sizet, must be at least nums[t] because there needs to be enough space in the array to hold all the elements. The space wasted at time t is defined as sizet - nums[t], and the total space wasted is the sum of the space wasted across every time t where 0 <= t < nums.length.\nReturn the minimum total space wasted if you can resize the array at most k times.\nNote: The array can have any size at the start and does not count towards the number of resizing operations.\n \nExample 1:\n\nInput: nums = [10,20], k = 0\nOutput: 10\nExplanation: size = [20,20].\nWe can set the initial size to be 20.\nThe total wasted space is (20 - 10) + (20 - 20) = 10.\n\nExample 2:\n\nInput: nums = [10,20,30], k = 1\nOutput: 10\nExplanation: size = [20,20,30].\nWe can set the initial size to be 20 and resize to 30 at time 2. \nThe total wasted space is (20 - 10) + (20 - 20) + (30 - 30) = 10.\n\nExample 3:\n\nInput: nums = [10,20,15,30,20], k = 2\nOutput: 15\nExplanation: size = [10,20,20,30,30].\nWe can set the initial size to 10, resize to 20 at time 1, and resize to 30 at time 3.\nThe total wasted space is (10 - 10) + (20 - 20) + (20 - 15) + (30 - 30) + (30 - 20) = 15.\n\n \nConstraints:\n\n1 <= nums.length <= 200\n1 <= nums[i] <= 106\n0 <= k <= nums.length - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10, 10],k = 2) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30],k = 3) == 10\n assert candidate(nums = [10, 20, 30],k = 1) == 10\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 0) == 45\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7],k = 3) == 3\n assert candidate(nums = [100, 200, 150, 300, 200, 350],k = 2) == 250\n assert candidate(nums = [10, 20, 15, 30, 20],k = 2) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 0) == 90\n assert candidate(nums = [1, 2, 3, 4, 5],k = 4) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],k = 0) == 1000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 0) == 450\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500],k = 4) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 10\n assert candidate(nums = [5, 8, 6, 10],k = 1) == 5\n assert candidate(nums = [1, 3, 5, 7, 9],k = 4) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9) == 0\n assert candidate(nums = [5, 5, 5, 5, 5],k = 0) == 0\n assert candidate(nums = [1000000, 1000000, 1000000],k = 2) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 40\n assert candidate(nums = [10, 20],k = 0) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 5\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 0\n assert candidate(nums = [20, 10, 30, 25, 40],k = 2) == 15\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 0) == 0\n assert candidate(nums = [20, 10, 30, 25, 15],k = 2) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 2) == 4\n assert candidate(nums = [300, 200, 100, 400, 300, 200, 500, 400, 300, 600, 500, 400, 700, 600, 500, 800, 700, 600, 900, 800, 700, 1000, 900, 800, 1100, 1000, 900, 1200, 1100, 1000, 1300, 1200, 1100, 1400, 1300, 1200, 1500, 1400, 1300, 1600, 1500, 1400, 1700, 1600, 1500, 1800, 1700, 1600, 1900, 1800, 1700, 2000, 1900, 1800, 2100, 2000, 1900, 2200, 2100, 2000, 2300, 2200, 2100, 2400, 2300, 2200],k = 30) == 4800\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 100) == inf\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 14) == 15\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 10) == 33\n assert candidate(nums = [3, 5, 4, 7, 8, 6, 9],k = 2) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 18\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 120\n assert candidate(nums = [20, 15, 10, 5, 15, 20, 25, 30, 35, 40, 45, 50],k = 2) == 65\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 4) == 50\n assert candidate(nums = [300, 200, 100, 50, 25, 125, 62, 31, 15, 7, 3, 1],k = 5) == 186\n assert candidate(nums = [100, 200, 150, 300, 250, 350, 400],k = 2) == 250\n assert candidate(nums = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 50\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == 0\n assert candidate(nums = [10, 20, 30, 25, 40, 35, 50, 45, 60, 55],k = 4) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 0) == 190\n assert candidate(nums = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000],k = 9) == 5000\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 0) == 0\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 3) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 4) == 90\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 5) == 24\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100],k = 9) == 495\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994],k = 3) == 3\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 0) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 9) == 29\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4) == 50\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 200) == inf\n assert candidate(nums = [20, 10, 30, 25, 40, 35, 50, 45, 60, 55, 70, 65, 80, 75, 90, 85, 100, 95, 110, 105],k = 3) == 215\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(nums = [100, 200, 150, 100, 300, 250, 200, 350, 400, 300],k = 3) == 450\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 10) == 1985\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 0) == 1900\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == 90\n assert candidate(nums = [1000000, 500000, 750000, 250000, 100000],k = 2) == 400000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 4) == 150\n assert candidate(nums = [10, 5, 15, 10, 20, 15, 25, 20, 30, 25, 35, 30, 40, 35, 45],k = 6) == 45\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 0\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],k = 5) == 140629\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],k = 6) == 12\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 5) == 73729\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350],k = 2) == 250\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 120\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350, 500],k = 2) == 450\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100],k = 5) == 80\n assert candidate(nums = [10, 20, 30, 20, 10, 40, 30, 20, 50, 40, 30, 20, 60, 50, 40, 30],k = 5) == 130\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 9) == 977778\n assert candidate(nums = [200, 150, 100, 50, 150, 200, 250, 300, 350, 400],k = 3) == 350\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 0) == 0\n assert candidate(nums = [500000, 400000, 300000, 200000, 100000, 100000, 200000, 300000, 400000, 500000, 100000, 200000, 300000, 400000, 500000, 100000, 200000, 300000, 400000, 500000],k = 7) == 1400000\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 5) == 81\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205],k = 7) == 160\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],k = 10) == 3788\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 5) == 0\n assert candidate(nums = [20, 10, 30, 5, 40, 25, 60, 35, 70, 45, 80, 55, 90, 65, 100, 75, 110, 85, 120, 95, 130, 105, 140, 115, 150, 125, 160, 135, 170, 145, 180, 155],k = 8) == 515\n assert candidate(nums = [10, 20, 10, 30, 10, 20, 30, 40, 50],k = 3) == 50\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100],k = 25) == 48\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 10\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 4) == 488889\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 0) == 0\n assert candidate(nums = [100, 200, 150, 300, 250, 400],k = 2) == 200\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 9) == 45\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9],k = 25) == 119\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 15) == 140\n assert candidate(nums = [100, 200, 150, 100, 250, 200, 150, 300],k = 2) == 400\n assert candidate(nums = [200, 100, 200, 100, 200, 100, 200, 100, 200, 100],k = 4) == 300\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],k = 0) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 10) == 90\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == 1200\n assert candidate(nums = [500, 400, 300, 200, 100, 50, 25, 10, 5, 2, 1, 1, 2, 5, 10, 25, 50, 100, 200, 300, 400, 500],k = 10) == 264\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 9\n assert candidate(nums = [10, 20, 30, 25, 40, 35, 50, 45, 60, 55, 70, 65, 80, 75, 90, 85, 100, 95, 110, 105, 120, 115, 130, 125, 140, 135, 150, 145, 160, 155, 170, 165, 180, 175, 190, 185, 200, 195, 210, 205, 220, 215, 230, 225, 240, 235, 250, 245, 260, 255, 270, 265, 280, 275, 290, 285, 300, 295, 310, 305, 320, 315, 330, 325, 340, 335, 350, 345, 360, 355, 370, 365, 380, 375, 390, 385, 400, 395, 410, 405],k = 100) == inf\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 90\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 8\n assert candidate(nums = [100, 90, 110, 80, 120, 70, 130, 60, 140, 50, 150, 40, 160, 30, 170, 20, 180, 10, 190, 0],k = 5) == 820\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 7) == 16\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 10) == 100\n assert candidate(nums = [10, 20, 15, 30, 20, 25, 35, 40, 45, 50],k = 4) == 30\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],k = 5) == 9\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 0) == 450\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 6\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 0\n assert candidate(nums = [20, 15, 10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85],k = 5) == 100\n assert candidate(nums = [1000, 2000, 1500, 3000, 2500, 4000, 3500, 5000, 4500, 6000],k = 5) == 2000\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 0) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minSpaceWastedKResizing", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minSpaceWastedKResizing(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "minSpaceWastedKResizing", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1960, "task_id": "maximum-product-of-the-length-of-two-palindromic-substrings", "difficulty": "Hard", "problem_description": "You are given a 0-indexed string s and are tasked with finding two non-intersecting palindromic substrings of odd length such that the product of their lengths is maximized.\nMore formally, you want to choose four integers i, j, k, l such that 0 <= i <= j < k <= l < s.length and both the substrings s[i...j] and s[k...l] are palindromes and have odd lengths. s[i...j] denotes a substring from index i to index j inclusive.\nReturn the maximum possible product of the lengths of the two non-intersecting palindromic substrings.\nA palindrome is a string that is the same forward and backward. A substring is a contiguous sequence of characters in a string.\n \nExample 1:\n\nInput: s = \"ababbb\"\nOutput: 9\nExplanation: Substrings \"aba\" and \"bbb\" are palindromes with odd length. product = 3 * 3 = 9.\n\nExample 2:\n\nInput: s = \"zaaaxbbby\"\nOutput: 9\nExplanation: Substrings \"aaa\" and \"bbb\" are palindromes with odd length. product = 3 * 3 = 9.\n\n \nConstraints:\n\n2 <= s.length <= 105\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"mnoonmmon\") == 1\n assert candidate(s = \"mamadmim\") == 9\n assert candidate(s = \"abcdcba\") == 5\n assert candidate(s = \"abcdedcba\") == 7\n assert candidate(s = \"mamad\") == 3\n assert candidate(s = \"aaaaa\") == 3\n assert candidate(s = \"abcdefghi\") == 1\n assert candidate(s = \"abacdfgdcaba\") == 9\n assert candidate(s = \"zaaaxbbby\") == 9\n assert candidate(s = \"noonnoon\") == 1\n assert candidate(s = \"abcde\") == 1\n assert candidate(s = \"racecar\") == 5\n assert candidate(s = \"abcdeedcba\") == 1\n assert candidate(s = \"banana\") == 5\n assert candidate(s = \"ababbb\") == 9\n assert candidate(s = \"abc\") == 1\n assert candidate(s = \"abcbabcbabcba\") == 35\n assert candidate(s = \"abcdefgh\") == 1\n assert candidate(s = \"abcd\") == 1\n assert candidate(s = \"mississippi\") == 7\n assert candidate(s = \"aabbccddeeffgghhiijj\") == 1\n assert candidate(s = \"mnoonmnonoomnm\") == 15\n assert candidate(s = \"abcdefg\") == 1\n assert candidate(s = \"aabbccddeeeffgg\") == 3\n assert candidate(s = \"abccbaabccbaabccbaabccba\") == 1\n assert candidate(s = \"aaaaaabbaaaaa\") == 25\n assert candidate(s = \"nunrunrunrun\") == 3\n assert candidate(s = \"abaaacbaaaaba\") == 9\n assert candidate(s = \"racecarlevelnoonracecar\") == 49\n assert candidate(s = \"deeeeefedeeeed\") == 15\n assert candidate(s = \"rotorrotor\") == 25\n assert candidate(s = \"abracadabra\") == 3\n assert candidate(s = \"abcabcabcabc\") == 1\n assert candidate(s = \"abcbaacbabcba\") == 25\n assert candidate(s = \"abcbacbacbacb\") == 5\n assert candidate(s = \"tattarrattat\") == 9\n assert candidate(s = \"repaperrelevelrepeepr\") == 35\n assert candidate(s = \"babadabababa\") == 25\n assert candidate(s = \"madaminnadammadam\") == 25\n assert candidate(s = \"abccbaabcdcba\") == 7\n assert candidate(s = \"aabaaaabaaaabaa\") == 25\n assert candidate(s = \"abcdeffedcbaffedcba\") == 1\n assert candidate(s = \"abccbaabccba\") == 1\n assert candidate(s = \"xyzabcbaedcbaxyz\") == 5\n assert candidate(s = \"levellevellevellevel\") == 75\n assert candidate(s = \"noonnoonnoonnoon\") == 1\n assert candidate(s = \"mississippimississippi\") == 49\n assert candidate(s = \"xyzxyzxyzxyz\") == 1\n assert candidate(s = \"abacdfgdcabaxyzzyzyzyzyzx\") == 27\n assert candidate(s = \"aabbbaabbbaabbbaaa\") == 49\n assert candidate(s = \"abacadaeafagahagaha\") == 21\n assert candidate(s = \"noonracecarnoon\") == 13\n assert candidate(s = \"aabbbaaabbbaaabbbaaabbbaaabbba\") == 221\n assert candidate(s = \"ababababababababa\") == 63\n assert candidate(s = \"abacabaabacabaabacaba\") == 49\n assert candidate(s = \"repel\") == 3\n assert candidate(s = \"levelnoonlevel\") == 25\n assert candidate(s = \"rotorlevelmadamracecar\") == 35\n assert candidate(s = \"noonnoonnoonnoonnoonnoon\") == 1\n assert candidate(s = \"kayak\") == 3\n assert candidate(s = \"mnopqrstuvuvwxyzyx\") == 15\n assert candidate(s = \"madamlevelmadam\") == 25\n assert candidate(s = \"babcbabcbabcba\") == 35\n assert candidate(s = \"abacadaeafagaha\") == 9\n assert candidate(s = \"leveloneleveleleveldoneleveldot\") == 55\n assert candidate(s = \"xyzzzzyzyzyzx\") == 21\n assert candidate(s = \"madaminnadam\") == 15\n assert candidate(s = \"abababababababab\") == 63\n assert candidate(s = \"racecarabcdeedcbacar\") == 21\n assert candidate(s = \"noon\") == 1\n assert candidate(s = \"abcbacbacb\") == 5\n assert candidate(s = \"ababababababababab\") == 81\n assert candidate(s = \"deeee\") == 3\n assert candidate(s = \"leveloneleveltwo\") == 25\n assert candidate(s = \"abcabcabcabcabcabc\") == 1\n assert candidate(s = \"xyzbcbzxyxzyzyzyz\") == 35\n assert candidate(s = \"abcdefggfedcba\") == 1\n assert candidate(s = \"aaaaabbbbbbaaaa\") == 25\n assert candidate(s = \"abcdeffedcba\") == 1\n assert candidate(s = \"ababcbaababcbaababcba\") == 25\n assert candidate(s = \"babcbabcbabcbabcbabcbabcbabcbabcbabcbabcba\") == 399\n assert candidate(s = \"ababaababaababa\") == 27\n assert candidate(s = \"abcbabcbaabcbabcba\") == 81\n assert candidate(s = \"mmabccbaakak\") == 3\n assert candidate(s = \"abcdefedcba\") == 9\n assert candidate(s = \"palindromeemordnilap\") == 1\n assert candidate(s = \"level\") == 3\n assert candidate(s = \"racecarlevelracecar\") == 49\n assert candidate(s = \"levellevellevel\") == 25\n assert candidate(s = \"aaaaabaaaaabaaaaabaaaaab\") == 143\n assert candidate(s = \"xyxzyxzyxzyx\") == 3\n assert candidate(s = \"nunabannun\") == 15\n assert candidate(s = \"deeeeefeeeed\") == 15\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzz\") == 143\n assert candidate(s = \"abababababababababab\") == 99\n assert candidate(s = \"madamimadamracecar\") == 77\n assert candidate(s = \"abbbbabbbaaaaaaaabbba\") == 49\n assert candidate(s = \"radar\") == 3\n assert candidate(s = \"abababa\") == 9\n assert candidate(s = \"abacabadabacaba\") == 49\n assert candidate(s = \"abacabadabacabada\") == 63\n assert candidate(s = \"bananaananab\") == 25\n assert candidate(s = \"aabbccddeeefffggg\") == 9\n assert candidate(s = \"redivider\") == 7\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 99\n assert candidate(s = \"abcabccbaabcabccba\") == 1\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 1\n assert candidate(s = \"deedlevel\") == 5\n assert candidate(s = \"abcbabcba\") == 15\n assert candidate(s = \"deifiedrotatordeified\") == 49\n assert candidate(s = \"noonnoonnoonnoonnoon\") == 1\n assert candidate(s = \"abcbadefgfe\") == 25\n assert candidate(s = \"anana\") == 3\n assert candidate(s = \"ababaabababababa\") == 55\n assert candidate(s = \"abracadabraabracadabra\") == 9\n assert candidate(s = \"detartrated\") == 9\n assert candidate(s = \"manamzzamanaplanacanalpanamazzamanaplanacanalpanamazzzzzz\") == 529\n assert candidate(s = \"xyxyxyxyxyxyxyxyx\") == 63\n assert candidate(s = \"madamimadam\") == 25\n assert candidate(s = \"levelonelevelonelevel\") == 25\n assert candidate(s = \"madamracecaramadam\") == 35\n assert candidate(s = \"aaabbaaabbaaa\") == 21\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"xylophonepiponolyx\") == 9\n assert candidate(s = \"racecarandracecar\") == 49\n assert candidate(s = \"aabaaaabaaba\") == 25\n assert candidate(s = \"racecarannakayak\") == 35\n assert candidate(s = \"kayakkayakkayakkayak\") == 75\n assert candidate(s = \"aaaaabbbbbaaaaa\") == 27\n assert candidate(s = \"mammadmooommom\") == 15\n assert candidate(s = \"aaaaabbbbbaaaaaabbbbaaaaa\") == 75\n assert candidate(s = \"racecarracecar\") == 49\n assert candidate(s = \"noonnoonnoon\") == 1\n assert candidate(s = \"repaper\") == 5\n assert candidate(s = \"racecarlevelrotorkayak\") == 35\n assert candidate(s = \"rotorrotorrotor\") == 25\n assert candidate(s = \"aaaaabaaabaaaabaaaaabaaaa\") == 99\n assert candidate(s = \"ababaababab\") == 25\n assert candidate(s = \"noonhighnoon\") == 1\n assert candidate(s = \"tacocattacocattaco\") == 49\n assert candidate(s = \"rotorrotorrotorrotor\") == 75\n assert candidate(s = \"bananaananananab\") == 45\n assert candidate(s = \"zzzyzyzyzyzyzyzyzyzyzyzyz\") == 121\n assert candidate(s = \"deeddeeddeed\") == 1\n assert candidate(s = \"aaaaaabbbbbaaaa\") == 35\n assert candidate(s = \"rotorresistor\") == 15\n assert candidate(s = \"xylophonelevel\") == 5\n assert candidate(s = \"aaabaaaabaaaaabaaaaaaab\") == 77\n assert candidate(s = \"aabbccddeeefffgggzzzzzzzzzzzzzzzzzzzz\") == 99\n assert candidate(s = \"abcdedcbaabcdedcbaabcdedcba\") == 81\n assert candidate(s = \"civic\") == 3\n assert candidate(s = \"rotor\") == 3\n assert candidate(s = \"qwertyuioplkjhgfdsazxcvbnmnbvcxzasdfghjklpoiuytrewq\") == 49\n assert candidate(s = \"abbaabbbaabba\") == 11\n assert candidate(s = \"abcdefghihgfedcba\") == 15\n assert candidate(s = \"tacocattaco\") == 7\n assert candidate(s = \"repaperrepaperrepaper\") == 49\n assert candidate(s = \"aabaaaabaa\") == 25\n assert candidate(s = \"reviled\") == 1\n assert candidate(s = \"amoreroma\") == 7\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjjkkkkllllmmmnnnooopppqqqqrrrrssssttttuuuuvvvvwwwwwxxxxxyyyyyzzzzzzyyyyyxxxwwvvuuttrrqqppoonnmlkkjjiihhggffeeddccbbaa\") == 25\n assert candidate(s = \"xyzyzyzyzyzyzyzyz\") == 63\n assert candidate(s = \"xyxzyzyzyzyzyzyx\") == 35\n assert candidate(s = \"zzzzzzyyyyyxxxwwvvuuttrrqqppoonnmlkkjjiihhggffeeddccbbaa\") == 25\n assert candidate(s = \"rotorabcdrotor\") == 25\n assert candidate(s = \"aabbccddeeeffgghhiii\") == 9\n assert candidate(s = \"abcdedcbabcdedcbabcdedcb\") == 135\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjjkkkkllllmmmnnnooopppqqqqrrrrssssttttuuuuvvvvwwwwwxxxxxyyyyyzzzzz\") == 25\n assert candidate(s = \"abcabcabcabcabc\") == 1\n assert candidate(s = \"deed\") == 1\n assert candidate(s = \"aaaaabbbbbbaaaaa\") == 25\n assert candidate(s = \"levelwasracecar\") == 35\n assert candidate(s = \"racecarabcdeedcba\") == 9\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxProduct(self, s: str) -> int:", "container": "Solution", "callable": "maxProduct", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1961, "task_id": "check-if-string-is-a-prefix-of-array", "difficulty": "Easy", "problem_description": "Given a string s and an array of strings words, determine whether s is a prefix string of words.\nA string s is a prefix string of words if s can be made by concatenating the first k strings in words for some positive k no larger than words.length.\nReturn true if s is a prefix string of words, or false otherwise.\n \nExample 1:\n\nInput: s = \"iloveleetcode\", words = [\"i\",\"love\",\"leetcode\",\"apples\"]\nOutput: true\nExplanation:\ns can be made by concatenating \"i\", \"love\", and \"leetcode\" together.\n\nExample 2:\n\nInput: s = \"iloveleetcode\", words = [\"apples\",\"i\",\"love\",\"leetcode\"]\nOutput: false\nExplanation:\nIt is impossible to make s using a prefix of arr.\n \nConstraints:\n\n1 <= words.length <= 100\n1 <= words[i].length <= 20\n1 <= s.length <= 1000\nwords[i] and s consist of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaaa\",words = ['aa', 'aa']) == True\n assert candidate(s = \"hello\",words = ['he', 'll', 'o']) == True\n assert candidate(s = \"abc\",words = ['a']) == False\n assert candidate(s = \"abc\",words = ['a', 'bc']) == True\n assert candidate(s = \"a\",words = ['a', 'b', 'c']) == True\n assert candidate(s = \"abcd\",words = ['a', 'bcd']) == True\n assert candidate(s = \"cat\",words = ['ca', 't']) == True\n assert candidate(s = \"abcd\",words = ['abc', 'd']) == True\n assert candidate(s = \"hello\",words = ['he', 'l', 'lo']) == True\n assert candidate(s = \"abc\",words = ['ab', 'c']) == True\n assert candidate(s = \"\",words = ['a', 'b', 'c']) == False\n assert candidate(s = \"iloveleetcode\",words = ['apples', 'i', 'love', 'leetcode']) == False\n assert candidate(s = \"hello\",words = ['he', 'llo']) == True\n assert candidate(s = \"abcd\",words = ['a', 'b', 'c', 'd']) == True\n assert candidate(s = \"abcd\",words = ['ab', 'cd']) == True\n assert candidate(s = \"abcd\",words = ['abcd']) == True\n assert candidate(s = \"iloveleetcode\",words = ['i', 'love', 'leetcode', 'apples']) == True\n assert candidate(s = \"xyz\",words = ['x', 'y', 'z']) == True\n assert candidate(s = \"abc\",words = ['a', 'b', 'c']) == True\n assert candidate(s = \"abcd\",words = ['abc']) == False\n assert candidate(s = \"complexprefixstring\",words = ['complex', 'prefix', 'string', 'extra']) == True\n assert candidate(s = \"aquickbrownfox\",words = ['a', 'quick', 'brown', 'fox', 'jumps']) == True\n assert candidate(s = \"onetwothree\",words = ['one', 'two', 'three', 'four', 'five']) == True\n assert candidate(s = \"algorithm\",words = ['algo', 'r', 'ith', 'm']) == True\n assert candidate(s = \"python\",words = ['py', 'th', 'on', 'n']) == True\n assert candidate(s = \"complexprefix\",words = ['com', 'ple', 'xpre', 'fix']) == True\n assert candidate(s = \"concatenate\",words = ['con', 'cat', 'en', 'ate']) == True\n assert candidate(s = \"algorithms\",words = ['algo', 'rithm', 's', 'data']) == True\n assert candidate(s = \"abracadabra\",words = ['abra', 'ca', 'da', 'bra', 'bra']) == True\n assert candidate(s = \"substring\",words = ['sub', 'str', 'ing', 'example']) == True\n assert candidate(s = \"onetwothreefour\",words = ['one', 'two', 'three', 'four', 'five']) == True\n assert candidate(s = \"xyz\",words = ['x', 'y', 'z', 'w']) == True\n assert candidate(s = \"prefixstring\",words = ['pre', 'fix', 'string']) == True\n assert candidate(s = \"programming\",words = ['pro', 'gram', 'ming']) == True\n assert candidate(s = \"concatenate\",words = ['con', 'cat', 'e', 'nate']) == True\n assert candidate(s = \"thisisatest\",words = ['this', 'is', 'a', 'test', 'case']) == True\n assert candidate(s = \"substring\",words = ['sub', 'string', 'abc']) == True\n assert candidate(s = \"mississippi\",words = ['mis', 'si', 'ssippi', 'p']) == True\n assert candidate(s = \"prefixprefix\",words = ['pre', 'fix', 'pre', 'fix', 'pre', 'fix']) == True\n assert candidate(s = \"abcdef\",words = ['a', 'b', 'c', 'def', 'ghi']) == True\n assert candidate(s = \"thisisatest\",words = ['this', 'is', 'a', 'test', 'case']) == True\n assert candidate(s = \"abcdefg\",words = ['a', 'b', 'c', 'd', 'e', 'f', 'g']) == True\n assert candidate(s = \"aaabbbccc\",words = ['aaa', 'bbb', 'ccc', 'ddd']) == True\n assert candidate(s = \"hello\",words = ['h', 'he', 'hel', 'hell', 'hello']) == False\n assert candidate(s = \"abcdabc\",words = ['ab', 'c', 'd', 'abc', 'def']) == True\n assert candidate(s = \"complexstring\",words = ['com', 'plex', 'string', 'other']) == True\n assert candidate(s = \"abcdefghijk\",words = ['abcd', 'ef', 'gh', 'ijk']) == True\n assert candidate(s = \"uniqueprefix\",words = ['unique', 'prefix', 'not']) == True\n assert candidate(s = \"prefix\",words = ['pre', 'fix', 'e', 'f', 'g']) == True\n assert candidate(s = \"oneonetwo\",words = ['one', 'one', 'two', 'three']) == True\n assert candidate(s = \"xyzzy\",words = ['xy', 'zz', 'y', 'z']) == True\n assert candidate(s = \"partialmatch\",words = ['partial', 'non', 'matching', 'words']) == False\n assert candidate(s = \"prefixmatching\",words = ['pre', 'fix', 'mat', 'ching']) == True\n assert candidate(s = \"overlapexample\",words = ['over', 'lap', 'ex', 'ample']) == True\n assert candidate(s = \"boundary\",words = ['bound', 'ary', 'extra']) == True\n assert candidate(s = \"partialmatch\",words = ['par', 'tial', 'match', 'nomatch']) == True\n assert candidate(s = \"abcdabcd\",words = ['abcd', 'abcd', 'abcd']) == True\n assert candidate(s = \"oneonetwo\",words = ['one', 'one', 'two', 'three']) == True\n assert candidate(s = \"abcdefghij\",words = ['abc', 'def', 'ghi', 'j']) == True\n assert candidate(s = \"mississippi\",words = ['mis', 'si', 'ss', 'ippi']) == True\n assert candidate(s = \"matchmaking\",words = ['mat', 'ch', 'mak', 'ing']) == True\n assert candidate(s = \"abcdefg\",words = ['a', 'bc', 'de', 'fg', 'xyz']) == True\n assert candidate(s = \"prefix\",words = ['pre', 'fix', 'ed', 'abc']) == True\n assert candidate(s = \"prefix\",words = ['pre', 'fix', 'post']) == True\n assert candidate(s = \"mnopqr\",words = ['mn', 'op', 'qr', 'st']) == True\n assert candidate(s = \"programminglanguage\",words = ['pro', 'gram', 'ming', 'lan', 'guage']) == True\n assert candidate(s = \"hellohello\",words = ['hello', 'hello', 'world']) == True\n assert candidate(s = \"prefixstring\",words = ['pre', 'fix', 'str', 'ing']) == True\n assert candidate(s = \"hellothere\",words = ['he', 'll', 'o', 'there']) == True\n assert candidate(s = \"concatenation\",words = ['con', 'cat', 'en', 'ation']) == True\n assert candidate(s = \"hellohello\",words = ['hello', 'hello', 'hello']) == True\n assert candidate(s = \"hello\",words = ['h', 'e', 'l', 'l', 'o', 'world']) == True\n assert candidate(s = \"quickbrownfox\",words = ['quick', 'brown', 'fox', 'jump']) == True\n assert candidate(s = \"abcdefghi\",words = ['abc', 'def', 'ghi', 'jkl']) == True\n assert candidate(s = \"one\",words = ['on', 'e', 'extra']) == True\n assert candidate(s = \"notprefix\",words = ['prefix', 'not']) == False\n assert candidate(s = \"abcdefgh\",words = ['a', 'bc', 'def', 'gh']) == True\n assert candidate(s = \"prefixstring\",words = ['prefix', 'string', 'extra']) == True\n assert candidate(s = \"prefix\",words = ['pre', 'fi', 'x']) == True\n assert candidate(s = \"longword\",words = ['lo', 'ng', 'wor', 'd']) == True\n assert candidate(s = \"xxyyyzzz\",words = ['xx', 'yyy', 'zzz', 'a']) == True\n assert candidate(s = \"concatenation\",words = ['con', 'cat', 'en', 'ation']) == True\n assert candidate(s = \"unique\",words = ['un', 'iq', 'ue']) == True\n assert candidate(s = \"abcdefghij\",words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == True\n assert candidate(s = \"algorithm\",words = ['algo', 'r', 'ith', 'm']) == True\n assert candidate(s = \"variouslengths\",words = ['vari', 'ous', 'length', 's']) == True\n assert candidate(s = \"two\",words = ['tw', 'o', 'tw', 'o']) == True\n assert candidate(s = \"abcdabcd\",words = ['abc', 'd', 'abcd']) == True\n assert candidate(s = \"wordplay\",words = ['word', 'play', 'game', 'time']) == True\n assert candidate(s = \"programming\",words = ['pro', 'gram', 'ming', 'lang']) == True\n assert candidate(s = \"concatenation\",words = ['con', 'cat', 'enation', 'ation']) == True\n assert candidate(s = \"supercalifragilisticexpialidocious\",words = ['super', 'cali', 'fragilistic', 'expiali', 'docious']) == True\n assert candidate(s = \"abcdefghij\",words = ['a', 'bc', 'de', 'fghi', 'j']) == True\n assert candidate(s = \"algorithm\",words = ['algo', 'rith', 'm']) == True\n assert candidate(s = \"testcase\",words = ['tes', 't', 'ca', 'se']) == True\n assert candidate(s = \"concatenation\",words = ['con', 'cat', 'e', 'na', 'tion']) == True\n assert candidate(s = \"abcdefghij\",words = ['abc', 'def', 'ghi', 'j']) == True\n assert candidate(s = \"xyz\",words = ['x', 'y', 'z', 'a', 'b', 'c']) == True\n assert candidate(s = \"prefixtest\",words = ['pre', 'fix', 'test', 'suffix']) == True\n assert candidate(s = \"repeated\",words = ['rep', 'e', 'ated']) == True\n assert candidate(s = \"matchingprefix\",words = ['matching', 'prefix', 'matching', 'prefix']) == True\n assert candidate(s = \"abcdexyz\",words = ['abc', 'de', 'xyz', 'mnop']) == True\n assert candidate(s = \"aabbccdd\",words = ['aa', 'bb', 'cc', 'd', 'd']) == True\n assert candidate(s = \"abcdef\",words = ['a', 'b', 'c', 'def']) == True\n assert candidate(s = \"programmingisfun\",words = ['pro', 'gram', 'ming', 'is', 'fun']) == True\n assert candidate(s = \"short\",words = ['shor', 't']) == True\n assert candidate(s = \"mississippi\",words = ['mis', 'si', 's', 'ip', 'pi']) == False\n assert candidate(s = \"repeatedword\",words = ['repeated', 'word', 'repeated']) == True\n assert candidate(s = \"rapiddevelopment\",words = ['rap', 'id', 'devel', 'op', 'ment']) == True\n assert candidate(s = \"onetwothree\",words = ['one', 'two', 'three', 'four']) == True\n assert candidate(s = \"interviewquestion\",words = ['inter', 'view', 'quest', 'ion']) == True\n assert candidate(s = \"abcdabcd\",words = ['abcd', 'abcd']) == True\n assert candidate(s = \"longstring\",words = ['long', 'string', 'extrastuff']) == True\n assert candidate(s = \"xyz\",words = ['xy', 'z', 'a', 'b']) == True\n assert candidate(s = \"thisisatest\",words = ['this', 'is', 'a', 'test']) == True\n assert candidate(s = \"abcdefg\",words = ['abc', 'def', 'g', 'h']) == True\n assert candidate(s = \"hellothere\",words = ['he', 'll', 'ot', 'her', 'e']) == True\n assert candidate(s = \"buildingblocks\",words = ['building', 'block', 's']) == True\n assert candidate(s = \"abcdefghij\",words = ['abc', 'de', 'f', 'gh', 'ij']) == True\n assert candidate(s = \"prefixmatch\",words = ['prefix', 'ma', 'tch']) == True\n assert candidate(s = \"python\",words = ['py', 'th', 'on', 'o']) == True\n assert candidate(s = \"python\",words = ['py', 't', 'h', 'o', 'n', 'extra']) == True\n assert candidate(s = \"aabbcc\",words = ['aa', 'bb', 'cc', 'dd']) == True\n assert candidate(s = \"abacax\",words = ['aba', 'c', 'ax', 'a']) == True\n assert candidate(s = \"aabbcc\",words = ['aa', 'bb', 'cc', 'dd']) == True\n"}, "metadata": {"canonical_parameter_names": ["s", "words"], "leetcode_dataset_entry_point": "Solution().isPrefixString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def isPrefixString(self, s: str, words: list[str]) -> bool:", "container": "Solution", "callable": "isPrefixString", "parameters": [{"name": "s", "type": "str"}, {"name": "words", "type": "list[str]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1962, "task_id": "remove-stones-to-minimize-the-total", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array piles, where piles[i] represents the number of stones in the ith pile, and an integer k. You should apply the following operation exactly k times:\n\nChoose any piles[i] and remove floor(piles[i] / 2) stones from it.\n\nNotice that you can apply the operation on the same pile more than once.\nReturn the minimum possible total number of stones remaining after applying the k operations.\nfloor(x) is the greatest integer that is smaller than or equal to x (i.e., rounds x down).\n \nExample 1:\n\nInput: piles = [5,4,9], k = 2\nOutput: 12\nExplanation: Steps of a possible scenario are:\n- Apply the operation on pile 2. The resulting piles are [5,4,5].\n- Apply the operation on pile 0. The resulting piles are [3,4,5].\nThe total number of stones in [3,4,5] is 12.\n\nExample 2:\n\nInput: piles = [4,3,6,7], k = 3\nOutput: 12\nExplanation: Steps of a possible scenario are:\n- Apply the operation on pile 2. The resulting piles are [4,3,3,7].\n- Apply the operation on pile 3. The resulting piles are [4,3,3,4].\n- Apply the operation on pile 0. The resulting piles are [2,3,3,4].\nThe total number of stones in [2,3,3,4] is 12.\n\n \nConstraints:\n\n1 <= piles.length <= 105\n1 <= piles[i] <= 104\n1 <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(piles = [1, 2, 3, 4, 5],k = 10) == 5\n assert candidate(piles = [10, 10, 10, 10],k = 4) == 20\n assert candidate(piles = [5, 4, 9],k = 2) == 12\n assert candidate(piles = [10, 10, 10],k = 1) == 25\n assert candidate(piles = [100, 200, 300],k = 10) == 57\n assert candidate(piles = [4, 3, 6, 7],k = 3) == 12\n assert candidate(piles = [100, 200, 300],k = 1) == 450\n assert candidate(piles = [10000, 10000, 10000],k = 10000) == 3\n assert candidate(piles = [100, 200, 300],k = 2) == 350\n assert candidate(piles = [100, 100, 100],k = 10) == 33\n assert candidate(piles = [1],k = 1) == 1\n assert candidate(piles = [10000, 10000, 10000],k = 10000) == 3\n assert candidate(piles = [10, 10, 10],k = 5) == 11\n assert candidate(piles = [1, 2, 3, 4, 5],k = 5) == 8\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 15\n assert candidate(piles = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],k = 5000) == 10\n assert candidate(piles = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1],k = 100) == 25\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000],k = 25000) == 5\n assert candidate(piles = [1000, 500, 250, 125],k = 10) == 252\n assert candidate(piles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == 20\n assert candidate(piles = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],k = 100) == 10\n assert candidate(piles = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 50) == 1441\n assert candidate(piles = [9999, 9998, 9997, 9996, 9995],k = 100) == 5\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(piles = [1000, 999, 998, 997, 996, 995],k = 15) == 1123\n assert candidate(piles = [10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19],k = 50) == 149\n assert candidate(piles = [9999],k = 10000) == 1\n assert candidate(piles = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 1000) == 10\n assert candidate(piles = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 100) == 10\n assert candidate(piles = [1, 10, 100, 1000, 10000],k = 100) == 5\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 50) == 10\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 117\n assert candidate(piles = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991],k = 1000) == 10\n assert candidate(piles = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 1000) == 20\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 32\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 10\n assert candidate(piles = [1, 100, 1000, 10000, 10000, 1000, 100, 1],k = 50000) == 8\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 100) == 50\n assert candidate(piles = [50, 25, 75, 200, 150],k = 5) == 201\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 20\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 20\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 20\n assert candidate(piles = [10000, 1000, 100, 10, 1],k = 15000) == 5\n assert candidate(piles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1000) == 20\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 200) == 10\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000],k = 1000) == 5\n assert candidate(piles = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 1000) == 10\n assert candidate(piles = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512],k = 100) == 20\n assert candidate(piles = [9999, 10000, 10001],k = 10000) == 3\n assert candidate(piles = [1000, 500, 250, 125, 63, 32, 16, 8, 4, 2, 1],k = 30) == 63\n assert candidate(piles = [999, 1000, 1001, 1002, 1003],k = 10) == 1253\n assert candidate(piles = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 2500) == 20\n assert candidate(piles = [10000, 5000, 2500, 1250, 625],k = 20) == 785\n assert candidate(piles = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 30) == 63\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000],k = 100000) == 5\n assert candidate(piles = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 1000) == 20\n assert candidate(piles = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 50) == 20\n assert candidate(piles = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],k = 50) == 1441\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 100) == 15\n assert candidate(piles = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 500) == 20\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 20\n assert candidate(piles = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 20) == 253\n assert candidate(piles = [9999, 9999, 9999, 9999],k = 100000) == 4\n assert candidate(piles = [1, 10, 100, 1000, 10000],k = 10) == 315\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 20\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1000) == 10\n assert candidate(piles = [500, 300, 200, 100],k = 5) == 400\n assert candidate(piles = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 30) == 31\n assert candidate(piles = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111],k = 10000) == 9\n assert candidate(piles = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 100) == 11\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 5000) == 31\n assert candidate(piles = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],k = 50) == 3130\n assert candidate(piles = [5000, 4000, 3000, 2000, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],k = 100) == 16\n assert candidate(piles = [1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576],k = 100000) == 10\n assert candidate(piles = [10, 15, 20, 25, 30, 35, 40, 45, 50],k = 100) == 9\n assert candidate(piles = [9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999],k = 10000) == 20\n assert candidate(piles = [9999, 1, 2, 3, 4, 5],k = 10) == 25\n assert candidate(piles = [1000, 1000, 1000, 1000, 1000],k = 50) == 5\n assert candidate(piles = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],k = 100) == 10\n assert candidate(piles = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],k = 5000) == 10\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 50000) == 10\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 50) == 30\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 100) == 20\n"}, "metadata": {"canonical_parameter_names": ["piles", "k"], "leetcode_dataset_entry_point": "Solution().minStoneSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minStoneSum(self, piles: list[int], k: int) -> int:", "container": "Solution", "callable": "minStoneSum", "parameters": [{"name": "piles", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1963, "task_id": "minimum-number-of-swaps-to-make-the-string-balanced", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string s of even length n. The string consists of exactly n / 2 opening brackets '[' and n / 2 closing brackets ']'.\nA string is called balanced if and only if:\n\nIt is the empty string, or\nIt can be written as AB, where both A and B are balanced strings, or\nIt can be written as [C], where C is a balanced string.\n\nYou may swap the brackets at any two indices any number of times.\nReturn the minimum number of swaps to make s balanced.\n \nExample 1:\n\nInput: s = \"][][\"\nOutput: 1\nExplanation: You can make the string balanced by swapping index 0 with index 3.\nThe resulting string is \"[[]]\".\n\nExample 2:\n\nInput: s = \"]]][[[\"\nOutput: 2\nExplanation: You can do the following to make the string balanced:\n- Swap index 0 with index 4. s = \"[]][][\".\n- Swap index 1 with index 5. s = \"[[][]]\".\nThe resulting string is \"[[][]]\".\n\nExample 3:\n\nInput: s = \"[]\"\nOutput: 0\nExplanation: The string is already balanced.\n\n \nConstraints:\n\nn == s.length\n2 <= n <= 106\nn is even.\ns[i] is either '[' or ']'.\nThe number of opening brackets '[' equals n / 2, and the number of closing brackets ']' equals n / 2.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"[]][[]\") == 1\n assert candidate(s = \"[[[[]]]]\") == 0\n assert candidate(s = \"]][[[]]]\") == 0\n assert candidate(s = \"][][\") == 1\n assert candidate(s = \"]]][[][[\") == 2\n assert candidate(s = \"]]]][[[[\") == 2\n assert candidate(s = \"][[]][\") == 1\n assert candidate(s = \"[][][][]\") == 0\n assert candidate(s = \"[[[]]]\") == 0\n assert candidate(s = \"[[[]]][[]]\") == 0\n assert candidate(s = \"]][[][][\") == 1\n assert candidate(s = \"]]][[[\") == 2\n assert candidate(s = \"[][]\") == 0\n assert candidate(s = \"[]\") == 0\n assert candidate(s = \"]][[\") == 1\n assert candidate(s = \"]]][[[[[[]]]]]\") == 1\n assert candidate(s = \"]][[[]\") == 1\n assert candidate(s = \"[[]][]\") == 0\n assert candidate(s = \"][[][]\") == 1\n assert candidate(s = \"[[[][]]]\") == 0\n assert candidate(s = \"]]]]][[[[[[[]]]]]]\") == 1\n assert candidate(s = \"]]]]][[[[[][][]]]]]][[[[[][][]]]]]\") == 0\n assert candidate(s = \"[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]\") == 1\n assert candidate(s = \"][]]]][[[[[]][[]]]\") == 1\n assert candidate(s = \"]][[[[[[[[[[]]]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]\") == 1\n assert candidate(s = \"]][[[]]]]][[[[[]]]\") == 1\n assert candidate(s = \"]]][[][[[[[]]]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[[[[[][][][]]]]]]][[[[[[[[[][][][]]]]]]][[[[[[[[[][][][]]]]]]]\") == 4\n assert candidate(s = \"]]][[[[]]]][[[[[]]]]][[[[]]]]\") == 0\n assert candidate(s = \"]]][[[][]]][[[[[[[]]]]]][][][[]][[\") == 2\n assert candidate(s = \"]][[[]]][][[[[[[[[]]]]]][][[\") == 2\n assert candidate(s = \"]]][[[[[[[]]]]]]][[[[[]]]]]][[[[]]]]]]]]\") == 0\n assert candidate(s = \"]]]]][[[[[[]]][]]]\") == 1\n assert candidate(s = \"]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[\") == 1\n assert candidate(s = \"[[[[]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]]\") == 0\n assert candidate(s = \"]][[[]]][][[[]]]\") == 0\n assert candidate(s = \"]]]]]]]]][[[[[[[[[[\") == 5\n assert candidate(s = \"[[][]]]][[[][][[]][][[]][[]]\") == 1\n assert candidate(s = \"[[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]]\") == 0\n assert candidate(s = \"]][[[][]]][[[[]]]\") == 1\n assert candidate(s = \"]][[[][]]][[[[[[[]]]]]]\") == 1\n assert candidate(s = \"]]][[[][]][[[\") == 2\n assert candidate(s = \"]]][[[[[[[[[[[][]]]]]]]]][[[[[[[[[][]]]]]]]]][[[[[[[[[][]]]]]]]]]\") == 1\n assert candidate(s = \"[[[[]]]]][[[[]]]]\") == 0\n assert candidate(s = \"[[[[[[]]]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[]]]]]]][[[[[]]]]]][[[[[]]]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]]]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[]]]]]]][[[[[]]]]]][[[[[]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[][]]]]]]][[[[[][]]]]][[[[[][]]]]]\") == 0\n assert candidate(s = \"]]][[]]][[[[][[\") == 3\n assert candidate(s = \"]][[][][][[][]][[]][[\") == 2\n assert candidate(s = \"]]][[[[]][]][][[][]][][[[]][]][][[[]]]\") == 1\n assert candidate(s = \"[][][][][][][][][][][][][][][][][][][][][][][][]\") == 0\n assert candidate(s = \"]][[[]][[]][[[]]]\") == 1\n assert candidate(s = \"[[[[[[[[]]]]]]]][[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]\") == 0\n assert candidate(s = \"]]]]]][[[[[[\") == 3\n assert candidate(s = \"]]]][[[[[][]]][]][[[[[]]]]]\") == 1\n assert candidate(s = \"]]]]][[[[[]]]]\") == 1\n assert candidate(s = \"]]][[[[[[[]]]]][[[[[[]]]]]]][[[[\") == 3\n assert candidate(s = \"]]]]][[[[[]]]][[\") == 2\n assert candidate(s = \"]]][[[[[[[[[[[][][]][[]][]]]]]]][[[[[[[[[][][]][[]][]]]]]]][[[[[[[[[][][]][[]][]]]]]]][[[[[[[[[][]]]]]]]]]\") == 3\n assert candidate(s = \"]]][[[[[[[[[[[][][]]]]]]][[[[[[[[[][][]]]]]]][[[[[[[[[][][]]]]]]][[[[[[[[[][]]]]]]]]]\") == 4\n assert candidate(s = \"]][[[[[[[]]]]]]][[[[[]]]]]\") == 0\n assert candidate(s = \"]]][[[]][[[[]]]][]]]]][][[[[]]]]\") == 0\n assert candidate(s = \"]]][[[[]]][][[[]]]\") == 1\n assert candidate(s = \"]]][[[[[[[]]]]][[[[\") == 3\n assert candidate(s = \"]][[[[[][]]]]]][[[[[][]]]]]][[[[[][]]]]][[\") == 1\n assert candidate(s = \"]]][[[[[[[]]]]]]\") == 1\n assert candidate(s = \"]]][[[]][][[[]]]]\") == 0\n assert candidate(s = \"]][[[][]]][[\") == 1\n assert candidate(s = \"]][[[[[[[[[[]]]]]]]]][[[[[[[[[[[]]]]]]]]]][[[[[[[[[[[]]]]]]]]]]]\") == 1\n assert candidate(s = \"]][[[]]][][[\") == 1\n assert candidate(s = \"]]][[[[[]][[]]]]][[[[[]][[]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[]]]]]]][[[]]]\") == 0\n assert candidate(s = \"]]][[[]]][[[]]]]][[[[[]]]]\") == 1\n assert candidate(s = \"]]][[[][]][[[[[[[]]]]]][]\") == 1\n assert candidate(s = \"]]]]][[[[[[]]]]][[[[]]]]\") == 1\n assert candidate(s = \"]][[[[[][]]]]]][[[[[[[]]]]]][[[[[]]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[]]]][]][[[[]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[[[[[][][]][[]][]]]][][[[[[[[[][][]][[]][]]]][][[[[[[[[][][]][[]][]]]][][[[[[[[[][]]]]]]]]]\") == 6\n assert candidate(s = \"]]][[[[[[[]]]]]]][[[[[]]]]]][[[[[]]]]]]][[[[[]]]]]]]]]]\") == 0\n assert candidate(s = \"]]][[[]]]][[[[\") == 2\n assert candidate(s = \"]]]][][][[[[\") == 2\n assert candidate(s = \"]][[[[[[]]]]]][[[]]\") == 1\n assert candidate(s = \"]][[[[[][]]]]]][[\") == 1\n assert candidate(s = \"]]][[[[[]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[][]]]]]]\") == 1\n assert candidate(s = \"]][[[]][[[]][]]]\") == 0\n assert candidate(s = \"]]][[[[[[[][][]]]]]]][[[[[][][]]]]][[[[[][][]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[]]]]][[[[[[]]]]]]\") == 1\n assert candidate(s = \"]]][[[[]][]]\") == 1\n assert candidate(s = \"]]][[[[[[[]]]]]]]]][[[[[[[[[]]]]]]]]]\") == 0\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minSwaps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minSwaps(self, s: str) -> int:", "container": "Solution", "callable": "minSwaps", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1964, "task_id": "find-the-longest-valid-obstacle-course-at-each-position", "difficulty": "Hard", "problem_description": "You want to build some obstacle courses. You are given a 0-indexed integer array obstacles of length n, where obstacles[i] describes the height of the ith obstacle.\nFor every index i between 0 and n - 1 (inclusive), find the length of the longest obstacle course in obstacles such that:\n\nYou choose any number of obstacles between 0 and i inclusive.\nYou must include the ith obstacle in the course.\nYou must put the chosen obstacles in the same order as they appear in obstacles.\nEvery obstacle (except the first) is taller than or the same height as the obstacle immediately before it.\n\nReturn an array ans of length n, where ans[i] is the length of the longest obstacle course for index i as described above.\n \nExample 1:\n\nInput: obstacles = [1,2,3,2]\nOutput: [1,2,3,3]\nExplanation: The longest valid obstacle course at each position is:\n- i = 0: [1], [1] has length 1.\n- i = 1: [1,2], [1,2] has length 2.\n- i = 2: [1,2,3], [1,2,3] has length 3.\n- i = 3: [1,2,3,2], [1,2,2] has length 3.\n\nExample 2:\n\nInput: obstacles = [2,2,1]\nOutput: [1,2,1]\nExplanation: The longest valid obstacle course at each position is:\n- i = 0: [2], [2] has length 1.\n- i = 1: [2,2], [2,2] has length 2.\n- i = 2: [2,2,1], [1] has length 1.\n\nExample 3:\n\nInput: obstacles = [3,1,5,6,4,2]\nOutput: [1,1,2,3,2,2]\nExplanation: The longest valid obstacle course at each position is:\n- i = 0: [3], [3] has length 1.\n- i = 1: [3,1], [1] has length 1.\n- i = 2: [3,1,5], [3,5] has length 2. [1,5] is also valid.\n- i = 3: [3,1,5,6], [3,5,6] has length 3. [1,5,6] is also valid.\n- i = 4: [3,1,5,6,4], [3,4] has length 2. [1,4] is also valid.\n- i = 5: [3,1,5,6,4,2], [1,2] has length 2.\n\n \nConstraints:\n\nn == obstacles.length\n1 <= n <= 105\n1 <= obstacles[i] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(obstacles = [1]) == [1]\n assert candidate(obstacles = [3, 1, 5, 6, 4, 2]) == [1, 1, 2, 3, 2, 2]\n assert candidate(obstacles = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5]\n assert candidate(obstacles = [10, 9, 2, 5, 3, 7, 101, 18]) == [1, 1, 1, 2, 2, 3, 4, 4]\n assert candidate(obstacles = [10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1]\n assert candidate(obstacles = [2, 2, 1]) == [1, 2, 1]\n assert candidate(obstacles = [1, 3, 5, 6, 8, 7, 9, 4, 10, 2]) == [1, 2, 3, 4, 5, 5, 6, 3, 7, 2]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(obstacles = [1, 3, 5, 7, 9]) == [1, 2, 3, 4, 5]\n assert candidate(obstacles = [1, 2, 3, 2]) == [1, 2, 3, 3]\n assert candidate(obstacles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12]\n assert candidate(obstacles = [5, 1, 5, 2, 5, 3, 5, 4, 5]) == [1, 1, 2, 2, 3, 3, 4, 4, 5]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 3, 4, 5, 6]\n assert candidate(obstacles = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]\n assert candidate(obstacles = [10, 10, 10, 1, 1, 1, 10, 10, 10, 1, 1, 1, 10, 10, 10]) == [1, 2, 3, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 8, 9]\n assert candidate(obstacles = [5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3, 4, 5, 6, 7, 8, 9, 10, 11, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(obstacles = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 2, 7, 3, 7, 4, 7, 5, 7, 6, 7]\n assert candidate(obstacles = [5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 5]) == [1, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 4]\n assert candidate(obstacles = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 2, 4, 5, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == [1, 2, 3, 3, 2, 4, 5, 5, 3, 6, 7, 7, 4, 8, 9]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]\n assert candidate(obstacles = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14]\n assert candidate(obstacles = [7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1]) == [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [3, 2, 1, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17, 16, 18, 17, 19, 18, 20, 19, 21, 20, 22, 21, 23, 22, 24, 23, 25, 24, 26, 25, 27, 26, 28, 27, 29, 28, 30, 29, 31, 30, 32, 31, 33, 32, 34, 33, 35, 34, 36, 35, 37, 36, 38, 37, 39, 38, 40, 39]) == [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38]\n assert candidate(obstacles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 2, 4, 6, 8, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 3, 4, 5, 6]\n assert candidate(obstacles = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7]\n assert candidate(obstacles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 10, 7, 8, 5, 6, 3, 4, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 4, 5, 6, 7]\n assert candidate(obstacles = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]\n assert candidate(obstacles = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]\n assert candidate(obstacles = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 19, 18, 17, 16, 15, 14, 13, 12]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(obstacles = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == [1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7]\n assert candidate(obstacles = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]\n assert candidate(obstacles = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16]\n assert candidate(obstacles = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1, 5, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 3, 2, 4, 5, 5, 4, 4, 3, 6, 7, 7, 6, 5, 5, 4]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 4, 5, 6, 7, 7, 6, 5, 3]\n assert candidate(obstacles = [100000, 99999, 99998, 100000, 100000, 99999, 99998, 99997, 99996, 99995]) == [1, 1, 1, 2, 3, 2, 2, 1, 1, 1]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 6, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(obstacles = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6]\n assert candidate(obstacles = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]\n assert candidate(obstacles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 10, 9, 8, 7, 6, 5, 4, 3]\n assert candidate(obstacles = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 1, 2, 3, 4, 5]\n assert candidate(obstacles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67]\n assert candidate(obstacles = [1, 2, 2, 3, 3, 2, 1, 4, 4, 3, 3, 5, 5, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7]) == [1, 2, 3, 4, 5, 4, 2, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]\n assert candidate(obstacles = [2, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2]) == [1, 2, 3, 4, 2, 3, 4, 5, 6, 7, 8, 9, 6, 7, 8, 9]\n assert candidate(obstacles = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 10, 7, 8, 5, 6, 3, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 2, 2, 3, 4, 5, 5, 6, 6, 7, 8, 9, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 13, 12, 11, 10, 8, 6, 5, 4, 2]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [10000000, 5000000, 7500000, 6000000, 8000000, 9000000, 4000000, 3000000, 2000000, 1000000]) == [1, 1, 2, 2, 3, 4, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(obstacles = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n assert candidate(obstacles = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 2, 6, 3, 6, 4, 6, 5, 6, 6]\n assert candidate(obstacles = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]\n assert candidate(obstacles = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 10, 9, 8, 7, 6, 5, 4, 3]\n assert candidate(obstacles = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == [1, 2, 3, 4, 5, 2, 3, 4, 5, 6]\n assert candidate(obstacles = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(obstacles = [1, 3, 5, 2, 4, 6, 3, 5, 7, 8, 4, 6, 9]) == [1, 2, 3, 2, 3, 4, 3, 4, 5, 6, 4, 5, 7]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == [1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7]\n assert candidate(obstacles = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 11, 10, 9, 8, 7, 6, 5, 3]\n assert candidate(obstacles = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(obstacles = [1, 2, 3, 2, 1, 3, 4, 5, 4, 3, 2, 4, 5, 6, 5, 4, 3, 4, 5]) == [1, 2, 3, 3, 2, 4, 5, 6, 6, 5, 4, 7, 8, 9, 9, 8, 6, 9, 10]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 4, 5, 6, 7, 7, 6, 5, 3, 6, 7, 8, 9]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(obstacles = [1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(obstacles = [3, 1, 2, 3, 4, 2, 1, 4, 3, 2, 5, 6, 4, 5, 7, 8, 9]) == [1, 1, 2, 3, 4, 3, 2, 5, 4, 4, 6, 7, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 2, 8, 3, 7, 4, 7, 5, 7, 6, 7, 9, 3, 10, 4, 8, 5, 8, 6, 8, 7, 8, 11]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(obstacles = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, 12, 13, 14, 15, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 2, 3, 4, 5]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 3, 4, 5, 6, 7, 8, 9, 10, 21]\n assert candidate(obstacles = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 7, 8, 9]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n assert candidate(obstacles = [5, 3, 4, 1, 2, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [1, 1, 2, 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7]\n assert candidate(obstacles = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]\n assert candidate(obstacles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == [1, 2, 3, 4, 2, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 10, 8, 9, 10, 8, 9, 10]\n assert candidate(obstacles = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]\n assert candidate(obstacles = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == [1, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9]\n assert candidate(obstacles = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 5, 3, 4, 5, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1]) == [1, 2, 3, 4, 5, 5, 6, 4, 6, 7, 3, 5, 7, 8, 2, 4, 6, 8, 9, 3]\n assert candidate(obstacles = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990, 9999989, 9999988, 9999987, 9999986, 9999985, 9999984, 9999983, 9999982, 9999981, 9999980, 9999979, 9999978, 9999977, 9999976, 9999975, 9999974, 9999973, 9999972, 9999971]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == [1, 1, 1, 2, 3, 3, 2, 4, 5, 6, 6, 5, 3, 6, 7, 8, 9]\n"}, "metadata": {"canonical_parameter_names": ["obstacles"], "leetcode_dataset_entry_point": "Solution().longestObstacleCourseAtEachPosition", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def longestObstacleCourseAtEachPosition(self, obstacles: list[int]) -> list[int]:", "container": "Solution", "callable": "longestObstacleCourseAtEachPosition", "parameters": [{"name": "obstacles", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1967, "task_id": "number-of-strings-that-appear-as-substrings-in-word", "difficulty": "Easy", "problem_description": "Given an array of strings patterns and a string word, return the number of strings in patterns that exist as a substring in word.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: patterns = [\"a\",\"abc\",\"bc\",\"d\"], word = \"abc\"\nOutput: 3\nExplanation:\n- \"a\" appears as a substring in \"abc\".\n- \"abc\" appears as a substring in \"abc\".\n- \"bc\" appears as a substring in \"abc\".\n- \"d\" does not appear as a substring in \"abc\".\n3 of the strings in patterns appear as a substring in word.\n\nExample 2:\n\nInput: patterns = [\"a\",\"b\",\"c\"], word = \"aaaaabbbbb\"\nOutput: 2\nExplanation:\n- \"a\" appears as a substring in \"aaaaabbbbb\".\n- \"b\" appears as a substring in \"aaaaabbbbb\".\n- \"c\" does not appear as a substring in \"aaaaabbbbb\".\n2 of the strings in patterns appear as a substring in word.\n\nExample 3:\n\nInput: patterns = [\"a\",\"a\",\"a\"], word = \"ab\"\nOutput: 3\nExplanation: Each of the patterns appears as a substring in word \"ab\".\n\n \nConstraints:\n\n1 <= patterns.length <= 100\n1 <= patterns[i].length <= 100\n1 <= word.length <= 100\npatterns[i] and word consist of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(patterns = ['a', 'b', 'c'],word = \"aaaaabbbbb\") == 2\n assert candidate(patterns = ['aa', 'bb', 'cc'],word = \"abcabc\") == 0\n assert candidate(patterns = ['a', 'abc', 'bc', 'd'],word = \"abc\") == 3\n assert candidate(patterns = ['aaa'],word = \"aaaaa\") == 1\n assert candidate(patterns = ['abc'],word = \"abc\") == 1\n assert candidate(patterns = ['xyz', 'xy', 'yz'],word = \"xyz\") == 3\n assert candidate(patterns = ['hello', 'world'],word = \"helloworld\") == 2\n assert candidate(patterns = ['a', 'a', 'a'],word = \"ab\") == 3\n assert candidate(patterns = ['z'],word = \"abcz\") == 1\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e'],word = \"edcba\") == 5\n assert candidate(patterns = ['hello', 'world', 'foo', 'bar'],word = \"helloworldfoo\") == 3\n assert candidate(patterns = ['repeated', 'repeat', 'eat'],word = \"repeatedrepeat\") == 3\n assert candidate(patterns = ['this', 'is', 'a', 'test'],word = \"thisisatest\") == 4\n assert candidate(patterns = ['abc', 'cab', 'bac'],word = \"abacabcabc\") == 3\n assert candidate(patterns = ['aabb', 'bbcc', 'ccdd', 'ddaa'],word = \"aabbccdd\") == 3\n assert candidate(patterns = ['a', 'ab', 'abc', 'abcd'],word = \"abcd\") == 4\n assert candidate(patterns = ['a', 'aa', 'aaa', 'aaaa'],word = \"aaaaaaaa\") == 4\n assert candidate(patterns = ['overlapping', 'lapping', 'lappingo', 'verlapping'],word = \"overlappinglappingoverlappingoverlapping\") == 4\n assert candidate(patterns = ['hello', 'world', 'python', 'programming'],word = \"helloworldpythonprogramming\") == 4\n assert candidate(patterns = ['xyz', 'zyx', 'zxy'],word = \"xyzzyxzyxzxyzyx\") == 3\n assert candidate(patterns = ['xy', 'yx', 'xyz', 'zyx'],word = \"xyzzyx\") == 4\n assert candidate(patterns = ['lorem', 'ipsum', 'dolor', 'sit', 'amet'],word = \"loremipsumdolorsitamet\") == 5\n assert candidate(patterns = ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwx', 'vwxy', 'wxyz'],word = \"abcdefghijklmnopqrstuvwxyz\") == 23\n assert candidate(patterns = ['mnop', 'nopq', 'opqr', 'pqrs', 'qrst'],word = \"mnopqrstu\") == 5\n assert candidate(patterns = ['quick', 'brown', 'fox'],word = \"thequickbrownfox\") == 3\n assert candidate(patterns = ['abcd', 'abcde', 'abcdef'],word = \"abcdefgabcdefg\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'yxz', 'xzy', 'zyx'],word = \"zyxzyxzyxzyx\") == 4\n assert candidate(patterns = ['ab', 'ba', 'aba', 'bab'],word = \"abababab\") == 4\n assert candidate(patterns = ['aaaa', 'bbbb', 'cccc'],word = \"aaaabbbbccccaaaabbbbcccc\") == 3\n assert candidate(patterns = ['aba', 'bba', 'aaa', 'bbb'],word = \"abababababa\") == 1\n assert candidate(patterns = ['repeated', 'pattern', 'substring', 'string'],word = \"repeatedpatternsubstringstring\") == 4\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de', 'ef', 'fg'],word = \"abcdefg\") == 6\n assert candidate(patterns = ['repeated', 'substring', 'example'],word = \"repeatedsubstringexample\") == 3\n assert candidate(patterns = ['overlap', 'lap', 'ap', 'p'],word = \"overlaplapap\") == 4\n assert candidate(patterns = ['hello', 'world', 'python', 'programming'],word = \"programmingworldpython\") == 3\n assert candidate(patterns = ['longer', 'substrings', 'to', 'check'],word = \"thisisalongersubstringtocheck\") == 3\n assert candidate(patterns = ['unique', 'un', 'iq'],word = \"uniqueiq\") == 3\n assert candidate(patterns = ['substring', 'string', 'sub'],word = \"thisisjustasubstringexample\") == 3\n assert candidate(patterns = ['hello', 'world', 'hello', 'world'],word = \"helloworldhello\") == 4\n assert candidate(patterns = ['aaa', 'aa', 'a'],word = \"aaaaaaaaaaaa\") == 3\n assert candidate(patterns = ['z', 'zz', 'zzz'],word = \"zzzzzzzzz\") == 3\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de', 'ef'],word = \"abcdef\") == 5\n assert candidate(patterns = ['123', '234', '345'],word = \"1234567890\") == 3\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],word = \"abcdefghij\") == 10\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e', 'f'],word = \"abcdef\") == 6\n assert candidate(patterns = ['a', 'ab', 'abc', 'abcd', 'abcde'],word = \"abcde\") == 5\n assert candidate(patterns = ['one', 'two', 'three'],word = \"onetwothreeonetwothree\") == 3\n assert candidate(patterns = ['aaa', 'aab', 'aba', 'baa', 'aabaa', 'aaaba', 'aaba', 'baaa'],word = \"aaaabaaaa\") == 8\n assert candidate(patterns = ['hello', 'world', 'helloworld'],word = \"helloworld\") == 3\n assert candidate(patterns = ['quick', 'brown', 'fox'],word = \"thequickbrownfoxjumps\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'yzz', 'zzz'],word = \"xyzzyzyzzz\") == 3\n assert candidate(patterns = ['aaa', 'bbb', 'ccc', 'abc', 'bca', 'cab'],word = \"abcabcabc\") == 3\n assert candidate(patterns = ['abcd', 'dcba', 'abcdabcd'],word = \"abcdabcdabcdabcd\") == 2\n assert candidate(patterns = ['a', 'ab', 'abc', 'abcd', 'abcde'],word = \"abcdefghijklmnopqrstuvwxyz\") == 5\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl'],word = \"abcdefghijkl\") == 4\n assert candidate(patterns = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd'],word = \"abcdeabcdeabcdeabcde\") == 0\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de'],word = \"abcdefg\") == 4\n assert candidate(patterns = ['pattern', 'matching', 'substrings'],word = \"matchingpatternsubstring\") == 2\n assert candidate(patterns = ['ab', 'ba', 'abab', 'baba'],word = \"abababababababab\") == 4\n assert candidate(patterns = ['same', 'sub', 'string', 'test', 'case'],word = \"substringtestcase\") == 4\n assert candidate(patterns = ['aaaa', 'bbbb', 'cccc', 'ddd'],word = \"aaaabbbbccccddd\") == 4\n assert candidate(patterns = ['apple', 'banana', 'cherry'],word = \"cherrybananaapple\") == 3\n assert candidate(patterns = ['cat', 'dog', 'bird', 'fish'],word = \"fishdogcatbird\") == 4\n assert candidate(patterns = ['python', 'java', 'cpp'],word = \"pythonjavacpp\") == 3\n assert candidate(patterns = ['aaa', 'bbb', 'ccc', 'ddd'],word = \"aaabbbcccddd\") == 4\n assert candidate(patterns = ['test', 'sett', 'best'],word = \"bestsett\") == 2\n assert candidate(patterns = ['abc', 'bca', 'cab', 'abcabc'],word = \"abcabcabcabc\") == 4\n assert candidate(patterns = ['aaa', 'aa', 'a'],word = \"aaaaaaaaaa\") == 3\n assert candidate(patterns = ['quick', 'brown', 'fox', 'jump', 'over', 'lazy', 'dog'],word = \"thequickbrownfoxjumpsoverthelazydog\") == 7\n assert candidate(patterns = ['abc', 'cab', 'bca'],word = \"abcabcabcabc\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'xy', 'yx', 'xzy', 'yzx'],word = \"zyxwvutsrqponmlkjihgfedcba\") == 2\n assert candidate(patterns = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff'],word = \"abcdefabcdefabcdef\") == 0\n assert candidate(patterns = ['abc', 'def', 'ghi'],word = \"defabc\") == 2\n assert candidate(patterns = ['quick', 'brown', 'fox'],word = \"thequickbrownfoxjumpsoverthelazydog\") == 3\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],word = \"abcdef ghijklmnopqrstuvwxyz\") == 9\n assert candidate(patterns = ['aaa', 'aa', 'a'],word = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 3\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],word = \"abcdefghijabcdefghij\") == 10\n assert candidate(patterns = ['test', 'string', 'finding', 'substring'],word = \"teststringfindingsubstring\") == 4\n assert candidate(patterns = ['aa', 'aaa', 'aaaa'],word = \"aaaa\") == 3\n assert candidate(patterns = ['short', 'shot', 'dot'],word = \"shortshot\") == 2\n assert candidate(patterns = ['foo', 'bar', 'foobar', 'barfoo'],word = \"foobarbarfoobarfoo\") == 4\n assert candidate(patterns = ['aba', 'bab', 'aba'],word = \"ababababa\") == 3\n assert candidate(patterns = ['hello', 'world', 'python'],word = \"pythonworldhello\") == 3\n assert candidate(patterns = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'],word = \"abcacbcbacbacbcbac\") == 5\n assert candidate(patterns = ['banana', 'ana', 'nan', 'ban'],word = \"banananana\") == 4\n assert candidate(patterns = ['abc', 'abcd', 'abcde'],word = \"abcdefgh\") == 3\n assert candidate(patterns = ['abcd', 'dcba', 'abcd'],word = \"abcdcbaabcd\") == 3\n assert candidate(patterns = ['aaaa', 'bbbb', 'cccc', 'dddd'],word = \"abcdeabcdeabcde\") == 0\n assert candidate(patterns = ['longpattern', 'long', 'pattern'],word = \"longpatternlongpattern\") == 3\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de', 'ef', 'fg', 'gh', 'hi', 'ij'],word = \"abcdefghij\") == 9\n assert candidate(patterns = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz'],word = \"abcdefghijklmnopqrstuvwxyz\") == 24\n assert candidate(patterns = ['zzz', 'zzzz', 'zzzzz'],word = \"zzzzzzzzzz\") == 3\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de'],word = \"abcde\") == 4\n assert candidate(patterns = ['abc', 'bcd', 'cde', 'def'],word = \"abcdefg\") == 4\n assert candidate(patterns = ['abc', 'abcd', 'abcde', 'abcdef'],word = \"abcdefg\") == 4\n assert candidate(patterns = ['test', 'tset', 'sett', 'settset'],word = \"testsettsettset\") == 4\n assert candidate(patterns = ['small', 'medium', 'large', 'extra', 'huge'],word = \"smallmediumlargeextrahuge\") == 5\n assert candidate(patterns = ['pattern', 'tern', 'ternary', 'ternarysearch'],word = \"binarysearchternarysearch\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'yzx'],word = \"xyzzyxzyxzyx\") == 2\n assert candidate(patterns = ['abcd', 'efgh', 'ijkl'],word = \"efghijklabcd\") == 3\n assert candidate(patterns = ['abc', 'cab', 'bac', 'bca', 'acb', 'cba'],word = \"abcabcabc\") == 3\n assert candidate(patterns = ['abc', 'abcabc', 'abcabcabc'],word = \"abcabcabcabc\") == 3\n assert candidate(patterns = ['aaa', 'bbb', 'ccc'],word = \"abacabadabc\") == 0\n assert candidate(patterns = ['one', 'two', 'three', 'onetwothree'],word = \"onetwothreeonetwothree\") == 4\n assert candidate(patterns = ['search', 'sear', 'arch'],word = \"searchingthesearchinthesearch\") == 3\n assert candidate(patterns = ['overlap', 'lap', 'lapping'],word = \"lapping\") == 2\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl'],word = \"abcdefghijklmnopqrstuvwxyz\") == 4\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl'],word = \"abcdefghijk\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'wxy', 'uvw'],word = \"xyzzyxwxyuvw\") == 4\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl'],word = \"abcdefghij\") == 3\n assert candidate(patterns = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yz'],word = \"abcdefghijklmnopqrstuvwxyz\") == 7\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],word = \"abcdefghijklmnopqrstuvwxyz\") == 9\n assert candidate(patterns = ['zz', 'zzz', 'zzzz'],word = \"zzzzzzzzzz\") == 3\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],word = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(patterns = ['example', 'ample', 'mple', 'ple', 'le', 'e'],word = \"exampleexampleexample\") == 6\n assert candidate(patterns = ['ab', 'ba', 'ac', 'ca', 'bc', 'cb'],word = \"abcbaacbba\") == 5\n assert candidate(patterns = ['abc', 'def', 'ghi'],word = \"abcdefghi\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'yzx'],word = \"xyzzyxzyx\") == 2\n assert candidate(patterns = ['zzz', 'zz', 'z'],word = \"zzzzzzzzzz\") == 3\n assert candidate(patterns = ['pattern', 'tern', 'ternary', 'ary'],word = \"patternarypatternary\") == 4\n assert candidate(patterns = ['xyz', 'abc', 'def', 'ghi', 'jkl'],word = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(patterns = ['a', 'ab', 'abc', 'abcd'],word = \"abcdabcdabcd\") == 4\n"}, "metadata": {"canonical_parameter_names": ["patterns", "word"], "leetcode_dataset_entry_point": "Solution().numOfStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numOfStrings(self, patterns: list[str], word: str) -> int:", "container": "Solution", "callable": "numOfStrings", "parameters": [{"name": "patterns", "type": "list[str]"}, {"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1968, "task_id": "array-with-elements-not-equal-to-average-of-neighbors", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums of distinct integers. You want to rearrange the elements in the array such that every element in the rearranged array is not equal to the average of its neighbors.\nMore formally, the rearranged array should have the property such that for every i in the range 1 <= i < nums.length - 1, (nums[i-1] + nums[i+1]) / 2 is not equal to nums[i].\nReturn any rearrangement of nums that meets the requirements.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5]\nOutput: [1,2,4,5,3]\nExplanation:\nWhen i=1, nums[i] = 2, and the average of its neighbors is (1+4) / 2 = 2.5.\nWhen i=2, nums[i] = 4, and the average of its neighbors is (2+5) / 2 = 3.5.\nWhen i=3, nums[i] = 5, and the average of its neighbors is (4+3) / 2 = 3.5.\n\nExample 2:\n\nInput: nums = [6,2,0,9,7]\nOutput: [9,7,6,2,0]\nExplanation:\nWhen i=1, nums[i] = 7, and the average of its neighbors is (9+6) / 2 = 7.5.\nWhen i=2, nums[i] = 6, and the average of its neighbors is (7+2) / 2 = 4.5.\nWhen i=3, nums[i] = 2, and the average of its neighbors is (6+0) / 2 = 3.\nNote that the original array [6,2,0,9,7] also satisfies the conditions.\n \nConstraints:\n\n3 <= nums.length <= 105\n0 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 100000, 50000, 25000, 75000]) == [0, 75000, 25000, 100000, 50000]\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == [10, 40, 20, 50, 30, 60]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13]) == [1, 9, 3, 11, 5, 13, 7]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7]) == [1, 5, 2, 6, 3, 7, 4]\n assert candidate(nums = [3, 1, 2, 5, 4]) == [1, 4, 2, 5, 3]\n assert candidate(nums = [10, 5, 1, 6, 2]) == [1, 6, 2, 10, 5]\n assert candidate(nums = [5, 1, 3, 2, 4]) == [1, 4, 2, 5, 3]\n assert candidate(nums = [5, 10, 15, 20, 25, 30]) == [5, 20, 10, 25, 15, 30]\n assert candidate(nums = [6, 2, 0, 9, 7]) == [0, 7, 2, 9, 6]\n assert candidate(nums = [0, 100, 50, 25, 75]) == [0, 75, 25, 100, 50]\n assert candidate(nums = [10, 20, 30, 40, 50]) == [10, 40, 20, 50, 30]\n assert candidate(nums = [5, 3, 1, 2, 4]) == [1, 4, 2, 5, 3]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [1, 4, 2, 5, 3]\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == [1, 7, 3, 9, 5, 11]\n assert candidate(nums = [10, 0, 5, 3, 8]) == [0, 8, 3, 10, 5]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == [100, 106, 101, 107, 102, 108, 103, 109, 104, 110, 105]\n assert candidate(nums = [31, 41, 59, 26, 53, 58, 97, 93, 23, 84, 62, 64, 33, 83, 27, 95, 0, 88, 49, 51]) == [0, 58, 23, 59, 26, 62, 27, 64, 31, 83, 33, 84, 41, 88, 49, 93, 51, 95, 53, 97]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == [7, 77, 14, 84, 21, 91, 28, 98, 35, 105, 42, 112, 49, 119, 56, 126, 63, 133, 70, 140]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 600, 200, 700, 300, 800, 400, 900, 500, 1000]\n assert candidate(nums = [85, 90, 80, 95, 75, 100, 70, 105, 65, 110]) == [65, 90, 70, 95, 75, 100, 80, 105, 85, 110]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [1, 32, 2, 64, 4, 128, 8, 256, 16, 512]\n assert candidate(nums = [100000, 50000, 25000, 12500, 62500, 31250, 93750, 46875, 15625, 78125]) == [12500, 50000, 15625, 62500, 25000, 78125, 31250, 93750, 46875, 100000]\n assert candidate(nums = [123, 456, 789, 234, 567, 890, 345, 678, 901, 12, 34, 56]) == [12, 456, 34, 567, 56, 678, 123, 789, 234, 890, 345, 901]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986]) == [9986, 9994, 9987, 9995, 9988, 9996, 9989, 9997, 9990, 9998, 9991, 9999, 9992, 10000, 9993]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [5, 3, 8, 6, 11, 9, 14, 12, 17, 15, 20, 18, 23, 21, 26, 24, 29, 27, 32, 30]) == [3, 18, 5, 20, 6, 21, 8, 23, 9, 24, 11, 26, 12, 27, 14, 29, 15, 30, 17, 32]\n assert candidate(nums = [100000, 0, 50000, 25000, 75000, 12500, 87500, 31250, 68750]) == [0, 68750, 12500, 75000, 25000, 87500, 31250, 100000, 50000]\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == [-9, 1, -8, 3, -7, 7, -6, 15, -5, 31, -4, 62, -3, 125, -2, 250, -1, 500, 0, 1000]\n assert candidate(nums = [50, 25, 75, 37, 62, 88, 43, 91, 56, 12]) == [12, 56, 25, 62, 37, 75, 43, 88, 50, 91]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == [1, 5, 1, 5, 2, 5, 2, 6, 3, 6, 3, 7, 3, 8, 3, 9, 4, 9, 4, 9]\n assert candidate(nums = [5, 15, 10, 20, 25, 30, 35, 40, 45, 50]) == [5, 30, 10, 35, 15, 40, 20, 45, 25, 50]\n assert candidate(nums = [5, 15, 10, 20, 25, 12, 30, 18, 28]) == [5, 20, 10, 25, 12, 28, 15, 30, 18]\n assert candidate(nums = [8, 6, 4, 2, 0, 1, 3, 5, 7, 9]) == [0, 5, 1, 6, 2, 7, 3, 8, 4, 9]\n assert candidate(nums = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995, 6, 99994, 7, 99993]) == [1, 99994, 2, 99995, 3, 99996, 4, 99997, 5, 99998, 6, 99999, 7, 100000, 99993]\n assert candidate(nums = [8, 1, 6, 3, 9, 4, 5, 2, 7]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [42, 84, 21, 168, 105, 252, 175, 336, 245, 420, 315, 462, 368]) == [21, 252, 42, 315, 84, 336, 105, 368, 168, 420, 175, 462, 245]\n assert candidate(nums = [8192, 16384, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1, 256, 2, 512, 4, 1024, 8, 2048, 16, 4096, 32, 8192, 64, 16384, 128]\n assert candidate(nums = [1, 4, 2, 5, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15, 8]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0]) == [0, 55555, 11111, 66666, 22222, 77777, 33333, 88888, 44444, 99999]\n assert candidate(nums = [34, 7, 23, 32, 5, 62, 32, 2, 78, 1, 45, 67, 89, 12, 34, 56, 78, 90]) == [1, 34, 2, 45, 5, 56, 7, 62, 12, 67, 23, 78, 32, 78, 32, 89, 34, 90]\n assert candidate(nums = [101, 203, 305, 407, 509, 611, 713, 815, 917, 1019]) == [101, 611, 203, 713, 305, 815, 407, 917, 509, 1019]\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == [15, 90, 30, 105, 45, 120, 60, 135, 75, 150]\n assert candidate(nums = [10, 5, 8, 2, 6, 4, 9, 1, 7, 3]) == [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]\n assert candidate(nums = [1, 5, 3, 9, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == [1, 5, 1, 5, 2, 5, 3, 6, 3, 9, 4, 9]\n assert candidate(nums = [314159, 271828, 161803, 377987, 141421, 271828, 161803, 377987, 141421, 271828]) == [141421, 271828, 141421, 271828, 161803, 314159, 161803, 377987, 271828, 377987]\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125]) == [15, 75, 25, 85, 35, 95, 45, 105, 55, 115, 65, 125]\n assert candidate(nums = [99999, 0, 50000, 25000, 75000, 1, 99998]) == [0, 75000, 1, 99998, 25000, 99999, 50000]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 30, 10, 35, 15, 40, 20, 45, 25, 50]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13]) == [1, 8, 2, 9, 3, 10, 4, 11, 5, 12, 6, 13, 7]\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930]) == [123, 161718, 456, 192021, 789, 222324, 101112, 252627, 131415, 282930]\n assert candidate(nums = [85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == [85, 93, 86, 94, 87, 95, 88, 96, 89, 97, 90, 98, 91, 99, 92, 100]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40]) == [5, 25, 10, 30, 15, 35, 20, 40]\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == [99990, 99995, 99991, 99996, 99992, 99997, 99993, 99998, 99994, 99999]\n assert candidate(nums = [42, 84, 21, 105, 52, 7, 14, 35, 28, 70]) == [7, 42, 14, 52, 21, 70, 28, 84, 35, 105]\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == [1, 13, 2, 21, 3, 34, 5, 55, 8, 89]\n assert candidate(nums = [1000, 2000, 500, 3000, 1500, 4000, 2500, 5000, 3500]) == [500, 3000, 1000, 3500, 1500, 4000, 2000, 5000, 2500]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [5, 55, 15, 65, 25, 75, 35, 85, 45, 95]\n assert candidate(nums = [100000, 0, 50000, 25000, 75000, 125000, 37500, 62500, 187500, 93750]) == [0, 75000, 25000, 93750, 37500, 100000, 50000, 125000, 62500, 187500]\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350, 500, 450, 600]) == [100, 350, 150, 400, 200, 450, 250, 500, 300, 600]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [7, 17, 8, 18, 9, 19, 10, 20, 11, 21, 12, 22, 13, 23, 14, 24, 15, 25, 16]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == [1, 256, 2, 512, 4, 1024, 8, 2048, 16, 4096, 32, 8192, 64, 16384, 128]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10]) == [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == [90, 95, 91, 96, 92, 97, 93, 98, 94, 99]\n assert candidate(nums = [10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009]) == [10000, 10005, 10001, 10006, 10002, 10007, 10003, 10008, 10004, 10009]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [2, 14, 4, 16, 6, 18, 8, 20, 10, 22, 12]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30, 16]\n assert candidate(nums = [50000, 25000, 75000, 12500, 87500, 31250, 68750, 15625, 93750]) == [12500, 68750, 15625, 75000, 25000, 87500, 31250, 93750, 50000]\n assert candidate(nums = [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180]) == [180, 191, 181, 192, 182, 193, 183, 194, 184, 195, 185, 196, 186, 197, 187, 198, 188, 199, 189, 200, 190]\n assert candidate(nums = [8, 6, 4, 2, 0, 1, 3, 5, 7, 9, 11, 13]) == [0, 6, 1, 7, 2, 8, 3, 9, 4, 11, 5, 13]\n assert candidate(nums = [50, 40, 30, 20, 10, 60, 70, 80, 90, 100, 110, 120]) == [10, 70, 20, 80, 30, 90, 40, 100, 50, 110, 60, 120]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15, 8]\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]\n assert candidate(nums = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100]) == [10, 60, 20, 70, 30, 80, 40, 90, 50, 100]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 5, 1, 6, 2, 7, 3, 8, 4, 9]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40]) == [-40, 40, -30, 50, -20, 60, -10, 70, 0, 80, 10, 90, 20, 100, 30]\n assert candidate(nums = [23, 45, 12, 67, 89, 34, 56, 78, 90, 11, 32, 54]) == [11, 54, 12, 56, 23, 67, 32, 78, 34, 89, 45, 90]\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [1, 5, 1, 5, 2, 5, 3, 6, 3, 9, 4]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]) == [100, 111, 101, 112, 102, 113, 103, 114, 104, 115, 105, 116, 106, 117, 107, 118, 108, 119, 109, 120, 110]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == [10, 70, 20, 80, 30, 90, 40, 100, 50, 110, 60, 120]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [10, 90, 20, 100, 30, 110, 40, 120, 50, 130, 60, 140, 70, 150, 80]\n assert candidate(nums = [123456, 654321, 13579, 24680, 98765, 43210]) == [13579, 98765, 24680, 123456, 43210, 654321]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == [-4, 6, -3, 7, -2, 8, -1, 9, 0, 10, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == [7, 63, 14, 70, 21, 77, 28, 84, 35, 91, 42, 98, 49, 105, 56]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == [85, 93, 86, 94, 87, 95, 88, 96, 89, 97, 90, 98, 91, 99, 92, 100]\n assert candidate(nums = [1, 2, 3, 6, 5, 4, 7, 8, 9]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]) == [100, 800, 200, 900, 300, 1000, 400, 1100, 500, 1200, 600, 1300, 700]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == [85, 93, 86, 94, 87, 95, 88, 96, 89, 97, 90, 98, 91, 99, 92]\n assert candidate(nums = [8, 1, 6, 3, 5, 7, 2, 4, 9]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == [1, 100, 2, 200, 3, 300, 4, 400, 5, 500]\n assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995]) == [1, 99996, 2, 99997, 3, 99998, 4, 99999, 99995]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == [1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15, 8]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119]) == [7, 70, 14, 77, 21, 84, 28, 91, 35, 98, 42, 105, 49, 112, 56, 119, 63]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 60, 20, 70, 30, 80, 40, 90, 50, 100]\n assert candidate(nums = [8, 1, 4, 9, 3, 7, 6, 2, 5, 10]) == [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707]) == [101, 456, 123, 505, 202, 606, 303, 707, 404, 789]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 5, 1, 6, 2, 7, 3, 8, 4, 9]\n assert candidate(nums = [15, 10, 5, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == [5, 45, 10, 50, 15, 55, 20, 60, 25, 65, 30, 70, 35, 75, 40]\n assert candidate(nums = [0, 100000, 50000, 25000, 75000, 125000, 37500, 62500, 87500, 162500]) == [0, 75000, 25000, 87500, 37500, 100000, 50000, 125000, 62500, 162500]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [5, 35, 10, 40, 15, 45, 20, 50, 25, 55, 30]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 600, 200, 700, 300, 800, 400, 900, 500, 1000]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [1000, 6000, 2000, 7000, 3000, 8000, 4000, 9000, 5000, 10000]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [10, 90, 20, 100, 30, 110, 40, 120, 50, 130, 60, 140, 70, 150, 80]\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350]) == [100, 300, 150, 350, 200, 400, 250]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7]) == [7, 17, 8, 18, 9, 19, 10, 20, 11, 21, 12, 22, 13, 23, 14, 24, 15, 25, 16]\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120]) == [12, 72, 24, 84, 36, 96, 48, 108, 60, 120]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().rearrangeArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def rearrangeArray(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "rearrangeArray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1970, "task_id": "last-day-where-you-can-still-cross", "difficulty": "Hard", "problem_description": "There is a 1-based binary matrix where 0 represents land and 1 represents water. You are given integers row and col representing the number of rows and columns in the matrix, respectively.\nInitially on day 0, the entire matrix is land. However, each day a new cell becomes flooded with water. You are given a 1-based 2D array cells, where cells[i] = [ri, ci] represents that on the ith day, the cell on the rith row and cith column (1-based coordinates) will be covered with water (i.e., changed to 1).\nYou want to find the last day that it is possible to walk from the top to the bottom by only walking on land cells. You can start from any cell in the top row and end at any cell in the bottom row. You can only travel in the four cardinal directions (left, right, up, and down).\nReturn the last day where it is possible to walk from the top to the bottom by only walking on land cells.\n \nExample 1:\n\n\nInput: row = 2, col = 2, cells = [[1,1],[2,1],[1,2],[2,2]]\nOutput: 2\nExplanation: The above image depicts how the matrix changes each day starting from day 0.\nThe last day where it is possible to cross from top to bottom is on day 2.\n\nExample 2:\n\n\nInput: row = 2, col = 2, cells = [[1,1],[1,2],[2,1],[2,2]]\nOutput: 1\nExplanation: The above image depicts how the matrix changes each day starting from day 0.\nThe last day where it is possible to cross from top to bottom is on day 1.\n\nExample 3:\n\n\nInput: row = 3, col = 3, cells = [[1,2],[2,1],[3,3],[2,2],[1,1],[1,3],[2,3],[3,2],[3,1]]\nOutput: 3\nExplanation: The above image depicts how the matrix changes each day starting from day 0.\nThe last day where it is possible to cross from top to bottom is on day 3.\n\n \nConstraints:\n\n2 <= row, col <= 2 * 104\n4 <= row * col <= 2 * 104\ncells.length == row * col\n1 <= ri <= row\n1 <= ci <= col\nAll the values of cells are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(row = 3,col = 3,cells = [[1, 2], [2, 1], [3, 3], [2, 2], [1, 1], [1, 3], [2, 3], [3, 2], [3, 1]]) == 3\n assert candidate(row = 3,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4]]) == 3\n assert candidate(row = 4,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4]]) == 3\n assert candidate(row = 2,col = 2,cells = [[1, 1], [2, 1], [1, 2], [2, 2]]) == 2\n assert candidate(row = 2,col = 2,cells = [[1, 1], [1, 2], [2, 1], [2, 2]]) == 1\n assert candidate(row = 6,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 1], [2, 6], [3, 1], [3, 6], [4, 1], [4, 6], [5, 1], [5, 6], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5], [4, 2], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5], [3, 3], [4, 4]]) == 5\n assert candidate(row = 5,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [4, 2], [4, 3], [4, 4]]) == 4\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7]]) == 6\n assert candidate(row = 10,col = 10,cells = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10], [9, 10], [8, 10], [7, 10], [6, 10], [5, 10], [4, 10], [3, 10], [2, 10], [1, 10], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]]) == 18\n assert candidate(row = 5,col = 4,cells = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4]]) == 15\n assert candidate(row = 6,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5], [4, 2], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5]]) == 5\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 1], [3, 7], [4, 1], [4, 7], [5, 1], [5, 7], [6, 1], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [4, 2], [4, 6], [5, 2], [5, 6], [6, 2], [6, 6], [4, 3], [4, 4], [4, 5], [5, 3], [5, 4], [5, 5]]) == 6\n assert candidate(row = 5,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 5], [3, 1], [3, 5], [4, 1], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [2, 2], [2, 3], [2, 4], [3, 2], [3, 4], [4, 2], [4, 3], [4, 4]]) == 4\n assert candidate(row = 5,col = 5,cells = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4]]) == 4\n assert candidate(row = 6,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [1, 3], [2, 4], [3, 5], [4, 6], [5, 5], [6, 4], [5, 4], [5, 3], [6, 3], [6, 2], [5, 2], [4, 2], [3, 2], [2, 3], [3, 3], [4, 3], [3, 4], [4, 4], [5, 4], [4, 5], [3, 5], [2, 5], [2, 6], [3, 6], [4, 6], [5, 6], [4, 5], [3, 4], [2, 3], [1, 2], [1, 4], [1, 6], [3, 1], [5, 1], [6, 1]]) == 5\n assert candidate(row = 5,col = 5,cells = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [2, 3], [3, 4], [4, 5], [5, 4], [5, 3], [5, 2], [5, 1], [4, 1], [3, 1], [2, 1], [1, 3], [1, 4], [1, 5], [2, 5], [3, 5], [4, 3], [4, 2], [3, 2], [2, 3], [2, 4], [3, 4], [4, 4], [4, 3], [3, 3], [2, 2], [1, 2]]) == 4\n assert candidate(row = 8,col = 8,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 1], [2, 8], [3, 1], [3, 8], [4, 1], [4, 8], [5, 1], [5, 8], [6, 1], [6, 8], [7, 1], [7, 8], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 7], [4, 2], [4, 7], [5, 2], [5, 7], [6, 2], [6, 7], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [3, 3], [3, 5], [4, 3], [4, 5], [5, 3], [5, 5], [6, 3], [6, 5], [4, 4], [5, 4]]) == 7\n assert candidate(row = 4,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 6], [3, 6], [4, 6], [4, 5], [4, 4], [4, 3], [4, 2], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5]]) == 5\n assert candidate(row = 4,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [4, 1], [4, 6], [4, 2], [4, 3], [4, 4], [4, 5]]) == 5\n assert candidate(row = 10,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5]]) == 4\n assert candidate(row = 9,col = 9,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [4, 5], [6, 5], [3, 5], [7, 5], [2, 5], [8, 5]]) == 8\n assert candidate(row = 8,col = 8,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 1], [2, 8], [3, 1], [3, 8], [4, 1], [4, 8], [5, 1], [5, 8], [6, 1], [6, 8], [7, 1], [7, 8], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 7], [3, 3], [3, 6], [3, 4], [3, 5], [4, 2], [4, 7], [4, 3], [4, 6], [4, 4], [4, 5], [5, 2], [5, 7], [5, 3], [5, 6], [5, 4], [5, 5], [6, 2], [6, 7], [6, 3], [6, 6], [6, 4], [6, 5], [7, 2], [7, 7], [7, 3], [7, 6], [7, 4], [7, 5]]) == 7\n assert candidate(row = 4,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 4], [3, 4], [4, 4], [4, 3], [4, 2], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [3, 3], [3, 2], [3, 1]]) == 3\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 7], [3, 1], [3, 7], [4, 1], [4, 7], [5, 1], [5, 7], [6, 1], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 2], [3, 6], [3, 3], [3, 5], [3, 4], [4, 2], [4, 6], [4, 3], [4, 5], [4, 4], [5, 2], [5, 6], [5, 3], [5, 5], [5, 4], [6, 2], [6, 6], [6, 3], [6, 5], [6, 4]]) == 6\n assert candidate(row = 5,col = 5,cells = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == 20\n assert candidate(row = 6,col = 6,cells = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [6, 4], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5]]) == 36\n assert candidate(row = 10,col = 10,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 10], [3, 1], [3, 10], [4, 1], [4, 10], [5, 1], [5, 10], [6, 1], [6, 10], [7, 1], [7, 10], [8, 1], [8, 10], [9, 1], [9, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [6, 8], [6, 9], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9]]) == 9\n assert candidate(row = 6,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [5, 1], [5, 2], [5, 3], [5, 4], [4, 4], [4, 3], [4, 2], [4, 1], [3, 1], [3, 2], [3, 3], [3, 4], [2, 4], [2, 3], [2, 2], [2, 1]]) == 4\n assert candidate(row = 6,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5]]) == 4\n assert candidate(row = 6,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 1], [2, 6], [3, 1], [3, 6], [4, 1], [4, 6], [5, 1], [5, 6], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 5], [4, 2], [4, 5], [5, 2], [5, 3], [5, 4], [3, 3], [3, 4], [4, 3], [4, 4]]) == 5\n assert candidate(row = 5,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4], [5, 1], [5, 2], [5, 3], [5, 4]]) == 3\n assert candidate(row = 5,col = 6,cells = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [2, 4], [3, 4], [4, 4], [5, 4], [1, 4], [1, 2], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [5, 2], [4, 2], [3, 2], [2, 2], [1, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 5], [5, 6], [5, 6]]) == 21\n assert candidate(row = 8,col = 8,cells = [[1, 4], [1, 5], [2, 4], [2, 5], [3, 4], [3, 5], [4, 4], [4, 5], [5, 4], [5, 5], [6, 4], [6, 5], [7, 4], [7, 5], [8, 4], [8, 5], [1, 1], [1, 2], [1, 3], [1, 6], [1, 7], [1, 8], [2, 1], [2, 2], [2, 3], [2, 6], [2, 7], [2, 8], [3, 1], [3, 2], [3, 3], [3, 6], [3, 7], [3, 8], [4, 1], [4, 2], [4, 3], [4, 6], [4, 7], [4, 8], [5, 1], [5, 2], [5, 3], [5, 6], [5, 7], [5, 8], [6, 1], [6, 2], [6, 3], [6, 6], [6, 7], [6, 8], [7, 1], [7, 2], [7, 3], [7, 6], [7, 7], [7, 8], [8, 1], [8, 2], [8, 3], [8, 6], [8, 7], [8, 8]]) == 21\n assert candidate(row = 5,col = 10,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 10], [3, 1], [3, 10], [4, 1], [4, 10], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 2], [3, 9], [3, 3], [3, 8], [3, 4], [3, 7], [3, 5], [3, 6], [4, 2], [4, 9], [4, 3], [4, 8], [4, 4], [4, 7], [4, 5], [4, 6]]) == 9\n assert candidate(row = 6,col = 6,cells = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 5], [6, 4], [5, 3], [4, 2], [3, 1], [2, 1], [1, 3], [1, 4], [1, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 4], [5, 1], [6, 1], [6, 2], [6, 3]]) == 5\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 7], [7, 1], [7, 7], [3, 3], [4, 4], [5, 5], [2, 2], [6, 6], [3, 2], [3, 4], [4, 3], [4, 5], [5, 4], [5, 6], [2, 3], [2, 4], [2, 5], [2, 6], [6, 2], [6, 3], [6, 4], [6, 5], [1, 3], [1, 4], [1, 5], [1, 6], [7, 3], [7, 4], [7, 5], [7, 6], [3, 1], [3, 5], [3, 6], [3, 7], [5, 1], [5, 2], [5, 3], [5, 7], [2, 1], [2, 7], [6, 1], [6, 7], [4, 1], [4, 2], [4, 6], [4, 7]]) == 8\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 7], [3, 1], [3, 7], [4, 1], [4, 7], [5, 1], [5, 7], [6, 1], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 2], [3, 6], [4, 2], [4, 6], [5, 2], [5, 6], [6, 2], [6, 3], [6, 4], [6, 5], [3, 3], [3, 5], [4, 3], [4, 5], [5, 3], [5, 5], [4, 4]]) == 6\n assert candidate(row = 5,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 5], [3, 1], [3, 5], [4, 1], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [2, 2], [2, 3], [2, 4], [3, 2], [3, 4], [4, 2], [4, 3], [4, 4], [3, 3]]) == 4\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 7], [3, 1], [3, 7], [4, 1], [4, 7], [5, 1], [5, 7], [6, 1], [6, 7], [7, 1], [7, 7], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6]]) == 6\n assert candidate(row = 6,col = 6,cells = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [1, 2], [2, 1], [1, 5], [2, 4], [1, 4], [2, 3], [1, 3], [2, 2], [1, 2], [1, 1]]) == 5\n assert candidate(row = 5,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 5], [3, 1], [3, 5], [4, 1], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [4, 2], [4, 3], [4, 4]]) == 4\n assert candidate(row = 10,col = 10,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 10], [3, 1], [3, 10], [4, 1], [4, 10], [5, 1], [5, 10], [6, 1], [6, 10], [7, 1], [7, 10], [8, 1], [8, 10], [9, 1], [9, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 2], [3, 9], [4, 2], [4, 9], [5, 2], [5, 9], [6, 2], [6, 9], [7, 2], [7, 9], [8, 2], [8, 9], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [3, 3], [3, 5], [3, 7], [4, 3], [4, 5], [4, 7], [5, 3], [5, 5], [5, 7], [6, 3], [6, 5], [6, 7], [7, 3], [7, 5], [7, 7], [5, 4]]) == 9\n assert candidate(row = 7,col = 7,cells = [[1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [6, 4], [7, 4], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [7, 6], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 7]]) == 42\n assert candidate(row = 8,col = 8,cells = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [7, 8], [6, 8], [5, 8], [4, 8], [3, 8], [2, 8], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [7, 4], [6, 4], [5, 4], [4, 4], [3, 4], [2, 4], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [7, 6], [6, 6], [5, 6], [4, 6], [3, 6], [2, 6], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 7]]) == 14\n assert candidate(row = 5,col = 5,cells = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == 20\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 7], [3, 1], [3, 7], [4, 1], [4, 7], [5, 1], [5, 7], [6, 1], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6]]) == 6\n assert candidate(row = 8,col = 8,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 1], [2, 8], [3, 1], [3, 8], [4, 1], [4, 8], [5, 1], [5, 8], [6, 1], [6, 8], [7, 1], [7, 8], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7]]) == 7\n assert candidate(row = 6,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 1], [2, 6], [3, 1], [3, 6], [4, 1], [4, 6], [5, 1], [5, 6], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5], [4, 2], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5]]) == 5\n assert candidate(row = 8,col = 8,cells = [[1, 1], [1, 8], [8, 1], [8, 8], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [3, 3], [4, 4], [5, 5], [6, 6], [3, 2], [3, 4], [4, 3], [4, 5], [5, 4], [5, 6], [6, 5], [6, 3], [3, 1], [3, 5], [3, 6], [3, 7], [5, 1], [5, 2], [5, 3], [5, 7], [2, 1], [2, 7], [6, 1], [6, 7], [4, 1], [4, 2], [4, 6], [4, 7]]) == 9\n assert candidate(row = 8,col = 8,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 1], [2, 8], [3, 1], [3, 8], [4, 1], [4, 8], [5, 1], [5, 8], [6, 1], [6, 8], [7, 1], [7, 8], [8, 1], [8, 8], [8, 7], [8, 6], [8, 5], [8, 4], [8, 3], [8, 2], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7]]) == 7\n assert candidate(row = 10,col = 10,cells = [[1, 5], [1, 6], [2, 5], [2, 6], [3, 5], [3, 6], [4, 5], [4, 6], [5, 5], [5, 6], [6, 5], [6, 6], [7, 5], [7, 6], [8, 5], [8, 6], [9, 5], [9, 6], [10, 5], [10, 6], [1, 1], [1, 2], [1, 3], [1, 4], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 2], [2, 3], [2, 4], [2, 7], [2, 8], [2, 9], [2, 10], [3, 1], [3, 2], [3, 3], [3, 4], [3, 7], [3, 8], [3, 9], [3, 10], [4, 1], [4, 2], [4, 3], [4, 4], [4, 7], [4, 8], [4, 9], [4, 10], [5, 1], [5, 2], [5, 3], [5, 4], [5, 7], [5, 8], [5, 9], [5, 10], [6, 1], [6, 2], [6, 3], [6, 4], [6, 7], [6, 8], [6, 9], [6, 10], [7, 1], [7, 2], [7, 3], [7, 4], [7, 7], [7, 8], [7, 9], [7, 10], [8, 1], [8, 2], [8, 3], [8, 4], [8, 7], [8, 8], [8, 9], [8, 10], [9, 1], [9, 2], [9, 3], [9, 4], [9, 7], [9, 8], [9, 9], [9, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 7], [10, 8], [10, 9], [10, 10]]) == 27\n assert candidate(row = 5,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [5, 3], [5, 2], [5, 1], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 2], [4, 3]]) == 3\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 6], [6, 5], [5, 5], [5, 4], [6, 4], [6, 3], [5, 3], [4, 3], [3, 3], [2, 3], [2, 4], [3, 4], [4, 4], [4, 3], [3, 3], [2, 2], [1, 2], [1, 4], [1, 6], [1, 7], [3, 1], [3, 2], [5, 1], [5, 2], [7, 1], [7, 2], [7, 3], [6, 3], [5, 3], [4, 2], [3, 2], [2, 2], [2, 6], [3, 6], [4, 6], [5, 6], [4, 5], [3, 4], [2, 4], [2, 5], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [4, 6], [3, 5], [2, 5], [1, 5]]) == 6\n assert candidate(row = 4,col = 5,cells = [[1, 2], [1, 3], [1, 4], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [4, 2], [4, 3], [4, 4], [1, 1], [2, 1], [3, 1], [4, 1], [1, 5], [2, 5], [3, 5], [4, 5]]) == 16\n"}, "metadata": {"canonical_parameter_names": ["row", "col", "cells"], "leetcode_dataset_entry_point": "Solution().latestDayToCross", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def latestDayToCross(self, row: int, col: int, cells: list[list[int]]) -> int:", "container": "Solution", "callable": "latestDayToCross", "parameters": [{"name": "row", "type": "int"}, {"name": "col", "type": "int"}, {"name": "cells", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1971, "task_id": "find-if-path-exists-in-graph", "difficulty": "Easy", "problem_description": "There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself.\nYou want to determine if there is a valid path that exists from vertex source to vertex destination.\nGiven edges and the integers n, source, and destination, return true if there is a valid path from source to destination, or false otherwise.\n \nExample 1:\n\n\nInput: n = 3, edges = [[0,1],[1,2],[2,0]], source = 0, destination = 2\nOutput: true\nExplanation: There are two paths from vertex 0 to vertex 2:\n- 0 → 1 → 2\n- 0 → 2\n\nExample 2:\n\n\nInput: n = 6, edges = [[0,1],[0,2],[3,5],[5,4],[4,3]], source = 0, destination = 5\nOutput: false\nExplanation: There is no path from vertex 0 to vertex 5.\n\n \nConstraints:\n\n1 <= n <= 2 * 105\n0 <= edges.length <= 2 * 105\nedges[i].length == 2\n0 <= ui, vi <= n - 1\nui != vi\n0 <= source, destination <= n - 1\nThere are no duplicate edges.\nThere are no self edges.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,edges = [],source = 0,destination = 0) == True\n assert candidate(n = 100,edges = [],source = 0,destination = 99) == False\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 0]],source = 15,destination = 10) == True\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],source = 14,destination = 0) == True\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "source", "destination"], "leetcode_dataset_entry_point": "Solution().validPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def validPath(self, n: int, edges: list[list[int]], source: int, destination: int) -> bool:", "container": "Solution", "callable": "validPath", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "source", "type": "int"}, {"name": "destination", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1974, "task_id": "minimum-time-to-type-word-using-special-typewriter", "difficulty": "Easy", "problem_description": "There is a special typewriter with lowercase English letters 'a' to 'z' arranged in a circle with a pointer. A character can only be typed if the pointer is pointing to that character. The pointer is initially pointing to the character 'a'.\n\nEach second, you may perform one of the following operations:\n\nMove the pointer one character counterclockwise or clockwise.\nType the character the pointer is currently on.\n\nGiven a string word, return the minimum number of seconds to type out the characters in word.\n \nExample 1:\n\nInput: word = \"abc\"\nOutput: 5\nExplanation: \nThe characters are printed as follows:\n- Type the character 'a' in 1 second since the pointer is initially on 'a'.\n- Move the pointer clockwise to 'b' in 1 second.\n- Type the character 'b' in 1 second.\n- Move the pointer clockwise to 'c' in 1 second.\n- Type the character 'c' in 1 second.\n\nExample 2:\n\nInput: word = \"bza\"\nOutput: 7\nExplanation:\nThe characters are printed as follows:\n- Move the pointer clockwise to 'b' in 1 second.\n- Type the character 'b' in 1 second.\n- Move the pointer counterclockwise to 'z' in 2 seconds.\n- Type the character 'z' in 1 second.\n- Move the pointer clockwise to 'a' in 1 second.\n- Type the character 'a' in 1 second.\n\nExample 3:\n\nInput: word = \"zjpc\"\nOutput: 34\nExplanation:\nThe characters are printed as follows:\n- Move the pointer counterclockwise to 'z' in 1 second.\n- Type the character 'z' in 1 second.\n- Move the pointer clockwise to 'j' in 10 seconds.\n- Type the character 'j' in 1 second.\n- Move the pointer clockwise to 'p' in 6 seconds.\n- Type the character 'p' in 1 second.\n- Move the pointer counterclockwise to 'c' in 13 seconds.\n- Type the character 'c' in 1 second.\n\n \nConstraints:\n\n1 <= word.length <= 100\nword consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aaabbbccc\") == 11\n assert candidate(word = \"zyxwvut\") == 14\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 29\n assert candidate(word = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 178\n assert candidate(word = \"qpwoeirutyalskdjfhgzmxncbv\") == 191\n assert candidate(word = \"zjpc\") == 34\n assert candidate(word = \"abcdz\") == 12\n assert candidate(word = \"pqrstuvwxyzabcdefghijklmno\") == 62\n assert candidate(word = \"aaa\") == 3\n assert candidate(word = \"mnopqrstuvwxyzabcdefghijkl\") == 63\n assert candidate(word = \"z\") == 2\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaaaaaaaa\") == 26\n assert candidate(word = \"qpwoeirutyalskdjfhgzmxncbva\") == 197\n assert candidate(word = \"za\") == 4\n assert candidate(word = \"zzz\") == 4\n assert candidate(word = \"qpwoeirutyalskdjfhgzmxcvbn\") == 193\n assert candidate(word = \"mnonmonmomnonmon\") == 47\n assert candidate(word = \"a\") == 1\n assert candidate(word = \"bza\") == 7\n assert candidate(word = \"abc\") == 5\n assert candidate(word = \"az\") == 3\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\") == 52\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\") == 51\n assert candidate(word = \"abacabadabacaba\") == 37\n assert candidate(word = \"mnbvcxzlkjhgfdsapoiuytrewqmnbvcxzlkjhgfdsapoiuytrewq\") == 348\n assert candidate(word = \"adgjmpsvxzbehiklnortuwfyqc\") == 110\n assert candidate(word = \"bbaaccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 79\n assert candidate(word = \"aazzbbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 81\n assert candidate(word = \"mamamamamamamamamamamamamam\") == 351\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 47\n assert candidate(word = \"abcdezyxwvut\") == 27\n assert candidate(word = \"zaqwsxcderfvgytujnhytgfrdxcvbnmzaqwsxcderfv\") == 328\n assert candidate(word = \"mnopqrstuvmnopqrstuvmnopqrstuv\") == 87\n assert candidate(word = \"qwertyuioplkjhgfdsazxcvbnmnbvcxzlkjhgfdsapoiuytrewq\") == 323\n assert candidate(word = \"mamamamamamamamamamamamamamamamamamamamamamamamamamama\") == 702\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzz\") == 70\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 346\n assert candidate(word = \"lkjhgfdsapoiuytrewqzxcvbnm\") == 174\n assert candidate(word = \"mjmlkdjfhakjdhfkahdfkldshfklsjdhfkjd\") == 217\n assert candidate(word = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 130\n assert candidate(word = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\") == 44\n assert candidate(word = \"lkjhgfdsapoiuytrewqmasdfghjkl\") == 178\n assert candidate(word = \"qponmlkjihgfedcba\") == 43\n assert candidate(word = \"jklmnopqrstuvwxyzaaaazzzzz\") == 53\n assert candidate(word = \"wvutsrqponmlkjihgfedcba\") == 49\n assert candidate(word = \"wertyuioplkjhgfdsamnbvcxzabcd\") == 164\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 33\n assert candidate(word = \"abcdpqrsuvxyzefghijkmnotwxyz\") == 79\n assert candidate(word = \"qwertypasdfghjklzxcvbnmqwertypasdfghjklzxcvbnm\") == 312\n assert candidate(word = \"bdfhjlnprtvxz\") == 38\n assert candidate(word = \"qzcvmlkjhgfdsapoiuytrwer\") == 157\n assert candidate(word = \"mnopqrstuvwxynmlkjihgfedcbazyxw\") == 83\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyza\") == 53\n assert candidate(word = \"zyzzzzzzzzzzzzzzzzzzzzzzzzz\") == 30\n assert candidate(word = \"qwerasdfzxcv\") == 99\n assert candidate(word = \"abcdefghijklnmopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 104\n assert candidate(word = \"abcdpqrsuvxyzefghijkmnotw\") == 73\n assert candidate(word = \"dcbazyxwvutsrqponmlkjihgfedcba\") == 62\n assert candidate(word = \"fedcbaZYXWVUTSRQPONMLKJIHGFEDCBA\") == 74\n assert candidate(word = \"acdfghjklmnpqrstvwxyz\") == 46\n assert candidate(word = \"mnopqrstuzyxwvutsrqponmlkjihgfedcba\") == 85\n assert candidate(word = \"zxcvbnmlkjhgfdsapoiuytrewqzxcvbnmlkjhgfdsapoiuytrewq\") == 320\n assert candidate(word = \"lkjhgfdsapoiuytrewqzxcvbnmzxcvbnmlkjhgfdsapoiuytrewq\") == 342\n assert candidate(word = \"fedcbazyxwvutsrqponmlkjihg\") == 56\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbb\") == 40\n assert candidate(word = \"mnopqrlkjihgfedcbazyxwvut\") == 66\n assert candidate(word = \"qpwoeirutyalskdjfhgzxcvbnm\") == 172\n assert candidate(word = \"mlkjihgfedcba\") == 37\n assert candidate(word = \"yzab\") == 9\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 102\n assert candidate(word = \"qzmlkihgfedcba\") == 58\n assert candidate(word = \"bcadefghijklmnopqrstuvwxyz\") == 55\n assert candidate(word = \"aaaaaaaaaaaabbbbbbbbccccccccdddddd\") == 37\n assert candidate(word = \"llllllllllllllllllllllllllllllllllllllllllllllllllllllll\") == 67\n assert candidate(word = \"nlbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkb\") == 392\n assert candidate(word = \"lkjhgfdsazxcvbnmmnbvcxzlkjhgfdsa\") == 176\n assert candidate(word = \"mnopqrsvxyz\") == 36\n assert candidate(word = \"poiuytrewqlkjhgfdsamnbvcxzpoiuytrewqlkjhgfdsamnbvcxz\") == 341\n assert candidate(word = \"qwertypoiuytrewertyuiop\") == 178\n assert candidate(word = \"aaaaabbbbbcccccdddddeeeee\") == 29\n assert candidate(word = \"uqwertyuioplkjhgfdsamnbvcxz\") == 170\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 104\n assert candidate(word = \"qrstuvzxcvbnmlkjhgfedcba\") == 88\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 35\n assert candidate(word = \"qwerasdfzxcvqwerasdfzxcvqwerasdfzxcv\") == 287\n assert candidate(word = \"lkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkm\") == 136\n assert candidate(word = \"zazazazazazazazazazazazazazazaz\") == 62\n assert candidate(word = \"aazzzzyyyyxxxwwvvuuttrrssqqppoonnmmlkkjjiihhggffeeddaa\") == 82\n assert candidate(word = \"jqpnfjwmsvkmrekjijgqpxvukz\") == 175\n assert candidate(word = \"lkjhgfdsapoiuytrewqasdfghjklmnbvcxz\") == 212\n assert candidate(word = \"ejpmytlrzwhgodicuvnkxfsab\") == 190\n assert candidate(word = \"qwertyuioplkjhgfdsazxcvbnmqwertyuioplkjhgfdsazxcvbnm\") == 310\n assert candidate(word = \"qrstuvwxyzaeiou\") == 55\n assert candidate(word = \"aeiouyaeiouyaeiouyaeiouy\") == 126\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcbaa\") == 53\n assert candidate(word = \"poiuytrewqasdfghjklzxcvbnmpoiuytrewqasdfghjklzxcvbnmpoiuytrewq\") == 414\n assert candidate(word = \"abcdefghjklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 101\n assert candidate(word = \"qazwsxedcrfvtgbyhnujmikolpqwazxsedcrfvtgbyhnujmikolpqwaz\") == 361\n assert candidate(word = \"mzaixmsdcvnbmqwerty\") == 169\n assert candidate(word = \"zabcdefghijklmnopqrstuvwxyz\") == 54\n assert candidate(word = \"poiuytrewqlkjhgfdsamnbvcxz\") == 171\n assert candidate(word = \"zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx\") == 111\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaaaaaaaaab\") == 29\n assert candidate(word = \"pppppppppppppppppppppppppppp\") == 39\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 103\n assert candidate(word = \"abcdefghijkmnopqrstuvwxyz\") == 50\n assert candidate(word = \"azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 58\n assert candidate(word = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 97\n assert candidate(word = \"zaazaaazzaa\") == 17\n assert candidate(word = \"zzzaaazzzaaazzzaaazzzaaazzzaaazzz\") == 44\n assert candidate(word = \"zyxcbaqwertyuiopasdfghjklmnbvcxz\") == 181\n assert candidate(word = \"asdfghjklqwertyuiopzxcvbnm\") == 158\n assert candidate(word = \"pqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 82\n assert candidate(word = \"zabcdefghijklmnopqrstuvwxyza\") == 56\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzza\") == 54\n assert candidate(word = \"tgbnhyujmkiolpvcxz\") == 125\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnm\") == 176\n assert candidate(word = \"qazwsxedcrfvtgbyhnujmikolp\") == 177\n assert candidate(word = \"zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx\") == 118\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 77\n assert candidate(word = \"mnbvcxzlkjhgfdsapoiuytrewqasdfghjklpoiuytrewq\") == 295\n assert candidate(word = \"lkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkj\") == 135\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 103\n assert candidate(word = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\") == 64\n assert candidate(word = \"mnopqrstuvwx\") == 35\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcbaqwertyuiop\") == 129\n assert candidate(word = \"abacabadabacabadabacaba\") == 59\n assert candidate(word = \"fedcbazyxwvutsrqponmlkjihgfedcba\") == 68\n assert candidate(word = \"zaqwsxcderfvgytuhjnmkiolp\") == 156\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().minTimeToType", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minTimeToType(self, word: str) -> int:", "container": "Solution", "callable": "minTimeToType", "parameters": [{"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1975, "task_id": "maximum-matrix-sum", "difficulty": "Medium", "problem_description": "You are given an n x n integer matrix. You can do the following operation any number of times:\n\nChoose any two adjacent elements of matrix and multiply each of them by -1.\n\nTwo elements are considered adjacent if and only if they share a border.\nYour goal is to maximize the summation of the matrix's elements. Return the maximum sum of the matrix's elements using the operation mentioned above.\n \nExample 1:\n\n\nInput: matrix = [[1,-1],[-1,1]]\nOutput: 4\nExplanation: We can follow the following steps to reach sum equals 4:\n- Multiply the 2 elements in the first row by -1.\n- Multiply the 2 elements in the first column by -1.\n\nExample 2:\n\n\nInput: matrix = [[1,2,3],[-1,-2,-3],[1,2,3]]\nOutput: 16\nExplanation: We can follow the following step to reach sum equals 16:\n- Multiply the 2 last elements in the second row by -1.\n\n \nConstraints:\n\nn == matrix.length == matrix[i].length\n2 <= n <= 250\n-105 <= matrix[i][j] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[-1, -2], [3, 4]]) == 10\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == 43\n assert candidate(matrix = [[1, 2], [3, -4]]) == 8\n assert candidate(matrix = [[1, 2, 3], [-1, -2, -3], [1, 2, 3]]) == 16\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(matrix = [[1, 2], [3, 4]]) == 10\n assert candidate(matrix = [[100000, -100000], [-100000, 100000]]) == 400000\n assert candidate(matrix = [[1, 0, -1], [0, 1, 0], [-1, 0, 1]]) == 5\n assert candidate(matrix = [[1, -2], [-3, 4]]) == 10\n assert candidate(matrix = [[1, -1], [-1, 1]]) == 4\n assert candidate(matrix = [[-10, -9, -8, -7, -6], [-5, -4, -3, -2, -1], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14]]) == 160\n assert candidate(matrix = [[-1, 2, -3, 4], [5, -6, 7, -8], [-9, 10, -11, 12], [13, -14, 15, -16]]) == 136\n assert candidate(matrix = [[-20, 15, 30], [5, -25, 40], [-10, 25, -35]]) == 205\n assert candidate(matrix = [[0, -100000, 100000, 0], [100000, 0, 0, -100000], [0, 100000, 0, -100000], [-100000, 0, 100000, 0]]) == 800000\n assert candidate(matrix = [[-1, -2, -3, -4], [5, 6, 7, 8], [-9, -10, -11, -12], [13, 14, 15, 16]]) == 136\n assert candidate(matrix = [[100000, 0, 0], [0, 0, 0], [0, 0, -100000]]) == 200000\n assert candidate(matrix = [[1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1]]) == 25\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(matrix = [[-1, 0, 1], [0, -2, 0], [1, 0, -1]]) == 6\n assert candidate(matrix = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]]) == 7\n assert candidate(matrix = [[1, -1], [-1, 1], [1, -1], [-1, 1]]) == 8\n assert candidate(matrix = [[10, 20, 30], [-40, -50, -60], [70, 80, 90]]) == 430\n assert candidate(matrix = [[-1, 2, -3, 4], [-5, 6, -7, 8], [9, -10, 11, -12], [13, -14, 15, -16]]) == 136\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, -25]]) == 47\n assert candidate(matrix = [[0, 0, 0], [0, -1, 0], [0, 0, 0]]) == 1\n assert candidate(matrix = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]]) == 7\n assert candidate(matrix = [[1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1]]) == 25\n assert candidate(matrix = [[1000, -1000, 1000, -1000], [1000, -1000, 1000, -1000], [-1000, 1000, -1000, 1000], [-1000, 1000, -1000, 1000]]) == 16000\n assert candidate(matrix = [[1, -2, 3, -4, 5], [-6, 7, -8, 9, -10], [11, -12, 13, -14, 15], [-16, 17, -18, 19, -20], [21, -22, 23, -24, 25]]) == 325\n assert candidate(matrix = [[-1, -1, 1, 1], [1, 1, -1, -1], [-1, -1, 1, 1], [1, 1, -1, -1]]) == 16\n assert candidate(matrix = [[-1, 1, -1, 1], [-1, 1, -1, 1], [-1, 1, -1, 1], [-1, 1, -1, 1]]) == 16\n assert candidate(matrix = [[-1, 2, -3, 4, -5], [5, -4, 3, -2, 1], [-1, 2, -3, 4, -5], [5, -4, 3, -2, 1], [-1, 2, -3, 4, -5]]) == 73\n assert candidate(matrix = [[-1, -2, -3, -4], [-5, -6, -7, -8], [-9, -10, -11, -12], [-13, -14, -15, -16]]) == 136\n assert candidate(matrix = [[-10000, 20000, -30000], [40000, -50000, 60000], [-70000, 80000, -90000]]) == 430000\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]) == 5050\n assert candidate(matrix = [[100000, 0, -100000, 0], [0, 100000, 0, -100000], [-100000, 0, 100000, 0], [0, -100000, 0, 100000]]) == 800000\n assert candidate(matrix = [[-1, 2, 3], [4, -5, 6], [-7, 8, -9]]) == 45\n assert candidate(matrix = [[-100000, 100000, -100000], [100000, -100000, 100000], [-100000, 100000, -100000]]) == 700000\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == 136\n assert candidate(matrix = [[-1, 2, -3], [4, -5, 6], [-7, 8, -9], [10, -11, 12], [-13, 14, -15]]) == 120\n assert candidate(matrix = [[-99999, 99999], [100000, -100000]]) == 399998\n assert candidate(matrix = [[-1, 2, -3, 4], [-5, 6, -7, 8], [-9, 10, -11, 12], [-13, 14, -15, 16]]) == 136\n assert candidate(matrix = [[-10, -20, -30, -40], [-50, -60, -70, -80], [-90, -100, -110, -120], [-130, -140, -150, -160]]) == 1360\n assert candidate(matrix = [[-100000, -100000], [-100000, -100000]]) == 400000\n assert candidate(matrix = [[-100000, 100000], [-100000, 100000], [100000, -100000], [100000, -100000]]) == 800000\n assert candidate(matrix = [[-5, 3, -2], [-1, 4, -6], [7, -8, 9]]) == 43\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == 43\n assert candidate(matrix = [[1, 2, 3, 4, 5], [-6, -7, -8, -9, -10], [11, 12, 13, 14, 15], [-16, -17, -18, -19, -20], [21, 22, 23, 24, 25]]) == 325\n assert candidate(matrix = [[-50000, 50000, -60000], [60000, -70000, 70000], [-80000, 80000, -90000]]) == 510000\n assert candidate(matrix = [[-1, -2, -3, -4], [-5, -6, -7, -8], [-9, -10, -11, -12], [-13, -14, -15, -16]]) == 136\n assert candidate(matrix = [[1, -1, 2, -2, 3, -3], [4, -4, 5, -5, 6, -6], [7, -7, 8, -8, 9, -9]]) == 88\n assert candidate(matrix = [[-1, 2, -3, 4, -5], [6, -7, 8, -9, 10], [-11, 12, -13, 14, -15], [16, -17, 18, -19, 20], [-21, 22, -23, 24, -25]]) == 323\n assert candidate(matrix = [[-5, -4, -3, -2, -1], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]]) == 205\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [-11, -12, -13, -14, -15], [-16, -17, -18, -19, -20], [21, 22, 23, 24, 25]]) == 325\n assert candidate(matrix = [[1, -2, 3, -4, 5], [-6, 7, -8, 9, -10], [11, -12, 13, -14, 15], [-16, 17, -18, 19, -20], [21, -22, 23, -24, 25]]) == 325\n assert candidate(matrix = [[-99999, 99998, -99997, 99996], [99995, -99994, 99993, -99992], [-99991, 99990, -99989, 99988], [99987, -99986, 99985, -99984]]) == 1599864\n assert candidate(matrix = [[-10, -20, -30], [-40, -50, -60], [-70, -80, -90]]) == 430\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(matrix = [[-10, -20, -30], [-40, -50, -60], [-70, -80, -90]]) == 430\n assert candidate(matrix = [[-1, 0, 1, 0, -1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [-1, 0, 1, 0, -1]]) == 13\n assert candidate(matrix = [[-99999, 100000, 99999], [-100000, -99999, 100000], [99999, -100000, -99999]]) == 699997\n assert candidate(matrix = [[1, -1, 1, -1], [1, -1, 1, -1], [-1, 1, -1, 1], [-1, 1, -1, 1]]) == 16\n assert candidate(matrix = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]) == 450\n assert candidate(matrix = [[-5, -4, -3, -2, -1], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 223\n assert candidate(matrix = [[-1, -1, -1], [1, 1, 1], [-1, -1, -1]]) == 9\n assert candidate(matrix = [[-1, 0, 1], [-2, 0, 2], [-3, 0, 3]]) == 12\n assert candidate(matrix = [[-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1]]) == 36\n assert candidate(matrix = [[-10000, 10000, -10000, 10000, -10000], [10000, -10000, 10000, -10000, 10000], [-10000, 10000, -10000, 10000, -10000], [10000, -10000, 10000, -10000, 10000], [-10000, 10000, -10000, 10000, -10000]]) == 230000\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 25\n assert candidate(matrix = [[1, -1, 1, -1], [-1, 1, -1, 1], [1, -1, 1, -1], [-1, 1, -1, 1]]) == 16\n assert candidate(matrix = [[-100000, 100000, -100000, 100000], [100000, -100000, 100000, -100000], [-100000, 100000, -100000, 100000], [100000, -100000, 100000, -100000]]) == 1600000\n assert candidate(matrix = [[100, -100, 200], [-300, 400, -500], [600, -700, 800]]) == 3700\n assert candidate(matrix = [[1, -2, 3, -4, 5], [6, -7, 8, -9, 10], [11, -12, 13, -14, 15], [16, -17, 18, -19, 20], [21, -22, 23, -24, 25]]) == 325\n assert candidate(matrix = [[-2, 3, -4], [-1, -2, -3], [4, 5, -6]]) == 30\n assert candidate(matrix = [[0, 1, -1], [1, 0, -1], [-1, 1, 0]]) == 6\n assert candidate(matrix = [[100000, -100000, 100000], [-100000, 100000, -100000], [100000, -100000, 100000]]) == 900000\n assert candidate(matrix = [[-5, -4, 3], [2, 1, 0], [-1, 6, -7]]) == 29\n assert candidate(matrix = [[100000, 0, -100000], [-100000, 0, 100000], [0, 100000, 0]]) == 500000\n assert candidate(matrix = [[1, -1, 2, -2], [3, -3, 4, -4], [5, -5, 6, -6], [7, -7, 8, -8]]) == 72\n assert candidate(matrix = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 1\n assert candidate(matrix = [[-1, 2, -3, 4], [-5, 6, -7, 8], [-9, 10, -11, 12], [13, -14, 15, -16]]) == 136\n assert candidate(matrix = [[100, -200, 300, -400], [500, -600, 700, -800], [900, -1000, 1100, -1200], [-1300, 1400, -1500, 1600]]) == 13600\n assert candidate(matrix = [[-1, 2, -3, 4, -5], [6, -7, 8, -9, 10], [-11, 12, -13, 14, -15], [16, -17, 18, -19, 20], [-21, 22, -23, 24, -25]]) == 323\n assert candidate(matrix = [[100000, 100000], [100000, 100000]]) == 400000\n assert candidate(matrix = [[-1, 2, -3, 4], [-5, 6, -7, 8], [9, -10, 11, -12], [-13, 14, -15, 16]]) == 136\n"}, "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().maxMatrixSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxMatrixSum(self, matrix: list[list[int]]) -> int:", "container": "Solution", "callable": "maxMatrixSum", "parameters": [{"name": "matrix", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1976, "task_id": "number-of-ways-to-arrive-at-destination", "difficulty": "Medium", "problem_description": "You are in a city that consists of n intersections numbered from 0 to n - 1 with bi-directional roads between some intersections. The inputs are generated such that you can reach any intersection from any other intersection and that there is at most one road between any two intersections.\nYou are given an integer n and a 2D integer array roads where roads[i] = [ui, vi, timei] means that there is a road between intersections ui and vi that takes timei minutes to travel. You want to know in how many ways you can travel from intersection 0 to intersection n - 1 in the shortest amount of time.\nReturn the number of ways you can arrive at your destination in the shortest amount of time. Since the answer may be large, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: n = 7, roads = [[0,6,7],[0,1,2],[1,2,3],[1,3,3],[6,3,3],[3,5,1],[6,5,1],[2,5,1],[0,4,5],[4,6,2]]\nOutput: 4\nExplanation: The shortest amount of time it takes to go from intersection 0 to intersection 6 is 7 minutes.\nThe four ways to get there in 7 minutes are:\n- 0 ➝ 6\n- 0 ➝ 4 ➝ 6\n- 0 ➝ 1 ➝ 2 ➝ 5 ➝ 6\n- 0 ➝ 1 ➝ 3 ➝ 5 ➝ 6\n\nExample 2:\n\nInput: n = 2, roads = [[1,0,10]]\nOutput: 1\nExplanation: There is only one way to go from intersection 0 to intersection 1, and it takes 10 minutes.\n\n \nConstraints:\n\n1 <= n <= 200\nn - 1 <= roads.length <= n * (n - 1) / 2\nroads[i].length == 3\n0 <= ui, vi <= n - 1\n1 <= timei <= 109\nui != vi\nThere is at most one road connecting any two intersections.\nYou can reach any intersection from any other intersection.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,roads = [[0, 1, 1], [0, 2, 4], [0, 3, 3], [0, 4, 10], [1, 2, 2], [1, 3, 4], [1, 4, 6], [2, 3, 3], [2, 4, 5], [3, 4, 1]]) == 1\n assert candidate(n = 4,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5]]) == 1\n assert candidate(n = 3,roads = [[0, 1, 1], [1, 2, 1], [0, 2, 2]]) == 2\n assert candidate(n = 5,roads = [[0, 1, 2], [0, 4, 8], [1, 2, 6], [1, 4, 2], [2, 3, 3], [3, 4, 2]]) == 1\n assert candidate(n = 5,roads = [[0, 1, 1], [0, 2, 2], [1, 3, 1], [1, 4, 3], [2, 3, 3], [2, 4, 1], [3, 4, 1]]) == 2\n assert candidate(n = 6,roads = [[0, 1, 5], [1, 2, 3], [0, 2, 4], [2, 3, 1], [2, 4, 2], [3, 5, 1], [4, 5, 2]]) == 1\n assert candidate(n = 4,roads = [[0, 1, 1], [0, 2, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1]]) == 2\n assert candidate(n = 7,roads = [[0, 6, 7], [0, 1, 2], [1, 2, 3], [1, 3, 3], [6, 3, 3], [3, 5, 1], [6, 5, 1], [2, 5, 1], [0, 4, 5], [4, 6, 2]]) == 4\n assert candidate(n = 5,roads = [[0, 1, 2], [0, 2, 4], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1]]) == 1\n assert candidate(n = 5,roads = [[0, 1, 1], [0, 2, 1], [1, 2, 1], [1, 3, 1], [2, 4, 1], [3, 4, 1]]) == 1\n assert candidate(n = 4,roads = [[0, 1, 2], [0, 2, 4], [1, 2, 1], [1, 3, 1], [2, 3, 2]]) == 1\n assert candidate(n = 3,roads = [[0, 1, 2], [1, 2, 2], [0, 2, 3]]) == 1\n assert candidate(n = 6,roads = [[0, 1, 4], [1, 2, 4], [2, 3, 3], [3, 4, 2], [4, 5, 2]]) == 1\n assert candidate(n = 2,roads = [[1, 0, 10]]) == 1\n assert candidate(n = 4,roads = [[0, 1, 1], [0, 2, 5], [1, 2, 1], [2, 3, 1]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 4], [2, 3, 1], [2, 4, 2], [3, 5, 3], [3, 6, 2], [4, 5, 4], [4, 6, 1], [5, 7, 2], [6, 7, 1]]) == 2\n assert candidate(n = 8,roads = [[0, 1, 4], [1, 2, 5], [2, 3, 1], [3, 4, 2], [4, 5, 3], [5, 6, 4], [6, 7, 5], [0, 7, 20], [0, 2, 10], [1, 6, 15], [2, 5, 8], [3, 4, 7]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [0, 14, 70], [1, 13, 69], [2, 12, 68], [3, 11, 67], [4, 10, 66], [5, 9, 65], [6, 8, 64]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 1], [7, 8, 2], [8, 9, 1], [9, 10, 2], [10, 11, 3], [11, 12, 1], [12, 13, 2], [13, 14, 1]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 3], [0, 2, 5], [1, 2, 2], [1, 3, 4], [1, 4, 1], [2, 5, 3], [3, 4, 2], [4, 5, 6], [4, 6, 4], [4, 7, 2], [5, 7, 5], [6, 7, 1]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 7, 4], [4, 7, 4], [5, 6, 1], [5, 7, 2], [6, 7, 2]]) == 2\n assert candidate(n = 20,roads = [[0, 1, 2], [0, 2, 10], [0, 3, 5], [1, 4, 1], [1, 5, 3], [1, 6, 4], [2, 5, 2], [2, 7, 6], [3, 6, 5], [3, 8, 7], [4, 9, 1], [4, 10, 2], [5, 9, 4], [5, 10, 3], [5, 11, 1], [6, 11, 3], [7, 11, 2], [7, 12, 10], [8, 12, 5], [8, 13, 3], [9, 13, 4], [9, 14, 6], [10, 14, 5], [11, 14, 3], [11, 15, 2], [11, 16, 1], [12, 16, 2], [12, 17, 10], [13, 17, 5], [14, 17, 3], [14, 18, 2], [14, 19, 1], [15, 18, 2], [16, 19, 3], [17, 19, 1]]) == 2\n assert candidate(n = 6,roads = [[0, 1, 10], [0, 2, 10], [1, 3, 5], [1, 4, 2], [2, 3, 3], [2, 4, 4], [3, 5, 8], [4, 5, 1]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 6], [2, 4, 4], [2, 5, 1], [3, 6, 3], [3, 7, 2], [4, 7, 5], [4, 8, 3], [5, 8, 2], [5, 9, 4], [6, 9, 1], [7, 9, 3]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 6], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 4, 2], [2, 5, 1], [3, 6, 3], [3, 7, 2], [4, 7, 1], [4, 8, 4], [5, 8, 3], [5, 9, 2], [6, 10, 1], [7, 10, 2], [7, 11, 3], [8, 11, 1], [9, 11, 2]]) == 2\n assert candidate(n = 20,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 1], [1, 3, 2], [1, 4, 3], [2, 3, 1], [2, 4, 2], [2, 5, 3], [3, 4, 1], [3, 5, 2], [3, 6, 3], [4, 5, 1], [4, 6, 2], [4, 7, 3], [5, 6, 1], [5, 7, 2], [5, 8, 3], [6, 7, 1], [6, 8, 2], [6, 9, 3], [7, 8, 1], [7, 9, 2], [7, 10, 3], [8, 9, 1], [8, 10, 2], [8, 11, 3], [9, 10, 1], [9, 11, 2], [9, 12, 3], [10, 11, 1], [10, 12, 2], [10, 13, 3], [11, 12, 1], [11, 13, 2], [11, 14, 3], [12, 13, 1], [12, 14, 2], [12, 15, 3], [13, 14, 1], [13, 15, 2], [13, 16, 3], [14, 15, 1], [14, 16, 2], [14, 17, 3], [15, 16, 1], [15, 17, 2], [15, 18, 3], [16, 17, 1], [16, 18, 2], [16, 19, 3], [17, 18, 1], [17, 19, 2], [18, 19, 1]]) == 55403\n assert candidate(n = 15,roads = [[0, 1, 5], [0, 2, 5], [1, 3, 4], [1, 4, 4], [2, 5, 5], [2, 6, 5], [3, 7, 3], [3, 8, 3], [4, 9, 4], [4, 10, 4], [5, 11, 5], [5, 12, 5], [6, 13, 6], [6, 14, 6], [7, 11, 2], [8, 12, 2], [9, 13, 3], [10, 14, 3], [11, 14, 1], [12, 13, 1]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 2], [0, 2, 4], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [0, 3, 5], [1, 4, 3], [2, 5, 6], [3, 6, 7], [4, 7, 8], [5, 8, 9], [6, 9, 10]]) == 2\n assert candidate(n = 15,roads = [[0, 1, 5], [0, 2, 10], [1, 2, 3], [1, 3, 8], [2, 3, 6], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [9, 10, 7], [10, 11, 8], [11, 12, 9], [12, 13, 10], [13, 14, 11], [0, 5, 7], [1, 6, 4], [2, 7, 5], [3, 8, 6], [4, 9, 7], [5, 10, 8], [6, 11, 9], [7, 12, 10], [8, 13, 11], [9, 14, 12]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 2], [1, 3, 3], [2, 4, 4], [3, 4, 3], [3, 5, 5], [4, 6, 6], [5, 7, 7], [6, 8, 8], [7, 8, 9], [8, 9, 10], [0, 3, 4], [1, 4, 5], [2, 5, 6], [3, 6, 7], [4, 7, 8], [5, 8, 9], [6, 9, 10]]) == 2\n assert candidate(n = 9,roads = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 1], [1, 5, 2], [2, 5, 3], [2, 6, 2], [3, 6, 1], [3, 7, 2], [4, 8, 1], [5, 8, 2], [6, 8, 3], [7, 8, 4]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 5], [0, 2, 3], [1, 2, 2], [1, 3, 10], [2, 3, 6], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [0, 9, 15], [1, 8, 8], [2, 7, 7], [3, 6, 5]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 1], [0, 2, 1], [1, 3, 2], [2, 3, 2], [1, 4, 1], [2, 5, 1], [3, 6, 3], [4, 6, 3], [5, 7, 4], [6, 7, 4], [1, 5, 2], [2, 4, 2], [0, 3, 3], [0, 4, 3], [1, 2, 3], [3, 5, 4], [4, 5, 4]]) == 1\n assert candidate(n = 20,roads = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 10, 5], [10, 11, 5], [11, 12, 5], [12, 13, 5], [13, 14, 5], [14, 15, 5], [15, 16, 5], [16, 17, 5], [17, 18, 5], [18, 19, 5], [0, 19, 100], [1, 18, 99], [2, 17, 98], [3, 16, 97], [4, 15, 96], [5, 14, 95], [6, 13, 94], [7, 12, 93], [8, 11, 92], [9, 10, 91]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 5], [0, 2, 3], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 1], [7, 8, 2], [8, 9, 1], [9, 10, 2], [10, 11, 3], [11, 4, 1]]) == 2\n assert candidate(n = 10,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 45], [1, 8, 35], [2, 7, 25], [3, 6, 15], [4, 5, 5]]) == 5\n assert candidate(n = 10,roads = [[0, 1, 4], [0, 2, 3], [1, 3, 2], [1, 4, 1], [2, 3, 5], [2, 4, 2], [3, 5, 1], [4, 5, 3], [5, 6, 2], [5, 7, 1], [6, 8, 2], [7, 8, 1], [8, 9, 3]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 18]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 5], [0, 2, 4], [1, 2, 3], [1, 3, 2], [2, 3, 1], [2, 4, 6], [3, 4, 5], [3, 5, 7], [3, 6, 2], [4, 5, 4], [4, 6, 3], [4, 7, 10], [5, 6, 6], [5, 7, 8], [5, 8, 4], [6, 7, 7], [6, 8, 9], [7, 8, 11], [7, 9, 6], [8, 9, 3], [9, 10, 2], [9, 11, 5], [9, 12, 7], [10, 11, 3], [10, 12, 6], [11, 12, 4], [11, 13, 8], [11, 14, 2], [12, 13, 5], [12, 14, 9], [13, 14, 1]]) == 4\n assert candidate(n = 8,roads = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [0, 7, 70], [1, 6, 60], [2, 5, 50], [3, 4, 40]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 4], [1, 3, 5], [2, 3, 6], [2, 4, 7], [3, 4, 8], [3, 5, 9], [4, 5, 10], [5, 6, 11], [6, 7, 12], [7, 8, 13], [8, 9, 14], [9, 10, 15], [10, 11, 16], [11, 12, 17], [12, 13, 18], [13, 14, 19], [0, 14, 20], [1, 13, 21], [2, 12, 22], [3, 11, 23], [4, 10, 24], [5, 9, 25], [6, 8, 26], [7, 9, 27], [8, 11, 28], [9, 12, 29], [10, 13, 30], [11, 14, 31]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [1, 4, 5], [2, 5, 2], [2, 6, 3], [3, 6, 1], [3, 7, 2], [4, 7, 3], [4, 8, 4], [5, 8, 5], [5, 9, 6], [6, 9, 7], [6, 10, 8], [7, 10, 9], [7, 11, 10], [8, 11, 11], [9, 11, 12]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 1], [7, 8, 2], [8, 9, 1]]) == 1\n assert candidate(n = 9,roads = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 5, 6], [2, 6, 7], [3, 7, 8], [3, 8, 9], [4, 5, 10], [4, 6, 11], [5, 7, 12], [5, 8, 13], [6, 7, 14], [6, 8, 15], [7, 8, 16]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [1, 4, 1], [1, 5, 2], [2, 5, 3], [2, 6, 1], [3, 6, 2], [3, 7, 3], [4, 8, 1], [5, 8, 2], [5, 9, 3], [6, 9, 1], [6, 10, 2], [7, 10, 3], [8, 11, 1], [9, 11, 2], [9, 12, 3], [10, 12, 1], [10, 13, 2], [11, 14, 1], [12, 14, 2], [13, 14, 3]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 12, 120], [12, 13, 130], [13, 14, 140], [0, 14, 900], [1, 13, 800], [2, 12, 700], [3, 11, 600], [4, 10, 500], [5, 9, 400], [6, 8, 300], [7, 9, 200], [8, 10, 100]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [7, 9, 16], [8, 9, 17], [8, 10, 18], [9, 10, 19], [9, 11, 20], [10, 11, 21], [0, 7, 22], [1, 8, 23], [2, 9, 24], [3, 10, 25], [4, 11, 26], [5, 0, 27], [6, 1, 28], [7, 2, 29], [8, 3, 30], [9, 4, 31], [10, 5, 32], [11, 6, 33]]) == 1\n assert candidate(n = 20,roads = [[0, 1, 5], [1, 2, 4], [2, 3, 3], [3, 4, 2], [4, 5, 1], [5, 6, 1], [6, 7, 2], [7, 8, 3], [8, 9, 4], [9, 10, 5], [10, 11, 6], [11, 12, 7], [12, 13, 8], [13, 14, 9], [14, 15, 10], [15, 16, 11], [16, 17, 12], [17, 18, 13], [18, 19, 14], [0, 19, 95], [1, 18, 90], [2, 17, 85], [3, 16, 80], [4, 15, 75], [5, 14, 70], [6, 13, 65], [7, 12, 60], [8, 11, 55], [9, 10, 50]]) == 1\n assert candidate(n = 20,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [7, 9, 16], [8, 9, 17], [8, 10, 18], [9, 10, 19], [9, 11, 20], [10, 11, 21], [10, 12, 22], [11, 12, 23], [11, 13, 24], [12, 13, 25], [12, 14, 26], [13, 14, 27], [13, 15, 28], [14, 15, 29], [14, 16, 30], [15, 16, 31], [15, 17, 32], [16, 17, 33], [16, 18, 34], [17, 18, 35], [17, 19, 36], [18, 19, 37]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 2], [0, 2, 5], [1, 2, 1], [1, 3, 3], [2, 4, 2], [3, 4, 2], [3, 5, 1], [4, 5, 1], [4, 6, 4], [5, 6, 3], [5, 7, 5], [6, 7, 2], [6, 8, 6], [7, 8, 1], [7, 9, 3], [8, 9, 2]]) == 10\n assert candidate(n = 8,roads = [[0, 1, 3], [0, 2, 5], [1, 2, 2], [1, 3, 4], [2, 3, 1], [2, 4, 6], [3, 4, 3], [3, 5, 7], [4, 5, 2], [4, 6, 8], [5, 6, 1], [5, 7, 5], [6, 7, 4]]) == 4\n assert candidate(n = 12,roads = [[0, 1, 2], [0, 3, 1], [1, 2, 3], [1, 3, 2], [2, 4, 1], [2, 5, 2], [3, 4, 4], [3, 5, 3], [4, 6, 1], [4, 7, 2], [5, 6, 2], [5, 7, 3], [6, 8, 1], [6, 9, 2], [7, 8, 3], [7, 9, 4], [8, 10, 1], [8, 11, 2], [9, 10, 3], [9, 11, 4]]) == 2\n assert candidate(n = 18,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [7, 9, 16], [8, 9, 17], [8, 10, 18], [9, 10, 19], [9, 11, 20], [10, 11, 21], [10, 12, 22], [11, 12, 23], [11, 13, 24], [12, 13, 25], [12, 14, 26], [13, 14, 27], [13, 15, 28], [14, 15, 29], [14, 16, 30], [15, 16, 31], [15, 17, 32], [16, 17, 33], [0, 13, 34], [1, 14, 35], [2, 15, 36], [3, 16, 37], [4, 17, 38], [5, 0, 39], [6, 1, 40], [7, 2, 41], [8, 3, 42], [9, 4, 43], [10, 5, 44], [11, 6, 45], [12, 7, 46], [13, 8, 47], [14, 9, 48], [15, 10, 49], [16, 11, 50], [17, 12, 51]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 1], [0, 2, 4], [1, 3, 2], [1, 4, 5], [2, 3, 1], [2, 5, 6], [3, 4, 3], [3, 6, 7], [4, 5, 2], [4, 7, 8], [5, 6, 3], [5, 8, 4], [6, 7, 1], [6, 9, 5], [7, 8, 2], [8, 9, 3]]) == 3\n assert candidate(n = 12,roads = [[0, 1, 2], [0, 2, 5], [0, 3, 10], [1, 4, 1], [1, 5, 3], [1, 6, 4], [2, 5, 2], [2, 7, 6], [3, 6, 5], [3, 8, 7], [4, 9, 1], [4, 10, 2], [5, 9, 4], [5, 10, 3], [5, 11, 1], [6, 11, 3], [7, 11, 2], [8, 11, 5], [9, 11, 2], [10, 11, 4]]) == 2\n assert candidate(n = 10,roads = [[0, 1, 1], [0, 3, 5], [1, 2, 2], [1, 3, 4], [2, 3, 1], [3, 4, 1], [4, 5, 2], [5, 6, 1], [6, 7, 2], [7, 8, 1], [8, 9, 2], [0, 2, 3], [2, 4, 2], [4, 6, 1], [6, 8, 2], [1, 5, 3], [5, 7, 1], [7, 9, 2]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 10], [0, 2, 15], [1, 2, 5], [1, 3, 6], [1, 4, 8], [2, 3, 3], [2, 4, 7], [3, 4, 1], [3, 5, 2], [3, 6, 4], [4, 5, 9], [4, 6, 6], [5, 7, 5], [5, 8, 1], [6, 8, 3], [6, 9, 7], [7, 10, 4], [8, 10, 2], [8, 11, 6], [9, 11, 5], [10, 12, 3], [10, 13, 8], [11, 13, 1], [11, 14, 9], [12, 14, 2], [13, 14, 7]]) == 1\n assert candidate(n = 18,roads = [[0, 1, 10], [0, 2, 5], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 1], [7, 8, 2], [8, 9, 1], [9, 10, 2], [10, 11, 3], [11, 12, 1], [12, 13, 2], [13, 14, 1], [14, 15, 2], [15, 16, 3], [16, 17, 1]]) == 2\n assert candidate(n = 15,roads = [[0, 1, 10], [0, 2, 15], [0, 3, 5], [1, 2, 7], [1, 4, 4], [1, 5, 3], [2, 5, 2], [2, 6, 10], [3, 5, 6], [3, 7, 2], [4, 6, 5], [4, 8, 3], [5, 9, 1], [5, 10, 2], [6, 10, 4], [6, 11, 8], [7, 11, 2], [7, 12, 10], [8, 12, 5], [8, 13, 3], [9, 13, 4], [9, 14, 6], [10, 14, 5], [11, 14, 3]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 5], [0, 2, 3], [0, 3, 4], [1, 2, 2], [1, 3, 10], [2, 3, 6], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [9, 10, 7], [10, 11, 8], [0, 11, 60], [1, 10, 59], [2, 9, 58], [3, 8, 57], [4, 7, 56], [5, 6, 55]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [0, 5, 14], [1, 6, 15], [2, 7, 16], [0, 3, 17], [1, 4, 18], [2, 5, 19], [3, 6, 20], [4, 7, 21]]) == 1\n assert candidate(n = 18,roads = [[0, 1, 2], [0, 2, 10], [0, 3, 5], [1, 4, 1], [1, 5, 3], [1, 6, 4], [2, 5, 2], [2, 7, 6], [3, 6, 5], [3, 8, 7], [4, 9, 1], [4, 10, 2], [5, 9, 4], [5, 10, 3], [5, 11, 1], [6, 11, 3], [7, 11, 2], [7, 12, 10], [8, 12, 5], [8, 13, 3], [9, 13, 4], [9, 14, 6], [10, 14, 5], [11, 14, 3], [11, 15, 2], [11, 16, 1], [12, 16, 2], [12, 17, 10], [13, 17, 5], [14, 17, 3]]) == 1\n assert candidate(n = 7,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 5], [2, 4, 4], [3, 4, 2], [3, 5, 6], [4, 5, 3], [4, 6, 7], [5, 6, 1]]) == 2\n assert candidate(n = 8,roads = [[0, 1, 4], [0, 2, 1], [1, 2, 2], [1, 3, 5], [2, 3, 1], [2, 4, 2], [3, 4, 3], [3, 5, 1], [4, 5, 2], [4, 6, 1], [5, 6, 2], [5, 7, 3], [6, 7, 1]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["n", "roads"], "leetcode_dataset_entry_point": "Solution().countPaths", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countPaths(self, n: int, roads: list[list[int]]) -> int:", "container": "Solution", "callable": "countPaths", "parameters": [{"name": "n", "type": "int"}, {"name": "roads", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1977, "task_id": "number-of-ways-to-separate-numbers", "difficulty": "Hard", "problem_description": "You wrote down many positive integers in a string called num. However, you realized that you forgot to add commas to seperate the different numbers. You remember that the list of integers was non-decreasing and that no integer had leading zeros.\nReturn the number of possible lists of integers that you could have written down to get the string num. Since the answer may be large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: num = \"327\"\nOutput: 2\nExplanation: You could have written down the numbers:\n3, 27\n327\n\nExample 2:\n\nInput: num = \"094\"\nOutput: 0\nExplanation: No numbers can have leading zeros and all numbers must be positive.\n\nExample 3:\n\nInput: num = \"0\"\nOutput: 0\nExplanation: No numbers can have leading zeros and all numbers must be positive.\n\n \nConstraints:\n\n1 <= num.length <= 3500\nnum consists of digits '0' through '9'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"327\") == 2\n assert candidate(num = \"11110000111100001111\") == 30\n assert candidate(num = \"3333333333\") == 42\n assert candidate(num = \"123456789012345678901234567890\") == 1451\n assert candidate(num = \"0\") == 0\n assert candidate(num = \"10101\") == 2\n assert candidate(num = \"987654321\") == 8\n assert candidate(num = \"123\") == 3\n assert candidate(num = \"094\") == 0\n assert candidate(num = \"1111111111111111111111111111111\") == 6842\n assert candidate(num = \"9876543210987654321098765432109876543210\") == 1307\n assert candidate(num = \"101010\") == 3\n assert candidate(num = \"5555555\") == 15\n assert candidate(num = \"9999999999999999999999999999999\") == 6842\n assert candidate(num = \"100100100100100100100\") == 15\n assert candidate(num = \"24680\") == 6\n assert candidate(num = \"12345678901234567890\") == 287\n assert candidate(num = \"1234567890\") == 41\n assert candidate(num = \"11111\") == 7\n assert candidate(num = \"13579\") == 7\n assert candidate(num = \"12345\") == 7\n assert candidate(num = \"1001\") == 1\n assert candidate(num = \"999\") == 3\n assert candidate(num = \"111\") == 3\n assert candidate(num = \"1000000000000000000000000000000\") == 1\n assert candidate(num = \"112113114115116117118119120121\") == 1464\n assert candidate(num = \"11223344556677889900112233445566\") == 4050\n assert candidate(num = \"112233445566778899001122334455\") == 2836\n assert candidate(num = \"3330333033303330333033303330333\") == 481\n assert candidate(num = \"98765432109876543210\") == 67\n assert candidate(num = \"9999999999999999999999999999998\") == 5604\n assert candidate(num = \"123456789101112131415161718192021\") == 3405\n assert candidate(num = \"012345678901234567890123456789\") == 0\n assert candidate(num = \"987654321109876543211098765432110987654321\") == 1638\n assert candidate(num = \"1234567890123456789012345678901\") == 1716\n assert candidate(num = \"1000000000000000000000000000001\") == 1\n assert candidate(num = \"111222333444555666777888999000111222333444555\") == 41226\n assert candidate(num = \"1234567890123456789012345678901234567890\") == 6307\n assert candidate(num = \"1010101010101010101010101010101\") == 176\n assert candidate(num = \"212121212121212121212121212121\") == 1186\n assert candidate(num = \"11110001111000111100011110001111000111100011110001111000\") == 2300\n assert candidate(num = \"123456789876543211234567898765\") == 2137\n assert candidate(num = \"5555555555555555555555555555555555555555555555555\") == 173525\n assert candidate(num = \"123123123123123123123123123123\") == 1474\n assert candidate(num = \"111111111111111111111111111111111111111111111111\") == 147273\n assert candidate(num = \"321321321321321321321321321321\") == 809\n assert candidate(num = \"12312312312312312312312312312312\") == 2069\n assert candidate(num = \"1231231231231231231231231231230\") == 1641\n assert candidate(num = \"123456789876543211234567898765432112345678987654321\") == 41516\n assert candidate(num = \"123123123123123123123123123123123\") == 2438\n assert candidate(num = \"987654321109876543210987654321\") == 310\n assert candidate(num = \"121212121212121212121212121212\") == 1888\n assert candidate(num = \"1234567898765432109876543210987654321098765432109876543210\") == 81400\n assert candidate(num = \"00000000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(num = \"1122334455667788990011223344556677889900\") == 14863\n assert candidate(num = \"1001001001001001001001001001001\") == 42\n assert candidate(num = \"202020202020202020202020202020\") == 176\n assert candidate(num = \"987654321987654321987654321987\") == 423\n assert candidate(num = \"123123123123123123123123123123123123123123123123123123123\") == 78648\n assert candidate(num = \"11112222333344445555666677778888\") == 8349\n assert candidate(num = \"98979695949392919089888786858483\") == 454\n assert candidate(num = \"999000999000999000999000999000999000999000999000999000\") == 1027\n assert candidate(num = \"10203040506070809010\") == 41\n assert candidate(num = \"111222333444555666777888999000\") == 5513\n assert candidate(num = \"2222222222222222222222222222222\") == 6842\n assert candidate(num = \"1234123412341234123412341234123412341234\") == 7113\n assert candidate(num = \"999111999111999111999111999111\") == 987\n assert candidate(num = \"2333233323332333233323332333233323332333233323332333\") == 43205\n assert candidate(num = \"100100100100100100100100100100100100100100100100100\") == 297\n assert candidate(num = \"999999999999999999999999999999999999999999999999\") == 147273\n assert candidate(num = \"1234567891011121314151617181920\") == 2406\n assert candidate(num = \"987654321098765432109876543210\") == 326\n assert candidate(num = \"1231231231231231231231231231231\") == 1751\n assert candidate(num = \"101010101010101010101010101010101010101010101010101\") == 1958\n assert candidate(num = \"999990000099999000009999900000\") == 107\n assert candidate(num = \"999000999000999000999000999000\") == 98\n assert candidate(num = \"99999999988888888877777777666666665555555544444444333333332222222211111111\") == 299850\n assert candidate(num = \"11223344556677889900\") == 616\n assert candidate(num = \"1234567898765432109876543210987654321\") == 5367\n assert candidate(num = \"0123456789012345678901234567890\") == 0\n assert candidate(num = \"10101010101010101010101010101010\") == 231\n assert candidate(num = \"1111111111111111111122222222222222222\") == 21637\n assert candidate(num = \"1010101010101010101010101010102\") == 176\n assert candidate(num = \"22222222222222222222222222222222222222222222222\") == 124754\n assert candidate(num = \"1231231231231231231231231231231231231231231231231231231230\") == 85398\n assert candidate(num = \"12343211234567898765432109876543210\") == 2572\n assert candidate(num = \"123412341234123412341234123412\") == 1471\n assert candidate(num = \"12345432101234543210\") == 199\n assert candidate(num = \"0000000000000000000000000000001\") == 0\n assert candidate(num = \"123456789876543212345678987654321\") == 3452\n assert candidate(num = \"100100100100100100100100100100\") == 42\n assert candidate(num = \"00000000000000000000\") == 0\n assert candidate(num = \"10000000000000000000000000000000000000000000000\") == 1\n assert candidate(num = \"555555555555555555555555555555\") == 5604\n assert candidate(num = \"9999999999999999999999999999999999999999999999\") == 105558\n assert candidate(num = \"303030303030303030303030303030\") == 176\n assert candidate(num = \"1112131415161718192021222324252627282930\") == 12048\n assert candidate(num = \"1212121212121212121212121212121\") == 2059\n assert candidate(num = \"123412341234123412341234123412341234123412341234123412341\") == 69419\n assert candidate(num = \"1213141516171819202122232425262728293031323334353637383940\") == 97025\n assert candidate(num = \"0000000000000000000000000000000\") == 0\n assert candidate(num = \"1010101010101010101010101010101010101010101010\") == 1255\n assert candidate(num = \"1221221221221221221221221221221221221221221221221221\") == 46460\n assert candidate(num = \"123456789101112131415\") == 387\n assert candidate(num = \"1001001001001001001001001001000\") == 42\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().numberOfCombinations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numberOfCombinations(self, num: str) -> int:", "container": "Solution", "callable": "numberOfCombinations", "parameters": [{"name": "num", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1979, "task_id": "find-greatest-common-divisor-of-array", "difficulty": "Easy", "problem_description": "Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums.\nThe greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers.\n \nExample 1:\n\nInput: nums = [2,5,6,9,10]\nOutput: 2\nExplanation:\nThe smallest number in nums is 2.\nThe largest number in nums is 10.\nThe greatest common divisor of 2 and 10 is 2.\n\nExample 2:\n\nInput: nums = [7,5,6,8,3]\nOutput: 1\nExplanation:\nThe smallest number in nums is 3.\nThe largest number in nums is 8.\nThe greatest common divisor of 3 and 8 is 1.\n\nExample 3:\n\nInput: nums = [3,3]\nOutput: 3\nExplanation:\nThe smallest number in nums is 3.\nThe largest number in nums is 3.\nThe greatest common divisor of 3 and 3 is 3.\n\n \nConstraints:\n\n2 <= nums.length <= 1000\n1 <= nums[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [42, 56, 14]) == 14\n assert candidate(nums = [1, 1000]) == 1\n assert candidate(nums = [17, 23, 37, 41]) == 1\n assert candidate(nums = [3, 3]) == 3\n assert candidate(nums = [7, 5, 6, 8, 3]) == 1\n assert candidate(nums = [1000, 1000]) == 1000\n assert candidate(nums = [48, 18, 30]) == 6\n assert candidate(nums = [10, 20, 30, 40, 50]) == 10\n assert candidate(nums = [100, 200, 300, 400, 500]) == 100\n assert candidate(nums = [17, 23, 19, 29, 31]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1000, 1]) == 1\n assert candidate(nums = [48, 18]) == 6\n assert candidate(nums = [2, 5, 6, 9, 10]) == 2\n assert candidate(nums = [48, 180, 120, 240]) == 48\n assert candidate(nums = [54, 24, 36]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [56, 98, 140, 224, 336]) == 56\n assert candidate(nums = [81, 27, 9, 3, 1]) == 1\n assert candidate(nums = [22, 44, 66, 88, 110, 132, 154]) == 22\n assert candidate(nums = [27, 54, 81, 108, 135, 162, 189]) == 27\n assert candidate(nums = [1024, 512, 256, 128, 64]) == 64\n assert candidate(nums = [999, 1000]) == 1\n assert candidate(nums = [4096, 2048, 1024, 512, 256, 128]) == 128\n assert candidate(nums = [84, 60, 48, 36, 24]) == 12\n assert candidate(nums = [81, 27, 54, 162, 81]) == 27\n assert candidate(nums = [29, 29, 29, 29, 29, 29]) == 29\n assert candidate(nums = [83, 166, 332, 664, 996]) == 83\n assert candidate(nums = [123456, 234567, 345678, 456789, 567891, 678912, 789123, 891234, 912345]) == 3\n assert candidate(nums = [999, 333, 666, 111, 222]) == 111\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136]) == 17\n assert candidate(nums = [1000, 1, 500, 250, 750, 200]) == 1\n assert candidate(nums = [60, 48, 36, 24, 12, 6, 3, 1]) == 1\n assert candidate(nums = [441, 49, 147, 343, 735]) == 49\n assert candidate(nums = [1, 1000, 2, 999, 3, 998]) == 1\n assert candidate(nums = [1000, 10, 50, 250, 500]) == 10\n assert candidate(nums = [44, 55, 66, 77, 88, 99]) == 11\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 15\n assert candidate(nums = [999, 998, 997, 996, 995]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500]) == 100\n assert candidate(nums = [31, 62, 93, 124, 155]) == 31\n assert candidate(nums = [77, 143, 209, 286, 187]) == 11\n assert candidate(nums = [42, 42, 42, 42, 42]) == 42\n assert candidate(nums = [98, 49, 147, 245, 343, 441, 539]) == 49\n assert candidate(nums = [17, 23, 29, 31, 37]) == 1\n assert candidate(nums = [13, 13, 13, 13, 13, 13, 13]) == 13\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130]) == 13\n assert candidate(nums = [999, 888, 777, 666, 555]) == 111\n assert candidate(nums = [1000, 750, 500, 250]) == 250\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260]) == 13\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == 111111\n assert candidate(nums = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876]) == 2\n assert candidate(nums = [123, 246, 369, 492, 615, 738, 861, 984, 1107, 1230, 1353, 1476, 1599, 1722, 1845, 1968, 2091, 2214, 2337, 2460]) == 123\n assert candidate(nums = [54, 24, 36, 48, 60]) == 12\n assert candidate(nums = [1000, 1000, 1000, 1000]) == 1000\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 2\n assert candidate(nums = [999, 333, 111, 37, 1]) == 1\n assert candidate(nums = [231, 105, 77, 49, 33, 11, 7]) == 7\n assert candidate(nums = [77, 49, 14, 21, 28]) == 7\n assert candidate(nums = [997, 991, 983, 977, 971, 967, 953, 941, 929, 919, 907, 887, 883]) == 1\n assert candidate(nums = [50, 75, 100, 125, 150, 175, 200]) == 50\n assert candidate(nums = [123456, 234567, 345678, 456789, 567890]) == 2\n assert candidate(nums = [210, 231, 273, 308, 357, 399]) == 21\n assert candidate(nums = [17, 34, 51, 68, 85]) == 17\n assert candidate(nums = [1, 1000]) == 1\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170]) == 17\n assert candidate(nums = [100, 150, 200, 250, 300]) == 100\n assert candidate(nums = [650, 520, 390, 780, 260]) == 260\n assert candidate(nums = [100, 200, 300, 400, 500, 600]) == 100\n assert candidate(nums = [17, 19, 23, 29, 31]) == 1\n assert candidate(nums = [123456, 987654, 111111, 222222, 333333]) == 3\n assert candidate(nums = [123, 456, 789, 987, 654]) == 3\n assert candidate(nums = [33, 66, 99, 132, 165, 198, 231, 264]) == 33\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [101010, 202020, 303030, 404040, 505050, 606060, 707070, 808080, 909090]) == 101010\n assert candidate(nums = [13, 26, 39, 52, 65]) == 13\n assert candidate(nums = [12, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 12\n assert candidate(nums = [17, 34, 51, 68, 85, 102]) == 17\n assert candidate(nums = [1, 1000, 2, 500, 4]) == 1\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290, 319, 348, 377, 406, 435, 464, 493, 522, 551, 580]) == 29\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996]) == 1\n assert candidate(nums = [256, 512, 1024, 2048, 4096]) == 256\n assert candidate(nums = [77, 49, 14, 28, 35, 56]) == 7\n assert candidate(nums = [123, 456, 789, 1011, 1213]) == 1\n assert candidate(nums = [500, 500, 500, 500, 500, 500]) == 500\n assert candidate(nums = [24, 36, 48, 60, 72, 84, 96]) == 24\n assert candidate(nums = [1000, 750, 500, 250, 125, 62, 31]) == 1\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111]) == 111\n assert candidate(nums = [41, 82, 123, 164, 205, 246, 287, 328]) == 41\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006]) == 1001\n assert candidate(nums = [1, 1000, 500, 250, 125, 62, 31, 15]) == 1\n assert candidate(nums = [84, 112, 168, 224, 280]) == 28\n assert candidate(nums = [56, 98, 140, 182, 224]) == 56\n assert candidate(nums = [840, 1764, 4620, 10920]) == 840\n assert candidate(nums = [77, 154, 231, 308, 385, 462, 539, 616]) == 77\n assert candidate(nums = [60, 120, 180, 240, 300, 360]) == 60\n assert candidate(nums = [840, 756, 630, 504, 420]) == 420\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108]) == 12\n assert candidate(nums = [49, 63, 28, 91, 35]) == 7\n assert candidate(nums = [1000, 500, 250, 125, 62]) == 2\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [27, 81, 54, 162, 243]) == 27\n assert candidate(nums = [101, 202, 303, 404, 505]) == 101\n assert candidate(nums = [27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441]) == 27\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203]) == 29\n assert candidate(nums = [1024, 2048, 3072, 4096, 5120]) == 1024\n assert candidate(nums = [24, 36, 48, 60, 72, 84]) == 12\n assert candidate(nums = [840, 756, 672, 588, 504, 420, 336, 252, 168, 84]) == 84\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909]) == 101\n assert candidate(nums = [997, 991, 983, 977, 971]) == 1\n assert candidate(nums = [8317, 16634, 24951, 33268, 41585, 49902, 58219]) == 8317\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == 101\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137]) == 1\n assert candidate(nums = [987, 654, 321, 123, 456, 789]) == 3\n assert candidate(nums = [101, 103, 107, 109, 113]) == 1\n assert candidate(nums = [23, 47, 17, 53, 31, 19, 89, 73]) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findGCD", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findGCD(self, nums: list[int]) -> int:", "container": "Solution", "callable": "findGCD", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1980, "task_id": "find-unique-binary-string", "difficulty": "Medium", "problem_description": "Given an array of strings nums containing n unique binary strings each of length n, return a binary string of length n that does not appear in nums. If there are multiple answers, you may return any of them.\n \nExample 1:\n\nInput: nums = [\"01\",\"10\"]\nOutput: \"11\"\nExplanation: \"11\" does not appear in nums. \"00\" would also be correct.\n\nExample 2:\n\nInput: nums = [\"00\",\"01\"]\nOutput: \"11\"\nExplanation: \"11\" does not appear in nums. \"10\" would also be correct.\n\nExample 3:\n\nInput: nums = [\"111\",\"011\",\"001\"]\nOutput: \"101\"\nExplanation: \"101\" does not appear in nums. \"000\", \"010\", \"100\", and \"110\" would also be correct.\n\n \nConstraints:\n\nn == nums.length\n1 <= n <= 16\nnums[i].length == n\nnums[i] is either '0' or '1'.\nAll the strings of nums are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = ['01', '10']) == \"00\"\n assert candidate(nums = ['1111', '1011', '0111', '0011', '1101', '1001', '0101', '0001']) == \"00000000\"\n assert candidate(nums = ['00', '01']) == \"11\"\n assert candidate(nums = ['111', '011', '001']) == \"000\"\n assert candidate(nums = ['1101', '1011', '0111', '0011']) == \"0000\"\n assert candidate(nums = ['11110000', '00001111', '10101010', '01010101', '11001100', '00110011', '10000000', '01111111', '11011011', '00100100', '10100101', '01011010', '11100011', '00011100', '10011001', '01100110']) == \"0000000000000000\"\n assert candidate(nums = ['11110000', '00001111', '10101010', '01010101', '11001100', '00110011', '10011001', '01100110', '11010100', '00101011', '10111000', '01000111', '10001011', '01110100', '11000110', '00111001']) == \"0000000000000000\"\n assert candidate(nums = ['000000', '111111', '010101', '101010', '110011', '001100', '011001', '100110', '000111', '111000', '110100', '001011']) == \"100000000000\"\n assert candidate(nums = ['1100', '0011', '1010', '0101']) == \"0000\"\n assert candidate(nums = ['1111100000', '0000011111', '1010101010', '0101010101', '1100110011', '0011001100', '1001100110', '0110011001', '1101010010', '0010101101', '1011100011', '0100011100', '1000101100', '0111010011', '1100011011', '0011100100']) == \"0000000000000000\"\n assert candidate(nums = ['111110', '000001', '100011', '010110', '110101', '101000', '001100', '011010', '110011', '000110', '011101', '101111', '111000', '001011', '110110', '010000']) == \"0000000000000000\"\n assert candidate(nums = ['11111111', '00000000', '11111110', '00000001', '11111101', '00000010', '11111011', '00000100', '11110111', '00001000', '11101111', '00010000', '11011111', '00100000', '10111111']) == \"110000000000000\"\n assert candidate(nums = ['1111', '1110', '1101', '1100', '1011', '1010', '1001', '1000', '0111', '0110', '0101', '0100', '0011', '0010', '0001']) == \"000000000000000\"\n assert candidate(nums = ['111010', '000101', '101011', '010100', '110001', '100110', '011000', '001110', '011100', '110111', '101110', '000011', '111100', '010001', '000111', '110010']) == \"0000000000000000\"\n assert candidate(nums = ['101010', '010101', '001100', '110011', '111100', '000011']) == \"000000\"\n assert candidate(nums = ['1100', '1011', '0011', '1110']) == \"0000\"\n assert candidate(nums = ['11111111', '00000000', '10101010', '01010101', '11001100', '00110011', '11110000', '00001111', '10001000', '01110111', '11000110', '00111001', '11100010', '00011101', '10010110', '01101001']) == \"1000000000000000\"\n assert candidate(nums = ['1111111111', '0000000000', '1111111000', '0000000111', '1111110111', '0000001000', '1111101111', '0000010000', '1111011111', '0000100000', '1110111111', '0001000000', '1101111111', '0010000000', '1011111111']) == \"110000000000000\"\n assert candidate(nums = ['110110', '001011', '100100', '011001', '101110', '010010', '111000', '000111', '011101', '101010', '111100', '000011', '100001', '010110', '110010']) == \"000000000000000\"\n assert candidate(nums = ['10101010', '01010101', '11001100', '00110011', '11110000', '00001111', '10011001', '01100110', '11010101', '00101010', '10111100', '01000011', '11100011', '00011100', '10001100']) == \"000000000000000\"\n assert candidate(nums = ['000000000', '000000001', '000000010', '000000011', '000000100', '000000101', '000000110', '000000111', '000001000', '000001001', '000001010', '000001011', '000001100', '000001101', '000001110', '000001111']) == \"1111100000000000\"\n assert candidate(nums = ['1101', '0010', '1001', '0110']) == \"0000\"\n assert candidate(nums = ['00000', '00001', '00010', '00011', '00100', '00101', '00110', '00111', '01000', '01001', '01010', '01011', '01100', '01101', '01110', '01111']) == \"1111100000000000\"\n assert candidate(nums = ['1100', '1010', '0011', '1001', '0110', '0000', '1110', '1000']) == \"11110000\"\n assert candidate(nums = ['1111', '1000', '0100', '0001', '0010', '0110', '1001', '1101']) == \"00000000\"\n assert candidate(nums = ['110110', '001001', '101010', '010101', '111111', '000000', '100011', '011100', '110001', '001110', '111001', '000110']) == \"100000000000\"\n assert candidate(nums = ['00000', '00001', '00010', '00011', '00100', '00101', '00110', '00111', '01000', '01001', '01010', '01011', '01100', '01101', '01110', '01111']) == \"1111100000000000\"\n assert candidate(nums = ['1110', '1101', '1011', '0111', '0000', '0001', '0010', '0100']) == \"11000000\"\n assert candidate(nums = ['1100', '0101', '1010', '0011']) == \"0000\"\n assert candidate(nums = ['1111', '1110', '1101', '1100', '1011', '1010', '1001', '1000', '0111', '0110', '0101', '0100', '0011', '0010', '0001']) == \"000000000000000\"\n assert candidate(nums = ['00000000', '00000001', '00000010', '00000011', '00000100', '00000101', '00000110', '00000111', '00001000', '00001001', '00001010', '00001011', '00001100', '00001101', '00001110', '00001111']) == \"1111100000000000\"\n assert candidate(nums = ['00000', '00001', '00010', '00011', '00100', '00101', '00110', '00111']) == \"11110000\"\n assert candidate(nums = ['1111', '1011', '0111', '0011', '1101', '1001', '0101', '0001', '1110', '1010', '0110', '0010', '1100', '1000', '0100', '0000']) == \"1111100000000000\"\n assert candidate(nums = ['0000000000', '0000000001', '0000000010', '0000000011', '0000000100', '0000000101', '0000000110', '0000000111', '0000001000', '0000001001', '0000001010', '0000001011', '0000001100', '0000001101', '0000001110']) == \"111100000000000\"\n assert candidate(nums = ['100000', '110000', '111000', '111100', '111110', '111111', '000001', '000011', '000111', '001111', '011111']) == \"00000000000\"\n assert candidate(nums = ['111110', '000001', '101010', '010101', '110011', '001100', '011001', '100110', '000111', '111000', '110100', '001011', '110110', '001001', '100100', '011011']) == \"0000000000000000\"\n assert candidate(nums = ['101010', '010101', '110011', '001100', '111100', '000011', '100101', '011010', '110110', '001001', '101101', '010010', '111000', '000111', '110001', '001110']) == \"0000000000000000\"\n assert candidate(nums = ['111000', '000111', '110110', '001001', '101010', '010101', '110011', '001100', '100011', '011100', '000111', '111000', '010101', '101010', '001100', '110011']) == \"0000000000000000\"\n assert candidate(nums = ['10101010', '01010101', '11110000', '00001111', '11001100', '00110011', '11111111', '00000000', '10010010', '01101101', '11011011', '00100100', '10000001', '01111110', '11101100', '00010011']) == \"1000000000000000\"\n assert candidate(nums = ['11111111', '00000000', '10101010', '01010101', '11001100', '00110011', '10011001', '01100110']) == \"10000000\"\n assert candidate(nums = ['1110', '1101', '1011', '0111', '1000', '0100', '0010', '0001']) == \"00000000\"\n assert candidate(nums = ['1100', '1010', '0110', '0001']) == \"0000\"\n assert candidate(nums = ['1010', '0101', '1111', '0000']) == \"1000\"\n assert candidate(nums = ['0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101', '1110']) == \"111100000000000\"\n assert candidate(nums = ['0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111']) == \"11110000\"\n assert candidate(nums = ['110011', '001100', '101010', '010101', '111100', '000011', '100100', '011011']) == \"00000000\"\n assert candidate(nums = ['10101', '01010', '11100', '00011', '11011', '01100', '10000', '01001', '11111', '00000', '10010', '01110', '10110', '00111', '11001', '01011']) == \"1111110000000000\"\n assert candidate(nums = ['1111', '1110', '1101', '1100', '1011', '1010', '1001', '1000', '0111', '0110', '0101', '0100', '0011', '0010', '0001', '0000']) == \"1111100000000000\"\n assert candidate(nums = ['1010', '0101', '1100', '0011']) == \"0000\"\n assert candidate(nums = ['11101', '10010', '01100', '11011', '00001', '01011', '10101', '11001', '01111', '00100', '10000', '11111', '00011', '00110', '10110']) == \"000000000000000\"\n assert candidate(nums = ['111111', '111110', '111101', '111100', '111011', '111010', '111001', '111000', '110111', '110110', '110101', '110100', '110011', '110010', '110001', '110000']) == \"0000000000000000\"\n assert candidate(nums = ['111000', '000111', '101010', '010101', '110011', '001100', '100100', '011011', '111100', '000011', '101110', '010001', '100001', '011110', '110110', '001001']) == \"0000000000000000\"\n assert candidate(nums = ['1111', '0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101']) == \"111110000000000\"\n assert candidate(nums = ['00000', '00001', '00010', '00011', '00100', '00101', '00110', '00111', '01000', '01001', '01010', '01011', '01100', '01101', '01110', '01111', '10000', '10001', '10010', '10011', '10100', '10101', '10110', '10111']) == \"111110000000000000000000\"\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findDifferentBinaryString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findDifferentBinaryString(self, nums: list[str]) -> str:", "container": "Solution", "callable": "findDifferentBinaryString", "parameters": [{"name": "nums", "type": "list[str]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1981, "task_id": "minimize-the-difference-between-target-and-chosen-elements", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix mat and an integer target.\nChoose one integer from each row in the matrix such that the absolute difference between target and the sum of the chosen elements is minimized.\nReturn the minimum absolute difference.\nThe absolute difference between two numbers a and b is the absolute value of a - b.\n \nExample 1:\n\n\nInput: mat = [[1,2,3],[4,5,6],[7,8,9]], target = 13\nOutput: 0\nExplanation: One possible choice is to:\n- Choose 1 from the first row.\n- Choose 5 from the second row.\n- Choose 7 from the third row.\nThe sum of the chosen elements is 13, which equals the target, so the absolute difference is 0.\n\nExample 2:\n\n\nInput: mat = [[1],[2],[3]], target = 100\nOutput: 94\nExplanation: The best possible choice is to:\n- Choose 1 from the first row.\n- Choose 2 from the second row.\n- Choose 3 from the third row.\nThe sum of the chosen elements is 6, and the absolute difference is 94.\n\nExample 3:\n\n\nInput: mat = [[1,2,9,8,7]], target = 6\nOutput: 1\nExplanation: The best choice is to choose 7 from the first row.\nThe absolute difference is 1.\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n1 <= m, n <= 70\n1 <= mat[i][j] <= 70\n1 <= target <= 800\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1], [2], [3]],target = 100) == 94\n assert candidate(mat = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],target = 15) == 0\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],target = 13) == 0\n assert candidate(mat = [[7, 8, 9], [1, 2, 3], [4, 5, 6]],target = 20) == 2\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19]],target = 25) == 1\n assert candidate(mat = [[10, 20, 30], [5, 15, 25], [1, 10, 20]],target = 50) == 4\n assert candidate(mat = [[7, 8, 9], [10, 11, 12], [13, 14, 15]],target = 36) == 0\n assert candidate(mat = [[70, 70, 70], [70, 70, 70], [70, 70, 70]],target = 150) == 60\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15]],target = 20) == 0\n assert candidate(mat = [[70, 70, 70], [70, 70, 70], [70, 70, 70]],target = 100) == 110\n assert candidate(mat = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],target = 150) == 0\n assert candidate(mat = [[1, 2, 9, 8, 7]],target = 6) == 1\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],target = 5) == 2\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7]],target = 21) == 0\n assert candidate(mat = [[70, 60, 50, 40, 30], [20, 10, 0, -10, -20], [-30, -40, -50, -60, -70], [80, 90, 100, 110, 120]],target = 200) == 20\n assert candidate(mat = [[70, 70, 70, 70, 70], [70, 70, 70, 70, 70], [70, 70, 70, 70, 70]],target = 800) == 590\n assert candidate(mat = [[2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [5, 10, 15, 20, 25], [7, 14, 21, 28, 35]],target = 100) == 15\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 1, 1, 1, 1]],target = 25) == 5\n assert candidate(mat = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [7, 17, 27, 37, 47]],target = 150) == 3\n assert candidate(mat = [[5, 15, 25], [5, 15, 25], [5, 15, 25], [5, 15, 25], [5, 15, 25]],target = 50) == 5\n assert candidate(mat = [[70, 1], [70, 1], [70, 1], [70, 1], [70, 1], [70, 1], [70, 1]],target = 200) == 14\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],target = 75) == 12\n assert candidate(mat = [[50, 60, 70], [10, 20, 30], [40, 50, 60], [70, 80, 90]],target = 200) == 0\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]],target = 105) == 21\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21]],target = 50) == 8\n assert candidate(mat = [[1, 10, 100], [1, 10, 100], [1, 10, 100], [1, 10, 100], [1, 10, 100], [1, 10, 100], [1, 10, 100]],target = 700) == 0\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28]],target = 100) == 30\n assert candidate(mat = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 2, 3, 4, 5]],target = 85) == 1\n assert candidate(mat = [[60, 59, 58, 57, 56, 55, 54], [53, 52, 51, 50, 49, 48, 47], [46, 45, 44, 43, 42, 41, 40], [39, 38, 37, 36, 35, 34, 33], [32, 31, 30, 29, 28, 27, 26], [25, 24, 23, 22, 21, 20, 19]],target = 420) == 165\n assert candidate(mat = [[10, 20, 30, 40, 50, 60, 70], [70, 60, 50, 40, 30, 20, 10], [1, 2, 3, 4, 5, 6, 7]],target = 200) == 53\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5]],target = 50) == 35\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [20, 22, 24, 26, 28]],target = 50) == 0\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],target = 50) == 1\n assert candidate(mat = [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50, 55, 60]],target = 120) == 0\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 8], [3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 10]],target = 50) == 16\n assert candidate(mat = [[50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50]],target = 400) == 50\n assert candidate(mat = [[1, 70], [2, 69], [3, 68], [4, 67], [5, 66], [6, 65], [7, 64], [8, 63], [9, 62], [10, 61]],target = 400) == 1\n assert candidate(mat = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [1, 6, 11, 16, 21, 26, 31, 36, 41, 46], [2, 7, 12, 17, 22, 27, 32, 37, 42, 47], [3, 8, 13, 18, 23, 28, 33, 38, 43, 48]],target = 150) == 1\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6], [7, 7, 7, 7, 7, 7, 7]],target = 28) == 0\n assert candidate(mat = [[1, 50, 100], [2, 51, 101], [3, 52, 102], [4, 53, 103], [5, 54, 104]],target = 260) == 0\n assert candidate(mat = [[70, 69, 68, 67, 66, 65, 64], [63, 62, 61, 60, 59, 58, 57], [56, 55, 54, 53, 52, 51, 50], [49, 48, 47, 46, 45, 44, 43]],target = 260) == 22\n assert candidate(mat = [[10, 20, 30, 40, 50, 60, 70], [11, 21, 31, 41, 51, 61, 71], [12, 22, 32, 42, 52, 62, 72], [13, 23, 33, 43, 53, 63, 73], [14, 24, 34, 44, 54, 64, 74], [15, 25, 35, 45, 55, 65, 75]],target = 300) == 5\n assert candidate(mat = [[1, 10, 100], [10, 100, 1000], [100, 1000, 10000]],target = 1234) == 34\n assert candidate(mat = [[10, 20, 30], [40, 50, 60], [70, 80, 90], [100, 110, 120], [130, 140, 150], [160, 170, 180], [190, 200, 210]],target = 700) == 0\n assert candidate(mat = [[70, 69, 68], [67, 66, 65], [64, 63, 62], [61, 60, 59], [58, 57, 56]],target = 250) == 60\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28]],target = 100) == 30\n assert candidate(mat = [[50, 49, 48, 47, 46, 45, 44], [43, 42, 41, 40, 39, 38, 37], [36, 35, 34, 33, 32, 31, 30]],target = 130) == 1\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],target = 10) == 6\n assert candidate(mat = [[3, 10, 7], [8, 6, 4], [15, 12, 9], [18, 16, 13]],target = 50) == 1\n assert candidate(mat = [[60, 70, 80, 90, 100], [1, 2, 3, 4, 5], [10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [100, 90, 80, 70, 60]],target = 300) == 0\n assert candidate(mat = [[7, 8, 9], [1, 2, 3], [4, 5, 6], [10, 11, 12]],target = 25) == 0\n assert candidate(mat = [[7, 21, 42, 58], [9, 23, 46, 62], [11, 25, 49, 65], [13, 27, 51, 67], [15, 29, 53, 69]],target = 200) == 0\n assert candidate(mat = [[70, 60, 50, 40], [30, 20, 10, 0], [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],target = 150) == 26\n assert candidate(mat = [[70, 60, 50, 40, 30], [20, 30, 40, 50, 60], [10, 20, 30, 40, 50]],target = 200) == 20\n assert candidate(mat = [[7, 17, 27, 37, 47], [8, 18, 28, 38, 48], [9, 19, 29, 39, 49], [10, 20, 30, 40, 50], [11, 21, 31, 41, 51]],target = 150) == 5\n assert candidate(mat = [[70, 69, 68, 67], [66, 65, 64, 63], [62, 61, 60, 59], [58, 57, 56, 55]],target = 260) == 4\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],target = 80) == 30\n assert candidate(mat = [[7, 8, 9], [4, 5, 6], [1, 2, 3], [7, 8, 9], [4, 5, 6], [1, 2, 3]],target = 30) == 0\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],target = 50) == 5\n assert candidate(mat = [[70, 60, 50, 40, 30], [10, 20, 30, 40, 50], [60, 50, 40, 30, 20], [1, 2, 3, 4, 5]],target = 180) == 1\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],target = 60) == 0\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [15, 17, 19, 21, 23, 25, 27]],target = 50) == 0\n assert candidate(mat = [[10, 20, 30], [11, 21, 31], [12, 22, 32], [13, 23, 33], [14, 24, 34]],target = 120) == 0\n assert candidate(mat = [[5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5]],target = 10) == 10\n assert candidate(mat = [[1, 3, 5, 7], [2, 4, 6, 8], [9, 11, 13, 15], [17, 19, 21, 23]],target = 30) == 1\n assert candidate(mat = [[1, 70], [1, 70], [1, 70], [1, 70], [1, 70], [1, 70], [1, 70]],target = 300) == 17\n assert candidate(mat = [[10, 20, 30], [15, 25, 35], [20, 30, 40], [25, 35, 45]],target = 120) == 0\n assert candidate(mat = [[10, 20, 30], [40, 50, 60], [70, 80, 90], [100, 110, 120], [130, 140, 150], [160, 170, 180]],target = 600) == 0\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15]],target = 100) == 66\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4]],target = 20) == 10\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35]],target = 150) == 45\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],target = 1) == 5\n assert candidate(mat = [[5, 10, 15], [10, 20, 30], [15, 25, 35], [20, 30, 40], [25, 35, 45]],target = 100) == 0\n assert candidate(mat = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41]],target = 120) == 4\n assert candidate(mat = [[70, 70, 70], [70, 70, 70], [70, 70, 70], [70, 70, 70], [70, 70, 70], [70, 70, 70], [70, 70, 70]],target = 800) == 310\n assert candidate(mat = [[5, 15, 25], [10, 20, 30], [15, 25, 35], [20, 30, 40]],target = 100) == 0\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]],target = 50) == 0\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5]],target = 100) == 85\n assert candidate(mat = [[1, 100, 200], [2, 150, 250], [3, 200, 300], [4, 250, 350]],target = 800) == 0\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19]],target = 50) == 12\n assert candidate(mat = [[5, 15, 25, 35], [10, 20, 30, 40], [15, 25, 35, 45], [20, 30, 40, 50], [25, 35, 45, 55]],target = 200) == 5\n assert candidate(mat = [[5, 10, 15, 20, 25], [30, 35, 40, 45, 50], [55, 60, 65, 70, 75]],target = 120) == 0\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19]],target = 30) == 0\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],target = 10) == 3\n assert candidate(mat = [[1, 50, 100, 150, 200], [2, 51, 101, 151, 201], [3, 52, 102, 152, 202], [4, 53, 103, 153, 203], [5, 54, 104, 154, 204]],target = 500) == 10\n assert candidate(mat = [[70, 60, 50, 40, 30, 20, 10], [65, 55, 45, 35, 25, 15, 5], [1, 2, 3, 4, 5, 6, 7]],target = 200) == 58\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 8, 12, 16, 20]],target = 40) == 0\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],target = 30) == 4\n assert candidate(mat = [[1, 5, 9, 14], [3, 7, 10, 17], [4, 8, 12, 19], [6, 11, 15, 20]],target = 45) == 0\n assert candidate(mat = [[7, 14, 21, 28], [35, 42, 49, 56], [63, 70, 77, 84]],target = 210) == 42\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21]],target = 50) == 8\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]],target = 55) == 22\n assert candidate(mat = [[1, 100, 200], [1, 100, 200], [1, 100, 200], [1, 100, 200], [1, 100, 200]],target = 500) == 0\n assert candidate(mat = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4], [5, 5, 5, 5, 5]],target = 15) == 0\n assert candidate(mat = [[7, 14, 21, 28, 35], [42, 49, 56, 63, 70], [77, 84, 91, 98, 105]],target = 250) == 40\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27], [28, 29, 30]],target = 150) == 0\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]],target = 30) == 1\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42]],target = 200) == 53\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]],target = 49) == 0\n assert candidate(mat = [[7, 8, 9], [1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3], [4, 5, 6], [7, 8, 9]],target = 50) == 5\n assert candidate(mat = [[7, 8, 9], [1, 2, 3], [4, 5, 6], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]],target = 80) == 0\n assert candidate(mat = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4]],target = 25) == 15\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]],target = 100) == 16\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],target = 7) == 0\n"}, "metadata": {"canonical_parameter_names": ["mat", "target"], "leetcode_dataset_entry_point": "Solution().minimizeTheDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimizeTheDifference(self, mat: list[list[int]], target: int) -> int:", "container": "Solution", "callable": "minimizeTheDifference", "parameters": [{"name": "mat", "type": "list[list[int]]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1982, "task_id": "find-array-given-subset-sums", "difficulty": "Hard", "problem_description": "You are given an integer n representing the length of an unknown array that you are trying to recover. You are also given an array sums containing the values of all 2n subset sums of the unknown array (in no particular order).\nReturn the array ans of length n representing the unknown array. If multiple answers exist, return any of them.\nAn array sub is a subset of an array arr if sub can be obtained from arr by deleting some (possibly zero or all) elements of arr. The sum of the elements in sub is one possible subset sum of arr. The sum of an empty array is considered to be 0.\nNote: Test cases are generated such that there will always be at least one correct answer.\n \nExample 1:\n\nInput: n = 3, sums = [-3,-2,-1,0,0,1,2,3]\nOutput: [1,2,-3]\nExplanation: [1,2,-3] is able to achieve the given subset sums:\n- []: sum is 0\n- [1]: sum is 1\n- [2]: sum is 2\n- [1,2]: sum is 3\n- [-3]: sum is -3\n- [1,-3]: sum is -2\n- [2,-3]: sum is -1\n- [1,2,-3]: sum is 0\nNote that any permutation of [1,2,-3] and also any permutation of [-1,-2,3] will also be accepted.\n\nExample 2:\n\nInput: n = 2, sums = [0,0,0,0]\nOutput: [0,0]\nExplanation: The only correct answer is [0,0].\n\nExample 3:\n\nInput: n = 4, sums = [0,0,5,5,4,-1,4,9,9,-1,4,3,4,8,3,8]\nOutput: [0,-1,4,5]\nExplanation: [0,-1,4,5] is able to achieve the given subset sums.\n\n \nConstraints:\n\n1 <= n <= 15\nsums.length == 2n\n-104 <= sums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,sums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n assert candidate(n = 3,sums = [-3, -2, -1, 0, 0, 1, 2, 3]) == [-1, -2, 3]\n assert candidate(n = 2,sums = [0, 0, 0, 0]) == [0, 0]\n assert candidate(n = 1,sums = [0, 5]) == [5]\n assert candidate(n = 3,sums = [3, 1, 2, 0, 4, 5, 6, 8]) == [1, 2, 4]\n assert candidate(n = 4,sums = [0, 0, 5, 5, 4, -1, 4, 9, 9, -1, 4, 3, 4, 8, 3, 8]) == [0, -1, 4, 5]\n assert candidate(n = 1,sums = [0, -1]) == [-1]\n assert candidate(n = 5,sums = [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, -4, 8, -16]\n assert candidate(n = 3,sums = [-1, 0, 1, 2, 3, 4, -2, -3, -4]) == [1, 2, -4]\n assert candidate(n = 6,sums = [-21, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-2, -3, 4, 8, -16, 21]\n assert candidate(n = 5,sums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 2, 4, 8, 16]\n assert candidate(n = 5,sums = [-25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [-1, 2, 4, -8, -16]\n assert candidate(n = 4,sums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == [0, 1, 2, 4]\n assert candidate(n = 4,sums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 2, 4, 8]\n assert candidate(n = 3,sums = [0, 2, 2, 4, 6, 6, 8, 10]) == [2, 2, 6]\n assert candidate(n = 5,sums = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27]) == [1, 2, 4, 8, 16]\n assert candidate(n = 5,sums = [-15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [-1, -2, -4, -8, 16]\n assert candidate(n = 5,sums = [-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11]) == [-1, -2, -4, 8, 17]\n assert candidate(n = 3,sums = [-5, -4, -3, -2, -1, 0, 1, 2, 3]) == [-1, 2, -4]\n assert candidate(n = 3,sums = [1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 4]\n assert candidate(n = 3,sums = [-6, -5, -5, -4, -2, -1, -1, 0, 1, 1, 2, 4, 5, 5, 6, 7]) == [-1, -1, -4]\n assert candidate(n = 4,sums = [-7, -6, -5, -4, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6, 7]) == [1, 2, 3, -7]\n assert candidate(n = 5,sums = [-30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, -2, -4, -8, -16]\n assert candidate(n = 5,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, -2, 4, -8, 16]\n assert candidate(n = 5,sums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 2, 4, 8, 16]\n assert candidate(n = 5,sums = [-10, -8, -7, -6, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7, 8, 10]) == [2, 3, -4, -6, 7]\n assert candidate(n = 5,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0]) == [1, -2, 4, -8, 10]\n assert candidate(n = 4,sums = [10, -10, 5, -5, 15, -15, 0, 20, -20]) == [5, 10, -20, 40]\n assert candidate(n = 3,sums = [-2, -1, 0, 1, 2, 3]) == [1, -2, 4]\n assert candidate(n = 4,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == [1, -2, 4, -8]\n assert candidate(n = 5,sums = [-5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5]) == [-1, 1, 2, -4, 8]\n assert candidate(n = 5,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, -2, 4, -8, 16]\n assert candidate(n = 5,sums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 4, 8, 16]\n assert candidate(n = 4,sums = [0, -1, -2, -3, -4, 1, 2, 3, 4, -5, 5, -6, 6, -7, 7, 8]) == [-1, -2, -4, 8]\n assert candidate(n = 3,sums = [10, 20, 30, 40, 50, 60, 70, 80]) == [10, 20, 40]\n assert candidate(n = 4,sums = [1, -1, 2, -2, 3, -3, 4, -4, 0]) == [1, 2, -4, 8]\n assert candidate(n = 5,sums = [0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 2, 2, 4, 8]\n assert candidate(n = 4,sums = [-1, -2, -3, -4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 2, -4, 8]\n assert candidate(n = 4,sums = [-9, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7]) == [-2, -3, -4, 8]\n assert candidate(n = 6,sums = [-20, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [2, 3, -4, 8, -16, 32]\n assert candidate(n = 5,sums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == [1, 2, 4, 8, 16]\n assert candidate(n = 6,sums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0]\n assert candidate(n = 6,sums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]) == [1, 2, 4, 8, 16, 32]\n assert candidate(n = 5,sums = [0, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]) == [1, 2, 3, 4, 8]\n assert candidate(n = 5,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15]) == [1, -2, 4, -8, 16]\n assert candidate(n = 4,sums = [-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [-1, -2, 4, 8]\n assert candidate(n = 5,sums = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == [-1, 2, 4, 8, 16]\n assert candidate(n = 4,sums = [-10, -7, -9, -8, -5, -6, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == [1, -2, 4, -8]\n assert candidate(n = 5,sums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 4, 8, 16]\n assert candidate(n = 5,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, -2, 4, -8, 16]\n assert candidate(n = 6,sums = [-63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]) == [-1, -2, -4, -8, -16, -32]\n assert candidate(n = 3,sums = [-4, -2, -1, 0, 0, 1, 2, 4]) == [2, 3, -4]\n assert candidate(n = 5,sums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [1, 2, 4, 8, 16]\n assert candidate(n = 3,sums = [-1, -2, -3, 0, 1, 2, 3, 4, 5]) == [-1, -2, 4]\n assert candidate(n = 5,sums = [-15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [-1, -2, -4, -8, 16]\n assert candidate(n = 3,sums = [-6, -3, -5, -2, -4, -1, 0, 1, 3, 2, 4, 5]) == [1, -2, -4]\n assert candidate(n = 4,sums = [-5, -4, -3, -2, -1, -1, 0, 0, 1, 1, 2, 3, 4, 5]) == [-1, 2, -4, 4]\n assert candidate(n = 4,sums = [-5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [-1, 1, 2, -4]\n assert candidate(n = 4,sums = [-6, -4, -3, -2, -2, -1, 0, 0, 1, 2, 2, 3, 4, 6]) == [-2, 3, -4, 4]\n assert candidate(n = 5,sums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == [0, 1, 2, 4, 8]\n assert candidate(n = 4,sums = [-6, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2]) == [-1, -1, 2, -4]\n assert candidate(n = 5,sums = [-15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [-1, -2, -4, -8, 15]\n assert candidate(n = 1,sums = [0, 2]) == [2]\n assert candidate(n = 5,sums = [-10, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10]) == [-2, 3, 4, -8, 10]\n assert candidate(n = 5,sums = [-10, -9, -8, -8, -7, -7, -6, -6, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 10]) == [1, -2, 2, 4, -8]\n assert candidate(n = 6,sums = [-31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [-1, -2, -4, -8, -16, 31]\n assert candidate(n = 5,sums = [31, 17, 21, 18, 12, 13, 19, 14, 20, 24, 8, 11, 9, 5, 4, 10, 0, 15, 7, 3, 16, 6, 2, 1, 23, 22, 16, 25, 26, 30, 27, 29, 31]) == [1, 2, 4, 8, 16]\n assert candidate(n = 3,sums = [-5, -3, -2, -1, 0, 0, 1, 2]) == [-2, -3, 4]\n assert candidate(n = 3,sums = [-1, -1, -1, -1, -1, 0, 0, 0]) == [0, 0, 0]\n assert candidate(n = 5,sums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, -1, -1, -1, -1, -2, -2, -2, -2, -3, -3, -3, -3, -4, -4, -4, -4, -5, -5, -5, -5]) == [0, 0, -1, 2, -4]\n assert candidate(n = 1,sums = [0, 1]) == [1]\n assert candidate(n = 4,sums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == [0, 0, 1, 2]\n assert candidate(n = 1,sums = [0, 3]) == [3]\n assert candidate(n = 2,sums = [-1, 0, 1, 2]) == [-1, 2]\n assert candidate(n = 3,sums = [-1, 0, 1, 2, 3, 4]) == [-1, 2, 4]\n assert candidate(n = 6,sums = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, -14, 14, -15, 15, -16, 16, -17, 17, -18, 18, -19, 19, -20, 20, -21, 21, -22, 22, -23, 23, -24, 24, -25, 25, -26, 26, -27, 27, -28, 28, -29, 29, -30, 30, -31, 31, -32, 32]) == [1, 2, 4, 8, 16, -32]\n assert candidate(n = 4,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == [1, -2, 4, -8]\n assert candidate(n = 3,sums = [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3]) == [1, -2, -4]\n assert candidate(n = 1,sums = [0, -5]) == [-5]\n assert candidate(n = 5,sums = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [-1, -2, -4, -8, 16]\n assert candidate(n = 4,sums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0]\n assert candidate(n = 2,sums = [-2, -1, 0, 1]) == [1, -2]\n assert candidate(n = 3,sums = [-3, -1, 0, 1, 2, 3, 4, 6]) == [2, -3, 4]\n assert candidate(n = 3,sums = [-1, -2, -3, 0, 1, 2, 3, 4]) == [-1, -2, 4]\n assert candidate(n = 1,sums = [0, 0]) == [0]\n assert candidate(n = 3,sums = [-6, -5, -5, -4, -3, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6]) == [1, 1, 3]\n assert candidate(n = 3,sums = [-3, -2, -1, -1, 0, 0, 1, 2]) == [-1, -2, 2]\n assert candidate(n = 5,sums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == [0, 0, 0, 0, 0]\n assert candidate(n = 3,sums = [1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 4]\n"}, "metadata": {"canonical_parameter_names": ["n", "sums"], "leetcode_dataset_entry_point": "Solution().recoverArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def recoverArray(self, n: int, sums: list[int]) -> list[int]:", "container": "Solution", "callable": "recoverArray", "parameters": [{"name": "n", "type": "int"}, {"name": "sums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1984, "task_id": "minimum-difference-between-highest-and-lowest-of-k-scores", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums, where nums[i] represents the score of the ith student. You are also given an integer k.\nPick the scores of any k students from the array so that the difference between the highest and the lowest of the k scores is minimized.\nReturn the minimum possible difference.\n \nExample 1:\n\nInput: nums = [90], k = 1\nOutput: 0\nExplanation: There is one way to pick score(s) of one student:\n- [90]. The difference between the highest and lowest score is 90 - 90 = 0.\nThe minimum possible difference is 0.\n\nExample 2:\n\nInput: nums = [9,4,1,7], k = 2\nOutput: 2\nExplanation: There are six ways to pick score(s) of two students:\n- [9,4,1,7]. The difference between the highest and lowest score is 9 - 4 = 5.\n- [9,4,1,7]. The difference between the highest and lowest score is 9 - 1 = 8.\n- [9,4,1,7]. The difference between the highest and lowest score is 9 - 7 = 2.\n- [9,4,1,7]. The difference between the highest and lowest score is 4 - 1 = 3.\n- [9,4,1,7]. The difference between the highest and lowest score is 7 - 4 = 3.\n- [9,4,1,7]. The difference between the highest and lowest score is 7 - 1 = 6.\nThe minimum possible difference is 2.\n \nConstraints:\n\n1 <= k <= nums.length <= 1000\n0 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 9, 1, 32, 13],k = 3) == 8\n assert candidate(nums = [1, 5, 6, 14, 15],k = 3) == 5\n assert candidate(nums = [9, 4, 1, 7],k = 2) == 2\n assert candidate(nums = [8, 10, 2],k = 2) == 2\n assert candidate(nums = [1, 5, 9, 14, 18],k = 3) == 8\n assert candidate(nums = [4, 9, 1, 17, 6, 11, 22],k = 5) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],k = 1) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 0\n assert candidate(nums = [8, 10, 5, 7, 9, 3],k = 4) == 3\n assert candidate(nums = [4, 9, 1, 32, 13],k = 2) == 3\n assert candidate(nums = [90],k = 1) == 0\n assert candidate(nums = [8, 10, 12, 14, 16],k = 3) == 4\n assert candidate(nums = [4, 2, 1, 3],k = 2) == 1\n assert candidate(nums = [8, 8, 8, 8, 8],k = 5) == 0\n assert candidate(nums = [1, 5, 6, 14, 15],k = 2) == 1\n assert candidate(nums = [100000, 0, 1, 2, 99999],k = 2) == 1\n assert candidate(nums = [8, 10, 15, 17, 20, 23],k = 4) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 3\n assert candidate(nums = [1, 3, 6, 19, 20],k = 3) == 5\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 10) == 900\n assert candidate(nums = [5, 8, 12, 19, 23, 27, 31, 35, 39, 41, 45, 49, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99],k = 5) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 40\n assert candidate(nums = [28, 90, 3, 23, 90, 18, 39, 72, 45, 67],k = 5) == 27\n assert candidate(nums = [88, 22, 55, 77, 33, 44, 66, 11, 99, 0, 6, 3, 5, 7, 9, 1, 2, 4, 8, 10, 12, 14, 16, 18, 20, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 90, 92, 94, 96, 98],k = 10) == 9\n assert candidate(nums = [50, 40, 30, 20, 10, 90, 80, 70, 60, 100],k = 5) == 40\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 8) == 700\n assert candidate(nums = [1, 3, 6, 19, 20, 25, 28, 30, 31, 32, 33],k = 6) == 8\n assert candidate(nums = [500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50],k = 7) == 30\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 3) == 0\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 5) == 4\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020],k = 11) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400],k = 13) == 120\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980],k = 15) == 14\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],k = 3) == 2000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 15) == 140\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 7\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0, 99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0],k = 15) == 77777\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 10000, 20000, 30000, 40000, 50000],k = 10) == 40000\n assert candidate(nums = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120],k = 6) == 5\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717],k = 8) == 505\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],k = 30) == 29\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 90000, 9000, 900, 90],k = 3) == 89\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 4) == 3\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 5) == 12\n assert candidate(nums = [2, 22, 222, 2222, 22222, 222222, 2222222, 22222222, 222222222],k = 5) == 22220\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 9\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120],k = 10) == 72\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4) == 3\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 3, 9, 3, 2, 8, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0],k = 20) == 1\n assert candidate(nums = [5, 15, 30, 10, 20, 25, 40, 50],k = 5) == 20\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 11) == 1000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 40\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 6) == 50\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 1) == 0\n assert candidate(nums = [1, 3, 6, 19, 20, 25, 30, 35, 40, 45, 50],k = 6) == 21\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 3) == 20000\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90],k = 4) == 30\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109],k = 10) == 36\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 2) == 0\n assert candidate(nums = [80, 60, 40, 20, 0, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480],k = 7) == 120\n assert candidate(nums = [23, 45, 12, 67, 89, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90],k = 8) == 23\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 60\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == 200\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 60\n assert candidate(nums = [1, 100, 1000, 10000, 100000, 1000000],k = 3) == 999\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],k = 3) == 2\n assert candidate(nums = [45, 33, 21, 10, 1, 0, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],k = 25) == 41\n assert candidate(nums = [300, 200, 100, 50, 25, 10, 5, 3, 2, 1, 0, 1, 3, 5, 10, 25, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 15) == 99\n assert candidate(nums = [99999, 100000, 0, 1, 2, 99998, 3, 4, 5, 6],k = 4) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 0\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 210, 311, 412, 513, 614, 715, 816, 917, 1018],k = 8) == 77\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 90\n assert candidate(nums = [8, 18, 28, 38, 48, 58, 68, 78, 88, 98, 108, 118, 128, 138, 148, 158],k = 3) == 20\n assert candidate(nums = [34, 7, 23, 32, 5, 62],k = 4) == 27\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 7) == 60\n assert candidate(nums = [5, 8, 12, 18, 23, 30, 37, 45, 53, 62],k = 6) == 25\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 26) == 50\n assert candidate(nums = [55, 45, 35, 25, 15, 5, 0, -5, -10, -15, -20, -25, -30],k = 6) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 14\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 4) == 999\n assert candidate(nums = [89, 75, 91, 85, 92, 88, 76, 90, 86, 84],k = 4) == 3\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991],k = 10) == 9\n assert candidate(nums = [5, 8, 12, 18, 22, 27, 30, 35, 40, 45, 50],k = 5) == 17\n assert candidate(nums = [987, 654, 321, 654, 321, 987, 654, 321, 987, 654, 321, 987, 654, 321, 987],k = 6) == 333\n assert candidate(nums = [345, 678, 901, 234, 567, 890, 123, 456, 789],k = 4) == 223\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 9) == 16\n assert candidate(nums = [5, 23, 9, 56, 12, 89, 76, 45, 34, 67, 88, 90],k = 5) == 23\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 6) == 99999\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minimumDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumDifference(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "minimumDifference", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1985, "task_id": "find-the-kth-largest-integer-in-the-array", "difficulty": "Medium", "problem_description": "You are given an array of strings nums and an integer k. Each string in nums represents an integer without leading zeros.\nReturn the string that represents the kth largest integer in nums.\nNote: Duplicate numbers should be counted distinctly. For example, if nums is [\"1\",\"2\",\"2\"], \"2\" is the first largest integer, \"2\" is the second-largest integer, and \"1\" is the third-largest integer.\n \nExample 1:\n\nInput: nums = [\"3\",\"6\",\"7\",\"10\"], k = 4\nOutput: \"3\"\nExplanation:\nThe numbers in nums sorted in non-decreasing order are [\"3\",\"6\",\"7\",\"10\"].\nThe 4th largest integer in nums is \"3\".\n\nExample 2:\n\nInput: nums = [\"2\",\"21\",\"12\",\"1\"], k = 3\nOutput: \"2\"\nExplanation:\nThe numbers in nums sorted in non-decreasing order are [\"1\",\"2\",\"12\",\"21\"].\nThe 3rd largest integer in nums is \"2\".\n\nExample 3:\n\nInput: nums = [\"0\",\"0\"], k = 2\nOutput: \"0\"\nExplanation:\nThe numbers in nums sorted in non-decreasing order are [\"0\",\"0\"].\nThe 2nd largest integer in nums is \"0\".\n\n \nConstraints:\n\n1 <= k <= nums.length <= 104\n1 <= nums[i].length <= 100\nnums[i] consists of only digits.\nnums[i] will not have any leading zeros.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = ['100', '200', '300', '400', '500'],k = 2) == \"400\"\n assert candidate(nums = ['2', '21', '12', '1'],k = 3) == \"2\"\n assert candidate(nums = ['9', '8', '7', '6', '5', '4', '3', '2', '1'],k = 5) == \"5\"\n assert candidate(nums = ['100', '200', '300', '400'],k = 2) == \"300\"\n assert candidate(nums = ['9', '11', '8', '9', '10'],k = 5) == \"8\"\n assert candidate(nums = ['9', '11', '2', '22'],k = 2) == \"11\"\n assert candidate(nums = ['10', '20', '30', '40', '50'],k = 5) == \"10\"\n assert candidate(nums = ['10', '10', '10', '10'],k = 3) == \"10\"\n assert candidate(nums = ['0', '0'],k = 2) == \"0\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],k = 10) == \"1\"\n assert candidate(nums = ['100', '200', '300', '400'],k = 1) == \"400\"\n assert candidate(nums = ['10', '2', '11', '3', '7'],k = 1) == \"11\"\n assert candidate(nums = ['5', '3', '8', '6', '7'],k = 1) == \"8\"\n assert candidate(nums = ['1', '2', '2', '3', '3', '3'],k = 4) == \"2\"\n assert candidate(nums = ['10', '100', '1000', '10000'],k = 3) == \"100\"\n assert candidate(nums = ['3', '6', '7', '10'],k = 4) == \"3\"\n assert candidate(nums = ['100', '200', '300', '400', '500', '600', '700', '800', '900'],k = 9) == \"100\"\n assert candidate(nums = ['500', '50', '5000', '50000', '5'],k = 4) == \"50\"\n assert candidate(nums = ['987654321', '987654320', '987654319', '987654318', '987654317'],k = 5) == \"987654317\"\n assert candidate(nums = ['123456789', '987654321', '135792468', '246813579', '864209753'],k = 3) == \"246813579\"\n assert candidate(nums = ['1', '11', '111', '1111', '11111'],k = 3) == \"111\"\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999', '000'],k = 7) == \"333\"\n assert candidate(nums = ['500', '50', '5', '5000'],k = 3) == \"50\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15'],k = 10) == \"6\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000'],k = 5) == \"100\"\n assert candidate(nums = ['1', '3', '5', '7', '9', '11', '13', '15', '17', '19'],k = 7) == \"7\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415', '161718', '192021', '222324', '252627', '282930'],k = 5) == \"161718\"\n assert candidate(nums = ['1000000', '999999', '100000', '99999', '10000', '9999', '1000', '999', '100', '99', '10', '9'],k = 8) == \"999\"\n assert candidate(nums = ['999', '1000', '1001', '1002', '1003'],k = 2) == \"1002\"\n assert candidate(nums = ['987654321', '987654320', '987654319', '987654318', '987654317'],k = 4) == \"987654318\"\n assert candidate(nums = ['9876543210', '9876543211', '9876543212', '9876543213', '9876543214'],k = 5) == \"9876543210\"\n assert candidate(nums = ['123', '456', '789', '123', '456', '789', '123', '456', '789'],k = 5) == \"456\"\n assert candidate(nums = ['10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 3) == \"10000000\"\n assert candidate(nums = ['1000000000', '1000000001', '1000000002', '1000000003', '1000000004'],k = 2) == \"1000000003\"\n assert candidate(nums = ['100000000000000000000000000000000000000000000000000000000000000', '99999999999999999999999999999999999999999999999999999999999999'],k = 1) == \"100000000000000000000000000000000000000000000000000000000000000\"\n assert candidate(nums = ['0', '00', '000', '0000', '00000'],k = 3) == \"000\"\n assert candidate(nums = ['5000', '4000', '3000', '2000', '1000', '500', '400', '300', '200', '100'],k = 5) == \"1000\"\n assert candidate(nums = ['987654321', '87654321', '7654321', '654321', '54321', '4321', '321', '21', '1'],k = 3) == \"7654321\"\n assert candidate(nums = ['1', '1', '2', '2', '3', '3', '4', '4', '5', '5'],k = 8) == \"2\"\n assert candidate(nums = ['111111111', '222222222', '333333333', '444444444', '555555555', '666666666', '777777777', '888888888', '999999999'],k = 9) == \"111111111\"\n assert candidate(nums = ['1', '11', '111', '1111', '11111', '111111'],k = 6) == \"1\"\n assert candidate(nums = ['12345', '12345', '12345', '12345', '12345', '12345', '12345', '12345', '12345', '12345'],k = 8) == \"12345\"\n assert candidate(nums = ['99', '98', '97', '96', '95', '94', '93', '92', '91', '90'],k = 5) == \"95\"\n assert candidate(nums = ['10', '2', '3', '4', '5', '6', '7', '8', '9'],k = 1) == \"10\"\n assert candidate(nums = ['9876543210', '987654321', '98765432', '9876543', '987654', '98765', '9876', '987', '98', '9'],k = 5) == \"987654\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20'],k = 10) == \"11\"\n assert candidate(nums = ['1', '3', '5', '7', '9', '11', '13', '15', '17', '19'],k = 1) == \"19\"\n assert candidate(nums = ['11111111111111111111', '22222222222222222222', '33333333333333333333', '44444444444444444444', '55555555555555555555'],k = 2) == \"44444444444444444444\"\n assert candidate(nums = ['100', '1000', '10000', '100000', '1000000'],k = 4) == \"1000\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20'],k = 19) == \"2\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 7) == \"1000\"\n assert candidate(nums = ['1000', '999', '100', '99', '10', '9', '1'],k = 7) == \"1\"\n assert candidate(nums = ['9', '8', '7', '6', '5', '4', '3', '2', '1'],k = 9) == \"1\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 3) == \"10000000\"\n assert candidate(nums = ['999999999999999999', '888888888888888888', '777777777777777777', '666666666666666666', '555555555555555555'],k = 3) == \"777777777777777777\"\n assert candidate(nums = ['123', '123', '123', '123', '123', '123', '123', '123', '123', '123'],k = 10) == \"123\"\n assert candidate(nums = ['123456789', '987654321', '123456789', '987654321', '123456789', '987654321', '123456789', '987654321', '123456789', '987654321'],k = 5) == \"987654321\"\n assert candidate(nums = ['1000', '999', '888', '777', '666', '555', '444', '333', '222', '111'],k = 10) == \"111\"\n assert candidate(nums = ['123456789', '987654321', '111111111', '999999999', '222222222'],k = 3) == \"222222222\"\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999', '1111'],k = 6) == \"555\"\n assert candidate(nums = ['10000', '9999', '9998', '9997', '9996', '9995', '9994', '9993', '9992', '9991'],k = 6) == \"9995\"\n assert candidate(nums = ['1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000'],k = 1) == \"1000\"\n assert candidate(nums = ['9', '99', '999', '9999', '99999', '999999', '9999999', '99999999', '999999999'],k = 8) == \"99\"\n assert candidate(nums = ['1000000000', '999999999', '100000000', '99999999', '10000000', '9999999', '1000000', '999999', '100000', '99999'],k = 10) == \"99999\"\n assert candidate(nums = ['123456789', '987654321', '135792468', '246813579'],k = 4) == \"123456789\"\n assert candidate(nums = ['1000000000', '1000000001', '1000000002', '1000000003', '1000000004', '1000000005'],k = 2) == \"1000000004\"\n assert candidate(nums = ['100', '200', '300', '400', '500', '600', '700', '800', '900', '1000'],k = 10) == \"100\"\n assert candidate(nums = ['123456789012345678901234567890', '987654321098765432109876543210', '111111111111111111111111111111', '999999999999999999999999999999', '222222222222222222222222222222'],k = 3) == \"222222222222222222222222222222\"\n assert candidate(nums = ['11111', '22222', '33333', '44444', '55555', '66666', '77777', '88888', '99999', '100000'],k = 9) == \"22222\"\n assert candidate(nums = ['500', '500', '500', '500', '500', '500', '500', '500', '500', '500'],k = 5) == \"500\"\n assert candidate(nums = ['9', '19', '29', '39', '49', '59', '69', '79', '89', '99'],k = 1) == \"99\"\n assert candidate(nums = ['9', '8', '7', '6', '5', '4', '3', '2', '1'],k = 1) == \"9\"\n assert candidate(nums = ['9', '99', '999', '9999', '99999'],k = 3) == \"999\"\n assert candidate(nums = ['1111111111', '2222222222', '3333333333', '4444444444', '5555555555'],k = 1) == \"5555555555\"\n assert candidate(nums = ['9999999999', '8888888888', '7777777777', '6666666666', '5555555555', '4444444444', '3333333333', '2222222222', '1111111111', '0'],k = 10) == \"0\"\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999', '1111', '2222', '3333', '4444', '5555', '6666', '7777', '8888', '9999'],k = 15) == \"444\"\n assert candidate(nums = ['9999999999', '8888888888', '7777777777', '6666666666', '5555555555'],k = 3) == \"7777777777\"\n assert candidate(nums = ['1000', '1000', '1000', '1000', '1000', '1000'],k = 3) == \"1000\"\n assert candidate(nums = ['1111111111', '2222222222', '3333333333', '4444444444', '5555555555', '6666666666', '7777777777', '8888888888', '9999999999', '10000000000'],k = 2) == \"9999999999\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000'],k = 5) == \"10\"\n assert candidate(nums = ['9', '29', '39', '49', '59', '69', '79', '89', '99', '109'],k = 8) == \"39\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15'],k = 15) == \"1\"\n assert candidate(nums = ['123456789', '987654321', '111111111', '222222222', '333333333'],k = 4) == \"123456789\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415'],k = 1) == \"131415\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415', '161718', '192021', '222324', '252627', '282930'],k = 4) == \"192021\"\n assert candidate(nums = ['5', '10', '15', '20', '25', '30', '35', '40'],k = 7) == \"10\"\n assert candidate(nums = ['1000000000', '999999999', '1000000000', '999999999', '1000000000', '999999999', '1000000000', '999999999', '1000000000', '999999999'],k = 8) == \"999999999\"\n assert candidate(nums = ['999999999999999999', '1000000000000000000', '999999999999999998'],k = 1) == \"1000000000000000000\"\n assert candidate(nums = ['100', '1000', '10', '1'],k = 2) == \"100\"\n assert candidate(nums = ['100', '200', '300', '400', '500', '600', '700', '800', '900'],k = 7) == \"300\"\n assert candidate(nums = ['1234567890', '1234567891', '1234567892', '1234567893', '1234567894', '1234567895', '1234567896', '1234567897', '1234567898', '1234567899'],k = 9) == \"1234567891\"\n assert candidate(nums = ['987654321', '98765432', '9876543', '987654', '98765', '9876', '987', '98', '9'],k = 8) == \"98\"\n assert candidate(nums = ['99999', '88888', '77777', '66666', '55555', '44444', '33333', '22222', '11111'],k = 9) == \"11111\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000'],k = 3) == \"100\"\n assert candidate(nums = ['10000', '10001', '10002', '10003', '10004', '10005', '10006', '10007', '10008', '10009'],k = 8) == \"10002\"\n assert candidate(nums = ['123456789', '987654321', '111111111', '222222222', '333333333'],k = 2) == \"333333333\"\n assert candidate(nums = ['999999999999999999', '999999999999999998', '1000000000000000000'],k = 2) == \"999999999999999999\"\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999', '111', '222', '333', '444', '555', '666', '777', '888', '999', '111', '222'],k = 15) == \"222\"\n assert candidate(nums = ['999999999999999999', '1000000000000000000', '999999999999999998'],k = 2) == \"999999999999999999\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 10) == \"1\"\n assert candidate(nums = ['100', '200', '300', '400', '500', '600', '700', '800', '900', '1000'],k = 7) == \"400\"\n assert candidate(nums = ['999', '998', '997', '996', '995', '994', '993', '992', '991', '990'],k = 10) == \"990\"\n assert candidate(nums = ['1', '11', '111', '1111', '11111', '111111', '1111111', '11111111', '111111111', '1111111111'],k = 3) == \"11111111\"\n assert candidate(nums = ['9876543210', '102030405060708090', '123456789', '987654321', '1000000000', '999999999', '1111111111', '2222222222', '3333333333', '4444444444'],k = 3) == \"4444444444\"\n assert candidate(nums = ['9', '99', '999', '9999', '99999', '999999', '9999999', '99999999', '999999999', '9999999999'],k = 5) == \"999999\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415', '161718', '192021', '222324', '252627', '282930'],k = 6) == \"131415\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415', '161718'],k = 3) == \"101112\"\n assert candidate(nums = ['1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000'],k = 5) == \"1000\"\n assert candidate(nums = ['1000000', '999999', '888888', '777777', '666666'],k = 2) == \"999999\"\n assert candidate(nums = ['999', '998', '997', '996', '995', '994', '993', '992', '991', '990'],k = 5) == \"995\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 5) == \"100000\"\n assert candidate(nums = ['12345678901234567890', '12345678901234567891', '12345678901234567892'],k = 2) == \"12345678901234567891\"\n assert candidate(nums = ['999', '888', '777', '666', '555', '444', '333', '222', '111', '0'],k = 1) == \"999\"\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().kthLargestNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def kthLargestNumber(self, nums: list[str], k: int) -> str:", "container": "Solution", "callable": "kthLargestNumber", "parameters": [{"name": "nums", "type": "list[str]"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1986, "task_id": "minimum-number-of-work-sessions-to-finish-the-tasks", "difficulty": "Medium", "problem_description": "There are n tasks assigned to you. The task times are represented as an integer array tasks of length n, where the ith task takes tasks[i] hours to finish. A work session is when you work for at most sessionTime consecutive hours and then take a break.\nYou should finish the given tasks in a way that satisfies the following conditions:\n\nIf you start a task in a work session, you must complete it in the same work session.\nYou can start a new task immediately after finishing the previous one.\nYou may complete the tasks in any order.\n\nGiven tasks and sessionTime, return the minimum number of work sessions needed to finish all the tasks following the conditions above.\nThe tests are generated such that sessionTime is greater than or equal to the maximum element in tasks[i].\n \nExample 1:\n\nInput: tasks = [1,2,3], sessionTime = 3\nOutput: 2\nExplanation: You can finish the tasks in two work sessions.\n- First work session: finish the first and the second tasks in 1 + 2 = 3 hours.\n- Second work session: finish the third task in 3 hours.\n\nExample 2:\n\nInput: tasks = [3,1,3,1,1], sessionTime = 8\nOutput: 2\nExplanation: You can finish the tasks in two work sessions.\n- First work session: finish all the tasks except the last one in 3 + 1 + 3 + 1 = 8 hours.\n- Second work session: finish the last task in 1 hour.\n\nExample 3:\n\nInput: tasks = [1,2,3,4,5], sessionTime = 15\nOutput: 1\nExplanation: You can finish all the tasks in one work session.\n\n \nConstraints:\n\nn == tasks.length\n1 <= n <= 14\n1 <= tasks[i] <= 10\nmax(tasks[i]) <= sessionTime <= 15\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [1, 3, 2, 4],sessionTime = 5) == 2\n assert candidate(tasks = [5, 7, 4, 2, 6],sessionTime = 10) == 3\n assert candidate(tasks = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],sessionTime = 12) == 5\n assert candidate(tasks = [1, 2, 3],sessionTime = 3) == 2\n assert candidate(tasks = [5, 5, 5, 5],sessionTime = 5) == 4\n assert candidate(tasks = [9, 9, 9, 9],sessionTime = 9) == 4\n assert candidate(tasks = [2, 3, 3, 4, 6],sessionTime = 6) == 3\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 2) == 7\n assert candidate(tasks = [14],sessionTime = 14) == 1\n assert candidate(tasks = [7, 7, 7, 7],sessionTime = 14) == 2\n assert candidate(tasks = [10, 10, 10, 10],sessionTime = 10) == 4\n assert candidate(tasks = [10, 10, 10],sessionTime = 10) == 3\n assert candidate(tasks = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1],sessionTime = 14) == 8\n assert candidate(tasks = [14, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 14) == 2\n assert candidate(tasks = [2, 3, 4, 5, 1],sessionTime = 6) == 3\n assert candidate(tasks = [1, 2, 3, 4, 5],sessionTime = 15) == 1\n assert candidate(tasks = [7, 2, 7, 2, 7],sessionTime = 12) == 3\n assert candidate(tasks = [8, 8, 8, 8, 8, 8, 8, 8],sessionTime = 15) == 8\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 15) == 7\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],sessionTime = 10) == 14\n assert candidate(tasks = [1, 2, 3, 4],sessionTime = 10) == 1\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 15) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 14) == 8\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 14) == 1\n assert candidate(tasks = [3, 1, 3, 1, 1],sessionTime = 8) == 2\n assert candidate(tasks = [7, 2, 4, 3, 5],sessionTime = 12) == 2\n assert candidate(tasks = [1, 2, 3, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7],sessionTime = 10) == 6\n assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1],sessionTime = 10) == 6\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 1, 3, 5, 7, 9, 11, 13],sessionTime = 15) == 7\n assert candidate(tasks = [7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7],sessionTime = 13) == 5\n assert candidate(tasks = [2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5],sessionTime = 12) == 5\n assert candidate(tasks = [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6],sessionTime = 12) == 5\n assert candidate(tasks = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1],sessionTime = 11) == 7\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],sessionTime = 15) == 14\n assert candidate(tasks = [10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 15) == 4\n assert candidate(tasks = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],sessionTime = 14) == 7\n assert candidate(tasks = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2],sessionTime = 8) == 5\n assert candidate(tasks = [1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 14],sessionTime = 14) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 28) == 4\n assert candidate(tasks = [3, 6, 7, 9, 10, 1, 2, 4, 5, 8, 2, 3, 4, 6],sessionTime = 10) == 7\n assert candidate(tasks = [7, 8, 7, 8, 7, 8, 7, 8],sessionTime = 15) == 4\n assert candidate(tasks = [7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7],sessionTime = 12) == 5\n assert candidate(tasks = [2, 3, 5, 7, 11, 13],sessionTime = 15) == 3\n assert candidate(tasks = [2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],sessionTime = 14) == 6\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 20) == 6\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6],sessionTime = 10) == 6\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 20) == 6\n assert candidate(tasks = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5],sessionTime = 10) == 4\n assert candidate(tasks = [8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 15) == 4\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 15) == 5\n assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7],sessionTime = 15) == 6\n assert candidate(tasks = [3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1],sessionTime = 7) == 5\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 14],sessionTime = 14) == 2\n assert candidate(tasks = [10, 10, 10, 10, 1, 2, 3, 4],sessionTime = 15) == 4\n assert candidate(tasks = [9, 1, 4, 8, 3, 2, 5, 6, 7, 10, 1, 2, 3, 4],sessionTime = 10) == 7\n assert candidate(tasks = [7, 7, 7, 7, 7, 7, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 14) == 4\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 5) == 14\n assert candidate(tasks = [10, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 10, 1, 2],sessionTime = 10) == 8\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 10) == 4\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],sessionTime = 30) == 5\n assert candidate(tasks = [7, 3, 4, 5, 6, 2, 8, 9, 10, 1, 2, 3, 4, 5],sessionTime = 10) == 7\n assert candidate(tasks = [10, 10, 10, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4],sessionTime = 14) == 4\n assert candidate(tasks = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5],sessionTime = 10) == 5\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],sessionTime = 14) == 4\n assert candidate(tasks = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],sessionTime = 9) == 5\n assert candidate(tasks = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],sessionTime = 12) == 6\n assert candidate(tasks = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],sessionTime = 9) == 5\n assert candidate(tasks = [2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7],sessionTime = 12) == 6\n assert candidate(tasks = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],sessionTime = 10) == 5\n assert candidate(tasks = [1, 2, 3, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2],sessionTime = 8) == 5\n assert candidate(tasks = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],sessionTime = 10) == 14\n assert candidate(tasks = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5],sessionTime = 9) == 5\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 10) == 7\n assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4],sessionTime = 20) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4],sessionTime = 10) == 4\n assert candidate(tasks = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],sessionTime = 16) == 7\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1],sessionTime = 10) == 14\n assert candidate(tasks = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],sessionTime = 13) == 5\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 10) == 7\n assert candidate(tasks = [2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13],sessionTime = 14) == 8\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2],sessionTime = 6) == 4\n assert candidate(tasks = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43],sessionTime = 15) == inf\n assert candidate(tasks = [10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 10) == 5\n assert candidate(tasks = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],sessionTime = 4) == 7\n assert candidate(tasks = [9, 6, 7, 8, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14],sessionTime = 14) == 8\n assert candidate(tasks = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],sessionTime = 6) == 6\n assert candidate(tasks = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],sessionTime = 10) == 6\n assert candidate(tasks = [9, 6, 3, 2, 1, 9, 6, 3, 2, 1, 9, 6, 3, 2],sessionTime = 10) == 7\n assert candidate(tasks = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],sessionTime = 13) == 3\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 10) == inf\n assert candidate(tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2],sessionTime = 10) == 5\n assert candidate(tasks = [10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 15) == 6\n assert candidate(tasks = [10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 10) == 5\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 14],sessionTime = 10) == inf\n assert candidate(tasks = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4],sessionTime = 8) == 4\n assert candidate(tasks = [1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7],sessionTime = 12) == 6\n assert candidate(tasks = [1, 3, 2, 4, 6, 5, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 14) == 8\n assert candidate(tasks = [14, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 14) == 2\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 13) == inf\n assert candidate(tasks = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],sessionTime = 4) == 6\n assert candidate(tasks = [3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1],sessionTime = 9) == 4\n assert candidate(tasks = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],sessionTime = 15) == 5\n assert candidate(tasks = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],sessionTime = 12) == 7\n assert candidate(tasks = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5],sessionTime = 6) == 7\n assert candidate(tasks = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],sessionTime = 8) == 4\n assert candidate(tasks = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1],sessionTime = 8) == 14\n assert candidate(tasks = [3, 2, 3, 2, 3, 2, 3, 2],sessionTime = 5) == 4\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],sessionTime = 10) == 6\n assert candidate(tasks = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43],sessionTime = 20) == inf\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 11, 9, 7, 5, 3, 1],sessionTime = 15) == 6\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 2) == 8\n assert candidate(tasks = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],sessionTime = 14) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 10) == inf\n assert candidate(tasks = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2],sessionTime = 5) == 6\n assert candidate(tasks = [2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5],sessionTime = 10) == 5\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 1, 3, 5, 7, 9, 11],sessionTime = 15) == 7\n assert candidate(tasks = [7, 7, 7, 7, 6, 6, 6, 5, 5, 4, 4, 3, 3, 2],sessionTime = 15) == 5\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],sessionTime = 8) == 7\n assert candidate(tasks = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7],sessionTime = 14) == 5\n assert candidate(tasks = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],sessionTime = 12) == 6\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 20) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 7) == inf\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],sessionTime = 20) == 7\n"}, "metadata": {"canonical_parameter_names": ["tasks", "sessionTime"], "leetcode_dataset_entry_point": "Solution().minSessions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minSessions(self, tasks: list[int], sessionTime: int) -> int:", "container": "Solution", "callable": "minSessions", "parameters": [{"name": "tasks", "type": "list[int]"}, {"name": "sessionTime", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1987, "task_id": "number-of-unique-good-subsequences", "difficulty": "Hard", "problem_description": "You are given a binary string binary. A subsequence of binary is considered good if it is not empty and has no leading zeros (with the exception of \"0\").\nFind the number of unique good subsequences of binary.\n\nFor example, if binary = \"001\", then all the good subsequences are [\"0\", \"0\", \"1\"], so the unique good subsequences are \"0\" and \"1\". Note that subsequences \"00\", \"01\", and \"001\" are not good because they have leading zeros.\n\nReturn the number of unique good subsequences of binary. Since the answer may be very large, return it modulo 109 + 7.\nA subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.\n \nExample 1:\n\nInput: binary = \"001\"\nOutput: 2\nExplanation: The good subsequences of binary are [\"0\", \"0\", \"1\"].\nThe unique good subsequences are \"0\" and \"1\".\n\nExample 2:\n\nInput: binary = \"11\"\nOutput: 2\nExplanation: The good subsequences of binary are [\"1\", \"1\", \"11\"].\nThe unique good subsequences are \"1\" and \"11\".\nExample 3:\n\nInput: binary = \"101\"\nOutput: 5\nExplanation: The good subsequences of binary are [\"1\", \"0\", \"1\", \"10\", \"11\", \"101\"]. \nThe unique good subsequences are \"0\", \"1\", \"10\", \"11\", and \"101\".\n\n \nConstraints:\n\n1 <= binary.length <= 105\nbinary consists of only '0's and '1's.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(binary = \"101\") == 5\n assert candidate(binary = \"1111\") == 4\n assert candidate(binary = \"1\") == 1\n assert candidate(binary = \"010101\") == 13\n assert candidate(binary = \"111000111\") == 43\n assert candidate(binary = \"10000100001\") == 64\n assert candidate(binary = \"1001001\") == 26\n assert candidate(binary = \"1010101010\") == 144\n assert candidate(binary = \"00000\") == 1\n assert candidate(binary = \"000000\") == 1\n assert candidate(binary = \"0000000000\") == 1\n assert candidate(binary = \"000\") == 1\n assert candidate(binary = \"001\") == 2\n assert candidate(binary = \"11\") == 2\n assert candidate(binary = \"0101010101\") == 89\n assert candidate(binary = \"1100110011\") == 99\n assert candidate(binary = \"0101010\") == 21\n assert candidate(binary = \"0\") == 1\n assert candidate(binary = \"111111\") == 6\n assert candidate(binary = \"100101010\") == 76\n assert candidate(binary = \"1000000000000000000000000000000000000000000000000000000000000001\") == 127\n assert candidate(binary = \"1101\") == 8\n assert candidate(binary = \"1001010\") == 29\n assert candidate(binary = \"01010101\") == 34\n assert candidate(binary = \"11010\") == 13\n assert candidate(binary = \"11111\") == 5\n assert candidate(binary = \"1111111111\") == 10\n assert candidate(binary = \"00000000000000000000000000000000000000000001\") == 2\n assert candidate(binary = \"11011011011011011011\") == 7953\n assert candidate(binary = \"10000000000000000001\") == 39\n assert candidate(binary = \"010101010101010101010101\") == 75025\n assert candidate(binary = \"11111111111111111111111111111111111111111110\") == 87\n assert candidate(binary = \"100000000000000000000000\") == 25\n assert candidate(binary = \"101010101010101010101010101010101010101010101010101\") == 316290802\n assert candidate(binary = \"10101010101010101010\") == 17711\n assert candidate(binary = \"010101010101010101010101010101010101010101010101010\") == 951279875\n assert candidate(binary = \"0000000011111111\") == 9\n assert candidate(binary = \"11110000111100001111000011110000\") == 121393\n assert candidate(binary = \"110110110110\") == 265\n assert candidate(binary = \"11111000001111100000\") == 836\n assert candidate(binary = \"1010101010101\") == 610\n assert candidate(binary = \"111000111000\") == 142\n assert candidate(binary = \"1001001001001001001001001001001001\") == 3650401\n assert candidate(binary = \"0101010101010101010101010101\") == 514229\n assert candidate(binary = \"010101010101\") == 233\n assert candidate(binary = \"1010101010101010101010101010101010101010\") == 267914296\n assert candidate(binary = \"0101010101010101\") == 1597\n assert candidate(binary = \"1111111111111111111111111111111111111111\") == 40\n assert candidate(binary = \"11001100110011001100\") == 8119\n assert candidate(binary = \"000000000001\") == 2\n assert candidate(binary = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110\") == 199\n assert candidate(binary = \"01010101010101010101010101010101010101010101010\") == 807526948\n assert candidate(binary = \"10101010101010101010101\") == 75025\n assert candidate(binary = \"1001001001\") == 97\n assert candidate(binary = \"11001010010111\") == 545\n assert candidate(binary = \"000111111111111111111111111111111111111111111111111\") == 49\n assert candidate(binary = \"111111111111111111111111\") == 24\n assert candidate(binary = \"11111111111111111111111111111111111111111111\") == 44\n assert candidate(binary = \"1001001001001001001001001001001001001001001001001001001001\") == 379190178\n assert candidate(binary = \"000000000000000000000000000000000000000000000000001\") == 2\n assert candidate(binary = \"0101010101010101010101010101010101010101\") == 165580141\n assert candidate(binary = \"110110110110110110\") == 3691\n assert candidate(binary = \"1111000011110000\") == 377\n assert candidate(binary = \"000000000000\") == 1\n assert candidate(binary = \"1111100000011111\") == 191\n assert candidate(binary = \"1111111111111111111111111111\") == 28\n assert candidate(binary = \"111000111000111000111000111000111000111000111000111000111\") == 619446900\n assert candidate(binary = \"110101010101\") == 377\n assert candidate(binary = \"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\") == 2\n assert candidate(binary = \"1001001001001001\") == 1351\n assert candidate(binary = \"1100110011001100\") == 1393\n assert candidate(binary = \"00000000000000000000000000000000\") == 1\n assert candidate(binary = \"01010101010101010101010101010101010101010101\") == 134903163\n assert candidate(binary = \"1010101010101010101010101010101010101010101010101011\") == 681301736\n assert candidate(binary = \"10111001001010011001\") == 8492\n assert candidate(binary = \"11111111111111111110\") == 39\n assert candidate(binary = \"111000111000111000111000111000111000111000111000\") == 239244622\n assert candidate(binary = \"101010101010\") == 377\n assert candidate(binary = \"000000000011111111110000000000\") == 111\n assert candidate(binary = \"00000000000000000000\") == 1\n assert candidate(binary = \"1111100000111110000011111\") == 4341\n assert candidate(binary = \"100100100100100100100100100100100100100100100100100\") == 694626305\n assert candidate(binary = \"000111000111000\") == 142\n assert candidate(binary = \"001100110011\") == 99\n assert candidate(binary = \"11000110001100011000\") == 4401\n assert candidate(binary = \"1000000000000000001\") == 37\n assert candidate(binary = \"111100001111000011110000111100001111000011110000111\") == 133957148\n assert candidate(binary = \"10010101010101010101\") == 15127\n assert candidate(binary = \"01010101010101010101\") == 10946\n assert candidate(binary = \"0001111111000\") == 29\n"}, "metadata": {"canonical_parameter_names": ["binary"], "leetcode_dataset_entry_point": "Solution().numberOfUniqueGoodSubsequences", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numberOfUniqueGoodSubsequences(self, binary: str) -> int:", "container": "Solution", "callable": "numberOfUniqueGoodSubsequences", "parameters": [{"name": "binary", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1991, "task_id": "find-the-middle-index-in-array", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums, find the leftmost middleIndex (i.e., the smallest amongst all the possible ones).\nA middleIndex is an index where nums[0] + nums[1] + ... + nums[middleIndex-1] == nums[middleIndex+1] + nums[middleIndex+2] + ... + nums[nums.length-1].\nIf middleIndex == 0, the left side sum is considered to be 0. Similarly, if middleIndex == nums.length - 1, the right side sum is considered to be 0.\nReturn the leftmost middleIndex that satisfies the condition, or -1 if there is no such index.\n \nExample 1:\n\nInput: nums = [2,3,-1,8,4]\nOutput: 3\nExplanation: The sum of the numbers before index 3 is: 2 + 3 + -1 = 4\nThe sum of the numbers after index 3 is: 4 = 4\n\nExample 2:\n\nInput: nums = [1,-1,4]\nOutput: 2\nExplanation: The sum of the numbers before index 2 is: 1 + -1 = 0\nThe sum of the numbers after index 2 is: 0\n\nExample 3:\n\nInput: nums = [2,5]\nOutput: -1\nExplanation: There is no valid middleIndex.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n-1000 <= nums[i] <= 1000\n\n \nNote: This question is the same as 724: https://leetcode.com/problems/find-pivot-index/\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, -1, 4]) == 2\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1, 100]) == -1\n assert candidate(nums = [0, 1]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5]) == -1\n assert candidate(nums = [2, 5]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums = [1, 0]) == 0\n assert candidate(nums = [2, 3, -1, 8, 4]) == 3\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == -1\n assert candidate(nums = [-1, -1, -1, -1]) == -1\n assert candidate(nums = [1, 7, 3, 6, 5, 6]) == 3\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [1000, -1000, 1000, -1000]) == -1\n assert candidate(nums = [1, 1]) == -1\n assert candidate(nums = [1, 2, 3]) == -1\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000]) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [1000, -500, 250, 250, -1000, 500, 500, 0, 0, 0]) == 0\n assert candidate(nums = [100, 0, -100, 0, 100, 0, -100]) == 3\n assert candidate(nums = [100, -50, 25, 25, -100, 50, 50]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 1, 0, -1, 0, 1, 0, -1, 0]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == -1\n assert candidate(nums = [7, 1, 5, 2, -4, 3, 0, 1, -2, 3]) == -1\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == -1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == 0\n assert candidate(nums = [5, -10, 10, 5, 0]) == -1\n assert candidate(nums = [-5, 5, -5, 5, -5, 5]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == -1\n assert candidate(nums = [3, -2, 1, 6, -4, 2, 5]) == -1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40]) == 6\n assert candidate(nums = [100, 200, -300, 400, -500, 600, -700, 800]) == -1\n assert candidate(nums = [7, 1, 5, 2, -4, 3, 0]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == -1\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, -1500, 600, 700]) == -1\n assert candidate(nums = [1000, -1000, 0, 1000, -1000]) == 2\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -1\n assert candidate(nums = [-1000, 500, -250, 125, -62, 31, -15, 7, -3, 1]) == -1\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5]) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == -1\n assert candidate(nums = [-1, -2, -3, -4, -5, 15]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == 9\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [1, -2, 3, 4, -3, 2]) == -1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, -210]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [10, -10, 0, 5, -5, 5, -5]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == -1\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000]) == -1\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40]) == -1\n assert candidate(nums = [0, 1, 0, -1, 0, 1, 0, -1]) == 0\n assert candidate(nums = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == -1\n assert candidate(nums = [1000, -1000, 500, -500, 250, -250, 125, -125]) == -1\n assert candidate(nums = [0, 1, 2, 3, 4, 3, 2, 1, 0]) == 4\n assert candidate(nums = [1, -1, 0, 1, -1]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(nums = [10, 20, 30, 10, 10, 30]) == -1\n assert candidate(nums = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1, 0]) == -1\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000]) == -1\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6, 3, -3, 1, -1]) == -1\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == -1\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == -1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 9\n assert candidate(nums = [1000, -1000, 500, -500, 250, -250]) == -1\n assert candidate(nums = [1000, -1000, 500, -500, 0, 0]) == 4\n assert candidate(nums = [7, 1, 5, 2, -4, 3, 0, 0, 0, 0]) == -1\n assert candidate(nums = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1, 1]) == -1\n assert candidate(nums = [-10, 10, -20, 20, -30, 30]) == -1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 0]) == 20\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findMiddleIndex", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findMiddleIndex(self, nums: list[int]) -> int:", "container": "Solution", "callable": "findMiddleIndex", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1992, "task_id": "find-all-groups-of-farmland", "difficulty": "Medium", "problem_description": "You are given a 0-indexed m x n binary matrix land where a 0 represents a hectare of forested land and a 1 represents a hectare of farmland.\nTo keep the land organized, there are designated rectangular areas of hectares that consist entirely of farmland. These rectangular areas are called groups. No two groups are adjacent, meaning farmland in one group is not four-directionally adjacent to another farmland in a different group.\nland can be represented by a coordinate system where the top left corner of land is (0, 0) and the bottom right corner of land is (m-1, n-1). Find the coordinates of the top left and bottom right corner of each group of farmland. A group of farmland with a top left corner at (r1, c1) and a bottom right corner at (r2, c2) is represented by the 4-length array [r1, c1, r2, c2].\nReturn a 2D array containing the 4-length arrays described above for each group of farmland in land. If there are no groups of farmland, return an empty array. You may return the answer in any order.\n \nExample 1:\n\n\nInput: land = [[1,0,0],[0,1,1],[0,1,1]]\nOutput: [[0,0,0,0],[1,1,2,2]]\nExplanation:\nThe first group has a top left corner at land[0][0] and a bottom right corner at land[0][0].\nThe second group has a top left corner at land[1][1] and a bottom right corner at land[2][2].\n\nExample 2:\n\n\nInput: land = [[1,1],[1,1]]\nOutput: [[0,0,1,1]]\nExplanation:\nThe first group has a top left corner at land[0][0] and a bottom right corner at land[1][1].\n\nExample 3:\n\n\nInput: land = [[0]]\nOutput: []\nExplanation:\nThere are no groups of farmland.\n\n \nConstraints:\n\nm == land.length\nn == land[i].length\n1 <= m, n <= 300\nland consists of only 0's and 1's.\nGroups of farmland are rectangular in shape.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(land = [[0]]) == []\n assert candidate(land = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]]) == [[0, 0, 0, 1], [1, 2, 1, 3], [2, 0, 2, 1], [3, 2, 3, 3]]\n assert candidate(land = [[1, 0, 1], [0, 0, 0], [1, 1, 1]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [2, 0, 2, 2]]\n assert candidate(land = [[1, 0, 1], [0, 0, 0], [1, 1, 0]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [2, 0, 2, 1]]\n assert candidate(land = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == []\n assert candidate(land = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == [[0, 0, 2, 2]]\n assert candidate(land = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [1, 1, 1, 1], [2, 0, 2, 0], [2, 2, 2, 2]]\n assert candidate(land = [[1, 1], [1, 1]]) == [[0, 0, 1, 1]]\n assert candidate(land = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]]) == [[0, 0, 1, 1], [2, 2, 3, 3]]\n assert candidate(land = [[1, 0, 0, 0], [0, 1, 1, 1], [0, 1, 1, 1], [0, 0, 0, 0]]) == [[0, 0, 0, 0], [1, 1, 2, 3]]\n assert candidate(land = [[1, 0, 0], [0, 1, 1], [0, 1, 1]]) == [[0, 0, 0, 0], [1, 1, 2, 2]]\n assert candidate(land = [[0, 1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1, 1, 0], [1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1]]) == [[0, 1, 1, 2], [0, 5, 1, 6], [3, 0, 4, 2], [3, 4, 4, 6], [6, 0, 7, 1], [6, 6, 7, 7]]\n assert candidate(land = [[1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1]]) == [[0, 0, 1, 1], [2, 2, 3, 4], [4, 5, 5, 5]]\n assert candidate(land = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [0, 6, 0, 6], [1, 1, 1, 1], [1, 3, 1, 3], [1, 5, 1, 5], [1, 7, 1, 7], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [2, 6, 2, 6], [3, 1, 3, 1], [3, 3, 3, 3], [3, 5, 3, 5], [3, 7, 3, 7], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4], [4, 6, 4, 6]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1]]) == [[0, 0, 1, 3]]\n assert candidate(land = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == [[0, 0, 1, 5], [3, 0, 4, 5]]\n assert candidate(land = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [1, 1, 1, 1], [1, 3, 1, 3], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [3, 1, 3, 1], [3, 3, 3, 3], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4]]\n assert candidate(land = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[1, 1, 3, 3]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 1, 1]]) == [[0, 0, 0, 2], [0, 6, 0, 8], [2, 0, 2, 2], [2, 4, 2, 6], [3, 7, 4, 8], [4, 0, 4, 4]]\n assert candidate(land = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == [[0, 0, 5, 5], [2, 2, 3, 3]]\n assert candidate(land = [[1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1]]) == [[0, 0, 1, 1], [0, 3, 1, 4], [0, 6, 1, 7], [0, 9, 1, 9], [3, 0, 4, 1], [3, 3, 4, 4], [3, 6, 4, 7], [3, 9, 4, 9], [6, 0, 7, 1], [6, 3, 7, 4], [6, 6, 7, 7], [6, 9, 7, 9]]\n assert candidate(land = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [0, 6, 0, 6], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [2, 6, 2, 6], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4], [4, 6, 4, 6]]\n assert candidate(land = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 1, 1], [1, 0, 0, 0]]) == [[0, 0, 3, 0], [2, 2, 2, 3]]\n assert candidate(land = [[1, 0, 0, 0, 0, 1], [1, 1, 0, 0, 1, 1], [0, 1, 0, 0, 1, 0], [1, 1, 0, 0, 1, 1], [0, 1, 0, 0, 1, 0]]) == [[0, 0, 1, 1], [0, 5, 1, 5], [1, 4, 4, 4], [3, 0, 3, 1]]\n assert candidate(land = [[1, 0, 0, 0, 1, 0, 1, 1, 0, 0], [0, 1, 1, 0, 1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1]]) == [[0, 0, 0, 0], [0, 4, 3, 7], [0, 6, 1, 7], [1, 1, 1, 2], [2, 9, 3, 9], [3, 1, 3, 1], [5, 2, 5, 4], [5, 8, 5, 9]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1]]) == [[0, 0, 2, 2], [0, 6, 2, 8], [4, 0, 6, 2], [4, 6, 6, 8]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0], [0, 1, 0, 1, 1, 0], [0, 0, 1, 0, 0, 1]]) == [[0, 0, 0, 2], [1, 3, 2, 4], [2, 1, 2, 1], [3, 2, 3, 2], [3, 5, 3, 5]]\n assert candidate(land = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == [[0, 0, 2, 7], [4, 0, 6, 7]]\n assert candidate(land = [[1, 0, 0, 0, 1, 0], [0, 1, 1, 0, 0, 1], [0, 1, 1, 0, 0, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]]) == [[0, 0, 0, 0], [0, 4, 0, 4], [1, 1, 2, 2], [1, 5, 4, 5], [3, 3, 4, 5]]\n assert candidate(land = [[1, 0, 0, 1, 0], [1, 1, 0, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 0, 1], [0, 1, 1, 0, 1]]) == [[0, 0, 1, 1], [0, 3, 1, 3], [3, 0, 3, 2], [3, 4, 4, 4]]\n assert candidate(land = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [0, 6, 0, 6], [1, 1, 1, 1], [1, 3, 1, 3], [1, 5, 1, 5], [1, 7, 1, 7], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [2, 6, 2, 6], [3, 1, 3, 1], [3, 3, 3, 3], [3, 5, 3, 5], [3, 7, 3, 7], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4], [4, 6, 4, 6], [5, 1, 5, 1], [5, 3, 5, 3], [5, 5, 5, 5], [5, 7, 5, 7]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1]]) == [[0, 0, 1, 3], [2, 4, 3, 5]]\n assert candidate(land = [[0, 1, 1, 0, 0, 0], [1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [0, 0, 1, 1, 0, 0]]) == [[0, 1, 1, 1], [1, 0, 2, 0], [1, 4, 2, 4], [2, 3, 2, 4], [3, 1, 3, 2], [3, 5, 3, 5]]\n assert candidate(land = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == [[1, 1, 3, 3]]\n assert candidate(land = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 0, 1], [1, 0, 0, 1]]) == [[1, 1, 2, 2], [4, 0, 4, 3], [6, 0, 7, 0], [6, 3, 7, 3]]\n assert candidate(land = [[1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == [[0, 0, 1, 1], [1, 4, 2, 5], [3, 2, 3, 3]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 0, 0, 1, 1, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1, 0, 1], [0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]) == [[0, 0, 1, 3], [0, 9, 3, 9], [1, 6, 3, 7], [2, 4, 3, 7], [4, 2, 4, 3]]\n assert candidate(land = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1], [0, 0, 1, 0, 0]]) == [[0, 0, 0, 0], [0, 2, 1, 3], [0, 4, 0, 4], [1, 1, 2, 1], [2, 0, 2, 1], [3, 2, 3, 2]]\n assert candidate(land = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[1, 1, 3, 4], [1, 8, 4, 9], [3, 6, 4, 9], [3, 11, 4, 12]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1]]) == [[0, 0, 1, 3], [2, 4, 4, 6], [4, 2, 4, 6]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]]) == [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 7, 7]]\n assert candidate(land = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 1, 1]]) == [[1, 1, 3, 5], [5, 3, 7, 7]]\n assert candidate(land = [[1, 1, 0, 1, 1], [1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [1, 1, 0, 1, 1], [1, 1, 0, 1, 1]]) == [[0, 0, 1, 1], [0, 3, 1, 4], [3, 0, 4, 1], [3, 3, 4, 4]]\n assert candidate(land = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 0, 0, 0]]) == [[1, 1, 2, 2], [1, 4, 2, 5], [3, 6, 4, 7], [5, 3, 5, 4]]\n assert candidate(land = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == [[1, 1, 4, 4]]\n assert candidate(land = [[1, 1, 0, 0, 1], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [1, 0, 0, 0, 1]]) == [[0, 0, 1, 1], [0, 4, 1, 4], [2, 2, 3, 3], [4, 0, 4, 0], [4, 4, 4, 4]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 1, 1, 0], [0, 0, 0, 1, 0, 0, 1], [1, 1, 1, 0, 0, 1, 0]]) == [[0, 0, 0, 3], [1, 4, 2, 5], [2, 0, 2, 2], [3, 3, 3, 3], [3, 6, 3, 6], [4, 0, 4, 2], [4, 5, 4, 5]]\n assert candidate(land = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [0, 6, 0, 6], [1, 1, 1, 1], [1, 3, 1, 3], [1, 5, 1, 5], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [2, 6, 2, 6], [3, 1, 3, 1], [3, 3, 3, 3], [3, 5, 3, 5], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4], [4, 6, 4, 6]]\n assert candidate(land = [[0, 0, 0, 0, 0], [0, 1, 1, 0, 0], [0, 1, 1, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 0], [0, 0, 0, 1, 1]]) == [[1, 1, 2, 2], [4, 0, 4, 3]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1, 1]]) == [[0, 0, 1, 2], [0, 6, 1, 7], [2, 4, 3, 5], [4, 0, 4, 1], [4, 6, 4, 7]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0]]) == [[0, 0, 1, 2], [2, 3, 3, 5], [4, 0, 5, 0], [4, 2, 5, 2]]\n assert candidate(land = [[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1]]) == [[0, 0, 1, 1], [0, 5, 1, 6], [2, 2, 3, 4], [4, 0, 5, 1], [4, 5, 5, 6]]\n assert candidate(land = [[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0], [1, 0, 0, 1, 1], [0, 0, 0, 1, 1]]) == [[0, 0, 0, 0], [0, 4, 0, 4], [1, 1, 1, 3], [3, 0, 3, 0], [3, 3, 4, 4]]\n assert candidate(land = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == [[0, 0, 4, 0]]\n assert candidate(land = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1]]) == [[0, 0, 0, 0], [0, 3, 0, 3], [1, 1, 2, 2], [1, 4, 2, 4], [3, 0, 3, 0], [3, 3, 3, 3], [4, 1, 4, 2], [4, 4, 4, 4]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0]]) == [[0, 0, 1, 3], [2, 4, 3, 7], [5, 0, 5, 3]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 1, 1], [0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0]]) == [[0, 0, 1, 2], [1, 4, 2, 5], [3, 0, 4, 1]]\n assert candidate(land = [[1, 1, 0, 0, 0], [1, 1, 0, 1, 1], [0, 0, 0, 1, 1], [1, 1, 0, 0, 0], [1, 1, 0, 0, 0]]) == [[0, 0, 1, 1], [1, 3, 2, 4], [3, 0, 4, 1]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[0, 0, 1, 1], [1, 4, 2, 5], [3, 0, 3, 3]]\n assert candidate(land = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [1, 1, 1, 1], [1, 3, 1, 3], [1, 5, 1, 5], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [3, 1, 3, 1], [3, 3, 3, 3], [3, 5, 3, 5], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4]]\n assert candidate(land = [[1, 0, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0]]) == [[0, 0, 0, 0], [0, 4, 0, 5], [1, 1, 2, 3], [3, 0, 3, 0], [3, 4, 3, 5], [4, 1, 4, 3]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0]]) == [[0, 0, 2, 2], [0, 6, 0, 8], [1, 4, 1, 4], [2, 6, 2, 8], [3, 3, 5, 5], [4, 1, 4, 7]]\n assert candidate(land = [[0, 1, 1, 0, 0, 1], [0, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 1]]) == [[0, 1, 0, 2], [0, 5, 0, 5], [1, 4, 2, 5], [2, 0, 2, 2], [4, 0, 4, 1], [4, 3, 4, 5]]\n assert candidate(land = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == [[1, 1, 2, 2]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0], [1, 0, 0, 1, 1, 0], [1, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 1]]) == [[0, 0, 2, 0]]\n assert candidate(land = [[0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1]]) == [[0, 1, 4, 1], [0, 3, 4, 3], [0, 5, 4, 5], [1, 0, 1, 5], [3, 0, 3, 5]]\n assert candidate(land = [[1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1]]) == [[0, 0, 0, 0], [0, 4, 0, 5], [2, 0, 2, 1], [2, 4, 2, 5], [4, 0, 4, 1], [4, 4, 4, 5]]\n assert candidate(land = [[1, 0, 0, 0, 0, 1], [0, 1, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1]]) == [[0, 0, 0, 0], [0, 5, 0, 5], [1, 1, 2, 2], [1, 4, 2, 4], [3, 3, 3, 3], [3, 5, 3, 5]]\n assert candidate(land = [[1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0]]) == [[0, 0, 1, 1], [0, 6, 1, 7], [2, 2, 3, 3], [4, 0, 4, 1], [4, 4, 4, 5]]\n assert candidate(land = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [1, 1, 1, 1], [1, 3, 1, 3], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [3, 1, 3, 1], [3, 3, 3, 3]]\n assert candidate(land = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]]) == [[0, 0, 0, 1], [0, 4, 0, 5], [0, 8, 0, 9], [1, 6, 1, 7], [2, 0, 2, 1], [2, 4, 2, 5], [2, 8, 2, 9], [3, 6, 3, 7], [4, 0, 4, 1], [4, 4, 4, 5], [4, 8, 4, 9]]\n assert candidate(land = [[1, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1]]) == [[0, 0, 0, 0], [0, 5, 0, 5], [1, 2, 2, 3], [4, 0, 4, 0], [4, 5, 4, 5]]\n assert candidate(land = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == [[0, 1, 0, 1], [0, 3, 0, 3], [0, 5, 0, 5], [0, 7, 0, 7], [0, 9, 0, 9], [1, 0, 1, 0], [1, 2, 1, 2], [1, 4, 1, 4], [1, 6, 1, 6], [1, 8, 1, 8], [2, 1, 2, 1], [2, 3, 2, 3], [2, 5, 2, 5], [2, 7, 2, 7], [2, 9, 2, 9], [3, 0, 3, 0], [3, 2, 3, 2], [3, 4, 3, 4], [3, 6, 3, 6], [3, 8, 3, 8]]\n assert candidate(land = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[0, 0, 2, 5]]\n"}, "metadata": {"canonical_parameter_names": ["land"], "leetcode_dataset_entry_point": "Solution().findFarmland", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findFarmland(self, land: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "findFarmland", "parameters": [{"name": "land", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1994, "task_id": "the-number-of-good-subsets", "difficulty": "Hard", "problem_description": "You are given an integer array nums. We call a subset of nums good if its product can be represented as a product of one or more distinct prime numbers.\n\nFor example, if nums = [1, 2, 3, 4]:\n\n\t\n[2, 3], [1, 2, 3], and [1, 3] are good subsets with products 6 = 2*3, 6 = 2*3, and 3 = 3 respectively.\n[1, 4] and [4] are not good subsets with products 4 = 2*2 and 4 = 2*2 respectively.\n\n\n\nReturn the number of different good subsets in nums modulo 109 + 7.\nA subset of nums is any array that can be obtained by deleting some (possibly none or all) elements from nums. Two subsets are different if and only if the chosen indices to delete are different.\n \nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: 6\nExplanation: The good subsets are:\n- [1,2]: product is 2, which is the product of distinct prime 2.\n- [1,2,3]: product is 6, which is the product of distinct primes 2 and 3.\n- [1,3]: product is 3, which is the product of distinct prime 3.\n- [2]: product is 2, which is the product of distinct prime 2.\n- [2,3]: product is 6, which is the product of distinct primes 2 and 3.\n- [3]: product is 3, which is the product of distinct prime 3.\n\nExample 2:\n\nInput: nums = [4,2,3,15]\nOutput: 5\nExplanation: The good subsets are:\n- [2]: product is 2, which is the product of distinct prime 2.\n- [2,3]: product is 6, which is the product of distinct primes 2 and 3.\n- [2,15]: product is 30, which is the product of distinct primes 2, 3, and 5.\n- [3]: product is 3, which is the product of distinct prime 3.\n- [15]: product is 15, which is the product of distinct primes 3 and 5.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 30\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 3, 2, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == 59048.0\n assert candidate(nums = [1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 8184.0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10.0\n assert candidate(nums = [1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 142.0\n assert candidate(nums = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 703.0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 20.0\n assert candidate(nums = [30, 26, 28, 12, 14, 22, 2, 4, 18, 20, 16, 8, 10, 24, 6, 5, 15, 3, 25, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29]) == 3327.0\n assert candidate(nums = [1, 2, 3, 4]) == 6.0\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6654.0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20.0\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 20.0\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29]) == 127.0\n assert candidate(nums = [4, 2, 3, 15]) == 5.0\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == 59048.0\n assert candidate(nums = [30, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3326.0\n assert candidate(nums = [30, 28, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 6.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 1023.0\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 30]) == 72.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 59048.0\n assert candidate(nums = [10, 20, 30, 1, 2, 3, 5, 7]) == 42.0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 1.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30]) == 14.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 1]) == 4092.0\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 5, 5, 5, 7, 7, 7, 11, 11, 11, 13, 13, 13, 17, 17, 17, 19, 19, 19, 23, 23, 23, 29, 29, 29]) == 1048575.0\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30, 33]) == 6654.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 6, 10, 14, 15, 21, 22, 26, 30, 4, 9, 16, 25, 28, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3406848.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 18, 20, 21, 22, 25, 26, 27, 30]) == 14.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 33, 34, 35, 38, 39, 42, 46, 51, 55, 57, 58, 62]) == 14.0\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 20.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 1, 1]) == 13308.0\n assert candidate(nums = [2, 3, 2, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29, 30, 30, 30]) == 65609.0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 43.0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 6654.0\n assert candidate(nums = [4, 6, 10, 14, 15, 21, 22, 26, 27, 30]) == 14.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 72693241.0\n assert candidate(nums = [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]) == 27.0\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 11, 11, 11, 11]) == 3124.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 1023.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 14.0\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 32736.0\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 255.0\n assert candidate(nums = [1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30]) == 4604.0\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 11, 11, 11, 11]) == 4998.0\n assert candidate(nums = [6, 15, 10, 14, 21, 22, 26, 22, 21, 14, 10, 15, 6, 30, 30, 30, 30, 30, 30, 30]) == 40.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 6, 10, 14, 15, 21, 22, 26, 30, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3406848.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 2303.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18]) == 2111.0\n assert candidate(nums = [4, 9, 16, 25, 28, 10, 14, 21, 22, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 16.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]) == 2046.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 1023.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 9765624.0\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29, 30, 30, 30, 30, 30]) == 69983.0\n assert candidate(nums = [4, 8, 9, 12, 18, 20, 24, 25, 27, 28, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7]) == 9984.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 30, 30]) == 16.0\n assert candidate(nums = [1, 6, 10, 15, 21, 22, 26, 30]) == 24.0\n assert candidate(nums = [1, 6, 8, 9, 10, 12, 14, 15, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 28.0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 6654.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 3327.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 1548287.0\n assert candidate(nums = [8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 35]) == 13.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 32, 34, 35, 38, 39, 41, 43, 46, 47]) == 1023.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 1047552.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30, 15, 6, 10, 21, 22]) == 5246.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 72693241.0\n assert candidate(nums = [1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 8184.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 1023.0\n assert candidate(nums = [1, 2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29, 30, 30]) == 126844.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 6, 10, 14, 15, 21, 22, 26, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 8958.0\n assert candidate(nums = [1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 28.0\n assert candidate(nums = [30, 28, 15, 10, 6, 3, 2, 1]) == 18.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 59048.0\n assert candidate(nums = [15, 10, 21, 30, 22, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 32.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113]) == 1023.0\n assert candidate(nums = [30, 28, 26, 22, 21, 14, 10, 15, 6, 4, 8, 9, 12, 18, 20, 24, 25, 27, 1, 1]) == 56.0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1054.0\n assert candidate(nums = [10, 15, 21, 22, 26, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 25.0\n assert candidate(nums = [8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 13.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 30, 30, 30, 30]) == 18.0\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 30.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 30, 30, 1, 1, 1, 1, 1, 1]) == 1024.0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30]) == 691088.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66, 68, 69, 70, 72, 74, 75, 76, 77, 78, 80, 81, 82, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, 96, 98, 99, 100]) == 14.0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 14.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 33, 34, 35, 38, 39, 46, 51, 55, 57, 58, 62, 65, 69, 74, 77, 82, 85, 86, 87, 91, 93, 94, 95]) == 14.0\n assert candidate(nums = [30, 15, 6, 10, 21, 22, 26, 27, 28, 3, 5, 7, 11, 13, 17, 19, 23, 29, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2292736.0\n assert candidate(nums = [2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30, 33, 34]) == 3327.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30, 2, 3, 5, 7, 11, 13, 17, 19, 23]) == 40823.0\n assert candidate(nums = [1, 2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == 118096.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30]) == 2302.0\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3406848.0\n assert candidate(nums = [30, 15, 21, 10, 6, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 4, 8, 9, 12, 14, 16, 18, 20, 22, 24, 25, 26, 27, 28, 32, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66, 68, 69, 70, 72, 74, 75, 76, 77, 78, 80, 81, 82, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, 96, 98, 99, 100]) == 3327.0\n assert candidate(nums = [6, 15, 10, 14, 21, 22, 26, 22, 21, 14, 10, 15, 6, 30, 2, 3, 5, 7, 11, 13]) == 359.0\n assert candidate(nums = [1, 6, 10, 14, 15, 21, 22, 26, 30, 33, 34, 35, 38, 39, 46, 51, 55, 57, 58, 62, 65, 69, 74, 77, 82, 85, 86, 87, 91, 93, 94, 95]) == 28.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1047552.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30, 30, 30]) == 1407.0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 20.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 6, 10, 14, 15, 21, 22, 26, 30, 1]) == 13308.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 30, 30]) == 16.0\n assert candidate(nums = [1, 1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 16368.0\n assert candidate(nums = [4, 8, 9, 12, 16, 18, 20, 24, 25, 27, 28, 1, 2, 3, 5, 7, 11, 13, 17, 19]) == 510.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == 1048575.0\n assert candidate(nums = [8, 9, 12, 18, 20, 24, 25, 27, 28, 30]) == 1.0\n assert candidate(nums = [1, 1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30]) == 13308.0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 24166.0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numberOfGoodSubsets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numberOfGoodSubsets(self, nums: list[int]) -> int:", "container": "Solution", "callable": "numberOfGoodSubsets", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1995, "task_id": "count-special-quadruplets", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums, return the number of distinct quadruplets (a, b, c, d) such that:\n\nnums[a] + nums[b] + nums[c] == nums[d], and\na < b < c < d\n\n \nExample 1:\n\nInput: nums = [1,2,3,6]\nOutput: 1\nExplanation: The only quadruplet that satisfies the requirement is (0, 1, 2, 3) because 1 + 2 + 3 == 6.\n\nExample 2:\n\nInput: nums = [3,3,6,4,5]\nOutput: 0\nExplanation: There are no such quadruplets in [3,3,6,4,5].\n\nExample 3:\n\nInput: nums = [1,1,1,3,5]\nOutput: 4\nExplanation: The 4 quadruplets that satisfy the requirement are:\n- (0, 1, 2, 3): 1 + 1 + 1 == 3\n- (0, 1, 3, 4): 1 + 1 + 3 == 5\n- (0, 2, 3, 4): 1 + 1 + 3 == 5\n- (1, 2, 3, 4): 1 + 1 + 3 == 5\n\n \nConstraints:\n\n4 <= nums.length <= 50\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 6]) == 1\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1]) == 0\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28]) == 3\n assert candidate(nums = [1, 3, 5, 0, 0, 1, 3, 5]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 12\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 11\n assert candidate(nums = [3, 3, 6, 4, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [1, 1, 1, 3, 5]) == 4\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36]) == 3\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 135]) == 21\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66]) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 147\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 11\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10]) == 40\n assert candidate(nums = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 147\n assert candidate(nums = [4, 3, 2, 1, 8, 7, 6, 5, 12, 11, 10, 9, 16, 15, 14, 13, 20, 19, 18, 17]) == 143\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 19]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 12]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15]) == 21\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99]) == 817\n assert candidate(nums = [50, 25, 25, 75, 50, 50, 100, 50, 75, 100]) == 7\n assert candidate(nums = [5, 5, 5, 5, 15, 15, 15, 15, 25, 25, 25, 25, 35, 35, 35, 35]) == 304\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 174\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 60]) == 123\n assert candidate(nums = [1, 2, 3, 6, 3, 6, 9, 12, 15, 18, 21, 24]) == 34\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 927\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 15, 5, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 358\n assert candidate(nums = [5, 5, 5, 5, 5, 15, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 1, 4, 3, 6, 2, 7, 8, 9, 10]) == 10\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 53\n assert candidate(nums = [2, 2, 2, 6, 6, 6, 18, 18, 18]) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == 31\n assert candidate(nums = [1, 1, 1, 1, 4, 1, 1, 1, 1, 5]) == 0\n assert candidate(nums = [3, 3, 6, 4, 5, 5, 5, 15, 15, 15, 15, 30, 30, 30, 30]) == 16\n assert candidate(nums = [1, 2, 3, 4, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, 32, 33]) == 19\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 30]) == 21\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20]) == 11\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 244\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 5, 5, 15, 15, 15, 30]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 244\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11]) == 39\n assert candidate(nums = [7, 1, 2, 4, 5, 3, 8, 6, 9, 10]) == 10\n assert candidate(nums = [3, 3, 3, 9, 3, 3, 3, 3, 3, 3, 9, 3]) == 85\n assert candidate(nums = [5, 5, 5, 15, 15, 25, 25]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 147\n assert candidate(nums = [2, 2, 2, 6, 2, 2, 2, 6, 2, 2, 2, 6, 2, 2, 2]) == 105\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 15, 15]) == 420\n assert candidate(nums = [50, 25, 100, 75, 50, 125, 100, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450]) == 212\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 147\n assert candidate(nums = [5, 5, 5, 15, 10, 15, 20]) == 5\n assert candidate(nums = [8, 2, 2, 4, 6, 10, 2, 6, 2, 12, 8, 4]) == 22\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325]) == 55\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 53\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]) == 0\n assert candidate(nums = [1, 2, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54]) == 119\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 83\n assert candidate(nums = [8, 8, 8, 8, 32, 8, 8, 8, 8, 8, 8, 8]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 5, 1, 8, 3, 9, 4, 6]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 586\n assert candidate(nums = [5, 5, 5, 5, 5, 15, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 1, 2, 3, 3, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 13, 13, 14, 15]) == 218\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 23\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 53\n assert candidate(nums = [5, 1, 4, 2, 8, 10, 7]) == 3\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 2972\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15]) == 21\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 147\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == 17\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 314\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 110]) == 104\n assert candidate(nums = [5, 1, 5, 5, 5, 5, 5, 10]) == 0\n assert candidate(nums = [30, 20, 10, 60, 50, 40, 100, 90, 80, 70]) == 10\n assert candidate(nums = [1, 2, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39]) == 43\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 21]) == 76\n assert candidate(nums = [2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 166\n assert candidate(nums = [5, 15, 10, 10, 10, 10, 25, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 120\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 575\n assert candidate(nums = [1, 2, 3, 6, 7, 8, 11, 12, 15, 16, 19, 20, 23, 24, 27, 28]) == 61\n assert candidate(nums = [9, 5, 3, 7, 2, 8, 10, 6, 4, 12, 1, 11]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 150, 200, 250, 300]) == 48\n assert candidate(nums = [7, 3, 6, 2, 4, 8, 10, 15, 1, 9]) == 5\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 0\n assert candidate(nums = [90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 9, 8, 7, 6, 5, 4, 3, 2, 1, 101]) == 12\n assert candidate(nums = [3, 3, 3, 6, 9, 12, 15, 18, 21, 24, 27]) == 38\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countQuadruplets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countQuadruplets(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countQuadruplets", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1996, "task_id": "the-number-of-weak-characters-in-the-game", "difficulty": "Medium", "problem_description": "You are playing a game that contains multiple characters, and each of the characters has two main properties: attack and defense. You are given a 2D integer array properties where properties[i] = [attacki, defensei] represents the properties of the ith character in the game.\nA character is said to be weak if any other character has both attack and defense levels strictly greater than this character's attack and defense levels. More formally, a character i is said to be weak if there exists another character j where attackj > attacki and defensej > defensei.\nReturn the number of weak characters.\n \nExample 1:\n\nInput: properties = [[5,5],[6,3],[3,6]]\nOutput: 0\nExplanation: No character has strictly greater attack and defense than the other.\n\nExample 2:\n\nInput: properties = [[2,2],[3,3]]\nOutput: 1\nExplanation: The first character is weak because the second character has a strictly greater attack and defense.\n\nExample 3:\n\nInput: properties = [[1,5],[10,4],[4,3]]\nOutput: 1\nExplanation: The third character is weak because the second character has a strictly greater attack and defense.\n\n \nConstraints:\n\n2 <= properties.length <= 105\nproperties[i].length == 2\n1 <= attacki, defensei <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(properties = [[5, 5], [6, 3], [3, 6], [2, 2], [1, 1]]) == 2\n assert candidate(properties = [[2, 2], [3, 3]]) == 1\n assert candidate(properties = [[5, 1], [5, 10], [4, 10], [4, 4], [3, 14], [3, 6], [2, 10], [1, 14], [1, 4]]) == 4\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 4\n assert candidate(properties = [[5, 5], [6, 3], [3, 6]]) == 0\n assert candidate(properties = [[10, 1], [5, 1], [7, 10], [4, 1], [5, 9], [6, 9], [7, 2], [1, 10]]) == 4\n assert candidate(properties = [[1, 5], [10, 4], [4, 3], [5, 6], [7, 8], [8, 7], [9, 9], [2, 2]]) == 6\n assert candidate(properties = [[1, 10], [10, 1], [4, 4], [4, 5]]) == 0\n assert candidate(properties = [[1, 5], [10, 4], [4, 3], [3, 15], [1, 20]]) == 2\n assert candidate(properties = [[1, 5], [10, 4], [4, 3]]) == 1\n assert candidate(properties = [[5, 5], [6, 3], [3, 6], [2, 2], [1, 1], [6, 7]]) == 4\n assert candidate(properties = [[1, 5], [1, 5], [1, 5], [10, 4], [4, 3]]) == 1\n assert candidate(properties = [[10, 1], [5, 1], [7, 10], [4, 11], [12, 1], [8, 4], [9, 7]]) == 2\n assert candidate(properties = [[6, 9], [7, 5], [7, 9], [7, 10], [10, 4], [10, 7], [8, 4]]) == 3\n assert candidate(properties = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 4\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 3\n assert candidate(properties = [[100000, 100000], [1, 1], [2, 2], [3, 3], [4, 4]]) == 4\n assert candidate(properties = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991], [11, 99990], [12, 99989], [13, 99988], [14, 99987], [15, 99986], [16, 99985], [17, 99984], [18, 99983], [19, 99982], [20, 99981]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [2, 1], [2, 2], [1, 3], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [1, 4], [2, 4], [3, 4], [4, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 16\n assert candidate(properties = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991]]) == 0\n assert candidate(properties = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [9, 5], [8, 5], [7, 5], [6, 5], [5, 5]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 2]]) == 8\n assert candidate(properties = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [1, 11]]) == 9\n assert candidate(properties = [[100000, 100000], [1, 1], [2, 2], [99999, 99999], [50000, 50000], [10000, 10000]]) == 5\n assert candidate(properties = [[100000, 100000], [99999, 99999], [99998, 99998], [99997, 99997], [99996, 99996], [99995, 99995], [99994, 99994], [99993, 99993], [99992, 99992], [99991, 99991]]) == 9\n assert candidate(properties = [[100000, 1], [1, 100000], [50000, 50000], [25000, 75000], [75000, 25000]]) == 0\n assert candidate(properties = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3]]) == 20\n assert candidate(properties = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [10, 9], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 10]]) == 17\n assert candidate(properties = [[5, 9], [5, 7], [5, 5], [5, 3], [5, 1], [10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [10, 1]]) == 5\n assert candidate(properties = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 17\n assert candidate(properties = [[1, 10], [10, 1], [2, 9], [9, 2], [3, 8], [8, 3], [4, 7], [7, 4], [5, 6], [6, 5]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [2, 10], [3, 9], [4, 8], [5, 7], [6, 6], [7, 5], [8, 4], [9, 3], [10, 2], [1, 10]]) == 16\n assert candidate(properties = [[1, 1], [1, 10], [1, 100], [1, 1000], [1, 10000], [1, 100000], [10, 1], [10, 10], [10, 100], [10, 1000], [10, 10000], [10, 100000]]) == 5\n assert candidate(properties = [[10, 9], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 10]]) == 8\n assert candidate(properties = [[100000, 100000], [99999, 99999], [99998, 99998], [99997, 99997], [99996, 99996]]) == 4\n assert candidate(properties = [[10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [10, 1], [9, 10], [8, 10], [7, 10], [6, 10], [5, 10], [4, 10], [3, 10], [2, 10], [1, 10]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [10, 10]]) == 9\n assert candidate(properties = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [1, 90], [2, 89], [3, 88], [4, 87], [5, 86], [6, 85], [7, 84], [8, 83], [9, 82], [10, 81], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 18\n assert candidate(properties = [[50, 50], [51, 49], [52, 48], [53, 47], [54, 46], [55, 45], [56, 44], [57, 43], [58, 42], [59, 41], [60, 40]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]]) == 9\n assert candidate(properties = [[100000, 1], [99999, 2], [99998, 3], [99997, 4], [99996, 5], [99995, 6], [99994, 7], [99993, 8], [99992, 9], [99991, 10]]) == 0\n assert candidate(properties = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 8\n assert candidate(properties = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 13\n assert candidate(properties = [[10, 5], [9, 6], [8, 7], [7, 8], [6, 9], [5, 10], [4, 11], [3, 12], [2, 13], [1, 14], [10, 15], [9, 16], [8, 17], [7, 18], [6, 19], [5, 20], [4, 21], [3, 22], [2, 23], [1, 24]]) == 9\n assert candidate(properties = [[100000, 1], [1, 100000], [50000, 50000], [90000, 20000], [20000, 90000]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == 8\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [4, 12], [5, 13], [5, 14], [5, 15]]) == 12\n assert candidate(properties = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]]) == 9\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 9\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5], [2, 4], [2, 3], [2, 2], [2, 1], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == 8\n assert candidate(properties = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 9\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 14\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [5, 1], [5, 2], [5, 3]]) == 8\n assert candidate(properties = [[1, 5], [2, 10], [3, 15], [4, 20], [5, 25], [6, 30], [7, 35], [8, 40], [9, 45], [10, 50], [5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45]]) == 17\n assert candidate(properties = [[1, 10], [1, 20], [1, 30], [1, 40], [1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [1, 100]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 0\n assert candidate(properties = [[5, 9], [7, 7], [4, 3], [1, 10], [6, 6], [8, 2], [3, 5]]) == 3\n assert candidate(properties = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [15, 6], [25, 11], [35, 16], [45, 21], [55, 26], [10, 7], [20, 12], [30, 17], [40, 22], [50, 27]]) == 13\n assert candidate(properties = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 1], [8, 2], [9, 3], [10, 4]]) == 8\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 14\n assert candidate(properties = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995]]) == 0\n assert candidate(properties = [[20, 39], [19, 37], [18, 35], [17, 33], [16, 31], [15, 29], [14, 27], [13, 25], [12, 23], [11, 21], [10, 19], [9, 17], [8, 15], [7, 13], [6, 11], [5, 9], [4, 7], [3, 5], [2, 3], [1, 1]]) == 19\n assert candidate(properties = [[1, 100000], [100000, 1], [50000, 50000], [75000, 25000], [25000, 75000], [1, 1], [100000, 100000]]) == 4\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 0\n assert candidate(properties = [[1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1]]) == 0\n assert candidate(properties = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 9\n assert candidate(properties = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [100, 9], [100, 10], [99, 11], [98, 12], [97, 13], [96, 14], [95, 15], [94, 16], [93, 17], [92, 18], [91, 19], [90, 20]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 17\n assert candidate(properties = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 0\n assert candidate(properties = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14]]) == 9\n assert candidate(properties = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [1, 11]]) == 0\n assert candidate(properties = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [1, 90], [2, 89], [3, 88], [4, 87], [5, 86], [6, 85], [7, 84], [8, 83], [9, 82], [10, 81]]) == 9\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 4\n assert candidate(properties = [[5, 5], [5, 6], [6, 5], [6, 6], [1, 1], [1, 2], [2, 1], [2, 2], [7, 7], [8, 8]]) == 9\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [10, 9], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 1]]) == 18\n assert candidate(properties = [[10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [9, 10], [8, 10], [7, 10], [6, 10], [5, 10]]) == 0\n assert candidate(properties = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]) == 8\n assert candidate(properties = [[1, 5], [1, 5], [1, 5], [10, 4], [4, 3], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 8\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 10]]) == 8\n assert candidate(properties = [[1, 50000], [50000, 1], [2, 49999], [49999, 2], [3, 49998], [49998, 3], [4, 49997], [49997, 4], [5, 49996], [49996, 5], [6, 49995], [49995, 6], [7, 49994], [49994, 7], [8, 49993], [49993, 8], [9, 49992], [49992, 9], [10, 49991], [49991, 10]]) == 0\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]]) == 11\n assert candidate(properties = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 9], [11, 8], [12, 7], [13, 6], [14, 5], [15, 4]]) == 8\n assert candidate(properties = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19], [11, 21], [12, 23], [13, 25], [14, 27], [15, 29], [16, 31], [17, 33], [18, 35], [19, 37], [20, 39]]) == 19\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [4, 5], [3, 5], [2, 5], [1, 5], [5, 4], [5, 3], [5, 2], [5, 1]]) == 4\n assert candidate(properties = [[50, 50], [40, 40], [30, 30], [20, 20], [10, 10], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == 9\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 8\n assert candidate(properties = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10]]) == 5\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]]) == 0\n assert candidate(properties = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]]) == 0\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 10]]) == 17\n assert candidate(properties = [[9, 8], [8, 9], [7, 10], [6, 11], [5, 12], [4, 13], [3, 14], [2, 15], [1, 16], [10, 7], [11, 6], [12, 5], [13, 4], [14, 3], [15, 2], [16, 1]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 16\n assert candidate(properties = [[1, 50], [50, 1], [2, 49], [49, 2], [3, 48], [48, 3], [4, 47], [47, 4], [5, 46], [46, 5], [6, 45], [45, 6], [7, 44], [44, 7], [8, 43], [43, 8], [9, 42], [42, 9], [10, 41], [41, 10]]) == 0\n assert candidate(properties = [[9, 7], [9, 8], [9, 9], [10, 7], [10, 8], [10, 9], [11, 7], [11, 8], [11, 9]]) == 4\n assert candidate(properties = [[1, 100000], [100000, 1], [50000, 50000], [75000, 25000], [25000, 75000]]) == 0\n assert candidate(properties = [[5, 10], [10, 5], [15, 15], [20, 10], [25, 15], [30, 20], [35, 25], [40, 30], [45, 35], [50, 40]]) == 9\n assert candidate(properties = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 9\n"}, "metadata": {"canonical_parameter_names": ["properties"], "leetcode_dataset_entry_point": "Solution().numberOfWeakCharacters", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numberOfWeakCharacters(self, properties: list[list[int]]) -> int:", "container": "Solution", "callable": "numberOfWeakCharacters", "parameters": [{"name": "properties", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1997, "task_id": "first-day-where-you-have-been-in-all-the-rooms", "difficulty": "Medium", "problem_description": "There are n rooms you need to visit, labeled from 0 to n - 1. Each day is labeled, starting from 0. You will go in and visit one room a day.\nInitially on day 0, you visit room 0. The order you visit the rooms for the coming days is determined by the following rules and a given 0-indexed array nextVisit of length n:\n\nAssuming that on a day, you visit room i,\nif you have been in room i an odd number of times (including the current visit), on the next day you will visit a room with a lower or equal room number specified by nextVisit[i] where 0 <= nextVisit[i] <= i;\nif you have been in room i an even number of times (including the current visit), on the next day you will visit room (i + 1) mod n.\n\nReturn the label of the first day where you have been in all the rooms. It can be shown that such a day exists. Since the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nextVisit = [0,0]\nOutput: 2\nExplanation:\n- On day 0, you visit room 0. The total times you have been in room 0 is 1, which is odd.\n  On the next day you will visit room nextVisit[0] = 0\n- On day 1, you visit room 0, The total times you have been in room 0 is 2, which is even.\n  On the next day you will visit room (0 + 1) mod 2 = 1\n- On day 2, you visit room 1. This is the first day where you have been in all the rooms.\n\nExample 2:\n\nInput: nextVisit = [0,0,2]\nOutput: 6\nExplanation:\nYour room visiting order for each day is: [0,0,1,0,0,1,2,...].\nDay 6 is the first day where you have been in all the rooms.\n\nExample 3:\n\nInput: nextVisit = [0,1,2,0]\nOutput: 6\nExplanation:\nYour room visiting order for each day is: [0,0,1,1,2,2,3,...].\nDay 6 is the first day where you have been in all the rooms.\n\n \nConstraints:\n\nn == nextVisit.length\n2 <= n <= 105\n0 <= nextVisit[i] <= i\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nextVisit = [0, 0, 2]) == 6\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5]) == 10\n assert candidate(nextVisit = [0, 2, 1, 0, 1, 2]) == 52\n assert candidate(nextVisit = [0, 1, 1, 1, 1]) == 16\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1022\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1]) == 42\n assert candidate(nextVisit = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 712\n assert candidate(nextVisit = [0, 1, 2, 3, 2, 1, 0, 1, 2, 3]) == 230\n assert candidate(nextVisit = [0, 1, 0, 2]) == 10\n assert candidate(nextVisit = [0, 1, 2, 0]) == 6\n assert candidate(nextVisit = [0, 1, 1, 1, 1, 1]) == 32\n assert candidate(nextVisit = [0, 1, 1, 0, 1, 1, 0]) == 72\n assert candidate(nextVisit = [0, 1, 0, 2, 1]) == 18\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 682\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 0]) == 10\n assert candidate(nextVisit = [0, 2, 2, 2, 2, 2]) == 20\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 18\n assert candidate(nextVisit = [0, 2, 1, 0]) == 12\n assert candidate(nextVisit = [0, 1, 1, 0, 1, 2]) == 36\n assert candidate(nextVisit = [0, 1, 1, 0]) == 8\n assert candidate(nextVisit = [0, 2, 1, 0, 1]) == 26\n assert candidate(nextVisit = [0, 0]) == 2\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == 328\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 0, 0, 0, 0]) == 670\n assert candidate(nextVisit = [0, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 192\n assert candidate(nextVisit = [0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 579139391\n assert candidate(nextVisit = [0, 1, 0, 3, 2, 5, 4, 7, 6, 9]) == 58\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1022\n assert candidate(nextVisit = [0, 0, 2, 1, 4, 3, 5, 6, 7, 8, 9]) == 98\n assert candidate(nextVisit = [0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0]) == 599186\n assert candidate(nextVisit = [0, 1, 1, 2, 2, 2, 3, 3, 3, 3]) == 358\n assert candidate(nextVisit = [0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18]) == 56\n assert candidate(nextVisit = [0, 1, 0, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 633246732\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 38\n assert candidate(nextVisit = [0, 2, 1, 2, 3, 4, 5, 4, 3, 2]) == 178\n assert candidate(nextVisit = [0, 2, 1, 3, 1, 2, 4, 2, 1, 3, 1, 2, 4, 2, 1, 3, 1, 2, 4, 2, 1, 3, 1, 2, 4, 2, 1, 3, 1, 2, 4, 2, 1, 3, 1, 2, 4]) == 449162187\n assert candidate(nextVisit = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 110\n assert candidate(nextVisit = [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2]) == 786434\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2044\n assert candidate(nextVisit = [0, 1, 0, 3, 2, 1, 4, 5, 2, 3, 6, 7, 8, 9]) == 3802\n assert candidate(nextVisit = [0, 2, 1, 0, 4, 3, 2, 1, 0]) == 176\n assert candidate(nextVisit = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 524288\n assert candidate(nextVisit = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8]) == 90\n assert candidate(nextVisit = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 562740\n assert candidate(nextVisit = [0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0]) == 4912\n assert candidate(nextVisit = [0, 3, 5, 3, 4, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0]) == 11288\n assert candidate(nextVisit = [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 19]) == 262148\n assert candidate(nextVisit = [0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 6, 5, 4, 3, 2, 1, 0]) == 40131408\n assert candidate(nextVisit = [0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0]) == 13851577\n assert candidate(nextVisit = [0, 2, 1, 3, 1, 2, 5, 4, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4]) == 269566\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 461127067\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1048574\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 44739242\n assert candidate(nextVisit = [0, 1, 0, 2, 1, 0, 3, 2, 1, 0]) == 556\n assert candidate(nextVisit = [0, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 594736\n assert candidate(nextVisit = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 701096\n assert candidate(nextVisit = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 786430\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1048574\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 699050\n assert candidate(nextVisit = [0, 1, 2, 3, 2, 1, 2, 3, 4, 3, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9]) == 198234\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10258\n assert candidate(nextVisit = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 712\n assert candidate(nextVisit = [0, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 260\n assert candidate(nextVisit = [0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 28010\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 41964584\n assert candidate(nextVisit = [0, 1, 1, 2, 2, 3, 3, 4, 4, 5]) == 308\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 63550\n assert candidate(nextVisit = [0, 1, 1, 3, 2, 2, 5]) == 34\n assert candidate(nextVisit = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 311766262\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 38954\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 0]) == 18\n assert candidate(nextVisit = [0, 1, 0, 2, 3, 2, 5, 4]) == 82\n assert candidate(nextVisit = [0, 2, 1, 0, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9]) == 438546\n assert candidate(nextVisit = [0, 1, 2, 3, 2, 3, 4, 3, 4, 5]) == 154\n assert candidate(nextVisit = [5, 4, 3, 2, 1, 0]) == 48\n assert candidate(nextVisit = [0, 1, 0, 3, 0, 1, 0, 5, 0, 1, 0, 3, 0, 1, 0, 7, 0, 1, 0, 3, 0, 1]) == 1543578\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 3, 2, 3, 4, 5]) == 106\n assert candidate(nextVisit = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 717916156\n assert candidate(nextVisit = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 57521884\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10258\n assert candidate(nextVisit = [0, 1, 2, 0, 4, 0, 6, 0, 8, 0, 10, 0, 12, 0, 14, 0, 16, 0, 18, 0, 20]) == 5114\n assert candidate(nextVisit = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0]) == 438\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3]) == 123366\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20126903\n assert candidate(nextVisit = [5, 0, 4, 1, 3, 2, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5]) == 514496163\n assert candidate(nextVisit = [0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 0, 10]) == 943314207\n assert candidate(nextVisit = [0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3]) == 229862\n assert candidate(nextVisit = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 317428\n assert candidate(nextVisit = [0, 2, 1, 0, 3, 4, 5]) == 60\n assert candidate(nextVisit = [10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 66670\n assert candidate(nextVisit = [0, 2, 1, 2, 0, 0, 0, 3, 4, 2, 5]) == 1312\n assert candidate(nextVisit = [0, 2, 4, 6, 8, 0, 2, 4, 6, 8]) == 812\n assert candidate(nextVisit = [0, 1, 0, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 89816588\n assert candidate(nextVisit = [0, 2, 1, 0, 3, 2, 1]) == 80\n assert candidate(nextVisit = [0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 25]) == 2657202\n assert candidate(nextVisit = [0, 3, 1, 0, 2, 0, 3, 1, 0, 2, 0, 3, 1, 0, 2, 0, 3, 1, 0, 2, 0, 3, 1, 0, 2, 0, 3, 1, 0, 2, 0]) == 558657481\n assert candidate(nextVisit = [0, 5, 2, 4, 3, 1, 6, 8, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 212\n assert candidate(nextVisit = [0, 2, 1, 2, 3, 2, 1, 2, 3, 4]) == 430\n assert candidate(nextVisit = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0]) == 855298880\n assert candidate(nextVisit = [0, 2, 4, 6, 8, 0, 2, 4, 6, 8]) == 812\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 40\n assert candidate(nextVisit = [0, 2, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == 788\n assert candidate(nextVisit = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 512\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 640520038\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 147483632\n assert candidate(nextVisit = [0, 1, 2, 0, 3, 2, 5, 6, 7, 8, 9, 10, 0]) == 220\n assert candidate(nextVisit = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 590\n assert candidate(nextVisit = [0, 3, 2, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 38\n assert candidate(nextVisit = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 512\n assert candidate(nextVisit = [0, 1, 0, 1, 2, 3, 4, 5, 6, 7]) == 334\n"}, "metadata": {"canonical_parameter_names": ["nextVisit"], "leetcode_dataset_entry_point": "Solution().firstDayBeenInAllRooms", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def firstDayBeenInAllRooms(self, nextVisit: list[int]) -> int:", "container": "Solution", "callable": "firstDayBeenInAllRooms", "parameters": [{"name": "nextVisit", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1998, "task_id": "gcd-sort-of-an-array", "difficulty": "Hard", "problem_description": "You are given an integer array nums, and you can perform the following operation any number of times on nums:\n\nSwap the positions of two elements nums[i] and nums[j] if gcd(nums[i], nums[j]) > 1 where gcd(nums[i], nums[j]) is the greatest common divisor of nums[i] and nums[j].\n\nReturn true if it is possible to sort nums in non-decreasing order using the above swap method, or false otherwise.\n \nExample 1:\n\nInput: nums = [7,21,3]\nOutput: true\nExplanation: We can sort [7,21,3] by performing the following operations:\n- Swap 7 and 21 because gcd(7,21) = 7. nums = [21,7,3]\n- Swap 21 and 3 because gcd(21,3) = 3. nums = [3,7,21]\n\nExample 2:\n\nInput: nums = [5,2,6,2]\nOutput: false\nExplanation: It is impossible to sort the array because 5 cannot be swapped with any other element.\n\nExample 3:\n\nInput: nums = [10,5,9,3,15]\nOutput: true\nWe can sort [10,5,9,3,15] by performing the following operations:\n- Swap 10 and 15 because gcd(10,15) = 5. nums = [15,5,9,3,10]\n- Swap 15 and 3 because gcd(15,3) = 3. nums = [3,5,9,15,10]\n- Swap 10 and 15 because gcd(10,15) = 5. nums = [3,5,9,10,15]\n\n \nConstraints:\n\n1 <= nums.length <= 3 * 104\n2 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [12, 15, 18, 20, 25]) == True\n assert candidate(nums = [7, 21, 3]) == True\n assert candidate(nums = [8, 4, 12, 6]) == True\n assert candidate(nums = [2, 3, 5, 7, 11]) == True\n assert candidate(nums = [2, 4, 6, 8, 10]) == True\n assert candidate(nums = [1, 2, 3, 4]) == True\n assert candidate(nums = [18, 9, 27, 3, 6]) == True\n assert candidate(nums = [3, 9, 6, 18, 27]) == True\n assert candidate(nums = [1, 2, 3, 4, 5]) == True\n assert candidate(nums = [37, 49, 111, 143, 169]) == True\n assert candidate(nums = [100, 200, 400, 800, 1600]) == True\n assert candidate(nums = [22, 44, 11, 66, 33]) == True\n assert candidate(nums = [100, 200, 300, 400, 500]) == True\n assert candidate(nums = [83, 97, 101, 103, 107]) == True\n assert candidate(nums = [100000, 99998, 99999, 99997, 99996]) == False\n assert candidate(nums = [10, 5, 9, 3, 15]) == True\n assert candidate(nums = [105, 70, 30, 210, 42]) == True\n assert candidate(nums = [30, 42, 70, 105, 35]) == True\n assert candidate(nums = [5, 2, 6, 2]) == False\n assert candidate(nums = [56, 72, 88, 104, 120, 136, 152]) == True\n assert candidate(nums = [121, 132, 143, 154, 165, 176, 187, 198, 209]) == True\n assert candidate(nums = [48, 64, 80, 96, 112]) == True\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119]) == True\n assert candidate(nums = [210, 315, 420, 525, 630, 735]) == True\n assert candidate(nums = [105, 45, 63, 21, 315]) == True\n assert candidate(nums = [100, 50, 25, 125, 200, 150]) == True\n assert candidate(nums = [91, 182, 273, 364, 455]) == True\n assert candidate(nums = [121, 132, 143, 154, 165, 176]) == True\n assert candidate(nums = [16, 32, 48, 64, 80, 96, 112, 128, 144]) == True\n assert candidate(nums = [70, 35, 28, 56, 14, 18]) == True\n assert candidate(nums = [14, 21, 28, 35, 42, 49, 56, 63, 70]) == True\n assert candidate(nums = [32, 48, 64, 80, 96, 112]) == True\n assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310]) == True\n assert candidate(nums = [30, 25, 20, 15, 10, 5]) == True\n assert candidate(nums = [30, 45, 60, 75, 90, 105]) == True\n assert candidate(nums = [44, 55, 66, 77, 88, 99, 110, 121]) == True\n assert candidate(nums = [15, 20, 25, 30, 35]) == True\n assert candidate(nums = [33, 66, 99, 132, 165]) == True\n assert candidate(nums = [49, 14, 7, 98, 28]) == True\n assert candidate(nums = [6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189]) == True\n assert candidate(nums = [49, 42, 28, 35, 70]) == True\n assert candidate(nums = [123, 246, 369, 492, 615, 738, 861, 984]) == True\n assert candidate(nums = [84, 126, 168, 210, 252, 294, 336, 378, 420]) == True\n assert candidate(nums = [84, 28, 42, 70, 56]) == True\n assert candidate(nums = [101, 202, 303, 404, 505, 606]) == True\n assert candidate(nums = [56, 14, 28, 7, 98, 49]) == True\n assert candidate(nums = [45, 30, 60, 90, 120, 150]) == True\n assert candidate(nums = [100, 50, 75, 25, 150]) == True\n assert candidate(nums = [15, 25, 35, 45, 55, 65]) == True\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184]) == True\n assert candidate(nums = [121, 221, 143, 169, 13]) == True\n assert candidate(nums = [100, 200, 300, 400, 500]) == True\n assert candidate(nums = [462, 882, 924, 1092, 1260]) == True\n assert candidate(nums = [360, 720, 1080, 1440, 1800, 2160]) == True\n assert candidate(nums = [1000, 500, 250, 125, 625]) == True\n assert candidate(nums = [48, 120, 180, 240, 300]) == True\n assert candidate(nums = [16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240]) == True\n assert candidate(nums = [210, 70, 35, 14, 105]) == True\n assert candidate(nums = [1024, 2048, 512, 256, 128]) == True\n assert candidate(nums = [56, 112, 168, 224, 280]) == True\n assert candidate(nums = [100, 25, 50, 20, 40]) == True\n assert candidate(nums = [24, 36, 48, 12, 60]) == True\n assert candidate(nums = [99, 33, 66, 22, 11, 132]) == True\n assert candidate(nums = [21, 42, 63, 84, 105]) == True\n assert candidate(nums = [13, 26, 39, 52, 65, 78]) == True\n assert candidate(nums = [30, 45, 60, 75, 90]) == True\n assert candidate(nums = [77, 154, 231, 308, 385]) == True\n assert candidate(nums = [91, 130, 169, 182, 273, 338]) == True\n assert candidate(nums = [22, 15, 45, 33, 10, 55]) == True\n assert candidate(nums = [18, 27, 36, 45, 54, 63, 72, 81, 90]) == True\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == True\n assert candidate(nums = [171, 342, 513, 684, 855]) == True\n assert candidate(nums = [33, 55, 66, 88, 110, 121, 132, 143]) == True\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]) == True\n assert candidate(nums = [45, 90, 135, 180, 225]) == True\n assert candidate(nums = [20, 40, 60, 80, 100, 120, 140, 160, 180]) == True\n assert candidate(nums = [100, 50, 25, 20, 125]) == True\n assert candidate(nums = [18, 24, 30, 36, 42]) == True\n assert candidate(nums = [1000, 250, 500, 200, 750, 125, 375, 625, 875, 1250]) == True\n assert candidate(nums = [102, 136, 170, 204, 238, 272, 306, 340, 374]) == True\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190]) == True\n assert candidate(nums = [27, 54, 81, 108, 135, 162, 189, 216]) == True\n assert candidate(nums = [119, 238, 357, 476, 595]) == True\n assert candidate(nums = [81, 27, 54, 162, 324, 486]) == True\n assert candidate(nums = [84, 12, 14, 21, 63]) == True\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105]) == True\n assert candidate(nums = [18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108]) == True\n assert candidate(nums = [49, 63, 77, 91, 105, 119, 133, 147, 161, 175, 189, 203, 217]) == True\n assert candidate(nums = [72, 108, 144, 180, 216, 252, 288, 324, 360, 396]) == True\n assert candidate(nums = [225, 150, 100, 50, 25, 75]) == True\n assert candidate(nums = [121, 110, 99, 88, 77, 66, 55, 44, 33, 22, 11]) == True\n assert candidate(nums = [22, 44, 66, 88, 110, 132, 154, 176, 198]) == True\n assert candidate(nums = [1000, 500, 250, 125, 2000]) == True\n assert candidate(nums = [135, 90, 45, 60, 30]) == True\n assert candidate(nums = [9, 18, 27, 36, 45, 54]) == True\n assert candidate(nums = [17, 34, 51, 68, 85]) == True\n assert candidate(nums = [105, 15, 35, 21, 63]) == True\n assert candidate(nums = [81, 135, 207, 279, 351, 423]) == True\n assert candidate(nums = [36, 48, 60, 72, 84, 96]) == True\n assert candidate(nums = [180, 120, 90, 60, 45, 30, 20, 15, 10, 5]) == True\n assert candidate(nums = [28, 14, 42, 70, 98]) == True\n assert candidate(nums = [17, 19, 23, 29, 31, 37]) == True\n assert candidate(nums = [81, 27, 54, 108, 162]) == True\n assert candidate(nums = [121, 11, 22, 33, 44, 55]) == True\n assert candidate(nums = [165, 330, 495, 660, 825]) == True\n assert candidate(nums = [49, 98, 147, 196, 245]) == True\n assert candidate(nums = [121, 44, 88, 22, 176]) == True\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85]) == True\n assert candidate(nums = [100, 101, 102, 103, 104, 105]) == True\n assert candidate(nums = [17, 19, 23, 29, 31]) == True\n assert candidate(nums = [315, 105, 35, 7, 14, 21, 42, 63, 84]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == True\n assert candidate(nums = [13, 26, 39, 52, 65]) == True\n assert candidate(nums = [15, 25, 35, 45, 55]) == True\n assert candidate(nums = [7, 49, 343, 2401, 16807]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152]) == True\n assert candidate(nums = [14, 21, 35, 49, 70]) == True\n assert candidate(nums = [33, 66, 99, 132, 165, 198]) == True\n assert candidate(nums = [18, 24, 30, 36, 42, 48]) == True\n assert candidate(nums = [22, 44, 66, 88, 110]) == True\n assert candidate(nums = [84, 56, 28, 14, 7, 49, 35]) == True\n assert candidate(nums = [48, 64, 80, 96, 112, 128]) == True\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768]) == True\n assert candidate(nums = [56, 63, 70, 77, 84, 91]) == True\n assert candidate(nums = [99, 33, 66, 132, 264]) == True\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250]) == True\n assert candidate(nums = [77, 91, 143, 1001, 1001, 143]) == True\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700]) == True\n assert candidate(nums = [77, 55, 99, 110, 132]) == True\n assert candidate(nums = [30, 45, 60, 15, 90]) == True\n assert candidate(nums = [72, 24, 16, 8, 40]) == True\n assert candidate(nums = [42, 21, 7, 14, 28]) == True\n assert candidate(nums = [77, 143, 169, 187, 209, 221, 247, 299, 323, 341]) == True\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(nums = [121, 143, 169, 187, 209]) == True\n assert candidate(nums = [14, 21, 28, 35, 42, 49, 56, 63]) == True\n assert candidate(nums = [14, 21, 28, 35, 42, 49]) == True\n assert candidate(nums = [49, 147, 245, 343, 441, 539]) == True\n assert candidate(nums = [22, 15, 10, 18, 30]) == True\n assert candidate(nums = [64, 32, 16, 8, 4, 2, 1]) == False\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149]) == True\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81]) == True\n assert candidate(nums = [16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(nums = [102, 204, 306, 408, 510]) == True\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000]) == True\n assert candidate(nums = [60, 120, 180, 240, 300, 360]) == True\n assert candidate(nums = [42, 28, 70, 14, 35]) == True\n assert candidate(nums = [22, 33, 44, 55, 66]) == True\n assert candidate(nums = [77, 49, 35, 21, 14, 7]) == True\n assert candidate(nums = [23, 46, 69, 92, 115]) == True\n assert candidate(nums = [16, 8, 4, 2, 1]) == False\n assert candidate(nums = [101, 202, 303, 404, 505]) == True\n assert candidate(nums = [102, 68, 34, 17, 51, 85]) == True\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117]) == True\n assert candidate(nums = [100, 105, 140, 210, 70]) == True\n assert candidate(nums = [11, 22, 33, 44, 55, 66]) == True\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153]) == True\n assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192, 16384]) == True\n assert candidate(nums = [1000, 500, 250, 125, 2000, 10000, 2500]) == True\n assert candidate(nums = [30, 45, 60, 75, 90, 105, 120]) == True\n assert candidate(nums = [12, 18, 24, 30, 36, 42]) == True\n assert candidate(nums = [25, 45, 65, 85, 105]) == True\n assert candidate(nums = [100, 200, 150, 300, 250]) == True\n assert candidate(nums = [14, 28, 42, 56, 70]) == True\n assert candidate(nums = [81, 135, 225, 315, 405, 525, 675]) == True\n assert candidate(nums = [121, 132, 220, 110, 55]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().gcdSort", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def gcdSort(self, nums: list[int]) -> bool:", "container": "Solution", "callable": "gcdSort", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2000, "task_id": "reverse-prefix-of-word", "difficulty": "Easy", "problem_description": "Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing.\n\nFor example, if word = \"abcdefd\" and ch = \"d\", then you should reverse the segment that starts at 0 and ends at 3 (inclusive). The resulting string will be \"dcbaefd\".\n\nReturn the resulting string.\n \nExample 1:\n\nInput: word = \"abcdefd\", ch = \"d\"\nOutput: \"dcbaefd\"\nExplanation: The first occurrence of \"d\" is at index 3. \nReverse the part of word from 0 to 3 (inclusive), the resulting string is \"dcbaefd\".\n\nExample 2:\n\nInput: word = \"xyxzxe\", ch = \"z\"\nOutput: \"zxyxxe\"\nExplanation: The first and only occurrence of \"z\" is at index 3.\nReverse the part of word from 0 to 3 (inclusive), the resulting string is \"zxyxxe\".\n\nExample 3:\n\nInput: word = \"abcd\", ch = \"z\"\nOutput: \"abcd\"\nExplanation: \"z\" does not exist in word.\nYou should not do any reverse operation, the resulting string is \"abcd\".\n\n \nConstraints:\n\n1 <= word.length <= 250\nword consists of lowercase English letters.\nch is a lowercase English letter.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"abcdef\",ch = \"f\") == \"fedcba\"\n assert candidate(word = \"madam\",ch = \"d\") == \"damam\"\n assert candidate(word = \"abcdefd\",ch = \"d\") == \"dcbaefd\"\n assert candidate(word = \"abcd\",ch = \"z\") == \"abcd\"\n assert candidate(word = \"a\",ch = \"a\") == \"a\"\n assert candidate(word = \"python\",ch = \"y\") == \"ypthon\"\n assert candidate(word = \"operation\",ch = \"p\") == \"poeration\"\n assert candidate(word = \"xyxzxe\",ch = \"z\") == \"zxyxxe\"\n assert candidate(word = \"segment\",ch = \"t\") == \"tnemges\"\n assert candidate(word = \"hello\",ch = \"l\") == \"lehlo\"\n assert candidate(word = \"racecar\",ch = \"e\") == \"ecarcar\"\n assert candidate(word = \"abcdef\",ch = \"g\") == \"abcdef\"\n assert candidate(word = \"example\",ch = \"m\") == \"maxeple\"\n assert candidate(word = \"reverse\",ch = \"r\") == \"reverse\"\n assert candidate(word = \"abcdef\",ch = \"a\") == \"abcdef\"\n assert candidate(word = \"supercalifragilisticexpialidocious\",ch = \"x\") == \"xecitsiligarfilacrepuspialidocious\"\n assert candidate(word = \"abracadabra\",ch = \"r\") == \"rbaacadabra\"\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\",ch = \"a\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(word = \"\",ch = \"a\") == \"\"\n assert candidate(word = \"unbelievable\",ch = \"e\") == \"ebnulievable\"\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",ch = \"m\") == \"mlkjihgfedcbanopqrstuvwxyz\"\n assert candidate(word = \"supercalifragilisticexpialidocious\",ch = \"c\") == \"crepusalifragilisticexpialidocious\"\n assert candidate(word = \"interview\",ch = \"w\") == \"weivretni\"\n assert candidate(word = \"unpredictable\",ch = \"d\") == \"derpnuictable\"\n assert candidate(word = \"beautifulization\",ch = \"z\") == \"zilufituaebation\"\n assert candidate(word = \"characterization\",ch = \"c\") == \"characterization\"\n assert candidate(word = \"communication\",ch = \"m\") == \"mocmunication\"\n assert candidate(word = \"reversethispart\",ch = \"e\") == \"erversethispart\"\n assert candidate(word = \"reinforce\",ch = \"e\") == \"erinforce\"\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\",ch = \"q\") == \"qrstuvwxyzponmlkjihgfedcba\"\n assert candidate(word = \"unbelievable\",ch = \"l\") == \"lebnuievable\"\n assert candidate(word = \"nothingtoreverse\",ch = \"x\") == \"nothingtoreverse\"\n assert candidate(word = \"characterization\",ch = \"a\") == \"ahcracterization\"\n assert candidate(word = \"quickbrownfox\",ch = \"o\") == \"orbkciuqwnfox\"\n assert candidate(word = \"banana\",ch = \"n\") == \"nabana\"\n assert candidate(word = \"qwertyuiop\",ch = \"p\") == \"poiuytrewq\"\n assert candidate(word = \"qwertyuiop\",ch = \"q\") == \"qwertyuiop\"\n assert candidate(word = \"boundary\",ch = \"d\") == \"dnuobary\"\n assert candidate(word = \"continuous\",ch = \"s\") == \"suounitnoc\"\n assert candidate(word = \"interoperability\",ch = \"i\") == \"interoperability\"\n assert candidate(word = \"aaaaaa\",ch = \"a\") == \"aaaaaa\"\n assert candidate(word = \"quizzically\",ch = \"q\") == \"quizzically\"\n assert candidate(word = \"congratulations\",ch = \"g\") == \"gnocratulations\"\n assert candidate(word = \"aabbccddeeff\",ch = \"f\") == \"feeddccbbaaf\"\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\",ch = \"m\") == \"mnopqrstuvwxyzlkjihgfedcba\"\n assert candidate(word = \"concatenation\",ch = \"c\") == \"concatenation\"\n assert candidate(word = \"implementation\",ch = \"i\") == \"implementation\"\n assert candidate(word = \"establishment\",ch = \"b\") == \"batselishment\"\n assert candidate(word = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllll\",ch = \"l\") == \"lkjihgfedcballlllllllllllllllllllllllllllllllllllllllllllll\"\n assert candidate(word = \"abcdefg\",ch = \"g\") == \"gfedcba\"\n assert candidate(word = \"development\",ch = \"p\") == \"polevedment\"\n assert candidate(word = \"unfortunately\",ch = \"r\") == \"rofnutunately\"\n assert candidate(word = \"challenges\",ch = \"e\") == \"ellahcnges\"\n assert candidate(word = \"thisisaverylongwordthatneedstoreversed\",ch = \"n\") == \"nolyrevasisihtgwordthatneedstoreversed\"\n assert candidate(word = \"interview\",ch = \"e\") == \"etnirview\"\n assert candidate(word = \"abcdeffedcba\",ch = \"f\") == \"fedcbafedcba\"\n assert candidate(word = \"classification\",ch = \"l\") == \"lcassification\"\n assert candidate(word = \"thisisateststring\",ch = \"t\") == \"thisisateststring\"\n assert candidate(word = \"mississippi\",ch = \"i\") == \"imssissippi\"\n assert candidate(word = \"unbelievable\",ch = \"b\") == \"bnuelievable\"\n assert candidate(word = \"mississippi\",ch = \"s\") == \"simsissippi\"\n assert candidate(word = \"congratulations\",ch = \"l\") == \"lutargnocations\"\n assert candidate(word = \"synchronous\",ch = \"c\") == \"cnyshronous\"\n assert candidate(word = \"algorithm\",ch = \"l\") == \"lagorithm\"\n assert candidate(word = \"abracadabra\",ch = \"c\") == \"carbaadabra\"\n assert candidate(word = \"zzzzzzzzzzzzzzzz\",ch = \"z\") == \"zzzzzzzzzzzzzzzz\"\n assert candidate(word = \"development\",ch = \"l\") == \"levedopment\"\n assert candidate(word = \"identification\",ch = \"i\") == \"identification\"\n assert candidate(word = \"beautiful\",ch = \"t\") == \"tuaebiful\"\n assert candidate(word = \"asdfghjklzxcvbnm\",ch = \"m\") == \"mnbvcxzlkjhgfdsa\"\n assert candidate(word = \"representation\",ch = \"r\") == \"representation\"\n assert candidate(word = \"congratulations\",ch = \"t\") == \"targnoculations\"\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",ch = \"q\") == \"qppoonnmmllkkjjiihhggffeeddccbbaaqrrssttuuvvwwxxyyzz\"\n assert candidate(word = \"sequence\",ch = \"q\") == \"qesuence\"\n assert candidate(word = \"environment\",ch = \"v\") == \"vneironment\"\n assert candidate(word = \"algorithm\",ch = \"g\") == \"glaorithm\"\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",ch = \"z\") == \"zyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaaz\"\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",ch = \"z\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(word = \"abcdefghij\",ch = \"e\") == \"edcbafghij\"\n assert candidate(word = \"solution\",ch = \"u\") == \"ulostion\"\n assert candidate(word = \"environment\",ch = \"n\") == \"nevironment\"\n assert candidate(word = \"environmentally\",ch = \"v\") == \"vneironmentally\"\n assert candidate(word = \"algorithm\",ch = \"o\") == \"oglarithm\"\n assert candidate(word = \"single\",ch = \"l\") == \"lgnise\"\n assert candidate(word = \"supercalifragilisticexpialidocious\",ch = \"f\") == \"filacrepusragilisticexpialidocious\"\n assert candidate(word = \"abcdefg\",ch = \"z\") == \"abcdefg\"\n assert candidate(word = \"double\",ch = \"x\") == \"double\"\n assert candidate(word = \"algorithms\",ch = \"a\") == \"algorithms\"\n assert candidate(word = \"algorithm\",ch = \"r\") == \"roglaithm\"\n assert candidate(word = \"characterization\",ch = \"h\") == \"hcaracterization\"\n assert candidate(word = \"xyzzyx\",ch = \"z\") == \"zyxzyx\"\n assert candidate(word = \"subsequence\",ch = \"q\") == \"qesbusuence\"\n assert candidate(word = \"reversal\",ch = \"a\") == \"asreverl\"\n assert candidate(word = \"a\",ch = \"b\") == \"a\"\n assert candidate(word = \"visualization\",ch = \"i\") == \"ivsualization\"\n assert candidate(word = \"incomprehensible\",ch = \"h\") == \"herpmocniensible\"\n assert candidate(word = \"hellothere\",ch = \"e\") == \"ehllothere\"\n assert candidate(word = \"reverseprefix\",ch = \"r\") == \"reverseprefix\"\n assert candidate(word = \"pneumonoultramicroscopicsilicovolcanoconiosis\",ch = \"o\") == \"omuenpnoultramicroscopicsilicovolcanoconiosis\"\n assert candidate(word = \"uniquecharacters\",ch = \"u\") == \"uniquecharacters\"\n assert candidate(word = \"alphabetization\",ch = \"b\") == \"bahplaetization\"\n assert candidate(word = \"standardization\",ch = \"i\") == \"idradnatszation\"\n assert candidate(word = \"automation\",ch = \"o\") == \"otuamation\"\n assert candidate(word = \"mnopqr\",ch = \"r\") == \"rqponm\"\n assert candidate(word = \"pronunciation\",ch = \"u\") == \"unorpnciation\"\n assert candidate(word = \"abacaxa\",ch = \"a\") == \"abacaxa\"\n assert candidate(word = \"reversal\",ch = \"r\") == \"reversal\"\n assert candidate(word = \"congratulations\",ch = \"u\") == \"utargnoclations\"\n assert candidate(word = \"performance\",ch = \"f\") == \"frepormance\"\n assert candidate(word = \"nevertheless\",ch = \"n\") == \"nevertheless\"\n assert candidate(word = \"multifaceted\",ch = \"f\") == \"fitlumaceted\"\n assert candidate(word = \"reversal\",ch = \"v\") == \"verersal\"\n assert candidate(word = \"thisisaverylongwordthatshouldtestthelimitsofthefunction\",ch = \"t\") == \"thisisaverylongwordthatshouldtestthelimitsofthefunction\"\n assert candidate(word = \"sophistication\",ch = \"s\") == \"sophistication\"\n assert candidate(word = \"xylophone\",ch = \"o\") == \"olyxphone\"\n assert candidate(word = \"visualization\",ch = \"z\") == \"zilausivation\"\n assert candidate(word = \"pneumonoultramicroscopicsilicovolcanoconiosis\",ch = \"u\") == \"uenpmonoultramicroscopicsilicovolcanoconiosis\"\n assert candidate(word = \"xyzxyzxyz\",ch = \"x\") == \"xyzxyzxyz\"\n assert candidate(word = \"challenge\",ch = \"e\") == \"ellahcnge\"\n assert candidate(word = \"perseverance\",ch = \"v\") == \"vesreperance\"\n assert candidate(word = \"abcdefghijk\",ch = \"i\") == \"ihgfedcbajk\"\n assert candidate(word = \"mississippi\",ch = \"p\") == \"pississimpi\"\n assert candidate(word = \"programming\",ch = \"g\") == \"gorpramming\"\n assert candidate(word = \"responsibilities\",ch = \"s\") == \"serponsibilities\"\n assert candidate(word = \"synchronization\",ch = \"n\") == \"nyschronization\"\n assert candidate(word = \"floccinaucinihilipilification\",ch = \"f\") == \"floccinaucinihilipilification\"\n assert candidate(word = \"operationalization\",ch = \"o\") == \"operationalization\"\n assert candidate(word = \"specializations\",ch = \"a\") == \"aicepslizations\"\n assert candidate(word = \"optimization\",ch = \"t\") == \"tpoimization\"\n assert candidate(word = \"abcdefghijk\",ch = \"h\") == \"hgfedcbaijk\"\n assert candidate(word = \"xylophone\",ch = \"p\") == \"polyxhone\"\n assert candidate(word = \"hellohellohello\",ch = \"l\") == \"lehlohellohello\"\n assert candidate(word = \"concatenation\",ch = \"n\") == \"noccatenation\"\n"}, "metadata": {"canonical_parameter_names": ["word", "ch"], "leetcode_dataset_entry_point": "Solution().reversePrefix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def reversePrefix(self, word: str, ch: str) -> str:", "container": "Solution", "callable": "reversePrefix", "parameters": [{"name": "word", "type": "str"}, {"name": "ch", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2001, "task_id": "number-of-pairs-of-interchangeable-rectangles", "difficulty": "Medium", "problem_description": "You are given n rectangles represented by a 0-indexed 2D integer array rectangles, where rectangles[i] = [widthi, heighti] denotes the width and height of the ith rectangle.\nTwo rectangles i and j (i < j) are considered interchangeable if they have the same width-to-height ratio. More formally, two rectangles are interchangeable if widthi/heighti == widthj/heightj (using decimal division, not integer division).\nReturn the number of pairs of interchangeable rectangles in rectangles.\n \nExample 1:\n\nInput: rectangles = [[4,8],[3,6],[10,20],[15,30]]\nOutput: 6\nExplanation: The following are the interchangeable pairs of rectangles by index (0-indexed):\n- Rectangle 0 with rectangle 1: 4/8 == 3/6.\n- Rectangle 0 with rectangle 2: 4/8 == 10/20.\n- Rectangle 0 with rectangle 3: 4/8 == 15/30.\n- Rectangle 1 with rectangle 2: 3/6 == 10/20.\n- Rectangle 1 with rectangle 3: 3/6 == 15/30.\n- Rectangle 2 with rectangle 3: 10/20 == 15/30.\n\nExample 2:\n\nInput: rectangles = [[4,5],[7,8]]\nOutput: 0\nExplanation: There are no interchangeable pairs of rectangles.\n\n \nConstraints:\n\nn == rectangles.length\n1 <= n <= 105\nrectangles[i].length == 2\n1 <= widthi, heighti <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 10\n assert candidate(rectangles = [[5, 10], [10, 20], [20, 40], [40, 80]]) == 6\n assert candidate(rectangles = [[2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(rectangles = [[4, 5], [7, 8]]) == 0\n assert candidate(rectangles = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50]]) == 10\n assert candidate(rectangles = [[5, 10], [10, 20], [15, 30], [20, 40]]) == 6\n assert candidate(rectangles = [[4, 8], [3, 6], [10, 20], [15, 30]]) == 6\n assert candidate(rectangles = [[1, 2], [2, 4], [3, 6], [4, 8]]) == 6\n assert candidate(rectangles = [[2, 3], [3, 4], [4, 6], [6, 9]]) == 3\n assert candidate(rectangles = [[2, 3], [3, 2], [6, 9], [9, 6]]) == 2\n assert candidate(rectangles = [[10, 5], [5, 10], [20, 10], [10, 20], [30, 15]]) == 4\n assert candidate(rectangles = [[1, 2], [2, 4], [4, 8], [8, 16]]) == 6\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 45\n assert candidate(rectangles = [[2, 4], [4, 8], [8, 16], [16, 32], [32, 64], [64, 128]]) == 15\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]]) == 66\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]]) == 55\n assert candidate(rectangles = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]]) == 45\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15]]) == 10\n assert candidate(rectangles = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90], [50, 100]]) == 45\n assert candidate(rectangles = [[7, 10], [14, 20], [21, 30], [28, 40], [35, 50], [42, 60], [49, 70], [56, 80], [63, 90], [70, 100], [77, 110], [84, 120]]) == 66\n assert candidate(rectangles = [[10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90]]) == 28\n assert candidate(rectangles = [[100, 200], [150, 300], [200, 400], [250, 500], [300, 600], [350, 700], [400, 800], [450, 900], [500, 1000]]) == 36\n assert candidate(rectangles = [[2, 5], [4, 10], [6, 15], [8, 20], [10, 25], [12, 30], [14, 35], [16, 40], [18, 45], [20, 50]]) == 45\n assert candidate(rectangles = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20], [11, 22], [12, 24]]) == 66\n assert candidate(rectangles = [[100, 200], [200, 400], [300, 600], [400, 800], [500, 1000], [600, 1200], [700, 1400], [800, 1600], [900, 1800], [1000, 2000]]) == 45\n assert candidate(rectangles = [[3, 9], [6, 18], [9, 27], [12, 36], [15, 45], [18, 54], [21, 63], [24, 72], [27, 81], [30, 90]]) == 45\n assert candidate(rectangles = [[1000, 2000], [1500, 3000], [2000, 4000], [2500, 5000], [3000, 6000], [3500, 7000], [4000, 8000], [4500, 9000], [5000, 10000]]) == 36\n assert candidate(rectangles = [[1, 1], [1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2], [1, 4], [4, 1], [2, 4], [4, 2], [3, 4], [4, 3]]) == 2\n assert candidate(rectangles = [[10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90], [50, 100]]) == 36\n assert candidate(rectangles = [[10, 5], [5, 10], [2, 1], [1, 2], [4, 2], [2, 4], [8, 4], [4, 8], [16, 8], [8, 16]]) == 20\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27], [10, 30], [11, 33], [12, 36], [13, 39]]) == 78\n assert candidate(rectangles = [[3, 4], [6, 8], [9, 12], [12, 16], [15, 20], [18, 24], [21, 28], [24, 32]]) == 28\n assert candidate(rectangles = [[5, 15], [10, 30], [15, 45], [20, 60], [25, 75]]) == 10\n assert candidate(rectangles = [[3, 9], [9, 27], [27, 81], [81, 243], [243, 729]]) == 10\n assert candidate(rectangles = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20], [11, 22], [12, 24], [13, 26], [14, 28], [15, 30]]) == 105\n assert candidate(rectangles = [[10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90], [50, 100], [55, 110]]) == 45\n assert candidate(rectangles = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == 0\n assert candidate(rectangles = [[1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2], [1, 4], [4, 1], [2, 4], [4, 2]]) == 2\n assert candidate(rectangles = [[5, 15], [10, 30], [15, 45], [20, 60], [25, 75], [30, 90], [35, 105], [40, 120]]) == 28\n assert candidate(rectangles = [[1, 100000], [2, 50000], [3, 33333], [4, 25000], [5, 20000], [6, 16667], [7, 14286], [8, 12500], [9, 11111], [10, 10000]]) == 0\n assert candidate(rectangles = [[2, 3], [4, 6], [6, 9], [8, 12], [10, 15], [12, 18], [14, 21], [16, 24], [18, 27], [20, 30]]) == 45\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27], [10, 30]]) == 45\n assert candidate(rectangles = [[2, 4], [4, 8], [8, 16], [16, 32], [32, 64], [64, 128], [128, 256], [256, 512], [512, 1024], [1024, 2048]]) == 45\n assert candidate(rectangles = [[5, 4], [10, 8], [15, 12], [20, 16], [25, 20], [30, 24], [35, 28], [40, 32], [45, 36], [50, 40]]) == 45\n assert candidate(rectangles = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 110], [12, 120], [13, 130], [14, 140], [15, 150]]) == 105\n assert candidate(rectangles = [[11, 22], [22, 44], [33, 66], [44, 88], [55, 110], [66, 132], [77, 154], [88, 176]]) == 28\n assert candidate(rectangles = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]]) == 45\n assert candidate(rectangles = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]]) == 45\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 105\n assert candidate(rectangles = [[1, 4], [2, 8], [3, 12], [4, 16], [5, 20], [6, 24], [7, 28], [8, 32], [9, 36], [10, 40]]) == 45\n assert candidate(rectangles = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 0\n assert candidate(rectangles = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]]) == 45\n assert candidate(rectangles = [[1, 100000], [2, 200000], [3, 300000], [4, 400000], [5, 500000], [6, 600000], [7, 700000], [8, 800000], [9, 900000], [10, 1000000]]) == 45\n assert candidate(rectangles = [[3, 4], [6, 8], [9, 12], [12, 16], [15, 20], [18, 24], [21, 28], [24, 32], [27, 36], [30, 40]]) == 45\n assert candidate(rectangles = [[3, 5], [6, 10], [9, 15], [12, 20], [15, 25], [18, 30]]) == 15\n assert candidate(rectangles = [[8, 12], [16, 24], [24, 36], [32, 48], [40, 60], [48, 72], [56, 84], [64, 96]]) == 28\n assert candidate(rectangles = [[100, 200], [200, 400], [300, 600], [400, 800], [500, 1000], [600, 1200]]) == 15\n assert candidate(rectangles = [[2, 1], [4, 2], [6, 3], [8, 4], [10, 5], [12, 6], [14, 7], [16, 8], [18, 9], [20, 10]]) == 45\n assert candidate(rectangles = [[100, 200], [200, 400], [300, 600], [400, 800], [500, 1000]]) == 10\n assert candidate(rectangles = [[3, 7], [6, 14], [9, 21], [12, 28], [15, 35], [18, 42], [21, 49], [24, 56], [27, 63], [30, 70]]) == 45\n assert candidate(rectangles = [[100000, 1], [200000, 2], [300000, 3], [400000, 4], [500000, 5], [600000, 6], [700000, 7], [800000, 8], [900000, 9], [1000000, 10]]) == 45\n assert candidate(rectangles = [[3, 9], [1, 3], [2, 6], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24]]) == 28\n assert candidate(rectangles = [[7, 14], [14, 28], [28, 56], [56, 112], [112, 224], [224, 448]]) == 15\n assert candidate(rectangles = [[3, 5], [6, 10], [9, 15], [12, 20], [15, 25], [18, 30], [21, 35], [24, 40], [27, 45], [30, 50]]) == 45\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21]]) == 21\n assert candidate(rectangles = [[7, 14], [14, 28], [21, 42], [28, 56], [35, 70], [42, 84]]) == 15\n assert candidate(rectangles = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 0\n assert candidate(rectangles = [[1, 1], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 0\n assert candidate(rectangles = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11]]) == 0\n assert candidate(rectangles = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 45\n assert candidate(rectangles = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9], [1000, 10]]) == 45\n assert candidate(rectangles = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]]) == 45\n assert candidate(rectangles = [[100000, 1], [1, 100000], [50000, 2], [2, 50000], [1, 1], [1, 2], [2, 1]]) == 0\n assert candidate(rectangles = [[1, 5], [2, 10], [3, 15], [4, 20], [5, 25], [6, 30], [7, 35], [8, 40], [9, 45], [10, 50], [11, 55], [12, 60]]) == 66\n assert candidate(rectangles = [[7, 14], [14, 28], [21, 42], [28, 56], [35, 70], [42, 84], [49, 98]]) == 21\n assert candidate(rectangles = [[3, 1], [6, 2], [9, 3], [12, 4], [15, 5], [18, 6], [21, 7], [24, 8], [27, 9], [30, 10]]) == 45\n assert candidate(rectangles = [[3, 4], [6, 8], [9, 12], [12, 16], [15, 20], [18, 24], [21, 28]]) == 21\n assert candidate(rectangles = [[1, 2], [2, 4], [4, 8], [8, 16], [16, 32], [32, 64], [64, 128], [128, 256], [256, 512], [512, 1024]]) == 45\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27], [10, 30], [11, 33], [12, 36]]) == 66\n assert candidate(rectangles = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90], [50, 100], [55, 110], [60, 120]]) == 66\n assert candidate(rectangles = [[7, 14], [14, 28], [21, 42], [28, 56], [35, 70], [42, 84], [49, 98], [56, 112]]) == 28\n assert candidate(rectangles = [[1, 2], [1, 3], [2, 4], [2, 6], [3, 6], [3, 9], [4, 8], [4, 12], [5, 10], [5, 15]]) == 20\n assert candidate(rectangles = [[5, 10], [15, 30], [25, 50], [35, 70], [45, 90], [55, 110], [65, 130], [75, 150], [85, 170], [95, 190]]) == 45\n assert candidate(rectangles = [[5, 7], [10, 14], [15, 21], [20, 28], [25, 35], [30, 42], [35, 49], [40, 56]]) == 28\n"}, "metadata": {"canonical_parameter_names": ["rectangles"], "leetcode_dataset_entry_point": "Solution().interchangeableRectangles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def interchangeableRectangles(self, rectangles: list[list[int]]) -> int:", "container": "Solution", "callable": "interchangeableRectangles", "parameters": [{"name": "rectangles", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2002, "task_id": "maximum-product-of-the-length-of-two-palindromic-subsequences", "difficulty": "Medium", "problem_description": "Given a string s, find two disjoint palindromic subsequences of s such that the product of their lengths is maximized. The two subsequences are disjoint if they do not both pick a character at the same index.\nReturn the maximum possible product of the lengths of the two palindromic subsequences.\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters. A string is palindromic if it reads the same forward and backward.\n \nExample 1:\n\n\nInput: s = \"leetcodecom\"\nOutput: 9\nExplanation: An optimal solution is to choose \"ete\" for the 1st subsequence and \"cdc\" for the 2nd subsequence.\nThe product of their lengths is: 3 * 3 = 9.\n\nExample 2:\n\nInput: s = \"bb\"\nOutput: 1\nExplanation: An optimal solution is to choose \"b\" (the first character) for the 1st subsequence and \"b\" (the second character) for the 2nd subsequence.\nThe product of their lengths is: 1 * 1 = 1.\n\nExample 3:\n\nInput: s = \"accbcaxxcxx\"\nOutput: 25\nExplanation: An optimal solution is to choose \"accca\" for the 1st subsequence and \"xxcxx\" for the 2nd subsequence.\nThe product of their lengths is: 5 * 5 = 25.\n\n \nConstraints:\n\n2 <= s.length <= 12\ns consists of lowercase English letters only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"xyzyx\") == 6\n assert candidate(s = \"aabbcc\") == 4\n assert candidate(s = \"aaaa\") == 4\n assert candidate(s = \"accbcaxxcxx\") == 25\n assert candidate(s = \"madam\") == 6\n assert candidate(s = \"noon\") == 4\n assert candidate(s = \"racecar\") == 12\n assert candidate(s = \"deified\") == 12\n assert candidate(s = \"noonhighnoon\") == 35\n assert candidate(s = \"abcdcba\") == 12\n assert candidate(s = \"abacaba\") == 12\n assert candidate(s = \"level\") == 6\n assert candidate(s = \"abcdedcba\") == 20\n assert candidate(s = \"abcde\") == 1\n assert candidate(s = \"rotor\") == 6\n assert candidate(s = \"leetcodecom\") == 9\n assert candidate(s = \"bb\") == 1\n assert candidate(s = \"refer\") == 6\n assert candidate(s = \"palindromeabcdcba\") == 20\n assert candidate(s = \"aaabbbccc\") == 9\n assert candidate(s = \"xxyyzzxxyyzz\") == 36\n assert candidate(s = \"noonnoonnoon\") == 36\n assert candidate(s = \"repaper\") == 12\n assert candidate(s = \"abbaabbaabba\") == 36\n assert candidate(s = \"xyzzyxzyxz\") == 25\n assert candidate(s = \"aababababab\") == 30\n assert candidate(s = \"xyzyzyzyzyzy\") == 30\n assert candidate(s = \"racecarlevelmadam\") == 45\n assert candidate(s = \"aabbbbaa\") == 16\n assert candidate(s = \"abababa\") == 12\n assert candidate(s = \"babadab\") == 9\n assert candidate(s = \"referrefer\") == 25\n assert candidate(s = \"rotorrotor\") == 25\n assert candidate(s = \"abracadabra\") == 25\n assert candidate(s = \"abacdfgdcaba\") == 35\n assert candidate(s = \"mammam\") == 9\n assert candidate(s = \"noonbedalabamoon\") == 35\n assert candidate(s = \"levelonelevel\") == 35\n assert candidate(s = \"abccbaabcba\") == 30\n assert candidate(s = \"redderredder\") == 36\n assert candidate(s = \"redivider\") == 20\n assert candidate(s = \"zzzyzzyyzzyzz\") == 42\n assert candidate(s = \"racecarabc\") == 15\n assert candidate(s = \"noonabbadammadam\") == 32\n assert candidate(s = \"noonnoon\") == 16\n assert candidate(s = \"abcdzdcba\") == 20\n assert candidate(s = \"abcdefghihgfedcba\") == 72\n assert candidate(s = \"levelup\") == 6\n assert candidate(s = \"rotorositor\") == 25\n assert candidate(s = \"madamracecarmadam\") == 72\n assert candidate(s = \"abcddcbaabcddcba\") == 64\n assert candidate(s = \"abcdefgfedcba\") == 42\n assert candidate(s = \"zyxzyxzyxzyxzyx\") == 49\n assert candidate(s = \"zzzzzzzzzzzz\") == 36\n assert candidate(s = \"xyzyxzyzyx\") == 25\n assert candidate(s = \"deeee\") == 4\n assert candidate(s = \"noonappaloopnoon\") == 56\n assert candidate(s = \"abcabcabcabcabcabc\") == 81\n assert candidate(s = \"abcbaabcba\") == 25\n assert candidate(s = \"aabbbaaaabbbb\") == 42\n assert candidate(s = \"aabbccddeeffgg\") == 4\n assert candidate(s = \"aabbccddeeefff\") == 9\n assert candidate(s = \"deeeevee\") == 12\n assert candidate(s = \"aaabaaa\") == 12\n assert candidate(s = \"aabbccddeeff\") == 4\n assert candidate(s = \"levellevel\") == 25\n assert candidate(s = \"madamimadam\") == 30\n assert candidate(s = \"mississippi\") == 24\n assert candidate(s = \"madamatadammadamada\") == 81\n assert candidate(s = \"xyzzazxy\") == 15\n assert candidate(s = \"xyxxyxyxyxyx\") == 35\n assert candidate(s = \"levelracecarlevel\") == 72\n assert candidate(s = \"programming\") == 12\n assert candidate(s = \"zyxzyxzyxzyx\") == 36\n assert candidate(s = \"levelracecara\") == 35\n assert candidate(s = \"zzzzzyzzzz\") == 25\n assert candidate(s = \"racecarannakayak\") == 40\n assert candidate(s = \"aabbaabbaa\") == 25\n assert candidate(s = \"xyzabcdcba\") == 12\n assert candidate(s = \"optimization\") == 15\n assert candidate(s = \"abccbaabc\") == 15\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxProduct(self, s: str) -> int:", "container": "Solution", "callable": "maxProduct", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2003, "task_id": "smallest-missing-genetic-value-in-each-subtree", "difficulty": "Hard", "problem_description": "There is a family tree rooted at 0 consisting of n nodes numbered 0 to n - 1. You are given a 0-indexed integer array parents, where parents[i] is the parent for node i. Since node 0 is the root, parents[0] == -1.\nThere are 105 genetic values, each represented by an integer in the inclusive range [1, 105]. You are given a 0-indexed integer array nums, where nums[i] is a distinct genetic value for node i.\nReturn an array ans of length n where ans[i] is the smallest genetic value that is missing from the subtree rooted at node i.\nThe subtree rooted at a node x contains node x and all of its descendant nodes.\n \nExample 1:\n\n\nInput: parents = [-1,0,0,2], nums = [1,2,3,4]\nOutput: [5,1,1,1]\nExplanation: The answer for each subtree is calculated as follows:\n- 0: The subtree contains nodes [0,1,2,3] with values [1,2,3,4]. 5 is the smallest missing value.\n- 1: The subtree contains only node 1 with value 2. 1 is the smallest missing value.\n- 2: The subtree contains nodes [2,3] with values [3,4]. 1 is the smallest missing value.\n- 3: The subtree contains only node 3 with value 4. 1 is the smallest missing value.\n\nExample 2:\n\n\nInput: parents = [-1,0,1,0,3,3], nums = [5,4,6,2,1,3]\nOutput: [7,1,1,4,2,1]\nExplanation: The answer for each subtree is calculated as follows:\n- 0: The subtree contains nodes [0,1,2,3,4,5] with values [5,4,6,2,1,3]. 7 is the smallest missing value.\n- 1: The subtree contains nodes [1,2] with values [4,6]. 1 is the smallest missing value.\n- 2: The subtree contains only node 2 with value 6. 1 is the smallest missing value.\n- 3: The subtree contains nodes [3,4,5] with values [2,1,3]. 4 is the smallest missing value.\n- 4: The subtree contains only node 4 with value 1. 2 is the smallest missing value.\n- 5: The subtree contains only node 5 with value 3. 1 is the smallest missing value.\n\nExample 3:\n\nInput: parents = [-1,2,3,0,2,4,1], nums = [2,3,4,5,6,7,8]\nOutput: [1,1,1,1,1,1,1]\nExplanation: The value 1 is missing from all the subtrees.\n\n \nConstraints:\n\nn == parents.length == nums.length\n2 <= n <= 105\n0 <= parents[i] <= n - 1 for i != 0\nparents[0] == -1\nparents represents a valid tree.\n1 <= nums[i] <= 105\nEach nums[i] is distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(parents = [-1, 0, 0, 2],nums = [1, 2, 3, 4]) == [5, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 0, 3, 3],nums = [5, 4, 6, 2, 1, 3]) == [7, 1, 1, 4, 2, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2],nums = [1, 2, 3, 4, 5, 6, 7]) == [8, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 2, 3, 0, 2, 4, 1],nums = [2, 3, 4, 5, 6, 7, 8]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3],nums = [7, 1, 3, 2, 6, 5, 4]) == [8, 2, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],nums = [5, 1, 12, 13, 1, 2, 6, 7, 8, 9, 3, 4, 10, 11, 14, 15]) == [16, 5, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3],nums = [10, 1, 2, 9, 8, 7, 6, 5, 4]) == [3, 2, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == [19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 0, 6, 7, 8],nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [10, 6, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [11, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4],nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == [12, 4, 1, 1, 2, 1, 1, 1, 1, 2, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [11, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums = [5, 1, 3, 7, 9, 2, 6, 4, 8, 10, 11]) == [12, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],nums = [2, 1, 14, 13, 8, 15, 6, 9, 4, 10, 5, 11, 3, 12, 7, 16]) == [17, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 3, 1, 3, 1, 1, 1, 1, 2]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [23, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 0, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],nums = [20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [21, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4],nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 101]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums = [10, 20, 30, 40, 1, 11, 21, 31, 41, 2, 12, 22, 32, 42, 3, 13, 23, 33, 4, 14, 24, 29]) == [5, 5, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == [23, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums = [40, 30, 20, 10, 35, 31, 25, 21, 34, 32, 24, 22, 33, 26, 23, 27, 36, 28, 29, 37, 38, 39]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 3, 3, 4, 4],nums = [1, 2, 3, 4, 5, 6, 7, 8]) == [9, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums = [10, 9, 1, 2, 3, 4, 5, 6, 7, 8, 15, 16, 17, 18, 19, 20]) == [11, 10, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],nums = [3, 1, 2, 5, 7, 8, 10, 12, 13, 9, 4, 6, 11, 14, 15, 16, 17, 18, 19, 20, 21]) == [22, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13]) == [14, 4, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30],nums = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == [12, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [44, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3],nums = [13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [14, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == [36, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 22]) == [23, 2, 2, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3],nums = [8, 9, 10, 1, 2, 3, 4, 5, 6]) == [7, 3, 1, 2, 1, 1, 1, 1, 1]\n"}, "metadata": {"canonical_parameter_names": ["parents", "nums"], "leetcode_dataset_entry_point": "Solution().smallestMissingValueSubtree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def smallestMissingValueSubtree(self, parents: list[int], nums: list[int]) -> list[int]:", "container": "Solution", "callable": "smallestMissingValueSubtree", "parameters": [{"name": "parents", "type": "list[int]"}, {"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2006, "task_id": "count-number-of-pairs-with-absolute-difference-k", "difficulty": "Easy", "problem_description": "Given an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] - nums[j]| == k.\nThe value of |x| is defined as:\n\nx if x >= 0.\n-x if x < 0.\n\n \nExample 1:\n\nInput: nums = [1,2,2,1], k = 1\nOutput: 4\nExplanation: The pairs with an absolute difference of 1 are:\n- [1,2,2,1]\n- [1,2,2,1]\n- [1,2,2,1]\n- [1,2,2,1]\n\nExample 2:\n\nInput: nums = [1,3], k = 3\nOutput: 0\nExplanation: There are no pairs with an absolute difference of 3.\n\nExample 3:\n\nInput: nums = [3,2,1,5,4], k = 2\nOutput: 3\nExplanation: The pairs with an absolute difference of 2 are:\n- [3,2,1,5,4]\n- [3,2,1,5,4]\n- [3,2,1,5,4]\n\n \nConstraints:\n\n1 <= nums.length <= 200\n1 <= nums[i] <= 100\n1 <= k <= 99\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 1, 100, 1, 100],k = 99) == 6\n assert candidate(nums = [5, 4, 3, 2, 1],k = 4) == 1\n assert candidate(nums = [1, 1, 1, 1],k = 0) == 6\n assert candidate(nums = [5, 5, 5, 5],k = 0) == 6\n assert candidate(nums = [3, 2, 1, 5, 4],k = 2) == 3\n assert candidate(nums = [5, 1, 4, 1],k = 2) == 0\n assert candidate(nums = [1, 3],k = 3) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],k = 20) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 4\n assert candidate(nums = [1, 2, 2, 1],k = 1) == 4\n assert candidate(nums = [100, 1, 100, 1],k = 99) == 4\n assert candidate(nums = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110],k = 10) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 4) == 32\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82],k = 9) == 9\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93],k = 99) == 1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86],k = 1) == 14\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],k = 4) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 20\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 3, 6, 9, 12, 15],k = 3) == 22\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 1) == 40\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],k = 4) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50],k = 30) == 16\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 1) == 36\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43],k = 1) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 4\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 8) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50],k = 10) == 16\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 5, 15, 25, 35, 45],k = 10) == 22\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],k = 4) == 13\n assert candidate(nums = [55, 45, 35, 25, 15, 5, 5, 15, 25, 35, 45],k = 10) == 18\n assert candidate(nums = [99, 100, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94],k = 1) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 2) == 19\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 0) == 45\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],k = 2) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 9\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 0) == 105\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 9\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 9) == 1\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 1) == 9\n assert candidate(nums = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],k = 0) == 1225\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 1) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == 17\n assert candidate(nums = [99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9],k = 97) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 45\n assert candidate(nums = [55, 45, 35, 25, 15, 5, 105, 115, 125],k = 10) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 10) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1) == 14\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],k = 9) == 26\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 0) == 45\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30],k = 10) == 11\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 1) == 9\n assert candidate(nums = [50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55],k = 1) == 125\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000],k = 99) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 2) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 32\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85],k = 2) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 15\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 2) == 12\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 2) == 19\n assert candidate(nums = [10, 10, 10, 10, 11, 11, 12, 12, 13],k = 1) == 14\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33],k = 3) == 10\n assert candidate(nums = [10, 20, 30, 20, 10, 30, 20, 10, 30],k = 10) == 18\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 2) == 32\n assert candidate(nums = [90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40],k = 5) == 10\n assert candidate(nums = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50],k = 10) == 10\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 2) == 14\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85],k = 3) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 19\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 10) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],k = 2) == 24\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 1) == 16\n assert candidate(nums = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 9],k = 10) == 10\n assert candidate(nums = [10, 12, 15, 7, 5, 3, 10, 15],k = 5) == 7\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 10) == 10\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],k = 9) == 11\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 9\n assert candidate(nums = [10, 10, 20, 20, 30, 30],k = 10) == 8\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79],k = 4) == 19\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 10) == 9\n assert candidate(nums = [100, 1, 100, 2, 100, 3, 100, 4, 100, 5],k = 99) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 5\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],k = 4) == 24\n assert candidate(nums = [8, 18, 28, 38, 48, 58, 68, 78, 88, 98],k = 10) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 36\n assert candidate(nums = [50, 60, 70, 80, 90, 50, 60, 70, 80, 90, 50, 60],k = 20) == 16\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50],k = 1) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 1) == 29\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 1) == 32\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 2) == 10\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42],k = 0) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 13\n assert candidate(nums = [50, 50, 50, 51, 51, 52, 52, 52, 53, 53],k = 1) == 18\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 4) == 13\n assert candidate(nums = [5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15],k = 5) == 50\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 3) == 8\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42],k = 0) == 21\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 0) == 2850\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 6\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91],k = 9) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 19\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 1\n assert candidate(nums = [1, 10, 100, 1000, 10000, 10, 100, 1000],k = 999) == 2\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],k = 7) == 13\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100],k = 9) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 60\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countKDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countKDifference(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "countKDifference", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2007, "task_id": "find-original-array-from-doubled-array", "difficulty": "Medium", "problem_description": "An integer array original is transformed into a doubled array changed by appending twice the value of every element in original, and then randomly shuffling the resulting array.\nGiven an array changed, return original if changed is a doubled array. If changed is not a doubled array, return an empty array. The elements in original may be returned in any order.\n \nExample 1:\n\nInput: changed = [1,3,4,2,6,8]\nOutput: [1,3,4]\nExplanation: One possible original array could be [1,3,4]:\n- Twice the value of 1 is 1 * 2 = 2.\n- Twice the value of 3 is 3 * 2 = 6.\n- Twice the value of 4 is 4 * 2 = 8.\nOther original arrays could be [4,3,1] or [3,1,4].\n\nExample 2:\n\nInput: changed = [6,3,0,1]\nOutput: []\nExplanation: changed is not a doubled array.\n\nExample 3:\n\nInput: changed = [1]\nOutput: []\nExplanation: changed is not a doubled array.\n\n \nConstraints:\n\n1 <= changed.length <= 105\n0 <= changed[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(changed = [2, 1, 4, 2, 8, 4]) == [1, 2, 4]\n assert candidate(changed = [2, 4, 2, 4]) == [2, 2]\n assert candidate(changed = [1, 2, 3, 6, 9, 18]) == [1, 3, 9]\n assert candidate(changed = [8, 4, 2, 1, 16, 8, 4, 2]) == [1, 2, 4, 8]\n assert candidate(changed = [5, 3, 10, 0, 6, 9, 18, 15]) == []\n assert candidate(changed = [0, 0, 0, 0]) == [0, 0]\n assert candidate(changed = [100, 200, 300, 400, 500, 1000]) == []\n assert candidate(changed = [1, 2, 3, 4, 6, 8, 12, 16]) == []\n assert candidate(changed = [1, 2, 3, 6, 12, 24, 48, 96]) == [1, 3, 12, 48]\n assert candidate(changed = [5, 3, 10, 15, 2, 6]) == []\n assert candidate(changed = [1, 3, 4, 2, 6, 8]) == [1, 3, 4]\n assert candidate(changed = [1, 2]) == [1]\n assert candidate(changed = [1]) == []\n assert candidate(changed = [2, 1, 2, 4, 4, 8]) == [1, 2, 4]\n assert candidate(changed = [6, 3, 0, 1]) == []\n assert candidate(changed = [5, 10, 15, 20, 25, 50]) == []\n assert candidate(changed = [1, 2, 3, 6, 4, 8]) == [1, 3, 4]\n assert candidate(changed = [2, 4, 2, 4, 8, 8]) == []\n assert candidate(changed = [2, 1]) == [1]\n assert candidate(changed = [5, 3, 10, 15, 20, 6]) == []\n assert candidate(changed = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 60, 120, 180, 240, 300]) == []\n assert candidate(changed = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == []\n assert candidate(changed = [3, 6, 6, 12, 12, 12, 24, 24, 24, 24, 24, 24, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48]) == []\n assert candidate(changed = [2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024]) == [2, 2, 8, 8, 32, 32, 128, 128, 512, 512]\n assert candidate(changed = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 18, 54, 162, 486, 1458, 4374, 13122, 39366, 118098, 354294]) == []\n assert candidate(changed = [1, 2, 3, 4, 6, 8, 9, 12, 12, 16, 18, 24, 24, 32, 36, 48, 48, 64, 72, 96, 96, 128, 144, 192, 192]) == []\n assert candidate(changed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == []\n assert candidate(changed = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 220, 242, 264, 286, 308, 330, 352, 374, 396, 440, 484, 528, 572, 616, 660, 704, 748, 792, 880, 968, 1056, 1144, 1232, 1320, 1408, 1496, 1584, 1760, 1936, 2112, 2288, 2464, 2640, 2816, 2992, 3168, 3520, 3872, 4224, 4576, 4928, 5280, 5632, 5984, 6336, 7040, 7744, 8448, 9152, 9856, 10560, 11264, 11968, 12672, 14080, 15488, 16896, 18304, 19712, 21120, 22528, 23936, 25344, 28160, 31936, 35712, 39488, 43264, 47136, 50944, 54752, 58560, 62368, 66176, 69984, 73792, 77600, 81408, 85216, 89024, 92832, 96640, 100448]) == []\n assert candidate(changed = [9, 18, 36, 72, 144, 288, 576, 1152, 2304, 4608, 9216, 18432, 36864, 73728, 147456, 294912, 589824, 1179648, 2359296]) == []\n assert candidate(changed = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == []\n assert candidate(changed = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 380, 570, 760, 950, 1140, 1330, 1520, 1710, 1900]) == []\n assert candidate(changed = [1, 1, 2, 2, 3, 3, 6, 6, 9, 9, 12, 12, 18, 18, 24, 24, 36, 36, 48, 48, 54, 54, 72, 72, 96, 96, 108, 108, 144, 144, 192, 192]) == []\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, 40]) == []\n assert candidate(changed = [1, 1, 2, 2, 3, 3, 6, 6, 9, 9, 18, 18]) == [1, 1, 3, 3, 9, 9]\n assert candidate(changed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == []\n assert candidate(changed = [0, 0, 0, 0, 0, 0]) == [0, 0, 0]\n assert candidate(changed = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336, 28672, 57344, 114688]) == []\n assert candidate(changed = [23, 46, 92, 184, 368, 736, 1472, 2944, 5888, 11776, 23552, 47104, 94208, 188416, 376832, 753664, 1507328, 3014656, 6029312]) == []\n assert candidate(changed = [2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256]) == []\n assert candidate(changed = [1, 2, 3, 4, 6, 8, 9, 12, 12, 16, 18, 24, 24, 32, 36, 48, 48, 64, 72, 96, 96, 128, 144, 192, 192, 256, 288, 384, 384]) == []\n assert candidate(changed = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(changed = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == []\n assert candidate(changed = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 222, 333, 444, 555, 666, 777, 888, 999, 1100, 2200, 3300, 4400, 5500, 6600, 7700, 8800, 9900]) == []\n assert candidate(changed = [7, 14, 7, 14, 28, 28, 56, 56, 112, 112, 224, 224]) == [7, 7, 28, 28, 112, 112]\n assert candidate(changed = [1, 2, 3, 6, 9, 18, 27, 54, 81, 162, 243, 486, 729, 1458, 2187, 4374, 6561, 13122, 19683, 39366]) == [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683]\n assert candidate(changed = [3, 6, 12, 15, 30, 60, 75, 150, 225, 450, 900]) == []\n assert candidate(changed = [1, 2, 2, 4, 4, 4, 8, 8, 8, 8, 16, 16, 16, 16, 16, 32, 32, 32, 32, 32, 64, 64, 64, 64, 64, 128, 128, 128, 128, 128, 256, 256, 256, 256, 256, 512, 512, 512, 512, 512, 1024, 1024, 1024, 1024, 1024, 2048, 2048, 2048, 2048, 2048]) == []\n assert candidate(changed = [5, 10, 15, 20, 25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400]) == []\n assert candidate(changed = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 300, 450, 600, 750, 900]) == []\n assert candidate(changed = [1023, 2046, 3069, 4092, 5115, 6138, 7161, 8184, 9207, 10230, 2046, 4092, 6138, 8184, 10230, 12276, 14322, 16368, 18414, 20460, 3069, 6138, 9207, 12276, 15345, 18414, 21483, 24540, 27597, 30654]) == []\n assert candidate(changed = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == []\n assert candidate(changed = [1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 48, 72, 144, 288, 576, 1152, 2304, 4608, 9216, 18432, 36864, 73728, 147456, 294912, 589824, 1179648, 2359296, 4718592, 9437184, 18874368, 37748736, 75497472, 150994944, 301989888, 603979776, 1207959552, 2415919104, 4831838208, 9663676416, 19327352832, 38654705664, 77309411328, 154618822656, 309237645312, 618475290624, 1236950581248, 2473901162496, 4947802324992, 9895604649984, 19791209299968, 39582418599936, 79164837199872, 158329674399744, 316659348799488, 633318697598976, 1266637395197952, 2533274790395904, 5066549580791808, 10133099161583616, 20266198323167232, 40532396646334464, 81064793292668928, 162129586585337856, 324259173170675712, 648518346341351424, 1297036692682702848, 2594073385365405696, 5188146770730811392, 10376293541461622784, 20752587082923245568, 41505174165846491136, 83010348331692982272, 166020696663385964544]) == []\n assert candidate(changed = [7, 14, 14, 21, 28, 28, 35, 42, 42, 56, 56, 70, 70, 84, 84, 105, 105, 140, 140, 168, 168, 210, 210, 280, 280]) == []\n assert candidate(changed = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 40, 80, 120, 160, 200, 240, 280, 320, 360, 400]) == [5, 10, 15, 20, 20, 25, 30, 35, 40, 40, 45, 50, 60, 80, 100, 120, 140, 160, 180, 200]\n assert candidate(changed = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 460, 690, 920, 1150, 1380, 1610, 1840, 2070, 2300]) == []\n assert candidate(changed = [0, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(changed = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == []\n assert candidate(changed = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == []\n assert candidate(changed = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == []\n assert candidate(changed = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 260, 520, 780, 1040, 1300]) == []\n assert candidate(changed = [1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == []\n assert candidate(changed = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == []\n assert candidate(changed = [1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32]) == []\n assert candidate(changed = [1, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256]) == []\n assert candidate(changed = [5, 10, 10, 20, 20, 40, 40, 80, 80, 160, 160, 320, 320]) == []\n assert candidate(changed = [3, 6, 9, 18, 27, 54, 81, 162, 243, 486]) == [3, 9, 27, 81, 243]\n assert candidate(changed = [1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024]) == []\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == []\n assert candidate(changed = [101, 202, 404, 808, 1616, 3232, 6464, 12928, 25856, 51712, 103424, 206848, 413696, 827392, 1654784, 3309568, 6619136, 13238272, 26476544]) == []\n assert candidate(changed = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 340, 510, 680, 850, 1020, 1190, 1360, 1530, 1700]) == []\n assert candidate(changed = [1, 2, 2, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16]) == []\n assert candidate(changed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(changed = [5, 10, 10, 15, 20, 20, 25, 30, 30, 40, 40, 50, 50, 60, 60, 75, 75, 100, 100, 120, 120, 150, 150, 200, 200]) == []\n assert candidate(changed = [3, 6, 9, 12, 18, 24, 36, 48, 54, 72, 96, 108, 144, 192, 216, 288, 384, 432, 576, 768, 864, 1152, 1536, 1728, 2304, 3072, 3456, 4608, 6144, 6912, 9216, 12288, 13824, 18432, 24576, 27648, 36864, 49152, 55296, 73728, 98304]) == []\n assert candidate(changed = [1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024]) == []\n assert candidate(changed = [1, 1, 2, 2, 3, 3, 4, 4, 6, 6, 8, 8, 12, 12, 16, 16, 24, 24, 32, 32, 48, 48, 64, 64, 96, 96, 128, 128]) == [1, 1, 3, 3, 4, 4, 12, 12, 16, 16, 48, 48, 64, 64]\n assert candidate(changed = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == []\n assert candidate(changed = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225, 234, 243, 252, 261, 270]) == []\n assert candidate(changed = [1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64, 128, 128, 128, 256, 256, 256, 512, 512, 512]) == [1, 1, 1, 4, 4, 4, 16, 16, 16, 64, 64, 64, 256, 256, 256]\n assert candidate(changed = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [2, 8, 32, 128, 512]\n assert candidate(changed = [2, 4, 4, 8, 8, 16, 16, 32, 32, 64]) == [2, 4, 8, 16, 32]\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200]) == []\n assert candidate(changed = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 140, 280, 420, 560, 700]) == []\n assert candidate(changed = [1, 2, 2, 3, 6, 6, 12, 12, 24, 24, 48, 48]) == []\n assert candidate(changed = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [1, 4, 16, 64, 256]\n assert candidate(changed = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024, 2048, 2048, 4096, 4096, 8192, 8192, 16384, 16384]) == []\n assert candidate(changed = [2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64]) == []\n assert candidate(changed = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == []\n assert candidate(changed = [10, 20, 30, 40, 50, 60, 20, 40, 60, 80, 100, 120, 40, 80, 120, 160, 200, 240, 80, 160, 240, 320, 400, 480, 160, 320, 480, 640, 800, 960]) == []\n assert candidate(changed = [3, 3, 6, 6, 9, 9, 18, 18, 27, 27]) == []\n assert candidate(changed = [1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == []\n assert candidate(changed = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(changed = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64]) == []\n assert candidate(changed = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == [2, 8, 32, 128, 512, 2048, 8192, 32768]\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 60, 120, 180, 240, 300]) == []\n assert candidate(changed = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 180, 360, 540, 720, 900]) == []\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == []\n assert candidate(changed = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336, 28672, 57344, 114688, 229376, 458752, 917504, 1835008]) == []\n assert candidate(changed = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 18, 36, 54, 72, 90, 108, 126, 144, 162, 180]) == []\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == []\n assert candidate(changed = [10, 20, 30, 40, 50, 60, 20, 40, 60, 80, 100, 120]) == [10, 20, 30, 40, 50, 60]\n assert candidate(changed = [1, 2, 2, 4, 4, 8, 8, 16, 16, 32]) == [1, 2, 4, 8, 16]\n assert candidate(changed = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 22, 44, 66, 88, 110, 132, 154, 176, 198, 220, 33, 66, 99, 132, 165, 198, 231, 264, 297, 330]) == []\n assert candidate(changed = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == []\n assert candidate(changed = [1, 1, 2, 3, 3, 6, 6, 12, 12, 24, 24, 48, 48, 96, 96, 192, 192, 384, 384, 768, 768, 1536, 1536, 3072, 3072, 6144, 6144, 12288, 12288, 24576, 24576]) == []\n assert candidate(changed = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == [1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144]\n assert candidate(changed = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290, 580, 870, 1160, 1450, 1740, 2030, 2320, 2610, 2900]) == []\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 1088, 1152, 1216, 1280, 1344, 1408, 1472, 1536, 1600, 128, 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1408, 1536, 1664, 1792, 1920, 2048, 2176, 2304, 2432, 2560, 2688, 2816, 2944, 3072, 3200, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5632, 5888, 6144, 6400]) == []\n assert candidate(changed = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == [2, 8, 32, 128, 512, 2048, 8192, 32768, 131072, 524288]\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == []\n assert candidate(changed = [5, 10, 10, 20, 20, 40, 40, 80, 80, 160, 160, 320, 320, 640, 640, 1280, 1280, 2560, 2560, 5120]) == [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560]\n assert candidate(changed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140, 160, 180, 200, 240, 280, 320, 360, 400]) == []\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(changed = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512]) == [1, 1, 4, 4, 16, 16, 64, 64, 256, 256]\n assert candidate(changed = [1, 2, 3, 6, 9, 12, 18, 27, 36, 54, 81, 108, 162, 243, 324, 486, 729, 972, 1458, 2187]) == []\n assert candidate(changed = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == []\n assert candidate(changed = [5, 10, 15, 20, 25, 50, 75, 100, 125, 250, 375, 500, 625, 1250]) == []\n assert candidate(changed = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(changed = [100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200]) == [100, 400, 1600, 6400, 25600]\n assert candidate(changed = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024]) == []\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 24, 30, 40, 60, 120]) == []\n assert candidate(changed = [1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 36, 48, 54, 72, 96, 108, 144, 192, 216, 288, 384, 432, 576, 768, 864, 1152, 1536, 1728, 2304, 3072, 3456, 4608, 6144, 6912, 9216, 12288, 13824, 18432, 24576, 27648, 36864, 49152, 55296, 73728, 98304, 110592, 147456, 196608, 221184, 294912, 393216, 442368, 589824, 786432, 884736, 1179648, 1572864, 1769472, 2359296, 3145728, 3538944, 4718592, 6291456, 7077888, 9437184, 12582912, 14155776, 18874368, 25165824, 28311552, 37748736, 50331648, 56623104, 75497472, 100663296, 113246208, 150994944, 201326592, 226492416, 301989888, 402653184, 452984832, 603979776, 805306368, 893558688, 1207959552, 1610612736, 1787117376, 2415919104, 3221225472, 3574234752, 4831838208, 6442450944, 7148469504, 9663676416, 12884901888, 14296939008, 19327352832, 25769803776, 28593878016, 38654705664, 51539607552, 57187756032, 77309411328, 103079215104, 114375512064, 154618822656, 206158430208, 228751024128, 309237645312, 412316860416, 457502048256, 618475290624, 824633720832, 915004096512, 1236950581248, 1649267441664, 1830008193024, 2473901162496, 3298534883328, 3660016386048, 4947802324992, 6597069766656, 7320032772096, 9895604649984, 13194139533312, 14640065544192, 19791209299968, 26388279066624, 29280131088384, 39582418599936, 52776558133248, 58560262176768, 79164837199872, 105553116266496, 117120524353536, 158329674399744, 211106232532992, 234241048707072, 316659348799488, 422212465065984, 468482097414144, 633318697598976, 844424930131968, 936964194828288, 1266637395197952, 1688849860263936, 1873928389656576, 2533274790395904, 3377699720527872, 3747856779313152, 5066549580791808, 6755399441055744, 7495713558626304, 10133099161583616, 13510798882111488, 14991427117252608, 18958426576449824, 24349218045901216, 25722183890390144, 33392794892405760, 43998436091802432, 46474474833634208, 59525809886226240, 76796872183603840, 81348611215888544, 104281498830908160, 133593744367207680, 139342930911092288, 166399283014597440, 204791659156811520, 215343397595105920, 253068831957584768, 306386488715214080, 323015096392658880, 386797763385011520, 459579311430428160, 484522644589988224, 583887458675897600, 719158822845642240, 726783966884982336, 875809045506491520, 1078318430193856320, 1090175950327473344, 1313710568259737280, 1617491260261184480, 1635263925491209984, 1970565852389605840, 2434982520522368960, 2452895888236814976, 2956131704779211680, 3669965041044737920, 3679343832355222464, 4434197557168817440, 5539930082089475840, 5519015748532833696, 6651296335753226160, 8303893443132713760, 8278523622799250544, 10666592671504839200, 13338186886263570720, 13317785434198875816, 16000189007257258880, 20450915848351427640, 20423678151298313728, 24000378014514517760, 30676373772527141460, 30635517226947470592, 36000567021771776000, 46014560658790712180, 46002688140418453888, 54000850532657664000]) == []\n assert candidate(changed = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n"}, "metadata": {"canonical_parameter_names": ["changed"], "leetcode_dataset_entry_point": "Solution().findOriginalArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findOriginalArray(self, changed: list[int]) -> list[int]:", "container": "Solution", "callable": "findOriginalArray", "parameters": [{"name": "changed", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2008, "task_id": "maximum-earnings-from-taxi", "difficulty": "Medium", "problem_description": "There are n points on a road you are driving your taxi on. The n points on the road are labeled from 1 to n in the direction you are going, and you want to drive from point 1 to point n to make money by picking up passengers. You cannot change the direction of the taxi.\nThe passengers are represented by a 0-indexed 2D integer array rides, where rides[i] = [starti, endi, tipi] denotes the ith passenger requesting a ride from point starti to point endi who is willing to give a tipi dollar tip.\nFor each passenger i you pick up, you earn endi - starti + tipi dollars. You may only drive at most one passenger at a time.\nGiven n and rides, return the maximum number of dollars you can earn by picking up the passengers optimally.\nNote: You may drop off a passenger and pick up a different passenger at the same point.\n \nExample 1:\n\nInput: n = 5, rides = [[2,5,4],[1,5,1]]\nOutput: 7\nExplanation: We can pick up passenger 0 to earn 5 - 2 + 4 = 7 dollars.\n\nExample 2:\n\nInput: n = 20, rides = [[1,6,1],[3,10,2],[10,12,3],[11,12,2],[12,15,2],[13,18,1]]\nOutput: 20\nExplanation: We will pick up the following passengers:\n- Drive passenger 1 from point 3 to point 10 for a profit of 10 - 3 + 2 = 9 dollars.\n- Drive passenger 2 from point 10 to point 12 for a profit of 12 - 10 + 3 = 5 dollars.\n- Drive passenger 5 from point 13 to point 18 for a profit of 18 - 13 + 1 = 6 dollars.\nWe earn 9 + 5 + 6 = 20 dollars in total.\n \nConstraints:\n\n1 <= n <= 105\n1 <= rides.length <= 3 * 104\nrides[i].length == 3\n1 <= starti < endi <= n\n1 <= tipi <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 100,rides = [[1, 10, 50], [20, 30, 25], [50, 60, 100], [70, 80, 75], [90, 100, 200]]) == 499\n assert candidate(n = 10,rides = [[1, 3, 2], [2, 5, 3], [4, 6, 1]]) == 7\n assert candidate(n = 30,rides = [[1, 10, 10], [10, 20, 10], [20, 30, 10]]) == 59\n assert candidate(n = 15,rides = [[1, 2, 5], [2, 3, 10], [3, 4, 20], [4, 5, 30]]) == 69\n assert candidate(n = 5,rides = [[2, 5, 4], [1, 5, 1]]) == 7\n assert candidate(n = 15,rides = [[1, 4, 1], [2, 6, 2], [3, 7, 3], [4, 8, 4], [5, 9, 5]]) == 13\n assert candidate(n = 10,rides = [[1, 3, 2], [2, 5, 3], [4, 8, 2], [6, 10, 3]]) == 13\n assert candidate(n = 100,rides = [[1, 10, 50], [2, 20, 60], [3, 30, 70], [4, 40, 80], [5, 50, 90]]) == 135\n assert candidate(n = 30,rides = [[1, 15, 10], [16, 30, 5]]) == 43\n assert candidate(n = 15,rides = [[1, 4, 3], [3, 7, 4], [7, 10, 5]]) == 16\n assert candidate(n = 15,rides = [[1, 4, 5], [2, 6, 3], [3, 8, 7], [5, 9, 4]]) == 16\n assert candidate(n = 20,rides = [[1, 6, 1], [3, 10, 2], [10, 12, 3], [11, 12, 2], [12, 15, 2], [13, 18, 1]]) == 20\n assert candidate(n = 10,rides = [[1, 3, 5], [2, 5, 2], [5, 8, 3]]) == 13\n assert candidate(n = 10,rides = [[1, 3, 2], [2, 5, 3], [5, 7, 2], [6, 9, 1]]) == 10\n assert candidate(n = 100000,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1]]) == 20\n assert candidate(n = 1000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 1000, 999]]) == 2043\n assert candidate(n = 30000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [29998, 29999, 1], [29999, 30000, 100]]) == 112\n assert candidate(n = 100000,rides = [[1, 100000, 1], [100000, 100000, 100000], [1, 2, 1], [2, 3, 2], [3, 4, 3], [99999, 100000, 100000]]) == 200010\n assert candidate(n = 10000,rides = [[1, 500, 100], [501, 1000, 200], [1001, 1500, 300], [1501, 2000, 400], [2001, 2500, 500], [2501, 3000, 600], [3001, 3500, 700], [3501, 4000, 800], [4001, 4500, 900], [4501, 5000, 1000], [5001, 10000, 4500]]) == 19989\n assert candidate(n = 75000,rides = [[1, 25000, 10000], [25000, 50000, 10000], [50000, 75000, 10000]]) == 104999\n assert candidate(n = 5000,rides = [[1, 2500, 2500], [2501, 5000, 2500], [1, 5000, 5000]]) == 9999\n assert candidate(n = 100,rides = [[1, 5, 10], [5, 10, 10], [10, 15, 10], [15, 20, 10], [20, 25, 10], [25, 30, 10], [30, 35, 10], [35, 40, 10], [40, 45, 10], [45, 50, 10], [50, 55, 10], [55, 60, 10], [60, 65, 10], [65, 70, 10], [70, 75, 10], [75, 80, 10], [80, 85, 10], [85, 90, 10], [90, 95, 10], [95, 100, 10]]) == 299\n assert candidate(n = 1000,rides = [[1, 500, 1000], [501, 1000, 500], [1, 250, 200], [251, 500, 150], [501, 750, 125], [751, 1000, 100]]) == 2498\n assert candidate(n = 50000,rides = [[1, 5, 5], [2, 6, 7], [3, 7, 8], [4, 8, 9], [5, 9, 10], [6, 10, 12], [7, 11, 14], [8, 12, 16], [9, 13, 18], [10, 14, 20]]) == 51\n assert candidate(n = 30000,rides = [[1, 10000, 5000], [10001, 20000, 5000], [20001, 30000, 5000], [1, 20000, 10000], [10001, 30000, 10000], [1, 30000, 15000]]) == 44999\n assert candidate(n = 30000,rides = [[1, 10000, 5000], [10001, 20000, 10000], [20001, 30000, 15000], [1, 5000, 2500], [5001, 10000, 5000], [10001, 15000, 7500], [15001, 20000, 10000], [20001, 25000, 12500], [25001, 30000, 15000], [1, 2000, 1000], [2001, 4000, 2000], [4001, 6000, 3000], [6001, 8000, 4000], [8001, 10000, 5000], [10001, 12000, 6000], [12001, 14000, 7000], [14001, 16000, 8000], [16001, 18000, 9000], [18001, 20000, 10000], [20001, 22000, 11000], [22001, 24000, 12000], [24001, 26000, 13000], [26001, 28000, 14000], [28001, 30000, 15000]]) == 149985\n assert candidate(n = 30000,rides = [[1, 30000, 15000], [2, 29999, 14999], [3, 29998, 14998], [4, 29997, 14997], [5, 29996, 14996], [6, 29995, 14995], [7, 29994, 14994], [8, 29993, 14993], [9, 29992, 14992], [10, 29991, 14991]]) == 44999\n assert candidate(n = 50000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5]]) == 20\n assert candidate(n = 200,rides = [[1, 100, 50], [50, 150, 100], [100, 200, 150], [25, 75, 75], [75, 125, 125], [125, 175, 175], [175, 225, 225]]) == 800\n assert candidate(n = 80000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 80000, 79999]]) == 160043\n assert candidate(n = 100000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]]) == 135\n assert candidate(n = 50000,rides = [[1, 1000, 500], [1001, 2000, 1000], [2001, 3000, 1500], [3001, 4000, 2000], [4001, 5000, 2500], [5001, 10000, 3000], [10001, 15000, 3500], [15001, 20000, 4000], [20001, 25000, 4500], [25001, 30000, 5000], [30001, 35000, 5500], [35001, 40000, 6000], [40001, 45000, 6500], [45001, 50000, 7000]]) == 102486\n assert candidate(n = 10000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [20, 21, 20], [21, 22, 21], [22, 23, 22], [23, 24, 23], [24, 25, 24], [25, 26, 25], [26, 27, 26], [27, 28, 27], [28, 29, 28], [29, 30, 29], [30, 31, 30], [31, 32, 31], [32, 33, 32], [33, 34, 33], [34, 35, 34], [35, 36, 35], [36, 37, 36], [37, 38, 37], [38, 39, 38], [39, 40, 39], [40, 41, 40]]) == 860\n assert candidate(n = 200,rides = [[1, 100, 50], [2, 199, 49], [3, 198, 48], [4, 197, 47], [5, 196, 46], [6, 195, 45], [7, 194, 44], [8, 193, 43], [9, 192, 42], [10, 191, 41]]) == 246\n assert candidate(n = 100,rides = [[10, 20, 10], [20, 30, 20], [30, 40, 30], [40, 50, 40], [50, 60, 50], [60, 70, 60], [70, 80, 70], [80, 90, 80], [90, 100, 90], [1, 10, 5], [2, 20, 15], [3, 30, 25], [4, 40, 35], [5, 50, 45], [6, 60, 55], [7, 70, 65], [8, 80, 75], [9, 90, 85], [10, 100, 95]]) == 554\n assert candidate(n = 10000,rides = [[1, 10000, 10000], [2, 9999, 9999], [3, 9998, 9998], [4, 9997, 9997], [5, 9996, 9996]]) == 19999\n assert candidate(n = 10000,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1]]) == 38\n assert candidate(n = 50,rides = [[1, 3, 2], [3, 5, 3], [5, 7, 2], [7, 9, 1], [9, 11, 5], [11, 13, 4], [13, 15, 6], [15, 17, 2], [17, 19, 3], [19, 21, 7], [21, 23, 4], [23, 25, 5], [25, 27, 2], [27, 29, 3], [29, 31, 1], [31, 33, 5], [33, 35, 4], [35, 37, 6], [37, 39, 2], [39, 41, 3], [41, 43, 7], [43, 45, 4], [45, 47, 5], [47, 49, 2], [49, 50, 3]]) == 140\n assert candidate(n = 100,rides = [[1, 10, 50], [11, 20, 50], [21, 30, 50], [31, 40, 50], [41, 50, 50], [51, 60, 50], [61, 70, 50], [71, 80, 50], [81, 90, 50], [91, 100, 50]]) == 590\n assert candidate(n = 30000,rides = [[1, 10, 50], [11, 20, 100], [21, 30, 150], [31, 40, 200], [41, 50, 250], [51, 60, 300], [61, 70, 350], [71, 80, 400], [81, 90, 450], [91, 100, 500], [101, 30000, 29900]]) == 62639\n assert candidate(n = 150,rides = [[1, 50, 10], [50, 100, 20], [100, 150, 30], [20, 70, 15], [70, 120, 25], [120, 170, 35], [30, 80, 20], [80, 130, 30], [130, 180, 40]]) == 240\n assert candidate(n = 20000,rides = [[1, 5, 10], [2, 6, 15], [3, 7, 20], [4, 8, 25], [5, 9, 30], [6, 10, 35], [7, 11, 40], [8, 12, 45], [9, 13, 50], [10, 20000, 19950]]) == 39998\n assert candidate(n = 1000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]) == 54\n assert candidate(n = 100000,rides = [[1, 100000, 100000]]) == 199999\n assert candidate(n = 30000,rides = [[1, 30000, 10000], [10000, 20000, 15000], [20000, 30000, 20000], [5000, 15000, 10000]]) == 55000\n assert candidate(n = 50000,rides = [[1, 25000, 25000], [25000, 50000, 25000], [5000, 10000, 5000], [15000, 20000, 5000], [30000, 35000, 5000]]) == 99999\n assert candidate(n = 50,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [20, 21, 20], [21, 22, 21], [22, 23, 22], [23, 24, 23], [24, 25, 24], [25, 26, 25], [26, 27, 26], [27, 28, 27], [28, 29, 28], [29, 30, 29], [30, 31, 30], [31, 32, 31], [32, 33, 32], [33, 34, 33], [34, 35, 34], [35, 36, 35], [36, 37, 36], [37, 38, 37], [38, 39, 38], [39, 40, 39], [40, 41, 40], [41, 42, 41], [42, 43, 42], [43, 44, 43], [44, 45, 44], [45, 46, 45], [46, 47, 46], [47, 48, 47], [48, 49, 48], [49, 50, 49]]) == 1274\n assert candidate(n = 50,rides = [[1, 10, 5], [1, 10, 3], [1, 10, 1], [10, 20, 5], [10, 20, 3], [10, 20, 1], [20, 30, 5], [20, 30, 3], [20, 30, 1]]) == 44\n assert candidate(n = 70000,rides = [[1, 10000, 10000], [10001, 20000, 10000], [20001, 30000, 10000], [30001, 40000, 10000], [40001, 50000, 10000], [50001, 60000, 10000], [60001, 70000, 10000]]) == 139993\n assert candidate(n = 100000,rides = [[1, 50000, 50000], [50000, 100000, 50000], [25000, 75000, 30000]]) == 199999\n assert candidate(n = 50000,rides = [[1, 10, 100], [10, 20, 100], [20, 30, 100], [30, 40, 100], [40, 50, 100], [50, 60, 100], [60, 70, 100], [70, 80, 100], [80, 90, 100], [90, 100, 100]]) == 1099\n assert candidate(n = 10000,rides = [[1, 5000, 1000], [5001, 10000, 2000], [2001, 4000, 1500], [4001, 6000, 1200], [6001, 8000, 1800], [8001, 10000, 1600], [3001, 4500, 800], [4501, 6500, 1300], [6501, 8500, 1700], [8501, 9500, 1400]]) == 14096\n assert candidate(n = 50000,rides = [[1, 10, 10], [10, 20, 20], [20, 30, 30], [30, 40, 40], [40, 50, 50], [50, 60, 60], [60, 70, 70], [70, 80, 80], [80, 90, 90], [90, 100, 100], [100, 50000, 49900]]) == 100449\n assert candidate(n = 90000,rides = [[1, 10, 1], [11, 20, 2], [21, 30, 3], [31, 40, 4], [41, 50, 5], [51, 60, 6], [61, 70, 7], [71, 80, 8], [81, 90, 9], [91, 100, 10], [101, 110, 11], [111, 120, 12], [121, 130, 13], [131, 140, 14], [141, 150, 15], [151, 160, 16], [161, 170, 17], [171, 180, 18], [181, 190, 19], [191, 200, 20]]) == 390\n assert candidate(n = 90000,rides = [[1, 30000, 30000], [30001, 60000, 30000], [60001, 90000, 30000], [1, 60000, 60000], [30001, 90000, 60000], [1, 90000, 90000]]) == 179999\n assert candidate(n = 5000,rides = [[1, 3, 1], [2, 4, 1], [3, 5, 1], [4, 6, 1], [5, 7, 1], [6, 8, 1], [7, 9, 1], [8, 10, 1], [9, 11, 1], [10, 12, 1], [11, 13, 1], [12, 14, 1], [13, 15, 1], [14, 16, 1], [15, 17, 1], [16, 18, 1], [17, 19, 1], [18, 20, 1], [19, 21, 1], [20, 22, 1], [21, 23, 1], [22, 24, 1], [23, 25, 1], [24, 26, 1], [25, 27, 1], [26, 28, 1], [27, 29, 1], [28, 30, 1], [29, 31, 1], [30, 32, 1], [31, 33, 1], [32, 34, 1], [33, 35, 1], [34, 36, 1], [35, 37, 1], [36, 38, 1], [37, 39, 1], [38, 40, 1]]) == 57\n assert candidate(n = 10000,rides = [[1, 5, 50], [2, 6, 40], [3, 7, 30], [4, 8, 20], [5, 9, 10], [6, 10, 5]]) == 68\n assert candidate(n = 1000,rides = [[1, 10, 5], [2, 15, 10], [5, 100, 50], [10, 50, 25], [15, 90, 45], [20, 80, 35], [25, 70, 30], [30, 60, 25], [35, 55, 20], [40, 45, 15]]) == 145\n assert candidate(n = 50000,rides = [[1, 10000, 10000], [10001, 20000, 20000], [20001, 30000, 30000], [30001, 40000, 40000], [40001, 50000, 50000]]) == 199995\n assert candidate(n = 100,rides = [[1, 10, 5], [11, 20, 10], [21, 30, 15], [31, 40, 20], [41, 50, 25], [51, 60, 30], [61, 70, 35], [71, 80, 40], [81, 90, 45], [91, 100, 50]]) == 365\n assert candidate(n = 100000,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1], [20, 21, 1], [21, 22, 1], [22, 23, 1], [23, 24, 1], [24, 25, 1], [25, 26, 1], [26, 27, 1], [27, 28, 1], [28, 29, 1], [29, 30, 1], [30, 31, 1], [31, 32, 1], [32, 33, 1], [33, 34, 1], [34, 35, 1], [35, 36, 1], [36, 37, 1], [37, 38, 1], [38, 39, 1], [39, 40, 1], [40, 41, 1], [41, 42, 1], [42, 43, 1], [43, 44, 1], [44, 45, 1], [45, 46, 1], [46, 47, 1], [47, 48, 1], [48, 49, 1], [49, 50, 1], [50, 51, 1], [51, 52, 1], [52, 53, 1], [53, 54, 1], [54, 55, 1], [55, 56, 1], [56, 57, 1], [57, 58, 1], [58, 59, 1], [59, 60, 1], [60, 61, 1], [61, 62, 1], [62, 63, 1], [63, 64, 1], [64, 65, 1], [65, 66, 1], [66, 67, 1], [67, 68, 1], [68, 69, 1], [69, 70, 1], [70, 71, 1], [71, 72, 1], [72, 73, 1], [73, 74, 1], [74, 75, 1], [75, 76, 1], [76, 77, 1], [77, 78, 1], [78, 79, 1], [79, 80, 1], [80, 81, 1], [81, 82, 1], [82, 83, 1], [83, 84, 1], [84, 85, 1], [85, 86, 1], [86, 87, 1], [87, 88, 1], [88, 89, 1], [89, 90, 1], [90, 91, 1], [91, 92, 1], [92, 93, 1], [93, 94, 1], [94, 95, 1], [95, 96, 1], [96, 97, 1], [97, 98, 1], [98, 99, 1], [99, 100, 1], [100, 101, 1], [101, 102, 1], [102, 103, 1], [103, 104, 1], [104, 105, 1], [105, 106, 1], [106, 107, 1], [107, 108, 1], [108, 109, 1], [109, 110, 1], [110, 111, 1], [111, 112, 1], [112, 113, 1], [113, 114, 1], [114, 115, 1], [115, 116, 1], [116, 117, 1], [117, 118, 1], [118, 119, 1], [119, 120, 1], [120, 121, 1], [121, 122, 1], [122, 123, 1], [123, 124, 1], [124, 125, 1], [125, 126, 1], [126, 127, 1], [127, 128, 1], [128, 129, 1], [129, 130, 1], [130, 131, 1], [131, 132, 1], [132, 133, 1], [133, 134, 1], [134, 135, 1], [135, 136, 1], [136, 137, 1], [137, 138, 1], [138, 139, 1], [139, 140, 1], [140, 141, 1], [141, 142, 1], [142, 143, 1], [143, 144, 1], [144, 145, 1], [145, 146, 1], [146, 147, 1], [147, 148, 1], [148, 149, 1], [149, 150, 1], [150, 151, 1], [151, 152, 1], [152, 153, 1], [153, 154, 1], [154, 155, 1], [155, 156, 1], [156, 157, 1], [157, 158, 1], [158, 159, 1], [159, 160, 1], [160, 161, 1], [161, 162, 1], [162, 163, 1], [163, 164, 1], [164, 165, 1], [165, 166, 1], [166, 167, 1], [167, 168, 1], [168, 169, 1], [169, 170, 1], [170, 171, 1], [171, 172, 1], [172, 173, 1], [173, 174, 1], [174, 175, 1], [175, 176, 1], [176, 177, 1], [177, 178, 1], [178, 179, 1], [179, 180, 1], [180, 181, 1], [181, 182, 1], [182, 183, 1], [183, 184, 1], [184, 185, 1], [185, 186, 1], [186, 187, 1], [187, 188, 1], [188, 189, 1], [189, 190, 1], [190, 191, 1], [191, 192, 1], [192, 193, 1], [193, 194, 1], [194, 195, 1], [195, 196, 1], [196, 197, 1], [197, 198, 1], [198, 199, 1], [199, 200, 1]]) == 398\n assert candidate(n = 100000,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 100000, 99999]]) == 200007\n assert candidate(n = 100000,rides = [[1, 100000, 100000], [50000, 100000, 50000], [25000, 75000, 25000], [1, 50000, 10000], [50001, 100000, 10000]]) == 199999\n assert candidate(n = 20,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1]]) == 38\n assert candidate(n = 100000,rides = [[1, 100000, 1], [1, 100000, 2], [1, 100000, 3], [1, 100000, 4], [1, 100000, 5], [1, 100000, 6], [1, 100000, 7], [1, 100000, 8], [1, 100000, 9], [1, 100000, 10]]) == 100009\n assert candidate(n = 15,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14]]) == 119\n assert candidate(n = 60000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [59999, 60000, 100000]]) == 100028\n assert candidate(n = 80000,rides = [[1, 20000, 1000], [20000, 40000, 1000], [40000, 60000, 1000], [60000, 80000, 1000]]) == 83999\n assert candidate(n = 10000,rides = [[1, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 10, 10], [7, 11, 10], [8, 12, 10], [9, 13, 10], [10, 14, 10]]) == 42\n assert candidate(n = 10000,rides = [[1, 10, 5], [2, 11, 5], [3, 12, 5], [4, 13, 5], [5, 14, 5], [6, 15, 5], [7, 16, 5], [8, 17, 5], [9, 18, 5], [10, 19, 5], [11, 20, 5], [12, 21, 5], [13, 22, 5], [14, 23, 5], [15, 24, 5], [16, 25, 5], [17, 26, 5], [18, 27, 5], [19, 28, 5], [20, 29, 5], [21, 30, 5], [22, 31, 5], [23, 32, 5], [24, 33, 5], [25, 34, 5], [26, 35, 5], [27, 36, 5], [28, 37, 5], [29, 38, 5], [30, 39, 5], [31, 40, 5], [32, 41, 5], [33, 42, 5], [34, 43, 5], [35, 44, 5], [36, 45, 5], [37, 46, 5], [38, 47, 5], [39, 48, 5], [40, 49, 5], [41, 50, 5], [42, 51, 5], [43, 52, 5], [44, 53, 5], [45, 54, 5], [46, 55, 5], [47, 56, 5], [48, 57, 5], [49, 58, 5], [50, 59, 5], [51, 60, 5], [52, 61, 5], [53, 62, 5], [54, 63, 5], [55, 64, 5], [56, 65, 5], [57, 66, 5], [58, 67, 5], [59, 68, 5], [60, 69, 5], [61, 70, 5], [62, 71, 5], [63, 72, 5], [64, 73, 5], [65, 74, 5], [66, 75, 5], [67, 76, 5], [68, 77, 5], [69, 78, 5], [70, 79, 5], [71, 80, 5], [72, 81, 5], [73, 82, 5], [74, 83, 5], [75, 84, 5], [76, 85, 5], [77, 86, 5], [78, 87, 5], [79, 88, 5], [80, 89, 5], [81, 90, 5], [82, 91, 5], [83, 92, 5], [84, 93, 5], [85, 94, 5], [86, 95, 5], [87, 96, 5], [88, 97, 5], [89, 98, 5], [90, 99, 5], [91, 100, 5]]) == 154\n assert candidate(n = 120000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [119998, 119999, 1], [119999, 120000, 100]]) == 112\n"}, "metadata": {"canonical_parameter_names": ["n", "rides"], "leetcode_dataset_entry_point": "Solution().maxTaxiEarnings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxTaxiEarnings(self, n: int, rides: list[list[int]]) -> int:", "container": "Solution", "callable": "maxTaxiEarnings", "parameters": [{"name": "n", "type": "int"}, {"name": "rides", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2009, "task_id": "minimum-number-of-operations-to-make-array-continuous", "difficulty": "Hard", "problem_description": "You are given an integer array nums. In one operation, you can replace any element in nums with any integer.\nnums is considered continuous if both of the following conditions are fulfilled:\n\nAll elements in nums are unique.\nThe difference between the maximum element and the minimum element in nums equals nums.length - 1.\n\nFor example, nums = [4, 2, 5, 3] is continuous, but nums = [1, 2, 3, 5, 6] is not continuous.\nReturn the minimum number of operations to make nums continuous.\n \nExample 1:\n\nInput: nums = [4,2,5,3]\nOutput: 0\nExplanation: nums is already continuous.\n\nExample 2:\n\nInput: nums = [1,2,3,5,6]\nOutput: 1\nExplanation: One possible solution is to change the last element to 4.\nThe resulting array is [1,2,3,5,4], which is continuous.\n\nExample 3:\n\nInput: nums = [1,10,100,1000]\nOutput: 3\nExplanation: One possible solution is to:\n- Change the second element to 2.\n- Change the third element to 3.\n- Change the fourth element to 4.\nThe resulting array is [1,2,3,4], which is continuous.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10]) == 3\n assert candidate(nums = [4, 2, 5, 3]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5]) == 2\n assert candidate(nums = [5, 6, 7, 8, 9, 1]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1000000000, 1, 2, 3, 4]) == 1\n assert candidate(nums = [1000000000]) == 0\n assert candidate(nums = [100, 101, 102, 1]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5]) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 5\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [2, 3, 5, 8, 9, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [1, 10, 100, 1000]) == 3\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [10, 5, 1, 2, 7]) == 2\n assert candidate(nums = [1, 2, 2, 3, 4]) == 1\n assert candidate(nums = [1, 2, 3, 5, 6]) == 1\n assert candidate(nums = [10, 5, 7, 11, 6]) == 2\n assert candidate(nums = [5, 3, 1, 2, 4]) == 0\n assert candidate(nums = [10, 5, 3, 11, 6]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [5, 3, 1, 4, 2]) == 0\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 4\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 1000000000, 2000000000, 3000000000, 4000000000]) == 4\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 16\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 14\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 9\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998]) == 3\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 2, 11, 101, 1001, 10001, 100001, 1000001, 10000001, 100000001, 1000000001]) == 16\n assert candidate(nums = [1, 1000000000]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 7\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 19\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496]) == 24\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 120, 131, 142, 153, 164, 175, 186, 197, 208, 219]) == 18\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 4, 5, 5, 6]) == 4\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 9\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 10\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [5, 6, 15, 16, 25, 26, 35, 36, 45, 46, 55, 56, 65, 66, 75, 76, 85, 86, 95, 96]) == 16\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [3, 7, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996, 6, 999999995]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(nums = [2, 1, 3, 4, 7, 6, 5, 8, 9, 10]) == 0\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 4\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 20, 21, 22, 23, 25, 26, 27, 28, 30, 31, 32, 33, 35, 36, 37, 38, 40]) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 15\n assert candidate(nums = [1, 3, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 7\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 12\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15, 15, 16]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20]) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(nums = [1, 2, 3, 1000000000, 2000000000]) == 2\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100, 109, 118, 127, 136, 145, 154, 163, 172, 181, 190, 199, 208, 217, 226]) == 23\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 18\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 13\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 12\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5]) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == 5\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 8\n assert candidate(nums = [1000000, 1000001, 1000002, 1000004, 1000005, 1000007, 1000008, 1000010, 1000011, 1000013]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 9\n assert candidate(nums = [1, 1000000000, 1000000001, 1000000002, 1000000003, 1000000004, 1000000005, 1000000006, 1000000007, 1000000008, 1000000009, 1000000010, 1000000011, 1000000012, 1000000013]) == 1\n assert candidate(nums = [5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 20]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 14\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 100, 101, 200, 201, 300, 301, 400, 401, 500, 501, 600, 601, 700, 701, 800, 801, 900, 901, 1000]) == 18\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 18\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 22\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 20\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500]) == 45\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 8\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996]) == 5\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 200, 201, 202, 203, 204]) == 5\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003, 1000000004, 1000000005]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 18\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 7\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 30\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 5\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 14\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 9\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209]) == 10\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 10\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971]) == 0\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 13\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minOperations(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2011, "task_id": "final-value-of-variable-after-performing-operations", "difficulty": "Easy", "problem_description": "There is a programming language with only four operations and one variable X:\n\n++X and X++ increments the value of the variable X by 1.\n--X and X-- decrements the value of the variable X by 1.\n\nInitially, the value of X is 0.\nGiven an array of strings operations containing a list of operations, return the final value of X after performing all the operations.\n \nExample 1:\n\nInput: operations = [\"--X\",\"X++\",\"X++\"]\nOutput: 1\nExplanation: The operations are performed as follows:\nInitially, X = 0.\n--X: X is decremented by 1, X = 0 - 1 = -1.\nX++: X is incremented by 1, X = -1 + 1 = 0.\nX++: X is incremented by 1, X = 0 + 1 = 1.\n\nExample 2:\n\nInput: operations = [\"++X\",\"++X\",\"X++\"]\nOutput: 3\nExplanation: The operations are performed as follows:\nInitially, X = 0.\n++X: X is incremented by 1, X = 0 + 1 = 1.\n++X: X is incremented by 1, X = 1 + 1 = 2.\nX++: X is incremented by 1, X = 2 + 1 = 3.\n\nExample 3:\n\nInput: operations = [\"X++\",\"++X\",\"--X\",\"X--\"]\nOutput: 0\nExplanation: The operations are performed as follows:\nInitially, X = 0.\nX++: X is incremented by 1, X = 0 + 1 = 1.\n++X: X is incremented by 1, X = 1 + 1 = 2.\n--X: X is decremented by 1, X = 2 - 1 = 1.\nX--: X is decremented by 1, X = 1 - 1 = 0.\n\n \nConstraints:\n\n1 <= operations.length <= 100\noperations[i] will be either \"++X\", \"X++\", \"--X\", or \"X--\".\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(operations = ['X++', '++X', '--X', 'X--']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++']) == 5\n assert candidate(operations = ['--X', '--X', 'X--', 'X--']) == -4\n assert candidate(operations = ['++X', '++X', '++X', '++X']) == 4\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++']) == 4\n assert candidate(operations = ['--X', 'X++', 'X++']) == 1\n assert candidate(operations = ['--X', '--X', '--X', '--X']) == -4\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X']) == -5\n assert candidate(operations = ['--X', '--X', 'X++', '++X']) == 0\n assert candidate(operations = ['++X', '++X', 'X++']) == 3\n assert candidate(operations = ['--X', '--X', 'X++', '++X', '--X']) == -1\n assert candidate(operations = ['++X', 'X--', '--X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X--', '++X', '--X']) == 0\n assert candidate(operations = ['++X', '++X', '++X', '++X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -12\n assert candidate(operations = ['X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', 'X++', 'X++', 'X++']) == 1\n assert candidate(operations = ['--X', '--X', 'X++', 'X++', 'X--', 'X--', 'X++', '++X', '--X', 'X++', '--X', '++X', 'X--', '--X', 'X++', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == 0\n assert candidate(operations = ['++X', '++X', '++X', '++X', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--']) == -6\n assert candidate(operations = ['--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++']) == 0\n assert candidate(operations = ['X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X']) == -16\n assert candidate(operations = ['++X', '--X', '++X', '--X', '++X', '--X']) == 0\n assert candidate(operations = ['++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--']) == 0\n assert candidate(operations = ['X--', '--X', 'X++', '++X', '--X', 'X--', '--X', '++X', 'X++']) == -1\n assert candidate(operations = ['++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', '--X', 'X++', 'X++', '--X', '--X', 'X++', '--X', 'X++', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X']) == 1\n assert candidate(operations = ['--X', '--X', 'X--', 'X++', '++X', '++X', 'X--', '--X', '++X', '--X']) == -2\n assert candidate(operations = ['++X', 'X--', '--X', 'X++', 'X--', '++X', 'X--', '--X', 'X++', '++X']) == 0\n assert candidate(operations = ['++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++']) == 2\n assert candidate(operations = ['++X', 'X--', '--X', 'X++', '++X', '--X', 'X++']) == 1\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '++X', '++X', '++X', '++X', '++X', '++X', '++X', '++X', '++X', '++X']) == -5\n assert candidate(operations = ['++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X']) == 0\n assert candidate(operations = ['++X', '++X', '--X', '--X', '++X', '++X', '--X', '--X', '++X', '++X', '--X', '--X', '++X', '++X', '--X', '--X', '++X', '++X']) == 2\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -12\n assert candidate(operations = ['X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == 0\n assert candidate(operations = ['++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X']) == 0\n assert candidate(operations = ['X++', '--X', '++X', 'X--', '++X', 'X++', '--X', '--X', '++X', 'X++']) == 2\n assert candidate(operations = ['++X', '++X', '++X', '++X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -4\n assert candidate(operations = ['X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == 0\n assert candidate(operations = ['--X', 'X++', '++X', '--X', 'X++', '--X', 'X--', 'X++', '--X', '++X']) == 0\n assert candidate(operations = ['++X', '++X', '++X', '--X', '--X', '--X', '++X', 'X++', '--X']) == 1\n assert candidate(operations = ['++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == -1\n assert candidate(operations = ['--X', '--X', 'X++', 'X--', 'X--', 'X--', 'X--', 'X--', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 0\n assert candidate(operations = ['++X', '--X', 'X++', '++X', '--X', 'X--', '++X', 'X++']) == 2\n assert candidate(operations = ['--X', 'X--', '--X', 'X--', '--X', 'X--', '++X', 'X++', '++X', 'X++', '++X', 'X++', '++X', 'X++']) == 2\n assert candidate(operations = ['X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X']) == 0\n assert candidate(operations = ['--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X--', 'X--', 'X--', 'X--', 'X++', 'X++', 'X--', 'X--']) == 0\n assert candidate(operations = ['X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -4\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X']) == -5\n assert candidate(operations = ['X++', 'X++', '--X', '--X', '++X', 'X--', '++X', '--X', '++X', '--X']) == 0\n assert candidate(operations = ['X++', 'X++', '++X', '--X', 'X--', 'X--', '--X', '++X', 'X--', '--X']) == -2\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 12\n assert candidate(operations = ['--X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', '--X', 'X++', '--X', '++X', 'X--', '--X', 'X++']) == -2\n assert candidate(operations = ['--X', '--X', '--X', '--X', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 4\n assert candidate(operations = ['--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == -1\n assert candidate(operations = ['X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', '++X', 'X++', '--X', '--X', '++X', 'X++']) == 2\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X', '--X', '++X', '++X', '++X', '++X', '++X', '++X', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 8\n assert candidate(operations = ['--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 57\n assert candidate(operations = ['X++', '--X', '++X', 'X--', '++X', '--X', 'X++', '++X', '--X', 'X--']) == 0\n assert candidate(operations = ['--X', '--X', '--X', '--X', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 37\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++']) == 2\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X']) == 0\n assert candidate(operations = ['X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == 0\n assert candidate(operations = ['--X', '--X', '--X', 'X++', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', 'X--', 'X--', '++X', '++X']) == 0\n assert candidate(operations = ['X++', 'X--', '++X', '--X', 'X++', 'X--', '++X', '--X', 'X++', 'X--', '++X', '--X', 'X++', 'X--', '++X', '--X', 'X++', 'X--', '++X', '--X']) == 0\n assert candidate(operations = ['X++', 'X--', '++X', '--X', 'X--', '++X', 'X--', '++X', 'X--', '++X', 'X--', '++X']) == 0\n assert candidate(operations = ['X++', '--X', '++X', '--X', 'X++', '--X', 'X--']) == -1\n assert candidate(operations = ['--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 2\n assert candidate(operations = ['X--', 'X--', '--X', '--X', 'X++', 'X++', '++X']) == -1\n assert candidate(operations = ['X++', 'X++', 'X++', '--X', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', 'X++', '--X', '--X']) == 1\n assert candidate(operations = ['++X', '++X', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++']) == 2\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X', '++X', '++X', '++X', '++X', '++X', 'X++', 'X++', 'X++']) == 3\n assert candidate(operations = ['++X', 'X++', '--X', 'X--', '++X', '--X', 'X++', '++X']) == 2\n assert candidate(operations = ['X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X']) == 2\n assert candidate(operations = ['X++', '++X', 'X++', '++X', '--X', '--X', 'X--', '--X', 'X++', '++X', '--X', 'X--', '++X', 'X++']) == 2\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -4\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X++', 'X++', '--X', '--X', '--X']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == 0\n assert candidate(operations = ['X--', '--X', 'X++', '++X', 'X--', 'X--', '--X', '++X', 'X--', 'X--', 'X++', '++X']) == -2\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X--', 'X++', '--X', 'X++', 'X--', '++X', '--X']) == 0\n assert candidate(operations = ['++X', 'X--', '++X', 'X--', '++X', 'X--', '++X', 'X--', '++X', 'X--', '++X', 'X--']) == 0\n assert candidate(operations = ['X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X']) == 0\n assert candidate(operations = ['--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++']) == 0\n assert candidate(operations = ['++X', '++X', '++X', '--X', 'X--', '--X', 'X--', '--X', '++X', '--X']) == -2\n"}, "metadata": {"canonical_parameter_names": ["operations"], "leetcode_dataset_entry_point": "Solution().finalValueAfterOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def finalValueAfterOperations(self, operations: list[str]) -> int:", "container": "Solution", "callable": "finalValueAfterOperations", "parameters": [{"name": "operations", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2012, "task_id": "sum-of-beauty-in-the-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. For each index i (1 <= i <= nums.length - 2) the beauty of nums[i] equals:\n\n2, if nums[j] < nums[i] < nums[k], for all 0 <= j < i and for all i < k <= nums.length - 1.\n1, if nums[i - 1] < nums[i] < nums[i + 1], and the previous condition is not satisfied.\n0, if none of the previous conditions holds.\n\nReturn the sum of beauty of all nums[i] where 1 <= i <= nums.length - 2.\n \nExample 1:\n\nInput: nums = [1,2,3]\nOutput: 2\nExplanation: For each index i in the range 1 <= i <= 1:\n- The beauty of nums[1] equals 2.\n\nExample 2:\n\nInput: nums = [2,4,6,4]\nOutput: 1\nExplanation: For each index i in the range 1 <= i <= 2:\n- The beauty of nums[1] equals 1.\n- The beauty of nums[2] equals 0.\n\nExample 3:\n\nInput: nums = [3,2,1]\nOutput: 0\nExplanation: For each index i in the range 1 <= i <= 1:\n- The beauty of nums[1] equals 0.\n\n \nConstraints:\n\n3 <= nums.length <= 105\n1 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 100, 8, 6, 90, 101]) == 1\n assert candidate(nums = [9, 7, 5, 3, 1]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [5, 3, 4, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 0\n assert candidate(nums = [2, 4, 6, 4]) == 1\n assert candidate(nums = [1, 100, 101, 102, 99]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [5, 1, 4, 3, 6, 7]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [100000, 99999, 100001, 99998, 100002]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 14\n assert candidate(nums = [3, 2, 1]) == 0\n assert candidate(nums = [1, 5, 2, 5, 3, 5, 4, 5]) == 0\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 0\n assert candidate(nums = [1, 3, 2, 3, 5, 2, 6, 2]) == 1\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 0\n assert candidate(nums = [1, 2, 3]) == 2\n assert candidate(nums = [1, 3, 2, 5, 4, 6]) == 0\n assert candidate(nums = [1, 6, 4, 3, 5, 7, 8]) == 3\n assert candidate(nums = [1, 5, 2, 4, 3, 6]) == 0\n assert candidate(nums = [1, 5, 3, 7, 9, 11, 13, 2, 14]) == 3\n assert candidate(nums = [10, 20, 15, 25, 20, 30, 25, 35, 30, 40, 35, 45, 40, 50, 45]) == 0\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9, 8, 9, 10]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 94, 93, 92, 91]) == 16\n assert candidate(nums = [5, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15]) == 10\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [10, 20, 30, 25, 24, 35, 40, 39, 45, 50]) == 6\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3]) == 2\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [3, 1, 4, 2, 5, 8, 7, 10, 9, 12, 11]) == 2\n assert candidate(nums = [1, 5, 3, 4, 2, 8, 6, 7, 9, 11, 10]) == 3\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 24\n assert candidate(nums = [5, 3, 4, 2, 6, 1, 7, 9, 8, 10]) == 2\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8]) == 0\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 35, 40, 2, 45]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10]) == 4\n assert candidate(nums = [10, 20, 11, 30, 12, 40, 13, 50, 14, 60, 15]) == 0\n assert candidate(nums = [1, 2, 3, 100, 2, 3, 4, 5, 6, 7]) == 6\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == 0\n assert candidate(nums = [1, 10, 3, 5, 8, 12, 7, 6, 9, 11, 15, 14, 13, 16, 18, 17, 20, 19, 21, 22]) == 8\n assert candidate(nums = [90, 100, 110, 120, 115, 130, 140, 150, 145, 160, 170, 180, 175, 190, 200]) == 14\n assert candidate(nums = [1, 3, 5, 4, 6, 7, 2, 8, 9, 10]) == 6\n assert candidate(nums = [1, 2, 3, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 22\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == 46\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 8\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 0\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 8, 7, 10, 9, 12, 11]) == 2\n assert candidate(nums = [1, 20, 3, 40, 5, 60, 7, 80, 9, 100]) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9]) == 8\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 0\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15]) == 16\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 46\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 8\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 3\n assert candidate(nums = [5, 1, 4, 3, 6, 8, 2, 9, 7, 10]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24]) == 0\n assert candidate(nums = [1, 20, 3, 15, 4, 10, 5, 25, 6]) == 0\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 8, 7, 9, 11]) == 6\n assert candidate(nums = [5, 1, 4, 3, 6, 2, 8, 7, 10, 9]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 28\n assert candidate(nums = [5, 1, 3, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 23\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [10, 20, 30, 25, 40, 35, 50, 45, 60, 55]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 56\n assert candidate(nums = [10, 20, 30, 25, 40, 35, 50, 45, 60]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 25\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12]) == 4\n assert candidate(nums = [10, 20, 30, 25, 35, 40, 45, 50, 39, 41]) == 6\n assert candidate(nums = [1, 100, 50, 200, 150, 250, 200, 300, 250, 350, 300, 400, 350, 450, 400, 500, 450, 550, 500, 600]) == 0\n assert candidate(nums = [10, 20, 30, 15, 25, 35, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 14\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 21]) == 0\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 0\n assert candidate(nums = [30, 20, 10, 25, 15, 5, 35, 25, 15, 40, 30, 20, 50, 40, 30]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 26\n assert candidate(nums = [5, 3, 4, 2, 1, 6, 7, 8]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 20]) == 17\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 22\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 14\n assert candidate(nums = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 99999]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11]) == 8\n assert candidate(nums = [1, 2, 5, 3, 6, 4, 7, 8, 10, 9]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10]) == 21\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 0\n assert candidate(nums = [5, 8, 3, 9, 4, 10, 6, 11, 7, 12]) == 0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 1\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991]) == 0\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == 0\n assert candidate(nums = [20, 10, 30, 5, 25, 15, 35, 40, 50, 60]) == 6\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 0, 8, 7, 9]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 36\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 25\n assert candidate(nums = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4, 104]) == 0\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 9, 10, 11, 12, 13, 14, 15]) == 12\n assert candidate(nums = [3, 1, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15]) == 4\n assert candidate(nums = [1, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 22\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == 0\n assert candidate(nums = [10, 11, 9, 12, 8, 13, 7, 14, 6, 15, 5, 16, 4, 17, 3, 18, 2, 19, 1, 20]) == 0\n assert candidate(nums = [5, 1, 4, 3, 6, 8, 2, 9, 7]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50]) == 11\n assert candidate(nums = [50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90, 110, 100, 120, 110, 130, 120, 140, 130]) == 0\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, 23, 24, 25, 26]) == 8\n assert candidate(nums = [1, 5, 3, 4, 6, 2, 7, 8, 9, 10]) == 7\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == 16\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 0\n assert candidate(nums = [10, 20, 30, 29, 28, 27, 26, 25, 24, 23]) == 2\n assert candidate(nums = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 16\n assert candidate(nums = [1, 3, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 10]) == 21\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10, 11, 12, 13, 14, 15]) == 14\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 11, 10, 13, 15]) == 8\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 35, 40, 2, 45, 50]) == 4\n assert candidate(nums = [1, 2, 100, 3, 4, 101, 5, 6, 102, 7, 8]) == 4\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 0\n assert candidate(nums = [10, 20, 30, 25, 35, 40, 36, 45, 50, 55]) == 8\n assert candidate(nums = [5, 1, 4, 3, 6, 2, 7, 8, 10, 9]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumOfBeauties", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def sumOfBeauties(self, nums: list[int]) -> int:", "container": "Solution", "callable": "sumOfBeauties", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2014, "task_id": "longest-subsequence-repeated-k-times", "difficulty": "Hard", "problem_description": "You are given a string s of length n, and an integer k. You are tasked to find the longest subsequence repeated k times in string s.\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\nA subsequence seq is repeated k times in the string s if seq * k is a subsequence of s, where seq * k represents a string constructed by concatenating seq k times.\n\nFor example, \"bba\" is repeated 2 times in the string \"bababcba\", because the string \"bbabba\", constructed by concatenating \"bba\" 2 times, is a subsequence of the string \"bababcba\".\n\nReturn the longest subsequence repeated k times in string s. If multiple such subsequences are found, return the lexicographically largest one. If there is no such subsequence, return an empty string.\n \nExample 1:\n\n\nInput: s = \"letsleetcode\", k = 2\nOutput: \"let\"\nExplanation: There are two longest subsequences repeated 2 times: \"let\" and \"ete\".\n\"let\" is the lexicographically largest one.\n\nExample 2:\n\nInput: s = \"bb\", k = 2\nOutput: \"b\"\nExplanation: The longest subsequence repeated 2 times is \"b\".\n\nExample 3:\n\nInput: s = \"ab\", k = 2\nOutput: \"\"\nExplanation: There is no subsequence repeated 2 times. Empty string is returned.\n\n \nConstraints:\n\nn == s.length\n2 <= n, k <= 2000\n2 <= n < k * 8\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbcc\",k = 3) == \"\"\n assert candidate(s = \"zzzzzzzzz\",k = 4) == \"zz\"\n assert candidate(s = \"zzzzzzzzzz\",k = 5) == \"zz\"\n assert candidate(s = \"abcabcabcabc\",k = 4) == \"abc\"\n assert candidate(s = \"abcdabcabc\",k = 3) == \"abc\"\n assert candidate(s = \"abababababab\",k = 3) == \"abab\"\n assert candidate(s = \"aabbbccccc\",k = 3) == \"c\"\n assert candidate(s = \"letsleetcode\",k = 2) == \"let\"\n assert candidate(s = \"ab\",k = 2) == \"\"\n assert candidate(s = \"zzzzzzzzzzzzzz\",k = 5) == \"zz\"\n assert candidate(s = \"aaaabbbbcccc\",k = 2) == \"cc\"\n assert candidate(s = \"aaaabbbb\",k = 2) == \"bb\"\n assert candidate(s = \"aabbccddeeff\",k = 2) == \"f\"\n assert candidate(s = \"abcabcabc\",k = 3) == \"abc\"\n assert candidate(s = \"abcdabcdabcd\",k = 3) == \"abcd\"\n assert candidate(s = \"bb\",k = 2) == \"b\"\n assert candidate(s = \"abcdeabcdeabcde\",k = 3) == \"abcde\"\n assert candidate(s = \"abcdefghi\",k = 1) == \"abcdefghi\"\n assert candidate(s = \"aabbcc\",k = 2) == \"c\"\n assert candidate(s = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",k = 16) == \"qq\"\n assert candidate(s = \"mnopmnopmnop\",k = 6) == \"\"\n assert candidate(s = \"abcabcabcabc\",k = 3) == \"cab\"\n assert candidate(s = \"abcdefabcdefabcdefabcdef\",k = 4) == \"abcdef\"\n assert candidate(s = \"aabbaaccdd\",k = 3) == \"a\"\n assert candidate(s = \"abcdefgabcdefgabcdefg\",k = 3) == \"abcdefg\"\n assert candidate(s = \"kkkkkkkkkkkkkkkk\",k = 16) == \"k\"\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\",k = 3) == \"i\"\n assert candidate(s = \"abcdefghijklaaaaaaabbbbbbbbbccccccccc\",k = 5) == \"cc\"\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 8) == \"yxyx\"\n assert candidate(s = \"abababababababababababababab\",k = 7) == \"abab\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 5) == \"zzzz\"\n assert candidate(s = \"aabaaaabbbaaa\",k = 4) == \"aa\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\",k = 2) == \"xyzxyzxyz\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbcccccccccccccc\",k = 5) == \"aaa\"\n assert candidate(s = \"ababababababababababababababababab\",k = 10) == \"ba\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabad\",k = 4) == \"abaabaaba\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\",k = 5) == \"cabcab\"\n assert candidate(s = \"mississippi\",k = 2) == \"ssi\"\n assert candidate(s = \"ppppqqrrrrrssstttt\",k = 3) == \"t\"\n assert candidate(s = \"abcabcabcabcabcabcabc\",k = 3) == \"cabcab\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzz\",k = 10) == \"z\"\n assert candidate(s = \"abcabcabcabcabcabc\",k = 3) == \"abcabc\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 20) == \"zzz\"\n assert candidate(s = \"abababababababab\",k = 8) == \"ab\"\n assert candidate(s = \"mnopqrqponmlkjihgfedcba\",k = 2) == \"q\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 5) == \"abcabc\"\n assert candidate(s = \"qqwweerrttyyuuiiooppllaaasssdddfffggghhjjkk\",k = 3) == \"s\"\n assert candidate(s = \"aabbccddeeefffggg\",k = 2) == \"g\"\n assert candidate(s = \"aaabbbcccddd\",k = 3) == \"d\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 5) == \"dabcdabc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 10) == \"abc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabca\",k = 5) == \"bcabca\"\n assert candidate(s = \"zzzzzzzzzzzz\",k = 5) == \"zz\"\n assert candidate(s = \"aaaabbbbccccdddddd\",k = 4) == \"d\"\n assert candidate(s = \"xzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzy\",k = 4) == \"zyxzyx\"\n assert candidate(s = \"aabbccddeeffgg\",k = 2) == \"g\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 20) == \"z\"\n assert candidate(s = \"ababababababab\",k = 4) == \"ba\"\n assert candidate(s = \"ababababababababab\",k = 5) == \"ba\"\n assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrsmnopqrs\",k = 3) == \"smnopqr\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\",k = 4) == \"abcdefghij\"\n assert candidate(s = \"aaaaaaaaaa\",k = 2) == \"aaaaa\"\n assert candidate(s = \"qwertyqwertyqwerty\",k = 3) == \"qwerty\"\n assert candidate(s = \"xyzzzzzzzzzzzxyzzzzzzzzzzzzxyzzzzzzzzzzzz\",k = 3) == \"xyzzzzzzzzzzz\"\n assert candidate(s = \"ababababababababababababababababab\",k = 16) == \"ba\"\n assert candidate(s = \"aabbccddeeefff\",k = 2) == \"f\"\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\",k = 6) == \"fabcde\"\n assert candidate(s = \"abcdefgabcdefgabcdefg\",k = 2) == \"gabcdef\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == \"zzzz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 25) == \"z\"\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiii\",k = 4) == \"\"\n assert candidate(s = \"abcdabcdbacdb\",k = 2) == \"cdab\"\n assert candidate(s = \"xyxyxyxyxyxy\",k = 4) == \"yx\"\n assert candidate(s = \"abcabcabcabcabcabcabcabc\",k = 4) == \"abcabc\"\n assert candidate(s = \"aabaaabaaabaaabaaab\",k = 5) == \"aab\"\n assert candidate(s = \"abcdefghijklaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbcccccccccccccc\",k = 6) == \"bbb\"\n assert candidate(s = \"abcabcabcabcabc\",k = 5) == \"abc\"\n assert candidate(s = \"mmmmmmnnnnnnnnnnoooooo\",k = 5) == \"nn\"\n assert candidate(s = \"mmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxxyyyyyzzzzz\",k = 5) == \"z\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\",k = 8) == \"abcd\"\n assert candidate(s = \"zzzzzzzzzzzzz\",k = 5) == \"zz\"\n assert candidate(s = \"axbyczdxeyfzgyhz\",k = 2) == \"xyz\"\n assert candidate(s = \"aaabbbcccdddeeefff\",k = 4) == \"\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\",k = 10) == \"zxy\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 2) == \"z\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",k = 3) == \"abcdefghij\"\n assert candidate(s = \"abcdefghabcdefghabcdefgh\",k = 3) == \"abcdefgh\"\n assert candidate(s = \"zzzzyyyxxxwww\",k = 4) == \"z\"\n assert candidate(s = \"xyzxyzxyzxyzxyz\",k = 4) == \"zxy\"\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().longestSubsequenceRepeatedK", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def longestSubsequenceRepeatedK(self, s: str, k: int) -> str:", "container": "Solution", "callable": "longestSubsequenceRepeatedK", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2016, "task_id": "maximum-difference-between-increasing-elements", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums of size n, find the maximum difference between nums[i] and nums[j] (i.e., nums[j] - nums[i]), such that 0 <= i < j < n and nums[i] < nums[j].\nReturn the maximum difference. If no such i and j exists, return -1.\n \nExample 1:\n\nInput: nums = [7,1,5,4]\nOutput: 4\nExplanation:\nThe maximum difference occurs with i = 1 and j = 2, nums[j] - nums[i] = 5 - 1 = 4.\nNote that with i = 1 and j = 0, the difference nums[j] - nums[i] = 7 - 1 = 6, but i > j, so it is not valid.\n\nExample 2:\n\nInput: nums = [9,4,3,2]\nOutput: -1\nExplanation:\nThere is no i and j such that i < j and nums[i] < nums[j].\n\nExample 3:\n\nInput: nums = [1,5,2,10]\nOutput: 9\nExplanation:\nThe maximum difference occurs with i = 0 and j = 3, nums[j] - nums[i] = 10 - 1 = 9.\n\n \nConstraints:\n\nn == nums.length\n2 <= n <= 1000\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [9, 4, 3, 2]) == -1\n assert candidate(nums = [5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 2, 999999999]) == 999999998\n assert candidate(nums = [1, 100, 1, 100, 1]) == 99\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [1, 999999999, 2, 999999998]) == 999999998\n assert candidate(nums = [10, 20, 20, 10, 30]) == 20\n assert candidate(nums = [1, 5, 2, 10]) == 9\n assert candidate(nums = [1, 1, 1, 1]) == -1\n assert candidate(nums = [1, 3, 2, 4, 3, 5]) == 4\n assert candidate(nums = [10, 1, 10, 1, 10]) == 9\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [7, 1, 5, 4]) == 4\n assert candidate(nums = [1, 3, 6, 7, 9, 14, 10]) == 13\n assert candidate(nums = [1, 2, 1, 2, 1]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 11]) == 1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 8\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [1000000000, 999999999, 999999998, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1000000000, 999999999, 1, 1000000000, 2, 999999998, 3, 1000000000, 4, 999999997]) == 999999999\n assert candidate(nums = [100, 100, 100, 100, 101, 100, 100, 100]) == 1\n assert candidate(nums = [2, 3, 10, 6, 4, 8, 1, 5, 7, 9]) == 8\n assert candidate(nums = [10, 1, 2, 8, 1, 5, 6, 3, 9]) == 8\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 18\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997]) == 999999999\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 38\n assert candidate(nums = [3, 2, 1, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 29\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 1\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 9\n assert candidate(nums = [1, 3, 2, 3, 100, 1, 2, 3, 4]) == 99\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 9\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 31]) == 30\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 1\n assert candidate(nums = [2, 1, 5, 3, 4, 8, 7, 6, 9, 10, 1]) == 9\n assert candidate(nums = [8, 11, 9, 8, 10, 12]) == 4\n assert candidate(nums = [10, 9, 10, 8, 9, 7, 8, 6, 7, 5, 6, 4, 5, 3, 4, 2, 3, 1, 2]) == 1\n assert candidate(nums = [1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 9\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 150]) == 50\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 90\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 9\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == 14\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 11, 12, 13]) == 12\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == -1\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 10\n assert candidate(nums = [999999999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 99\n assert candidate(nums = [3, 3, 3, 1, 2, 2, 2, 5, 5, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12]) == 11\n assert candidate(nums = [1, 2, 3, 100, 1, 2, 3, 101, 1, 2, 3, 102, 1, 2, 3, 103, 1, 2, 3, 104]) == 103\n assert candidate(nums = [3, 3, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 8\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 2\n assert candidate(nums = [5, 1, 4, 3, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 18\n assert candidate(nums = [5, 2, 6, 1, 9, 4, 3, 7, 8]) == 8\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == -1\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 10, 40, 35, 45, 50]) == 45\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 5, 3, 7, 9, 2, 6, 8, 4, 10]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1]) == 90\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(nums = [5, 3, 6, 7, 2, 5, 4, 8, 9, 1]) == 7\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 21]) == 20\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [5, 4, 3, 2, 1, 10]) == 9\n assert candidate(nums = [3, 3, 3, 1, 1, 1, 2, 2, 2, 5, 5, 5, 4, 4, 4]) == 4\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 9\n assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == 10\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 9\n assert candidate(nums = [5, 11, 2, 14, 1, 3, 10, 6, 12, 4, 15, 8]) == 14\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == -1\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4, 104, 5, 105, 6, 106, 7, 107, 8, 108, 9, 109, 10]) == 108\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [5, 1, 9, 2, 8, 3, 7, 4, 6, 10, 1, 9, 2, 8, 3, 7, 4, 6, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [3, 2, 6, 5, 0, 3]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [50, 20, 30, 10, 40, 60, 25, 35, 55, 45, 70, 65, 80, 75, 90, 85, 100, 95]) == 90\n assert candidate(nums = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 11\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11]) == 10\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996]) == 999999999\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 100, 5, 6, 7, 8, 9, 10]) == 99\n assert candidate(nums = [5, 2, 3, 1, 4, 7, 6, 8]) == 7\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 9\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2]) == -1\n assert candidate(nums = [100, 100, 100, 100, 101, 100, 100, 100, 100, 100]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18]) == 99\n assert candidate(nums = [50, 25, 75, 100, 200, 150, 175, 225, 275, 300, 250, 325, 350]) == 325\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40]) == 40\n assert candidate(nums = [10, 5, 1, 7, 3, 6, 4]) == 6\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 1000000001]) == 5\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4, 104, 5]) == 103\n assert candidate(nums = [5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumDifference(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maximumDifference", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2017, "task_id": "grid-game", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 2D array grid of size 2 x n, where grid[r][c] represents the number of points at position (r, c) on the matrix. Two robots are playing a game on this matrix.\nBoth robots initially start at (0, 0) and want to reach (1, n-1). Each robot may only move to the right ((r, c) to (r, c + 1)) or down ((r, c) to (r + 1, c)).\nAt the start of the game, the first robot moves from (0, 0) to (1, n-1), collecting all the points from the cells on its path. For all cells (r, c) traversed on the path, grid[r][c] is set to 0. Then, the second robot moves from (0, 0) to (1, n-1), collecting the points on its path. Note that their paths may intersect with one another.\nThe first robot wants to minimize the number of points collected by the second robot. In contrast, the second robot wants to maximize the number of points it collects. If both robots play optimally, return the number of points collected by the second robot.\n \nExample 1:\n\n\nInput: grid = [[2,5,4],[1,5,1]]\nOutput: 4\nExplanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.\nThe cells visited by the first robot are set to 0.\nThe second robot will collect 0 + 0 + 4 + 0 = 4 points.\n\nExample 2:\n\n\nInput: grid = [[3,3,1],[8,5,2]]\nOutput: 4\nExplanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.\nThe cells visited by the first robot are set to 0.\nThe second robot will collect 0 + 3 + 1 + 0 = 4 points.\n\nExample 3:\n\n\nInput: grid = [[1,3,1,15],[1,3,3,1]]\nOutput: 7\nExplanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.\nThe cells visited by the first robot are set to 0.\nThe second robot will collect 0 + 1 + 3 + 3 + 0 = 7 points.\n\n \nConstraints:\n\ngrid.length == 2\nn == grid[r].length\n1 <= n <= 5 * 104\n1 <= grid[r][c] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == 9\n assert candidate(grid = [[1, 3, 1, 15], [1, 3, 3, 1]]) == 7\n assert candidate(grid = [[2, 5, 4], [1, 5, 1]]) == 4\n assert candidate(grid = [[10, 10, 10], [1, 1, 1]]) == 2\n assert candidate(grid = [[3, 3, 1], [8, 5, 2]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]]) == 9\n assert candidate(grid = [[100, 200, 300, 400, 500], [500, 400, 300, 200, 100]]) == 900\n assert candidate(grid = [[100000, 100000, 100000, 100000, 100000], [1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 10, 3, 40, 5, 60, 7, 80, 9, 100], [100, 9, 80, 7, 60, 5, 40, 3, 20, 1]]) == 256\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[100000, 100000, 100000], [1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]]) == 19\n assert candidate(grid = [[100000, 90000, 80000, 70000, 60000, 50000], [50000, 60000, 70000, 80000, 90000, 100000]]) == 180000\n assert candidate(grid = [[23456, 12345, 67890, 45678, 34567], [76543, 89012, 12345, 67890, 54321]]) == 148135\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 84\n assert candidate(grid = [[100000, 1, 100000, 1, 100000, 1], [1, 100000, 1, 100000, 1, 100000]]) == 100002\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 155\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 15\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 7\n assert candidate(grid = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 75\n assert candidate(grid = [[5, 10, 15, 20, 25, 30, 35], [35, 30, 25, 20, 15, 10, 5]]) == 90\n assert candidate(grid = [[7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [16, 15, 14, 13, 12, 11, 10, 9, 8, 7]]) == 70\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10]]) == 90\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 25\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 8\n assert candidate(grid = [[5, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 5]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 27\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]) == 35\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(grid = [[100000, 99999, 99998, 99997, 99996], [1, 2, 3, 4, 5]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]]) == 9\n assert candidate(grid = [[99999, 99998, 99997, 99996, 99995], [1, 2, 3, 4, 5]]) == 10\n assert candidate(grid = [[1, 1, 100000], [100000, 1, 1]]) == 100000\n assert candidate(grid = [[100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1], [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]]) == 200003\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 13\n assert candidate(grid = [[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]]) == 4000\n assert candidate(grid = [[100000, 99999, 99998, 99997, 99996], [1, 2, 3, 4, 5]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 6\n assert candidate(grid = [[10, 20, 30, 40, 50, 60], [60, 50, 40, 30, 20, 10]]) == 150\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 13\n assert candidate(grid = [[1, 100, 1], [100, 1, 100]]) == 100\n assert candidate(grid = [[1, 100000, 1, 100000, 1], [100000, 1, 100000, 1, 100000]]) == 100001\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(grid = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 89\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 40\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10]]) == 90\n assert candidate(grid = [[5, 4, 3, 2, 1], [1, 2, 3, 4, 5]]) == 3\n assert candidate(grid = [[100, 200, 300, 400, 500], [500, 400, 300, 200, 100]]) == 900\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 234\n assert candidate(grid = [[1, 99999, 99999, 99999, 99999], [99999, 99999, 99999, 99999, 99999]]) == 199998\n assert candidate(grid = [[5, 10, 15, 20, 25, 30], [30, 25, 20, 15, 10, 5]]) == 75\n assert candidate(grid = [[100000, 100000, 100000, 100000], [1, 1, 1, 1]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 40\n assert candidate(grid = [[100000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999]]) == 18\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 5, 5, 5, 5]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 9\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]]) == 23\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 84\n assert candidate(grid = [[1, 5, 2, 7, 3, 8, 4, 9], [9, 4, 8, 3, 7, 2, 5, 1]]) == 24\n assert candidate(grid = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2]]) == 3\n assert candidate(grid = [[100000, 100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000, 100000]]) == 200000\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 8\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 950\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 234\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100000], [100000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 100004\n assert candidate(grid = [[5000, 5000, 5000, 5000, 5000], [1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 155\n assert candidate(grid = [[100000, 100000, 100000, 100000, 100000], [1, 2, 3, 4, 5]]) == 10\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 30\n assert candidate(grid = [[1, 10, 100, 1000, 10000], [10000, 1000, 100, 10, 1]]) == 11000\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 15\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]]) == 9\n assert candidate(grid = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]]) == 200\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().gridGame", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def gridGame(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "gridGame", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2018, "task_id": "check-if-word-can-be-placed-in-crossword", "difficulty": "Medium", "problem_description": "You are given an m x n matrix board, representing the current state of a crossword puzzle. The crossword contains lowercase English letters (from solved words), ' ' to represent any empty cells, and '#' to represent any blocked cells.\nA word can be placed horizontally (left to right or right to left) or vertically (top to bottom or bottom to top) in the board if:\n\nIt does not occupy a cell containing the character '#'.\nThe cell each letter is placed in must either be ' ' (empty) or match the letter already on the board.\nThere must not be any empty cells ' ' or other lowercase letters directly left or right of the word if the word was placed horizontally.\nThere must not be any empty cells ' ' or other lowercase letters directly above or below the word if the word was placed vertically.\n\nGiven a string word, return true if word can be placed in board, or false otherwise.\n \nExample 1:\n\n\nInput: board = [[\"#\", \" \", \"#\"], [\" \", \" \", \"#\"], [\"#\", \"c\", \" \"]], word = \"abc\"\nOutput: true\nExplanation: The word \"abc\" can be placed as shown above (top to bottom).\n\nExample 2:\n\n\nInput: board = [[\" \", \"#\", \"a\"], [\" \", \"#\", \"c\"], [\" \", \"#\", \"a\"]], word = \"ac\"\nOutput: false\nExplanation: It is impossible to place the word because there will always be a space/letter above or below it.\nExample 3:\n\n\nInput: board = [[\"#\", \" \", \"#\"], [\" \", \" \", \"#\"], [\"#\", \" \", \"c\"]], word = \"ca\"\nOutput: true\nExplanation: The word \"ca\" can be placed as shown above (right to left). \n\n \nConstraints:\n\nm == board.length\nn == board[i].length\n1 <= m * n <= 2 * 105\nboard[i][j] will be ' ', '#', or a lowercase English letter.\n1 <= word.length <= max(m, n)\nword will contain only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', '#'], ['#', ' ', 'c']],word = \"ca\") == True\n assert candidate(board = [['a'], ['b'], ['c'], ['d'], ['e']],word = \"abcde\") == True\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', '#'], ['#', ' ', 'c']],word = \"ca\") == True\n assert candidate(board = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']],word = \"ihg\") == True\n assert candidate(board = [['a', ' ', 'a'], [' ', ' ', ' '], ['a', ' ', 'a']],word = \"aba\") == True\n assert candidate(board = [['#', ' ', '#'], ['a', 'b', 'c'], ['#', ' ', '#']],word = \"cba\") == True\n assert candidate(board = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']],word = \"def\") == True\n assert candidate(board = [['a', 'b', 'c'], ['#', '#', '#'], ['g', 'h', 'i']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' '], ['#', 'a', '#'], [' ', ' ', ' ']],word = \"a\") == True\n assert candidate(board = [['#', '#', '#'], ['#', ' ', '#'], ['#', ' ', '#']],word = \"a\") == True\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', '#'], ['#', 'c', ' ']],word = \"abc\") == True\n assert candidate(board = [[' ', '#', 'a'], [' ', '#', 'c'], [' ', '#', 'a']],word = \"ac\") == False\n assert candidate(board = [[' ', '#', 'a'], [' ', '#', 'c'], [' ', '#', 'a']],word = \"ac\") == False\n assert candidate(board = [[' ', ' ', ' ', '#'], [' ', ' ', ' ', '#'], [' ', ' ', ' ', '#']],word = \"test\") == False\n assert candidate(board = [['#', '#', '#'], [' ', ' ', ' '], ['#', '#', '#']],word = \"ab\") == False\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', '#'], ['#', 'c', ' ']],word = \"abc\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"test\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"python\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ']],word = \"abcd\") == True\n assert candidate(board = [['#', '#', 'a', '#', '#'], ['#', '#', 'b', '#', '#'], ['#', '#', 'c', '#', '#'], ['#', '#', 'd', '#', '#'], ['#', '#', '#', '#', '#']],word = \"abcd\") == True\n assert candidate(board = [[' ', ' ', '#', '#', '#', ' '], [' ', ' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ', ' '], [' ', ' ', '#', '#', '#', ' ']],word = \"test\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['a', 'b', 'c', 'd', 'e'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#', '#']],word = \"abcdefg\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], [' ', 'a', ' ', 'b', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [['#', 'a', '#'], ['b', ' ', 'c'], ['#', 'd', '#'], [' ', 'e', ' ']],word = \"abcde\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"find\") == False\n assert candidate(board = [[' ', '#', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', ' ', ' ', '#']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', ' ', ' ', '#'], ['#', '#', '#', '#']],word = \"a\") == False\n assert candidate(board = [['a', 'b', 'c'], ['#', '#', '#'], [' ', ' ', ' '], [' ', ' ', ' '], ['#', 'a', 'b']],word = \"abc\") == True\n assert candidate(board = [[' ', '#', ' ', ' ', '#', ' '], ['#', ' ', '#', ' ', '#', '#'], [' ', '#', ' ', '#', ' ', ' '], ['#', '#', ' ', '#', ' ', '#']],word = \"hello\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"ghijkl\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', 'a', ' ', ' '], ['#', ' ', 'b', ' '], ['#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], ['#', 'a', ' ', ' '], ['#', ' ', 'b', ' '], ['#', ' ', ' ', 'c']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"hello\") == True\n assert candidate(board = [['#', ' ', '#'], ['a', 'b', 'c'], [' ', ' ', ' '], ['d', 'e', 'f'], ['#', ' ', '#']],word = \"abcdef\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [['#', ' ', '#', ' '], [' ', ' ', ' ', ' '], [' ', ' ', '#', ' '], [' ', ' ', ' ', ' ']],word = \"ab\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', 'a', ' ', ' '], [' ', ' ', 'b', ' '], ['#', ' ', ' ', 'c']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', ' ', ' ', 'a'], ['#', '#', 'b', 'c']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['a', 'b', 'c', 'd', 'e'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', '#', '#', ' '], [' ', ' ', ' ', ' ']],word = \"ab\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['c', 'b', 'a', ' ', ' '], [' ', 'd', 'e', 'f', ' '], ['#', ' ', '#', ' ', '#']],word = \"abcdef\") == False\n assert candidate(board = [[' ', '#', ' ', '#', ' '], ['#', 'a', '#', ' ', '#'], ['#', '#', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', ' ']],word = \"abc\") == False\n assert candidate(board = [['#', '#', '#'], ['#', ' ', '#'], ['#', ' ', '#'], ['#', '#', '#']],word = \"ab\") == True\n assert candidate(board = [['#', '#', '#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', ' ', ' ', '#'], ['#', ' ', '#', '#', '#', ' ', '#'], ['#', ' ', '#', 'a', '#', ' ', '#'], ['#', ' ', '#', 'b', '#', ' ', '#'], ['#', ' ', '#', 'c', '#', ' ', '#'], ['#', '#', '#', '#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [['#', 'a', '#'], ['#', '#', '#'], ['#', 'a', '#']],word = \"aa\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['#', 'a', '#', 'c', '#'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"ac\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], ['#', 'a', 'b', '#'], [' ', ' ', ' ', ' '], ['#', 'd', 'c', '#']],word = \"abcd\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', 'a', ' ', 'b', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"ab\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', ' ', ' ', '#'], ['#', '#', ' ', '#', '#', ' ', '#'], ['#', ' ', 'a', ' ', ' ', ' ', '#'], ['#', '#', ' ', 'b', '#', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', '#']],word = \"abc\") == True\n assert candidate(board = [[' ', '#', ' ', '#', ' '], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], [' ', '#', ' ', '#', ' ']],word = \"test\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['e', 'd', 'c', 'b', 'a'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['#', 'a', 'b', 'c', '#'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"cba\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', 'a', ' ', ' ', '#'], ['#', ' ', ' ', 'b', '#'], ['#', ' ', 'c', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', '#', ' ', ' '], ['#', ' ', 'a', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', 'c', ' ', '#'], [' ', ' ', '#', ' ', ' ']],word = \"play\") == False\n assert candidate(board = [[' ', '#', '#', '#', ' '], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', '#', '#', '#', ' ']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"mnopqr\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"abcdef\") == True\n assert candidate(board = [['#', '#', '#', '#'], ['#', ' ', ' ', '#'], ['#', ' ', ' ', '#'], ['#', '#', '#', '#']],word = \"word\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' '], ['#', 'a', ' ', ' ', 'b', '#'], ['#', ' ', ' ', ' ', ' ', '#'], ['#', 'c', ' ', ' ', 'd', '#'], ['#', ' ', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#', '#']],word = \"abcd\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"abc\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"abcdefghi\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', 'a', ' ', ' '], [' ', ' ', 'b', ' '], [' ', ' ', ' ', 'c']],word = \"abc\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"python\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ']],word = \"world\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#']],word = \"abcdef\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', 'a', ' ', 'a', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#']],word = \"banana\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#', ' ', '#'], ['#', 'a', '#', 'b', '#', 'c', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', 'd', '#', 'e', '#', 'f', '#'], ['#', ' ', '#', ' ', '#', ' ', '#']],word = \"abcdef\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', 'a', '#', '#'], ['#', '#', 'b', '#', '#'], ['#', '#', 'c', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"abc\") == False\n assert candidate(board = [[' ', '#', ' ', ' ', ' '], [' ', ' ', ' ', '#', ' '], [' ', '#', ' ', ' ', ' '], [' ', ' ', ' ', '#', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', '#', ' ', ' '], ['#', 'a', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [['a', 'b', ' ', 'd', 'e'], ['#', '#', 'c', '#', '#'], ['e', 'd', ' ', 'b', 'a'], ['#', '#', 'c', '#', '#'], ['a', 'b', ' ', 'd', 'e']],word = \"abcde\") == True\n assert candidate(board = [[' ', '#', '#', '#', ' '], ['#', 'a', '#', 'b', '#'], ['#', '#', '#', '#', '#'], ['#', 'c', '#', 'd', '#'], [' ', '#', '#', '#', ' ']],word = \"abcd\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', 'a', '#', ' '], ['#', 'b', '#', ' '], ['#', 'c', '#', ' ']],word = \"abc\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"abcdef\") == True\n assert candidate(board = [['#', 'a', 'b', 'c', '#'], [' ', ' ', ' ', ' ', ' '], ['#', 'd', 'e', 'f', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"abcdef\") == False\n assert candidate(board = [['#', 'a', '#', 'b', '#'], [' ', ' ', ' ', ' ', ' '], ['#', 'c', '#', 'd', '#'], [' ', ' ', ' ', ' ', ' '], ['#', 'e', '#', 'f', '#']],word = \"abcdef\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"abcd\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], ['#', '#', ' ', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', ' ', '#', '#'], ['#', ' ', ' ', ' ', '#']],word = \"game\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', '#', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', 'k', ' ', ' ', 'l', ' '], ['#', ' ', ' ', ' ', ' ', ' ', 'm'], ['#', '#', '#', '#', '#', '#', '#']],word = \"klm\") == True\n assert candidate(board = [['#', ' ', '#'], [' ', 'a', ' '], ['#', ' ', '#'], [' ', 'b', ' '], ['#', ' ', '#']],word = \"aba\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#']],word = \"a\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' '], ['#', 'a', '#', 'b', '#', 'c'], [' ', ' ', ' ', ' ', ' ', ' '], ['#', 'd', '#', 'e', '#', 'f'], [' ', ' ', ' ', ' ', ' ', ' ']],word = \"abcdef\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"world\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', 'j'], ['#', ' ', '#', ' ', '#', ' ', 'i'], ['#', ' ', ' ', ' ', ' ', ' ', 'h'], ['#', ' ', '#', ' ', '#', ' ', 'g'], ['#', ' ', ' ', ' ', ' ', ' ', 'f'], ['#', '#', '#', '#', '#', '#', '#']],word = \"ghij\") == False\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', ' '], [' ', ' ', '#'], [' ', '#', ' ']],word = \"abc\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], [' ', ' ', '#', ' ', ' '], [' ', 'a', '#', 'b', ' '], ['#', ' ', '#', ' ', '#']],word = \"abcd\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', 'a', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"aaa\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', ' ', ' ', '#'], [' ', 'g', ' ', 'h', ' ', 'i', ' '], ['#', ' ', '#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#', '#', '#']],word = \"ghji\") == True\n assert candidate(board = [['#', '#', '#', '#'], ['#', ' ', ' ', ' '], ['#', ' ', '#', ' '], ['#', ' ', ' ', ' '], ['#', '#', '#', '#']],word = \"code\") == False\n assert candidate(board = [['#', 'a', 'b', 'c'], ['#', 'd', 'e', 'f'], ['#', 'g', 'h', 'i'], ['#', 'j', 'k', 'l']],word = \"mnop\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abcd\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', ' '], ['#', ' ', 'a', ' ', ' '], ['#', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', ' ']],word = \"abc\") == False\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', 'a', '#', 'b', '#'], ['#', '#', '#', '#', '#'], ['#', 'c', '#', 'd', '#'], ['#', '#', '#', '#', '#']],word = \"abcd\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', '#', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', 'n', ' ', ' ', 'o', ' '], ['#', ' ', ' ', ' ', ' ', ' ', 'p'], ['#', '#', '#', '#', '#', '#', '#']],word = \"pon\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"abc\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', 'a', 'b', 'c', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"abc\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', ' ', ' ', '#'], ['#', '#', ' ', '#', '#', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', '#'], ['#', '#', ' ', '#', '#', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', '#']],word = \"abcdefgh\") == False\n assert candidate(board = [[' ', ' ', ' ', '#'], [' ', ' ', ' ', '#'], [' ', ' ', ' ', '#'], [' ', ' ', ' ', '#'], ['a', 'b', 'c', 'd']],word = \"abcd\") == True\n assert candidate(board = [['a', ' ', 'c'], ['b', ' ', 'd'], [' ', ' ', ' ']],word = \"abcd\") == False\n assert candidate(board = [[' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' ']],word = \"abacaba\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#', ' ', '#'], [' ', 'a', ' ', 'b', ' ', 'c', ' '], ['#', ' ', '#', ' ', '#', ' ', '#'], [' ', 'd', ' ', 'e', ' ', 'f', ' ']],word = \"abcdef\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', 'a', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', 'c', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"race\") == False\n assert candidate(board = [['#', ' ', ' ', '#'], [' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', ' ', ' ', '#']],word = \"word\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#', ' ', '#'], ['#', 'g', '#', 'h', '#', 'i', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', 'j', '#', 'k', '#', 'l', '#'], ['#', ' ', '#', ' ', '#', ' ', '#']],word = \"ghijkl\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#']],word = \"word\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', '#', ' ', ' '], [' ', ' ', ' ', ' ']],word = \"a\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', ' ', '#'], ['#', 'b', 'c', '#'], ['#', ' ', ' ', '#'], ['#', 'd', ' ', 'e']],word = \"bcde\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"hello\") == False\n assert candidate(board = [['a', 'b', 'c', 'd', 'e'], ['#', '#', '#', '#', '#'], ['e', 'd', 'c', 'b', 'a'], ['#', '#', '#', '#', '#'], ['a', 'b', 'c', 'd', 'e']],word = \"abcde\") == True\n assert candidate(board = [['#', '#', '#'], ['a', ' ', 'a'], ['#', ' ', '#'], ['b', ' ', 'b'], ['#', '#', '#']],word = \"aba\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"java\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', 'a', ' ', 'a', ' '], ['#', ' ', '#', ' ', '#'], [' ', 'b', ' ', 'b', ' '], ['#', ' ', '#', ' ', '#']],word = \"abba\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', 'a', 'b', 'c', ' '], ['#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [['#', '#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', ' ', '#'], ['#', ' ', 'a', 'b', ' ', '#'], ['#', ' ', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#', '#']],word = \"ab\") == False\n assert candidate(board = [[' ', ' ', '#', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', '#', ' ', ' ']],word = \"hello\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], ['#', ' ', 'a', ' ', '#'], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"a\") == True\n assert candidate(board = [['a', ' ', ' ', '#'], [' ', 'b', ' ', '#'], [' ', ' ', 'c', ' '], ['#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"car\") == True\n assert candidate(board = [['#', '#', '#'], ['#', '#', '#'], ['#', '#', '#']],word = \"a\") == False\n assert candidate(board = [['a', 'b', 'c'], ['d', '#', 'e'], ['f', 'g', 'h'], ['i', 'j', 'k']],word = \"def\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', '#', 'a', '#', ' '], [' ', '#', ' ', '#', ' '], [' ', '#', 'b', '#', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"ba\") == False\n assert candidate(board = [['#', ' ', '#'], ['a', ' ', 'b'], ['#', ' ', '#'], ['c', ' ', 'd'], ['#', ' ', '#']],word = \"abcd\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', '#', '#', ' '], [' ', '#', '#', ' '], [' ', ' ', ' ', ' ']],word = \"abcd\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [['#', ' ', '#'], ['f', 'e', 'd'], [' ', ' ', ' '], ['c', 'b', 'a'], ['#', ' ', '#']],word = \"abcdef\") == False\n assert candidate(board = [[' ', '#', ' ', '#', ' '], ['#', 'a', '#', 'c', '#'], [' ', '#', ' ', '#', ' '], ['#', ' ', '#', 'a', '#']],word = \"ca\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', 'a', 'b', 'c'], [' ', ' ', ' ', ' ']],word = \"abc\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', '#'], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', '#'], ['#', ' ', '#', ' ', '#']],word = \"abcde\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', 'c', 'b', 'a', ' '], ['#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"cross\") == True\n"}, "metadata": {"canonical_parameter_names": ["board", "word"], "leetcode_dataset_entry_point": "Solution().placeWordInCrossword", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def placeWordInCrossword(self, board: list[list[str]], word: str) -> bool:", "container": "Solution", "callable": "placeWordInCrossword", "parameters": [{"name": "board", "type": "list[list[str]]"}, {"name": "word", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2019, "task_id": "the-score-of-students-solving-math-expression", "difficulty": "Hard", "problem_description": "You are given a string s that contains digits 0-9, addition symbols '+', and multiplication symbols '*' only, representing a valid math expression of single digit numbers (e.g., 3+5*2). This expression was given to n elementary school students. The students were instructed to get the answer of the expression by following this order of operations:\n\nCompute multiplication, reading from left to right; Then,\nCompute addition, reading from left to right.\n\nYou are given an integer array answers of length n, which are the submitted answers of the students in no particular order. You are asked to grade the answers, by following these rules:\n\nIf an answer equals the correct answer of the expression, this student will be rewarded 5 points;\nOtherwise, if the answer could be interpreted as if the student applied the operators in the wrong order but had correct arithmetic, this student will be rewarded 2 points;\nOtherwise, this student will be rewarded 0 points.\n\nReturn the sum of the points of the students.\n \nExample 1:\n\n\nInput: s = \"7+3*1*2\", answers = [20,13,42]\nOutput: 7\nExplanation: As illustrated above, the correct answer of the expression is 13, therefore one student is rewarded 5 points: [20,13,42]\nA student might have applied the operators in this wrong order: ((7+3)*1)*2 = 20. Therefore one student is rewarded 2 points: [20,13,42]\nThe points for the students are: [2,5,0]. The sum of the points is 2+5+0=7.\n\nExample 2:\n\nInput: s = \"3+5*2\", answers = [13,0,10,13,13,16,16]\nOutput: 19\nExplanation: The correct answer of the expression is 13, therefore three students are rewarded 5 points each: [13,0,10,13,13,16,16]\nA student might have applied the operators in this wrong order: ((3+5)*2 = 16. Therefore two students are rewarded 2 points: [13,0,10,13,13,16,16]\nThe points for the students are: [5,0,0,5,5,2,2]. The sum of the points is 5+0+0+5+5+2+2=19.\n\nExample 3:\n\nInput: s = \"6+0*1\", answers = [12,9,6,4,8,6]\nOutput: 10\nExplanation: The correct answer of the expression is 6.\nIf a student had incorrectly done (6+0)*1, the answer would also be 6.\nBy the rules of grading, the students will still be rewarded 5 points (as they got the correct answer), not 2 points.\nThe points for the students are: [0,0,5,0,0,5]. The sum of the points is 10.\n\n \nConstraints:\n\n3 <= s.length <= 31\ns represents a valid expression that contains only digits 0-9, '+', and '*' only.\nAll the integer operands in the expression are in the inclusive range [0, 9].\n1 <= The count of all operators ('+' and '*') in the math expression <= 15\nTest data are generated such that the correct answer of the expression is in the range of [0, 1000].\nn == answers.length\n1 <= n <= 104\n0 <= answers[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"3+5*2\",answers = [13, 0, 10, 13, 13, 16, 16]) == 19\n assert candidate(s = \"1+2*3+4*5\",answers = [14, 23, 13, 47, 23, 53]) == 2\n assert candidate(s = \"7+3*1*2\",answers = [20, 13, 42]) == 7\n assert candidate(s = \"5*4+3+2\",answers = [27, 20, 17, 25, 20, 30]) == 5\n assert candidate(s = \"5*3+2*2\",answers = [19, 17, 15, 13, 21]) == 5\n assert candidate(s = \"9*7+3*8\",answers = [78, 108, 70, 63, 136, 54, 110, 39, 103, 97]) == 0\n assert candidate(s = \"1+2*3+4\",answers = [11, 13, 15, 9]) == 9\n assert candidate(s = \"6+0*1\",answers = [12, 9, 6, 4, 8, 6]) == 10\n assert candidate(s = \"1+2*3+4\",answers = [23, 18, 21, 9, 10, 17, 14, 22, 20, 15]) == 4\n assert candidate(s = \"9+8*7+6*5+4*3+2*1\",answers = [268, 280, 292, 304, 316, 328, 340, 352, 364, 376]) == 0\n assert candidate(s = \"5+6*2+7*3+8*1\",answers = [63, 104, 80, 77, 63, 120]) == 2\n assert candidate(s = \"1*5+2*7+3*6+4\",answers = [56, 50, 47, 53, 58, 45, 51, 46, 49, 52]) == 2\n assert candidate(s = \"2*9+5*6*7+8\",answers = [226, 488, 628, 624, 226, 508]) == 0\n assert candidate(s = \"4*6+3*2+5*1+7*8+9*0\",answers = [74, 76, 78, 80, 82, 84, 86, 88, 90, 92]) == 2\n assert candidate(s = \"7+6*5+4*3+2*1\",answers = [181, 175, 169, 163, 157, 151, 145, 139, 133, 127]) == 4\n assert candidate(s = \"1*2*3*4*5+6\",answers = [126, 12, 36, 24, 126, 126]) == 15\n assert candidate(s = \"9*8+7*6+5*4\",answers = [203, 230, 247, 274, 263, 290, 307, 334, 343, 370]) == 0\n assert candidate(s = \"1+2*3+4*5+6\",answers = [71, 51, 83, 47, 79, 53, 77, 67, 89, 57, 59, 73, 41, 87, 85, 61, 65, 75]) == 20\n assert candidate(s = \"9+8*2*4+1\",answers = [153, 73, 161, 177, 145, 153]) == 4\n assert candidate(s = \"8*7+9*6+4\",answers = [158, 202, 156, 134, 164, 148, 162, 174]) == 0\n assert candidate(s = \"9+7*8+5*4\",answers = [155, 143, 139, 147, 135, 149, 153, 151, 157]) == 0\n assert candidate(s = \"7*3+1*2*4+6*5\",answers = [62, 122, 86, 74, 62, 86]) == 2\n assert candidate(s = \"1+2+3+4+5+6+7+8+9\",answers = [45, 44, 46, 43, 47, 42, 48, 41, 49]) == 5\n assert candidate(s = \"5*5*5+4*4*4+3*3*3+2*2*2+1*1*1\",answers = [657, 681, 679, 678, 680, 677, 676, 675, 674, 673, 672, 671, 670, 669, 668, 667, 666, 665, 664, 663]) == 14\n assert candidate(s = \"1*2*3+4*5+6*7+8*9\",answers = [204, 205, 203, 206, 202, 207, 201]) == 2\n assert candidate(s = \"8*9+7*6+5*4+3*2\",answers = [167, 173, 179, 185, 191, 197, 203, 209, 215, 221]) == 0\n assert candidate(s = \"3+8*5*2+7+6*4\",answers = [173, 185, 197, 209, 221, 233, 245, 257, 269, 281]) == 0\n assert candidate(s = \"5*6+7*2+8*1+9\",answers = [104, 100, 111, 110, 115, 120, 108, 116, 106, 118]) == 0\n assert candidate(s = \"2*3+4*5+6\",answers = [30, 46, 28, 52, 34, 38, 40, 42, 44, 50]) == 4\n assert candidate(s = \"3*4+2*5+1*6+8\",answers = [58, 54, 59, 65, 62, 68, 63, 66, 57, 60]) == 2\n assert candidate(s = \"5+9*3+8*2\",answers = [89, 71, 106, 58, 95, 125, 86, 92, 91]) == 2\n assert candidate(s = \"8*7+6*5+4*3+2*1\",answers = [134, 135, 133, 136, 132, 137, 131]) == 0\n assert candidate(s = \"1*2*3*4*5+6+7+8+9\",answers = [120, 150, 315, 369, 225, 252, 360, 270, 288]) == 7\n assert candidate(s = \"6+3*5*2+9*1\",answers = [48, 39, 69, 102, 57, 78]) == 0\n assert candidate(s = \"4*3+2*8+1*7+6\",answers = [63, 59, 66, 71, 60, 69, 64, 73, 68, 61]) == 0\n assert candidate(s = \"2*9+8*7+6*5+4*3\",answers = [192, 172, 162, 152, 187, 202, 207, 182, 197, 177, 167, 157, 184, 169, 159, 179, 199, 174, 189]) == 4\n assert candidate(s = \"2*1+1*2+3*2+2*3+4*3+3*4+5*4+4*5+6*5+5*6\",answers = [194, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214]) == 22\n assert candidate(s = \"1*2+3*4+5*6+7*8+9\",answers = [159, 173, 187, 201, 215, 229, 243, 257, 271, 285]) == 4\n assert candidate(s = \"6+5*4+3*2+1\",answers = [55, 51, 47, 43, 39, 35, 31, 27, 23, 19]) == 4\n assert candidate(s = \"9*8*7*6*5+4*3+2*1\",answers = [151230, 151228, 151229, 151231, 151232]) == 0\n assert candidate(s = \"9+1*8+2*3+7*4\",answers = [77, 81, 90, 83, 94, 100, 88, 97, 91, 105]) == 2\n assert candidate(s = \"9*8+7*6+5*4+3*2+1*0\",answers = [168, 172, 176, 180, 184, 188, 192, 196, 200, 204]) == 2\n assert candidate(s = \"2+3*4+5*6+7\",answers = [157, 172, 187, 202, 217, 232, 247, 262, 277, 292]) == 6\n assert candidate(s = \"9*0+8*1+7*2\",answers = [23, 15, 16, 8, 3, 17, 24, 22, 18, 9]) == 5\n assert candidate(s = \"1*2+3*4+5*6+7*8+9*0\",answers = [120, 93, 115, 132, 108, 114, 102, 130, 128, 124, 123, 125, 126, 127, 129, 121, 122, 131, 133, 134]) == 2\n assert candidate(s = \"1+1*1+1*1+1*1+1*1+1*1+1*1+1*1\",answers = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 25\n assert candidate(s = \"9*8+7*6+5*4+3*2+1\",answers = [383, 410, 437, 464, 491, 518, 545, 572, 599, 626]) == 4\n assert candidate(s = \"3*3+2*2+1*1\",answers = [15, 12, 13, 14, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(s = \"7*1+6*2+5*3\",answers = [47, 37, 41, 43, 49, 53, 55, 57, 61, 63]) == 2\n assert candidate(s = \"4*1*3+5*2\",answers = [22, 14, 16, 17, 18, 19, 20, 21, 23]) == 5\n assert candidate(s = \"9+8*7+6*5+4*3+2*1\",answers = [383, 357, 347, 358, 356, 365, 359, 348, 350, 351, 349, 352, 353, 354, 355, 346, 345, 364, 366, 367]) == 2\n assert candidate(s = \"8*2+3*9+4*1+5\",answers = [69, 76, 108, 98, 63, 110, 95, 80, 73, 83]) == 0\n assert candidate(s = \"8+9*2+3*4*5+6\",answers = [222, 185, 223, 197, 196, 231, 229, 226, 220, 225, 221, 228, 227, 219, 218, 217, 230, 232, 233, 234]) == 2\n assert candidate(s = \"9*9+8*8+7*7+6*6\",answers = [320, 311, 314, 317, 323, 332, 335, 338, 341, 347, 344, 350, 353, 356, 359, 365, 368, 371, 374, 380, 383, 386, 389, 395, 392, 398]) == 0\n assert candidate(s = \"8*9+7*6+5*4+3*2+1\",answers = [163, 177, 181, 185, 189, 193, 197, 201, 205, 209]) == 4\n assert candidate(s = \"9*2+1*6+4*5+8*3\",answers = [124, 122, 121, 126, 125, 123, 127, 120, 128, 119]) == 2\n assert candidate(s = \"2+3*4+5*6\",answers = [106, 110, 74, 86, 62, 140, 106, 128]) == 0\n assert candidate(s = \"9*3+8*2+7*1\",answers = [55, 63, 95, 100, 111, 120, 123, 115, 116, 119, 102, 87, 90, 83, 93]) == 0\n assert candidate(s = \"1*9+8*2+3*7+5\",answers = [85, 100, 80, 88, 93, 95, 91, 107, 105, 98]) == 0\n assert candidate(s = \"1*2+3*4+5*6\",answers = [101, 39, 45, 81, 29, 143, 51, 17, 135, 65]) == 0\n assert candidate(s = \"6*4+3*2+1*5+7\",answers = [45, 43, 47, 52, 46, 44, 48, 50, 49, 51]) == 2\n assert candidate(s = \"2*3+4*5+6*7+8*9+0\",answers = [234, 248, 262, 276, 290, 304, 318, 332, 346, 360]) == 0\n assert candidate(s = \"2+3*4+5*6+7\",answers = [107, 110, 113, 104, 116, 109, 115, 108, 111, 112]) == 2\n assert candidate(s = \"8*7+4*2+1\",answers = [65, 100, 57, 60, 93, 120, 81, 65, 96, 104]) == 10\n assert candidate(s = \"2*3+5*6+7\",answers = [41, 101, 38, 47, 110, 83, 37, 53, 61, 56]) == 2\n assert candidate(s = \"9*8+7*6+5*4+3*2+1\",answers = [234, 197, 207, 198, 209, 205, 214, 218, 216, 215, 213, 212, 210, 211, 208, 206, 204, 203, 202, 201]) == 2\n assert candidate(s = \"5*5+4*4+3*3+2*2\",answers = [105, 85, 135, 90, 110, 100, 120, 115, 130, 95, 101, 125, 80, 91, 87, 83, 89]) == 6\n assert candidate(s = \"1*3+2*4+5*6+7*8\",answers = [109, 113, 137, 141, 145, 149, 153, 161, 165, 169]) == 2\n assert candidate(s = \"3*6+2*7+8*9\",answers = [134, 132, 136, 130, 128, 138, 140, 126, 142]) == 2\n assert candidate(s = \"1*2+3*4+5*6+7*8\",answers = [497, 524, 551, 578, 605, 632, 659, 686, 713, 740]) == 2\n assert candidate(s = \"1+2+3+4+5+6+7+8+9+0\",answers = [45, 46, 44, 43, 47, 48, 42]) == 5\n assert candidate(s = \"4*2+1*3+5*6+7\",answers = [51, 49, 67, 51, 67, 69]) == 0\n assert candidate(s = \"9*1+8*2+7*3+6\",answers = [92, 110, 113, 92, 113, 110]) == 0\n assert candidate(s = \"8+7*6+5*4+3*2+1*0\",answers = [177, 185, 184, 186, 183, 182, 181, 180, 179, 178, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167]) == 2\n assert candidate(s = \"1*2+3*4+5*6+7*8+9*0\",answers = [88, 92, 96, 100, 104, 108, 112, 116, 120, 124]) == 7\n assert candidate(s = \"8*3+2*7+9*5+4*1\",answers = [124, 116, 127, 119, 118, 120, 121, 117, 126, 122]) == 2\n assert candidate(s = \"9*8+7*6+5*4+3*2+1*0\",answers = [162, 178, 194, 210, 226, 242, 258, 274, 290, 306]) == 4\n assert candidate(s = \"3*5+2*4+6\",answers = [33, 50, 38, 46, 40, 64, 54, 28, 58, 42]) == 0\n assert candidate(s = \"9+8*7*6*5*4*3*2*1\",answers = [362880, 51840, 29160, 120960, 60480, 90720]) == 0\n assert candidate(s = \"9+8*7+6*5+4*3+2*1+0\",answers = [389, 388, 390, 391, 387, 392, 386]) == 2\n assert candidate(s = \"1+2*3+4*5+6*7+8*9\",answers = [528, 526, 527, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545]) == 10\n assert candidate(s = \"2*3+4*5+6*7\",answers = [65, 51, 47, 45, 41, 37, 35, 31, 29, 27]) == 0\n assert candidate(s = \"5*3*6+2*8+1\",answers = [91, 100, 110, 120, 95, 93, 99, 105, 94, 101, 97, 96, 102, 98, 103, 92, 90, 104, 106, 91]) == 0\n assert candidate(s = \"3+5*6+7*2+8\",answers = [109, 119, 80, 103, 109, 119]) == 2\n assert candidate(s = \"8*3+4*2+5\",answers = [37, 70, 100, 61, 51, 41, 37]) == 12\n assert candidate(s = \"9*8*7*6*5\",answers = [151200, 134400, 141120, 147840, 120960, 130680, 127020, 133680, 123540]) == 0\n assert candidate(s = \"6*3+4*2+1+5*3\",answers = [44, 53, 49, 41, 57, 61, 56, 67, 65, 46]) == 2\n assert candidate(s = \"3*3*3*3*3+2+1\",answers = [244, 242, 243, 245, 246, 247]) == 5\n assert candidate(s = \"8*6+5*3+2*1\",answers = [56, 51, 106, 103, 83, 96, 90, 113, 78, 111, 54, 122]) == 0\n assert candidate(s = \"7*6+5*4+3*2+1*0\",answers = [62, 57, 67, 72, 69, 75, 77, 74, 71, 52, 64, 76, 78, 73, 53, 65, 70, 66, 68, 61, 56, 60, 59, 58, 55, 54, 51, 50, 49]) == 7\n assert candidate(s = \"8*3+7*2+9*4\",answers = [118, 154, 106, 94, 210, 142, 126, 130, 182, 166]) == 0\n assert candidate(s = \"5*3+2*8+9*7\",answers = [108, 131, 128, 136, 119, 131, 142, 123, 127, 131]) == 0\n assert candidate(s = \"3*8+2*6+5*9+1*7\",answers = [140, 138, 137, 142, 141, 139, 143, 136, 144, 145]) == 2\n assert candidate(s = \"1+2*3+4*5+6*7+8*9\",answers = [277, 278, 276, 275, 279, 280, 274]) == 2\n assert candidate(s = \"4*4+3*3+2*2+1*1\",answers = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(s = \"9*3+8*2+7*6+5\",answers = [139, 167, 145, 151, 146, 158, 147, 148, 152, 150]) == 2\n assert candidate(s = \"7*2+3*9+1*6+5*8\",answers = [155, 148, 149, 151, 147, 152, 150, 146, 154, 153]) == 0\n assert candidate(s = \"1+2*3+4*5+6\",answers = [78, 54, 72, 86, 94, 104, 118, 126, 138, 158]) == 0\n assert candidate(s = \"3*6+2*5+4*7\",answers = [54, 59, 66, 74, 81, 83, 88, 60, 71, 78]) == 0\n assert candidate(s = \"8*7+5*6+2\",answers = [65, 106, 122, 158, 162, 232, 250, 188, 210, 202]) == 0\n assert candidate(s = \"7*6+5*3+2*4+1\",answers = [74, 78, 83, 79, 87, 81, 85, 76, 82, 86]) == 0\n assert candidate(s = \"5+4*3+2*1+0\",answers = [19, 25, 17, 15, 23, 27, 30]) == 7\n assert candidate(s = \"2+5*3*2+4\",answers = [40, 42, 38, 50, 36, 74, 68, 54, 82, 80]) == 7\n assert candidate(s = \"5*9+4*8+3*7\",answers = [102, 105, 116, 121, 135, 132, 93, 113, 143, 150]) == 0\n assert candidate(s = \"4+3*2*1+5\",answers = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3]) == 7\n assert candidate(s = \"3*3+2*2+1*1\",answers = [14, 16, 12, 18, 15, 13, 17, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 19]) == 7\n assert candidate(s = \"6+7*8+9*2\",answers = [169, 137, 154, 131, 166, 152, 145, 158, 170]) == 0\n assert candidate(s = \"1*2*3*4*5\",answers = [120, 20, 60, 30, 10, 240, 15, 40, 6]) == 5\n assert candidate(s = \"5+9*8+7*6+4*3+2*1\",answers = [279, 283, 287, 291, 295, 299, 303, 307, 311, 315]) == 2\n"}, "metadata": {"canonical_parameter_names": ["s", "answers"], "leetcode_dataset_entry_point": "Solution().scoreOfStudents", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def scoreOfStudents(self, s: str, answers: list[int]) -> int:", "container": "Solution", "callable": "scoreOfStudents", "parameters": [{"name": "s", "type": "str"}, {"name": "answers", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2022, "task_id": "convert-1d-array-into-2d-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with m rows and n columns using all the elements from original.\nThe elements from indices 0 to n - 1 (inclusive) of original should form the first row of the constructed 2D array, the elements from indices n to 2 * n - 1 (inclusive) should form the second row of the constructed 2D array, and so on.\nReturn an m x n 2D array constructed according to the above procedure, or an empty 2D array if it is impossible.\n \nExample 1:\n\n\nInput: original = [1,2,3,4], m = 2, n = 2\nOutput: [[1,2],[3,4]]\nExplanation: The constructed 2D array should contain 2 rows and 2 columns.\nThe first group of n=2 elements in original, [1,2], becomes the first row in the constructed 2D array.\nThe second group of n=2 elements in original, [3,4], becomes the second row in the constructed 2D array.\n\nExample 2:\n\nInput: original = [1,2,3], m = 1, n = 3\nOutput: [[1,2,3]]\nExplanation: The constructed 2D array should contain 1 row and 3 columns.\nPut all three elements in original into the first row of the constructed 2D array.\n\nExample 3:\n\nInput: original = [1,2], m = 1, n = 1\nOutput: []\nExplanation: There are 2 elements in original.\nIt is impossible to fit 2 elements in a 1x1 2D array, so return an empty 2D array.\n\n \nConstraints:\n\n1 <= original.length <= 5 * 104\n1 <= original[i] <= 105\n1 <= m, n <= 4 * 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(original = [5, 6, 7, 8, 9, 10, 11, 12],m = 4,n = 2) == [[5, 6], [7, 8], [9, 10], [11, 12]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9],m = 3,n = 3) == [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n assert candidate(original = [9, 10, 11, 12, 13, 14],m = 2,n = 3) == [[9, 10, 11], [12, 13, 14]]\n assert candidate(original = [1, 2],m = 1,n = 1) == []\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8],m = 4,n = 2) == [[1, 2], [3, 4], [5, 6], [7, 8]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],m = 3,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]\n assert candidate(original = [3, 3, 3, 3, 3, 3],m = 2,n = 3) == [[3, 3, 3], [3, 3, 3]]\n assert candidate(original = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,n = 3) == [[9, 8, 7], [6, 5, 4], [3, 2, 1]]\n assert candidate(original = [1, 2, 3, 4, 5, 6],m = 2,n = 3) == [[1, 2, 3], [4, 5, 6]]\n assert candidate(original = [10, 20, 30, 40, 50],m = 5,n = 1) == [[10], [20], [30], [40], [50]]\n assert candidate(original = [5, 6, 7, 8, 9, 10],m = 2,n = 3) == [[5, 6, 7], [8, 9, 10]]\n assert candidate(original = [42, 43, 44, 45, 46, 47, 48, 49, 50],m = 3,n = 3) == [[42, 43, 44], [45, 46, 47], [48, 49, 50]]\n assert candidate(original = [1, 2, 3, 4],m = 2,n = 2) == [[1, 2], [3, 4]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 2,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]\n assert candidate(original = [25, 26, 27],m = 3,n = 1) == [[25], [26], [27]]\n assert candidate(original = [1, 2, 3],m = 1,n = 3) == [[1, 2, 3]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],m = 4,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]\n assert candidate(original = [5, 6, 7, 8, 9],m = 1,n = 5) == [[5, 6, 7, 8, 9]]\n assert candidate(original = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24],m = 5,n = 2) == [[15, 16], [17, 18], [19, 20], [21, 22], [23, 24]]\n assert candidate(original = [1],m = 1,n = 1) == [[1]]\n assert candidate(original = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41],m = 3,n = 4) == [[30, 31, 32, 33], [34, 35, 36, 37], [38, 39, 40, 41]]\n assert candidate(original = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],m = 4,n = 3) == [[10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]]\n assert candidate(original = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],m = 6,n = 6) == []\n assert candidate(original = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 7,n = 5) == []\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 5,n = 6) == [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]\n assert candidate(original = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],m = 5,n = 2) == [[1000, 2000], [3000, 4000], [5000, 6000], [7000, 8000], [9000, 10000]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],m = 5,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]\n assert candidate(original = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],m = 3,n = 4) == [[100, 200, 300, 400], [500, 600, 700, 800], [900, 1000, 1100, 1200]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],m = 10,n = 5) == [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39], [41, 43, 45, 47, 49], [51, 53, 55, 57, 59], [61, 63, 65, 67, 69], [71, 73, 75, 77, 79], [81, 83, 85, 87, 89], [91, 93, 95, 97, 99]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 5,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],m = 5,n = 5) == [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39], [41, 43, 45, 47, 49]]\n assert candidate(original = [12345],m = 1,n = 1) == [[12345]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],m = 5,n = 8) == [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 3,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]\n assert candidate(original = [99, 88, 77, 66, 55, 44, 33, 22, 11],m = 3,n = 3) == [[99, 88, 77], [66, 55, 44], [33, 22, 11]]\n assert candidate(original = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 4,n = 4) == [[5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]\n assert candidate(original = [42],m = 1,n = 1) == [[42]]\n assert candidate(original = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255],m = 5,n = 5) == []\n assert candidate(original = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160],m = 5,n = 4) == [[8, 16, 24, 32], [40, 48, 56, 64], [72, 80, 88, 96], [104, 112, 120, 128], [136, 144, 152, 160]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],m = 10,n = 5) == [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39], [41, 43, 45, 47, 49], [51, 53, 55, 57, 59], [61, 63, 65, 67, 69], [71, 73, 75, 77, 79], [81, 83, 85, 87, 89], [91, 93, 95, 97, 99]]\n assert candidate(original = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,n = 3) == [[9, 8, 7], [6, 5, 4], [3, 2, 1]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10,n = 1) == [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],m = 6,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24]]\n assert candidate(original = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240],m = 6,n = 4) == [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160], [170, 180, 190, 200], [210, 220, 230, 240]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60],m = 6,n = 10) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60]]\n assert candidate(original = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,n = 5) == [[15, 14, 13, 12, 11], [10, 9, 8, 7, 6], [5, 4, 3, 2, 1]]\n assert candidate(original = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],m = 5,n = 5) == [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30], [32, 34, 36, 38, 40], [42, 44, 46, 48, 50]]\n assert candidate(original = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930, 313233, 343536, 373839, 404142, 434445],m = 3,n = 5) == [[123, 456, 789, 101112, 131415], [161718, 192021, 222324, 252627, 282930], [313233, 343536, 373839, 404142, 434445]]\n assert candidate(original = [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],m = 10,n = 10) == []\n assert candidate(original = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 6,n = 5) == []\n assert candidate(original = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],m = 2,n = 5) == [[1000, 2000, 3000, 4000, 5000], [6000, 7000, 8000, 9000, 10000]]\n assert candidate(original = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],m = 3,n = 4) == [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],m = 10,n = 10) == []\n assert candidate(original = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70],m = 5,n = 6) == [[99, 98, 97, 96, 95, 94], [93, 92, 91, 90, 89, 88], [87, 86, 85, 84, 83, 82], [81, 80, 79, 78, 77, 76], [75, 74, 73, 72, 71, 70]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],m = 7,n = 7) == []\n assert candidate(original = [5, 15, 25, 35, 45, 55, 65, 75],m = 2,n = 4) == [[5, 15, 25, 35], [45, 55, 65, 75]]\n assert candidate(original = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],m = 5,n = 3) == [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50, 55, 60], [65, 70, 75]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],m = 10,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40], [41, 42, 43, 44, 45], [46, 47, 48, 49, 50]]\n assert candidate(original = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 10,n = 10) == []\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60],m = 6,n = 10) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60]]\n assert candidate(original = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],m = 4,n = 4) == [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60], [65, 70, 75, 80]]\n assert candidate(original = [1, 2, 3, 4, 5],m = 1,n = 5) == [[1, 2, 3, 4, 5]]\n assert candidate(original = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],m = 7,n = 3) == [[42, 42, 42], [42, 42, 42], [42, 42, 42], [42, 42, 42], [42, 42, 42], [42, 42, 42], [42, 42, 42]]\n assert candidate(original = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90],m = 6,n = 3) == [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50, 55, 60], [65, 70, 75], [80, 85, 90]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],m = 8,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40]]\n assert candidate(original = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120],m = 6,n = 10) == [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [22, 24, 26, 28, 30, 32, 34, 36, 38, 40], [42, 44, 46, 48, 50, 52, 54, 56, 58, 60], [62, 64, 66, 68, 70, 72, 74, 76, 78, 80], [82, 84, 86, 88, 90, 92, 94, 96, 98, 100], [102, 104, 106, 108, 110, 112, 114, 116, 118, 120]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 4,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],m = 4,n = 4) == [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23], [25, 27, 29, 31]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 5,n = 6) == [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],m = 10,n = 10) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27],m = 3,n = 9) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],m = 4,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]\n assert candidate(original = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],m = 4,n = 5) == [[3, 6, 9, 12, 15], [18, 21, 24, 27, 30], [33, 36, 39, 42, 45], [48, 51, 54, 57, 60]]\n assert candidate(original = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],m = 2,n = 5) == [[5, 10, 15, 20, 25], [30, 35, 40, 45, 50]]\n assert candidate(original = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],m = 4,n = 5) == [[99, 98, 97, 96, 95], [94, 93, 92, 91, 90], [89, 88, 87, 86, 85], [84, 83, 82, 81, 80]]\n assert candidate(original = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400],m = 4,n = 6) == [[100, 200, 300, 400, 500, 600], [700, 800, 900, 1000, 1100, 1200], [1300, 1400, 1500, 1600, 1700, 1800], [1900, 2000, 2100, 2200, 2300, 2400]]\n assert candidate(original = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],m = 4,n = 4) == [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]]\n assert candidate(original = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],m = 2,n = 5) == [[1000, 2000, 3000, 4000, 5000], [6000, 7000, 8000, 9000, 10000]]\n assert candidate(original = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020, 2121, 2222, 2323, 2424, 2525],m = 5,n = 5) == [[101, 202, 303, 404, 505], [606, 707, 808, 909, 1010], [1111, 1212, 1313, 1414, 1515], [1616, 1717, 1818, 1919, 2020], [2121, 2222, 2323, 2424, 2525]]\n assert candidate(original = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986],m = 3,n = 5) == [[100000, 99999, 99998, 99997, 99996], [99995, 99994, 99993, 99992, 99991], [99990, 99989, 99988, 99987, 99986]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],m = 5,n = 10) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]]\n assert candidate(original = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],m = 5,n = 3) == [[10, 20, 30], [40, 50, 60], [70, 80, 90], [100, 110, 120], [130, 140, 150]]\n assert candidate(original = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135],m = 9,n = 4) == [[100, 101, 102, 103], [104, 105, 106, 107], [108, 109, 110, 111], [112, 113, 114, 115], [116, 117, 118, 119], [120, 121, 122, 123], [124, 125, 126, 127], [128, 129, 130, 131], [132, 133, 134, 135]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],m = 2,n = 13) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]]\n assert candidate(original = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],m = 5,n = 3) == [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200], [1300, 1400, 1500]]\n"}, "metadata": {"canonical_parameter_names": ["original", "m", "n"], "leetcode_dataset_entry_point": "Solution().construct2DArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def construct2DArray(self, original: list[int], m: int, n: int) -> list[list[int]]:", "container": "Solution", "callable": "construct2DArray", "parameters": [{"name": "original", "type": "list[int]"}, {"name": "m", "type": "int"}, {"name": "n", "type": "int"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2023, "task_id": "number-of-pairs-of-strings-with-concatenation-equal-to-target", "difficulty": "Medium", "problem_description": "Given an array of digit strings nums and a digit string target, return the number of pairs of indices (i, j) (where i != j) such that the concatenation of nums[i] + nums[j] equals target.\n \nExample 1:\n\nInput: nums = [\"777\",\"7\",\"77\",\"77\"], target = \"7777\"\nOutput: 4\nExplanation: Valid pairs are:\n- (0, 1): \"777\" + \"7\"\n- (1, 0): \"7\" + \"777\"\n- (2, 3): \"77\" + \"77\"\n- (3, 2): \"77\" + \"77\"\n\nExample 2:\n\nInput: nums = [\"123\",\"4\",\"12\",\"34\"], target = \"1234\"\nOutput: 2\nExplanation: Valid pairs are:\n- (0, 1): \"123\" + \"4\"\n- (2, 3): \"12\" + \"34\"\n\nExample 3:\n\nInput: nums = [\"1\",\"1\",\"1\"], target = \"11\"\nOutput: 6\nExplanation: Valid pairs are:\n- (0, 1): \"1\" + \"1\"\n- (1, 0): \"1\" + \"1\"\n- (0, 2): \"1\" + \"1\"\n- (2, 0): \"1\" + \"1\"\n- (1, 2): \"1\" + \"1\"\n- (2, 1): \"1\" + \"1\"\n\n \nConstraints:\n\n2 <= nums.length <= 100\n1 <= nums[i].length <= 100\n2 <= target.length <= 100\nnums[i] and target consist of digits.\nnums[i] and target do not have leading zeros.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = ['777', '7', '77', '77'],target = \"7777\") == 4\n assert candidate(nums = ['10', '11', '1'],target = \"101\") == 1\n assert candidate(nums = ['1234', '56', '78', '9'],target = \"123456\") == 1\n assert candidate(nums = ['99', '9', '999'],target = \"9999\") == 2\n assert candidate(nums = ['50', '2', '5', '0'],target = \"5025\") == 0\n assert candidate(nums = ['10', '100', '1'],target = \"10100\") == 1\n assert candidate(nums = ['123', '4', '12', '34'],target = \"1234\") == 2\n assert candidate(nums = ['50', '5', '500'],target = \"505\") == 1\n assert candidate(nums = ['1', '1', '1'],target = \"11\") == 6\n assert candidate(nums = ['123', '234', '345', '456', '567', '678', '789', '890'],target = \"123234\") == 1\n assert candidate(nums = ['66', '666', '6666', '66666'],target = \"66666666\") == 2\n assert candidate(nums = ['33', '3', '333', '3333', '33'],target = \"333333\") == 4\n assert candidate(nums = ['555', '55', '5', '5555'],target = \"555555\") == 2\n assert candidate(nums = ['1', '1', '2', '2', '3', '3'],target = \"11\") == 2\n assert candidate(nums = ['78', '87', '7', '8'],target = \"7887\") == 1\n assert candidate(nums = ['7777', '777', '77', '7'],target = \"7777777\") == 2\n assert candidate(nums = ['0', '00', '000', '0000'],target = \"0000\") == 2\n assert candidate(nums = ['001', '010', '100', '1'],target = \"1001\") == 2\n assert candidate(nums = ['15', '51', '1515', '151', '515'],target = \"151515\") == 3\n assert candidate(nums = ['10', '01', '100', '001', '1000', '0001'],target = \"1001\") == 1\n assert candidate(nums = ['789', '897', '978', '78', '89', '97'],target = \"789897\") == 1\n assert candidate(nums = ['10', '20', '30', '40', '50'],target = \"1020\") == 1\n assert candidate(nums = ['1234', '5678', '4321', '8765'],target = \"12345678\") == 1\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999'],target = \"111222\") == 1\n assert candidate(nums = ['5', '55', '555', '5555', '55555'],target = \"555555\") == 4\n assert candidate(nums = ['9', '99', '999', '9999'],target = \"999999\") == 2\n assert candidate(nums = ['18', '81', '181', '818', '1818'],target = \"181818\") == 3\n assert candidate(nums = ['20', '02', '2', '2002'],target = \"200202\") == 1\n assert candidate(nums = ['5', '55', '555', '5555'],target = \"55555\") == 4\n assert candidate(nums = ['9', '99', '999', '9999', '99999'],target = \"999999\") == 4\n assert candidate(nums = ['90', '09', '9', '0'],target = \"9009\") == 1\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9'],target = \"12\") == 1\n assert candidate(nums = ['111', '222', '333', '111', '222'],target = \"111222\") == 4\n assert candidate(nums = ['222', '2222', '2', '22', '22222'],target = \"22222222\") == 2\n assert candidate(nums = ['1234', '5678', '12', '34', '56', '78'],target = \"12345678\") == 1\n assert candidate(nums = ['111', '222', '333', '444'],target = \"111222\") == 1\n assert candidate(nums = ['98765', '4321', '9876', '54321'],target = \"987654321\") == 2\n assert candidate(nums = ['90', '909', '09', '9'],target = \"90909\") == 2\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '09'],target = \"09\") == 1\n assert candidate(nums = ['100000', '10000', '1000', '100', '10', '1'],target = \"10000010000\") == 1\n assert candidate(nums = ['0', '0', '0', '0'],target = \"00\") == 12\n assert candidate(nums = ['8', '88', '888', '8888'],target = \"88888\") == 4\n assert candidate(nums = ['123', '456', '789', '0', '1', '2'],target = \"123456\") == 1\n assert candidate(nums = ['111111', '11111', '1111', '111', '11'],target = \"111111111\") == 4\n assert candidate(nums = ['100', '200', '300', '400', '500'],target = \"100200\") == 1\n assert candidate(nums = ['123', '234', '345', '456', '567'],target = \"123234\") == 1\n assert candidate(nums = ['1234', '4321', '2341', '3412', '5678', '8765', '6785', '7856'],target = \"12344321\") == 1\n assert candidate(nums = ['123', '345', '567', '789'],target = \"123345\") == 1\n assert candidate(nums = ['10', '20', '30', '40', '50'],target = \"2030\") == 1\n assert candidate(nums = ['0000', '000', '00', '0'],target = \"00000000\") == 0\n assert candidate(nums = ['0001', '10', '01', '1'],target = \"00011\") == 1\n assert candidate(nums = ['123', '456', '789', '0'],target = \"123456\") == 1\n assert candidate(nums = ['16', '61', '161', '6', '1661'],target = \"166161\") == 1\n assert candidate(nums = ['21', '12', '22', '11', '2112'],target = \"211221\") == 1\n assert candidate(nums = ['42', '424', '2', '4'],target = \"4242\") == 1\n assert candidate(nums = ['777', '77', '7', '7777'],target = \"777777\") == 2\n assert candidate(nums = ['11', '11', '11', '11', '11'],target = \"1111\") == 20\n assert candidate(nums = ['19', '91', '191', '9', '1991'],target = \"199191\") == 1\n assert candidate(nums = ['987654321', '123456789', '1234', '4321'],target = \"987654321123456789\") == 1\n assert candidate(nums = ['111111', '1111', '111', '11', '1'],target = \"111111111111\") == 0\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],target = \"12\") == 1\n assert candidate(nums = ['1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],target = \"11\") == 90\n assert candidate(nums = ['101', '101', '101', '101'],target = \"101101\") == 12\n assert candidate(nums = ['8888', '888', '88', '8', '88', '888', '8888'],target = \"88888888\") == 2\n assert candidate(nums = ['22', '2', '222', '2222'],target = \"222222\") == 2\n assert candidate(nums = ['123456', '654321', '1234', '4321', '5678', '8765'],target = \"123456654321\") == 1\n assert candidate(nums = ['12', '21', '11', '22'],target = \"1221\") == 1\n assert candidate(nums = ['55', '555', '5555', '55555'],target = \"5555555\") == 4\n assert candidate(nums = ['14', '41', '144', '4'],target = \"1441\") == 1\n assert candidate(nums = ['8', '88', '888', '8888', '88888', '888888'],target = \"8888888\") == 6\n assert candidate(nums = ['12', '23', '34', '45', '56'],target = \"2345\") == 1\n assert candidate(nums = ['12345', '54321', '123', '321', '12', '21'],target = \"1234554321\") == 1\n assert candidate(nums = ['55', '5', '555', '5555'],target = \"55555\") == 4\n assert candidate(nums = ['987', '654', '321', '654'],target = \"987654\") == 2\n assert candidate(nums = ['111', '11', '1', '1111', '11111'],target = \"1111111\") == 4\n assert candidate(nums = ['1234', '4321', '2341', '3412'],target = \"12344321\") == 1\n assert candidate(nums = ['101', '01', '10', '1'],target = \"1010\") == 0\n assert candidate(nums = ['8', '88', '888', '8888', '88888'],target = \"888888888\") == 2\n assert candidate(nums = ['6', '66', '666', '6666'],target = \"666666\") == 2\n assert candidate(nums = ['10', '01', '0', '1'],target = \"1001\") == 1\n assert candidate(nums = ['10', '20', '30', '40', '50', '60', '70', '80', '90'],target = \"1020\") == 1\n assert candidate(nums = ['111', '11', '1', '1111'],target = \"111111\") == 2\n assert candidate(nums = ['1', '2', '3', '4', '5'],target = \"12\") == 1\n assert candidate(nums = ['111', '222', '112', '121', '211'],target = \"111222\") == 1\n assert candidate(nums = ['12345', '23456', '34567', '45678', '56789'],target = \"1234523456\") == 1\n assert candidate(nums = ['12', '12', '12', '12'],target = \"1212\") == 12\n assert candidate(nums = ['555', '55', '5', '5555', '55555'],target = \"5555555\") == 4\n assert candidate(nums = ['23', '32', '232', '2', '3223'],target = \"233223\") == 1\n assert candidate(nums = ['11', '22', '33', '44', '55', '66', '77', '88', '99'],target = \"1122\") == 1\n assert candidate(nums = ['123', '321', '213', '132', '231', '312'],target = \"123213\") == 1\n assert candidate(nums = ['12', '21', '121', '212'],target = \"1212\") == 0\n assert candidate(nums = ['555', '555', '555', '555', '555'],target = \"555555\") == 20\n assert candidate(nums = ['89', '98', '8998', '9889'],target = \"899889\") == 2\n assert candidate(nums = ['22', '222', '2', '2222'],target = \"222222\") == 2\n assert candidate(nums = ['23', '32', '123', '456', '654', '321'],target = \"23456\") == 1\n assert candidate(nums = ['9876', '8765', '7654', '6543', '5432', '4321', '3210', '2109'],target = \"98768765\") == 1\n assert candidate(nums = ['1010', '0101', '10', '01', '101', '010'],target = \"10100101\") == 1\n assert candidate(nums = ['90', '80', '70', '60'],target = \"7080\") == 1\n assert candidate(nums = ['101', '010', '10', '01'],target = \"101010\") == 1\n assert candidate(nums = ['9', '99', '999', '9999'],target = \"99999999\") == 0\n assert candidate(nums = ['5050', '50', '5', '500', '5000'],target = \"505050\") == 2\n assert candidate(nums = ['12', '21', '121', '112'],target = \"12112\") == 2\n assert candidate(nums = ['13', '31', '1', '3'],target = \"1331\") == 1\n assert candidate(nums = ['2', '22', '222', '2222', '22222'],target = \"222222\") == 4\n assert candidate(nums = ['2020', '20', '2', '0202'],target = \"202020\") == 2\n assert candidate(nums = ['12', '23', '34', '45', '56', '67', '78', '89'],target = \"1223\") == 1\n assert candidate(nums = ['999', '99', '9', '9999'],target = \"9999999\") == 2\n assert candidate(nums = ['00', '0', '000', '0000'],target = \"000000\") == 2\n assert candidate(nums = ['17', '71', '1717', '717', '177'],target = \"171717\") == 2\n assert candidate(nums = ['987', '876', '765', '654', '543'],target = \"987876\") == 1\n assert candidate(nums = ['12', '23', '34', '45', '56', '67', '78', '89', '90'],target = \"1223\") == 1\n assert candidate(nums = ['12', '12', '12', '12', '12', '12', '12', '12', '12', '12'],target = \"1212\") == 90\n assert candidate(nums = ['00', '000', '0000', '00000'],target = \"00000000\") == 2\n assert candidate(nums = ['1010', '10', '1', '101', '10101'],target = \"10101010\") == 0\n assert candidate(nums = ['12', '23', '34', '45', '56'],target = \"1223\") == 1\n assert candidate(nums = ['55', '5', '555', '5555'],target = \"5555\") == 2\n assert candidate(nums = ['1234', '456', '12', '3456'],target = \"123456\") == 1\n assert candidate(nums = ['45', '54', '4', '5'],target = \"4554\") == 1\n assert candidate(nums = ['10', '01', '100', '1'],target = \"101\") == 2\n assert candidate(nums = ['100', '10', '1', '1000'],target = \"1001000\") == 1\n assert candidate(nums = ['1111', '111', '11', '1'],target = \"11111111\") == 0\n assert candidate(nums = ['11', '111', '1111', '11111'],target = \"111111111\") == 2\n assert candidate(nums = ['9876', '8769', '7698', '6987', '987', '876', '769', '698'],target = \"98768769\") == 1\n assert candidate(nums = ['12345', '67890', '123', '4567890'],target = \"1234567890\") == 2\n assert candidate(nums = ['9', '9', '9', '9', '9', '9', '9', '9', '9', '9'],target = \"99\") == 90\n assert candidate(nums = ['123', '456', '789', '1234'],target = \"123456\") == 1\n assert candidate(nums = ['1234', '5678', '91011', '121314'],target = \"12345678\") == 1\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().numOfPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def numOfPairs(self, nums: list[str], target: str) -> int:", "container": "Solution", "callable": "numOfPairs", "parameters": [{"name": "nums", "type": "list[str]"}, {"name": "target", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2024, "task_id": "maximize-the-confusion-of-an-exam", "difficulty": "Medium", "problem_description": "A teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false. He wants to confuse the students by maximizing the number of consecutive questions with the same answer (multiple trues or multiple falses in a row).\nYou are given a string answerKey, where answerKey[i] is the original answer to the ith question. In addition, you are given an integer k, the maximum number of times you may perform the following operation:\n\nChange the answer key for any question to 'T' or 'F' (i.e., set answerKey[i] to 'T' or 'F').\n\nReturn the maximum number of consecutive 'T's or 'F's in the answer key after performing the operation at most k times.\n \nExample 1:\n\nInput: answerKey = \"TTFF\", k = 2\nOutput: 4\nExplanation: We can replace both the 'F's with 'T's to make answerKey = \"TTTT\".\nThere are four consecutive 'T's.\n\nExample 2:\n\nInput: answerKey = \"TFFT\", k = 1\nOutput: 3\nExplanation: We can replace the first 'T' with an 'F' to make answerKey = \"FFFT\".\nAlternatively, we can replace the second 'T' with an 'F' to make answerKey = \"TFFF\".\nIn both cases, there are three consecutive 'F's.\n\nExample 3:\n\nInput: answerKey = \"TTFTTFTT\", k = 1\nOutput: 5\nExplanation: We can replace the first 'F' to make answerKey = \"TTTTTFTT\"\nAlternatively, we can replace the second 'F' to make answerKey = \"TTFTTTTT\". \nIn both cases, there are five consecutive 'T's.\n\n \nConstraints:\n\nn == answerKey.length\n1 <= n <= 5 * 104\nanswerKey[i] is either 'T' or 'F'\n1 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(answerKey = \"TTTTFFFF\",k = 2) == 6\n assert candidate(answerKey = \"FFFFFF\",k = 3) == 6\n assert candidate(answerKey = \"TFFTFFTFFTFT\",k = 3) == 10\n assert candidate(answerKey = \"TFTFTFTF\",k = 2) == 5\n assert candidate(answerKey = \"FFTFFT\",k = 2) == 6\n assert candidate(answerKey = \"FFTTFFTTFF\",k = 5) == 10\n assert candidate(answerKey = \"FFTFFTFF\",k = 2) == 8\n assert candidate(answerKey = \"TFTFTFTFTF\",k = 4) == 9\n assert candidate(answerKey = \"T\",k = 1) == 1\n assert candidate(answerKey = \"FFTFFTFF\",k = 3) == 8\n assert candidate(answerKey = \"TTFF\",k = 2) == 4\n assert candidate(answerKey = \"TFTFTFTF\",k = 4) == 8\n assert candidate(answerKey = \"FTFTFTFT\",k = 2) == 5\n assert candidate(answerKey = \"TTFTTFTT\",k = 1) == 5\n assert candidate(answerKey = \"TF TFT TFTF\",k = 3) == 10\n assert candidate(answerKey = \"FFFFFFFF\",k = 5) == 8\n assert candidate(answerKey = \"FFFFFFT\",k = 2) == 7\n assert candidate(answerKey = \"FTFTFTFTFTFT\",k = 5) == 11\n assert candidate(answerKey = \"TTTTFFT\",k = 1) == 5\n assert candidate(answerKey = \"TTTTTTFTTTTT\",k = 2) == 12\n assert candidate(answerKey = \"TTTTTT\",k = 0) == 6\n assert candidate(answerKey = \"TTTTT\",k = 0) == 5\n assert candidate(answerKey = \"TFFTFFTT\",k = 3) == 7\n assert candidate(answerKey = \"TTTTFFTFFT\",k = 3) == 8\n assert candidate(answerKey = \"FTFFTFFT\",k = 3) == 8\n assert candidate(answerKey = \"TTTTTTTT\",k = 3) == 8\n assert candidate(answerKey = \"TFFT\",k = 1) == 3\n assert candidate(answerKey = \"FFFFFFF\",k = 3) == 7\n assert candidate(answerKey = \"FFFFF\",k = 3) == 5\n assert candidate(answerKey = \"FFFFF\",k = 0) == 5\n assert candidate(answerKey = \"TFFFFF\",k = 2) == 6\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\",k = 20) == 38\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFT\",k = 4) == 9\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFF\",k = 10) == 16\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFT\",k = 8) == 16\n assert candidate(answerKey = \"TTTTTTTFFFFFFFFFFFFFFTTTTTTTTTTTTTTTTTTTTTT\",k = 15) == 43\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTT\",k = 5) == 16\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 25) == 51\n assert candidate(answerKey = \"TFFTFTFTFTFTFTFTFTFT\",k = 10) == 20\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTTTT\",k = 15) == 24\n assert candidate(answerKey = \"TTFTFTFFTFTF\",k = 4) == 10\n assert candidate(answerKey = \"TFFFFFFFFFTTTTTTTTTT\",k = 6) == 16\n assert candidate(answerKey = \"TTFTFTFTFT\",k = 4) == 10\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFT\",k = 8) == 17\n assert candidate(answerKey = \"TFFTFFTFFTFFTFFTFFTFFTFFTFFT\",k = 21) == 28\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTF\",k = 10) == 20\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 20) == 32\n assert candidate(answerKey = \"FFFFFFFFTTTTTTTT\",k = 5) == 13\n assert candidate(answerKey = \"TFFTFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFT\",k = 7) == 23\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 20) == 28\n assert candidate(answerKey = \"FFFFFFFFFTTTTTTTTT\",k = 5) == 14\n assert candidate(answerKey = \"FTTFTTFTTFFTFTTFFT\",k = 11) == 18\n assert candidate(answerKey = \"FFFFFFFFTTTTTTFFFFFFFFTTTTTTTTT\",k = 9) == 25\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTF\",k = 10) == 16\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTT\",k = 10) == 16\n assert candidate(answerKey = \"FFFFFFFFTTTTTTTTTTFT\",k = 2) == 13\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 0) == 44\n assert candidate(answerKey = \"TTTFFFFTTTFFTFTFFF\",k = 3) == 9\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 20) == 41\n assert candidate(answerKey = \"FTTTFTTFTTFTTFTTFT\",k = 7) == 18\n assert candidate(answerKey = \"TFTFTFTFTF\",k = 5) == 10\n assert candidate(answerKey = \"FFFTTTFFFFTTTTFF\",k = 5) == 12\n assert candidate(answerKey = \"TTFFFFFFFFTTTTTTTTTTTTFFFFFFF\",k = 8) == 22\n assert candidate(answerKey = \"TTTFFFTTTFFFTTTFFF\",k = 5) == 11\n assert candidate(answerKey = \"FFFFFFFFFTTTTTTTTTTTTTT\",k = 10) == 23\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFT\",k = 2) == 5\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFT\",k = 5) == 12\n assert candidate(answerKey = \"FFTTFFTTFFTTFFTTFF\",k = 10) == 18\n assert candidate(answerKey = \"TTTTFFFFFFFFFFFFTTTTTTTTTTTT\",k = 15) == 28\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFTFTFTFT\",k = 12) == 22\n assert candidate(answerKey = \"TTTTTTTTTTFFFFFFFFFFFFFFFFF\",k = 11) == 27\n assert candidate(answerKey = \"TTTTTTTTTFFFFFFF\",k = 5) == 14\n assert candidate(answerKey = \"FTFFTFFTFFTFFTFFTFF\",k = 10) == 19\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 7) == 16\n assert candidate(answerKey = \"FFFFFFFFFTTTTT\",k = 5) == 14\n assert candidate(answerKey = \"TFFTFTFTFFTTFTFT\",k = 3) == 9\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTF\",k = 6) == 13\n assert candidate(answerKey = \"TTTFTFTFTFTFTFTF\",k = 6) == 15\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTT\",k = 15) == 17\n assert candidate(answerKey = \"FFTFTFTFTFFTFTFTFT\",k = 6) == 15\n assert candidate(answerKey = \"FFFFFFFFTTTTTFFFFF\",k = 4) == 12\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFTTTTTTTTTTTTTTTT\",k = 8) == 38\n assert candidate(answerKey = \"FFFFFFFFTTTTTTTTTT\",k = 12) == 18\n assert candidate(answerKey = \"TTTTTTFFTFFTFFFF\",k = 4) == 12\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTF\",k = 9) == 18\n assert candidate(answerKey = \"TTTTTTTTTTFFTTFFTT\",k = 5) == 18\n assert candidate(answerKey = \"TTTFFFFTTTFFFFTTTFFFFTTT\",k = 6) == 18\n assert candidate(answerKey = \"TTFFTTFFTFFTFFTT\",k = 7) == 15\n assert candidate(answerKey = \"FFTTFFFTTF\",k = 2) == 7\n assert candidate(answerKey = \"FFFFFFFF\",k = 0) == 8\n assert candidate(answerKey = \"FFFFFFFFFTTTTTTT\",k = 6) == 15\n assert candidate(answerKey = \"TTFTTTFTFTFTFTFFTFTF\",k = 4) == 12\n assert candidate(answerKey = \"TTTTTTTTTTFFFFFFFFFF\",k = 8) == 18\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 20) == 36\n assert candidate(answerKey = \"TTTFFFFTTTTFTTTFFTTT\",k = 7) == 20\n assert candidate(answerKey = \"TFFTFTFTFTFTFTFTFT\",k = 8) == 17\n assert candidate(answerKey = \"TTFFFTFTFTFTFFFT\",k = 6) == 15\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFT\",k = 5) == 11\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 20) == 38\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 25) == 32\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 15) == 31\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTF\",k = 20) == 41\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFT\",k = 9) == 18\n assert candidate(answerKey = \"TTTTTFFTTTTFFTT\",k = 4) == 15\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 15) == 28\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\",k = 0) == 48\n assert candidate(answerKey = \"FFTFTFFTFTFFTFTFFTFT\",k = 5) == 14\n assert candidate(answerKey = \"TTFFFFFFFFFFFFFFFFFT\",k = 3) == 20\n assert candidate(answerKey = \"TFFTFFTFFTFFTFFTFF\",k = 10) == 18\n assert candidate(answerKey = \"FFFFFFFFTTTTTTTTFFFFFFFFTTTTTTTT\",k = 8) == 24\n assert candidate(answerKey = \"TTTTTTFTTTTTFTTTTTFTTTTT\",k = 7) == 24\n assert candidate(answerKey = \"TFFFFFFFTTTTTTTTTT\",k = 10) == 18\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTF\",k = 15) == 20\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\",k = 25) == 30\n assert candidate(answerKey = \"FTTFTTFTTFFTFTTFFTFFTFTTFTT\",k = 22) == 27\n assert candidate(answerKey = \"TTFFFFFFFFFFFFFFFFFF\",k = 10) == 20\n assert candidate(answerKey = \"FFFFFFFFFTTTTTTT\",k = 7) == 16\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTFTFTFTFTF\",k = 18) == 28\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 10) == 21\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTT\",k = 15) == 22\n assert candidate(answerKey = \"FFTTFFTFFTFFTFFT\",k = 4) == 12\n assert candidate(answerKey = \"TTTTTFFFFF\",k = 2) == 7\n assert candidate(answerKey = \"TTTFFFTTTFFFTTTFFFTTTFFFTTTFFTFTFFTT\",k = 15) == 32\n assert candidate(answerKey = \"TFFTFFTTFFTTFFTTFFTT\",k = 9) == 19\n assert candidate(answerKey = \"FTFTFTTTTTFTFTFT\",k = 6) == 16\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTTTTTTTT\",k = 20) == 28\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFF\",k = 15) == 17\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFT\",k = 8) == 17\n assert candidate(answerKey = \"TFFTFFTFFTFFTFFTFFTFFTFFTFFT\",k = 12) == 28\n assert candidate(answerKey = \"TTTTFFTTFFTTFF\",k = 4) == 12\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 12) == 25\n assert candidate(answerKey = \"TFFFFFFFTTTTTTTT\",k = 7) == 16\n assert candidate(answerKey = \"TTTTTTTTTT\",k = 0) == 10\n assert candidate(answerKey = \"TFFTFFTFFTFFTFFTFFTFFT\",k = 7) == 21\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 20) == 29\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 24) == 32\n assert candidate(answerKey = \"TTFTTTTTTTTTTTTTTTTT\",k = 1) == 20\n assert candidate(answerKey = \"TTFFTFTFFTFFTFTFFTFFTFFTTFFTFTFFTFFTFFTFFTFTFFTFF\",k = 6) == 19\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFTFTFTFTFT\",k = 12) == 24\n assert candidate(answerKey = \"TTTTTTTTTFFFFFFF\",k = 6) == 15\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFF\",k = 15) == 24\n"}, "metadata": {"canonical_parameter_names": ["answerKey", "k"], "leetcode_dataset_entry_point": "Solution().maxConsecutiveAnswers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxConsecutiveAnswers(self, answerKey: str, k: int) -> int:", "container": "Solution", "callable": "maxConsecutiveAnswers", "parameters": [{"name": "answerKey", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2025, "task_id": "maximum-number-of-ways-to-partition-an-array", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums of length n. The number of ways to partition nums is the number of pivot indices that satisfy both conditions:\n\n1 <= pivot < n\nnums[0] + nums[1] + ... + nums[pivot - 1] == nums[pivot] + nums[pivot + 1] + ... + nums[n - 1]\n\nYou are also given an integer k. You can choose to change the value of one element of nums to k, or to leave the array unchanged.\nReturn the maximum possible number of ways to partition nums to satisfy both conditions after changing at most one element.\n \nExample 1:\n\nInput: nums = [2,-1,2], k = 3\nOutput: 1\nExplanation: One optimal approach is to change nums[0] to k. The array becomes [3,-1,2].\nThere is one way to partition the array:\n- For pivot = 2, we have the partition [3,-1 | 2]: 3 + -1 == 2.\n\nExample 2:\n\nInput: nums = [0,0,0], k = 1\nOutput: 2\nExplanation: The optimal approach is to leave the array unchanged.\nThere are two ways to partition the array:\n- For pivot = 1, we have the partition [0 | 0,0]: 0 == 0 + 0.\n- For pivot = 2, we have the partition [0,0 | 0]: 0 + 0 == 0.\n\nExample 3:\n\nInput: nums = [22,4,-25,-20,-15,15,-16,7,19,-10,0,-13,-14], k = -33\nOutput: 4\nExplanation: One optimal approach is to change nums[2] to k. The array becomes [22,4,-33,-20,-15,15,-16,7,19,-10,0,-13,-14].\nThere are four ways to partition the array.\n\n \nConstraints:\n\nn == nums.length\n2 <= n <= 105\n-105 <= k, nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 0\n assert candidate(nums = [0, 0, 0],k = 1) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [100000, -100000, 100000, -100000],k = 0) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5],k = -3) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = -5) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0],k = 1) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 55) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5],k = -15) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [2, -1, 2],k = 3) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],k = 9) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1],k = 0) == 3\n assert candidate(nums = [22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14],k = -33) == 4\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],k = 15000) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000],k = 0) == 4\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100],k = 50) == 9\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 60) == 0\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1) == 14\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1],k = 0) == 3\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 0) == 1\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, -150000],k = 25000) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1],k = 0) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15],k = 0) == 1\n assert candidate(nums = [22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14, 22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14],k = -33) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20],k = 5) == 1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40],k = 0) == 3\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996],k = 50000) == 0\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000],k = 550000) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 105) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 15) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 525) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9],k = 0) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 210) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = -5) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1],k = 2) == 4\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 50) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1],k = 0) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000],k = 0) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 55) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 0) == 7\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400],k = 50) == 3\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 420) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 780) == 0\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100],k = 0) == 1\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000, -100000],k = 0) == 2\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000],k = 10500) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 0) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 1) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 2100) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 110) == 0\n assert candidate(nums = [-100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000],k = 0) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 1910) == 1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40],k = 0) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 1\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000],k = 0) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 65) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 100) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 1275) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 10) == 0\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 0) == 5\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 5) == 10\n assert candidate(nums = [-100000, 0, 100000, 0, -100000, 0, 100000, 0, -100000],k = 50000) == 0\n assert candidate(nums = [10000, -10000, 20000, -20000, 30000, -30000, 40000, -40000, 50000],k = -10000) == 3\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1],k = 0) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 1\n assert candidate(nums = [10000, -5000, 20000, -10000, 15000, -5000, 20000, -10000, 15000],k = 10000) == 2\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40],k = 0) == 3\n assert candidate(nums = [22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14, 30, -30],k = -33) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 120) == 0\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000],k = 5500000) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 500) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 0) == 4\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5],k = 10) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 100) == 1\n assert candidate(nums = [22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14],k = 100) == 0\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 5) == 1\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 0) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 50) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 0\n assert candidate(nums = [-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000],k = 5000) == 3\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 120) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 20) == 0\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90],k = 0) == 2\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 1) == 2\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 10) == 1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 0) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = -55) == 0\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 55000) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 225) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = -50) == 1\n assert candidate(nums = [-100000, -90000, -80000, -70000, -60000, -50000, -40000, -30000, -20000, -10000],k = -55000) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 14\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 0) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],k = 210) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 275) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],k = -10) == 1\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],k = 50000) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 55) == 0\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 500000) == 1\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 1) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900],k = 4500) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 550) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 190) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 100) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().waysToPartition", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def waysToPartition(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "waysToPartition", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2027, "task_id": "minimum-moves-to-convert-string", "difficulty": "Easy", "problem_description": "You are given a string s consisting of n characters which are either 'X' or 'O'.\nA move is defined as selecting three consecutive characters of s and converting them to 'O'. Note that if a move is applied to the character 'O', it will stay the same.\nReturn the minimum number of moves required so that all the characters of s are converted to 'O'.\n \nExample 1:\n\nInput: s = \"XXX\"\nOutput: 1\nExplanation: XXX -> OOO\nWe select all the 3 characters and convert them in one move.\n\nExample 2:\n\nInput: s = \"XXOX\"\nOutput: 2\nExplanation: XXOX -> OOOX -> OOOO\nWe select the first 3 characters in the first move, and convert them to 'O'.\nThen we select the last 3 characters and convert them so that the final string contains all 'O's.\nExample 3:\n\nInput: s = \"OOOO\"\nOutput: 0\nExplanation: There are no 'X's in s to convert.\n\n \nConstraints:\n\n3 <= s.length <= 1000\ns[i] is either 'X' or 'O'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"XXXXXXXXXX\") == 4\n assert candidate(s = \"OOXOOX\") == 2\n assert candidate(s = \"OOXOOXOOXO\") == 3\n assert candidate(s = \"OOXXOOXXOO\") == 2\n assert candidate(s = \"XXOX\") == 2\n assert candidate(s = \"OXOXOXOXOX\") == 3\n assert candidate(s = \"XOOOXXOOOX\") == 3\n assert candidate(s = \"XXX\") == 1\n assert candidate(s = \"OOOO\") == 0\n assert candidate(s = \"XOOXOX\") == 2\n assert candidate(s = \"OXOXOX\") == 2\n assert candidate(s = \"OOOXXOOOXXOOO\") == 2\n assert candidate(s = \"XOXOXOXOXO\") == 3\n assert candidate(s = \"XXXXXX\") == 2\n assert candidate(s = \"XOOXOOXOOX\") == 4\n assert candidate(s = \"XXXXXXXXX\") == 3\n assert candidate(s = \"XOXOXO\") == 2\n assert candidate(s = \"OOXXOOX\") == 2\n assert candidate(s = \"OOXOXO\") == 1\n assert candidate(s = \"XOOOOXOOXOXXXX\") == 4\n assert candidate(s = \"XOOXOXOOXOXOXO\") == 4\n assert candidate(s = \"OOXOXOXXOXXOOXOX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 8\n assert candidate(s = \"XOXOOXOXOOXOXOXOXOOXOXOXOOXOXOXOOXO\") == 9\n assert candidate(s = \"XOOXOXOOXOOXOOXOOXOOXOOXOOXOOX\") == 10\n assert candidate(s = \"XOXOXXOOXOXOXXXOXO\") == 5\n assert candidate(s = \"XOOXOXOOXOXOOXOXOOX\") == 5\n assert candidate(s = \"OOXOOXOOXOOXOO\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXO\") == 7\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 12\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 9\n assert candidate(s = \"XOOOXOOOXOOOXOOOXOOO\") == 5\n assert candidate(s = \"XOOXOXOXOXOXOXOX\") == 5\n assert candidate(s = \"OOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"OOOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXOOOOXXOOOOXXOOOOXXOOOOXXOOOOXXOOOOXXOOOOXX\") == 8\n assert candidate(s = \"OOXXOOXXOOXXXX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 9\n assert candidate(s = \"XOOXXOOXXOOXXOOXX\") == 5\n assert candidate(s = \"XOXOXOXOXOOOXOXO\") == 4\n assert candidate(s = \"XXXOXOXOXOXO\") == 3\n assert candidate(s = \"XXOOXOXOXOXOXX\") == 4\n assert candidate(s = \"OXXOXOXOXOXO\") == 3\n assert candidate(s = \"XXXXXXXXXXXXXXXXXXX\") == 7\n assert candidate(s = \"OOXOXOXOXOOO\") == 2\n assert candidate(s = \"OXOXOXOXOXOX\") == 3\n assert candidate(s = \"XXOOXOXOXOXOXXOXOXXOXOXXOXOXXOXOXX\") == 10\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 14\n assert candidate(s = \"XOXOXOXOXOXO\") == 3\n assert candidate(s = \"XOOOXXXXOOOXXXXOOO\") == 5\n assert candidate(s = \"XXOXOXOXOXOXOXOXOXOXOXOXOX\") == 7\n assert candidate(s = \"XXOOXXOOXXOOXXOOXXOOX\") == 6\n assert candidate(s = \"XXXXXXXXXXXXXXXX\") == 6\n assert candidate(s = \"XXXOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"XOXXXXXXXXXOXOXOXOXOXOXOXO\") == 8\n assert candidate(s = \"XOXOXXXXXXXXXOXXXXXXXXXOXXXXXXXXXOXXXXXXXXXO\") == 13\n assert candidate(s = \"OOXOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 12\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXOXOX\") == 6\n assert candidate(s = \"OOXXOOXXOOXXOOXXOOXXOO\") == 5\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXOXOXOX\") == 6\n assert candidate(s = \"XXXXXXXXXOOOOOOOOOXXXXXXXXX\") == 6\n assert candidate(s = \"XXOOXXOOXXOOXXOOXX\") == 5\n assert candidate(s = \"XOOXOOXOOXOOXOOX\") == 6\n assert candidate(s = \"OOXOXOXOXOXOXOXOXOXOXOXOXOXOXOOO\") == 7\n assert candidate(s = \"OOXOOXOOXOOXOOXO\") == 5\n assert candidate(s = \"XXXXXXXXXXXXX\") == 5\n assert candidate(s = \"XXOOXOXOXOXOXO\") == 4\n assert candidate(s = \"XXXOOOOXOXOOXOXO\") == 3\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXO\") == 6\n assert candidate(s = \"XXOOXXOOXXOOXX\") == 4\n assert candidate(s = \"XOOXOOXOOXOXOX\") == 5\n assert candidate(s = \"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXOOXOXOXOXOXOXOXO\") == 5\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOX\") == 7\n assert candidate(s = \"OOOXXXOOOXXXOOO\") == 2\n assert candidate(s = \"XXXOXOXOXXXO\") == 3\n assert candidate(s = \"XOXOXXOOXOXO\") == 3\n assert candidate(s = \"OXXXXOOOXXXXOOOXXX\") == 5\n assert candidate(s = \"OOOXOXOXOXOXOXOOOO\") == 3\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOXOOX\") == 8\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOO\") == 6\n assert candidate(s = \"OOXOOXOOXOOXOOX\") == 5\n assert candidate(s = \"XXXXXXXXXXXXXXXXXXXXXXXX\") == 8\n assert candidate(s = \"OOXOXOXOXOXOXOOO\") == 3\n assert candidate(s = \"XOXXOXXOXXOXXOXX\") == 6\n assert candidate(s = \"XXOOXOXOXOXOXOXOXOXX\") == 6\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXO\") == 13\n assert candidate(s = \"XOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"OXOXOXOXOXOXOX\") == 4\n assert candidate(s = \"XXOXOXOXOXOXOXOXOXOX\") == 6\n assert candidate(s = \"XXXXOXXXXOXXXXO\") == 5\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 7\n assert candidate(s = \"XOOXOXOOXOXOOXOXOOXOXOOX\") == 6\n assert candidate(s = \"OOOOXXOOXXOOXX\") == 3\n assert candidate(s = \"XXOOXXOOXXOOXXOOXXOOXXOOXXOOX\") == 8\n assert candidate(s = \"XXXXOOXXXXOOXXXXOO\") == 6\n assert candidate(s = \"XXOXXOXXOXXOXX\") == 5\n assert candidate(s = \"OOOOOOOOOOOOO\") == 0\n assert candidate(s = \"OOXXXXXXOOXXXXXXOOXXXXXX\") == 6\n assert candidate(s = \"XOXOXXXOXOXOXXX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXO\") == 5\n assert candidate(s = \"XOXOXOOXOXOX\") == 4\n assert candidate(s = \"XXOOXXOOXXOOXXOOXXOO\") == 5\n assert candidate(s = \"XXXXXXXXXXXXXXXXXX\") == 6\n assert candidate(s = \"XXXXXXXXXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 13\n assert candidate(s = \"XXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 9\n assert candidate(s = \"XXOXOXOXOXOXOXOX\") == 5\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOXOOXOOX\") == 9\n assert candidate(s = \"XOOOXOOOXOOOXOOO\") == 4\n assert candidate(s = \"OOXXOOXXOOXXOO\") == 3\n assert candidate(s = \"XOXOXOXOXOXOX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXO\") == 5\n assert candidate(s = \"XXOXOXOXOXOX\") == 4\n assert candidate(s = \"OOXOXOXOXO\") == 2\n assert candidate(s = \"XOOOXXOOOOXXOOOXXOOO\") == 4\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOOXOOX\") == 8\n assert candidate(s = \"XXOXOXOXOXOXOX\") == 4\n assert candidate(s = \"OXOXOXOXOXOXOXOXOX\") == 5\n assert candidate(s = \"OXOOXOOXOOXOOXOOXOOXOOX\") == 8\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOOXOOXOOXOO\") == 9\n assert candidate(s = \"OXXOXOXXOXOXXOXO\") == 5\n assert candidate(s = \"XXXXXXXXOXOXO\") == 4\n assert candidate(s = \"XXXXXXXXOOOXXXXX\") == 5\n assert candidate(s = \"OOXXOOXXOOXXOOXXOOXXOOXXOO\") == 6\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOO\") == 12\n assert candidate(s = \"XOOXOXXOXOXXOX\") == 5\n assert candidate(s = \"OOOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOO\") == 9\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXO\") == 5\n assert candidate(s = \"OXOXOXOXOXOXO\") == 3\n assert candidate(s = \"XXXXOXXXXOXXXXOXXXXOXXXXOXXXXOXXXXO\") == 11\n assert candidate(s = \"XOXOXXXXXXXXOXXXXXXXXX\") == 7\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOX\") == 12\n assert candidate(s = \"XOOOXXOOOXXOOOXXOOO\") == 4\n assert candidate(s = \"OOOXOXOXOXOXOXOXOXOXOXOOOO\") == 5\n assert candidate(s = \"XOXXOXOXXOXOXXOXOXXOXXO\") == 7\n assert candidate(s = \"OOXOXOXOXOXOXOXOXOXOXOXOXO\") == 6\n assert candidate(s = \"OOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXOXXOXXOXXO\") == 4\n assert candidate(s = \"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"OXOXOXOXOXOXOXOX\") == 4\n assert candidate(s = \"XXXXXXXXXXXXXXXXXOOOOOOOOOOOO\") == 6\n assert candidate(s = \"OOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXXXXXXXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 11\n assert candidate(s = \"XXXOOXOXOOXOXX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"XOOOOXOOOOXOOOOXOOOO\") == 4\n assert candidate(s = \"XOOXXOOXXOOXXOOX\") == 5\n assert candidate(s = \"OOOXOXOXOXOXOOOO\") == 3\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOX\") == 12\n assert candidate(s = \"XOOOOXOOOXOOO\") == 3\n assert candidate(s = \"XXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXX\") == 11\n assert candidate(s = \"OOXOXOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"XOXOXOOXOXOXOO\") == 4\n assert candidate(s = \"XOOOOXOOOOXOOOOXOOOOXOOOO\") == 5\n assert candidate(s = \"XOOXOXOXOXOX\") == 4\n assert candidate(s = \"OOXOOOXOOOXOOOXOOOXOOOXOOOXOOOXOOOXOOOXOOO\") == 10\n assert candidate(s = \"XXOOXXOOXXOO\") == 3\n assert candidate(s = \"XXXXXXXXOOOOXXXXXXXX\") == 6\n assert candidate(s = \"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\") == 14\n assert candidate(s = \"XXXXXXXXXXXXXXXXX\") == 6\n assert candidate(s = \"XOXOOXOXOOXOXOXO\") == 4\n assert candidate(s = \"OXOOXOOOXOXOOXOO\") == 4\n assert candidate(s = \"XXOXOXXOXOXOXXOX\") == 5\n assert candidate(s = \"OOOOOOOOOOOOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXXXXXXXXXXXXX\") == 5\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumMoves", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumMoves(self, s: str) -> int:", "container": "Solution", "callable": "minimumMoves", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2028, "task_id": "find-missing-observations", "difficulty": "Medium", "problem_description": "You have observations of n + m 6-sided dice rolls with each face numbered from 1 to 6. n of the observations went missing, and you only have the observations of m rolls. Fortunately, you have also calculated the average value of the n + m rolls.\nYou are given an integer array rolls of length m where rolls[i] is the value of the ith observation. You are also given the two integers mean and n.\nReturn an array of length n containing the missing observations such that the average value of the n + m rolls is exactly mean. If there are multiple valid answers, return any of them. If no such array exists, return an empty array.\nThe average value of a set of k numbers is the sum of the numbers divided by k.\nNote that mean is an integer, so the sum of the n + m rolls should be divisible by n + m.\n \nExample 1:\n\nInput: rolls = [3,2,4,3], mean = 4, n = 2\nOutput: [6,6]\nExplanation: The mean of all n + m rolls is (3 + 2 + 4 + 3 + 6 + 6) / 6 = 4.\n\nExample 2:\n\nInput: rolls = [1,5,6], mean = 3, n = 4\nOutput: [2,3,2,2]\nExplanation: The mean of all n + m rolls is (1 + 5 + 6 + 2 + 3 + 2 + 2) / 7 = 3.\n\nExample 3:\n\nInput: rolls = [1,2,3,4], mean = 6, n = 4\nOutput: []\nExplanation: It is impossible for the mean to be 6 no matter what the 4 missing rolls are.\n\n \nConstraints:\n\nm == rolls.length\n1 <= n, m <= 105\n1 <= rolls[i], mean <= 6\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rolls = [1, 2],mean = 3,n = 2) == [5, 4]\n assert candidate(rolls = [1, 3, 5],mean = 2,n = 2) == []\n assert candidate(rolls = [5, 5, 5, 5],mean = 5,n = 4) == [5, 5, 5, 5]\n assert candidate(rolls = [5, 6, 6, 6],mean = 5,n = 3) == [4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6],mean = 6,n = 3) == [6, 6, 6]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 3,n = 6) == [3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 2, 3, 4],mean = 6,n = 4) == []\n assert candidate(rolls = [1, 5, 6],mean = 3,n = 4) == [3, 2, 2, 2]\n assert candidate(rolls = [5, 5, 5, 5],mean = 5,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1],mean = 2,n = 6) == [3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [3, 2, 4, 3],mean = 4,n = 2) == [6, 6]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 5,n = 6) == [4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 1, 1, 1],mean = 2,n = 4) == [3, 3, 3, 3]\n assert candidate(rolls = [3],mean = 4,n = 1) == [5]\n assert candidate(rolls = [6],mean = 6,n = 1) == [6]\n assert candidate(rolls = [1, 1, 1],mean = 2,n = 3) == [3, 3, 3]\n assert candidate(rolls = [6, 6, 6],mean = 5,n = 3) == [4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],mean = 3,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6],mean = 3,n = 6) == [3, 3, 3, 2, 2, 2]\n assert candidate(rolls = [1],mean = 6,n = 5) == []\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 6,n = 15) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 4,n = 3) == [6, 6, 6]\n assert candidate(rolls = [1, 1, 1, 1],mean = 2,n = 10) == [3, 3, 3, 3, 2, 2, 2, 2, 2, 2]\n assert candidate(rolls = [1, 1, 1, 1, 1],mean = 5,n = 5) == []\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 4,n = 20) == []\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 3,n = 3) == [3, 3, 3]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 12) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 6, 3, 4, 2, 5],mean = 3,n = 5) == [3, 3, 2, 2, 2]\n assert candidate(rolls = [2, 4, 6, 1, 3, 5],mean = 4,n = 3) == [5, 5, 5]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1],mean = 4,n = 12) == [5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 6, 1, 6, 1, 6],mean = 4,n = 3) == [5, 5, 5]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 6,n = 10) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 2, 3, 4, 5],mean = 4,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],mean = 4,n = 20) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3],mean = 5,n = 5) == []\n assert candidate(rolls = [5, 1, 5, 1, 5, 1],mean = 4,n = 2) == []\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1],mean = 4,n = 18) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],mean = 3,n = 15) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 15) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 1, 1, 1, 1],mean = 2,n = 10) == [3, 3, 3, 3, 3, 2, 2, 2, 2, 2]\n assert candidate(rolls = [6, 5, 4, 3, 2, 1],mean = 3,n = 7) == [3, 3, 3, 3, 2, 2, 2]\n assert candidate(rolls = [1, 2, 3],mean = 2,n = 9) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(rolls = [4, 4, 4, 4, 4, 4, 4, 4],mean = 4,n = 1) == [4]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2],mean = 2,n = 12) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 20) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [2, 3, 4, 5, 6],mean = 4,n = 6) == [4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6],mean = 4,n = 3) == [5, 5, 5]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 6,n = 12) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [6, 4, 6, 4, 6, 4],mean = 5,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 3,n = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 5,n = 12) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [6, 5, 4, 3, 2, 1],mean = 4,n = 10) == [5, 5, 5, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [5, 1, 5, 1, 5, 1],mean = 3,n = 6) == [3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [4, 4, 4, 4, 4, 4],mean = 5,n = 1) == []\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 5,n = 10) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 6,n = 6) == [6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 20) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 1,n = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 6,n = 6) == [6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 1, 2, 2, 3, 3],mean = 3,n = 3) == [5, 5, 5]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 6) == [5, 5, 5, 4, 4, 4]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 6,n = 18) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 6, 1, 6, 1, 6],mean = 4,n = 6) == [5, 5, 5, 4, 4, 4]\n assert candidate(rolls = [1, 6, 1, 6, 1, 6],mean = 4,n = 3) == [5, 5, 5]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2],mean = 3,n = 4) == [5, 5, 5, 4]\n assert candidate(rolls = [1, 2, 3, 4, 5],mean = 2,n = 1) == []\n assert candidate(rolls = [2, 4, 6, 5, 4, 3, 2],mean = 4,n = 5) == [5, 5, 4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 5,n = 5) == [4, 4, 4, 4, 3]\n assert candidate(rolls = [6, 6, 6, 6],mean = 4,n = 8) == [3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 5,n = 20) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 10) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [6, 5, 4, 3, 2, 1],mean = 4,n = 5) == [5, 5, 5, 4, 4]\n assert candidate(rolls = [1, 2, 3, 4, 5],mean = 3,n = 5) == [3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],mean = 4,n = 5) == [6, 6, 6, 5, 5]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],mean = 4,n = 12) == [5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 4,n = 5) == []\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 4,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 3,n = 10) == [2, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rolls = [4, 5, 6, 1, 2, 3],mean = 4,n = 6) == [5, 5, 5, 4, 4, 4]\n assert candidate(rolls = [1, 2, 2, 3, 3, 4, 5, 6],mean = 3,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 2, 2]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 5) == [4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],mean = 4,n = 5) == [5, 5, 5, 4, 4]\n assert candidate(rolls = [5, 5, 5, 5, 5],mean = 5,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 18) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5],mean = 4,n = 6) == [3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 5,n = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 4,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1],mean = 2,n = 9) == [3, 3, 3, 3, 3, 3, 3, 2, 2]\n assert candidate(rolls = [4, 4, 4, 4, 4, 4],mean = 4,n = 3) == [4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],mean = 4,n = 5) == [6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 3,n = 20) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [6],mean = 1,n = 5) == []\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 4,n = 3) == [6, 6, 6]\n assert candidate(rolls = [2, 4, 6, 8, 10],mean = 4,n = 5) == [2, 2, 2, 2, 2]\n assert candidate(rolls = [6, 6, 6, 6, 6],mean = 6,n = 1) == [6]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],mean = 4,n = 12) == [5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 4,n = 10) == [5, 5, 5, 5, 5, 5, 4, 4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6],mean = 5,n = 2) == [3, 3]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 5,n = 3) == [3, 3, 3]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 5,n = 20) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [3, 3, 3, 3, 3],mean = 5,n = 5) == []\n assert candidate(rolls = [6, 5, 4, 3, 2, 1],mean = 4,n = 6) == [5, 5, 5, 4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 6,n = 10) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6],mean = 4,n = 5) == [5, 5, 5, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 4,n = 5) == [6, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 20) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],mean = 5,n = 10) == []\n assert candidate(rolls = [1, 2, 3, 4, 5],mean = 3,n = 7) == [3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],mean = 5,n = 5) == [4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],mean = 5,n = 15) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(rolls = [1, 1, 2, 2, 3, 3],mean = 3,n = 6) == [4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 10) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],mean = 3,n = 5) == [3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 2, 3],mean = 4,n = 3) == [6, 6, 6]\n"}, "metadata": {"canonical_parameter_names": ["rolls", "mean", "n"], "leetcode_dataset_entry_point": "Solution().missingRolls", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def missingRolls(self, rolls: list[int], mean: int, n: int) -> list[int]:", "container": "Solution", "callable": "missingRolls", "parameters": [{"name": "rolls", "type": "list[int]"}, {"name": "mean", "type": "int"}, {"name": "n", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2029, "task_id": "stone-game-ix", "difficulty": "Medium", "problem_description": "Alice and Bob continue their games with stones. There is a row of n stones, and each stone has an associated value. You are given an integer array stones, where stones[i] is the value of the ith stone.\nAlice and Bob take turns, with Alice starting first. On each turn, the player may remove any stone from stones. The player who removes a stone loses if the sum of the values of all removed stones is divisible by 3. Bob will win automatically if there are no remaining stones (even if it is Alice's turn).\nAssuming both players play optimally, return true if Alice wins and false if Bob wins.\n \nExample 1:\n\nInput: stones = [2,1]\nOutput: true\nExplanation: The game will be played as follows:\n- Turn 1: Alice can remove either stone.\n- Turn 2: Bob removes the remaining stone. \nThe sum of the removed stones is 1 + 2 = 3 and is divisible by 3. Therefore, Bob loses and Alice wins the game.\n\nExample 2:\n\nInput: stones = [2]\nOutput: false\nExplanation: Alice will remove the only stone, and the sum of the values on the removed stones is 2. \nSince all the stones are removed and the sum of values is not divisible by 3, Bob wins the game.\n\nExample 3:\n\nInput: stones = [5,1,2,4,3]\nOutput: false\nExplanation: Bob will always win. One possible way for Bob to win is shown below:\n- Turn 1: Alice can remove the second stone with value 1. Sum of removed stones = 1.\n- Turn 2: Bob removes the fifth stone with value 3. Sum of removed stones = 1 + 3 = 4.\n- Turn 3: Alices removes the fourth stone with value 4. Sum of removed stones = 1 + 3 + 4 = 8.\n- Turn 4: Bob removes the third stone with value 2. Sum of removed stones = 1 + 3 + 4 + 2 = 10.\n- Turn 5: Alice removes the first stone with value 5. Sum of removed stones = 1 + 3 + 4 + 2 + 5 = 15.\nAlice loses the game because the sum of the removed stones (15) is divisible by 3. Bob wins the game.\n\n \nConstraints:\n\n1 <= stones.length <= 105\n1 <= stones[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(stones = [3, 6, 9, 12, 15]) == False\n assert candidate(stones = [2, 1]) == True\n assert candidate(stones = [1, 2, 3, 6, 9, 12, 15]) == False\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [3, 3, 3]) == False\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 1]) == False\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [1, 5, 9, 13, 17, 21]) == True\n assert candidate(stones = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [5, 1, 2, 4, 3]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21]) == False\n assert candidate(stones = [1, 5, 7, 11, 13, 17, 19]) == True\n assert candidate(stones = [10, 20, 30, 40, 50]) == False\n assert candidate(stones = [3, 6, 9]) == False\n assert candidate(stones = [1, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73]) == True\n assert candidate(stones = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == True\n assert candidate(stones = [2]) == False\n assert candidate(stones = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == True\n assert candidate(stones = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == False\n assert candidate(stones = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == True\n assert candidate(stones = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27]) == False\n assert candidate(stones = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == False\n assert candidate(stones = [1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2]) == True\n assert candidate(stones = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == False\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3]) == True\n assert candidate(stones = [2, 2, 2, 1, 1, 1, 0, 0, 0]) == False\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == False\n assert candidate(stones = [1, 2, 4, 5, 7, 8, 10, 11]) == True\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(stones = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == False\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == False\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == True\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80]) == False\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1]) == True\n assert candidate(stones = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28]) == False\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == False\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29]) == False\n assert candidate(stones = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == False\n assert candidate(stones = [5, 1, 2, 4, 3, 5, 1, 2, 4, 3, 5, 1, 2, 4, 3, 5, 1, 2, 4, 3, 5, 1, 2, 4, 3, 5, 1, 2, 4, 3]) == True\n assert candidate(stones = [1, 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 8, 8, 8, 9, 10, 10, 10, 11, 12, 12, 12, 13, 14, 15, 16, 16, 17, 18, 18, 19, 19, 20]) == False\n assert candidate(stones = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == False\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(stones = [3, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51]) == False\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(stones = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17]) == True\n assert candidate(stones = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4]) == True\n assert candidate(stones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == True\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == False\n assert candidate(stones = [1, 2, 2, 2, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1]) == True\n assert candidate(stones = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == False\n assert candidate(stones = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88]) == False\n assert candidate(stones = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(stones = [3, 6, 9, 12, 15, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22]) == False\n assert candidate(stones = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == True\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87]) == False\n assert candidate(stones = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == False\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(stones = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == False\n assert candidate(stones = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == True\n assert candidate(stones = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == True\n assert candidate(stones = [3, 6, 9, 2, 5, 8, 11, 14, 17, 20]) == True\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == False\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29]) == True\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [1, 2, 2, 1, 2, 1, 2, 2, 1]) == True\n assert candidate(stones = [1, 2, 2, 2, 3, 3, 3, 3, 4, 5, 6, 6, 6, 6, 7, 8, 9]) == False\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == False\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59]) == False\n assert candidate(stones = [1001, 1004, 1007, 1010, 1013, 1016, 1019, 1022, 1025, 1028, 1031, 1034, 1037, 1040, 1043, 1046, 1049, 1052, 1055, 1058]) == False\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == True\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(stones = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == True\n assert candidate(stones = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]) == False\n assert candidate(stones = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == True\n assert candidate(stones = [1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6]) == True\n assert candidate(stones = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == False\n assert candidate(stones = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180]) == False\n assert candidate(stones = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == True\n assert candidate(stones = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1]) == True\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7]) == True\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == False\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86, 89]) == False\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == False\n assert candidate(stones = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58]) == False\n assert candidate(stones = [1, 2, 2, 1, 2, 2, 1, 2]) == True\n assert candidate(stones = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(stones = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == False\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == False\n assert candidate(stones = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(stones = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]) == True\n assert candidate(stones = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == True\n"}, "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().stoneGameIX", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def stoneGameIX(self, stones: list[int]) -> bool:", "container": "Solution", "callable": "stoneGameIX", "parameters": [{"name": "stones", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2030, "task_id": "smallest-k-length-subsequence-with-occurrences-of-a-letter", "difficulty": "Hard", "problem_description": "You are given a string s, an integer k, a letter letter, and an integer repetition.\nReturn the lexicographically smallest subsequence of s of length k that has the letter letter appear at least repetition times. The test cases are generated so that the letter appears in s at least repetition times.\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\nA string a is lexicographically smaller than a string b if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b.\n \nExample 1:\n\nInput: s = \"leet\", k = 3, letter = \"e\", repetition = 1\nOutput: \"eet\"\nExplanation: There are four subsequences of length 3 that have the letter 'e' appear at least 1 time:\n- \"lee\" (from \"leet\")\n- \"let\" (from \"leet\")\n- \"let\" (from \"leet\")\n- \"eet\" (from \"leet\")\nThe lexicographically smallest subsequence among them is \"eet\".\n\nExample 2:\n\n\nInput: s = \"leetcode\", k = 4, letter = \"e\", repetition = 2\nOutput: \"ecde\"\nExplanation: \"ecde\" is the lexicographically smallest subsequence of length 4 that has the letter \"e\" appear at least 2 times.\n\nExample 3:\n\nInput: s = \"bb\", k = 2, letter = \"b\", repetition = 2\nOutput: \"bb\"\nExplanation: \"bb\" is the only subsequence of length 2 that has the letter \"b\" appear at least 2 times.\n\n \nConstraints:\n\n1 <= repetition <= k <= s.length <= 5 * 104\ns consists of lowercase English letters.\nletter is a lowercase English letter, and appears in s at least repetition times.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"bb\",k = 2,letter = \"b\",repetition = 2) == \"bb\"\n assert candidate(s = \"leetcode\",k = 4,letter = \"e\",repetition = 2) == \"ecde\"\n assert candidate(s = \"leet\",k = 3,letter = \"e\",repetition = 1) == \"eet\"\n assert candidate(s = \"aabbc\",k = 3,letter = \"a\",repetition = 1) == \"aab\"\n assert candidate(s = \"abacabad\",k = 4,letter = \"a\",repetition = 2) == \"aaaa\"\n assert candidate(s = \"zzzzz\",k = 3,letter = \"z\",repetition = 3) == \"zzz\"\n assert candidate(s = \"abcdedcba\",k = 5,letter = \"d\",repetition = 1) == \"abcda\"\n assert candidate(s = \"zzzzzaaaaa\",k = 5,letter = \"a\",repetition = 3) == \"aaaaa\"\n assert candidate(s = \"apple\",k = 3,letter = \"p\",repetition = 1) == \"ape\"\n assert candidate(s = \"abacabadabacaba\",k = 7,letter = \"a\",repetition = 3) == \"aaaaaaa\"\n assert candidate(s = \"azbzczdz\",k = 4,letter = \"z\",repetition = 2) == \"abzz\"\n assert candidate(s = \"abcdedcba\",k = 5,letter = \"c\",repetition = 1) == \"abcba\"\n assert candidate(s = \"xyzxyzxyz\",k = 5,letter = \"z\",repetition = 2) == \"xxyzz\"\n assert candidate(s = \"abcdedcba\",k = 5,letter = \"c\",repetition = 2) == \"abcca\"\n assert candidate(s = \"zzzz\",k = 2,letter = \"z\",repetition = 2) == \"zz\"\n assert candidate(s = \"abcabcabc\",k = 6,letter = \"a\",repetition = 2) == \"aababc\"\n assert candidate(s = \"abcdabcdabcd\",k = 9,letter = \"b\",repetition = 3) == \"ababcabcd\"\n assert candidate(s = \"elephant\",k = 4,letter = \"e\",repetition = 1) == \"eant\"\n assert candidate(s = \"zazbzazbzazb\",k = 8,letter = \"z\",repetition = 4) == \"abzazbzz\"\n assert candidate(s = \"babcbabcbabc\",k = 5,letter = \"b\",repetition = 3) == \"aabbb\"\n assert candidate(s = \"abcdedcbaabcdedcbaabcdedcba\",k = 15,letter = \"c\",repetition = 3) == \"aaabcaabcdedcba\"\n assert candidate(s = \"aaaaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\",k = 20,letter = \"c\",repetition = 4) == \"aaaaaaaaaaaabbbbcccc\"\n assert candidate(s = \"aaaaaabbbbbbcccccc\",k = 12,letter = \"b\",repetition = 4) == \"aaaaaabbbbbb\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 26,letter = \"z\",repetition = 1) == \"aabcdefghijklmnopqrstuvwxz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 13,letter = \"m\",repetition = 1) == \"abcdefghijklm\"\n assert candidate(s = \"mississippi\",k = 5,letter = \"i\",repetition = 2) == \"iiipi\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\",k = 26,letter = \"a\",repetition = 2) == \"ayxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"ababababababababababababababababababababababab\",k = 10,letter = \"a\",repetition = 3) == \"aaaaaaaaaa\"\n assert candidate(s = \"xyzyxyzyxyzyxyzyzyzyxyzyzyzyzyzyxyzyxyzyzyzyzyzy\",k = 15,letter = \"x\",repetition = 3) == \"xxxxxxxyyyyzyzy\"\n assert candidate(s = \"aabbccddeeff\",k = 8,letter = \"c\",repetition = 3) == \"aabbccd\"\n assert candidate(s = \"zzzzzaaaaabbbb\",k = 10,letter = \"a\",repetition = 4) == \"zaaaaabbbb\"\n assert candidate(s = \"mississippi\",k = 4,letter = \"i\",repetition = 2) == \"iiii\"\n assert candidate(s = \"mississippi\",k = 6,letter = \"i\",repetition = 2) == \"iiippi\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 50,letter = \"z\",repetition = 10) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 20,letter = \"a\",repetition = 2) == \"aabbccddeeffgghhiijj\"\n assert candidate(s = \"banana\",k = 4,letter = \"a\",repetition = 2) == \"aana\"\n assert candidate(s = \"abcdabcdabcd\",k = 8,letter = \"b\",repetition = 3) == \"abababcd\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 10,letter = \"m\",repetition = 2) == \"abcdefghm\"\n assert candidate(s = \"abracadabra\",k = 7,letter = \"a\",repetition = 3) == \"aaaabra\"\n assert candidate(s = \"zyxzyxzyx\",k = 5,letter = \"x\",repetition = 2) == \"xxzyx\"\n assert candidate(s = \"abracadabraabracadabra\",k = 12,letter = \"a\",repetition = 4) == \"aaaaaaaaabra\"\n assert candidate(s = \"racecar\",k = 5,letter = \"e\",repetition = 1) == \"acear\"\n assert candidate(s = \"abcdabcabcabc\",k = 9,letter = \"c\",repetition = 3) == \"aabcabcac\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwerty\",k = 12,letter = \"r\",repetition = 2) == \"erabnmqwerty\"\n assert candidate(s = \"xyzyzyzyzyx\",k = 7,letter = \"y\",repetition = 3) == \"xyyyyyx\"\n"}, "metadata": {"canonical_parameter_names": ["s", "k", "letter", "repetition"], "leetcode_dataset_entry_point": "Solution().smallestSubsequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def smallestSubsequence(self, s: str, k: int, letter: str, repetition: int) -> str:", "container": "Solution", "callable": "smallestSubsequence", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}, {"name": "letter", "type": "str"}, {"name": "repetition", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2032, "task_id": "two-out-of-three", "difficulty": "Easy", "problem_description": "Given three integer arrays nums1, nums2, and nums3, return a distinct array containing all the values that are present in at least two out of the three arrays. You may return the values in any order.\n \nExample 1:\n\nInput: nums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3]\nOutput: [3,2]\nExplanation: The values that are present in at least two arrays are:\n- 3, in all three arrays.\n- 2, in nums1 and nums2.\n\nExample 2:\n\nInput: nums1 = [3,1], nums2 = [2,3], nums3 = [1,2]\nOutput: [2,3,1]\nExplanation: The values that are present in at least two arrays are:\n- 2, in nums2 and nums3.\n- 3, in nums1 and nums2.\n- 1, in nums1 and nums3.\n\nExample 3:\n\nInput: nums1 = [1,2,2], nums2 = [4,3,3], nums3 = [5]\nOutput: []\nExplanation: No value is present in at least two arrays.\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length, nums3.length <= 100\n1 <= nums1[i], nums2[j], nums3[k] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [5, 6, 7],nums2 = [5, 6, 8],nums3 = [7, 6, 9]) == [5, 6, 7]\n assert candidate(nums1 = [100],nums2 = [100],nums3 = [100]) == [100]\n assert candidate(nums1 = [5, 5, 5],nums2 = [5, 5, 5],nums3 = [5, 5, 5]) == [5]\n assert candidate(nums1 = [10, 20, 30],nums2 = [40, 50, 60],nums3 = [10, 50, 90]) == [10, 50]\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6],nums3 = [7, 8, 9]) == []\n assert candidate(nums1 = [10, 20, 30],nums2 = [20, 30, 40],nums3 = [30, 40, 50]) == [20, 30, 40]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],nums3 = [1, 3, 5, 7, 9]) == [1, 2, 3, 4, 5]\n assert candidate(nums1 = [1, 2],nums2 = [2, 3],nums3 = [3, 4]) == [2, 3]\n assert candidate(nums1 = [1, 2, 2],nums2 = [4, 3, 3],nums3 = [5]) == []\n assert candidate(nums1 = [1, 1, 3, 2],nums2 = [2, 3],nums3 = [3]) == [2, 3]\n assert candidate(nums1 = [3, 1],nums2 = [2, 3],nums3 = [1, 2]) == [1, 2, 3]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 6, 7, 8, 9],nums3 = [3, 4, 5, 10, 11]) == [3, 4, 5]\n assert candidate(nums1 = [10],nums2 = [10, 20],nums3 = [10, 30]) == [10]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums3 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums3 = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == []\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55],nums3 = [20, 30, 40, 50, 60]) == [20, 30, 40, 50]\n assert candidate(nums1 = [1, 2, 3, 1, 2, 3],nums2 = [3, 4, 5, 3, 4, 5],nums3 = [5, 6, 7, 5, 6, 7]) == [3, 5]\n assert candidate(nums1 = [99, 98, 97, 96, 95],nums2 = [94, 93, 92, 91, 90],nums3 = [95, 94, 93, 92, 91]) == [91, 92, 93, 94, 95]\n assert candidate(nums1 = [6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5],nums3 = [5, 6, 7]) == [5, 6, 7]\n assert candidate(nums1 = [50, 50, 50, 50],nums2 = [50, 50, 50, 50],nums3 = [50, 50, 50, 50]) == [50]\n assert candidate(nums1 = [5, 10, 15, 20],nums2 = [10, 20, 30, 40],nums3 = [15, 20, 25, 30]) == [10, 15, 20, 30]\n assert candidate(nums1 = [50, 51, 52, 53, 54, 55],nums2 = [55, 56, 57, 58, 59],nums3 = [59, 60, 61, 62, 63]) == [55, 59]\n assert candidate(nums1 = [7, 7, 7, 7, 7],nums2 = [7, 7, 7, 7, 8],nums3 = [7, 7, 7, 7, 9]) == [7]\n assert candidate(nums1 = [15, 25, 35, 45, 55],nums2 = [55, 65, 75, 85, 95],nums3 = [15, 25, 35, 45, 55]) == [15, 25, 35, 45, 55]\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2],nums3 = [1, 2, 3, 4, 5]) == [1, 2]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45],nums3 = [10, 25, 40, 55]) == [10, 25, 40]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45],nums3 = [10, 20, 30, 40, 50]) == [10, 20, 30, 40, 50]\n assert candidate(nums1 = [60, 61, 62, 63],nums2 = [63, 64, 65, 66],nums3 = [66, 67, 68, 69]) == [63, 66]\n assert candidate(nums1 = [1, 1, 2, 2],nums2 = [2, 2, 3, 3],nums3 = [3, 3, 1, 1]) == [1, 2, 3]\n assert candidate(nums1 = [50, 51, 52, 53, 54],nums2 = [55, 56, 57, 58, 59],nums3 = [50, 51, 52, 53, 54]) == [50, 51, 52, 53, 54]\n assert candidate(nums1 = [1, 1, 1, 2, 2, 3],nums2 = [2, 2, 2, 3, 3, 3],nums3 = [3, 3, 3, 4, 4, 4]) == [2, 3]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 60, 70, 80, 90],nums3 = [90, 10, 20, 30, 100]) == [10, 20, 30, 50, 90]\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [40, 50, 60],nums3 = [10, 50, 70]) == [10, 40, 50]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [2, 3, 4, 5, 6, 7],nums3 = [3, 4, 5, 6, 7, 8]) == [2, 3, 4, 5, 6, 7]\n assert candidate(nums1 = [99, 98, 97],nums2 = [96, 95, 94],nums3 = [93, 92, 91]) == []\n assert candidate(nums1 = [7, 14, 21, 28],nums2 = [14, 28, 42, 56],nums3 = [21, 42, 63, 84]) == [14, 21, 28, 42]\n assert candidate(nums1 = [99, 100],nums2 = [1, 2],nums3 = [3, 4]) == []\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1],nums3 = [2, 2, 2, 2]) == [1]\n assert candidate(nums1 = [90, 91, 92],nums2 = [91, 92, 93],nums3 = [92, 93, 94]) == [91, 92, 93]\n assert candidate(nums1 = [10, 20, 30],nums2 = [20, 30, 40],nums3 = [30, 40, 50]) == [20, 30, 40]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [4, 5, 6, 7, 8],nums3 = [5, 8, 9, 10, 11]) == [4, 5, 8]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],nums3 = [1, 3, 5, 7, 9]) == [1, 2, 3, 4, 5]\n assert candidate(nums1 = [20, 30, 40, 50],nums2 = [50, 60, 70, 80],nums3 = [80, 90, 100, 20]) == [20, 50, 80]\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 40, 50],nums3 = [50, 60, 70]) == [30, 50]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums3 = [21, 22, 23, 24, 25, 1, 2, 3]) == [1, 2, 3]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums3 = [5, 10, 15, 20]) == [5, 10, 15, 20]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],nums3 = [1, 4, 7, 10]) == [1, 4, 7, 10]\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 40, 50],nums3 = [50, 60, 70, 10]) == [10, 30, 50]\n assert candidate(nums1 = [99, 98, 97, 96, 95],nums2 = [94, 95, 96, 97, 98],nums3 = [93, 94, 95, 96, 97]) == [94, 95, 96, 97, 98]\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],nums3 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums1 = [4, 5, 6],nums2 = [7, 8, 9],nums3 = [4, 7, 10]) == [4, 7]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [4, 5, 6, 7, 8],nums3 = [7, 8, 9, 10, 1]) == [1, 4, 5, 7, 8]\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [30, 40, 50, 60],nums3 = [50, 60, 70, 80]) == [30, 40, 50, 60]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [60, 70, 80, 90, 10],nums3 = [11, 22, 33, 44, 50]) == [10, 50]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],nums3 = [1, 3, 5, 7, 9]) == [1, 3, 5, 7, 9]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [2, 4, 6, 8, 10, 12],nums3 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [20, 30, 40, 50],nums3 = [30, 40, 50, 60]) == [20, 30, 40, 50]\n assert candidate(nums1 = [10],nums2 = [20, 30, 40, 50, 10],nums3 = [10, 60, 70, 80, 90]) == [10]\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 3, 5, 7, 9],nums3 = [2, 4, 6, 8, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 6, 7, 8, 9],nums3 = [9, 1, 2, 3]) == [1, 2, 3, 5, 9]\n assert candidate(nums1 = [25, 50, 75, 100],nums2 = [50, 100, 125, 150],nums3 = [100, 150, 200, 25]) == [25, 50, 100]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],nums3 = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6],nums3 = [7, 8, 9]) == []\n assert candidate(nums1 = [60, 61, 62, 63, 64],nums2 = [65, 66, 67, 68, 69],nums3 = [60, 61, 62, 63, 64, 65]) == [60, 61, 62, 63, 64, 65]\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 2, 3, 4],nums3 = [1, 5, 6, 7]) == [1]\n assert candidate(nums1 = [90, 91, 92, 93],nums2 = [91, 92, 93, 94],nums3 = [92, 93, 94, 95]) == [91, 92, 93, 94]\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 40, 50],nums3 = [50, 60, 10]) == [10, 30, 50]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],nums3 = [1, 5, 9, 10, 11]) == [1, 5, 9, 10]\n assert candidate(nums1 = [1, 2],nums2 = [1, 3],nums3 = [1, 4]) == [1]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [10, 20, 60, 70, 80],nums3 = [30, 40, 50, 60, 90]) == [10, 20, 30, 40, 50, 60]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],nums3 = [3, 6, 9, 12]) == [3, 6, 9]\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 2, 2, 2],nums3 = [1, 2, 3, 3]) == [1, 2]\n assert candidate(nums1 = [99, 98, 97],nums2 = [97, 96, 95],nums3 = [95, 94, 93]) == [95, 97]\n assert candidate(nums1 = [50, 51, 52, 53, 54],nums2 = [50, 55, 56, 57, 58],nums3 = [50, 51, 59, 60, 61]) == [50, 51]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 6, 7, 8, 9],nums3 = [9, 10, 1, 11, 12]) == [1, 5, 9]\n assert candidate(nums1 = [1, 4, 7, 9],nums2 = [2, 4, 7, 10],nums3 = [3, 4, 8, 9]) == [4, 7, 9]\n assert candidate(nums1 = [7, 8, 9],nums2 = [10, 11, 12],nums3 = [13, 14, 15]) == []\n assert candidate(nums1 = [25, 50, 75],nums2 = [50, 100],nums3 = [25, 50, 125]) == [25, 50]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [3, 4, 5, 6, 7],nums3 = [5, 6, 7, 8, 9]) == [3, 4, 5, 6, 7]\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6],nums3 = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 20, 31, 42, 53, 64, 75, 86, 97, 108],nums3 = [3, 22, 33, 44, 55, 66, 77, 88, 99, 100]) == [20, 100]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [20, 30, 40, 50, 60],nums3 = [30, 40, 50, 60, 70]) == [20, 30, 40, 50, 60]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],nums3 = [5, 10, 15, 20, 25]) == [5, 10]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],nums3 = [3, 4, 5, 6, 7]) == [3, 4, 5, 6, 7]\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [1, 3, 5, 7, 9],nums3 = [2, 4, 6, 8, 10]) == [2, 4, 6, 8, 10]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1],nums3 = [3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [25, 30, 35, 40, 45],nums3 = [45, 50, 55, 60, 65]) == [25, 45]\n assert candidate(nums1 = [1, 2, 3],nums2 = [1, 2, 4, 5],nums3 = [2, 3, 4, 6]) == [1, 2, 3, 4]\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [10, 15, 20, 25, 30],nums3 = [15, 20, 25, 30, 35]) == [10, 15, 20, 25, 30]\n assert candidate(nums1 = [33, 44, 55, 66],nums2 = [22, 33, 44, 55],nums3 = [11, 22, 33, 44]) == [22, 33, 44, 55]\n assert candidate(nums1 = [20, 30, 40, 50],nums2 = [20, 30, 40],nums3 = [20, 30]) == [20, 30, 40]\n assert candidate(nums1 = [5, 15, 25, 35],nums2 = [5, 15, 45, 55],nums3 = [5, 25, 45, 65]) == [5, 15, 25, 45]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums3 = [1, 11, 3, 13, 5, 15, 7, 17, 9, 19]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums3 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [1, 2, 3, 4, 5, 6],nums3 = [3, 4, 5, 6, 7, 8]) == [1, 2, 3, 4, 5, 6]\n assert candidate(nums1 = [11, 22, 33, 44, 55],nums2 = [55, 66, 77, 88, 99],nums3 = [99, 11, 22, 33, 111]) == [11, 22, 33, 55, 99]\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums3 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [1, 2, 3, 4, 5, 7, 9]\n assert candidate(nums1 = [90, 91, 92],nums2 = [92, 93, 94],nums3 = [94, 95, 96, 97, 90]) == [90, 92, 94]\n assert candidate(nums1 = [1, 1, 2, 2, 3],nums2 = [3, 3, 4, 4, 5],nums3 = [5, 5, 6, 6, 7]) == [3, 5]\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 2],nums3 = [2, 2, 2, 2, 2]) == [1, 2]\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2", "nums3"], "leetcode_dataset_entry_point": "Solution().twoOutOfThree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def twoOutOfThree(self, nums1: list[int], nums2: list[int], nums3: list[int]) -> list[int]:", "container": "Solution", "callable": "twoOutOfThree", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}, {"name": "nums3", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2033, "task_id": "minimum-operations-to-make-a-uni-value-grid", "difficulty": "Medium", "problem_description": "You are given a 2D integer grid of size m x n and an integer x. In one operation, you can add x to or subtract x from any element in the grid.\nA uni-value grid is a grid where all the elements of it are equal.\nReturn the minimum number of operations to make the grid uni-value. If it is not possible, return -1.\n \nExample 1:\n\n\nInput: grid = [[2,4],[6,8]], x = 2\nOutput: 4\nExplanation: We can make every element equal to 4 by doing the following: \n- Add x to 2 once.\n- Subtract x from 6 once.\n- Subtract x from 8 twice.\nA total of 4 operations were used.\n\nExample 2:\n\n\nInput: grid = [[1,5],[2,3]], x = 1\nOutput: 5\nExplanation: We can make every element equal to 3.\n\nExample 3:\n\n\nInput: grid = [[1,2],[3,4]], x = 2\nOutput: -1\nExplanation: It is impossible to make every element equal.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 105\n1 <= m * n <= 105\n1 <= x, grid[i][j] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 5], [2, 3]],x = 1) == 5\n assert candidate(grid = [[10, 10], [10, 10]],x = 5) == 0\n assert candidate(grid = [[10, 10], [10, 10]],x = 3) == 0\n assert candidate(grid = [[10, 12], [14, 16]],x = 2) == 4\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],x = 1) == 0\n assert candidate(grid = [[2, 4], [6, 8]],x = 2) == 4\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 1) == 20\n assert candidate(grid = [[1, 2], [3, 4]],x = 2) == -1\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],x = 5) == 0\n assert candidate(grid = [[1, 1, 1], [1, 1, 1]],x = 3) == 0\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 2) == -1\n assert candidate(grid = [[1, 1], [2, 2]],x = 3) == -1\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],x = 1) == 0\n assert candidate(grid = [[1, 2, 3], [6, 5, 4], [7, 8, 9]],x = 1) == 20\n assert candidate(grid = [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23]],x = 2) == 36\n assert candidate(grid = [[7, 14, 21, 28, 35], [42, 49, 56, 63, 70], [77, 84, 91, 98, 105], [112, 119, 126, 133, 140]],x = 7) == 100\n assert candidate(grid = [[100, 200, 300], [400, 500, 600], [700, 800, 900]],x = 100) == 20\n assert candidate(grid = [[5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],x = 1) == 36\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18]],x = 1) == 81\n assert candidate(grid = [[1, 2], [3, 4], [5, 6]],x = 1) == 9\n assert candidate(grid = [[1, 5, 9], [13, 17, 21], [25, 29, 33]],x = 4) == 20\n assert candidate(grid = [[7, 14, 21], [14, 28, 42], [21, 42, 63]],x = 7) == 17\n assert candidate(grid = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],x = 1) == 8\n assert candidate(grid = [[2, 4, 6, 8], [10, 12, 14, 16], [18, 20, 22, 24]],x = 2) == 36\n assert candidate(grid = [[1, 2], [3, 4], [5, 7]],x = 2) == -1\n assert candidate(grid = [[7, 7, 7], [7, 8, 7], [7, 7, 7]],x = 1) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],x = 1) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],x = 2) == -1\n assert candidate(grid = [[7, 11, 15], [19, 23, 27], [31, 35, 39]],x = 2) == 40\n assert candidate(grid = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],x = 1) == 6\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],x = 15) == -1\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11]],x = 2) == -1\n assert candidate(grid = [[3, 6, 9, 12], [15, 18, 21, 24], [27, 30, 33, 36], [39, 42, 45, 48]],x = 3) == 64\n assert candidate(grid = [[100, 200], [300, 400]],x = 100) == 4\n assert candidate(grid = [[1001, 1002, 1003, 1004], [1005, 1006, 1007, 1008], [1009, 1010, 1011, 1012]],x = 1) == 36\n assert candidate(grid = [[3, 6, 9, 12], [6, 12, 18, 24], [9, 18, 27, 36], [12, 24, 36, 48]],x = 3) == 54\n assert candidate(grid = [[1, 3, 5], [7, 9, 11], [13, 15, 17]],x = 2) == 20\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 2, 1]],x = 1) == 1\n assert candidate(grid = [[5000, 5000, 5000], [5000, 5000, 5000], [5000, 5000, 5000]],x = 1000) == 0\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 3) == -1\n assert candidate(grid = [[5, 10, 15], [20, 25, 30], [35, 40, 45]],x = 5) == 20\n assert candidate(grid = [[2, 4, 6], [8, 10, 12], [14, 16, 18]],x = 2) == 20\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],x = 7) == -1\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],x = 1) == 100\n assert candidate(grid = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100]],x = 10) == 25\n assert candidate(grid = [[10, 20, 30], [20, 30, 40], [30, 40, 50]],x = 10) == 8\n assert candidate(grid = [[2, 4, 6], [8, 10, 12], [14, 16, 18]],x = 5) == -1\n assert candidate(grid = [[4, 8, 12, 16], [8, 16, 24, 32], [12, 24, 36, 48], [16, 32, 48, 64]],x = 4) == 54\n assert candidate(grid = [[4, 8, 12], [16, 20, 24], [28, 32, 36]],x = 4) == 20\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 2]],x = 1) == 1\n assert candidate(grid = [[101, 202, 303], [404, 505, 606], [707, 808, 909]],x = 101) == 20\n assert candidate(grid = [[7, 14, 21, 28], [35, 42, 49, 56], [63, 70, 77, 84]],x = 7) == 36\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],x = 5) == -1\n assert candidate(grid = [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29]],x = 2) == 56\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 4) == -1\n assert candidate(grid = [[1, 5, 9], [2, 6, 10], [3, 7, 11]],x = 2) == -1\n assert candidate(grid = [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39]],x = 2) == 100\n assert candidate(grid = [[101, 102, 103], [104, 105, 106], [107, 108, 109]],x = 1) == 20\n assert candidate(grid = [[1, 4, 7, 10], [13, 16, 19, 22], [25, 28, 31, 34]],x = 3) == 36\n assert candidate(grid = [[1, 2, 3], [2, 3, 4], [3, 4, 5]],x = 1) == 8\n assert candidate(grid = [[1, 5, 9], [2, 6, 10], [3, 7, 11]],x = 3) == -1\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 10]],x = 5) == 1\n assert candidate(grid = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60]],x = 5) == 36\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 10) == -1\n assert candidate(grid = [[5, 9, 13], [17, 21, 25], [29, 33, 37]],x = 4) == 20\n assert candidate(grid = [[3, 6, 9], [12, 15, 18], [21, 24, 27]],x = 3) == 20\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],x = 10) == 20\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],x = 5) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 2, 1, 1]],x = 1) == 1\n assert candidate(grid = [[3, 3, 3, 3, 3], [3, 3, 3, 3, 3], [3, 3, 3, 3, 4]],x = 1) == 1\n assert candidate(grid = [[3, 9, 15], [12, 15, 18], [21, 24, 27]],x = 3) == 17\n assert candidate(grid = [[5, 15, 25, 35], [45, 55, 65, 75], [85, 95, 105, 115], [125, 135, 145, 155]],x = 10) == 64\n assert candidate(grid = [[2, 4, 6], [8, 10, 12], [14, 16, 18]],x = 3) == -1\n assert candidate(grid = [[100, 102, 104], [106, 108, 110], [112, 114, 116]],x = 2) == 20\n assert candidate(grid = [[3, 9, 15], [21, 27, 33], [39, 45, 51]],x = 6) == 20\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 2, 1]],x = 1) == 1\n assert candidate(grid = [[5, 15, 25], [35, 45, 55], [65, 75, 85]],x = 10) == 20\n assert candidate(grid = [[1, 1, 1, 2], [1, 1, 2, 2], [1, 2, 2, 3]],x = 1) == 7\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],x = 1) == 0\n assert candidate(grid = [[123, 456, 789], [1011, 1213, 1415], [1617, 1819, 2021]],x = 3) == -1\n assert candidate(grid = [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23], [25, 27, 29, 31]],x = 2) == 64\n assert candidate(grid = [[5, 10, 15, 20], [10, 20, 30, 40], [15, 30, 45, 60]],x = 5) == 30\n assert candidate(grid = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30]],x = 2) == 56\n assert candidate(grid = [[1, 5, 9, 13, 17], [21, 25, 29, 33, 37], [41, 45, 49, 53, 57]],x = 4) == 56\n assert candidate(grid = [[2, 4, 6, 8], [10, 12, 14, 16], [18, 20, 22, 24], [26, 28, 30, 32]],x = 2) == 64\n assert candidate(grid = [[7, 14, 21], [28, 35, 42], [49, 56, 63]],x = 7) == 20\n assert candidate(grid = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120]],x = 10) == 36\n assert candidate(grid = [[5, 15, 25, 35], [45, 55, 65, 75], [85, 95, 105, 115]],x = 10) == 36\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],x = 1) == 36\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],x = 1) == 56\n assert candidate(grid = [[3, 6, 9, 12], [15, 18, 21, 24], [27, 30, 33, 36]],x = 3) == 36\n assert candidate(grid = [[1, 4, 7, 10], [2, 5, 8, 11], [3, 6, 9, 12]],x = 3) == -1\n assert candidate(grid = [[4, 8, 12, 16], [20, 24, 28, 32], [36, 40, 44, 48]],x = 4) == 36\n assert candidate(grid = [[2, 4, 6], [8, 10, 12], [14, 16, 18]],x = 1) == 40\n assert candidate(grid = [[11, 22, 33], [44, 55, 66], [77, 88, 99]],x = 11) == 20\n"}, "metadata": {"canonical_parameter_names": ["grid", "x"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minOperations(self, grid: list[list[int]], x: int) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "grid", "type": "list[list[int]]"}, {"name": "x", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2035, "task_id": "partition-array-into-two-arrays-to-minimize-sum-difference", "difficulty": "Hard", "problem_description": "You are given an integer array nums of 2 * n integers. You need to partition nums into two arrays of length n to minimize the absolute difference of the sums of the arrays. To partition nums, put each element of nums into one of the two arrays.\nReturn the minimum possible absolute difference.\n \nExample 1:\n\n\nInput: nums = [3,9,7,3]\nOutput: 2\nExplanation: One optimal partition is: [3,9] and [7,3].\nThe absolute difference between the sums of the arrays is abs((3 + 9) - (7 + 3)) = 2.\n\nExample 2:\n\nInput: nums = [-36,36]\nOutput: 72\nExplanation: One optimal partition is: [-36] and [36].\nThe absolute difference between the sums of the arrays is abs((-36) - (36)) = 72.\n\nExample 3:\n\n\nInput: nums = [2,-1,0,4,-2,-9]\nOutput: 0\nExplanation: One optimal partition is: [2,4,-9] and [-1,0,-2].\nThe absolute difference between the sums of the arrays is abs((2 + 4 + -9) - (-1 + 0 + -2)) = 0.\n\n \nConstraints:\n\n1 <= n <= 15\nnums.length == 2 * n\n-107 <= nums[i] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 9, 7, 3]) == 2\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]) == 0\n assert candidate(nums = [10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000]) == 5000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 30]) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000, 1250000, -1250000]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, -1, 0, 4, -2, -9]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40]) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(nums = [10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000]) == 0\n assert candidate(nums = [10000000, -10000000, 10000000, -10000000, 10000000, -10000000]) == 20000000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 0\n assert candidate(nums = [-36, 36]) == 72\n assert candidate(nums = [-1, -2, -3, -4, -5, -6]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]) == 0\n assert candidate(nums = [-1000, 1000, -1500, 1500, -2000, 2000, -2500, 2500, -3000, 3000, -3500, 3500, -4000, 4000, -4500, 4500]) == 0\n assert candidate(nums = [987654, -987654, 876543, -876543, 765432, -765432, 654321, -654321, 543210, -543210, 432109, -432109, 321098, -321098, 210987, -210987]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 0\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000, 125000, -125000, 62500, -62500, 31250, -31250, 15625, -15625, 7812, -7812]) == 0\n assert candidate(nums = [5, -5, 15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75]) == 0\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800]) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(nums = [1234567, -7654321, 8901234, -4321098, 5678901, -1234567, 8765432, -2345678, 9876543, -3456789, 4567890, -5678901, 6789012, -6789012, 7890123, -7890123]) == 7307\n assert candidate(nums = [1000000, -1000000, 2000000, -2000000, 3000000, -3000000, 4000000, -4000000, 5000000, -5000000, 6000000, -6000000, 7000000, -7000000, 8000000, -8000000]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 1\n assert candidate(nums = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, -10000000, -10000000, -10000000, -10000000, -10000000, -10000000]) == 0\n assert candidate(nums = [0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == 0\n assert candidate(nums = [-9, 9, -8, 8, -7, 7, -6, 6, -5, 5, -4, 4, -3, 3, -2, 2]) == 0\n assert candidate(nums = [-1000, 1000, -2000, 2000, -3000, 3000, -4000, 4000, -5000, 5000, -6000, 6000, -7000, 7000, -8000, 8000]) == 0\n assert candidate(nums = [1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [12345, -12345, 67890, -67890, 11111, -11111, 22222, -22222, 33333, -33333, 44444, -44444, 55555, -55555, 66666, -66666]) == 0\n assert candidate(nums = [123, 456, 789, -123, -456, -789, 321, 654, 987, -321, -654, -987, 234, 567, 890, -234, -567, -890]) == 4\n assert candidate(nums = [10000000, -10000000, 20000000, -20000000, 30000000, -30000000, 40000000, -40000000, 50000000, -50000000, 60000000, -60000000, 70000000, -70000000, 80000000, -80000000]) == 0\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16]) == 0\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 0\n assert candidate(nums = [-10000, 10000, -20000, 20000, -30000, 30000, -40000, 40000, -50000, 50000, -60000, 60000, -70000, 70000, -80000, 80000]) == 0\n assert candidate(nums = [5, 2, 9, 11, 15, 18, 3, 7, 14, 6, 10, 4, 8, 13, 1, 12]) == 0\n assert candidate(nums = [100000, -100000, 200000, -200000, 300000, -300000, 400000, -400000, 500000, -500000, 600000, -600000, 700000, -700000, 800000, -800000]) == 0\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]) == 0\n assert candidate(nums = [-100, -200, -300, -400, -500, 500, 400, 300, 200, 100, 0, 100, 200, 300, 400, 500]) == 100\n assert candidate(nums = [9999999, -9999999, 4999999, -4999999, 2499999, -2499999, 1249999, -1249999, 624999, -624999, 312499, -312499, 156249, -156249, 78124, -78124]) == 0\n assert candidate(nums = [1000, -500, 2000, -1500, 3000, -2500, 4000, -3500, 5000, -4500, 6000, -5500, 7000, -6500, 8000, -7500]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 0\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80]) == 0\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300, -1400, 1500, -1600]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]) == 0\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000, 750000, -750000, 375000, -375000, 187500, -187500, 937500, -937500, 468750, -468750]) == 0\n assert candidate(nums = [-7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 0\n assert candidate(nums = [100, 200, 300, 400, -500, 600, -700, 800, -900, 1000, -1100, 1200, -1300, 1400, -1500, 1600]) == 0\n assert candidate(nums = [-5, 5, -10, 10, -15, 15, -20, 20, -25, 25, -30, 30, -35, 35, -40, 40]) == 0\n assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500, -600, 600, -700, 700, -800, 800]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]) == 0\n assert candidate(nums = [-5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 0\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50, -60, 60, -70, 70, -80, 80]) == 0\n assert candidate(nums = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11, 33, 55, 77, 99, 22, 44]) == 3\n assert candidate(nums = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000, 0, -1000000, -2000000, -3000000, -4000000, -5000000]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [10000000, -9999999, 9999998, -9999997, 9999996, -9999995, 9999994, -9999993, 9999992, -9999991, 9999990, -9999989, 9999988, -9999987, 9999986, -9999985]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100000]) == 99999\n assert candidate(nums = [9999999, -9999999, 8888888, -8888888, 7777777, -7777777, 6666666, -6666666, 5555555, -5555555, 4444444, -4444444, 3333333, -3333333, 2222222, -2222222]) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 0\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8]) == 0\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 0\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [5, 3, 8, 1, 9, 2, 6, 4, 7, 0, 11, 13, 15, 17, 19, 21]) == 1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 0\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 13000000, 14000000, 15000000, 16000000]) == 0\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumDifference(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minimumDifference", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2037, "task_id": "minimum-number-of-moves-to-seat-everyone", "difficulty": "Easy", "problem_description": "There are n availabe seats and n students standing in a room. You are given an array seats of length n, where seats[i] is the position of the ith seat. You are also given the array students of length n, where students[j] is the position of the jth student.\nYou may perform the following move any number of times:\n\nIncrease or decrease the position of the ith student by 1 (i.e., moving the ith student from position x to x + 1 or x - 1)\n\nReturn the minimum number of moves required to move each student to a seat such that no two students are in the same seat.\nNote that there may be multiple seats or students in the same position at the beginning.\n \nExample 1:\n\nInput: seats = [3,1,5], students = [2,7,4]\nOutput: 4\nExplanation: The students are moved as follows:\n- The first student is moved from position 2 to position 1 using 1 move.\n- The second student is moved from position 7 to position 5 using 2 moves.\n- The third student is moved from position 4 to position 3 using 1 move.\nIn total, 1 + 2 + 1 = 4 moves were used.\n\nExample 2:\n\nInput: seats = [4,1,5,9], students = [1,3,2,6]\nOutput: 7\nExplanation: The students are moved as follows:\n- The first student is not moved.\n- The second student is moved from position 3 to position 4 using 1 move.\n- The third student is moved from position 2 to position 5 using 3 moves.\n- The fourth student is moved from position 6 to position 9 using 3 moves.\nIn total, 0 + 1 + 3 + 3 = 7 moves were used.\n\nExample 3:\n\nInput: seats = [2,2,6,6], students = [1,3,2,6]\nOutput: 4\nExplanation: Note that there are two seats at position 2 and two seats at position 6.\nThe students are moved as follows:\n- The first student is moved from position 1 to position 2 using 1 move.\n- The second student is moved from position 3 to position 6 using 3 moves.\n- The third student is not moved.\n- The fourth student is not moved.\nIn total, 1 + 3 + 0 + 0 = 4 moves were used.\n\n \nConstraints:\n\nn == seats.length == students.length\n1 <= n <= 100\n1 <= seats[i], students[j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(seats = [5, 5, 5, 5],students = [5, 5, 5, 5]) == 0\n assert candidate(seats = [10, 20, 30],students = [5, 15, 25]) == 15\n assert candidate(seats = [4, 1, 5, 9],students = [1, 3, 2, 6]) == 7\n assert candidate(seats = [1, 1, 1, 1],students = [1, 1, 1, 1]) == 0\n assert candidate(seats = [3, 1, 5],students = [2, 7, 4]) == 4\n assert candidate(seats = [1, 1, 1],students = [1, 1, 1]) == 0\n assert candidate(seats = [50, 50, 50],students = [49, 50, 51]) == 2\n assert candidate(seats = [10, 20, 30],students = [15, 25, 35]) == 15\n assert candidate(seats = [10, 20, 30],students = [1, 2, 3]) == 54\n assert candidate(seats = [100, 1, 50],students = [50, 100, 1]) == 0\n assert candidate(seats = [10, 20, 30, 40, 50],students = [5, 15, 25, 35, 45]) == 25\n assert candidate(seats = [100, 1, 50, 50],students = [50, 1, 100, 50]) == 0\n assert candidate(seats = [100, 1, 2, 3, 4],students = [1, 2, 3, 4, 100]) == 0\n assert candidate(seats = [100, 90, 80, 70],students = [70, 80, 90, 100]) == 0\n assert candidate(seats = [50, 50, 50],students = [50, 50, 50]) == 0\n assert candidate(seats = [10, 1, 100],students = [5, 10, 99]) == 5\n assert candidate(seats = [1, 2, 3, 4, 5],students = [5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [2, 2, 6, 6],students = [1, 3, 2, 6]) == 4\n assert candidate(seats = [1, 3, 5, 7, 9],students = [2, 4, 6, 8, 10]) == 5\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 495\n assert candidate(seats = [5, 5, 5, 5, 5, 5],students = [1, 2, 3, 4, 5, 6]) == 11\n assert candidate(seats = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 495\n assert candidate(seats = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],students = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]) == 95\n assert candidate(seats = [20, 30, 40, 50, 60, 70, 80],students = [15, 25, 35, 45, 55, 65, 75]) == 35\n assert candidate(seats = [50, 50, 50, 50, 50, 50],students = [45, 45, 45, 55, 55, 55]) == 30\n assert candidate(seats = [3, 3, 8, 8, 10, 10, 13, 13],students = [2, 3, 6, 8, 9, 10, 12, 15]) == 7\n assert candidate(seats = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],students = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 0\n assert candidate(seats = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],students = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28]) == 20\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],students = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],students = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == 0\n assert candidate(seats = [1, 100, 1, 100, 1, 100],students = [50, 50, 50, 50, 50, 50]) == 297\n assert candidate(seats = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],students = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 300\n assert candidate(seats = [90, 80, 70, 60, 50, 40, 30],students = [10, 20, 30, 40, 50, 60, 70]) == 140\n assert candidate(seats = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],students = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 495\n assert candidate(seats = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],students = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 250\n assert candidate(seats = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],students = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 30\n assert candidate(seats = [99, 100, 1, 2, 3, 4],students = [5, 6, 7, 8, 9, 1]) == 191\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],students = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [30, 10, 20, 40, 50, 60],students = [5, 15, 25, 35, 45, 55]) == 30\n assert candidate(seats = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 980\n assert candidate(seats = [1, 5, 9, 13, 17, 21, 25, 29],students = [2, 6, 10, 14, 18, 22, 26, 30]) == 8\n assert candidate(seats = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],students = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 9\n assert candidate(seats = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],students = [99, 97, 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(seats = [5, 5, 5, 5, 5],students = [1, 2, 3, 4, 5]) == 10\n assert candidate(seats = [2, 2, 2, 3, 3, 3, 5, 5, 5, 6, 6, 6],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 32\n assert candidate(seats = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41],students = [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 50\n assert candidate(seats = [8, 12, 20, 25, 30, 35],students = [5, 10, 15, 22, 31, 36]) == 15\n assert candidate(seats = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],students = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 90\n assert candidate(seats = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],students = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59]) == 450\n assert candidate(seats = [5, 3, 8, 9, 2, 10],students = [4, 6, 7, 1, 11, 15]) == 11\n assert candidate(seats = [5, 20, 35, 50, 65, 80, 95, 110, 125, 140],students = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145]) == 50\n assert candidate(seats = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],students = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29]) == 10\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],students = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 45\n assert candidate(seats = [50, 50, 50, 50, 50],students = [49, 50, 51, 52, 53]) == 7\n assert candidate(seats = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 130\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],students = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == 100\n assert candidate(seats = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],students = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]) == 40\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(seats = [2, 3, 5, 6, 8, 11, 13],students = [1, 4, 7, 9, 10, 12, 15]) == 12\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],students = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145],students = [5, 20, 35, 50, 65, 80, 95, 110, 125, 140]) == 50\n assert candidate(seats = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],students = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 540\n assert candidate(seats = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],students = [1, 7, 13, 19, 24, 29, 34, 38, 44, 49]) == 17\n assert candidate(seats = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],students = [6, 5, 5, 4, 4, 3, 3, 2, 2, 1]) == 0\n assert candidate(seats = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],students = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 0\n assert candidate(seats = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(seats = [1, 3, 6, 8, 10, 15],students = [2, 4, 5, 7, 9, 16]) == 6\n assert candidate(seats = [50, 40, 30, 20, 10, 100, 90, 80, 70, 60],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 495\n assert candidate(seats = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],students = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]) == 90\n assert candidate(seats = [3, 8, 15, 22, 29],students = [1, 6, 13, 21, 28]) == 8\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],students = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5, 105, 115, 125, 135, 145]) == 75\n assert candidate(seats = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],students = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == 20\n assert candidate(seats = [1, 2, 3, 4, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 42\n assert candidate(seats = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],students = [3, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57]) == 35\n assert candidate(seats = [1, 4, 6, 9, 12, 15],students = [3, 5, 7, 10, 13, 16]) == 7\n assert candidate(seats = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],students = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 210\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],students = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],students = [45, 46, 47, 48, 49, 51, 52, 53, 54, 55]) == 30\n assert candidate(seats = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 100\n assert candidate(seats = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 31\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],students = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(seats = [2, 3, 5, 7, 11, 13, 17, 19],students = [1, 4, 6, 8, 10, 12, 14, 16]) == 12\n assert candidate(seats = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],students = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 15\n assert candidate(seats = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],students = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(seats = [1, 3, 6, 8, 10, 15],students = [2, 4, 7, 9, 11, 16]) == 6\n assert candidate(seats = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99]) == 10\n assert candidate(seats = [95, 96, 97, 98, 99, 100],students = [1, 2, 3, 4, 5, 6]) == 564\n assert candidate(seats = [5, 15, 25, 35, 45, 55],students = [1, 7, 17, 27, 37, 47]) == 44\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 540\n assert candidate(seats = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 890\n assert candidate(seats = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],students = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 0\n assert candidate(seats = [5, 6, 8, 10, 15, 17, 20, 25, 30, 35],students = [4, 5, 7, 10, 12, 16, 18, 22, 28, 34]) == 15\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 50\n assert candidate(seats = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10],students = [1, 3, 3, 5, 5, 7, 7, 9, 9, 11]) == 10\n assert candidate(seats = [20, 20, 20, 20, 20],students = [19, 20, 21, 22, 23]) == 7\n assert candidate(seats = [95, 55, 10, 30, 70],students = [5, 90, 60, 40, 80]) == 35\n assert candidate(seats = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],students = [1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24]) == 800\n assert candidate(seats = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6],students = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == 3\n"}, "metadata": {"canonical_parameter_names": ["seats", "students"], "leetcode_dataset_entry_point": "Solution().minMovesToSeat", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minMovesToSeat(self, seats: list[int], students: list[int]) -> int:", "container": "Solution", "callable": "minMovesToSeat", "parameters": [{"name": "seats", "type": "list[int]"}, {"name": "students", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2038, "task_id": "remove-colored-pieces-if-both-neighbors-are-the-same-color", "difficulty": "Medium", "problem_description": "There are n pieces arranged in a line, and each piece is colored either by 'A' or by 'B'. You are given a string colors of length n where colors[i] is the color of the ith piece.\nAlice and Bob are playing a game where they take alternating turns removing pieces from the line. In this game, Alice moves first.\n\nAlice is only allowed to remove a piece colored 'A' if both its neighbors are also colored 'A'. She is not allowed to remove pieces that are colored 'B'.\nBob is only allowed to remove a piece colored 'B' if both its neighbors are also colored 'B'. He is not allowed to remove pieces that are colored 'A'.\nAlice and Bob cannot remove pieces from the edge of the line.\nIf a player cannot make a move on their turn, that player loses and the other player wins.\n\nAssuming Alice and Bob play optimally, return true if Alice wins, or return false if Bob wins.\n \nExample 1:\n\nInput: colors = \"AAABABB\"\nOutput: true\nExplanation:\nAAABABB -> AABABB\nAlice moves first.\nShe removes the second 'A' from the left since that is the only 'A' whose neighbors are both 'A'.\n\nNow it's Bob's turn.\nBob cannot make a move on his turn since there are no 'B's whose neighbors are both 'B'.\nThus, Alice wins, so return true.\n\nExample 2:\n\nInput: colors = \"AA\"\nOutput: false\nExplanation:\nAlice has her turn first.\nThere are only two 'A's and both are on the edge of the line, so she cannot move on her turn.\nThus, Bob wins, so return false.\n\nExample 3:\n\nInput: colors = \"ABBBBBBBAAA\"\nOutput: false\nExplanation:\nABBBBBBBAAA -> ABBBBBBBAA\nAlice moves first.\nHer only option is to remove the second to last 'A' from the right.\n\nABBBBBBBAA -> ABBBBBBAA\nNext is Bob's turn.\nHe has many options for which 'B' piece to remove. He can pick any.\n\nOn Alice's second turn, she has no more pieces that she can remove.\nThus, Bob wins, so return false.\n\n \nConstraints:\n\n1 <= colors.length <= 105\ncolors consists of only the letters 'A' and 'B'\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(colors = \"AABBAABB\") == False\n assert candidate(colors = \"AAAAAAAAA\") == True\n assert candidate(colors = \"AAABAAAAABBBB\") == True\n assert candidate(colors = \"ABABABABAB\") == False\n assert candidate(colors = \"AABBBBAAA\") == False\n assert candidate(colors = \"BBBBB\") == False\n assert candidate(colors = \"BBBAAAABB\") == True\n assert candidate(colors = \"AAAAAAAA\") == True\n assert candidate(colors = \"AAAAA\") == True\n assert candidate(colors = \"AAABBBAAABBBA\") == False\n assert candidate(colors = \"AAABABB\") == True\n assert candidate(colors = \"AABBBBAA\") == False\n assert candidate(colors = \"AAAABBBB\") == False\n assert candidate(colors = \"BBBBBBBBB\") == False\n assert candidate(colors = \"ABBBBBBBAAA\") == False\n assert candidate(colors = \"ABABABABABA\") == False\n assert candidate(colors = \"ABABABAB\") == False\n assert candidate(colors = \"AAAAABBAAA\") == True\n assert candidate(colors = \"AABAABBBBAAA\") == False\n assert candidate(colors = \"ABABAB\") == False\n assert candidate(colors = \"BBBAAABB\") == False\n assert candidate(colors = \"ABAAABAA\") == True\n assert candidate(colors = \"AA\") == False\n assert candidate(colors = \"BBBBAAAABBB\") == False\n assert candidate(colors = \"AAAABBBAA\") == True\n assert candidate(colors = \"AABBBAAABBB\") == False\n assert candidate(colors = \"ABABABABABABAB\") == False\n assert candidate(colors = \"AAABBBAAABBBAABBBAAABBBAABBB\") == False\n assert candidate(colors = \"AABBABBABBABBABBABBA\") == False\n assert candidate(colors = \"ABAABAABAABAABAABA\") == False\n assert candidate(colors = \"BBBBBBBBBBAAAABBB\") == False\n assert candidate(colors = \"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AAABAAAABBAAABBBBAAAABBB\") == True\n assert candidate(colors = \"AABAABAABAABAABAA\") == False\n assert candidate(colors = \"AABBBAAABBBAABBAAABBBAABB\") == False\n assert candidate(colors = \"BBBBBBBBBBABBBBBBBBB\") == False\n assert candidate(colors = \"ABABABABABABABABABABAB\") == False\n assert candidate(colors = \"ABABABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AABBBAAABBBAAABBB\") == False\n assert candidate(colors = \"AABBAABBBAABBBAABBBAABBA\") == False\n assert candidate(colors = \"ABABABABABABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"AAABAAAAAAAAABBBBBBB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBB\") == True\n assert candidate(colors = \"ABABABABABABABABA\") == False\n assert candidate(colors = \"BBBBBBBBBBAAAAAAAAAAB\") == False\n assert candidate(colors = \"BBBAAAABBBAAAABBBAAAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"BBABBABBABBABBABB\") == False\n assert candidate(colors = \"BAAAAAAAAAABBBBBBBBBB\") == False\n assert candidate(colors = \"AAABAAABBBAAABBBBAA\") == False\n assert candidate(colors = \"AABBBAAAABBBAAB\") == False\n assert candidate(colors = \"AABBAAAABBAAAABB\") == True\n assert candidate(colors = \"BBBAABBBAAABBBAABBB\") == False\n assert candidate(colors = \"AAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAAABBBBBBBBBBB\") == False\n assert candidate(colors = \"AAAABBBBBBAAAABBBBBB\") == False\n assert candidate(colors = \"AAAAAABAAAAAABAAAAAAB\") == True\n assert candidate(colors = \"BBBAAAAAAAAABBBBBB\") == True\n assert candidate(colors = \"BBABABABABABABABABAB\") == False\n assert candidate(colors = \"AAABBBAAABBBAAABBBAAABBBAAABBBAAABBB\") == False\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"AAAAAAAABBBBBBBBBB\") == False\n assert candidate(colors = \"ABBBAAAAABBAAAAAAA\") == True\n assert candidate(colors = \"BBBAAAABBAAAABBAAAABBAAAABBAAAABB\") == True\n assert candidate(colors = \"AAAABAAAABBAAAABBAAAABBAAAABBAAAAB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAABBBBBBBBBBBB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"AABBBAAAAABBBBAAA\") == True\n assert candidate(colors = \"AAAAAAAAAABBBBBBBBBB\") == False\n assert candidate(colors = \"AAABBBAAAABBBAAABBBAAABBBAA\") == True\n assert candidate(colors = \"AAABAAAABAAABAAAABAA\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"AAAAAAAAABBBBBBBBAABBBBBBBBA\") == False\n assert candidate(colors = \"BBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"ABABABAAAABBBABAABAB\") == True\n assert candidate(colors = \"ABBBAAAABBAAAABBBA\") == True\n assert candidate(colors = \"AAABBBAABBBAAABBBA\") == False\n assert candidate(colors = \"AAABBBAABBBAABBBAAB\") == False\n assert candidate(colors = \"AAABBBAAAABBBAAABBBAA\") == True\n assert candidate(colors = \"ABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"BBBAAAABBBAAAABAA\") == True\n assert candidate(colors = \"AAABBBAAAABBBAAAABBBAAA\") == True\n assert candidate(colors = \"BBBBBAABAAAAAAABBB\") == True\n assert candidate(colors = \"AAABBAAAABBAAAABBAAAABBBAAAABB\") == True\n assert candidate(colors = \"BBBBBAAAAAAAAABBBBB\") == True\n assert candidate(colors = \"AAAAAAAAABBBBBBBBBBBB\") == False\n assert candidate(colors = \"BABAABABABABABABAB\") == False\n assert candidate(colors = \"AAABBBBAABBBBAA\") == False\n assert candidate(colors = \"BBAAABBBAAABBBAAABB\") == True\n assert candidate(colors = \"AAABAAABAAABAAABA\") == True\n assert candidate(colors = \"AAABBBAAABBBAAABBBAAABBBAAABBB\") == False\n assert candidate(colors = \"BBBBBBBBBB\") == False\n assert candidate(colors = \"BBAAAABBBAAABBBAAABB\") == True\n assert candidate(colors = \"AAAAAAAAAABBBBBBBB\") == True\n assert candidate(colors = \"BBBBBAAAABBBBBBBAAAAA\") == False\n assert candidate(colors = \"BBBBBAAAABBBBBAAAABBBBBAAAABBBBB\") == False\n assert candidate(colors = \"AAAAABBBBBAAAAABBBBBAAAAA\") == True\n assert candidate(colors = \"ABBBAAAABBAAAABBBAABA\") == True\n assert candidate(colors = \"AAAABBBBAAAABBBBAAAABBBB\") == False\n assert candidate(colors = \"BBBBAAAABBBBBBBBAAA\") == False\n assert candidate(colors = \"ABABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBB\") == True\n assert candidate(colors = \"BBBBBBAAAABBBBBBBBAAA\") == False\n assert candidate(colors = \"AABAAAAAAABBBBBBBBA\") == False\n assert candidate(colors = \"BBBAABBBAAAABBBAAABBB\") == False\n assert candidate(colors = \"ABABABABAAAAAAAABBBBBBBB\") == False\n assert candidate(colors = \"BBAAAABBBAAAABBAAA\") == True\n assert candidate(colors = \"BBAABBAAAABBAAAABBBB\") == True\n assert candidate(colors = \"AAABBBAABBAAABBBAAAAAAABBBB\") == True\n assert candidate(colors = \"AAAAABBAAAABBAAAAB\") == True\n assert candidate(colors = \"ABBBAAAABBBBAAA\") == False\n assert candidate(colors = \"BBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"BBBBBBAAAAAAAAAA\") == True\n assert candidate(colors = \"BBAAAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"ABBBAAAABBBAAAABB\") == True\n assert candidate(colors = \"BBBBBAABBBBAABBBBAABBBBA\") == False\n assert candidate(colors = \"BBBBBBBBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"BBBBBBBAAAAAAAAAAAABB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"ABABABABABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"BBBBAAAABBBBBAAAABBBBBAAAABB\") == False\n assert candidate(colors = \"AABAAABAABAAABAAA\") == True\n assert candidate(colors = \"ABABABABABABABABAB\") == False\n assert candidate(colors = \"BBBAAAABBAAAABBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAABBBBBBBBBBBAAAAAAAAAAAAAAAAABBBBBBBBBBB\") == True\n assert candidate(colors = \"AABBBAAABBAAAABBAAAAB\") == True\n assert candidate(colors = \"AAABAAABAAABAAABAAABAAAB\") == True\n assert candidate(colors = \"ABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"AAAAAABBBBBBAAA\") == True\n assert candidate(colors = \"BBBAAAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"ABABABABABABABABABABA\") == False\n assert candidate(colors = \"AAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AAAABBAABBABBAABBBAAA\") == True\n assert candidate(colors = \"ABAAAABBBBAABBBBAA\") == False\n assert candidate(colors = \"AAABAAAABBBBAAAABBBBAAAABBBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAABBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"BABAABBAABBBBAAAABBBB\") == False\n assert candidate(colors = \"AABBAABBAABBAAA\") == True\n assert candidate(colors = \"AAAAAAAAABBBBBBBB\") == True\n assert candidate(colors = \"BBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"BBAABBAAAABBBBAAAAABBBAAABBBAAABBBB\") == True\n assert candidate(colors = \"AAAAAAAAABBAAAAAAAAA\") == True\n assert candidate(colors = \"AAAABBBAAAABBB\") == True\n assert candidate(colors = \"AABBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAABBBBBBBBBBAAA\") == False\n assert candidate(colors = \"AAAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAABBBBBBB\") == True\n assert candidate(colors = \"BBAAAABBAAAABBAAAABBAAAABBB\") == True\n assert candidate(colors = \"AABBBAAAABBBAAA\") == True\n assert candidate(colors = \"BBBBBBBBAAAABBBBBBB\") == False\n assert candidate(colors = \"BBBBBAAAABBBBBAAAABBBBBAAAABBBBBAAAABBBBBAAAABBBBB\") == False\n assert candidate(colors = \"BBABABABBABABABBABABABBB\") == False\n assert candidate(colors = \"BBAABBAAAABBAAAABBAAAABBB\") == True\n assert candidate(colors = \"BBBAAAABBAAAABBB\") == True\n assert candidate(colors = \"BBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AAAABBBBAAAA\") == True\n assert candidate(colors = \"BBBBAABBBAABBBAAB\") == False\n assert candidate(colors = \"AAAAAAAAAA\") == True\n assert candidate(colors = \"BBBBBBAAAABBBBBBAAAABBBBBB\") == False\n assert candidate(colors = \"BAAABAAABAAABBB\") == True\n assert candidate(colors = \"AAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAABBBBAAAABBBBAAAAA\") == True\n assert candidate(colors = \"BBBAAAAAAAABBBBBB\") == True\n assert candidate(colors = \"AAABBBAABBBAAABBBAABBB\") == False\n assert candidate(colors = \"BABABABABABABABAB\") == False\n assert candidate(colors = \"AABAAAAABBAAABAAAAABB\") == True\n assert candidate(colors = \"BBBBBAAAABBBBBAAAABBBBBAAAABBBBBAAAABBBBB\") == False\n assert candidate(colors = \"BBBAAABBBAAABBBAAA\") == False\n assert candidate(colors = \"AAABAAAAAAAABBBBBBB\") == True\n assert candidate(colors = \"BBBBBBBBAAAAAAAAAA\") == True\n assert candidate(colors = \"ABABABABABABABABABAB\") == False\n assert candidate(colors = \"ABBBBAAAAAABBBBBAAA\") == False\n assert candidate(colors = \"AAABAAABBBABBAAA\") == True\n assert candidate(colors = \"AABBBAAAAAAAAABBBBB\") == True\n assert candidate(colors = \"BBAAAABBBAAAABBBAAAABBBAAA\") == True\n assert candidate(colors = \"BBBBBBBAAAAAAAAAA\") == True\n assert candidate(colors = \"AABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAAABBBBBBBBAAAAAAAAAABBBBBBBB\") == True\n assert candidate(colors = \"AABAAABAAABAAABAAABAAABAAABAAABAAAB\") == True\n assert candidate(colors = \"BBBBBAAAABBBBBAAAAABBBBBAAABBBAAAB\") == False\n"}, "metadata": {"canonical_parameter_names": ["colors"], "leetcode_dataset_entry_point": "Solution().winnerOfGame", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def winnerOfGame(self, colors: str) -> bool:", "container": "Solution", "callable": "winnerOfGame", "parameters": [{"name": "colors", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2039, "task_id": "the-time-when-the-network-becomes-idle", "difficulty": "Medium", "problem_description": "There is a network of n servers, labeled from 0 to n - 1. You are given a 2D integer array edges, where edges[i] = [ui, vi] indicates there is a message channel between servers ui and vi, and they can pass any number of messages to each other directly in one second. You are also given a 0-indexed integer array patience of length n.\nAll servers are connected, i.e., a message can be passed from one server to any other server(s) directly or indirectly through the message channels.\nThe server labeled 0 is the master server. The rest are data servers. Each data server needs to send its message to the master server for processing and wait for a reply. Messages move between servers optimally, so every message takes the least amount of time to arrive at the master server. The master server will process all newly arrived messages instantly and send a reply to the originating server via the reversed path the message had gone through.\nAt the beginning of second 0, each data server sends its message to be processed. Starting from second 1, at the beginning of every second, each data server will check if it has received a reply to the message it sent (including any newly arrived replies) from the master server:\n\nIf it has not, it will resend the message periodically. The data server i will resend the message every patience[i] second(s), i.e., the data server i will resend the message if patience[i] second(s) have elapsed since the last time the message was sent from this server.\nOtherwise, no more resending will occur from this server.\n\nThe network becomes idle when there are no messages passing between servers or arriving at servers.\nReturn the earliest second starting from which the network becomes idle.\n \nExample 1:\n\n\nInput: edges = [[0,1],[1,2]], patience = [0,2,1]\nOutput: 8\nExplanation:\nAt (the beginning of) second 0,\n- Data server 1 sends its message (denoted 1A) to the master server.\n- Data server 2 sends its message (denoted 2A) to the master server.\n\nAt second 1,\n- Message 1A arrives at the master server. Master server processes message 1A instantly and sends a reply 1A back.\n- Server 1 has not received any reply. 1 second (1 < patience[1] = 2) elapsed since this server has sent the message, therefore it does not resend the message.\n- Server 2 has not received any reply. 1 second (1 == patience[2] = 1) elapsed since this server has sent the message, therefore it resends the message (denoted 2B).\n\nAt second 2,\n- The reply 1A arrives at server 1. No more resending will occur from server 1.\n- Message 2A arrives at the master server. Master server processes message 2A instantly and sends a reply 2A back.\n- Server 2 resends the message (denoted 2C).\n...\nAt second 4,\n- The reply 2A arrives at server 2. No more resending will occur from server 2.\n...\nAt second 7, reply 2D arrives at server 2.\n\nStarting from the beginning of the second 8, there are no messages passing between servers or arriving at servers.\nThis is the time when the network becomes idle.\n\nExample 2:\n\n\nInput: edges = [[0,1],[0,2],[1,2]], patience = [0,10,10]\nOutput: 3\nExplanation: Data servers 1 and 2 receive a reply back at the beginning of second 2.\nFrom the beginning of the second 3, the network becomes idle.\n\n \nConstraints:\n\nn == patience.length\n2 <= n <= 105\npatience[0] == 0\n1 <= patience[i] <= 105 for 1 <= i < n\n1 <= edges.length <= min(105, n * (n - 1) / 2)\nedges[i].length == 2\n0 <= ui, vi < n\nui != vi\nThere are no duplicate edges.\nEach server can directly or indirectly reach another server.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [[0, 1], [1, 2]],patience = [0, 2, 1]) == 8\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]],patience = [0, 5, 5, 5]) == 3\n assert candidate(edges = [[0, 1], [1, 3], [3, 4], [2, 4]],patience = [0, 1, 2, 3, 4]) == 15\n assert candidate(edges = [[0, 1], [1, 2], [2, 0]],patience = [0, 2, 1]) == 4\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4]],patience = [0, 1, 2, 3, 4]) == 13\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],patience = [0, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],patience = [0, 5, 4, 3, 2, 1, 6, 7, 8, 9]) == 28\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4]],patience = [0, 5, 2, 3, 1]) == 16\n assert candidate(edges = [[0, 1], [0, 2], [1, 2]],patience = [0, 10, 10]) == 3\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],patience = [0, 1, 2, 3, 4, 5, 6]) == 8\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],patience = [0, 1, 1, 5, 2, 3, 6]) == 8\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],patience = [0, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]],patience = [0, 4, 3, 2, 1, 5]) == 4\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 0], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [12, 14]],patience = [0, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15]) == 13\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(edges = [[0, 1], [1, 2], [2, 0], [0, 3], [3, 4], [4, 5], [5, 0], [0, 6], [6, 7], [7, 8], [8, 9], [9, 0]],patience = [0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 5\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10]],patience = [0, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 9\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 5, 7, 3, 2, 1, 6, 4, 8, 9, 11]) == 11\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 23\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]],patience = [0, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 9\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 58\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 7\n assert candidate(edges = [[0, 1], [1, 2], [0, 3], [3, 4], [2, 4], [4, 5], [5, 6]],patience = [0, 2, 1, 3, 4, 5, 6]) == 15\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0]],patience = [0, 100, 90, 80, 70, 60, 50, 40, 30]) == 9\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],patience = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26]],patience = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 16\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0], [0, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 0]],patience = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 11\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],patience = [0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == 12\n assert candidate(edges = [[0, 1], [0, 3], [1, 2], [1, 4], [2, 5], [2, 7], [3, 6], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 20]],patience = [0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == 9\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],patience = [0, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 5\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 7\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]],patience = [0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12]) == 27\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 7\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 20], [19, 21], [20, 22], [11, 23], [12, 24], [13, 25], [14, 26], [15, 27], [16, 28], [17, 29], [29, 30], [28, 31], [27, 32], [26, 33], [25, 34], [24, 35], [23, 36]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]) == 13\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [7, 22], [8, 23], [8, 24], [8, 25]],patience = [0, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == 7\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],patience = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900]) == 29\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20]],patience = [0, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 12\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]],patience = [0, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 3\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],patience = [0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11]) == 12\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12]],patience = [0, 7, 7, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2]) == 7\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 9\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 15, 10, 20, 5, 12, 8, 6, 4, 7, 3]) == 11\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 0]],patience = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58]) == 31\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 6], [1, 7], [2, 8], [2, 9], [3, 10], [3, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [8, 21], [9, 22], [9, 23], [10, 24], [10, 25], [11, 26], [11, 27], [12, 28], [12, 29], [13, 30], [13, 31], [14, 32], [14, 33], [15, 34], [15, 35]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 7\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 5, 5, 3, 3, 1, 1, 4, 4, 2, 2]) == 11\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]],patience = [0, 3, 2, 1, 6, 5, 4, 7, 8, 9, 12, 11, 10, 15, 14, 13, 18, 17, 16, 19, 20, 21, 24, 23, 22, 27, 26, 25, 28, 29, 30, 31, 32, 33, 34, 35]) == 9\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39]],patience = [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 119\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 5], [5, 6], [6, 0], [0, 7], [7, 8], [8, 9], [9, 0]],patience = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],patience = [0, 2, 5, 3, 4, 7, 8, 6, 1, 9, 10]) == 12\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]],patience = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 116\n"}, "metadata": {"canonical_parameter_names": ["edges", "patience"], "leetcode_dataset_entry_point": "Solution().networkBecomesIdle", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def networkBecomesIdle(self, edges: list[list[int]], patience: list[int]) -> int:", "container": "Solution", "callable": "networkBecomesIdle", "parameters": [{"name": "edges", "type": "list[list[int]]"}, {"name": "patience", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2040, "task_id": "kth-smallest-product-of-two-sorted-arrays", "difficulty": "Hard", "problem_description": "Given two sorted 0-indexed integer arrays nums1 and nums2 as well as an integer k, return the kth (1-based) smallest product of nums1[i] * nums2[j] where 0 <= i < nums1.length and 0 <= j < nums2.length.\n \nExample 1:\n\nInput: nums1 = [2,5], nums2 = [3,4], k = 2\nOutput: 8\nExplanation: The 2 smallest products are:\n- nums1[0] * nums2[0] = 2 * 3 = 6\n- nums1[0] * nums2[1] = 2 * 4 = 8\nThe 2nd smallest product is 8.\n\nExample 2:\n\nInput: nums1 = [-4,-2,0,3], nums2 = [2,4], k = 6\nOutput: 0\nExplanation: The 6 smallest products are:\n- nums1[0] * nums2[1] = (-4) * 4 = -16\n- nums1[0] * nums2[0] = (-4) * 2 = -8\n- nums1[1] * nums2[1] = (-2) * 4 = -8\n- nums1[1] * nums2[0] = (-2) * 2 = -4\n- nums1[2] * nums2[0] = 0 * 2 = 0\n- nums1[2] * nums2[1] = 0 * 4 = 0\nThe 6th smallest product is 0.\n\nExample 3:\n\nInput: nums1 = [-2,-1,0,1,2], nums2 = [-3,-1,2,4,5], k = 3\nOutput: -6\nExplanation: The 3 smallest products are:\n- nums1[0] * nums2[4] = (-2) * 5 = -10\n- nums1[0] * nums2[3] = (-2) * 4 = -8\n- nums1[4] * nums2[0] = 2 * (-3) = -6\nThe 3rd smallest product is -6.\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 5 * 104\n-105 <= nums1[i], nums2[j] <= 105\n1 <= k <= nums1.length * nums2.length\nnums1 and nums2 are sorted.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [-100000, 100000],nums2 = [-100000, 100000],k = 1) == -10000000000\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1],k = 4) == 0\n assert candidate(nums1 = [-100000, -50000, 0, 50000, 100000],nums2 = [-100000, -50000, 0, 50000, 100000],k = 12) == 0\n assert candidate(nums1 = [-10, -9, -8, -7, -6],nums2 = [-5, -4, -3, -2, -1],k = 1) == 6\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],k = 25) == 90\n assert candidate(nums1 = [2, 5],nums2 = [3, 4],k = 2) == 8\n assert candidate(nums1 = [-4, -2, 0, 3],nums2 = [2, 4],k = 6) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5],k = 10) == 5\n assert candidate(nums1 = [-100000, 100000],nums2 = [-100000, 100000],k = 2) == -10000000000\n assert candidate(nums1 = [-5, -3, -1, 1, 3, 5],nums2 = [-5, -3, -1, 1, 3, 5],k = 18) == -1\n assert candidate(nums1 = [-2, -1, 0, 1, 2],nums2 = [-3, -1, 2, 4, 5],k = 3) == -6\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5],k = 25) == 25\n assert candidate(nums1 = [-10, -5, -1],nums2 = [1, 5, 10],k = 5) == -10\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6],k = 5) == 10\n assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0],k = 5) == 0\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0],k = 12) == 0\n assert candidate(nums1 = [-100, -50, -10, -5, 0, 5, 10, 50, 100],nums2 = [-100, -50, -10, -5, 0, 5, 10, 50, 100],k = 200) == 10001\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [-5, -4, -3, -2, -1],k = 12) == 6\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-10000, 0, 10000],k = 7) == 0\n assert candidate(nums1 = [-25, -15, -5, 5, 15, 25],nums2 = [-25, -15, -5, 0, 5, 15, 25],k = 30) == 75\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],k = 25) == 1\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-10000, -5000, 0, 5000, 10000],k = 7) == -125000000\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-10000, -5000, 0, 5000, 10000],k = 125000) == 500000001\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [-1, -1, -1, -1, -1],k = 25) == -1\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 50) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],k = 20) == 50\n assert candidate(nums1 = [-9, -3, 0, 1, 5],nums2 = [-6, -2, 1, 4, 7],k = 9) == -3\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-50000, -25000, 0, 25000, 50000],k = 124999) == 2500000001\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-100, -50, 0, 50, 100],k = 10) == 0\n assert candidate(nums1 = [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5],nums2 = [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5],k = 49) == -2\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],k = 24) == 72\n assert candidate(nums1 = [-100, -50, 0, 50, 100],nums2 = [-200, -100, 0, 100, 200],k = 10) == 0\n assert candidate(nums1 = [-10, -5, -1, 0, 1, 5, 10],nums2 = [-20, -15, -10, -5, 0, 5, 10, 15, 20],k = 20) == -15\n assert candidate(nums1 = [-1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000],nums2 = [-1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000],k = 1000) == 1000001\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-50000, -25000, 0, 25000, 50000],k = 1250000) == 2500000001\n assert candidate(nums1 = [-50, -25, 0, 25, 50],nums2 = [-50, -25, 0, 25, 50],k = 12) == 0\n assert candidate(nums1 = [100000],nums2 = [-100000, 0, 100000],k = 2) == 0\n assert candidate(nums1 = [-100000, 100000],nums2 = [-1, 1],k = 1) == -100000\n assert candidate(nums1 = [-1000, -900, -800],nums2 = [800, 900, 1000],k = 8) == -720000\n assert candidate(nums1 = [-100000, -50000, -10000, -5000, -1000, -500, -100, -50, -10, -5, 0, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000],nums2 = [-100000, -50000, -10000, -5000, -1000, -500, -100, -50, -10, -5, 0, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000],k = 1000000) == 10000000001\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [-9, -7, -5, -3, -1],k = 15) == -15\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 15) == 0\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 13) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 45) == 20\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 2, 3, 4, 5],k = 20) == 1500\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000],nums2 = [-10000, -20000, -30000, -40000, -50000],k = 12) == -900000000\n assert candidate(nums1 = [-2, -1, 0, 1, 2],nums2 = [-2, -1, 0, 1, 2, 3, 4, 5],k = 15) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [2, 4, 6, 8, 10, 12],k = 36) == 132\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-5, -10, -15, -20, -25],k = 10) == -600\n assert candidate(nums1 = [-1000, -500, -100, 0, 100, 500, 1000],nums2 = [-1000, -500, -100, 0, 100, 500, 1000],k = 48) == 1000000\n assert candidate(nums1 = [-2, 0, 2],nums2 = [-2, 0, 2],k = 3) == 0\n assert candidate(nums1 = [-1, -1, 0, 1, 1],nums2 = [-1, -1, 0, 1, 1],k = 12) == 0\n assert candidate(nums1 = [-100, -50, 0, 50, 100],nums2 = [-200, -100, 0, 100, 200],k = 50) == 20001\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 100) == 380\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1],k = 3) == 0\n assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000],nums2 = [-1, -2, -3, -4, -5],k = 15) == -90000\n assert candidate(nums1 = [-100, -50, 0, 50, 100],nums2 = [-100, -50, 0, 50, 100],k = 1000) == 10001\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-50000, -25000, 0, 25000, 50000],k = 125000000) == 2500000001\n assert candidate(nums1 = [-10000, -5000, -1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000, 5000, 10000],nums2 = [-10000, -5000, -1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000, 5000, 10000],k = 361) == 100000000\n assert candidate(nums1 = [-1, 1],nums2 = [-100000, 100000],k = 1) == -100000\n assert candidate(nums1 = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 324) == 40\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-100000, -10000, -1000, -100, -10, -1, 0, 1, 10, 100, 1000, 10000, 100000],k = 100) == 100001\n assert candidate(nums1 = [-1, -1, -1, -1, -1],nums2 = [-1, -1, -1, -1, -1],k = 1) == 1\n assert candidate(nums1 = [-3, -2, -1, 0, 1, 2, 3],nums2 = [-3, -2, -1, 0, 1, 2, 3],k = 21) == 0\n assert candidate(nums1 = [-1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000],nums2 = [-1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000],k = 22500) == 1000001\n assert candidate(nums1 = [-1, -1, -1, -1, -1],nums2 = [-1, -1, -1, -1, -1],k = 20) == 1\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-100000, -10000, -1000, -100, -10, -1, 0, 1, 10, 100, 1000, 10000, 100000],k = 13) == 0\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-50000, -25000, 0, 25000, 50000],k = 500000) == 2500000001\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1],k = 5) == 0\n assert candidate(nums1 = [-5, -3, -1, 1, 3, 5],nums2 = [-5, -3, -1, 1, 3, 5],k = 15) == -3\n assert candidate(nums1 = [-50000, -40000, -30000, -20000, -10000, 0, 10000, 20000, 30000, 40000, 50000],nums2 = [-50000, -40000, -30000, -20000, -10000, 0, 10000, 20000, 30000, 40000, 50000],k = 1000000) == 2500000001\n assert candidate(nums1 = [-9, -7, -5, -3, -1],nums2 = [-9, -7, -5, -3, -1],k = 24) == 63\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-50000, -25000, 0, 25000, 50000],k = 24999) == 2500000001\n assert candidate(nums1 = [-1, -1, -1, -1],nums2 = [-1, -1, -1, -1],k = 10) == 1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 240\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1],k = 4) == 0\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums1 = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 100) == -15\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-2, -1, 0, 1, 2],k = 8) == -5\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 10) == 0\n assert candidate(nums1 = [-1, -1, -1, -1],nums2 = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 5) == 1\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],k = 12) == 20\n assert candidate(nums1 = [-1000, -900, -800, -700, -600],nums2 = [-1000, -900, -800, -700, -600],k = 20) == 800000\n assert candidate(nums1 = [-100, -50, 0, 50, 100],nums2 = [-100, -50, 0, 50, 100],k = 12) == 0\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 12) == 0\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-100000, -50000, -10000, -5000, -1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000],k = 50) == 5\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 25) == 100\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-100, 0, 100],k = 4) == 0\n assert candidate(nums1 = [-5, -3, -1, 0, 1, 3, 5],nums2 = [-6, -4, -2, 0, 2, 4, 6],k = 15) == -4\n assert candidate(nums1 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 441) == 100\n assert candidate(nums1 = [-1000, -500, 0, 500, 1000],nums2 = [-1000, -500, 0, 500, 1000],k = 1250) == 1000001\n assert candidate(nums1 = [-5, -3, -1, 1, 3, 5],nums2 = [-6, -4, -2, 0, 2, 4, 6],k = 15) == -4\n assert candidate(nums1 = [-9, -7, -5, -3, -1],nums2 = [1, 3, 5, 7, 9],k = 10) == -27\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [-5, -4, -3, -2, -1],k = 25) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 24\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 45) == -36\n assert candidate(nums1 = [-3, -2, -1, 0, 1, 2, 3],nums2 = [-3, -2, -1, 0, 1, 2, 3],k = 20) == 0\n assert candidate(nums1 = [-1, -1, -1, -1, 1, 1, 1, 1],nums2 = [-1, -1, -1, -1, 1, 1, 1, 1],k = 32) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [-9, -7, -5, -3, -1],k = 25) == -1\n assert candidate(nums1 = [-50000, -40000, -30000, 0, 30000, 40000, 50000],nums2 = [-50000, 0, 50000],k = 20) == 2500000000\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [-5, -4, -3, -2, -1],k = 15) == -6\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 20) == 50\n assert candidate(nums1 = [-1, 1, -1, 1, -1],nums2 = [-1, 1, -1, 1, -1],k = 10) == -1\n assert candidate(nums1 = [-9, -6, -3, 0, 3, 6, 9],nums2 = [-9, -6, -3, 0, 3, 6, 9],k = 49) == 81\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-20, -15, -10, -5, 0, 5, 10, 15, 20],k = 30) == 25\n assert candidate(nums1 = [-100, -50, -25, -10, -5, -1, 0, 1, 5, 10, 25, 50, 100],nums2 = [-100, -50, -25, -10, -5, -1, 0, 1, 5, 10, 25, 50, 100],k = 100) == 5\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5],k = 25) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2", "k"], "leetcode_dataset_entry_point": "Solution().kthSmallestProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def kthSmallestProduct(self, nums1: list[int], nums2: list[int], k: int) -> int:", "container": "Solution", "callable": "kthSmallestProduct", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2042, "task_id": "check-if-numbers-are-ascending-in-a-sentence", "difficulty": "Easy", "problem_description": "A sentence is a list of tokens separated by a single space with no leading or trailing spaces. Every token is either a positive number consisting of digits 0-9 with no leading zeros, or a word consisting of lowercase English letters.\n\nFor example, \"a puppy has 2 eyes 4 legs\" is a sentence with seven tokens: \"2\" and \"4\" are numbers and the other tokens such as \"puppy\" are words.\n\nGiven a string s representing a sentence, you need to check if all the numbers in s are strictly increasing from left to right (i.e., other than the last number, each number is strictly smaller than the number on its right in s).\nReturn true if so, or false otherwise.\n \nExample 1:\n\n\nInput: s = \"1 box has 3 blue 4 red 6 green and 12 yellow marbles\"\nOutput: true\nExplanation: The numbers in s are: 1, 3, 4, 6, 12.\nThey are strictly increasing from left to right: 1 < 3 < 4 < 6 < 12.\n\nExample 2:\n\nInput: s = \"hello world 5 x 5\"\nOutput: false\nExplanation: The numbers in s are: 5, 5. They are not strictly increasing.\n\nExample 3:\n\n\nInput: s = \"sunset is at 7 51 pm overnight lows will be in the low 50 and 60 s\"\nOutput: false\nExplanation: The numbers in s are: 7, 51, 50, 60. They are not strictly increasing.\n\n \nConstraints:\n\n3 <= s.length <= 200\ns consists of lowercase English letters, spaces, and digits from 0 to 9, inclusive.\nThe number of tokens in s is between 2 and 100, inclusive.\nThe tokens in s are separated by a single space.\nThere are at least two numbers in s.\nEach number in s is a positive number less than 100, with no leading zeros.\ns contains no leading or trailing spaces.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"start 99 end 100\") == True\n assert candidate(s = \"1 apple 2 banana 3 cherry 4 date\") == True\n assert candidate(s = \"100 99 98 97 96\") == False\n assert candidate(s = \"5 15 25 35 45 55\") == True\n assert candidate(s = \"there are 10 cars 20 bikes and 30 trucks\") == True\n assert candidate(s = \"the times 10 20 30 40 50 are correct\") == True\n assert candidate(s = \"5 6 7 8 9 10 11\") == True\n assert candidate(s = \"the quick brown fox jumps over 1 lazy 2 dogs\") == True\n assert candidate(s = \"10 20 30 40 50\") == True\n assert candidate(s = \"start 1 end 2\") == True\n assert candidate(s = \"5 6 7 8 7\") == False\n assert candidate(s = \"but 100 99 98 are not\") == False\n assert candidate(s = \"100 99 98 97 96 95 94 93 92 91 90\") == False\n assert candidate(s = \"9 10 11 12 13\") == True\n assert candidate(s = \"i have 1 cat 2 dogs and 3 fish\") == True\n assert candidate(s = \"the temperature rose from 23 to 28 degrees\") == True\n assert candidate(s = \"hello world 5 x 5\") == False\n assert candidate(s = \"start 1 end 1\") == False\n assert candidate(s = \"the temperature is 23 degrees and will rise to 28 by afternoon\") == True\n assert candidate(s = \"he has 3 cats and 7 dogs\") == True\n assert candidate(s = \"the temperature is 23 degrees and rising to 28\") == True\n assert candidate(s = \"1 2 3 4 5 6 7 8 9\") == True\n assert candidate(s = \"2 apple 3 4 banana 5 6\") == True\n assert candidate(s = \"i have 1 apple 2 oranges and 3 bananas\") == True\n assert candidate(s = \"i saw 1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"i have 1 cat 2 dogs and 3 hamsters\") == True\n assert candidate(s = \"sunset is at 7 51 pm overnight lows will be in the low 50 and 60 s\") == False\n assert candidate(s = \"9 10 11\") == True\n assert candidate(s = \"1 2 3 apple 4 5\") == True\n assert candidate(s = \"9 8 7 6 5 4 3 2 1\") == False\n assert candidate(s = \"0 is not a valid number 1 is\") == False\n assert candidate(s = \"3 14 15 9 26 53 59\") == False\n assert candidate(s = \"3 5 7 9 11 13 15\") == True\n assert candidate(s = \"the temperature is 23 degrees and will rise to 30\") == True\n assert candidate(s = \"5 6 7 8 9 10\") == True\n assert candidate(s = \"100 99\") == False\n assert candidate(s = \"100 101 102\") == True\n assert candidate(s = \"10 20 30 25 40\") == False\n assert candidate(s = \"1 box has 3 blue 4 red 6 green and 12 yellow marbles\") == True\n assert candidate(s = \"one two 3 four 5 six 7\") == True\n assert candidate(s = \"she sold 12 eggs for 24 dollars\") == True\n assert candidate(s = \"we started with 50 employees and now we have 75\") == True\n assert candidate(s = \"the quick brown fox jumps over 13 lazy dogs and 14 sleeping cats\") == True\n assert candidate(s = \"there are 100 ants 110 bees and 120 wasps\") == True\n assert candidate(s = \"the measurements are 10 20 30 40 50 60 70\") == True\n assert candidate(s = \"1 car 2 trucks 3 motorcycles 4 bicycles\") == True\n assert candidate(s = \"she ate 2 apples and then 3 apples later\") == True\n assert candidate(s = \"123 124 125 126 127 128 129\") == True\n assert candidate(s = \"she turned 21 years old in 2022 and will turn 22 in 2023\") == False\n assert candidate(s = \"the heights are 30 45 60 75 90\") == True\n assert candidate(s = \"the sequence of numbers is 1 2 4 8 16 32 and 64\") == True\n assert candidate(s = \"he scored 50 60 75 80 and 90 in exams\") == True\n assert candidate(s = \"repeating numbers 1 1 2 2 3 3\") == False\n assert candidate(s = \"the journey took 3 hours and 4 hours on different days\") == True\n assert candidate(s = \"in the year 2001 we had 1 event in 2003 we had 4 events in 2005 we had 6 events\") == False\n assert candidate(s = \"lets count 1 2 3 4 5 6 7 8 9 10 and check if they are increasing\") == True\n assert candidate(s = \"the sequence is 1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"the temperature decreased from 30 degrees to 25 degrees then to 20 degrees\") == False\n assert candidate(s = \"3 little pigs 10 11 12 13 14 15\") == True\n assert candidate(s = \"1 one 2 two 3 three 4 four 5 five 6 six 7 seven\") == True\n assert candidate(s = \"in the year 1990 1995 there were 2000 2005 cars\") == True\n assert candidate(s = \"the sequence 1 3 5 7 9 is strictly increasing\") == True\n assert candidate(s = \"12 monkeys and 13 apes and 14 elephants\") == True\n assert candidate(s = \"the areas are 1 4 9 16 25 36 and 49\") == True\n assert candidate(s = \"a1 b2 c3 6 7 8 9 10\") == True\n assert candidate(s = \"1000 apples 2000 bananas 3000 cherries 4000 dates\") == True\n assert candidate(s = \"the book had 5 chapters and the next book had 8 chapters\") == True\n assert candidate(s = \"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25\") == True\n assert candidate(s = \"a1 b2 c3 4 d5 e6 f7 g8 h9 i10\") == True\n assert candidate(s = \"we have 100 books 200 magazines and 300 newspapers\") == True\n assert candidate(s = \"42 is the answer to life 43 the universe and 44 everything\") == True\n assert candidate(s = \"he received 10 calls in the morning and 15 in the afternoon\") == True\n assert candidate(s = \"the temperature rose from 20 degrees to 22 and then to 25\") == True\n assert candidate(s = \"one 2 three 4 five 6 seven 8 nine 10\") == True\n assert candidate(s = \"12 monkeys and 13 gorillas but only 7 chimpanzees\") == False\n assert candidate(s = \"the temperature was 10 degrees at 1 oclock and 12 degrees at 2 oclock and 15 degrees at 3 oclock\") == False\n assert candidate(s = \"the temperature rose from 20 to 22 then to 25\") == True\n assert candidate(s = \"the times are 12 24 36 48 and 60\") == True\n assert candidate(s = \"the weights are 1 2 3 5 8 13 and 21\") == True\n assert candidate(s = \"she baked 5 cakes 10 muffins and 15 brownies\") == True\n assert candidate(s = \"the steps are 100 200 300 400 500\") == True\n assert candidate(s = \"there are 100 ants 200 bees 300 flies and 400 spiders\") == True\n assert candidate(s = \"the number 10 comes before 20 and 30\") == True\n assert candidate(s = \"the sales increased from 100 units to 150 units last quarter\") == True\n assert candidate(s = \"the numbers 1 2 3 4 5 6 7 8 9 10 are in ascending order\") == True\n assert candidate(s = \"the increments are 1 2 3 4 5 6 7 8\") == True\n assert candidate(s = \"alpha 1 beta 2 gamma 3 delta 4 epsilon 5 zeta 6 eta 7 theta 8 iota 9 kappa 10 lambda 11 mu 12 nu 13 xi 14 omicron 15 pi 16 rho 17 sigma 18 tau 19 upsilon 20 phi 21 chi 22 psi 23 omega 24\") == True\n assert candidate(s = \"the sequence of numbers is 1 3 6 10 15 21 and 28\") == True\n assert candidate(s = \"in the year 1800 there were 1801 people in this town 1802\") == True\n assert candidate(s = \"20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39\") == True\n assert candidate(s = \"she baked 5 cakes 10 pies and 15 tarts\") == True\n assert candidate(s = \"the positions are 10 20 30 40 50 60 and 70\") == True\n assert candidate(s = \"58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77\") == True\n assert candidate(s = \"the volumes are 10 100 1000 10000 and 100000\") == True\n assert candidate(s = \"the temperature rose from 10 to 20 then to 30 degrees\") == True\n assert candidate(s = \"in the year 2000 we had 100 participants and in 2005 we had 150 participants\") == False\n assert candidate(s = \"the project took 1 month and then 2 months to complete\") == True\n assert candidate(s = \"the sequence 1 3 5 7 9 11 13 15 17 19 is strictly increasing\") == True\n assert candidate(s = \"the numbers are 1 2 3 but then 2 again\") == False\n assert candidate(s = \"a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20\") == True\n assert candidate(s = \"increasing by one 1 2 3 4 5 6 7 8 9\") == True\n assert candidate(s = \"the temperature today is 30 degrees 31 tomorrow 32 the day after\") == True\n assert candidate(s = \"the sequence is 1 3 5 7 9 11 13\") == True\n assert candidate(s = \"the garden has 1 tulip 3 roses 5 daisies 7 sunflowers\") == True\n assert candidate(s = \"we planted 50 trees 100 bushes and 200 flowers\") == True\n assert candidate(s = \"in 1999 there were 2000 cars and in 2001 there were 2002 cars\") == True\n assert candidate(s = \"we collected 15 apples 20 oranges and 25 bananas\") == True\n assert candidate(s = \"one 1 two 2 three 3 four 4 five 5 six 6 seven 7 eight 8 nine 9 ten 10 eleven 11\") == True\n assert candidate(s = \"3 cats 5 dogs 7 birds 9 fish\") == True\n assert candidate(s = \"99 98 97 96 95 94 93 92 91 90\") == False\n assert candidate(s = \"she sold 1 apple 2 oranges 3 bananas 4 grapes 5 watermelons 6 pineapples\") == True\n assert candidate(s = \"the speed increased from 20 kmph to 30 kmph and then to 40 kmph\") == True\n assert candidate(s = \"the distances are 1000 2000 3000 4000 and 5000\") == True\n assert candidate(s = \"we climbed 100 meters then 200 meters and finally 300 meters\") == True\n assert candidate(s = \"the time is 12 13 14 15 16 17 18 19 20 21 22 23\") == True\n assert candidate(s = \"there were 5 kids 6 teenagers 7 adults in the room\") == True\n assert candidate(s = \"the company grew from 1000 employees to 1500 employees last year\") == True\n assert candidate(s = \"he won 1 race and then 2 races in a row\") == True\n assert candidate(s = \"the first year 1990 was followed by 1991 and then 1992\") == True\n assert candidate(s = \"1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10\") == False\n assert candidate(s = \"the sequence 10 20 30 40 50 60 70 80 90 100 is ascending\") == True\n assert candidate(s = \"in the year 2020 2021 2022 and 2023\") == True\n assert candidate(s = \"the ages are 5 10 15 20 25 30\") == True\n assert candidate(s = \"the numbers 10 20 30 40 50 are increasing\") == True\n assert candidate(s = \"in the sequence 2 4 6 8 10 12 14 16 18 20 all numbers are in increasing order\") == True\n assert candidate(s = \"there are 2 cars 4 trucks and 6 motorcycles\") == True\n assert candidate(s = \"random 5 10 20 15 25 30 29 35 40 45\") == False\n assert candidate(s = \"20 apples and 25 oranges but only 15 bananas\") == False\n assert candidate(s = \"a quick brown fox jumps over 1 lazy dog then 2 sleepy dogs\") == True\n assert candidate(s = \"the ages are 25 30 35 40 45 50 55\") == True\n assert candidate(s = \"she sold sea shells by the sea shore 1 2 3 4 5 6 7 8 9 10 11 12\") == True\n assert candidate(s = \"39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58\") == True\n assert candidate(s = \"there are 100 bottles of beer on the wall 101 102 103\") == True\n assert candidate(s = \"in the year 2020 we had 21 cars 23 trucks and 25 buses\") == False\n assert candidate(s = \"compare these numbers 10 20 30 40 50 60 70 80 90 100\") == True\n assert candidate(s = \"decreasing numbers 5 4 3 2 1\") == False\n assert candidate(s = \"there are 30 apples 40 oranges 50 bananas 60 grapes 70 strawberries 80 blueberries\") == True\n assert candidate(s = \"the temperature rose from 20 to 25 to 30 degrees\") == True\n assert candidate(s = \"random order 1 3 2 4 5\") == False\n assert candidate(s = \"a1 b2 c3 d4 e5 f6 g7 h8 i9 j10 11 12 13 14 15 16 17 18 19 20\") == True\n assert candidate(s = \"the chapters are numbered 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\") == True\n assert candidate(s = \"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20\") == True\n assert candidate(s = \"the ages are 5 10 15 20 25 30 35 40\") == True\n assert candidate(s = \"the quick brown fox jumps over 1 lazy dog 2\") == True\n assert candidate(s = \"she played 1 game 2 matches 3 tournaments\") == True\n assert candidate(s = \"we counted 1 bird 2 cats 3 dogs 4 elephants 5 foxes 6 giraffes 7 hippos\") == True\n assert candidate(s = \"she saw 5 stars 10 planets and 15 galaxies\") == True\n assert candidate(s = \"23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43\") == True\n assert candidate(s = \"even numbers 2 4 6 8 10 12 14 16 18 20\") == True\n assert candidate(s = \"strictly increasing 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\") == True\n assert candidate(s = \"in a race 10 runners came first 20 second and 30 third\") == True\n assert candidate(s = \"the clock struck 1 pm 2 pm 3 pm 4 pm\") == True\n assert candidate(s = \"the sequence of numbers is 3 9 27 81 and 243\") == True\n assert candidate(s = \"mixed numbers 1 20 2 30 3\") == False\n assert candidate(s = \"in the year 2000 2001 2002 the world changed\") == True\n assert candidate(s = \"a sequence of 1 2 3 4 5 6 7 8 9 10 numbers\") == True\n assert candidate(s = \"a sequence of numbers like 10 20 30 40 50 should be increasing\") == True\n assert candidate(s = \"the values are 2 4 8 16 32\") == True\n assert candidate(s = \"42 cats 43 dogs 44 elephants 45 flamingos\") == True\n assert candidate(s = \"77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96\") == True\n assert candidate(s = \"abc 1 def 2 ghi 3 jkl 4 mno 5 pqr 6 stu 7 vwx 8 yz 9 10\") == True\n assert candidate(s = \"nested numbers like 10 in 11 the 12 and 13 final\") == True\n assert candidate(s = \"99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115\") == True\n assert candidate(s = \"99 100 101 102 103 104 105 106\") == True\n assert candidate(s = \"96 97 98 99 100 101 102 103 104 105 106 107 108 109 110\") == True\n assert candidate(s = \"the children are 1 year old 2 years old 3 years old 4 years old\") == True\n assert candidate(s = \"100 apples 101 oranges 102 bananas\") == True\n assert candidate(s = \"my password is 123 and my pin is 124 and my secret number is 125\") == True\n assert candidate(s = \"the team scored 2 goals in the first half and 3 goals in the second half\") == True\n assert candidate(s = \"the prices are 5 10 15 20 25\") == True\n assert candidate(s = \"decreasing numbers 20 19 18 17 16 15 14 13 12 11 10\") == False\n assert candidate(s = \"the sequence is 1 4 9 16 25 and 36\") == True\n assert candidate(s = \"there are 3 cats 5 dogs and 7 birds in the zoo\") == True\n assert candidate(s = \"the quick brown fox jumps over the lazy dog 1 2 3 4 5\") == True\n assert candidate(s = \"he collected 2 seashells by the sea 4 on the beach and 6 in the sand\") == True\n assert candidate(s = \"1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"a quick brown fox jumps over the lazy dog 1 2 3 4 5\") == True\n assert candidate(s = \"there are 100 apples 101 oranges and 102 bananas\") == True\n assert candidate(s = \"the levels are 10 20 30 40 50 60 70 80 90\") == True\n assert candidate(s = \"007 is not a valid number but 7 8 9 are valid numbers\") == False\n assert candidate(s = \"two digit numbers 10 20 30 40 50\") == True\n assert candidate(s = \"the quick brown fox jumps over the lazy dog 1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"99 100 99 101 102 103 104 105 106 107 108 109 110 111 112 113 114\") == False\n assert candidate(s = \"a series of 1 3 5 7 9 11 13 15 17 19 odd numbers\") == True\n assert candidate(s = \"we have 10 apples 20 oranges 30 bananas and 30 grapes\") == False\n assert candidate(s = \"the number sequence is 1 2 3 4 5 6 7 8 9\") == True\n assert candidate(s = \"he ran 1 mile in 5 minutes then 2 miles in 10 minutes\") == False\n assert candidate(s = \"99 bottles of beer on the wall 98 bottles of beer\") == False\n assert candidate(s = \"the heights are 100 200 300 400 and 500\") == True\n assert candidate(s = \"the numbers 5 10 15 20 25 30 35 40 45 50 are increasing\") == True\n assert candidate(s = \"30 apples 40 oranges 50 bananas 60 grapes\") == True\n assert candidate(s = \"a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10\") == True\n assert candidate(s = \"21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40\") == True\n assert candidate(s = \"the counts are 1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"the first 2 books have 3 chapters each and the 5 next books have 6 chapters each\") == True\n assert candidate(s = \"1234 5678 91011 121314\") == True\n assert candidate(s = \"the temperature rose from 5 degrees to 10 degrees then to 15 degrees\") == True\n assert candidate(s = \"single digit numbers 1 2 3 4 5\") == True\n assert candidate(s = \"a quick brown fox jumps over 1 3 5 lazy dogs\") == True\n assert candidate(s = \"she has 10 red balloons 20 blue ones and 30 green ones\") == True\n assert candidate(s = \"a 1 digit number 10 two digit numbers 100 three digit numbers\") == True\n assert candidate(s = \"in the series 2 4 6 8 10 the numbers are strictly increasing\") == True\n assert candidate(s = \"we planted 1 tree 2 bushes 3 flowers 4 vines and 5 cacti\") == True\n assert candidate(s = \"the sequence is 1 1 2 3 5 8 and 13\") == False\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().areNumbersAscending", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def areNumbersAscending(self, s: str) -> bool:", "container": "Solution", "callable": "areNumbersAscending", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2044, "task_id": "count-number-of-maximum-bitwise-or-subsets", "difficulty": "Medium", "problem_description": "Given an integer array nums, find the maximum possible bitwise OR of a subset of nums and return the number of different non-empty subsets with the maximum bitwise OR.\nAn array a is a subset of an array b if a can be obtained from b by deleting some (possibly zero) elements of b. Two subsets are considered different if the indices of the elements chosen are different.\nThe bitwise OR of an array a is equal to a[0] OR a[1] OR ... OR a[a.length - 1] (0-indexed).\n \nExample 1:\n\nInput: nums = [3,1]\nOutput: 2\nExplanation: The maximum possible bitwise OR of a subset is 3. There are 2 subsets with a bitwise OR of 3:\n- [3]\n- [3,1]\n\nExample 2:\n\nInput: nums = [2,2,2]\nOutput: 7\nExplanation: All non-empty subsets of [2,2,2] have a bitwise OR of 2. There are 23 - 1 = 7 total subsets.\n\nExample 3:\n\nInput: nums = [3,2,1,5]\nOutput: 6\nExplanation: The maximum possible bitwise OR of a subset is 7. There are 6 subsets with a bitwise OR of 7:\n- [3,5]\n- [3,1,5]\n- [3,2,5]\n- [3,2,1,5]\n- [2,5]\n- [2,1,5]\n \nConstraints:\n\n1 <= nums.length <= 16\n1 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [15, 15, 15]) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 255\n assert candidate(nums = [3, 2, 1, 5]) == 6\n assert candidate(nums = [6, 2, 1, 3, 4]) == 17\n assert candidate(nums = [6, 2, 1, 5, 4]) == 17\n assert candidate(nums = [5, 1, 1, 2, 5]) == 12\n assert candidate(nums = [1, 3, 5, 7, 9]) == 10\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [2, 2, 2]) == 7\n assert candidate(nums = [1, 3, 7, 15, 31]) == 16\n assert candidate(nums = [15, 15, 15, 15]) == 15\n assert candidate(nums = [1, 2, 4, 8]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50]) == 16\n assert candidate(nums = [5, 5, 5, 5, 5]) == 31\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 65535\n assert candidate(nums = [15, 7, 3, 1]) == 8\n assert candidate(nums = [16, 8, 4, 2, 1]) == 1\n assert candidate(nums = [3, 1]) == 2\n assert candidate(nums = [1, 3, 7, 15]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 255\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 65535\n assert candidate(nums = [10, 20, 30, 40]) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 1]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 64594\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35]) == 52\n assert candidate(nums = [5, 10, 15, 20, 25, 30]) == 44\n assert candidate(nums = [1, 2, 4, 8, 16, 32]) == 1\n assert candidate(nums = [8, 4, 2, 1, 15, 7, 3]) == 85\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 65535\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3]) == 32768\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 64594\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 859\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 128, 64, 32, 16, 8, 4, 2, 1]) == 6561\n assert candidate(nums = [16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384]) == 65535\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 32767\n assert candidate(nums = [32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 1\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 16203\n assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32]) == 1\n assert candidate(nums = [31, 15, 7, 3, 1, 31, 15, 7, 3, 1, 31, 15, 7, 3, 1, 31]) == 61440\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 32297\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0]) == 64812\n assert candidate(nums = [13, 7, 15, 3, 1, 8, 2, 4]) == 205\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 32297\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 64897\n assert candidate(nums = [1, 5, 11, 5, 1, 11, 5, 1, 11, 5, 1, 11, 5, 1]) == 14880\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1023]) == 32768\n assert candidate(nums = [15, 7, 3, 1]) == 8\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 255\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 511\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64]) == 1\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 65535\n assert candidate(nums = [15, 15, 15, 15, 15]) == 31\n assert candidate(nums = [31, 15, 7, 3, 1]) == 16\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 1\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1]) == 128\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 64594\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 32768\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 512\n assert candidate(nums = [31, 28, 29, 30, 31, 30, 29, 28]) == 228\n assert candidate(nums = [17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17]) == 65535\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 171\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1]) == 109\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 65535\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384]) == 21\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]) == 22336\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 255\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64]) == 109\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 257\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 65535\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40]) == 150\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128]) == 1\n assert candidate(nums = [31, 14, 7, 3, 1, 31, 14, 7, 3, 1]) == 768\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31]) == 32768\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255]) == 255\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 62449\n assert candidate(nums = [14, 7, 3, 1, 14, 7, 3, 1]) == 189\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 65535\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562]) == 13\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8]) == 255\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1, 1, 1, 1, 1, 1]) == 32768\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 128, 64, 32, 16, 8, 4, 2, 1]) == 6561\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144]) == 48108\n assert candidate(nums = [32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == 32768\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == 6561\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == 170\n assert candidate(nums = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]) == 65535\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 512\n assert candidate(nums = [32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 16384\n assert candidate(nums = [5, 3, 10, 14, 15, 1, 2, 8, 4, 6, 7, 11, 12, 13, 9]) == 32297\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 48609\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 59421\n assert candidate(nums = [127, 63, 31, 15, 7, 3, 1]) == 64\n assert candidate(nums = [5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40]) == 59922\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 1, 10, 100, 1000, 10000, 100000]) == 2592\n assert candidate(nums = [31, 15, 7, 3, 1, 63, 127, 255, 511, 1023, 1, 2, 4, 8, 16, 32]) == 32768\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128]) == 1\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1]) == 128\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32767]) == 32769\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72]) == 109\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]) == 32768\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240]) == 63775\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1]) == 1\n assert candidate(nums = [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14]) == 65535\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 65535\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 32297\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3]) == 12611\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127]) == 64\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64]) == 1\n assert candidate(nums = [7, 3, 2, 1, 6, 5, 4, 8, 10, 9, 11, 12, 13, 14, 15, 16]) == 32297\n assert candidate(nums = [12, 14, 7, 1, 9, 3, 11]) == 102\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countMaxOrSubsets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countMaxOrSubsets(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countMaxOrSubsets", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2045, "task_id": "second-minimum-time-to-reach-destination", "difficulty": "Hard", "problem_description": "A city is represented as a bi-directional connected graph with n vertices where each vertex is labeled from 1 to n (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself. The time taken to traverse any edge is time minutes.\nEach vertex has a traffic signal which changes its color from green to red and vice versa every change minutes. All signals change at the same time. You can enter a vertex at any time, but can leave a vertex only when the signal is green. You cannot wait at a vertex if the signal is green.\nThe second minimum value is defined as the smallest value strictly larger than the minimum value.\n\nFor example the second minimum value of [2, 3, 4] is 3, and the second minimum value of [2, 2, 4] is 4.\n\nGiven n, edges, time, and change, return the second minimum time it will take to go from vertex 1 to vertex n.\nNotes:\n\nYou can go through any vertex any number of times, including 1 and n.\nYou can assume that when the journey starts, all signals have just turned green.\n\n \nExample 1:\n        \n\nInput: n = 5, edges = [[1,2],[1,3],[1,4],[3,4],[4,5]], time = 3, change = 5\nOutput: 13\nExplanation:\nThe figure on the left shows the given graph.\nThe blue path in the figure on the right is the minimum time path.\nThe time taken is:\n- Start at 1, time elapsed=0\n- 1 -> 4: 3 minutes, time elapsed=3\n- 4 -> 5: 3 minutes, time elapsed=6\nHence the minimum time needed is 6 minutes.\n\nThe red path shows the path to get the second minimum time.\n- Start at 1, time elapsed=0\n- 1 -> 3: 3 minutes, time elapsed=3\n- 3 -> 4: 3 minutes, time elapsed=6\n- Wait at 4 for 4 minutes, time elapsed=10\n- 4 -> 5: 3 minutes, time elapsed=13\nHence the second minimum time is 13 minutes. \n\nExample 2:\n\n\nInput: n = 2, edges = [[1,2]], time = 3, change = 2\nOutput: 11\nExplanation:\nThe minimum time path is 1 -> 2 with time = 3 minutes.\nThe second minimum time path is 1 -> 2 -> 1 -> 2 with time = 11 minutes.\n \nConstraints:\n\n2 <= n <= 104\nn - 1 <= edges.length <= min(2 * 104, n * (n - 1) / 2)\nedges[i].length == 2\n1 <= ui, vi <= n\nui != vi\nThere are no duplicate edges.\nEach vertex can be reached directly or indirectly from every other vertex.\n1 <= time, change <= 103\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 2,edges = [[1, 2]],time = 3,change = 2) == 11\n assert candidate(n = 3,edges = [[1, 2], [2, 3]],time = 2,change = 3) == 10\n assert candidate(n = 3,edges = [[1, 2], [2, 3]],time = 5,change = 5) == 35\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 5], [4, 5], [5, 6]],time = 2,change = 4) == 18\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 4], [1, 4]],time = 2,change = 3) == 8\n assert candidate(n = 4,edges = [[1, 2], [1, 3], [3, 4], [2, 4]],time = 2,change = 3) == 10\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6]],time = 4,change = 7) == 32\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [3, 4], [4, 5]],time = 3,change = 5) == 13\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 4]],time = 5,change = 7) == 33\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 5], [5, 6]],time = 4,change = 7) == 22\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 4], [4, 1]],time = 2,change = 3) == 8\n assert candidate(n = 14,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],time = 1,change = 2) == 29\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 9], [10, 11], [12, 13], [14, 15]],time = 8,change = 11) == 38\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 12], [11, 12], [1, 12]],time = 5,change = 7) == 19\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]],time = 2,change = 3) == 8\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 7], [6, 8], [7, 9], [8, 10]],time = 3,change = 5) == 13\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],time = 5,change = 4) == 29\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 8], [9, 10], [11, 12]],time = 3,change = 4) == 14\n assert candidate(n = 50,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35], [18, 36], [18, 37], [19, 38], [19, 39], [20, 40], [20, 41], [21, 42], [21, 43], [22, 44], [22, 45], [23, 46], [23, 47], [24, 48], [24, 49], [25, 50]],time = 3,change = 5) == 33\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 24], [13, 25]],time = 5,change = 7) == 38\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 6], [3, 7], [4, 6], [4, 7], [5, 6], [5, 7]],time = 5,change = 8) == 26\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = 8,change = 12) == 184\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]],time = 4,change = 6) == 28\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 12], [11, 12]],time = 3,change = 5) == 26\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 10], [9, 11], [12, 14], [13, 15]],time = 5,change = 8) == 26\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11]],time = 9,change = 12) == 57\n assert candidate(n = 11,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [1, 5], [1, 6], [1, 7], [2, 8], [2, 9], [3, 10], [3, 11]],time = 6,change = 8) == 28\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9]],time = 7,change = 10) == 47\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 3,change = 5) == 53\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20]],time = 6,change = 9) == 42\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 13], [13, 14], [14, 15]],time = 5,change = 8) == 37\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 7]],time = 4,change = 5) == 24\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7]],time = 3,change = 4) == 22\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],time = 3,change = 5) == 43\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = 4,change = 7) == 92\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]],time = 7,change = 9) == 43\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 11], [11, 12], [5, 7], [4, 6]],time = 3,change = 7) == 20\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 10]],time = 7,change = 10) == 47\n assert candidate(n = 14,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [1, 5], [1, 7], [2, 8], [2, 10], [3, 9], [3, 11], [4, 12], [4, 14], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]],time = 6,change = 13) == 18\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = 3,change = 4) == 14\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 6], [7, 8], [9, 10]],time = 4,change = 5) == 14\n assert candidate(n = 16,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 7], [4, 6], [4, 7], [5, 8], [5, 9], [6, 8], [6, 10], [7, 9], [7, 10], [8, 11], [8, 12], [9, 11], [9, 12], [10, 13], [10, 14], [11, 13], [11, 15], [12, 14], [12, 15], [13, 16], [14, 16], [15, 16]],time = 5,change = 10) == 50\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8]],time = 4,change = 6) == 28\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = 4,change = 6) == 124\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 7], [4, 6], [4, 7], [5, 8], [5, 9], [6, 8], [6, 10], [7, 9], [7, 10], [8, 11], [8, 12], [9, 11], [10, 12]],time = 8,change = 12) == 64\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 2,change = 3) == 32\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20]],time = 5,change = 8) == 42\n assert candidate(n = 18,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18]],time = 5,change = 6) == 101\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 8], [9, 10]],time = 2,change = 4) == 12\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],time = 4,change = 7) == 22\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11], [2, 3], [5, 7], [6, 8], [9, 10]],time = 3,change = 5) == 16\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 5], [4, 6], [5, 7], [5, 8], [6, 9], [7, 9], [8, 9]],time = 5,change = 7) == 24\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = 3,change = 5) == 93\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],time = 4,change = 6) == 28\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],time = 7,change = 10) == 54\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 7], [4, 6], [4, 7], [5, 8], [6, 8], [7, 8]],time = 6,change = 5) == 46\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [7, 12]],time = 2,change = 3) == 14\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [4, 6], [5, 6]],time = 10,change = 12) == 34\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 10], [5, 15], [9, 19]],time = 4,change = 6) == 32\n assert candidate(n = 16,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [8, 9], [10, 11], [12, 13], [14, 15], [16, 15]],time = 3,change = 5) == 16\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [1, 12]],time = 2,change = 3) == 8\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 6,change = 8) == 86\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],time = 6,change = 9) == 42\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = 3,change = 6) == 123\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 10], [9, 11], [12, 14], [13, 15]],time = 2,change = 5) == 12\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 8], [9, 10], [11, 12]],time = 3,change = 5) == 16\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = 4,change = 3) == 94\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 6], [7, 8], [8, 9], [5, 8], [6, 7], [5, 7], [6, 8]],time = 4,change = 6) == 16\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],time = 3,change = 4) == 22\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = 7,change = 9) == 97\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],time = 6,change = 8) == 28\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 12], [9, 13], [10, 14], [11, 15]],time = 2,change = 3) == 10\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 9]],time = 6,change = 5) == 36\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = 3,change = 5) == 63\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 7], [6, 7]],time = 5,change = 4) == 29\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 9], [10, 11], [12, 13], [14, 15]],time = 5,change = 6) == 22\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [24, 25]],time = 3,change = 6) == 18\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 7,change = 13) == 137\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [1, 4], [1, 5], [2, 6], [3, 4], [3, 6]],time = 7,change = 10) == 27\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],time = 3,change = 4) == 19\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 9], [10, 11], [12, 13], [14, 15]],time = 3,change = 7) == 17\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],time = 3,change = 5) == 26\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 5], [4, 6], [5, 7], [6, 7]],time = 7,change = 5) == 47\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]],time = 6,change = 5) == 56\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "time", "change"], "leetcode_dataset_entry_point": "Solution().secondMinimum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def secondMinimum(self, n: int, edges: list[list[int]], time: int, change: int) -> int:", "container": "Solution", "callable": "secondMinimum", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "time", "type": "int"}, {"name": "change", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2047, "task_id": "number-of-valid-words-in-a-sentence", "difficulty": "Easy", "problem_description": "A sentence consists of lowercase letters ('a' to 'z'), digits ('0' to '9'), hyphens ('-'), punctuation marks ('!', '.', and ','), and spaces (' ') only. Each sentence can be broken down into one or more tokens separated by one or more spaces ' '.\nA token is a valid word if all three of the following are true:\n\nIt only contains lowercase letters, hyphens, and/or punctuation (no digits).\nThere is at most one hyphen '-'. If present, it must be surrounded by lowercase characters (\"a-b\" is valid, but \"-ab\" and \"ab-\" are not valid).\nThere is at most one punctuation mark. If present, it must be at the end of the token (\"ab,\", \"cd!\", and \".\" are valid, but \"a!b\" and \"c.,\" are not valid).\n\nExamples of valid words include \"a-b.\", \"afad\", \"ba-c\", \"a!\", and \"!\".\nGiven a string sentence, return the number of valid words in sentence.\n \nExample 1:\n\nInput: sentence = \"cat and dog\"\nOutput: 3\nExplanation: The valid words in the sentence are \"cat\", \"and\", and \"dog\".\n\nExample 2:\n\nInput: sentence = \"!this 1-s b8d!\"\nOutput: 0\nExplanation: There are no valid words in the sentence.\n\"!this\" is invalid because it starts with a punctuation mark.\n\"1-s\" and \"b8d\" are invalid because they contain digits.\n\nExample 3:\n\nInput: sentence = \"alice and bob are playing stone-game10\"\nOutput: 5\nExplanation: The valid words in the sentence are \"alice\", \"and\", \"bob\", \"are\", and \"playing\".\n\"stone-game10\" is invalid because it contains digits.\n\n \nConstraints:\n\n1 <= sentence.length <= 1000\nsentence only contains lowercase English letters, digits, ' ', '-', '!', '.', and ','.\nThere will be at least 1 token.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence = \"no-digits123 or symbols#allowed\") == 2\n assert candidate(sentence = \"a.b.c\") == 0\n assert candidate(sentence = \"hello-world, this-is-a-test\") == 1\n assert candidate(sentence = \"hello-\") == 0\n assert candidate(sentence = \"a-\") == 0\n assert candidate(sentence = \"singleletter a b c d e f g\") == 8\n assert candidate(sentence = \"valid-words only\") == 2\n assert candidate(sentence = \"a\") == 1\n assert candidate(sentence = \"hello world! this is a test.\") == 6\n assert candidate(sentence = \"hello-world, my.name-is Qwen\") == 2\n assert candidate(sentence = \"ending-with-punctuation!\") == 0\n assert candidate(sentence = \"invalid--double-dash\") == 0\n assert candidate(sentence = \"multiple spaces between words\") == 4\n assert candidate(sentence = \"123\") == 0\n assert candidate(sentence = \"multiple--hyphens\") == 0\n assert candidate(sentence = \"valid-hyphenated-word\") == 0\n assert candidate(sentence = \"-invalid invalid- invalid-!\") == 0\n assert candidate(sentence = \"well-well, well!\") == 2\n assert candidate(sentence = \"singleletter\") == 1\n assert candidate(sentence = \"a! b. c?\") == 3\n assert candidate(sentence = \"hello-world\") == 1\n assert candidate(sentence = \"a-b-c\") == 0\n assert candidate(sentence = \"-world\") == 0\n assert candidate(sentence = \"a-b-c d-e f-g\") == 2\n assert candidate(sentence = \"-b\") == 0\n assert candidate(sentence = \"no-digits-allowed 123 456-789\") == 0\n assert candidate(sentence = \"alice and bob are playing stone-game10\") == 5\n assert candidate(sentence = \"no-dash-here\") == 0\n assert candidate(sentence = \"a-b!\") == 1\n assert candidate(sentence = \"valid-word here!\") == 2\n assert candidate(sentence = \"a-b- c d\") == 2\n assert candidate(sentence = \"valid-word here and another-valid one!\") == 5\n assert candidate(sentence = \"a-b-c-d.e.f!\") == 0\n assert candidate(sentence = \"singleletter a b c\") == 4\n assert candidate(sentence = \"a-b. afad ba-c a! .\") == 5\n assert candidate(sentence = \"a.b-c\") == 0\n assert candidate(sentence = \"hello!world\") == 0\n assert candidate(sentence = \",\") == 1\n assert candidate(sentence = \"a!b\") == 0\n assert candidate(sentence = \"-ab cd- ef-\") == 0\n assert candidate(sentence = \"hello-world, my name is john-doe.\") == 5\n assert candidate(sentence = \"!this 1-s b8d!\") == 0\n assert candidate(sentence = \"trailingpunctuation. comma, exclamation!\") == 3\n assert candidate(sentence = \"punctuation,in,middle,a-b.c\") == 0\n assert candidate(sentence = \"invalid-end-\") == 0\n assert candidate(sentence = \"-invalid start\") == 1\n assert candidate(sentence = \"valid-word here! and here.\") == 4\n assert candidate(sentence = \"!\") == 1\n assert candidate(sentence = \"valid-word-here!\") == 0\n assert candidate(sentence = \"punctuation,at,end.\") == 0\n assert candidate(sentence = \"a-b.c\") == 0\n assert candidate(sentence = \"cat and dog\") == 3\n assert candidate(sentence = \".\") == 1\n assert candidate(sentence = \"-invalid-start\") == 0\n assert candidate(sentence = \"a.b\") == 0\n assert candidate(sentence = \"hello-world!\") == 1\n assert candidate(sentence = \"punctuation! marks, are: allowed?\") == 4\n assert candidate(sentence = \"punctuation.only,\") == 0\n assert candidate(sentence = \"valid-word- valid-word-\") == 0\n assert candidate(sentence = \"word-with-digit1\") == 0\n assert candidate(sentence = \"punctuation-after-hyphen-! invalid\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation-1,\") == 0\n assert candidate(sentence = \"valid-word, valid-word!\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word?\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word@123\") == 1\n assert candidate(sentence = \"valid-word-with-hyphen-and-punctuation!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!\") == 1\n assert candidate(sentence = \"valid-word, invalid-word2\") == 1\n assert candidate(sentence = \"word-with-hyphen-and-punctuation-after-hyphen-,\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen-1b\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-1b-\") == 0\n assert candidate(sentence = \"valid-word-123\") == 0\n assert candidate(sentence = \"word-with-punctuation,at,end.\") == 0\n assert candidate(sentence = \"multiple---hyphens-in-a-row\") == 0\n assert candidate(sentence = \"word-with-hyphen-\") == 0\n assert candidate(sentence = \"word-with-digit-in-middle-1word\") == 0\n assert candidate(sentence = \"punctuation-inside-word!word\") == 0\n assert candidate(sentence = \"a-b-c d-e-f g-h\") == 1\n assert candidate(sentence = \"word-with-punctuation-and-digit1!\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation-after-hyphen-!\") == 0\n assert candidate(sentence = \"-word-with-leading-hyphen\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-b--1\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc\") == 1\n assert candidate(sentence = \"word-with-punctuation! word-without\") == 1\n assert candidate(sentence = \"word. word- word!\") == 2\n assert candidate(sentence = \"hyphenated-word- is valid\") == 2\n assert candidate(sentence = \"no-spaces\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen-1-word\") == 0\n assert candidate(sentence = \"word! word- word. word?\") == 3\n assert candidate(sentence = \"hyphen-at-end-\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word!\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@!\") == 1\n assert candidate(sentence = \"multiple---hyphens\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-exclamation!\") == 0\n assert candidate(sentence = \"valid-word- valid-word!\") == 1\n assert candidate(sentence = \"word word, word! word.\") == 4\n assert candidate(sentence = \"word-with-digit-and-hyphen-b--\") == 0\n assert candidate(sentence = \"valid-word- word-with-hyphen\") == 0\n assert candidate(sentence = \"word-with-digit1-and-punctuation!\") == 0\n assert candidate(sentence = \"punctuation-in-middle-of-word!word\") == 0\n assert candidate(sentence = \"word!word\") == 0\n assert candidate(sentence = \"singleletter singleletter! singleletter.\") == 3\n assert candidate(sentence = \"word-with-digit-at-end1!\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-1--b\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#\") == 1\n assert candidate(sentence = \"word-with-punctuation-and-hyphen-word-123\") == 0\n assert candidate(sentence = \"multiple--dashes are invalid\") == 2\n assert candidate(sentence = \"word-with-punctuation.at.end,invalid\") == 0\n assert candidate(sentence = \"word-with-digit1-and-punctuation.\") == 0\n assert candidate(sentence = \"valid-word-with-punctuation-at-end,\") == 0\n assert candidate(sentence = \"single-hyphenated-word a-b\") == 1\n assert candidate(sentence = \"123 word- word! word?\") == 2\n assert candidate(sentence = \"a.b!\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation, word-with-hyphen-and-punctuation.\") == 0\n assert candidate(sentence = \"valid-word- valid-word- valid-word\") == 1\n assert candidate(sentence = \"punctuation-only! and !only-punctuation\") == 2\n assert candidate(sentence = \"hello-world- is not valid\") == 3\n assert candidate(sentence = \"word-with-valid-hyphen word-with--invalid-hyphen\") == 0\n assert candidate(sentence = \"valid-word valid-word- valid-word\") == 2\n assert candidate(sentence = \"word-with-digit-and-hyphen-and-punctuation-1-word!\") == 0\n assert candidate(sentence = \"invalid-1word and valid-word\") == 2\n assert candidate(sentence = \"word-with-punctuation,at,end!\") == 0\n assert candidate(sentence = \"word- word\") == 1\n assert candidate(sentence = \"word-with-punctuations!word-with-punctuations!word-with-punctuations.\") == 0\n assert candidate(sentence = \"valid-ending-punctuation.\") == 0\n assert candidate(sentence = \"word-with-punctuation,word\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!\") == 1\n assert candidate(sentence = \"word..\") == 0\n assert candidate(sentence = \"word-with-multiple-hyphens-and-punctuation-,\") == 0\n assert candidate(sentence = \"multiple-spaces between words\") == 3\n assert candidate(sentence = \"word-with-hyphen-123\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word-\") == 1\n assert candidate(sentence = \"word-with-punctuations!word-with-punctuations!word-with-punctuations!word-with-punctuations!word-with-punctuations.\") == 0\n assert candidate(sentence = \"valid!word\") == 0\n assert candidate(sentence = \"word- word- valid\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-123\") == 1\n assert candidate(sentence = \"a--b\") == 0\n assert candidate(sentence = \"word-hyphenated-word word- word. word?\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen-b1\") == 0\n assert candidate(sentence = \"word- word! word@\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc-def,word\") == 1\n assert candidate(sentence = \"word-with-hyphen- valid-word\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation1-,\") == 0\n assert candidate(sentence = \"validwordwithmultiplepunctuations,,,\") == 0\n assert candidate(sentence = \"valid-word-with-hyphen-and-comma, valid.\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#\") == 1\n assert candidate(sentence = \"word,word,word\") == 0\n assert candidate(sentence = \"valid-word-with-punctuation-at-end!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123!\") == 1\n assert candidate(sentence = \"word,with,commas and.punctuations\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word@!\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123?\") == 1\n assert candidate(sentence = \"valid-word, valid-word. valid-word! valid-word\") == 4\n assert candidate(sentence = \"word-with-hyphen-and-punctuation,\") == 0\n assert candidate(sentence = \"word-with-space-in-word\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation word-with-hyphen-and-punctuation-\") == 0\n assert candidate(sentence = \"multiple---hyphens-in-word\") == 0\n assert candidate(sentence = \"word,word\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word?\") == 2\n assert candidate(sentence = \"123 456 789\") == 0\n assert candidate(sentence = \"punctuation!in!the!middle\") == 0\n assert candidate(sentence = \"multiple-punctuation,,\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-digit-1\") == 0\n assert candidate(sentence = \"word-with-digit123\") == 0\n assert candidate(sentence = \"word-with-digit123 and another-word!\") == 2\n assert candidate(sentence = \"a!b.c\") == 0\n assert candidate(sentence = \"multiple-punctuation!!\") == 0\n assert candidate(sentence = \"word-with123-hyphen\") == 0\n assert candidate(sentence = \"only!only only.only only-\") == 0\n assert candidate(sentence = \"word1 word2- word3- word4\") == 0\n assert candidate(sentence = \"word-with-hyphen- word\") == 1\n assert candidate(sentence = \"valid-word\") == 1\n assert candidate(sentence = \"-word\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word\") == 1\n assert candidate(sentence = \"word-with-1digit\") == 0\n assert candidate(sentence = \"word-with-punctuations,word-with-punctuations,word-with-punctuations,word-with-punctuations,word-with-punctuations!\") == 0\n assert candidate(sentence = \"valid-word, and invalid-word1\") == 2\n assert candidate(sentence = \"word-with-punctuation-in-middle.a\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word@?\") == 2\n assert candidate(sentence = \"word-with-hyphen-and-period.\") == 0\n assert candidate(sentence = \"word-with-multiple-hyphens-and-punctuation-,and valid-word!\") == 1\n assert candidate(sentence = \"word-with-punctuations,word-with-punctuations.\") == 0\n assert candidate(sentence = \"valid-word followed-by-number123\") == 1\n assert candidate(sentence = \"single-punctuation!\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@123\") == 1\n assert candidate(sentence = \"word word- word! word-\") == 2\n assert candidate(sentence = \"word-! word- word-\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc123\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen-and-punctuation-word-1.\") == 0\n assert candidate(sentence = \"word-with-hyphen word-with-hyphen- word-with-hyphen\") == 0\n assert candidate(sentence = \"valid-word! another-valid-word?\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation1,\") == 0\n assert candidate(sentence = \"word-with-punctuation.at-end\") == 0\n assert candidate(sentence = \"valid-word, invalid-word123\") == 1\n assert candidate(sentence = \"!valid valid. valid-\") == 1\n assert candidate(sentence = \"valid-word.\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation1-.\") == 0\n assert candidate(sentence = \"a a-b a-b-c a-b-c-d\") == 2\n assert candidate(sentence = \"word-with-trailing-punctuation,\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation-after-hyphen-.\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@123\") == 1\n assert candidate(sentence = \"multiple spaces\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word?\") == 1\n assert candidate(sentence = \"multiple-punctuation..\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc-123\") == 1\n assert candidate(sentence = \"word! word- word. word-\") == 2\n assert candidate(sentence = \"valid-word followed-by-digits123\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen--b-1\") == 0\n assert candidate(sentence = \"hello-world- is-not-valid\") == 0\n assert candidate(sentence = \"word-with-punctuations!word-with-punctuations!\") == 0\n assert candidate(sentence = \"-a\") == 0\n assert candidate(sentence = \"nohyphens here!\") == 2\n assert candidate(sentence = \"word-with-punctuation-at-start!word\") == 0\n assert candidate(sentence = \"leading!and-trailing!punctuation!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def!\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc\") == 1\n assert candidate(sentence = \"no-dashes-here but-here-are-too-many-dashes\") == 0\n assert candidate(sentence = \"word-hyphen- word\") == 1\n assert candidate(sentence = \"valid-word-with-hyphen-and-punctuation.\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation!\") == 0\n assert candidate(sentence = \"valid-word, valid-word. valid-word!\") == 3\n assert candidate(sentence = \"word-with-punctuation.at.end.\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word-\") == 1\n assert candidate(sentence = \"a!b!c\") == 0\n assert candidate(sentence = \"word-with-number1234 and valid-word\") == 2\n assert candidate(sentence = \"word,word!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word@\") == 2\n assert candidate(sentence = \"word1 word2 word3 word4\") == 0\n assert candidate(sentence = \"word-with-punctuation,at,end!invalid\") == 0\n assert candidate(sentence = \"complex-word-with-punctuation,\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc-def!\") == 1\n assert candidate(sentence = \"word-with-punctuations!word-with-punctuations!word-with-punctuations!word-with-punctuations.\") == 0\n assert candidate(sentence = \"single-letter-word a\") == 1\n assert candidate(sentence = \"word-with-trailing-hyphen-\") == 0\n assert candidate(sentence = \"punctuation.multiple\") == 0\n assert candidate(sentence = \"multi-hyphen-word-123\") == 0\n assert candidate(sentence = \"word-with-hyphen word-with-hyphen-\") == 0\n assert candidate(sentence = \"valid-word a valid-word- valid-word\") == 3\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc123\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation-1.\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-b-1--\") == 0\n assert candidate(sentence = \"word!word!\") == 0\n assert candidate(sentence = \"!word .word ,word\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation- word\") == 1\n assert candidate(sentence = \"invalid-punctuation, invalid-punctuation! invalid-punctuation?\") == 3\n assert candidate(sentence = \"a.b.c.d\") == 0\n assert candidate(sentence = \"multi-hyphenated-word-should-fail\") == 0\n assert candidate(sentence = \"valid-word!\") == 1\n assert candidate(sentence = \"punctuation!in!middle\") == 0\n assert candidate(sentence = \"trailing-hyphen- invalid-hyphen-\") == 0\n assert candidate(sentence = \"single-letter a\") == 2\n assert candidate(sentence = \"word-with-digit-and-hyphen--b1\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-period-and-comma,./\") == 0\n assert candidate(sentence = \"word-with-punctuations! word\") == 1\n assert candidate(sentence = \"word-with-2-hyphens-a-b-c\") == 0\n assert candidate(sentence = \"word-with--double-hyphen\") == 0\n assert candidate(sentence = \"a.b-c!d.e\") == 0\n assert candidate(sentence = \"this-is-valid-1\") == 0\n assert candidate(sentence = \"valid-word! valid-word!\") == 2\n assert candidate(sentence = \"word-with-hyphen-and-digit1-\") == 0\n assert candidate(sentence = \"a!b-c.d.e\") == 0\n assert candidate(sentence = \"a.b-c.d.e\") == 0\n assert candidate(sentence = \"word-with-digit-and-punctuation1-!\") == 0\n assert candidate(sentence = \"1word 12word word3\") == 0\n assert candidate(sentence = \"word-with-punctuation,word-with-punctuation, word-with-punctuation!word-with-punctuation.\") == 0\n assert candidate(sentence = \"a!b.c-d.e\") == 0\n assert candidate(sentence = \"valid-word-1 valid-word-2\") == 0\n assert candidate(sentence = \"word!word another-word,\") == 1\n assert candidate(sentence = \"a.b-c.d!e\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def\") == 1\n assert candidate(sentence = \"a-b.c.d\") == 0\n assert candidate(sentence = \"mid,dash\") == 0\n assert candidate(sentence = \"valid.word\") == 0\n assert candidate(sentence = \"valid-word valid-word-\") == 1\n assert candidate(sentence = \"word-with-punctuations,word\") == 0\n assert candidate(sentence = \"word-with-digit-and-punctuation1.\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-word-1\") == 0\n assert candidate(sentence = \"word-!\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-comma,\") == 0\n assert candidate(sentence = \"-hyphen-at-start\") == 0\n assert candidate(sentence = \"single-punctuation-mark.\") == 0\n assert candidate(sentence = \"!invalid-start-word invalid-end-word!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def!\") == 1\n assert candidate(sentence = \"a-b-c-d\") == 0\n assert candidate(sentence = \"word-with-punctuations,word-with-punctuations,word-with-punctuations!\") == 0\n assert candidate(sentence = \"word-with-digit-at-end1.\") == 0\n assert candidate(sentence = \"valid-word-!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc-def\") == 1\n assert candidate(sentence = \"multiple-hyphens-in--one-word\") == 0\n assert candidate(sentence = \"a valid-word- valid-word valid-word-\") == 2\n assert candidate(sentence = \"double--hyphen invalid\") == 1\n assert candidate(sentence = \"validwordwithmultiplepunctuations...\") == 0\n assert candidate(sentence = \"!a-b\") == 0\n assert candidate(sentence = \"word! word- word. word@\") == 3\n assert candidate(sentence = \"valid-word- valid-word valid-word\") == 2\n assert candidate(sentence = \"leading-hyphen invalid-hyphen\") == 2\n assert candidate(sentence = \"a.b.c!\") == 0\n assert candidate(sentence = \"invalid-word- punctuation-here.\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def\") == 1\n assert candidate(sentence = \"valid-word-here, and-this.is!ok\") == 0\n assert candidate(sentence = \"valid-word, valid-word.\") == 2\n assert candidate(sentence = \"valid-word valid-word valid-word-\") == 2\n assert candidate(sentence = \"word-h word-hyphenated word-!\") == 2\n assert candidate(sentence = \"another!valid!word\") == 0\n assert candidate(sentence = \"word-with.punctuation\") == 0\n assert candidate(sentence = \"valid-word- valid-hyphenated-word\") == 0\n assert candidate(sentence = \"valid-word word-with-hyphen-\") == 1\n assert candidate(sentence = \"word-with-hyphen-and-punctuation! word-with-hyphen-and-punctuation!\") == 0\n assert candidate(sentence = \"single-letter a valid-word\") == 3\n assert candidate(sentence = \"valid-word-with-hyphen-and-punctuation,\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation.\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word!\") == 1\n assert candidate(sentence = \"end! punctuation\") == 2\n assert candidate(sentence = \"word-with-digit-at-end1\") == 0\n assert candidate(sentence = \"hyphenated-word-\") == 0\n assert candidate(sentence = \"valid-word,\") == 1\n assert candidate(sentence = \"-word-with-hyphen\") == 0\n assert candidate(sentence = \"only-allowed-here\") == 0\n assert candidate(sentence = \"word-with-digit-in-hyphen-1-word\") == 0\n assert candidate(sentence = \"mixed-case Words Are Invalid\") == 4\n assert candidate(sentence = \"-leading-hyphen\") == 0\n assert candidate(sentence = \"word-with-punctuation!at!the!end\") == 0\n assert candidate(sentence = \"validwordwithmultiplepunctuations!!!\") == 0\n assert candidate(sentence = \"valid-word word-with-hyphen\") == 1\n assert candidate(sentence = \"word-with-digit1-and-punctuation,\") == 0\n assert candidate(sentence = \"word-with-hyphen123\") == 0\n assert candidate(sentence = \"word-with-punctuation!at!end\") == 0\n assert candidate(sentence = \"word-hyphenated word- word. word?\") == 3\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123\") == 1\n assert candidate(sentence = \"word-with-digit-at-end1,\") == 0\n assert candidate(sentence = \"word word- word! word?\") == 3\n assert candidate(sentence = \"valid-word,another-valid-word\") == 0\n assert candidate(sentence = \"trailing-punctuations,, are! invalid\") == 2\n assert candidate(sentence = \"word-with-punctuation!and-more\") == 0\n assert candidate(sentence = \"123abc and abc123 are invalid\") == 3\n assert candidate(sentence = \"word-with-digit-and-hyphen--b\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-b-1\") == 0\n assert candidate(sentence = \"valid-word! valid-word, valid-word.\") == 3\n assert candidate(sentence = \"no-hyphens allowed\") == 2\n assert candidate(sentence = \"word-with-digit-and-punctuation-1!\") == 0\n assert candidate(sentence = \"multiple spaces between words\") == 4\n assert candidate(sentence = \"triple-hyphen---word\") == 0\n assert candidate(sentence = \"punctuation,,comma and space\") == 2\n assert candidate(sentence = \"valid-word-2!\") == 0\n assert candidate(sentence = \"word-with-digit1-and-hyphen-b\") == 0\n assert candidate(sentence = \"valid-hyphen-word word- word\") == 1\n assert candidate(sentence = \"word- word- word- word.\") == 1\n assert candidate(sentence = \"word!!\") == 0\n assert candidate(sentence = \"trailing-hyphen-\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@\") == 1\n assert candidate(sentence = \"word- word- word- word\") == 1\n assert candidate(sentence = \"word-!!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-123\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation1!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#\") == 1\n assert candidate(sentence = \"word-with-multiple-punctuations!!!\") == 0\n assert candidate(sentence = \"word-with-punctuations!.\") == 0\n assert candidate(sentence = \"word1- word2- word3- word4-\") == 0\n assert candidate(sentence = \"multiple--hyphens-are!invalid\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc123\") == 1\n assert candidate(sentence = \"valid-word- valid-word- valid-word-\") == 0\n assert candidate(sentence = \"valid-word-with-punctuation-at-end.\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen1-b\") == 0\n assert candidate(sentence = \"multi-hyphen-usage-is-not-allowed\") == 0\n assert candidate(sentence = \"word-with! punctuation\") == 2\n assert candidate(sentence = \"valid-word valid-word valid-word\") == 3\n assert candidate(sentence = \"valid-word-1 valid-word-2 valid-word-3\") == 0\n assert candidate(sentence = \"word-with-punctuations,word-with-punctuations,word-with-punctuations,word-with-punctuations!\") == 0\n assert candidate(sentence = \"word-with-digit-in-hyphen-word-1\") == 0\n assert candidate(sentence = \"word-\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-1-b\") == 0\n assert candidate(sentence = \"valid,word valid.word valid-word!\") == 1\n"}, "metadata": {"canonical_parameter_names": ["sentence"], "leetcode_dataset_entry_point": "Solution().countValidWords", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countValidWords(self, sentence: str) -> int:", "container": "Solution", "callable": "countValidWords", "parameters": [{"name": "sentence", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2048, "task_id": "next-greater-numerically-balanced-number", "difficulty": "Medium", "problem_description": "An integer x is numerically balanced if for every digit d in the number x, there are exactly d occurrences of that digit in x.\nGiven an integer n, return the smallest numerically balanced number strictly greater than n.\n \nExample 1:\n\nInput: n = 1\nOutput: 22\nExplanation: \n22 is numerically balanced since:\n- The digit 2 occurs 2 times. \nIt is also the smallest numerically balanced number strictly greater than 1.\n\nExample 2:\n\nInput: n = 1000\nOutput: 1333\nExplanation: \n1333 is numerically balanced since:\n- The digit 1 occurs 1 time.\n- The digit 3 occurs 3 times. \nIt is also the smallest numerically balanced number strictly greater than 1000.\nNote that 1022 cannot be the answer because 0 appeared more than 0 times.\n\nExample 3:\n\nInput: n = 3000\nOutput: 3133\nExplanation: \n3133 is numerically balanced since:\n- The digit 1 occurs 1 time.\n- The digit 3 occurs 3 times.\nIt is also the smallest numerically balanced number strictly greater than 3000.\n\n \nConstraints:\n\n0 <= n <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 1\n assert candidate(n = 122333) == 123233\n assert candidate(n = 3000) == 3133\n assert candidate(n = 1222) == 1333\n assert candidate(n = 55555) == 122333\n assert candidate(n = 1234) == 1333\n assert candidate(n = 112233) == 122333\n assert candidate(n = 122133) == 122333\n assert candidate(n = 1234567) == 1242444\n assert candidate(n = 999999) == 1224444\n assert candidate(n = 123456) == 132233\n assert candidate(n = 1) == 22\n assert candidate(n = 1000) == 1333\n assert candidate(n = 1224444) == 1242444\n assert candidate(n = 987654) == 1224444\n assert candidate(n = 122) == 212\n assert candidate(n = 122333444) == 122666666\n assert candidate(n = 2233445566) == 2233535555\n assert candidate(n = 122444) == 123233\n assert candidate(n = 3333333) == 3334444\n assert candidate(n = 666666) == 1224444\n assert candidate(n = 11222233) == 12255555\n assert candidate(n = 444444) == 515555\n assert candidate(n = 1223334444) == 1223343444\n assert candidate(n = 2222222) == 2241444\n assert candidate(n = 44445555) == 51225555\n assert candidate(n = 6665554443332211) == 6665554444155666\n assert candidate(n = 1233333) == 1242444\n assert candidate(n = 122111333) == 122666666\n assert candidate(n = 22333444) == 22515555\n assert candidate(n = 123321) == 123323\n assert candidate(n = 98765) == 122333\n assert candidate(n = 665544332211) == 665551556666\n assert candidate(n = 400000) == 422444\n assert candidate(n = 123456789) == 126266666\n assert candidate(n = 1223334) == 1224444\n assert candidate(n = 5555555) == 6166666\n assert candidate(n = 223334444555) == 223336166666\n assert candidate(n = 111) == 122\n assert candidate(n = 7777777) == 12255555\n assert candidate(n = 1112233) == 1224444\n assert candidate(n = 122333444555555) == 122333445445555\n assert candidate(n = 2233444) == 2241444\n assert candidate(n = 1222333) == 1224444\n assert candidate(n = 2121212121) == 2123334444\n assert candidate(n = 122444455555) == 122444545555\n assert candidate(n = 12233344) == 12255555\n assert candidate(n = 666666555444333222111) == 666666555444333224155\n assert candidate(n = 1000000) == 1224444\n assert candidate(n = 22222222) == 22515555\n assert candidate(n = 122333444555666) == 122333445445555\n assert candidate(n = 1221221) == 1224444\n assert candidate(n = 5555544332211) == 5555544333144\n assert candidate(n = 1233322) == 1242444\n assert candidate(n = 4444) == 14444\n assert candidate(n = 122334444) == 122666666\n assert candidate(n = 1222233333) == 1223334444\n assert candidate(n = 1333331) == 1422444\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().nextBeautifulNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def nextBeautifulNumber(self, n: int) -> int:", "container": "Solution", "callable": "nextBeautifulNumber", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2049, "task_id": "count-nodes-with-the-highest-score", "difficulty": "Medium", "problem_description": "There is a binary tree rooted at 0 consisting of n nodes. The nodes are labeled from 0 to n - 1. You are given a 0-indexed integer array parents representing the tree, where parents[i] is the parent of node i. Since node 0 is the root, parents[0] == -1.\nEach node has a score. To find the score of a node, consider if the node and the edges connected to it were removed. The tree would become one or more non-empty subtrees. The size of a subtree is the number of the nodes in it. The score of the node is the product of the sizes of all those subtrees.\nReturn the number of nodes that have the highest score.\n \nExample 1:\n\n\nInput: parents = [-1,2,0,2,0]\nOutput: 3\nExplanation:\n- The score of node 0 is: 3 * 1 = 3\n- The score of node 1 is: 4 = 4\n- The score of node 2 is: 1 * 1 * 2 = 2\n- The score of node 3 is: 4 = 4\n- The score of node 4 is: 4 = 4\nThe highest score is 4, and three nodes (node 1, node 3, and node 4) have the highest score.\n\nExample 2:\n\n\nInput: parents = [-1,2,0]\nOutput: 2\nExplanation:\n- The score of node 0 is: 2 = 2\n- The score of node 1 is: 2 = 2\n- The score of node 2 is: 1 * 1 = 1\nThe highest score is 2, and two nodes (node 0 and node 1) have the highest score.\n\n \nConstraints:\n\nn == parents.length\n2 <= n <= 105\nparents[0] == -1\n0 <= parents[i] <= n - 1 for i != 0\nparents represents a valid binary tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3]) == 5\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2]) == 1\n assert candidate(parents = [-1, 2, 0, 2, 0]) == 3\n assert candidate(parents = [-1, 0, 1, 2, 3]) == 3\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 2\n assert candidate(parents = [-1, 0, 1, 2, 2]) == 3\n assert candidate(parents = [-1, 0, 0, 1, 1]) == 3\n assert candidate(parents = [-1, 1, 1, 2, 2, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2]) == 3\n assert candidate(parents = [-1, 0, 1, 1, 3, 3]) == 4\n assert candidate(parents = [-1, 2, 0]) == 2\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63, 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, 74, 74, 75, 75, 76, 76, 77, 77, 78, 78, 79, 79, 80, 80, 81, 81, 82, 82, 83, 83, 84, 84, 85, 85, 86, 86, 87, 87, 88, 88, 89, 89, 90, 90]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 2\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30]) == 2\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30, 32, 32, 34, 34, 36, 36]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200]) == 2\n assert candidate(parents = [-1, 0, 1, 0, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4]) == 2\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 2\n assert candidate(parents = [-1, 0, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30, 32, 32]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 1\n"}, "metadata": {"canonical_parameter_names": ["parents"], "leetcode_dataset_entry_point": "Solution().countHighestScoreNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countHighestScoreNodes(self, parents: list[int]) -> int:", "container": "Solution", "callable": "countHighestScoreNodes", "parameters": [{"name": "parents", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2050, "task_id": "parallel-courses-iii", "difficulty": "Hard", "problem_description": "You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given a 2D integer array relations where relations[j] = [prevCoursej, nextCoursej] denotes that course prevCoursej has to be completed before course nextCoursej (prerequisite relationship). Furthermore, you are given a 0-indexed integer array time where time[i] denotes how many months it takes to complete the (i+1)th course.\nYou must find the minimum number of months needed to complete all the courses following these rules:\n\nYou may start taking a course at any time if the prerequisites are met.\nAny number of courses can be taken at the same time.\n\nReturn the minimum number of months needed to complete all the courses.\nNote: The test cases are generated such that it is possible to complete every course (i.e., the graph is a directed acyclic graph).\n \nExample 1:\n\n\nInput: n = 3, relations = [[1,3],[2,3]], time = [3,2,5]\nOutput: 8\nExplanation: The figure above represents the given graph and the time required to complete each course. \nWe start course 1 and course 2 simultaneously at month 0.\nCourse 1 takes 3 months and course 2 takes 2 months to complete respectively.\nThus, the earliest time we can start course 3 is at month 3, and the total time required is 3 + 5 = 8 months.\n\nExample 2:\n\n\nInput: n = 5, relations = [[1,5],[2,5],[3,5],[3,4],[4,5]], time = [1,2,3,4,5]\nOutput: 12\nExplanation: The figure above represents the given graph and the time required to complete each course.\nYou can start courses 1, 2, and 3 at month 0.\nYou can complete them after 1, 2, and 3 months respectively.\nCourse 4 can be taken only after course 3 is completed, i.e., after 3 months. It is completed after 3 + 4 = 7 months.\nCourse 5 can be taken only after courses 1, 2, 3, and 4 have been completed, i.e., after max(1,2,3,7) = 7 months.\nThus, the minimum time needed to complete all the courses is 7 + 5 = 12 months.\n\n \nConstraints:\n\n1 <= n <= 5 * 104\n0 <= relations.length <= min(n * (n - 1) / 2, 5 * 104)\nrelations[j].length == 2\n1 <= prevCoursej, nextCoursej <= n\nprevCoursej != nextCoursej\nAll the pairs [prevCoursej, nextCoursej] are unique.\ntime.length == n\n1 <= time[i] <= 104\nThe given graph is a directed acyclic graph.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,relations = [[1, 2], [1, 3], [2, 4], [3, 4]],time = [4, 2, 3, 1]) == 8\n assert candidate(n = 3,relations = [[1, 3], [2, 3]],time = [3, 2, 5]) == 8\n assert candidate(n = 6,relations = [[1, 2], [2, 3], [3, 4], [1, 5], [5, 6], [4, 6]],time = [1, 2, 3, 4, 5, 6]) == 16\n assert candidate(n = 1,relations = [],time = [5]) == 5\n assert candidate(n = 4,relations = [[1, 2], [2, 3], [3, 4]],time = [1, 2, 3, 4]) == 10\n assert candidate(n = 5,relations = [[1, 5], [2, 5], [3, 5], [3, 4], [4, 5]],time = [1, 2, 3, 4, 5]) == 12\n assert candidate(n = 9,relations = [[1, 4], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],time = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10], [10, 11], [10, 12]],time = [2, 3, 4, 1, 5, 6, 7, 8, 9, 3, 12, 4]) == 37\n assert candidate(n = 8,relations = [[1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8]],time = [2, 3, 2, 3, 2, 3, 4, 5]) == 11\n assert candidate(n = 8,relations = [[1, 2], [2, 4], [1, 3], [3, 5], [3, 6], [4, 6], [5, 7], [6, 7], [7, 8]],time = [1, 3, 2, 4, 5, 6, 1, 8]) == 23\n assert candidate(n = 20,relations = [[1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9]],time = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 100\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [5, 6], [5, 7], [4, 8], [7, 8], [8, 9], [9, 10]],time = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 50\n assert candidate(n = 12,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]],time = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 126\n assert candidate(n = 11,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 66\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 13], [9, 14], [10, 15], [11, 15]],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 62\n assert candidate(n = 12,relations = [[1, 6], [2, 6], [3, 6], [4, 7], [5, 7], [6, 8], [6, 9], [7, 10], [8, 11], [9, 11], [10, 12], [11, 12]],time = [1, 1, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7]) == 20\n assert candidate(n = 25,relations = [[1, 6], [2, 6], [3, 7], [4, 7], [5, 7], [6, 8], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]],time = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 64\n assert candidate(n = 15,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15]],time = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 95\n assert candidate(n = 8,relations = [[1, 3], [2, 3], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7], [7, 8]],time = [10, 20, 30, 40, 50, 60, 70, 80]) == 300\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 17\n assert candidate(n = 15,relations = [[1, 6], [2, 6], [3, 7], [4, 7], [5, 7], [6, 8], [7, 8], [8, 9], [8, 10], [9, 11], [10, 11], [11, 12], [11, 13], [12, 14], [13, 14], [14, 15]],time = [4, 5, 2, 6, 3, 1, 8, 9, 2, 7, 5, 6, 4, 3, 10]) == 54\n assert candidate(n = 7,relations = [[1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [4, 5], [5, 7], [6, 7]],time = [2, 3, 4, 5, 1, 6, 7]) == 16\n assert candidate(n = 11,relations = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],time = [1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(n = 6,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 6]],time = [1, 2, 3, 4, 5, 6]) == 15\n assert candidate(n = 12,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 73\n assert candidate(n = 8,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [6, 8]],time = [5, 3, 10, 2, 8, 4, 1, 6]) == 33\n assert candidate(n = 12,relations = [[1, 5], [2, 5], [3, 5], [1, 6], [2, 6], [3, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = [2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7]) == 32\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [3, 6], [4, 6], [5, 6], [6, 7], [7, 8], [7, 9], [7, 10], [8, 11], [9, 11], [10, 11], [11, 12], [12, 13], [12, 14], [12, 15]],time = [2, 3, 4, 5, 1, 6, 7, 8, 9, 2, 5, 1, 3, 4, 5]) == 40\n assert candidate(n = 20,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(n = 7,relations = [[1, 2], [1, 4], [2, 3], [2, 5], [4, 6], [5, 6], [6, 7]],time = [5, 4, 3, 2, 1, 10, 15]) == 35\n assert candidate(n = 15,relations = [[1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 40\n assert candidate(n = 30,relations = [[1, 10], [2, 10], [3, 11], [4, 11], [5, 11], [6, 12], [7, 12], [8, 12], [9, 12], [10, 13], [11, 13], [12, 14], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]],time = [2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1]) == 62\n assert candidate(n = 12,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [7, 10], [8, 11], [9, 11], [10, 12], [11, 12]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 42\n assert candidate(n = 8,relations = [[1, 3], [2, 3], [3, 4], [1, 5], [2, 5], [5, 6], [6, 7], [7, 8]],time = [2, 3, 1, 2, 4, 3, 2, 1]) == 13\n assert candidate(n = 12,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [1, 6], [1, 7], [1, 8], [2, 9], [2, 10], [3, 11], [4, 12]],time = [3, 2, 5, 1, 6, 7, 4, 8, 9, 2, 5, 1]) == 53\n assert candidate(n = 7,relations = [[1, 4], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [4, 6], [5, 6], [4, 7], [5, 7]],time = [3, 2, 5, 4, 3, 7, 5]) == 16\n assert candidate(n = 9,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],time = [3, 2, 5, 4, 3, 2, 5, 4, 3, 2]) == 18\n assert candidate(n = 9,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [1, 6], [1, 7], [2, 8], [3, 9]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 47\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [8, 11], [9, 12], [9, 13], [10, 14], [11, 14], [12, 15], [13, 15]],time = [2, 3, 2, 4, 3, 1, 5, 6, 7, 8, 4, 3, 2, 5, 6]) == 28\n assert candidate(n = 20,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20]],time = [2, 3, 4, 5, 1, 6, 7, 8, 9, 2, 5, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == 105\n assert candidate(n = 13,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [6, 8], [7, 9], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]],time = [4, 3, 5, 2, 6, 7, 8, 9, 3, 4, 10, 1, 2]) == 51\n assert candidate(n = 15,relations = [[1, 10], [1, 11], [2, 10], [3, 11], [4, 12], [5, 12], [6, 13], [7, 13], [8, 14], [9, 14], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15]],time = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1]) == 16\n assert candidate(n = 20,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(n = 15,relations = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 7], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = [2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1]) == 35\n assert candidate(n = 9,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],time = [4, 3, 2, 1, 4, 3, 2, 1, 4]) == 24\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7], [7, 8]],time = [5, 4, 3, 2, 1, 1, 2, 3]) == 17\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8]],time = [10, 20, 30, 40, 50, 60, 70, 80]) == 210\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(n = 20,relations = [[1, 5], [2, 6], [3, 7], [4, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 13], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19], [12, 20], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 20]],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 12\n assert candidate(n = 20,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [8, 11], [9, 12], [9, 13], [10, 14], [11, 14], [12, 15], [13, 15], [14, 16], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 138\n assert candidate(n = 7,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7]],time = [3, 2, 5, 4, 1, 6, 8]) == 27\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7], [7, 8], [8, 9], [9, 10]],time = [1, 2, 3, 2, 3, 2, 3, 4, 5, 6]) == 27\n assert candidate(n = 6,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],time = [1000, 2000, 3000, 4000, 5000, 6000]) == 21000\n assert candidate(n = 7,relations = [[1, 4], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7]],time = [1, 1, 1, 3, 2, 2, 1]) == 7\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [5, 7], [6, 8], [7, 8], [8, 9], [9, 10]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 47\n"}, "metadata": {"canonical_parameter_names": ["n", "relations", "time"], "leetcode_dataset_entry_point": "Solution().minimumTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumTime(self, n: int, relations: list[list[int]], time: list[int]) -> int:", "container": "Solution", "callable": "minimumTime", "parameters": [{"name": "n", "type": "int"}, {"name": "relations", "type": "list[list[int]]"}, {"name": "time", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2053, "task_id": "kth-distinct-string-in-an-array", "difficulty": "Easy", "problem_description": "A distinct string is a string that is present only once in an array.\nGiven an array of strings arr, and an integer k, return the kth distinct string present in arr. If there are fewer than k distinct strings, return an empty string \"\".\nNote that the strings are considered in the order in which they appear in the array.\n \nExample 1:\n\nInput: arr = [\"d\",\"b\",\"c\",\"b\",\"c\",\"a\"], k = 2\nOutput: \"a\"\nExplanation:\nThe only distinct strings in arr are \"d\" and \"a\".\n\"d\" appears 1st, so it is the 1st distinct string.\n\"a\" appears 2nd, so it is the 2nd distinct string.\nSince k == 2, \"a\" is returned. \n\nExample 2:\n\nInput: arr = [\"aaa\",\"aa\",\"a\"], k = 1\nOutput: \"aaa\"\nExplanation:\nAll strings in arr are distinct, so the 1st string \"aaa\" is returned.\n\nExample 3:\n\nInput: arr = [\"a\",\"b\",\"a\"], k = 3\nOutput: \"\"\nExplanation:\nThe only distinct string is \"b\". Since there are fewer than 3 distinct strings, we return an empty string \"\".\n\n \nConstraints:\n\n1 <= k <= arr.length <= 1000\n1 <= arr[i].length <= 5\narr[i] consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = ['a'],k = 1) == \"a\"\n assert candidate(arr = ['a', 'a', 'b', 'b', 'c', 'c', 'd'],k = 1) == \"d\"\n assert candidate(arr = ['apple', 'banana', 'apple', 'orange', 'banana', 'kiwi'],k = 2) == \"kiwi\"\n assert candidate(arr = ['apple', 'banana', 'apple', 'orange', 'banana', 'grape'],k = 2) == \"grape\"\n assert candidate(arr = ['aaa', 'aa', 'a'],k = 1) == \"aaa\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f'],k = 6) == \"f\"\n assert candidate(arr = ['repeat', 'repeat', 'repeat'],k = 1) == \"\"\n assert candidate(arr = ['apple', 'banana', 'cherry', 'date'],k = 1) == \"apple\"\n assert candidate(arr = ['hello', 'world', 'hello', 'world'],k = 2) == \"\"\n assert candidate(arr = ['x', 'y', 'z', 'x', 'y', 'z'],k = 2) == \"\"\n assert candidate(arr = ['apple', 'apple', 'banana', 'banana', 'cherry'],k = 3) == \"\"\n assert candidate(arr = ['apple', 'banana', 'apple', 'orange'],k = 2) == \"orange\"\n assert candidate(arr = ['repeat', 'repeat', 'repeat', 'repeat'],k = 1) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],k = 10) == \"j\"\n assert candidate(arr = ['unique', 'distinct', 'strings', 'unique'],k = 2) == \"strings\"\n assert candidate(arr = ['unique'],k = 1) == \"unique\"\n assert candidate(arr = ['same', 'same', 'same', 'same'],k = 1) == \"\"\n assert candidate(arr = ['apple', 'banana', 'cherry'],k = 1) == \"apple\"\n assert candidate(arr = ['hello', 'world', 'hello', 'python', 'world', 'code'],k = 3) == \"\"\n assert candidate(arr = ['a', 'b', 'a'],k = 3) == \"\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five'],k = 5) == \"five\"\n assert candidate(arr = ['a', 'a', 'a', 'a', 'a'],k = 1) == \"\"\n assert candidate(arr = ['test', 'test', 'test'],k = 1) == \"\"\n assert candidate(arr = ['d', 'b', 'c', 'b', 'c', 'a'],k = 2) == \"a\"\n assert candidate(arr = ['hello', 'world', 'hello', 'python', 'world'],k = 1) == \"python\"\n assert candidate(arr = ['single'],k = 2) == \"\"\n assert candidate(arr = ['xyz', 'zyx', 'zyx', 'xyz', 'zyx'],k = 1) == \"\"\n assert candidate(arr = ['abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij'],k = 5) == \"abcdefgh\"\n assert candidate(arr = ['unique', 'strings', 'only', 'here', 'unique', 'strings', 'here', 'unique'],k = 2) == \"\"\n assert candidate(arr = ['longer', 'string', 'values', 'are', 'also', 'allowed', 'in', 'this', 'example'],k = 2) == \"string\"\n assert candidate(arr = ['unique1', 'unique2', 'unique3', 'unique4', 'unique5', 'unique6', 'unique7', 'unique8', 'unique9', 'unique10'],k = 5) == \"unique5\"\n assert candidate(arr = ['same', 'word', 'same', 'word', 'same', 'word', 'same', 'word', 'same'],k = 1) == \"\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],k = 7) == \"seven\"\n assert candidate(arr = ['x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y'],k = 1) == \"\"\n assert candidate(arr = ['test', 'testing', 'test', 'testing', 'test', 'testing'],k = 1) == \"\"\n assert candidate(arr = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab', 'cdef', 'ghij', 'klmn', 'opqr', 'stuv', 'wxyz'],k = 13) == \"wxyz\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty'],k = 20) == \"twenty\"\n assert candidate(arr = ['short', 'longerstring', 'shorter', 'longeststring', 'short', 'shorter', 'longerstring'],k = 2) == \"\"\n assert candidate(arr = ['abcd', 'abc', 'ab', 'a', 'abcd', 'abc', 'ab', 'a', 'abcd', 'abc', 'ab', 'a'],k = 3) == \"\"\n assert candidate(arr = ['abc', 'def', 'ghi', 'abc', 'jkl', 'ghi', 'mno'],k = 4) == \"\"\n assert candidate(arr = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'unique'],k = 1) == \"unique\"\n assert candidate(arr = ['x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'unique'],k = 6) == \"\"\n assert candidate(arr = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],k = 1) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 26) == \"z\"\n assert candidate(arr = ['unique', 'distinct', 'unique', 'distinct', 'unique', 'distinct', 'unique', 'distinct', 'unique', 'distinct'],k = 5) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 27) == \"\"\n assert candidate(arr = ['test', 'testcase', 'testing', 'test', 'testcase', 'test', 'test', 'testcase', 'testing', 'testing'],k = 3) == \"\"\n assert candidate(arr = ['xy', 'yx', 'xx', 'yy', 'xz', 'zx', 'yz', 'zy', 'xxyy', 'xyxy', 'yxyx', 'yxyy', 'xyyx', 'xyyy', 'yyxx', 'yyxy', 'yyyx', 'yyyy'],k = 10) == \"xyxy\"\n assert candidate(arr = ['xyz', 'zyx', 'wxy', 'yxw', 'uvw', 'vuw', 'wuv', 'abc', 'cab', 'bac'],k = 2) == \"zyx\"\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abc', 'def', 'ghi'],k = 5) == \"vwx\"\n assert candidate(arr = ['same', 'different', 'same', 'different', 'same', 'different', 'same', 'different'],k = 2) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd'],k = 10) == \"\"\n assert candidate(arr = ['aaaaa', 'aaaab', 'aaaba', 'aabaa', 'abaaa', 'baaaa', 'abcde', 'bcdea', 'cdeab', 'decab', 'efghi', 'fghie', 'ghief', 'hiefg', 'iefgh', 'jklmn', 'klmno', 'lmnop', 'mnopq', 'nopqr', 'opqrs', 'pqrst', 'qrstu', 'rstuv', 'stuvw', 'tuvwx', 'uvwxy', 'vwxyz'],k = 15) == \"iefgh\"\n assert candidate(arr = ['unique', 'string', 'in', 'this', 'array'],k = 5) == \"array\"\n assert candidate(arr = ['loop', 'pool', 'look', 'cool', 'cool', 'lopo', 'loopo'],k = 3) == \"look\"\n assert candidate(arr = ['repeated', 'repeated', 'repeated', 'repeated', 'repeated', 'repeated'],k = 1) == \"\"\n assert candidate(arr = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba'],k = 25) == \"dabc\"\n assert candidate(arr = ['same', 'word', 'same', 'word', 'same'],k = 2) == \"\"\n assert candidate(arr = ['complex', 'input', 'with', 'various', 'strings', 'complex', 'input', 'with', 'various', 'strings', 'complex', 'input', 'with', 'various', 'strings'],k = 5) == \"\"\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],k = 9) == \"\"\n assert candidate(arr = ['repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'unique'],k = 21) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 15) == \"o\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],k = 15) == \"\"\n assert candidate(arr = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd'],k = 2) == \"\"\n assert candidate(arr = ['unique', 'strings', 'here', 'are', 'distinct', 'elements', 'with', 'no', 'repeats'],k = 10) == \"\"\n assert candidate(arr = ['apple', 'banana', 'apple', 'cherry', 'date', 'banana', 'fig'],k = 4) == \"\"\n assert candidate(arr = ['abcd', 'ab', 'a', 'abcde', 'abcd', 'abc', 'ab', 'a'],k = 3) == \"\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven'],k = 7) == \"seven\"\n assert candidate(arr = ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth'],k = 1) == \"first\"\n assert candidate(arr = ['aabb', 'abab', 'bbaa', 'abba', 'baab', 'baba', 'aabb', 'abab'],k = 1) == \"bbaa\"\n assert candidate(arr = ['a', 'a', 'a', 'b', 'b', 'c', 'c', 'c', 'c', 'd', 'd', 'd', 'd', 'd'],k = 4) == \"\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],k = 5) == \"five\"\n assert candidate(arr = ['repeat', 'repeat', 'distinct', 'repeat', 'distinct', 'distinct', 'distinct', 'repeat', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct'],k = 6) == \"\"\n assert candidate(arr = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'different'],k = 2) == \"\"\n assert candidate(arr = ['abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba'],k = 20) == \"dacb\"\n assert candidate(arr = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'],k = 10) == \"\"\n assert candidate(arr = ['apple', 'banana', 'apple', 'orange', 'banana', 'grape', 'kiwi', 'grape'],k = 4) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 5) == \"e\"\n assert candidate(arr = ['same', 'same', 'same', 'same', 'same', 'unique', 'unique', 'unique'],k = 1) == \"\"\n assert candidate(arr = ['abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh'],k = 3) == \"abcdef\"\n assert candidate(arr = ['aabb', 'abab', 'abba', 'baab', 'baba', 'bbaa', 'aaaa', 'bbbb', 'cccc', 'dddd'],k = 5) == \"baba\"\n assert candidate(arr = ['aaa', 'aab', 'aac', 'aad', 'aae', 'aaf', 'aag', 'aah', 'aai', 'aaj', 'aak'],k = 10) == \"aaj\"\n assert candidate(arr = ['only', 'one', 'distinct', 'string', 'here', 'in', 'this', 'array'],k = 1) == \"only\"\n assert candidate(arr = ['apple', 'banana', 'apple', 'orange', 'banana', 'grape', 'kiwi'],k = 4) == \"\"\n assert candidate(arr = ['apple', 'banana', 'cherry', 'banana', 'date', 'elderberry', 'fig', 'grape', 'fig', 'honeydew'],k = 5) == \"grape\"\n assert candidate(arr = ['repeat', 'repeat', 'repeat', 'distinct', 'distinct', 'distinct', 'kth', 'distinct'],k = 3) == \"\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen'],k = 10) == \"ten\"\n assert candidate(arr = ['a', 'ab', 'abc', 'abcd', 'abcde', 'a', 'ab', 'abc', 'abcd'],k = 3) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 10) == \"m\"\n assert candidate(arr = ['repeated', 'repeated', 'repeated', 'repeated', 'repeated', 'repeated', 'repeated'],k = 1) == \"\"\n assert candidate(arr = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],k = 1) == \"\"\n assert candidate(arr = ['aaaaa', 'aaaab', 'aaaba', 'aabaa', 'abaaa', 'baaaa', 'abcde', 'bcdea', 'cdeab', 'decab'],k = 8) == \"bcdea\"\n assert candidate(arr = ['test', 'testing', 'tested', 'testable', 'testify', 'testing'],k = 2) == \"tested\"\n assert candidate(arr = ['abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd'],k = 1) == \"\"\n assert candidate(arr = ['test', 'testing', 'tested', 'testing', 'tested', 'test', 'testing'],k = 2) == \"\"\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],k = 5) == \"mno\"\n assert candidate(arr = ['x', 'y', 'x', 'y', 'x', 'y', 'z', 'w', 'z', 'w', 'z', 'w', 'v', 'u', 'v', 'u', 't', 's', 'r', 'q', 'p'],k = 10) == \"\"\n assert candidate(arr = ['repeat', 'distinct', 'repeat', 'distinct', 'repeat', 'distinct', 'repeat', 'distinct', 'repeat', 'distinct'],k = 5) == \"\"\n assert candidate(arr = ['unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique'],k = 1) == \"\"\n assert candidate(arr = ['abcd', 'dcba', 'adbc', 'bdac', 'cadb', 'dacb', 'abcd', 'dcba'],k = 5) == \"\"\n assert candidate(arr = ['apple', 'banana', 'cherry', 'apple', 'banana', 'date', 'fig', 'grape', 'fig'],k = 4) == \"\"\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yza'],k = 10) == \"\"\n assert candidate(arr = ['same', 'same', 'same', 'different', 'different', 'unique'],k = 3) == \"\"\n assert candidate(arr = ['repeated', 'distinct', 'value', 'repeated', 'value', 'distinct', 'unique'],k = 4) == \"\"\n assert candidate(arr = ['same', 'same', 'different', 'different', 'unique'],k = 3) == \"\"\n assert candidate(arr = ['abc', 'def', 'abc', 'def', 'abc', 'def', 'abc', 'def', 'ghi', 'jkl'],k = 3) == \"\"\n assert candidate(arr = ['abcd', 'abcde', 'abcdef', 'abc', 'ab', 'a', '', 'a', 'ab', 'abc'],k = 5) == \"\"\n assert candidate(arr = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba'],k = 3) == \"\"\n assert candidate(arr = ['apple', 'banana', 'cherry', 'apple', 'banana', 'date', 'fig', 'grape'],k = 4) == \"grape\"\n assert candidate(arr = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],k = 5) == \"\"\n"}, "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().kthDistinct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def kthDistinct(self, arr: list[str], k: int) -> str:", "container": "Solution", "callable": "kthDistinct", "parameters": [{"name": "arr", "type": "list[str]"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2054, "task_id": "two-best-non-overlapping-events", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 2D integer array of events where events[i] = [startTimei, endTimei, valuei]. The ith event starts at startTimei and ends at endTimei, and if you attend this event, you will receive a value of valuei. You can choose at most two non-overlapping events to attend such that the sum of their values is maximized.\nReturn this maximum sum.\nNote that the start time and end time is inclusive: that is, you cannot attend two events where one of them starts and the other ends at the same time. More specifically, if you attend an event with end time t, the next event must start at or after t + 1.\n \nExample 1:\n\n\nInput: events = [[1,3,2],[4,5,2],[2,4,3]]\nOutput: 4\nExplanation: Choose the green events, 0 and 1 for a sum of 2 + 2 = 4.\n\nExample 2:\n\n\nInput: events = [[1,3,2],[4,5,2],[1,5,5]]\nOutput: 5\nExplanation: Choose event 2 for a sum of 5.\n\nExample 3:\n\n\nInput: events = [[1,5,3],[1,5,1],[6,6,5]]\nOutput: 8\nExplanation: Choose events 0 and 2 for a sum of 3 + 5 = 8.\n \nConstraints:\n\n2 <= events.length <= 105\nevents[i].length == 3\n1 <= startTimei <= endTimei <= 109\n1 <= valuei <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(events = [[1, 1000000000, 1000000], [1000000000, 1000000000, 1000000]]) == 1000000\n assert candidate(events = [[1, 10, 1], [2, 3, 2], [4, 5, 3], [6, 7, 4], [8, 9, 5]]) == 9\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]]) == 19\n assert candidate(events = [[10, 20, 15], [20, 30, 10], [1, 10, 5]]) == 15\n assert candidate(events = [[1, 10, 4], [1, 10, 5], [5, 10, 3]]) == 5\n assert candidate(events = [[1, 3, 2], [4, 5, 2], [2, 4, 3]]) == 4\n assert candidate(events = [[1, 3, 2], [4, 5, 2], [1, 5, 5]]) == 5\n assert candidate(events = [[1, 2, 4], [3, 4, 3], [2, 3, 1]]) == 7\n assert candidate(events = [[1, 5, 3], [1, 5, 1], [6, 6, 5]]) == 8\n assert candidate(events = [[1, 3, 5], [2, 5, 6], [4, 6, 7], [5, 7, 8]]) == 13\n assert candidate(events = [[1, 5, 10], [6, 10, 10], [11, 15, 10], [16, 20, 10]]) == 20\n assert candidate(events = [[2, 2, 1], [3, 3, 2], [4, 4, 3], [5, 5, 4], [6, 6, 5]]) == 9\n assert candidate(events = [[1, 10, 10], [2, 3, 5], [4, 5, 7], [6, 7, 9]]) == 16\n assert candidate(events = [[1, 2, 100], [3, 4, 200], [5, 6, 300], [7, 8, 400], [9, 10, 500], [11, 12, 600]]) == 1100\n assert candidate(events = [[1, 5, 1], [1, 4, 2], [2, 5, 3], [2, 4, 4], [3, 6, 5], [3, 5, 6], [4, 7, 7], [4, 6, 8], [5, 8, 9], [5, 7, 10]]) == 14\n assert candidate(events = [[1, 10, 5], [1, 10, 6], [1, 10, 7], [1, 10, 8], [1, 10, 9]]) == 9\n assert candidate(events = [[1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 2, 4], [1, 2, 5], [1, 2, 6], [1, 2, 7], [1, 2, 8], [1, 2, 9], [1, 2, 10], [1, 2, 11], [1, 2, 12], [1, 2, 13], [1, 2, 14], [1, 2, 15]]) == 15\n assert candidate(events = [[1, 3, 1], [2, 3, 2], [3, 3, 3], [4, 5, 4], [5, 5, 5], [6, 7, 6], [7, 7, 7]]) == 12\n assert candidate(events = [[1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5], [11, 20, 6], [12, 19, 7], [13, 18, 8], [14, 17, 9], [15, 16, 10]]) == 15\n assert candidate(events = [[1, 1000000, 1], [1000001, 2000000, 2], [2000001, 3000000, 3], [3000001, 4000000, 4], [4000001, 5000000, 5], [5000001, 6000000, 6], [6000001, 7000000, 7], [7000001, 8000000, 8], [8000001, 9000000, 9], [9000001, 10000000, 10]]) == 19\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7]]) == 13\n assert candidate(events = [[1, 5, 5], [6, 10, 10], [11, 15, 15], [16, 20, 20], [21, 25, 25]]) == 45\n assert candidate(events = [[1, 1000000000, 1000000], [2, 1000000000, 2000000], [3, 1000000000, 3000000], [4, 1000000000, 4000000], [5, 1000000000, 5000000]]) == 5000000\n assert candidate(events = [[1, 2, 100], [3, 4, 200], [5, 6, 300], [7, 8, 400], [9, 10, 500]]) == 900\n assert candidate(events = [[1, 5, 1], [6, 10, 2], [11, 15, 3], [16, 20, 4], [21, 25, 5], [26, 30, 6]]) == 11\n assert candidate(events = [[1, 2, 1000000], [2, 3, 900000], [3, 4, 800000], [4, 5, 700000], [5, 6, 600000], [6, 7, 500000], [7, 8, 400000], [8, 9, 300000], [9, 10, 200000], [10, 11, 100000]]) == 1800000\n assert candidate(events = [[1, 1000000000, 1], [2, 1000000000, 2], [3, 1000000000, 3], [4, 1000000000, 4], [5, 1000000000, 5]]) == 5\n assert candidate(events = [[1, 1000000000, 1], [1000000000, 1000000000, 1000000]]) == 1000000\n assert candidate(events = [[1, 5, 10], [2, 6, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50]]) == 50\n assert candidate(events = [[1, 100, 1], [101, 200, 2], [201, 300, 3], [301, 400, 4], [401, 500, 5], [501, 600, 6], [601, 700, 7], [701, 800, 8], [801, 900, 9], [901, 1000, 10]]) == 19\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500]]) == 800\n assert candidate(events = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40], [5, 5, 50], [6, 6, 60], [7, 7, 70], [8, 8, 80], [9, 9, 90], [10, 10, 100], [11, 11, 110], [12, 12, 120], [13, 13, 130], [14, 14, 140], [15, 15, 150]]) == 290\n assert candidate(events = [[1, 2, 1000000], [3, 4, 2000000], [5, 6, 3000000], [7, 8, 4000000], [9, 10, 5000000]]) == 9000000\n assert candidate(events = [[1, 1, 10], [2, 2, 9], [3, 3, 8], [4, 4, 7], [5, 5, 6], [6, 6, 5], [7, 7, 4], [8, 8, 3], [9, 9, 2], [10, 10, 1], [11, 11, 100], [12, 12, 99], [13, 13, 98], [14, 14, 97], [15, 15, 96]]) == 199\n assert candidate(events = [[1, 1, 1000000], [2, 2, 999999], [3, 3, 999998], [4, 4, 999997], [5, 5, 999996]]) == 1999999\n assert candidate(events = [[1, 1000000000, 1], [2, 999999999, 1000000], [3, 999999998, 2000000], [4, 999999997, 3000000]]) == 3000000\n assert candidate(events = [[1, 5, 100], [5, 10, 200], [10, 15, 300], [15, 20, 400], [20, 25, 500], [25, 30, 600], [30, 35, 700], [35, 40, 800], [40, 45, 900], [45, 50, 1000]]) == 1800\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120], [13, 14, 130], [14, 15, 140], [15, 16, 150]]) == 280\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7], [15, 16, 8], [17, 18, 9], [19, 20, 10], [21, 22, 11], [23, 24, 12], [25, 26, 13], [27, 28, 14], [29, 30, 15]]) == 29\n assert candidate(events = [[1, 2, 10], [3, 4, 20], [5, 6, 30], [7, 8, 40], [9, 10, 50], [11, 12, 60], [13, 14, 70], [15, 16, 80], [17, 18, 90], [19, 20, 100], [21, 22, 110], [23, 24, 120], [25, 26, 130], [27, 28, 140], [29, 30, 150]]) == 290\n assert candidate(events = [[1, 2, 1000000], [3, 4, 999999], [5, 6, 999998], [7, 8, 999997], [9, 10, 999996], [11, 12, 999995], [13, 14, 999994], [15, 16, 999993], [17, 18, 999992], [19, 20, 999991]]) == 1999999\n assert candidate(events = [[1, 5, 1000000], [1, 5, 900000], [1, 5, 800000], [1, 5, 700000], [1, 5, 600000], [1, 5, 500000], [1, 5, 400000], [1, 5, 300000], [1, 5, 200000], [1, 5, 100000]]) == 1000000\n assert candidate(events = [[1, 2, 10], [1, 2, 11], [1, 2, 12], [1, 2, 13], [1, 2, 14], [1, 2, 15]]) == 15\n assert candidate(events = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9], [1, 10, 10]]) == 10\n assert candidate(events = [[10, 20, 100], [20, 30, 200], [30, 40, 300], [40, 50, 400], [50, 60, 500], [60, 70, 600]]) == 1000\n assert candidate(events = [[1, 1, 100], [2, 2, 200], [3, 3, 300], [4, 4, 400], [5, 5, 500], [6, 6, 600], [7, 7, 700], [8, 8, 800], [9, 9, 900], [10, 10, 1000]]) == 1900\n assert candidate(events = [[1, 10, 1], [2, 11, 2], [3, 12, 3], [4, 13, 4], [5, 14, 5], [6, 15, 6], [7, 16, 7], [8, 17, 8], [9, 18, 9], [10, 19, 10]]) == 10\n assert candidate(events = [[1, 3, 100], [2, 5, 200], [3, 7, 300], [4, 10, 400], [5, 12, 500], [6, 15, 600], [7, 17, 700], [8, 18, 800], [9, 19, 900]]) == 1200\n assert candidate(events = [[1, 2, 10], [1, 3, 20], [1, 4, 30], [1, 5, 40], [1, 6, 50], [1, 7, 60], [1, 8, 70], [1, 9, 80], [1, 10, 90]]) == 90\n assert candidate(events = [[1, 5, 3], [1, 5, 1], [6, 6, 5], [7, 8, 4]]) == 9\n assert candidate(events = [[1, 1, 1], [2, 10, 2], [3, 9, 3], [4, 8, 4], [5, 7, 5], [6, 6, 6], [7, 5, 7], [8, 4, 8], [9, 3, 9], [10, 2, 10], [11, 1, 11]]) == 22\n assert candidate(events = [[1, 5, 1], [2, 6, 2], [3, 7, 3], [4, 8, 4], [5, 9, 5], [6, 10, 6], [7, 11, 7], [8, 12, 8], [9, 13, 9], [10, 14, 10]]) == 15\n assert candidate(events = [[1, 10, 1], [2, 20, 2], [3, 30, 3], [4, 40, 4], [5, 50, 5], [6, 60, 6], [7, 70, 7], [8, 80, 8], [9, 90, 9], [10, 100, 10]]) == 10\n assert candidate(events = [[1, 1000000000, 1000000], [2, 999999999, 2000000], [3, 999999998, 3000000], [4, 999999997, 4000000]]) == 4000000\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600], [61, 70, 700], [71, 80, 800], [81, 90, 900], [91, 100, 1000], [1, 50, 500000], [51, 100, 500000]]) == 1000000\n assert candidate(events = [[1, 3, 5], [3, 5, 5], [5, 7, 5], [7, 9, 5], [9, 11, 5]]) == 10\n assert candidate(events = [[1, 100, 1], [2, 99, 2], [3, 98, 3], [4, 97, 4], [5, 96, 5], [6, 95, 6], [7, 94, 7], [8, 93, 8], [9, 92, 9], [10, 91, 10]]) == 10\n assert candidate(events = [[1, 5, 10], [2, 6, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50], [6, 10, 60], [7, 11, 70], [8, 12, 80], [9, 13, 90], [10, 14, 100]]) == 150\n assert candidate(events = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1]]) == 2\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50]]) == 80\n assert candidate(events = [[1, 5, 10], [2, 5, 20], [3, 5, 30], [4, 5, 40], [5, 5, 50], [6, 10, 60], [7, 10, 70], [8, 10, 80], [9, 10, 90], [10, 10, 100]]) == 150\n assert candidate(events = [[1, 1, 1000000], [1000000000, 1000000000, 1], [500000000, 500000000, 2], [600000000, 600000000, 3], [700000000, 700000000, 4], [800000000, 800000000, 5]]) == 1000005\n assert candidate(events = [[1, 10, 5], [10, 20, 10], [20, 30, 15], [30, 40, 20], [40, 50, 25], [50, 60, 30], [60, 70, 35], [70, 80, 40], [80, 90, 45], [90, 100, 50]]) == 90\n assert candidate(events = [[1, 1, 1000000], [2, 2, 999999], [3, 3, 999998], [4, 4, 999997], [5, 5, 999996], [6, 6, 999995], [7, 7, 999994], [8, 8, 999993], [9, 9, 999992], [10, 10, 999991]]) == 1999999\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]]) == 28\n assert candidate(events = [[1, 5, 3], [2, 4, 5], [6, 8, 7], [9, 11, 10], [12, 15, 12], [16, 20, 15]]) == 27\n assert candidate(events = [[1, 10, 10], [2, 3, 20], [4, 5, 30], [6, 7, 40], [8, 9, 50], [11, 12, 60]]) == 110\n assert candidate(events = [[1, 10, 10], [11, 20, 20], [21, 30, 30], [31, 40, 40], [41, 50, 50], [51, 60, 60], [61, 70, 70], [71, 80, 80], [81, 90, 90], [91, 100, 100]]) == 190\n assert candidate(events = [[1, 3, 1], [4, 6, 2], [7, 9, 3], [10, 12, 4], [13, 15, 5], [16, 18, 6], [19, 21, 7], [22, 24, 8], [25, 27, 9], [28, 30, 10]]) == 19\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14]]) == 26\n assert candidate(events = [[1, 3, 3], [3, 5, 2], [5, 7, 1], [7, 9, 4], [9, 11, 5], [11, 13, 6]]) == 10\n assert candidate(events = [[1, 2, 5], [3, 4, 10], [5, 6, 15], [7, 8, 20], [9, 10, 25], [11, 12, 30], [13, 14, 35], [15, 16, 40]]) == 75\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7], [15, 16, 8], [17, 18, 9], [19, 20, 10]]) == 19\n assert candidate(events = [[1, 1000000000, 10], [2, 999999999, 20], [3, 999999998, 30], [4, 999999997, 40], [5, 999999996, 50], [6, 999999995, 60], [7, 999999994, 70], [8, 999999993, 80], [9, 999999992, 90], [10, 999999991, 100]]) == 100\n assert candidate(events = [[1, 1, 1000000], [2, 2, 1000000], [3, 3, 1000000], [4, 4, 1000000], [5, 5, 1000000], [6, 6, 1000000], [7, 7, 1000000], [8, 8, 1000000], [9, 9, 1000000], [10, 10, 1000000]]) == 2000000\n assert candidate(events = [[1, 1000000000, 1], [2, 1000000000, 2], [3, 1000000000, 3]]) == 3\n assert candidate(events = [[1, 10, 1], [10, 20, 2], [20, 30, 3], [30, 40, 4], [40, 50, 5], [50, 60, 6], [60, 70, 7], [70, 80, 8], [80, 90, 9], [90, 100, 10], [1, 100, 11], [2, 99, 12], [3, 98, 13], [4, 97, 14], [5, 96, 15]]) == 18\n assert candidate(events = [[1, 3, 2], [2, 4, 3], [3, 5, 4], [4, 6, 5], [5, 7, 6], [6, 8, 7], [7, 9, 8], [8, 10, 9], [9, 11, 10]]) == 17\n assert candidate(events = [[1, 1000000000, 1], [2, 1000000000, 2], [3, 1000000000, 3], [4, 1000000000, 4]]) == 4\n assert candidate(events = [[1, 3, 10], [2, 5, 8], [4, 6, 6], [7, 8, 5], [8, 10, 7], [9, 12, 4]]) == 17\n assert candidate(events = [[1, 1000000000, 1000000], [1000000001, 2000000000, 2000000], [2000000001, 3000000000, 3000000], [3000000001, 4000000000, 4000000], [4000000001, 5000000000, 5000000]]) == 9000000\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13], [14, 14, 14], [15, 15, 15]]) == 29\n assert candidate(events = [[1, 1000000000, 1], [1000000001, 2000000000, 2], [2000000001, 3000000000, 3], [3000000001, 4000000000, 4], [4000000001, 5000000000, 5], [5000000001, 6000000000, 6], [6000000001, 7000000000, 7], [7000000001, 8000000000, 8], [8000000001, 9000000000, 9], [9000000001, 10000000000, 10]]) == 19\n assert candidate(events = [[1, 2, 50], [3, 4, 60], [5, 6, 70], [7, 8, 80], [9, 10, 90], [11, 12, 100], [13, 14, 110], [15, 16, 120], [17, 18, 130], [19, 20, 140], [21, 22, 150], [23, 24, 160], [25, 26, 170], [27, 28, 180], [29, 30, 190]]) == 370\n assert candidate(events = [[1, 3, 10], [2, 4, 20], [3, 5, 30], [4, 6, 40], [5, 7, 50], [6, 8, 60], [7, 9, 70], [8, 10, 80]]) == 130\n assert candidate(events = [[1, 2, 100], [3, 5, 200], [6, 8, 300], [9, 10, 400], [11, 12, 500]]) == 900\n assert candidate(events = [[1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 2, 4], [1, 2, 5], [1, 2, 6], [1, 2, 7], [1, 2, 8], [1, 2, 9], [1, 2, 10]]) == 10\n assert candidate(events = [[1, 5, 5], [2, 6, 10], [3, 7, 15], [4, 8, 20], [5, 9, 25], [6, 10, 30], [7, 11, 35], [8, 12, 40], [9, 13, 45], [10, 14, 50]]) == 75\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8]]) == 14\n assert candidate(events = [[1, 3, 2], [1, 3, 3], [1, 3, 4], [1, 3, 5], [1, 3, 6], [1, 3, 7], [1, 3, 8], [1, 3, 9], [1, 3, 10], [1, 3, 11], [1, 3, 12], [1, 3, 13], [1, 3, 14], [1, 3, 15], [1, 3, 16]]) == 16\n assert candidate(events = [[1, 1000000000, 1000000], [2, 999999999, 999999], [3, 999999998, 999998]]) == 1000000\n assert candidate(events = [[1, 5, 10], [2, 6, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50], [6, 10, 60], [7, 11, 70], [8, 12, 80], [9, 13, 90], [10, 14, 100], [11, 15, 110], [12, 16, 120], [13, 17, 130], [14, 18, 140], [15, 19, 150]]) == 250\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600], [61, 70, 700], [71, 80, 800], [81, 90, 900], [91, 100, 1000]]) == 1900\n assert candidate(events = [[1, 1000000000, 1000000], [2, 3, 500000], [4, 5, 600000], [6, 7, 400000], [8, 9, 700000], [10, 1000000000, 800000]]) == 1500000\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12]]) == 22\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]]) == 18\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]) == 16\n"}, "metadata": {"canonical_parameter_names": ["events"], "leetcode_dataset_entry_point": "Solution().maxTwoEvents", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxTwoEvents(self, events: list[list[int]]) -> int:", "container": "Solution", "callable": "maxTwoEvents", "parameters": [{"name": "events", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2055, "task_id": "plates-between-candles", "difficulty": "Medium", "problem_description": "There is a long table with a line of plates and candles arranged on top of it. You are given a 0-indexed string s consisting of characters '*' and '|' only, where a '*' represents a plate and a '|' represents a candle.\nYou are also given a 0-indexed 2D integer array queries where queries[i] = [lefti, righti] denotes the substring s[lefti...righti] (inclusive). For each query, you need to find the number of plates between candles that are in the substring. A plate is considered between candles if there is at least one candle to its left and at least one candle to its right in the substring.\n\nFor example, s = \"||**||**|*\", and a query [3, 8] denotes the substring \"*||**|\". The number of plates between candles in this substring is 2, as each of the two plates has at least one candle in the substring to its left and right.\n\nReturn an integer array answer where answer[i] is the answer to the ith query.\n \nExample 1:\n\n\nInput: s = \"**|**|***|\", queries = [[2,5],[5,9]]\nOutput: [2,3]\nExplanation:\n- queries[0] has two plates between candles.\n- queries[1] has three plates between candles.\n\nExample 2:\n\n\nInput: s = \"***|**|*****|**||**|*\", queries = [[1,17],[4,5],[14,17],[5,11],[15,16]]\nOutput: [9,0,0,0,0]\nExplanation:\n- queries[0] has nine plates between candles.\n- The other queries have zero plates between candles.\n\n \nConstraints:\n\n3 <= s.length <= 105\ns consists of '*' and '|' characters.\n1 <= queries.length <= 105\nqueries[i].length == 2\n0 <= lefti <= righti < s.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"**|**|***|\",queries = [[2, 5], [5, 9]]) == [2, 3]\n assert candidate(s = \"***||***\",queries = [[0, 5], [2, 4]]) == [0, 0]\n assert candidate(s = \"*|*|*|*|*|*|*|\",queries = [[0, 7], [1, 6], [2, 5]]) == [3, 2, 1]\n assert candidate(s = \"|||***|||\",queries = [[0, 8], [1, 7], [2, 6]]) == [3, 3, 3]\n assert candidate(s = \"||*|*|*|*|*|*|\",queries = [[0, 10], [1, 9], [2, 8], [3, 7]]) == [4, 4, 2, 2]\n assert candidate(s = \"|||****|****|****||\",queries = [[0, 10], [5, 15], [1, 4]]) == [4, 4, 0]\n assert candidate(s = \"*|*|*|*|*|\",queries = [[0, 5], [1, 4]]) == [2, 1]\n assert candidate(s = \"|*|*|*|*|*|*|*|*|*|*|\",queries = [[0, 10], [1, 9], [2, 8], [3, 7]]) == [5, 3, 3, 1]\n assert candidate(s = \"|||*****|||\",queries = [[0, 2], [3, 8], [7, 10]]) == [0, 0, 0]\n assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|*|\",queries = [[0, 11], [1, 10], [2, 9], [3, 8]]) == [5, 4, 3, 2]\n assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|\",queries = [[0, 10], [1, 9], [2, 8], [3, 7]]) == [4, 4, 2, 2]\n assert candidate(s = \"***|**|*****|**||**|*\",queries = [[1, 17], [4, 5], [14, 17], [5, 11], [15, 16]]) == [9, 0, 0, 0, 0]\n assert candidate(s = \"***||****|**|\",queries = [[0, 4], [5, 8], [9, 11]]) == [0, 0, 0]\n"}, "metadata": {"canonical_parameter_names": ["s", "queries"], "leetcode_dataset_entry_point": "Solution().platesBetweenCandles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def platesBetweenCandles(self, s: str, queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "platesBetweenCandles", "parameters": [{"name": "s", "type": "str"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2056, "task_id": "number-of-valid-move-combinations-on-chessboard", "difficulty": "Hard", "problem_description": "There is an 8 x 8 chessboard containing n pieces (rooks, queens, or bishops). You are given a string array pieces of length n, where pieces[i] describes the type (rook, queen, or bishop) of the ith piece. In addition, you are given a 2D integer array positions also of length n, where positions[i] = [ri, ci] indicates that the ith piece is currently at the 1-based coordinate (ri, ci) on the chessboard.\nWhen making a move for a piece, you choose a destination square that the piece will travel toward and stop on.\n\nA rook can only travel horizontally or vertically from (r, c) to the direction of (r+1, c), (r-1, c), (r, c+1), or (r, c-1).\nA queen can only travel horizontally, vertically, or diagonally from (r, c) to the direction of (r+1, c), (r-1, c), (r, c+1), (r, c-1), (r+1, c+1), (r+1, c-1), (r-1, c+1), (r-1, c-1).\nA bishop can only travel diagonally from (r, c) to the direction of (r+1, c+1), (r+1, c-1), (r-1, c+1), (r-1, c-1).\n\nYou must make a move for every piece on the board simultaneously. A move combination consists of all the moves performed on all the given pieces. Every second, each piece will instantaneously travel one square towards their destination if they are not already at it. All pieces start traveling at the 0th second. A move combination is invalid if, at a given time, two or more pieces occupy the same square.\nReturn the number of valid move combinations​​​​​.\nNotes:\n\nNo two pieces will start in the same square.\nYou may choose the square a piece is already on as its destination.\nIf two pieces are directly adjacent to each other, it is valid for them to move past each other and swap positions in one second.\n\n \nExample 1:\n\n\nInput: pieces = [\"rook\"], positions = [[1,1]]\nOutput: 15\nExplanation: The image above shows the possible squares the piece can move to.\n\nExample 2:\n\n\nInput: pieces = [\"queen\"], positions = [[1,1]]\nOutput: 22\nExplanation: The image above shows the possible squares the piece can move to.\n\nExample 3:\n\n\nInput: pieces = [\"bishop\"], positions = [[4,3]]\nOutput: 12\nExplanation: The image above shows the possible squares the piece can move to.\n\n \nConstraints:\n\nn == pieces.length \nn == positions.length\n1 <= n <= 4\npieces only contains the strings \"rook\", \"queen\", and \"bishop\".\nThere will be at most one queen on the chessboard.\n1 <= ri, ci <= 8\nEach positions[i] is distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pieces = ['bishop'],positions = [[4, 3]]) == 12\n assert candidate(pieces = ['queen', 'rook'],positions = [[1, 1], [2, 2]]) == 309\n assert candidate(pieces = ['rook', 'rook'],positions = [[1, 1], [8, 8]]) == 223\n assert candidate(pieces = ['queen', 'rook'],positions = [[2, 2], [5, 5]]) == 340\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[1, 1], [5, 5], [8, 8]]) == 2907\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[1, 1], [2, 2], [3, 3]]) == 3289\n assert candidate(pieces = ['rook', 'rook'],positions = [[1, 1], [1, 3]]) == 189\n assert candidate(pieces = ['rook'],positions = [[1, 1]]) == 15\n assert candidate(pieces = ['rook', 'bishop'],positions = [[1, 1], [4, 3]]) == 173\n assert candidate(pieces = ['bishop', 'bishop'],positions = [[2, 2], [7, 7]]) == 80\n assert candidate(pieces = ['bishop', 'bishop'],positions = [[2, 2], [6, 6]]) == 84\n assert candidate(pieces = ['queen', 'bishop'],positions = [[1, 1], [4, 4]]) == 280\n assert candidate(pieces = ['bishop', 'rook', 'bishop'],positions = [[3, 4], [5, 5], [7, 6]]) == 1265\n assert candidate(pieces = ['queen'],positions = [[1, 1]]) == 22\n assert candidate(pieces = ['rook', 'bishop'],positions = [[1, 1], [4, 4]]) == 205\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[1, 1], [5, 5], [4, 3]]) == 4421\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[1, 1], [2, 2], [4, 3]]) == 3161\n assert candidate(pieces = ['rook', 'bishop', 'rook', 'bishop'],positions = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 16893\n assert candidate(pieces = ['queen', 'rook'],positions = [[1, 1], [8, 8]]) == 327\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[1, 1], [8, 8], [1, 8]]) == 4163\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[3, 3], [5, 5], [7, 2]]) == 3589\n assert candidate(pieces = ['queen', 'bishop', 'bishop'],positions = [[1, 1], [8, 8], [1, 8]]) == 1232\n assert candidate(pieces = ['queen', 'rook', 'bishop', 'rook'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 32176\n assert candidate(pieces = ['queen', 'rook', 'bishop', 'rook'],positions = [[1, 1], [8, 8], [3, 3], [6, 6]]) == 44166\n assert candidate(pieces = ['queen', 'queen'],positions = [[3, 3], [6, 6]]) == 638\n assert candidate(pieces = ['rook', 'rook', 'rook', 'rook'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 33009\n assert candidate(pieces = ['bishop', 'bishop', 'rook', 'rook'],positions = [[1, 1], [8, 8], [4, 4], [5, 5]]) == 7561\n assert candidate(pieces = ['queen', 'bishop', 'rook', 'bishop'],positions = [[1, 1], [8, 8], [4, 4], [4, 1]]) == 15440\n assert candidate(pieces = ['rook', 'rook', 'rook'],positions = [[1, 1], [1, 8], [8, 1]]) == 2753\n assert candidate(pieces = ['rook', 'queen', 'bishop', 'rook'],positions = [[1, 1], [8, 8], [4, 4], [2, 2]]) == 51937\n assert candidate(pieces = ['rook', 'queen', 'bishop', 'rook'],positions = [[1, 1], [5, 5], [8, 8], [8, 1]]) == 38251\n assert candidate(pieces = ['queen', 'rook', 'rook', 'bishop'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 29034\n assert candidate(pieces = ['queen', 'queen', 'rook'],positions = [[3, 3], [4, 4], [2, 2]]) == 8446\n assert candidate(pieces = ['queen', 'bishop', 'rook', 'rook'],positions = [[1, 1], [8, 8], [1, 8], [8, 1]]) == 29034\n assert candidate(pieces = ['queen', 'rook'],positions = [[4, 4], [7, 7]]) == 400\n assert candidate(pieces = ['rook', 'rook', 'bishop'],positions = [[1, 1], [8, 8], [4, 4]]) == 3034\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[2, 2], [7, 7], [3, 8]]) == 2590\n assert candidate(pieces = ['rook', 'rook'],positions = [[4, 4], [5, 5]]) == 193\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[1, 4], [4, 4], [7, 4]]) == 3784\n assert candidate(pieces = ['rook', 'bishop', 'queen'],positions = [[1, 1], [8, 8], [4, 4]]) == 2681\n assert candidate(pieces = ['bishop', 'bishop', 'bishop', 'bishop'],positions = [[2, 2], [2, 7], [7, 2], [7, 7]]) == 6400\n assert candidate(pieces = ['queen', 'bishop', 'rook'],positions = [[8, 1], [1, 8], [4, 4]]) == 2110\n assert candidate(pieces = ['queen', 'bishop', 'rook'],positions = [[2, 2], [3, 3], [5, 5]]) == 3484\n assert candidate(pieces = ['bishop', 'rook', 'queen', 'rook'],positions = [[3, 3], [4, 4], [5, 5], [6, 6]]) == 44433\n assert candidate(pieces = ['queen', 'bishop', 'bishop'],positions = [[1, 1], [3, 3], [6, 6]]) == 2162\n assert candidate(pieces = ['rook', 'queen', 'rook', 'bishop'],positions = [[1, 1], [5, 5], [8, 1], [1, 8]]) == 41166\n assert candidate(pieces = ['rook', 'rook', 'queen'],positions = [[1, 1], [1, 8], [8, 8]]) == 4163\n assert candidate(pieces = ['bishop', 'rook', 'queen'],positions = [[3, 3], [4, 3], [3, 4]]) == 3142\n assert candidate(pieces = ['rook', 'rook', 'bishop', 'bishop'],positions = [[1, 2], [1, 7], [2, 1], [2, 8]]) == 10952\n assert candidate(pieces = ['bishop', 'rook', 'rook', 'bishop'],positions = [[1, 2], [3, 3], [6, 7], [8, 6]]) == 10473\n assert candidate(pieces = ['rook', 'bishop', 'bishop', 'queen'],positions = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 26725\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[1, 1], [8, 8], [4, 4]]) == 4145\n assert candidate(pieces = ['bishop', 'rook', 'queen', 'rook'],positions = [[1, 8], [2, 2], [5, 5], [8, 1]]) == 42649\n assert candidate(pieces = ['queen', 'rook', 'bishop', 'rook'],positions = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 35461\n assert candidate(pieces = ['rook', 'rook', 'rook'],positions = [[1, 1], [2, 2], [3, 3]]) == 2709\n assert candidate(pieces = ['rook', 'bishop'],positions = [[2, 2], [3, 6]]) == 172\n assert candidate(pieces = ['queen', 'queen'],positions = [[1, 1], [8, 8]]) == 462\n assert candidate(pieces = ['rook', 'bishop'],positions = [[1, 1], [8, 1]]) == 118\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[1, 1], [2, 2], [3, 3]]) == 2842\n assert candidate(pieces = ['bishop', 'bishop', 'rook', 'rook'],positions = [[2, 2], [7, 7], [1, 1], [8, 8]]) == 13998\n assert candidate(pieces = ['queen', 'bishop', 'bishop', 'rook'],positions = [[4, 4], [3, 3], [6, 6], [1, 1]]) == 39585\n assert candidate(pieces = ['rook', 'rook', 'rook'],positions = [[1, 1], [8, 8], [4, 4]]) == 3079\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[1, 1], [4, 5], [8, 2]]) == 2308\n assert candidate(pieces = ['bishop', 'bishop'],positions = [[3, 3], [6, 6]]) == 124\n assert candidate(pieces = ['bishop', 'rook', 'rook'],positions = [[1, 1], [8, 1], [8, 8]]) == 1600\n assert candidate(pieces = ['rook', 'rook', 'bishop', 'queen'],positions = [[1, 1], [8, 8], [3, 3], [6, 6]]) == 56730\n assert candidate(pieces = ['rook', 'bishop', 'rook'],positions = [[2, 2], [3, 3], [4, 4]]) == 2185\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[1, 1], [5, 5], [5, 6]]) == 4182\n assert candidate(pieces = ['rook', 'rook', 'bishop', 'bishop'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 12485\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[4, 4], [1, 1], [8, 8]]) == 5890\n assert candidate(pieces = ['bishop', 'bishop', 'rook'],positions = [[2, 2], [7, 7], [1, 8]]) == 1112\n assert candidate(pieces = ['bishop', 'bishop', 'rook', 'rook'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 12485\n assert candidate(pieces = ['bishop', 'rook', 'rook', 'queen'],positions = [[4, 4], [1, 1], [1, 8], [8, 8]]) == 49107\n assert candidate(pieces = ['queen', 'rook', 'bishop', 'rook'],positions = [[3, 3], [5, 5], [2, 2], [6, 6]]) == 37434\n assert candidate(pieces = ['queen', 'bishop'],positions = [[2, 2], [7, 7]]) == 220\n assert candidate(pieces = ['queen', 'queen', 'queen'],positions = [[2, 2], [3, 3], [4, 4]]) == 13103\n assert candidate(pieces = ['queen', 'bishop'],positions = [[1, 1], [8, 8]]) == 156\n assert candidate(pieces = ['queen', 'queen'],positions = [[2, 2], [7, 7]]) == 548\n assert candidate(pieces = ['bishop', 'bishop', 'rook', 'rook'],positions = [[2, 2], [3, 3], [6, 6], [7, 7]]) == 18260\n assert candidate(pieces = ['rook', 'bishop', 'queen'],positions = [[3, 3], [6, 6], [5, 5]]) == 4230\n assert candidate(pieces = ['rook', 'bishop', 'rook', 'bishop'],positions = [[1, 1], [8, 8], [2, 2], [7, 7]]) == 10336\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[1, 1], [1, 8], [8, 1]]) == 4286\n assert candidate(pieces = ['queen', 'rook'],positions = [[4, 4], [8, 1]]) == 412\n assert candidate(pieces = ['rook', 'rook', 'rook', 'rook', 'bishop'],positions = [[1, 1], [1, 8], [8, 1], [8, 8], [4, 4]]) == 437408\n assert candidate(pieces = ['rook', 'rook', 'queen', 'bishop'],positions = [[1, 1], [8, 8], [4, 4], [5, 5]]) == 74604\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[5, 5], [1, 1], [8, 8]]) == 5890\n assert candidate(pieces = ['bishop', 'bishop', 'rook'],positions = [[2, 2], [7, 7], [4, 4]]) == 1150\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[4, 4], [1, 1], [8, 8]]) == 2681\n assert candidate(pieces = ['queen', 'bishop', 'rook'],positions = [[3, 3], [6, 6], [1, 1]]) == 4107\n assert candidate(pieces = ['queen', 'queen'],positions = [[1, 2], [8, 7]]) == 476\n assert candidate(pieces = ['queen', 'queen'],positions = [[2, 3], [3, 2]]) == 518\n assert candidate(pieces = ['bishop', 'bishop'],positions = [[1, 1], [8, 8]]) == 44\n assert candidate(pieces = ['bishop', 'bishop', 'bishop'],positions = [[2, 2], [5, 5], [8, 8]]) == 460\n assert candidate(pieces = ['rook', 'rook'],positions = [[1, 1], [1, 8]]) == 205\n assert candidate(pieces = ['rook', 'rook', 'bishop'],positions = [[1, 1], [8, 1], [4, 4]]) == 2764\n assert candidate(pieces = ['queen', 'queen', 'rook'],positions = [[1, 1], [8, 8], [4, 4]]) == 6380\n assert candidate(pieces = ['rook', 'queen', 'bishop', 'rook'],positions = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 41894\n assert candidate(pieces = ['queen', 'rook'],positions = [[1, 1], [8, 1]]) == 309\n assert candidate(pieces = ['bishop', 'bishop', 'bishop'],positions = [[2, 3], [4, 5], [6, 7]]) == 728\n assert candidate(pieces = ['bishop', 'bishop', 'bishop'],positions = [[2, 2], [4, 4], [6, 6]]) == 792\n"}, "metadata": {"canonical_parameter_names": ["pieces", "positions"], "leetcode_dataset_entry_point": "Solution().countCombinations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countCombinations(self, pieces: list[str], positions: list[list[int]]) -> int:", "container": "Solution", "callable": "countCombinations", "parameters": [{"name": "pieces", "type": "list[str]"}, {"name": "positions", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2057, "task_id": "smallest-index-with-equal-value", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums, return the smallest index i of nums such that i mod 10 == nums[i], or -1 if such index does not exist.\nx mod y denotes the remainder when x is divided by y.\n \nExample 1:\n\nInput: nums = [0,1,2]\nOutput: 0\nExplanation: \ni=0: 0 mod 10 = 0 == nums[0].\ni=1: 1 mod 10 = 1 == nums[1].\ni=2: 2 mod 10 = 2 == nums[2].\nAll indices have i mod 10 == nums[i], so we return the smallest index 0.\n\nExample 2:\n\nInput: nums = [4,3,2,1]\nOutput: 2\nExplanation: \ni=0: 0 mod 10 = 0 != nums[0].\ni=1: 1 mod 10 = 1 != nums[1].\ni=2: 2 mod 10 = 2 == nums[2].\ni=3: 3 mod 10 = 3 != nums[3].\n2 is the only index which has i mod 10 == nums[i].\n\nExample 3:\n\nInput: nums = [1,2,3,4,5,6,7,8,9,0]\nOutput: -1\nExplanation: No index satisfies i mod 10 == nums[i].\n\n \nConstraints:\n\n1 <= nums.length <= 100\n0 <= nums[i] <= 9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 5, 0, 5, 0, 5, 0, 5, 0, 5]) == 0\n assert candidate(nums = [4, 3, 2, 1]) == 2\n assert candidate(nums = [7, 8, 9, 0, 1, 2, 3, 4, 5, 6]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [0, 10, 20, 30, 40]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9]) == 9\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n assert candidate(nums = [3, 6, 9, 2, 5, 8, 1, 4, 7, 0]) == -1\n assert candidate(nums = [0, 10, 20, 30]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [3, 0, 1, 4, 2, 5, 9, 6, 7, 8]) == 5\n assert candidate(nums = [0, 1, 2]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == -1\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 4\n assert candidate(nums = [1, 10, 2, 20, 3, 30, 4, 40, 5, 50]) == 2\n assert candidate(nums = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5, 0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == 0\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7]) == 3\n assert candidate(nums = [0, 2, 4, 6, 8, 0, 2, 4, 6, 8]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9]) == 9\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == -1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 0\n assert candidate(nums = [4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 0]) == -1\n assert candidate(nums = [6, 3, 8, 6, 2, 9, 1, 3, 4, 7, 6, 3, 8, 6, 2, 9, 1, 3, 4, 7]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3]) == 1\n assert candidate(nums = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == -1\n assert candidate(nums = [1, 3, 5, 7, 9, 0, 2, 4, 6, 8, 1, 3, 5, 7, 9, 0, 2, 4, 6, 8, 1, 3, 5, 7, 9, 0, 2, 4, 6, 8]) == -1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == -1\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9]) == 4\n assert candidate(nums = [4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 9\n assert candidate(nums = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2]) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == -1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [10, 22, 33, 44, 55, 66, 77, 88, 99, 0]) == -1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 4\n assert candidate(nums = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [9, 0, 9, 0, 9, 0, 9, 0, 9, 0]) == -1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 3\n assert candidate(nums = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == -1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(nums = [1, 0, 9, 8, 7, 6, 5, 4, 3, 2]) == -1\n assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == -1\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [8, 6, 4, 2, 0, 9, 7, 5, 3, 1]) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [6, 3, 9, 2, 4, 1, 5, 8, 0, 7, 6, 3, 9, 2, 4, 1, 5, 8, 0, 7, 6, 3, 9, 2, 4, 1, 5, 8, 0, 7, 6, 3, 9, 2, 4, 1, 5, 8, 0, 7]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().smallestEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def smallestEqual(self, nums: list[int]) -> int:", "container": "Solution", "callable": "smallestEqual", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2058, "task_id": "find-the-minimum-and-maximum-number-of-nodes-between-critical-points", "difficulty": "Medium", "problem_description": "A critical point in a linked list is defined as either a local maxima or a local minima.\nA node is a local maxima if the current node has a value strictly greater than the previous node and the next node.\nA node is a local minima if the current node has a value strictly smaller than the previous node and the next node.\nNote that a node can only be a local maxima/minima if there exists both a previous node and a next node.\nGiven a linked list head, return an array of length 2 containing [minDistance, maxDistance] where minDistance is the minimum distance between any two distinct critical points and maxDistance is the maximum distance between any two distinct critical points. If there are fewer than two critical points, return [-1, -1].\n \nExample 1:\n\n\nInput: head = [3,1]\nOutput: [-1,-1]\nExplanation: There are no critical points in [3,1].\n\nExample 2:\n\n\nInput: head = [5,3,1,2,5,1,2]\nOutput: [1,3]\nExplanation: There are three critical points:\n- [5,3,1,2,5,1,2]: The third node is a local minima because 1 is less than 3 and 2.\n- [5,3,1,2,5,1,2]: The fifth node is a local maxima because 5 is greater than 2 and 1.\n- [5,3,1,2,5,1,2]: The sixth node is a local minima because 1 is less than 5 and 2.\nThe minimum distance is between the fifth and the sixth node. minDistance = 6 - 5 = 1.\nThe maximum distance is between the third and the sixth node. maxDistance = 6 - 3 = 3.\n\nExample 3:\n\n\nInput: head = [1,3,2,2,3,2,2,2,7]\nOutput: [3,3]\nExplanation: There are two critical points:\n- [1,3,2,2,3,2,2,2,7]: The second node is a local maxima because 3 is greater than 1 and 2.\n- [1,3,2,2,3,2,2,2,7]: The fifth node is a local maxima because 3 is greater than 2 and 2.\nBoth the minimum and maximum distances are between the second and the fifth node.\nThus, minDistance and maxDistance is 5 - 2 = 3.\nNote that the last node is not considered a local maxima because it does not have a next node.\n\n \nConstraints:\n\nThe number of nodes in the list is in the range [2, 105].\n1 <= Node.val <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 1, 2, 3, 4])) == [3, 3]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5])) == [1, 6]\n assert candidate(head = list_node([1, 3, 2, 2, 3, 2, 2, 2, 7])) == [3, 3]\n assert candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == [-1, -1]\n assert candidate(head = list_node([5, 4, 3, 2, 1])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 1])) == [-1, -1]\n assert candidate(head = list_node([5, 3, 1, 2, 5, 1, 2])) == [1, 3]\n assert candidate(head = list_node([1, 2, 3, 4, 5])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == [-1, -1]\n assert candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 2, 3, 2, 1])) == [2, 4]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 2, 3])) == [2, 2]\n assert candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [-1, -1]\n assert candidate(head = list_node([1, 1, 1, 1, 1])) == [-1, -1]\n assert candidate(head = list_node([2, 4, 1, 1, 3, 5, 6, 4, 2])) == [5, 5]\n assert candidate(head = list_node([2, 4, 1, 1, 3, 9, 8])) == [4, 4]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6])) == [1, 8]\n assert candidate(head = list_node([3, 1])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9])) == [8, 8]\n assert candidate(head = list_node([1, 2, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3])) == [3, 14]\n assert candidate(head = list_node([2, 4, 3, 5, 1, 3, 2, 4, 6, 7, 5, 6, 8, 7, 9, 8, 10])) == [1, 14]\n assert candidate(head = list_node([1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1])) == [3, 15]\n assert candidate(head = list_node([1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10])) == [1, 17]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3])) == [2, 24]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2])) == [2, 18]\n assert candidate(head = list_node([10, 20, 15, 25, 30, 20, 10, 5, 15, 25, 35, 40, 35, 30, 25, 20, 15, 10, 5])) == [1, 10]\n assert candidate(head = list_node([10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90])) == [1, 16]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == [1, 1]\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1])) == [3, 18]\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9])) == [-1, -1]\n assert candidate(head = list_node([5, 4, 3, 2, 1, 2, 3, 4, 5, 6])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 3, 2, 1, 2, 3, 4, 5, 3, 2, 1])) == [3, 7]\n assert candidate(head = list_node([1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18])) == [1, 16]\n assert candidate(head = list_node([1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10])) == [1, 16]\n assert candidate(head = list_node([1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 3, 1, 1, 3])) == [3, 15]\n assert candidate(head = list_node([5, 3, 1, 2, 5, 1, 2, 3, 4, 2, 1, 3, 5, 7, 6, 8])) == [1, 12]\n assert candidate(head = list_node([5, 10, 15, 20, 25, 30, 25, 20, 15, 10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50])) == [5, 5]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5])) == [1, 1]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10])) == [1, 16]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8])) == [1, 12]\n assert candidate(head = list_node([100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81])) == [-1, -1]\n assert candidate(head = list_node([1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4])) == [8, 8]\n assert candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == [-1, -1]\n assert candidate(head = list_node([3, 3, 3, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3, 1, 3, 3, 3])) == [5, 10]\n assert candidate(head = list_node([2, 4, 2, 6, 2, 8, 2, 10, 2, 12, 2, 14, 2, 16, 2])) == [1, 12]\n assert candidate(head = list_node([1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10])) == [1, 17]\n assert candidate(head = list_node([1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 6, 5, 7, 4, 8, 3, 9, 2, 10, 1])) == [1, 17]\n assert candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50])) == [-1, -1]\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5])) == [8, 8]\n assert candidate(head = list_node([1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1])) == [1, 16]\n assert candidate(head = list_node([5, 1, 2, 1, 5, 1, 2, 1, 5, 1, 2, 1, 5, 1, 2, 1, 5, 1, 2, 1])) == [1, 17]\n assert candidate(head = list_node([1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9])) == [1, 16]\n assert candidate(head = list_node([1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2])) == [1, 17]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5])) == [2, 10]\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1])) == [3, 18]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [1, 16]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1])) == [2, 24]\n assert candidate(head = list_node([2, 4, 6, 8, 10, 8, 6, 4, 2, 4, 6, 8, 10, 8, 6, 4, 2, 4, 6, 8, 10, 8, 6, 4, 2])) == [4, 16]\n assert candidate(head = list_node([5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1])) == [4, 12]\n assert candidate(head = list_node([1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1])) == [1, 42]\n assert candidate(head = list_node([100, 200, 300, 400, 500, 400, 300, 200, 100, 200, 300, 200, 100])) == [2, 6]\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1])) == [3, 12]\n assert candidate(head = list_node([1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1])) == [6, 12]\n assert candidate(head = list_node([1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1])) == [4, 8]\n assert candidate(head = list_node([1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 3, 1, 1])) == [3, 15]\n assert candidate(head = list_node([1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16])) == [1, 14]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1])) == [1, 9]\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1])) == [9, 9]\n assert candidate(head = list_node([1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1])) == [1, 18]\n assert candidate(head = list_node([9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [5, 5]\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6])) == [8, 8]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [-1, -1]\n assert candidate(head = list_node([1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 101, 102, 103, 104, 105])) == [-1, -1]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [1, 14]\n assert candidate(head = list_node([1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1])) == [6, 12]\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1])) == [2, 6]\n assert candidate(head = list_node([1, 3, 5, 4, 6, 7, 8, 6, 9])) == [1, 5]\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [9, 9]\n assert candidate(head = list_node([100, 90, 100, 80, 100, 70, 100, 60, 100, 50, 100])) == [1, 8]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5])) == [4, 12]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8])) == [1, 15]\n assert candidate(head = list_node([1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 7, 4, 8, 3, 9, 2, 10, 1])) == [1, 16]\n assert candidate(head = list_node([1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1])) == [-1, -1]\n assert candidate(head = list_node([5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5])) == [5, 10]\n assert candidate(head = list_node([10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10])) == [1, 14]\n assert candidate(head = list_node([100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200])) == [1, 9]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == [9, 9]\n assert candidate(head = list_node([5, 4, 3, 2, 1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [5, 5]\n assert candidate(head = list_node([5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5])) == [1, 16]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12])) == [1, 17]\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 2, 1])) == [2, 5]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1])) == [1, 24]\n assert candidate(head = list_node([100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2])) == [2, 16]\n assert candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == [-1, -1]\n assert candidate(head = list_node([10, 20, 30, 20, 10, 20, 30, 20, 10, 20, 30, 20, 10])) == [2, 8]\n assert candidate(head = list_node([10, 20, 30, 20, 10, 5, 15, 25, 35, 25, 15, 5, 10, 20, 30])) == [3, 9]\n assert candidate(head = list_node([5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5])) == [4, 8]\n assert candidate(head = list_node([1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2])) == [1, 17]\n assert candidate(head = list_node([1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4])) == [1, 25]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7])) == [1, 10]\n assert candidate(head = list_node([1, 3, 5, 7, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 8, 6, 4, 2])) == [4, 9]\n assert candidate(head = list_node([100000, 99999, 100001, 100002, 100000, 100003, 100001, 100004, 100002, 100005])) == [1, 7]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1])) == [1, 18]\n assert candidate(head = list_node([10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10])) == [-1, -1]\n assert candidate(head = list_node([5, 10, 5, 15, 5, 20, 5, 25, 5, 30, 5])) == [1, 8]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1])) == [4, 8]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1])) == [5, 15]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5])) == [1, 13]\n assert candidate(head = list_node([1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14])) == [1, 12]\n assert candidate(head = list_node([100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1])) == [3, 6]\n assert candidate(head = list_node([5, 4, 3, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9, 8, 9, 10])) == [1, 11]\n"}, "metadata": {"canonical_parameter_names": ["head"], "leetcode_dataset_entry_point": "Solution().nodesBetweenCriticalPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def nodesBetweenCriticalPoints(self, head: ListNode | None) -> list[int]:", "container": "Solution", "callable": "nodesBetweenCriticalPoints", "parameters": [{"name": "head", "type": "ListNode | None"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2059, "task_id": "minimum-operations-to-convert-number", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the number x:\nIf 0 <= x <= 1000, then for any index i in the array (0 <= i < nums.length), you can set x to any of the following:\n\nx + nums[i]\nx - nums[i]\nx ^ nums[i] (bitwise-XOR)\n\nNote that you can use each nums[i] any number of times in any order. Operations that set x to be out of the range 0 <= x <= 1000 are valid, but no more operations can be done afterward.\nReturn the minimum number of operations needed to convert x = start into goal, and -1 if it is not possible.\n \nExample 1:\n\nInput: nums = [2,4,12], start = 2, goal = 12\nOutput: 2\nExplanation: We can go from 2 → 14 → 12 with the following 2 operations.\n- 2 + 12 = 14\n- 14 - 2 = 12\n\nExample 2:\n\nInput: nums = [3,5,7], start = 0, goal = -4\nOutput: 2\nExplanation: We can go from 0 → 3 → -4 with the following 2 operations. \n- 0 + 3 = 3\n- 3 - 7 = -4\nNote that the last operation sets x out of the range 0 <= x <= 1000, which is valid.\n\nExample 3:\n\nInput: nums = [2,8,16], start = 0, goal = 1\nOutput: -1\nExplanation: There is no way to convert 0 into 1.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n-109 <= nums[i], goal <= 109\n0 <= start <= 1000\nstart != goal\nAll the integers in nums are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30],start = 100,goal = 50) == 2\n assert candidate(nums = [1, 2, 3],start = 5,goal = 5) == 2\n assert candidate(nums = [5, 15, 25],start = 10,goal = 30) == 2\n assert candidate(nums = [10, 20, 30],start = 100,goal = 300) == 7\n assert candidate(nums = [500, 500, 500],start = 1,goal = 1001) == 2\n assert candidate(nums = [1, 3, 5, 7, 9],start = 0,goal = 10) == 2\n assert candidate(nums = [1, 3, 5, 7, 9],start = 1000,goal = 0) == 112\n assert candidate(nums = [10, 20, 30, 40, 50],start = 100,goal = 0) == 2\n assert candidate(nums = [10, 20, 30],start = 100,goal = 200) == 4\n assert candidate(nums = [500, 501, 502],start = 500,goal = 505) == 4\n assert candidate(nums = [1000, -1000, 500],start = 0,goal = 1000) == 1\n assert candidate(nums = [-1000, 1000],start = 0,goal = 0) == 2\n assert candidate(nums = [7, 14, 28],start = 1,goal = 28) == 4\n assert candidate(nums = [100, 200, 300],start = 100,goal = 1000) == 3\n assert candidate(nums = [100, 200, 300],start = 500,goal = 1000) == 2\n assert candidate(nums = [1],start = 0,goal = 1000) == 1000\n assert candidate(nums = [500, 500],start = 500,goal = 1000) == 1\n assert candidate(nums = [7, 14, 21],start = 7,goal = 0) == 1\n assert candidate(nums = [1000],start = 1000,goal = 0) == 1\n assert candidate(nums = [2, 4, 12],start = 2,goal = 12) == 2\n assert candidate(nums = [1, 1000],start = 0,goal = 1001) == 2\n assert candidate(nums = [1, 3, 5, 7, 9],start = 500,goal = 500) == 2\n assert candidate(nums = [-1, -2, -3],start = 5,goal = -5) == 1\n assert candidate(nums = [100, 200, 300],start = 500,goal = 100) == 2\n assert candidate(nums = [1, 1000],start = 500,goal = 1500) == 1\n assert candidate(nums = [3, 5, 7],start = 0,goal = -4) == 2\n assert candidate(nums = [1, 2, 3],start = 1000,goal = 0) == 334\n assert candidate(nums = [500, 500, 500],start = 100,goal = 500) == -1\n assert candidate(nums = [10, 20, 30],start = 50,goal = 110) == 2\n assert candidate(nums = [2, 8, 16],start = 0,goal = 1) == -1\n assert candidate(nums = [1000, 500, 250],start = 1,goal = 1000) == -1\n assert candidate(nums = [1, 2, 3, 4, 5],start = 1,goal = 5) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],start = 5,goal = 0) == 1\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 50,goal = 1000) == 10\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],start = 1,goal = 1000) == 3\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],start = 1000,goal = 0) == 22\n assert candidate(nums = [128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],start = 500,goal = 1000) == -1\n assert candidate(nums = [256, 512, 768, 1024],start = 0,goal = 1024) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 500,goal = 1) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 10,goal = 1000) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],start = 1000,goal = 0) == 20\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],start = 500,goal = 1000) == 6\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113],start = 0,goal = 999) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 10,goal = 500) == 490\n assert candidate(nums = [13, 21, 34, 55, 89, 144, 233, 377, 610, 987],start = 500,goal = 1000) == 3\n assert candidate(nums = [256, 128, 64, 32, 16, 8, 4, 2, 1],start = 500,goal = 999) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],start = 1000,goal = 0) == 18\n assert candidate(nums = [999, 1, 2, 3, 4, 5],start = 0,goal = 999) == 1\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],start = 512,goal = 0) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 5,goal = 100) == 10\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],start = 50,goal = 999) == 10\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],start = 1,goal = 98) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 100,goal = 1000) == 48\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],start = 50,goal = 1000) == 106\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],start = 500,goal = 1000) == 17\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 100,goal = 256) == 3\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 25,goal = 1000) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],start = 1,goal = 999) == 36\n assert candidate(nums = [10, 20, 30, 40, 50],start = 500,goal = -100) == -1\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29],start = 1,goal = 999) == 36\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],start = 50,goal = 999) == 21\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 500,goal = 0) == 5\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31],start = 1,goal = 1000) == 33\n assert candidate(nums = [13, 19, 23, 29, 31, 37, 41, 43, 47, 53],start = 200,goal = 300) == 2\n assert candidate(nums = [1, 10, 100, 1000],start = 1,goal = 1000) == 2\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 500,goal = 0) == 3\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 100,goal = 1000) == 10\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41],start = 100,goal = 999) == 23\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],start = 10,goal = 1000) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 1,goal = 1000) == 5\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900],start = 0,goal = 1000) == 2\n assert candidate(nums = [333, 667, 999],start = 1,goal = 999) == 2\n assert candidate(nums = [999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008],start = 1,goal = 1000) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 0,goal = 1000) == 4\n assert candidate(nums = [64, 128, 256, 512],start = 100,goal = 1024) == -1\n assert candidate(nums = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144],start = 10,goal = 200) == 3\n assert candidate(nums = [123, 456, 789],start = 321,goal = 654) == 2\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 1000,goal = 0) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290],start = 50,goal = 1000) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 500,goal = 1000) == 500\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],start = 100,goal = 0) == 3\n assert candidate(nums = [999, 1000, 1001, 1002, 1003],start = 500,goal = 1500) == 1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],start = 100,goal = 200) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 0,goal = 500) == 5\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 500,goal = 1000) == 1\n assert candidate(nums = [100, 200, 300, 400, 500],start = 10,goal = 999) == -1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],start = 100,goal = 999) == 31\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 500,goal = 1000) == 500\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 1024,goal = 1) == 2\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110],start = 100,goal = 1000) == 9\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1000],start = 500,goal = 1500) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 100,goal = 2048) == -1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 100,goal = 511) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 100,goal = 99) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 50,goal = 1000) == 10\n assert candidate(nums = [123, 456, 789],start = 100,goal = 900) == 6\n assert candidate(nums = [29, 31, 37, 41, 43, 47, 53, 59, 61, 67],start = 5,goal = 1000) == 15\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 50,goal = 500) == 6\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],start = 1,goal = 1000000000) == 2\n assert candidate(nums = [333, 667, 999],start = 500,goal = 1000) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 500,goal = 400) == 6\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99],start = 500,goal = 200) == 4\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],start = 200,goal = 500) == 8\n assert candidate(nums = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26],start = 500,goal = 550) == 2\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],start = 1,goal = 1000) == 11\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 50,goal = 990) == 10\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 100,goal = -100) == -1\n assert candidate(nums = [13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],start = 500,goal = 999) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 0,goal = 500) == 10\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],start = 100,goal = 1000) == 10\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 50,goal = 999) == 11\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 500,goal = 1024) == 3\n assert candidate(nums = [100, 200, 300, 400, 500],start = 999,goal = 1) == -1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 512,goal = 1000) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 50,goal = 150) == 1\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],start = 50,goal = 987) == 3\n assert candidate(nums = [23, 45, 67, 89, 101],start = 100,goal = 1) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],start = 1,goal = 1000) == 200\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 500,goal = 1024) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 1,goal = 999) == 54\n assert candidate(nums = [100, 200, 300, 400, 500],start = 100,goal = 500) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 500,goal = 1005) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 1,goal = 1001) == 100\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],start = 1,goal = 999) == 1\n assert candidate(nums = [100, 200, 300, 400, 500],start = 50,goal = 500) == -1\n assert candidate(nums = [-1, 1, -2, 2, -4, 4, -8, 8, -16, 16],start = 500,goal = 1) == 33\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 1,goal = 1000) == 999\n assert candidate(nums = [666, 333, 111, 777, 888, 999, 222, 444, 555],start = 111,goal = 777) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 0,goal = 1000) == 1000\n assert candidate(nums = [-100, -50, -25, 0, 25, 50, 100],start = 50,goal = 250) == 2\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],start = 1,goal = 1000) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],start = 1000,goal = 1) == 50\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],start = 10,goal = 99) == 4\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 500,goal = 999) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums", "start", "goal"], "leetcode_dataset_entry_point": "Solution().minimumOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumOperations(self, nums: list[int], start: int, goal: int) -> int:", "container": "Solution", "callable": "minimumOperations", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "start", "type": "int"}, {"name": "goal", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2060, "task_id": "check-if-an-original-string-exists-given-two-encoded-strings", "difficulty": "Hard", "problem_description": "An original string, consisting of lowercase English letters, can be encoded by the following steps:\n\nArbitrarily split it into a sequence of some number of non-empty substrings.\nArbitrarily choose some elements (possibly none) of the sequence, and replace each with its length (as a numeric string).\nConcatenate the sequence as the encoded string.\n\nFor example, one way to encode an original string \"abcdefghijklmnop\" might be:\n\nSplit it as a sequence: [\"ab\", \"cdefghijklmn\", \"o\", \"p\"].\nChoose the second and third elements to be replaced by their lengths, respectively. The sequence becomes [\"ab\", \"12\", \"1\", \"p\"].\nConcatenate the elements of the sequence to get the encoded string: \"ab121p\".\n\nGiven two encoded strings s1 and s2, consisting of lowercase English letters and digits 1-9 (inclusive), return true if there exists an original string that could be encoded as both s1 and s2. Otherwise, return false.\nNote: The test cases are generated such that the number of consecutive digits in s1 and s2 does not exceed 3.\n \nExample 1:\n\nInput: s1 = \"internationalization\", s2 = \"i18n\"\nOutput: true\nExplanation: It is possible that \"internationalization\" was the original string.\n- \"internationalization\" \n -> Split: [\"internationalization\"]\n -> Do not replace any element\n -> Concatenate: \"internationalization\", which is s1.\n- \"internationalization\"\n -> Split: [\"i\", \"nternationalizatio\", \"n\"]\n -> Replace: [\"i\", \"18\", \"n\"]\n -> Concatenate: \"i18n\", which is s2\n\nExample 2:\n\nInput: s1 = \"l123e\", s2 = \"44\"\nOutput: true\nExplanation: It is possible that \"leetcode\" was the original string.\n- \"leetcode\" \n -> Split: [\"l\", \"e\", \"et\", \"cod\", \"e\"]\n -> Replace: [\"l\", \"1\", \"2\", \"3\", \"e\"]\n -> Concatenate: \"l123e\", which is s1.\n- \"leetcode\" \n -> Split: [\"leet\", \"code\"]\n -> Replace: [\"4\", \"4\"]\n -> Concatenate: \"44\", which is s2.\n\nExample 3:\n\nInput: s1 = \"a5b\", s2 = \"c5b\"\nOutput: false\nExplanation: It is impossible.\n- The original string encoded as s1 must start with the letter 'a'.\n- The original string encoded as s2 must start with the letter 'c'.\n\n \nConstraints:\n\n1 <= s1.length, s2.length <= 40\ns1 and s2 consist of digits 1-9 (inclusive), and lowercase English letters only.\nThe number of consecutive digits in s1 and s2 does not exceed 3.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"a1b\",s2 = \"a1b1\") == False\n assert candidate(s1 = \"ab123cd\",s2 = \"a3bcd\") == False\n assert candidate(s1 = \"ab123cd\",s2 = \"abc5\") == False\n assert candidate(s1 = \"123\",s2 = \"onetwothree\") == False\n assert candidate(s1 = \"1a\",s2 = \"a\") == False\n assert candidate(s1 = \"a9b\",s2 = \"a10b\") == False\n assert candidate(s1 = \"a1b1c1d1\",s2 = \"abcd\") == False\n assert candidate(s1 = \"a1a1a1\",s2 = \"a3a3\") == False\n assert candidate(s1 = \"a1b1\",s2 = \"ab\") == False\n assert candidate(s1 = \"a5b\",s2 = \"c5b\") == False\n assert candidate(s1 = \"abc\",s2 = \"3\") == True\n assert candidate(s1 = \"h3ll0\",s2 = \"hello\") == False\n assert candidate(s1 = \"123\",s2 = \"3\") == False\n assert candidate(s1 = \"a1b2c3\",s2 = \"a1b23c\") == True\n assert candidate(s1 = \"internationalization\",s2 = \"i18n\") == True\n assert candidate(s1 = \"a1b\",s2 = \"ab\") == False\n assert candidate(s1 = \"a1b2c3\",s2 = \"a1b5\") == False\n assert candidate(s1 = \"z1x2c3v\",s2 = \"zx9\") == False\n assert candidate(s1 = \"a1b2c3d4\",s2 = \"a1b2c34d\") == True\n assert candidate(s1 = \"1a1b1c\",s2 = \"3abc\") == False\n assert candidate(s1 = \"a\",s2 = \"1\") == True\n assert candidate(s1 = \"ab1\",s2 = \"a1b\") == True\n assert candidate(s1 = \"123\",s2 = \"321\") == True\n assert candidate(s1 = \"ab\",s2 = \"a2\") == False\n assert candidate(s1 = \"a2b\",s2 = \"aaab\") == True\n assert candidate(s1 = \"a1b1\",s2 = \"2\") == False\n assert candidate(s1 = \"a1b2c3\",s2 = \"abc6\") == False\n assert candidate(s1 = \"abc\",s2 = \"abc\") == True\n assert candidate(s1 = \"hello\",s2 = \"5\") == True\n assert candidate(s1 = \"l123e\",s2 = \"44\") == True\n assert candidate(s1 = \"123abc\",s2 = \"3abc\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z26\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == False\n assert candidate(s1 = \"a5b5c5\",s2 = \"abc15\") == True\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s1 = \"a2b2c2\",s2 = \"aabbcc\") == False\n assert candidate(s1 = \"abc12def45\",s2 = \"abcdef123\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i\",s2 = \"abcdefghi\") == False\n assert candidate(s1 = \"x9y8z7\",s2 = \"xyz321\") == True\n assert candidate(s1 = \"a1b2c3\",s2 = \"abc123\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\",s2 = \"10abcdefghijklmnopqrstuvwxyz10abcdefghijklmnopqrstuvwxyz10\") == False\n assert candidate(s1 = \"123abc456\",s2 = \"9abc10\") == False\n assert candidate(s1 = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z2\",s2 = \"abcdefghij10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\") == False\n assert candidate(s1 = \"123456\",s2 = \"654321\") == True\n assert candidate(s1 = \"abcdefghij123456789012\",s2 = \"abcdefghij123456789012\") == True\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz2\") == False\n assert candidate(s1 = \"1a2b3c4d\",s2 = \"aabbcccdddd\") == False\n assert candidate(s1 = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"1abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"abcdefghijklmnopqrstuvwxyza1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\") == False\n assert candidate(s1 = \"abc12def45\",s2 = \"abcdef19\") == False\n assert candidate(s1 = \"abc1def2ghi3\",s2 = \"a1b1c1d1e1f1g1h1i1\") == False\n assert candidate(s1 = \"a1b1c1\",s2 = \"abc1\") == False\n assert candidate(s1 = \"1a2b3c4d\",s2 = \"1234abcd\") == True\n assert candidate(s1 = \"11a2b\",s2 = \"aaaaaaaaaab\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j0\",s2 = \"abcdefghij10\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyz1\") == False\n assert candidate(s1 = \"abcdefghij123456789\",s2 = \"abcdefghij1234567891\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == True\n assert candidate(s1 = \"a5b5c5d5e5\",s2 = \"abcde25\") == True\n assert candidate(s1 = \"a2b3c4d5e6f7g8h9i10\",s2 = \"abcdefghi10\") == False\n assert candidate(s1 = \"abcdefghij1234567890\",s2 = \"abcdefghij123456789\") == True\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i10j11k12l13m14n15o16p17q18r19s20t21u22v23w24x25y26z27\",s2 = \"abcdefghijklmnopqrstuvwxyza27\") == False\n assert candidate(s1 = \"abc123def\",s2 = \"abc12def3\") == True\n assert candidate(s1 = \"a12b34c56\",s2 = \"a12b34c56\") == True\n assert candidate(s1 = \"l10n\",s2 = \"leetcode\") == False\n assert candidate(s1 = \"1a2b3c4d5e\",s2 = \"a1b2c3d4e5\") == True\n assert candidate(s1 = \"123abc\",s2 = \"321cba\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i10j\",s2 = \"abcdefghij1\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyz26\") == False\n assert candidate(s1 = \"a4b2c3\",s2 = \"aaaaabbbccc\") == False\n assert candidate(s1 = \"a3b\",s2 = \"aaab\") == False\n assert candidate(s1 = \"a2b3c4\",s2 = \"aaabbbcccc\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\",s2 = \"abcdefghijklmnopqrstuvwxyz123456\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"z1y1x1w1v1u1t1s1r1q1p1o1n1m1l1k1j1i1h1g1f1e1d1c1b1a1\") == False\n assert candidate(s1 = \"a2b3c\",s2 = \"aabbccc\") == False\n assert candidate(s1 = \"abc123def456ghi789\",s2 = \"abcdef789ghi123456\") == True\n assert candidate(s1 = \"a2b3c4\",s2 = \"a9\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\",s2 = \"abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890\") == False\n assert candidate(s1 = \"abc123def\",s2 = \"abcdef123\") == True\n assert candidate(s1 = \"123abc\",s2 = \"12abc3\") == True\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26a1b2\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z127a1b2\") == False\n assert candidate(s1 = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyz1\") == False\n assert candidate(s1 = \"111abc222def333\",s2 = \"333abc222def111\") == True\n assert candidate(s1 = \"abcdefghij1234567891\",s2 = \"abcdefghij123456789\") == False\n assert candidate(s1 = \"12abc\",s2 = \"a1b2c\") == True\n assert candidate(s1 = \"x1y2z3\",s2 = \"xyz123\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26a27b28c29d30\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z126a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z126a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z126a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z126\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\") == True\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyza1\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s1 = \"11abc\",s2 = \"abcdefghij1\") == False\n assert candidate(s1 = \"a5b5c5\",s2 = \"aaaaabbbbbccccc\") == False\n assert candidate(s1 = \"a5b3c2d\",s2 = \"abc10d\") == True\n assert candidate(s1 = \"9z\",s2 = \"zzzzzzzzz\") == False\n assert candidate(s1 = \"a1b2c3d4e5\",s2 = \"a1b2c3d4e5\") == True\n assert candidate(s1 = \"a1b1c1\",s2 = \"a1b1c1d0\") == False\n assert candidate(s1 = \"a12b\",s2 = \"aaaaaaaaaaaaab\") == True\n assert candidate(s1 = \"abcde123fghi\",s2 = \"abcdefghi123\") == True\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i1j2k3l4m5n6o7p8q9r1s2t3u4v5w6x7y8z9\",s2 = \"1abcdefghijklmnopqrstuvwxyza2b3c4d5e6f7g8h9i1j2k3l4m5n6o7p8q9r1s2t3u4v5w6x7y8z9\") == False\n assert candidate(s1 = \"abc123def456\",s2 = \"abcdef123456\") == True\n assert candidate(s1 = \"123abc123\",s2 = \"321cba321\") == True\n assert candidate(s1 = \"abcdefghij10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == False\n assert candidate(s1 = \"abcdefghij1234567891\",s2 = \"abcdefghij1234567891\") == True\n assert candidate(s1 = \"a2b3c4\",s2 = \"ab2c3d4\") == False\n assert candidate(s1 = \"123abc\",s2 = \"15c\") == False\n assert candidate(s1 = \"abc12def\",s2 = \"a15f\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26a28b29c30d31e32f33g34h35i36j37k38l39m40\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z126a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z126\") == False\n assert candidate(s1 = \"l123e\",s2 = \"leetcode\") == True\n assert candidate(s1 = \"a2b3c4d5e6f7g8h9i10j11k12l13m14n15o16p17q18r19s20t21u22v23w24x25y26z27a28b29c30d31e32f33g34h35i36j37k38l39m40\",s2 = \"abcdefghijklmnopqrstuvwxyz12345678910111213141516171819202122232425262728293031323334353637383940\") == False\n assert candidate(s1 = \"abc12def\",s2 = \"abcdefghijkl\") == False\n assert candidate(s1 = \"1234\",s2 = \"1234\") == True\n assert candidate(s1 = \"abc12\",s2 = \"ab11c\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i10j\",s2 = \"abcdefghij10\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10\",s2 = \"abcdefghij10\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"abcdefghijklmnopqrstuvwxyz1234567891011121314151617181920212223242526\") == False\n assert candidate(s1 = \"12ab3c\",s2 = \"a1b2c3\") == True\n assert candidate(s1 = \"abc1def2ghi3jkl4mno5pqr6stu7vwx8yz9\",s2 = \"a1b2c3d4e5f6g7h8i9jklmnopqrstuvwxyz\") == False\n assert candidate(s1 = \"a1b2c3d4\",s2 = \"a111b1111c11111d111111\") == False\n assert candidate(s1 = \"a9b8c7d6e5f4g3h2i1\",s2 = \"abcdefghi123456789\") == True\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"abcdefghijklmnopqrstuvwxyz1234567891011121314151617181920212223242526abcdefghijklmnopqrstuvwxyz1234567891011121314151617181920212223242526\") == False\n assert candidate(s1 = \"abcdefghij123456789\",s2 = \"abcdefghij1234567890\") == True\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1\",s2 = \"abcdefghij\") == False\n assert candidate(s1 = \"abcde1234567890\",s2 = \"0987654321edcba\") == True\n assert candidate(s1 = \"9a8b7c6d5e4f3g2h1i0j9k8l7m6n5o4p3q2r1s0t9u8v7w6x5y4z3\",s2 = \"zyxwvutsrqponmlkjihgfedcba34567890123\") == False\n assert candidate(s1 = \"1a1b1c\",s2 = \"abc1\") == False\n assert candidate(s1 = \"abc123def456ghi789jkl012mno345pqr678stu901vwx234yz567\",s2 = \"abcdefghijklmnopqrstu901vwx234yz567jkl012mno345pqr678ghi789def456abc123\") == True\n assert candidate(s1 = \"abcd1234\",s2 = \"a3b2cd4\") == False\n assert candidate(s1 = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z2\",s2 = \"abcdefghijklnmopqrstuvwxyz22\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z2\") == False\n assert candidate(s1 = \"ab1cd2ef3\",s2 = \"a1b1c1d1e1f1\") == False\n assert candidate(s1 = \"l10n\",s2 = \"leet1c2d\") == False\n assert candidate(s1 = \"1a2b3c4d5e\",s2 = \"11111\") == False\n assert candidate(s1 = \"123456789\",s2 = \"abcdefghi9\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i10\",s2 = \"abcdefghij10\") == False\n assert candidate(s1 = \"a9b\",s2 = \"aaaaaaaaaab\") == True\n assert candidate(s1 = \"l10e\",s2 = \"leetcode\") == False\n assert candidate(s1 = \"12ab34cd56\",s2 = \"15abcd\") == False\n assert candidate(s1 = \"123abc\",s2 = \"abc123\") == True\n assert candidate(s1 = \"abcdefghij12345678901234\",s2 = \"abcdefghij12345678901234\") == True\n assert candidate(s1 = \"leetcode\",s2 = \"l2e8\") == False\n assert candidate(s1 = \"a1b2c3\",s2 = \"a12b3c\") == True\n assert candidate(s1 = \"1a2b3c\",s2 = \"6\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i10j11k12\",s2 = \"abcdefghijk11lm12\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z11a2b3c4d5e6f7g8h9i10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\") == False\n assert candidate(s1 = \"123abc456def789ghi101112\",s2 = \"123abc456def789ghi101112\") == True\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"1abcdefghijklmnopqrstuvwxyza2b3c4d5e6f7g8h9i10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\") == False\n assert candidate(s1 = \"123abc456\",s2 = \"9abc101\") == False\n assert candidate(s1 = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z2\",s2 = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z2\") == True\n assert candidate(s1 = \"1a2a3a4a5a6a7a8a9a\",s2 = \"aaaaaaaaaab\") == False\n assert candidate(s1 = \"abcdefghij123456789\",s2 = \"abcdefghij123456789\") == True\n assert candidate(s1 = \"a1b2c3d4\",s2 = \"abcd\") == False\n assert candidate(s1 = \"a9b9c\",s2 = \"abcdefghiabcdefghi\") == False\n assert candidate(s1 = \"abc123\",s2 = \"a1b1c123\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"z25y24x23w22v21u20t19s18r17q16p15o14n13m12l11k10j9i8h7g6f5e4d3c2b1a1\") == False\n assert candidate(s1 = \"abcdefghij123456789\",s2 = \"abcdefghij12345678\") == True\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9\",s2 = \"abcdefghi\") == False\n assert candidate(s1 = \"abc11\",s2 = \"abcdefghij1\") == False\n assert candidate(s1 = \"abcdefghij1234567890123\",s2 = \"abcdefghij1234567890123\") == True\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\",s2 = \"abcdefghijklmnopqrst1020\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1\",s2 = \"abcdefghi1\") == False\n assert candidate(s1 = \"a5b2c3\",s2 = \"aaaaaaaaabbccc\") == False\n assert candidate(s1 = \"a5b5c5d5\",s2 = \"10abcde5\") == False\n assert candidate(s1 = \"abcde123\",s2 = \"a4bcd3\") == True\n assert candidate(s1 = \"abcdefghij10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"abcdefghijklmnopqrstuvwxyz1234567891011121314151617181920212223242526\") == False\n assert candidate(s1 = \"abc123\",s2 = \"123abc\") == True\n assert candidate(s1 = \"a12b3c4\",s2 = \"a1b22c4\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz2\") == False\n assert candidate(s1 = \"a9b9c9d9e9f9g9h9i9j9k9l9m9n9o9p9q9r9s9t9u9v9w9x9y9z9\",s2 = \"aaaaaaaaabbbbbbbbcccccccccddddddddddeeeeeeeeeffffffffggggggggghhhhhhhhiiiiiiiiiijjjjjjjjjkkkkkkkkklllllllllmmmmmmmmmnnnnnnnnnoooooooooopppppppppqqqqqqqqqrrrrrrrrrssssssssstttttttttuuuuuuuuuvvvvvvvvvwwwwwwwwwxxxxxxxxxyyyyyyyyyzzzzzzzzz\") == False\n assert candidate(s1 = \"1a2b3c\",s2 = \"a1b2c3\") == True\n assert candidate(s1 = \"abc123def\",s2 = \"a1b1c3d4e5f6\") == False\n assert candidate(s1 = \"a2b3c4d5e6f7g8h9i10j11k12l13m14n15o16p17q18r19s20t21u22v23w24x25y26z27\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z127\") == False\n assert candidate(s1 = \"9a9b9c9d\",s2 = \"81abcd\") == False\n assert candidate(s1 = \"x9y9z9\",s2 = \"xxxxxxxxxxxyyyyyyyyzzzzzzzzz\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15\",s2 = \"abcdefghijklmnop123456789101112131415\") == False\n assert candidate(s1 = \"abc1def2ghi3\",s2 = \"abcdefghi\") == False\n assert candidate(s1 = \"a9b9c9\",s2 = \"aaaaaaaaabbbbbbbbcccccccccc\") == False\n assert candidate(s1 = \"abc123\",s2 = \"a1b2c3123\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"1abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s1 = \"a1b1c\",s2 = \"abc\") == False\n assert candidate(s1 = \"abcdefghij10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z126\") == False\n assert candidate(s1 = \"a1b2c3d4\",s2 = \"abcd10\") == False\n assert candidate(s1 = \"a2b3c4d5e6f7g8h9i10j11\",s2 = \"abcdefghij10jk11\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz12345678910111213141516171819202122232425261234567891011121314151617181920212223242526\") == False\n assert candidate(s1 = \"abcdefghij12345678901\",s2 = \"abcdefghij12345678901\") == True\n assert candidate(s1 = \"a1b2c3d4e5\",s2 = \"15\") == False\n assert candidate(s1 = \"1a2b3c\",s2 = \"abc123\") == False\n assert candidate(s1 = \"ab3c\",s2 = \"abc3\") == True\n assert candidate(s1 = \"abcde12345\",s2 = \"abcde54321\") == True\n assert candidate(s1 = \"abc1def2ghi3\",s2 = \"abcdefg1h1i\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11\",s2 = \"abcdefghijk11\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11\",s2 = \"abcdefghijk123\") == False\n assert candidate(s1 = \"abcdefghij1234567890\",s2 = \"abcdefghij1234567890\") == True\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyz123\") == False\n assert candidate(s1 = \"a10b\",s2 = \"aaaaaaaaaab\") == False\n"}, "metadata": {"canonical_parameter_names": ["s1", "s2"], "leetcode_dataset_entry_point": "Solution().possiblyEquals", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def possiblyEquals(self, s1: str, s2: str) -> bool:", "container": "Solution", "callable": "possiblyEquals", "parameters": [{"name": "s1", "type": "str"}, {"name": "s2", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2062, "task_id": "count-vowel-substrings-of-a-string", "difficulty": "Easy", "problem_description": "A substring is a contiguous (non-empty) sequence of characters within a string.\nA vowel substring is a substring that only consists of vowels ('a', 'e', 'i', 'o', and 'u') and has all five vowels present in it.\nGiven a string word, return the number of vowel substrings in word.\n \nExample 1:\n\nInput: word = \"aeiouu\"\nOutput: 2\nExplanation: The vowel substrings of word are as follows (underlined):\n- \"aeiouu\"\n- \"aeiouu\"\n\nExample 2:\n\nInput: word = \"unicornarihan\"\nOutput: 0\nExplanation: Not all 5 vowels are present, so there are no vowel substrings.\n\nExample 3:\n\nInput: word = \"cuaieuouac\"\nOutput: 7\nExplanation: The vowel substrings of word are as follows (underlined):\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n\n \nConstraints:\n\n1 <= word.length <= 100\nword consists of lowercase English letters only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aeiou\") == 1\n assert candidate(word = \"aeiofvuaeiou\") == 3\n assert candidate(word = \"uoiea\") == 1\n assert candidate(word = \"aeiouxaeeiaouoieua\") == 28\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiu\") == 175\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuoo\") == 55\n assert candidate(word = \"aeiouaeiouaeiou\") == 66\n assert candidate(word = \"unicornarihan\") == 0\n assert candidate(word = \"aaaaaeeeeeeiiiiioooooouuuuu\") == 25\n assert candidate(word = \"aeiouu\") == 2\n assert candidate(word = \"a\") == 0\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(word = \"vowelsaeiou\") == 1\n assert candidate(word = \"cuaieuouac\") == 7\n assert candidate(word = \"aeiooauuieoiau\") == 41\n assert candidate(word = \"bcdfeioau\") == 1\n assert candidate(word = \"zzzzzaeiouzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiou\") == 43\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 496\n assert candidate(word = \"aeiouxyzaeiouaeiou\") == 22\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 1326\n assert candidate(word = \"aeiouxyzaeiou\") == 2\n assert candidate(word = \"xyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 63\n assert candidate(word = \"aeiouuuueeiooiaaaeeoioioiaaaeeuuuiooiiuaeiouaeiouaeiouaeiouaeiou\") == 1565\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiou\") == 231\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiou\") == 63\n assert candidate(word = \"uoieaueoiaueoiaueoiaueoi\") == 208\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 666\n assert candidate(word = \"aeioubcdfghjklmnpqrstvwxyzaeiou\") == 2\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 63\n assert candidate(word = \"aeioubaeioucaeioudeaeioufaeioubaeioucaeioudeaeioufaeioubaeioucaeioudeaeiouf\") == 15\n assert candidate(word = \"bcdaeioufghijklmnopqrstuvwxyz\") == 1\n assert candidate(word = \"aeiouwxyzaeiouwxyzaeiouwxyzaeiouwxyz\") == 4\n assert candidate(word = \"xayaioeoiuaueoieoiauiouio\") == 139\n assert candidate(word = \"aeioubaeiouaeioubaeiouxyzaeiouaeiouaeioubaeiou\") == 90\n assert candidate(word = \"aeioubaeioucaeiou\") == 3\n assert candidate(word = \"bcaeiouaeiouaieouacb\") == 77\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyz\") == 42\n assert candidate(word = \"aieouaeiouaieouaeiouaieouaeiouaieou\") == 490\n assert candidate(word = \"aeiouuueeiooiaaaeeoioioiaaaeeuuuiooiiu\") == 348\n assert candidate(word = \"aeioubaeiouaeioucaeiou\") == 23\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouzzzzzzzzz\") == 231\n assert candidate(word = \"aeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyz\") == 8\n assert candidate(word = \"aeiouxyzzyxwvutsrqponmlkjihgfedcbaeiouaeiou\") == 22\n assert candidate(word = \"aeiouxyaeiouaeiou\") == 22\n assert candidate(word = \"aeeeeiiiioouuuaeiouaaaeioueee\") == 247\n assert candidate(word = \"aeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyz\") == 5\n assert candidate(word = \"aeioucaeioubaeiouaeiou\") == 23\n assert candidate(word = \"aeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiou\") == 5\n assert candidate(word = \"xyzaeiouaeiouxyzaeiouaeiouxyz\") == 42\n assert candidate(word = \"mnopqrstuvwxyaeiouaeiouxyzaeiouxyzzyxwvutsrqponmlkjihgfedcbaeiou\") == 23\n assert candidate(word = \"bcaeiouc\") == 1\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 4656\n assert candidate(word = \"aeioueoiuaeiouaeioua\") == 125\n assert candidate(word = \"aabbccddeeeffgghhiijjkkllmmnnooouuupppqqrrsstttuuuvvvwwxxyyzz\") == 0\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 1081\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 105\n assert candidate(word = \"aeiouaeiouxxxaeiouaeiou\") == 42\n assert candidate(word = \"aebcioudfeiauoceioua\") == 2\n assert candidate(word = \"aouieaeioueaouieaeiou\") == 139\n assert candidate(word = \"aeiouaeiouabcdeiouaeiouabcdeiouaeiou\") == 64\n assert candidate(word = \"zzzzzvvvvvaeeeiioouuuaeiou\") == 44\n assert candidate(word = \"uoieaueoiaueoiaueoiaueoiaeiou\") == 317\n assert candidate(word = \"bcdfeaioueaiouaeioueaioueaiou\") == 229\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 1596\n assert candidate(word = \"ueaiaoueoiuaeiouaeiouaeiou\") == 245\n assert candidate(word = \"aeiaeiouoieiouaeiou\") == 93\n assert candidate(word = \"aeioubaeioucaeioudaeioufaeioubaeioucaeioudaeioufaeioubaeioucaeioudaeioufxyzaeioubaeioucaeioudaeioufaeioubaeioucaeioudaeiouf\") == 20\n assert candidate(word = \"uoieaueoiaueoiaueoiaueoiaeiouaeiouaeiouaeiouaeiou\") == 1027\n assert candidate(word = \"aeiooouiaeiouaeiou\") == 92\n assert candidate(word = \"aeioubaeiouaeioubaeiouxyzaeiouaeiouaeioubaeiouxyzaeiouaeioubaeiou\") == 112\n assert candidate(word = \"aabbccddeeffggahhiiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(word = \"xyzaeiouaeiouxyz\") == 21\n assert candidate(word = \"aeioueoiuaeiouaeioueoiuaeiouaeioueoiu\") == 529\n assert candidate(word = \"zzzzzaeiouzzzzzzzzzz\") == 1\n assert candidate(word = \"zbcdefghijklmnopqrstuvwxyaeiou\") == 1\n assert candidate(word = \"bcdfgohueaioeuncdfeoiu\") == 5\n assert candidate(word = \"aeioubaeioucaeioudaeioubaeioucaeioudaeioubaeioucaeiou\") == 9\n assert candidate(word = \"xaaaeeeiiiiooooouuuuuaaaeiiiou\") == 131\n assert candidate(word = \"eiaouoieaueioaeioaeiaoueioea\") == 253\n assert candidate(word = \"aeiouaeiouaeiouxyzaeiouaeiouaeiouxyzaeiouaeiou\") == 153\n assert candidate(word = \"aeiouxyzaeiouxyzaeiouxyz\") == 3\n assert candidate(word = \"mnopqrstuvwxyaeiouaeiouxyz\") == 21\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 84\n assert candidate(word = \"xyzaeiouaeiouaeiouaeiouaeiouaeiouxyz\") == 351\n assert candidate(word = \"baeiouaeiouaeiouaeiouaeiou\") == 231\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(word = \"aeioubaeioucaeioudeaeiouf\") == 5\n assert candidate(word = \"oiueaeiouaeiouaeiouaeiouaeiouaeiou\") == 461\n assert candidate(word = \"aeioubaeiouaeiouaeiouaeiou\") == 137\n assert candidate(word = \"zzzzzaeiouzzzzz\") == 1\n assert candidate(word = \"baeioucaeiouaeioucb\") == 22\n assert candidate(word = \"eiouaeioua\") == 21\n assert candidate(word = \"aeioubaeiouaeioubaeiou\") == 23\n assert candidate(word = \"xyzabcdeioufghijklmnopqrstuvwaeiou\") == 1\n assert candidate(word = \"aeiouaeeeeeiioouuuuuaeiou\") == 146\n assert candidate(word = \"abcdeioua\") == 1\n assert candidate(word = \"aeioubaeioucaeioudeaeioufaeioubaeioucaeioudeaeiouf\") == 10\n assert candidate(word = \"aeioueaioueaioueaioueaioueaiou\") == 350\n assert candidate(word = \"aeioubaeiouaeioubaeiouaeiou\") == 43\n assert candidate(word = \"aeiouaeiouaebcdeaeiouaeiou\") == 63\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiou\") == 351\n assert candidate(word = \"aeiouaeiouaeiouaeiou\") == 136\n assert candidate(word = \"xyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiou\") == 84\n assert candidate(word = \"aeiouzyxwvutsrqponmlkjihgfedcbaeiou\") == 2\n assert candidate(word = \"aeiouzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(word = \"aeiouxyzzyxwvutsrqponmlkjihgfedcbaeiouaeiouaeiouxyzaeiouxyzzyxwvutsrqponmlkjihgfedcbaeiou\") == 69\n assert candidate(word = \"eiouaeiouaeiouaeiouaeiouaeiou\") == 325\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 147\n assert candidate(word = \"xzaeiouaeiouaeiouaeiouaeioux\") == 231\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().countVowelSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countVowelSubstrings(self, word: str) -> int:", "container": "Solution", "callable": "countVowelSubstrings", "parameters": [{"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2063, "task_id": "vowels-of-all-substrings", "difficulty": "Medium", "problem_description": "Given a string word, return the sum of the number of vowels ('a', 'e', 'i', 'o', and 'u') in every substring of word.\nA substring is a contiguous (non-empty) sequence of characters within a string.\nNote: Due to the large constraints, the answer may not fit in a signed 32-bit integer. Please be careful during the calculations.\n \nExample 1:\n\nInput: word = \"aba\"\nOutput: 6\nExplanation: \nAll possible substrings are: \"a\", \"ab\", \"aba\", \"b\", \"ba\", and \"a\".\n- \"b\" has 0 vowels in it\n- \"a\", \"ab\", \"ba\", and \"a\" have 1 vowel each\n- \"aba\" has 2 vowels in it\nHence, the total sum of vowels = 0 + 1 + 1 + 1 + 1 + 2 = 6. \n\nExample 2:\n\nInput: word = \"abc\"\nOutput: 3\nExplanation: \nAll possible substrings are: \"a\", \"ab\", \"abc\", \"b\", \"bc\", and \"c\".\n- \"a\", \"ab\", and \"abc\" have 1 vowel each\n- \"b\", \"bc\", and \"c\" have 0 vowels each\nHence, the total sum of vowels = 1 + 1 + 1 + 0 + 0 + 0 = 3.\n\nExample 3:\n\nInput: word = \"ltcd\"\nOutput: 0\nExplanation: There are no vowels in any substring of \"ltcd\".\n\n \nConstraints:\n\n1 <= word.length <= 105\nword consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"e\") == 1\n assert candidate(word = \"aeiou\") == 35\n assert candidate(word = \"abc\") == 3\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiuiauuuuaeioaaaaeaiaioieoieiieoioioieouieiiaiaeiieoieouuiooaoaaiiaeiieeiooieiei\") == 209934\n assert candidate(word = \"bcbcbcbcbc\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiu\") == 4960\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiuiaoiuuaeiuuaieiiaaaeeiuuoiuuuuuuu\") == 43680\n assert candidate(word = \"ltcd\") == 0\n assert candidate(word = \"aba\") == 6\n assert candidate(word = \"u\") == 1\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\") == 604\n assert candidate(word = \"a\") == 1\n assert candidate(word = \"o\") == 1\n assert candidate(word = \"b\") == 0\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"i\") == 1\n assert candidate(word = \"\") == 0\n assert candidate(word = \"bbaaeekkeeaabbaaeekkeeaabbaaeekkeeaabb\") == 6576\n assert candidate(word = \"uvijqet\") == 34\n assert candidate(word = \"aieouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 16215\n assert candidate(word = \"uuygqijetbvrcw\") == 150\n assert candidate(word = \"mississippi\") == 98\n assert candidate(word = \"vowels\") == 22\n assert candidate(word = \"aeiouaeiouaeiou\") == 680\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 3412\n assert candidate(word = \"cccccdcccc\") == 0\n assert candidate(word = \"aovnwqoeirqoweoirqoweoirquw\") == 1949\n assert candidate(word = \"congratulations\") == 299\n assert candidate(word = \"xyzaeiouxyzaeiouxyz\") == 820\n assert candidate(word = \"bcbcbcbcbcbcbcbcbcbc\") == 0\n assert candidate(word = \"vvvuuuooooiiiaaaaeeeee\") == 1900\n assert candidate(word = \"consonants\") == 76\n assert candidate(word = \"vowelvowelvowel\") == 278\n assert candidate(word = \"supercalifragilisticexpialidocious\") == 3282\n assert candidate(word = \"aquickbrownfoxjumpsoverthelazydog\") == 2016\n assert candidate(word = \"leetcode\") == 58\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 3860\n assert candidate(word = \"sequence\") == 62\n assert candidate(word = \"aovvoaoaueuioeaueoaiouaoieaouioeaouioiea\") == 11218\n assert candidate(word = \"aeeee\") == 35\n assert candidate(word = \"aeioouaeiou\") == 286\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"bbbbbbbbbbbbbbbbbbbbbbba\") == 24\n assert candidate(word = \"hello\") == 13\n assert candidate(word = \"uoiea\") == 35\n assert candidate(word = \"bcdfghjklmnpqrstvwxyz\") == 0\n assert candidate(word = \"ffaaabbbccc\") == 94\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiou\") == 2925\n assert candidate(word = \"qweoiauoieqweoiauoieqweoiauoie\") == 4016\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 4562\n assert candidate(word = \"rhythms\") == 0\n assert candidate(word = \"bbbbbebbbb\") == 30\n assert candidate(word = \"aabbccddeeeffgg\") == 221\n assert candidate(word = \"beautiful\") == 101\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiou\") == 4960\n assert candidate(word = \"dddddeoeddd\") == 103\n assert candidate(word = \"aeiouaeiouaeiouaeiou\") == 1540\n assert candidate(word = \"vowel\") == 16\n assert candidate(word = \"xylophone\") == 54\n assert candidate(word = \"repetitiveeeee\") == 350\n assert candidate(word = \"repetition\") == 118\n assert candidate(word = \"characters\") == 78\n assert candidate(word = \"uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\") == 13244\n assert candidate(word = \"uvaeiouz\") == 98\n assert candidate(word = \"aovylqjwhepfuciphg\") == 280\n assert candidate(word = \"uoieaoueioauoiea\") == 816\n assert candidate(word = \"zzzzzzzzzzz\") == 0\n assert candidate(word = \"eeeeeaeeee\") == 220\n assert candidate(word = \"aaaaabaaaaa\") == 250\n assert candidate(word = \"abacaxabayabac\") == 280\n assert candidate(word = \"aeiouaeiou\") == 220\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"programming\") == 90\n assert candidate(word = \"aeiaoeiaoeiaoeiaoeiaoeiaoeiaoeiaoeiaoei\") == 10660\n assert candidate(word = \"ouqofyrcjgz\") == 63\n assert candidate(word = \"aeiaeaieaa\") == 220\n assert candidate(word = \"vowelsarefun\") == 158\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 4718\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().countVowels", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countVowels(self, word: str) -> int:", "container": "Solution", "callable": "countVowels", "parameters": [{"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2064, "task_id": "minimized-maximum-of-products-distributed-to-any-store", "difficulty": "Medium", "problem_description": "You are given an integer n indicating there are n specialty retail stores. There are m product types of varying amounts, which are given as a 0-indexed integer array quantities, where quantities[i] represents the number of products of the ith product type.\nYou need to distribute all products to the retail stores following these rules:\n\nA store can only be given at most one product type but can be given any amount of it.\nAfter distribution, each store will have been given some number of products (possibly 0). Let x represent the maximum number of products given to any store. You want x to be as small as possible, i.e., you want to minimize the maximum number of products that are given to any store.\n\nReturn the minimum possible x.\n \nExample 1:\n\nInput: n = 6, quantities = [11,6]\nOutput: 3\nExplanation: One optimal way is:\n- The 11 products of type 0 are distributed to the first four stores in these amounts: 2, 3, 3, 3\n- The 6 products of type 1 are distributed to the other two stores in these amounts: 3, 3\nThe maximum number of products given to any store is max(2, 3, 3, 3, 3, 3) = 3.\n\nExample 2:\n\nInput: n = 7, quantities = [15,10,10]\nOutput: 5\nExplanation: One optimal way is:\n- The 15 products of type 0 are distributed to the first three stores in these amounts: 5, 5, 5\n- The 10 products of type 1 are distributed to the next two stores in these amounts: 5, 5\n- The 10 products of type 2 are distributed to the last two stores in these amounts: 5, 5\nThe maximum number of products given to any store is max(5, 5, 5, 5, 5, 5, 5) = 5.\n\nExample 3:\n\nInput: n = 1, quantities = [100000]\nOutput: 100000\nExplanation: The only optimal way is:\n- The 100000 products of type 0 are distributed to the only store.\nThe maximum number of products given to any store is max(100000) = 100000.\n\n \nConstraints:\n\nm == quantities.length\n1 <= m <= n <= 105\n1 <= quantities[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,quantities = [10, 20, 30, 40, 50]) == 50\n assert candidate(n = 3,quantities = [100, 100, 100]) == 100\n assert candidate(n = 10,quantities = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100000]) == 100000\n assert candidate(n = 3,quantities = [1, 100000]) == 50000\n assert candidate(n = 2,quantities = [50000, 50000]) == 50000\n assert candidate(n = 50000,quantities = [1, 2, 3, 4, 5]) == 1\n assert candidate(n = 10,quantities = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == 100000\n assert candidate(n = 2,quantities = [100000, 100000]) == 100000\n assert candidate(n = 7,quantities = [15, 10, 10]) == 5\n assert candidate(n = 10,quantities = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(n = 5,quantities = [10, 10, 10, 10, 10]) == 10\n assert candidate(n = 5,quantities = [1, 1, 1, 1, 1]) == 1\n assert candidate(n = 6,quantities = [11, 6]) == 3\n assert candidate(n = 5,quantities = [1, 2, 3, 4, 5]) == 5\n assert candidate(n = 100000,quantities = [1]) == 1\n assert candidate(n = 10,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(n = 50000,quantities = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 4\n assert candidate(n = 50000,quantities = [100000, 100000]) == 4\n assert candidate(n = 100,quantities = [100000]) == 1000\n assert candidate(n = 10,quantities = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(n = 3,quantities = [50, 50, 50]) == 50\n assert candidate(n = 2,quantities = [100, 1]) == 100\n assert candidate(n = 3,quantities = [100, 200, 300]) == 300\n assert candidate(n = 1,quantities = [100000]) == 100000\n assert candidate(n = 100000,quantities = [100000]) == 1\n assert candidate(n = 8,quantities = [12, 24, 36, 48, 60, 72, 84, 96]) == 96\n assert candidate(n = 95000,quantities = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000, 180000, 190000, 200000]) == 23\n assert candidate(n = 100000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(n = 80000,quantities = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]) == 2\n assert candidate(n = 50000,quantities = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(n = 100000,quantities = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == 2\n assert candidate(n = 9,quantities = [10, 100, 1000, 10000, 100000, 100, 10, 1, 1000000]) == 1000000\n assert candidate(n = 75000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 1\n assert candidate(n = 100000,quantities = [10000, 20000, 30000, 40000, 50000]) == 2\n assert candidate(n = 45000,quantities = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 35\n assert candidate(n = 15000,quantities = [50000, 40000, 30000, 20000, 10000]) == 10\n assert candidate(n = 80000,quantities = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 1\n assert candidate(n = 20000,quantities = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1\n assert candidate(n = 90000,quantities = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == 3\n assert candidate(n = 10,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(n = 40000,quantities = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, 483, 482, 481, 480, 479, 478, 477, 476, 475, 474, 473, 472, 471, 470]) == 1\n assert candidate(n = 100000,quantities = [100000, 50000, 30000, 20000, 10000]) == 3\n assert candidate(n = 40000,quantities = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 1\n assert candidate(n = 30000,quantities = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500]) == 2\n assert candidate(n = 50000,quantities = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999]) == 20\n assert candidate(n = 30000,quantities = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == 6\n assert candidate(n = 60000,quantities = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980]) == 34\n assert candidate(n = 10,quantities = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 500\n assert candidate(n = 60000,quantities = [15000, 15000, 15000, 15000, 15000, 15000]) == 2\n assert candidate(n = 99999,quantities = [100000, 99999, 99998, 99997, 99996, 99995]) == 7\n assert candidate(n = 1,quantities = [1000000]) == 1000000\n assert candidate(n = 80000,quantities = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019]) == 1\n assert candidate(n = 6,quantities = [10, 20, 30, 40, 50, 60]) == 60\n assert candidate(n = 15,quantities = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 150\n assert candidate(n = 90000,quantities = [90000, 100, 200, 300, 400, 500, 600, 700, 800]) == 2\n assert candidate(n = 7,quantities = [5, 15, 25, 35, 45, 55, 65]) == 65\n assert candidate(n = 10,quantities = [1000, 2000, 3000, 4000, 5000]) == 2000\n assert candidate(n = 50000,quantities = [1, 10, 100, 1000, 10000, 100000]) == 3\n assert candidate(n = 100000,quantities = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 4\n assert candidate(n = 30000,quantities = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 8\n assert candidate(n = 20000,quantities = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 1\n assert candidate(n = 40000,quantities = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 14\n assert candidate(n = 75000,quantities = [99999, 1, 2, 3, 4, 5]) == 2\n assert candidate(n = 50000,quantities = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1\n assert candidate(n = 45000,quantities = [45000, 22500, 15000, 11250, 9000]) == 3\n assert candidate(n = 25000,quantities = [10000, 20000, 30000, 40000, 50000]) == 7\n assert candidate(n = 50000,quantities = [10000, 15000, 20000, 25000, 30000]) == 2\n assert candidate(n = 100000,quantities = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 1\n assert candidate(n = 90000,quantities = [9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000]) == 2\n assert candidate(n = 10000,quantities = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 22\n assert candidate(n = 75000,quantities = [20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000]) == 3\n assert candidate(n = 100000,quantities = [50000, 50000, 50000, 50000]) == 2\n assert candidate(n = 90000,quantities = [1, 10, 100, 1000, 10000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 17\n assert candidate(n = 99999,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(n = 50000,quantities = [25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000]) == 5\n assert candidate(n = 50000,quantities = [100000]) == 2\n assert candidate(n = 75000,quantities = [75000, 75000, 75000, 75000, 75000, 75000, 75000, 75000, 75000, 75000]) == 10\n assert candidate(n = 60000,quantities = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 10\n assert candidate(n = 50000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 1\n assert candidate(n = 100000,quantities = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(n = 50000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(n = 20,quantities = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110]) == 110\n assert candidate(n = 10000,quantities = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 10\n assert candidate(n = 30000,quantities = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1\n assert candidate(n = 80000,quantities = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == 1\n assert candidate(n = 55000,quantities = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000]) == 22\n assert candidate(n = 45000,quantities = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980]) == 45\n assert candidate(n = 1,quantities = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000000\n assert candidate(n = 90000,quantities = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(n = 3,quantities = [99999, 99999, 99999]) == 99999\n assert candidate(n = 60000,quantities = [1, 10, 100, 1000, 10000, 100000]) == 2\n assert candidate(n = 55000,quantities = [77777, 88888, 99999, 111111, 222222, 333333, 444444]) == 26\n assert candidate(n = 55000,quantities = [150000, 125000, 100000, 75000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(n = 60000,quantities = [99999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(n = 60000,quantities = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999]) == 34\n assert candidate(n = 80000,quantities = [8000, 8001, 8002, 8003, 8004, 8005, 8006, 8007, 8008, 8009]) == 2\n assert candidate(n = 50000,quantities = [100000, 200000, 300000, 400000]) == 20\n assert candidate(n = 20000,quantities = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 100\n assert candidate(n = 30000,quantities = [30000, 30001, 30002, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, 30018, 30019]) == 21\n assert candidate(n = 100000,quantities = [50000, 50000, 50000, 50000, 50000]) == 3\n assert candidate(n = 100000,quantities = [10000, 15000, 20000, 25000, 30000]) == 1\n assert candidate(n = 75000,quantities = [12345, 67890, 11111, 22222, 33333, 44444, 55555]) == 4\n assert candidate(n = 50000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(n = 30000,quantities = [9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999]) == 11\n assert candidate(n = 25000,quantities = [50000, 100000, 150000, 200000, 250000, 300000]) == 43\n assert candidate(n = 100,quantities = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 20\n assert candidate(n = 80000,quantities = [20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000]) == 17\n assert candidate(n = 25000,quantities = [200000, 150000, 100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == 23\n"}, "metadata": {"canonical_parameter_names": ["n", "quantities"], "leetcode_dataset_entry_point": "Solution().minimizedMaximum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimizedMaximum(self, n: int, quantities: list[int]) -> int:", "container": "Solution", "callable": "minimizedMaximum", "parameters": [{"name": "n", "type": "int"}, {"name": "quantities", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2065, "task_id": "maximum-path-quality-of-a-graph", "difficulty": "Hard", "problem_description": "There is an undirected graph with n nodes numbered from 0 to n - 1 (inclusive). You are given a 0-indexed integer array values where values[i] is the value of the ith node. You are also given a 0-indexed 2D integer array edges, where each edges[j] = [uj, vj, timej] indicates that there is an undirected edge between the nodes uj and vj, and it takes timej seconds to travel between the two nodes. Finally, you are given an integer maxTime.\nA valid path in the graph is any path that starts at node 0, ends at node 0, and takes at most maxTime seconds to complete. You may visit the same node multiple times. The quality of a valid path is the sum of the values of the unique nodes visited in the path (each node's value is added at most once to the sum).\nReturn the maximum quality of a valid path.\nNote: There are at most four edges connected to each node.\n \nExample 1:\n\n\nInput: values = [0,32,10,43], edges = [[0,1,10],[1,2,15],[0,3,10]], maxTime = 49\nOutput: 75\nExplanation:\nOne possible path is 0 -> 1 -> 0 -> 3 -> 0. The total time taken is 10 + 10 + 10 + 10 = 40 <= 49.\nThe nodes visited are 0, 1, and 3, giving a maximal path quality of 0 + 32 + 43 = 75.\n\nExample 2:\n\n\nInput: values = [5,10,15,20], edges = [[0,1,10],[1,2,10],[0,3,10]], maxTime = 30\nOutput: 25\nExplanation:\nOne possible path is 0 -> 3 -> 0. The total time taken is 10 + 10 = 20 <= 30.\nThe nodes visited are 0 and 3, giving a maximal path quality of 5 + 20 = 25.\n\nExample 3:\n\n\nInput: values = [1,2,3,4], edges = [[0,1,10],[1,2,11],[2,3,12],[1,3,13]], maxTime = 50\nOutput: 7\nExplanation:\nOne possible path is 0 -> 1 -> 3 -> 1 -> 0. The total time taken is 10 + 13 + 13 + 10 = 46 <= 50.\nThe nodes visited are 0, 1, and 3, giving a maximal path quality of 1 + 2 + 4 = 7.\n\n \nConstraints:\n\nn == values.length\n1 <= n <= 1000\n0 <= values[i] <= 108\n0 <= edges.length <= 2000\nedges[j].length == 3 \n0 <= uj < vj <= n - 1\n10 <= timej, maxTime <= 100\nAll the pairs [uj, vj] are unique.\nThere are at most four edges connected to each node.\nThe graph may not be connected.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 4, 40]],maxTime = 100) == 70\n assert candidate(values = [100, 200, 300, 400],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 0, 10]],maxTime = 50) == 1000\n assert candidate(values = [5, 5, 5, 5, 5],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 0, 10]],maxTime = 40) == 15\n assert candidate(values = [5, 5, 5, 5],edges = [[0, 1, 10], [0, 2, 10], [2, 3, 10]],maxTime = 25) == 10\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10]],maxTime = 50) == 3\n assert candidate(values = [1, 2, 3, 4, 5],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10]],maxTime = 20) == 4\n assert candidate(values = [1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10]],maxTime = 40) == 3\n assert candidate(values = [5, 10, 15, 20],edges = [[0, 1, 10], [1, 2, 10], [0, 3, 10]],maxTime = 30) == 25\n assert candidate(values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10]],maxTime = 100) == 27\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],maxTime = 90) == 25\n assert candidate(values = [5, 5, 5, 5, 5, 5],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10]],maxTime = 30) == 10\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10]],maxTime = 50) == 90\n assert candidate(values = [5, 5, 5, 5],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 3, 10]],maxTime = 30) == 10\n assert candidate(values = [1, 2, 3, 4],edges = [[0, 1, 10], [1, 2, 11], [2, 3, 12], [1, 3, 13]],maxTime = 50) == 7\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [0, 2, 20], [1, 3, 15], [2, 3, 25], [3, 4, 10]],maxTime = 60) == 70\n assert candidate(values = [1, 2, 3, 4],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10]],maxTime = 10) == 1\n assert candidate(values = [1, 2, 3, 4, 5, 6],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10]],maxTime = 60) == 12\n assert candidate(values = [0, 32, 10, 43],edges = [[0, 1, 10], [1, 2, 15], [0, 3, 10]],maxTime = 49) == 75\n assert candidate(values = [10, 20, 30],edges = [[0, 1, 10], [1, 2, 10]],maxTime = 25) == 30\n assert candidate(values = [10, 20, 30],edges = [[0, 1, 10], [1, 2, 20]],maxTime = 30) == 30\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 0, 10]],maxTime = 50) == 150\n assert candidate(values = [10],edges = [],maxTime = 100) == 10\n assert candidate(values = [100, 0, 0, 0],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10]],maxTime = 10) == 100\n assert candidate(values = [100, 50, 200, 300, 150, 250, 400],edges = [[0, 1, 20], [0, 2, 30], [0, 3, 40], [1, 4, 10], [1, 5, 20], [2, 6, 30], [3, 6, 40], [4, 5, 50], [5, 6, 60]],maxTime = 120) == 700\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10]],maxTime = 80) == 2500\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 7, 10], [6, 8, 10], [7, 8, 10], [7, 9, 10], [8, 9, 10]],maxTime = 50) == 110\n assert candidate(values = [10, 10, 10, 10, 10],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 40) == 40\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [1, 6, 10], [1, 7, 10], [2, 8, 10], [2, 9, 10], [3, 10, 10], [3, 11, 10], [4, 12, 10], [4, 13, 10], [5, 14, 10], [5, 15, 10], [6, 16, 10], [6, 17, 10], [7, 18, 10], [7, 19, 10], [8, 14, 10], [8, 15, 10], [9, 16, 10], [9, 17, 10], [10, 18, 10], [10, 19, 10], [11, 14, 10], [11, 15, 10], [12, 16, 10], [12, 17, 10], [13, 18, 10], [13, 19, 10]],maxTime = 100) == 10\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],edges = [[0, 1, 10], [0, 2, 20], [1, 3, 15], [2, 4, 25], [3, 5, 10], [4, 6, 15], [5, 7, 20], [6, 8, 10], [7, 9, 15], [8, 10, 20], [9, 11, 10]],maxTime = 120) == 210\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10]],maxTime = 80) == 8\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10], [0, 2, 15], [1, 3, 15], [2, 4, 15], [3, 5, 15], [4, 6, 15], [5, 7, 15], [6, 8, 15], [7, 9, 15], [8, 0, 15], [9, 1, 15]],maxTime = 150) == 550\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 0, 10]],maxTime = 50) == 70\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],maxTime = 55) == 600\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10]],maxTime = 50) == 9\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 100) == 5\n assert candidate(values = [10, 20, 30, 40, 50, 60],edges = [[0, 1, 10], [0, 2, 10], [1, 2, 15], [1, 3, 20], [2, 4, 25], [3, 4, 30], [4, 5, 15]],maxTime = 70) == 90\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10], [8, 0, 10]],maxTime = 90) == 310\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 7, 10], [6, 8, 10], [7, 8, 10], [8, 9, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [2, 7, 10], [3, 8, 10], [4, 9, 10], [5, 6, 10]],maxTime = 60) == 37\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [3, 8, 10], [4, 9, 10], [4, 10, 10], [5, 11, 10], [5, 12, 10], [6, 13, 10], [6, 14, 10], [7, 15, 10], [7, 16, 10], [8, 17, 10], [8, 18, 10], [9, 19, 10]],maxTime = 150) == 8\n assert candidate(values = [1, 2, 3, 4, 5],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 40) == 9\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10]],maxTime = 100) == 310\n assert candidate(values = [100, 200, 100, 200, 100, 200, 100, 200],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10]],maxTime = 50) == 500\n assert candidate(values = [50, 20, 30, 40],edges = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 2, 15], [1, 3, 25], [2, 3, 10]],maxTime = 40) == 80\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 35) == 100\n assert candidate(values = [5, 10, 15, 20, 25, 30],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [0, 3, 35], [1, 4, 40]],maxTime = 100) == 50\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [5, 6, 35], [6, 7, 40], [0, 7, 10]],maxTime = 100) == 80\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10]],maxTime = 80) == 27\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10]],maxTime = 50) == 20\n assert candidate(values = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10], [0, 5, 10], [1, 6, 10], [2, 7, 10], [3, 8, 10], [4, 9, 10]],maxTime = 150) == 550\n assert candidate(values = [30, 20, 10, 40, 50],edges = [[0, 1, 10], [0, 2, 15], [0, 3, 20], [0, 4, 25], [1, 2, 5], [1, 3, 15], [1, 4, 25], [2, 3, 10], [2, 4, 20], [3, 4, 5]],maxTime = 60) == 150\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 15, 10], [15, 16, 10], [16, 17, 10], [17, 18, 10], [18, 19, 10]],maxTime = 190) == 275\n assert candidate(values = [9, 8, 7, 6, 5, 4, 3, 2, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [1, 4, 10], [1, 5, 10], [2, 6, 10], [2, 7, 10], [3, 8, 10], [4, 8, 10], [5, 6, 10]],maxTime = 60) == 31\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],edges = [[0, 1, 10], [1, 2, 10], [0, 3, 10], [3, 4, 10], [2, 5, 10], [5, 6, 10], [4, 7, 10], [7, 8, 10], [6, 9, 10]],maxTime = 100) == 145\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 15], [0, 2, 20], [1, 3, 25], [2, 4, 30], [3, 5, 35], [4, 6, 40], [5, 7, 45], [6, 8, 50], [7, 9, 55], [8, 9, 60]],maxTime = 150) == 13\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [1, 4, 10], [1, 5, 10], [2, 6, 10], [2, 7, 10], [3, 8, 10], [3, 9, 10]],maxTime = 50) == 150\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 0, 10]],maxTime = 140) == 850\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10]],maxTime = 100) == 510\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 10], [5, 6, 30], [6, 7, 10], [7, 8, 25], [8, 9, 20], [9, 10, 15], [10, 11, 20], [11, 12, 15], [12, 13, 10], [13, 14, 30]],maxTime = 200) == 210\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10]],maxTime = 90) == 3500\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [1, 6, 10], [2, 7, 10], [2, 8, 10], [3, 9, 10], [3, 10, 10], [4, 11, 10], [4, 12, 10], [5, 13, 10], [6, 14, 10], [7, 15, 10], [8, 16, 10], [9, 17, 10], [10, 18, 10], [11, 19, 10], [12, 13, 10], [14, 15, 10], [16, 17, 10], [18, 19, 10]],maxTime = 150) == 142\n assert candidate(values = [100, 200, 300, 400, 500],edges = [[0, 1, 20], [0, 2, 30], [1, 3, 25], [2, 4, 35], [3, 4, 40]],maxTime = 150) == 1500\n assert candidate(values = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10], [3, 4, 15], [5, 6, 15]],maxTime = 120) == 950\n assert candidate(values = [100, 200, 300, 400, 500],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 0, 10]],maxTime = 50) == 1500\n assert candidate(values = [50, 20, 10, 30, 40, 60],edges = [[0, 1, 10], [1, 2, 15], [1, 3, 20], [2, 3, 25], [3, 4, 10], [4, 5, 30]],maxTime = 100) == 150\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 3, 10], [3, 4, 10], [1, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 1, 10]],maxTime = 60) == 22\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 7, 10], [6, 8, 10], [7, 8, 10]],maxTime = 100) == 40\n assert candidate(values = [5, 10, 15, 20, 25, 30],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [0, 5, 35]],maxTime = 70) == 35\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],maxTime = 90) == 15\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10], [0, 3, 30], [1, 5, 30], [2, 4, 30]],maxTime = 90) == 450\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [0, 2, 15], [1, 3, 20], [2, 4, 25], [3, 5, 10], [4, 6, 30], [5, 7, 10], [6, 8, 25], [7, 9, 20]],maxTime = 150) == 3100\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 9, 10], [7, 9, 10], [8, 9, 10]],maxTime = 50) == 15\n assert candidate(values = [100000000, 200000000, 300000000, 400000000],edges = [[0, 1, 20], [1, 2, 30], [2, 3, 25], [3, 0, 35]],maxTime = 100) == 600000000\n assert candidate(values = [50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 20], [1, 3, 15], [2, 3, 25], [3, 4, 10], [4, 5, 15]],maxTime = 100) == 380\n assert candidate(values = [100, 200, 300, 400, 500],edges = [[0, 1, 20], [1, 2, 30], [2, 3, 25], [3, 4, 35], [4, 0, 40]],maxTime = 120) == 800\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 0, 10], [1, 3, 15], [2, 4, 20]],maxTime = 50) == 150\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10], [0, 5, 20], [1, 6, 20], [2, 7, 20], [3, 8, 20], [4, 9, 20]],maxTime = 120) == 275\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 7, 10], [6, 8, 10], [7, 8, 10], [8, 9, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [2, 7, 10], [3, 8, 10], [4, 9, 10], [5, 6, 10], [0, 5, 10], [1, 6, 10], [2, 3, 10], [3, 9, 10], [4, 5, 10], [6, 9, 10], [7, 9, 10]],maxTime = 100) == 5500\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 15, 10]],maxTime = 150) == 40\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 0, 10]],maxTime = 150) == 1180\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [0, 5, 10], [0, 6, 10], [0, 7, 10], [0, 8, 10], [0, 9, 10], [1, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 15, 10], [15, 16, 10], [16, 17, 10], [17, 18, 10], [18, 19, 10]],maxTime = 50) == 3\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [3, 8, 10], [4, 9, 10], [5, 6, 10], [7, 8, 10], [8, 9, 10]],maxTime = 90) == 390\n assert candidate(values = [100, 200, 300, 400, 500],edges = [[0, 1, 20], [0, 2, 20], [1, 3, 20], [2, 3, 20], [3, 4, 20], [1, 2, 20]],maxTime = 80) == 1000\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10]],maxTime = 90) == 350\n assert candidate(values = [8, 6, 7, 5, 3, 0, 9],edges = [[0, 1, 15], [1, 2, 20], [2, 3, 25], [3, 4, 30], [4, 5, 35], [5, 6, 40], [6, 0, 45]],maxTime = 100) == 21\n assert candidate(values = [5, 10, 15, 20, 25, 30],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [0, 5, 10]],maxTime = 100) == 70\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10], [9, 0, 10]],maxTime = 100) == 390\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10]],maxTime = 150) == 360\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 9, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],maxTime = 80) == 35\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 30) == 100\n"}, "metadata": {"canonical_parameter_names": ["values", "edges", "maxTime"], "leetcode_dataset_entry_point": "Solution().maximalPathQuality", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximalPathQuality(self, values: list[int], edges: list[list[int]], maxTime: int) -> int:", "container": "Solution", "callable": "maximalPathQuality", "parameters": [{"name": "values", "type": "list[int]"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "maxTime", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2068, "task_id": "check-whether-two-strings-are-almost-equivalent", "difficulty": "Easy", "problem_description": "Two strings word1 and word2 are considered almost equivalent if the differences between the frequencies of each letter from 'a' to 'z' between word1 and word2 is at most 3.\nGiven two strings word1 and word2, each of length n, return true if word1 and word2 are almost equivalent, or false otherwise.\nThe frequency of a letter x is the number of times it occurs in the string.\n \nExample 1:\n\nInput: word1 = \"aaaa\", word2 = \"bccb\"\nOutput: false\nExplanation: There are 4 'a's in \"aaaa\" but 0 'a's in \"bccb\".\nThe difference is 4, which is more than the allowed 3.\n\nExample 2:\n\nInput: word1 = \"abcdeef\", word2 = \"abaaacc\"\nOutput: true\nExplanation: The differences between the frequencies of each letter in word1 and word2 are at most 3:\n- 'a' appears 1 time in word1 and 4 times in word2. The difference is 3.\n- 'b' appears 1 time in word1 and 1 time in word2. The difference is 0.\n- 'c' appears 1 time in word1 and 2 times in word2. The difference is 1.\n- 'd' appears 1 time in word1 and 0 times in word2. The difference is 1.\n- 'e' appears 2 times in word1 and 0 times in word2. The difference is 2.\n- 'f' appears 1 time in word1 and 0 times in word2. The difference is 1.\n\nExample 3:\n\nInput: word1 = \"cccddabba\", word2 = \"babababab\"\nOutput: true\nExplanation: The differences between the frequencies of each letter in word1 and word2 are at most 3:\n- 'a' appears 2 times in word1 and 4 times in word2. The difference is 2.\n- 'b' appears 2 times in word1 and 5 times in word2. The difference is 3.\n- 'c' appears 3 times in word1 and 0 times in word2. The difference is 3.\n- 'd' appears 2 times in word1 and 0 times in word2. The difference is 2.\n\n \nConstraints:\n\nn == word1.length == word2.length\n1 <= n <= 100\nword1 and word2 consist only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"cccddabba\",word2 = \"babababab\") == True\n assert candidate(word1 = \"aaa\",word2 = \"bbb\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"ccbbaa\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(word1 = \"pqrstu\",word2 = \"utsrpq\") == True\n assert candidate(word1 = \"mnop\",word2 = \"ponm\") == True\n assert candidate(word1 = \"abcabcabc\",word2 = \"bcbcbcbcb\") == True\n assert candidate(word1 = \"aaaa\",word2 = \"bccb\") == False\n assert candidate(word1 = \"xyz\",word2 = \"zyx\") == True\n assert candidate(word1 = \"abcdeef\",word2 = \"abaaacc\") == True\n assert candidate(word1 = \"abc\",word2 = \"abc\") == True\n assert candidate(word1 = \"hello\",word2 = \"world\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggeeffddccbbaa\") == True\n assert candidate(word1 = \"abcabcabc\",word2 = \"abcabcabc\") == True\n assert candidate(word1 = \"zzzz\",word2 = \"zzzz\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"bbccdd\") == True\n assert candidate(word1 = \"abc\",word2 = \"xyz\") == True\n assert candidate(word1 = \"zzz\",word2 = \"zzz\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"abcabc\") == True\n assert candidate(word1 = \"abcdef\",word2 = \"fedcba\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"abc\") == True\n assert candidate(word1 = \"abcd\",word2 = \"dcba\") == True\n assert candidate(word1 = \"abc\",word2 = \"def\") == True\n assert candidate(word1 = \"abcdefg\",word2 = \"gfedcba\") == True\n assert candidate(word1 = \"almostequivalent\",word2 = \"equivalentalmost\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(word1 = \"abacabadabacabad\",word2 = \"babaabacabacabac\") == True\n assert candidate(word1 = \"abcdefghijl\",word2 = \"abcdefghijllll\") == True\n assert candidate(word1 = \"aabbaabbaabb\",word2 = \"bbaabbaabbab\") == True\n assert candidate(word1 = \"hello world\",word2 = \"world hello\") == True\n assert candidate(word1 = \"frequency\",word2 = \"requeency\") == True\n assert candidate(word1 = \"aaaabbbbccccddddeeeffffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\",word2 = \"zzzyyyxxxwwvvvuuuutttsssrqqqpppoonnmmlllkkkjjjiiihhhgggfffffeeedddccccbbbbaaaa\") == True\n assert candidate(word1 = \"xyzxyzxyzxyzxyz\",word2 = \"zyxzyxzyxzyxzyx\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwwvvttrrppoonnmmllkkjjiihhggeeddbbccaabb\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"ssipimisip\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzzzyyyxxxwwvvuuttrrssqqpponnmlkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"xyzxyzxyzxyzxyzxyz\",word2 = \"xyzxyzxyzxyzxyzxyx\") == True\n assert candidate(word1 = \"xylophone\",word2 = \"polyxhnon\") == True\n assert candidate(word1 = \"almost\",word2 = \"almosttttt\") == False\n assert candidate(word1 = \"aaaabbbb\",word2 = \"bbbbaaaa\") == True\n assert candidate(word1 = \"almostequivalent\",word2 = \"almostequivalen\") == True\n assert candidate(word1 = \"testtesttest\",word2 = \"setttestsett\") == True\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcba\") == True\n assert candidate(word1 = \"aaaaabbbbcccc\",word2 = \"bbbbbccccddddd\") == False\n assert candidate(word1 = \"aaabbbccc\",word2 = \"bbcccaaa\") == True\n assert candidate(word1 = \"abababababababababababababababababababab\",word2 = \"babababababababababababababababababababaa\") == True\n assert candidate(word1 = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooo\",word2 = \"bbbbaaaaccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooo\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwvwuvttsrqpqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(word1 = \"banana\",word2 = \"nanaba\") == True\n assert candidate(word1 = \"python\",word2 = \"pythooon\") == True\n assert candidate(word1 = \"abacabadabacabad\",word2 = \"bacadabacadaba\") == True\n assert candidate(word1 = \"almostequivalent\",word2 = \"quivalentalmosta\") == True\n assert candidate(word1 = \"frequency\",word2 = \"frequncey\") == True\n assert candidate(word1 = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",word2 = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqz\") == True\n assert candidate(word1 = \"frequencycheck\",word2 = \"checkfrequency\") == True\n assert candidate(word1 = \"aabbbcccddddeee\",word2 = \"eeeeddddccccbbbbaaa\") == True\n assert candidate(word1 = \"abracadabra\",word2 = \"alakazam\") == True\n assert candidate(word1 = \"aabbbccc\",word2 = \"bbaaccdd\") == True\n assert candidate(word1 = \"abcdefghijlll\",word2 = \"abcdefghijllll\") == True\n assert candidate(word1 = \"abcdefghijabcdefghij\",word2 = \"abcdefghijabcdefghii\") == True\n assert candidate(word1 = \"ppppqqqqrrrrssss\",word2 = \"ttttuuuuvvvv\") == False\n assert candidate(word1 = \"abababababababab\",word2 = \"babababababababa\") == True\n assert candidate(word1 = \"aaaaaaaabbbbbbbbbbcccccccccc\",word2 = \"ccccccccccbbbbbbbbbbaaaaaaaabbbb\") == False\n assert candidate(word1 = \"aaabbbccc\",word2 = \"bbbaacccd\") == True\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"bcbcbcbcbcbc\") == False\n assert candidate(word1 = \"mississippi\",word2 = \"pississim\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwwvvttrrssqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"aaaaabbbbccccdddd\",word2 = \"bbbbbccccddddaaaaa\") == True\n assert candidate(word1 = \"xylophone\",word2 = \"polynomial\") == True\n assert candidate(word1 = \"aaaabbbbcccc\",word2 = \"cccbbbbaaa\") == True\n assert candidate(word1 = \"asdfghjkl\",word2 = \"lkjhgfdsa\") == True\n assert candidate(word1 = \"hello\",word2 = \"yellow\") == True\n assert candidate(word1 = \"almostequivalent\",word2 = \"quivalentalmost\") == True\n assert candidate(word1 = \"abcdefghij\",word2 = \"abcdefghijk\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"acabacabacababa\") == True\n assert candidate(word1 = \"abcdefgabcdefgabcdefgabcdefg\",word2 = \"gfedcbagfedcbagfedcbagfedcb\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwwvvttrrqqppoonnmmllkkjjiihhggeeffeeddccbbaa\") == True\n assert candidate(word1 = \"hellothere\",word2 = \"heellooerr\") == True\n assert candidate(word1 = \"abcdeffghijklmnopqrstuvwxyz\",word2 = \"mnopqrstuvwxyzabcdefghijkl\") == True\n assert candidate(word1 = \"abcabcabc\",word2 = \"bcabcbac\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"equaldiffffe\",word2 = \"equaldifffff\") == True\n assert candidate(word1 = \"racecar\",word2 = \"carrace\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"bississippi\") == True\n assert candidate(word1 = \"abacabadabacabad\",word2 = \"abcabcabcabc\") == False\n assert candidate(word1 = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkk\",word2 = \"ffffgggghhhhiiiijjjjkkkkaaaabbbbccccddddeeee\") == True\n assert candidate(word1 = \"abcdefg\",word2 = \"ghfedcba\") == True\n assert candidate(word1 = \"pythonprogramming\",word2 = \"programmingpython\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"abcdabcdabcdabcdabcdabcd\",word2 = \"abcdabcdabcdabcdabcdabc\") == True\n assert candidate(word1 = \"abcdefghijk\",word2 = \"abcdefghijl\") == True\n assert candidate(word1 = \"aaaaaaaaaaa\",word2 = \"bbbbbbbbbbb\") == False\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"ababababababababababababababababababababab\",word2 = \"bababababababababababababababababababababa\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"aabbbcccddd\",word2 = \"aaabbbcc\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"ssissippi\") == True\n assert candidate(word1 = \"programming\",word2 = \"mmprogain\") == True\n assert candidate(word1 = \"aaabbbccc\",word2 = \"bbbaaacc\") == True\n assert candidate(word1 = \"aaaaabbbbcccccddddd\",word2 = \"aaabbbcccdddd\") == True\n assert candidate(word1 = \"banana\",word2 = \"ananaa\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"cbacabacabacabc\") == True\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"bcdbcdabcdabcd\") == False\n assert candidate(word1 = \"aaaaaaaabbbbbbbccccccdddddeeeeeffffff\",word2 = \"ffffffeeeeeee/ddddddccccbbbbbbaaaaaa\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"abcdabcdabcdabcd\",word2 = \"bcdbcdbcdbcdbcdb\") == False\n assert candidate(word1 = \"abcdabcdabcdabcd\",word2 = \"dcbaabcdabcdabcd\") == True\n assert candidate(word1 = \"abcdefghij\",word2 = \"abcdefghix\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttsrqpponnml lkjihgfedcba\") == True\n assert candidate(word1 = \"abcdefghi\",word2 = \"ihgfedcba\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyza\",word2 = \"bcdefghijklmnopqrstuvwxyzzz\") == True\n assert candidate(word1 = \"frequency\",word2 = \"frequnecy\") == True\n assert candidate(word1 = \"aaabbbcccddd\",word2 = \"aaaabbbbccccdddd\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(word1 = \"abcde\",word2 = \"fghij\") == True\n assert candidate(word1 = \"abcabcabcabcabc\",word2 = \"bcbcbcbcbcbcb\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(word1 = \"abcdabcdabcdabcd\",word2 = \"abcdeabcdeabcdeabcde\") == False\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyzz\",word2 = \"abcdefghijklmnopqrstuvwxyyz\") == True\n assert candidate(word1 = \"aabbbcccdddee\",word2 = \"eeedddcccbbaa\") == True\n assert candidate(word1 = \"uvwxyz\",word2 = \"vwxyz\") == True\n assert candidate(word1 = \"aaaaabbbbccccc\",word2 = \"bbbaaaaaccccc\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzzzyyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"pythonprogramming\",word2 = \"rogrammingpython\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"abacabadabacaba\") == True\n assert candidate(word1 = \"aaaaaabbbbbbccccccdddddeeeeee\",word2 = \"eeeeeeaaaaaabbbbbbccccccddddde\") == True\n assert candidate(word1 = \"abcabcabcabcabc\",word2 = \"cccbbbbaaaabcabc\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttrrssqqppoonnmlkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"abcabcabcabcabc\") == True\n assert candidate(word1 = \"qwerasdfzxcv\",word2 = \"asdfzxcvqwer\") == True\n assert candidate(word1 = \"mnopqr\",word2 = \"mnopqz\") == True\n assert candidate(word1 = \"mnopqr\",word2 = \"rqponm\") == True\n assert candidate(word1 = \"abcdefg\",word2 = \"ghijklm\") == True\n assert candidate(word1 = \"abcdefghijllll\",word2 = \"abcdefghijlll\") == True\n assert candidate(word1 = \"aaaaaaaaabbbbbbbbbbccccccccccdddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhiiiiiiiiiijjjjjjjjjjkkkkkkkkkkllllllllllmmmmmmmmmmnnnnnnnnnnooooooooooppppppppppqqqqqqqqqqrrrrrrrrrrssssssssssttttttttttuuuuuuuuuuvvvvvvvvvvwwwwwwwwwwxxxxxxxxxxxyyyyyyyyyyzzzzzzzzzz\",word2 = \"zzzzzzzzzzyyyyyyyyyyxxxxxxxxxxwwwwwwwwwwvvvvvvvvvvuuuuuuuuuuttttttttttssssssssssrrrrrrrrrrqqqqqqqqqqpppppppppooooooooollllllllllkkkkkkkkkkjjjjjjjjjiiiiiiiiiijjjjjjjjjjhhhhhhhhhhhggggggggggffffffffeeeeeeeeeeeeddddddddddccccccccccbbbbbbbbbbbbaaaaaaaaaa\") == False\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"dcbaefghefgh\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"missiisssipp\") == True\n assert candidate(word1 = \"aaaabbbbccccdddd\",word2 = \"bbbaaaacccddde\") == True\n assert candidate(word1 = \"qwert\",word2 = \"qwerty\") == True\n assert candidate(word1 = \"aaaabbbbcccc\",word2 = \"ddddeeeeffff\") == False\n assert candidate(word1 = \"programming\",word2 = \"grammipnorg\") == True\n assert candidate(word1 = \"aaaabbbbccccdddd\",word2 = \"ddddccccbbbbaaaa\") == True\n assert candidate(word1 = \"aabccddeeff\",word2 = \"abccddeeffggh\") == True\n"}, "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().checkAlmostEquivalent", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def checkAlmostEquivalent(self, word1: str, word2: str) -> bool:", "container": "Solution", "callable": "checkAlmostEquivalent", "parameters": [{"name": "word1", "type": "str"}, {"name": "word2", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2070, "task_id": "most-beautiful-item-for-each-query", "difficulty": "Medium", "problem_description": "You are given a 2D integer array items where items[i] = [pricei, beautyi] denotes the price and beauty of an item respectively.\nYou are also given a 0-indexed integer array queries. For each queries[j], you want to determine the maximum beauty of an item whose price is less than or equal to queries[j]. If no such item exists, then the answer to this query is 0.\nReturn an array answer of the same length as queries where answer[j] is the answer to the jth query.\n \nExample 1:\n\nInput: items = [[1,2],[3,2],[2,4],[5,6],[3,5]], queries = [1,2,3,4,5,6]\nOutput: [2,4,5,5,6,6]\nExplanation:\n- For queries[0]=1, [1,2] is the only item which has price <= 1. Hence, the answer for this query is 2.\n- For queries[1]=2, the items which can be considered are [1,2] and [2,4]. \n The maximum beauty among them is 4.\n- For queries[2]=3 and queries[3]=4, the items which can be considered are [1,2], [3,2], [2,4], and [3,5].\n The maximum beauty among them is 5.\n- For queries[4]=5 and queries[5]=6, all items can be considered.\n Hence, the answer for them is the maximum beauty of all items, i.e., 6.\n\nExample 2:\n\nInput: items = [[1,2],[1,2],[1,3],[1,4]], queries = [1]\nOutput: [4]\nExplanation: \nThe price of every item is equal to 1, so we choose the item with the maximum beauty 4. \nNote that multiple items can have the same price and/or beauty. \n\nExample 3:\n\nInput: items = [[10,1000]], queries = [5]\nOutput: [0]\nExplanation:\nNo item has a price less than or equal to 5, so no item can be chosen.\nHence, the answer to the query is 0.\n\n \nConstraints:\n\n1 <= items.length, queries.length <= 105\nitems[i].length == 2\n1 <= pricei, beautyi, queries[j] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(items = [[10, 1000]],queries = [5]) == [0]\n assert candidate(items = [[100, 5], [50, 4], [200, 3], [150, 2], [300, 1]],queries = [50, 100, 150, 200, 250, 300]) == [4, 5, 5, 5, 5, 5]\n assert candidate(items = [[1, 5], [2, 9], [3, 12], [4, 15], [5, 18]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [5, 12, 18, 18, 18, 18, 18, 18, 18, 18]\n assert candidate(items = [[5, 10], [4, 4], [6, 8], [7, 12]],queries = [3, 5, 7, 10]) == [0, 10, 12, 12]\n assert candidate(items = [[5, 10], [3, 5], [10, 15], [1, 1]],queries = [3, 7, 10]) == [5, 10, 15]\n assert candidate(items = [[1, 2], [1, 2], [1, 3], [1, 4]],queries = [1]) == [4]\n assert candidate(items = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]],queries = [1, 2, 3, 4, 5, 6]) == [5, 5, 5, 5, 5, 5]\n assert candidate(items = [[5, 1], [3, 2], [7, 4], [2, 3]],queries = [8, 6, 4, 2, 1]) == [4, 3, 3, 3, 0]\n assert candidate(items = [[1, 2], [3, 2], [2, 4], [5, 6], [3, 5]],queries = [1, 2, 3, 4, 5, 6]) == [2, 4, 5, 5, 6, 6]\n assert candidate(items = [[5, 10], [7, 15], [8, 20]],queries = [6, 9, 12]) == [10, 20, 20]\n assert candidate(items = [[100, 1], [99, 2], [98, 3], [97, 4], [96, 5]],queries = [96, 97, 98, 99, 100]) == [5, 5, 5, 5, 5]\n assert candidate(items = [[5, 1], [3, 2], [7, 4], [2, 6], [9, 8]],queries = [1, 3, 5, 7, 9, 11]) == [0, 6, 6, 6, 8, 8]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [5, 4, 3, 2, 1]) == [5, 4, 3, 2, 1]\n assert candidate(items = [[2, 3], [5, 5], [6, 7], [8, 8]],queries = [1, 4, 6, 9]) == [0, 3, 7, 8]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(items = [[1, 1], [2, 3], [2, 5], [3, 4], [3, 6], [4, 7], [4, 8], [5, 9]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 5, 6, 8, 9, 9, 9, 9, 9]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700], [80, 800], [90, 900], [100, 1000]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(items = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],queries = [4, 5, 6]) == [0, 10, 10]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]],queries = [1, 1, 1, 1, 1]) == [6, 6, 6, 6, 6]\n assert candidate(items = [[1, 1000], [1, 900], [1, 800], [1, 700], [1, 600], [1, 500], [1, 400], [1, 300], [1, 200], [1, 100]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]\n assert candidate(items = [[1, 10], [2, 15], [3, 5], [4, 20], [5, 10], [6, 25], [7, 30], [8, 20], [9, 5], [10, 15]],queries = [1, 3, 5, 7, 9, 10]) == [10, 15, 20, 30, 30, 30]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]\n assert candidate(items = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1000000000, 1000000000]],queries = [500000000, 1000000000, 1500000000]) == [0, 1000000000, 1000000000]\n assert candidate(items = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]\n assert candidate(items = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == [0, 10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100]\n assert candidate(items = [[1, 100], [10, 200], [100, 300], [1000, 400], [10000, 500]],queries = [1, 5, 50, 500, 5000, 50000, 100000]) == [100, 100, 200, 300, 400, 500, 500]\n assert candidate(items = [[2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],queries = [99, 199, 299, 399, 499, 599, 699, 799, 899, 999, 1001]) == [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 3, 5, 7, 9, 11]) == [1, 3, 5, 7, 9, 10]\n assert candidate(items = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50]],queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [0, 0, 5, 5, 10, 10, 10, 15, 15, 20]\n assert candidate(items = [[50, 100], [25, 200], [75, 150], [100, 250], [125, 300]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == [0, 0, 200, 200, 200, 200, 200, 200, 200, 250, 250, 250, 300]\n assert candidate(items = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5]],queries = [10]) == [5]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(items = [[1, 50], [2, 40], [3, 30], [4, 20], [5, 10], [6, 5]],queries = [0, 1, 2, 3, 4, 5, 6, 7]) == [0, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [10, 60], [15, 70], [20, 80], [25, 90], [30, 100]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [10, 30, 50, 50, 50, 60, 60, 70, 70, 70, 80, 80, 90, 90, 90, 100]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(items = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5]],queries = [5, 10, 15]) == [0, 5, 5]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(items = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],queries = [5, 4, 3, 2, 1]) == [10, 10, 10, 10, 10]\n assert candidate(items = [[1, 10], [10, 1], [100, 100], [1000, 1], [10000, 10000], [100000, 1], [1000000, 1000000]],queries = [1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000, 500000, 1000000, 1500000]) == [10, 10, 10, 10, 100, 100, 100, 100, 10000, 10000, 10000, 10000, 1000000, 1000000]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[100, 500], [200, 1000], [300, 1500], [400, 2000], [500, 2500]],queries = [50, 150, 250, 350, 450, 550]) == [0, 500, 1000, 1500, 2000, 2500]\n assert candidate(items = [[1, 10], [3, 20], [2, 30], [5, 40], [4, 50]],queries = [1, 2, 3, 4, 5]) == [10, 30, 30, 50, 50]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1]) == [10]\n assert candidate(items = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [1, 5, 9, 13, 17, 19, 19, 19, 19, 19]\n assert candidate(items = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(items = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]],queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(items = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8], [100000000, 9], [1000000000, 10]],queries = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [5, 6, 7, 8, 9, 10, 10, 10, 10, 10]\n assert candidate(items = [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]],queries = [15, 25, 35, 45, 55]) == [5, 5, 5, 5, 5]\n assert candidate(items = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10]],queries = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1]) == [10]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20]\n assert candidate(items = [[1, 10], [10, 20], [100, 30], [1000, 40], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8], [100000000, 9], [1000000000, 10]],queries = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [10, 20, 30, 40, 40, 40, 40, 40, 40, 40]\n assert candidate(items = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500]],queries = [5, 15, 25, 35, 45, 55]) == [0, 100, 200, 300, 400, 500]\n assert candidate(items = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [50, 150, 250, 350, 450, 550]) == [0, 100, 200, 300, 400, 500]\n assert candidate(items = [[1, 100], [50, 50], [100, 10], [150, 1], [200, 50], [250, 100], [300, 150], [350, 200], [400, 250], [450, 300]],queries = [25, 50, 75, 125, 175, 225, 275, 325, 375, 425]) == [100, 100, 100, 100, 100, 100, 100, 150, 200, 250]\n assert candidate(items = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]\n assert candidate(items = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [0, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(items = [[1000000000, 1], [999999999, 2], [999999998, 3], [999999997, 4], [999999996, 5]],queries = [1, 2, 3, 4, 5]) == [0, 0, 0, 0, 0]\n assert candidate(items = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [10, 15, 20, 25]) == [10, 16, 20, 20]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],queries = [1, 3, 5, 7, 9, 11, 13, 15]) == [1, 3, 5, 7, 9, 11, 13, 15]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(items = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5]],queries = [4, 5, 6]) == [0, 5, 5]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],queries = [1]) == [5]\n assert candidate(items = [[1, 2], [3, 5], [2, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]],queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [6, 8, 12, 16, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(items = [[1, 100], [100, 1], [1, 200], [100, 2], [1, 300], [100, 3], [1, 400], [100, 4], [1, 500], [100, 5]],queries = [1, 50, 100, 150, 200]) == [500, 500, 500, 500, 500]\n assert candidate(items = [[1, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1000000000], [1000000000, 1]],queries = [500000000, 1000000000]) == [1000000000, 1000000000]\n assert candidate(items = [[1000000000, 1], [2000000000, 2], [3000000000, 3], [4000000000, 4], [5000000000, 5]],queries = [500000000, 1500000000, 2500000000, 3500000000, 4500000000, 5500000000]) == [0, 1, 2, 3, 4, 5]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]\n assert candidate(items = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5]\n assert candidate(items = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9]],queries = [1, 2, 3, 4, 5, 6]) == [0, 0, 0, 0, 9, 9]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 20, 30, 40, 50, 50, 50, 50, 50, 50]\n assert candidate(items = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996]],queries = [1, 2, 3, 4, 5]) == [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]\n assert candidate(items = [[5, 20], [5, 18], [5, 16], [5, 14], [5, 12], [5, 10], [5, 8], [5, 6], [5, 4], [5, 2]],queries = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(items = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(items = [[1, 1], [2, 2], [2, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10]],queries = [2, 4, 6, 8, 10]) == [3, 7, 10, 10, 10]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1000000000, 1], [1, 1000000000], [500000000, 500000000], [250000000, 250000000]],queries = [1000000000, 1, 500000000, 250000000, 0]) == [1000000000, 1000000000, 1000000000, 1000000000, 0]\n assert candidate(items = [[1, 1000000000], [1000000000, 1]],queries = [1, 1000000000]) == [1000000000, 1000000000]\n assert candidate(items = [[100, 500], [200, 400], [300, 300], [400, 200], [500, 100]],queries = [50, 150, 250, 350, 450, 550]) == [0, 500, 500, 500, 500, 500]\n assert candidate(items = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(items = [[1000000000, 999999999], [1000000000, 1000000000], [1000000000, 1000000001]],queries = [1000000000, 999999999, 1000000001]) == [1000000001, 0, 1000000001]\n assert candidate(items = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700], [80, 800], [90, 900], [100, 1000]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(items = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],queries = [1, 3, 5, 7, 9, 11]) == [100, 300, 500, 700, 900, 1000]\n assert candidate(items = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]],queries = [1, 5, 10, 15, 20, 25, 30]) == [1, 9, 19, 19, 19, 19, 19]\n assert candidate(items = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]\n"}, "metadata": {"canonical_parameter_names": ["items", "queries"], "leetcode_dataset_entry_point": "Solution().maximumBeauty", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumBeauty(self, items: list[list[int]], queries: list[int]) -> list[int]:", "container": "Solution", "callable": "maximumBeauty", "parameters": [{"name": "items", "type": "list[list[int]]"}, {"name": "queries", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2071, "task_id": "maximum-number-of-tasks-you-can-assign", "difficulty": "Hard", "problem_description": "You have n tasks and m workers. Each task has a strength requirement stored in a 0-indexed integer array tasks, with the ith task requiring tasks[i] strength to complete. The strength of each worker is stored in a 0-indexed integer array workers, with the jth worker having workers[j] strength. Each worker can only be assigned to a single task and must have a strength greater than or equal to the task's strength requirement (i.e., workers[j] >= tasks[i]).\nAdditionally, you have pills magical pills that will increase a worker's strength by strength. You can decide which workers receive the magical pills, however, you may only give each worker at most one magical pill.\nGiven the 0-indexed integer arrays tasks and workers and the integers pills and strength, return the maximum number of tasks that can be completed.\n \nExample 1:\n\nInput: tasks = [3,2,1], workers = [0,3,3], pills = 1, strength = 1\nOutput: 3\nExplanation:\nWe can assign the magical pill and tasks as follows:\n- Give the magical pill to worker 0.\n- Assign worker 0 to task 2 (0 + 1 >= 1)\n- Assign worker 1 to task 1 (3 >= 2)\n- Assign worker 2 to task 0 (3 >= 3)\n\nExample 2:\n\nInput: tasks = [5,4], workers = [0,0,0], pills = 1, strength = 5\nOutput: 1\nExplanation:\nWe can assign the magical pill and tasks as follows:\n- Give the magical pill to worker 0.\n- Assign worker 0 to task 0 (0 + 5 >= 5)\n\nExample 3:\n\nInput: tasks = [10,15,30], workers = [0,10,10,10,10], pills = 3, strength = 10\nOutput: 2\nExplanation:\nWe can assign the magical pills and tasks as follows:\n- Give the magical pill to worker 0 and worker 1.\n- Assign worker 0 to task 0 (0 + 10 >= 10)\n- Assign worker 1 to task 1 (10 + 10 >= 15)\nThe last pill is not given because it will not make any worker strong enough for the last task.\n\n \nConstraints:\n\nn == tasks.length\nm == workers.length\n1 <= n, m <= 5 * 104\n0 <= pills <= m\n0 <= tasks[i], workers[j], strength <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [100, 200, 300],workers = [50, 150, 250, 350],pills = 2,strength = 100) == 3\n assert candidate(tasks = [10, 20, 30],workers = [30, 40, 50],pills = 0,strength = 10) == 3\n assert candidate(tasks = [10, 15, 30],workers = [0, 10, 10, 10, 10],pills = 3,strength = 10) == 2\n assert candidate(tasks = [100, 200, 300],workers = [100, 100, 100, 100, 100],pills = 2,strength = 100) == 2\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 5,strength = 5) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 0,strength = 1) == 5\n assert candidate(tasks = [5, 5, 5, 5],workers = [1, 1, 1, 1],pills = 4,strength = 4) == 4\n assert candidate(tasks = [100, 200, 300],workers = [150, 250, 350],pills = 1,strength = 100) == 3\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 0,strength = 2) == 5\n assert candidate(tasks = [100, 200, 300],workers = [150, 250, 350],pills = 2,strength = 50) == 3\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [5, 15, 25, 35, 45],pills = 2,strength = 10) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 2,strength = 5) == 5\n assert candidate(tasks = [5, 4],workers = [0, 0, 0],pills = 1,strength = 5) == 1\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [1, 2, 3, 4, 5],pills = 5,strength = 10) == 1\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [5, 15, 25, 35, 45],pills = 0,strength = 10) == 4\n assert candidate(tasks = [9, 8, 7, 6, 5],workers = [4, 4, 4, 4, 4],pills = 5,strength = 5) == 5\n assert candidate(tasks = [3, 6, 7, 11],workers = [6, 8, 9],pills = 2,strength = 3) == 3\n assert candidate(tasks = [1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1],pills = 5,strength = 0) == 5\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [5, 15, 25, 35, 45],pills = 5,strength = 10) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 5,strength = 0) == 5\n assert candidate(tasks = [1, 1, 1, 1],workers = [1, 1, 1, 1],pills = 4,strength = 0) == 4\n assert candidate(tasks = [1, 10, 100, 1000],workers = [1, 10, 100, 1000],pills = 2,strength = 500) == 4\n assert candidate(tasks = [3, 2, 1],workers = [0, 3, 3],pills = 1,strength = 1) == 3\n assert candidate(tasks = [1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1],pills = 0,strength = 0) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],pills = 10,strength = 5) == 20\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pills = 0,strength = 1) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],workers = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],pills = 10,strength = 5) == 30\n assert candidate(tasks = [3, 6, 9, 12, 15],workers = [3, 6, 9, 12, 15],pills = 2,strength = 3) == 5\n assert candidate(tasks = [1000000000, 1000000000, 1000000000],workers = [1000000000, 1000000000, 1000000000],pills = 3,strength = 0) == 3\n assert candidate(tasks = [1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1],pills = 3,strength = 1) == 5\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],pills = 10,strength = 0) == 10\n assert candidate(tasks = [50, 100, 150, 200, 250],workers = [40, 80, 120, 160, 200],pills = 3,strength = 60) == 4\n assert candidate(tasks = [5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],pills = 5,strength = 20) == 11\n assert candidate(tasks = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],workers = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],pills = 5,strength = 1) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500],workers = [100, 150, 200, 250, 300],pills = 2,strength = 100) == 4\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pills = 10,strength = 0) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 5,strength = 10) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [1, 1, 1, 1, 1],pills = 5,strength = 4) == 5\n assert candidate(tasks = [3, 6, 9, 12, 15],workers = [3, 6, 9, 12, 15],pills = 0,strength = 10) == 5\n assert candidate(tasks = [500000000, 500000000, 500000000, 500000000, 500000000],workers = [500000000, 500000000, 500000000, 500000000, 500000000],pills = 5,strength = 0) == 5\n assert candidate(tasks = [1, 3, 5, 7, 9],workers = [10, 20, 30, 40, 50],pills = 2,strength = 5) == 5\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pills = 5,strength = 0) == 10\n assert candidate(tasks = [1000000000],workers = [999999999],pills = 1,strength = 1) == 1\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [10, 20, 30, 40, 50],pills = 2,strength = 5) == 5\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950],pills = 5,strength = 100) == 9\n assert candidate(tasks = [1000, 2000, 3000],workers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pills = 5,strength = 500) == 1\n assert candidate(tasks = [5, 15, 25, 35, 45],workers = [1, 11, 21, 31, 41],pills = 2,strength = 10) == 4\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],workers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],pills = 15,strength = 1) == 15\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 5,strength = 1) == 10\n assert candidate(tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],workers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],pills = 10,strength = 0) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],workers = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400],pills = 10,strength = 20) == 20\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pills = 10,strength = 0) == 10\n assert candidate(tasks = [1000, 2000, 3000, 4000, 5000],workers = [500, 1000, 1500, 2000, 2500],pills = 4,strength = 1000) == 3\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [10, 20, 30, 40, 50],pills = 0,strength = 0) == 5\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],workers = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145],pills = 7,strength = 50) == 15\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],pills = 5,strength = 5) == 10\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15],workers = [2, 4, 6, 8, 10, 12, 14, 16],pills = 3,strength = 2) == 8\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pills = 5,strength = 2) == 10\n assert candidate(tasks = [5, 10, 15, 20, 25, 30],workers = [10, 15, 20, 25, 30, 35],pills = 3,strength = 5) == 6\n assert candidate(tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 3,strength = 5) == 10\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pills = 5,strength = 50) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],pills = 5,strength = 10) == 20\n assert candidate(tasks = [100, 200, 300, 400, 500],workers = [150, 250, 350, 450, 550],pills = 3,strength = 100) == 5\n assert candidate(tasks = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 3,strength = 20) == 10\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],workers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pills = 5,strength = 1) == 10\n assert candidate(tasks = [5, 15, 25, 35, 45],workers = [1, 1, 1, 1, 1],pills = 5,strength = 40) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],pills = 10,strength = 4) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pills = 5,strength = 50) == 10\n assert candidate(tasks = [50, 50, 50, 50, 50],workers = [100, 100, 100, 100, 100],pills = 2,strength = 10) == 5\n assert candidate(tasks = [500, 400, 300, 200, 100],workers = [100, 200, 300, 400, 500],pills = 2,strength = 100) == 5\n assert candidate(tasks = [100, 150, 200, 250, 300],workers = [50, 100, 150, 200, 250],pills = 2,strength = 50) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pills = 5,strength = 1) == 10\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],pills = 10,strength = 0) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500],workers = [100, 200, 300, 400, 500],pills = 5,strength = 500) == 5\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 5,strength = 0) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],workers = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 7,strength = 3) == 15\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],workers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pills = 5,strength = 0) == 10\n assert candidate(tasks = [999999999, 999999998, 999999997, 999999996, 999999995],workers = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],pills = 2,strength = 1) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 0,strength = 1) == 10\n assert candidate(tasks = [5, 25, 50, 75, 100],workers = [10, 20, 30, 40, 50],pills = 3,strength = 20) == 3\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pills = 0,strength = 0) == 10\n assert candidate(tasks = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 10,strength = 9) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],workers = [900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800],pills = 10,strength = 200) == 20\n assert candidate(tasks = [1, 5, 9, 13, 17, 21, 25],workers = [2, 6, 10, 14, 18, 22, 26],pills = 3,strength = 1) == 7\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 4,strength = 10) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pills = 5,strength = 1) == 10\n assert candidate(tasks = [500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],workers = [500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],pills = 3,strength = 200) == 11\n assert candidate(tasks = [1000, 2000, 3000, 4000, 5000],workers = [500, 1500, 2500, 3500, 4500],pills = 2,strength = 1000) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 10,strength = 1) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pills = 5,strength = 1) == 10\n assert candidate(tasks = [1000000000, 1000000000],workers = [1000000000, 1000000000],pills = 1,strength = 0) == 2\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 10,strength = 10) == 10\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],pills = 5,strength = 10) == 2\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],pills = 5,strength = 1) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 0,strength = 0) == 10\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],workers = [20, 22, 24, 26, 28, 30, 32, 34, 36, 38],pills = 5,strength = 10) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],workers = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 5,strength = 10) == 20\n assert candidate(tasks = [90, 80, 70, 60, 50, 40, 30, 20, 10],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90],pills = 4,strength = 20) == 9\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pills = 0,strength = 100) == 10\n assert candidate(tasks = [50, 60, 70, 80, 90],workers = [40, 50, 60, 70, 80],pills = 3,strength = 10) == 4\n assert candidate(tasks = [500, 500, 500, 500, 500],workers = [250, 250, 250, 250, 250],pills = 5,strength = 250) == 5\n assert candidate(tasks = [10, 10, 10, 10, 10],workers = [1, 1, 1, 1, 1],pills = 5,strength = 9) == 5\n assert candidate(tasks = [1000000000, 1000000000, 1000000000],workers = [1000000000, 1000000000, 1000000000],pills = 1,strength = 0) == 3\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950],pills = 5,strength = 50) == 9\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950],pills = 10,strength = 100) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500, 600],workers = [100, 200, 300, 400, 500, 600],pills = 0,strength = 0) == 6\n assert candidate(tasks = [1000000000],workers = [1000000000],pills = 0,strength = 0) == 1\n assert candidate(tasks = [5, 15, 25, 35, 45, 55],workers = [10, 20, 30, 40, 50, 60],pills = 3,strength = 10) == 6\n assert candidate(tasks = [1000000000],workers = [1000000000],pills = 1,strength = 0) == 1\n assert candidate(tasks = [9, 8, 7, 6, 5, 4, 3, 2, 1],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9],pills = 0,strength = 2) == 9\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],pills = 5,strength = 10) == 10\n assert candidate(tasks = [1, 3, 5, 7, 9],workers = [2, 4, 6, 8, 10],pills = 2,strength = 1) == 5\n assert candidate(tasks = [10000, 20000, 30000, 40000, 50000],workers = [1000, 2000, 3000, 4000, 5000],pills = 5,strength = 10000) == 1\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],pills = 5,strength = 5) == 9\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [100, 200, 300, 400, 500],pills = 5,strength = 500) == 5\n assert candidate(tasks = [500000000, 500000000],workers = [500000000, 500000000],pills = 2,strength = 0) == 2\n assert candidate(tasks = [50, 100, 150, 200, 250],workers = [100, 150, 200, 250, 300],pills = 3,strength = 50) == 5\n assert candidate(tasks = [9, 18, 27, 36, 45, 54],workers = [12, 24, 36, 48, 60, 72],pills = 5,strength = 6) == 6\n assert candidate(tasks = [10, 10, 10, 10, 10],workers = [10, 10, 10, 10, 10],pills = 5,strength = 0) == 5\n"}, "metadata": {"canonical_parameter_names": ["tasks", "workers", "pills", "strength"], "leetcode_dataset_entry_point": "Solution().maxTaskAssign", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxTaskAssign(self, tasks: list[int], workers: list[int], pills: int, strength: int) -> int:", "container": "Solution", "callable": "maxTaskAssign", "parameters": [{"name": "tasks", "type": "list[int]"}, {"name": "workers", "type": "list[int]"}, {"name": "pills", "type": "int"}, {"name": "strength", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2073, "task_id": "time-needed-to-buy-tickets", "difficulty": "Easy", "problem_description": "There are n people in a line queuing to buy tickets, where the 0th person is at the front of the line and the (n - 1)th person is at the back of the line.\nYou are given a 0-indexed integer array tickets of length n where the number of tickets that the ith person would like to buy is tickets[i].\nEach person takes exactly 1 second to buy a ticket. A person can only buy 1 ticket at a time and has to go back to the end of the line (which happens instantaneously) in order to buy more tickets. If a person does not have any tickets left to buy, the person will leave the line.\nReturn the time taken for the person initially at position k (0-indexed) to finish buying tickets.\n \nExample 1:\n\nInput: tickets = [2,3,2], k = 2\nOutput: 6\nExplanation:\n\nThe queue starts as [2,3,2], where the kth person is underlined.\nAfter the person at the front has bought a ticket, the queue becomes [3,2,1] at 1 second.\nContinuing this process, the queue becomes [2,1,2] at 2 seconds.\nContinuing this process, the queue becomes [1,2,1] at 3 seconds.\nContinuing this process, the queue becomes [2,1] at 4 seconds. Note: the person at the front left the queue.\nContinuing this process, the queue becomes [1,1] at 5 seconds.\nContinuing this process, the queue becomes [1] at 6 seconds. The kth person has bought all their tickets, so return 6.\n\n\nExample 2:\n\nInput: tickets = [5,1,1,1], k = 0\nOutput: 8\nExplanation:\n\nThe queue starts as [5,1,1,1], where the kth person is underlined.\nAfter the person at the front has bought a ticket, the queue becomes [1,1,1,4] at 1 second.\nContinuing this process for 3 seconds, the queue becomes [4] at 4 seconds.\nContinuing this process for 4 seconds, the queue becomes [] at 8 seconds. The kth person has bought all their tickets, so return 8.\n\n\n \nConstraints:\n\nn == tickets.length\n1 <= n <= 100\n1 <= tickets[i] <= 100\n0 <= k < n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tickets = [5, 1, 1, 1],k = 0) == 8\n assert candidate(tickets = [4, 3, 2, 1],k = 1) == 9\n assert candidate(tickets = [100, 100, 100],k = 1) == 299\n assert candidate(tickets = [1],k = 0) == 1\n assert candidate(tickets = [10, 10, 10],k = 2) == 30\n assert candidate(tickets = [10, 10, 10],k = 0) == 28\n assert candidate(tickets = [10, 10, 10],k = 1) == 29\n assert candidate(tickets = [1, 2, 3, 4, 5],k = 4) == 15\n assert candidate(tickets = [2, 3, 2],k = 2) == 6\n assert candidate(tickets = [100, 100, 100],k = 2) == 300\n assert candidate(tickets = [1, 1, 1, 1],k = 2) == 3\n assert candidate(tickets = [1, 1, 1, 1],k = 1) == 2\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 19) == 110\n assert candidate(tickets = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 10) == 59\n assert candidate(tickets = [9, 3, 5, 7, 1, 2, 6],k = 4) == 5\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 91\n assert candidate(tickets = [7, 2, 9, 1, 8, 3, 6, 4, 5],k = 6) == 39\n assert candidate(tickets = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 15) == 86\n assert candidate(tickets = [1, 2, 3, 4, 5, 4, 3, 2, 1],k = 8) == 9\n assert candidate(tickets = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 15) == 76\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 91\n assert candidate(tickets = [25, 30, 15, 20, 10],k = 3) == 85\n assert candidate(tickets = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == 44\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 4) == 25\n assert candidate(tickets = [5, 2, 3, 1, 4],k = 2) == 11\n assert candidate(tickets = [5, 1, 2, 3, 4],k = 0) == 15\n assert candidate(tickets = [3, 1, 5, 4, 2],k = 3) == 14\n assert candidate(tickets = [7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 99\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 10\n assert candidate(tickets = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 8) == 29\n assert candidate(tickets = [9, 3, 8, 4, 6, 7, 5, 2, 1],k = 1) == 19\n assert candidate(tickets = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19) == 20\n assert candidate(tickets = [1, 5, 3, 4, 2, 6, 7, 8],k = 5) == 31\n assert candidate(tickets = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 15) == 28\n assert candidate(tickets = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2],k = 10) == 192\n assert candidate(tickets = [5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1],k = 19) == 20\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 81\n assert candidate(tickets = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4) == 395\n assert candidate(tickets = [1, 2, 3, 4, 3, 2, 1],k = 5) == 12\n assert candidate(tickets = [5, 3, 5, 2, 4, 1, 3],k = 3) == 11\n assert candidate(tickets = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4],k = 10) == 43\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 85\n assert candidate(tickets = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5) == 16\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 45\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 9) == 90\n assert candidate(tickets = [1, 2, 3, 4, 5, 4, 3, 2, 1],k = 4) == 25\n assert candidate(tickets = [2, 6, 3, 4, 5, 1],k = 2) == 13\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 10\n assert candidate(tickets = [20, 1, 20, 1, 20],k = 2) == 61\n assert candidate(tickets = [25, 30, 5, 10, 15],k = 1) == 85\n assert candidate(tickets = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 8) == 9\n assert candidate(tickets = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 4) == 35\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 40\n assert candidate(tickets = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 0) == 45\n assert candidate(tickets = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 0) == 1\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 156\n assert candidate(tickets = [5, 4, 3, 2, 1],k = 0) == 15\n assert candidate(tickets = [4, 2, 3, 3, 1, 4, 2, 3],k = 5) == 22\n assert candidate(tickets = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 50) == 104\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == 210\n assert candidate(tickets = [5, 6, 7, 8, 9],k = 2) == 30\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 49) == 162\n assert candidate(tickets = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 6\n assert candidate(tickets = [10, 15, 5, 20, 25, 30, 5],k = 4) == 104\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 0) == 55\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 35\n assert candidate(tickets = [1, 5, 2, 3, 4, 5],k = 5) == 20\n assert candidate(tickets = [3, 1, 5, 2, 4, 6],k = 3) == 9\n assert candidate(tickets = [20, 15, 10, 5, 1],k = 0) == 51\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == 1\n assert candidate(tickets = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 19) == 20\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 41\n assert candidate(tickets = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 11\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 156\n assert candidate(tickets = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 9) == 30\n assert candidate(tickets = [10, 1, 10, 1, 10, 1, 10],k = 3) == 4\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 0) == 163\n assert candidate(tickets = [10, 5, 4, 6, 3, 8, 2],k = 4) == 19\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 55\n assert candidate(tickets = [2, 5, 3, 4, 1, 2],k = 2) == 13\n assert candidate(tickets = [10, 20, 30, 40, 50],k = 2) == 118\n assert candidate(tickets = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 0) == 393\n assert candidate(tickets = [3, 2, 1, 4, 5, 6],k = 5) == 21\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 238\n assert candidate(tickets = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 5) == 36\n assert candidate(tickets = [20, 15, 10, 5, 1],k = 1) == 46\n assert candidate(tickets = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 9) == 10\n assert candidate(tickets = [3, 3, 3, 3, 3],k = 2) == 13\n assert candidate(tickets = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 96\n assert candidate(tickets = [50, 50, 50, 50, 50],k = 2) == 248\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 7) == 38\n assert candidate(tickets = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],k = 9) == 110\n assert candidate(tickets = [7, 8, 9, 10, 11, 12, 13, 14],k = 5) == 79\n assert candidate(tickets = [3, 5, 2, 4, 1],k = 2) == 8\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 24\n assert candidate(tickets = [1, 1, 1, 2, 2, 2, 3, 3, 3],k = 6) == 16\n assert candidate(tickets = [5, 4, 3, 2, 1],k = 2) == 12\n assert candidate(tickets = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 8) == 29\n assert candidate(tickets = [50, 30, 20, 10, 90, 80, 70, 60],k = 4) == 410\n"}, "metadata": {"canonical_parameter_names": ["tickets", "k"], "leetcode_dataset_entry_point": "Solution().timeRequiredToBuy", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def timeRequiredToBuy(self, tickets: list[int], k: int) -> int:", "container": "Solution", "callable": "timeRequiredToBuy", "parameters": [{"name": "tickets", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2074, "task_id": "reverse-nodes-in-even-length-groups", "difficulty": "Medium", "problem_description": "You are given the head of a linked list.\nThe nodes in the linked list are sequentially assigned to non-empty groups whose lengths form the sequence of the natural numbers (1, 2, 3, 4, ...). The length of a group is the number of nodes assigned to it. In other words,\n\nThe 1st node is assigned to the first group.\nThe 2nd and the 3rd nodes are assigned to the second group.\nThe 4th, 5th, and 6th nodes are assigned to the third group, and so on.\n\nNote that the length of the last group may be less than or equal to 1 + the length of the second to last group.\nReverse the nodes in each group with an even length, and return the head of the modified linked list.\n \nExample 1:\n\n\nInput: head = [5,2,6,3,9,1,7,3,8,4]\nOutput: [5,6,2,3,9,1,4,8,3,7]\nExplanation:\n- The length of the first group is 1, which is odd, hence no reversal occurs.\n- The length of the second group is 2, which is even, hence the nodes are reversed.\n- The length of the third group is 3, which is odd, hence no reversal occurs.\n- The length of the last group is 4, which is even, hence the nodes are reversed.\n\nExample 2:\n\n\nInput: head = [1,1,0,6]\nOutput: [1,0,1,6]\nExplanation:\n- The length of the first group is 1. No reversal occurs.\n- The length of the second group is 2. The nodes are reversed.\n- The length of the last group is 1. No reversal occurs.\n\nExample 3:\n\n\nInput: head = [1,1,0,6,5]\nOutput: [1,0,1,5,6]\nExplanation:\n- The length of the first group is 1. No reversal occurs.\n- The length of the second group is 2. The nodes are reversed.\n- The length of the last group is 2. The nodes are reversed.\n\n \nConstraints:\n\nThe number of nodes in the list is in the range [1, 105].\n0 <= Node.val <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_list(candidate(head = list_node([1, 2, 3])), list_node([1, 3, 2]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5])), list_node([1, 3, 2, 5, 4]))\n assert is_same_list(candidate(head = list_node([1, 2])), list_node([1, 2]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4])), list_node([1, 3, 2, 4]))\n assert is_same_list(candidate(head = list_node([1, 1, 0, 6])), list_node([1, 0, 1, 6]))\n assert is_same_list(candidate(head = list_node([100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991])), list_node([100000, 99998, 99999, 99997, 99996, 99995, 99991, 99992, 99993, 99994]))\n assert is_same_list(candidate(head = list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])), list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9])), list_node([1, 3, 2, 4, 5, 6, 7, 8, 9]))\n assert is_same_list(candidate(head = list_node([1, 1, 0, 6, 5])), list_node([1, 0, 1, 5, 6]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11]))\n assert is_same_list(candidate(head = list_node([1])), list_node([1]))\n assert is_same_list(candidate(head = list_node([5, 2, 6, 3, 9, 1, 7, 3, 8, 4])), list_node([5, 6, 2, 3, 9, 1, 4, 8, 3, 7]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7])), list_node([1, 3, 2, 4, 5, 6, 7]))\n assert is_same_list(candidate(head = list_node([0])), list_node([0]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 12, 11]))\n assert is_same_list(candidate(head = list_node([2, 4, 3])), list_node([2, 3, 4]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90])), list_node([10, 30, 20, 40, 50, 60, 70, 80, 90]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6])), list_node([1, 3, 2, 4, 5, 6]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8])), list_node([1, 3, 2, 4, 5, 6, 8, 7]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 36, 35, 34, 33, 32, 31, 30, 29, 40, 39, 38, 37]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10])), list_node([1, 1, 1, 2, 2, 2, 4, 3, 3, 3, 4, 4, 5, 5, 5, 7, 7, 7, 6, 6, 6, 8, 8, 8, 9, 9, 9, 10, 10, 10]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59])), list_node([1, 5, 3, 7, 9, 11, 19, 17, 15, 13, 21, 23, 25, 27, 29, 41, 39, 37, 35, 33, 31, 43, 45, 47, 49, 51, 53, 55, 59, 57]))\n assert is_same_list(candidate(head = list_node([29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([29, 27, 28, 26, 25, 24, 20, 21, 22, 23, 19, 18, 17, 16, 15, 9, 10, 11, 12, 13, 14, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 32, 31, 30, 29]))\n assert is_same_list(candidate(head = list_node([1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26])), list_node([1, 2, 3, 5, 4, 7, 11, 8, 9, 6, 10, 13, 12, 15, 14, 20, 21, 18, 19, 16, 17, 26, 27, 24, 25, 22, 23]))\n assert is_same_list(candidate(head = list_node([23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([23, 21, 22, 20, 19, 18, 14, 15, 16, 17, 13, 12, 11, 10, 9, 3, 4, 5, 6, 7, 8, 1, 2]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 16, 17, 18]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])), list_node([5, 3, 4, 2, 1, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 25, 24, 23, 22]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31])), list_node([1, 5, 3, 7, 9, 11, 19, 17, 15, 13, 21, 23, 25, 27, 29, 31]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 19, 18, 17, 16]))\n assert is_same_list(candidate(head = list_node([1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6])), list_node([1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41])), list_node([1, 5, 3, 7, 9, 11, 19, 17, 15, 13, 21, 23, 25, 27, 29, 41, 39, 37, 35, 33, 31]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4])), list_node([10, 8, 9, 7, 6, 5, 1, 2, 3, 4, 10, 9, 8, 7, 6, 10, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34])), list_node([2, 6, 4, 8, 10, 12, 20, 18, 16, 14, 22, 24, 26, 28, 30, 34, 32]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([5, 3, 2, 6, 9, 1, 7, 3, 8, 4, 2, 7, 5, 9, 3, 6, 8, 0, 1, 2])), list_node([5, 2, 3, 6, 9, 1, 4, 8, 3, 7, 2, 7, 5, 9, 3, 6, 8, 0, 1, 2]))\n assert is_same_list(candidate(head = list_node([1, 1, 0, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0])), list_node([1, 0, 1, 6, 5, 4, 0, 1, 2, 3, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49])), list_node([1, 5, 3, 7, 9, 11, 19, 17, 15, 13, 21, 23, 25, 27, 29, 41, 39, 37, 35, 33, 31, 49, 47, 45, 43]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44])), list_node([2, 6, 4, 8, 10, 12, 20, 18, 16, 14, 22, 24, 26, 28, 30, 42, 40, 38, 36, 34, 32, 44]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15])), list_node([9, 7, 8, 6, 5, 4, 0, 1, 2, 3, -1, -2, -3, -4, -5, -11, -10, -9, -8, -7, -6, -15, -14, -13, -12]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 36, 35, 34, 33, 32, 31, 30, 29]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200])), list_node([10, 30, 20, 40, 50, 60, 100, 90, 80, 70, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([5, 1, 9, 3, 7, 2, 6, 4, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24])), list_node([5, 9, 1, 3, 7, 2, 10, 8, 4, 6, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 36, 35, 34, 33, 32, 31, 30, 29, 37, 38, 39, 40, 41, 42, 43, 44, 45, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4])), list_node([9, 7, 8, 6, 5, 4, 0, 1, 2, 3, 9, 8, 7, 6, 5, 9, 0, 1, 2, 3, 4, 8, 7, 6, 5, 4]))\n assert is_same_list(candidate(head = list_node([5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23])), list_node([5, 2, 1, 3, 4, 5, 9, 8, 7, 6, 10, 11, 12, 13, 14, 20, 19, 18, 17, 16, 15, 21, 22, 23]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0])), list_node([9, 7, 8, 6, 5, 4, 0, 1, 2, 3, 9, 8, 7, 6, 5, 9, 0, 1, 2, 3, 4, 8, 7, 6, 5, 4, 3, 2, 0, 1]))\n assert is_same_list(candidate(head = list_node([50000, 40000, 30000, 20000, 10000, 0, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000])), list_node([50000, 30000, 40000, 20000, 10000, 0, 40000, 30000, 20000, 10000, 50000, 60000, 70000, 80000, 90000, 100000]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62])), list_node([2, 6, 4, 8, 10, 12, 20, 18, 16, 14, 22, 24, 26, 28, 30, 42, 40, 38, 36, 34, 32, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62]))\n assert is_same_list(candidate(head = list_node([1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41, 40, 43, 42, 45, 44, 47, 46, 49, 48, 51, 50])), list_node([1, 2, 3, 5, 4, 7, 11, 8, 9, 6, 10, 13, 12, 15, 14, 20, 21, 18, 19, 16, 17, 23, 22, 25, 24, 27, 26, 29, 37, 34, 35, 32, 33, 30, 31, 28, 36, 39, 38, 41, 40, 43, 42, 45, 44, 50, 51, 48, 49, 46, 47]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1])), list_node([0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]))\n assert is_same_list(candidate(head = list_node([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13])), list_node([1, 2, 1, 2, 3, 3, 5, 5, 4, 4, 6, 6, 7, 7, 8, 11, 10, 10, 9, 9, 8, 11, 12, 12, 13, 13]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15])), list_node([1, 2, 1, 2, 3, 3, 5, 5, 4, 4, 6, 6, 7, 7, 8, 11, 10, 10, 9, 9, 8, 11, 12, 12, 13, 13, 14, 14, 15, 15]))\n assert is_same_list(candidate(head = list_node([1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16, 17, 19, 18, 20, 21, 23, 22, 24, 25, 27, 26, 28, 29, 30])), list_node([1, 2, 3, 4, 5, 7, 11, 9, 8, 6, 10, 12, 13, 15, 14, 21, 20, 18, 19, 17, 16, 23, 22, 24, 25, 27, 26, 28, 30, 29]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 14, 13, 12, 11]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 30, 29]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 23, 22]))\n assert is_same_list(candidate(head = list_node([27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([27, 25, 26, 24, 23, 22, 18, 19, 20, 21, 17, 16, 15, 14, 13, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 17, 16]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33])), list_node([1, 5, 3, 7, 9, 11, 19, 17, 15, 13, 21, 23, 25, 27, 29, 33, 31]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1])), list_node([0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1]))\n assert is_same_list(candidate(head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120])), list_node([5, 15, 10, 20, 25, 30, 50, 45, 40, 35, 55, 60, 65, 70, 75, 105, 100, 95, 90, 85, 80, 110, 115, 120]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42])), list_node([2, 6, 4, 8, 10, 12, 20, 18, 16, 14, 22, 24, 26, 28, 30, 42, 40, 38, 36, 34, 32]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 36, 35, 34, 33, 32, 31, 30, 29, 37, 38, 39, 40, 41, 42, 43, 44, 45, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 80, 79]))\n assert is_same_list(candidate(head = list_node([5, 2, 6, 3, 9, 1, 7, 3, 8, 4, 10, 11, 12, 13, 14, 15, 16])), list_node([5, 6, 2, 3, 9, 1, 4, 8, 3, 7, 10, 11, 12, 13, 14, 16, 15]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17])), list_node([1, 2, 1, 2, 3, 3, 5, 5, 4, 4, 6, 6, 7, 7, 8, 11, 10, 10, 9, 9, 8, 11, 12, 12, 13, 13, 14, 14, 17, 17, 16, 16, 15, 15]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23])), list_node([10, 8, 9, 7, 6, 5, 1, 2, 3, 4, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 23, 22]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])), list_node([10, 8, 9, 7, 6, 5, 1, 2, 3, 4, 0, 11, 12, 13, 14, 20, 19, 18, 17, 16, 15, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 36, 35, 34, 33, 32, 31, 30, 29, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10])), list_node([10, 8, 9, 7, 6, 5, 1, 2, 3, 4, 0, -1, -2, -3, -4, -10, -9, -8, -7, -6, -5]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24])), list_node([5, 3, 4, 2, 1, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([30, 28, 29, 27, 26, 25, 21, 22, 23, 24, 20, 19, 18, 17, 16, 10, 11, 12, 13, 14, 15, 9, 8, 7, 6, 5, 4, 3, 1, 2]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40])), list_node([2, 6, 4, 8, 10, 12, 20, 18, 16, 14, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1])), list_node([0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0]))\n assert is_same_list(candidate(head = list_node([49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1])), list_node([49, 45, 47, 43, 41, 39, 31, 33, 35, 37, 29, 27, 25, 23, 21, 9, 11, 13, 15, 17, 19, 1, 3, 5, 7]))\n assert is_same_list(candidate(head = list_node([50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([50, 48, 49, 47, 46, 45, 41, 42, 43, 44, 40, 39, 38, 37, 36, 30, 31, 32, 33, 34, 35, 29, 28, 27, 26, 25, 24, 23, 15, 16, 17, 18, 19, 20, 21, 22, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([9, 7, 8, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250])), list_node([10, 30, 20, 40, 50, 60, 100, 90, 80, 70, 110, 120, 130, 140, 150, 210, 200, 190, 180, 170, 160, 250, 240, 230, 220]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 16]))\n assert is_same_list(candidate(head = list_node([1, 1, 0, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([1, 0, 1, 6, 5, 4, 0, 1, 2, 3, 9, 8, 7, 6, 5, 1, 2, 3, 4]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 25, 24, 23, 22]))\n assert is_same_list(candidate(head = list_node([26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([26, 24, 25, 23, 22, 21, 17, 18, 19, 20, 16, 15, 14, 13, 12, 6, 7, 8, 9, 10, 11, 5, 4, 3, 2, 1]))\n"}, "metadata": {"canonical_parameter_names": ["head"], "leetcode_dataset_entry_point": "Solution().reverseEvenLengthGroups", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def reverseEvenLengthGroups(self, head: ListNode | None) -> ListNode | None:", "container": "Solution", "callable": "reverseEvenLengthGroups", "parameters": [{"name": "head", "type": "ListNode | None"}], "return_type": "ListNode | None", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2075, "task_id": "decode-the-slanted-ciphertext", "difficulty": "Medium", "problem_description": "A string originalText is encoded using a slanted transposition cipher to a string encodedText with the help of a matrix having a fixed number of rows rows.\noriginalText is placed first in a top-left to bottom-right manner.\n\nThe blue cells are filled first, followed by the red cells, then the yellow cells, and so on, until we reach the end of originalText. The arrow indicates the order in which the cells are filled. All empty cells are filled with ' '. The number of columns is chosen such that the rightmost column will not be empty after filling in originalText.\nencodedText is then formed by appending all characters of the matrix in a row-wise fashion.\n\nThe characters in the blue cells are appended first to encodedText, then the red cells, and so on, and finally the yellow cells. The arrow indicates the order in which the cells are accessed.\nFor example, if originalText = \"cipher\" and rows = 3, then we encode it in the following manner:\n\nThe blue arrows depict how originalText is placed in the matrix, and the red arrows denote the order in which encodedText is formed. In the above example, encodedText = \"ch ie pr\".\nGiven the encoded string encodedText and number of rows rows, return the original string originalText.\nNote: originalText does not have any trailing spaces ' '. The test cases are generated such that there is only one possible originalText.\n \nExample 1:\n\nInput: encodedText = \"ch ie pr\", rows = 3\nOutput: \"cipher\"\nExplanation: This is the same example described in the problem description.\n\nExample 2:\n\n\nInput: encodedText = \"iveo eed l te olc\", rows = 4\nOutput: \"i love leetcode\"\nExplanation: The figure above denotes the matrix that was used to encode originalText. \nThe blue arrows show how we can find originalText from encodedText.\n\nExample 3:\n\n\nInput: encodedText = \"coding\", rows = 1\nOutput: \"coding\"\nExplanation: Since there is only 1 row, both originalText and encodedText are the same.\n\n \nConstraints:\n\n0 <= encodedText.length <= 106\nencodedText consists of lowercase English letters and ' ' only.\nencodedText is a valid encoding of some originalText that does not have trailing spaces.\n1 <= rows <= 1000\nThe testcases are generated such that there is only one possible originalText.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(encodedText = \"a\",rows = 1) == \"a\"\n assert candidate(encodedText = \"abcd efg hijk\",rows = 3) == \"aeibfjcgd\"\n assert candidate(encodedText = \"a b c d\",rows = 2) == \"a c b\"\n assert candidate(encodedText = \"coding\",rows = 1) == \"coding\"\n assert candidate(encodedText = \"abc def ghi jkl mno\",rows = 5) == \"adgbec\"\n assert candidate(encodedText = \"ab c de\",rows = 2) == \"a bd ec\"\n assert candidate(encodedText = \"ch ie pr\",rows = 3) == \"cipher\"\n assert candidate(encodedText = \"iveo eed l te olc\",rows = 4) == \"i love leetcode\"\n assert candidate(encodedText = \"python programming is fun\",rows = 4) == \"ppm yriftonuhggorn\"\n assert candidate(encodedText = \"algorithms and data structures\",rows = 5) == \"ah telmdrsgsauo trai\"\n assert candidate(encodedText = \"hello world from leetcode challenges\",rows = 6) == \"hrmt nel c gld ocl do fw\"\n assert candidate(encodedText = \"t a c o s e q u i r r e s e l l f o o d s o u p\",rows = 5) == \"t e s q f a s o u o c e u i o o l r s\"\n assert candidate(encodedText = \"one two three four five six\",rows = 3) == \"oh nrfeei ev e t wf oos ui rx\"\n assert candidate(encodedText = \"programming challenges are fun\",rows = 4) == \"pilrrneeogn g gfrceahm\"\n assert candidate(encodedText = \"filling the matrix in a slanted manner\",rows = 6) == \"f t aaitr nnlhi tnlexaei n g\"\n assert candidate(encodedText = \"p y trh e t s o n a\",rows = 3) == \"pe y t t nrs h\"\n assert candidate(encodedText = \"m e t a l l i c a\",rows = 3) == \"mai elc t\"\n assert candidate(encodedText = \"\",rows = 10) == \"\"\n assert candidate(encodedText = \"padding with spaces at the end \",rows = 5) == \"pwc aiet dtsh dh e i n g a s\"\n assert candidate(encodedText = \"a b c d e f g h i\",rows = 9) == \"abcd\"\n assert candidate(encodedText = \"qo su me ve rt\",rows = 5) == \"qsmvoue\"\n assert candidate(encodedText = \"sh jfuew xq z r e\",rows = 3) == \"sw h x jqrf u\"\n assert candidate(encodedText = \"this is a test string\",rows = 5) == \"ti ghstsi esa\"\n assert candidate(encodedText = \"abcdef ghijkl mnopqr stuvwx yz\",rows = 5) == \"agmsybhntzcioudjpekf\"\n assert candidate(encodedText = \"a quick brown fox jumps over the lazy dog\",rows = 6) == \"a fp z bostqrx uo iwc\"\n assert candidate(encodedText = \"wcy hmu eai xfi\",rows = 3) == \"wu c xy f ei ah\"\n assert candidate(encodedText = \"two words\",rows = 1) == \"two words\"\n assert candidate(encodedText = \"th qzih xof c \",rows = 3) == \"th h c x qoz\"\n assert candidate(encodedText = \"ab c d e f g h i j\",rows = 10) == \"a b ef d c\"\n assert candidate(encodedText = \"programming in python is fun\",rows = 3) == \"pgnr oiignsr apfmyumti\"\n assert candidate(encodedText = \"spaces in between words\",rows = 4) == \"s twpiwoanerc ede ns\"\n assert candidate(encodedText = \"qjewukcuvm xs ezmrg\",rows = 4) == \"qcsmju rev wmu\"\n assert candidate(encodedText = \"this is a longer example to test the decoding function\",rows = 8) == \"t epteharlei esle oi\"\n assert candidate(encodedText = \"q w e r t y u i o p\",rows = 4) == \"q y r w\"\n assert candidate(encodedText = \"a q o q r s\",rows = 6) == \"aqoq\"\n assert candidate(encodedText = \"abcdefghi jklmnop qrstuv wx yz\",rows = 5) == \"ahntybiouzc pvdj ekf\"\n assert candidate(encodedText = \"i s l a n d o f d r e a m s\",rows = 3) == \"i r s e o l a f a m n\"\n assert candidate(encodedText = \"s h e e l s s f i r e\",rows = 5) == \"se hls e\"\n assert candidate(encodedText = \"abc def ghi jkl mno pqr stu vwx yz\",rows = 6) == \"afjosb k cgl hd\"\n assert candidate(encodedText = \"hello world this is a test\",rows = 5) == \"hwtsteoh elri slls od\"\n assert candidate(encodedText = \"c o n s t a n t i n o p o l i s\",rows = 6) == \"csnno ott n\"\n assert candidate(encodedText = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",rows = 5) == \"a l w g r b m x h s c n y i t d o j e\"\n assert candidate(encodedText = \"this is a test of the emergency broadcast system\",rows = 6) == \"t tedththnceieecamss ys te i mso\"\n assert candidate(encodedText = \"x w v u t s r q p o n m l k j i h g f e d c b a\",rows = 26) == \"x\"\n assert candidate(encodedText = \"keep it secret keep it safe\",rows = 6) == \"kicketre p\"\n assert candidate(encodedText = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",rows = 26) == \"a\"\n assert candidate(encodedText = \"hello world from the other side\",rows = 4) == \"hr eeltrldh l esof rw\"\n assert candidate(encodedText = \"data structures and algorithms\",rows = 8) == \"d uast\"\n assert candidate(encodedText = \"abcdefghij klmnopqrst uvwxyz\",rows = 3) == \"a tbk cludmvenwfoxgpyhqi\"\n assert candidate(encodedText = \"singleword\",rows = 10) == \"s\"\n assert candidate(encodedText = \"the quick brown fox jumps over the lazy dog\",rows = 6) == \"tkfshdh o eoebxo r vqojuwi\"\n assert candidate(encodedText = \"thisisaverylongstringthatwillbereconstructedusingtheslantedciphertechnique\",rows = 7) == \"tlhcunehoaostcintniehsgwsndnisitgcstlrtarluvibenr\"\n assert candidate(encodedText = \"one\",rows = 1) == \"one\"\n assert candidate(encodedText = \"z y x w v u t s r q p o n m l k j i h g f e d c b a\",rows = 5) == \"z o d t i y n c s h x m b r g w l q v\"\n assert candidate(encodedText = \"t h e q u i c k b r o w n f o x j u m p s o v e r t h e l a z y d o g\",rows = 7) == \"tcnjohy hk uve ebfme d qropr uox i\"\n assert candidate(encodedText = \"abcdefgh ijklmnop qrstuvwx yz this is a test\",rows = 5) == \"ajs ibkt sclu dmv aenw foxtgp h\"\n assert candidate(encodedText = \"a quick movement of the enemy will jeopardize five gunboats\",rows = 7) == \"aofme b v yofoqet piumhwaieeicn kt\"\n assert candidate(encodedText = \"slantedtranspositioncipheriscomplexandfun\",rows = 7) == \"sdpoeltonarsnat\"\n assert candidate(encodedText = \"one two three four five six seven eight nine ten eleven twelve\",rows = 4) == \"oun nr ee el fietigvwvheoetn tsnthiiwrxnee eles ef\"\n assert candidate(encodedText = \"abcdefghij\",rows = 1) == \"abcdefghij\"\n assert candidate(encodedText = \"x y z \",rows = 3) == \"x zy\"\n assert candidate(encodedText = \"machine learning is fascinating\",rows = 7) == \"mnagaerc h\"\n assert candidate(encodedText = \"lqtk e o mu yzfe ot i g rya wne l oxtesn gdeo\",rows = 5) == \"luie q gtygldkz e frooeeyx aoo\"\n assert candidate(encodedText = \"p r o g r a m m i n g l a n g u a g e s\",rows = 5) == \"p n g a n r g e m g o m g\"\n assert candidate(encodedText = \"wecoloveleetcode\",rows = 2) == \"weeectocloodvee\"\n assert candidate(encodedText = \"example of a very long encoded text\",rows = 7) == \"e eon x rnca aygm po lfe\"\n assert candidate(encodedText = \"longer text with multiple spaces in between\",rows = 3) == \"lheo snm guielnrt ibtpeeltxewt e sewpi\"\n assert candidate(encodedText = \"it wof eit ss dp\",rows = 4) == \"iftst w\"\n assert candidate(encodedText = \"a b c d e\",rows = 5) == \"a b c\"\n assert candidate(encodedText = \"abcd efgh ijkl mnop qrst uvwx yz\",rows = 5) == \"ag rxbhms c ntdio je\"\n assert candidate(encodedText = \"the quick brown fox jumps over lazy dogs\",rows = 4) == \"trmzhopyews n dq ooufvgioescxrk\"\n assert candidate(encodedText = \"special characters !@#$%^&*() are allowed in the text\",rows = 10) == \"s c * ep t!( e e@)ccr#ihsaal\"\n assert candidate(encodedText = \"thisisaverylongtextthatneedstobeencodedusingaslantedtranspositioncipher\",rows = 8) == \"trtsdsaohyttelnilhodasoabuintesgnatv\"\n assert candidate(encodedText = \"spaces are handled correctly\",rows = 5) == \"s h tp a laancycrdoeels\"\n assert candidate(encodedText = \"f l e x i b l e r e s o u r c e s\",rows = 5) == \"fi oe lbrus ele x\"\n assert candidate(encodedText = \"t h e q u i c k b r o w n f o x j u m p s o v e r l a z y d o g s\",rows = 3) == \"t v n h e e r f o q l x u a i z j c y u k m d p b o s r g o\"\n assert candidate(encodedText = \"a b c d e f g h i\",rows = 9) == \"a de c b\"\n assert candidate(encodedText = \"python programming is fun\",rows = 3) == \"po ygitrsha omfnmu ip\"\n assert candidate(encodedText = \"spaces between words are preserved\",rows = 3) == \"sn p a c pewrsoe rs de srb ve et dwae\"\n assert candidate(encodedText = \"keep calm and code on\",rows = 2) == \"knede pc ocdael mo\"\n assert candidate(encodedText = \"abcdefgh ijklmnop qrstuv wxyz\",rows = 4) == \"a p bi wcjqxdkryelsfmg\"\n assert candidate(encodedText = \"decoding slanted transposition cipher is challenging\",rows = 7) == \"d si gestipcclrthoaaidnnitn\"\n assert candidate(encodedText = \"a quick brown fox jumps over the lazy dog\",rows = 3) == \"af otqxhu eij culkma pzbsyr oodwvn\"\n assert candidate(encodedText = \"the quick brown fox jumps over the lazy dog and then some more text to fill\",rows = 8) == \"tbj der hrutonefeomhg wpe sqns au lifocok\"\n assert candidate(encodedText = \"empty string test\",rows = 1) == \"empty string test\"\n assert candidate(encodedText = \"u p d o w n w i d e t h i n g s\",rows = 4) == \"uwdi pnen g dwt o\"\n assert candidate(encodedText = \"this is a test of the emergency broadcast system\",rows = 5) == \"tteythe isebsstmry eosiorasfg a\"\n assert candidate(encodedText = \"shorttext\",rows = 1) == \"shorttext\"\n assert candidate(encodedText = \"a quick brown fox jumps over the lazy dog\",rows = 5) == \"arjry ou qwmtdunphoi secf ko\"\n assert candidate(encodedText = \"a bcd efgh ijklm nopqrst uvwxy z\",rows = 5) == \"aekry fls gmtz h b nc d\"\n assert candidate(encodedText = \"one two three four five six seven eight nine ten\",rows = 4) == \"o x nf neosi uentrvew e ofnt i etvenheir e\"\n assert candidate(encodedText = \"a b c d e\",rows = 5) == \"abcd\"\n assert candidate(encodedText = \"thisisaverylongtextthatneedstobeencodedproperly\",rows = 6) == \"teeeerhrxenoiytdcsltsiohsna\"\n assert candidate(encodedText = \"the quick brown fox jumps over a lazy dog\",rows = 3) == \"tneh ref oaqx u lijacuzkmy p bsdr o\"\n assert candidate(encodedText = \"one two three four five six seven\",rows = 3) == \"oeene e s fitoxwu ors e v e ntfh\"\n assert candidate(encodedText = \"pythonprogramminglanguageisawesome\",rows = 5) == \"priuwyonaetggghrloan\"\n assert candidate(encodedText = \"sl yz vx qu tm\",rows = 4) == \"sz l\"\n assert candidate(encodedText = \"this is a long encoded text for testing\",rows = 7) == \"tsln fsh octoi noes gd a\"\n assert candidate(encodedText = \"abcdefghij klmnopqrst uvwxyz\",rows = 3) == \"a b ck dl emufnvgowhpxiqyjr\"\n assert candidate(encodedText = \"a quick brown fox jumps over the lazy dog\",rows = 4) == \"awsl n aq ozufvyioe cxrdk o jtbur\"\n assert candidate(encodedText = \"a b c d e\",rows = 5) == \"a b c\"\n assert candidate(encodedText = \"a bcd efgh ijklm nopqrst uvwxyz\",rows = 6) == \"a mqu r eibfc\"\n assert candidate(encodedText = \"a a a a a a a a a a\",rows = 10) == \"aaa\"\n assert candidate(encodedText = \"exampleofasingleword\",rows = 1) == \"exampleofasingleword\"\n assert candidate(encodedText = \"the quick brown fox jumps over lazy dogs\",rows = 5) == \"t xvdhb eoerjrg ou sqwmlunpi c\"\n assert candidate(encodedText = \"a very long text that is used to test the edge cases of the problem statement\",rows = 10) == \"ao ea ntut vghsee aerttye\"\n assert candidate(encodedText = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",rows = 6) == \"ae n w j s f o xb k t g pc l hd\"\n assert candidate(encodedText = \"onewordonly\",rows = 1) == \"onewordonly\"\n assert candidate(encodedText = \"python is an interpreted high level general purpose programming language\",rows = 6) == \"piiepayngrrntthaoghe lguorl ranpepag rvumeieermstlp e adn\"\n assert candidate(encodedText = \"abcdefghijklmnopqrstuvwxyz\",rows = 10) == \"adb\"\n assert candidate(encodedText = \"abcdefghijklmnopqrstuvwxyz\",rows = 26) == \"a\"\n assert candidate(encodedText = \"slantedtranspositioncipherexample\",rows = 10) == \"strlea\"\n"}, "metadata": {"canonical_parameter_names": ["encodedText", "rows"], "leetcode_dataset_entry_point": "Solution().decodeCiphertext", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def decodeCiphertext(self, encodedText: str, rows: int) -> str:", "container": "Solution", "callable": "decodeCiphertext", "parameters": [{"name": "encodedText", "type": "str"}, {"name": "rows", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2076, "task_id": "process-restricted-friend-requests", "difficulty": "Hard", "problem_description": "You are given an integer n indicating the number of people in a network. Each person is labeled from 0 to n - 1.\nYou are also given a 0-indexed 2D integer array restrictions, where restrictions[i] = [xi, yi] means that person xi and person yi cannot become friends, either directly or indirectly through other people.\nInitially, no one is friends with each other. You are given a list of friend requests as a 0-indexed 2D integer array requests, where requests[j] = [uj, vj] is a friend request between person uj and person vj.\nA friend request is successful if uj and vj can be friends. Each friend request is processed in the given order (i.e., requests[j] occurs before requests[j + 1]), and upon a successful request, uj and vj become direct friends for all future friend requests.\nReturn a boolean array result, where each result[j] is true if the jth friend request is successful or false if it is not.\nNote: If uj and vj are already direct friends, the request is still successful.\n \nExample 1:\n\nInput: n = 3, restrictions = [[0,1]], requests = [[0,2],[2,1]]\nOutput: [true,false]\nExplanation:\nRequest 0: Person 0 and person 2 can be friends, so they become direct friends. \nRequest 1: Person 2 and person 1 cannot be friends since person 0 and person 1 would be indirect friends (1--2--0).\n\nExample 2:\n\nInput: n = 3, restrictions = [[0,1]], requests = [[1,2],[0,2]]\nOutput: [true,false]\nExplanation:\nRequest 0: Person 1 and person 2 can be friends, so they become direct friends.\nRequest 1: Person 0 and person 2 cannot be friends since person 0 and person 1 would be indirect friends (0--2--1).\n\nExample 3:\n\nInput: n = 5, restrictions = [[0,1],[1,2],[2,3]], requests = [[0,4],[1,2],[3,1],[3,4]]\nOutput: [true,false,true,false]\nExplanation:\nRequest 0: Person 0 and person 4 can be friends, so they become direct friends.\nRequest 1: Person 1 and person 2 cannot be friends since they are directly restricted.\nRequest 2: Person 3 and person 1 can be friends, so they become direct friends.\nRequest 3: Person 3 and person 4 cannot be friends since person 0 and person 1 would be indirect friends (0--4--3--1).\n\n \nConstraints:\n\n2 <= n <= 1000\n0 <= restrictions.length <= 1000\nrestrictions[i].length == 2\n0 <= xi, yi <= n - 1\nxi != yi\n1 <= requests.length <= 1000\nrequests[j].length == 2\n0 <= uj, vj <= n - 1\nuj != vj\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,restrictions = [[0, 2], [1, 3]],requests = [[0, 1], [2, 3], [0, 3]]) == [True, True, False]\n assert candidate(n = 4,restrictions = [],requests = [[0, 1], [1, 2], [2, 3], [3, 0]]) == [True, True, True, True]\n assert candidate(n = 4,restrictions = [[0, 2], [1, 3]],requests = [[0, 1], [2, 3], [1, 2]]) == [True, True, False]\n assert candidate(n = 5,restrictions = [[0, 1], [1, 2], [2, 3]],requests = [[0, 4], [1, 2], [3, 1], [3, 4]]) == [True, False, True, False]\n assert candidate(n = 6,restrictions = [[1, 4], [2, 5]],requests = [[0, 3], [1, 2], [3, 4]]) == [True, True, True]\n assert candidate(n = 6,restrictions = [[0, 1], [2, 3], [4, 5]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 0], [5, 1]]) == [True, True, True, True, True, True]\n assert candidate(n = 6,restrictions = [[0, 1], [2, 3], [4, 5]],requests = [[0, 2], [1, 3], [4, 5], [2, 4]]) == [True, True, False, True]\n assert candidate(n = 3,restrictions = [[0, 1]],requests = [[1, 2], [0, 2]]) == [True, False]\n assert candidate(n = 3,restrictions = [[0, 1]],requests = [[0, 2], [2, 1]]) == [True, False]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],requests = [[0, 5], [2, 7], [4, 9], [1, 6]]) == [True, True, True, True]\n assert candidate(n = 12,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]],requests = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [0, 5], [2, 7], [4, 9], [6, 11]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 7,restrictions = [[0, 6], [1, 5], [2, 4]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0]]) == [True, True, True, False, True, True, False]\n assert candidate(n = 20,restrictions = [[0, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 10]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 9,restrictions = [[0, 3], [1, 4], [2, 5], [6, 8]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 0], [7, 1], [8, 2]]) == [True, True, False, True, True, True, True, False, True, True, False, False, True, True, True, False, False, True]\n assert candidate(n = 7,restrictions = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 0], [5, 1], [6, 2]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0]]) == [True, True, False, True, True, False, False]\n assert candidate(n = 10,restrictions = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 9]],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 3], [5, 2], [6, 1], [7, 0], [8, 5], [9, 4]]) == [True, True, True, True, False, True, False, True, True, False, False, False, False, True, False]\n assert candidate(n = 15,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 0], [14, 1]]) == [True, True, True, True, True, True, True, True, True, True, True, True, False, False, False]\n assert candidate(n = 8,restrictions = [[0, 4], [1, 5], [2, 6], [3, 7]],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [0, 5]]) == [True, True, True, True, False]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [True, True, True, True, False]\n assert candidate(n = 8,restrictions = [[0, 7], [1, 6], [2, 5], [3, 4]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]]) == [True, True, True, False, True, True, True, False]\n assert candidate(n = 9,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 0], [8, 1]],requests = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 0], [6, 1], [7, 2], [8, 3]]) == [True, True, True, True, False, False, False, False, False]\n assert candidate(n = 12,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False]\n assert candidate(n = 15,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 12], [12, 9], [13, 14], [14, 13]],requests = [[0, 3], [1, 4], [2, 0], [3, 1], [4, 2], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 5], [11, 6], [12, 7]]) == [True, True, False, False, False, False, True, True, True, False, True, True, True]\n assert candidate(n = 12,restrictions = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [0, 11]]) == [True, True, True, True, True, True, True]\n assert candidate(n = 8,restrictions = [[0, 4], [1, 5], [2, 6], [3, 7]],requests = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [0, 5], [1, 6], [2, 7], [3, 4]]) == [True, True, True, True, True, True, True, True, False, False, False, False]\n assert candidate(n = 8,restrictions = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4]],requests = [[0, 4], [1, 5], [2, 6], [3, 7], [0, 5], [1, 6], [2, 7], [3, 4]]) == [True, True, True, True, False, False, False, False]\n assert candidate(n = 8,restrictions = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4]],requests = [[0, 4], [1, 5], [2, 6], [3, 7]]) == [True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],requests = [[0, 5], [2, 7], [4, 9], [1, 6], [3, 8]]) == [True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]],requests = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 0], [9, 1]]) == [True, True, True, True, True, True]\n assert candidate(n = 7,restrictions = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 0], [5, 1], [6, 2]],requests = [[0, 6], [1, 5], [2, 4], [3, 0], [4, 1], [5, 2], [6, 3]]) == [True, False, True, False, False, False, False]\n assert candidate(n = 15,restrictions = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [True, True, True, True, False, True, True, True, True, False, True, True, True, True]\n assert candidate(n = 8,restrictions = [[0, 2], [1, 3], [4, 6], [5, 7]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 0], [6, 1], [7, 2]]) == [True, False, True, True, True, False, True, True, False, False, True, False, False, False, True, False]\n assert candidate(n = 15,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 0]],requests = [[0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 1]]) == [True, True, True, True, True, True, False, True]\n assert candidate(n = 9,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 8]],requests = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 8], [0, 7], [1, 6], [2, 5], [3, 4]]) == [False, True, True, True, True, False, False, False, False]\n assert candidate(n = 10,restrictions = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 0]]) == [True, True, True, True, False, True, True, True, True, False, True, True, False, True, False]\n assert candidate(n = 10,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 0], [9, 1]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 15,restrictions = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]]) == [True, True, True, True, False, True, True, True, True, False, True, True, True, True, True]\n assert candidate(n = 7,restrictions = [[0, 2], [1, 3], [4, 6]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 3], [1, 4], [2, 5]]) == [True, False, True, True, True, False, True, False, False, True]\n assert candidate(n = 12,restrictions = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 6], [0, 7], [1, 8], [2, 9], [3, 10], [4, 11], [5, 6]]) == [True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False]\n assert candidate(n = 10,restrictions = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 0], [6, 1], [7, 2], [8, 3], [9, 4]]) == [True, True, False, True, True, False, False, False, False, False]\n assert candidate(n = 15,restrictions = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 0], [14, 1]],requests = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 0]]) == [True, True, True, True, True, True, False, True]\n assert candidate(n = 12,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],requests = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 0], [7, 1], [8, 2], [9, 3], [10, 4], [11, 5]]) == [True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 7,restrictions = [[0, 2], [1, 3], [4, 6]],requests = [[0, 1], [2, 3], [4, 5], [5, 6], [0, 3], [2, 5]]) == [True, True, True, False, False, True]\n assert candidate(n = 9,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 0], [8, 1]]) == [True, True, True, True, True, True, False, False, False]\n assert candidate(n = 9,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 0]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 0], [8, 1], [0, 4]]) == [True, True, True, True, True, True, False, False, True, True]\n assert candidate(n = 15,restrictions = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == [True, True, True, True, True, True, True, False, True, True, True, True, True, True, False, False, False, False, False, False, False, True]\n assert candidate(n = 5,restrictions = [[0, 2], [1, 3]],requests = [[0, 1], [2, 3], [1, 4], [3, 4]]) == [True, True, True, False]\n assert candidate(n = 7,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],requests = [[0, 6], [1, 5], [2, 4], [3, 0], [4, 1], [5, 2], [6, 3]]) == [True, True, True, True, False, False, True]\n assert candidate(n = 20,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0]],requests = [[0, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 1], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [True, True, True, True, False]\n assert candidate(n = 8,restrictions = [[0, 1], [2, 3], [4, 5], [5, 6], [6, 7]],requests = [[0, 2], [1, 4], [3, 5], [5, 7], [0, 7], [4, 6]]) == [True, True, True, True, False, True]\n assert candidate(n = 15,restrictions = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14]],requests = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 0], [12, 1], [13, 2], [14, 3]]) == [True, True, True, True, True, True, True, True, True, True, True, False, False, False, False]\n assert candidate(n = 8,restrictions = [[0, 2], [1, 3], [4, 6], [5, 7]],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [0, 2], [1, 3], [4, 6], [5, 7], [0, 4], [2, 6], [1, 5], [3, 7], [0, 6], [2, 4], [1, 7], [3, 5]]) == [True, True, True, True, False, False, False, False, True, True, True, True, False, False, False, False]\n assert candidate(n = 7,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0]],requests = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 0], [5, 1], [6, 2]]) == [True, True, True, False, False, False, False]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],requests = [[0, 9], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(n = 12,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],requests = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 0], [7, 1], [8, 2], [9, 3], [10, 4], [11, 5]]) == [True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]],requests = [[0, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5]]) == [True, True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == [True, True, True, True, False, True, True, True, True, False]\n assert candidate(n = 8,restrictions = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 7]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [0, 7], [1, 6]]) == [True, True, True, True, True, True, False, False]\n assert candidate(n = 12,restrictions = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],requests = [[0, 5], [1, 4], [2, 3], [6, 11], [7, 10], [8, 9], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [True, True, True, True, True, True, False, False, False, False, False, False]\n assert candidate(n = 10,restrictions = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 12,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]],requests = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [True, True, True, True, True, True, True, True, True, True, False, False]\n assert candidate(n = 11,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 0], [10, 1]]) == [True, True, True, True, True, True, True, True, True, False, False]\n assert candidate(n = 20,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]],requests = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [12, 14], [13, 15], [16, 18], [17, 19], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False]\n assert candidate(n = 12,restrictions = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 7], [1, 8], [2, 9], [3, 10], [4, 11], [5, 6]]) == [True, True, True, True, True, False, False, False, False, False, False]\n assert candidate(n = 15,restrictions = [[0, 7], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [True, True, True, True, True, True, False, True, True, True, True, True, True, False]\n assert candidate(n = 9,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 0], [8, 1], [0, 8], [1, 7], [2, 6], [3, 5], [4, 3], [5, 2], [6, 1], [7, 0], [8, 6], [0, 4], [1, 5], [2, 7], [3, 8]]) == [True, True, True, True, True, True, True, False, False, True, True, True, True, False, False, False, False, True, True, True, False, False]\n assert candidate(n = 12,restrictions = [[0, 3], [1, 4], [2, 5], [6, 9], [7, 10], [8, 11]],requests = [[0, 1], [1, 2], [3, 4], [4, 5], [6, 7], [7, 8], [9, 10], [10, 11], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, True]\n assert candidate(n = 6,restrictions = [[0, 1], [2, 3], [4, 5]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [0, 5], [1, 4]]) == [True, True, True, True, False, False]\n assert candidate(n = 10,restrictions = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == [True, True, True, True, False, True, True, True, True, False]\n assert candidate(n = 8,restrictions = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]],requests = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [0, 1], [2, 3], [4, 5], [6, 7]]) == [True, True, True, True, True, False, False, False, False]\n"}, "metadata": {"canonical_parameter_names": ["n", "restrictions", "requests"], "leetcode_dataset_entry_point": "Solution().friendRequests", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def friendRequests(self, n: int, restrictions: list[list[int]], requests: list[list[int]]) -> list[bool]:", "container": "Solution", "callable": "friendRequests", "parameters": [{"name": "n", "type": "int"}, {"name": "restrictions", "type": "list[list[int]]"}, {"name": "requests", "type": "list[list[int]]"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2078, "task_id": "two-furthest-houses-with-different-colors", "difficulty": "Easy", "problem_description": "There are n houses evenly lined up on the street, and each house is beautifully painted. You are given a 0-indexed integer array colors of length n, where colors[i] represents the color of the ith house.\nReturn the maximum distance between two houses with different colors.\nThe distance between the ith and jth houses is abs(i - j), where abs(x) is the absolute value of x.\n \nExample 1:\n\n\nInput: colors = [1,1,1,6,1,1,1]\nOutput: 3\nExplanation: In the above image, color 1 is blue, and color 6 is red.\nThe furthest two houses with different colors are house 0 and house 3.\nHouse 0 has color 1, and house 3 has color 6. The distance between them is abs(0 - 3) = 3.\nNote that houses 3 and 6 can also produce the optimal answer.\n\nExample 2:\n\n\nInput: colors = [1,8,3,8,3]\nOutput: 4\nExplanation: In the above image, color 1 is blue, color 8 is yellow, and color 3 is green.\nThe furthest two houses with different colors are house 0 and house 4.\nHouse 0 has color 1, and house 4 has color 3. The distance between them is abs(0 - 4) = 4.\n\nExample 3:\n\nInput: colors = [0,1]\nOutput: 1\nExplanation: The furthest two houses with different colors are house 0 and house 1.\nHouse 0 has color 0, and house 1 has color 1. The distance between them is abs(0 - 1) = 1.\n\n \nConstraints:\n\nn == colors.length\n2 <= n <= 100\n0 <= colors[i] <= 100\nTest data are generated such that at least two houses have different colors.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(colors = [10, 20, 10, 10, 10]) == 3\n assert candidate(colors = [10, 20, 30, 40, 50]) == 4\n assert candidate(colors = [100, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 9\n assert candidate(colors = [3, 1, 3, 3, 3]) == 3\n assert candidate(colors = [1, 1, 1, 6, 1, 1, 1]) == 3\n assert candidate(colors = [1, 2, 3, 4, 5]) == 4\n assert candidate(colors = [5, 5, 5, 5, 1]) == 4\n assert candidate(colors = [5, 5, 5, 5, 5, 2]) == 5\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(colors = [7, 7, 7, 7, 7, 7, 7, 7, 7, 8]) == 9\n assert candidate(colors = [1, 1, 2, 1, 1]) == 2\n assert candidate(colors = [1, 1, 2, 1, 1, 1, 1]) == 4\n assert candidate(colors = [100, 99, 98, 97, 96, 95]) == 5\n assert candidate(colors = [2, 2, 2, 2, 3, 2]) == 4\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 2]) == 9\n assert candidate(colors = [0, 1]) == 1\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 9\n assert candidate(colors = [1, 1, 1, 1, 1, 2]) == 5\n assert candidate(colors = [1, 8, 3, 8, 3]) == 4\n assert candidate(colors = [1, 1, 2, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(colors = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 2]) == 7\n assert candidate(colors = [100, 0, 100, 100, 100]) == 3\n assert candidate(colors = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 9\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 2, 1]) == 8\n assert candidate(colors = [4, 4, 4, 4, 4, 4, 4, 4, 4, 2]) == 9\n assert candidate(colors = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 18\n assert candidate(colors = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 0]) == 30\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1]) == 33\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 32\n assert candidate(colors = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 32\n assert candidate(colors = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 57\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 55\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 20\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 29\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 21\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 31\n assert candidate(colors = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 71\n assert candidate(colors = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 29\n assert candidate(colors = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 29\n assert candidate(colors = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10]) == 20\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 52\n assert candidate(colors = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 77\n assert candidate(colors = [10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 10]) == 54\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == 80\n assert candidate(colors = [34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35]) == 81\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 59\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 77\n assert candidate(colors = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 19\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 21\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 57\n assert candidate(colors = [7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 9]) == 75\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 17\n assert candidate(colors = [1, 1, 1, 1, 2, 1, 1, 1, 1, 1]) == 5\n assert candidate(colors = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 29\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 52\n assert candidate(colors = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 55\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 57\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1]) == 19\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]) == 55\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 90\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 19\n assert candidate(colors = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 99\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6]) == 56\n assert candidate(colors = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 75\n assert candidate(colors = [34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35]) == 56\n assert candidate(colors = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 77\n assert candidate(colors = [1, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 8\n assert candidate(colors = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(colors = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1]) == 53\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5, 5]) == 10\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 45\n assert candidate(colors = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]) == 52\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 68\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 78\n assert candidate(colors = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 2]) == 78\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 17\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == 30\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == 77\n assert candidate(colors = [1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1]) == 5\n assert candidate(colors = [100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100]) == 29\n assert candidate(colors = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 0]) == 71\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(colors = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 11\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 87\n assert candidate(colors = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 19\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1]) == 49\n"}, "metadata": {"canonical_parameter_names": ["colors"], "leetcode_dataset_entry_point": "Solution().maxDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxDistance(self, colors: list[int]) -> int:", "container": "Solution", "callable": "maxDistance", "parameters": [{"name": "colors", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2079, "task_id": "watering-plants", "difficulty": "Medium", "problem_description": "You want to water n plants in your garden with a watering can. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i. There is a river at x = -1 that you can refill your watering can at.\nEach plant needs a specific amount of water. You will water the plants in the following way:\n\nWater the plants in order from left to right.\nAfter watering the current plant, if you do not have enough water to completely water the next plant, return to the river to fully refill the watering can.\nYou cannot refill the watering can early.\n\nYou are initially at the river (i.e., x = -1). It takes one step to move one unit on the x-axis.\nGiven a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the ith plant needs, and an integer capacity representing the watering can capacity, return the number of steps needed to water all the plants.\n \nExample 1:\n\nInput: plants = [2,2,3,3], capacity = 5\nOutput: 14\nExplanation: Start at the river with a full watering can:\n- Walk to plant 0 (1 step) and water it. Watering can has 3 units of water.\n- Walk to plant 1 (1 step) and water it. Watering can has 1 unit of water.\n- Since you cannot completely water plant 2, walk back to the river to refill (2 steps).\n- Walk to plant 2 (3 steps) and water it. Watering can has 2 units of water.\n- Since you cannot completely water plant 3, walk back to the river to refill (3 steps).\n- Walk to plant 3 (4 steps) and water it.\nSteps needed = 1 + 1 + 2 + 3 + 3 + 4 = 14.\n\nExample 2:\n\nInput: plants = [1,1,1,4,2,3], capacity = 4\nOutput: 30\nExplanation: Start at the river with a full watering can:\n- Water plants 0, 1, and 2 (3 steps). Return to river (3 steps).\n- Water plant 3 (4 steps). Return to river (4 steps).\n- Water plant 4 (5 steps). Return to river (5 steps).\n- Water plant 5 (6 steps).\nSteps needed = 3 + 3 + 4 + 4 + 5 + 5 + 6 = 30.\n\nExample 3:\n\nInput: plants = [7,7,7,7,7,7,7], capacity = 8\nOutput: 49\nExplanation: You have to refill before watering each plant.\nSteps needed = 1 + 1 + 2 + 2 + 3 + 3 + 4 + 4 + 5 + 5 + 6 + 6 + 7 = 49.\n\n \nConstraints:\n\nn == plants.length\n1 <= n <= 1000\n1 <= plants[i] <= 106\nmax(plants[i]) <= capacity <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(plants = [1000000],capacity = 1000000) == 1\n assert candidate(plants = [3, 2, 4, 2, 1],capacity = 6) == 17\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 1) == 100\n assert candidate(plants = [5, 5, 5, 5, 5],capacity = 5) == 25\n assert candidate(plants = [10, 10, 10],capacity = 10) == 9\n assert candidate(plants = [1, 1, 1, 4, 2, 3],capacity = 4) == 30\n assert candidate(plants = [1, 2, 3, 4, 5],capacity = 10) == 13\n assert candidate(plants = [1, 2, 3],capacity = 6) == 3\n assert candidate(plants = [5, 8, 6],capacity = 10) == 9\n assert candidate(plants = [1, 1, 1, 1, 1],capacity = 5) == 5\n assert candidate(plants = [2, 2, 3, 3],capacity = 5) == 14\n assert candidate(plants = [3, 2, 4, 2, 1],capacity = 4) == 17\n assert candidate(plants = [7, 7, 7, 7, 7, 7, 7],capacity = 8) == 49\n assert candidate(plants = [2, 4, 5, 1, 2],capacity = 6) == 17\n assert candidate(plants = [10],capacity = 10) == 1\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 15) == 146\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacity = 5) == 961\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 25) == 242\n assert candidate(plants = [9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 10) == 41\n assert candidate(plants = [2, 3, 2, 1, 4, 2, 1, 3, 2, 1, 4, 2, 1],capacity = 6) == 77\n assert candidate(plants = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],capacity = 3) == 138\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacity = 50) == 88\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacity = 10) == 362\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 10) == 200\n assert candidate(plants = [2, 4, 5, 1, 2],capacity = 5) == 17\n assert candidate(plants = [7, 2, 5, 9, 3, 8, 4, 6, 1, 1, 1, 1],capacity = 15) == 42\n assert candidate(plants = [1, 3, 2, 4, 2, 1, 3, 2, 1, 4, 2, 1],capacity = 5) == 78\n assert candidate(plants = [5, 8, 6, 10, 2, 1, 1, 1, 1, 1],capacity = 12) == 32\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = 20) == 152\n assert candidate(plants = [2, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8],capacity = 12) == 71\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 10) == 54\n assert candidate(plants = [9, 1, 5, 3, 7, 8, 4, 2],capacity = 10) == 42\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],capacity = 20) == 213\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacity = 30) == 2881\n assert candidate(plants = [2, 4, 6, 8, 10],capacity = 10) == 23\n assert candidate(plants = [1000000, 500000, 1000000, 500000, 1000000, 500000],capacity = 1000000) == 36\n assert candidate(plants = [100, 200, 300, 400, 500],capacity = 1000) == 13\n assert candidate(plants = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],capacity = 3) == 900\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],capacity = 150) == 68\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacity = 15) == 4499\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = 10) == 88\n assert candidate(plants = [1, 3, 2, 5, 4, 3, 2, 1],capacity = 5) == 50\n assert candidate(plants = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],capacity = 3) == 400\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = 18) == 52\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 10) == 249\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = 15) == 68\n assert candidate(plants = [9, 1, 2, 3, 4, 5, 6, 7, 8],capacity = 10) == 65\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 10) == 200\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],capacity = 20) == 88\n assert candidate(plants = [5, 8, 6, 7, 4, 9],capacity = 12) == 28\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 4) == 400\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 5) == 84\n assert candidate(plants = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],capacity = 5) == 200\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 25) == 180\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacity = 15) == 225\n assert candidate(plants = [2, 4, 6, 8, 10],capacity = 12) == 19\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 10) == 127\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 2) == 511\n assert candidate(plants = [3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],capacity = 4) == 407\n assert candidate(plants = [5, 8, 6, 7, 9, 4, 2],capacity = 10) == 37\n assert candidate(plants = [7, 3, 5, 8, 10, 2, 6, 4, 9, 1],capacity = 15) == 52\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],capacity = 20) == 78\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 1) == 6724\n assert candidate(plants = [7, 3, 6, 2, 5, 4, 9, 1, 8],capacity = 12) == 49\n assert candidate(plants = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],capacity = 15) == 126\n assert candidate(plants = [100, 200, 100],capacity = 150) == 9\n assert candidate(plants = [100, 200, 300, 400, 500],capacity = 1000) == 13\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 15) == 38\n assert candidate(plants = [100, 200, 300, 400, 500],capacity = 500) == 23\n assert candidate(plants = [5, 8, 6, 10, 2, 9, 4],capacity = 12) == 41\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 5) == 2878\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 10) == 10082\n assert candidate(plants = [1000000, 1000000, 1000000],capacity = 1000000) == 9\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 10) == 249\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacity = 10) == 146\n assert candidate(plants = [9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 5) == 67\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 15) == 46\n assert candidate(plants = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],capacity = 14) == 200\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacity = 25) == 296\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacity = 20) == 177\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacity = 15) == 368\n assert candidate(plants = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],capacity = 14) == 200\n assert candidate(plants = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],capacity = 10) == 276\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 1) == 900\n"}, "metadata": {"canonical_parameter_names": ["plants", "capacity"], "leetcode_dataset_entry_point": "Solution().wateringPlants", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def wateringPlants(self, plants: list[int], capacity: int) -> int:", "container": "Solution", "callable": "wateringPlants", "parameters": [{"name": "plants", "type": "list[int]"}, {"name": "capacity", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2081, "task_id": "sum-of-k-mirror-numbers", "difficulty": "Hard", "problem_description": "A k-mirror number is a positive integer without leading zeros that reads the same both forward and backward in base-10 as well as in base-k.\n\nFor example, 9 is a 2-mirror number. The representation of 9 in base-10 and base-2 are 9 and 1001 respectively, which read the same both forward and backward.\nOn the contrary, 4 is not a 2-mirror number. The representation of 4 in base-2 is 100, which does not read the same both forward and backward.\n\nGiven the base k and the number n, return the sum of the n smallest k-mirror numbers.\n \nExample 1:\n\nInput: k = 2, n = 5\nOutput: 25\nExplanation:\nThe 5 smallest 2-mirror numbers and their representations in base-2 are listed as follows:\n base-10 base-2\n 1 1\n 3 11\n 5 101\n 7 111\n 9 1001\nTheir sum = 1 + 3 + 5 + 7 + 9 = 25. \n\nExample 2:\n\nInput: k = 3, n = 7\nOutput: 499\nExplanation:\nThe 7 smallest 3-mirror numbers are and their representations in base-3 are listed as follows:\n base-10 base-3\n 1 1\n 2 2\n 4 11\n 8 22\n 121 11111\n 151 12121\n 212 21212\nTheir sum = 1 + 2 + 4 + 8 + 121 + 151 + 212 = 499.\n\nExample 3:\n\nInput: k = 7, n = 17\nOutput: 20379000\nExplanation: The 17 smallest 7-mirror numbers are:\n1, 2, 3, 4, 5, 6, 8, 121, 171, 242, 292, 16561, 65656, 2137312, 4602064, 6597956, 6958596\n\n \nConstraints:\n\n2 <= k <= 9\n1 <= n <= 30\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 2,n = 1) == 1\n assert candidate(k = 5,n = 8) == 638\n assert candidate(k = 8,n = 15) == 5818\n assert candidate(k = 9,n = 5) == 15\n assert candidate(k = 9,n = 6) == 21\n assert candidate(k = 8,n = 9) == 158\n assert candidate(k = 4,n = 8) == 1498\n assert candidate(k = 9,n = 30) == 18627530\n assert candidate(k = 2,n = 10) == 1772\n assert candidate(k = 4,n = 10) == 3224\n assert candidate(k = 3,n = 7) == 499\n assert candidate(k = 5,n = 10) == 1940\n assert candidate(k = 9,n = 10) == 509\n assert candidate(k = 9,n = 20) == 156242\n assert candidate(k = 4,n = 15) == 233041\n assert candidate(k = 6,n = 12) == 1297\n assert candidate(k = 8,n = 20) == 94182\n assert candidate(k = 3,n = 5) == 136\n assert candidate(k = 5,n = 15) == 20526195\n assert candidate(k = 2,n = 5) == 25\n assert candidate(k = 2,n = 30) == 2609044274\n assert candidate(k = 7,n = 17) == 20379000\n assert candidate(k = 7,n = 28) == 115121130305\n assert candidate(k = 5,n = 25) == 6849225412\n assert candidate(k = 3,n = 20) == 2863752\n assert candidate(k = 8,n = 28) == 7054305\n assert candidate(k = 7,n = 35) == 639048703165\n assert candidate(k = 9,n = 15) == 3203\n assert candidate(k = 5,n = 20) == 1000828708\n assert candidate(k = 7,n = 15) == 6822448\n assert candidate(k = 6,n = 25) == 7009551\n assert candidate(k = 8,n = 25) == 1651182\n assert candidate(k = 6,n = 30) == 28888231\n assert candidate(k = 2,n = 25) == 20005383\n assert candidate(k = 6,n = 28) == 19806423\n assert candidate(k = 4,n = 22) == 22726545\n assert candidate(k = 9,n = 29) == 16185088\n assert candidate(k = 5,n = 28) == 19101218022\n assert candidate(k = 9,n = 27) == 11349704\n assert candidate(k = 8,n = 17) == 27727\n assert candidate(k = 6,n = 15) == 4383\n assert candidate(k = 5,n = 30) == 43401017264\n assert candidate(k = 4,n = 28) == 721411086\n assert candidate(k = 3,n = 28) == 44192979\n assert candidate(k = 4,n = 20) == 12448815\n assert candidate(k = 9,n = 25) == 7586042\n assert candidate(k = 7,n = 19) == 91104965\n assert candidate(k = 9,n = 35) == 33584024\n assert candidate(k = 9,n = 28) == 13750746\n assert candidate(k = 2,n = 28) == 759196316\n assert candidate(k = 4,n = 25) == 38898160\n assert candidate(k = 6,n = 20) == 156389\n assert candidate(k = 3,n = 30) == 155059889\n assert candidate(k = 8,n = 18) == 41058\n assert candidate(k = 7,n = 20) == 321578997\n assert candidate(k = 7,n = 25) == 3428700695\n assert candidate(k = 8,n = 30) == 66619574\n assert candidate(k = 6,n = 18) == 41849\n assert candidate(k = 7,n = 30) == 241030621167\n"}, "metadata": {"canonical_parameter_names": ["k", "n"], "leetcode_dataset_entry_point": "Solution().kMirror", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def kMirror(self, k: int, n: int) -> int:", "container": "Solution", "callable": "kMirror", "parameters": [{"name": "k", "type": "int"}, {"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2085, "task_id": "count-common-words-with-one-occurrence", "difficulty": "Easy", "problem_description": "Given two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.\n \nExample 1:\n\nInput: words1 = [\"leetcode\",\"is\",\"amazing\",\"as\",\"is\"], words2 = [\"amazing\",\"leetcode\",\"is\"]\nOutput: 2\nExplanation:\n- \"leetcode\" appears exactly once in each of the two arrays. We count this string.\n- \"amazing\" appears exactly once in each of the two arrays. We count this string.\n- \"is\" appears in each of the two arrays, but there are 2 occurrences of it in words1. We do not count this string.\n- \"as\" appears once in words1, but does not appear in words2. We do not count this string.\nThus, there are 2 strings that appear exactly once in each of the two arrays.\n\nExample 2:\n\nInput: words1 = [\"b\",\"bb\",\"bbb\"], words2 = [\"a\",\"aa\",\"aaa\"]\nOutput: 0\nExplanation: There are no strings that appear in each of the two arrays.\n\nExample 3:\n\nInput: words1 = [\"a\",\"ab\"], words2 = [\"a\",\"a\",\"a\",\"ab\"]\nOutput: 1\nExplanation: The only string that appears exactly once in each of the two arrays is \"ab\".\n\n \nConstraints:\n\n1 <= words1.length, words2.length <= 1000\n1 <= words1[i].length, words2[j].length <= 30\nwords1[i] and words2[j] consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words1 = ['one'],words2 = ['two']) == 0\n assert candidate(words1 = ['unique'],words2 = ['unique']) == 1\n assert candidate(words1 = ['b', 'bb', 'bbb'],words2 = ['a', 'aa', 'aaa']) == 0\n assert candidate(words1 = ['distinct'],words2 = ['distinct', 'distinct']) == 0\n assert candidate(words1 = ['a', 'b', 'c'],words2 = ['c', 'b', 'a']) == 3\n assert candidate(words1 = ['same', 'same'],words2 = ['same', 'same', 'same']) == 0\n assert candidate(words1 = ['a', 'ab'],words2 = ['a', 'a', 'a', 'ab']) == 1\n assert candidate(words1 = ['hello', 'world'],words2 = ['hello', 'world', 'hello']) == 1\n assert candidate(words1 = ['hello', 'world'],words2 = ['hello', 'world']) == 2\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'date']) == 2\n assert candidate(words1 = ['leetcode', 'is', 'amazing', 'as', 'is'],words2 = ['amazing', 'leetcode', 'is']) == 2\n assert candidate(words1 = ['repeat', 'repeat'],words2 = ['repeat', 'repeat']) == 0\n assert candidate(words1 = ['python', 'java', 'c++', 'javascript'],words2 = ['c++', 'java', 'python', 'python', 'javascript', 'java', 'c++', 'javascript', 'c++', 'javascript']) == 0\n assert candidate(words1 = ['abc', 'def', 'ghi', 'jkl'],words2 = ['def', 'ghi', 'jkl', 'mno', 'pqr', 'abc', 'def', 'ghi', 'jkl']) == 1\n assert candidate(words1 = ['python', 'java', 'c++', 'ruby'],words2 = ['java', 'c++', 'ruby', 'python', 'python', 'java']) == 2\n assert candidate(words1 = ['alpha', 'beta', 'gamma', 'delta'],words2 = ['delta', 'gamma', 'beta', 'alpha', 'alpha', 'beta', 'gamma', 'delta']) == 0\n assert candidate(words1 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five'],words2 = ['two', 'three', 'four', 'five', 'six', 'seven', 'eight']) == 4\n assert candidate(words1 = ['hello', 'world', 'hello'],words2 = ['world', 'hello', 'hello', 'world']) == 0\n assert candidate(words1 = ['cat', 'dog', 'bird', 'fish'],words2 = ['cat', 'dog', 'bird', 'fish', 'dog', 'bird']) == 2\n assert candidate(words1 = ['hello', 'hello', 'world'],words2 = ['hello', 'world', 'world', 'world']) == 0\n assert candidate(words1 = ['cat', 'dog', 'fish'],words2 = ['dog', 'cat', 'bird', 'fish', 'dog', 'fish']) == 1\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e'],words2 = ['f', 'g', 'h', 'i', 'j']) == 0\n assert candidate(words1 = ['alpha', 'beta', 'gamma', 'delta'],words2 = ['alpha', 'beta', 'gamma', 'delta', 'delta']) == 3\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five', 'six'],words2 = ['three', 'four', 'seven', 'eight', 'nine', 'one', 'two']) == 4\n assert candidate(words1 = ['one', 'two', 'three', 'four'],words2 = ['four', 'three', 'two', 'one', 'one', 'two', 'three', 'four', 'four', 'three', 'two', 'one']) == 0\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],words2 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 0\n assert candidate(words1 = ['same', 'word', 'multiple'],words2 = ['same', 'word', 'multiple', 'same', 'word', 'multiple']) == 0\n assert candidate(words1 = ['test', 'case', 'one'],words2 = ['case', 'test', 'one', 'one', 'test', 'case']) == 0\n assert candidate(words1 = ['same', 'word', 'repeated'],words2 = ['same', 'word', 'repeated', 'same', 'word', 'repeated']) == 0\n assert candidate(words1 = ['hello', 'world', 'hello', 'world'],words2 = ['hello', 'world', 'hello', 'world', 'hello', 'world']) == 0\n assert candidate(words1 = ['x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],words2 = ['a', 'b', 'b', 'c', 'd', 'd', 'e', 'f', 'f', 'g']) == 4\n assert candidate(words1 = ['car', 'truck', 'bus', 'van', 'car', 'truck'],words2 = ['bus', 'van', 'motorcycle', 'bicycle', 'bus', 'van', 'truck']) == 0\n assert candidate(words1 = ['cat', 'dog', 'fish', 'bird'],words2 = ['dog', 'cat', 'cat', 'fish', 'dog', 'bird']) == 2\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e'],words2 = ['f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e']) == 5\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],words2 = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']) == 0\n assert candidate(words1 = ['same', 'word', 'repeated', 'multiple', 'times'],words2 = ['times', 'repeated', 'multiple', 'same', 'word', 'word']) == 4\n assert candidate(words1 = ['one', 'two', 'three', 'four'],words2 = ['four', 'three', 'two', 'one', 'one', 'two', 'three', 'four']) == 0\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'cherry', 'apple']) == 2\n assert candidate(words1 = ['a', 'b', 'c', 'd'],words2 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 4\n assert candidate(words1 = ['a', 'b', 'c', 'd'],words2 = ['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd']) == 0\n assert candidate(words1 = ['x', 'y', 'z', 'w', 'v'],words2 = ['x', 'y', 'z', 'w', 'v', 'x', 'y', 'z', 'w', 'v', 'x', 'y', 'z', 'w', 'v', 'x', 'y', 'z', 'w', 'v']) == 0\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e'],words2 = ['e', 'd', 'c', 'b', 'a', 'a', 'b', 'c', 'd', 'e']) == 0\n assert candidate(words1 = ['unique', 'words', 'only', 'once', 'here'],words2 = ['words', 'only', 'once', 'here', 'unique', 'twice', 'unique']) == 4\n assert candidate(words1 = ['x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['cat', 'dog', 'elephant', 'frog', 'cat'],words2 = ['dog', 'frog', 'giraffe', 'elephant', 'hippo']) == 3\n assert candidate(words1 = ['cat', 'dog', 'fish'],words2 = ['fish', 'dog', 'cat', 'dog', 'cat']) == 1\n assert candidate(words1 = ['python', 'java', 'c', 'cpp'],words2 = ['python', 'java', 'java', 'csharp']) == 1\n assert candidate(words1 = ['unique', 'words', 'only', 'here'],words2 = ['here', 'only', 'words', 'unique', 'unique']) == 3\n assert candidate(words1 = ['hello', 'world', 'hello'],words2 = ['world', 'hello', 'world', 'hello', 'world', 'hello']) == 0\n assert candidate(words1 = ['hello', 'world', 'python', 'java', 'csharp'],words2 = ['python', 'java', 'csharp', 'hello', 'ruby', 'scala', 'world', 'python', 'java']) == 3\n assert candidate(words1 = ['x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['unique', 'word', 'only', 'in', 'this', 'array'],words2 = ['unique', 'only', 'word', 'in', 'that', 'array']) == 5\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'cherry', 'apple', 'apple']) == 2\n assert candidate(words1 = ['apple', 'banana', 'cherry', 'date'],words2 = ['banana', 'cherry', 'fig', 'grape']) == 2\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'apple', 'cherry', 'date']) == 2\n assert candidate(words1 = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abc'],words2 = ['mno', 'pqr', 'stu', 'vwx', 'yz', 'abc', 'def', 'ghi', 'jkl', 'mno']) == 7\n assert candidate(words1 = ['apple', 'banana', 'cherry', 'date'],words2 = ['banana', 'date', 'fig', 'grape', 'apple']) == 3\n assert candidate(words1 = ['apple', 'banana', 'cherry', 'date', 'elderberry'],words2 = ['banana', 'cherry', 'elderberry', 'fig', 'grape', 'apple', 'date']) == 5\n assert candidate(words1 = ['a', 'b', 'c', 'a', 'b', 'c'],words2 = ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c']) == 0\n assert candidate(words1 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['sun', 'moon', 'star', 'planet', 'sun', 'moon'],words2 = ['star', 'planet', 'comet', 'asteroid', 'planet', 'star']) == 0\n assert candidate(words1 = ['alpha', 'beta', 'gamma', 'delta', 'epsilon'],words2 = ['gamma', 'delta', 'zeta', 'eta', 'theta', 'epsilon', 'delta']) == 2\n assert candidate(words1 = ['python', 'java', 'csharp'],words2 = ['java', 'csharp', 'python', 'python']) == 2\n assert candidate(words1 = ['python', 'java', 'c++'],words2 = ['c++', 'java', 'python', 'java', 'python', 'c++', 'python']) == 0\n assert candidate(words1 = ['cat', 'dog', 'mouse'],words2 = ['dog', 'cat', 'cat', 'mouse', 'dog']) == 1\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'cherry', 'apple', 'banana']) == 2\n assert candidate(words1 = ['same', 'words', 'in', 'both', 'arrays'],words2 = ['same', 'words', 'in', 'both', 'arrays']) == 5\n assert candidate(words1 = ['single'],words2 = ['single', 'single', 'single', 'single']) == 0\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['cherry', 'banana', 'apple', 'apple']) == 2\n assert candidate(words1 = ['abc', 'def', 'ghi'],words2 = ['def', 'ghi', 'jkl', 'def', 'ghi']) == 0\n assert candidate(words1 = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault'],words2 = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'grault']) == 6\n assert candidate(words1 = ['foo', 'bar', 'baz', 'qux'],words2 = ['foo', 'bar', 'qux', 'quux']) == 3\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'cherry', 'banana']) == 2\n assert candidate(words1 = ['hello', 'hello', 'world'],words2 = ['world', 'world', 'hello', 'hello', 'hello']) == 0\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five'],words2 = ['five', 'four', 'three', 'two', 'one']) == 5\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'cherry', 'cherry']) == 2\n assert candidate(words1 = ['unique', 'words', 'only'],words2 = ['only', 'words', 'unique', 'words']) == 2\n assert candidate(words1 = ['red', 'blue', 'green'],words2 = ['red', 'red', 'blue', 'green', 'blue', 'green']) == 0\n assert candidate(words1 = ['cat', 'dog', 'mouse', 'elephant'],words2 = ['dog', 'mouse', 'cat', 'tiger', 'elephant', 'dog']) == 3\n assert candidate(words1 = ['test', 'case', 'input'],words2 = ['input', 'test', 'case', 'input', 'test', 'case', 'input', 'test', 'case']) == 0\n assert candidate(words1 = ['hello', 'world', 'hello', 'world'],words2 = ['hello', 'world', 'world', 'hello']) == 0\n assert candidate(words1 = ['first', 'second', 'third', 'fourth'],words2 = ['fourth', 'third', 'second', 'first', 'first', 'second', 'third', 'fourth', 'first', 'second', 'third', 'fourth']) == 0\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five'],words2 = ['two', 'three', 'five', 'six', 'seven', 'eight', 'nine', 'one', 'four']) == 5\n assert candidate(words1 = ['repeated', 'repeated', 'words', 'in', 'both', 'arrays'],words2 = ['repeated', 'words', 'in', 'both', 'arrays', 'arrays']) == 3\n assert candidate(words1 = ['x', 'y', 'z'],words2 = ['z', 'y', 'x']) == 3\n assert candidate(words1 = ['a', 'b', 'c', 'd'],words2 = ['a', 'a', 'b', 'c', 'c', 'd', 'd', 'd']) == 1\n assert candidate(words1 = ['single'],words2 = ['single']) == 1\n assert candidate(words1 = ['hello', 'world', 'python', 'java'],words2 = ['python', 'java', 'hello', 'world', 'world', 'hello']) == 2\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e'],words2 = ['a', 'a', 'b', 'c', 'c', 'd', 'e', 'e']) == 2\n assert candidate(words1 = ['python', 'java', 'c', 'cpp'],words2 = ['java', 'c', 'cpp', 'ruby']) == 3\n assert candidate(words1 = ['unique', 'string', 'in', 'each', 'array'],words2 = ['different', 'string', 'in', 'each', 'array']) == 4\n assert candidate(words1 = ['single'],words2 = ['single', 'single', 'single']) == 0\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'cherry', 'date']) == 2\n assert candidate(words1 = ['repeat', 'repeat', 'repeat'],words2 = ['repeat', 'repeat', 'repeat', 'repeat']) == 0\n assert candidate(words1 = ['red', 'blue', 'green', 'yellow', 'red'],words2 = ['blue', 'green', 'purple', 'yellow', 'blue', 'green']) == 1\n assert candidate(words1 = ['foo', 'bar', 'baz', 'qux', 'quux'],words2 = ['qux', 'quux', 'foo', 'bar', 'baz', 'corge', 'grault', 'foo']) == 4\n assert candidate(words1 = ['example', 'test', 'case'],words2 = ['test', 'case', 'example', 'example', 'test', 'case']) == 0\n assert candidate(words1 = ['unique'],words2 = ['unique', 'unique', 'unique']) == 0\n assert candidate(words1 = ['x', 'y', 'z', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'],words2 = ['x', 'y', 'z', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a', 'x', 'y', 'z']) == 23\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g'],words2 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c', 'd', 'e', 'f', 'g']) == 0\n assert candidate(words1 = ['unique'],words2 = ['unique', 'unique', 'unique', 'unique']) == 0\n"}, "metadata": {"canonical_parameter_names": ["words1", "words2"], "leetcode_dataset_entry_point": "Solution().countWords", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countWords(self, words1: list[str], words2: list[str]) -> int:", "container": "Solution", "callable": "countWords", "parameters": [{"name": "words1", "type": "list[str]"}, {"name": "words2", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2086, "task_id": "minimum-number-of-food-buckets-to-feed-the-hamsters", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string hamsters where hamsters[i] is either:\n\n'H' indicating that there is a hamster at index i, or\n'.' indicating that index i is empty.\n\nYou will add some number of food buckets at the empty indices in order to feed the hamsters. A hamster can be fed if there is at least one food bucket to its left or to its right. More formally, a hamster at index i can be fed if you place a food bucket at index i - 1 and/or at index i + 1.\nReturn the minimum number of food buckets you should place at empty indices to feed all the hamsters or -1 if it is impossible to feed all of them.\n \nExample 1:\n\n\nInput: hamsters = \"H..H\"\nOutput: 2\nExplanation: We place two food buckets at indices 1 and 2.\nIt can be shown that if we place only one food bucket, one of the hamsters will not be fed.\n\nExample 2:\n\n\nInput: hamsters = \".H.H.\"\nOutput: 1\nExplanation: We place one food bucket at index 2.\n\nExample 3:\n\n\nInput: hamsters = \".HHH.\"\nOutput: -1\nExplanation: If we place a food bucket at every empty index as shown, the hamster at index 2 will not be able to eat.\n\n \nConstraints:\n\n1 <= hamsters.length <= 105\nhamsters[i] is either'H' or '.'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(hamsters = \"H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H\") == 3\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H\") == 5\n assert candidate(hamsters = \".....\") == 0\n assert candidate(hamsters = \".\") == 0\n assert candidate(hamsters = \"H..H\") == 2\n assert candidate(hamsters = \"H.H\") == 1\n assert candidate(hamsters = \"H....H\") == 2\n assert candidate(hamsters = \"H.H.H.H.H\") == 3\n assert candidate(hamsters = \"HHHH\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H\") == 4\n assert candidate(hamsters = \"HH\") == -1\n assert candidate(hamsters = \"H.H.HH\") == -1\n assert candidate(hamsters = \".HHH.\") == -1\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == 8\n assert candidate(hamsters = \"HH.HH.HH\") == -1\n assert candidate(hamsters = \"H.H.H\") == 2\n assert candidate(hamsters = \"HH.H.H.H.H\") == -1\n assert candidate(hamsters = \"H.H.H.H\") == 2\n assert candidate(hamsters = \"HH.HH\") == -1\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \".H.H.\") == 1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H\") == 4\n assert candidate(hamsters = \"H.HH\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H.H\") == 7\n assert candidate(hamsters = \"HHHHHH\") == -1\n assert candidate(hamsters = \"HH.H.H\") == -1\n assert candidate(hamsters = \"HH.H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H\") == 5\n assert candidate(hamsters = \"HH.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == 10\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"HH.H.HH\") == -1\n assert candidate(hamsters = \"......\") == 0\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H\") == 6\n assert candidate(hamsters = \"...\") == 0\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == 9\n assert candidate(hamsters = \"H.H.HH.H.H\") == 4\n assert candidate(hamsters = \"H.....H\") == 2\n assert candidate(hamsters = \"H.H.H.H.H.H.H\") == 4\n assert candidate(hamsters = \"H.....H\") == 2\n assert candidate(hamsters = \".......\") == 0\n assert candidate(hamsters = \"HH.HHHHH.HH\") == -1\n assert candidate(hamsters = \".H.H.\") == 1\n assert candidate(hamsters = \"H.H.H.H.HH\") == -1\n assert candidate(hamsters = \"........\") == 0\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H\") == 5\n assert candidate(hamsters = \"..H.H..\") == 1\n assert candidate(hamsters = \"H.H.H.H.H\") == 3\n assert candidate(hamsters = \"HH.H.H.HH\") == -1\n assert candidate(hamsters = \"HH\") == -1\n assert candidate(hamsters = \"H.HH.H\") == 2\n assert candidate(hamsters = \"HH.HH.HH.HH.HH.HH.HH.HH\") == -1\n assert candidate(hamsters = \"...\") == 0\n assert candidate(hamsters = \"H.\") == 1\n assert candidate(hamsters = \"H.H..H.H\") == 2\n assert candidate(hamsters = \"H.......H\") == 2\n assert candidate(hamsters = \"..H..H..\") == 2\n assert candidate(hamsters = \"HHHHH\") == -1\n assert candidate(hamsters = \"HH.HH\") == -1\n assert candidate(hamsters = \"HH.H.H.H.HH\") == -1\n assert candidate(hamsters = \"H...H\") == 2\n assert candidate(hamsters = \"HH.HHH.HH\") == -1\n assert candidate(hamsters = \"........\") == 0\n assert candidate(hamsters = \"H.H.H.HH.H\") == 3\n assert candidate(hamsters = \"HH.HH.HH.HH\") == -1\n assert candidate(hamsters = \"H.H.H.H\") == 2\n assert candidate(hamsters = \".\") == 0\n assert candidate(hamsters = \"HHHHHHHHHH\") == -1\n assert candidate(hamsters = \".HHH.\") == -1\n assert candidate(hamsters = \"H.H.H.HH\") == -1\n assert candidate(hamsters = \".H\") == 1\n assert candidate(hamsters = \".H.H.H.H.\") == 2\n assert candidate(hamsters = \"H.H.H\") == 2\n assert candidate(hamsters = \"H\") == -1\n assert candidate(hamsters = \".........\") == 0\n assert candidate(hamsters = \".H.H.H.H.H.H.H.H.H.\") == 5\n assert candidate(hamsters = \".H.H.H.H.H.H.H.H.\") == 4\n assert candidate(hamsters = \"HHHHHHH\") == -1\n assert candidate(hamsters = \"HH...HH\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H\") == 6\n assert candidate(hamsters = \"H......H\") == 2\n assert candidate(hamsters = \"H.H\") == 1\n assert candidate(hamsters = \"HH.HH.HH.HH.HH\") == -1\n assert candidate(hamsters = \"H..H\") == 2\n assert candidate(hamsters = \"HH..HH\") == -1\n assert candidate(hamsters = \"HHHH\") == -1\n"}, "metadata": {"canonical_parameter_names": ["hamsters"], "leetcode_dataset_entry_point": "Solution().minimumBuckets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumBuckets(self, hamsters: str) -> int:", "container": "Solution", "callable": "minimumBuckets", "parameters": [{"name": "hamsters", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2087, "task_id": "minimum-cost-homecoming-of-a-robot-in-a-grid", "difficulty": "Medium", "problem_description": "There is an m x n grid, where (0, 0) is the top-left cell and (m - 1, n - 1) is the bottom-right cell. You are given an integer array startPos where startPos = [startrow, startcol] indicates that initially, a robot is at the cell (startrow, startcol). You are also given an integer array homePos where homePos = [homerow, homecol] indicates that its home is at the cell (homerow, homecol).\nThe robot needs to go to its home. It can move one cell in four directions: left, right, up, or down, and it can not move outside the boundary. Every move incurs some cost. You are further given two 0-indexed integer arrays: rowCosts of length m and colCosts of length n.\n\nIf the robot moves up or down into a cell whose row is r, then this move costs rowCosts[r].\nIf the robot moves left or right into a cell whose column is c, then this move costs colCosts[c].\n\nReturn the minimum total cost for this robot to return home.\n \nExample 1:\n\n\nInput: startPos = [1, 0], homePos = [2, 3], rowCosts = [5, 4, 3], colCosts = [8, 2, 6, 7]\nOutput: 18\nExplanation: One optimal path is that:\nStarting from (1, 0)\n-> It goes down to (2, 0). This move costs rowCosts[2] = 3.\n-> It goes right to (2, 1). This move costs colCosts[1] = 2.\n-> It goes right to (2, 2). This move costs colCosts[2] = 6.\n-> It goes right to (2, 3). This move costs colCosts[3] = 7.\nThe total cost is 3 + 2 + 6 + 7 = 18\nExample 2:\n\nInput: startPos = [0, 0], homePos = [0, 0], rowCosts = [5], colCosts = [26]\nOutput: 0\nExplanation: The robot is already at its home. Since no moves occur, the total cost is 0.\n\n \nConstraints:\n\nm == rowCosts.length\nn == colCosts.length\n1 <= m, n <= 105\n0 <= rowCosts[r], colCosts[c] <= 104\nstartPos.length == 2\nhomePos.length == 2\n0 <= startrow, homerow < m\n0 <= startcol, homecol < n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(startPos = [2, 2],homePos = [0, 0],rowCosts = [1, 10, 1],colCosts = [1, 10, 1]) == 22\n assert candidate(startPos = [3, 3],homePos = [0, 0],rowCosts = [10, 20, 30, 40],colCosts = [5, 15, 25, 35]) == 105\n assert candidate(startPos = [1, 0],homePos = [2, 3],rowCosts = [5, 4, 3],colCosts = [8, 2, 6, 7]) == 18\n assert candidate(startPos = [0, 0],homePos = [2, 2],rowCosts = [1, 10, 1],colCosts = [1, 10, 1]) == 22\n assert candidate(startPos = [0, 0],homePos = [2, 2],rowCosts = [1, 1, 1],colCosts = [1, 1, 1]) == 4\n assert candidate(startPos = [1, 1],homePos = [1, 1],rowCosts = [1, 2, 3],colCosts = [4, 5, 6]) == 0\n assert candidate(startPos = [2, 2],homePos = [0, 0],rowCosts = [1, 1, 1],colCosts = [1, 1, 1]) == 4\n assert candidate(startPos = [0, 1],homePos = [2, 1],rowCosts = [3, 2, 1],colCosts = [4, 5]) == 3\n assert candidate(startPos = [0, 0],homePos = [0, 0],rowCosts = [5],colCosts = [26]) == 0\n assert candidate(startPos = [2, 2],homePos = [2, 2],rowCosts = [1, 2],colCosts = [3, 4]) == 0\n assert candidate(startPos = [3, 2],homePos = [0, 0],rowCosts = [1, 2, 3, 4],colCosts = [5, 6, 7]) == 17\n assert candidate(startPos = [0, 1],homePos = [3, 3],rowCosts = [3, 2, 1, 4],colCosts = [4, 3, 2, 1]) == 10\n assert candidate(startPos = [0, 2],homePos = [2, 2],rowCosts = [10, 20, 30],colCosts = [5, 5, 5]) == 50\n assert candidate(startPos = [2, 3],homePos = [1, 1],rowCosts = [1, 1, 1],colCosts = [1, 1, 1, 1]) == 3\n assert candidate(startPos = [2, 3],homePos = [1, 0],rowCosts = [5, 4, 3],colCosts = [8, 2, 6, 7]) == 20\n assert candidate(startPos = [0, 1],homePos = [2, 2],rowCosts = [1, 2, 3],colCosts = [4, 5, 6]) == 11\n assert candidate(startPos = [3, 3],homePos = [7, 7],rowCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(startPos = [1, 2],homePos = [3, 4],rowCosts = [5, 4, 3, 2],colCosts = [1, 2, 3, 4, 5]) == 14\n assert candidate(startPos = [0, 4],homePos = [4, 0],rowCosts = [1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1]) == 8\n assert candidate(startPos = [9, 0],homePos = [9, 9],rowCosts = [100],colCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 540\n assert candidate(startPos = [0, 0],homePos = [9, 9],rowCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],colCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 99\n assert candidate(startPos = [9, 0],homePos = [0, 9],rowCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],colCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 99\n assert candidate(startPos = [2, 3],homePos = [2, 3],rowCosts = [5, 4, 3],colCosts = [8, 2, 6, 7]) == 0\n assert candidate(startPos = [5, 2],homePos = [0, 0],rowCosts = [1, 2, 3, 4, 5, 6],colCosts = [6, 5, 4, 3, 2, 1]) == 26\n assert candidate(startPos = [2, 1],homePos = [2, 1],rowCosts = [1000, 2000, 3000, 4000],colCosts = [5000, 6000, 7000, 8000, 9000]) == 0\n assert candidate(startPos = [0, 9],homePos = [0, 0],rowCosts = [1],colCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 450\n assert candidate(startPos = [2, 3],homePos = [4, 1],rowCosts = [3, 2, 1, 4, 5],colCosts = [6, 7, 8, 9]) == 24\n assert candidate(startPos = [1, 2],homePos = [3, 4],rowCosts = [1, 2, 3, 4],colCosts = [4, 3, 2, 1]) == 8\n assert candidate(startPos = [0, 9],homePos = [9, 0],rowCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],colCosts = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1080\n assert candidate(startPos = [5, 2],homePos = [2, 5],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [60, 50, 40, 30, 20, 10]) == 180\n assert candidate(startPos = [1, 1],homePos = [3, 3],rowCosts = [5, 10, 15, 20],colCosts = [10, 20, 30, 40]) == 105\n assert candidate(startPos = [2, 2],homePos = [7, 2],rowCosts = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],colCosts = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(startPos = [2, 4],homePos = [2, 4],rowCosts = [100, 200, 300],colCosts = [100, 200, 300, 400, 500]) == 0\n assert candidate(startPos = [2, 2],homePos = [2, 2],rowCosts = [100, 200, 300, 400, 500],colCosts = [100, 200, 300, 400, 500]) == 0\n assert candidate(startPos = [0, 5],homePos = [5, 0],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [60, 50, 40, 30, 20, 10]) == 400\n assert candidate(startPos = [1, 2],homePos = [4, 3],rowCosts = [100, 200, 300, 400, 500],colCosts = [10, 20, 30, 40]) == 1240\n assert candidate(startPos = [0, 3],homePos = [3, 0],rowCosts = [10, 20, 30, 40],colCosts = [5, 6, 7, 8]) == 108\n assert candidate(startPos = [4, 4],homePos = [0, 0],rowCosts = [10, 20, 30, 40, 50],colCosts = [1, 2, 3, 4, 5]) == 110\n assert candidate(startPos = [1, 3],homePos = [4, 1],rowCosts = [2, 3, 5, 7, 11],colCosts = [13, 17, 19, 23]) == 59\n assert candidate(startPos = [5, 0],homePos = [0, 5],rowCosts = [1, 1, 1, 1, 1],colCosts = [1, 2, 3, 4, 5]) == 19\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [1, 1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1, 1]) == 10\n assert candidate(startPos = [3, 3],homePos = [0, 0],rowCosts = [10000, 9000, 8000, 7000],colCosts = [6000, 5000, 4000, 3000]) == 42000\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [6, 5, 4, 3, 2, 1]) == 170\n assert candidate(startPos = [0, 5],homePos = [5, 0],rowCosts = [2, 2, 2, 2, 2, 2],colCosts = [2, 2, 2, 2, 2, 2]) == 20\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],colCosts = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 550\n assert candidate(startPos = [3, 3],homePos = [1, 1],rowCosts = [100, 200, 300, 400],colCosts = [400, 300, 200, 100]) == 1000\n assert candidate(startPos = [7, 7],homePos = [2, 2],rowCosts = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2],colCosts = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 60\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [9, 8, 7, 6, 5, 4],colCosts = [3, 2, 1, 4, 5, 6]) == 50\n assert candidate(startPos = [0, 0],homePos = [4, 5],rowCosts = [10, 20, 30, 40, 50],colCosts = [5, 15, 25, 35, 45, 55]) == 315\n assert candidate(startPos = [4, 4],homePos = [6, 6],rowCosts = [5, 1, 2, 3, 4, 3, 2, 1, 5, 10],colCosts = [10, 1, 2, 3, 4, 3, 2, 1, 5, 10]) == 10\n assert candidate(startPos = [3, 3],homePos = [0, 0],rowCosts = [10, 20, 30, 40],colCosts = [40, 30, 20, 10]) == 150\n assert candidate(startPos = [0, 0],homePos = [5, 5],rowCosts = [1, 2, 3, 4, 5, 6],colCosts = [6, 5, 4, 3, 2, 1]) == 35\n assert candidate(startPos = [0, 9],homePos = [9, 0],rowCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 18\n assert candidate(startPos = [3, 2],homePos = [0, 0],rowCosts = [1, 1, 1, 1],colCosts = [1, 1, 1]) == 5\n assert candidate(startPos = [1, 0],homePos = [3, 2],rowCosts = [1, 1, 1, 1],colCosts = [1, 1, 1]) == 4\n assert candidate(startPos = [1, 2],homePos = [3, 0],rowCosts = [1, 1, 1, 1],colCosts = [1, 1, 1]) == 4\n assert candidate(startPos = [0, 0],homePos = [4, 4],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 4, 3, 2, 1]) == 24\n assert candidate(startPos = [10, 5],homePos = [10, 5],rowCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],colCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(startPos = [0, 0],homePos = [3, 3],rowCosts = [1, 2, 3, 4],colCosts = [1, 1, 1, 1]) == 12\n assert candidate(startPos = [5, 5],homePos = [1, 1],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [15, 25, 35, 45, 55, 65]) == 300\n assert candidate(startPos = [2, 2],homePos = [4, 4],rowCosts = [1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1]) == 4\n assert candidate(startPos = [0, 4],homePos = [4, 0],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 10, 15, 20, 25]) == 64\n assert candidate(startPos = [2, 0],homePos = [2, 4],rowCosts = [1, 2, 3],colCosts = [10, 20, 30, 40, 50]) == 140\n assert candidate(startPos = [3, 1],homePos = [0, 3],rowCosts = [5, 10, 15, 20],colCosts = [1, 2, 3, 4]) == 37\n assert candidate(startPos = [5, 5],homePos = [5, 5],rowCosts = [1, 1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1, 1]) == 0\n assert candidate(startPos = [2, 2],homePos = [2, 2],rowCosts = [100, 200, 300],colCosts = [100, 200, 300]) == 0\n assert candidate(startPos = [2, 2],homePos = [2, 2],rowCosts = [1000, 2000, 3000],colCosts = [100, 200, 300]) == 0\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [5, 15, 25, 35, 45, 55]) == 275\n assert candidate(startPos = [0, 3],homePos = [4, 0],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 4, 3, 2, 1]) == 26\n assert candidate(startPos = [3, 4],homePos = [0, 0],rowCosts = [10, 20, 30, 40],colCosts = [5, 15, 25, 35, 45]) == 140\n assert candidate(startPos = [4, 4],homePos = [4, 4],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 4, 3, 2, 1]) == 0\n assert candidate(startPos = [2, 2],homePos = [4, 4],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 4, 3, 2, 1]) == 12\n assert candidate(startPos = [4, 4],homePos = [1, 1],rowCosts = [5, 10, 15, 20, 25],colCosts = [1, 2, 3, 4, 5]) == 54\n assert candidate(startPos = [0, 2],homePos = [4, 2],rowCosts = [10, 20, 30, 40, 50],colCosts = [1, 2, 3]) == 140\n assert candidate(startPos = [4, 0],homePos = [0, 4],rowCosts = [10, 20, 30, 40, 50],colCosts = [50, 40, 30, 20, 10]) == 200\n assert candidate(startPos = [0, 5],homePos = [5, 0],rowCosts = [1, 1, 1, 1, 1, 1],colCosts = [99, 98, 97, 96, 95, 94]) == 490\n assert candidate(startPos = [1, 1],homePos = [3, 3],rowCosts = [1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1]) == 4\n assert candidate(startPos = [3, 0],homePos = [0, 3],rowCosts = [1, 2, 3, 4],colCosts = [1, 1, 1, 1, 1]) == 9\n assert candidate(startPos = [4, 0],homePos = [4, 4],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 10, 15, 20, 25]) == 70\n assert candidate(startPos = [1, 5],homePos = [3, 2],rowCosts = [1, 2, 3, 4],colCosts = [5, 4, 3, 2, 1]) == 13\n"}, "metadata": {"canonical_parameter_names": ["startPos", "homePos", "rowCosts", "colCosts"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minCost(self, startPos: list[int], homePos: list[int], rowCosts: list[int], colCosts: list[int]) -> int:", "container": "Solution", "callable": "minCost", "parameters": [{"name": "startPos", "type": "list[int]"}, {"name": "homePos", "type": "list[int]"}, {"name": "rowCosts", "type": "list[int]"}, {"name": "colCosts", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2088, "task_id": "count-fertile-pyramids-in-a-land", "difficulty": "Hard", "problem_description": "A farmer has a rectangular grid of land with m rows and n columns that can be divided into unit cells. Each cell is either fertile (represented by a 1) or barren (represented by a 0). All cells outside the grid are considered barren.\nA pyramidal plot of land can be defined as a set of cells with the following criteria:\n\nThe number of cells in the set has to be greater than 1 and all cells must be fertile.\nThe apex of a pyramid is the topmost cell of the pyramid. The height of a pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r <= i <= r + h - 1 and c - (i - r) <= j <= c + (i - r).\n\nAn inverse pyramidal plot of land can be defined as a set of cells with similar criteria:\n\nThe number of cells in the set has to be greater than 1 and all cells must be fertile.\nThe apex of an inverse pyramid is the bottommost cell of the inverse pyramid. The height of an inverse pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r - h + 1 <= i <= r and c - (r - i) <= j <= c + (r - i).\n\nSome examples of valid and invalid pyramidal (and inverse pyramidal) plots are shown below. Black cells indicate fertile cells.\n\nGiven a 0-indexed m x n binary matrix grid representing the farmland, return the total number of pyramidal and inverse pyramidal plots that can be found in grid.\n \nExample 1:\n\n\nInput: grid = [[0,1,1,0],[1,1,1,1]]\nOutput: 2\nExplanation: The 2 possible pyramidal plots are shown in blue and red respectively.\nThere are no inverse pyramidal plots in this grid. \nHence total number of pyramidal and inverse pyramidal plots is 2 + 0 = 2.\n\nExample 2:\n\n\nInput: grid = [[1,1,1],[1,1,1]]\nOutput: 2\nExplanation: The pyramidal plot is shown in blue, and the inverse pyramidal plot is shown in red. \nHence the total number of plots is 1 + 1 = 2.\n\nExample 3:\n\n\nInput: grid = [[1,1,1,1,0],[1,1,1,1,1],[1,1,1,1,1],[0,1,0,0,1]]\nOutput: 13\nExplanation: There are 7 pyramidal plots, 3 of which are shown in the 2nd and 3rd figures.\nThere are 6 inverse pyramidal plots, 2 of which are shown in the last figure.\nThe total number of plots is 7 + 6 = 13.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 1000\n1 <= m * n <= 105\ngrid[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 0], [1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 30\n assert candidate(grid = [[1, 1, 0, 1], [1, 1, 1, 1], [0, 1, 1, 0]]) == 3\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 14\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 8\n assert candidate(grid = [[1, 1, 1], [1, 1, 1]]) == 2\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [0, 1, 0, 0, 1]]) == 13\n assert candidate(grid = [[0, 1, 1, 0, 0, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1]]) == 4\n assert candidate(grid = [[1, 1], [1, 1]]) == 0\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0]]) == 32\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0]]) == 54\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 120\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0]]) == 24\n assert candidate(grid = [[1, 1, 1, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1]]) == 34\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 8\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 36\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 24\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 41\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0]]) == 88\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 80\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0]]) == 16\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1140\n assert candidate(grid = [[0, 0, 1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0]]) == 75\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 12\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 8\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]]) == 50\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 128\n assert candidate(grid = [[1, 0, 1, 0, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0]]) == 19\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 18\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == 40\n assert candidate(grid = [[1, 1, 1, 0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 14\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 0, 1, 1, 0, 1]]) == 14\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 100\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0]]) == 177\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 8\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 24\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 53\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 200\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 54\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0]]) == 112\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().countPyramids", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countPyramids(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "countPyramids", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2089, "task_id": "find-target-indices-after-sorting-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums and a target element target.\nA target index is an index i such that nums[i] == target.\nReturn a list of the target indices of nums after sorting nums in non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing order.\n \nExample 1:\n\nInput: nums = [1,2,5,2,3], target = 2\nOutput: [1,2]\nExplanation: After sorting, nums is [1,2,2,3,5].\nThe indices where nums[i] == 2 are 1 and 2.\n\nExample 2:\n\nInput: nums = [1,2,5,2,3], target = 3\nOutput: [3]\nExplanation: After sorting, nums is [1,2,2,3,5].\nThe index where nums[i] == 3 is 3.\n\nExample 3:\n\nInput: nums = [1,2,5,2,3], target = 5\nOutput: [4]\nExplanation: After sorting, nums is [1,2,2,3,5].\nThe index where nums[i] == 5 is 4.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i], target <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 99, 98, 97, 96],target = 98) == [2]\n assert candidate(nums = [10, 20, 30, 40, 50],target = 50) == [4]\n assert candidate(nums = [7, 7, 7, 7, 7],target = 8) == []\n assert candidate(nums = [10, 20, 30, 40, 50],target = 25) == []\n assert candidate(nums = [1, 3, 5, 7, 9],target = 0) == []\n assert candidate(nums = [50, 40, 30, 20, 10],target = 15) == []\n assert candidate(nums = [100, 100, 100],target = 100) == [0, 1, 2]\n assert candidate(nums = [1, 2, 5, 2, 3],target = 3) == [3]\n assert candidate(nums = [2, 4, 6, 8, 10],target = 2) == [0]\n assert candidate(nums = [5, 5, 5, 5, 5],target = 5) == [0, 1, 2, 3, 4]\n assert candidate(nums = [1, 1, 1, 1, 1],target = 1) == [0, 1, 2, 3, 4]\n assert candidate(nums = [5, 4, 3, 2, 1],target = 3) == [2]\n assert candidate(nums = [1, 3, 5, 7, 9],target = 2) == []\n assert candidate(nums = [1, 2, 2, 2, 3, 4],target = 2) == [1, 2, 3]\n assert candidate(nums = [1, 2, 5, 2, 3],target = 2) == [1, 2]\n assert candidate(nums = [50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4]\n assert candidate(nums = [5, 5, 5, 5, 5],target = 6) == []\n assert candidate(nums = [1, 3, 5, 7, 9],target = 10) == []\n assert candidate(nums = [100, 1, 100, 1, 100],target = 1) == [0, 1]\n assert candidate(nums = [1, 2, 5, 2, 3],target = 5) == [4]\n assert candidate(nums = [1, 1, 1, 1, 1],target = 2) == []\n assert candidate(nums = [1, 3, 5, 7, 9],target = 4) == []\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 4) == [6, 7]\n assert candidate(nums = [5, 4, 3, 2, 1],target = 3) == [2]\n assert candidate(nums = [90, 80, 70, 60, 50, 40, 30, 20, 10],target = 45) == []\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 50) == [4]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],target = 95) == [5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10],target = 7) == [6]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],target = 5) == [4]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],target = 27) == [8]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],target = 4) == [3]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],target = 5) == [4]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],target = 35) == [6]\n assert candidate(nums = [100, 100, 99, 99, 98, 98, 97, 97],target = 99) == [4, 5]\n assert candidate(nums = [45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31],target = 37) == [6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 1) == [0]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 8) == [3]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 10) == []\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5) == [4]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 20) == []\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],target = 4) == [3]\n assert candidate(nums = [42, 24, 36, 18, 54, 30, 48, 27, 60, 39],target = 30) == [3]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],target = 5) == [4]\n assert candidate(nums = [100, 50, 30, 70, 20],target = 30) == [1]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 50) == [4]\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],target = 8) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [42, 23, 37, 23, 42, 37],target = 37) == [2, 3]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 4) == [7, 8, 9, 10]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7],target = 15) == [8]\n assert candidate(nums = [100, 99, 98, 97, 96, 95],target = 98) == [3]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],target = 55) == [5]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = 15) == [7]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 10) == [9]\n assert candidate(nums = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1],target = 2) == [5, 6, 7, 8, 9]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 55) == []\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 1) == [0]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],target = 35) == [4]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],target = 3) == [6, 7, 8]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 20) == [9]\n assert candidate(nums = [100, 99, 98, 97, 96],target = 97) == [1]\n assert candidate(nums = [8, 6, 6, 6, 8, 6, 8, 6, 8, 6, 6, 6, 6, 6],target = 6) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [42, 27, 89, 10, 56, 23, 50, 78, 34, 67],target = 50) == [5]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 8) == []\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 10) == [18, 19]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 40) == [3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 11) == []\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9],target = 7) == [4]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],target = 5) == [4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10) == [9]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],target = 13) == [12]\n assert candidate(nums = [50, 20, 30, 40, 10],target = 30) == [2]\n assert candidate(nums = [100, 1, 50, 20, 30, 60, 40],target = 30) == [2]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 6) == [5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [14]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],target = 10) == [9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15) == [14]\n assert candidate(nums = [50, 50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 8) == [7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 11) == []\n assert candidate(nums = [10, 20, 30, 40, 50],target = 20) == [1]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],target = 20) == [5, 6, 7, 8, 9]\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [5]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 17) == []\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],target = 95) == [4]\n assert candidate(nums = [50, 20, 30, 10, 40],target = 30) == [2]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 6) == []\n assert candidate(nums = [3, 1, 2, 5, 4, 2, 3, 3, 5, 1],target = 3) == [4, 5, 6]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1],target = 2) == []\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 6) == []\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 18) == [8]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5) == [4]\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100],target = 1) == [0, 1, 2]\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3],target = 2) == [3, 4, 5]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5) == [4]\n assert candidate(nums = [50, 20, 30, 40, 10],target = 20) == [1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 10) == []\n assert candidate(nums = [50, 20, 30, 40, 10, 60, 70, 80, 90, 100],target = 40) == [3]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 10) == [9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 21) == []\n assert candidate(nums = [3, 1, 2, 5, 4],target = 4) == [3]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [8]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10],target = 15) == [5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 55) == []\n assert candidate(nums = [10, 20, 10, 20, 10, 20],target = 10) == [0, 1, 2]\n assert candidate(nums = [50, 40, 30, 20, 10],target = 30) == [2]\n assert candidate(nums = [100, 200, 300, 400, 500],target = 250) == []\n assert candidate(nums = [50, 40, 30, 20, 10],target = 20) == [1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [14]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 6) == [5]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],target = 25) == [12]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 5) == [4]\n assert candidate(nums = [3, 1, 2, 4, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 3) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(nums = [42, 37, 58, 54, 19, 91, 49, 100, 65, 28, 74, 99, 96, 33, 80, 78, 60, 82, 97, 71],target = 74) == [11]\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().targetIndices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def targetIndices(self, nums: list[int], target: int) -> list[int]:", "container": "Solution", "callable": "targetIndices", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2090, "task_id": "k-radius-subarray-averages", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums of n integers, and an integer k.\nThe k-radius average for a subarray of nums centered at some index i with the radius k is the average of all elements in nums between the indices i - k and i + k (inclusive). If there are less than k elements before or after the index i, then the k-radius average is -1.\nBuild and return an array avgs of length n where avgs[i] is the k-radius average for the subarray centered at index i.\nThe average of x elements is the sum of the x elements divided by x, using integer division. The integer division truncates toward zero, which means losing its fractional part.\n\nFor example, the average of four elements 2, 3, 1, and 5 is (2 + 3 + 1 + 5) / 4 = 11 / 4 = 2.75, which truncates to 2.\n\n \nExample 1:\n\n\nInput: nums = [7,4,3,9,1,8,5,2,6], k = 3\nOutput: [-1,-1,-1,5,4,4,-1,-1,-1]\nExplanation:\n- avg[0], avg[1], and avg[2] are -1 because there are less than k elements before each index.\n- The sum of the subarray centered at index 3 with radius 3 is: 7 + 4 + 3 + 9 + 1 + 8 + 5 = 37.\n Using integer division, avg[3] = 37 / 7 = 5.\n- For the subarray centered at index 4, avg[4] = (4 + 3 + 9 + 1 + 8 + 5 + 2) / 7 = 4.\n- For the subarray centered at index 5, avg[5] = (3 + 9 + 1 + 8 + 5 + 2 + 6) / 7 = 4.\n- avg[6], avg[7], and avg[8] are -1 because there are less than k elements after each index.\n\nExample 2:\n\nInput: nums = [100000], k = 0\nOutput: [100000]\nExplanation:\n- The sum of the subarray centered at index 0 with radius 0 is: 100000.\n avg[0] = 100000 / 1 = 100000.\n\nExample 3:\n\nInput: nums = [8], k = 100000\nOutput: [-1]\nExplanation: \n- avg[0] is -1 because there are less than k elements before and after index 0.\n\n \nConstraints:\n\nn == nums.length\n1 <= n <= 105\n0 <= nums[i], k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0],k = 2) == [-1, -1, 0, -1, -1]\n assert candidate(nums = [100000],k = 0) == [100000]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == [-1, -1, -1, -1, 5, 5, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 2) == [-1, -1, 3, 4, 5, 6, 7, -1, -1]\n assert candidate(nums = [8],k = 100000) == [-1]\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == [-1, -1, 3, -1, -1]\n assert candidate(nums = [5],k = 0) == [5]\n assert candidate(nums = [5, 5, 5, 5, 5],k = 1) == [-1, 5, 5, 5, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == [-1, -1, -1, -1, 5, 6, -1, -1, -1, -1]\n assert candidate(nums = [7, 4, 3, 9, 1, 8, 5, 2, 6],k = 3) == [-1, -1, -1, 5, 4, 4, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == [-1, 2, 3, 4, -1]\n assert candidate(nums = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],k = 3) == [-1, -1, -1, 102, 103, 104, 105, 106, 107, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 8, 9, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 0) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5) == [-1, -1, -1, -1, -1, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 12) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 5) == [-1, -1, -1, -1, -1, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, -1, -1, -1, -1, -1]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 0) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == [-1, -1, -1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 3) == [-1, -1, -1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4) == [-1, -1, -1, -1, 5, 4, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 3) == [-1, -1, -1, 2, 1, 1, 1, 2, -1, -1, -1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == [-1, -1, -1, -1, 6, 5, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 2) == [-1, -1, 3, 2, 1, 1, 1, 2, 3, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 3) == [-1, -1, -1, 7, 9, 11, 13, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 4) == [-1, -1, -1, -1, 0, 0, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2) == [-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 4) == [-1, -1, -1, -1, 5000, 6000, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == [-1, -1, -1, -1, -1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 2) == [-1, -1, 99998, 99997, 99996, 99995, 99994, 99993, -1, -1]\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],k = 4) == [-1, -1, -1, -1, 99995, 99994, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 4) == [-1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 6) == [-1, -1, -1, -1, -1, -1, 7, 8, 9, 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == [-1, 8, 7, 6, 5, 4, 3, 2, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 8) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 8) == [-1, -1, -1, -1, -1, -1, -1, -1, 90, 100, 110, 120, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0],k = 4) == [-1, -1, -1, -1, 55555, 44444, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 4) == [-1, -1, -1, -1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 0) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 4) == [-1, -1, -1, -1, 60000, 50000, -1, -1, -1, -1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 2) == [-1, -1, 15, 20, 25, 30, 35, 40, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 5, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0],k = 2) == [-1, -1, 60000, 40000, 60000, 40000, 60000, 40000, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5) == [-1, -1, -1, -1, -1, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 5) == [-1, -1, -1, -1, -1, 600, 700, 800, 900, 1000, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == [-1, -1, -1, -1, -1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 3) == [-1, -1, -1, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 0) == [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 4) == [-1, -1, -1, -1, 5, 6, 7, 8, 9, 10, 11, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == [-1, -1, -1, 40, 50, 60, 70, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == [-1, -1, -1, 0, 0, 0, 0, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1],k = 1) == [-1, 5, 5, 5, 5, 4, 6, 4, -1]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 5) == [-1, -1, -1, -1, -1, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 2) == [-1, -1, 3, 2, 1, 1, 1, 2, 3, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 2) == [-1, -1, 80000, 70000, 60000, 50000, 40000, 30000, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2) == [-1, -1, 30, 40, 50, 60, 70, 80, -1, -1]\n assert candidate(nums = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],k = 4) == [-1, -1, -1, -1, 99999, 99999, -1, -1, -1, -1]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 4) == [-1, -1, -1, -1, 100000, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == [-1, -1, -1, 40, 50, 60, 70, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 15, 17, 19, 21, 23, 25, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == [-1, -1, 300, 400, 500, 600, 700, 800, -1, -1]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == [-1, -1, -1, -1, -1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 4) == [-1, -1, -1, -1, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 1) == [-1, 3, 5, 7, 9, 11, 13, 15, 17, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [6, 10, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 2) == [-1, -1, 5, 5, 4, 4, 5, 5, 4, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2) == [-1, -1, 0, 0, 0, 0, 0, 0, -1, -1]\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().getAverages", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getAverages(self, nums: list[int], k: int) -> list[int]:", "container": "Solution", "callable": "getAverages", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2091, "task_id": "removing-minimum-and-maximum-from-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of distinct integers nums.\nThere is an element in nums that has the lowest value and an element that has the highest value. We call them the minimum and maximum respectively. Your goal is to remove both these elements from the array.\nA deletion is defined as either removing an element from the front of the array or removing an element from the back of the array.\nReturn the minimum number of deletions it would take to remove both the minimum and maximum element from the array.\n \nExample 1:\n\nInput: nums = [2,10,7,5,4,1,8,6]\nOutput: 5\nExplanation: \nThe minimum element in the array is nums[5], which is 1.\nThe maximum element in the array is nums[1], which is 10.\nWe can remove both the minimum and maximum by removing 2 elements from the front and 3 elements from the back.\nThis results in 2 + 3 = 5 deletions, which is the minimum number possible.\n\nExample 2:\n\nInput: nums = [0,-4,19,1,8,-2,-3,5]\nOutput: 3\nExplanation: \nThe minimum element in the array is nums[1], which is -4.\nThe maximum element in the array is nums[2], which is 19.\nWe can remove both the minimum and maximum by removing 3 elements from the front.\nThis results in only 3 deletions, which is the minimum number possible.\n\nExample 3:\n\nInput: nums = [101]\nOutput: 1\nExplanation: \nThere is only one element in the array, which makes it both the minimum and maximum element.\nWe can remove it with 1 deletion.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n-105 <= nums[i] <= 105\nThe integers in nums are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 10, 7, 5, 4, 1, 8, 6]) == 5\n assert candidate(nums = [100000, -100000, 50000, -50000]) == 2\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [101]) == 1\n assert candidate(nums = [3, 1, 2, 4, 5]) == 3\n assert candidate(nums = [100000, -100000, 50000, -50000, 0]) == 2\n assert candidate(nums = [0, -4, 19, 1, 8, -2, -3, 5]) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [1, 3, 2]) == 2\n assert candidate(nums = [3, 1]) == 2\n assert candidate(nums = [3, 2, 1]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 2\n assert candidate(nums = [-1, 1]) == 2\n assert candidate(nums = [5, 3, 1, 2, 4]) == 3\n assert candidate(nums = [5, 3, 1, 4, 2]) == 3\n assert candidate(nums = [99, 97, 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59, 57, 55, 53, 51]) == 2\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991, -99990, -99989, -99988, -99987, -99986, -99985, -99984, -99983, -99982, -99981, -99980, -99979, -99978, -99977, -99976, -99975, -99974, -99973, -99972, -99971, -99970, 100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970]) == 32\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 2\n assert candidate(nums = [-50000, 49999, -49999, 49998, -49998, 49997, -49997, 49996, -49996, 49995]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 2\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [3, 1, 2, 5, 4, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [-7, 10, 5, -3, 2, 8, 0, -1, 6, 4]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 2\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(nums = [3, 7, 1, 9, 5, 2, 8, 4, 6]) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500]) == 6\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 2\n assert candidate(nums = [30, 20, 10, 0, -10, -20, -30, 40, 50, 60, 70, 80, 90, 100]) == 8\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995]) == 2\n assert candidate(nums = [-1, -5, -3, -7, -2, -6, -4]) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500, 0]) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14]) == 13\n assert candidate(nums = [9, 3, 5, 2, 7, 6, 1, 8, 4]) == 4\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 75000, -75000, 12500, -12500]) == 2\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 2\n assert candidate(nums = [3, 1, 2, 5, 4]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1]) == 2\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == 2\n assert candidate(nums = [5, 2, 8, 3, 7, 6, 4, 10, 1, 9]) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 2\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 2\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 2\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 2\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 8, 7, 10, 9]) == 4\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [-5, -10, -3, -1, -8, -2, -7, -4, -6, -9]) == 4\n assert candidate(nums = [3, 1, 2]) == 2\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -1]) == 2\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7]) == 22\n assert candidate(nums = [40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21]) == 2\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, 0]) == 3\n assert candidate(nums = [1, 10, 3, 8, 5, 2, 7, 4, 6, 9]) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 6\n assert candidate(nums = [1000, 100, 10, 1, 0, -1, -10, -100, -1000, 500, 50, 5, 0.5, 0.05, 0.005, 0.0005, 5e-05]) == 9\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500, 6250, -6250]) == 2\n assert candidate(nums = [-10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2\n assert candidate(nums = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(nums = [10, 2, 8, 6, 7, 3, 5, 1, 9, 4]) == 4\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 11\n assert candidate(nums = [-100000, 100000, 1, -1, 50000, -50000, 99999, -99999, 42, -42]) == 2\n assert candidate(nums = [7, 3, 5, 2, 8, 6, 4, 1]) == 4\n assert candidate(nums = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 2\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [20, 18, 19, 16, 17, 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 1]) == 2\n assert candidate(nums = [9, 3, 15, 1, 12, 7, 8, 6, 10, 2]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6]) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 8, 18, 28, 38, 48, 58, 68, 78, 88, 98, 7, 17, 27, 37, 47, 57, 67, 77, 87, 97, 6, 16, 26, 36, 46, 56, 66, 76, 86, 96, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 4, 14, 24, 34, 44, 54, 64, 74, 84, 94, 3, 13, 23, 33, 43, 53, 63, 73, 83, 93, 2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 1, 11, 21, 31, 41, 51, 61, 71, 81, 91]) == 20\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 2\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993, 9, 99992, 10, 99991, 11, 99990, 12, 99989, 13, 99988, 14, 99987, 15, 99986, 16, 99985, 17, 99984, 18, 99983, 19, 99982, 20, 99981, 21, 99980, 22, 99979, 23, 99978, 24, 99977, 25, 99976, 26, 99975, 27, 99974, 28, 99973, 29, 99972, 30, 99971]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7]) == 2\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumDeletions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumDeletions(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minimumDeletions", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2092, "task_id": "find-all-people-with-secret", "difficulty": "Hard", "problem_description": "You are given an integer n indicating there are n people numbered from 0 to n - 1. You are also given a 0-indexed 2D integer array meetings where meetings[i] = [xi, yi, timei] indicates that person xi and person yi have a meeting at timei. A person may attend multiple meetings at the same time. Finally, you are given an integer firstPerson.\nPerson 0 has a secret and initially shares the secret with a person firstPerson at time 0. This secret is then shared every time a meeting takes place with a person that has the secret. More formally, for every meeting, if a person xi has the secret at timei, then they will share the secret with person yi, and vice versa.\nThe secrets are shared instantaneously. That is, a person may receive the secret and share it with people in other meetings within the same time frame.\nReturn a list of all the people that have the secret after all the meetings have taken place. You may return the answer in any order.\n \nExample 1:\n\nInput: n = 6, meetings = [[1,2,5],[2,3,8],[1,5,10]], firstPerson = 1\nOutput: [0,1,2,3,5]\nExplanation:\nAt time 0, person 0 shares the secret with person 1.\nAt time 5, person 1 shares the secret with person 2.\nAt time 8, person 2 shares the secret with person 3.\nAt time 10, person 1 shares the secret with person 5.​​​​\nThus, people 0, 1, 2, 3, and 5 know the secret after all the meetings.\n\nExample 2:\n\nInput: n = 4, meetings = [[3,1,3],[1,2,2],[0,3,3]], firstPerson = 3\nOutput: [0,1,3]\nExplanation:\nAt time 0, person 0 shares the secret with person 3.\nAt time 2, neither person 1 nor person 2 know the secret.\nAt time 3, person 3 shares the secret with person 0 and person 1.\nThus, people 0, 1, and 3 know the secret after all the meetings.\n\nExample 3:\n\nInput: n = 5, meetings = [[3,4,2],[1,2,1],[2,3,1]], firstPerson = 1\nOutput: [0,1,2,3,4]\nExplanation:\nAt time 0, person 0 shares the secret with person 1.\nAt time 1, person 1 shares the secret with person 2, and person 2 shares the secret with person 3.\nNote that person 2 can share the secret at the same time as receiving it.\nAt time 2, person 3 shares the secret with person 4.\nThus, people 0, 1, 2, 3, and 4 know the secret after all the meetings.\n\n \nConstraints:\n\n2 <= n <= 105\n1 <= meetings.length <= 105\nmeetings[i].length == 3\n0 <= xi, yi <= n - 1\nxi != yi\n1 <= timei <= 105\n1 <= firstPerson <= n - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,meetings = [[0, 1, 10], [1, 2, 20]],firstPerson = 1) == [0, 1, 2]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 3,meetings = [[0, 1, 1], [1, 2, 2], [0, 2, 3]],firstPerson = 2) == [0, 1, 2]\n assert candidate(n = 5,meetings = [[3, 4, 2], [1, 2, 1], [2, 3, 1]],firstPerson = 1) == [0, 1, 2, 3, 4]\n assert candidate(n = 7,meetings = [[0, 1, 10], [1, 2, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 4,meetings = [[3, 1, 3], [1, 2, 2], [0, 3, 3]],firstPerson = 3) == [0, 1, 3]\n assert candidate(n = 7,meetings = [[0, 2, 1], [1, 3, 2], [2, 4, 3], [3, 5, 4], [4, 6, 5]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 3,meetings = [[0, 1, 10], [1, 2, 20], [2, 0, 30]],firstPerson = 2) == [0, 1, 2]\n assert candidate(n = 3,meetings = [[0, 1, 1], [1, 2, 2], [0, 2, 3]],firstPerson = 1) == [0, 1, 2]\n assert candidate(n = 7,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 6,meetings = [[1, 2, 5], [2, 3, 8], [1, 5, 10]],firstPerson = 1) == [0, 1, 2, 3, 5]\n assert candidate(n = 7,meetings = [[0, 2, 1], [1, 3, 1], [4, 5, 1], [5, 6, 1]],firstPerson = 2) == [0, 2]\n assert candidate(n = 15,meetings = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 0, 75]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 10,meetings = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [1, 5, 2], [2, 6, 2], [3, 7, 2], [4, 8, 2], [5, 9, 3], [6, 9, 3], [7, 9, 3], [8, 9, 3]],firstPerson = 9) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 2], [2, 0, 3], [3, 4, 4], [4, 5, 5], [5, 3, 6], [6, 7, 7], [7, 8, 8], [8, 6, 9], [9, 10, 10], [10, 11, 11], [11, 9, 12]],firstPerson = 1) == [0, 1, 2]\n assert candidate(n = 7,meetings = [[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3]],firstPerson = 2) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 11,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 0, 11]],firstPerson = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 0, 1], [0, 5, 2], [1, 6, 2], [2, 7, 2], [3, 8, 2], [4, 9, 2], [5, 10, 2], [6, 11, 2], [7, 0, 2], [8, 1, 2], [9, 2, 2], [10, 3, 2], [11, 4, 2]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 20,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19]],firstPerson = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12]],firstPerson = 6) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 20,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20]],firstPerson = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 7, 9], [1, 6, 10], [2, 5, 11], [3, 4, 12]],firstPerson = 4) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 2, 11], [1, 3, 12], [2, 4, 13], [3, 5, 14], [4, 6, 15], [5, 7, 16], [6, 8, 17], [7, 9, 18], [8, 0, 19], [9, 1, 20]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 10,meetings = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 6,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 0, 6]],firstPerson = 1) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 0, 1]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 9,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 0, 9], [0, 5, 10]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(n = 20,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 0, 1]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 15,meetings = [[0, 1, 10], [0, 2, 10], [1, 3, 20], [1, 4, 20], [2, 5, 30], [2, 6, 30], [3, 7, 40], [3, 8, 40], [4, 9, 50], [4, 10, 50], [5, 11, 60], [5, 12, 60], [6, 13, 70], [6, 14, 70]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 10,meetings = [[0, 9, 1], [1, 8, 2], [2, 7, 3], [3, 6, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],firstPerson = 5) == [0, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 15,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [0, 7, 8], [1, 6, 8], [2, 5, 8], [3, 4, 8]],firstPerson = 0) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 6,meetings = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50]],firstPerson = 1) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 0, 2], [1, 3, 3], [2, 4, 3], [3, 5, 3], [4, 6, 3], [5, 7, 3], [6, 8, 3], [7, 9, 3], [8, 0, 3], [9, 1, 3]],firstPerson = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 10,meetings = [[0, 9, 1], [1, 8, 2], [2, 7, 3], [3, 6, 4], [4, 5, 5], [5, 4, 5], [6, 3, 4], [7, 2, 3], [8, 1, 2], [9, 0, 1]],firstPerson = 5) == [0, 4, 5, 9]\n assert candidate(n = 15,meetings = [[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 7, 4], [3, 8, 4], [4, 9, 5], [4, 10, 5], [5, 11, 6], [5, 12, 6], [6, 13, 7], [6, 14, 7]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 10,meetings = [[0, 9, 1], [0, 8, 1], [1, 7, 2], [1, 6, 2], [2, 5, 3], [2, 4, 3], [3, 3, 4], [4, 2, 4], [5, 1, 5], [6, 0, 5]],firstPerson = 5) == [0, 1, 2, 4, 5, 6, 8, 9]\n assert candidate(n = 10,meetings = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [0, 5, 1], [0, 6, 1], [0, 7, 1], [0, 8, 1], [0, 9, 1]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 9,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 0, 9], [0, 2, 10], [1, 3, 11], [2, 4, 12], [3, 5, 13], [4, 6, 14], [5, 7, 15], [6, 8, 16], [7, 0, 17], [8, 1, 18]],firstPerson = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [1, 3, 9], [3, 5, 10], [5, 7, 11], [7, 1, 12]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 10,meetings = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5]],firstPerson = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12], [0, 11, 13]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 7,meetings = [[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 4, 4], [3, 5, 5], [4, 6, 6], [5, 6, 7]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 15,meetings = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 7,meetings = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [0, 6, 70]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 9, 11], [1, 8, 12], [2, 7, 13], [3, 6, 14], [4, 5, 15]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 7,meetings = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 4, 4], [3, 5, 5], [4, 6, 6], [5, 6, 7]],firstPerson = 2) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 6,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5]],firstPerson = 1) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 10,meetings = [[0, 9, 10], [1, 2, 10], [3, 4, 10], [5, 6, 10], [7, 8, 10], [1, 3, 10], [2, 4, 10], [5, 7, 10], [6, 8, 10]],firstPerson = 1) == [0, 1, 2, 3, 4, 9]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 2], [2, 0, 3], [0, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 11]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 5, 3], [5, 6, 3], [6, 7, 4], [7, 8, 4], [8, 9, 5]],firstPerson = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 8,meetings = [[0, 1, 1], [2, 3, 2], [4, 5, 3], [6, 7, 4], [0, 2, 5], [1, 3, 6], [2, 4, 7], [3, 5, 8], [4, 6, 9], [5, 7, 10]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 7,meetings = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 0, 5]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 8,meetings = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 6,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 5, 3], [5, 0, 3], [1, 4, 4], [2, 5, 5]],firstPerson = 2) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 7,meetings = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [5, 6, 35], [6, 0, 40]],firstPerson = 6) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 15,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 3, 9], [1, 5, 10]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 10,meetings = [[0, 4, 5], [4, 5, 5], [0, 1, 6], [1, 2, 6], [2, 3, 7], [3, 4, 7], [4, 6, 8], [5, 7, 9], [6, 8, 10], [7, 9, 11]],firstPerson = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 20,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20]],firstPerson = 19) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 15,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15], [0, 7, 16], [7, 11, 17], [11, 14, 18]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 7,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 0, 7], [0, 6, 8]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 15,meetings = [[0, 1, 1], [2, 3, 1], [4, 5, 1], [6, 7, 1], [8, 9, 1], [10, 11, 1], [12, 13, 1], [13, 14, 1], [0, 2, 2], [1, 3, 2], [4, 6, 2], [5, 7, 2], [8, 10, 2], [9, 11, 2], [12, 14, 2], [13, 0, 3], [14, 1, 3], [0, 4, 3], [1, 5, 3], [2, 6, 3], [3, 7, 3], [4, 8, 3], [5, 9, 3], [6, 10, 3], [7, 11, 3], [8, 12, 3], [9, 13, 3], [10, 14, 3]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 10,meetings = [[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 4, 4], [3, 5, 5], [4, 6, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 11], [0, 3, 12], [1, 5, 13], [2, 4, 14]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 15,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 5, 3], [5, 6, 3], [6, 7, 4], [7, 8, 4], [8, 9, 5], [9, 10, 5], [10, 11, 6], [11, 12, 6], [12, 13, 7], [13, 14, 7], [14, 0, 8]],firstPerson = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10]],firstPerson = 9) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 7,meetings = [[0, 1, 1], [1, 2, 2], [0, 3, 3], [3, 4, 4], [0, 5, 5], [5, 6, 6], [2, 4, 7], [1, 6, 8]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 6,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [0, 5, 6]],firstPerson = 1) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 15,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 10,meetings = [[0, 9, 10], [1, 8, 10], [2, 7, 10], [3, 6, 10], [4, 5, 10], [0, 1, 20], [1, 2, 20], [2, 3, 20], [3, 4, 20], [4, 5, 20]],firstPerson = 9) == [0, 1, 2, 3, 4, 5, 9]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12], [0, 6, 13], [1, 7, 14], [2, 8, 15], [3, 9, 16], [4, 10, 17], [5, 11, 18]],firstPerson = 6) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 6,meetings = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5]],firstPerson = 1) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 9,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 0, 9], [0, 2, 10], [1, 3, 11], [2, 4, 12], [3, 5, 13], [4, 6, 14], [5, 7, 15], [6, 8, 16], [7, 0, 17], [8, 1, 18]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(n = 15,meetings = [[0, 1, 10], [1, 2, 11], [2, 3, 12], [3, 4, 13], [4, 5, 14], [5, 6, 15], [6, 7, 16], [7, 8, 17], [8, 9, 18], [9, 10, 19], [10, 11, 20], [11, 12, 21], [12, 13, 22], [13, 14, 23]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 6,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 0, 6], [0, 2, 7], [1, 3, 8], [2, 4, 9], [3, 5, 10]],firstPerson = 0) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 0, 1]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 7,meetings = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 4], [1, 5, 5], [2, 6, 6], [3, 6, 6], [4, 5, 5], [4, 6, 6], [5, 6, 6]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6]\n"}, "metadata": {"canonical_parameter_names": ["n", "meetings", "firstPerson"], "leetcode_dataset_entry_point": "Solution().findAllPeople", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findAllPeople(self, n: int, meetings: list[list[int]], firstPerson: int) -> list[int]:", "container": "Solution", "callable": "findAllPeople", "parameters": [{"name": "n", "type": "int"}, {"name": "meetings", "type": "list[list[int]]"}, {"name": "firstPerson", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2094, "task_id": "finding-3-digit-even-numbers", "difficulty": "Easy", "problem_description": "You are given an integer array digits, where each element is a digit. The array may contain duplicates.\nYou need to find all the unique integers that follow the given requirements:\n\nThe integer consists of the concatenation of three elements from digits in any arbitrary order.\nThe integer does not have leading zeros.\nThe integer is even.\n\nFor example, if the given digits were [1, 2, 3], integers 132 and 312 follow the requirements.\nReturn a sorted array of the unique integers.\n \nExample 1:\n\nInput: digits = [2,1,3,0]\nOutput: [102,120,130,132,210,230,302,310,312,320]\nExplanation: All the possible integers that follow the requirements are in the output array. \nNotice that there are no odd integers or integers with leading zeros.\n\nExample 2:\n\nInput: digits = [2,2,8,8,2]\nOutput: [222,228,282,288,822,828,882]\nExplanation: The same digit can be used as many times as it appears in digits. \nIn this example, the digit 8 is used twice each time in 288, 828, and 882. \n\nExample 3:\n\nInput: digits = [3,7,5]\nOutput: []\nExplanation: No even integers can be formed using the given digits.\n\n \nConstraints:\n\n3 <= digits.length <= 100\n0 <= digits[i] <= 9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(digits = [1, 1, 1, 1, 1, 1]) == []\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(digits = [2, 4, 6, 8, 0]) == [204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 0, 2, 4, 3, 5, 7, 9]) == [102, 104, 120, 124, 130, 132, 134, 140, 142, 150, 152, 154, 170, 172, 174, 190, 192, 194, 204, 210, 214, 230, 234, 240, 250, 254, 270, 274, 290, 294, 302, 304, 310, 312, 314, 320, 324, 340, 342, 350, 352, 354, 370, 372, 374, 390, 392, 394, 402, 410, 412, 420, 430, 432, 450, 452, 470, 472, 490, 492, 502, 504, 510, 512, 514, 520, 524, 530, 532, 534, 540, 542, 570, 572, 574, 590, 592, 594, 702, 704, 710, 712, 714, 720, 724, 730, 732, 734, 740, 742, 750, 752, 754, 790, 792, 794, 902, 904, 910, 912, 914, 920, 924, 930, 932, 934, 940, 942, 950, 952, 954, 970, 972, 974]\n assert candidate(digits = [2, 1, 3, 0]) == [102, 120, 130, 132, 210, 230, 302, 310, 312, 320]\n assert candidate(digits = [0, 2, 4, 6, 8]) == [204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 0, 0, 0]) == [100]\n assert candidate(digits = [2, 4, 6, 8]) == [246, 248, 264, 268, 284, 286, 426, 428, 462, 468, 482, 486, 624, 628, 642, 648, 682, 684, 824, 826, 842, 846, 862, 864]\n assert candidate(digits = [1, 3, 5, 7, 9]) == []\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [2, 2, 8, 8, 2]) == [222, 228, 282, 288, 822, 828, 882]\n assert candidate(digits = [3, 7, 5]) == []\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [0, 0, 0]) == []\n assert candidate(digits = [0, 2, 2, 2, 4, 4, 4, 6, 6, 6, 8, 8, 8]) == [202, 204, 206, 208, 220, 222, 224, 226, 228, 240, 242, 244, 246, 248, 260, 262, 264, 266, 268, 280, 282, 284, 286, 288, 402, 404, 406, 408, 420, 422, 424, 426, 428, 440, 442, 444, 446, 448, 460, 462, 464, 466, 468, 480, 482, 484, 486, 488, 602, 604, 606, 608, 620, 622, 624, 626, 628, 640, 642, 644, 646, 648, 660, 662, 664, 666, 668, 680, 682, 684, 686, 688, 802, 804, 806, 808, 820, 822, 824, 826, 828, 840, 842, 844, 846, 848, 860, 862, 864, 866, 868, 880, 882, 884, 886, 888]\n assert candidate(digits = [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]) == [100, 102, 110, 112, 120, 122, 130, 132, 200, 202, 210, 212, 220, 222, 230, 232, 300, 302, 310, 312, 320, 322, 330, 332]\n assert candidate(digits = [9, 9, 9, 0, 0, 0, 1, 1, 1, 2]) == [100, 102, 110, 112, 120, 190, 192, 200, 210, 290, 900, 902, 910, 912, 920, 990, 992]\n assert candidate(digits = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [0, 0, 0, 1, 1, 1, 2, 2, 2]) == [100, 102, 110, 112, 120, 122, 200, 202, 210, 212, 220, 222]\n assert candidate(digits = [0, 0, 2, 4, 6, 8]) == [200, 204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 400, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 600, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 800, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 0]) == [990]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0]) == [200, 202, 220, 222]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 0, 0, 0, 1, 1, 1]) == [100, 110, 190, 900, 910, 990]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]) == [100, 110]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == [888]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 0]) == [550]\n assert candidate(digits = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [2, 2, 0, 0, 8, 8]) == [200, 202, 208, 220, 228, 280, 282, 288, 800, 802, 808, 820, 822, 828, 880, 882]\n assert candidate(digits = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [800, 808, 880, 888]\n assert candidate(digits = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == [112, 114, 122, 124, 132, 134, 142, 144, 212, 214, 222, 224, 232, 234, 242, 244, 312, 314, 322, 324, 332, 334, 342, 344, 412, 414, 422, 424, 432, 434, 442, 444]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0]) == [550]\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == [200, 202, 204, 206, 208, 220, 224, 226, 228, 240, 242, 244, 246, 248, 260, 262, 264, 266, 268, 280, 282, 284, 286, 288, 400, 402, 404, 406, 408, 420, 422, 424, 426, 428, 440, 442, 446, 448, 460, 462, 464, 466, 468, 480, 482, 484, 486, 488, 600, 602, 604, 606, 608, 620, 622, 624, 626, 628, 640, 642, 644, 646, 648, 660, 662, 664, 668, 680, 682, 684, 686, 688, 800, 802, 804, 806, 808, 820, 822, 824, 826, 828, 840, 842, 844, 846, 848, 860, 862, 864, 866, 868, 880, 882, 884, 886]\n assert candidate(digits = [0, 0, 1, 2, 4, 6]) == [100, 102, 104, 106, 120, 124, 126, 140, 142, 146, 160, 162, 164, 200, 204, 206, 210, 214, 216, 240, 246, 260, 264, 400, 402, 406, 410, 412, 416, 420, 426, 460, 462, 600, 602, 604, 610, 612, 614, 620, 624, 640, 642]\n assert candidate(digits = [4, 4, 4, 4, 4, 4, 4]) == [444]\n assert candidate(digits = [4, 4, 4, 4, 1, 1, 1, 1, 0, 0, 0, 0]) == [100, 104, 110, 114, 140, 144, 400, 404, 410, 414, 440, 444]\n assert candidate(digits = [0, 2, 2, 0, 4, 6, 8]) == [200, 202, 204, 206, 208, 220, 224, 226, 228, 240, 242, 246, 248, 260, 262, 264, 268, 280, 282, 284, 286, 400, 402, 406, 408, 420, 422, 426, 428, 460, 462, 468, 480, 482, 486, 600, 602, 604, 608, 620, 622, 624, 628, 640, 642, 648, 680, 682, 684, 800, 802, 804, 806, 820, 822, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [112, 122, 212, 222]\n assert candidate(digits = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [124, 126, 128, 132, 134, 136, 138, 142, 146, 148, 152, 154, 156, 158, 162, 164, 168, 172, 174, 176, 178, 182, 184, 186, 192, 194, 196, 198, 214, 216, 218, 234, 236, 238, 246, 248, 254, 256, 258, 264, 268, 274, 276, 278, 284, 286, 294, 296, 298, 312, 314, 316, 318, 324, 326, 328, 342, 346, 348, 352, 354, 356, 358, 362, 364, 368, 372, 374, 376, 378, 382, 384, 386, 392, 394, 396, 398, 412, 416, 418, 426, 428, 432, 436, 438, 452, 456, 458, 462, 468, 472, 476, 478, 482, 486, 492, 496, 498, 512, 514, 516, 518, 524, 526, 528, 532, 534, 536, 538, 542, 546, 548, 562, 564, 568, 572, 574, 576, 578, 582, 584, 586, 592, 594, 596, 598, 612, 614, 618, 624, 628, 632, 634, 638, 642, 648, 652, 654, 658, 672, 674, 678, 682, 684, 692, 694, 698, 712, 714, 716, 718, 724, 726, 728, 732, 734, 736, 738, 742, 746, 748, 752, 754, 756, 758, 762, 764, 768, 782, 784, 786, 792, 794, 796, 798, 812, 814, 816, 824, 826, 832, 834, 836, 842, 846, 852, 854, 856, 862, 864, 872, 874, 876, 892, 894, 896, 912, 914, 916, 918, 924, 926, 928, 932, 934, 936, 938, 942, 946, 948, 952, 954, 956, 958, 962, 964, 968, 972, 974, 976, 978, 982, 984, 986]\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [100, 102, 110, 112, 120, 122, 200, 202, 210, 212, 220, 222]\n assert candidate(digits = [2, 4, 6, 8, 0, 0, 0, 0, 0, 0]) == [200, 204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 400, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 600, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 800, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == [112, 114, 116, 118, 122, 124, 126, 128, 132, 134, 136, 138, 142, 144, 146, 148, 152, 154, 156, 158, 162, 164, 166, 168, 172, 174, 176, 178, 182, 184, 186, 188, 192, 194, 196, 198, 212, 214, 216, 218, 222, 224, 226, 228, 232, 234, 236, 238, 242, 244, 246, 248, 252, 254, 256, 258, 262, 264, 266, 268, 272, 274, 276, 278, 282, 284, 286, 288, 292, 294, 296, 298, 312, 314, 316, 318, 322, 324, 326, 328, 332, 334, 336, 338, 342, 344, 346, 348, 352, 354, 356, 358, 362, 364, 366, 368, 372, 374, 376, 378, 382, 384, 386, 388, 392, 394, 396, 398, 412, 414, 416, 418, 422, 424, 426, 428, 432, 434, 436, 438, 442, 444, 446, 448, 452, 454, 456, 458, 462, 464, 466, 468, 472, 474, 476, 478, 482, 484, 486, 488, 492, 494, 496, 498, 512, 514, 516, 518, 522, 524, 526, 528, 532, 534, 536, 538, 542, 544, 546, 548, 552, 554, 556, 558, 562, 564, 566, 568, 572, 574, 576, 578, 582, 584, 586, 588, 592, 594, 596, 598, 612, 614, 616, 618, 622, 624, 626, 628, 632, 634, 636, 638, 642, 644, 646, 648, 652, 654, 656, 658, 662, 664, 666, 668, 672, 674, 676, 678, 682, 684, 686, 688, 692, 694, 696, 698, 712, 714, 716, 718, 722, 724, 726, 728, 732, 734, 736, 738, 742, 744, 746, 748, 752, 754, 756, 758, 762, 764, 766, 768, 772, 774, 776, 778, 782, 784, 786, 788, 792, 794, 796, 798, 812, 814, 816, 818, 822, 824, 826, 828, 832, 834, 836, 838, 842, 844, 846, 848, 852, 854, 856, 858, 862, 864, 866, 868, 872, 874, 876, 878, 882, 884, 886, 888, 892, 894, 896, 898, 912, 914, 916, 918, 922, 924, 926, 928, 932, 934, 936, 938, 942, 944, 946, 948, 952, 954, 956, 958, 962, 964, 966, 968, 972, 974, 976, 978, 982, 984, 986, 988, 992, 994, 996, 998]\n assert candidate(digits = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 666, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == [112]\n assert candidate(digits = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == [112, 122, 132, 212, 222, 232, 312, 322, 332]\n assert candidate(digits = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [1, 0, 2, 3, 4, 5, 6, 7, 8, 9]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(digits = [5, 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222, 252, 522, 552]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == [112, 122, 212, 222]\n assert candidate(digits = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [100, 110]\n assert candidate(digits = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [118, 188, 818, 888]\n assert candidate(digits = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == [500, 550]\n assert candidate(digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0]) == [100, 102, 104, 106, 108, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2]) == [200, 202, 220, 222]\n assert candidate(digits = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == [100, 102, 104, 120, 124, 130, 132, 134, 140, 142, 150, 152, 154, 200, 204, 210, 214, 230, 234, 240, 250, 254, 300, 302, 304, 310, 312, 314, 320, 324, 340, 342, 350, 352, 354, 400, 402, 410, 412, 420, 430, 432, 450, 452, 500, 502, 504, 510, 512, 514, 520, 524, 530, 532, 534, 540, 542]\n assert candidate(digits = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == [444]\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == []\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == [112, 122, 212, 222]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == [122, 124, 126, 132, 134, 136, 142, 144, 146, 152, 154, 156, 162, 164, 166, 212, 214, 216, 224, 226, 232, 234, 236, 242, 244, 246, 252, 254, 256, 262, 264, 266, 312, 314, 316, 322, 324, 326, 332, 334, 336, 342, 344, 346, 352, 354, 356, 362, 364, 366, 412, 414, 416, 422, 424, 426, 432, 434, 436, 442, 446, 452, 454, 456, 462, 464, 466, 512, 514, 516, 522, 524, 526, 532, 534, 536, 542, 544, 546, 552, 554, 556, 562, 564, 566, 612, 614, 616, 622, 624, 626, 632, 634, 636, 642, 644, 646, 652, 654, 656, 662, 664]\n assert candidate(digits = [0, 1, 2, 2, 4, 6, 8, 8, 8, 9]) == [102, 104, 106, 108, 120, 122, 124, 126, 128, 140, 142, 146, 148, 160, 162, 164, 168, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 240, 242, 246, 248, 260, 262, 264, 268, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 402, 406, 408, 410, 412, 416, 418, 420, 422, 426, 428, 460, 462, 468, 480, 482, 486, 488, 490, 492, 496, 498, 602, 604, 608, 610, 612, 614, 618, 620, 622, 624, 628, 640, 642, 648, 680, 682, 684, 688, 690, 692, 694, 698, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 840, 842, 846, 848, 860, 862, 864, 868, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 940, 942, 946, 948, 960, 962, 964, 968, 980, 982, 984, 986, 988]\n assert candidate(digits = [2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [112, 114, 122, 124, 132, 134, 142, 144, 152, 154, 212, 214, 224, 232, 234, 242, 244, 252, 254, 312, 314, 322, 324, 332, 334, 342, 344, 352, 354, 412, 414, 422, 424, 432, 434, 442, 452, 454, 512, 514, 522, 524, 532, 534, 542, 544, 552, 554]\n assert candidate(digits = [7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == [778, 788, 878, 888]\n assert candidate(digits = [0, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == [102, 110, 112, 120, 122, 130, 132, 202, 210, 212, 220, 222, 230, 232, 302, 310, 312, 320, 322, 330, 332]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [5, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8]) == [200, 202, 204, 206, 208, 220, 222, 224, 226, 228, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 280, 282, 284, 286, 288, 400, 402, 404, 406, 408, 420, 422, 424, 426, 428, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 480, 482, 484, 486, 488, 500, 502, 504, 506, 508, 520, 522, 524, 526, 528, 540, 542, 544, 546, 548, 560, 562, 564, 566, 568, 580, 582, 584, 586, 588, 600, 602, 604, 606, 608, 620, 622, 624, 626, 628, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 666, 668, 680, 682, 684, 686, 688, 800, 802, 804, 806, 808, 820, 822, 824, 826, 828, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 880, 882, 884, 886, 888]\n"}, "metadata": {"canonical_parameter_names": ["digits"], "leetcode_dataset_entry_point": "Solution().findEvenNumbers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def findEvenNumbers(self, digits: list[int]) -> list[int]:", "container": "Solution", "callable": "findEvenNumbers", "parameters": [{"name": "digits", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2095, "task_id": "delete-the-middle-node-of-a-linked-list", "difficulty": "Medium", "problem_description": "You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list.\nThe middle node of a linked list of size n is the ⌊n / 2⌋th node from the start using 0-based indexing, where ⌊x⌋ denotes the largest integer less than or equal to x.\n\nFor n = 1, 2, 3, 4, and 5, the middle nodes are 0, 1, 1, 2, and 2, respectively.\n\n \nExample 1:\n\n\nInput: head = [1,3,4,7,1,2,6]\nOutput: [1,3,4,1,2,6]\nExplanation:\nThe above figure represents the given linked list. The indices of the nodes are written below.\nSince n = 7, node 3 with value 7 is the middle node, which is marked in red.\nWe return the new list after removing this node. \n\nExample 2:\n\n\nInput: head = [1,2,3,4]\nOutput: [1,2,4]\nExplanation:\nThe above figure represents the given linked list.\nFor n = 4, node 2 with value 3 is the middle node, which is marked in red.\n\nExample 3:\n\n\nInput: head = [2,1]\nOutput: [2]\nExplanation:\nThe above figure represents the given linked list.\nFor n = 2, node 1 with value 1 is the middle node, which is marked in red.\nNode 0 with value 2 is the only node remaining after removing node 1.\n \nConstraints:\n\nThe number of nodes in the list is in the range [1, 105].\n1 <= Node.val <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_list(candidate(head = list_node([1, 2, 3])), list_node([1, 3]))\n assert is_same_list(candidate(head = list_node([2, 1])), list_node([2]))\n assert candidate(head = list_node([1])) == None\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([1, 2, 3, 4, 5, 7, 8, 9, 10]))\n assert is_same_list(candidate(head = list_node([1, 2])), list_node([1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5])), list_node([1, 2, 4, 5]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4])), list_node([1, 2, 4]))\n assert is_same_list(candidate(head = list_node([1, 3, 4, 7, 1, 2, 6])), list_node([1, 3, 4, 1, 2, 6]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6])), list_node([1, 2, 3, 5, 6]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]))\n assert is_same_list(candidate(head = list_node([7, 7, 7, 7, 7, 7, 7, 7, 7, 7])), list_node([7, 7, 7, 7, 7, 7, 7, 7, 7]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1])), list_node([5, 4, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21])), list_node([1, 3, 5, 7, 9, 13, 15, 17, 19, 21]))\n assert is_same_list(candidate(head = list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])), list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([10, 9, 8, 7, 6, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60])), list_node([5, 10, 15, 20, 25, 30, 40, 45, 50, 55, 60]))\n assert is_same_list(candidate(head = list_node([100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991])), list_node([100000, 99999, 99998, 99997, 99996, 99994, 99993, 99992, 99991]))\n assert is_same_list(candidate(head = list_node([31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1])), list_node([31, 29, 27, 25, 23, 21, 19, 17, 13, 11, 9, 7, 5, 3, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9])), list_node([1, 2, 3, 4, 6, 7, 8, 9]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25])), list_node([1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])), list_node([1, 2, 3, 4, 5, 7, 8, 9, 10, 11]))\n assert is_same_list(candidate(head = list_node([1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000])), list_node([1000, 2000, 3000, 4000, 5000, 7000, 8000, 9000, 10000]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8])), list_node([1, 2, 3, 4, 6, 7, 8]))\n assert is_same_list(candidate(head = list_node([1, 2, 2, 1])), list_node([1, 2, 1]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100])), list_node([10, 20, 30, 40, 50, 70, 80, 90, 100]))\n assert is_same_list(candidate(head = list_node([21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1])), list_node([21, 19, 17, 15, 13, 9, 7, 5, 3, 1]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10])), list_node([5, 4, 3, 2, 1, 0, -1, -2, -4, -5, -6, -7, -8, -9, -10]))\n assert candidate(head = list_node([5])) == None\n assert is_same_list(candidate(head = list_node([100000, 99999, 99998, 99997, 99996, 99995])), list_node([100000, 99999, 99998, 99996, 99995]))\n assert is_same_list(candidate(head = list_node([1, 3, 4, 7, 1, 2, 6, 8])), list_node([1, 3, 4, 7, 2, 6, 8]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2])), list_node([9, 8, 7, 6, 5, 4, 2, 1, 0, -1, -2]))\n assert is_same_list(candidate(head = list_node([100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000])), list_node([100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]))\n assert is_same_list(candidate(head = list_node([21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21])), list_node([21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21]))\n assert is_same_list(candidate(head = list_node([5, 3, 1, 4, 7, 6, 2, 8, 9])), list_node([5, 3, 1, 4, 6, 2, 8, 9]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])), list_node([1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5])), list_node([5, 4, 3, 2, 1, -1, -2, -3, -4, -5]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])), list_node([1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110])), list_node([10, 20, 30, 40, 50, 70, 80, 90, 100, 110]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])), list_node([1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15]))\n assert is_same_list(candidate(head = list_node([1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80])), list_node([10, 20, 30, 40, 60, 70, 80]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([9, 8, 7, 6, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17])), list_node([1, 3, 5, 7, 11, 13, 15, 17]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])), list_node([2, 4, 6, 8, 10, 12, 14, 18, 20, 22, 24, 26, 28, 30]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0])), list_node([9, 8, 7, 6, 5, 3, 2, 1, 0]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 2, 1])), list_node([1, 2, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19])), list_node([1, 3, 5, 7, 9, 13, 15, 17, 19]))\n assert is_same_list(candidate(head = list_node([7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7])), list_node([7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]))\n assert is_same_list(candidate(head = list_node([99, 88, 77, 66, 55, 44, 33, 22, 11])), list_node([99, 88, 77, 66, 44, 33, 22, 11]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]))\n assert is_same_list(candidate(head = list_node([5, 3, 8, 6, 2, 9, 1, 7, 4])), list_node([5, 3, 8, 6, 9, 1, 7, 4]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29])), list_node([1, 3, 5, 7, 9, 11, 13, 17, 19, 21, 23, 25, 27, 29]))\n"}, "metadata": {"canonical_parameter_names": ["head"], "leetcode_dataset_entry_point": "Solution().deleteMiddle", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def deleteMiddle(self, head: ListNode | None) -> ListNode | None:", "container": "Solution", "callable": "deleteMiddle", "parameters": [{"name": "head", "type": "ListNode | None"}], "return_type": "ListNode | None", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2096, "task_id": "step-by-step-directions-from-a-binary-tree-node-to-another", "difficulty": "Medium", "problem_description": "You are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue representing the value of the start node s, and a different integer destValue representing the value of the destination node t.\nFind the shortest path starting from node s and ending at node t. Generate step-by-step directions of such path as a string consisting of only the uppercase letters 'L', 'R', and 'U'. Each letter indicates a specific direction:\n\n'L' means to go from a node to its left child node.\n'R' means to go from a node to its right child node.\n'U' means to go from a node to its parent node.\n\nReturn the step-by-step directions of the shortest path from node s to node t.\n \nExample 1:\n\n\nInput: root = [5,1,2,3,null,6,4], startValue = 3, destValue = 6\nOutput: \"UURL\"\nExplanation: The shortest path is: 3 → 1 → 5 → 2 → 6.\n\nExample 2:\n\n\nInput: root = [2,1], startValue = 2, destValue = 1\nOutput: \"L\"\nExplanation: The shortest path is: 2 → 1.\n\n \nConstraints:\n\nThe number of nodes in the tree is n.\n2 <= n <= 105\n1 <= Node.val <= n\nAll the values in the tree are unique.\n1 <= startValue, destValue <= n\nstartValue != destValue\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18]),startValue = 3,destValue = 18) == \"UURR\"\n assert candidate(root = tree_node([2, 1]),startValue = 2,destValue = 1) == \"L\"\n assert candidate(root = tree_node([5, 1, 2, 3, None, 6, 4]),startValue = 3,destValue = 6) == \"UURL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),startValue = 4,destValue = 7) == \"UURR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),startValue = 8,destValue = 10) == \"UURL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 8,destValue = 15) == \"UUURRR\"\n assert candidate(root = tree_node([1, 2]),startValue = 2,destValue = 1) == \"U\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 1,destValue = 15) == \"RRR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 8,destValue = 14) == \"UUURRL\"\n assert candidate(root = tree_node([3, 1, 4, None, 2]),startValue = 2,destValue = 4) == \"UUR\"\n assert candidate(root = tree_node([3, 1, 2]),startValue = 2,destValue = 1) == \"UL\"\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 22, 27, 32, 38, 1, 4, 6, 8, 11, 13, 16, 18, 19, 21, 23, 24, 26, 28, 30, 31, 33, 34, 36, 37, 39, 40]),startValue = 37,destValue = 4) == \"U\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]),startValue = 45,destValue = 50) == \"UUUUURLLRL\"\n assert candidate(root = tree_node([5, 1, 2, 3, 8, 6, 4, 9, None, None, 10]),startValue = 9,destValue = 10) == \"UURR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 12,destValue = 14) == \"UURL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),startValue = 16,destValue = 19) == \"UURR\"\n assert candidate(root = tree_node([1, 2, 3, None, None, 6, 7, 8, 9, None, None, 12, 13, None, None, 16, 17]),startValue = 16,destValue = 17) == \"UR\"\n assert candidate(root = tree_node([5, 1, 2, 3, None, 6, 4, 8, None, None, None, 9]),startValue = 8,destValue = 9) == \"UUURRL\"\n assert candidate(root = tree_node([5, 1, 2, 3, 6, None, 4, 7, 8, None, None, 9, 10, None, None, 11, 12, None, None, 13, 14, None, None, 15, 16]),startValue = 7,destValue = 16) == \"URRR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),startValue = 4,destValue = 17) == \"LR\"\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 62, 87, 6, 20, None, 40, None, 59, 80, 90]),startValue = 6,destValue = 80) == \"UUURRL\"\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, 1, None, 6, None, 11, 13, None, None, None, None, None, None, None]),startValue = 3,destValue = 13) == \"UURLR\"\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12]),startValue = 7,destValue = 12) == \"LLLLL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]),startValue = 21,destValue = 28) == \"UUUURRLL\"\n assert candidate(root = tree_node([1, 2, None, 3, 4, None, 5, 6, None, None, 7, 8, 9]),startValue = 6,destValue = 9) == \"R\"\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 22, 27, 32, 38, 1, 4, 6, 8, 11, 13, 16, 18, 19, 21, 23, 24, 26, 28, 30, 31, 33, 34, 36, 37, 39, 40]),startValue = 4,destValue = 37) == \"R\"\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6, None, 14, 20, None, None, None, None, None, 13, 16, 19]),startValue = 3,destValue = 20) == \"UURRR\"\n assert candidate(root = tree_node([3, 1, 2, None, None, None, 4, None, 5, None, None, None, 6, None, None, None, None, None, None, 7]),startValue = 1,destValue = 7) == \"\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),startValue = 10,destValue = 19) == \"UULRR\"\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 62, 87, 6, 18, 31, 43, 55, 59, 81, 93, 3, 9, 15, 21, 27, 35, 39, 47, 51, 57, 61, 67, 71, 77, 83, 89, 95, 1, 5, 7, 11, 13, 17, 19, 23, 29, 33, 37, 41, 45, 49, 53, 58, 63, 65, 69, 73, 75, 79, 85, 88, 91, 94, 97, 99]),startValue = 55,destValue = 88) == \"UURLLL\"\n assert candidate(root = tree_node([200, 100, 300, 50, 150, 250, 350, 25, 75, 125, 175, 225, 275, 325, 375, 10, 40, 60, 90, 130, 160, 180, 210, 240, 260, 290, 310, 340, 360, 390]),startValue = 10,destValue = 390) == \"UUUURRRL\"\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, 6, 7, None, None, None, None, 8, 9, None, None, None, None, 10]),startValue = 10,destValue = 8) == \"\"\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9]),startValue = 6,destValue = 9) == \"URR\"\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, 6, None, None, 7, 8, None, None, 9, 10, 11, 12, 13, 14, None, None, None, None, None, None, None, 15, 16, None, 17, None, None, 18]),startValue = 6,destValue = 18) == \"LLLLRL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]),startValue = 12,destValue = 24) == \"L\"\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6]),startValue = 3,destValue = 7) == \"UR\"\n assert candidate(root = tree_node([5, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 8,destValue = 15) == \"UUURRR\"\n assert candidate(root = tree_node([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4]),startValue = 5,destValue = 1) == \"UR\"\n assert candidate(root = tree_node([30, 15, 45, 10, 20, 40, 50, 5, 12, None, 25, 35, 48, None, None, None, 18, None, None, None, None, None, None, None, None, 22, None, None, None, None, None, None, None, None, None, None]),startValue = 5,destValue = 22) == \"RL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, None, None, 14, 15, None, None, None, None, None, 16, 17, 18, 19, 20]),startValue = 8,destValue = 19) == \"UUURLRL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 14,destValue = 11) == \"UUULRR\"\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6]),startValue = 1,destValue = 6) == \"UURL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),startValue = 16,destValue = 20) == \"UUURLL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 5,destValue = 11) == \"R\"\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 85, 110, 140, 160, 180]),startValue = 85,destValue = 140) == \"UUURLR\"\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, None, 5, 6, None, None, None, None, 7, 8, None, None, None, None, 9, 10]),startValue = 9,destValue = 10) == \"\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]),startValue = 10,destValue = 45) == \"URLR\"\n assert candidate(root = tree_node([15, 10, 20, 8, 12, 18, 25, 6, 9, 11, 13, 16, 19, 22, 28, 5, 7, None, None, None, None, None, None, 14, None, None, None, None, None, 17, None, None, None, None, None, None, 21, None, None, None, None, None, None, None, None, None, None, None, None, 24, None, None, None, None, None, None, 26, None, 27]),startValue = 5,destValue = 27) == \"\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]),startValue = 12,destValue = 49) == \"LR\"\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 35, 65, 85, 115, 135, 165, 185]),startValue = 10,destValue = 185) == \"UUURRR\"\n assert candidate(root = tree_node([5, 1, 2, 3, 9, None, 6, 4, None, None, None, None, 8]),startValue = 4,destValue = 9) == \"UUR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, 20, 21, 22, None, 24, 25, 26, 27, 28]),startValue = 20,destValue = 27) == \"UUURRR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),startValue = 19,destValue = 7) == \"UUUURR\"\n assert candidate(root = tree_node([5, 1, 2, 3, None, 6, 4, 8, 9, None, None, 12, 13, None, None, 16, 17, None, None, None, 18, 19, 20, None, None, None, None, 22, 23, 24, 25, 26, 27, 28, None, None, None, None, None, None, None, None, None, None, None, 30]),startValue = 16,destValue = 28) == \"LRL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 7,destValue = 1) == \"UU\"\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),startValue = 1,destValue = 10) == \"RRRRRRRRR\"\n assert candidate(root = tree_node([30, 15, 45, 10, 20, 40, 50, 5, 12, 18, 25, 35, 48, 2, 8, 13, 16, 19, 23, 32, 38, 43, 47, 49, 1, 6, 9, 11, 14, 17, 21, 22, 24, 26, 29, 31, 33, 37, 41, 42, 44, 46, 51]),startValue = 42,destValue = 46) == \"UURL\"\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, 6, 7, None, 8, 9, 10, None, None, 11, 12, None, None, 13, 14, None, None, 15]),startValue = 11,destValue = 15) == \"R\"\n assert candidate(root = tree_node([1, 2, 3, None, None, 6, 4, None, None, None, 5]),startValue = 5,destValue = 1) == \"UUU\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]),startValue = 10,destValue = 60) == \"UUURRRLL\"\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, None, 6]),startValue = 3,destValue = 6) == \"URL\"\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, None, 17, 16, 25, 0, 2, None, None, None, None, None, None, 9]),startValue = 3,destValue = 25) == \"UURRR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]),startValue = 16,destValue = 30) == \"UUUURLLLL\"\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 12, 37, 62, 87, 112, 137, 162, 187, 6, 18, 31, 43, 55, 59, 81, 93, 107, 118, 127, 133, 147, 153, 167, 173, 183, 193, 3, 9, 15, 21, 27, 33, 39, 45, 49, 53, 58, 63, 65, 69, 73, 75, 79, 85, 88, 91, 94, 97, 99, 103, 109, 115, 121, 123, 129, 131, 139, 141, 149, 151, 157, 159, 165, 169, 171, 179, 181, 189, 191, 199]),startValue = 69,destValue = 171) == \"UUUULRLLL\"\n assert candidate(root = tree_node([5, 1, 2, 3, 8, None, 6, 4, None, None, 9, 10, 11]),startValue = 4,destValue = 11) == \"UUURRR\"\n assert candidate(root = tree_node([5, 1, 2, 3, 6, 7, 4, None, None, None, None, None, None, 8, 9, 10, 11, None, None, 12, 13]),startValue = 8,destValue = 13) == \"LR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]),startValue = 19,destValue = 38) == \"L\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15]),startValue = 2,destValue = 14) == \"URLRR\"\n assert candidate(root = tree_node([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4]),startValue = 5,destValue = 0) == \"URL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]),startValue = 10,destValue = 40) == \"LL\"\n assert candidate(root = tree_node([5, 1, 2, 3, None, 6, 4, 8, 9, None, None, 12, 13, None, None, 16, 17, None, None, None, 18, 19, 20, None, None, None, None, 22, 23, 24, 25, 26, 27, 28, None, None, None, None, None, None, None, None, None, None, None, 30, None, None, None, 34, 35, 36, 37, 38, 39, 40, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 45]),startValue = 34,destValue = 40) == \"\"\n assert candidate(root = tree_node([50, 25, 75, 10, 30, 60, 80, 5, 15, 27, 33, 55, 65, 77, 85]),startValue = 5,destValue = 65) == \"UUURLR\"\n assert candidate(root = tree_node([5, 2, 8, 1, 3, 6, 9, None, None, 4, 7, None, None, None, None, 10, 11]),startValue = 10,destValue = 11) == \"UR\"\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, None, 4, None, None, None, None, None, 8]),startValue = 3,destValue = 7) == \"UR\"\n assert candidate(root = tree_node([5, 1, 2, 3, None, 6, 4, 8, 9, None, None, 12, 13, None, None, 16, 17, None, None, None, 18, 19, 20, None, None, None, None, 22, 23, 24, 25, 26, 27, 28, None, None, None, None, None, None, None, None, None, None, None, 30, None, None, None, 34, 35, 36, 37, 38, 39, 40, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 45, None, None, None, 49, 50, 51, 52, 53, 54, 55]),startValue = 49,destValue = 55) == \"\"\n assert candidate(root = tree_node([1, 2, 3, None, None, None, 4, None, 5, 6, None, None, None, None, None, 7, 8]),startValue = 1,destValue = 8) == \"\"\n assert candidate(root = tree_node([2, 1, 3, None, None, 4, 5]),startValue = 3,destValue = 5) == \"R\"\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 2, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38]),startValue = 8,destValue = 32) == \"UUUURRLL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),startValue = 8,destValue = 19) == \"URR\"\n assert candidate(root = tree_node([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4, None, None, None, None]),startValue = 6,destValue = 7) == \"URL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 3,destValue = 14) == \"RL\"\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9]),startValue = 1,destValue = 9) == \"RRRR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 14,destValue = 12) == \"UULL\"\n assert candidate(root = tree_node([8, 3, 10, 1, 6, None, 14, None, None, 4, 7, 13]),startValue = 7,destValue = 13) == \"UUURRL\"\n"}, "metadata": {"canonical_parameter_names": ["root", "startValue", "destValue"], "leetcode_dataset_entry_point": "Solution().getDirections", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def getDirections(self, root: TreeNode | None, startValue: int, destValue: int) -> str:", "container": "Solution", "callable": "getDirections", "parameters": [{"name": "root", "type": "TreeNode | None"}, {"name": "startValue", "type": "int"}, {"name": "destValue", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2097, "task_id": "valid-arrangement-of-pairs", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array pairs where pairs[i] = [starti, endi]. An arrangement of pairs is valid if for every index i where 1 <= i < pairs.length, we have endi-1 == starti.\nReturn any valid arrangement of pairs.\nNote: The inputs will be generated such that there exists a valid arrangement of pairs.\n \nExample 1:\n\nInput: pairs = [[5,1],[4,5],[11,9],[9,4]]\nOutput: [[11,9],[9,4],[4,5],[5,1]]\nExplanation:\nThis is a valid arrangement since endi-1 always equals starti.\nend0 = 9 == 9 = start1 \nend1 = 4 == 4 = start2\nend2 = 5 == 5 = start3\n\nExample 2:\n\nInput: pairs = [[1,3],[3,2],[2,1]]\nOutput: [[1,3],[3,2],[2,1]]\nExplanation:\nThis is a valid arrangement since endi-1 always equals starti.\nend0 = 3 == 3 = start1\nend1 = 2 == 2 = start2\nThe arrangements [[2,1],[1,3],[3,2]] and [[3,2],[2,1],[1,3]] are also valid.\n\nExample 3:\n\nInput: pairs = [[1,2],[1,3],[2,1]]\nOutput: [[1,2],[2,1],[1,3]]\nExplanation:\nThis is a valid arrangement since endi-1 always equals starti.\nend0 = 2 == 2 = start1\nend1 = 1 == 1 = start2\n\n \nConstraints:\n\n1 <= pairs.length <= 105\npairs[i].length == 2\n0 <= starti, endi <= 109\nstarti != endi\nNo two pairs are exactly the same.\nThere exists a valid arrangement of pairs.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pairs = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [[0, 1], [1, 2], [2, 3], [3, 4]]\n assert candidate(pairs = [[0, 1], [1, 2], [2, 3], [3, 0]]) == [[0, 1], [1, 2], [2, 3], [3, 0]]\n assert candidate(pairs = [[1, 2], [1, 3], [2, 1]]) == [[1, 2], [2, 1], [1, 3]]\n assert candidate(pairs = [[10, 20], [20, 30], [30, 40], [40, 50]]) == [[10, 20], [20, 30], [30, 40], [40, 50]]\n assert candidate(pairs = [[1, 3], [3, 2], [2, 1]]) == [[1, 3], [3, 2], [2, 1]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 100]]) == [[100, 200], [200, 300], [300, 100]]\n assert candidate(pairs = [[10, 20], [20, 30], [30, 40], [40, 10]]) == [[10, 20], [20, 30], [30, 40], [40, 10]]\n assert candidate(pairs = [[5, 1], [4, 5], [11, 9], [9, 4]]) == [[11, 9], [9, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 1]]) == [[1, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 1]]\n assert candidate(pairs = [[7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7]]) == [[7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5], [5, 2], [2, 4], [4, 1]]) == [[1, 3], [3, 5], [5, 2], [2, 4], [4, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5]]) == [[1, 3], [3, 5], [5, 1], [1, 2], [2, 3], [3, 4], [4, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 11], [11, 12], [12, 13], [13, 1]]) == [[1, 11], [11, 12], [12, 13], [13, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 10], [10, 11], [11, 1]]) == [[1, 10], [10, 11], [11, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]) == [[1, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5]]) == [[1, 3], [3, 5], [5, 1], [1, 2], [2, 3], [3, 4], [4, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1]]\n assert candidate(pairs = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1]]) == [[1, 5], [5, 1], [1, 4], [4, 1], [1, 3], [3, 1], [1, 2], [2, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1], [1, 60], [60, 70], [70, 80], [80, 1]]) == [[1, 60], [60, 70], [70, 80], [80, 1], [1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1]]\n assert candidate(pairs = [[5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]) == [[5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 100], [100, 400], [400, 500], [500, 100]]) == [[100, 400], [400, 500], [500, 100], [100, 200], [200, 300], [300, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [2, 7], [7, 8], [8, 9], [9, 10], [10, 2]]) == [[1, 2], [2, 7], [7, 8], [8, 9], [9, 10], [10, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]\n assert candidate(pairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 1], [1, 13], [13, 2]]) == [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 1], [1, 13], [13, 2]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 1], [1, 3], [3, 2], [2, 4], [4, 3], [3, 1], [1, 4], [4, 2], [2, 1]]) == [[1, 4], [4, 2], [2, 1], [1, 3], [3, 1], [1, 2], [2, 4], [4, 3], [3, 2], [2, 3], [3, 4], [4, 1]]\n assert candidate(pairs = [[1, 2], [3, 1], [2, 3], [4, 2], [3, 5], [5, 4], [4, 1]]) == [[3, 5], [5, 4], [4, 2], [4, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [7, 8], [8, 9], [9, 10], [10, 7]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]\n assert candidate(pairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 10], [10, 30], [30, 50], [50, 20], [20, 40], [40, 10]]) == [[10, 30], [30, 50], [50, 20], [20, 40], [40, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 10]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 10], [10, 11], [11, 1], [12, 13], [13, 14], [14, 12]]) == [[1, 10], [10, 11], [11, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 999], [999, 2], [2, 998], [998, 3], [3, 997], [997, 4], [4, 996], [996, 5], [5, 995], [995, 1]]) == [[1, 999], [999, 2], [2, 998], [998, 3], [3, 997], [997, 4], [4, 996], [996, 5], [5, 995], [995, 1]]\n assert candidate(pairs = [[1, 9], [9, 7], [7, 3], [3, 5], [5, 1], [1, 8], [8, 6], [6, 2], [2, 4], [4, 1]]) == [[1, 8], [8, 6], [6, 2], [2, 4], [4, 1], [1, 9], [9, 7], [7, 3], [3, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == [[1, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 4]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1000000, 2000000], [2000000, 3000000], [3000000, 1000000], [500000, 1000000]]) == [[500000, 1000000], [1000000, 2000000], [2000000, 3000000], [3000000, 1000000]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 7], [7, 4], [8, 9], [9, 10], [10, 8]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 4]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1000, 2000], [2000, 3000], [3000, 1000], [1000, 4000], [4000, 5000], [5000, 6000], [6000, 1000]]) == [[1000, 4000], [4000, 5000], [5000, 6000], [6000, 1000], [1000, 2000], [2000, 3000], [3000, 1000]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]\n assert candidate(pairs = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 5]]) == [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 5]]\n assert candidate(pairs = [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 6], [6, 7], [7, 8], [8, 1], [1, 9], [9, 10], [10, 1]]) == [[1, 9], [9, 10], [10, 1], [1, 6], [6, 7], [7, 8], [8, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[5, 6], [6, 5], [5, 7], [7, 5], [5, 8], [8, 5], [5, 9], [9, 5], [5, 10], [10, 5]]) == [[5, 10], [10, 5], [5, 9], [9, 5], [5, 8], [8, 5], [5, 7], [7, 5], [5, 6], [6, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 1], [1, 20], [20, 3], [3, 21], [21, 1]]) == [[1, 20], [20, 3], [3, 21], [21, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 1]]\n assert candidate(pairs = [[7, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 12], [12, 8]]) == [[7, 12], [12, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 8]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 100]]\n assert candidate(pairs = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 5]]) == [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 5]]\n assert candidate(pairs = [[7, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 9], [9, 11], [11, 8]]) == [[7, 9], [9, 11], [11, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 8]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 11], [14, 15], [15, 16], [16, 14], [17, 18], [18, 19], [19, 20], [20, 17]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 9], [9, 10], [10, 11], [11, 12], [12, 1], [1, 13], [13, 14], [14, 15], [15, 1], [1, 16], [16, 17], [17, 18], [18, 1]]) == [[1, 16], [16, 17], [17, 18], [18, 1], [1, 13], [13, 14], [14, 15], [15, 1], [1, 9], [9, 10], [10, 11], [11, 12], [12, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]\n assert candidate(pairs = [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1]]) == [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 10], [10, 2]]) == [[1, 10], [10, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 2]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100], [100, 600], [600, 700], [700, 800], [800, 900], [900, 100]]) == [[100, 600], [600, 700], [700, 800], [800, 900], [900, 100], [100, 200], [200, 300], [300, 400], [400, 500], [500, 100]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1], [60, 70], [70, 80], [80, 90], [90, 100], [100, 60]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1]]\n assert candidate(pairs = [[5, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]) == [[5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5], [5, 1], [1, 2], [2, 3], [3, 4], [4, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 4], [4, 7], [7, 1]]) == [[1, 4], [4, 5], [5, 6], [6, 4], [4, 7], [7, 8], [8, 9], [9, 7], [7, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 1]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 1]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 1]]\n assert candidate(pairs = [[1, 1000000000], [1000000000, 999999999], [999999999, 888888888], [888888888, 1]]) == [[1, 1000000000], [1000000000, 999999999], [999999999, 888888888], [888888888, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 10], [10, 11], [11, 12], [12, 1]]) == [[1, 10], [10, 11], [11, 12], [12, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 11], [14, 15], [15, 16], [16, 14], [17, 18], [18, 19], [19, 20], [20, 17], [21, 22], [22, 23], [23, 21]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [1, 4], [4, 5], [5, 1], [1, 6], [6, 7], [7, 1]]) == [[1, 6], [6, 7], [7, 1], [1, 4], [4, 5], [5, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 3]]) == [[3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 3]]\n assert candidate(pairs = [[11, 22], [22, 33], [33, 44], [44, 55], [55, 66], [66, 77], [77, 88], [88, 99], [99, 11]]) == [[11, 22], [22, 33], [33, 44], [44, 55], [55, 66], [66, 77], [77, 88], [88, 99], [99, 11]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100], [100, 300], [300, 500], [500, 200]]) == [[100, 300], [300, 500], [500, 200], [200, 300], [300, 400], [400, 500], [500, 100], [100, 200]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1], [1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1]]) == [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1], [1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 5]]) == [[1, 2], [2, 3], [3, 4], [4, 1]]\n assert candidate(pairs = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1], [1, 7], [7, 1], [1, 8], [8, 1], [1, 9], [9, 1], [1, 10], [10, 1]]) == [[1, 10], [10, 1], [1, 9], [9, 1], [1, 8], [8, 1], [1, 7], [7, 1], [1, 6], [6, 1], [1, 5], [5, 1], [1, 4], [4, 1], [1, 3], [3, 1], [1, 2], [2, 1]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 1], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 4]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 4], [4, 1]]\n assert candidate(pairs = [[123, 456], [456, 789], [789, 101], [101, 112], [112, 234], [234, 345], [345, 123]]) == [[123, 456], [456, 789], [789, 101], [101, 112], [112, 234], [234, 345], [345, 123]]\n"}, "metadata": {"canonical_parameter_names": ["pairs"], "leetcode_dataset_entry_point": "Solution().validArrangement", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def validArrangement(self, pairs: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "validArrangement", "parameters": [{"name": "pairs", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2099, "task_id": "find-subsequence-of-length-k-with-the-largest-sum", "difficulty": "Easy", "problem_description": "You are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum.\nReturn any such subsequence as an integer array of length k.\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n \nExample 1:\n\nInput: nums = [2,1,3,3], k = 2\nOutput: [3,3]\nExplanation:\nThe subsequence has the largest sum of 3 + 3 = 6.\nExample 2:\n\nInput: nums = [-1,-2,3,4], k = 3\nOutput: [-1,3,4]\nExplanation: \nThe subsequence has the largest sum of -1 + 3 + 4 = 6.\n\nExample 3:\n\nInput: nums = [3,4,3,3], k = 2\nOutput: [3,4]\nExplanation:\nThe subsequence has the largest sum of 3 + 4 = 7. \nAnother possible subsequence is [4, 3].\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n-105 <= nums[i] <= 105\n1 <= k <= nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 3, 1, 2, 4],k = 5) == [5, 3, 1, 2, 4]\n assert candidate(nums = [10, 10, 10, 10, 10],k = 3) == [10, 10, 10]\n assert candidate(nums = [0, 0, 0, 0],k = 2) == [0, 0]\n assert candidate(nums = [-1, -2, 3, 4],k = 3) == [-1, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == [3, 4, 5]\n assert candidate(nums = [5, 1, 2, 3, 4],k = 3) == [5, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == [6, 7, 8, 9, 10]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [-1, -2, -3, -4],k = 2) == [-1, -2]\n assert candidate(nums = [-1, -1, -1, -1, -1],k = 3) == [-1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500],k = 4) == [200, 300, 400, 500]\n assert candidate(nums = [1],k = 1) == [1]\n assert candidate(nums = [2, 1, 3, 3],k = 2) == [3, 3]\n assert candidate(nums = [-10, -20, -30, -40],k = 2) == [-10, -20]\n assert candidate(nums = [5, 4, 3, 2, 1],k = 4) == [5, 4, 3, 2]\n assert candidate(nums = [100000, -100000, 50000, -50000, 0],k = 2) == [100000, 50000]\n assert candidate(nums = [100000, -100000, 200000, -200000],k = 2) == [100000, 200000]\n assert candidate(nums = [10, -2, 0, 5],k = 2) == [10, 5]\n assert candidate(nums = [5, 1, 2, 4, 3],k = 3) == [5, 4, 3]\n assert candidate(nums = [3, 4, 3, 3],k = 2) == [4, 3]\n assert candidate(nums = [-5, -4, -3, -2, -1],k = 2) == [-2, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10) == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 15) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],k = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == [100, 90, 80]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 7) == [50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 3) == [-1, -2, -3]\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],k = 4) == [300, 500, 700, 900]\n assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50],k = 7) == [10, 20, 30, 40, 50, -10, -20]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 7) == [-1, -2, -3, -4, -5, -6, -7]\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 6) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [100000, -50000, 100000, -50000, 100000],k = 3) == [100000, 100000, 100000]\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],k = 5) == [10, 30, 50, 70, 90]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 15) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 3) == [-1, -2, -3]\n assert candidate(nums = [100, 200, 300, 400, 500],k = 1) == [500]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50],k = 5) == [10, 20, 30, 40, 50]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],k = 7) == [70, 80, 90, 100, 110, 120, 130]\n assert candidate(nums = [-10, 100, -20, 200, -30, 300, -40, 400, -50, 500, -60, 600, -70, 700, -80, 800],k = 8) == [100, 200, 300, 400, 500, 600, 700, 800]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [10, -1, 2, 9, 3, 8, 4, 7, 5, 6],k = 5) == [10, 9, 8, 7, 6]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 15) == [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],k = 3) == [99999, 99998, 99997]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == [100, 90, 80]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 8) == [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 7) == [10, 9, 8, 7, 6, 5, 4]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == [1, 1, 1]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100],k = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, -1, 2, -3, 4, -5, 6, -7, 8, -9],k = 5) == [10, 2, 4, 6, 8]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90],k = 15) == [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == [9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 5) == [100, 200, 300, 400, 500]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 15) == [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, -1, -2, -3, -4, -5]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 4) == [-1, -2, -3, -4]\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300],k = 7) == [100, 300, 500, 700, 900, 1100, 1300]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == [6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 4) == [50, 50, 50, 50]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [60, 70, 80, 90, 100]\n assert candidate(nums = [100000, -100000, 50000, -50000, 0, 25000, -25000, 75000, -75000],k = 3) == [100000, 50000, 75000]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],k = 10) == [7, 6, 9, 8, 11, 10, 13, 12, 15, 14]\n assert candidate(nums = [-100, -200, -300, -400, -500],k = 3) == [-100, -200, -300]\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 8) == [1000, 900, 800, 700, 600, 500, 400, 300]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 5) == [1, 3, 5, 7, 9]\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 3) == [-10, -20, -30]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 10) == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 6) == [1, -1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 10) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 6) == [9, 8, 7, 6, 5, 4]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == [0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == [9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [10000, -10000, 20000, -20000, 30000, -30000, 40000, -40000],k = 4) == [10000, 20000, 30000, 40000]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 3) == [-1, -2, -3]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8, 10],k = 5) == [9, 6, 7, 8, 10]\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500],k = 10) == [300, 400, 500, 300, 400, 500, 200, 300, 400, 500]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 20) == [21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 6) == [25, 30, 35, 40, 45, 50]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110],k = 5) == [-10, -20, -30, -40, -50]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == [15, 14, 13, 12, 11, 10, 9, 8]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1],k = 10) == [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 8) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [-10, -20, -30, -40, -50, 100, 200],k = 3) == [-10, 100, 200]\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxSubsequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maxSubsequence(self, nums: list[int], k: int) -> list[int]:", "container": "Solution", "callable": "maxSubsequence", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2100, "task_id": "find-good-days-to-rob-the-bank", "difficulty": "Medium", "problem_description": "You and a gang of thieves are planning on robbing a bank. You are given a 0-indexed integer array security, where security[i] is the number of guards on duty on the ith day. The days are numbered starting from 0. You are also given an integer time.\nThe ith day is a good day to rob the bank if:\n\nThere are at least time days before and after the ith day,\nThe number of guards at the bank for the time days before i are non-increasing, and\nThe number of guards at the bank for the time days after i are non-decreasing.\n\nMore formally, this means day i is a good day to rob the bank if and only if security[i - time] >= security[i - time + 1] >= ... >= security[i] <= ... <= security[i + time - 1] <= security[i + time].\nReturn a list of all days (0-indexed) that are good days to rob the bank. The order that the days are returned in does not matter.\n \nExample 1:\n\nInput: security = [5,3,3,3,5,6,2], time = 2\nOutput: [2,3]\nExplanation:\nOn day 2, we have security[0] >= security[1] >= security[2] <= security[3] <= security[4].\nOn day 3, we have security[1] >= security[2] >= security[3] <= security[4] <= security[5].\nNo other days satisfy this condition, so days 2 and 3 are the only good days to rob the bank.\n\nExample 2:\n\nInput: security = [1,1,1,1,1], time = 0\nOutput: [0,1,2,3,4]\nExplanation:\nSince time equals 0, every day is a good day to rob the bank, so return every day.\n\nExample 3:\n\nInput: security = [1,2,3,4,5,6], time = 2\nOutput: []\nExplanation:\nNo day has 2 days before it that have a non-increasing number of guards.\nThus, no day is a good day to rob the bank, so return an empty list.\n\n \nConstraints:\n\n1 <= security.length <= 105\n0 <= security[i], time <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(security = [3, 3, 5, 5, 5, 5, 2, 2, 2, 3],time = 2) == [6, 7]\n assert candidate(security = [1, 1, 1, 1, 1],time = 0) == [0, 1, 2, 3, 4]\n assert candidate(security = [1, 2, 2, 3, 3, 4, 5, 5, 6, 6],time = 1) == [2, 4, 7]\n assert candidate(security = [6, 5, 4, 3, 2, 1],time = 2) == []\n assert candidate(security = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],time = 1) == [2, 4, 6, 8]\n assert candidate(security = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],time = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(security = [1, 2, 2, 3, 3, 4],time = 1) == [2, 4]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [1, 2, 2, 3, 3, 4, 5],time = 1) == [2, 4]\n assert candidate(security = [3, 3, 5, 5, 5, 5, 2, 2, 1, 1],time = 2) == []\n assert candidate(security = [1, 1, 1, 2, 2, 2, 3, 3, 3],time = 2) == [2, 5]\n assert candidate(security = [100, 90, 80, 70, 60, 50, 60, 70, 80, 90, 100],time = 4) == [5]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3],time = 3) == [3]\n assert candidate(security = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],time = 4) == [4, 5]\n assert candidate(security = [1],time = 0) == [0]\n assert candidate(security = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],time = 2) == []\n assert candidate(security = [3, 3, 5, 5, 5, 5, 4, 4, 4, 3],time = 3) == []\n assert candidate(security = [1, 2, 3, 4, 5, 6],time = 2) == []\n assert candidate(security = [1, 2, 3, 3, 3, 3, 2, 2, 1],time = 2) == []\n assert candidate(security = [5, 3, 3, 3, 5, 6, 2],time = 2) == [2, 3]\n assert candidate(security = [1, 2, 3, 2, 1, 0, 1, 0, 1, 2, 3],time = 1) == [5, 7]\n assert candidate(security = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],time = 2) == [5]\n assert candidate(security = [1, 2, 2, 3, 4, 5, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [6, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 3) == []\n assert candidate(security = [1, 2],time = 1) == []\n assert candidate(security = [2, 1],time = 1) == []\n assert candidate(security = [1, 3, 3, 3, 3, 2, 2, 2, 2],time = 2) == [5, 6]\n assert candidate(security = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],time = 5) == [23]\n assert candidate(security = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],time = 2) == [2, 6, 10, 14, 18, 22, 26]\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7],time = 2) == [8]\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 5) == [10]\n assert candidate(security = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],time = 3) == [11]\n assert candidate(security = [5, 3, 3, 3, 3, 5, 6, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1],time = 3) == [3, 11, 12, 13]\n assert candidate(security = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1],time = 2) == [3, 6, 9, 13, 16, 19]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5],time = 2) == []\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(security = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],time = 2) == []\n assert candidate(security = [1, 2, 3, 2, 1, 0, 1, 0, 1, 2, 3, 2, 1, 0, 1],time = 2) == []\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5],time = 2) == [8, 16]\n assert candidate(security = [7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7],time = 3) == [4, 8, 9, 10, 11, 15]\n assert candidate(security = [1, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2],time = 1) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],time = 3) == [11]\n assert candidate(security = [1, 3, 2, 2, 2, 1, 2, 2, 2, 3, 1, 1, 1],time = 1) == [2, 3, 5, 7, 8, 10, 11]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],time = 4) == [8, 9, 17]\n assert candidate(security = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],time = 2) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]\n assert candidate(security = [1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2],time = 2) == [4, 8, 12]\n assert candidate(security = [10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10],time = 4) == [12]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 4) == [4, 5]\n assert candidate(security = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],time = 5) == [10]\n assert candidate(security = [5, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4],time = 5) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],time = 6) == [10, 11, 12, 13, 14]\n assert candidate(security = [5, 3, 3, 3, 5, 6, 2, 2, 2, 1, 1, 1, 2, 2, 2],time = 3) == [9, 10, 11]\n assert candidate(security = [1, 2, 2, 1, 0, 0, 1, 1, 2, 2],time = 1) == [4, 5, 7]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],time = 4) == [19]\n assert candidate(security = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],time = 4) == [9]\n assert candidate(security = [5, 3, 3, 3, 5, 6, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 2) == [2, 3, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 5) == [5, 6, 7, 8, 9, 10, 11]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 5) == []\n assert candidate(security = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0],time = 4) == []\n assert candidate(security = [2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 2, 1, 1, 2, 2],time = 2) == [5, 6, 12, 13]\n assert candidate(security = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],time = 3) == [4]\n assert candidate(security = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],time = 2) == []\n assert candidate(security = [10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 4) == []\n assert candidate(security = [1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 10, 11, 12, 11, 12, 13],time = 4) == []\n assert candidate(security = [3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],time = 2) == [2, 5, 6, 7, 8, 9, 12]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5],time = 3) == [8, 16]\n assert candidate(security = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],time = 1) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],time = 3) == [10]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 4) == [10]\n assert candidate(security = [5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5],time = 4) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5],time = 2) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],time = 8) == [10]\n assert candidate(security = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],time = 7) == [7, 8, 9]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 4) == [10]\n assert candidate(security = [3, 2, 1, 2, 1, 0, 1, 0, 1, 2, 3, 2, 1, 2, 1, 0, 1, 0, 1, 2],time = 2) == []\n assert candidate(security = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],time = 3) == [11, 23]\n assert candidate(security = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],time = 3) == [5]\n assert candidate(security = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 1],time = 3) == []\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(security = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],time = 3) == []\n assert candidate(security = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],time = 5) == [10, 11]\n assert candidate(security = [9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 4) == [4]\n assert candidate(security = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1],time = 2) == [4, 5, 8, 9, 12, 13, 16, 17, 20, 21]\n assert candidate(security = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5],time = 2) == [2, 5, 6, 7, 8, 9, 12, 13, 14, 17, 18, 19, 22, 23, 24, 27]\n assert candidate(security = [3, 3, 5, 5, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],time = 3) == [5]\n assert candidate(security = [3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0],time = 3) == [4, 8, 12, 13]\n assert candidate(security = [1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2],time = 2) == [4, 5, 6, 10, 11, 12, 16, 17, 18]\n assert candidate(security = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11],time = 3) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 4) == [5, 20]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 7) == [19]\n assert candidate(security = [1, 2, 3, 2, 1, 2, 1, 2, 3, 4, 3, 2, 1, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],time = 3) == [5]\n assert candidate(security = [1, 3, 2, 3, 1, 2, 3, 2, 1, 2, 1, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 3, 2, 1],time = 2) == [13]\n assert candidate(security = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 5) == [5]\n assert candidate(security = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 2) == [2, 3, 4, 5, 6, 7]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 5, 5, 6, 7, 8, 9, 10],time = 3) == [5, 6, 7]\n assert candidate(security = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],time = 5) == [5, 6, 7, 8, 9, 10]\n assert candidate(security = [8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8],time = 2) == [2, 5, 6, 7, 8, 9, 12]\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46]\n assert candidate(security = [1, 3, 2, 3, 2, 1, 2, 3, 2, 1],time = 1) == [2, 5]\n assert candidate(security = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],time = 5) == []\n assert candidate(security = [1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 5, 6, 7, 8, 9],time = 2) == [5, 11]\n assert candidate(security = [8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],time = 6) == [7]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 12) == [12, 13]\n assert candidate(security = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],time = 7) == []\n assert candidate(security = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],time = 2) == [3, 4, 5, 6, 7, 8, 9]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10],time = 2) == [5]\n assert candidate(security = [5, 5, 4, 4, 4, 5, 6, 7, 8, 8],time = 2) == [2, 3, 4]\n assert candidate(security = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],time = 2) == [10, 11]\n assert candidate(security = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 3) == [4]\n assert candidate(security = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1],time = 3) == []\n assert candidate(security = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],time = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]\n assert candidate(security = [3, 3, 5, 5, 5, 5, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 1, 1, 1],time = 3) == [11]\n assert candidate(security = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3],time = 2) == [4, 8, 12]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]\n assert candidate(security = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],time = 2) == []\n assert candidate(security = [1, 3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],time = 2) == []\n assert candidate(security = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 5) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(security = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1],time = 1) == [1, 4, 5, 8, 9, 12, 13, 16, 17, 20]\n"}, "metadata": {"canonical_parameter_names": ["security", "time"], "leetcode_dataset_entry_point": "Solution().goodDaysToRobBank", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def goodDaysToRobBank(self, security: list[int], time: int) -> list[int]:", "container": "Solution", "callable": "goodDaysToRobBank", "parameters": [{"name": "security", "type": "list[int]"}, {"name": "time", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2101, "task_id": "detonate-the-maximum-bombs", "difficulty": "Medium", "problem_description": "You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb.\nThe bombs are represented by a 0-indexed 2D integer array bombs where bombs[i] = [xi, yi, ri]. xi and yi denote the X-coordinate and Y-coordinate of the location of the ith bomb, whereas ri denotes the radius of its range.\nYou may choose to detonate a single bomb. When a bomb is detonated, it will detonate all bombs that lie in its range. These bombs will further detonate the bombs that lie in their ranges.\nGiven the list of bombs, return the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb.\n \nExample 1:\n\n\nInput: bombs = [[2,1,3],[6,1,4]]\nOutput: 2\nExplanation:\nThe above figure shows the positions and ranges of the 2 bombs.\nIf we detonate the left bomb, the right bomb will not be affected.\nBut if we detonate the right bomb, both bombs will be detonated.\nSo the maximum bombs that can be detonated is max(1, 2) = 2.\n\nExample 2:\n\n\nInput: bombs = [[1,1,5],[10,10,5]]\nOutput: 1\nExplanation:\nDetonating either bomb will not detonate the other bomb, so the maximum number of bombs that can be detonated is 1.\n\nExample 3:\n\n\nInput: bombs = [[1,2,3],[2,3,1],[3,4,2],[4,5,3],[5,6,4]]\nOutput: 5\nExplanation:\nThe best bomb to detonate is bomb 0 because:\n- Bomb 0 detonates bombs 1 and 2. The red circle denotes the range of bomb 0.\n- Bomb 2 detonates bomb 3. The blue circle denotes the range of bomb 2.\n- Bomb 3 detonates bomb 4. The green circle denotes the range of bomb 3.\nThus all 5 bombs are detonated.\n\n \nConstraints:\n\n1 <= bombs.length <= 100\nbombs[i].length == 3\n1 <= xi, yi, ri <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5]]) == 1\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1]]) == 1\n assert candidate(bombs = [[1, 1, 100], [1, 1, 50], [1, 1, 25]]) == 3\n assert candidate(bombs = [[1, 1, 10], [10, 10, 10], [5, 5, 5]]) == 2\n assert candidate(bombs = [[1, 1, 10], [10, 10, 1], [5, 5, 5]]) == 2\n assert candidate(bombs = [[1, 1, 5], [10, 10, 5]]) == 1\n assert candidate(bombs = [[1, 2, 3], [2, 3, 1], [3, 4, 2], [4, 5, 3], [5, 6, 4]]) == 5\n assert candidate(bombs = [[5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1]]) == 1\n assert candidate(bombs = [[0, 0, 100], [50, 50, 100], [100, 100, 100]]) == 3\n assert candidate(bombs = [[100, 100, 1], [101, 101, 1], [102, 102, 1]]) == 1\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2]]) == 4\n assert candidate(bombs = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 3\n assert candidate(bombs = [[2, 1, 3], [6, 1, 4]]) == 2\n assert candidate(bombs = [[1, 1, 3], [2, 2, 3], [3, 3, 3], [4, 4, 3]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1]]) == 1\n assert candidate(bombs = [[5, 5, 3], [6, 6, 1], [7, 7, 4]]) == 3\n assert candidate(bombs = [[5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8]]) == 4\n assert candidate(bombs = [[10, 10, 10], [20, 20, 10], [30, 30, 10]]) == 1\n assert candidate(bombs = [[10, 10, 1], [20, 10, 1], [30, 10, 1], [40, 10, 1], [50, 10, 1], [60, 10, 1], [70, 10, 1], [80, 10, 1], [90, 10, 1], [100, 10, 1]]) == 1\n assert candidate(bombs = [[100, 100, 10], [100, 110, 10], [100, 120, 10], [110, 100, 10], [110, 110, 10], [110, 120, 10], [120, 100, 10], [120, 110, 10], [120, 120, 10]]) == 9\n assert candidate(bombs = [[0, 0, 1], [1, 0, 1], [2, 0, 1], [3, 0, 1], [4, 0, 1], [5, 0, 1], [6, 0, 1]]) == 7\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5]]) == 1\n assert candidate(bombs = [[50, 50, 10], [60, 60, 20], [70, 70, 30], [80, 80, 40], [90, 90, 50]]) == 5\n assert candidate(bombs = [[10, 10, 3], [10, 13, 3], [13, 10, 3], [13, 13, 3], [16, 16, 3], [16, 19, 3], [19, 16, 3], [19, 19, 3]]) == 4\n assert candidate(bombs = [[1, 1, 10], [1, 10, 10], [10, 1, 10], [10, 10, 10], [15, 15, 15], [15, 5, 15], [5, 15, 15], [20, 20, 5]]) == 8\n assert candidate(bombs = [[0, 0, 1], [1, 0, 1], [2, 0, 1], [3, 0, 1], [4, 0, 1], [5, 0, 1], [6, 0, 1], [7, 0, 1], [8, 0, 1], [9, 0, 1]]) == 10\n assert candidate(bombs = [[50, 50, 5], [55, 50, 5], [60, 50, 5], [65, 50, 5], [70, 50, 5], [75, 50, 5], [80, 50, 5], [85, 50, 5], [90, 50, 5], [95, 50, 5], [100, 50, 5], [105, 50, 5], [110, 50, 5], [115, 50, 5], [120, 50, 5], [125, 50, 5], [130, 50, 5], [135, 50, 5], [140, 50, 5], [145, 50, 5]]) == 20\n assert candidate(bombs = [[100, 100, 10], [110, 100, 10], [120, 100, 10], [130, 100, 10], [140, 100, 10], [150, 100, 10], [160, 100, 10], [170, 100, 10], [180, 100, 10]]) == 9\n assert candidate(bombs = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1]]) == 1\n assert candidate(bombs = [[50, 50, 5], [60, 50, 5], [70, 50, 5], [80, 50, 5], [50, 60, 5], [50, 70, 5], [50, 80, 5], [50, 90, 5], [50, 100, 5], [60, 60, 15]]) == 6\n assert candidate(bombs = [[100, 100, 50], [200, 100, 50], [100, 200, 50], [200, 200, 50], [150, 150, 100]]) == 5\n assert candidate(bombs = [[10, 10, 1], [20, 20, 1], [30, 30, 1], [40, 40, 1], [50, 50, 1], [60, 60, 1], [70, 70, 1], [80, 80, 1], [90, 90, 1], [100, 100, 100]]) == 8\n assert candidate(bombs = [[5, 5, 5], [5, 15, 5], [15, 5, 5], [15, 15, 5], [10, 10, 20]]) == 5\n assert candidate(bombs = [[1, 1, 5], [2, 2, 10], [3, 3, 2], [4, 4, 8], [5, 5, 1]]) == 5\n assert candidate(bombs = [[1, 1, 100], [1, 1, 100], [1, 1, 100], [1, 1, 100], [1, 1, 100]]) == 5\n assert candidate(bombs = [[0, 0, 20], [5, 0, 15], [10, 0, 10], [15, 0, 5], [20, 0, 1], [25, 0, 20], [30, 0, 15], [35, 0, 10], [40, 0, 5]]) == 9\n assert candidate(bombs = [[0, 0, 1], [2, 0, 1], [0, 2, 1], [2, 2, 1], [1, 1, 1.5]]) == 5\n assert candidate(bombs = [[50, 50, 15], [60, 50, 20], [70, 50, 10], [50, 60, 25], [50, 70, 12], [50, 80, 5]]) == 6\n assert candidate(bombs = [[0, 0, 10], [10, 0, 20], [20, 0, 30], [30, 0, 40], [40, 0, 50], [50, 0, 60], [60, 0, 70], [70, 0, 80], [80, 0, 90]]) == 9\n assert candidate(bombs = [[1, 1, 10], [10, 1, 10], [1, 10, 10], [10, 10, 10], [5, 5, 5], [15, 15, 15]]) == 6\n assert candidate(bombs = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9], [1, 10, 10]]) == 10\n assert candidate(bombs = [[1, 1, 10], [20, 20, 10], [30, 30, 10], [40, 40, 10], [50, 50, 10], [60, 60, 10]]) == 1\n assert candidate(bombs = [[100, 100, 50], [200, 200, 50], [300, 300, 50], [100, 200, 60], [200, 300, 70]]) == 1\n assert candidate(bombs = [[10, 10, 1], [15, 15, 2], [20, 20, 3], [25, 25, 4], [30, 30, 5]]) == 1\n assert candidate(bombs = [[5, 5, 1], [5, 6, 1], [5, 7, 1], [5, 8, 1], [5, 9, 1]]) == 5\n assert candidate(bombs = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40], [5, 5, 50], [6, 6, 60]]) == 6\n assert candidate(bombs = [[5, 5, 20], [10, 5, 20], [15, 5, 20], [20, 5, 20], [25, 5, 20], [30, 5, 20], [35, 5, 20], [40, 5, 20], [45, 5, 20], [50, 5, 20]]) == 10\n assert candidate(bombs = [[1, 1, 100], [200, 200, 100], [400, 400, 100], [600, 600, 100], [800, 800, 100], [1000, 1000, 100], [1200, 1200, 100], [1400, 1400, 100], [1600, 1600, 100], [1800, 1800, 100]]) == 1\n assert candidate(bombs = [[0, 0, 10], [20, 20, 10], [10, 10, 15], [30, 30, 20]]) == 3\n assert candidate(bombs = [[10, 10, 15], [20, 20, 15], [30, 30, 15], [40, 40, 15], [50, 50, 15], [60, 60, 15], [70, 70, 15], [80, 80, 15], [90, 90, 15]]) == 9\n assert candidate(bombs = [[10, 10, 15], [20, 20, 15], [30, 30, 15], [40, 40, 15], [50, 50, 15], [60, 60, 15], [70, 70, 15]]) == 7\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]]) == 10\n assert candidate(bombs = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]]) == 8\n assert candidate(bombs = [[100, 100, 100], [200, 100, 100], [300, 100, 100], [400, 100, 100], [500, 100, 100], [600, 100, 100], [700, 100, 100], [800, 100, 100], [900, 100, 100]]) == 9\n assert candidate(bombs = [[0, 0, 1], [1, 0, 1], [2, 0, 1], [3, 0, 1], [4, 0, 1], [5, 0, 1], [6, 0, 1], [7, 0, 1], [8, 0, 1], [9, 0, 1], [10, 0, 1]]) == 11\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1]]) == 1\n assert candidate(bombs = [[10, 10, 5], [15, 10, 5], [20, 10, 5], [25, 10, 5], [30, 10, 5], [35, 10, 5], [40, 10, 5], [45, 10, 5]]) == 8\n assert candidate(bombs = [[1, 1, 100], [1, 101, 100], [101, 101, 100], [101, 1, 100], [51, 51, 100], [51, 1, 100], [1, 51, 100], [101, 51, 100], [51, 101, 100]]) == 9\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2], [5, 5, 2], [6, 6, 2]]) == 6\n assert candidate(bombs = [[10, 10, 20], [30, 30, 20], [50, 50, 20], [70, 70, 20], [90, 90, 20], [110, 110, 20], [130, 130, 20], [150, 150, 20], [170, 170, 20], [190, 190, 20], [210, 210, 20], [230, 230, 20], [250, 250, 20], [270, 270, 20], [290, 290, 20]]) == 1\n assert candidate(bombs = [[5, 5, 2], [10, 5, 2], [15, 5, 2], [20, 5, 2], [25, 5, 2], [30, 5, 2], [35, 5, 2], [40, 5, 2], [45, 5, 2], [50, 5, 2], [55, 5, 2]]) == 1\n assert candidate(bombs = [[10, 10, 15], [20, 20, 25], [30, 30, 35], [40, 40, 45], [50, 50, 55]]) == 5\n assert candidate(bombs = [[100, 100, 100], [200, 200, 50], [300, 300, 25], [400, 400, 12.5]]) == 1\n assert candidate(bombs = [[5, 5, 10], [15, 5, 10], [5, 15, 10], [15, 15, 10], [10, 10, 5]]) == 5\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2], [5, 5, 2], [6, 6, 2], [7, 7, 2], [8, 8, 2], [9, 9, 2]]) == 9\n assert candidate(bombs = [[10, 10, 25], [15, 10, 15], [10, 15, 20], [5, 10, 10], [10, 5, 15]]) == 5\n assert candidate(bombs = [[1, 1, 3], [4, 4, 3], [7, 1, 3], [4, 7, 3], [10, 10, 3]]) == 2\n assert candidate(bombs = [[1, 1, 5], [1, 6, 5], [6, 1, 5], [6, 6, 5], [3, 3, 1]]) == 5\n assert candidate(bombs = [[1, 1, 1000], [2, 2, 1000], [3, 3, 1000], [4, 4, 1000], [5, 5, 1000], [6, 6, 1000], [7, 7, 1000], [8, 8, 1000]]) == 8\n assert candidate(bombs = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]]) == 1\n assert candidate(bombs = [[100, 100, 50], [150, 100, 50], [200, 100, 50], [250, 100, 50], [300, 100, 50], [350, 100, 50], [400, 100, 50], [450, 100, 50]]) == 8\n assert candidate(bombs = [[0, 0, 5], [10, 0, 5], [5, 5, 5], [15, 5, 5]]) == 1\n assert candidate(bombs = [[10, 10, 5], [15, 10, 5], [10, 15, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5]]) == 4\n assert candidate(bombs = [[0, 0, 10], [15, 0, 10], [30, 0, 10], [22, 0, 5]]) == 2\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13], [14, 14, 14], [15, 15, 15]]) == 15\n assert candidate(bombs = [[0, 0, 10], [20, 0, 10], [40, 0, 10], [60, 0, 10], [80, 0, 10], [100, 0, 10], [120, 0, 10], [140, 0, 10], [160, 0, 10], [180, 0, 10]]) == 1\n assert candidate(bombs = [[5, 5, 5], [10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5]]) == 1\n assert candidate(bombs = [[50, 50, 50], [60, 60, 50], [70, 70, 50], [80, 80, 50], [90, 90, 50], [100, 100, 50]]) == 6\n assert candidate(bombs = [[50, 50, 50], [100, 100, 50], [150, 150, 50], [200, 200, 50], [250, 250, 50], [300, 300, 50], [350, 350, 50], [400, 400, 50], [450, 450, 50]]) == 1\n assert candidate(bombs = [[0, 0, 10], [10, 0, 10], [20, 0, 10], [30, 0, 10], [40, 0, 10], [50, 0, 10]]) == 6\n assert candidate(bombs = [[10, 10, 5], [15, 15, 3], [20, 20, 4], [25, 25, 2], [30, 30, 6]]) == 1\n assert candidate(bombs = [[10, 10, 15], [15, 15, 15], [20, 20, 15], [25, 25, 15], [30, 30, 15]]) == 5\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5]]) == 1\n assert candidate(bombs = [[1, 1, 100], [101, 101, 100], [201, 201, 100], [301, 301, 100], [401, 401, 100]]) == 1\n assert candidate(bombs = [[5, 5, 3], [7, 5, 3], [9, 5, 3], [11, 5, 3], [13, 5, 3]]) == 5\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5], [5, 5, 5], [6, 6, 5], [7, 7, 5], [8, 8, 5], [9, 9, 5]]) == 9\n assert candidate(bombs = [[10000, 10000, 5000], [15000, 10000, 10000], [20000, 10000, 3000], [10000, 20000, 6000], [25000, 25000, 8000]]) == 3\n assert candidate(bombs = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9]]) == 9\n assert candidate(bombs = [[1000, 1000, 1000], [2000, 2000, 500], [3000, 3000, 250], [4000, 4000, 125]]) == 1\n assert candidate(bombs = [[0, 0, 10], [10, 0, 10], [20, 0, 10], [30, 0, 10], [40, 0, 10]]) == 5\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]]) == 5\n assert candidate(bombs = [[10, 10, 50], [20, 20, 40], [30, 30, 30], [40, 40, 20], [50, 50, 10]]) == 5\n assert candidate(bombs = [[5, 5, 10], [10, 10, 10], [15, 15, 10], [20, 20, 10], [25, 25, 10], [30, 30, 10], [35, 35, 10]]) == 7\n assert candidate(bombs = [[10, 10, 10], [20, 20, 10], [30, 30, 10], [40, 40, 10], [50, 50, 10], [60, 60, 10], [70, 70, 10], [80, 80, 10], [90, 90, 10], [100, 100, 10], [110, 110, 10], [120, 120, 10], [130, 130, 10], [140, 140, 10], [150, 150, 10]]) == 1\n assert candidate(bombs = [[1, 1, 10], [10, 1, 5], [10, 10, 15], [20, 20, 10]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]]) == 7\n assert candidate(bombs = [[1, 1, 10], [10, 1, 5], [1, 10, 5], [5, 5, 2], [7, 7, 7]]) == 5\n assert candidate(bombs = [[1, 1, 10000], [2, 2, 10000], [3, 3, 10000], [4, 4, 10000], [5, 5, 10000], [6, 6, 10000], [7, 7, 10000], [8, 8, 10000], [9, 9, 10000], [10, 10, 10000]]) == 10\n assert candidate(bombs = [[10, 10, 1], [11, 11, 2], [12, 12, 3], [13, 13, 4], [14, 14, 5], [15, 15, 6], [16, 16, 7], [17, 17, 8], [18, 18, 9], [19, 19, 10]]) == 10\n assert candidate(bombs = [[0, 0, 10], [10, 0, 10], [20, 0, 10], [15, 5, 5]]) == 4\n assert candidate(bombs = [[1, 1, 10], [11, 1, 10], [21, 1, 10], [1, 11, 10], [11, 11, 10], [21, 11, 10], [1, 21, 10], [11, 21, 10], [21, 21, 10]]) == 9\n assert candidate(bombs = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 5\n assert candidate(bombs = [[1, 1, 10], [2, 1, 10], [3, 1, 10], [4, 1, 10], [5, 1, 10], [6, 1, 10], [7, 1, 10], [8, 1, 10], [9, 1, 10], [10, 1, 10]]) == 10\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5], [5, 5, 5], [6, 6, 5], [7, 7, 5], [8, 8, 5], [9, 9, 5], [10, 10, 5], [11, 11, 5], [12, 12, 5], [13, 13, 5], [14, 14, 5], [15, 15, 5]]) == 15\n assert candidate(bombs = [[0, 0, 1], [1, 2, 2], [2, 4, 3], [3, 6, 4], [4, 8, 5], [5, 10, 6], [6, 12, 7], [7, 14, 8], [8, 16, 9]]) == 8\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]]) == 9\n assert candidate(bombs = [[5, 5, 5], [10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5], [45, 45, 5], [50, 50, 5]]) == 1\n assert candidate(bombs = [[0, 0, 50], [50, 0, 50], [100, 0, 50], [150, 0, 50], [200, 0, 50], [250, 0, 50], [300, 0, 50], [350, 0, 50], [400, 0, 50]]) == 9\n assert candidate(bombs = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5], [50, 50, 5], [60, 60, 5], [70, 70, 5], [80, 80, 5], [90, 90, 5], [100, 100, 5], [110, 110, 5], [120, 120, 5], [130, 130, 5], [140, 140, 5], [150, 150, 5]]) == 1\n assert candidate(bombs = [[10, 10, 3], [12, 12, 2], [15, 15, 1], [18, 18, 4], [20, 20, 5]]) == 2\n assert candidate(bombs = [[10, 10, 5], [15, 10, 10], [20, 10, 3], [10, 20, 6], [25, 25, 8]]) == 3\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13]]) == 13\n assert candidate(bombs = [[100, 100, 50], [200, 200, 50], [300, 300, 50], [250, 250, 100]]) == 3\n assert candidate(bombs = [[1, 1, 5], [5, 1, 5], [9, 1, 5], [13, 1, 5]]) == 4\n"}, "metadata": {"canonical_parameter_names": ["bombs"], "leetcode_dataset_entry_point": "Solution().maximumDetonation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def maximumDetonation(self, bombs: list[list[int]]) -> int:", "container": "Solution", "callable": "maximumDetonation", "parameters": [{"name": "bombs", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2103, "task_id": "rings-and-rods", "difficulty": "Easy", "problem_description": "There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9.\nYou are given a string rings of length 2n that describes the n rings that are placed onto the rods. Every two characters in rings forms a color-position pair that is used to describe each ring where:\n\nThe first character of the ith pair denotes the ith ring's color ('R', 'G', 'B').\nThe second character of the ith pair denotes the rod that the ith ring is placed on ('0' to '9').\n\nFor example, \"R3G2B1\" describes n == 3 rings: a red ring placed onto the rod labeled 3, a green ring placed onto the rod labeled 2, and a blue ring placed onto the rod labeled 1.\nReturn the number of rods that have all three colors of rings on them.\n \nExample 1:\n\n\nInput: rings = \"B0B6G0R6R0R6G9\"\nOutput: 1\nExplanation: \n- The rod labeled 0 holds 3 rings with all colors: red, green, and blue.\n- The rod labeled 6 holds 3 rings, but it only has red and blue.\n- The rod labeled 9 holds only a green ring.\nThus, the number of rods with all three colors is 1.\n\nExample 2:\n\n\nInput: rings = \"B0R0G0R9R0B0G0\"\nOutput: 1\nExplanation: \n- The rod labeled 0 holds 6 rings with all colors: red, green, and blue.\n- The rod labeled 9 holds only a red ring.\nThus, the number of rods with all three colors is 1.\n\nExample 3:\n\nInput: rings = \"G4\"\nOutput: 0\nExplanation: \nOnly one ring is given. Thus, no rods have all three colors.\n\n \nConstraints:\n\nrings.length == 2 * n\n1 <= n <= 100\nrings[i] where i is even is either 'R', 'G', or 'B' (0-indexed).\nrings[i] where i is odd is a digit from '0' to '9' (0-indexed).\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2\") == 3\n assert candidate(rings = \"R9G9B9R9G9B9R9G9B9\") == 1\n assert candidate(rings = \"G4\") == 0\n assert candidate(rings = \"R0G0R0G0R0G0\") == 0\n assert candidate(rings = \"G0G1G2G3G4G5G6G7G8G9\") == 0\n assert candidate(rings = \"B0B1B2B3B4B5B6B7B8B9\") == 0\n assert candidate(rings = \"G1G2G3G4G5G6G7G8G9G0\") == 0\n assert candidate(rings = \"R1R2R3R4R5R6R7R8R9R0\") == 0\n assert candidate(rings = \"B0B6G0R6R0R6G9\") == 1\n assert candidate(rings = \"R9G9B9\") == 1\n assert candidate(rings = \"B1B2B3B4B5B6B7B8B9B0\") == 0\n assert candidate(rings = \"R0R0G0G0B0B0R1R1G1G1B1B1\") == 2\n assert candidate(rings = \"B0R0G0R9R0B0G0\") == 1\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9\") == 0\n assert candidate(rings = \"R1R1R1G1G1G1B1B1B1\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0R1R2R3R4R5R6R7R8R9\") == 0\n assert candidate(rings = \"R9G9B9R9G9B9\") == 1\n assert candidate(rings = \"R0G0B0R1G0B0R2G0B0R3G0B0R4G0B0R5G0B0R6G0B0R7G0B0R8G0B0R9G0B0\") == 1\n assert candidate(rings = \"R5G5B5R5G5B5R5G5B5\") == 1\n assert candidate(rings = \"R1G1B1R2G2B2R3G3B3\") == 3\n assert candidate(rings = \"B9B9B9G9G9G9R9R9R9\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R1G1B1R2G2B2\") == 2\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R2G2B2R4G4B4R6G6B6R8G8B8\") == 5\n assert candidate(rings = \"R9G9B9R8G8B8R7G7B7\") == 3\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1R2G2B2R2G2B2R2G2B2R2G2B2\") == 3\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G2B3R4G5B6R7G8B9\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G2B3R4G5B6R7G8B9R0G1B2R3G4B5\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R0G0B0R1G1B1R2G2B2R3G3B3R0G0B0\") == 4\n assert candidate(rings = \"R0R0G0G0B0B0R1R1G1G1B1B1R2R2G2G2B2B2R3R3G3G3B3B3R4R4G4G4B4B4R5R5G5G5B5B5\") == 6\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G0B1R2G0B2R3G0B3R4G0B4R5G0B5R6G0B6R7G0B7R8G0B8R9G0B9R0G0B0R1G0B1R2G0B2R3G0B3R4G0B4R5G0B5R6G0B6R7G0B7R8G0B8R9G0B9\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R1G1B1\") == 10\n assert candidate(rings = \"R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1\") == 10\n assert candidate(rings = \"R0R0R0R0R0R0R0R0R0R0G0G0G0G0G0G0G0G0G0G0G0G0B0B0B0B0B0B0B0B0B0B0\") == 1\n assert candidate(rings = \"R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2\") == 0\n assert candidate(rings = \"R0G0B0R0G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 9\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0\") == 10\n assert candidate(rings = \"R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3\") == 0\n assert candidate(rings = \"R0G0B0R1G0B0R2G0B0R3G0B0R4G0B0R5G0B0R6G0B0R7G0B0R8G0B0R9G0B0R0G0B0R1G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R9G9B9R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R0G0B0R0G0B0\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G1B1R2G2B2R3G3B3\") == 4\n assert candidate(rings = \"R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3\") == 0\n assert candidate(rings = \"R9G9B9R8G8B8R7G7B7R6G6B6R5G5B5R4G4B4R3G3B3R2G2B2R1G1B1R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R2G2B2R2G2B2R2G2B2R3G3B3\") == 4\n assert candidate(rings = \"R0R0R0R0R0R1R1R1R1R1R2R2R2R2R2R3R3R3R3R3R4R4R4R4R4R5R5R5R5R5R6R6R6R6R6R7R7R7R7R7R8R8R8R8R8R9R9R9R9R9\") == 0\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0G0B0R1G1B1R1G1B2G2B2R2G2B3G3B3R3G3B4G4B4R4G4B5G5B5R5G5B6G6B6R6G6B7G7B7R7G7B8G8B8R8G8B9G9B9R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R8G8B8\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1\") == 2\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1\") == 2\n assert candidate(rings = \"R9G8B7R6G5B4R3G2B1R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5\") == 6\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R7G7B7R7G7B7R7G7B7\") == 10\n assert candidate(rings = \"R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2\") == 0\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R9G9B9R8G8B8R7G7B7R6G6B6R5G5B5R4G4B4R3G3B3R2G2B2R1G1B1R0G0B0\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G2B3R4G5B6R7G8B9R0G1B2R3G4B5R6G7B8R9G0\") == 10\n assert candidate(rings = \"R0B0G1R1B1G2R2B2G3R3B3G4R4B4G5R5B5G6R6B6G7R7B7G8R8B8G9R9B9\") == 9\n assert candidate(rings = \"R0G0B0G0B0R0B0G0R0R0G0B0R0G0B0R0R0G0R0G0B0R0B0G0R0G0R0B0G0R0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0\") == 0\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R6G6B6R6G6B6R6G6B6R6G6B6\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4\") == 10\n assert candidate(rings = \"R0R0R0G0G0G0B0B0B0R1R1R1G1G1G1B1B1B1R2R2R2G2G2G2B2B2B2\") == 3\n assert candidate(rings = \"R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0R0R0R0R0R0R0R0R0R0G0G0G0G0G0G0G0G0G0G0G0B0B0B0B0B0B0B0B0B0B0B0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4\") == 10\n assert candidate(rings = \"R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2\") == 0\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1\") == 2\n assert candidate(rings = \"G0B0R0G1B1R1G2B2R2G3B3R3G4B4R4G5B5R5G6B6R6G7B7R7G8B8R8G9B9R9G0B0R0G1B1R1G2B2R2G3B3R3G4B4R4G5B5R5G6B6R6G7B7R7G8B8R8G9B9R9\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0\") == 1\n assert candidate(rings = \"B9G9R9B8G8R8B7G7R7B6G6R6B5G5R5B4G4R4B3G3R3B2G2R2B1G1R1B0G0R0B9G9R9B8G8R8B7G7R7B6G6R6B5G5R5B4G4R4B3G3R3B2G2R2B1G1R1B0G0R0\") == 10\n assert candidate(rings = \"R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0\") == 10\n assert candidate(rings = \"B0G0B0G0B0R1G1R1G1R1B2G2B2G2G2R3G3R3G3G3B4G4B4G4G4R5G5R5G5G5B6G6B6G6G6R7G7R7G7G7B8G8B8G8G8R9G9R9G9G9B9G9B9G9G9\") == 1\n assert candidate(rings = \"G0B0R0G1B1R1G2B2R2G3B3R3G4B4R4G5B5R5G6B6R6G7B7R7G8B8R8G9B9R9G0B1R2G3B4R5G6B7R8G9B0\") == 10\n assert candidate(rings = \"R0G0B0R0G1B1R0G2B2R0G3B3R0G4B4R0G5B5R0G6B6R0G7B7R0G8B8R0G9B9\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0\") == 10\n assert candidate(rings = \"R0B1G2R3B4G5R6B7G8R9B0G1R2B3G4R5B6G7R8B9G0R1B2G3R4B5G6R7B8G9\") == 10\n assert candidate(rings = \"B9G8R7B6G5R4B3G2R1B0G9R8B7G6R5B4G3R2B1G0R9B8G7R6B5G4R3B2G1R0\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n"}, "metadata": {"canonical_parameter_names": ["rings"], "leetcode_dataset_entry_point": "Solution().countPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def countPoints(self, rings: str) -> int:", "container": "Solution", "callable": "countPoints", "parameters": [{"name": "rings", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2104, "task_id": "sum-of-subarray-ranges", "difficulty": "Medium", "problem_description": "You are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the subarray.\nReturn the sum of all subarray ranges of nums.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,2,3]\nOutput: 4\nExplanation: The 6 subarrays of nums are the following:\n[1], range = largest - smallest = 1 - 1 = 0 \n[2], range = 2 - 2 = 0\n[3], range = 3 - 3 = 0\n[1,2], range = 2 - 1 = 1\n[2,3], range = 3 - 2 = 1\n[1,2,3], range = 3 - 1 = 2\nSo the sum of all ranges is 0 + 0 + 0 + 1 + 1 + 2 = 4.\nExample 2:\n\nInput: nums = [1,3,3]\nOutput: 4\nExplanation: The 6 subarrays of nums are the following:\n[1], range = largest - smallest = 1 - 1 = 0\n[3], range = 3 - 3 = 0\n[3], range = 3 - 3 = 0\n[1,3], range = 3 - 1 = 2\n[3,3], range = 3 - 3 = 0\n[1,3,3], range = 3 - 1 = 2\nSo the sum of all ranges is 0 + 0 + 0 + 2 + 0 + 2 = 4.\n\nExample 3:\n\nInput: nums = [4,-2,-3,4,1]\nOutput: 59\nExplanation: The sum of all subarray ranges of nums is 59.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n-109 <= nums[i] <= 109\n\n \nFollow-up: Could you find a solution with O(n) time complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, -2, -3, -4]) == 10\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 165\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 165\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 30\n assert candidate(nums = [4, -2, -3, 4, 1]) == 59\n assert candidate(nums = [3, 2, 2, 2, 1]) == 8\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 20000000000\n assert candidate(nums = [10, 20, 30, 40, 50]) == 200\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 20\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 20\n assert candidate(nums = [100, 100, 100, 100]) == 0\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == 12000000000\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == 700\n assert candidate(nums = [10, 20, 30, 40, 50]) == 200\n assert candidate(nums = [1, 2, 2, 2, 3]) == 8\n assert candidate(nums = [5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [-10, -20, -30, -40, -50]) == 200\n assert candidate(nums = [1, 3, 3]) == 4\n assert candidate(nums = [1, 2, 3]) == 4\n assert candidate(nums = [-10, 100, -20, 200, -30, 300]) == 3580\n assert candidate(nums = [5]) == 0\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == 66\n assert candidate(nums = [-1, 4, -2, 3, -3]) == 60\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 45\n assert candidate(nums = [1, 0, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 384\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 16500\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 64\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50]) == 2400\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 190\n assert candidate(nums = [10, 20, 30, 25, 15, 10, 5, 2, 1, 0]) == 743\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 105\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 560\n assert candidate(nums = [5, 3, 8, 1, 4]) == 57\n assert candidate(nums = [10, 20, 30, 25, 15, 5]) == 240\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4]) == 168\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == 12000000000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 330\n assert candidate(nums = [5, 1, 4, 2, 8, 3]) == 77\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == 60\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 1540\n assert candidate(nums = [100, 200, 300, 400, 500, -500, -400, -300, -200, -100]) == 29000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 560\n assert candidate(nums = [100, 200, 300, 400, 500]) == 2000\n assert candidate(nums = [10, 20, 30, 40, 50, -50, -40, -30, -20, -10]) == 2900\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 20000000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 635\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == 36000\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1540\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 40\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 10, 1, 0, 1, 10, 100]) == 1149\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == 66\n assert candidate(nums = [9, -8, 7, -6, 5, -4, 3, -2, 1]) == 444\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 330\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 80\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1]) == 28\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 480\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 1655\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 240\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40]) == 1680\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10]) == 210\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 45\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000, -250000000]) == 21000000000\n assert candidate(nums = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 5600\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1650\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 330\n assert candidate(nums = [5, 8, 6, 7, 9, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1736\n assert candidate(nums = [9, 7, 5, 3, 1]) == 40\n assert candidate(nums = [5, 8, 3, 7, 9, 1]) == 87\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0]) == 22000\n assert candidate(nums = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10]) == 180\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 20\n assert candidate(nums = [10, -5, 3, 7, -2, 8]) == 172\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1]) == 42\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 165\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 330\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [-1, -5, -9, -3, -6]) == 59\n assert candidate(nums = [100, 200, 300, 400, 500, 600]) == 3500\n assert candidate(nums = [1, 5, 3, 7, 9, 2, 6, 8, 4, 10]) == 283\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 560\n assert candidate(nums = [5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 165\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5]) == 240\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 1650\n assert candidate(nums = [5, 2, 9, 1, 5, 6]) == 99\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 328\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 651\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1540\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 285\n assert candidate(nums = [100, -100, 200, -200, 300]) == 4000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 8550\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 235\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 6150\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1000000000, 1000000000, -1000000000, -1000000000]) == 8000000000\n assert candidate(nums = [-1, 2, -3, 4, -5]) == 70\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000]) == 15250000000\n assert candidate(nums = [100, -200, 300, -400, 500]) == 7000\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 220\n assert candidate(nums = [5, 3, 1, 2, 4]) == 27\n assert candidate(nums = [5, 2, 3, 1, 4, 6, 8, 7, 9, 0]) == 244\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2660\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 45\n assert candidate(nums = [5, 3, 8, 1, 4]) == 57\n assert candidate(nums = [5, 2, 4, 6, 1, 3]) == 60\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1]) == 56\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 330\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1650\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 90\n assert candidate(nums = [5, 3, 8, 2, 7]) == 53\n assert candidate(nums = [5, 1, 4, 3, 2]) == 29\n assert candidate(nums = [1, 2, 3, -1, -2, -3, 4, 5, 6]) == 201\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 2135\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 1650\n assert candidate(nums = [1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 3]) == 392\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 165000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 5600\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7]) == 560\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1540\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().subArrayRanges", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def subArrayRanges(self, nums: list[int]) -> int:", "container": "Solution", "callable": "subArrayRanges", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2105, "task_id": "watering-plants-ii", "difficulty": "Medium", "problem_description": "Alice and Bob want to water n plants in their garden. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i.\nEach plant needs a specific amount of water. Alice and Bob have a watering can each, initially full. They water the plants in the following way:\n\nAlice waters the plants in order from left to right, starting from the 0th plant. Bob waters the plants in order from right to left, starting from the (n - 1)th plant. They begin watering the plants simultaneously.\nIt takes the same amount of time to water each plant regardless of how much water it needs.\nAlice/Bob must water the plant if they have enough in their can to fully water it. Otherwise, they first refill their can (instantaneously) then water the plant.\nIn case both Alice and Bob reach the same plant, the one with more water currently in his/her watering can should water this plant. If they have the same amount of water, then Alice should water this plant.\n\nGiven a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the ith plant needs, and two integers capacityA and capacityB representing the capacities of Alice's and Bob's watering cans respectively, return the number of times they have to refill to water all the plants.\n \nExample 1:\n\nInput: plants = [2,2,3,3], capacityA = 5, capacityB = 5\nOutput: 1\nExplanation:\n- Initially, Alice and Bob have 5 units of water each in their watering cans.\n- Alice waters plant 0, Bob waters plant 3.\n- Alice and Bob now have 3 units and 2 units of water respectively.\n- Alice has enough water for plant 1, so she waters it. Bob does not have enough water for plant 2, so he refills his can then waters it.\nSo, the total number of times they have to refill to water all the plants is 0 + 0 + 1 + 0 = 1.\n\nExample 2:\n\nInput: plants = [2,2,3,3], capacityA = 3, capacityB = 4\nOutput: 2\nExplanation:\n- Initially, Alice and Bob have 3 units and 4 units of water in their watering cans respectively.\n- Alice waters plant 0, Bob waters plant 3.\n- Alice and Bob now have 1 unit of water each, and need to water plants 1 and 2 respectively.\n- Since neither of them have enough water for their current plants, they refill their cans and then water the plants.\nSo, the total number of times they have to refill to water all the plants is 0 + 1 + 1 + 0 = 2.\n\nExample 3:\n\nInput: plants = [5], capacityA = 10, capacityB = 8\nOutput: 0\nExplanation:\n- There is only one plant.\n- Alice's watering can has 10 units of water, whereas Bob's can has 8 units. Since Alice has more water in her can, she waters this plant.\nSo, the total number of times they have to refill is 0.\n\n \nConstraints:\n\nn == plants.length\n1 <= n <= 105\n1 <= plants[i] <= 106\nmax(plants[i]) <= capacityA, capacityB <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(plants = [5],capacityA = 10,capacityB = 8) == 0\n assert candidate(plants = [1000000, 1000000, 1000000],capacityA = 1000000,capacityB = 1000000) == 1\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 15,capacityB = 15) == 3\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 10) == 5\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 15,capacityB = 15) == 3\n assert candidate(plants = [2, 2, 3, 3],capacityA = 5,capacityB = 5) == 1\n assert candidate(plants = [1000000],capacityA = 1000000,capacityB = 1000000) == 0\n assert candidate(plants = [2, 2, 3, 3],capacityA = 3,capacityB = 4) == 2\n assert candidate(plants = [1, 10, 1, 10, 1, 10, 1, 10],capacityA = 10,capacityB = 10) == 6\n assert candidate(plants = [5, 8, 6],capacityA = 10,capacityB = 10) == 1\n assert candidate(plants = [10, 10, 10, 10, 10],capacityA = 10,capacityB = 10) == 3\n assert candidate(plants = [1, 2, 3, 4, 5],capacityA = 5,capacityB = 5) == 2\n assert candidate(plants = [10, 8, 6, 4, 2],capacityA = 10,capacityB = 8) == 2\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 5,capacityB = 5) == 8\n assert candidate(plants = [1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 3\n assert candidate(plants = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],capacityA = 150,capacityB = 100) == 4\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 50,capacityB = 50) == 5\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 29\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],capacityA = 30,capacityB = 30) == 8\n assert candidate(plants = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],capacityA = 10,capacityB = 12) == 17\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 20,capacityB = 20) == 5\n assert candidate(plants = [1000000, 500000, 1000000, 500000, 1000000, 500000, 1000000, 500000, 1000000, 500000],capacityA = 1000000,capacityB = 1000000) == 8\n assert candidate(plants = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],capacityA = 15,capacityB = 15) == 18\n assert candidate(plants = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],capacityA = 20,capacityB = 30) == 9\n assert candidate(plants = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],capacityA = 10,capacityB = 10) == 12\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],capacityA = 55,capacityB = 65) == 8\n assert candidate(plants = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],capacityA = 5,capacityB = 5) == 22\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],capacityA = 15,capacityB = 20) == 6\n assert candidate(plants = [10, 20, 30, 40, 50, 40, 30, 20, 10],capacityA = 25,capacityB = 25) == 7\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 1000000,capacityB = 1000000) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 20,capacityB = 25) == 11\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 5,capacityB = 5) == 0\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 1000000,capacityB = 1000000) == 3\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 30,capacityB = 35) == 7\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],capacityA = 50,capacityB = 60) == 16\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacityA = 100,capacityB = 100) == 11\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 10,capacityB = 10) == 12\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 10,capacityB = 10) == 16\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 10,capacityB = 35) == 9\n assert candidate(plants = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 15,capacityB = 20) == 6\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 5) == 7\n assert candidate(plants = [100, 150, 200, 250, 300, 350, 400, 450, 500],capacityA = 200,capacityB = 300) == 8\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 28\n assert candidate(plants = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 10) == 16\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],capacityA = 50,capacityB = 50) == 8\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],capacityA = 150,capacityB = 150) == 8\n assert candidate(plants = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981],capacityA = 2000000,capacityB = 2000000) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 20,capacityB = 10) == 13\n assert candidate(plants = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],capacityA = 150,capacityB = 120) == 4\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],capacityA = 15,capacityB = 15) == 19\n assert candidate(plants = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],capacityA = 30,capacityB = 60) == 8\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 2,capacityB = 2) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacityA = 7,capacityB = 8) == 12\n assert candidate(plants = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250],capacityA = 500,capacityB = 500) == 11\n assert candidate(plants = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],capacityA = 25,capacityB = 25) == 7\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 10,capacityB = 10) == 16\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],capacityA = 25,capacityB = 30) == 19\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 5,capacityB = 5) == 28\n assert candidate(plants = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],capacityA = 50,capacityB = 50) == 115\n assert candidate(plants = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61],capacityA = 1000000,capacityB = 500000) == 1\n assert candidate(plants = [1000000, 500000, 1000000, 500000],capacityA = 1000000,capacityB = 1000000) == 2\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],capacityA = 20,capacityB = 20) == 10\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 5,capacityB = 10) == 13\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 5,capacityB = 5) == 8\n assert candidate(plants = [3, 2, 4, 1, 2, 4, 3, 1, 2, 3],capacityA = 5,capacityB = 5) == 4\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 28\n assert candidate(plants = [500, 400, 300, 200, 100, 100, 200, 300, 400, 500],capacityA = 500,capacityB = 500) == 6\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],capacityA = 15,capacityB = 15) == 7\n assert candidate(plants = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],capacityA = 100,capacityB = 100) == 18\n assert candidate(plants = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],capacityA = 500000,capacityB = 500000) == 3\n assert candidate(plants = [5, 7, 3, 8, 6, 10, 4, 9, 2, 1],capacityA = 10,capacityB = 12) == 5\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 2,capacityB = 2) == 8\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 15,capacityB = 15) == 7\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 10,capacityB = 9) == 13\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 500000,capacityB = 500000) == 10\n assert candidate(plants = [100, 200, 150, 50, 300, 250, 350, 400, 450, 500],capacityA = 500,capacityB = 600) == 4\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 2000000,capacityB = 1500000) == 6\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],capacityA = 14,capacityB = 16) == 12\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],capacityA = 25,capacityB = 20) == 10\n assert candidate(plants = [100, 200, 300, 400, 500, 400, 300, 200, 100],capacityA = 300,capacityB = 300) == 5\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacityA = 25,capacityB = 20) == 4\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacityA = 5,capacityB = 5) == 18\n assert candidate(plants = [3, 2, 4, 2, 1, 2, 4, 3, 2, 1, 3, 2, 4, 2, 1],capacityA = 5,capacityB = 5) == 7\n assert candidate(plants = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],capacityA = 500,capacityB = 400) == 8\n assert candidate(plants = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],capacityA = 1000000,capacityB = 1000000) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacityA = 15,capacityB = 15) == 8\n assert candidate(plants = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71],capacityA = 150,capacityB = 150) == 26\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],capacityA = 10,capacityB = 10) == 7\n assert candidate(plants = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5],capacityA = 10,capacityB = 10) == 9\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],capacityA = 25,capacityB = 25) == 14\n assert candidate(plants = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],capacityA = 5,capacityB = 5) == 13\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacityA = 5,capacityB = 5) == 20\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacityA = 10,capacityB = 10) == 11\n assert candidate(plants = [5, 8, 6, 7, 5, 4, 3, 2, 1, 9],capacityA = 10,capacityB = 8) == 7\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],capacityA = 20,capacityB = 25) == 11\n assert candidate(plants = [9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 10) == 4\n assert candidate(plants = [10, 5, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 25,capacityB = 30) == 8\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 18\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 5,capacityB = 5) == 18\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],capacityA = 12,capacityB = 15) == 20\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 15,capacityB = 15) == 8\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],capacityA = 25,capacityB = 30) == 8\n assert candidate(plants = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],capacityA = 100,capacityB = 100) == 5\n"}, "metadata": {"canonical_parameter_names": ["plants", "capacityA", "capacityB"], "leetcode_dataset_entry_point": "Solution().minimumRefill", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "python", "interface": {"raw_signature": "def minimumRefill(self, plants: list[int], capacityA: int, capacityB: int) -> int:", "container": "Solution", "callable": "minimumRefill", "parameters": [{"name": "plants", "type": "list[int]"}, {"name": "capacityA", "type": "int"}, {"name": "capacityB", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1637, "task_id": "widest-vertical-area-between-two-points-containing-no-points", "difficulty": "Easy", "problem_description": "Given n points on a 2D plane where points[i] = [x_i, y_i], Return the widest vertical area between two points such that no points are inside the area.\n\nA vertical area is an area of fixed-width extending infinitely along the y-axis (i.e., infinite height). The widest vertical area is the one with the maximum width.\n\nNote that points on the edge of a vertical area are not considered included in the area.\n\nExample 1:\n\nInput: points = [[8,7],[9,9],[7,4],[9,7]]\nOutput: 1\nExplanation: Both the red and the blue area are optimal.\n\nExample 2:\n\nInput: points = [[3,1],[9,0],[1,0],[1,4],[5,3],[8,8]]\nOutput: 3\n\nConstraints:\n\n- n == points.length\n- 2 <= n <= 10^5\n- points[i].length == 2\n- 0 <= x_i, y_i <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 1\n assert candidate(points = [[1, 10], [3, 3], [5, 5], [7, 7], [9, 9]]) == 2\n assert candidate(points = [[5, 1], [4, 1], [3, 1], [2, 1], [1, 1]]) == 1\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]]) == 10\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7]]) == 2\n assert candidate(points = [[3, 1], [9, 0], [1, 0], [1, 4], [5, 3], [8, 8]]) == 3\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 1\n assert candidate(points = [[0, 0], [1000000000, 1000000000]]) == 1000000000\n assert candidate(points = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600]]) == 100\n assert candidate(points = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3]]) == 1\n assert candidate(points = [[8, 7], [9, 9], [7, 4], [9, 7]]) == 1\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == 10\n assert candidate(points = [[5, 5], [15, 5], [25, 5], [35, 5], [45, 5]]) == 10\n assert candidate(points = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14]]) == 3\n assert candidate(points = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == 1\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40]]) == 10\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]]) == 100\n assert candidate(points = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512]]) == 256\n assert candidate(points = [[5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == 1\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 999999991\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 110]]) == 1\n assert candidate(points = [[2, 5], [2, 8], [3, 6], [5, 9], [7, 10], [9, 3], [11, 7], [13, 4]]) == 2\n assert candidate(points = [[1, 10], [10, 1], [100, 10], [1000, 1], [10000, 10], [100000, 1], [1000000, 10], [10000000, 1], [100000000, 10], [1000000000, 1]]) == 900000000\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [10, 10], [20, 20], [30, 30], [40, 40]]) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 1\n assert candidate(points = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19], [22, 21]]) == 2\n assert candidate(points = [[1, 999999999], [2, 999999998], [3, 999999997], [4, 999999996], [5, 999999995], [6, 999999994], [7, 999999993], [8, 999999992], [9, 999999991], [10, 999999990]]) == 1\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 1\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [11, 1], [12, 2], [13, 3], [14, 4], [15, 5], [16, 6], [17, 7], [18, 8], [19, 9]]) == 1\n assert candidate(points = [[1, 5], [3, 5], [5, 5], [7, 5], [9, 5], [11, 5], [13, 5], [15, 5], [17, 5], [19, 5], [21, 5], [23, 5], [25, 5], [27, 5], [29, 5], [31, 5], [33, 5], [35, 5]]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 1\n assert candidate(points = [[5, 2], [4, 3], [3, 4], [2, 5], [1, 6], [0, 7], [10, 8], [9, 9], [8, 10], [7, 11]]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [5, 5], [8, 8], [13, 13], [21, 21], [34, 34], [55, 55], [89, 89], [144, 144], [233, 233], [377, 377]]) == 144\n assert candidate(points = [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]]) == 2\n assert candidate(points = [[1, 1], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [10, 11], [11, 10], [12, 13], [13, 12], [14, 15], [15, 14]]) == 1\n assert candidate(points = [[100, 1], [200, 1], [300, 1], [400, 1], [500, 1], [600, 1], [700, 1], [800, 1], [900, 1], [1000, 1]]) == 100\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600]]) == 100\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19], [21, 21], [23, 23], [25, 25], [27, 27], [29, 29], [31, 31]]) == 2\n assert candidate(points = [[1, 1000000000], [1000000000, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 999999991\n assert candidate(points = [[1, 1], [10, 10], [100, 100], [1000, 1000], [10000, 10000], [100000, 100000], [1000000, 1000000], [10000000, 10000000], [100000000, 100000000], [1000000000, 1000000000], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 900000000\n assert candidate(points = [[1000000000, 10], [500000000, 20], [250000000, 30], [125000000, 40], [62500000, 50]]) == 500000000\n assert candidate(points = [[10, 10], [20, 25], [30, 30], [40, 45], [50, 50], [60, 65], [70, 70], [80, 85], [90, 90], [100, 105]]) == 10\n assert candidate(points = [[100, 1], [200, 1], [300, 1], [400, 1], [500, 1], [600, 1], [700, 1], [800, 1], [900, 1], [1000, 1]]) == 100\n assert candidate(points = [[10, 10], [100, 20], [1000, 30], [10000, 40], [100000, 50], [1000000, 60], [10000000, 70], [100000000, 80], [1000000000, 90]]) == 900000000\n assert candidate(points = [[5, 5], [10, 5], [15, 5], [20, 5], [25, 5], [30, 5], [35, 5], [40, 5], [45, 5], [50, 5]]) == 5\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19], [21, 21], [23, 23], [25, 25]]) == 2\n assert candidate(points = [[1, 1], [1000000000, 1], [500000000, 1], [750000000, 1], [250000000, 1], [125000000, 1], [375000000, 1], [625000000, 1], [875000000, 1]]) == 125000000\n assert candidate(points = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10], [110, 10], [120, 10], [130, 10], [140, 10], [150, 10], [160, 10], [170, 10], [180, 10], [190, 10], [200, 10], [210, 10], [220, 10], [230, 10], [240, 10], [250, 10], [260, 10], [270, 10], [280, 10], [290, 10], [300, 10], [310, 10], [320, 10], [330, 10], [340, 10], [350, 10], [360, 10], [370, 10], [380, 10], [390, 10], [400, 10], [410, 10], [420, 10], [430, 10], [440, 10], [450, 10], [460, 10], [470, 10], [480, 10], [490, 10], [500, 10]]) == 10\n assert candidate(points = [[1, 2], [4, 6], [7, 8], [10, 5], [13, 9], [16, 3], [19, 7]]) == 3\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]]) == 2\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]]) == 1\n assert candidate(points = [[1000000000, 1000000000], [999999999, 999999999], [999999998, 1000000000], [999999997, 999999999], [999999996, 1000000000], [999999995, 999999999], [999999994, 1000000000]]) == 1\n assert candidate(points = [[1, 10], [100, 100], [200, 100], [300, 100], [400, 100], [500, 100]]) == 100\n assert candidate(points = [[10, 20], [20, 10], [30, 30], [40, 20], [50, 10], [60, 30], [70, 20], [80, 10], [90, 30], [100, 20]]) == 10\n assert candidate(points = [[1, 2], [3, 4], [6, 5], [7, 8], [10, 9], [15, 1], [20, 6], [25, 3]]) == 5\n assert candidate(points = [[10, 1], [15, 2], [20, 3], [25, 4], [30, 5], [35, 6], [40, 7], [45, 8], [50, 9], [55, 10], [60, 11], [65, 12], [70, 13], [75, 14], [80, 15]]) == 5\n assert candidate(points = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110], [110, 120], [120, 130], [130, 140], [140, 150], [150, 160], [160, 170], [170, 180], [180, 190], [190, 200], [200, 210], [210, 220], [220, 230], [230, 240], [240, 250], [250, 260], [260, 270], [270, 280], [280, 290], [290, 300]]) == 10\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1]]) == 1\n assert candidate(points = [[100, 100], [101, 101], [102, 102], [200, 200], [201, 201], [300, 300], [301, 301]]) == 99\n assert candidate(points = [[1, 1], [10, 10], [100, 100], [1000, 1000], [10000, 10000], [100000, 100000], [1000000, 1000000], [10000000, 10000000], [100000000, 100000000]]) == 90000000\n assert candidate(points = [[10, 15], [25, 20], [5, 5], [35, 30], [40, 40], [50, 5], [60, 60], [75, 80], [80, 85], [90, 90]]) == 15\n assert candidate(points = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512], [1024, 1024]]) == 512\n assert candidate(points = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [2, 3]]) == 1\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [2, 2], [999999999, 999999999], [3, 3], [999999998, 999999998]]) == 999999995\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [750000000, 750000000]]) == 250000000\n assert candidate(points = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]]) == 1\n assert candidate(points = [[1, 9], [3, 8], [5, 7], [7, 6], [9, 5], [11, 4], [13, 3], [15, 2], [17, 1], [19, 0], [21, 9], [23, 8], [25, 7], [27, 6], [29, 5], [31, 4], [33, 3], [35, 2], [37, 1], [39, 0]]) == 2\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [11, 9], [12, 8], [13, 7], [14, 6], [15, 5], [16, 4], [17, 3], [18, 2], [19, 1], [20, 0]]) == 1\n assert candidate(points = [[5, 5], [5, 1], [5, 9], [10, 10], [10, 5], [10, 0], [15, 15], [15, 10], [15, 0]]) == 5\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 2\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]]) == 0\n assert candidate(points = [[100, 200], [200, 200], [300, 200], [400, 200], [500, 200], [600, 200], [700, 200], [800, 200], [900, 200], [1000, 200]]) == 100\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]]) == 50\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [10, 40], [11, 50], [20, 60], [21, 70]]) == 9\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]]) == 1\n assert candidate(points = [[1000000, 1], [2000000, 2], [3000000, 3], [4000000, 4], [5000000, 5], [6000000, 6], [7000000, 7], [8000000, 8], [9000000, 9], [10000000, 10]]) == 1000000\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [750000000, 750000000], [125000000, 125000000], [625000000, 625000000], [375000000, 375000000], [875000000, 875000000]]) == 125000000\n assert candidate(points = [[10, 20], [30, 20], [20, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]]) == 10\n assert candidate(points = [[500000000, 1], [500000001, 2], [500000002, 3], [500000003, 4], [500000004, 5]]) == 1\n assert candidate(points = [[1000000000, 0], [1000000000, 1000000000], [0, 0], [0, 1000000000], [500000000, 500000000]]) == 500000000\n assert candidate(points = [[1, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 1\n assert candidate(points = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95], [105, 105]]) == 10\n assert candidate(points = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8], [100000000, 9], [1000000000, 10]]) == 900000000\n assert candidate(points = [[1, 5], [2, 3], [3, 1], [4, 4], [5, 7], [6, 2], [7, 6], [8, 8], [9, 9], [10, 0]]) == 1\n assert candidate(points = [[0, 0], [1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [750000000, 750000000]]) == 250000000\n assert candidate(points = [[8, 1], [16, 2], [24, 3], [32, 4], [40, 5], [48, 6], [56, 7], [64, 8], [72, 9], [80, 10], [88, 11], [96, 12], [104, 13], [112, 14], [120, 15]]) == 8\n assert candidate(points = [[1, 10], [2, 20], [4, 30], [8, 40], [16, 50], [32, 60], [64, 70], [128, 80], [256, 90], [512, 100]]) == 256\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [550, 550], [600, 600]]) == 50\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11]]) == 10\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [11, 9], [12, 8], [13, 7], [14, 6], [15, 5]]) == 1\n assert candidate(points = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512], [1024, 1024], [2048, 2048], [4096, 4096], [8192, 8192], [16384, 16384]]) == 8192\n assert candidate(points = [[5, 9], [5, 8], [5, 7], [5, 6], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0]]) == 0\n assert candidate(points = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 1]]) == 10\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 1]]) == 1\n assert candidate(points = [[1, 1], [10, 1], [100, 1], [1000, 1], [10000, 1], [100000, 1], [1000000, 1], [10000000, 1], [100000000, 1], [1000000000, 1]]) == 900000000\n assert candidate(points = [[1, 10], [1, 20], [1, 30], [1, 40], [1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [1, 100], [1, 110], [1, 120], [1, 130], [1, 140], [1, 150]]) == 0\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11], [120, 12], [130, 13], [140, 14], [150, 15]]) == 10\n assert candidate(points = [[8, 7], [9, 9], [7, 4], [9, 7], [11, 11], [12, 12], [10, 10], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18]]) == 1\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 1\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]]) == 1\n", "comparison": "exact"}, "public_tests": ["[[8,7],[9,9],[7,4],[9,7]]", "[[3,1],[9,0],[1,0],[1,4],[5,3],[8,8]]"], "hints": ["Try sorting the points", "Think whether the y-axis of a point is relevant"], "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().maxWidthOfVerticalArea", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:00+00:00", "tests_total": 104, "tests_dropped": 3, "flags": ["has_images"], "topic_tags": ["array", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxWidthOfVerticalArea(self, points: list[list[int]]) -> int:", "container": "Solution", "callable": "maxWidthOfVerticalArea", "parameters": [{"name": "points", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1638, "task_id": "count-substrings-that-differ-by-one-character", "difficulty": "Medium", "problem_description": "Given two strings s and t, find the number of ways you can choose a non-empty substring of s and replace a single character by a different character such that the resulting substring is a substring of t. In other words, find the number of substrings in s that differ from some substring in t by exactly one character.\n\nFor example, the underlined substrings in \"computer\" and \"computation\" only differ by the 'e'/'a', so this is a valid way.\n\nReturn the number of substrings that satisfy the condition above.\n\nA substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: s = \"aba\", t = \"baba\"\nOutput: 6\nExplanation: The following are the pairs of substrings from s and t that differ by exactly 1 character:\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\nThe underlined portions are the substrings that are chosen from s and t.\n\nExample 2:\n\nInput: s = \"ab\", t = \"bb\"\nOutput: 3\nExplanation: The following are the pairs of substrings from s and t that differ by 1 character:\n(\"ab\", \"bb\")\n(\"ab\", \"bb\")\n(\"ab\", \"bb\")\nThe underlined portions are the substrings that are chosen from s and t.\n\nConstraints:\n\n- 1 <= s.length, t.length <= 100\n- s and t consist of lowercase English letters only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abc\",t = \"abcd\") == 9\n assert candidate(s = \"abcde\",t = \"bcdef\") == 21\n assert candidate(s = \"aaaa\",t = \"bbbb\") == 16\n assert candidate(s = \"xyz\",t = \"xya\") == 9\n assert candidate(s = \"python\",t = \"typhon\") == 40\n assert candidate(s = \"xyz\",t = \"xyy\") == 9\n assert candidate(s = \"zzz\",t = \"zzz\") == 0\n assert candidate(s = \"same\",t = \"same\") == 12\n assert candidate(s = \"abcd\",t = \"abcf\") == 16\n assert candidate(s = \"abcde\",t = \"fghij\") == 25\n assert candidate(s = \"abcabc\",t = \"abcabc\") == 24\n assert candidate(s = \"aaaa\",t = \"aaab\") == 10\n assert candidate(s = \"mississippi\",t = \"misissippi\") == 126\n assert candidate(s = \"xyz\",t = \"xyw\") == 9\n assert candidate(s = \"a\",t = \"a\") == 0\n assert candidate(s = \"abcd\",t = \"dcba\") == 16\n assert candidate(s = \"abc\",t = \"def\") == 9\n assert candidate(s = \"a\",t = \"b\") == 1\n assert candidate(s = \"test\",t = \"tast\") == 16\n assert candidate(s = \"aba\",t = \"baba\") == 6\n assert candidate(s = \"aaa\",t = \"aaa\") == 0\n assert candidate(s = \"test\",t = \"text\") == 16\n assert candidate(s = \"abcd\",t = \"abce\") == 16\n assert candidate(s = \"hello\",t = \"hallo\") == 30\n assert candidate(s = \"code\",t = \"cide\") == 18\n assert candidate(s = \"ab\",t = \"bb\") == 3\n assert candidate(s = \"same\",t = \"sane\") == 18\n assert candidate(s = \"abcdefg\",t = \"abcdxyz\") == 49\n assert candidate(s = \"aaaaaab\",t = \"aaaaaac\") == 49\n assert candidate(s = \"qwertyuiop\",t = \"qwertuiopq\") == 99\n assert candidate(s = \"banana\",t = \"banane\") == 38\n assert candidate(s = \"asdfghjkl\",t = \"asdfghjkl\") == 72\n assert candidate(s = \"substring\",t = \"substrung\") == 94\n assert candidate(s = \"aaaaabbbbb\",t = \"bbbbbbaaaa\") == 91\n assert candidate(s = \"banana\",t = \"anana\") == 21\n assert candidate(s = \"algorithm\",t = \"algorihm\") == 72\n assert candidate(s = \"racecar\",t = \"racecdr\") == 55\n assert candidate(s = \"abacaba\",t = \"abacabb\") == 50\n assert candidate(s = \"aabbcc\",t = \"aabbcz\") == 41\n assert candidate(s = \"abcdefg\",t = \"gfedcba\") == 52\n assert candidate(s = \"aabbccddeeff\",t = \"aaabccddeeff\") == 177\n assert candidate(s = \"hellohello\",t = \"hellohelll\") == 101\n assert candidate(s = \"aabbccdd\",t = \"bbccddaa\") == 64\n assert candidate(s = \"racecar\",t = \"racecars\") == 52\n assert candidate(s = \"xyzxyzxyz\",t = \"zyxzyxzyx\") == 96\n assert candidate(s = \"programming\",t = \"programminh\") == 125\n assert candidate(s = \"banana\",t = \"bandana\") == 44\n assert candidate(s = \"abcdefg\",t = \"abcdefgh\") == 49\n assert candidate(s = \"qwert\",t = \"qwqrt\") == 29\n assert candidate(s = \"abcdefg\",t = \"abcdeff\") == 49\n assert candidate(s = \"abcdefghij\",t = \"abcdefghjk\") == 100\n assert candidate(s = \"abcabcabc\",t = \"abcabcabd\") == 72\n assert candidate(s = \"aaaaabbbbb\",t = \"aaaabbbbbb\") == 123\n assert candidate(s = \"abcdefghij\",t = \"abcdefghib\") == 100\n assert candidate(s = \"abcdefghi\",t = \"abcfghi\") == 63\n assert candidate(s = \"hellohello\",t = \"hallohallo\") == 134\n assert candidate(s = \"abcdefgh\",t = \"abcdefgha\") == 63\n assert candidate(s = \"qwert\",t = \"qwera\") == 25\n assert candidate(s = \"programming\",t = \"progrcmming\") == 150\n assert candidate(s = \"banana\",t = \"banama\") == 42\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",t = \"pneumonoultramicroscopicsilicovolcanoconiosus\") == 2250\n assert candidate(s = \"abcdabcd\",t = \"abceabcd\") == 72\n assert candidate(s = \"abcdefghij\",t = \"abcdefghix\") == 100\n assert candidate(s = \"example\",t = \"exampel\") == 48\n assert candidate(s = \"abcdefgh\",t = \"abxdefgh\") == 74\n assert candidate(s = \"abcabcabc\",t = \"defdefdef\") == 81\n assert candidate(s = \"programming\",t = \"prognamming\") == 149\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\") == 106\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",t = \"pneumonoultramicroscopicsilicovolcanoconiosi\") == 2118\n assert candidate(s = \"abcdef\",t = \"fedcba\") == 38\n assert candidate(s = \"abcdabcd\",t = \"dcbaabcd\") == 66\n assert candidate(s = \"abcdefgh\",t = \"fedcbagh\") == 68\n assert candidate(s = \"abcdefgh\",t = \"abcdexyz\") == 64\n assert candidate(s = \"abcdefg\",t = \"fghijkl\") == 47\n assert candidate(s = \"abcdefg\",t = \"abcdefh\") == 49\n assert candidate(s = \"abcdefghij\",t = \"abcdefghia\") == 99\n assert candidate(s = \"abcdef\",t = \"abcxef\") == 42\n assert candidate(s = \"abcdeabcde\",t = \"abcdeabcda\") == 94\n assert candidate(s = \"xyzzyx\",t = \"zyxzyx\") == 38\n assert candidate(s = \"zxcvbnm\",t = \"zxsvbnm\") == 57\n assert candidate(s = \"abcdabcd\",t = \"abxdabcd\") == 72\n assert candidate(s = \"mississippi\",t = \"misssissippi\") == 155\n assert candidate(s = \"longerstring\",t = \"longerstirng\") == 148\n assert candidate(s = \"pqrstuvw\",t = \"pqrsvwxy\") == 64\n assert candidate(s = \"zzzzzzzzzz\",t = \"zzzzzzzzza\") == 55\n assert candidate(s = \"abcdefg\",t = \"abcdefi\") == 49\n assert candidate(s = \"substring\",t = \"substrang\") == 93\n assert candidate(s = \"abacaba\",t = \"abaxaba\") == 56\n assert candidate(s = \"abcabcabc\",t = \"abcabcab\") == 48\n assert candidate(s = \"abcdefgh\",t = \"abcefgih\") == 67\n assert candidate(s = \"abcdefgabcdefg\",t = \"abcdefgabcdeff\") == 189\n assert candidate(s = \"python\",t = \"pythpn\") == 40\n assert candidate(s = \"abcdabcd\",t = \"abcddcba\") == 66\n assert candidate(s = \"abcdefg\",t = \"abcdefj\") == 49\n assert candidate(s = \"testtest\",t = \"tasttest\") == 68\n assert candidate(s = \"algorithm\",t = \"algorithr\") == 81\n assert candidate(s = \"aaaaab\",t = \"aaaabb\") == 35\n assert candidate(s = \"programming\",t = \"programming\") == 114\n assert candidate(s = \"banana\",t = \"bananas\") == 40\n assert candidate(s = \"testcase\",t = \"tastcase\") == 73\n assert candidate(s = \"aabbcc\",t = \"aabbbcc\") == 54\n assert candidate(s = \"qwertyuiop\",t = \"qwertuiop\") == 90\n assert candidate(s = \"programming\",t = \"programmimg\") == 136\n assert candidate(s = \"aabbccddeeff\",t = \"aabbccddeegg\") == 160\n assert candidate(s = \"abcdefg\",t = \"abcdefa\") == 48\n assert candidate(s = \"abcabcabc\",t = \"abcababc\") == 66\n assert candidate(s = \"abcabcabc\",t = \"abcabcbca\") == 71\n assert candidate(s = \"abcdefghij\",t = \"abcdefghja\") == 99\n assert candidate(s = \"testtest\",t = \"settsett\") == 83\n assert candidate(s = \"abcdefgh\",t = \"efghabcd\") == 56\n assert candidate(s = \"abacaba\",t = \"abacaba\") == 40\n assert candidate(s = \"abcdxyz\",t = \"xyzabcd\") == 42\n assert candidate(s = \"zzzzzz\",t = \"zzzzzz\") == 0\n assert candidate(s = \"pqrstuv\",t = \"qrsuvwp\") == 48\n assert candidate(s = \"abcabcabc\",t = \"ababcabc\") == 63\n assert candidate(s = \"abcdefghijk\",t = \"abcdefghijx\") == 121\n assert candidate(s = \"algorithm\",t = \"algorihtm\") == 83\n assert candidate(s = \"abcdabcd\",t = \"abacabad\") == 74\n assert candidate(s = \"zzzzz\",t = \"zzzzz\") == 0\n assert candidate(s = \"xyzz\",t = \"xyyz\") == 18\n assert candidate(s = \"banana\",t = \"bananna\") == 44\n assert candidate(s = \"aaaaabbbb\",t = \"aaaabbbbb\") == 98\n assert candidate(s = \"pattern\",t = \"patterr\") == 51\n assert candidate(s = \"abacax\",t = \"abacay\") == 40\n assert candidate(s = \"mississippi\",t = \"mississippa\") == 141\n assert candidate(s = \"programming\",t = \"progranning\") == 125\n assert candidate(s = \"substrings\",t = \"substraings\") == 108\n assert candidate(s = \"abcdefgh\",t = \"abcdefga\") == 63\n assert candidate(s = \"mississippi\",t = \"mississipp\") == 119\n assert candidate(s = \"zzzzzzzzzz\",t = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"abcdefghij\",t = \"abcegijhif\") == 104\n assert candidate(s = \"aaaaaaaaaa\",t = \"bbbbbbbbbb\") == 100\n assert candidate(s = \"programming\",t = \"programminq\") == 125\n assert candidate(s = \"xyzzyx\",t = \"zyxzyz\") == 39\n assert candidate(s = \"aabbcc\",t = \"bbaacc\") == 38\n assert candidate(s = \"abcabcabcabc\",t = \"abababababab\") == 166\n assert candidate(s = \"mnopqr\",t = \"mnopqs\") == 36\n assert candidate(s = \"abacabadabacaba\",t = \"abacabadabacaba\") == 272\n assert candidate(s = \"racecar\",t = \"racecer\") == 56\n assert candidate(s = \"abacaba\",t = \"babcaba\") == 47\n assert candidate(s = \"abcdefgh\",t = \"abcdefgi\") == 64\n assert candidate(s = \"abababa\",t = \"bababab\") == 25\n assert candidate(s = \"abcd\",t = \"abdc\") == 16\n assert candidate(s = \"qwerty\",t = \"qwertyuiop\") == 54\n assert candidate(s = \"interview\",t = \"interviww\") == 89\n assert candidate(s = \"mississippi\",t = \"mississipxy\") == 140\n assert candidate(s = \"qwertyuiop\",t = \"poiuytrewq\") == 106\n assert candidate(s = \"abcdefg\",t = \"abacdef\") == 49\n assert candidate(s = \"abcdefg\",t = \"abcxefg\") == 58\n assert candidate(s = \"aaaaabbbbb\",t = \"aaaabbbbba\") == 128\n assert candidate(s = \"aaaaab\",t = \"aaabaa\") == 39\n assert candidate(s = \"aaaaaaab\",t = \"aaaaaaax\") == 64\n assert candidate(s = \"abcdefgh\",t = \"hgfedcba\") == 68\n assert candidate(s = \"abababab\",t = \"babababa\") == 32\n assert candidate(s = \"abcdef\",t = \"abcdeg\") == 36\n", "comparison": "exact"}, "public_tests": ["\"aba\"\n\"baba\"", "\"ab\"\n\"bb\""], "hints": ["Take every substring of s, change a character, and see how many substrings of t match that substring.", "Use a Trie to store all substrings of t as a dictionary."], "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().countSubstrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:02+00:00", "tests_total": 156, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string", "dynamic-programming", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def countSubstrings(self, s: str, t: str) -> int:", "container": "Solution", "callable": "countSubstrings", "parameters": [{"name": "s", "type": "str"}, {"name": "t", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1639, "task_id": "number-of-ways-to-form-a-target-string-given-a-dictionary", "difficulty": "Hard", "problem_description": "You are given a list of strings of the same length words and a string target.\n\nYour task is to form target using the given words under the following rules:\n\n- target should be formed from left to right.\n- To form the i^th character (0-indexed) of target, you can choose the k^th character of the j^th string in words if target[i] = words[j][k].\n- Once you use the k^th character of the j^th string of words, you can no longer use the x^th character of any string in words where x <= k. In other words, all characters to the left of or at index k become unusuable for every string.\n- Repeat the process until you form the string target.\n\nNotice that you can use multiple characters from the same string in words provided the conditions above are met.\n\nReturn the number of ways to form target from words. Since the answer may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: words = [\"acca\",\"bbbb\",\"caca\"], target = \"aba\"\nOutput: 6\nExplanation: There are 6 ways to form target.\n\"aba\" -> index 0 (\"acca\"), index 1 (\"bbbb\"), index 3 (\"caca\")\n\"aba\" -> index 0 (\"acca\"), index 2 (\"bbbb\"), index 3 (\"caca\")\n\"aba\" -> index 0 (\"acca\"), index 1 (\"bbbb\"), index 3 (\"acca\")\n\"aba\" -> index 0 (\"acca\"), index 2 (\"bbbb\"), index 3 (\"acca\")\n\"aba\" -> index 1 (\"caca\"), index 2 (\"bbbb\"), index 3 (\"acca\")\n\"aba\" -> index 1 (\"caca\"), index 2 (\"bbbb\"), index 3 (\"caca\")\n\nExample 2:\n\nInput: words = [\"abba\",\"baab\"], target = \"bab\"\nOutput: 4\nExplanation: There are 4 ways to form target.\n\"bab\" -> index 0 (\"baab\"), index 1 (\"baab\"), index 2 (\"abba\")\n\"bab\" -> index 0 (\"baab\"), index 1 (\"baab\"), index 3 (\"baab\")\n\"bab\" -> index 0 (\"baab\"), index 2 (\"baab\"), index 3 (\"baab\")\n\"bab\" -> index 1 (\"abba\"), index 2 (\"baab\"), index 3 (\"baab\")\n\nConstraints:\n\n- 1 <= words.length <= 1000\n- 1 <= words[i].length <= 1000\n- All strings in words have the same length.\n- 1 <= target.length <= 1000\n- words[i] and target contain only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['a', 'b', 'c'],target = \"abc\") == 0\n assert candidate(words = ['abc', 'def'],target = \"ad\") == 0\n assert candidate(words = ['mississippi'],target = \"issi\") == 15\n assert candidate(words = ['aaa', 'aaa', 'aaa'],target = \"aaa\") == 27\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'],target = \"abc\") == 8\n assert candidate(words = ['abc', 'bcd', 'cde'],target = \"abc\") == 1\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"miss\") == 567\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"issi\") == 1215\n assert candidate(words = ['acca', 'bbbb', 'caca'],target = \"aba\") == 6\n assert candidate(words = ['leetcode', 'leetcode', 'leetcode'],target = \"leet\") == 81\n assert candidate(words = ['aaa', 'aaa', 'aaa'],target = \"a\") == 9\n assert candidate(words = ['zzz', 'zzz', 'zzz'],target = \"zzz\") == 27\n assert candidate(words = ['abc', 'bcd', 'cde'],target = \"aab\") == 0\n assert candidate(words = ['abc', 'bcd', 'cde'],target = \"abd\") == 1\n assert candidate(words = ['aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa'],target = \"aaaa\") == 17010\n assert candidate(words = ['abc', 'def', 'ghi'],target = \"adg\") == 0\n assert candidate(words = ['abba', 'baab'],target = \"bab\") == 4\n assert candidate(words = ['mississippi'],target = \"sip\") == 12\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghijk\") == 0\n assert candidate(words = ['abcdef', 'bcadef', 'cdefgh'],target = \"abcd\") == 2\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"mnop\") == 1\n assert candidate(words = ['abcdefgh', 'ijklmnop', 'qrstuvwx', 'yzabcdef'],target = \"aceg\") == 1\n assert candidate(words = ['abcdefg', 'xyzabc', 'mnopqr', 'stuvwx'],target = \"abc\") == 4\n assert candidate(words = ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd'],target = \"abcd\") == 15\n assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd'],target = \"abcd\") == 1\n assert candidate(words = ['xyzxyz', 'yzxyzy', 'zxyzxy', 'yzyxzy'],target = \"zyx\") == 26\n assert candidate(words = ['thisisanexample', 'thisisanexample', 'thisisanexample'],target = \"example\") == 2187\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi', 'mississippi'],target = \"miss\") == 1792\n assert candidate(words = ['hello', 'hello', 'hello', 'hello', 'hello'],target = \"hello\") == 3125\n assert candidate(words = ['xylophone', 'xylophone', 'xylophone'],target = \"xylo\") == 162\n assert candidate(words = ['hellohellohello', 'worldworldworld', 'hellohellohello'],target = \"helloworld\") == 2496\n assert candidate(words = ['ababababab', 'bababababa', 'ababababab'],target = \"ababab\") == 4339\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"aceg\") == 81\n assert candidate(words = ['lloremipsumdolorsitamet', 'lloremipsumdolorsitamet', 'lloremipsumdolorsitamet'],target = \"lorem\") == 1458\n assert candidate(words = ['abacabadabacaba', 'bacabadabacabab', 'acabadabacababa'],target = \"abacaba\") == 13252\n assert candidate(words = ['abcabc', 'bcabca', 'cababc'],target = \"abc\") == 39\n assert candidate(words = ['aabbccddeeff', 'bbaacceeddff', 'ccaabbeedddf', 'ddaabbccdeff'],target = \"abcde\") == 1496\n assert candidate(words = ['zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz'],target = \"zz\") == 150\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abcd\") == 5\n assert candidate(words = ['zzzzzz', 'yyyyyy', 'xxxxxx', 'wwwwww', 'vvvvvv'],target = \"zyxwv\") == 6\n assert candidate(words = ['abcabcabcabc', 'defdefdefdef', 'ghighighighi', 'jkljkljkljkl'],target = \"adgj\") == 1\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 999999937\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst'],target = \"afkp\") == 0\n assert candidate(words = ['zzzz', 'zzzz', 'zzzz', 'zzzz'],target = \"zzz\") == 256\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"ijkl\") == 1\n assert candidate(words = ['xyzxyzxyzxyz', 'yzxyzyzyzx', 'zxyzxyzxyz'],target = \"xyzxyz\") == 770\n assert candidate(words = ['aabbccddeeff', 'bbccddeeffgg', 'ccddeeffgghh'],target = \"abcdeffg\") == 414\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"acfi\") == 256\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"mnopqr\") == 1\n assert candidate(words = ['hello', 'hello', 'hello', 'hello', 'hello'],target = \"hello\") == 3125\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccaabb'],target = \"abc\") == 40\n assert candidate(words = ['banana', 'banana', 'banana', 'banana'],target = \"ban\") == 192\n assert candidate(words = ['abcdefghi', 'jklmnopqr', 'stuvwxyz'],target = \"adgt\") == 0\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij'],target = \"abcde\") == 1\n assert candidate(words = ['abcabcabc', 'abcabcabc', 'abcabcabc'],target = \"abc\") == 270\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"mississippi\") == 177147\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi', 'mississippi', 'mississippi', 'mississippi'],target = \"issipi\") == 746496\n assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz'],target = \"zzzz\") == 131250\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhii', 'jjkkll', 'mmnnoo'],target = \"abcd\") == 0\n assert candidate(words = ['aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa'],target = \"aaaa\") == 53760\n assert candidate(words = ['zzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzz'],target = \"zzzz\") == 392445\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"afg\") == 0\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"acegi\") == 3125\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij'],target = \"efghij\") == 1\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba'],target = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(words = ['abacaba', 'bacabab', 'cacabac', 'dacabad'],target = \"abac\") == 81\n assert candidate(words = ['zzzzzzzzzz', 'yyyyyyyyyy', 'xxxxxxxxxx', 'wwwwwwwwww', 'vvvvvvvvvv'],target = \"zyxwv\") == 252\n assert candidate(words = ['aaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc'],target = \"abc\") == 120\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij'],target = \"defg\") == 15\n assert candidate(words = ['target', 'target', 'target', 'target', 'target'],target = \"target\") == 15625\n assert candidate(words = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'jihgfedcba'],target = \"abcdefghij\") == 1024\n assert candidate(words = ['abcdefghij', 'klmnopqr', 'stuvwxyz', 'abcdefghij', 'klmnopqr'],target = \"mnop\") == 16\n assert candidate(words = ['banana', 'banana', 'banana', 'banana', 'banana'],target = \"ban\") == 375\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 59049\n assert candidate(words = ['aaaa', 'abbb', 'accc', 'addd'],target = \"abcd\") == 4\n assert candidate(words = ['aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz', 'aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz'],target = \"abcdefghijklmnopqrstu\") == 46480318\n assert candidate(words = ['abcdefg', 'abcdefg', 'abcdefg', 'abcdefg', 'abcdefg'],target = \"abcdefg\") == 78125\n assert candidate(words = ['abcdefghijklmnop', 'qrstuvwxyzab', 'cdefghijklmnop', 'qrstuvwxyzab'],target = \"abcde\") == 1\n assert candidate(words = ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd'],target = \"abcd\") == 15\n assert candidate(words = ['abcdefghijk', 'abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc'],target = \"abcdefg\") == 1224720\n assert candidate(words = ['aabbccdd', 'aabbccdd', 'aabbccdd', 'aabbccdd'],target = \"abcd\") == 4096\n assert candidate(words = ['abcd', 'abcf', 'acdf', 'adef'],target = \"ace\") == 4\n assert candidate(words = ['abcdefghij', 'klmnopqr', 'stuvwxyz', 'abcdefghij', 'klmnopqr'],target = \"mnopqrst\") == 0\n assert candidate(words = ['aaaaaaaabaaaaaa', 'baaaaaaaabaaaaa', 'caaaaaaabaaaaaa'],target = \"aaaaaabaaaaaa\") == 9920232\n assert candidate(words = ['abacabadabacaba', 'bcbdbecbdbecb', 'dcdcdcddcdcdc'],target = \"abc\") == 110\n assert candidate(words = ['abababababababab', 'bababababababa', 'abababababababab'],target = \"abab\") == 9394\n assert candidate(words = ['abcdef', 'fedcba', 'abcdef'],target = \"abcdef\") == 64\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"stuvwx\") == 1\n assert candidate(words = ['qwerty', 'qwerty', 'qwerty', 'qwerty', 'qwerty'],target = \"qwe\") == 125\n assert candidate(words = ['abcabcabc', 'defdefdef', 'ghighighi'],target = \"adg\") == 1\n assert candidate(words = ['abcdefghijk', 'abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc'],target = \"abc\") == 729\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghijabcdefghij\") == 0\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhii', 'jjkkgg'],target = \"abgi\") == 4\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba'],target = \"zyxwvutsrqponmlkjihgfedcba\") == 67108864\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz'],target = \"abcdefghijklmnopqrstuvwxyz\") == 67108864\n assert candidate(words = ['aaaa', 'abab', 'acac', 'adad', 'aeae'],target = \"aa\") == 46\n assert candidate(words = ['programming', 'is', 'fun'],target = \"pin\") == 1\n assert candidate(words = ['sequence', 'sequence', 'sequence', 'sequence', 'sequence'],target = \"seq\") == 125\n assert candidate(words = ['abcd', 'abcd', 'abcd', 'abcd', 'abcd'],target = \"abcd\") == 625\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"ssss\") == 81\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abc\") == 4\n assert candidate(words = ['abcdefghijkl', 'mnopqrstuv', 'wxyzabcdef', 'ghijklmnop'],target = \"mnop\") == 5\n assert candidate(words = ['abcdefghijabcdefghij', 'jihgfedcbaabcdef', 'abcdefghijjihgfe'],target = \"abcdefghij\") == 3536\n assert candidate(words = ['abacaba', 'bcbcbcb', 'cacacac'],target = \"abcabc\") == 10\n assert candidate(words = ['aabbccddeeff', 'gghhiijjkkll', 'mmnnooppqqrr', 'ssttuuvvwwxx'],target = \"abcdefff\") == 0\n assert candidate(words = ['abcde', 'abfgh', 'acjkl'],target = \"abac\") == 0\n assert candidate(words = ['algorithm', 'algorithm', 'algorithm', 'algorithm', 'algorithm'],target = \"algo\") == 625\n assert candidate(words = ['aaaaaaaaaa', 'aaaaaaaaab', 'aaaaaaaaac', 'aaaaaaaaad'],target = \"aaa\") == 5952\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"yzabcd\") == 1\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 9765625\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abcde\") == 1\n assert candidate(words = ['abcdefg', 'bcdefgh', 'cdefghi'],target = \"efg\") == 10\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 9765625\n assert candidate(words = ['racecar', 'racecar', 'racecar', 'racecar', 'racecar'],target = \"race\") == 625\n assert candidate(words = ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'],target = \"zzzzzzzzzz\") == 277520636\n assert candidate(words = ['abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd'],target = \"abcdabcd\") == 0\n assert candidate(words = ['abcabcabcabc', 'bcabcabcabca', 'cabcabcabcab'],target = \"abcabc\") == 924\n assert candidate(words = ['aabbccdd', 'bbaaddcc', 'ccddaabb', 'ddbbaacc'],target = \"abcd\") == 77\n assert candidate(words = ['aaaaaaaaa', 'bbbbbbbbb', 'ccccccccc', 'ddddddddd', 'eeeeeeeee', 'fffffff', 'ggggggggg', 'hhhhhhhhh', 'iiiiiiiii'],target = \"abcdefghi\") == 1\n assert candidate(words = ['zzzzzz', 'zzzzzz', 'zzzzzz'],target = \"zzz\") == 540\n assert candidate(words = ['quickbrownfox', 'quickbrownfox', 'quickbrownfox'],target = \"quickfox\") == 6561\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 59049\n assert candidate(words = ['abacabadabacaba', 'bcbdbecbdbecb', 'dcdcdcddcdcdc', 'efefegfefegfe', 'ghighighihighi'],target = \"abcdefg\") == 40\n assert candidate(words = ['abcdabcdabcd', 'abcdabcdabcd', 'abcdabcdabcd'],target = \"abcd\") == 1215\n assert candidate(words = ['abcdabcdabcd', 'bcdbcdbcdb', 'cdcdcdcdcd'],target = \"abcdabcd\") == 184\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abcdef\") == 1\n assert candidate(words = ['abcabcabc', 'defdefdef', 'ghighighi'],target = \"adg\") == 1\n assert candidate(words = ['abcdefg', 'hijklmn', 'opqrstu', 'vwxyzab', 'cdefghi'],target = \"abcde\") == 1\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr'],target = \"abcghi\") == 0\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zabcd'],target = \"ace\") == 4\n assert candidate(words = ['aaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc', 'dddddddddd', 'eeeeeeeeee'],target = \"abcde\") == 252\n assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz'],target = \"zzz\") == 7680\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhii', 'jjkkll'],target = \"abcd\") == 0\n assert candidate(words = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee'],target = \"abcde\") == 1\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"efgh\") == 5\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],target = \"zyxwvut\") == 0\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst'],target = \"afk\") == 0\n assert candidate(words = ['leetcode', 'leetcode', 'leetcode', 'leetcode'],target = \"leet\") == 256\n assert candidate(words = ['abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh'],target = \"abcdefgh\") == 390625\n assert candidate(words = ['thisisalongstring', 'thisisalongstring', 'thisisalongstring', 'thisisalongstring'],target = \"thisisalongstring\") == 179869065\n assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz'],target = \"zzzz\") == 53760\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"afik\") == 0\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 1048576\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abc\") == 125\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"missi\") == 3645\n assert candidate(words = ['abracadabra', 'abracadabra', 'abracadabra', 'abracadabra'],target = \"abrac\") == 1024\n assert candidate(words = ['ababababab', 'bababababa', 'ababababab', 'bababababa'],target = \"abab\") == 3360\n assert candidate(words = ['xylophone', 'xylophone', 'xylophone', 'xylophone', 'xylophone'],target = \"xyl\") == 125\n", "comparison": "exact"}, "public_tests": ["[\"acca\",\"bbbb\",\"caca\"]\n\"aba\"", "[\"abba\",\"baab\"]\n\"bab\""], "hints": ["For each index i, store the frequency of each character in the ith row.", "Use dynamic programing to calculate the number of ways to get the target string using the frequency array."], "metadata": {"canonical_parameter_names": ["words", "target"], "leetcode_dataset_entry_point": "Solution().numWays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:05+00:00", "tests_total": 148, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def numWays(self, words: list[str], target: str) -> int:", "container": "Solution", "callable": "numWays", "parameters": [{"name": "words", "type": "list[str]"}, {"name": "target", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1640, "task_id": "check-array-formation-through-concatenation", "difficulty": "Easy", "problem_description": "You are given an array of distinct integers arr and an array of integer arrays pieces, where the integers in pieces are distinct. Your goal is to form arr by concatenating the arrays in pieces in any order. However, you are not allowed to reorder the integers in each array pieces[i].\n\nReturn true if it is possible to form the array arr from pieces. Otherwise, return false.\n\nExample 1:\n\nInput: arr = [15,88], pieces = [[88],[15]]\nOutput: true\nExplanation: Concatenate [15] then [88]\n\nExample 2:\n\nInput: arr = [49,18,16], pieces = [[16,18,49]]\nOutput: false\nExplanation: Even though the numbers match, we cannot reorder pieces[0].\n\nExample 3:\n\nInput: arr = [91,4,64,78], pieces = [[78],[4,64],[91]]\nOutput: true\nExplanation: Concatenate [91] then [4,64] then [78]\n\nConstraints:\n\n- 1 <= pieces.length <= arr.length <= 100\n- sum(pieces[i].length) == arr.length\n- 1 <= pieces[i].length <= arr.length\n- 1 <= arr[i], pieces[i][j] <= 100\n- The integers in arr are distinct.\n- The integers in pieces are distinct (i.e., If we flatten pieces in a 1D array, all the integers in this array are distinct).\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [10, 20, 30, 40, 50],pieces = [[10, 20], [30, 40, 50]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5],pieces = [[2, 3], [1, 4], [5]]) == False\n assert candidate(arr = [91, 4, 64, 78],pieces = [[78], [4, 64], [91]]) == True\n assert candidate(arr = [49, 18, 16],pieces = [[16, 18, 49]]) == False\n assert candidate(arr = [15, 88],pieces = [[88], [15]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5],pieces = [[2], [4, 5], [3], [1]]) == True\n assert candidate(arr = [5, 9, 13, 17, 21, 25],pieces = [[5, 9, 13], [17, 21, 25]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14],pieces = [[2, 4], [6, 8], [10, 12], [14]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],pieces = [[100, 99], [98, 97], [96, 95, 94], [93, 92], [91]]) == True\n assert candidate(arr = [91, 4, 64, 78, 100, 50],pieces = [[78, 100], [91, 4], [64], [50]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],pieces = [[1, 3, 5, 7], [9, 11], [13, 15, 17, 19], [21, 23, 25], [27, 29]]) == True\n assert candidate(arr = [8, 16, 24, 32, 40, 48, 56, 64],pieces = [[8, 16, 24], [32, 40, 48], [56, 64]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99],pieces = [[11, 22], [33, 44, 55], [66, 77, 88, 99]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40],pieces = [[5, 10, 15], [20, 25], [30, 35, 40]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pieces = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1, 3, 5], [7, 9, 11], [13, 15, 17, 19]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2, 3], [4, 5], [6, 7, 8, 9, 10]]) == True\n assert candidate(arr = [23, 32, 45, 54, 67, 76, 89, 98],pieces = [[23, 32], [45, 54, 67], [76, 89], [98]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1, 3], [5, 7, 9], [11, 13], [15, 17, 19]]) == True\n assert candidate(arr = [3, 1, 2, 5, 4],pieces = [[3, 1], [2, 5], [4]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],pieces = [[1, 2], [3, 4, 5], [6], [7, 8, 9]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pieces = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],pieces = [[100, 99], [98, 97, 96], [95, 94, 93], [92, 91]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pieces = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11], [12, 13, 14, 15]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4], [6, 8, 10], [12, 14], [16, 18, 20]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pieces = [[1, 2, 3], [4, 5], [6, 7, 8], [9, 10, 11], [12, 13, 14, 15]]) == True\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],pieces = [[9], [8], [7], [6], [5], [4], [3], [2], [1]]) == True\n assert candidate(arr = [42, 13, 56, 78, 91, 100],pieces = [[42], [13, 56], [78], [91, 100]]) == True\n assert candidate(arr = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30],pieces = [[21, 22], [23, 24], [25, 26], [27, 28], [29, 30]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90],pieces = [[10, 20, 30], [40, 50], [60, 70, 80, 90]]) == True\n assert candidate(arr = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30],pieces = [[12, 14, 16], [18, 20], [22, 24, 26, 28, 30]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == True\n assert candidate(arr = [99, 88, 77, 66, 55, 44, 33, 22, 11],pieces = [[99], [88], [77], [66], [55], [44], [33], [22], [11]]) == True\n assert candidate(arr = [20, 30, 10, 50, 40],pieces = [[20, 30], [10, 50], [40]]) == True\n assert candidate(arr = [7, 14, 28, 21, 42],pieces = [[7, 14, 28], [21, 42]]) == True\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],pieces = [[100, 90], [80, 70, 60, 50], [40, 30, 20, 10]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[3, 4], [1, 2], [7, 8], [5, 6], [9, 10]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],pieces = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == True\n assert candidate(arr = [42, 43, 44, 45, 46, 47, 48, 49, 50],pieces = [[42, 43], [44, 45, 46], [47, 48], [49, 50]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1, 3, 5], [7, 9], [11, 13], [15, 17, 19]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40],pieces = [[5], [10, 15], [20, 25, 30], [35, 40]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15],pieces = [[1, 3, 5], [7, 9], [11, 13, 15]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1], [3, 5], [7, 9], [11, 13], [15, 17, 19]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90],pieces = [[10], [20], [30], [40], [50], [60], [70], [80], [90]]) == True\n assert candidate(arr = [2, 5, 3, 8, 9, 4],pieces = [[2, 5], [3], [8, 9], [4]]) == True\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],pieces = [[99, 98, 97], [96, 95, 94], [93, 92, 91, 90]]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27],pieces = [[3, 6, 9], [12, 15], [18, 21, 24, 27]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],pieces = [[1, 2], [3, 4, 5], [6, 7, 8], [9]]) == True\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15],pieces = [[3, 5, 7], [9, 11], [13, 15]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4, 5], [6, 7], [8, 9, 10]]) == True\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15],pieces = [[3, 5, 7], [9], [11, 13, 15]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96],pieces = [[97, 98], [96], [99], [100]]) == False\n assert candidate(arr = [7, 14, 21, 28, 35, 42],pieces = [[7], [14], [21], [28], [35], [42]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30],pieces = [[10, 15], [5], [20, 25, 30]]) == True\n assert candidate(arr = [5, 6, 1, 2, 3, 4],pieces = [[5, 6], [1, 2], [3, 4]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95],pieces = [[100], [99, 98], [97, 96, 95]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4, 5], [6, 7, 8, 9, 10]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95],pieces = [[100, 99], [98, 97], [96, 95]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],pieces = [[1, 3, 5], [7, 9, 11], [13, 15, 17], [19, 21]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35],pieces = [[5, 10, 15], [20], [25, 30, 35]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99],pieces = [[11, 22, 33], [44, 55], [66, 77, 88, 99]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70],pieces = [[10, 20], [30, 40, 50], [60, 70]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pieces = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == True\n assert candidate(arr = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34],pieces = [[25, 26], [27, 28, 29], [30, 31, 32, 33], [34]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],pieces = [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16],pieces = [[2, 4], [6, 8, 10], [12, 14, 16]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4], [6, 8, 10], [12, 14], [16, 18, 20]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4, 6], [8, 10, 12], [14, 16, 18], [20]]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21],pieces = [[3, 6], [9, 12], [15, 18], [21]]) == True\n assert candidate(arr = [5, 4, 3, 2, 1],pieces = [[5], [4, 3], [2, 1]]) == True\n assert candidate(arr = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40],pieces = [[31, 32], [33, 34], [35, 36], [37, 38], [39, 40]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],pieces = [[100, 99], [98, 97], [96, 95], [94, 93], [92, 91]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4, 6], [8, 10], [12, 14, 16, 18, 20]]) == True\n assert candidate(arr = [23, 29, 20, 32, 45, 67],pieces = [[23, 29, 20], [32], [45, 67]]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56],pieces = [[7, 14, 21, 28], [35, 42], [49, 56]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],pieces = [[1, 2], [3, 4], [5, 6], [7, 8], [9]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],pieces = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]) == True\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],pieces = [[9, 8, 7], [6, 5], [4, 3, 2], [1]]) == True\n assert candidate(arr = [5, 1, 3, 7, 8, 2, 4, 9, 6],pieces = [[1, 3], [5], [7, 8], [2, 4], [9, 6]]) == True\n assert candidate(arr = [5, 3, 8, 9, 10, 15, 20],pieces = [[5], [3, 8, 9], [10, 15], [20]]) == True\n assert candidate(arr = [4, 2, 5, 3, 6, 1, 7],pieces = [[4, 2], [5], [3, 6], [1, 7]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99],pieces = [[11, 22], [33, 44], [55, 66], [77, 88, 99]]) == True\n assert candidate(arr = [42, 24, 66, 33, 55, 77],pieces = [[42], [24, 66], [33, 55], [77]]) == True\n assert candidate(arr = [5, 1, 3, 9, 7, 6],pieces = [[5, 1], [3, 9], [7, 6]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100],pieces = [[11, 22], [33, 44], [55, 66], [77, 88], [99, 100]]) == True\n assert candidate(arr = [23, 45, 67, 89, 90, 12, 34, 56],pieces = [[23, 45], [67, 89, 90], [12, 34, 56]]) == True\n", "comparison": "exact"}, "public_tests": ["[15,88]\n[[88],[15]]", "[49,18,16]\n[[16,18,49]]", "[91,4,64,78]\n[[78],[4,64],[91]]"], "hints": ["Note that the distinct part means that every position in the array belongs to only one piece", "Note that you can get the piece every position belongs to naively"], "metadata": {"canonical_parameter_names": ["arr", "pieces"], "leetcode_dataset_entry_point": "Solution().canFormArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:07+00:00", "tests_total": 99, "tests_dropped": 11, "flags": [], "topic_tags": ["array", "hash-table"]}, "language": "python", "interface": {"raw_signature": "def canFormArray(self, arr: list[int], pieces: list[list[int]]) -> bool:", "container": "Solution", "callable": "canFormArray", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "pieces", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1641, "task_id": "count-sorted-vowel-strings", "difficulty": "Medium", "problem_description": "Given an integer n, return the number of strings of length n that consist only of vowels (a, e, i, o, u) and are lexicographically sorted.\n\nA string s is lexicographically sorted if for all valid i, s[i] is the same as or comes before s[i+1] in the alphabet.\n\nExample 1:\n\nInput: n = 1\nOutput: 5\nExplanation: The 5 sorted strings that consist of vowels only are [\"a\",\"e\",\"i\",\"o\",\"u\"].\n\nExample 2:\n\nInput: n = 2\nOutput: 15\nExplanation: The 15 sorted strings that consist of vowels only are\n[\"aa\",\"ae\",\"ai\",\"ao\",\"au\",\"ee\",\"ei\",\"eo\",\"eu\",\"ii\",\"io\",\"iu\",\"oo\",\"ou\",\"uu\"].\nNote that \"ea\" is not a valid string since 'e' comes after 'a' in the alphabet.\n\nExample 3:\n\nInput: n = 33\nOutput: 66045\n\nConstraints:\n\n- 1 <= n <= 50\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 35\n assert candidate(n = 4) == 70\n assert candidate(n = 33) == 66045\n assert candidate(n = 2) == 15\n assert candidate(n = 20) == 10626\n assert candidate(n = 1) == 5\n assert candidate(n = 50) == 316251\n assert candidate(n = 10) == 1001\n assert candidate(n = 5) == 126\n assert candidate(n = 45) == 211876\n assert candidate(n = 49) == 292825\n assert candidate(n = 12) == 1820\n assert candidate(n = 28) == 35960\n assert candidate(n = 30) == 46376\n assert candidate(n = 40) == 135751\n assert candidate(n = 8) == 495\n assert candidate(n = 22) == 14950\n assert candidate(n = 27) == 31465\n assert candidate(n = 35) == 82251\n assert candidate(n = 15) == 3876\n assert candidate(n = 9) == 715\n assert candidate(n = 6) == 210\n assert candidate(n = 7) == 330\n assert candidate(n = 25) == 23751\n", "comparison": "exact"}, "public_tests": ["1", "2", "33"], "hints": ["For each character, its possible values will depend on the value of its previous character, because it needs to be not smaller than it.", "Think backtracking. Build a recursive function count(n, last_character) that counts the number of valid strings of length n and whose first characters are not less than last_character.", "In this recursive function, iterate on the possible characters for the first character, which will be all the vowels not less than last_character, and for each possible value c, increase the answer by count(n-1, c)."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countVowelStrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:09+00:00", "tests_total": 24, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "dynamic-programming", "combinatorics"]}, "language": "python", "interface": {"raw_signature": "def countVowelStrings(self, n: int) -> int:", "container": "Solution", "callable": "countVowelStrings", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1642, "task_id": "furthest-building-you-can-reach", "difficulty": "Medium", "problem_description": "You are given an integer array heights representing the heights of buildings, some bricks, and some ladders.\n\nYou start your journey from building 0 and move to the next building by possibly using bricks or ladders.\n\nWhile moving from building i to building i+1 (0-indexed),\n\n- If the current building's height is greater than or equal to the next building's height, you do not need a ladder or bricks.\n- If the current building's height is less than the next building's height, you can either use one ladder or (h[i+1] - h[i]) bricks.\n\nReturn the furthest building index (0-indexed) you can reach if you use the given ladders and bricks optimally.\n\nExample 1:\n\nInput: heights = [4,2,7,6,9,14,12], bricks = 5, ladders = 1\nOutput: 4\nExplanation: Starting at building 0, you can follow these steps:\n- Go to building 1 without using ladders nor bricks since 4 >= 2.\n- Go to building 2 using 5 bricks. You must use either bricks or ladders because 2 < 7.\n- Go to building 3 without using ladders nor bricks since 7 >= 6.\n- Go to building 4 using your only ladder. You must use either bricks or ladders because 6 < 9.\nIt is impossible to go beyond building 4 because you do not have any more bricks or ladders.\n\nExample 2:\n\nInput: heights = [4,12,2,7,3,18,20,3,19], bricks = 10, ladders = 2\nOutput: 7\n\nExample 3:\n\nInput: heights = [14,3,19,3], bricks = 17, ladders = 0\nOutput: 3\n\nConstraints:\n\n- 1 <= heights.length <= 10^5\n- 1 <= heights[i] <= 10^6\n- 0 <= bricks <= 10^9\n- 0 <= ladders <= heights.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(heights = [10, 15, 20, 25, 30],bricks = 0,ladders = 2) == 2\n assert candidate(heights = [3, 1, 2, 1, 5],bricks = 2,ladders = 1) == 4\n assert candidate(heights = [5, 5, 5, 5, 5],bricks = 0,ladders = 0) == 4\n assert candidate(heights = [1, 1000000, 1, 1000000, 1],bricks = 1000000,ladders = 1) == 4\n assert candidate(heights = [10, 15, 20, 25, 30],bricks = 30,ladders = 2) == 4\n assert candidate(heights = [1, 1000000],bricks = 999999,ladders = 0) == 1\n assert candidate(heights = [14, 3, 19, 3],bricks = 17,ladders = 0) == 3\n assert candidate(heights = [1, 2, 3, 4, 5],bricks = 10,ladders = 0) == 4\n assert candidate(heights = [5, 4, 3, 2, 1],bricks = 0,ladders = 0) == 4\n assert candidate(heights = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],bricks = 100,ladders = 5) == 9\n assert candidate(heights = [100, 90, 80, 70, 60],bricks = 50,ladders = 0) == 4\n assert candidate(heights = [10, 15, 20, 25, 30],bricks = 30,ladders = 0) == 4\n assert candidate(heights = [1, 3, 5, 7, 9],bricks = 20,ladders = 2) == 4\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bricks = 0,ladders = 5) == 5\n assert candidate(heights = [3, 14, 3, 14, 3, 3, 14, 3, 14],bricks = 1,ladders = 1) == 2\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15],bricks = 20,ladders = 3) == 7\n assert candidate(heights = [1, 3, 5, 7, 9],bricks = 10,ladders = 0) == 4\n assert candidate(heights = [1, 1, 1, 1, 1],bricks = 0,ladders = 0) == 4\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bricks = 18,ladders = 1) == 9\n assert candidate(heights = [4, 2, 7, 6, 9, 14, 12],bricks = 5,ladders = 1) == 4\n assert candidate(heights = [1, 5, 1, 2, 3, 4, 10000],bricks = 4,ladders = 1) == 5\n assert candidate(heights = [5, 1, 3, 4, 2],bricks = 0,ladders = 1) == 2\n assert candidate(heights = [4, 2, 3],bricks = 0,ladders = 1) == 2\n assert candidate(heights = [5, 18, 22, 33, 8, 26, 48, 29, 55, 46],bricks = 83,ladders = 3) == 9\n assert candidate(heights = [1, 2],bricks = 0,ladders = 0) == 0\n assert candidate(heights = [4, 12, 2, 7, 3, 18, 20, 3, 19],bricks = 10,ladders = 2) == 7\n assert candidate(heights = [1, 3, 5, 7, 9],bricks = 100,ladders = 0) == 4\n assert candidate(heights = [9, 8, 7, 6, 5],bricks = 0,ladders = 5) == 4\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],bricks = 100,ladders = 2) == 13\n assert candidate(heights = [1, 3, 5, 4, 2, 1, 3, 5, 4, 2, 1, 3, 5, 4, 2, 1, 3, 5, 4, 2, 1],bricks = 20,ladders = 3) == 20\n assert candidate(heights = [5, 18, 3, 14, 5, 19, 2, 13, 11, 18, 23, 25, 28, 30, 35],bricks = 30,ladders = 4) == 14\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bricks = 200,ladders = 3) == 9\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 10,ladders = 0) == 9\n assert candidate(heights = [1, 2, 3, 100, 101, 102, 103, 104, 105],bricks = 10,ladders = 3) == 8\n assert candidate(heights = [1, 5, 3, 6, 7, 3, 8, 4, 9, 2, 10, 6, 11, 7, 12, 8, 13, 9, 14, 10],bricks = 20,ladders = 4) == 17\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],bricks = 50,ladders = 2) == 9\n assert candidate(heights = [4, 12, 2, 7, 3, 18, 20, 3, 19, 10, 5, 21, 17, 8, 15],bricks = 15,ladders = 3) == 13\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],bricks = 100,ladders = 3) == 15\n assert candidate(heights = [5, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],bricks = 50,ladders = 5) == 19\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bricks = 0,ladders = 0) == 19\n assert candidate(heights = [4, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50],bricks = 20,ladders = 4) == 10\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bricks = 100,ladders = 3) == 9\n assert candidate(heights = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 0,ladders = 0) == 49\n assert candidate(heights = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],bricks = 100,ladders = 10) == 59\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bricks = 0,ladders = 0) == 9\n assert candidate(heights = [5, 8, 17, 14, 12, 19, 21, 16, 18, 25, 27, 22, 24, 26, 30],bricks = 30,ladders = 4) == 14\n assert candidate(heights = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],bricks = 50,ladders = 5) == 9\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],bricks = 100,ladders = 5) == 24\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 50,ladders = 5) == 19\n assert candidate(heights = [10, 15, 20, 25, 30, 35, 40],bricks = 30,ladders = 2) == 6\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000],bricks = 0,ladders = 0) == 8\n assert candidate(heights = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],bricks = 15,ladders = 3) == 19\n assert candidate(heights = [3, 17, 9, 16, 14, 3, 17, 13, 19, 20, 15, 2, 18, 12, 1, 12, 14, 9, 1, 19],bricks = 20,ladders = 3) == 14\n assert candidate(heights = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],bricks = 25,ladders = 3) == 9\n assert candidate(heights = [5, 18, 3, 14, 5, 19, 2, 13, 11, 18],bricks = 20,ladders = 3) == 9\n assert candidate(heights = [40, 20, 30, 10, 50, 60, 70, 80, 90],bricks = 100,ladders = 2) == 8\n assert candidate(heights = [1, 2, 3, 4, 5, 15, 20, 25, 30, 35],bricks = 10,ladders = 0) == 4\n assert candidate(heights = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],bricks = 0,ladders = 0) == 29\n assert candidate(heights = [1, 1, 2, 1, 1, 2, 1, 1, 2, 1],bricks = 1,ladders = 1) == 7\n assert candidate(heights = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],bricks = 10,ladders = 0) == 19\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1],bricks = 10,ladders = 5) == 10\n assert candidate(heights = [10, 16, 18, 15, 12, 19, 20, 18, 17, 16],bricks = 15,ladders = 2) == 9\n assert candidate(heights = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],bricks = 0,ladders = 5) == 10\n assert candidate(heights = [1, 3, 6, 7, 8, 10, 12, 13, 14, 15, 17],bricks = 15,ladders = 2) == 10\n assert candidate(heights = [1, 3, 6, 7, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54],bricks = 100,ladders = 5) == 19\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 30,ladders = 5) == 19\n assert candidate(heights = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],bricks = 30,ladders = 1) == 8\n assert candidate(heights = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],bricks = 5,ladders = 0) == 9\n assert candidate(heights = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],bricks = 100,ladders = 5) == 9\n assert candidate(heights = [4, 10, 15, 20, 25, 30, 35, 40, 45, 50],bricks = 50,ladders = 2) == 9\n assert candidate(heights = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],bricks = 50,ladders = 4) == 9\n assert candidate(heights = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 0,ladders = 0) == 24\n assert candidate(heights = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],bricks = 10,ladders = 1) == 9\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],bricks = 100,ladders = 3) == 19\n assert candidate(heights = [100, 150, 200, 250, 300, 350, 400, 450, 500],bricks = 1000,ladders = 3) == 8\n assert candidate(heights = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5],bricks = 20,ladders = 3) == 9\n assert candidate(heights = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],bricks = 100,ladders = 2) == 9\n assert candidate(heights = [1, 5, 20, 30, 40, 50, 60, 70, 80, 90],bricks = 150,ladders = 2) == 9\n assert candidate(heights = [1, 100, 2, 101, 3, 102, 4, 103, 5],bricks = 100,ladders = 2) == 6\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],bricks = 100,ladders = 5) == 24\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],bricks = 100,ladders = 5) == 13\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 50,ladders = 5) == 9\n assert candidate(heights = [1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000],bricks = 1000000,ladders = 4) == 9\n assert candidate(heights = [5, 18, 12, 15, 20, 10, 19, 21],bricks = 50,ladders = 3) == 7\n assert candidate(heights = [4, 4, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 20,ladders = 2) == 19\n assert candidate(heights = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],bricks = 1,ladders = 1) == 29\n assert candidate(heights = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9],bricks = 30,ladders = 5) == 15\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],bricks = 150,ladders = 5) == 29\n assert candidate(heights = [10, 15, 20, 25, 30, 35, 40, 45, 50],bricks = 30,ladders = 2) == 8\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bricks = 45,ladders = 0) == 9\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],bricks = 100,ladders = 1) == 13\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],bricks = 50,ladders = 5) == 14\n assert candidate(heights = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],bricks = 20,ladders = 3) == 16\n assert candidate(heights = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11],bricks = 50,ladders = 3) == 19\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],bricks = 100,ladders = 3) == 9\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],bricks = 200,ladders = 15) == 39\n assert candidate(heights = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],bricks = 25,ladders = 2) == 8\n assert candidate(heights = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1],bricks = 15,ladders = 2) == 19\n assert candidate(heights = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],bricks = 20,ladders = 3) == 19\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],bricks = 100,ladders = 10) == 19\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 30,ladders = 2) == 19\n assert candidate(heights = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],bricks = 4000,ladders = 5) == 9\n assert candidate(heights = [5, 8, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],bricks = 50,ladders = 3) == 19\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 50,ladders = 4) == 19\n assert candidate(heights = [1, 5, 7, 8, 10, 12, 15, 20, 25, 30],bricks = 15,ladders = 3) == 9\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],bricks = 150,ladders = 10) == 29\n assert candidate(heights = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bricks = 55,ladders = 3) == 8\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 50,ladders = 2) == 19\n assert candidate(heights = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],bricks = 20,ladders = 2) == 6\n assert candidate(heights = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119],bricks = 50,ladders = 5) == 19\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bricks = 50,ladders = 3) == 9\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bricks = 0,ladders = 0) == 31\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bricks = 100,ladders = 0) == 9\n assert candidate(heights = [5, 10, 15, 10, 5, 10, 15, 20, 25, 30],bricks = 40,ladders = 1) == 9\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bricks = 150,ladders = 3) == 9\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],bricks = 100,ladders = 4) == 24\n", "comparison": "exact"}, "public_tests": ["[4,2,7,6,9,14,12]\n5\n1", "[4,12,2,7,3,18,20,3,19]\n10\n2", "[14,3,19,3]\n17\n0"], "hints": ["Assume the problem is to check whether you can reach the last building or not.", "You'll have to do a set of jumps, and choose for each one whether to do it using a ladder or bricks. It's always optimal to use ladders in the largest jumps.", "Iterate on the buildings, maintaining the largest r jumps and the sum of the remaining ones so far, and stop whenever this sum exceeds b."], "metadata": {"canonical_parameter_names": ["heights", "bricks", "ladders"], "leetcode_dataset_entry_point": "Solution().furthestBuilding", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:12+00:00", "tests_total": 118, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["array", "greedy", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def furthestBuilding(self, heights: list[int], bricks: int, ladders: int) -> int:", "container": "Solution", "callable": "furthestBuilding", "parameters": [{"name": "heights", "type": "list[int]"}, {"name": "bricks", "type": "int"}, {"name": "ladders", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1643, "task_id": "kth-smallest-instructions", "difficulty": "Hard", "problem_description": "Bob is standing at cell (0, 0), and he wants to reach destination: (row, column). He can only travel right and down. You are going to help Bob by providing instructions for him to reach destination.\n\nThe instructions are represented as a string, where each character is either:\n\n- 'H', meaning move horizontally (go right), or\n- 'V', meaning move vertically (go down).\n\nMultiple instructions will lead Bob to destination. For example, if destination is (2, 3), both \"HHHVV\" and \"HVHVH\" are valid instructions.\n\nHowever, Bob is very picky. Bob has a lucky number k, and he wants the k^th lexicographically smallest instructions that will lead him to destination. k is 1-indexed.\n\nGiven an integer array destination and an integer k, return the k^th lexicographically smallest instructions that will take Bob to destination.\n\nExample 1:\n\nInput: destination = [2,3], k = 1\nOutput: \"HHHVV\"\nExplanation: All the instructions that reach (2, 3) in lexicographic order are as follows:\n[\"HHHVV\", \"HHVHV\", \"HHVVH\", \"HVHHV\", \"HVHVH\", \"HVVHH\", \"VHHHV\", \"VHHVH\", \"VHVHH\", \"VVHHH\"].\n\nExample 2:\n\nInput: destination = [2,3], k = 2\nOutput: \"HHVHV\"\n\nExample 3:\n\nInput: destination = [2,3], k = 3\nOutput: \"HHVVH\"\n\nConstraints:\n\n- destination.length == 2\n- 1 <= row, column <= 15\n- 1 <= k <= nCr(row + column, row), where nCr(a, b) denotes a choose b.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(destination = [3, 3],k = 5) == \"HVHHVV\"\n assert candidate(destination = [2, 3],k = 1) == \"HHHVV\"\n assert candidate(destination = [4, 4],k = 10) == \"HHVVHHVV\"\n assert candidate(destination = [3, 3],k = 10) == \"HVVVHH\"\n assert candidate(destination = [2, 3],k = 2) == \"HHVHV\"\n assert candidate(destination = [2, 3],k = 3) == \"HHVVH\"\n assert candidate(destination = [4, 4],k = 20) == \"HVHVHHVV\"\n assert candidate(destination = [4, 5],k = 10) == \"HHHVVHHVV\"\n assert candidate(destination = [15, 15],k = 1) == \"HHHHHHHHHHHHHHHVVVVVVVVVVVVVVV\"\n assert candidate(destination = [3, 2],k = 4) == \"HVVVH\"\n assert candidate(destination = [3, 4],k = 5) == \"HHVHHVV\"\n assert candidate(destination = [5, 5],k = 100) == \"HVVHHVVHVH\"\n assert candidate(destination = [3, 2],k = 1) == \"HHVVV\"\n assert candidate(destination = [3, 10],k = 175) == \"HVHHHHHHVVHHH\"\n assert candidate(destination = [7, 8],k = 1716) == \"HHVVVVVVVHHHHHH\"\n assert candidate(destination = [12, 12],k = 50000) == \"HHHHHVVVVVVVHVVHHVHHVVHH\"\n assert candidate(destination = [15, 5],k = 2000) == \"HVVHVVVVVVVHVVVVVVHH\"\n assert candidate(destination = [9, 5],k = 252) == \"HVHHVVVVHVHVVV\"\n assert candidate(destination = [5, 7],k = 1000) == \"VVVVVVVVVVVV\"\n assert candidate(destination = [7, 9],k = 300) == \"HHHHHVVVVHHVHHVV\"\n assert candidate(destination = [9, 7],k = 5678) == \"VHHVHVHVVHVHVVVH\"\n assert candidate(destination = [10, 10],k = 5000) == \"HHHHVHVVVVVVVVHHHHHV\"\n assert candidate(destination = [9, 9],k = 1000) == \"HHHHVHVHVVVVVVVHHH\"\n assert candidate(destination = [3, 4],k = 15) == \"HVHVHVH\"\n assert candidate(destination = [14, 10],k = 5000) == \"HHHHHVHVVVVVHVHVHVHVVVVV\"\n assert candidate(destination = [15, 15],k = 10000) == \"HHHHHHHHHHVVVHVHVVVHVVVHVVVVVH\"\n assert candidate(destination = [15, 15],k = 500000) == \"HHHHHHVHHHHVVVVVHHVHHVVVVHVVVV\"\n assert candidate(destination = [8, 12],k = 250) == \"HHHHHHHHVHVVHVVVVVHH\"\n assert candidate(destination = [15, 15],k = 40116600) == \"HVHHHVHVHVVHHVVHHVVVVHVHHHVVHV\"\n assert candidate(destination = [10, 5],k = 200) == \"HHVVVHVVVVVVHHV\"\n assert candidate(destination = [12, 5],k = 1234) == \"HVVVHVVHVVVVHVVHV\"\n assert candidate(destination = [5, 15],k = 3003) == \"HHHHHVVVVVHHHHHHHHHH\"\n assert candidate(destination = [12, 8],k = 500) == \"HHHHVHHVVVVHVVHVVVVV\"\n assert candidate(destination = [7, 6],k = 150) == \"HHVHVHHVHVVVV\"\n assert candidate(destination = [3, 7],k = 123) == \"VVVVVVVVVV\"\n assert candidate(destination = [13, 7],k = 4000) == \"HHVHVVVVVVHHVHVVHVVV\"\n assert candidate(destination = [12, 12],k = 100000) == \"HHHHVVHVVVVHHHHVVHVHVHVV\"\n assert candidate(destination = [2, 13],k = 150) == \"VVVVVVVVVVVVVVV\"\n assert candidate(destination = [10, 10],k = 500) == \"HHHHHHVHVVVVVVVHVHHV\"\n assert candidate(destination = [10, 10],k = 1000) == \"HHHHHHVVVVVVVVVHVHHH\"\n assert candidate(destination = [7, 5],k = 30) == \"HHHVVVVHVVVH\"\n assert candidate(destination = [6, 6],k = 500) == \"VHHHVVHHVHVV\"\n assert candidate(destination = [9, 9],k = 10000) == \"HHVVVHHVHVHHVVHHVV\"\n assert candidate(destination = [6, 7],k = 120) == \"HHHVHVHVVVVHH\"\n assert candidate(destination = [8, 9],k = 500) == \"HHHHVHHHHVVVVHVVV\"\n assert candidate(destination = [15, 15],k = 1000000) == \"HHHHHHVVHVVVVHVVVVHHHVHVVVHHHV\"\n assert candidate(destination = [1, 15],k = 1) == \"HHHHHHHHHHHHHHHV\"\n assert candidate(destination = [10, 10],k = 10000) == \"HHHVHHVVVVVVVHVHHHHV\"\n assert candidate(destination = [10, 10],k = 1000) == \"HHHHHHVVVVVVVVVHVHHH\"\n assert candidate(destination = [7, 8],k = 3000) == \"HVVHVHVVHHHHVVH\"\n assert candidate(destination = [3, 10],k = 100) == \"HHHVHHVHHHHHV\"\n assert candidate(destination = [12, 8],k = 5000) == \"HHHVVVVHHVVHVVHVVVVH\"\n assert candidate(destination = [10, 5],k = 200) == \"HHVVVHVVVVVVHHV\"\n assert candidate(destination = [10, 10],k = 50000) == \"HVHHVHHVVVVVHHHVHVHV\"\n assert candidate(destination = [7, 7],k = 343) == \"HHVHHHVHVVVVVH\"\n assert candidate(destination = [7, 8],k = 1000) == \"HHVHHVVVVVHHVHH\"\n assert candidate(destination = [5, 4],k = 50) == \"HVVVHVHHV\"\n assert candidate(destination = [7, 8],k = 2000) == \"HVHHVHVHVHHVVHV\"\n assert candidate(destination = [3, 12],k = 200) == \"HHHVHHVHVHHHHHH\"\n assert candidate(destination = [6, 14],k = 10000) == \"HHHVHHVVVHVVHHHHHHHH\"\n assert candidate(destination = [8, 9],k = 15000) == \"VHHVHHVVVHHHVVHHV\"\n assert candidate(destination = [12, 4],k = 250) == \"HVVVHVHVVVVHVVVV\"\n assert candidate(destination = [7, 8],k = 1234) == \"HHVHVVVVHHHHHVV\"\n assert candidate(destination = [8, 7],k = 3456) == \"VHHVHVHVVHHVVHV\"\n assert candidate(destination = [13, 2],k = 100) == \"VVVVVVVVVVVHHVV\"\n assert candidate(destination = [11, 11],k = 6000) == \"HHHHHVHVHVVVVHVVHVHVHV\"\n assert candidate(destination = [7, 7],k = 200) == \"HHHVHVVVVHVVHH\"\n assert candidate(destination = [15, 15],k = 12345) == \"HHHHHHHHHHVVVVHVVVVVHVVHHVVVVH\"\n assert candidate(destination = [8, 12],k = 3456) == \"HHHHHVHHVHVHVVHHVVHV\"\n assert candidate(destination = [6, 9],k = 300) == \"HHHHVHVHVVVHVHH\"\n assert candidate(destination = [14, 6],k = 5000) == \"HVHVVVVVHVHVHVHVVVVV\"\n assert candidate(destination = [10, 6],k = 8316) == \"VVVVVVVVVVVVVVVV\"\n assert candidate(destination = [15, 15],k = 10000) == \"HHHHHHHHHHVVVHVHVVVHVVVHVVVVVH\"\n assert candidate(destination = [12, 12],k = 123456) == \"HHHHVVVVVVHHVHHHVHVHHVVV\"\n assert candidate(destination = [10, 10],k = 12870) == \"HHHVHVVVVVHHVVVHHHVH\"\n assert candidate(destination = [14, 6],k = 98765) == \"VVVVVVVVVVVVVVVVVVVV\"\n assert candidate(destination = [8, 6],k = 150) == \"HHHVVVVVHVHHVV\"\n assert candidate(destination = [7, 6],k = 300) == \"HHVVVVHHVHHVV\"\n assert candidate(destination = [12, 8],k = 2500) == \"HHHVHVVHHVVVHVVHVVVV\"\n assert candidate(destination = [5, 6],k = 120) == \"HHVVVHVHVHH\"\n assert candidate(destination = [6, 7],k = 500) == \"HVHHHVVHHVHVV\"\n assert candidate(destination = [9, 7],k = 200) == \"HHHHVVVVVHVVVVHH\"\n assert candidate(destination = [8, 6],k = 500) == \"HVHHHHVVVVHVVV\"\n assert candidate(destination = [15, 15],k = 6435678) == \"HHHHVVVHHHVHHVVVVHVVHHHVHVHVVV\"\n assert candidate(destination = [4, 12],k = 500) == \"HHHVHHHHHHHVHHVV\"\n assert candidate(destination = [8, 7],k = 650) == \"HHVHVHVHVHHVVVV\"\n assert candidate(destination = [6, 7],k = 123) == \"HHHVHVVHHVVHV\"\n assert candidate(destination = [12, 3],k = 200) == \"VVHVVVHHVVVVVVV\"\n assert candidate(destination = [5, 12],k = 500) == \"HHHHHVHHHVHHHVVHV\"\n assert candidate(destination = [5, 7],k = 30) == \"HHHHVHVHVVVH\"\n assert candidate(destination = [6, 4],k = 45) == \"HVHVVVHVHV\"\n assert candidate(destination = [15, 1],k = 1) == \"HVVVVVVVVVVVVVVV\"\n assert candidate(destination = [6, 8],k = 300) == \"HHHVHVHVVVHVHH\"\n", "comparison": "exact"}, "public_tests": ["[2,3]\n1", "[2,3]\n2", "[2,3]\n3"], "hints": ["There are nCr(row + column, row) possible instructions to reach (row, column).", "Try building the instructions one step at a time. How many instructions start with \"H\", and how does this compare with k?"], "metadata": {"canonical_parameter_names": ["destination", "k"], "leetcode_dataset_entry_point": "Solution().kthSmallestPath", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:14+00:00", "tests_total": 93, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "math", "dynamic-programming", "combinatorics"]}, "language": "python", "interface": {"raw_signature": "def kthSmallestPath(self, destination: list[int], k: int) -> str:", "container": "Solution", "callable": "kthSmallestPath", "parameters": [{"name": "destination", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1646, "task_id": "get-maximum-in-generated-array", "difficulty": "Easy", "problem_description": "You are given an integer n. A 0-indexed integer array nums of length n + 1 is generated in the following way:\n\n- nums[0] = 0\n- nums[1] = 1\n- nums[2 * i] = nums[i] when 2 <= 2 * i <= n\n- nums[2 * i + 1] = nums[i] + nums[i + 1] when 2 <= 2 * i + 1 <= n\n\nReturn the maximum integer in the array nums.\n\nExample 1:\n\nInput: n = 7\nOutput: 3\nExplanation: According to the given rules:\n nums[0] = 0\n nums[1] = 1\n nums[(1 * 2) = 2] = nums[1] = 1\n nums[(1 * 2) + 1 = 3] = nums[1] + nums[2] = 1 + 1 = 2\n nums[(2 * 2) = 4] = nums[2] = 1\n nums[(2 * 2) + 1 = 5] = nums[2] + nums[3] = 1 + 2 = 3\n nums[(3 * 2) = 6] = nums[3] = 2\n nums[(3 * 2) + 1 = 7] = nums[3] + nums[4] = 2 + 1 = 3\nHence, nums = [0,1,1,2,1,3,2,3], and the maximum is max(0,1,1,2,1,3,2,3) = 3.\n\nExample 2:\n\nInput: n = 2\nOutput: 1\nExplanation: According to the given rules, nums = [0,1,1]. The maximum is max(0,1,1) = 1.\n\nExample 3:\n\nInput: n = 3\nOutput: 2\nExplanation: According to the given rules, nums = [0,1,1,2]. The maximum is max(0,1,1,2) = 2.\n\nConstraints:\n\n- 0 <= n <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 0\n assert candidate(n = 3) == 2\n assert candidate(n = 100) == 21\n assert candidate(n = 99) == 21\n assert candidate(n = 2) == 1\n assert candidate(n = 20) == 7\n assert candidate(n = 1) == 1\n assert candidate(n = 50) == 13\n assert candidate(n = 7) == 3\n assert candidate(n = 10) == 4\n assert candidate(n = 88) == 21\n assert candidate(n = 97) == 21\n assert candidate(n = 63) == 13\n assert candidate(n = 45) == 13\n assert candidate(n = 49) == 13\n assert candidate(n = 47) == 13\n assert candidate(n = 60) == 13\n assert candidate(n = 64) == 13\n assert candidate(n = 37) == 11\n assert candidate(n = 17) == 5\n assert candidate(n = 42) == 11\n assert candidate(n = 90) == 21\n assert candidate(n = 22) == 8\n assert candidate(n = 89) == 21\n assert candidate(n = 75) == 18\n assert candidate(n = 81) == 18\n assert candidate(n = 24) == 8\n assert candidate(n = 11) == 5\n assert candidate(n = 15) == 5\n assert candidate(n = 31) == 8\n assert candidate(n = 25) == 8\n", "comparison": "exact"}, "public_tests": ["7", "2", "3"], "hints": ["Try generating the array.", "Make sure not to fall in the base case of 0."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().getMaximumGenerated", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:18+00:00", "tests_total": 31, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "simulation"]}, "language": "python", "interface": {"raw_signature": "def getMaximumGenerated(self, n: int) -> int:", "container": "Solution", "callable": "getMaximumGenerated", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1647, "task_id": "minimum-deletions-to-make-character-frequencies-unique", "difficulty": "Medium", "problem_description": "A string s is called good if there are no two different characters in s that have the same frequency.\n\nGiven a string s, return the minimum number of characters you need to delete to make s good.\n\nThe frequency of a character in a string is the number of times it appears in the string. For example, in the string \"aab\", the frequency of 'a' is 2, while the frequency of 'b' is 1.\n\nExample 1:\n\nInput: s = \"aab\"\nOutput: 0\nExplanation: s is already good.\n\nExample 2:\n\nInput: s = \"aaabbbcc\"\nOutput: 2\nExplanation: You can delete two 'b's resulting in the good string \"aaabcc\".\nAnother way it to delete one 'b' and one 'c' resulting in the good string \"aaabbc\".\n\nExample 3:\n\nInput: s = \"ceabaacb\"\nOutput: 2\nExplanation: You can delete both 'c's resulting in the good string \"eabaab\".\nNote that we only care about characters that are still in the string at the end (i.e. frequency of 0 is ignored).\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s contains only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aab\") == 0\n assert candidate(s = \"aabacabadabaeabafabagabahabaiabajabakabalabamabanabaoabapabaqabarabasabataabuabavabawabaxabayabajabaz\") == 22\n assert candidate(s = \"abcabcabc\") == 3\n assert candidate(s = \"aabbbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiii\") == 2\n assert candidate(s = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzz\") == 24\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 49\n assert candidate(s = \"ceabaacb\") == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aaabbbcc\") == 2\n assert candidate(s = \"aabbccddeeffgghhii\") == 15\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(s = \"a\") == 0\n assert candidate(s = \"zzzzzzzzzzyyyyyyyyyxxxxxxxwwwwwwvvvvuuuuutttttsssssrrrrqqqqppppooooonnnnmmmmlllkkkjjjiii\") == 41\n assert candidate(s = \"aabbccddeeefffggg\") == 11\n assert candidate(s = \"aabbccddeeefffhhhiiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 48\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 47\n assert candidate(s = \"pppppppppooooooonnnnnmmmllllllkkkkjjjjiiiiiiiihhhhhhhggggggg\") == 15\n assert candidate(s = \"aabbbccccddddeeeee\") == 3\n assert candidate(s = \"abababababababababab\") == 1\n assert candidate(s = \"zzzzzzzzzzzyyyyyyyxxxxxxxwwwwwwvvvvuuuutttssrrqponmlkjihgfedcba\") == 24\n assert candidate(s = \"aabbbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiiijjjjjjjjjj\") == 2\n", "comparison": "exact"}, "public_tests": ["\"aab\"", "\"aaabbbcc\"", "\"ceabaacb\""], "hints": ["As we can only delete characters, if we have multiple characters having the same frequency, we must decrease all the frequencies of them, except one.", "Sort the alphabet characters by their frequencies non-increasingly.", "Iterate on the alphabet characters, keep decreasing the frequency of the current character until it reaches a value that has not appeared before."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minDeletions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:21+00:00", "tests_total": 23, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minDeletions(self, s: str) -> int:", "container": "Solution", "callable": "minDeletions", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1648, "task_id": "sell-diminishing-valued-colored-balls", "difficulty": "Medium", "problem_description": "You have an inventory of different colored balls, and there is a customer that wants orders balls of any color.\n\nThe customer weirdly values the colored balls. Each colored ball's value is the number of balls of that color you currently have in your inventory. For example, if you own 6 yellow balls, the customer would pay 6 for the first yellow ball. After the transaction, there are only 5 yellow balls left, so the next yellow ball is then valued at 5 (i.e., the value of the balls decreases as you sell more to the customer).\n\nYou are given an integer array, inventory, where inventory[i] represents the number of balls of the i^th color that you initially own. You are also given an integer orders, which represents the total number of balls that the customer wants. You can sell the balls in any order.\n\nReturn the maximum total value that you can attain after selling orders colored balls. As the answer may be too large, return it modulo 10^9+ 7.\n\nExample 1:\n\nInput: inventory = [2,5], orders = 4\nOutput: 14\nExplanation: Sell the 1st color 1 time (2) and the 2nd color 3 times (5 + 4 + 3).\nThe maximum total value is 2 + 5 + 4 + 3 = 14.\n\nExample 2:\n\nInput: inventory = [3,5], orders = 6\nOutput: 19\nExplanation: Sell the 1st color 2 times (3 + 2) and the 2nd color 4 times (5 + 4 + 3 + 2).\nThe maximum total value is 3 + 2 + 5 + 4 + 3 + 2 = 19.\n\nConstraints:\n\n- 1 <= inventory.length <= 10^5\n- 1 <= inventory[i] <= 10^9\n- 1 <= orders <= min(sum(inventory[i]), 10^9)\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(inventory = [10, 10, 10],orders = 5) == 48\n assert candidate(inventory = [3, 5],orders = 6) == 19\n assert candidate(inventory = [1, 2, 3, 4, 5],orders = 10) == 30\n assert candidate(inventory = [1, 1, 1, 1, 1],orders = 3) == 3\n assert candidate(inventory = [7],orders = 7) == 28\n assert candidate(inventory = [1000000000, 1000000000],orders = 1000000000) == 250000035\n assert candidate(inventory = [1000000000],orders = 1) == 1000000000\n assert candidate(inventory = [5, 5, 5, 5, 5],orders = 20) == 70\n assert candidate(inventory = [1000000000],orders = 1000000000) == 21\n assert candidate(inventory = [2, 5],orders = 4) == 14\n assert candidate(inventory = [100],orders = 10) == 955\n assert candidate(inventory = [9, 9, 9, 9, 9, 9],orders = 25) == 185\n assert candidate(inventory = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20],orders = 350) == 4110\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 5) == 5\n assert candidate(inventory = [100, 90, 80, 70, 60],orders = 200) == 12600\n assert candidate(inventory = [1000000, 2000000, 3000000],orders = 5000000) == 335785502\n assert candidate(inventory = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],orders = 100) == 500\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 50) == 215\n assert candidate(inventory = [1000, 2000, 3000, 4000, 5000],orders = 10000) == 25005000\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 55) == 220\n assert candidate(inventory = [5, 15, 25, 35, 45],orders = 35) == 1138\n assert candidate(inventory = [100000000, 100000000, 100000000],orders = 299999997) == 44999997\n assert candidate(inventory = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],orders = 50) == 150\n assert candidate(inventory = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],orders = 900) == 70200\n assert candidate(inventory = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],orders = 500) == 37750\n assert candidate(inventory = [1000000000, 500000000, 250000000, 125000000, 62500000],orders = 999999999) == 312500027\n assert candidate(inventory = [500000000, 400000000, 300000000, 200000000, 100000000],orders = 1500000000) == 825000014\n assert candidate(inventory = [100, 200, 300, 400, 500],orders = 1000) == 250500\n assert candidate(inventory = [100000000, 200000000, 300000000, 400000000, 500000000],orders = 900000000) == 778750014\n assert candidate(inventory = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],orders = 50) == 400\n assert candidate(inventory = [999999999, 999999999, 999999999, 999999999, 999999999],orders = 500000000) == 425000028\n assert candidate(inventory = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],orders = 500) == 37750\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],orders = 190) == 1520\n assert candidate(inventory = [50, 40, 30, 20, 10],orders = 100) == 2550\n assert candidate(inventory = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],orders = 1500) == 134972\n assert candidate(inventory = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],orders = 5000) == 1915000\n assert candidate(inventory = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20],orders = 500) == 6080\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 10) == 10\n assert candidate(inventory = [3, 5, 7, 9],orders = 15) == 79\n assert candidate(inventory = [500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000],orders = 4500000) == 502241341\n assert candidate(inventory = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],orders = 550) == 19525\n assert candidate(inventory = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],orders = 10000) == 6071070\n assert candidate(inventory = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],orders = 1000) == 66330\n assert candidate(inventory = [1, 3, 5, 7, 9],orders = 15) == 79\n assert candidate(inventory = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],orders = 7500) == 5500000\n assert candidate(inventory = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],orders = 50) == 110\n assert candidate(inventory = [10, 10, 20, 20, 30, 30],orders = 50) == 1012\n assert candidate(inventory = [10, 20, 30, 40, 50],orders = 100) == 2550\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 20) == 20\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 10) == 10\n assert candidate(inventory = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],orders = 300) == 16124\n assert candidate(inventory = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],orders = 200) == 9100\n assert candidate(inventory = [10, 20, 30, 40, 50],orders = 50) == 1708\n assert candidate(inventory = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],orders = 1500) == 94500\n assert candidate(inventory = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],orders = 40) == 110\n assert candidate(inventory = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],orders = 100) == 715\n assert candidate(inventory = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],orders = 25000) == 144369642\n assert candidate(inventory = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],orders = 1000000000) == 46\n assert candidate(inventory = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],orders = 40) == 200\n assert candidate(inventory = [10, 8, 6, 4, 2],orders = 15) == 94\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 45) == 210\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],orders = 50) == 465\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 50) == 50\n assert candidate(inventory = [50, 20, 10, 5, 1],orders = 50) == 1375\n assert candidate(inventory = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],orders = 500) == 19375\n assert candidate(inventory = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],orders = 100) == 1155\n assert candidate(inventory = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],orders = 100) == 800\n assert candidate(inventory = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],orders = 10000) == 75005000\n assert candidate(inventory = [1000000000, 500000000, 250000000, 125000000, 62500000],orders = 1000000000) == 562500028\n assert candidate(inventory = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],orders = 1000000) == 499475\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 30) == 174\n assert candidate(inventory = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990],orders = 1000000000) == 350000124\n assert candidate(inventory = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],orders = 50) == 460\n assert candidate(inventory = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],orders = 1000) == 750500\n assert candidate(inventory = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],orders = 200) == 14627\n assert candidate(inventory = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],orders = 45) == 145\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],orders = 190) == 1520\n assert candidate(inventory = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],orders = 1000) == 175234\n assert candidate(inventory = [50, 40, 30, 20, 10],orders = 150) == 2825\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],orders = 150) == 1416\n assert candidate(inventory = [10, 20, 30, 40, 50],orders = 100) == 2550\n assert candidate(inventory = [500000000, 500000000, 500000000, 500000000, 500000000],orders = 2000000000) == 800000028\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 55) == 220\n", "comparison": "exact"}, "public_tests": ["[2,5]\n4", "[3,5]\n6"], "hints": ["Greedily sell the most expensive ball.", "There is some value k where all balls of value > k are sold, and some, (maybe 0) of balls of value k are sold.", "Use binary search to find this value k, and use maths to find the total sum."], "metadata": {"canonical_parameter_names": ["inventory", "orders"], "leetcode_dataset_entry_point": "Solution().maxProfit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:23+00:00", "tests_total": 88, "tests_dropped": 5, "flags": ["has_images"], "topic_tags": ["array", "math", "binary-search", "greedy", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def maxProfit(self, inventory: list[int], orders: int) -> int:", "container": "Solution", "callable": "maxProfit", "parameters": [{"name": "inventory", "type": "list[int]"}, {"name": "orders", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1649, "task_id": "create-sorted-array-through-instructions", "difficulty": "Hard", "problem_description": "Given an integer array instructions, you are asked to create a sorted array from the elements in instructions. You start with an empty container nums. For each element from left to right in instructions, insert it into nums. The cost of each insertion is the minimum of the following:\n\n- The number of elements currently in nums that are strictly less than instructions[i].\n- The number of elements currently in nums that are strictly greater than instructions[i].\n\nFor example, if inserting element 3 into nums = [1,2,3,5], the cost of insertion is min(2, 1) (elements 1 and 2 are less than 3, element 5 is greater than 3) and nums will become [1,2,3,3,5].\n\nReturn the total cost to insert all elements from instructions into nums. Since the answer may be large, return it modulo 10^9 + 7\n\nExample 1:\n\nInput: instructions = [1,5,6,2]\nOutput: 1\nExplanation: Begin with nums = [].\nInsert 1 with cost min(0, 0) = 0, now nums = [1].\nInsert 5 with cost min(1, 0) = 0, now nums = [1,5].\nInsert 6 with cost min(2, 0) = 0, now nums = [1,5,6].\nInsert 2 with cost min(1, 2) = 1, now nums = [1,2,5,6].\nThe total cost is 0 + 0 + 0 + 1 = 1.\n\nExample 2:\n\nInput: instructions = [1,2,3,6,5,4]\nOutput: 3\nExplanation: Begin with nums = [].\nInsert 1 with cost min(0, 0) = 0, now nums = [1].\nInsert 2 with cost min(1, 0) = 0, now nums = [1,2].\nInsert 3 with cost min(2, 0) = 0, now nums = [1,2,3].\nInsert 6 with cost min(3, 0) = 0, now nums = [1,2,3,6].\nInsert 5 with cost min(3, 1) = 1, now nums = [1,2,3,5,6].\nInsert 4 with cost min(3, 2) = 2, now nums = [1,2,3,4,5,6].\nThe total cost is 0 + 0 + 0 + 0 + 1 + 2 = 3.\n\nExample 3:\n\nInput: instructions = [1,3,3,3,2,4,2,1,2]\nOutput: 4\nExplanation: Begin with nums = [].\nInsert 1 with cost min(0, 0) = 0, now nums = [1].\nInsert 3 with cost min(1, 0) = 0, now nums = [1,3].\nInsert 3 with cost min(1, 0) = 0, now nums = [1,3,3].\nInsert 3 with cost min(1, 0) = 0, now nums = [1,3,3,3].\nInsert 2 with cost min(1, 3) = 1, now nums = [1,2,3,3,3].\nInsert 4 with cost min(5, 0) = 0, now nums = [1,2,3,3,3,4].\nInsert 2 with cost min(1, 4) = 1, now nums = [1,2,2,3,3,3,4].\nInsert 1 with cost min(0, 6) = 0, now nums = [1,1,2,2,3,3,3,4].\nInsert 2 with cost min(2, 4) = 2, now nums = [1,1,2,2,2,3,3,3,4].\nThe total cost is 0 + 0 + 0 + 0 + 1 + 0 + 1 + 0 + 2 = 4.\n\nConstraints:\n\n- 1 <= instructions.length <= 10^5\n- 1 <= instructions[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(instructions = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(instructions = [50000, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009]) == 0\n assert candidate(instructions = [1, 2, 3, 6, 5, 4]) == 3\n assert candidate(instructions = [1, 5, 6, 2]) == 1\n assert candidate(instructions = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 20\n assert candidate(instructions = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 20\n assert candidate(instructions = [1, 3, 3, 3, 2, 4, 2, 1, 2]) == 4\n assert candidate(instructions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(instructions = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(instructions = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9]) == 5\n assert candidate(instructions = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == 10\n assert candidate(instructions = [50000, 40000, 30000, 20000, 10000, 60000, 70000, 80000, 90000, 100000]) == 0\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 27\n assert candidate(instructions = [5, 3, 8, 6, 2, 7, 4, 1, 10, 9]) == 5\n assert candidate(instructions = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 10\n assert candidate(instructions = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 32\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 75\n assert candidate(instructions = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 4\n assert candidate(instructions = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 0\n assert candidate(instructions = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 27\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 75\n assert candidate(instructions = [9, 3, 8, 3, 7, 3, 6, 3, 5, 3, 4, 3, 2, 3, 1, 3]) == 18\n assert candidate(instructions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 24\n assert candidate(instructions = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 75\n assert candidate(instructions = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(instructions = [1, 2, 3, 6, 5, 4, 1, 2, 3, 6, 5, 4]) == 14\n assert candidate(instructions = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15]) == 10\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 75\n assert candidate(instructions = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 30\n assert candidate(instructions = [5, 4, 3, 2, 1]) == 0\n assert candidate(instructions = [1, 3, 2, 6, 5, 4, 9, 8, 7, 10, 1, 3, 2, 6, 5, 4, 9, 8, 7, 10, 1, 3, 2, 6, 5, 4, 9, 8, 7, 10]) == 88\n assert candidate(instructions = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 0\n assert candidate(instructions = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 60\n assert candidate(instructions = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10]) == 16\n assert candidate(instructions = [10, 20, 30, 40, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == 22\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 75\n assert candidate(instructions = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 27\n assert candidate(instructions = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 0\n assert candidate(instructions = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(instructions = [100000, 99999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 33\n assert candidate(instructions = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 27\n assert candidate(instructions = [50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 14\n assert candidate(instructions = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 36\n assert candidate(instructions = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993]) == 56\n assert candidate(instructions = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1]) == 0\n assert candidate(instructions = [10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9]) == 0\n assert candidate(instructions = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(instructions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 0\n assert candidate(instructions = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 20\n assert candidate(instructions = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 10\n assert candidate(instructions = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == 60\n assert candidate(instructions = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16]) == 25\n assert candidate(instructions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\n assert candidate(instructions = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(instructions = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n assert candidate(instructions = [1, 3, 2, 4, 2, 3, 1, 4, 2, 3]) == 7\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 0\n assert candidate(instructions = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 75\n assert candidate(instructions = [3, 1, 2, 5, 4, 6, 9, 7, 10, 8]) == 5\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 30\n assert candidate(instructions = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 0\n assert candidate(instructions = [50000, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009, 50000, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009]) == 27\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 30\n assert candidate(instructions = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 45\n assert candidate(instructions = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 27\n assert candidate(instructions = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 0\n assert candidate(instructions = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 317\n assert candidate(instructions = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(instructions = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9]) == 9\n assert candidate(instructions = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 0\n assert candidate(instructions = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 27\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(instructions = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 21\n assert candidate(instructions = [100000, 50000, 75000, 25000, 62500, 37500, 87500, 12500, 93750, 43750, 68750, 31250, 81250, 18750, 90625, 46875, 71875, 28125, 89062, 40625, 65625, 34375, 84375, 21875, 82812, 45312, 70312, 29687, 88281, 49218, 74218, 32187, 86171, 42187, 67187, 35156, 83125, 23437, 85937, 50312, 75312, 37812, 81562, 44531, 69531, 33437, 87968, 47968, 72968, 30937, 90468, 52968, 77968, 38906, 85468, 55468, 80468, 43437, 92460, 57460, 82460, 47460, 91718, 61718, 86718, 52656, 94359, 66359, 91359, 57359, 93671, 69671, 94671, 73671, 86913, 64406, 93406, 68406, 92406, 65406, 95507, 70507, 90507, 67507, 92753, 75253, 87753, 62753, 94753, 78753, 83753, 71753, 88281, 53281, 88281, 58281, 83281, 50281, 81281, 45281, 86281, 51281, 82281, 46281, 84281, 48281, 85281, 50281, 87281, 52281, 89281, 54281, 90281, 56281, 91281, 58281, 92281, 60281, 93281, 62281, 94281, 64281, 95281, 66281, 96281, 68281, 97281, 70281, 98281, 72281, 99281, 74281, 100000]) == 2291\n assert candidate(instructions = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 65\n assert candidate(instructions = [5, 1, 4, 2, 3, 8, 6, 7, 10, 9, 5, 5, 5, 5, 5]) == 27\n assert candidate(instructions = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 0\n assert candidate(instructions = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 27\n assert candidate(instructions = [7, 7, 7, 7, 7, 7, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 27\n assert candidate(instructions = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 84\n assert candidate(instructions = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 15\n assert candidate(instructions = [2, 3, 1, 4, 5, 1, 3, 2, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 27\n assert candidate(instructions = [100000, 100000, 100000, 1, 1, 1, 50000, 50000, 50000, 25000]) == 12\n assert candidate(instructions = [1, 2, 3, 4, 5, 100000, 99999, 99998, 99997, 99996]) == 10\n assert candidate(instructions = [5, 4, 3, 2, 1, 100000, 99999, 99998, 99997, 99996]) == 10\n assert candidate(instructions = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 0\n assert candidate(instructions = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9, 1000, 10]) == 45\n assert candidate(instructions = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 27\n assert candidate(instructions = [50000, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009]) == 0\n assert candidate(instructions = [5, 3, 1, 2, 4, 6, 8, 7, 10, 9]) == 4\n assert candidate(instructions = [100, 200, 300, 400, 500, 500, 400, 300, 200, 100]) == 5\n assert candidate(instructions = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 95000, 92500, 90000, 87500, 85000, 82500, 80000, 77500, 75000, 72500]) == 52\n assert candidate(instructions = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 1]) == 0\n assert candidate(instructions = [5, 1, 9, 2, 8, 3, 7, 4, 6, 10]) == 12\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 32\n", "comparison": "exact"}, "public_tests": ["[1,5,6,2]", "[1,2,3,6,5,4]", "[1,3,3,3,2,4,2,1,2]"], "hints": ["This problem is closely related to finding the number of inversions in an array", "if i know the position in which i will insert the i-th element in I can find the minimum cost to insert it"], "metadata": {"canonical_parameter_names": ["instructions"], "leetcode_dataset_entry_point": "Solution().createSortedArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:26+00:00", "tests_total": 113, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "binary-search", "divide-and-conquer", "binary-indexed-tree", "segment-tree", "merge-sort", "ordered-set"]}, "language": "python", "interface": {"raw_signature": "def createSortedArray(self, instructions: List[int]) -> int:", "container": "Solution", "callable": "createSortedArray", "parameters": [{"name": "instructions", "type": "List[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1652, "task_id": "defuse-the-bomb", "difficulty": "Easy", "problem_description": "You have a bomb to defuse, and your time is running out! Your informer will provide you with a circular array code of length of n and a key k.\n\nTo decrypt the code, you must replace every number. All the numbers are replaced simultaneously.\n\n- If k > 0, replace the i^th number with the sum of the next k numbers.\n- If k < 0, replace the i^th number with the sum of the previous -k numbers.\n- If k == 0, replace the i^th number with 0.\n\nAs code is circular, the next element of code[n-1] is code[0], and the previous element of code[0] is code[n-1].\n\nGiven the circular array code and an integer key k, return the decrypted code to defuse the bomb!\n\nExample 1:\n\nInput: code = [5,7,1,4], k = 3\nOutput: [12,10,16,13]\nExplanation: Each number is replaced by the sum of the next 3 numbers. The decrypted code is [7+1+4, 1+4+5, 4+5+7, 5+7+1]. Notice that the numbers wrap around.\n\nExample 2:\n\nInput: code = [1,2,3,4], k = 0\nOutput: [0,0,0,0]\nExplanation: When k is zero, the numbers are replaced by 0.\n\nExample 3:\n\nInput: code = [2,4,9,3], k = -2\nOutput: [12,5,6,13]\nExplanation: The decrypted code is [3+9, 2+3, 4+2, 9+4]. Notice that the numbers wrap around again. If k is negative, the sum is of the previous numbers.\n\nConstraints:\n\n- n == code.length\n- 1 <= n <= 100\n- 1 <= code[i] <= 100\n- -(n - 1) <= k <= n - 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(code = [7, 8, 9],k = 1) == [8, 9, 7]\n assert candidate(code = [6, 5, 4, 3, 2, 1],k = -1) == [1, 6, 5, 4, 3, 2]\n assert candidate(code = [1, 1, 1, 1, 1],k = -1) == [1, 1, 1, 1, 1]\n assert candidate(code = [5, 7, 1, 4],k = 3) == [12, 10, 16, 13]\n assert candidate(code = [8, 6, 4, 2],k = -3) == [12, 14, 16, 18]\n assert candidate(code = [6, 5, 4, 3, 2, 1],k = -3) == [6, 9, 12, 15, 12, 9]\n assert candidate(code = [2, 4, 9, 3],k = -2) == [12, 5, 6, 13]\n assert candidate(code = [10, 20, 30, 40, 50],k = -1) == [50, 10, 20, 30, 40]\n assert candidate(code = [3, 3, 3, 3],k = 1) == [3, 3, 3, 3]\n assert candidate(code = [5, 5, 5, 5, 5],k = -1) == [5, 5, 5, 5, 5]\n assert candidate(code = [10, 20, 30, 40, 50],k = 2) == [50, 70, 90, 60, 30]\n assert candidate(code = [15, 20, 25],k = 0) == [0, 0, 0]\n assert candidate(code = [1, 2, 3, 4],k = 0) == [0, 0, 0, 0]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = -3) == [6, 12, 18, 24, 21, 18, 15, 12, 9]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = -5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(code = [3, 3, 3, 3],k = 0) == [0, 0, 0, 0]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = -20) == [410, 400, 390, 380, 370, 360, 350, 340, 330, 320, 310, 300, 290, 280, 270, 260, 250, 240, 230, 220, 210, 230, 250, 270, 290, 310, 330, 350, 370, 390]\n assert candidate(code = [7, 14, 21, 28, 35, 42],k = 3) == [63, 84, 105, 84, 63, 42]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = -4) == [170, 140, 110, 80, 50, 70, 90, 110, 130, 150]\n assert candidate(code = [50, 40, 30, 20, 10],k = -4) == [100, 110, 120, 130, 140]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == [20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 75, 60, 45, 30, 15]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = -18) == [396, 392, 388, 384, 380, 376, 372, 368, 364, 360, 356, 352, 348, 344, 340, 336, 332, 328, 324, 360]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == [14, 18, 22, 26, 30, 34, 28, 22, 16, 10]\n assert candidate(code = [7, 8, 9, 10, 11, 12, 13, 14, 15],k = -4) == [54, 49, 44, 39, 34, 38, 42, 46, 50]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == [5, 7, 9, 11, 13, 15, 17, 19, 11, 3]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == [450, 460, 470, 480, 490, 500, 510, 520, 530, 540]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 5) == [35, 45, 55, 65, 75, 85, 95, 81, 67, 53, 39, 25]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = -10) == [105, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 65, 75, 85, 95]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == [20, 25, 30, 35, 40, 35, 30, 25, 20, 15]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 3) == [45, 60, 75, 90, 105, 120, 135, 100, 65, 30]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = -5) == [80, 70, 60, 50, 40, 30, 40, 50, 60, 70]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26],k = -6) == [126, 112, 98, 84, 70, 56, 42, 54, 66, 78, 90, 102, 114]\n assert candidate(code = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9) == [540, 530, 520, 510, 500, 490, 480, 470, 460, 450]\n assert candidate(code = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4) == [140, 180, 220, 260, 300, 340, 280, 220, 160, 100]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == [240, 210, 180, 150, 120, 90, 60, 130, 200, 270]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = -5) == [150, 200, 250, 300, 350, 400, 350, 300, 250, 200]\n assert candidate(code = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 0) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = -2) == [3, 10, 17, 15, 13, 11, 9, 7, 5]\n assert candidate(code = [7, 14, 21, 28, 35],k = -4) == [98, 91, 84, 77, 70]\n assert candidate(code = [9, 18, 27, 36, 45, 54, 63, 72, 81],k = 6) == [243, 297, 351, 324, 297, 270, 243, 216, 189]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = -4) == [34, 28, 22, 16, 10, 14, 18, 22, 26, 30]\n assert candidate(code = [10, 20, 30, 40, 50],k = 2) == [50, 70, 90, 60, 30]\n assert candidate(code = [97, 98, 99, 100],k = -1) == [100, 97, 98, 99]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 19) == [1045, 1040, 1035, 1030, 1025, 1020, 1015, 1010, 1005, 1000, 995, 990, 985, 980, 975, 970, 965, 960, 955, 950]\n assert candidate(code = [10, 20, 30, 40, 50],k = 4) == [140, 130, 120, 110, 100]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19) == [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = -2) == [3, 10, 17, 15, 13, 11, 9, 7, 5]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5) == [350, 300, 250, 200, 150, 200, 250, 300, 350, 400]\n assert candidate(code = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = -4) == [102, 84, 66, 48, 30, 42, 54, 66, 78, 90]\n assert candidate(code = [10, 20, 30, 40, 50],k = -2) == [90, 60, 30, 50, 70]\n assert candidate(code = [26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12],k = -9) == [144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 189, 180, 171, 162, 153]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = -5) == [150, 200, 250, 300, 350, 400, 350, 300, 250, 200]\n assert candidate(code = [3, 6, 9, 12, 15, 18, 21, 24, 27],k = -4) == [90, 75, 60, 45, 30, 42, 54, 66, 78]\n assert candidate(code = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 7) == [75, 95, 119, 114, 106, 98, 88, 80, 70, 58]\n assert candidate(code = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75],k = -20) == [1690, 1695, 1700, 1705, 1710, 1715, 1720, 1725, 1730, 1735, 1740, 1745, 1750, 1755, 1760, 1765, 1770, 1775, 1780, 1785, 1790, 1770, 1750, 1730, 1710]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40],k = 7) == [175, 170, 165, 160, 155, 150, 145, 140]\n assert candidate(code = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 8) == [124, 132, 140, 148, 156, 164, 172, 165, 158, 151, 144, 137, 130, 123, 116]\n assert candidate(code = [100, 100, 100, 100, 100, 100, 100, 100],k = 3) == [300, 300, 300, 300, 300, 300, 300, 300]\n assert candidate(code = [50, 40, 30, 20, 10],k = 0) == [0, 0, 0, 0, 0]\n assert candidate(code = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = -5) == [400, 350, 300, 250, 200, 150, 200, 250, 300, 350]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(code = [31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],k = -8) == [77, 89, 101, 111, 119, 129, 137, 145, 150, 124, 98]\n assert candidate(code = [23, 45, 12, 67, 34, 89, 23, 56, 78, 90, 12, 34, 56, 78, 90, 23, 45, 67, 89, 10],k = 10) == [506, 495, 539, 550, 606, 540, 562, 573, 584, 504, 515, 526, 482, 471, 415, 481, 459, 448, 437, 517]\n assert candidate(code = [11, 22, 33, 44, 55, 66],k = 0) == [0, 0, 0, 0, 0, 0]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13],k = 4) == [24, 32, 40, 34, 28, 22, 16]\n assert candidate(code = [30, 20, 10, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = -5) == [35, 60, 74, 77, 74, 66, 38, 21, 15, 15, 20, 25, 30]\n assert candidate(code = [9, 1, 2, 3, 4, 5, 6, 7, 8, 10],k = 4) == [10, 14, 18, 22, 26, 31, 34, 28, 22, 15]\n assert candidate(code = [3, 6, 9, 12, 15, 18, 21],k = -2) == [39, 24, 9, 15, 21, 27, 33]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40],k = -4) == [130, 110, 90, 70, 50, 70, 90, 110]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == [26, 22, 18, 14, 10, 15, 20, 25, 30]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 19) == [418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40],k = 5) == [100, 125, 150, 135, 120, 105, 90, 75]\n assert candidate(code = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [200, 250, 300, 350, 400, 350, 300, 250, 200, 150]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 9) == [99, 117, 135, 153, 171, 189, 207, 225, 243, 261, 279, 257, 235, 213, 191, 169, 147, 125, 103, 81]\n assert candidate(code = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = -7) == [455, 425, 395, 365, 335, 305, 275, 245, 315, 385]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == [36, 37, 38, 39, 40, 41, 42, 43, 44]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = -15) == [390, 380, 370, 360, 350, 340, 330, 320, 310, 300, 290, 280, 270, 260, 250, 240, 270, 300, 330, 360]\n assert candidate(code = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == [20, 21, 23, 27, 25, 21, 22, 17, 16, 14, 14]\n assert candidate(code = [50, 40, 30, 20, 10],k = -2) == [30, 60, 90, 70, 50]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40],k = 0) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(code = [7, 14, 21, 28, 35, 42, 49],k = -3) == [126, 98, 70, 42, 63, 84, 105]\n assert candidate(code = [7, 14, 21, 28, 35, 42],k = -5) == [140, 133, 126, 119, 112, 105]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 6) == [48, 60, 72, 84, 96, 108, 96, 84, 72, 60, 48, 36]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == [15, 13, 11, 9, 7, 5, 3, 10, 17]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22],k = 7) == [70, 84, 98, 112, 104, 96, 88, 80, 72, 64, 56]\n assert candidate(code = [10, 20, 30, 40, 50, 60],k = 2) == [50, 70, 90, 110, 70, 30]\n assert candidate(code = [23, 45, 12, 67, 34, 89, 23, 56, 78, 90, 12, 34, 56, 78, 90, 23, 45, 67, 89, 10],k = -10) == [504, 515, 526, 482, 471, 415, 481, 459, 448, 437, 517, 506, 495, 539, 550, 606, 540, 562, 573, 584]\n assert candidate(code = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 5) == [485, 480, 475, 470, 465, 470, 475, 480, 485, 490]\n assert candidate(code = [7, 14, 21, 28, 35, 42, 49],k = 3) == [63, 84, 105, 126, 98, 70, 42]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = -5) == [95, 81, 67, 53, 39, 25, 35, 45, 55, 65, 75, 85]\n assert candidate(code = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = -8) == [64, 70, 76, 82, 88, 94, 100, 106, 112, 96, 80]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 7) == [63, 77, 91, 105, 97, 89, 81, 73, 65, 57, 49]\n assert candidate(code = [23, 17, 15, 9, 2],k = 1) == [17, 15, 9, 2, 23]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(code = [3, 6, 9, 12, 15, 18, 21, 24],k = -2) == [45, 27, 9, 15, 21, 27, 33, 39]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = -19) == [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = -4) == [10, 15, 20, 25, 30, 26, 22, 18, 14]\n", "comparison": "exact"}, "public_tests": ["[5,7,1,4]\n3", "[1,2,3,4]\n0", "[2,4,9,3]\n-2"], "hints": ["As the array is circular, use modulo to find the correct index.", "The constraints are low enough for a brute-force solution."], "metadata": {"canonical_parameter_names": ["code", "k"], "leetcode_dataset_entry_point": "Solution().decrypt", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:28+00:00", "tests_total": 119, "tests_dropped": 19, "flags": [], "topic_tags": ["array", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def decrypt(self, code: list[int], k: int) -> list[int]:", "container": "Solution", "callable": "decrypt", "parameters": [{"name": "code", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1653, "task_id": "minimum-deletions-to-make-string-balanced", "difficulty": "Medium", "problem_description": "You are given a string s consisting only of characters 'a' and 'b'.\n\nYou can delete any number of characters in s to make s balanced. s is balanced if there is no pair of indices (i,j) such that i < j and s[i] = 'b' and s[j]= 'a'.\n\nReturn the minimum number of deletions needed to make s balanced.\n\nExample 1:\n\nInput: s = \"aababbab\"\nOutput: 2\nExplanation: You can either:\nDelete the characters at 0-indexed positions 2 and 6 (\"aababbab\" -> \"aaabbb\"), or\nDelete the characters at 0-indexed positions 3 and 6 (\"aababbab\" -> \"aabbbb\").\n\nExample 2:\n\nInput: s = \"bbaaaaabb\"\nOutput: 2\nExplanation: The only solution is to delete the first two characters.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s[i] is 'a' or 'b'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaaaaabbbb\") == 0\n assert candidate(s = \"bbbaaaaa\") == 3\n assert candidate(s = \"bbbaaaaabbbb\") == 3\n assert candidate(s = \"aabbaa\") == 2\n assert candidate(s = \"abababab\") == 3\n assert candidate(s = \"aaaaa\") == 0\n assert candidate(s = \"aabbaabb\") == 2\n assert candidate(s = \"aababbaa\") == 3\n assert candidate(s = \"baabbaab\") == 3\n assert candidate(s = \"abababa\") == 3\n assert candidate(s = \"aabbaaab\") == 2\n assert candidate(s = \"aabbbbbaa\") == 2\n assert candidate(s = \"bbaabb\") == 2\n assert candidate(s = \"babababababababab\") == 8\n assert candidate(s = \"bbbbb\") == 0\n assert candidate(s = \"bababab\") == 3\n assert candidate(s = \"aababbab\") == 2\n assert candidate(s = \"ababababa\") == 4\n assert candidate(s = \"baabbaabba\") == 4\n assert candidate(s = \"bbaaaaabb\") == 2\n assert candidate(s = \"bbbbaaaa\") == 4\n assert candidate(s = \"aabbaaabbbaaabbb\") == 5\n assert candidate(s = \"baababababa\") == 5\n assert candidate(s = \"aaaa\") == 0\n assert candidate(s = \"bbbb\") == 0\n assert candidate(s = \"bbaabbaabbaa\") == 6\n assert candidate(s = \"aabbaaabbbaa\") == 4\n assert candidate(s = \"baba\") == 2\n assert candidate(s = \"abbaaabbbbba\") == 3\n assert candidate(s = \"aabbabba\") == 2\n assert candidate(s = \"bbbbbaaaaa\") == 5\n assert candidate(s = \"bbabbaab\") == 3\n assert candidate(s = \"aaabbbba\") == 1\n assert candidate(s = \"aaaaaaaa\") == 0\n assert candidate(s = \"bbbbbbbb\") == 0\n assert candidate(s = \"baabaa\") == 2\n assert candidate(s = \"bbbbbaaaaaabbbbaaaaabbbbbbaaaabbbaaaaabbbb\") == 18\n assert candidate(s = \"aaaaaaaaaabbbaaabbbbaaaaaaaaa\") == 7\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbb\") == 0\n assert candidate(s = \"aaaaabbbbaaaaabbbb\") == 4\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababababababab\") == 53\n assert candidate(s = \"babababababababa\") == 8\n assert candidate(s = \"abbbbbaaaabbbab\") == 5\n assert candidate(s = \"abbbabbaabbbaabaaabababbbaaabbbaaaabbbabbbaaabbabbaabbaabaabbabbaabbabbaabbbaabb\") == 36\n assert candidate(s = \"abbbbbaaaabbbb\") == 4\n assert candidate(s = \"abababababababa\") == 7\n assert candidate(s = \"bbbbaaaaabbbbbbbba\") == 5\n assert candidate(s = \"aaaaaaaaaabbbabb\") == 1\n assert candidate(s = \"bababababababababab\") == 9\n assert candidate(s = \"ababababaababababa\") == 8\n assert candidate(s = \"baabbabababaabbabababaabbabababaabb\") == 16\n assert candidate(s = \"bbbbbbaaaaaa\") == 6\n assert candidate(s = \"bbbbbbaaaaaabbbb\") == 6\n assert candidate(s = \"aaaabbbaaaaabbbb\") == 3\n assert candidate(s = \"aaaaabbbbbbbbbaaaa\") == 4\n assert candidate(s = \"abbaabbaabbaabbaabbaabba\") == 11\n assert candidate(s = \"baabbaabbaabbaabba\") == 8\n assert candidate(s = \"baaaabbbbaaabbbbaaaaabbbbbaaaaaabbbbbbaaaaabbbbbaaaaaabbbbbbaaaaabbbbbaaaaaabbbbbbaaaaabbbbbaaaaaabbbbbbaaaaabbbbbaaaaaabbbbbbaaaaabb\") == 63\n assert candidate(s = \"baaabbaaabbaabab\") == 6\n assert candidate(s = \"abababababababababababababababababababababababababababababababab\") == 31\n assert candidate(s = \"abbbabbbabbbabbbabbbabbbabbbabbbab\") == 8\n assert candidate(s = \"baaaababababbbabba\") == 6\n assert candidate(s = \"abbbabaaaababbbaaaabbaaababbabaaaabbabaaaaabaa\") == 18\n assert candidate(s = \"bbbbbaaaaabbbbbaaaa\") == 9\n assert candidate(s = \"abababababbababb\") == 6\n assert candidate(s = \"bababababababababababababababababababa\") == 19\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbbb\") == 0\n assert candidate(s = \"bbbbabbaaababbaaababbaaababbaaababbaaab\") == 18\n assert candidate(s = \"bbbbbbbbbaaaaaaaaa\") == 9\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbbbaaaaaaabbbbaaaaaaa\") == 14\n assert candidate(s = \"aaaaaabbbbbbaaaaaaabbbbbaaaaabbbbb\") == 11\n assert candidate(s = \"aaabbaabbaabbaabbaabbaabbaabbaabbaa\") == 16\n assert candidate(s = \"baaaaaabbbbbbb\") == 1\n assert candidate(s = \"bbbbbaaaabbbbaaabbbbaa\") == 9\n assert candidate(s = \"aabbbbaaaabbbbbb\") == 4\n assert candidate(s = \"aababbabbaababba\") == 6\n assert candidate(s = \"bbaabbabbaabbabbaa\") == 8\n assert candidate(s = \"abababbababababa\") == 7\n assert candidate(s = \"aabbaaababababba\") == 6\n assert candidate(s = \"aabbaabbaabbaabb\") == 6\n assert candidate(s = \"aaaaaabbbbbbaaabbb\") == 3\n assert candidate(s = \"bbbbbaaaaaabbbbbbaaaaaaabbbbbbbaaaaaaaaa\") == 18\n assert candidate(s = \"bbbaaabbaaabbaabbaaabbaaabbaabbaabbaa\") == 17\n assert candidate(s = \"bbaababbabababbababaababababababaababababababaababababababaababababababaababababababaabababaabababa\") == 47\n assert candidate(s = \"bbaaaaabaaaaabaaaaabaaaaabaaaaabaaaa\") == 7\n assert candidate(s = \"aabbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaa\") == 25\n assert candidate(s = \"abbaabbaabbaabba\") == 7\n assert candidate(s = \"bbbbbbbaaaabbbbbbbaa\") == 6\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbaabbbbaaaaaaaaa\") == 11\n assert candidate(s = \"bbabbababbaaab\") == 6\n assert candidate(s = \"bababababa\") == 5\n assert candidate(s = \"ababababababab\") == 6\n assert candidate(s = \"aabbbabbbabbbabbbabba\") == 5\n assert candidate(s = \"abababababab\") == 5\n assert candidate(s = \"ababababababababab\") == 8\n assert candidate(s = \"bbbbbaaaaabbbbb\") == 5\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaa\") == 17\n assert candidate(s = \"aaaaaaaaaabbbbbb\") == 0\n assert candidate(s = \"baaaaaaaaaaaaaaaaaab\") == 1\n assert candidate(s = \"bbbbaaaabaaaab\") == 5\n assert candidate(s = \"baaaaaabbbbb\") == 1\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 21\n assert candidate(s = \"bbbbbbbbbaaaaaa\") == 6\n assert candidate(s = \"aaaaaaaaabbbbbbbbbbbaa\") == 2\n assert candidate(s = \"bbbbbaaaaabbaaab\") == 7\n assert candidate(s = \"abbaababbaababbaababbaababbaababbaabab\") == 18\n assert candidate(s = \"aaaaaabbbbbbaaaaaabbbbbbaaaaaabbbbbb\") == 12\n assert candidate(s = \"bbbbaaaabbbbba\") == 5\n assert candidate(s = \"bbbbbbbbbaaaabbb\") == 4\n assert candidate(s = \"baababababaabbaa\") == 7\n assert candidate(s = \"aaaaaaaaaabbbbba\") == 1\n assert candidate(s = \"aabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbb\") == 14\n assert candidate(s = \"abababababababababab\") == 9\n assert candidate(s = \"aaaaabbbbaaaaabbbbbaaa\") == 7\n assert candidate(s = \"aaaaaaaaaabbbaaaaaaaaa\") == 3\n assert candidate(s = \"aababababababababa\") == 8\n assert candidate(s = \"bababababababa\") == 7\n assert candidate(s = \"babbaabbbaabbaabbbaabbaabbbaabbaabba\") == 16\n assert candidate(s = \"aaabbaabbaabbbbb\") == 4\n assert candidate(s = \"aabbaaabbbabbaaabb\") == 6\n assert candidate(s = \"bbbbbbbbbaaaaaaaaaaa\") == 9\n assert candidate(s = \"aaabbbbaaaaabba\") == 5\n assert candidate(s = \"baaaaaabbaaabbbaaa\") == 6\n assert candidate(s = \"bbbaaaaabbbaaaa\") == 6\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbb\") == 0\n assert candidate(s = \"aabbaabbbaaabb\") == 5\n assert candidate(s = \"babababababababababa\") == 10\n assert candidate(s = \"bababababababababababababababab\") == 15\n assert candidate(s = \"baaababbababab\") == 5\n assert candidate(s = \"baabababababababababab\") == 10\n assert candidate(s = \"bbbbbbbbbaaaaaaaaaa\") == 9\n assert candidate(s = \"bbbbbbbbbaaaaa\") == 5\n assert candidate(s = \"bbbbbbbbbbbbbaaaaaaaaa\") == 9\n assert candidate(s = \"baaaaaabbbbbbbaaaaaaaaaabbbbbbbaaaaaaaaaaabbbbbbbaaaaaaaaaaabbbbbbbaaaaaaaaaa\") == 29\n assert candidate(s = \"baaaaaabbbbbbbbba\") == 2\n assert candidate(s = \"abbaabbaabbaabbaab\") == 8\n assert candidate(s = \"babbabbabbabbabbabba\") == 7\n assert candidate(s = \"aababababababababababababababababababababababa\") == 22\n assert candidate(s = \"bbbbbaaaaabbbb\") == 5\n assert candidate(s = \"baabababaabababa\") == 7\n assert candidate(s = \"aaaaabbbbbabbbbb\") == 1\n assert candidate(s = \"babababababababaab\") == 8\n assert candidate(s = \"bbbbbbbbbaaaaaaabbbbbbbbbaaaaaaa\") == 14\n assert candidate(s = \"aaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 0\n assert candidate(s = \"bbbbaaaaabbaaabb\") == 6\n assert candidate(s = \"aaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaa\") == 36\n assert candidate(s = \"bbbbbbaaabaaabbaab\") == 8\n assert candidate(s = \"aabbaabbbaabba\") == 5\n assert candidate(s = \"abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\") == 46\n assert candidate(s = \"abbaabbaabba\") == 5\n assert candidate(s = \"baaabbbbaaabbbbaaabbbbaaabbbbaaabbb\") == 13\n assert candidate(s = \"aaaaaaaaaabbbbbbaa\") == 2\n assert candidate(s = \"aabbaaabbaabbaa\") == 6\n assert candidate(s = \"ababbababbabab\") == 5\n assert candidate(s = \"bbbbbaaabbaabb\") == 5\n assert candidate(s = \"abababababababababa\") == 9\n assert candidate(s = \"babbbbbaaabbbbaabb\") == 6\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaa\") == 20\n assert candidate(s = \"abbbbaaababaaaabbaaabaaabbaaaabbbaaabbaaaabbaaabbaaabbbbaaaaa\") == 24\n assert candidate(s = \"bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbaaaaaaaaa\") == 26\n assert candidate(s = \"bbaaabbaaabbaaabbaaabbaaabbaaabbaaab\") == 14\n assert candidate(s = \"aaabbbaaababba\") == 5\n assert candidate(s = \"ababababab\") == 4\n assert candidate(s = \"aaaaabbbbaaaabbbba\") == 5\n assert candidate(s = \"bbbbaaaaabbaaaab\") == 6\n assert candidate(s = \"aabbaaabbaaabbaaabbaa\") == 8\n assert candidate(s = \"bbbbbbaaabbbbaaaa\") == 7\n assert candidate(s = \"bbbbbaaaaaaaaaaa\") == 5\n assert candidate(s = \"baabaaabbaabaaabbaabaa\") == 8\n assert candidate(s = \"aabbbbbbaabbaaaabb\") == 6\n assert candidate(s = \"aababbbaaababbab\") == 6\n assert candidate(s = \"bbbbabbbbbaaaaa\") == 6\n assert candidate(s = \"bbaaaaaaaaaabbbbaaaabbbba\") == 7\n assert candidate(s = \"aabbaabbabbaabbabbbaaabbaa\") == 11\n assert candidate(s = \"aaaaaaaaaabbbaaa\") == 3\n assert candidate(s = \"aaaaaaaaaabbbaaaabbbbbaaabbbbaaabbbbbaaa\") == 12\n assert candidate(s = \"babababaabab\") == 5\n assert candidate(s = \"bbbbbbbbbaaaaabbbb\") == 5\n assert candidate(s = \"aabbaaabbbaaabbbaaabbbaaabbaa\") == 13\n assert candidate(s = \"aaaabababababbbbba\") == 5\n assert candidate(s = \"aaabbaaabbaaabba\") == 5\n assert candidate(s = \"bbbbbbaaaaaabbbbaaa\") == 9\n assert candidate(s = \"bbbbbbbbaaaaabaaaaabbaaaabbaaaabbbaaaabbbbbbb\") == 16\n assert candidate(s = \"baaaaabbbbaaaaabba\") == 6\n assert candidate(s = \"abababaabababaab\") == 6\n assert candidate(s = \"bbbaaabbaaabbaab\") == 7\n assert candidate(s = \"aaaabaaaabaaaa\") == 2\n assert candidate(s = \"ababababababababababababababababababab\") == 18\n assert candidate(s = \"bbabbbbaaabbbbaaab\") == 7\n assert candidate(s = \"abbaabbaabbbaabb\") == 6\n", "comparison": "exact"}, "public_tests": ["\"aababbab\"", "\"bbaaaaabb\""], "hints": ["You need to find for every index the number of Bs before it and the number of A's after it", "You can speed up the finding of A's and B's in suffix and prefix using preprocessing"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumDeletions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:30+00:00", "tests_total": 190, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming", "stack"]}, "language": "python", "interface": {"raw_signature": "def minimumDeletions(self, s: str) -> int:", "container": "Solution", "callable": "minimumDeletions", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1654, "task_id": "minimum-jumps-to-reach-home", "difficulty": "Medium", "problem_description": "A certain bug's home is on the x-axis at position x. Help them get there from position 0.\n\nThe bug jumps according to the following rules:\n\n- It can jump exactly a positions forward (to the right).\n- It can jump exactly b positions backward (to the left).\n- It cannot jump backward twice in a row.\n- It cannot jump to any forbidden positions.\n\nThe bug may jump forward beyond its home, but it cannot jump to positions numbered with negative integers.\n\nGiven an array of integers forbidden, where forbidden[i] means that the bug cannot jump to the position forbidden[i], and integers a, b, and x, return the minimum number of jumps needed for the bug to reach its home. If there is no possible sequence of jumps that lands the bug on position x, return -1.\n\nExample 1:\n\nInput: forbidden = [14,4,18,1,15], a = 3, b = 15, x = 9\nOutput: 3\nExplanation: 3 jumps forward (0 -> 3 -> 6 -> 9) will get the bug home.\n\nExample 2:\n\nInput: forbidden = [8,3,16,6,12,20], a = 15, b = 13, x = 11\nOutput: -1\n\nExample 3:\n\nInput: forbidden = [1,6,2,14,5,17,4], a = 16, b = 9, x = 7\nOutput: 2\nExplanation: One jump forward (0 -> 16) then one jump backward (16 -> 7) will get the bug home.\n\nConstraints:\n\n- 1 <= forbidden.length <= 1000\n- 1 <= a, b, forbidden[i] <= 2000\n- 0 <= x <= 2000\n- All the elements in forbidden are distinct.\n- Position x is not forbidden.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(forbidden = [2, 4, 6, 8, 10],a = 2,b = 1,x = 1) == -1\n assert candidate(forbidden = [5, 6, 7],a = 1,b = 1,x = 10) == -1\n assert candidate(forbidden = [1, 6, 2, 14, 5, 17, 4],a = 16,b = 9,x = 7) == 2\n assert candidate(forbidden = [8, 3, 16, 6, 12, 20],a = 15,b = 13,x = 11) == -1\n assert candidate(forbidden = [14, 4, 18, 1, 15],a = 3,b = 15,x = 9) == 3\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],a = 3,b = 5,x = 20) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],a = 1,b = 3,x = 50) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 1,b = 2,x = 25) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],a = 2,b = 4,x = 58) == 29\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200],a = 5,b = 10,x = 195) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],a = 2,b = 1,x = 51) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],a = 2,b = 4,x = 41) == -1\n assert candidate(forbidden = [200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000],a = 100,b = 50,x = 1950) == 21\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 3,x = 20) == 10\n assert candidate(forbidden = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900],a = 100,b = 200,x = 1999) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 20,x = 210) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 1,x = 21) == 12\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 1,b = 2,x = 21) == -1\n assert candidate(forbidden = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 50,x = 1000) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 5,x = 199) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],a = 2,b = 1,x = 28) == 14\n assert candidate(forbidden = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519],a = 100,b = 50,x = 600) == 9\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 5,x = 210) == -1\n assert candidate(forbidden = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],a = 25,b = 50,x = 600) == -1\n assert candidate(forbidden = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],a = 15,b = 25,x = 100) == -1\n assert candidate(forbidden = [1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990],a = 1,b = 2,x = 2000) == -1\n assert candidate(forbidden = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1500],a = 250,b = 125,x = 2000) == 11\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],a = 2,b = 4,x = 50) == 25\n assert candidate(forbidden = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],a = 5,b = 3,x = 20) == -1\n assert candidate(forbidden = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 50,x = 1001) == -1\n assert candidate(forbidden = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],a = 3,b = 6,x = 63) == -1\n assert candidate(forbidden = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],a = 10,b = 5,x = 195) == 21\n assert candidate(forbidden = [199, 399, 599, 799, 999, 1199, 1399, 1599, 1799, 1999],a = 200,b = 100,x = 1998) == -1\n assert candidate(forbidden = [500, 1000, 1500],a = 100,b = 50,x = 2000) == 23\n assert candidate(forbidden = [2000],a = 1000,b = 500,x = 1500) == 3\n assert candidate(forbidden = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],a = 10,b = 5,x = 200) == 20\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 2,b = 4,x = 30) == -1\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 1,b = 2,x = 25) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 4,x = 21) == -1\n assert candidate(forbidden = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130],a = 5,b = 3,x = 140) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],a = 5,b = 10,x = 135) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],a = 50,b = 100,x = 350) == -1\n assert candidate(forbidden = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 200,x = 1500) == -1\n assert candidate(forbidden = [5, 15, 25, 35, 45],a = 10,b = 5,x = 100) == 10\n assert candidate(forbidden = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90],a = 3,b = 9,x = 88) == -1\n assert candidate(forbidden = [100, 150, 200, 250, 300],a = 50,b = 20,x = 180) == 5\n assert candidate(forbidden = [101, 201, 301, 401, 501, 601, 701, 801, 901, 1001, 1101, 1201, 1301, 1401, 1501, 1601, 1701, 1801, 1901],a = 100,b = 50,x = 1899) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 5,x = 195) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 4,x = 20) == 10\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],a = 1,b = 2,x = 31) == -1\n assert candidate(forbidden = [150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, 1800, 1950],a = 150,b = 100,x = 1000) == -1\n assert candidate(forbidden = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597],a = 7,b = 5,x = 400) == 64\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 1,b = 3,x = 21) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],a = 20,b = 10,x = 199) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50],a = 5,b = 10,x = 15) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],a = 10,b = 20,x = 200) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 5,x = 210) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],a = 5,b = 10,x = 105) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 2,b = 1,x = 19) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],a = 5,b = 3,x = 48) == -1\n assert candidate(forbidden = [3, 6, 9, 12, 15, 18, 21, 24, 27],a = 3,b = 2,x = 30) == -1\n assert candidate(forbidden = [300, 600, 900, 1200, 1500, 1800, 2000],a = 100,b = 200,x = 1900) == -1\n assert candidate(forbidden = [150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, 1800, 1950],a = 150,b = 75,x = 1995) == -1\n assert candidate(forbidden = [199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180],a = 1,b = 2,x = 175) == 175\n assert candidate(forbidden = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],a = 10,b = 5,x = 199) == -1\n assert candidate(forbidden = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, 103, 107, 111, 115, 119, 123, 127, 131, 135, 139, 143, 147, 151, 155, 159, 163, 167, 171, 175, 179, 183, 187, 191, 195, 199],a = 4,b = 8,x = 197) == -1\n assert candidate(forbidden = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],a = 2,b = 3,x = 50) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],a = 5,b = 10,x = 150) == -1\n assert candidate(forbidden = [50, 100, 150, 200],a = 50,b = 25,x = 200) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],a = 10,b = 5,x = 145) == -1\n assert candidate(forbidden = [100, 200, 300, 400, 500],a = 100,b = 200,x = 600) == -1\n assert candidate(forbidden = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145, 160, 175, 190, 205, 220, 235, 250, 265, 280, 295],a = 15,b = 30,x = 290) == -1\n assert candidate(forbidden = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],a = 1,b = 1,x = 110) == -1\n assert candidate(forbidden = [10, 15, 20, 25, 30],a = 5,b = 10,x = 40) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],a = 5,b = 10,x = 55) == -1\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],a = 3,b = 1,x = 45) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],a = 2,b = 4,x = 62) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],a = 10,b = 5,x = 185) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],a = 2,b = 1,x = 39) == -1\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 1,b = 2,x = 21) == -1\n assert candidate(forbidden = [2, 5, 7, 10, 15, 20],a = 2,b = 4,x = 25) == -1\n assert candidate(forbidden = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119],a = 1,b = 1,x = 120) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90],a = 10,b = 5,x = 100) == -1\n assert candidate(forbidden = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],a = 10,b = 20,x = 105) == -1\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 1,b = 2,x = 30) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],a = 2,b = 3,x = 42) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],a = 10,b = 5,x = 195) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290],a = 10,b = 20,x = 299) == -1\n", "comparison": "exact"}, "public_tests": ["[14,4,18,1,15]\n3\n15\n9", "[8,3,16,6,12,20]\n15\n13\n11", "[1,6,2,14,5,17,4]\n16\n9\n7"], "hints": ["Think of the line as a graph", "to handle the no double back jumps condition you can handle it by holding the state of your previous jump"], "metadata": {"canonical_parameter_names": ["forbidden", "a", "b", "x"], "leetcode_dataset_entry_point": "Solution().minimumJumps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:32+00:00", "tests_total": 98, "tests_dropped": 10, "flags": [], "topic_tags": ["array", "hash-table", "breadth-first-search"]}, "language": "python", "interface": {"raw_signature": "def minimumJumps(self, forbidden: list[int], a: int, b: int, x: int) -> int:", "container": "Solution", "callable": "minimumJumps", "parameters": [{"name": "forbidden", "type": "list[int]"}, {"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "x", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1655, "task_id": "distribute-repeating-integers", "difficulty": "Hard", "problem_description": "You are given an array of n integers, nums, where there are at most 50 unique values in the array. You are also given an array of m customer order quantities, quantity, where quantity[i] is the amount of integers the i^th customer ordered. Determine if it is possible to distribute nums such that:\n\n- The i^th customer gets exactly quantity[i] integers,\n- The integers the i^th customer gets are all equal, and\n- Every customer is satisfied.\n\nReturn true if it is possible to distribute nums according to the above conditions.\n\nExample 1:\n\nInput: nums = [1,2,3,4], quantity = [2]\nOutput: false\nExplanation: The 0^th customer cannot be given two different integers.\n\nExample 2:\n\nInput: nums = [1,2,3,3], quantity = [2]\nOutput: true\nExplanation: The 0^th customer is given [3,3]. The integers [1,2] are not used.\n\nExample 3:\n\nInput: nums = [1,1,2,2], quantity = [2,2]\nOutput: true\nExplanation: The 0^th customer is given [1,1], and the 1st customer is given [2,2].\n\nConstraints:\n\n- n == nums.length\n- 1 <= n <= 10^5\n- 1 <= nums[i] <= 1000\n- m == quantity.length\n- 1 <= m <= 10\n- 1 <= quantity[i] <= 10^5\n- There are at most 50 unique values in nums.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 2, 2],quantity = [2, 2]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],quantity = [3, 3]) == True\n assert candidate(nums = [10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40, 50, 50, 50, 60, 60, 60, 70, 70, 70],quantity = [3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1],quantity = [5]) == True\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],quantity = [2, 2, 2, 2]) == True\n assert candidate(nums = [1, 2, 3, 4],quantity = [2]) == False\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4],quantity = [4, 4, 4]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],quantity = [2, 2, 2]) == True\n assert candidate(nums = [1, 2, 3, 3],quantity = [2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],quantity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50],quantity = [2, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4],quantity = [3, 3, 3, 4]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],quantity = [3, 3, 3]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],quantity = [2, 2, 3, 4, 5]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 3],quantity = [2, 3]) == True\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],quantity = [10]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [3, 3, 3, 4]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [2, 3, 3, 4, 4]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [10, 10, 10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6],quantity = [5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],quantity = [3, 3, 3, 5, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],quantity = [5, 7, 4]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],quantity = [7, 7, 7, 7]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [10, 10, 10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],quantity = [2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20],quantity = [10, 10, 10]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],quantity = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [3, 4, 5, 3]) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],quantity = [4, 6, 6, 8]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],quantity = [3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [5, 5, 5, 10, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],quantity = [2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],quantity = [4, 4, 4, 4]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [15, 15, 15, 15]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10],quantity = [6, 6, 6, 6, 6]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [10, 10, 10, 10, 10]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6],quantity = [5, 5, 6]) == True\n assert candidate(nums = [7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10],quantity = [3, 3, 4, 4]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5, 10]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],quantity = [3, 4, 5, 6]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],quantity = [10, 10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],quantity = [10, 10, 10]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5]) == False\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [10, 10, 10, 10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [7, 7, 7, 5]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],quantity = [5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6],quantity = [2, 2, 3, 3, 3]) == True\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],quantity = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6],quantity = [2, 2, 3, 3, 4]) == True\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50],quantity = [2, 4, 6]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5],quantity = [3, 5, 4]) == True\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]\n[2]", "[1,2,3,3]\n[2]", "[1,1,2,2]\n[2,2]"], "hints": ["Count the frequencies of each number. For example, if nums = [4,4,5,5,5], frequencies = [2,3].", "Each customer wants all of their numbers to be the same. This means that each customer will be assigned to one number.", "Use dynamic programming. Iterate through the numbers' frequencies, and choose some subset of customers to be assigned to this number."], "metadata": {"canonical_parameter_names": ["nums", "quantity"], "leetcode_dataset_entry_point": "Solution().canDistribute", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:35+00:00", "tests_total": 62, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "dynamic-programming", "backtracking", "bit-manipulation", "counting", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def canDistribute(self, nums: list[int], quantity: list[int]) -> bool:", "container": "Solution", "callable": "canDistribute", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "quantity", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1657, "task_id": "determine-if-two-strings-are-close", "difficulty": "Medium", "problem_description": "Two strings are considered close if you can attain one from the other using the following operations:\n\n- Operation 1: Swap any two existing characters.\n - For example, abcde -> aecdb\n- Operation 2: Transform every occurrence of one existing character into another existing character, and do the same with the other character.\n - For example, aacabb -> bbcbaa (all a's turn into b's, and all b's turn into a's)\n\nYou can use the operations on either string as many times as necessary.\n\nGiven two strings, word1 and word2, return true if word1 and word2 are close, and false otherwise.\n\nExample 1:\n\nInput: word1 = \"abc\", word2 = \"bca\"\nOutput: true\nExplanation: You can attain word2 from word1 in 2 operations.\nApply Operation 1: \"abc\" -> \"acb\"\nApply Operation 1: \"acb\" -> \"bca\"\n\nExample 2:\n\nInput: word1 = \"a\", word2 = \"aa\"\nOutput: false\nExplanation: It is impossible to attain word2 from word1, or vice versa, in any number of operations.\n\nExample 3:\n\nInput: word1 = \"cabbba\", word2 = \"abbccc\"\nOutput: true\nExplanation: You can attain word2 from word1 in 3 operations.\nApply Operation 1: \"cabbba\" -> \"caabbb\"\nApply Operation 2: \"caabbb\" -> \"baaccc\"\nApply Operation 2: \"baaccc\" -> \"abbccc\"\n\nConstraints:\n\n- 1 <= word1.length, word2.length <= 10^5\n- word1 and word2 contain only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"leetcode\",word2 = \"coeddlet\") == False\n assert candidate(word1 = \"aaa\",word2 = \"bbb\") == False\n assert candidate(word1 = \"aaabbbbccdddd\",word2 = \"bbbbaacdddd\") == False\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"ccbbaa\") == True\n assert candidate(word1 = \"abc\",word2 = \"bca\") == True\n assert candidate(word1 = \"abcabcabc\",word2 = \"bcbcbcbcb\") == False\n assert candidate(word1 = \"abcde\",word2 = \"edcba\") == True\n assert candidate(word1 = \"cabbba\",word2 = \"abbccc\") == True\n assert candidate(word1 = \"xyzz\",word2 = \"zzxy\") == True\n assert candidate(word1 = \"xyz\",word2 = \"zyx\") == True\n assert candidate(word1 = \"abcd\",word2 = \"abce\") == False\n assert candidate(word1 = \"aaabbbbcc\",word2 = \"bbbcccaaa\") == False\n assert candidate(word1 = \"uau\",word2 = \"ssx\") == False\n assert candidate(word1 = \"aaabbbbccddd\",word2 = \"bbbccdddcccc\") == False\n assert candidate(word1 = \"aabbbbccc\",word2 = \"bbcccaaaa\") == True\n assert candidate(word1 = \"abab\",word2 = \"baba\") == True\n assert candidate(word1 = \"aaabbbbcc\",word2 = \"aaaabbbcc\") == True\n assert candidate(word1 = \"a\",word2 = \"aa\") == False\n assert candidate(word1 = \"aab\",word2 = \"bba\") == True\n assert candidate(word1 = \"abcd\",word2 = \"dcba\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\") == False\n assert candidate(word1 = \"aaaabbbbccccdddd\",word2 = \"ddddeeeeffffgggg\") == False\n assert candidate(word1 = \"aaabbcccddeeefffggghhhhiiiii\",word2 = \"iiiiihhhgggfffeeedddcccbbaaa\") == False\n assert candidate(word1 = \"xyzxyzxyz\",word2 = \"zyxzyxzyx\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"bbacabadabacaba\") == False\n assert candidate(word1 = \"aaabbcccddddeeeeeffffffgggggghhhhhiiiijjjjkkkkklllllmmmmnnooooppqqrrsstttuuuuuvvvvvvvwwxxxxxyyyyzzzzz\",word2 = \"zzzzzyyyyxxxwwwvvvvvvuuuuutttssrrqqppoonnmmllkkjjiihhhgggfffddddccccbbbbaaa\") == False\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"ffeeddccbbaa\") == True\n assert candidate(word1 = \"aaabbbcccdddeeefff\",word2 = \"ffeeeedddcccbbbaaa\") == False\n assert candidate(word1 = \"mississippi\",word2 = \"ppissimissi\") == True\n assert candidate(word1 = \"abcdabcabcabcd\",word2 = \"dcbaababdcbaabab\") == False\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"bacabacababacab\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxyywwvvuuttssrrqqppoonnmmllkkjjiihhggffeeeeddccbbaa\") == False\n assert candidate(word1 = \"ppppoooonnnnmmmlllkkeeeeeddcccbbbaaa\",word2 = \"aaaaaaaaabbbbbbccccdddddeeeeeeeekkkkkklllllmmmmmmmnnnnnnnnoooooooooppppppp\") == False\n assert candidate(word1 = \"qqqwwwweeerrrttt\",word2 = \"tttwwweerrrqqq\") == False\n assert candidate(word1 = \"abcabcabc\",word2 = \"ccbbbaaa\") == False\n assert candidate(word1 = \"qwertypoiuytrewq\",word2 = \"poiuytrewqqwertypo\") == False\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(word1 = \"abcdefabcdefabcdef\",word2 = \"fedcbafedcbafedcba\") == True\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcba\") == True\n assert candidate(word1 = \"abcdefgh\",word2 = \"hgfedcba\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"cbacbacbcacbacb\") == False\n assert candidate(word1 = \"abcdefg\",word2 = \"gfedcba\") == True\n assert candidate(word1 = \"loooooonnnngggggwwwoooorrrrddddsssaaammmmeeeerrttttyyyyyyyyyyyynnnnnnnnnn\",word2 = \"nnnnnnnnnnyyyyyyyyyyyttttyyyyymmmeeraatttddddsssaaawwwggggnnnllllloooooo\") == False\n assert candidate(word1 = \"xylophone\",word2 = \"phonexylo\") == True\n assert candidate(word1 = \"abcdefghijklopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(word1 = \"abcdefabcabc\",word2 = \"abcabcabcdef\") == True\n assert candidate(word1 = \"aaaaabbbbcccccccdddddddd\",word2 = \"ddddddddcccccccbbbbaaaaa\") == True\n assert candidate(word1 = \"mnopqr\",word2 = \"rpqomn\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"ppiimssisss\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttssrrqppoonnmlkkjjiihhggffeeeeddccbbaa\") == False\n assert candidate(word1 = \"anotherexample\",word2 = \"mpleaxarnothee\") == True\n assert candidate(word1 = \"aaaaabbbbbccccc\",word2 = \"bbbbbcccccaaaaa\") == True\n assert candidate(word1 = \"zzzzzzyyyxxx\",word2 = \"yyyxxxzzzzzy\") == False\n assert candidate(word1 = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"yzxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\") == False\n assert candidate(word1 = \"xyzxyzxyzxyzxyzxyzxyz\",word2 = \"zyxzyxzyxzyxzyxzyxzyxzyxzyx\") == False\n assert candidate(word1 = \"aabccddddeeeeefffffff\",word2 = \"eeeeeeffffffdddddcccbaaa\") == False\n assert candidate(word1 = \"mnopqr\",word2 = \"rstuvw\") == False\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == False\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"abcdeffedcba\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"abcdefghijklmnopqrstuvxyzmnopqrstuvwxyzabcdefg\") == False\n assert candidate(word1 = \"uniqueletters\",word2 = \"letterniquesu\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxyywwvvuuttssrrqqlloonnmmllkkjjiihhggeeddbbaa\") == False\n assert candidate(word1 = \"abcabcabcabcabcabcabcabcabcabc\",word2 = \"bcabacabcabacabcabacabcabacabcabac\") == False\n assert candidate(word1 = \"abcdefghijk\",word2 = \"abcdefghijl\") == False\n assert candidate(word1 = \"thisisatest\",word2 = \"esttasisthi\") == True\n assert candidate(word1 = \"qqwweerrttyyuuiiooppllaaassddffgg\",word2 = \"ggffddssaallooppuiiyyttreeewwqq\") == False\n assert candidate(word1 = \"abacabadaba\",word2 = \"dabacababad\") == False\n assert candidate(word1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",word2 = \"oconsinolpnacirosccvilcooimmutapernovulcrosmicn\") == False\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"cccbbbaaabbb\") == False\n assert candidate(word1 = \"leetcode\",word2 = \"codeleet\") == True\n assert candidate(word1 = \"z\",word2 = \"z\") == True\n assert candidate(word1 = \"aabbaa\",word2 = \"bbaabb\") == True\n assert candidate(word1 = \"aaabbbccc\",word2 = \"bbbaaacc\") == False\n assert candidate(word1 = \"transform\",word2 = \"rmorfnapt\") == False\n assert candidate(word1 = \"aaaabbbbccccddddeeeeeffffffgggggg\",word2 = \"ggggggffffffeeeeeeeeeccccbbbbaaaa\") == False\n assert candidate(word1 = \"abacabadabacabad\",word2 = \"badacabdacabad\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"hello\",word2 = \"ollhe\") == True\n assert candidate(word1 = \"uniquestring\",word2 = \"stringunique\") == True\n assert candidate(word1 = \"abcdef\",word2 = \"gfedcb\") == False\n assert candidate(word1 = \"xyxyxyxyxyxyxyxyxyxy\",word2 = \"yyxyxyxyxyxyxyxyxyxxyx\") == False\n assert candidate(word1 = \"aaaaabbbbccccdddd\",word2 = \"ddddccccbbbbaaa\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(word1 = \"abcde\",word2 = \"fghij\") == False\n assert candidate(word1 = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",word2 = \"ddddccccbbbbaaaaaaddddccccbbbbaaaaaa\") == False\n assert candidate(word1 = \"aabbbcccc\",word2 = \"cccbbbaaa\") == False\n assert candidate(word1 = \"aabbccddeee\",word2 = \"eeeedddccbbbaaa\") == False\n assert candidate(word1 = \"thisisatest\",word2 = \"esttisita\") == False\n assert candidate(word1 = \"aaabbbcccddd\",word2 = \"ddddcccbbbbaaa\") == False\n assert candidate(word1 = \"abcdefghijabcdefghijabcdefghij\",word2 = \"abcdefghijabcdefghijabcdefghij\") == True\n assert candidate(word1 = \"zzzzzzzzzz\",word2 = \"zzzzzzzzzz\") == True\n assert candidate(word1 = \"abcdeabcde\",word2 = \"edcbaedcba\") == True\n assert candidate(word1 = \"abcdabcdabcdabcdabcdabcd\",word2 = \"dcbaabcdabcdabcdabcdabcd\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzzyyxwwvvuuttrrqqppoonnmmllkkiijjgghhffeeeeddccbbaa\") == False\n assert candidate(word1 = \"abcdexyz\",word2 = \"zyxwvuts\") == False\n assert candidate(word1 = \"qqwweerrttyyuuiiooppaassddffgg\",word2 = \"ggffddssaappoouuiittyyerrrwwqq\") == False\n assert candidate(word1 = \"abcdefg\",word2 = \"ghijklm\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwwvvuuttssrrqqlloonnmmllkkjjiihhggeeddbbaa\") == False\n assert candidate(word1 = \"aaaabbbbccccddddeee\",word2 = \"eeedddccccbbbbaaaa\") == False\n assert candidate(word1 = \"abcdabcd\",word2 = \"dcbaabcd\") == True\n assert candidate(word1 = \"closestrings\",word2 = \"stringsclose\") == True\n assert candidate(word1 = \"aaaabbbbccccdddd\",word2 = \"ddddccccbbbbaaaa\") == True\n assert candidate(word1 = \"xyzzzz\",word2 = \"zzzzxy\") == True\n", "comparison": "exact"}, "public_tests": ["\"abc\"\n\"bca\"", "\"a\"\n\"aa\"", "\"cabbba\"\n\"abbccc\""], "hints": ["Operation 1 allows you to freely reorder the string.", "Operation 2 allows you to freely reassign the letters' frequencies."], "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().closeStrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:37+00:00", "tests_total": 106, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "sorting", "counting"]}, "language": "python", "interface": {"raw_signature": "def closeStrings(self, word1: str, word2: str) -> bool:", "container": "Solution", "callable": "closeStrings", "parameters": [{"name": "word1", "type": "str"}, {"name": "word2", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1658, "task_id": "minimum-operations-to-reduce-x-to-zero", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer x. In one operation, you can either remove the leftmost or the rightmost element from the array nums and subtract its value from x. Note that this modifies the array for future operations.\n\nReturn the minimum number of operations to reduce x to exactly 0 if it is possible, otherwise, return -1.\n\nExample 1:\n\nInput: nums = [1,1,4,2,3], x = 5\nOutput: 2\nExplanation: The optimal solution is to remove the last two elements to reduce x to zero.\n\nExample 2:\n\nInput: nums = [5,6,7,8,9], x = 4\nOutput: -1\n\nExample 3:\n\nInput: nums = [3,2,20,1,1,3], x = 10\nOutput: 5\nExplanation: The optimal solution is to remove the last three elements and the first two elements (5 operations in total) to reduce x to zero.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^4\n- 1 <= x <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],x = 15) == 5\n assert candidate(nums = [1, 1, 4, 2, 3],x = 5) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],x = 100) == 3\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000],x = 30000) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 10) == 10\n assert candidate(nums = [3, 2, 20, 1, 1, 3],x = 10) == 5\n assert candidate(nums = [1, 1, 1, 1, 1],x = 5) == 5\n assert candidate(nums = [1, 1, 1, 1, 1],x = 3) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 15) == 5\n assert candidate(nums = [2, 3, 1, 2, 4, 3],x = 7) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 11) == 2\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000],x = 50000) == 5\n assert candidate(nums = [5, 6, 7, 8, 9],x = 4) == -1\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],x = 25000) == 5\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],x = 15) == 10\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],x = 5000) == 5\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],x = 1400000) == -1\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],x = 10) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],x = 1000) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 190) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 190) == 15\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],x = 55000) == 10\n assert candidate(nums = [3, 5, 10, 7, 15, 1, 4, 2, 8, 6],x = 29) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 21) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 5) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 95) == 15\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],x = 55000) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 30) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 25) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],x = 55) == 7\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 15) == 4\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],x = 15) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 85) == 8\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 100) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 10) == 10\n assert candidate(nums = [1, 2, 3, 4, 5],x = 15) == 5\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],x = 35000) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 10) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 50) == 50\n assert candidate(nums = [3, 2, 20, 1, 1, 3, 5, 10, 1, 1],x = 29) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 1000) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 150) == 5\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],x = 50000) == 5\n assert candidate(nums = [5, 3, 2, 5, 3, 2, 5, 3, 2, 5, 3, 2, 5, 3, 2],x = 20) == 6\n assert candidate(nums = [1, 3, 2, 4, 5, 2, 3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 150) == 12\n assert candidate(nums = [5, 2, 3, 1, 1, 2, 3, 4, 5],x = 9) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],x = 1225) == 45\n assert candidate(nums = [2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3],x = 15) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 100) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 100) == 20\n assert candidate(nums = [3, 5, 2, 1, 4, 7, 8, 9, 6, 10],x = 18) == 3\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],x = 45000) == 6\n assert candidate(nums = [3, 2, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 3, 2, 2, 3, 3, 3, 3, 2, 3, 3, 2, 3, 2, 2, 3, 3, 3, 3],x = 30) == 11\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],x = 370) == 6\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],x = 50) == 5\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 9) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],x = 1500) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 210) == 20\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],x = 55000) == 10\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 90) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],x = 45) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],x = 275) == 20\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],x = 60) == 20\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],x = 100000) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 55) == 10\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],x = 30) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 50) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 100) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 15) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 55) == 10\n assert candidate(nums = [10000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9000],x = 20000) == -1\n assert candidate(nums = [10000, 9999, 10000, 9999, 10000, 9999],x = 59996) == -1\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],x = 3000) == 5\n assert candidate(nums = [9, 1, 2, 3, 9, 3, 2, 1, 9],x = 18) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],x = 80) == 14\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 25) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 105) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],x = 1275) == 50\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 50) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],x = 435) == 25\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 550) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 65) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 100) == 9\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],x = 100) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 45) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 20) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 120) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 450) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 55) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],x = 5500) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 55) == 10\n assert candidate(nums = [9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999],x = 49995) == 5\n assert candidate(nums = [5, 2, 3, 1, 1, 5, 5, 3, 2, 5],x = 10) == 2\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],x = 90) == 30\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],x = 80) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],x = 950) == 10\n assert candidate(nums = [3, 5, 2, 4, 1, 9, 6, 7, 8, 10],x = 25) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 100) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],x = 120) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 15) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 20) == 20\n assert candidate(nums = [5000, 3000, 2000, 4000, 1000, 6000],x = 21000) == 6\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],x = 70000) == 7\n", "comparison": "exact"}, "public_tests": ["[1,1,4,2,3]\n5", "[5,6,7,8,9]\n4", "[3,2,20,1,1,3]\n10"], "hints": ["Think in reverse; instead of finding the minimum prefix + suffix, find the maximum subarray.", "Finding the maximum subarray is standard and can be done greedily."], "metadata": {"canonical_parameter_names": ["nums", "x"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:39+00:00", "tests_total": 107, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "hash-table", "binary-search", "sliding-window", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minOperations(self, nums: list[int], x: int) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "x", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1659, "task_id": "maximize-grid-happiness", "difficulty": "Hard", "problem_description": "You are given four integers, m, n, introvertsCount, and extrovertsCount. You have an m x n grid, and there are two types of people: introverts and extroverts. There are introvertsCount introverts and extrovertsCount extroverts.\n\nYou should decide how many people you want to live in the grid and assign each of them one grid cell. Note that you do not have to have all the people living in the grid.\n\nThe happiness of each person is calculated as follows:\n\n- Introverts start with 120 happiness and lose 30 happiness for each neighbor (introvert or extrovert).\n- Extroverts start with 40 happiness and gain 20 happiness for each neighbor (introvert or extrovert).\n\nNeighbors live in the directly adjacent cells north, east, south, and west of a person's cell.\n\nThe grid happiness is the sum of each person's happiness. Return the maximum possible grid happiness.\n\nExample 1:\n\nInput: m = 2, n = 3, introvertsCount = 1, extrovertsCount = 2\nOutput: 240\nExplanation: Assume the grid is 1-indexed with coordinates (row, column).\nWe can put the introvert in cell (1,1) and put the extroverts in cells (1,3) and (2,3).\n- Introvert at (1,1) happiness: 120 (starting happiness) - (0 * 30) (0 neighbors) = 120\n- Extrovert at (1,3) happiness: 40 (starting happiness) + (1 * 20) (1 neighbor) = 60\n- Extrovert at (2,3) happiness: 40 (starting happiness) + (1 * 20) (1 neighbor) = 60\nThe grid happiness is 120 + 60 + 60 = 240.\nThe above figure shows the grid in this example with each person's happiness. The introvert stays in the light green cell while the extroverts live on the light purple cells.\n\nExample 2:\n\nInput: m = 3, n = 1, introvertsCount = 2, extrovertsCount = 1\nOutput: 260\nExplanation: Place the two introverts in (1,1) and (3,1) and the extrovert at (2,1).\n- Introvert at (1,1) happiness: 120 (starting happiness) - (1 * 30) (1 neighbor) = 90\n- Extrovert at (2,1) happiness: 40 (starting happiness) + (2 * 20) (2 neighbors) = 80\n- Introvert at (3,1) happiness: 120 (starting happiness) - (1 * 30) (1 neighbor) = 90\nThe grid happiness is 90 + 80 + 90 = 260.\n\nExample 3:\n\nInput: m = 2, n = 2, introvertsCount = 4, extrovertsCount = 0\nOutput: 240\n\nConstraints:\n\n- 1 <= m, n <= 5\n- 0 <= introvertsCount, extrovertsCount <= min(m * n, 6)\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(m = 5,n = 5,introvertsCount = 6,extrovertsCount = 6) == 1240\n assert candidate(m = 1,n = 1,introvertsCount = 0,extrovertsCount = 1) == 40\n assert candidate(m = 5,n = 1,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 2,n = 3,introvertsCount = 1,extrovertsCount = 2) == 240\n assert candidate(m = 1,n = 1,introvertsCount = 1,extrovertsCount = 0) == 120\n assert candidate(m = 4,n = 4,introvertsCount = 6,extrovertsCount = 0) == 720\n assert candidate(m = 2,n = 2,introvertsCount = 4,extrovertsCount = 0) == 240\n assert candidate(m = 3,n = 1,introvertsCount = 2,extrovertsCount = 1) == 260\n assert candidate(m = 1,n = 1,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 5,n = 1,introvertsCount = 0,extrovertsCount = 5) == 360\n assert candidate(m = 4,n = 4,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 5,n = 5,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 1,n = 5,introvertsCount = 5,extrovertsCount = 0) == 360\n assert candidate(m = 4,n = 5,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 2,n = 5,introvertsCount = 5,extrovertsCount = 5) == 770\n assert candidate(m = 3,n = 5,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 2,n = 5,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 5,n = 2,introvertsCount = 4,extrovertsCount = 2) == 590\n assert candidate(m = 3,n = 3,introvertsCount = 4,extrovertsCount = 1) == 520\n assert candidate(m = 4,n = 3,introvertsCount = 4,extrovertsCount = 3) == 680\n assert candidate(m = 5,n = 2,introvertsCount = 5,extrovertsCount = 1) == 620\n assert candidate(m = 5,n = 2,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 5,n = 5,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 4,n = 4,introvertsCount = 3,extrovertsCount = 4) == 680\n assert candidate(m = 4,n = 4,introvertsCount = 1,extrovertsCount = 6) == 640\n assert candidate(m = 4,n = 4,introvertsCount = 6,extrovertsCount = 6) == 1140\n assert candidate(m = 3,n = 2,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 5,n = 5,introvertsCount = 6,extrovertsCount = 5) == 1120\n assert candidate(m = 4,n = 4,introvertsCount = 2,extrovertsCount = 2) == 360\n assert candidate(m = 1,n = 5,introvertsCount = 1,extrovertsCount = 4) == 390\n assert candidate(m = 4,n = 4,introvertsCount = 4,extrovertsCount = 4) == 800\n assert candidate(m = 2,n = 5,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 5,n = 2,introvertsCount = 4,extrovertsCount = 1) == 520\n assert candidate(m = 3,n = 5,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 2,n = 5,introvertsCount = 2,extrovertsCount = 2) == 360\n assert candidate(m = 3,n = 3,introvertsCount = 4,extrovertsCount = 3) == 640\n assert candidate(m = 3,n = 4,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 5,n = 3,introvertsCount = 1,extrovertsCount = 4) == 440\n assert candidate(m = 4,n = 3,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 3,n = 2,introvertsCount = 0,extrovertsCount = 3) == 200\n assert candidate(m = 5,n = 4,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 3,n = 3,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 3,n = 3,introvertsCount = 5,extrovertsCount = 1) == 610\n assert candidate(m = 5,n = 1,introvertsCount = 5,extrovertsCount = 1) == 380\n assert candidate(m = 5,n = 5,introvertsCount = 5,extrovertsCount = 1) == 640\n assert candidate(m = 4,n = 4,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 4,n = 3,introvertsCount = 5,extrovertsCount = 1) == 640\n assert candidate(m = 4,n = 2,introvertsCount = 4,extrovertsCount = 2) == 520\n assert candidate(m = 5,n = 3,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 4,n = 3,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 3,n = 5,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 3,n = 3,introvertsCount = 3,extrovertsCount = 3) == 550\n assert candidate(m = 4,n = 2,introvertsCount = 3,extrovertsCount = 2) == 470\n assert candidate(m = 5,n = 3,introvertsCount = 4,extrovertsCount = 2) == 600\n assert candidate(m = 4,n = 2,introvertsCount = 2,extrovertsCount = 4) == 550\n assert candidate(m = 5,n = 3,introvertsCount = 6,extrovertsCount = 0) == 720\n assert candidate(m = 5,n = 2,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 4,n = 2,introvertsCount = 1,extrovertsCount = 5) == 520\n assert candidate(m = 4,n = 5,introvertsCount = 1,extrovertsCount = 4) == 440\n assert candidate(m = 4,n = 4,introvertsCount = 4,extrovertsCount = 3) == 680\n assert candidate(m = 4,n = 1,introvertsCount = 2,extrovertsCount = 2) == 340\n assert candidate(m = 4,n = 3,introvertsCount = 5,extrovertsCount = 2) == 710\n assert candidate(m = 5,n = 3,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 2,n = 5,introvertsCount = 1,extrovertsCount = 5) == 520\n assert candidate(m = 5,n = 3,introvertsCount = 3,extrovertsCount = 4) == 680\n assert candidate(m = 4,n = 4,introvertsCount = 4,extrovertsCount = 2) == 600\n assert candidate(m = 4,n = 5,introvertsCount = 6,extrovertsCount = 2) == 840\n assert candidate(m = 3,n = 4,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 3,n = 4,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 3,n = 3,introvertsCount = 4,extrovertsCount = 4) == 700\n assert candidate(m = 2,n = 2,introvertsCount = 2,extrovertsCount = 2) == 280\n assert candidate(m = 5,n = 4,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 3,n = 3,introvertsCount = 6,extrovertsCount = 0) == 600\n assert candidate(m = 4,n = 3,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 5,n = 1,introvertsCount = 5,extrovertsCount = 0) == 360\n assert candidate(m = 2,n = 4,introvertsCount = 3,extrovertsCount = 2) == 470\n assert candidate(m = 2,n = 2,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 3,n = 3,introvertsCount = 1,extrovertsCount = 1) == 160\n assert candidate(m = 1,n = 5,introvertsCount = 3,extrovertsCount = 3) == 420\n assert candidate(m = 3,n = 3,introvertsCount = 2,extrovertsCount = 2) == 360\n assert candidate(m = 3,n = 3,introvertsCount = 2,extrovertsCount = 4) == 550\n assert candidate(m = 2,n = 2,introvertsCount = 0,extrovertsCount = 1) == 40\n assert candidate(m = 2,n = 2,introvertsCount = 0,extrovertsCount = 2) == 120\n assert candidate(m = 3,n = 3,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 3,n = 3,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 5,n = 2,introvertsCount = 5,extrovertsCount = 5) == 770\n assert candidate(m = 5,n = 1,introvertsCount = 3,extrovertsCount = 3) == 420\n assert candidate(m = 5,n = 2,introvertsCount = 5,extrovertsCount = 0) == 600\n assert candidate(m = 4,n = 4,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 5,n = 1,introvertsCount = 1,extrovertsCount = 0) == 120\n assert candidate(m = 2,n = 2,introvertsCount = 1,extrovertsCount = 1) == 160\n assert candidate(m = 1,n = 5,introvertsCount = 0,extrovertsCount = 5) == 360\n assert candidate(m = 4,n = 4,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 4,n = 4,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 4,n = 5,introvertsCount = 5,extrovertsCount = 4) == 920\n assert candidate(m = 1,n = 1,introvertsCount = 1,extrovertsCount = 1) == 120\n assert candidate(m = 5,n = 5,introvertsCount = 1,extrovertsCount = 1) == 160\n assert candidate(m = 1,n = 5,introvertsCount = 1,extrovertsCount = 0) == 120\n assert candidate(m = 1,n = 5,introvertsCount = 0,extrovertsCount = 1) == 40\n assert candidate(m = 5,n = 1,introvertsCount = 0,extrovertsCount = 1) == 40\n assert candidate(m = 2,n = 5,introvertsCount = 3,extrovertsCount = 2) == 480\n", "comparison": "exact"}, "public_tests": ["2\n3\n1\n2", "3\n1\n2\n1", "2\n2\n4\n0"], "hints": ["For each cell, it has 3 options, either it is empty, or contains an introvert, or an extrovert.", "You can do DP where you maintain the state of the previous row, the number of remaining introverts and extroverts, the current row and column, and try the 3 options for each cell.", "Assume that the previous columns in the current row already belong to the previous row."], "metadata": {"canonical_parameter_names": ["m", "n", "introvertsCount", "extrovertsCount"], "leetcode_dataset_entry_point": "Solution().getMaxGridHappiness", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:42+00:00", "tests_total": 102, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["dynamic-programming", "bit-manipulation", "memoization", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def getMaxGridHappiness(self, m: int, n: int, introvertsCount: int, extrovertsCount: int) -> int:", "container": "Solution", "callable": "getMaxGridHappiness", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "introvertsCount", "type": "int"}, {"name": "extrovertsCount", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1662, "task_id": "check-if-two-string-arrays-are-equivalent", "difficulty": "Easy", "problem_description": "Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise.\n\nA string is represented by an array if the array elements concatenated in order forms the string.\n\nExample 1:\n\nInput: word1 = [\"ab\", \"c\"], word2 = [\"a\", \"bc\"]\nOutput: true\nExplanation:\nword1 represents string \"ab\" + \"c\" -> \"abc\"\nword2 represents string \"a\" + \"bc\" -> \"abc\"\nThe strings are the same, so return true.\n\nExample 2:\n\nInput: word1 = [\"a\", \"cb\"], word2 = [\"ab\", \"c\"]\nOutput: false\n\nExample 3:\n\nInput: word1 = [\"abc\", \"d\", \"defg\"], word2 = [\"abcddefg\"]\nOutput: true\n\nConstraints:\n\n- 1 <= word1.length, word2.length <= 10^3\n- 1 <= word1[i].length, word2[i].length <= 10^3\n- 1 <= sum(word1[i].length), sum(word2[i].length) <= 10^3\n- word1[i] and word2[i] consist of lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = ['abc', 'd', 'defg'],word2 = ['abcddefg']) == True\n assert candidate(word1 = ['x'],word2 = ['y']) == False\n assert candidate(word1 = ['different'],word2 = ['string']) == False\n assert candidate(word1 = ['hello', 'world'],word2 = ['helloworld']) == True\n assert candidate(word1 = ['one', 'two', 'three'],word2 = ['onetwothree']) == True\n assert candidate(word1 = ['abc'],word2 = ['a', 'b', 'c']) == True\n assert candidate(word1 = ['abc'],word2 = ['ab', 'c']) == True\n assert candidate(word1 = ['xyz'],word2 = ['x', 'y', 'z']) == True\n assert candidate(word1 = ['ab', 'c'],word2 = ['a', 'bc']) == True\n assert candidate(word1 = ['a'],word2 = ['a']) == True\n assert candidate(word1 = ['a', 'cb'],word2 = ['ab', 'c']) == False\n assert candidate(word1 = ['hello'],word2 = ['hello']) == True\n assert candidate(word1 = ['test'],word2 = ['t', 'es', 't']) == True\n assert candidate(word1 = ['a', 'b'],word2 = ['ab']) == True\n assert candidate(word1 = ['same', 'string'],word2 = ['same', 'string']) == True\n assert candidate(word1 = ['a', 'b', 'c'],word2 = ['a', 'b', 'c']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g'],word2 = ['abcdefg']) == True\n assert candidate(word1 = ['split', 'in', 'pieces'],word2 = ['spli', 'tin', 'pi', 'eces']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd', 'e', 'f'],word2 = ['abcdef']) == True\n assert candidate(word1 = ['complex', 'string', 'example'],word2 = ['com', 'plex', 'string', 'ex', 'ample']) == True\n assert candidate(word1 = ['a', 'b', 'c'],word2 = ['ab', 'c']) == True\n assert candidate(word1 = ['same', 'same', 'same'],word2 = ['same', 'same', 'same']) == True\n assert candidate(word1 = ['split', 'this', 'up'],word2 = ['splitthis', 'up']) == True\n assert candidate(word1 = ['a', 'b', 'c'],word2 = ['d', 'e', 'f']) == False\n assert candidate(word1 = ['abcdef'],word2 = ['abc', 'd', 'e', 'f']) == True\n assert candidate(word1 = ['abcd', 'efgh', 'ijkl'],word2 = ['abcdefgh', 'ijkl']) == True\n assert candidate(word1 = ['abc', 'def'],word2 = ['abcdefg']) == False\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abc', 'd', 'efghi']) == True\n assert candidate(word1 = ['complex', 'word'],word2 = ['c', 'o', 'm', 'p', 'l', 'e', 'x', 'word']) == True\n assert candidate(word1 = ['partial', 'match'],word2 = ['partialm', 'atch']) == True\n assert candidate(word1 = ['a', 'bc', 'def', 'ghij'],word2 = ['abc', 'defghij']) == True\n assert candidate(word1 = ['equal', 'strings'],word2 = ['equalstrings']) == True\n assert candidate(word1 = ['example'],word2 = ['ex', 'ample']) == True\n assert candidate(word1 = ['complex', 'example'],word2 = ['com', 'plexex', 'ample']) == True\n assert candidate(word1 = ['abcdefg', 'hijklmn'],word2 = ['abc', 'defghijklmn']) == True\n assert candidate(word1 = ['same'],word2 = ['s', 'a', 'm', 'e']) == True\n assert candidate(word1 = ['long', 'word', 'sequence'],word2 = ['l', 'ongw', 'ordsequ', 'ence']) == True\n assert candidate(word1 = ['a', 'very', 'long', 'string', 'here'],word2 = ['averylongstringhere']) == True\n assert candidate(word1 = ['same', 'string'],word2 = ['sam', 'e', 'string']) == True\n assert candidate(word1 = ['abc', 'defg', 'hijkl'],word2 = ['abcdefg', 'hijkl']) == True\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abcdef', 'ghi']) == True\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abcdefg', 'hi']) == True\n assert candidate(word1 = ['long', 'string', 'here'],word2 = ['longstring', 'here']) == True\n assert candidate(word1 = ['x', 'y', 'z'],word2 = ['xyz']) == True\n assert candidate(word1 = ['z'],word2 = ['z']) == True\n assert candidate(word1 = ['one', 'two', 'three', 'four'],word2 = ['onetwo', 'three', 'four']) == True\n assert candidate(word1 = ['one', 'two', 'three', 'four'],word2 = ['onetwo', 'threefour']) == True\n assert candidate(word1 = ['x', 'y', 'z'],word2 = ['x', 'yz']) == True\n assert candidate(word1 = ['xyz', 'uvw'],word2 = ['xy', 'zu', 'vw']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd', 'e'],word2 = ['abcd', 'e']) == True\n assert candidate(word1 = ['longerstring', 'here'],word2 = ['longerstringhere']) == True\n assert candidate(word1 = ['onetwothree'],word2 = ['one', 'two', 'three']) == True\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['ab', 'cdef', 'ghi']) == True\n assert candidate(word1 = ['abcd'],word2 = ['ab', 'c', 'd']) == True\n assert candidate(word1 = ['one', 'two', 'three', 'four'],word2 = ['onetwothreefour']) == True\n assert candidate(word1 = ['almost', 'thesame'],word2 = ['almostthesame', 'extra']) == False\n assert candidate(word1 = ['split', 'into', 'multiple', 'parts'],word2 = ['splitint', 'omulti', 'pleparts']) == True\n assert candidate(word1 = ['ab', 'cde', 'f'],word2 = ['abc', 'def']) == True\n assert candidate(word1 = ['same', 'string', 'here'],word2 = ['samestringhere']) == True\n assert candidate(word1 = ['xyz', 'uvw', 'mnop'],word2 = ['xyzu', 'vw', 'mnop']) == True\n assert candidate(word1 = ['xyz', 'uvw', 'qrst'],word2 = ['xyzuvw', 'qrst']) == True\n assert candidate(word1 = ['same', 'string', 'here'],word2 = ['sam', 'e', 'stringhere']) == True\n assert candidate(word1 = ['longstringhere', 'another'],word2 = ['longstringhereanother']) == True\n assert candidate(word1 = ['this', 'is', 'a', 'test'],word2 = ['thi', 'sisa', 'test']) == True\n assert candidate(word1 = ['abc', 'defg', 'hijk', 'lmnop'],word2 = ['abcdefg', 'hijklmnop']) == True\n assert candidate(word1 = ['longstringhere', 'anotherlongstringhere'],word2 = ['longstringhereanotherlongstringhere']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd', 'e'],word2 = ['abcde']) == True\n assert candidate(word1 = ['a', 'longer', 'string', 'here'],word2 = ['a', 'longerstring', 'here']) == True\n assert candidate(word1 = ['a', 'b', 'c'],word2 = ['abc']) == True\n assert candidate(word1 = ['different', 'length'],word2 = ['differentlen', 'gth']) == True\n assert candidate(word1 = ['longstringone', 'longstringtwo'],word2 = ['longstringone', 'long', 'string', 'two']) == True\n assert candidate(word1 = ['same', 'string', 'here'],word2 = ['samestring', 'here']) == True\n assert candidate(word1 = ['short'],word2 = ['loooooooonger']) == False\n assert candidate(word1 = ['hello', 'world'],word2 = ['he', 'll', 'o', 'wor', 'ld']) == True\n assert candidate(word1 = ['hello', 'world', 'python'],word2 = ['hello', 'wor', 'ldpy', 'thon']) == True\n assert candidate(word1 = ['another', 'example', 'with', 'spaces'],word2 = ['anotherexam', 'plewithspaces']) == True\n assert candidate(word1 = ['xyz', 'uvw', 'rst'],word2 = ['xyzuvw', 'rst']) == True\n assert candidate(word1 = ['abc', 'def'],word2 = ['a', 'bc', 'd', 'ef']) == True\n assert candidate(word1 = ['this', 'is', 'a', 'test'],word2 = ['thisisatest']) == True\n assert candidate(word1 = ['samestringhere'],word2 = ['same', 'string', 'here']) == True\n assert candidate(word1 = ['abcd'],word2 = ['a', 'b', 'c', 'd']) == True\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abcdefghi']) == True\n assert candidate(word1 = ['a', 'a', 'a', 'a', 'a'],word2 = ['a', 'a', 'a', 'a', 'a']) == True\n assert candidate(word1 = ['a', 'a', 'a', 'a', 'a'],word2 = ['aaaaa']) == True\n assert candidate(word1 = ['mismatch', 'here'],word2 = ['mismatch', 'there']) == False\n assert candidate(word1 = ['one', 'two', 'three'],word2 = ['on', 'etwothree']) == True\n assert candidate(word1 = ['part', 'one'],word2 = ['p', 'artone']) == True\n assert candidate(word1 = ['equal', 'length', 'words'],word2 = ['equal', 'length', 'word']) == False\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abc', 'def', 'ghi']) == True\n assert candidate(word1 = ['equal', 'length'],word2 = ['equal', 'length']) == True\n assert candidate(word1 = ['longwordhere'],word2 = ['l', 'on', 'g', 'wo', 'rd', 'here']) == True\n assert candidate(word1 = ['longer', 'string', 'example'],word2 = ['longerstringexample']) == True\n assert candidate(word1 = ['singleword'],word2 = ['single', 'word']) == True\n assert candidate(word1 = ['different', 'sizes'],word2 = ['different', 'siz', 'es']) == True\n assert candidate(word1 = ['a'],word2 = ['b']) == False\n assert candidate(word1 = ['one', 'two', 'three'],word2 = ['one', 'twothree']) == True\n assert candidate(word1 = ['split', 'this', 'way'],word2 = ['sp', 'lit', 'thi', 'sway']) == True\n assert candidate(word1 = ['one', 'two', 'three'],word2 = ['onetwo', 'three']) == True\n assert candidate(word1 = ['this', 'is', 'a', 'test'],word2 = ['thisis', 'atest']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd'],word2 = ['abcd']) == True\n assert candidate(word1 = ['split', 'across', 'multiple', 'parts'],word2 = ['splitacrossmultip', 'leparts']) == True\n", "comparison": "exact"}, "public_tests": ["[\"ab\", \"c\"]\n[\"a\", \"bc\"]", "[\"a\", \"cb\"]\n[\"ab\", \"c\"]", "[\"abc\", \"d\", \"defg\"]\n[\"abcddefg\"]"], "hints": ["Concatenate all strings in the first array into a single string in the given order, the same for the second array.", "Both arrays represent the same string if and only if the generated strings are the same."], "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().arrayStringsAreEqual", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:44+00:00", "tests_total": 105, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "string"]}, "language": "python", "interface": {"raw_signature": "def arrayStringsAreEqual(self, word1: list[str], word2: list[str]) -> bool:", "container": "Solution", "callable": "arrayStringsAreEqual", "parameters": [{"name": "word1", "type": "list[str]"}, {"name": "word2", "type": "list[str]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1663, "task_id": "smallest-string-with-a-given-numeric-value", "difficulty": "Medium", "problem_description": "The numeric value of a lowercase character is defined as its position (1-indexed) in the alphabet, so the numeric value of a is 1, the numeric value of b is 2, the numeric value of c is 3, and so on.\n\nThe numeric value of a string consisting of lowercase characters is defined as the sum of its characters' numeric values. For example, the numeric value of the string \"abe\" is equal to 1 + 2 + 5 = 8.\n\nYou are given two integers n and k. Return the lexicographically smallest string with length equal to n and numeric value equal to k.\n\nNote that a string x is lexicographically smaller than string y if x comes before y in dictionary order, that is, either x is a prefix of y, or if i is the first position such that x[i] != y[i], then x[i] comes before y[i] in alphabetic order.\n\nExample 1:\n\nInput: n = 3, k = 27\nOutput: \"aay\"\nExplanation: The numeric value of the string is 1 + 1 + 25 = 27, and it is the smallest string with such a value and length equal to 3.\n\nExample 2:\n\nInput: n = 5, k = 73\nOutput: \"aaszz\"\n\nConstraints:\n\n- 1 <= n <= 10^5\n- n <= k <= 26 * n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 7,k = 100) == \"aaaszzz\"\n assert candidate(n = 1,k = 26) == \"z\"\n assert candidate(n = 4,k = 40) == \"aalz\"\n assert candidate(n = 5,k = 73) == \"aaszz\"\n assert candidate(n = 10,k = 260) == \"zzzzzzzzzz\"\n assert candidate(n = 2,k = 2) == \"aa\"\n assert candidate(n = 1,k = 1) == \"a\"\n assert candidate(n = 2,k = 26) == \"ay\"\n assert candidate(n = 4,k = 52) == \"aaxz\"\n assert candidate(n = 3,k = 27) == \"aay\"\n assert candidate(n = 10,k = 100) == \"aaaaaapzzz\"\n assert candidate(n = 50,k = 650) == \"aaaaaaaaaaaaaaaaaaaaaaaaaazzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 100,k = 1000) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 12,k = 300) == \"nzzzzzzzzzzz\"\n assert candidate(n = 6,k = 156) == \"zzzzzz\"\n assert candidate(n = 10,k = 131) == \"aaaaavzzzz\"\n assert candidate(n = 5,k = 67) == \"aamzz\"\n assert candidate(n = 15,k = 350) == \"akzzzzzzzzzzzzz\"\n assert candidate(n = 25,k = 650) == \"zzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 12,k = 150) == \"aaaaaanzzzzz\"\n assert candidate(n = 7,k = 145) == \"anzzzzz\"\n assert candidate(n = 6,k = 45) == \"aaaaoz\"\n assert candidate(n = 3,k = 51) == \"axz\"\n assert candidate(n = 11,k = 260) == \"ayzzzzzzzzz\"\n assert candidate(n = 15,k = 180) == \"aaaaaaaapzzzzzz\"\n assert candidate(n = 9,k = 150) == \"aaaqzzzzz\"\n assert candidate(n = 7,k = 104) == \"aaawzzz\"\n assert candidate(n = 7,k = 150) == \"aszzzzz\"\n assert candidate(n = 8,k = 175) == \"arzzzzzz\"\n assert candidate(n = 10,k = 150) == \"aaaapzzzzz\"\n assert candidate(n = 20,k = 400) == \"aaaafzzzzzzzzzzzzzzz\"\n assert candidate(n = 10,k = 52) == \"aaaaaaaarz\"\n assert candidate(n = 6,k = 100) == \"aatzzz\"\n assert candidate(n = 12,k = 200) == \"aaaanzzzzzzz\"\n assert candidate(n = 8,k = 208) == \"zzzzzzzz\"\n assert candidate(n = 3,k = 25) == \"aaw\"\n assert candidate(n = 20,k = 200) == \"aaaaaaaaaaaafzzzzzzz\"\n assert candidate(n = 15,k = 150) == \"aaaaaaaaakzzzzz\"\n assert candidate(n = 100,k = 2600) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 6,k = 78) == \"aaawzz\"\n assert candidate(n = 15,k = 225) == \"aaaaaakzzzzzzzz\"\n assert candidate(n = 26,k = 676) == \"zzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 3,k = 30) == \"acz\"\n assert candidate(n = 12,k = 312) == \"zzzzzzzzzzzz\"\n assert candidate(n = 9,k = 182) == \"aaxzzzzzz\"\n assert candidate(n = 7,k = 91) == \"aaajzzz\"\n assert candidate(n = 5,k = 130) == \"zzzzz\"\n assert candidate(n = 8,k = 120) == \"aaamzzzz\"\n assert candidate(n = 9,k = 234) == \"zzzzzzzzz\"\n assert candidate(n = 5,k = 125) == \"uzzzz\"\n assert candidate(n = 30,k = 780) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 20,k = 520) == \"zzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 50,k = 1300) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 4,k = 50) == \"aavz\"\n assert candidate(n = 11,k = 286) == \"zzzzzzzzzzz\"\n assert candidate(n = 15,k = 200) == \"aaaaaaakzzzzzzz\"\n assert candidate(n = 9,k = 230) == \"vzzzzzzzz\"\n assert candidate(n = 4,k = 10) == \"aaag\"\n assert candidate(n = 2,k = 27) == \"az\"\n assert candidate(n = 7,k = 42) == \"aaaaakz\"\n assert candidate(n = 4,k = 90) == \"lzzz\"\n", "comparison": "exact"}, "public_tests": ["3\n27", "5\n73"], "hints": ["Think greedily.", "If you build the string from the end to the beginning, it will always be optimal to put the highest possible character at the current index."], "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().getSmallestString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:46+00:00", "tests_total": 65, "tests_dropped": 4, "flags": [], "topic_tags": ["string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def getSmallestString(self, n: int, k: int) -> str:", "container": "Solution", "callable": "getSmallestString", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1664, "task_id": "ways-to-make-a-fair-array", "difficulty": "Medium", "problem_description": "You are given an integer array nums. You can choose exactly one index (0-indexed) and remove the element. Notice that the index of the elements may change after the removal.\n\nFor example, if nums = [6,1,7,4,1]:\n\n- Choosing to remove index 1 results in nums = [6,7,4,1].\n- Choosing to remove index 2 results in nums = [6,1,4,1].\n- Choosing to remove index 4 results in nums = [6,1,7,4].\n\nAn array is fair if the sum of the odd-indexed values equals the sum of the even-indexed values.\n\nReturn the number of indices that you could choose such that after the removal, nums is fair.\n\nExample 1:\n\nInput: nums = [2,1,6,4]\nOutput: 1\nExplanation:\nRemove index 0: [1,6,4] -> Even sum: 1 + 4 = 5. Odd sum: 6. Not fair.\nRemove index 1: [2,6,4] -> Even sum: 2 + 4 = 6. Odd sum: 6. Fair.\nRemove index 2: [2,1,4] -> Even sum: 2 + 4 = 6. Odd sum: 1. Not fair.\nRemove index 3: [2,1,6] -> Even sum: 2 + 6 = 8. Odd sum: 1. Not fair.\nThere is 1 index that you can remove to make nums fair.\n\nExample 2:\n\nInput: nums = [1,1,1]\nOutput: 3\nExplanation: You can remove any index and the remaining array is fair.\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: 0\nExplanation: You cannot make a fair array after removing any index.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 0\n assert candidate(nums = [1, 2]) == 0\n assert candidate(nums = [2, 1, 6, 4]) == 1\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000]) == 5\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [1, 1, 1]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50]) == 0\n assert candidate(nums = [4, 5, 6, 7, 8]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 0\n assert candidate(nums = [9999, 1, 9999, 1, 9999, 1, 9999, 1, 9999, 1]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [23, 17, 14, 6, 9, 4, 3, 10, 13, 2, 11, 1, 5, 15, 7, 12, 8, 16, 19, 18]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 0\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11, 33, 55, 77, 99, 22, 44, 66, 88, 10]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 0\n assert candidate(nums = [7, 10, 5, 8, 6, 3, 2, 9, 4, 1]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 0\n assert candidate(nums = [10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 0\n assert candidate(nums = [10000]) == 1\n assert candidate(nums = [5, 3, 2, 4, 1, 6, 7, 8, 9, 10, 11, 12]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(nums = [10000, 9999, 10000, 9999, 10000, 9999, 10000, 9999, 10000, 9999]) == 0\n assert candidate(nums = [42]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 0\n assert candidate(nums = [5, 3, 5, 3, 5, 3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == 0\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [2468, 1357, 2468, 1357, 2468, 1357, 2468, 1357, 2468, 1357, 2468, 1357, 2468, 1357, 2468]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(nums = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 13\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 0\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(nums = [2, 1, 6, 4, 3, 5, 7, 8]) == 0\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 91\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\n assert candidate(nums = [10000, 1, 10000, 1, 10000, 1]) == 0\n", "comparison": "exact"}, "public_tests": ["[2,1,6,4]", "[1,1,1]", "[1,2,3]"], "hints": ["The parity of the indices after the removed element changes.", "Calculate prefix sums for even and odd indices separately to calculate for each index in O(1)."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().waysToMakeFair", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:49+00:00", "tests_total": 100, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def waysToMakeFair(self, nums: list[int]) -> int:", "container": "Solution", "callable": "waysToMakeFair", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1665, "task_id": "minimum-initial-energy-to-finish-tasks", "difficulty": "Hard", "problem_description": "You are given an array tasks where tasks[i] = [actual_i, minimum_i]:\n\n- actual_i is the actual amount of energy you spend to finish the i^th task.\n- minimum_i is the minimum amount of energy you require to begin the i^th task.\n\nFor example, if the task is [10, 12] and your current energy is 11, you cannot start this task. However, if your current energy is 13, you can complete this task, and your energy will be 3 after finishing it.\n\nYou can finish the tasks in any order you like.\n\nReturn the minimum initial amount of energy you will need to finish all the tasks.\n\nExample 1:\n\nInput: tasks = [[1,2],[2,4],[4,8]]\nOutput: 8\nExplanation:\nStarting with 8 energy, we finish the tasks in the following order:\n - 3rd task. Now energy = 8 - 4 = 4.\n - 2nd task. Now energy = 4 - 2 = 2.\n - 1st task. Now energy = 2 - 1 = 1.\nNotice that even though we have leftover energy, starting with 7 energy does not work because we cannot do the 3rd task.\n\nExample 2:\n\nInput: tasks = [[1,3],[2,4],[10,11],[10,12],[8,9]]\nOutput: 32\nExplanation:\nStarting with 32 energy, we finish the tasks in the following order:\n - 1st task. Now energy = 32 - 1 = 31.\n - 2nd task. Now energy = 31 - 2 = 29.\n - 3rd task. Now energy = 29 - 10 = 19.\n - 4th task. Now energy = 19 - 10 = 9.\n - 5th task. Now energy = 9 - 8 = 1.\n\nExample 3:\n\nInput: tasks = [[1,7],[2,8],[3,9],[4,10],[5,11],[6,12]]\nOutput: 27\nExplanation:\nStarting with 27 energy, we finish the tasks in the following order:\n - 5th task. Now energy = 27 - 5 = 22.\n - 2nd task. Now energy = 22 - 2 = 20.\n - 3rd task. Now energy = 20 - 3 = 17.\n - 1st task. Now energy = 17 - 1 = 16.\n - 4th task. Now energy = 16 - 4 = 12.\n - 6th task. Now energy = 12 - 6 = 6.\n\nConstraints:\n\n- 1 <= tasks.length <= 10^5\n- 1 <= actual_i <= minimum_i <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [[10, 15], [20, 25], [30, 35]]) == 65\n assert candidate(tasks = [[10, 15], [5, 10], [3, 7]]) == 22\n assert candidate(tasks = [[10, 10], [15, 15], [5, 5]]) == 30\n assert candidate(tasks = [[1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12]]) == 27\n assert candidate(tasks = [[5, 10], [1, 2], [3, 4]]) == 10\n assert candidate(tasks = [[1, 2], [2, 4], [4, 8]]) == 8\n assert candidate(tasks = [[3, 3], [2, 5], [1, 4]]) == 6\n assert candidate(tasks = [[1, 100], [2, 99], [3, 98]]) == 101\n assert candidate(tasks = [[10, 10], [10, 10], [10, 10], [10, 10]]) == 40\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3]]) == 6\n assert candidate(tasks = [[1, 3], [2, 4], [10, 11], [10, 12], [8, 9]]) == 32\n assert candidate(tasks = [[1, 50], [2, 51], [3, 52], [4, 53], [5, 54], [6, 55], [7, 56], [8, 57], [9, 58], [10, 59], [11, 60], [12, 61], [13, 62], [14, 63], [15, 64], [16, 65], [17, 66], [18, 67], [19, 68], [20, 69], [21, 70], [22, 71], [23, 72], [24, 73], [25, 74]]) == 374\n assert candidate(tasks = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995]]) == 10010\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 191\n assert candidate(tasks = [[1, 2], [2, 4], [4, 8], [8, 16], [16, 32]]) == 32\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 56\n assert candidate(tasks = [[1, 10000], [10000, 10000], [1, 10000], [10000, 10000], [1, 10000]]) == 20003\n assert candidate(tasks = [[10000, 10000], [1, 2], [10000, 10000], [1, 2], [10000, 10000], [1, 2]]) == 30003\n assert candidate(tasks = [[100, 150], [50, 100], [30, 70], [20, 50], [10, 30], [5, 15]]) == 230\n assert candidate(tasks = [[10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10]]) == 100\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25]]) == 45\n assert candidate(tasks = [[100, 120], [200, 220], [300, 320], [400, 420], [500, 520]]) == 1520\n assert candidate(tasks = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 59\n assert candidate(tasks = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 100\n assert candidate(tasks = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 110], [12, 120], [13, 130], [14, 140], [15, 150]]) == 165\n assert candidate(tasks = [[100, 100], [90, 90], [80, 80], [70, 70], [60, 60], [50, 50], [40, 40], [30, 30], [20, 20], [10, 10], [5, 5]]) == 555\n assert candidate(tasks = [[9999, 10000], [9998, 10001], [9997, 10002], [9996, 10003], [9995, 10004], [9994, 10005], [9993, 10006], [9992, 10007], [9991, 10008], [9990, 10009]]) == 99946\n assert candidate(tasks = [[100, 105], [10, 15], [1, 2], [5, 7], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65], [70, 75]]) == 387\n assert candidate(tasks = [[5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19]]) == 79\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 55\n assert candidate(tasks = [[9999, 10000], [9998, 9999], [9997, 9998], [9996, 9997], [9995, 9996]]) == 49986\n assert candidate(tasks = [[100, 101], [99, 100], [98, 99], [97, 98], [96, 97], [95, 96]]) == 586\n assert candidate(tasks = [[1000, 1000], [900, 950], [800, 850], [700, 750], [600, 650]]) == 4000\n assert candidate(tasks = [[100, 200], [100, 300], [100, 400], [100, 500], [100, 600], [100, 700], [100, 800], [100, 900], [100, 1000]]) == 1000\n assert candidate(tasks = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]]) == 55\n assert candidate(tasks = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == 136\n assert candidate(tasks = [[1000, 1001], [2000, 2002], [3000, 3003], [4000, 4004], [5000, 5005], [6000, 6006], [7000, 7007], [8000, 8008], [9000, 9009], [10000, 10001]]) == 55001\n assert candidate(tasks = [[500, 1000], [400, 900], [300, 800], [200, 700], [100, 600], [50, 500], [25, 400], [12, 300], [7, 200], [5, 100], [3, 50]]) == 2000\n assert candidate(tasks = [[1, 10000], [10000, 10000], [1, 10000], [10000, 10000], [1, 10000], [10000, 10000]]) == 30003\n assert candidate(tasks = [[10000, 10000], [9999, 9999], [9998, 9998], [9997, 9997], [9996, 9996], [9995, 9995], [9994, 9994], [9993, 9993], [9992, 9992], [9991, 9991]]) == 99955\n assert candidate(tasks = [[1000, 1001], [999, 1002], [998, 1003], [997, 1004], [996, 1005], [995, 1006], [994, 1007], [993, 1008], [992, 1009], [991, 1010], [990, 1011], [989, 1012], [988, 1013], [987, 1014], [986, 1015], [985, 1016], [984, 1017], [983, 1018], [982, 1019], [981, 1020]]) == 19811\n assert candidate(tasks = [[1, 2], [100, 101], [1, 2], [100, 101], [1, 2], [100, 101]]) == 304\n assert candidate(tasks = [[500, 500], [500, 500], [500, 500], [500, 500], [500, 500]]) == 2500\n assert candidate(tasks = [[5, 10], [2, 8], [3, 5], [4, 7]]) == 16\n assert candidate(tasks = [[5000, 5000], [4999, 4999], [4998, 4998], [4997, 4997], [4996, 4996], [4995, 4995], [4994, 4994], [4993, 4993], [4992, 4992], [4991, 4991], [4990, 4990], [4989, 4989], [4988, 4988], [4987, 4987], [4986, 4986], [4985, 4985], [4984, 4984], [4983, 4983], [4982, 4982], [4981, 4981], [4980, 4980], [4979, 4979], [4978, 4978], [4977, 4977], [4976, 4976], [4975, 4975], [4974, 4974], [4973, 4973], [4972, 4972], [4971, 4971], [4970, 4970], [4969, 4969], [4968, 4968], [4967, 4967], [4966, 4966], [4965, 4965], [4964, 4964], [4963, 4963], [4962, 4962], [4961, 4961], [4960, 4960]]) == 204180\n assert candidate(tasks = [[5, 10], [4, 9], [3, 8], [2, 7], [1, 6], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15]]) == 60\n assert candidate(tasks = [[10, 11], [20, 21], [30, 31], [40, 41], [50, 51], [60, 61], [70, 71]]) == 281\n assert candidate(tasks = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65], [70, 75], [80, 85], [90, 95], [100, 105]]) == 555\n assert candidate(tasks = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120]]) == 780\n assert candidate(tasks = [[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000]]) == 10000\n assert candidate(tasks = [[1, 10000], [10000, 10000], [1, 10000], [10000, 10000], [1, 10000], [10000, 10000], [1, 10000], [10000, 10000]]) == 40004\n assert candidate(tasks = [[100, 150], [50, 100], [25, 75], [12, 60], [7, 35], [5, 25], [3, 15]]) == 235\n assert candidate(tasks = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 10\n assert candidate(tasks = [[100, 101], [102, 203], [204, 305], [306, 407], [408, 509], [510, 611], [612, 713], [714, 815], [816, 917], [918, 1019]]) == 4691\n assert candidate(tasks = [[9, 10], [8, 9], [7, 8], [6, 7], [5, 6], [4, 5], [3, 4], [2, 3], [1, 2]]) == 46\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 56\n assert candidate(tasks = [[9000, 10000], [8000, 9000], [7000, 8000], [6000, 7000], [5000, 6000], [4000, 5000]]) == 40000\n assert candidate(tasks = [[100, 110], [50, 60], [30, 40], [10, 20], [5, 15], [1, 3]]) == 205\n assert candidate(tasks = [[100, 200], [50, 150], [25, 125], [12, 112], [6, 106], [3, 103], [1, 101], [7, 107], [8, 108], [9, 109], [10, 110]]) == 331\n assert candidate(tasks = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996]]) == 10006\n assert candidate(tasks = [[500, 510], [400, 410], [300, 310], [200, 210], [100, 110], [50, 60], [10, 20], [1, 2], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 1658\n assert candidate(tasks = [[100, 200], [150, 250], [50, 100], [300, 400], [200, 300], [1000, 1200], [500, 600]]) == 2350\n assert candidate(tasks = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995], [7, 9994], [8, 9993], [9, 9992], [10, 9991], [11, 9990], [12, 9989], [13, 9988], [14, 9987], [15, 9986]]) == 10091\n assert candidate(tasks = [[5, 10], [10, 15], [20, 25], [30, 35], [40, 45]]) == 110\n assert candidate(tasks = [[10000, 10000], [9000, 9000], [8000, 8000], [7000, 7000], [6000, 6000], [5000, 5000], [4000, 4000], [3000, 3000], [2000, 2000], [1000, 1000]]) == 55000\n assert candidate(tasks = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995]]) == 10010\n assert candidate(tasks = [[8, 12], [15, 20], [5, 7], [10, 15], [3, 6]]) == 43\n assert candidate(tasks = [[7, 10], [4, 8], [6, 12], [2, 5], [1, 3]]) == 22\n assert candidate(tasks = [[1, 2], [3, 6], [5, 10], [7, 14], [9, 18], [11, 22], [13, 26], [15, 30], [17, 34], [19, 38], [21, 42], [23, 46], [25, 50], [27, 54], [29, 58], [31, 62], [33, 66], [35, 70], [37, 74], [39, 78]]) == 402\n assert candidate(tasks = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 75\n assert candidate(tasks = [[1000, 2000], [500, 1500], [250, 750], [125, 375], [63, 188], [31, 95], [16, 48], [8, 25], [4, 13], [2, 7], [1, 4]]) == 2500\n assert candidate(tasks = [[1000, 1010], [999, 1009], [998, 1008], [997, 1007], [996, 1006], [995, 1005], [994, 1004], [993, 1003], [992, 1002], [991, 1001]]) == 9965\n assert candidate(tasks = [[100, 200], [50, 200], [30, 200], [10, 200], [5, 200], [1, 200], [100, 300], [50, 300], [30, 300], [10, 300], [5, 300], [1, 300]]) == 492\n assert candidate(tasks = [[20, 25], [10, 13], [5, 6], [15, 20], [2, 3], [7, 10]]) == 60\n assert candidate(tasks = [[100, 150], [50, 100], [25, 50], [10, 20], [5, 10]]) == 200\n assert candidate(tasks = [[50, 60], [40, 70], [30, 80], [20, 90], [10, 100], [5, 110], [1, 120]]) == 166\n assert candidate(tasks = [[1000, 1010], [900, 910], [800, 810], [700, 710], [600, 610], [500, 510], [400, 410], [300, 310], [200, 210], [100, 110], [50, 60], [10, 20], [1, 2]]) == 5570\n assert candidate(tasks = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95]]) == 110\n assert candidate(tasks = [[500, 1000], [400, 900], [300, 800], [200, 700], [100, 600], [50, 500], [40, 400], [30, 300], [20, 200], [10, 100]]) == 2000\n assert candidate(tasks = [[1000, 2000], [500, 1500], [300, 1200], [200, 1100], [100, 1000]]) == 3000\n assert candidate(tasks = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30]]) == 226\n assert candidate(tasks = [[5, 7], [8, 10], [12, 14], [15, 18], [20, 22]]) == 62\n assert candidate(tasks = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]]) == 37\n assert candidate(tasks = [[1, 20], [2, 21], [3, 22], [4, 23], [5, 24], [6, 25]]) == 40\n assert candidate(tasks = [[2, 5], [3, 6], [4, 7], [5, 8], [1, 3]]) == 17\n assert candidate(tasks = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0]]) == 55\n assert candidate(tasks = [[100, 200], [150, 250], [200, 300], [50, 100], [25, 50], [75, 150], [30, 60], [40, 80], [60, 120], [80, 160]]) == 835\n assert candidate(tasks = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]) == 460\n assert candidate(tasks = [[10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70], [10, 80], [10, 90], [10, 100], [10, 110], [10, 120]]) == 120\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16]]) == 16\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 121\n assert candidate(tasks = [[5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20]]) == 60\n assert candidate(tasks = [[5, 7], [8, 12], [10, 15], [3, 4], [6, 9], [2, 3]]) == 35\n assert candidate(tasks = [[2, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30]]) == 80\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 10\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]]) == 210\n assert candidate(tasks = [[5000, 5005], [4000, 4007], [3000, 3009], [2000, 2011], [1000, 1013], [500, 517], [100, 121], [50, 130], [10, 140], [1, 150]]) == 15666\n assert candidate(tasks = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]]) == 160\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 191\n assert candidate(tasks = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]]) == 1036\n assert candidate(tasks = [[7, 10], [5, 7], [4, 5], [3, 6], [2, 4]]) == 22\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [100, 100]]) == 115\n assert candidate(tasks = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]]) == 25\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]]) == 91\n", "comparison": "exact"}, "public_tests": ["[[1,2],[2,4],[4,8]]", "[[1,3],[2,4],[10,11],[10,12],[8,9]]", "[[1,7],[2,8],[3,9],[4,10],[5,11],[6,12]]"], "hints": ["We can easily figure that the f(x) : does x solve this array is monotonic so binary Search is doable", "Figure a sorting pattern"], "metadata": {"canonical_parameter_names": ["tasks"], "leetcode_dataset_entry_point": "Solution().minimumEffort", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:51+00:00", "tests_total": 104, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minimumEffort(self, tasks: list[list[int]]) -> int:", "container": "Solution", "callable": "minimumEffort", "parameters": [{"name": "tasks", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1668, "task_id": "maximum-repeating-substring", "difficulty": "Easy", "problem_description": "For a string sequence, a string word is k-repeating if word concatenated k times is a substring of sequence. The word's maximum k-repeating value is the highest value k where word is k-repeating in sequence. If word is not a substring of sequence, word's maximum k-repeating value is 0.\n\nGiven strings sequence and word, return the maximum k-repeating value of word in sequence.\n\nExample 1:\n\nInput: sequence = \"ababc\", word = \"ab\"\nOutput: 2\nExplanation: \"abab\" is a substring in \"ababc\".\n\nExample 2:\n\nInput: sequence = \"ababc\", word = \"ba\"\nOutput: 1\nExplanation: \"ba\" is a substring in \"ababc\". \"baba\" is not a substring in \"ababc\".\n\nExample 3:\n\nInput: sequence = \"ababc\", word = \"ac\"\nOutput: 0\nExplanation: \"ac\" is not a substring in \"ababc\".\n\nConstraints:\n\n- 1 <= sequence.length <= 100\n- 1 <= word.length <= 100\n- sequence and word contains only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sequence = \"ababc\",word = \"ac\") == 0\n assert candidate(sequence = \"banana\",word = \"ana\") == 1\n assert candidate(sequence = \"abcabcabc\",word = \"abc\") == 3\n assert candidate(sequence = \"aaaa\",word = \"aa\") == 2\n assert candidate(sequence = \"abc\",word = \"d\") == 0\n assert candidate(sequence = \"ababc\",word = \"ab\") == 2\n assert candidate(sequence = \"mississippi\",word = \"issi\") == 1\n assert candidate(sequence = \"aaaabaaa\",word = \"aa\") == 2\n assert candidate(sequence = \"ababc\",word = \"ba\") == 1\n assert candidate(sequence = \"a\",word = \"a\") == 1\n assert candidate(sequence = \"abcabcabc\",word = \"abcd\") == 0\n assert candidate(sequence = \"hellohellohello\",word = \"llohe\") == 2\n assert candidate(sequence = \"abababababab\",word = \"abab\") == 3\n assert candidate(sequence = \"abababababababab\",word = \"ababab\") == 2\n assert candidate(sequence = \"aabbccddeeff\",word = \"aabbcc\") == 1\n assert candidate(sequence = \"ababababab\",word = \"ababab\") == 1\n assert candidate(sequence = \"xyxxyxyxyxyxyxyxyxyxyx\",word = \"xyxxy\") == 1\n assert candidate(sequence = \"abcabcabcabc\",word = \"abcd\") == 0\n assert candidate(sequence = \"ababababab\",word = \"ab\") == 5\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcdabcdabcd\",word = \"abcd\") == 8\n assert candidate(sequence = \"abacabadabacaba\",word = \"dab\") == 1\n assert candidate(sequence = \"abcabcabcabcabcabc\",word = \"abcabcabc\") == 2\n assert candidate(sequence = \"abababababababababab\",word = \"ababab\") == 3\n assert candidate(sequence = \"banana\",word = \"ban\") == 1\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"cab\") == 4\n assert candidate(sequence = \"abacabadabacaba\",word = \"cab\") == 1\n assert candidate(sequence = \"hellohellohellohello\",word = \"hello\") == 4\n assert candidate(sequence = \"banana\",word = \"na\") == 2\n assert candidate(sequence = \"abababababab\",word = \"baba\") == 2\n assert candidate(sequence = \"ababababababababab\",word = \"ababab\") == 3\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcd\") == 0\n assert candidate(sequence = \"xyzyzyzyzyzyzyzy\",word = \"zyzyzyzyzyzyzyzy\") == 0\n assert candidate(sequence = \"zzzxxzzzxxzzzxx\",word = \"zzzxx\") == 3\n assert candidate(sequence = \"aabbccddeeffgghhiijj\",word = \"ccdd\") == 1\n assert candidate(sequence = \"xyzxyzxyzxyzxyz\",word = \"zyx\") == 0\n assert candidate(sequence = \"abcabcabcabc\",word = \"cab\") == 3\n assert candidate(sequence = \"ababababababababab\",word = \"bab\") == 1\n assert candidate(sequence = \"bananaananabana\",word = \"ana\") == 2\n assert candidate(sequence = \"aaaaabaaa\",word = \"aaaa\") == 1\n assert candidate(sequence = \"abacabadabacaba\",word = \"bac\") == 1\n assert candidate(sequence = \"aaaaabbbbbcccc\",word = \"abc\") == 0\n assert candidate(sequence = \"aaaaaaa\",word = \"aaa\") == 2\n assert candidate(sequence = \"zzzzzzzzzzzz\",word = \"zzzz\") == 3\n assert candidate(sequence = \"ababababa\",word = \"aba\") == 1\n assert candidate(sequence = \"abababcabababc\",word = \"ababc\") == 1\n assert candidate(sequence = \"ababababababababababababababab\",word = \"abab\") == 7\n assert candidate(sequence = \"aaaabaaaabaaaab\",word = \"aaab\") == 1\n assert candidate(sequence = \"abababababababab\",word = \"baba\") == 3\n assert candidate(sequence = \"xyzyzyzyzyzyzyzy\",word = \"zyzy\") == 3\n assert candidate(sequence = \"abcabcabcabc\",word = \"abcabc\") == 2\n assert candidate(sequence = \"aaaabaaaabaaaabaaaab\",word = \"aaaab\") == 4\n assert candidate(sequence = \"abcabcabc\",word = \"cab\") == 2\n assert candidate(sequence = \"abababababababababab\",word = \"abab\") == 5\n assert candidate(sequence = \"abacabadabacaba\",word = \"abaca\") == 1\n assert candidate(sequence = \"aaaaaaa\",word = \"a\") == 7\n assert candidate(sequence = \"aabbccddeeff\",word = \"abc\") == 0\n assert candidate(sequence = \"abcabcabcabcabcabcabc\",word = \"abca\") == 1\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcabcab\") == 1\n assert candidate(sequence = \"abcdefabcdefabcdef\",word = \"defabc\") == 2\n assert candidate(sequence = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word = \"aabbccddeeffgghhiijjkkll\") == 1\n assert candidate(sequence = \"abcdefabcdefabcdef\",word = \"abcdef\") == 3\n assert candidate(sequence = \"zzzzzzzzzzzzzzzzzzzz\",word = \"zzzzzz\") == 3\n assert candidate(sequence = \"xyzxyzxyzxyzxyzxyz\",word = \"xyzxyzxyz\") == 2\n assert candidate(sequence = \"abababab\",word = \"ab\") == 4\n assert candidate(sequence = \"abacabacabacabacabac\",word = \"abac\") == 5\n assert candidate(sequence = \"aaaaab\",word = \"aaa\") == 1\n assert candidate(sequence = \"aaaaaaa\",word = \"aaaa\") == 1\n assert candidate(sequence = \"ababababababababababab\",word = \"babab\") == 1\n assert candidate(sequence = \"abababab\",word = \"aba\") == 1\n assert candidate(sequence = \"aaaaaabaaa\",word = \"aaa\") == 2\n assert candidate(sequence = \"aaaaabaaaa\",word = \"aaa\") == 1\n assert candidate(sequence = \"ababababab\",word = \"aba\") == 1\n assert candidate(sequence = \"hellohellohellohellohello\",word = \"hellohello\") == 2\n assert candidate(sequence = \"abcabcabcabcabcabcabcabcabcabc\",word = \"abcabcabc\") == 3\n assert candidate(sequence = \"aabbccddeeefffggghhh\",word = \"eefffggg\") == 1\n assert candidate(sequence = \"mississippi\",word = \"iss\") == 2\n assert candidate(sequence = \"abacabacabac\",word = \"abac\") == 3\n assert candidate(sequence = \"xyxyxyxyxyxyxyxy\",word = \"xyxyxyxyxyxyxy\") == 1\n assert candidate(sequence = \"abcabcabcabcabcabcabcabc\",word = \"abcabcabc\") == 2\n assert candidate(sequence = \"aabbccddeeffgghhiijj\",word = \"aabbcc\") == 1\n assert candidate(sequence = \"xyxyxyxyxyxyxyxyxyxy\",word = \"xyxy\") == 5\n assert candidate(sequence = \"xyxyxyxyxyxyxy\",word = \"xyxy\") == 3\n assert candidate(sequence = \"zzzzzzzzzzzzzzzzzzzz\",word = \"zzzz\") == 5\n assert candidate(sequence = \"mississippi\",word = \"miss\") == 1\n assert candidate(sequence = \"ababababababababab\",word = \"ab\") == 9\n assert candidate(sequence = \"hellohellohellohello\",word = \"hellohello\") == 2\n assert candidate(sequence = \"banana\",word = \"nan\") == 1\n assert candidate(sequence = \"abababaaba\",word = \"aba\") == 2\n assert candidate(sequence = \"hellohellohello\",word = \"lohel\") == 2\n assert candidate(sequence = \"qqqqqqqqqqqq\",word = \"qqqq\") == 3\n assert candidate(sequence = \"xyxxyxyxyxyxyx\",word = \"xyxyx\") == 1\n assert candidate(sequence = \"abcdabcdabcdabcd\",word = \"abcdabcd\") == 2\n assert candidate(sequence = \"sequencewordsequenceword\",word = \"word\") == 1\n assert candidate(sequence = \"abababa\",word = \"aba\") == 1\n assert candidate(sequence = \"xyxyxyxyxyxyxyxy\",word = \"xyxy\") == 4\n assert candidate(sequence = \"abcdefgabcdefgabcdefg\",word = \"abcdefg\") == 3\n assert candidate(sequence = \"abababababababababababab\",word = \"abababab\") == 3\n assert candidate(sequence = \"aaaabaaaabaaaabaaaab\",word = \"aaab\") == 1\n assert candidate(sequence = \"ababababababababab\",word = \"abab\") == 4\n assert candidate(sequence = \"abcdefghijabcdefghij\",word = \"cde\") == 1\n assert candidate(sequence = \"mamamamamamama\",word = \"mama\") == 3\n assert candidate(sequence = \"ababababababab\",word = \"abab\") == 3\n assert candidate(sequence = \"hellohellohello\",word = \"hello\") == 3\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcabcabcabc\") == 1\n assert candidate(sequence = \"xyzxyzxyzxyz\",word = \"xyz\") == 4\n assert candidate(sequence = \"abcabcabcabcabcabc\",word = \"bcabc\") == 1\n assert candidate(sequence = \"abababababababab\",word = \"abab\") == 4\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcdabcdabcd\",word = \"dabc\") == 7\n assert candidate(sequence = \"mississippiissippi\",word = \"issi\") == 1\n assert candidate(sequence = \"xyzxyzxyz\",word = \"xy\") == 1\n assert candidate(sequence = \"abcabcabcabcabcabcabc\",word = \"abcabcabcabcabc\") == 1\n assert candidate(sequence = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word = \"zzzz\") == 7\n assert candidate(sequence = \"abcabcabcabcabcabc\",word = \"abcabc\") == 3\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcdabcdabcd\",word = \"dcba\") == 0\n assert candidate(sequence = \"qwertyqwertyqwerty\",word = \"qwerty\") == 3\n assert candidate(sequence = \"acacacacacac\",word = \"acac\") == 3\n assert candidate(sequence = \"ababababa\",word = \"bab\") == 1\n assert candidate(sequence = \"ababcabcababc\",word = \"abcab\") == 1\n assert candidate(sequence = \"aaaaaaaaaa\",word = \"aaa\") == 3\n assert candidate(sequence = \"aaaaaaaaaa\",word = \"aaaa\") == 2\n assert candidate(sequence = \"mississippi\",word = \"sip\") == 1\n assert candidate(sequence = \"aaaaaaa\",word = \"aa\") == 3\n assert candidate(sequence = \"aaaaaabaaaaa\",word = \"aaaaa\") == 1\n assert candidate(sequence = \"xyzxyzxyzxyz\",word = \"xyzxyz\") == 2\n assert candidate(sequence = \"ababababc\",word = \"aba\") == 1\n assert candidate(sequence = \"abcabcabcabcabcabc\",word = \"cab\") == 5\n assert candidate(sequence = \"abacabacabacabac\",word = \"abacabac\") == 2\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcabcabc\") == 1\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcabc\") == 2\n assert candidate(sequence = \"xyzxyzyzyzxzyzyzxzyzyz\",word = \"zyz\") == 1\n assert candidate(sequence = \"xyzxyzxyzxyz\",word = \"zyxzyx\") == 0\n assert candidate(sequence = \"xyzxyzxyzxyz\",word = \"xyzxyzxyz\") == 1\n assert candidate(sequence = \"aaaaaa\",word = \"aa\") == 3\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcdabcdabcd\",word = \"abcdabcdabcdabcd\") == 2\n assert candidate(sequence = \"abcdabcdabcdabcd\",word = \"cdab\") == 3\n assert candidate(sequence = \"zzzzzzzz\",word = \"zzzz\") == 2\n assert candidate(sequence = \"abcdefgabcdefgabcdefg\",word = \"efg\") == 1\n assert candidate(sequence = \"zzzzzzzzzzzzzzzzzzzz\",word = \"zzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(sequence = \"abcdefgabcdefg\",word = \"abcdefg\") == 2\n assert candidate(sequence = \"bananaananabananananabanananananana\",word = \"anana\") == 2\n assert candidate(sequence = \"qwertyqwertyqwerty\",word = \"erty\") == 1\n assert candidate(sequence = \"pqrspqrspqrspqrspqr\",word = \"pqrs\") == 4\n assert candidate(sequence = \"ababababababa\",word = \"bab\") == 1\n assert candidate(sequence = \"abcbabcabcbabcabc\",word = \"abcabc\") == 1\n assert candidate(sequence = \"qwertyqwertyqwerty\",word = \"qwertyqwerty\") == 1\n assert candidate(sequence = \"zzzzzzzzzzzz\",word = \"zzz\") == 4\n assert candidate(sequence = \"zzzzzzzzzzzzzzz\",word = \"zzzz\") == 3\n assert candidate(sequence = \"xyzxyzxyz\",word = \"xyz\") == 3\n assert candidate(sequence = \"aabbccddeeff\",word = \"eeff\") == 1\n assert candidate(sequence = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word = \"mmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(sequence = \"ababababab\",word = \"abab\") == 2\n assert candidate(sequence = \"xyxyxyxyxyxyxyxy\",word = \"xyxyxyxyxyxyxyxy\") == 1\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcd\",word = \"abcdabcd\") == 3\n assert candidate(sequence = \"qwertyqwertyqwertyqwerty\",word = \"qwertyqwerty\") == 2\n", "comparison": "exact"}, "public_tests": ["\"ababc\"\n\"ab\"", "\"ababc\"\n\"ba\"", "\"ababc\"\n\"ac\""], "hints": ["The constraints are low enough for a brute force approach.", "Try every k value from 0 upwards until word is no longer k-repeating."], "metadata": {"canonical_parameter_names": ["sequence", "word"], "leetcode_dataset_entry_point": "Solution().maxRepeating", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:53+00:00", "tests_total": 154, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming", "string-matching"]}, "language": "python", "interface": {"raw_signature": "def maxRepeating(self, sequence: str, word: str) -> int:", "container": "Solution", "callable": "maxRepeating", "parameters": [{"name": "sequence", "type": "str"}, {"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1671, "task_id": "minimum-number-of-removals-to-make-mountain-array", "difficulty": "Hard", "problem_description": "You may recall that an array arr is a mountain array if and only if:\n\n- arr.length >= 3\n- There exists some index i (0-indexed) with 0 < i < arr.length - 1 such that:\n - arr[0] < arr[1] < ... < arr[i - 1] < arr[i]\n - arr[i] > arr[i + 1] > ... > arr[arr.length - 1]\n\nGiven an integer array nums, return the minimum number of elements to remove to make nums a mountain array.\n\nExample 1:\n\nInput: nums = [1,3,1]\nOutput: 0\nExplanation: The array itself is a mountain array so we do not need to remove any elements.\n\nExample 2:\n\nInput: nums = [2,1,1,5,6,2,3,1]\nOutput: 3\nExplanation: One solution is to remove the elements at indices 0, 1, and 5, making the array nums = [1,5,6,3,1].\n\nConstraints:\n\n- 3 <= nums.length <= 1000\n- 1 <= nums[i] <= 10^9\n- It is guaranteed that you can make a mountain array out of nums.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 1]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [100, 92, 89, 77, 74, 66, 64, 66, 64]) == 6\n assert candidate(nums = [1, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [4, 3, 2, 1, 1, 2, 3, 1]) == 4\n assert candidate(nums = [2, 1, 1, 5, 6, 2, 3, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 1, 5, 7, 6, 3, 2]) == 1\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [9, 8, 1, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 3, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 2, 1, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 10, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12]) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 3, 5, 7, 9, 11]) == 5\n assert candidate(nums = [20, 40, 30, 50, 60, 70, 35, 10, 5, 45, 65, 75, 25, 55, 85, 95, 15, 25, 35, 45]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 8, 6, 4, 2]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(nums = [10, 20, 15, 20, 25, 30, 25, 20, 15, 10, 5, 10, 15, 20]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 54\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 19\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 40\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 14\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 2, 1, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 27\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1]) == 8\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 15, 25, 35, 45, 55, 65, 75, 85, 95, 100, 5, 10, 15]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 24\n assert candidate(nums = [4, 3, 2, 1, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [2, 3, 1, 4, 3, 2, 5, 4, 3, 2, 1, 6, 7, 8, 7, 6, 5, 4, 3]) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 20\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 29\n assert candidate(nums = [1, 5, 3, 7, 5, 9, 7, 11, 9, 13, 11, 15, 13, 17, 15, 19, 17]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 14\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 20\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 11\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15]) == 13\n assert candidate(nums = [1, 5, 3, 4, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 13\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 0\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91, 11, 90, 12, 89, 13, 88]) == 12\n assert candidate(nums = [1, 5, 3, 4, 6, 7, 8, 9, 10, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [3, 5, 4, 5, 4, 3, 5, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 5]) == 12\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 125, 120, 115, 110, 105, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15]) == 7\n assert candidate(nums = [1, 1000000000, 999999999, 1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n", "comparison": "exact"}, "public_tests": ["[1,3,1]", "[2,1,1,5,6,2,3,1]"], "hints": ["Think the opposite direction instead of minimum elements to remove the maximum mountain subsequence", "Think of LIS it's kind of close"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumMountainRemovals", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:58+00:00", "tests_total": 107, "tests_dropped": 11, "flags": [], "topic_tags": ["array", "binary-search", "dynamic-programming", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minimumMountainRemovals(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minimumMountainRemovals", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1672, "task_id": "richest-customer-wealth", "difficulty": "Easy", "problem_description": "You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the i^th customer has in the j^th bank. Return the wealth that the richest customer has.\n\nA customer's wealth is the amount of money they have in all their bank accounts. The richest customer is the customer that has the maximum wealth.\n\nExample 1:\n\nInput: accounts = [[1,2,3],[3,2,1]]\nOutput: 6\nExplanation:\n1st customer has wealth = 1 + 2 + 3 = 6\n2nd customer has wealth = 3 + 2 + 1 = 6\nBoth customers are considered the richest with a wealth of 6 each, so return 6.\n\nExample 2:\n\nInput: accounts = [[1,5],[7,3],[3,5]]\nOutput: 10\nExplanation:\n1st customer has wealth = 6\n2nd customer has wealth = 10\n3rd customer has wealth = 8\nThe 2nd customer is the richest with a wealth of 10.\n\nExample 3:\n\nInput: accounts = [[2,8,7],[7,1,3],[1,9,5]]\nOutput: 17\n\nConstraints:\n\n- m == accounts.length\n- n == accounts[i].length\n- 1 <= m, n <= 50\n- 1 <= accounts[i][j] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(accounts = [[10, 10], [20, 20], [30, 30], [40, 40]]) == 80\n assert candidate(accounts = [[100], [100], [100]]) == 100\n assert candidate(accounts = [[10, 20, 30], [5, 15, 25], [1, 2, 3]]) == 60\n assert candidate(accounts = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 3\n assert candidate(accounts = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == 25\n assert candidate(accounts = [[50, 50], [50, 50], [50, 50]]) == 100\n assert candidate(accounts = [[1, 2], [3, 4], [5, 6], [7, 8]]) == 15\n assert candidate(accounts = [[1, 5], [7, 3], [3, 5]]) == 10\n assert candidate(accounts = [[10, 10, 10], [5, 5, 5], [1, 1, 1]]) == 30\n assert candidate(accounts = [[1], [2], [3]]) == 3\n assert candidate(accounts = [[2, 8, 7], [7, 1, 3], [1, 9, 5]]) == 17\n assert candidate(accounts = [[1, 2, 3], [3, 2, 1]]) == 6\n assert candidate(accounts = [[1], [2], [3], [4], [5]]) == 5\n assert candidate(accounts = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == 190\n assert candidate(accounts = [[1, 100, 1], [10, 50, 10], [100, 1, 100], [50, 10, 50]]) == 201\n assert candidate(accounts = [[99, 1, 2, 3], [4, 5, 6, 99], [7, 8, 9, 10]]) == 114\n assert candidate(accounts = [[10, 20, 30, 40, 50], [90, 80, 70, 60, 50], [1, 2, 3, 4, 5]]) == 350\n assert candidate(accounts = [[50, 1, 50], [1, 50, 50], [50, 50, 1], [50, 1, 50], [1, 50, 50], [50, 50, 1]]) == 101\n assert candidate(accounts = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 2, 3, 4, 5]]) == 150\n assert candidate(accounts = [[99, 1, 1, 1, 1], [1, 99, 1, 1, 1], [1, 1, 99, 1, 1], [1, 1, 1, 99, 1], [1, 1, 1, 1, 99]]) == 103\n assert candidate(accounts = [[90, 5], [5, 90], [45, 55], [55, 45], [75, 25], [25, 75], [60, 40], [40, 60]]) == 100\n assert candidate(accounts = [[100, 100, 100, 100, 100], [99, 99, 99, 99, 99], [98, 98, 98, 98, 98], [97, 97, 97, 97, 97], [96, 96, 96, 96, 96]]) == 500\n assert candidate(accounts = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == 30\n assert candidate(accounts = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4], [5, 5, 5, 5, 5]]) == 25\n assert candidate(accounts = [[10, 20, 30], [50, 60, 70], [80, 90, 100], [10, 10, 10]]) == 270\n assert candidate(accounts = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [60, 60, 60], [70, 70, 70], [80, 80, 80], [90, 90, 90], [100, 100, 100]]) == 300\n assert candidate(accounts = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == 190\n assert candidate(accounts = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == 30\n assert candidate(accounts = [[99, 1], [1, 99], [49, 51], [51, 49], [50, 50]]) == 100\n assert candidate(accounts = [[30, 20, 10], [10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 30, 20]]) == 60\n assert candidate(accounts = [[50, 50, 50], [50, 50, 50], [50, 50, 50], [50, 50, 50], [50, 50, 50]]) == 150\n assert candidate(accounts = [[99, 1], [98, 2], [97, 3], [96, 4], [95, 5], [94, 6], [93, 7], [92, 8], [91, 9], [90, 10]]) == 100\n assert candidate(accounts = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]]) == 90\n assert candidate(accounts = [[1, 99], [2, 98], [3, 97], [4, 96], [5, 95]]) == 100\n assert candidate(accounts = [[45, 55], [46, 54], [47, 53], [48, 52], [49, 51]]) == 100\n assert candidate(accounts = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [10, 9, 8, 7, 6], [6, 7, 8, 9, 10]]) == 40\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 55\n assert candidate(accounts = [[99, 1, 100], [100, 1, 99], [50, 50, 50]]) == 200\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 55\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 120\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]]) == 500\n assert candidate(accounts = [[100, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 100, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 100, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 100, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 100, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 100, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 100, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 100, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 100, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 100]]) == 109\n assert candidate(accounts = [[90, 90, 90, 90, 90], [80, 80, 80, 80, 80], [70, 70, 70, 70, 70], [60, 60, 60, 60, 60], [50, 50, 50, 50, 50]]) == 450\n assert candidate(accounts = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]]) == 20\n assert candidate(accounts = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 40\n assert candidate(accounts = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 2, 3, 4, 5], [50, 40, 30, 20, 10]]) == 150\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 100\n assert candidate(accounts = [[10, 10, 10, 10], [20, 20, 20, 20], [30, 30, 30, 30], [40, 40, 40, 40]]) == 160\n assert candidate(accounts = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 100\n", "comparison": "exact"}, "public_tests": ["[[1,2,3],[3,2,1]]", "[[1,5],[7,3],[3,5]]", "[[2,8,7],[7,1,3],[1,9,5]]"], "hints": ["Calculate the wealth of each customer", "Find the maximum element in array."], "metadata": {"canonical_parameter_names": ["accounts"], "leetcode_dataset_entry_point": "Solution().maximumWealth", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:00+00:00", "tests_total": 85, "tests_dropped": 36, "flags": [], "topic_tags": ["array", "matrix"]}, "language": "python", "interface": {"raw_signature": "def maximumWealth(self, accounts: list[list[int]]) -> int:", "container": "Solution", "callable": "maximumWealth", "parameters": [{"name": "accounts", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1673, "task_id": "find-the-most-competitive-subsequence", "difficulty": "Medium", "problem_description": "Given an integer array nums and a positive integer k, return the most competitive subsequence of nums of size k.\n\nAn array's subsequence is a resulting sequence obtained by erasing some (possibly zero) elements from the array.\n\nWe define that a subsequence a is more competitive than a subsequence b (of the same length) if in the first position where a and b differ, subsequence a has a number less than the corresponding number in b. For example, [1,3,4] is more competitive than [1,3,5] because the first position they differ is at the final number, and 4 is less than 5.\n\nExample 1:\n\nInput: nums = [3,5,2,6], k = 2\nOutput: [2,6]\nExplanation: Among the set of every possible subsequence: {[3,5], [3,2], [3,6], [5,2], [5,6], [2,6]}, [2,6] is the most competitive.\n\nExample 2:\n\nInput: nums = [2,4,3,3,5,4,9,6], k = 4\nOutput: [2,3,3,4]\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= nums[i] <= 10^9\n- 1 <= k <= nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 9, 8, 7, 6, 5, 4, 3, 2],k = 1) == [1]\n assert candidate(nums = [2, 4, 3, 3, 5, 4, 9, 6],k = 4) == [2, 3, 3, 4]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == [5, 4, 3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7],k = 3) == [1, 2, 3]\n assert candidate(nums = [1, 3, 1, 1, 2, 3, 1],k = 4) == [1, 1, 1, 1]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],k = 3) == [3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == [1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == [1, 2, 3]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],k = 2) == [1, 1]\n assert candidate(nums = [3, 5, 2, 6],k = 2) == [2, 6]\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 2) == [1, 2]\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1],k = 2) == [1, 1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10],k = 5) == [2, 1, 8, 9, 10]\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5) == [50, 40, 30, 20, 10]\n assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [100, 200, 150, 250, 300, 100, 200, 300, 100, 200],k = 6) == [100, 100, 200, 300, 100, 200]\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2],k = 5) == [1, 1, 2, 1, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 6) == [1, 1, 2, 3, 4, 5]\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10],k = 10) == [5, 6, 7, 8, 9, 1, 2, 3, 4, 10]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 8, 9],k = 5) == [3, 2, 1, 8, 9]\n assert candidate(nums = [5, 1, 4, 3, 2, 6, 7, 8, 9, 10],k = 5) == [1, 2, 6, 7, 8]\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10],k = 7) == [5, 6, 1, 2, 3, 4, 10]\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1],k = 4) == [1, 1, 1, 1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [10, 20, 30, 40, 50]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 3) == [10, 10, 10]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 4) == [1, 1, 2, 3]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == [2, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == [1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],k = 3) == [1, 1, 1]\n assert candidate(nums = [9, 1, 9, 2, 9, 3, 9, 4, 9, 5],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [10, 5, 6, 3, 2, 1, 8, 7],k = 3) == [1, 8, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],k = 5) == [1, 2, 3, 4, 0]\n assert candidate(nums = [5, 3, 1, 2, 4, 6, 8, 7, 9, 0],k = 5) == [1, 2, 4, 6, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [8, 6, 9, 2, 5, 7, 8, 8],k = 4) == [2, 5, 7, 8]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 3) == [1, 2, 3]\n assert candidate(nums = [1, 3, 1, 1, 2, 3, 4, 1, 5, 6],k = 3) == [1, 1, 1]\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 5) == [3, 3, 3, 3, 3]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == [3, 2, 1]\n assert candidate(nums = [1, 3, 1, 1, 2, 3, 1, 2, 3, 1],k = 4) == [1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1],k = 4) == [1, 1, 1, 1]\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10],k = 5) == [1, 6, 7, 8, 9]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],k = 6) == [1, 1, 2, 3, 5, 9]\n assert candidate(nums = [1, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == [1, 2, 1]\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10],k = 7) == [1, 2, 3, 4, 6, 5, 10]\n assert candidate(nums = [5, 3, 1, 2, 4, 1, 3, 2, 1, 4, 2, 3],k = 6) == [1, 1, 1, 4, 2, 3]\n assert candidate(nums = [5, 1, 4, 3, 5, 9, 2, 1, 4, 7, 8, 1],k = 7) == [1, 2, 1, 4, 7, 8, 1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 8) == [1, 1, 2, 2, 3, 3, 4, 4]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7],k = 8) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [100, 200, 150, 100, 50, 250, 300, 200, 150],k = 5) == [50, 250, 300, 200, 150]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == [0, 0, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == [1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 10) == [0, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 7) == [10, 20, 30, 40, 50, 60, 70]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 5) == [10, 10, 10, 10, 10]\n assert candidate(nums = [1, 5, 4, 3, 2, 6],k = 3) == [1, 2, 6]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 7) == [3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [5, 6, 1, 2, 3, 4, 10, 9, 8, 7],k = 4) == [1, 2, 3, 4]\n assert candidate(nums = [8, 9, 7, 6, 5, 4, 3, 2, 1],k = 4) == [4, 3, 2, 1]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 6) == [1, 1, 1, 1, 2, 3]\n assert candidate(nums = [5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5],k = 6) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == [5, 5, 5, 5, 5]\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 0],k = 5) == [1, 2, 3, 4, 0]\n assert candidate(nums = [7, 1, 5, 3, 6, 4],k = 3) == [1, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [7, 14, 4, 14, 13, 2, 6, 13],k = 5) == [4, 13, 2, 6, 13]\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 4, 3, 2, 1],k = 4) == [1, 1, 2, 1]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 6) == [1, 2, 4, 6, 8, 10]\n assert candidate(nums = [5, 1, 9, 7, 3, 8, 2, 4, 6],k = 4) == [1, 2, 4, 6]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 5) == [1, 1, 2, 2, 3]\n assert candidate(nums = [8, 6, 5, 7, 3, 4, 1, 2, 9, 0],k = 4) == [1, 2, 9, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 4) == [1, 1, 2, 2]\n assert candidate(nums = [4, 3, 5, 1, 2, 3, 6, 7, 8, 9],k = 5) == [1, 2, 3, 6, 7]\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9],k = 5) == [1, 6, 7, 8, 9]\n assert candidate(nums = [4, 3, 2, 1, 2, 3, 4, 3, 2, 1],k = 5) == [1, 2, 3, 2, 1]\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 0],k = 6) == [1, 2, 3, 4, 5, 0]\n assert candidate(nums = [1, 3, 2, 1, 2, 1, 3, 2, 1],k = 3) == [1, 1, 1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5],k = 10) == [4, 3, 2, 1, 0, 9, 8, 7, 6, 5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 15) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9],k = 3) == [1, 1, 1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 6) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == [100, 200, 300, 400, 500]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],k = 3) == [1, 2, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 10) == [0, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 8, 9],k = 5) == [2, 1, 0, 8, 9]\n assert candidate(nums = [1, 3, 2, 4, 1, 2, 3, 1, 2, 3],k = 4) == [1, 1, 1, 2]\n assert candidate(nums = [5, 2, 6, 3, 4, 1],k = 2) == [2, 1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 5) == [7, 7, 7, 7, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],k = 12) == [1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(nums = [5, 3, 1, 4, 2, 6, 8, 7, 9, 0, 11, 10, 12, 13, 14],k = 10) == [1, 2, 6, 7, 0, 11, 10, 12, 13, 14]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n", "comparison": "exact"}, "public_tests": ["[3,5,2,6]\n2", "[2,4,3,3,5,4,9,6]\n4"], "hints": ["In lexicographical order, the elements to the left have higher priority than those that come after. Can you think of a strategy that incrementally builds the answer from left to right?"], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().mostCompetitive", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:03+00:00", "tests_total": 106, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "stack", "greedy", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def mostCompetitive(self, nums: list[int], k: int) -> list[int]:", "container": "Solution", "callable": "mostCompetitive", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1674, "task_id": "minimum-moves-to-make-array-complementary", "difficulty": "Medium", "problem_description": "You are given an integer array nums of even length n and an integer limit. In one move, you can replace any integer from nums with another integer between 1 and limit, inclusive.\n\nThe array nums is complementary if for all indices i (0-indexed), nums[i] + nums[n - 1 - i] equals the same number. For example, the array [1,2,3,4] is complementary because for all indices i, nums[i] + nums[n - 1 - i] = 5.\n\nReturn the minimum number of moves required to make nums complementary.\n\nExample 1:\n\nInput: nums = [1,2,4,3], limit = 4\nOutput: 1\nExplanation: In 1 move, you can change nums to [1,2,2,3] (underlined elements are changed).\nnums[0] + nums[3] = 1 + 3 = 4.\nnums[1] + nums[2] = 2 + 2 = 4.\nnums[2] + nums[1] = 2 + 2 = 4.\nnums[3] + nums[0] = 3 + 1 = 4.\nTherefore, nums[i] + nums[n-1-i] = 4 for every i, so nums is complementary.\n\nExample 2:\n\nInput: nums = [1,2,2,1], limit = 2\nOutput: 2\nExplanation: In 2 moves, you can change nums to [2,2,2,2]. You cannot change any number to 3 since 3 > limit.\n\nExample 3:\n\nInput: nums = [1,2,1,2], limit = 2\nOutput: 0\nExplanation: nums is already complementary.\n\nConstraints:\n\n- n == nums.length\n- 2 <= n <= 10^5\n- 1 <= nums[i] <= limit <= 10^5\n- n is even.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 3, 3, 3],limit = 5) == 0\n assert candidate(nums = [1, 1, 1, 1],limit = 10) == 0\n assert candidate(nums = [5, 3, 5, 3],limit = 10) == 0\n assert candidate(nums = [1, 5, 5, 1],limit = 5) == 2\n assert candidate(nums = [1, 2, 2, 1],limit = 2) == 2\n assert candidate(nums = [100000, 1, 100000, 1],limit = 100000) == 0\n assert candidate(nums = [100000, 1, 1, 100000],limit = 100000) == 2\n assert candidate(nums = [100000, 1, 1, 100000, 1, 1, 100000, 1],limit = 100000) == 1\n assert candidate(nums = [3, 5, 5, 3],limit = 5) == 1\n assert candidate(nums = [1, 1, 1, 1],limit = 1) == 0\n assert candidate(nums = [1, 5, 9, 13],limit = 15) == 0\n assert candidate(nums = [1, 3, 5, 7],limit = 10) == 0\n assert candidate(nums = [2, 5, 6, 5, 2, 2],limit = 7) == 2\n assert candidate(nums = [1, 9, 9, 1, 1, 9, 9, 1],limit = 9) == 4\n assert candidate(nums = [10, 1, 10, 1],limit = 10) == 0\n assert candidate(nums = [100000, 100000, 100000, 100000],limit = 100000) == 0\n assert candidate(nums = [10, 15, 15, 10],limit = 20) == 1\n assert candidate(nums = [2, 3, 4, 3, 2, 1],limit = 6) == 2\n assert candidate(nums = [1, 9, 9, 1],limit = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6],limit = 6) == 0\n assert candidate(nums = [10, 1, 1, 10],limit = 10) == 2\n assert candidate(nums = [5, 5, 5, 5],limit = 10) == 0\n assert candidate(nums = [50000, 50000, 50000, 50000],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6],limit = 7) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5],limit = 5) == 0\n assert candidate(nums = [1, 3, 2, 4],limit = 5) == 0\n assert candidate(nums = [1, 2, 4, 3],limit = 4) == 1\n assert candidate(nums = [5, 5, 5, 5],limit = 5) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3],limit = 6) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3],limit = 3) == 0\n assert candidate(nums = [1, 2, 1, 2],limit = 2) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 20) == 0\n assert candidate(nums = [1, 100000, 50000, 50000, 100000, 1],limit = 100000) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 2) == 0\n assert candidate(nums = [30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000],limit = 60000) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],limit = 6) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],limit = 16) == 0\n assert candidate(nums = [25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000],limit = 50000) == 0\n assert candidate(nums = [100000, 1, 2, 99999, 3, 99998, 4, 99997],limit = 100000) == 3\n assert candidate(nums = [1, 100000, 1, 100000, 2, 99999, 2, 99999],limit = 100000) == 2\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1],limit = 100000) == 0\n assert candidate(nums = [1, 100000, 100000, 1],limit = 100000) == 2\n assert candidate(nums = [10000, 90000, 20000, 80000, 30000, 70000],limit = 100000) == 2\n assert candidate(nums = [25000, 25001, 25002, 24999, 25003, 24998, 25004, 24997],limit = 50000) == 3\n assert candidate(nums = [30000, 70000, 40000, 60000, 50000, 50000, 40000, 60000, 30000, 70000],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],limit = 30) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 21) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 100) == 0\n assert candidate(nums = [99999, 1, 99999, 1, 99999, 1],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],limit = 12) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],limit = 10) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80],limit = 80) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 100000) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 50, 40, 30, 20, 10, 1],limit = 100) == 5\n assert candidate(nums = [1, 99999, 99999, 1, 1, 99999, 99999, 1, 1, 99999, 99999, 1],limit = 100000) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4],limit = 4) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 10) == 0\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 30) == 0\n assert candidate(nums = [5, 3, 5, 3, 2, 8, 8, 2],limit = 10) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1) == 0\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3],limit = 6) == 0\n assert candidate(nums = [1, 2, 3, 3, 2, 1, 4, 4, 3, 3, 2, 2, 1, 1],limit = 5) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 2) == 0\n assert candidate(nums = [25, 75, 25, 75, 25, 75, 25, 75, 25, 75, 25, 75, 25, 75, 25, 75],limit = 100) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],limit = 100) == 0\n assert candidate(nums = [50000, 1, 50000, 1, 50000, 1, 50000, 1],limit = 100000) == 0\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],limit = 84) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 5) == 0\n assert candidate(nums = [1, 100000, 1, 100000],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],limit = 15) == 0\n assert candidate(nums = [10000, 20000, 30000, 40000, 40000, 30000, 20000, 10000],limit = 50000) == 3\n assert candidate(nums = [99999, 1, 1, 99999],limit = 100000) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6],limit = 10) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],limit = 13) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],limit = 20) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 11) == 9\n assert candidate(nums = [90000, 10000, 80000, 20000, 70000, 30000, 60000, 40000],limit = 100000) == 3\n assert candidate(nums = [1, 5, 9, 13, 17, 21],limit = 22) == 0\n assert candidate(nums = [50000, 40000, 30000, 20000, 10000, 10000, 20000, 30000, 40000, 50000],limit = 100000) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 110) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],limit = 5) == 0\n assert candidate(nums = [1, 99999, 99998, 2, 99997, 3, 99996, 4],limit = 100000) == 3\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],limit = 12) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 20) == 0\n assert candidate(nums = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5],limit = 100000) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 0\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],limit = 50000) == 0\n assert candidate(nums = [99999, 99998, 1, 2, 3, 4, 5, 6],limit = 100000) == 3\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],limit = 5) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 0\n assert candidate(nums = [50, 51, 52, 49, 53, 48, 54, 47],limit = 100) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],limit = 16) == 0\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996],limit = 100000) == 3\n assert candidate(nums = [100000, 1, 2, 99998, 3, 99997, 4, 99996],limit = 100000) == 3\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 2, 3, 2, 3, 2, 3, 2],limit = 5) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],limit = 25) == 0\n assert candidate(nums = [10000, 90000, 10000, 90000, 10000, 90000, 10000, 90000],limit = 100000) == 0\n assert candidate(nums = [10, 20, 30, 40, 40, 30, 20, 10],limit = 50) == 3\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40],limit = 50) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],limit = 110) == 9\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],limit = 21) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],limit = 15) == 0\n assert candidate(nums = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],limit = 100000) == 0\n assert candidate(nums = [3, 7, 11, 11, 7, 3],limit = 14) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],limit = 15) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800],limit = 900) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 20) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 0\n", "comparison": "exact"}, "public_tests": ["[1,2,4,3]\n4", "[1,2,2,1]\n2", "[1,2,1,2]\n2"], "hints": ["Given a target sum x, each pair of nums[i] and nums[n-1-i] would either need 0, 1, or 2 modifications.", "Can you find the optimal target sum x value such that the sum of modifications is minimized?", "Create a difference array to efficiently sum all the modifications."], "metadata": {"canonical_parameter_names": ["nums", "limit"], "leetcode_dataset_entry_point": "Solution().minMoves", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:05+00:00", "tests_total": 112, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minMoves(self, nums: list[int], limit: int) -> int:", "container": "Solution", "callable": "minMoves", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "limit", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1675, "task_id": "minimize-deviation-in-array", "difficulty": "Hard", "problem_description": "You are given an array nums of n positive integers.\n\nYou can perform two types of operations on any element of the array any number of times:\n\n- If the element is even, divide it by 2.\n - For example, if the array is [1,2,3,4], then you can do this operation on the last element, and the array will be [1,2,3,2].\n- If the element is odd, multiply it by 2.\n - For example, if the array is [1,2,3,4], then you can do this operation on the first element, and the array will be [2,2,3,4].\n\nThe deviation of the array is the maximum difference between any two elements in the array.\n\nReturn the minimum deviation the array can have after performing some number of operations.\n\nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: 1\nExplanation: You can transform the array to [1,2,3,2], then to [2,2,3,2], then the deviation will be 3 - 2 = 1.\n\nExample 2:\n\nInput: nums = [4,1,5,20,3]\nOutput: 3\nExplanation: You can transform the array after two operations to [4,2,5,5,3], then the deviation will be 5 - 2 = 3.\n\nExample 3:\n\nInput: nums = [2,10,8]\nOutput: 3\n\nConstraints:\n\n- n == nums.length\n- 2 <= n <= 5 * 10^4\n- 1 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1000000000]) == 1953123\n assert candidate(nums = [3, 9, 6, 12]) == 3\n assert candidate(nums = [3, 9, 7, 3]) == 3\n assert candidate(nums = [2, 10, 8]) == 3\n assert candidate(nums = [5, 3, 11, 24, 2]) == 9\n assert candidate(nums = [1000000000, 1, 1000000000]) == 1953123\n assert candidate(nums = [1, 3, 5, 7, 9]) == 7\n assert candidate(nums = [15, 15, 15, 15]) == 0\n assert candidate(nums = [1, 2, 3, 4]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50]) == 15\n assert candidate(nums = [6, 1, 3, 4, 2, 8]) == 1\n assert candidate(nums = [8, 12, 24, 6]) == 1\n assert candidate(nums = [6, 10, 18, 24]) == 4\n assert candidate(nums = [4, 1, 5, 20, 3]) == 3\n assert candidate(nums = [7, 4, 1, 8, 12]) == 5\n assert candidate(nums = [10, 10, 10]) == 0\n assert candidate(nums = [3, 5, 6, 10, 15]) == 9\n assert candidate(nums = [10, 4, 3, 5]) == 2\n assert candidate(nums = [7, 4, 3, 7]) == 3\n assert candidate(nums = [1, 2, 9, 16]) == 7\n assert candidate(nums = [5, 17, 100, 1]) == 23\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 29\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 29\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 10\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 275\n assert candidate(nums = [1024, 2048, 3072, 4096, 5120, 6144, 7168, 8192, 9216, 10240, 11264, 12288, 13312, 14336, 15360, 16384, 17408, 18432, 19456, 20480]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020]) == 1717\n assert candidate(nums = [17, 23, 31, 37, 41, 43, 47, 53, 59, 61]) == 28\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 13\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 27\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555]) == 765432099\n assert candidate(nums = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000]) == 12500\n assert candidate(nums = [2, 14, 18, 26, 34, 42, 50, 58, 66, 74]) == 35\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == 135\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 105\n assert candidate(nums = [64, 32, 16, 8, 4, 2, 1, 2, 4, 8, 16, 32, 64]) == 0\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997]) == 3\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78]) == 37\n assert candidate(nums = [1, 1000000000, 2, 500000000, 3, 333333333, 4, 250000000, 5, 200000000]) == 333333331\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000]) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 187\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 45\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 17\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 9\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000]) == 31250\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 69\n assert candidate(nums = [123456789, 987654321, 456789123, 321987654, 654321987, 789123456]) == 740740743\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165]) == 143\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 0\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 51\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195]) == 169\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == 13\n assert candidate(nums = [2, 6, 18, 54, 162, 486, 1458, 4374, 13122, 39366, 118098, 354294, 1062882, 3188646, 9565938]) == 4782967\n assert candidate(nums = [13579, 24681, 35791, 46813, 57915, 68137, 79159, 81379, 91591, 113791]) == 86633\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500]) == 525\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383]) == 14337\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625]) == 9765615\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 17\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 59043\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 275\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 39\n assert candidate(nums = [13, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 71\n assert candidate(nums = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 65\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287]) == 522241\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 4\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 21\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996]) == 999999997\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 85\n assert candidate(nums = [5, 15, 25, 35, 45, 55]) == 45\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 37\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995]) == 4\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5]) == 1953123\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 63\n assert candidate(nums = [1024, 2048, 512, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5]) == 1953123\n assert candidate(nums = [1023, 2046, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1021\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(nums = [9, 18, 27, 36, 45, 54]) == 27\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums = [83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181]) == 84\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34]) == 9\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == 707\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 65\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]", "[4,1,5,20,3]", "[2,10,8]"], "hints": ["Assume you start with the minimum possible value for each number so you can only multiply a number by 2 till it reaches its maximum possible value.", "If there is a better solution than the current one, then it must have either its maximum value less than the current maximum value, or the minimum value larger than the current minimum value.", "Since that we only increase numbers (multiply them by 2), we cannot decrease the current maximum value, so we must multiply the current minimum number by 2."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumDeviation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:08+00:00", "tests_total": 105, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "greedy", "heap-priority-queue", "ordered-set"]}, "language": "python", "interface": {"raw_signature": "def minimumDeviation(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minimumDeviation", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1678, "task_id": "goal-parser-interpretation", "difficulty": "Easy", "problem_description": "You own a Goal Parser that can interpret a string command. The command consists of an alphabet of \"G\", \"()\" and/or \"(al)\" in some order. The Goal Parser will interpret \"G\" as the string \"G\", \"()\" as the string \"o\", and \"(al)\" as the string \"al\". The interpreted strings are then concatenated in the original order.\n\nGiven the string command, return the Goal Parser's interpretation of command.\n\nExample 1:\n\nInput: command = \"G()(al)\"\nOutput: \"Goal\"\nExplanation: The Goal Parser interprets the command as follows:\nG -> G\n() -> o\n(al) -> al\nThe final concatenated result is \"Goal\".\n\nExample 2:\n\nInput: command = \"G()()()()(al)\"\nOutput: \"Gooooal\"\n\nExample 3:\n\nInput: command = \"(al)G(al)()()G\"\nOutput: \"alGalooG\"\n\nConstraints:\n\n- 1 <= command.length <= 100\n- command consists of \"G\", \"()\", and/or \"(al)\" in some order.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(command = \"G()()()()(al)\") == \"Gooooal\"\n assert candidate(command = \"G\") == \"G\"\n assert candidate(command = \"()\") == \"o\"\n assert candidate(command = \"(al)G(al)()()G\") == \"alGalooG\"\n assert candidate(command = \"G()(G)()\") == \"Go(G)o\"\n assert candidate(command = \"G(al)G(al)\") == \"GalGal\"\n assert candidate(command = \"G()(al)\") == \"Goal\"\n assert candidate(command = \"()()()()\") == \"oooo\"\n assert candidate(command = \"G()G(al)G()\") == \"GoGalGo\"\n assert candidate(command = \"G(al)G(al)G(al)\") == \"GalGalGal\"\n assert candidate(command = \"(al)(al)(al)\") == \"alalal\"\n assert candidate(command = \"(al)\") == \"al\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGalGalGal\"\n assert candidate(command = \"G(al)()()G(al)()()G(al)()()\") == \"GalooGalooGaloo\"\n assert candidate(command = \"G(al)(al)G(al)(al)G(al)(al)\") == \"GalalGalalGalal\"\n assert candidate(command = \"()()()()G(al)G(al)G(al)G(al)\") == \"ooooGalGalGalGal\"\n assert candidate(command = \"()()()G(al)G(al)G(al)G(al)G(al)G(al)\") == \"oooGalGalGalGalGalGal\"\n assert candidate(command = \"()G(al)G()G(al)()\") == \"oGalGoGalo\"\n assert candidate(command = \"()G(al)()G(al)()G(al)()\") == \"oGaloGaloGalo\"\n assert candidate(command = \"G()G()G()G()G()G()G()G()G()G()G()G()G()G()G(al)\") == \"GoGoGoGoGoGoGoGoGoGoGoGoGoGoGal\"\n assert candidate(command = \"G(al)(al)(al)\") == \"Galalal\"\n assert candidate(command = \"()(G(al)G(al))(G(al)G(al))\") == \"o(GalGal)(GalGal)\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGalGal\"\n assert candidate(command = \"()G(al)G(al)G(al)G(al)G(al)G(al)\") == \"oGalGalGalGalGalGal\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGal\"\n assert candidate(command = \"G(al)G()G(al)G()G(al)\") == \"GalGoGalGoGal\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"G()(al)G()(al)G()(al)\") == \"GoalGoalGoal\"\n assert candidate(command = \"(al)G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"alGaloGaloGaloGaloGalo\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGalGal\"\n assert candidate(command = \"()G(al)G()G(al)\") == \"oGalGoGal\"\n assert candidate(command = \"(al)G(al)()()G(al)G(al)()()G(al)G(al)()()G\") == \"alGalooGalGalooGalGalooG\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGal\"\n assert candidate(command = \"G(al)(al)(al)(al)\") == \"Galalalal\"\n assert candidate(command = \"(al)G(al)(G(al)(G(al)G(al)))G(al)\") == \"alGal(Gal(GalGal))Gal\"\n assert candidate(command = \"G()()G()()G()()\") == \"GooGooGoo\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"GaloGaloGaloGaloGalo\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"GaloGaloGaloGaloGaloGaloGaloGaloGaloGaloGalo\"\n assert candidate(command = \"G()G()G(al)(al)G()\") == \"GoGoGalalGo\"\n assert candidate(command = \"G(al)G(al)()()G(al)G(al)G(al)\") == \"GalGalooGalGalGal\"\n assert candidate(command = \"G()(G()(G()(G())))\") == \"Go(Go(Go(Go)))\"\n assert candidate(command = \"()G()G(al)()G(al)()G(al)\") == \"oGoGaloGaloGal\"\n assert candidate(command = \"()G()()G()()G()()G(al)G()\") == \"oGooGooGooGalGo\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)\") == \"GalGalGalGal\"\n assert candidate(command = \"G()(al)G()(al)G()(al)G()(al)\") == \"GoalGoalGoalGoal\"\n assert candidate(command = \"G()()()()(al)G(al)G(al)G(al)\") == \"GooooalGalGalGal\"\n assert candidate(command = \"G(al)G(al)()()G(al)G(al)()()\") == \"GalGalooGalGaloo\"\n assert candidate(command = \"G()(G(al))(G(al))G()(G(al))(G(al))\") == \"Go(Gal)(Gal)Go(Gal)(Gal)\"\n assert candidate(command = \"(al)(al)G(al)(al)G(al)(al)\") == \"alalGalalGalal\"\n assert candidate(command = \"G(al)(al)(al)G\") == \"GalalalG\"\n assert candidate(command = \"(al)G(al)()G(al)()G(al)()G(al)()\") == \"alGaloGaloGaloGalo\"\n assert candidate(command = \"G(al)(al)(al)G(al)(al)(al)G(al)(al)(al)G\") == \"GalalalGalalalGalalalG\"\n assert candidate(command = \"G(al)(G(al)G(al))(G(al))\") == \"Gal(GalGal)(Gal)\"\n assert candidate(command = \"G()(G(al))G()(G(al))\") == \"Go(Gal)Go(Gal)\"\n assert candidate(command = \"G()G()G()G()G()G()G()G()\") == \"GoGoGoGoGoGoGoGo\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"GaloGaloGaloGaloGaloGalo\"\n assert candidate(command = \"()()()G(al)G(al)G(al)()()()\") == \"oooGalGalGalooo\"\n assert candidate(command = \"(al)()G(al)()G(al)G(al)\") == \"aloGaloGalGal\"\n assert candidate(command = \"(al)(al)(al)(al)G(al)G()\") == \"alalalalGalGo\"\n assert candidate(command = \"(al)(G)(al)(G)(al)(G)(al)\") == \"al(G)al(G)al(G)al\"\n assert candidate(command = \"G(al)(al)G(al)\") == \"GalalGal\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGal\"\n assert candidate(command = \"()G(al)G(al)G(al)G(al)G(al)\") == \"oGalGalGalGalGal\"\n assert candidate(command = \"G(al)G()(al)G()(al)G()(al)G()\") == \"GalGoalGoalGoalGo\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"G()(G()(G)())\") == \"Go(Go(G)o)\"\n assert candidate(command = \"()()()()()()()()()()()()()()()()()()()()()G(al)\") == \"oooooooooooooooooooooGal\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)\") == \"GaloGaloGaloGaloGal\"\n assert candidate(command = \"(al)G(al)(al)G(al)G\") == \"alGalalGalG\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGal\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"(al)()G(al)()G(al)()G(al)()\") == \"aloGaloGaloGalo\"\n assert candidate(command = \"G(al)(G()(G)(G)())G(al)\") == \"Gal(Go(G)(G)o)Gal\"\n assert candidate(command = \"G()G(al)G()G(al)\") == \"GoGalGoGal\"\n assert candidate(command = \"(al)(al)(al)G(al)\") == \"alalalGal\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGal\"\n assert candidate(command = \"(al)(G(al))(G(al))(G(al))(G(al))(G(al))\") == \"al(Gal)(Gal)(Gal)(Gal)(Gal)\"\n assert candidate(command = \"()()()()()G(al)()()\") == \"oooooGaloo\"\n assert candidate(command = \"()G(al)()G(al)()\") == \"oGaloGalo\"\n assert candidate(command = \"(al)(al)(al)(al)(al)(al)(al)(al)\") == \"alalalalalalalal\"\n assert candidate(command = \"()()()()(al)()()()(al)()()()\") == \"ooooaloooalooo\"\n assert candidate(command = \"G(al)G()G(al)G()G(al)G()\") == \"GalGoGalGoGalGo\"\n assert candidate(command = \"G()(G()(G()(G)())())\") == \"Go(Go(Go(G)o)o)\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"GaloGaloGaloGaloGaloGaloGaloGalo\"\n assert candidate(command = \"G(al)(al)G(al)G(al)\") == \"GalalGalGal\"\n assert candidate(command = \"G(al)(G(al))(G(al))(G(al))G(al)\") == \"Gal(Gal)(Gal)(Gal)Gal\"\n assert candidate(command = \"G()()()()(al)G(al)G(al)G(al)G(al)\") == \"GooooalGalGalGalGal\"\n assert candidate(command = \"G()(G()(G()(G()())))\") == \"Go(Go(Go(Goo)))\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)G(al)\") == \"GaloGaloGaloGaloGalGal\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"G()G()G()G()G()G()G()G()G()G()G()G()G()G()G()G()\") == \"GoGoGoGoGoGoGoGoGoGoGoGoGoGoGoGo\"\n assert candidate(command = \"(al)()()()()()()()()()()()()()()()()()()()()()()()()()()()()\") == \"aloooooooooooooooooooooooooooo\"\n assert candidate(command = \"G()G()G()G()G(al)G(al)G(al)\") == \"GoGoGoGoGalGalGal\"\n assert candidate(command = \"()()()()()()()()()()G(al)G(al)G(al)G(al)G(al)\") == \"ooooooooooGalGalGalGalGal\"\n", "comparison": "exact"}, "public_tests": ["\"G()(al)\"", "\"G()()()()(al)\"", "\"(al)G(al)()()G\""], "hints": ["You need to check at most 2 characters to determine which character comes next."], "metadata": {"canonical_parameter_names": ["command"], "leetcode_dataset_entry_point": "Solution().interpret", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:10+00:00", "tests_total": 95, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def interpret(self, command: str) -> str:", "container": "Solution", "callable": "interpret", "parameters": [{"name": "command", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1679, "task_id": "max-number-of-k-sum-pairs", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer k.\n\nIn one operation, you can pick two numbers from the array whose sum equals k and remove them from the array.\n\nReturn the maximum number of operations you can perform on the array.\n\nExample 1:\n\nInput: nums = [1,2,3,4], k = 5\nOutput: 2\nExplanation: Starting with nums = [1,2,3,4]:\n- Remove numbers 1 and 4, then nums = [2,3]\n- Remove numbers 2 and 3, then nums = []\nThere are no more pairs that sum up to 5, hence a total of 2 operations.\n\nExample 2:\n\nInput: nums = [3,1,3,4,3], k = 6\nOutput: 1\nExplanation: Starting with nums = [3,1,3,4,3]:\n- Remove the first two 3's, then nums = [1,4,3]\nThere are no more pairs that sum up to 6, hence a total of 1 operation.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^9\n- 1 <= k <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 1, 3, 4, 3],k = 6) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 5\n assert candidate(nums = [1000000000],k = 1000000000) == 0\n assert candidate(nums = [1, 5, 4, 2, 9, 6, 5, 3, 4, 7, 8, 10],k = 11) == 5\n assert candidate(nums = [1, 3, 5, 7, 9],k = 10) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 10) == 3\n assert candidate(nums = [1, 5, 7, 8, 2, 6, 3, 4],k = 9) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11) == 5\n assert candidate(nums = [5, 5, 5, 5, 5],k = 10) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 4) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 4\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],k = 3) == 3\n assert candidate(nums = [1, 2, 3, 4],k = 5) == 2\n assert candidate(nums = [1, 3, 2, 2, 2, 3, 1],k = 4) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 10) == 4\n assert candidate(nums = [1, 3, 2, 2, 2, 3, 1],k = 4) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 26) == 12\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 30) == 7\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 42) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],k = 15) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 21) == 20\n assert candidate(nums = [1, 3, 3, 5, 7, 7, 5, 9, 9, 11, 11, 13],k = 12) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 21) == 10\n assert candidate(nums = [1, 5, 7, 3, 5, 7, 9, 11, 13, 15],k = 12) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 7\n assert candidate(nums = [1, 3, 2, 2, 2, 2, 2, 3, 1, 3, 3, 2, 2, 2, 3, 2, 2, 1, 3, 2],k = 4) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 11) == 10\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 100) == 5\n assert candidate(nums = [1, 5, 7, 1, 5, 7, 1, 5, 7, 1, 5, 7, 1, 5, 7, 1, 5, 7, 1, 5, 7],k = 6) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 300) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 16) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 6) == 25\n assert candidate(nums = [999999999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1000000000) == 1\n assert candidate(nums = [1, 5, 7, 1, 5, 9, 5, 5, 5, 5],k = 10) == 4\n assert candidate(nums = [5, 1, 4, 8, 6, 9, 7, 2, 3, 10],k = 15) == 3\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 200) == 10\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8],k = 6) == 6\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 20) == 7\n assert candidate(nums = [1, 5, 4, 2, 8, 6, 7, 3, 9],k = 10) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 300) == 11\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 400) == 21\n assert candidate(nums = [2, 5, 4, 4, 1, 3, 4, 4, 1, 4, 4, 1, 2, 1, 2, 2, 3, 2, 4, 2],k = 6) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 21) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 21) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 300) == 11\n assert candidate(nums = [2, 4, 3, 5, 7, 8, 1, 9, 10, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 31) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 32) == 8\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 27) == 7\n assert candidate(nums = [3, 6, 3, 3, 6, 6, 3, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6],k = 9) == 15\n assert candidate(nums = [1, 5, 7, 1, 5, 9, 7, 5, 11, 1],k = 10) == 2\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 12) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 16\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 11) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 41) == 20\n assert candidate(nums = [3, 1, 3, 4, 3, 5, 6, 2, 3, 1],k = 6) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],k = 50) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 16) == 7\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 18) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 20) == 5\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]\n5", "[3,1,3,4,3]\n6"], "hints": ["The abstract problem asks to count the number of disjoint pairs with a given sum k.", "For each possible value x, it can be paired up with k - x.", "The number of such pairs equals to min(count(x), count(k-x)), unless that x = k / 2, where the number of such pairs will be floor(count(x) / 2)."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:13+00:00", "tests_total": 68, "tests_dropped": 9, "flags": [], "topic_tags": ["array", "hash-table", "two-pointers", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxOperations(self, nums: List[int], k: int) -> int:", "container": "Solution", "callable": "maxOperations", "parameters": [{"name": "nums", "type": "List[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1680, "task_id": "concatenation-of-consecutive-binary-numbers", "difficulty": "Medium", "problem_description": "Given an integer n, return the decimal value of the binary string formed by concatenating the binary representations of 1 to n in order, modulo 10^9+ 7.\n\nExample 1:\n\nInput: n = 1\nOutput: 1\nExplanation: \"1\" in binary corresponds to the decimal value 1.\n\nExample 2:\n\nInput: n = 3\nOutput: 27\nExplanation: In binary, 1, 2, and 3 corresponds to \"1\", \"10\", and \"11\".\nAfter concatenating them, we have \"11011\", which corresponds to the decimal value 27.\n\nExample 3:\n\nInput: n = 12\nOutput: 505379714\nExplanation: The concatenation results in \"1101110010111011110001001101010111100\".\nThe decimal value of that is 118505380540.\nAfter modulo 10^9 + 7, the result is 505379714.\n\nConstraints:\n\n- 1 <= n <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 27\n assert candidate(n = 100000) == 757631812\n assert candidate(n = 100) == 310828084\n assert candidate(n = 12) == 505379714\n assert candidate(n = 10000) == 356435599\n assert candidate(n = 20) == 632668867\n assert candidate(n = 1) == 1\n assert candidate(n = 1000) == 499361981\n assert candidate(n = 10) == 462911642\n assert candidate(n = 5) == 1765\n assert candidate(n = 15000) == 760107204\n assert candidate(n = 99999) == 880407397\n assert candidate(n = 12345) == 836722104\n assert candidate(n = 67890) == 121883656\n assert candidate(n = 32767) == 351669993\n assert candidate(n = 90000) == 333354001\n assert candidate(n = 50000) == 305317209\n assert candidate(n = 60000) == 841047212\n assert candidate(n = 30000) == 789968936\n assert candidate(n = 80000) == 801174769\n assert candidate(n = 8192) == 853721666\n assert candidate(n = 65536) == 273282097\n assert candidate(n = 5000) == 754628255\n assert candidate(n = 75000) == 363627085\n assert candidate(n = 40000) == 162370743\n assert candidate(n = 65535) == 183542430\n assert candidate(n = 500) == 715412131\n assert candidate(n = 25000) == 110872861\n", "comparison": "exact"}, "public_tests": ["1", "3", "12"], "hints": ["Express the nth number value in a recursion formula and think about how we can do a fast evaluation."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().concatenatedBinary", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:15+00:00", "tests_total": 28, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "bit-manipulation", "simulation"]}, "language": "python", "interface": {"raw_signature": "def concatenatedBinary(self, n: int) -> int:", "container": "Solution", "callable": "concatenatedBinary", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1681, "task_id": "minimum-incompatibility", "difficulty": "Hard", "problem_description": "You are given an integer array nums and an integer k. You are asked to distribute this array into k subsets of equal size such that there are no two equal elements in the same subset.\n\nA subset's incompatibility is the difference between the maximum and minimum elements in that array.\n\nReturn the minimum possible sum of incompatibilities of the k subsets after distributing the array optimally, or return -1 if it is not possible.\n\nA subset is a group integers that appear in the array with no particular order.\n\nExample 1:\n\nInput: nums = [1,2,1,4], k = 2\nOutput: 4\nExplanation: The optimal distribution of subsets is [1,2] and [1,4].\nThe incompatibility is (2-1) + (4-1) = 4.\nNote that [1,1] and [2,4] would result in a smaller sum, but the first subset contains 2 equal elements.\n\nExample 2:\n\nInput: nums = [6,3,8,1,3,1,2,2], k = 4\nOutput: 6\nExplanation: The optimal distribution of subsets is [1,2], [2,3], [6,8], and [1,3].\nThe incompatibility is (2-1) + (3-2) + (8-6) + (3-1) = 6.\n\nExample 3:\n\nInput: nums = [5,3,3,6,3,3], k = 3\nOutput: -1\nExplanation: It is impossible to distribute nums into 3 subsets where no two elements are equal in the same subset.\n\nConstraints:\n\n- 1 <= k <= nums.length <= 16\n- nums.length is divisible by k\n- 1 <= nums[i] <= nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 1) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 8) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8],k = 4) == 4\n assert candidate(nums = [6, 3, 8, 1, 3, 1, 2, 2],k = 4) == 6\n assert candidate(nums = [1, 2, 1, 4],k = 2) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8],k = 2) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 4) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 16) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4],k = 4) == 4\n assert candidate(nums = [5, 3, 3, 6, 3, 3],k = 3) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],k = 1) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 2) == 14\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4],k = 8) == 0\n assert candidate(nums = [1, 2, 3, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14],k = 2) == 18\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 12\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7],k = 4) == 14\n assert candidate(nums = [1, 2, 3, 3, 3, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9, 10],k = 2) == -1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6],k = 4) == 14\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 1],k = 2) == 14\n assert candidate(nums = [3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],k = 4) == 12\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11],k = 4) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 2) == 14\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7],k = 2) == -1\n assert candidate(nums = [1, 3, 2, 6, 4, 5, 7, 8, 10, 9, 12, 11, 14, 13, 16, 15],k = 4) == 12\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9],k = 4) == 13\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14],k = 4) == 15\n assert candidate(nums = [1, 3, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 10, 10, 11, 12],k = 4) == 15\n assert candidate(nums = [1, 2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 12],k = 8) == 11\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6],k = 4) == -1\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 13],k = 4) == 17\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],k = 4) == 13\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 4) == 13\n assert candidate(nums = [1, 1, 1, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 11, 11],k = 4) == 22\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],k = 4) == 13\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 4) == 12\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],k = 8) == 8\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16],k = 4) == 16\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7],k = 8) == 8\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6],k = 4) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 8) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8],k = 8) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 9, 10, 11, 12, 13, 13],k = 4) == 16\n assert candidate(nums = [3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],k = 2) == -1\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 2) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13],k = 4) == 15\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 8) == 9\n assert candidate(nums = [6, 3, 8, 1, 3, 1, 2, 2, 4, 5, 7, 9, 10, 11, 12, 13],k = 4) == 13\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],k = 2) == 14\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 4) == 12\n assert candidate(nums = [1, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 13],k = 4) == 16\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 2) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15],k = 8) == 9\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10, 11],k = 4) == 14\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 4) == 16\n assert candidate(nums = [2, 2, 3, 4, 5, 5, 6, 6, 7, 8, 9, 10, 10, 11, 12, 12],k = 8) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7],k = 4) == 12\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4],k = 4) == 12\n assert candidate(nums = [1, 3, 3, 3, 3, 5, 5, 5, 7, 7, 7, 7, 9, 9, 9, 9],k = 2) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 12, 13, 14, 15, 16],k = 8) == 9\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 1) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8],k = 4) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 9, 10, 10, 11, 12, 13],k = 4) == 13\n", "comparison": "exact"}, "public_tests": ["[1,2,1,4]\n2", "[6,3,8,1,3,1,2,2]\n4", "[5,3,3,6,3,3]\n3"], "hints": ["The constraints are small enough for a backtrack solution but not any backtrack solution", "If we use a naive n^k don't you think it can be optimized"], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minimumIncompatibility", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:17+00:00", "tests_total": 91, "tests_dropped": 28, "flags": [], "topic_tags": ["array", "hash-table", "dynamic-programming", "bit-manipulation", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def minimumIncompatibility(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "minimumIncompatibility", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1684, "task_id": "count-the-number-of-consistent-strings", "difficulty": "Easy", "problem_description": "You are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string appear in the string allowed.\n\nReturn the number of consistent strings in the array words.\n\nExample 1:\n\nInput: allowed = \"ab\", words = [\"ad\",\"bd\",\"aaab\",\"baa\",\"badab\"]\nOutput: 2\nExplanation: Strings \"aaab\" and \"baa\" are consistent since they only contain characters 'a' and 'b'.\n\nExample 2:\n\nInput: allowed = \"abc\", words = [\"a\",\"b\",\"c\",\"ab\",\"ac\",\"bc\",\"abc\"]\nOutput: 7\nExplanation: All strings are consistent.\n\nExample 3:\n\nInput: allowed = \"cad\", words = [\"cc\",\"acd\",\"b\",\"ba\",\"bac\",\"bad\",\"ac\",\"d\"]\nOutput: 4\nExplanation: Strings \"cc\", \"acd\", \"ac\", and \"d\" are consistent.\n\nConstraints:\n\n- 1 <= words.length <= 10^4\n- 1 <= allowed.length <=26\n- 1 <= words[i].length <= 10\n- The characters in allowed are distinct.\n- words[i] and allowed contain only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(allowed = \"ijkl\",words = ['i', 'j', 'k', 'l', 'ij', 'ik', 'il', 'jk', 'jl', 'kl', 'ijkl']) == 11\n assert candidate(allowed = \"abcdef\",words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef']) == 6\n assert candidate(allowed = \"cad\",words = ['cc', 'acd', 'b', 'ba', 'bac', 'bad', 'ac', 'd']) == 4\n assert candidate(allowed = \"gh\",words = ['g', 'h', 'gh']) == 3\n assert candidate(allowed = \"xyz\",words = ['xy', 'yz', 'xzy', 'zxy', 'zyx', 'xyz']) == 6\n assert candidate(allowed = \"xyz\",words = ['x', 'y', 'z', 'xy', 'xz', 'yz', 'xyz']) == 7\n assert candidate(allowed = \"uvw\",words = ['u', 'v', 'w', 'uv', 'uw', 'vw', 'uvw']) == 7\n assert candidate(allowed = \"mnop\",words = ['m', 'n', 'o', 'p', 'mn', 'mo', 'mp', 'no', 'np', 'op', 'mno', 'mnp', 'mop', 'nop', 'mnop']) == 15\n assert candidate(allowed = \"mnop\",words = ['m', 'n', 'o', 'p', 'mn', 'mo', 'mp', 'no', 'np', 'op', 'mno', 'mnp', 'mop', 'nop', 'mnop']) == 15\n assert candidate(allowed = \"ab\",words = ['ad', 'bd', 'aaab', 'baa', 'badab']) == 2\n assert candidate(allowed = \"abc\",words = ['a', 'b', 'c', 'ab', 'ac', 'bc', 'abc']) == 7\n assert candidate(allowed = \"qrst\",words = ['qr', 'qs', 'qt', 'rs', 'rt', 'st', 'qrs', 'qrt', 'qst', 'rst', 'qrst']) == 11\n assert candidate(allowed = \"qwerty\",words = ['q', 'w', 'e', 'r', 't', 'y', 'qw', 'we', 'er', 'rt', 'ty', 'yq', 'qr', 're', 'et', 'ty', 'yr', 're', 'et', 'ty', 'qwer', 'wert', 'erty', 'rtye', 'tyer', 'yert', 'erty', 'rtye', 'tyer', 'yert']) == 30\n assert candidate(allowed = \"xyz\",words = ['xzy', 'zyx', 'xyzz', 'zyzzx', 'xzyzyx', 'zyzxzy', 'xyzxyz', 'zyxzyxzyx']) == 8\n assert candidate(allowed = \"abcdef\",words = ['abc', 'bcd', 'cde', 'def', 'abcf', 'bcde', 'cdef', 'abcdef', 'af', 'bf', 'cf', 'df', 'ef', 'f', 'a', 'b', 'c', 'd', 'e']) == 19\n assert candidate(allowed = \"abcdefg\",words = ['abc', 'def', 'ghi', 'abcd', 'efg', 'abdefg', 'abcdef', 'abcdefg', 'xyz']) == 7\n assert candidate(allowed = \"mnopqr\",words = ['mnop', 'opqr', 'mnqr', 'mpqr', 'mnoq', 'mnpq', 'mnopq', 'mnopqr', 'mnoqr', 'mnopqr', 'qrmpno', 'rpmnqo', 'qrmp', 'mnpqr', 'pqmno']) == 15\n assert candidate(allowed = \"xyz\",words = ['x', 'y', 'z', 'xy', 'xz', 'yz', 'xyz', 'xyzz', 'zxy', 'yxz', 'zyx', 'zzz']) == 12\n assert candidate(allowed = \"abcdef\",words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'fedcba', 'defabc', 'cbadef', 'abcdefg', 'abcdefh', 'abcdefi', 'abcdefj', 'abcdefk', 'abcdefl', 'abcdefm', 'abef', 'acd', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'ab', 'bc', 'cd', 'de', 'ef', 'fg', 'gh', 'hi', 'ij', 'jk', 'kl', 'lm', 'mn', 'no', 'op', 'pq', 'qr', 'rs', 'st', 'tu', 'uv', 'vw', 'wx', 'xy', 'yz', 'za', 'abab', 'acac', 'adad', 'aeae', 'afaf', 'agag', 'ahah', 'aiai', 'ajaj', 'akak', 'alal', 'amam', 'anan', 'aoao', 'apap', 'aqaq', 'arar', 'asas', 'atat', 'auau', 'avav', 'awaw', 'axax', 'ayay', 'azaz']) == 24\n assert candidate(allowed = \"tuvwxy\",words = ['tuv', 'uvw', 'vwx', 'wxy', 'tuvw', 'uvwx', 'vwx', 'wxy', 'tuvwx', 'uvwxy', 'tuvwxy', 'tuvwxyu', 'tuvwxyv', 'tuvwxyw', 'tuvwxyx', 'tuvwxyy']) == 16\n assert candidate(allowed = \"qrstuv\",words = ['qrst', 'uv', 'qrs', 'tu', 'rqs', 'vut', 'qrtuv', 'tuvqr', 'usvrtq', 'rqstuv', 'uvtqrs', 'qrsutv', 'rqvstu']) == 13\n assert candidate(allowed = \"pqrs\",words = ['pq', 'qr', 'rs', 'sp', 'pqrs', 'prqs', 'psrq', 'sqrp', 'rqps', 'rspq', 'pqs', 'qsr', 'rsq', 'spq', 'qrp', 'rps', 'sqr', 'prq', 'qsp', 'rqs', 'spr', 'psr', 'qrs', 'rsq', 'spq', 'pqr', 'qrs', 'rsp', 'spr', 'psr', 'srp', 'rps', 'qsp', 'psq']) == 34\n assert candidate(allowed = \"mnopqr\",words = ['mno', 'mnp', 'mqr', 'npr', 'opq', 'orq', 'pqr', 'mnop', 'mnoq', 'mnopqr', 'pqor', 'nopr', 'mnopq', 'nopqr', 'mnopqrs', 'mnoprq', 'mnopqrr', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs']) == 16\n assert candidate(allowed = \"jklm\",words = ['jj', 'kk', 'll', 'mm', 'jk', 'jl', 'jm', 'kl', 'km', 'lm', 'jkl', 'jkm', 'jlm', 'klm', 'jklm', 'jkll', 'jjkkllmm', 'klmklm', 'jkljkl', 'mnop', 'qrst', 'uvwxy', 'z']) == 19\n assert candidate(allowed = \"mno\",words = ['m', 'n', 'o', 'mn', 'no', 'om', 'mno', 'mon', 'nom', 'omn', 'nmo', 'nom', 'omn', 'mon', 'mno', 'mno', 'nom', 'omn', 'mon', 'mno', 'nom', 'omn', 'mon', 'mno', 'nom', 'omn', 'mon', 'mno', 'nom', 'omn', 'mon', 'mno']) == 32\n assert candidate(allowed = \"ijkl\",words = ['ij', 'kl', 'ik', 'jl', 'ikl', 'jkl', 'ijk', 'ijkl', 'ijl', 'ikjl', 'likj', 'ljk', 'lkij', 'lijk', 'ilkj', 'lkji']) == 16\n assert candidate(allowed = \"xyz\",words = ['xy', 'yz', 'xz', 'xyz', 'zyx', 'yxz', 'xzy', 'zy', 'yx', 'zx']) == 10\n assert candidate(allowed = \"xyz\",words = ['x', 'y', 'z', 'xy', 'xz', 'yz', 'xyz', 'xzy', 'yzx', 'zyx', 'zyz', 'zxz', 'yzy', 'xyx', 'xxy', 'xxz', 'xyy', 'xzz', 'yyy', 'yzz', 'zzz']) == 21\n assert candidate(allowed = \"xyz\",words = ['xyzzy', 'zyx', 'zxyx', 'zzyzxzy', 'xyzabc', 'xzyz']) == 5\n assert candidate(allowed = \"fv\",words = ['f', 'v', 'fv', 'vf', 'ff', 'vv', 'ffff', 'vvvv', 'fvfv', 'vfvf', 'fvvf', 'vvff', 'fvff', 'vvvf', 'fvvv', 'ffvv', 'f', 'v', 'fv', 'vf', 'ff', 'vv', 'ffff', 'vvvv', 'fvfv', 'vfvf', 'fvvf', 'vvff', 'fvff', 'vvvf', 'fvvv', 'ffvv', 'f', 'v', 'fv', 'vf', 'ff', 'vv', 'ffff', 'vvvv']) == 40\n assert candidate(allowed = \"qrst\",words = ['qqqq', 'rrrr', 'ssss', 'tttt', 'qqrr', 'qqss', 'qqtt', 'rrss', 'rrtt', 'sstt', 'qqrrss', 'qqrrtt', 'qqsstt', 'rrsstt', 'qqrrsstt', 'qqrrssttt']) == 16\n assert candidate(allowed = \"xyz\",words = ['xy', 'xz', 'yz', 'xyz', 'xx', 'yy', 'zz', 'xyx', 'yzy', 'zxz', 'xyxy', 'xzyz', 'yzxy', 'xyzx', 'xzyzx', 'yzxyz', 'xyzyx', 'zxyxz', 'yxzyz', 'zyxzy']) == 20\n assert candidate(allowed = \"abcdef\",words = ['a', 'b', 'c', 'd', 'e', 'f', 'ab', 'cd', 'ef', 'abc', 'def', 'abcdef', 'abcdefg', 'abcdefabc']) == 13\n assert candidate(allowed = \"qrstuv\",words = ['qrst', 'qrsu', 'rstuv', 'qrstu', 'quv', 'qrs', 'qrtuv', 'qru', 'quvtsr', 'quvz']) == 9\n assert candidate(allowed = \"abcdef\",words = ['abc', 'def', 'abcdef', 'aabbcc', 'ddeeff', 'abcdeff', 'abcdefg']) == 6\n assert candidate(allowed = \"ijklmnop\",words = ['ijkl', 'mnop', 'ijkm', 'klnm', 'ijlmo', 'ijkmnop', 'ijklmnopq', 'ijklmno', 'ijklnop']) == 8\n assert candidate(allowed = \"jklmno\",words = ['jk', 'kl', 'lm', 'mn', 'no', 'jkl', 'klm', 'lmn', 'mno', 'jklm', 'klmn', 'lmno', 'jklmo', 'klmno', 'jklmno', 'jklmnou', 'klmnop', 'jklmnop']) == 15\n assert candidate(allowed = \"abcdef\",words = ['abc', 'def', 'abcd', 'abef', 'acdf', 'bcde', 'acde', 'bcdf', 'abcf', 'abcdef', 'afecbd', 'fedcba']) == 12\n assert candidate(allowed = \"qrst\",words = ['q', 'r', 's', 't', 'qr', 'qs', 'qt', 'rs', 'rt', 'st', 'qrs', 'qrt', 'qst', 'rst', 'qrst']) == 15\n assert candidate(allowed = \"wxyz\",words = ['w', 'x', 'y', 'z', 'wx', 'wxyz', 'xy', 'yz', 'wxy', 'wxyz', 'wxzy', 'xywz', 'yzwx', 'zxyw']) == 14\n assert candidate(allowed = \"abcd\",words = ['a', 'b', 'c', 'd', 'ab', 'bc', 'cd', 'da', 'abc', 'bcd', 'cda', 'dab', 'abcd', 'bcda', 'cdab', 'dabc', 'abdc', 'bacd', 'cabd', 'dabc', 'acbd', 'badc', 'cabd', 'dacb', 'acdb', 'bdac', 'cadb', 'dbac', 'dcab', 'dcba']) == 30\n assert candidate(allowed = \"xyz\",words = ['xyzz', 'zyx', 'zxy', 'xxxyyyzzz', 'zzzz', 'yyyxxx', 'abc', 'xyzzyx', 'zzzxxx', 'xyxyxy']) == 9\n assert candidate(allowed = \"abcdef\",words = ['abc', 'def', 'abcdef', 'abcd', 'abcf', 'defa', 'bcde', 'fabc', 'aabbccdd', 'fedcba']) == 10\n assert candidate(allowed = \"qz\",words = ['qqqz', 'zqq', 'q', 'z', 'zzzz', 'qqqq', 'qzqz', 'zqzq', 'zzzq', 'zqqz']) == 10\n assert candidate(allowed = \"xyz\",words = ['xy', 'yz', 'xz', 'xyz', 'xzy', 'yxz', 'zxy', 'zyx', 'yzz', 'zzz']) == 10\n assert candidate(allowed = \"jkl\",words = ['j', 'k', 'l', 'jk', 'kl', 'lj', 'jkl', 'klj', 'lkj', 'kjl', 'jlk', 'lk', 'kj', 'jl', 'kl', 'jk', 'lj', 'kl', 'jl', 'kj', 'jl', 'kj', 'lk', 'jk', 'kl', 'jl', 'kj', 'lk', 'jk', 'kl', 'jl', 'kj']) == 32\n assert candidate(allowed = \"uvw\",words = ['uvw', 'uv', 'uw', 'vw', 'u', 'v', 'w', 'uvvw', 'uwwv', 'vwwu', 'vvvuuuwww', 'wuvuvuvuv']) == 12\n assert candidate(allowed = \"pqrstuvw\",words = ['pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'pqrsrstuvw', 'uvws', 'uvwpqr', 'rstuvwq', 'pqrstuvwz', 'uvwstu', 'qrpstu', 'vwstupqr']) == 12\n assert candidate(allowed = \"pqrst\",words = ['p', 'q', 'r', 's', 't', 'pq', 'qr', 'rs', 'st', 'pqrs', 'qrst', 'pqrst', 'pqrs', 'pqst', 'prst', 'qrstu', 'pqrstv']) == 15\n assert candidate(allowed = \"lmnopq\",words = ['lmn', 'opq', 'lmnop', 'lmnopq', 'pqonm', 'qlmnp', 'pqlno', 'opqmn', 'nopql', 'mnopq', 'lmnopqrr', 'plmqon', 'opqlnm', 'qponml', 'mnopql']) == 14\n assert candidate(allowed = \"xyz\",words = ['xx', 'yy', 'zz', 'xy', 'yz', 'zx', 'xyz', 'zxy', 'yxz']) == 9\n assert candidate(allowed = \"xyz\",words = ['xzy', 'zyx', 'zyzx', 'xxxyyyzzz', 'xzyxzyxzy']) == 5\n", "comparison": "exact"}, "public_tests": ["\"ab\"\n[\"ad\",\"bd\",\"aaab\",\"baa\",\"badab\"]", "\"abc\"\n[\"a\",\"b\",\"c\",\"ab\",\"ac\",\"bc\",\"abc\"]", "\"cad\"\n[\"cc\",\"acd\",\"b\",\"ba\",\"bac\",\"bad\",\"ac\",\"d\"]"], "hints": ["A string is incorrect if it contains a character that is not allowed", "Constraints are small enough for brute force"], "metadata": {"canonical_parameter_names": ["allowed", "words"], "leetcode_dataset_entry_point": "Solution().countConsistentStrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:22+00:00", "tests_total": 66, "tests_dropped": 14, "flags": [], "topic_tags": ["array", "hash-table", "string", "bit-manipulation", "counting"]}, "language": "python", "interface": {"raw_signature": "def countConsistentStrings(self, allowed: str, words: List[str]) -> int:", "container": "Solution", "callable": "countConsistentStrings", "parameters": [{"name": "allowed", "type": "str"}, {"name": "words", "type": "List[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1685, "task_id": "sum-of-absolute-differences-in-a-sorted-array", "difficulty": "Medium", "problem_description": "You are given an integer array nums sorted in non-decreasing order.\n\nBuild and return an integer array result with the same length as nums such that result[i] is equal to the summation of absolute differences between nums[i] and all the other elements in the array.\n\nIn other words, result[i] is equal to sum(|nums[i]-nums[j]|) where 0 <= j < nums.length and j != i (0-indexed).\n\nExample 1:\n\nInput: nums = [2,3,5]\nOutput: [4,3,5]\nExplanation: Assuming the arrays are 0-indexed, then\nresult[0] = |2-2| + |2-3| + |2-5| = 0 + 1 + 3 = 4,\nresult[1] = |3-2| + |3-3| + |3-5| = 1 + 0 + 2 = 3,\nresult[2] = |5-2| + |5-3| + |5-5| = 3 + 2 + 0 = 5.\n\nExample 2:\n\nInput: nums = [1,4,6,8,10]\nOutput: [24,15,13,15,21]\n\nConstraints:\n\n- 2 <= nums.length <= 10^5\n- 1 <= nums[i] <= nums[i + 1] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [100, 200, 300, 400, 500]) == [1000, 700, 600, 700, 1000]\n assert candidate(nums = [1, 1, 1, 1]) == [0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 4, 6, 8, 10]) == [24, 15, 13, 15, 21]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(nums = [2, 3, 5]) == [4, 3, 5]\n assert candidate(nums = [1, 2, 3, 100, 101, 102, 103, 104, 105, 106]) == [717, 709, 703, 315, 313, 313, 315, 319, 325, 333]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 10, 10, 15, 15, 15, 20, 20, 20, 20]) == [100, 100, 100, 70, 70, 60, 60, 60, 80, 80, 80, 80]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == [19000, 17200, 15600, 14200, 13000, 12000, 11200, 10600, 10200, 10000, 10000, 10200, 10600, 11200, 12000, 13000, 14200, 15600, 17200, 19000]\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == [441, 369, 309, 269, 249, 249, 269, 309, 369, 449]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [45000, 37000, 31000, 27000, 25000, 25000, 27000, 31000, 37000, 45000]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [950, 860, 780, 710, 650, 600, 560, 530, 510, 500, 500, 510, 530, 560, 600, 650, 710, 780, 860, 950]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == [570, 516, 468, 426, 390, 360, 336, 318, 306, 300, 300, 306, 318, 336, 360, 390, 426, 468, 516, 570]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [135, 117, 101, 87, 75, 65, 57, 51, 47, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45]\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, 10, 10, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == [137, 137, 137, 123, 123, 113, 105, 99, 95, 93, 93, 95, 99, 105, 113, 123, 135, 149, 165, 183]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [380, 344, 312, 284, 260, 240, 224, 212, 204, 200, 200, 204, 212, 224, 240, 260, 284, 312, 344, 380]\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101]) == [816, 726, 648, 582, 528, 486, 456, 438, 432, 438, 456, 486, 528, 582, 648, 726, 816]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == [30, 30, 30, 30, 30, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [1900, 1720, 1560, 1420, 1300, 1200, 1120, 1060, 1020, 1000, 1000, 1020, 1060, 1120, 1200, 1300, 1420, 1560, 1720, 1900]\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [210, 194, 176, 160, 150, 150, 164, 196, 250, 330]\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [5490, 4599, 3899, 3399, 3099, 2999, 3099, 3399, 3899, 4599, 5499]\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [210, 194, 176, 160, 150, 150, 164, 196, 250, 330]\n assert candidate(nums = [3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 9, 9, 9, 9, 11, 11, 11, 11]) == [80, 80, 80, 80, 56, 56, 56, 56, 48, 48, 48, 48, 56, 56, 56, 56, 80, 80, 80, 80]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [20, 20, 14, 14, 12, 12, 14, 14, 20, 20]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [210, 184, 162, 144, 130, 120, 114, 112, 114, 120, 130, 144, 162, 184, 210]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [210, 184, 162, 144, 130, 120, 114, 112, 114, 120, 130, 144, 162, 184, 210]\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]) == [2567, 2554, 2543, 2525, 2504, 2479, 2455, 2442, 2463, 2565, 2840, 3463, 4759, 7322, 12223]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [450, 370, 310, 270, 250, 250, 270, 310, 370, 450]\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == [2850, 2796, 2716, 2618, 2510, 2400, 2296, 2206, 2138, 2100, 2100, 2146, 2246, 2408, 2640, 2950, 3346, 3836, 4428, 5130]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7]) == [15, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == [130, 102, 102, 78, 78, 78, 60, 60, 60, 60, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 80, 80, 80, 80, 80]\n assert candidate(nums = [5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7]) == [12, 12, 12, 12, 8, 8, 8, 8, 12, 12, 12, 12]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [90, 74, 62, 54, 50, 50, 54, 62, 74, 90]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5]) == [24, 15, 15, 10, 10, 10, 11, 11, 11, 11, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [2026, 2010, 1986, 1954, 1922, 1922, 2050, 2562, 4098, 8194]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [1900, 1720, 1560, 1420, 1300, 1200, 1120, 1060, 1020, 1000, 1000, 1020, 1060, 1120, 1200, 1300, 1420, 1560, 1720, 1900]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [380, 344, 312, 284, 260, 240, 224, 212, 204, 200, 200, 204, 212, 224, 240, 260, 284, 312, 344, 380]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [300, 277, 256, 237, 220, 205, 192, 181, 172, 165, 160, 157, 156, 157, 160, 165, 172, 181, 192, 205, 220, 237, 256, 277, 300]\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 5, 6]) == [24, 17, 17, 14, 13, 14, 14, 14, 21]\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [540, 459, 389, 339, 309, 299, 309, 339, 389, 459, 549]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == [2175, 2035, 1905, 1785, 1675, 1575, 1485, 1405, 1335, 1275, 1225, 1185, 1155, 1135, 1125, 1125, 1135, 1155, 1185, 1225, 1275, 1335, 1405, 1485, 1575, 1675, 1785, 1905, 2035, 2175]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == [15, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [20, 12, 12, 8, 8, 8, 10, 10, 10, 10]\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011, 5012, 5013, 5014, 5015, 5016, 5017, 5018, 5019]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [275, 230, 195, 170, 155, 150, 155, 170, 195, 230, 275]\n assert candidate(nums = [1, 2, 5, 7, 9, 11, 13, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49]) == [437, 419, 371, 343, 319, 299, 283, 265, 257, 253, 253, 259, 271, 289, 313, 343, 379, 421, 469, 523]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [1050, 920, 810, 720, 650, 600, 570, 560, 570, 600, 650, 720, 810, 920, 1050]\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [540, 459, 389, 339, 309, 299, 309, 339, 389, 459, 549]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [45000, 37000, 31000, 27000, 25000, 25000, 27000, 31000, 37000, 45000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [1013, 1005, 993, 977, 961, 961, 1025, 1281, 2049, 4097]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [105, 92, 81, 72, 65, 60, 57, 56, 57, 60, 65, 72, 81, 92, 105]\n", "comparison": "exact"}, "public_tests": ["[2,3,5]", "[1,4,6,8,10]"], "hints": ["Absolute difference is the same as max(a, b) - min(a, b). How can you use this fact with the fact that the array is sorted?", "For nums[i], the answer is (nums[i] - nums[0]) + (nums[i] - nums[1]) + ... + (nums[i] - nums[i-1]) + (nums[i+1] - nums[i]) + (nums[i+2] - nums[i]) + ... + (nums[n-1] - nums[i]).", "It can be simplified to (nums[i] * i - (nums[0] + nums[1] + ... + nums[i-1])) + ((nums[i+1] + nums[i+2] + ... + nums[n-1]) - nums[i] * (n-i-1)). One can build prefix and suffix sums to compute this quickly."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().getSumAbsoluteDifferences", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:24+00:00", "tests_total": 69, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "math", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def getSumAbsoluteDifferences(self, nums: List[int]) -> List[int]:", "container": "Solution", "callable": "getSumAbsoluteDifferences", "parameters": [{"name": "nums", "type": "List[int]"}], "return_type": "List[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1686, "task_id": "stone-game-vi", "difficulty": "Medium", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\n\nThere are n stones in a pile. On each player's turn, they can remove a stone from the pile and receive points based on the stone's value. Alice and Bob may value the stones differently.\n\nYou are given two integer arrays of length n, aliceValues and bobValues. Each aliceValues[i] and bobValues[i] represents how Alice and Bob, respectively, value the i^th stone.\n\nThe winner is the person with the most points after all the stones are chosen. If both players have the same amount of points, the game results in a draw. Both players will play optimally. Both players know the other's values.\n\nDetermine the result of the game, and:\n\n- If Alice wins, return 1.\n- If Bob wins, return -1.\n- If the game results in a draw, return 0.\n\nExample 1:\n\nInput: aliceValues = [1,3], bobValues = [2,1]\nOutput: 1\nExplanation:\nIf Alice takes stone 1 (0-indexed) first, Alice will receive 3 points.\nBob can only choose stone 0, and will only receive 2 points.\nAlice wins.\n\nExample 2:\n\nInput: aliceValues = [1,2], bobValues = [3,1]\nOutput: 0\nExplanation:\nIf Alice takes stone 0, and Bob takes stone 1, they will both have 1 point.\nDraw.\n\nExample 3:\n\nInput: aliceValues = [2,4,3], bobValues = [1,6,7]\nOutput: -1\nExplanation:\nRegardless of how Alice plays, Bob will be able to have more points than Alice.\nFor example, if Alice takes stone 1, Bob can take stone 2, and Alice takes stone 0, Alice will have 6 points to Bob's 7.\nBob wins.\n\nConstraints:\n\n- n == aliceValues.length == bobValues.length\n- 1 <= n <= 10^5\n- 1 <= aliceValues[i], bobValues[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(aliceValues = [1, 2],bobValues = [3, 1]) == 0\n assert candidate(aliceValues = [1, 2, 3, 4, 5],bobValues = [5, 4, 3, 2, 1]) == 1\n assert candidate(aliceValues = [9, 9, 9, 9, 9],bobValues = [1, 1, 1, 1, 1]) == 1\n assert candidate(aliceValues = [5, 3, 1, 4],bobValues = [4, 1, 2, 3]) == 1\n assert candidate(aliceValues = [10, 20, 30],bobValues = [30, 20, 10]) == 1\n assert candidate(aliceValues = [1, 3],bobValues = [2, 1]) == 1\n assert candidate(aliceValues = [2, 2, 2, 2, 2],bobValues = [3, 3, 3, 3, 3]) == 0\n assert candidate(aliceValues = [1, 1, 1, 1],bobValues = [1, 1, 1, 1]) == 0\n assert candidate(aliceValues = [1, 1, 1, 1, 1],bobValues = [9, 9, 9, 9, 9]) == -1\n assert candidate(aliceValues = [7, 8, 9],bobValues = [9, 8, 7]) == 1\n assert candidate(aliceValues = [2, 4, 3],bobValues = [1, 6, 7]) == -1\n assert candidate(aliceValues = [10, 10, 10, 10],bobValues = [10, 10, 10, 10]) == 0\n assert candidate(aliceValues = [5, 3, 8, 2],bobValues = [4, 1, 7, 3]) == 1\n assert candidate(aliceValues = [100, 100, 100],bobValues = [100, 100, 100]) == 1\n assert candidate(aliceValues = [99, 98, 97],bobValues = [1, 2, 3]) == 1\n assert candidate(aliceValues = [100, 1, 1, 1],bobValues = [1, 100, 1, 1]) == 0\n assert candidate(aliceValues = [30, 20, 10],bobValues = [10, 20, 30]) == 1\n assert candidate(aliceValues = [5, 5, 5, 5],bobValues = [5, 5, 5, 5]) == 0\n assert candidate(aliceValues = [1, 1, 1, 1, 1],bobValues = [1, 1, 1, 1, 1]) == 1\n assert candidate(aliceValues = [99, 1, 99, 1, 99, 1],bobValues = [1, 99, 1, 99, 1, 99]) == 0\n assert candidate(aliceValues = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],bobValues = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 0\n assert candidate(aliceValues = [80, 70, 60, 50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50, 60, 70, 80]) == 0\n assert candidate(aliceValues = [99, 50, 25, 10, 5],bobValues = [1, 1, 1, 1, 1]) == 1\n assert candidate(aliceValues = [100, 50, 25, 12, 6],bobValues = [5, 20, 40, 60, 80]) == 1\n assert candidate(aliceValues = [100, 1, 100, 1, 100],bobValues = [1, 100, 1, 100, 1]) == 1\n assert candidate(aliceValues = [5, 8, 7, 12, 9],bobValues = [4, 6, 5, 10, 7]) == 1\n assert candidate(aliceValues = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],bobValues = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],bobValues = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 1\n assert candidate(aliceValues = [3, 2, 3, 4, 5],bobValues = [5, 4, 3, 2, 3]) == 1\n assert candidate(aliceValues = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],bobValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(aliceValues = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1],bobValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == 0\n assert candidate(aliceValues = [50, 30, 20],bobValues = [1, 20, 30]) == 1\n assert candidate(aliceValues = [100, 99, 98, 97, 96],bobValues = [95, 94, 93, 92, 91]) == 1\n assert candidate(aliceValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bobValues = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(aliceValues = [5, 5, 5, 5],bobValues = [6, 6, 6, 6]) == -1\n assert candidate(aliceValues = [23, 45, 67, 89, 10],bobValues = [10, 89, 67, 45, 23]) == 1\n assert candidate(aliceValues = [23, 45, 67, 89, 12],bobValues = [12, 89, 67, 45, 23]) == 1\n assert candidate(aliceValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bobValues = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(aliceValues = [50, 30, 20, 10, 1],bobValues = [10, 20, 30, 40, 50]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],bobValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(aliceValues = [99, 98, 97, 96, 95],bobValues = [1, 2, 3, 4, 5]) == 1\n assert candidate(aliceValues = [50, 50, 50, 50, 50],bobValues = [50, 50, 50, 50, 50]) == 1\n assert candidate(aliceValues = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],bobValues = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == 0\n assert candidate(aliceValues = [5, 2, 3, 3, 4],bobValues = [4, 3, 2, 3, 5]) == 1\n assert candidate(aliceValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],bobValues = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n assert candidate(aliceValues = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],bobValues = [75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 1\n assert candidate(aliceValues = [100, 50, 25, 10, 5],bobValues = [5, 10, 25, 50, 100]) == 1\n assert candidate(aliceValues = [30, 20, 10, 50, 40, 60, 70],bobValues = [70, 60, 50, 40, 30, 20, 10]) == 1\n assert candidate(aliceValues = [50, 50, 50],bobValues = [100, 100, 100]) == 0\n assert candidate(aliceValues = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5],bobValues = [5, 95, 4, 96, 3, 97, 2, 98, 1, 99]) == 0\n assert candidate(aliceValues = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86],bobValues = [86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 1\n assert candidate(aliceValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bobValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(aliceValues = [100, 100, 100, 100, 100],bobValues = [99, 99, 99, 99, 99]) == 1\n assert candidate(aliceValues = [80, 20, 60, 40, 100, 50, 70],bobValues = [70, 50, 100, 60, 20, 40, 80]) == 1\n assert candidate(aliceValues = [7, 14, 21, 28, 35, 42],bobValues = [6, 12, 18, 24, 30, 36]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10],bobValues = [20, 20, 20, 20]) == -1\n assert candidate(aliceValues = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(aliceValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bobValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(aliceValues = [100, 90, 80, 70, 60],bobValues = [60, 70, 80, 90, 100]) == 1\n assert candidate(aliceValues = [100, 100, 1, 1, 1],bobValues = [1, 1, 100, 100, 100]) == 1\n assert candidate(aliceValues = [2, 4, 6, 8, 10],bobValues = [1, 3, 5, 7, 9]) == 1\n assert candidate(aliceValues = [5, 15, 25, 35, 45, 55],bobValues = [55, 45, 35, 25, 15, 5]) == 0\n assert candidate(aliceValues = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],bobValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(aliceValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],bobValues = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(aliceValues = [100, 100, 100, 100, 100],bobValues = [50, 50, 50, 50, 50]) == 1\n assert candidate(aliceValues = [90, 20, 30, 10, 50],bobValues = [50, 90, 10, 30, 20]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10, 10, 10],bobValues = [9, 9, 9, 9, 9, 9]) == 1\n assert candidate(aliceValues = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],bobValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],bobValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(aliceValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],bobValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(aliceValues = [100, 1, 2, 3, 4],bobValues = [1, 100, 2, 3, 4]) == 1\n assert candidate(aliceValues = [100, 1, 50, 25, 75],bobValues = [90, 99, 5, 20, 70]) == 1\n assert candidate(aliceValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bobValues = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(aliceValues = [90, 90, 90, 90, 90, 90, 90, 90, 90, 90],bobValues = [91, 91, 91, 91, 91, 91, 91, 91, 91, 91]) == -1\n assert candidate(aliceValues = [2, 3, 5, 7, 11],bobValues = [11, 7, 5, 3, 2]) == 1\n assert candidate(aliceValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],bobValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(aliceValues = [30, 30, 30, 30, 30],bobValues = [30, 30, 30, 30, 30]) == 1\n assert candidate(aliceValues = [30, 20, 10],bobValues = [10, 20, 30]) == 1\n assert candidate(aliceValues = [10, 1, 10, 1, 10, 1, 10, 1],bobValues = [1, 10, 1, 10, 1, 10, 1, 10]) == 0\n assert candidate(aliceValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bobValues = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(aliceValues = [1, 3, 5, 7, 9, 11, 13],bobValues = [2, 4, 6, 8, 10, 12, 14]) == 1\n assert candidate(aliceValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bobValues = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(aliceValues = [10, 20, 30, 40, 50],bobValues = [50, 40, 30, 20, 10]) == 1\n assert candidate(aliceValues = [50, 50, 50, 50, 50],bobValues = [40, 40, 40, 40, 60]) == 1\n assert candidate(aliceValues = [50, 40, 30, 20, 10, 10, 20, 30, 40, 50],bobValues = [10, 20, 30, 40, 50, 50, 40, 30, 20, 10]) == 0\n assert candidate(aliceValues = [99, 1, 2, 3, 4],bobValues = [4, 3, 2, 1, 99]) == 1\n assert candidate(aliceValues = [50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50]) == 1\n assert candidate(aliceValues = [10, 30, 20, 50, 40],bobValues = [40, 20, 30, 10, 50]) == 1\n assert candidate(aliceValues = [50, 50, 50, 50, 50],bobValues = [50, 50, 50, 50, 51]) == 1\n assert candidate(aliceValues = [5, 15, 25, 35, 45, 55, 65],bobValues = [65, 55, 45, 35, 25, 15, 5]) == 1\n assert candidate(aliceValues = [10, 20, 30, 40, 50],bobValues = [50, 40, 30, 20, 10]) == 1\n assert candidate(aliceValues = [50, 25, 50, 75, 25],bobValues = [75, 50, 25, 25, 50]) == 1\n assert candidate(aliceValues = [1, 1, 1, 2, 2, 2, 3, 3, 3],bobValues = [3, 3, 3, 2, 2, 2, 1, 1, 1]) == 1\n assert candidate(aliceValues = [100, 1, 1, 1, 1],bobValues = [1, 1, 1, 1, 100]) == 1\n assert candidate(aliceValues = [90, 80, 70, 60, 50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 1\n assert candidate(aliceValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],bobValues = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(aliceValues = [90, 10, 90, 10, 90],bobValues = [10, 90, 10, 90, 10]) == 1\n assert candidate(aliceValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],bobValues = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(aliceValues = [42, 23, 17, 5, 99],bobValues = [99, 5, 17, 23, 42]) == 1\n assert candidate(aliceValues = [100, 50, 1, 1, 1, 1, 1, 1, 1, 1],bobValues = [1, 1, 99, 99, 99, 99, 99, 99, 99, 99]) == -1\n assert candidate(aliceValues = [70, 60, 50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50, 60, 70]) == 1\n assert candidate(aliceValues = [90, 10, 20, 30, 40, 50, 60, 70, 80],bobValues = [10, 90, 80, 70, 60, 50, 40, 30, 20]) == 1\n assert candidate(aliceValues = [100],bobValues = [1]) == 1\n", "comparison": "exact"}, "public_tests": ["[1,3]\n[2,1]", "[1,2]\n[3,1]", "[2,4,3]\n[1,6,7]"], "hints": ["When one takes the stone, they not only get the points, but they take them away from the other player too.", "Greedily choose the stone with the maximum aliceValues[i] + bobValues[i]."], "metadata": {"canonical_parameter_names": ["aliceValues", "bobValues"], "leetcode_dataset_entry_point": "Solution().stoneGameVI", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:27+00:00", "tests_total": 106, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "math", "greedy", "minimax-algorithm", "sorting", "heap-priority-queue", "game-theory", "zero-sum-game"]}, "language": "python", "interface": {"raw_signature": "def stoneGameVI(self, aliceValues: list[int], bobValues: list[int]) -> int:", "container": "Solution", "callable": "stoneGameVI", "parameters": [{"name": "aliceValues", "type": "list[int]"}, {"name": "bobValues", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1687, "task_id": "delivering-boxes-from-storage-to-ports", "difficulty": "Hard", "problem_description": "You have the task of delivering some boxes from storage to their ports using only one ship. However, this ship has a limit on the number of boxes and the total weight that it can carry.\n\nYou are given an array boxes, where boxes[i] = [ports_i, weight_i], and three integers portsCount, maxBoxes, and maxWeight.\n\n- ports_i is the port where you need to deliver the i^th box and weights_i is the weight of the i^th box.\n- portsCount is the number of ports.\n- maxBoxes and maxWeight are the respective box and weight limits of the ship.\n\nThe boxes need to be delivered in the order they are given. The ship will follow these steps:\n\n- The ship will take some number of boxes from the boxes queue, not violating the maxBoxes and maxWeight constraints.\n- For each loaded box in order, the ship will make a trip to the port the box needs to be delivered to and deliver it. If the ship is already at the correct port, no trip is needed, and the box can immediately be delivered.\n- The ship then makes a return trip to storage to take more boxes from the queue.\n\nThe ship must end at storage after all the boxes have been delivered.\n\nReturn the minimum number of trips the ship needs to make to deliver all boxes to their respective ports.\n\nExample 1:\n\nInput: boxes = [[1,1],[2,1],[1,1]], portsCount = 2, maxBoxes = 3, maxWeight = 3\nOutput: 4\nExplanation: The optimal strategy is as follows:\n- The ship takes all the boxes in the queue, goes to port 1, then port 2, then port 1 again, then returns to storage. 4 trips.\nSo the total number of trips is 4.\nNote that the first and third boxes cannot be delivered together because the boxes need to be delivered in order (i.e. the second box needs to be delivered at port 2 before the third box).\n\nExample 2:\n\nInput: boxes = [[1,2],[3,3],[3,1],[3,1],[2,4]], portsCount = 3, maxBoxes = 3, maxWeight = 6\nOutput: 6\nExplanation: The optimal strategy is as follows:\n- The ship takes the first box, goes to port 1, then returns to storage. 2 trips.\n- The ship takes the second, third and fourth boxes, goes to port 3, then returns to storage. 2 trips.\n- The ship takes the fifth box, goes to port 2, then returns to storage. 2 trips.\nSo the total number of trips is 2 + 2 + 2 = 6.\n\nExample 3:\n\nInput: boxes = [[1,4],[1,2],[2,1],[2,1],[3,2],[3,4]], portsCount = 3, maxBoxes = 6, maxWeight = 7\nOutput: 6\nExplanation: The optimal strategy is as follows:\n- The ship takes the first and second boxes, goes to port 1, then returns to storage. 2 trips.\n- The ship takes the third and fourth boxes, goes to port 2, then returns to storage. 2 trips.\n- The ship takes the fifth and sixth boxes, goes to port 3, then returns to storage. 2 trips.\nSo the total number of trips is 2 + 2 + 2 = 6.\n\nConstraints:\n\n- 1 <= boxes.length <= 10^5\n- 1 <= portsCount, maxBoxes, maxWeight <= 10^5\n- 1 <= ports_i <= portsCount\n- 1 <= weights_i <= maxWeight\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 5,maxWeight = 5) == 4\n assert candidate(boxes = [[2, 2], [2, 2], [3, 3], [3, 3], [4, 4], [4, 4]],portsCount = 4,maxBoxes = 2,maxWeight = 4) == 10\n assert candidate(boxes = [[1, 2], [2, 2], [1, 2], [2, 2], [1, 2]],portsCount = 2,maxBoxes = 3,maxWeight = 6) == 7\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],portsCount = 5,maxBoxes = 1,maxWeight = 5) == 10\n assert candidate(boxes = [[1, 5], [1, 5], [1, 5], [2, 5], [2, 5], [2, 5]],portsCount = 2,maxBoxes = 2,maxWeight = 10) == 7\n assert candidate(boxes = [[1, 5], [2, 5], [1, 5], [2, 5], [1, 5], [2, 5]],portsCount = 2,maxBoxes = 2,maxWeight = 10) == 9\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],portsCount = 15,maxBoxes = 5,maxWeight = 15) == 18\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 12\n assert candidate(boxes = [[1, 2], [2, 2], [1, 2], [2, 2], [1, 2], [2, 2], [1, 2], [2, 2], [1, 2], [2, 2]],portsCount = 2,maxBoxes = 4,maxWeight = 10) == 13\n assert candidate(boxes = [[1, 1], [2, 1], [1, 1]],portsCount = 2,maxBoxes = 3,maxWeight = 3) == 4\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1]],portsCount = 5,maxBoxes = 5,maxWeight = 5) == 6\n assert candidate(boxes = [[1, 100], [2, 100], [3, 100], [4, 100], [5, 100]],portsCount = 5,maxBoxes = 5,maxWeight = 500) == 6\n assert candidate(boxes = [[2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3]],portsCount = 5,maxBoxes = 3,maxWeight = 10) == 10\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 3,maxWeight = 30) == 7\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],portsCount = 9,maxBoxes = 3,maxWeight = 15) == 13\n assert candidate(boxes = [[1, 5], [2, 3], [3, 2], [2, 1], [1, 4]],portsCount = 3,maxBoxes = 5,maxWeight = 15) == 6\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 2,maxWeight = 2) == 6\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 3,maxWeight = 5) == 4\n assert candidate(boxes = [[1, 4], [1, 2], [2, 1], [2, 1], [3, 2], [3, 4]],portsCount = 3,maxBoxes = 6,maxWeight = 7) == 6\n assert candidate(boxes = [[1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3], [4, 4], [4, 4], [5, 5], [5, 5]],portsCount = 5,maxBoxes = 3,maxWeight = 5) == 16\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],portsCount = 10,maxBoxes = 10,maxWeight = 55) == 11\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10]],portsCount = 3,maxBoxes = 2,maxWeight = 20) == 5\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],portsCount = 5,maxBoxes = 2,maxWeight = 10) == 8\n assert candidate(boxes = [[1, 3], [1, 3], [1, 3], [1, 3], [1, 3]],portsCount = 1,maxBoxes = 3,maxWeight = 9) == 4\n assert candidate(boxes = [[1, 3], [2, 5], [3, 7], [4, 9]],portsCount = 4,maxBoxes = 2,maxWeight = 12) == 7\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],portsCount = 5,maxBoxes = 2,maxWeight = 5) == 9\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 5,maxWeight = 50) == 6\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 5,maxWeight = 25) == 8\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],portsCount = 5,maxBoxes = 2,maxWeight = 5) == 10\n assert candidate(boxes = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 6\n assert candidate(boxes = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2]],portsCount = 5,maxBoxes = 2,maxWeight = 4) == 8\n assert candidate(boxes = [[1, 5], [2, 2], [3, 3], [1, 1]],portsCount = 3,maxBoxes = 3,maxWeight = 11) == 6\n assert candidate(boxes = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3]],portsCount = 10,maxBoxes = 10,maxWeight = 30) == 11\n assert candidate(boxes = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 6\n assert candidate(boxes = [[1, 3], [2, 2], [3, 1]],portsCount = 3,maxBoxes = 5,maxWeight = 6) == 4\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],portsCount = 10,maxBoxes = 1,maxWeight = 1) == 20\n assert candidate(boxes = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 12\n assert candidate(boxes = [[1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3], [4, 4], [4, 4], [5, 5], [5, 5]],portsCount = 5,maxBoxes = 2,maxWeight = 4) == 0\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 5,maxWeight = 10) == 4\n assert candidate(boxes = [[1, 3], [2, 2], [1, 4], [2, 2], [3, 1]],portsCount = 3,maxBoxes = 3,maxWeight = 10) == 7\n assert candidate(boxes = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5]],portsCount = 1,maxBoxes = 5,maxWeight = 25) == 2\n assert candidate(boxes = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],portsCount = 10,maxBoxes = 5,maxWeight = 10) == 12\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 5,maxWeight = 30) == 7\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5]],portsCount = 4,maxBoxes = 4,maxWeight = 20) == 5\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [1, 10], [2, 10], [3, 10]],portsCount = 3,maxBoxes = 3,maxWeight = 20) == 9\n assert candidate(boxes = [[1, 5], [1, 5], [2, 5], [2, 5], [3, 5], [3, 5]],portsCount = 3,maxBoxes = 3,maxWeight = 15) == 6\n assert candidate(boxes = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],portsCount = 5,maxBoxes = 2,maxWeight = 100) == 8\n assert candidate(boxes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],portsCount = 1,maxBoxes = 5,maxWeight = 15) == 2\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 5,maxWeight = 5) == 2\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 5,maxWeight = 40) == 7\n assert candidate(boxes = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5]],portsCount = 10,maxBoxes = 5,maxWeight = 15) == 2\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],portsCount = 7,maxBoxes = 4,maxWeight = 8) == 12\n assert candidate(boxes = [[1, 3], [1, 3], [2, 3], [2, 3], [3, 3], [3, 3]],portsCount = 3,maxBoxes = 4,maxWeight = 9) == 6\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 1,maxWeight = 10) == 10\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 6\n assert candidate(boxes = [[2, 3], [2, 3], [3, 2], [3, 2], [3, 2]],portsCount = 3,maxBoxes = 2,maxWeight = 5) == 7\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],portsCount = 5,maxBoxes = 10,maxWeight = 50) == 11\n assert candidate(boxes = [[1, 5], [2, 2], [3, 1], [4, 4], [5, 3]],portsCount = 5,maxBoxes = 2,maxWeight = 10) == 8\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [2, 10], [1, 10]],portsCount = 3,maxBoxes = 2,maxWeight = 20) == 8\n assert candidate(boxes = [[1, 3], [2, 3], [3, 3], [2, 3], [1, 3]],portsCount = 3,maxBoxes = 2,maxWeight = 9) == 8\n assert candidate(boxes = [[1, 2], [3, 3], [3, 1], [3, 1], [2, 4]],portsCount = 3,maxBoxes = 3,maxWeight = 6) == 6\n assert candidate(boxes = [[1, 5], [2, 5], [1, 5], [2, 5], [1, 5], [2, 5], [1, 5], [2, 5], [1, 5], [2, 5]],portsCount = 2,maxBoxes = 5,maxWeight = 25) == 12\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 2,maxWeight = 20) == 8\n assert candidate(boxes = [[1, 5], [2, 3], [3, 2], [4, 1], [2, 2]],portsCount = 4,maxBoxes = 5,maxWeight = 10) == 7\n assert candidate(boxes = [[1, 3], [2, 2], [3, 2], [4, 2], [5, 2]],portsCount = 5,maxBoxes = 3,maxWeight = 5) == 8\n assert candidate(boxes = [[1, 5], [2, 5], [1, 5], [2, 5], [1, 5]],portsCount = 2,maxBoxes = 3,maxWeight = 15) == 7\n assert candidate(boxes = [[1, 5], [2, 6], [3, 7]],portsCount = 3,maxBoxes = 2,maxWeight = 12) == 5\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],portsCount = 10,maxBoxes = 10,maxWeight = 10) == 11\n assert candidate(boxes = [[2, 5], [2, 4], [5, 1], [5, 1], [5, 1], [1, 5], [1, 5], [1, 5], [1, 5], [5, 1]],portsCount = 5,maxBoxes = 5,maxWeight = 10) == 10\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 2,maxWeight = 2) == 6\n assert candidate(boxes = [[1, 5], [2, 3], [3, 2], [4, 1], [2, 2]],portsCount = 4,maxBoxes = 4,maxWeight = 10) == 7\n assert candidate(boxes = [[1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3]],portsCount = 3,maxBoxes = 3,maxWeight = 10) == 6\n assert candidate(boxes = [[1, 10], [1, 10], [1, 10], [1, 10]],portsCount = 1,maxBoxes = 2,maxWeight = 20) == 4\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],portsCount = 10,maxBoxes = 5,maxWeight = 5) == 12\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],portsCount = 5,maxBoxes = 1,maxWeight = 5) == 10\n assert candidate(boxes = [[2, 10], [2, 10], [3, 10], [3, 10]],portsCount = 3,maxBoxes = 3,maxWeight = 20) == 4\n", "comparison": "exact"}, "public_tests": ["[[1,1],[2,1],[1,1]]\n2\n3\n3", "[[1,2],[3,3],[3,1],[3,1],[2,4]]\n3\n3\n6", "[[1,4],[1,2],[2,1],[2,1],[3,2],[3,4]]\n3\n6\n7"], "hints": ["Try to think of the most basic dp which is n^2 now optimize it", "Think of any range query data structure to optimize"], "metadata": {"canonical_parameter_names": ["boxes", "portsCount", "maxBoxes", "maxWeight"], "leetcode_dataset_entry_point": "Solution().boxDelivering", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:30+00:00", "tests_total": 76, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming", "segment-tree", "queue", "heap-priority-queue", "prefix-sum", "monotonic-queue"]}, "language": "python", "interface": {"raw_signature": "def boxDelivering(self, boxes: list[list[int]], portsCount: int, maxBoxes: int, maxWeight: int) -> int:", "container": "Solution", "callable": "boxDelivering", "parameters": [{"name": "boxes", "type": "list[list[int]]"}, {"name": "portsCount", "type": "int"}, {"name": "maxBoxes", "type": "int"}, {"name": "maxWeight", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1688, "task_id": "count-of-matches-in-tournament", "difficulty": "Easy", "problem_description": "You are given an integer n, the number of teams in a tournament that has strange rules:\n\n- If the current number of teams is even, each team gets paired with another team. A total of n / 2 matches are played, and n / 2 teams advance to the next round.\n- If the current number of teams is odd, one team randomly advances in the tournament, and the rest gets paired. A total of (n - 1) / 2 matches are played, and (n - 1) / 2 + 1 teams advance to the next round.\n\nReturn the number of matches played in the tournament until a winner is decided.\n\nExample 1:\n\nInput: n = 7\nOutput: 6\nExplanation: Details of the tournament:\n- 1st Round: Teams = 7, Matches = 3, and 4 teams advance.\n- 2nd Round: Teams = 4, Matches = 2, and 2 teams advance.\n- 3rd Round: Teams = 2, Matches = 1, and 1 team is declared the winner.\nTotal number of matches = 3 + 2 + 1 = 6.\n\nExample 2:\n\nInput: n = 14\nOutput: 13\nExplanation: Details of the tournament:\n- 1st Round: Teams = 14, Matches = 7, and 7 teams advance.\n- 2nd Round: Teams = 7, Matches = 3, and 4 teams advance.\n- 3rd Round: Teams = 4, Matches = 2, and 2 teams advance.\n- 4th Round: Teams = 2, Matches = 1, and 1 team is declared the winner.\nTotal number of matches = 7 + 3 + 2 + 1 = 13.\n\nConstraints:\n\n- 1 <= n <= 200\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 2\n assert candidate(n = 100) == 99\n assert candidate(n = 14) == 13\n assert candidate(n = 200) == 199\n assert candidate(n = 17) == 16\n assert candidate(n = 2) == 1\n assert candidate(n = 199) == 198\n assert candidate(n = 1) == 0\n assert candidate(n = 7) == 6\n assert candidate(n = 13) == 12\n assert candidate(n = 97) == 96\n assert candidate(n = 63) == 62\n assert candidate(n = 29) == 28\n assert candidate(n = 45) == 44\n assert candidate(n = 135) == 134\n assert candidate(n = 183) == 182\n assert candidate(n = 49) == 48\n assert candidate(n = 130) == 129\n assert candidate(n = 163) == 162\n assert candidate(n = 111) == 110\n assert candidate(n = 10) == 9\n assert candidate(n = 197) == 196\n assert candidate(n = 50) == 49\n assert candidate(n = 157) == 156\n assert candidate(n = 5) == 4\n assert candidate(n = 123) == 122\n assert candidate(n = 59) == 58\n assert candidate(n = 87) == 86\n assert candidate(n = 173) == 172\n assert candidate(n = 4) == 3\n assert candidate(n = 99) == 98\n assert candidate(n = 16) == 15\n assert candidate(n = 177) == 176\n assert candidate(n = 64) == 63\n assert candidate(n = 33) == 32\n assert candidate(n = 143) == 142\n assert candidate(n = 98) == 97\n assert candidate(n = 73) == 72\n assert candidate(n = 133) == 132\n assert candidate(n = 175) == 174\n assert candidate(n = 128) == 127\n assert candidate(n = 101) == 100\n assert candidate(n = 181) == 180\n assert candidate(n = 8) == 7\n assert candidate(n = 131) == 130\n assert candidate(n = 27) == 26\n assert candidate(n = 169) == 168\n assert candidate(n = 32) == 31\n assert candidate(n = 149) == 148\n assert candidate(n = 127) == 126\n assert candidate(n = 81) == 80\n assert candidate(n = 150) == 149\n assert candidate(n = 151) == 150\n assert candidate(n = 198) == 197\n assert candidate(n = 11) == 10\n assert candidate(n = 15) == 14\n assert candidate(n = 189) == 188\n assert candidate(n = 85) == 84\n assert candidate(n = 31) == 30\n assert candidate(n = 25) == 24\n", "comparison": "exact"}, "public_tests": ["7", "14"], "hints": ["Simulate the tournament as given in the statement.", "Be careful when handling odd integers."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().numberOfMatches", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:32+00:00", "tests_total": 60, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "simulation"]}, "language": "python", "interface": {"raw_signature": "def numberOfMatches(self, n: int) -> int:", "container": "Solution", "callable": "numberOfMatches", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1689, "task_id": "partitioning-into-minimum-number-of-deci-binary-numbers", "difficulty": "Medium", "problem_description": "A decimal number is called deci-binary if each of its digits is either 0 or 1 without any leading zeros. For example, 101 and 1100 are deci-binary, while 112 and 3001 are not.\n\nGiven a string n that represents a positive decimal integer, return the minimum number of positive deci-binary numbers needed so that they sum up to n.\n\nExample 1:\n\nInput: n = \"32\"\nOutput: 3\nExplanation: 10 + 11 + 11 = 32\n\nExample 2:\n\nInput: n = \"82734\"\nOutput: 8\n\nExample 3:\n\nInput: n = \"27346209830709182346\"\nOutput: 9\n\nConstraints:\n\n- 1 <= n.length <= 10^5\n- n consists of only digits.\n- n does not contain any leading zeros and represents a positive integer.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = \"9876543210\") == 9\n assert candidate(n = \"111\") == 1\n assert candidate(n = \"123456789\") == 9\n assert candidate(n = \"1\") == 1\n assert candidate(n = \"82734\") == 8\n assert candidate(n = \"32\") == 3\n assert candidate(n = \"11111\") == 1\n assert candidate(n = \"555555555\") == 5\n assert candidate(n = \"9\") == 9\n assert candidate(n = \"27346209830709182346\") == 9\n assert candidate(n = \"1000000000\") == 1\n assert candidate(n = \"55555\") == 5\n assert candidate(n = \"987654321\") == 9\n assert candidate(n = \"987654321098765432109876543210\") == 9\n assert candidate(n = \"1999199919991999199919991999199919991999199919991999\") == 9\n assert candidate(n = \"11111111112222222222333333333333444444444444555555555\") == 5\n assert candidate(n = \"111999888777666555444333222111\") == 9\n assert candidate(n = \"8888888888888888888888888888888888888888\") == 8\n assert candidate(n = \"87654321098765432109\") == 9\n assert candidate(n = \"999999999\") == 9\n assert candidate(n = \"11111111111111111111\") == 1\n assert candidate(n = \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111\") == 1\n assert candidate(n = \"999999999999999999999999999999\") == 9\n assert candidate(n = \"44444444444444444444444444444444444444444444444444\") == 4\n assert candidate(n = \"101010101010101010101010101010\") == 1\n assert candidate(n = \"5432105432105432105432105432105432105432105432105432\") == 5\n assert candidate(n = \"10000000000000000000\") == 1\n assert candidate(n = \"19191919191919191919\") == 9\n assert candidate(n = \"77777777777777777777777777777777777777777777777777\") == 7\n assert candidate(n = \"222222222222222222222222222222222222222222222222222\") == 2\n assert candidate(n = \"99999999999999999999\") == 9\n assert candidate(n = \"8456391728391657813265813265\") == 9\n assert candidate(n = \"9999999999\") == 9\n assert candidate(n = \"918273645091827364509182736450\") == 9\n assert candidate(n = \"12345678901234567890\") == 9\n assert candidate(n = \"9999111199991111999911119999111199991111999911119999\") == 9\n assert candidate(n = \"19191919191919191919191919191919191919191919191919191919191919191919191919191919\") == 9\n assert candidate(n = \"10000000000000000000000000000000000000000000\") == 1\n assert candidate(n = \"55555555555555555555\") == 5\n assert candidate(n = \"888888888888888888888888888888888888888888888888888\") == 8\n assert candidate(n = \"99999\") == 9\n assert candidate(n = \"1111111111\") == 1\n assert candidate(n = \"987654321012345678987654321\") == 9\n assert candidate(n = \"10101010101010101010101010101010\") == 1\n assert candidate(n = \"24681357924681357924\") == 9\n assert candidate(n = \"123456789876543210000000000000000000000000000000000\") == 9\n assert candidate(n = \"12345678987654321\") == 9\n assert candidate(n = \"10101010101010101010\") == 1\n assert candidate(n = \"111222333444555666777888999\") == 9\n assert candidate(n = \"18181818181818181818\") == 8\n assert candidate(n = \"13579135791357913579\") == 9\n assert candidate(n = \"101010101010101010101010101\") == 1\n assert candidate(n = \"100000000000000000000000000000\") == 1\n assert candidate(n = \"765432101023456765432101023456765432101023456765432\") == 7\n assert candidate(n = \"8765432109876543210987654321\") == 9\n assert candidate(n = \"918273645432187654321\") == 9\n assert candidate(n = \"2468135791113151719\") == 9\n assert candidate(n = \"1234567890\") == 9\n assert candidate(n = \"22222222222222222222\") == 2\n assert candidate(n = \"98765432109876543210\") == 9\n assert candidate(n = \"123123123123123123123123123\") == 3\n assert candidate(n = \"191919191919191919191919191919191919191919191919191\") == 9\n assert candidate(n = \"24680246802468024680\") == 8\n assert candidate(n = \"111122223333444455556666777788889999\") == 9\n assert candidate(n = \"50505050505050505050505050505050505050505050\") == 5\n assert candidate(n = \"123456789012345678901234567890\") == 9\n assert candidate(n = \"50000000000000000005\") == 5\n assert candidate(n = \"5555555555\") == 5\n assert candidate(n = \"192837465056473829109876543210\") == 9\n assert candidate(n = \"87654321987654321098\") == 9\n assert candidate(n = \"90000000000000000000900000000000000000000009\") == 9\n assert candidate(n = \"987654321987654321987654321987654321\") == 9\n", "comparison": "exact"}, "public_tests": ["\"32\"", "\"82734\"", "\"27346209830709182346\""], "hints": ["Think about if the input was only one digit. Then you need to add up as many ones as the value of this digit.", "If the input has multiple digits, then you can solve for each digit independently, and merge the answers to form numbers that add up to that input.", "Thus the answer is equal to the max digit."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minPartitions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:34+00:00", "tests_total": 72, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minPartitions(self, n: str) -> int:", "container": "Solution", "callable": "minPartitions", "parameters": [{"name": "n", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1690, "task_id": "stone-game-vii", "difficulty": "Medium", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\n\nThere are n stones arranged in a row. On each player's turn, they can remove either the leftmost stone or the rightmost stone from the row and receive points equal to the sum of the remaining stones' values in the row. The winner is the one with the higher score when there are no stones left to remove.\n\nBob found that he will always lose this game (poor Bob, he always loses), so he decided to minimize the score's difference. Alice's goal is to maximize the difference in the score.\n\nGiven an array of integers stones where stones[i] represents the value of the i^th stone from the left, return the difference in Alice and Bob's score if they both play optimally.\n\nExample 1:\n\nInput: stones = [5,3,1,4,2]\nOutput: 6\nExplanation:\n- Alice removes 2 and gets 5 + 3 + 1 + 4 = 13 points. Alice = 13, Bob = 0, stones = [5,3,1,4].\n- Bob removes 5 and gets 3 + 1 + 4 = 8 points. Alice = 13, Bob = 8, stones = [3,1,4].\n- Alice removes 3 and gets 1 + 4 = 5 points. Alice = 18, Bob = 8, stones = [1,4].\n- Bob removes 1 and gets 4 points. Alice = 18, Bob = 12, stones = [4].\n- Alice removes 4 and gets 0 points. Alice = 18, Bob = 12, stones = [].\nThe score difference is 18 - 12 = 6.\n\nExample 2:\n\nInput: stones = [7,90,5,1,100,10,10,2]\nOutput: 122\n\nConstraints:\n\n- n == stones.length\n- 2 <= n <= 1000\n- 1 <= stones[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 30\n assert candidate(stones = [2, 3, 4, 1, 5, 6, 7, 8, 9, 10]) == 28\n assert candidate(stones = [1, 2, 3, 4, 5]) == 6\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(stones = [7, 90, 5, 1, 100, 10, 10, 2]) == 122\n assert candidate(stones = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9]) == 123\n assert candidate(stones = [10, 20, 30, 40, 50]) == 60\n assert candidate(stones = [1, 100, 1, 100, 1, 100]) == 300\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(stones = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 30\n assert candidate(stones = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 5000\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 15\n assert candidate(stones = [3, 9, 4, 2, 10, 3, 2, 5]) == 22\n assert candidate(stones = [5, 3, 1, 4, 2]) == 6\n assert candidate(stones = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 210\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 210\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 105\n assert candidate(stones = [500, 250, 750, 1000, 125, 375, 875, 625, 300, 700, 150, 450, 900, 550, 200, 600, 800, 400, 950, 100]) == 5950\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 40\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 156\n assert candidate(stones = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 110\n assert candidate(stones = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9, 1000, 10]) == 5500\n assert candidate(stones = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 56\n assert candidate(stones = [500, 2, 100, 400, 3, 800, 7, 600, 9, 50]) == 1852\n assert candidate(stones = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 9900\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1100\n assert candidate(stones = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993]) == 7972\n assert candidate(stones = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 2000\n assert candidate(stones = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 650\n assert candidate(stones = [5, 2, 9, 4, 6, 3, 8, 1, 7, 10]) == 35\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 450\n assert candidate(stones = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975]) == 11844\n assert candidate(stones = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 600\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 420\n assert candidate(stones = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 136\n assert candidate(stones = [500, 400, 300, 200, 100, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5]) == 696\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 650\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 650\n assert candidate(stones = [2, 1, 3, 4, 1, 5, 7, 8, 1, 9, 6, 10, 12, 11, 13, 14, 15, 16, 17, 18]) == 96\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000]) == 7\n assert candidate(stones = [500, 250, 750, 125, 625, 375, 875, 125, 625, 375, 875, 125, 625, 375, 875, 125, 625, 375, 875, 125]) == 7250\n assert candidate(stones = [500, 250, 750, 200, 1000, 150, 300, 850, 600, 400]) == 3150\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 3000\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 110\n assert candidate(stones = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == 9990\n assert candidate(stones = [200, 300, 100, 400, 500, 150, 250, 350, 450, 550]) == 1850\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 450\n assert candidate(stones = [50, 20, 30, 10, 40, 60, 70, 80, 90, 100]) == 280\n assert candidate(stones = [1, 10, 100, 1000, 10, 1, 1000, 100, 10, 1, 10, 100, 1000, 10, 1, 100, 100, 10, 1, 10, 100]) == 1342\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 830\n assert candidate(stones = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15]) == 72\n assert candidate(stones = [5, 25, 5, 25, 5, 25, 5, 25, 5, 25, 5, 25, 5, 25, 5]) == 35\n assert candidate(stones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 75\n assert candidate(stones = [100, 200, 300, 400, 500, 400, 300, 200, 100, 50, 40, 30, 20, 10, 1]) == 1090\n assert candidate(stones = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991, 11, 990, 12, 989, 13, 988, 14, 987, 15, 986]) == 14895\n assert candidate(stones = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == 14\n assert candidate(stones = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 1, 3, 6, 12, 25, 50, 100, 200, 300, 400, 500]) == 1597\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(stones = [50, 10, 50, 10, 50, 10, 50, 10, 50, 10]) == 250\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 30\n assert candidate(stones = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(stones = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996]) == 4990\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 4500\n assert candidate(stones = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 490\n assert candidate(stones = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991]) == 9955\n assert candidate(stones = [1000, 1, 999, 2, 998, 3, 997, 4, 996, 5, 995, 6, 994, 7, 993, 8, 992, 9, 991, 10]) == 9955\n assert candidate(stones = [1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000]) == 10000\n assert candidate(stones = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 8]) == 28\n assert candidate(stones = [300, 100, 250, 150, 200, 50, 100, 300, 250, 150, 200, 50, 100]) == 800\n assert candidate(stones = [100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100]) == 350\n assert candidate(stones = [5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2]) == 48\n assert candidate(stones = [1000, 1, 2, 1000, 3, 1000, 4, 1000, 5, 1000, 6, 1000, 7, 1000, 8, 1000, 9, 1000, 10, 1000]) == 9001\n assert candidate(stones = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 560\n assert candidate(stones = [1, 10, 100, 1000, 10, 100, 1000, 10, 100, 1000, 10, 100, 1000, 10, 100]) == 2230\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3030\n assert candidate(stones = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 105\n assert candidate(stones = [145, 135, 125, 115, 105, 95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 525\n assert candidate(stones = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5]) == 4985\n assert candidate(stones = [100, 50, 200, 150, 250, 100, 300, 50, 200, 150, 250, 100, 300]) == 600\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 16\n assert candidate(stones = [700, 100, 500, 200, 600, 300, 400, 800, 900, 100, 200, 300, 400, 500, 600]) == 2300\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 410\n assert candidate(stones = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992]) == 28\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 560\n assert candidate(stones = [50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 141\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 60\n assert candidate(stones = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145]) == 525\n assert candidate(stones = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 10\n assert candidate(stones = [314, 159, 265, 358, 979, 323, 846, 264, 338, 327, 950, 288, 419, 716, 939]) == 2435\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 105\n assert candidate(stones = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 29\n assert candidate(stones = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 1, 2, 4, 8, 16]) == 674\n", "comparison": "exact"}, "public_tests": ["[5,3,1,4,2]", "[7,90,5,1,100,10,10,2]"], "hints": ["The constraints are small enough for an N^2 solution.", "Try using dynamic programming."], "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().stoneGameVII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:36+00:00", "tests_total": 109, "tests_dropped": 13, "flags": [], "topic_tags": ["array", "math", "dynamic-programming", "minimax-algorithm", "game-theory", "zero-sum-game"]}, "language": "python", "interface": {"raw_signature": "def stoneGameVII(self, stones: List[int]) -> int:", "container": "Solution", "callable": "stoneGameVII", "parameters": [{"name": "stones", "type": "List[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1691, "task_id": "maximum-height-by-stacking-cuboids", "difficulty": "Hard", "problem_description": "Given n cuboids where the dimensions of the i^th cuboid is cuboids[i] = [width_i, length_i, height_i] (0-indexed). Choose a subset of cuboids and place them on each other.\n\nYou can place cuboid i on cuboid j if width_i <= width_j and length_i <= length_j and height_i <= height_j. You can rearrange any cuboid's dimensions by rotating it to put it on another cuboid.\n\nReturn the maximum height of the stacked cuboids.\n\nExample 1:\n\nInput: cuboids = [[50,45,20],[95,37,53],[45,23,12]]\nOutput: 190\nExplanation:\nCuboid 1 is placed on the bottom with the 53x37 side facing down with height 95.\nCuboid 0 is placed next with the 45x20 side facing down with height 50.\nCuboid 2 is placed next with the 23x12 side facing down with height 45.\nThe total height is 95 + 50 + 45 = 190.\n\nExample 2:\n\nInput: cuboids = [[38,25,45],[76,35,3]]\nOutput: 76\nExplanation:\nYou can't place any of the cuboids on the other.\nWe choose cuboid 1 and rotate it so that the 35x3 side is facing down and its height is 76.\n\nExample 3:\n\nInput: cuboids = [[7,11,17],[7,17,11],[11,7,17],[11,17,7],[17,7,11],[17,11,7]]\nOutput: 102\nExplanation:\nAfter rearranging the cuboids, you can see that all cuboids have the same dimension.\nYou can place the 11x7 side down on all cuboids so their heights are 17.\nThe maximum height of stacked cuboids is 6 * 17 = 102.\n\nConstraints:\n\n- n == cuboids.length\n- 1 <= n <= 100\n- 1 <= width_i, length_i, height_i <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cuboids = [[4, 6, 7], [1, 2, 3], [4, 5, 6], [10, 12, 32]]) == 48\n assert candidate(cuboids = [[10, 10, 10], [5, 5, 5], [20, 20, 20]]) == 35\n assert candidate(cuboids = [[1, 1, 1], [2, 2, 2], [3, 3, 3]]) == 6\n assert candidate(cuboids = [[50, 45, 20], [95, 37, 53], [45, 23, 12]]) == 190\n assert candidate(cuboids = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 18\n assert candidate(cuboids = [[38, 25, 45], [76, 35, 3]]) == 76\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6]]) == 40\n assert candidate(cuboids = [[100, 100, 1], [100, 100, 1], [100, 100, 1]]) == 300\n assert candidate(cuboids = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 4\n assert candidate(cuboids = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) == 10\n assert candidate(cuboids = [[1, 2, 2], [3, 4, 4], [5, 6, 6]]) == 12\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8], [7, 7, 7]]) == 34\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8]]) == 27\n assert candidate(cuboids = [[7, 11, 17], [7, 17, 11], [11, 7, 17], [11, 17, 7], [17, 7, 11], [17, 11, 7]]) == 102\n assert candidate(cuboids = [[1, 1, 100], [1, 1, 100], [1, 1, 100]]) == 300\n assert candidate(cuboids = [[100, 100, 100], [99, 99, 99], [98, 98, 98]]) == 297\n assert candidate(cuboids = [[10, 20, 30], [30, 20, 10], [20, 10, 30]]) == 90\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [60, 60, 60]]) == 210\n assert candidate(cuboids = [[3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11]]) == 56\n assert candidate(cuboids = [[9, 8, 7], [6, 5, 4], [3, 2, 1], [12, 11, 10], [15, 14, 13]]) == 45\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [15, 15, 15], [25, 25, 25], [30, 30, 30]]) == 100\n assert candidate(cuboids = [[20, 20, 20], [20, 20, 15], [20, 15, 10], [15, 10, 5]]) == 75\n assert candidate(cuboids = [[3, 4, 5], [1, 2, 6], [4, 5, 3], [5, 3, 4], [6, 2, 1]]) == 15\n assert candidate(cuboids = [[50, 50, 50], [49, 49, 49], [48, 48, 48], [47, 47, 47], [46, 46, 46], [45, 45, 45], [44, 44, 44]]) == 329\n assert candidate(cuboids = [[10, 1, 1], [9, 2, 2], [8, 3, 3], [7, 4, 4], [6, 5, 5], [5, 6, 6], [4, 7, 7], [3, 8, 8], [2, 9, 9], [1, 10, 10], [10, 9, 8], [9, 8, 7], [8, 7, 6], [7, 6, 5], [6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1], [2, 1, 10], [1, 10, 9]]) == 64\n assert candidate(cuboids = [[30, 20, 10], [20, 10, 5], [10, 5, 2], [5, 2, 1], [2, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 70\n assert candidate(cuboids = [[20, 30, 40], [40, 30, 20], [10, 5, 15], [5, 10, 15]]) == 110\n assert candidate(cuboids = [[1, 3, 5], [1, 4, 6], [1, 5, 7], [2, 4, 8], [2, 5, 9], [3, 5, 11]]) == 39\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]]) == 55\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [60, 60, 60], [70, 70, 70], [80, 80, 80]]) == 360\n assert candidate(cuboids = [[60, 50, 40], [50, 40, 30], [40, 30, 20], [30, 20, 10], [20, 10, 5], [10, 5, 2], [5, 2, 1]]) == 215\n assert candidate(cuboids = [[1, 3, 2], [2, 1, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]]) == 33\n assert candidate(cuboids = [[1, 2, 2], [2, 2, 1], [2, 1, 2], [2, 2, 3], [3, 2, 2], [2, 3, 2]]) == 15\n assert candidate(cuboids = [[10, 20, 30], [15, 25, 40], [20, 30, 50], [25, 40, 60], [30, 50, 70]]) == 250\n assert candidate(cuboids = [[10, 11, 12], [12, 10, 11], [11, 12, 10], [10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40]]) == 136\n assert candidate(cuboids = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 1, 2], [2, 3, 1]]) == 18\n assert candidate(cuboids = [[3, 6, 5], [4, 4, 7], [5, 6, 7], [3, 5, 8], [2, 3, 4]]) == 18\n assert candidate(cuboids = [[99, 99, 99], [98, 98, 98], [97, 97, 97], [96, 96, 96], [95, 95, 95], [94, 94, 94]]) == 579\n assert candidate(cuboids = [[50, 40, 30], [40, 30, 20], [30, 20, 10], [20, 10, 5], [10, 5, 1], [9, 8, 7], [8, 7, 6], [7, 6, 5], [6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1]]) == 165\n assert candidate(cuboids = [[20, 30, 40], [10, 20, 30], [15, 25, 35], [5, 10, 15], [25, 35, 45]]) == 165\n assert candidate(cuboids = [[8, 8, 8], [9, 9, 9], [7, 7, 7], [6, 6, 6], [10, 10, 10]]) == 40\n assert candidate(cuboids = [[10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 10, 10]]) == 100\n assert candidate(cuboids = [[10, 20, 30], [5, 15, 25], [40, 60, 70], [15, 25, 5]]) == 150\n assert candidate(cuboids = [[2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]]) == 30\n assert candidate(cuboids = [[40, 50, 60], [20, 30, 40], [10, 20, 30], [5, 10, 15], [25, 35, 45]]) == 190\n assert candidate(cuboids = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 1, 1], [2, 2, 2], [3, 3, 3]]) == 22\n assert candidate(cuboids = [[50, 30, 20], [40, 25, 15], [60, 35, 25], [70, 40, 30], [80, 45, 35]]) == 300\n assert candidate(cuboids = [[10, 20, 30], [30, 20, 10], [20, 30, 10], [10, 30, 20], [30, 10, 20], [20, 10, 30]]) == 180\n assert candidate(cuboids = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [3, 1, 2], [1, 3, 2], [2, 3, 1], [4, 5, 6], [6, 5, 4], [5, 4, 6], [6, 4, 5], [5, 6, 4], [4, 6, 5]]) == 54\n assert candidate(cuboids = [[20, 20, 20], [19, 19, 19], [18, 18, 18], [17, 17, 17], [16, 16, 16], [15, 15, 15]]) == 105\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50]]) == 150\n assert candidate(cuboids = [[1, 1, 100], [1, 100, 1], [100, 1, 1], [1, 1, 50], [1, 50, 1], [50, 1, 1]]) == 450\n assert candidate(cuboids = [[5, 5, 5], [5, 5, 6], [5, 5, 7], [5, 5, 8], [5, 5, 9]]) == 35\n assert candidate(cuboids = [[7, 8, 9], [9, 10, 11], [12, 13, 14], [15, 16, 17], [18, 19, 20]]) == 71\n assert candidate(cuboids = [[10, 10, 10], [10, 10, 5], [10, 5, 10], [5, 10, 10], [10, 5, 5], [5, 10, 5], [5, 5, 10]]) == 70\n assert candidate(cuboids = [[50, 45, 20], [95, 37, 53], [45, 23, 12], [53, 37, 95], [23, 12, 45], [12, 45, 23]]) == 375\n assert candidate(cuboids = [[90, 10, 10], [10, 90, 10], [10, 10, 90], [45, 45, 45], [60, 60, 60], [80, 80, 80]]) == 270\n assert candidate(cuboids = [[5, 12, 2], [2, 9, 12], [12, 3, 4], [8, 6, 10], [7, 12, 5], [1, 15, 15], [15, 1, 15], [15, 15, 1]]) == 45\n assert candidate(cuboids = [[5, 3, 1], [7, 5, 3], [9, 7, 5], [11, 9, 7], [13, 11, 9], [15, 13, 11]]) == 60\n assert candidate(cuboids = [[7, 3, 1], [8, 4, 2], [9, 5, 3], [10, 6, 4], [11, 7, 5], [12, 8, 6]]) == 57\n assert candidate(cuboids = [[10, 10, 10], [15, 15, 15], [20, 20, 20], [25, 25, 25], [30, 30, 30], [35, 35, 35], [40, 40, 40], [45, 45, 45]]) == 220\n assert candidate(cuboids = [[8, 1, 6], [3, 5, 7], [4, 9, 2], [2, 6, 8], [5, 7, 3], [9, 4, 1]]) == 18\n assert candidate(cuboids = [[30, 20, 10], [25, 20, 10], [20, 15, 5], [15, 10, 5], [10, 6, 3], [5, 3, 1]]) == 105\n assert candidate(cuboids = [[50, 45, 20], [95, 37, 53], [45, 23, 12], [60, 60, 60], [10, 10, 10], [20, 20, 20], [30, 30, 30]]) == 200\n assert candidate(cuboids = [[5, 12, 17], [3, 8, 9], [1, 2, 3], [6, 7, 8], [4, 10, 11], [2, 5, 6]]) == 46\n assert candidate(cuboids = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [3, 1, 2], [2, 3, 1], [1, 3, 2]]) == 18\n assert candidate(cuboids = [[100, 1, 1], [99, 2, 2], [98, 3, 3], [97, 4, 4], [96, 5, 5], [95, 6, 6], [94, 7, 7], [93, 8, 8], [92, 9, 9], [91, 10, 10]]) == 100\n assert candidate(cuboids = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 30\n assert candidate(cuboids = [[8, 8, 8], [7, 7, 9], [6, 6, 10], [5, 5, 11], [4, 4, 12], [3, 3, 13], [2, 2, 14], [1, 1, 15]]) == 15\n assert candidate(cuboids = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60], [50, 60, 70]]) == 250\n assert candidate(cuboids = [[100, 50, 25], [50, 25, 12], [25, 12, 6], [12, 6, 3], [6, 3, 1], [3, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 199\n assert candidate(cuboids = [[10, 20, 30], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 57\n assert candidate(cuboids = [[4, 6, 7], [1, 2, 3], [4, 5, 6], [10, 12, 32], [1, 1, 4]]) == 49\n assert candidate(cuboids = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6]]) == 21\n assert candidate(cuboids = [[7, 11, 17], [11, 7, 17], [17, 11, 7], [7, 17, 11], [11, 17, 7], [17, 7, 11], [7, 11, 17], [11, 7, 17], [17, 11, 7]]) == 153\n assert candidate(cuboids = [[20, 20, 20], [10, 10, 10], [30, 30, 30], [15, 15, 15]]) == 75\n assert candidate(cuboids = [[1, 1, 100], [2, 2, 99], [3, 3, 98], [4, 4, 97], [5, 5, 96], [6, 6, 95]]) == 100\n assert candidate(cuboids = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]]) == 33\n assert candidate(cuboids = [[8, 8, 8], [8, 8, 7], [8, 7, 6], [7, 6, 5], [6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1]]) == 49\n assert candidate(cuboids = [[3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]]) == 52\n assert candidate(cuboids = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [1, 3, 2], [3, 1, 2], [2, 1, 3]]) == 18\n assert candidate(cuboids = [[10, 12, 3], [1, 3, 5], [6, 7, 8], [5, 4, 3], [7, 8, 9], [8, 9, 10]]) == 37\n assert candidate(cuboids = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 40\n assert candidate(cuboids = [[9, 8, 7], [8, 7, 6], [7, 6, 5], [6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1]]) == 42\n assert candidate(cuboids = [[23, 28, 32], [28, 32, 23], [32, 23, 28], [11, 29, 31], [29, 31, 11], [31, 11, 29], [12, 16, 24], [16, 24, 12], [24, 12, 16], [16, 24, 14]]) == 192\n assert candidate(cuboids = [[15, 12, 8], [8, 12, 15], [12, 15, 8], [9, 10, 7], [7, 10, 9], [10, 7, 9]]) == 75\n assert candidate(cuboids = [[1, 1, 10], [1, 2, 9], [1, 3, 8], [1, 4, 7], [1, 5, 6], [1, 6, 5], [1, 7, 4], [1, 8, 3], [1, 9, 2], [1, 10, 1]]) == 20\n assert candidate(cuboids = [[30, 50, 70], [20, 40, 60], [10, 30, 50], [5, 15, 25], [1, 2, 3]]) == 208\n assert candidate(cuboids = [[25, 15, 10], [15, 10, 5], [10, 5, 2], [5, 3, 1], [3, 2, 1], [2, 1, 1], [1, 1, 1]]) == 61\n assert candidate(cuboids = [[12, 34, 56], [34, 12, 78], [56, 78, 12], [78, 12, 34]]) == 290\n assert candidate(cuboids = [[100, 1, 1], [1, 100, 1], [1, 1, 100], [99, 2, 2], [2, 99, 2], [2, 2, 99], [50, 50, 50], [75, 75, 75]]) == 300\n assert candidate(cuboids = [[3, 4, 5], [3, 3, 3], [3, 5, 5], [2, 3, 4], [2, 2, 2], [1, 1, 1], [1, 2, 3]]) == 18\n assert candidate(cuboids = [[15, 10, 5], [10, 8, 4], [5, 4, 2], [30, 20, 10], [20, 15, 5], [10, 6, 3]]) == 90\n assert candidate(cuboids = [[5, 4, 3], [4, 3, 2], [3, 2, 1], [2, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 18\n assert candidate(cuboids = [[1, 1, 1], [1, 2, 2], [2, 2, 2], [1, 3, 3], [2, 3, 3], [3, 3, 3], [1, 4, 4], [2, 4, 4], [3, 4, 4], [4, 4, 4]]) == 22\n assert candidate(cuboids = [[10, 20, 30], [30, 20, 10], [20, 10, 30], [10, 30, 20], [30, 10, 20], [20, 30, 10]]) == 180\n assert candidate(cuboids = [[5, 5, 5], [10, 10, 10], [15, 15, 15], [20, 20, 20], [25, 25, 25]]) == 75\n assert candidate(cuboids = [[5, 20, 30], [20, 30, 5], [30, 5, 20], [5, 30, 20], [30, 20, 5], [20, 5, 30]]) == 180\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]]) == 55\n assert candidate(cuboids = [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) == 26\n assert candidate(cuboids = [[4, 5, 6], [6, 5, 4], [7, 8, 9], [9, 8, 7], [1, 2, 3], [3, 2, 1]]) == 36\n assert candidate(cuboids = [[40, 40, 40], [30, 30, 30], [20, 20, 20], [10, 10, 10], [5, 5, 5], [1, 1, 1], [40, 30, 20], [30, 20, 10], [20, 10, 5], [10, 5, 1]]) == 141\n assert candidate(cuboids = [[9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]]) == 45\n assert candidate(cuboids = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9]]) == 42\n assert candidate(cuboids = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24]]) == 108\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [60, 60, 60], [70, 70, 70], [80, 80, 80], [90, 90, 90], [100, 100, 100]]) == 550\n assert candidate(cuboids = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60], [50, 60, 70], [60, 70, 80], [70, 80, 90], [80, 90, 100]]) == 520\n", "comparison": "exact"}, "public_tests": ["[[50,45,20],[95,37,53],[45,23,12]]", "[[38,25,45],[76,35,3]]", "[[7,11,17],[7,17,11],[11,7,17],[11,17,7],[17,7,11],[17,11,7]]"], "hints": ["Does the dynamic programming sound like the right algorithm after sorting?", "Let's say box1 can be placed on top of box2. No matter what orientation box2 is in, we can rotate box1 so that it can be placed on top. Why don't we orient everything such that height is the biggest?"], "metadata": {"canonical_parameter_names": ["cuboids"], "leetcode_dataset_entry_point": "Solution().maxHeight", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:38+00:00", "tests_total": 108, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxHeight(self, cuboids: List[List[int]]) -> int:", "container": "Solution", "callable": "maxHeight", "parameters": [{"name": "cuboids", "type": "List[List[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1694, "task_id": "reformat-phone-number", "difficulty": "Easy", "problem_description": "You are given a phone number as a string number. number consists of digits, spaces ' ', and/or dashes '-'.\n\nYou would like to reformat the phone number in a certain manner. Firstly, remove all spaces and dashes. Then, group the digits from left to right into blocks of length 3 until there are 4 or fewer digits. The final digits are then grouped as follows:\n\n- 2 digits: A single block of length 2.\n- 3 digits: A single block of length 3.\n- 4 digits: Two blocks of length 2 each.\n\nThe blocks are then joined by dashes. Notice that the reformatting process should never produce any blocks of length 1 and produce at most two blocks of length 2.\n\nReturn the phone number after formatting.\n\nExample 1:\n\nInput: number = \"1-23-45 6\"\nOutput: \"123-456\"\nExplanation: The digits are \"123456\".\nStep 1: There are more than 4 digits, so group the next 3 digits. The 1st block is \"123\".\nStep 2: There are 3 digits remaining, so put them in a single block of length 3. The 2nd block is \"456\".\nJoining the blocks gives \"123-456\".\n\nExample 2:\n\nInput: number = \"123 4-567\"\nOutput: \"123-45-67\"\nExplanation: The digits are \"1234567\".\nStep 1: There are more than 4 digits, so group the next 3 digits. The 1st block is \"123\".\nStep 2: There are 4 digits left, so split them into two blocks of length 2. The blocks are \"45\" and \"67\".\nJoining the blocks gives \"123-45-67\".\n\nExample 3:\n\nInput: number = \"123 4-5678\"\nOutput: \"123-456-78\"\nExplanation: The digits are \"12345678\".\nStep 1: The 1st block is \"123\".\nStep 2: The 2nd block is \"456\".\nStep 3: There are 2 digits left, so put them in a single block of length 2. The 3rd block is \"78\".\nJoining the blocks gives \"123-456-78\".\n\nConstraints:\n\n- 2 <= number.length <= 100\n- number consists of digits and the characters '-' and ' '.\n- There are at least two digits in number.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(number = \"12 345 678\") == \"123-456-78\"\n assert candidate(number = \"1234-5678-9012\") == \"123-456-789-012\"\n assert candidate(number = \"12 345 678 90\") == \"123-456-78-90\"\n assert candidate(number = \"123456789\") == \"123-456-789\"\n assert candidate(number = \"12 345 678 901\") == \"123-456-789-01\"\n assert candidate(number = \"12 345-6789\") == \"123-456-789\"\n assert candidate(number = \"123456789012\") == \"123-456-789-012\"\n assert candidate(number = \"1234567890123\") == \"123-456-789-01-23\"\n assert candidate(number = \"12-345 67-89--01\") == \"123-456-789-01\"\n assert candidate(number = \"1234\") == \"12-34\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0\") == \"123-456-78-90\"\n assert candidate(number = \"1234567\") == \"123-45-67\"\n assert candidate(number = \"1 234 567 8901\") == \"123-456-789-01\"\n assert candidate(number = \"123 4567\") == \"123-45-67\"\n assert candidate(number = \"12 345 6789\") == \"123-456-789\"\n assert candidate(number = \"1-23-45 6\") == \"123-456\"\n assert candidate(number = \"12\") == \"12\"\n assert candidate(number = \"1234567890\") == \"123-456-78-90\"\n assert candidate(number = \"123 4-5678\") == \"123-456-78\"\n assert candidate(number = \"123 4-567\") == \"123-45-67\"\n assert candidate(number = \"123-4567890123\") == \"123-456-789-01-23\"\n assert candidate(number = \"1 234-567 890\") == \"123-456-78-90\"\n assert candidate(number = \"123-456-7890\") == \"123-456-78-90\"\n assert candidate(number = \"123\") == \"123\"\n assert candidate(number = \"123-456-789-012-345-678-901-234-567-890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"12 34-56-78-90\") == \"123-456-78-90\"\n assert candidate(number = \"12345 67890 123456 7890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12345678901234567890123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3\") == \"123-456-789-01-23\"\n assert candidate(number = \"1234-5678-9012-3456-7890-12\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"1234-5678-9012-3456-7890-1234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \" 1-23-45-67-89-01-23 \") == \"123-456-789-01-23\"\n assert candidate(number = \"12345678-90123456-78901234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 1234567890 12\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-90-12\"\n assert candidate(number = \"123 4567 890 1234 56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123-456-789-012-345-678-901-234-56\") == \"123-456-789-012-345-678-901-234-56\"\n assert candidate(number = \"123 456 7890 1234567890 1234567890 123\") == \"123-456-789-012-345-678-901-234-567-890-123\"\n assert candidate(number = \"12345678901234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12345678901234567890123456789012345\") == \"123-456-789-012-345-678-901-234-567-890-123-45\"\n assert candidate(number = \"12 34 56 78 90 12 34 56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"1234567890-12345-678-9\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"1-234-56789-012345\") == \"123-456-789-012-345\"\n assert candidate(number = \"123 456 7890 12345 678 90\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1234567890123456789012\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"12-345-6789-012345-6789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"12 3456 789 012 3456 78\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"1-23-45-67-89-01-23-45-67-89-01-23\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1 2345678901234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"123 456 789 012 345 678 901 234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9-0-1\") == \"123-456-789-012-345-678-901\"\n assert candidate(number = \"12 345 678 901 234 567\") == \"123-456-789-012-345-67\"\n assert candidate(number = \"12345678901234567890123456789012345678\") == \"123-456-789-012-345-678-901-234-567-890-123-456-78\"\n assert candidate(number = \"12345678901234567890123456789012\") == \"123-456-789-012-345-678-901-234-567-890-12\"\n assert candidate(number = \"1234 5678 9012 3456 7890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1 234 567 890 123 456 789 012 345\") == \"123-456-789-012-345-678-901-23-45\"\n assert candidate(number = \"123-45678901234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-78-90\"\n assert candidate(number = \"123-45 67-89 01 2\") == \"123-456-789-012\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0 1 2 3 4 5\") == \"123-456-789-012-345\"\n assert candidate(number = \"1234567890 123 4567 890 1234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"1234-567890-1234567890-12345\") == \"123-456-789-012-345-678-901-23-45\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"123456789012345678901234567890123456\") == \"123-456-789-012-345-678-901-234-567-890-123-456\"\n assert candidate(number = \"1234567890-1234567890-1234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"12345-6789-0123-456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12-345-678-90\") == \"123-456-78-90\"\n assert candidate(number = \"-12 34 56 78 90 -\") == \"123-456-78-90\"\n assert candidate(number = \"123 456-789-0123-4567-8901\") == \"123-456-789-012-345-678-901\"\n assert candidate(number = \"12-345-678-901-234\") == \"123-456-789-012-34\"\n assert candidate(number = \"1234567890-1234567890-1234567890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"12 345 678 901 234 56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123-456-7890-1234-567\") == \"123-456-789-012-345-67\"\n assert candidate(number = \"123 4567 8901 2345\") == \"123-456-789-012-345\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234\") == \"123-456-789-012-345-678-901-234-567-890-12-34\"\n assert candidate(number = \"1-23-456-7890-1234\") == \"123-456-789-012-34\"\n assert candidate(number = \"123456789-0123456789-0123456789-0123\") == \"123-456-789-012-345-678-901-234-567-890-123\"\n assert candidate(number = \"123 456 7890 1234567890 123456\") == \"123-456-789-012-345-678-901-234-56\"\n assert candidate(number = \"123-4567890123456789012345678901234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-78-90\"\n assert candidate(number = \"12-345-67890123456789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"1 23 456 7890 1234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"1234567890-1234567890-1234567890-1234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-78-90\"\n assert candidate(number = \"1234-56789-012345-678\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"-1-23-456-7890-12345-6789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"-1-2-3-4-5-6-7-8-9-0-\") == \"123-456-78-90\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 1234567890 123\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-23\"\n assert candidate(number = \"12-34-56-78-90-12-34-56-78-90-12-34\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"1234567890 1234567890 1234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"123-4567-8901-2345-6789-012\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"123 456 7890 123 456 7890 123 456 7890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 123\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-01-23\"\n assert candidate(number = \"-12- 345-678-9012-3456-\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"1-23-45-67-89-01\") == \"123-456-789-01\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 12\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012\"\n assert candidate(number = \"12345 67890 1234 56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"12-345-67-89-01-23\") == \"123-456-789-01-23\"\n assert candidate(number = \"1234567890-123456-789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"1-23-45 67-890\") == \"123-456-78-90\"\n assert candidate(number = \"-1--2--3--4--5--6--7--8--9--0-\") == \"123-456-78-90\"\n assert candidate(number = \"123-456-789-012-345-678\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"123 456 789 012\") == \"123-456-789-012\"\n assert candidate(number = \"123456789012345678901234567890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"123-456 789-012 345-678\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"1-23-45-67-89-01-23-45-67-89-01\") == \"123-456-789-012-345-678-901\"\n assert candidate(number = \"123456789-0123456789012345\") == \"123-456-789-012-345-678-901-23-45\"\n assert candidate(number = \"123 456789 01234 567\") == \"123-456-789-012-345-67\"\n assert candidate(number = \"123-4567-8901-2345-6789-0123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1234-5678-9012-3456-7890-1234-56\") == \"123-456-789-012-345-678-901-234-56\"\n assert candidate(number = \"1-234 567-89 0\") == \"123-456-78-90\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0 1 2 3\") == \"123-456-789-01-23\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9-0\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1234-5678-9012-3456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123456789-0123456789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"123 456 7890 1234567890 123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"-123-456-789-012-345-678-90\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12 34 56 78 90 12 34 56 78\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"123-456-789-012-3456-7890-123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1234567890 1234567890 1234567890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"12-34-56-78-90-12-34\") == \"123-456-789-012-34\"\n assert candidate(number = \"1234567890123456789012345678901234\") == \"123-456-789-012-345-678-901-234-567-890-12-34\"\n assert candidate(number = \"123-4567-89012345-6789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3-4\") == \"123-456-789-012-34\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9\") == \"123-456-789\"\n assert candidate(number = \"123-4567-89012-3456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"12 34 56 78 90 12 34\") == \"123-456-789-012-34\"\n assert candidate(number = \"123-456-789-012-345-6789-0123-4567-8901\") == \"123-456-789-012-345-678-901-234-567-89-01\"\n assert candidate(number = \"123456789012345678901234567890123\") == \"123-456-789-012-345-678-901-234-567-890-123\"\n assert candidate(number = \"123 456 789 012 345 678 9012\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"123-456-789-012-345-678-90\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"-123-456-789-012-345-678-901-\") == \"123-456-789-012-345-678-901\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"1234567890-1234567890-1234567890-1234\") == \"123-456-789-012-345-678-901-234-567-890-12-34\"\n assert candidate(number = \"123 456 7890 1234 5678\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"123 4567 8901 2345 6789 0123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1234 5678 9012 3456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"12345 67890 123 456 7890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0\") == \"123-456-78-90\"\n assert candidate(number = \"1 234 567 890 123 456 789 012\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"12345-67890-12345-67890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12-345 678 901-234\") == \"123-456-789-012-34\"\n assert candidate(number = \"123-4567-8901-2345-6789-0123-4567-8901-2345\") == \"123-456-789-012-345-678-901-234-567-890-123-45\"\n assert candidate(number = \"12 34 56 78 90 12 34 56 78 90 12 34 56 78 90\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"1234-567890-1234567-890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"123 4567 89012 3456 789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"12 34 567 890 123-4\") == \"123-456-789-012-34\"\n assert candidate(number = \"123 456 789 012 345\") == \"123-456-789-012-345\"\n assert candidate(number = \"123 4567 890 123 45 6789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"12-34-56-78-90-12-34-56-78\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"1234567890-1234-5678901234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"123-45-678901234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12-34-56-78-90-12-34-56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123 456 789 012 345 678 901 234 567 890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"1-23-45-67-89-01-23-45-67\") == \"123-456-789-012-345-67\"\n assert candidate(number = \"12-345-678-9012-34\") == \"123-456-789-012-34\"\n assert candidate(number = \"12-345-6789-0123-4567-8901-2345-6789\") == \"123-456-789-012-345-678-901-234-567-89\"\n assert candidate(number = \"12345-6789-01234-5678-90123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1234567890123456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123-456-7890-123456\") == \"123-456-789-012-34-56\"\n", "comparison": "exact"}, "public_tests": ["\"1-23-45 6\"", "\"123 4-567\"", "\"123 4-5678\""], "hints": ["Discard all the spaces and dashes.", "Use a while loop. While the string still has digits, check its length and see which rule to apply."], "metadata": {"canonical_parameter_names": ["number"], "leetcode_dataset_entry_point": "Solution().reformatNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:43+00:00", "tests_total": 161, "tests_dropped": 2, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def reformatNumber(self, number: str) -> str:", "container": "Solution", "callable": "reformatNumber", "parameters": [{"name": "number", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1695, "task_id": "maximum-erasure-value", "difficulty": "Medium", "problem_description": "You are given an array of positive integers nums and want to erase a subarray containing unique elements. The score you get by erasing the subarray is equal to the sum of its elements.\n\nReturn the maximum score you can get by erasing exactly one subarray.\n\nAn array b is called to be a subarray of a if it forms a contiguous subsequence of a, that is, if it is equal to a[l],a[l+1],...,a[r] for some (l,r).\n\nExample 1:\n\nInput: nums = [4,2,4,5,6]\nOutput: 17\nExplanation: The optimal subarray here is [2,4,5,6].\n\nExample 2:\n\nInput: nums = [5,2,1,2,5,2,1,2,5]\nOutput: 8\nExplanation: The optimal subarray here is [5,2,1] or [1,2,5].\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 18\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1]) == 55\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 6]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [10, 5, 2, 7, 8, 7, 4, 5]) == 32\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 6, 5, 7, 8, 9, 8, 10]) == 35\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996]) == 49990\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7, 8, 9]) == 42\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [9, 9, 9, 9, 10, 9, 9, 9]) == 19\n assert candidate(nums = [4, 2, 4, 5, 6]) == 17\n assert candidate(nums = [5, 2, 1, 2, 5, 2, 1, 2, 5]) == 8\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 11\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 2500\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 19\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 21\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 99955\n assert candidate(nums = [400, 300, 200, 100, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 12000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1]) == 595\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 15, 15]) == 54\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 55\n assert candidate(nums = [3, 1, 2, 4, 5, 6, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 324\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 1810\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 210\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 99955\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 10000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5]) == 45\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 3\n assert candidate(nums = [1, 2, 3, 1, 4, 5, 6, 2, 3, 7, 8, 9, 10, 1, 2, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 450\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 210\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 5, 7, 8, 9, 8, 10, 11, 10, 12, 13, 12, 14, 15]) == 54\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 639\n assert candidate(nums = [1, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 324\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996, 6, 9995, 7, 9994, 8, 9993, 9, 9992, 10, 9991]) == 100010\n assert candidate(nums = [2, 3, 1, 4, 5, 6, 1, 2, 3, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 3, 5, 7, 9, 1]) == 55\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 1810\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 10000]) == 99955\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12]) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(nums = [9999, 10000, 9999, 10000, 9999, 10000, 9999, 10000, 9999, 10000, 9999, 10000]) == 19999\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 66\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 204\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [3, 1, 2, 4, 5, 3, 6, 7, 8, 9, 1, 2, 3, 4]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 55\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 39\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 19\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7]) == 55\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 1275\n assert candidate(nums = [100, 200, 100, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 12000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [2, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 2, 2, 2, 2]) == 819\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 300\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == 5000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5000]) == 50045\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981]) == 199810\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [3, 1, 2, 4, 2, 3, 5, 6, 7, 8, 9, 1]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 55\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 3, 2, 1, 4, 2, 3, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 820\n assert candidate(nums = [1, 10, 100, 1000, 10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 10, 100, 1000, 10000, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11155\n assert candidate(nums = [5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2]) == 7\n assert candidate(nums = [10, 9, 8, 7, 6, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n", "comparison": "exact"}, "public_tests": ["[4,2,4,5,6]", "[5,2,1,2,5,2,1,2,5]"], "hints": ["The main point here is for the subarray to contain unique elements for each index. Only the first subarrays starting from that index have unique elements.", "This can be solved using the two pointers technique"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumUniqueSubarray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:45+00:00", "tests_total": 105, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def maximumUniqueSubarray(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maximumUniqueSubarray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1696, "task_id": "jump-game-vi", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums and an integer k.\n\nYou are initially standing at index 0. In one move, you can jump at most k steps forward without going outside the boundaries of the array. That is, you can jump from index i to any index in the range [i + 1, min(n - 1, i + k)] inclusive.\n\nYou want to reach the last index of the array (index n - 1). Your score is the sum of all nums[j] for each index j you visited in the array.\n\nReturn the maximum score you can get.\n\nExample 1:\n\nInput: nums = [1,-1,-2,4,-7,3], k = 2\nOutput: 7\nExplanation: You can choose your jumps forming the subsequence [1,-1,4,3] (underlined above). The sum is 7.\n\nExample 2:\n\nInput: nums = [10,-5,-2,4,0,3], k = 3\nOutput: 17\nExplanation: You can choose your jumps forming the subsequence [10,4,3] (underlined above). The sum is 17.\n\nExample 3:\n\nInput: nums = [1,-5,-20,4,-1,3,-6,-3], k = 2\nOutput: 0\n\nConstraints:\n\n- 1 <= nums.length, k <= 10^5\n- -10^4 <= nums[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 55\n assert candidate(nums = [1, -1, -2, 4, -7, 3],k = 2) == 7\n assert candidate(nums = [10, -5, -2, 4, 0, 3],k = 3) == 17\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 4) == -6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 50\n assert candidate(nums = [-10000, -10000, -10000, -10000, -10000],k = 2) == -30000\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 2) == -9\n assert candidate(nums = [5, -1, 5],k = 2) == 10\n assert candidate(nums = [1],k = 1) == 1\n assert candidate(nums = [5, 4, 3, 2, 1],k = 1) == 15\n assert candidate(nums = [100, -100, 100, -100, 100],k = 2) == 300\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000],k = 5) == 50000\n assert candidate(nums = [5, 6, -4, 2, 1],k = 3) == 14\n assert candidate(nums = [1, -5, -20, 4, -1, 3, -6, -3],k = 2) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 15\n assert candidate(nums = [-5, -1, -5],k = 1) == -11\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],k = 2) == 4000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 9\n assert candidate(nums = [1000, -500, 2000, -100, 4000, -200, 3000, -300, 5000, -400],k = 5) == 14600\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == -16\n assert candidate(nums = [1, -10, 5, 6, -4, -5, 10, 1, 2],k = 4) == 25\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 55\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 4) == -19\n assert candidate(nums = [5, -1, -2, -3, -4, -5, 6, -1, 2, -3, -4, -5, 10],k = 5) == 22\n assert candidate(nums = [1000, -2000, 3000, -4000, 5000, -6000, 7000, -8000, 9000],k = 6) == 25000\n assert candidate(nums = [10, 20, 30, 40, 50, -60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 4) == 1140\n assert candidate(nums = [3, 2, -6, 5, 0, -3, 2, 1],k = 3) == 13\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == 5500\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 550\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 55\n assert candidate(nums = [10000, -5000, 5000, 6000, -2000, 3000, 7000, -8000, 4000, 10000],k = 5) == 45000\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],k = 4) == 29\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 5) == 9\n assert candidate(nums = [1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000],k = 10) == 2000\n assert candidate(nums = [-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000],k = 5) == 40000\n assert candidate(nums = [1, -10, 5, 6, -2, 3, 7, -8, 4, 10],k = 3) == 36\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1) == 550\n assert candidate(nums = [10000, -9999, 10000, -9999, 10000, -9999, 10000, -9999, 10000, -9999],k = 2) == 40001\n assert candidate(nums = [5, -1, 3, -2, 7, 1, -4, 8, -3, 2],k = 4) == 26\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 0\n assert candidate(nums = [3, -2, -2, 2, -1, 2, 1, -5, 4],k = 3) == 12\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100],k = 2) == 400\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],k = 5) == 4000\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 3) == 1000\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 4) == 7\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 10) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 210\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 15) == 1\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10],k = 2) == 55\n assert candidate(nums = [3, -1, 2, -5, 6, 2, -1, 4],k = 4) == 17\n assert candidate(nums = [1, -5, 4, 2, -2, -1, 3, 1, -1, 2, -3, 4, -5, 6],k = 3) == 23\n assert candidate(nums = [5, -10, 4, -2, 3, 100, -100, 200, -200, 300],k = 4) == 612\n assert candidate(nums = [10, 5, 2, 7, 8, 9, 3, 5, 2, 1, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5],k = 3) == 102\n assert candidate(nums = [10, -5, -20, 4, -1, 3, -6, -3, 5, 2],k = 4) == 24\n assert candidate(nums = [1, -10, 100, -1000, 10000],k = 3) == 10101\n assert candidate(nums = [-1, -5, -2, -4, -10, -20],k = 2) == -27\n assert candidate(nums = [5, -10, 15, -20, 25, -30, 35, -40, 45, -50, 55, -60, 65, -70, 75, -80],k = 5) == 240\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 15\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 3) == -220\n assert candidate(nums = [3, -1, -1, -1, 10, 5],k = 2) == 17\n assert candidate(nums = [10, -1, 10, -1, 10, -1, 10, -1, 10, -1],k = 5) == 49\n assert candidate(nums = [3, -1, 2, 1, -4, 2, 3, -5, 4],k = 4) == 15\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6],k = 4) == 187\n assert candidate(nums = [1, -5, 10, 20, -30, 5, 15],k = 4) == 51\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 55\n assert candidate(nums = [1000, -1000, 500, -500, 250, -250, 125, -125, 62, -62, 31, -31],k = 5) == 1937\n assert candidate(nums = [5, 3, 2, 1, 7, 6, 4, 8, 9],k = 3) == 45\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 10) == -110\n assert candidate(nums = [1, -10, 2, -20, 3, -30, 4, -40, 5, -50],k = 4) == -35\n assert candidate(nums = [100, -50, 200, -300, 400, -500, 600, -700, 800],k = 3) == 2100\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 4\n assert candidate(nums = [100, -50, -100, 200, -300, 400, 500],k = 3) == 1200\n assert candidate(nums = [10000, -5000, 2000, -1000, 5000, 2000, -2000, 3000, 4000, -1000],k = 3) == 25000\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20],k = 5) == 109\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 20\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 210\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 5) == 50\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 20) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 55\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10],k = 2) == 40\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 4) == 10\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150],k = 3) == -460\n assert candidate(nums = [100, 200, 300, 400, 500],k = 5) == 1500\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 5) == 1000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 55\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n", "comparison": "exact"}, "public_tests": ["[1,-1,-2,4,-7,3]\n2", "[10,-5,-2,4,0,3]\n3", "[1,-5,-20,4,-1,3,-6,-3]\n2"], "hints": ["Let dp[i] be \"the maximum score to reach the end starting at index i\". The answer for dp[i] is nums[i] + max{dp[i+j]} for 1 <= j <= k. That gives an O(n*k) solution.", "Instead of checking every j for every i, keep track of the largest dp[i] values in a heap and calculate dp[i] from right to left. When the largest value in the heap is out of bounds of the current index, remove it and keep checking."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxResult", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:48+00:00", "tests_total": 92, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming", "queue", "heap-priority-queue", "monotonic-queue"]}, "language": "python", "interface": {"raw_signature": "def maxResult(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "maxResult", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1697, "task_id": "checking-existence-of-edge-length-limited-paths", "difficulty": "Hard", "problem_description": "An undirected graph of n nodes is defined by edgeList, where edgeList[i] = [u_i, v_i, dis_i] denotes an edge between nodes u_i and v_i with distance dis_i. Note that there may be multiple edges between two nodes.\n\nGiven an array queries, where queries[j] = [p_j, q_j, limit_j], your task is to determine for each queries[j] whether there is a path between p_j and q_jsuch that each edge on the path has a distance strictly less than limit_j .\n\nReturn a boolean array answer, where answer.length == queries.length and the j^th value of answer is true if there is a path for queries[j] is true, and false otherwise.\n\nExample 1:\n\nInput: n = 3, edgeList = [[0,1,2],[1,2,4],[2,0,8],[1,0,16]], queries = [[0,1,2],[0,2,5]]\nOutput: [false,true]\nExplanation: The above figure shows the given graph. Note that there are two overlapping edges between 0 and 1 with distances 2 and 16.\nFor the first query, between 0 and 1 there is no path where each distance is less than 2, thus we return false for this query.\nFor the second query, there is a path (0 -> 1 -> 2) of two edges with distances less than 5, thus we return true for this query.\n\nExample 2:\n\nInput: n = 5, edgeList = [[0,1,10],[1,2,5],[2,3,9],[3,4,13]], queries = [[0,4,14],[1,4,13]]\nOutput: [true,false]\nExplanation: The above figure shows the given graph.\n\nConstraints:\n\n- 2 <= n <= 10^5\n- 1 <= edgeList.length, queries.length <= 10^5\n- edgeList[i].length == 3\n- queries[j].length == 3\n- 0 <= u_i, v_i, p_j, q_j <= n - 1\n- u_i != v_i\n- p_j != q_j\n- 1 <= dis_i, limit_j <= 10^9\n- There may be multiple edges between two nodes.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,edgeList = [[0, 1, 2], [1, 2, 4], [2, 0, 8], [1, 0, 16]],queries = [[0, 1, 2], [0, 2, 5]]) == [False, True]\n assert candidate(n = 7,edgeList = [[0, 1, 5], [1, 2, 7], [2, 3, 10], [3, 4, 3], [4, 5, 2], [5, 6, 6], [6, 0, 1]],queries = [[0, 6, 8], [3, 5, 4]]) == [True, True]\n assert candidate(n = 6,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5]],queries = [[0, 5, 6], [0, 5, 10], [0, 5, 3]]) == [True, True, False]\n assert candidate(n = 7,edgeList = [[0, 1, 9], [0, 2, 3], [1, 3, 2], [2, 3, 8], [2, 4, 6], [3, 4, 5], [3, 5, 7], [4, 5, 1]],queries = [[0, 4, 8], [1, 2, 4], [3, 5, 6]]) == [True, False, True]\n assert candidate(n = 6,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5]],queries = [[0, 5, 6], [1, 4, 5], [2, 3, 4]]) == [True, True, True]\n assert candidate(n = 4,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 0, 20]],queries = [[0, 3, 15], [1, 2, 8]]) == [False, False]\n assert candidate(n = 2,edgeList = [[0, 1, 1]],queries = [[0, 1, 2], [0, 1, 1]]) == [True, False]\n assert candidate(n = 6,edgeList = [[0, 1, 4], [1, 2, 3], [2, 3, 1], [3, 4, 5], [4, 5, 6]],queries = [[0, 5, 10], [1, 4, 8]]) == [True, True]\n assert candidate(n = 4,edgeList = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 0, 1]],queries = [[0, 3, 2], [1, 2, 1]]) == [True, False]\n assert candidate(n = 4,edgeList = [[0, 1, 3], [1, 2, 1], [2, 3, 2], [3, 0, 4]],queries = [[0, 2, 4], [1, 3, 5]]) == [True, True]\n assert candidate(n = 5,edgeList = [[0, 1, 10], [1, 2, 5], [2, 3, 9], [3, 4, 13]],queries = [[0, 4, 14], [1, 4, 13]]) == [True, False]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 5]],queries = [[0, 9, 4], [0, 9, 5], [0, 9, 6], [0, 9, 7], [0, 9, 8]]) == [False, False, True, True, True]\n assert candidate(n = 12,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 0, 1200], [0, 2, 150], [2, 4, 250], [4, 6, 350], [6, 8, 450], [8, 10, 550], [10, 1, 650], [1, 3, 750], [3, 5, 850], [5, 7, 950], [7, 9, 1050], [9, 11, 1150], [11, 3, 1250]],queries = [[0, 11, 700], [2, 10, 550], [4, 8, 400], [6, 0, 250]]) == [False, False, False, False]\n assert candidate(n = 6,edgeList = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 0, 5], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 0, 10], [5, 1, 10]],queries = [[0, 3, 6], [1, 4, 7], [2, 5, 8]]) == [True, True, True]\n assert candidate(n = 50,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 12, 1200], [12, 13, 1300], [13, 14, 1400], [14, 15, 1500], [15, 16, 1600], [16, 17, 1700], [17, 18, 1800], [18, 19, 1900], [19, 20, 2000], [20, 21, 2100], [21, 22, 2200], [22, 23, 2300], [23, 24, 2400], [24, 25, 2500], [25, 26, 2600], [26, 27, 2700], [27, 28, 2800], [28, 29, 2900], [29, 30, 3000], [30, 31, 3100], [31, 32, 3200], [32, 33, 3300], [33, 34, 3400], [34, 35, 3500], [35, 36, 3600], [36, 37, 3700], [37, 38, 3800], [38, 39, 3900], [39, 40, 4000], [40, 41, 4100], [41, 42, 4200], [42, 43, 4300], [43, 44, 4400], [44, 45, 4500], [45, 46, 4600], [46, 47, 4700], [47, 48, 4800], [48, 49, 4900], [49, 0, 5000]],queries = [[0, 49, 5010], [1, 48, 5020], [2, 47, 5030], [3, 46, 5040], [4, 45, 5050], [5, 44, 5060], [6, 43, 5070], [7, 42, 5080], [8, 41, 5090], [9, 40, 5100], [10, 39, 5110], [11, 38, 5120], [12, 37, 5130], [13, 36, 5140], [14, 35, 5150], [15, 34, 5160], [16, 33, 5170], [17, 32, 5180], [18, 31, 5190], [19, 30, 5200], [20, 29, 5210], [21, 28, 5220], [22, 27, 5230], [23, 26, 5240], [24, 25, 5250], [0, 25, 2600], [1, 24, 2700], [2, 23, 2800], [3, 22, 2900], [4, 21, 3000], [5, 20, 3100], [6, 19, 3200], [7, 18, 3300], [8, 17, 3400], [9, 16, 3500], [10, 15, 3600], [11, 14, 3700], [12, 13, 3800]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 2], [1, 2, 4], [2, 3, 6], [3, 4, 8], [4, 5, 10], [5, 6, 12], [6, 7, 14], [7, 8, 16], [8, 9, 18], [9, 10, 20], [10, 11, 22], [11, 12, 24], [12, 13, 26], [13, 14, 28], [14, 15, 30], [15, 16, 32], [16, 17, 34], [17, 18, 36], [18, 19, 38]],queries = [[0, 19, 40], [1, 18, 39], [2, 17, 38], [3, 16, 37], [4, 15, 36], [5, 14, 35], [6, 13, 34], [7, 12, 33], [8, 11, 32], [9, 10, 31]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 12, 1200], [12, 13, 1300], [13, 14, 1400], [14, 0, 1500]],queries = [[0, 14, 1200], [1, 13, 1100], [2, 12, 1000], [3, 11, 900], [4, 10, 800]]) == [False, False, False, False, False]\n assert candidate(n = 6,edgeList = [[0, 1, 100], [0, 2, 200], [1, 3, 300], [2, 3, 400], [1, 4, 500], [2, 5, 600], [3, 5, 700]],queries = [[0, 5, 800], [0, 5, 400], [0, 3, 350], [0, 4, 600]]) == [True, False, True, True]\n assert candidate(n = 12,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [0, 4, 10], [4, 5, 20], [5, 6, 25], [6, 7, 30], [7, 8, 35], [8, 9, 40], [9, 10, 45], [10, 11, 50], [0, 11, 60]],queries = [[0, 11, 65], [0, 11, 55], [0, 5, 25], [5, 10, 45]]) == [True, True, True, False]\n assert candidate(n = 8,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 0, 80], [0, 3, 5], [1, 4, 15], [2, 5, 25], [3, 6, 35], [4, 7, 45], [5, 0, 55], [6, 1, 65], [7, 2, 75]],queries = [[0, 7, 40], [2, 6, 35], [4, 0, 60], [1, 5, 75]]) == [False, False, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 10]],queries = [[0, 9, 5], [0, 9, 15], [2, 7, 6]]) == [False, True, False]\n assert candidate(n = 8,edgeList = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [0, 7, 9], [0, 6, 10], [1, 5, 11], [2, 4, 12]],queries = [[0, 7, 8], [1, 5, 9], [2, 4, 10], [3, 6, 11], [0, 5, 12], [1, 6, 13], [2, 7, 14], [0, 4, 15], [3, 5, 16], [0, 6, 17]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 2], [0, 2, 3], [1, 2, 4], [2, 3, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8], [6, 7, 9], [7, 8, 10], [8, 9, 11], [9, 0, 12]],queries = [[0, 9, 13], [1, 8, 15], [2, 7, 17], [3, 6, 19], [4, 5, 21]]) == [True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],queries = [[0, 9, 10], [0, 5, 6], [3, 7, 5]]) == [True, True, False]\n assert candidate(n = 25,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 12, 120], [12, 13, 130], [13, 14, 140], [14, 15, 150], [15, 16, 160], [16, 17, 170], [17, 18, 180], [18, 19, 190], [19, 20, 200], [20, 21, 210], [21, 22, 220], [22, 23, 230], [23, 24, 240], [0, 24, 250]],queries = [[0, 24, 200], [0, 24, 251], [2, 23, 225], [5, 20, 160]]) == [False, True, False, False]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10]],queries = [[0, 9, 11], [2, 6, 6], [1, 8, 15]]) == [True, False, True]\n assert candidate(n = 15,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 150], [3, 4, 250], [4, 5, 300], [5, 6, 350], [6, 7, 400], [7, 8, 450], [8, 9, 500], [9, 10, 550], [10, 11, 600], [11, 12, 650], [12, 13, 700], [13, 14, 750]],queries = [[0, 14, 800], [1, 13, 900], [2, 12, 1000], [3, 11, 1100], [4, 10, 1200], [5, 9, 1300]]) == [True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 1]],queries = [[0, 9, 15], [2, 6, 8], [4, 7, 12]]) == [True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 15, 75], [15, 16, 80], [16, 17, 85], [17, 18, 90], [18, 19, 95], [19, 0, 100]],queries = [[0, 19, 200], [5, 15, 150], [10, 15, 100]]) == [True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 5, 11], [5, 1, 12]],queries = [[0, 9, 11], [1, 8, 10], [2, 7, 9], [3, 6, 8], [4, 5, 7]]) == [True, True, True, True, True]\n assert candidate(n = 11,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [0, 10, 11]],queries = [[0, 10, 12], [0, 10, 6], [0, 5, 8], [5, 10, 7], [2, 8, 9], [3, 7, 10]]) == [True, False, True, False, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20]],queries = [[0, 19, 15], [1, 18, 14], [2, 17, 13], [3, 16, 12], [4, 15, 11]]) == [False, False, False, False, False]\n assert candidate(n = 50,edgeList = [[0, 1, 5], [1, 2, 15], [2, 3, 25], [3, 4, 35], [4, 5, 45], [5, 6, 55], [6, 7, 65], [7, 8, 75], [8, 9, 85], [9, 10, 95], [10, 11, 105], [11, 12, 115], [12, 13, 125], [13, 14, 135], [14, 15, 145], [15, 16, 155], [16, 17, 165], [17, 18, 175], [18, 19, 185], [19, 20, 195], [20, 21, 205], [21, 22, 215], [22, 23, 225], [23, 24, 235], [24, 25, 245], [25, 26, 255], [26, 27, 265], [27, 28, 275], [28, 29, 285], [29, 30, 295], [30, 31, 305], [31, 32, 315], [32, 33, 325], [33, 34, 335], [34, 35, 345], [35, 36, 355], [36, 37, 365], [37, 38, 375], [38, 39, 385], [39, 40, 395], [40, 41, 405], [41, 42, 415], [42, 43, 425], [43, 44, 435], [44, 45, 445], [45, 46, 455], [46, 47, 465], [47, 48, 475], [48, 49, 485]],queries = [[0, 49, 500], [10, 30, 310], [20, 40, 410]]) == [True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [0, 19, 20]],queries = [[0, 19, 10], [0, 19, 21], [2, 18, 15], [5, 15, 10]]) == [False, True, False, False]\n assert candidate(n = 50,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 20, 20], [20, 21, 21], [21, 22, 22], [22, 23, 23], [23, 24, 24], [24, 25, 25], [25, 26, 26], [26, 27, 27], [27, 28, 28], [28, 29, 29], [29, 30, 30], [30, 31, 31], [31, 32, 32], [32, 33, 33], [33, 34, 34], [34, 35, 35], [35, 36, 36], [36, 37, 37], [37, 38, 38], [38, 39, 39], [39, 40, 40], [40, 41, 41], [41, 42, 42], [42, 43, 43], [43, 44, 44], [44, 45, 45], [45, 46, 46], [46, 47, 47], [47, 48, 48], [48, 49, 49], [0, 49, 50]],queries = [[0, 49, 40], [0, 49, 51], [2, 48, 45], [5, 45, 30]]) == [False, True, False, False]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15], [0, 2, 16], [2, 4, 17], [4, 6, 18], [6, 8, 19], [8, 10, 20], [10, 12, 21], [12, 14, 22], [14, 1, 23], [1, 3, 24], [3, 5, 25], [5, 7, 26], [7, 9, 27], [9, 11, 28], [11, 13, 29], [13, 0, 30]],queries = [[0, 14, 15], [2, 12, 13], [4, 10, 11], [6, 8, 9], [8, 6, 8], [10, 4, 10], [12, 2, 16], [14, 0, 14]]) == [True, True, True, True, False, False, True, False]\n assert candidate(n = 20,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 12, 1200], [12, 13, 1300], [13, 14, 1400], [14, 15, 1500], [15, 16, 1600], [16, 17, 1700], [17, 18, 1800], [18, 19, 1900], [0, 19, 2000]],queries = [[0, 19, 1900], [0, 19, 2000], [1, 18, 3800], [2, 17, 5400], [3, 16, 6900]]) == [False, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15], [0, 7, 20], [1, 8, 21], [2, 9, 22], [3, 10, 23], [4, 11, 24], [5, 12, 25], [6, 13, 26], [7, 14, 27], [8, 0, 28], [9, 1, 29], [10, 2, 30], [11, 3, 31], [12, 4, 32], [13, 5, 33], [14, 6, 34]],queries = [[0, 14, 16], [1, 13, 17], [2, 12, 18], [3, 11, 19], [4, 10, 20], [5, 9, 21], [6, 8, 22], [7, 0, 23], [8, 1, 24], [9, 2, 25], [10, 3, 26], [11, 4, 27], [12, 5, 28], [13, 6, 29], [0, 7, 35], [1, 8, 36], [2, 9, 37], [3, 10, 38], [4, 11, 39], [5, 12, 40], [6, 13, 41], [7, 14, 42]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [0, 14, 15]],queries = [[0, 14, 10], [0, 14, 16], [2, 12, 8]]) == [False, True, False]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [0, 2, 3], [1, 2, 2], [3, 4, 5], [4, 5, 4], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],queries = [[0, 9, 10], [2, 5, 5], [4, 7, 12], [1, 8, 15]]) == [False, False, True, False]\n assert candidate(n = 8,edgeList = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 4], [1, 5, 5], [2, 6, 6], [2, 7, 7], [3, 4, 8], [3, 5, 9], [4, 6, 10], [5, 7, 11]],queries = [[0, 7, 12], [1, 6, 10], [2, 5, 9], [3, 4, 8], [0, 4, 7]]) == [True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 12, 1200], [12, 13, 1300], [13, 14, 1400]],queries = [[0, 14, 1500], [5, 10, 800], [3, 7, 600]]) == [True, False, False]\n assert candidate(n = 15,edgeList = [[0, 1, 20], [1, 2, 30], [2, 3, 40], [3, 4, 50], [4, 5, 60], [5, 6, 70], [6, 7, 80], [7, 8, 90], [8, 9, 100], [9, 10, 110], [10, 11, 120], [11, 12, 130], [12, 13, 140], [13, 14, 150], [14, 0, 160]],queries = [[0, 14, 300], [3, 7, 200], [6, 10, 150]]) == [True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15]],queries = [[0, 7, 8], [1, 8, 9], [2, 9, 10], [3, 10, 11], [4, 11, 12], [5, 12, 13], [6, 13, 14]]) == [True, True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 3], [1, 2, 2], [2, 3, 1], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 10]],queries = [[0, 9, 9], [0, 9, 11], [1, 8, 15], [2, 7, 20]]) == [False, True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20]],queries = [[0, 10, 11], [1, 11, 12], [2, 12, 13], [3, 13, 14], [4, 14, 15], [5, 15, 16], [6, 16, 17], [7, 17, 18], [8, 18, 19], [9, 19, 20]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 0, 1], [0, 9, 2], [1, 8, 2], [2, 7, 2], [3, 6, 2], [4, 5, 2]],queries = [[0, 4, 2], [5, 9, 2], [3, 7, 2]]) == [True, True, True]\n assert candidate(n = 8,edgeList = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 3, 4], [1, 4, 5], [2, 5, 6], [3, 6, 7], [4, 7, 8], [5, 7, 9]],queries = [[0, 7, 15], [1, 6, 10], [2, 5, 7], [3, 4, 4]]) == [True, True, True, False]\n assert candidate(n = 7,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]],queries = [[0, 6, 7], [0, 5, 6], [0, 4, 5], [0, 3, 4], [0, 2, 3], [0, 1, 2]]) == [True, True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14]],queries = [[0, 14, 15], [1, 13, 25], [2, 12, 30], [3, 11, 35], [4, 10, 40]]) == [True, True, True, True, True]\n assert candidate(n = 8,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 2, 3], [1, 3, 4], [2, 4, 5], [3, 5, 6], [4, 6, 7], [5, 7, 8]],queries = [[0, 7, 9], [1, 6, 10], [2, 5, 11]]) == [True, True, True]\n assert candidate(n = 12,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12]],queries = [[0, 6, 7], [1, 7, 8], [2, 8, 9], [3, 9, 10], [4, 10, 11], [5, 11, 12]]) == [True, True, True, True, True, True]\n assert candidate(n = 9,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [0, 8, 9], [1, 7, 10], [2, 6, 11], [3, 5, 12]],queries = [[0, 8, 13], [1, 7, 11], [2, 6, 9], [3, 5, 7]]) == [True, True, True, True]\n assert candidate(n = 12,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 0, 120], [0, 6, 130], [1, 7, 140], [2, 8, 150], [3, 9, 160], [4, 10, 170], [5, 11, 180]],queries = [[0, 11, 125], [1, 10, 135], [2, 9, 145], [3, 8, 155], [4, 7, 165], [5, 6, 175], [0, 7, 185], [1, 8, 195], [2, 11, 205], [3, 0, 215]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 12, 120], [12, 13, 130], [13, 14, 140], [14, 15, 150], [15, 16, 160], [16, 17, 170], [17, 18, 180], [18, 19, 190], [19, 0, 200]],queries = [[0, 19, 210], [1, 18, 220], [2, 17, 230], [3, 16, 240], [4, 15, 250], [5, 14, 260], [6, 13, 270], [7, 12, 280], [8, 11, 290], [9, 10, 300]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 3], [1, 2, 1], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 2]],queries = [[0, 9, 15], [2, 5, 12], [1, 8, 6]]) == [True, True, False]\n assert candidate(n = 20,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 12, 120], [12, 13, 130], [13, 14, 140], [14, 15, 150], [15, 16, 160], [16, 17, 170], [17, 18, 180], [18, 19, 190]],queries = [[0, 19, 200], [5, 15, 120], [3, 10, 80]]) == [True, False, False]\n assert candidate(n = 10,edgeList = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]],queries = [[0, 9, 11], [0, 9, 5], [0, 4, 10]]) == [True, False, True]\n assert candidate(n = 10,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 0, 50], [0, 5, 55], [5, 1, 60], [1, 6, 65], [6, 2, 70], [2, 7, 75]],queries = [[0, 9, 60], [1, 8, 55], [2, 7, 50], [3, 6, 45], [4, 5, 40]]) == [True, True, True, True, True]\n assert candidate(n = 18,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 15, 75], [15, 16, 80], [16, 17, 85], [17, 0, 90], [0, 8, 95], [1, 9, 100], [2, 10, 105], [3, 11, 110], [4, 12, 115], [5, 13, 120], [6, 14, 125], [7, 15, 130], [8, 16, 135], [9, 17, 140], [10, 0, 145], [11, 1, 150], [12, 2, 155], [13, 3, 160], [14, 4, 165], [15, 5, 170], [16, 6, 175], [17, 7, 180]],queries = [[0, 17, 175], [1, 16, 180], [2, 15, 185], [3, 14, 190], [4, 13, 195], [5, 12, 200], [6, 11, 205], [7, 10, 210], [8, 9, 215], [0, 15, 220], [1, 14, 225], [2, 13, 230], [3, 12, 235], [4, 11, 240], [5, 10, 245], [6, 9, 250], [7, 8, 255], [0, 14, 260], [1, 13, 265], [2, 12, 270], [3, 11, 275], [4, 10, 280], [5, 9, 285], [6, 8, 290], [0, 13, 295], [1, 12, 300], [2, 11, 305], [3, 10, 310], [4, 9, 315], [5, 8, 320], [0, 12, 325], [1, 11, 330], [2, 10, 335], [3, 9, 340], [4, 8, 345], [0, 11, 350], [1, 10, 355], [2, 9, 360], [3, 8, 365], [0, 10, 370], [1, 9, 375], [2, 8, 380], [0, 9, 385], [1, 8, 390], [0, 8, 395]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 4, 40], [3, 5, 50], [4, 6, 60], [5, 7, 70], [6, 8, 80], [7, 9, 90], [8, 10, 100], [9, 11, 110], [10, 12, 120], [11, 13, 130], [12, 14, 140]],queries = [[0, 14, 150], [0, 14, 75], [0, 7, 85], [7, 14, 110]]) == [True, False, True, False]\n assert candidate(n = 6,edgeList = [[0, 1, 20], [1, 2, 30], [2, 3, 40], [3, 4, 50], [4, 5, 60], [5, 0, 70], [0, 2, 15], [2, 4, 25], [4, 1, 35], [1, 3, 45], [3, 5, 55], [5, 2, 65]],queries = [[0, 5, 50], [1, 4, 40], [2, 3, 30]]) == [False, True, False]\n", "comparison": "exact"}, "public_tests": ["3\n[[0,1,2],[1,2,4],[2,0,8],[1,0,16]]\n[[0,1,2],[0,2,5]]", "5\n[[0,1,10],[1,2,5],[2,3,9],[3,4,13]]\n[[0,4,14],[1,4,13]]"], "hints": ["All the queries are given in advance. Is there a way you can reorder the queries to avoid repeated computations?"], "metadata": {"canonical_parameter_names": ["n", "edgeList", "queries"], "leetcode_dataset_entry_point": "Solution().distanceLimitedPathsExist", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:50+00:00", "tests_total": 62, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "two-pointers", "union-find", "graph", "sorting"]}, "language": "python", "interface": {"raw_signature": "def distanceLimitedPathsExist(self, n: int, edgeList: list[list[int]], queries: list[list[int]]) -> list[bool]:", "container": "Solution", "callable": "distanceLimitedPathsExist", "parameters": [{"name": "n", "type": "int"}, {"name": "edgeList", "type": "list[list[int]]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1700, "task_id": "number-of-students-unable-to-eat-lunch", "difficulty": "Easy", "problem_description": "The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers square or circular sandwiches.\n\nThe number of sandwiches in the cafeteria is equal to the number of students. The sandwiches are placed in a stack. At each step:\n\n- If the student at the front of the queue prefers the sandwich on the top of the stack, they will take it and leave the queue.\n- Otherwise, they will leave it and go to the queue's end.\n\nThis continues until none of the queue students want to take the top sandwich and are thus unable to eat.\n\nYou are given two integer arrays students and sandwiches where sandwiches[i] is the type of the i^th sandwich in the stack (i = 0 is the top of the stack) and students[j] is the preference of the j^th student in the initial queue (j = 0 is the front of the queue). Return the number of students that are unable to eat.\n\nExample 1:\n\nInput: students = [1,1,0,0], sandwiches = [0,1,0,1]\nOutput: 0\nExplanation:\n- Front student leaves the top sandwich and returns to the end of the line making students = [1,0,0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [0,0,1,1].\n- Front student takes the top sandwich and leaves the line making students = [0,1,1] and sandwiches = [1,0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [1,1,0].\n- Front student takes the top sandwich and leaves the line making students = [1,0] and sandwiches = [0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [0,1].\n- Front student takes the top sandwich and leaves the line making students = [1] and sandwiches = [1].\n- Front student takes the top sandwich and leaves the line making students = [] and sandwiches = [].\nHence all students are able to eat.\n\nExample 2:\n\nInput: students = [1,1,1,0,0,1], sandwiches = [1,0,0,0,1,1]\nOutput: 3\n\nConstraints:\n\n- 1 <= students.length, sandwiches.length <= 100\n- students.length == sandwiches.length\n- sandwiches[i] is 0 or 1.\n- students[i] is 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(students = [0, 1, 0, 1],sandwiches = [1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 0, 0, 1],sandwiches = [1, 0, 0, 0, 1, 1]) == 3\n assert candidate(students = [0, 0, 1, 1],sandwiches = [1, 1, 0, 0]) == 0\n assert candidate(students = [1, 0, 1, 0],sandwiches = [0, 1, 0, 1]) == 0\n assert candidate(students = [0, 0, 0, 0],sandwiches = [0, 0, 0, 0]) == 0\n assert candidate(students = [0, 1, 0, 1],sandwiches = [0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 0, 0],sandwiches = [0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 1, 1],sandwiches = [1, 1, 1, 1]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 0, 0, 0, 0, 1, 1],sandwiches = [0, 0, 0, 1, 1, 1, 0, 1, 1]) == 0\n assert candidate(students = [1, 0, 0, 1, 1, 0, 0, 1],sandwiches = [1, 1, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 0, 0, 1, 0, 1, 1, 0],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0],sandwiches = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(students = [0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 1, 0, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 1, 0],sandwiches = [0, 0, 1, 0, 1, 1, 0, 1]) == 0\n assert candidate(students = [0, 1, 1, 1, 0, 1, 0, 0, 1, 0],sandwiches = [0, 1, 0, 1, 1, 1, 1, 0, 0, 0]) == 0\n assert candidate(students = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],sandwiches = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 2\n assert candidate(students = [1, 0, 0, 1, 1, 0, 1, 0, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0],sandwiches = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1]) == 0\n assert candidate(students = [1, 1, 1, 0, 0, 0, 0, 1, 1],sandwiches = [1, 0, 0, 0, 1, 0, 0, 1, 0]) == 3\n assert candidate(students = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1],sandwiches = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 2\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0],sandwiches = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 1, 0, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],sandwiches = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(students = [1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1],sandwiches = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 0, 0, 1, 1, 1, 1, 0, 0, 0],sandwiches = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0]) == 3\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],sandwiches = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sandwiches = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(students = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 2\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0],sandwiches = [0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 0, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 0]) == 0\n assert candidate(students = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1],sandwiches = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0],sandwiches = [1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 0, 1, 0, 0, 1, 1, 0, 1],sandwiches = [0, 1, 1, 0, 1, 1, 0, 1, 0, 0]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 0, 1, 1, 0, 0, 1, 1],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 0, 1, 1, 0],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 1\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],sandwiches = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == 4\n assert candidate(students = [1, 1, 0, 0, 0, 0, 1, 1],sandwiches = [1, 1, 0, 0, 0, 0, 1, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1],sandwiches = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],sandwiches = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 1, 1, 0, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 0, 0, 1, 1, 0, 0, 1],sandwiches = [1, 0, 1, 0, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1],sandwiches = [1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0]) == 1\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(students = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],sandwiches = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(students = [1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1],sandwiches = [1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0]) == 1\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 1]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 1, 0, 0, 1],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 0, 1, 1, 0, 0, 0, 1],sandwiches = [0, 1, 1, 0, 0, 0, 1, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],sandwiches = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1],sandwiches = [1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 1, 0, 0],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],sandwiches = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0],sandwiches = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0],sandwiches = [1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sandwiches = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 69\n assert candidate(students = [1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0],sandwiches = [0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1]) == 0\n assert candidate(students = [0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0]) == 1\n", "comparison": "exact"}, "public_tests": ["[1,1,0,0]\n[0,1,0,1]", "[1,1,1,0,0,1]\n[1,0,0,0,1,1]"], "hints": ["Simulate the given in the statement", "Calculate those who will eat instead of those who will not."], "metadata": {"canonical_parameter_names": ["students", "sandwiches"], "leetcode_dataset_entry_point": "Solution().countStudents", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:55+00:00", "tests_total": 88, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "stack", "queue", "simulation"]}, "language": "python", "interface": {"raw_signature": "def countStudents(self, students: list[int], sandwiches: list[int]) -> int:", "container": "Solution", "callable": "countStudents", "parameters": [{"name": "students", "type": "list[int]"}, {"name": "sandwiches", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1701, "task_id": "average-waiting-time", "difficulty": "Medium", "problem_description": "There is a restaurant with a single chef. You are given an array customers, where customers[i] = [arrival_i, time_i]:\n\n- arrival_i is the arrival time of the i^th customer. The arrival times are sorted in non-decreasing order.\n- time_i is the time needed to prepare the order of the i^th customer.\n\nWhen a customer arrives, he gives the chef his order, and the chef starts preparing it once he is idle. The customer waits till the chef finishes preparing his order. The chef does not prepare food for more than one customer at a time. The chef prepares food for customers in the order they were given in the input.\n\nReturn the average waiting time of all customers. Solutions within 10^-5 from the actual answer are considered accepted.\n\nExample 1:\n\nInput: customers = [[1,2],[2,5],[4,3]]\nOutput: 5.00000\nExplanation:\n1) The first customer arrives at time 1, the chef takes his order and starts preparing it immediately at time 1, and finishes at time 3, so the waiting time of the first customer is 3 - 1 = 2.\n2) The second customer arrives at time 2, the chef takes his order and starts preparing it at time 3, and finishes at time 8, so the waiting time of the second customer is 8 - 2 = 6.\n3) The third customer arrives at time 4, the chef takes his order and starts preparing it at time 8, and finishes at time 11, so the waiting time of the third customer is 11 - 4 = 7.\nSo the average waiting time = (2 + 6 + 7) / 3 = 5.\n\nExample 2:\n\nInput: customers = [[5,2],[5,4],[10,3],[20,1]]\nOutput: 3.25000\nExplanation:\n1) The first customer arrives at time 5, the chef takes his order and starts preparing it immediately at time 5, and finishes at time 7, so the waiting time of the first customer is 7 - 5 = 2.\n2) The second customer arrives at time 5, the chef takes his order and starts preparing it at time 7, and finishes at time 11, so the waiting time of the second customer is 11 - 5 = 6.\n3) The third customer arrives at time 10, the chef takes his order and starts preparing it at time 11, and finishes at time 14, so the waiting time of the third customer is 14 - 10 = 4.\n4) The fourth customer arrives at time 20, the chef takes his order and starts preparing it immediately at time 20, and finishes at time 21, so the waiting time of the fourth customer is 21 - 20 = 1.\nSo the average waiting time = (2 + 6 + 4 + 1) / 4 = 3.25.\n\nConstraints:\n\n- 1 <= customers.length <= 10^5\n- 1 <= arrival_i, time_i <= 10^4\n- arrival_i<= arrival_{i+1}\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(customers=[[5, 2], [5, 4], [10, 3], [20, 1]]), 3.25)\n assert answers_match(candidate(customers=[[1, 1], [1, 1], [1, 1], [1, 1]]), 2.5)\n assert answers_match(candidate(customers=[[1, 1], [1, 1], [1, 1]]), 2.0)\n assert answers_match(candidate(customers=[[1, 3], [2, 3], [6, 3], [10, 3]]), 3.75)\n assert answers_match(candidate(customers=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]), 5.0)\n assert answers_match(candidate(customers=[[1, 3], [2, 3], [6, 3]]), 4.0)\n assert answers_match(candidate(customers=[[1, 2], [2, 5], [4, 3]]), 5.0)\n assert answers_match(candidate(customers=[[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]), 28.0)\n assert answers_match(candidate(customers=[[2, 3], [6, 3], [10, 3], [15, 3]]), 3.0)\n assert answers_match(candidate(customers=[[1, 5], [2, 2], [3, 3], [4, 4], [5, 5]]), 9.0)\n assert answers_match(candidate(customers=[[1, 10], [10, 10], [20, 10], [30, 10], [40, 10]]), 10.8)\n assert answers_match(candidate(customers=[[1, 3], [2, 2], [3, 1]]), 3.6666666666666665)\n assert answers_match(candidate(customers=[[10, 5], [15, 2], [20, 3], [30, 1]]), 2.75)\n assert answers_match(candidate(customers=[[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]), 5.5)\n assert answers_match(candidate(customers=[[1, 1000], [1010, 500], [1510, 250], [1760, 125], [1885, 62], [1947, 31], [1978, 15], [1993, 7], [1999, 3], [2001, 1]]), 199.7)\n assert answers_match(candidate(customers=[[1, 1], [3, 1], [5, 1], [7, 1], [9, 1], [11, 1], [13, 1], [15, 1], [17, 1], [19, 1], [21, 1], [23, 1], [25, 1], [27, 1], [29, 1]]), 1.0)\n assert answers_match(candidate(customers=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]), 35.0)\n assert answers_match(candidate(customers=[[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]]), 1.0)\n assert answers_match(candidate(customers=[[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11], [120, 12], [130, 13], [140, 14], [150, 15]]), 9.333333333333334)\n assert answers_match(candidate(customers=[[1, 100], [101, 50], [151, 200], [251, 100], [351, 300], [451, 150], [601, 50], [651, 100], [751, 250], [851, 50]]), 320.0)\n assert answers_match(candidate(customers=[[1, 5], [2, 3], [3, 4], [10, 2], [15, 5], [20, 1], [25, 3], [30, 4], [35, 2], [40, 5]]), 4.7)\n assert answers_match(candidate(customers=[[1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 2], [4, 3], [4, 4], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]), 13.692307692307692)\n assert answers_match(candidate(customers=[[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]), 14.0)\n assert answers_match(candidate(customers=[[1, 5], [2, 3], [3, 4], [4, 2], [5, 6], [6, 1]]), 10.833333333333334)\n assert answers_match(candidate(customers=[[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 2], [12, 2], [13, 2], [14, 2], [15, 2], [16, 2], [17, 2], [18, 2], [19, 2], [20, 2]]), 11.5)\n assert answers_match(candidate(customers=[[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 10], [12, 10], [13, 10], [14, 10], [15, 10], [16, 10], [17, 10], [18, 10], [19, 10], [20, 10], [21, 10], [22, 10], [23, 10], [24, 10], [25, 10], [26, 10], [27, 10], [28, 10], [29, 10], [30, 10]]), 140.5)\n assert answers_match(candidate(customers=[[1, 1000], [2000, 1000], [3000, 1000], [4000, 1000], [5000, 1000], [6000, 1000]]), 1000.0)\n assert answers_match(candidate(customers=[[1, 2], [2, 3], [3, 2], [4, 3], [5, 2], [6, 3], [7, 2], [8, 3], [9, 2], [10, 3], [11, 2], [12, 3], [13, 2], [14, 3], [15, 2], [16, 3], [17, 2], [18, 3], [19, 2], [20, 3]]), 16.5)\n assert answers_match(candidate(customers=[[1, 3], [2, 4], [5, 2], [6, 1], [8, 6], [10, 3], [11, 2]]), 7.0)\n assert answers_match(candidate(customers=[[1, 3], [2, 2], [4, 3], [5, 4], [6, 2], [8, 1], [10, 5]]), 6.857142857142857)\n assert answers_match(candidate(customers=[[10, 30], [20, 20], [30, 10], [40, 5], [50, 2], [60, 1], [70, 3], [80, 4], [90, 2], [100, 5], [110, 1], [120, 3], [130, 4], [140, 2], [150, 5]]), 15.2)\n assert answers_match(candidate(customers=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25], [26, 26], [27, 27], [28, 28], [29, 29], [30, 30]]), 150.83333333333334)\n assert answers_match(candidate(customers=[[100, 50], [150, 20], [200, 30], [250, 10], [300, 40], [350, 5], [400, 15]]), 24.285714285714285)\n assert answers_match(candidate(customers=[[1, 1], [3, 3], [3, 3], [3, 3], [5, 5], [5, 5], [7, 7], [7, 7], [9, 9], [9, 9]]), 18.0)\n assert answers_match(candidate(customers=[[5, 3], [6, 4], [8, 2], [9, 5], [12, 3], [15, 1], [18, 2], [20, 4], [25, 3], [30, 1]]), 6.9)\n assert answers_match(candidate(customers=[[100, 100], [200, 50], [300, 25], [400, 12], [500, 6]]), 38.6)\n assert answers_match(candidate(customers=[[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70], [10, 80], [10, 90], [10, 100]]), 220.0)\n assert answers_match(candidate(customers=[[1, 100], [101, 50], [151, 25], [201, 10], [251, 5], [301, 1]]), 31.833333333333332)\n assert answers_match(candidate(customers=[[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]), 8.0)\n assert answers_match(candidate(customers=[[5, 10], [10, 10], [15, 10], [20, 10], [25, 10], [30, 10], [35, 10], [40, 10], [45, 10], [50, 10]]), 32.5)\n assert answers_match(candidate(customers=[[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20]]), 77.0)\n assert answers_match(candidate(customers=[[1, 1], [2, 1], [2, 1], [3, 1], [3, 1], [4, 1], [4, 1], [5, 1], [5, 1]]), 2.7777777777777777)\n assert answers_match(candidate(customers=[[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]]), 34.0)\n assert answers_match(candidate(customers=[[1, 20], [1, 15], [2, 10], [2, 5], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]), 45.0)\n assert answers_match(candidate(customers=[[1, 1], [100, 100], [200, 100], [300, 100], [400, 100], [500, 100], [600, 100], [700, 100], [800, 100], [900, 100]]), 90.1)\n assert answers_match(candidate(customers=[[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]), 6.5)\n assert answers_match(candidate(customers=[[1, 1000], [2, 1000], [3, 1000], [4, 1000], [5, 1000], [6, 1000], [7, 1000], [8, 1000], [9, 1000], [10, 1000]]), 5495.5)\n assert answers_match(candidate(customers=[[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]), 529.0)\n assert answers_match(candidate(customers=[[1, 5], [3, 7], [5, 2], [10, 1], [12, 3], [15, 2], [18, 5]]), 7.428571428571429)\n assert answers_match(candidate(customers=[[5, 10], [15, 15], [25, 20], [35, 25], [45, 30], [55, 35], [65, 40], [75, 45], [85, 50]]), 76.66666666666667)\n assert answers_match(candidate(customers=[[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1]]), 1.0)\n assert answers_match(candidate(customers=[[1, 100], [1, 90], [1, 80], [1, 70], [1, 60], [1, 50], [1, 40], [1, 30], [1, 20], [1, 10]]), 385.0)\n assert answers_match(candidate(customers=[[5, 3], [5, 2], [5, 4], [5, 1], [5, 5]]), 8.4)\n assert answers_match(candidate(customers=[[2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5]]), 27.5)\n assert answers_match(candidate(customers=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 17.5)\n assert answers_match(candidate(customers=[[1, 100], [20, 50], [40, 30], [60, 20], [80, 10], [100, 5], [120, 3], [140, 2], [160, 1]]), 111.33333333333333)\n assert answers_match(candidate(customers=[[1, 10], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10], [30, 10], [35, 10], [40, 10], [45, 10], [50, 10], [55, 10], [60, 10], [65, 10], [70, 10], [75, 10], [80, 10], [85, 10], [90, 10], [95, 10]]), 58.45)\n assert answers_match(candidate(customers=[[1, 5], [6, 10], [12, 15], [18, 20], [24, 25], [30, 30], [36, 35], [42, 40], [48, 45], [54, 50]]), 83.9)\n assert answers_match(candidate(customers=[[1, 1], [2, 2], [3, 2], [4, 1], [5, 2], [6, 3], [7, 1], [8, 2], [9, 3], [10, 1], [11, 2], [12, 3], [13, 1], [14, 2], [15, 3]]), 7.466666666666667)\n assert answers_match(candidate(customers=[[1, 100], [101, 100], [201, 100], [301, 100], [401, 100], [501, 100], [601, 100], [701, 100], [801, 100], [901, 100]]), 100.0)\n assert answers_match(candidate(customers=[[100, 50], [200, 25], [300, 12], [400, 6], [500, 3], [600, 1], [700, 2], [800, 4], [900, 1]]), 11.555555555555555)\n assert answers_match(candidate(customers=[[1, 1000], [1001, 1000], [2001, 1000], [3001, 1000], [4001, 1000], [5001, 1000]]), 1000.0)\n assert answers_match(candidate(customers=[[1, 1], [3, 2], [6, 3], [10, 4], [15, 5], [21, 6], [28, 7], [36, 8], [45, 9], [55, 10]]), 5.5)\n assert answers_match(candidate(customers=[[1, 10], [10, 10], [20, 10], [30, 10], [40, 10], [50, 10]]), 10.833333333333334)\n assert answers_match(candidate(customers=[[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), 21.0)\n assert answers_match(candidate(customers=[[1, 5], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5]]), 8.333333333333334)\n assert answers_match(candidate(customers=[[1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000]]), 55000.0)\n assert answers_match(candidate(customers=[[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512]]), 102.3)\n assert answers_match(candidate(customers=[[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]), 22.0)\n assert answers_match(candidate(customers=[[100, 200], [200, 300], [300, 400], [400, 500], [500, 600]]), 800.0)\n assert answers_match(candidate(customers=[[1, 100], [101, 50], [151, 20], [201, 10], [251, 5], [301, 1], [351, 2], [401, 3], [451, 4]]), 21.666666666666668)\n assert answers_match(candidate(customers=[[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]), 215.5)\n assert answers_match(candidate(customers=[[1, 1000], [1001, 1000], [2001, 1000], [3001, 1000], [4001, 1000]]), 1000.0)\n assert answers_match(candidate(customers=[[1, 5000], [100, 2000], [2000, 3000], [3000, 1000], [4000, 4000], [5000, 5000], [6000, 6000], [7000, 7000], [8000, 8000], [9000, 9000], [10000, 10000]]), 20355.454545454544)\n assert answers_match(candidate(customers=[[1, 2], [3, 3], [6, 2], [8, 1], [10, 3], [15, 4]]), 2.5)\n assert answers_match(candidate(customers=[[1, 1], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 2], [12, 2], [13, 2], [14, 2], [15, 2], [16, 2], [17, 2], [18, 2], [19, 2], [20, 2]]), 10.5)\n assert answers_match(candidate(customers=[[1, 1000], [1001, 500], [1501, 250], [2001, 125], [2501, 62], [3001, 31], [3501, 15], [4001, 7], [4501, 3], [5001, 1]]), 199.4)\n assert answers_match(candidate(customers=[[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]]), 50.0)\n assert answers_match(candidate(customers=[[1000, 1], [2000, 1], [3000, 1], [4000, 1], [5000, 1], [6000, 1], [7000, 1], [8000, 1], [9000, 1], [10000, 1]]), 1.0)\n assert answers_match(candidate(customers=[[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), 31.0)\n assert answers_match(candidate(customers=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22]]), 42.0)\n assert answers_match(candidate(customers=[[1, 10], [11, 10], [21, 10], [31, 10], [41, 10], [51, 10], [61, 10], [71, 10], [81, 10], [91, 10]]), 10.0)\n assert answers_match(candidate(customers=[[1000, 100], [2000, 200], [3000, 300], [4000, 400], [5000, 500], [6000, 600], [7000, 700], [8000, 800], [9000, 900], [10000, 1000]]), 550.0)\n assert answers_match(candidate(customers=[[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21]]), 40.5)\n assert answers_match(candidate(customers=[[1, 1], [2, 100], [3, 200], [4, 300], [5, 400], [6, 500], [7, 600], [8, 700], [9, 800], [10, 900]]), 1646.5)\n assert answers_match(candidate(customers=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30]]), 76.66666666666667)\n assert answers_match(candidate(customers=[[100, 100], [200, 100], [300, 100], [400, 100], [500, 100], [600, 100], [700, 100], [800, 100], [900, 100], [1000, 100]]), 100.0)\n assert answers_match(candidate(customers=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]), 38.333333333333336)\n assert answers_match(candidate(customers=[[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]]), 27.5)\n", "comparison": "float"}, "public_tests": ["[[1,2],[2,5],[4,3]]", "[[5,2],[5,4],[10,3],[20,1]]"], "hints": ["Iterate on the customers, maintaining the time the chef will finish the previous orders.", "If that time is before the current arrival time, the chef starts immediately. Else, the current customer waits till the chef finishes, and then the chef starts.", "Update the running time by the time when the chef starts preparing + preparation time."], "metadata": {"canonical_parameter_names": ["customers"], "leetcode_dataset_entry_point": "Solution().averageWaitingTime", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:57+00:00", "tests_total": 92, "tests_dropped": 3, "flags": ["decimal_answer"], "topic_tags": ["array", "simulation"]}, "language": "python", "interface": {"raw_signature": "def averageWaitingTime(self, customers: list[list[int]]) -> float:", "container": "Solution", "callable": "averageWaitingTime", "parameters": [{"name": "customers", "type": "list[list[int]]"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1702, "task_id": "maximum-binary-string-after-change", "difficulty": "Medium", "problem_description": "You are given a binary string binary consisting of only 0's or 1's. You can apply each of the following operations any number of times:\n\n- Operation 1: If the number contains the substring \"00\", you can replace it with \"10\".\n - For example, \"00010\" -> \"10010\"\n- Operation 2: If the number contains the substring \"10\", you can replace it with \"01\".\n - For example, \"00010\" -> \"00001\"\n\nReturn the maximum binary string you can obtain after any number of operations. Binary string x is greater than binary string y if x's decimal representation is greater than y's decimal representation.\n\nExample 1:\n\nInput: binary = \"000110\"\nOutput: \"111011\"\nExplanation: A valid transformation sequence can be:\n\"000110\" -> \"000101\"\n\"000101\" -> \"100101\"\n\"100101\" -> \"110101\"\n\"110101\" -> \"110011\"\n\"110011\" -> \"111011\"\n\nExample 2:\n\nInput: binary = \"01\"\nOutput: \"01\"\nExplanation: \"01\" cannot be transformed any further.\n\nConstraints:\n\n- 1 <= binary.length <= 10^5\n- binary consist of '0' and '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(binary = \"01010101010\") == \"11111011111\"\n assert candidate(binary = \"01\") == \"01\"\n assert candidate(binary = \"000001\") == \"111101\"\n assert candidate(binary = \"1111\") == \"1111\"\n assert candidate(binary = \"10101010101010101010\") == \"11111111110111111111\"\n assert candidate(binary = \"000000000\") == \"111111110\"\n assert candidate(binary = \"010101\") == \"110111\"\n assert candidate(binary = \"111000011\") == \"111111011\"\n assert candidate(binary = \"00110011\") == \"11101111\"\n assert candidate(binary = \"00000\") == \"11110\"\n assert candidate(binary = \"000000\") == \"111110\"\n assert candidate(binary = \"1100101\") == \"1111011\"\n assert candidate(binary = \"001001\") == \"111011\"\n assert candidate(binary = \"101010\") == \"111011\"\n assert candidate(binary = \"0000\") == \"1110\"\n assert candidate(binary = \"0101010101\") == \"1111011111\"\n assert candidate(binary = \"000111000\") == \"111110111\"\n assert candidate(binary = \"10101010\") == \"11110111\"\n assert candidate(binary = \"1100110011\") == \"1111101111\"\n assert candidate(binary = \"0101010\") == \"1110111\"\n assert candidate(binary = \"111000\") == \"111110\"\n assert candidate(binary = \"0001010101\") == \"1111101111\"\n assert candidate(binary = \"000001111\") == \"111101111\"\n assert candidate(binary = \"111111\") == \"111111\"\n assert candidate(binary = \"00001111\") == \"11101111\"\n assert candidate(binary = \"11001000101\") == \"11111110111\"\n assert candidate(binary = \"0010101\") == \"1110111\"\n assert candidate(binary = \"11001100\") == \"11111011\"\n assert candidate(binary = \"11110000\") == \"11111110\"\n assert candidate(binary = \"011110\") == \"101111\"\n assert candidate(binary = \"110010\") == \"111101\"\n assert candidate(binary = \"000110\") == \"111011\"\n assert candidate(binary = \"100100100\") == \"111111011\"\n assert candidate(binary = \"1000000\") == \"1111110\"\n assert candidate(binary = \"11111\") == \"11111\"\n assert candidate(binary = \"100000000001\") == \"111111111101\"\n assert candidate(binary = \"10101001010100101\") == \"11111111101111111\"\n assert candidate(binary = \"00000000000000000000111111111111\") == \"11111111111111111110111111111111\"\n assert candidate(binary = \"01111111111111111111111111111111\") == \"01111111111111111111111111111111\"\n assert candidate(binary = \"00000000000000000\") == \"11111111111111110\"\n assert candidate(binary = \"01001001001001001\") == \"11111111110111111\"\n assert candidate(binary = \"0000000000\") == \"1111111110\"\n assert candidate(binary = \"0000111100001111\") == \"1111111011111111\"\n assert candidate(binary = \"000001111000001111000001111000001111000001111\") == \"111111111111111111111111011111111111111111111\"\n assert candidate(binary = \"001001001001001001001001001001001001001001001001001001\") == \"111111111111111111111111111111111110111111111111111111\"\n assert candidate(binary = \"000000000000\") == \"111111111110\"\n assert candidate(binary = \"11111011111011111011111011111011111011111011111\") == \"11111111111011111111111111111111111111111111111\"\n assert candidate(binary = \"10010010010010010\") == \"11111111111011111\"\n assert candidate(binary = \"111001001001001000\") == \"111111111111101111\"\n assert candidate(binary = \"00000011100000\") == \"11111111110111\"\n assert candidate(binary = \"111111111111111111111111111111111111111111111111111111111111111111111111\") == \"111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(binary = \"00011001100110011\") == \"11111111011111111\"\n assert candidate(binary = \"010101010101010101010\") == \"111111111101111111111\"\n assert candidate(binary = \"00010101010100\") == \"11111111011111\"\n assert candidate(binary = \"000000000000000000000000000000000000000000000000000000000000000000000000\") == \"111111111111111111111111111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111\") == \"111111111111111111111111111111111111111111111111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(binary = \"1010101010101010101010101010101010101010101010101010101010101010\") == \"1111111111111111111111111111111101111111111111111111111111111111\"\n assert candidate(binary = \"11111100000000111\") == \"11111111111110111\"\n assert candidate(binary = \"01010101010101010101\") == \"11111111101111111111\"\n assert candidate(binary = \"10101010101010101010101010101010\") == \"11111111111111110111111111111111\"\n assert candidate(binary = \"0000111111110000\") == \"1111111011111111\"\n assert candidate(binary = \"00000000000011111111111111111111\") == \"11111111111011111111111111111111\"\n assert candidate(binary = \"001010101010\") == \"111111011111\"\n assert candidate(binary = \"1111111111111111\") == \"1111111111111111\"\n assert candidate(binary = \"1010101010\") == \"1111101111\"\n assert candidate(binary = \"0101010101010101\") == \"1111111011111111\"\n assert candidate(binary = \"00001111000011110000111100001111\") == \"11111111111111101111111111111111\"\n assert candidate(binary = \"0000000000000000000000000001\") == \"1111111111111111111111111101\"\n assert candidate(binary = \"11111111111111111111\") == \"11111111111111111111\"\n assert candidate(binary = \"000011110000\") == \"111111101111\"\n assert candidate(binary = \"000010101010101010101010101010101010101010101010\") == \"111111111111111111111111101111111111111111111111\"\n assert candidate(binary = \"11011011011011011\") == \"11111101111111111\"\n assert candidate(binary = \"00000010000000100000001000000010000000100000001\") == \"11111111111111111111111111111111111111110111111\"\n assert candidate(binary = \"11111100000000000000000000000000\") == \"11111111111111111111111111111110\"\n assert candidate(binary = \"11000000000000000000\") == \"11111111111111111110\"\n assert candidate(binary = \"1010101010101010\") == \"1111111101111111\"\n assert candidate(binary = \"110011001100\") == \"111111101111\"\n assert candidate(binary = \"00001111000011110000\") == \"11111111111011111111\"\n assert candidate(binary = \"00011110101010101010101010101010101010101010101\") == \"11111111111111111111110111111111111111111111111\"\n assert candidate(binary = \"11100001010101010100001111100001111000011110000\") == \"11111111111111111111111111101111111111111111111\"\n assert candidate(binary = \"001100110011\") == \"111110111111\"\n assert candidate(binary = \"01001001001001001001\") == \"11111111111101111111\"\n assert candidate(binary = \"0000001111110000001111\") == \"1111111111101111111111\"\n assert candidate(binary = \"111111111110\") == \"111111111110\"\n assert candidate(binary = \"00000000000001111\") == \"11111111111101111\"\n assert candidate(binary = \"101010100000\") == \"111111110111\"\n assert candidate(binary = \"11111111111111111\") == \"11111111111111111\"\n assert candidate(binary = \"00000000000000000000000000000000000000000000\") == \"11111111111111111111111111111111111111111110\"\n assert candidate(binary = \"00001010101010100\") == \"11111111110111111\"\n assert candidate(binary = \"01010101010101010\") == \"11111111011111111\"\n assert candidate(binary = \"10101010101010101\") == \"11111111011111111\"\n assert candidate(binary = \"0101010101010101010101010101010101010101010101010101\") == \"1111111111111111111111111011111111111111111111111111\"\n assert candidate(binary = \"00000000000000000000000000000001\") == \"11111111111111111111111111111101\"\n assert candidate(binary = \"010101010101010101010101010101010101010101010101\") == \"111111111111111111111110111111111111111111111111\"\n assert candidate(binary = \"1100000000000011\") == \"1111111111111011\"\n assert candidate(binary = \"11111111111111111111111111111111111111111111\") == \"11111111111111111111111111111111111111111111\"\n assert candidate(binary = \"00000000010000000000000000000000\") == \"11111111111111111111111111111101\"\n assert candidate(binary = \"11001100110011001\") == \"11111111101111111\"\n assert candidate(binary = \"101010101010101010101\") == \"111111111101111111111\"\n assert candidate(binary = \"111100001111\") == \"111111101111\"\n assert candidate(binary = \"00000000000000000000000000000000000000000000000000000000\") == \"11111111111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"1100110011001100\") == \"1111111110111111\"\n assert candidate(binary = \"111111111111\") == \"111111111111\"\n assert candidate(binary = \"0001100010001000\") == \"1111111111101111\"\n assert candidate(binary = \"0000000000000111111\") == \"1111111111110111111\"\n assert candidate(binary = \"1110000110001100\") == \"1111111111101111\"\n assert candidate(binary = \"111111111\") == \"111111111\"\n assert candidate(binary = \"0000000000000000000000000000000000000000000000000000000000000000000000000000\") == \"1111111111111111111111111111111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"11111111111111111111111111111111111111111111111111111111\") == \"11111111111111111111111111111111111111111111111111111111\"\n assert candidate(binary = \"1001001001001\") == \"1111111101111\"\n assert candidate(binary = \"000000000000000000000000000000000000000000000000\") == \"111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"010101010101\") == \"111110111111\"\n assert candidate(binary = \"00100100100100100100100100100100\") == \"11111111111111111111101111111111\"\n assert candidate(binary = \"11110000000000000\") == \"11111111111111110\"\n assert candidate(binary = \"11110000111100001111000011110000111100001111\") == \"11111111111111111111111011111111111111111111\"\n assert candidate(binary = \"0011001100110011\") == \"1111111011111111\"\n assert candidate(binary = \"11000000110000001100000011000000\") == \"11111111111111111111111110111111\"\n assert candidate(binary = \"01010101010101010101010101010101\") == \"11111111111111101111111111111111\"\n assert candidate(binary = \"111111111111111111111111111111111111111111111111\") == \"111111111111111111111111111111111111111111111111\"\n assert candidate(binary = \"00000000000000000000\") == \"11111111111111111110\"\n assert candidate(binary = \"110101010101\") == \"111111011111\"\n assert candidate(binary = \"01001010100101001\") == \"11111111101111111\"\n assert candidate(binary = \"1010101010101010101010101010101010101010101010101010\") == \"1111111111111111111111111101111111111111111111111111\"\n assert candidate(binary = \"0110110110110\") == \"1111011111111\"\n assert candidate(binary = \"00000000000000000000000000000000000000000000000000000000000000000000000\") == \"11111111111111111111111111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"11111111111111111111111111111110\") == \"11111111111111111111111111111110\"\n assert candidate(binary = \"0000000000000000\") == \"1111111111111110\"\n assert candidate(binary = \"1100101010100001\") == \"1111111111011111\"\n assert candidate(binary = \"01101101101101101\") == \"11111011111111111\"\n assert candidate(binary = \"11111111111111111111000000000000\") == \"11111111111111111111111111111110\"\n assert candidate(binary = \"11111111111111110\") == \"11111111111111110\"\n assert candidate(binary = \"000100010001\") == \"111111110111\"\n assert candidate(binary = \"1111111111\") == \"1111111111\"\n", "comparison": "exact"}, "public_tests": ["\"000110\"", "\"01\""], "hints": ["Note that with the operations, you can always make the string only contain at most 1 zero."], "metadata": {"canonical_parameter_names": ["binary"], "leetcode_dataset_entry_point": "Solution().maximumBinaryString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:27:59+00:00", "tests_total": 133, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maximumBinaryString(self, binary: str) -> str:", "container": "Solution", "callable": "maximumBinaryString", "parameters": [{"name": "binary", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1703, "task_id": "minimum-adjacent-swaps-for-k-consecutive-ones", "difficulty": "Hard", "problem_description": "You are given an integer array, nums, and an integer k. nums comprises of only 0's and 1's. In one move, you can choose two adjacent indices and swap their values.\n\nReturn the minimum number of moves required so that nums has k consecutive 1's.\n\nExample 1:\n\nInput: nums = [1,0,0,1,0,1], k = 2\nOutput: 1\nExplanation: In 1 move, nums could be [1,0,0,0,1,1] and have 2 consecutive 1's.\n\nExample 2:\n\nInput: nums = [1,0,0,0,0,0,1,1], k = 3\nOutput: 5\nExplanation: In 5 moves, the leftmost 1 can be shifted right until nums = [0,0,0,0,0,1,1,1].\n\nExample 3:\n\nInput: nums = [1,1,0,1], k = 2\nOutput: 0\nExplanation: nums already has 2 consecutive 1's.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- nums[i] is 0 or 1.\n- 1 <= k <= sum(nums)\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 1, 1, 1, 0, 0, 1, 1, 1],k = 4) == 2\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == 6\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 1],k = 3) == 5\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1],k = 4) == 4\n assert candidate(nums = [1, 1, 1, 1, 1],k = 3) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 6\n assert candidate(nums = [0, 0, 1, 0, 1, 0, 1, 0, 1],k = 3) == 2\n assert candidate(nums = [0, 0, 1, 0, 1, 1, 0, 0, 1],k = 3) == 1\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1],k = 5) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1],k = 3) == 2\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 3) == 2\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 4) == 4\n assert candidate(nums = [1, 1, 0, 1],k = 2) == 0\n assert candidate(nums = [0, 0, 1, 0, 1, 0, 1, 0, 1],k = 4) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1],k = 4) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0],k = 2) == 1\n assert candidate(nums = [1, 0, 0, 1, 0, 1],k = 2) == 1\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 6) == 18\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 7) == 33\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1],k = 4) == 6\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],k = 3) == 12\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],k = 9) == 54\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0],k = 7) == 16\n assert candidate(nums = [0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1],k = 4) == 6\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],k = 4) == 28\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 10) == 75\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],k = 3) == 0\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 3) == 10\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],k = 3) == 6\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 5) == 24\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1],k = 6) == 9\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0],k = 5) == 5\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1],k = 6) == 14\n assert candidate(nums = [1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1],k = 6) == 13\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1],k = 4) == 6\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 5) == 12\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 5) == 12\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1],k = 6) == 20\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 8) == 16\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0],k = 5) == 15\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 7) == 12\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 12) == 36\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 6\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 8) == 32\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 4) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 25\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 4) == 4\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1],k = 9) == 18\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == 20\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 5) == 24\n assert candidate(nums = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 5\n assert candidate(nums = [0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0],k = 5) == 12\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0],k = 4) == 5\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 9) == 20\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2) == 9\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == 20\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 4) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 5) == 12\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1],k = 6) == 15\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],k = 6) == 24\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 7) == 24\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 3) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 7) == 12\n assert candidate(nums = [1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 10) == 25\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 7) == 24\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 7) == 24\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],k = 5) == 36\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1],k = 4) == 3\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 3) == 51\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1],k = 9) == 40\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 5) == 12\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 6) == 27\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 7) == 36\n assert candidate(nums = [1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 8) == 46\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 15) == 56\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0],k = 5) == 15\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 5) == 27\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1],k = 5) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2) == 14\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 11) == 30\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 7) == 24\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],k = 6) == 26\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 8) == 16\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 9) == 20\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 25\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 10) == 50\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 4) == 8\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 5) == 15\n assert candidate(nums = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 8) == 15\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0],k = 3) == 10\n", "comparison": "exact"}, "public_tests": ["[1,0,0,1,0,1]\n2", "[1,0,0,0,0,0,1,1]\n3", "[1,1,0,1]\n2"], "hints": ["Choose k 1s and determine how many steps are required to move them into 1 group.", "Maintain a sliding window of k 1s, and maintain the steps required to group them.", "When you slide the window across, should you move the group to the right? Once you move the group to the right, it will never need to slide to the left again."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minMoves", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:02+00:00", "tests_total": 99, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "greedy", "sliding-window", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minMoves(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "minMoves", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1704, "task_id": "determine-if-string-halves-are-alike", "difficulty": "Easy", "problem_description": "You are given a string s of even length. Split this string into two halves of equal lengths, and let a be the first half and b be the second half.\n\nTwo strings are alike if they have the same number of vowels ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'). Notice that s contains uppercase and lowercase letters.\n\nReturn true if a and b are alike. Otherwise, return false.\n\nExample 1:\n\nInput: s = \"book\"\nOutput: true\nExplanation: a = \"bo\" and b = \"ok\". a has 1 vowel and b has 1 vowel. Therefore, they are alike.\n\nExample 2:\n\nInput: s = \"textbook\"\nOutput: false\nExplanation: a = \"text\" and b = \"book\". a has 1 vowel whereas b has 2. Therefore, they are not alike.\nNotice that the vowel o is counted twice.\n\nConstraints:\n\n- 2 <= s.length <= 1000\n- s.length is even.\n- s consists of uppercase and lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aAeEiIoOuU\") == True\n assert candidate(s = \"Leetcode\") == True\n assert candidate(s = \"AbCdEfGh\") == True\n assert candidate(s = \"textbook\") == False\n assert candidate(s = \"cOdInGQuEsTiOn\") == False\n assert candidate(s = \"AaEeIiOoUu\") == True\n assert candidate(s = \"leetcode\") == True\n assert candidate(s = \"abcdefgH\") == True\n assert candidate(s = \"Margelet\") == False\n assert candidate(s = \"book\") == True\n assert candidate(s = \"MerryChristmas\") == False\n assert candidate(s = \"ArtificialIntelligence\") == False\n assert candidate(s = \"aAbBcCdDeEfFgG\") == True\n assert candidate(s = \"Supercalifragilisticexpialidocious\") == False\n assert candidate(s = \"InDiCoRn\") == False\n assert candidate(s = \"vowelvowelvowelvowelvowelvowel\") == True\n assert candidate(s = \"VowelCOnsonAnt\") == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == True\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\") == False\n assert candidate(s = \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == True\n assert candidate(s = \"EqUiVaLeNt\") == False\n assert candidate(s = \"unevenNumberOfVowels\") == True\n assert candidate(s = \"QuantumComputing\") == True\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == False\n assert candidate(s = \"Internationalization\") == True\n assert candidate(s = \"AbcDeFgHiJkLmNoPqRsTuVwXyZ\") == False\n assert candidate(s = \"Electroencephalographies\") == True\n assert candidate(s = \"fAcEtImE\") == True\n assert candidate(s = \"AnALoGuIzAtIoN\") == True\n assert candidate(s = \"sImPlEVoWaElStRiNg\") == True\n assert candidate(s = \"VoWaElCoUnTiNg\") == True\n assert candidate(s = \"SiMpLy\") == False\n assert candidate(s = \"Electroencephalography\") == False\n assert candidate(s = \"abcdefghijABCDEFGHIJ\") == True\n assert candidate(s = \"METHINKSITISLIKEALITTLEIODEUCALYPTUS\") == False\n assert candidate(s = \"HumanComputerInteraction\") == True\n assert candidate(s = \"AmOrAnGe\") == True\n assert candidate(s = \"balancedString\") == False\n assert candidate(s = \"EuPoCrAtIc\") == False\n assert candidate(s = \"RoMaNiCa\") == True\n assert candidate(s = \"aAaAaAaAaAbBbBbBbB\") == False\n assert candidate(s = \"MaRiNo\") == False\n assert candidate(s = \"CloudComputing\") == False\n assert candidate(s = \"DataScienceAndML\") == False\n assert candidate(s = \"Hippopotomonstrosesquippedaliophobia\") == False\n assert candidate(s = \"Pseudopseudohypoparathyroidism\") == True\n assert candidate(s = \"DatabaseManagement\") == True\n assert candidate(s = \"ComplexExample\") == False\n assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\") == False\n assert candidate(s = \"AEIOUaeiouAEIOUaeiou\") == True\n assert candidate(s = \"SyMmEtrY\") == False\n assert candidate(s = \"PaLInDrOmE\") == True\n assert candidate(s = \"Floccinaucinihilipilifications\") == True\n assert candidate(s = \"AlphabetSymmetry\") == False\n assert candidate(s = \"VowelsInBoth\") == True\n assert candidate(s = \"FLUtTuAtIoNs\") == False\n assert candidate(s = \"MaLiNoUs\") == True\n assert candidate(s = \"InternetOfThings\") == False\n assert candidate(s = \"PeRuKkIa\") == True\n assert candidate(s = \"TrAnSaPoRt\") == False\n assert candidate(s = \"OddAndEven\") == True\n assert candidate(s = \"aEiOuUoIeA\") == True\n assert candidate(s = \"Alphabetical\") == False\n assert candidate(s = \"VowelsAEIOUaeiou\") == False\n assert candidate(s = \"aEiOuUeIoA\") == True\n assert candidate(s = \"SeNtEnCe\") == False\n assert candidate(s = \"RepetitionRepetition\") == True\n assert candidate(s = \"MississippiRiver\") == True\n assert candidate(s = \"vowelvowelvowelvowel\") == True\n assert candidate(s = \"MississippiRiverside\") == False\n assert candidate(s = \"aeiouAEIOUaeiouAEIOU\") == True\n assert candidate(s = \"PythonCoding\") == False\n assert candidate(s = \"aEiOuUaEiO\") == True\n assert candidate(s = \"ProgrammingIsFun\") == False\n assert candidate(s = \"aEiOuAeIoU\") == True\n assert candidate(s = \"Alphabetically\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == False\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(s = \"DataAnalysis\") == False\n assert candidate(s = \"VoCaBuLaRy\") == True\n assert candidate(s = \"AEIOUaeiou\") == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s = \"CaThODoRiC\") == True\n assert candidate(s = \"Antidisestablishmentarianism\") == False\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == False\n assert candidate(s = \"BaLaNcEd\") == False\n assert candidate(s = \"BlockchainTechnology\") == True\n assert candidate(s = \"SystemAnalysis\") == True\n assert candidate(s = \"hAlFVaLuEs\") == False\n assert candidate(s = \"AlphabetSoup\") == False\n assert candidate(s = \"Unbelievable\") == True\n assert candidate(s = \"SplittingStrings\") == False\n assert candidate(s = \"GrApHiTe\") == False\n assert candidate(s = \"evenNumberOfVowels\") == False\n assert candidate(s = \"RoTiCoRn\") == False\n assert candidate(s = \"bYtEcOdE\") == False\n assert candidate(s = \"BigDataAnalytics\") == False\n assert candidate(s = \"FLYINGDUCK\") == True\n assert candidate(s = \"ComplexityAnalysis\") == True\n assert candidate(s = \"equalvowelcounts\") == False\n assert candidate(s = \"EnvironmentalStudies\") == True\n assert candidate(s = \"xyzXYZxyzXYZ\") == True\n", "comparison": "exact"}, "public_tests": ["\"book\"", "\"textbook\""], "hints": ["Create a function that checks if a character is a vowel, either uppercase or lowercase."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().halvesAreAlike", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:04+00:00", "tests_total": 175, "tests_dropped": 73, "flags": [], "topic_tags": ["string", "counting"]}, "language": "python", "interface": {"raw_signature": "def halvesAreAlike(self, s: str) -> bool:", "container": "Solution", "callable": "halvesAreAlike", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1705, "task_id": "maximum-number-of-eaten-apples", "difficulty": "Medium", "problem_description": "There is a special kind of apple tree that grows apples every day for n days. On the i^th day, the tree grows apples[i] apples that will rot after days[i] days, that is on day i + days[i] the apples will be rotten and cannot be eaten. On some days, the apple tree does not grow any apples, which are denoted by apples[i] == 0 and days[i] == 0.\n\nYou decided to eat at most one apple a day (to keep the doctors away). Note that you can keep eating after the first n days.\n\nGiven two integer arrays days and apples of length n, return the maximum number of apples you can eat.\n\nExample 1:\n\nInput: apples = [1,2,3,5,2], days = [3,2,1,4,2]\nOutput: 7\nExplanation: You can eat 7 apples:\n- On the first day, you eat an apple that grew on the first day.\n- On the second day, you eat an apple that grew on the second day.\n- On the third day, you eat an apple that grew on the second day. After this day, the apples that grew on the third day rot.\n- On the fourth to the seventh days, you eat apples that grew on the fourth day.\n\nExample 2:\n\nInput: apples = [3,0,0,0,0,2], days = [3,0,0,0,0,2]\nOutput: 5\nExplanation: You can eat 5 apples:\n- On the first to the third day you eat apples that grew on the first day.\n- Do nothing on the fouth and fifth days.\n- On the sixth and seventh days you eat apples that grew on the sixth day.\n\nConstraints:\n\n- n == apples.length == days.length\n- 1 <= n <= 2 * 10^4\n- 0 <= apples[i], days[i] <= 2 * 10^4\n- days[i] = 0 if and only if apples[i] = 0.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(apples = [0, 0, 0, 0],days = [0, 0, 0, 0]) == 0\n assert candidate(apples = [1, 3, 2],days = [3, 5, 2]) == 6\n assert candidate(apples = [5, 5, 5, 5, 5],days = [1, 2, 3, 4, 5]) == 9\n assert candidate(apples = [5, 5, 5, 5, 5],days = [1, 1, 1, 1, 1]) == 5\n assert candidate(apples = [0, 0, 0, 5, 0, 6],days = [0, 0, 0, 5, 0, 4]) == 6\n assert candidate(apples = [5, 4, 3, 2, 1],days = [1, 2, 3, 4, 5]) == 8\n assert candidate(apples = [1, 2, 3, 5, 2],days = [3, 2, 1, 4, 2]) == 7\n assert candidate(apples = [3, 0, 0, 0, 0, 2],days = [3, 0, 0, 0, 0, 2]) == 5\n assert candidate(apples = [2, 1, 10],days = [2, 10, 1]) == 4\n assert candidate(apples = [4, 2, 2, 3, 1],days = [3, 2, 10, 1, 2]) == 7\n assert candidate(apples = [0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [20, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 10\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(apples = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0],days = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0]) == 10\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == 20\n assert candidate(apples = [3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0],days = [10, 9, 8, 0, 0, 0, 0, 0, 0, 0, 0]) == 6\n assert candidate(apples = [10, 20, 30, 40, 50],days = [1, 2, 3, 4, 5]) == 9\n assert candidate(apples = [3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0],days = [5, 4, 3, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5]) == 12\n assert candidate(apples = [10, 0, 20, 0, 30, 0, 40, 0, 50, 0],days = [5, 0, 4, 0, 3, 0, 2, 0, 1, 0]) == 9\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(apples = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],days = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0]) == 5\n assert candidate(apples = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],days = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0]) == 10\n assert candidate(apples = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],days = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 79\n assert candidate(apples = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(apples = [10, 20, 0, 0, 15, 10],days = [5, 5, 0, 0, 3, 3]) == 8\n assert candidate(apples = [3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1],days = [2, 0, 0, 5, 0, 0, 0, 0, 0, 0, 2, 2]) == 6\n assert candidate(apples = [0, 0, 10, 0, 0, 0, 0, 0, 10, 0],days = [0, 0, 1, 0, 0, 0, 0, 0, 2, 0]) == 3\n assert candidate(apples = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(apples = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(apples = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],days = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(apples = [1, 3, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 4\n assert candidate(apples = [5, 4, 3, 2, 1],days = [5, 4, 3, 2, 1]) == 5\n assert candidate(apples = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],days = [20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 2\n assert candidate(apples = [3, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7],days = [2, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6]) == 17\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 29\n assert candidate(apples = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],days = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(apples = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],days = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(apples = [10, 15, 0, 20, 25, 0, 0, 30],days = [3, 4, 0, 5, 6, 0, 0, 7]) == 14\n assert candidate(apples = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10],days = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10]) == 27\n assert candidate(apples = [10, 0, 10, 0, 10, 0, 10],days = [3, 0, 3, 0, 3, 0, 3]) == 9\n assert candidate(apples = [3, 2, 1, 0, 0, 4, 2, 1, 0, 1],days = [2, 2, 2, 0, 0, 3, 2, 2, 0, 1]) == 9\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(apples = [4, 0, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0],days = [5, 0, 4, 3, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0]) == 9\n assert candidate(apples = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0],days = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == 13\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 100, 100],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 15, 15]) == 17\n assert candidate(apples = [2, 4, 6, 8, 10],days = [1, 2, 3, 4, 5]) == 9\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(apples = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],days = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 13\n assert candidate(apples = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 5\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(apples = [10, 0, 5, 0, 0, 15],days = [10, 0, 4, 0, 0, 3]) == 10\n assert candidate(apples = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(apples = [5, 0, 0, 5, 0, 5, 0, 5, 0, 5],days = [1, 0, 0, 2, 0, 3, 0, 4, 0, 5]) == 12\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(apples = [2, 3, 1, 0, 0, 0, 0, 4, 5, 6, 0, 0, 0, 0, 7],days = [2, 2, 2, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 4]) == 13\n assert candidate(apples = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0],days = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 12\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [10, 20, 0, 0, 15, 10, 5],days = [5, 4, 0, 0, 6, 3, 2]) == 10\n assert candidate(apples = [10, 0, 20, 0, 30, 0, 40, 0, 50, 0, 60, 0, 70, 0, 80, 0, 90, 0, 100, 0],days = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == 23\n assert candidate(apples = [0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0]) == 7\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 32\n assert candidate(apples = [1, 2, 0, 4, 5, 0, 0, 6, 7, 0, 0, 8, 9],days = [3, 2, 0, 4, 5, 0, 0, 2, 3, 0, 0, 2, 3]) == 15\n assert candidate(apples = [100, 100, 100, 100, 100],days = [5, 5, 5, 5, 5]) == 9\n assert candidate(apples = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(apples = [2, 3, 1, 5, 4, 2, 3, 1, 1, 1, 1],days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 17\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n", "comparison": "exact"}, "public_tests": ["[1,2,3,5,2]\n[3,2,1,4,2]", "[3,0,0,0,0,2]\n[3,0,0,0,0,2]"], "hints": ["It's optimal to finish the apples that will rot first before those that will rot last", "You need a structure to keep the apples sorted by their finish time"], "metadata": {"canonical_parameter_names": ["apples", "days"], "leetcode_dataset_entry_point": "Solution().eatenApples", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:06+00:00", "tests_total": 72, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def eatenApples(self, apples: list[int], days: list[int]) -> int:", "container": "Solution", "callable": "eatenApples", "parameters": [{"name": "apples", "type": "list[int]"}, {"name": "days", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1706, "task_id": "where-will-the-ball-fall", "difficulty": "Medium", "problem_description": "You have a 2-D grid of size m x n representing a box, and you have n balls. The box is open on the top and bottom sides.\n\nEach cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left.\n\n- A board that redirects the ball to the right spans the top-left corner to the bottom-right corner and is represented in the grid as 1.\n- A board that redirects the ball to the left spans the top-right corner to the bottom-left corner and is represented in the grid as -1.\n\nWe drop one ball at the top of each column of the box. Each ball can get stuck in the box or fall out of the bottom. A ball gets stuck if it hits a \"V\" shaped pattern between two boards or if a board redirects the ball into either wall of the box.\n\nReturn an array answer of size n where answer[i] is the column that the ball falls out of at the bottom after dropping the ball from the i^th column at the top, or -1 if the ball gets stuck in the box.\n\nExample 1:\n\nInput: grid = [[1,1,1,-1,-1],[1,1,1,-1,-1],[-1,-1,-1,1,1],[1,1,1,1,-1],[-1,-1,-1,-1,-1]]\nOutput: [1,-1,-1,-1,-1]\nExplanation: This example is shown in the photo.\nBall b0 is dropped at column 0 and falls out of the box at column 1.\nBall b1 is dropped at column 1 and will get stuck in the box between column 2 and 3 and row 1.\nBall b2 is dropped at column 2 and will get stuck on the box between column 2 and 3 and row 0.\nBall b3 is dropped at column 3 and will get stuck on the box between column 2 and 3 and row 0.\nBall b4 is dropped at column 4 and will get stuck on the box between column 2 and 3 and row 1.\n\nExample 2:\n\nInput: grid = [[-1]]\nOutput: [-1]\nExplanation: The ball gets stuck against the left wall.\n\nExample 3:\n\nInput: grid = [[1,1,1,1,1,1],[-1,-1,-1,-1,-1,-1],[1,1,1,1,1,1],[-1,-1,-1,-1,-1,-1]]\nOutput: [0,1,2,3,4,-1]\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 100\n- grid[i][j] is 1 or -1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == [-1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]]) == [-1, -1, -1]\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [-1, -1, -1]]) == [1, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1], [1, 1, 1, -1, -1], [-1, -1, -1, 1, 1], [1, 1, 1, 1, -1], [-1, -1, -1, -1, -1]]) == [1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1], [1, 1, -1, 1, 1], [-1, 1, 1, -1, 1], [1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1]\n assert candidate(grid = [[-1]]) == [-1]\n assert candidate(grid = [[1, 1, -1, -1], [1, 1, -1, -1], [-1, -1, 1, 1], [-1, -1, 1, 1]]) == [-1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, -1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, 1, -1, -1, -1, -1], [1, 1, 1, 1, -1, 1, 1, 1, 1, 1], [1, -1, -1, 1, 1, -1, 1, -1, -1, 1]]) == [-1, 1, 4, -1, -1, -1, -1, 7, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, -1, -1], [-1, -1, -1, 1, 1, -1], [1, 1, -1, -1, 1, 1], [1, -1, 1, -1, -1, 1], [-1, 1, -1, 1, 1, -1]]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1]]) == [-1, -1, -1, 2, -1, -1, -1, 6, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, -1, 1, -1], [1, -1, 1, -1, 1, 1, 1], [-1, 1, 1, -1, 1, 1, -1], [1, -1, 1, 1, -1, 1, 1], [-1, 1, -1, -1, 1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, -1, 1, 1, 1, -1], [-1, -1, -1, 1, 1, 1, -1, -1, -1, 1], [1, 1, 1, -1, -1, -1, 1, 1, 1, -1], [-1, -1, -1, 1, 1, 1, -1, -1, -1, 1]]) == [0, 1, -1, -1, 4, 5, 6, 7, -1, -1]\n assert candidate(grid = [[-1, -1, 1, 1, -1, -1, 1, 1, -1, -1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1]]) == [-1, 1, 2, -1, -1, 5, 6, -1, -1, 9]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1]\n assert candidate(grid = [[-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, 1, 1, 1, -1, -1, -1, -1, 1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, -1, 1, 1, -1, -1, 1, 1, -1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, 8, -1, -1]\n assert candidate(grid = [[-1, -1, -1, 1, 1, 1, 1, 1, 1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]]) == [4, 5, -1, -1, -1, -1, -1, -1, -1, -1, 6]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, 1, -1], [1, -1, 1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, 1, -1, 1, -1], [1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [-1, 0, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1], [1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, 1, -1, -1, 1, 1, -1, 1], [-1, 1, -1, 1, -1, -1, 1, 1, -1, 1], [1, -1, 1, 1, -1, -1, 1, 1, -1, 1], [-1, 1, -1, 1, -1, -1, 1, 1, -1, 1], [1, -1, 1, 1, -1, -1, 1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1]]) == [-1, -1, -1, 2, -1, -1, -1, 6, -1, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, -1, -1, 1, 1, 1, 1], [-1, -1, -1, 1, 1, -1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, 1, 1, -1, -1], [1, -1, 1, -1, -1, 1, 1, -1, 1, -1]]) == [-1, -1, 6, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, -1, 1], [1, -1, 1, -1, 1, 1], [-1, 1, 1, -1, 1, 1], [1, -1, 1, 1, -1, 1], [-1, 1, -1, -1, 1, 1]]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1]]) == [-1, 2, -1, -1, 3, 6, 7, -1, -1, -1, 11, -1, -1, -1, -1, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, -1, -1, -1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, -1, -1, -1, -1, 1, 1], [-1, -1, -1, -1, 1, 1, 1, 1, -1, -1], [1, 1, 1, 1, -1, -1, -1, -1, 1, 1], [-1, -1, -1, -1, 1, 1, 1, 1, -1, -1]]) == [-1, 0, 1, 2, 5, 6, 7, 8, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, -1, -1, -1, -1, 1, 1], [1, -1, -1, -1, 1, 1, 1, 1, -1, -1], [-1, 1, 1, 1, -1, -1, -1, -1, 1, 1], [1, -1, -1, -1, 1, 1, 1, 1, -1, -1]]) == [-1, 1, 2, -1, -1, 5, 6, 7, 8, -1]\n assert candidate(grid = [[1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1], [-1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1], [1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1], [-1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, -1, -1, -1, -1, -1, -1, -1, -1, 18]\n assert candidate(grid = [[1, 1, 1, -1, -1, -1, 1, 1, 1], [1, -1, -1, 1, 1, -1, -1, 1, -1], [-1, 1, -1, -1, 1, -1, 1, -1, 1], [1, 1, -1, 1, -1, 1, -1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]]) == [4, -1, -1, -1, -1, -1, -1, -1, -1, 5]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1], [1, -1, 1, 1, -1, -1, 1, 1, -1], [-1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, 1, -1, 1, -1, 1, 1, -1], [-1, 1, -1, -1, 1, -1, 1, -1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, 1, -1, 1, -1, 1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, -1, -1, -1, 1, 1, 1, 1, -1, -1], [-1, -1, 1, 1, 1, 1, -1, -1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, 0, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [-1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1], [1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [-1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1]]) == [0, 1, -1, -1, 4, 5, 6, -1, -1, 9, 10, 11, -1, -1, 14, 15, 16, -1, -1, 19]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, -1, 1, 1, 1, -1], [-1, -1, -1, 1, 1, 1, -1, -1, -1, 1], [1, 1, 1, -1, -1, -1, 1, 1, 1, -1], [-1, -1, -1, 1, 1, 1, -1, -1, -1, 1], [1, 1, 1, -1, -1, -1, 1, 1, 1, -1]]) == [1, 2, -1, -1, 3, 4, 7, 8, -1, -1]\n assert candidate(grid = [[1, -1, 1, 1, -1, -1, 1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, -1, 1, 1, -1, 1, -1, -1, 1, -1], [1, 1, -1, -1, 1, -1, 1, -1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n", "comparison": "exact"}, "public_tests": ["[[1,1,1,-1,-1],[1,1,1,-1,-1],[-1,-1,-1,1,1],[1,1,1,1,-1],[-1,-1,-1,-1,-1]]", "[[-1]]", "[[1,1,1,1,1,1],[-1,-1,-1,-1,-1,-1],[1,1,1,1,1,1],[-1,-1,-1,-1,-1,-1]]"], "hints": ["Use DFS.", "Traverse the path of the ball downwards until you reach the bottom or get stuck."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().findBall", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:08+00:00", "tests_total": 65, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "matrix", "simulation"]}, "language": "python", "interface": {"raw_signature": "def findBall(self, grid: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "findBall", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1707, "task_id": "maximum-xor-with-an-element-from-array", "difficulty": "Hard", "problem_description": "You are given an array nums consisting of non-negative integers. You are also given a queries array, where queries[i] = [x_i, m_i].\n\nThe answer to the i^th query is the maximum bitwise XOR value of x_i and any element of nums that does not exceed m_i. In other words, the answer is max(nums[j] XOR x_i) for all j such that nums[j] <= m_i. If all elements in nums are larger than m_i, then the answer is -1.\n\nReturn an integer array answer where answer.length == queries.length and answer[i] is the answer to the i^th query.\n\nExample 1:\n\nInput: nums = [0,1,2,3,4], queries = [[3,1],[1,3],[5,6]]\nOutput: [3,3,7]\nExplanation:\n1) 0 and 1 are the only two integers not greater than 1. 0 XOR 3 = 3 and 1 XOR 3 = 2. The larger of the two is 3.\n2) 1 XOR 2 = 3.\n3) 5 XOR 2 = 7.\n\nExample 2:\n\nInput: nums = [5,2,4,6,6,3], queries = [[12,4],[8,1],[6,3]]\nOutput: [15,-1,5]\n\nConstraints:\n\n- 1 <= nums.length, queries.length <= 10^5\n- queries[i].length == 2\n- 0 <= nums[j], x_i, m_i <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 4, 8, 16],queries = [[10, 15], [30, 20], [5, 5]]) == [14, 31, 7]\n assert candidate(nums = [100, 200, 300, 400],queries = [[150, 250], [10, 100], [450, 500]]) == [242, 110, 422]\n assert candidate(nums = [7, 8, 9],queries = [[1, 5], [6, 8], [10, 12]]) == [-1, 14, 13]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[1, 10], [2, 5], [3, 3], [4, 4], [5, 2], [6, 6], [7, 7], [8, 8], [9, 9], [10, 1]]) == [11, 7, 2, 7, 7, 7, 6, 15, 15, 11]\n assert candidate(nums = [1000000000],queries = [[1000000000, 1000000000], [999999999, 999999999]]) == [0, -1]\n assert candidate(nums = [5, 2, 4, 6, 6, 3],queries = [[12, 4], [8, 1], [6, 3]]) == [15, -1, 5]\n assert candidate(nums = [0, 1, 2, 3, 4],queries = [[3, 1], [1, 3], [5, 6]]) == [3, 3, 7]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [[9, 10], [99, 100], [999, 1000], [9999, 10000], [99999, 100000], [999999, 1000000], [9999999, 10000000], [99999999, 100000000], [999999999, 1000000000], [0, 1]]) == [8, 105, 1005, 10091, 106895, 1008943, 10031327, 100311743, 1047472383, 1]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],queries = [[1000000000, 999999999], [999999998, 999999997], [999999996, 999999995], [999999995, 1000000000]]) == [1023, 3, -1, 1019]\n assert candidate(nums = [1, 1, 1, 1, 1],queries = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 0], [1, 0], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == [-1, -1, 3, 2, 5, 4, 7, 6, 9, 8]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],queries = [[7, 7], [7, 6], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15]]) == [0, -1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384],queries = [[1024, 2047], [2048, 4095], [4096, 8191], [8192, 16383], [16384, 32767], [32768, 16384], [65536, 8192]]) == [0, 3072, 6144, 12288, 24576, 49152, 73728]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],queries = [[1000000000, 999999999], [999999998, 999999997], [999999996, 999999995], [999999994, 999999993], [999999992, 999999991], [999999990, 999999989], [999999988, 999999987], [999999986, 999999985], [999999984, 999999983], [999999982, 999999981]]) == [1023, 9, 11, 13, 15, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400],queries = [[10, 100], [150, 200], [250, 300], [350, 400], [400, 450], [500, 550]]) == [110, 242, 470, 456, 500, 400]\n assert candidate(nums = [1024, 2048, 3072, 4096, 5120, 6144, 7168, 8192, 9216],queries = [[512, 1024], [1536, 2048], [2560, 3072], [3584, 4096], [4608, 5120], [5632, 6144], [6656, 7168], [7680, 8192], [8704, 9216]]) == [1536, 3584, 3584, 7680, 7680, 7680, 7680, 15872, 15872]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10], [100, 0]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],queries = [[0, 31], [1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21], [11, 20], [12, 19], [13, 18], [14, 17], [15, 16]]) == [31, 28, 31, 26, 31, 28, 31, 22, 31, 28, 31, 26, 31, 28, 31, 14]\n assert candidate(nums = [1000000000, 900000000, 800000000, 700000000, 600000000],queries = [[1000000000, 1000000000], [900000000, 900000000], [800000000, 800000000], [700000000, 700000000], [600000000, 600000000], [500000000, 500000000]]) == [408521728, 471715328, 208424448, 175792384, 0, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[50, 350], [150, 450], [250, 550], [350, 650], [450, 750], [550, 850], [650, 950], [750, 1050], [850, 1150], [950, 1250]]) == [286, 442, 470, 774, 922, 978, 934, 962, 922, 978]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],queries = [[1024, 512], [512, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1], [1, 1]]) == [1536, 768, 384, 192, 96, 48, 24, 12, 6, 3, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [0, 3, 2, 7, 6, 7, 6, 15, 14, 15]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19]]) == [3, 7, 7, 15, 15, 15, 15, 31, 31, 31]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],queries = [[0, 1], [1, 2], [3, 4], [7, 8], [15, 16], [31, 32], [63, 64], [127, 128], [255, 256], [511, 512], [1023, 1024], [2047, 2048], [4095, 4096], [8191, 8192], [16383, 16384], [32767, 32768], [65535, 65536], [131071, 131072], [262143, 262144], [524287, 524288], [1048575, 1048576]]) == [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],queries = [[1, 2], [3, 4], [7, 8], [15, 16], [31, 32], [63, 64], [127, 128], [255, 256], [511, 512], [1023, 1024]]) == [3, 7, 15, 31, 63, 127, 255, 511, 1023, 1022]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],queries = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19], [22, 21], [24, 23], [26, 25], [28, 27], [30, 29], [32, 31]]) == [3, 7, 7, 15, 15, 15, 15, 31, 31, 31, 31, 31, 31, 31, 31, 63]\n assert candidate(nums = [23, 31, 12, 22, 19, 30, 27, 14, 29, 25],queries = [[10, 30], [35, 35], [23, 23], [19, 20], [30, 31]]) == [29, 62, 27, 31, 18]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[5, 10], [15, 25], [25, 35], [35, 45], [45, 55], [55, 65], [65, 75], [75, 85], [85, 95], [95, 105]]) == [15, 27, 19, 61, 57, 61, 125, 121, 125, 119]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[50, 150], [250, 350], [450, 550], [650, 750], [850, 950], [1050, 1150]]) == [86, 470, 422, 934, 922, 2034]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],queries = [[1, 5], [10, 50], [100, 500], [1000, 5000], [10000, 50000], [100000, 500000], [1000000, 1500000]]) == [0, 11, 110, 1001, 10100, 106928, 1008976]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19]]) == [-1, 1, 7, 5, 15, 15, 15, 13, 31, 31]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [5, 100], [105, 100]]) == [0, 30, 20, 60, 56, 54, 122, 120, 114, 122, 97, 125]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[2, 10], [4, 20], [6, 30], [8, 40], [10, 50], [12, 60], [14, 70], [16, 80], [18, 90], [20, 100]]) == [11, 23, 23, 27, 27, 31, 31, 31, 31, 31]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == [0, 2, 6, 6, 14, 14, 14, 14, 30, 30]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [[1, 1], [5, 10], [50, 100], [500, 1000], [5000, 10000], [50000, 100000], [500000, 1000000], [5000000, 10000000], [50000000, 100000000], [500000000, 1000000000]]) == [0, 15, 86, 540, 13464, 83440, 582496, 13950400, 118428032, 643280640]\n assert candidate(nums = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22],queries = [[32, 31], [33, 30], [34, 29], [35, 28], [36, 27], [37, 26], [38, 25], [39, 24], [40, 23], [41, 22]]) == [63, 63, 63, 63, 63, 63, 63, 63, 63, 63]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],queries = [[100, 100], [101, 101], [102, 102], [103, 103], [104, 104], [105, 105], [106, 106], [107, 107], [108, 108], [109, 109]]) == [0, 1, 3, 3, 15, 15, 15, 15, 11, 11]\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505],queries = [[100, 200], [300, 400], [500, 600], [700, 800], [800, 700], [900, 1000]]) == [31, 486, 401, 915, 1002, 1023]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[5, 50], [15, 30], [25, 40], [35, 60], [45, 70], [55, 80], [65, 90], [75, 100], [85, 20], [95, 10]]) == [55, 27, 49, 61, 107, 113, 125, 121, 95, 85]\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],queries = [[500, 1024], [256, 256], [1025, 1025], [10, 20], [2, 3]]) == [1524, 384, 1537, 26, 3]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],queries = [[1, 1], [2, 2], [3, 4], [5, 8], [9, 16], [17, 32], [33, 64], [65, 128], [129, 256], [257, 512], [513, 1024], [1025, 2048], [2049, 4096], [4097, 8192], [8193, 16384], [16385, 32768]]) == [0, 3, 7, 13, 25, 49, 97, 193, 385, 769, 1537, 3073, 6145, 12289, 24577, 49153]\n assert candidate(nums = [50, 40, 30, 20, 10],queries = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70], [75, 80], [85, 90], [95, 100]]) == [15, 27, 19, 61, 57, 61, 115, 121, 125, 119]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[101, 99], [201, 199], [301, 299], [401, 399], [501, 499], [601, 599], [701, 699], [801, 799], [901, 899], [1001, 999]]) == [-1, 173, 485, 501, 401, 969, 913, 1001, 993, 909]\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384],queries = [[512, 1024], [1536, 2048], [2560, 4096], [4608, 8192], [8704, 16384], [32768, 65536]]) == [1536, 3584, 6656, 12800, 25088, 49152]\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],queries = [[100, 123], [400, 456], [700, 789], [100000, 101112], [130000, 131415], [160000, 161718], [190000, 192021], [220000, 222324], [250000, 252627], [280000, 282930]]) == [31, 491, 884, 100200, 260743, 261112, 224456, 219931, 250757, 499475]\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500],queries = [[50, 100], [250, 350], [375, 400], [500, 500], [100, 99]]) == [86, 470, 481, 400, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [1, 3, 3, 7, 7, 7, 7, 15, 15, 15]\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99],queries = [[8, 9], [17, 18], [26, 27], [35, 36], [44, 45], [53, 54], [62, 63], [71, 72], [80, 81], [89, 90], [98, 99]]) == [1, 24, 19, 56, 62, 60, 55, 120, 125, 125, 121]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],queries = [[999, 1000], [1999, 2000], [2999, 3000], [3999, 4000], [4999, 5000], [5999, 6000], [6999, 7000], [7999, 8000], [8999, 9000], [9999, 10000]]) == [15, 1063, 3175, 3191, 7207, 7383, 7303, 7383, 15463, 15447]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 100], [12, 100], [13, 100], [14, 100], [15, 100], [16, 100], [17, 100], [18, 100], [19, 100], [20, 100]]) == [11, 22, 29, 44, 55, 58, 65, 88, 89, 110, 111, 104, 105, 106, 107, 116, 117, 118, 119, 112]\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],queries = [[8, 9], [17, 18], [26, 27], [35, 36], [44, 45], [53, 54], [62, 63], [71, 72], [80, 81], [89, 90], [91, 90]]) == [1, 24, 19, 56, 62, 60, 55, 120, 125, 125, 127]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[2, 5], [4, 9], [6, 13], [8, 17], [10, 19], [12, 21], [14, 23], [16, 25], [18, 27], [20, 29]]) == [7, 13, 15, 25, 27, 31, 31, 31, 31, 31]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],queries = [[10, 9], [7, 6], [1, 10], [8, 5], [0, 0]]) == [15, 6, 8, 13, -1]\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021],queries = [[122, 123], [455, 456], [788, 789], [101111, 101112], [131414, 131415], [161717, 161718], [192020, 192021], [200000, 210000]]) == [1, 444, 879, 101183, 232366, 261453, 222444, 200277]\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000],queries = [[1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [125000000, 125000000], [62500000, 62500000], [31250000, 31250000], [15625000, 15625000]]) == [1021940544, 510970272, 255485136, 127742568, 56084360, 20102520, 0]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[1, 15], [2, 14], [3, 13], [4, 12], [5, 11], [6, 10], [7, 9], [8, 8], [9, 7], [10, 6], [11, 5], [12, 4], [13, 3], [14, 2], [15, 1]]) == [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],queries = [[2, 10], [4, 12], [6, 14], [8, 16], [10, 18], [12, 20], [14, 22], [16, 24], [18, 26], [20, 28], [22, 30], [24, 10], [26, 12], [28, 14], [30, 16]]) == [11, 15, 15, 15, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31]\n assert candidate(nums = [100, 200, 300, 400, 500],queries = [[150, 200], [250, 350], [350, 450], [50, 150], [450, 500]]) == [242, 470, 406, 86, 422]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [[1, 1000000000], [2, 100000000], [3, 10000000], [4, 1000000], [5, 100000], [6, 10000], [7, 1000], [8, 100], [9, 10], [10, 1]]) == [1000000001, 100000002, 10000003, 1000004, 100005, 10006, 1007, 108, 8, 11]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],queries = [[1000000000, 1000000000], [1, 1000000000], [1000000000, 999999999], [1, 999999999], [1000000000, 999999998]]) == [1023, 1000000001, 1023, 999999999, 1022]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],queries = [[1, 2], [2, 4], [3, 8], [4, 16], [5, 32], [6, 64], [7, 128], [8, 256], [9, 512], [10, 1024], [11, 2048], [12, 4096], [13, 8192], [14, 16384], [15, 32768]]) == [3, 6, 11, 20, 37, 70, 135, 264, 521, 1034, 2059, 4108, 8205, 16398, 16399]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],queries = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512], [1024, 1024], [2048, 2048], [4096, 4096], [8192, 8192], [16384, 16384], [32768, 16384]]) == [0, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152]\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109],queries = [[11, 30], [22, 40], [33, 50], [44, 60], [55, 70], [66, 80], [77, 90], [88, 100], [99, 110], [100, 120]]) == [30, 54, 52, 57, 118, 116, 123, 120, 118, 113]\n assert candidate(nums = [8, 4, 2, 1, 16, 32, 64, 128, 256, 512],queries = [[7, 8], [3, 4], [1, 2], [15, 16], [31, 32], [63, 64], [127, 128], [255, 256], [511, 512], [1023, 1024]]) == [15, 7, 3, 31, 63, 127, 255, 511, 1023, 1022]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],queries = [[2, 3], [5, 6], [8, 9], [11, 12], [14, 15], [17, 18], [20, 21], [23, 24], [26, 27], [29, 30], [31, 32]]) == [1, 6, 14, 13, 13, 30, 29, 30, 28, 30, 28]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[15, 10], [25, 20], [35, 30], [45, 40], [55, 50], [65, 60], [75, 70], [85, 80], [95, 90], [105, 100]]) == [5, 19, 61, 57, 61, 125, 121, 125, 119, 125]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],queries = [[1, 1], [2, 2], [3, 4], [5, 8], [9, 16], [17, 32], [33, 64], [65, 128], [129, 256], [257, 512]]) == [0, 3, 7, 13, 25, 49, 97, 193, 385, 769]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],queries = [[1000000000, 999999999], [999999998, 999999998], [999999997, 999999996], [999999996, 999999995]]) == [1023, 3, 1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],queries = [[2, 10], [4, 12], [6, 14], [8, 16], [10, 18], [12, 20], [14, 22], [16, 24], [18, 26], [20, 28], [22, 30], [24, 32], [26, 34], [28, 36], [30, 38]]) == [11, 15, 15, 15, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 1], [2, 1], [0, 1], [10, 1], [100, 1]]) == [0, 3, 1, 11, 101]\n assert candidate(nums = [23, 45, 67, 89, 111, 135, 159, 183, 207, 231],queries = [[22, 23], [44, 45], [66, 67], [88, 89], [110, 111], [134, 135], [158, 159], [182, 183], [206, 207], [230, 231]]) == [1, 59, 111, 117, 121, 233, 241, 245, 227, 241]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],queries = [[100, 105], [101, 101], [102, 103], [103, 107], [104, 104], [105, 108], [106, 106], [107, 109], [108, 110], [109, 100], [110, 102]]) == [13, 1, 3, 15, 15, 15, 15, 15, 11, 9, 11]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[99, 100], [150, 300], [250, 250], [350, 400], [450, 500], [550, 600], [650, 700], [750, 800], [850, 900], [950, 1000]]) == [7, 442, 158, 406, 422, 978, 934, 962, 922, 978]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],queries = [[1, 2], [2, 3], [3, 5], [4, 7], [5, 11], [6, 13], [7, 17], [8, 19], [9, 23], [10, 29]]) == [3, 1, 6, 7, 14, 13, 22, 27, 30, 29]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23]]) == [7, 7, 15, 15, 15, 15, 31, 31, 31, 31]\n", "comparison": "exact"}, "public_tests": ["[0,1,2,3,4]\n[[3,1],[1,3],[5,6]]", "[5,2,4,6,6,3]\n[[12,4],[8,1],[6,3]]"], "hints": ["In problems involving bitwise operations, we often think on the bits level. In this problem, we can think that to maximize the result of an xor operation, we need to maximize the most significant bit, then the next one, and so on.", "If there's some number in the array that is less than m and whose the most significant bit is different than that of x, then xoring with this number maximizes the most significant bit, so I know this bit in the answer is 1.", "To check the existence of such numbers and narrow your scope for further bits based on your choice, you can use trie.", "You can sort the array and the queries, and maintain the trie such that in each query the trie consists exactly of the valid elements."], "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().maximizeXor", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:11+00:00", "tests_total": 83, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "bit-manipulation", "trie"]}, "language": "python", "interface": {"raw_signature": "def maximizeXor(self, nums: list[int], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "maximizeXor", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1710, "task_id": "maximum-units-on-a-truck", "difficulty": "Easy", "problem_description": "You are assigned to put some amount of boxes onto one truck. You are given a 2D array boxTypes, where boxTypes[i] = [numberOfBoxes_i, numberOfUnitsPerBox_i]:\n\n- numberOfBoxes_i is the number of boxes of type i.\n- numberOfUnitsPerBox_iis the number of units in each box of the type i.\n\nYou are also given an integer truckSize, which is the maximum number of boxes that can be put on the truck. You can choose any boxes to put on the truck as long as the number of boxes does not exceed truckSize.\n\nReturn the maximum total number of units that can be put on the truck.\n\nExample 1:\n\nInput: boxTypes = [[1,3],[2,2],[3,1]], truckSize = 4\nOutput: 8\nExplanation: There are:\n- 1 box of the first type that contains 3 units.\n- 2 boxes of the second type that contain 2 units each.\n- 3 boxes of the third type that contain 1 unit each.\nYou can take all the boxes of the first and second types, and one box of the third type.\nThe total number of units will be = (1 * 3) + (2 * 2) + (1 * 1) = 8.\n\nExample 2:\n\nInput: boxTypes = [[5,10],[2,5],[4,7],[3,9]], truckSize = 10\nOutput: 91\n\nConstraints:\n\n- 1 <= boxTypes.length <= 1000\n- 1 <= numberOfBoxes_i, numberOfUnitsPerBox_i <= 1000\n- 1 <= truckSize <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(boxTypes = [[1, 3], [2, 2], [3, 1]],truckSize = 4) == 8\n assert candidate(boxTypes = [[1, 1], [2, 2], [3, 3], [4, 4]],truckSize = 1) == 4\n assert candidate(boxTypes = [[2, 1], [4, 4], [3, 3]],truckSize = 5) == 19\n assert candidate(boxTypes = [[10, 1], [20, 2], [30, 3]],truckSize = 50) == 130\n assert candidate(boxTypes = [[5, 10], [2, 5], [4, 7], [3, 9]],truckSize = 10) == 91\n assert candidate(boxTypes = [[1, 100], [2, 99], [3, 98], [4, 97]],truckSize = 10) == 980\n assert candidate(boxTypes = [[10, 1], [5, 2], [3, 3]],truckSize = 10) == 21\n assert candidate(boxTypes = [[100, 1], [99, 2], [98, 3], [97, 4]],truckSize = 200) == 692\n assert candidate(boxTypes = [[10, 1]],truckSize = 10) == 10\n assert candidate(boxTypes = [[1, 1000], [1000, 1]],truckSize = 500) == 1499\n assert candidate(boxTypes = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60]],truckSize = 10) == 800\n assert candidate(boxTypes = [[5, 5], [5, 5], [5, 5], [5, 5]],truckSize = 15) == 75\n assert candidate(boxTypes = [[2, 1], [3, 2], [4, 3], [5, 4], [6, 5]],truckSize = 15) == 62\n assert candidate(boxTypes = [[2, 1000], [1, 900], [2, 800], [1, 700], [2, 600], [1, 500], [2, 400], [1, 300], [2, 200], [1, 100]],truckSize = 10) == 7300\n assert candidate(boxTypes = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]],truckSize = 20) == 115\n assert candidate(boxTypes = [[5, 10], [1, 15], [3, 12], [2, 14], [4, 8]],truckSize = 15) == 161\n assert candidate(boxTypes = [[7, 10], [5, 3], [2, 6], [8, 1]],truckSize = 20) == 103\n assert candidate(boxTypes = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5]],truckSize = 15) == 35\n assert candidate(boxTypes = [[5, 10], [4, 20], [3, 30], [2, 40], [1, 50]],truckSize = 15) == 350\n assert candidate(boxTypes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],truckSize = 5) == 40\n assert candidate(boxTypes = [[9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],truckSize = 30) == 174\n assert candidate(boxTypes = [[999, 1], [1, 999], [500, 500], [250, 250], [125, 125]],truckSize = 1000) == 329248\n assert candidate(boxTypes = [[1, 5], [2, 3], [3, 2], [4, 1]],truckSize = 10) == 21\n assert candidate(boxTypes = [[50, 10], [100, 9], [150, 8], [200, 7], [250, 6], [300, 5]],truckSize = 800) == 5750\n assert candidate(boxTypes = [[50, 5], [30, 6], [20, 7]],truckSize = 100) == 570\n assert candidate(boxTypes = [[3, 100], [2, 200], [1, 300], [5, 400]],truckSize = 5) == 2000\n assert candidate(boxTypes = [[20, 5], [15, 10], [10, 15], [5, 20], [1, 25]],truckSize = 35) == 445\n assert candidate(boxTypes = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],truckSize = 20) == 18900\n assert candidate(boxTypes = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50]],truckSize = 40) == 1400\n assert candidate(boxTypes = [[50, 10], [30, 20], [20, 30], [10, 40], [5, 50]],truckSize = 120) == 2350\n assert candidate(boxTypes = [[200, 1], [100, 2], [150, 3], [50, 4], [250, 5]],truckSize = 500) == 2000\n assert candidate(boxTypes = [[100, 1], [50, 2], [25, 3], [10, 4], [5, 5], [1, 6]],truckSize = 150) == 305\n assert candidate(boxTypes = [[20, 25], [15, 30], [10, 35], [5, 40]],truckSize = 50) == 1500\n assert candidate(boxTypes = [[10, 10], [5, 7], [15, 5], [20, 3]],truckSize = 25) == 185\n assert candidate(boxTypes = [[50, 10], [30, 20], [20, 30], [10, 40]],truckSize = 100) == 2000\n assert candidate(boxTypes = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],truckSize = 150) == 5500\n assert candidate(boxTypes = [[1, 900], [2, 800], [3, 700], [4, 600], [5, 500], [6, 400], [7, 300], [8, 200], [9, 100]],truckSize = 15) == 9500\n assert candidate(boxTypes = [[1, 999], [2, 998], [3, 997], [4, 996], [5, 995], [6, 994], [7, 993], [8, 992], [9, 991], [10, 990]],truckSize = 20) == 19915\n assert candidate(boxTypes = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],truckSize = 55) == 220\n assert candidate(boxTypes = [[30, 20], [20, 15], [10, 10], [40, 5], [50, 2]],truckSize = 100) == 1200\n assert candidate(boxTypes = [[10, 30], [20, 20], [30, 10], [40, 5], [50, 1]],truckSize = 60) == 1000\n assert candidate(boxTypes = [[50, 10], [40, 20], [30, 30], [20, 40], [10, 50]],truckSize = 120) == 3200\n assert candidate(boxTypes = [[500, 1000], [400, 900], [300, 800], [200, 700], [100, 600]],truckSize = 1200) == 1100000\n assert candidate(boxTypes = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],truckSize = 150) == 1450\n assert candidate(boxTypes = [[100, 10], [200, 9], [150, 8], [50, 7], [25, 6]],truckSize = 300) == 2800\n assert candidate(boxTypes = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],truckSize = 50) == 215\n assert candidate(boxTypes = [[500, 100], [300, 200], [200, 300], [100, 400]],truckSize = 800) == 180000\n assert candidate(boxTypes = [[50, 100], [25, 200], [75, 50], [100, 250]],truckSize = 200) == 36250\n assert candidate(boxTypes = [[1, 999], [999, 1]],truckSize = 1000) == 1998\n assert candidate(boxTypes = [[7, 9], [7, 8], [7, 7], [7, 6], [7, 5], [7, 4], [7, 3], [7, 2], [7, 1]],truckSize = 20) == 161\n assert candidate(boxTypes = [[3, 8], [5, 7], [2, 9], [6, 10], [4, 5]],truckSize = 15) == 130\n assert candidate(boxTypes = [[5, 10], [4, 20], [3, 30], [2, 40], [1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [1, 100]],truckSize = 20) == 750\n assert candidate(boxTypes = [[50, 20], [100, 15], [150, 10], [200, 5], [250, 1]],truckSize = 500) == 5000\n assert candidate(boxTypes = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996]],truckSize = 15) == 14960\n assert candidate(boxTypes = [[5, 10], [5, 20], [5, 30], [5, 40], [5, 50], [5, 60], [5, 70], [5, 80], [5, 90], [5, 100]],truckSize = 25) == 2000\n assert candidate(boxTypes = [[10, 1000], [9, 900], [8, 800], [7, 700], [6, 600], [5, 500], [4, 400], [3, 300], [2, 200], [1, 100]],truckSize = 25) == 22900\n assert candidate(boxTypes = [[100, 5], [200, 2], [50, 10], [150, 3]],truckSize = 350) == 1550\n assert candidate(boxTypes = [[50, 100], [40, 99], [30, 98], [20, 97], [10, 96], [5, 95]],truckSize = 160) == 15275\n assert candidate(boxTypes = [[1, 500], [1, 400], [1, 300], [1, 200], [1, 100]],truckSize = 2) == 900\n assert candidate(boxTypes = [[3, 9], [2, 8], [5, 7], [1, 6], [4, 5]],truckSize = 15) == 104\n assert candidate(boxTypes = [[10, 20], [20, 10], [30, 5], [40, 2], [50, 1]],truckSize = 100) == 630\n assert candidate(boxTypes = [[300, 1], [200, 2], [100, 3], [50, 4], [25, 5]],truckSize = 700) == 1325\n assert candidate(boxTypes = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996]],truckSize = 15) == 14960\n assert candidate(boxTypes = [[5, 15], [10, 12], [20, 9], [30, 7], [40, 5], [50, 3]],truckSize = 150) == 920\n assert candidate(boxTypes = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],truckSize = 500) == 3740\n assert candidate(boxTypes = [[5, 15], [20, 3], [5, 20], [10, 7]],truckSize = 25) == 260\n assert candidate(boxTypes = [[100, 10], [50, 20], [20, 30], [10, 40]],truckSize = 200) == 3000\n assert candidate(boxTypes = [[100, 2], [200, 3], [300, 4], [400, 5], [500, 6]],truckSize = 1000) == 5400\n assert candidate(boxTypes = [[100, 1], [50, 2], [25, 3], [12, 4], [6, 5], [3, 6], [1, 7]],truckSize = 200) == 378\n assert candidate(boxTypes = [[50, 10], [40, 9], [30, 8], [20, 7], [10, 6], [5, 5], [1, 4]],truckSize = 160) == 1329\n assert candidate(boxTypes = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],truckSize = 50) == 374\n assert candidate(boxTypes = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],truckSize = 500) == 37400\n assert candidate(boxTypes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],truckSize = 10) == 55\n assert candidate(boxTypes = [[1, 500], [2, 400], [3, 300], [4, 200], [5, 100]],truckSize = 10) == 3000\n assert candidate(boxTypes = [[30, 4], [10, 20], [15, 5]],truckSize = 50) == 375\n assert candidate(boxTypes = [[100, 10], [200, 9], [300, 8], [400, 7]],truckSize = 1000) == 8000\n assert candidate(boxTypes = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],truckSize = 1) == 50\n assert candidate(boxTypes = [[10, 100], [5, 200], [3, 300], [2, 400], [1, 500]],truckSize = 20) == 4100\n assert candidate(boxTypes = [[10, 5], [5, 10], [15, 3]],truckSize = 18) == 109\n assert candidate(boxTypes = [[10, 5], [20, 8], [30, 2], [5, 9]],truckSize = 40) == 265\n assert candidate(boxTypes = [[10, 10], [20, 9], [30, 8], [40, 7], [50, 6], [60, 5], [70, 4], [80, 3], [90, 2], [100, 1]],truckSize = 250) == 1560\n assert candidate(boxTypes = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5]],truckSize = 30) == 120\n assert candidate(boxTypes = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]],truckSize = 15) == 11000\n assert candidate(boxTypes = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700], [80, 800], [90, 900]],truckSize = 300) == 230000\n assert candidate(boxTypes = [[500, 500], [500, 500], [500, 500]],truckSize = 1000) == 500000\n assert candidate(boxTypes = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],truckSize = 1000) == 4400\n assert candidate(boxTypes = [[50, 20], [30, 15], [40, 10], [20, 5]],truckSize = 100) == 1650\n assert candidate(boxTypes = [[10, 5], [20, 3], [30, 4], [40, 2], [50, 1]],truckSize = 100) == 310\n assert candidate(boxTypes = [[10, 500], [20, 450], [30, 400], [40, 350], [50, 300], [60, 250], [70, 200], [80, 150], [90, 100], [100, 50]],truckSize = 200) == 67500\n assert candidate(boxTypes = [[3, 2], [2, 5], [6, 1], [10, 3]],truckSize = 12) == 40\n assert candidate(boxTypes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],truckSize = 30) == 266\n assert candidate(boxTypes = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [10, 6], [9, 7], [8, 8], [7, 9], [6, 10]],truckSize = 50) == 340\n assert candidate(boxTypes = [[100, 10], [200, 5], [300, 1]],truckSize = 500) == 2200\n assert candidate(boxTypes = [[10, 5], [9, 4], [8, 3], [7, 2], [6, 1]],truckSize = 20) == 89\n assert candidate(boxTypes = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5]],truckSize = 250) == 1050\n assert candidate(boxTypes = [[50, 10], [50, 20], [50, 30], [50, 40], [50, 50]],truckSize = 150) == 6000\n assert candidate(boxTypes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],truckSize = 15) == 145\n assert candidate(boxTypes = [[50, 1], [200, 2], [100, 3], [30, 4], [10, 5]],truckSize = 250) == 690\n assert candidate(boxTypes = [[1, 1000], [1, 999], [1, 998], [1, 997], [1, 996], [1, 995], [1, 994], [1, 993], [1, 992], [1, 991]],truckSize = 10) == 9955\n assert candidate(boxTypes = [[10, 100], [20, 90], [30, 80], [40, 70], [50, 60]],truckSize = 200) == 11000\n assert candidate(boxTypes = [[100, 100], [90, 90], [80, 80], [70, 70], [60, 60], [50, 50]],truckSize = 500) == 35500\n assert candidate(boxTypes = [[20, 1], [20, 2], [20, 3], [20, 4], [20, 5], [20, 6], [20, 7], [20, 8], [20, 9], [20, 10]],truckSize = 100) == 800\n", "comparison": "exact"}, "public_tests": ["[[1,3],[2,2],[3,1]]\n4", "[[5,10],[2,5],[4,7],[3,9]]\n10"], "hints": ["If we have space for at least one box, it's always optimal to put the box with the most units.", "Sort the box types with the number of units per box non-increasingly.", "Iterate on the box types and take from each type as many as you can."], "metadata": {"canonical_parameter_names": ["boxTypes", "truckSize"], "leetcode_dataset_entry_point": "Solution().maximumUnits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:16+00:00", "tests_total": 104, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maximumUnits(self, boxTypes: list[list[int]], truckSize: int) -> int:", "container": "Solution", "callable": "maximumUnits", "parameters": [{"name": "boxTypes", "type": "list[list[int]]"}, {"name": "truckSize", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1711, "task_id": "count-good-meals", "difficulty": "Medium", "problem_description": "A good meal is a meal that contains exactly two different food items with a sum of deliciousness equal to a power of two.\n\nYou can pick any two different foods to make a good meal.\n\nGiven an array of integers deliciousness where deliciousness[i] is the deliciousness of the i^th item of food, return the number of different good meals you can make from this list modulo 10^9 + 7.\n\nNote that items with different indices are considered different even if they have the same deliciousness value.\n\nExample 1:\n\nInput: deliciousness = [1,3,5,7,9]\nOutput: 4\nExplanation: The good meals are (1,3), (1,7), (3,5) and, (7,9).\nTheir respective sums are 4, 8, 8, and 16, all of which are powers of 2.\n\nExample 2:\n\nInput: deliciousness = [1,1,1,3,3,3,7]\nOutput: 15\nExplanation: The good meals are (1,1) with 3 ways, (1,3) with 9 ways, and (1,7) with 3 ways.\n\nConstraints:\n\n- 1 <= deliciousness.length <= 10^5\n- 0 <= deliciousness[i] <= 2^20\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(deliciousness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(deliciousness = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 15\n assert candidate(deliciousness = [0, 0, 0, 0, 0, 0]) == 0\n assert candidate(deliciousness = [0, 0]) == 0\n assert candidate(deliciousness = [2, 2, 2, 3, 3, 3, 4, 4, 4]) == 6\n assert candidate(deliciousness = [1048576, 1048576, 524288, 524288, 262144, 262144]) == 3\n assert candidate(deliciousness = [1]) == 0\n assert candidate(deliciousness = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(deliciousness = [1048576, 1048576]) == 1\n assert candidate(deliciousness = [13, 100, 13]) == 0\n assert candidate(deliciousness = [1, 3, 5, 7, 9]) == 4\n assert candidate(deliciousness = [1, 1, 1, 3, 3, 3, 7]) == 15\n assert candidate(deliciousness = [1, 0, 0, 0, 0]) == 4\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32]) == 0\n assert candidate(deliciousness = [1023, 1024, 512, 512, 256, 256, 128, 128, 64, 64, 32, 32, 16, 16, 8, 8, 4, 4, 2, 2, 1, 1]) == 12\n assert candidate(deliciousness = [1048576, 1, 1, 1, 1]) == 6\n assert candidate(deliciousness = [1, 1048575, 1048575, 1048576]) == 2\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 0\n assert candidate(deliciousness = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]) == 5\n assert candidate(deliciousness = [1, 100000, 200000, 300000, 400000]) == 0\n assert candidate(deliciousness = [220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220]) == 0\n assert candidate(deliciousness = [0, 0, 0, 0]) == 0\n assert candidate(deliciousness = [1048576, 1048576]) == 1\n assert candidate(deliciousness = [2, 2, 2, 2, 2]) == 10\n assert candidate(deliciousness = [1, 1048575]) == 1\n assert candidate(deliciousness = [0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 9]) == 10\n assert candidate(deliciousness = [31, 1, 4, 3, 12, 13, 8, 16, 7]) == 5\n assert candidate(deliciousness = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(deliciousness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(deliciousness = [1048575, 1048576, 524287, 524288, 262143, 262144, 131071, 131072, 65535, 65536, 32767, 32768, 16383, 16384, 8191, 8192, 4095, 4096, 2047, 2048, 1023, 1024, 511, 512, 255, 256, 127, 128, 63, 64, 31, 32, 15, 16, 7, 8, 3, 4, 1, 2, 0, 0, 0, 0, 0, 0]) == 145\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(deliciousness = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(deliciousness = [1048575, 1048574, 1048573, 1048572, 1048571, 1048570]) == 0\n assert candidate(deliciousness = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 28\n assert candidate(deliciousness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 11\n assert candidate(deliciousness = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31]) == 249\n assert candidate(deliciousness = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]) == 3\n assert candidate(deliciousness = [5, 1, 4, 3, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 15\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 0\n assert candidate(deliciousness = [21, 1, 17, 3, 9, 18, 25, 33]) == 1\n assert candidate(deliciousness = [1023, 1024, 2047, 2048, 3071, 3072, 4095, 4096]) == 1\n assert candidate(deliciousness = [1023, 1024, 1025, 2047, 2048, 2049, 4095, 4096, 4097]) == 3\n assert candidate(deliciousness = [1023, 1024, 2047, 2048, 4095, 4096, 8191, 8192]) == 0\n assert candidate(deliciousness = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127]) == 0\n assert candidate(deliciousness = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 14\n assert candidate(deliciousness = [5, 15, 1, 3, 7, 9, 11, 13]) == 7\n assert candidate(deliciousness = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047]) == 0\n assert candidate(deliciousness = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 19\n assert candidate(deliciousness = [1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575]) == 0\n assert candidate(deliciousness = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == 10\n assert candidate(deliciousness = [1023, 1024, 2047, 2048, 4095, 4096]) == 0\n assert candidate(deliciousness = [21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845]) == 0\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n assert candidate(deliciousness = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 0\n assert candidate(deliciousness = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 16\n assert candidate(deliciousness = [1, 1048575, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 1\n assert candidate(deliciousness = [0, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845]) == 0\n assert candidate(deliciousness = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 15\n assert candidate(deliciousness = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512]) == 10\n assert candidate(deliciousness = [1, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 13\n assert candidate(deliciousness = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 3\n assert candidate(deliciousness = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(deliciousness = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 100\n assert candidate(deliciousness = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128]) == 0\n assert candidate(deliciousness = [3, 5, 7, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 154\n assert candidate(deliciousness = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) == 5\n assert candidate(deliciousness = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 90\n assert candidate(deliciousness = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 0\n assert candidate(deliciousness = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 12\n assert candidate(deliciousness = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 0\n assert candidate(deliciousness = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(deliciousness = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]) == 61\n assert candidate(deliciousness = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 0\n assert candidate(deliciousness = [1, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 11\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n assert candidate(deliciousness = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 19\n assert candidate(deliciousness = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 26\n assert candidate(deliciousness = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 65\n assert candidate(deliciousness = [1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == 41\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 0\n assert candidate(deliciousness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 26\n assert candidate(deliciousness = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == 8\n assert candidate(deliciousness = [15, 9, 8, 7, 3, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 135\n assert candidate(deliciousness = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1, 1, 1]) == 6\n assert candidate(deliciousness = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n assert candidate(deliciousness = [22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22]) == 0\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 0\n assert candidate(deliciousness = [524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == 20\n assert candidate(deliciousness = [65535, 65536, 131071, 131072, 262143, 262144]) == 0\n assert candidate(deliciousness = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(deliciousness = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]) == 3\n assert candidate(deliciousness = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 12\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]) == 0\n", "comparison": "exact"}, "public_tests": ["[1,3,5,7,9]", "[1,1,1,3,3,3,7]"], "hints": ["Note that the number of powers of 2 is at most 21 so this turns the problem to a classic find the number of pairs that sum to a certain value but for 21 values", "You need to use something fasters than the NlogN approach since there is already the log of iterating over the powers so one idea is two pointers"], "metadata": {"canonical_parameter_names": ["deliciousness"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:18+00:00", "tests_total": 101, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "hash-table"]}, "language": "python", "interface": {"raw_signature": "def countPairs(self, deliciousness: list[int]) -> int:", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "deliciousness", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1712, "task_id": "ways-to-split-array-into-three-subarrays", "difficulty": "Medium", "problem_description": "A split of an integer array is good if:\n\n- The array is split into three non-empty contiguous subarrays - named left, mid, right respectively from left to right.\n- The sum of the elements in left is less than or equal to the sum of the elements in mid, and the sum of the elements in mid is less than or equal to the sum of the elements in right.\n\nGiven nums, an array of non-negative integers, return the number of good ways to split nums. As the number may be too large, return it modulo 10^9+ 7.\n\nExample 1:\n\nInput: nums = [1,1,1]\nOutput: 1\nExplanation: The only good way to split nums is [1] [1] [1].\n\nExample 2:\n\nInput: nums = [1,2,2,2,5,0]\nOutput: 3\nExplanation: There are three good ways of splitting nums:\n[1] [2] [2,2,5,0]\n[1] [2,2] [2,5,0]\n[1,2] [2,2] [5,0]\n\nExample 3:\n\nInput: nums = [3,2,1]\nOutput: 0\nExplanation: There is no good way to split nums.\n\nConstraints:\n\n- 3 <= nums.length <= 10^5\n- 0 <= nums[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10000, 10000, 10000]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 12\n assert candidate(nums = [1, 3, 2, 3, 1, 1, 1, 3, 2, 3]) == 9\n assert candidate(nums = [9, 4, 2, 5, 1]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 15\n assert candidate(nums = [1, 3, 2, 4, 1, 2, 3, 4]) == 6\n assert candidate(nums = [1, 1, 1]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 8\n assert candidate(nums = [10, 10, 10, 10, 10]) == 2\n assert candidate(nums = [1, 3, 1, 1, 2]) == 1\n assert candidate(nums = [3, 2, 1]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 6\n assert candidate(nums = [1, 2, 2, 2, 5, 0]) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 2]) == 0\n assert candidate(nums = [1, 3, 2, 2, 1, 1]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 160\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 74\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 36\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 292\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 37\n assert candidate(nums = [1000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000]) == 34\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 463\n assert candidate(nums = [10000, 10000, 10000, 10000, 0, 10000, 10000, 10000, 10000]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 184\n assert candidate(nums = [10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 4\n assert candidate(nums = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 28\n assert candidate(nums = [1, 3, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 163\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 171\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 320\n assert candidate(nums = [1, 3, 2, 4, 2, 3, 4, 2, 5, 1]) == 9\n assert candidate(nums = [9, 3, 5, 7, 3, 5, 7, 3, 5, 7, 3, 5, 7, 3, 5, 7, 3, 5, 7, 3]) == 26\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 33\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 108\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 33\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 33\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 110\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 24\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 16\n assert candidate(nums = [100, 50, 50, 25, 25, 25, 25, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 53\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 71\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 406\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 33\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 8\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 184\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 16\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 171\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 71\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 33\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 385\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 91\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 36\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 163\n assert candidate(nums = [1, 3, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 39\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 31\n assert candidate(nums = [5, 1, 4, 2, 2, 1]) == 1\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 75\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 75\n assert candidate(nums = [1, 10000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 31\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 17\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 154\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980]) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 70\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 16\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 21\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 161\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 70\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 19\n assert candidate(nums = [100, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 46\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 37\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 21\n", "comparison": "exact"}, "public_tests": ["[1,1,1]", "[1,2,2,2,5,0]", "[3,2,1]"], "hints": ["Create a prefix array to efficiently find the sum of subarrays.", "As we are dividing the array into three subarrays, there are two \"walls\". Iterate over the right wall positions and find where the left wall could be for each right wall position.", "Use binary search to find the left-most position and right-most position the left wall could be."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().waysToSplit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:21+00:00", "tests_total": 93, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "two-pointers", "binary-search", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def waysToSplit(self, nums: list[int]) -> int:", "container": "Solution", "callable": "waysToSplit", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1713, "task_id": "minimum-operations-to-make-a-subsequence", "difficulty": "Hard", "problem_description": "You are given an array target that consists of distinct integers and another integer array arr that can have duplicates.\n\nIn one operation, you can insert any integer at any position in arr. For example, if arr = [1,4,1,2], you can add 3 in the middle and make it [1,4,3,1,2]. Note that you can insert the integer at the very beginning or end of the array.\n\nReturn the minimum number of operations needed to make target a subsequence of arr.\n\nA subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the remaining elements' relative order. For example, [2,7,4] is a subsequence of [4,2,3,7,2,1,4] (the underlined elements), while [2,4,2] is not.\n\nExample 1:\n\nInput: target = [5,1,3], arr = [9,4,2,3,4]\nOutput: 2\nExplanation: You can add 5 and 1 in such a way that makes arr = [5,9,4,1,2,3,4], then target will be a subsequence of arr.\n\nExample 2:\n\nInput: target = [6,4,8,1,3,2], arr = [4,7,6,2,3,8,6,1]\nOutput: 3\n\nConstraints:\n\n- 1 <= target.length, arr.length <= 10^5\n- 1 <= target[i], arr[i] <= 10^9\n- target contains no duplicates.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 4, 3, 2, 1]) == 4\n assert candidate(target = [3, 1, 5, 8, 9],arr = [1, 5, 3, 8, 9]) == 1\n assert candidate(target = [1],arr = [1, 1, 1, 1]) == 0\n assert candidate(target = [6, 4, 8, 1, 3, 2],arr = [4, 7, 6, 2, 3, 8, 6, 1]) == 3\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [1, 2, 3],arr = [1, 2, 3, 1, 2, 3]) == 0\n assert candidate(target = [1, 3, 5, 7],arr = [2, 4, 6, 8]) == 4\n assert candidate(target = [1, 2, 3, 4, 5],arr = [1, 2, 3, 4, 5]) == 0\n assert candidate(target = [1, 3, 5, 7, 9],arr = [2, 4, 6, 8, 10]) == 5\n assert candidate(target = [1, 2, 3],arr = [4, 5, 6]) == 3\n assert candidate(target = [10, 20, 30],arr = [10, 15, 20, 25, 30]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 4\n assert candidate(target = [1],arr = [1]) == 0\n assert candidate(target = [10, 20, 30, 40],arr = [10, 20, 5, 30, 40]) == 0\n assert candidate(target = [100, 200, 300],arr = [1, 2, 3, 100, 200, 300]) == 0\n assert candidate(target = [1, 2, 3],arr = [3, 2, 1]) == 2\n assert candidate(target = [5, 1, 3],arr = [9, 4, 2, 3, 4]) == 2\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [100, 200, 300, 400, 500],arr = [100, 500, 200, 400, 300, 100, 500, 200, 400, 300]) == 1\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 12\n assert candidate(target = [1, 2, 3, 4, 5],arr = [2, 3, 1, 4, 5, 2, 3, 1, 4, 5, 2, 3, 1, 4, 5]) == 0\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [100, 200, 300, 400, 500],arr = [50, 150, 250, 350, 450, 550, 650, 100, 200, 300, 400, 500]) == 0\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [7, 14, 21, 28, 35],arr = [35, 28, 21, 14, 7, 35, 28, 21, 14, 7]) == 3\n assert candidate(target = [1, 2, 3, 4, 5],arr = [3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(target = [1, 3, 5, 7, 9],arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == 0\n assert candidate(target = [1, 3, 2, 4],arr = [4, 3, 2, 1, 1, 2, 3, 4]) == 1\n assert candidate(target = [7, 11, 13, 17, 19, 23, 29, 31],arr = [19, 23, 31, 7, 11, 13, 17, 29, 37, 41, 43, 47]) == 3\n assert candidate(target = [7, 11, 15, 20, 25, 30, 35, 40, 45, 50],arr = [50, 45, 40, 35, 30, 25, 20, 15, 11, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49]) == 9\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(target = [1, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41],arr = [41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 1, 43, 45, 47, 49, 51]) == 19\n assert candidate(target = [5, 3, 8, 12, 9, 11],arr = [3, 5, 8, 12, 9, 11, 14, 15, 16, 17, 18, 19]) == 1\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr = [10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996],arr = [999999998, 999999997, 999999996, 1000000000, 999999999]) == 2\n assert candidate(target = [7, 5, 3, 1],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 10, 20, 30, 40, 50]) == 5\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 2\n assert candidate(target = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],arr = [1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 10\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],arr = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 9\n assert candidate(target = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 1, 9, 7, 3, 2, 8]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 1, 3, 2, 4]) == 2\n assert candidate(target = [5, 3, 8, 6, 2, 7, 4, 1],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 1\n assert candidate(target = [1, 10, 100, 1000, 10000, 100000],arr = [10, 100, 1000, 10000, 100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(target = [1, 5, 9, 13, 17, 21],arr = [21, 17, 13, 9, 5, 1, 14, 10, 6, 2, 18, 12, 8, 4]) == 5\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [10, 90, 20, 80, 30, 70, 40, 60, 50, 100]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(target = [5, 1, 4, 2, 3],arr = [1, 5, 4, 2, 3, 1, 5, 4, 2, 3, 1, 5, 4, 2, 3, 1, 5, 4, 2, 3]) == 0\n assert candidate(target = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 0\n assert candidate(target = [10, 20, 30, 40, 50, 60],arr = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 0\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],arr = [1000000000, 999999998, 999999996, 999999994, 999999992, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(target = [1, 10, 100, 1000, 10000],arr = [1, 1, 1, 1, 10, 10, 10, 10, 100, 100, 100, 100, 1000, 1000, 1000, 1000, 10000, 10000, 10000, 10000]) == 0\n assert candidate(target = [1, 5, 10, 15, 20],arr = [1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 10, 10, 10, 15, 15, 20]) == 0\n assert candidate(target = [100, 200, 300, 400, 500],arr = [500, 400, 300, 200, 100, 150, 250, 350, 450, 550]) == 4\n assert candidate(target = [100, 200, 300, 400, 500],arr = [100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 300, 300, 300, 400, 500]) == 0\n assert candidate(target = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]) == 0\n assert candidate(target = [1, 5, 3, 4, 2],arr = [2, 3, 1, 4, 5, 1, 2, 3, 4, 5]) == 1\n assert candidate(target = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],arr = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 40, 35, 30, 25, 20, 15, 10, 5, 2, 1]) == 1\n assert candidate(target = [7, 5, 3, 1],arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 3\n assert candidate(target = [1, 3, 5, 7, 9],arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(target = [1, 4, 7, 10, 13, 16, 19],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 0\n assert candidate(target = [1, 2, 3, 4, 5],arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 0\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],arr = [59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 0\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr = [100, 300, 500, 700, 200, 400, 600, 800, 100, 300, 500, 700]) == 5\n assert candidate(target = [5, 1, 2, 6, 3, 7, 4, 8, 9],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(target = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],arr = [3, 5, 1, 6, 2, 9, 4, 1, 5, 3, 5]) == 7\n assert candidate(target = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 1, 2, 3, 4, 5]) == 0\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 8\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [10, 20, 30, 40, 50],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 0\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],arr = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 9\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 10\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(target = [23, 1, 7, 11, 2, 14, 6],arr = [7, 14, 4, 14, 13, 2, 6, 1, 23, 13]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(target = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],arr = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 2, 91, 87, 85, 81, 77, 75, 74, 72, 69, 65, 64, 62, 58, 57, 55, 52, 50, 49, 48, 46, 45, 44, 42, 40, 39, 38, 36, 35, 34, 33, 32, 30, 28, 27, 26, 25, 24, 22, 21, 20, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(target = [5, 3, 8, 12, 7],arr = [12, 8, 3, 7, 5, 12, 8, 3, 7, 5]) == 2\n assert candidate(target = [2, 1, 4, 3, 6, 5, 8, 7],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],arr = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 24\n assert candidate(target = [5, 1, 3, 2, 4, 6],arr = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == 1\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900],arr = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 9\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr = [500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 1, 4, 2, 3, 1, 5, 2, 4, 3, 1, 5, 2, 4, 3]) == 0\n assert candidate(target = [100, 200, 300, 400, 500],arr = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 200, 300, 400, 500]) == 0\n assert candidate(target = [1, 2, 3, 4, 5],arr = [3, 1, 2, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 9\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],arr = [5, 6, 10, 11, 15, 16, 20, 21, 25, 26, 30, 31, 35, 36, 40, 41, 45, 46, 50, 51]) == 0\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],arr = [5, 15, 25, 35, 45, 55, 65, 10, 20, 30, 40, 50]) == 4\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 1, 4, 2, 3, 5, 1, 4, 2, 3, 5, 1, 4, 2, 3, 5, 1, 4, 2, 3]) == 0\n assert candidate(target = [10, 20, 30, 40, 50],arr = [10, 25, 30, 35, 50, 40]) == 2\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14]) == 7\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 8, 6, 4, 2, 1, 3, 5, 7, 9]) == 5\n assert candidate(target = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],arr = [27, 24, 21, 18, 15, 12, 9, 6, 3, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3]) == 8\n assert candidate(target = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],arr = [1, 9, 17, 25, 33, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 5, 13, 21, 29, 37]) == 4\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 110, 120]) == 9\n", "comparison": "exact"}, "public_tests": ["[5,1,3]\n[9,4,2,3,4]", "[6,4,8,1,3,2]\n[4,7,6,2,3,8,6,1]"], "hints": ["The problem can be reduced to computing Longest Common Subsequence between both arrays.", "Since one of the arrays has distinct elements, we can consider that these elements describe an arrangement of numbers, and we can replace each element in the other array with the index it appeared at in the first array.", "Then the problem is converted to finding Longest Increasing Subsequence in the second array, which can be done in O(n log n)."], "metadata": {"canonical_parameter_names": ["target", "arr"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:24+00:00", "tests_total": 111, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "hash-table", "binary-search", "greedy", "longest-increasing-subsequence"]}, "language": "python", "interface": {"raw_signature": "def minOperations(self, target: list[int], arr: list[int]) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "target", "type": "list[int]"}, {"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1716, "task_id": "calculate-money-in-leetcode-bank", "difficulty": "Easy", "problem_description": "Hercy wants to save money for his first car. He puts money in the Leetcode bank every day.\n\nHe starts by putting in $1 on Monday, the first day. Every day from Tuesday to Sunday, he will put in $1 more than the day before. On every subsequent Monday, he will put in $1 more than the previous Monday.\n\nGiven n, return the total amount of money he will have in the Leetcode bank at the end of the n^th day.\n\nExample 1:\n\nInput: n = 4\nOutput: 10\nExplanation: After the 4^th day, the total is 1 + 2 + 3 + 4 = 10.\n\nExample 2:\n\nInput: n = 10\nOutput: 37\nExplanation: After the 10^th day, the total is (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4) = 37. Notice that on the 2^nd Monday, Hercy only puts in $2.\n\nExample 3:\n\nInput: n = 20\nOutput: 96\nExplanation: After the 20^th day, the total is (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4 + 5 + 6 + 7 + 8) + (3 + 4 + 5 + 6 + 7 + 8) = 96.\n\nConstraints:\n\n- 1 <= n <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 30) == 165\n assert candidate(n = 4) == 10\n assert candidate(n = 20) == 96\n assert candidate(n = 1) == 1\n assert candidate(n = 1000) == 74926\n assert candidate(n = 7) == 28\n assert candidate(n = 10) == 37\n assert candidate(n = 29) == 159\n assert candidate(n = 63) == 504\n assert candidate(n = 210) == 3885\n assert candidate(n = 49) == 343\n assert candidate(n = 125) == 1551\n assert candidate(n = 21) == 105\n assert candidate(n = 70) == 595\n assert candidate(n = 100) == 1060\n assert candidate(n = 50) == 351\n assert candidate(n = 300) == 7476\n assert candidate(n = 28) == 154\n assert candidate(n = 60) == 462\n assert candidate(n = 56) == 420\n assert candidate(n = 40) == 250\n assert candidate(n = 600) == 27810\n assert candidate(n = 99) == 1044\n assert candidate(n = 98) == 1029\n assert candidate(n = 2) == 3\n assert candidate(n = 365) == 10791\n assert candidate(n = 80) == 732\n assert candidate(n = 700) == 37450\n assert candidate(n = 8) == 30\n assert candidate(n = 250) == 5335\n assert candidate(n = 777) == 45843\n assert candidate(n = 999) == 74778\n assert candidate(n = 22) == 109\n assert candidate(n = 35) == 210\n assert candidate(n = 140) == 1890\n assert candidate(n = 91) == 910\n assert candidate(n = 150) == 2127\n assert candidate(n = 15) == 66\n assert candidate(n = 180) == 2940\n assert candidate(n = 899) == 60870\n assert candidate(n = 85) == 811\n assert candidate(n = 200) == 3552\n assert candidate(n = 14) == 63\n assert candidate(n = 400) == 12826\n assert candidate(n = 120) == 1446\n assert candidate(n = 500) == 19602\n assert candidate(n = 52) == 370\n assert candidate(n = 90) == 891\n assert candidate(n = 25) == 127\n assert candidate(n = 84) == 798\n", "comparison": "exact"}, "public_tests": ["4", "10", "20"], "hints": ["Simulate the process by keeping track of how much money Hercy is putting in and which day of the week it is, and use this information to deduce how much money Hercy will put in the next day."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().totalMoney", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:29+00:00", "tests_total": 50, "tests_dropped": 0, "flags": [], "topic_tags": ["math"]}, "language": "python", "interface": {"raw_signature": "def totalMoney(self, n: int) -> int:", "container": "Solution", "callable": "totalMoney", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1717, "task_id": "maximum-score-from-removing-substrings", "difficulty": "Medium", "problem_description": "You are given a string s and two integers x and y. You can perform two types of operations any number of times.\n\n- Remove substring \"ab\" and gain x points.\n - For example, when removing \"ab\" from \"cabxbae\" it becomes \"cxbae\".\n- Remove substring \"ba\" and gain y points.\n - For example, when removing \"ba\" from \"cabxbae\" it becomes \"cabxe\".\n\nReturn the maximum points you can gain after applying the above operations on s.\n\nExample 1:\n\nInput: s = \"cdbcbbaaabab\", x = 4, y = 5\nOutput: 19\nExplanation:\n- Remove the \"ba\" underlined in \"cdbcbbaaabab\". Now, s = \"cdbcbbaaab\" and 5 points are added to the score.\n- Remove the \"ab\" underlined in \"cdbcbbaaab\". Now, s = \"cdbcbbaa\" and 4 points are added to the score.\n- Remove the \"ba\" underlined in \"cdbcbbaa\". Now, s = \"cdbcba\" and 5 points are added to the score.\n- Remove the \"ba\" underlined in \"cdbcba\". Now, s = \"cdbc\" and 5 points are added to the score.\nTotal score = 5 + 4 + 5 + 5 = 19.\n\nExample 2:\n\nInput: s = \"aabbaaxybbaabb\", x = 5, y = 4\nOutput: 20\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- 1 <= x, y <= 10^4\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"ababababababababababababababababababababab\",x = 1,y = 1) == 21\n assert candidate(s = \"abbaabba\",x = 7,y = 8) == 31\n assert candidate(s = \"abababab\",x = 10,y = 10) == 40\n assert candidate(s = \"ababab\",x = 10,y = 10) == 30\n assert candidate(s = \"babaabab\",x = 3,y = 2) == 11\n assert candidate(s = \"aabbcc\",x = 2,y = 2) == 4\n assert candidate(s = \"babaabab\",x = 10,y = 5) == 35\n assert candidate(s = \"abcde\",x = 1,y = 2) == 1\n assert candidate(s = \"baabaa\",x = 3,y = 2) == 5\n assert candidate(s = \"aaaaabbbbb\",x = 7,y = 8) == 35\n assert candidate(s = \"ba\",x = 1,y = 1) == 1\n assert candidate(s = \"aabbcc\",x = 1,y = 1) == 2\n assert candidate(s = \"ab\",x = 1,y = 1) == 1\n assert candidate(s = \"abbaabba\",x = 7,y = 3) == 24\n assert candidate(s = \"abcabcabcabc\",x = 2,y = 3) == 8\n assert candidate(s = \"abababab\",x = 1,y = 1) == 4\n assert candidate(s = \"aabbaaxybbaabb\",x = 5,y = 4) == 20\n assert candidate(s = \"ababababab\",x = 1,y = 1) == 5\n assert candidate(s = \"abcde\",x = 10,y = 20) == 10\n assert candidate(s = \"babaabab\",x = 2,y = 3) == 11\n assert candidate(s = \"cdbcbbaaabab\",x = 4,y = 5) == 19\n assert candidate(s = \"abcde\",x = 100,y = 200) == 100\n assert candidate(s = \"baabbaabba\",x = 500,y = 500) == 2500\n assert candidate(s = \"bbbbbbaaaa\",x = 8,y = 7) == 28\n assert candidate(s = \"ababababab\",x = 1000,y = 1000) == 5000\n assert candidate(s = \"babaab\",x = 10,y = 5) == 25\n assert candidate(s = \"aaaabbbbbaaaaabbbb\",x = 10,y = 15) == 115\n assert candidate(s = \"babababababababababababab\",x = 7,y = 3) == 84\n assert candidate(s = \"abababababababab\",x = 10000,y = 10000) == 80000\n assert candidate(s = \"babbbabbbabbbabbbabbbabb\",x = 15,y = 25) == 150\n assert candidate(s = \"ababbaabababababab\",x = 6,y = 7) == 62\n assert candidate(s = \"aabbaabbaabbba\",x = 1000,y = 1000) == 7000\n assert candidate(s = \"bbabaabababbabaabababbba\",x = 100,y = 50) == 1050\n assert candidate(s = \"babababababa\",x = 10,y = 15) == 90\n assert candidate(s = \"abbaabbaabba\",x = 3,y = 2) == 17\n assert candidate(s = \"bbbbbaaaabbbbbaaaabbbb\",x = 4,y = 6) == 48\n assert candidate(s = \"bbaabbbaaabbba\",x = 10,y = 5) == 55\n assert candidate(s = \"babababababa\",x = 7,y = 7) == 42\n assert candidate(s = \"baabababababab\",x = 5,y = 5) == 35\n assert candidate(s = \"bababababababababababa\",x = 20,y = 20) == 220\n assert candidate(s = \"bababababababababababababababababababababa\",x = 2,y = 3) == 63\n assert candidate(s = \"babababaabababababababab\",x = 1000,y = 1000) == 12000\n assert candidate(s = \"aaaabbbbbaaaaabbbb\",x = 6,y = 9) == 69\n assert candidate(s = \"babaabababab\",x = 1000,y = 500) == 5500\n assert candidate(s = \"abbbabbaaa\",x = 10,y = 5) == 35\n assert candidate(s = \"ababababababababababababababababababababababababa\",x = 1,y = 10000) == 240000\n assert candidate(s = \"aaaaaabbaaabbaaa\",x = 5,y = 5) == 20\n assert candidate(s = \"babbbbabbbbabbbbabbb\",x = 12,y = 15) == 60\n assert candidate(s = \"abababababbababbaabab\",x = 4,y = 4) == 40\n assert candidate(s = \"ababbbbaababba\",x = 100,y = 200) == 1100\n assert candidate(s = \"bbabababababababbaa\",x = 8,y = 6) == 68\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbb\",x = 100,y = 100) == 1000\n assert candidate(s = \"abababababababababababababababab\",x = 10000,y = 1) == 160000\n assert candidate(s = \"abbaabbaabba\",x = 10,y = 20) == 110\n assert candidate(s = \"zazbzabzbabzbabz\",x = 5,y = 6) == 17\n assert candidate(s = \"bababbbabababa\",x = 1,y = 10000) == 60000\n assert candidate(s = \"abababababababababababababababababab\",x = 2,y = 1) == 36\n assert candidate(s = \"aabbbaaabbbaaabbbaaabbbaa\",x = 15,y = 5) == 170\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaa\",x = 1000,y = 500) == 12000\n assert candidate(s = \"bbaabbabababbaabba\",x = 10,y = 5) == 75\n assert candidate(s = \"ababababababababababababababababababababababababababababa\",x = 10000,y = 10000) == 280000\n assert candidate(s = \"xyzababxyzbaaxyzbaxyz\",x = 15,y = 10) == 50\n assert candidate(s = \"zababxyzab\",x = 4,y = 5) == 13\n assert candidate(s = \"abbbabbbabbbabbbabbbabbb\",x = 20,y = 10) == 120\n assert candidate(s = \"aabbbaaabbbaaabbbaab\",x = 7,y = 3) == 66\n assert candidate(s = \"abababababababababababababababab\",x = 10,y = 10) == 160\n assert candidate(s = \"babababababababa\",x = 1,y = 2) == 16\n assert candidate(s = \"ababababababababababababab\",x = 1,y = 1) == 13\n assert candidate(s = \"abababababababababababababababab\",x = 90,y = 100) == 1590\n assert candidate(s = \"abbbbaabbbbaabbbbaab\",x = 200,y = 300) == 2000\n assert candidate(s = \"abababababababababababababababababababababababababababab\",x = 1,y = 1) == 28\n assert candidate(s = \"abababababababababababababababab\",x = 50,y = 50) == 800\n assert candidate(s = \"babaabababab\",x = 10,y = 15) == 85\n assert candidate(s = \"abbbabababba\",x = 500,y = 400) == 2400\n assert candidate(s = \"babaababbaab\",x = 10,y = 5) == 55\n assert candidate(s = \"xyxzyzyzxzyz\",x = 100,y = 200) == 0\n assert candidate(s = \"ababbaababba\",x = 3,y = 2) == 17\n assert candidate(s = \"ababababababababababababababababab\",x = 1,y = 1) == 17\n assert candidate(s = \"xyxyxyxyxy\",x = 3,y = 3) == 0\n assert candidate(s = \"ababababababababababababababababababababababababababababa\",x = 2,y = 3) == 84\n assert candidate(s = \"babababababababababababababababa\",x = 1000,y = 500) == 15500\n assert candidate(s = \"abbaabbaabbaabbaabbaabbaabbaabba\",x = 25,y = 30) == 475\n assert candidate(s = \"ababababababababababab\",x = 5,y = 5) == 55\n assert candidate(s = \"abababababababababababababababab\",x = 1,y = 100) == 1501\n assert candidate(s = \"abaabbaabbabab\",x = 10000,y = 1) == 70000\n assert candidate(s = \"babbababbababbababbababb\",x = 5,y = 4) == 45\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",x = 1000,y = 2000) == 0\n assert candidate(s = \"bababababababababa\",x = 1,y = 2) == 18\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbbaaaaaaaaaaabbbbbbbbbbbbb\",x = 15,y = 25) == 425\n assert candidate(s = \"bbaabbababababababababab\",x = 1,y = 9999) == 109989\n assert candidate(s = \"abbaabbaabbaabba\",x = 10,y = 10) == 80\n assert candidate(s = \"aabbaaabaabbaaabaabbaabb\",x = 1,y = 1) == 10\n assert candidate(s = \"bbbababbaabbababbaabbbaabababbbabababababababa\",x = 8000,y = 9000) == 180000\n assert candidate(s = \"babababababababababababababababa\",x = 7,y = 7) == 112\n assert candidate(s = \"babababababababababababababababababababababababababababa\",x = 1000,y = 1000) == 28000\n assert candidate(s = \"abababababababababababababababab\",x = 10,y = 9) == 160\n assert candidate(s = \"bbababababababababababababababab\",x = 100,y = 90) == 1500\n assert candidate(s = \"abbaabbaabbaabbaabbaabbaabbaabba\",x = 6,y = 4) == 94\n assert candidate(s = \"ababbbababababba\",x = 20,y = 15) == 135\n assert candidate(s = \"babbbbabbbbabbaa\",x = 8,y = 6) == 36\n assert candidate(s = \"abbaabbaabbaabbaabba\",x = 8,y = 3) == 75\n assert candidate(s = \"aabababababa\",x = 20,y = 15) == 100\n assert candidate(s = \"ababbaababbaababba\",x = 7,y = 9) == 79\n assert candidate(s = \"ababbbabababbaababababab\",x = 20,y = 10) == 210\n assert candidate(s = \"ababbbbaabab\",x = 5,y = 10) == 45\n assert candidate(s = \"bbbbbaaaaabbbbbbaaaaabbbbb\",x = 1000,y = 500) == 10000\n assert candidate(s = \"baaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbb\",x = 500,y = 1000) == 12500\n assert candidate(s = \"babababababababa\",x = 1,y = 100) == 800\n assert candidate(s = \"bbaaabaaaaba\",x = 20,y = 10) == 60\n assert candidate(s = \"ababababababababababababab\",x = 7,y = 8) == 103\n assert candidate(s = \"aabbbaababaababbbbababba\",x = 3,y = 2) == 32\n assert candidate(s = \"baaababababababaabaababb\",x = 10,y = 20) == 200\n assert candidate(s = \"babababababababaabab\",x = 3,y = 2) == 29\n assert candidate(s = \"bababababababababababababababa\",x = 1,y = 2) == 30\n assert candidate(s = \"abbbbbbbbbaaaaaaaa\",x = 20,y = 18) == 164\n assert candidate(s = \"baabbaabbaabbaabbaabbaabbaabbaab\",x = 30,y = 25) == 475\n assert candidate(s = \"abcabcabcabc\",x = 5,y = 5) == 20\n assert candidate(s = \"ababababababababab\",x = 100,y = 1) == 900\n assert candidate(s = \"baabbaabbaabbaabbaab\",x = 4,y = 3) == 39\n assert candidate(s = \"bbaaabbaaabbaa\",x = 1,y = 10000) == 60000\n assert candidate(s = \"bbbbbaaaaabbbbbaaaaabbbbbaaaaa\",x = 100,y = 1) == 1005\n assert candidate(s = \"abababababababababababa\",x = 50,y = 25) == 550\n assert candidate(s = \"aababababaab\",x = 100,y = 100) == 500\n assert candidate(s = \"babababababa\",x = 2000,y = 2000) == 12000\n assert candidate(s = \"babbbabbaabababbababbaabbbbaabab\",x = 20,y = 15) == 255\n assert candidate(s = \"babababababaab\",x = 8,y = 7) == 55\n assert candidate(s = \"babababababababa\",x = 100,y = 90) == 790\n assert candidate(s = \"aabbbaabbaabbbaabbaabbba\",x = 2,y = 3) == 31\n assert candidate(s = \"babababababababababababababababababa\",x = 1,y = 2) == 36\n assert candidate(s = \"aabbaabbccddeeffgg\",x = 10,y = 20) == 60\n assert candidate(s = \"aaaabbbbbaaaaabbb\",x = 5,y = 3) == 38\n assert candidate(s = \"ababbaababbaab\",x = 6,y = 4) == 40\n assert candidate(s = \"babaababababba\",x = 3,y = 2) == 20\n assert candidate(s = \"abababababababababababab\",x = 9999,y = 1) == 119988\n assert candidate(s = \"baabaabaabaabaabaabaabaabaabaabaab\",x = 5000,y = 4000) == 59000\n assert candidate(s = \"abababababababababab\",x = 1,y = 2) == 19\n assert candidate(s = \"bababababa\",x = 2,y = 3) == 15\n assert candidate(s = \"abbaabbaabbaabbaabbaabba\",x = 10,y = 15) == 175\n assert candidate(s = \"babababababababababababababababababababababababa\",x = 5000,y = 4000) == 119000\n assert candidate(s = \"bbaabaaaabbbbbaaaab\",x = 3,y = 2) == 25\n assert candidate(s = \"ababababababababababababababababababababababababa\",x = 2000,y = 2000) == 48000\n assert candidate(s = \"baababababababababababababababab\",x = 4,y = 4) == 64\n assert candidate(s = \"babababababababababababababababababababababababababababa\",x = 3,y = 2) == 83\n assert candidate(s = \"ababbbabaabbbbab\",x = 7,y = 3) == 42\n assert candidate(s = \"abbaabbaabbaabbaabbaabbaabbaabba\",x = 1000,y = 1000) == 16000\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",x = 1000,y = 2000) == 2000\n assert candidate(s = \"abbbabaababaabbaaaabbbbaaabbabab\",x = 5,y = 6) == 93\n assert candidate(s = \"abababababababababababababababab\",x = 1000,y = 1000) == 16000\n assert candidate(s = \"babababababababababababa\",x = 5,y = 5) == 60\n assert candidate(s = \"ababaababbabbaab\",x = 3,y = 4) == 30\n assert candidate(s = \"babababababababababababababababababababababababababababa\",x = 8,y = 5) == 221\n", "comparison": "exact"}, "public_tests": ["\"cdbcbbaaabab\"\n4\n5", "\"aabbaaxybbaabb\"\n5\n4"], "hints": ["Note that it is always more optimal to take one type of substring before another", "You can use a stack to handle erasures"], "metadata": {"canonical_parameter_names": ["s", "x", "y"], "leetcode_dataset_entry_point": "Solution().maximumGain", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:31+00:00", "tests_total": 154, "tests_dropped": 3, "flags": [], "topic_tags": ["string", "stack", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maximumGain(self, s: str, x: int, y: int) -> int:", "container": "Solution", "callable": "maximumGain", "parameters": [{"name": "s", "type": "str"}, {"name": "x", "type": "int"}, {"name": "y", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1718, "task_id": "construct-the-lexicographically-largest-valid-sequence", "difficulty": "Medium", "problem_description": "Given an integer n, find a sequence with elements in the range [1, n] that satisfies all of the following:\n\n- The integer 1 occurs once in the sequence.\n- Each integer between 2 and n occurs twice in the sequence.\n- For every integer i between 2 and n, the distance between the two occurrences of i is exactly i.\n\nThe distance between two numbers on the sequence, a[i] and a[j], is the absolute difference of their indices, |j - i|.\n\nReturn the lexicographically largest sequence. It is guaranteed that under the given constraints, there is always a solution.\n\nA sequence a is lexicographically larger than a sequence b (of the same length) if in the first position where a and b differ, sequence a has a number greater than the corresponding number in b. For example, [0,1,9,0] is lexicographically larger than [0,1,5,6] because the first position they differ is at the third number, and 9 is greater than 5.\n\nExample 1:\n\nInput: n = 3\nOutput: [3,1,2,3,2]\nExplanation: [2,3,2,1,3] is also a valid sequence, but [3,1,2,3,2] is the lexicographically largest valid sequence.\n\nExample 2:\n\nInput: n = 5\nOutput: [5,3,1,4,3,5,2,4,2]\n\nConstraints:\n\n- 1 <= n <= 20\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == [3, 1, 2, 3, 2]\n assert candidate(n = 15) == [15, 13, 14, 10, 8, 12, 5, 3, 11, 9, 3, 5, 8, 10, 13, 15, 14, 12, 9, 11, 7, 4, 6, 1, 2, 4, 2, 7, 6]\n assert candidate(n = 4) == [4, 2, 3, 2, 4, 3, 1]\n assert candidate(n = 20) == [20, 18, 19, 15, 13, 17, 10, 16, 7, 5, 3, 14, 12, 3, 5, 7, 10, 13, 15, 18, 20, 19, 17, 16, 12, 14, 11, 9, 4, 6, 8, 2, 4, 2, 1, 6, 9, 11, 8]\n assert candidate(n = 2) == [2, 1, 2]\n assert candidate(n = 1) == [1]\n assert candidate(n = 10) == [10, 8, 6, 9, 3, 1, 7, 3, 6, 8, 10, 5, 9, 7, 4, 2, 5, 2, 4]\n assert candidate(n = 5) == [5, 3, 1, 4, 3, 5, 2, 4, 2]\n assert candidate(n = 8) == [8, 6, 4, 2, 7, 2, 4, 6, 8, 5, 3, 7, 1, 3, 5]\n assert candidate(n = 11) == [11, 9, 10, 6, 4, 1, 7, 8, 4, 6, 9, 11, 10, 7, 5, 8, 2, 3, 2, 5, 3]\n assert candidate(n = 12) == [12, 10, 11, 7, 5, 3, 8, 9, 3, 5, 7, 10, 12, 11, 8, 6, 9, 2, 4, 2, 1, 6, 4]\n assert candidate(n = 16) == [16, 14, 15, 11, 9, 13, 6, 4, 12, 10, 1, 4, 6, 9, 11, 14, 16, 15, 13, 10, 12, 8, 5, 7, 2, 3, 2, 5, 3, 8, 7]\n assert candidate(n = 14) == [14, 12, 13, 9, 7, 11, 4, 1, 10, 8, 4, 7, 9, 12, 14, 13, 11, 8, 10, 6, 3, 5, 2, 3, 2, 6, 5]\n assert candidate(n = 17) == [17, 15, 16, 12, 10, 14, 7, 5, 3, 13, 11, 3, 5, 7, 10, 12, 15, 17, 16, 14, 9, 11, 13, 8, 6, 2, 1, 2, 4, 9, 6, 8, 4]\n assert candidate(n = 18) == [18, 16, 17, 13, 11, 15, 8, 14, 4, 2, 12, 2, 4, 10, 8, 11, 13, 16, 18, 17, 15, 14, 12, 10, 9, 7, 5, 3, 6, 1, 3, 5, 7, 9, 6]\n assert candidate(n = 13) == [13, 11, 12, 8, 6, 4, 9, 10, 1, 4, 6, 8, 11, 13, 12, 9, 7, 10, 3, 5, 2, 3, 2, 7, 5]\n assert candidate(n = 6) == [6, 4, 2, 5, 2, 4, 6, 3, 5, 1, 3]\n assert candidate(n = 7) == [7, 5, 3, 6, 4, 3, 5, 7, 4, 6, 2, 1, 2]\n", "comparison": "exact"}, "public_tests": ["3", "5"], "hints": ["Heuristic algorithm may work."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().constructDistancedSequence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:33+00:00", "tests_total": 18, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "backtracking"]}, "language": "python", "interface": {"raw_signature": "def constructDistancedSequence(self, n: int) -> list[int]:", "container": "Solution", "callable": "constructDistancedSequence", "parameters": [{"name": "n", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1719, "task_id": "number-of-ways-to-reconstruct-a-tree", "difficulty": "Hard", "problem_description": "You are given an array pairs, where pairs[i] = [x_i, y_i], and:\n\n- There are no duplicates.\n- x_i < y_i\n\nLet ways be the number of rooted trees that satisfy the following conditions:\n\n- The tree consists of nodes whose values appeared in pairs.\n- A pair [x_i, y_i] exists in pairs if and only if x_i is an ancestor of y_i or y_i is an ancestor of x_i.\n- Note: the tree does not have to be a binary tree.\n\nTwo ways are considered to be different if there is at least one node that has different parents in both ways.\n\nReturn:\n\n- 0 if ways == 0\n- 1 if ways == 1\n- 2 if ways > 1\n\nA rooted tree is a tree that has a single root node, and all edges are oriented to be outgoing from the root.\n\nAn ancestor of a node is any node on the path from the root to that node (excluding the node itself). The root has no ancestors.\n\nExample 1:\n\nInput: pairs = [[1,2],[2,3]]\nOutput: 1\nExplanation: There is exactly one valid rooted tree, which is shown in the above figure.\n\nExample 2:\n\nInput: pairs = [[1,2],[2,3],[1,3]]\nOutput: 2\nExplanation: There are multiple valid rooted trees. Three of them are shown in the above figures.\n\nExample 3:\n\nInput: pairs = [[1,2],[2,3],[2,4],[1,5]]\nOutput: 0\nExplanation: There are no valid rooted trees.\n\nConstraints:\n\n- 1 <= pairs.length <= 10^5\n- 1 <= x_i< y_i <= 500\n- The elements in pairs are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [4, 5]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 5]]) == 0\n assert candidate(pairs = [[1, 3], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(pairs = [[1, 2], [3, 4]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3]]) == 1\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [3, 5]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(pairs = [[1, 3], [2, 3], [4, 5]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [1, 4]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]) == 2\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5]]) == 1\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [4, 5]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [1, 3]]) == 2\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [1, 5]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [3, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 18], [5, 19], [5, 20], [5, 21], [6, 22], [6, 23], [6, 24], [7, 25], [7, 26], [7, 27], [8, 28], [8, 29], [8, 30], [9, 31], [9, 32], [9, 33], [10, 34], [10, 35], [10, 36], [11, 37], [11, 38], [11, 39], [12, 40], [12, 41], [12, 42], [13, 43], [13, 44], [13, 45], [14, 46], [14, 47], [14, 48], [15, 49], [15, 50], [15, 51]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19], [12, 20]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16], [9, 17], [9, 18], [10, 19], [10, 20], [11, 21], [11, 22], [12, 23], [12, 24], [13, 25], [13, 26], [14, 27], [14, 28], [15, 29], [15, 30], [16, 31], [16, 32], [17, 33], [17, 34], [18, 35], [18, 36], [19, 37], [19, 38], [20, 39], [20, 40], [21, 41], [21, 42], [22, 43], [22, 44], [23, 45], [23, 46], [24, 47], [24, 48]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [4, 16], [5, 17], [5, 18], [5, 19], [5, 20], [6, 21], [6, 22], [6, 23], [6, 24], [7, 25], [7, 26]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16], [9, 17], [9, 18], [10, 19], [10, 20], [11, 21], [11, 22], [12, 23], [12, 24]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 0\n assert candidate(pairs = [[1, 12], [1, 11], [1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2]]) == 1\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [4, 14], [5, 15], [5, 16], [5, 17], [6, 18], [6, 19], [7, 20], [7, 21], [8, 22], [8, 23], [9, 24], [9, 25], [10, 26], [10, 27], [11, 28], [11, 29], [12, 30], [12, 31], [13, 32], [13, 33], [14, 34], [14, 35], [15, 36], [15, 37], [16, 38], [16, 39], [17, 40], [17, 41]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8], [6, 9], [7, 10], [7, 11]]) == 0\n assert candidate(pairs = [[1, 6], [6, 7], [6, 8], [1, 9], [9, 10], [9, 11], [1, 12], [12, 13], [12, 14]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [4, 5], [1, 6], [6, 7], [6, 8], [8, 9], [9, 10], [1, 11], [11, 12], [12, 13]]) == 0\n assert candidate(pairs = [[1, 3], [3, 5], [5, 7], [3, 6], [6, 8], [1, 2], [2, 4], [4, 9], [9, 10]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27], [13, 28], [13, 29], [14, 30], [14, 31], [15, 32], [15, 33]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20], [16, 21], [17, 22], [18, 23], [19, 24], [20, 25], [21, 26], [22, 27], [23, 28], [24, 29], [25, 30], [26, 31], [27, 32], [28, 33], [29, 34], [30, 35], [31, 36], [32, 37], [33, 38], [34, 39], [35, 40], [36, 41], [37, 42], [38, 43], [39, 44], [40, 45], [41, 46], [42, 47], [43, 48], [44, 49], [45, 50]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16], [9, 17], [9, 18], [10, 19], [11, 20], [11, 21], [12, 22], [12, 23], [13, 24], [13, 25], [14, 26], [14, 27], [15, 28], [15, 29], [16, 30], [16, 31], [17, 32], [17, 33], [18, 34], [18, 35], [19, 36], [19, 37], [20, 38], [20, 39], [21, 40], [21, 41], [22, 42], [22, 43], [23, 44], [23, 45]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [7, 22], [8, 23], [8, 24], [8, 25], [9, 26], [9, 27], [9, 28], [10, 29], [10, 30], [10, 31]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [4, 16], [5, 17], [5, 18], [5, 19], [5, 20], [6, 21], [6, 22], [6, 23], [6, 24], [7, 25], [7, 26], [7, 27], [7, 28], [8, 29], [8, 30], [8, 31], [8, 32]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [8, 17]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [3, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 18], [5, 19], [5, 20], [5, 21]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35], [18, 36], [18, 37], [19, 38], [19, 39], [20, 40], [20, 41], [21, 42], [21, 43]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25], [22, 26], [23, 27], [24, 28], [25, 29], [26, 30], [27, 31], [28, 32], [29, 33], [30, 34]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [1, 5], [5, 6], [6, 7], [1, 8], [8, 9], [9, 10], [10, 11]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [3, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 18], [5, 19], [5, 20], [5, 21], [6, 22], [6, 23], [6, 24], [6, 25], [7, 26], [7, 27], [7, 28], [7, 29], [8, 30], [8, 31], [8, 32], [8, 33], [9, 34], [9, 35], [9, 36], [9, 37], [10, 38], [10, 39], [10, 40], [10, 41]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [10, 19], [11, 20], [12, 21], [13, 22], [14, 23], [15, 24], [16, 25], [17, 26], [18, 27], [19, 28], [20, 29], [21, 30], [22, 31], [23, 32], [24, 33], [25, 34], [26, 35], [27, 36], [28, 37], [29, 38], [30, 39], [31, 40]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30], [15, 31], [15, 32], [16, 33], [16, 34], [17, 35], [17, 36], [18, 37], [18, 38], [19, 39], [19, 40], [20, 41], [20, 42], [21, 43], [21, 44], [22, 45], [22, 46], [23, 47], [23, 48], [24, 49], [24, 50]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [7, 22], [8, 23], [8, 24]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20], [16, 21], [17, 22], [18, 23], [19, 24], [20, 25]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8], [6, 9], [7, 10], [7, 11], [10, 12], [11, 13]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [14, 27], [15, 28], [16, 29], [17, 30], [18, 31], [19, 32], [20, 33]]) == 0\n assert candidate(pairs = [[1, 3], [1, 2], [3, 5], [3, 6], [3, 7], [2, 4], [2, 8], [2, 9], [4, 10], [4, 11], [8, 12], [8, 13], [9, 14], [9, 15], [14, 16], [15, 17]]) == 0\n assert candidate(pairs = [[1, 6], [1, 7], [1, 8], [2, 6], [3, 7], [4, 8], [5, 8], [5, 6], [5, 7]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [5, 13]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == 0\n assert candidate(pairs = [[1, 6], [6, 7], [1, 2], [1, 3], [1, 4], [1, 5], [5, 8], [8, 9]]) == 0\n assert candidate(pairs = [[1, 3], [3, 5], [5, 7], [7, 9], [1, 4], [4, 6], [6, 8], [8, 10], [1, 11], [11, 12], [12, 13], [13, 14]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35], [18, 36], [18, 37], [19, 38], [19, 39], [20, 40], [20, 41], [21, 42], [21, 43], [22, 44], [22, 45], [23, 46], [23, 47], [24, 48], [24, 49], [25, 50], [25, 51]]) == 0\n assert candidate(pairs = [[1, 15], [1, 14], [1, 13], [1, 12], [1, 11], [1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2]]) == 1\n", "comparison": "exact"}, "public_tests": ["[[1,2],[2,3]]", "[[1,2],[2,3],[1,3]]", "[[1,2],[2,3],[2,4],[1,5]]"], "hints": ["Think inductively. The first step is to get the root. Obviously, the root should be in pairs with all the nodes. If there isn't exactly one such node, then there are 0 ways.", "The number of pairs involving a node must be less than or equal to that number of its parent.", "Actually, if it's equal, then there is not exactly 1 way, because they can be swapped.", "Recursively, given a set of nodes, get the node with the most pairs, then this must be a root and have no parents in the current set of nodes."], "metadata": {"canonical_parameter_names": ["pairs"], "leetcode_dataset_entry_point": "Solution().checkWays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:36+00:00", "tests_total": 80, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "hash-table", "tree", "graph", "simulation"]}, "language": "python", "interface": {"raw_signature": "def checkWays(self, pairs: list[list[int]]) -> int:", "container": "Solution", "callable": "checkWays", "parameters": [{"name": "pairs", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1720, "task_id": "decode-xored-array", "difficulty": "Easy", "problem_description": "There is a hidden integer array arr that consists of n non-negative integers.\n\nIt was encoded into another integer array encoded of length n - 1, such that encoded[i] = arr[i] XOR arr[i + 1]. For example, if arr = [1,0,2,1], then encoded = [1,2,3].\n\nYou are given the encoded array. You are also given an integer first, that is the first element of arr, i.e. arr[0].\n\nReturn the original array arr. It can be proved that the answer exists and is unique.\n\nExample 1:\n\nInput: encoded = [1,2,3], first = 1\nOutput: [1,0,2,1]\nExplanation: If arr = [1,0,2,1], then first = 1 and encoded = [1 XOR 0, 0 XOR 2, 2 XOR 1] = [1,2,3]\n\nExample 2:\n\nInput: encoded = [6,2,7,3], first = 4\nOutput: [4,2,0,7,4]\n\nConstraints:\n\n- 2 <= n <= 10^4\n- encoded.length == n - 1\n- 0 <= encoded[i] <= 10^5\n- 0 <= first <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(encoded = [10, 5, 15],first = 0) == [0, 10, 15, 0]\n assert candidate(encoded = [0, 0, 0],first = 7) == [7, 7, 7, 7]\n assert candidate(encoded = [9, 5, 6],first = 0) == [0, 9, 12, 10]\n assert candidate(encoded = [10, 5, 15, 20],first = 0) == [0, 10, 15, 0, 20]\n assert candidate(encoded = [3, 1, 2],first = 0) == [0, 3, 2, 0]\n assert candidate(encoded = [12345, 67890, 13579, 24680],first = 98765) == [98765, 111092, 47302, 36301, 60837]\n assert candidate(encoded = [1, 2, 3],first = 1) == [1, 0, 2, 1]\n assert candidate(encoded = [6, 2, 7, 3],first = 4) == [4, 2, 0, 7, 4]\n assert candidate(encoded = [0, 0, 0, 0],first = 5) == [5, 5, 5, 5, 5]\n assert candidate(encoded = [3, 1],first = 5) == [5, 6, 7]\n assert candidate(encoded = [10, 5, 15],first = 3) == [3, 9, 12, 3]\n assert candidate(encoded = [0, 0, 0],first = 5) == [5, 5, 5, 5]\n assert candidate(encoded = [3, 1],first = 2) == [2, 1, 0]\n assert candidate(encoded = [7, 9, 14, 2, 6],first = 8) == [8, 15, 6, 8, 10, 12]\n assert candidate(encoded = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],first = 0) == [0, 65535, 32768, 49151, 40960, 45055, 43008, 44031, 43520, 43775, 43648, 43711, 43680, 43695, 43688, 43691, 43690]\n assert candidate(encoded = [255, 128, 64, 32, 16, 8, 4, 2, 1],first = 255) == [255, 0, 128, 192, 224, 240, 248, 252, 254, 255]\n assert candidate(encoded = [255, 0, 255, 0, 255],first = 1) == [1, 254, 254, 1, 1, 254]\n assert candidate(encoded = [88, 99, 22, 15, 77, 44, 55, 11, 33, 66],first = 3) == [3, 91, 56, 46, 33, 108, 64, 119, 124, 93, 31]\n assert candidate(encoded = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],first = 1) == [1, 0, 2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046, 4094]\n assert candidate(encoded = [5, 5, 5, 5, 5],first = 10) == [10, 15, 10, 15, 10, 15]\n assert candidate(encoded = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],first = 1) == [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]\n assert candidate(encoded = [255, 128, 64, 32, 16, 8, 4, 2, 1],first = 0) == [0, 255, 127, 63, 31, 15, 7, 3, 1, 0]\n assert candidate(encoded = [8, 12, 5, 10, 15],first = 7) == [7, 15, 3, 6, 12, 3]\n assert candidate(encoded = [99, 142, 55, 231, 78, 102, 184, 33, 201, 127],first = 23) == [23, 116, 250, 205, 42, 100, 2, 186, 155, 82, 45]\n assert candidate(encoded = [15, 9, 12, 5, 6, 3, 14, 10],first = 8) == [8, 7, 14, 2, 7, 1, 2, 12, 6]\n assert candidate(encoded = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],first = 1) == [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]\n assert candidate(encoded = [123, 246, 369, 492, 615, 738, 861, 984],first = 100) == [100, 31, 233, 408, 116, 531, 241, 940, 116]\n assert candidate(encoded = [7, 9, 3, 10, 8],first = 2) == [2, 5, 12, 15, 5, 13]\n assert candidate(encoded = [12, 4, 6, 5, 11, 3],first = 8) == [8, 4, 0, 6, 3, 8, 11]\n assert candidate(encoded = [13, 26, 52, 104, 208, 416, 832, 1664, 3328, 6656],first = 7) == [7, 10, 16, 36, 76, 156, 316, 636, 1276, 2556, 5116]\n assert candidate(encoded = [15, 6, 9, 12, 23, 45],first = 10) == [10, 5, 3, 10, 6, 17, 60]\n assert candidate(encoded = [100000, 50000, 25000, 12500, 6250, 3125],first = 15625) == [15625, 113577, 96505, 72017, 76165, 78319, 81370]\n assert candidate(encoded = [4, 13, 5, 10, 3, 7, 1],first = 9) == [9, 13, 0, 5, 15, 12, 11, 10]\n assert candidate(encoded = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768],first = 128) == [128, 384, 896, 1920, 3968, 8064, 16256, 32640, 65408]\n assert candidate(encoded = [100, 200, 50, 250, 10, 300, 150, 225],first = 42) == [42, 78, 134, 180, 78, 68, 360, 510, 287]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35, 40, 45],first = 0) == [0, 5, 15, 0, 20, 13, 19, 48, 24, 53]\n assert candidate(encoded = [0, 0, 0, 0, 0],first = 0) == [0, 0, 0, 0, 0, 0]\n assert candidate(encoded = [255, 128, 64, 32, 16],first = 1) == [1, 254, 126, 62, 30, 14]\n assert candidate(encoded = [10, 10, 10, 10, 10, 10, 10, 10, 10],first = 10) == [10, 0, 10, 0, 10, 0, 10, 0, 10, 0]\n assert candidate(encoded = [0, 1, 0, 1, 0],first = 1) == [1, 1, 0, 0, 1, 1]\n assert candidate(encoded = [8, 3, 12, 5, 9],first = 6) == [6, 14, 13, 1, 4, 13]\n assert candidate(encoded = [99, 101, 97, 95, 103, 109, 100, 98, 94, 96, 92],first = 100) == [100, 7, 98, 3, 92, 59, 86, 50, 80, 14, 110, 50]\n assert candidate(encoded = [14, 7, 11, 12],first = 3) == [3, 13, 10, 1, 13]\n assert candidate(encoded = [31, 41, 59, 26, 53, 58, 97, 93, 23, 84, 62, 64, 33, 83, 27, 95, 8, 4],first = 271) == [271, 272, 313, 258, 280, 301, 279, 374, 299, 316, 360, 342, 278, 311, 356, 383, 288, 296, 300]\n assert candidate(encoded = [2, 3, 1, 4, 5],first = 7) == [7, 5, 6, 7, 3, 6]\n assert candidate(encoded = [231, 45, 67, 89, 101, 123, 145],first = 99) == [99, 132, 169, 234, 179, 214, 173, 60]\n assert candidate(encoded = [7, 5, 3, 1, 9, 11, 13, 15, 17, 19],first = 2) == [2, 5, 0, 3, 2, 11, 0, 13, 2, 19, 0]\n assert candidate(encoded = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],first = 2048) == [2048, 3072, 3584, 3840, 3968, 4032, 4064, 4080, 4088, 4092, 4094, 4095]\n assert candidate(encoded = [8, 6, 10, 12, 14, 16, 18, 20],first = 4) == [4, 12, 10, 0, 12, 2, 18, 0, 20]\n assert candidate(encoded = [2, 3, 2, 3, 2, 3],first = 1) == [1, 3, 0, 2, 1, 3, 0]\n assert candidate(encoded = [8, 13, 7, 10, 15],first = 2) == [2, 10, 7, 0, 10, 5]\n assert candidate(encoded = [7, 7, 7, 7, 7, 7, 7, 7],first = 3) == [3, 4, 3, 4, 3, 4, 3, 4, 3]\n assert candidate(encoded = [14, 11, 7, 15],first = 2) == [2, 12, 7, 0, 15]\n assert candidate(encoded = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],first = 3) == [3, 0, 6, 15, 3, 12, 30, 11, 19, 8, 22, 55, 19]\n assert candidate(encoded = [98765, 43210, 12345, 67890, 54321, 89012, 21043],first = 78901) == [78901, 46584, 7474, 11531, 74809, 126984, 43964, 63887]\n assert candidate(encoded = [7, 13, 14, 12, 17],first = 9) == [9, 14, 3, 13, 1, 16]\n assert candidate(encoded = [16, 32, 64, 128, 256, 512],first = 8) == [8, 24, 56, 120, 248, 504, 1016]\n assert candidate(encoded = [25, 15, 10, 13, 7, 4],first = 8) == [8, 17, 30, 20, 25, 30, 26]\n assert candidate(encoded = [128, 64, 32, 16, 8, 4, 2, 1],first = 255) == [255, 127, 63, 31, 15, 7, 3, 1, 0]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],first = 5) == [5, 0, 10, 5, 17, 8, 22, 53, 29, 48, 2]\n assert candidate(encoded = [255, 128, 64, 32, 16, 8, 4, 2, 1],first = 0) == [0, 255, 127, 63, 31, 15, 7, 3, 1, 0]\n assert candidate(encoded = [1000, 500, 250, 125, 62, 31, 15],first = 1) == [1, 1001, 541, 743, 666, 676, 699, 692]\n assert candidate(encoded = [15, 24, 32, 16, 8, 4, 2],first = 1) == [1, 14, 22, 54, 38, 46, 42, 40]\n assert candidate(encoded = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0],first = 65536) == [65536, 131071, 98304, 114687, 106496, 110591, 108544, 109567, 109056, 109311, 109184, 109247, 109216, 109231, 109224, 109227, 109226, 109226]\n assert candidate(encoded = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],first = 0) == [0, 1, 2, 5, 10, 21, 42, 85, 170, 341, 682]\n assert candidate(encoded = [1, 2, 4, 8, 16, 32, 64, 128],first = 256) == [256, 257, 259, 263, 271, 287, 319, 383, 511]\n assert candidate(encoded = [8, 2, 6, 4, 2, 6, 4],first = 7) == [7, 15, 13, 11, 15, 13, 11, 15]\n assert candidate(encoded = [1023, 2047, 4095, 8191, 16383, 32767, 65535],first = 1) == [1, 1022, 1025, 3070, 5121, 11262, 21505, 44030]\n assert candidate(encoded = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42],first = 1) == [1, 3, 5, 15, 1, 19, 5, 31, 1, 35, 5, 47]\n assert candidate(encoded = [100000, 50000, 25000, 12500, 6250, 3125],first = 1) == [1, 100001, 83441, 74841, 70797, 68839, 65746]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],first = 1) == [1, 4, 14, 1, 21, 12, 18, 49, 25, 52, 6, 49, 13, 76, 10, 65, 17]\n assert candidate(encoded = [1, 0, 1, 0, 1, 0, 1, 0],first = 0) == [0, 1, 1, 0, 0, 1, 1, 0, 0]\n assert candidate(encoded = [3, 5, 6, 1, 7, 4, 2, 8, 0],first = 3) == [3, 0, 5, 3, 2, 5, 1, 3, 11, 11]\n assert candidate(encoded = [9, 5, 7, 3, 8, 6, 2, 4, 1, 0],first = 11) == [11, 2, 7, 0, 3, 11, 13, 15, 11, 10, 10]\n assert candidate(encoded = [0, 1, 0, 1, 0, 1, 0, 1],first = 1) == [1, 1, 0, 0, 1, 1, 0, 0, 1]\n assert candidate(encoded = [2, 3, 1, 4, 5, 6, 7, 8, 9],first = 1) == [1, 3, 0, 1, 5, 0, 6, 1, 9, 0]\n assert candidate(encoded = [30, 15, 25, 35, 45, 55, 65],first = 5) == [5, 27, 20, 13, 46, 3, 52, 117]\n assert candidate(encoded = [23, 54, 12, 9, 17, 33, 20],first = 15) == [15, 24, 46, 34, 43, 58, 27, 15]\n assert candidate(encoded = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97],first = 1) == [1, 100001, 83441, 74841, 70797, 68839, 65746, 67272, 67013, 66627, 66688, 66785]\n assert candidate(encoded = [4, 6, 5, 7, 10, 13],first = 2) == [2, 6, 0, 5, 2, 8, 5]\n assert candidate(encoded = [100000, 90000, 80000, 70000, 60000],first = 50000) == [50000, 83440, 6752, 74464, 13200, 55792]\n assert candidate(encoded = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],first = 3) == [3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6]\n assert candidate(encoded = [12345, 67890, 12345, 67890, 12345],first = 98765) == [98765, 111092, 47302, 35071, 98765, 111092]\n assert candidate(encoded = [98765, 43210, 67890, 12345, 54321, 90123],first = 65432) == [65432, 97877, 120479, 57261, 61332, 15269, 89006]\n assert candidate(encoded = [25, 17, 31, 18, 29, 14],first = 10) == [10, 19, 2, 29, 15, 18, 28]\n assert candidate(encoded = [13, 11, 7, 14, 28, 16, 32],first = 8) == [8, 5, 14, 9, 7, 27, 11, 43]\n assert candidate(encoded = [14, 22, 36, 52, 72, 96, 124],first = 1) == [1, 15, 25, 61, 9, 65, 33, 93]\n assert candidate(encoded = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111],first = 10000) == [10000, 106895, 64183, 120166, 53516, 2063, 42387, 10150, 29032, 23055]\n assert candidate(encoded = [12, 15, 2, 8, 17, 5],first = 3) == [3, 15, 0, 2, 10, 27, 30]\n assert candidate(encoded = [4, 3, 2, 1],first = 5) == [5, 1, 2, 0, 1]\n assert candidate(encoded = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],first = 1) == [1, 0, 3, 4, 11, 20, 43, 84, 171, 340, 683]\n assert candidate(encoded = [2047, 4094, 2047, 4094, 2047, 4094, 2047],first = 4095) == [4095, 2048, 2046, 1, 4095, 2048, 2046, 1]\n assert candidate(encoded = [13, 9, 16, 22, 10, 19, 7, 12],first = 4) == [4, 9, 0, 16, 6, 12, 31, 24, 20]\n assert candidate(encoded = [32767, 16383, 8191, 4095, 2047],first = 1024) == [1024, 31743, 17408, 23551, 21504, 21503]\n", "comparison": "exact"}, "public_tests": ["[1,2,3]\n1", "[6,2,7,3]\n4"], "hints": ["Since that encoded[i] = arr[i] XOR arr[i+1], then arr[i+1] = encoded[i] XOR arr[i].", "Iterate on i from beginning to end, and set arr[i+1] = encoded[i] XOR arr[i]."], "metadata": {"canonical_parameter_names": ["encoded", "first"], "leetcode_dataset_entry_point": "Solution().decode", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:38+00:00", "tests_total": 97, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def decode(self, encoded: list[int], first: int) -> list[int]:", "container": "Solution", "callable": "decode", "parameters": [{"name": "encoded", "type": "list[int]"}, {"name": "first", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1722, "task_id": "minimize-hamming-distance-after-swap-operations", "difficulty": "Medium", "problem_description": "You are given two integer arrays, source and target, both of length n. You are also given an array allowedSwaps where each allowedSwaps[i] = [a_i, b_i] indicates that you are allowed to swap the elements at index a_i and index b_i (0-indexed) of array source. Note that you can swap elements at a specific pair of indices multiple times and in any order.\n\nThe Hamming distance of two arrays of the same length, source and target, is the number of positions where the elements are different. Formally, it is the number of indices i for 0 <= i <= n-1 where source[i] != target[i] (0-indexed).\n\nReturn the minimum Hamming distance of source and target after performing any amount of swap operations on array source.\n\nExample 1:\n\nInput: source = [1,2,3,4], target = [2,1,4,5], allowedSwaps = [[0,1],[2,3]]\nOutput: 1\nExplanation: source can be transformed the following way:\n- Swap indices 0 and 1: source = [2,1,3,4]\n- Swap indices 2 and 3: source = [2,1,4,3]\nThe Hamming distance of source and target is 1 as they differ in 1 position: index 3.\n\nExample 2:\n\nInput: source = [1,2,3,4], target = [1,3,2,4], allowedSwaps = []\nOutput: 2\nExplanation: There are no allowed swaps.\nThe Hamming distance of source and target is 2 as they differ in 2 positions: index 1 and index 2.\n\nExample 3:\n\nInput: source = [5,1,2,4,3], target = [1,5,4,2,3], allowedSwaps = [[0,4],[4,2],[1,3],[1,4]]\nOutput: 0\n\nConstraints:\n\n- n == source.length == target.length\n- 1 <= n <= 10^5\n- 1 <= source[i], target[i] <= 10^5\n- 0 <= allowedSwaps.length <= 10^5\n- allowedSwaps[i].length == 2\n- 0 <= a_i, b_i <= n - 1\n- a_i != b_i\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(source = [4, 3, 2, 1],target = [1, 2, 3, 4],allowedSwaps = [[0, 3], [1, 2], [0, 1], [2, 3]]) == 0\n assert candidate(source = [4, 3, 2, 1],target = [1, 2, 3, 4],allowedSwaps = [[0, 2], [1, 3]]) == 4\n assert candidate(source = [1, 1, 1, 1],target = [1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3]]) == 0\n assert candidate(source = [1, 2, 3, 4],target = [1, 3, 2, 4],allowedSwaps = []) == 2\n assert candidate(source = [1, 2, 3, 4],target = [2, 1, 4, 5],allowedSwaps = [[0, 1], [2, 3]]) == 1\n assert candidate(source = [5, 1, 2, 4, 3],target = [1, 5, 4, 2, 3],allowedSwaps = [[0, 4], [4, 2], [1, 3], [1, 4]]) == 0\n assert candidate(source = [4, 5, 6],target = [6, 4, 5],allowedSwaps = [[0, 1], [1, 2]]) == 0\n assert candidate(source = [10, 20, 30],target = [30, 20, 10],allowedSwaps = [[0, 2]]) == 0\n assert candidate(source = [1, 1, 1, 1],target = [2, 2, 2, 2],allowedSwaps = [[0, 1], [1, 2], [2, 3]]) == 4\n assert candidate(source = [1, 2, 2, 1],target = [2, 1, 1, 2],allowedSwaps = [[0, 1], [2, 3], [1, 2]]) == 0\n assert candidate(source = [1, 2, 2, 1, 3, 3, 4, 4],target = [4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 6], [1, 7], [2, 5], [3, 4], [0, 1], [2, 3], [4, 5], [6, 7]]) == 2\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],allowedSwaps = [[0, 2], [2, 4], [4, 6], [6, 8], [1, 3], [3, 5], [5, 7], [7, 9]]) == 4\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 5], [1, 6], [2, 3], [3, 2], [4, 1], [5, 0]]) == 0\n assert candidate(source = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],target = [99991, 99992, 99993, 99994, 99995, 99996, 99997, 99998, 99999, 100000],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 2], [1, 3]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 0\n assert candidate(source = [7, 8, 9, 10, 11, 12],target = [12, 11, 10, 9, 8, 7],allowedSwaps = [[0, 5], [1, 4], [2, 3]]) == 0\n assert candidate(source = [1, 3, 5, 7, 9, 11],target = [11, 9, 7, 5, 3, 1],allowedSwaps = [[0, 5], [1, 4], [2, 3]]) == 0\n assert candidate(source = [1, 3, 5, 7, 9, 11, 13, 15],target = [15, 13, 11, 9, 7, 5, 3, 1],allowedSwaps = [[0, 7], [1, 6], [2, 5], [3, 4]]) == 0\n assert candidate(source = [5, 5, 5, 5, 5, 5],target = [5, 5, 5, 5, 5, 5],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = []) == 10\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 3], [4, 6]]) == 0\n assert candidate(source = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],target = [8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8], [0, 7], [1, 6], [2, 5], [3, 4]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],allowedSwaps = [[0, 1]]) == 9\n assert candidate(source = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 4], [1, 3], [2, 8], [5, 7], [6, 9]]) == 8\n assert candidate(source = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7]]) == 8\n assert candidate(source = [10, 20, 30, 40, 50, 60],target = [60, 20, 50, 40, 30, 10],allowedSwaps = [[0, 5], [2, 4], [0, 2]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = [9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 8], [1, 7], [2, 6], [3, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 6\n assert candidate(source = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],allowedSwaps = []) == 0\n assert candidate(source = [7, 8, 9, 10, 11, 12, 13],target = [13, 12, 11, 10, 9, 8, 7],allowedSwaps = [[0, 6], [1, 5], [2, 4], [0, 3]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50],target = [50, 40, 30, 20, 10],allowedSwaps = [[0, 4], [1, 3]]) == 0\n assert candidate(source = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],allowedSwaps = []) == 10\n assert candidate(source = [1, 1, 2, 2, 3, 3],target = [3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 2], [0, 4], [1, 3], [1, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 20\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 7], [1, 6], [2, 5], [3, 4]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 10\n assert candidate(source = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [1, 5], [2, 6], [3, 7], [0, 8], [1, 9], [2, 5], [3, 6], [4, 7]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],allowedSwaps = [[0, 1], [1, 9], [9, 8]]) == 7\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 3], [4, 6], [7, 8]]) == 0\n assert candidate(source = [3, 2, 1, 4, 5],target = [5, 4, 3, 2, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 1, 19, 2, 18, 3, 17, 4, 16, 5, 15, 6, 14, 7, 13, 8, 12, 9, 11, 10],allowedSwaps = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 16\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(source = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [4, 1, 3, 2],target = [2, 3, 1, 4],allowedSwaps = [[0, 1], [1, 2], [2, 3], [0, 2], [1, 3]]) == 0\n assert candidate(source = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 3], [4, 6], [7, 8]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],allowedSwaps = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == 0\n assert candidate(source = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],target = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 12\n assert candidate(source = [7, 8, 9, 10, 11, 12],target = [10, 11, 12, 7, 8, 9],allowedSwaps = [[0, 3], [1, 4], [2, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 10\n assert candidate(source = [1, 1, 1, 1, 1],target = [1, 1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [1, 5], [2, 6], [3, 7]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],target = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50, 60],target = [60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 5], [1, 4], [2, 3]]) == 0\n assert candidate(source = [1, 1, 2, 2, 3, 3, 4, 4],target = [4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 6], [1, 7], [2, 5], [3, 4]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = [9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 8], [1, 7], [2, 6], [3, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],target = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8]]) == 0\n assert candidate(source = [100000, 90000, 80000, 70000],target = [70000, 80000, 90000, 100000],allowedSwaps = [[0, 3], [1, 2], [0, 1], [2, 3]]) == 0\n assert candidate(source = [4, 4, 4, 4, 4],target = [1, 2, 3, 4, 5],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 4\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 2, 9, 3, 8, 4, 7, 5, 6, 1],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 5\n assert candidate(source = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == 10\n assert candidate(source = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],target = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 3], [4, 8], [5, 7]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],allowedSwaps = []) == 0\n assert candidate(source = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]\n[2,1,4,5]\n[[0,1],[2,3]]", "[1,2,3,4]\n[1,3,2,4]\n[]", "[5,1,2,4,3]\n[1,5,4,2,3]\n[[0,4],[4,2],[1,3],[1,4]]"], "hints": ["The source array can be imagined as a graph where each index is a node and each allowedSwaps[i] is an edge.", "Nodes within the same component can be freely swapped with each other.", "For each component, find the number of common elements. The elements that are not in common will contribute to the total Hamming distance."], "metadata": {"canonical_parameter_names": ["source", "target", "allowedSwaps"], "leetcode_dataset_entry_point": "Solution().minimumHammingDistance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:43+00:00", "tests_total": 83, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "depth-first-search", "union-find"]}, "language": "python", "interface": {"raw_signature": "def minimumHammingDistance(self, source: list[int], target: list[int], allowedSwaps: list[list[int]]) -> int:", "container": "Solution", "callable": "minimumHammingDistance", "parameters": [{"name": "source", "type": "list[int]"}, {"name": "target", "type": "list[int]"}, {"name": "allowedSwaps", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1723, "task_id": "find-minimum-time-to-finish-all-jobs", "difficulty": "Hard", "problem_description": "You are given an integer array jobs, where jobs[i] is the amount of time it takes to complete the i^th job.\n\nThere are k workers that you can assign jobs to. Each job should be assigned to exactly one worker. The working time of a worker is the sum of the time it takes to complete all jobs assigned to them. Your goal is to devise an optimal assignment such that the maximum working time of any worker is minimized.\n\nReturn the minimum possible maximum working time of any assignment.\n\nExample 1:\n\nInput: jobs = [3,2,3], k = 3\nOutput: 3\nExplanation: By assigning each person one job, the maximum time is 3.\n\nExample 2:\n\nInput: jobs = [1,2,4,7,8], k = 2\nOutput: 11\nExplanation: Assign the jobs the following way:\nWorker 1: 1, 2, 8 (working time = 1 + 2 + 8 = 11)\nWorker 2: 4, 7 (working time = 4 + 7 = 11)\nThe maximum working time is 11.\n\nConstraints:\n\n- 1 <= k <= jobs.length <= 12\n- 1 <= jobs[i] <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(jobs = [1, 2, 4, 7, 8],k = 2) == 11\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 4) == 20\n assert candidate(jobs = [6, 5, 4, 3, 2, 1],k = 6) == 6\n assert candidate(jobs = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 20\n assert candidate(jobs = [10, 20, 30, 40, 50, 60],k = 3) == 70\n assert candidate(jobs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 12) == 10\n assert candidate(jobs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 4) == 3\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 6) == 13\n assert candidate(jobs = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 6) == 18\n assert candidate(jobs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 6) == 10\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 12) == 120\n assert candidate(jobs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 12) == 1\n assert candidate(jobs = [3, 2, 3],k = 3) == 3\n assert candidate(jobs = [5, 5, 3, 2, 4, 1],k = 3) == 7\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 3) == 26\n assert candidate(jobs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 15\n assert candidate(jobs = [12, 3, 5, 8, 9, 4, 7, 6, 2, 10, 11, 1],k = 5) == 16\n assert candidate(jobs = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 6) == 100\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 5) == 160\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 7) == 12\n assert candidate(jobs = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000],k = 2) == 39000\n assert candidate(jobs = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 2) == 18\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 7) == 120\n assert candidate(jobs = [10000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],k = 4) == 10000000\n assert candidate(jobs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],k = 4) == 40\n assert candidate(jobs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 3) == 130\n assert candidate(jobs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 4) == 36\n assert candidate(jobs = [3, 7, 1, 10, 5, 2, 8, 6, 4, 9, 11, 12],k = 5) == 16\n assert candidate(jobs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 4) == 11\n assert candidate(jobs = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000],k = 6) == 20000000\n assert candidate(jobs = [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12],k = 6) == 24\n assert candidate(jobs = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 1) == 36\n assert candidate(jobs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 5) == 1600\n assert candidate(jobs = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 8) == 12\n assert candidate(jobs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 12) == 23\n assert candidate(jobs = [30, 15, 40, 10, 25, 5, 60, 45, 20, 50, 55, 35],k = 5) == 80\n assert candidate(jobs = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 1) == 12000000\n assert candidate(jobs = [20, 10, 30, 25, 15, 5, 40, 35, 50, 100, 200, 50],k = 3) == 200\n assert candidate(jobs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14],k = 3) == 28\n assert candidate(jobs = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],k = 6) == 56\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 4) == 200\n assert candidate(jobs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 6) == 65\n assert candidate(jobs = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],k = 4) == 38\n assert candidate(jobs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 6) == 4\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 2) == 390\n assert candidate(jobs = [9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11, 10],k = 4) == 20\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 2) == 39\n assert candidate(jobs = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],k = 4) == 140\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 1) == 78\n assert candidate(jobs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 11) == 1200\n assert candidate(jobs = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 7) == 12\n assert candidate(jobs = [1000, 1000, 1000, 1000, 2000, 2000, 2000, 2000, 3000, 3000, 3000, 3000],k = 8) == 3000\n assert candidate(jobs = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 4) == 200\n assert candidate(jobs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 3) == 8\n assert candidate(jobs = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],k = 4) == 60\n assert candidate(jobs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 5) == 30\n assert candidate(jobs = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 12\n assert candidate(jobs = [2, 5, 10, 17, 26, 37, 50, 65, 82, 101, 122, 145],k = 4) == 168\n assert candidate(jobs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 8) == 4\n assert candidate(jobs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 12) == 1200\n assert candidate(jobs = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000],k = 2) == 39000\n assert candidate(jobs = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],k = 6) == 91\n assert candidate(jobs = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == 13\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 2) == 390\n assert candidate(jobs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],k = 5) == 2048\n assert candidate(jobs = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 11],k = 6) == 13\n assert candidate(jobs = [1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000],k = 4) == 5000\n assert candidate(jobs = [7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1],k = 2) == 17\n assert candidate(jobs = [10000000, 10000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 10000000\n assert candidate(jobs = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37],k = 3) == 66\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 3) == 260\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 4) == 200\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 12) == 12\n assert candidate(jobs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 8) == 20\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 3) == 260\n assert candidate(jobs = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 8) == 14\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 4) == 20\n assert candidate(jobs = [3, 5, 7, 12, 4, 8, 9, 11, 6, 10, 2, 1],k = 3) == 26\n assert candidate(jobs = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3],k = 5) == 11\n assert candidate(jobs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 3) == 14\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 12) == 120\n assert candidate(jobs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 4) == 36\n assert candidate(jobs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 6) == 1300\n assert candidate(jobs = [10000000, 1000000, 100000, 10000, 1000, 100, 10, 1, 1, 1, 1, 1],k = 7) == 10000000\n assert candidate(jobs = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5],k = 6) == 7\n assert candidate(jobs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 4) == 11\n assert candidate(jobs = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115],k = 5) == 150\n assert candidate(jobs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],k = 3) == 2048\n assert candidate(jobs = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1],k = 5) == 10\n assert candidate(jobs = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 26\n assert candidate(jobs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11],k = 4) == 20\n assert candidate(jobs = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 6) == 14\n assert candidate(jobs = [7, 2, 8, 9, 4, 3, 6, 1, 5, 10, 11, 12],k = 3) == 26\n assert candidate(jobs = [10000000, 1000000, 100000, 10000, 1000, 100, 10, 1, 1, 1, 1, 1],k = 3) == 10000000\n assert candidate(jobs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 3) == 40\n assert candidate(jobs = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],k = 4) == 8\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 12) == 12\n assert candidate(jobs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 8) == 60\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 6) == 130\n assert candidate(jobs = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 5) == 18\n assert candidate(jobs = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],k = 4) == 14\n assert candidate(jobs = [9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 20, 25],k = 5) == 25\n assert candidate(jobs = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],k = 3) == 56\n assert candidate(jobs = [5, 7, 12, 18, 23, 30, 37, 40, 45, 50, 55, 60],k = 3) == 128\n assert candidate(jobs = [10000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],k = 5) == 10000000\n assert candidate(jobs = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000, 100000, 10000],k = 6) == 10000000\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 1) == 78\n assert candidate(jobs = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144],k = 9) == 144\n assert candidate(jobs = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37],k = 5) == 40\n assert candidate(jobs = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062, 19531, 9765, 4882],k = 3) == 10000000\n", "comparison": "exact"}, "public_tests": ["[3,2,3]\n3", "[1,2,4,7,8]\n2"], "hints": ["We can select a subset of tasks and assign it to a worker then solve the subproblem on the remaining tasks"], "metadata": {"canonical_parameter_names": ["jobs", "k"], "leetcode_dataset_entry_point": "Solution().minimumTimeRequired", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:45+00:00", "tests_total": 111, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "dynamic-programming", "backtracking", "bit-manipulation", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def minimumTimeRequired(self, jobs: list[int], k: int) -> int:", "container": "Solution", "callable": "minimumTimeRequired", "parameters": [{"name": "jobs", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1725, "task_id": "number-of-rectangles-that-can-form-the-largest-square", "difficulty": "Easy", "problem_description": "You are given an array rectangles where rectangles[i] = [l_i, w_i] represents the i^th rectangle of length l_i and width w_i.\n\nYou can cut the i^th rectangle to form a square with a side length of k if both k <= l_i and k <= w_i. For example, if you have a rectangle [4,6], you can cut it to get a square with a side length of at most 4.\n\nLet maxLen be the side length of the largest square you can obtain from any of the given rectangles.\n\nReturn the number of rectangles that can make a square with a side length of maxLen.\n\nExample 1:\n\nInput: rectangles = [[5,8],[3,9],[5,12],[16,5]]\nOutput: 3\nExplanation: The largest squares you can get from each rectangle are of lengths [5,3,5,5].\nThe largest possible square is of length 5, and you can get it out of 3 rectangles.\n\nExample 2:\n\nInput: rectangles = [[2,3],[3,7],[4,3],[3,7]]\nOutput: 3\n\nConstraints:\n\n- 1 <= rectangles.length <= 1000\n- rectangles[i].length == 2\n- 1 <= l_i, w_i <= 10^9\n- l_i != w_i\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rectangles = [[1, 2], [2, 1], [3, 4], [4, 3]]) == 2\n assert candidate(rectangles = [[2, 3], [3, 7], [4, 3], [3, 7]]) == 3\n assert candidate(rectangles = [[5, 8], [3, 9], [5, 12], [16, 5]]) == 3\n assert candidate(rectangles = [[10, 1], [1, 10], [20, 2], [2, 20], [30, 3], [3, 30], [40, 4], [4, 40], [50, 5], [5, 50]]) == 2\n assert candidate(rectangles = [[1, 999999999], [2, 999999998], [3, 999999997], [4, 999999996], [5, 999999995]]) == 1\n assert candidate(rectangles = [[1, 999999999], [2, 999999998], [3, 999999997], [4, 999999996], [5, 999999995]]) == 1\n assert candidate(rectangles = [[2, 4], [4, 2], [3, 6], [6, 3], [4, 8], [8, 4], [5, 10], [10, 5], [6, 12], [12, 6], [7, 14], [14, 7], [8, 16], [16, 8], [9, 18], [18, 9], [10, 20], [20, 10]]) == 2\n assert candidate(rectangles = [[1, 1000000000], [1000000000, 1], [2, 500000000], [500000000, 2]]) == 2\n assert candidate(rectangles = [[3, 1], [1, 3], [4, 2], [2, 4], [5, 3], [3, 5], [6, 4], [4, 6], [7, 5], [5, 7], [8, 6], [6, 8]]) == 2\n assert candidate(rectangles = [[2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [10, 11], [11, 10]]) == 2\n assert candidate(rectangles = [[100, 200], [101, 199], [102, 198], [103, 197], [104, 196], [105, 195], [106, 194], [107, 193], [108, 192], [109, 191], [110, 190]]) == 1\n assert candidate(rectangles = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 1\n assert candidate(rectangles = [[1, 1000000000], [1000000000, 1], [2, 999999998], [999999998, 2], [3, 999999996], [999999996, 3], [4, 999999994], [999999994, 4], [5, 999999992], [999999992, 5]]) == 2\n assert candidate(rectangles = [[999999999, 1000000000], [1000000000, 999999999], [1, 1000000000], [1000000000, 1], [2, 999999999], [999999999, 2], [3, 999999998], [999999998, 3], [4, 999999997], [999999997, 4]]) == 2\n assert candidate(rectangles = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 2\n assert candidate(rectangles = [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(rectangles = [[2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [11, 10], [12, 11], [13, 12], [1, 12], [12, 1]]) == 1\n assert candidate(rectangles = [[11, 12], [12, 11], [13, 14], [14, 13], [15, 16], [16, 15], [17, 18], [18, 17], [19, 20], [20, 19]]) == 2\n assert candidate(rectangles = [[10, 20], [20, 10], [30, 40], [40, 30], [50, 60], [60, 50], [70, 80], [80, 70], [90, 100], [100, 90]]) == 2\n assert candidate(rectangles = [[15, 20], [20, 15], [25, 30], [30, 25], [35, 40], [40, 35], [45, 50], [50, 45]]) == 2\n assert candidate(rectangles = [[5, 10], [10, 5], [15, 20], [20, 15], [25, 30], [30, 25], [35, 40], [40, 35]]) == 2\n assert candidate(rectangles = [[1000000000, 1], [1000000000, 2], [1000000000, 3], [1000000000, 4], [1000000000, 5]]) == 1\n", "comparison": "exact"}, "public_tests": ["[[5,8],[3,9],[5,12],[16,5]]", "[[2,3],[3,7],[4,3],[3,7]]"], "hints": ["What is the length of the largest square the can be cut out of some rectangle? It'll be equal to min(rectangle.length, rectangle.width). Replace each rectangle with this value.", "Calculate maxSize by iterating over the given rectangles and maximizing the answer with their values denoted in the first hint.", "Then iterate again on the rectangles and calculate the number whose values = maxSize."], "metadata": {"canonical_parameter_names": ["rectangles"], "leetcode_dataset_entry_point": "Solution().countGoodRectangles", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:47+00:00", "tests_total": 83, "tests_dropped": 61, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def countGoodRectangles(self, rectangles: List[List[int]]) -> int:", "container": "Solution", "callable": "countGoodRectangles", "parameters": [{"name": "rectangles", "type": "List[List[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1726, "task_id": "tuple-with-same-product", "difficulty": "Medium", "problem_description": "Given an array nums of distinct positive integers, return the number of tuples (a, b, c, d) such that a * b = c * d where a, b, c, and d are elements of nums, and a != b != c != d.\n\nExample 1:\n\nInput: nums = [2,3,4,6]\nOutput: 8\nExplanation: There are 8 valid tuples:\n(2,6,3,4) , (2,6,4,3) , (6,2,3,4) , (6,2,4,3)\n(3,4,2,6) , (4,3,2,6) , (3,4,6,2) , (4,3,6,2)\n\nExample 2:\n\nInput: nums = [1,2,4,5,10]\nOutput: 16\nExplanation: There are 16 valid tuples:\n(1,10,2,5) , (1,10,5,2) , (10,1,2,5) , (10,1,5,2)\n(2,5,1,10) , (2,5,10,1) , (5,2,1,10) , (5,2,10,1)\n(2,10,4,5) , (2,10,5,4) , (10,2,4,5) , (10,2,5,4)\n(4,5,2,10) , (4,5,10,2) , (5,4,2,10) , (5,4,10,2)\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 1 <= nums[i] <= 10^4\n- All elements in nums are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 16\n assert candidate(nums = [7, 8, 9, 14, 21]) == 0\n assert candidate(nums = [7, 11, 13, 19, 23, 29, 31]) == 0\n assert candidate(nums = [2, 5, 10, 15, 20]) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64]) == 56\n assert candidate(nums = [7, 8, 14, 21]) == 0\n assert candidate(nums = [2, 3, 4, 6]) == 8\n assert candidate(nums = [8, 12, 16, 20, 24]) == 8\n assert candidate(nums = [1, 2, 4, 5, 10]) == 16\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 72\n assert candidate(nums = [1, 10, 100, 1000]) == 8\n assert candidate(nums = [2, 3, 5, 7, 11, 13]) == 0\n assert candidate(nums = [10, 20, 30, 60]) == 8\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 72\n assert candidate(nums = [10, 15, 20, 30, 40, 50, 60, 75, 100, 150, 200, 300, 500, 1000]) == 600\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == 536\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 72\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 72\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729]) == 104\n assert candidate(nums = [1, 6, 9, 18, 27, 54, 81]) == 48\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120]) == 784\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 136\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240]) == 1664\n assert candidate(nums = [3, 6, 9, 12, 18, 27, 36, 54, 72, 108]) == 256\n assert candidate(nums = [10, 20, 40, 50, 80, 100, 160, 200, 250, 400, 500, 800, 1000, 1600, 2000, 2500, 4000, 5000, 8000, 10000]) == 2784\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == 184\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225]) == 248\n assert candidate(nums = [5, 10, 15, 25, 50, 75, 125, 250, 375, 625]) == 176\n assert candidate(nums = [12, 15, 20, 25, 30, 60, 100, 150]) == 40\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90]) == 240\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 136\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 536\n assert candidate(nums = [2, 6, 12, 18, 36, 72, 108, 216, 324, 432, 648, 1296]) == 472\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 400\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 400\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 32, 48, 64]) == 112\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120]) == 248\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]) == 0\n assert candidate(nums = [2, 5, 10, 25, 50, 125, 250, 625, 1250, 3125, 6250]) == 400\n assert candidate(nums = [1, 2, 3, 4, 6, 8, 12, 24]) == 128\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132]) == 136\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729]) == 104\n assert candidate(nums = [1, 2, 3, 4, 6, 8, 12, 24]) == 128\n assert candidate(nums = [2, 3, 6, 12, 24, 48, 96, 192, 384, 768]) == 272\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175]) == 968\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 72\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96]) == 304\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100]) == 968\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625]) == 968\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209]) == 408\n assert candidate(nums = [2, 3, 5, 6, 10, 15, 30]) == 48\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154]) == 184\n assert candidate(nums = [12, 15, 20, 24, 30, 36, 40, 45, 48, 60, 72, 80, 90, 120, 144, 180, 240, 360, 720]) == 1592\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275, 286, 297, 308, 319, 330, 341, 352, 363, 374, 385, 396, 407, 418, 429, 440, 451, 462, 473, 484, 495]) == 4592\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180]) == 1664\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 60, 100]) == 56\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 536\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 248\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 253, 276, 299, 322, 345, 368, 391, 414, 437, 460, 483, 506, 529, 552, 575, 598, 621, 644, 667, 690, 713, 736, 759, 782, 805, 828, 851, 874, 897, 920, 943, 966, 989, 1012]) == 4200\n assert candidate(nums = [10, 15, 30, 45, 60, 90, 120, 135, 180, 225]) == 144\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260]) == 536\n assert candidate(nums = [5, 10, 15, 25, 50, 75, 125, 250, 375, 625]) == 176\n assert candidate(nums = [12, 15, 18, 20, 24, 30, 36, 40, 45, 48, 60, 72, 80, 90, 120, 144, 150, 180, 200, 240, 300, 360, 400, 450, 720, 900]) == 4112\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75]) == 968\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561]) == 176\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 248\n assert candidate(nums = [5, 10, 15, 20, 25, 50, 100, 200]) == 72\n assert candidate(nums = [5, 10, 15, 20, 25, 50, 75, 100]) == 64\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == 184\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 20, 24, 30, 40, 60, 120]) == 1168\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == 72\n assert candidate(nums = [2, 5, 10, 20, 25, 50, 100, 125, 250, 500, 1000, 2500, 5000]) == 608\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 209, 228, 247, 266, 285, 304, 323, 342, 361, 380, 399, 418, 437, 456, 475, 494, 513, 532, 551, 570, 589, 608, 627, 646, 665, 684, 703, 722, 741, 760]) == 3432\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132]) == 136\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 560\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290, 319, 348, 377, 406, 435, 464, 493, 522, 551, 580, 609, 638, 667, 696, 725, 754, 783, 812, 841, 870, 899, 928, 957, 986, 1015, 1044, 1073, 1102, 1131, 1160, 1189, 1218, 1247, 1276, 1305, 1334, 1363, 1392, 1421, 1450, 1479, 1508, 1537, 1566, 1595, 1624]) == 7912\n assert candidate(nums = [2, 5, 10, 20, 25, 50, 100, 125, 200, 250, 500, 1000]) == 472\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208]) == 304\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340, 357, 374, 391, 408, 425]) == 968\n assert candidate(nums = [2, 5, 10, 20, 25, 50, 100, 125, 200, 250, 500, 1000, 1250, 2000, 2500, 5000, 10000]) == 1584\n assert candidate(nums = [12, 18, 24, 36, 48, 72, 96, 144, 216, 288, 432, 576, 720, 864, 1152, 1728, 2160, 2592, 3456, 4320]) == 1840\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 1000\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260, 273, 286, 299, 312, 325, 338, 351, 364, 377, 390]) == 1664\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340]) == 536\n assert candidate(nums = [2, 5, 10, 25, 50, 125, 250, 625]) == 128\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60]) == 248\n assert candidate(nums = [5, 10, 15, 20, 25, 50, 100, 200]) == 72\n", "comparison": "exact"}, "public_tests": ["[2,3,4,6]", "[1,2,4,5,10]"], "hints": ["Note that all of the integers are distinct. This means that each time a product is formed it must be formed by two unique integers.", "Count the frequency of each product of 2 distinct numbers. Then calculate the permutations formed."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().tupleSameProduct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:50+00:00", "tests_total": 105, "tests_dropped": 16, "flags": [], "topic_tags": ["array", "hash-table", "counting"]}, "language": "python", "interface": {"raw_signature": "def tupleSameProduct(self, nums: list[int]) -> int:", "container": "Solution", "callable": "tupleSameProduct", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1727, "task_id": "largest-submatrix-with-rearrangements", "difficulty": "Medium", "problem_description": "You are given a binary matrix matrix of size m x n, and you are allowed to rearrange the columns of the matrix in any order.\n\nReturn the area of the largest submatrix within matrix where every element of the submatrix is 1 after reordering the columns optimally.\n\nExample 1:\n\nInput: matrix = [[0,0,1],[1,1,1],[1,0,1]]\nOutput: 4\nExplanation: You can rearrange the columns as shown above.\nThe largest submatrix of 1s, in bold, has an area of 4.\n\nExample 2:\n\nInput: matrix = [[1,0,1,0,1]]\nOutput: 3\nExplanation: You can rearrange the columns as shown above.\nThe largest submatrix of 1s, in bold, has an area of 3.\n\nExample 3:\n\nInput: matrix = [[1,1,0],[1,0,1]]\nOutput: 2\nExplanation: Notice that you must rearrange entire columns, and there is no way to make a submatrix of 1s larger than an area of 2.\n\nConstraints:\n\n- m == matrix.length\n- n == matrix[i].length\n- 1 <= m * n <= 10^5\n- matrix[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[0, 1], [1, 0]]) == 1\n assert candidate(matrix = [[1, 1, 0], [1, 0, 1]]) == 2\n assert candidate(matrix = [[0, 0, 1], [1, 1, 1], [1, 0, 1]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(matrix = [[1, 0, 1, 0, 1]]) == 3\n assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0]]) == 6\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1], [1, 0, 1, 1, 0, 1], [0, 1, 1, 0, 1, 1], [1, 1, 0, 1, 1, 0], [0, 0, 1, 1, 0, 1]]) == 4\n assert candidate(matrix = [[1, 0, 1, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 4\n assert candidate(matrix = [[1, 0, 0, 0, 0, 0, 1, 0, 1, 1], [0, 1, 1, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 15\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 20\n assert candidate(matrix = [[1, 1, 1, 0, 1, 1, 1], [0, 1, 1, 1, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1], [1, 1, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 1], [1, 0, 0, 1, 0, 1]]) == 4\n assert candidate(matrix = [[1, 0, 1, 0, 1, 1], [1, 1, 1, 0, 1, 0], [1, 0, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1], [1, 0, 0, 0], [1, 1, 0, 1], [0, 0, 1, 1], [1, 1, 1, 1]]) == 4\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 0, 0]]) == 8\n assert candidate(matrix = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 0, 1, 1]]) == 4\n assert candidate(matrix = [[1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1]]) == 5\n assert candidate(matrix = [[1, 1, 1, 0, 0], [0, 1, 1, 1, 0], [1, 0, 1, 1, 1]]) == 4\n assert candidate(matrix = [[0, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 16\n assert candidate(matrix = [[1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 1, 1, 1, 0], [1, 0, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 0, 0, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [1, 1, 1, 0, 1]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 1, 1], [0, 0, 1, 1, 1], [1, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 1, 0, 0, 1], [0, 1, 1, 1, 1, 0], [1, 1, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0]]) == 6\n assert candidate(matrix = [[1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 1, 1, 0, 0, 1]]) == 6\n assert candidate(matrix = [[0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1]]) == 4\n assert candidate(matrix = [[0, 1, 1, 1], [1, 1, 0, 1], [1, 0, 1, 1], [1, 1, 1, 0]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 12\n assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1], [0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 0, 1]]) == 5\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 15\n assert candidate(matrix = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1], [1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 0, 1], [0, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[0, 1, 1, 0], [1, 1, 1, 1], [1, 0, 1, 1]]) == 6\n assert candidate(matrix = [[0, 0, 0, 0], [0, 1, 1, 0], [1, 1, 1, 1], [0, 1, 1, 0], [1, 1, 1, 1]]) == 8\n assert candidate(matrix = [[0, 0, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]]) == 4\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 5\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1], [1, 0, 1, 1, 1, 0], [1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 0, 0, 1], [0, 1, 1, 1, 1], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 30\n assert candidate(matrix = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 1\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]]) == 6\n assert candidate(matrix = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 3\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 4\n assert candidate(matrix = [[1, 0, 0, 1], [0, 1, 1, 0], [1, 1, 1, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 0, 1, 1], [1, 0, 1, 0, 1], [0, 1, 1, 1, 0]]) == 6\n assert candidate(matrix = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1]]) == 6\n assert candidate(matrix = [[0, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 0, 1], [0, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[0, 0, 0, 1, 1, 1], [0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 0, 1], [1, 1, 1, 1, 0, 0]]) == 4\n assert candidate(matrix = [[1, 1, 1], [1, 0, 1], [1, 1, 1], [1, 0, 1], [1, 1, 1], [1, 0, 1]]) == 12\n assert candidate(matrix = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 1, 0, 1, 0, 1], [0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 1], [0, 1, 1, 1, 0, 1], [1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1], [1, 1, 0, 1, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 0, 1]]) == 6\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 3\n assert candidate(matrix = [[1, 0, 1, 1, 1], [1, 1, 1, 0, 1], [0, 1, 1, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 8\n assert candidate(matrix = [[1, 0, 1, 1], [0, 1, 0, 1], [1, 1, 0, 0], [1, 1, 1, 1]]) == 4\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 20\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 0, 0, 1, 1], [1, 1, 1, 1, 0], [0, 1, 1, 1, 1], [1, 1, 0, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 1, 0, 0, 0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[0, 1, 1, 1, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [1, 0, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 0, 1]]) == 9\n assert candidate(matrix = [[0, 0, 0, 1, 1], [1, 1, 1, 1, 1], [0, 1, 0, 1, 1], [1, 0, 1, 0, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 1, 1, 1], [1, 0, 1, 0], [0, 1, 1, 1], [1, 1, 0, 1]]) == 4\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0]]) == 7\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 1, 1], [1, 0, 1, 0]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 1, 0, 0, 1], [1, 1, 1, 0, 1], [1, 0, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1], [1, 1, 0, 1, 1, 1], [1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 0, 1]]) == 12\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 5\n assert candidate(matrix = [[0, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1, 0, 1]]) == 5\n", "comparison": "exact"}, "public_tests": ["[[0,0,1],[1,1,1],[1,0,1]]", "[[1,0,1,0,1]]", "[[1,1,0],[1,0,1]]"], "hints": ["For each column, find the number of consecutive ones ending at each position.", "For each row, sort the cumulative ones in non-increasing order and \"fit\" the largest submatrix."], "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().largestSubmatrix", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:52+00:00", "tests_total": 83, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "greedy", "sorting", "matrix"]}, "language": "python", "interface": {"raw_signature": "def largestSubmatrix(self, matrix: list[list[int]]) -> int:", "container": "Solution", "callable": "largestSubmatrix", "parameters": [{"name": "matrix", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1728, "task_id": "cat-and-mouse-ii", "difficulty": "Hard", "problem_description": "A game is played by a cat and a mouse named Cat and Mouse.\n\nThe environment is represented by a grid of size rows x cols, where each element is a wall, floor, player (Cat, Mouse), or food.\n\n- Players are represented by the characters 'C'(Cat),'M'(Mouse).\n- Floors are represented by the character '.' and can be walked on.\n- Walls are represented by the character '#' and cannot be walked on.\n- Food is represented by the character 'F' and can be walked on.\n- There is only one of each character 'C', 'M', and 'F' in grid.\n\nMouse and Cat play according to the following rules:\n\n- Mouse moves first, then they take turns to move.\n- During each turn, Cat and Mouse can jump in one of the four directions (left, right, up, down). They cannot jump over the wall nor outside of the grid.\n- catJump, mouseJump are the maximum lengths Cat and Mouse can jump at a time, respectively. Cat and Mouse can jump less than the maximum length.\n- Staying in the same position is allowed.\n- Mouse can jump over Cat.\n\nThe game can end in 4 ways:\n\n- If Cat occupies the same position as Mouse, Cat wins.\n- If Cat reaches the food first, Cat wins.\n- If Mouse reaches the food first, Mouse wins.\n- If Mouse cannot get to the food within 1000 turns, Cat wins.\n\nGiven a rows x cols matrix grid and two integers catJump and mouseJump, return true if Mouse can win the game if both Cat and Mouse play optimally, otherwise return false.\n\nExample 1:\n\nInput: grid = [\"####F\",\"#C...\",\"M....\"], catJump = 1, mouseJump = 2\nOutput: true\nExplanation: Cat cannot catch Mouse on its turn nor can it get the food before Mouse.\n\nExample 2:\n\nInput: grid = [\"M.C...F\"], catJump = 1, mouseJump = 4\nOutput: true\n\nExample 3:\n\nInput: grid = [\"M.C...F\"], catJump = 1, mouseJump = 3\nOutput: false\n\nConstraints:\n\n- rows == grid.length\n- cols = grid[i].length\n- 1 <= rows, cols <= 8\n- grid[i][j] consist only of characters 'C', 'M', 'F', '.', and '#'.\n- There is only one of each character 'C', 'M', and 'F' in grid.\n- 1 <= catJump, mouseJump <= 8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = ['...M.', '.F#C.', '.....'],catJump = 2,mouseJump = 2) == True\n assert candidate(grid = ['M....', '.....', 'C.F..'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['C.......', '........', '........', '........', '........', '........', '........', '.......M'],catJump = 5,mouseJump = 5) == False\n assert candidate(grid = ['M......', '#F.C.#.'],catJump = 2,mouseJump = 3) == False\n assert candidate(grid = ['M....', '.F.C.', '.....'],catJump = 1,mouseJump = 1) == True\n assert candidate(grid = ['M....', '.#C..', '..#F.', '.....'],catJump = 3,mouseJump = 1) == False\n assert candidate(grid = ['M....', '.....', '.F.C.'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M.C...F'],catJump = 1,mouseJump = 4) == True\n assert candidate(grid = ['####F', '#C...', 'M....'],catJump = 1,mouseJump = 2) == True\n assert candidate(grid = ['M......', '.......', '..F....', '....C..'],catJump = 3,mouseJump = 4) == True\n assert candidate(grid = ['MC..F', '.....', '.....'],catJump = 2,mouseJump = 2) == False\n assert candidate(grid = ['M.C...F'],catJump = 1,mouseJump = 3) == False\n assert candidate(grid = ['M...F', '#..C.', '......'],catJump = 2,mouseJump = 1) == False\n assert candidate(grid = ['MC..F', '#####'],catJump = 2,mouseJump = 2) == False\n assert candidate(grid = ['.......', '.#....#', '.#....#', '.#.....', '.#....#', '.#....#', 'C......'],catJump = 5,mouseJump = 3) == True\n assert candidate(grid = ['M...', '....', '#...', 'C.F.'],catJump = 1,mouseJump = 3) == True\n assert candidate(grid = ['M....', '.....', '#C.F.', '.....', '.....'],catJump = 3,mouseJump = 2) == False\n assert candidate(grid = ['M...#', '...C.', '.....', '.....', '..F..'],catJump = 2,mouseJump = 2) == True\n assert candidate(grid = ['M....', '.....', '.....', '..C..', '...F.'],catJump = 1,mouseJump = 4) == True\n assert candidate(grid = ['M.....', '......', '......', '......', '......', '......', '...F..', '....C.'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M...F', '.#C.#', '...#.', '.....', '....#'],catJump = 2,mouseJump = 3) == True\n assert candidate(grid = ['M......', '.......', '.......', '....#..', '....C..', '.......', '....F..'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M....', '.....', '.....', '...C.', '..#F.'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M......', '.......', '.......', '......#', '....C..', '.......', '....F..'],catJump = 2,mouseJump = 4) == False\n assert candidate(grid = ['M......', '.......', '.....#C', '......#', '.......', '#F.....', '.......'],catJump = 3,mouseJump = 3) == True\n assert candidate(grid = ['.......', '.M.....', '.#C..#.', '.#F..#.', '.#.....', '.#.....', '.......'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M.......', '........', '........', '........', '........', '.....C..', '........', '........', '.......F'],catJump = 4,mouseJump = 4) == False\n assert candidate(grid = ['M...F', '..#C.', '.....', '.....', '.....'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M........', '........#', '.........', '#........', '........C', '.........', '.......F.'],catJump = 7,mouseJump = 2) == False\n assert candidate(grid = ['.......', '.#....#', '.#....#', '.#C.M#.', '.#....#', '.#....#', '.......'],catJump = 3,mouseJump = 3) == False\n assert candidate(grid = ['M......', '.#....#', '..#F...', '#......', '......C'],catJump = 4,mouseJump = 1) == False\n assert candidate(grid = ['######', '#M...#', '#.#F#.', '#.....', '######'],catJump = 2,mouseJump = 3) == False\n assert candidate(grid = ['M.......', '........', '.####...', '.....#..', '......#F', '........', '........', '.....C..'],catJump = 2,mouseJump = 1) == False\n assert candidate(grid = ['M......', '.......', '.......', '......#', '....C..', '.......', '....F..'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M........', '.........', '.........', '.........', '.........', '.........', '......C..', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'F........'],catJump = 7,mouseJump = 7) == True\n assert candidate(grid = ['M....', '.....', '...C.', '#####', '....F'],catJump = 2,mouseJump = 1) == False\n assert candidate(grid = ['M....', '.....', '.....', '.....', '#....', 'C....', '..F..'],catJump = 4,mouseJump = 3) == False\n assert candidate(grid = ['M....', '.....', '....C', '....F', '.....'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M........', '.........', '.........', '.........', '.........', '.........', '........C', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'F........'],catJump = 5,mouseJump = 5) == True\n assert candidate(grid = ['M.....', '......', '......', '......', '......', '......', '...F..', '..C...'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M....#.', '.#....#', '.#....#', '.#.....', '.#....#', '.#....#', '.F....C'],catJump = 3,mouseJump = 4) == False\n assert candidate(grid = ['M....', '.#C..', '..#F.', '.....'],catJump = 3,mouseJump = 2) == False\n assert candidate(grid = ['.......', '.......', '.......', '...C...', '...M...', '.......', '...F...'],catJump = 5,mouseJump = 5) == True\n assert candidate(grid = ['M..#....', '......#.', '......#C', '......#.', '......#.', '......F.', '........'],catJump = 3,mouseJump = 3) == False\n assert candidate(grid = ['M....', '.####', '..F..', '....C'],catJump = 2,mouseJump = 1) == False\n assert candidate(grid = ['M....F...', '.#..#....', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M.F....', '......C', '......#', '........', '........'],catJump = 3,mouseJump = 2) == True\n assert candidate(grid = ['M....', '.####', '..F..', '....C'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'F........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'C........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........'],catJump = 8,mouseJump = 8) == False\n assert candidate(grid = ['M....', '.....', '.F.C.', '.....', '.....'],catJump = 3,mouseJump = 3) == False\n assert candidate(grid = ['M....', '#....', '..C..', '....F', '.....'],catJump = 2,mouseJump = 2) == False\n assert candidate(grid = ['.......', '.#....#', '.#....#', '.#.....', '.#....#', '.#....#', 'F......'],catJump = 3,mouseJump = 3) == False\n assert candidate(grid = ['M......', '.......', '.......', '....C..', '.......', '.......', '......F'],catJump = 2,mouseJump = 3) == False\n assert candidate(grid = ['.........', '.........', '.........', '.........', '........C', '........M', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'F........'],catJump = 6,mouseJump = 6) == True\n assert candidate(grid = ['M.......', '........', '........', '...F....', '........', '........', '........', '.......C'],catJump = 6,mouseJump = 2) == False\n assert candidate(grid = ['M....', '#..C.', '...#F', '....#', '.....'],catJump = 2,mouseJump = 2) == False\n assert candidate(grid = ['M....', '.....', '#....', '..C..', '...F.'],catJump = 3,mouseJump = 1) == False\n", "comparison": "exact"}, "public_tests": ["[\"####F\",\"#C...\",\"M....\"]\n1\n2", "[\"M.C...F\"]\n1\n4", "[\"M.C...F\"]\n1\n3"], "hints": ["Try working backward: consider all trivial states you know to be winning or losing, and work backward to determine which other states can be labeled as winning or losing."], "metadata": {"canonical_parameter_names": ["grid", "catJump", "mouseJump"], "leetcode_dataset_entry_point": "Solution().canMouseWin", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:54+00:00", "tests_total": 57, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "math", "dynamic-programming", "graph", "topological-sort", "memoization", "minimax-algorithm", "matrix", "game-theory", "zero-sum-game"]}, "language": "python", "interface": {"raw_signature": "def canMouseWin(self, grid: list[str], catJump: int, mouseJump: int) -> bool:", "container": "Solution", "callable": "canMouseWin", "parameters": [{"name": "grid", "type": "list[str]"}, {"name": "catJump", "type": "int"}, {"name": "mouseJump", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1732, "task_id": "find-the-highest-altitude", "difficulty": "Easy", "problem_description": "There is a biker going on a road trip. The road trip consists of n + 1 points at various altitudes. The biker starts his trip on point 0 with altitude equal 0.\n\nYou are given an integer array gain of length n where gain[i] is the net gain in altitude between points i and i + 1 for all (0 <= i < n). Return the highest altitude of a point.\n\nExample 1:\n\nInput: gain = [-5,1,5,0,-7]\nOutput: 1\nExplanation: The altitudes are [0,-5,-4,1,1,-6]. The highest is 1.\n\nExample 2:\n\nInput: gain = [-4,-3,-2,-1,4,3,2]\nOutput: 0\nExplanation: The altitudes are [0,-4,-7,-9,-10,-6,-3,-1]. The highest is 0.\n\nConstraints:\n\n- n == gain.length\n- 1 <= n <= 100\n- -100 <= gain[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(gain = [4, 3, 2, 1, 0, -1, -2, -3, -4]) == 10\n assert candidate(gain = [-1, -2, -3, -4]) == 0\n assert candidate(gain = [-10, -20, -30, -40, -50]) == 0\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 100]) == 145\n assert candidate(gain = [-1, 1, -1, 1, -1, 1]) == 0\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [-5, -4, -3, -2, -1]) == 0\n assert candidate(gain = [5, 5, 5, 5]) == 20\n assert candidate(gain = [-100, 50, -50, 100, -100]) == 0\n assert candidate(gain = [-100, 100, -100, 100, -100]) == 0\n assert candidate(gain = [100, -100, 100, -100, 100]) == 100\n assert candidate(gain = [1, 2, 3, 4, 5]) == 15\n assert candidate(gain = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -100]) == 0\n assert candidate(gain = [-1, -2, -3, -4, -5]) == 0\n assert candidate(gain = [1, -1, 1, -1, 1, -1]) == 1\n assert candidate(gain = [-50, 50, -25, 25, -12, 12]) == 0\n assert candidate(gain = [10, 20, 30, 40, 50]) == 150\n assert candidate(gain = [0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [100, -50, 50, -100, 50]) == 100\n assert candidate(gain = [100, -100, 50, -50, 25, -25]) == 100\n assert candidate(gain = [100, -100, 100, -100]) == 100\n assert candidate(gain = [-5, 1, 5, 0, -7]) == 1\n assert candidate(gain = [0, 0, 0, 0]) == 0\n assert candidate(gain = [50, 50, 50, 50, 50]) == 250\n assert candidate(gain = [-4, -3, -2, -1, 4, 3, 2]) == 0\n assert candidate(gain = [23, -15, 42, -5, 0, 17, -30, 29]) == 62\n assert candidate(gain = [-10, -20, 30, 40, -50, 60, -70, 80, -90, 100]) == 70\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [10, -5, 15, -20, 25, -30, 35, -40]) == 30\n assert candidate(gain = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(gain = [100, -100, 100, -100, 100, -100, 100, -100]) == 100\n assert candidate(gain = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5]) == 50\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 10\n assert candidate(gain = [100, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -98]) == 100\n assert candidate(gain = [10, -5, 3, 2, -3, 4, -2, 5, -6, 1]) == 14\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [100, -1, 99, -2, 98, -3, 97, -4, 96, -5, 95, -6, 94, -7, 93, -8, 92, -9, 91, -10]) == 910\n assert candidate(gain = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 15\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 55\n assert candidate(gain = [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1]) == 0\n assert candidate(gain = [10, -5, 3, 2, -3, 4, -1, -2, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16]) == 18\n assert candidate(gain = [5, -3, 20, -20, 30, -10, 15, -5, 25, -15, 10, -5, 30, -30, 40]) == 87\n assert candidate(gain = [10, 15, 20, 25, 30, 35, 40, 45, 50, -100]) == 270\n assert candidate(gain = [50, -20, 30, -10, 40, -5, 60, -25, 70, -10]) == 190\n assert candidate(gain = [0, 25, -25, 50, -50, 100, -100]) == 100\n assert candidate(gain = [20, 30, -10, -40, 50, 10, -20, 30, -40, 50]) == 80\n assert candidate(gain = [5, 10, 15, 20, 25, -5, -10, -15, -20, -25, 5, 10, 15, 20, 25, -5, -10, -15, -20, -25]) == 75\n assert candidate(gain = [99, -50, 50, -100, 100, -99, 99, -49, 49, -51, 51, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == 99\n assert candidate(gain = [100, -25, 25, -50, 50, -75, 75, -100, 100]) == 100\n assert candidate(gain = [10, -5, 3, -2, 8, -4, 6, -3, 5, -1, 7, -2, 9, -4, 11, -5, 13, -6, 15, -7]) == 55\n assert candidate(gain = [5, 5, 5, 5, 5, -5, -5, -5, -5, -5, 10, 10, -10, -10, 15]) == 25\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11]) == 210\n assert candidate(gain = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(gain = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 5\n assert candidate(gain = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100]) == 100\n assert candidate(gain = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5]) == 0\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 10\n assert candidate(gain = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 15\n assert candidate(gain = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, 50, -50, 40, -40, 30, -30, 20, -20, 10, -10]) == 150\n assert candidate(gain = [-5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5]) == 0\n assert candidate(gain = [0, 20, -10, 5, -3, 15, -10]) == 27\n assert candidate(gain = [10, -5, 3, 8, -2, 15, -7, 20]) == 42\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(gain = [-10, -20, -30, -40, -50, 10, 20, 30, 40, 50, -1, -2, -3, -4, -5, 1, 2, 3, 4, 5]) == 0\n assert candidate(gain = [-5, -10, -15, 20, 25, -30, 35, -40, 45, -50, 55, -60, 65, -70, 75, -80, 85, -90, 95]) == 50\n assert candidate(gain = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 50\n assert candidate(gain = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 50\n assert candidate(gain = [99, -99, 98, -98, 97, -97, 96, -96, 95, -95]) == 99\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30]) == 15\n assert candidate(gain = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(gain = [5, 10, 15, 20, 25, 30, -5, -10, -15, -20, -25, -30]) == 105\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 5\n assert candidate(gain = [100, -50, 25, -12, 50, -25, 60, -30, 70, -35, 80, -40, 90, -45, 100]) == 338\n assert candidate(gain = [-10, 10, -10, 10, -10, 10, -10, 10, -10, 10]) == 0\n assert candidate(gain = [20, -10, 30, -15, 40, -20, 50, -25, 60, -30, 70, -35, 80, -40, 90]) == 265\n assert candidate(gain = [10, -10, 20, -20, 30, -30, 40, -40, 50]) == 50\n assert candidate(gain = [2, 3, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25]) == 17\n assert candidate(gain = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -15, -20, -25, -30, -35, -40, -45, -50]) == 275\n assert candidate(gain = [-10, -20, -30, -40, -50, 50, 40, 30, 20, 10]) == 0\n assert candidate(gain = [1, 1, 1, 1, 1, 1, 1, 1, 1, -10]) == 9\n assert candidate(gain = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(gain = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 10\n assert candidate(gain = [-50, 0, 50, 0, -50, 0, 50, 0, -50, 0, 50, 0, -50, 0, 50]) == 0\n assert candidate(gain = [0, 20, -10, 30, -20, 10, -30, 40, -50, 60]) == 50\n assert candidate(gain = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 50\n assert candidate(gain = [100, -50, 50, -50, 100, -50, 50, -50, 100]) == 200\n assert candidate(gain = [100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99]) == 114\n assert candidate(gain = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9]) == 9\n assert candidate(gain = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 10\n assert candidate(gain = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25, -26, 27, -28, 29, -30]) == 15\n assert candidate(gain = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25]) == 25\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 210\n assert candidate(gain = [10, -20, 30, -40, 50, -60, 70]) == 40\n assert candidate(gain = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 50\n assert candidate(gain = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 15\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 55\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30, -30]) == 15\n assert candidate(gain = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 10\n assert candidate(gain = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(gain = [100, -99, 98, -97, 96, -95, 94, -93, 92, -91, 90, -89, 88, -87, 86, -85, 84, -83, 82, -81, 80]) == 100\n assert candidate(gain = [2, 4, -3, 1, -2, 1, 5, -4, 3, -1, 0, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 12\n assert candidate(gain = [100, -50, 50, -100, 50, -50, 100, -100, 50, -50]) == 100\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 100\n assert candidate(gain = [-50, 50, -50, 50, -50, 50, -50, 50]) == 0\n assert candidate(gain = [-1, 3, -2, 4, -3, 5, -4, 6, -5, 7]) == 10\n", "comparison": "exact"}, "public_tests": ["[-5,1,5,0,-7]", "[-4,-3,-2,-1,4,3,2]"], "hints": ["Let's note that the altitude of an element is the sum of gains of all the elements behind it", "Getting the altitudes can be done by getting the prefix sum array of the given array"], "metadata": {"canonical_parameter_names": ["gain"], "leetcode_dataset_entry_point": "Solution().largestAltitude", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:28:59+00:00", "tests_total": 110, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def largestAltitude(self, gain: list[int]) -> int:", "container": "Solution", "callable": "largestAltitude", "parameters": [{"name": "gain", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1733, "task_id": "minimum-number-of-people-to-teach", "difficulty": "Medium", "problem_description": "On a social network consisting of m users and some friendships between users, two users can communicate with each other if they know a common language.\n\nYou are given an integer n, an array languages, and an array friendships where:\n\n- There are n languages numbered 1 through n,\n- languages[i] is the set of languages the i^th user knows, and\n- friendships[i] = [u_i, v_i] denotes a friendship between the users u_i and v_i.\n\nYou can choose one language and teach it to some users so that all friends can communicate with each other. Return the minimum number of users you need to teach.\n\nNote that friendships are not transitive, meaning if x is a friend of y and y is a friend of z, this doesn't guarantee that x is a friend of z.\n\nExample 1:\n\nInput: n = 2, languages = [[1],[2],[1,2]], friendships = [[1,2],[1,3],[2,3]]\nOutput: 1\nExplanation: You can either teach user 1 the second language or user 2 the first language.\n\nExample 2:\n\nInput: n = 3, languages = [[2],[1,3],[1,2],[3]], friendships = [[1,4],[1,2],[3,4],[2,3]]\nOutput: 2\nExplanation: Teach the third language to users 1 and 3, yielding two users to teach.\n\nConstraints:\n\n- 2 <= n <= 500\n- languages.length == m\n- 1 <= m <= 500\n- 1 <= languages[i].length <= n\n- 1 <= languages[i][j] <= n\n- 1 <= u_i < v_i <= languages.length\n- 1 <= friendships.length <= 500\n- All tuples (u_i,v_i) are unique\n- languages[i] contains only unique values\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,languages = [[1], [2], [3], [4]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 3\n assert candidate(n = 3,languages = [[1, 2], [2, 3], [3, 1]],friendships = [[1, 2], [2, 3], [3, 1]]) == 0\n assert candidate(n = 5,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(n = 2,languages = [[1], [2], [1, 2]],friendships = [[1, 2], [1, 3], [2, 3]]) == 1\n assert candidate(n = 4,languages = [[1, 3], [2, 4], [1, 2], [3, 4]],friendships = [[1, 2], [2, 3], [3, 4]]) == 2\n assert candidate(n = 4,languages = [[1], [2], [3], [4]],friendships = [[1, 2], [2, 3], [3, 4], [1, 4]]) == 3\n assert candidate(n = 5,languages = [[1], [2], [3], [4], [5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 4\n assert candidate(n = 3,languages = [[2], [1, 3], [1, 2], [3]],friendships = [[1, 4], [1, 2], [3, 4], [2, 3]]) == 2\n assert candidate(n = 2,languages = [[1, 2], [1, 2]],friendships = [[1, 2]]) == 0\n assert candidate(n = 3,languages = [[1, 2, 3], [2, 3], [1, 3]],friendships = [[1, 2], [2, 3], [1, 3]]) == 0\n assert candidate(n = 5,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 0\n assert candidate(n = 4,languages = [[1, 2], [3, 4], [1, 3], [2, 4]],friendships = [[1, 2], [1, 3], [2, 3], [3, 4]]) == 2\n assert candidate(n = 5,languages = [[1], [2], [3], [4], [5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 4\n assert candidate(n = 4,languages = [[1], [2], [3], [4]],friendships = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]) == 3\n assert candidate(n = 10,languages = [[1, 2, 3], [4, 5], [6, 7], [8, 9], [10]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5]]) == 4\n assert candidate(n = 6,languages = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]],friendships = [[1, 2], [3, 4], [5, 6]]) == 4\n assert candidate(n = 4,languages = [[1, 2], [2, 3], [3, 4], [4, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1], [1, 3], [2, 4], [1, 4], [2, 3], [1, 2], [3, 4]]) == 2\n assert candidate(n = 10,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 1], [10, 1, 2]],friendships = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 3\n assert candidate(n = 12,languages = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 1]]) == 11\n assert candidate(n = 6,languages = [[1], [2], [3], [4], [5], [6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]]) == 5\n assert candidate(n = 3,languages = [[1, 3], [2], [1, 2], [3, 2]],friendships = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4]]) == 1\n assert candidate(n = 9,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 1], [9, 2]]) == 7\n assert candidate(n = 5,languages = [[1, 2, 3], [4, 5], [1, 4], [2, 5], [3]],friendships = [[1, 4], [2, 5], [3, 5], [1, 3], [2, 4]]) == 1\n assert candidate(n = 3,languages = [[1], [2], [3], [1, 2], [2, 3], [1, 3]],friendships = [[1, 2], [2, 3], [1, 3], [4, 5], [5, 6], [4, 6]]) == 2\n assert candidate(n = 10,languages = [[1, 2, 3], [4, 5], [6, 7, 8], [9, 10], [1, 5, 9], [2, 6, 10], [3, 7, 4], [8, 1]],friendships = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 5], [2, 6], [3, 7], [4, 8], [5, 7], [6, 8]]) == 5\n assert candidate(n = 8,languages = [[1], [2], [3], [4], [5], [6], [7], [8]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 1], [8, 2]]) == 7\n assert candidate(n = 8,languages = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 3], [2, 4], [5, 7], [6, 8]],friendships = [[1, 3], [2, 4], [5, 7], [6, 8], [1, 5], [2, 6], [3, 7], [4, 8]]) == 6\n assert candidate(n = 8,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 1], [8, 2]]) == 6\n assert candidate(n = 4,languages = [[1, 2], [3, 4], [2, 3], [1, 4]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 2\n assert candidate(n = 9,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]) == 0\n assert candidate(n = 5,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 0\n assert candidate(n = 7,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 1], [7, 1, 2]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 1], [7, 2]]) == 0\n assert candidate(n = 10,languages = [[1, 3, 5], [2, 4, 6], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [1, 4], [2, 5], [3, 6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 7\n assert candidate(n = 10,languages = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 9\n assert candidate(n = 5,languages = [[1], [2], [3], [4], [5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5], [4, 1], [5, 2]]) == 4\n assert candidate(n = 3,languages = [[1], [1, 3], [2], [2, 3], [3]],friendships = [[1, 3], [2, 3], [4, 5]]) == 1\n assert candidate(n = 10,languages = [[1, 3, 5], [2, 4, 6], [1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 1], [2, 3, 4]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 6\n assert candidate(n = 10,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 0\n assert candidate(n = 15,languages = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9], [6, 7, 8, 9, 10], [7, 8, 9, 10, 11], [8, 9, 10, 11, 12], [9, 10, 11, 12, 13], [10, 11, 12, 13, 14], [11, 12, 13, 14, 15], [1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 1], [15, 2]]) == 2\n assert candidate(n = 5,languages = [[1], [2], [3], [4], [5], [1, 2], [3, 4], [4, 5], [1, 3], [2, 5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 7\n assert candidate(n = 7,languages = [[1, 2], [3, 4], [5, 6], [7], [1, 3], [2, 4], [5, 7]],friendships = [[1, 3], [1, 5], [1, 7], [2, 4], [2, 6], [3, 5], [3, 7], [4, 6], [4, 7], [5, 6]]) == 5\n assert candidate(n = 5,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5], [4, 1], [5, 2]]) == 3\n assert candidate(n = 10,languages = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],friendships = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 9\n assert candidate(n = 7,languages = [[1, 2, 3, 4], [5, 6], [7], [1, 2], [3, 4], [5, 6], [7]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]]) == 5\n assert candidate(n = 4,languages = [[1, 2], [2, 3], [3, 4], [4, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 0\n assert candidate(n = 7,languages = [[1], [2], [3], [4], [5], [6], [7]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 1], [7, 2]]) == 6\n assert candidate(n = 8,languages = [[1], [1], [1], [1], [2], [2], [2], [2]],friendships = [[1, 5], [2, 6], [3, 7], [4, 8]]) == 4\n assert candidate(n = 7,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]],friendships = [[1, 3], [3, 5], [5, 7], [7, 2], [2, 4], [4, 6]]) == 5\n assert candidate(n = 7,languages = [[1], [2], [3], [1, 4], [5, 6], [6, 7], [7]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]]) == 4\n assert candidate(n = 5,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 1], [5, 1, 2]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 0\n assert candidate(n = 7,languages = [[1, 3, 5], [2, 4, 6], [1, 2, 3], [4, 5, 6], [1, 4, 7], [2, 5, 7], [3, 6, 7]],friendships = [[1, 2], [3, 4], [5, 6], [7, 1], [2, 5], [4, 7], [6, 3]]) == 2\n assert candidate(n = 6,languages = [[1], [2], [3], [4], [5], [6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == 5\n assert candidate(n = 4,languages = [[1, 2], [2, 3], [3, 4], [1, 4]],friendships = [[1, 2], [2, 3], [3, 4], [1, 4]]) == 0\n assert candidate(n = 6,languages = [[1], [2], [3], [4], [5], [6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == 5\n assert candidate(n = 6,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == 0\n assert candidate(n = 3,languages = [[1, 2], [2, 3], [1, 3]],friendships = [[1, 2], [2, 3], [1, 3], [1, 2], [2, 3], [1, 3]]) == 0\n assert candidate(n = 3,languages = [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 0\n assert candidate(n = 4,languages = [[1, 2], [3, 4], [2, 3], [1, 4], [1, 3]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 5]]) == 2\n assert candidate(n = 4,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 1], [4, 1, 2]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 0\n assert candidate(n = 5,languages = [[1, 2, 3, 4, 5]],friendships = [[1, 1], [1, 1], [1, 1]]) == 0\n assert candidate(n = 4,languages = [[1, 2], [2, 3], [3, 4], [1, 4]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1], [1, 3], [2, 4]]) == 2\n assert candidate(n = 10,languages = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],friendships = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 9\n assert candidate(n = 8,languages = [[1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [1, 8]]) == 1\n assert candidate(n = 6,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6], [1, 3], [2, 4], [3, 5], [4, 6], [1, 5], [2, 6]]) == 4\n assert candidate(n = 5,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [1, 2], [4, 5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 5]]) == 2\n assert candidate(n = 5,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 1], [5, 1, 2]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 0\n assert candidate(n = 10,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 0\n assert candidate(n = 6,languages = [[1, 2, 3], [4, 5, 6], [1, 4], [2, 5], [3, 6], [1, 2, 3, 4, 5, 6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 3], [2, 4], [3, 5], [4, 6], [1, 5], [2, 6]]) == 3\n assert candidate(n = 6,languages = [[1], [2], [3], [4], [5], [6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]]) == 5\n assert candidate(n = 12,languages = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [1, 4, 7, 10], [2, 5, 8, 11], [3, 6, 9, 12], [1, 5, 9, 12], [2, 6, 10, 11], [3, 4, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]],friendships = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 10], [8, 11], [8, 12], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12]]) == 7\n assert candidate(n = 7,languages = [[1], [2], [3], [4], [5], [6], [7]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 1], [7, 2]]) == 6\n assert candidate(n = 8,languages = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 3], [2, 4], [5, 7], [6, 8]],friendships = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 3], [2, 4], [5, 7], [6, 8]]) == 6\n assert candidate(n = 5,languages = [[1, 2], [3, 4], [1, 3], [2, 5], [4, 5]],friendships = [[1, 2], [3, 4], [2, 3], [4, 5], [1, 3]]) == 2\n", "comparison": "exact"}, "public_tests": ["2\n[[1],[2],[1,2]]\n[[1,2],[1,3],[2,3]]", "3\n[[2],[1,3],[1,2],[3]]\n[[1,4],[1,2],[3,4],[2,3]]"], "hints": ["You can just use brute force and find out for each language the number of users you need to teach", "Note that a user can appear in multiple friendships but you need to teach that user only once"], "metadata": {"canonical_parameter_names": ["n", "languages", "friendships"], "leetcode_dataset_entry_point": "Solution().minimumTeachings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:01+00:00", "tests_total": 73, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minimumTeachings(self, n: int, languages: list[list[int]], friendships: list[list[int]]) -> int:", "container": "Solution", "callable": "minimumTeachings", "parameters": [{"name": "n", "type": "int"}, {"name": "languages", "type": "list[list[int]]"}, {"name": "friendships", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1734, "task_id": "decode-xored-permutation", "difficulty": "Medium", "problem_description": "There is an integer array perm that is a permutation of the first n positive integers, where n is always odd.\n\nIt was encoded into another integer array encoded of length n - 1, such that encoded[i] = perm[i] XOR perm[i + 1]. For example, if perm = [1,3,2], then encoded = [2,1].\n\nGiven the encoded array, return the original array perm. It is guaranteed that the answer exists and is unique.\n\nExample 1:\n\nInput: encoded = [3,1]\nOutput: [1,2,3]\nExplanation: If perm = [1,2,3], then encoded = [1 XOR 2,2 XOR 3] = [3,1]\n\nExample 2:\n\nInput: encoded = [6,5,4,6]\nOutput: [2,4,1,5,3]\n\nConstraints:\n\n- 3 <= n < 10^5\n- n is odd.\n- encoded.length == n - 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(encoded = [15, 8, 12, 4, 1]) == [11, 4, 12, 0, 4, 5]\n assert candidate(encoded = [1, 7, 6, 5, 4, 3]) == [1, 0, 7, 1, 4, 0, 3]\n assert candidate(encoded = [6, 5, 4, 6]) == [2, 4, 1, 5, 3]\n assert candidate(encoded = [8, 12, 4, 6, 1, 3, 5]) == [1, 9, 5, 1, 7, 6, 5, 0]\n assert candidate(encoded = [2, 3, 1, 4, 7]) == [0, 2, 1, 0, 4, 3]\n assert candidate(encoded = [8, 13, 10, 3, 7, 12, 9]) == [10, 2, 15, 5, 6, 1, 13, 4]\n assert candidate(encoded = [2, 3, 1, 6, 7, 0]) == [5, 7, 4, 5, 3, 4, 4]\n assert candidate(encoded = [1, 5, 7]) == [1, 0, 5, 2]\n assert candidate(encoded = [8, 9, 10, 11, 12, 13, 14]) == [7, 15, 6, 12, 7, 11, 6, 8]\n assert candidate(encoded = [7, 8, 9, 10, 11, 12]) == [14, 9, 1, 8, 2, 9, 5]\n assert candidate(encoded = [15, 10, 5, 2, 1, 4]) == [12, 3, 9, 12, 14, 15, 11]\n assert candidate(encoded = [2, 3, 2]) == [7, 5, 6, 4]\n assert candidate(encoded = [1, 0, 1, 0, 1]) == [7, 6, 6, 7, 7, 6]\n assert candidate(encoded = [7, 3, 5]) == [7, 0, 3, 6]\n assert candidate(encoded = [1, 6, 5, 4, 3, 2]) == [0, 1, 7, 2, 6, 5, 7]\n assert candidate(encoded = [2, 3, 1, 4, 5]) == [0, 2, 1, 0, 4, 1]\n assert candidate(encoded = [3, 1]) == [1, 2, 3]\n assert candidate(encoded = [123, 234, 345, 456, 567, 678, 789, 890, 901, 1002]) == [788, 879, 901, 732, 788, 291, 901, 144, 1002, 111, 901]\n assert candidate(encoded = [14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58]) == [9, 7, 21, 3, 25, 7, 37, 3, 41, 7, 53, 3, 57]\n assert candidate(encoded = [15, 10, 5, 3, 2, 1, 4]) == [0, 15, 5, 0, 3, 1, 0, 4]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35]) == [8, 13, 7, 8, 28, 5, 27, 56]\n assert candidate(encoded = [2, 15, 18, 17, 20, 23, 22, 25, 28]) == [27, 25, 22, 4, 21, 1, 22, 0, 25, 5]\n assert candidate(encoded = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [3, 2, 0, 3, 7, 2, 4, 3, 11, 2, 8, 3, 15, 2, 12, 3, 19, 2, 16, 3, 23, 2, 20, 3, 27, 2]\n assert candidate(encoded = [77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198]) == [95, 18, 74, 41, 71, 62, 186, 53, 175, 10, 186, 1, 199]\n assert candidate(encoded = [9, 20, 27, 34, 41, 48, 55]) == [14, 7, 19, 8, 42, 3, 51, 4]\n assert candidate(encoded = [7, 2, 5, 8, 3, 6, 1, 4, 9]) == [3, 4, 6, 3, 11, 8, 14, 15, 11, 2]\n assert candidate(encoded = [65, 131, 263, 527, 1055, 2111, 4223, 8447, 16895, 33791, 67583, 135167]) == [173645, 173580, 173711, 173960, 173447, 172440, 174503, 178648, 170279, 186584, 154407, 220376, 86823]\n assert candidate(encoded = [7, 18, 27, 34, 41, 48, 55]) == [8, 15, 29, 6, 36, 13, 61, 10]\n assert candidate(encoded = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323]) == [583287, 583284, 583293, 583270, 583223, 583364, 582685, 584854, 587063, 571860, 548733, 715910, 194423, 1746084]\n assert candidate(encoded = [2, 7, 13, 18, 24, 30, 36, 42, 48, 54, 60]) == [27, 25, 30, 19, 1, 25, 7, 35, 9, 57, 15, 51]\n assert candidate(encoded = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39]) == [39, 36, 35, 40, 39, 52, 35, 56, 39, 4, 35]\n assert candidate(encoded = [31, 34, 37, 40, 43, 46, 49]) == [44, 51, 17, 52, 28, 55, 25, 40]\n assert candidate(encoded = [255, 222, 199, 176, 153, 130, 107, 84]) == [185, 70, 152, 95, 239, 118, 244, 159, 203]\n assert candidate(encoded = [19, 22, 25, 28, 31, 34, 37]) == [32, 51, 37, 60, 32, 63, 29, 56]\n assert candidate(encoded = [15, 22, 13, 20, 9, 16, 11]) == [26, 21, 3, 14, 26, 19, 3, 8]\n assert candidate(encoded = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650]) == [93, 57, 175, 103, 157, 433, 239, 383, 189, 329, 879, 311, 957]\n assert candidate(encoded = [15, 22, 3, 26, 11, 28, 7, 30, 13, 32, 9, 34, 5, 36, 1]) == [56, 55, 33, 34, 56, 51, 47, 40, 54, 59, 27, 18, 48, 53, 17, 16]\n assert candidate(encoded = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [3267, 4924, 7363, 6972, 6339, 6460, 6595, 6588, 6531, 6556, 6547, 6548, 6551, 6550]\n assert candidate(encoded = [4, 12, 8, 16, 10, 18, 14]) == [6, 2, 14, 6, 22, 28, 14, 0]\n assert candidate(encoded = [42, 35, 26, 15, 4, 17, 38, 67, 114, 181, 278, 399]) == [325, 367, 332, 342, 345, 349, 332, 362, 297, 347, 494, 248, 375]\n assert candidate(encoded = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [968, 940, 868, 584, 984, 556, 116, 712, 488, 620, 388]\n assert candidate(encoded = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245]) == [250, 5, 251, 6, 250, 1, 251, 2, 250, 13, 251, 14]\n assert candidate(encoded = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304]) == [2796223, 2796219, 2796211, 2796195, 2796163, 2796227, 2796099, 2796355, 2795843, 2796867, 2794819, 2798915, 2790723, 2807107, 2774339, 2839875, 2708803, 2970947, 2446659, 3495235, 1398083, 5592387]\n assert candidate(encoded = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78]) == [14, 2, 12, 28, 14, 26, 12, 20, 14, 18, 12, 44, 14, 42, 12, 36, 14, 34, 12, 60, 14, 58, 12, 52, 14, 50, 12, 76, 14, 74, 12, 68, 14, 66, 12]\n assert candidate(encoded = [24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64]) == [16, 8, 20, 52, 16, 56, 20, 36, 16, 40, 20, 84]\n assert candidate(encoded = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == [11, 14, 9, 0, 11, 6, 9, 24, 11, 30, 9, 16]\n assert candidate(encoded = [5, 8, 11, 14, 17, 20, 23, 26, 29, 32]) == [40, 45, 37, 46, 32, 49, 37, 50, 40, 53, 21]\n assert candidate(encoded = [17, 19, 21, 23, 25, 27, 29, 31]) == [1, 16, 3, 22, 1, 24, 3, 30, 1]\n assert candidate(encoded = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [19, 22, 17, 24, 19, 30, 17, 0, 19, 6, 17, 8, 19, 14]\n assert candidate(encoded = [99, 198, 297, 396, 495, 594, 693, 792, 891, 990, 1089]) == [978, 945, 887, 606, 978, 573, 111, 730, 450, 697, 359, 1318]\n assert candidate(encoded = [2047, 4094, 2047, 4094, 2047, 4094, 2047, 4094, 2047, 4094, 2047]) == [4082, 2061, 2035, 12, 4082, 2061, 2035, 12, 4082, 2061, 2035, 12]\n assert candidate(encoded = [2, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432, 1572864]) == [2097151, 2097149, 2097147, 2097143, 2097135, 2097119, 2097087, 2097023, 2096895, 2096639, 2096127, 2095103, 2093055, 2088959, 2080767, 2064383, 2031615, 1966079, 1835007, 1572863, 1048575]\n assert candidate(encoded = [30, 10, 20, 15, 25, 12, 22, 17, 27, 14, 24, 19, 29, 16, 26]) == [5, 27, 17, 5, 10, 19, 31, 9, 24, 3, 13, 21, 6, 27, 11, 17]\n assert candidate(encoded = [255, 128, 64, 32, 16, 8, 4, 2, 1]) == [161, 94, 222, 158, 190, 174, 166, 162, 160, 161]\n assert candidate(encoded = [15, 22, 33, 46, 59, 74, 91, 110, 131, 154]) == [134, 137, 159, 190, 144, 171, 225, 186, 212, 87, 205]\n assert candidate(encoded = [14, 11, 12, 15, 16, 19, 20, 23, 24, 27]) == [27, 21, 30, 18, 29, 13, 30, 10, 29, 5, 30]\n assert candidate(encoded = [31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == [838849, 838878, 838881, 838814, 838753, 839070, 839265, 838046, 837217, 842142, 845409, 825758, 812641, 891294, 943713, 629150, 419425]\n assert candidate(encoded = [11, 24, 29, 36, 43, 50, 57]) == [6, 13, 21, 8, 44, 7, 53, 12]\n assert candidate(encoded = [13, 22, 31, 40, 49, 58, 67]) == [12, 1, 23, 8, 32, 17, 43, 104]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85]) == [35, 38, 44, 35, 55, 46, 48, 19, 59, 22, 36, 19, 47, 110, 40, 99, 51, 102]\n assert candidate(encoded = [14, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [5, 11, 29, 9, 27, 11, 5, 9, 3, 11, 13, 9, 11]\n assert candidate(encoded = [7, 14, 21, 28, 35, 42, 49]) == [48, 55, 57, 44, 48, 19, 57, 8]\n assert candidate(encoded = [127, 63, 31, 15, 7, 3, 1]) == [59, 68, 123, 100, 107, 108, 111, 110]\n assert candidate(encoded = [27, 24, 21, 18, 15, 12, 9, 6, 3]) == [11, 16, 8, 29, 15, 0, 12, 5, 3, 0]\n assert candidate(encoded = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [409, 614, 921, 870, 793, 806, 825, 822, 817, 818, 819]\n assert candidate(encoded = [31, 28, 33, 30, 35, 32, 37]) == [42, 53, 41, 8, 22, 53, 21, 48]\n assert candidate(encoded = [15, 23, 19, 21, 17, 13, 9, 5, 1]) == [1, 14, 25, 10, 31, 14, 3, 10, 15, 14]\n assert candidate(encoded = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 6, 14, 7, 13, 6, 10, 7, 9, 6, 22, 7, 21, 6, 18, 7, 17, 6, 30, 7, 29, 6, 26, 7, 25]\n assert candidate(encoded = [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77]) == [29, 24, 17, 28, 13, 24, 1, 28, 61, 24, 49, 28, 45, 24, 33, 28, 93, 24, 81, 28]\n assert candidate(encoded = [4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [1639, 2456, 3687, 3480, 3175, 3224, 3303, 3288, 3271, 3272, 3279, 3276, 3277]\n assert candidate(encoded = [25, 30, 35, 40, 45, 50, 55]) == [12, 21, 11, 40, 0, 45, 31, 40]\n assert candidate(encoded = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34]) == [33, 37, 35, 43, 33, 45, 35, 51, 33, 53, 35, 59, 33, 61, 35, 3, 33]\n assert candidate(encoded = [32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [13091, 19676, 29475, 27868, 25379, 25820, 26403, 26332, 26147, 26204, 26211, 26236, 26227, 26228, 26231, 26230]\n assert candidate(encoded = [3, 10, 17, 24, 31, 38, 45]) == [60, 63, 53, 36, 60, 35, 5, 40]\n assert candidate(encoded = [13, 23, 37, 55, 77, 103, 133, 167, 205, 247, 293, 343, 397]) == [335, 322, 341, 368, 327, 266, 365, 488, 335, 386, 373, 80, 263, 138]\n assert candidate(encoded = [14, 23, 32, 41, 50, 59, 68]) == [13, 3, 20, 52, 29, 47, 20, 80]\n assert candidate(encoded = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [3, 26, 2, 21, 3, 22, 2, 17, 3, 18, 2, 13, 3, 14, 2, 9, 3, 10, 2, 5, 3, 6, 2, 1, 3, 2]\n assert candidate(encoded = [10, 20, 15, 25, 30, 22, 28, 19, 29, 12]) == [4, 14, 26, 21, 12, 18, 4, 24, 11, 22, 26]\n assert candidate(encoded = [23, 45, 12, 34, 56, 78, 90, 112, 134]) == [58, 45, 0, 12, 46, 22, 88, 2, 114, 244]\n assert candidate(encoded = [15, 22, 30, 39, 45, 51, 57, 63, 69]) == [54, 57, 47, 49, 22, 59, 8, 49, 14, 75]\n assert candidate(encoded = [3, 9, 15, 21, 27, 33, 39]) == [53, 54, 63, 48, 37, 62, 31, 56]\n assert candidate(encoded = [5, 12, 19, 26, 33, 40, 47]) == [54, 51, 63, 44, 54, 23, 63, 16]\n assert candidate(encoded = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [8, 10, 14, 8, 0, 10, 6, 8, 24, 10, 30, 8]\n assert candidate(encoded = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143]) == [197, 206, 216, 249, 213, 226, 160, 237, 181, 214, 184, 193, 69, 202]\n assert candidate(encoded = [63, 66, 69, 72, 75, 78, 81]) == [76, 115, 49, 116, 60, 119, 57, 104]\n assert candidate(encoded = [29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == [109, 112, 111, 74, 99, 72, 103, 82, 105, 84, 23, 80]\n assert candidate(encoded = [1023, 511, 255, 127, 63, 31, 15, 7]) == [409, 614, 921, 870, 793, 806, 825, 822, 817]\n assert candidate(encoded = [31, 30, 29, 28, 27, 26, 25, 24, 23]) == [11, 20, 10, 23, 11, 16, 10, 19, 11, 28]\n assert candidate(encoded = [13, 29, 61, 125, 253, 509, 1021, 2045, 4093, 8189, 16381, 32765, 65533, 131077, 262149]) == [157301, 157304, 157285, 157272, 157221, 157400, 157477, 156888, 156453, 158936, 160549, 150744, 144165, 183512, 52445, 314584]\n assert candidate(encoded = [9, 19, 31, 45, 61, 79, 99, 121, 145, 171, 199, 229, 261, 295, 331]) == [369, 376, 363, 372, 345, 356, 299, 328, 305, 416, 267, 460, 297, 44, 267, 64]\n assert candidate(encoded = [31, 14, 17, 9, 22, 15, 26, 11, 24]) == [8, 23, 25, 8, 1, 23, 24, 2, 9, 17]\n assert candidate(encoded = [4, 13, 12, 15, 10, 19, 18, 21, 14, 23, 22]) == [31, 27, 22, 26, 21, 31, 12, 30, 11, 5, 18, 4]\n assert candidate(encoded = [7, 13, 21, 31, 43, 57, 73, 91, 111, 133, 157, 183, 211, 241, 273]) == [163, 164, 169, 188, 163, 136, 177, 248, 163, 204, 73, 212, 99, 176, 65, 336]\n assert candidate(encoded = [15, 22, 17, 24, 19, 26, 21, 28, 23]) == [3, 12, 26, 11, 19, 0, 26, 15, 19, 4]\n assert candidate(encoded = [2, 3, 1, 6, 5, 4, 11, 10, 9, 16, 15, 14, 21, 20, 19]) == [17, 19, 16, 17, 23, 18, 22, 29, 23, 30, 14, 1, 15, 26, 14, 29]\n assert candidate(encoded = [15, 20, 17, 23, 18, 24, 19]) == [19, 28, 8, 25, 14, 28, 4, 23]\n assert candidate(encoded = [31, 29, 27, 25, 23, 21, 19, 17, 15]) == [11, 20, 9, 18, 11, 28, 9, 26, 11, 4]\n assert candidate(encoded = [65, 68, 71, 74, 77, 80, 83]) == [86, 23, 83, 20, 94, 19, 67, 16]\n assert candidate(encoded = [15, 20, 25, 30, 35, 40, 45, 50, 55]) == [27, 20, 0, 25, 7, 36, 12, 33, 19, 36]\n assert candidate(encoded = [100, 200, 50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == [639, 539, 723, 737, 631, 653, 979, 529, 55, 701, 83, 769, 183]\n assert candidate(encoded = [127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101]) == [122, 5, 123, 6, 122, 1, 123, 2, 122, 13, 123, 14, 122, 9, 123, 10, 122, 21, 123, 22, 122, 17, 123, 18, 122, 29, 123, 30]\n assert candidate(encoded = [16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [6553, 9830, 14745, 13926, 12697, 12902, 13209, 13158, 13081, 13094, 13113, 13110, 13105, 13106, 13107]\n assert candidate(encoded = [127, 130, 133, 136, 139, 142, 145]) == [140, 243, 113, 244, 124, 247, 121, 232]\n assert candidate(encoded = [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45]) == [5, 0, 9, 4, 21, 0, 25, 4, 37, 0, 41, 4]\n assert candidate(encoded = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120]) == [1, 2, 4, 13, 1, 14, 28, 9, 17, 10, 20, 53, 17, 54, 28, 49, 1, 50, 4, 61, 1, 62, 124, 57, 113, 58, 116, 37, 113, 38, 124, 33, 65, 34, 68, 45, 65, 46, 92, 41, 81]\n assert candidate(encoded = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047]) == [831, 830, 829, 826, 821, 810, 789, 874, 917, 618, 405, 1642]\n assert candidate(encoded = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == [1, 101, 6, 100, 5, 101, 58, 100, 57, 101, 62, 100, 61, 101, 50, 100, 49]\n assert candidate(encoded = [31, 14, 7, 3, 1, 0, 2, 6, 14, 30, 62, 126, 254]) == [100, 123, 117, 114, 113, 112, 112, 114, 116, 122, 100, 90, 36, 218]\n assert candidate(encoded = [15, 27, 18, 23, 31, 45, 56, 67, 78]) == [105, 102, 125, 111, 120, 103, 74, 114, 49, 127]\n", "comparison": "exact"}, "public_tests": ["[3,1]", "[6,5,4,6]"], "hints": ["Compute the XOR of the numbers between 1 and n, and think about how it can be used. Let it be x.", "Think why n is odd.", "perm[0] = x XOR encoded[1] XOR encoded[3] XOR encoded[5] ...", "perm[i] = perm[i-1] XOR encoded[i-1]"], "metadata": {"canonical_parameter_names": ["encoded"], "leetcode_dataset_entry_point": "Solution().decode", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:04+00:00", "tests_total": 110, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def decode(self, encoded: list[int]) -> list[int]:", "container": "Solution", "callable": "decode", "parameters": [{"name": "encoded", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1736, "task_id": "latest-time-by-replacing-hidden-digits", "difficulty": "Easy", "problem_description": "You are given a string time in the form of hh:mm, where some of the digits in the string are hidden (represented by ?).\n\nThe valid times are those inclusively between 00:00 and 23:59.\n\nReturn the latest valid time you can get from time by replacing the hidden digits.\n\nExample 1:\n\nInput: time = \"2?:?0\"\nOutput: \"23:50\"\nExplanation: The latest hour beginning with the digit '2' is 23 and the latest minute ending with the digit '0' is 50.\n\nExample 2:\n\nInput: time = \"0?:3?\"\nOutput: \"09:39\"\n\nExample 3:\n\nInput: time = \"1?:22\"\nOutput: \"19:22\"\n\nConstraints:\n\n- time is in the format hh:mm.\n- It is guaranteed that you can produce a valid time from the given string.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(time = \"?3:?0\") == \"23:50\"\n assert candidate(time = \"1?:22\") == \"19:22\"\n assert candidate(time = \"1?:??\") == \"19:59\"\n assert candidate(time = \"0?:59\") == \"09:59\"\n assert candidate(time = \"23:?9\") == \"23:59\"\n assert candidate(time = \"00:?0\") == \"00:50\"\n assert candidate(time = \"2?:5?\") == \"23:59\"\n assert candidate(time = \"2?:?0\") == \"23:50\"\n assert candidate(time = \"?:?:??\") == \"2:?:9?\"\n assert candidate(time = \"00:??\") == \"00:59\"\n assert candidate(time = \"1?:?5\") == \"19:55\"\n assert candidate(time = \"?9:5?\") == \"19:59\"\n assert candidate(time = \"??:??\") == \"23:59\"\n assert candidate(time = \"12:3?\") == \"12:39\"\n assert candidate(time = \"??:00\") == \"23:00\"\n assert candidate(time = \"0?:3?\") == \"09:39\"\n assert candidate(time = \"1?:?9\") == \"19:59\"\n assert candidate(time = \"00:?5\") == \"00:55\"\n assert candidate(time = \"?9:59\") == \"19:59\"\n assert candidate(time = \"2?:59\") == \"23:59\"\n assert candidate(time = \"12:?5\") == \"12:55\"\n assert candidate(time = \"1?:3?\") == \"19:39\"\n assert candidate(time = \"20:??\") == \"20:59\"\n assert candidate(time = \"?4:2?\") == \"14:29\"\n assert candidate(time = \"2?:3?\") == \"23:39\"\n assert candidate(time = \"??:45\") == \"23:45\"\n assert candidate(time = \"23:?0\") == \"23:50\"\n assert candidate(time = \"??:09\") == \"23:09\"\n assert candidate(time = \"0?:2?\") == \"09:29\"\n assert candidate(time = \"?4:?4\") == \"14:54\"\n assert candidate(time = \"23:?5\") == \"23:55\"\n assert candidate(time = \"23:?7\") == \"23:57\"\n assert candidate(time = \"20:?9\") == \"20:59\"\n assert candidate(time = \"?3:?2\") == \"23:52\"\n assert candidate(time = \"0?:?4\") == \"09:54\"\n assert candidate(time = \"?3:?8\") == \"23:58\"\n assert candidate(time = \"???:59\") == \"23?:59\"\n assert candidate(time = \"2??:5?\") == \"23?:5?\"\n assert candidate(time = \"2?:1?\") == \"23:19\"\n assert candidate(time = \"22:?8\") == \"22:58\"\n assert candidate(time = \"0?:?9\") == \"09:59\"\n assert candidate(time = \"2?:??\") == \"23:59\"\n assert candidate(time = \"0?:?2\") == \"09:52\"\n assert candidate(time = \"02:?7\") == \"02:57\"\n assert candidate(time = \"1?:?8\") == \"19:58\"\n assert candidate(time = \"09:?5\") == \"09:55\"\n assert candidate(time = \"???:??\") == \"23?:9?\"\n assert candidate(time = \"09:?3\") == \"09:53\"\n assert candidate(time = \"?2:?7\") == \"22:57\"\n assert candidate(time = \"1?:4?\") == \"19:49\"\n assert candidate(time = \"2?:0?\") == \"23:09\"\n assert candidate(time = \"??:59\") == \"23:59\"\n assert candidate(time = \"23:?4\") == \"23:54\"\n assert candidate(time = \"2??:3?\") == \"23?:3?\"\n assert candidate(time = \"0??:30\") == \"09?:30\"\n assert candidate(time = \"0?:?5\") == \"09:55\"\n assert candidate(time = \"0?:4?\") == \"09:49\"\n assert candidate(time = \"09:5?\") == \"09:59\"\n assert candidate(time = \"1?:?0\") == \"19:50\"\n assert candidate(time = \"00:?9\") == \"00:59\"\n assert candidate(time = \"2?:?5\") == \"23:55\"\n assert candidate(time = \"1?:5?\") == \"19:59\"\n assert candidate(time = \"19:?9\") == \"19:59\"\n assert candidate(time = \"1?:?4\") == \"19:54\"\n assert candidate(time = \"1?:0?\") == \"19:09\"\n assert candidate(time = \"2?:4?\") == \"23:49\"\n assert candidate(time = \"?0:?5\") == \"20:55\"\n assert candidate(time = \"??:?9\") == \"23:59\"\n assert candidate(time = \"???:00\") == \"23?:00\"\n assert candidate(time = \"?9:?8\") == \"19:58\"\n assert candidate(time = \"?3:?9\") == \"23:59\"\n assert candidate(time = \"0?:5?\") == \"09:59\"\n assert candidate(time = \"2?:?4\") == \"23:54\"\n assert candidate(time = \"?9:?9\") == \"19:59\"\n assert candidate(time = \"2?:00\") == \"23:00\"\n assert candidate(time = \"?2:3?\") == \"22:39\"\n assert candidate(time = \"0?:??\") == \"09:59\"\n assert candidate(time = \"?4:?8\") == \"14:58\"\n assert candidate(time = \"0?:?0\") == \"09:50\"\n assert candidate(time = \"20:?4\") == \"20:54\"\n assert candidate(time = \"1?:59\") == \"19:59\"\n assert candidate(time = \"0?:0?\") == \"09:09\"\n assert candidate(time = \"23:??\") == \"23:59\"\n assert candidate(time = \"?0:?0\") == \"20:50\"\n assert candidate(time = \"0?:1?\") == \"09:19\"\n assert candidate(time = \"1?:2?\") == \"19:29\"\n assert candidate(time = \"0?:?8\") == \"09:58\"\n assert candidate(time = \"19:?8\") == \"19:58\"\n assert candidate(time = \"?2:?5\") == \"22:55\"\n assert candidate(time = \"0?:45\") == \"09:45\"\n assert candidate(time = \"2?:?9\") == \"23:59\"\n assert candidate(time = \"?3:5?\") == \"23:59\"\n assert candidate(time = \"23:?8\") == \"23:58\"\n assert candidate(time = \"09:??\") == \"09:59\"\n assert candidate(time = \"2?:?8\") == \"23:58\"\n assert candidate(time = \"2?:2?\") == \"23:29\"\n", "comparison": "exact"}, "public_tests": ["\"2?:?0\"", "\"0?:3?\"", "\"1?:22\""], "hints": ["Trying out all possible solutions from biggest to smallest would fit in the time limit.", "To check if the solution is okay, you need to find out if it's valid and matches every character"], "metadata": {"canonical_parameter_names": ["time"], "leetcode_dataset_entry_point": "Solution().maximumTime", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:06+00:00", "tests_total": 96, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maximumTime(self, time: str) -> str:", "container": "Solution", "callable": "maximumTime", "parameters": [{"name": "time", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1737, "task_id": "change-minimum-characters-to-satisfy-one-of-three-conditions", "difficulty": "Medium", "problem_description": "You are given two strings a and b that consist of lowercase letters. In one operation, you can change any character in a or b to any lowercase letter.\n\nYour goal is to satisfy one of the following three conditions:\n\n- Every letter in a is strictly less than every letter in b in the alphabet.\n- Every letter in b is strictly less than every letter in a in the alphabet.\n- Both a and b consist of only one distinct letter.\n\nReturn the minimum number of operations needed to achieve your goal.\n\nExample 1:\n\nInput: a = \"aba\", b = \"caa\"\nOutput: 2\nExplanation: Consider the best way to make each condition true:\n1) Change b to \"ccc\" in 2 operations, then every letter in a is less than every letter in b.\n2) Change a to \"bbb\" and b to \"aaa\" in 3 operations, then every letter in b is less than every letter in a.\n3) Change a to \"aaa\" and b to \"aaa\" in 2 operations, then a and b consist of one distinct letter.\nThe best way was done in 2 operations (either condition 1 or condition 3).\n\nExample 2:\n\nInput: a = \"dabadd\", b = \"cda\"\nOutput: 3\nExplanation: The best way is to make condition 1 true by changing b to \"eee\".\n\nConstraints:\n\n- 1 <= a.length, b.length <= 10^5\n- a and b consist only of lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = \"abc\",b = \"bcd\") == 2\n assert candidate(a = \"aba\",b = \"caa\") == 2\n assert candidate(a = \"xyzz\",b = \"zzzz\") == 2\n assert candidate(a = \"abcd\",b = \"dcba\") == 4\n assert candidate(a = \"aaaabbbb\",b = \"ccccdddd\") == 0\n assert candidate(a = \"xyz\",b = \"abc\") == 0\n assert candidate(a = \"abc\",b = \"def\") == 0\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(a = \"zzz\",b = \"aaa\") == 0\n assert candidate(a = \"abc\",b = \"abc\") == 3\n assert candidate(a = \"a\",b = \"z\") == 0\n assert candidate(a = \"aaa\",b = \"zzz\") == 0\n assert candidate(a = \"abacabadabacaba\",b = \"zzzyzxzyzxzyzxz\") == 0\n assert candidate(a = \"aabbcc\",b = \"bbccdd\") == 4\n assert candidate(a = \"xyz\",b = \"xyz\") == 3\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(a = \"xyz\",b = \"zyx\") == 3\n assert candidate(a = \"aaa\",b = \"bbb\") == 0\n assert candidate(a = \"dabadd\",b = \"cda\") == 3\n assert candidate(a = \"a\",b = \"b\") == 0\n assert candidate(a = \"aaaa\",b = \"bbbb\") == 0\n assert candidate(a = \"aaaaabbbbbccccc\",b = \"cccccbbaaaa\") == 11\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaa\") == 0\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zyxwvutsrqponmlkjihgfedcba\") == 27\n assert candidate(a = \"qwert\",b = \"asdfg\") == 2\n assert candidate(a = \"ababababababababababababababab\",b = \"bababababababababababababababa\") == 30\n assert candidate(a = \"algorithm\",b = \"datastructure\") == 7\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabc\",b = \"zzzzyyyxxxwwwwvvvvuuuuttttssssrrrrqqqqppppooooonnnnmmmmmlllllkkkkkjjjjjiiiii\") == 0\n assert candidate(a = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",b = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 0\n assert candidate(a = \"abcdabcdabcdabcdabcd\",b = \"dcbaabcdabcdabcdabcd\") == 20\n assert candidate(a = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\",b = \"abadabadabadabadabadabadabadabadabadabadabadabadabadabadabadabadabadabadabadab\") == 39\n assert candidate(a = \"aaabbbcccddd\",b = \"eefffgggg\") == 0\n assert candidate(a = \"aaaaaaaaaabbbbbbbbbbbccccccccc\",b = \"zzzzzzzzzzzyyyyyyyyyyxxxxxxxxxx\") == 0\n assert candidate(a = \"abababababababababab\",b = \"babababababababababa\") == 20\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 25\n assert candidate(a = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",b = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 52\n assert candidate(a = \"mnopmnopmnopmnopmnop\",b = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 0\n assert candidate(a = \"abacabadabacabadabacaba\",b = \"zyxzyxzyxzyxzyxzyxzyxzyx\") == 0\n assert candidate(a = \"aaaaa\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"aaaaaabbbbccccdddd\",b = \"eeeeefffffggggghhhhh\") == 0\n assert candidate(a = \"abcdefg\",b = \"hijklmnopqrstuvwxyz\") == 0\n assert candidate(a = \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\",b = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 0\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 2\n assert candidate(a = \"mississippi\",b = \"bababababa\") == 0\n assert candidate(a = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",b = \"pppppppppppppppppppppppppppppppppppppppppp\") == 0\n assert candidate(a = \"mnop\",b = \"qrst\") == 0\n assert candidate(a = \"qazwsxedcrfvtgbyhnujmikolp\",b = \"ploikmjhunbygvtfredcxswqaz\") == 26\n assert candidate(a = \"hello\",b = \"world\") == 3\n assert candidate(a = \"mno\",b = \"jkl\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"hellohellohello\",b = \"worldworldworld\") == 9\n assert candidate(a = \"mmmmmmmmmmmmmmmmmmmmmm\",b = \"nnnnnnnnnnnnnnnnnnnnnn\") == 0\n assert candidate(a = \"aabaaaacaba\",b = \"bcdef\") == 2\n assert candidate(a = \"zzzzzzzzzz\",b = \"aaaaaaaaaa\") == 0\n assert candidate(a = \"aaaaaaaaaaaaaabbbbbbbbbbbbbbcccccccccccccccccdddddddddddddddd\",b = \"eeeeeeeeeeeeeeeeffffffffgggggggggggggggggghhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiii\") == 0\n assert candidate(a = \"qwertqwertqwert\",b = \"mnbvmnbvmnbv\") == 6\n assert candidate(a = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\",b = \"jkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 0\n assert candidate(a = \"qwertyuiop\",b = \"poiuytrewq\") == 10\n assert candidate(a = \"mno\",b = \"mnpq\") == 2\n assert candidate(a = \"llllllllllllllllllllllllllllllllllllllll\",b = \"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk\") == 0\n assert candidate(a = \"programming\",b = \"contest\") == 4\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzxxwwvvutssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 48\n assert candidate(a = \"xyzzzzzxyzzzzz\",b = \"zzzzzxyzzzzzxy\") == 8\n assert candidate(a = \"zzzzz\",b = \"aaaaa\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"ababababababababababababababababab\",b = \"bababababababababababababababababa\") == 34\n assert candidate(a = \"ppppqqqqqqrrrrrrsssssss\",b = \"tttttuuuuuuuuvvvvvvvvvvvvv\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"qwerttyuiiopasdfghjklzzxcvbnm\",b = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 26\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 2\n assert candidate(a = \"python\",b = \"java\") == 2\n assert candidate(a = \"pqrstuv\",b = \"mnopq\") == 2\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(a = \"acabcbacbacbacbaca\",b = \"bdadbdadbdadbdad\") == 8\n assert candidate(a = \"abcdefghijklmnopqrstu\",b = \"vwxyzvwxyzvwxyzvwxyz\") == 0\n assert candidate(a = \"abcdefghijklmnop\",b = \"zyxwvutsrqponmlkjihgfedcba\") == 16\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"abcdefghijklmnopqrstuvwxy\") == 25\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",b = \"defdefdefdefdefdefdefdefdefdefdefdefdefdefdefdefdefdef\") == 0\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabc\",b = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 0\n assert candidate(a = \"aabbaacc\",b = \"zzzzyyxx\") == 0\n assert candidate(a = \"aaaabbbbcccc\",b = \"ccccbbbbaaaa\") == 12\n assert candidate(a = \"abcdefg\",b = \"zzzzzzz\") == 0\n assert candidate(a = \"abcdefghijklmnopqrstuvwxy\",b = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(a = \"acacacacacacacacacacacacacacaca\",b = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\") == 15\n assert candidate(a = \"mnop\",b = \"qrstuvwxyza\") == 1\n assert candidate(a = \"abcdabcdabcd\",b = \"xyzxyzxyzxyz\") == 0\n assert candidate(a = \"abacabadabacaba\",b = \"zyxzyxzyxzyxzyxzyx\") == 0\n assert candidate(a = \"same\",b = \"same\") == 4\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"mnopqrstu\",b = \"vwxyzijkl\") == 4\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"abcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(a = \"mnopqrstuvwxy\",b = \"abcdefghijklmnopqrstuvwxyz\") == 14\n assert candidate(a = \"abcdabcabc\",b = \"zyxzxyzxyz\") == 0\n assert candidate(a = \"abacabadabacabad\",b = \"zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx\") == 0\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabc\",b = \"abcabcabcabcabcabcabcabcabcabc\") == 30\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"abcdefghijklm\",b = \"nopqrstuvwxyz\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"mnopqrstuvwxyzmnopqrstu\",b = \"abcdefghijklmnopqrstuabcdefghijklmnopqrstu\") == 18\n assert candidate(a = \"aaabbbcccdddeeefffggghhhhiiiiijjjjjjkkkkkkkllllllllmmmmmmmmmmm\",b = \"mnopqrstuvwxyzmnopqrstuvwxyzmnopqrstuvwxyzmnopqrstuvwxyz\") == 4\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccdddddddddddddddddddddd\",b = \"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\") == 0\n assert candidate(a = \"xyxzyzxzyzxzyzxzyz\",b = \"zyxzyzxzyzxzyzxzyx\") == 18\n assert candidate(a = \"abcdefghijklmnop\",b = \"qrstuvwxyz\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"xyzz\",b = \"abcd\") == 0\n assert candidate(a = \"racecar\",b = \"madam\") == 5\n assert candidate(a = \"abcdefghijklmnopqrstu\",b = \"vwxyzabcdefghijklmnopqrstu\") == 21\n assert candidate(a = \"qwe\",b = \"qwer\") == 3\n assert candidate(a = \"pppppppppppppppppppppppppppppppppppppppppp\",b = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 0\n assert candidate(a = \"mnbvcxzlkjhgfdsapoiuytrewq\",b = \"qwertyuiopasdfghjklzxcvbnm\") == 26\n assert candidate(a = \"abcdabcdabcd\",b = \"dcbaabcdabcd\") == 12\n assert candidate(a = \"aaaaabbbbb\",b = \"bbbbbccccc\") == 5\n assert candidate(a = \"aaabbbcccdddeeefffggghhhiii\",b = \"kkklllmmmnnnooopppqqqrrrssstttuuuvvv\") == 0\n assert candidate(a = \"aaaaaaaaaaaaaaaaaaaaaaa\",b = \"bbbbbbbbbbbbbbbbbbbbbbbbb\") == 0\n assert candidate(a = \"abacabadabacabadabacabad\",b = \"zzzzyyyyxxxxyyyyzzzz\") == 0\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeeeddccbbbaa\") == 52\n assert candidate(a = \"abacabadabacaba\",b = \"zzzyyyxxxwwwwvvvvuuuuuuttttttsssssrrrrrqqqqqqpppppoonnnnmmmllllkkkkjjjjiiiihhhhhgggggffffffeeeeeeeedddddccccbbbaaaa\") == 10\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 52\n assert candidate(a = \"mnopqrstuvwxyz\",b = \"abcdefghijklm\") == 1\n assert candidate(a = \"one\",b = \"two\") == 1\n assert candidate(a = \"qwertyuiopasdfghjklzxcvbnm\",b = \"qwertyuiopasdfghjklzxcvbnm\") == 26\n assert candidate(a = \"mississippi\",b = \"delaware\") == 3\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 1\n assert candidate(a = \"abc\",b = \"xyz\") == 0\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"abcdefghijklmnopqrstuvwxyz\") == 27\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",b = \"mnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnop\") == 0\n", "comparison": "exact"}, "public_tests": ["\"aba\"\n\"caa\"", "\"dabadd\"\n\"cda\""], "hints": ["Iterate on each letter in the alphabet, and check the smallest number of operations needed to make it one of the following: the largest letter in a and smaller than the smallest one in b, vice versa, or let a and b consist only of this letter.", "For the first 2 conditions, take care that you can only change characters to lowercase letters, so you can't make 'z' the smallest letter in one of the strings or 'a' the largest letter in one of them."], "metadata": {"canonical_parameter_names": ["a", "b"], "leetcode_dataset_entry_point": "Solution().minCharacters", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:09+00:00", "tests_total": 128, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "counting", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minCharacters(self, a: str, b: str) -> int:", "container": "Solution", "callable": "minCharacters", "parameters": [{"name": "a", "type": "str"}, {"name": "b", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1738, "task_id": "find-kth-largest-xor-coordinate-value", "difficulty": "Medium", "problem_description": "You are given a 2D matrix of size m x n, consisting of non-negative integers. You are also given an integer k.\n\nThe value of coordinate (a, b) of the matrix is the XOR of all matrix[i][j] where 0 <= i <= a < m and 0 <= j <= b < n (0-indexed).\n\nFind the k^th largest value (1-indexed) of all the coordinates of matrix.\n\nExample 1:\n\nInput: matrix = [[5,2],[1,6]], k = 1\nOutput: 7\nExplanation: The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value.\n\nExample 2:\n\nInput: matrix = [[5,2],[1,6]], k = 2\nOutput: 5\nExplanation: The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value.\n\nExample 3:\n\nInput: matrix = [[5,2],[1,6]], k = 3\nOutput: 4\nExplanation: The value of coordinate (1,0) is 5 XOR 1 = 4, which is the 3rd largest value.\n\nConstraints:\n\n- m == matrix.length\n- n == matrix[i].length\n- 1 <= m, n <= 1000\n- 0 <= matrix[i][j] <= 10^6\n- 1 <= k <= m * n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[5, 2, 3], [1, 6, 4]],k = 5) == 4\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],k = 9) == 0\n assert candidate(matrix = [[5, 2, 3], [1, 6, 4], [7, 8, 9]],k = 9) == 0\n assert candidate(matrix = [[10, 12, 3], [1, 6, 4], [7, 8, 9]],k = 4) == 10\n assert candidate(matrix = [[10, 20], [30, 40]],k = 1) == 40\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 5) == 2\n assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],k = 4) == 1\n assert candidate(matrix = [[0, 0], [0, 0]],k = 1) == 0\n assert candidate(matrix = [[5, 2], [1, 6]],k = 1) == 7\n assert candidate(matrix = [[5, 2, 3], [1, 6, 4]],k = 1) == 7\n assert candidate(matrix = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],k = 9) == 0\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6]],k = 6) == 1\n assert candidate(matrix = [[5, 2], [1, 6]],k = 3) == 4\n assert candidate(matrix = [[5, 2], [1, 6]],k = 2) == 5\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6]],k = 4) == 3\n assert candidate(matrix = [[1000000, 999999, 999998], [999997, 999996, 999995], [999994, 999993, 999992]],k = 6) == 126\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 4, 3, 2]],k = 25) == 2\n assert candidate(matrix = [[5, 8, 9, 12, 15], [14, 11, 10, 7, 4], [3, 6, 7, 10, 13], [12, 15, 14, 11, 8], [1, 4, 5, 8, 11]],k = 18) == 5\n assert candidate(matrix = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],k = 5) == 1\n assert candidate(matrix = [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200]],k = 10) == 172\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],k = 25) == 0\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 10) == 0\n assert candidate(matrix = [[9, 10, 11], [12, 13, 14], [15, 16, 17], [18, 19, 20]],k = 8) == 8\n assert candidate(matrix = [[8, 6, 2, 5, 8, 4, 9], [4, 5, 5, 6, 9, 8, 9], [7, 3, 8, 7, 5, 6, 2], [4, 3, 1, 2, 3, 4, 5], [5, 6, 7, 8, 9, 0, 1]],k = 15) == 11\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 50) == 0\n assert candidate(matrix = [[1, 3, 5, 7, 9, 11, 13], [15, 17, 19, 21, 23, 25, 27], [29, 31, 33, 35, 37, 39, 41]],k = 12) == 14\n assert candidate(matrix = [[25, 10, 15, 20], [5, 30, 35, 40], [45, 50, 55, 60], [65, 70, 75, 80]],k = 15) == 8\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],k = 13) == 0\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 25) == 1\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64]],k = 30) == 7\n assert candidate(matrix = [[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5], [3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4], [3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9], [7, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5]],k = 18) == 9\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 1) == 0\n assert candidate(matrix = [[9, 18, 27, 36, 45], [44, 35, 26, 17, 8], [7, 16, 25, 34, 43], [42, 33, 24, 15, 6], [5, 14, 23, 32, 41]],k = 20) == 8\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 10) == 3\n assert candidate(matrix = [[1000000, 999999, 999998], [999997, 999996, 999995], [999994, 999993, 999992]],k = 9) == 123\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 30) == 0\n assert candidate(matrix = [[5, 2, 15, 6, 3], [10, 1, 4, 7, 8], [3, 1, 9, 2, 12], [6, 14, 11, 13, 5], [1, 15, 8, 6, 7]],k = 20) == 6\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 16) == 0\n assert candidate(matrix = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]],k = 8) == 20\n assert candidate(matrix = [[7, 1, 4, 2], [9, 6, 3, 8], [5, 0, 10, 12], [15, 11, 14, 13]],k = 7) == 8\n assert candidate(matrix = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30], [32, 34, 36, 38, 40], [42, 44, 46, 48, 50]],k = 14) == 8\n assert candidate(matrix = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4], [5, 5, 5, 5, 5]],k = 12) == 1\n assert candidate(matrix = [[5, 2, 15, 10], [1, 6, 8, 3], [12, 4, 7, 9], [14, 11, 13, 5]],k = 10) == 6\n assert candidate(matrix = [[8, 12, 7, 3, 15], [9, 6, 11, 14, 4], [13, 8, 2, 5, 9], [1, 10, 7, 12, 8], [6, 4, 14, 3, 13]],k = 13) == 7\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],k = 1) == 0\n assert candidate(matrix = [[999999, 999999, 999999], [999999, 999999, 999999], [999999, 999999, 999999]],k = 9) == 0\n assert candidate(matrix = [[13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],k = 14) == 12\n assert candidate(matrix = [[15, 9, 12, 3], [11, 6, 4, 14], [7, 8, 9, 13], [2, 5, 10, 1]],k = 7) == 8\n assert candidate(matrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],k = 10) == 1\n assert candidate(matrix = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]],k = 10) == 8\n assert candidate(matrix = [[3, 4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14], [15, 16, 17, 18]],k = 15) == 0\n assert candidate(matrix = [[1, 0, 0, 1, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],k = 12) == 1\n assert candidate(matrix = [[31, 41, 59, 26, 53], [58, 97, 93, 23, 84], [62, 64, 33, 83, 27], [95, 25, 43, 30, 48], [67, 47, 54, 90, 88]],k = 17) == 31\n assert candidate(matrix = [[256, 512, 1024], [128, 256, 512], [64, 128, 256]],k = 5) == 640\n assert candidate(matrix = [[3, 1, 2], [4, 1, 1], [5, 10, 6]],k = 6) == 3\n assert candidate(matrix = [[3, 6, 9, 12], [4, 7, 10, 13], [5, 8, 11, 14]],k = 7) == 5\n assert candidate(matrix = [[3, 8, 1], [9, 11, 13], [4, 7, 12]],k = 6) == 10\n assert candidate(matrix = [[1000000, 0, 0, 0, 0, 0, 0], [0, 1000000, 0, 0, 0, 0, 0], [0, 0, 1000000, 0, 0, 0, 0], [0, 0, 0, 1000000, 0, 0, 0], [0, 0, 0, 0, 1000000, 0, 0], [0, 0, 0, 0, 0, 1000000, 0], [0, 0, 0, 0, 0, 0, 1000000]],k = 25) == 1000000\n assert candidate(matrix = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]],k = 25) == 0\n assert candidate(matrix = [[9, 8, 7, 6, 5, 4], [3, 2, 1, 0, 9, 8], [7, 6, 5, 4, 3, 2], [1, 0, 9, 8, 7, 6], [5, 4, 3, 2, 1, 0]],k = 30) == 0\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 25) == 0\n assert candidate(matrix = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],k = 14) == 0\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 20) == 1\n assert candidate(matrix = [[1000000, 999999, 999998, 999997], [999996, 999995, 999994, 999993], [999992, 999991, 999990, 999989]],k = 6) == 124\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 1) == 1\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 20) == 7\n assert candidate(matrix = [[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]],k = 15) == 5\n assert candidate(matrix = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]],k = 13) == 4\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 25) == 0\n assert candidate(matrix = [[1000000, 999999, 999998, 999997, 999996], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 15) == 1000000\n assert candidate(matrix = [[7, 7, 7], [7, 7, 7], [7, 7, 7]],k = 4) == 7\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 1) == 15\n assert candidate(matrix = [[1000000, 999999, 999998, 999997], [999996, 999995, 999994, 999993], [999992, 999991, 999990, 999989], [999988, 999987, 999986, 999985]],k = 10) == 120\n assert candidate(matrix = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],k = 3) == 7\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15]],k = 10) == 4\n assert candidate(matrix = [[1000000, 200000, 30000], [4000, 5000, 6000], [70, 80, 900]],k = 8) == 799482\n assert candidate(matrix = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [60, 70, 80, 90, 100], [55, 65, 75, 85, 95]],k = 15) == 10\n assert candidate(matrix = [[42, 42, 42, 42, 42], [42, 42, 42, 42, 42], [42, 42, 42, 42, 42], [42, 42, 42, 42, 42], [42, 42, 42, 42, 42]],k = 15) == 0\n assert candidate(matrix = [[2, 4, 6, 8, 10, 12], [14, 16, 18, 20, 22, 24], [26, 28, 30, 32, 34, 36]],k = 17) == 2\n assert candidate(matrix = [[15, 14, 13, 12], [11, 10, 9, 8], [7, 6, 5, 4], [3, 2, 1, 0]],k = 10) == 0\n assert candidate(matrix = [[23, 56, 12, 78], [34, 89, 56, 45], [12, 34, 56, 78], [89, 56, 23, 12]],k = 10) == 47\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 25) == 0\n assert candidate(matrix = [[100, 200, 300], [400, 500, 600], [700, 800, 900]],k = 5) == 384\n assert candidate(matrix = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [20, 22, 24, 26, 28]],k = 12) == 7\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 16) == 0\n assert candidate(matrix = [[3, 5, 11, 13], [8, 2, 12, 7], [4, 6, 9, 15], [1, 10, 3, 8]],k = 6) == 11\n", "comparison": "exact"}, "public_tests": ["[[5,2],[1,6]]\n1", "[[5,2],[1,6]]\n2", "[[5,2],[1,6]]\n3"], "hints": ["Use a 2D prefix sum to precalculate the xor-sum of the upper left submatrix."], "metadata": {"canonical_parameter_names": ["matrix", "k"], "leetcode_dataset_entry_point": "Solution().kthLargestValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:11+00:00", "tests_total": 87, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "divide-and-conquer", "bit-manipulation", "sorting", "heap-priority-queue", "matrix", "prefix-sum", "quickselect"]}, "language": "python", "interface": {"raw_signature": "def kthLargestValue(self, matrix: list[list[int]], k: int) -> int:", "container": "Solution", "callable": "kthLargestValue", "parameters": [{"name": "matrix", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1739, "task_id": "building-boxes", "difficulty": "Hard", "problem_description": "You have a cubic storeroom where the width, length, and height of the room are all equal to n units. You are asked to place n boxes in this room where each box is a cube of unit side length. There are however some rules to placing the boxes:\n\n- You can place the boxes anywhere on the floor.\n- If box x is placed on top of the box y, then each side of the four vertical sides of the box y must either be adjacent to another box or to a wall.\n\nGiven an integer n, return the minimum possible number of boxes touching the floor.\n\nExample 1:\n\nInput: n = 3\nOutput: 3\nExplanation: The figure above is for the placement of the three boxes.\nThese boxes are placed in the corner of the room, where the corner is on the left side.\n\nExample 2:\n\nInput: n = 4\nOutput: 3\nExplanation: The figure above is for the placement of the four boxes.\nThese boxes are placed in the corner of the room, where the corner is on the left side.\n\nExample 3:\n\nInput: n = 10\nOutput: 6\nExplanation: The figure above is for the placement of the ten boxes.\nThese boxes are placed in the corner of the room, where the corner is on the back side.\n\nConstraints:\n\n- 1 <= n <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 6\n assert candidate(n = 3) == 3\n assert candidate(n = 100) == 34\n assert candidate(n = 15) == 9\n assert candidate(n = 4) == 3\n assert candidate(n = 1000000) == 16443\n assert candidate(n = 20) == 10\n assert candidate(n = 1) == 1\n assert candidate(n = 1000000000) == 1650467\n assert candidate(n = 1000) == 161\n assert candidate(n = 10) == 6\n assert candidate(n = 329) == 75\n assert candidate(n = 344) == 77\n assert candidate(n = 729) == 130\n assert candidate(n = 567890) == 11279\n assert candidate(n = 324) == 75\n assert candidate(n = 300) == 71\n assert candidate(n = 333) == 76\n assert candidate(n = 316) == 74\n assert candidate(n = 23) == 12\n assert candidate(n = 303) == 72\n assert candidate(n = 334) == 76\n assert candidate(n = 35) == 15\n assert candidate(n = 347) == 77\n assert candidate(n = 5000) == 474\n assert candidate(n = 567890123) == 1131581\n assert candidate(n = 4913) == 464\n assert candidate(n = 200) == 53\n assert candidate(n = 500000000) == 1039682\n assert candidate(n = 313) == 73\n assert candidate(n = 500) == 100\n assert candidate(n = 317) == 74\n assert candidate(n = 3375) == 365\n assert candidate(n = 897543210) == 1535456\n assert candidate(n = 341) == 76\n assert candidate(n = 216) == 55\n assert candidate(n = 50000) == 2210\n assert candidate(n = 987654) == 16287\n assert candidate(n = 314) == 73\n assert candidate(n = 318) == 74\n assert candidate(n = 100000) == 3536\n assert candidate(n = 25) == 13\n assert candidate(n = 350) == 77\n assert candidate(n = 5000000) == 48159\n assert candidate(n = 325) == 75\n assert candidate(n = 305) == 72\n assert candidate(n = 123456789) == 408968\n assert candidate(n = 999999) == 16443\n assert candidate(n = 308) == 73\n assert candidate(n = 12167) == 857\n assert candidate(n = 342) == 77\n assert candidate(n = 666) == 120\n assert candidate(n = 315) == 74\n assert candidate(n = 999999999) == 1650467\n assert candidate(n = 2000) == 252\n assert candidate(n = 250000000) == 654763\n assert candidate(n = 30) == 14\n assert candidate(n = 23456789) == 135151\n assert candidate(n = 345) == 77\n assert candidate(n = 336) == 76\n assert candidate(n = 9261) == 719\n assert candidate(n = 311) == 73\n assert candidate(n = 310) == 73\n assert candidate(n = 337) == 76\n assert candidate(n = 343) == 77\n assert candidate(n = 339) == 76\n assert candidate(n = 320) == 74\n assert candidate(n = 332) == 76\n assert candidate(n = 987654321) == 1636751\n assert candidate(n = 307) == 72\n assert candidate(n = 309) == 73\n assert candidate(n = 500000) == 10365\n assert candidate(n = 328) == 75\n assert candidate(n = 348) == 77\n assert candidate(n = 304) == 72\n assert candidate(n = 1500) == 208\n assert candidate(n = 2197) == 272\n assert candidate(n = 1331) == 191\n assert candidate(n = 319) == 74\n assert candidate(n = 125) == 39\n assert candidate(n = 321) == 74\n assert candidate(n = 6859) == 586\n assert candidate(n = 50) == 20\n assert candidate(n = 323) == 75\n assert candidate(n = 331) == 75\n assert candidate(n = 40) == 18\n assert candidate(n = 327) == 75\n assert candidate(n = 349) == 77\n assert candidate(n = 10000) == 756\n assert candidate(n = 335) == 76\n assert candidate(n = 302) == 72\n assert candidate(n = 312) == 73\n assert candidate(n = 330) == 75\n assert candidate(n = 322) == 74\n assert candidate(n = 338) == 76\n assert candidate(n = 306) == 72\n assert candidate(n = 326) == 75\n assert candidate(n = 301) == 71\n assert candidate(n = 123456) == 4068\n assert candidate(n = 346) == 77\n assert candidate(n = 340) == 76\n", "comparison": "exact"}, "public_tests": ["3", "4", "10"], "hints": ["Suppose We can put m boxes on the floor, within all the ways to put the boxes, what’s the maximum number of boxes we can put in?", "The first box should always start in the corner"], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minimumBoxes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:13+00:00", "tests_total": 101, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["math", "binary-search", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minimumBoxes(self, n: int) -> int:", "container": "Solution", "callable": "minimumBoxes", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1742, "task_id": "maximum-number-of-balls-in-a-box", "difficulty": "Easy", "problem_description": "You are working in a ball factory where you have n balls numbered from lowLimit up to highLimit inclusive (i.e., n == highLimit - lowLimit + 1), and an infinite number of boxes numbered from 1 to infinity.\n\nYour job at this factory is to put each ball in the box with a number equal to the sum of digits of the ball's number. For example, the ball number 321 will be put in the box number 3 + 2 + 1 = 6 and the ball number 10 will be put in the box number 1 + 0 = 1.\n\nGiven two integers lowLimit and highLimit, return the number of balls in the box with the most balls.\n\nExample 1:\n\nInput: lowLimit = 1, highLimit = 10\nOutput: 2\nExplanation:\nBox Number: 1 2 3 4 5 6 7 8 9 10 11 ...\nBall Count: 2 1 1 1 1 1 1 1 1 0 0 ...\nBox 1 has the most number of balls with 2 balls.\n\nExample 2:\n\nInput: lowLimit = 5, highLimit = 15\nOutput: 2\nExplanation:\nBox Number: 1 2 3 4 5 6 7 8 9 10 11 ...\nBall Count: 1 1 1 1 2 2 1 1 1 0 0 ...\nBoxes 5 and 6 have the most number of balls with 2 balls in each.\n\nExample 3:\n\nInput: lowLimit = 19, highLimit = 28\nOutput: 2\nExplanation:\nBox Number: 1 2 3 4 5 6 7 8 9 10 11 12 ...\nBall Count: 0 1 1 1 1 1 1 1 1 2 0 0 ...\nBox 10 has the most number of balls with 2 balls.\n\nConstraints:\n\n- 1 <= lowLimit <= highLimit <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(lowLimit = 999,highLimit = 1000) == 1\n assert candidate(lowLimit = 1000,highLimit = 10000) == 615\n assert candidate(lowLimit = 50000,highLimit = 50500) == 44\n assert candidate(lowLimit = 99,highLimit = 999) == 70\n assert candidate(lowLimit = 500,highLimit = 550) == 6\n assert candidate(lowLimit = 9999,highLimit = 100000) == 5520\n assert candidate(lowLimit = 1,highLimit = 10) == 2\n assert candidate(lowLimit = 100,highLimit = 200) == 10\n assert candidate(lowLimit = 99,highLimit = 199) == 10\n assert candidate(lowLimit = 1,highLimit = 100) == 10\n assert candidate(lowLimit = 1,highLimit = 20) == 3\n assert candidate(lowLimit = 10,highLimit = 100) == 9\n assert candidate(lowLimit = 50,highLimit = 150) == 10\n assert candidate(lowLimit = 5,highLimit = 15) == 2\n assert candidate(lowLimit = 19,highLimit = 28) == 2\n assert candidate(lowLimit = 45678,highLimit = 98765) == 3544\n assert candidate(lowLimit = 40000,highLimit = 50000) == 670\n assert candidate(lowLimit = 10000,highLimit = 20000) == 670\n assert candidate(lowLimit = 33333,highLimit = 44444) == 782\n assert candidate(lowLimit = 67890,highLimit = 67990) == 11\n assert candidate(lowLimit = 54321,highLimit = 54421) == 10\n assert candidate(lowLimit = 88888,highLimit = 88988) == 10\n assert candidate(lowLimit = 100,highLimit = 100) == 1\n assert candidate(lowLimit = 99999,highLimit = 100000) == 1\n assert candidate(lowLimit = 9995,highLimit = 10005) == 1\n assert candidate(lowLimit = 43210,highLimit = 43250) == 5\n assert candidate(lowLimit = 30000,highLimit = 35000) == 365\n assert candidate(lowLimit = 98765,highLimit = 98865) == 10\n assert candidate(lowLimit = 54321,highLimit = 54341) == 3\n assert candidate(lowLimit = 11111,highLimit = 11115) == 1\n assert candidate(lowLimit = 10000,highLimit = 99999) == 5520\n assert candidate(lowLimit = 66666,highLimit = 66766) == 10\n assert candidate(lowLimit = 77777,highLimit = 77800) == 3\n assert candidate(lowLimit = 99990,highLimit = 100000) == 1\n assert candidate(lowLimit = 11111,highLimit = 11200) == 9\n assert candidate(lowLimit = 5000,highLimit = 6000) == 75\n assert candidate(lowLimit = 56789,highLimit = 56800) == 2\n assert candidate(lowLimit = 55555,highLimit = 66666) == 782\n assert candidate(lowLimit = 9990,highLimit = 10000) == 1\n assert candidate(lowLimit = 12345,highLimit = 54321) == 2854\n assert candidate(lowLimit = 50000,highLimit = 50100) == 10\n assert candidate(lowLimit = 23456,highLimit = 23460) == 1\n assert candidate(lowLimit = 500,highLimit = 5000) == 340\n assert candidate(lowLimit = 5000,highLimit = 5100) == 10\n assert candidate(lowLimit = 90000,highLimit = 95000) == 365\n assert candidate(lowLimit = 10000,highLimit = 100000) == 5520\n assert candidate(lowLimit = 9999,highLimit = 10000) == 1\n assert candidate(lowLimit = 999,highLimit = 1009) == 1\n assert candidate(lowLimit = 12345,highLimit = 12395) == 6\n assert candidate(lowLimit = 1,highLimit = 99999) == 6000\n assert candidate(lowLimit = 12345,highLimit = 12345) == 1\n assert candidate(lowLimit = 1,highLimit = 1000) == 75\n assert candidate(lowLimit = 22222,highLimit = 22322) == 10\n assert candidate(lowLimit = 12345,highLimit = 67890) == 3699\n assert candidate(lowLimit = 56789,highLimit = 56799) == 2\n assert candidate(lowLimit = 100,highLimit = 1000) == 70\n assert candidate(lowLimit = 11111,highLimit = 22222) == 754\n assert candidate(lowLimit = 77777,highLimit = 77877) == 10\n assert candidate(lowLimit = 100000,highLimit = 100000) == 1\n assert candidate(lowLimit = 250,highLimit = 750) == 46\n assert candidate(lowLimit = 30000,highLimit = 40000) == 670\n assert candidate(lowLimit = 12345,highLimit = 12445) == 11\n assert candidate(lowLimit = 5000,highLimit = 5050) == 6\n assert candidate(lowLimit = 995,highLimit = 1005) == 1\n assert candidate(lowLimit = 1000,highLimit = 1050) == 6\n assert candidate(lowLimit = 33333,highLimit = 33433) == 10\n assert candidate(lowLimit = 1234,highLimit = 5678) == 344\n assert candidate(lowLimit = 8888,highLimit = 8900) == 2\n assert candidate(lowLimit = 11111,highLimit = 11211) == 10\n assert candidate(lowLimit = 999,highLimit = 1001) == 1\n assert candidate(lowLimit = 67890,highLimit = 78900) == 749\n assert candidate(lowLimit = 20000,highLimit = 30000) == 670\n assert candidate(lowLimit = 50000,highLimit = 51000) == 75\n assert candidate(lowLimit = 99,highLimit = 101) == 1\n assert candidate(lowLimit = 88888,highLimit = 99999) == 736\n assert candidate(lowLimit = 1234,highLimit = 1244) == 2\n assert candidate(lowLimit = 44444,highLimit = 55555) == 785\n assert candidate(lowLimit = 300,highLimit = 600) == 28\n assert candidate(lowLimit = 12345,highLimit = 12355) == 2\n assert candidate(lowLimit = 70000,highLimit = 80000) == 670\n assert candidate(lowLimit = 88888,highLimit = 88999) == 11\n assert candidate(lowLimit = 20000,highLimit = 25000) == 365\n assert candidate(lowLimit = 123,highLimit = 456) == 33\n", "comparison": "exact"}, "public_tests": ["1\n10", "5\n15", "19\n28"], "hints": ["Note that both lowLimit and highLimit are of small constraints so you can iterate on all number between them", "You can simulate the boxes by counting for each box the number of balls with digit sum equal to that box number"], "metadata": {"canonical_parameter_names": ["lowLimit", "highLimit"], "leetcode_dataset_entry_point": "Solution().countBalls", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:18+00:00", "tests_total": 86, "tests_dropped": 3, "flags": [], "topic_tags": ["hash-table", "math", "counting"]}, "language": "python", "interface": {"raw_signature": "def countBalls(self, lowLimit: int, highLimit: int) -> int:", "container": "Solution", "callable": "countBalls", "parameters": [{"name": "lowLimit", "type": "int"}, {"name": "highLimit", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1743, "task_id": "restore-the-array-from-adjacent-pairs", "difficulty": "Medium", "problem_description": "There is an integer array nums that consists of n unique elements, but you have forgotten it. However, you do remember every pair of adjacent elements in nums.\n\nYou are given a 2D integer array adjacentPairs of size n - 1 where each adjacentPairs[i] = [u_i, v_i] indicates that the elements u_i and v_i are adjacent in nums.\n\nIt is guaranteed that every adjacent pair of elements nums[i] and nums[i+1] will exist in adjacentPairs, either as [nums[i], nums[i+1]] or [nums[i+1], nums[i]]. The pairs can appear in any order.\n\nReturn the original array nums. If there are multiple solutions, return any of them.\n\nExample 1:\n\nInput: adjacentPairs = [[2,1],[3,4],[3,2]]\nOutput: [1,2,3,4]\nExplanation: This array has all its adjacent pairs in adjacentPairs.\nNotice that adjacentPairs[i] may not be in left-to-right order.\n\nExample 2:\n\nInput: adjacentPairs = [[4,-2],[1,4],[-3,1]]\nOutput: [-2,4,1,-3]\nExplanation: There can be negative numbers.\nAnother solution is [-3,1,4,-2], which would also be accepted.\n\nExample 3:\n\nInput: adjacentPairs = [[100000,-100000]]\nOutput: [100000,-100000]\n\nConstraints:\n\n- nums.length == n\n- adjacentPairs.length == n - 1\n- adjacentPairs[i].length == 2\n- 2 <= n <= 10^5\n- -10^5 <= nums[i], u_i, v_i <= 10^5\n- There exists some nums that has adjacentPairs as its pairs.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, -2]]) == [-1, 0, 1, 2, 3, -2]\n assert candidate(adjacentPairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]]) == [10, 20, 30, 40, 50, 60]\n assert candidate(adjacentPairs = [[2, 1], [3, 4], [3, 2]]) == [1, 2, 3, 4]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700]]) == [100, 200, 300, 400, 500, 600, 700]\n assert candidate(adjacentPairs = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6]]) == [-1, -2, -3, -4, -5, -6]\n assert candidate(adjacentPairs = [[-1, 2], [2, 3], [3, 4], [4, 5]]) == [-1, 2, 3, 4, 5]\n assert candidate(adjacentPairs = [[5, 1], [1, 2], [2, 3], [3, 4]]) == [5, 1, 2, 3, 4]\n assert candidate(adjacentPairs = [[100000, -100000]]) == [100000, -100000]\n assert candidate(adjacentPairs = [[5, 3], [3, 1], [1, 2], [2, 4], [4, 6]]) == [5, 3, 1, 2, 4, 6]\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [-2, -1]]) == [2, 1, 0, -1, -2]\n assert candidate(adjacentPairs = [[4, -2], [1, 4], [-3, 1]]) == [-2, 4, 1, -3]\n assert candidate(adjacentPairs = [[1, 6], [2, 3], [3, 4], [4, 5], [5, 6]]) == [1, 6, 5, 4, 3, 2]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [1, 2, 3, 4, 5, 6]\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4]]) == [-1, 0, 1, 2, 3, 4]\n assert candidate(adjacentPairs = [[1, 6], [6, 8], [8, 3], [3, 7], [7, 2], [2, 5], [5, 4]]) == [1, 6, 8, 3, 7, 2, 5, 4]\n assert candidate(adjacentPairs = [[-1, 1], [-2, -1], [-3, -2], [4, -3], [5, 4], [6, 5], [7, 6]]) == [1, -1, -2, -3, 4, 5, 6, 7]\n assert candidate(adjacentPairs = [[-10, -20], [-20, -30], [-30, -40], [-40, -50], [-50, -60]]) == [-10, -20, -30, -40, -50, -60]\n assert candidate(adjacentPairs = [[-10000, 10000], [10000, 20000], [20000, -10000], [-20000, -10000], [30000, 20000], [30000, 40000]]) == [-20000, -10000, 20000, 10000, -10000, 20000, 10000]\n assert candidate(adjacentPairs = [[-5, -4], [-4, -3], [-3, -2], [-2, -1], [-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]\n assert candidate(adjacentPairs = [[100000, -100000], [99999, 100000], [-99999, -100000], [88888, 99999], [-88888, -99999]]) == [88888, 99999, 100000, -100000, -99999, -88888]\n assert candidate(adjacentPairs = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6], [-6, -7], [-7, -8], [-8, -9], [-9, -10]]) == [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]\n assert candidate(adjacentPairs = [[-5, 0], [0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 65], [65, 70], [70, 75], [75, 80], [80, 85], [85, 90]]) == [-5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90]\n assert candidate(adjacentPairs = [[-10, -20], [-20, -30], [-30, -40], [-40, -50], [-50, -60], [-60, -70], [-70, -80], [-80, -90], [-90, -100]]) == [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]\n assert candidate(adjacentPairs = [[-10, -9], [-9, -8], [-8, -7], [-7, -6], [-6, -5], [-5, -4], [-4, -3], [-3, -2], [-2, -1], [-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 1100], [1100, 1200], [1200, 1300], [1300, 1400], [1400, 1500]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(adjacentPairs = [[1, 2], [3, 4], [5, 6], [1, 3], [4, 5]]) == [2, 1, 3, 4, 5, 6]\n assert candidate(adjacentPairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110], [110, 120]]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]\n assert candidate(adjacentPairs = [[100000, -100000], [-99999, 100000], [-99998, -99999], [-99997, -99998], [-99996, -99997], [-99995, -99996], [-99994, -99995], [-99993, -99994], [-99992, -99993], [-99991, -99992]]) == [-100000, 100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991]\n assert candidate(adjacentPairs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(adjacentPairs = [[5, 15], [15, 25], [25, 35], [35, 45], [45, 55], [55, 65], [65, 75], [75, 85], [85, 95], [95, 105]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]\n assert candidate(adjacentPairs = [[50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110], [110, 120], [120, 130], [130, 140], [140, 150]]) == [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]\n assert candidate(adjacentPairs = [[-5, 0], [0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [-5, -10], [-10, -15], [-15, -20], [-20, -25], [-25, -30], [-30, -35], [-35, -40], [-40, -45], [-45, -50]]) == [50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50]\n assert candidate(adjacentPairs = [[-5, -4], [-4, -3], [-3, -2], [-2, -1], [-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]\n assert candidate(adjacentPairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23], [23, 25], [25, 27], [27, 29], [29, 31], [31, 33], [33, 35], [35, 37], [37, 39]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]\n assert candidate(adjacentPairs = [[100000, 99999], [99998, 99999], [99997, 99998], [99996, 99997], [99995, 99996]]) == [100000, 99999, 99998, 99997, 99996, 99995]\n assert candidate(adjacentPairs = [[-10, -20], [-20, -30], [-30, -40], [-40, -50], [-50, -60], [-60, -70], [-70, -80], [-80, -90]]) == [-10, -20, -30, -40, -50, -60, -70, -80, -90]\n assert candidate(adjacentPairs = [[-1, 1], [-2, -1], [-3, -2], [-4, -3], [-5, -4], [-6, -5], [-7, -6], [-8, -7], [-9, -8], [-10, -9]]) == [1, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]\n assert candidate(adjacentPairs = [[10, 5], [5, -10], [-10, 15], [15, -15], [20, 10], [25, 20], [30, 25], [35, 30], [40, 35], [45, 40], [50, 45]]) == [-15, 15, -10, 5, 10, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(adjacentPairs = [[1, 2], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [11, 10], [12, 11], [13, 12], [14, 13], [15, 14], [16, 15], [17, 16], [18, 17], [19, 18], [20, 19]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(adjacentPairs = [[1, 2], [3, 2], [5, 4], [4, 3], [7, 6], [6, 5], [9, 8], [8, 7], [11, 10], [10, 9]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(adjacentPairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(adjacentPairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23], [23, 25], [25, 27], [27, 29]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]\n assert candidate(adjacentPairs = [[5, 3], [3, 1], [1, -2], [-2, -4], [-4, -6], [-6, -8], [-8, -10], [-10, -12], [-12, -14], [-14, -16], [-16, -18], [-18, -20], [-20, -22], [-22, -24], [-24, -26]]) == [5, 3, 1, -2, -4, -6, -8, -10, -12, -14, -16, -18, -20, -22, -24, -26]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(adjacentPairs = [[1, -1], [-1, 2], [2, -2], [-2, 3], [3, -3], [-3, 4], [4, -4], [-4, 5], [5, -5], [-5, 6], [6, -6], [-6, 7], [7, -7], [-7, 8], [8, -8], [-8, 9], [9, -9], [-9, 10], [10, -10]]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\n assert candidate(adjacentPairs = [[-1, 100], [100, 200], [200, -300], [-300, 400], [400, 500]]) == [-1, 100, 200, -300, 400, 500]\n assert candidate(adjacentPairs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0]]) == [0, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(adjacentPairs = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6], [-6, -7], [-7, -8], [-8, -9], [-9, -10], [-10, -11], [-11, -12]]) == [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12]\n assert candidate(adjacentPairs = [[500, 1000], [1000, 1500], [1500, 2000], [2000, 2500], [2500, 3000], [3000, 3500], [3500, 4000], [4000, 4500], [4500, 5000], [5000, 5500], [5500, 6000], [6000, 6500], [6500, 7000], [7000, 7500], [7500, 8000], [8000, 8500], [8500, 9000], [9000, 9500], [9500, 10000]]) == [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000]\n assert candidate(adjacentPairs = [[1, 5], [5, 9], [9, 13], [13, 17], [17, 21], [21, 25], [25, 29], [29, 33], [33, 37], [37, 41]]) == [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41]\n assert candidate(adjacentPairs = [[-10, -20], [-20, -30], [-30, -40], [-40, -50], [-50, -60], [-60, -70], [-70, -80], [-80, -90], [-90, -100]]) == [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]\n assert candidate(adjacentPairs = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]\n assert candidate(adjacentPairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23], [23, 25], [25, 27], [27, 29], [29, 31], [31, 33], [33, 35], [35, 37], [37, 39], [39, 41]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [100, 150], [150, 250], [250, 350], [350, 450], [450, 550], [550, 650], [650, 750], [750, 850], [850, 950], [950, 1050]]) == [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]\n assert candidate(adjacentPairs = [[10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 65], [65, 70]]) == [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(adjacentPairs = [[100000, 90000], [80000, 90000], [70000, 80000], [60000, 70000], [50000, 60000]]) == [100000, 90000, 80000, 70000, 60000, 50000]\n assert candidate(adjacentPairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(adjacentPairs = [[-50000, -40000], [-30000, -40000], [-20000, -30000], [-10000, -20000], [0, -10000]]) == [-50000, -40000, -30000, -20000, -10000, 0]\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(adjacentPairs = [[-99999, 99999], [99999, -99998], [-99998, 99998], [99998, -99997], [-99997, 99997], [99997, -99996], [-99996, 99996], [99996, -99995]]) == [-99999, 99999, -99998, 99998, -99997, 99997, -99996, 99996, -99995]\n assert candidate(adjacentPairs = [[-5, 0], [-4, -5], [-3, -4], [-2, -3], [-1, -2], [0, -1], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4]]) == [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, 0]\n assert candidate(adjacentPairs = [[0, 1], [2, 1], [4, 3], [3, 2], [6, 5], [5, 4], [8, 7], [7, 6], [10, 9], [9, 8], [12, 11], [11, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(adjacentPairs = [[-1, 2], [2, -3], [-3, 4], [4, -5], [-5, 6], [6, -7], [-7, 8], [8, -9], [-9, 10], [10, -11], [-11, 12], [12, -13], [-13, 14], [14, -15], [-15, 16], [16, -17], [-17, 18], [18, -19], [-19, 20]]) == [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [2, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2]\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(adjacentPairs = [[-100, -99], [-99, -98], [-98, -97], [-97, -96], [-96, -95], [-95, -94], [-94, -93], [-93, -92], [-92, -91], [-91, -90], [-90, -89], [-89, -88], [-88, -87], [-87, -86], [-86, -85], [-85, -84], [-84, -83], [-83, -82], [-82, -81], [-81, -80]]) == [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80]\n assert candidate(adjacentPairs = [[1, 6], [6, 11], [11, 16], [16, 21], [21, 26], [26, 31], [31, 36], [36, 41], [41, 46], [46, 51]]) == [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51]\n assert candidate(adjacentPairs = [[-100000, -90000], [-90000, -80000], [-80000, -70000], [-70000, -60000], [-60000, -50000], [-50000, -40000], [-40000, -30000], [-30000, -20000], [-20000, -10000], [-10000, 0], [0, 10000], [10000, 20000], [20000, 30000], [30000, 40000], [40000, 50000], [50000, 60000], [60000, 70000], [70000, 80000], [80000, 90000], [90000, 100000]]) == [-100000, -90000, -80000, -70000, -60000, -50000, -40000, -30000, -20000, -10000, 0, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(adjacentPairs = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [2, 3], [4, 5], [6, 7], [8, 9]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(adjacentPairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110]]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n", "comparison": "exact"}, "public_tests": ["[[2,1],[3,4],[3,2]]", "[[4,-2],[1,4],[-3,1]]", "[[100000,-100000]]"], "hints": ["Find the first element of nums - it will only appear once in adjacentPairs.", "The adjacent pairs are like edges of a graph. Perform a depth-first search from the first element."], "metadata": {"canonical_parameter_names": ["adjacentPairs"], "leetcode_dataset_entry_point": "Solution().restoreArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:20+00:00", "tests_total": 79, "tests_dropped": 0, "flags": ["multiple_answers"], "topic_tags": ["array", "hash-table", "depth-first-search"]}, "language": "python", "interface": {"raw_signature": "def restoreArray(self, adjacentPairs: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "restoreArray", "parameters": [{"name": "adjacentPairs", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1744, "task_id": "can-you-eat-your-favorite-candy-on-your-favorite-day", "difficulty": "Medium", "problem_description": "You are given a (0-indexed) array of positive integers candiesCount where candiesCount[i] represents the number of candies of the i^th type you have. You are also given a 2D array queries where queries[i] = [favoriteType_i, favoriteDay_i, dailyCap_i].\n\nYou play a game with the following rules:\n\n- You start eating candies on day 0.\n- You cannot eat any candy of type i unless you have eaten all candies of type i - 1.\n- You must eat at least one candy per day until you have eaten all the candies.\n\nConstruct a boolean array answer such that answer.length == queries.length and answer[i] is true if you can eat a candy of type favoriteType_i on day favoriteDay_i without eating more than dailyCap_i candies on any day, and false otherwise. Note that you can eat different types of candy on the same day, provided that you follow rule 2.\n\nReturn the constructed array answer.\n\nExample 1:\n\nInput: candiesCount = [7,4,5,3,8], queries = [[0,2,2],[4,2,4],[2,13,1000000000]]\nOutput: [true,false,true]\nExplanation:\n1- If you eat 2 candies (type 0) on day 0 and 2 candies (type 0) on day 1, you will eat a candy of type 0 on day 2.\n2- You can eat at most 4 candies each day.\n If you eat 4 candies every day, you will eat 4 candies (type 0) on day 0 and 4 candies (type 0 and type 1) on day 1.\n On day 2, you can only eat 4 candies (type 1 and type 2), so you cannot eat a candy of type 4 on day 2.\n3- If you eat 1 candy each day, you will eat a candy of type 2 on day 13.\n\nExample 2:\n\nInput: candiesCount = [5,2,6,4,1], queries = [[3,1,2],[4,10,3],[3,10,100],[4,100,30],[1,3,1]]\nOutput: [false,true,true,false,false]\n\nConstraints:\n\n- 1 <= candiesCount.length <= 10^5\n- 1 <= candiesCount[i] <= 10^5\n- 1 <= queries.length <= 10^5\n- queries[i].length == 3\n- 0 <= favoriteType_i < candiesCount.length\n- 0 <= favoriteDay_i <= 10^9\n- 1 <= dailyCap_i <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(candiesCount = [7, 4, 5, 3, 8],queries = [[0, 2, 2], [4, 2, 4], [2, 13, 1000000000]]) == [True, False, True]\n assert candidate(candiesCount = [5, 2, 6, 4, 1],queries = [[3, 1, 2], [4, 10, 3], [3, 10, 100], [4, 100, 30], [1, 3, 1]]) == [False, True, True, False, False]\n assert candidate(candiesCount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 0, 1], [1, 1, 2], [2, 3, 3], [3, 6, 4], [4, 10, 5], [5, 15, 6], [6, 21, 7], [7, 28, 8], [8, 36, 9], [9, 45, 10]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[0, 0, 10], [1, 1, 20], [2, 2, 30], [3, 3, 40], [4, 4, 50], [0, 5, 5], [1, 10, 10], [2, 15, 15], [3, 20, 20], [4, 25, 25]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]]) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 1, 1], [1, 3, 2], [2, 6, 3], [3, 10, 4], [4, 15, 5], [5, 21, 6], [6, 28, 7], [7, 36, 8], [8, 45, 9], [9, 55, 10]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 0, 10], [1, 10, 20], [2, 30, 30], [3, 60, 40], [4, 100, 50], [5, 150, 60], [6, 210, 70], [7, 280, 80], [8, 360, 90], [9, 450, 100]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 0, 1], [1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5], [5, 5, 6], [6, 6, 7], [7, 7, 8], [8, 8, 9], [9, 9, 10]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [5, 4, 3, 2, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [0, 4, 10], [1, 3, 10], [2, 2, 10], [3, 1, 10], [4, 0, 10]]) == [True, False, False, False, False, True, True, True, True, False]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[4, 49, 50], [3, 29, 40], [2, 19, 30], [1, 9, 20], [0, 9, 10]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 5, 5], [1, 15, 15], [2, 30, 25], [3, 45, 35], [4, 60, 45], [5, 75, 55], [6, 90, 65], [7, 105, 75], [8, 120, 85], [9, 135, 95]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500],queries = [[0, 99, 100], [1, 199, 200], [2, 299, 300], [3, 399, 400], [4, 499, 500], [0, 1, 50], [1, 1, 100], [2, 1, 150], [3, 1, 200], [4, 1, 250]]) == [True, True, True, True, True, True, True, False, False, False]\n assert candidate(candiesCount = [100, 200, 300, 400, 500],queries = [[0, 99, 100], [1, 199, 200], [2, 299, 300], [3, 399, 400], [4, 499, 500]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],queries = [[0, 10000, 1000], [1, 20000, 2000], [2, 30000, 3000], [3, 40000, 4000], [4, 50000, 5000], [5, 60000, 6000], [6, 70000, 7000], [7, 80000, 8000], [8, 90000, 9000], [9, 100000, 10000]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 0, 10], [1, 1, 10], [2, 2, 10], [3, 3, 10], [4, 4, 10], [5, 5, 10], [6, 6, 10], [7, 7, 10], [8, 8, 10], [9, 9, 10]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [0, 99, 1000], [1, 199, 1000], [2, 299, 1000], [3, 399, 1000], [4, 499, 1000], [5, 599, 1000], [6, 699, 1000], [7, 799, 1000], [8, 899, 1000], [9, 999, 1000]]) == [True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[0, 5, 10], [1, 15, 10], [2, 25, 10], [3, 35, 10], [4, 45, 10], [0, 9, 9], [1, 19, 9], [2, 29, 9], [3, 39, 9], [4, 49, 9], [0, 1, 1], [1, 11, 1], [2, 21, 1], [3, 31, 1], [4, 41, 1]]) == [True, True, True, True, True, True, True, True, True, True, True, True, False, False, False]\n assert candidate(candiesCount = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [13, 13, 1], [14, 14, 1], [15, 15, 1], [16, 16, 1], [17, 17, 1], [18, 18, 1], [19, 19, 1]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [1, 10, 100, 1000, 10000],queries = [[0, 0, 1], [1, 1, 10], [2, 2, 100], [3, 3, 1000], [4, 4, 10000], [0, 5, 5], [1, 10, 10], [2, 15, 15], [3, 20, 20], [4, 25, 25]]) == [True, True, True, True, True, False, True, True, True, False]\n assert candidate(candiesCount = [1000, 1000, 1000, 1000, 1000],queries = [[0, 0, 1], [1, 500, 1000], [2, 1000, 1000], [3, 1500, 1000], [4, 2000, 1000]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]]) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 0, 1], [1, 1, 2], [2, 3, 3], [3, 6, 4], [4, 10, 5], [5, 15, 6], [6, 21, 7], [7, 28, 8], [8, 36, 9]]) == [True, False, False, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 3, 1], [3, 6, 1], [4, 10, 1], [5, 15, 1], [6, 21, 1], [7, 28, 1], [8, 36, 1], [9, 45, 1]]) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, 99, 100], [1, 199, 200], [2, 299, 300], [3, 399, 400], [4, 499, 500], [5, 599, 600], [6, 699, 700], [7, 799, 800], [8, 899, 900], [9, 999, 1000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 0, 10], [9, 494, 100], [5, 150, 60], [2, 30, 30], [8, 315, 90]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 0, 1], [9, 44, 10], [3, 9, 4], [5, 14, 5], [8, 35, 9]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500],queries = [[0, 0, 100], [1, 100, 200], [2, 300, 300], [3, 600, 400], [4, 1000, 500]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, 1, 50], [1, 51, 100], [2, 151, 150], [3, 301, 200], [4, 501, 250], [5, 751, 300], [6, 1051, 350], [7, 1401, 400], [8, 1801, 450], [9, 2251, 500]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[0, 0, 5], [1, 4, 10], [2, 19, 15], [3, 34, 20], [4, 49, 25]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [50, 50, 50, 50, 50],queries = [[0, 24, 50], [1, 49, 50], [2, 74, 50], [3, 99, 50], [4, 124, 50], [0, 25, 25], [1, 50, 25], [2, 75, 25], [3, 100, 25], [4, 125, 25]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, 0, 100], [1, 199, 200], [2, 399, 300], [3, 599, 400], [4, 799, 500], [5, 999, 600], [6, 1199, 700], [7, 1399, 800], [8, 1599, 900], [9, 1799, 1000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[0, 0, 10], [1, 10, 20], [2, 30, 30], [3, 60, 40], [4, 100, 50]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500],queries = [[0, 0, 1], [1, 100, 100], [2, 200, 150], [3, 300, 200], [4, 400, 250]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1, 1, 1, 1, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],queries = [[0, 1000, 500], [1, 3000, 1000], [2, 5000, 1500], [3, 7000, 2000], [4, 9000, 2500], [5, 11000, 3000], [6, 13000, 3500], [7, 15000, 4000], [8, 17000, 4500], [9, 19000, 5000]]) == [False, False, True, True, True, True, True, True, True, True]\n", "comparison": "exact"}, "public_tests": ["[7,4,5,3,8]\n[[0,2,2],[4,2,4],[2,13,1000000000]]", "[5,2,6,4,1]\n[[3,1,2],[4,10,3],[3,10,100],[4,100,30],[1,3,1]]"], "hints": ["The query is true if and only if your favorite day is in between the earliest and latest possible days to eat your favorite candy.", "To get the earliest day, you need to eat dailyCap candies every day. To get the latest day, you need to eat 1 candy every day.", "The latest possible day is the total number of candies with a smaller type plus the number of your favorite candy minus 1.", "The earliest possible day that you can eat your favorite candy is the total number of candies with a smaller type divided by dailyCap."], "metadata": {"canonical_parameter_names": ["candiesCount", "queries"], "leetcode_dataset_entry_point": "Solution().canEat", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:23+00:00", "tests_total": 55, "tests_dropped": 19, "flags": [], "topic_tags": ["array", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def canEat(self, candiesCount: list[int], queries: list[list[int]]) -> list[bool]:", "container": "Solution", "callable": "canEat", "parameters": [{"name": "candiesCount", "type": "list[int]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1745, "task_id": "palindrome-partitioning-iv", "difficulty": "Hard", "problem_description": "Given a string s, return true if it is possible to split the string s into three non-empty palindromic substrings. Otherwise, return false.\n\nA string is said to be palindrome if it the same string when reversed.\n\nExample 1:\n\nInput: s = \"abcbdd\"\nOutput: true\nExplanation: \"abcbdd\" = \"a\" + \"bcb\" + \"dd\", and all three substrings are palindromes.\n\nExample 2:\n\nInput: s = \"bcbddxy\"\nOutput: false\nExplanation: s cannot be split into 3 palindromes.\n\nConstraints:\n\n- 3 <= s.length <= 2000\n- s consists only of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcba\") == True\n assert candidate(s = \"abcdcba\") == True\n assert candidate(s = \"aabbaa\") == True\n assert candidate(s = \"aaaaa\") == True\n assert candidate(s = \"abacdfgdcaba\") == False\n assert candidate(s = \"aabbbaa\") == True\n assert candidate(s = \"noonnoon\") == True\n assert candidate(s = \"aaa\") == True\n assert candidate(s = \"aabb\") == True\n assert candidate(s = \"racecar\") == True\n assert candidate(s = \"abba\") == True\n assert candidate(s = \"noon\") == True\n assert candidate(s = \"deeee\") == True\n assert candidate(s = \"abc\") == True\n assert candidate(s = \"abcbdd\") == True\n assert candidate(s = \"abcd\") == False\n assert candidate(s = \"aabbcc\") == True\n assert candidate(s = \"madamimadam\") == True\n assert candidate(s = \"aabaacaab\") == True\n assert candidate(s = \"bcbddxy\") == False\n assert candidate(s = \"aabbccddeeeffgghhii\") == False\n assert candidate(s = \"aabbccddeeefffggghhhiiii\") == False\n assert candidate(s = \"kayakmadamracecar\") == True\n assert candidate(s = \"levelracecar\") == False\n assert candidate(s = \"civicnooncivicnoon\") == False\n assert candidate(s = \"aaaaaabbaaaaa\") == True\n assert candidate(s = \"madamnoonmadamnoonmadam\") == True\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == True\n assert candidate(s = \"rotordetartratedrotor\") == True\n assert candidate(s = \"tattarrattatmadamracecar\") == True\n assert candidate(s = \"abcabcabc\") == False\n assert candidate(s = \"rotorlevelrotor\") == True\n assert candidate(s = \"deifiedcivicdeified\") == True\n assert candidate(s = \"rotorrefer\") == False\n assert candidate(s = \"madamadam\") == True\n assert candidate(s = \"aaaabbbbcccc\") == True\n assert candidate(s = \"levellevellevellevellevellevel\") == True\n assert candidate(s = \"deifieddeifieddeified\") == True\n assert candidate(s = \"xyzzyxabcba\") == False\n assert candidate(s = \"tacocatdeified\") == False\n assert candidate(s = \"leveloneone\") == False\n assert candidate(s = \"aabbccddeeefffggghhhhiiiiijjjjkkkkllllmmmmnnnnoooo\") == False\n assert candidate(s = \"levelmadamrotor\") == True\n assert candidate(s = \"abccbaabccba\") == True\n assert candidate(s = \"abcdmadamracecar\") == False\n assert candidate(s = \"levellevellevellevel\") == True\n assert candidate(s = \"repaperdeified\") == False\n assert candidate(s = \"noonnoonnoonnoon\") == True\n assert candidate(s = \"racecarlevel\") == False\n assert candidate(s = \"revilerleveldeified\") == False\n assert candidate(s = \"aabbaabbaa\") == True\n assert candidate(s = \"deifieddeifieddeifieddeifieddeified\") == True\n assert candidate(s = \"kayakracecarkayak\") == True\n assert candidate(s = \"abbbcbbaabbcbba\") == False\n assert candidate(s = \"levelrotorabcddcba\") == True\n assert candidate(s = \"aabbccddeeeffgghhiiiii\") == False\n assert candidate(s = \"leveldeifiedlevel\") == True\n assert candidate(s = \"noonnoonnoonnoonnoonnoon\") == True\n assert candidate(s = \"abacabaabacabaabacabaabacaba\") == True\n assert candidate(s = \"rotorreferrotorrefer\") == False\n assert candidate(s = \"abccbaabccbaabccba\") == True\n assert candidate(s = \"abacdfgdcabaaa\") == False\n assert candidate(s = \"aabbaccd\") == False\n assert candidate(s = \"aabbccddeeefffggghhhiiiiijjjjkkkkllllmmmmnnnnooooppppqqqrrrssstttuuuuvvvwwwxxxxyyyyzzzz\") == False\n assert candidate(s = \"madammadammadam\") == True\n assert candidate(s = \"racecarracecarracecar\") == True\n assert candidate(s = \"madammadam\") == True\n assert candidate(s = \"aibohphobiamadamaibohphobia\") == True\n assert candidate(s = \"racecarbanana\") == True\n assert candidate(s = \"abaabbab\") == True\n assert candidate(s = \"racecarabacaba\") == False\n assert candidate(s = \"abcdeedcba\") == True\n assert candidate(s = \"aabbccddeeeeddcbaabbccdd\") == False\n assert candidate(s = \"deeeeefeee\") == True\n assert candidate(s = \"rotorleveldeifiedleveldeifiedrotor\") == False\n assert candidate(s = \"aabbccddeeeeedddccbbaa\") == False\n assert candidate(s = \"abccbaabccbaabccbaabccbaabccbaabccbaabccbaabccba\") == True\n assert candidate(s = \"deifiedcivic\") == False\n assert candidate(s = \"abcbaabcbabcba\") == True\n assert candidate(s = \"civicracecar\") == False\n assert candidate(s = \"wasitacaroracatisaw\") == True\n assert candidate(s = \"rotorcentralpalindromerotor\") == False\n assert candidate(s = \"abcdcbaabdcbaabcdcba\") == False\n assert candidate(s = \"aibohphobia\") == True\n assert candidate(s = \"leveldeifiedcivic\") == True\n assert candidate(s = \"referredder\") == False\n assert candidate(s = \"level\") == True\n assert candidate(s = \"aabbccdd\") == False\n assert candidate(s = \"rotorleveltwol\") == False\n assert candidate(s = \"levellevellevel\") == True\n assert candidate(s = \"rotorpusher\") == False\n assert candidate(s = \"abccbaabc\") == False\n assert candidate(s = \"referreferrefer\") == True\n assert candidate(s = \"xyzyzyxyz\") == True\n assert candidate(s = \"madamrotorlevel\") == True\n assert candidate(s = \"madam\") == True\n assert candidate(s = \"mammadmam\") == False\n assert candidate(s = \"ababababababa\") == True\n assert candidate(s = \"racecarlevelmadam\") == True\n assert candidate(s = \"abababab\") == False\n assert candidate(s = \"civiccivicciviccivicciviccivic\") == True\n assert candidate(s = \"wasitacaroracitisawreferredder\") == False\n assert candidate(s = \"xxyyxyyxxyyxyyxxyyxyy\") == True\n assert candidate(s = \"abababa\") == True\n assert candidate(s = \"racecarracecarracecarracecarracecar\") == True\n assert candidate(s = \"referredderreferredderreferredder\") == False\n assert candidate(s = \"levelonevenflow\") == False\n assert candidate(s = \"referreferreferreferreferrefer\") == True\n assert candidate(s = \"deifiedrotor\") == False\n assert candidate(s = \"abcbaababcbcabcba\") == False\n assert candidate(s = \"banana\") == False\n assert candidate(s = \"levelonevenone\") == False\n assert candidate(s = \"rotorrotorrotorrotorrotor\") == True\n assert candidate(s = \"aabbccddeeffgg\") == False\n assert candidate(s = \"detartrated\") == True\n assert candidate(s = \"abbcbba\") == True\n assert candidate(s = \"aabbabba\") == True\n assert candidate(s = \"racecarannakayak\") == True\n assert candidate(s = \"amanaplanacanalpanama\") == True\n assert candidate(s = \"refermadamrefermadam\") == False\n assert candidate(s = \"racecarleveldadlevel\") == False\n assert candidate(s = \"abbaeaeabba\") == True\n assert candidate(s = \"racecarracecar\") == True\n assert candidate(s = \"rotorreferredder\") == True\n assert candidate(s = \"noonnoonnoon\") == True\n assert candidate(s = \"levelrefercivic\") == True\n assert candidate(s = \"deified\") == True\n assert candidate(s = \"abbaabbaabba\") == True\n assert candidate(s = \"levelmadamatadammadam\") == False\n assert candidate(s = \"abcdedcba\") == True\n assert candidate(s = \"rotormadamrotor\") == True\n assert candidate(s = \"rotorrotorrotor\") == True\n assert candidate(s = \"xyxzyxyxzyx\") == False\n assert candidate(s = \"rotorresistor\") == False\n assert candidate(s = \"xylophonelevel\") == False\n assert candidate(s = \"deifiedrotordeified\") == True\n assert candidate(s = \"racecarrotorrotorcarcerac\") == False\n assert candidate(s = \"abccbaabcba\") == False\n assert candidate(s = \"noonnoonnoonnoonnoonnoonnoonnoonnoonnoonnoonnoonnoon\") == True\n assert candidate(s = \"abcddcba\") == True\n assert candidate(s = \"civic\") == True\n assert candidate(s = \"rotor\") == True\n assert candidate(s = \"civicnoon\") == False\n assert candidate(s = \"madamatadammadam\") == False\n assert candidate(s = \"repaperrepaperrepaper\") == True\n assert candidate(s = \"rotorracecarracecar\") == True\n assert candidate(s = \"civicciviccivic\") == True\n assert candidate(s = \"rotorabanana\") == False\n assert candidate(s = \"aabbccddeeefff\") == False\n assert candidate(s = \"referdeifiedrefer\") == True\n assert candidate(s = \"rotorotator\") == True\n assert candidate(s = \"aabbccddeeffgghh\") == False\n assert candidate(s = \"leveltwol\") == False\n assert candidate(s = \"rotorresistorresistor\") == False\n assert candidate(s = \"levelracecarlevel\") == True\n assert candidate(s = \"rotordetartratedleveldeifiedrotor\") == False\n assert candidate(s = \"madammadammadammadammadam\") == True\n assert candidate(s = \"deifiedrotorlevel\") == True\n assert candidate(s = \"refercivicrefer\") == True\n assert candidate(s = \"abccbaabccbaabccbaabccbaabccba\") == True\n assert candidate(s = \"leveldeified\") == False\n assert candidate(s = \"rotorlevelmadam\") == True\n assert candidate(s = \"neveroddoreven\") == True\n assert candidate(s = \"redividerleveldeified\") == True\n assert candidate(s = \"refer\") == True\n", "comparison": "exact"}, "public_tests": ["\"abcbdd\"", "\"bcbddxy\""], "hints": ["Preprocess checking palindromes in O(1)", "Note that one string is a prefix and another one is a suffix you can try brute forcing the rest"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().checkPartitioning", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:25+00:00", "tests_total": 165, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def checkPartitioning(self, s: str) -> bool:", "container": "Solution", "callable": "checkPartitioning", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1748, "task_id": "sum-of-unique-elements", "difficulty": "Easy", "problem_description": "You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array.\n\nReturn the sum of all the unique elements of nums.\n\nExample 1:\n\nInput: nums = [1,2,3,2]\nOutput: 4\nExplanation: The unique elements are [1,3], and the sum is 4.\n\nExample 2:\n\nInput: nums = [1,1,1,1,1]\nOutput: 0\nExplanation: There are no unique elements, and the sum is 0.\n\nExample 3:\n\nInput: nums = [1,2,3,4,5]\nOutput: 15\nExplanation: The unique elements are [1,2,3,4,5], and the sum is 15.\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 1 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == 54\n assert candidate(nums = [10, 20, 20, 10, 30]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 100, 99, 98, 97, 96, 95]) == 485\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 955\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 8, 8, 8]) == 0\n assert candidate(nums = [1, 2]) == 3\n assert candidate(nums = [1, 2, 3, 2]) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6]) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == 1\n assert candidate(nums = [7]) == 7\n assert candidate(nums = [5]) == 5\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 594\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 155\n assert candidate(nums = [50, 50, 50, 50, 50, 51, 52, 52, 53, 53, 53, 54, 55, 55, 55, 55]) == 105\n assert candidate(nums = [10, 20, 20, 30, 30, 40, 50, 60, 60, 70, 80, 80, 90, 100]) == 360\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5050\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 5050\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10]) == 37\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 0\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 40\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9, 10, 10, 11]) == 42\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == 400\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75]) == 2175\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10]) == 40\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 52, 53, 54, 55]) == 265\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 6, 7, 6, 5, 8, 9, 10, 9, 8, 11, 12, 13, 12, 11, 14, 15, 16, 15, 14, 17, 18, 19, 18, 17, 20, 21, 22, 21, 20, 23, 24, 25, 24, 23]) == 119\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 955\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 195\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == 0\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 13]) == 0\n assert candidate(nums = [50, 50, 50, 51, 52, 53, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70]) == 1157\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 650\n assert candidate(nums = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30]) == 490\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 465\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 1050\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 0\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90]) == 855\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15, 15, 14, 13, 12, 11]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [50, 50, 50, 50, 50, 51, 52, 53, 54, 55]) == 265\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 195\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 6, 7]) == 22\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 400\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 7, 8, 8, 9, 10, 11, 12, 12, 13]) == 56\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 14, 15, 15, 16, 16, 17, 18, 18, 19, 20, 20]) == 85\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5050\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 100, 99]) == 756\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 200\n assert candidate(nums = [10, 10, 10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 1\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20]) == 100\n assert candidate(nums = [10, 20, 10, 20, 30, 40, 30, 40, 50, 60, 50, 60, 70, 80, 70, 80, 90, 100, 90, 100]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 40\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 60, 70]) == 130\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80]) == 2015\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 0\n assert candidate(nums = [50, 50, 50, 50, 50, 49, 48, 47, 46, 45]) == 235\n", "comparison": "exact"}, "public_tests": ["[1,2,3,2]", "[1,1,1,1,1]", "[1,2,3,4,5]"], "hints": ["Use a dictionary to count the frequency of each number."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumOfUnique", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:30+00:00", "tests_total": 99, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "hash-table", "counting"]}, "language": "python", "interface": {"raw_signature": "def sumOfUnique(self, nums: list[int]) -> int:", "container": "Solution", "callable": "sumOfUnique", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1749, "task_id": "maximum-absolute-sum-of-any-subarray", "difficulty": "Medium", "problem_description": "You are given an integer array nums. The absolute sum of a subarray [nums_l, nums_{l+1}, ..., nums_{r-1}, nums_r] is abs(nums_l + nums_{l+1} + ... + nums_{r-1} + nums_r).\n\nReturn the maximum absolute sum of any (possibly empty) subarray of nums.\n\nNote that abs(x) is defined as follows:\n\n- If x is a negative integer, then abs(x) = -x.\n- If x is a non-negative integer, then abs(x) = x.\n\nExample 1:\n\nInput: nums = [1,-3,2,3,-4]\nOutput: 5\nExplanation: The subarray [2,3] has absolute sum = abs(2+3) = abs(5) = 5.\n\nExample 2:\n\nInput: nums = [2,-5,1,-4,3,-2]\nOutput: 8\nExplanation: The subarray [-5,1,-4] has absolute sum = abs(-5+1-4) = abs(-8) = 8.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- -10^4 <= nums[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [-10000, 10000, -10000, 10000]) == 10000\n assert candidate(nums = [1, -3, 2, 3, -4]) == 5\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [2, -5, 1, -4, 3, -2]) == 8\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000]) == 10000\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 15\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [-1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [-10000, 10000, -10000, 10000, -10000]) == 10000\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 6, 7, 8, 9, 10, -25, 11, 12, 13, 14, 15]) == 80\n assert candidate(nums = [10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 100\n assert candidate(nums = [5, 1, -2, 4, -1, -3, 6, -2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [-100, 101, -102, 103, -104, 105, -106, 107]) == 107\n assert candidate(nums = [100, -50, 25, -10, 5, -2, 1]) == 100\n assert candidate(nums = [-1, -2, -3, -4, -5, 5, 4, 3, 2, 1, -1, -2, -3, -4, -5, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums = [5, -1, 3, -2, 4, -3, 6, -4, 7, -5]) == 15\n assert candidate(nums = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1]) == 1000\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000]) == 1000\n assert candidate(nums = [1, 2, 3, -6, 1, 2, 3, -6, 1, 2, 3, -6]) == 6\n assert candidate(nums = [5000, 4000, 3000, 2000, 1000, -5000, -4000, -3000, -2000, -1000]) == 15000\n assert candidate(nums = [10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, -10000]) == 10000\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 55\n assert candidate(nums = [43, 44, -87, 45, 46, 47, -135, 48, 49, 50, 51, -195, 52, 53, 54, 55, 56, -260, 57, 58]) == 276\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500]) == 500\n assert candidate(nums = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 15\n assert candidate(nums = [10, 20, 30, -60, 40, 50, -100, 60, 70, 80, -230, 90, 100, 110, -340, 120]) == 340\n assert candidate(nums = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [5000, -1200, 3000, -1500, 2000, -1000, 4000]) == 10300\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 20\n assert candidate(nums = [10000, -9999, 10000, -9999, 10000, -9999, 10000, -9999]) == 10003\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 20\n assert candidate(nums = [5, -1, 4, -2, 3, -3, 2, -2, 1, -1, 0, 1, -1, 2, -2, 3, -3, 4, -4, 5]) == 11\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [-5, 10, -15, 20, -25, 30, -35, 40]) == 40\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [-5, 4, -3, 7, -8, 2, -6, 1, 9, -4]) == 12\n assert candidate(nums = [26, -27, 28, -29, 30, -31, 32, -33, 34, -35, 36, -37, 38, -39, 40, -41, 42, -43, 44, -45, 46, -47, 48, -49, 50]) == 50\n assert candidate(nums = [10, -3, 20, -40, 50, -60, 70, -80, 90]) == 90\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 50\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16]) == 16\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120, -130, 140, -150, 160, -170, 180, -190, 200]) == 200\n assert candidate(nums = [23, -24, 25, -26, 27, -28, 29, -30, 31, -32, 33, -34, 35, -36, 37, -38, 39, -40, 41, -42]) == 42\n assert candidate(nums = [1, -100, 100, -50, 50, -25, 25, -12, 12, -6, 6]) == 100\n assert candidate(nums = [2, 3, -5, 4, 2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12]) == 13\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 100\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400]) == 400\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 15\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 5\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7]) == 7\n assert candidate(nums = [5000, -2000, 1500, -1000, 800, -700, 600, -500, 400, -300]) == 5000\n assert candidate(nums = [-3000, 4500, -5000, 6000, -7000, 8000, -9000]) == 9000\n assert candidate(nums = [-100, 200, -300, 400, -500, 600, -700, 800, -900, 1000]) == 1000\n assert candidate(nums = [500, -500, 500, -500, 500, -500, 500, -500, 500, -500]) == 500\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13]) == 13\n assert candidate(nums = [0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 20\n assert candidate(nums = [1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 10\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 10\n assert candidate(nums = [3, 2, 1, 0, -1, -2, -3, 0, 3, 2, 1, 0, -1, -2, -3]) == 6\n assert candidate(nums = [9999, -9998, 9997, -9996, 9995, -9994, 9993, -9992, 9991, -9990]) == 9999\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [10000, 9000, 8000, -7000, -6000, -5000, 4000, 3000, 2000, -1000]) == 27000\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 10\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 5\n assert candidate(nums = [5, -1, 3, -2, 7, -8, 2, -6, 4]) == 12\n assert candidate(nums = [100, 200, 300, -600, 400, 500, -1400, 600, 700, 800, 900, 1000]) == 4000\n assert candidate(nums = [-10, -20, -30, 60, -40, -50, 100, -60, -70, -80, 230, -90, -100, -110, 340, -120]) == 340\n assert candidate(nums = [-100, -200, -300, -400, -500, 1500, -600, -700, -800, -900, -1000]) == 4000\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, 100, 200, 300, 400, 500]) == 5500\n assert candidate(nums = [5, -1, 4, -2, 3, -3, 2, -4, 1, -5, 0, 6, -6, 7, -7, 8, -8, 9, -9, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 100, -200, 300, -400, 500]) == 1200\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [10000, -9000, 8000, -7000, 6000, -5000, 4000, -3000, 2000, -1000]) == 10000\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 10\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 10\n assert candidate(nums = [-5000, 5000, 0, -5000, 5000, 0, -5000, 5000, 0]) == 5000\n assert candidate(nums = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 15\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000, -10000]) == 10000\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, 20, -21, 22, -23, 24, -25]) == 41\n assert candidate(nums = [5000, -2000, 1000, -500, 250, -125, 62, -31, 15, -7, 3, -1]) == 5000\n assert candidate(nums = [10000, 10000, 10000, -10000, -10000, -10000, 10000]) == 30000\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 6, 7, 8, 9, 10]) == 40\n assert candidate(nums = [1000, -2000, 3000, -4000, 5000]) == 5000\n assert candidate(nums = [100, 200, 300, 400, 500, -1500, 600, 700, 800, 900, 1000]) == 4000\n assert candidate(nums = [-9999, 9998, -9997, 9996, -9995, 9994]) == 9999\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 5\n assert candidate(nums = [-20, 19, -18, 17, -16, 15, -14, 13, -12, 11, -10, 9, -8, 7, -6, 5, -4, 3, -2, 1]) == 20\n assert candidate(nums = [100, -1, 200, -2, 300, -3, 400, -4, 500, -5]) == 1490\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110]) == 110\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 15\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, 20, -21, 22]) == 40\n assert candidate(nums = [10000, -9999, 9998, -9997, 9996, -9995, 9994, -9993, 9992, -9991]) == 10000\n assert candidate(nums = [5, -3, 8, -1, 4, -7, 9, -2, 6, -10]) == 19\n assert candidate(nums = [10000, -9999, 9998, -9997, 9996, -9995, 9994]) == 10000\n assert candidate(nums = [5, -3, 8, -6, 2, -4, 7, -9, 1, -1]) == 10\n", "comparison": "exact"}, "public_tests": ["[1,-3,2,3,-4]", "[2,-5,1,-4,3,-2]"], "hints": ["What if we asked for maximum sum, not absolute sum?", "It's a standard problem that can be solved by Kadane's algorithm.", "The key idea is the max absolute sum will be either the max sum or the min sum.", "So just run kadane twice, once calculating the max sum and once calculating the min sum."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxAbsoluteSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:32+00:00", "tests_total": 110, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def maxAbsoluteSum(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maxAbsoluteSum", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1750, "task_id": "minimum-length-of-string-after-deleting-similar-ends", "difficulty": "Medium", "problem_description": "Given a string s consisting only of characters 'a', 'b', and 'c'. You are asked to apply the following algorithm on the string any number of times:\n\n1. Pick a non-empty prefix from the string s where all the characters in the prefix are equal.\n2. Pick a non-empty suffix from the string s where all the characters in this suffix are equal.\n3. The prefix and the suffix should not intersect at any index.\n4. The characters from the prefix and suffix must be the same.\n5. Delete both the prefix and the suffix.\n\nReturn the minimum length of s after performing the above operation any number of times (possibly zero times).\n\nExample 1:\n\nInput: s = \"ca\"\nOutput: 2\nExplanation: You can't remove any characters, so the string stays as is.\n\nExample 2:\n\nInput: s = \"cabaabac\"\nOutput: 0\nExplanation: An optimal sequence of operations is:\n- Take prefix = \"c\" and suffix = \"c\" and remove them, s = \"abaaba\".\n- Take prefix = \"a\" and suffix = \"a\" and remove them, s = \"baab\".\n- Take prefix = \"b\" and suffix = \"b\" and remove them, s = \"aa\".\n- Take prefix = \"a\" and suffix = \"a\" and remove them, s = \"\".\n\nExample 3:\n\nInput: s = \"aabccabba\"\nOutput: 3\nExplanation: An optimal sequence of operations is:\n- Take prefix = \"aa\" and suffix = \"a\" and remove them, s = \"bccabb\".\n- Take prefix = \"b\" and suffix = \"bb\" and remove them, s = \"cca\".\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s only consists of characters 'a', 'b', and 'c'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcba\") == 1\n assert candidate(s = \"ca\") == 2\n assert candidate(s = \"abac\") == 4\n assert candidate(s = \"aabccabba\") == 3\n assert candidate(s = \"aabbaa\") == 0\n assert candidate(s = \"aaaaa\") == 0\n assert candidate(s = \"aababbaa\") == 1\n assert candidate(s = \"cabaabac\") == 0\n assert candidate(s = \"aabbccbaa\") == 0\n assert candidate(s = \"aaa\") == 0\n assert candidate(s = \"abcabc\") == 6\n assert candidate(s = \"aabbbcccbbaa\") == 0\n assert candidate(s = \"aababa\") == 1\n assert candidate(s = \"aabcccbaa\") == 0\n assert candidate(s = \"abc\") == 3\n assert candidate(s = \"abbaccaa\") == 5\n assert candidate(s = \"aaaa\") == 0\n assert candidate(s = \"abccba\") == 0\n assert candidate(s = \"aaabaaa\") == 1\n assert candidate(s = \"aabbcc\") == 6\n assert candidate(s = \"abca\") == 2\n assert candidate(s = \"cccccc\") == 0\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababab\") == 76\n assert candidate(s = \"aabacccbaa\") == 4\n assert candidate(s = \"abacabacabacabacabacabacabacabacabacabacab\") == 42\n assert candidate(s = \"aabbbcccbbbbaa\") == 0\n assert candidate(s = \"ccabbbcccabbbcccabbbcc\") == 18\n assert candidate(s = \"abccbaabccbaabccbaabccba\") == 0\n assert candidate(s = \"acabacabacabacabacabacabacabacab\") == 32\n assert candidate(s = \"cccaaaaabbb\") == 11\n assert candidate(s = \"aaaabbbbccccaaaabbbbcccc\") == 24\n assert candidate(s = \"aaabbbbbbbbccccccaaa\") == 14\n assert candidate(s = \"cbabcbabcb\") == 10\n assert candidate(s = \"bbbbbbaaaaa\") == 11\n assert candidate(s = \"abcabcabc\") == 9\n assert candidate(s = \"aaaabaaaabaaa\") == 0\n assert candidate(s = \"abcabcabcabc\") == 12\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbccccc\") == 24\n assert candidate(s = \"abccbaabcbaabccba\") == 1\n assert candidate(s = \"abacabacabaacaba\") == 1\n assert candidate(s = \"aaabaaaabbaaaabaa\") == 0\n assert candidate(s = \"abacaabacaabaca\") == 13\n assert candidate(s = \"abacbacbacbacbacba\") == 14\n assert candidate(s = \"aaaabaaaabaaaabaaa\") == 1\n assert candidate(s = \"aabccccbbaa\") == 0\n assert candidate(s = \"aaaabbbbcccc\") == 12\n assert candidate(s = \"aabccbaaab\") == 10\n assert candidate(s = \"aaabbbcccbbbbaaa\") == 0\n assert candidate(s = \"aabbbcccbbaaaabbbcccbbaaa\") == 0\n assert candidate(s = \"abbbbaaaaabbbaaaaabbbb\") == 22\n assert candidate(s = \"cccaaaaabbbcccbaaabccbaaabccbaaabccbaa\") == 38\n assert candidate(s = \"bbbbaaaaabbbb\") == 0\n assert candidate(s = \"abccbaabccba\") == 0\n assert candidate(s = \"aaabaaaabbbaaa\") == 0\n assert candidate(s = \"abacabacaba\") == 1\n assert candidate(s = \"aaabaaaabaaaabaaa\") == 1\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\") == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\") == 36\n assert candidate(s = \"abacaba\") == 1\n assert candidate(s = \"cccbbbaaa\") == 9\n assert candidate(s = \"abcbaabcbacba\") == 7\n assert candidate(s = \"aaabaaaabba\") == 0\n assert candidate(s = \"aabbaabbaabbaabb\") == 16\n assert candidate(s = \"abcabcabcabcabcabcabc\") == 21\n assert candidate(s = \"ccabbbccbbbbcabcabbbccabc\") == 22\n assert candidate(s = \"cccccccccccccccccccccc\") == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 99\n assert candidate(s = \"acaacacaacac\") == 12\n assert candidate(s = \"aaabbbcccbbbaaa\") == 0\n assert candidate(s = \"abcbaabcbaabcbaabcbaabcbaabcbaabcba\") == 1\n assert candidate(s = \"abccbaabccbaabccba\") == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 30\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabb\") == 32\n assert candidate(s = \"aaaaabbbbbcccccaaaa\") == 10\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 48\n assert candidate(s = \"ababbababbababb\") == 15\n assert candidate(s = \"aabbbcccbaa\") == 0\n assert candidate(s = \"acaacaaca\") == 1\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 93\n assert candidate(s = \"aabbaaabbbaaabbbaaabbaa\") == 0\n assert candidate(s = \"accbabcbaccbacc\") == 15\n assert candidate(s = \"abcabcabcabcabcabc\") == 18\n assert candidate(s = \"abcbaabcba\") == 0\n assert candidate(s = \"aabbccbbccbbccaa\") == 12\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(s = \"aaaabbbcccbbbaaa\") == 0\n assert candidate(s = \"cbbccbbcc\") == 0\n assert candidate(s = \"abacbacbacbacbacbacbac\") == 22\n assert candidate(s = \"aaaaabccccbaaaa\") == 0\n assert candidate(s = \"ccccaaaabbbbaaaa\") == 16\n assert candidate(s = \"aaabbbcccbbbbaaabbbcccbbbbaaa\") == 0\n assert candidate(s = \"ababababababababababab\") == 22\n assert candidate(s = \"aaaabbbbccccccaaaabbbb\") == 22\n assert candidate(s = \"aabbaaabbbaaabbbaaabbaaa\") == 0\n assert candidate(s = \"abababababababababab\") == 20\n assert candidate(s = \"aaaabccccbbbbaaaa\") == 0\n assert candidate(s = \"aabbbbccccbbbbaaa\") == 0\n assert candidate(s = \"aabaaabaaa\") == 0\n assert candidate(s = \"aabccccbaa\") == 0\n assert candidate(s = \"acccba\") == 4\n assert candidate(s = \"abacbacbacbacbaba\") == 11\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 42\n assert candidate(s = \"aaaabbbaaabbbbaaaabbbaaaa\") == 0\n assert candidate(s = \"abacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabac\") == 96\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 90\n assert candidate(s = \"aaabbbcccbbaaa\") == 0\n assert candidate(s = \"ccbaaaabbbcccbaaaabbbccc\") == 0\n assert candidate(s = \"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\") == 0\n assert candidate(s = \"cccccccccccccccccc\") == 0\n assert candidate(s = \"aaaabbaaabbbaaaa\") == 0\n assert candidate(s = \"aabbaabbaabbaabbaabb\") == 20\n assert candidate(s = \"ababaababa\") == 0\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(s = \"abcbaabcbaabcba\") == 1\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 0\n assert candidate(s = \"aabbaaccbbbaa\") == 4\n assert candidate(s = \"ccccccc\") == 0\n assert candidate(s = \"abccbaabcba\") == 0\n assert candidate(s = \"ababababab\") == 10\n assert candidate(s = \"ccccaaaabbbbcccc\") == 8\n assert candidate(s = \"babbacabacababb\") == 1\n assert candidate(s = \"ccccccabbbbbbbcc\") == 8\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 24\n assert candidate(s = \"aabbaabbccbbccbbccaa\") == 16\n assert candidate(s = \"aaabbbcccbaabbbcccbaaabbb\") == 25\n assert candidate(s = \"ababa\") == 1\n assert candidate(s = \"acaabaaaca\") == 1\n assert candidate(s = \"aabbccbbccbbccbbccaa\") == 16\n assert candidate(s = \"ccccbaaaabbbcccbaaaabbbccc\") == 0\n assert candidate(s = \"aaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaab\") == 72\n assert candidate(s = \"aaaaabbbbbccccccccbbbbbbaaaaa\") == 0\n assert candidate(s = \"ccabbaacc\") == 0\n assert candidate(s = \"acbacbacbacbacba\") == 14\n assert candidate(s = \"abcabcabcabcabc\") == 15\n assert candidate(s = \"ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\") == 0\n assert candidate(s = \"caabaccaabaaccaaa\") == 17\n", "comparison": "exact"}, "public_tests": ["\"ca\"", "\"cabaabac\"", "\"aabccabba\""], "hints": ["If both ends have distinct characters, no more operations can be made. Otherwise, the only operation is to remove all of the same characters from both ends. We will do this as many times as we can.", "Note that if the length is equal 1 the answer is 1"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumLength", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:34+00:00", "tests_total": 170, "tests_dropped": 34, "flags": [], "topic_tags": ["two-pointers", "string"]}, "language": "python", "interface": {"raw_signature": "def minimumLength(self, s: str) -> int:", "container": "Solution", "callable": "minimumLength", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1751, "task_id": "maximum-number-of-events-that-can-be-attended-ii", "difficulty": "Hard", "problem_description": "You are given an array of events where events[i] = [startDay_i, endDay_i, value_i]. The i^th event starts at startDay_iand ends at endDay_i, and if you attend this event, you will receive a value of value_i. You are also given an integer k which represents the maximum number of events you can attend.\n\nYou can only attend one event at a time. If you choose to attend an event, you must attend the entire event. Note that the end day is inclusive: that is, you cannot attend two events where one of them starts and the other ends on the same day.\n\nReturn the maximum sum of values that you can receive by attending events.\n\nExample 1:\n\nInput: events = [[1,2,4],[3,4,3],[2,3,1]], k = 2\nOutput: 7\nExplanation: Choose the green events, 0 and 1 (0-indexed) for a total value of 4 + 3 = 7.\n\nExample 2:\n\nInput: events = [[1,2,4],[3,4,3],[2,3,10]], k = 2\nOutput: 10\nExplanation: Choose event 2 for a total value of 10.\nNotice that you cannot attend any other event as they overlap, and that you do not have to attend k events.\n\nExample 3:\n\nInput: events = [[1,1,1],[2,2,2],[3,3,3],[4,4,4]], k = 3\nOutput: 9\nExplanation: Although the events do not overlap, you can only attend 3 events. Pick the highest valued three.\n\nConstraints:\n\n- 1 <= k <= events.length\n- 1 <= k * events.length <= 10^6\n- 1 <= startDay_i <= endDay_i <= 10^9\n- 1 <= value_i <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(events = [[1, 5, 4], [11, 15, 1], [8, 10, 2], [2, 11, 6]],k = 3) == 7\n assert candidate(events = [[2, 8, 6], [4, 9, 10], [6, 8, 3]],k = 2) == 10\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [6, 10, 5], [2, 9, 4]],k = 2) == 11\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500]],k = 3) == 900\n assert candidate(events = [[1, 2, 7], [2, 3, 10], [3, 4, 3], [1, 5, 5], [6, 7, 1]],k = 4) == 11\n assert candidate(events = [[1, 2, 4], [3, 5, 1], [5, 6, 2], [6, 7, 3]],k = 3) == 8\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [6, 10, 5], [2, 9, 8]],k = 2) == 11\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [6, 10, 5], [2, 7, 8], [9, 10, 4]],k = 3) == 12\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [6, 6, 5], [2, 7, 9]],k = 3) == 11\n assert candidate(events = [[2, 8, 6], [2, 9, 9], [1, 6, 1], [3, 5, 5], [1, 5, 3]],k = 2) == 9\n assert candidate(events = [[1, 2, 100], [2, 3, 100], [3, 4, 100]],k = 1) == 100\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [1, 5, 5], [2, 3, 5], [2, 3, 5]],k = 1) == 6\n assert candidate(events = [[1, 2, 4], [3, 4, 3], [2, 3, 1]],k = 2) == 7\n assert candidate(events = [[1, 2, 3], [4, 5, 4], [1, 5, 5]],k = 2) == 7\n assert candidate(events = [[1, 2, 4], [3, 4, 3], [2, 3, 10]],k = 2) == 10\n assert candidate(events = [[1, 3, 5], [2, 4, 6], [3, 5, 7], [4, 6, 8]],k = 2) == 13\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [1, 5, 5]],k = 2) == 6\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]],k = 3) == 9\n assert candidate(events = [[1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10]],k = 5) == 50\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9], [2, 11, 10], [3, 12, 11], [4, 13, 12], [5, 14, 13], [6, 15, 14]],k = 5) == 18\n assert candidate(events = [[1, 3, 10], [2, 4, 20], [3, 5, 30], [4, 6, 40], [5, 7, 50], [6, 8, 60], [7, 9, 70], [8, 10, 80], [9, 11, 90], [10, 12, 100], [11, 13, 110], [12, 14, 120]],k = 4) == 300\n assert candidate(events = [[1, 1000000000, 1], [1, 1000000000, 2], [1, 1000000000, 3], [1, 1000000000, 4], [1, 1000000000, 5]],k = 5) == 5\n assert candidate(events = [[1, 2, 10], [10, 11, 10], [20, 21, 10], [30, 31, 10], [40, 41, 10], [50, 51, 10], [60, 61, 10], [70, 71, 10], [80, 81, 10], [90, 91, 10]],k = 5) == 50\n assert candidate(events = [[1, 1000000000, 1000000], [2, 999999999, 999999], [3, 888888888, 888888], [4, 777777777, 777777], [5, 666666666, 666666]],k = 3) == 1000000\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [15, 25, 150], [26, 35, 250]],k = 4) == 600\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900], [10, 11, 1000], [11, 12, 1100], [12, 13, 1200], [13, 14, 1300]],k = 7) == 4900\n assert candidate(events = [[1, 10, 10], [2, 9, 8], [3, 8, 6], [4, 7, 4], [5, 6, 2]],k = 5) == 10\n assert candidate(events = [[1, 1, 1000000], [2, 2, 999999], [3, 3, 999998], [4, 4, 999997], [5, 5, 999996], [6, 6, 999995], [7, 7, 999994], [8, 8, 999993], [9, 9, 999992], [10, 10, 999991]],k = 5) == 4999990\n assert candidate(events = [[1, 2, 10], [3, 4, 20], [2, 3, 15], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55]],k = 4) == 160\n assert candidate(events = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9], [1, 10, 10]],k = 1) == 10\n assert candidate(events = [[1, 1, 1000], [2, 2, 2000], [3, 3, 3000], [4, 4, 4000], [5, 5, 5000], [6, 6, 6000], [7, 7, 7000], [8, 8, 8000], [9, 9, 9000]],k = 5) == 35000\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120], [13, 14, 130], [14, 15, 140]],k = 7) == 560\n assert candidate(events = [[1, 10, 5], [2, 9, 6], [3, 8, 7], [4, 7, 8], [5, 6, 9], [11, 20, 10], [12, 19, 11], [13, 18, 12], [14, 17, 13], [15, 16, 14]],k = 4) == 23\n assert candidate(events = [[1, 3, 1000], [2, 5, 1000], [3, 7, 1000], [4, 8, 1000], [5, 10, 1000], [6, 11, 1000], [7, 12, 1000], [8, 13, 1000], [9, 14, 1000], [10, 15, 1000]],k = 5) == 3000\n assert candidate(events = [[1, 2, 1000000], [2, 3, 999999], [3, 4, 999998], [4, 5, 999997], [5, 6, 999996], [6, 7, 999995], [7, 8, 999994], [8, 9, 999993], [9, 10, 999992]],k = 5) == 4999980\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600]],k = 3) == 1500\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110]],k = 6) == 360\n assert candidate(events = [[1, 10, 10], [2, 9, 20], [3, 8, 30], [4, 7, 40], [5, 6, 50], [1, 10, 60], [2, 9, 70], [3, 8, 80], [4, 7, 90], [5, 6, 100]],k = 5) == 100\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100]],k = 5) == 300\n assert candidate(events = [[1, 1000000000, 1000000], [2, 999999999, 900000], [3, 999999998, 800000], [4, 999999997, 700000], [5, 999999996, 600000], [6, 999999995, 500000], [7, 999999994, 400000], [8, 999999993, 300000], [9, 999999992, 200000], [10, 999999991, 100000]],k = 5) == 1000000\n assert candidate(events = [[1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10]],k = 5) == 10\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9]],k = 2) == 9\n assert candidate(events = [[1, 2, 5], [3, 5, 10], [5, 7, 15], [7, 9, 20], [9, 11, 25], [11, 13, 30]],k = 4) == 65\n assert candidate(events = [[1, 3, 50], [2, 4, 60], [3, 5, 70], [4, 6, 80], [5, 7, 90], [6, 8, 100], [7, 9, 110], [8, 10, 120], [9, 11, 130], [10, 12, 140]],k = 3) == 330\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7], [15, 16, 8], [17, 18, 9], [19, 20, 10], [21, 22, 11], [23, 24, 12]],k = 6) == 57\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13]],k = 13) == 91\n assert candidate(events = [[1, 10, 1], [2, 10, 2], [3, 10, 3], [4, 10, 4], [5, 10, 5], [6, 10, 6], [7, 10, 7], [8, 10, 8], [9, 10, 9], [1, 20, 10], [11, 20, 11], [21, 30, 12], [31, 40, 13], [41, 50, 14]],k = 5) == 59\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900]],k = 4) == 2400\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]],k = 5) == 40\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900], [10, 11, 1000], [11, 12, 1100], [12, 13, 1200], [13, 14, 1300]],k = 6) == 4800\n assert candidate(events = [[1, 10, 100], [2, 5, 200], [3, 8, 300], [6, 12, 400], [9, 15, 500]],k = 3) == 800\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]],k = 10) == 30\n assert candidate(events = [[1, 10, 1], [11, 20, 2], [21, 30, 3], [31, 40, 4], [41, 50, 5], [51, 60, 6], [61, 70, 7], [71, 80, 8], [81, 90, 9]],k = 9) == 45\n assert candidate(events = [[1, 2, 4], [1, 2, 3], [1, 2, 2], [1, 2, 1], [3, 4, 5], [3, 4, 6], [5, 6, 7], [5, 6, 8]],k = 3) == 18\n assert candidate(events = [[1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10]],k = 9) == 50\n assert candidate(events = [[1, 1000000000, 1], [2, 1000000000, 2], [3, 1000000000, 3], [4, 1000000000, 4], [5, 1000000000, 5]],k = 3) == 5\n assert candidate(events = [[1, 2, 1000000], [10, 11, 999999], [20, 21, 999998], [30, 31, 999997], [40, 41, 999996], [50, 51, 999995], [60, 61, 999994], [70, 71, 999993], [80, 81, 999992], [90, 91, 999991]],k = 10) == 9999955\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9], [1, 11, 10], [1, 12, 11], [1, 13, 12], [1, 14, 13], [1, 15, 14]],k = 7) == 14\n assert candidate(events = [[1, 5, 1], [1, 5, 2], [1, 5, 3], [1, 5, 4], [1, 5, 5], [1, 5, 6], [1, 5, 7], [1, 5, 8], [1, 5, 9], [1, 5, 10], [1, 5, 11], [1, 5, 12], [1, 5, 13], [1, 5, 14], [1, 5, 15]],k = 5) == 15\n assert candidate(events = [[1, 10, 10], [11, 20, 20], [21, 30, 30], [31, 40, 40], [41, 50, 50], [51, 60, 60], [61, 70, 70], [71, 80, 80], [81, 90, 90], [91, 100, 100]],k = 10) == 550\n assert candidate(events = [[1, 3, 100], [2, 5, 200], [3, 6, 300], [4, 7, 400], [5, 8, 500], [6, 9, 600]],k = 3) == 800\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7], [15, 16, 8], [17, 18, 9], [19, 20, 10]],k = 5) == 40\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120]],k = 10) == 420\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [2, 3, 6], [2, 4, 7], [2, 5, 8], [2, 6, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [5, 6, 15]],k = 3) == 26\n assert candidate(events = [[1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1]],k = 5) == 1\n assert candidate(events = [[1, 1, 100], [1, 1, 200], [1, 1, 300], [1, 1, 400], [1, 1, 500], [1, 1, 600], [1, 1, 700], [1, 1, 800], [1, 1, 900], [1, 1, 1000]],k = 5) == 1000\n assert candidate(events = [[1, 5, 5], [5, 10, 10], [10, 15, 15], [15, 20, 20], [20, 25, 25], [25, 30, 30], [30, 35, 35]],k = 3) == 75\n assert candidate(events = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [2, 2, 1], [2, 3, 2], [2, 4, 3], [2, 5, 4], [3, 3, 1], [3, 4, 2], [3, 5, 3], [4, 4, 1], [4, 5, 2], [5, 5, 1]],k = 3) == 5\n assert candidate(events = [[5, 10, 15], [5, 7, 10], [7, 12, 20], [9, 15, 18], [10, 17, 12], [13, 20, 30], [14, 20, 25]],k = 3) == 50\n assert candidate(events = [[1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5], [11, 20, 6], [12, 19, 7], [13, 18, 8], [14, 17, 9], [15, 16, 10]],k = 5) == 15\n assert candidate(events = [[1, 3, 100], [2, 5, 200], [3, 6, 300], [4, 7, 400], [5, 8, 500], [6, 9, 600]],k = 4) == 800\n assert candidate(events = [[1, 1, 100], [2, 2, 200], [3, 3, 300], [4, 4, 400], [5, 5, 500], [6, 6, 600], [7, 7, 700], [8, 8, 800], [9, 9, 900], [10, 10, 1000]],k = 10) == 5500\n assert candidate(events = [[1, 5, 5], [6, 10, 10], [11, 15, 15], [16, 20, 20], [21, 25, 25], [26, 30, 30], [31, 35, 35], [36, 40, 40], [41, 45, 45], [46, 50, 50]],k = 5) == 200\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120]],k = 6) == 420\n assert candidate(events = [[1, 1000000000, 1], [1, 1000000000, 2], [1, 1000000000, 3], [1, 1000000000, 4], [1, 1000000000, 5]],k = 2) == 5\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]],k = 5) == 25\n assert candidate(events = [[1, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 10, 10], [7, 11, 11], [8, 12, 12], [9, 13, 13], [10, 14, 14]],k = 3) == 23\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]],k = 7) == 63\n assert candidate(events = [[1, 1000000000, 1], [1000000000, 1000000000, 1000000]],k = 1) == 1000000\n assert candidate(events = [[1, 2, 1], [1, 2, 2], [1, 2, 3], [2, 3, 4], [2, 3, 5], [2, 3, 6], [3, 4, 7], [3, 4, 8], [3, 4, 9], [4, 5, 10]],k = 3) == 16\n assert candidate(events = [[1, 3, 50], [2, 5, 20], [4, 6, 40], [6, 9, 60], [8, 11, 80], [10, 12, 30]],k = 3) == 170\n assert candidate(events = [[1, 2, 1000000], [2, 3, 1000000], [3, 4, 1000000], [4, 5, 1000000], [5, 6, 1000000], [6, 7, 1000000]],k = 3) == 3000000\n assert candidate(events = [[1, 2, 100], [3, 4, 200], [5, 6, 300], [7, 8, 400], [9, 10, 500], [11, 12, 600], [13, 14, 700], [15, 16, 800], [17, 18, 900]],k = 5) == 3500\n assert candidate(events = [[1, 3, 10], [2, 5, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50], [6, 10, 60], [7, 11, 70], [8, 12, 80], [9, 13, 90]],k = 4) == 140\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600], [61, 70, 700], [71, 80, 800], [81, 90, 900], [91, 100, 1000]],k = 5) == 4000\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9], [1, 11, 10]],k = 5) == 10\n assert candidate(events = [[1, 2, 1000], [2, 3, 2000], [3, 4, 3000], [4, 5, 4000], [5, 6, 5000], [6, 7, 6000], [7, 8, 7000], [8, 9, 8000], [9, 10, 9000]],k = 9) == 25000\n assert candidate(events = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9], [1, 10, 10], [1, 11, 11], [1, 12, 12], [1, 13, 13], [1, 14, 14], [1, 15, 15]],k = 15) == 15\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600], [61, 70, 700], [71, 80, 800], [81, 90, 900], [91, 100, 1000]],k = 3) == 2700\n assert candidate(events = [[1, 20, 100], [2, 15, 80], [3, 10, 60], [4, 5, 40], [5, 6, 20], [6, 7, 10], [7, 8, 5], [8, 9, 3], [9, 10, 2], [10, 11, 1], [11, 12, 2], [12, 13, 3], [13, 14, 5], [14, 15, 10], [15, 16, 20], [16, 17, 40], [17, 18, 60], [18, 19, 80], [19, 20, 100]],k = 10) == 247\n assert candidate(events = [[1, 3, 5], [2, 5, 8], [4, 6, 6], [6, 8, 3], [5, 7, 10], [7, 9, 4]],k = 4) == 15\n assert candidate(events = [[1, 2, 100], [3, 5, 150], [6, 8, 200], [9, 11, 250], [12, 14, 300], [15, 17, 350]],k = 4) == 1100\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]],k = 5) == 30\n assert candidate(events = [[1, 100, 1000], [2, 99, 900], [3, 98, 800], [4, 97, 700], [5, 96, 600], [6, 95, 500], [7, 94, 400], [8, 93, 300], [9, 92, 200], [10, 91, 100]],k = 5) == 1000\n assert candidate(events = [[1, 100, 1], [50, 150, 10], [100, 200, 50], [150, 250, 100], [200, 300, 200], [250, 350, 500], [300, 400, 1000], [350, 450, 2000], [400, 500, 5000]],k = 5) == 5550\n assert candidate(events = [[1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5]],k = 4) == 5\n assert candidate(events = [[1, 50, 500], [51, 100, 400], [101, 150, 300], [151, 200, 200], [201, 250, 100]],k = 3) == 1200\n assert candidate(events = [[1, 10, 50], [11, 20, 100], [21, 30, 150], [31, 40, 200], [41, 50, 250]],k = 3) == 600\n assert candidate(events = [[1, 3, 5], [2, 4, 6], [3, 5, 7], [4, 6, 8], [5, 7, 9], [6, 8, 10], [7, 9, 11], [8, 10, 12], [9, 11, 13]],k = 4) == 30\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13], [14, 14, 14]],k = 7) == 77\n assert candidate(events = [[1, 2, 50], [1, 3, 40], [1, 4, 30], [1, 5, 20], [1, 6, 10], [2, 7, 60], [3, 8, 70], [4, 9, 80], [5, 10, 90], [6, 11, 100]],k = 4) == 150\n assert candidate(events = [[1, 2, 10], [1, 2, 20], [1, 2, 30], [1, 2, 40], [1, 2, 50], [1, 2, 60], [1, 2, 70], [1, 2, 80], [1, 2, 90], [1, 2, 100]],k = 3) == 100\n", "comparison": "exact"}, "public_tests": ["[[1,2,4],[3,4,3],[2,3,1]]\n2", "[[1,2,4],[3,4,3],[2,3,10]]\n2", "[[1,1,1],[2,2,2],[3,3,3],[4,4,4]]\n3"], "hints": ["Sort the events by its startTime.", "For every event, you can either choose it and consider the next event available, or you can ignore it. You can efficiently find the next event that is available using binary search."], "metadata": {"canonical_parameter_names": ["events", "k"], "leetcode_dataset_entry_point": "Solution().maxValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:37+00:00", "tests_total": 108, "tests_dropped": 6, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "dynamic-programming", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxValue(self, events: list[list[int]], k: int) -> int:", "container": "Solution", "callable": "maxValue", "parameters": [{"name": "events", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1752, "task_id": "check-if-array-is-sorted-and-rotated", "difficulty": "Easy", "problem_description": "Given an array nums, return true if the array was originally sorted in non-decreasing order, then rotated some number of positions (including zero). Otherwise, return false.\n\nThere may be duplicates in the original array.\n\nNote: An array A rotated by x positions results in an array B of the same length such that B[i] == A[(i+x) % A.length] for every valid index i.\n\nExample 1:\n\nInput: nums = [3,4,5,1,2]\nOutput: true\nExplanation: [1,2,3,4,5] is the original sorted array.\nYou can rotate the array by x = 2 positions to begin on the element of value 3: [3,4,5,1,2].\n\nExample 2:\n\nInput: nums = [2,1,3,4]\nOutput: false\nExplanation: There is no sorted array once rotated that can make nums.\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: true\nExplanation: [1,2,3] is the original sorted array.\nYou can rotate the array by x = 0 positions (i.e. no rotation) to make nums.\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 1 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 1, 3, 4]) == False\n assert candidate(nums = [1, 3, 2]) == False\n assert candidate(nums = [4, 5, 6, 1, 2, 3]) == True\n assert candidate(nums = [1, 3, 5, 7, 2, 4, 6, 8]) == False\n assert candidate(nums = [2, 2, 1, 1, 1]) == True\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [2, 1, 2]) == True\n assert candidate(nums = [1, 2, 3]) == True\n assert candidate(nums = [1, 1, 1]) == True\n assert candidate(nums = [2, 3, 4, 5, 1]) == True\n assert candidate(nums = [5, 1, 2, 3, 4]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [100, 1, 100, 100]) == True\n assert candidate(nums = [3, 4, 5, 1, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 3, 2, 4, 5]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 1, 3]) == False\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == True\n assert candidate(nums = [3, 3, 4, 4, 5, 5, 1, 1, 2, 2]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [1, 3, 4, 5, 6, 7, 8, 9, 10, 2]) == False\n assert candidate(nums = [5, 5, 5, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == True\n assert candidate(nums = [3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == False\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3]) == True\n assert candidate(nums = [7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [2, 3, 4, 5, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 1, 2, 3, 3, 3]) == True\n assert candidate(nums = [6, 7, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [2, 3, 4, 5, 1, 2, 3, 4, 5]) == False\n assert candidate(nums = [1, 2, 1]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 1, 2, 3, 4, 5]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == False\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == True\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2]) == True\n assert candidate(nums = [7, 8, 9, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == True\n assert candidate(nums = [1, 3, 2, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == False\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(nums = [1, 2, 3, 2, 1]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 1, 2]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1]) == True\n assert candidate(nums = [8, 9, 1, 2, 3, 4, 5, 6, 7]) == True\n assert candidate(nums = [30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(nums = [99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 98]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 2]) == False\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1]) == True\n assert candidate(nums = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5]) == False\n assert candidate(nums = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4]) == True\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == True\n assert candidate(nums = [5, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [9, 10, 11, 12, 13, 5, 6, 7, 8]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == False\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 1, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 1, 2, 3]) == False\n assert candidate(nums = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(nums = [2, 3, 1, 2, 3]) == False\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 2, 3]) == True\n assert candidate(nums = [1, 3, 2, 2, 3, 4, 5]) == False\n assert candidate(nums = [100, 1, 100, 100, 100]) == True\n assert candidate(nums = [5, 6, 7, 8, 1, 2, 3, 4, 5, 6]) == False\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 99]) == True\n assert candidate(nums = [99, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == False\n assert candidate(nums = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1]) == True\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2]) == False\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3]) == False\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 1, 1]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 1, 3, 3, 3]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 1]) == True\n assert candidate(nums = [9, 10, 1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1]) == False\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) == True\n assert candidate(nums = [99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == True\n assert candidate(nums = [3, 4, 5, 2, 1]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 3, 3, 3, 3]) == False\n assert candidate(nums = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [8, 9, 9, 9, 1, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [3, 1, 2]) == True\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]) == True\n assert candidate(nums = [2, 2, 2, 2, 1, 2, 2, 2, 2]) == True\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == False\n assert candidate(nums = [3, 4, 5, 1, 1, 2, 2]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1]) == True\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == True\n assert candidate(nums = [6, 7, 8, 9, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [2, 2, 2, 2, 1, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [4, 5, 6, 7, 8, 1, 2, 3]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == False\n assert candidate(nums = [6, 10, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [8, 9, 10, 1, 2, 3, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [100, 1, 100, 100, 100, 100]) == True\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == False\n assert candidate(nums = [5, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1]) == True\n", "comparison": "exact"}, "public_tests": ["[3,4,5,1,2]", "[2,1,3,4]", "[1,2,3]"], "hints": ["Brute force and check if it is possible for a sorted array to start from each position."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().check", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:39+00:00", "tests_total": 141, "tests_dropped": 7, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def check(self, nums: list[int]) -> bool:", "container": "Solution", "callable": "check", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1753, "task_id": "maximum-score-from-removing-stones", "difficulty": "Medium", "problem_description": "You are playing a solitaire game with three piles of stones of sizes a, b, and c respectively. Each turn you choose two different non-empty piles, take one stone from each, and add 1 point to your score. The game stops when there are fewer than two non-empty piles (meaning there are no more available moves).\n\nGiven three integers a, b, and c, return the maximum score you can get.\n\nExample 1:\n\nInput: a = 2, b = 4, c = 6\nOutput: 6\nExplanation: The starting state is (2, 4, 6). One optimal set of moves is:\n- Take from 1st and 3rd piles, state is now (1, 4, 5)\n- Take from 1st and 3rd piles, state is now (0, 4, 4)\n- Take from 2nd and 3rd piles, state is now (0, 3, 3)\n- Take from 2nd and 3rd piles, state is now (0, 2, 2)\n- Take from 2nd and 3rd piles, state is now (0, 1, 1)\n- Take from 2nd and 3rd piles, state is now (0, 0, 0)\nThere are fewer than two non-empty piles, so the game ends. Total: 6 points.\n\nExample 2:\n\nInput: a = 4, b = 4, c = 6\nOutput: 7\nExplanation: The starting state is (4, 4, 6). One optimal set of moves is:\n- Take from 1st and 2nd piles, state is now (3, 3, 6)\n- Take from 1st and 3rd piles, state is now (2, 3, 5)\n- Take from 1st and 3rd piles, state is now (1, 3, 4)\n- Take from 1st and 3rd piles, state is now (0, 3, 3)\n- Take from 2nd and 3rd piles, state is now (0, 2, 2)\n- Take from 2nd and 3rd piles, state is now (0, 1, 1)\n- Take from 2nd and 3rd piles, state is now (0, 0, 0)\nThere are fewer than two non-empty piles, so the game ends. Total: 7 points.\n\nExample 3:\n\nInput: a = 1, b = 8, c = 8\nOutput: 8\nExplanation: One optimal set of moves is to take from the 2nd and 3rd piles for 8 turns until they are empty.\nAfter that, there are fewer than two non-empty piles, so the game ends.\n\nConstraints:\n\n- 1 <= a, b, c <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = 10,b = 10,c = 1) == 10\n assert candidate(a = 5,b = 7,c = 9) == 10\n assert candidate(a = 5,b = 5,c = 5) == 7\n assert candidate(a = 1,b = 8,c = 8) == 8\n assert candidate(a = 3,b = 3,c = 3) == 4\n assert candidate(a = 100000,b = 1,c = 1) == 2\n assert candidate(a = 100000,b = 100000,c = 100000) == 150000\n assert candidate(a = 4,b = 4,c = 6) == 7\n assert candidate(a = 30,b = 60,c = 90) == 90\n assert candidate(a = 1,b = 1,c = 100000) == 2\n assert candidate(a = 50000,b = 50000,c = 1) == 50000\n assert candidate(a = 10,b = 10,c = 10) == 15\n assert candidate(a = 2,b = 4,c = 6) == 6\n assert candidate(a = 5,b = 10,c = 15) == 15\n assert candidate(a = 20,b = 30,c = 40) == 45\n assert candidate(a = 7,b = 7,c = 14) == 14\n assert candidate(a = 10,b = 1,c = 1) == 2\n assert candidate(a = 7,b = 14,c = 10) == 15\n assert candidate(a = 1,b = 1,c = 2) == 2\n assert candidate(a = 7,b = 8,c = 9) == 12\n assert candidate(a = 33333,b = 33333,c = 33334) == 50000\n assert candidate(a = 50000,b = 50000,c = 50001) == 75000\n assert candidate(a = 1000,b = 1000,c = 1000) == 1500\n assert candidate(a = 80,b = 80,c = 40) == 100\n assert candidate(a = 7,b = 14,c = 21) == 21\n assert candidate(a = 10,b = 15,c = 20) == 22\n assert candidate(a = 5000,b = 5001,c = 5002) == 7501\n assert candidate(a = 33333,b = 66666,c = 100000) == 99999\n assert candidate(a = 50000,b = 1,c = 1) == 2\n assert candidate(a = 60000,b = 20000,c = 20000) == 40000\n assert candidate(a = 99999,b = 1,c = 1) == 2\n assert candidate(a = 5,b = 5,c = 100) == 10\n assert candidate(a = 80000,b = 80000,c = 1) == 80000\n assert candidate(a = 99998,b = 99999,c = 100000) == 149998\n assert candidate(a = 20,b = 20,c = 20) == 30\n assert candidate(a = 50000,b = 40000,c = 30000) == 60000\n assert candidate(a = 10000,b = 10000,c = 1) == 10000\n assert candidate(a = 5,b = 5,c = 10) == 10\n assert candidate(a = 10000,b = 10000,c = 10000) == 15000\n assert candidate(a = 42,b = 27,c = 19) == 44\n assert candidate(a = 45000,b = 45000,c = 10000) == 50000\n assert candidate(a = 2,b = 2,c = 100000) == 4\n assert candidate(a = 25,b = 25,c = 24) == 37\n assert candidate(a = 500,b = 500,c = 1500) == 1000\n assert candidate(a = 100,b = 200,c = 300) == 300\n assert candidate(a = 15,b = 15,c = 15) == 22\n assert candidate(a = 25,b = 75,c = 125) == 100\n assert candidate(a = 20,b = 20,c = 21) == 30\n assert candidate(a = 20000,b = 30000,c = 10000) == 30000\n assert candidate(a = 20,b = 40,c = 60) == 60\n assert candidate(a = 12345,b = 67890,c = 11111) == 23456\n assert candidate(a = 80000,b = 10000,c = 10000) == 20000\n assert candidate(a = 12345,b = 67890,c = 54321) == 66666\n assert candidate(a = 5,b = 15,c = 20) == 20\n assert candidate(a = 2,b = 2,c = 3) == 3\n assert candidate(a = 100,b = 100,c = 101) == 150\n assert candidate(a = 3,b = 3,c = 9) == 6\n assert candidate(a = 15,b = 25,c = 35) == 37\n assert candidate(a = 50000,b = 50000,c = 99999) == 99999\n assert candidate(a = 10000,b = 20000,c = 30000) == 30000\n assert candidate(a = 10000,b = 5000,c = 5000) == 10000\n assert candidate(a = 25000,b = 25000,c = 50000) == 50000\n assert candidate(a = 99999,b = 99998,c = 99997) == 149997\n assert candidate(a = 75,b = 25,c = 50) == 75\n assert candidate(a = 1,b = 2,c = 3) == 3\n assert candidate(a = 10,b = 20,c = 30) == 30\n assert candidate(a = 3,b = 9,c = 9) == 10\n assert candidate(a = 15,b = 10,c = 5) == 15\n assert candidate(a = 30,b = 5,c = 25) == 30\n assert candidate(a = 50,b = 50,c = 100) == 100\n assert candidate(a = 100,b = 100,c = 100) == 150\n assert candidate(a = 99999,b = 99999,c = 99999) == 149998\n assert candidate(a = 100,b = 100,c = 1) == 100\n assert candidate(a = 50000,b = 49999,c = 49998) == 74998\n assert candidate(a = 50,b = 25,c = 25) == 50\n assert candidate(a = 98765,b = 43210,c = 54321) == 97531\n assert candidate(a = 5000,b = 5000,c = 10000) == 10000\n assert candidate(a = 55,b = 15,c = 35) == 50\n assert candidate(a = 33333,b = 33334,c = 33335) == 50001\n assert candidate(a = 10000,b = 10000,c = 5000) == 12500\n assert candidate(a = 30,b = 50,c = 20) == 50\n assert candidate(a = 30,b = 30,c = 30) == 45\n assert candidate(a = 60000,b = 40000,c = 20000) == 60000\n assert candidate(a = 1,b = 1,c = 1) == 1\n assert candidate(a = 8,b = 8,c = 8) == 12\n assert candidate(a = 100000,b = 50000,c = 50000) == 100000\n", "comparison": "exact"}, "public_tests": ["2\n4\n6", "4\n4\n6", "1\n8\n8"], "hints": ["It's optimal to always remove one stone from the biggest 2 piles", "Note that the limits are small enough for simulation"], "metadata": {"canonical_parameter_names": ["a", "b", "c"], "leetcode_dataset_entry_point": "Solution().maximumScore", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:41+00:00", "tests_total": 88, "tests_dropped": 2, "flags": [], "topic_tags": ["math", "greedy", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def maximumScore(self, a: int, b: int, c: int) -> int:", "container": "Solution", "callable": "maximumScore", "parameters": [{"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1754, "task_id": "largest-merge-of-two-strings", "difficulty": "Medium", "problem_description": "You are given two strings word1 and word2. You want to construct a string merge in the following way: while either word1 or word2 are non-empty, choose one of the following options:\n\n- If word1 is non-empty, append the first character in word1 to merge and delete it from word1.\n - For example, if word1 = \"abc\" and merge = \"dv\", then after choosing this operation, word1 = \"bc\" and merge = \"dva\".\n- If word2 is non-empty, append the first character in word2 to merge and delete it from word2.\n - For example, if word2 = \"abc\" and merge = \"\", then after choosing this operation, word2 = \"bc\" and merge = \"a\".\n\nReturn the lexicographically largest merge you can construct.\n\nA string a is lexicographically larger than a string b (of the same length) if in the first position where a and b differ, a has a character strictly larger than the corresponding character in b. For example, \"abcd\" is lexicographically larger than \"abcc\" because the first position they differ is at the fourth character, and d is greater than c.\n\nExample 1:\n\nInput: word1 = \"cabaa\", word2 = \"bcaaa\"\nOutput: \"cbcabaaaaa\"\nExplanation: One way to get the lexicographically largest merge is:\n- Take from word1: merge = \"c\", word1 = \"abaa\", word2 = \"bcaaa\"\n- Take from word2: merge = \"cb\", word1 = \"abaa\", word2 = \"caaa\"\n- Take from word2: merge = \"cbc\", word1 = \"abaa\", word2 = \"aaa\"\n- Take from word1: merge = \"cbca\", word1 = \"baa\", word2 = \"aaa\"\n- Take from word1: merge = \"cbcab\", word1 = \"aa\", word2 = \"aaa\"\n- Append the remaining 5 a's from word1 and word2 at the end of merge.\n\nExample 2:\n\nInput: word1 = \"abcabc\", word2 = \"abdcaba\"\nOutput: \"abdcabcabcaba\"\n\nConstraints:\n\n- 1 <= word1.length, word2.length <= 3000\n- word1 and word2 consist only of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"lexicographically\",word2 = \"largestmerge\") == \"llexicogrargestmergeaphically\"\n assert candidate(word1 = \"zyxw\",word2 = \"abcd\") == \"zyxwabcd\"\n assert candidate(word1 = \"abcdabcd\",word2 = \"zyxwzyxw\") == \"zyxwzyxwabcdabcd\"\n assert candidate(word1 = \"leetcode\",word2 = \"challenge\") == \"leetcodechallenge\"\n assert candidate(word1 = \"aaaab\",word2 = \"aaabb\") == \"aaabbaaaab\"\n assert candidate(word1 = \"lexicographic\",word2 = \"merge\") == \"mlexiergecographic\"\n assert candidate(word1 = \"aaaa\",word2 = \"bbbb\") == \"bbbbaaaa\"\n assert candidate(word1 = \"abcabc\",word2 = \"abdcaba\") == \"abdcabcabcaba\"\n assert candidate(word1 = \"abc\",word2 = \"defghijklmnopqrstuvwxyz\") == \"defghijklmnopqrstuvwxyzabc\"\n assert candidate(word1 = \"z\",word2 = \"z\") == \"zz\"\n assert candidate(word1 = \"hello\",word2 = \"world\") == \"worlhellod\"\n assert candidate(word1 = \"abcd\",word2 = \"zyxw\") == \"zyxwabcd\"\n assert candidate(word1 = \"leetcode\",word2 = \"etco\") == \"leteetcodeco\"\n assert candidate(word1 = \"xy\",word2 = \"xy\") == \"xyxy\"\n assert candidate(word1 = \"cabaa\",word2 = \"bcaaa\") == \"cbcabaaaaa\"\n assert candidate(word1 = \"aabbcc\",word2 = \"bbccdd\") == \"bbccddaabbcc\"\n assert candidate(word1 = \"zzz\",word2 = \"zzz\") == \"zzzzzz\"\n assert candidate(word1 = \"a\",word2 = \"b\") == \"ba\"\n assert candidate(word1 = \"aaaaa\",word2 = \"bbbbb\") == \"bbbbbaaaaa\"\n assert candidate(word1 = \"aabbcc\",word2 = \"abcabc\") == \"abcabcaabbcc\"\n assert candidate(word1 = \"xyz\",word2 = \"xyz\") == \"xyzxyz\"\n assert candidate(word1 = \"abcd\",word2 = \"efgh\") == \"efghabcd\"\n assert candidate(word1 = \"abcd\",word2 = \"dcba\") == \"dcbabcda\"\n assert candidate(word1 = \"same\",word2 = \"same\") == \"ssameame\"\n assert candidate(word1 = \"abcdabcd\",word2 = \"abcde\") == \"abcdeabcdabcd\"\n assert candidate(word1 = \"bca\",word2 = \"cab\") == \"cbcaba\"\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcbabcdefghijklmnopqrstuvwxyza\"\n assert candidate(word1 = \"mississippi\",word2 = \"missouri\") == \"mmissourississippii\"\n assert candidate(word1 = \"zzzzzzzz\",word2 = \"zzzzzzzz\") == \"zzzzzzzzzzzzzzzz\"\n assert candidate(word1 = \"complexity\",word2 = \"similarity\") == \"similcomplexityarity\"\n assert candidate(word1 = \"xyzzzzzzzzzzzzzzzz\",word2 = \"xyzzzzzzzzzzzzzz\") == \"xyzzzzzzzzzzzzzzzzxyzzzzzzzzzzzzzz\"\n assert candidate(word1 = \"aaaabbbbccccdddd\",word2 = \"aaaabbbbccccdddd\") == \"aaaabbbbccccddddaaaabbbbccccdddd\"\n assert candidate(word1 = \"zzzzzzz\",word2 = \"zzzzzzzz\") == \"zzzzzzzzzzzzzzz\"\n assert candidate(word1 = \"aaaaaaa\",word2 = \"bbbbbbb\") == \"bbbbbbbaaaaaaa\"\n assert candidate(word1 = \"zzzzz\",word2 = \"zzzz\") == \"zzzzzzzzz\"\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzzyyxxwwvvuuttssrrqqponmlkjihgfedcbbaa\") == \"zzzyyxxwwvvuuttssrrqqponmlkjihgfedcbbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaa\"\n assert candidate(word1 = \"zyxwvut\",word2 = \"utsrqponmlkjihgfedcba\") == \"zyxwvuuttsrqponmlkjihgfedcba\"\n assert candidate(word1 = \"pqrstuvwxyz\",word2 = \"nopqrstuvwxyz\") == \"pqrstuvwxyznopqrstuvwxyz\"\n assert candidate(word1 = \"zzzzzz\",word2 = \"zzzzzz\") == \"zzzzzzzzzzzz\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"feebdccbaa\") == \"feebdccbaabbccddeeffaa\"\n assert candidate(word1 = \"cccccccc\",word2 = \"dddddddd\") == \"ddddddddcccccccc\"\n assert candidate(word1 = \"a\",word2 = \"z\") == \"za\"\n assert candidate(word1 = \"aabbcc\",word2 = \"aaabbb\") == \"aabbccaaabbb\"\n assert candidate(word1 = \"abcdxyz\",word2 = \"xyzabcd\") == \"xyzabcdxyzabcd\"\n assert candidate(word1 = \"python\",word2 = \"java\") == \"pytjhonava\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"abcabcabc\") == \"abcdabcdabcdabcabcabc\"\n assert candidate(word1 = \"sameprefix\",word2 = \"sameprefixsuffix\") == \"ssameprefixsuffixameprefix\"\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcba\") == \"jihgfedcbabcdefghija\"\n assert candidate(word1 = \"onetwothreefour\",word2 = \"fivesixseveneightnine\") == \"onfivetwothresixseveneightnineefoure\"\n assert candidate(word1 = \"racecar\",word2 = \"racecar\") == \"rracecaracecar\"\n assert candidate(word1 = \"abcdabcdabcdabcdabcdabcd\",word2 = \"zyxwzyxwzyxwzyxwzyxwzyxw\") == \"zyxwzyxwzyxwzyxwzyxwzyxwabcdabcdabcdabcdabcdabcd\"\n assert candidate(word1 = \"xyxzyzyzyx\",word2 = \"zyzyzyzyxz\") == \"zyzyzyzyxzxyxzyzyzyx\"\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"xyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyzabacabadabacaba\"\n assert candidate(word1 = \"xyzz\",word2 = \"yxzz\") == \"yxzzxyzz\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"zyxwzyxwzyxw\") == \"zyxwzyxwzyxwabcdabcdabcd\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"zzzzyyyxxx\") == \"zzzzyyyxxxaabbccddeeff\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"zzyyxxwwvvuu\") == \"zzyyxxwwvvuuaabbccddeeff\"\n assert candidate(word1 = \"abcdefg\",word2 = \"hijklmnop\") == \"hijklmnopabcdefg\"\n assert candidate(word1 = \"banana\",word2 = \"bandana\") == \"bbandanananaa\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"dcbaabcdabcd\") == \"dcbabcdabcdabcdaabcdabcd\"\n assert candidate(word1 = \"abracadabra\",word2 = \"alakazam\") == \"alakazamabracadabra\"\n assert candidate(word1 = \"aaaabbbbcccc\",word2 = \"bbbbaaaacccc\") == \"bbbbaaaaccccaaaabbbbcccc\"\n assert candidate(word1 = \"leetcode\",word2 = \"edocteel\") == \"leetedocteelcode\"\n assert candidate(word1 = \"aaaaaaaabbbbbbbbcccccccc\",word2 = \"ccccccccbbbbbbbbbaaaaaaa\") == \"ccccccccbbbbbbbbbaaaaaaaabbbbbbbbccccccccaaaaaaa\"\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxcba\") == \"zyxcbabcdxyza\"\n assert candidate(word1 = \"ababababab\",word2 = \"bababababa\") == \"babababababababababa\"\n assert candidate(word1 = \"equalequal\",word2 = \"equal\") == \"equequalequalal\"\n assert candidate(word1 = \"abcabcabc\",word2 = \"abcabcabc\") == \"abcabcabcabcabcabc\"\n assert candidate(word1 = \"zzzzzzyyyy\",word2 = \"yyyyzzzzzz\") == \"zzzzzzyyyyzzzzzzyyyy\"\n assert candidate(word1 = \"racecar\",word2 = \"race\") == \"rracecarace\"\n assert candidate(word1 = \"programming\",word2 = \"challenges\") == \"progrchammingallenges\"\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzza\"\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxwvut\") == \"zyxwvutabcdxyz\"\n assert candidate(word1 = \"abacaxi\",word2 = \"abacax\") == \"abacaxiabacax\"\n assert candidate(word1 = \"aaaaaabbbbb\",word2 = \"cccccdddddeeeee\") == \"cccccdddddeeeeeaaaaaabbbbb\"\n assert candidate(word1 = \"abcdefg\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcbabcdefga\"\n assert candidate(word1 = \"samecharacters\",word2 = \"samecharacters\") == \"ssamecharamecharactersacters\"\n assert candidate(word1 = \"abababababab\",word2 = \"babababababa\") == \"babababababababababababa\"\n assert candidate(word1 = \"aaaaab\",word2 = \"bbbaaa\") == \"bbbaaaaabaaa\"\n assert candidate(word1 = \"aabbbccc\",word2 = \"aabbcc\") == \"aabbccaabbbccc\"\n assert candidate(word1 = \"zzzzz\",word2 = \"zzzzzz\") == \"zzzzzzzzzzz\"\n assert candidate(word1 = \"abcdefghijk\",word2 = \"abcdefghijl\") == \"abcdefghijlabcdefghijk\"\n assert candidate(word1 = \"nestednested\",word2 = \"nested\") == \"nnestesteednestedd\"\n assert candidate(word1 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",word2 = \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(word1 = \"abcde\",word2 = \"edcba\") == \"edcbabcdea\"\n assert candidate(word1 = \"supercalifragilisticexpialidocious\",word2 = \"antidisestablishmentarianism\") == \"supercantidisestalifragilisticexpialidociousablishmentarianism\"\n assert candidate(word1 = \"xyzz\",word2 = \"zzxy\") == \"zzxyzzxy\"\n assert candidate(word1 = \"xyzz\",word2 = \"zzx\") == \"zzxyzzx\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"zzzzyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihghffeeddccbbaa\") == \"zzzzyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihghffeeddccbbaabbccddeeffaa\"\n assert candidate(word1 = \"abababab\",word2 = \"babababa\") == \"babababababababa\"\n assert candidate(word1 = \"xylophone\",word2 = \"xylophon\") == \"xyxyloplophonhone\"\n assert candidate(word1 = \"abcdabcdabcdabcd\",word2 = \"zyxwzyxwzyxwzyxw\") == \"zyxwzyxwzyxwzyxwabcdabcdabcdabcd\"\n assert candidate(word1 = \"zzzz\",word2 = \"zzzz\") == \"zzzzzzzz\"\n assert candidate(word1 = \"longwordone\",word2 = \"longwordtwo\") == \"lonlongworgwordtwodone\"\n assert candidate(word1 = \"aaaaaaaaaaaa\",word2 = \"bbbbbbbbbbba\") == \"bbbbbbbbbbbaaaaaaaaaaaaa\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"dcba\") == \"dcbabcdabcdabcda\"\n assert candidate(word1 = \"aaaabbbbcccc\",word2 = \"ddddccccbbbaaaa\") == \"ddddccccbbbaaaabbbbccccaaaa\"\n assert candidate(word1 = \"leetcode\",word2 = \"contest\") == \"leetcontestcode\"\n assert candidate(word1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",word2 = \"zoology\") == \"zpoonlogyeumonoultramicroscopicsilicovolcanoconiosis\"\n assert candidate(word1 = \"abcdabcdb\",word2 = \"abcdabcdb\") == \"abcdabcdbabcdabcdb\"\n assert candidate(word1 = \"amazing\",word2 = \"algorithm\") == \"amazingalgorithm\"\n assert candidate(word1 = \"b\",word2 = \"a\") == \"ba\"\n assert candidate(word1 = \"qwerqwerqwer\",word2 = \"qwertyuiop\") == \"qwqwertyuioperqwerqwer\"\n assert candidate(word1 = \"onesmallstring\",word2 = \"averylongstringwithmanycharactersandvariouslengthsandcombinations\") == \"onesmaverylongstringwithmanycharallstringactersandvariouslengthsandcombinations\"\n assert candidate(word1 = \"banana\",word2 = \"apple\") == \"bappleanana\"\n assert candidate(word1 = \"abcde\",word2 = \"fghij\") == \"fghijabcde\"\n assert candidate(word1 = \"zyxwvutsrqponmlkjihgfedcba\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == \"zyxwvutsrqponmlkjihgfedcbabcdefghijklmnopqrstuvwxyza\"\n assert candidate(word1 = \"zzyzxzyzxzy\",word2 = \"xyxyxyxyxyx\") == \"zzyzxzyzxzyxyxyxyxyxyx\"\n assert candidate(word1 = \"aabbcc\",word2 = \"bbccaa\") == \"bbccaabbccaa\"\n assert candidate(word1 = \"appleapple\",word2 = \"banana\") == \"bappleappleanana\"\n assert candidate(word1 = \"abcdef\",word2 = \"fghijk\") == \"fghijkabcdef\"\n assert candidate(word1 = \"zzzzyyyyxxx\",word2 = \"zzzyyyyxx\") == \"zzzzzzzyyyyyyyyxxxxx\"\n assert candidate(word1 = \"aaaaaabbbb\",word2 = \"bbbbbaaaa\") == \"bbbbbaaaaaabbbbaaaa\"\n assert candidate(word1 = \"aaaaaa\",word2 = \"bbbbbbbb\") == \"bbbbbbbbaaaaaa\"\n assert candidate(word1 = \"lexicographically\",word2 = \"mergeable\") == \"mlexiergecographicallyable\"\n assert candidate(word1 = \"abcabcabc\",word2 = \"cbacbacba\") == \"cbacbacbabcabcabca\"\n assert candidate(word1 = \"samestart\",word2 = \"samestart\") == \"ssamestartamestart\"\n assert candidate(word1 = \"zzzzzzzzzz\",word2 = \"zzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzz\"\n assert candidate(word1 = \"abcdexyz\",word2 = \"zyxwvuts\") == \"zyxwvutsabcdexyz\"\n assert candidate(word1 = \"abcdefg\",word2 = \"ghijklm\") == \"ghijklmabcdefg\"\n assert candidate(word1 = \"longwordone\",word2 = \"evenlongerwordtwo\") == \"longworevenlongerwordtwodone\"\n assert candidate(word1 = \"aaaab\",word2 = \"aaabaaa\") == \"aaabaaaabaaa\"\n assert candidate(word1 = \"abcdabcd\",word2 = \"dcbaabcd\") == \"dcbabcdabcdaabcd\"\n assert candidate(word1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",word2 = \"supercalifragilisticexpialidocious\") == \"suppneumonoultrercamicroscopicsilicovolcanoconiosisalifragilisticexpialidocious\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"aabbccddeegf\") == \"aabbccddeegfaabbccddeeff\"\n assert candidate(word1 = \"zyxzyxzyx\",word2 = \"zyxzyxzyx\") == \"zzyyxzyxzyxzyxzyxx\"\n assert candidate(word1 = \"overlapover\",word2 = \"overlap\") == \"ovoverlerlapoverap\"\n assert candidate(word1 = \"aebcdefghijklmnopqrstuvwxyz\",word2 = \"zxcvbnmlkjihgfedcbaeb\") == \"zxcvbnmlkjihgfedcbaebcdefghijklmnopqrstuvwxyzaeb\"\n assert candidate(word1 = \"abcdef\",word2 = \"fedcba\") == \"fedcbabcdefa\"\n assert candidate(word1 = \"aaaabbbbcccc\",word2 = \"ddddeeeeffff\") == \"ddddeeeeffffaaaabbbbcccc\"\n assert candidate(word1 = \"hellohellohello\",word2 = \"worldworld\") == \"worlhellohellohellodworld\"\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"abcabc\") == \"abcabcabcabcabcabc\"\n assert candidate(word1 = \"zzzz\",word2 = \"zzz\") == \"zzzzzzz\"\n assert candidate(word1 = \"xyzzzzzzzzzzzz\",word2 = \"yyyyyyyyyyyyyy\") == \"yyyyyyyyyyyyyyxyzzzzzzzzzzzz\"\n assert candidate(word1 = \"aabaaa\",word2 = \"baabaa\") == \"baabaabaaaaa\"\n assert candidate(word1 = \"aaaaaaaaaabbbbbbbbbbcccccccccc\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzaaaaaaaaaabbbbbbbbbbcccccccccc\"\n", "comparison": "exact"}, "public_tests": ["\"cabaa\"\n\"bcaaa\"", "\"abcabc\"\n\"abdcaba\""], "hints": ["Build the result character by character. At each step, you choose a character from one of the two strings.", "If the next character of the first string is larger than that of the second string, or vice versa, it's optimal to use the larger one.", "If both are equal, think of a criteria that lets you decide which string to consume the next character from.", "You should choose the next character from the larger string."], "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().largestMerge", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:43+00:00", "tests_total": 138, "tests_dropped": 2, "flags": [], "topic_tags": ["two-pointers", "string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def largestMerge(self, word1: str, word2: str) -> str:", "container": "Solution", "callable": "largestMerge", "parameters": [{"name": "word1", "type": "str"}, {"name": "word2", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1755, "task_id": "closest-subsequence-sum", "difficulty": "Hard", "problem_description": "You are given an integer array nums and an integer goal.\n\nYou want to choose a subsequence of nums such that the sum of its elements is the closest possible to goal. That is, if the sum of the subsequence's elements is sum, then you want to minimize the absolute difference abs(sum - goal).\n\nReturn the minimum possible value of abs(sum - goal).\n\nNote that a subsequence of an array is an array formed by removing some elements (possibly all or none) of the original array.\n\nExample 1:\n\nInput: nums = [5,-7,3,5], goal = 6\nOutput: 0\nExplanation: Choose the whole array as a subsequence, with a sum of 6.\nThis is equal to the goal, so the absolute difference is 0.\n\nExample 2:\n\nInput: nums = [7,-9,15,-2], goal = -5\nOutput: 1\nExplanation: Choose the subsequence [7,-9,-2], with a sum of -4.\nThe absolute difference is abs(-4 - (-5)) = abs(1) = 1, which is the minimum.\n\nExample 3:\n\nInput: nums = [1,2,3], goal = -7\nOutput: 7\n\nConstraints:\n\n- 1 <= nums.length <= 40\n- -10^7 <= nums[i] <= 10^7\n- -10^9 <= goal <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-10, -20, -30, -40, -50],goal = -100) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],goal = 100) == 0\n assert candidate(nums = [10, 22, 9, -24, -33, 21, 4, 19, 29, -14, 34, 10, -11, 8, -8, -7, 13, 24, -29, -10, -28, 10, -32, -23, 7, 31, 2, 25, -31, -40, -4, -23],goal = 100) == 0\n assert candidate(nums = [7, -9, 15, -2],goal = -5) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],goal = 25) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],goal = 10) == 0\n assert candidate(nums = [10000000, -10000000, 10000000, -10000000],goal = 0) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000],goal = 0) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],goal = -255) == 5\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],goal = 0) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5],goal = -15) == 0\n assert candidate(nums = [1, 2, 3],goal = -7) == 7\n assert candidate(nums = [5, -7, 3, 5],goal = 6) == 0\n assert candidate(nums = [10000000, -10000000],goal = 0) == 0\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16],goal = 0) == 0\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50, -60, 60, -70, 70, -80, 80, -90, 90, -100, 100],goal = -500) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40],goal = -1000) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 900) == 80\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80],goal = 5) == 5\n assert candidate(nums = [-1000, 1000, -500, 500, -250, 250, -125, 125, -62, 62, -31, 31, -15, 15, -7, 7, -3, 3, -1, 1],goal = -1000) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],goal = -450) == 0\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],goal = 0) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000],goal = 3000000) == 500000\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],goal = 50) == 0\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, -1000000, -2000000, -3000000, -4000000, -5000000, -6000000, -7000000, -8000000, -9000000, -10000000],goal = 20000000) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],goal = 500) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],goal = 100) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000],goal = 10000) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],goal = 10000) == 0\n assert candidate(nums = [10000000, -5000000, 3000000, -2000000, 1500000, -1000000, 750000, -500000, 250000, -125000, 62500, -31250, 15625, -7812, 3906, -1953, 976, -488, 244, -122],goal = 0) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100],goal = 50) == 0\n assert candidate(nums = [-10000, -20000, -30000, -40000, -50000, 10000, 20000, 30000, 40000, 50000],goal = -50000) == 0\n assert candidate(nums = [7, 3, 8, 4, 6, 2, 5, 1, 10, 9],goal = 42) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],goal = 100) == 0\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],goal = 5000) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],goal = 1500) == 0\n assert candidate(nums = [5, -3, 1, 7, -9, 10, -20, 15, -1, 4, 8, -6, 2, 11, -7, 13, -5, 9, -12, 6, 14, -4, 16, -8, 12, -11, 17, -13, 18, -9, 19, -14, 20, -15, 21, -16, 22, -17, 23, -18],goal = 50) == 0\n assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500, -600, 600, -700, 700, -800, 800, -900, 900, -1000, 1000],goal = 0) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],goal = -15) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8],goal = 1) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50],goal = 0) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 800) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60],goal = 5) == 5\n assert candidate(nums = [5, -7, 3, 5, 9, -1, 2, -3, 8],goal = 6) == 0\n assert candidate(nums = [10000000, -5000000, 2500000, -1250000, 625000, -312500, 156250, -78125, 39062, -19531, 9765, -4882, 2441, -1220, 610, -305, 152, -76, 38, -19, 9, -4, 2, -1],goal = 5000000) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, -5, -15, -25, -35, -45, -55, -65, -75, -85, -95, -105],goal = 250) == 0\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],goal = 0) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 300) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20],goal = -100) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20],goal = 5) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000, 1250000, -1250000, 625000, -625000, 312500, -312500, 156250, -156250, 78125, -78125],goal = 0) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 1) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],goal = 1) == 0\n assert candidate(nums = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000, -1000000, -2000000, -3000000, -4000000, -5000000, -6000000, -7000000, -8000000, -9000000, -10000000],goal = 5000000) == 0\n assert candidate(nums = [3, -1, 4, 1, 5, -9, 2, 6, 5, 3, -5, 7, -7, 8, -8, 9, -9, 10, -10],goal = 0) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],goal = 1000000) == 0\n assert candidate(nums = [-10000000, 10000000, -5000000, 5000000, 2500000, -2500000, 1250000, -1250000],goal = 1234567) == 15433\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, -14, 14, -15, 15, -16, 16, -17, 17, -18, 18, -19, 19, -20, 20],goal = 0) == 0\n assert candidate(nums = [1000000, -1000000, 2000000, -2000000, 3000000, -3000000, 4000000, -4000000, 5000000, -5000000, 6000000, -6000000, 7000000, -7000000, 8000000, -8000000, 9000000, -9000000, 10000000, -10000000],goal = 5000000) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],goal = 0) == 0\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000],goal = 500) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 1000) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = -1000) == 1000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20],goal = 0) == 0\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, -14, 14, -15, 15],goal = 50) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],goal = 0) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],goal = -30) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],goal = -50) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000, 1250000, -1250000],goal = 0) == 0\n assert candidate(nums = [-10000, 10000, -20000, 20000, -30000, 30000, -40000, 40000, -50000, 50000, -60000, 60000, -70000, 70000, -80000, 80000, -90000, 90000, -100000, 100000],goal = 0) == 0\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30, -31, 32, -33, 34, -35, 36, -37, 38, -39, 40],goal = 0) == 0\n assert candidate(nums = [9999999, 8888888, 7777777, 6666666, 5555555, 4444444, 3333333, 2222222, 1111111, -1111111, -2222222, -3333333, -4444444, -5555555, -6666666, -7777777, -8888888, -9999999],goal = 123456789) == 73456794\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],goal = 10000) == 0\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20],goal = 5) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],goal = 1000) == 100\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40],goal = -1) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],goal = 1) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],goal = 10) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000],goal = 0) == 0\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30],goal = -150) == 0\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000],goal = 0) == 0\n assert candidate(nums = [10000, -10000, 20000, -20000, 30000, -30000, 40000, -40000, 50000, -50000],goal = 25000) == 5000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],goal = 500) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],goal = 450) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],goal = 999) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],goal = 500) == 0\n", "comparison": "exact"}, "public_tests": ["[5,-7,3,5]\n6", "[7,-9,15,-2]\n-5", "[1,2,3]\n-7"], "hints": ["The naive solution is to check all possible subsequences. This works in O(2^n).", "Divide the array into two parts of nearly is equal size.", "Consider all subsets of one part and make a list of all possible subset sums and sort this list.", "Consider all subsets of the other part, and for each one, let its sum = x, do binary search to get the nearest possible value to goal - x in the first part."], "metadata": {"canonical_parameter_names": ["nums", "goal"], "leetcode_dataset_entry_point": "Solution().minAbsDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:46+00:00", "tests_total": 98, "tests_dropped": 12, "flags": [], "topic_tags": ["array", "two-pointers", "dynamic-programming", "bit-manipulation", "meet-in-the-middle", "sorting", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def minAbsDifference(self, nums: list[int], goal: int) -> int:", "container": "Solution", "callable": "minAbsDifference", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "goal", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1758, "task_id": "minimum-changes-to-make-alternating-binary-string", "difficulty": "Easy", "problem_description": "You are given a string s consisting only of the characters '0' and '1'. In one operation, you can change any '0' to '1' or vice versa.\n\nThe string is called alternating if no two adjacent characters are equal. For example, the string \"010\" is alternating, while the string \"0100\" is not.\n\nReturn the minimum number of operations needed to make s alternating.\n\nExample 1:\n\nInput: s = \"0100\"\nOutput: 1\nExplanation: If you change the last character to '1', s will be \"0101\", which is alternating.\n\nExample 2:\n\nInput: s = \"10\"\nOutput: 0\nExplanation: s is already alternating.\n\nExample 3:\n\nInput: s = \"1111\"\nOutput: 2\nExplanation: You need two operations to reach \"0101\" or \"1010\".\n\nConstraints:\n\n- 1 <= s.length <= 10^4\n- s[i] is either '0' or '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == 2\n assert candidate(s = \"101010\") == 0\n assert candidate(s = \"111000\") == 2\n assert candidate(s = \"1101101101\") == 4\n assert candidate(s = \"001100\") == 3\n assert candidate(s = \"10\") == 0\n assert candidate(s = \"110011\") == 3\n assert candidate(s = \"0100\") == 1\n assert candidate(s = \"0110101010\") == 2\n assert candidate(s = \"010101\") == 0\n assert candidate(s = \"0000\") == 2\n assert candidate(s = \"000111\") == 2\n assert candidate(s = \"101010101010101010\") == 0\n assert candidate(s = \"1100110011001100110011001100110011\") == 17\n assert candidate(s = \"01010101010101010\") == 0\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111\") == 30\n assert candidate(s = \"10101101010110101010\") == 7\n assert candidate(s = \"00000000000000000000000000000000\") == 16\n assert candidate(s = \"111110000111110000111110000111110000111110000111110000\") == 27\n assert candidate(s = \"1100110011001100\") == 8\n assert candidate(s = \"010101010101010101010101\") == 0\n assert candidate(s = \"111000111000111\") == 5\n assert candidate(s = \"0110101010101010\") == 2\n assert candidate(s = \"101010101010101010101010\") == 0\n assert candidate(s = \"1010101010101001\") == 2\n assert candidate(s = \"101010101010101010101\") == 0\n assert candidate(s = \"1000111010010101\") == 8\n assert candidate(s = \"0000000000\") == 5\n assert candidate(s = \"1100110011\") == 5\n assert candidate(s = \"111000111000111000111000111000\") == 10\n assert candidate(s = \"11110000000000001111\") == 10\n assert candidate(s = \"0000000000000000\") == 8\n assert candidate(s = \"11001100110011001100110011001100\") == 16\n assert candidate(s = \"1010101010101010\") == 0\n assert candidate(s = \"110011001100\") == 6\n assert candidate(s = \"110011001100110011\") == 9\n assert candidate(s = \"010101010110\") == 2\n assert candidate(s = \"0011001100110011\") == 8\n assert candidate(s = \"000001111000001111000011110000111100001111000011110000\") == 27\n assert candidate(s = \"1010100101010101010101010101010101\") == 6\n assert candidate(s = \"11111000001111100000\") == 8\n assert candidate(s = \"0101010101010101010101010101010101\") == 0\n assert candidate(s = \"100100100100100100100100\") == 12\n assert candidate(s = \"00110011001100110011001100110011\") == 16\n assert candidate(s = \"0110110110110110\") == 8\n assert candidate(s = \"10110101010101010101\") == 3\n assert candidate(s = \"1010010101010101\") == 4\n assert candidate(s = \"0101011010101010\") == 6\n assert candidate(s = \"010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"0011001100110\") == 6\n assert candidate(s = \"11111111111111111111\") == 10\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001\") == 26\n assert candidate(s = \"00001111111111110000\") == 10\n assert candidate(s = \"1111111111111111\") == 8\n assert candidate(s = \"01010101010\") == 0\n assert candidate(s = \"111000111000111000111000111000111000111000111000111000111\") == 19\n assert candidate(s = \"001100110011\") == 6\n assert candidate(s = \"11010011\") == 3\n assert candidate(s = \"00011100011100011100011100011100\") == 11\n assert candidate(s = \"011011011011011011011011\") == 12\n assert candidate(s = \"00000111110000011111\") == 8\n assert candidate(s = \"111000111000111000111\") == 7\n assert candidate(s = \"11001100110011001100\") == 10\n assert candidate(s = \"01010101010101010101010101010101\") == 0\n assert candidate(s = \"10010010010010010010\") == 9\n assert candidate(s = \"1010101010101010101010101010\") == 0\n assert candidate(s = \"1110000111000011\") == 8\n assert candidate(s = \"01110111011101110111\") == 5\n assert candidate(s = \"111100001111\") == 6\n assert candidate(s = \"1101101101101101\") == 7\n assert candidate(s = \"01100110011001100110\") == 10\n assert candidate(s = \"00110011001100\") == 7\n assert candidate(s = \"010101010101\") == 0\n assert candidate(s = \"1111111111111111111111111111\") == 14\n assert candidate(s = \"0101010101010101\") == 0\n assert candidate(s = \"0001110001\") == 3\n assert candidate(s = \"11111111111111111111111111111111\") == 16\n assert candidate(s = \"00000000\") == 4\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"01100110011001100110011001100110011\") == 17\n assert candidate(s = \"0101010101\") == 0\n assert candidate(s = \"1001001001001001001001001001001001\") == 17\n assert candidate(s = \"00001111000011110000111100001111\") == 16\n assert candidate(s = \"10101010101010101\") == 0\n assert candidate(s = \"111000111\") == 3\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000000000\") == 30\n assert candidate(s = \"0111000111000111\") == 5\n assert candidate(s = \"0001111000111100\") == 8\n assert candidate(s = \"1010101010101\") == 0\n assert candidate(s = \"00000000000000000000\") == 10\n assert candidate(s = \"1111000011110000\") == 8\n assert candidate(s = \"10101010101010101010101010101010\") == 0\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"010010010010\") == 6\n assert candidate(s = \"0111000101101010\") == 8\n assert candidate(s = \"0110110110110\") == 6\n assert candidate(s = \"01010101010101\") == 0\n assert candidate(s = \"001100110011001100110\") == 10\n assert candidate(s = \"1001001001001\") == 6\n assert candidate(s = \"010101010101010101010\") == 0\n assert candidate(s = \"1111111111\") == 5\n assert candidate(s = \"0110011001100110\") == 8\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011001100\") == 32\n assert candidate(s = \"1001100110011001\") == 8\n assert candidate(s = \"01010101010101010101\") == 0\n assert candidate(s = \"11111111\") == 4\n assert candidate(s = \"1101001100\") == 4\n assert candidate(s = \"0001110001110001110001\") == 7\n assert candidate(s = \"110000111100001111000011110000\") == 15\n assert candidate(s = \"01101101101101101101\") == 9\n assert candidate(s = \"10101010101010101010\") == 0\n assert candidate(s = \"01010010101001010101\") == 7\n assert candidate(s = \"1101010101\") == 1\n assert candidate(s = \"111000111000111000111000\") == 8\n assert candidate(s = \"0000000000000000000000000000\") == 14\n assert candidate(s = \"000111000111000\") == 5\n assert candidate(s = \"0000111100001111\") == 8\n", "comparison": "exact"}, "public_tests": ["\"0100\"", "\"10\"", "\"1111\""], "hints": ["Think about how the final string will look like.", "It will either start with a '0' and be like '010101010..' or with a '1' and be like '10101010..'", "Try both ways, and check for each way, the number of changes needed to reach it from the given string. The answer is the minimum of both ways."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:48+00:00", "tests_total": 117, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def minOperations(self, s: str) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1759, "task_id": "count-number-of-homogenous-substrings", "difficulty": "Medium", "problem_description": "Given a string s, return the number of homogenous substrings of s. Since the answer may be too large, return it modulo 10^9 + 7.\n\nA string is homogenous if all the characters of the string are the same.\n\nA substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: s = \"abbcccaa\"\nOutput: 13\nExplanation: The homogenous substrings are listed as below:\n\"a\" appears 3 times.\n\"aa\" appears 1 time.\n\"b\" appears 2 times.\n\"bb\" appears 1 time.\n\"c\" appears 3 times.\n\"cc\" appears 2 times.\n\"ccc\" appears 1 time.\n3 + 1 + 2 + 1 + 3 + 2 + 1 = 13.\n\nExample 2:\n\nInput: s = \"xy\"\nOutput: 2\nExplanation: The homogenous substrings are \"x\" and \"y\".\n\nExample 3:\n\nInput: s = \"zzzzz\"\nOutput: 15\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaabbbccc\") == 18\n assert candidate(s = \"aabbccddeeefffggghhhiiii\") == 46\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"xy\") == 2\n assert candidate(s = \"aabbaa\") == 9\n assert candidate(s = \"aaaaa\") == 15\n assert candidate(s = \"pppppppppp\") == 55\n assert candidate(s = \"abcdeffffff\") == 26\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"qqqqqwwweeeerrrrtttttyyyyyuuuuuiooooo\") == 102\n assert candidate(s = \"abcabcabc\") == 9\n assert candidate(s = \"ababababab\") == 10\n assert candidate(s = \"abcde\") == 5\n assert candidate(s = \"ababababa\") == 9\n assert candidate(s = \"zzzzyyyyxxxwwwwvvvvuuuuttttsrrrqqqppoonnmlkjihgfedcba\") == 101\n assert candidate(s = \"ccccccccc\") == 45\n assert candidate(s = \"abbcccaa\") == 13\n assert candidate(s = \"abcd\") == 4\n assert candidate(s = \"zzzzz\") == 15\n assert candidate(s = \"ababab\") == 6\n assert candidate(s = \"aaaaaabb\") == 24\n assert candidate(s = \"aabbccddeeeeffff\") == 32\n assert candidate(s = \"abcabcabcabcabcabcabc\") == 21\n assert candidate(s = \"aabbbccccdddd\") == 29\n assert candidate(s = \"mmmmmlllllkkkkkkjjjjjjjjiiiiiiiiiiiihhhhhhhhhhhh\") == 243\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1326\n assert candidate(s = \"aaabaaaabaaaaabaaaaaaabaaaaaaaabaaaaaaaaabaaaaaaaaaabaaaaaaaaaa\") == 257\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeee\") == 208\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 903\n assert candidate(s = \"aabbcccddddeeeee\") == 37\n assert candidate(s = \"pppppqqqqqqrrrrrrsssssstttttuuuuuuvvvvvvvvvwwwwwwwww\") == 204\n assert candidate(s = \"aabbbcccc\") == 19\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 676\n assert candidate(s = \"aaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaa\") == 252\n assert candidate(s = \"mmmmmmmmmmmmmmmnnnnnnnnnnnnnnnoooooooooooopppppppppppp\") == 396\n assert candidate(s = \"aabbccddeeefffggg\") == 30\n assert candidate(s = \"abcabcabcabc\") == 12\n assert candidate(s = \"aaabbaaaabbaaa\") == 28\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\") == 165\n assert candidate(s = \"aabbccddeeefffggghhhh\") == 40\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 277140\n assert candidate(s = \"zzzzyyyyzzzz\") == 30\n assert candidate(s = \"aaaaabbbbccccc\") == 40\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 29403\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\") == 24\n assert candidate(s = \"aabbccddeeeeffffggggghhhhiiiii\") == 72\n assert candidate(s = \"pppppppppppppppppppppppppppppppppp\") == 595\n assert candidate(s = \"ababababababababababababababab\") == 30\n assert candidate(s = \"aaaaabbbbccccdddddeeeee\") == 65\n assert candidate(s = \"aabbccddeeefffggghhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\") == 145\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 1892\n assert candidate(s = \"ppppppppppppppppppppppp\") == 276\n assert candidate(s = \"xyzzyzxzyzxyz\") == 14\n assert candidate(s = \"ababababababab\") == 14\n assert candidate(s = \"aabbccddeeeefffghhhiiiijjjjkkkkllllmmmmmnnnnnooooo\") == 120\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\") == 27\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjjkkkkllllmmmmmnnnnnooooooo\") == 134\n assert candidate(s = \"aaaaaaaaabbbbbbbbbbcccccccccc\") == 155\n assert candidate(s = \"zzzzzyyyxxxwwwwvvvvuuuuu\") == 62\n assert candidate(s = \"aabbccddeeeeffffggggghhhiiijjjkkklllmmnnooopppqqqrrsssttuuuvvvwwwwwxxxxxyyyyyzzzz\") == 180\n assert candidate(s = \"abcdefffffffffffffffffffffffffghijklmnopqrstuvwxyz\") == 350\n assert candidate(s = \"abcdabcdbcdabcd\") == 15\n assert candidate(s = \"aabbbbccccc\") == 28\n assert candidate(s = \"aaaaaaaaaaaabbaaaaaaa\") == 109\n assert candidate(s = \"aabbbccccc\") == 24\n assert candidate(s = \"xyxyxyxyxyxyxyx\") == 15\n assert candidate(s = \"aabbaaabbbaaa\") == 24\n assert candidate(s = \"aabbaaabbcccddeee\") == 30\n assert candidate(s = \"aabbccddeeffgg\") == 21\n assert candidate(s = \"aaaaabbbbbbbbbbcccccccccc\") == 125\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppp\") == 820\n assert candidate(s = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 84\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 160\n assert candidate(s = \"qwerqwerqwerqwerqwerqwerqwer\") == 28\n assert candidate(s = \"aaabbaaa\") == 15\n assert candidate(s = \"aaabbaaabbaaa\") == 24\n assert candidate(s = \"abcabcabcabcabc\") == 15\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 21736\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1275\n assert candidate(s = \"abcdefg\") == 7\n", "comparison": "exact"}, "public_tests": ["\"abbcccaa\"", "\"xy\"", "\"zzzzz\""], "hints": ["A string of only 'a's of length k contains k + 1 choose 2 homogenous substrings.", "Split the string into substrings where each substring contains only one letter, and apply the formula on each substring's length."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().countHomogenous", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:50+00:00", "tests_total": 80, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "string"]}, "language": "python", "interface": {"raw_signature": "def countHomogenous(self, s: str) -> int:", "container": "Solution", "callable": "countHomogenous", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1760, "task_id": "minimum-limit-of-balls-in-a-bag", "difficulty": "Medium", "problem_description": "You are given an integer array nums where the i^th bag contains nums[i] balls. You are also given an integer maxOperations.\n\nYou can perform the following operation at most maxOperations times:\n\n- Take any bag of balls and divide it into two new bags with a positive number of balls.\n - For example, a bag of 5 balls can become two new bags of 1 and 4 balls, or two new bags of 2 and 3 balls.\n\nYour penalty is the maximum number of balls in a bag. You want to minimize your penalty after the operations.\n\nReturn the minimum possible penalty after performing the operations.\n\nExample 1:\n\nInput: nums = [9], maxOperations = 2\nOutput: 3\nExplanation:\n- Divide the bag with 9 balls into two bags of sizes 6 and 3. [9] -> [6,3].\n- Divide the bag with 6 balls into two bags of sizes 3 and 3. [6,3] -> [3,3,3].\nThe bag with the most number of balls has 3 balls, so your penalty is 3 and you should return 3.\n\nExample 2:\n\nInput: nums = [2,4,8,2], maxOperations = 4\nOutput: 2\nExplanation:\n- Divide the bag with 8 balls into two bags of sizes 4 and 4. [2,4,8,2] -> [2,4,4,4,2].\n- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,4,4,4,2] -> [2,2,2,4,4,2].\n- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,2,2,4,4,2] -> [2,2,2,2,2,4,2].\n- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,2,2,2,2,4,2] -> [2,2,2,2,2,2,2,2].\nThe bag with the most number of balls has 2 balls, so your penalty is 2, and you should return 2.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= maxOperations, nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],maxOperations = 10) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],maxOperations = 9) == 5\n assert candidate(nums = [1000000000],maxOperations = 1) == 500000000\n assert candidate(nums = [1, 2, 3, 4, 5],maxOperations = 5) == 2\n assert candidate(nums = [100, 100, 100, 100],maxOperations = 10) == 34\n assert candidate(nums = [1000000000],maxOperations = 999999999) == 1\n assert candidate(nums = [1000000000],maxOperations = 1000000000) == 1\n assert candidate(nums = [7, 17],maxOperations = 2) == 7\n assert candidate(nums = [9],maxOperations = 2) == 3\n assert candidate(nums = [10, 20, 30, 40, 50],maxOperations = 10) == 10\n assert candidate(nums = [2, 4, 8, 2],maxOperations = 4) == 2\n assert candidate(nums = [1000000000, 1000000000],maxOperations = 1) == 1000000000\n assert candidate(nums = [10, 10, 10],maxOperations = 6) == 4\n assert candidate(nums = [10, 10, 10],maxOperations = 3) == 5\n assert candidate(nums = [7, 14, 21, 28],maxOperations = 3) == 14\n assert candidate(nums = [1, 1, 1, 1],maxOperations = 2) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],maxOperations = 5) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 5) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],maxOperations = 5) == 50\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000],maxOperations = 9) == 100000000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],maxOperations = 25) == 180\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000],maxOperations = 30) == 3449\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 29) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000],maxOperations = 3) == 500000000\n assert candidate(nums = [999999999, 1],maxOperations = 1) == 500000000\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],maxOperations = 9) == 100\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000],maxOperations = 10) == 142857143\n assert candidate(nums = [999, 999, 999, 999, 999, 999, 999, 999, 999, 999],maxOperations = 5) == 999\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000],maxOperations = 3) == 333333334\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000],maxOperations = 5) == 250000000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],maxOperations = 20) == 44\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],maxOperations = 9) == 100000000\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],maxOperations = 15) == 10\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995],maxOperations = 10) == 333333333\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],maxOperations = 10) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],maxOperations = 14) == 5\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],maxOperations = 50) == 18\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],maxOperations = 50) == 3\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],maxOperations = 19) == 1000\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],maxOperations = 10) == 500\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],maxOperations = 9) == 50\n assert candidate(nums = [1000000000, 500000000, 250000000],maxOperations = 3) == 333333334\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],maxOperations = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],maxOperations = 15) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],maxOperations = 30) == 3\n assert candidate(nums = [1, 1000000000, 1],maxOperations = 1000000000) == 1\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999],maxOperations = 5) == 500000000\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],maxOperations = 5) == 166666667\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],maxOperations = 19) == 7\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999],maxOperations = 10) == 333333333\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],maxOperations = 50) == 10000\n assert candidate(nums = [1, 1, 1, 1, 1000000000],maxOperations = 999999) == 1000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],maxOperations = 30) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],maxOperations = 20) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],maxOperations = 20) == 20\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],maxOperations = 10) == 142857143\n assert candidate(nums = [500000000, 500000000, 500000000, 500000000, 500000000],maxOperations = 1000000) == 2500\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],maxOperations = 15) == 7\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],maxOperations = 50) == 9\n assert candidate(nums = [500000000, 500000000, 500000000, 500000000, 500000000],maxOperations = 10) == 166666667\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],maxOperations = 30) == 50\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],maxOperations = 45) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],maxOperations = 10) == 4\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],maxOperations = 20) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],maxOperations = 15) == 114\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999],maxOperations = 4) == 500000000\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],maxOperations = 20) == 5\n assert candidate(nums = [2, 3, 6, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],maxOperations = 100) == 6\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],maxOperations = 50) == 1171\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],maxOperations = 20) == 19\n assert candidate(nums = [100, 200, 300, 400, 500],maxOperations = 15) == 84\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],maxOperations = 10) == 74\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 5) == 1\n assert candidate(nums = [999999999, 999999998, 999999997],maxOperations = 2) == 999999997\n assert candidate(nums = [100, 200, 300, 400, 500],maxOperations = 50) == 29\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],maxOperations = 5) == 5\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999, 999999999],maxOperations = 10) == 500000000\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000],maxOperations = 5) == 500000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],maxOperations = 45) == 100\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000],maxOperations = 10) == 10000000\n assert candidate(nums = [500000000, 500000000, 500000000, 500000000],maxOperations = 3) == 500000000\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000],maxOperations = 50) == 28572\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],maxOperations = 100) == 500\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],maxOperations = 20) == 6\n assert candidate(nums = [1000000000, 1000000000, 1000000000],maxOperations = 2) == 1000000000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 30) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],maxOperations = 10) == 350\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],maxOperations = 9) == 8\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],maxOperations = 25) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 9) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],maxOperations = 10) == 7\n", "comparison": "exact"}, "public_tests": ["[9]\n2", "[2,4,8,2]\n4"], "hints": ["Let's change the question if we know the maximum size of a bag what is the minimum number of bags you can make", "note that as the maximum size increases the minimum number of bags decreases so we can binary search the maximum size"], "metadata": {"canonical_parameter_names": ["nums", "maxOperations"], "leetcode_dataset_entry_point": "Solution().minimumSize", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:53+00:00", "tests_total": 99, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "binary-search"]}, "language": "python", "interface": {"raw_signature": "def minimumSize(self, nums: list[int], maxOperations: int) -> int:", "container": "Solution", "callable": "minimumSize", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "maxOperations", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1761, "task_id": "minimum-degree-of-a-connected-trio-in-a-graph", "difficulty": "Hard", "problem_description": "You are given an undirected graph. You are given an integer n which is the number of nodes in the graph and an array edges, where each edges[i] = [u_i, v_i] indicates that there is an undirected edge between u_i and v_i.\n\nA connected trio is a set of three nodes where there is an edge between every pair of them.\n\nThe degree of a connected trio is the number of edges where one endpoint is in the trio, and the other is not.\n\nReturn the minimum degree of a connected trio in the graph, or -1 if the graph has no connected trios.\n\nExample 1:\n\nInput: n = 6, edges = [[1,2],[1,3],[3,2],[4,1],[5,2],[3,6]]\nOutput: 3\nExplanation: There is exactly one trio, which is [1,2,3]. The edges that form its degree are bolded in the figure above.\n\nExample 2:\n\nInput: n = 7, edges = [[1,3],[4,1],[4,3],[2,5],[5,6],[6,7],[7,5],[2,6]]\nOutput: 0\nExplanation: There are exactly three trios:\n1) [1,4,3] with degree 0.\n2) [2,5,6] with degree 2.\n3) [5,6,7] with degree 2.\n\nConstraints:\n\n- 2 <= n <= 400\n- edges[i].length == 2\n- 1 <= edges.length <= n * (n-1) / 2\n- 1 <= u_i, v_i <= n\n- u_i!= v_i\n- There are no repeated edges.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[1, 2], [1, 3], [2, 3]]) == 0\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 3\n assert candidate(n = 400,edges = [[1, 2], [2, 3], [3, 1]]) == 0\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [8, 9], [9, 7], [10, 1]]) == 0\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 4], [7, 8]]) == 0\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8]]) == 0\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [3, 2], [4, 1], [5, 2], [3, 6]]) == 3\n assert candidate(n = 3,edges = [[1, 2], [2, 3], [3, 1]]) == 0\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 1], [1, 4], [4, 5], [5, 1]]) == 2\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5]]) == -1\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8]]) == 0\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5]]) == 4\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 4]]) == -1\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == -1\n assert candidate(n = 7,edges = [[1, 3], [4, 1], [4, 3], [2, 5], [5, 6], [6, 7], [7, 5], [2, 6]]) == 0\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 1], [3, 4], [4, 5]]) == 1\n assert candidate(n = 3,edges = [[1, 2], [2, 3]]) == -1\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 1], [1, 4], [2, 4], [3, 4]]) == 3\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [6, 7], [7, 8], [5, 7], [6, 8], [4, 7], [4, 8]]) == 0\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [1, 10], [2, 11], [3, 12]]) == 9\n assert candidate(n = 100,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 19], [1, 100], [100, 50], [50, 25], [25, 75], [75, 50], [50, 1], [2, 50], [3, 50], [4, 50], [5, 50], [6, 50], [7, 50], [8, 50], [9, 50], [10, 50], [11, 50], [12, 50], [13, 50], [14, 50], [15, 50], [16, 50], [17, 50], [18, 50], [19, 50], [21, 50], [22, 50], [23, 50], [24, 50], [25, 50], [26, 50], [27, 50], [28, 50], [29, 50], [30, 50], [31, 50], [32, 50], [33, 50], [34, 50], [35, 50], [36, 50], [37, 50], [38, 50], [39, 50], [40, 50], [41, 50], [42, 50], [43, 50], [44, 50], [45, 50], [46, 50], [47, 50], [48, 50], [49, 50], [51, 50], [52, 50], [53, 50], [54, 50], [55, 50], [56, 50], [57, 50], [58, 50], [59, 50], [60, 50], [61, 50], [62, 50], [63, 50], [64, 50], [65, 50], [66, 50], [67, 50], [68, 50], [69, 50], [70, 50], [71, 50], [72, 50], [73, 50], [74, 50], [75, 50], [76, 50], [77, 50], [78, 50], [79, 50], [80, 50], [81, 50], [82, 50], [83, 50], [84, 50], [85, 50], [86, 50], [87, 50], [88, 50], [89, 50], [90, 50], [91, 50], [92, 50], [93, 50], [94, 50], [95, 50], [96, 50], [97, 50], [98, 50], [99, 50], [100, 99]]) == 3\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 1], [2, 5], [3, 5]]) == 5\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 6], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 10], [8, 11], [8, 12], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [14, 15], [14, 16], [14, 17], [14, 18], [15, 16], [15, 17], [15, 18], [16, 17], [16, 18], [17, 18], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [20, 21], [20, 22], [20, 23], [20, 24], [21, 22], [21, 23], [21, 24], [22, 23], [22, 24], [23, 24], [1, 13], [2, 14], [3, 15], [4, 16], [5, 17], [6, 18], [7, 19], [8, 20], [9, 21], [10, 22], [11, 23], [12, 24]]) == 12\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19], [11, 20], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20]]) == 9\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]) == 6\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10]]) == 3\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [14, 15], [14, 16], [15, 16], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [19, 20], [1, 5], [2, 6], [3, 7], [4, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20]]) == 6\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1], [1, 3], [4, 6], [2, 7], [5, 8]]) == 3\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [14, 15], [14, 16], [15, 16], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [19, 20], [21, 22], [21, 23], [21, 24], [22, 23], [22, 24], [23, 24], [25, 26], [25, 27], [25, 28], [26, 27], [26, 28], [27, 28], [29, 30]]) == 3\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8]]) == 3\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [14, 15], [14, 16], [15, 16], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [19, 20], [21, 22], [21, 23], [21, 24], [22, 23], [22, 24], [23, 24], [25, 26], [25, 27], [25, 28], [26, 27], [26, 28], [27, 28], [29, 30], [1, 5], [2, 6], [3, 7], [4, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25], [22, 26], [23, 27], [24, 28], [25, 29], [26, 30]]) == 7\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 1], [20, 2]]) == 6\n assert candidate(n = 35,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [17, 18], [17, 19], [17, 20], [17, 21], [18, 19], [18, 20], [18, 21], [19, 20], [19, 21], [20, 21], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [24, 25], [24, 26], [24, 27], [24, 28], [25, 26], [25, 27], [25, 28], [26, 27], [26, 28], [27, 28], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 35], [30, 31], [30, 32], [30, 33], [30, 34], [30, 35], [31, 32], [31, 33], [31, 34], [31, 35], [32, 33], [32, 34], [32, 35], [33, 34], [33, 35], [34, 35], [1, 15], [2, 16], [3, 17], [4, 18], [5, 19], [6, 20], [7, 21], [8, 22], [9, 23], [10, 24], [11, 25], [12, 26], [13, 27], [14, 28], [15, 29], [16, 30], [17, 31], [18, 32], [19, 33], [20, 34], [21, 35]]) == 15\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [2, 5], [3, 5], [4, 7], [5, 7], [6, 9], [7, 9], [8, 11], [9, 11], [10, 13], [11, 13], [12, 14], [13, 14]]) == 5\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15], [16, 17], [16, 18], [16, 19], [17, 18], [17, 19], [18, 19], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]]) == 3\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 19], [1, 4], [2, 5], [3, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 19], [14, 20], [1, 16], [2, 17], [3, 18], [4, 19], [5, 20]]) == 5\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]) == 3\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5]]) == 5\n assert candidate(n = 40,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 21], [21, 19], [22, 23], [23, 24], [24, 22], [25, 26], [26, 27], [27, 25], [28, 29], [29, 30], [30, 28], [31, 32], [32, 33], [33, 31], [34, 35], [35, 36], [36, 34], [37, 38], [38, 39], [39, 37], [40, 1]]) == 0\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20]]) == 12\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [14, 15], [14, 16], [15, 16], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [19, 20]]) == 3\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [1, 4], [2, 5], [3, 6], [1, 7], [2, 8], [3, 8]]) == 3\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 1], [20, 19]]) == 0\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [14, 15]]) == 3\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 1], [9, 2], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 1], [8, 2], [9, 3]]) == 12\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [9, 10]]) == 6\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [3, 5], [4, 5]]) == 4\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15]]) == 6\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20], [21, 2], [22, 3], [23, 4], [24, 5], [25, 1]]) == -1\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [4, 8], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [6, 10], [7, 8], [7, 9], [7, 10], [7, 11], [8, 9], [8, 10], [8, 11], [8, 12], [9, 10], [9, 11], [9, 12], [9, 13], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [11, 15], [12, 13], [12, 14], [12, 15], [12, 16], [13, 14], [13, 15], [13, 16], [13, 17], [14, 15], [14, 16], [14, 17], [14, 18], [15, 16], [15, 17], [15, 18], [15, 19], [16, 17], [16, 18], [16, 19], [16, 20], [17, 18], [17, 19], [17, 20], [17, 21], [18, 19], [18, 20], [18, 21], [18, 22], [19, 20], [19, 21], [19, 22], [19, 23], [20, 21], [20, 22], [20, 23], [20, 24], [21, 22], [21, 23], [21, 24], [21, 25], [22, 23], [22, 24], [22, 25], [23, 24], [23, 25], [24, 25], [25, 1]]) == 10\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 1], [10, 2]]) == 4\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [9, 10], [11, 12], [11, 13], [12, 13], [1, 5], [3, 6], [4, 8], [7, 11]]) == 1\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [26, 27], [26, 28], [26, 29], [26, 30], [27, 28], [27, 29], [27, 30], [28, 29], [28, 30], [29, 30], [30, 1]]) == 13\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [1, 4], [2, 5], [3, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 13], [11, 14], [12, 15]]) == 6\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 6], [4, 5], [5, 6], [6, 7], [7, 8], [8, 4]]) == 4\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 21], [21, 19], [22, 23], [23, 24], [24, 22], [25, 26], [26, 27], [27, 25], [28, 29], [29, 30], [30, 28]]) == 0\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 6], [3, 4], [3, 7], [4, 8], [5, 6], [6, 7], [7, 8]]) == 6\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 21], [21, 19], [22, 23], [23, 24], [24, 22], [25, 26], [26, 27], [27, 25], [28, 29], [29, 30], [30, 28], [1, 13], [2, 14], [3, 15], [4, 16], [5, 17], [6, 18], [7, 19], [8, 20], [9, 21], [10, 22], [11, 23], [12, 24], [1, 25], [2, 26], [3, 27], [4, 28], [5, 29], [6, 30]]) == 3\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 1], [20, 19], [21, 22], [22, 23], [23, 21], [24, 25], [25, 26], [26, 24], [27, 28], [28, 29], [29, 27], [30, 21], [30, 25]]) == 0\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [1, 5], [2, 6], [3, 7], [4, 8], [1, 9], [2, 10], [3, 11], [4, 12]]) == 6\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [14, 15], [14, 16], [14, 17], [15, 16], [15, 17], [16, 17], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [1, 14], [2, 15], [3, 16], [4, 17], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17]]) == 11\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 1]]) == 5\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 1], [2, 5], [3, 5], [4, 7], [5, 7], [6, 9], [7, 9], [8, 11], [9, 11]]) == 5\n assert candidate(n = 40,edges = [[1, 2], [2, 3], [1, 3], [4, 5], [5, 6], [4, 6], [7, 8], [8, 9], [7, 9], [10, 11], [11, 12], [10, 12], [13, 14], [14, 15], [13, 15], [16, 17], [17, 18], [16, 18], [19, 20], [20, 21], [19, 21], [22, 23], [23, 24], [22, 24], [25, 26], [26, 27], [25, 27], [28, 29], [29, 30], [28, 30], [31, 32], [32, 33], [31, 33], [34, 35], [35, 36], [34, 36], [37, 38], [38, 39], [37, 39], [40, 1], [2, 4], [3, 5], [6, 8], [7, 9], [10, 12], [11, 13], [14, 16], [15, 17], [18, 20], [19, 21], [22, 24], [23, 25], [26, 28], [27, 29], [30, 32], [31, 33], [34, 36], [35, 37], [38, 40], [39, 1]]) == 3\n", "comparison": "exact"}, "public_tests": ["6\n[[1,2],[1,3],[3,2],[4,1],[5,2],[3,6]]", "7\n[[1,3],[4,1],[4,3],[2,5],[5,6],[6,7],[7,5],[2,6]]"], "hints": ["Consider a trio with nodes u, v, and w. The degree of the trio is just degree(u) + degree(v) + degree(w) - 6. The -6 comes from subtracting the edges u-v, u-w, and v-w, which are counted twice each in the vertex degree calculation.", "To get the trios (u,v,w), you can iterate on u, then iterate on each w,v such that w and v are neighbors of u and are neighbors of each other."], "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().minTrioDegree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:29:55+00:00", "tests_total": 64, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["graph", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def minTrioDegree(self, n: int, edges: list[list[int]]) -> int:", "container": "Solution", "callable": "minTrioDegree", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1763, "task_id": "longest-nice-substring", "difficulty": "Easy", "problem_description": "A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, \"abABB\" is nice because 'A' and 'a' appear, and 'B' and 'b' appear. However, \"abA\" is not because 'b' appears, but 'B' does not.\n\nGiven a string s, return the longest substring of s that is nice. If there are multiple, return the substring of the earliest occurrence. If there are none, return an empty string.\n\nExample 1:\n\nInput: s = \"YazaAay\"\nOutput: \"aAa\"\nExplanation: \"aAa\" is a nice string because 'A/a' is the only letter of the alphabet in s, and both 'A' and 'a' appear.\n\"aAa\" is the longest nice substring.\n\nExample 2:\n\nInput: s = \"Bb\"\nOutput: \"Bb\"\nExplanation: \"Bb\" is a nice string because both 'B' and 'b' appear. The whole string is a substring.\n\nExample 3:\n\nInput: s = \"c\"\nOutput: \"\"\nExplanation: There are no nice substrings.\n\nConstraints:\n\n- 1 <= s.length <= 100\n- s consists of uppercase and lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"Bb\") == \"Bb\"\n assert candidate(s = \"aAbBcCdDeEfFgG\") == \"aAbBcCdDeEfFgG\"\n assert candidate(s = \"c\") == \"\"\n assert candidate(s = \"aBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"BbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"abcdefgHIJKlmnopQRStuVwxYZ\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"aAaBbCc\") == \"aAaBbCc\"\n assert candidate(s = \"QwertyuiopASDFGHJKLzxcvbnmMNBVCXZLKJHGFDSAPOIUYTREWq\") == \"zxcvbnmMNBVCXZ\"\n assert candidate(s = \"aaAAbbBBccCC\") == \"aaAAbbBBccCC\"\n assert candidate(s = \"aA\") == \"aA\"\n assert candidate(s = \"dDcCbBaA\") == \"dDcCbBaA\"\n assert candidate(s = \"AabbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"CcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"aAb\") == \"aA\"\n assert candidate(s = \"aAbBcC\") == \"aAbBcC\"\n assert candidate(s = \"YazaAay\") == \"aAa\"\n assert candidate(s = \"dDfFgG\") == \"dDfFgG\"\n assert candidate(s = \"mnopQRstuvQR\") == \"\"\n assert candidate(s = \"aBcDef\") == \"\"\n assert candidate(s = \"abABB\") == \"abABB\"\n assert candidate(s = \"AbcDEdEfghIjklmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"\"\n assert candidate(s = \"abABcdCDefEF\") == \"abABcdCDefEF\"\n assert candidate(s = \"aabBcC\") == \"bBcC\"\n assert candidate(s = \"AaBbCcDd\") == \"AaBbCcDd\"\n assert candidate(s = \"xyzXYZ\") == \"xyzXYZ\"\n assert candidate(s = \"abcD\") == \"\"\n assert candidate(s = \"abcABCdefDEFghGHijIJklKLmnopMNOPqrstQRSTuvUVwxWXyzYZ\") == \"abcABCdefDEFghGHijIJklKLmnopMNOPqrstQRSTuvUVwxWXyzYZ\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefgHIJKLmnopQRstuvWxyz\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbB\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbB\"\n assert candidate(s = \"aBcD\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdEFGH\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdEFGH\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmM\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmM\"\n assert candidate(s = \"xyzXYZaBcDedCbAz\") == \"xyzXYZ\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeE\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeE\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyzaA\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyzaA\"\n assert candidate(s = \"aabbCCddEEffGGhhIIjjKKllMMnnOOppQQrrSSttuUvVwWxXyYzZ\") == \"uUvVwWxXyYzZ\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == \"\"\n assert candidate(s = \"abcdEFGHijklMNOpQRstUVwxyzZ\") == \"zZ\"\n assert candidate(s = \"abABcdCDefEFGghHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"abABcdCDefEFGghHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"abcdEFGhijKLMnopQRStuVwXYz\") == \"\"\n assert candidate(s = \"abcdefGhijklMnopqrstuvwxyz\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"abcdefABCDefghijklmnoMNOPQRSTuvwxyXYZ\") == \"mnoMNO\"\n assert candidate(s = \"abcdEFGHijklMNOPqrstUVWXyzABCDefghIJKLmnopQRstuVWXyz\") == \"\"\n assert candidate(s = \"aBcDabcdABCD\") == \"aBcDabcdABCD\"\n assert candidate(s = \"xYzZyXaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwW\") == \"xYzZyXaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwW\"\n assert candidate(s = \"aBcDEfGhIjKlMnOpQrStUvWxYz\") == \"\"\n assert candidate(s = \"xyzXYZabcABCdefDEFghijGHIJklmnopqrQRSTUVWstuvUVW\") == \"xyzXYZabcABCdefDEFghijGHIJ\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopQRstuVWXyz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopQRstuVWXyz\"\n assert candidate(s = \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\") == \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\"\n assert candidate(s = \"abcdefABCDefgHIJKlMNOPqrSTUVwxYZaBcDefGhIjKlMnoPqrStUvWxYz\") == \"\"\n assert candidate(s = \"abABcdCDefEFghGHijIJklKLmnopMNOPqrstuvwxyzZXYwvuUVtsrSRQPONMLKJIHgfedcbaABab\") == \"abABcdCDefEFghGHijIJklKLmnopMNOP\"\n assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\") == \"\"\n assert candidate(s = \"abcdefghijABCDEFGHIJKLmnopqrstuvwxyz\") == \"abcdefghijABCDEFGHIJ\"\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\") == \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbB\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbB\"\n assert candidate(s = \"aaabBBcccAAbbbCCC\") == \"aaabBBcccAAbbbCCC\"\n assert candidate(s = \"abcdefgHIJKLmnopQRstuvWxyzabcdefgHIJKLmnopQRstuvWxyz\") == \"\"\n assert candidate(s = \"aBcDabcdABCDzzZZyyYYxxXXwwWWvvVVuuUUttTTssSSrrQQppOOmmLLkkJJiiHHggFFddBBAA\") == \"aBcDabcdABCDzzZZyyYYxxXXwwWWvvVVuuUUttTTssSS\"\n assert candidate(s = \"aaAaAaBbBbBbCcCcCc\") == \"aaAaAaBbBbBbCcCcCc\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\"\n assert candidate(s = \"bAcBdCd\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZxyzXYZabcABCdefDEFghiGHIjklJKLmnoMNOpqrPQRstuSTUvVwWxyXYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZxyzXYZabcABCdefDEFghiGHIjklJKLmnoMNOpqrPQRstuSTUvVwWxyXYzZ\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"abcABCxyzXYZdefDEF\") == \"abcABCxyzXYZdefDEF\"\n assert candidate(s = \"abAcBdCdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"EeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZabcDEF\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZabcDEF\"\n assert candidate(s = \"aAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzABCdef\") == \"aAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzABCdef\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbB\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbB\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abcABCdefDEFghGHIjklKLmnopqrQRstuvUVwxyzXYZ\") == \"abcABCdefDEFghGH\"\n assert candidate(s = \"abABcdCDefEFghGHijIJklKLmnopMNOPqrstuvwxyzZXYwvuUVtsrSRQPONMLKJIHgfedcba\") == \"abABcdCDefEFghGHijIJklKLmnopMNOP\"\n assert candidate(s = \"abcdefABCDefgHIJKlMNOPqrSTUVwxYZ\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopqrQRST\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopqrQRST\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZabcdEfghijklmnopqrstuVwxy\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZabcdEfghijklmnopqrstuVwxy\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZa\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZa\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZcC\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZcC\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbBaAcCdD\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbBaAcCdD\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"zZyYxXwWvVuUtTsSrRpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"xYzZyXaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"xYzZyXaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCc\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCc\"\n assert candidate(s = \"abcABCdefDEFgGhHijIJklKLmMnopNOPqrQRstSTuUVwWXyYzZ\") == \"abcABCdefDEFgGhHijIJklKLmMnopNOPqrQRstSTuU\"\n assert candidate(s = \"AbcDeFgHiJklMnopqrStuvWxyzZ\") == \"zZ\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzXxYyZz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzXxYyZz\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeEfffGg\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeE\"\n assert candidate(s = \"abcdefABCDEFxyzXYZuvwUVWqQrRsStTuUvVwWxXyYzZ\") == \"abcdefABCDEFxyzXYZuvwUVWqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"abcdEFGHijklMNOPqrSTUVwxyz\") == \"\"\n assert candidate(s = \"abcXYZabcXYZabcXYZ\") == \"\"\n assert candidate(s = \"abcdEFGHijklMNOPqrstUVWXyzabcdEFGHijklMNOPqrstUVWXyz\") == \"\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAA\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopQRstuVWXyzABCdefGHIjklMNOpQRstuVWXyz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopQRstuVWXyzABCdefGHIjklMNOpQRstuVWXyz\"\n assert candidate(s = \"aaBBccDDeeFFggHHiiJJKkllMMnnOoPPqqRRssTTuuVVwwXXyyZZ\") == \"Kk\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAbCdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"xyzXYZabcABCdefDEFghiGHIjklJKLmnoMNOpqrPQRstuSTUvVwWxyXYzZ\") == \"xyzXYZabcABCdefDEFghiGHIjklJKLmnoMNOpqrPQRstuSTUvVwWxyXYzZ\"\n assert candidate(s = \"AbcDefGhiJklMnoPqrStuVwxYzABCdefGHIjklMNOpQRstuVWXyz\") == \"\"\n assert candidate(s = \"abcdEFGHijklMNOPqrstUVWXyz\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbC\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbC\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzABCD\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"abcdefgHIJKLmnopQRstUVwXYZ\") == \"\"\n assert candidate(s = \"abcdEFGHijkLmnopQRstUVwxYZ\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZab\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZab\"\n assert candidate(s = \"abcdefgHIJKLmnopQRstuvWxyz\") == \"\"\n assert candidate(s = \"abcdefgHIJKLmnopQRstuvWxyzab\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyza\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyza\"\n assert candidate(s = \"abcdefGHIJkLmnopQRstuvWXYZ\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzABCDEF\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzABCDEF\"\n assert candidate(s = \"xXyYzZwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"xXyYzZwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"\"\n assert candidate(s = \"aBcDcBaEeFfEgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"EeFfEgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaabbCCddeeffGG\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaabbCCddeeffGG\"\n", "comparison": "exact"}, "public_tests": ["\"YazaAay\"", "\"Bb\"", "\"c\""], "hints": ["Brute force and check each substring to see if it is nice."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().longestNiceSubstring", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:00+00:00", "tests_total": 152, "tests_dropped": 30, "flags": [], "topic_tags": ["hash-table", "string", "divide-and-conquer", "bit-manipulation", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def longestNiceSubstring(self, s: str) -> str:", "container": "Solution", "callable": "longestNiceSubstring", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1764, "task_id": "form-array-by-concatenating-subarrays-of-another-array", "difficulty": "Medium", "problem_description": "You are given a 2D integer array groups of length n. You are also given an integer array nums.\n\nYou are asked if you can choose n disjoint subarrays from the array nums such that the i^th subarray is equal to groups[i] (0-indexed), and if i > 0, the (i-1)^th subarray appears before the i^th subarray in nums (i.e. the subarrays must be in the same order as groups).\n\nReturn true if you can do this task, and false otherwise.\n\nNote that the subarrays are disjoint if and only if there is no index k such that nums[k] belongs to more than one subarray. A subarray is a contiguous sequence of elements within an array.\n\nExample 1:\n\nInput: groups = [[1,-1,-1],[3,-2,0]], nums = [1,-1,0,1,-1,-1,3,-2,0]\nOutput: true\nExplanation: You can choose the 0^th subarray as [1,-1,0,1,-1,-1,3,-2,0] and the 1^st one as [1,-1,0,1,-1,-1,3,-2,0].\nThese subarrays are disjoint as they share no common nums[k] element.\n\nExample 2:\n\nInput: groups = [[10,-2],[1,2,3,4]], nums = [1,2,3,4,10,-2]\nOutput: false\nExplanation: Note that choosing the subarrays [1,2,3,4,10,-2] and [1,2,3,4,10,-2] is incorrect because they are not in the same order as in groups.\n[10,-2] must come before [1,2,3,4].\n\nExample 3:\n\nInput: groups = [[1,2,3],[3,4]], nums = [7,7,1,2,3,4,7,7]\nOutput: false\nExplanation: Note that choosing the subarrays [7,7,1,2,3,4,7,7] and [7,7,1,2,3,4,7,7] is invalid because they are not disjoint.\nThey share a common elements nums[4] (0-indexed).\n\nConstraints:\n\n- groups.length == n\n- 1 <= n <= 10^3\n- 1 <= groups[i].length, sum(groups[i].length) <= 10^3\n- 1 <= nums.length <= 10^3\n- -10^7 <= groups[i][j], nums[k] <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(groups = [[1, 2, 3]],nums = [1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2], [3, 4]],nums = [1, 2, 4, 3]) == False\n assert candidate(groups = [[5, 5, 5], [5]],nums = [5, 5, 5, 5]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1]],nums = [1, 1, 1, 1]) == False\n assert candidate(groups = [[1, 2], [3, 4]],nums = [1, 2, 3, 4]) == True\n assert candidate(groups = [[1, 2], [2, 1]],nums = [1, 2, 2, 1]) == True\n assert candidate(groups = [[-1, -2, -3], [-3, -2, -1]],nums = [-1, -2, -3, -3, -2, -1]) == True\n assert candidate(groups = [[1, -1, -1], [3, -2, 0]],nums = [1, -1, 0, 1, -1, -1, 3, -2, 0]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[1]],nums = [1]) == True\n assert candidate(groups = [[1, 2], [3, 4]],nums = [1, 2, 5, 3, 4]) == True\n assert candidate(groups = [[1], [2], [3]],nums = [3, 2, 1]) == False\n assert candidate(groups = [[1, 1, 1, 1], [1, 1]],nums = [1, 1, 1, 1]) == False\n assert candidate(groups = [[1], [2], [3]],nums = [1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4]],nums = [7, 7, 1, 2, 3, 4, 7, 7]) == False\n assert candidate(groups = [[5, 5]],nums = [5, 5, 5, 5]) == True\n assert candidate(groups = [[10, -2], [1, 2, 3, 4]],nums = [1, 2, 3, 4, 10, -2]) == False\n assert candidate(groups = [[1]],nums = [2]) == False\n assert candidate(groups = [[1, 2], [2, 3]],nums = [1, 2, 2, 3]) == True\n assert candidate(groups = [[1, 2], [3, 4]],nums = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4]],nums = [1, 2, 3, 4]) == False\n assert candidate(groups = [[1, 2], [3, 4], [5, 6]],nums = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[100, 200], [200, 300], [300, 400]],nums = [100, 200, 200, 300, 300, 400]) == True\n assert candidate(groups = [[100, 200], [300, 400], [500, 600]],nums = [100, 200, 300, 400, 500, 600, 100, 200]) == True\n assert candidate(groups = [[0, 0, 0, 0], [0]],nums = [0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(groups = [[10, 20, 30], [30, 40, 50], [50, 60, 70]],nums = [10, 20, 30, 40, 50, 60, 70]) == False\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 8, 9, 7, 8, 9]) == True\n assert candidate(groups = [[9, 8, 7], [8, 7, 6], [7, 6, 5]],nums = [9, 8, 7, 8, 7, 6, 7, 6, 5]) == True\n assert candidate(groups = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],nums = [1, 2, 3, 4, 5, 6, 7]) == False\n assert candidate(groups = [[1, 1, 1], [1, 1, 1]],nums = [1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[-1, -2, -3], [-3, -4, -5], [-5, -6, -7]],nums = [-1, -2, -3, -3, -4, -5, -5, -6, -7]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1]) == False\n assert candidate(groups = [[0, 1], [1, 2], [2, 3], [3, 4]],nums = [0, 1, 1, 2, 2, 3, 3, 4]) == True\n assert candidate(groups = [[-1, -2, -3], [-4, -5], [-6, -7, -8, -9]],nums = [-1, -2, -3, 0, -4, -5, 1, -6, -7, -8, -9]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5]],nums = [1, 2, 3, 99, 3, 4, 5]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 4, 5, 1, 2, 3, 6, 7, 8, 1, 2, 3]) == True\n assert candidate(groups = [[-1, -2, -3], [-3, -2, -1], [0, 0, 0]],nums = [-1, -2, -3, 0, 0, 0, -3, -2, -1]) == False\n assert candidate(groups = [[1, 2, 3], [1, 2, 3, 4], [4, 5]],nums = [1, 2, 3, 1, 2, 3, 4, 4, 5]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [2, 3, 4], [3, 4, 5, 6]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 2, 3, 3, 4, 4, 5]) == True\n assert candidate(groups = [[-1, -2, -3], [-4, -5, -6]],nums = [-1, -2, -3, -4, -5, -6, -1, -2, -3, -4, -5, -6]) == True\n assert candidate(groups = [[1, 2, 3], [3, 2, 1], [2, 1, 3]],nums = [1, 2, 3, 3, 2, 1, 2, 1, 3]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]],nums = [1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9]) == True\n assert candidate(groups = [[10, 20, 30], [40, 50], [60, 70, 80]],nums = [5, 10, 20, 30, 15, 40, 50, 25, 60, 70, 80]) == True\n assert candidate(groups = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],nums = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 2, 3, 3, 4, 99, 4, 5]) == True\n assert candidate(groups = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7]],nums = [1, 2, 3, 3, 4, 5, 5, 6, 7]) == True\n assert candidate(groups = [[9, 8, 7], [6, 5, 4], [3, 2, 1]],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(groups = [[1, 2, 3], [2, 3, 4], [3, 4, 5]],nums = [1, 2, 3, 2, 3, 4, 3, 4, 5]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5]],nums = [1, 0, 2, 0, 3, 0, 4, 0, 5]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2], [1]],nums = [1, 2, 3, 1, 2, 1]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]],nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4]],nums = [1, 2, 3, 4, 5, 3, 4]) == False\n assert candidate(groups = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [1, 1, 1]],nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1]) == True\n assert candidate(groups = [[1, 1], [2, 2], [1, 1], [2, 2]],nums = [1, 1, 2, 2, 1, 1, 2, 2]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[-10, -20, -30], [-40, -50, -60], [-70, -80, -90]],nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == True\n assert candidate(groups = [[1, 2, 3, 4], [5, 6, 7], [8, 9]],nums = [1, 2, 3, 4, 10, 11, 5, 6, 7, 12, 8, 9]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 3, 4, 5, 2, 3, 4, 5]) == False\n assert candidate(groups = [[1, 2, 3, 4, 5], [5, 6, 7], [8, 9]],nums = [1, 2, 3, 4, 5, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[-1, -2, -3], [-3, -2, -1], [1, 2, 3]],nums = [-1, -2, -3, -3, -2, -1, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [9, 10, 11, 12, 13]],nums = [1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9, 10, 11, 12, 13]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == True\n assert candidate(groups = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5]],nums = [1, 2, 3, 3, 4, 5]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4]],nums = [1, 2, 3, 4, 5]) == False\n assert candidate(groups = [[-1, -2, -3], [-4, -5], [-6, -7, -8]],nums = [-1, -2, -3, 0, -4, -5, 0, -6, -7, -8]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]],nums = [1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9]) == True\n assert candidate(groups = [[10, 20, 30], [20, 30, 40], [30, 40, 50]],nums = [10, 20, 30, 20, 30, 40, 30, 40, 50]) == True\n assert candidate(groups = [[1, 2], [3, 4], [5, 6], [7, 8]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[100, 200], [200, 300], [300, 400], [400, 500]],nums = [100, 200, 200, 300, 300, 400, 400, 500]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [1, 2, 3], [4, 5, 6]],nums = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[-1, -2, -3], [-2, -3, -4], [-3, -4, -5]],nums = [-1, -2, -3, -2, -3, -4, -3, -4, -5]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 3, 4, 5]) == False\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 10, 4, 5, 6, 11, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7]],nums = [1, 2, 3, 4, 5, 6, 7]) == False\n assert candidate(groups = [[100, 200], [300, 400, 500], [600]],nums = [50, 100, 200, 150, 300, 400, 500, 200, 600]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4]],nums = [1, 2, 2, 3, 3, 4, 4]) == True\n assert candidate(groups = [[1, 2], [3, 4], [1, 2]],nums = [1, 2, 3, 4, 1, 2]) == True\n assert candidate(groups = [[1, 1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2], [2, 3]],nums = [1, 2, 3, 1, 2, 2, 3]) == True\n assert candidate(groups = [[9, 8, 7], [6, 5, 4], [3, 2, 1]],nums = [9, 8, 7, 0, 6, 5, 4, 0, 3, 2, 1]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7]],nums = [1, 2, 3, 3, 4, 5, 5, 6, 7]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 9, 8, 7, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(groups = [[10000000], [9999999], [8888888], [7777777]],nums = [10000000, 9999999, 8888888, 7777777]) == True\n assert candidate(groups = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(groups = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]],nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n assert candidate(groups = [[5, 5, 5, 5], [5, 5, 5], [5, 5], [5]],nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5]],nums = [1, 2, 3, 4, 5]) == True\n assert candidate(groups = [[-10, -20, -30], [-40, -50], [-60, -70, -80]],nums = [-10, -20, -30, -40, -50, -60, -70, -80]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5]],nums = [1, 2, 3, 4, 5]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],nums = [1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(groups = [[1, 2], [3, 4, 5, 6], [7, 8]],nums = [1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[10, 20, 30, 40], [50, 60, 70, 80]],nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(groups = [[1, 2], [2, 1], [1, 2], [2, 1]],nums = [1, 2, 2, 1, 1, 2, 2, 1]) == True\n assert candidate(groups = [[-10, -20, -30], [-30, -20, -10]],nums = [-10, -20, -30, -30, -20, -10]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == True\n assert candidate(groups = [[-1, 0, 1], [-2, 0, 2]],nums = [-1, 0, 1, -2, 0, 2, -1, 0, 1]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7]],nums = [99, 1, 2, 3, 99, 3, 4, 5, 99, 5, 6, 7]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5]],nums = [1, 2, 3, 3, 4, 5]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3], [3, 2, 1], [1, 2, 3]],nums = [1, 2, 3, 3, 2, 1, 1, 2, 3]) == True\n assert candidate(groups = [[7, 8, 9], [1, 2, 3], [4, 5, 6]],nums = [7, 8, 9, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6]],nums = [1, 2, 3, 0, 0, 4, 5, 6]) == True\n assert candidate(groups = [[-1, -2, -3], [0, 1, 2], [-3, -2, -1]],nums = [-1, -2, -3, 0, 1, 2, -3, -2, -1]) == True\n assert candidate(groups = [[1, 2, 3], [2, 3, 4]],nums = [1, 2, 3, 4]) == False\n assert candidate(groups = [[9, 8, 7, 6, 5], [4, 3, 2, 1], [0, -1, -2, -3, -4]],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == True\n assert candidate(groups = [[100, 200, 300], [400, 500], [600]],nums = [100, 200, 300, 400, 500, 600]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6]],nums = [1, 2, 3, 99, 4, 5, 6]) == True\n assert candidate(groups = [[1, 1, 1, 1], [1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(groups = [[1, 2, 3], [3, 2, 1]],nums = [1, 2, 3, 3, 2, 1, 1, 2, 3, 3, 2, 1]) == True\n assert candidate(groups = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],nums = [0, 1, 2, 3, 4, 0, 5, 6, 7, 8, 0, 9, 10, 11, 12]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]],nums = [1, 2, 3, 4, 5, 11, 12, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, -1], [1, -1]],nums = [1, -1, 1, -1, 1, -1]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 4, 5, 6, 7, 8, 9, 10], [3, 4, 5, 6, 7, 8, 9, 10, 11]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 3, 4, 5]) == False\n assert candidate(groups = [[1, 2, 3], [4, 5, 6]],nums = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5], [6]],nums = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [0, 1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9]) == True\n assert candidate(groups = [[100, 200, 300], [400, 500], [600, 700, 800, 900]],nums = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == True\n assert candidate(groups = [[1, 1], [1, 1], [1, 1]],nums = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [6, 7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(groups = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n", "comparison": "exact"}, "public_tests": ["[[1,-1,-1],[3,-2,0]]\n[1,-1,0,1,-1,-1,3,-2,0]", "[[10,-2],[1,2,3,4]]\n[1,2,3,4,10,-2]", "[[1,2,3],[3,4]]\n[7,7,1,2,3,4,7,7]"], "hints": ["When we use a subarray, the room for the next subarrays will be the suffix after the used subarray.", "If we can match a group with multiple subarrays, we should choose the first one, as this will just leave the largest room for the next subarrays."], "metadata": {"canonical_parameter_names": ["groups", "nums"], "leetcode_dataset_entry_point": "Solution().canChoose", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:02+00:00", "tests_total": 148, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "two-pointers", "greedy", "string-matching", "knuth-morris-pratt-algorithm"]}, "language": "python", "interface": {"raw_signature": "def canChoose(self, groups: List[List[int]], nums: List[int]) -> bool:", "container": "Solution", "callable": "canChoose", "parameters": [{"name": "groups", "type": "List[List[int]]"}, {"name": "nums", "type": "List[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1765, "task_id": "map-of-highest-peak", "difficulty": "Medium", "problem_description": "You are given an integer matrix isWater of size m x n that represents a map of land and water cells.\n\n- If isWater[i][j] == 0, cell (i, j) is a land cell.\n- If isWater[i][j] == 1, cell (i, j) is a water cell.\n\nYou must assign each cell a height in a way that follows these rules:\n\n- The height of each cell must be non-negative.\n- If the cell is a water cell, its height must be 0.\n- Any two adjacent cells must have an absolute height difference of at most 1. A cell is adjacent to another cell if the former is directly north, east, south, or west of the latter (i.e., their sides are touching).\n\nFind an assignment of heights such that the maximum height in the matrix is maximized.\n\nReturn an integer matrix height of size m x n where height[i][j] is cell (i, j)'s height. If there are multiple solutions, return any of them.\n\nExample 1:\n\nInput: isWater = [[0,1],[0,0]]\nOutput: [[1,0],[2,1]]\nExplanation: The image shows the assigned heights of each cell.\nThe blue cell is the water cell, and the green cells are the land cells.\n\nExample 2:\n\nInput: isWater = [[0,0,1],[1,0,0],[0,0,0]]\nOutput: [[1,1,0],[0,1,1],[1,2,2]]\nExplanation: A height of 2 is the maximum possible height of any assignment.\nAny height assignment that has a maximum height of 2 while still meeting the rules will also be accepted.\n\nConstraints:\n\n- m == isWater.length\n- n == isWater[i].length\n- 1 <= m, n <= 1000\n- isWater[i][j] is 0 or 1.\n- There is at least one water cell.\n\nNote: This question is the same as 542: https://leetcode.com/problems/01-matrix/\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(isWater = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == [[2, 1, 2], [1, 0, 1], [2, 1, 2]]\n assert candidate(isWater = [[0, 1], [0, 0]]) == [[1, 0], [2, 1]]\n assert candidate(isWater = [[1, 1], [1, 1]]) == [[0, 0], [0, 0]]\n assert candidate(isWater = [[0, 0, 1], [1, 0, 0], [0, 0, 0]]) == [[1, 1, 0], [0, 1, 1], [1, 2, 2]]\n assert candidate(isWater = [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\n assert candidate(isWater = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == [[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 3, 2, 3, 4], [3, 2, 1, 2, 1, 2, 3], [2, 1, 0, 1, 0, 1, 2], [3, 2, 1, 2, 1, 2, 3], [4, 3, 2, 3, 2, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[4, 3, 2, 1, 0, 1, 2, 3, 4], [3, 4, 3, 2, 1, 2, 3, 4, 3], [2, 3, 4, 3, 2, 3, 4, 3, 2], [1, 2, 3, 4, 3, 4, 3, 2, 1], [0, 1, 2, 3, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == [[3, 2, 1, 2, 3], [2, 1, 0, 1, 2], [1, 0, 1, 0, 1], [2, 1, 0, 1, 2], [3, 2, 1, 2, 3]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 4], [1, 2, 1, 2, 3, 3], [2, 1, 0, 1, 2, 2], [3, 2, 1, 2, 2, 1], [4, 3, 2, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]]) == [[0, 1, 2, 1, 0, 1, 2, 1, 0], [1, 2, 3, 2, 1, 2, 3, 2, 1], [2, 3, 4, 3, 2, 3, 4, 3, 2], [3, 4, 5, 4, 3, 4, 5, 4, 3], [4, 5, 6, 5, 4, 5, 6, 5, 4], [3, 4, 5, 4, 3, 4, 5, 4, 3], [2, 3, 4, 3, 2, 3, 4, 3, 2], [1, 2, 3, 2, 1, 2, 3, 2, 1], [0, 1, 2, 1, 0, 1, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[5, 4, 3, 2, 1, 0, 1, 2, 3, 4], [6, 5, 4, 3, 2, 1, 2, 3, 4, 5], [7, 6, 5, 4, 3, 2, 3, 4, 5, 6], [8, 7, 6, 5, 4, 3, 4, 5, 6, 7], [9, 8, 7, 6, 5, 4, 5, 6, 7, 8], [10, 9, 8, 7, 6, 5, 6, 7, 8, 9], [11, 10, 9, 8, 7, 6, 7, 8, 9, 10], [12, 11, 10, 9, 8, 7, 8, 9, 10, 11]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[7, 6, 5, 4, 5, 6, 7, 8, 9, 10], [6, 5, 4, 3, 4, 5, 6, 7, 8, 9], [5, 4, 3, 2, 3, 4, 5, 6, 7, 8], [4, 3, 2, 1, 2, 3, 4, 5, 6, 7], [3, 2, 1, 0, 1, 2, 3, 4, 5, 6], [4, 3, 2, 1, 2, 3, 4, 5, 6, 7], [5, 4, 3, 2, 3, 4, 5, 6, 7, 8], [6, 5, 4, 3, 4, 5, 6, 7, 8, 9], [7, 6, 5, 4, 5, 6, 7, 8, 9, 10], [8, 7, 6, 5, 6, 7, 8, 9, 10, 11]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 8], [2, 3, 4, 5, 6, 7, 8, 9, 8, 7], [3, 4, 5, 6, 7, 8, 9, 8, 7, 6], [4, 5, 6, 7, 8, 9, 8, 7, 6, 5], [5, 6, 7, 8, 9, 8, 7, 6, 5, 4], [6, 7, 8, 9, 8, 7, 6, 5, 4, 3], [7, 8, 9, 8, 7, 6, 5, 4, 3, 2], [8, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[8, 7, 6, 5, 4, 5, 6, 7, 8, 9], [7, 6, 5, 4, 3, 4, 5, 6, 7, 8], [6, 5, 4, 3, 2, 3, 4, 5, 6, 7], [5, 4, 3, 2, 1, 2, 3, 4, 5, 6], [4, 3, 2, 1, 0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 4, 5, 6, 7, 8]]\n assert candidate(isWater = [[0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[3, 2, 1, 0, 1, 2, 3, 4, 5, 6], [2, 1, 0, 1, 2, 3, 4, 5, 6, 7], [1, 0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0]]) == [[2, 1, 2, 1, 2], [1, 0, 1, 0, 1], [2, 1, 2, 1, 2], [1, 0, 1, 0, 1], [2, 1, 2, 1, 2]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == [[10, 9, 8, 7, 6, 7, 8, 9], [9, 8, 7, 6, 5, 6, 7, 8], [8, 7, 6, 5, 4, 5, 6, 7], [7, 6, 5, 4, 3, 4, 5, 6], [6, 5, 4, 3, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4], [4, 3, 2, 1, 0, 1, 2, 3], [5, 4, 3, 2, 1, 2, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[2, 1, 2, 1, 2, 3], [1, 0, 1, 0, 1, 2], [2, 1, 2, 1, 2, 3], [1, 0, 1, 0, 1, 2], [2, 1, 2, 1, 2, 3]]\n assert candidate(isWater = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4], [1, 2, 3, 4, 3], [2, 3, 4, 3, 2], [3, 4, 3, 2, 1], [4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 3, 2, 3], [3, 2, 1, 2, 1, 2], [2, 1, 0, 1, 0, 1], [3, 2, 1, 2, 1, 2], [4, 3, 2, 3, 2, 3], [5, 4, 3, 4, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 3, 4, 3, 2, 3, 4, 5], [3, 2, 1, 2, 3, 2, 1, 2, 3, 4], [2, 1, 0, 1, 2, 1, 0, 1, 2, 3], [3, 2, 1, 2, 3, 2, 1, 2, 3, 4], [3, 2, 1, 2, 3, 2, 1, 2, 3, 4], [2, 1, 0, 1, 2, 1, 0, 1, 2, 3], [3, 2, 1, 2, 3, 2, 1, 2, 3, 4], [4, 3, 2, 3, 2, 3, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4, 5, 6], [4, 3, 2, 1, 0, 1, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5, 4, 3, 4, 5], [5, 4, 3, 2, 3, 4, 3, 2, 3, 4], [4, 3, 2, 1, 2, 3, 2, 1, 2, 3], [3, 2, 1, 0, 1, 2, 1, 0, 1, 2], [4, 3, 2, 1, 2, 3, 2, 1, 2, 3], [4, 3, 2, 1, 2, 3, 2, 1, 2, 3], [3, 2, 1, 0, 1, 2, 1, 0, 1, 2], [4, 3, 2, 1, 2, 3, 2, 1, 2, 3]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 4], [1, 2, 3, 4, 4, 3], [2, 3, 4, 4, 3, 2], [3, 4, 4, 3, 2, 1], [4, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 3, 4, 5, 6], [5, 4, 3, 2, 2, 3, 4, 5], [4, 3, 2, 1, 1, 2, 3, 4], [3, 2, 1, 0, 0, 1, 2, 3], [3, 2, 1, 0, 0, 1, 2, 3], [4, 3, 2, 1, 1, 2, 3, 4], [5, 4, 3, 2, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, 1], [7, 6, 5, 4, 3, 2, 1, 0, 1, 2], [6, 5, 4, 3, 2, 1, 0, 1, 2, 3], [5, 4, 3, 2, 1, 0, 1, 2, 3, 4], [4, 3, 2, 1, 0, 1, 2, 3, 4, 5], [3, 2, 1, 0, 1, 2, 3, 4, 5, 6], [2, 1, 0, 1, 2, 3, 4, 5, 6, 7], [1, 0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 2, 3, 4], [1, 2, 1, 2, 1, 2, 3], [2, 1, 0, 1, 0, 1, 2], [3, 2, 1, 0, 1, 2, 3], [2, 1, 0, 1, 0, 1, 2], [3, 2, 1, 2, 1, 2, 1], [4, 3, 2, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 3, 4, 5, 6, 7], [2, 3, 4, 3, 2, 3, 4, 5, 6], [3, 4, 3, 2, 1, 2, 3, 4, 5], [4, 3, 2, 1, 0, 1, 2, 3, 4], [5, 4, 3, 2, 1, 2, 3, 4, 3], [6, 5, 4, 3, 2, 3, 4, 3, 2], [7, 6, 5, 4, 3, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 4], [2, 3, 4, 5, 4, 3], [3, 4, 5, 4, 3, 2], [4, 5, 4, 3, 2, 1], [5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 4], [1, 2, 3, 4, 5, 4, 3], [2, 3, 4, 5, 4, 3, 2], [3, 4, 5, 4, 3, 2, 1], [4, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0]]) == [[2, 1, 0, 1, 2, 2], [1, 2, 1, 2, 2, 1], [0, 1, 2, 2, 1, 0], [1, 2, 1, 2, 2, 1], [2, 1, 0, 1, 2, 2]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5], [5, 4, 3, 2, 3, 4], [4, 3, 2, 1, 2, 3], [3, 2, 1, 0, 1, 2], [4, 3, 2, 1, 2, 3], [5, 4, 3, 2, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == [[5, 4, 3, 2, 1, 0], [4, 3, 2, 1, 0, 1], [3, 2, 1, 0, 1, 2], [2, 1, 0, 1, 2, 3], [1, 0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[5, 4, 3, 2, 1, 0, 1, 2, 3, 4], [5, 4, 3, 2, 2, 1, 2, 3, 4, 5], [4, 3, 2, 1, 2, 2, 3, 4, 5, 4], [3, 2, 1, 0, 1, 2, 3, 4, 4, 3], [4, 3, 2, 1, 2, 3, 4, 4, 3, 2], [5, 4, 3, 2, 3, 4, 4, 3, 2, 1], [6, 5, 4, 3, 4, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 3, 4, 5], [3, 2, 1, 2, 3, 4], [2, 1, 0, 1, 2, 3], [3, 2, 1, 2, 3, 4], [4, 3, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5, 6, 7, 8], [5, 4, 3, 2, 3, 4, 5, 6, 7], [4, 3, 2, 1, 2, 3, 4, 5, 6], [3, 2, 1, 0, 1, 2, 3, 4, 5], [4, 3, 2, 1, 2, 3, 4, 5, 6], [5, 4, 3, 2, 3, 4, 5, 6, 7], [6, 5, 4, 3, 4, 5, 6, 7, 8], [7, 6, 5, 4, 5, 6, 7, 8, 9], [8, 7, 6, 5, 6, 7, 8, 9, 10]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2], [18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3], [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5], [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6], [22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7], [23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8], [24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9], [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10], [26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12], [28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13], [29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14], [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0]]) == [[2, 1, 2, 3, 4], [1, 0, 1, 2, 3], [2, 1, 2, 1, 2], [3, 2, 1, 0, 1], [4, 3, 2, 1, 2]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 4, 3, 2, 1, 0], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 7, 6, 5, 4, 3], [3, 4, 5, 6, 7, 7, 6, 5, 4, 3], [2, 3, 4, 5, 6, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [0, 1, 2, 3, 4, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == [[2, 1, 2, 3, 3, 2, 1, 2], [1, 0, 1, 2, 2, 1, 0, 1], [2, 1, 2, 3, 3, 2, 1, 2], [3, 2, 3, 4, 4, 3, 2, 3], [2, 1, 2, 3, 3, 2, 1, 2], [1, 0, 1, 2, 2, 1, 0, 1], [2, 1, 2, 3, 3, 2, 1, 2], [3, 2, 3, 4, 4, 3, 2, 3]]\n assert candidate(isWater = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == [[5, 4, 3, 4, 5], [4, 3, 2, 3, 4], [3, 2, 1, 2, 3], [2, 1, 0, 1, 2], [3, 2, 1, 2, 3]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == [[3, 2, 1, 2, 3], [2, 1, 0, 1, 2], [3, 2, 1, 2, 3], [4, 3, 2, 3, 4], [5, 4, 3, 4, 5]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 3, 2, 1, 0], [1, 2, 3, 4, 4, 3, 2, 1], [2, 3, 4, 5, 5, 4, 3, 2], [3, 4, 5, 6, 6, 5, 4, 3], [3, 4, 5, 6, 6, 5, 4, 3], [2, 3, 4, 5, 5, 4, 3, 2], [1, 2, 3, 4, 4, 3, 2, 1], [0, 1, 2, 3, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 6], [2, 3, 4, 5, 6, 7, 6, 5], [3, 4, 5, 6, 7, 6, 5, 4], [4, 5, 6, 7, 6, 5, 4, 3], [5, 6, 7, 6, 5, 4, 3, 2], [6, 7, 6, 5, 4, 3, 2, 1], [7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == [[2, 1, 1, 1, 1, 2], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [2, 1, 1, 1, 1, 2]]\n assert candidate(isWater = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]]) == [[0, 1, 2, 1, 0], [1, 2, 3, 2, 1], [1, 2, 3, 2, 1], [0, 1, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7], [6, 5, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8], [5, 4, 3, 4, 5, 4, 3, 4, 5, 6, 7, 8, 9], [4, 3, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 10], [3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [4, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [5, 4, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [6, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2], [9, 8, 7, 6, 5, 4, 3], [10, 9, 8, 7, 6, 5, 4], [11, 10, 9, 8, 7, 6, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 2, 3, 4], [3, 2, 1, 1, 2, 3], [2, 1, 0, 0, 1, 2], [2, 1, 0, 0, 1, 2], [3, 2, 1, 1, 2, 3], [4, 3, 2, 2, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5, 6], [5, 4, 3, 2, 3, 4, 5], [4, 3, 2, 1, 2, 3, 4], [3, 2, 1, 0, 1, 2, 3], [4, 3, 2, 1, 2, 3, 4], [5, 4, 3, 2, 3, 4, 5]]\n assert candidate(isWater = [[1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1]]) == [[0, 1, 0, 1, 0, 1, 0], [1, 2, 1, 2, 1, 2, 1], [0, 1, 0, 1, 0, 1, 0], [1, 2, 1, 2, 1, 2, 1], [0, 1, 0, 1, 0, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 1, 0, 1], [3, 2, 3, 2, 1, 2], [2, 1, 2, 3, 2, 3], [1, 0, 1, 2, 3, 4], [2, 1, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0]]) == [[4, 3, 2, 1, 0, 1], [3, 2, 1, 0, 1, 2], [2, 1, 0, 1, 0, 1], [1, 0, 1, 2, 1, 0], [0, 1, 0, 1, 2, 1], [1, 2, 1, 0, 1, 2]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 3, 3, 4, 5, 6], [5, 4, 3, 2, 2, 2, 3, 4, 5], [4, 3, 2, 1, 1, 1, 2, 3, 4], [3, 2, 1, 0, 0, 0, 1, 2, 3], [3, 2, 1, 0, 0, 0, 1, 2, 3], [3, 2, 1, 0, 0, 0, 1, 2, 3], [4, 3, 2, 1, 1, 1, 2, 3, 4], [5, 4, 3, 2, 2, 2, 3, 4, 5], [6, 5, 4, 3, 3, 3, 4, 5, 6]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 4, 3, 2, 1, 0], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 7, 6, 5, 4, 3], [4, 5, 6, 7, 8, 8, 7, 6, 5, 4], [4, 5, 6, 7, 8, 8, 7, 6, 5, 4], [3, 4, 5, 6, 7, 7, 6, 5, 4, 3], [2, 3, 4, 5, 6, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [0, 1, 2, 3, 4, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[3, 2, 3, 2, 3, 4], [2, 1, 2, 1, 2, 3], [1, 0, 1, 0, 1, 2], [2, 1, 2, 1, 2, 3], [3, 2, 3, 2, 3, 4]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0], [1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3], [4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4], [5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5], [6, 7, 8, 9, 10, 11, 12, 13, 12, 11, 10, 9, 8, 7, 6], [7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 8, 7], [6, 7, 8, 9, 10, 11, 12, 13, 12, 11, 10, 9, 8, 7, 6], [5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5], [4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4], [3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3], [2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1], [0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == [[1, 0, 1, 2, 3, 3, 4], [2, 1, 2, 3, 3, 2, 3], [3, 2, 3, 3, 2, 1, 2], [4, 3, 3, 2, 1, 0, 1], [5, 4, 4, 3, 2, 1, 2], [6, 5, 5, 4, 3, 2, 3]]\n assert candidate(isWater = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == [[3, 2, 1, 2, 3], [2, 1, 0, 1, 2], [3, 2, 1, 2, 3], [4, 3, 2, 3, 4]]\n assert candidate(isWater = [[0, 1, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == [[1, 0, 1, 2, 3], [1, 1, 2, 3, 3], [0, 1, 2, 3, 2], [1, 2, 3, 2, 1], [2, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 2, 1, 0, 1, 2, 3], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4], [8, 7, 6, 5, 4, 3, 2, 3, 4, 5], [9, 8, 7, 6, 5, 4, 3, 4, 5, 6], [10, 9, 8, 7, 6, 5, 4, 5, 6, 7], [11, 10, 9, 8, 7, 6, 5, 6, 7, 8], [12, 11, 10, 9, 8, 7, 6, 7, 8, 9], [13, 12, 11, 10, 9, 8, 7, 8, 9, 10]]\n assert candidate(isWater = [[0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0]]) == [[4, 3, 2, 1, 0, 1, 2, 3, 4], [3, 4, 3, 2, 1, 2, 3, 4, 3], [2, 3, 4, 3, 2, 3, 4, 3, 2], [1, 2, 3, 4, 3, 4, 3, 2, 1], [0, 1, 2, 3, 4, 3, 2, 1, 0], [1, 2, 3, 4, 3, 4, 3, 2, 1], [2, 3, 4, 3, 2, 3, 4, 3, 2], [3, 4, 3, 2, 1, 2, 3, 4, 3], [4, 3, 2, 1, 0, 1, 2, 3, 4]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 7], [1, 2, 3, 4, 5, 6, 7, 8, 7, 6], [2, 3, 4, 5, 6, 7, 8, 7, 6, 5], [3, 4, 5, 6, 7, 8, 7, 6, 5, 4], [4, 5, 6, 7, 8, 7, 6, 5, 4, 3], [5, 6, 7, 8, 7, 6, 5, 4, 3, 2], [6, 7, 8, 7, 6, 5, 4, 3, 2, 1], [7, 8, 7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]]) == [[0, 1, 2, 1, 0], [1, 2, 3, 2, 1], [2, 3, 4, 3, 2], [1, 2, 3, 2, 1], [0, 1, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[10, 9, 8, 7, 6, 5, 4, 5, 6, 7, 6, 5, 4, 5, 6, 7, 8, 9, 10, 11], [9, 8, 7, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 9, 10], [8, 7, 6, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8], [6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8], [6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 5, 6, 7, 6, 5, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 6, 7, 8, 7, 6, 5, 6, 7, 8, 9, 10, 11, 12], [12, 11, 10, 9, 8, 7, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9, 10, 11, 12, 13], [13, 12, 11, 10, 9, 8, 7, 8, 9, 10, 9, 8, 7, 8, 9, 10, 11, 12, 13, 14], [14, 13, 12, 11, 10, 9, 8, 9, 10, 11, 10, 9, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 10, 11, 12, 11, 10, 9, 10, 11, 12, 13, 14, 15, 16], [16, 15, 14, 13, 12, 11, 10, 11, 12, 13, 12, 11, 10, 11, 12, 13, 14, 15, 16, 17], [17, 16, 15, 14, 13, 12, 11, 12, 13, 14, 13, 12, 11, 12, 13, 14, 15, 16, 17, 18]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5, 6, 7], [5, 4, 3, 2, 3, 4, 5, 6], [4, 3, 2, 1, 2, 3, 4, 5], [3, 2, 1, 0, 1, 2, 3, 4], [4, 3, 2, 1, 2, 3, 4, 5], [5, 4, 3, 2, 3, 4, 5, 6], [6, 5, 4, 3, 4, 5, 6, 7], [7, 6, 5, 4, 5, 6, 7, 8]]\n", "comparison": "exact"}, "public_tests": ["[[0,1],[0,0]]", "[[0,0,1],[1,0,0],[0,0,0]]"], "hints": ["Set each water cell to be 0. The height of each cell is limited by its closest water cell.", "Perform a multi-source BFS with all the water cells as sources."], "metadata": {"canonical_parameter_names": ["isWater"], "leetcode_dataset_entry_point": "Solution().highestPeak", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:04+00:00", "tests_total": 68, "tests_dropped": 0, "flags": ["multiple_answers", "has_images"], "topic_tags": ["array", "breadth-first-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def highestPeak(self, isWater: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "highestPeak", "parameters": [{"name": "isWater", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1766, "task_id": "tree-of-coprimes", "difficulty": "Hard", "problem_description": "There is a tree (i.e., a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. Each node has a value associated with it, and the root of the tree is node 0.\n\nTo represent this tree, you are given an integer array nums and a 2D array edges. Each nums[i] represents the i^th node's value, and each edges[j] = [u_j, v_j] represents an edge between nodes u_j and v_j in the tree.\n\nTwo values x and y are coprime if gcd(x, y) == 1 where gcd(x, y) is the greatest common divisor of x and y.\n\nAn ancestor of a node i is any other node on the shortest path from node i to the root. A node is not considered an ancestor of itself.\n\nReturn an array ans of size n, where ans[i] is the closest ancestor to node i such that nums[i] and nums[ans[i]] are coprime, or -1 if there is no such ancestor.\n\nExample 1:\n\nInput: nums = [2,3,3,2], edges = [[0,1],[1,2],[1,3]]\nOutput: [-1,0,0,1]\nExplanation: In the above figure, each node's value is in parentheses.\n- Node 0 has no coprime ancestors.\n- Node 1 has only one ancestor, node 0. Their values are coprime (gcd(2,3) == 1).\n- Node 2 has two ancestors, nodes 1 and 0. Node 1's value is not coprime (gcd(3,3) == 3), but node 0's\n value is (gcd(2,3) == 1), so node 0 is the closest valid ancestor.\n- Node 3 has two ancestors, nodes 1 and 0. It is coprime with node 1 (gcd(3,2) == 1), so node 1 is its\n closest valid ancestor.\n\nExample 2:\n\nInput: nums = [5,6,10,2,3,6,15], edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]]\nOutput: [-1,0,-1,0,0,0,-1]\n\nConstraints:\n\n- nums.length == n\n- 1 <= nums[i] <= 50\n- 1 <= n <= 10^5\n- edges.length == n - 1\n- edges[j].length == 2\n- 0 <= u_j, v_j < n\n- u_j != v_j\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 3, 3, 2],edges = [[0, 1], [1, 2], [1, 3]]) == [-1, 0, 0, 1]\n assert candidate(nums = [5, 6, 10, 2, 3, 6, 15],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == [-1, 0, -1, 0, 0, 0, -1]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4]\n assert candidate(nums = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 5, 1, 11],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]\n assert candidate(nums = [49, 42, 35, 28, 21, 14, 7, 1, 49, 42],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8], [6, 9]]) == [-1, -1, -1, -1, -1, -1, -1, 3, -1, -1]\n assert candidate(nums = [7, 11, 13, 5, 3, 2, 8, 9, 10, 12],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 4, 2]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [15, 10, 6, 9, 12, 18, 21, 30, 24, 33],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [41, 37, 43, 47, 29, 31, 37, 41, 43, 47, 29, 31, 37, 41, 43, 47, 29, 31, 37, 41],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 1, 2, 5, 6, 6, 7, 7, 8, 8, 9]\n assert candidate(nums = [47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]\n assert candidate(nums = [47, 37, 41, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6]\n assert candidate(nums = [2, 3, 5, 2, 3, 5, 2, 3, 5, 2, 3, 5, 2, 3, 5, 2, 3, 5, 2, 3, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20]]) == [-1, 0, 0, 1, 0, 0, 2, 3, 3, 4, 0, 0, 5, 6, 6, 7, 3, 3, 8, 9, 9]\n assert candidate(nums = [7, 5, 6, 3, 5, 3, 7, 11, 13, 17],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [5, 8], [6, 9]]) == [-1, 0, 0, 1, 0, 0, 2, 3, 5, 6]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11]]) == [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [5, 8], [6, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [41, 43, 47, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14]]) == [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6]\n", "comparison": "exact"}, "public_tests": ["[2,3,3,2]\n[[0,1],[1,2],[1,3]]", "[5,6,10,2,3,6,15]\n[[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]]"], "hints": ["Note that for a node, it's not optimal to consider two nodes with the same value.", "Note that the values are small enough for you to iterate over them instead of iterating over the parent nodes."], "metadata": {"canonical_parameter_names": ["nums", "edges"], "leetcode_dataset_entry_point": "Solution().getCoprimes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:06+00:00", "tests_total": 31, "tests_dropped": 8, "flags": ["has_images"], "topic_tags": ["array", "math", "tree", "depth-first-search", "number-theory"]}, "language": "python", "interface": {"raw_signature": "def getCoprimes(self, nums: list[int], edges: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "getCoprimes", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1768, "task_id": "merge-strings-alternately", "difficulty": "Easy", "problem_description": "You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string.\n\nReturn the merged string.\n\nExample 1:\n\nInput: word1 = \"abc\", word2 = \"pqr\"\nOutput: \"apbqcr\"\nExplanation: The merged string will be merged as so:\nword1: a b c\nword2: p q r\nmerged: a p b q c r\n\nExample 2:\n\nInput: word1 = \"ab\", word2 = \"pqrs\"\nOutput: \"apbqrs\"\nExplanation: Notice that as word2 is longer, \"rs\" is appended to the end.\nword1: a b\nword2: p q r s\nmerged: a p b q r s\n\nExample 3:\n\nInput: word1 = \"abcd\", word2 = \"pq\"\nOutput: \"apbqcd\"\nExplanation: Notice that as word1 is longer, \"cd\" is appended to the end.\nword1: a b c d\nword2: p q\nmerged: a p b q c d\n\nConstraints:\n\n- 1 <= word1.length, word2.length <= 100\n- word1 and word2 consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"a\",word2 = \"b\") == \"ab\"\n assert candidate(word1 = \"abcd\",word2 = \"pq\") == \"apbqcd\"\n assert candidate(word1 = \"ab\",word2 = \"pqrs\") == \"apbqrs\"\n assert candidate(word1 = \"x\",word2 = \"y\") == \"xy\"\n assert candidate(word1 = \"hello\",word2 = \"world\") == \"hweolrllod\"\n assert candidate(word1 = \"a\",word2 = \"bcd\") == \"abcd\"\n assert candidate(word1 = \"abcde\",word2 = \"fgh\") == \"afbgchde\"\n assert candidate(word1 = \"abc\",word2 = \"pqr\") == \"apbqcr\"\n assert candidate(word1 = \"abcd\",word2 = \"e\") == \"aebcd\"\n assert candidate(word1 = \"a\",word2 = \"bcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(word1 = \"thisisateststring\",word2 = \"anotheronehere\") == \"tahniostihseartoensethsetrreing\"\n assert candidate(word1 = \"aabbccdd\",word2 = \"eeffgg\") == \"aeaebfbfcgcgdd\"\n assert candidate(word1 = \"complex\",word2 = \"strings\") == \"csotmrpilnegxs\"\n assert candidate(word1 = \"xyz\",word2 = \"abcde\") == \"xaybzcde\"\n assert candidate(word1 = \"abcdefgh\",word2 = \"ijkl\") == \"aibjckdlefgh\"\n assert candidate(word1 = \"abcdefghijk\",word2 = \"lmnopqrstuvwxyz\") == \"albmcndoepfqgrhsitjukvwxyz\"\n assert candidate(word1 = \"abcdefghij\",word2 = \"klmnopqrstuvwxyz\") == \"akblcmdneofpgqhrisjtuvwxyz\"\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxy\",word2 = \"z\") == \"azbcdefghijklmnopqrstuvwxy\"\n assert candidate(word1 = \"quick\",word2 = \"brownfox\") == \"qburiocwknfox\"\n assert candidate(word1 = \"onetwothreefour\",word2 = \"five\") == \"ofnievtewothreefour\"\n assert candidate(word1 = \"overlap\",word2 = \"lapping\") == \"olvaeprplianpg\"\n assert candidate(word1 = \"python\",word2 = \"java\") == \"pjyatvhaon\"\n assert candidate(word1 = \"abcdefgh\",word2 = \"ijklmnopqrstuv\") == \"aibjckdlemfngohpqrstuv\"\n assert candidate(word1 = \"different\",word2 = \"length\") == \"dliefnfgetrhent\"\n assert candidate(word1 = \"abcdefghij\",word2 = \"klmnopqrst\") == \"akblcmdneofpgqhrisjt\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"zyxwzyxwzyxw\") == \"azbycxdwazbycxdwazbycxdw\"\n assert candidate(word1 = \"longerfirstword\",word2 = \"short\") == \"lsohnogretrfirstword\"\n assert candidate(word1 = \"abcdefg\",word2 = \"hijklmnop\") == \"ahbicjdkelfmgnop\"\n assert candidate(word1 = \"abcdef\",word2 = \"ghijklmnopqrstuvwxyz\") == \"agbhcidjekflmnopqrstuvwxyz\"\n assert candidate(word1 = \"xyz\",word2 = \"abcdefg\") == \"xaybzcdefg\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"efghefghefghefgh\") == \"aebfcgdhaebfcgdhaebfcgdhefgh\"\n assert candidate(word1 = \"short\",word2 = \"longersecondword\") == \"slhoonrgtersecondword\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"gggghhhhiiii\") == \"agagbgbgchchdhdheieififi\"\n assert candidate(word1 = \"oddlength\",word2 = \"evenlengths\") == \"oedvdelnelnegntghths\"\n assert candidate(word1 = \"same\",word2 = \"size\") == \"ssaimzee\"\n assert candidate(word1 = \"abcdefg\",word2 = \"hijklmnopqrstuvwxyz\") == \"ahbicjdkelfmgnopqrstuvwxyz\"\n assert candidate(word1 = \"aabbccddeeffgghhiijj\",word2 = \"kkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"akakblblcmcmdndneoeofpfpgqgqhrhrisisjtjtuuvvwwxxyyzz\"\n assert candidate(word1 = \"hello\",word2 = \"worldwide\") == \"hweolrllodwide\"\n assert candidate(word1 = \"xyzxyzxyz\",word2 = \"abcabcabc\") == \"xaybzcxaybzcxaybzc\"\n assert candidate(word1 = \"abcdxyz\",word2 = \"efghwvu\") == \"aebfcgdhxwyvzu\"\n assert candidate(word1 = \"short\",word2 = \"averylongstring\") == \"sahvoerrtylongstring\"\n assert candidate(word1 = \"hello\",word2 = \"worldthisisaverylongstring\") == \"hweolrllodthisisaverylongstring\"\n assert candidate(word1 = \"abcdefg\",word2 = \"hijkl\") == \"ahbicjdkelfg\"\n assert candidate(word1 = \"abcdef\",word2 = \"ghijklmnop\") == \"agbhcidjekflmnop\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"xyzxyzxyzxyz\") == \"axbyczdxaybzcxdyazbxcydz\"\n assert candidate(word1 = \"averyveryverylongword\",word2 = \"short\") == \"asvheorrytveryverylongword\"\n assert candidate(word1 = \"longerword\",word2 = \"short\") == \"lsohnogretrword\"\n assert candidate(word1 = \"longstringwithmorecharacters\",word2 = \"shortstr\") == \"lsohnogrsttsrtirngwithmorecharacters\"\n assert candidate(word1 = \"abcdef\",word2 = \"zyxwvu\") == \"azbycxdwevfu\"\n assert candidate(word1 = \"xyz\",word2 = \"uvw\") == \"xuyvzw\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"zzzzyyyxxww\") == \"azazbzbzcycydydxexewfwf\"\n assert candidate(word1 = \"abcdefgh\",word2 = \"ijklmnop\") == \"aibjckdlemfngohp\"\n assert candidate(word1 = \"onetwothree\",word2 = \"four\") == \"ofnoeutrwothree\"\n assert candidate(word1 = \"aabbcc\",word2 = \"ddeeff\") == \"adadbebecfcf\"\n assert candidate(word1 = \"aabbccddeeffgghhiijj\",word2 = \"zzzzzzzzzz\") == \"azazbzbzczczdzdzezezffgghhiijj\"\n assert candidate(word1 = \"abacaxi\",word2 = \"manga\") == \"ambaancgaaxi\"\n assert candidate(word1 = \"onetwothreefour\",word2 = \"fivesix\") == \"ofnievtewsoitxhreefour\"\n assert candidate(word1 = \"one\",word2 = \"twothreefour\") == \"otnweothreefour\"\n assert candidate(word1 = \"xyz\",word2 = \"wvutsrqponmlkjihgfedcba\") == \"xwyvzutsrqponmlkjihgfedcba\"\n assert candidate(word1 = \"short\",word2 = \"averyverylongwordindeed\") == \"sahvoerrtyverylongwordindeed\"\n assert candidate(word1 = \"xy\",word2 = \"abcdefghijk\") == \"xaybcdefghijk\"\n assert candidate(word1 = \"onetwothree\",word2 = \"fourfivesix\") == \"ofnoeutrwfoitvherseiex\"\n assert candidate(word1 = \"python\",word2 = \"programming\") == \"ppyrtohgornamming\"\n assert candidate(word1 = \"verylongwordthatgoesonandone\",word2 = \"short\") == \"vsehroyrltongwordthatgoesonandone\"\n assert candidate(word1 = \"xyz\",word2 = \"abcdef\") == \"xaybzcdef\"\n assert candidate(word1 = \"merge\",word2 = \"these\") == \"mtehregsee\"\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"z\") == \"azbcdefghijklmnopqrstuvwxyz\"\n assert candidate(word1 = \"xyzlmnop\",word2 = \"qrstuvwx\") == \"xqyrzsltmunvowpx\"\n assert candidate(word1 = \"abcdefgh\",word2 = \"ijklmno\") == \"aibjckdlemfngoh\"\n assert candidate(word1 = \"short\",word2 = \"averyveryverylongword\") == \"sahvoerrtyveryverylongword\"\n assert candidate(word1 = \"averyverylongwordindeed\",word2 = \"short\") == \"asvheorrytverylongwordindeed\"\n assert candidate(word1 = \"equal\",word2 = \"equal\") == \"eeqquuaall\"\n assert candidate(word1 = \"ab\",word2 = \"cd\") == \"acbd\"\n assert candidate(word1 = \"short\",word2 = \"averylongstringthatweneedtocheck\") == \"sahvoerrtylongstringthatweneedtocheck\"\n assert candidate(word1 = \"same\",word2 = \"same\") == \"ssaammee\"\n assert candidate(word1 = \"thisisaverylongstring\",word2 = \"hello\") == \"thheilsliosaverylongstring\"\n", "comparison": "exact"}, "public_tests": ["\"abc\"\n\"pqr\"", "\"ab\"\n\"pqrs\"", "\"abcd\"\n\"pq\""], "hints": ["Use two pointers, one pointer for each string. Alternately choose the character from each pointer, and move the pointer upwards."], "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().mergeAlternately", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:09+00:00", "tests_total": 92, "tests_dropped": 16, "flags": [], "topic_tags": ["two-pointers", "string"]}, "language": "python", "interface": {"raw_signature": "def mergeAlternately(self, word1: str, word2: str) -> str:", "container": "Solution", "callable": "mergeAlternately", "parameters": [{"name": "word1", "type": "str"}, {"name": "word2", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1769, "task_id": "minimum-number-of-operations-to-move-all-balls-to-each-box", "difficulty": "Medium", "problem_description": "You have n boxes. You are given a binary string boxes of length n, where boxes[i] is '0' if the i^th box is empty, and '1' if it contains one ball.\n\nIn one operation, you can move one ball from a box to an adjacent box. Box i is adjacent to box j if abs(i - j) == 1. Note that after doing so, there may be more than one ball in some boxes.\n\nReturn an array answer of size n, where answer[i] is the minimum number of operations needed to move all the balls to the i^th box.\n\nEach answer[i] is calculated considering the initial state of the boxes.\n\nExample 1:\n\nInput: boxes = \"110\"\nOutput: [1,1,3]\nExplanation: The answer for each box is as follows:\n1) First box: you will have to move one ball from the second box to the first box in one operation.\n2) Second box: you will have to move one ball from the first box to the second box in one operation.\n3) Third box: you will have to move one ball from the first box to the third box in two operations, and move one ball from the second box to the third box in one operation.\n\nExample 2:\n\nInput: boxes = \"001011\"\nOutput: [11,8,5,4,3,4]\n\nConstraints:\n\n- n == boxes.length\n- 1 <= n <= 2000\n- boxes[i] is either '0' or '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(boxes = \"0101010101\") == [25, 20, 17, 14, 13, 12, 13, 14, 17, 20]\n assert candidate(boxes = \"001011\") == [11, 8, 5, 4, 3, 4]\n assert candidate(boxes = \"000111000\") == [12, 9, 6, 3, 2, 3, 6, 9, 12]\n assert candidate(boxes = \"111000\") == [3, 2, 3, 6, 9, 12]\n assert candidate(boxes = \"01010101\") == [16, 12, 10, 8, 8, 8, 10, 12]\n assert candidate(boxes = \"1000000001\") == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(boxes = \"1010101010\") == [20, 17, 14, 13, 12, 13, 14, 17, 20, 25]\n assert candidate(boxes = \"1001001001001\") == [30, 27, 24, 21, 20, 19, 18, 19, 20, 21, 24, 27, 30]\n assert candidate(boxes = \"101010\") == [6, 5, 4, 5, 6, 9]\n assert candidate(boxes = \"1001001\") == [9, 8, 7, 6, 7, 8, 9]\n assert candidate(boxes = \"010101010101\") == [36, 30, 26, 22, 20, 18, 18, 18, 20, 22, 26, 30]\n assert candidate(boxes = \"11111\") == [10, 7, 6, 7, 10]\n assert candidate(boxes = \"1111\") == [6, 4, 4, 6]\n assert candidate(boxes = \"111100001111\") == [44, 38, 34, 32, 32, 32, 32, 32, 32, 34, 38, 44]\n assert candidate(boxes = \"111000111\") == [24, 20, 18, 18, 18, 18, 18, 20, 24]\n assert candidate(boxes = \"0000\") == [0, 0, 0, 0]\n assert candidate(boxes = \"1111111111\") == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(boxes = \"110\") == [1, 1, 3]\n assert candidate(boxes = \"00000\") == [0, 0, 0, 0, 0]\n assert candidate(boxes = \"1000001\") == [6, 6, 6, 6, 6, 6, 6]\n assert candidate(boxes = \"000111\") == [12, 9, 6, 3, 2, 3]\n assert candidate(boxes = \"0000011111000001111100000\") == [120, 110, 100, 90, 80, 70, 62, 56, 52, 50, 50, 50, 50, 50, 50, 50, 52, 56, 62, 70, 80, 90, 100, 110, 120]\n assert candidate(boxes = \"000000111111000000111111\") == [174, 162, 150, 138, 126, 114, 102, 92, 84, 78, 74, 72, 72, 72, 72, 72, 72, 72, 72, 74, 78, 84, 92, 102]\n assert candidate(boxes = \"0101010101010101010101010101\") == [196, 182, 170, 158, 148, 138, 130, 122, 116, 110, 106, 102, 100, 98, 98, 98, 100, 102, 106, 110, 116, 122, 130, 138, 148, 158, 170, 182]\n assert candidate(boxes = \"0101010101010101010101010101010101010101010101010101\") == [676, 650, 626, 602, 580, 558, 538, 518, 500, 482, 466, 450, 436, 422, 410, 398, 388, 378, 370, 362, 356, 350, 346, 342, 340, 338, 338, 338, 340, 342, 346, 350, 356, 362, 370, 378, 388, 398, 410, 422, 436, 450, 466, 482, 500, 518, 538, 558, 580, 602, 626, 650]\n assert candidate(boxes = \"01010101010101010101010101010101010101010101010101\") == [625, 600, 577, 554, 533, 512, 493, 474, 457, 440, 425, 410, 397, 384, 373, 362, 353, 344, 337, 330, 325, 320, 317, 314, 313, 312, 313, 314, 317, 320, 325, 330, 337, 344, 353, 362, 373, 384, 397, 410, 425, 440, 457, 474, 493, 512, 533, 554, 577, 600]\n assert candidate(boxes = \"1001001001001001001001001001001001001001001001001001\") == [459, 443, 427, 411, 397, 383, 369, 357, 345, 333, 323, 313, 303, 295, 287, 279, 273, 267, 261, 257, 253, 249, 247, 245, 243, 243, 243, 243, 245, 247, 249, 253, 257, 261, 267, 273, 279, 287, 295, 303, 313, 323, 333, 345, 357, 369, 383, 397, 411, 427, 443, 459]\n assert candidate(boxes = \"1000100010001\") == [24, 22, 20, 18, 16, 16, 16, 16, 16, 18, 20, 22, 24]\n assert candidate(boxes = \"111000111000111000111\") == [120, 110, 102, 96, 90, 84, 78, 74, 72, 72, 72, 72, 72, 74, 78, 84, 90, 96, 102, 110, 120]\n assert candidate(boxes = \"1101100110011001\") == [61, 54, 49, 44, 41, 40, 39, 38, 39, 42, 45, 48, 53, 60, 67, 74]\n assert candidate(boxes = \"111101010101010101010101010101010101010101010101\") == [578, 554, 532, 512, 494, 476, 460, 444, 430, 416, 404, 392, 382, 372, 364, 356, 350, 344, 340, 336, 334, 332, 332, 332, 334, 336, 340, 344, 350, 356, 364, 372, 382, 392, 404, 416, 430, 444, 460, 476, 494, 512, 532, 552, 574, 596, 620, 644]\n assert candidate(boxes = \"00001111110000\") == [39, 33, 27, 21, 15, 11, 9, 9, 11, 15, 21, 27, 33, 39]\n assert candidate(boxes = \"0000000000000000000000000000000000000000000000001\") == [48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(boxes = \"111000111000111\") == [63, 56, 51, 48, 45, 42, 39, 38, 39, 42, 45, 48, 51, 56, 63]\n assert candidate(boxes = \"00000000000000000000000100000000000000000000000\") == [23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]\n assert candidate(boxes = \"0001000100010001000100010001\") == [105, 98, 91, 84, 79, 74, 69, 64, 61, 58, 55, 52, 51, 50, 49, 48, 49, 50, 51, 52, 55, 58, 61, 64, 69, 74, 79, 84]\n assert candidate(boxes = \"100000000000000000000000000000000000000000000000001\") == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(boxes = \"0000000000000000000000000000000000000000000000000001\") == [51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(boxes = \"10101010101010101010101010101010101010101010\") == [462, 442, 422, 404, 386, 370, 354, 340, 326, 314, 302, 292, 282, 274, 266, 260, 254, 250, 246, 244, 242, 242, 242, 244, 246, 250, 254, 260, 266, 274, 282, 292, 302, 314, 326, 340, 354, 370, 386, 404, 422, 442, 462, 484]\n assert candidate(boxes = \"000010001000100010001\") == [60, 55, 50, 45, 40, 37, 34, 31, 28, 27, 26, 25, 24, 25, 26, 27, 28, 31, 34, 37, 40]\n assert candidate(boxes = \"00101010101010101010101010101\") == [210, 196, 182, 170, 158, 148, 138, 130, 122, 116, 110, 106, 102, 100, 98, 98, 98, 100, 102, 106, 110, 116, 122, 130, 138, 148, 158, 170, 182]\n assert candidate(boxes = \"011100000111000001110000011100000\") == [168, 156, 146, 138, 132, 126, 120, 114, 108, 102, 98, 96, 96, 96, 96, 96, 96, 96, 98, 102, 108, 114, 120, 126, 132, 138, 146, 156, 168, 180, 192, 204, 216]\n assert candidate(boxes = \"110001100011000\") == [33, 29, 27, 25, 23, 21, 21, 23, 25, 27, 29, 33, 39, 45, 51]\n assert candidate(boxes = \"10101010101010101010\") == [90, 82, 74, 68, 62, 58, 54, 52, 50, 50, 50, 52, 54, 58, 62, 68, 74, 82, 90, 100]\n assert candidate(boxes = \"010010001000010000010000001000000000\") == [71, 65, 61, 57, 53, 51, 49, 47, 45, 45, 45, 45, 45, 45, 47, 49, 51, 53, 55, 57, 61, 65, 69, 73, 77, 81, 85, 91, 97, 103, 109, 115, 121, 127, 133, 139]\n assert candidate(boxes = \"11100000000111100000001111\") == [147, 138, 131, 126, 121, 116, 111, 106, 101, 96, 91, 86, 83, 82, 83, 86, 89, 92, 95, 98, 101, 104, 107, 112, 119, 128]\n assert candidate(boxes = \"0010001000100010001\") == [50, 45, 40, 37, 34, 31, 28, 27, 26, 25, 24, 25, 26, 27, 28, 31, 34, 37, 40]\n assert candidate(boxes = \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\") == [112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112]\n assert candidate(boxes = \"1010101010101010101010101\") == [156, 145, 134, 125, 116, 109, 102, 97, 92, 89, 86, 85, 84, 85, 86, 89, 92, 97, 102, 109, 116, 125, 134, 145, 156]\n assert candidate(boxes = \"111100000011110000001111\") == [138, 128, 120, 114, 110, 106, 102, 98, 94, 90, 86, 84, 84, 86, 90, 94, 98, 102, 106, 110, 114, 120, 128, 138]\n assert candidate(boxes = \"1010101010101010101010101010101010101010\") == [380, 362, 344, 328, 312, 298, 284, 272, 260, 250, 240, 232, 224, 218, 212, 208, 204, 202, 200, 200, 200, 202, 204, 208, 212, 218, 224, 232, 240, 250, 260, 272, 284, 298, 312, 328, 344, 362, 380, 400]\n assert candidate(boxes = \"101010101010101010101010101010101010101010101010101010101010\") == [870, 842, 814, 788, 762, 738, 714, 692, 670, 650, 630, 612, 594, 578, 562, 548, 534, 522, 510, 500, 490, 482, 474, 468, 462, 458, 454, 452, 450, 450, 450, 452, 454, 458, 462, 468, 474, 482, 490, 500, 510, 522, 534, 548, 562, 578, 594, 612, 630, 650, 670, 692, 714, 738, 762, 788, 814, 842, 870, 900]\n assert candidate(boxes = \"001001001001001001001001001001001001001001001001001001001\") == [551, 532, 513, 496, 479, 462, 447, 432, 417, 404, 391, 378, 367, 356, 345, 336, 327, 318, 311, 304, 297, 292, 287, 282, 279, 276, 273, 272, 271, 270, 271, 272, 273, 276, 279, 282, 287, 292, 297, 304, 311, 318, 327, 336, 345, 356, 367, 378, 391, 404, 417, 432, 447, 462, 479, 496, 513]\n assert candidate(boxes = \"1101101101101101101101101101101101101101101101101101101101101101101101101101101101101101\") == [2552, 2495, 2440, 2385, 2332, 2281, 2230, 2181, 2134, 2087, 2042, 1999, 1956, 1915, 1876, 1837, 1800, 1765, 1730, 1697, 1666, 1635, 1606, 1579, 1552, 1527, 1504, 1481, 1460, 1441, 1422, 1405, 1390, 1375, 1362, 1351, 1340, 1331, 1324, 1317, 1312, 1309, 1306, 1305, 1306, 1307, 1310, 1315, 1320, 1327, 1336, 1345, 1356, 1369, 1382, 1397, 1414, 1431, 1450, 1471, 1492, 1515, 1540, 1565, 1592, 1621, 1650, 1681, 1714, 1747, 1782, 1819, 1856, 1895, 1936, 1977, 2020, 2065, 2110, 2157, 2206, 2255, 2306, 2359, 2412, 2467, 2524, 2581]\n assert candidate(boxes = \"10100101001010010100101001010010\") == [192, 181, 170, 161, 152, 143, 136, 129, 124, 119, 114, 111, 108, 107, 106, 105, 106, 107, 110, 113, 116, 121, 126, 133, 140, 147, 156, 165, 176, 187, 198, 211]\n assert candidate(boxes = \"1001001001001001001001001001\") == [135, 127, 119, 111, 105, 99, 93, 89, 85, 81, 79, 77, 75, 75, 75, 75, 77, 79, 81, 85, 89, 93, 99, 105, 111, 119, 127, 135]\n assert candidate(boxes = \"0001000010000100001\") == [42, 38, 34, 30, 28, 26, 24, 22, 20, 20, 20, 20, 20, 20, 22, 24, 26, 28, 30]\n assert candidate(boxes = \"0000100000000100000001\") == [38, 35, 32, 29, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(boxes = \"100000000000000000001\") == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(boxes = \"101001010010100101001010\") == [110, 102, 94, 88, 82, 76, 72, 68, 66, 64, 62, 62, 62, 64, 66, 68, 72, 76, 82, 88, 94, 102, 110, 120]\n assert candidate(boxes = \"1111000011110000111100001111\") == [216, 202, 190, 180, 172, 164, 156, 148, 140, 134, 130, 128, 128, 128, 128, 128, 128, 130, 134, 140, 148, 156, 164, 172, 180, 190, 202, 216]\n assert candidate(boxes = \"110100100100110\") == [44, 39, 36, 33, 32, 31, 30, 31, 32, 33, 36, 39, 42, 47, 54]\n assert candidate(boxes = \"1111111111111111111111111111111111111111111111111111\") == [1326, 1276, 1228, 1182, 1138, 1096, 1056, 1018, 982, 948, 916, 886, 858, 832, 808, 786, 766, 748, 732, 718, 706, 696, 688, 682, 678, 676, 676, 678, 682, 688, 696, 706, 718, 732, 748, 766, 786, 808, 832, 858, 886, 916, 948, 982, 1018, 1056, 1096, 1138, 1182, 1228, 1276, 1326]\n assert candidate(boxes = \"0000000000101010101010101010101010100000000\") == [286, 273, 260, 247, 234, 221, 208, 195, 182, 169, 156, 145, 134, 125, 116, 109, 102, 97, 92, 89, 86, 85, 84, 85, 86, 89, 92, 97, 102, 109, 116, 125, 134, 145, 156, 169, 182, 195, 208, 221, 234, 247, 260]\n assert candidate(boxes = \"10011001100110011001100110011\") == [217, 204, 191, 178, 167, 158, 149, 140, 133, 128, 123, 118, 115, 114, 113, 112, 113, 116, 119, 122, 127, 134, 141, 148, 157, 168, 179, 190, 203]\n assert candidate(boxes = \"11111111100000000111111110000000011111111\") == [492, 469, 448, 429, 412, 397, 384, 373, 364, 357, 350, 343, 336, 329, 322, 315, 308, 301, 296, 293, 292, 293, 296, 301, 308, 317, 326, 335, 344, 353, 362, 371, 380, 389, 400, 413, 428, 445, 464, 485, 508]\n assert candidate(boxes = \"1010101010101010\") == [56, 50, 44, 40, 36, 34, 32, 32, 32, 34, 36, 40, 44, 50, 56, 64]\n assert candidate(boxes = \"0000110000000000110000000000110000000000110000000000110000000000110000000000110000000000\") == [567, 553, 539, 525, 511, 499, 489, 479, 469, 459, 449, 439, 429, 419, 409, 399, 389, 381, 375, 369, 363, 357, 351, 345, 339, 333, 327, 321, 315, 311, 309, 307, 305, 303, 301, 299, 297, 295, 293, 291, 289, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 315, 321, 327, 333, 339, 345, 351, 357, 363, 369, 375, 381, 389, 399, 409, 419, 429, 439, 449, 459, 469, 479, 489, 499, 511, 525, 539, 553, 567, 581, 595, 609, 623, 637, 651]\n assert candidate(boxes = \"00000000000111111111100000000000\") == [155, 145, 135, 125, 115, 105, 95, 85, 75, 65, 55, 45, 37, 31, 27, 25, 25, 27, 31, 37, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]\n assert candidate(boxes = \"01001010010100101001010010100101001010010100101001\") == [500, 480, 462, 444, 426, 410, 394, 380, 366, 352, 340, 328, 318, 308, 298, 290, 282, 276, 270, 264, 260, 256, 254, 252, 250, 250, 250, 252, 254, 256, 260, 264, 270, 276, 282, 290, 298, 308, 318, 328, 340, 352, 366, 380, 394, 410, 426, 444, 462, 480]\n assert candidate(boxes = \"101010101010101010101010\") == [132, 122, 112, 104, 96, 90, 84, 80, 76, 74, 72, 72, 72, 74, 76, 80, 84, 90, 96, 104, 112, 122, 132, 144]\n assert candidate(boxes = \"11110000111100001111000011110000111100001111000011110000\") == [714, 688, 664, 642, 622, 602, 582, 562, 542, 524, 508, 494, 482, 470, 458, 446, 434, 424, 416, 410, 406, 402, 398, 394, 390, 388, 388, 390, 394, 398, 402, 406, 410, 416, 424, 434, 446, 458, 470, 482, 494, 508, 524, 542, 562, 582, 602, 622, 642, 664, 688, 714, 742, 770, 798, 826]\n assert candidate(boxes = \"10000000001000000000100000000010000000001\") == [100, 97, 94, 91, 88, 85, 82, 79, 76, 73, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100]\n assert candidate(boxes = \"0000011111100000\") == [45, 39, 33, 27, 21, 15, 11, 9, 9, 11, 15, 21, 27, 33, 39, 45]\n assert candidate(boxes = \"11100000000000000000000000000000000000001\") == [43, 41, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117]\n assert candidate(boxes = \"110011001100110011001100110011001100\") == [297, 281, 267, 253, 239, 227, 217, 207, 197, 189, 183, 177, 171, 167, 165, 163, 161, 161, 163, 165, 167, 171, 177, 183, 189, 197, 207, 217, 227, 239, 253, 267, 281, 297, 315, 333]\n assert candidate(boxes = \"01010101010101010101010101010101\") == [256, 240, 226, 212, 200, 188, 178, 168, 160, 152, 146, 140, 136, 132, 130, 128, 128, 128, 130, 132, 136, 140, 146, 152, 160, 168, 178, 188, 200, 212, 226, 240]\n assert candidate(boxes = \"11111111111111111111111111111111\") == [496, 466, 438, 412, 388, 366, 346, 328, 312, 298, 286, 276, 268, 262, 258, 256, 256, 258, 262, 268, 276, 286, 298, 312, 328, 346, 366, 388, 412, 438, 466, 496]\n assert candidate(boxes = \"111111111111111111111111111111111111111111111111\") == [1128, 1082, 1038, 996, 956, 918, 882, 848, 816, 786, 758, 732, 708, 686, 666, 648, 632, 618, 606, 596, 588, 582, 578, 576, 576, 578, 582, 588, 596, 606, 618, 632, 648, 666, 686, 708, 732, 758, 786, 816, 848, 882, 918, 956, 996, 1038, 1082, 1128]\n assert candidate(boxes = \"10000001000001\") == [20, 19, 18, 17, 16, 15, 14, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(boxes = \"00000000000000000000000000000000000000000000000000000000000000000000000000000001\") == [79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(boxes = \"10000000000000000000000000000001\") == [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31]\n assert candidate(boxes = \"1000010000100001000010000100001\") == [105, 100, 95, 90, 85, 80, 77, 74, 71, 68, 65, 64, 63, 62, 61, 60, 61, 62, 63, 64, 65, 68, 71, 74, 77, 80, 85, 90, 95, 100, 105]\n assert candidate(boxes = \"111000111000111000111000111000111000\") == [288, 272, 258, 246, 234, 222, 210, 200, 192, 186, 180, 174, 168, 164, 162, 162, 162, 162, 162, 164, 168, 174, 180, 186, 192, 200, 210, 222, 234, 246, 258, 272, 288, 306, 324, 342]\n assert candidate(boxes = \"00000000000000000001111111111111111111\") == [532, 513, 494, 475, 456, 437, 418, 399, 380, 361, 342, 323, 304, 285, 266, 247, 228, 209, 190, 171, 154, 139, 126, 115, 106, 99, 94, 91, 90, 91, 94, 99, 106, 115, 126, 139, 154, 171]\n", "comparison": "exact"}, "public_tests": ["\"110\"", "\"001011\""], "hints": ["If you want to move a ball from box i to box j, you'll need abs(i-j) moves.", "To move all balls to some box, you can move them one by one.", "For each box i, iterate on each ball in a box j, and add abs(i-j) to answers[i]."], "metadata": {"canonical_parameter_names": ["boxes"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:11+00:00", "tests_total": 85, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "string", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minOperations(self, boxes: str) -> list[int]:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "boxes", "type": "str"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1770, "task_id": "maximum-score-from-performing-multiplication-operations", "difficulty": "Hard", "problem_description": "You are given two 0-indexed integer arrays nums and multipliers of size n and m respectively, where n >= m.\n\nYou begin with a score of 0. You want to perform exactly m operations. On the i^th operation (0-indexed) you will:\n\n- Choose one integer x from either the start or the end of the array nums.\n- Add multipliers[i] * x to your score.\n - Note that multipliers[0] corresponds to the first operation, multipliers[1] to the second operation, and so on.\n- Remove x from nums.\n\nReturn the maximum score after performing m operations.\n\nExample 1:\n\nInput: nums = [1,2,3], multipliers = [3,2,1]\nOutput: 14\nExplanation: An optimal solution is as follows:\n- Choose from the end, [1,2,3], adding 3 * 3 = 9 to the score.\n- Choose from the end, [1,2], adding 2 * 2 = 4 to the score.\n- Choose from the end, [1], adding 1 * 1 = 1 to the score.\nThe total score is 9 + 4 + 1 = 14.\n\nExample 2:\n\nInput: nums = [-5,-3,-3,-2,7,1], multipliers = [-10,-5,3,4,6]\nOutput: 102\nExplanation: An optimal solution is as follows:\n- Choose from the start, [-5,-3,-3,-2,7,1], adding -5 * -10 = 50 to the score.\n- Choose from the start, [-3,-3,-2,7,1], adding -3 * -5 = 15 to the score.\n- Choose from the start, [-3,-2,7,1], adding -3 * 3 = -9 to the score.\n- Choose from the end, [-2,7,1], adding 1 * 4 = 4 to the score.\n- Choose from the end, [-2,7], adding 7 * 6 = 42 to the score.\nThe total score is 50 + 15 - 9 + 4 + 42 = 102.\n\nConstraints:\n\n- n == nums.length\n- m == multipliers.length\n- 1 <= m <= 300\n- m <= n <= 10^5\n- -1000 <= nums[i], multipliers[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 385\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],multipliers = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 385\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [10, 9, 8, 7, 6]) == 330\n assert candidate(nums = [-1, -2, -3, -4, -5, -6],multipliers = [-1, -2, -3, -4, -5, -6]) == 91\n assert candidate(nums = [-3, -2, -1, 1, 2, 3],multipliers = [1, -1, 1, -1, 1, -1]) == 12\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],multipliers = [1, 2, 3, 4, 5]) == 101\n assert candidate(nums = [100, 200, 300],multipliers = [1, 2]) == 700\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],multipliers = [9, 8, 7]) == 194\n assert candidate(nums = [5, -2, 5, -3, 5, 5],multipliers = [-1, 1, -1, 1, -1, 1]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [1, 2, 3, 4]) == 80\n assert candidate(nums = [-5, -3, -3, -2, 7, 1],multipliers = [-10, -5, 3, 4, 6]) == 102\n assert candidate(nums = [1],multipliers = [1]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5],multipliers = [-1, -2, -3]) == 23\n assert candidate(nums = [-1, -2, -3, -4, -5],multipliers = [1, 2, 3, 4, 5]) == -35\n assert candidate(nums = [10, 20, 30, 40, 50],multipliers = [5, 4, 3, 2, 1]) == 550\n assert candidate(nums = [10, 20, 30, 40, 50],multipliers = [1, 2, 3, 4, 5]) == 550\n assert candidate(nums = [1, 2, 3, 4, 5, 6],multipliers = [1, 2, 3]) == 28\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],multipliers = [1, 2, 3, 4]) == 71\n assert candidate(nums = [1, 2, 3],multipliers = [3, 2, 1]) == 14\n assert candidate(nums = [9, 8, 7, 6, 5],multipliers = [-1, -2, -3]) == -37\n assert candidate(nums = [-1, -2, -3, -4, -5],multipliers = [-1, -2, -3, -4, -5]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5],multipliers = [1, 2, 3]) == 23\n assert candidate(nums = [5, 7, 3, 8, 6],multipliers = [3, 2, 4]) == 60\n assert candidate(nums = [5, 3, 8, 4, 9, 2, 7, 1, 6, 0],multipliers = [10, -20, 30, -40, 50]) == 540\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],multipliers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == -10\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],multipliers = [10, -20, 30, -40, 50]) == 115000\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12],multipliers = [10, 9, 8, 7, 6, 5]) == 105\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 38500\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250],multipliers = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55250\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [5, 3, 8, 1, 6, 9, 2, 7, 4, 10],multipliers = [-1, 2, -3, 4, -5, 6]) == 75\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],multipliers = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 75\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],multipliers = [10, -9, 8, -7, 6, -5, 4, -3, 2, -1]) == 205\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],multipliers = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == -5550\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],multipliers = [-1, -2, -3, -4, -5]) == 185\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],multipliers = [-1, 1, -1, 1, -1, 1]) == 6000\n assert candidate(nums = [5, -3, 8, 2, -7, 6, 1, 4, -9, 11],multipliers = [3, -2, 7, 5, -8, 6]) == 234\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 21250\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [5, 4, 3, 2, 1]) == -350\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],multipliers = [10, -20, 30, -40, 50]) == 115000\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -220\n assert candidate(nums = [-100, -200, -300, 400, 500, 600, -700, 800, -900],multipliers = [10, 20, 30, 40, 50, 60, 70]) == 77000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],multipliers = [-1, -1, -1, -1, -1]) == -5\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],multipliers = [1, 2, 3, 4, 5, 6, 7]) == 52\n assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500],multipliers = [1, -1, 1, -1, 1, -1]) == 2400\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],multipliers = [1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],multipliers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 800\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],multipliers = [1, -1, 1, -1, 1]) == 240\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],multipliers = [5, 10, 15, 20, 25]) == 925\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],multipliers = [29, 27, 25, 23, 21]) == 3165\n assert candidate(nums = [5, 3, 8, 10, 15, 1, 4, 7],multipliers = [10, 20, 30, 40, 50]) == 1500\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],multipliers = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == -30500\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],multipliers = [-1, 2, -3, 4, -5]) == 110\n assert candidate(nums = [5, 2, 1, 4, 3],multipliers = [-1, -2, -3]) == -12\n assert candidate(nums = [500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, 1000, 900, 800, 700],multipliers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 35400\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == -22000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 2485\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [10, 20, 30, 40, 50]) == -5000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],multipliers = [-10, 9, -8, 7, -6, 5, -4, 3, -2, 1]) == 480\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10],multipliers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 85\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],multipliers = [10, 20, 30, 40, 50]) == 2150\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -22000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],multipliers = [1, -1, 1, -1, 1, -1, 1]) == 48\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],multipliers = [-5, 10, -15, 20, -25, 30]) == 4625\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 155\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],multipliers = [15, 14, 13, 12, 11]) == 855\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50],multipliers = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 300\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [20, 19, 18, 17, 16, 15, 14]) == 2051\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],multipliers = [1, 2, 3, 4, 5, 6]) == 15300\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700],multipliers = [1, -2, 3, -4, 5]) == 7500\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],multipliers = [1, 2, -3, 4, -5]) == 1030\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],multipliers = [100, -50, 25, -12, 6]) == 9630\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 821\n assert candidate(nums = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 1925\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],multipliers = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 200\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],multipliers = [1, 2, 3, 4, 5]) == 7000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],multipliers = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 700\n assert candidate(nums = [-5, 3, -1, 2, -4, 6, -7, 8, -9, 10],multipliers = [1, -1, 1, -1, 1, -1]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2670\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -8\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],multipliers = [1, -1, 2, -2, 3]) == 4700\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [1, 2, 3, 4, 5, 6]) == 161\n assert candidate(nums = [5, 1, 4, 3, 2, 6, 7, 8, 9, 10],multipliers = [10, -10, 20, -20, 30]) == 450\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],multipliers = [1, -1, 1, -1, 1, -1]) == 4100\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 26800\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 0\n assert candidate(nums = [5, 3, 8, -2, 6, 7, -4, 10, 15, -20],multipliers = [1, 2, 3, 4, 5, 6, 7, 8]) == 242\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 75\n assert candidate(nums = [300, -100, 200, -200, 500, -300, 400, -400, 600, -500],multipliers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 61000\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],multipliers = [-30, -29, -28, -27, -26, -25, -24, -23, -22, -21]) == -1320\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [2, -3, 4, -5, 6]) == 211\n assert candidate(nums = [50, 25, 75, 100, -50, -25, -75, -100, 200, 150, 175, 200],multipliers = [10, -5, 2, -1, 3, -2]) == 2750\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],multipliers = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == -220\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 3850\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],multipliers = [-1, -2, -3, -4, -5]) == -550\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],multipliers = [-1, 1, -1, 1, -1, 1, -1, 1]) == 50\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],multipliers = [5, -5, 4, -4, 3, -3]) == 87\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -334\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],multipliers = [100, -100, 100, -100, 100]) == 500000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],multipliers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == -120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1081\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1540\n assert candidate(nums = [5, 3, 8, -2, 6, 7, -4, 10],multipliers = [1, 2, 3, 4, 5]) == 77\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],multipliers = [1, 2, 3, 4, 5]) == 1850\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 54666\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [-1, -2, -3, -4, -5]) == 1150\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100],multipliers = [1, 2, 3, 4, 5]) == 600\n", "comparison": "exact"}, "public_tests": ["[1,2,3]\n[3,2,1]", "[-5,-3,-3,-2,7,1]\n[-10,-5,3,4,6]"], "hints": ["At first glance, the solution seems to be greedy, but if you try to greedily take the largest value from the beginning or the end, this will not be optimal.", "You should try all scenarios but this will be costly.", "Memoizing the pre-visited states while trying all the possible scenarios will reduce the complexity, and hence dp is a perfect choice here."], "metadata": {"canonical_parameter_names": ["nums", "multipliers"], "leetcode_dataset_entry_point": "Solution().maximumScore", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:13+00:00", "tests_total": 118, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def maximumScore(self, nums: list[int], multipliers: list[int]) -> int:", "container": "Solution", "callable": "maximumScore", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "multipliers", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1771, "task_id": "maximize-palindrome-length-from-subsequences", "difficulty": "Hard", "problem_description": "You are given two strings, word1 and word2. You want to construct a string in the following manner:\n\n- Choose some non-empty subsequence subsequence1 from word1.\n- Choose some non-empty subsequence subsequence2 from word2.\n- Concatenate the subsequences: subsequence1 + subsequence2, to make the string.\n\nReturn the length of the longest palindrome that can be constructed in the described manner. If no palindromes can be constructed, return 0.\n\nA subsequence of a string s is a string that can be made by deleting some (possibly none) characters from s without changing the order of the remaining characters.\n\nA palindrome is a string that reads the same forward as well as backward.\n\nExample 1:\n\nInput: word1 = \"cacb\", word2 = \"cbba\"\nOutput: 5\nExplanation: Choose \"ab\" from word1 and \"cba\" from word2 to make \"abcba\", which is a palindrome.\n\nExample 2:\n\nInput: word1 = \"ab\", word2 = \"ab\"\nOutput: 3\nExplanation: Choose \"ab\" from word1 and \"a\" from word2 to make \"aba\", which is a palindrome.\n\nExample 3:\n\nInput: word1 = \"aa\", word2 = \"bb\"\nOutput: 0\nExplanation: You cannot construct a palindrome from the described method, so return 0.\n\nConstraints:\n\n- 1 <= word1.length, word2.length <= 1000\n- word1 and word2 consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"race\",word2 = \"car\") == 7\n assert candidate(word1 = \"a\",word2 = \"a\") == 2\n assert candidate(word1 = \"aabb\",word2 = \"bbcc\") == 4\n assert candidate(word1 = \"race\",word2 = \"care\") == 7\n assert candidate(word1 = \"abcde\",word2 = \"edcba\") == 10\n assert candidate(word1 = \"madam\",word2 = \"madam\") == 10\n assert candidate(word1 = \"aabb\",word2 = \"bbaa\") == 8\n assert candidate(word1 = \"xyz\",word2 = \"zyx\") == 6\n assert candidate(word1 = \"palindrome\",word2 = \"emordnilap\") == 20\n assert candidate(word1 = \"abcabc\",word2 = \"cbacba\") == 12\n assert candidate(word1 = \"aa\",word2 = \"bb\") == 0\n assert candidate(word1 = \"hello\",word2 = \"world\") == 5\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxcba\") == 12\n assert candidate(word1 = \"cacb\",word2 = \"cbba\") == 5\n assert candidate(word1 = \"mnop\",word2 = \"pqrs\") == 2\n assert candidate(word1 = \"noon\",word2 = \"noon\") == 8\n assert candidate(word1 = \"level\",word2 = \"deified\") == 5\n assert candidate(word1 = \"a\",word2 = \"b\") == 0\n assert candidate(word1 = \"noon\",word2 = \"moon\") == 7\n assert candidate(word1 = \"abcba\",word2 = \"abcba\") == 10\n assert candidate(word1 = \"abcd\",word2 = \"dcba\") == 8\n assert candidate(word1 = \"abc\",word2 = \"def\") == 0\n assert candidate(word1 = \"ab\",word2 = \"ab\") == 3\n assert candidate(word1 = \"xyzzxyzzxyzz\",word2 = \"zzzyzxzzzyzxzzzyx\") == 25\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == 52\n assert candidate(word1 = \"abacax\",word2 = \"xcabab\") == 10\n assert candidate(word1 = \"deeee\",word2 = \"eee\") == 7\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcbajihgfedcba\") == 21\n assert candidate(word1 = \"madam\",word2 = \"rotor\") == 0\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"ffeeddccbbaa\") == 24\n assert candidate(word1 = \"level\",word2 = \"leve\") == 8\n assert candidate(word1 = \"palindrome\",word2 = \"emordnilapracecar\") == 20\n assert candidate(word1 = \"longestpalindrome\",word2 = \"emordnilapstgnol\") == 30\n assert candidate(word1 = \"racecar\",word2 = \"level\") == 3\n assert candidate(word1 = \"aabbaa\",word2 = \"ccddeee\") == 0\n assert candidate(word1 = \"abc\",word2 = \"cba\") == 6\n assert candidate(word1 = \"xyzzyx\",word2 = \"zyxzyz\") == 7\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxcdb\") == 10\n assert candidate(word1 = \"xyx\",word2 = \"xyx\") == 6\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcba\") == 20\n assert candidate(word1 = \"racecar\",word2 = \"racecar\") == 14\n assert candidate(word1 = \"b\",word2 = \"b\") == 2\n assert candidate(word1 = \"abcdefgh\",word2 = \"hgfedcba\") == 16\n assert candidate(word1 = \"level\",word2 = \"level\") == 10\n assert candidate(word1 = \"aabbccddeeffgg\",word2 = \"ggffeeddccbbaa\") == 28\n assert candidate(word1 = \"aabaaa\",word2 = \"aaabaa\") == 12\n assert candidate(word1 = \"abacaxaba\",word2 = \"xyzzyx\") == 6\n assert candidate(word1 = \"abcdefg\",word2 = \"gfedcba\") == 14\n assert candidate(word1 = \"uniqueletters\",word2 = \"stretteleunik\") == 20\n assert candidate(word1 = \"aaa\",word2 = \"bbb\") == 0\n assert candidate(word1 = \"abcxyz\",word2 = \"zyxcba\") == 12\n assert candidate(word1 = \"abacdfgdcaba\",word2 = \"abacdfgdcaba\") == 22\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"dcbaabcdabcd\") == 14\n assert candidate(word1 = \"aabbaa\",word2 = \"aaabba\") == 11\n assert candidate(word1 = \"aabbccdd\",word2 = \"ddccbbaa\") == 16\n assert candidate(word1 = \"aaaaaa\",word2 = \"bbbbbb\") == 0\n assert candidate(word1 = \"ababababab\",word2 = \"bababababa\") == 20\n assert candidate(word1 = \"step\",word2 = \"onests\") == 7\n assert candidate(word1 = \"abcd\",word2 = \"zyxw\") == 0\n assert candidate(word1 = \"ababab\",word2 = \"bababa\") == 12\n assert candidate(word1 = \"abacaba\",word2 = \"bcbcbcb\") == 9\n assert candidate(word1 = \"palindromeconstruction\",word2 = \"noitcitsnocemordnilap\") == 40\n assert candidate(word1 = \"abcd\",word2 = \"dcbaabcd\") == 8\n assert candidate(word1 = \"racecar\",word2 = \"car\") == 7\n assert candidate(word1 = \"deified\",word2 = \"deified\") == 14\n assert candidate(word1 = \"abcdefg\",word2 = \"hgfedcba\") == 15\n assert candidate(word1 = \"complexstring\",word2 = \"gnirtsxlpmoc\") == 24\n assert candidate(word1 = \"noonnoon\",word2 = \"noonnoon\") == 16\n assert candidate(word1 = \"thisisatest\",word2 = \"tsetasitisth\") == 18\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxwvut\") == 6\n assert candidate(word1 = \"mnopqr\",word2 = \"rstuvw\") == 2\n assert candidate(word1 = \"racecar\",word2 = \"carrace\") == 9\n assert candidate(word1 = \"aabbccdd\",word2 = \"aabbccdd\") == 6\n assert candidate(word1 = \"abababa\",word2 = \"bababab\") == 13\n assert candidate(word1 = \"aaaaabbbbb\",word2 = \"bbbbbbaaaa\") == 19\n assert candidate(word1 = \"xyzz\",word2 = \"zzxy\") == 6\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"cbacbacbacba\") == 24\n assert candidate(word1 = \"ab\",word2 = \"bbaa\") == 5\n assert candidate(word1 = \"qwertyuiop\",word2 = \"poiuytrewq\") == 20\n assert candidate(word1 = \"aaaaabbbbb\",word2 = \"bbbbbbaaaaa\") == 21\n assert candidate(word1 = \"zzzz\",word2 = \"zzzz\") == 8\n assert candidate(word1 = \"xyx\",word2 = \"yxy\") == 5\n assert candidate(word1 = \"repaper\",word2 = \"repaper\") == 14\n assert candidate(word1 = \"reviled\",word2 = \"devil\") == 6\n assert candidate(word1 = \"abcdef\",word2 = \"fedcbaxyz\") == 12\n assert candidate(word1 = \"mississippi\",word2 = \"ississippim\") == 18\n assert candidate(word1 = \"abcdabc\",word2 = \"cbadcbad\") == 14\n assert candidate(word1 = \"rotor\",word2 = \"rotor\") == 10\n assert candidate(word1 = \"abcdabc\",word2 = \"cbadacb\") == 12\n assert candidate(word1 = \"zyxwvutsrqponmlkjihgfedcba\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == 52\n assert candidate(word1 = \"aabbccddeeffgg\",word2 = \"ggffeeddccbaa\") == 26\n assert candidate(word1 = \"xxyyzz\",word2 = \"zzxyyx\") == 10\n assert candidate(word1 = \"xyzyx\",word2 = \"xzyyx\") == 8\n assert candidate(word1 = \"aabbcc\",word2 = \"ccbbaa\") == 12\n assert candidate(word1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",word2 = \"sinoconiovacolcosilicropicoviscounmoneup\") == 49\n assert candidate(word1 = \"aaaabbbb\",word2 = \"bbbbcccc\") == 8\n assert candidate(word1 = \"pqrstu\",word2 = \"utsrqp\") == 12\n assert candidate(word1 = \"mamad\",word2 = \"adam\") == 7\n assert candidate(word1 = \"abcabcabc\",word2 = \"cbacbacba\") == 18\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"abacabadabacaba\") == 30\n assert candidate(word1 = \"refer\",word2 = \"refer\") == 10\n assert candidate(word1 = \"redder\",word2 = \"redder\") == 12\n assert candidate(word1 = \"abacdfgdcaba\",word2 = \"gfdcbba\") == 15\n assert candidate(word1 = \"abcdefghijk\",word2 = \"kjihgfedcba\") == 22\n assert candidate(word1 = \"mnopqr\",word2 = \"rqponm\") == 12\n assert candidate(word1 = \"aabbaa\",word2 = \"bbccbb\") == 6\n assert candidate(word1 = \"thisisaverylongwordtoseetifthelongestpalindrome\",word2 = \"emordnilapelongethtofeesavaloydnevasiht\") == 58\n assert candidate(word1 = \"xyzzxy\",word2 = \"zyxzyxzyx\") == 13\n assert candidate(word1 = \"overlappingword\",word2 = \"drowgnalppero\") == 20\n assert candidate(word1 = \"ab\",word2 = \"ba\") == 4\n assert candidate(word1 = \"zxcvbnmasdfghjkl\",word2 = \"lkjhgfdsamnbvcxz\") == 32\n assert candidate(word1 = \"aaaaa\",word2 = \"bbbbb\") == 0\n assert candidate(word1 = \"racecar\",word2 = \"civic\") == 5\n assert candidate(word1 = \"abcdef\",word2 = \"fedcba\") == 12\n assert candidate(word1 = \"pqr\",word2 = \"rstuv\") == 2\n assert candidate(word1 = \"xyz\",word2 = \"zyxcba\") == 6\n assert candidate(word1 = \"c\",word2 = \"c\") == 2\n assert candidate(word1 = \"abcabcabcabcabc\",word2 = \"cbacbacbacbacba\") == 30\n", "comparison": "exact"}, "public_tests": ["\"cacb\"\n\"cbba\"", "\"ab\"\n\"ab\"", "\"aa\"\n\"bb\""], "hints": ["Let's ignore the non-empty subsequence constraint. We can concatenate the two strings and find the largest palindromic subsequence with dynamic programming.", "Iterate through every pair of characters word1[i] and word2[j], and see if some palindrome begins with word1[i] and ends with word2[j]. This ensures that the subsequences are non-empty."], "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().longestPalindrome", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:16+00:00", "tests_total": 120, "tests_dropped": 2, "flags": [], "topic_tags": ["string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def longestPalindrome(self, word1: str, word2: str) -> int:", "container": "Solution", "callable": "longestPalindrome", "parameters": [{"name": "word1", "type": "str"}, {"name": "word2", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1773, "task_id": "count-items-matching-a-rule", "difficulty": "Easy", "problem_description": "You are given an array items, where each items[i] = [type_i, color_i, name_i] describes the type, color, and name of the i^th item. You are also given a rule represented by two strings, ruleKey and ruleValue.\n\nThe i^th item is said to match the rule if one of the following is true:\n\n- ruleKey == \"type\" and ruleValue == type_i.\n- ruleKey == \"color\" and ruleValue == color_i.\n- ruleKey == \"name\" and ruleValue == name_i.\n\nReturn the number of items that match the given rule.\n\nExample 1:\n\nInput: items = [[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"lenovo\"],[\"phone\",\"gold\",\"iphone\"]], ruleKey = \"color\", ruleValue = \"silver\"\nOutput: 1\nExplanation: There is only one item matching the given rule, which is [\"computer\",\"silver\",\"lenovo\"].\n\nExample 2:\n\nInput: items = [[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"phone\"],[\"phone\",\"gold\",\"iphone\"]], ruleKey = \"type\", ruleValue = \"phone\"\nOutput: 2\nExplanation: There are only two items matching the given rule, which are [\"phone\",\"blue\",\"pixel\"] and [\"phone\",\"gold\",\"iphone\"]. Note that the item [\"computer\",\"silver\",\"phone\"] does not match.\n\nConstraints:\n\n- 1 <= items.length <= 10^4\n- 1 <= type_i.length, color_i.length, name_i.length, ruleValue.length <= 10\n- ruleKey is equal to either \"type\", \"color\", or \"name\".\n- All strings consist only of lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'harley'], ['car', 'green', 'lambo']],ruleKey = \"color\",ruleValue = \"red\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'phone'], ['phone', 'gold', 'iphone']],ruleKey = \"type\",ruleValue = \"phone\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['phone', 'black', 'samsung'], ['tablet', 'black', 'ipad']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['phone', 'white', 'samsung'], ['tablet', 'gray', 'apple']],ruleKey = \"name\",ruleValue = \"apple\") == 1\n assert candidate(items = [['laptop', 'black', 'dell'], ['tablet', 'white', 'samsung'], ['laptop', 'silver', 'macbook']],ruleKey = \"name\",ruleValue = \"dell\") == 1\n assert candidate(items = [['shoe', 'white', 'nike'], ['shirt', 'black', 'adidas'], ['shoe', 'black', 'puma']],ruleKey = \"type\",ruleValue = \"shoe\") == 2\n assert candidate(items = [['book', 'red', 'novel'], ['pen', 'blue', 'ballpoint'], ['notebook', 'red', 'blank']],ruleKey = \"name\",ruleValue = \"blank\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone']],ruleKey = \"color\",ruleValue = \"silver\") == 1\n assert candidate(items = [['laptop', 'black', 'dell'], ['laptop', 'gray', 'hp'], ['desktop', 'black', 'asus']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['book', 'brown', 'alice'], ['pen', 'blue', 'bic'], ['notebook', 'white', 'staples']],ruleKey = \"type\",ruleValue = \"book\") == 1\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'red', 'yamaha'], ['truck', 'blue', 'ford']],ruleKey = \"type\",ruleValue = \"red\") == 0\n assert candidate(items = [['book', 'red', 'novel'], ['pen', 'blue', 'ballpoint'], ['book', 'brown', 'textbook']],ruleKey = \"type\",ruleValue = \"book\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['camera', 'black', 'canon'], ['camera', 'silver', 'nikon'], ['camera', 'black', 'sony'], ['camera', 'gold', 'fujifilm'], ['camera', 'black', 'olympus']],ruleKey = \"name\",ruleValue = \"sony\") == 1\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'blue', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'black', 'apple'], ['smartphone', 'red', 'motorola']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['toys', 'yellow', 'balloon'], ['toys', 'red', 'car'], ['toys', 'blue', 'doll'], ['toys', 'green', 'teddy'], ['toys', 'yellow', 'block']],ruleKey = \"color\",ruleValue = \"yellow\") == 2\n assert candidate(items = [['computer', 'silver', 'dell'], ['computer', 'black', 'apple'], ['computer', 'silver', 'hp'], ['computer', 'black', 'asus'], ['computer', 'silver', 'lenovo'], ['computer', 'black', 'microsoft']],ruleKey = \"color\",ruleValue = \"silver\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'blue', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'black', 'apple'], ['laptop', 'gray', 'hp']],ruleKey = \"type\",ruleValue = \"laptop\") == 2\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shoes', 'blue', 'puma'], ['hat', 'blue', 'reebok'], ['shirt', 'blue', 'nike']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['chair', 'brown', 'ikea'], ['table', 'white', 'ikea'], ['couch', 'gray', 'ikea'], ['desk', 'black', 'ikea'], ['lamp', 'silver', 'ikea']],ruleKey = \"brand\",ruleValue = \"ikea\") == 5\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp']],ruleKey = \"type\",ruleValue = \"laptop\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp'], ['laptop', 'black', 'macbook']],ruleKey = \"type\",ruleValue = \"laptop\") == 3\n assert candidate(items = [['book', 'blue', 'fiction'], ['book', 'red', 'nonfiction'], ['book', 'blue', 'science'], ['book', 'green', 'history'], ['book', 'blue', 'fantasy']],ruleKey = \"name\",ruleValue = \"nonfiction\") == 1\n assert candidate(items = [['chair', 'white', 'ikea'], ['sofa', 'brown', 'ikea'], ['table', 'brown', 'ikea'], ['lamp', 'white', 'ikea'], ['shelf', 'brown', 'ikea'], ['cabinet', 'white', 'ikea']],ruleKey = \"type\",ruleValue = \"ikea\") == 0\n assert candidate(items = [['apparel', 'black', 'jacket'], ['apparel', 'white', 'shirt'], ['apparel', 'red', 'pants'], ['apparel', 'blue', 'hat']],ruleKey = \"type\",ruleValue = \"apparel\") == 4\n assert candidate(items = [['camera', 'black', 'nikon'], ['camera', 'silver', 'canon'], ['camera', 'gold', 'leica'], ['camera', 'black', 'olympus'], ['camera', 'white', 'fujifilm']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['toy', 'green', 'car'], ['toy', 'red', 'doll'], ['toy', 'blue', 'block'], ['toy', 'green', 'train'], ['toy', 'red', 'helicopter'], ['toy', 'blue', 'truck']],ruleKey = \"type\",ruleValue = \"toy\") == 6\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone'], ['tablet', 'black', 'samsung'], ['smartwatch', 'black', 'fitbit'], ['laptop', 'blue', 'macbook']],ruleKey = \"color\",ruleValue = \"blue\") == 2\n assert candidate(items = [['smartphone', 'red', 'iphone'], ['smartphone', 'black', 'galaxy'], ['smartphone', 'white', 'nokia'], ['smartphone', 'black', 'oneplus'], ['smartphone', 'red', 'motorola'], ['smartphone', 'blue', 'huawei'], ['smartphone', 'red', 'oppo'], ['smartphone', 'green', 'realme']],ruleKey = \"name\",ruleValue = \"red\") == 0\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp'], ['laptop', 'black', 'macbook'], ['laptop', 'gray', 'asus']],ruleKey = \"name\",ruleValue = \"laptop\") == 0\n assert candidate(items = [['house', 'white', 'mansions'], ['house', 'blue', 'cottages'], ['apartment', 'gray', 'flats'], ['condo', 'white', 'duplex'], ['townhouse', 'blue', 'terraced'], ['house', 'white', 'bungalows'], ['apartment', 'gray', 'penthouse'], ['condo', 'blue', 'villa'], ['townhouse', 'white', 'villas'], ['house', 'gray', 'detached']],ruleKey = \"type\",ruleValue = \"house\") == 4\n assert candidate(items = [['smartphone', 'red', 'iphone'], ['smartphone', 'black', 'galaxy'], ['smartphone', 'white', 'nokia'], ['smartphone', 'black', 'oneplus'], ['smartphone', 'red', 'motorola']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shirt', 'blue', 'reebok']],ruleKey = \"color\",ruleValue = \"blue\") == 5\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'red', 'adidas'], ['hat', 'blue', 'reebok'], ['jacket', 'green', 'nike'], ['shoes', 'black', 'puma']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['television', 'black', 'samsung'], ['television', 'silver', 'lg'], ['television', 'gray', 'tcl'], ['television', 'black', 'sony'], ['television', 'red', 'panasonic']],ruleKey = \"type\",ruleValue = \"television\") == 5\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas']],ruleKey = \"name\",ruleValue = \"nike\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone'], ['tv', 'black', 'samsung'], ['monitor', 'silver', 'dell'], ['laptop', 'gray', 'hp'], ['phone', 'black', 'nokia'], ['tablet', 'gold', 'ipad']],ruleKey = \"type\",ruleValue = \"phone\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp']],ruleKey = \"name\",ruleValue = \"dell\") == 1\n assert candidate(items = [['tv', 'black', 'samsung'], ['tv', 'white', 'lg'], ['tv', 'silver', 'sony'], ['tv', 'black', 'toshiba'], ['tv', 'white', 'vizio']],ruleKey = \"color\",ruleValue = \"white\") == 2\n assert candidate(items = [['toy', 'red', 'car'], ['toy', 'blue', 'doll'], ['toy', 'green', 'car'], ['toy', 'red', 'ball'], ['toy', 'green', 'doll'], ['toy', 'blue', 'ball']],ruleKey = \"name\",ruleValue = \"car\") == 2\n assert candidate(items = [['clothing', 'blue', 'shirt'], ['clothing', 'red', 't-shirt'], ['clothing', 'blue', 'jeans'], ['clothing', 'green', 'pants'], ['clothing', 'blue', 'jacket'], ['clothing', 'yellow', 'shorts'], ['clothing', 'blue', 'hat']],ruleKey = \"color\",ruleValue = \"blue\") == 4\n assert candidate(items = [['chair', 'brown', 'leather'], ['table', 'white', 'wood'], ['lamp', 'black', 'glass'], ['sofa', 'gray', 'cotton'], ['rug', 'blue', 'carpet'], ['cabinet', 'black', 'oak'], ['bed', 'white', 'sheets'], ['mirror', 'silver', 'frame'], ['shelf', 'black', 'metal']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['shirt', 'white', 'nike'], ['pants', 'blue', 'adidas'], ['shoes', 'black', 'puma'], ['hat', 'white', 'reebok'], ['socks', 'blue', 'nike']],ruleKey = \"color\",ruleValue = \"blue\") == 2\n assert candidate(items = [['couch', 'brown', 'sofa'], ['chair', 'black', 'office'], ['table', 'brown', 'dining'], ['lamp', 'black', 'reading'], ['cabinet', 'brown', 'kitchen']],ruleKey = \"color\",ruleValue = \"brown\") == 3\n assert candidate(items = [['keyboard', 'black', 'logitech'], ['keyboard', 'white', 'razer'], ['keyboard', 'blue', 'corsair'], ['keyboard', 'black', 'microsoft'], ['keyboard', 'black', 'filco']],ruleKey = \"type\",ruleValue = \"keyboard\") == 5\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shoes', 'black', 'reebok'], ['hat', 'red', 'nike'], ['jacket', 'blue', 'puma'], ['watch', 'silver', 'rolex'], ['belt', 'brown', 'gucci']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['laptop', 'gray', 'hp'], ['desktop', 'black', 'asus'], ['monitor', 'black', 'dell'], ['laptop', 'silver', 'lenovo']],ruleKey = \"type\",ruleValue = \"laptop\") == 3\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas']],ruleKey = \"color\",ruleValue = \"blue\") == 4\n assert candidate(items = [['camera', 'black', 'canon'], ['smartphone', 'white', 'iphone'], ['tablet', 'gold', 'ipad'], ['smartwatch', 'black', 'applewatch'], ['laptop', 'silver', 'macbook']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['furniture', 'brown', 'table'], ['furniture', 'white', 'sofa'], ['furniture', 'brown', 'chair'], ['furniture', 'black', 'cabinet'], ['furniture', 'white', 'lamp'], ['furniture', 'brown', 'dresser']],ruleKey = \"color\",ruleValue = \"brown\") == 3\n assert candidate(items = [['computer', 'black', 'macbook'], ['smartwatch', 'silver', 'apple'], ['tablet', 'white', 'samsung'], ['laptop', 'blue', 'dell'], ['desktop', 'black', 'asus'], ['computer', 'silver', 'lenovo'], ['smartwatch', 'white', 'fitbit'], ['tablet', 'black', 'xiaomi']],ruleKey = \"color\",ruleValue = \"white\") == 2\n assert candidate(items = [['camera', 'black', 'canon'], ['camera', 'silver', 'nikon'], ['lens', 'black', 'canon'], ['camera', 'white', 'sony'], ['tripod', 'gray', 'benro'], ['camera', 'black', 'fujifilm']],ruleKey = \"brand\",ruleValue = \"canon\") == 2\n assert candidate(items = [['headphones', 'black', 'sony'], ['headphones', 'black', 'apple'], ['headphones', 'black', 'sennheiser'], ['headphones', 'black', 'bose'], ['headphones', 'black', 'jaybird']],ruleKey = \"color\",ruleValue = \"black\") == 5\n assert candidate(items = [['toy', 'red', 'car'], ['toy', 'blue', 'doll'], ['toy', 'red', 'truck'], ['toy', 'yellow', 'balloon'], ['toy', 'blue', 'teddybear'], ['toy', 'red', 'firetruck']],ruleKey = \"type\",ruleValue = \"toy\") == 6\n assert candidate(items = [['camera', 'black', 'nikon'], ['phone', 'black', 'iphone'], ['tablet', 'black', 'ipad'], ['smartwatch', 'black', 'applewatch'], ['laptop', 'black', 'macbook']],ruleKey = \"color\",ruleValue = \"black\") == 5\n assert candidate(items = [['sneakers', 'white', 'nike'], ['tshirt', 'blue', 'adidas'], ['jeans', 'black', 'puma'], ['hat', 'red', 'nike'], ['pants', 'blue', 'reebok']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['computer', 'black', 'macbook'], ['smartwatch', 'silver', 'apple'], ['tablet', 'white', 'samsung'], ['laptop', 'blue', 'dell'], ['desktop', 'black', 'asus']],ruleKey = \"type\",ruleValue = \"computer\") == 1\n assert candidate(items = [['monitor', 'black', 'asus'], ['monitor', 'white', 'dell'], ['monitor', 'blue', 'benq'], ['monitor', 'silver', 'acer'], ['monitor', 'black', 'lg']],ruleKey = \"type\",ruleValue = \"monitor\") == 5\n assert candidate(items = [['smartphone', 'black', 'samsung'], ['smartphone', 'blue', 'iphone'], ['smartphone', 'black', 'google'], ['smartphone', 'red', 'oneplus'], ['smartphone', 'black', 'zte']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['shirt', 'black', 'nike'], ['jeans', 'blue', 'levis'], ['jacket', 'brown', 'adidas'], ['shoes', 'white', 'nike'], ['hat', 'black', 'nike'], ['socks', 'blue', 'addidas'], ['gloves', 'brown', 'adidas'], ['shorts', 'white', 'levis']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartphone', 'blue', 'huawei'], ['laptop', 'red', 'macbook']],ruleKey = \"type\",ruleValue = \"smartphone\") == 2\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone'], ['phone', 'black', 'samsung'], ['laptop', 'gray', 'hp'], ['tablet', 'silver', 'ipad']],ruleKey = \"type\",ruleValue = \"phone\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['laptop', 'gray', 'hp'], ['desktop', 'black', 'asus'], ['laptop', 'black', 'lenovo'], ['desktop', 'black', 'acer']],ruleKey = \"color\",ruleValue = \"black\") == 4\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shirt', 'blue', 'reebok'], ['shirt', 'blue', 'puma']],ruleKey = \"name\",ruleValue = \"blue\") == 0\n assert candidate(items = [['tv', 'black', 'samsung'], ['fridge', 'white', 'lg'], ['microwave', 'black', 'whirlpool'], ['stove', 'black', 'bosch']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['phone', 'blue', 'pixel'], ['phone', 'blue', 'galaxy'], ['phone', 'blue', 'nokia'], ['phone', 'blue', 'oneplus'], ['phone', 'blue', 'google'], ['phone', 'blue', 'xiaomi'], ['phone', 'blue', 'htc']],ruleKey = \"name\",ruleValue = \"google\") == 1\n assert candidate(items = [['smartwatch', 'silver', 'apple'], ['smartwatch', 'gold', 'rolex'], ['bracelet', 'silver', 'tissot'], ['pendant', 'gold', 'omega'], ['bracelet', 'silver', 'casio']],ruleKey = \"name\",ruleValue = \"silver\") == 0\n", "comparison": "exact"}, "public_tests": ["[[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"lenovo\"],[\"phone\",\"gold\",\"iphone\"]]\n\"color\"\n\"silver\"", "[[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"phone\"],[\"phone\",\"gold\",\"iphone\"]]\n\"type\"\n\"phone\""], "hints": ["Iterate on each item, and check if each one matches the rule according to the statement."], "metadata": {"canonical_parameter_names": ["items", "ruleKey", "ruleValue"], "leetcode_dataset_entry_point": "Solution().countMatches", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:20+00:00", "tests_total": 108, "tests_dropped": 41, "flags": [], "topic_tags": ["array", "string"]}, "language": "python", "interface": {"raw_signature": "def countMatches(self, items: list[list[str]], ruleKey: str, ruleValue: str) -> int:", "container": "Solution", "callable": "countMatches", "parameters": [{"name": "items", "type": "list[list[str]]"}, {"name": "ruleKey", "type": "str"}, {"name": "ruleValue", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1774, "task_id": "closest-dessert-cost", "difficulty": "Medium", "problem_description": "You would like to make dessert and are preparing to buy the ingredients. You have n ice cream base flavors and m types of toppings to choose from. You must follow these rules when making your dessert:\n\n- There must be exactly one ice cream base.\n- You can add one or more types of topping or have no toppings at all.\n- There are at most two of each type of topping.\n\nYou are given three inputs:\n\n- baseCosts, an integer array of length n, where each baseCosts[i] represents the price of the i^th ice cream base flavor.\n- toppingCosts, an integer array of length m, where each toppingCosts[i] is the price of one of the i^th topping.\n- target, an integer representing your target price for dessert.\n\nYou want to make a dessert with a total cost as close to target as possible.\n\nReturn the closest possible cost of the dessert to target. If there are multiple, return the lower one.\n\nExample 1:\n\nInput: baseCosts = [1,7], toppingCosts = [3,4], target = 10\nOutput: 10\nExplanation: Consider the following combination (all 0-indexed):\n- Choose base 1: cost 7\n- Take 1 of topping 0: cost 1 x 3 = 3\n- Take 0 of topping 1: cost 0 x 4 = 0\nTotal: 7 + 3 + 0 = 10.\n\nExample 2:\n\nInput: baseCosts = [2,3], toppingCosts = [4,5,100], target = 18\nOutput: 17\nExplanation: Consider the following combination (all 0-indexed):\n- Choose base 1: cost 3\n- Take 1 of topping 0: cost 1 x 4 = 4\n- Take 2 of topping 1: cost 2 x 5 = 10\n- Take 0 of topping 2: cost 0 x 100 = 0\nTotal: 3 + 4 + 10 + 0 = 17. You cannot make a dessert with a total cost of 18.\n\nExample 3:\n\nInput: baseCosts = [3,10], toppingCosts = [2,5], target = 9\nOutput: 8\nExplanation: It is possible to make desserts with cost 8 and 10. Return 8 as it is the lower cost.\n\nConstraints:\n\n- n == baseCosts.length\n- m == toppingCosts.length\n- 1 <= n, m <= 10\n- 1 <= baseCosts[i], toppingCosts[i] <= 10^4\n- 1 <= target <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(baseCosts = [10, 20],toppingCosts = [1, 2, 3],target = 15) == 15\n assert candidate(baseCosts = [5, 9],toppingCosts = [2, 3, 7],target = 15) == 15\n assert candidate(baseCosts = [1, 7],toppingCosts = [3, 4],target = 10) == 10\n assert candidate(baseCosts = [10, 20, 30],toppingCosts = [1, 2, 3, 4, 5],target = 25) == 25\n assert candidate(baseCosts = [4, 8],toppingCosts = [1, 3],target = 15) == 15\n assert candidate(baseCosts = [5],toppingCosts = [1, 2, 3],target = 8) == 8\n assert candidate(baseCosts = [4],toppingCosts = [1, 2, 3],target = 8) == 8\n assert candidate(baseCosts = [10, 20],toppingCosts = [5, 15, 25],target = 50) == 50\n assert candidate(baseCosts = [1],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 10\n assert candidate(baseCosts = [5, 8],toppingCosts = [6, 1, 2],target = 20) == 20\n assert candidate(baseCosts = [10],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 20) == 20\n assert candidate(baseCosts = [2, 3],toppingCosts = [4, 5, 100],target = 18) == 17\n assert candidate(baseCosts = [3, 10],toppingCosts = [2, 5],target = 9) == 8\n assert candidate(baseCosts = [4, 8, 12, 16, 20],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 30) == 30\n assert candidate(baseCosts = [50, 75, 100, 125],toppingCosts = [10, 15, 20, 25, 30],target = 300) == 300\n assert candidate(baseCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],toppingCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1023) == 1023\n assert candidate(baseCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 1500) == 1500\n assert candidate(baseCosts = [1234, 5678, 9101],toppingCosts = [111, 222, 333, 444, 555, 666],target = 10000) == 10007\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000],toppingCosts = [50, 100, 150, 200, 250, 300, 350],target = 10000) == 7800\n assert candidate(baseCosts = [15, 25, 35, 45],toppingCosts = [2, 4, 6, 8, 10],target = 50) == 49\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [10, 20, 30, 40, 50],target = 500) == 500\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [987, 654, 321, 654, 321, 987],target = 1000) == 1086\n assert candidate(baseCosts = [10, 20, 30, 40, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 150) == 150\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 7500) == 7500\n assert candidate(baseCosts = [1, 5, 10, 15],toppingCosts = [3, 6, 9, 12],target = 30) == 30\n assert candidate(baseCosts = [7, 14, 21],toppingCosts = [3, 6, 9, 12, 15, 18],target = 30) == 30\n assert candidate(baseCosts = [500, 1000, 1500],toppingCosts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],target = 3000) == 3000\n assert candidate(baseCosts = [1000, 2000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 5000) == 5000\n assert candidate(baseCosts = [8, 16, 24],toppingCosts = [2, 4, 6, 8, 10, 12, 14, 16],target = 35) == 34\n assert candidate(baseCosts = [3, 6, 9, 12, 15],toppingCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1024) == 1024\n assert candidate(baseCosts = [300, 600, 900],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 1200) == 1200\n assert candidate(baseCosts = [1, 2, 3, 4, 5],toppingCosts = [5, 10, 15, 20, 25],target = 50) == 50\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 50) == 50\n assert candidate(baseCosts = [100, 200, 300],toppingCosts = [50, 75, 100, 125, 150],target = 600) == 600\n assert candidate(baseCosts = [1, 10000],toppingCosts = [5000, 3000, 2000, 1000, 500, 100],target = 9000) == 9001\n assert candidate(baseCosts = [15, 25, 35],toppingCosts = [5, 7, 11, 13, 17],target = 50) == 50\n assert candidate(baseCosts = [100, 150, 200, 250],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 750) == 750\n assert candidate(baseCosts = [999, 1999, 2999],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 5000) == 3109\n assert candidate(baseCosts = [1, 1, 1, 1, 1],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 25) == 25\n assert candidate(baseCosts = [150, 250, 350],toppingCosts = [5, 15, 25, 35, 45, 55],target = 400) == 400\n assert candidate(baseCosts = [2000, 4000, 6000],toppingCosts = [100, 200, 300, 400, 500],target = 7000) == 7000\n assert candidate(baseCosts = [1, 10, 100],toppingCosts = [9, 90, 900, 9000],target = 10000) == 10000\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 1000) == 1000\n assert candidate(baseCosts = [15, 25, 35, 45],toppingCosts = [1, 2, 3, 4, 5, 6, 7],target = 30) == 30\n assert candidate(baseCosts = [10, 20, 30],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 45) == 45\n assert candidate(baseCosts = [1, 1, 1, 1, 1],toppingCosts = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 100) == 101\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 10000) == 10000\n assert candidate(baseCosts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 100) == 100\n assert candidate(baseCosts = [500, 250],toppingCosts = [100, 200, 300, 400, 500],target = 1000) == 1000\n assert candidate(baseCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 500) == 210\n assert candidate(baseCosts = [100, 200, 300],toppingCosts = [10, 20, 30, 40, 50, 60],target = 500) == 500\n assert candidate(baseCosts = [1000, 2000, 3000],toppingCosts = [500, 100, 250, 125, 75],target = 4500) == 4500\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [11, 22, 33, 44, 55, 66, 77, 88, 99],target = 1000) == 998\n assert candidate(baseCosts = [5, 10, 15, 20, 25],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == 20\n assert candidate(baseCosts = [9999],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10000) == 10000\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [987, 654, 321, 123, 456, 789, 100, 200, 300],target = 2000) == 2000\n assert candidate(baseCosts = [500, 501, 502],toppingCosts = [250, 251, 252, 253],target = 1000) == 1000\n assert candidate(baseCosts = [777, 888],toppingCosts = [55, 44, 33, 22, 11, 1, 2, 3, 4, 5],target = 2000) == 1248\n assert candidate(baseCosts = [10, 20, 30, 40, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 25) == 25\n assert candidate(baseCosts = [10, 20, 30, 40, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 50) == 50\n assert candidate(baseCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 10\n assert candidate(baseCosts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 30) == 30\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [11, 22, 33, 44, 55],target = 700) == 698\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [10, 20, 30, 40, 50, 60],target = 750) == 750\n assert candidate(baseCosts = [100, 200],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 500) == 310\n assert candidate(baseCosts = [1000, 1001, 1002, 1003],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10000) == 1113\n assert candidate(baseCosts = [23, 45, 67, 89, 10],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 200) == 199\n assert candidate(baseCosts = [5, 10, 15, 20],toppingCosts = [1, 3, 5, 7, 9, 11, 13],target = 40) == 40\n assert candidate(baseCosts = [100, 200, 300, 400, 500],toppingCosts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 1000) == 1000\n assert candidate(baseCosts = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],toppingCosts = [2, 4, 6, 8, 10],target = 50) == 49\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [10, 20, 30, 40, 50, 60],target = 1500) == 820\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [50, 10, 15, 20, 25, 30, 35, 40, 45, 55],target = 1500) == 1050\n assert candidate(baseCosts = [1, 2, 3, 4, 5],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 100) == 101\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],toppingCosts = [500, 1500, 2500, 3500],target = 7500) == 7500\n assert candidate(baseCosts = [2000, 3000, 4000, 5000],toppingCosts = [50, 100, 150, 200, 250],target = 8500) == 6500\n assert candidate(baseCosts = [50, 100, 150, 200, 250, 300],toppingCosts = [5, 10, 15, 20, 25, 30],target = 750) == 510\n assert candidate(baseCosts = [100, 200],toppingCosts = [50, 25, 10, 5, 1],target = 300) == 300\n assert candidate(baseCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 5000) == 5001\n assert candidate(baseCosts = [1000, 2000, 3000],toppingCosts = [500, 1000, 1500, 2000, 2500],target = 6000) == 6000\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 50) == 50\n assert candidate(baseCosts = [800, 1600, 2400],toppingCosts = [100, 200, 300, 400, 500, 600],target = 3000) == 3000\n assert candidate(baseCosts = [1000, 2000, 3000],toppingCosts = [500, 100, 250, 150, 200],target = 4500) == 4500\n assert candidate(baseCosts = [4, 8, 12, 16, 20],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 45) == 45\n assert candidate(baseCosts = [1, 2, 3, 4, 5],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 500) == 501\n assert candidate(baseCosts = [50, 60, 70, 80, 90],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 150) == 150\n assert candidate(baseCosts = [100, 200, 300],toppingCosts = [50, 75, 100, 125, 150],target = 500) == 500\n assert candidate(baseCosts = [10, 20],toppingCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1000) == 1000\n assert candidate(baseCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 500) == 210\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [9999],target = 10000) == 10000\n assert candidate(baseCosts = [5, 10],toppingCosts = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 15) == 15\n assert candidate(baseCosts = [500, 1000, 1500],toppingCosts = [5, 10, 15, 20, 25, 30, 35, 40],target = 2000) == 1860\n assert candidate(baseCosts = [999, 1000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 4000) == 4000\n", "comparison": "exact"}, "public_tests": ["[1,7]\n[3,4]\n10", "[2,3]\n[4,5,100]\n18", "[3,10]\n[2,5]\n9"], "hints": ["As the constraints are not large, you can brute force and enumerate all the possibilities."], "metadata": {"canonical_parameter_names": ["baseCosts", "toppingCosts", "target"], "leetcode_dataset_entry_point": "Solution().closestCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:23+00:00", "tests_total": 99, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "dynamic-programming", "backtracking", "knapsack-problem", "mixed-knapsack"]}, "language": "python", "interface": {"raw_signature": "def closestCost(self, baseCosts: list[int], toppingCosts: list[int], target: int) -> int:", "container": "Solution", "callable": "closestCost", "parameters": [{"name": "baseCosts", "type": "list[int]"}, {"name": "toppingCosts", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1775, "task_id": "equal-sum-arrays-with-minimum-number-of-operations", "difficulty": "Medium", "problem_description": "You are given two arrays of integers nums1 and nums2, possibly of different lengths. The values in the arrays are between 1 and 6, inclusive.\n\nIn one operation, you can change any integer's value in any of the arrays to any value between 1 and 6, inclusive.\n\nReturn the minimum number of operations required to make the sum of values in nums1 equal to the sum of values in nums2. Return -1 if it is not possible to make the sum of the two arrays equal.\n\nExample 1:\n\nInput: nums1 = [1,2,3,4,5,6], nums2 = [1,1,2,2,2,2]\nOutput: 3\nExplanation: You can make the sums of nums1 and nums2 equal with 3 operations. All indices are 0-indexed.\n- Change nums2[0] to 6. nums1 = [1,2,3,4,5,6], nums2 = [6,1,2,2,2,2].\n- Change nums1[5] to 1. nums1 = [1,2,3,4,5,1], nums2 = [6,1,2,2,2,2].\n- Change nums1[2] to 2. nums1 = [1,2,2,4,5,1], nums2 = [6,1,2,2,2,2].\n\nExample 2:\n\nInput: nums1 = [1,1,1,1,1,1,1], nums2 = [6]\nOutput: -1\nExplanation: There is no way to decrease the sum of nums1 or to increase the sum of nums2 to make them equal.\n\nExample 3:\n\nInput: nums1 = [6,6], nums2 = [1]\nOutput: 3\nExplanation: You can make the sums of nums1 and nums2 equal with 3 operations. All indices are 0-indexed.\n- Change nums1[0] to 2. nums1 = [2,6], nums2 = [1].\n- Change nums1[1] to 2. nums1 = [2,2], nums2 = [1].\n- Change nums2[0] to 4. nums1 = [2,2], nums2 = [4].\n\nConstraints:\n\n- 1 <= nums1.length, nums2.length <= 10^5\n- 1 <= nums1[i], nums2[i] <= 6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [3, 3, 3, 3],nums2 = [2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1, 1],nums2 = [6, 6]) == 2\n assert candidate(nums1 = [6, 6, 6],nums2 = [1, 1]) == 4\n assert candidate(nums1 = [1, 1, 2],nums2 = [6, 6, 6]) == 3\n assert candidate(nums1 = [1, 1],nums2 = [6, 6, 6]) == 4\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums1 = [1, 2],nums2 = [5, 6]) == 2\n assert candidate(nums1 = [6, 6, 6],nums2 = [1, 1, 1]) == 3\n assert candidate(nums1 = [3, 3, 3],nums2 = [3, 3, 3]) == 0\n assert candidate(nums1 = [2, 3, 4],nums2 = [5, 5, 5]) == 2\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1],nums2 = [6]) == -1\n assert candidate(nums1 = [6],nums2 = [1]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [1, 1, 2, 2, 2, 2]) == 3\n assert candidate(nums1 = [3, 3, 3],nums2 = [2, 2, 2]) == 1\n assert candidate(nums1 = [6, 6],nums2 = [1]) == 3\n assert candidate(nums1 = [2, 2, 2],nums2 = [5, 5, 5]) == 3\n assert candidate(nums1 = [3, 3, 3],nums2 = [2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1],nums2 = [6]) == 1\n assert candidate(nums1 = [1, 1, 1],nums2 = [6, 6, 6]) == 3\n assert candidate(nums1 = [3],nums2 = [3]) == 0\n assert candidate(nums1 = [1, 3, 5],nums2 = [2, 4, 6]) == 1\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 2\n assert candidate(nums1 = [5, 5],nums2 = [1, 1]) == 2\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1]) == 4\n assert candidate(nums1 = [3, 3, 3, 3],nums2 = [1, 6, 1, 6]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 6\n assert candidate(nums1 = [1, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2]) == 5\n assert candidate(nums1 = [6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 2, 3, 4, 5, 6]) == 3\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [1, 6, 1, 6, 1, 6],nums2 = [6, 1, 6, 1, 6, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 58\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [4, 5, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 8\n assert candidate(nums1 = [1, 3, 5, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == -1\n assert candidate(nums1 = [2, 3, 4, 5, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 9\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6]) == 5\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5]) == 11\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 5\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 18\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 7\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 12\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2],nums2 = [2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3]) == 1\n assert candidate(nums1 = [1, 3, 5, 1, 3, 5, 1, 3, 5],nums2 = [2, 4, 6, 2, 4, 6, 2, 4, 6]) == 2\n assert candidate(nums1 = [1, 6, 1, 6, 1, 6],nums2 = [2, 5, 2, 5, 2, 5]) == 0\n assert candidate(nums1 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4],nums2 = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 7\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 10\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 2, 3, 4, 5, 6, 6, 6, 6]) == 3\n assert candidate(nums1 = [2, 3, 4, 5, 6],nums2 = [1, 1, 1, 1]) == 4\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 131\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5]) == 2\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 6, 6, 6],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 15\n assert candidate(nums1 = [1, 6, 1, 6, 1, 6, 1, 6, 1, 6],nums2 = [6, 1, 6, 1, 6, 1, 6, 1, 6, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 6]) == 2\n assert candidate(nums1 = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 9\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 30\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 28\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 14\n assert candidate(nums1 = [2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6]) == 3\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 11\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 8\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == 5\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 3\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [3, 3, 3, 3, 3, 3]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 33\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 21\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [2, 3, 4, 5, 6, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 15\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4, 4],nums2 = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums1 = [6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums1 = [6, 4, 2, 6, 4, 2, 6, 4, 2],nums2 = [1, 3, 5, 1, 3, 5, 1, 3, 5]) == 2\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5]) == 3\n assert candidate(nums1 = [1, 3, 5, 1, 3, 5, 1, 3, 5, 1, 3, 5],nums2 = [2, 4, 6, 2, 4, 6, 2, 4, 6, 2, 4, 6]) == 3\n assert candidate(nums1 = [2, 3, 4],nums2 = [1, 5, 6, 6]) == 2\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [6, 6, 6, 6, 6]) == 2\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 6, 6, 6, 6, 6]) == 5\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(nums1 = [1, 3, 5],nums2 = [2, 4, 6]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 7\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 20\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 8\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1]) == 5\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6]) == 7\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [4, 4, 5, 5, 6, 6]) == 4\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6]) == -1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 8\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [4, 5, 6, 6, 6, 6, 6]) == 5\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1]) == 6\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5,6]\n[1,1,2,2,2,2]", "[1,1,1,1,1,1,1]\n[6]", "[6,6]\n[1]"], "hints": ["Let's note that we want to either decrease the sum of the array with a larger sum or increase the array's sum with the smaller sum.", "You can maintain the largest increase or decrease you can make in a binary search tree and each time get the maximum one."], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:25+00:00", "tests_total": 138, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "counting"]}, "language": "python", "interface": {"raw_signature": "def minOperations(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1776, "task_id": "car-fleet-ii", "difficulty": "Hard", "problem_description": "There are n cars traveling at different speeds in the same direction along a one-lane road. You are given an array cars of length n, where cars[i] = [position_i, speed_i] represents:\n\n- position_i is the distance between the i^th car and the beginning of the road in meters. It is guaranteed that position_i < position_{i+1}.\n- speed_i is the initial speed of the i^th car in meters per second.\n\nFor simplicity, cars can be considered as points moving along the number line. Two cars collide when they occupy the same position. Once a car collides with another car, they unite and form a single car fleet. The cars in the formed fleet will have the same position and the same speed, which is the initial speed of the slowest car in the fleet.\n\nReturn an array answer, where answer[i] is the time, in seconds, at which the i^th car collides with the next car, or -1 if the car does not collide with the next car. Answers within 10^-5 of the actual answers are accepted.\n\nExample 1:\n\nInput: cars = [[1,2],[2,1],[4,3],[7,2]]\nOutput: [1.00000,-1.00000,3.00000,-1.00000]\nExplanation: After exactly one second, the first car will collide with the second car, and form a car fleet with speed 1 m/s. After exactly 3 seconds, the third car will collide with the fourth car, and form a car fleet with speed 2 m/s.\n\nExample 2:\n\nInput: cars = [[3,4],[5,4],[6,3],[9,1]]\nOutput: [2.00000,1.00000,1.50000,-1.00000]\n\nConstraints:\n\n- 1 <= cars.length <= 10^5\n- 1 <= position_i, speed_i <= 10^6\n- position_i < position_{i+1}\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(cars=[[1, 4], [2, 3], [3, 2], [4, 1]]), [1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 5], [3, 2], [5, 1]]), [0.6666666666666666, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]), [-1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[3, 4], [5, 4], [6, 3], [9, 1]]), [2.0, 1.0, 1.5, -1])\n assert answers_match(candidate(cars=[[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]), [-1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[5, 10], [10, 5], [15, 2], [20, 1]]), [1.0, 1.6666666666666667, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [3, 8], [5, 6], [7, 4], [9, 2]]), [1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]]), [-1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 2], [2, 1], [4, 3], [7, 2]]), [1.0, -1, 3.0, -1])\n assert answers_match(candidate(cars=[[10, 10], [8, 5], [6, 3], [4, 2], [2, 1]]), [-0.8888888888888888, -1.5, -2.0, -2.0, -1])\n assert answers_match(candidate(cars=[[10, 2], [20, 1], [30, 3], [40, 2]]), [10.0, -1, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[5, 10], [15, 8], [20, 7], [25, 6], [30, 5]]), [5.0, 5.0, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]]), [10.0, 10.0, 10.0, 10.0, -1])\n assert answers_match(candidate(cars=[[10, 5], [15, 3], [20, 2], [25, 1]]), [2.5, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]), [1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [3, 6], [5, 5], [7, 4]]), [0.5, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 20], [2, 18], [3, 16], [4, 14], [5, 12], [6, 10], [7, 8], [8, 6], [9, 4], [10, 2]]), [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1])\n assert answers_match(candidate(cars=[[2, 9], [5, 7], [8, 6], [11, 4], [14, 2], [17, 1]]), [1.5, 1.8, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[10, 5], [20, 15], [30, 10], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45]]), [-1, 2.0, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10], [100, 1]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.1111111111111112, -1])\n assert answers_match(candidate(cars=[[1, 100], [10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10]]), [0.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[50, 100], [150, 90], [250, 80], [350, 70], [450, 60], [550, 50], [650, 40], [750, 30], [850, 20], [950, 10]]), [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 25], [3, 24], [5, 23], [7, 22], [9, 21], [11, 20], [13, 19], [15, 18], [17, 17], [19, 16], [21, 15]]), [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [10, 9], [19, 8], [28, 7], [37, 6], [46, 5], [55, 4], [64, 3], [73, 2], [82, 1]]), [9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, -1])\n assert answers_match(candidate(cars=[[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [11, 10], [12, 9], [13, 8], [14, 7], [15, 6], [16, 5], [17, 4], [18, 3], [19, 2], [20, 1]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [12, 10], [14, 9], [16, 8], [18, 7], [20, 6], [22, 5], [24, 4], [26, 3], [28, 2], [30, 1]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]]), [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -1])\n assert answers_match(candidate(cars=[[1, 50], [10, 45], [20, 40], [30, 35], [40, 30], [50, 25], [60, 20], [70, 15], [80, 10], [90, 5]]), [1.8, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 5], [2, 10], [3, 15], [4, 20], [5, 25], [6, 30], [7, 35], [8, 40], [9, 45], [10, 50]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 10], [4, 8], [7, 6], [10, 4], [13, 2], [16, 1]]), [1.5, 1.5, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 8], [3, 7], [5, 6], [7, 5], [9, 4], [11, 3], [13, 2], [15, 1]]), [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 30], [4, 20], [7, 15], [10, 10], [13, 8], [16, 6], [19, 4], [22, 2], [25, 1]]), [0.3, 0.6, 0.6, 1.5, 1.5, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [10, 95], [20, 90], [30, 85], [40, 80], [50, 75], [60, 70], [70, 65], [80, 60], [90, 55]]), [1.8, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 15], [2, 25], [3, 35], [4, 45], [5, 55], [6, 65], [7, 75], [8, 85], [9, 95], [10, 105]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 5], [4, 4], [7, 3], [10, 2], [13, 1]]), [3.0, 3.0, 3.0, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [20, 50], [30, 30], [40, 20], [50, 10], [60, 1]]), [0.38, 0.5, 1.0, 1.0, 1.1111111111111112, -1])\n assert answers_match(candidate(cars=[[1, 15], [2, 10], [4, 5], [6, 4], [8, 3], [10, 2], [12, 1]]), [0.2, 0.4, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 3], [2, 2], [3, 1], [4, 4], [5, 5], [6, 6]]), [1.0, 1.0, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 200], [11, 180], [21, 160], [31, 140], [41, 120], [51, 100], [61, 80], [71, 60], [81, 40], [91, 20]]), [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1])\n assert answers_match(candidate(cars=[[1, 5], [3, 4], [5, 3], [7, 2], [9, 1], [11, 10], [13, 9], [15, 8], [17, 7], [19, 6]]), [2.0, 2.0, 2.0, 2.0, -1, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 20], [4, 18], [7, 16], [10, 14], [13, 12], [16, 10], [19, 8], [22, 6], [25, 4], [28, 2], [31, 1]]), [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 100000], [2, 99000], [3, 98000], [4, 97000], [5, 96000], [6, 95000], [7, 94000], [8, 93000], [9, 92000], [10, 91000]]), [0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, -1])\n assert answers_match(candidate(cars=[[1, 100], [5, 80], [10, 60], [15, 40], [20, 20], [25, 10]]), [0.2, 0.25, 0.25, 0.25, 0.5, -1])\n assert answers_match(candidate(cars=[[1, 30], [2, 25], [3, 20], [5, 15], [8, 10], [13, 5], [20, 2], [28, 1]]), [0.2, 0.2, 0.4, 0.6, 1.0, 2.3333333333333335, 8.0, -1])\n assert answers_match(candidate(cars=[[1, 12], [3, 10], [5, 8], [7, 6], [9, 4], [11, 2]]), [1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 50], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44], [8, 43], [9, 42], [10, 41]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 5], [6, 10], [11, 5], [16, 10], [21, 5], [26, 10], [31, 5], [36, 10], [41, 5], [46, 10]]), [-1, 1.0, -1, 1.0, -1, 1.0, -1, 1.0, -1, -1])\n assert answers_match(candidate(cars=[[1, 200], [2, 190], [3, 180], [4, 170], [5, 160], [6, 150], [7, 140], [8, 130], [9, 120], [10, 110]]), [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -1])\n assert answers_match(candidate(cars=[[1, 6], [3, 5], [5, 4], [7, 3], [9, 2], [11, 1], [13, 5], [15, 4], [17, 3], [19, 2], [21, 1]]), [2.0, 2.0, 2.0, 2.0, 2.0, -1, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 15], [5, 14], [10, 13], [15, 12], [20, 11], [25, 10], [30, 9], [35, 8], [40, 7], [45, 6], [50, 5], [55, 4], [60, 3], [65, 2], [70, 1]]), [4.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10], [30, 10], [35, 10], [40, 10], [45, 10]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 3], [5, 2], [10, 1], [15, 4], [20, 3], [25, 2], [30, 1]]), [4.0, 5.0, -1, 5.0, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 9], [5, 8], [8, 7], [13, 6], [18, 5], [24, 4], [30, 3], [36, 2], [42, 1]]), [1.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0, 6.0, 6.0, -1])\n assert answers_match(candidate(cars=[[1, 2], [2, 3], [3, 5], [4, 8], [5, 13], [6, 21], [7, 34], [8, 55], [9, 89], [10, 144]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 2], [3, 5], [5, 10], [7, 3], [9, 8], [11, 6], [13, 7], [15, 4]]), [-1, 2.0, 0.2857142857142857, -1, 1.0, 2.0, 0.6666666666666666, -1])\n assert answers_match(candidate(cars=[[3, 12], [6, 10], [9, 8], [12, 6], [15, 4], [18, 2], [21, 1]]), [1.5, 1.5, 1.5, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [4, 9], [10, 8], [15, 7], [20, 6], [25, 5], [30, 4], [35, 3], [40, 2], [45, 1]]), [3.0, 5.125, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 20], [4, 18], [10, 16], [15, 14], [20, 12], [25, 10], [30, 8], [35, 6], [40, 4], [45, 2]]), [1.5, 2.5625, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, -1])\n assert answers_match(candidate(cars=[[1, 1], [10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 50], [5, 40], [10, 30], [16, 20], [23, 10], [31, 5], [40, 3], [50, 1]]), [0.4, 0.5, 0.6, 0.7, 1.6, 4.5, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]]), [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, -1])\n assert answers_match(candidate(cars=[[1, 20], [2, 18], [3, 16], [5, 14], [8, 12], [13, 10], [20, 8], [28, 6], [37, 4], [46, 2]]), [0.5, 0.5, 1.0, 1.5, 2.5, 3.5, 4.0, 4.5, 4.5, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 20], [3, 15], [4, 25], [5, 20], [6, 30], [7, 25], [8, 35], [9, 30], [10, 40]]), [-1, 0.2, -1, 0.2, -1, 0.2, -1, 0.2, -1, -1])\n assert answers_match(candidate(cars=[[10, 10], [20, 9], [30, 8], [40, 7], [50, 6], [60, 5], [70, 4], [80, 3], [90, 2], [100, 1]]), [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [11, 9], [21, 8], [31, 7], [41, 6], [51, 5], [61, 4], [71, 3], [81, 2], [91, 1]]), [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [3, 10], [5, 10], [7, 10], [9, 10], [11, 10], [13, 10], [15, 10], [17, 10], [19, 10], [21, 10]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[10, 10], [25, 9], [40, 8], [55, 7], [70, 6], [85, 5], [100, 4], [115, 3], [130, 2], [145, 1]]), [15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, -1])\n assert answers_match(candidate(cars=[[1, 2], [5, 4], [9, 6], [13, 8], [17, 10], [21, 12], [25, 14], [29, 16], [33, 18], [37, 20]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 1], [100000, 100000], [200000, 99999], [300000, 99998], [400000, 99997], [500000, 99996]]), [-1, 100000.0, 100000.0, 100000.0, 100000.0, -1])\n assert answers_match(candidate(cars=[[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 50], [3, 45], [6, 40], [10, 35], [15, 30], [21, 25], [28, 20], [36, 15], [45, 10], [55, 5]]), [0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [5, 90], [10, 80], [15, 70], [20, 60], [25, 50], [30, 40], [35, 30], [40, 20], [45, 10]]), [0.4, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1])\n assert answers_match(candidate(cars=[[1, 10], [11, 9.99999], [21, 9.99998], [31, 9.99997], [41, 9.99996], [51, 9.99995], [61, 9.99994], [71, 9.99993], [81, 9.99992], [91, 9.99991]]), [999999.9999786458, 999999.9999490399, 999999.999860222, 1000000.0000023306, 999999.9999934488, 999999.9999786458, 999999.9999490399, 999999.999860222, 1000000.0000378577, -1])\n assert answers_match(candidate(cars=[[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86], [16, 85], [17, 84], [18, 83], [19, 82], [20, 81]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 15], [5, 10], [9, 7], [13, 4], [17, 2], [21, 1], [25, 3], [29, 6], [33, 9], [37, 12]]), [0.8, 1.3333333333333333, 1.3333333333333333, 2.0, 4.0, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10]]), [1.1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[10, 5], [20, 5], [30, 5], [40, 5], [50, 5], [60, 5], [70, 5], [80, 5], [90, 5], [100, 5]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 150], [4, 130], [7, 110], [10, 90], [13, 70], [16, 50], [19, 30], [22, 10]]), [0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, -1])\n assert answers_match(candidate(cars=[[1, 10], [3, 9], [6, 8], [10, 7], [15, 6], [21, 5], [28, 4], [36, 3], [45, 2], [55, 1]]), [2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86], [16, 85], [17, 84], [18, 83], [19, 82], [20, 81], [21, 80], [22, 79], [23, 78], [24, 77], [25, 76], [26, 75], [27, 74], [28, 73], [29, 72], [30, 71]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 30], [4, 28], [7, 26], [10, 24], [13, 22], [16, 20], [19, 18], [22, 16], [25, 14], [28, 12], [31, 10], [34, 8], [37, 6], [40, 4], [43, 2]]), [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, -1])\n assert answers_match(candidate(cars=[[1, 5], [5, 10], [9, 5], [13, 10], [17, 5], [21, 10], [25, 5], [29, 10], [33, 5], [37, 10]]), [-1, 0.8, -1, 0.8, -1, 0.8, -1, 0.8, -1, -1])\n assert answers_match(candidate(cars=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 9.5], [3, 9], [4, 8.5], [5, 8], [6, 7.5], [7, 7], [8, 6.5], [9, 6], [10, 5.5], [11, 5]]), [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 15], [4, 12], [7, 9], [10, 6], [13, 3], [16, 2], [19, 1]]), [1.0, 1.0, 1.0, 1.0, 3.0, 3.0, -1])\n", "comparison": "float"}, "public_tests": ["[[1,2],[2,1],[4,3],[7,2]]", "[[3,4],[5,4],[6,3],[9,1]]"], "hints": ["We can simply ignore the merging of any car fleet, simply assume they cross each other. Now the aim is to find the first car to the right, which intersects with the current car before any other.", "Assume we have already considered all cars to the right already, now the current car is to be considered. Let’s ignore all cars with speeds higher than the current car since the current car cannot intersect with those ones. Now, all cars to the right having speed strictly less than current car are to be considered. Now, for two cars c1 and c2 with positions p1 and p2 (p1 < p2) and speed s1 and s2 (s1 > s2), if c1 and c2 intersect before the current car and c2, then c1 can never be the first car of intersection for any car to the left of current car including current car. So we can remove that car from our consideration.", "We can see that we can maintain candidate cars in this way using a stack, removing cars with speed greater than or equal to current car, and then removing cars which can never be first point of intersection. The first car after this process (if any) would be first point of intersection."], "metadata": {"canonical_parameter_names": ["cars"], "leetcode_dataset_entry_point": "Solution().getCollisionTimes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:28+00:00", "tests_total": 95, "tests_dropped": 4, "flags": ["decimal_answer"], "topic_tags": ["array", "math", "stack", "heap-priority-queue", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def getCollisionTimes(self, cars: list[list[int]]) -> list[float]:", "container": "Solution", "callable": "getCollisionTimes", "parameters": [{"name": "cars", "type": "list[list[int]]"}], "return_type": "list[float]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1779, "task_id": "find-nearest-point-that-has-the-same-x-or-y-coordinate", "difficulty": "Easy", "problem_description": "You are given two integers, x and y, which represent your current location on a Cartesian grid: (x, y). You are also given an array points where each points[i] = [a_i, b_i] represents that a point exists at (a_i, b_i). A point is valid if it shares the same x-coordinate or the same y-coordinate as your location.\n\nReturn the index (0-indexed) of the valid point with the smallest Manhattan distance from your current location. If there are multiple, return the valid point with the smallest index. If there are no valid points, return -1.\n\nThe Manhattan distance between two points (x_1, y_1) and (x_2, y_2) is abs(x_1 - x_2) + abs(y_1 - y_2).\n\nExample 1:\n\nInput: x = 3, y = 4, points = [[1,2],[3,1],[2,4],[2,3],[4,4]]\nOutput: 2\nExplanation: Of all the points, only [3,1], [2,4] and [4,4] are valid. Of the valid points, [2,4] and [4,4] have the smallest Manhattan distance from your current location, with a distance of 1. [2,4] has the smallest index, so return 2.\n\nExample 2:\n\nInput: x = 3, y = 4, points = [[3,4]]\nOutput: 0\nExplanation: The answer is allowed to be on the same location as your current location.\n\nExample 3:\n\nInput: x = 3, y = 4, points = [[2,3]]\nOutput: -1\nExplanation: There are no valid points.\n\nConstraints:\n\n- 1 <= points.length <= 10^4\n- points[i].length == 2\n- 1 <= x, y, a_i, b_i <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(x = 3,y = 4,points = [[3, 4]]) == 0\n assert candidate(x = 5,y = 5,points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4]]) == 3\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4]]) == -1\n assert candidate(x = 3,y = 4,points = [[2, 3]]) == -1\n assert candidate(x = 1,y = 1,points = [[1, 1], [1, 2], [1, 3], [2, 1], [3, 1]]) == 0\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == -1\n assert candidate(x = 1,y = 1,points = [[1, 1], [1, 2], [2, 1], [2, 2]]) == 0\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5]]) == -1\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 9\n assert candidate(x = 100,y = 100,points = [[50, 100], [100, 50], [150, 100], [100, 150]]) == 0\n assert candidate(x = 5,y = 5,points = [[1, 1], [5, 5], [3, 3], [4, 4]]) == 1\n assert candidate(x = 5,y = 5,points = [[5, 5], [5, 6], [6, 5], [6, 6]]) == 0\n assert candidate(x = 1,y = 10,points = [[1, 1], [1, 2], [1, 3], [1, 4]]) == 3\n assert candidate(x = 5,y = 5,points = [[1, 5], [5, 1], [5, 9], [9, 5], [5, 5]]) == 4\n assert candidate(x = 5,y = 5,points = [[5, 1], [5, 2], [5, 3], [5, 4], [1, 5], [2, 5], [3, 5], [4, 5]]) == 3\n assert candidate(x = 5,y = 5,points = [[10, 10], [5, 5], [1, 1]]) == 1\n assert candidate(x = 1,y = 1,points = [[1, 2], [1, 3], [1, 4], [2, 1], [3, 1]]) == 0\n assert candidate(x = 5,y = 5,points = [[5, 5], [6, 6], [7, 7]]) == 0\n assert candidate(x = 10,y = 10,points = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == -1\n assert candidate(x = 2,y = 3,points = [[2, 3], [1, 1], [3, 3], [4, 4]]) == 0\n assert candidate(x = 10,y = 1,points = [[1, 1], [2, 1], [3, 1], [4, 1]]) == 3\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [4, 4]]) == -1\n assert candidate(x = 3,y = 4,points = [[1, 2], [3, 1], [2, 4], [2, 3], [4, 4]]) == 2\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [10, 10]]) == 3\n assert candidate(x = 5,y = 5,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 4\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 1], [1, 1], [1, 1], [1, 1]]) == 0\n assert candidate(x = 7,y = 7,points = [[6, 7], [7, 6], [7, 8], [8, 7]]) == 0\n assert candidate(x = 3,y = 3,points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 7\n assert candidate(x = 50,y = 50,points = [[49, 50], [51, 50], [50, 49], [50, 51], [48, 50], [52, 50], [50, 48], [50, 52]]) == 0\n assert candidate(x = 7,y = 8,points = [[7, 1], [1, 8], [7, 9], [9, 8], [7, 7], [8, 8]]) == 2\n assert candidate(x = 100,y = 100,points = [[99, 100], [100, 99], [101, 100], [100, 101], [98, 100], [100, 98]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 1], [4, 4], [5, 5], [1, 3], [3, 1]]) == 2\n assert candidate(x = 1,y = 2,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 2]]) == 9\n assert candidate(x = 7,y = 7,points = [[1, 1], [1, 7], [7, 1], [7, 7], [2, 2], [6, 6], [3, 3], [5, 5], [4, 4], [8, 8]]) == 3\n assert candidate(x = 2000,y = 2000,points = [[2000, 1999], [1999, 2000], [2000, 2001], [2001, 2000], [2000, 2000], [2000, 2002], [2002, 2000]]) == 4\n assert candidate(x = 20,y = 20,points = [[20, 19], [19, 20], [21, 20], [20, 21], [20, 20], [19, 19]]) == 4\n assert candidate(x = 5,y = 5,points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 3\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1]]) == 0\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [1, 1]]) == 5\n assert candidate(x = 7,y = 7,points = [[1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [8, 7], [9, 7], [10, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 8], [7, 9], [7, 10]]) == 5\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [1, 2], [2, 1]]) == 9\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 10], [10, 2], [5, 5], [10, 10], [1, 10], [10, 1]]) == 4\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [10, 1], [10, 2], [10, 3], [1, 10], [2, 10], [3, 10]]) == 5\n assert candidate(x = 100,y = 100,points = [[100, 100], [100, 99], [99, 100], [100, 101], [101, 100], [99, 99], [101, 101]]) == 0\n assert candidate(x = 5000,y = 5000,points = [[5000, 4999], [4999, 5000], [5000, 5001], [5001, 5000], [4999, 4999], [5001, 5001]]) == 0\n assert candidate(x = 5000,y = 5000,points = [[4999, 5000], [5000, 4999], [5001, 5000], [5000, 5001], [5000, 5000]]) == 4\n assert candidate(x = 2000,y = 3000,points = [[2000, 2999], [2000, 3001], [1999, 3000], [2001, 3000], [2000, 3000]]) == 4\n assert candidate(x = 20,y = 20,points = [[20, 1], [1, 20], [19, 20], [20, 19], [20, 18], [20, 17], [20, 16], [20, 15], [20, 14], [20, 13], [20, 12], [20, 11], [20, 10], [20, 9], [20, 8], [20, 7], [20, 6], [20, 5], [20, 4], [20, 3], [20, 2]]) == 2\n assert candidate(x = 20,y = 20,points = [[15, 20], [20, 15], [25, 20], [20, 25], [10, 10], [30, 30]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 0\n assert candidate(x = 7,y = 7,points = [[7, 1], [1, 7], [7, 2], [2, 7], [7, 3], [3, 7], [7, 4], [4, 7], [7, 5], [5, 7], [7, 6], [6, 7], [7, 7]]) == 12\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [1, 2], [2, 1]]) == 4\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == 4\n assert candidate(x = 2,y = 2,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 1\n assert candidate(x = 1,y = 100,points = [[1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [2, 100], [3, 100], [4, 100], [5, 100], [6, 100]]) == 5\n assert candidate(x = 5,y = 5,points = [[5, 6], [6, 5], [5, 4], [4, 5], [5, 5], [5, 3], [3, 5], [5, 7], [7, 5]]) == 4\n assert candidate(x = 1000,y = 1000,points = [[1000, 1000], [999, 1000], [1000, 999], [999, 999], [998, 998], [997, 997], [996, 996], [995, 995], [994, 994], [993, 993]]) == 0\n assert candidate(x = 12,y = 15,points = [[10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]]) == 2\n assert candidate(x = 7,y = 7,points = [[7, 8], [8, 7], [6, 7], [7, 6], [7, 9], [9, 7], [7, 7], [7, 5], [5, 7]]) == 6\n assert candidate(x = 20,y = 25,points = [[15, 25], [25, 20], [20, 15], [20, 30], [30, 20], [20, 20]]) == 0\n assert candidate(x = 10,y = 10,points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [10, 9], [8, 7], [6, 5], [4, 3], [2, 1]]) == 4\n assert candidate(x = 30,y = 40,points = [[30, 35], [25, 40], [30, 45], [35, 40], [30, 40], [25, 35]]) == 4\n assert candidate(x = 10,y = 10,points = [[5, 10], [15, 10], [10, 5], [10, 15], [10, 10]]) == 4\n assert candidate(x = 1,y = 1,points = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2]]) == -1\n assert candidate(x = 1,y = 1,points = [[2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20]]) == 0\n assert candidate(x = 9,y = 9,points = [[9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [9, 10]]) == 8\n assert candidate(x = 3,y = 3,points = [[1, 3], [3, 1], [2, 3], [3, 2], [3, 3], [4, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9]]) == 4\n assert candidate(x = 9999,y = 9999,points = [[9998, 9998], [9997, 9997], [9996, 9996], [9995, 9995], [9994, 9994], [9999, 9998], [9999, 9997], [9999, 9996], [9999, 9995], [9999, 9994], [9998, 9999], [9997, 9999], [9996, 9999], [9995, 9999], [9994, 9999]]) == 5\n assert candidate(x = 5,y = 5,points = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [1, 5], [2, 5], [3, 5], [4, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 3\n assert candidate(x = 5000,y = 5000,points = [[1, 1], [10000, 10000], [5000, 1], [1, 5000], [5000, 5000], [4999, 4999], [5001, 5001]]) == 4\n assert candidate(x = 100,y = 1,points = [[50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6]]) == 5\n assert candidate(x = 5000,y = 5000,points = [[4999, 5000], [5001, 5000], [5000, 4999], [5000, 5001], [4998, 5000], [5002, 5000], [5000, 4998], [5000, 5002]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1]]) == 0\n assert candidate(x = 50,y = 50,points = [[50, 50], [50, 49], [49, 50], [50, 48], [48, 50], [50, 47], [47, 50], [50, 46], [46, 50], [50, 45], [45, 50]]) == 0\n assert candidate(x = 2500,y = 7500,points = [[2500, 7499], [2500, 7501], [2499, 7500], [2501, 7500], [2498, 7500], [2502, 7500], [2500, 7498], [2500, 7502]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 1]]) == 4\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 1], [2, 2], [3, 3]]) == 4\n assert candidate(x = 10,y = 10,points = [[5, 10], [10, 5], [10, 15], [15, 10], [10, 10], [11, 10], [10, 11], [9, 10], [10, 9]]) == 4\n assert candidate(x = 5,y = 5,points = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 3\n assert candidate(x = 6,y = 6,points = [[5, 6], [6, 5], [7, 6], [6, 7], [6, 6], [5, 5], [7, 7], [5, 7], [7, 5]]) == 4\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1]]) == 9\n assert candidate(x = 10,y = 10,points = [[10, 1], [1, 10], [10, 10], [5, 5], [10, 9], [9, 10]]) == 2\n assert candidate(x = 15,y = 20,points = [[10, 20], [15, 10], [20, 15], [15, 20], [10, 10], [20, 20]]) == 3\n assert candidate(x = 2,y = 2,points = [[2, 1], [1, 2], [3, 2], [2, 3], [1, 1], [3, 1], [1, 3], [3, 3], [2, 4], [4, 2], [4, 3], [3, 4], [4, 4]]) == 0\n assert candidate(x = 5,y = 5,points = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 5], [7, 5], [8, 5], [9, 5]]) == 0\n assert candidate(x = 3,y = 3,points = [[1, 3], [2, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3], [3, 1], [3, 2], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]]) == 1\n assert candidate(x = 7,y = 7,points = [[5, 7], [6, 8], [7, 9], [8, 6], [9, 5], [7, 7], [7, 8], [8, 7]]) == 5\n assert candidate(x = 100,y = 100,points = [[100, 50], [50, 100], [100, 60], [60, 100], [100, 70], [70, 100], [100, 80], [80, 100], [100, 90], [90, 100]]) == 8\n assert candidate(x = 7,y = 7,points = [[1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [8, 7], [9, 7], [10, 7]]) == 5\n assert candidate(x = 5000,y = 5000,points = [[5000, 5000], [5001, 5000], [4999, 5000], [5000, 5001], [5000, 4999]]) == 0\n assert candidate(x = 100,y = 100,points = [[99, 100], [100, 99], [100, 101], [101, 100], [98, 100], [100, 98], [99, 99], [101, 101]]) == 0\n assert candidate(x = 100,y = 100,points = [[50, 100], [100, 50], [150, 100], [100, 150], [100, 100]]) == 4\n assert candidate(x = 500,y = 500,points = [[500, 1], [1, 500], [500, 499], [499, 500], [10, 10], [490, 490], [50, 50], [1, 1], [500, 500]]) == 8\n assert candidate(x = 100,y = 100,points = [[100, 1], [1, 100], [99, 100], [100, 99], [10, 10], [90, 90], [50, 50], [1, 1], [100, 100]]) == 8\n assert candidate(x = 50,y = 50,points = [[50, 1], [50, 99], [1, 50], [99, 50], [50, 2], [2, 50], [50, 3], [3, 50], [50, 4], [4, 50]]) == 8\n assert candidate(x = 5000,y = 5000,points = [[4999, 4999], [5001, 5001], [4998, 5000], [5000, 4998], [5000, 5001], [5001, 5000], [4999, 5001], [5001, 4999]]) == 4\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [10, 5], [5, 10], [10, 10]]) == 5\n assert candidate(x = 100,y = 100,points = [[99, 100], [100, 99], [98, 100], [100, 98], [99, 99], [101, 100], [100, 101]]) == 0\n assert candidate(x = 5000,y = 5000,points = [[1, 1], [10000, 10000], [5000, 1], [1, 5000], [5000, 5001], [5001, 5000]]) == 4\n assert candidate(x = 100,y = 100,points = [[100, 99], [99, 100], [101, 100], [100, 101], [100, 100]]) == 4\n assert candidate(x = 10,y = 10,points = [[10, 10], [9, 10], [10, 9], [11, 10], [10, 11], [9, 9], [11, 11]]) == 0\n assert candidate(x = 7,y = 7,points = [[6, 7], [8, 7], [7, 6], [7, 8], [5, 7], [7, 5], [9, 7], [7, 9], [7, 7], [6, 6], [8, 8]]) == 8\n assert candidate(x = 5000,y = 5000,points = [[5000, 5001], [5001, 5000], [4999, 5000], [5000, 4999], [5000, 5000], [1, 1], [10000, 10000]]) == 4\n assert candidate(x = 50,y = 50,points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == 4\n assert candidate(x = 3,y = 3,points = [[1, 3], [2, 3], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 3], [5, 3]]) == 4\n assert candidate(x = 10000,y = 10000,points = [[10000, 9999], [9999, 10000], [10000, 10000], [5000, 5000]]) == 2\n assert candidate(x = 25,y = 25,points = [[25, 10], [10, 25], [25, 15], [15, 25], [25, 20], [20, 25], [25, 5], [5, 25], [25, 30], [30, 25]]) == 4\n assert candidate(x = 15,y = 20,points = [[15, 1], [1, 20], [15, 3], [3, 20], [15, 4], [4, 20], [15, 5], [5, 20], [15, 6], [6, 20]]) == 9\n assert candidate(x = 20,y = 15,points = [[15, 20], [20, 15], [10, 10], [25, 25], [5, 5], [30, 30], [15, 15], [20, 20]]) == 1\n assert candidate(x = 10,y = 10,points = [[10, 1], [1, 10], [10, 10], [9, 10], [10, 9]]) == 2\n assert candidate(x = 8,y = 7,points = [[8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9], [8, 10]]) == 6\n", "comparison": "exact"}, "public_tests": ["3\n4\n[[1,2],[3,1],[2,4],[2,3],[4,4]]", "3\n4\n[[3,4]]", "3\n4\n[[2,3]]"], "hints": ["Iterate through each point, and keep track of the current point with the smallest Manhattan distance from your current location."], "metadata": {"canonical_parameter_names": ["x", "y", "points"], "leetcode_dataset_entry_point": "Solution().nearestValidPoint", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:30+00:00", "tests_total": 121, "tests_dropped": 9, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def nearestValidPoint(self, x: int, y: int, points: list[list[int]]) -> int:", "container": "Solution", "callable": "nearestValidPoint", "parameters": [{"name": "x", "type": "int"}, {"name": "y", "type": "int"}, {"name": "points", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1780, "task_id": "check-if-number-is-a-sum-of-powers-of-three", "difficulty": "Medium", "problem_description": "Given an integer n, return true if it is possible to represent n as the sum of distinct powers of three. Otherwise, return false.\n\nAn integer y is a power of three if there exists an integer x such that y == 3^x.\n\nExample 1:\n\nInput: n = 12\nOutput: true\nExplanation: 12 = 3^1 + 3^2\n\nExample 2:\n\nInput: n = 91\nOutput: true\nExplanation: 91 = 3^0 + 3^2 + 3^4\n\nExample 3:\n\nInput: n = 21\nOutput: false\n\nConstraints:\n\n- 1 <= n <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 59049) == True\n assert candidate(n = 3) == True\n assert candidate(n = 729) == True\n assert candidate(n = 12) == True\n assert candidate(n = 243) == True\n assert candidate(n = 21) == False\n assert candidate(n = 4782969) == True\n assert candidate(n = 19683) == True\n assert candidate(n = 1594323) == True\n assert candidate(n = 40) == True\n assert candidate(n = 59048) == False\n assert candidate(n = 1093) == True\n assert candidate(n = 10000000) == False\n assert candidate(n = 100000) == False\n assert candidate(n = 27) == True\n assert candidate(n = 6561) == True\n assert candidate(n = 3645) == False\n assert candidate(n = 2187) == True\n assert candidate(n = 177147) == True\n assert candidate(n = 91) == True\n assert candidate(n = 81) == True\n assert candidate(n = 531441) == True\n assert candidate(n = 1000000) == False\n assert candidate(n = 1000001) == False\n assert candidate(n = 9) == True\n assert candidate(n = 98415) == False\n assert candidate(n = 1) == True\n assert candidate(n = 10) == True\n assert candidate(n = 89076) == False\n assert candidate(n = 9999999) == False\n assert candidate(n = 98416) == False\n assert candidate(n = 39856) == False\n assert candidate(n = 1640261) == False\n assert candidate(n = 59050) == True\n assert candidate(n = 9876543) == False\n assert candidate(n = 32804) == False\n assert candidate(n = 819) == True\n assert candidate(n = 9841) == True\n assert candidate(n = 8) == False\n assert candidate(n = 810000) == False\n assert candidate(n = 8191) == False\n assert candidate(n = 72900) == False\n assert candidate(n = 524880) == False\n assert candidate(n = 7290) == True\n assert candidate(n = 11) == False\n assert candidate(n = 1048575) == False\n assert candidate(n = 59250) == False\n assert candidate(n = 109355) == False\n assert candidate(n = 10935) == False\n assert candidate(n = 98414) == False\n assert candidate(n = 2391484) == True\n assert candidate(n = 88572) == True\n assert candidate(n = 32805) == False\n assert candidate(n = 88573) == True\n assert candidate(n = 50000) == False\n assert candidate(n = 1049755) == False\n assert candidate(n = 590490) == True\n assert candidate(n = 4) == True\n assert candidate(n = 98411) == False\n assert candidate(n = 6560) == False\n assert candidate(n = 4100) == False\n assert candidate(n = 19684) == True\n assert candidate(n = 531442) == True\n assert candidate(n = 49308) == False\n assert candidate(n = 39858) == False\n assert candidate(n = 59047) == False\n assert candidate(n = 99018) == False\n assert candidate(n = 98409) == False\n assert candidate(n = 58324) == False\n assert candidate(n = 48619) == False\n assert candidate(n = 69192) == False\n assert candidate(n = 369059) == False\n assert candidate(n = 4052555) == False\n assert candidate(n = 1291401) == False\n assert candidate(n = 98413) == False\n assert candidate(n = 131220) == False\n assert candidate(n = 437400) == False\n assert candidate(n = 2) == False\n assert candidate(n = 4000000) == False\n assert candidate(n = 981) == True\n assert candidate(n = 97656) == False\n assert candidate(n = 3986) == False\n assert candidate(n = 19682) == False\n assert candidate(n = 797162) == False\n assert candidate(n = 656100) == False\n assert candidate(n = 45927) == False\n assert candidate(n = 79134) == False\n assert candidate(n = 1234567) == False\n assert candidate(n = 3125) == False\n assert candidate(n = 2097152) == False\n assert candidate(n = 98410) == False\n assert candidate(n = 99999) == False\n assert candidate(n = 728997) == False\n assert candidate(n = 405224) == False\n assert candidate(n = 31259) == False\n assert candidate(n = 119050) == False\n assert candidate(n = 104976) == False\n assert candidate(n = 546789) == False\n assert candidate(n = 39366) == False\n assert candidate(n = 40000) == False\n assert candidate(n = 29524) == True\n assert candidate(n = 98412) == False\n assert candidate(n = 400) == False\n assert candidate(n = 32806) == False\n assert candidate(n = 3188646) == False\n assert candidate(n = 123456) == False\n", "comparison": "exact"}, "public_tests": ["12", "91", "21"], "hints": ["Let's note that the maximum power of 3 you'll use in your soln is 3^16", "The number can not be represented as a sum of powers of 3 if it's ternary presentation has a 2 in it"], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().checkPowersOfThree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:33+00:00", "tests_total": 110, "tests_dropped": 4, "flags": [], "topic_tags": ["math"]}, "language": "python", "interface": {"raw_signature": "def checkPowersOfThree(self, n: int) -> bool:", "container": "Solution", "callable": "checkPowersOfThree", "parameters": [{"name": "n", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1781, "task_id": "sum-of-beauty-of-all-substrings", "difficulty": "Medium", "problem_description": "The beauty of a string is the difference in frequencies between the most frequent and least frequent characters.\n\n- For example, the beauty of \"abaacc\" is 3 - 1 = 2.\n\nGiven a string s, return the sum of beauty of all of its substrings.\n\nExample 1:\n\nInput: s = \"aabcb\"\nOutput: 5\nExplanation: The substrings with non-zero beauty are [\"aab\",\"aabc\",\"aabcb\",\"abcb\",\"bcb\"], each with beauty equal to 1.\n\nExample 2:\n\nInput: s = \"aabcbaa\"\nOutput: 17\n\nConstraints:\n\n- 1 <= s.length <=500\n- s consists of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"xyzzxyzzxyzz\") == 87\n assert candidate(s = \"aaabbbccc\") == 29\n assert candidate(s = \"aabcb\") == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(s = \"abcdedcba\") == 16\n assert candidate(s = \"a\") == 0\n assert candidate(s = \"abcabcabc\") == 16\n assert candidate(s = \"zzzz\") == 0\n assert candidate(s = \"aabcbaa\") == 17\n assert candidate(s = \"pqrspqrspqrspqrs\") == 63\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 0\n assert candidate(s = \"xyzxyzxyz\") == 16\n assert candidate(s = \"abcdabcdabcd\") == 30\n assert candidate(s = \"abc\") == 0\n assert candidate(s = \"xyzzxyzz\") == 25\n assert candidate(s = \"abcd\") == 0\n assert candidate(s = \"aabbccddeeff\") == 40\n assert candidate(s = \"zzzzz\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 950\n assert candidate(s = \"abcdefg\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\") == 1112\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 432\n assert candidate(s = \"pqrstuvwxyzabcdefghijklmno\") == 0\n assert candidate(s = \"abccbaabccbaabccbaabccba\") == 222\n assert candidate(s = \"verycomplicatedstringwithrepeatedcharactersrepeatedrepeated\") == 5556\n assert candidate(s = \"mississippimississippimississippimississippi\") == 4387\n assert candidate(s = \"abracadabra\") == 64\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 2236\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacaba\") == 11131\n assert candidate(s = \"abcabcabcabc\") == 33\n assert candidate(s = \"xzyxzxyzxyz\") == 34\n assert candidate(s = \"abcdefabcdeabcdeabcde\") == 183\n assert candidate(s = \"aabacababa\") == 66\n assert candidate(s = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"abcdefghijklmabcdefghijklm\") == 90\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 1170\n assert candidate(s = \"abababababababababababababababab\") == 240\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabc\") == 456\n assert candidate(s = \"mississippiissiippiisppiiiiiiii\") == 1732\n assert candidate(s = \"abacabadabacabadabacabadabacaba\") == 2047\n assert candidate(s = \"thisisaverylongandcomplicatedstringwithvariouscharacters\") == 2645\n assert candidate(s = \"mnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 325\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 513\n assert candidate(s = \"kayak\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 261\n assert candidate(s = \"xyzzzzxyzzzzxyzzzzxyzzzz\") == 1254\n assert candidate(s = \"ababababababab\") == 42\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\") == 1\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdef\") == 400\n assert candidate(s = \"abcdabcdabcdabcd\") == 63\n assert candidate(s = \"level\") == 4\n assert candidate(s = \"ppppppppppppppppppppppppppppppppppqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 13090\n assert candidate(s = \"xyzzyxzyxzyzyx\") == 87\n assert candidate(s = \"pqrsrstsrqpqrs\") == 102\n assert candidate(s = \"madam\") == 4\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 1053\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwerty\") == 21\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 2450\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggg\") == 630\n assert candidate(s = \"abacabadabacaba\") == 231\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\") == 702\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 44628\n assert candidate(s = \"xyzzazxzy\") == 45\n assert candidate(s = \"abababababababababababababababababababababababab\") == 552\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\") == 1275\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 1350\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjaabbccddeeffgghhiijjaabbccddeeffgghhiijj\") == 2118\n assert candidate(s = \"bananaananabananananabananananananananananananana\") == 7610\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"banana\") == 8\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzz\") == 11722\n assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrs\") == 1071\n assert candidate(s = \"aabbccddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxxyyyzzz\") == 4312\n assert candidate(s = \"aaaaabbbbccccddddeeeffffggghhh\") == 782\n assert candidate(s = \"nnnnoonnmnmlmllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll\") == 33629\n assert candidate(s = \"aaaabbbbccccdddd\") == 162\n assert candidate(s = \"abacabadabacabadabacabad\") == 948\n assert candidate(s = \"deified\") == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"repaper\") == 9\n assert candidate(s = \"xyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzz\") == 17541\n assert candidate(s = \"aabbaaabbbaaabbaaaabbbaaabbaaaabbbaaabbaaaabbbaaabbaaaab\") == 5129\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzz\") == 11950\n assert candidate(s = \"aabbccddeeffgghhiijjanmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 1979\n assert candidate(s = \"abababababababababababab\") == 132\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 350\n assert candidate(s = \"rotor\") == 4\n assert candidate(s = \"racecar\") == 9\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 320\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 161\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 350\n assert candidate(s = \"reviled\") == 4\n assert candidate(s = \"mnopqrnopqmonmnopq\") == 145\n assert candidate(s = \"abacabadaba\") == 85\n assert candidate(s = \"mississippi\") == 64\n assert candidate(s = \"aaaaabbbbccccddddeeeffffgggghhhhiiiiijjjjkkkkllllmmmmmnnnnnooooo\") == 4941\n assert candidate(s = \"abcabcabcabcabc\") == 56\n assert candidate(s = \"xyzzzzzxyzzzzzxyzzzzz\") == 936\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"refer\") == 4\n", "comparison": "exact"}, "public_tests": ["\"aabcb\"", "\"aabcbaa\""], "hints": ["Maintain a prefix sum for the frequencies of characters.", "You can iterate over all substring then iterate over the alphabet and find which character appears most and which appears least using the prefix sum array"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().beautySum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:35+00:00", "tests_total": 103, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def beautySum(self, s: str) -> int:", "container": "Solution", "callable": "beautySum", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1782, "task_id": "count-pairs-of-nodes", "difficulty": "Hard", "problem_description": "You are given an undirected graph defined by an integer n, the number of nodes, and a 2D integer array edges, the edges in the graph, where edges[i] = [u_i, v_i] indicates that there is an undirected edge between u_i and v_i. You are also given an integer array queries.\n\nLet incident(a, b) be defined as the number of edges that are connected to either node a or b.\n\nThe answer to the j^th query is the number of pairs of nodes (a, b) that satisfy both of the following conditions:\n\n- a < b\n- incident(a, b) > queries[j]\n\nReturn an array answers such that answers.length == queries.length and answers[j] is the answer of the j^th query.\n\nNote that there can be multiple edges between the same two nodes.\n\nExample 1:\n\nInput: n = 4, edges = [[1,2],[2,4],[1,3],[2,3],[2,1]], queries = [2,3]\nOutput: [6,5]\nExplanation: The calculations for incident(a, b) are shown in the table above.\nThe answers for each of the queries are as follows:\n- answers[0] = 6. All the pairs have an incident(a, b) value greater than 2.\n- answers[1] = 5. All the pairs except (3, 4) have an incident(a, b) value greater than 3.\n\nExample 2:\n\nInput: n = 5, edges = [[1,5],[1,5],[3,4],[2,5],[1,3],[5,1],[2,3],[2,5]], queries = [1,2,3,4,5]\nOutput: [10,10,9,8,6]\n\nConstraints:\n\n- 2 <= n <= 2 * 10^4\n- 1 <= edges.length <= 10^5\n- 1 <= u_i, v_i <= n\n- u_i!= v_i\n- 1 <= queries.length <= 20\n- 0 <= queries[j] < edges.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[1, 2], [2, 4], [1, 3], [2, 3], [2, 1]],queries = [2, 3]) == [6, 5]\n assert candidate(n = 5,edges = [[1, 5], [1, 5], [3, 4], [2, 5], [1, 3], [5, 1], [2, 3], [2, 5]],queries = [1, 2, 3, 4, 5]) == [10, 10, 9, 8, 6]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [9, 10]],queries = [5, 10, 15]) == [45, 8, 0]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20]],queries = [3, 4, 5, 6]) == [190, 187, 183, 148]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15]],queries = [7, 8, 9, 10, 11]) == [75, 69, 24, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]],queries = [3, 5, 7, 9]) == [41, 33, 1, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10]],queries = [5, 6, 7]) == [16, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]],queries = [1, 5, 9]) == [45, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 6], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 7]],queries = [3, 8, 13]) == [176, 15, 0]\n assert candidate(n = 100,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 1], [10, 2], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 1], [9, 2], [10, 3], [1, 4], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 1], [8, 2], [9, 3], [10, 4]],queries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [945, 945, 945, 945, 945, 945, 945, 765, 45, 45, 45]\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20]],queries = [5, 15, 25, 35, 45]) == [190, 85, 10, 10, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14], [8, 15]],queries = [10, 12, 14]) == [12, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30], [29, 1], [30, 2]],queries = [15, 20, 25, 30, 35]) == [0, 0, 0, 0, 0]\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [1, 25], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25]],queries = [4, 9, 14]) == [300, 0, 0]\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15], [14, 16], [15, 16], [15, 17], [16, 17], [16, 18], [17, 18], [17, 19], [18, 19], [19, 20], [19, 21], [20, 21], [20, 22], [20, 23], [21, 22], [21, 23], [22, 23], [22, 24], [22, 25], [23, 24], [23, 25], [24, 25]],queries = [6, 12, 18, 24]) == [283, 0, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10], [2, 5], [3, 7], [4, 8], [5, 9], [6, 10]],queries = [4, 5, 6, 7, 8]) == [43, 28, 4, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [2, 30], [3, 29], [4, 28], [5, 27], [6, 26], [7, 25], [8, 24], [9, 23], [10, 22], [11, 21], [12, 20], [13, 19], [14, 18], [15, 17], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]],queries = [20, 25, 30, 35, 40, 45]) == [29, 29, 14, 0, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21], [11, 20], [12, 19], [13, 18], [14, 17], [15, 16]],queries = [0, 5, 10, 15, 20, 25, 30]) == [435, 338, 0, 0, 0, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [13, 14], [13, 15], [14, 15], [14, 16], [15, 16], [15, 17], [16, 17], [16, 18], [17, 18], [17, 19], [18, 19], [19, 20], [20, 1]],queries = [5, 10, 15, 20]) == [184, 0, 0, 0]\n assert candidate(n = 50,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30], [29, 31], [30, 32], [31, 33], [32, 34], [33, 35], [34, 36], [35, 37], [36, 38], [37, 39], [38, 40], [39, 41], [40, 42], [41, 43], [42, 44], [43, 45], [44, 46], [45, 47], [46, 48], [47, 49], [48, 50]],queries = [10, 20, 30, 40, 50]) == [0, 0, 0, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 1], [12, 2]],queries = [3, 4, 5, 6, 7]) == [66, 66, 66, 66, 42]\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 1], [25, 2], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17], [15, 18], [16, 19], [17, 20], [18, 21], [19, 22], [20, 23], [21, 24], [22, 25], [23, 1], [24, 2], [25, 3]],queries = [10, 15, 20, 25, 30]) == [300, 0, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14], [8, 15], [9, 1], [10, 2], [11, 3], [12, 4], [13, 5], [14, 6], [15, 7]],queries = [10, 15, 20, 25]) == [0, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 2], [1, 3], [2, 3], [2, 3], [2, 4], [3, 4], [3, 5], [4, 5], [4, 6], [5, 6], [5, 7], [6, 7], [6, 8], [7, 8], [7, 9], [8, 9], [8, 10], [9, 10], [9, 11], [10, 11], [10, 12], [11, 12], [11, 13], [12, 13], [12, 14], [13, 14], [13, 15], [14, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [105, 105, 105, 104, 102, 89, 51, 17, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],queries = [3, 4, 5, 6, 7, 8]) == [136, 0, 0, 0, 0, 0]\n assert candidate(n = 18,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 1], [18, 2]],queries = [5, 10, 15, 20]) == [153, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 15], [1, 15], [2, 15], [3, 15], [4, 15]],queries = [8, 9, 10, 11]) == [6, 0, 0, 0]\n assert candidate(n = 100,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 5], [2, 6], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50], [50, 51], [51, 52], [52, 53], [53, 54], [54, 55], [55, 56], [56, 57], [57, 58], [58, 59], [59, 60], [60, 61], [61, 62], [62, 63], [63, 64], [64, 65], [65, 66], [66, 67], [67, 68], [68, 69], [69, 70], [70, 71], [71, 72], [72, 73], [73, 74], [74, 75], [75, 76], [76, 77], [77, 78], [78, 79], [79, 80], [80, 81], [81, 82], [82, 83], [83, 84], [84, 85], [85, 86], [86, 87], [87, 88], [88, 89], [89, 90], [90, 91], [91, 92], [92, 93], [93, 94], [94, 95], [95, 96], [96, 97], [97, 98], [98, 99], [99, 100]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20]],queries = [5, 10, 15, 20, 25]) == [187, 0, 0, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [9, 10]],queries = [5, 10, 15]) == [45, 8, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [5, 6, 7]) == [8, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [4, 8], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [6, 10], [7, 8], [7, 9], [7, 10], [7, 11], [8, 9], [8, 10], [8, 11], [8, 12], [9, 10], [9, 11], [9, 12], [9, 13], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [11, 15], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15]],queries = [10, 20, 30, 40]) == [91, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8]],queries = [1, 2, 3, 4, 5]) == [28, 28, 28, 28, 28]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [1, 12], [2, 13], [3, 14], [4, 15], [5, 16], [6, 17], [7, 18], [8, 19], [9, 20]],queries = [10, 15, 20, 25]) == [0, 0, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15], [14, 16], [15, 16], [15, 17], [16, 17], [16, 18], [17, 18], [17, 19], [18, 19], [19, 20], [19, 21], [20, 21], [20, 22], [20, 23], [21, 22], [21, 23], [22, 23], [22, 24], [22, 25], [23, 24], [23, 25], [24, 25], [24, 26], [24, 27], [25, 26], [25, 27], [26, 27], [26, 28], [26, 29], [27, 28], [27, 29], [28, 29], [28, 30], [29, 30]],queries = [7, 14, 21, 28]) == [360, 0, 0, 0]\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 1], [25, 2]],queries = [15, 20, 25, 30]) == [0, 0, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],queries = [5, 10, 15]) == [36, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]],queries = [4, 8, 12, 16]) == [76, 1, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30]],queries = [5, 10, 15]) == [432, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [1, 15]],queries = [2, 7, 12]) == [105, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 5], [2, 6], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]],queries = [5, 6, 7]) == [19, 4, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]],queries = [5, 10, 15]) == [24, 7, 0]\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 1], [15, 2], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 1], [14, 2], [15, 3]],queries = [10, 15, 20, 25, 30]) == [105, 0, 0, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],queries = [0, 5, 10, 15, 20]) == [190, 128, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [1, 15], [2, 14], [3, 13], [4, 12], [5, 11], [6, 10], [7, 9]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [105, 105, 104, 98, 50, 0, 0, 0, 0, 0]\n", "comparison": "exact"}, "public_tests": ["4\n[[1,2],[2,4],[1,3],[2,3],[2,1]]\n[2,3]", "5\n[[1,5],[1,5],[3,4],[2,5],[1,3],[5,1],[2,3],[2,5]]\n[1,2,3,4,5]"], "hints": ["We want to count pairs (x,y) such that degree[x] + degree[y] - occurrences(x,y) > k", "Think about iterating on x, and counting the number of valid y to pair with x.", "You can consider at first that the (- occurrences(x,y)) isn't there, or it is 0 at first for all y. Count the valid y this way.", "Then you can iterate on the neighbors of x, let that neighbor be y, and update occurrences(x,y).", "When you update occurrences(x,y), the left-hand side decreases. Once it reaches k, then y is not valid for x anymore, so you should decrease the answer by 1."], "metadata": {"canonical_parameter_names": ["n", "edges", "queries"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:37+00:00", "tests_total": 50, "tests_dropped": 5, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "hash-table", "two-pointers", "binary-search", "graph", "sorting", "counting"]}, "language": "python", "interface": {"raw_signature": "def countPairs(self, n: int, edges: list[list[int]], queries: list[int]) -> list[int]:", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "queries", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1784, "task_id": "check-if-binary-string-has-at-most-one-segment-of-ones", "difficulty": "Easy", "problem_description": "Given a binary string s without leading zeros, return true if s contains at most one contiguous segment of ones. Otherwise, return false.\n\nExample 1:\n\nInput: s = \"1001\"\nOutput: false\nExplanation: The string has two segments of size 1.\n\nExample 2:\n\nInput: s = \"110\"\nOutput: true\n\nConstraints:\n\n- 1 <= s.length <= 100\n- s[i] is either '0' or '1'.\n- s[0] is '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == True\n assert candidate(s = \"1000001\") == False\n assert candidate(s = \"111\") == True\n assert candidate(s = \"11110000\") == True\n assert candidate(s = \"100000\") == True\n assert candidate(s = \"11000\") == True\n assert candidate(s = \"111000\") == True\n assert candidate(s = \"1001001\") == False\n assert candidate(s = \"1111111111\") == True\n assert candidate(s = \"100001\") == False\n assert candidate(s = \"1000000000\") == True\n assert candidate(s = \"101\") == False\n assert candidate(s = \"10\") == True\n assert candidate(s = \"110\") == True\n assert candidate(s = \"110001\") == False\n assert candidate(s = \"1010101010\") == False\n assert candidate(s = \"1\") == True\n assert candidate(s = \"1100111\") == False\n assert candidate(s = \"101010\") == False\n assert candidate(s = \"111110000\") == True\n assert candidate(s = \"1001\") == False\n assert candidate(s = \"11001\") == False\n assert candidate(s = \"101010101010101\") == False\n assert candidate(s = \"1000000000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"11110000001\") == False\n assert candidate(s = \"111000111000111000111000111000111000111000111000111\") == False\n assert candidate(s = \"111000111000111000\") == False\n assert candidate(s = \"1000000000000000000000000001\") == False\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"1000010001000100\") == False\n assert candidate(s = \"10000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"1111111\") == True\n assert candidate(s = \"111000111000111\") == False\n assert candidate(s = \"111111111111111111111\") == True\n assert candidate(s = \"1100110011\") == False\n assert candidate(s = \"11100000000000\") == True\n assert candidate(s = \"1010101010101010\") == False\n assert candidate(s = \"10000000000000000000\") == True\n assert candidate(s = \"111100000000\") == True\n assert candidate(s = \"11110001\") == False\n assert candidate(s = \"1111111111111110000000000001111111111111\") == False\n assert candidate(s = \"11110000111100001111\") == False\n assert candidate(s = \"101010101010\") == False\n assert candidate(s = \"111000000000000000000\") == True\n assert candidate(s = \"111111111111110000000000000\") == True\n assert candidate(s = \"100000000000100000\") == False\n assert candidate(s = \"100000000000\") == True\n assert candidate(s = \"1110001\") == False\n assert candidate(s = \"1111111111111111\") == True\n assert candidate(s = \"1001001001\") == False\n assert candidate(s = \"1000000000000000000000000000000000000001\") == False\n assert candidate(s = \"100000000000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"1111111000000\") == True\n assert candidate(s = \"111011101110111011101\") == False\n assert candidate(s = \"100000000000000000001\") == False\n assert candidate(s = \"11100000000111\") == False\n assert candidate(s = \"100000000001\") == False\n assert candidate(s = \"1001001001001001\") == False\n assert candidate(s = \"100000000000000\") == True\n assert candidate(s = \"10000000001\") == False\n assert candidate(s = \"111000111000\") == False\n assert candidate(s = \"10111000110\") == False\n assert candidate(s = \"111100001111\") == False\n assert candidate(s = \"100010001000100010001\") == False\n assert candidate(s = \"1000000000000000\") == True\n assert candidate(s = \"111110111111\") == False\n assert candidate(s = \"111111000000\") == True\n assert candidate(s = \"11011011011011011011\") == False\n assert candidate(s = \"1000000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"11010101010101\") == False\n assert candidate(s = \"11111000001\") == False\n assert candidate(s = \"1000100010\") == False\n assert candidate(s = \"1110000000000001\") == False\n assert candidate(s = \"10000000100000001\") == False\n assert candidate(s = \"100000010000001000000\") == False\n assert candidate(s = \"10000100001\") == False\n assert candidate(s = \"1110000000\") == True\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"10101010101010101\") == False\n assert candidate(s = \"11100000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"1111000011110000\") == False\n assert candidate(s = \"10101010101010101010101010101010\") == False\n assert candidate(s = \"1111100000\") == True\n assert candidate(s = \"1111000000001111\") == False\n assert candidate(s = \"11110000100001110000\") == False\n assert candidate(s = \"1101101101\") == False\n assert candidate(s = \"1001001001001\") == False\n assert candidate(s = \"1110111100001\") == False\n assert candidate(s = \"110001000000\") == False\n assert candidate(s = \"111111111100\") == True\n assert candidate(s = \"1100000000000001\") == False\n assert candidate(s = \"10000000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"11001100110011\") == False\n assert candidate(s = \"1110000000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"11000001111\") == False\n assert candidate(s = \"11111111110000000000000000000000000000000000000000\") == True\n assert candidate(s = \"1111000011\") == False\n assert candidate(s = \"10101010101010101010\") == False\n assert candidate(s = \"10000111111110\") == False\n assert candidate(s = \"10000111110001\") == False\n assert candidate(s = \"10101010101010\") == False\n assert candidate(s = \"1000001000001000001\") == False\n assert candidate(s = \"1000000010000\") == False\n assert candidate(s = \"10000000000001\") == False\n assert candidate(s = \"11100001\") == False\n assert candidate(s = \"1000000000000001\") == False\n", "comparison": "exact"}, "public_tests": ["\"1001\"", "\"110\""], "hints": ["It's guaranteed to have at least one segment", "The string size is small so you can count all segments of ones with no that have no adjacent ones."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().checkOnesSegment", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:40+00:00", "tests_total": 113, "tests_dropped": 6, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def checkOnesSegment(self, s: str) -> bool:", "container": "Solution", "callable": "checkOnesSegment", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1785, "task_id": "minimum-elements-to-add-to-form-a-given-sum", "difficulty": "Medium", "problem_description": "You are given an integer array nums and two integers limit and goal. The array nums has an interesting property that abs(nums[i]) <= limit.\n\nReturn the minimum number of elements you need to add to make the sum of the array equal to goal. The array must maintain its property that abs(nums[i]) <= limit.\n\nNote that abs(x) equals x if x >= 0, and -x otherwise.\n\nExample 1:\n\nInput: nums = [1,-1,1], limit = 3, goal = -4\nOutput: 2\nExplanation: You can add -2 and -3, then the sum of the array will be 1 - 1 + 1 - 2 - 3 = -4.\n\nExample 2:\n\nInput: nums = [1,-10,9,1], limit = 100, goal = 0\nOutput: 1\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= limit <= 10^6\n- -limit <= nums[i] <= limit\n- -10^9 <= goal <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, -1, 1],limit = 3,goal = -4) == 2\n assert candidate(nums = [1, -10, 9, 1],limit = 100,goal = 0) == 1\n assert candidate(nums = [0, 0, 0],limit = 1,goal = 3) == 3\n assert candidate(nums = [0, 0, 0, 0],limit = 5,goal = 10) == 2\n assert candidate(nums = [2, 2, 2],limit = 2,goal = 6) == 0\n assert candidate(nums = [-5, -5, -5],limit = 5,goal = 15) == 6\n assert candidate(nums = [999999, -999999, 999998, -999998, 999997, -999997],limit = 1000000,goal = -1000000) == 1\n assert candidate(nums = [1000000, -1000000, 500000, -500000],limit = 1000000,goal = 0) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 2,goal = -15) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = -10) == 20\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000],limit = 1000000,goal = 0) == 5\n assert candidate(nums = [5, -5, 5, -5, 5, -5],limit = 5,goal = 10) == 2\n assert candidate(nums = [999999, 999999, 999999],limit = 1000000,goal = -2999997) == 6\n assert candidate(nums = [999999, -999999, 999999, -999999, 999999, -999999],limit = 1000000,goal = 0) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 1,goal = -20) == 10\n assert candidate(nums = [1000000, -1000000, 1000000],limit = 1000000,goal = 3000000) == 2\n assert candidate(nums = [999999, 999998, 999997, 999996],limit = 999999,goal = 3999990) == 0\n assert candidate(nums = [1000000, -1000000, 500000],limit = 1000000,goal = 0) == 1\n assert candidate(nums = [1000, -1000, 1000, -1000],limit = 1000,goal = 1000) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 10,goal = 55) == 0\n assert candidate(nums = [5, -5, 5, -5, 5],limit = 10,goal = -15) == 2\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 1,goal = -5) == 5\n assert candidate(nums = [100, -50, 25],limit = 100,goal = 200) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = 15) == 5\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],limit = 5,goal = -10) == 2\n assert candidate(nums = [1000000, -1000000, 500000],limit = 1000000,goal = 1000000) == 1\n assert candidate(nums = [-100, 100, -100, 100],limit = 100,goal = 0) == 0\n assert candidate(nums = [-100000, 100000, -100000, 100000, -100000],limit = 100000,goal = 50000) == 2\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 1,goal = 5) == 5\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],limit = 100000,goal = 600000) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = 10) == 0\n assert candidate(nums = [5, -5, 5, -5],limit = 5,goal = 10) == 2\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 1,goal = 1) == 1\n assert candidate(nums = [-5, 5, -5, 5, -5],limit = 5,goal = 0) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 10,goal = 0) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 5,goal = 10) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],limit = 10,goal = 0) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 1,goal = 0) == 0\n assert candidate(nums = [-999999, -999999, -999999],limit = 1000000,goal = 2999997) == 6\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 1,goal = -15) == 5\n assert candidate(nums = [-1, -1, -1, -1, -1],limit = 3,goal = 5) == 4\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 2,goal = 0) == 0\n assert candidate(nums = [1, -1, 1, -1, 1],limit = 1,goal = -1) == 2\n assert candidate(nums = [-5, 3, 2, -4, 1],limit = 5,goal = -10) == 2\n assert candidate(nums = [999999, -999999, 999999, -999999, 999999],limit = 1000000,goal = 4999995) == 4\n assert candidate(nums = [-1, 0, 1],limit = 1,goal = -1000000) == 1000000\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 2,goal = -30) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 3,goal = 20) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = 5) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = 20) == 10\n assert candidate(nums = [-999999, -999999, -999999, -999999, -999999],limit = 1000000,goal = -5000000) == 1\n assert candidate(nums = [1, -2, 3, -4, 5],limit = 5,goal = 0) == 1\n assert candidate(nums = [999999, 999999, 999999, 999999, 999999],limit = 1000000,goal = 5000000) == 1\n assert candidate(nums = [-1000000, -1000000, -1000000, -1000000, -1000000],limit = 1000000,goal = 0) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 10,goal = 5) == 1\n assert candidate(nums = [-999999, -999998, -999997, -999996],limit = 999999,goal = -3999990) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],limit = 10,goal = -55) == 0\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000],limit = 1000000,goal = 500000) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],limit = 1000000,goal = 10000000) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],limit = 100,goal = 500) == 5\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 2,goal = -20) == 5\n", "comparison": "exact"}, "public_tests": ["[1,-1,1]\n3\n-4", "[1,-10,9,1]\n100\n0"], "hints": ["Try thinking about the problem as if the array is empty. Then you only need to form goal using elements whose absolute value is <= limit.", "You can greedily set all of the elements except one to limit or -limit, so the number of elements you need is ceil(abs(goal)/ limit).", "You can \"normalize\" goal by offsetting it by the sum of the array. For example, if the goal is 5 and the sum is -3, then it's exactly the same as if the goal is 8 and the array is empty.", "The answer is ceil(abs(goal-sum)/limit) = (abs(goal-sum)+limit-1) / limit."], "metadata": {"canonical_parameter_names": ["nums", "limit", "goal"], "leetcode_dataset_entry_point": "Solution().minElements", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:42+00:00", "tests_total": 106, "tests_dropped": 45, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minElements(self, nums: list[int], limit: int, goal: int) -> int:", "container": "Solution", "callable": "minElements", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "limit", "type": "int"}, {"name": "goal", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1786, "task_id": "number-of-restricted-paths-from-first-to-last-node", "difficulty": "Medium", "problem_description": "There is an undirected weighted connected graph. You are given a positive integer n which denotes that the graph has n nodes labeled from 1 to n, and an array edges where each edges[i] = [u_i, v_i, weight_i] denotes that there is an edge between nodes u_i and v_i with weight equal to weight_i.\n\nA path from node start to node end is a sequence of nodes [z_0, z_1,z_2, ..., z_k] such that z_0= start and z_k = end and there is an edge between z_i and z_{i+1} where 0 <= i <= k-1.\n\nThe distance of a path is the sum of the weights on the edges of the path. Let distanceToLastNode(x) denote the shortest distance of a path between node n and node x. A restricted path is a path that also satisfies that distanceToLastNode(z_i) > distanceToLastNode(z_{i+1}) where 0 <= i <= k-1.\n\nReturn the number of restricted paths from node 1 to node n. Since that number may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 5, edges = [[1,2,3],[1,3,3],[2,3,1],[1,4,2],[5,2,2],[3,5,1],[5,4,10]]\nOutput: 3\nExplanation: Each circle contains the node number in black and its distanceToLastNode value in blue. The three restricted paths are:\n1) 1 --> 2 --> 5\n2) 1 --> 2 --> 3 --> 5\n3) 1 --> 3 --> 5\n\nExample 2:\n\nInput: n = 7, edges = [[1,3,1],[4,1,2],[7,3,4],[2,5,3],[5,6,1],[6,7,2],[7,5,3],[2,6,4]]\nOutput: 1\nExplanation: Each circle contains the node number in black and its distanceToLastNode value in blue. The only restricted path is 1 --> 3 --> 7.\n\nConstraints:\n\n- 1 <= n <= 2 * 10^4\n- n - 1 <= edges.length <= 4 * 10^4\n- edges[i].length == 3\n- 1 <= u_i, v_i <= n\n- u_i!= v_i\n- 1 <= weight_i <= 10^5\n- There is at most one edge between any two nodes.\n- There is at least one path between any two nodes.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 1, 4]]) == 1\n assert candidate(n = 3,edges = [[1, 2, 5], [1, 3, 6], [2, 3, 1]]) == 2\n assert candidate(n = 7,edges = [[1, 3, 1], [4, 1, 2], [7, 3, 4], [2, 5, 3], [5, 6, 1], [6, 7, 2], [7, 5, 3], [2, 6, 4]]) == 1\n assert candidate(n = 6,edges = [[1, 2, 2], [1, 3, 4], [2, 4, 3], [3, 4, 1], [4, 5, 2], [5, 6, 1]]) == 2\n assert candidate(n = 5,edges = [[1, 2, 3], [1, 3, 3], [2, 3, 1], [1, 4, 2], [5, 2, 2], [3, 5, 1], [5, 4, 10]]) == 3\n assert candidate(n = 15,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [1, 15, 15]]) == 1\n assert candidate(n = 12,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [1, 3, 12], [2, 4, 13], [3, 5, 14], [4, 6, 15], [5, 7, 16], [6, 8, 17], [7, 9, 18], [8, 10, 19], [9, 11, 20], [10, 12, 21], [1, 4, 22], [2, 5, 23], [3, 6, 24], [4, 7, 25], [5, 8, 26], [6, 9, 27], [7, 10, 28], [8, 11, 29], [9, 12, 30]]) == 504\n assert candidate(n = 10,edges = [[1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1], [6, 7, 6], [7, 8, 5], [8, 9, 4], [9, 10, 3]]) == 1\n assert candidate(n = 20,edges = [[1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 20, 20], [1, 20, 10], [2, 19, 10], [3, 18, 10], [4, 17, 10], [5, 16, 10], [6, 15, 10], [7, 14, 10], [8, 13, 10], [9, 12, 10], [10, 11, 10]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 1], [1, 3, 4], [2, 4, 2], [3, 4, 1], [4, 5, 3], [5, 6, 2], [6, 7, 1], [7, 8, 2], [8, 9, 3], [9, 10, 1]]) == 2\n assert candidate(n = 8,edges = [[1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1], [6, 7, 6], [7, 8, 7], [8, 1, 8], [2, 5, 9], [3, 6, 10], [4, 7, 11], [1, 8, 12]]) == 2\n assert candidate(n = 10,edges = [[1, 2, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 1], [6, 7, 3], [7, 8, 2], [8, 9, 1], [9, 10, 2], [1, 10, 5]]) == 1\n assert candidate(n = 50,edges = [[1, 2, 1000], [2, 3, 2000], [3, 4, 3000], [4, 5, 4000], [5, 6, 5000], [6, 7, 6000], [7, 8, 7000], [8, 9, 8000], [9, 10, 9000], [10, 11, 10000], [11, 12, 11000], [12, 13, 12000], [13, 14, 13000], [14, 15, 14000], [15, 16, 15000], [16, 17, 16000], [17, 18, 17000], [18, 19, 18000], [19, 20, 19000], [20, 21, 20000], [21, 22, 21000], [22, 23, 22000], [23, 24, 23000], [24, 25, 24000], [25, 26, 25000], [26, 27, 26000], [27, 28, 27000], [28, 29, 28000], [29, 30, 29000], [30, 31, 30000], [31, 32, 31000], [32, 33, 32000], [33, 34, 33000], [34, 35, 34000], [35, 36, 35000], [36, 37, 36000], [37, 38, 37000], [38, 39, 38000], [39, 40, 39000], [40, 41, 40000], [41, 42, 41000], [42, 43, 42000], [43, 44, 43000], [44, 45, 44000], [45, 46, 45000], [46, 47, 46000], [47, 48, 47000], [48, 49, 48000], [49, 50, 49000]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 15, 75]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 5], [1, 3, 3], [2, 4, 7], [3, 4, 2], [4, 5, 5], [5, 6, 4], [6, 7, 8], [7, 8, 2], [8, 9, 1], [9, 10, 2], [10, 11, 3], [11, 12, 1], [12, 13, 5], [13, 14, 4], [14, 15, 6]]) == 1\n assert candidate(n = 8,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [1, 3, 8], [2, 4, 9], [3, 5, 10], [4, 6, 11], [5, 7, 12], [6, 8, 13]]) == 21\n assert candidate(n = 10,edges = [[1, 2, 4], [1, 3, 3], [2, 4, 2], [3, 4, 1], [4, 5, 5], [5, 6, 3], [6, 7, 2], [7, 8, 1], [8, 9, 4], [9, 10, 5], [2, 5, 3], [3, 6, 4], [5, 8, 2], [6, 9, 1]]) == 4\n assert candidate(n = 15,edges = [[1, 2, 2], [1, 3, 3], [2, 4, 5], [3, 5, 4], [4, 6, 1], [5, 7, 2], [6, 8, 3], [7, 9, 4], [8, 10, 5], [9, 11, 1], [10, 12, 2], [11, 13, 3], [12, 14, 4], [13, 15, 5], [4, 7, 2], [5, 8, 1], [6, 9, 4], [7, 10, 3], [8, 11, 2], [9, 12, 1], [10, 13, 4], [11, 14, 5], [12, 15, 1]]) == 7\n assert candidate(n = 30,edges = [[1, 2, 5], [2, 3, 4], [3, 4, 1], [4, 5, 3], [5, 6, 2], [6, 7, 4], [7, 8, 3], [8, 9, 5], [9, 10, 4], [10, 11, 2], [11, 12, 1], [12, 13, 3], [13, 14, 2], [14, 15, 4], [15, 16, 1], [16, 17, 2], [17, 18, 3], [18, 19, 2], [19, 20, 1], [20, 21, 5], [21, 22, 4], [22, 23, 3], [23, 24, 2], [24, 25, 4], [25, 26, 3], [26, 27, 5], [27, 28, 1], [28, 29, 2], [29, 30, 3], [30, 1, 4]]) == 1\n assert candidate(n = 25,edges = [[1, 2, 20], [1, 3, 10], [2, 4, 5], [2, 5, 15], [3, 6, 1], [3, 7, 20], [4, 8, 25], [4, 9, 1], [5, 9, 30], [5, 10, 1], [6, 11, 10], [6, 12, 25], [7, 12, 15], [7, 13, 1], [8, 14, 20], [9, 14, 5], [10, 14, 10], [11, 15, 25], [11, 16, 1], [12, 16, 30], [12, 17, 5], [13, 17, 10], [14, 18, 15], [15, 18, 1], [16, 19, 20], [17, 19, 30], [18, 20, 10], [19, 20, 25], [20, 21, 1], [21, 22, 5], [22, 23, 10], [23, 24, 15], [24, 25, 20]]) == 2\n assert candidate(n = 30,edges = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900], [10, 11, 1000], [11, 12, 1100], [12, 13, 1200], [13, 14, 1300], [14, 15, 1400], [15, 16, 1500], [16, 17, 1600], [17, 18, 1700], [18, 19, 1800], [19, 20, 1900], [20, 21, 2000], [21, 22, 2100], [22, 23, 2200], [23, 24, 2300], [24, 25, 2400], [25, 26, 2500], [26, 27, 2600], [27, 28, 2700], [28, 29, 2800], [29, 30, 2900]]) == 1\n assert candidate(n = 8,edges = [[1, 2, 5], [1, 3, 6], [2, 4, 2], [3, 5, 4], [4, 5, 3], [4, 6, 1], [5, 7, 2], [6, 8, 3], [7, 8, 1], [2, 3, 4], [4, 7, 6], [5, 6, 2], [3, 8, 5], [2, 6, 3]]) == 8\n assert candidate(n = 20,edges = [[1, 2, 2], [1, 3, 1], [2, 4, 3], [2, 5, 4], [3, 6, 5], [3, 7, 6], [4, 8, 7], [4, 9, 8], [5, 10, 9], [5, 11, 10], [6, 12, 11], [6, 13, 12], [7, 14, 13], [7, 15, 14], [8, 16, 15], [9, 17, 16], [10, 18, 17], [11, 19, 18], [12, 20, 19], [13, 18, 20], [14, 19, 11], [15, 20, 12], [16, 17, 13], [17, 18, 14], [18, 19, 15], [19, 20, 16]]) == 2\n assert candidate(n = 15,edges = [[1, 2, 10], [2, 3, 5], [3, 4, 15], [4, 5, 20], [5, 6, 25], [6, 7, 30], [7, 8, 35], [8, 9, 40], [9, 10, 45], [10, 11, 50], [11, 12, 55], [12, 13, 60], [13, 14, 65], [14, 15, 70], [1, 3, 5], [2, 4, 5], [3, 5, 5], [4, 6, 5], [5, 7, 5], [6, 8, 5], [7, 9, 5], [8, 10, 5], [9, 11, 5], [10, 12, 5], [11, 13, 5], [12, 14, 5], [13, 15, 5]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 4], [1, 3, 2], [2, 4, 1], [2, 5, 6], [3, 5, 3], [4, 6, 2], [5, 6, 1], [6, 7, 5], [6, 8, 3], [7, 9, 4], [8, 9, 2], [9, 10, 1]]) == 6\n assert candidate(n = 20,edges = [[1, 2, 2], [1, 3, 1], [2, 4, 3], [2, 5, 4], [3, 5, 2], [4, 6, 5], [4, 7, 6], [5, 6, 7], [5, 8, 8], [6, 9, 1], [7, 9, 2], [8, 10, 3], [9, 10, 4], [10, 11, 5], [11, 12, 6], [11, 13, 7], [12, 14, 8], [13, 14, 9], [14, 15, 10], [15, 16, 1], [16, 17, 2], [16, 18, 3], [17, 19, 4], [18, 19, 5], [19, 20, 6]]) == 24\n assert candidate(n = 20,edges = [[1, 2, 10], [2, 3, 9], [3, 4, 8], [4, 5, 7], [5, 6, 6], [6, 7, 5], [7, 8, 4], [8, 9, 3], [9, 10, 2], [10, 11, 1], [11, 12, 2], [12, 13, 3], [13, 14, 4], [14, 15, 5], [15, 16, 6], [16, 17, 7], [17, 18, 8], [18, 19, 9], [19, 20, 10], [1, 20, 15], [2, 19, 16], [3, 18, 17], [4, 17, 18], [5, 16, 19], [6, 15, 20]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120], [13, 14, 130], [14, 15, 140], [1, 3, 15], [3, 5, 25], [5, 7, 35], [7, 9, 45], [9, 11, 55], [11, 13, 65], [13, 15, 75], [2, 4, 25], [4, 6, 35], [6, 8, 45], [8, 10, 55], [10, 12, 65], [12, 14, 75], [2, 5, 30], [5, 8, 40], [8, 11, 50], [11, 14, 60], [3, 6, 35], [6, 9, 45], [9, 12, 55], [12, 15, 65], [4, 7, 45], [7, 10, 55], [10, 13, 65], [4, 8, 50], [8, 12, 60], [8, 13, 65], [10, 14, 75], [10, 15, 80], [5, 9, 55], [9, 13, 70], [5, 10, 60], [10, 15, 90]]) == 174\n assert candidate(n = 12,edges = [[1, 2, 5], [1, 3, 3], [2, 4, 2], [3, 4, 1], [4, 5, 4], [5, 6, 5], [6, 7, 4], [7, 8, 3], [8, 9, 2], [9, 10, 1], [10, 11, 6], [11, 12, 7]]) == 2\n assert candidate(n = 10,edges = [[1, 2, 5], [2, 3, 10], [3, 4, 15], [4, 5, 20], [5, 6, 25], [6, 7, 30], [7, 8, 35], [8, 9, 40], [9, 10, 45], [1, 3, 2], [3, 5, 3], [5, 7, 4], [7, 9, 5], [2, 4, 7], [4, 6, 8], [6, 8, 9], [8, 10, 11], [1, 4, 6], [4, 7, 7], [7, 10, 8]]) == 3\n assert candidate(n = 20,edges = [[1, 2, 10], [1, 3, 20], [2, 4, 15], [3, 4, 5], [4, 5, 25], [5, 6, 10], [6, 7, 30], [7, 8, 15], [8, 9, 5], [9, 10, 25], [10, 11, 10], [11, 12, 30], [12, 13, 15], [13, 14, 5], [14, 15, 25], [15, 16, 10], [16, 17, 30], [17, 18, 15], [18, 19, 5], [19, 20, 25]]) == 2\n assert candidate(n = 50,edges = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1], [20, 21, 1], [21, 22, 1], [22, 23, 1], [23, 24, 1], [24, 25, 1], [25, 26, 1], [26, 27, 1], [27, 28, 1], [28, 29, 1], [29, 30, 1], [30, 31, 1], [31, 32, 1], [32, 33, 1], [33, 34, 1], [34, 35, 1], [35, 36, 1], [36, 37, 1], [37, 38, 1], [38, 39, 1], [39, 40, 1], [40, 41, 1], [41, 42, 1], [42, 43, 1], [43, 44, 1], [44, 45, 1], [45, 46, 1], [46, 47, 1], [47, 48, 1], [48, 49, 1], [49, 50, 1], [1, 50, 10], [2, 49, 10], [3, 48, 10], [4, 47, 10], [5, 46, 10], [6, 45, 10], [7, 44, 10], [8, 43, 10], [9, 42, 10], [10, 41, 10], [11, 40, 10], [12, 39, 10], [13, 38, 10], [14, 37, 10], [15, 36, 10], [16, 35, 10], [17, 34, 10], [18, 33, 10], [19, 32, 10], [20, 31, 10], [21, 30, 10], [22, 29, 10], [23, 28, 10], [24, 27, 10], [25, 26, 10]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 10], [1, 3, 20], [2, 4, 5], [2, 5, 7], [3, 5, 3], [4, 6, 2], [4, 7, 8], [5, 7, 1], [5, 8, 6], [6, 9, 4], [7, 9, 3], [8, 10, 1], [9, 10, 5], [10, 11, 3], [11, 12, 4], [12, 13, 1], [12, 14, 7], [13, 15, 2], [14, 15, 6]]) == 5\n assert candidate(n = 20,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 1], [4, 5, 3], [5, 6, 2], [6, 7, 4], [7, 8, 1], [8, 9, 2], [9, 10, 3], [10, 11, 2], [11, 12, 1], [12, 13, 3], [13, 14, 2], [14, 15, 4], [15, 16, 1], [16, 17, 2], [17, 18, 3], [18, 19, 2], [19, 20, 1], [20, 1, 5]]) == 1\n assert candidate(n = 20,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [1, 3, 3], [3, 5, 5], [5, 7, 7], [7, 9, 9], [9, 11, 11], [11, 13, 13], [13, 15, 15], [15, 17, 17], [17, 19, 19], [2, 4, 4], [4, 6, 6], [6, 8, 8], [8, 10, 10], [10, 12, 12], [12, 14, 14], [14, 16, 16], [16, 18, 18], [2, 5, 5], [5, 8, 8], [8, 11, 11], [11, 14, 14], [14, 17, 17], [3, 6, 6], [6, 9, 9], [9, 12, 12], [12, 15, 15], [12, 16, 16], [15, 18, 18], [4, 7, 7], [7, 10, 10], [10, 13, 13], [10, 14, 14], [13, 16, 16], [6, 11, 11], [11, 16, 16], [11, 17, 17], [7, 12, 12], [12, 17, 17], [12, 18, 18]]) == 494\n assert candidate(n = 20,edges = [[1, 2, 2], [1, 3, 3], [2, 4, 1], [2, 5, 4], [3, 6, 5], [3, 7, 7], [4, 8, 8], [4, 9, 9], [5, 9, 2], [5, 10, 3], [6, 11, 6], [6, 12, 10], [7, 12, 4], [7, 13, 5], [8, 14, 3], [9, 14, 4], [10, 14, 7], [11, 15, 1], [11, 16, 2], [12, 16, 3], [12, 17, 8], [13, 17, 9], [14, 18, 6], [15, 18, 5], [16, 19, 4], [17, 19, 3], [18, 20, 10], [19, 20, 7]]) == 6\n assert candidate(n = 20,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 5], [1, 3, 3], [2, 4, 2], [2, 5, 6], [3, 4, 1], [3, 6, 4], [4, 7, 7], [5, 7, 8], [5, 8, 2], [6, 8, 3], [7, 9, 5], [8, 9, 6], [8, 10, 9], [9, 10, 10]]) == 2\n assert candidate(n = 50,edges = [[1, 2, 5], [2, 3, 4], [3, 4, 1], [4, 5, 3], [5, 6, 2], [6, 7, 4], [7, 8, 3], [8, 9, 5], [9, 10, 4], [10, 11, 2], [11, 12, 1], [12, 13, 3], [13, 14, 2], [14, 15, 4], [15, 16, 1], [16, 17, 2], [17, 18, 3], [18, 19, 2], [19, 20, 1], [20, 21, 5], [21, 22, 4], [22, 23, 3], [23, 24, 2], [24, 25, 4], [25, 26, 3], [26, 27, 5], [27, 28, 1], [28, 29, 2], [29, 30, 3], [30, 31, 4], [31, 32, 5], [32, 33, 4], [33, 34, 3], [34, 35, 2], [35, 36, 1], [36, 37, 2], [37, 38, 3], [38, 39, 2], [39, 40, 1], [40, 41, 5], [41, 42, 4], [42, 43, 3], [43, 44, 2], [44, 45, 4], [45, 46, 3], [46, 47, 5], [47, 48, 1], [48, 49, 2], [49, 50, 3], [50, 1, 4]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 10], [1, 3, 5], [2, 4, 3], [2, 5, 4], [3, 6, 2], [3, 7, 6], [4, 8, 7], [4, 9, 8], [5, 9, 3], [5, 10, 1], [6, 11, 5], [6, 12, 3], [7, 12, 2], [7, 13, 9], [8, 14, 5], [9, 14, 6], [10, 14, 4], [11, 15, 7], [12, 15, 8], [13, 15, 3]]) == 4\n assert candidate(n = 50,edges = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1], [20, 21, 1], [21, 22, 1], [22, 23, 1], [23, 24, 1], [24, 25, 1], [25, 26, 1], [26, 27, 1], [27, 28, 1], [28, 29, 1], [29, 30, 1], [30, 31, 1], [31, 32, 1], [32, 33, 1], [33, 34, 1], [34, 35, 1], [35, 36, 1], [36, 37, 1], [37, 38, 1], [38, 39, 1], [39, 40, 1], [40, 41, 1], [41, 42, 1], [42, 43, 1], [43, 44, 1], [44, 45, 1], [45, 46, 1], [46, 47, 1], [47, 48, 1], [48, 49, 1], [49, 50, 1], [1, 50, 50]]) == 2\n assert candidate(n = 15,edges = [[1, 2, 2], [2, 3, 3], [3, 4, 2], [4, 5, 1], [5, 6, 2], [6, 7, 3], [7, 8, 4], [8, 9, 2], [9, 10, 1], [10, 11, 3], [11, 12, 2], [12, 13, 1], [13, 14, 3], [14, 15, 2], [15, 1, 5]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 2], [1, 3, 4], [2, 4, 3], [3, 4, 1], [4, 5, 2], [5, 6, 1], [6, 7, 5], [7, 8, 1], [8, 9, 4], [9, 10, 3], [10, 1, 7]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [1, 10, 5], [2, 8, 4], [3, 9, 3], [4, 7, 2], [5, 6, 1]]) == 1\n", "comparison": "exact"}, "public_tests": ["5\n[[1,2,3],[1,3,3],[2,3,1],[1,4,2],[5,2,2],[3,5,1],[5,4,10]]", "7\n[[1,3,1],[4,1,2],[7,3,4],[2,5,3],[5,6,1],[6,7,2],[7,5,3],[2,6,4]]"], "hints": ["Run a Dijkstra from node numbered n to compute distance from the last node.", "Consider all edges [u, v] one by one and direct them such that distance of u to n > distance of v to n. If both u and v are at the same distance from n, discard this edge.", "Now this problem reduces to computing the number of paths from 1 to n in a DAG, a standard DP problem."], "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().countRestrictedPaths", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:45+00:00", "tests_total": 45, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["dynamic-programming", "graph", "topological-sort", "heap-priority-queue", "shortest-path", "dijkstra"]}, "language": "python", "interface": {"raw_signature": "def countRestrictedPaths(self, n: int, edges: list[list[int]]) -> int:", "container": "Solution", "callable": "countRestrictedPaths", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1787, "task_id": "make-the-xor-of-all-segments-equal-to-zero", "difficulty": "Hard", "problem_description": "You are given an array nums and an integer k. The XOR of a segment [left, right] where left <= right is the XOR of all the elements with indices between left and right, inclusive: nums[left] XOR nums[left+1] XOR ... XOR nums[right].\n\nReturn the minimum number of elements to change in the array such that the XOR of all segments of size k is equal to zero.\n\nExample 1:\n\nInput: nums = [1,2,0,3,0], k = 1\nOutput: 3\nExplanation: Modify the array from [1,2,0,3,0] to from [0,0,0,0,0].\n\nExample 2:\n\nInput: nums = [3,4,5,2,1,7,3,4,7], k = 3\nOutput: 3\nExplanation: Modify the array from [3,4,5,2,1,7,3,4,7] to [3,4,7,3,4,7,3,4,7].\n\nExample 3:\n\nInput: nums = [1,2,4,1,2,5,1,2,6], k = 3\nOutput: 3\nExplanation: Modify the array from [1,2,4,1,2,5,1,2,6] to [1,2,3,1,2,3,1,2,3].\n\nConstraints:\n\n- 1 <= k <= nums.length <= 2000\n- 0 <= nums[i] < 2^10\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 0\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 5) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],k = 5) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],k = 4) == 4\n assert candidate(nums = [3, 4, 5, 2, 1, 7, 3, 4, 7],k = 3) == 3\n assert candidate(nums = [0, 0, 0, 0, 0],k = 2) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 10\n assert candidate(nums = [1, 2, 4, 1, 2, 5, 1, 2, 6],k = 3) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1],k = 6) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 2) == 9\n assert candidate(nums = [1, 1, 1, 1, 1],k = 5) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 1) == 10\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 2) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 9) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17],k = 3) == 7\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 6) == 0\n assert candidate(nums = [1, 3, 5, 7, 9],k = 5) == 1\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 10) == 0\n assert candidate(nums = [1, 2, 0, 3, 0],k = 1) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 4) == 11\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 5\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 11\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 5\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 12\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19],k = 8) == 30\n assert candidate(nums = [3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1],k = 2) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 3) == 24\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n assert candidate(nums = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240],k = 5) == 12\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 15) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 5) == 10\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31],k = 15) == 2\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 5) == 16\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],k = 5) == 14\n assert candidate(nums = [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 13, 12, 11],k = 4) == 24\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 15\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7],k = 8) == 26\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],k = 15) == 1\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6],k = 3) == 22\n assert candidate(nums = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 3) == 9\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4],k = 7) == 21\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 17) == 5\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 8\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0],k = 3) == 42\n assert candidate(nums = [511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540],k = 15) == 16\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 18) == 5\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 10) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4],k = 5) == 24\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 6, 7, 9],k = 13) == 69\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 7) == 23\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],k = 10) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3],k = 5) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 10) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 15) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 20) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11) == 69\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 20) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 6) == 7\n assert candidate(nums = [5, 7, 9, 11, 13, 5, 7, 9, 11, 13],k = 5) == 2\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],k = 5) == 27\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 8, 7, 6, 5, 4, 3, 2, 1, 0, 8, 7, 6, 5, 4, 3, 2, 1, 0, 8, 7, 6],k = 5) == 25\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 10) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15],k = 5) == 23\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 10) == 11\n assert candidate(nums = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 5) == 12\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 6\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 8) == 24\n assert candidate(nums = [8, 4, 2, 1, 0, 1, 2, 4, 8, 4, 2, 1, 0, 1, 2, 4, 8, 4, 2, 1],k = 5) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 20) == 20\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 7) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 5) == 26\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 3) == 15\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 3) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 4) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200],k = 17) == 184\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],k = 15) == 16\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 0, 255, 128, 64, 32, 16, 8, 4, 2, 1, 0, 255, 128, 64, 32, 16, 8, 4, 2, 1, 0],k = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 11\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 7) == 13\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],k = 7) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 15\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 12) == 38\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 10) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],k = 6) == 22\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 182, 189, 196, 203, 210],k = 15) == 15\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12],k = 10) == 11\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2],k = 7) == 19\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 8) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 3) == 10\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9],k = 10) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0],k = 10) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390],k = 15) == 24\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 0, 255, 128, 64, 32, 16, 8, 4, 2, 1, 0, 255, 128, 64, 32, 16, 8, 4, 2, 1, 0],k = 7) == 23\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 25) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 16\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30],k = 8) == 52\n assert candidate(nums = [17, 255, 8, 19, 7, 23, 15, 42, 99, 1023, 22, 31, 56, 78, 90, 111, 132, 153, 174, 195],k = 7) == 13\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],k = 10) == 21\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0],k = 6) == 5\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 7) == 24\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511],k = 10) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 5) == 25\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n", "comparison": "exact"}, "public_tests": ["[1,2,0,3,0]\n1", "[3,4,5,2,1,7,3,4,7]\n3", "[1,2,4,1,2,5,1,2,6]\n3"], "hints": ["Let's note that for the XOR of all segments with size K to be equal to zeros, nums[i] has to be equal to nums[i+k]", "Basically, we need to make the first K elements have XOR = 0 and then modify them."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minChanges", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:47+00:00", "tests_total": 113, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "dynamic-programming", "bit-manipulation", "counting"]}, "language": "python", "interface": {"raw_signature": "def minChanges(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "minChanges", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1790, "task_id": "check-if-one-string-swap-can-make-strings-equal", "difficulty": "Easy", "problem_description": "You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices.\n\nReturn true if it is possible to make both strings equal by performing at most one string swap on exactly one of the strings. Otherwise, return false.\n\nExample 1:\n\nInput: s1 = \"bank\", s2 = \"kanb\"\nOutput: true\nExplanation: For example, swap the first character with the last character of s2 to make \"bank\".\n\nExample 2:\n\nInput: s1 = \"attack\", s2 = \"defend\"\nOutput: false\nExplanation: It is impossible to make them equal with one string swap.\n\nExample 3:\n\nInput: s1 = \"kelb\", s2 = \"kelb\"\nOutput: true\nExplanation: The two strings are already equal, so no string swap operation is required.\n\nConstraints:\n\n- 1 <= s1.length, s2.length <= 100\n- s1.length == s2.length\n- s1 and s2 consist of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"attack\",s2 = \"defend\") == False\n assert candidate(s1 = \"bank\",s2 = \"kanb\") == True\n assert candidate(s1 = \"abcde\",s2 = \"abced\") == True\n assert candidate(s1 = \"abcd\",s2 = \"abdc\") == True\n assert candidate(s1 = \"aaa\",s2 = \"aaa\") == True\n assert candidate(s1 = \"kelb\",s2 = \"kelb\") == True\n assert candidate(s1 = \"aabb\",s2 = \"abab\") == True\n assert candidate(s1 = \"abcd\",s2 = \"dcba\") == False\n assert candidate(s1 = \"algorithm\",s2 = \"logarithm\") == False\n assert candidate(s1 = \"almost\",s2 = \"almost\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"ghfedcb\") == False\n assert candidate(s1 = \"xyzabc\",s2 = \"yzabxc\") == False\n assert candidate(s1 = \"abcdefg\",s2 = \"fedcbag\") == False\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdefx\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"ccbaab\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"aabbbc\") == False\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"babacabadabacab\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"ccbbaa\") == False\n assert candidate(s1 = \"programming\",s2 = \"programminj\") == False\n assert candidate(s1 = \"samestr\",s2 = \"strsame\") == False\n assert candidate(s1 = \"hello\",s2 = \"hlelo\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"gfedcba\") == False\n assert candidate(s1 = \"abababab\",s2 = \"babababa\") == False\n assert candidate(s1 = \"abracadabra\",s2 = \"abracadabrb\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"mississipsp\") == False\n assert candidate(s1 = \"palindrome\",s2 = \"lpadnrimoe\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"ccabba\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"mississipip\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdefg\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"bbaacc\") == False\n assert candidate(s1 = \"abcdexyz\",s2 = \"xyzabcde\") == False\n assert candidate(s1 = \"abcdxyz\",s2 = \"abczyxd\") == False\n assert candidate(s1 = \"abcdefgh\",s2 = \"hgfedcba\") == False\n assert candidate(s1 = \"abcde\",s2 = \"abcde\") == True\n assert candidate(s1 = \"ab\",s2 = \"ba\") == True\n assert candidate(s1 = \"hello\",s2 = \"olleh\") == False\n assert candidate(s1 = \"hello\",s2 = \"hallo\") == False\n assert candidate(s1 = \"abcdef\",s2 = \"abcfed\") == True\n assert candidate(s1 = \"qwertyuiop\",s2 = \"qewrtyuipo\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"mississippa\") == False\n assert candidate(s1 = \"programming\",s2 = \"prorgamming\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"abdecfg\") == False\n assert candidate(s1 = \"noon\",s2 = \"nnon\") == False\n assert candidate(s1 = \"hello\",s2 = \"ohell\") == False\n assert candidate(s1 = \"hello\",s2 = \"hxllo\") == False\n assert candidate(s1 = \"aaaabbbb\",s2 = \"bbbbaaaa\") == False\n assert candidate(s1 = \"abc\",s2 = \"acb\") == True\n assert candidate(s1 = \"hello\",s2 = \"lehho\") == False\n assert candidate(s1 = \"abcdexyz\",s2 = \"abcdefyz\") == False\n assert candidate(s1 = \"python\",s2 = \"pythno\") == True\n assert candidate(s1 = \"abracadabra\",s2 = \"abracadabra\") == True\n assert candidate(s1 = \"abcdefgh\",s2 = \"bcadefgh\") == False\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"abacabadabacaba\") == True\n assert candidate(s1 = \"hello\",s2 = \"bello\") == False\n assert candidate(s1 = \"hello\",s2 = \"heoll\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghjk\") == False\n assert candidate(s1 = \"unique\",s2 = \"unqieu\") == False\n assert candidate(s1 = \"abcdabcd\",s2 = \"dcbaabcd\") == False\n assert candidate(s1 = \"abacax\",s2 = \"abacxa\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghij\") == True\n assert candidate(s1 = \"algorithm\",s2 = \"algorithn\") == False\n assert candidate(s1 = \"algorithm\",s2 = \"aloritghm\") == False\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdegf\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"aaccbb\") == False\n assert candidate(s1 = \"almost\",s2 = \"alosmt\") == False\n assert candidate(s1 = \"racecar\",s2 = \"racecar\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"mmissisippi\") == False\n assert candidate(s1 = \"abcdefgh\",s2 = \"efghabcd\") == False\n assert candidate(s1 = \"xyzz\",s2 = \"zzxy\") == False\n assert candidate(s1 = \"palindrome\",s2 = \"palindorme\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"abcdef\") == True\n assert candidate(s1 = \"ab\",s2 = \"ab\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"abcdeg\") == False\n assert candidate(s1 = \"oneone\",s2 = \"noonoe\") == False\n assert candidate(s1 = \"abcxyz\",s2 = \"xyzabc\") == False\n assert candidate(s1 = \"abac\",s2 = \"caba\") == False\n assert candidate(s1 = \"xyz\",s2 = \"zyx\") == True\n assert candidate(s1 = \"abracadabra\",s2 = \"abracadbrba\") == False\n assert candidate(s1 = \"abac\",s2 = \"abca\") == True\n assert candidate(s1 = \"same\",s2 = \"same\") == True\n assert candidate(s1 = \"abcdefgh\",s2 = \"abcdefgh\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"fedcba\") == False\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghji\") == True\n assert candidate(s1 = \"abcde\",s2 = \"edcba\") == False\n assert candidate(s1 = \"swapping\",s2 = \"swapgnip\") == False\n assert candidate(s1 = \"aabbccdd\",s2 = \"ddccbbaa\") == False\n assert candidate(s1 = \"xyzz\",s2 = \"zyzz\") == False\n assert candidate(s1 = \"algorithm\",s2 = \"algorjthm\") == False\n assert candidate(s1 = \"xyzz\",s2 = \"zyxz\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"aabbdc\") == False\n assert candidate(s1 = \"abcdefghijk\",s2 = \"abcdefghijl\") == False\n assert candidate(s1 = \"ababab\",s2 = \"bababa\") == False\n assert candidate(s1 = \"abab\",s2 = \"baba\") == False\n assert candidate(s1 = \"mambo\",s2 = \"mambp\") == False\n assert candidate(s1 = \"abcdef\",s2 = \"abcdfe\") == True\n assert candidate(s1 = \"abdc\",s2 = \"abcd\") == True\n assert candidate(s1 = \"xyzz\",s2 = \"zyzx\") == True\n assert candidate(s1 = \"aabb\",s2 = \"bbaa\") == False\n assert candidate(s1 = \"same\",s2 = \"emsa\") == False\n assert candidate(s1 = \"abcdxyz\",s2 = \"abcdzyx\") == True\n assert candidate(s1 = \"python\",s2 = \"ytonph\") == False\n assert candidate(s1 = \"xyzxyz\",s2 = \"zyxzyx\") == False\n assert candidate(s1 = \"aaaa\",s2 = \"aaaa\") == True\n", "comparison": "exact"}, "public_tests": ["\"bank\"\n\"kanb\"", "\"attack\"\n\"defend\"", "\"kelb\"\n\"kelb\""], "hints": ["The answer is false if the number of nonequal positions in the strings is not equal to 0 or 2.", "Check that these positions have the same set of characters."], "metadata": {"canonical_parameter_names": ["s1", "s2"], "leetcode_dataset_entry_point": "Solution().areAlmostEqual", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:52+00:00", "tests_total": 108, "tests_dropped": 5, "flags": [], "topic_tags": ["hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def areAlmostEqual(self, s1: str, s2: str) -> bool:", "container": "Solution", "callable": "areAlmostEqual", "parameters": [{"name": "s1", "type": "str"}, {"name": "s2", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1791, "task_id": "find-center-of-star-graph", "difficulty": "Easy", "problem_description": "There is an undirected star graph consisting of n nodes labeled from 1 to n. A star graph is a graph where there is one center node and exactly n - 1 edges that connect the center node with every other node.\n\nYou are given a 2D integer array edges where each edges[i] = [u_i, v_i] indicates that there is an edge between the nodes u_i and v_i. Return the center of the given star graph.\n\nExample 1:\n\nInput: edges = [[1,2],[2,3],[4,2]]\nOutput: 2\nExplanation: As shown in the figure above, node 2 is connected to every other node, so 2 is the center.\n\nExample 2:\n\nInput: edges = [[1,2],[5,1],[1,3],[1,4]]\nOutput: 1\n\nConstraints:\n\n- 3 <= n <= 10^5\n- edges.length == n - 1\n- edges[i].length == 2\n- 1 <= u_i, v_i <= n\n- u_i != v_i\n- The given edges represent a valid star graph.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [[3, 1], [1, 2], [1, 4], [1, 5]]) == 1\n assert candidate(edges = [[7, 3], [7, 4], [7, 2], [7, 5], [7, 6], [7, 1]]) == 7\n assert candidate(edges = [[4, 3], [5, 3], [2, 3], [1, 3]]) == 3\n assert candidate(edges = [[1, 2], [2, 3], [4, 2]]) == 2\n assert candidate(edges = [[1, 2], [5, 1], [1, 3], [1, 4]]) == 1\n assert candidate(edges = [[3, 1], [2, 1]]) == 1\n assert candidate(edges = [[3, 1], [3, 2], [3, 4], [3, 5]]) == 3\n assert candidate(edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]]) == 1\n assert candidate(edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50], [50, 1]]) == 2\n assert candidate(edges = [[2, 1], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 35], [2, 36], [2, 37], [2, 38], [2, 39], [2, 40], [2, 41], [2, 42], [2, 43], [2, 44], [2, 45], [2, 46], [2, 47], [2, 48], [2, 49], [2, 50], [2, 51], [2, 52], [2, 53], [2, 54], [2, 55], [2, 56], [2, 57], [2, 58], [2, 59], [2, 60]]) == 2\n assert candidate(edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30]]) == 1\n assert candidate(edges = [[3, 1], [3, 2], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [3, 40], [3, 41], [3, 42], [3, 43], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 52], [3, 53], [3, 54], [3, 55], [3, 56], [3, 57], [3, 58], [3, 59], [3, 60], [3, 61], [3, 62], [3, 63], [3, 64], [3, 65], [3, 66], [3, 67], [3, 68], [3, 69], [3, 70], [3, 71], [3, 72], [3, 73], [3, 74], [3, 75], [3, 76], [3, 77], [3, 78], [3, 79], [3, 80], [3, 81], [3, 82], [3, 83], [3, 84], [3, 85], [3, 86], [3, 87], [3, 88], [3, 89], [3, 90], [3, 91], [3, 92], [3, 93], [3, 94], [3, 95], [3, 96], [3, 97], [3, 98], [3, 99], [3, 100]]) == 3\n assert candidate(edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]) == 2\n assert candidate(edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30]]) == 1\n assert candidate(edges = [[2, 1], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15]]) == 2\n assert candidate(edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 2\n assert candidate(edges = [[30, 1], [30, 2], [30, 3], [30, 4], [30, 5], [30, 6], [30, 7], [30, 8], [30, 9], [30, 10], [30, 11], [30, 12], [30, 13], [30, 14], [30, 15], [30, 16], [30, 17], [30, 18], [30, 19], [30, 20], [30, 21], [30, 22], [30, 23], [30, 24], [30, 25], [30, 26], [30, 27], [30, 28], [30, 29]]) == 30\n assert candidate(edges = [[2, 1], [2, 4], [3, 2], [2, 6], [5, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == 2\n", "comparison": "exact"}, "public_tests": ["[[1,2],[2,3],[4,2]]", "[[1,2],[5,1],[1,3],[1,4]]"], "hints": ["The center is the only node that has more than one edge.", "The center is also connected to all other nodes.", "Any two edges must have a common node, which is the center."], "metadata": {"canonical_parameter_names": ["edges"], "leetcode_dataset_entry_point": "Solution().findCenter", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:54+00:00", "tests_total": 58, "tests_dropped": 40, "flags": ["figure_reference", "has_images"], "topic_tags": ["graph"]}, "language": "python", "interface": {"raw_signature": "def findCenter(self, edges: list[list[int]]) -> int:", "container": "Solution", "callable": "findCenter", "parameters": [{"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1792, "task_id": "maximum-average-pass-ratio", "difficulty": "Medium", "problem_description": "There is a school that has classes of students and each class will be having a final exam. You are given a 2D integer array classes, where classes[i] = [pass_i, total_i]. You know beforehand that in the i^th class, there are total_i total students, but only pass_i number of students will pass the exam.\n\nYou are also given an integer extraStudents. There are another extraStudents brilliant students that are guaranteed to pass the exam of any class they are assigned to. You want to assign each of the extraStudents students to a class in a way that maximizes the average pass ratio across all the classes.\n\nThe pass ratio of a class is equal to the number of students of the class that will pass the exam divided by the total number of students of the class. The average pass ratio is the sum of pass ratios of all the classes divided by the number of the classes.\n\nReturn the maximum possible average pass ratio after assigning the extraStudents students. Answers within 10^-5 of the actual answer will be accepted.\n\nExample 1:\n\nInput: classes = [[1,2],[3,5],[2,2]], extraStudents = 2\nOutput: 0.78333\nExplanation: You can assign the two extra students to the first class. The average pass ratio will be equal to (3/4 + 3/5 + 2/2) / 3 = 0.78333.\n\nExample 2:\n\nInput: classes = [[2,4],[3,9],[4,5],[2,10]], extraStudents = 4\nOutput: 0.53485\n\nConstraints:\n\n- 1 <= classes.length <= 10^5\n- classes[i].length == 2\n- 1 <= pass_i <= total_i <= 10^5\n- 1 <= extraStudents <= 10^5\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(classes=[[5, 10], [6, 10], [7, 10]], extraStudents=1), 0.6151515151515151)\n assert answers_match(candidate(classes=[[2, 4], [3, 9], [4, 5], [2, 10]], extraStudents=4), 0.5348484848484849)\n assert answers_match(candidate(classes=[[1, 1], [1, 1], [1, 1]], extraStudents=1), 1.0)\n assert answers_match(candidate(classes=[[1, 2], [3, 5], [2, 2]], extraStudents=2), 0.7833333333333333)\n assert answers_match(candidate(classes=[[10, 20], [20, 30], [30, 40]], extraStudents=5), 0.6722222222222222)\n assert answers_match(candidate(classes=[[5, 5], [10, 10]], extraStudents=10), 1.0)\n assert answers_match(candidate(classes=[[1, 1], [1, 2], [1, 3]], extraStudents=3), 0.7555555555555555)\n assert answers_match(candidate(classes=[[99, 100], [999, 1000], [9999, 10000]], extraStudents=1000), 0.999331746031746)\n assert answers_match(candidate(classes=[[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]], extraStudents=10), 1.0)\n assert answers_match(candidate(classes=[[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]], extraStudents=10), 0.6842857142857143)\n assert answers_match(candidate(classes=[[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000]], extraStudents=45), 0.7958742756361804)\n assert answers_match(candidate(classes=[[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]], extraStudents=15), 0.2273449131513648)\n assert answers_match(candidate(classes=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]], extraStudents=15), 0.8571428571428571)\n assert answers_match(candidate(classes=[[1, 100], [10, 1000], [100, 10000], [1000, 100000]], extraStudents=1000), 0.3008176852167975)\n assert answers_match(candidate(classes=[[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]], extraStudents=50), 0.6412325174825175)\n assert answers_match(candidate(classes=[[99, 100], [999, 1000], [9999, 10000], [99999, 100000]], extraStudents=10), 0.9974497727272728)\n assert answers_match(candidate(classes=[[5, 10], [10, 20], [15, 30], [20, 40], [25, 50]], extraStudents=25), 0.5977592214345788)\n assert answers_match(candidate(classes=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]], extraStudents=1000), 1.0)\n assert answers_match(candidate(classes=[[1000, 2000], [1500, 3000], [2000, 4000], [2500, 5000], [3000, 6000]], extraStudents=1000), 0.5350170085037467)\n assert answers_match(candidate(classes=[[1, 3], [2, 6], [3, 9], [4, 12], [5, 15]], extraStudents=10), 0.4884670884670885)\n assert answers_match(candidate(classes=[[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]], extraStudents=10), 0.4164285714285715)\n assert answers_match(candidate(classes=[[1, 100], [10, 100], [50, 100]], extraStudents=50), 0.3296191939890711)\n assert answers_match(candidate(classes=[[100, 200], [150, 250], [200, 300], [250, 350]], extraStudents=50), 0.6452380952380952)\n assert answers_match(candidate(classes=[[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]], extraStudents=5), 0.4371428571428571)\n assert answers_match(candidate(classes=[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]], extraStudents=50), 1.0)\n assert answers_match(candidate(classes=[[10000, 10001], [20000, 20001], [30000, 30001], [40000, 40001]], extraStudents=1000), 0.9999501925188506)\n assert answers_match(candidate(classes=[[50, 100], [75, 150], [125, 250], [200, 400], [300, 600], [450, 900]], extraStudents=300), 0.5992478200634347)\n assert answers_match(candidate(classes=[[5, 8], [5, 8], [5, 8], [5, 8], [5, 8]], extraStudents=20), 0.75)\n assert answers_match(candidate(classes=[[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]], extraStudents=100), 0.8541887125220459)\n assert answers_match(candidate(classes=[[99, 100], [98, 100], [97, 100], [96, 100], [95, 100]], extraStudents=5), 0.9704761904761904)\n assert answers_match(candidate(classes=[[99999, 100000], [50000, 100000], [25000, 50000], [10000, 20000]], extraStudents=5000), 0.6499975)\n assert answers_match(candidate(classes=[[1, 100000], [2, 100000], [3, 100000]], extraStudents=100000), 0.2500150000093752)\n assert answers_match(candidate(classes=[[100, 200], [200, 500], [300, 800], [400, 1000]], extraStudents=100), 0.4604967738352485)\n assert answers_match(candidate(classes=[[1, 2], [3, 6], [5, 10], [7, 14], [9, 18]], extraStudents=15), 0.6531926406926407)\n assert answers_match(candidate(classes=[[1, 100000], [2, 100000], [3, 100000], [4, 100000], [5, 100000]], extraStudents=100000), 0.16669166670370508)\n assert answers_match(candidate(classes=[[10000, 20000], [5000, 10000], [2500, 5000], [1000, 2000], [500, 1000], [250, 500], [100, 200], [50, 100], [25, 50], [10, 20]], extraStudents=10000), 0.7885364227868774)\n assert answers_match(candidate(classes=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]], extraStudents=5), 1.0)\n assert answers_match(candidate(classes=[[50, 100], [150, 300], [250, 500], [350, 700]], extraStudents=150), 0.5803610885401075)\n assert answers_match(candidate(classes=[[1, 1], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]], extraStudents=20), 0.9074074074074074)\n assert answers_match(candidate(classes=[[9, 10], [99, 100], [999, 1000], [9999, 10000], [99999, 100000]], extraStudents=50000), 0.9999456354114968)\n assert answers_match(candidate(classes=[[99, 100], [98, 100], [97, 100], [96, 100], [95, 100], [94, 100], [93, 100], [92, 100], [91, 100], [90, 100]], extraStudents=10), 0.945917211328976)\n assert answers_match(candidate(classes=[[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11]], extraStudents=10), 0.3255194805194805)\n assert answers_match(candidate(classes=[[50, 100], [100, 200], [150, 300], [200, 400]], extraStudents=100), 0.567861188343116)\n assert answers_match(candidate(classes=[[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]], extraStudents=9), 0.341005291005291)\n assert answers_match(candidate(classes=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]], extraStudents=5), 0.7966666666666666)\n assert answers_match(candidate(classes=[[10, 11], [20, 22], [30, 33], [40, 44]], extraStudents=5), 0.9161931818181818)\n assert answers_match(candidate(classes=[[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]], extraStudents=15), 0.7535606060606062)\n assert answers_match(candidate(classes=[[1, 3], [2, 5], [3, 7], [4, 9]], extraStudents=5), 0.528968253968254)\n assert answers_match(candidate(classes=[[1, 1000], [10, 1000], [100, 1000], [1000, 1000]], extraStudents=100), 0.30143093489681594)\n assert answers_match(candidate(classes=[[10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65]], extraStudents=100), 0.9114219114219114)\n assert answers_match(candidate(classes=[[1, 100], [20, 50], [30, 40], [40, 60]], extraStudents=10), 0.4822964571623233)\n assert answers_match(candidate(classes=[[1, 100000], [100000, 100000], [100000, 100000], [100000, 100000], [1, 100000]], extraStudents=100000), 0.733336)\n assert answers_match(candidate(classes=[[5, 6], [10, 12], [15, 18], [20, 24], [25, 30]], extraStudents=50), 0.8996095210091154)\n assert answers_match(candidate(classes=[[1, 2], [2, 4], [3, 8], [4, 16], [5, 32], [6, 64], [7, 128], [8, 256], [9, 512]], extraStudents=256), 0.56112903154186)\n assert answers_match(candidate(classes=[[99999, 100000], [99998, 100000], [99997, 100000]], extraStudents=3), 0.999980000299991)\n assert answers_match(candidate(classes=[[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]], extraStudents=100), 0.29977994676131325)\n assert answers_match(candidate(classes=[[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]], extraStudents=45), 0.5812816812816812)\n assert answers_match(candidate(classes=[[1, 3], [2, 5], [3, 7], [4, 9], [5, 11]], extraStudents=5), 0.5140836940836941)\n assert answers_match(candidate(classes=[[100, 200], [200, 300], [50, 150], [250, 500], [100, 250]], extraStudents=50), 0.5133333333333333)\n assert answers_match(candidate(classes=[[1, 2], [1, 3], [1, 4], [1, 5]], extraStudents=5), 0.5)\n assert answers_match(candidate(classes=[[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]], extraStudents=5), 0.5488095238095239)\n assert answers_match(candidate(classes=[[1000, 10000], [2000, 20000], [3000, 30000], [4000, 40000]], extraStudents=2000), 0.1375)\n assert answers_match(candidate(classes=[[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]], extraStudents=200), 0.638637428727642)\n assert answers_match(candidate(classes=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]], extraStudents=50), 0.9128787878787878)\n assert answers_match(candidate(classes=[[100, 101], [200, 201], [300, 301], [400, 401], [500, 501]], extraStudents=500), 0.9974701296361822)\n assert answers_match(candidate(classes=[[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]], extraStudents=5), 0.5833333333333333)\n assert answers_match(candidate(classes=[[50, 100], [40, 80], [30, 60], [20, 40], [10, 20]], extraStudents=20), 0.554287556415216)\n assert answers_match(candidate(classes=[[1, 2], [2, 5], [3, 10], [4, 20], [5, 50], [6, 100], [7, 200], [8, 500], [9, 1000], [10, 10000]], extraStudents=5000), 0.7736090641036538)\n assert answers_match(candidate(classes=[[1, 1000], [1, 2000], [1, 3000], [1, 4000], [1, 5000]], extraStudents=1500), 0.14190236063451128)\n assert answers_match(candidate(classes=[[10, 20], [20, 40], [30, 60], [40, 80]], extraStudents=20), 0.56785944551902)\n assert answers_match(candidate(classes=[[99, 100], [199, 200], [299, 300], [399, 400], [499, 500]], extraStudents=1000), 0.998)\n assert answers_match(candidate(classes=[[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]], extraStudents=4500), 0.5002246672081883)\n assert answers_match(candidate(classes=[[10000, 100000], [20000, 100000], [30000, 100000], [40000, 100000]], extraStudents=10000), 0.27058853870831734)\n assert answers_match(candidate(classes=[[1, 100], [1, 100], [1, 100], [1, 100], [1, 100]], extraStudents=500), 0.505)\n assert answers_match(candidate(classes=[[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]], extraStudents=5), 1.0)\n assert answers_match(candidate(classes=[[1, 10], [2, 15], [3, 20], [4, 25], [5, 30]], extraStudents=15), 0.2816248934356351)\n assert answers_match(candidate(classes=[[10, 20], [15, 25], [20, 30], [25, 35]], extraStudents=10), 0.6633597883597884)\n assert answers_match(candidate(classes=[[1, 100], [10, 100], [100, 100], [1000, 1000], [10000, 10000]], extraStudents=10000), 0.9925924392888745)\n assert answers_match(candidate(classes=[[1, 100000], [100000, 100000], [50000, 100000]], extraStudents=50000), 0.6114404678259185)\n assert answers_match(candidate(classes=[[10, 20], [15, 30], [5, 15], [25, 50]], extraStudents=15), 0.55)\n assert answers_match(candidate(classes=[[10000, 100000], [20000, 100000], [30000, 100000], [40000, 100000], [50000, 100000], [60000, 100000], [70000, 100000], [80000, 100000], [90000, 100000], [100000, 100000]], extraStudents=10000), 0.5582354154833269)\n assert answers_match(candidate(classes=[[50, 100], [40, 80], [30, 60], [20, 40], [10, 20]], extraStudents=30), 0.5707749766573296)\n assert answers_match(candidate(classes=[[1, 100000], [1, 100000], [1, 100000], [1, 100000], [1, 100000]], extraStudents=100000), 0.166675)\n assert answers_match(candidate(classes=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]], extraStudents=100), 0.9415395787944808)\n assert answers_match(candidate(classes=[[10, 100], [20, 200], [30, 300], [40, 400], [50, 500]], extraStudents=50), 0.16025231286795627)\n assert answers_match(candidate(classes=[[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]], extraStudents=15), 0.5976190476190476)\n assert answers_match(candidate(classes=[[50, 100], [75, 150], [25, 75], [10, 50]], extraStudents=20), 0.44060351413292587)\n assert answers_match(candidate(classes=[[1, 100], [2, 100], [3, 100], [4, 100], [5, 100]], extraStudents=250), 0.3533647454875556)\n assert answers_match(candidate(classes=[[50000, 100000], [40000, 100000], [30000, 100000], [20000, 100000], [10000, 100000]], extraStudents=50000), 0.3696598823228846)\n assert answers_match(candidate(classes=[[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]], extraStudents=100), 0.7595597403486419)\n assert answers_match(candidate(classes=[[3, 4], [4, 5], [5, 6], [6, 7], [7, 8]], extraStudents=3), 0.8464285714285715)\n assert answers_match(candidate(classes=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]], extraStudents=9), 0.8504850088183421)\n assert answers_match(candidate(classes=[[10, 12], [20, 25], [30, 35], [40, 45], [50, 55]], extraStudents=30), 0.8916472416472416)\n assert answers_match(candidate(classes=[[1, 2], [2, 4], [4, 8], [8, 16], [16, 32]], extraStudents=64), 0.7993434343434344)\n assert answers_match(candidate(classes=[[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]], extraStudents=100), 0.49407730392552046)\n assert answers_match(candidate(classes=[[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7]], extraStudents=21), 0.5919612794612795)\n assert answers_match(candidate(classes=[[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]], extraStudents=500), 0.5672899020682859)\n assert answers_match(candidate(classes=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]], extraStudents=10), 0.8541887125220459)\n assert answers_match(candidate(classes=[[999, 1000], [998, 1000], [997, 1000], [996, 1000], [995, 1000]], extraStudents=10), 0.997009900990099)\n", "comparison": "float"}, "public_tests": ["[[1,2],[3,5],[2,2]]\n2", "[[2,4],[3,9],[4,5],[2,10]]\n4"], "hints": ["Pay attention to how much the pass ratio changes when you add a student to the class. If you keep adding students, what happens to the change in pass ratio? The more students you add to a class, the smaller the change in pass ratio becomes.", "Since the change in the pass ratio is always decreasing with the more students you add, then the very first student you add to each class is the one that makes the biggest change in the pass ratio.", "Because each class's pass ratio is weighted equally, it's always optimal to put the student in the class that makes the biggest change among all the other classes.", "Keep a max heap of the current class sizes and order them by the change in pass ratio. For each extra student, take the top of the heap, update the class size, and put it back in the heap."], "metadata": {"canonical_parameter_names": ["classes", "extraStudents"], "leetcode_dataset_entry_point": "Solution().maxAverageRatio", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:57+00:00", "tests_total": 101, "tests_dropped": 2, "flags": ["decimal_answer"], "topic_tags": ["array", "greedy", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def maxAverageRatio(self, classes: list[list[int]], extraStudents: int) -> float:", "container": "Solution", "callable": "maxAverageRatio", "parameters": [{"name": "classes", "type": "list[list[int]]"}, {"name": "extraStudents", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1793, "task_id": "maximum-score-of-a-good-subarray", "difficulty": "Hard", "problem_description": "You are given an array of integers nums (0-indexed) and an integer k.\n\nThe score of a subarray (i, j) is defined as min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1). A good subarray is a subarray where i <= k <= j.\n\nReturn the maximum possible score of a good subarray.\n\nExample 1:\n\nInput: nums = [1,4,3,7,4,5], k = 3\nOutput: 15\nExplanation: The optimal subarray is (1, 5) with a score of min(4,3,7,4,5) * (5-1+1) = 3 * 5 = 15.\n\nExample 2:\n\nInput: nums = [5,5,4,5,4,1,1,1], k = 0\nOutput: 20\nExplanation: The optimal subarray is (0, 4) with a score of min(5,5,4,5,4) * (4-0+1) = 4 * 5 = 20.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 2 * 10^4\n- 0 <= k < nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 4, 5, 4, 1, 1, 1],k = 0) == 20\n assert candidate(nums = [10, 10, 10, 10, 10],k = 2) == 50\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 25\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],k = 4) == 10\n assert candidate(nums = [9, 7, 5, 3, 1],k = 2) == 15\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 30\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == 9\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9],k = 2) == 21\n assert candidate(nums = [1, 4, 3, 7, 4, 5],k = 3) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1],k = 4) == 25\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100],k = 4) == 1500\n assert candidate(nums = [10, 20, 30, 40, 50],k = 2) == 90\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 30\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 54\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],k = 3) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 30\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 30\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10, 1, 2, 3, 4, 5],k = 9) == 18\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 7) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],k = 25) == 69\n assert candidate(nums = [1, 20000, 2, 19999, 3, 19998, 4, 19997, 5, 19996, 6],k = 5) == 19998\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 200\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 110\n assert candidate(nums = [5, 15, 10, 20, 25, 30, 35, 40, 45, 50],k = 3) == 140\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 12) == 150\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 9) == 200000\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == 110\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 4) == 1000\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 19\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 110\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 20\n assert candidate(nums = [20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000],k = 10) == 400000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 300\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5],k = 15) == 44\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5],k = 4) == 19\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9],k = 9) == 30\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 10) == 1000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 6) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1],k = 9) == 10\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 7) == 64\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5],k = 5) == 150\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 55\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 15) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 7) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == 300\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 5) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 6) == 420\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 11) == 55\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 44\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12],k = 5) == 24\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10) == 200\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 1) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 9) == 99\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 2, 1, 2, 3, 6, 12, 25, 50, 100],k = 7) == 15\n assert candidate(nums = [5, 5, 4, 4, 4, 5, 5, 4, 4, 4, 5, 5, 4, 4, 4, 5, 5, 4, 4, 4, 5, 5, 4, 4, 4, 5, 5, 4, 4, 4],k = 12) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 14) == 55\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],k = 4) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 10) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10],k = 4) == 150\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5],k = 10) == 55\n assert candidate(nums = [10, 10, 10, 10, 10, 1, 1, 1, 1, 1],k = 5) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100],k = 9) == 100\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],k = 10) == 66\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 20) == 169\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 12) == 128\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 100],k = 4) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5, 10, 20, 30, 40, 50, 40, 30, 20, 10, 5],k = 15) == 150\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],k = 10) == 1620\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 5) == 10\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10],k = 9) == 39\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 8) == 18\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 64\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],k = 5) == 109890\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 20) == 38\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 5) == 910\n assert candidate(nums = [60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5],k = 5) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 20) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4],k = 10) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 15) == 100\n assert candidate(nums = [3, 3, 3, 1, 2, 3, 2, 1, 3, 3, 3, 3],k = 5) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 110\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 5) == 21\n assert candidate(nums = [20000, 19000, 18000, 17000, 16000, 15000, 14000, 13000, 12000, 11000, 10000],k = 10) == 110000\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],k = 15) == 1620\n assert candidate(nums = [1, 5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5],k = 25) == 30\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6],k = 4) == 10\n assert candidate(nums = [10000, 20000, 10000, 20000, 10000, 20000, 10000, 20000, 10000, 20000, 10000],k = 7) == 110000\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 8) == 18\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 80\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],k = 15) == 210\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 4) == 300\n", "comparison": "exact"}, "public_tests": ["[1,4,3,7,4,5]\n3", "[5,5,4,5,4,1,1,1]\n0"], "hints": ["Try thinking about the prefix before index k and the suffix after index k as two separate arrays.", "Using two pointers or binary search, we can find the maximum prefix of each array where the numbers are less than or equal to a certain value"], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumScore", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:59+00:00", "tests_total": 98, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "two-pointers", "binary-search", "stack", "monotonic-stack", "cartesian-tree"]}, "language": "python", "interface": {"raw_signature": "def maximumScore(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "maximumScore", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1796, "task_id": "second-largest-digit-in-a-string", "difficulty": "Easy", "problem_description": "Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist.\n\nAn alphanumeric string is a string consisting of lowercase English letters and digits.\n\nExample 1:\n\nInput: s = \"dfa12321afd\"\nOutput: 2\nExplanation: The digits that appear in s are [1, 2, 3]. The second largest digit is 2.\n\nExample 2:\n\nInput: s = \"abc1111\"\nOutput: -1\nExplanation: The digits that appear in s are [1]. There is no second largest digit.\n\nConstraints:\n\n- 1 <= s.length <= 500\n- s consists of only lowercase English letters and digits.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"9876543210\") == 8\n assert candidate(s = \"same1same1same1\") == -1\n assert candidate(s = \"abcdefghij0\") == -1\n assert candidate(s = \"abc1111\") == -1\n assert candidate(s = \"1a\") == -1\n assert candidate(s = \"1234567890\") == 8\n assert candidate(s = \"dfa12321afd\") == 2\n assert candidate(s = \"a1\") == -1\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0\") == 8\n assert candidate(s = \"11223344556677889900\") == 8\n assert candidate(s = \"unique9\") == -1\n assert candidate(s = \"a1a2a3a4a5a6a7a8a9a0\") == 8\n assert candidate(s = \"0000000000\") == -1\n assert candidate(s = \"9999999999\") == -1\n assert candidate(s = \"00000000001111111111\") == 0\n assert candidate(s = \"1001\") == 0\n assert candidate(s = \"abcdefg\") == -1\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0\") == 8\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz0\") == -1\n assert candidate(s = \"0a0b0c0d0e0f0g0h0i0j0k0l0m0n0o0p0q0r0s0t0u0v0w0x0y0z0\") == -1\n assert candidate(s = \"abcd1abcd2abcd3abcd4abcd5abcd6abcd7abcd8abcd9abcd0\") == 8\n assert candidate(s = \"9a8b7c6d5e4f3g2h1i0\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == 8\n assert candidate(s = \"abc123xyz123\") == 2\n assert candidate(s = \"9876543210abc9876543210\") == 8\n assert candidate(s = \"9223372036854775807\") == 8\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p9o8n7m6l5k4j3i2h1g0f9e8d7c6b5a4\") == 8\n assert candidate(s = \"1234567890abcdefghijklmnopqrstuvwxyz\") == 8\n assert candidate(s = \"1234567890abcdefghij0123456789\") == 8\n assert candidate(s = \"99887766554433221100\") == 8\n assert candidate(s = \"abcdefghij01234567890\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == 8\n assert candidate(s = \"abc123abc123abc123\") == 2\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == -1\n assert candidate(s = \"abc123xyz123abc123\") == 2\n assert candidate(s = \"1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz\") == 8\n assert candidate(s = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == -1\n assert candidate(s = \"123abc456def789ghi123\") == 8\n assert candidate(s = \"1\") == -1\n assert candidate(s = \"a1b1c2d2e3f3g4h4i5j5k6l6m7n7o8p8q9r0\") == 8\n assert candidate(s = \"1223344556677889900\") == 8\n assert candidate(s = \"1234123412341234\") == 3\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\") == 0\n assert candidate(s = \"abc123123123abc123123\") == 2\n assert candidate(s = \"000000000000000000000\") == -1\n assert candidate(s = \"123456789098765432101234567890\") == 8\n assert candidate(s = \"a1b1c2d2e3f3g4h4i5j5\") == 4\n assert candidate(s = \"1111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\") == 8\n assert candidate(s = \"1234567890123456789012345678901234567890\") == 8\n assert candidate(s = \"999888777666555444333222111000\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0\") == 8\n assert candidate(s = \"9876543210abcdefghijklmnopqrstuvwxyz\") == 8\n assert candidate(s = \"99999999999999999999\") == -1\n assert candidate(s = \"012345678901234567890123456789\") == 8\n assert candidate(s = \"10011001100110011001100110011001100110011001\") == 0\n assert candidate(s = \"1234567890abcdefghijk\") == 8\n assert candidate(s = \"abcdefghij0123456789\") == 8\n assert candidate(s = \"5555555555\") == -1\n assert candidate(s = \"55555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555\") == -1\n assert candidate(s = \"987654321009876543210987654321098765432109876543210\") == 8\n assert candidate(s = \"1234567890abcdefghij1234567890\") == 8\n assert candidate(s = \"12345678901234567890\") == 8\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij012345678901234567890123456789\") == 8\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz1234567890\") == 8\n assert candidate(s = \"98765432109876543210\") == 8\n assert candidate(s = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z11\") == -1\n assert candidate(s = \"111222333444555666777888999\") == 8\n assert candidate(s = \"999999999999999999999999999999999999999999999999\") == -1\n assert candidate(s = \"abcdefg1234567890\") == 8\n assert candidate(s = \"5555555555555\") == -1\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij012345678901234567890123456789\") == 8\n assert candidate(s = \"a1b2c2d3e3f4g4h5i5j6k6l7m7n8o8p9q9r0\") == 8\n assert candidate(s = \"zzzzz99999\") == -1\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1\") == -1\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p\") == 8\n assert candidate(s = \"9876543210abcdefg\") == 8\n assert candidate(s = \"98765432100123456789\") == 8\n assert candidate(s = \"0000000000000000000000000000000000000000000000000\") == -1\n assert candidate(s = \"abc123xyz456\") == 5\n assert candidate(s = \"123456789012345678901234567890123456789012345678901234567890\") == 8\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7\") == 8\n assert candidate(s = \"zzzzzzzzzzzzzzzzz9zzzzzzzzzzzzzzzz8\") == 8\n assert candidate(s = \"aabbccddeeffgghhii123456789\") == 8\n assert candidate(s = \"0123456789\") == 8\n assert candidate(s = \"abcdefghij1234567890\") == 8\n assert candidate(s = \"abcabcabc123123123\") == 2\n assert candidate(s = \"zzz9zzz8zzz7zzz6zzz5zzz4zzz3zzz2zzz1zzz0zzz\") == 8\n assert candidate(s = \"5555555555555555\") == -1\n assert candidate(s = \"a1b\") == -1\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t\") == 8\n assert candidate(s = \"111222333444555666777888999000\") == 8\n assert candidate(s = \"zzz999zzz888zzz\") == 8\n assert candidate(s = \"0000000000000111111111111222222222222333333333\") == 2\n assert candidate(s = \"abcd1234567890abcd\") == 8\n assert candidate(s = \"123abc123abc123\") == 2\n assert candidate(s = \"123abc456def789ghi0jkl\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0\") == 8\n assert candidate(s = \"00000000000000000000\") == -1\n assert candidate(s = \"abcdefghij012345678909876543210\") == 8\n assert candidate(s = \"123456789012345678901234567890\") == 8\n assert candidate(s = \"9999999999999999999999999999\") == -1\n assert candidate(s = \"987654321098765432109876543210\") == 8\n assert candidate(s = \"abc123xyz987\") == 8\n assert candidate(s = \"0000111122223333444455556666777788889999\") == 8\n assert candidate(s = \"555555555555555555555555555555555555\") == -1\n assert candidate(s = \"1a1b2c2d3e3f4g4h5i5j6k6l7m7n8o8p9q9r0s0t1u2v3w4x5y6z7\") == 8\n assert candidate(s = \"1122334455667788990011223344556677889900\") == 8\n assert candidate(s = \"0123456789abcdefghij0123456789\") == 8\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j\") == 8\n assert candidate(s = \"1111111111111111111112\") == 1\n assert candidate(s = \"1234567890abcdefghijabcdefghijabcdefghijabcdefghij012345678901234567890123456789\") == 8\n assert candidate(s = \"1234567890abcdefghij\") == 8\n assert candidate(s = \"122222222222222222222\") == 1\n assert candidate(s = \"123123123123123123123123123123123\") == 2\n assert candidate(s = \"9999999999888888888877777777766666666555555554444444433333333222222221111111100000000\") == 8\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz9876543210\") == 8\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1\") == 8\n assert candidate(s = \"111122223333444455556666777788889999\") == 8\n assert candidate(s = \"abcdefghij9876543210\") == 8\n assert candidate(s = \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\") == -1\n assert candidate(s = \"abcd1234efgh5678ijkl90mnop\") == 8\n assert candidate(s = \"123123123123123\") == 2\n assert candidate(s = \"9876543210abcdefghij0123456789\") == 8\n assert candidate(s = \"5555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555\") == -1\n assert candidate(s = \"zz9zz8zz7zz6zz5zz4zz3zz2zz1zz0zz\") == 8\n assert candidate(s = \"12345678901234567890abcdefghijabcdefghijabcdefghijabcdefghij012345678901234567890123456789\") == 8\n assert candidate(s = \"0102030405060708090\") == 8\n assert candidate(s = \"abc1234567890\") == 8\n", "comparison": "exact"}, "public_tests": ["\"dfa12321afd\"", "\"abc1111\""], "hints": ["First of all, get the distinct characters since we are only interested in those", "Let's note that there might not be any digits."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().secondHighest", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:04+00:00", "tests_total": 131, "tests_dropped": 2, "flags": [], "topic_tags": ["hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def secondHighest(self, s: str) -> int:", "container": "Solution", "callable": "secondHighest", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1798, "task_id": "maximum-number-of-consecutive-values-you-can-make", "difficulty": "Medium", "problem_description": "You are given an integer array coins of length n which represents the n coins that you own. The value of the i^th coin is coins[i]. You can make some value x if you can choose some of your n coins such that their values sum up to x.\n\nReturn the maximum number of consecutive integer values that you can make with your coins starting from and including 0.\n\nNote that you may have multiple coins of the same value.\n\nExample 1:\n\nInput: coins = [1,3]\nOutput: 2\nExplanation: You can make the following values:\n- 0: take []\n- 1: take [1]\nYou can make 2 consecutive integer values starting from 0.\n\nExample 2:\n\nInput: coins = [1,1,1,4]\nOutput: 8\nExplanation: You can make the following values:\n- 0: take []\n- 1: take [1]\n- 2: take [1,1]\n- 3: take [1,1,1]\n- 4: take [4]\n- 5: take [4,1]\n- 6: take [4,1,1]\n- 7: take [4,1,1,1]\nYou can make 8 consecutive integer values starting from 0.\n\nExample 3:\n\nInput: coins = [1,4,10,3,1]\nOutput: 20\n\nConstraints:\n\n- coins.length == n\n- 1 <= n <= 4 * 10^4\n- 1 <= coins[i] <= 4 * 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(coins = [1, 3]) == 2\n assert candidate(coins = [1, 2, 5]) == 4\n assert candidate(coins = [2, 2, 2, 2]) == 1\n assert candidate(coins = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 56\n assert candidate(coins = [1]) == 2\n assert candidate(coins = [1, 4, 10, 3, 1]) == 20\n assert candidate(coins = [40000, 40000, 40000, 40000]) == 1\n assert candidate(coins = [4, 3, 2, 1]) == 11\n assert candidate(coins = [100, 200, 300, 400, 500]) == 1\n assert candidate(coins = [1, 2, 3, 4, 5]) == 16\n assert candidate(coins = [1, 1, 1, 1, 1]) == 6\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1024\n assert candidate(coins = [1, 1, 3, 4]) == 10\n assert candidate(coins = [1, 2, 5, 10]) == 4\n assert candidate(coins = [100, 400, 200, 300]) == 1\n assert candidate(coins = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 1\n assert candidate(coins = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 21\n assert candidate(coins = [2]) == 1\n assert candidate(coins = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(coins = [10000, 20000, 30000, 40000]) == 1\n assert candidate(coins = [100, 400, 1, 1, 1]) == 4\n assert candidate(coins = [2, 2, 3, 3, 3, 4]) == 1\n assert candidate(coins = [1, 1, 3, 4, 10]) == 20\n assert candidate(coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 56\n assert candidate(coins = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 84\n assert candidate(coins = [1, 1, 1, 4]) == 8\n assert candidate(coins = [2, 4, 6, 8]) == 1\n assert candidate(coins = [1, 1, 2, 2, 3, 3]) == 13\n assert candidate(coins = [40000]) == 1\n assert candidate(coins = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 1\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100]) == 4\n assert candidate(coins = [5, 7, 11, 13, 17, 19, 23, 29, 31]) == 1\n assert candidate(coins = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 31\n assert candidate(coins = [2, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144]) == 1\n assert candidate(coins = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 1\n assert candidate(coins = [1, 2, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == 3073\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000]) == 4\n assert candidate(coins = [1, 5, 10, 25, 50, 100, 200, 500, 1000]) == 2\n assert candidate(coins = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 1\n assert candidate(coins = [3, 6, 9, 12, 15, 18, 21, 24, 27]) == 1\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2048\n assert candidate(coins = [2, 3, 6, 12, 24, 48, 96, 192, 384, 768]) == 1\n assert candidate(coins = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 111\n assert candidate(coins = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 5, 5, 5, 5, 5]) == 41\n assert candidate(coins = [1, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576]) == 2\n assert candidate(coins = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 1\n assert candidate(coins = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 73\n assert candidate(coins = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256]) == 1023\n assert candidate(coins = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n assert candidate(coins = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]) == 1597\n assert candidate(coins = [1, 2, 3, 6, 11, 20, 37, 68, 129, 254]) == 532\n assert candidate(coins = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(coins = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 1\n assert candidate(coins = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 821\n assert candidate(coins = [100, 200, 200, 300, 400, 400, 400, 500, 600, 600, 700, 800, 800, 900, 1000]) == 1\n assert candidate(coins = [2, 2, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 7]) == 1\n assert candidate(coins = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 46\n assert candidate(coins = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(coins = [1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 8192\n assert candidate(coins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1\n assert candidate(coins = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2\n assert candidate(coins = [10, 25, 50, 100, 200, 500, 1000, 2000, 5000, 10000]) == 1\n assert candidate(coins = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) == 144\n assert candidate(coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 121\n assert candidate(coins = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 1\n assert candidate(coins = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n assert candidate(coins = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 166\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64]) == 128\n assert candidate(coins = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 111\n assert candidate(coins = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 2\n assert candidate(coins = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 2\n assert candidate(coins = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(coins = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 1\n assert candidate(coins = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 2\n assert candidate(coins = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 28656\n assert candidate(coins = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 213\n assert candidate(coins = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 26\n assert candidate(coins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 32768\n assert candidate(coins = [1, 2, 3, 4, 5, 10, 20, 50, 100, 200]) == 46\n assert candidate(coins = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == 511\n assert candidate(coins = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16]) == 63\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128]) == 256\n assert candidate(coins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(coins = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 164\n assert candidate(coins = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 151\n assert candidate(coins = [4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == 1\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000]) == 4\n assert candidate(coins = [1, 5, 10, 25, 50, 100, 200, 500, 1000, 2000, 5000, 10000]) == 2\n", "comparison": "exact"}, "public_tests": ["[1,3]", "[1,1,1,4]", "[1,4,10,3,1]"], "hints": ["If you can make the first x values and you have a value v, then you can make all the values ≤ v + x", "Sort the array of coins. You can always make the value 0 so you can start with x = 0.", "Process the values starting from the smallest and stop when there is a value that cannot be achieved with the current x."], "metadata": {"canonical_parameter_names": ["coins"], "leetcode_dataset_entry_point": "Solution().getMaximumConsecutive", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:07+00:00", "tests_total": 98, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def getMaximumConsecutive(self, coins: list[int]) -> int:", "container": "Solution", "callable": "getMaximumConsecutive", "parameters": [{"name": "coins", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1800, "task_id": "maximum-ascending-subarray-sum", "difficulty": "Easy", "problem_description": "Given an array of positive integers nums, return the maximum possible sum of an strictly increasing subarray in nums.\n\nA subarray is defined as a contiguous sequence of numbers in an array.\n\nExample 1:\n\nInput: nums = [10,20,30,5,10,50]\nOutput: 65\nExplanation: [5,10,50] is the ascending subarray with the maximum sum of 65.\n\nExample 2:\n\nInput: nums = [10,20,30,40,50]\nOutput: 150\nExplanation: [10,20,30,40,50] is the ascending subarray with the maximum sum of 150.\n\nExample 3:\n\nInput: nums = [12,17,15,13,10,11,12]\nOutput: 33\nExplanation: [10,11,12] is the ascending subarray with the maximum sum of 33.\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 1 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 99, 98, 97, 96]) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [10]) == 10\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [100, 1, 2, 3, 100, 2, 3, 100]) == 106\n assert candidate(nums = [100]) == 100\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 1, 2, 1, 2]) == 3\n assert candidate(nums = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [10, 20, 30, 5, 10, 50]) == 65\n assert candidate(nums = [12, 17, 15, 13, 10, 11, 12]) == 33\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 5]) == 14\n assert candidate(nums = [100, 100, 100]) == 100\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 175\n assert candidate(nums = [5, 10, 9, 15, 20, 25, 20, 30, 40, 50]) == 140\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 40, 41, 42, 43, 44]) == 605\n assert candidate(nums = [5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7]) == 18\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 166\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [50, 1, 2, 3, 4, 50, 5, 6, 7, 8, 9, 50, 10, 11, 12, 13, 14, 15, 50, 16, 17, 18, 19, 20]) == 125\n assert candidate(nums = [30, 20, 10, 21, 22, 23, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [10, 20, 15, 25, 30, 22, 35, 40, 38, 45, 50]) == 133\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 240\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 7, 8, 6, 9, 10, 11, 10]) == 36\n assert candidate(nums = [10, 20, 10, 20, 30, 20, 30, 40, 50, 40, 60]) == 140\n assert candidate(nums = [1, 2, 3, 4, 3, 4, 5, 6, 5, 7, 8, 9, 10, 8, 9, 10, 11]) == 39\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 400\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92]) == 100\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12]) == 23\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 3, 5, 7, 4, 6, 8, 5, 7, 9]) == 21\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 100\n assert candidate(nums = [20, 30, 25, 35, 40, 35, 45, 50, 45, 55, 60, 55, 65, 70, 65, 75, 80]) == 220\n assert candidate(nums = [5, 10, 15, 20, 25, 1, 2, 3, 4, 5, 30, 35, 40, 45, 50, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 215\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 18\n assert candidate(nums = [1, 2, 3, 2, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5]) == 41\n assert candidate(nums = [10, 20, 30, 25, 35, 40, 35, 45, 50, 45, 55, 60, 55, 65, 70, 65, 75, 80, 75, 85, 90]) == 250\n assert candidate(nums = [1, 10, 11, 2, 20, 21, 3, 30, 31, 4, 40, 41, 5, 50, 51, 6, 60, 61, 7, 70, 71]) == 148\n assert candidate(nums = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 747\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1]) == 55\n assert candidate(nums = [3, 2, 1, 10, 20, 30, 25, 35, 45, 55]) == 160\n assert candidate(nums = [10, 20, 15, 25, 30, 20, 35, 40, 50, 45, 60]) == 145\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == 30\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 624\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 225\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 110\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 10, 20, 15, 25, 30, 20, 35, 40]) == 95\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [10, 20, 15, 25, 30, 20, 35, 40, 30, 45, 50]) == 125\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 550\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 100\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 100\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 1, 2, 3, 4, 5, 10, 15, 20]) == 105\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30]) == 50\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 165\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 156\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 100\n assert candidate(nums = [9, 10, 11, 8, 12, 13, 14, 7, 15, 16, 17, 18, 6, 19, 20, 21, 22, 23, 5, 24, 25, 26, 27, 28]) == 135\n assert candidate(nums = [5, 6, 3, 8, 9, 10, 7, 8, 9]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(nums = [30, 31, 32, 33, 34, 35, 15, 16, 17, 18, 19, 20, 21]) == 195\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 22\n assert candidate(nums = [5, 6, 7, 8, 9, 5, 6, 7, 10, 11, 12, 13]) == 64\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10, 11, 12, 13, 14, 1, 2, 3, 4, 5]) == 70\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [50, 40, 30, 20, 10, 20, 30, 40, 50, 60]) == 210\n assert candidate(nums = [10, 20, 10, 20, 30, 40, 30, 40, 50, 60]) == 180\n assert candidate(nums = [10, 20, 30, 25, 40, 50, 60, 55, 70, 80]) == 205\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 14]) == 39\n assert candidate(nums = [5, 1, 2, 3, 4, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [2, 3, 6, 6, 5, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 11, 12, 5, 6, 7]) == 68\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [5, 3, 7, 8, 2, 6, 9, 11, 10, 15]) == 28\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 1, 2, 3, 4, 5]) == 605\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 110\n assert candidate(nums = [10, 20, 30, 25, 26, 27, 28, 29, 30, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 275\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16]) == 72\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 8, 9, 10, 11, 12]) == 50\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 11, 10]) == 32\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 315\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 12, 11, 12]) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 11]) == 51\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 20, 30]) == 61\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 200\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 200\n assert candidate(nums = [10, 15, 20, 25, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(nums = [100, 99, 98, 97, 96, 1, 2, 3, 4, 5]) == 100\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 10, 11, 12, 13, 12, 13, 14, 15]) == 54\n assert candidate(nums = [3, 5, 4, 6, 7, 8, 6, 7, 8, 9, 10, 8, 9, 10, 11, 12, 10, 11, 12, 13, 14]) == 60\n", "comparison": "exact"}, "public_tests": ["[10,20,30,5,10,50]", "[10,20,30,40,50]", "[12,17,15,13,10,11,12]"], "hints": ["It is fast enough to check all possible subarrays", "The end of each ascending subarray will be the start of the next"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxAscendingSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:09+00:00", "tests_total": 128, "tests_dropped": 6, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def maxAscendingSum(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maxAscendingSum", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1801, "task_id": "number-of-orders-in-the-backlog", "difficulty": "Medium", "problem_description": "You are given a 2D integer array orders, where each orders[i] = [price_i, amount_i, orderType_i] denotes that amount_iorders have been placed of type orderType_i at the price price_i. The orderType_i is:\n\n- 0 if it is a batch of buy orders, or\n- 1 if it is a batch of sell orders.\n\nNote that orders[i] represents a batch of amount_i independent orders with the same price and order type. All orders represented by orders[i] will be placed before all orders represented by orders[i+1] for all valid i.\n\nThere is a backlog that consists of orders that have not been executed. The backlog is initially empty. When an order is placed, the following happens:\n\n- If the order is a buy order, you look at the sell order with the smallest price in the backlog. If that sell order's price is smaller than or equal to the current buy order's price, they will match and be executed, and that sell order will be removed from the backlog. Else, the buy order is added to the backlog.\n- Vice versa, if the order is a sell order, you look at the buy order with the largest price in the backlog. If that buy order's price is larger than or equal to the current sell order's price, they will match and be executed, and that buy order will be removed from the backlog. Else, the sell order is added to the backlog.\n\nReturn the total amount of orders in the backlog after placing all the orders from the input. Since this number can be large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: orders = [[10,5,0],[15,2,1],[25,1,1],[30,4,0]]\nOutput: 6\nExplanation: Here is what happens with the orders:\n- 5 orders of type buy with price 10 are placed. There are no sell orders, so the 5 orders are added to the backlog.\n- 2 orders of type sell with price 15 are placed. There are no buy orders with prices larger than or equal to 15, so the 2 orders are added to the backlog.\n- 1 order of type sell with price 25 is placed. There are no buy orders with prices larger than or equal to 25 in the backlog, so this order is added to the backlog.\n- 4 orders of type buy with price 30 are placed. The first 2 orders are matched with the 2 sell orders of the least price, which is 15 and these 2 sell orders are removed from the backlog. The 3^rd order is matched with the sell order of the least price, which is 25 and this sell order is removed from the backlog. Then, there are no more sell orders in the backlog, so the 4^th order is added to the backlog.\nFinally, the backlog has 5 buy orders with price 10, and 1 buy order with price 30. So the total number of orders in the backlog is 6.\n\nExample 2:\n\nInput: orders = [[7,1000000000,1],[15,3,0],[5,999999995,0],[5,1,1]]\nOutput: 999999984\nExplanation: Here is what happens with the orders:\n- 10^9 orders of type sell with price 7 are placed. There are no buy orders, so the 10^9 orders are added to the backlog.\n- 3 orders of type buy with price 15 are placed. They are matched with the 3 sell orders with the least price which is 7, and those 3 sell orders are removed from the backlog.\n- 999999995 orders of type buy with price 5 are placed. The least price of a sell order is 7, so the 999999995 orders are added to the backlog.\n- 1 order of type sell with price 5 is placed. It is matched with the buy order of the highest price, which is 5, and that buy order is removed from the backlog.\nFinally, the backlog has (1000000000-3) sell orders with price 7, and (999999995-1) buy orders with price 5. So the total number of orders = 1999999991, which is equal to 999999984 % (10^9 + 7).\n\nConstraints:\n\n- 1 <= orders.length <= 10^5\n- orders[i].length == 3\n- 1 <= price_i, amount_i <= 10^9\n- orderType_i is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(orders = [[7, 1000000000, 1], [15, 3, 0], [5, 999999995, 0], [5, 1, 1]]) == 999999984\n assert candidate(orders = [[1, 10, 0], [1, 10, 1], [1, 10, 0], [1, 10, 1]]) == 0\n assert candidate(orders = [[100, 1, 0], [200, 2, 0], [300, 3, 1], [400, 4, 1]]) == 10\n assert candidate(orders = [[1, 1, 0], [1, 1, 1], [1, 1, 0], [1, 1, 1]]) == 0\n assert candidate(orders = [[5, 5, 0], [5, 5, 1], [5, 5, 0], [5, 5, 1]]) == 0\n assert candidate(orders = [[100, 100, 0], [100, 100, 1], [101, 100, 0], [99, 100, 1]]) == 0\n assert candidate(orders = [[1, 10, 0], [2, 10, 0], [3, 10, 1], [4, 10, 1]]) == 40\n assert candidate(orders = [[5, 5, 0], [4, 4, 1], [3, 3, 0], [2, 2, 1], [1, 1, 0]]) == 3\n assert candidate(orders = [[100, 10, 0], [200, 15, 0], [100, 5, 1], [200, 20, 1]]) == 20\n assert candidate(orders = [[5, 5, 0], [5, 5, 1]]) == 0\n assert candidate(orders = [[10, 5, 0], [15, 2, 1], [25, 1, 1], [30, 4, 0]]) == 6\n assert candidate(orders = [[100, 1, 0], [99, 2, 0], [98, 3, 0], [97, 4, 1], [96, 5, 1]]) == 3\n assert candidate(orders = [[5, 10, 0], [5, 5, 1], [5, 5, 0], [5, 3, 1]]) == 7\n assert candidate(orders = [[1, 10, 0], [2, 20, 1], [3, 30, 0], [4, 40, 1]]) == 60\n assert candidate(orders = [[100, 10, 0], [99, 9, 1], [98, 8, 0], [97, 7, 1], [96, 6, 0]]) == 8\n assert candidate(orders = [[10, 10, 0], [10, 10, 0], [10, 10, 1], [10, 10, 1]]) == 0\n assert candidate(orders = [[50, 10, 0], [40, 15, 0], [30, 20, 0], [20, 25, 1], [10, 30, 1], [5, 35, 1], [3, 40, 1], [2, 45, 1], [1, 50, 1]]) == 180\n assert candidate(orders = [[10, 5, 0], [20, 5, 0], [30, 5, 0], [40, 5, 0], [10, 5, 1], [20, 5, 1], [30, 5, 1], [40, 5, 1], [5, 5, 0], [35, 5, 1]]) == 30\n assert candidate(orders = [[1, 1000000000, 0], [1, 1000000000, 0], [1, 1000000000, 1], [1, 1000000000, 1], [1, 1000000000, 0], [1, 1000000000, 1]]) == 0\n assert candidate(orders = [[1000000000, 1, 0], [1000000000, 1, 0], [1000000000, 1, 0], [1000000000, 1, 1], [1000000000, 1, 1], [1000000000, 1, 1]]) == 0\n assert candidate(orders = [[10, 5, 0], [9, 5, 0], [8, 5, 0], [7, 5, 0], [6, 5, 0], [6, 5, 1], [7, 5, 1], [8, 5, 1], [9, 5, 1], [10, 5, 1]]) == 20\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 2, 0], [999999998, 3, 0], [999999997, 4, 1], [999999996, 5, 1], [999999995, 6, 1]]) == 9\n assert candidate(orders = [[1, 1000000000, 0], [1000000000, 1, 1], [2, 999999999, 0], [999999999, 2, 1], [3, 999999998, 0], [999999998, 3, 1], [4, 999999997, 0], [999999997, 4, 1]]) == 999999983\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 2, 0], [999999998, 3, 0], [999999997, 4, 1], [999999996, 5, 1]]) == 3\n assert candidate(orders = [[1, 1000, 0], [2, 2000, 1], [3, 3000, 0], [4, 4000, 1], [5, 5000, 0], [6, 6000, 1], [7, 7000, 0], [8, 8000, 1], [9, 9000, 0], [10, 10000, 1]]) == 15000\n assert candidate(orders = [[1000, 1, 0], [1000, 2, 0], [1000, 3, 0], [1000, 1, 1], [1000, 2, 1], [1000, 3, 1]]) == 0\n assert candidate(orders = [[10, 100, 0], [20, 50, 1], [15, 30, 0], [25, 20, 1], [5, 10, 0], [30, 5, 1]]) == 215\n assert candidate(orders = [[100, 10, 0], [90, 5, 1], [80, 15, 0], [70, 20, 1], [60, 25, 0], [50, 30, 1]]) == 5\n assert candidate(orders = [[999999999, 50000, 0], [1, 50000, 1], [999999998, 50000, 0], [2, 50000, 1], [999999997, 50000, 0], [3, 50000, 1]]) == 0\n assert candidate(orders = [[1, 1000000000, 0], [2, 999999999, 0], [3, 999999998, 0], [4, 999999997, 0], [5, 999999996, 0], [5, 999999996, 1], [4, 999999997, 1], [3, 999999998, 1], [2, 999999999, 1], [1, 1000000000, 1]]) == 0\n assert candidate(orders = [[10, 10, 0], [20, 20, 1], [15, 15, 0], [16, 16, 1], [14, 14, 0], [17, 17, 1]]) == 92\n assert candidate(orders = [[10, 1, 0], [9, 2, 0], [8, 3, 0], [7, 4, 0], [6, 5, 1], [5, 6, 1], [4, 7, 1], [3, 8, 1], [2, 9, 1], [1, 10, 1]]) == 35\n assert candidate(orders = [[1000, 1000000, 0], [1001, 1000000, 0], [1002, 1000000, 0], [999, 1000000, 1], [998, 1000000, 1], [997, 1000000, 1]]) == 0\n assert candidate(orders = [[10, 10, 0], [20, 10, 1], [15, 10, 0], [25, 10, 1], [10, 10, 0], [20, 10, 1], [15, 10, 0], [25, 10, 1], [10, 10, 0], [20, 10, 1], [15, 10, 0], [25, 10, 1], [10, 10, 0], [20, 10, 1], [15, 10, 0], [25, 10, 1]]) == 160\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 1], [3, 1000000000, 0], [4, 1000000000, 1], [5, 1000000000, 0], [6, 1000000000, 1]]) == 999999993\n assert candidate(orders = [[10, 1000, 0], [20, 1000, 0], [30, 1000, 0], [40, 1000, 1], [50, 1000, 1], [60, 1000, 1], [70, 1000, 0], [80, 1000, 1], [90, 1000, 0]]) == 5000\n assert candidate(orders = [[10, 5, 0], [20, 10, 0], [30, 15, 0], [40, 20, 0], [50, 25, 0], [10, 5, 1], [20, 10, 1], [30, 15, 1], [40, 20, 1], [50, 25, 1]]) == 60\n assert candidate(orders = [[10, 5, 0], [20, 5, 0], [30, 5, 0], [40, 5, 0], [15, 5, 1], [25, 5, 1], [35, 5, 1], [45, 5, 1]]) == 20\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 0], [3, 1000000000, 0], [1, 1000000000, 1], [2, 1000000000, 1], [3, 1000000000, 1]]) == 999999993\n assert candidate(orders = [[10, 1, 0], [11, 2, 0], [12, 3, 0], [13, 4, 1], [14, 5, 1], [15, 6, 1], [16, 7, 1], [17, 8, 0], [18, 9, 0], [19, 10, 0]]) == 11\n assert candidate(orders = [[10, 1, 0], [10, 2, 0], [10, 3, 0], [10, 4, 1], [10, 5, 1], [10, 6, 1], [10, 7, 1], [10, 8, 0], [10, 9, 0], [10, 10, 0]]) == 11\n assert candidate(orders = [[5, 1, 0], [5, 2, 0], [5, 3, 0], [5, 4, 0], [5, 5, 1], [5, 4, 1], [5, 3, 1], [5, 2, 1], [5, 1, 1]]) == 5\n assert candidate(orders = [[100, 5, 0], [90, 10, 0], [80, 15, 0], [70, 20, 0], [60, 25, 0], [50, 30, 1], [40, 35, 1], [30, 40, 1], [20, 45, 1], [10, 50, 1]]) == 125\n assert candidate(orders = [[10, 1000, 0], [10, 900, 0], [10, 800, 0], [10, 700, 1], [10, 600, 1], [10, 500, 1], [10, 400, 1]]) == 500\n assert candidate(orders = [[10, 5, 0], [10, 5, 1], [10, 5, 0], [10, 5, 1], [10, 5, 0], [10, 5, 1], [10, 5, 0], [10, 5, 1]]) == 0\n assert candidate(orders = [[1, 999999999, 0], [1, 999999999, 0], [1, 999999999, 0], [1, 999999999, 0], [2, 999999999, 1], [2, 999999999, 1], [2, 999999999, 1], [2, 999999999, 1]]) == 999999943\n assert candidate(orders = [[10, 1, 0], [9, 2, 0], [8, 3, 0], [7, 4, 1], [6, 5, 1], [5, 6, 0], [4, 7, 0], [3, 8, 1], [2, 9, 1], [1, 10, 0]]) == 17\n assert candidate(orders = [[5, 100, 0], [10, 100, 1], [15, 100, 0], [20, 100, 1], [25, 100, 0], [30, 100, 1]]) == 200\n assert candidate(orders = [[10, 5, 0], [10, 5, 0], [10, 5, 0], [10, 5, 1], [10, 5, 1], [10, 5, 1], [10, 5, 0], [10, 5, 1], [10, 5, 0], [10, 5, 1]]) == 0\n assert candidate(orders = [[100, 100, 1], [90, 200, 1], [80, 300, 1], [70, 400, 0], [60, 500, 0], [50, 600, 0]]) == 2100\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 1, 0], [999999998, 1, 0], [999999997, 1, 1], [999999996, 1, 1], [999999995, 1, 1]]) == 0\n assert candidate(orders = [[10, 1, 0], [20, 2, 0], [30, 3, 0], [40, 4, 0], [50, 5, 0], [10, 1, 1], [20, 2, 1], [30, 3, 1], [40, 4, 1], [50, 5, 1]]) == 12\n assert candidate(orders = [[1, 1000000000, 0], [1000000000, 1, 1], [500000000, 2, 0], [1000000000, 999999999, 1], [1, 1, 0]]) == 999999996\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 1], [3, 1000000000, 0], [4, 1000000000, 1], [5, 1000000000, 0], [6, 1000000000, 1]]) == 999999993\n assert candidate(orders = [[100, 1000, 0], [999, 500, 1], [998, 750, 1], [1000, 1000, 0], [999, 250, 0]]) == 1000\n assert candidate(orders = [[100, 1, 0], [99, 2, 0], [98, 3, 0], [97, 4, 1], [96, 5, 1], [95, 6, 0], [94, 7, 1], [93, 8, 0], [92, 9, 1]]) == 5\n assert candidate(orders = [[1, 1000000000, 0], [1, 1000000000, 0], [1, 1000000000, 0], [1, 1000000000, 1], [1, 1000000000, 1], [1, 1000000000, 1]]) == 0\n assert candidate(orders = [[100, 1, 0], [99, 2, 0], [98, 3, 0], [97, 4, 1], [96, 5, 1], [95, 6, 0], [94, 7, 0], [93, 8, 1], [92, 9, 1]]) == 7\n assert candidate(orders = [[100, 100, 0], [200, 200, 0], [300, 300, 0], [400, 400, 0], [500, 500, 1], [600, 600, 1], [700, 700, 1], [800, 800, 1], [900, 900, 1], [1000, 1000, 1]]) == 5500\n assert candidate(orders = [[10, 5, 0], [20, 10, 0], [30, 15, 0], [5, 1, 1], [15, 2, 1], [25, 3, 1]]) == 24\n assert candidate(orders = [[100, 100, 0], [99, 150, 0], [98, 200, 0], [97, 250, 1], [96, 300, 1], [95, 350, 1]]) == 450\n assert candidate(orders = [[1, 1, 0], [2, 1, 0], [3, 1, 0], [4, 1, 0], [5, 1, 0], [6, 1, 0], [7, 1, 0], [8, 1, 0], [9, 1, 0], [10, 1, 0], [1, 1, 1], [2, 1, 1], [3, 1, 1], [4, 1, 1], [5, 1, 1], [6, 1, 1], [7, 1, 1], [8, 1, 1], [9, 1, 1], [10, 1, 1]]) == 10\n assert candidate(orders = [[1000000000, 1, 0], [1, 1, 1], [500000000, 1, 0], [500000000, 1, 1], [1000000000, 1, 0], [1, 1, 1]]) == 0\n assert candidate(orders = [[100, 100, 0], [90, 200, 0], [80, 300, 0], [70, 400, 1], [60, 500, 1], [50, 600, 1]]) == 900\n assert candidate(orders = [[10, 1, 0], [20, 2, 0], [10, 1, 1], [20, 2, 1], [30, 3, 0], [25, 2, 1], [15, 1, 0], [5, 1, 1]]) == 1\n assert candidate(orders = [[100, 5, 0], [200, 10, 0], [150, 5, 1], [160, 5, 1], [200, 20, 0], [150, 10, 1]]) == 15\n assert candidate(orders = [[10, 10, 0], [20, 10, 0], [30, 10, 0], [40, 10, 0], [50, 10, 0], [10, 10, 1], [20, 10, 1], [30, 10, 1], [40, 10, 1], [50, 10, 1], [10, 10, 0], [20, 10, 0], [30, 10, 0], [40, 10, 0], [50, 10, 0], [10, 10, 1], [20, 10, 1], [30, 10, 1], [40, 10, 1], [50, 10, 1]]) == 60\n assert candidate(orders = [[100, 1, 0], [90, 2, 0], [80, 3, 0], [70, 4, 1], [60, 5, 1], [50, 6, 1], [40, 7, 1], [30, 8, 1], [20, 9, 1], [10, 10, 1]]) == 43\n assert candidate(orders = [[1, 1, 0], [2, 1, 0], [3, 1, 0], [4, 1, 0], [5, 1, 0], [5, 1, 1], [4, 1, 1], [3, 1, 1], [2, 1, 1], [1, 1, 1]]) == 0\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 2, 0], [999999998, 3, 0], [999999997, 4, 1], [999999996, 5, 1], [999999995, 6, 0], [999999994, 7, 0], [999999993, 8, 1], [999999992, 9, 1]]) == 7\n assert candidate(orders = [[10, 100, 0], [20, 50, 0], [30, 200, 1], [15, 150, 1], [25, 100, 0], [35, 100, 1]]) == 400\n assert candidate(orders = [[1, 1, 0], [1, 1, 1], [1, 1, 0], [1, 1, 1], [1, 1, 0], [1, 1, 1]]) == 0\n assert candidate(orders = [[1, 1, 0], [2, 2, 0], [3, 3, 0], [4, 4, 0], [5, 5, 0], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1]]) == 12\n assert candidate(orders = [[100, 5, 0], [100, 5, 0], [100, 5, 1], [100, 5, 1], [100, 5, 0], [100, 5, 1]]) == 0\n assert candidate(orders = [[5, 1, 0], [6, 1, 0], [7, 1, 0], [8, 1, 0], [9, 1, 0], [10, 1, 1], [11, 1, 1], [12, 1, 1], [13, 1, 1], [14, 1, 1]]) == 10\n assert candidate(orders = [[10, 10, 0], [20, 20, 0], [30, 30, 0], [40, 40, 0], [50, 50, 0], [10, 1, 1], [20, 2, 1], [30, 3, 1], [40, 4, 1], [50, 5, 1]]) == 135\n assert candidate(orders = [[50, 10, 0], [50, 15, 0], [50, 20, 0], [50, 25, 1], [50, 30, 1], [50, 35, 1], [50, 40, 1], [50, 45, 1], [50, 50, 1]]) == 180\n assert candidate(orders = [[100, 50, 0], [100, 50, 0], [100, 50, 0], [100, 50, 1], [100, 50, 1], [100, 50, 1]]) == 0\n assert candidate(orders = [[10, 5, 0], [20, 5, 0], [30, 5, 0], [10, 5, 1], [20, 5, 1], [30, 5, 1], [15, 5, 0], [25, 5, 0], [35, 5, 0]]) == 15\n assert candidate(orders = [[10, 1, 0], [10, 1, 1], [11, 1, 0], [9, 1, 1], [12, 1, 0], [8, 1, 1], [13, 1, 0], [7, 1, 1]]) == 0\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 0], [3, 1000000000, 0], [4, 1000000000, 1], [5, 1000000000, 1], [6, 1000000000, 1]]) == 999999965\n assert candidate(orders = [[10, 10, 0], [10, 10, 1], [10, 10, 0], [10, 10, 1], [10, 10, 0], [10, 10, 1], [10, 10, 0], [10, 10, 1], [10, 10, 0], [10, 10, 1]]) == 0\n assert candidate(orders = [[1, 1000000000, 0], [2, 999999999, 0], [3, 999999998, 0], [4, 999999997, 1], [5, 999999996, 1], [6, 999999995, 1], [7, 999999994, 1], [8, 999999993, 0], [9, 999999992, 0], [10, 999999991, 0]]) == 999999982\n assert candidate(orders = [[50, 10, 0], [40, 20, 0], [30, 30, 0], [20, 40, 0], [10, 50, 0], [10, 60, 1], [20, 70, 1], [30, 80, 1], [40, 90, 1], [50, 100, 1], [15, 5, 0], [25, 5, 0], [35, 5, 0], [45, 5, 0], [55, 5, 0]]) == 335\n assert candidate(orders = [[100, 10, 0], [90, 10, 0], [80, 10, 0], [70, 10, 0], [60, 10, 0], [50, 10, 1], [40, 10, 1], [30, 10, 1], [20, 10, 1], [10, 10, 1]]) == 0\n assert candidate(orders = [[10, 5, 0], [20, 5, 0], [30, 5, 0], [15, 10, 1], [25, 10, 1], [35, 10, 1], [10, 5, 0], [20, 5, 0], [30, 5, 0], [15, 10, 1], [25, 10, 1], [35, 10, 1]]) == 50\n assert candidate(orders = [[100, 100000000, 0], [90, 200000000, 0], [80, 300000000, 1], [70, 400000000, 1], [60, 500000000, 0]]) == 900000000\n assert candidate(orders = [[100, 500, 0], [90, 500, 0], [80, 500, 0], [70, 500, 1], [60, 500, 1], [50, 500, 1]]) == 0\n assert candidate(orders = [[10, 1, 0], [10, 2, 1], [10, 3, 0], [10, 4, 1], [10, 5, 0]]) == 3\n assert candidate(orders = [[1, 1000000000, 0], [2, 500000000, 1], [3, 300000000, 0], [4, 200000000, 1], [5, 400000000, 0]]) == 1000000000\n assert candidate(orders = [[100, 5, 0], [101, 3, 0], [102, 2, 0], [99, 5, 1], [98, 6, 1], [97, 7, 1]]) == 8\n assert candidate(orders = [[500, 10, 0], [500, 10, 1], [500, 5, 0], [500, 5, 1], [500, 3, 0], [500, 3, 1]]) == 0\n assert candidate(orders = [[50, 10, 0], [60, 15, 0], [70, 20, 0], [40, 5, 1], [55, 10, 1], [65, 15, 1], [50, 10, 1], [60, 15, 1], [70, 20, 1]]) == 50\n assert candidate(orders = [[10, 1, 0], [20, 1, 1], [30, 1, 0], [40, 1, 1], [50, 1, 0], [60, 1, 1], [70, 1, 0], [80, 1, 1], [90, 1, 0]]) == 1\n assert candidate(orders = [[10, 10, 0], [9, 20, 0], [8, 30, 0], [7, 40, 1], [6, 50, 1], [5, 60, 1]]) == 90\n assert candidate(orders = [[20, 5, 0], [15, 3, 0], [10, 2, 1], [5, 1, 1], [15, 4, 0], [10, 6, 1]]) == 3\n assert candidate(orders = [[100, 1, 0], [200, 1, 0], [300, 1, 0], [400, 1, 0], [500, 1, 0], [150, 1, 1], [250, 1, 1], [350, 1, 1], [450, 1, 1], [550, 1, 1]]) == 6\n assert candidate(orders = [[999999999, 1, 0], [999999998, 2, 0], [999999997, 3, 0], [999999996, 4, 1], [999999995, 5, 1]]) == 3\n assert candidate(orders = [[10, 1, 0], [10, 1, 1], [10, 1, 0], [10, 1, 1], [10, 1, 0], [10, 1, 1], [10, 1, 0], [10, 1, 1], [10, 1, 0], [10, 1, 1]]) == 0\n assert candidate(orders = [[100, 500, 0], [90, 400, 0], [80, 300, 0], [70, 200, 1], [60, 100, 1], [50, 50, 1], [40, 50, 1], [30, 100, 1], [20, 200, 1]]) == 500\n assert candidate(orders = [[100, 100000, 0], [200, 200000, 0], [150, 50000, 1], [175, 75000, 1]]) == 175000\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 1, 0], [999999998, 1, 0], [999999997, 1, 0], [999999996, 1, 0], [999999995, 1, 1], [999999994, 1, 1], [999999993, 1, 1], [999999992, 1, 1], [999999991, 1, 1]]) == 0\n assert candidate(orders = [[1, 1, 0], [2, 2, 0], [3, 3, 0], [4, 4, 0], [5, 5, 0], [6, 6, 0], [7, 7, 0], [8, 8, 0], [9, 9, 0], [10, 10, 0], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1]]) == 54\n assert candidate(orders = [[5, 10, 0], [10, 20, 0], [15, 30, 0], [20, 10, 1], [25, 20, 1], [30, 30, 1]]) == 120\n assert candidate(orders = [[100, 10, 0], [90, 5, 1], [80, 3, 0], [70, 2, 1], [60, 4, 0], [50, 1, 1]]) == 9\n assert candidate(orders = [[10, 1, 0], [20, 1, 0], [30, 1, 0], [40, 1, 0], [50, 1, 0], [10, 1, 1], [20, 1, 1], [30, 1, 1], [40, 1, 1], [50, 1, 1]]) == 4\n assert candidate(orders = [[1, 1000000000, 1], [1000000000, 1, 0], [2, 1000000000, 1], [999999999, 1, 0], [3, 1000000000, 1]]) == 999999984\n assert candidate(orders = [[1, 10, 0], [2, 10, 0], [3, 10, 0], [4, 10, 1], [5, 10, 1], [6, 10, 1], [7, 10, 1], [8, 10, 1], [9, 10, 1]]) == 90\n assert candidate(orders = [[100, 1, 0], [100, 1, 0], [100, 1, 0], [100, 1, 1], [100, 1, 1], [100, 1, 1], [100, 1, 0], [100, 1, 0], [100, 1, 0], [100, 1, 1], [100, 1, 1], [100, 1, 1], [100, 1, 0], [100, 1, 0], [100, 1, 0], [100, 1, 1], [100, 1, 1], [100, 1, 1]]) == 0\n assert candidate(orders = [[100, 10, 0], [90, 20, 0], [80, 30, 0], [70, 40, 0], [60, 50, 0], [50, 60, 1], [40, 70, 1], [30, 80, 1], [20, 90, 1], [10, 100, 1]]) == 250\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 0], [3, 1000000000, 1], [4, 1000000000, 1], [5, 1000000000, 0]]) == 999999986\n assert candidate(orders = [[1, 1, 0], [2, 2, 1], [3, 3, 0], [4, 4, 1], [5, 5, 0], [6, 6, 1], [7, 7, 0], [8, 8, 1], [9, 9, 0], [10, 10, 1]]) == 15\n assert candidate(orders = [[50, 10, 0], [40, 15, 0], [30, 20, 0], [20, 25, 1], [10, 30, 1], [15, 35, 0], [25, 40, 1]]) == 65\n", "comparison": "exact"}, "public_tests": ["[[10,5,0],[15,2,1],[25,1,1],[30,4,0]]", "[[7,1000000000,1],[15,3,0],[5,999999995,0],[5,1,1]]"], "hints": ["Store the backlog buy and sell orders in two heaps, the buy orders in a max heap by price and the sell orders in a min heap by price.", "Store the orders in batches and update the fields according to new incoming orders. Each batch should only take 1 \"slot\" in the heap."], "metadata": {"canonical_parameter_names": ["orders"], "leetcode_dataset_entry_point": "Solution().getNumberOfBacklogOrders", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:11+00:00", "tests_total": 113, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "heap-priority-queue", "simulation"]}, "language": "python", "interface": {"raw_signature": "def getNumberOfBacklogOrders(self, orders: List[List[int]]) -> int:", "container": "Solution", "callable": "getNumberOfBacklogOrders", "parameters": [{"name": "orders", "type": "List[List[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1802, "task_id": "maximum-value-at-a-given-index-in-a-bounded-array", "difficulty": "Medium", "problem_description": "You are given three positive integers: n, index, and maxSum. You want to construct an array nums (0-indexed) that satisfies the following conditions:\n\n- nums.length == n\n- nums[i] is a positive integer where 0 <= i < n.\n- abs(nums[i] - nums[i+1]) <= 1 where 0 <= i < n-1.\n- The sum of all the elements of nums does not exceed maxSum.\n- nums[index] is maximized.\n\nReturn nums[index] of the constructed array.\n\nNote that abs(x) equals x if x >= 0, and -x otherwise.\n\nExample 1:\n\nInput: n = 4, index = 2, maxSum = 6\nOutput: 2\nExplanation: nums = [1,2,2,1] is one array that satisfies all the conditions.\nThere are no arrays that satisfy all the conditions and have nums[2] == 3, so 2 is the maximum nums[2].\n\nExample 2:\n\nInput: n = 6, index = 1, maxSum = 10\nOutput: 3\n\nConstraints:\n\n- 1 <= n <= maxSum <= 10^9\n- 0 <= index < n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,index = 0,maxSum = 1) == 1\n assert candidate(n = 10,index = 5,maxSum = 50) == 7\n assert candidate(n = 6,index = 1,maxSum = 10) == 3\n assert candidate(n = 1000000000,index = 500000000,maxSum = 1000000000) == 1\n assert candidate(n = 4,index = 2,maxSum = 6) == 2\n assert candidate(n = 20,index = 10,maxSum = 210) == 15\n assert candidate(n = 7,index = 3,maxSum = 20) == 4\n assert candidate(n = 100000,index = 0,maxSum = 10000000) == 4450\n assert candidate(n = 9,index = 4,maxSum = 25) == 5\n assert candidate(n = 1000,index = 500,maxSum = 500000) == 750\n assert candidate(n = 1000000000,index = 999999999,maxSum = 1000000000) == 1\n assert candidate(n = 20,index = 10,maxSum = 200) == 15\n assert candidate(n = 100,index = 50,maxSum = 5000) == 75\n assert candidate(n = 4,index = 1,maxSum = 10) == 3\n assert candidate(n = 1000,index = 500,maxSum = 100000) == 315\n assert candidate(n = 100000,index = 99999,maxSum = 10000000) == 4450\n assert candidate(n = 1000000,index = 500000,maxSum = 10000000) == 3001\n assert candidate(n = 999999999,index = 0,maxSum = 999999999) == 1\n assert candidate(n = 1000000000,index = 0,maxSum = 1000000000) == 1\n assert candidate(n = 50,index = 24,maxSum = 1225) == 37\n assert candidate(n = 100,index = 50,maxSum = 5050) == 75\n assert candidate(n = 9,index = 4,maxSum = 45) == 7\n assert candidate(n = 35,index = 17,maxSum = 3000) == 94\n assert candidate(n = 10000,index = 4999,maxSum = 1000000) == 995\n assert candidate(n = 9,index = 4,maxSum = 100) == 13\n assert candidate(n = 20,index = 0,maxSum = 50) == 8\n assert candidate(n = 50,index = 25,maxSum = 500) == 22\n assert candidate(n = 500,index = 250,maxSum = 150000) == 425\n assert candidate(n = 100,index = 50,maxSum = 10000) == 125\n assert candidate(n = 5,index = 2,maxSum = 15) == 4\n assert candidate(n = 50,index = 24,maxSum = 1275) == 38\n assert candidate(n = 200,index = 100,maxSum = 2000) == 43\n assert candidate(n = 1,index = 0,maxSum = 1000000000) == 1000000000\n assert candidate(n = 8,index = 3,maxSum = 30) == 5\n assert candidate(n = 12,index = 6,maxSum = 75) == 9\n assert candidate(n = 10,index = 0,maxSum = 36) == 7\n assert candidate(n = 50,index = 24,maxSum = 5000) == 112\n assert candidate(n = 20,index = 19,maxSum = 50) == 8\n assert candidate(n = 500000000,index = 250000000,maxSum = 1000000000) == 22361\n assert candidate(n = 2,index = 1,maxSum = 3) == 2\n assert candidate(n = 15,index = 7,maxSum = 120) == 11\n assert candidate(n = 10,index = 0,maxSum = 100) == 14\n assert candidate(n = 15,index = 7,maxSum = 500) == 37\n assert candidate(n = 50,index = 25,maxSum = 1000) == 32\n assert candidate(n = 3,index = 1,maxSum = 15) == 5\n assert candidate(n = 25,index = 12,maxSum = 1500) == 66\n assert candidate(n = 7,index = 3,maxSum = 25) == 5\n assert candidate(n = 10,index = 9,maxSum = 100) == 14\n assert candidate(n = 3,index = 1,maxSum = 1000000000) == 333333334\n assert candidate(n = 500,index = 250,maxSum = 2000) == 39\n assert candidate(n = 20,index = 19,maxSum = 200) == 19\n assert candidate(n = 500000,index = 250000,maxSum = 100000000) == 9975\n assert candidate(n = 15,index = 7,maxSum = 100) == 10\n assert candidate(n = 200,index = 100,maxSum = 20100) == 150\n assert candidate(n = 999999999,index = 499999999,maxSum = 999999999) == 1\n assert candidate(n = 200000000,index = 100000000,maxSum = 500000000) == 17321\n assert candidate(n = 1000000,index = 999999,maxSum = 2000000) == 1414\n assert candidate(n = 1000000000,index = 1,maxSum = 1000000000) == 1\n assert candidate(n = 10,index = 4,maxSum = 55) == 8\n assert candidate(n = 100,index = 50,maxSum = 1000) == 31\n assert candidate(n = 10,index = 9,maxSum = 25) == 6\n assert candidate(n = 10,index = 9,maxSum = 36) == 7\n assert candidate(n = 100000,index = 50000,maxSum = 5000000) == 2214\n assert candidate(n = 10,index = 0,maxSum = 50) == 9\n assert candidate(n = 2,index = 1,maxSum = 6) == 3\n assert candidate(n = 10,index = 0,maxSum = 25) == 6\n assert candidate(n = 150,index = 75,maxSum = 100000) == 704\n assert candidate(n = 2,index = 1,maxSum = 1000000000) == 500000000\n assert candidate(n = 5,index = 2,maxSum = 17) == 4\n assert candidate(n = 500000000,index = 250000000,maxSum = 800000000) == 17321\n assert candidate(n = 5,index = 2,maxSum = 20) == 5\n assert candidate(n = 7,index = 3,maxSum = 50) == 8\n", "comparison": "exact"}, "public_tests": ["4\n2\n6", "6\n1\n10"], "hints": ["What if the problem was instead determining if you could generate a valid array with nums[index] == target?", "To generate the array, set nums[index] to target, nums[index-i] to target-i, and nums[index+i] to target-i. Then, this will give the minimum possible sum, so check if the sum is less than or equal to maxSum.", "n is too large to actually generate the array, so you can use the formula 1 + 2 + ... + n = n * (n+1) / 2 to quickly find the sum of nums[0...index] and nums[index...n-1].", "Binary search for the target. If it is possible, then move the lower bound up. Otherwise, move the upper bound down."], "metadata": {"canonical_parameter_names": ["n", "index", "maxSum"], "leetcode_dataset_entry_point": "Solution().maxValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:14+00:00", "tests_total": 92, "tests_dropped": 20, "flags": [], "topic_tags": ["math", "binary-search", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maxValue(self, n: int, index: int, maxSum: int) -> int:", "container": "Solution", "callable": "maxValue", "parameters": [{"name": "n", "type": "int"}, {"name": "index", "type": "int"}, {"name": "maxSum", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1803, "task_id": "count-pairs-with-xor-in-a-range", "difficulty": "Hard", "problem_description": "Given a (0-indexed) integer array nums and two integers low and high, return the number of nice pairs.\n\nA nice pair is a pair (i, j) where 0 <= i < j < nums.length and low <= (nums[i] XOR nums[j]) <= high.\n\nExample 1:\n\nInput: nums = [1,4,2,7], low = 2, high = 6\nOutput: 6\nExplanation: All nice pairs (i, j) are as follows:\n - (0, 1): nums[0] XOR nums[1] = 5\n - (0, 2): nums[0] XOR nums[2] = 3\n - (0, 3): nums[0] XOR nums[3] = 6\n - (1, 2): nums[1] XOR nums[2] = 6\n - (1, 3): nums[1] XOR nums[3] = 3\n - (2, 3): nums[2] XOR nums[3] = 5\n\nExample 2:\n\nInput: nums = [9,8,4,2,1], low = 5, high = 14\nOutput: 8\nExplanation: All nice pairs (i, j) are as follows:\n - (0, 2): nums[0] XOR nums[2] = 13\n - (0, 3): nums[0] XOR nums[3] = 11\n - (0, 4): nums[0] XOR nums[4] = 8\n - (1, 2): nums[1] XOR nums[2] = 12\n - (1, 3): nums[1] XOR nums[3] = 10\n - (1, 4): nums[1] XOR nums[4] = 9\n - (2, 3): nums[2] XOR nums[3] = 6\n - (2, 4): nums[2] XOR nums[4] = 5\n\nConstraints:\n\n- 1 <= nums.length <= 2 * 10^4\n- 1 <= nums[i] <= 2 * 10^4\n- 1 <= low <= high <= 2 * 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 7, 9],low = 1,high = 10) == 8\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9],low = 3,high = 7) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],low = 15,high = 25) == 1\n assert candidate(nums = [9, 8, 4, 2, 1],low = 5,high = 14) == 8\n assert candidate(nums = [1, 4, 2, 7],low = 2,high = 6) == 6\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80],low = 2,high = 60) == 486\n assert candidate(nums = [8, 14, 23, 41, 56, 72],low = 10,high = 50) == 7\n assert candidate(nums = [8, 15, 3, 11, 2, 9, 13],low = 4,high = 12) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],low = 3,high = 12) == 70\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],low = 1,high = 10000) == 89\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000],low = 1000,high = 12000) == 77\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],low = 2,high = 10) == 60\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],low = 5,high = 1000) == 36\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1024, 512, 256, 128],low = 1,high = 256) == 35\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],low = 2,high = 16) == 64\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993],low = 1,high = 10) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],low = 2,high = 6) == 35\n assert candidate(nums = [1023, 2047, 3071, 4095, 5119, 6143, 7167, 8191, 9215, 10239],low = 500,high = 5000) == 17\n assert candidate(nums = [2, 3, 1, 6, 7, 5, 4, 8],low = 3,high = 9) == 16\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999],low = 2000,high = 8000) == 18\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],low = 3,high = 15) == 18\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],low = 10,high = 50) == 102\n assert candidate(nums = [6, 2, 3, 8, 10, 12, 15, 18],low = 1,high = 10) == 14\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],low = 20,high = 80) == 92\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],low = 5,high = 35) == 336\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31],low = 5,high = 20) == 15\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],low = 10,high = 2000) == 51\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225],low = 50,high = 200) == 63\n assert candidate(nums = [16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],low = 1,high = 1000) == 45\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],low = 1,high = 20) == 86\n assert candidate(nums = [15, 3, 8, 7, 10, 12, 13, 14],low = 5,high = 15) == 18\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400],low = 50,high = 200) == 7\n assert candidate(nums = [31, 14, 7, 28, 21, 1, 2, 4, 8, 16],low = 5,high = 25) == 33\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],low = 5,high = 25) == 125\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],low = 5,high = 25) == 42\n assert candidate(nums = [20000, 19999, 19998, 19997, 19996, 19995, 19994, 19993, 19992, 19991],low = 100,high = 200) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],low = 1,high = 10) == 80\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],low = 1,high = 512) == 36\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],low = 2,high = 15) == 13\n assert candidate(nums = [1234, 2345, 3456, 4567, 5678, 6789, 7890],low = 1000,high = 5000) == 11\n assert candidate(nums = [16384, 8192, 4096, 2048, 1024],low = 2000,high = 7000) == 3\n assert candidate(nums = [24, 48, 72, 96, 120, 144, 168, 192, 216, 240],low = 20,high = 100) == 16\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],low = 5,high = 200) == 27\n assert candidate(nums = [8191, 4095, 2047, 1023, 511],low = 1500,high = 3000) == 2\n assert candidate(nums = [123, 456, 789, 101, 112, 134, 156, 178, 190, 212],low = 50,high = 150) == 6\n assert candidate(nums = [16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],low = 1,high = 10000) == 89\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],low = 1,high = 30) == 211\n assert candidate(nums = [1024, 2048, 3072, 4096, 5120, 6144, 7168],low = 1024,high = 6144) == 18\n assert candidate(nums = [9876, 5432, 10987, 6543, 2019, 8765, 4321, 7654, 3210, 1111],low = 1000,high = 5000) == 14\n assert candidate(nums = [20000, 15000, 10000, 5000, 2500, 1250, 625],low = 1000,high = 5000) == 4\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901, 1012, 1113, 1214, 1315, 1416, 1517, 1618, 1719, 1820, 1921, 2022],low = 100,high = 500) == 41\n assert candidate(nums = [12345, 12346, 12347, 12348, 12349, 12350, 12351, 12352, 12353, 12354],low = 1,high = 5) == 18\n assert candidate(nums = [23, 5, 7, 9, 11, 13, 17, 19, 21, 23],low = 3,high = 15) == 14\n assert candidate(nums = [5000, 10000, 15000, 20000, 500, 1000, 1500, 2000],low = 100,high = 5000) == 8\n assert candidate(nums = [8, 13, 14, 30, 15, 17, 9],low = 3,high = 12) == 7\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160],low = 10,high = 70) == 149\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],low = 10,high = 40) == 37\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],low = 500,high = 1000) == 9\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],low = 10,high = 100) == 17\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],low = 100,high = 1000) == 90\n assert candidate(nums = [1023, 511, 255, 127, 63],low = 100,high = 500) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],low = 1,high = 5000) == 76\n assert candidate(nums = [20000, 19000, 18000, 17000, 16000, 15000, 14000, 13000, 12000, 11000, 10000, 9000, 8000, 7000, 6000],low = 500,high = 10000) == 43\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901, 1012, 1113, 1214, 1315, 1416, 1517],low = 100,high = 1000) == 51\n assert candidate(nums = [9876, 6543, 3210, 1234, 5678, 8765, 5432, 2109, 4321],low = 1000,high = 10000) == 23\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],low = 15,high = 55) == 21\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],low = 2,high = 18) == 28\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],low = 1,high = 15) == 24\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],low = 2,high = 10) == 63\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],low = 100,high = 500) == 20\n assert candidate(nums = [18, 17, 32, 31, 16, 15, 8, 7, 4, 3, 2, 1],low = 4,high = 12) == 14\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],low = 20,high = 100) == 15\n", "comparison": "exact"}, "public_tests": ["[1,4,2,7]\n2\n6", "[9,8,4,2,1]\n5\n14"], "hints": ["Let's note that we can count all pairs with XOR ≤ K, so the answer would be to subtract the number of pairs withs XOR < low from the number of pairs with XOR ≤ high.", "For each value, find out the number of values when you XOR it with the result is ≤ K using a trie."], "metadata": {"canonical_parameter_names": ["nums", "low", "high"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:16+00:00", "tests_total": 100, "tests_dropped": 28, "flags": [], "topic_tags": ["array", "bit-manipulation", "trie"]}, "language": "python", "interface": {"raw_signature": "def countPairs(self, nums: List[int], low: int, high: int) -> int:", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "nums", "type": "List[int]"}, {"name": "low", "type": "int"}, {"name": "high", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1805, "task_id": "number-of-different-integers-in-a-string", "difficulty": "Easy", "problem_description": "You are given a string word that consists of digits and lowercase English letters.\n\nYou will replace every non-digit character with a space. For example, \"a123bc34d8ef34\" will become \" 123 34 8 34\". Notice that you are left with some integers that are separated by at least one space: \"123\", \"34\", \"8\", and \"34\".\n\nReturn the number of different integers after performing the replacement operations on word.\n\nTwo integers are considered different if their decimal representations without any leading zeros are different.\n\nExample 1:\n\nInput: word = \"a123bc34d8ef34\"\nOutput: 3\nExplanation: The three different integers are \"123\", \"34\", and \"8\". Notice that \"34\" is only counted once.\n\nExample 2:\n\nInput: word = \"leet1234code234\"\nOutput: 2\n\nExample 3:\n\nInput: word = \"a1b01c001\"\nOutput: 1\nExplanation: The three integers \"1\", \"01\", and \"001\" all represent the same integer because\nthe leading zeros are ignored when comparing their decimal values.\n\nConstraints:\n\n- 1 <= word.length <= 1000\n- word consists of digits and lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0\") == 10\n assert candidate(word = \"a123bc34d8ef34\") == 3\n assert candidate(word = \"a1a2a3a4a5a6a7a8a9a0\") == 10\n assert candidate(word = \"100leetcode\") == 1\n assert candidate(word = \"a1a1a1\") == 1\n assert candidate(word = \"0a001b002\") == 3\n assert candidate(word = \"12345\") == 1\n assert candidate(word = \"1a2b3c4d5e6f7g8h9i0j\") == 10\n assert candidate(word = \"00000\") == 1\n assert candidate(word = \"0a001b1c1\") == 2\n assert candidate(word = \"111222333444555666777888999000\") == 1\n assert candidate(word = \"leet1234code234\") == 2\n assert candidate(word = \"1234567890\") == 1\n assert candidate(word = \"000111222333444555666777888999000\") == 1\n assert candidate(word = \"11223344556677889900\") == 1\n assert candidate(word = \"a1b1c1\") == 1\n assert candidate(word = \"1a2b3c4d5e6f7g8h9i0j1\") == 10\n assert candidate(word = \"abc\") == 0\n assert candidate(word = \"22o22o22o\") == 1\n assert candidate(word = \"a1b01c001\") == 1\n assert candidate(word = \"a001b002c003\") == 3\n assert candidate(word = \"a001001b1001c001001\") == 1\n assert candidate(word = \"1a2b3c4d5\") == 5\n assert candidate(word = \"0a0b0c0\") == 1\n assert candidate(word = \"0abc00abc000abc0000abc\") == 1\n assert candidate(word = \"1a10a100a1000a10000a1\") == 5\n assert candidate(word = \"123abc456def789ghi123jkl456mno789pqr\") == 3\n assert candidate(word = \"abc123xyz456abc123xyz456abc123xyz456\") == 2\n assert candidate(word = \"0001abc002def03ghi0004\") == 4\n assert candidate(word = \"same123same123same123same\") == 1\n assert candidate(word = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == 1\n assert candidate(word = \"mixed123with456numbers789\") == 3\n assert candidate(word = \"000111000222000333000444000555000\") == 1\n assert candidate(word = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t\") == 10\n assert candidate(word = \"123abc456def789ghi123jkl456mno789pqr001s002t003u\") == 6\n assert candidate(word = \"123abc321def234ghi432jkl543mno654pqrs765tuvw876xyz987\") == 9\n assert candidate(word = \"1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0a\") == 10\n assert candidate(word = \"1a11a111a1111a11111a111111\") == 6\n assert candidate(word = \"9876543210a123456789b0987654321c\") == 3\n assert candidate(word = \"aaa123bbb123ccc123ddd123eee123\") == 1\n assert candidate(word = \"a0b00c000d0000e00000f000000g0000000h00000000i00000000j000000000\") == 1\n assert candidate(word = \"z9z8z7z6z5z4z3z2z1z0z9z8z7z6z5z4z3z2z1z0\") == 10\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0a01b02c03d04e05f06g07h08i09j00\") == 10\n assert candidate(word = \"a10000b1000c100d10e1f0g00h000i0000j00000k\") == 6\n assert candidate(word = \"1a10a100a1000a10000a100000a1000000a10000000a100000000\") == 9\n assert candidate(word = \"1000000000000000000000000000000\") == 1\n assert candidate(word = \"123xyz456xyz789xyz123xyz\") == 3\n assert candidate(word = \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111\") == 1\n assert candidate(word = \"100000a200000b300000c400000d500000e600000f700000g800000h900000\") == 9\n assert candidate(word = \"leading0s123trailing0s456\") == 3\n assert candidate(word = \"0001000200030004000500060007000800090000000100020003\") == 1\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\") == 10\n assert candidate(word = \"same123same123same123\") == 1\n assert candidate(word = \"1a001b0001c00001d000001e0000001f00000001g000000001\") == 1\n assert candidate(word = \"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010\") == 1\n assert candidate(word = \"aaaa111bbbb222cccc333dddd444\") == 4\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0\") == 10\n assert candidate(word = \"a0b00c000d0000\") == 1\n assert candidate(word = \"abc0abc00abc000abc0000abc000000abc0000000abc00000000abc000000000abc0000000000\") == 1\n assert candidate(word = \"leading000trailing\") == 1\n assert candidate(word = \"many000123manymany000456many000789many\") == 3\n assert candidate(word = \"a1000b1000c1000d1000e1000f1000g1000h1000i1000j1000\") == 1\n assert candidate(word = \"abc0def00ghi000jkl0000mno00000pqr000000stu\") == 1\n assert candidate(word = \"0000123456789000000000123456789000000012345678900000001234567890\") == 1\n assert candidate(word = \"0abc00abc000abc0000abc00000\") == 1\n assert candidate(word = \"0001000000001000000001\") == 1\n assert candidate(word = \"12345abc54321abc12345\") == 2\n assert candidate(word = \"repeated000repeated000repeated\") == 1\n assert candidate(word = \"z999y999x999w998v997u996\") == 4\n assert candidate(word = \"123abc321def456ghi654jkl789mno987pqr012stu210vwx321yz456\") == 8\n assert candidate(word = \"a1b01c001d0001e00001f10g100\") == 3\n assert candidate(word = \"000000000000000001\") == 1\n assert candidate(word = \"9a8b7c6d5e4f3g2h1i0j9k8l7m6n5o4p3q2r1s0\") == 10\n assert candidate(word = \"9876543210abcdefgh0987654321\") == 2\n assert candidate(word = \"9876543210zyxwvutsrqponmlkjihgfedcba9876543210\") == 1\n assert candidate(word = \"xyz001abc002def003ghi004jkl005\") == 5\n assert candidate(word = \"000000000012345678900000000\") == 1\n assert candidate(word = \"000abc0000def1234gh5678\") == 3\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0a00b002c003d004e005f006g007h008i009j000\") == 10\n assert candidate(word = \"a1b01c001d0001e00001f000001g0000001h00000001\") == 1\n assert candidate(word = \"1a01b002c0003d00004e000005f0000006g00000007h000000008i0000000009j0\") == 10\n assert candidate(word = \"123abc456def789ghi0jklm00nopqr000stu0000vwx00000yz\") == 4\n assert candidate(word = \"abc123xyz456def789ghi10jkl11mno12pqr13stu14vwx15\") == 9\n assert candidate(word = \"000001000002000003000004000005000006000007000008000009\") == 1\n assert candidate(word = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == 1\n assert candidate(word = \"abc123xyz456def789ghi001jkl234mno567pqr890stu0vwx123y0z456\") == 8\n assert candidate(word = \"abc123xyz456def456ghi789\") == 3\n assert candidate(word = \"a0b00c000d0000e00000f\") == 1\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0a000b0002c0003d0004e0005f0006g0007h0008i0009j0000\") == 10\n assert candidate(word = \"99999zzz88888xxx7777yyy6666\") == 4\n assert candidate(word = \"12345678901234567890123456789012345678901234567890123456789012345678901234567890\") == 1\n assert candidate(word = \"abc123xyz456abc123\") == 2\n assert candidate(word = \"abc123xyz456def123\") == 2\n assert candidate(word = \"a1b10c100d1000e10000f100000g1000000h10000000i100000000j1000000000\") == 10\n assert candidate(word = \"1234567890abcdefghijklmnopqrstuvwxyz0987654321\") == 2\n assert candidate(word = \"0000000000000000000000000\") == 1\n assert candidate(word = \"00000000000000000000000000000000000000000000000001\") == 1\n assert candidate(word = \"010abc0010def00010ghi\") == 1\n assert candidate(word = \"123abc123def123ghi123jkl123mno123pqrs123tuvw123xyz123\") == 1\n assert candidate(word = \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000\") == 1\n assert candidate(word = \"abc123def456ghi789jkl0123\") == 3\n assert candidate(word = \"123456789a987654321b123456789c987654321d123456789e987654321f123456789g\") == 2\n assert candidate(word = \"00123456789000\") == 1\n assert candidate(word = \"0a00b000c0000d00000e000000f0000000g00000000h000000000i000000000j0\") == 1\n assert candidate(word = \"a0b00c000d0000e00000f000000g0000000h00000000i0\") == 1\n assert candidate(word = \"a1b01c001d100e0001f10\") == 3\n assert candidate(word = \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999\") == 1\n assert candidate(word = \"abc001abc01abc1\") == 1\n assert candidate(word = \"a100000000b100000001c100000002d100000003e100000004f100000005\") == 6\n assert candidate(word = \"100000000000000000000000000000000000000000000000000000001\") == 1\n assert candidate(word = \"0012300abc045600def0123\") == 3\n assert candidate(word = \"00123004560078900100000000000000000000000000000000\") == 1\n assert candidate(word = \"9876543210qwertyuiopasdfghjklzxcvbnm\") == 1\n assert candidate(word = \"a0b0c00d000e0000f00000g000000h0000000i00000000j000000000\") == 1\n assert candidate(word = \"123abc456def789ghi0jkl123mno456pqr789stu0vwxyz\") == 4\n assert candidate(word = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7\") == 10\n assert candidate(word = \"abc123456def654321ghi123456\") == 2\n assert candidate(word = \"abc1def2ghi3jkl4mno5pqr6stu7vwx8yz90123456789\") == 9\n assert candidate(word = \"0a123b456c789d0123\") == 4\n assert candidate(word = \"a123b456c789d012e345f678g901\") == 7\n assert candidate(word = \"00100a001b001c\") == 2\n assert candidate(word = \"abc1abc01abc001abc0001abc00001abc000001abc0000001\") == 1\n assert candidate(word = \"abc001xyz01abc100\") == 2\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == 10\n", "comparison": "exact"}, "public_tests": ["\"a123bc34d8ef34\"", "\"leet1234code234\"", "\"a1b01c001\""], "hints": ["Try to split the string so that each integer is in a different string.", "Try to remove each integer's leading zeroes and compare the strings to find how many of them are unique."], "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().numDifferentIntegers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:18+00:00", "tests_total": 124, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def numDifferentIntegers(self, word: str) -> int:", "container": "Solution", "callable": "numDifferentIntegers", "parameters": [{"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1806, "task_id": "minimum-number-of-operations-to-reinitialize-a-permutation", "difficulty": "Medium", "problem_description": "You are given an even integer n. You initially have a permutation perm of size n where perm[i] == i (0-indexed).\n\nIn one operation, you will create a new array arr, and for each i:\n\n- If i % 2 == 0, then arr[i] = perm[i / 2].\n- If i % 2 == 1, then arr[i] = perm[n / 2 + (i - 1) / 2].\n\nYou will then assign arr to perm.\n\nReturn the minimum non-zero number of operations you need to perform on perm to return the permutation to its initial value.\n\nExample 1:\n\nInput: n = 2\nOutput: 1\nExplanation: perm = [0,1] initially.\nAfter the 1^st operation, perm = [0,1]\nSo it takes only 1 operation.\n\nExample 2:\n\nInput: n = 4\nOutput: 2\nExplanation: perm = [0,1,2,3] initially.\nAfter the 1^st operation, perm = [0,2,1,3]\nAfter the 2^nd operation, perm = [0,1,2,3]\nSo it takes only 2 operations.\n\nExample 3:\n\nInput: n = 6\nOutput: 4\n\nConstraints:\n\n- 2 <= n <= 1000\n- n is even.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 3\n assert candidate(n = 4) == 2\n assert candidate(n = 12) == 10\n assert candidate(n = 14) == 12\n assert candidate(n = 16) == 4\n assert candidate(n = 18) == 8\n assert candidate(n = 6) == 4\n assert candidate(n = 2) == 1\n assert candidate(n = 20) == 18\n assert candidate(n = 100) == 30\n assert candidate(n = 500) == 166\n assert candidate(n = 1000) == 36\n assert candidate(n = 10) == 6\n assert candidate(n = 896) == 356\n assert candidate(n = 992) == 495\n assert candidate(n = 988) == 138\n assert candidate(n = 50) == 21\n assert candidate(n = 300) == 132\n assert candidate(n = 384) == 191\n assert candidate(n = 600) == 299\n assert candidate(n = 64) == 6\n assert candidate(n = 72) == 35\n assert candidate(n = 192) == 95\n assert candidate(n = 888) == 443\n assert candidate(n = 128) == 7\n assert candidate(n = 22) == 6\n assert candidate(n = 46) == 12\n assert candidate(n = 256) == 8\n assert candidate(n = 768) == 348\n assert candidate(n = 32) == 5\n assert candidate(n = 48) == 23\n assert candidate(n = 800) == 184\n assert candidate(n = 200) == 99\n assert candidate(n = 400) == 18\n assert candidate(n = 512) == 9\n assert candidate(n = 750) == 318\n assert candidate(n = 998) == 332\n", "comparison": "exact"}, "public_tests": ["2", "4", "6"], "hints": ["It is safe to assume the number of operations isn't more than n", "The number is small enough to apply a brute force solution."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().reinitializePermutation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:20+00:00", "tests_total": 38, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "math", "simulation"]}, "language": "python", "interface": {"raw_signature": "def reinitializePermutation(self, n: int) -> int:", "container": "Solution", "callable": "reinitializePermutation", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1807, "task_id": "evaluate-the-bracket-pairs-of-a-string", "difficulty": "Medium", "problem_description": "You are given a string s that contains some bracket pairs, with each pair containing a non-empty key.\n\n- For example, in the string \"(name)is(age)yearsold\", there are two bracket pairs that contain the keys \"name\" and \"age\".\n\nYou know the values of a wide range of keys. This is represented by a 2D string array knowledge where each knowledge[i] = [key_i, value_i] indicates that key key_i has a value of value_i.\n\nYou are tasked to evaluate all of the bracket pairs. When you evaluate a bracket pair that contains some key key_i, you will:\n\n- Replace key_i and the bracket pair with the key's corresponding value_i.\n- If you do not know the value of the key, you will replace key_i and the bracket pair with a question mark \"?\" (without the quotation marks).\n\nEach key will appear at most once in your knowledge. There will not be any nested brackets in s.\n\nReturn the resulting string after evaluating all of the bracket pairs.\n\nExample 1:\n\nInput: s = \"(name)is(age)yearsold\", knowledge = [[\"name\",\"bob\"],[\"age\",\"two\"]]\nOutput: \"bobistwoyearsold\"\nExplanation:\nThe key \"name\" has a value of \"bob\", so replace \"(name)\" with \"bob\".\nThe key \"age\" has a value of \"two\", so replace \"(age)\" with \"two\".\n\nExample 2:\n\nInput: s = \"hi(name)\", knowledge = [[\"a\",\"b\"]]\nOutput: \"hi?\"\nExplanation: As you do not know the value of the key \"name\", replace \"(name)\" with \"?\".\n\nExample 3:\n\nInput: s = \"(a)(a)(a)aaa\", knowledge = [[\"a\",\"yes\"]]\nOutput: \"yesyesyesaaa\"\nExplanation: The same key can appear multiple times.\nThe key \"a\" has a value of \"yes\", so replace all occurrences of \"(a)\" with \"yes\".\nNotice that the \"a\"s not in a bracket pair are not evaluated.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- 0 <= knowledge.length <= 10^5\n- knowledge[i].length == 2\n- 1 <= key_i.length, value_i.length <= 10\n- s consists of lowercase English letters and round brackets '(' and ')'.\n- Every open bracket '(' in s will have a corresponding close bracket ')'.\n- The key in each bracket pair of s will be non-empty.\n- There will not be any nested bracket pairs in s.\n- key_i and value_i consist of lowercase English letters.\n- Each key_i in knowledge is unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(a)(a)(a)aaa\",knowledge = [['a', 'yes']]) == \"yesyesyesaaa\"\n assert candidate(s = \"hi(name)\",knowledge = [['a', 'b']]) == \"hi?\"\n assert candidate(s = \"(a)(a)(a)aaa\",knowledge = [['a', 'yes']]) == \"yesyesyesaaa\"\n assert candidate(s = \"noknowledgehere\",knowledge = []) == \"noknowledgehere\"\n assert candidate(s = \"no(brackets)here\",knowledge = []) == \"no?here\"\n assert candidate(s = \"hi(name)\",knowledge = [['a', 'b']]) == \"hi?\"\n assert candidate(s = \"(nested)but(not)really\",knowledge = [['nested', 'nested'], ['not', 'not']]) == \"nestedbutnotreally\"\n assert candidate(s = \"this(is)a(test)\",knowledge = [['is', 'was'], ['test', 'trial']]) == \"thiswasatrial\"\n assert candidate(s = \"(name)is(age)yearsold\",knowledge = [['name', 'bob'], ['age', 'two']]) == \"bobistwoyearsold\"\n assert candidate(s = \"(single)\",knowledge = [['single', 'one']]) == \"one\"\n assert candidate(s = \"(last)one\",knowledge = [['last', 'final']]) == \"finalone\"\n assert candidate(s = \"single\",knowledge = [['single', 'word']]) == \"single\"\n assert candidate(s = \"hello\",knowledge = []) == \"hello\"\n assert candidate(s = \"(unknown)key\",knowledge = [['known', 'value']]) == \"?key\"\n assert candidate(s = \"(name)is(age)yearsold\",knowledge = [['name', 'bob'], ['age', 'two']]) == \"bobistwoyearsold\"\n assert candidate(s = \"(nested)(key)(nested)\",knowledge = [['key', 'value'], ['nested', 'deep']]) == \"deepvaluedeep\"\n assert candidate(s = \"(greeting)(world)(planet)\",knowledge = [['greeting', 'hello'], ['world', 'earth'], ['planet', 'mars']]) == \"helloearthmars\"\n assert candidate(s = \"(language)programmingis(fun)\",knowledge = [['language', 'python'], ['fun', 'awesome']]) == \"pythonprogrammingisawesome\"\n assert candidate(s = \"(fruit)(vegetable)\",knowledge = [['fruit', 'apple'], ['vegetable', 'carrot']]) == \"applecarrot\"\n assert candidate(s = \"(animal)lives(in)(habitat)\",knowledge = [['animal', 'tiger'], ['habitat', 'jungle']]) == \"tigerlives?jungle\"\n assert candidate(s = \"(first)and(last)name\",knowledge = [['first', 'john'], ['last', 'doe']]) == \"johnanddoename\"\n assert candidate(s = \"(name)is(living)(in)(city)\",knowledge = [['name', 'bob'], ['in', 'at'], ['city', 'london']]) == \"bobis?atlondon\"\n assert candidate(s = \"(animal)(eats)(food)\",knowledge = [['animal', 'lion'], ['food', 'meat']]) == \"lion?meat\"\n assert candidate(s = \"(user)likes(to)(eat)(food)\",knowledge = [['user', 'alice'], ['eat', 'enjoy'], ['food', 'pizza']]) == \"alicelikes?enjoypizza\"\n assert candidate(s = \"(prefix)middle(suffix)\",knowledge = [['prefix', 'start'], ['suffix', 'end']]) == \"startmiddleend\"\n assert candidate(s = \"(flower)grows(in)(soil)\",knowledge = [['flower', 'rose'], ['soil', 'dirt']]) == \"rosegrows?dirt\"\n assert candidate(s = \"(first)nameis(last)name\",knowledge = [['first', 'john'], ['last', 'doe']]) == \"johnnameisdoename\"\n assert candidate(s = \"(drink)is(served)in(glass)\",knowledge = [['drink', 'water'], ['glass', 'big']]) == \"wateris?inbig\"\n assert candidate(s = \"(greeting)world\",knowledge = [['greeting', 'hello'], ['farewell', 'bye']]) == \"helloworld\"\n assert candidate(s = \"(name)has(a)(pet)(dog)\",knowledge = [['name', 'john'], ['pet', 'dog'], ['dog', 'buddy']]) == \"johnhas?dogbuddy\"\n assert candidate(s = \"(repeated)(key)(repeated)(key)\",knowledge = [['key', 'value']]) == \"?value?value\"\n assert candidate(s = \"(first)(second)(third)(fourth)\",knowledge = [['first', 'one'], ['second', 'two'], ['third', 'three']]) == \"onetwothree?\"\n assert candidate(s = \"(color)(animal)\",knowledge = [['color', 'blue'], ['animal', 'dog'], ['bird', 'sparrow']]) == \"bluedog\"\n assert candidate(s = \"(nested)but(notreally)nested\",knowledge = [['nested', 'deep'], ['notreally', 'shallow']]) == \"deepbutshallownested\"\n assert candidate(s = \"(first)(last)(age)\",knowledge = [['first', 'john'], ['last', 'doe'], ['age', 'thirty']]) == \"johndoethirty\"\n assert candidate(s = \"(city)(has)(many)(buildings)\",knowledge = [['city', 'newyork'], ['many', 'lots']]) == \"newyork?lots?\"\n assert candidate(s = \"(multiple)(keys)(here)\",knowledge = [['multiple', 'many'], ['keys', 'some'], ['here', 'there']]) == \"manysomethere\"\n assert candidate(s = \"(color)(is)(used)in(art)\",knowledge = [['color', 'red'], ['used', 'frequently']]) == \"red?frequentlyin?\"\n assert candidate(s = \"(prefix)example(suffix)\",knowledge = [['prefix', 'pre'], ['suffix', 'post']]) == \"preexamplepost\"\n assert candidate(s = \"(unknown)(key)(not)(present)\",knowledge = [['present', 'available']]) == \"???available\"\n assert candidate(s = \"(instrument)plays(music)\",knowledge = [['instrument', 'guitar'], ['music', 'beautiful']]) == \"guitarplaysbeautiful\"\n assert candidate(s = \"(prefix)(middle)(suffix)\",knowledge = [['prefix', 'pre'], ['middle', 'mid'], ['suffix', 'suf']]) == \"premidsuf\"\n assert candidate(s = \"(fruit)are(sweet)and(healthy)\",knowledge = [['fruit', 'apples'], ['sweet', 'very'], ['healthy', 'indeed']]) == \"applesareveryandindeed\"\n assert candidate(s = \"(repeated)repeated(repeated)\",knowledge = [['repeated', 'again']]) == \"againrepeatedagain\"\n assert candidate(s = \"(greeting)everyone(my)name(is)(unknown)\",knowledge = [['greeting', 'hi'], ['my', 'my']]) == \"hieveryonemyname??\"\n assert candidate(s = \"(bird)can(fly)high\",knowledge = [['bird', 'eagle'], ['fly', 'soar']]) == \"eaglecansoarhigh\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)\",knowledge = [['a', 'one'], ['b', 'two'], ['c', 'three'], ['d', 'four'], ['e', 'five'], ['f', 'six']]) == \"onetwothreefourfivesix\"\n assert candidate(s = \"(color)(of)the(sky)\",knowledge = [['color', 'blue'], ['sky', 'beautiful']]) == \"blue?thebeautiful\"\n assert candidate(s = \"(a)(b)(c)(d)(e)\",knowledge = [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma'], ['d', 'delta'], ['e', 'epsilon']]) == \"alphabetagammadeltaepsilon\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)(q)(r)(s)(t)(u)(v)(w)(x)(y)(z)\",knowledge = [['a', 'a'], ['b', 'b'], ['c', 'c'], ['d', 'd'], ['e', 'e'], ['f', 'f'], ['g', 'g'], ['h', 'h'], ['i', 'i'], ['j', 'j'], ['k', 'k'], ['l', 'l'], ['m', 'm'], ['n', 'n'], ['o', 'o'], ['p', 'p'], ['q', 'q'], ['r', 'r'], ['s', 's'], ['t', 't'], ['u', 'u'], ['v', 'v'], ['w', 'w'], ['x', 'x'], ['y', 'y'], ['z', 'z']]) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"(repeated)(repeated)(repeated)\",knowledge = [['repeated', 'rep']]) == \"repreprep\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)\",knowledge = [['a', 'one'], ['b', 'two'], ['c', 'three'], ['d', 'four'], ['e', 'five'], ['f', 'six'], ['g', 'seven'], ['h', 'eight'], ['i', 'nine'], ['j', 'ten']]) == \"onetwothreefourfivesixseveneightnineten\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)\",knowledge = [['a', 'yes'], ['b', 'no'], ['c', 'maybe'], ['d', 'sure'], ['e', 'never'], ['f', 'always'], ['g', 'often'], ['h', 'rarely'], ['i', 'sometimes'], ['j', 'usually']]) == \"yesnomaybesureneveralwaysoftenrarelysometimesusually\"\n assert candidate(s = \"(complex)(string)(with)(multiple)(keys)\",knowledge = [['complex', 'com'], ['string', 'str'], ['with', 'wi'], ['multiple', 'mul'], ['keys', 'ke']]) == \"comstrwimulke\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)\",knowledge = [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma'], ['d', 'delta'], ['e', 'epsilon']]) == \"alphabetagammadeltaepsilon?\"\n assert candidate(s = \"(nested)brackets(are)not(allowed)\",knowledge = [['nested', 'nested'], ['brackets', 'brackets'], ['not', 'not']]) == \"nestedbrackets?not?\"\n", "comparison": "exact"}, "public_tests": ["\"(name)is(age)yearsold\"\n[[\"name\",\"bob\"],[\"age\",\"two\"]]", "\"hi(name)\"\n[[\"a\",\"b\"]]", "\"(a)(a)(a)aaa\"\n[[\"a\",\"yes\"]]"], "hints": ["Process pairs from right to left to handle repeats", "Keep track of the current enclosed string using another string"], "metadata": {"canonical_parameter_names": ["s", "knowledge"], "leetcode_dataset_entry_point": "Solution().evaluate", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:23+00:00", "tests_total": 113, "tests_dropped": 57, "flags": [], "topic_tags": ["array", "hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def evaluate(self, s: str, knowledge: list[list[str]]) -> str:", "container": "Solution", "callable": "evaluate", "parameters": [{"name": "s", "type": "str"}, {"name": "knowledge", "type": "list[list[str]]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1812, "task_id": "determine-color-of-a-chessboard-square", "difficulty": "Easy", "problem_description": "You are given coordinates, a string that represents the coordinates of a square of the chessboard. Below is a chessboard for your reference.\n\nReturn true if the square is white, and false if the square is black.\n\nThe coordinate will always represent a valid chessboard square. The coordinate will always have the letter first, and the number second.\n\nExample 1:\n\nInput: coordinates = \"a1\"\nOutput: false\nExplanation: From the chessboard above, the square with coordinates \"a1\" is black, so return false.\n\nExample 2:\n\nInput: coordinates = \"h3\"\nOutput: true\nExplanation: From the chessboard above, the square with coordinates \"h3\" is white, so return true.\n\nExample 3:\n\nInput: coordinates = \"c7\"\nOutput: false\n\nConstraints:\n\n- coordinates.length == 2\n- 'a' <= coordinates[0] <= 'h'\n- '1' <= coordinates[1] <= '8'\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(coordinates = \"d5\") == True\n assert candidate(coordinates = \"e4\") == True\n assert candidate(coordinates = \"b8\") == False\n assert candidate(coordinates = \"b2\") == False\n assert candidate(coordinates = \"a1\") == False\n assert candidate(coordinates = \"g8\") == True\n assert candidate(coordinates = \"e5\") == False\n assert candidate(coordinates = \"d4\") == False\n assert candidate(coordinates = \"g2\") == True\n assert candidate(coordinates = \"e6\") == True\n assert candidate(coordinates = \"f6\") == False\n assert candidate(coordinates = \"h3\") == True\n assert candidate(coordinates = \"f4\") == False\n assert candidate(coordinates = \"c7\") == False\n assert candidate(coordinates = \"d3\") == True\n assert candidate(coordinates = \"g7\") == False\n assert candidate(coordinates = \"a7\") == False\n assert candidate(coordinates = \"c8\") == True\n assert candidate(coordinates = \"f2\") == False\n assert candidate(coordinates = \"f1\") == True\n assert candidate(coordinates = \"g1\") == False\n assert candidate(coordinates = \"b3\") == True\n assert candidate(coordinates = \"h5\") == True\n assert candidate(coordinates = \"e1\") == False\n assert candidate(coordinates = \"a5\") == False\n assert candidate(coordinates = \"d7\") == True\n assert candidate(coordinates = \"g5\") == False\n assert candidate(coordinates = \"b6\") == False\n assert candidate(coordinates = \"f5\") == True\n assert candidate(coordinates = \"h1\") == True\n assert candidate(coordinates = \"e3\") == False\n assert candidate(coordinates = \"c3\") == False\n assert candidate(coordinates = \"g4\") == True\n assert candidate(coordinates = \"a4\") == True\n assert candidate(coordinates = \"d6\") == False\n assert candidate(coordinates = \"b1\") == True\n assert candidate(coordinates = \"g6\") == True\n assert candidate(coordinates = \"h6\") == False\n assert candidate(coordinates = \"c1\") == False\n assert candidate(coordinates = \"h7\") == True\n assert candidate(coordinates = \"b7\") == True\n assert candidate(coordinates = \"c4\") == True\n assert candidate(coordinates = \"c2\") == True\n assert candidate(coordinates = \"f3\") == True\n assert candidate(coordinates = \"h4\") == False\n assert candidate(coordinates = \"d8\") == False\n assert candidate(coordinates = \"b4\") == False\n assert candidate(coordinates = \"a8\") == True\n assert candidate(coordinates = \"a3\") == False\n assert candidate(coordinates = \"e2\") == True\n assert candidate(coordinates = \"e7\") == False\n assert candidate(coordinates = \"f7\") == True\n assert candidate(coordinates = \"d2\") == False\n assert candidate(coordinates = \"a2\") == True\n assert candidate(coordinates = \"b5\") == True\n assert candidate(coordinates = \"c5\") == False\n assert candidate(coordinates = \"h8\") == False\n assert candidate(coordinates = \"a6\") == True\n assert candidate(coordinates = \"h2\") == False\n assert candidate(coordinates = \"g3\") == False\n assert candidate(coordinates = \"d1\") == True\n assert candidate(coordinates = \"f8\") == False\n assert candidate(coordinates = \"e8\") == True\n assert candidate(coordinates = \"c6\") == True\n", "comparison": "exact"}, "public_tests": ["\"a1\"", "\"h3\"", "\"c7\""], "hints": ["Convert the coordinates to (x, y) - that is, \"a1\" is (1, 1), \"d7\" is (4, 7).", "Try add the numbers together and look for a pattern."], "metadata": {"canonical_parameter_names": ["coordinates"], "leetcode_dataset_entry_point": "Solution().squareIsWhite", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:27+00:00", "tests_total": 74, "tests_dropped": 10, "flags": ["has_images"], "topic_tags": ["math", "string"]}, "language": "python", "interface": {"raw_signature": "def squareIsWhite(self, coordinates: str) -> bool:", "container": "Solution", "callable": "squareIsWhite", "parameters": [{"name": "coordinates", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1813, "task_id": "sentence-similarity-iii", "difficulty": "Medium", "problem_description": "You are given two strings sentence1 and sentence2, each representing a sentence composed of words. A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of only uppercase and lowercase English characters.\n\nTwo sentences s1 and s2 are considered similar if it is possible to insert an arbitrary sentence (possibly empty) inside one of these sentences such that the two sentences become equal. Note that the inserted sentence must be separated from existing words by spaces.\n\nFor example,\n\n- s1 = \"Hello Jane\" and s2 = \"Hello my name is Jane\" can be made equal by inserting \"my name is\" between \"Hello\" and \"Jane\" in s1.\n- s1 = \"Frog cool\" and s2 = \"Frogs are cool\" are not similar, since although there is a sentence \"s are\" inserted into s1, it is not separated from \"Frog\" by a space.\n\nGiven two sentences sentence1 and sentence2, return true if sentence1 and sentence2 are similar. Otherwise, return false.\n\nExample 1:\n\nInput: sentence1 = \"My name is Haley\", sentence2 = \"My Haley\"\nOutput: true\nExplanation:\nsentence2 can be turned to sentence1 by inserting \"name is\" between \"My\" and \"Haley\".\n\nExample 2:\n\nInput: sentence1 = \"of\", sentence2 = \"A lot of words\"\nOutput: false\nExplanation:\nNo single sentence can be inserted inside one of the sentences to make it equal to the other.\n\nExample 3:\n\nInput: sentence1 = \"Eating right now\", sentence2 = \"Eating\"\nOutput: true\nExplanation:\nsentence2 can be turned to sentence1 by inserting \"right now\" at the end of the sentence.\n\nConstraints:\n\n- 1 <= sentence1.length, sentence2.length <= 100\n- sentence1 and sentence2 consist of lowercase and uppercase English letters and spaces.\n- The words in sentence1 and sentence2 are separated by a single space.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Similar similar sentences\") == True\n assert candidate(sentence1 = \"Start end\",sentence2 = \"Start middle end\") == True\n assert candidate(sentence1 = \"Eating right now\",sentence2 = \"Eating\") == True\n assert candidate(sentence1 = \"A quick brown fox\",sentence2 = \"A quick brown fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"Quick brown fox\",sentence2 = \"Quick brown fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"of\",sentence2 = \"A lot of words\") == False\n assert candidate(sentence1 = \"Similarity check\",sentence2 = \"check Similarity\") == False\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Sentences Similar\") == False\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Similar very very similar sentences\") == True\n assert candidate(sentence1 = \"Python is great\",sentence2 = \"Python is very very great\") == True\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One three\") == True\n assert candidate(sentence1 = \"Python is great\",sentence2 = \"is great\") == True\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Sentences that are Similar\") == False\n assert candidate(sentence1 = \"One\",sentence2 = \"One two three\") == True\n assert candidate(sentence1 = \"One\",sentence2 = \"One\") == True\n assert candidate(sentence1 = \"Test\",sentence2 = \"Test test\") == True\n assert candidate(sentence1 = \"Single\",sentence2 = \"Single word\") == True\n assert candidate(sentence1 = \"Test test test\",sentence2 = \"Test test test test\") == True\n assert candidate(sentence1 = \"Python programming\",sentence2 = \"programming\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is\") == True\n assert candidate(sentence1 = \"A B C\",sentence2 = \"A B X C\") == True\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One two three four\") == True\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Similar very similar sentences\") == True\n assert candidate(sentence1 = \"My name is Haley\",sentence2 = \"My Haley\") == True\n assert candidate(sentence1 = \"Same Same Same\",sentence2 = \"Same\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is a dummy test\") == True\n assert candidate(sentence1 = \"Same same\",sentence2 = \"Same same same\") == True\n assert candidate(sentence1 = \"Overlap here\",sentence2 = \"Overlap word here\") == True\n assert candidate(sentence1 = \"Hello World\",sentence2 = \"World\") == True\n assert candidate(sentence1 = \"Hello World\",sentence2 = \"Hello\") == True\n assert candidate(sentence1 = \"Same same\",sentence2 = \"Same same\") == True\n assert candidate(sentence1 = \"Hello World\",sentence2 = \"Hello amazing World\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is a simple test\") == True\n assert candidate(sentence1 = \"First Second Third\",sentence2 = \"First Third\") == True\n assert candidate(sentence1 = \"Match here\",sentence2 = \"Match something here\") == True\n assert candidate(sentence1 = \"Hello World\",sentence2 = \"Hello from the World\") == True\n assert candidate(sentence1 = \"Alice in Wonderland\",sentence2 = \"Alice is in Wonderland\") == True\n assert candidate(sentence1 = \"Left Right\",sentence2 = \"Left Middle Right\") == True\n assert candidate(sentence1 = \"The quick brown fox\",sentence2 = \"The quick brown fox jumps over\") == True\n assert candidate(sentence1 = \"To be or not to be that is the question\",sentence2 = \"To be that is the question\") == True\n assert candidate(sentence1 = \"The world is a stage\",sentence2 = \"The world is a stage and all the men and women merely players\") == True\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One two insert three\") == True\n assert candidate(sentence1 = \"The quick brown fox\",sentence2 = \"The quick brown fox jumps\") == True\n assert candidate(sentence1 = \"No pain no gain\",sentence2 = \"No pain no gain but sometimes the pain is not worth the gain\") == True\n assert candidate(sentence1 = \"Let us play\",sentence2 = \"Let us play a game\") == True\n assert candidate(sentence1 = \"Mary had a little lamb\",sentence2 = \"Mary lamb\") == True\n assert candidate(sentence1 = \"All roads lead to Rome\",sentence2 = \"All roads lead to Rome but not all roads are the same\") == True\n assert candidate(sentence1 = \"Unique words only\",sentence2 = \"Unique unique words only\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over the lazy dog\",sentence2 = \"Quick brown fox jumps over the lazy quick brown dog\") == True\n assert candidate(sentence1 = \"a b c d e f g h i j\",sentence2 = \"a b c X Y Z d e f g h i j\") == True\n assert candidate(sentence1 = \"OnlyOneWordHere\",sentence2 = \"Only One Word Here\") == False\n assert candidate(sentence1 = \"Actions speak louder than words\",sentence2 = \"Actions speak\") == True\n assert candidate(sentence1 = \"One two three four five\",sentence2 = \"One two four five\") == True\n assert candidate(sentence1 = \"Python programming is fun\",sentence2 = \"Python programming is very fun\") == True\n assert candidate(sentence1 = \"Actions speak louder than words\",sentence2 = \"Actions speak louder than words but intentions matter\") == True\n assert candidate(sentence1 = \"Python is fun\",sentence2 = \"Python programming is really fun\") == False\n assert candidate(sentence1 = \"OpenAI is great\",sentence2 = \"OpenAI is indeed indeed great\") == True\n assert candidate(sentence1 = \"Do or do not there is no try\",sentence2 = \"Do or do not there is no no try\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over the lazy dog\",sentence2 = \"Quick fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"Time flies when you are having fun\",sentence2 = \"Time flies\") == True\n assert candidate(sentence1 = \"The world is a book and those who do not travel read only one page\",sentence2 = \"The world is a book and those who do not travel read only one chapter\") == False\n assert candidate(sentence1 = \"Python programming is fun and effective\",sentence2 = \"Python programming effective\") == True\n assert candidate(sentence1 = \"Complex complex case\",sentence2 = \"Complex even more complex case\") == True\n assert candidate(sentence1 = \"Time heals all wounds\",sentence2 = \"Time heals all wounds but time is also a thief\") == True\n assert candidate(sentence1 = \"SingleWord\",sentence2 = \"SingleWord\") == True\n assert candidate(sentence1 = \"The cat sat on the mat\",sentence2 = \"The cat sat on the blue mat\") == True\n assert candidate(sentence1 = \"First and last\",sentence2 = \"First something in the middle last\") == False\n assert candidate(sentence1 = \"Once upon a time\",sentence2 = \"Once upon a time in a land far far away\") == True\n assert candidate(sentence1 = \"I think therefore I am\",sentence2 = \"I think therefore I am six\") == True\n assert candidate(sentence1 = \"Single word match\",sentence2 = \"Single word match\") == True\n assert candidate(sentence1 = \"Silence is golden\",sentence2 = \"Silence is golden in the morning\") == True\n assert candidate(sentence1 = \"A quick brown fox jumps\",sentence2 = \"A quick brown fox quick brown fox jumps\") == True\n assert candidate(sentence1 = \"Complex problem solving\",sentence2 = \"Complex problem problem solving\") == True\n assert candidate(sentence1 = \"Short\",sentence2 = \"Short and sweet\") == True\n assert candidate(sentence1 = \"a\",sentence2 = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\") == True\n assert candidate(sentence1 = \"Overlap at end\",sentence2 = \"Continue overlap at end\") == False\n assert candidate(sentence1 = \"Happy birthday\",sentence2 = \"Happy birthday dear\") == True\n assert candidate(sentence1 = \"First word last word\",sentence2 = \"First first word last word\") == True\n assert candidate(sentence1 = \"To be or not to be\",sentence2 = \"To be or not to be that is the question\") == True\n assert candidate(sentence1 = \"May the force be with you\",sentence2 = \"May the force\") == True\n assert candidate(sentence1 = \"Python programming is fun\",sentence2 = \"Python programming is really really fun\") == True\n assert candidate(sentence1 = \"Alibaba Cloud offers various cloud services\",sentence2 = \"Alibaba Cloud offers cloud computing and storage services\") == False\n assert candidate(sentence1 = \"The early morning sun was a beautiful sight\",sentence2 = \"The early morning sun was a beautiful golden sight\") == True\n assert candidate(sentence1 = \"This is a long sentence with multiple words in it\",sentence2 = \"This long sentence with multiple words in it\") == True\n assert candidate(sentence1 = \"Lorem ipsum dolor sit amet\",sentence2 = \"Lorem ipsum dolor sit amet consectetur adipiscing elit\") == True\n assert candidate(sentence1 = \"Hello from the other side\",sentence2 = \"Hello from this side\") == False\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One two X Y Z three\") == True\n assert candidate(sentence1 = \"Beginning middle end\",sentence2 = \"Beginning middle middle middle end\") == True\n assert candidate(sentence1 = \"Unique sentence\",sentence2 = \"Unique special sentence\") == True\n assert candidate(sentence1 = \"The quick brown fox jumps over the lazy dog\",sentence2 = \"The quick brown fox jumps over the lazy\") == True\n assert candidate(sentence1 = \"Start with a sentence\",sentence2 = \"Start with a really long sentence\") == True\n assert candidate(sentence1 = \"Python is fun\",sentence2 = \"Python is an amazing and fun language\") == False\n assert candidate(sentence1 = \"All your base are belong to us\",sentence2 = \"All base are belong to us\") == True\n assert candidate(sentence1 = \"Longer sentence with multiple words\",sentence2 = \"Longer sentence with even more multiple words\") == True\n assert candidate(sentence1 = \"She sells sea shells by the sea shore\",sentence2 = \"She sells green sea shells by the sea shore\") == True\n assert candidate(sentence1 = \"Complex algorithm design and analysis\",sentence2 = \"Complex algorithm\") == True\n assert candidate(sentence1 = \"In the middle\",sentence2 = \"In the middle of nowhere\") == True\n assert candidate(sentence1 = \"First Last\",sentence2 = \"First in between Last\") == True\n assert candidate(sentence1 = \"I love to code\",sentence2 = \"I love to code code code\") == True\n assert candidate(sentence1 = \"Unique words only\",sentence2 = \"Unique words in between only\") == True\n assert candidate(sentence1 = \"The quick brown fox\",sentence2 = \"The quick brown fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"Single\",sentence2 = \"Single single single\") == True\n assert candidate(sentence1 = \"Life is a journey\",sentence2 = \"Life is a journey not a destination\") == True\n assert candidate(sentence1 = \"A B C D E\",sentence2 = \"A B X Y Z C D E\") == True\n assert candidate(sentence1 = \"The rain in Spain stays mainly in the plain\",sentence2 = \"The rain in Spain falls mainly in the plain\") == False\n assert candidate(sentence1 = \"A quick movement of the enemy will jeopardize six gunboats\",sentence2 = \"A quick movement of the enemy will jeopardize\") == True\n assert candidate(sentence1 = \"Short\",sentence2 = \"Very very short\") == False\n assert candidate(sentence1 = \"Do or do not there is no try\",sentence2 = \"Do or do not there is no other way\") == False\n assert candidate(sentence1 = \"Python programming is fun\",sentence2 = \"Python programming is very very fun\") == True\n assert candidate(sentence1 = \"Start coding\",sentence2 = \"Start coding today\") == True\n assert candidate(sentence1 = \"Happy new year\",sentence2 = \"Happy new new new year\") == True\n assert candidate(sentence1 = \"I love programming in Python\",sentence2 = \"I love programming in Java Python\") == True\n assert candidate(sentence1 = \"Actions speak louder than words\",sentence2 = \"Actions speak louder than words but words can inspire actions\") == True\n assert candidate(sentence1 = \"Python is great\",sentence2 = \"Programming in Python is great\") == True\n assert candidate(sentence1 = \"Data engineering and data science\",sentence2 = \"Data engineering\") == True\n assert candidate(sentence1 = \"One two three four\",sentence2 = \"One two five six seven eight three four\") == True\n assert candidate(sentence1 = \"I love coding\",sentence2 = \"I love coding in Python\") == True\n assert candidate(sentence1 = \"Prefix and suffix\",sentence2 = \"Prefix and more words suffix\") == True\n assert candidate(sentence1 = \"One two three four\",sentence2 = \"One two three four five six\") == True\n assert candidate(sentence1 = \"The quick brown fox jumps over the lazy dog\",sentence2 = \"The quick brown fox jumps over lazy dog\") == True\n assert candidate(sentence1 = \"Catch me if you can\",sentence2 = \"Catch me\") == True\n assert candidate(sentence1 = \"This is a complex example\",sentence2 = \"This is an extremely complex example\") == False\n assert candidate(sentence1 = \"Match start\",sentence2 = \"Match start middle\") == True\n assert candidate(sentence1 = \"x y z\",sentence2 = \"a b c x y z\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is only a test\") == True\n assert candidate(sentence1 = \"The quick brown fox jumps over the lazy dog\",sentence2 = \"The quick brown fox jumps high over the lazy dog\") == True\n assert candidate(sentence1 = \"Python is great\",sentence2 = \"Python is the best language great\") == True\n assert candidate(sentence1 = \"The cat in the hat sat on the mat\",sentence2 = \"The cat sat on the mat\") == True\n assert candidate(sentence1 = \"The pen is mightier than the sword\",sentence2 = \"The pen is mightier than the sword but silence is golden\") == True\n assert candidate(sentence1 = \"Machine learning is transforming industries\",sentence2 = \"Machine learning transforming industries\") == True\n assert candidate(sentence1 = \"The quick brown fox\",sentence2 = \"The quick brown lazy dog\") == False\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One two two three\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is a longer test sentence\") == False\n assert candidate(sentence1 = \"Insert this sentence\",sentence2 = \"Insert some words this sentence\") == True\n assert candidate(sentence1 = \"An apple a day keeps the doctor away\",sentence2 = \"An apple a day\") == True\n assert candidate(sentence1 = \"Learning new things every day\",sentence2 = \"Learning new things every single day\") == True\n assert candidate(sentence1 = \"Match end\",sentence2 = \"Middle match end\") == False\n assert candidate(sentence1 = \"Test\",sentence2 = \"Test test test\") == True\n assert candidate(sentence1 = \"A B C D E\",sentence2 = \"A B C X Y Z D E\") == True\n assert candidate(sentence1 = \"Start with this\",sentence2 = \"Start with something in the middle this\") == True\n assert candidate(sentence1 = \"Qwen is a large language model\",sentence2 = \"Qwen is a language model\") == True\n assert candidate(sentence1 = \"The cat sat on the mat\",sentence2 = \"The cat sat on the brown mat\") == True\n assert candidate(sentence1 = \"Last word\",sentence2 = \"Last last last word\") == True\n assert candidate(sentence1 = \"Python is great for data science\",sentence2 = \"Python is great\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over the lazy dog\",sentence2 = \"Quick brown fox quickly jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"It is a truth universally acknowledged\",sentence2 = \"It is a universally acknowledged\") == True\n assert candidate(sentence1 = \"Start and finish\",sentence2 = \"Start middle and finish\") == True\n assert candidate(sentence1 = \"SingleWord\",sentence2 = \"SingleWordInserted\") == False\n assert candidate(sentence1 = \"End with a sentence\",sentence2 = \"End with a sentence and more words\") == True\n assert candidate(sentence1 = \"Overlap at start\",sentence2 = \"Overlap at start and continue\") == True\n assert candidate(sentence1 = \"We hold these truths to be self evident\",sentence2 = \"We hold these self evident\") == True\n assert candidate(sentence1 = \"Once upon a time in a land far far away\",sentence2 = \"Once upon a time\") == True\n assert candidate(sentence1 = \"Java is a high level programming language\",sentence2 = \"Java is a high level programming language that is platform independent\") == True\n assert candidate(sentence1 = \"Similar beginning and end\",sentence2 = \"Similar beginning with extra words and end\") == True\n assert candidate(sentence1 = \"Hello from the other side\",sentence2 = \"Hello from the very very other side\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over lazy dog\",sentence2 = \"Quick brown fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"Silence is golden\",sentence2 = \"Silence\") == True\n assert candidate(sentence1 = \"Middle insertion is key\",sentence2 = \"Middle insertion of some text is key\") == True\n assert candidate(sentence1 = \"To be or not to be that is the question\",sentence2 = \"To be or not to be\") == True\n assert candidate(sentence1 = \"This is a simple test\",sentence2 = \"This is an extremely simple and detailed test\") == False\n assert candidate(sentence1 = \"It was the best of times it was the worst of times\",sentence2 = \"It was the best of times\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over the lazy dog\",sentence2 = \"Quick brown fox jumps over the lazy brown dog\") == True\n assert candidate(sentence1 = \"Learning new things is fun\",sentence2 = \"Learning fun\") == True\n assert candidate(sentence1 = \"Life is a journey not a destination\",sentence2 = \"Life is a journey of ups and downs not a destination\") == True\n assert candidate(sentence1 = \"She sells sea shells by the sea shore\",sentence2 = \"She sells sea\") == True\n assert candidate(sentence1 = \"In the beginning God created the heaven and the earth\",sentence2 = \"In the beginning God created the earth\") == True\n assert candidate(sentence1 = \"Insert sentence here\",sentence2 = \"Insert sentence in the middle sentence here\") == True\n assert candidate(sentence1 = \"End with this\",sentence2 = \"End with this and something more\") == True\n assert candidate(sentence1 = \"Python is fun\",sentence2 = \"Python is very very fun\") == True\n assert candidate(sentence1 = \"Advanced machine learning techniques\",sentence2 = \"Advanced machine learning deep learning techniques\") == True\n assert candidate(sentence1 = \"Hello from the other side\",sentence2 = \"Hello from the other side my old friend\") == True\n assert candidate(sentence1 = \"Single word\",sentence2 = \"Single single word\") == True\n assert candidate(sentence1 = \"One two three four five\",sentence2 = \"One two six seven eight nine five\") == False\n assert candidate(sentence1 = \"Same at the start\",sentence2 = \"Same at the start but different end\") == True\n assert candidate(sentence1 = \"All animals are equal\",sentence2 = \"All animals are equal but some animals are more equal than others\") == True\n assert candidate(sentence1 = \"The rain in Spain stays mainly in the plain\",sentence2 = \"The rain in Spain stays\") == True\n assert candidate(sentence1 = \"Multiple words in between\",sentence2 = \"Multiple multiple words in between\") == True\n assert candidate(sentence1 = \"Natural language processing is fascinating\",sentence2 = \"Natural language processing\") == True\n assert candidate(sentence1 = \"Hello my friend\",sentence2 = \"Hello my dear friend\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is an amazing test\") == False\n assert candidate(sentence1 = \"Front and back\",sentence2 = \"Front middle back\") == False\n assert candidate(sentence1 = \"Complex sentences are fun\",sentence2 = \"Complex sentences with more words in between are fun\") == True\n assert candidate(sentence1 = \"Alice went to the market\",sentence2 = \"Alice went to the market to buy apples\") == True\n assert candidate(sentence1 = \"The early morning light\",sentence2 = \"The early morning light is so peaceful\") == True\n assert candidate(sentence1 = \"Same same same\",sentence2 = \"Same Same\") == False\n assert candidate(sentence1 = \"Same at the end\",sentence2 = \"Different start same at the end\") == False\n assert candidate(sentence1 = \"Beautiful day in the neighborhood\",sentence2 = \"Beautiful day in the beautiful neighborhood\") == True\n assert candidate(sentence1 = \"First second third\",sentence2 = \"First first first second third\") == True\n assert candidate(sentence1 = \"Hello from the other side\",sentence2 = \"Hello\") == True\n assert candidate(sentence1 = \"I have a dream\",sentence2 = \"I have a dream that one day this nation will rise up and live out the true meaning of its creed\") == True\n assert candidate(sentence1 = \"May the force be with you\",sentence2 = \"May the be with you\") == True\n assert candidate(sentence1 = \"OpenAI develops AI models\",sentence2 = \"OpenAI develops cutting edge AI models\") == True\n assert candidate(sentence1 = \"May the Force be with you\",sentence2 = \"May the Force be with you always\") == True\n assert candidate(sentence1 = \"Keep it simple\",sentence2 = \"Keep it simple stupid\") == True\n assert candidate(sentence1 = \"A short sentence\",sentence2 = \"A very very very short sentence\") == True\n", "comparison": "exact"}, "public_tests": ["\"My name is Haley\"\n\"My Haley\"", "\"of\"\n\"A lot of words\"", "\"Eating right now\"\n\"Eating\""], "hints": ["One way to look at it is to find one sentence as a concatenation of a prefix and suffix from the other sentence.", "Get the longest common prefix between them and the longest common suffix."], "metadata": {"canonical_parameter_names": ["sentence1", "sentence2"], "leetcode_dataset_entry_point": "Solution().areSentencesSimilar", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:29+00:00", "tests_total": 197, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "two-pointers", "string"]}, "language": "python", "interface": {"raw_signature": "def areSentencesSimilar(self, sentence1: str, sentence2: str) -> bool:", "container": "Solution", "callable": "areSentencesSimilar", "parameters": [{"name": "sentence1", "type": "str"}, {"name": "sentence2", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1814, "task_id": "count-nice-pairs-in-an-array", "difficulty": "Medium", "problem_description": "You are given an array nums that consists of non-negative integers. Let us define rev(x) as the reverse of the non-negative integer x. For example, rev(123) = 321, and rev(120) = 21. A pair of indices (i, j) is nice if it satisfies all of the following conditions:\n\n- 0 <= i < j < nums.length\n- nums[i] + rev(nums[j]) == nums[j] + rev(nums[i])\n\nReturn the number of nice pairs of indices. Since that number can be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: nums = [42,11,1,97]\nOutput: 2\nExplanation: The two pairs are:\n - (0,3) : 42 + rev(97) = 42 + 79 = 121, 97 + rev(42) = 97 + 24 = 121.\n - (1,2) : 11 + rev(1) = 11 + 1 = 12, 1 + rev(11) = 1 + 11 = 12.\n\nExample 2:\n\nInput: nums = [13,10,35,24,76]\nOutput: 4\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 45\n assert candidate(nums = [100, 200, 300, 400]) == 0\n assert candidate(nums = [123, 321, 213, 132, 231, 312]) == 2\n assert candidate(nums = [123, 321, 213, 132]) == 1\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333]) == 3\n assert candidate(nums = [987654321, 123456789, 234567890, 345678901]) == 0\n assert candidate(nums = [123, 321, 120, 21]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500]) == 0\n assert candidate(nums = [13, 10, 35, 24, 76]) == 4\n assert candidate(nums = [1, 1, 1, 1]) == 6\n assert candidate(nums = [10, 100, 1000, 10000]) == 0\n assert candidate(nums = [0, 0, 0, 0]) == 6\n assert candidate(nums = [100, 10, 1]) == 0\n assert candidate(nums = [42, 11, 1, 97]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5]) == 10\n assert candidate(nums = [100000, 100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009]) == 0\n assert candidate(nums = [1234, 2341, 3412, 4123, 5678, 6785, 7856, 8567]) == 8\n assert candidate(nums = [123, 132, 213, 231, 312, 321, 111, 222, 333, 444, 555, 666, 777, 888, 999, 101, 202, 303, 404, 505]) == 93\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 0\n assert candidate(nums = [123, 321, 213, 132, 231, 312, 123, 321]) == 4\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 0]) == 45\n assert candidate(nums = [1122, 2211, 3344, 4433, 5566, 6655, 7788, 8877]) == 12\n assert candidate(nums = [1001, 1010, 1100, 1111, 2002, 2020, 2200, 2222]) == 6\n assert candidate(nums = [564, 465, 654, 645, 546, 456]) == 2\n assert candidate(nums = [101010101, 202020202, 303030303, 404040404, 505050505, 606060606, 707070707, 808080808, 909090909]) == 36\n assert candidate(nums = [123, 456, 789, 1234, 5678, 9012, 3456, 7890, 12345, 67890]) == 7\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == 36\n assert candidate(nums = [101, 101, 101, 101, 101, 101, 101, 101, 101, 101]) == 45\n assert candidate(nums = [111111, 222222, 333333, 444444, 555555, 666666]) == 15\n assert candidate(nums = [1001, 1101, 1201, 1301, 1401, 1501, 1601, 1701, 1801, 1901]) == 0\n assert candidate(nums = [123456789, 234567890, 345678901, 456789012, 567890123, 678901234, 789012345, 890123456, 901234567, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == 40\n assert candidate(nums = [121, 131, 141, 151, 161, 171, 181, 191, 202, 212, 222, 232, 242, 252, 262, 272, 282, 292, 303, 313, 323, 333, 343, 353, 363, 373, 383, 393, 404, 414, 424, 434, 444, 454, 464, 474, 484, 494, 505, 515, 525, 535, 545, 555, 565, 575, 585, 595, 606, 616, 626, 636, 646, 656, 666, 676, 686, 696, 707, 717, 727, 737, 747, 757, 767, 777, 787, 797, 808, 818, 828, 838, 848, 858, 868, 878, 888, 898, 909, 919, 929, 939, 949, 959, 969, 979, 989, 999]) == 3828\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555]) == 10\n assert candidate(nums = [123456789, 234567890, 345678901, 456789012, 567890123, 678901234, 789012345, 890123456, 901234567, 101234567]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 45\n assert candidate(nums = [1001, 1010, 1100, 1, 10, 100]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 45\n assert candidate(nums = [12345, 54321, 1234, 4321, 123, 321, 12, 21, 1, 0]) == 1\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == 36\n assert candidate(nums = [12345, 54321, 12345, 54321, 12345, 54321, 12345, 54321]) == 12\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == 36\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]) == 0\n assert candidate(nums = [987, 789, 897, 798, 978, 879, 987, 789, 897, 798]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 36\n assert candidate(nums = [500000000, 400000000, 300000000, 200000000, 100000000, 50000000, 40000000, 30000000, 20000000, 10000000, 5000000, 4000000, 3000000, 2000000, 1000000, 500000, 400000, 300000, 200000, 100000]) == 0\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 0]) == 45\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == 36\n assert candidate(nums = [1234, 4321, 1111, 2222, 3333, 4444, 5555]) == 10\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901]) == 22\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999]) == 28\n assert candidate(nums = [120, 210, 102, 201, 321, 123, 312, 213, 432, 234]) == 8\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]) == 36\n assert candidate(nums = [123, 321, 213, 132, 312, 231]) == 2\n assert candidate(nums = [123456789, 987654321, 12345678, 87654321, 1234567, 7654321, 123456, 654321, 12345, 54321, 1234, 4321, 123, 321, 12, 21, 1, 0]) == 1\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009, 11011, 22022, 33033, 44044, 55055, 66066, 77077, 88088, 99099, 11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999]) == 351\n assert candidate(nums = [10001, 10101, 11001, 11111, 20002, 20202, 22002, 22222]) == 15\n assert candidate(nums = [1230, 3210, 2130, 1320, 3120, 2310]) == 0\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999, 1]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 45\n assert candidate(nums = [123, 321, 213, 312, 132, 231, 456, 654, 546, 465, 789, 987, 897, 798, 101, 11, 22, 33, 44, 55, 66, 77, 88, 99]) == 64\n assert candidate(nums = [999999999, 100000000, 111111111, 222222222, 333333333, 444444444, 555555555]) == 15\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999, 123456789]) == 36\n assert candidate(nums = [1001, 1010, 1100, 100, 10, 1, 11, 111, 1111]) == 10\n assert candidate(nums = [1234, 4321, 5678, 8765, 9012, 2109, 3456, 6543]) == 6\n assert candidate(nums = [123456, 654321, 123456, 654321, 123456, 654321]) == 6\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993]) == 0\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999, 1000000000]) == 36\n assert candidate(nums = [12321, 13231, 21312, 31213, 41114, 51015, 60906, 70807, 80708, 90609]) == 45\n assert candidate(nums = [12345, 54321, 23451, 123456, 654321, 213456, 111111, 222222, 333333, 444444]) == 6\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 171\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == 36\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 153\n assert candidate(nums = [1234, 4321, 3412, 2143, 2341, 3142, 1324, 4231, 4123, 2413, 3214, 1423]) == 1\n assert candidate(nums = [1, 21, 12, 11, 22, 202, 220, 101, 110, 111, 2002, 2200, 2020, 1001, 1100, 1010, 10001, 10101, 11001]) == 45\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 0\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000]) == 0\n assert candidate(nums = [123, 321, 456, 654, 789, 987, 101, 110, 111]) == 7\n assert candidate(nums = [123, 321, 213, 132, 231, 312, 4321, 1234, 1111, 2222, 3333]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 45\n assert candidate(nums = [1001, 1010, 1100, 2002, 2020, 2200, 3003, 3030, 3300]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 435\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 0\n assert candidate(nums = [1000001, 2000002, 3000003, 4000004, 5000005, 6000006, 7000007, 8000008, 9000009]) == 36\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 36\n assert candidate(nums = [100001, 100010, 100100, 101000, 110000, 100002, 100020, 100200, 102000, 120000]) == 0\n assert candidate(nums = [123456789, 987654321, 234567890, 890123456, 345678901, 765432109, 456789012, 654321098, 567890123, 345678901]) == 3\n assert candidate(nums = [112233, 332211, 221133, 113322, 445566, 665544, 556644]) == 3\n assert candidate(nums = [1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 0\n assert candidate(nums = [12, 21, 13, 31, 23, 32, 14, 41, 24, 42, 34, 43]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 0\n assert candidate(nums = [100001, 100101, 101001, 101101, 110001, 110101, 111001, 111101]) == 2\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995]) == 0\n assert candidate(nums = [900000000, 800000000, 700000000, 600000000, 500000000, 400000000, 300000000, 200000000, 100000000]) == 0\n assert candidate(nums = [123456789, 123456790, 123456788, 123456791, 123456787, 123456792, 123456786, 123456793, 123456785, 123456794]) == 0\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == 36\n assert candidate(nums = [1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 0\n assert candidate(nums = [123, 321, 213, 132, 312, 231, 101, 110, 10, 1]) == 5\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == 36\n assert candidate(nums = [123456789, 987654321, 234567890, 345678901, 456789012, 567890123, 678901234, 789012345, 890123456, 901234567]) == 4\n", "comparison": "exact"}, "public_tests": ["[42,11,1,97]", "[13,10,35,24,76]"], "hints": ["The condition can be rearranged to (nums[i] - rev(nums[i])) == (nums[j] - rev(nums[j])).", "Transform each nums[i] into (nums[i] - rev(nums[i])). Then, count the number of (i, j) pairs that have equal values.", "Keep a map storing the frequencies of values that you have seen so far. For each i, check if nums[i] is in the map. If it is, then add that count to the overall count. Then, increment the frequency of nums[i]."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countNicePairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:32+00:00", "tests_total": 107, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "hash-table", "math", "counting"]}, "language": "python", "interface": {"raw_signature": "def countNicePairs(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countNicePairs", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1815, "task_id": "maximum-number-of-groups-getting-fresh-donuts", "difficulty": "Hard", "problem_description": "There is a donuts shop that bakes donuts in batches of batchSize. They have a rule where they must serve all of the donuts of a batch before serving any donuts of the next batch. You are given an integer batchSize and an integer array groups, where groups[i] denotes that there is a group of groups[i] customers that will visit the shop. Each customer will get exactly one donut.\n\nWhen a group visits the shop, all customers of the group must be served before serving any of the following groups. A group will be happy if they all get fresh donuts. That is, the first customer of the group does not receive a donut that was left over from the previous group.\n\nYou can freely rearrange the ordering of the groups. Return the maximum possible number of happy groups after rearranging the groups.\n\nExample 1:\n\nInput: batchSize = 3, groups = [1,2,3,4,5,6]\nOutput: 4\nExplanation: You can arrange the groups as [6,2,4,5,1,3]. Then the 1^st, 2^nd, 4^th, and 6^th groups will be happy.\n\nExample 2:\n\nInput: batchSize = 4, groups = [1,3,2,5,2,2,1,6]\nOutput: 4\n\nConstraints:\n\n- 1 <= batchSize <= 9\n- 1 <= groups.length <= 30\n- 1 <= groups[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49]) == 7\n assert candidate(batchSize = 2,groups = [2, 2, 2, 2, 2, 2]) == 6\n assert candidate(batchSize = 7,groups = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 12\n assert candidate(batchSize = 4,groups = [4, 8, 12, 16, 20]) == 5\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 5\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42]) == 6\n assert candidate(batchSize = 3,groups = [1, 2, 3, 4, 5, 6]) == 4\n assert candidate(batchSize = 4,groups = [1, 3, 2, 5, 2, 2, 1, 6]) == 4\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15]) == 5\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25]) == 5\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72]) == 9\n assert candidate(batchSize = 1,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(batchSize = 5,groups = [1, 2, 3, 4, 5]) == 3\n assert candidate(batchSize = 5,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81]) == 9\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 10\n assert candidate(batchSize = 8,groups = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 15\n assert candidate(batchSize = 5,groups = [5, 5, 5, 5, 5, 5]) == 6\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49, 56]) == 8\n assert candidate(batchSize = 9,groups = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(batchSize = 9,groups = [9, 9, 9, 9, 9, 9, 9, 9, 9]) == 9\n assert candidate(batchSize = 2,groups = [1, 2, 3, 4, 5]) == 4\n assert candidate(batchSize = 6,groups = [6, 12, 18, 24, 30, 36, 42, 48, 54]) == 9\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64]) == 8\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == 30\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 11\n assert candidate(batchSize = 8,groups = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 8\n assert candidate(batchSize = 7,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 11\n assert candidate(batchSize = 6,groups = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == 10\n assert candidate(batchSize = 5,groups = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 30\n assert candidate(batchSize = 4,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 19\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 10\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147]) == 21\n assert candidate(batchSize = 8,groups = [4, 7, 9, 12, 14, 15, 18, 20, 22, 23, 25, 26, 27, 29, 31, 32]) == 8\n assert candidate(batchSize = 2,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(batchSize = 5,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(batchSize = 7,groups = [14, 28, 42, 56, 70, 84, 98, 112, 126, 140, 154, 168, 182]) == 13\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126]) == 14\n assert candidate(batchSize = 6,groups = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336, 348, 360]) == 30\n assert candidate(batchSize = 5,groups = [8, 9, 10, 11, 12, 13, 14, 15]) == 5\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40]) == 8\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225, 234, 243, 252, 261, 270]) == 30\n assert candidate(batchSize = 5,groups = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 6\n assert candidate(batchSize = 6,groups = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90]) == 15\n assert candidate(batchSize = 4,groups = [5, 8, 10, 11, 13, 16, 17, 19, 21, 22, 25, 28, 30]) == 8\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80]) == 10\n assert candidate(batchSize = 2,groups = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 21\n assert candidate(batchSize = 5,groups = [2, 3, 7, 8, 10, 12, 15, 17]) == 5\n assert candidate(batchSize = 3,groups = [9, 15, 2, 7, 8, 11, 13, 4, 1]) == 6\n assert candidate(batchSize = 4,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 13\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 20\n assert candidate(batchSize = 6,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 7\n assert candidate(batchSize = 5,groups = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165]) == 9\n assert candidate(batchSize = 8,groups = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 3\n assert candidate(batchSize = 9,groups = [1, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112]) == 8\n assert candidate(batchSize = 5,groups = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 6\n assert candidate(batchSize = 5,groups = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 10\n assert candidate(batchSize = 7,groups = [1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92]) == 2\n assert candidate(batchSize = 9,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 20\n assert candidate(batchSize = 5,groups = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 6\n assert candidate(batchSize = 5,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 30\n assert candidate(batchSize = 3,groups = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40]) == 5\n assert candidate(batchSize = 7,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(batchSize = 4,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 8\n assert candidate(batchSize = 8,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119]) == 10\n assert candidate(batchSize = 6,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(batchSize = 4,groups = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 6\n assert candidate(batchSize = 5,groups = [2, 4, 6, 8, 10, 12, 14, 16]) == 5\n assert candidate(batchSize = 9,groups = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 6\n assert candidate(batchSize = 9,groups = [8, 7, 6, 5, 4, 3, 2, 1, 9, 18, 27, 36, 45, 54, 63, 72, 81]) == 13\n assert candidate(batchSize = 4,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9\n assert candidate(batchSize = 4,groups = [13, 19, 22, 29, 31, 37, 41, 43, 47, 53, 59]) == 6\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 8\n assert candidate(batchSize = 3,groups = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 14\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104]) == 13\n assert candidate(batchSize = 8,groups = [15, 22, 33, 44, 55, 66, 77, 88, 99]) == 5\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96]) == 12\n assert candidate(batchSize = 6,groups = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 30\n assert candidate(batchSize = 4,groups = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == 10\n assert candidate(batchSize = 6,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65]) == 8\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120]) == 15\n assert candidate(batchSize = 5,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 9\n assert candidate(batchSize = 6,groups = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72]) == 12\n assert candidate(batchSize = 9,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 7\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 182, 189, 196, 203, 210]) == 30\n assert candidate(batchSize = 9,groups = [81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93]) == 7\n assert candidate(batchSize = 5,groups = [2, 3, 4, 1, 5, 6, 7, 8, 9]) == 5\n assert candidate(batchSize = 8,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(batchSize = 3,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(batchSize = 9,groups = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 8\n assert candidate(batchSize = 5,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9\n assert candidate(batchSize = 6,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 18\n assert candidate(batchSize = 8,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112]) == 9\n assert candidate(batchSize = 6,groups = [12, 24, 36, 48, 60, 72, 84, 96, 108]) == 9\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39]) == 13\n assert candidate(batchSize = 7,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75]) == 14\n assert candidate(batchSize = 9,groups = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91]) == 2\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240]) == 30\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 5\n assert candidate(batchSize = 6,groups = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51]) == 7\n assert candidate(batchSize = 6,groups = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]) == 6\n assert candidate(batchSize = 3,groups = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 7\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 30\n assert candidate(batchSize = 4,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 10\n assert candidate(batchSize = 3,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 16\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85]) == 17\n assert candidate(batchSize = 6,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 7\n assert candidate(batchSize = 7,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9\n assert candidate(batchSize = 7,groups = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4]) == 10\n assert candidate(batchSize = 3,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 20\n assert candidate(batchSize = 7,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 9\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 15\n assert candidate(batchSize = 3,groups = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 8\n assert candidate(batchSize = 4,groups = [9, 13, 17, 21, 25, 29, 33, 37, 41, 45]) == 3\n assert candidate(batchSize = 4,groups = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 8\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112]) == 16\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180]) == 20\n assert candidate(batchSize = 9,groups = [8, 17, 26, 35, 44, 53, 62, 71, 80, 89, 98, 107, 116, 125, 134, 143, 152]) == 2\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 11\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 20\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]) == 12\n assert candidate(batchSize = 5,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n", "comparison": "exact"}, "public_tests": ["3\n[1,2,3,4,5,6]", "4\n[1,3,2,5,2,2,1,6]"], "hints": ["The maximum number of happy groups is the maximum number of partitions you can split the groups into such that the sum of group sizes in each partition is 0 mod batchSize. At most one partition is allowed to have a different remainder (the first group will get fresh donuts anyway).", "Suppose you have an array freq of length k where freq[i] = number of groups of size i mod batchSize. How can you utilize this in a dp solution?", "Make a DP state dp[freq][r] that represents \"the maximum number of partitions you can form given the current freq and current remainder r\". You can hash the freq array to store it more easily in the dp table.", "For each i from 0 to batchSize-1, the next DP state is dp[freq`][(r+i)%batchSize] where freq` is freq but with freq[i] decremented by 1. Take the largest of all of the next states and store it in ans. If r == 0, then return ans+1 (because you can form a new partition), otherwise return ans (continuing the current partition)."], "metadata": {"canonical_parameter_names": ["batchSize", "groups"], "leetcode_dataset_entry_point": "Solution().maxHappyGroups", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:34+00:00", "tests_total": 125, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "dynamic-programming", "bit-manipulation", "memoization", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def maxHappyGroups(self, batchSize: int, groups: list[int]) -> int:", "container": "Solution", "callable": "maxHappyGroups", "parameters": [{"name": "batchSize", "type": "int"}, {"name": "groups", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1816, "task_id": "truncate-sentence", "difficulty": "Easy", "problem_description": "A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of only uppercase and lowercase English letters (no punctuation).\n\n- For example, \"Hello World\", \"HELLO\", and \"hello world hello world\" are all sentences.\n\nYou are given a sentence s and an integer k. You want to truncate s such that it contains only the first k words. Return s after truncating it.\n\nExample 1:\n\nInput: s = \"Hello how are you Contestant\", k = 4\nOutput: \"Hello how are you\"\nExplanation:\nThe words in s are [\"Hello\", \"how\", \"are\", \"you\", \"Contestant\"].\nThe first 4 words are [\"Hello\", \"how\", \"are\", \"you\"].\nHence, you should return \"Hello how are you\".\n\nExample 2:\n\nInput: s = \"What is the solution to this problem\", k = 4\nOutput: \"What is the solution\"\nExplanation:\nThe words in s are [\"What\", \"is\", \"the\", \"solution\", \"to\", \"this\", \"problem\"].\nThe first 4 words are [\"What\", \"is\", \"the\", \"solution\"].\nHence, you should return \"What is the solution\".\n\nExample 3:\n\nInput: s = \"chopper is not a tanuki\", k = 5\nOutput: \"chopper is not a tanuki\"\n\nConstraints:\n\n- 1 <= s.length <= 500\n- k is in the range [1, the number of words in s].\n- s consist of only lowercase and uppercase English letters and spaces.\n- The words in s are separated by a single space.\n- There are no leading or trailing spaces.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"I love to code\",k = 3) == \"I love to\"\n assert candidate(s = \"Python is great\",k = 2) == \"Python is\"\n assert candidate(s = \"Python programming is fun\",k = 2) == \"Python programming\"\n assert candidate(s = \"A quick brown fox jumps over the lazy dog\",k = 3) == \"A quick brown\"\n assert candidate(s = \"I love programming in Python\",k = 3) == \"I love programming\"\n assert candidate(s = \"Hello how are you Contestant\",k = 4) == \"Hello how are you\"\n assert candidate(s = \"Python is a great programming language\",k = 2) == \"Python is\"\n assert candidate(s = \"chopper is not a tanuki\",k = 5) == \"chopper is not a tanuki\"\n assert candidate(s = \"Python is fun\",k = 2) == \"Python is\"\n assert candidate(s = \"I love programming\",k = 1) == \"I\"\n assert candidate(s = \"What is the solution to this problem\",k = 4) == \"What is the solution\"\n assert candidate(s = \"I love solving problems\",k = 3) == \"I love solving\"\n assert candidate(s = \"It does not matter how slowly you go as long as you do not stop\",k = 9) == \"It does not matter how slowly you go as\"\n assert candidate(s = \"The road to success is always under construction\",k = 7) == \"The road to success is always under\"\n assert candidate(s = \"The best way to predict your future is to create it\",k = 8) == \"The best way to predict your future is\"\n assert candidate(s = \"This is a test sentence to check the functionality of the code\",k = 9) == \"This is a test sentence to check the functionality\"\n assert candidate(s = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",k = 5) == \"a b c d e\"\n assert candidate(s = \"A journey of a thousand miles begins with a single step\",k = 8) == \"A journey of a thousand miles begins with\"\n assert candidate(s = \"Keep it simple stupid\",k = 5) == \"Keep it simple stupid\"\n assert candidate(s = \"To be or not to be that is the question\",k = 10) == \"To be or not to be that is the question\"\n assert candidate(s = \"May the Force be with you young Jedi\",k = 6) == \"May the Force be with you\"\n assert candidate(s = \"Short sentence\",k = 2) == \"Short sentence\"\n assert candidate(s = \"The only way to do great work is to love what you do\",k = 7) == \"The only way to do great work\"\n assert candidate(s = \"Honesty is the best policy\",k = 4) == \"Honesty is the best\"\n assert candidate(s = \"In the middle of difficulty lies opportunity\",k = 4) == \"In the middle of\"\n assert candidate(s = \"Natural language processing has become a cornerstone of modern technology\",k = 9) == \"Natural language processing has become a cornerstone of modern\"\n assert candidate(s = \"One two three four five six seven eight nine ten\",k = 10) == \"One two three four five six seven eight nine ten\"\n assert candidate(s = \"One two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen\",k = 10) == \"One two three four five six seven eight nine ten\"\n assert candidate(s = \"What you get by achieving your goals is not as important as what you become by achieving your goals\",k = 12) == \"What you get by achieving your goals is not as important as\"\n assert candidate(s = \"Debugging is twice as hard as writing the code in the first place\",k = 7) == \"Debugging is twice as hard as writing\"\n assert candidate(s = \"Python programming is fun and challenging\",k = 10) == \"Python programming is fun and challenging\"\n assert candidate(s = \"A journey of a thousand miles begins with a single step\",k = 7) == \"A journey of a thousand miles begins\"\n assert candidate(s = \"Success is not final success is to be able to continue to try\",k = 8) == \"Success is not final success is to be\"\n assert candidate(s = \"OneWordOnly\",k = 1) == \"OneWordOnly\"\n assert candidate(s = \"Data Science and Machine Learning\",k = 3) == \"Data Science and\"\n assert candidate(s = \"Life is what happens when you are busy making other plans\",k = 7) == \"Life is what happens when you are\"\n assert candidate(s = \"The early morning sun is warm and welcoming\",k = 7) == \"The early morning sun is warm and\"\n assert candidate(s = \"To be or not to be that is the question\",k = 7) == \"To be or not to be that\"\n assert candidate(s = \"Short but tricky\",k = 2) == \"Short but\"\n assert candidate(s = \"The early bird catches the worm\",k = 5) == \"The early bird catches the\"\n assert candidate(s = \"Final complex sentence with multiple words indeed\",k = 7) == \"Final complex sentence with multiple words indeed\"\n assert candidate(s = \"The best way to predict the future is to invent it\",k = 9) == \"The best way to predict the future is to\"\n assert candidate(s = \"VeryLongWordWithoutSpacesIsAlsoAcceptedButNotTypicalInSentences\",k = 1) == \"VeryLongWordWithoutSpacesIsAlsoAcceptedButNotTypicalInSentences\"\n assert candidate(s = \"Do not judge a book by its cover\",k = 7) == \"Do not judge a book by its\"\n assert candidate(s = \"All that glitters is not gold only the good do well by gold\",k = 9) == \"All that glitters is not gold only the good\"\n assert candidate(s = \"All that glitters is not gold\",k = 5) == \"All that glitters is not\"\n assert candidate(s = \"To be or not to be that is the question\",k = 5) == \"To be or not to\"\n assert candidate(s = \"Edge case with k equal to the number of words here\",k = 9) == \"Edge case with k equal to the number of\"\n assert candidate(s = \"Multiple words with mixed CASE Words\",k = 4) == \"Multiple words with mixed\"\n assert candidate(s = \"Programming in Python is both fun and educational\",k = 6) == \"Programming in Python is both fun\"\n assert candidate(s = \"A journey of a thousand miles begins with a single step\",k = 6) == \"A journey of a thousand miles\"\n assert candidate(s = \"Success is not final success is courage to continue\",k = 7) == \"Success is not final success is courage\"\n assert candidate(s = \"In the beginning God created the heavens and the earth\",k = 6) == \"In the beginning God created the\"\n assert candidate(s = \"Programming in Python is very rewarding\",k = 5) == \"Programming in Python is very\"\n assert candidate(s = \"You can lead a horse to water but you cannot make it drink\",k = 11) == \"You can lead a horse to water but you cannot make\"\n assert candidate(s = \"Another example with different words\",k = 3) == \"Another example with\"\n assert candidate(s = \"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\",k = 10) == \"A B C D E F G H I J\"\n assert candidate(s = \"The quick brown fox jumps over the lazy dog\",k = 9) == \"The quick brown fox jumps over the lazy dog\"\n assert candidate(s = \"MixedCASE Words In Sentences Should Be Handled\",k = 5) == \"MixedCASE Words In Sentences Should\"\n assert candidate(s = \"Well done is better than well said\",k = 5) == \"Well done is better than\"\n assert candidate(s = \"The quick brown fox jumps over the lazy dog\",k = 7) == \"The quick brown fox jumps over the\"\n assert candidate(s = \"Yet another test to ensure correctness\",k = 5) == \"Yet another test to ensure\"\n assert candidate(s = \"Edge case test with exact words count\",k = 6) == \"Edge case test with exact words\"\n assert candidate(s = \"SingleWord\",k = 1) == \"SingleWord\"\n assert candidate(s = \"Hello World from the other side of the universe\",k = 8) == \"Hello World from the other side of the\"\n assert candidate(s = \"In the middle of every difficulty lies opportunity\",k = 8) == \"In the middle of every difficulty lies opportunity\"\n assert candidate(s = \"One two three four five six seven eight nine ten\",k = 5) == \"One two three four five\"\n assert candidate(s = \"With great power comes great responsibility\",k = 5) == \"With great power comes great\"\n assert candidate(s = \"Multiple Spaces Between Words Are Not Allowed\",k = 5) == \"Multiple Spaces Between Words Are\"\n assert candidate(s = \"Multiple spaces should not be here but for testing purposes we will add them\",k = 10) == \"Multiple spaces should not be here but for testing purposes\"\n assert candidate(s = \"An apple a day keeps the doctor away\",k = 8) == \"An apple a day keeps the doctor away\"\n assert candidate(s = \"Sometimes the journey is more important than the destination\",k = 9) == \"Sometimes the journey is more important than the destination\"\n assert candidate(s = \"Sometimes you just want to have a long sentence to test the truncation functionality of the code\",k = 15) == \"Sometimes you just want to have a long sentence to test the truncation functionality of\"\n assert candidate(s = \"A quick brown fox jumps over the lazy dog\",k = 9) == \"A quick brown fox jumps over the lazy dog\"\n assert candidate(s = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",k = 26) == \"a b c d e f g h i j k l m n o p q r s t u v w x y z\"\n assert candidate(s = \"This is a very long sentence that we need to truncate to the first few words\",k = 7) == \"This is a very long sentence that\"\n assert candidate(s = \"May the force be with you\",k = 5) == \"May the force be with\"\n assert candidate(s = \"In the heart of the night the fireflies dance\",k = 8) == \"In the heart of the night the fireflies\"\n assert candidate(s = \"ManyManyWordsInOneSentenceWithoutSpacesButAllowedByConstraintsIfWeRemoveSpacesThenThisWillBeAVeryLongListofWords\",k = 5) == \"ManyManyWordsInOneSentenceWithoutSpacesButAllowedByConstraintsIfWeRemoveSpacesThenThisWillBeAVeryLongListofWords\"\n assert candidate(s = \"To be or not to be that is the question\",k = 6) == \"To be or not to be\"\n assert candidate(s = \"Better late than never\",k = 4) == \"Better late than never\"\n assert candidate(s = \"Actions speak louder than words\",k = 4) == \"Actions speak louder than\"\n assert candidate(s = \"Keep calm and carry on\",k = 3) == \"Keep calm and\"\n assert candidate(s = \"Lorem ipsum dolor sit amet consectetur adipiscing elit\",k = 7) == \"Lorem ipsum dolor sit amet consectetur adipiscing\"\n assert candidate(s = \"This is a longer sentence to test the functionality\",k = 7) == \"This is a longer sentence to test\"\n assert candidate(s = \"Software design is all about managing complexity\",k = 7) == \"Software design is all about managing complexity\"\n assert candidate(s = \"May the Force be with you\",k = 3) == \"May the Force\"\n assert candidate(s = \"Data structures and algorithms are the building blocks of software development\",k = 8) == \"Data structures and algorithms are the building blocks\"\n assert candidate(s = \"An algorithm must be seen to be believed\",k = 5) == \"An algorithm must be seen\"\n assert candidate(s = \"This is a test for truncating the sentence at exactly the word limit\",k = 10) == \"This is a test for truncating the sentence at exactly\"\n", "comparison": "exact"}, "public_tests": ["\"Hello how are you Contestant\"\n4", "\"What is the solution to this problem\"\n4", "\"chopper is not a tanuki\"\n5"], "hints": ["It's easier to solve this problem on an array of strings so parse the string to an array of words", "After return the first k words as a sentence"], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().truncateSentence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:36+00:00", "tests_total": 94, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "string"]}, "language": "python", "interface": {"raw_signature": "def truncateSentence(self, s: str, k: int) -> str:", "container": "Solution", "callable": "truncateSentence", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1817, "task_id": "finding-the-users-active-minutes", "difficulty": "Medium", "problem_description": "You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented by a 2D integer array logs where each logs[i] = [ID_i, time_i] indicates that the user with ID_i performed an action at the minute time_i.\n\nMultiple users can perform actions simultaneously, and a single user can perform multiple actions in the same minute.\n\nThe user active minutes (UAM) for a given user is defined as the number of unique minutes in which the user performed an action on LeetCode. A minute can only be counted once, even if multiple actions occur during it.\n\nYou are to calculate a 1-indexed array answer of size k such that, for each j (1 <= j <= k), answer[j] is the number of users whose UAM equals j.\n\nReturn the array answer as described above.\n\nExample 1:\n\nInput: logs = [[0,5],[1,2],[0,2],[0,5],[1,3]], k = 5\nOutput: [0,2,0,0,0]\nExplanation:\nThe user with ID=0 performed actions at minutes 5, 2, and 5 again. Hence, they have a UAM of 2 (minute 5 is only counted once).\nThe user with ID=1 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.\nSince both users have a UAM of 2, answer[2] is 2, and the remaining answer[j] values are 0.\n\nExample 2:\n\nInput: logs = [[1,1],[2,2],[2,3]], k = 4\nOutput: [1,1,0,0]\nExplanation:\nThe user with ID=1 performed a single action at minute 1. Hence, they have a UAM of 1.\nThe user with ID=2 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.\nThere is one user with a UAM of 1 and one with a UAM of 2.\nHence, answer[1] = 1, answer[2] = 1, and the remaining values are 0.\n\nConstraints:\n\n- 1 <= logs.length <= 10^4\n- 0 <= ID_i <= 10^9\n- 1 <= time_i <= 10^5\n- k is in the range [The maximum UAM for a user, 10^5].\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],k = 3) == [0, 0, 3]\n assert candidate(logs = [[10, 1], [11, 2], [10, 2], [11, 3], [10, 3], [11, 4]],k = 4) == [0, 0, 2, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],k = 5) == [0, 0, 0, 0, 1]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3]],k = 3) == [0, 0, 2]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1]],k = 1) == [4]\n assert candidate(logs = [[1, 1], [2, 2], [2, 3]],k = 4) == [1, 1, 0, 0]\n assert candidate(logs = [[10, 10], [10, 10], [10, 11], [11, 12]],k = 3) == [1, 1, 0]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 5) == [5, 0, 0, 0, 0]\n assert candidate(logs = [[0, 10], [0, 10], [1, 10], [1, 11], [1, 12]],k = 3) == [1, 0, 1]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4]],k = 4) == [4, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],k = 5) == [5, 0, 0, 0, 0]\n assert candidate(logs = [[0, 5], [1, 2], [0, 2], [0, 5], [1, 3]],k = 5) == [0, 2, 0, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],k = 1) == [1]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1]],k = 1) == [5]\n assert candidate(logs = [[10, 10], [10, 10], [10, 11], [10, 12], [11, 10], [11, 11]],k = 3) == [0, 1, 1]\n assert candidate(logs = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10], [110, 10], [120, 10], [130, 10], [140, 10], [150, 10]],k = 1) == [15]\n assert candidate(logs = [[100, 1], [101, 1], [102, 2], [103, 2], [104, 3], [105, 3], [106, 4], [107, 4], [108, 5], [109, 5]],k = 5) == [10, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [0, 16], [1, 17], [2, 18], [3, 19], [4, 20]],k = 15) == [10, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15]],k = 5) == [5, 5, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],k = 5) == [5, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],k = 3) == [0, 0, 4]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],k = 5) == [0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 10) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [5, 1], [5, 2], [5, 3]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]],k = 2) == [0, 5]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [0, 4], [1, 5], [2, 6], [0, 7], [1, 8], [2, 9], [0, 10], [1, 11], [2, 12], [0, 13], [1, 14], [2, 15]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[5, 1], [5, 1], [5, 1], [5, 1], [5, 1], [6, 2], [6, 2], [6, 2], [6, 3], [6, 4], [6, 5], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4]],k = 5) == [3, 0, 0, 1, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]],k = 5) == [0, 0, 1, 1, 1]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 1, 1]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]],k = 15) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[100, 1], [101, 1], [102, 2], [103, 2], [104, 2], [105, 3], [106, 3], [107, 3], [108, 4], [109, 4]],k = 4) == [10, 0, 0, 0]\n assert candidate(logs = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15]],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(logs = [[0, 10], [1, 20], [0, 10], [1, 25], [2, 30], [3, 35], [4, 40], [5, 45], [6, 50], [7, 55], [8, 60], [9, 65]],k = 10) == [9, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 3], [12, 3], [13, 3], [14, 3], [15, 3]],k = 3) == [15, 0, 0]\n assert candidate(logs = [[9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [9, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 2]\n assert candidate(logs = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [0, 1100], [1, 1200], [2, 1300], [3, 1400], [4, 1500], [5, 1600], [6, 1700], [7, 1800], [8, 1900], [9, 2000]],k = 10) == [0, 10, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[10, 5], [10, 5], [10, 6], [10, 7], [11, 5], [11, 6], [11, 7], [12, 5], [12, 6], [12, 7], [13, 5], [13, 6], [13, 7]],k = 3) == [0, 0, 4]\n assert candidate(logs = [[0, 10], [1, 10], [2, 10], [0, 11], [1, 11], [2, 11], [0, 12], [1, 12], [2, 12]],k = 3) == [0, 0, 3]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]],k = 1) == [10]\n assert candidate(logs = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [101, 1], [101, 2], [101, 3], [101, 4], [101, 5], [102, 1], [102, 2], [102, 3], [102, 4], [102, 5], [103, 1], [103, 2], [103, 3], [103, 4], [103, 5]],k = 5) == [0, 0, 0, 0, 4]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 11], [1, 12], [2, 13], [3, 14], [4, 15], [5, 16], [6, 17], [7, 18], [8, 19], [9, 20]],k = 10) == [0, 10, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 5], [0, 5], [0, 5], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 1], [2, 1], [2, 2]],k = 5) == [1, 1, 0, 1, 0]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8]],k = 5) == [0, 0, 0, 5, 0]\n assert candidate(logs = [[99, 99], [99, 100], [99, 101], [99, 102], [99, 103], [99, 104], [99, 105]],k = 7) == [0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11], [120, 12], [130, 13], [140, 14], [150, 15]],k = 15) == [15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(logs = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [0, 3], [1, 3], [2, 3], [3, 3], [4, 3]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15]],k = 15) == [0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[10, 100], [11, 101], [10, 101], [11, 102], [12, 102], [13, 103], [13, 104], [14, 104], [14, 105], [15, 106], [15, 106], [15, 107]],k = 5) == [1, 5, 0, 0, 0]\n assert candidate(logs = [[0, 10], [0, 10], [0, 11], [1, 12], [1, 12], [1, 13], [2, 14], [2, 15], [2, 15], [2, 16]],k = 4) == [0, 2, 1, 0]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],k = 2) == [0, 11]\n assert candidate(logs = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1]],k = 1) == [1]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],k = 20) == [20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [0, 2], [1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2]],k = 2) == [0, 6]\n assert candidate(logs = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5], [11, 5], [12, 5], [13, 5], [14, 5]],k = 1) == [15]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 11]],k = 11) == [9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [0, 3], [1, 3], [2, 3], [3, 3], [4, 3], [0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [0, 6], [1, 6], [2, 6], [3, 6], [4, 6]],k = 6) == [0, 0, 0, 0, 0, 5]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2], [0, 3], [1, 3], [2, 3], [0, 4], [1, 4], [2, 4], [0, 5], [1, 5], [2, 5], [0, 6], [1, 6], [2, 6]],k = 6) == [0, 0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 1, 1, 1]\n assert candidate(logs = [[10, 1], [10, 2], [10, 3], [20, 1], [20, 2], [30, 1], [30, 2], [30, 3], [40, 1], [40, 2], [40, 3], [50, 1], [50, 2], [50, 3], [60, 1], [60, 2]],k = 3) == [0, 2, 4]\n assert candidate(logs = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [1, 12], [2, 12], [3, 12], [4, 12], [5, 12]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[0, 1], [0, 2], [0, 1], [0, 2], [0, 1], [0, 2], [0, 1], [0, 2], [0, 1], [0, 2], [0, 3], [0, 4]],k = 5) == [0, 0, 0, 1, 0]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 2) == [5, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [5, 1], [5, 2], [5, 3], [6, 1], [6, 2], [6, 3]],k = 3) == [0, 0, 7]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(logs = [[1, 1], [2, 2], [2, 2], [2, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],k = 4) == [4, 1, 0, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4]],k = 4) == [0, 0, 0, 4]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],k = 1) == [15]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20]],k = 20) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]],k = 1) == [1]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [5, 6], [5, 7], [5, 8], [6, 9]],k = 5) == [4, 1, 1, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],k = 1) == [5]\n assert candidate(logs = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5]],k = 1) == [10]\n assert candidate(logs = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16]],k = 6) == [0, 2, 1, 1, 1, 0]\n assert candidate(logs = [[10, 10], [10, 10], [20, 20], [20, 21], [20, 22], [30, 30], [30, 30], [30, 31]],k = 3) == [1, 1, 1]\n assert candidate(logs = [[0, 1], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6]],k = 6) == [1, 0, 1, 1, 1, 1]\n assert candidate(logs = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2], [6, 1], [6, 2], [7, 1], [7, 2], [8, 1], [8, 2], [9, 1], [9, 2], [10, 1], [10, 2]],k = 2) == [0, 10]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8]],k = 8) == [0, 0, 0, 0, 1, 0, 1, 1]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [1, 16]],k = 6) == [0, 0, 4, 1, 0, 0]\n assert candidate(logs = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [10, 11], [20, 12], [30, 13], [40, 14], [50, 15], [60, 16], [70, 17], [80, 18], [90, 19], [100, 20]],k = 10) == [0, 10, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[0, 1], [0, 1], [0, 1], [0, 2], [0, 2], [0, 2], [0, 3], [0, 3], [0, 3], [0, 4], [0, 4], [0, 4], [0, 5], [0, 5], [0, 5]],k = 5) == [0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [0, 11], [1, 12], [2, 13], [3, 14], [4, 15]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],k = 15) == [15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [4, 18], [4, 19], [4, 20]],k = 7) == [1, 0, 2, 0, 0, 1, 1]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]],k = 5) == [0, 0, 1, 1, 1]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [0, 11], [1, 12], [2, 13], [3, 14], [4, 15]],k = 5) == [0, 0, 5, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 2], [2, 1], [2, 1], [2, 2], [2, 3], [3, 1], [3, 1], [3, 2], [3, 3], [3, 4]],k = 4) == [0, 1, 1, 1]\n assert candidate(logs = [[0, 1], [0, 1], [1, 1], [1, 1], [2, 1], [2, 1], [3, 1], [3, 1], [4, 1], [4, 1]],k = 1) == [5]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[10, 10], [20, 10], [10, 20], [20, 20], [10, 30], [20, 40], [30, 50]],k = 5) == [1, 0, 2, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 2], [4, 1], [4, 2], [4, 3], [4, 4]],k = 4) == [1, 1, 1, 1]\n assert candidate(logs = [[100, 1], [101, 2], [102, 3], [103, 4], [104, 5], [105, 6], [106, 7], [107, 8], [108, 9], [109, 10]],k = 10) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],k = 3) == [0, 1, 3]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1]],k = 1) == [20]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20]],k = 20) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],k = 1) == [11]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3], [1, 4], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [1, 6], [2, 6], [3, 6], [1, 7], [2, 7], [3, 7]],k = 7) == [0, 0, 0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 0, 0, 3]\n", "comparison": "exact"}, "public_tests": ["[[0,5],[1,2],[0,2],[0,5],[1,3]]\n5", "[[1,1],[2,2],[2,3]]\n4"], "hints": ["Try to find the number of different minutes when action happened for each user.", "For each user increase the value of the answer array index which matches the UAM for this user."], "metadata": {"canonical_parameter_names": ["logs", "k"], "leetcode_dataset_entry_point": "Solution().findingUsersActiveMinutes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:39+00:00", "tests_total": 108, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table"]}, "language": "python", "interface": {"raw_signature": "def findingUsersActiveMinutes(self, logs: list[list[int]], k: int) -> list[int]:", "container": "Solution", "callable": "findingUsersActiveMinutes", "parameters": [{"name": "logs", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1818, "task_id": "minimum-absolute-sum-difference", "difficulty": "Medium", "problem_description": "You are given two positive integer arrays nums1 and nums2, both of length n.\n\nThe absolute sum difference of arrays nums1 and nums2 is defined as the sum of |nums1[i] - nums2[i]| for each 0 <= i < n (0-indexed).\n\nYou can replace at most one element of nums1 with any other element in nums1 to minimize the absolute sum difference.\n\nReturn the minimum absolute sum difference after replacing at most one element in the array nums1. Since the answer may be large, return it modulo 10^9 + 7.\n\n|x| is defined as:\n\n- x if x >= 0, or\n- -x if x < 0.\n\nExample 1:\n\nInput: nums1 = [1,7,5], nums2 = [2,3,5]\nOutput: 3\nExplanation: There are two possible optimal solutions:\n- Replace the second element with the first: [1,7,5] => [1,1,5], or\n- Replace the second element with the third: [1,7,5] => [1,5,5].\nBoth will yield an absolute sum difference of |1-2| + (|1-3| or |5-3|) + |5-5| = 3.\n\nExample 2:\n\nInput: nums1 = [2,4,6,8,10], nums2 = [2,4,6,8,10]\nOutput: 0\nExplanation: nums1 is equal to nums2 so no replacement is needed. This will result in an\nabsolute sum difference of 0.\n\nExample 3:\n\nInput: nums1 = [1,10,4,4,2,7], nums2 = [9,3,5,1,7,4]\nOutput: 20\nExplanation: Replace the first element with the second: [1,10,4,4,2,7] => [10,10,4,4,2,7].\nThis yields an absolute sum difference of |10-9| + |10-3| + |4-5| + |4-1| + |2-7| + |7-4| = 20\n\nConstraints:\n\n- n == nums1.length\n- n == nums2.length\n- 1 <= n <= 10^5\n- 1 <= nums1[i], nums2[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [1, 1, 1]) == 299997\n assert candidate(nums1 = [1, 7, 5],nums2 = [2, 3, 5]) == 3\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1]) == 16\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [1, 1, 1]) == 299997\n assert candidate(nums1 = [1, 10, 4, 4, 2, 7],nums2 = [9, 3, 5, 1, 7, 4]) == 20\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [2, 4, 6, 8, 10]) == 0\n assert candidate(nums1 = [1, 2, 3],nums2 = [6, 5, 4]) == 7\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 8\n assert candidate(nums1 = [100000, 1, 100000],nums2 = [1, 100000, 1]) == 199998\n assert candidate(nums1 = [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000],nums2 = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == 899991\n assert candidate(nums1 = [100000, 99999, 99998, 99997],nums2 = [1, 2, 3, 4]) == 399981\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1]) == 15\n assert candidate(nums1 = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 999881\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 999945\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 90\n assert candidate(nums1 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 945\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums1 = [100000, 99999, 99998, 99997, 99996],nums2 = [1, 2, 3, 4, 5]) == 499971\n assert candidate(nums1 = [100000, 100000, 100000, 100000],nums2 = [1, 100000, 100000, 1]) == 199998\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 41\n assert candidate(nums1 = [50000, 50000, 50000, 50000, 50000],nums2 = [1, 2, 3, 4, 5]) == 249985\n assert candidate(nums1 = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996],nums2 = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == 899951\n assert candidate(nums1 = [100000, 1, 50000, 75000],nums2 = [50000, 99999, 1, 100000]) == 125000\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums1 = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],nums2 = [90, 80, 70, 60, 50, 40, 30, 20, 10, 1]) == 409\n assert candidate(nums1 = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996],nums2 = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == 899951\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [45, 40, 35, 30, 25, 20, 15, 10, 5, 1]) == 204\n assert candidate(nums1 = [50000, 50000, 50000, 50000, 50000],nums2 = [1, 1, 1, 1, 1]) == 249995\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 10\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [1, 3, 6, 8, 11, 13, 16, 18, 21, 23]) == 130\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 98\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999]) == 999980\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 499936\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5]) == 95\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 36\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 16\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [90000, 90000, 90000]) == 30000\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 210\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == 500\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 41\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 50\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 32\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 181\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 82\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 25\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 8\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000],nums2 = [100000, 10000, 1000, 100, 10, 1]) == 121779\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 486\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 410\n assert candidate(nums1 = [100, 100, 100, 100, 100],nums2 = [10, 90, 110, 10, 90]) == 210\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 999990\n assert candidate(nums1 = [100000, 100000, 100000, 100000],nums2 = [1, 1, 1, 1]) == 399996\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 50\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 67\n assert candidate(nums1 = [1, 10, 100, 1000, 10000],nums2 = [2, 11, 101, 1001, 10001]) == 5\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 405\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 549990\n assert candidate(nums1 = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 999891\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 20\n assert candidate(nums1 = [99999, 99998, 99997, 99996, 99995],nums2 = [1, 100, 200, 300, 400]) == 498980\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 9\n assert candidate(nums1 = [50000, 40000, 30000, 20000, 10000],nums2 = [1, 2, 3, 4, 5]) == 109985\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 171\n assert candidate(nums1 = [100000, 90000, 80000, 70000, 60000],nums2 = [50000, 40000, 30000, 20000, 10000]) == 210000\n assert candidate(nums1 = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 99943\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [101, 201, 301, 401, 501]) == 5\n assert candidate(nums1 = [5, 25, 45, 65, 85],nums2 = [10, 30, 50, 70, 90]) == 25\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 82\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 891\n assert candidate(nums1 = [100000, 100000, 100000, 100000, 100000],nums2 = [1, 1, 1, 1, 1]) == 499995\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 540\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55]) == 25\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 999882\n assert candidate(nums1 = [100000, 50000, 25000, 12500, 6250],nums2 = [99999, 49999, 24999, 12499, 6249]) == 5\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 55\n", "comparison": "exact"}, "public_tests": ["[1,7,5]\n[2,3,5]", "[2,4,6,8,10]\n[2,4,6,8,10]", "[1,10,4,4,2,7]\n[9,3,5,1,7,4]"], "hints": ["Go through each element and test the optimal replacements.", "There are only 2 possible replacements for each element (higher and lower) that are optimal."], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minAbsoluteSumDiff", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:41+00:00", "tests_total": 87, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "binary-search", "sorting", "ordered-set"]}, "language": "python", "interface": {"raw_signature": "def minAbsoluteSumDiff(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "minAbsoluteSumDiff", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1819, "task_id": "number-of-different-subsequences-gcds", "difficulty": "Hard", "problem_description": "You are given an array nums that consists of positive integers.\n\nThe GCD of a sequence of numbers is defined as the greatest integer that divides all the numbers in the sequence evenly.\n\n- For example, the GCD of the sequence [4,6,16] is 2.\n\nA subsequence of an array is a sequence that can be formed by removing some elements (possibly none) of the array.\n\n- For example, [2,5,10] is a subsequence of [1,2,1,2,4,1,5,10].\n\nReturn the number of different GCDs among all non-empty subsequences of nums.\n\nExample 1:\n\nInput: nums = [6,10,3]\nOutput: 5\nExplanation: The figure shows all the non-empty subsequences and their GCDs.\nThe different GCDs are 6, 10, 3, 2, and 1.\n\nExample 2:\n\nInput: nums = [5,15,40,5,6]\nOutput: 7\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 2 * 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [6, 10, 3]) == 5\n assert candidate(nums = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [5, 15, 40, 5, 6]) == 7\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500]) == 5\n assert candidate(nums = [7, 14, 21, 28, 35]) == 5\n assert candidate(nums = [100000]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 11\n assert candidate(nums = [100000, 200000, 150000]) == 4\n assert candidate(nums = [7, 7, 7, 7]) == 1\n assert candidate(nums = [30, 15, 60, 90, 180]) == 5\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840, 882, 924, 966, 1008, 1050]) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 50\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 20\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 15\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 10\n assert candidate(nums = [37, 74, 111, 148, 185, 222, 259, 296, 333, 370, 407, 444, 481, 518, 555, 592, 629, 666, 703, 740, 777, 814, 851, 888, 925, 962, 999]) == 27\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630]) == 15\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020]) == 20\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175]) == 18\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 30\n assert candidate(nums = [10, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 22\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]) == 15\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 15\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120]) == 20\n assert candidate(nums = [5, 25, 45, 65, 85, 105, 125, 145, 165, 185, 205, 225, 245, 265, 285, 305, 325, 345, 365, 385]) == 23\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225, 234, 243, 252, 261, 270]) == 30\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197]) == 21\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30]) == 34\n assert candidate(nums = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111]) == 25\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 10\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 10\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993]) == 16\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 20\n assert candidate(nums = [12, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 26\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260, 273, 286, 299, 312, 325, 338, 351, 364, 377, 390]) == 30\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225]) == 25\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == 16\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 20\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96]) == 24\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515]) == 15\n assert candidate(nums = [37, 74, 111, 148, 185, 222, 259, 296, 333, 370, 407, 444, 481, 518, 555, 592, 629, 666, 703, 740]) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 25\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 25\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275, 286, 297, 308, 319, 330]) == 30\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 20\n assert candidate(nums = [104729, 104728, 104727, 104726, 104725, 104724, 104723, 104722, 104721, 104720, 104719, 104718, 104717, 104716, 104715]) == 25\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 20\n assert candidate(nums = [97, 194, 291, 388, 485, 582, 679, 776, 873, 970, 1067, 1164, 1261, 1358, 1455, 1552, 1649, 1746, 1843, 1940]) == 20\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 16\n assert candidate(nums = [15, 21, 25, 33, 35, 39, 45, 51, 55, 57, 63, 65, 69, 75, 77, 81, 85, 87, 91, 93, 95, 99]) == 31\n assert candidate(nums = [37, 74, 111, 148, 185, 222, 259, 296, 333, 370, 407, 444, 481, 518, 555]) == 15\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54]) == 18\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == 21\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600]) == 10\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300]) == 25\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 15\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 26\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == 14\n assert candidate(nums = [99995, 99996, 99997, 99998, 99999, 100000, 100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009]) == 26\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 20\n assert candidate(nums = [71, 142, 213, 284, 355, 426, 497, 568, 639, 710, 781, 852, 923, 994, 1065, 1136, 1207, 1278, 1349]) == 19\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510, 540, 570, 600]) == 20\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 15\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 900, 960, 1020, 1080, 1140, 1200]) == 20\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 30\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == 20\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 10\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300, 315, 330, 345, 360, 375, 390, 405, 420, 435, 450]) == 30\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 1\n assert candidate(nums = [120, 240, 360, 480, 600, 720, 840, 960, 1080, 1200, 1320, 1440, 1560, 1680, 1800, 1920, 2040]) == 17\n assert candidate(nums = [21, 35, 49, 63, 77, 91, 105, 119, 133, 147]) == 11\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99]) == 33\n assert candidate(nums = [200000, 199999, 199998, 199997, 199996, 199995, 199994, 199993, 199992, 199991]) == 17\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300]) == 20\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 1\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340]) == 20\n assert candidate(nums = [30, 42, 54, 60, 72, 84, 90, 102, 105, 108, 120, 126, 132, 144, 150, 156, 162, 168, 180, 192]) == 29\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015]) == 27\n", "comparison": "exact"}, "public_tests": ["[6,10,3]", "[5,15,40,5,6]"], "hints": ["Think of how to check if a number x is a gcd of a subsequence.", "If there is such subsequence, then all of it will be divisible by x. Moreover, if you divide each number in the subsequence by x , then the gcd of the resulting numbers will be 1.", "Adding a number to a subsequence cannot increase its gcd. So, if there is a valid subsequence for x , then the subsequence that contains all multiples of x is a valid one too.", "Iterate on all possiblex from 1 to 10^5, and check if there is a valid subsequence for x."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countDifferentSubsequenceGCDs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:44+00:00", "tests_total": 101, "tests_dropped": 3, "flags": ["has_images"], "topic_tags": ["array", "math", "counting", "number-theory", "euclidean-algorithm", "greatest-common-divisor"]}, "language": "python", "interface": {"raw_signature": "def countDifferentSubsequenceGCDs(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countDifferentSubsequenceGCDs", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1822, "task_id": "sign-of-the-product-of-an-array", "difficulty": "Easy", "problem_description": "Implement a function signFunc(x) that returns:\n\n- 1 if x is positive.\n- -1 if x is negative.\n- 0 if x is equal to 0.\n\nYou are given an integer array nums. Let product be the product of all values in the array nums.\n\nReturn signFunc(product).\n\nExample 1:\n\nInput: nums = [-1,-2,-3,-4,3,2,1]\nOutput: 1\nExplanation: The product of all values in the array is 144, and signFunc(144) = 1\n\nExample 2:\n\nInput: nums = [1,5,0,2,-3]\nOutput: 0\nExplanation: The product of all values in the array is 0, and signFunc(0) = 0\n\nExample 3:\n\nInput: nums = [-1,1,-1,1,-1]\nOutput: -1\nExplanation: The product of all values in the array is -1, and signFunc(-1) = -1\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- -100 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1]) == -1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [0, 0, 0]) == 0\n assert candidate(nums = [-99, -98, -97, -96, -95, -94, -93, -92, -91, -90]) == 1\n assert candidate(nums = [100, -100, 100]) == -1\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [100, -100, 1]) == -1\n assert candidate(nums = [-100, 0, 100]) == 0\n assert candidate(nums = [-1, -2, -3, -4, 3, 2, 1]) == 1\n assert candidate(nums = [100, -100, 100, -100]) == 1\n assert candidate(nums = [-1, -2, -3, -4]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [1, 5, 0, 2, -3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [-1, -2, -3]) == -1\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == 0\n assert candidate(nums = [100, -50, 25, -10, 5]) == 1\n assert candidate(nums = [100, -50, 25, -12.5, 6.25]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 1\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 0\n assert candidate(nums = [-1, 1, 0, -1, 1, 0, -1, 1, 0]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 0, 60, 70, 80, 90]) == 0\n assert candidate(nums = [1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1]) == 0\n assert candidate(nums = [-50, 50, -50, 50, -50, 50, -50, 50, -50, 50]) == -1\n assert candidate(nums = [50, 25, -10, 4, -2, 0.5, 0.2]) == 1\n assert candidate(nums = [-100, 0, 100, -100, 100, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, -6, -7, -8, -9, -10]) == -1\n assert candidate(nums = [-1, -1, -1, -1, -1]) == -1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 0\n assert candidate(nums = [0, 1, 2, 3]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == -1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == -1\n assert candidate(nums = [100, -50, 25, -12.5, 0.5]) == 1\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0]) == 0\n assert candidate(nums = [100, -100, 50, -50, 25, -25]) == -1\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6]) == -1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 1\n assert candidate(nums = [1, 0, -1, 2, 0, -2, 3, 0, -3, 4, 0, -4]) == 0\n assert candidate(nums = [100, -50, 0, 25, -10]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [99, 98, 97, -96, -95, -94]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0]) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [99, -99, 98, -98, 97, -97, 96, -96, 95, -95]) == -1\n assert candidate(nums = [-10, 10, -10, 10]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 1\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]) == -1\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == -1\n assert candidate(nums = [-10, -20, -30, -40, -50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]) == 0\n assert candidate(nums = [100, -50, 20, -10, 5]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -16]) == -1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [100, -100, 100, -100, 100]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == -1\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, 0]) == 0\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100]) == 1\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 1\n assert candidate(nums = [-100, 100, -10, 10, -1, 1]) == -1\n", "comparison": "exact"}, "public_tests": ["[-1,-2,-3,-4,3,2,1]", "[1,5,0,2,-3]", "[-1,1,-1,1,-1]"], "hints": ["If there is a 0 in the array the answer is 0", "To avoid overflow make all the negative numbers -1 and all positive numbers 1 and calculate the prod"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().arraySign", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:49+00:00", "tests_total": 96, "tests_dropped": 9, "flags": [], "topic_tags": ["array", "math"]}, "language": "python", "interface": {"raw_signature": "def arraySign(self, nums: list[int]) -> int:", "container": "Solution", "callable": "arraySign", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1823, "task_id": "find-the-winner-of-the-circular-game", "difficulty": "Medium", "problem_description": "There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwise from the i^th friend brings you to the (i+1)^th friend for 1 <= i < n, and moving clockwise from the n^th friend brings you to the 1^st friend.\n\nThe rules of the game are as follows:\n\n1. Start at the 1^st friend.\n2. Count the next k friends in the clockwise direction including the friend you started at. The counting wraps around the circle and may count some friends more than once.\n3. The last friend you counted leaves the circle and loses the game.\n4. If there is still more than one friend in the circle, go back to step 2 starting from the friend immediately clockwise of the friend who just lost and repeat.\n5. Else, the last friend in the circle wins the game.\n\nGiven the number of friends, n, and an integer k, return the winner of the game.\n\nExample 1:\n\nInput: n = 5, k = 2\nOutput: 3\nExplanation: Here are the steps of the game:\n1) Start at friend 1.\n2) Count 2 friends clockwise, which are friends 1 and 2.\n3) Friend 2 leaves the circle. Next start is friend 3.\n4) Count 2 friends clockwise, which are friends 3 and 4.\n5) Friend 4 leaves the circle. Next start is friend 5.\n6) Count 2 friends clockwise, which are friends 5 and 1.\n7) Friend 1 leaves the circle. Next start is friend 3.\n8) Count 2 friends clockwise, which are friends 3 and 5.\n9) Friend 5 leaves the circle. Only friend 3 is left, so they are the winner.\n\nExample 2:\n\nInput: n = 6, k = 5\nOutput: 1\nExplanation: The friends leave in this order: 5, 4, 6, 2, 3. The winner is friend 1.\n\nConstraints:\n\n- 1 <= k <= n <= 500\n\nFollow up:\n\nCould you solve this problem in linear time with constant space?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,k = 1) == 3\n assert candidate(n = 3,k = 3) == 2\n assert candidate(n = 5,k = 2) == 3\n assert candidate(n = 7,k = 3) == 4\n assert candidate(n = 7,k = 1) == 7\n assert candidate(n = 6,k = 5) == 1\n assert candidate(n = 7,k = 7) == 5\n assert candidate(n = 1,k = 1) == 1\n assert candidate(n = 4,k = 4) == 2\n assert candidate(n = 10,k = 4) == 5\n assert candidate(n = 10,k = 3) == 4\n assert candidate(n = 250,k = 125) == 173\n assert candidate(n = 300,k = 150) == 152\n assert candidate(n = 250,k = 150) == 76\n assert candidate(n = 200,k = 100) == 189\n assert candidate(n = 150,k = 50) == 138\n assert candidate(n = 300,k = 300) == 265\n assert candidate(n = 450,k = 450) == 87\n assert candidate(n = 123,k = 123) == 94\n assert candidate(n = 499,k = 250) == 134\n assert candidate(n = 300,k = 200) == 139\n assert candidate(n = 100,k = 13) == 70\n assert candidate(n = 500,k = 1) == 500\n assert candidate(n = 37,k = 37) == 16\n assert candidate(n = 500,k = 250) == 384\n assert candidate(n = 20,k = 19) == 11\n assert candidate(n = 200,k = 199) == 163\n assert candidate(n = 100,k = 99) == 88\n assert candidate(n = 30,k = 15) == 4\n assert candidate(n = 50,k = 7) == 1\n assert candidate(n = 30,k = 29) == 25\n assert candidate(n = 50,k = 2) == 37\n assert candidate(n = 250,k = 89) == 225\n assert candidate(n = 250,k = 3) == 41\n assert candidate(n = 50,k = 10) == 36\n assert candidate(n = 100,k = 37) == 45\n assert candidate(n = 40,k = 7) == 24\n assert candidate(n = 45,k = 23) == 36\n assert candidate(n = 45,k = 19) == 14\n assert candidate(n = 100,k = 50) == 95\n assert candidate(n = 123,k = 45) == 116\n assert candidate(n = 45,k = 13) == 36\n assert candidate(n = 500,k = 2) == 489\n assert candidate(n = 499,k = 300) == 36\n assert candidate(n = 200,k = 1) == 200\n assert candidate(n = 300,k = 299) == 145\n assert candidate(n = 400,k = 399) == 30\n assert candidate(n = 125,k = 124) == 31\n assert candidate(n = 150,k = 75) == 125\n assert candidate(n = 20,k = 7) == 3\n assert candidate(n = 350,k = 7) == 211\n assert candidate(n = 150,k = 2) == 45\n assert candidate(n = 123,k = 57) == 77\n assert candidate(n = 150,k = 41) == 79\n assert candidate(n = 200,k = 67) == 163\n assert candidate(n = 499,k = 499) == 122\n assert candidate(n = 500,k = 499) == 121\n assert candidate(n = 500,k = 500) == 69\n assert candidate(n = 400,k = 100) == 313\n assert candidate(n = 499,k = 5) == 327\n assert candidate(n = 200,k = 50) == 23\n assert candidate(n = 20,k = 5) == 7\n assert candidate(n = 250,k = 249) == 204\n assert candidate(n = 40,k = 13) == 14\n assert candidate(n = 50,k = 11) == 10\n assert candidate(n = 450,k = 3) == 286\n assert candidate(n = 450,k = 449) == 143\n assert candidate(n = 50,k = 13) == 5\n assert candidate(n = 15,k = 11) == 12\n assert candidate(n = 37,k = 13) == 14\n assert candidate(n = 15,k = 7) == 5\n assert candidate(n = 30,k = 11) == 28\n assert candidate(n = 300,k = 100) == 59\n assert candidate(n = 40,k = 19) == 6\n assert candidate(n = 120,k = 1) == 120\n assert candidate(n = 299,k = 299) == 146\n assert candidate(n = 50,k = 17) == 8\n assert candidate(n = 150,k = 1) == 150\n assert candidate(n = 250,k = 100) == 23\n assert candidate(n = 45,k = 20) == 29\n assert candidate(n = 373,k = 186) == 14\n assert candidate(n = 499,k = 2) == 487\n assert candidate(n = 50,k = 25) == 5\n", "comparison": "exact"}, "public_tests": ["5\n2", "6\n5"], "hints": ["Simulate the process.", "Maintain in a circular list the people who are still in the circle and the current person you are standing at.", "In each turn, count k people and remove the last person from the list."], "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().findTheWinner", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:51+00:00", "tests_total": 83, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "math", "recursion", "queue", "simulation"]}, "language": "python", "interface": {"raw_signature": "def findTheWinner(self, n: int, k: int) -> int:", "container": "Solution", "callable": "findTheWinner", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1824, "task_id": "minimum-sideway-jumps", "difficulty": "Medium", "problem_description": "There is a 3 lane road of length n that consists of n + 1 points labeled from 0 to n. A frog starts at point 0 in the second lane and wants to jump to point n. However, there could be obstacles along the way.\n\nYou are given an array obstacles of length n + 1 where each obstacles[i] (ranging from 0 to 3) describes an obstacle on the lane obstacles[i] at point i. If obstacles[i] == 0, there are no obstacles at point i. There will be at most one obstacle in the 3 lanes at each point.\n\n- For example, if obstacles[2] == 1, then there is an obstacle on lane 1 at point 2.\n\nThe frog can only travel from point i to point i + 1 on the same lane if there is not an obstacle on the lane at point i + 1. To avoid obstacles, the frog can also perform a side jump to jump to another lane (even if they are not adjacent) at the same point if there is no obstacle on the new lane.\n\n- For example, the frog can jump from lane 3 at point 3 to lane 1 at point 3.\n\nReturn the minimum number of side jumps the frog needs to reach any lane at point n starting from lane 2 at point 0.\n\nNote: There will be no obstacles on points 0 and n.\n\nExample 1:\n\nInput: obstacles = [0,1,2,3,0]\nOutput: 2\nExplanation: The optimal solution is shown by the arrows above. There are 2 side jumps (red arrows).\nNote that the frog can jump over obstacles only when making side jumps (as shown at point 2).\n\nExample 2:\n\nInput: obstacles = [0,1,1,3,3,0]\nOutput: 0\nExplanation: There are no obstacles on lane 2. No side jumps are required.\n\nExample 3:\n\nInput: obstacles = [0,2,1,0,3,0]\nOutput: 2\nExplanation: The optimal solution is shown by the arrows above. There are 2 side jumps.\n\nConstraints:\n\n- obstacles.length == n + 1\n- 1 <= n <= 5 * 10^5\n- 0 <= obstacles[i] <= 3\n- obstacles[0] == obstacles[n] == 0\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(obstacles = [0, 1, 0, 0, 2, 0, 0, 3, 0, 0]) == 1\n assert candidate(obstacles = [0, 0, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 1, 0, 3, 2, 1, 0]) == 4\n assert candidate(obstacles = [0, 0, 1, 0, 0, 2, 0, 0, 3, 0]) == 1\n assert candidate(obstacles = [0, 1, 3, 2, 3, 1, 0, 0, 0, 0]) == 2\n assert candidate(obstacles = [0, 3, 0, 0, 2, 0, 0, 1, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 0, 0]) == 5\n assert candidate(obstacles = [0, 2, 1, 0, 3, 0]) == 2\n assert candidate(obstacles = [0, 1, 2, 0, 2, 1, 0, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 2, 0, 0, 0, 3, 0, 0, 1, 0]) == 2\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 0]) == 1\n assert candidate(obstacles = [0, 1, 1, 3, 3, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 1, 3, 0]) == 3\n assert candidate(obstacles = [0, 0, 1, 2, 3, 0]) == 2\n assert candidate(obstacles = [0, 3, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 2, 0, 2, 0, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 0, 3, 0, 3, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 3, 0]) == 2\n assert candidate(obstacles = [0, 1, 0, 0, 2, 0]) == 1\n assert candidate(obstacles = [0, 2, 3, 2, 1, 2, 3, 0]) == 3\n assert candidate(obstacles = [0, 3, 2, 1, 0, 0]) == 2\n assert candidate(obstacles = [0, 1, 2, 0, 3, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 1, 0, 0]) == 2\n assert candidate(obstacles = [0, 2, 2, 2, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 2, 1, 3, 2, 1, 0]) == 5\n assert candidate(obstacles = [0, 3, 0, 1, 2, 0, 0, 0, 0, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 16\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 11\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 12\n assert candidate(obstacles = [0, 3, 3, 3, 3, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0]) == 10\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 8\n assert candidate(obstacles = [0, 1, 1, 1, 1, 0, 2, 2, 2, 2, 0, 3, 3, 3, 3, 0, 1, 1, 1, 1, 0]) == 2\n assert candidate(obstacles = [0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 20\n assert candidate(obstacles = [0, 1, 2, 0, 3, 0, 1, 2, 0, 3, 0, 1, 2, 0, 3, 0, 1, 2, 0]) == 7\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 4\n assert candidate(obstacles = [0, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 0]) == 5\n assert candidate(obstacles = [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]) == 10\n assert candidate(obstacles = [0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 3\n assert candidate(obstacles = [0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]) == 1\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 10\n assert candidate(obstacles = [0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 0, 1, 0, 3, 2, 0, 1, 0, 3, 0]) == 4\n assert candidate(obstacles = [0, 1, 0, 0, 2, 0, 3, 0, 0, 1, 0, 0, 0, 3, 0, 2, 0]) == 3\n assert candidate(obstacles = [0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 3, 3, 2, 2, 1, 1, 3, 3, 2, 2, 1, 1, 0]) == 5\n assert candidate(obstacles = [0, 1, 3, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 10\n assert candidate(obstacles = [0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0]) == 10\n assert candidate(obstacles = [0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0]) == 4\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 13\n assert candidate(obstacles = [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 12\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0]) == 7\n assert candidate(obstacles = [0, 3, 2, 1, 0, 2, 1, 0, 3, 2, 1, 0, 2, 1, 3, 0]) == 5\n assert candidate(obstacles = [0, 1, 3, 2, 3, 1, 2, 3, 0, 1, 2, 3, 0]) == 6\n assert candidate(obstacles = [0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 30\n assert candidate(obstacles = [0, 2, 1, 3, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 26\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 11\n assert candidate(obstacles = [0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 25\n assert candidate(obstacles = [0, 2, 2, 0, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 0]) == 5\n assert candidate(obstacles = [0, 3, 0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0]) == 6\n assert candidate(obstacles = [0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 0]) == 7\n assert candidate(obstacles = [0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0]) == 8\n assert candidate(obstacles = [0, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 8\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 6\n assert candidate(obstacles = [0, 1, 3, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 18\n assert candidate(obstacles = [0, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 0, 3, 3, 3, 3, 3, 0]) == 1\n assert candidate(obstacles = [0, 1, 2, 0, 3, 0, 1, 2, 0, 3, 0, 1, 0]) == 4\n assert candidate(obstacles = [0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0]) == 2\n assert candidate(obstacles = [0, 3, 2, 1, 0, 2, 1, 0, 3, 1, 0, 2, 1, 0, 3, 1, 0, 2, 1, 0]) == 6\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 19\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 31\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 0, 3, 2, 1, 0, 2, 1, 3, 2, 1, 0]) == 11\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 2, 3, 2, 1, 0]) == 5\n assert candidate(obstacles = [0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 23\n assert candidate(obstacles = [0, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 0]) == 1\n assert candidate(obstacles = [0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0]) == 3\n assert candidate(obstacles = [0, 3, 2, 1, 2, 3, 1, 2, 3, 1, 0]) == 7\n assert candidate(obstacles = [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 3, 3, 3, 3, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]) == 1\n assert candidate(obstacles = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 0\n assert candidate(obstacles = [0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 0]) == 12\n assert candidate(obstacles = [0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 1, 2, 3, 0, 2, 1, 3, 0, 1, 2, 3, 0]) == 6\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 11\n assert candidate(obstacles = [0, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 17\n assert candidate(obstacles = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 7\n assert candidate(obstacles = [0, 3, 0, 1, 0, 3, 0, 1, 0, 3, 0, 1, 0, 3, 0]) == 0\n assert candidate(obstacles = [0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0]) == 3\n assert candidate(obstacles = [0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 2, 1, 0]) == 2\n assert candidate(obstacles = [0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 17\n assert candidate(obstacles = [0, 1, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 6\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 7\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0]) == 4\n assert candidate(obstacles = [0, 3, 2, 3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 9\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 9\n assert candidate(obstacles = [0, 3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(obstacles = [0, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 11\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 9\n assert candidate(obstacles = [0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0]) == 0\n", "comparison": "exact"}, "public_tests": ["[0,1,2,3,0]", "[0,1,1,3,3,0]", "[0,2,1,0,3,0]"], "hints": ["At a given point, there are only 3 possible states for where the frog can be.", "Check all the ways to move from one point to the next and update the minimum side jumps for each lane."], "metadata": {"canonical_parameter_names": ["obstacles"], "leetcode_dataset_entry_point": "Solution().minSideJumps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:54+00:00", "tests_total": 132, "tests_dropped": 11, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minSideJumps(self, obstacles: list[int]) -> int:", "container": "Solution", "callable": "minSideJumps", "parameters": [{"name": "obstacles", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1827, "task_id": "minimum-operations-to-make-the-array-increasing", "difficulty": "Easy", "problem_description": "You are given an integer array nums (0-indexed). In one operation, you can choose an element of the array and increment it by 1.\n\n- For example, if nums = [1,2,3], you can choose to increment nums[1] to make nums = [1,3,3].\n\nReturn the minimum number of operations needed to make nums strictly increasing.\n\nAn array nums is strictly increasing if nums[i] < nums[i+1] for all 0 <= i < nums.length - 1. An array of length 1 is trivially strictly increasing.\n\nExample 1:\n\nInput: nums = [1,1,1]\nOutput: 3\nExplanation: You can do the following operations:\n1) Increment nums[2], so nums becomes [1,1,2].\n2) Increment nums[1], so nums becomes [1,2,2].\n3) Increment nums[2], so nums becomes [1,2,3].\n\nExample 2:\n\nInput: nums = [1,5,2,4,1]\nOutput: 14\n\nExample 3:\n\nInput: nums = [8]\nOutput: 0\n\nConstraints:\n\n- 1 <= nums.length <= 5000\n- 1 <= nums[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [10000, 1, 1, 1, 1]) == 40006\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 25\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == 109\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 25\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 16\n assert candidate(nums = [8]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 1, 1]) == 3\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000]) == 10\n assert candidate(nums = [10000, 10000, 10000, 10000]) == 6\n assert candidate(nums = [1, 5, 2, 4, 1]) == 14\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 400\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 66\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 10\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 380\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4095\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 45045\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 380\n assert candidate(nums = [1, 100, 50, 200, 100, 300, 150, 400, 200, 500]) == 504\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 0\n assert candidate(nums = [1, 5, 10, 15, 20, 25, 20, 25, 30, 35]) == 8\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 90\n assert candidate(nums = [5, 6, 6, 10, 8, 11, 11, 11]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [100, 200, 300, 200, 100, 200, 300, 400, 500]) == 410\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15]) == 273\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == 380\n assert candidate(nums = [10, 9, 10, 8, 10, 7, 10, 6, 10, 5, 10, 4, 10, 3, 10, 2, 10, 1, 10]) == 216\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 870\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 300\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 6215\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 225\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(nums = [59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 1305\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 21, 20, 22, 21, 23, 22, 24, 23, 25]) == 35\n assert candidate(nums = [10000, 1000, 100, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 189064\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21]) == 18\n assert candidate(nums = [5000, 4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 4985, 4984, 4983, 4982, 4981, 4980, 4979, 4978, 4977, 4976, 4975, 4974, 4973, 4972, 4971, 4970]) == 930\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 375\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 480\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 100\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 25\n assert candidate(nums = [5, 6, 6, 8, 8, 9, 9, 10, 10, 10, 11]) == 18\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 3, 2, 1]) == 930\n assert candidate(nums = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == 55\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 172\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 65\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 189\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5]) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 36\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 81\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 80\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9]) == 486\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990]) == 110\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 24\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 5055\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 45045\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 4000, 3000, 2000, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 1, 1, 1, 1, 1, 1, 1]) == 89209\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 280\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 260\n assert candidate(nums = [2, 3, 3, 5, 5, 5, 6, 7, 8, 8, 9, 9, 9]) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11]) == 2\n assert candidate(nums = [1, 2, 10, 11, 10, 12, 11, 13, 12, 14]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 464\n assert candidate(nums = [10, 9, 10, 9, 10, 9, 10, 9, 10, 9]) == 50\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7]) == 133\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 212\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 189\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 7, 8, 9, 10]) == 17\n assert candidate(nums = [100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50]) == 690\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 99\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1128\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 22935\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 4140\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 171\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 14\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 100, 100, 100]) == 7278\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 72\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [100, 100, 100, 100, 100, 101, 101, 101, 101, 101, 102, 102, 102, 102, 102, 103, 103, 103, 103, 103, 104, 104, 104, 104, 104, 105, 105, 105, 105, 105]) == 360\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 155\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 75\n assert candidate(nums = [1, 1, 10, 10, 100, 100, 1000, 1000, 10000, 10000]) == 5\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6]) == 36\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 280\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 45\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 40\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 496\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 1325\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 99\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 180\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 495\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 105\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 252\n", "comparison": "exact"}, "public_tests": ["[1,1,1]", "[1,5,2,4,1]", "[8]"], "hints": ["nums[i+1] must be at least equal to nums[i] + 1.", "Think greedily. You don't have to increase nums[i+1] beyond nums[i]+1.", "Iterate on i and set nums[i] = max(nums[i-1]+1, nums[i]) ."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:58+00:00", "tests_total": 118, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minOperations(self, nums: List[int]) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "List[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1828, "task_id": "queries-on-number-of-points-inside-a-circle", "difficulty": "Medium", "problem_description": "You are given an array points where points[i] = [x_i, y_i] is the coordinates of the i^th point on a 2D plane. Multiple points can have the same coordinates.\n\nYou are also given an array queries where queries[j] = [x_j, y_j, r_j] describes a circle centered at (x_j, y_j) with a radius of r_j.\n\nFor each query queries[j], compute the number of points inside the j^th circle. Points on the border of the circle are considered inside.\n\nReturn an array answer, where answer[j] is the answer to the j^th query.\n\nExample 1:\n\nInput: points = [[1,3],[3,3],[5,3],[2,2]], queries = [[2,3,1],[4,3,1],[1,1,2]]\nOutput: [3,2,2]\nExplanation: The points and circles are shown above.\nqueries[0] is the green circle, queries[1] is the red circle, and queries[2] is the blue circle.\n\nExample 2:\n\nInput: points = [[1,1],[2,2],[3,3],[4,4],[5,5]], queries = [[1,2,2],[2,2,2],[4,3,2],[4,3,3]]\nOutput: [2,3,2,4]\nExplanation: The points and circles are shown above.\nqueries[0] is green, queries[1] is red, queries[2] is blue, and queries[3] is purple.\n\nConstraints:\n\n- 1 <= points.length <= 500\n- points[i].length == 2\n- 0 <= x_i, y_i <= 500\n- 1 <= queries.length <= 500\n- queries[j].length == 3\n- 0 <= x_j, y_j <= 500\n- 1 <= r_j <= 500\n- All coordinates are integers.\n\nFollow up: Could you find the answer for each query in better complexity than O(n)?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 2, 2], [2, 2, 2], [4, 3, 2], [4, 3, 3]]) == [2, 3, 2, 4]\n assert candidate(points = [[1, 3], [3, 3], [5, 3], [2, 2]],queries = [[2, 3, 1], [4, 3, 1], [1, 1, 2]]) == [3, 2, 2]\n assert candidate(points = [[50, 50], [50, 150], [50, 250], [150, 50], [150, 150], [150, 250], [250, 50], [250, 150], [250, 250], [50, 100], [100, 100], [150, 100], [200, 100], [250, 100], [100, 150], [150, 150], [200, 150], [250, 150], [100, 200], [150, 200], [200, 200], [250, 200]],queries = [[100, 100, 50], [150, 150, 75], [200, 200, 100]]) == [4, 10, 12]\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],queries = [[5, 5, 5], [2, 2, 3], [7, 7, 2], [0, 0, 10]]) == [7, 5, 3, 8]\n assert candidate(points = [[250, 250], [260, 260], [270, 270], [280, 280], [290, 290]],queries = [[250, 250, 10], [250, 250, 20], [250, 250, 30], [250, 250, 40], [250, 250, 50]]) == [1, 2, 3, 3, 4]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[100, 100, 150], [200, 200, 150], [300, 300, 150], [400, 400, 150], [500, 500, 150]]) == [2, 3, 3, 3, 2]\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25]],queries = [[1, 1, 2], [10, 10, 5], [20, 20, 8], [15, 15, 10]]) == [2, 7, 11, 15]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[150, 150, 100], [350, 350, 150], [250, 250, 200], [450, 450, 250]]) == [2, 2, 2, 3]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],queries = [[25, 25, 10], [15, 15, 5], [35, 35, 20]]) == [2, 0, 2]\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [20, 10], [20, 20], [20, 30], [20, 40], [20, 50], [30, 10], [30, 20], [30, 30], [30, 40], [30, 50]],queries = [[15, 15, 5], [15, 25, 5], [15, 35, 5], [15, 45, 5], [15, 55, 5], [25, 15, 5], [25, 25, 5], [25, 35, 5], [25, 45, 5], [25, 55, 5], [35, 15, 5], [35, 25, 5], [35, 35, 5], [35, 45, 5], [35, 55, 5]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(points = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450], [50, 450], [450, 50]],queries = [[100, 100, 50], [200, 200, 50], [300, 300, 50], [400, 400, 50], [50, 50, 100], [450, 450, 100]]) == [0, 0, 0, 0, 1, 1]\n assert candidate(points = [[250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [550, 550], [600, 600], [650, 650], [700, 700], [750, 750], [800, 800], [850, 850], [900, 900], [950, 950]],queries = [[500, 500, 100], [600, 600, 150], [750, 750, 200], [850, 850, 250]]) == [3, 5, 5, 6]\n assert candidate(points = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [150, 250], [250, 350]],queries = [[200, 300, 50], [300, 400, 100], [400, 500, 150], [500, 600, 200]]) == [1, 2, 3, 2]\n assert candidate(points = [[0, 0], [500, 500], [250, 250], [100, 100], [400, 400]],queries = [[250, 250, 200], [100, 100, 100], [400, 400, 150]]) == [1, 1, 2]\n assert candidate(points = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [110, 120]],queries = [[50, 50, 25], [70, 70, 30], [10, 10, 15], [90, 90, 20]]) == [2, 2, 1, 1]\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],queries = [[3, 3, 5], [6, 6, 10], [9, 9, 15]]) == [6, 13, 15]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],queries = [[5, 5, 15], [15, 15, 25], [25, 25, 35], [35, 35, 45], [45, 45, 55]]) == [1, 3, 4, 5, 5]\n assert candidate(points = [[25, 25], [26, 26], [27, 27], [28, 28], [29, 29]],queries = [[10, 10, 20], [20, 20, 20], [30, 30, 20], [40, 40, 20], [50, 50, 20]]) == [0, 5, 5, 4, 0]\n assert candidate(points = [[50, 100], [100, 150], [150, 200], [200, 250], [250, 300]],queries = [[75, 125, 50], [125, 175, 50], [175, 225, 50], [225, 275, 50], [275, 325, 50]]) == [2, 2, 2, 2, 1]\n assert candidate(points = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450]],queries = [[100, 100, 50], [100, 100, 100], [100, 100, 150], [100, 100, 200], [100, 100, 250]]) == [0, 2, 2, 2, 3]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [[15, 15, 10], [25, 25, 15], [35, 35, 20], [45, 45, 25], [55, 55, 30]]) == [2, 2, 2, 4, 4]\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [[5, 5, 5], [10, 10, 10], [15, 15, 15], [20, 20, 20], [25, 25, 25], [30, 30, 30], [35, 35, 35], [40, 40, 40], [45, 45, 45], [50, 50, 50]]) == [4, 7, 8, 7, 7, 6, 5, 4, 4, 3]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [[15, 15, 10], [25, 25, 15], [35, 35, 20], [45, 45, 25], [55, 55, 30], [65, 65, 35], [75, 75, 40], [85, 85, 45], [95, 95, 50], [105, 105, 55]]) == [2, 2, 2, 4, 4, 4, 6, 5, 5, 4]\n assert candidate(points = [[400, 400], [450, 450], [500, 500], [550, 550], [600, 600]],queries = [[400, 400, 100], [450, 450, 150], [500, 500, 200], [550, 550, 250], [600, 600, 300]]) == [2, 4, 5, 5, 5]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250]],queries = [[50, 50, 50], [100, 100, 50], [150, 150, 50], [200, 200, 50], [250, 250, 50]]) == [1, 1, 1, 1, 1]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [50, 50], [150, 150], [250, 250], [350, 350], [450, 450]],queries = [[250, 250, 100], [150, 150, 50], [450, 450, 150], [50, 50, 200]]) == [3, 1, 4, 3]\n assert candidate(points = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95]],queries = [[10, 10, 10], [20, 20, 15], [30, 30, 20], [40, 40, 25], [50, 50, 30], [60, 60, 35], [70, 70, 40], [80, 80, 45], [90, 90, 50], [100, 100, 55]]) == [2, 2, 2, 4, 4, 4, 6, 5, 5, 4]\n assert candidate(points = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450], [100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[200, 200, 100], [100, 100, 50], [300, 300, 150], [400, 400, 200], [500, 500, 250]]) == [3, 1, 5, 5, 4]\n assert candidate(points = [[0, 0], [500, 0], [0, 500], [500, 500], [250, 250], [125, 125], [375, 125], [125, 375], [375, 375]],queries = [[250, 250, 200], [0, 0, 150], [500, 500, 150], [125, 125, 50], [375, 375, 50], [250, 0, 100], [250, 500, 100]]) == [5, 1, 1, 1, 1, 0, 0]\n assert candidate(points = [[10, 10], [10, 30], [10, 50], [10, 70], [10, 90], [30, 10], [30, 30], [30, 50], [30, 70], [30, 90], [50, 10], [50, 30], [50, 50], [50, 70], [50, 90]],queries = [[20, 20, 20], [40, 40, 20], [60, 60, 20], [20, 60, 20], [60, 20, 20]]) == [4, 4, 2, 4, 2]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]],queries = [[250, 250, 100], [300, 300, 150], [350, 350, 200], [400, 400, 250], [450, 450, 300]]) == [3, 5, 5, 6, 6]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120], [130, 130], [140, 140], [150, 150]],queries = [[50, 50, 40], [100, 100, 50], [150, 150, 60], [20, 20, 30], [130, 130, 70]]) == [5, 7, 5, 4, 7]\n assert candidate(points = [[100, 100], [150, 100], [200, 100], [250, 100], [300, 100], [100, 150], [150, 150], [200, 150], [250, 150], [300, 150]],queries = [[150, 100, 50], [200, 150, 75], [100, 100, 100]]) == [4, 6, 5]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [100, 200], [200, 300], [300, 400], [400, 500], [500, 100]],queries = [[150, 150, 50], [250, 250, 75], [350, 350, 100], [450, 450, 125], [550, 550, 150], [150, 250, 60], [250, 350, 85], [350, 450, 110], [450, 550, 135], [550, 150, 160]]) == [0, 3, 3, 3, 1, 0, 3, 3, 2, 1]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120], [130, 130], [140, 140], [150, 150], [160, 160], [170, 170], [180, 180], [190, 190], [200, 200]],queries = [[100, 100, 50], [150, 150, 60], [200, 200, 70], [125, 125, 80]]) == [7, 9, 5, 12]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [50, 100], [100, 150], [150, 200], [200, 250], [250, 300], [300, 350], [350, 400], [400, 450], [450, 500], [500, 550]],queries = [[75, 75, 25], [125, 125, 50], [175, 175, 75], [225, 225, 100], [275, 275, 125], [325, 325, 150], [375, 375, 175], [425, 425, 200], [475, 475, 225], [525, 525, 250]]) == [0, 3, 3, 5, 7, 9, 9, 10, 9, 8]\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5, 5], [2, 2, 3], [8, 8, 4]]) == [7, 4, 5]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [50, 50], [150, 150], [250, 250], [350, 350], [450, 450]],queries = [[100, 100, 50], [300, 300, 100], [400, 400, 150], [200, 200, 200], [50, 50, 25]]) == [1, 3, 5, 5, 1]\n assert candidate(points = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110]],queries = [[15, 25, 5], [25, 35, 10], [35, 45, 15], [45, 55, 20], [55, 65, 25], [65, 75, 30], [75, 85, 35], [85, 95, 40], [95, 105, 45], [105, 115, 50]]) == [0, 2, 2, 2, 4, 4, 4, 5, 4, 4]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120], [130, 130], [140, 140], [150, 150]],queries = [[75, 75, 25], [50, 50, 30], [125, 125, 40], [100, 100, 50]]) == [4, 5, 6, 7]\n assert candidate(points = [[250, 250], [260, 260], [270, 270], [280, 280], [290, 290], [300, 300], [310, 310], [320, 320], [330, 330], [340, 340]],queries = [[270, 270, 20], [300, 300, 40], [320, 320, 60]]) == [3, 5, 7]\n assert candidate(points = [[25, 25], [26, 26], [27, 27], [28, 28], [29, 29], [30, 30], [31, 31], [32, 32], [33, 33], [34, 34]],queries = [[25, 25, 10], [25, 25, 20], [25, 25, 30], [25, 25, 40], [25, 25, 50], [25, 25, 60], [25, 25, 70], [25, 25, 80], [25, 25, 90], [25, 25, 100]]) == [8, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]],queries = [[25, 25, 30], [75, 75, 40], [125, 125, 50], [175, 175, 60], [225, 225, 70], [275, 275, 80], [325, 325, 90], [375, 375, 100], [425, 425, 110], [475, 475, 120]]) == [0, 2, 2, 2, 2, 2, 2, 2, 4, 3]\n assert candidate(points = [[10, 10], [10, 20], [20, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80]],queries = [[15, 15, 10], [50, 50, 30], [75, 75, 15], [45, 45, 25]]) == [4, 5, 2, 4]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]],queries = [[250, 250, 100], [50, 50, 50], [450, 450, 150], [300, 300, 200]]) == [3, 1, 4, 5]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]],queries = [[250, 250, 100], [100, 100, 50], [300, 300, 150], [400, 400, 200]]) == [3, 1, 5, 5]\n assert candidate(points = [[0, 0], [500, 500], [250, 250], [100, 400], [400, 100], [200, 300], [300, 200], [150, 350], [350, 150], [50, 450]],queries = [[250, 250, 200], [100, 100, 50], [400, 400, 150], [200, 200, 100]]) == [5, 0, 1, 3]\n assert candidate(points = [[50, 50], [100, 50], [150, 50], [200, 50], [250, 50], [300, 50], [350, 50], [400, 50], [450, 50], [500, 50]],queries = [[75, 50, 25], [125, 50, 25], [175, 50, 25], [225, 50, 25], [275, 50, 25], [325, 50, 25], [375, 50, 25], [425, 50, 25], [475, 50, 25]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(points = [[100, 100], [100, 200], [100, 300], [100, 400], [100, 500]],queries = [[100, 100, 50], [100, 200, 50], [100, 300, 50], [100, 400, 50], [100, 500, 50]]) == [1, 1, 1, 1, 1]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[250, 250, 150], [150, 150, 50], [350, 350, 100]]) == [2, 0, 2]\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]],queries = [[5, 5, 5], [10, 10, 10], [15, 15, 15]]) == [7, 15, 15]\n", "comparison": "exact"}, "public_tests": ["[[1,3],[3,3],[5,3],[2,2]]\n[[2,3,1],[4,3,1],[1,1,2]]", "[[1,1],[2,2],[3,3],[4,4],[5,5]]\n[[1,2,2],[2,2,2],[4,3,2],[4,3,3]]"], "hints": ["For a point to be inside a circle, the euclidean distance between it and the circle's center needs to be less than or equal to the radius.", "Brute force for each circle and iterate overall points and find those inside it."], "metadata": {"canonical_parameter_names": ["points", "queries"], "leetcode_dataset_entry_point": "Solution().countPoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:00+00:00", "tests_total": 51, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "math", "geometry"]}, "language": "python", "interface": {"raw_signature": "def countPoints(self, points: list[list[int]], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "countPoints", "parameters": [{"name": "points", "type": "list[list[int]]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1829, "task_id": "maximum-xor-for-each-query", "difficulty": "Medium", "problem_description": "You are given a sorted array nums of n non-negative integers and an integer maximumBit. You want to perform the following query n times:\n\n1. Find a non-negative integer k < 2^maximumBit such that nums[0] XOR nums[1] XOR ... XOR nums[nums.length-1] XOR k is maximized. k is the answer to the i^th query.\n2. Remove the last element from the current array nums.\n\nReturn an array answer, where answer[i] is the answer to the i^th query.\n\nExample 1:\n\nInput: nums = [0,1,1,3], maximumBit = 2\nOutput: [0,3,2,3]\nExplanation: The queries are answered as follows:\n1^st query: nums = [0,1,1,3], k = 0 since 0 XOR 1 XOR 1 XOR 3 XOR 0 = 3.\n2^nd query: nums = [0,1,1], k = 3 since 0 XOR 1 XOR 1 XOR 3 = 3.\n3^rd query: nums = [0,1], k = 2 since 0 XOR 1 XOR 2 = 3.\n4^th query: nums = [0], k = 3 since 0 XOR 3 = 3.\n\nExample 2:\n\nInput: nums = [2,3,4,7], maximumBit = 3\nOutput: [5,2,6,5]\nExplanation: The queries are answered as follows:\n1^st query: nums = [2,3,4,7], k = 5 since 2 XOR 3 XOR 4 XOR 7 XOR 5 = 7.\n2^nd query: nums = [2,3,4], k = 2 since 2 XOR 3 XOR 4 XOR 2 = 7.\n3^rd query: nums = [2,3], k = 6 since 2 XOR 3 XOR 6 = 7.\n4^th query: nums = [2], k = 5 since 2 XOR 5 = 7.\n\nExample 3:\n\nInput: nums = [0,1,2,2,5,7], maximumBit = 3\nOutput: [4,3,6,4,6,7]\n\nConstraints:\n\n- nums.length == n\n- 1 <= n <= 10^5\n- 1 <= maximumBit <= 20\n- 0 <= nums[i] < 2^maximumBit\n- nums is sorted in ascending order.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 3, 4, 7],maximumBit = 3) == [5, 2, 6, 5]\n assert candidate(nums = [0, 1, 1, 3],maximumBit = 2) == [0, 3, 2, 3]\n assert candidate(nums = [1, 2, 4, 8, 16],maximumBit = 5) == [0, 16, 24, 28, 30]\n assert candidate(nums = [31, 31, 31, 31, 31],maximumBit = 5) == [0, 31, 0, 31, 0]\n assert candidate(nums = [0, 1, 2, 2, 5, 7],maximumBit = 3) == [4, 3, 6, 4, 6, 7]\n assert candidate(nums = [1, 1, 1, 1, 1],maximumBit = 1) == [0, 1, 0, 1, 0]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109, 113, 117],maximumBit = 7) == [123, 14, 127, 18, 123, 30, 127, 34, 123, 46, 127, 50, 123, 62, 127, 66, 123, 78, 127, 82, 123, 94, 127, 98, 123, 110, 127, 114, 123, 126]\n assert candidate(nums = [1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575],maximumBit = 20) == [1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],maximumBit = 4) == [14, 7, 15, 8, 14, 11, 15, 12, 14, 15]\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],maximumBit = 14) == [5056, 14594, 9071, 13114, 14626, 16159, 15556, 16038, 16351, 16182, 16294, 16383, 16328, 16362, 16383, 16370, 16378, 16383, 16380, 16382]\n assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maximumBit = 1) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]\n assert candidate(nums = [0, 2, 6, 14, 30, 62, 126, 254, 510, 1022],maximumBit = 10) == [341, 683, 853, 939, 981, 1003, 1013, 1019, 1021, 1023]\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],maximumBit = 15) == [10922, 21845, 27306, 30037, 31402, 32085, 32426, 32597, 32682, 32725, 32746, 32757, 32762, 32765, 32766]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],maximumBit = 5) == [31, 0, 29, 6, 31, 8, 29, 14, 31, 16, 29, 22, 31, 24, 29, 30]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],maximumBit = 4) == [15, 15, 14, 12, 15, 11, 14, 8, 15, 7, 14, 4, 15, 3, 14, 0]\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50],maximumBit = 6) == [29, 47, 0, 44, 5, 35, 0, 32, 61, 39, 48, 36, 53, 59, 48, 56, 61]\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049],maximumBit = 16) == [18165, 41052, 60607, 62750, 64917, 65356, 65471, 65518, 65525, 65532]\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],maximumBit = 10) == [1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],maximumBit = 5) == [29, 14, 31, 16, 29, 22, 31, 24, 29, 30]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],maximumBit = 5) == [31, 0, 30, 3, 31, 4, 30, 7, 31, 8, 30, 11, 31, 12, 30, 15, 31, 16, 30, 19, 31, 20, 30, 23, 31, 24, 30, 27, 31, 28, 30]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],maximumBit = 6) == [61, 6, 63, 8, 61, 14, 63, 16, 61, 22, 63, 24, 61, 30, 63, 32, 61, 38, 63, 40, 61, 46, 63, 48, 61, 54, 63, 56, 61, 62]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],maximumBit = 20) == [0, 524288, 786432, 917504, 983040, 1015808, 1032192, 1040384, 1044480, 1046528, 1047552, 1048064, 1048320, 1048448, 1048512, 1048544, 1048560, 1048568, 1048572, 1048574]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],maximumBit = 5) == [11, 10, 8, 11, 15, 10, 12, 11, 3, 10, 0, 11, 7, 10, 4, 11, 27, 10, 24, 11]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],maximumBit = 3) == [7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2]\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38],maximumBit = 6) == [63, 25, 61, 31, 63, 33, 61, 39, 63, 41, 61, 47, 63, 49, 61, 55, 63, 57, 61, 63]\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58],maximumBit = 6) == [61, 7, 63, 9, 61, 15, 63, 17, 61, 23, 63, 25, 61, 31, 63, 33, 61, 39, 63, 41, 61, 47, 63, 49, 61, 55, 63, 57, 61, 63]\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400],maximumBit = 9) == [99, 499, 154, 478, 255, 511, 286, 474, 371, 483, 410, 510, 431, 495, 478, 506, 483, 499, 506, 510]\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576],maximumBit = 15) == [16382, 24574, 28670, 30718, 31742, 32254, 32510, 32638, 32702, 32734, 32750, 32758, 32762, 32764]\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765],maximumBit = 13) == [6403, 878, 4923, 6435, 7966, 7365, 7847, 8158, 7991, 8103, 8190, 8137, 8171, 8190, 8179, 8187, 8190, 8189, 8191, 8190]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],maximumBit = 11) == [0, 1024, 1536, 1792, 1920, 1984, 2016, 2032, 2040, 2044, 2046]\n assert candidate(nums = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015],maximumBit = 10) == [8, 1023, 7, 1022, 4, 1023, 3, 1022, 0]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],maximumBit = 4) == [15, 0, 14, 3, 15, 4, 14, 7, 15, 8, 14, 11, 15, 12, 14, 15]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],maximumBit = 7) == [63, 116, 50, 115, 79, 120, 74, 103, 79, 108, 114, 107, 127, 112, 122]\n assert candidate(nums = [12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288],maximumBit = 14) == [8187, 12283, 14331, 15355, 15867, 16123, 16251, 16315, 16347, 16363, 16371]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],maximumBit = 6) == [1, 61, 7, 63, 9, 61, 15, 63, 17, 61, 23, 63, 25, 61, 31, 63, 33, 61, 39, 63, 41, 61, 47, 63, 49, 61, 55, 63, 57, 61]\n assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maximumBit = 1) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maximumBit = 1) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35],maximumBit = 6) == [15, 44, 50, 43, 63, 48, 58]\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095],maximumBit = 13) == [5461, 6826, 7509, 7850, 8021, 8106, 8149, 8170, 8181, 8186, 8189, 8190]\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64],maximumBit = 7) == [63, 127, 71, 119, 95, 127, 103, 119]\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],maximumBit = 10) == [341, 682, 853, 938, 981, 1002, 1013, 1018, 1021, 1022]\n assert candidate(nums = [0, 2, 3, 5, 6, 8, 10, 12],maximumBit = 4) == [3, 15, 5, 13, 11, 14, 13, 15]\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18],maximumBit = 5) == [31, 13, 30, 14, 31, 17, 30, 18, 31, 21, 30, 22, 31, 25, 30, 26, 31, 29, 30, 30]\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127],maximumBit = 7) == [42, 85, 106, 117, 122, 125, 126]\n assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310],maximumBit = 10) == [990, 744, 1023, 775, 990, 868, 1023, 899, 990, 992]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],maximumBit = 1) == [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]\n assert candidate(nums = [7, 15, 23, 31, 39, 47, 55, 63, 71, 79, 87, 95],maximumBit = 7) == [127, 32, 119, 56, 127, 64, 119, 88, 127, 96, 119, 120]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],maximumBit = 8) == [183, 127, 193, 117, 223, 127, 233, 101, 231, 159, 241, 149, 207, 159, 217, 229, 215, 255, 225, 245]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],maximumBit = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],maximumBit = 10) == [0, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022]\n assert candidate(nums = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287],maximumBit = 20) == [699050, 873813, 961194, 1004885, 1026730, 1037653, 1043114, 1045845, 1047210, 1047893, 1048234, 1048405, 1048490, 1048533, 1048554, 1048565, 1048570, 1048573, 1048574, 1048575]\n assert candidate(nums = [0, 1, 3, 7, 15, 31, 63],maximumBit = 6) == [21, 42, 53, 58, 61, 62, 63]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],maximumBit = 4) == [15, 0, 14, 3, 15, 4, 14, 7, 15, 8, 14, 11, 15, 12, 14, 15]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],maximumBit = 20) == [0, 524288, 786432, 917504, 983040, 1015808, 1032192, 1040384, 1044480, 1046528, 1047552, 1048064, 1048320, 1048448, 1048512, 1048544, 1048560, 1048568, 1048572, 1048574]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],maximumBit = 6) == [14, 63, 16, 61, 22, 63, 24, 61, 30, 63, 32, 61, 38, 63, 40, 61, 46, 63, 48, 61, 54, 63, 56, 61, 62]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],maximumBit = 2) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],maximumBit = 10) == [1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],maximumBit = 7) == [113, 21, 79, 31, 89, 101, 87, 127, 97, 117]\n assert candidate(nums = [1, 3, 4, 7, 10, 12, 15, 19, 22],maximumBit = 5) == [18, 4, 23, 24, 20, 30, 25, 29, 30]\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],maximumBit = 10) == [1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0]\n assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120],maximumBit = 13) == [2041, 5113, 6649, 7417, 7801, 7993, 8089, 8137, 8161, 8181]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],maximumBit = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],maximumBit = 5) == [11, 31, 12, 30, 15, 31, 16, 30, 19, 31, 20, 30, 23, 31, 24, 30, 27, 31, 28, 30]\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],maximumBit = 7) == [26, 126, 47, 111, 94, 122, 99, 115, 122, 126]\n assert candidate(nums = [0, 1, 3, 7, 15, 31, 63, 127],maximumBit = 7) == [42, 85, 106, 117, 122, 125, 126, 127]\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],maximumBit = 3) == [7, 4, 7, 4, 7, 4, 6, 4, 6, 4, 6, 7, 6, 7, 6, 7, 7, 7, 7, 7]\n assert candidate(nums = [127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117],maximumBit = 7) == [11, 126, 8, 127, 7, 126, 4, 127, 3, 126, 0]\n assert candidate(nums = [5, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383],maximumBit = 14) == [5458, 10925, 13650, 15021, 15698, 16045, 16210, 16301, 16338, 16365, 16370, 16381, 16378]\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],maximumBit = 20) == [349525, 349524, 349527, 349520, 349535, 349504, 349567, 349440, 349695, 349184, 350207, 348160, 352255, 344064, 360447, 327680, 393215, 262144, 524287, 0]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],maximumBit = 10) == [0, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022]\n assert candidate(nums = [8, 10, 12, 14, 16, 18, 20, 22],maximumBit = 5) == [31, 9, 29, 15, 31, 17, 29, 23]\n assert candidate(nums = [2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575],maximumBit = 20) == [350207, 698368, 874495, 960512, 1005567, 1026048, 1038335, 1042432, 1046527, 1046528]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],maximumBit = 6) == [63, 3, 58, 12, 63, 15, 34, 8, 47, 11, 42, 52, 47, 55, 34, 48, 63, 51, 58, 60]\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],maximumBit = 8) == [255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0]\n assert candidate(nums = [0, 2, 3, 5, 8, 13, 21, 34, 55, 89],maximumBit = 7) == [39, 126, 73, 107, 126, 115, 123, 126, 125, 127]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],maximumBit = 6) == [63, 24, 61, 30, 63, 32, 61, 38, 63, 40, 61, 46, 63, 48, 61, 54, 63, 56, 61, 62]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1023],maximumBit = 10) == [1023, 0, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022]\n assert candidate(nums = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512],maximumBit = 10) == [0, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022, 1023]\n", "comparison": "exact"}, "public_tests": ["[0,1,1,3]\n2", "[2,3,4,7]\n3", "[0,1,2,2,5,7]\n3"], "hints": ["Note that the maximum possible XOR result is always 2^(maximumBit) - 1", "So the answer for a prefix is the XOR of that prefix XORed with 2^(maximumBit)-1"], "metadata": {"canonical_parameter_names": ["nums", "maximumBit"], "leetcode_dataset_entry_point": "Solution().getMaximumXor", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:03+00:00", "tests_total": 81, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "bit-manipulation", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def getMaximumXor(self, nums: list[int], maximumBit: int) -> list[int]:", "container": "Solution", "callable": "getMaximumXor", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "maximumBit", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1832, "task_id": "check-if-the-sentence-is-pangram", "difficulty": "Easy", "problem_description": "A pangram is a sentence where every letter of the English alphabet appears at least once.\n\nGiven a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise.\n\nExample 1:\n\nInput: sentence = \"thequickbrownfoxjumpsoverthelazydog\"\nOutput: true\nExplanation: sentence contains at least one of every letter of the English alphabet.\n\nExample 2:\n\nInput: sentence = \"leetcode\"\nOutput: false\n\nConstraints:\n\n- 1 <= sentence.length <= 1000\n- sentence consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(sentence = \"quickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"aaaaabbbbbccccc\") == False\n assert candidate(sentence = \"a\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogandmorelettersjusttoextendthelengthofthesentenceevenmorejustformeasurements\") == True\n assert candidate(sentence = \"hellothere\") == False\n assert candidate(sentence = \"hello\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazy\") == False\n assert candidate(sentence = \"abcdefghijjklmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzzzzz\") == True\n assert candidate(sentence = \"leetcode\") == False\n assert candidate(sentence = \"thisisaverylongsentencebutnotapangram\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzabc\") == True\n assert candidate(sentence = \"mississippi\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelaz\") == False\n assert candidate(sentence = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(sentence = \"abcdefghijlkmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogandthenomeofthezebra\") == True\n assert candidate(sentence = \"aquickmovementsoftheenemywilljeopardizethesecurityofthefort\") == False\n assert candidate(sentence = \"neverjumpoveraslydogquicklyasmyfastcat\") == False\n assert candidate(sentence = \"jumpedoverthelazybrownfoxquickly\") == False\n assert candidate(sentence = \"thisisaverylongsentencethatwantsyoumakesurethatispangram\") == False\n assert candidate(sentence = \"everygoodboydoesfine\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthefly\") == False\n assert candidate(sentence = \"thefoxjumpedoveralazydogandquicklymunchedberries\") == False\n assert candidate(sentence = \"aquickmovofjumpsbxngthevlackdwarf\") == False\n assert candidate(sentence = \"abcdefghijklnopqrstuvwxyz\") == False\n assert candidate(sentence = \"sphinxofblackquartzjudgemyvowels\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydozzzzzzzzzz\") == False\n assert candidate(sentence = \"aabbbcccdddeeefffggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == True\n assert candidate(sentence = \"thisisaverylongsentencethatshouldcontainalllettersquickly\") == False\n assert candidate(sentence = \"thebrownfoxjumpsovertheleazydog\") == False\n assert candidate(sentence = \"phinxofquizzingjudgesbringsmywonder\") == False\n assert candidate(sentence = \"packmyboxwithfivedozenliquorjugsquicklyandjudgeeachvowel\") == True\n assert candidate(sentence = \"vowelsaeiouyzqjfdxhcntrbplsmkgw\") == True\n assert candidate(sentence = \"jumpsquickonthisbrownfox\") == False\n assert candidate(sentence = \"fivexwiseguysjumpquicklyonthiszanyboat\") == False\n assert candidate(sentence = \"aquickmovewiththiszestyjuicebringsvexflation\") == False\n assert candidate(sentence = \"quickbrownfoxjumpsoverthelazydogquickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"pythonprogramminglanguage\") == False\n assert candidate(sentence = \"xylophonesarefunbutquickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogy\") == True\n assert candidate(sentence = \"qwertypoiuytrewqasdfghjklzxcvbnmasdfghjklzxcvbnmqwertyuiopcvbnm\") == True\n assert candidate(sentence = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"thesixfatfingersjumpquicklyonthisverylazydog\") == False\n assert candidate(sentence = \"jumpsfoxoverthelazydogquickb\") == False\n assert candidate(sentence = \"sixjovialfellowshavequicklyzippedanddrunkmanybeers\") == False\n assert candidate(sentence = \"abacaxypromiseyouanelephantwhoxylophones\") == False\n assert candidate(sentence = \"jumpedoverthelazydogthequickbrownfox\") == False\n assert candidate(sentence = \"sphinxofblackquartzjudgemyvexzwift\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpedoverthelazydogquickly\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxy\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzz\") == True\n assert candidate(sentence = \"foxjumpsoverthelazydogquickbrown\") == True\n assert candidate(sentence = \"thisquestionaboutpangramsissomewhatredundant\") == False\n assert candidate(sentence = \"aquickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"jumpedoverthelazydogquickbrownfox\") == False\n assert candidate(sentence = \"aquickmovingtonafleetofsixgreyhounds\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogg\") == True\n assert candidate(sentence = \"howvexinglyquickdaftzebrasjump\") == True\n assert candidate(sentence = \"quickbrownfoxjumpsoverthelazydogzzzzzzzzzz\") == True\n assert candidate(sentence = \"aquickmovementsofthejaguarzephyr\") == False\n assert candidate(sentence = \"quicklyjudginghowvexingzebraflowscanbeverytricky\") == False\n assert candidate(sentence = \"aquickbrownfoxjumpsoverthelazydogandbackagain\") == True\n assert candidate(sentence = \"abcdefghijklnopqrstuvwxyzabcdefghijklnopqrstuvwxyz\") == False\n assert candidate(sentence = \"jellyoftheplumlovesmeandthemonkeyrinsesupwithgrapejuicequickly\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(sentence = \"thebrownfoxjumpedoveralazylazydog\") == False\n assert candidate(sentence = \"packmyboxwithfivedozenliquorjugs\") == True\n assert candidate(sentence = \"foxjumpsoverthelazydogquickbrownzzzzzzzzzz\") == True\n assert candidate(sentence = \"althoughsomehumansareabsolutelyastonishing\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"jovialwaltzsexemplifiesquickbymyflyfriend\") == False\n assert candidate(sentence = \"aquickbrownfoxjumpsoverthelazydogs\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydo\") == False\n assert candidate(sentence = \"abcdefghjklmnopqrstuvwxyz\") == False\n assert candidate(sentence = \"veryfewlazydogslikejumpingoverthebigbrownfox\") == False\n assert candidate(sentence = \"therearemanysmallpacksofdifferentbooksinthelibrary\") == False\n assert candidate(sentence = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(sentence = \"jimquicklyzippedvexedfowlsbymyplushog\") == False\n assert candidate(sentence = \"quickbrownfoxjumpsoverthelazydogs\") == True\n assert candidate(sentence = \"abcdefghijkllllmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogandmore\") == True\n assert candidate(sentence = \"everygoodboydoesfinejustkickslovingmonkeysnearpianoquicksly\") == False\n assert candidate(sentence = \"pqrsghijklmnabcdefwxyzotuvcd\") == True\n assert candidate(sentence = \"pangramsarefunnywordsusedinyogamatclasses\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpedoverthelazydogandthenranoff\") == False\n assert candidate(sentence = \"fourxsixtwoseveneleveneightfivenineninetwozero\") == False\n assert candidate(sentence = \"abracadabracabracadabra\") == False\n assert candidate(sentence = \"mjklqrswxzytfpuhncideaoxbgvlozmt\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogandcat\") == True\n assert candidate(sentence = \"thisisaverylongstringsentencethatwillnotbepangram\") == False\n assert candidate(sentence = \"quovadis\") == False\n assert candidate(sentence = \"thisisaverylongsentencethatjustmightcontainallthelettersofthealphabet\") == False\n assert candidate(sentence = \"everygoodboydoesfineandzestfullyjumpoverlazysnails\") == False\n", "comparison": "exact"}, "public_tests": ["\"thequickbrownfoxjumpsoverthelazydog\"", "\"leetcode\""], "hints": ["Iterate over the string and mark each character as found (using a boolean array, bitmask, or any other similar way).", "Check if the number of found characters equals the alphabet length."], "metadata": {"canonical_parameter_names": ["sentence"], "leetcode_dataset_entry_point": "Solution().checkIfPangram", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:05+00:00", "tests_total": 98, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def checkIfPangram(self, sentence: str) -> bool:", "container": "Solution", "callable": "checkIfPangram", "parameters": [{"name": "sentence", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1833, "task_id": "maximum-ice-cream-bars", "difficulty": "Medium", "problem_description": "It is a sweltering summer day, and a boy wants to buy some ice cream bars.\n\nAt the store, there are n ice cream bars. You are given an array costs of length n, where costs[i] is the price of the i^th ice cream bar in coins. The boy initially has coins coins to spend, and he wants to buy as many ice cream bars as possible.\n\nNote: The boy can buy the ice cream bars in any order.\n\nReturn the maximum number of ice cream bars the boy can buy with coins coins.\n\nYou must solve the problem by counting sort.\n\nExample 1:\n\nInput: costs = [1,3,2,4,1], coins = 7\nOutput: 4\nExplanation: The boy can buy ice cream bars at indices 0,1,2,4 for a total price of 1 + 3 + 2 + 1 = 7.\n\nExample 2:\n\nInput: costs = [10,6,8,7,7,8], coins = 5\nOutput: 0\nExplanation: The boy cannot afford any of the ice cream bars.\n\nExample 3:\n\nInput: costs = [1,6,3,1,2,5], coins = 20\nOutput: 6\nExplanation: The boy can buy all the ice cream bars for a total price of 1 + 6 + 3 + 1 + 2 + 5 = 18.\n\nConstraints:\n\n- costs.length == n\n- 1 <= n <= 10^5\n- 1 <= costs[i] <= 10^5\n- 1 <= coins <= 10^8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(costs = [1, 3, 2, 4, 1],coins = 7) == 4\n assert candidate(costs = [10, 6, 8, 7, 7, 8],coins = 5) == 0\n assert candidate(costs = [1],coins = 1) == 1\n assert candidate(costs = [1, 6, 3, 1, 2, 5],coins = 20) == 6\n assert candidate(costs = [100000],coins = 100000) == 1\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 10) == 4\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 55) == 10\n assert candidate(costs = [5, 5, 5, 5, 5],coins = 15) == 3\n assert candidate(costs = [10, 20, 30, 40, 50],coins = 100) == 4\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 15) == 5\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 50) == 9\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 19) == 19\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 5) == 5\n assert candidate(costs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],coins = 15) == 6\n assert candidate(costs = [5, 4, 2, 3, 1, 6, 7, 8, 9, 10],coins = 15) == 5\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],coins = 250) == 6\n assert candidate(costs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],coins = 25) == 12\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],coins = 210) == 20\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],coins = 55) == 2\n assert candidate(costs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],coins = 40) == 8\n assert candidate(costs = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],coins = 100) == 13\n assert candidate(costs = [100000, 99999, 99998, 99997, 99996, 99995],coins = 599985) == 6\n assert candidate(costs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],coins = 50) == 13\n assert candidate(costs = [50, 25, 75, 100, 200, 300, 400, 500, 600, 700],coins = 2000) == 8\n assert candidate(costs = [1, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],coins = 800) == 12\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [5, 1, 4, 2, 3],coins = 10) == 4\n assert candidate(costs = [1000, 500, 200, 100, 50, 20, 10, 5, 2, 1],coins = 1000) == 9\n assert candidate(costs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],coins = 8000) == 12\n assert candidate(costs = [5, 7, 8, 6, 3, 2, 1, 4, 9, 10],coins = 20) == 5\n assert candidate(costs = [50, 20, 30, 10, 40],coins = 100) == 4\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],coins = 1000) == 10\n assert candidate(costs = [100000, 100000, 100000, 100000, 100000],coins = 500000) == 5\n assert candidate(costs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],coins = 50) == 5\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],coins = 300) == 24\n assert candidate(costs = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],coins = 25) == 6\n assert candidate(costs = [99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1],coins = 5) == 5\n assert candidate(costs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],coins = 20) == 4\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 50) == 9\n assert candidate(costs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],coins = 50) == 10\n assert candidate(costs = [9, 8, 7, 6, 5, 4, 3, 2, 1],coins = 25) == 6\n assert candidate(costs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],coins = 55) == 10\n assert candidate(costs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],coins = 1500) == 5\n assert candidate(costs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],coins = 15) == 7\n assert candidate(costs = [5, 1, 3, 1, 2, 5, 3, 1, 2, 5],coins = 15) == 7\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],coins = 55) == 2\n assert candidate(costs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],coins = 20) == 4\n assert candidate(costs = [1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4],coins = 10) == 7\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],coins = 550) == 10\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],coins = 190) == 19\n assert candidate(costs = [3, 1, 2, 1, 4, 2, 2, 3, 2, 1, 2, 3, 4, 1, 2],coins = 20) == 11\n assert candidate(costs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],coins = 300) == 10\n assert candidate(costs = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31],coins = 100) == 8\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],coins = 1000) == 13\n assert candidate(costs = [100000, 1, 100000, 1, 100000, 1, 100000],coins = 100003) == 4\n assert candidate(costs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],coins = 100) == 10\n assert candidate(costs = [5, 1, 3, 2, 4, 1],coins = 10) == 4\n assert candidate(costs = [5, 3, 3, 2, 7, 8, 9],coins = 15) == 4\n assert candidate(costs = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],coins = 500000) == 9\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],coins = 100) == 13\n assert candidate(costs = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],coins = 1000000) == 10\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 5) == 5\n assert candidate(costs = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],coins = 150000) == 9\n assert candidate(costs = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],coins = 250) == 18\n assert candidate(costs = [5, 2, 3, 1, 4, 2, 3, 5, 1, 2],coins = 15) == 7\n assert candidate(costs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],coins = 2500) == 6\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 30) == 7\n assert candidate(costs = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],coins = 60) == 10\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],coins = 100) == 13\n", "comparison": "exact"}, "public_tests": ["[1,3,2,4,1]\n7", "[10,6,8,7,7,8]\n5", "[1,6,3,1,2,5]\n20"], "hints": ["It is always optimal to buy the least expensive ice cream bar first.", "Sort the prices so that the cheapest ice cream bar comes first."], "metadata": {"canonical_parameter_names": ["costs", "coins"], "leetcode_dataset_entry_point": "Solution().maxIceCream", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:07+00:00", "tests_total": 75, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "greedy", "sorting", "counting-sort"]}, "language": "python", "interface": {"raw_signature": "def maxIceCream(self, costs: list[int], coins: int) -> int:", "container": "Solution", "callable": "maxIceCream", "parameters": [{"name": "costs", "type": "list[int]"}, {"name": "coins", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1834, "task_id": "single-threaded-cpu", "difficulty": "Medium", "problem_description": "You are given n tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTime_i, processingTime_i] means that the i^th task will be available to process at enqueueTime_i and will take processingTime_ito finish processing.\n\nYou have a single-threaded CPU that can process at most one task at a time and will act in the following way:\n\n- If the CPU is idle and there are no available tasks to process, the CPU remains idle.\n- If the CPU is idle and there are available tasks, the CPU will choose the one with the shortest processing time. If multiple tasks have the same shortest processing time, it will choose the task with the smallest index.\n- Once a task is started, the CPU will process the entire task without stopping.\n- The CPU can finish a task then start a new one instantly.\n\nReturn the order in which the CPU will process the tasks.\n\nExample 1:\n\nInput: tasks = [[1,2],[2,4],[3,2],[4,1]]\nOutput: [0,2,3,1]\nExplanation: The events go as follows:\n- At time = 1, task 0 is available to process. Available tasks = {0}.\n- Also at time = 1, the idle CPU starts processing task 0. Available tasks = {}.\n- At time = 2, task 1 is available to process. Available tasks = {1}.\n- At time = 3, task 2 is available to process. Available tasks = {1, 2}.\n- Also at time = 3, the CPU finishes task 0 and starts processing task 2 as it is the shortest. Available tasks = {1}.\n- At time = 4, task 3 is available to process. Available tasks = {1, 3}.\n- At time = 5, the CPU finishes task 2 and starts processing task 3 as it is the shortest. Available tasks = {1}.\n- At time = 6, the CPU finishes task 3 and starts processing task 1. Available tasks = {}.\n- At time = 10, the CPU finishes task 1 and becomes idle.\n\nExample 2:\n\nInput: tasks = [[7,10],[7,12],[7,5],[7,4],[7,2]]\nOutput: [4,3,2,0,1]\nExplanation: The events go as follows:\n- At time = 7, all the tasks become available. Available tasks = {0,1,2,3,4}.\n- Also at time = 7, the idle CPU starts processing task 4. Available tasks = {0,1,2,3}.\n- At time = 9, the CPU finishes task 4 and starts processing task 3. Available tasks = {0,1,2}.\n- At time = 13, the CPU finishes task 3 and starts processing task 2. Available tasks = {0,1}.\n- At time = 18, the CPU finishes task 2 and starts processing task 0. Available tasks = {1}.\n- At time = 28, the CPU finishes task 0 and starts processing task 1. Available tasks = {}.\n- At time = 40, the CPU finishes task 1 and becomes idle.\n\nConstraints:\n\n- 1 <= tasks.length <= 10^5\n- tasks[i] = [enqueueTime_i, processingTime_i]\n- 1 <= enqueueTime_i, processingTime_i <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [[1, 3], [2, 2], [3, 1], [4, 4]]) == [0, 2, 1, 3]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 3], [2, 5], [8, 2], [7, 4], [10, 2]]) == [0, 1, 2, 4, 3]\n assert candidate(tasks = [[1, 3], [2, 2], [3, 1], [4, 4], [5, 5]]) == [0, 2, 1, 3, 4]\n assert candidate(tasks = [[3, 1], [1, 2], [2, 4], [1, 4]]) == [1, 0, 2, 3]\n assert candidate(tasks = [[5, 2], [3, 1], [1, 4], [4, 3], [2, 5]]) == [2, 1, 0, 3, 4]\n assert candidate(tasks = [[5, 5], [8, 2], [1, 9], [3, 8]]) == [2, 1, 0, 3]\n assert candidate(tasks = [[9, 3], [3, 7], [8, 10], [4, 3], [5, 3]]) == [1, 0, 3, 4, 2]\n assert candidate(tasks = [[2, 1], [3, 1], [1, 2], [7, 3], [8, 4], [9, 5]]) == [2, 0, 1, 3, 4, 5]\n assert candidate(tasks = [[19, 13], [16, 9], [21, 10], [32, 25], [37, 4], [49, 24], [2, 15], [38, 41], [37, 34], [33, 6], [45, 4], [18, 18], [46, 39], [12, 24]]) == [6, 1, 2, 9, 4, 10, 0, 11, 5, 13, 3, 8, 12, 7]\n assert candidate(tasks = [[5, 2], [7, 2], [9, 4], [6, 3], [8, 2]]) == [0, 1, 4, 3, 2]\n assert candidate(tasks = [[7, 10], [7, 12], [7, 5], [7, 4], [7, 2]]) == [4, 3, 2, 0, 1]\n assert candidate(tasks = [[5, 2], [1, 2], [3, 1], [2, 1]]) == [1, 2, 3, 0]\n assert candidate(tasks = [[1, 2], [2, 4], [3, 2], [4, 1]]) == [0, 2, 3, 1]\n assert candidate(tasks = [[1, 3], [2, 5], [8, 2], [7, 4], [6, 1], [5, 6], [4, 3], [3, 2], [9, 5], [10, 4]]) == [0, 7, 4, 6, 2, 3, 9, 1, 8, 5]\n assert candidate(tasks = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 10]]) == [0, 8, 7, 6, 5, 4, 3, 2, 1, 9]\n assert candidate(tasks = [[100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[1, 2], [2, 3], [4, 5], [8, 9], [16, 17], [32, 33], [64, 65], [128, 129], [256, 257], [512, 513], [1024, 1025], [2048, 2049], [4096, 4097], [8192, 8193], [16384, 16385]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 100], [101, 1], [201, 10], [301, 100], [401, 10], [501, 1], [601, 100], [701, 10], [801, 1], [901, 100]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [1, 3], [2, 4], [1, 5], [2, 6], [1, 7], [2, 8], [1, 9], [2, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [0, 10, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19]\n assert candidate(tasks = [[1, 1000000000], [2, 1000000000], [3, 1000000000], [4, 1000000000], [5, 1000000000]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 100], [200, 1], [300, 1], [400, 1], [500, 1], [600, 1], [700, 1], [800, 1], [900, 1], [1000, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 1], [7, 2], [8, 3], [9, 4], [10, 5]]) == [0, 4, 5, 3, 6, 2, 7, 1, 8, 9]\n assert candidate(tasks = [[1, 10], [10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[2, 5], [1, 3], [2, 2], [4, 1], [5, 10], [7, 1], [8, 2], [9, 3], [10, 4]]) == [1, 3, 2, 5, 6, 7, 8, 0, 4]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]]) == [5, 6, 3, 4, 10, 2, 7, 11, 15, 1, 8, 12, 16, 0, 9, 13, 17, 14, 18, 19]\n assert candidate(tasks = [[1, 10], [10, 1], [100, 1], [1000, 1], [10000, 1], [100000, 1], [1000000, 1], [10000000, 1], [100000000, 1], [1000000000, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[10, 100], [100, 10], [200, 20], [300, 30], [400, 40], [500, 50], [600, 60], [700, 70], [800, 80], [900, 90]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 5], [1, 4], [1, 3], [1, 2], [1, 1], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]]) == [4, 5, 3, 6, 2, 7, 1, 8, 0, 9]\n assert candidate(tasks = [[1, 3], [1, 2], [1, 1], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [2, 1, 0, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [1, 2], [1, 2], [2, 1], [2, 1], [2, 1], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5]]) == [0, 3, 4, 5, 1, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 1], [1000000000, 1000000000], [2, 2], [999999999, 999999999], [3, 3], [999999998, 999999998], [4, 4], [999999997, 999999997], [5, 5], [999999996, 999999996]]) == [0, 2, 4, 6, 8, 9, 7, 5, 3, 1]\n assert candidate(tasks = [[10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [2, 1], [3, 2], [4, 1], [5, 2], [6, 1], [7, 2], [8, 1], [9, 2], [10, 1], [1, 2], [2, 1], [3, 2], [4, 1], [5, 2], [6, 1], [7, 2], [8, 1], [9, 2], [10, 1]]) == [0, 1, 3, 11, 5, 13, 7, 15, 9, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18]\n assert candidate(tasks = [[1, 1], [10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[1000000000, 1], [1000000000, 2], [1000000000, 3], [1000000000, 4], [1000000000, 5]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [1, 2], [1, 4], [1, 8], [1, 16], [1, 32], [1, 64], [1, 128], [1, 256], [1, 512]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]\n assert candidate(tasks = [[5, 10], [10, 5], [15, 1], [20, 2], [25, 8], [30, 3], [35, 4], [40, 9], [45, 6], [50, 7]]) == [0, 2, 1, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1000000000], [2, 1000000000], [3, 1000000000], [4, 1000000000], [5, 1000000000], [6, 1000000000], [7, 1000000000], [8, 1000000000], [9, 1000000000], [10, 1000000000]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [1000000000, 1], [999999999, 2], [2, 2], [999999998, 3], [3, 3], [999999997, 4], [4, 4], [999999996, 5], [5, 5]]) == [0, 3, 5, 7, 9, 8, 1, 2, 4, 6]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(tasks = [[1, 2], [1, 3], [2, 1], [2, 2], [3, 3], [3, 4], [4, 1], [4, 2], [5, 3], [5, 4], [6, 1], [6, 2], [7, 3], [7, 4], [8, 1], [8, 2], [9, 3], [9, 4], [10, 1], [10, 2]]) == [0, 2, 6, 3, 10, 14, 7, 18, 11, 15, 19, 1, 4, 8, 12, 16, 5, 9, 13, 17]\n assert candidate(tasks = [[1, 100], [2, 50], [3, 25], [4, 12], [5, 6], [6, 3], [7, 2], [8, 1]]) == [0, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[1, 20], [5, 10], [10, 5], [15, 2], [20, 1], [25, 1], [30, 1], [35, 1], [40, 1], [45, 1]]) == [0, 4, 3, 2, 5, 6, 1, 7, 8, 9]\n assert candidate(tasks = [[100, 100], [150, 100], [200, 100], [250, 100], [300, 100], [350, 100], [400, 100], [450, 100], [500, 100]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 1], [3, 1], [5, 1], [7, 1], [9, 1], [11, 1], [13, 1], [15, 1], [17, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [4, 1]]) == [0, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[2, 1], [4, 1], [6, 1], [8, 1], [10, 1], [1, 2], [3, 2], [5, 2], [7, 2], [9, 2], [11, 2], [13, 2], [15, 2], [17, 2], [19, 2]]) == [5, 0, 1, 6, 2, 3, 7, 4, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10]]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(tasks = [[10, 10], [15, 5], [20, 1], [25, 2], [30, 3], [35, 4], [40, 5], [45, 6], [50, 7]]) == [0, 2, 1, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 100], [10, 100], [20, 100], [30, 100], [40, 100], [50, 100], [60, 100], [70, 100], [80, 100], [90, 100]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(tasks = [[1, 5], [3, 3], [5, 1], [7, 2], [9, 4], [11, 6], [13, 5], [15, 3], [17, 2], [19, 1]]) == [0, 2, 3, 1, 4, 7, 9, 8, 6, 5]\n assert candidate(tasks = [[1000000000, 1], [1000000000, 1], [1000000000, 1], [1000000000, 1], [1000000000, 1]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 10], [11, 1], [21, 1], [31, 1], [41, 1], [51, 1], [61, 1], [71, 1], [81, 1], [91, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[10, 1], [11, 2], [12, 3], [13, 4], [14, 5], [15, 6], [16, 7], [17, 8], [18, 9], [19, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1]]) == [0, 5, 6, 7, 8, 9, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 2], [10, 3], [20, 4], [30, 5], [40, 6], [50, 7], [60, 8], [70, 9], [80, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 1], [1, 10], [1, 100], [1, 1000], [1, 10000], [1, 100000], [1, 1000000], [1, 10000000], [1, 100000000], [1, 1000000000]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [3, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(tasks = [[1, 2], [3, 1], [5, 3], [7, 4], [9, 2], [11, 1], [13, 5], [15, 3], [17, 2], [19, 1]]) == [0, 1, 2, 3, 5, 4, 7, 8, 9, 6]\n assert candidate(tasks = [[9, 5], [1, 5], [8, 5], [3, 5], [2, 5], [4, 5], [6, 5], [7, 5], [10, 5], [11, 5]]) == [1, 3, 0, 2, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [2, 1], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8], [100000000, 9], [1000000000, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[10, 3], [20, 2], [30, 1], [40, 4], [50, 5], [60, 6]]) == [0, 1, 2, 3, 4, 5]\n assert candidate(tasks = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [2, 2], [4, 4], [6, 6], [8, 8], [10, 10]]) == [0, 5, 1, 6, 2, 7, 3, 8, 4, 9]\n assert candidate(tasks = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [0, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1], [2, 10], [2, 9], [2, 8], [2, 7], [2, 6], [2, 5], [2, 4], [2, 3], [2, 2], [2, 1]]) == [9, 19, 8, 18, 7, 17, 6, 16, 5, 15, 4, 14, 3, 13, 2, 12, 1, 11, 0, 10]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [2, 4], [3, 8], [4, 16], [5, 32], [6, 64], [7, 128], [8, 256], [9, 512], [10, 1024]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(tasks = [[1, 10], [10, 10], [20, 10], [30, 10], [40, 10], [50, 10]]) == [0, 1, 2, 3, 4, 5]\n assert candidate(tasks = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]]) == [0, 1, 3, 5, 7, 9, 2, 4, 6, 8]\n assert candidate(tasks = [[10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2]]) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]\n assert candidate(tasks = [[1, 1], [1, 1], [1, 2], [1, 2], [1, 3], [1, 3], [1, 4], [1, 4], [1, 5], [1, 5]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(tasks = [[1, 10], [2, 5], [3, 15], [4, 20], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [0, 4, 5, 6, 7, 8, 9, 1, 2, 3]\n assert candidate(tasks = [[1, 2], [3, 3], [5, 2], [7, 1], [9, 2], [11, 3], [13, 1], [15, 2], [17, 3], [19, 1], [21, 2], [23, 3], [25, 1], [27, 2], [29, 3]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 10], [5, 1], [3, 2], [2, 3], [7, 4], [6, 5], [8, 6], [9, 7], [10, 8]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 1000000000], [2, 900000000], [3, 800000000], [4, 700000000], [5, 600000000], [6, 500000000], [7, 400000000], [8, 300000000], [9, 200000000], [10, 100000000]]) == [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[10, 10], [20, 5], [30, 15], [40, 1], [50, 20]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 1], [2, 1], [1, 2], [2, 2], [1, 3], [2, 3], [1, 4], [2, 4], [1, 5], [2, 5]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1]]) == [8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(tasks = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [11, 10], [12, 9], [13, 8], [14, 7], [15, 6], [16, 5], [17, 4], [18, 3], [19, 2], [20, 1]]) == [0, 9, 8, 7, 6, 19, 18, 17, 16, 5, 15, 4, 14, 3, 13, 2, 12, 1, 11, 10]\n", "comparison": "exact"}, "public_tests": ["[[1,2],[2,4],[3,2],[4,1]]", "[[7,10],[7,12],[7,5],[7,4],[7,2]]"], "hints": ["To simulate the problem we first need to note that if at any point in time there are no enqueued tasks we need to wait to the smallest enqueue time of a non-processed element", "We need a data structure like a min-heap to support choosing the task with the smallest processing time from all the enqueued tasks"], "metadata": {"canonical_parameter_names": ["tasks"], "leetcode_dataset_entry_point": "Solution().getOrder", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:10+00:00", "tests_total": 109, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def getOrder(self, tasks: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "getOrder", "parameters": [{"name": "tasks", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1835, "task_id": "find-xor-sum-of-all-pairs-bitwise-and", "difficulty": "Hard", "problem_description": "The XOR sum of a list is the bitwise XOR of all its elements. If the list only contains one element, then its XOR sum will be equal to this element.\n\n- For example, the XOR sum of [1,2,3,4] is equal to 1 XOR 2 XOR 3 XOR 4 = 4, and the XOR sum of [3] is equal to 3.\n\nYou are given two 0-indexed arrays arr1 and arr2 that consist only of non-negative integers.\n\nConsider the list containing the result of arr1[i] AND arr2[j] (bitwise AND) for every (i, j) pair where 0 <= i < arr1.length and 0 <= j < arr2.length.\n\nReturn the XOR sum of the aforementioned list.\n\nExample 1:\n\nInput: arr1 = [1,2,3], arr2 = [6,5]\nOutput: 0\nExplanation: The list = [1 AND 6, 1 AND 5, 2 AND 6, 2 AND 5, 3 AND 6, 3 AND 5] = [0,1,2,0,2,1].\nThe XOR sum = 0 XOR 1 XOR 2 XOR 0 XOR 2 XOR 1 = 0.\n\nExample 2:\n\nInput: arr1 = [12], arr2 = [4]\nOutput: 4\nExplanation: The list = [12 AND 4] = [4]. The XOR sum = 4.\n\nConstraints:\n\n- 1 <= arr1.length, arr2.length <= 10^5\n- 0 <= arr1[i], arr2[j] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr1 = [1, 2, 3],arr2 = [6, 5]) == 0\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1]) == 1\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10]) == 0\n assert candidate(arr1 = [1000000000],arr2 = [1000000000]) == 1000000000\n assert candidate(arr1 = [0, 0, 0],arr2 = [0, 0, 0]) == 0\n assert candidate(arr1 = [255, 128, 64],arr2 = [32, 16, 8]) == 56\n assert candidate(arr1 = [1000000000, 500000000],arr2 = [500000000, 1000000000]) == 643280640\n assert candidate(arr1 = [255, 128, 64, 32, 16],arr2 = [1, 3, 7, 15, 31]) == 5\n assert candidate(arr1 = [0, 1, 2, 3, 4],arr2 = [0, 1, 2, 3, 4]) == 4\n assert candidate(arr1 = [255, 128, 64, 32],arr2 = [1, 2, 4, 8]) == 15\n assert candidate(arr1 = [0, 1, 2, 3, 4],arr2 = [4, 3, 2, 1, 0]) == 4\n assert candidate(arr1 = [12],arr2 = [4]) == 4\n assert candidate(arr1 = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],arr2 = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 13\n assert candidate(arr1 = [8, 16, 32, 64, 128, 256, 512],arr2 = [1024, 2048, 4096, 8192]) == 0\n assert candidate(arr1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15],arr2 = [2, 4, 6, 8, 10, 12, 14, 16]) == 0\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 484\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(arr1 = [1023, 2047, 4095],arr2 = [8191, 16383, 32767]) == 3071\n assert candidate(arr1 = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127],arr2 = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 640\n assert candidate(arr1 = [5, 10, 15, 20, 25],arr2 = [30, 35, 40, 45, 50]) == 8\n assert candidate(arr1 = [7, 14, 21, 28, 35],arr2 = [42, 49, 56, 63, 70]) == 2\n assert candidate(arr1 = [11235813, 21345589, 34558914, 55891442],arr2 = [832040, 1346269, 2178309, 3524578]) == 279040\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(arr1 = [1023, 512, 256, 128, 64],arr2 = [32, 16, 8, 4, 2, 1]) == 63\n assert candidate(arr1 = [987654321, 234567890],arr2 = [135792468, 864201357]) == 855638081\n assert candidate(arr1 = [13, 29, 42, 57, 71],arr2 = [88, 99, 101, 113, 131]) == 4\n assert candidate(arr1 = [1],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 0\n assert candidate(arr1 = [1000000000, 500000000, 250000000, 125000000, 62500000],arr2 = [1, 3, 5, 7, 9]) == 0\n assert candidate(arr1 = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(arr1 = [23, 45, 67, 89, 101],arr2 = [113, 131, 149, 167]) == 64\n assert candidate(arr1 = [29, 18, 7, 2, 11],arr2 = [19, 23, 31, 37, 41]) == 1\n assert candidate(arr1 = [1000000, 2000000, 3000000],arr2 = [1000, 2000, 3000, 4000, 5000]) == 0\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32],arr2 = [64, 128, 256, 512, 1024]) == 0\n assert candidate(arr1 = [1, 3, 7, 15, 31, 63, 127, 255],arr2 = [255, 127, 63, 31, 15, 7, 3, 1]) == 170\n assert candidate(arr1 = [15, 31, 63, 127, 255],arr2 = [255, 127, 63, 31, 15]) == 175\n assert candidate(arr1 = [7, 14, 21, 28, 35],arr2 = [8, 16, 24, 32, 40]) == 0\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32, 64, 128],arr2 = [128, 64, 32, 16, 8, 4, 2, 1]) == 255\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr1 = [999999999, 999999998, 999999997, 999999996, 999999995],arr2 = [999999994, 999999993, 999999992, 999999991, 999999990]) == 999999994\n assert candidate(arr1 = [314159265, 271828182, 8675309],arr2 = [161803398, 141421356, 423606797]) == 403842\n assert candidate(arr1 = [17, 34, 51, 68, 85],arr2 = [1, 2, 4, 8, 16]) == 17\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0],arr2 = [1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],arr2 = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 682\n assert candidate(arr1 = [123456789, 987654321],arr2 = [111111111, 222222222, 333333333]) == 403023108\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [1]) == 1\n assert candidate(arr1 = [255, 192, 128, 64, 32],arr2 = [16, 8, 4, 2, 1]) == 31\n assert candidate(arr1 = [134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152],arr2 = [512, 256, 128, 64, 32, 16]) == 0\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(arr1 = [1, 1, 1, 1],arr2 = [2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(arr1 = [1023, 511, 255, 127, 63],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 703\n assert candidate(arr1 = [13, 14, 15],arr2 = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 12\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],arr2 = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2047\n assert candidate(arr1 = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 2097151\n assert candidate(arr1 = [1000000000, 500000000, 250000000, 125000000],arr2 = [2, 3, 5, 7]) == 0\n assert candidate(arr1 = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 682\n assert candidate(arr1 = [2, 4, 6, 8, 10],arr2 = [3, 6, 9, 12, 15]) == 2\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(arr1 = [1023, 2047, 4095, 8191],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1024\n assert candidate(arr1 = [0, 0, 0, 0, 0],arr2 = [1, 3, 5, 7, 9]) == 0\n assert candidate(arr1 = [29, 31, 37, 41, 43],arr2 = [47, 53, 59, 61, 67, 71]) == 0\n assert candidate(arr1 = [31, 63, 127, 255],arr2 = [255, 127, 63, 31]) == 160\n assert candidate(arr1 = [2, 4, 6, 8, 10, 12, 14, 16],arr2 = [1, 3, 5, 7, 9, 11, 13, 15]) == 0\n assert candidate(arr1 = [234, 456, 789, 1024],arr2 = [123, 234, 345, 456]) == 0\n assert candidate(arr1 = [987654321, 123456789, 456789123],arr2 = [987654321, 123456789, 456789123]) == 650094887\n assert candidate(arr1 = [123456, 654321, 987654, 321654],arr2 = [789456, 123789, 456789]) == 196608\n assert candidate(arr1 = [0, 0, 0, 0, 0],arr2 = [0, 0, 0, 0, 0]) == 0\n assert candidate(arr1 = [23, 45, 67, 89, 123],arr2 = [56, 78, 90, 101, 112]) == 25\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [600, 700, 800, 900, 1000]) == 416\n assert candidate(arr1 = [7, 8, 9, 10, 11],arr2 = [12, 13, 14, 15, 16]) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(arr1 = [15, 30, 45, 60, 75, 90],arr2 = [10, 20, 30, 40, 50, 60]) == 0\n assert candidate(arr1 = [15, 27, 45, 63],arr2 = [31, 63, 95, 127]) == 0\n assert candidate(arr1 = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],arr2 = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17]) == 16\n assert candidate(arr1 = [1000000000, 999999999, 888888888],arr2 = [777777777, 666666666, 555555555]) == 553274368\n assert candidate(arr1 = [123456789, 987654321, 111111111],arr2 = [222222222, 333333333, 444444444]) == 1575491\n assert candidate(arr1 = [13, 21, 34, 55, 89, 144, 233, 377, 610, 987],arr2 = [1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393]) == 1\n assert candidate(arr1 = [1048576, 2097152, 4194304],arr2 = [1, 3, 5, 7]) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 0\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(arr1 = [255, 0, 127, 63, 31],arr2 = [255, 128, 64, 32, 16]) == 0\n assert candidate(arr1 = [314159265],arr2 = [271828182]) == 271679616\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15],arr2 = [1, 2, 4, 8, 16, 32, 64, 128]) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n assert candidate(arr1 = [1000000000, 500000000, 250000000],arr2 = [1000000000, 500000000, 250000000]) == 682696064\n assert candidate(arr1 = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],arr2 = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 682\n assert candidate(arr1 = [123456789, 987654321, 135792468],arr2 = [246813579, 864204864, 975318642]) == 85229744\n assert candidate(arr1 = [1048575, 524287, 262143, 131071, 65535],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 720895\n assert candidate(arr1 = [1000000000, 999999999, 999999998],arr2 = [999999997, 999999996, 999999995]) == 999999488\n assert candidate(arr1 = [123456789, 987654321],arr2 = [234567891, 123456789]) == 142648708\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr1 = [1000000000, 500000000, 250000000, 125000000],arr2 = [2, 4, 8, 16]) == 0\n assert candidate(arr1 = [256, 512, 768, 1024],arr2 = [1, 2, 4, 8, 16]) == 0\n assert candidate(arr1 = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 682\n", "comparison": "exact"}, "public_tests": ["[1,2,3]\n[6,5]", "[12]\n[4]"], "hints": ["Think about (a&b) ^ (a&c). Can you simplify this expression?", "It is equal to a&(b^c). Then, (arr1[i]&arr2[0])^(arr1[i]&arr2[1]).. = arr1[i]&(arr2[0]^arr2[1]^arr[2]...).", "Let arr2XorSum = (arr2[0]^arr2[1]^arr2[2]...), arr1XorSum = (arr1[0]^arr1[1]^arr1[2]...) so the final answer is (arr2XorSum&arr1[0]) ^ (arr2XorSum&arr1[1]) ^ (arr2XorSum&arr1[2]) ^ ... = arr2XorSum & arr1XorSum."], "metadata": {"canonical_parameter_names": ["arr1", "arr2"], "leetcode_dataset_entry_point": "Solution().getXORSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:12+00:00", "tests_total": 103, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "math", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def getXORSum(self, arr1: list[int], arr2: list[int]) -> int:", "container": "Solution", "callable": "getXORSum", "parameters": [{"name": "arr1", "type": "list[int]"}, {"name": "arr2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1837, "task_id": "sum-of-digits-in-base-k", "difficulty": "Easy", "problem_description": "Given an integer n (in base 10) and a base k, return the sum of the digits of n after converting n from base 10 to base k.\n\nAfter converting, each digit should be interpreted as a base 10 number, and the sum should be returned in base 10.\n\nExample 1:\n\nInput: n = 34, k = 6\nOutput: 9\nExplanation: 34 (base 10) expressed in base 6 is 54. 5 + 4 = 9.\n\nExample 2:\n\nInput: n = 10, k = 10\nOutput: 1\nExplanation: n is already in base 10. 1 + 0 = 1.\n\nConstraints:\n\n- 1 <= n <= 100\n- 2 <= k <= 10\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 64,k = 2) == 1\n assert candidate(n = 7,k = 3) == 3\n assert candidate(n = 42,k = 5) == 6\n assert candidate(n = 50,k = 4) == 5\n assert candidate(n = 100,k = 3) == 4\n assert candidate(n = 10,k = 10) == 1\n assert candidate(n = 50,k = 7) == 2\n assert candidate(n = 99,k = 9) == 3\n assert candidate(n = 81,k = 9) == 1\n assert candidate(n = 34,k = 6) == 9\n assert candidate(n = 8,k = 2) == 1\n assert candidate(n = 45,k = 3) == 3\n assert candidate(n = 25,k = 2) == 3\n assert candidate(n = 81,k = 3) == 1\n assert candidate(n = 64,k = 10) == 10\n assert candidate(n = 27,k = 5) == 3\n assert candidate(n = 100,k = 2) == 3\n assert candidate(n = 1,k = 2) == 1\n assert candidate(n = 100,k = 4) == 4\n assert candidate(n = 72,k = 8) == 2\n assert candidate(n = 50,k = 5) == 2\n assert candidate(n = 17,k = 8) == 3\n assert candidate(n = 91,k = 8) == 7\n assert candidate(n = 73,k = 4) == 4\n assert candidate(n = 85,k = 7) == 7\n assert candidate(n = 63,k = 9) == 7\n assert candidate(n = 100,k = 7) == 4\n assert candidate(n = 63,k = 5) == 7\n assert candidate(n = 37,k = 5) == 5\n assert candidate(n = 95,k = 9) == 7\n assert candidate(n = 63,k = 7) == 3\n assert candidate(n = 55,k = 7) == 7\n assert candidate(n = 31,k = 5) == 3\n assert candidate(n = 32,k = 2) == 1\n assert candidate(n = 42,k = 4) == 6\n assert candidate(n = 19,k = 4) == 4\n assert candidate(n = 55,k = 6) == 5\n assert candidate(n = 100,k = 5) == 4\n assert candidate(n = 15,k = 6) == 5\n assert candidate(n = 45,k = 7) == 9\n assert candidate(n = 84,k = 4) == 3\n assert candidate(n = 31,k = 10) == 4\n assert candidate(n = 45,k = 6) == 5\n assert candidate(n = 97,k = 5) == 9\n assert candidate(n = 45,k = 10) == 9\n assert candidate(n = 50,k = 8) == 8\n assert candidate(n = 67,k = 5) == 7\n assert candidate(n = 37,k = 2) == 3\n assert candidate(n = 67,k = 7) == 7\n assert candidate(n = 29,k = 3) == 3\n assert candidate(n = 50,k = 6) == 5\n assert candidate(n = 72,k = 5) == 8\n assert candidate(n = 37,k = 6) == 2\n assert candidate(n = 85,k = 3) == 3\n assert candidate(n = 88,k = 3) == 4\n assert candidate(n = 64,k = 3) == 4\n assert candidate(n = 64,k = 4) == 1\n assert candidate(n = 95,k = 6) == 10\n assert candidate(n = 67,k = 3) == 5\n assert candidate(n = 100,k = 10) == 1\n assert candidate(n = 81,k = 5) == 5\n assert candidate(n = 55,k = 5) == 3\n assert candidate(n = 98,k = 2) == 3\n assert candidate(n = 58,k = 7) == 4\n assert candidate(n = 48,k = 4) == 3\n assert candidate(n = 31,k = 2) == 5\n assert candidate(n = 81,k = 8) == 4\n assert candidate(n = 42,k = 7) == 6\n assert candidate(n = 27,k = 9) == 3\n assert candidate(n = 77,k = 7) == 5\n assert candidate(n = 29,k = 8) == 8\n assert candidate(n = 97,k = 10) == 16\n assert candidate(n = 77,k = 4) == 5\n assert candidate(n = 13,k = 6) == 3\n assert candidate(n = 49,k = 9) == 9\n assert candidate(n = 55,k = 10) == 10\n assert candidate(n = 41,k = 4) == 5\n assert candidate(n = 98,k = 6) == 8\n assert candidate(n = 50,k = 3) == 6\n assert candidate(n = 85,k = 5) == 5\n assert candidate(n = 73,k = 8) == 3\n assert candidate(n = 100,k = 9) == 4\n assert candidate(n = 77,k = 8) == 7\n assert candidate(n = 85,k = 4) == 4\n assert candidate(n = 99,k = 3) == 3\n assert candidate(n = 29,k = 4) == 5\n assert candidate(n = 72,k = 6) == 2\n", "comparison": "exact"}, "public_tests": ["34\n6", "10\n10"], "hints": ["Convert the given number into base k."], "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().sumBase", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:17+00:00", "tests_total": 87, "tests_dropped": 0, "flags": [], "topic_tags": ["math"]}, "language": "python", "interface": {"raw_signature": "def sumBase(self, n: int, k: int) -> int:", "container": "Solution", "callable": "sumBase", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1838, "task_id": "frequency-of-the-most-frequent-element", "difficulty": "Medium", "problem_description": "The frequency of an element is the number of times it occurs in an array.\n\nYou are given an integer array nums and an integer k. In one operation, you can choose an index of nums and increment the element at that index by 1.\n\nReturn the maximum possible frequency of an element after performing at most k operations.\n\nExample 1:\n\nInput: nums = [1,2,4], k = 5\nOutput: 3\nExplanation: Increment the first element three times and the second element two times to make nums = [4,4,4].\n4 has a frequency of 3.\n\nExample 2:\n\nInput: nums = [1,4,8,13], k = 5\nOutput: 2\nExplanation: There are multiple optimal solutions:\n- Increment the first element three times to make nums = [4,4,8,13]. 4 has a frequency of 2.\n- Increment the second element four times to make nums = [1,8,8,13]. 8 has a frequency of 2.\n- Increment the third element five times to make nums = [1,4,13,13]. 13 has a frequency of 2.\n\nExample 3:\n\nInput: nums = [3,9,6], k = 2\nOutput: 1\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^5\n- 1 <= k <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 4],k = 5) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 25) == 7\n assert candidate(nums = [5, 5, 5, 5, 5],k = 10) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4],k = 7) == 6\n assert candidate(nums = [1, 1, 1, 1, 1],k = 10) == 5\n assert candidate(nums = [3, 9, 6],k = 2) == 1\n assert candidate(nums = [1, 1, 1, 1, 1],k = 5) == 5\n assert candidate(nums = [1, 100000],k = 100000) == 2\n assert candidate(nums = [1, 2, 2, 4],k = 6) == 3\n assert candidate(nums = [1, 4, 8, 13],k = 5) == 2\n assert candidate(nums = [1, 100000],k = 99999) == 2\n assert candidate(nums = [100000, 100000, 100000],k = 100000) == 3\n assert candidate(nums = [5, 9, 11, 13, 15],k = 10) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],k = 10) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 3],k = 6) == 6\n assert candidate(nums = [1, 2, 2, 4],k = 3) == 3\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 10) == 10\n assert candidate(nums = [1, 1, 1, 1],k = 10) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],k = 15) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 50) == 20\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 200) == 9\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 150) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 50) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 45) == 10\n assert candidate(nums = [2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5],k = 150) == 21\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9],k = 50) == 15\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 15) == 10\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 75) == 20\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],k = 40) == 19\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 1000) == 14\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 55) == 7\n assert candidate(nums = [1, 3, 6, 10, 15],k = 25) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 6\n assert candidate(nums = [5, 7, 7, 8, 8, 10, 10, 10, 10],k = 30) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 50) == 10\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 100) == 20\n assert candidate(nums = [5, 7, 7, 8, 8, 10, 10, 10, 12, 12, 12, 12],k = 30) == 11\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 10) == 7\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 100) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 150) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 50) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5],k = 10) == 10\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9],k = 30) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 60) == 25\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1000) == 10\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 60) == 20\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 100) == 10\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 30) == 17\n assert candidate(nums = [10, 20, 30, 40, 50],k = 100) == 5\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],k = 100000) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == 10\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 50) == 10\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],k = 100) == 7\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 200) == 14\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 50) == 18\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 100) == 20\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 1500) == 17\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4],k = 50) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 200) == 20\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 100) == 10\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101],k = 500) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 200) == 20\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 20) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3000) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1000) == 20\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 100) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 50) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 100) == 10\n assert candidate(nums = [1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 100) == 40\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 300) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 14\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 150) == 17\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50],k = 100) == 6\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7],k = 100) == 21\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 200) == 30\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 20) == 14\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 50000) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],k = 200) == 29\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 15) == 13\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 250) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 100) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 500) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 14\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5],k = 50) == 20\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 12\n", "comparison": "exact"}, "public_tests": ["[1,2,4]\n5", "[1,4,8,13]\n5", "[3,9,6]\n2"], "hints": ["Note that you can try all values in a brute force manner and find the maximum frequency of that value.", "To find the maximum frequency of a value consider the biggest elements smaller than or equal to this value"], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxFrequency", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:19+00:00", "tests_total": 99, "tests_dropped": 12, "flags": [], "topic_tags": ["array", "binary-search", "greedy", "sliding-window", "sorting", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maxFrequency(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "maxFrequency", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1839, "task_id": "longest-substring-of-all-vowels-in-order", "difficulty": "Medium", "problem_description": "A string is considered beautiful if it satisfies the following conditions:\n\n- Each of the 5 English vowels ('a', 'e', 'i', 'o', 'u') must appear at least once in it.\n- The letters must be sorted in alphabetical order (i.e. all 'a's before 'e's, all 'e's before 'i's, etc.).\n\nFor example, strings \"aeiou\" and \"aaaaaaeiiiioou\" are considered beautiful, but \"uaeio\", \"aeoiu\", and \"aaaeeeooo\" are not beautiful.\n\nGiven a string word consisting of English vowels, return the length of the longest beautiful substring of word. If no such substring exists, return 0.\n\nA substring is a contiguous sequence of characters in a string.\n\nExample 1:\n\nInput: word = \"aeiaaioaaaaeiiiiouuuooaauuaeiu\"\nOutput: 13\nExplanation: The longest beautiful substring in word is \"aaaaeiiiiouuu\" of length 13.\n\nExample 2:\n\nInput: word = \"aeeeiiiioooauuuaeiou\"\nOutput: 5\nExplanation: The longest beautiful substring in word is \"aeiou\" of length 5.\n\nExample 3:\n\nInput: word = \"a\"\nOutput: 0\nExplanation: There is no beautiful substring, so return 0.\n\nConstraints:\n\n- 1 <= word.length <= 5 * 10^5\n- word consists of characters 'a', 'e', 'i', 'o', and 'u'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuooaauuaeiuuuuuuuuuuuuuuuuuuuuaaa\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuaauuaeiu\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuuuuuuuuuuuuuuuuuuaaaaaaeiou\") == 10\n assert candidate(word = \"aeiaaioaaaaeiioooaeiouuuaeiouuu\") == 7\n assert candidate(word = \"aeeeiiiioooauuuaeiou\") == 5\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuuuaaaaaaaaaeeeeiiiioooouuuuuu\") == 27\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuooaaeiouaaaaaaaaaaeiouuuuuuuuuuuuuuuuuuuu\") == 33\n assert candidate(word = \"aeiaaioaaaaeiioooaeiouuuaeiouuuaeiouuu\") == 7\n assert candidate(word = \"aeiaaioaaaaeiiaaaouuuooauuaeiu\") == 0\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiou\") == 5\n assert candidate(word = \"aaaaaaaaaeeeeeeeeeeiiiiiiioooooouuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\") == 68\n assert candidate(word = \"aeiaaioaaaaeiioooaeiouuu\") == 7\n assert candidate(word = \"aeiaaioaaaaeiiooouuuaeiou\") == 13\n assert candidate(word = \"a\") == 0\n assert candidate(word = \"aeiou\") == 5\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuuuuuuuuuuuuuuuuuu\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiaaaouuuooaauuaeiaaioaaaaeiiiiouuuooaauuaeiu\") == 13\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiu\") == 13\n assert candidate(word = \"aeiaaioaaaaeiiooouuuooauuaeiu\") == 13\n assert candidate(word = \"uuuuuuuuuuuuuuuuuuuu\") == 0\n", "comparison": "exact"}, "public_tests": ["\"aeiaaioaaaaeiiiiouuuooaauuaeiu\"", "\"aeeeiiiioooauuuaeiou\"", "\"a\""], "hints": ["Start from each 'a' and find the longest beautiful substring starting at that index.", "Based on the current character decide if you should include the next character in the beautiful substring."], "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().longestBeautifulSubstring", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:22+00:00", "tests_total": 20, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def longestBeautifulSubstring(self, word: str) -> int:", "container": "Solution", "callable": "longestBeautifulSubstring", "parameters": [{"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1840, "task_id": "maximum-building-height", "difficulty": "Hard", "problem_description": "You want to build n new buildings in a city. The new buildings will be built in a line and are labeled from 1 to n.\n\nHowever, there are city restrictions on the heights of the new buildings:\n\n- The height of each building must be a non-negative integer.\n- The height of the first building must be 0.\n- The height difference between any two adjacent buildings cannot exceed 1.\n\nAdditionally, there are city restrictions on the maximum height of specific buildings. These restrictions are given as a 2D integer array restrictions where restrictions[i] = [id_i, maxHeight_i] indicates that building id_i must have a height less than or equal to maxHeight_i.\n\nIt is guaranteed that each building will appear at most once in restrictions, and building 1 will not be in restrictions.\n\nReturn the maximum possible height of the tallest building.\n\nExample 1:\n\nInput: n = 5, restrictions = [[2,1],[4,1]]\nOutput: 2\nExplanation: The green area in the image indicates the maximum allowed height for each building.\nWe can build the buildings with heights [0,1,2,1,2], and the tallest building has a height of 2.\n\nExample 2:\n\nInput: n = 6, restrictions = []\nOutput: 5\nExplanation: The green area in the image indicates the maximum allowed height for each building.\nWe can build the buildings with heights [0,1,2,3,4,5], and the tallest building has a height of 5.\n\nExample 3:\n\nInput: n = 10, restrictions = [[5,3],[2,5],[7,4],[10,3]]\nOutput: 5\nExplanation: The green area in the image indicates the maximum allowed height for each building.\nWe can build the buildings with heights [0,1,2,3,3,4,4,5,4,3], and the tallest building has a height of 5.\n\nConstraints:\n\n- 2 <= n <= 10^9\n- 0 <= restrictions.length <= min(n - 1, 10^5)\n- 2 <= id_i <= n\n- id_i is unique.\n- 0 <= maxHeight_i <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,restrictions = []) == 5\n assert candidate(n = 5,restrictions = [[2, 1], [4, 1]]) == 2\n assert candidate(n = 100,restrictions = [[10, 5], [50, 25], [90, 10]]) == 37\n assert candidate(n = 1000000,restrictions = [[500000, 500000]]) == 999999\n assert candidate(n = 10,restrictions = [[5, 3], [2, 5], [7, 4], [10, 3]]) == 5\n assert candidate(n = 100000,restrictions = [[1000, 50], [2000, 100], [3000, 150], [4000, 200], [5000, 250], [6000, 300], [7000, 350], [8000, 400], [9000, 450]]) == 91450\n assert candidate(n = 20,restrictions = [[5, 3], [6, 2], [7, 1], [8, 0], [9, 1], [10, 2], [11, 3], [12, 4], [13, 5], [14, 6], [15, 7]]) == 12\n assert candidate(n = 1000,restrictions = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9]]) == 109\n assert candidate(n = 200,restrictions = [[20, 100], [40, 50], [60, 75], [80, 25], [100, 100], [120, 75], [140, 50], [160, 25], [180, 0], [200, 100]]) == 62\n assert candidate(n = 100,restrictions = [[10, 5], [30, 5], [50, 5], [70, 5], [90, 5]]) == 15\n assert candidate(n = 1000000,restrictions = [[500000, 1], [500001, 1], [500002, 1], [500003, 1], [500004, 1], [500005, 1], [500006, 1], [500007, 1], [500008, 1]]) == 499993\n assert candidate(n = 10000,restrictions = [[2000, 1000], [4000, 1500], [6000, 2000], [8000, 2500]]) == 4500\n assert candidate(n = 200,restrictions = [[5, 3], [10, 2], [15, 1], [20, 2], [25, 3], [30, 2], [35, 1], [40, 2], [45, 3], [50, 2], [55, 1], [60, 2], [65, 3], [70, 2], [75, 1], [80, 2], [85, 3], [90, 2], [95, 1], [100, 2], [105, 3], [110, 2], [115, 1], [120, 2], [125, 3], [130, 2], [135, 1], [140, 2], [145, 3], [150, 2], [155, 1], [160, 2], [165, 3], [170, 2], [175, 1], [180, 2], [185, 3], [190, 2], [195, 1]]) == 6\n assert candidate(n = 100,restrictions = [[10, 9], [20, 8], [30, 7], [40, 6], [50, 5], [60, 4], [70, 3], [80, 2], [90, 1]]) == 13\n assert candidate(n = 5000,restrictions = [[50, 1000], [100, 900], [150, 800], [200, 700], [250, 600], [300, 500], [350, 400], [400, 300], [450, 200], [500, 100]]) == 4600\n assert candidate(n = 20,restrictions = [[2, 3], [5, 4], [8, 1], [15, 5], [18, 2]]) == 6\n assert candidate(n = 100,restrictions = [[10, 5], [20, 10], [30, 3], [40, 15], [50, 5], [60, 20], [70, 7], [80, 12], [90, 10], [100, 2]]) == 16\n assert candidate(n = 20,restrictions = [[3, 2], [6, 3], [9, 2], [15, 5], [18, 4]]) == 6\n assert candidate(n = 10000,restrictions = [[1000, 5000], [2000, 10000], [3000, 15000], [4000, 20000], [5000, 25000], [6000, 30000], [7000, 35000], [8000, 40000], [9000, 45000], [10000, 50000]]) == 9999\n assert candidate(n = 999,restrictions = [[999, 1]]) == 499\n assert candidate(n = 1000000000,restrictions = [[100000000, 10000000], [200000000, 20000000], [300000000, 30000000], [400000000, 40000000]]) == 640000000\n assert candidate(n = 1000000,restrictions = [[999999, 999999]]) == 999999\n assert candidate(n = 50,restrictions = [[3, 2], [5, 3], [10, 5], [15, 7], [20, 9], [25, 11], [30, 13], [35, 15], [40, 17], [45, 19], [50, 21]]) == 22\n assert candidate(n = 20,restrictions = [[3, 3], [6, 2], [9, 5], [15, 4]]) == 9\n assert candidate(n = 1000,restrictions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]]) == 950\n assert candidate(n = 500000,restrictions = [[50000, 100000], [100000, 150000], [150000, 200000], [200000, 250000], [250000, 300000]]) == 499999\n assert candidate(n = 10000,restrictions = [[1000, 500], [2000, 1000], [3000, 1500], [4000, 2000], [5000, 2500], [6000, 3000], [7000, 3500], [8000, 4000], [9000, 4500], [10000, 5000]]) == 5250\n assert candidate(n = 1000000,restrictions = [[2, 1], [4, 1], [6, 1], [8, 1], [10, 1], [12, 1], [14, 1], [16, 1], [18, 1], [20, 1]]) == 999981\n assert candidate(n = 100000,restrictions = [[10000, 5000], [30000, 15000], [50000, 25000], [70000, 30000], [90000, 35000]]) == 45000\n assert candidate(n = 1000000,restrictions = [[2, 500000], [3, 500000], [4, 500000], [5, 500000], [6, 500000], [7, 500000], [8, 500000], [9, 500000], [10, 500000]]) == 999999\n assert candidate(n = 50000000,restrictions = [[10000000, 20000000], [20000000, 10000000], [30000000, 15000000], [40000000, 5000000], [50000000, 25000000]]) == 17500000\n assert candidate(n = 500000,restrictions = [[100000, 150000], [200000, 250000], [300000, 350000], [400000, 450000]]) == 499999\n assert candidate(n = 150,restrictions = [[15, 15], [30, 30], [45, 45], [60, 60], [75, 75], [90, 90], [105, 105], [120, 120], [135, 135], [150, 150]]) == 149\n assert candidate(n = 1000,restrictions = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [550, 550], [600, 600], [650, 650], [700, 700], [750, 750], [800, 800], [850, 850], [900, 900], [950, 950], [1000, 1000]]) == 999\n assert candidate(n = 5000,restrictions = [[1000, 500], [2000, 1000], [3000, 1500], [4000, 2000]]) == 3000\n assert candidate(n = 1000,restrictions = [[100, 900], [200, 800], [300, 700], [400, 600], [500, 500], [600, 400], [700, 300], [800, 200], [900, 100]]) == 499\n assert candidate(n = 100,restrictions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25]]) == 75\n assert candidate(n = 50,restrictions = [[5, 4], [10, 3], [15, 2], [20, 1], [25, 0], [30, 1], [35, 2], [40, 3], [45, 4], [50, 5]]) == 7\n assert candidate(n = 1000,restrictions = [[50, 100], [150, 100], [250, 100], [350, 100], [450, 100], [550, 100], [650, 100], [750, 100], [850, 100], [950, 100]]) == 150\n assert candidate(n = 1000,restrictions = [[500, 500], [250, 250], [750, 750], [100, 100], [900, 900]]) == 999\n assert candidate(n = 100000,restrictions = [[1000, 500], [5000, 2500], [10000, 5000], [25000, 10000], [50000, 15000], [75000, 10000], [90000, 5000], [95000, 1000]]) == 25000\n assert candidate(n = 100,restrictions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45]]) == 55\n assert candidate(n = 100,restrictions = [[10, 10], [20, 15], [30, 20], [40, 10], [50, 25], [60, 20], [70, 15], [80, 10], [90, 5]]) == 25\n assert candidate(n = 100,restrictions = [[3, 20], [50, 10], [90, 5]]) == 29\n assert candidate(n = 100,restrictions = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1]]) == 11\n assert candidate(n = 10000,restrictions = [[500, 1000], [2500, 2000], [5000, 3000], [7500, 2000], [9500, 1000]]) == 3750\n assert candidate(n = 100,restrictions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]]) == 52\n assert candidate(n = 1000000000,restrictions = [[100000000, 99999999], [200000000, 88888888], [300000000, 77777777], [400000000, 66666666], [500000000, 55555555]]) == 555555555\n assert candidate(n = 20,restrictions = [[2, 3], [4, 2], [6, 3], [8, 2], [10, 3], [12, 2], [14, 3], [16, 2], [18, 3]]) == 5\n assert candidate(n = 200,restrictions = [[20, 1], [40, 3], [60, 5], [80, 7], [100, 9], [120, 11], [140, 13], [160, 15], [180, 17]]) == 37\n assert candidate(n = 50,restrictions = [[5, 25], [10, 15], [20, 30], [35, 20], [45, 10]]) == 27\n assert candidate(n = 1000000,restrictions = [[100000, 50000], [200000, 100000], [300000, 75000], [400000, 25000], [500000, 100000]]) == 600000\n assert candidate(n = 1000000,restrictions = [[50000, 100000], [100000, 200000], [150000, 300000], [200000, 400000], [250000, 500000], [300000, 400000], [350000, 300000], [400000, 200000], [450000, 100000]]) == 650000\n assert candidate(n = 15,restrictions = [[3, 2], [6, 3], [9, 1], [12, 4]]) == 7\n assert candidate(n = 1000000,restrictions = [[10000, 1000], [20000, 2000], [30000, 3000], [40000, 4000], [50000, 5000], [60000, 6000], [70000, 7000], [80000, 8000], [90000, 9000]]) == 919000\n assert candidate(n = 100,restrictions = [[10, 10], [20, 5], [30, 15], [40, 20], [50, 10], [60, 25], [70, 30], [80, 5], [90, 40]]) == 25\n assert candidate(n = 50,restrictions = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45]]) == 49\n assert candidate(n = 100,restrictions = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]]) == 14\n assert candidate(n = 10000,restrictions = [[2, 9999], [4, 9998], [6, 9997], [8, 9996], [10, 9995], [12, 9994], [14, 9993], [16, 9992], [18, 9991], [20, 9990]]) == 9999\n assert candidate(n = 100,restrictions = [[2, 99], [4, 98], [6, 97], [8, 96], [10, 95], [12, 94], [14, 93], [16, 92], [18, 91], [20, 90], [22, 89], [24, 88], [26, 87], [28, 86], [30, 85], [32, 84], [34, 83], [36, 82], [38, 81], [40, 80], [42, 79], [44, 78], [46, 77], [48, 76], [50, 75], [52, 74], [54, 73], [56, 72], [58, 71], [60, 70], [62, 69], [64, 68], [66, 67], [68, 66], [70, 65], [72, 64], [74, 63], [76, 62], [78, 61], [80, 60], [82, 59], [84, 58], [86, 57], [88, 56], [90, 55], [92, 54], [94, 53], [96, 52], [98, 51], [100, 50]]) == 66\n assert candidate(n = 200,restrictions = [[2, 1], [50, 50], [150, 20], [100, 30], [180, 10]]) == 64\n assert candidate(n = 1000000,restrictions = [[200000, 300000], [400000, 100000], [600000, 200000], [800000, 400000], [1000000, 500000]]) == 550000\n assert candidate(n = 1000,restrictions = [[10, 900], [20, 800], [30, 700], [40, 600], [50, 500], [60, 400], [70, 300], [80, 200], [90, 100]]) == 999\n assert candidate(n = 10000,restrictions = [[100, 50], [200, 40], [300, 30], [400, 20], [500, 10], [600, 0], [700, 10], [800, 20], [900, 30]]) == 9130\n assert candidate(n = 200,restrictions = [[10, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10], [110, 20], [120, 30], [130, 40], [140, 50], [150, 60], [160, 70], [170, 80], [180, 90], [190, 100], [200, 110]]) == 110\n assert candidate(n = 500,restrictions = [[50, 10], [100, 20], [150, 10], [200, 20], [250, 10], [300, 20], [350, 10], [400, 20], [450, 10], [500, 20]]) == 40\n assert candidate(n = 50,restrictions = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]]) == 12\n assert candidate(n = 5000,restrictions = [[500, 500], [1000, 400], [1500, 600], [2000, 500], [2500, 700], [3000, 400], [3500, 600], [4000, 500], [4500, 700], [5000, 400]]) == 850\n assert candidate(n = 500,restrictions = [[100, 10], [200, 200], [300, 150], [400, 100], [500, 50]]) == 180\n assert candidate(n = 300,restrictions = [[30, 2], [60, 4], [90, 6], [120, 8], [150, 10], [180, 12], [210, 14], [240, 16], [270, 18]]) == 48\n assert candidate(n = 100,restrictions = [[10, 5], [30, 10], [50, 5], [70, 10], [90, 5]]) == 17\n assert candidate(n = 100,restrictions = [[20, 15], [30, 25], [40, 35], [50, 45], [60, 55], [70, 65], [80, 75], [90, 85]]) == 95\n assert candidate(n = 1000,restrictions = [[10, 5], [20, 15], [30, 10], [40, 20], [50, 15], [60, 25], [70, 20], [80, 30], [90, 25], [100, 35]]) == 935\n assert candidate(n = 20,restrictions = [[3, 2], [6, 3], [15, 5], [18, 4]]) == 8\n assert candidate(n = 1000,restrictions = [[100, 100], [200, 900], [300, 300], [400, 700], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900]]) == 999\n assert candidate(n = 10000000,restrictions = [[1000000, 500000], [2000000, 1000000], [3000000, 1500000], [4000000, 2000000], [5000000, 2500000], [6000000, 3000000], [7000000, 3500000], [8000000, 4000000], [9000000, 4500000]]) == 5500000\n assert candidate(n = 500,restrictions = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]]) == 460\n assert candidate(n = 2000,restrictions = [[500, 500], [1000, 500], [1500, 500]]) == 1000\n assert candidate(n = 2000,restrictions = [[500, 100], [1000, 500], [1500, 200], [2000, 1000]]) == 700\n assert candidate(n = 200,restrictions = [[2, 198], [4, 196], [6, 194], [8, 192], [10, 190], [12, 188], [14, 186], [16, 184], [18, 182], [20, 180]]) == 199\n assert candidate(n = 10000000,restrictions = [[1000000, 1000000], [3000000, 3000000], [5000000, 5000000], [7000000, 7000000], [9000000, 9000000]]) == 9999999\n assert candidate(n = 500000,restrictions = [[100000, 100000], [200000, 200000], [300000, 300000], [400000, 400000], [500000, 500000]]) == 499999\n assert candidate(n = 100000,restrictions = [[5000, 1000], [15000, 2000], [25000, 3000], [35000, 4000], [45000, 5000], [55000, 6000], [65000, 7000], [75000, 8000], [85000, 9000], [95000, 10000]]) == 15000\n assert candidate(n = 10000,restrictions = [[500, 5000], [1000, 10000], [1500, 15000], [2000, 20000], [2500, 25000], [3000, 30000]]) == 9999\n assert candidate(n = 1000000,restrictions = [[1000, 500], [2000, 1000], [3000, 750], [4000, 1500], [5000, 1250], [6000, 2000], [7000, 1750], [8000, 2500], [9000, 2250], [10000, 3000]]) == 993000\n assert candidate(n = 10000,restrictions = [[1000, 500], [2000, 750], [3000, 1000], [4000, 1250], [5000, 1500]]) == 6500\n assert candidate(n = 1000000,restrictions = [[100000, 100000], [200000, 200000], [300000, 300000], [400000, 400000], [500000, 500000], [600000, 600000], [700000, 700000], [800000, 800000], [900000, 900000]]) == 999999\n", "comparison": "exact"}, "public_tests": ["5\n[[2,1],[4,1]]", "6\n[]", "10\n[[5,3],[2,5],[7,4],[10,3]]"], "hints": ["Is it possible to find the max height if given the height range of a particular building?", "You can find the height range of a restricted building by doing 2 passes from the left and right."], "metadata": {"canonical_parameter_names": ["n", "restrictions"], "leetcode_dataset_entry_point": "Solution().maxBuilding", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:24+00:00", "tests_total": 87, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "math", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxBuilding(self, n: int, restrictions: list[list[int]]) -> int:", "container": "Solution", "callable": "maxBuilding", "parameters": [{"name": "n", "type": "int"}, {"name": "restrictions", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1844, "task_id": "replace-all-digits-with-characters", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string s that has lowercase English letters in its even indices and digits in its odd indices.\n\nYou must perform an operation shift(c, x), where c is a character and x is a digit, that returns the x^th character after c.\n\n- For example, shift('a', 5) = 'f' and shift('x', 0) = 'x'.\n\nFor every odd index i, you want to replace the digit s[i] with the result of the shift(s[i-1], s[i]) operation.\n\nReturn s after replacing all digits. It is guaranteed that shift(s[i-1], s[i]) will never exceed 'z'.\n\nNote that shift(c, x) is not a preloaded function, but an operation to be implemented as part of the solution.\n\nExample 1:\n\nInput: s = \"a1c1e1\"\nOutput: \"abcdef\"\nExplanation: The digits are replaced as follows:\n- s[1] -> shift('a',1) = 'b'\n- s[3] -> shift('c',1) = 'd'\n- s[5] -> shift('e',1) = 'f'\n\nExample 2:\n\nInput: s = \"a1b2c3d4e\"\nOutput: \"abbdcfdhe\"\nExplanation: The digits are replaced as follows:\n- s[1] -> shift('a',1) = 'b'\n- s[3] -> shift('b',2) = 'd'\n- s[5] -> shift('c',3) = 'f'\n- s[7] -> shift('d',4) = 'h'\n\nConstraints:\n\n- 1 <= s.length <= 100\n- s consists only of lowercase English letters and digits.\n- shift(s[i-1], s[i]) <= 'z' for all odd indices i.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"x1y2z3a4b5c6d7e8f9g0\") == \"xyy{z}aebgcidkemfogg\"\n assert candidate(s = \"x5y5z5\") == \"x}y~z\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0\") == \"ajbjcjdjejfjgjhjijjj\"\n assert candidate(s = \"a9b9c9d9\") == \"ajbkcldm\"\n assert candidate(s = \"z0y0x0w0\") == \"zzyyxxww\"\n assert candidate(s = \"a0b0c0d0\") == \"aabbccdd\"\n assert candidate(s = \"m9l8k7j6\") == \"mvltkrjp\"\n assert candidate(s = \"z0y1x2w3\") == \"zzyzxzwz\"\n assert candidate(s = \"z0y0x0w0v0\") == \"zzyyxxwwvv\"\n assert candidate(s = \"a0b0c0d0e0f0g0h0i0j0\") == \"aabbccddeeffgghhiijj\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1\") == \"ajbjcjdjejfjgjhjij\"\n assert candidate(s = \"t1s2r3q4p5o6n7m8l9k0\") == \"tusuruqupuounumulukk\"\n assert candidate(s = \"s9r8q7p6o5n4m3l2k1j0\") == \"s|rzqxpvotnrmplnkljj\"\n assert candidate(s = \"p2r4t6v8\") == \"prrvtzv~\"\n assert candidate(s = \"m0n1o2p3\") == \"mmnooqps\"\n assert candidate(s = \"q2w3e4r5\") == \"qswzeirw\"\n assert candidate(s = \"t1t2t3t4\") == \"tutvtwtx\"\n assert candidate(s = \"a1b2c3d4e\") == \"abbdcfdhe\"\n assert candidate(s = \"p1q2r3s4t\") == \"pqqsruswt\"\n assert candidate(s = \"a1c1e1\") == \"abcdef\"\n assert candidate(s = \"z0y2x3w4v\") == \"zzy{x{w{v\"\n assert candidate(s = \"q9r8s7t6u5\") == \"qzrzsztzuz\"\n assert candidate(s = \"x2y3z4\") == \"xzy|z~\"\n assert candidate(s = \"q9r8s7t6\") == \"qzrzsztz\"\n assert candidate(s = \"s0t1u2v3w4x5y6z7\") == \"sstuuwvyw{x}yz\"\n assert candidate(s = \"m9l8k7j6i5h4g3f2e1d0\") == \"mvltkrjpinhlgjfhefdd\"\n assert candidate(s = \"s9s8s7s6\") == \"s|s{szsy\"\n assert candidate(s = \"p2o3n4m5l6\") == \"prornrmrlr\"\n assert candidate(s = \"t2r3e4w5q6p7o8i9u0y1t2r3e4w\") == \"tvrueiw|qwpwowiruuyztvrueiw\"\n assert candidate(s = \"m4n3o2p1q0r9s8t7u6v5w4x3y2z1\") == \"mqnqoqpqqqr{s{t{u{v{w{x{y{z{\"\n assert candidate(s = \"z1y2x3w4v5u6t7s8r9q0p1o2n3m4l5k6j7i8h9g0f1e2d3c4b5a6\") == \"z{y{x{w{v{u{t{s{r{qqpqoqnqmqlqkqjqiqhqggfgegdgcgbgag\"\n assert candidate(s = \"n9m8l7k6j5i4h3g2f1e0d9c8b7a6z5y4x3w2v1u0t9s8r7q6p5\") == \"nwmulskqjoimhkgifgeedmckbiagzy}x{wyvwuut}s{ryqwpu\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p0o0n0m0l0k0j0i0h0g0f0e0d0c0b0a0\") == \"zƒyxw}v{uytwsursqqppoonnmmllkkjjiihhggffeeddccbbaa\"\n assert candidate(s = \"z8y6x4w2v0u8t6s4r2q0p8o6n4m2l0k8j6i4h2g0f8e6d4c2b0a8\") == \"z‚yx|wyvvu}tzswrtqqpxounrmollksjpimhjggfnekdhcebbai\"\n assert candidate(s = \"b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9u0v1w2x3y4z5\") == \"bccedgeifkgmhoiqjskklmmonqospuqwrys{t}uuvwwyx{y}z\"\n assert candidate(s = \"m3n5o7p9q1r3s5t7u9v1w3x5y7z9a1b3c5d7e9f1g3h5i7j9\") == \"mpnsovpyqrrusxt{u~vwwzx}y€zƒabbechdkenfggjhmipjs\"\n assert candidate(s = \"c3d2e1f0g9h8i7j6k5l4m3n2o1p0q9r8\") == \"cfdfefffgphpipjpkplpmpnpopppqzrz\"\n assert candidate(s = \"d3c2b1a0z9y8x7w6v5u4t3s2r1q0p9o8n7m6l5k4j3i2h1g0f9\") == \"dgcebcaazƒyxw}v{uytwsursqqpyownumslqkojmikhiggfo\"\n assert candidate(s = \"a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7\") == \"acbecgdiekfmgohqiijkkmlomqnsoupwqyr{sstuuwvyw{x}yz\"\n assert candidate(s = \"d3f5h7j9l1n3p5r7t9v1x3z5b7d9f1h3j5l7n9p1r3t5v7x9\") == \"dgfkhojslmnqpuryt}vwx{zbidmfghkjolsnwpqrutyv}x\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p9o8n7m6l5k4j3i2h1g0f9e8d7c6b5a4\") == \"zƒyxw}v{uytwsursqqpyownumslqkojmikhiggfoemdkcibgae\"\n assert candidate(s = \"z1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4\") == \"z{acbecgdiekfmgohqiijkkmlomqnsoupwqyr{sstuuwvyw{\"\n assert candidate(s = \"v1u2t3s4r5q6p7o8n9m0l1k2j3i4h5g6f7e8d9c0b1a2z3y4x5\") == \"vwuwtwswrwqwpwownwmmlmkmjmimhmgmfmemdmccbcacz}y}x}\"\n assert candidate(s = \"b2c4d6e8f0g2h4i6j8k0l2m4n6o8p0q2r4s6t8u0v2w4x6y8z0a2\") == \"bdcgdjemffgihliojrkklnmqntowppqsrvsyt|uuvxw{x~yzzac\"\n assert candidate(s = \"a9z8y7x6w5v4u3t2s1r0\") == \"ajz‚y€x~w|vzuxtvstrr\"\n assert candidate(s = \"n7m6l5k4j3i2h1g0f5e4d3\") == \"numslqkojmikhiggfkeidg\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == \"abbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{\"\n assert candidate(s = \"b5c6d7e8f9g0h1i2j3k4l5m6n7o8p9q0r1s2t3u4v5w6x7y8z9\") == \"bgcidkemfogghiikjmkolqmsnuowpyqqrssutwuyv{w}xyzƒ\"\n assert candidate(s = \"q0r2s4t6u8v0w2x4y6z8\") == \"qqrtswtzu}vvwyx|yz‚\"\n assert candidate(s = \"s5r4q3p2o1n0m9l8k7j6i5h4g3f2e1d0c9b8a7z6y5x4w3v2u1t0s9\") == \"sxrvqtpropnnmvltkrjpinhlgjfhefddclbjahz€y~x|wzvxuvtts|\"\n assert candidate(s = \"x2y3z2a3b4c5d6e7f8g9h0i1j2k3l4m5n6o7p8q9r0s1t2u3v4w5x6y7z8a9\") == \"xzy|z|adbfchdjelfngphhijjlknlpmrntovpxqzrrsttvuxvzw|x~y€z‚aj\"\n assert candidate(s = \"s1t2u3v4w5x6y7z8a9b0c1d2e3f4g5h6i7j8k9l0m1n2o3p4q5r6\") == \"sttvuxvzw|x~y€z‚ajbbcddfehfjglhnipjrktllmnnporptqvrx\"\n assert candidate(s = \"t4r2q0p8o6n4m2l0k8j6i4h2g0f8e6d4c2b0a8y6x4w2v0u8t6s4\") == \"txrtqqpxounrmollksjpimhjggfnekdhcebbaiyx|wyvvu}tzsw\"\n assert candidate(s = \"a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0\") == \"acbecgdiekfmgohqiijkkmlomqnsoupwqyr{ss\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9\") == \"abbdcfdhejflgnhpirjjkllnmpnrotpvqxrzs|ttuvvxwzx|y~z€ahbjcl\"\n assert candidate(s = \"x2y4z6a8b0c2d4e6f8g0h2i4j6k8l0m2n4o6p8q0r2s4t6u8v0\") == \"xzy}z€aibbcedhekfngghjimjpksllmonroupxqqrtswtzu}vv\"\n assert candidate(s = \"t4s3r2q1p0o9n8m7l6k5j4i3h2g1f0\") == \"txsvrtqrppoxnvmtlrkpjnilhjghff\"\n assert candidate(s = \"a2c4e6g8i0k2m4o6q8s0u2w4y6b8d0f2h4j6l8n0p2r4t6v8x0\") == \"accgekgoiikmmqouqyssuww{ybjddfhhljpltnnprrvtzv~xx\"\n assert candidate(s = \"m1n2o3p4q5r6s7t8u9v0w1x2y3z4\") == \"mnnporptqvrxszt|u~vvwxxzy|z~\"\n assert candidate(s = \"m7l6k5j4i3h2g1f0e9d8c7b6a5\") == \"mtlrkpjnilhjghffendlcjbhaf\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j8i7h6g5f4e3d2c1b0a9\") == \"abbdcfdhejflgnhpirjriphnglfjehdfcdbbaj\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0\") == \"zƒyxw}v{uytwsursqq\"\n assert candidate(s = \"y7x6w5v4u3t2s1r0q9p8o7n6m5l4k3j2i1h0g9f8e7d6c5b4a3z2y1x0w9v8u7t6s5r4q3p2o1n0\") == \"y€x~w|vzuxtvstrrqzpxovntmrlpknjlijhhgpfneldjchbfadz|yzxxw€v~u|tzsxrvqtpropnn\"\n assert candidate(s = \"z2y4x6w8v0u2t4s6r8q0p2o4n6m8l0k2j4i6h8g0f2e4d6c8b0\") == \"z|y}x~wvvuwtxsyrzqqprosntmullkmjniohpggfheidjckbb\"\n assert candidate(s = \"a2b4c6d8e0f1g3h5i7j9\") == \"acbfcidleefggjhmipjs\"\n assert candidate(s = \"b2d3f4h5j6l7n8p9r0t1v2x3z4\") == \"bddgfjhmjplsnvpyrrtuvxx{z~\"\n assert candidate(s = \"q2r3s4t5u6v7w8x9y0z1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7\") == \"qsruswtyu{v}wxyyz{acbecgdiekfmgohqiijkkmlomqnsoupw\"\n assert candidate(s = \"x9y8z7a6b5c4d3e2f1g0h9i8j7k6l5m4n3o2p1q0r9s8t7u6\") == \"xyzagbgcgdgegfggghqiqjqkqlqmqnqoqpqqqr{s{t{u{\"\n assert candidate(s = \"t2h4n6m8g0p2r4l6t8s0q2e4v6s8g0t2l4m6b8c0t2r4l6n8m0\") == \"tvhlntmuggprrvlrt|ssqseiv|s{ggtvlpmsbjcctvrvlrnvmm\"\n assert candidate(s = \"x2y3z4a5b6c7d8e9f0g1h2i3j4\") == \"xzy|z~afbhcjdlenffghhjiljn\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0k9l8m7n6\") == \"ajbjcjdjejfjgjhjijjjktltmtnt\"\n assert candidate(s = \"n5n4n3n2n1n0n9n8n7n6\") == \"nsnrnqnpnonnnwnvnunt\"\n assert candidate(s = \"d7c6b5a4z3y2x1w0v9u8t7s6r5q4p3o2n1\") == \"dkcibgaez}y{xywwvu}t{syrwqupsoqno\"\n assert candidate(s = \"q7r5s3t1u9v7w5x3y1z9a7b5c3d1e9f7g5h3i1j9k7l5m3n1o9p7\") == \"qxrwsvtuu~v}w|x{yzzƒahbgcfdeenfmglhkijjskrlqmpnooxpw\"\n assert candidate(s = \"x2y4z6a8b0c2d4e6f8g0h2i4j6k8l0m2n4o6p8q0r2s4t6u8v0w2y4z6\") == \"xzy}z€aibbcedhekfngghjimjpksllmonroupxqqrtswtzu}vvwyy}z€\"\n assert candidate(s = \"n5m4l3k2j1i0h9g8f7e6d5c4b3a2z1y0x9w8v7u6t5s4r3q2p1o0\") == \"nsmqlokmjkiihqgofmekdicgbeacz{yyxwv}u{tyswruqspqoo\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1\") == \"abbccddeeffgghhiijjk\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p\") == \"zƒyxw}v{uytwsursqqp\"\n assert candidate(s = \"a1z2y3x4w5v6u7t8s9r0q1p2o3n4m5l6k7j8i9h0g1f2e3d4c5b6a7\") == \"abz|y|x|w|v|u|t|s|rrqrprornrmrlrkrjrirhhghfhehdhchbhah\"\n assert candidate(s = \"n9m8l7k6j5i4h3g2f1e0d9c8b7a6n9m8l7k6j5i4h3g2f1e0\") == \"nwmulskqjoimhkgifgeedmckbiagnwmulskqjoimhkgifgee\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0a1b2c3d4\") == \"abbdcfdhejflgnhpirjjabbdcfdhejflgnhpirjjabbdcfdh\"\n assert candidate(s = \"b5c3d7e2f4g6h1i5j3k7l2m4n6o1p5q3r7s2t4u6v1w5x3y7z2\") == \"bgcfdkegfjgmhiinjmkrlnmqntoppuqtrysutxu{vww|x{y€z|\"\n assert candidate(s = \"l8k7j6i5h4g3f2e1d0c9b8a7z6y5x4w3v2u1t0s9r8q7p6o5n4m3l2\") == \"ltkrjpinhlgjfhefddclbjahz€y~x|wzvxuvtts|rzqxpvotnrmpln\"\n assert candidate(s = \"z1y2x3w4v5u6t7s8r9q0p1o2n3m4\") == \"z{y{x{w{v{u{t{s{r{qqpqoqnqmq\"\n assert candidate(s = \"t2r3q4p5o6n7m8l9k0j1i2h3g4f5e6d7c8b9a0\") == \"tvruqupuounumulukkjkikhkgkfkekdkckbkaa\"\n assert candidate(s = \"t8r7e6w5q4u3i2o1p0l9k8j7h6g5f4d3c2b1a0\") == \"t|ryekw|quuxikopppluksjqhnglfjdgcebcaa\"\n assert candidate(s = \"a1c2e3g4i5k6m7o8q9s0u1w2y3\") == \"abceehgkinkqmtowqzssuvwyy|\"\n assert candidate(s = \"q9r8s7t6u5v4w3x2y1z0a9b8c7d6e5f4g3h2i1j0k9l8m7n6o5p4\") == \"qzrzsztzuzvzwzxzyzzzajbjcjdjejfjgjhjijjjktltmtntotpt\"\n assert candidate(s = \"t0u2v4w6x8y0z2a4b6c8d0e2f4g6h8i0j2k4l6m8n0o2p4q6r8s0t2u4v6w8x0y2z4\") == \"ttuwvzw}x€yyz|aebhckddegfjgmhpiijlkolrmunnoqptqwrzsstvuyv|wxxy{z~\"\n assert candidate(s = \"q2r3s4t5u6v7w8x9y0z1\") == \"qsruswtyu{v}wxyyz{\"\n assert candidate(s = \"s1t2u3v4w5x6y7z8a9b0c1d2e3f4g5h6i7j8k9l0m1n2o3p4q5\") == \"sttvuxvzw|x~y€z‚ajbbcddfehfjglhnipjrktllmnnporptqv\"\n assert candidate(s = \"b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6\") == \"bccedgeifkgmhoiqjskklmmonqospuqw\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0k9l8\") == \"ajbjcjdjejfjgjhjijjjktlt\"\n assert candidate(s = \"v9w8x7y6z5a4b3c2d1e0f9g8h7\") == \"vwxyzaebecedeeefogoho\"\n assert candidate(s = \"b5c7d9e2f0g1h3i5j7k9l1m3n5o7p9q1r3s5t7u9\") == \"bgcjdmegffghhkinjqktlmmpnsovpyqrrusxt{u~\"\n assert candidate(s = \"x9y8z7a6b5c4d3e2f1g0h9i8j7k6l5m4n3o2p1q0r9\") == \"xyzagbgcgdgegfggghqiqjqkqlqmqnqoqpqqqr{\"\n assert candidate(s = \"a9z8y7x6w5v4u3t2s1r0q9p8o7n6m5l4k3j2i1h0g9f8e7d6c5b4a3\") == \"ajz‚y€x~w|vzuxtvstrrqzpxovntmrlpknjlijhhgpfneldjchbfad\"\n assert candidate(s = \"y0x1w2v3u4t5s6r7q8p9o0n1m2l3k4j5i6h7g8f9e0d1c2b3a4\") == \"yyxywyvyuytysyryqypyoonomolokojoiohogofoeedecebeae\"\n assert candidate(s = \"n5m4l3k2j1i0h9g8f7e6d5c4b3a2\") == \"nsmqlokmjkiihqgofmekdicgbeac\"\n assert candidate(s = \"a2b4c6d8e0f2g4h6i8j0k2l4m6n8o0p2q4r6s8t0u2v4w6x8y0z2\") == \"acbfcidleefhgkhniqjjkmlpmsnvooprqurxs{ttuwvzw}x€yyz|\"\n assert candidate(s = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z2\") == \"acbdcedfegfhgihjikjlkmlnmonpoqprqsrtsutvuwvxwyxzy{z|\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0k9l8m7n6o5p4q3r2s1t0u9v8w7x6y5z4\") == \"ajbjcjdjejfjgjhjijjjktltmtntotptqtrtstttu~v~w~x~y~z~\"\n assert candidate(s = \"t1s2r3q4p5o6n7m8l9k0j1i2h3g4f5e6d7c8b9a0z1y2x3w4v5u\") == \"tusuruqupuounumulukkjkikhkgkfkekdkckbkaaz{y{x{w{v{u\"\n assert candidate(s = \"z1y2x3w4v5u6t7s8r9q0p1o2n3\") == \"z{y{x{w{v{u{t{s{r{qqpqoqnq\"\n assert candidate(s = \"y2x3w4v5u6t7s8r9q0p1o2n3m4l5k6j7i8h9g0f1e2d3c4b5a6\") == \"y{x{w{v{u{t{s{r{qqpqoqnqmqlqkqjqiqhqggfgegdgcgbgag\"\n assert candidate(s = \"y3x5w7v9u1t3s5r7q9p1o3n5m7l9k1j3i5h7g9f1e3d5c7b9a1\") == \"y|x}w~vuvtwsxryqzpqornsmtlukljminhogpfgehdicjbkab\"\n assert candidate(s = \"s9r8q7p6o5n4m3l2k1j0i9h8g7f6e5d4c3b2a1z0y9x8w7v6u5t4s3r2q1p0\") == \"s|rzqxpvotnrmplnkljjirhpgnflejdhcfbdabzzy‚x€w~v|uztxsvrtqrpp\"\n assert candidate(s = \"m8n7o6p5q4r3s2t1u0v9w8x7y6z5a4b3c2d1e0f9g8h7i6j5k4l3m2\") == \"munuoupuqurusutuuuvwxyzaebecedeeefogohoiojokolomo\"\n assert candidate(s = \"q2w3e4r5t6y7u8i9o0p1a2s3d4f5g6h7j8k9l0\") == \"qswzeirwtzy€u}iroopqacsvdhfkgmhojrktll\"\n assert candidate(s = \"b5c6d7e8f9g0h1i2j3k4l5\") == \"bgcidkemfogghiikjmkolq\"\n assert candidate(s = \"m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2g3h4i5j6k7l8\") == \"mpnrotpvqxrzs|ttuvvxwzx|y~z€ahbjclddeffhgjhlinjpkrlt\"\n assert candidate(s = \"q1w2e3r4t5y6u7i8o9p0a1s2d3f4g5\") == \"qrwyehrvtyyu|iqoxppabsudgfjgl\"\n assert candidate(s = \"q2w3e4r5t6y7u8i9o0p1a2s3d4f5g6h7j8k9l0z1x2c3v4b5n6m7\") == \"qswzeirwtzy€u}iroopqacsvdhfkgmhojrktllz{xzcfvzbgntmt\"\n assert candidate(s = \"n4m3l2k1j0i9h8g7f6e5d4c3b2a1z0y9x8w7v6u5t4s3r2q1p0\") == \"nrmplnkljjirhpgnflejdhcfbdabzzy‚x€w~v|uztxsvrtqrpp\"\n", "comparison": "exact"}, "public_tests": ["\"a1c1e1\"", "\"a1b2c3d4e\""], "hints": ["We just need to replace every even positioned character with the character s[i] positions ahead of the character preceding it", "Get the position of the preceeding character in alphabet then advance it s[i] positions and get the character at that position"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().replaceDigits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:29+00:00", "tests_total": 115, "tests_dropped": 1, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def replaceDigits(self, s: str) -> str:", "container": "Solution", "callable": "replaceDigits", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1846, "task_id": "maximum-element-after-decreasing-and-rearranging", "difficulty": "Medium", "problem_description": "You are given an array of positive integers arr. Perform some operations (possibly none) on arr so that it satisfies these conditions:\n\n- The value of the first element in arr must be 1.\n- The absolute difference between any 2 adjacent elements must be less than or equal to 1. In other words, abs(arr[i] - arr[i - 1]) <= 1 for each i where 1 <= i < arr.length (0-indexed). abs(x) is the absolute value of x.\n\nThere are 2 types of operations that you can perform any number of times:\n\n- Decrease the value of any element of arr to a smaller positive integer.\n- Rearrange the elements of arr to be in any order.\n\nReturn the maximum possible value of an element in arr after performing the operations to satisfy the conditions.\n\nExample 1:\n\nInput: arr = [2,2,1,2,1]\nOutput: 2\nExplanation:\nWe can satisfy the conditions by rearranging arr so it becomes [1,2,2,2,1].\nThe largest element in arr is 2.\n\nExample 2:\n\nInput: arr = [100,1,1000]\nOutput: 3\nExplanation:\nOne possible way to satisfy the conditions is by doing the following:\n1. Rearrange arr so it becomes [1,100,1000].\n2. Decrease the value of the second element to 2.\n3. Decrease the value of the third element to 3.\nNow arr = [1,2,3], which satisfies the conditions.\nThe largest element in arr is 3.\n\nExample 3:\n\nInput: arr = [1,2,3,4,5]\nOutput: 5\nExplanation: The array already satisfies the conditions, and the largest element is 5.\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- 1 <= arr[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [3, 2, 1]) == 3\n assert candidate(arr = [5, 4, 3, 2, 1]) == 5\n assert candidate(arr = [1, 1000000000, 2, 3, 4]) == 5\n assert candidate(arr = [9, 7, 5, 3, 1]) == 5\n assert candidate(arr = [5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [1000000000, 1, 1000000000, 1, 1000000000]) == 4\n assert candidate(arr = [1, 10, 20, 30, 40]) == 5\n assert candidate(arr = [1, 1000000000, 2, 1000000000, 3]) == 5\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [100, 1, 1000]) == 3\n assert candidate(arr = [1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [1, 10, 100, 1000, 10000]) == 5\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [2, 3, 4, 5, 6]) == 5\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [2, 2, 1, 2, 1]) == 2\n assert candidate(arr = [1, 3, 5, 7, 9]) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 4\n assert candidate(arr = [999999999, 1, 999999998, 2, 999999997, 3, 999999996, 4, 999999995, 5]) == 10\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 4\n assert candidate(arr = [1, 3, 6, 10, 15, 21]) == 6\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10]) == 10\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1]) == 7\n assert candidate(arr = [1000000000, 1, 1000000000, 1, 1000000000]) == 4\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(arr = [1, 100, 2, 101, 3, 102, 4, 103, 5, 104]) == 10\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 9]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [50, 25, 75, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 13\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 5\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1]) == 5\n assert candidate(arr = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997]) == 8\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 16\n assert candidate(arr = [1, 1000000000, 2, 999999999, 3, 999999998]) == 6\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 20\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 10\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 20\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 20\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(arr = [5, 3, 1, 4, 2]) == 5\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 15\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 5\n assert candidate(arr = [100, 50, 20, 10, 5, 2, 1, 2, 5, 10, 20, 50, 100, 150, 200, 250, 300]) == 16\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(arr = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 13\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]) == 15\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(arr = [10, 1, 2, 2, 3, 4, 5]) == 6\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 10\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 15\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n assert candidate(arr = [10, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 20\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 20\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [50, 40, 30, 20, 10, 5, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 2\n assert candidate(arr = [5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(arr = [2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7]) == 8\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 10\n assert candidate(arr = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 3\n assert candidate(arr = [50, 40, 30, 20, 10, 1, 2, 3, 4, 5]) == 10\n assert candidate(arr = [1, 999999999, 999999998, 999999997, 999999996, 999999995]) == 6\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 10\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000]) == 5\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1, 1, 1]) == 4\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(arr = [999999999, 999999998, 999999997, 999999996, 999999995, 1]) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]) == 10\n assert candidate(arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(arr = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1]) == 5\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10]) == 10\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 20\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [5, 4, 3, 2, 1, 1, 1]) == 5\n assert candidate(arr = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 11\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 100, 1000]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 30\n assert candidate(arr = [10, 5, 15, 20, 1, 3, 8]) == 7\n assert candidate(arr = [5, 4, 3, 2, 1]) == 5\n assert candidate(arr = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == 10\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5]) == 15\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 20\n assert candidate(arr = [1000000000, 1, 1000000000, 2, 1000000000, 3]) == 6\n assert candidate(arr = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 5\n assert candidate(arr = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [3, 3, 3, 3, 3, 2, 2, 2, 1, 1]) == 3\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 10\n assert candidate(arr = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(arr = [1, 1000000000, 2, 999999999, 3]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [1, 1000000000, 2, 999999999, 3, 999999998]) == 6\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 2\n assert candidate(arr = [5, 4, 3, 2, 1, 1, 1]) == 5\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 15\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5]) == 5\n assert candidate(arr = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 15\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 21\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 15\n assert candidate(arr = [1, 2, 3, 100, 200, 300, 400, 500]) == 8\n", "comparison": "exact"}, "public_tests": ["[2,2,1,2,1]", "[100,1,1000]", "[1,2,3,4,5]"], "hints": ["Sort the Array.", "Decrement each element to the largest integer that satisfies the conditions."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().maximumElementAfterDecrementingAndRearranging", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:31+00:00", "tests_total": 135, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maximumElementAfterDecrementingAndRearranging(self, arr: list[int]) -> int:", "container": "Solution", "callable": "maximumElementAfterDecrementingAndRearranging", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1847, "task_id": "closest-room", "difficulty": "Hard", "problem_description": "There is a hotel with n rooms. The rooms are represented by a 2D integer array rooms where rooms[i] = [roomId_i, size_i] denotes that there is a room with room number roomId_i and size equal to size_i. Each roomId_i is guaranteed to be unique.\n\nYou are also given k queries in a 2D array queries where queries[j] = [preferred_j, minSize_j]. The answer to the j^th query is the room number id of a room such that:\n\n- The room has a size of at least minSize_j, and\n- abs(id - preferred_j) is minimized, where abs(x) is the absolute value of x.\n\nIf there is a tie in the absolute difference, then use the room with the smallest such id. If there is no such room, the answer is -1.\n\nReturn an array answer of length k where answer[j] contains the answer to the j^th query.\n\nExample 1:\n\nInput: rooms = [[2,2],[1,2],[3,2]], queries = [[3,1],[3,3],[5,2]]\nOutput: [3,-1,3]\nExplanation: The answers to the queries are as follows:\nQuery = [3,1]: Room number 3 is the closest as abs(3 - 3) = 0, and its size of 2 is at least 1. The answer is 3.\nQuery = [3,3]: There are no rooms with a size of at least 3, so the answer is -1.\nQuery = [5,2]: Room number 3 is the closest as abs(3 - 5) = 2, and its size of 2 is at least 2. The answer is 3.\n\nExample 2:\n\nInput: rooms = [[1,4],[2,3],[3,5],[4,1],[5,2]], queries = [[2,3],[2,4],[2,5]]\nOutput: [2,1,3]\nExplanation: The answers to the queries are as follows:\nQuery = [2,3]: Room number 2 is the closest as abs(2 - 2) = 0, and its size of 3 is at least 3. The answer is 2.\nQuery = [2,4]: Room numbers 1 and 3 both have sizes of at least 4. The answer is 1 since it is smaller.\nQuery = [2,5]: Room number 3 is the only room with a size of at least 5. The answer is 3.\n\nConstraints:\n\n- n == rooms.length\n- 1 <= n <= 10^5\n- k == queries.length\n- 1 <= k <= 10^4\n- 1 <= roomId_i, preferred_j <= 10^7\n- 1 <= size_i, minSize_j <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8]],queries = [[15, 4], [25, 7], [35, 2]]) == [10, 30, 30]\n assert candidate(rooms = [[5, 5], [10, 5], [15, 5], [20, 5]],queries = [[7, 5], [12, 5], [17, 5], [22, 5]]) == [5, 10, 15, 20]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == [1, 2, 3, 4, 5, -1]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3]],queries = [[15, 3], [25, 4], [35, 5]]) == [10, 20, 10]\n assert candidate(rooms = [[2, 2], [1, 2], [3, 2]],queries = [[3, 1], [3, 3], [5, 2]]) == [3, -1, 3]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3]],queries = [[10, 5], [25, 3], [15, 4]]) == [10, 20, 10]\n assert candidate(rooms = [[5, 10], [10, 10], [15, 10]],queries = [[5, 10], [10, 10], [15, 10], [20, 10]]) == [5, 10, 15, 15]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300]],queries = [[150, 150], [250, 250], [350, 350]]) == [200, 300, -1]\n assert candidate(rooms = [[7, 10], [6, 9], [5, 8], [4, 7], [3, 6]],queries = [[7, 10], [6, 9], [5, 8], [4, 7], [3, 6]]) == [7, 6, 5, 4, 3]\n assert candidate(rooms = [[7, 10], [15, 7], [25, 12]],queries = [[10, 10], [15, 7], [30, 10]]) == [7, 15, 25]\n assert candidate(rooms = [[1, 4], [2, 3], [3, 5], [4, 1], [5, 2]],queries = [[2, 3], [2, 4], [2, 5]]) == [2, 1, 3]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],queries = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 7]],queries = [[10, 5], [25, 4], [40, 8]]) == [10, 30, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5], [15, 10], [25, 15], [35, 20], [45, 25], [55, 30], [65, 35], [75, 40], [85, 45], [95, 50]]) == [5, 10, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998]],queries = [[10000000, 10000000], [9999999, 9999999], [9999998, 9999998]]) == [1, 2, 3]\n assert candidate(rooms = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]],queries = [[1, 1500], [2, 1400], [3, 1300], [4, 1200], [5, 1100], [6, 1000], [7, 900], [8, 800], [9, 700], [10, 600]]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [[10, 5], [9, 15], [8, 25], [7, 35], [6, 45], [5, 55], [4, 65], [3, 75], [2, 85], [1, 95]]) == [10, 9, 8, 7, 6, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996], [6, 9999995], [7, 9999994], [8, 9999993], [9, 9999992], [10, 9999991]],queries = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996], [6, 9999995], [7, 9999994], [8, 9999993], [9, 9999992], [10, 9999991], [11, 9999990]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]\n assert candidate(rooms = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997], [5, 999996], [6, 999995], [7, 999994], [8, 999993], [9, 999992], [10, 999991]],queries = [[1, 1000000], [2, 1000000], [3, 1000000], [4, 1000000], [5, 1000000], [6, 1000000], [7, 1000000], [8, 1000000], [9, 1000000], [10, 1000000]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rooms = [[10000, 5000], [20000, 4000], [30000, 3000], [40000, 2000], [50000, 1000]],queries = [[5000, 3000], [15000, 2000], [25000, 1000], [35000, 500], [45000, 1]]) == [10000, 10000, 20000, 30000, 40000]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]],queries = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]\n assert candidate(rooms = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95]],queries = [[1, 1], [10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, -1]\n assert candidate(rooms = [[1, 1], [10000000, 10000000]],queries = [[5000000, 1], [5000000, 10000000], [1, 1], [10000000, 10000000], [5000000, 5000000]]) == [1, 10000000, 1, 10000000, 10000000]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],queries = [[150, 100], [250, 200], [350, 300], [450, 400], [550, 500], [650, 600], [750, 700], [850, 800], [950, 900], [1050, 1000]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(rooms = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]],queries = [[3, 1], [6, 2], [9, 3], [12, 4], [15, 5], [18, 6], [21, 7], [24, 8], [27, 9], [30, 10], [33, 11]]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, -1]\n assert candidate(rooms = [[5, 10], [10, 9], [15, 8], [20, 7], [25, 6], [30, 5], [35, 4]],queries = [[8, 7], [13, 6], [18, 5], [23, 4], [28, 3], [33, 2], [38, 1]]) == [10, 15, 20, 25, 30, 35, 35]\n assert candidate(rooms = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70], [75, 80], [85, 90], [95, 100]],queries = [[10, 5], [20, 15], [30, 25], [40, 35], [50, 45], [60, 55], [70, 65], [80, 75], [90, 85], [100, 95], [110, 105]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, -1]\n assert candidate(rooms = [[10000, 10000], [20000, 20000], [30000, 30000], [40000, 40000], [50000, 50000]],queries = [[5000, 9000], [15000, 19000], [25000, 29000], [35000, 39000], [45000, 49000]]) == [10000, 20000, 30000, 40000, 50000]\n assert candidate(rooms = [[1, 1], [10000000, 10000000], [5000000, 5000000], [1000000, 1000000], [100000, 100000], [10000, 10000], [1000, 1000], [100, 100], [10, 10], [100000000, 100000000]],queries = [[1, 1], [10000000, 10000000], [5000000, 5000000], [1000000, 1000000], [100000, 100000], [10000, 10000], [1000, 1000], [100, 100], [10, 10], [100000000, 100000000]]) == [1, 10000000, 5000000, 1000000, 100000, 10000, 1000, 100, 10, 100000000]\n assert candidate(rooms = [[1000, 5000], [2000, 4000], [3000, 3000], [4000, 2000], [5000, 1000]],queries = [[1500, 3000], [2500, 2000], [3500, 1000], [4500, 500], [5500, 1]]) == [1000, 2000, 3000, 4000, 5000]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450], [550, 550]]) == [100, 200, 300, 400, 500, -1]\n assert candidate(rooms = [[100000, 1], [100001, 1], [100002, 1], [100003, 1], [100004, 1], [100005, 1], [100006, 1], [100007, 1], [100008, 1], [100009, 1]],queries = [[100000, 2], [100001, 2], [100002, 2], [100003, 2], [100004, 2], [100005, 2], [100006, 2], [100007, 2], [100008, 2], [100009, 2]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1]\n assert candidate(rooms = [[1, 10], [10, 20], [100, 30], [1000, 40], [10000, 50]],queries = [[5, 5], [50, 15], [500, 25], [5000, 35], [50000, 45]]) == [1, 10, 100, 1000, 10000]\n assert candidate(rooms = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8]],queries = [[5, 1], [50, 2], [500, 3], [5000, 4], [50000, 5], [500000, 6], [5000000, 7], [50000000, 8], [50000000, 9], [50000000, 10]]) == [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, -1, -1]\n assert candidate(rooms = [[10000000, 10000000], [1, 1], [5000000, 5000000], [2, 2], [9999999, 9999999]],queries = [[10000000, 10000000], [5000000, 5000000], [2, 1], [10000000, 1], [1, 10000000]]) == [10000000, 5000000, 2, 10000000, 10000000]\n assert candidate(rooms = [[500, 1000], [1000, 900], [1500, 800], [2000, 700], [2500, 600], [3000, 500], [3500, 400], [4000, 300], [4500, 200], [5000, 100]],queries = [[100, 500], [600, 400], [1100, 300], [1600, 200], [2100, 100], [2600, 50], [3100, 1], [3600, 1], [4100, 1], [4600, 1]]) == [500, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500]\n assert candidate(rooms = [[1, 10], [10, 9], [100, 8], [1000, 7], [10000, 6]],queries = [[1, 10], [10, 9], [100, 8], [1000, 7], [10000, 6], [5, 5], [50, 5], [500, 5], [5000, 5], [50000, 5]]) == [1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95]]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996], [6, 9999995]]) == [1, 2, 3, 4, 5, 5]\n assert candidate(rooms = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == [5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, -1]\n assert candidate(rooms = [[1, 5], [10, 15], [20, 25], [30, 35], [40, 45], [50, 55]],queries = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65]]) == [1, 10, 20, 30, 40, 50, -1]\n assert candidate(rooms = [[100, 100], [200, 90], [300, 80], [400, 70], [500, 60], [600, 50], [700, 40], [800, 30], [900, 20], [1000, 10]],queries = [[150, 80], [250, 70], [350, 60], [450, 50], [550, 40], [650, 30], [750, 20], [850, 10], [950, 5], [1050, 1]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(rooms = [[1, 10], [20, 9], [30, 8], [40, 7], [50, 6], [60, 5], [70, 4], [80, 3], [90, 2], [100, 1]],queries = [[15, 3], [25, 4], [35, 5], [45, 6], [55, 7], [65, 8], [75, 9], [85, 10], [95, 11], [105, 12]]) == [20, 20, 30, 40, 40, 30, 20, 1, -1, -1]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]],queries = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[10000000, 1], [9999999, 2], [9999998, 3], [9999997, 4], [9999996, 5], [9999995, 6], [9999994, 7], [9999993, 8], [9999992, 9], [9999991, 10]],queries = [[9999995, 3], [9999994, 4], [9999993, 5], [9999992, 6], [9999991, 7], [9999990, 8], [9999989, 9], [9999988, 10]]) == [9999995, 9999994, 9999993, 9999992, 9999991, 9999991, 9999991, 9999991]\n assert candidate(rooms = [[1, 10], [10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10]],queries = [[5, 10], [15, 10], [25, 10], [35, 10], [45, 10], [55, 10], [65, 10], [75, 10], [85, 10], [95, 10]]) == [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]\n assert candidate(rooms = [[10000, 100], [20000, 200], [30000, 300], [40000, 400], [50000, 500], [60000, 600], [70000, 700], [80000, 800], [90000, 900], [100000, 1000]],queries = [[5000, 50], [15000, 150], [25000, 250], [35000, 350], [45000, 450], [55000, 550], [65000, 650], [75000, 750], [85000, 850], [95000, 950]]) == [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]\n assert candidate(rooms = [[1, 10000000], [2, 9000000], [3, 8000000], [4, 7000000], [5, 6000000]],queries = [[1, 10000000], [2, 9000000], [3, 8000000], [4, 7000000], [5, 6000000], [10000000, 1]]) == [1, 2, 3, 4, 5, 5]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]]) == [5, 5, 5, 5, 5, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [[1, 9999999], [2, 9999998], [3, 9999997], [4, 9999996], [5, 9999995]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[100, 100], [200, 90], [300, 80], [400, 70], [500, 60]],queries = [[150, 85], [250, 75], [350, 65], [450, 55], [550, 45]]) == [100, 200, 300, 400, 500]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [100, 9], [100, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rooms = [[1, 1], [10000000, 10000000]],queries = [[5000000, 1], [5000000, 10000000], [1, 1], [10000000, 10000000], [5000000, 5000000]]) == [1, 10000000, 1, 10000000, 10000000]\n assert candidate(rooms = [[5, 1000], [15, 900], [25, 800], [35, 700], [45, 600], [55, 500], [65, 400], [75, 300], [85, 200], [95, 100]],queries = [[10, 900], [20, 800], [30, 700], [40, 600], [50, 500], [60, 400], [70, 300], [80, 200], [90, 100], [100, 90]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [[5, 15], [15, 25], [25, 35], [35, 45], [45, 55], [55, 65], [65, 75], [75, 85], [85, 95], [95, 105]]) == [20, 30, 40, 50, 60, 70, 80, 90, 100, -1]\n assert candidate(rooms = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997], [5, 999996], [6, 999995], [7, 999994], [8, 999993], [9, 999992], [10, 999991]],queries = [[500000, 999998], [1000000, 999997], [1500000, 999996], [2000000, 999995], [2500000, 999994], [3000000, 999993], [3500000, 999992], [4000000, 999991], [4500000, 999990], [5000000, 999989]]) == [3, 4, 5, 6, 7, 8, 9, 10, 10, 10]\n assert candidate(rooms = [[10, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10]],queries = [[15, 50], [25, 40], [35, 30], [45, 20], [55, 10], [65, 5], [75, 15], [85, 25], [95, 35], [105, 45]]) == [10, 20, 30, 40, 50, 60, 70, 80, 70, 60]\n assert candidate(rooms = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50]],queries = [[3, 3], [8, 8], [13, 13], [18, 18], [23, 23], [28, 28], [33, 33], [38, 38], [43, 43], [48, 48]]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5], [1, 6]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]\n assert candidate(rooms = [[1, 1], [10000000, 10000000]],queries = [[5000000, 1], [5000000, 5000000], [5000000, 10000000], [15000000, 1]]) == [1, 10000000, 10000000, 10000000]\n assert candidate(rooms = [[100000, 10000], [200000, 9000], [300000, 8000], [400000, 7000], [500000, 6000]],queries = [[100000, 10000], [200000, 9000], [300000, 8000], [400000, 7000], [500000, 6000], [500000, 11000]]) == [100000, 200000, 300000, 400000, 500000, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]\n assert candidate(rooms = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, -1]\n assert candidate(rooms = [[10000000, 10000000], [1, 1], [5000000, 5000000]],queries = [[9999999, 9999999], [1, 1], [5000000, 5000000]]) == [10000000, 1, 5000000]\n assert candidate(rooms = [[5, 10], [15, 12], [25, 9], [35, 8], [45, 11], [55, 7]],queries = [[10, 8], [20, 9], [30, 10], [40, 11], [50, 12]]) == [5, 15, 15, 45, 15]\n assert candidate(rooms = [[100000, 10], [200000, 20], [300000, 30], [400000, 40], [500000, 50], [600000, 60], [700000, 70], [800000, 80], [900000, 90], [1000000, 100]],queries = [[50000, 10], [150000, 20], [250000, 30], [350000, 40], [450000, 50], [550000, 60], [650000, 70], [750000, 80], [850000, 90], [950000, 100]]) == [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]\n assert candidate(rooms = [[1, 10000], [2, 10000], [3, 10000], [4, 10000], [5, 10000]],queries = [[1, 9000], [2, 9000], [3, 9000], [4, 9000], [5, 9000], [6, 9000], [7, 9000], [8, 9000], [9, 9000]]) == [1, 2, 3, 4, 5, 5, 5, 5, 5]\n assert candidate(rooms = [[1000000, 1000000], [999999, 999999], [999998, 999998], [999997, 999997], [999996, 999996], [999995, 999995]],queries = [[1000000, 1000000], [1000000, 999999], [1000000, 999998], [1000000, 999997], [1000000, 999996], [1000000, 999995], [1000000, 1], [1000000, 2], [1000000, 3], [1000000, 4]]) == [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]\n assert candidate(rooms = [[100, 50], [200, 60], [300, 70], [400, 80], [500, 90]],queries = [[150, 55], [250, 65], [350, 75], [450, 85], [550, 95]]) == [200, 300, 400, 500, -1]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [[5, 15], [6, 25], [7, 35], [8, 45], [9, 55], [10, 65], [11, 75], [12, 85], [13, 95], [14, 105], [15, 115]]) == [5, 6, 7, 8, 9, 10, 10, 10, 10, -1, -1]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [[1, 5], [2, 15], [3, 25], [4, 35], [5, 45], [6, 55], [7, 65], [8, 75], [9, 85], [10, 95]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[150, 150], [250, 250], [350, 350], [450, 450], [550, 550]]) == [200, 300, 400, 500, -1]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]\n assert candidate(rooms = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9], [1000, 10]],queries = [[50, 1], [150, 2], [250, 3], [350, 4], [450, 5], [550, 6], [650, 7], [750, 8], [850, 9], [950, 10], [1050, 11]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 1]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50], [600, 60], [700, 70], [800, 80], [900, 90], [1000, 100]],queries = [[50, 10], [150, 20], [250, 30], [350, 40], [450, 50], [550, 60], [650, 70], [750, 80], [850, 90], [950, 100], [1050, 10]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000]\n assert candidate(rooms = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5], [11, 5], [12, 5], [13, 5], [14, 5], [15, 5]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]\n assert candidate(rooms = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]],queries = [[3, 1], [8, 2], [13, 3], [18, 4], [23, 5], [28, 6], [33, 7], [38, 8], [43, 9], [48, 10], [55, 11]]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5], [5, 6], [5, 4], [5, 7], [5, 3]]) == [5, 6, 5, 7, 5]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[10, 20], [20, 20], [30, 20], [40, 20], [50, 20], [60, 20], [70, 20], [80, 20], [90, 20], [100, 20]],queries = [[5, 10], [15, 10], [25, 10], [35, 10], [45, 10], [55, 10], [65, 10], [75, 10], [85, 10], [95, 10]]) == [10, 10, 20, 30, 40, 50, 60, 70, 80, 90]\n assert candidate(rooms = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9], [1000, 10]],queries = [[50, 5], [150, 15], [250, 25], [350, 35], [450, 45], [550, 55], [650, 65], [750, 75], [850, 85], [950, 95]]) == [500, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],queries = [[10, 1], [9, 1], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1]]) == [9, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rooms = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997], [5, 999996], [6, 999995], [7, 999994], [8, 999993], [9, 999992], [10, 999991]],queries = [[1, 999991], [2, 999992], [3, 999993], [4, 999994], [5, 999995], [6, 999996], [7, 999997], [8, 999998], [9, 999999], [10, 1000000]]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]) == [1, 2, 3, 4, 5, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [1, 2, 3, 2, 1, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [[1, 9999999], [2, 9999998], [3, 9999997], [4, 9999996], [5, 9999995], [6, 9999994], [7, 9999993]]) == [1, 2, 3, 4, 5, 5, 5]\n assert candidate(rooms = [[1000, 1], [2000, 2], [3000, 3], [4000, 4], [5000, 5], [6000, 6], [7000, 7], [8000, 8], [9000, 9], [10000, 10]],queries = [[500, 1], [1500, 2], [2500, 3], [3500, 4], [4500, 5], [5500, 6], [6500, 7], [7500, 8], [8500, 9], [9500, 10]]) == [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]\n assert candidate(rooms = [[10000000, 1], [9000000, 2], [8000000, 3], [7000000, 4], [6000000, 5], [5000000, 6], [4000000, 7], [3000000, 8], [2000000, 9], [1000000, 10]],queries = [[500000, 1], [1500000, 2], [2500000, 3], [3500000, 4], [4500000, 5], [5500000, 6], [6500000, 7], [7500000, 8], [8500000, 9], [9500000, 10], [10500000, 1]]) == [1000000, 1000000, 2000000, 3000000, 4000000, 5000000, 4000000, 3000000, 2000000, 1000000, 10000000]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10]]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1]\n assert candidate(rooms = [[1, 10000], [2, 9000], [3, 8000], [4, 7000], [5, 6000], [6, 5000], [7, 4000], [8, 3000], [9, 2000], [10, 1000]],queries = [[1, 10000], [2, 9000], [3, 8000], [4, 7000], [5, 6000], [6, 5000], [7, 4000], [8, 3000], [9, 2000], [10, 1000], [11, 500]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]\n assert candidate(rooms = [[1000, 10], [2000, 20], [3000, 30], [4000, 40], [5000, 50]],queries = [[1500, 5], [2500, 15], [3500, 25], [4500, 35], [5500, 45]]) == [1000, 2000, 3000, 4000, 5000]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[1, 1], [3, 3], [5, 5]],queries = [[2, 2], [4, 4]]) == [3, 5]\n assert candidate(rooms = [[10, 5], [20, 5], [30, 5], [40, 5], [50, 5]],queries = [[15, 5], [25, 5], [35, 5], [45, 5], [55, 5]]) == [10, 20, 30, 40, 50]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30]],queries = [[1, 10], [2, 20], [3, 30]]) == [1, 2, 3]\n assert candidate(rooms = [[5, 10], [10, 10], [15, 10]],queries = [[7, 5], [12, 5], [17, 5]]) == [5, 10, 15]\n assert candidate(rooms = [[7, 10], [15, 20], [25, 30]],queries = [[10, 10], [20, 20], [30, 30], [40, 40]]) == [7, 15, 25, -1]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[15, 10], [25, 20], [35, 30]]) == [10, 20, 30]\n assert candidate(rooms = [[5, 5], [15, 15], [25, 25], [35, 35]],queries = [[10, 5], [20, 15], [30, 25], [40, 35]]) == [5, 15, 25, 35]\n assert candidate(rooms = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5]],queries = [[1, 1], [6, 2], [11, 3], [16, 4], [21, 5], [26, 6]]) == [5, 10, 15, 20, 25, -1]\n assert candidate(rooms = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5]],queries = [[3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == [3, 3, 3, 2, 1]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[7, 7], [14, 14], [21, 21], [28, 28]],queries = [[7, 7], [14, 14], [21, 21], [28, 28], [35, 35]]) == [7, 14, 21, 28, -1]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [[3, 5], [3, 15], [3, 25], [3, 35], [3, 45]]) == [3, 3, 3, 4, 5]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8]],queries = [[15, 3], [25, 7], [10, 5]]) == [10, 30, 10]\n assert candidate(rooms = [[1, 10000000]],queries = [[1, 10000000], [1, 9999999], [1, 10000001]]) == [1, 1, -1]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[15, 10], [25, 15], [35, 25]]) == [10, 20, 30]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 5000000], [10000000, 1], [1, 10000000]]) == [1, 10000000, 1]\n assert candidate(rooms = [[7, 7], [17, 17], [27, 27], [37, 37]],queries = [[5, 7], [15, 17], [25, 27], [35, 37]]) == [7, 17, 27, 37]\n assert candidate(rooms = [[1, 10], [10, 1], [2, 9], [9, 2], [3, 8], [8, 3]],queries = [[5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [3, 3, 8, 8, 9]\n assert candidate(rooms = [[7, 10], [5, 15], [12, 20], [3, 25]],queries = [[6, 15], [8, 10], [15, 20]]) == [5, 7, 12]\n assert candidate(rooms = [[5, 10], [6, 11], [7, 12]],queries = [[5, 10], [6, 11], [7, 12]]) == [5, 6, 7]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300]],queries = [[150, 150], [250, 250], [50, 50]]) == [200, 300, 100]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],queries = [[3, 5], [3, 10], [3, 15]]) == [3, 3, -1]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50]],queries = [[150, 15], [250, 25], [350, 35], [450, 45], [550, 55]]) == [200, 300, 400, 500, -1]\n assert candidate(rooms = [[5, 10], [15, 8], [25, 12], [35, 9]],queries = [[10, 10], [20, 8], [30, 12], [40, 9]]) == [5, 15, 25, 35]\n assert candidate(rooms = [[100, 100], [200, 100], [300, 100]],queries = [[150, 100], [250, 100], [50, 100]]) == [100, 200, 100]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 5000000], [10000000, 10000000], [1, 1]]) == [1, 1, 1]\n assert candidate(rooms = [[7, 7], [8, 8], [9, 9]],queries = [[10, 10], [11, 11], [12, 12]]) == [-1, -1, -1]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30]],queries = [[150, 15], [250, 25], [50, 5], [350, 35]]) == [200, 300, 100, -1]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [[1, 5], [2, 15], [3, 25], [4, 35], [5, 45]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],queries = [[15, 1], [25, 2], [35, 3], [45, 4]]) == [10, 20, 30, 40]\n assert candidate(rooms = [[10, 5], [20, 5], [30, 5]],queries = [[25, 5], [15, 5], [5, 5], [35, 5]]) == [20, 10, 10, 30]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[1, 1], [10000000, 10000000], [5000000, 5000000]]) == [1, 1, 1]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998]],queries = [[2, 9999999], [1, 10000000], [3, 9999998]]) == [2, 1, 3]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(rooms = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],queries = [[3, 3], [2, 2], [1, 1], [6, 6], [0, 0]]) == [3, 2, 1, -1, 1]\n assert candidate(rooms = [[1, 1]],queries = [[1, 1], [2, 1], [3, 1]]) == [1, 1, 1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6]]) == [3, 3, 3, 4, 5, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 7]],queries = [[15, 3], [25, 6], [35, 8]]) == [10, 30, -1]\n assert candidate(rooms = [[100000, 100000], [1, 1], [50000, 50000]],queries = [[100000, 100000], [1, 1], [50000, 50000], [25000, 50000]]) == [100000, 1, 50000, 50000]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998]],queries = [[1, 10000000], [2, 9999999], [3, 9999998]]) == [1, 2, 3]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [[3, 15], [3, 25], [3, 35], [3, 45], [3, 55]]) == [3, 3, 4, 5, -1]\n assert candidate(rooms = [[5, 10], [15, 10], [25, 10]],queries = [[10, 10], [20, 10], [30, 10]]) == [5, 15, 25]\n assert candidate(rooms = [[5, 5], [5, 5], [5, 5]],queries = [[5, 5], [5, 5], [5, 5]]) == [5, 5, 5]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],queries = [[3, 10], [3, 11], [3, 9]]) == [3, -1, 3]\n assert candidate(rooms = [[10000000, 1], [9999999, 2], [9999998, 3]],queries = [[10000000, 1], [9999999, 2], [9999998, 3]]) == [10000000, 9999999, 9999998]\n assert candidate(rooms = [[10, 5], [20, 7], [30, 9]],queries = [[15, 6], [25, 8], [35, 10]]) == [20, 30, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 7], [40, 2], [50, 6]],queries = [[15, 4], [25, 3], [35, 5], [45, 2]]) == [10, 20, 30, 40]\n assert candidate(rooms = [[5, 5], [6, 6], [7, 7]],queries = [[5, 6], [6, 7], [7, 8]]) == [6, 7, -1]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[1, 10000000], [2, 10000000], [3, 10000000]],queries = [[1, 10000000], [2, 10000000], [3, 10000000]]) == [1, 2, 3]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [5, 6, 7, 8, 9]\n assert candidate(rooms = [[7, 7], [8, 8], [9, 9]],queries = [[7, 7], [8, 8], [9, 9], [10, 10]]) == [7, 8, 9, -1]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 1], [5000000, 10000000], [1, 1], [10000000, 1]]) == [1, 1, 1, 10000000]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 5000000], [10000000, 10000000]]) == [1, 1]\n assert candidate(rooms = [[5, 5], [3, 3], [1, 1], [7, 7]],queries = [[4, 4], [6, 6], [2, 2], [8, 8]]) == [5, 7, 3, -1]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30]],queries = [[150, 15], [250, 25], [350, 35]]) == [200, 300, -1]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]],queries = [[15, 4], [25, 3], [35, 2], [45, 1], [55, 1]]) == [10, 20, 30, 40, 50]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],queries = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10]]) == [1, 2, 3, 4, 5, 5]\n assert candidate(rooms = [[100, 100], [200, 90], [300, 80], [400, 70], [500, 60]],queries = [[150, 90], [250, 80], [350, 70]]) == [100, 200, 300]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 3], [1, 1], [2, 2], [4, 4], [5, 5]]) == [3, 1, 2, 4, 5]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 4], [40, 2]],queries = [[25, 3], [15, 5], [35, 4]]) == [20, 10, 30]\n assert candidate(rooms = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9]],queries = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9]]) == [1, 3, 5, 7, 9]\n assert candidate(rooms = [[1, 100], [100, 1], [50, 50]],queries = [[50, 1], [50, 50], [50, 100]]) == [50, 50, 1]\n assert candidate(rooms = [[5, 10], [10, 10], [15, 10], [20, 10], [25, 10]],queries = [[7, 5], [12, 8], [17, 11], [22, 14], [27, 17]]) == [5, 10, -1, -1, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 4], [40, 6]],queries = [[25, 3], [15, 5], [35, 4]]) == [20, 10, 30]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30], [400, 40]],queries = [[150, 5], [250, 15], [350, 25], [450, 35]]) == [100, 200, 300, 400]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 6], [40, 4]],queries = [[15, 4], [25, 5], [35, 6]]) == [10, 30, 30]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[15, 5], [25, 25], [35, 15]]) == [10, 30, 30]\n assert candidate(rooms = [[1000, 1000], [2000, 1000], [3000, 1000]],queries = [[1500, 1000], [2500, 1000], [500, 1000]]) == [1000, 2000, 1000]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30]],queries = [[1, 5], [2, 15], [3, 25]]) == [1, 2, 3]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5]],queries = [[1, 6], [2, 6], [3, 6]]) == [-1, -1, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 4], [40, 2]],queries = [[15, 3], [25, 4], [35, 5]]) == [10, 30, 10]\n assert candidate(rooms = [[10, 5], [20, 6], [30, 7]],queries = [[15, 5], [25, 6], [35, 7]]) == [10, 20, 30]\n assert candidate(rooms = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],queries = [[5, 5], [15, 4], [25, 3], [35, 2], [45, 1], [55, 6]]) == [50, 40, 30, 30, 40, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8], [40, 7]],queries = [[15, 4], [25, 6], [35, 7]]) == [10, 30, 30]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],queries = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [1, 2, 3, 3, 2]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == [5, 4, 3, 4, 5]\n assert candidate(rooms = [[100, 1], [200, 2], [300, 3]],queries = [[99, 1], [199, 2], [299, 3]]) == [100, 200, 300]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[15, 5], [25, 15], [35, 25]]) == [10, 20, 30]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 5000000], [1, 1], [10000000, 10000000]]) == [1, 1, 1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8]],queries = [[15, 4], [25, 3], [35, 9]]) == [10, 20, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == [3, 3, 3, 4, 5]\n assert candidate(rooms = [[5, 10], [15, 20], [25, 30]],queries = [[10, 15], [20, 25], [30, 35]]) == [15, 25, -1]\n assert candidate(rooms = [[1, 5], [3, 5], [5, 5], [7, 5], [9, 5]],queries = [[2, 5], [4, 5], [6, 5], [8, 5]]) == [1, 3, 5, 7]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30]],queries = [[50, 5], [150, 15], [250, 25]]) == [100, 200, 300]\n assert candidate(rooms = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50]],queries = [[10, 5], [20, 15], [30, 25], [40, 35], [50, 45]]) == [5, 15, 25, 35, 45]\n assert candidate(rooms = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],queries = [[5, 1], [15, 2], [25, 3], [35, 4], [45, 5]]) == [10, 20, 30, 40, 50]\n assert candidate(rooms = [[5, 10], [15, 15], [25, 20], [35, 25], [45, 30]],queries = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == [5, 25, 45, -1, -1]\n assert candidate(rooms = [[1, 1], [10, 10], [100, 100]],queries = [[5, 1], [50, 10], [500, 100], [5000, 50]]) == [1, 10, 100, 100]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8]],queries = [[15, 3], [25, 6], [35, 10]]) == [10, 30, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[10000000, 10000000]],queries = [[10000000, 10000000], [9999999, 10000000], [10000001, 10000000]]) == [10000000, 10000000, 10000000]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]],queries = [[15, 2], [25, 3], [35, 4]]) == [10, 20, 20]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400]],queries = [[150, 100], [250, 200], [350, 300], [450, 400]]) == [100, 200, 300, 400]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 1], [4, 2], [5, 3], [6, 4], [7, 5]]) == [3, 4, 5, 5, 5]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [[1, 1], [5, 5], [10, 10]]) == [1, 5, 1]\n assert candidate(rooms = [[1, 5], [2, 6], [3, 7]],queries = [[1, 6], [2, 7], [3, 8]]) == [2, 3, -1]\n assert candidate(rooms = [[5, 5], [15, 15], [25, 25], [35, 35]],queries = [[10, 10], [20, 20], [30, 30], [40, 40]]) == [15, 25, 35, -1]\n assert candidate(rooms = [[7, 7], [8, 8], [9, 9]],queries = [[7, 7], [8, 8], [9, 9], [6, 6], [10, 10]]) == [7, 8, 9, 7, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [1, 2, 3, 2, 1]\n assert candidate(rooms = [[1, 10000000], [2, 10000000], [3, 10000000]],queries = [[1, 10000000], [2, 10000000], [3, 10000000], [4, 10000000]]) == [1, 2, 3, 3]\n assert candidate(rooms = [[10000000, 10000000]],queries = [[10000000, 10000000], [9999999, 9999999], [10000001, 10000001]]) == [10000000, 10000000, -1]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10]],queries = [[1, 5], [2, 10], [3, 15]]) == [1, 2, -1]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400]],queries = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450]]) == [100, 200, 300, 400, -1]\n assert candidate(rooms = [[1000, 100], [2000, 200], [3000, 300], [4000, 400]],queries = [[1500, 50], [2500, 150], [3500, 250], [4500, 350]]) == [1000, 2000, 3000, 4000]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 2], [4, 3], [5, 4]]) == [3, 4, 5]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3]],queries = [[15, 4], [25, 3], [5, 6]]) == [10, 20, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[6, 1], [7, 2], [8, 3], [9, 4], [10, 5]]) == [5, 5, 5, 5, 5]\n assert candidate(rooms = [[10, 5], [20, 5], [30, 5]],queries = [[15, 5], [25, 5], [5, 5]]) == [10, 20, 10]\n assert candidate(rooms = [[1, 10000000], [2, 10000000], [3, 10000000], [4, 10000000], [5, 10000000]],queries = [[3, 10000000], [3, 10000001], [3, 9999999]]) == [3, -1, 3]\n assert candidate(rooms = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],queries = [[50, 1], [150, 2], [250, 3], [350, 4], [450, 5]]) == [100, 200, 300, 400, 500]\n assert candidate(rooms = [[10000000, 10000000]],queries = [[10000000, 10000000]]) == [10000000]\n assert candidate(rooms = [[10000000, 10000000], [1, 1]],queries = [[10000000, 10000000], [2, 1]]) == [10000000, 1]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[25, 15], [15, 10], [35, 25]]) == [20, 10, 30]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 3], [3, 4], [3, 5], [3, 6], [3, 2], [3, 1]]) == [3, 4, 5, -1, 3, 3]\n assert candidate(rooms = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]],queries = [[7, 6], [12, 11], [17, 16], [22, 21], [27, 26]]) == [10, 15, 20, 25, -1]\n", "comparison": "exact"}, "public_tests": ["[[2,2],[1,2],[3,2]]\n[[3,1],[3,3],[5,2]]", "[[1,4],[2,3],[3,5],[4,1],[5,2]]\n[[2,3],[2,4],[2,5]]"], "hints": ["Is there a way to sort the queries so it's easier to search the closest room larger than the size?", "Use binary search to speed up the search time."], "metadata": {"canonical_parameter_names": ["rooms", "queries"], "leetcode_dataset_entry_point": "Solution().closestRoom", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:34+00:00", "tests_total": 213, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "binary-search", "sorting", "ordered-set"]}, "language": "python", "interface": {"raw_signature": "def closestRoom(self, rooms: list[list[int]], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "closestRoom", "parameters": [{"name": "rooms", "type": "list[list[int]]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1848, "task_id": "minimum-distance-to-the-target-element", "difficulty": "Easy", "problem_description": "Given an integer array nums (0-indexed) and two integers target and start, find an index i such that nums[i] == target and abs(i - start) is minimized. Note that abs(x) is the absolute value of x.\n\nReturn abs(i - start).\n\nIt is guaranteed that target exists in nums.\n\nExample 1:\n\nInput: nums = [1,2,3,4,5], target = 5, start = 3\nOutput: 1\nExplanation: nums[4] = 5 is the only value equal to target, so the answer is abs(4 - 3) = 1.\n\nExample 2:\n\nInput: nums = [1], target = 1, start = 0\nOutput: 0\nExplanation: nums[0] = 1 is the only value equal to target, so the answer is abs(0 - 0) = 0.\n\nExample 3:\n\nInput: nums = [1,1,1,1,1,1,1,1,1,1], target = 1, start = 0\nOutput: 0\nExplanation: Every value of nums is 1, but nums[0] minimizes abs(i - start), which is abs(0 - 0) = 0.\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 1 <= nums[i] <= 10^4\n- 0 <= start < nums.length\n- target is in nums.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 1, 4, 1],target = 1,start = 2) == 1\n assert candidate(nums = [1, 5, 3, 4, 5],target = 5,start = 2) == 1\n assert candidate(nums = [4, 1, 3, 5, 2],target = 2,start = 1) == 3\n assert candidate(nums = [4, 1, 3, 5, 6],target = 3,start = 1) == 1\n assert candidate(nums = [4, 1, 3, 5, 2],target = 1,start = 2) == 1\n assert candidate(nums = [5, 1, 4, 1, 2],target = 1,start = 0) == 1\n assert candidate(nums = [1],target = 1,start = 0) == 0\n assert candidate(nums = [4, 1, 3, 5, 6],target = 1,start = 2) == 1\n assert candidate(nums = [5, 1, 4, 1, 2],target = 1,start = 1) == 0\n assert candidate(nums = [5, 1, 4, 1, 2],target = 1,start = 2) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1,start = 0) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],target = 5,start = 3) == 1\n assert candidate(nums = [7, 8, 9, 5, 6, 5, 4, 5, 3, 5],target = 5,start = 4) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15,start = 9) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5,start = 9) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 500,start = 3) == 1\n assert candidate(nums = [7, 2, 5, 8, 3, 9, 1, 5],target = 5,start = 4) == 2\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],target = 18,start = 8) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 19,start = 4) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 30,start = 0) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 2,start = 15) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 10,start = 19) == 10\n assert candidate(nums = [1, 3, 5, 2, 4, 3, 2, 1, 3],target = 3,start = 5) == 0\n assert candidate(nums = [10, 23, 56, 78, 90, 12, 34, 56, 78, 90],target = 56,start = 5) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2,start = 10) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],target = 15,start = 20) == 6\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 700,start = 0) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 60,start = 5) == 0\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 20,start = 15) == 15\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 7,start = 9) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 10,start = 14) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 1,start = 9) == 9\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 15,start = 9) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 15,start = 4) == 3\n assert candidate(nums = [5, 3, 8, 6, 2, 10, 1, 4],target = 10,start = 3) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 12,start = 10) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15,start = 0) == 14\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 1,start = 5) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 50,start = 2) == 2\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],target = 997,start = 2) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 35,start = 9) == 3\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 3,start = 15) == 0\n assert candidate(nums = [5, 2, 3, 4, 5, 1, 5],target = 5,start = 3) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 16,start = 0) == 7\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 7],target = 7,start = 5) == 4\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5],target = 1,start = 4) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 2,start = 9) == 9\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],target = 4,start = 10) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 10,start = 7) == 2\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],target = 93,start = 8) == 2\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 12,start = 3) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 13,start = 19) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],target = 15,start = 0) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 39,start = 0) == 19\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],target = 65,start = 5) == 1\n assert candidate(nums = [1000, 500, 250, 125, 63, 31, 16, 8, 4, 2, 1],target = 16,start = 5) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 500,start = 9) == 5\n assert candidate(nums = [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59],target = 50,start = 14) == 9\n assert candidate(nums = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3],target = 1,start = 4) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2],target = 10,start = 9) == 5\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 10,start = 0) == 10\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 60,start = 4) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 7,start = 7) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 40,start = 0) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 19,start = 9) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10,start = 0) == 9\n assert candidate(nums = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],target = 1,start = 19) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1],target = 9,start = 4) == 0\n assert candidate(nums = [5, 3, 2, 5, 3, 5, 2, 5, 3, 5],target = 3,start = 4) == 0\n assert candidate(nums = [1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2,start = 7) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = 19,start = 12) == 3\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981],target = 985,start = 15) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 500,start = 9) == 5\n assert candidate(nums = [3, 4, 2, 5, 1, 5, 3, 2, 5],target = 5,start = 4) == 1\n assert candidate(nums = [7, 1, 3, 4, 2, 5, 7, 6, 7, 8],target = 7,start = 5) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10,start = 5) == 8\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5,start = 10) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15,start = 10) == 4\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7],target = 2,start = 6) == 1\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],target = 4,start = 9) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009],target = 1009,start = 2) == 7\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 18,start = 10) == 2\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5],target = 2,start = 4) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 1,start = 19) == 19\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 7,start = 15) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 13,start = 5) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],target = 23,start = 0) == 8\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],target = 15,start = 5) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 10,start = 7) == 2\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15],target = 12,start = 3) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 30,start = 5) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 7,start = 0) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 3,start = 8) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],target = 25,start = 15) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 10,start = 0) == 9\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],target = 3,start = 6) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5,start = 5) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 1,start = 19) == 19\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 18,start = 9) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 18,start = 12) == 4\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 7,start = 3) == 1\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29],target = 20,start = 4) == 2\n assert candidate(nums = [10, 22, 33, 44, 55, 66, 77, 88, 99],target = 88,start = 0) == 7\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5]\n5\n3", "[1]\n1\n0", "[5,3,6]\n5\n2"], "hints": ["Loop in both directions until you find the target element.", "For each index i such that nums[i] == target calculate abs(i - start)."], "metadata": {"canonical_parameter_names": ["nums", "target", "start"], "leetcode_dataset_entry_point": "Solution().getMinDistance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:36+00:00", "tests_total": 117, "tests_dropped": 14, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def getMinDistance(self, nums: list[int], target: int, start: int) -> int:", "container": "Solution", "callable": "getMinDistance", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "target", "type": "int"}, {"name": "start", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1849, "task_id": "splitting-a-string-into-descending-consecutive-values", "difficulty": "Medium", "problem_description": "You are given a string s that consists of only digits.\n\nCheck if we can split s into two or more non-empty substrings such that the numerical values of the substrings are in descending order and the difference between numerical values of every two adjacent substrings is equal to 1.\n\n- For example, the string s = \"0090089\" can be split into [\"0090\", \"089\"] with numerical values [90,89]. The values are in descending order and adjacent values differ by 1, so this way is valid.\n- Another example, the string s = \"001\" can be split into [\"0\", \"01\"], [\"00\", \"1\"], or [\"0\", \"0\", \"1\"]. However all the ways are invalid because they have numerical values [0,1], [0,1], and [0,0,1] respectively, all of which are not in descending order.\n\nReturn true if it is possible to split s as described above, or false otherwise.\n\nA substring is a contiguous sequence of characters in a string.\n\nExample 1:\n\nInput: s = \"1234\"\nOutput: false\nExplanation: There is no valid way to split s.\n\nExample 2:\n\nInput: s = \"050043\"\nOutput: true\nExplanation: s can be split into [\"05\", \"004\", \"3\"] with numerical values [5,4,3].\nThe values are in descending order with adjacent values differing by 1.\n\nExample 3:\n\nInput: s = \"9080701\"\nOutput: false\nExplanation: There is no valid way to split s.\n\nConstraints:\n\n- 1 <= s.length <= 20\n- s only consists of digits.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"21\") == True\n assert candidate(s = \"9876543210\") == True\n assert candidate(s = \"050043\") == True\n assert candidate(s = \"989796959493929190\") == True\n assert candidate(s = \"1009998\") == True\n assert candidate(s = \"2120191817\") == True\n assert candidate(s = \"1201100009\") == False\n assert candidate(s = \"212120\") == False\n assert candidate(s = \"10010\") == False\n assert candidate(s = \"0000\") == False\n assert candidate(s = \"1234\") == False\n assert candidate(s = \"11110\") == False\n assert candidate(s = \"111121111\") == False\n assert candidate(s = \"1111111111\") == False\n assert candidate(s = \"989796\") == True\n assert candidate(s = \"1010\") == False\n assert candidate(s = \"9080701\") == False\n assert candidate(s = \"98765432109\") == False\n assert candidate(s = \"1001000\") == False\n assert candidate(s = \"543210\") == True\n assert candidate(s = \"1\") == False\n assert candidate(s = \"101010\") == False\n assert candidate(s = \"1000999898\") == False\n assert candidate(s = \"00000\") == False\n assert candidate(s = \"001\") == False\n assert candidate(s = \"5432109876543210\") == False\n assert candidate(s = \"100999989876543210\") == False\n assert candidate(s = \"22222222222222222221\") == True\n assert candidate(s = \"99887766554433221100\") == False\n assert candidate(s = \"11111111111111111112\") == False\n assert candidate(s = \"987876757473727170\") == False\n assert candidate(s = \"987654321987654320\") == True\n assert candidate(s = \"09080706050403020100\") == True\n assert candidate(s = \"123432109876543210\") == False\n assert candidate(s = \"98765432100987654321\") == False\n assert candidate(s = \"1098765432110987654\") == False\n assert candidate(s = \"9080706050403020100\") == True\n assert candidate(s = \"99999999999999999999\") == False\n assert candidate(s = \"11111111111111111111\") == False\n assert candidate(s = \"98765432109876543210\") == False\n assert candidate(s = \"10010010010010010010\") == False\n assert candidate(s = \"8070605040302010\") == True\n assert candidate(s = \"987654321987654321\") == False\n assert candidate(s = \"987654321000000\") == True\n assert candidate(s = \"9876543210987654321\") == False\n assert candidate(s = \"54321543215432154321\") == False\n assert candidate(s = \"12345678909876543210\") == False\n assert candidate(s = \"00000000000000000000\") == False\n assert candidate(s = \"9876556789\") == False\n assert candidate(s = \"9876543210123456789\") == False\n assert candidate(s = \"00000000000000000001\") == False\n assert candidate(s = \"12341233123212311230\") == True\n assert candidate(s = \"9879876543210\") == False\n assert candidate(s = \"000000001000000000\") == True\n", "comparison": "exact"}, "public_tests": ["\"1234\"", "\"050043\"", "\"9080701\""], "hints": ["One solution is to try all possible splits using backtrack", "Look out for trailing zeros in string"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().splitString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:38+00:00", "tests_total": 135, "tests_dropped": 81, "flags": [], "topic_tags": ["string", "backtracking", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def splitString(self, s: str) -> bool:", "container": "Solution", "callable": "splitString", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1850, "task_id": "minimum-adjacent-swaps-to-reach-the-kth-smallest-number", "difficulty": "Medium", "problem_description": "You are given a string num, representing a large integer, and an integer k.\n\nWe call some integer wonderful if it is a permutation of the digits in num and is greater in value than num. There can be many wonderful integers. However, we only care about the smallest-valued ones.\n\n- For example, when num = \"5489355142\":\n - The 1^st smallest wonderful integer is \"5489355214\".\n - The 2^nd smallest wonderful integer is \"5489355241\".\n - The 3^rd smallest wonderful integer is \"5489355412\".\n - The 4^th smallest wonderful integer is \"5489355421\".\n\nReturn the minimum number of adjacent digit swaps that needs to be applied to num to reach the k^th smallest wonderful integer.\n\nThe tests are generated in such a way that k^th smallest wonderful integer exists.\n\nExample 1:\n\nInput: num = \"5489355142\", k = 4\nOutput: 2\nExplanation: The 4^th smallest wonderful number is \"5489355421\". To get this number:\n- Swap index 7 with index 8: \"5489355142\" -> \"5489355412\"\n- Swap index 8 with index 9: \"5489355412\" -> \"5489355421\"\n\nExample 2:\n\nInput: num = \"11112\", k = 4\nOutput: 4\nExplanation: The 4^th smallest wonderful number is \"21111\". To get this number:\n- Swap index 3 with index 4: \"11112\" -> \"11121\"\n- Swap index 2 with index 3: \"11121\" -> \"11211\"\n- Swap index 1 with index 2: \"11211\" -> \"12111\"\n- Swap index 0 with index 1: \"12111\" -> \"21111\"\n\nExample 3:\n\nInput: num = \"00123\", k = 1\nOutput: 1\nExplanation: The 1^st smallest wonderful number is \"00132\". To get this number:\n- Swap index 3 with index 4: \"00123\" -> \"00132\"\n\nConstraints:\n\n- 2 <= num.length <= 1000\n- 1 <= k <= 1000\n- num only consists of digits.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"111222333\",k = 10) == 3\n assert candidate(num = \"1234567890\",k = 5) == 2\n assert candidate(num = \"1111111111\",k = 5) == 0\n assert candidate(num = \"9876543210\",k = 3) == 0\n assert candidate(num = \"5489355142\",k = 4) == 2\n assert candidate(num = \"321\",k = 2) == 0\n assert candidate(num = \"1000001\",k = 2) == 2\n assert candidate(num = \"343123\",k = 3) == 2\n assert candidate(num = \"00123\",k = 1) == 1\n assert candidate(num = \"12345678901234567890\",k = 10) == 5\n assert candidate(num = \"9999999999\",k = 1) == 0\n assert candidate(num = \"9876543210\",k = 5) == 0\n assert candidate(num = \"1234567890\",k = 3) == 3\n assert candidate(num = \"321\",k = 1) == 0\n assert candidate(num = \"11112\",k = 4) == 4\n assert candidate(num = \"000000000000000000000000000000000000000000000000\",k = 1) == 0\n assert candidate(num = \"12345678901234567890123456789012345678901234567890\",k = 500) == 11\n assert candidate(num = \"00000000001111111111\",k = 500) == 28\n assert candidate(num = \"12345678901234567890\",k = 1000) == 9\n assert candidate(num = \"111112222233333\",k = 500) == 9\n assert candidate(num = \"123456789012345678901234567890\",k = 50) == 3\n assert candidate(num = \"1234567890987654321012345678909876543210\",k = 100) == 39\n assert candidate(num = \"00000000000000000000000000000000000000000000000001\",k = 1) == 1\n assert candidate(num = \"01234567890123456789\",k = 500) == 8\n assert candidate(num = \"5555555555555555555555555555555555555555555555555\",k = 10) == 0\n assert candidate(num = \"3333333333\",k = 1) == 0\n assert candidate(num = \"1212121212121212121212121212\",k = 500) == 6\n assert candidate(num = \"9876543210\",k = 10) == 0\n assert candidate(num = \"5678987656789\",k = 250) == 10\n assert candidate(num = \"12345678909876543210\",k = 500) == 37\n assert candidate(num = \"55667788990011223344\",k = 500) == 11\n assert candidate(num = \"3456789012\",k = 10) == 2\n assert candidate(num = \"123123123123123123123123123123123123123123\",k = 200) == 6\n assert candidate(num = \"123321123321\",k = 50) == 3\n assert candidate(num = \"9876543210\",k = 15) == 0\n assert candidate(num = \"1000000000000000000000000000000000000000000000000001\",k = 10) == 10\n assert candidate(num = \"12345678901234567890\",k = 100) == 8\n assert candidate(num = \"3214567890\",k = 10) == 5\n assert candidate(num = \"123321123321\",k = 100) == 5\n assert candidate(num = \"987654321098765432109876543210\",k = 1000) == 37\n assert candidate(num = \"01234567890123456789\",k = 1000) == 8\n assert candidate(num = \"3333333333\",k = 500) == 0\n assert candidate(num = \"3333222211110000\",k = 100) == 0\n assert candidate(num = \"9876543210987654321098765432109876543210\",k = 50) == 42\n assert candidate(num = \"987654321987654321987654321\",k = 500) == 28\n assert candidate(num = \"33333333333333333333\",k = 1) == 0\n assert candidate(num = \"01010101010101010101\",k = 250) == 3\n assert candidate(num = \"987654321987654321\",k = 100) == 30\n assert candidate(num = \"22222222222222222223\",k = 500) == 19\n assert candidate(num = \"333333333333333333333333333333333333333333333333\",k = 10) == 0\n assert candidate(num = \"987654321098765432109876543210987654321098765432109876543210\",k = 500) == 37\n assert candidate(num = \"1010101010101010\",k = 50) == 5\n assert candidate(num = \"1221112222211122222211111222222211111111122222222222222\",k = 100) == 19\n assert candidate(num = \"99887766554433221100\",k = 500) == 0\n assert candidate(num = \"1234554321\",k = 10) == 13\n assert candidate(num = \"0000000001\",k = 1) == 1\n assert candidate(num = \"44444444444444444444\",k = 100) == 0\n assert candidate(num = \"111122223333444455556666777788889999\",k = 1000) == 15\n assert candidate(num = \"90876543210987654321\",k = 50) == 34\n assert candidate(num = \"1234321234321\",k = 50) == 6\n assert candidate(num = \"111111111111111111112\",k = 1000) == 20\n assert candidate(num = \"98765432109876543210\",k = 10) == 42\n assert candidate(num = \"1234567890\",k = 100) == 8\n assert candidate(num = \"55555555555555555555\",k = 100) == 0\n assert candidate(num = \"555444333222111000\",k = 300) == 0\n assert candidate(num = \"123123123123123123123\",k = 200) == 6\n assert candidate(num = \"0000000000000000000000000000000000000000000000000001\",k = 1) == 1\n assert candidate(num = \"33333333332222222222111111111111\",k = 500) == 0\n assert candidate(num = \"9876543210\",k = 50) == 0\n assert candidate(num = \"33333333333333333333333333333333333333333333333333\",k = 1) == 0\n assert candidate(num = \"102030405060708090\",k = 50) == 8\n assert candidate(num = \"989796959493929190898887868584838281807978777675747372717069686766656463626160595857565554535251504948474645444342414039383736353433323130292827262524232221201918171615141312111009080706050403020100\",k = 1000) == 15\n assert candidate(num = \"00000000000000000001\",k = 10) == 10\n assert candidate(num = \"23456789012345678901\",k = 500) == 10\n assert candidate(num = \"0000000000000000000000000000000000001\",k = 1) == 1\n assert candidate(num = \"13579135791357913579\",k = 500) == 7\n assert candidate(num = \"876543210123456789\",k = 500) == 8\n assert candidate(num = \"10000000001\",k = 5) == 5\n assert candidate(num = \"3333333333\",k = 100) == 0\n assert candidate(num = \"1111111111111111111111111111111111111111\",k = 100) == 0\n assert candidate(num = \"98765432101234567890\",k = 20) == 7\n assert candidate(num = \"98765432109876543210\",k = 1000) == 37\n assert candidate(num = \"1221122112211221\",k = 100) == 13\n assert candidate(num = \"222111333000444555666777888999\",k = 500) == 10\n assert candidate(num = \"123456789876543210\",k = 100) == 39\n assert candidate(num = \"11223344556677889900\",k = 50) == 12\n assert candidate(num = \"12345678900987654321\",k = 200) == 31\n assert candidate(num = \"432111111111111111111111111111\",k = 100) == 0\n assert candidate(num = \"9999999999999999999999999999999999999999999999999999\",k = 5) == 0\n assert candidate(num = \"12345678909876543210\",k = 5) == 43\n assert candidate(num = \"11223344556677889900\",k = 100) == 9\n assert candidate(num = \"11111111112222222222\",k = 100) == 11\n assert candidate(num = \"12345678901234567890\",k = 5) == 2\n assert candidate(num = \"133221100998877665544332211\",k = 1000) == 133\n assert candidate(num = \"12345678901234567890\",k = 20) == 7\n assert candidate(num = \"000000000011111111112222222222\",k = 100) == 11\n assert candidate(num = \"55555555555555555555555555555555555555555555555555555\",k = 5) == 0\n assert candidate(num = \"11223344556677889900\",k = 1000) == 11\n assert candidate(num = \"1111222233334444\",k = 1000) == 15\n assert candidate(num = \"9999999999888888888877777777776666666666\",k = 1000) == 0\n assert candidate(num = \"11223344556677889900\",k = 200) == 9\n assert candidate(num = \"99999999999999999999\",k = 1000) == 0\n assert candidate(num = \"2233445566\",k = 300) == 4\n assert candidate(num = \"99999999999999999999\",k = 100) == 0\n assert candidate(num = \"98765432109876543210987654321098765432109876543210\",k = 1000) == 37\n", "comparison": "exact"}, "public_tests": ["\"5489355142\"\n4", "\"11112\"\n4", "\"00123\"\n1"], "hints": ["Find the next permutation of the given string k times.", "Try to move each element to its correct position and calculate the number of steps."], "metadata": {"canonical_parameter_names": ["num", "k"], "leetcode_dataset_entry_point": "Solution().getMinSwaps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:40+00:00", "tests_total": 105, "tests_dropped": 0, "flags": [], "topic_tags": ["two-pointers", "string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def getMinSwaps(self, num: str, k: int) -> int:", "container": "Solution", "callable": "getMinSwaps", "parameters": [{"name": "num", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1851, "task_id": "minimum-interval-to-include-each-query", "difficulty": "Hard", "problem_description": "You are given a 2D integer array intervals, where intervals[i] = [left_i, right_i] describes the i^th interval starting at left_i and ending at right_i (inclusive). The size of an interval is defined as the number of integers it contains, or more formally right_i - left_i + 1.\n\nYou are also given an integer array queries. The answer to the j^th query is the size of the smallest interval i such that left_i <= queries[j] <= right_i. If no such interval exists, the answer is -1.\n\nReturn an array containing the answers to the queries.\n\nExample 1:\n\nInput: intervals = [[1,4],[2,4],[3,6],[4,4]], queries = [2,3,4,5]\nOutput: [3,3,1,4]\nExplanation: The queries are processed as follows:\n- Query = 2: The interval [2,4] is the smallest interval containing 2. The answer is 4 - 2 + 1 = 3.\n- Query = 3: The interval [2,4] is the smallest interval containing 3. The answer is 4 - 2 + 1 = 3.\n- Query = 4: The interval [4,4] is the smallest interval containing 4. The answer is 4 - 4 + 1 = 1.\n- Query = 5: The interval [3,6] is the smallest interval containing 5. The answer is 6 - 3 + 1 = 4.\n\nExample 2:\n\nInput: intervals = [[2,3],[2,5],[1,8],[20,25]], queries = [2,19,5,22]\nOutput: [2,-1,4,6]\nExplanation: The queries are processed as follows:\n- Query = 2: The interval [2,3] is the smallest interval containing 2. The answer is 3 - 2 + 1 = 2.\n- Query = 19: None of the intervals contain 19. The answer is -1.\n- Query = 5: The interval [2,5] is the smallest interval containing 5. The answer is 5 - 2 + 1 = 4.\n- Query = 22: The interval [20,25] is the smallest interval containing 22. The answer is 25 - 20 + 1 = 6.\n\nConstraints:\n\n- 1 <= intervals.length <= 10^5\n- 1 <= queries.length <= 10^5\n- intervals[i].length == 2\n- 1 <= left_i <= right_i <= 10^7\n- 1 <= queries[j] <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(intervals = [[1, 1], [2, 2]],queries = [1, 2, 3]) == [1, 1, -1]\n assert candidate(intervals = [[1, 10], [10, 20], [15, 25]],queries = [5, 10, 15, 20, 25]) == [10, 10, 11, 11, 11]\n assert candidate(intervals = [[1, 1]],queries = [1]) == [1]\n assert candidate(intervals = [[5, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [-1, -1, -1, -1, 6, 6, 6, 6, 6, 6, -1]\n assert candidate(intervals = [[2, 3], [2, 5], [1, 8], [20, 25]],queries = [2, 19, 5, 22]) == [2, -1, 4, 6]\n assert candidate(intervals = [[5, 5], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [-1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1]\n assert candidate(intervals = [[1, 10000000]],queries = [1, 5000000, 10000000]) == [10000000, 10000000, 10000000]\n assert candidate(intervals = [[1, 4], [2, 4], [3, 6], [4, 4]],queries = [2, 3, 4, 5]) == [3, 3, 1, 4]\n assert candidate(intervals = [[1, 3], [4, 5]],queries = [2, 3, 4, 5]) == [3, 3, 2, 2]\n assert candidate(intervals = [[10000000, 10000000]],queries = [10000000]) == [1]\n assert candidate(intervals = [[5, 5], [1, 2], [3, 4]],queries = [1, 5, 2, 3]) == [2, 1, 2, 2]\n assert candidate(intervals = [[1, 10], [2, 9], [3, 8]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 8, 6, 6, 6, 6, 6, 6, 8, 10]\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300]],queries = [1, 50, 100, 150, 200, 250, 300, 301]) == [100, 100, 100, 101, 101, 101, 101, -1]\n assert candidate(intervals = [[1000, 2000], [500, 1500], [100, 1000], [50, 500], [1, 50]],queries = [1, 50, 100, 500, 1000, 1500, 2000]) == [50, 50, 451, 451, 901, 1001, 1001]\n assert candidate(intervals = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40]],queries = [10, 15, 20, 25, 30, 35, 40, 45]) == [11, 11, 11, 11, 11, 11, 11, -1]\n assert candidate(intervals = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 3, 5, 7, 9]) == [1, 1, 1, 1, 1]\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -1]\n assert candidate(intervals = [[1, 10000000], [5000000, 7500000], [2500000, 3750000], [6250000, 8750000]],queries = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == [10000000, 10000000, 1250001, 10000000, 2500001, 2500001, 2500001, 2500001, 10000000, 10000000]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == [2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 5], [6, 10], [11, 15], [16, 20]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(intervals = [[1, 10], [10, 20], [15, 25], [25, 35], [30, 40], [35, 45]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == [10, 10, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(intervals = [[1000000, 10000000], [2000000, 10000000], [3000000, 10000000], [4000000, 10000000]],queries = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == [9000001, 8000001, 7000001, 6000001, 6000001, 6000001, 6000001, 6000001, 6000001, 6000001]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8]],queries = [1, 2, 3, 4, 5, 6, 7, 8]) == [3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1]\n assert candidate(intervals = [[1, 500000], [500000, 1000000], [1000000, 1500000], [1500000, 2000000], [2000000, 2500000]],queries = [250000, 750000, 1250000, 1750000, 2250000]) == [500000, 500001, 500001, 500001, 500001]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1]\n assert candidate(intervals = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(intervals = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [10, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(intervals = [[1, 5000], [2, 4999], [3, 4998], [4, 4997], [5, 4996], [6, 4995], [7, 4994], [8, 4993], [9, 4992], [10, 4991]],queries = [2500, 3500, 4500, 5500]) == [4982, 4982, 4982, -1]\n assert candidate(intervals = [[1, 1000], [2, 1001], [3, 1002], [4, 1003], [5, 1004], [6, 1005], [7, 1006], [8, 1007], [9, 1008], [10, 1009]],queries = [1, 500, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, -1]\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [1, 19, 10, 2, 9, 18, 7, 16, 5, 15, 3, 14, 11, 13, 6, 12, 8, 17, 4]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70]],queries = [15, 25, 35, 45, 55, 65, 75]) == [11, 11, 11, 11, 11, 11, -1]\n assert candidate(intervals = [[1, 50000], [2, 30000], [3, 20000], [4, 10000]],queries = [1, 2, 3, 4, 5, 10000, 20000, 30000, 50000]) == [50000, 29999, 19998, 9997, 9997, 9997, 19998, 29999, 50000]\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 10000000], [1000000, 2000000], [2000000, 3000000], [3000000, 4000000], [4000000, 5000000], [5000000, 6000000], [6000000, 7000000], [7000000, 8000000], [8000000, 9000000], [9000000, 10000000]],queries = [1, 5000000, 1000000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000, 4500000, 5500000, 6000000, 6500000, 7000000, 7500000, 8000000, 8500000, 9000000, 9500000, 10000000]) == [10000000, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1]\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]],queries = [1, 5, 9, 13, 17]) == [2, 2, 2, 2, -1]\n assert candidate(intervals = [[1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(intervals = [[1, 2000], [2, 1999], [3, 1998], [4, 1997], [5, 1996], [6, 1995], [7, 1994], [8, 1993], [9, 1992], [10, 1991]],queries = [1, 1000, 2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991]) == [2000, 1982, 2000, 1998, 1996, 1994, 1992, 1990, 1988, 1986, 1984, 1982]\n assert candidate(intervals = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30]],queries = [3, 7, 13, 19, 23, 27, 10, 21, 31]) == [5, 5, 5, 5, 5, 5, 5, 5, -1]\n assert candidate(intervals = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70], [75, 80], [85, 90], [95, 100]],queries = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96, 101]) == [-1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1]\n assert candidate(intervals = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11], [6, 13], [7, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]\n assert candidate(intervals = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],queries = [50, 60, 70, 80, 90, 100]) == [82, 82, 82, 82, 82, 100]\n assert candidate(intervals = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]],queries = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90]) == [-1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 1000000], [1, 999999], [1, 999998], [1, 999997], [1, 999996]],queries = [500000, 250000, 750000, 125000, 375000]) == [999996, 999996, 999996, 999996, 999996]\n assert candidate(intervals = [[1, 3], [1, 5], [1, 7], [1, 9], [1, 11], [1, 13], [1, 15], [1, 17], [1, 19], [1, 21]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == [3, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17, 17, 19, 19, 21, 21, -1]\n assert candidate(intervals = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996]],queries = [1, 50000, 100000, 99999, 99998]) == [100000, 99992, 100000, 99998, 99996]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(intervals = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [1, 2, 3, 4, 5]) == [10000000, 9999998, 9999996, 9999994, 9999992]\n assert candidate(intervals = [[5, 500], [6, 499], [7, 498], [8, 497], [9, 496]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 500]) == [488, 488, 488, 488, 488, 488, 488, 488, 488, 488, 496]\n assert candidate(intervals = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997]],queries = [1, 2, 3, 4, 5, 9999999, 10000000]) == [10000000, 9999998, 9999996, 9999994, 9999994, 9999998, 10000000]\n assert candidate(intervals = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23]],queries = [1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24]) == [3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1]\n assert candidate(intervals = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [5, 5, 5, 5, 5, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, -1]\n assert candidate(intervals = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15]],queries = [1, 5, 7, 11, 13, 16]) == [3, 3, 3, 3, 3, -1]\n assert candidate(intervals = [[1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3]],queries = [1, 2, 3]) == [3, 3, 3]\n assert candidate(intervals = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],queries = [5, 15, 25, 35, 45]) == [10, 10, 10, 10, 10]\n assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],queries = [3, 4, 5, 6, 7, 8, 9, 1, 2, 10]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997], [5, 999996]],queries = [500000, 250000, 750000, 125000, 375000]) == [999992, 999992, 999992, 999992, 999992]\n assert candidate(intervals = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50]],queries = [3, 7, 12, 18, 23, 28, 33, 38, 43, 48]) == [-1, 6, -1, 6, -1, 6, -1, 6, -1, 6]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [11, 20], [12, 19], [13, 18], [14, 17], [15, 16]],queries = [5, 15, 25, 35, 45]) == [2, 2, -1, -1, -1]\n assert candidate(intervals = [[1, 1], [10000000, 10000000], [2, 9999999], [9999998, 9999998], [3, 9999997], [9999996, 9999996]],queries = [1, 5000000, 10000000, 9999999, 9999998, 9999997, 9999996, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 9999995, 1, 9999998, 1, 9999995, 1, 1, 9999998, 9999995, 9999995, 9999995, 9999995, 9999995, 9999995, 9999995, 9999995]\n assert candidate(intervals = [[1, 2], [4, 6], [8, 10], [12, 14], [16, 18], [20, 22], [24, 26], [28, 30], [32, 34], [36, 38], [40, 42], [44, 46], [48, 50], [52, 54], [56, 58], [60, 62], [64, 66], [68, 70], [72, 74], [76, 78]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79]) == [2, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1]\n assert candidate(intervals = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, -1]\n assert candidate(intervals = [[1, 100000], [50000, 100000], [1, 50000], [100000, 100000]],queries = [1, 25000, 50000, 75000, 100000]) == [50000, 50000, 50000, 50001, 1]\n assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(intervals = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995], [7, 9994]],queries = [1, 2, 3, 4, 5, 6, 7, 10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993]) == [10000, 9998, 9996, 9994, 9992, 9990, 9988, 10000, 9998, 9996, 9994, 9992, 9990, 9988, 9988]\n assert candidate(intervals = [[1, 5000], [1000, 5000], [2000, 5000], [3000, 5000], [4000, 5000]],queries = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000]) == [5000, 4001, 4001, 3001, 3001, 2001, 2001, 1001, 1001, 1001]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [1, 11, 6, 3, 8, 5, 10, 2, 7, 4, 9]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [1, 5, 9, 13, 17, 21]) == [2, 2, 2, 2, 2, -1]\n assert candidate(intervals = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]],queries = [500, 600, 700, 800, 900, 1000]) == [982, 982, 982, 982, 982, 1000]\n assert candidate(intervals = [[1, 1000000], [1000000, 2000000], [2000000, 3000000], [3000000, 4000000], [4000000, 5000000], [5000000, 6000000]],queries = [500000, 1500000, 2500000, 3500000, 4500000, 5500000]) == [1000000, 1000001, 1000001, 1000001, 1000001, 1000001]\n assert candidate(intervals = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 8, 6, 4, 2, 2, 4, 6, 8, 10]\n assert candidate(intervals = [[1, 100000], [2, 99999], [50, 100], [101, 200], [201, 300]],queries = [1, 50, 101, 201, 500, 1000, 100000]) == [100000, 51, 100, 100, 99998, 99998, 100000]\n assert candidate(intervals = [[1, 1000000], [500000, 1500000], [750000, 2000000]],queries = [1, 500000, 1000000, 1500000, 2000000]) == [1000000, 1000000, 1000000, 1000001, 1250001]\n assert candidate(intervals = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]],queries = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(intervals = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -1]\n assert candidate(intervals = [[1000000, 2000000], [1500000, 2500000], [2000000, 3000000]],queries = [1000000, 1500000, 2000000, 2500000, 3000000]) == [1000001, 1000001, 1000001, 1000001, 1000001]\n assert candidate(intervals = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [1, 5000000, 10000000, 9999999, 9999998]) == [10000000, 9999992, 10000000, 9999998, 9999996]\n assert candidate(intervals = [[10, 200], [20, 190], [30, 180], [40, 170], [50, 160]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210]) == [191, 171, 151, 131, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 131, 151, 171, 191, -1]\n assert candidate(intervals = [[1, 100000], [50000, 150000], [75000, 250000]],queries = [10000, 50000, 75000, 150000, 250000]) == [100000, 100000, 100000, 100001, 175001]\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300]],queries = [25, 75, 125, 175, 225]) == [100, 100, 101, 101, 101]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500], [450, 550], [500, 600]],queries = [150, 250, 350, 450, 550, 600, 100, 200, 300, 400, 500]) == [101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101]\n assert candidate(intervals = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],queries = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59]) == [82, 82, 82, 82, 82, 82, 82, 82, 82, 82]\n assert candidate(intervals = [[1, 500], [501, 1000], [1001, 1500], [1501, 2000]],queries = [1, 500, 501, 1000, 1001, 1500, 1501, 2000]) == [500, 500, 500, 500, 500, 500, 500, 500]\n assert candidate(intervals = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [1, 9999998, 5000000, 9999997, 10000000]) == [10000000, 9999996, 9999992, 9999994, 10000000]\n assert candidate(intervals = [[1, 100000], [50000, 150000], [100000, 200000], [250000, 300000], [1, 1000000]],queries = [50000, 150000, 250000, 500000, 999999]) == [100000, 100001, 50001, 1000000, 1000000]\n assert candidate(intervals = [[1, 3], [4, 7], [8, 10], [11, 15], [16, 20], [21, 25], [26, 30]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1]\n assert candidate(intervals = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],queries = [3, 7, 12, 17, 22, 27]) == [5, 5, 5, 5, 5, -1]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]],queries = [1, 3, 5, 7, 9, 11]) == [1, 1, 1, 1, 1, 1]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 3, 5, 7, 9, 11]) == [1, 1, 1, 1, 1, -1]\n assert candidate(intervals = [[1, 10000000], [5000001, 10000000], [5000001, 7500000], [5000001, 6250000], [5000001, 5625000]],queries = [1, 5000000, 5625000, 6250000, 7500000, 10000000]) == [10000000, 10000000, 625000, 1250000, 2500000, 5000000]\n assert candidate(intervals = [[1, 3], [2, 6], [5, 9], [8, 12], [11, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(intervals = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350]],queries = [1, 50, 100, 150, 200, 250, 300, 350]) == [100, 100, 100, 101, 101, 101, 101, 101]\n", "comparison": "exact"}, "public_tests": ["[[1,4],[2,4],[3,6],[4,4]]\n[2,3,4,5]", "[[2,3],[2,5],[1,8],[20,25]]\n[2,19,5,22]"], "hints": ["Is there a way to order the intervals and queries such that it takes less time to query?", "Is there a way to add and remove intervals by going from the smallest query to the largest query to find the minimum size?"], "metadata": {"canonical_parameter_names": ["intervals", "queries"], "leetcode_dataset_entry_point": "Solution().minInterval", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:43+00:00", "tests_total": 104, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "binary-search", "sweep-line", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def minInterval(self, intervals: list[list[int]], queries: list[int]) -> list[int]:", "container": "Solution", "callable": "minInterval", "parameters": [{"name": "intervals", "type": "list[list[int]]"}, {"name": "queries", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1854, "task_id": "maximum-population-year", "difficulty": "Easy", "problem_description": "You are given a 2D integer array logs where each logs[i] = [birth_i, death_i] indicates the birth and death years of the i^th person.\n\nThe population of some year x is the number of people alive during that year. The i^th person is counted in year x's population if x is in the inclusive range [birth_i, death_i - 1]. Note that the person is not counted in the year that they die.\n\nReturn the earliest year with the maximum population.\n\nExample 1:\n\nInput: logs = [[1993,1999],[2000,2010]]\nOutput: 1993\nExplanation: The maximum population is 1, and 1993 is the earliest year with this population.\n\nExample 2:\n\nInput: logs = [[1950,1961],[1960,1971],[1970,1981]]\nOutput: 1960\nExplanation:\nThe maximum population is 2, and it had happened in years 1960 and 1970.\nThe earlier year between them is 1960.\n\nConstraints:\n\n- 1 <= logs.length <= 100\n- 1950 <= birth_i < death_i <= 2050\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(logs = [[2000, 2005], [2005, 2010], [2010, 2015]]) == 2000\n assert candidate(logs = [[1980, 1985], [1985, 1990], [1990, 1995], [1995, 2000]]) == 1980\n assert candidate(logs = [[2000, 2010], [1990, 2000], [2000, 2020]]) == 2000\n assert candidate(logs = [[1993, 1999], [2000, 2010]]) == 1993\n assert candidate(logs = [[1950, 1960], [1960, 1970], [1970, 1980], [1980, 1990]]) == 1950\n assert candidate(logs = [[1991, 1992], [1992, 1993], [1993, 1994], [1994, 1995]]) == 1991\n assert candidate(logs = [[1950, 2050]]) == 1950\n assert candidate(logs = [[1950, 1961], [1960, 1971], [1970, 1981], [1960, 1980]]) == 1960\n assert candidate(logs = [[1975, 1985], [1985, 1995], [1995, 2005], [2005, 2015]]) == 1975\n assert candidate(logs = [[1990, 1995], [1991, 1996], [1992, 1997]]) == 1992\n assert candidate(logs = [[1950, 1961], [1960, 1971], [1970, 1981]]) == 1960\n assert candidate(logs = [[2000, 2010], [2010, 2020], [2020, 2030]]) == 2000\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005]]) == 1985\n assert candidate(logs = [[1995, 2005], [2005, 2015], [2015, 2025]]) == 1995\n assert candidate(logs = [[2000, 2010], [1990, 2000], [1980, 1990]]) == 1980\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025], [2020, 2030]]) == 1985\n assert candidate(logs = [[1993, 1995], [1994, 1996], [1995, 1997], [1996, 1998], [1997, 1999], [1998, 2000], [1999, 2001], [2000, 2002], [2001, 2003], [2002, 2004], [2003, 2005]]) == 1994\n assert candidate(logs = [[2000, 2005], [2001, 2006], [2002, 2007], [2003, 2008], [2004, 2009], [2005, 2010]]) == 2004\n assert candidate(logs = [[1965, 1980], [1970, 1985], [1975, 1990], [1980, 1995], [1985, 2000]]) == 1975\n assert candidate(logs = [[1950, 1960], [1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010], [2010, 2020], [2020, 2030]]) == 1950\n assert candidate(logs = [[1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025]]) == 1990\n assert candidate(logs = [[1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990]]) == 1960\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005]]) == 1955\n assert candidate(logs = [[1955, 1975], [1960, 1980], [1965, 1985], [1970, 1990], [1975, 1995], [1980, 2000], [1985, 2005], [1990, 2010], [1995, 2015], [2000, 2020]]) == 1970\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015]]) == 1985\n assert candidate(logs = [[1980, 1990], [1981, 1991], [1982, 1992], [1983, 1993], [1984, 1994], [1985, 1995], [1986, 1996], [1987, 1997], [1988, 1998], [1989, 1999]]) == 1989\n assert candidate(logs = [[1950, 2000], [1960, 1990], [1970, 1995], [1980, 2005], [1990, 2010], [2000, 2020]]) == 1980\n assert candidate(logs = [[1975, 1978], [1977, 1980], [1979, 1982], [1981, 1984], [1983, 1986], [1985, 1988], [1987, 1990], [1989, 1992], [1991, 1994], [1993, 1996]]) == 1977\n assert candidate(logs = [[1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025], [2020, 2030], [2025, 2035]]) == 1995\n assert candidate(logs = [[1990, 1991], [1991, 1992], [1992, 1993], [1993, 1994], [1994, 1995], [1995, 1996], [1996, 1997], [1997, 1998], [1998, 1999], [1999, 2000]]) == 1990\n assert candidate(logs = [[1960, 1970], [1961, 1971], [1962, 1972], [1963, 1973], [1964, 1974], [1965, 1975], [1966, 1976], [1967, 1977], [1968, 1978], [1969, 1979], [1970, 1980]]) == 1969\n assert candidate(logs = [[1950, 2050], [1960, 2040], [1970, 2030], [1980, 2020], [1990, 2010], [2000, 2005]]) == 2000\n assert candidate(logs = [[1980, 1985], [1982, 1987], [1984, 1989], [1986, 1991], [1988, 1993]]) == 1984\n assert candidate(logs = [[1950, 2050], [1951, 2049], [1952, 2048], [1953, 2047], [1954, 2046], [1955, 2045], [1956, 2044], [1957, 2043], [1958, 2042], [1959, 2041], [1960, 2040]]) == 1960\n assert candidate(logs = [[1950, 2050], [1960, 1980], [1970, 1990], [1980, 2000], [1990, 2010], [2000, 2020]]) == 1970\n assert candidate(logs = [[1990, 1995], [1991, 1996], [1992, 1997], [1993, 1998], [1994, 1999]]) == 1994\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985]]) == 1955\n assert candidate(logs = [[1950, 1961], [1955, 1966], [1960, 1971], [1965, 1976], [1970, 1981], [1975, 1986]]) == 1960\n assert candidate(logs = [[1980, 1990], [1982, 1992], [1984, 1994], [1986, 1996], [1988, 1998], [1990, 2000]]) == 1988\n assert candidate(logs = [[1955, 1966], [1961, 1971], [1966, 1976], [1971, 1981], [1976, 1986], [1981, 1991], [1986, 1996], [1991, 2001]]) == 1961\n assert candidate(logs = [[1965, 1985], [1970, 1990], [1975, 1995], [1980, 2000], [1985, 2005], [1990, 2010], [1995, 2015], [2000, 2020], [2005, 2025], [2010, 2030]]) == 1980\n assert candidate(logs = [[1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025], [2020, 2030], [2025, 2035], [2030, 2040], [2035, 2045], [2040, 2050]]) == 1975\n assert candidate(logs = [[1950, 1965], [1960, 1975], [1970, 1985], [1980, 1995], [1990, 2005], [2000, 2015], [2010, 2025], [2020, 2035]]) == 1960\n assert candidate(logs = [[1950, 1960], [1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010], [2010, 2020], [2020, 2030], [2030, 2040], [2040, 2050]]) == 1950\n assert candidate(logs = [[1950, 2050], [1955, 2045], [1960, 2040], [1965, 2035], [1970, 2030], [1975, 2025], [1980, 2020], [1985, 2015], [1990, 2010]]) == 1990\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2015], [2005, 2020]]) == 1985\n assert candidate(logs = [[1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015]]) == 1965\n assert candidate(logs = [[1960, 1965], [1961, 1966], [1962, 1967], [1963, 1968], [1964, 1969], [1965, 1970], [1966, 1971], [1967, 1972], [1968, 1973], [1969, 1974]]) == 1964\n assert candidate(logs = [[1950, 1960], [1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010]]) == 1950\n assert candidate(logs = [[1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005]]) == 1960\n assert candidate(logs = [[1993, 1999], [2000, 2010], [1995, 2000], [1985, 1995], [1990, 1998]]) == 1993\n assert candidate(logs = [[1955, 1965], [1950, 1960], [1960, 1970], [1970, 1980], [1965, 1975], [1975, 1985]]) == 1955\n assert candidate(logs = [[1955, 1965], [1965, 1975], [1975, 1985], [1985, 1995], [1995, 2005], [2005, 2015], [2015, 2025]]) == 1955\n assert candidate(logs = [[1970, 1975], [1971, 1976], [1972, 1977], [1973, 1978], [1974, 1979], [1975, 1980]]) == 1974\n assert candidate(logs = [[2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025], [2020, 2030], [2025, 2035], [2030, 2040]]) == 2005\n assert candidate(logs = [[1955, 1961], [1960, 1965], [1965, 1970], [1970, 1975], [1975, 1980], [1980, 1985], [1985, 1990]]) == 1960\n assert candidate(logs = [[1970, 1980], [1971, 1981], [1972, 1982], [1973, 1983], [1974, 1984], [1975, 1985], [1976, 1986], [1977, 1987], [1978, 1988], [1979, 1989], [1980, 1990]]) == 1979\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980]]) == 1955\n assert candidate(logs = [[1975, 1985], [1985, 1995], [1995, 2005], [2005, 2015], [2015, 2025], [2025, 2035]]) == 1975\n assert candidate(logs = [[1990, 2000], [1992, 2002], [1994, 2004], [1996, 2006], [1998, 2008]]) == 1998\n assert candidate(logs = [[1960, 1961], [1961, 1962], [1962, 1963], [1963, 1964], [1964, 1965], [1965, 1966], [1966, 1967], [1967, 1968], [1968, 1969], [1969, 1970], [1970, 1971]]) == 1960\n assert candidate(logs = [[1950, 1955], [1951, 1956], [1952, 1957], [1953, 1958], [1954, 1959], [1955, 1960], [1956, 1961], [1957, 1962], [1958, 1963], [1959, 1964], [1960, 1965]]) == 1954\n assert candidate(logs = [[1993, 1998], [1994, 1999], [1995, 2000], [1996, 2001], [1997, 2002], [1998, 2003], [1999, 2004]]) == 1997\n assert candidate(logs = [[1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995]]) == 1965\n assert candidate(logs = [[1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2000], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025]]) == 1975\n assert candidate(logs = [[1970, 1975], [1971, 1976], [1972, 1977], [1973, 1978], [1974, 1979], [1975, 1980], [1976, 1981], [1977, 1982], [1978, 1983], [1979, 1984]]) == 1974\n assert candidate(logs = [[1950, 2000], [1960, 2010], [1970, 2020], [1980, 2030], [1990, 2040], [2000, 2050]]) == 1990\n assert candidate(logs = [[1950, 1955], [1955, 1960], [1960, 1965], [1965, 1970], [1970, 1975], [1975, 1980], [1980, 1985], [1985, 1990], [1990, 1995], [1995, 2000], [2000, 2005], [2005, 2010], [2010, 2015], [2015, 2020], [2020, 2025], [2025, 2030], [2030, 2035], [2035, 2040], [2040, 2045], [2045, 2050]]) == 1950\n assert candidate(logs = [[1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025]]) == 1995\n assert candidate(logs = [[1950, 1951], [1951, 1952], [1952, 1953], [1953, 1954], [1954, 1955], [1955, 1956], [1956, 1957], [1957, 1958], [1958, 1959], [1959, 1960], [1960, 1961], [1961, 1962], [1962, 1963], [1963, 1964], [1964, 1965]]) == 1950\n assert candidate(logs = [[1950, 1961], [1955, 1966], [1960, 1971], [1965, 1976], [1970, 1981], [1975, 1986], [1980, 1991], [1985, 1996]]) == 1960\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025]]) == 1985\n assert candidate(logs = [[1955, 1975], [1960, 1980], [1965, 1985], [1970, 1990], [1975, 1995], [1980, 2000]]) == 1970\n assert candidate(logs = [[1990, 1995], [1992, 1997], [1994, 1999], [1996, 2001], [1998, 2003]]) == 1994\n assert candidate(logs = [[1955, 1965], [1965, 1975], [1975, 1985], [1985, 1995], [1995, 2005], [2005, 2015], [2015, 2025], [2025, 2035]]) == 1955\n assert candidate(logs = [[1975, 1980], [1978, 1985], [1980, 1985], [1982, 1990], [1985, 1995], [1988, 1995], [1990, 1998], [1992, 2000]]) == 1992\n assert candidate(logs = [[1950, 1980], [1960, 1990], [1970, 2000], [1980, 2010], [1990, 2020]]) == 1970\n assert candidate(logs = [[1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2000], [2000, 2010]]) == 1975\n assert candidate(logs = [[1960, 1970], [1961, 1971], [1962, 1972], [1963, 1973], [1964, 1974], [1965, 1975], [1966, 1976], [1967, 1977]]) == 1967\n assert candidate(logs = [[1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005]]) == 1965\n assert candidate(logs = [[1980, 1985], [1981, 1986], [1982, 1987], [1983, 1988], [1984, 1989], [1985, 1990], [1986, 1991], [1987, 1992]]) == 1984\n assert candidate(logs = [[1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020]]) == 1995\n assert candidate(logs = [[1993, 1995], [1994, 1996], [1995, 1997], [1996, 1998], [1997, 1999]]) == 1994\n assert candidate(logs = [[1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000]]) == 1960\n assert candidate(logs = [[1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010], [2010, 2020], [2020, 2030]]) == 1960\n assert candidate(logs = [[1990, 1995], [1990, 1995], [1990, 1995], [1995, 2000], [1995, 2000], [1995, 2000]]) == 1990\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000]]) == 1955\n assert candidate(logs = [[1980, 1990], [1982, 1992], [1984, 1994], [1986, 1996], [1988, 1998], [1990, 2000], [1992, 2002], [1994, 2004], [1996, 2006], [1998, 2008]]) == 1988\n assert candidate(logs = [[1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010], [2010, 2020]]) == 1960\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990]]) == 1955\n", "comparison": "exact"}, "public_tests": ["[[1993,1999],[2000,2010]]", "[[1950,1961],[1960,1971],[1970,1981]]"], "hints": ["For each year find the number of people whose birth_i ≤ year and death_i > year.", "Find the maximum value between all years."], "metadata": {"canonical_parameter_names": ["logs"], "leetcode_dataset_entry_point": "Solution().maximumPopulation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:48+00:00", "tests_total": 91, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "counting", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maximumPopulation(self, logs: list[list[int]]) -> int:", "container": "Solution", "callable": "maximumPopulation", "parameters": [{"name": "logs", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1855, "task_id": "maximum-distance-between-a-pair-of-values", "difficulty": "Medium", "problem_description": "You are given two non-increasing 0-indexed integer arrays nums1 and nums2.\n\nA pair of indices (i, j), where 0 <= i < nums1.length and 0 <= j < nums2.length, is valid if both i <= j and nums1[i] <= nums2[j]. The distance of the pair is j - i.\n\nReturn the maximum distance of any valid pair (i, j). If there are no valid pairs, return 0.\n\nAn array arr is non-increasing if arr[i-1] >= arr[i] for every 1 <= i < arr.length.\n\nExample 1:\n\nInput: nums1 = [55,30,5,4,2], nums2 = [100,20,10,10,5]\nOutput: 2\nExplanation: The valid pairs are (0,0), (2,2), (2,3), (2,4), (3,3), (3,4), and (4,4).\nThe maximum distance is 2 with pair (2,4).\n\nExample 2:\n\nInput: nums1 = [2,2,2], nums2 = [10,10,1]\nOutput: 1\nExplanation: The valid pairs are (0,0), (0,1), and (1,1).\nThe maximum distance is 1 with pair (0,1).\n\nExample 3:\n\nInput: nums1 = [30,29,19,5], nums2 = [25,25,25,25,25]\nOutput: 2\nExplanation: The valid pairs are (2,2), (2,3), (2,4), (3,3), and (3,4).\nThe maximum distance is 2 with pair (2,4).\n\nConstraints:\n\n- 1 <= nums1.length, nums2.length <= 10^5\n- 1 <= nums1[i], nums2[j] <= 10^5\n- Both nums1 and nums2 are non-increasing.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [100],nums2 = [101]) == 0\n assert candidate(nums1 = [30, 29, 19, 5],nums2 = [25, 25, 25, 25, 25]) == 2\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [10, 9, 8, 7, 6]) == 0\n assert candidate(nums1 = [5],nums2 = [10]) == 0\n assert candidate(nums1 = [10, 9, 8, 7],nums2 = [7, 7, 7, 7]) == 0\n assert candidate(nums1 = [5],nums2 = [5]) == 0\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == 3\n assert candidate(nums1 = [10],nums2 = [5]) == 0\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [100, 90],nums2 = [95, 85]) == 0\n assert candidate(nums1 = [100, 90, 80],nums2 = [100, 90, 80, 70, 60]) == 0\n assert candidate(nums1 = [99999, 99998, 99997],nums2 = [100000, 99999, 99998]) == 1\n assert candidate(nums1 = [1],nums2 = [2]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [5, 5, 5, 5, 5]) == 4\n assert candidate(nums1 = [2, 2, 2],nums2 = [10, 10, 1]) == 1\n assert candidate(nums1 = [100, 50, 25, 10],nums2 = [100, 100, 100, 100]) == 3\n assert candidate(nums1 = [55, 30, 5, 4, 2],nums2 = [100, 20, 10, 10, 5]) == 2\n assert candidate(nums1 = [1],nums2 = [1]) == 0\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [15, 14, 13, 12, 11]) == 4\n assert candidate(nums1 = [100000],nums2 = [100000]) == 0\n assert candidate(nums1 = [50, 40, 30, 20, 10],nums2 = [100, 80, 60, 40, 20]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums1 = [30, 29, 19, 5],nums2 = [25, 25, 25, 25, 25, 20, 15, 10, 5]) == 5\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 9\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 9\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 9\n assert candidate(nums1 = [95, 85, 75, 65, 55],nums2 = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 0\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [100000, 100000, 100000, 100000, 100000],nums2 = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 9\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 9\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 9\n assert candidate(nums1 = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 5\n assert candidate(nums1 = [1],nums2 = [100000]) == 0\n assert candidate(nums1 = [50, 40, 30, 20, 10],nums2 = [55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 5\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [99, 89, 79, 69, 59, 49, 39, 29, 19, 9]) == 0\n assert candidate(nums1 = [50, 25, 10, 1],nums2 = [50, 40, 30, 25, 20, 15, 10, 5, 1]) == 5\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1]) == 10\n assert candidate(nums1 = [90, 80, 70, 60, 50],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums1 = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],nums2 = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 1\n assert candidate(nums1 = [10, 5, 3, 2],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 4\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 4\n assert candidate(nums1 = [20, 10, 5, 2, 1],nums2 = [50, 40, 30, 20, 10, 5, 2, 1]) == 3\n assert candidate(nums1 = [50, 40, 30, 20, 10],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 5\n assert candidate(nums1 = [100],nums2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 9\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 10\n assert candidate(nums1 = [50, 30, 10],nums2 = [60, 50, 40, 30, 20, 10]) == 3\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [10, 9, 8, 7, 6]) == 0\n assert candidate(nums1 = [90, 70, 50, 30, 10],nums2 = [100, 80, 60, 40, 20]) == 0\n assert candidate(nums1 = [100, 50, 25],nums2 = [150, 120, 90, 70, 50, 30, 10]) == 3\n assert candidate(nums1 = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],nums2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 9\n assert candidate(nums1 = [1000, 900, 800, 700, 600],nums2 = [1000, 950, 900, 850, 800, 750, 700, 650, 600, 550, 500]) == 4\n assert candidate(nums1 = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 1],nums2 = [100000, 99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111]) == 1\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [10, 10, 10, 10, 10, 10],nums2 = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 14\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums1 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],nums2 = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 9\n assert candidate(nums1 = [100, 50, 25, 10, 1],nums2 = [200, 150, 100, 90, 80, 70, 60, 50, 40, 30, 25, 20, 15, 10, 5]) == 10\n assert candidate(nums1 = [10, 5, 5, 5, 5],nums2 = [20, 15, 15, 10, 10, 10, 5, 5, 5, 5]) == 8\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums1 = [5, 4, 4, 3, 3, 3, 2, 1],nums2 = [9, 8, 7, 6, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 9\n assert candidate(nums1 = [100, 50, 30, 20, 10],nums2 = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 10\n assert candidate(nums1 = [100, 50, 25, 10, 5],nums2 = [100, 75, 50, 25, 10, 5, 2]) == 1\n assert candidate(nums1 = [10, 10, 10, 10, 10],nums2 = [20, 20, 20, 20, 20]) == 4\n assert candidate(nums1 = [100000],nums2 = [1]) == 0\n assert candidate(nums1 = [100, 90, 80, 70, 60],nums2 = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55]) == 4\n", "comparison": "exact"}, "public_tests": ["[55,30,5,4,2]\n[100,20,10,10,5]", "[2,2,2]\n[10,10,1]", "[30,29,19,5]\n[25,25,25,25,25]"], "hints": ["Since both arrays are sorted in a non-increasing way, this means that for each value in the first array, we can find the farthest value larger than or equal to it using binary search.", "There is another solution using a two pointers approach. Since the first array is non-increasing, the farthest j such that nums2[j] ≥ nums1[i] is at least as far as the farthest j such that nums2[j] ≥ nums1[i-1]"], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maxDistance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:50+00:00", "tests_total": 75, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "two-pointers", "binary-search"]}, "language": "python", "interface": {"raw_signature": "def maxDistance(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "maxDistance", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1856, "task_id": "maximum-subarray-min-product", "difficulty": "Medium", "problem_description": "The min-product of an array is equal to the minimum value in the array multiplied by the array's sum.\n\n- For example, the array [3,2,5] (minimum value is 2) has a min-product of 2 * (3+2+5) = 2 * 10 = 20.\n\nGiven an array of integers nums, return the maximum min-product of any non-empty subarray of nums. Since the answer may be large, return it modulo 10^9 + 7.\n\nNote that the min-product should be maximized before performing the modulo operation. Testcases are generated such that the maximum min-product without modulo will fit in a 64-bit signed integer.\n\nA subarray is a contiguous part of an array.\n\nExample 1:\n\nInput: nums = [1,2,3,2]\nOutput: 14\nExplanation: The maximum min-product is achieved with the subarray [2,3,2] (minimum value is 2).\n2 * (2+3+2) = 2 * 7 = 14.\n\nExample 2:\n\nInput: nums = [2,3,3,1,2]\nOutput: 18\nExplanation: The maximum min-product is achieved with the subarray [3,3] (minimum value is 3).\n3 * (3+3) = 3 * 6 = 18.\n\nExample 3:\n\nInput: nums = [3,1,5,6,4,2]\nOutput: 60\nExplanation: The maximum min-product is achieved with the subarray [5,6,4] (minimum value is 4).\n4 * (5+6+4) = 4 * 15 = 60.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 9, 6, 8, 7]) == 180\n assert candidate(nums = [2, 1]) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 240\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [10000000]) == 999300007\n assert candidate(nums = [5, 9, 6, 8, 7, 4, 3, 2, 10, 1]) == 180\n assert candidate(nums = [2, 3, 3, 1, 2]) == 18\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996]) == 696500047\n assert candidate(nums = [5, 5, 5, 5, 5]) == 125\n assert candidate(nums = [7, 1, 5, 6, 4, 2]) == 60\n assert candidate(nums = [1, 2, 3, 4, 5]) == 36\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [3, 1, 5, 6, 4, 2]) == 60\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997]) == 817200025\n assert candidate(nums = [5, 4, 3, 2, 1]) == 36\n assert candidate(nums = [1, 2]) == 4\n assert candidate(nums = [1, 2, 3, 2]) == 14\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 72\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 135\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991]) == 643000419\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 2400000\n assert candidate(nums = [5, 8, 6, 7, 8, 9, 9, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 642\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1728\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1728\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 360\n assert candidate(nums = [10, 20, 10, 30, 20, 10, 40, 30, 20, 10]) == 2100\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1728\n assert candidate(nums = [9999999, 1, 9999999, 1, 9999999, 1, 9999999, 1, 9999999, 1]) == 979300008\n assert candidate(nums = [1, 3, 2, 5, 6, 2, 8, 4, 9, 1, 3]) == 84\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990]) == 342300564\n assert candidate(nums = [1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000]) == 999300007\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 756\n assert candidate(nums = [1, 1, 1, 1, 10000000, 1, 1, 1, 1, 10000000, 1, 1, 1, 1]) == 999300007\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [10000000, 10000000, 10000000, 10000000, 10000000]) == 996500007\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5]) == 3600\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 420\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7]) == 90\n assert candidate(nums = [7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == 238\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 420\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 10000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 420\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 240\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 480\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 420\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 480\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 999930007\n assert candidate(nums = [2, 3, 2, 4, 3, 2, 5, 4, 3, 2, 6, 5, 4, 3, 2, 7, 6, 5, 4, 3, 2, 8, 7, 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 10]) == 332\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1728\n assert candidate(nums = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000]) == 998320007\n assert candidate(nums = [3, 2, 1, 4, 3, 2, 5, 4, 3, 6, 5, 4, 7, 6, 5, 8, 7, 6, 9, 8, 7]) == 315\n assert candidate(nums = [10, 20, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1000\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 240\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994]) == 365100133\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1728\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [8, 2, 6, 5, 4, 1, 3, 7, 9]) == 112\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 24000\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 41\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 82\n assert candidate(nums = [10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1]) == 999300007\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 980\n assert candidate(nums = [2, 1, 3, 4, 1, 5, 1, 6, 1, 7]) == 49\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 420\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991]) == 643000419\n assert candidate(nums = [10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000]) == 999300007\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 3300\n assert candidate(nums = [3, 2, 5, 4, 7, 6, 8, 9, 1, 10, 2, 3, 4, 5, 6, 7, 8, 9, 1, 10, 2, 3, 4, 5, 6, 7, 8, 9, 1, 10, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 756\n assert candidate(nums = [1, 5, 4, 3, 6, 2, 8, 7, 9]) == 168\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 81\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 100\n assert candidate(nums = [5, 6, 1, 2, 8, 9, 3, 4, 7, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 240\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1728\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 180\n assert candidate(nums = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000]) == 993000007\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 144\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 148\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [10000000, 1, 10000000, 1, 10000000, 1, 10000000]) == 999300007\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 240\n assert candidate(nums = [1, 10000000, 2, 9999999, 3, 9999998, 4, 9999997, 5, 9999996]) == 999300007\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1]) == 36\n assert candidate(nums = [9999996, 9999997, 9999998, 9999999, 10000000, 9999999, 9999998, 9999997, 9999996]) == 433700087\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 30\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 33\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 24000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 999300007\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 375\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 25\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 999937007\n assert candidate(nums = [1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000]) == 999300007\n", "comparison": "exact"}, "public_tests": ["[1,2,3,2]", "[2,3,3,1,2]", "[3,1,5,6,4,2]"], "hints": ["Is there a way we can sort the elements to simplify the problem?", "Can we find the maximum min-product for every value in the array?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxSumMinProduct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:53+00:00", "tests_total": 101, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "stack", "monotonic-stack", "prefix-sum", "cartesian-tree"]}, "language": "python", "interface": {"raw_signature": "def maxSumMinProduct(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maxSumMinProduct", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1857, "task_id": "largest-color-value-in-a-directed-graph", "difficulty": "Hard", "problem_description": "There is a directed graph of n colored nodes and m edges. The nodes are numbered from 0 to n - 1.\n\nYou are given a string colors where colors[i] is a lowercase English letter representing the color of the i^th node in this graph (0-indexed). You are also given a 2D array edges where edges[j] = [a_j, b_j] indicates that there is a directed edge from node a_j to node b_j.\n\nA valid path in the graph is a sequence of nodes x_1 -> x_2 -> x_3 -> ... -> x_k such that there is a directed edge from x_i to x_{i+1} for every 1 <= i < k. The color value of the path is the number of nodes that are colored the most frequently occurring color along that path.\n\nReturn the largest color value of any valid path in the given graph, or -1 if the graph contains a cycle.\n\nExample 1:\n\nInput: colors = \"abaca\", edges = [[0,1],[0,2],[2,3],[3,4]]\nOutput: 3\nExplanation: The path 0 -> 2 -> 3 -> 4 contains 3 nodes that are colored \"a\" (red in the above image).\n\nExample 2:\n\nInput: colors = \"a\", edges = [[0,0]]\nOutput: -1\nExplanation: There is a cycle from 0 to 0.\n\nConstraints:\n\n- n == colors.length\n- m == edges.length\n- 1 <= n <= 10^5\n- 0 <= m <= 10^5\n- colors consists of lowercase English letters.\n- 0 <= a_j, b_j < n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(colors = \"abcde\",edges = []) == 1\n assert candidate(colors = \"abcdefghijklmnopqrstuvwxyz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]]) == 1\n assert candidate(colors = \"zzz\",edges = [[0, 1], [1, 2], [2, 0]]) == -1\n assert candidate(colors = \"abacabadabacaba\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 8\n assert candidate(colors = \"aaaaa\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 1\n assert candidate(colors = \"abcde\",edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 1\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5]]) == 1\n assert candidate(colors = \"abcde\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"aaaaa\",edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 5\n assert candidate(colors = \"xyzz\",edges = [[0, 1], [1, 2], [2, 3]]) == 2\n assert candidate(colors = \"abcabc\",edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3]]) == -1\n assert candidate(colors = \"abcdabcdabcd\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 3\n assert candidate(colors = \"xyz\",edges = [[0, 1], [1, 2]]) == 1\n assert candidate(colors = \"aabbcc\",edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3]]) == -1\n assert candidate(colors = \"abcabcabc\",edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3]]) == -1\n assert candidate(colors = \"aabbcc\",edges = [[0, 1], [2, 3], [4, 5]]) == 2\n assert candidate(colors = \"aaabbb\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 3\n assert candidate(colors = \"zzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"aaaa\",edges = [[0, 1], [1, 2], [2, 3], [3, 0]]) == -1\n assert candidate(colors = \"aabbcc\",edges = [[0, 1], [1, 2], [2, 0]]) == -1\n assert candidate(colors = \"a\",edges = []) == 1\n assert candidate(colors = \"abcd\",edges = [[0, 1], [0, 2], [1, 3], [2, 3]]) == 1\n assert candidate(colors = \"aabbbbcccc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 4\n assert candidate(colors = \"abcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 3\n assert candidate(colors = \"a\",edges = [[0, 0]]) == -1\n assert candidate(colors = \"abaca\",edges = [[0, 1], [0, 2], [2, 3], [3, 4]]) == 3\n assert candidate(colors = \"abcd\",edges = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [1, 3]]) == -1\n assert candidate(colors = \"ab\",edges = [[0, 1]]) == 1\n assert candidate(colors = \"aabbcc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 2\n assert candidate(colors = \"zzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0]]) == -1\n assert candidate(colors = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35]]) == 2\n assert candidate(colors = \"abcabcabcabcabcabcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 10]]) == -1\n assert candidate(colors = \"zzzzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == -1\n assert candidate(colors = \"abcbcbc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 2]]) == -1\n assert candidate(colors = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39]]) == 2\n assert candidate(colors = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 0]]) == -1\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == -1\n assert candidate(colors = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49]]) == 2\n assert candidate(colors = \"abacabadabe\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == -1\n assert candidate(colors = \"abcde\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3], [2, 4], [3, 0], [4, 1]]) == -1\n assert candidate(colors = \"aaaaaaaaaa\",edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9], [8, 9]]) == 5\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4], [2, 5], [3, 5], [4, 5]]) == 1\n assert candidate(colors = \"bbaaabbbaaabbbaaabbbaaa\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 8\n assert candidate(colors = \"abcdefghijklmnopqrstuvwx\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23]]) == 1\n assert candidate(colors = \"ababababa\",edges = [[0, 1], [1, 2], [2, 0], [1, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 3]]) == -1\n assert candidate(colors = \"xyzxyzxyz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 2], [1, 3], [4, 6], [5, 7]]) == -1\n assert candidate(colors = \"abcde\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [2, 0], [3, 1]]) == -1\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 2]]) == -1\n assert candidate(colors = \"abacabadabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 5\n assert candidate(colors = \"abcdefghijk\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0]]) == -1\n assert candidate(colors = \"abacabadabe\",edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 3]]) == -1\n assert candidate(colors = \"abcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 10]]) == -1\n assert candidate(colors = \"aaabbbccc\",edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 8], [8, 4], [1, 3], [3, 5], [5, 7]]) == -1\n assert candidate(colors = \"ababababc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0]]) == -1\n assert candidate(colors = \"abcdefghij\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 0], [9, 1]]) == -1\n assert candidate(colors = \"zzzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == -1\n assert candidate(colors = \"aaaabbbbccccdddd\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 4\n assert candidate(colors = \"zzzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(colors = \"aabbccddeeff\",edges = [[0, 1], [0, 5], [1, 2], [1, 3], [2, 4], [3, 4], [5, 6], [5, 7], [6, 8], [7, 8], [8, 9]]) == 2\n assert candidate(colors = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0]]) == -1\n assert candidate(colors = \"abacabadabe\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 5\n assert candidate(colors = \"abcde\",edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"abcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [1, 3], [3, 5], [5, 7]]) == -1\n assert candidate(colors = \"abcabcabcabcabcabcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 28]]) == -1\n assert candidate(colors = \"abcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0]]) == -1\n assert candidate(colors = \"abacbacba\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 4\n assert candidate(colors = \"abacabadabe\",edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9], [8, 9]]) == 4\n assert candidate(colors = \"abacabadaba\",edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 9]]) == 5\n assert candidate(colors = \"abacabadaba\",edges = [[0, 1], [1, 0], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == -1\n assert candidate(colors = \"ababababab\",edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 9], [8, 9]]) == 5\n assert candidate(colors = \"abacabadaba\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 5\n assert candidate(colors = \"abcabcabcabcabcabcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == 10\n assert candidate(colors = \"abcdefghij\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == -1\n assert candidate(colors = \"abacabadaba\",edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 5\n assert candidate(colors = \"aabbaabb\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]]) == -1\n assert candidate(colors = \"abcdefgabcdefgabcdefgabcdefg\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 7]]) == -1\n assert candidate(colors = \"aaabbbcccdddeeefffggghhh\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23]]) == 3\n assert candidate(colors = \"abcdefghijk\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(colors = \"aaaabbbbccccdddd\",edges = [[0, 1], [0, 4], [1, 2], [1, 5], [2, 3], [2, 6], [3, 7], [4, 5], [4, 8], [5, 6], [5, 9], [6, 7], [6, 10], [7, 11], [8, 9], [8, 12], [9, 10], [9, 13], [10, 11], [10, 14], [11, 15], [12, 13], [13, 14], [14, 15]]) == 4\n assert candidate(colors = \"abcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 5\n assert candidate(colors = \"abcde\",edges = [[0, 1], [0, 2], [2, 1], [1, 3], [2, 3], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"zzzzzzyyyyy\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 6\n assert candidate(colors = \"abacabadabacaba\",edges = [[0, 1], [0, 2], [2, 3], [3, 4], [1, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 6\n", "comparison": "exact"}, "public_tests": ["\"abaca\"\n[[0,1],[0,2],[2,3],[3,4]]", "\"a\"\n[[0,0]]"], "hints": ["Use topological sort.", "let dp[u][c] := the maximum count of vertices with color c of any path starting from vertex u. (by JerryJin2905)"], "metadata": {"canonical_parameter_names": ["colors", "edges"], "leetcode_dataset_entry_point": "Solution().largestPathValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:32:56+00:00", "tests_total": 84, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["hash-table", "string", "dynamic-programming", "graph", "topological-sort", "memoization", "counting", "directed-acyclic-graph"]}, "language": "python", "interface": {"raw_signature": "def largestPathValue(self, colors: str, edges: list[list[int]]) -> int:", "container": "Solution", "callable": "largestPathValue", "parameters": [{"name": "colors", "type": "str"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1859, "task_id": "sorting-the-sentence", "difficulty": "Easy", "problem_description": "A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase English letters.\n\nA sentence can be shuffled by appending the 1-indexed word position to each word then rearranging the words in the sentence.\n\n- For example, the sentence \"This is a sentence\" can be shuffled as \"sentence4 a3 is2 This1\" or \"is2 sentence4 This1 a3\".\n\nGiven a shuffled sentence s containing no more than 9 words, reconstruct and return the original sentence.\n\nExample 1:\n\nInput: s = \"is2 sentence4 This1 a3\"\nOutput: \"This is a sentence\"\nExplanation: Sort the words in s to their original positions \"This1 is2 a3 sentence4\", then remove the numbers.\n\nExample 2:\n\nInput: s = \"Myself2 Me1 I4 and3\"\nOutput: \"Me Myself and I\"\nExplanation: Sort the words in s to their original positions \"Me1 Myself2 and3 I4\", then remove the numbers.\n\nConstraints:\n\n- 2 <= s.length <= 200\n- s consists of lowercase and uppercase English letters, spaces, and digits from 1 to 9.\n- The number of words in s is between 1 and 9.\n- The words in s are separated by a single space.\n- s contains no leading or trailing spaces.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"eight8 seven7 six6 five5 four4 three3 two2 one1\") == \"one two three four five six seven eight\"\n assert candidate(s = \"seven7 six6 five5 four4 three3 two2 one1\") == \"one two three four five six seven\"\n assert candidate(s = \"nine9 eight8 seven7 six6 five5 four4 three3 two2 one1\") == \"one two three four five six seven eight nine\"\n assert candidate(s = \"three3 two2 one1\") == \"one two three\"\n assert candidate(s = \"is2 sentence4 This1 a3\") == \"This is a sentence\"\n assert candidate(s = \"five5 four4 three3 two2 one1\") == \"one two three four five\"\n assert candidate(s = \"A9 B8 C7 D6 E5 F4 G3 H2 I1\") == \"I H G F E D C B A\"\n assert candidate(s = \"Myself2 Me1 I4 and3\") == \"Me Myself and I\"\n assert candidate(s = \"nine9 eight8 seven7 six6 five5 four4 three3 two2 one1 zero0\") == \"one two three four five six seven eight nine zero\"\n assert candidate(s = \"six6 five5 four4 three3 two2 one1\") == \"one two three four five six\"\n assert candidate(s = \"one1\") == \"one\"\n assert candidate(s = \"two1 one2\") == \"two one\"\n assert candidate(s = \"four4 three3 two2 one1\") == \"one two three four\"\n assert candidate(s = \"quick5 brown3 fox2 jumps9 over8 lazy4 the7 dog6 a1\") == \"a fox brown lazy quick dog the over jumps\"\n assert candidate(s = \"Quick5 brown4 fox3 jumps2 over1\") == \"over jumps fox brown Quick\"\n assert candidate(s = \"big2 bigger3 biggest1\") == \"biggest big bigger\"\n assert candidate(s = \"order10 words9 in8 correct7 sequence6 is5 important4 for3 understanding2 this1\") == \"this understanding for important is sequence correct in words order1\"\n assert candidate(s = \"a1 bc2 def3 ghij4 klmno5 pqrstu6 vwxyz7 abcdefg8 hijklmno9\") == \"a bc def ghij klmno pqrstu vwxyz abcdefg hijklmno\"\n assert candidate(s = \"abc1 def2 ghi3 jkl4 mno5 pqr6 stu7 vwx8 yza9\") == \"abc def ghi jkl mno pqr stu vwx yza\"\n assert candidate(s = \"Data2 Science1\") == \"Science Data\"\n assert candidate(s = \"alpha10 beta9 gamma8 delta7 epsilon6 zeta5 eta4 theta3 iota2 kappa1\") == \"kappa iota theta eta zeta epsilon delta gamma beta alpha1\"\n assert candidate(s = \"Quick5 Brown4 Fox3 Jumps2 Over1\") == \"Over Jumps Fox Brown Quick\"\n assert candidate(s = \"Digital2 Transformation1\") == \"Transformation Digital\"\n assert candidate(s = \"zebra9 yellow8 xenon7 winter6 volcano5 umbrella4 tornado3 storm2 rainbow1\") == \"rainbow storm tornado umbrella volcano winter xenon yellow zebra\"\n assert candidate(s = \"short1 longerWord2 evenLongerWord3\") == \"short longerWord evenLongerWord\"\n assert candidate(s = \"one9 two8 three7 four6 five5 six4 seven3 eight2 nine1\") == \"nine eight seven six five four three two one\"\n assert candidate(s = \"apple8 banana7 cherry6 date5 elderberry4 fig3 grape2 huckleberry1\") == \"huckleberry grape fig elderberry date cherry banana apple\"\n assert candidate(s = \"apple9 banana8 cherry7 date6 elderberry5 fig4 grape3 honeydew2 ice1\") == \"ice honeydew grape fig elderberry date cherry banana apple\"\n assert candidate(s = \"MixedCASE1 Word2 with3 DIFFERENT4 cases5\") == \"MixedCASE Word with DIFFERENT cases\"\n assert candidate(s = \"Python1 is2 great3\") == \"Python is great\"\n assert candidate(s = \"a9 b8 c7 d6 e5 f4 g3 h2 i1\") == \"i h g f e d c b a\"\n assert candidate(s = \"single1\") == \"single\"\n assert candidate(s = \"one1 two2 three3 four4 five5 six6 seven7 eight8 nine9\") == \"one two three four five six seven eight nine\"\n assert candidate(s = \"reverse9 order8 words7 in6 a5 sentence4 for3 testing2 purposes1\") == \"purposes testing for sentence a in words order reverse\"\n assert candidate(s = \"sun8 moon7 stars6 galaxy5 universe4 planets3 asteroid2 comet1\") == \"comet asteroid planets universe galaxy stars moon sun\"\n assert candidate(s = \"two2 one1 three3 four4 five5 six6 seven7 eight8 nine9\") == \"one two three four five six seven eight nine\"\n assert candidate(s = \"complex1 testing2 cases3 with4 multiple5 digits6 and7 shuffled8 order9\") == \"complex testing cases with multiple digits and shuffled order\"\n assert candidate(s = \"Sustainability1\") == \"Sustainability\"\n assert candidate(s = \"Hard2 Work3 Makes1 Success4\") == \"Makes Hard Work Success\"\n assert candidate(s = \"A5 B4 C3 D2 E1 F6 G7 H8 I9\") == \"E D C B A F G H I\"\n assert candidate(s = \"Alphabetically9 Better8 Christmas7 Does6 Everyone5 Feel4 Good3 Happy2 Indeed1\") == \"Indeed Happy Good Feel Everyone Does Christmas Better Alphabetically\"\n assert candidate(s = \"sun9 moon8 star7 planet6 comet5 asteroid4 meteor3 satellite2 galaxy1\") == \"galaxy satellite meteor asteroid comet planet star moon sun\"\n assert candidate(s = \"The9 quick8 brown7 fox6 jumps5 over4 lazy3 dog2 one1\") == \"one dog lazy over jumps fox brown quick The\"\n assert candidate(s = \"short6 longer5 very4 much3 more2 words1\") == \"words more much very longer short\"\n assert candidate(s = \"first1 second2 third3 fourth4 fifth5 sixth6 seventh7 eighth8 ninth9\") == \"first second third fourth fifth sixth seventh eighth ninth\"\n assert candidate(s = \"Two2 Words1\") == \"Words Two\"\n assert candidate(s = \"Complicated1 Sorting2 becomes3 significantly4 more5 challenging6 when7 words8 overlap9\") == \"Complicated Sorting becomes significantly more challenging when words overlap\"\n assert candidate(s = \"Python10 Java9 C8 Cpp7 Rust6 Go5 Ruby4 Swift3 Kotlin2 TypeScript1\") == \"TypeScript Kotlin Swift Ruby Go Rust Cpp C Java Python1\"\n assert candidate(s = \"zZ9 yY8 xX7 wW6 vV5 uU4 tT3 sS2 rR1\") == \"rR sS tT uU vV wW xX yY zZ\"\n assert candidate(s = \"A9 lot8 of7 testing6 needs5 to4 be3 done2 always1\") == \"always done be to needs testing of lot A\"\n assert candidate(s = \"z9 y8 x7 w6 v5 u4 t3 s2 r1\") == \"r s t u v w x y z\"\n assert candidate(s = \"twoWords2 oneWord1\") == \"oneWord twoWords\"\n assert candidate(s = \"ab9 cd8 ef7 gh6 ij5 kl4 mn3 op2 qr1\") == \"qr op mn kl ij gh ef cd ab\"\n assert candidate(s = \"Open3 Source2 Software1\") == \"Software Source Open\"\n assert candidate(s = \"a9 quick8 brown7 fox6 jumps5 over4 lazy3 dogs2 one1\") == \"one dogs lazy over jumps fox brown quick a\"\n assert candidate(s = \"aA9 bB8 cC7 dD6 eE5 fF4 gG3 hH2 iI1\") == \"iI hH gG fF eE dD cC bB aA\"\n assert candidate(s = \"shuffle7 sentence6 original5 reconstruct4 and3 a2 is1\") == \"is a and reconstruct original sentence shuffle\"\n assert candidate(s = \"shuffle9 words8 correctly7 to6 get5 the4 right3 order2 one1\") == \"one order right the get to correctly words shuffle\"\n assert candidate(s = \"HELLO1 woRLD2\") == \"HELLO woRLD\"\n assert candidate(s = \"Short1 words2 can3 also4 be5 tricky6\") == \"Short words can also be tricky\"\n assert candidate(s = \"Python3 Java2 C1 Ruby4 Go5\") == \"C Java Python Ruby Go\"\n assert candidate(s = \"mixed8 case7 word6 CASE5 Mixed4 CASE3 mixed2 CASE1\") == \"CASE mixed CASE Mixed CASE word case mixed\"\n assert candidate(s = \"Python3 Java2 C1\") == \"C Java Python\"\n assert candidate(s = \"This8 is7 a6 sample5 sentence4 with3 various2 words1\") == \"words various with sentence sample a is This\"\n assert candidate(s = \"ninja9 samurai8 katana7 wakizashi6 tanto5 yoroi4 kusarigama3 tsurugi2 ninja1\") == \"ninja tsurugi kusarigama yoroi tanto wakizashi katana samurai ninja\"\n assert candidate(s = \"alpha9 beta8 gamma7 delta6 epsilon5 zeta4 eta3 theta2 iota1\") == \"iota theta eta zeta epsilon delta gamma beta alpha\"\n assert candidate(s = \"zebra9 yak8 xenon7 wolf6 vulture5 unicorn4 tiger3 snake2 rabbit1\") == \"rabbit snake tiger unicorn vulture wolf xenon yak zebra\"\n assert candidate(s = \"repeated1 same2 numbers3 in4 different5 words6 should7 not8 be9 valid10\") == \"repeated same numbers in different words should not be valid1\"\n assert candidate(s = \"reverse9 order8 words7 in6 this5 shuffled4 sentence3 into2 proper1\") == \"proper into sentence shuffled this in words order reverse\"\n assert candidate(s = \"Single1\") == \"Single\"\n", "comparison": "exact"}, "public_tests": ["\"is2 sentence4 This1 a3\"", "\"Myself2 Me1 I4 and3\""], "hints": ["Divide the string into the words as an array of strings", "Sort the words by removing the last character from each word and sorting according to it"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().sortSentence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:00+00:00", "tests_total": 70, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "sorting", "bubble-sort"]}, "language": "python", "interface": {"raw_signature": "def sortSentence(self, s: str) -> str:", "container": "Solution", "callable": "sortSentence", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1860, "task_id": "incremental-memory-leak", "difficulty": "Medium", "problem_description": "You are given two integers memory1 and memory2 representing the available memory in bits on two memory sticks. There is currently a faulty program running that consumes an increasing amount of memory every second.\n\nAt the i^th second (starting from 1), i bits of memory are allocated to the stick with more available memory (or from the first memory stick if both have the same available memory). If neither stick has at least i bits of available memory, the program crashes.\n\nReturn an array containing [crashTime, memory1_crash, memory2_crash], where crashTime is the time (in seconds) when the program crashed and memory1_crash and memory2_crash are the available bits of memory in the first and second sticks respectively.\n\nExample 1:\n\nInput: memory1 = 2, memory2 = 2\nOutput: [3,1,0]\nExplanation: The memory is allocated as follows:\n- At the 1^st second, 1 bit of memory is allocated to stick 1. The first stick now has 1 bit of available memory.\n- At the 2^nd second, 2 bits of memory are allocated to stick 2. The second stick now has 0 bits of available memory.\n- At the 3^rd second, the program crashes. The sticks have 1 and 0 bits available respectively.\n\nExample 2:\n\nInput: memory1 = 8, memory2 = 11\nOutput: [6,0,4]\nExplanation: The memory is allocated as follows:\n- At the 1^st second, 1 bit of memory is allocated to stick 2. The second stick now has 10 bit of available memory.\n- At the 2^nd second, 2 bits of memory are allocated to stick 2. The second stick now has 8 bits of available memory.\n- At the 3^rd second, 3 bits of memory are allocated to stick 1. The first stick now has 5 bits of available memory.\n- At the 4^th second, 4 bits of memory are allocated to stick 2. The second stick now has 4 bits of available memory.\n- At the 5^th second, 5 bits of memory are allocated to stick 1. The first stick now has 0 bits of available memory.\n- At the 6^th second, the program crashes. The sticks have 0 and 4 bits available respectively.\n\nConstraints:\n\n- 0 <= memory1, memory2 <= 2^31 - 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(memory1 = 0,memory2 = 0) == [1, 0, 0]\n assert candidate(memory1 = 2147483647,memory2 = 2147483647) == [92681, 88047, 41707]\n assert candidate(memory1 = 1000000000,memory2 = 1000000000) == [63245, 49116, 17494]\n assert candidate(memory1 = 15,memory2 = 10) == [7, 4, 0]\n assert candidate(memory1 = 100,memory2 = 100) == [20, 0, 10]\n assert candidate(memory1 = 10,memory2 = 10) == [6, 1, 4]\n assert candidate(memory1 = 1073741823,memory2 = 1073741823) == [65535, 65534, 32767]\n assert candidate(memory1 = 1,memory2 = 1) == [2, 0, 1]\n assert candidate(memory1 = 8,memory2 = 11) == [6, 0, 4]\n assert candidate(memory1 = 1073741824,memory2 = 1073741824) == [65536, 0, 32768]\n assert candidate(memory1 = 15,memory2 = 15) == [7, 6, 3]\n assert candidate(memory1 = 1,memory2 = 2) == [2, 1, 1]\n assert candidate(memory1 = 15,memory2 = 5) == [6, 0, 5]\n assert candidate(memory1 = 100,memory2 = 50) == [17, 3, 11]\n assert candidate(memory1 = 2,memory2 = 2) == [3, 1, 0]\n assert candidate(memory1 = 1000000000,memory2 = 500000000) == [54772, 3472, 37922]\n assert candidate(memory1 = 0,memory2 = 1000000) == [1414, 0, 1009]\n assert candidate(memory1 = 1024,memory2 = 512) == [55, 12, 39]\n assert candidate(memory1 = 123456789,memory2 = 987654321) == [47140, 11258, 33622]\n assert candidate(memory1 = 256,memory2 = 255) == [32, 15, 0]\n assert candidate(memory1 = 1000000000,memory2 = 999999999) == [63245, 17493, 49116]\n assert candidate(memory1 = 2048,memory2 = 512) == [71, 67, 8]\n assert candidate(memory1 = 5,memory2 = 1) == [3, 2, 1]\n assert candidate(memory1 = 500000000,memory2 = 499999999) == [44721, 8039, 30400]\n assert candidate(memory1 = 100000,memory2 = 100001) == [632, 460, 145]\n assert candidate(memory1 = 1073741823,memory2 = 1073741824) == [65536, 32767, 0]\n assert candidate(memory1 = 2147483647,memory2 = 1073741824) == [80264, 34153, 76602]\n assert candidate(memory1 = 1000000,memory2 = 0) == [1414, 1009, 0]\n assert candidate(memory1 = 5,memory2 = 5) == [4, 1, 3]\n assert candidate(memory1 = 0,memory2 = 100) == [14, 0, 9]\n assert candidate(memory1 = 1000000000,memory2 = 2000000000) == [77459, 17790, 72599]\n assert candidate(memory1 = 500000000,memory2 = 500000001) == [44721, 8040, 30401]\n assert candidate(memory1 = 500000,memory2 = 500000) == [1414, 151, 858]\n assert candidate(memory1 = 2000000000,memory2 = 1000000000) == [77459, 72599, 17790]\n assert candidate(memory1 = 1,memory2 = 0) == [2, 0, 0]\n assert candidate(memory1 = 1000000,memory2 = 1000000) == [2000, 0, 1000]\n assert candidate(memory1 = 2147483647,memory2 = 0) == [65536, 32767, 0]\n assert candidate(memory1 = 500000000,memory2 = 500000000) == [44721, 30400, 8040]\n assert candidate(memory1 = 1234567890,memory2 = 1234567890) == [70272, 29394, 64530]\n assert candidate(memory1 = 1024,memory2 = 1023) == [64, 31, 0]\n assert candidate(memory1 = 1023,memory2 = 1024) == [64, 31, 0]\n assert candidate(memory1 = 1048576,memory2 = 1048576) == [2048, 0, 1024]\n assert candidate(memory1 = 512,memory2 = 1024) == [55, 39, 12]\n assert candidate(memory1 = 1000000000,memory2 = 1000000001) == [63245, 17494, 49117]\n assert candidate(memory1 = 4,memory2 = 5) == [4, 2, 1]\n assert candidate(memory1 = 0,memory2 = 2147483647) == [65536, 0, 32767]\n assert candidate(memory1 = 512,memory2 = 2048) == [71, 8, 67]\n assert candidate(memory1 = 1000000,memory2 = 999999) == [2000, 999, 0]\n assert candidate(memory1 = 2147483647,memory2 = 2147483646) == [92681, 41706, 88047]\n assert candidate(memory1 = 4,memory2 = 4) == [4, 0, 2]\n assert candidate(memory1 = 4096,memory2 = 2048) == [110, 102, 47]\n assert candidate(memory1 = 1024,memory2 = 1024) == [64, 0, 32]\n assert candidate(memory1 = 2147483646,memory2 = 1) == [65536, 32766, 1]\n assert candidate(memory1 = 234567890,memory2 = 234567890) == [30631, 18665, 3350]\n assert candidate(memory1 = 2147483646,memory2 = 2147483646) == [92681, 88046, 41706]\n assert candidate(memory1 = 1,memory2 = 1000000000) == [44721, 1, 38440]\n assert candidate(memory1 = 999999999,memory2 = 1) == [44721, 38439, 1]\n assert candidate(memory1 = 500,memory2 = 500) == [44, 16, 38]\n assert candidate(memory1 = 2,memory2 = 1) == [2, 1, 1]\n assert candidate(memory1 = 128,memory2 = 256) == [27, 23, 10]\n assert candidate(memory1 = 1,memory2 = 1073741823) == [46341, 1, 20853]\n assert candidate(memory1 = 100000,memory2 = 100000) == [632, 144, 460]\n assert candidate(memory1 = 0,memory2 = 1000) == [45, 0, 10]\n assert candidate(memory1 = 2147483646,memory2 = 2147483645) == [92681, 41705, 88046]\n assert candidate(memory1 = 10,memory2 = 1) == [5, 0, 1]\n assert candidate(memory1 = 0,memory2 = 1) == [2, 0, 0]\n assert candidate(memory1 = 1000000001,memory2 = 1000000000) == [63245, 17494, 49117]\n assert candidate(memory1 = 1,memory2 = 2147483647) == [65536, 1, 32767]\n assert candidate(memory1 = 100,memory2 = 0) == [14, 9, 0]\n assert candidate(memory1 = 2147483646,memory2 = 2147483647) == [92681, 41706, 88047]\n assert candidate(memory1 = 1073741823,memory2 = 1073741825) == [65536, 0, 32768]\n assert candidate(memory1 = 10,memory2 = 15) == [7, 0, 4]\n assert candidate(memory1 = 9,memory2 = 9) == [6, 0, 3]\n assert candidate(memory1 = 1000,memory2 = 1000) == [63, 39, 8]\n assert candidate(memory1 = 2048,memory2 = 4096) == [110, 47, 102]\n assert candidate(memory1 = 1000,memory2 = 0) == [45, 10, 0]\n assert candidate(memory1 = 1,memory2 = 5) == [3, 1, 2]\n assert candidate(memory1 = 1000000000,memory2 = 1) == [44721, 38440, 1]\n", "comparison": "exact"}, "public_tests": ["2\n2", "8\n11"], "hints": ["What is the upper bound for the number of seconds?", "Simulate the process of allocating memory."], "metadata": {"canonical_parameter_names": ["memory1", "memory2"], "leetcode_dataset_entry_point": "Solution().memLeak", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:02+00:00", "tests_total": 81, "tests_dropped": 3, "flags": [], "topic_tags": ["math", "simulation"]}, "language": "python", "interface": {"raw_signature": "def memLeak(self, memory1: int, memory2: int) -> list[int]:", "container": "Solution", "callable": "memLeak", "parameters": [{"name": "memory1", "type": "int"}, {"name": "memory2", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1861, "task_id": "rotating-the-box", "difficulty": "Medium", "problem_description": "You are given an m x n matrix of characters boxGrid representing a side-view of a box. Each cell of the box is one of the following:\n\n- A stone '#'\n- A stationary obstacle '*'\n- Empty '.'\n\nThe box is rotated 90 degrees clockwise, causing some of the stones to fall due to gravity. Each stone falls down until it lands on an obstacle, another stone, or the bottom of the box. Gravity does not affect the obstacles' positions, and the inertia from the box's rotation does not affect the stones' horizontal positions.\n\nIt is guaranteed that each stone in boxGrid rests on an obstacle, another stone, or the bottom of the box.\n\nReturn an n x m matrix representing the box after the rotation described above.\n\nExample 1:\n\nInput: boxGrid = [[\"#\",\".\",\"#\"]]\nOutput: [[\".\"],\n [\"#\"],\n [\"#\"]]\n\nExample 2:\n\nInput: boxGrid = [[\"#\",\".\",\"*\",\".\"],\n [\"#\",\"#\",\"*\",\".\"]]\nOutput: [[\"#\",\".\"],\n [\"#\",\"#\"],\n [\"*\",\"*\"],\n [\".\",\".\"]]\n\nExample 3:\n\nInput: boxGrid = [[\"#\",\"#\",\"*\",\".\",\"*\",\".\"],\n [\"#\",\"#\",\"#\",\"*\",\".\",\".\"],\n [\"#\",\"#\",\"#\",\".\",\"#\",\".\"]]\nOutput: [[\".\",\"#\",\"#\"],\n [\".\",\"#\",\"#\"],\n [\"#\",\"#\",\"*\"],\n [\"#\",\"*\",\".\"],\n [\"#\",\".\",\"*\"],\n [\"#\",\".\",\".\"]]\n\nConstraints:\n\n- m == boxGrid.length\n- n == boxGrid[i].length\n- 1 <= m, n <= 500\n- boxGrid[i][j] is either '#', '*', or '.'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(boxGrid = [['#', '.', '*', '.'], ['#', '#', '*', '.']]) == [['#', '.'], ['#', '#'], ['*', '*'], ['.', '.']]\n assert candidate(boxGrid = [['#', '.', '#']]) == [['.'], ['#'], ['#']]\n assert candidate(boxGrid = [['#', '#', '*', '.', '*', '.'], ['#', '#', '#', '*', '.', '.'], ['#', '#', '#', '.', '#', '.']]) == [['.', '#', '#'], ['.', '#', '#'], ['#', '#', '*'], ['#', '*', '.'], ['#', '.', '*'], ['#', '.', '.']]\n assert candidate(boxGrid = [['*', '.', '.', '.', '#', '.', '*', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['#', '.', '.', '.', '.']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '*', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '*', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '#', '#', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '#', '*', '.'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '#'], ['.', '.', '#'], ['.', '#', '*'], ['#', '#', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '#', '.'], ['*', '.', '#', '.', '.', '#'], ['#', '.', '*', '.', '#', '.'], ['.', '#', '#', '*', '.', '.']]) == [['.', '.', '*', '.'], ['#', '#', '.', '.'], ['#', '*', '.', '.'], ['*', '.', '.', '.'], ['.', '.', '#', '#'], ['.', '#', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '#', '*'], ['*', '.', '.', '#'], ['.', '#', '.', '.'], ['#', '.', '.', '.']]) == [['.', '.', '*', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#'], ['#', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '*', '.', '.'], ['.', '#', '#', '.', '.', '#'], ['#', '.', '.', '.', '#', '.'], ['#', '.', '*', '.', '.', '*'], ['.', '.', '.', '#', '#', '.']]) == [['.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.'], ['.', '*', '.', '.', '#'], ['.', '.', '.', '#', '*'], ['#', '.', '#', '#', '.'], ['#', '*', '#', '#', '.']]\n assert candidate(boxGrid = [['*', '.', '.', '#'], ['.', '#', '#', '*'], ['.', '#', '.', '.'], ['.', '.', '.', '.']]) == [['.', '.', '.', '*'], ['.', '.', '#', '.'], ['.', '.', '#', '.'], ['.', '#', '*', '#']]\n assert candidate(boxGrid = [['#', '.', '*', '.', '#', '.', '*', '.'], ['.', '#', '.', '.', '.', '#', '.', '.'], ['.', '.', '#', '.', '.', '.', '#', '.']]) == [['.', '.', '.'], ['.', '.', '#'], ['.', '.', '*'], ['.', '.', '.'], ['.', '.', '.'], ['.', '.', '#'], ['#', '#', '*'], ['#', '#', '.']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '*'], ['.', '#', '#', '.', '.'], ['.', '.', '*', '.', '#'], ['#', '.', '.', '#', '.']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '*', '.', '#'], ['#', '.', '#', '#'], ['#', '#', '#', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#', '*', '.'], ['.', '.', '#', '*', '.', '.', '.'], ['#', '*', '.', '.', '.', '.', '.']]) == [['#', '.', '.', '.'], ['*', '.', '.', '.'], ['.', '#', '.', '.'], ['.', '*', '.', '.'], ['.', '.', '#', '.'], ['.', '.', '*', '.'], ['.', '.', '.', '#']]\n assert candidate(boxGrid = [['#', '#', '*', '#', '.', '.', '*', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '*', '.', '.'], ['.', '.', '.', '.', '#', '.', '.', '#', '.']]) == [['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '*', '.', '.', '*'], ['#', '.', '#', '.', '.'], ['#', '.', '#', '#', '.']]\n assert candidate(boxGrid = [['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '*'], ['.', '.', '#', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '#', '*', '#', '.', '#', '#']]\n assert candidate(boxGrid = [['#', '#', '#', '.', '.', '.', '*'], ['.', '.', '#', '#', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '.', '*', '.', '.', '.'], ['#', '.', '#', '.', '.', '.', '#'], ['.', '.', '.', '.', '#', '.', '.'], ['.', '*', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.', '.'], ['*', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '*', '.', '.', '#'], ['.', '.', '#', '.', '.', '.', '#'], ['.', '.', '#', '.', '#', '#', '#'], ['.', '#', '#', '.', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '#', '*', '.', '*', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['*', '.', '.', '.', '*', '.', '.'], ['.', '#', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#']]) == [['.', '.', '*', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['.', '.', '*', '.', '.'], ['.', '#', '.', '.', '*'], ['#', '#', '.', '.', '.']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['#', '#', '#', '.'], ['.', '.', '#', '.'], ['.', '#', '.', '.']]) == [['.', '.', '.', '.'], ['.', '.', '#', '.'], ['.', '.', '#', '.'], ['#', '#', '#', '.']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '*'], ['#', '#', '#', '#', '#']]) == [['#', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['#', '*', '.', '.', '.', '.']]\n assert candidate(boxGrid = [['#', '#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.', '.'], ['*', '*', '*', '*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#']]\n assert candidate(boxGrid = [['.', '.', '#', '*', '#'], ['#', '.', '#', '.', '.'], ['.', '*', '.', '#', '.']]) == [['.', '.', '.'], ['*', '.', '.'], ['.', '.', '#'], ['.', '#', '*'], ['#', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '*']]) == [['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['*', '#', '#', '#', '#', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '#', '.', '#', '.', '*', '.'], ['.', '.', '#', '.', '.', '.', '#', '.'], ['#', '.', '.', '.', '*', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['*', '.', '.', '.', '.', '.', '.', '*'], ['.', '#', '.', '.', '.', '.', '.', '.']]) == [['.', '*', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '#'], ['.', '.', '.', '*', '.', '#'], ['.', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#', '*'], ['#', '*', '.', '.', '#', '.']]\n assert candidate(boxGrid = [['#', '#', '#', '#', '*', '.'], ['.', '.', '*', '#', '.', '#'], ['*', '.', '#', '.', '.', '#'], ['#', '#', '#', '#', '.', '.']]) == [['.', '*', '.', '#'], ['.', '.', '.', '#'], ['#', '.', '*', '#'], ['#', '.', '.', '#'], ['#', '#', '#', '*'], ['#', '#', '#', '.']]\n assert candidate(boxGrid = [['*', '.', '.', '#', '.', '*'], ['.', '#', '.', '.', '.', '#'], ['.', '.', '#', '.', '*', '.'], ['#', '.', '.', '.', '.', '#'], ['.', '*', '.', '#', '.', '.']]) == [['.', '.', '.', '.', '*'], ['*', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '*', '#', '#'], ['#', '#', '.', '#', '*']]\n assert candidate(boxGrid = [['.', '.', '#', '.', '*', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['.', '#', '#', '*', '.', '.', '.'], ['.', '.', '.', '.', '.', '*', '.']]) == [['.', '.', '.', '.'], ['.', '#', '.', '.'], ['.', '#', '.', '.'], ['.', '*', '.', '#'], ['.', '.', '.', '*'], ['*', '.', '#', '.'], ['.', '.', '#', '#']]\n assert candidate(boxGrid = [['#', '*', '#', '*', '.', '#'], ['.', '#', '.', '.', '.', '.'], ['#', '.', '.', '*', '#', '.'], ['*', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '.']]) == [['.', '*', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['.', '.', '#', '.', '#'], ['.', '.', '*', '.', '*'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '#', '.', '.', '.', '#'], ['.', '.', '.', '#', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['#', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#'], ['.', '#', '.', '#'], ['#', '#', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['#', '#', '.', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '#']]) == [['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '.', '.', '#']]\n assert candidate(boxGrid = [['*', '*', '*', '*', '*'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['*', '*', '#', '#', '.'], ['#', '#', '.', '.', '.']]) == [['.', '*', '.', '#', '*'], ['.', '*', '.', '#', '*'], ['.', '.', '.', '#', '*'], ['#', '#', '.', '#', '*'], ['#', '#', '.', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '.', '.'], ['.', '#', '#', '.', '.', '.'], ['.', '.', '#', '#', '.', '.'], ['.', '.', '.', '#', '#', '.'], ['.', '.', '.', '.', '#', '#'], ['.', '.', '.', '.', '.', '#']]) == [['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#']]\n assert candidate(boxGrid = [['*', '.', '.', '.', '.', '.', '#', '.', '*'], ['.', '.', '#', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '#', '#', '#'], ['.', '.', '.', '#', '#', '#', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '*'], ['.', '#', '.', '.', '.'], ['.', '.', '#', '.', '.'], ['.', '.', '.', '#', '.'], ['.', '.', '.', '.', '#']]) == [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['#', '#', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '*', '.'], ['#', '.', '.', '#', '.', '.'], ['*', '#', '.', '.', '.', '#'], ['.', '.', '.', '#', '*', '.'], ['#', '.', '.', '.', '.', '.']]) == [['.', '.', '*', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '#', '.', '.', '#'], ['.', '*', '#', '#', '*'], ['#', '.', '#', '#', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '.', '.', '*'], ['#', '#', '.', '.', '.', '*', '.'], ['*', '.', '.', '#', '.', '.', '.'], ['.', '#', '#', '.', '.', '.', '#'], ['#', '.', '.', '.', '#', '.', '.'], ['.', '.', '#', '.', '.', '#', '.']]) == [['.', '.', '.', '*', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.'], ['#', '#', '#', '.', '*', '#'], ['#', '#', '#', '#', '.', '*']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '*', '.'], ['.', '#', '#', '*', '.', '#'], ['.', '.', '#', '#', '#', '.'], ['*', '.', '.', '#', '.', '.'], ['.', '#', '.', '.', '#', '*']]) == [['.', '*', '.', '.', '.'], ['.', '.', '.', '#', '.'], ['.', '.', '.', '#', '#'], ['#', '.', '#', '*', '#'], ['#', '.', '#', '.', '*'], ['*', '#', '#', '#', '.']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '*', '.'], ['#', '.', '#', '.', '.', '*'], ['.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '#', '.'], ['.', '*', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.'], ['*', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '#', '#'], ['.', '.', '#', '#', '*'], ['.', '#', '#', '*', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '#', '.', '.', '*', '.', '.', '#'], ['.', '#', '#', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.'], ['.', '#', '.', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '#']]) == [['.'], ['#'], ['#']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['*', '*', '*', '*']]) == [['*', '.'], ['*', '.'], ['*', '.'], ['*', '.']]\n assert candidate(boxGrid = [['#', '.', '#']]) == [['.'], ['#'], ['#']]\n assert candidate(boxGrid = [['*'], ['.'], ['#']]) == [['#', '.', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['*', '*', '*', '*']]) == [['*', '.', '.'], ['*', '.', '.'], ['*', '.', '.'], ['*', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '#'], ['.', '#', '.', '.'], ['.', '.', '#', '.'], ['#', '.', '.', '*']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '.', '.', '#'], ['*', '#', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '*'], ['.', '#', '.', '*'], ['#', '.', '#', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['#', '#', '#'], ['#', '*', '*']]\n assert candidate(boxGrid = [['#', '#', '#'], ['*', '*', '*'], ['#', '#', '#']]) == [['#', '*', '#'], ['#', '*', '#'], ['#', '*', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '#', '*', '.'], ['#', '#', '#', '*']]) == [['#', '#', '.', '.'], ['#', '#', '.', '.'], ['#', '*', '.', '.'], ['*', '.', '.', '.']]\n assert candidate(boxGrid = [['#', '#', '#'], ['.', '.', '.'], ['*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#']]\n assert candidate(boxGrid = [['.', '#', '#', '*']]) == [['.'], ['#'], ['#'], ['*']]\n assert candidate(boxGrid = [['#', '.', '#']]) == [['.'], ['#'], ['#']]\n assert candidate(boxGrid = [['*', '*', '*', '*']]) == [['*'], ['*'], ['*'], ['*']]\n assert candidate(boxGrid = [['#', '#', '#', '#', '#', '*', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['*', '*', '*', '*', '*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '*'], ['*', '.', '.']]\n assert candidate(boxGrid = [['.', '#', '*', '#', '.', '*'], ['#', '.', '#', '.', '.', '#'], ['*', '.', '.', '#', '*', '.'], ['.', '#', '#', '*', '#', '.']]) == [['.', '*', '.', '.'], ['#', '.', '.', '#'], ['#', '.', '.', '*'], ['*', '#', '#', '.'], ['.', '*', '#', '#'], ['#', '.', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '*'], ['.', '#', '.', '.'], ['.', '.', '#', '*']]) == [['.', '.', '.'], ['.', '.', '.'], ['#', '.', '#'], ['*', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '*', '.', '*', '.'], ['#', '#', '#', '*', '.', '.'], ['#', '#', '#', '.', '#', '.']]) == [['.', '#', '#'], ['.', '#', '#'], ['#', '#', '*'], ['#', '*', '.'], ['#', '.', '*'], ['#', '.', '.']]\n assert candidate(boxGrid = [['#', '#'], ['*', '.'], ['#', '.']]) == [['.', '*', '#'], ['#', '.', '#']]\n assert candidate(boxGrid = [['#', '*'], ['#', '*']]) == [['#', '#'], ['*', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '*'], ['.', '#', '.', '.'], ['.', '.', '#', '.'], ['.', '.', '.', '*']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#'], ['*', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '#'], ['.', '.', '.'], ['*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#']]\n assert candidate(boxGrid = [['#', '.', '*', '#', '.', '*'], ['#', '#', '.', '.', '#', '.'], ['.', '#', '#', '*', '.', '.'], ['*', '.', '.', '.', '.', '*']]) == [['*', '.', '.', '.'], ['.', '#', '.', '#'], ['.', '#', '.', '*'], ['.', '*', '#', '.'], ['.', '.', '#', '#'], ['*', '.', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '*'], ['.', '#', '.'], ['*', '.', '#']]) == [['*', '.', '.'], ['.', '.', '#'], ['#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '*'], ['.', '#', '.', '#'], ['.', '.', '#', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['.', '#', '#'], ['#', '#', '*']]\n assert candidate(boxGrid = [['.', '#', '.'], ['*', '.', '#'], ['#', '#', '*']]) == [['#', '*', '.'], ['#', '.', '.'], ['*', '#', '#']]\n assert candidate(boxGrid = [['.', '#', '.', '*', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['*', '.', '#', '.', '.', '*']]) == [['*', '.', '.'], ['.', '.', '.'], ['.', '.', '#'], ['.', '.', '*'], ['#', '.', '.'], ['*', '.', '#']]\n assert candidate(boxGrid = [['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['*', '*', '*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#']]\n assert candidate(boxGrid = [['.', '#', '*'], ['.', '.', '#'], ['#', '.', '.']]) == [['.', '.', '.'], ['.', '.', '#'], ['#', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '.', '*'], ['.', '.', '.', '.'], ['.', '*', '.', '#'], ['#', '.', '#', '*']]) == [['.', '.', '.', '.'], ['#', '*', '.', '#'], ['#', '.', '.', '#'], ['*', '#', '.', '*']]\n assert candidate(boxGrid = [['*', '.', '.', '.'], ['#', '#', '#', '.'], ['*', '*', '#', '.']]) == [['*', '.', '*'], ['*', '#', '.'], ['.', '#', '.'], ['#', '#', '.']]\n assert candidate(boxGrid = [['#', '#', '#'], ['#', '#', '#'], ['#', '#', '#']]) == [['#', '#', '#'], ['#', '#', '#'], ['#', '#', '#']]\n assert candidate(boxGrid = [['#', '#', '#'], ['*', '*', '*'], ['.', '.', '.']]) == [['.', '*', '#'], ['.', '*', '#'], ['.', '*', '#']]\n assert candidate(boxGrid = [['*', '.', '.', '#'], ['*', '.', '.', '.'], ['#', '.', '.', '*']]) == [['.', '*', '*'], ['.', '.', '.'], ['#', '.', '.'], ['*', '.', '#']]\n assert candidate(boxGrid = [['*', '*', '*', '*'], ['#', '#', '#', '#'], ['*', '*', '*', '*'], ['#', '#', '#', '#']]) == [['#', '*', '#', '*'], ['#', '*', '#', '*'], ['#', '*', '#', '*'], ['#', '*', '#', '*']]\n assert candidate(boxGrid = [['#', '*'], ['#', '.'], ['#', '.'], ['#', '.']]) == [['.', '.', '.', '#'], ['#', '#', '#', '*']]\n assert candidate(boxGrid = [['#'], ['*'], ['.']]) == [['.', '*', '#']]\n assert candidate(boxGrid = [['.', '#', '*', '.', '#'], ['.', '.', '#', '.', '.'], ['#', '.', '.', '*', '.']]) == [['.', '.', '.'], ['.', '.', '#'], ['#', '.', '*'], ['*', '.', '.'], ['.', '#', '#']]\n assert candidate(boxGrid = [['#', '*', '.'], ['.', '#', '.'], ['.', '.', '#']]) == [['.', '.', '#'], ['.', '.', '*'], ['#', '#', '.']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['#', '#', '#', '#'], ['.', '*', '.', '*'], ['#', '.', '#', '.']]) == [['.', '.', '#', '.'], ['.', '*', '#', '.'], ['#', '.', '#', '.'], ['#', '*', '#', '.']]\n assert candidate(boxGrid = [['*', '*', '.', '*'], ['*', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#']]) == [['.', '.', '*', '*'], ['.', '.', '.', '*'], ['.', '.', '.', '.'], ['#', '.', '.', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['#', '#', '#', '#'], ['*', '.', '*', '.']]) == [['*', '#', '.'], ['.', '#', '.'], ['*', '#', '.'], ['.', '#', '.']]\n assert candidate(boxGrid = [['.', '#'], ['.', '*'], ['#', '.'], ['*', '.']]) == [['*', '.', '.', '.'], ['.', '#', '*', '#']]\n assert candidate(boxGrid = [['.', '.', '*', '.', '#'], ['#', '.', '#', '.', '.'], ['.', '#', '.', '*', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['#', '.', '*'], ['*', '#', '.'], ['.', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '#', '#', '#'], ['*', '.', '.', '*']]) == [['*', '#', '.', '.'], ['.', '#', '.', '.'], ['.', '#', '.', '.'], ['*', '#', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '*', '.'], ['#', '#', '*', '.']]) == [['#', '.'], ['#', '#'], ['*', '*'], ['.', '.']]\n assert candidate(boxGrid = [['#', '*', '#'], ['*', '#', '*'], ['#', '*', '#']]) == [['#', '*', '#'], ['*', '#', '*'], ['#', '*', '#']]\n assert candidate(boxGrid = [['.', '#', '*', '#', '.', '.', '#'], ['#', '.', '.', '.', '#', '.', '.'], ['.', '*', '.', '.', '.', '#', '#'], ['.', '.', '#', '.', '.', '.', '*']]) == [['.', '.', '.', '.'], ['.', '*', '.', '#'], ['.', '.', '.', '*'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '#', '#', '#'], ['*', '#', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '*', '.'], ['#', '#', '*', '.']]) == [['#', '.'], ['#', '#'], ['*', '*'], ['.', '.']]\n assert candidate(boxGrid = [['#'], ['.'], ['*']]) == [['*', '.', '#']]\n assert candidate(boxGrid = [['*', '.', '#'], ['.', '#', '.'], ['#', '.', '*']]) == [['.', '.', '*'], ['#', '.', '.'], ['*', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '#'], ['.', '.', '#', '.', '.'], ['#', '#', '#', '*', '.']]) == [['#', '.', '.'], ['#', '.', '.'], ['#', '.', '.'], ['*', '.', '#'], ['.', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '*'], ['#', '.', '.', '.', '.'], ['#', '.', '#', '.', '.'], ['#', '#', '.', '.', '.'], ['#', '.', '.', '#', '.'], ['#', '#', '#', '.', '.']]) == [['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['#', '#', '#', '#', '.', '#'], ['#', '#', '#', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '#'], ['.', '*', '.'], ['#', '#', '#']]) == [['#', '.', '.'], ['#', '*', '#'], ['#', '.', '#']]\n assert candidate(boxGrid = [['#', '#', '*', '.', '*', '.'], ['#', '#', '#', '*', '.', '.'], ['#', '#', '#', '.', '#', '.']]) == [['.', '#', '#'], ['.', '#', '#'], ['#', '#', '*'], ['#', '*', '.'], ['#', '.', '*'], ['#', '.', '.']]\n assert candidate(boxGrid = [['#', '#', '*', '.', '*', '.'], ['#', '#', '#', '*', '.', '.'], ['#', '#', '#', '.', '#', '.']]) == [['.', '#', '#'], ['.', '#', '#'], ['#', '#', '*'], ['#', '*', '.'], ['#', '.', '*'], ['#', '.', '.']]\n assert candidate(boxGrid = [['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*']]) == [['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*']]\n assert candidate(boxGrid = [['.', '.', '#'], ['.', '.', '.'], ['#', '.', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['#', '.', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '*'], ['#', '.', '#', '.'], ['.', '#', '.', '.'], ['#', '.', '.', '.']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '#', '.'], ['#', '#', '#', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['*', '*', '*', '*', '*']]) == [['*', '#', '.'], ['*', '#', '.'], ['*', '#', '.'], ['*', '#', '.'], ['*', '#', '.']]\n assert candidate(boxGrid = [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']]\n assert candidate(boxGrid = [['#', '#', '#', '*'], ['.', '.', '.', '.'], ['*', '.', '.', '*']]) == [['*', '.', '#'], ['.', '.', '#'], ['.', '.', '#'], ['*', '.', '*']]\n assert candidate(boxGrid = [['*', '*', '*', '*'], ['#', '#', '#', '#'], ['#', '#', '#', '#'], ['*', '*', '*', '*']]) == [['*', '#', '#', '*'], ['*', '#', '#', '*'], ['*', '#', '#', '*'], ['*', '#', '#', '*']]\n assert candidate(boxGrid = [['.', '.', '#', '*', '.'], ['#', '#', '.', '.', '#'], ['.', '*', '#', '.', '.']]) == [['.', '.', '.'], ['*', '.', '.'], ['.', '#', '#'], ['.', '#', '*'], ['#', '#', '.']]\n assert candidate(boxGrid = [['#', '.', '*', '.'], ['#', '#', '*', '.']]) == [['#', '.'], ['#', '#'], ['*', '*'], ['.', '.']]\n assert candidate(boxGrid = [['*', '*', '*', '*'], ['.', '.', '.', '.'], ['#', '#', '#', '#']]) == [['#', '.', '*'], ['#', '.', '*'], ['#', '.', '*'], ['#', '.', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '#'], ['.', '#', '#', '.'], ['.', '*', '.', '*']]) == [['.', '.', '.'], ['*', '.', '.'], ['.', '#', '#'], ['*', '#', '#']]\n assert candidate(boxGrid = [['#', '*', '*', '#'], ['#', '#', '#', '.'], ['*', '.', '.', '*']]) == [['*', '.', '#'], ['.', '#', '*'], ['.', '#', '*'], ['*', '#', '#']]\n assert candidate(boxGrid = [['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*']]) == [['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*']]\n assert candidate(boxGrid = [['#', '*', '.'], ['.', '.', '*'], ['*', '.', '.']]) == [['*', '.', '#'], ['.', '.', '*'], ['.', '*', '.']]\n assert candidate(boxGrid = [['*', '.', '.', '#'], ['#', '#', '#', '*'], ['#', '#', '.', '#']]) == [['.', '#', '*'], ['#', '#', '.'], ['#', '#', '.'], ['#', '*', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '*'], ['.', '#', '.', '.'], ['.', '#', '#', '.'], ['*', '#', '.', '*']]) == [['*', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '#', '.', '.'], ['*', '#', '#', '*']]\n", "comparison": "exact"}, "public_tests": ["[[\"#\",\".\",\"#\"]]", "[[\"#\",\".\",\"*\",\".\"],[\"#\",\"#\",\"*\",\".\"]]", "[[\"#\",\"#\",\"*\",\".\",\"*\",\".\"],[\"#\",\"#\",\"#\",\"*\",\".\",\".\"],[\"#\",\"#\",\"#\",\".\",\"#\",\".\"]]"], "hints": ["Rotate the box using the relation rotatedBox[i][j] = box[m - 1 - j][i].", "Start iterating from the bottom of the box and for each empty cell check if there is any stone above it with no obstacles between them."], "metadata": {"canonical_parameter_names": ["boxGrid"], "leetcode_dataset_entry_point": "Solution().rotateTheBox", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:05+00:00", "tests_total": 114, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "two-pointers", "matrix"]}, "language": "python", "interface": {"raw_signature": "def rotateTheBox(self, boxGrid: list[list[str]]) -> list[list[str]]:", "container": "Solution", "callable": "rotateTheBox", "parameters": [{"name": "boxGrid", "type": "list[list[str]]"}], "return_type": "list[list[str]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1862, "task_id": "sum-of-floored-pairs", "difficulty": "Hard", "problem_description": "Given an integer array nums, return the sum of floor(nums[i] / nums[j]) for all pairs of indices 0 <= i, j < nums.length in the array. Since the answer may be too large, return it modulo 10^9 + 7.\n\nThe floor() function returns the integer part of the division.\n\nExample 1:\n\nInput: nums = [2,5,9]\nOutput: 10\nExplanation:\nfloor(2 / 5) = floor(2 / 9) = floor(5 / 9) = 0\nfloor(2 / 2) = floor(5 / 5) = floor(9 / 9) = 1\nfloor(5 / 2) = 2\nfloor(9 / 2) = 4\nfloor(9 / 5) = 1\nWe calculate the floor of the division for every pair of indices in the array then sum them up.\n\nExample 2:\n\nInput: nums = [7,7,7,7,7,7,7]\nOutput: 49\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 49\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 100\n assert candidate(nums = [2, 5, 9]) == 10\n assert candidate(nums = [100000, 1, 100000]) == 200005\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250]) == 57\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 400\n assert candidate(nums = [10, 20, 30, 40, 50]) == 27\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 178\n assert candidate(nums = [1, 2, 3, 4, 5]) == 27\n assert candidate(nums = [100000, 100000, 100000]) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 65519\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980]) == 210\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 600\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 127\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3249\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 1492\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 127\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 2400\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 6268\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 834\n assert candidate(nums = [15, 15, 15, 30, 30, 45, 45, 60, 60, 75, 75, 90, 90, 105, 105]) == 287\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 55\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 100\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 371\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 508\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 600\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 314\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000, 21000, 22000, 23000, 24000, 25000]) == 991\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 508\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 1650\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 623578\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000]) == 123456\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 127\n assert candidate(nums = [100000, 100000, 50000, 50000, 25000, 25000, 12500, 12500, 6250, 6250]) == 228\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 127\n assert candidate(nums = [50000, 40000, 30000, 20000, 10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1]) == 314353\n assert candidate(nums = [5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50]) == 508\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 513\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 400\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2036\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 127\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 2806\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 600\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 313945\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 949\n assert candidate(nums = [50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == 166591\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 6400\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225]) == 314\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 2841\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 65519\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1024\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 600\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 314\n assert candidate(nums = [3, 3, 3, 5, 5, 5, 7, 7, 7, 11, 11, 11, 13, 13, 13, 17, 17, 17, 19, 19]) == 412\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 1]) == 500096\n", "comparison": "exact"}, "public_tests": ["[2,5,9]", "[7,7,7,7,7,7,7]"], "hints": ["Find the frequency (number of occurrences) of all elements in the array.", "For each element, iterate through its multiples and multiply frequencies to find the answer."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumOfFlooredPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:09+00:00", "tests_total": 60, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "math", "binary-search", "counting", "enumeration", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def sumOfFlooredPairs(self, nums: list[int]) -> int:", "container": "Solution", "callable": "sumOfFlooredPairs", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1863, "task_id": "sum-of-all-subset-xor-totals", "difficulty": "Easy", "problem_description": "The XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty.\n\n- For example, the XOR total of the array [2,5,6] is 2 XOR 5 XOR 6 = 1.\n\nGiven an array nums, return the sum of all XOR totals for every subset of nums.\n\nNote: Subsets with the same elements should be counted multiple times.\n\nAn array a is a subset of an array b if a can be obtained from b by deleting some (possibly zero) elements of b.\n\nExample 1:\n\nInput: nums = [1,3]\nOutput: 6\nExplanation: The 4 subsets of [1,3] are:\n- The empty subset has an XOR total of 0.\n- [1] has an XOR total of 1.\n- [3] has an XOR total of 3.\n- [1,3] has an XOR total of 1 XOR 3 = 2.\n0 + 1 + 3 + 2 = 6\n\nExample 2:\n\nInput: nums = [5,1,6]\nOutput: 28\nExplanation: The 8 subsets of [5,1,6] are:\n- The empty subset has an XOR total of 0.\n- [5] has an XOR total of 5.\n- [1] has an XOR total of 1.\n- [6] has an XOR total of 6.\n- [5,1] has an XOR total of 5 XOR 1 = 4.\n- [5,6] has an XOR total of 5 XOR 6 = 3.\n- [1,6] has an XOR total of 1 XOR 6 = 7.\n- [5,1,6] has an XOR total of 5 XOR 1 XOR 6 = 2.\n0 + 5 + 1 + 6 + 4 + 3 + 7 + 2 = 28\n\nExample 3:\n\nInput: nums = [3,4,5,6,7,8]\nOutput: 480\nExplanation: The sum of all XOR totals for every subset is 480.\n\nConstraints:\n\n- 1 <= nums.length <= 12\n- 1 <= nums[i] <= 20\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 1, 6]) == 28\n assert candidate(nums = [1, 1, 1, 1]) == 8\n assert candidate(nums = [1, 2, 4, 8, 16]) == 496\n assert candidate(nums = [10, 11, 12]) == 60\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14]) == 896\n assert candidate(nums = [2, 3, 5]) == 28\n assert candidate(nums = [11, 2, 3, 14, 7]) == 240\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [7, 8, 9, 10, 11]) == 240\n assert candidate(nums = [1, 2, 3, 4]) == 56\n assert candidate(nums = [3, 4, 5, 6, 7, 8]) == 480\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 30720\n assert candidate(nums = [2, 3, 5, 7]) == 56\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9]) == 63488\n assert candidate(nums = [1, 3]) == 6\n assert candidate(nums = [2, 2, 2, 2]) == 16\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 15360\n assert candidate(nums = [15, 16, 17, 18, 19, 20]) == 992\n assert candidate(nums = [1, 2, 3]) == 12\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2048\n assert candidate(nums = [6, 3, 5, 2, 1, 9]) == 480\n assert candidate(nums = [3, 3, 3, 5, 5, 5, 7, 7, 7, 11, 11, 11]) == 30720\n assert candidate(nums = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8]) == 63488\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 30720\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 14336\n assert candidate(nums = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8]) == 63488\n assert candidate(nums = [2, 3, 4, 5, 6]) == 112\n assert candidate(nums = [3, 5, 7, 9, 11, 13]) == 480\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 15360\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14]) == 896\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9]) == 63488\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 14336\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 15360\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7]) == 1984\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4]) == 30720\n assert candidate(nums = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30720\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1]) == 30720\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19]) == 3968\n", "comparison": "exact"}, "public_tests": ["[1,3]", "[5,1,6]", "[3,4,5,6,7,8]"], "hints": ["Is there a way to iterate through all the subsets of the array?", "Can we use recursion to efficiently iterate through all the subsets?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().subsetXORSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:11+00:00", "tests_total": 99, "tests_dropped": 61, "flags": [], "topic_tags": ["array", "math", "backtracking", "bit-manipulation", "combinatorics", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def subsetXORSum(self, nums: list[int]) -> int:", "container": "Solution", "callable": "subsetXORSum", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1864, "task_id": "minimum-number-of-swaps-to-make-the-binary-string-alternating", "difficulty": "Medium", "problem_description": "Given a binary string s, return the minimum number of character swaps to make it alternating, or -1 if it is impossible.\n\nThe string is called alternating if no two adjacent characters are equal. For example, the strings \"010\" and \"1010\" are alternating, while the string \"0100\" is not.\n\nAny two characters may be swapped, even if they are not adjacent.\n\nExample 1:\n\nInput: s = \"111000\"\nOutput: 1\nExplanation: Swap positions 1 and 4: \"111000\" -> \"101010\"\nThe string is now alternating.\n\nExample 2:\n\nInput: s = \"010\"\nOutput: 0\nExplanation: The string is already alternating, no swaps are needed.\n\nExample 3:\n\nInput: s = \"1110\"\nOutput: -1\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- s[i] is either '0' or '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == -1\n assert candidate(s = \"1100110\") == 2\n assert candidate(s = \"110011\") == -1\n assert candidate(s = \"00110011\") == 2\n assert candidate(s = \"0101010\") == 0\n assert candidate(s = \"111\") == -1\n assert candidate(s = \"11110000\") == 2\n assert candidate(s = \"1110\") == -1\n assert candidate(s = \"0000\") == -1\n assert candidate(s = \"01010\") == 0\n assert candidate(s = \"111000\") == 1\n assert candidate(s = \"10101\") == 0\n assert candidate(s = \"1100\") == 1\n assert candidate(s = \"010\") == 0\n assert candidate(s = \"1010101\") == 0\n assert candidate(s = \"1010\") == 0\n assert candidate(s = \"0101\") == 0\n assert candidate(s = \"000111\") == 1\n assert candidate(s = \"000\") == -1\n assert candidate(s = \"01010101\") == 0\n assert candidate(s = \"10101010\") == 0\n assert candidate(s = \"110\") == 1\n assert candidate(s = \"1010101010\") == 0\n assert candidate(s = \"010101\") == 0\n assert candidate(s = \"101010\") == 0\n assert candidate(s = \"1101001\") == 2\n assert candidate(s = \"11001100\") == 2\n assert candidate(s = \"0011\") == 1\n assert candidate(s = \"0101010101\") == 0\n assert candidate(s = \"0011001\") == 2\n assert candidate(s = \"1001\") == 1\n assert candidate(s = \"101010101010101010\") == 0\n assert candidate(s = \"1110010011100100111001\") == -1\n assert candidate(s = \"010101101010101010101010101\") == 3\n assert candidate(s = \"110010110010\") == 2\n assert candidate(s = \"000110110001101100011011\") == 6\n assert candidate(s = \"00111111001111110011111100111111001111110011111100\") == -1\n assert candidate(s = \"101010101110\") == -1\n assert candidate(s = \"000000111111000000111111\") == 6\n assert candidate(s = \"0000000111111\") == 3\n assert candidate(s = \"000000000000000000111111111111111\") == -1\n assert candidate(s = \"11110000111100001111000011110000111100001111000011\") == -1\n assert candidate(s = \"010101010101010101010101010101010101010101010101011\") == 25\n assert candidate(s = \"101010101010101001010101010\") == 8\n assert candidate(s = \"1010101010101010101\") == 0\n assert candidate(s = \"010101010101010110101010101\") == 8\n assert candidate(s = \"0000000000000001111111111111\") == -1\n assert candidate(s = \"11010101010101010101010101010101\") == -1\n assert candidate(s = \"010101010101010101010101\") == 0\n assert candidate(s = \"10101010101010101010101010\") == 0\n assert candidate(s = \"000000000000111111111111\") == 6\n assert candidate(s = \"0000111110101010\") == 2\n assert candidate(s = \"1001100110011\") == 3\n assert candidate(s = \"0000000000111111111000\") == -1\n assert candidate(s = \"101010101001010101010101010\") == 5\n assert candidate(s = \"00001111000011110000\") == -1\n assert candidate(s = \"111000111000111\") == -1\n assert candidate(s = \"1011010010110100\") == 4\n assert candidate(s = \"000111000111000111\") == 3\n assert candidate(s = \"101010101010101010101010\") == 0\n assert candidate(s = \"1010010101001010100101010\") == -1\n assert candidate(s = \"111010101010\") == -1\n assert candidate(s = \"101010101010101010101\") == 0\n assert candidate(s = \"111111000000111111000000111111000000111111\") == -1\n assert candidate(s = \"010101010101010101\") == 0\n assert candidate(s = \"101010101010101010101010101\") == 0\n assert candidate(s = \"1010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"1100110011\") == -1\n assert candidate(s = \"111000111000111000111000111000\") == 5\n assert candidate(s = \"11000011000011000011\") == -1\n assert candidate(s = \"0101010101001011\") == 2\n assert candidate(s = \"111001100110011001100110011\") == -1\n assert candidate(s = \"1111111111111111111000000000000000\") == -1\n assert candidate(s = \"1010101010101010\") == 0\n assert candidate(s = \"111100001111000011110000111100001111\") == -1\n assert candidate(s = \"0000000111111100000000111111110000000011111111\") == 11\n assert candidate(s = \"111111000000111111000000\") == 6\n assert candidate(s = \"011111000000\") == -1\n assert candidate(s = \"111100001111000011110000\") == 6\n assert candidate(s = \"10101110101000\") == 1\n assert candidate(s = \"110011001100\") == 3\n assert candidate(s = \"11100101101000\") == 3\n assert candidate(s = \"0011001100110011\") == 4\n assert candidate(s = \"001100110011001100\") == -1\n assert candidate(s = \"000000111111\") == 3\n assert candidate(s = \"11111000001111100000\") == 4\n assert candidate(s = \"110010101001\") == 2\n assert candidate(s = \"111100000011\") == 3\n assert candidate(s = \"01010101011\") == 5\n assert candidate(s = \"0101010101010101010101010101010101\") == 0\n assert candidate(s = \"0000111100001111000011110000\") == -1\n assert candidate(s = \"1110001000\") == -1\n assert candidate(s = \"010101010101010101010101010\") == 0\n assert candidate(s = \"10100101010\") == 2\n assert candidate(s = \"000000000000000011111111111111\") == -1\n assert candidate(s = \"01010101010101010101010\") == 0\n assert candidate(s = \"11110000111100001111\") == -1\n assert candidate(s = \"01010101010101010101010101\") == 0\n assert candidate(s = \"01101101101101\") == -1\n assert candidate(s = \"111111111111111111000000000000000\") == -1\n assert candidate(s = \"101010101010\") == 0\n assert candidate(s = \"111111000000111111\") == -1\n assert candidate(s = \"111111111111111100000000000000\") == -1\n assert candidate(s = \"1111111111110000000000\") == -1\n assert candidate(s = \"0011001100110\") == 3\n assert candidate(s = \"01101010100\") == 4\n assert candidate(s = \"000111111000\") == 3\n assert candidate(s = \"0101010010101010\") == -1\n assert candidate(s = \"11111111111111111111\") == -1\n assert candidate(s = \"000011110000\") == -1\n assert candidate(s = \"1111111111100000000011\") == -1\n assert candidate(s = \"001001110010011\") == 4\n assert candidate(s = \"00001111111100\") == -1\n assert candidate(s = \"000111000111000\") == -1\n assert candidate(s = \"11111111000000001111111100000000\") == 8\n assert candidate(s = \"001100110011\") == 3\n assert candidate(s = \"1111111000000\") == 3\n assert candidate(s = \"10010010010010\") == -1\n assert candidate(s = \"111111111000000001111111100000000\") == 8\n assert candidate(s = \"00000000001111111111\") == 5\n assert candidate(s = \"101010101010101010101010101010101\") == 0\n assert candidate(s = \"1111111111000000000011111111110000000000\") == 10\n assert candidate(s = \"01010101010101010101010101010101010101010101010100\") == -1\n assert candidate(s = \"11001100110011001100\") == 5\n assert candidate(s = \"11111111110000000000\") == 5\n assert candidate(s = \"1111111000000011111111100000001111111110000000\") == -1\n assert candidate(s = \"01010101010101010101010101010101\") == 0\n assert candidate(s = \"0101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"1010101010101010101010101010\") == 0\n assert candidate(s = \"11110000111100\") == -1\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\") == -1\n assert candidate(s = \"111010101001\") == -1\n assert candidate(s = \"111000111000111000111000111\") == -1\n assert candidate(s = \"1110000011100000\") == -1\n assert candidate(s = \"111111101111111011111110\") == -1\n assert candidate(s = \"0000111111110000\") == 4\n assert candidate(s = \"111000111000\") == 2\n assert candidate(s = \"1111111100000000\") == 4\n assert candidate(s = \"1010101010110100\") == 2\n assert candidate(s = \"101110010110\") == -1\n assert candidate(s = \"0101101010101001\") == 3\n assert candidate(s = \"111100001111\") == -1\n assert candidate(s = \"000011111111\") == -1\n assert candidate(s = \"00000000000000000111111111111111\") == -1\n assert candidate(s = \"110110001101100\") == 4\n assert candidate(s = \"1100110011001100110011001100\") == 7\n assert candidate(s = \"11110000111100001111000011110000\") == 8\n assert candidate(s = \"110110110110110110110110\") == -1\n assert candidate(s = \"00110011001100\") == -1\n assert candidate(s = \"010101010101\") == 0\n assert candidate(s = \"111000100011\") == 2\n assert candidate(s = \"1111111111111111111111111111\") == -1\n assert candidate(s = \"0101010101010101\") == 0\n assert candidate(s = \"00001111\") == 2\n assert candidate(s = \"11111100000000\") == -1\n assert candidate(s = \"10100101001010010100101001010010100101001010\") == -1\n assert candidate(s = \"1111000010101010\") == 2\n assert candidate(s = \"11111111111111100000000000000000\") == -1\n assert candidate(s = \"11100111001110011100\") == -1\n assert candidate(s = \"1010101110001010\") == 1\n assert candidate(s = \"0101010101010101010101010101\") == 0\n assert candidate(s = \"11000000110000001100000011000000110000001100000011\") == -1\n assert candidate(s = \"0000000100000001000000010\") == -1\n assert candidate(s = \"111100001111000011\") == -1\n assert candidate(s = \"00000000000000000000000000000000000000000000000001\") == -1\n assert candidate(s = \"0101010101010101010\") == 0\n assert candidate(s = \"0000000000001111111111111111\") == -1\n assert candidate(s = \"000111000111000111000111000111\") == 5\n assert candidate(s = \"11111110000000\") == 3\n assert candidate(s = \"0000000000000001111111111111111\") == 8\n assert candidate(s = \"010100011101010\") == 1\n assert candidate(s = \"010101010001010101010101010\") == -1\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\") == -1\n assert candidate(s = \"000000111111000000111111000000111111000000\") == -1\n assert candidate(s = \"110101010101010101\") == -1\n assert candidate(s = \"100010001000\") == -1\n assert candidate(s = \"00001111000011110000111100001111\") == 8\n assert candidate(s = \"1111111111111110000000000000\") == -1\n assert candidate(s = \"101010101000\") == -1\n assert candidate(s = \"10101010010\") == 4\n assert candidate(s = \"10010010010\") == -1\n assert candidate(s = \"00110011001100110011\") == 5\n assert candidate(s = \"010110001110\") == 3\n assert candidate(s = \"011011010101010101010101010\") == 12\n assert candidate(s = \"010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"00000000000000000000\") == -1\n assert candidate(s = \"1010101010101\") == 0\n assert candidate(s = \"1111000011110000\") == 4\n assert candidate(s = \"0000000011111111\") == 4\n assert candidate(s = \"010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"1111000000001111\") == 4\n assert candidate(s = \"1111100000\") == 2\n assert candidate(s = \"11001100110011001100110011001100110011001100110011\") == -1\n assert candidate(s = \"00100100100100100100100100100100100100100100\") == -1\n assert candidate(s = \"000111000111000111000111000\") == -1\n assert candidate(s = \"01010101010101\") == 0\n assert candidate(s = \"111000010101\") == 2\n assert candidate(s = \"1001001001001\") == -1\n assert candidate(s = \"101011100010101\") == 1\n assert candidate(s = \"0100101101001011\") == 4\n assert candidate(s = \"0110110110110110110110110\") == -1\n assert candidate(s = \"11111111111111111000000000000000\") == -1\n assert candidate(s = \"1010101010101010101010\") == 0\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"00111100111100111100\") == -1\n assert candidate(s = \"100110011001\") == 3\n assert candidate(s = \"111001001001\") == 3\n assert candidate(s = \"11101110111011101110\") == -1\n assert candidate(s = \"00011100011100011100\") == -1\n assert candidate(s = \"1001100110011001\") == 4\n assert candidate(s = \"01010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"100100100100\") == -1\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"0011001100110011001100110011\") == 7\n assert candidate(s = \"01010101010101010101\") == 0\n assert candidate(s = \"110011001100110011001100110011\") == -1\n assert candidate(s = \"1100110011001\") == 3\n assert candidate(s = \"11001100110011\") == -1\n assert candidate(s = \"101010101010101010101010101010101010101010101010100\") == 25\n assert candidate(s = \"1001001001001001001001001001\") == -1\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"1101011010100010\") == 3\n assert candidate(s = \"0110011001100110011001100110011\") == 8\n assert candidate(s = \"101010010101010101010101010\") == 3\n assert candidate(s = \"1111111111110000000000000000\") == -1\n assert candidate(s = \"101010101010101010101010101010101010\") == 0\n assert candidate(s = \"000100100100\") == -1\n assert candidate(s = \"1111000000\") == -1\n assert candidate(s = \"0101010101010\") == 0\n assert candidate(s = \"111111111110000000000111111111110000000000\") == -1\n assert candidate(s = \"1111111000000011111110000000\") == 6\n assert candidate(s = \"11000011110000111100\") == 5\n assert candidate(s = \"10101010101010101010\") == 0\n assert candidate(s = \"0000000000000000000111111111111111\") == -1\n assert candidate(s = \"100110011001100110011001\") == 6\n assert candidate(s = \"11001100110011001100110011\") == -1\n assert candidate(s = \"000000111111000000111111000000\") == -1\n assert candidate(s = \"011011011011\") == -1\n assert candidate(s = \"0000000000000000000000000000\") == -1\n assert candidate(s = \"11111111111111111111111111111111111111111111111110\") == -1\n assert candidate(s = \"00001111000011110000111100001111000011110000111100\") == -1\n", "comparison": "exact"}, "public_tests": ["\"111000\"", "\"010\"", "\"1110\""], "hints": ["Think about all valid strings of length n.", "Try to count the mismatched positions with each valid string of length n."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minSwaps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:13+00:00", "tests_total": 243, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minSwaps(self, s: str) -> int:", "container": "Solution", "callable": "minSwaps", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1866, "task_id": "number-of-ways-to-rearrange-sticks-with-k-sticks-visible", "difficulty": "Hard", "problem_description": "There are n uniquely-sized sticks whose lengths are integers from 1 to n. You want to arrange the sticks such that exactly k sticks are visible from the left. A stick is visible from the left if there are no longer sticks to the left of it.\n\n- For example, if the sticks are arranged [1,3,2,5,4], then the sticks with lengths 1, 3, and 5 are visible from the left.\n\nGiven n and k, return the number of such arrangements. Since the answer may be large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 3, k = 2\nOutput: 3\nExplanation: [1,3,2], [2,3,1], and [2,1,3] are the only arrangements such that exactly 2 sticks are visible.\nThe visible sticks are underlined.\n\nExample 2:\n\nInput: n = 5, k = 5\nOutput: 1\nExplanation: [1,2,3,4,5] is the only arrangement such that all 5 sticks are visible.\nThe visible sticks are underlined.\n\nExample 3:\n\nInput: n = 20, k = 11\nOutput: 647427950\nExplanation: There are 647427950 (mod 10^9+ 7) ways to rearrange the sticks such that exactly 11 sticks are visible.\n\nConstraints:\n\n- 1 <= n <= 1000\n- 1 <= k <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,k = 1) == 362880\n assert candidate(n = 1000,k = 500) == 761367694\n assert candidate(n = 7,k = 4) == 735\n assert candidate(n = 1,k = 1) == 1\n assert candidate(n = 3,k = 2) == 3\n assert candidate(n = 100,k = 50) == 768969154\n assert candidate(n = 5,k = 5) == 1\n assert candidate(n = 20,k = 11) == 647427950\n assert candidate(n = 4,k = 3) == 6\n assert candidate(n = 10,k = 3) == 1172700\n assert candidate(n = 400,k = 200) == 321592380\n assert candidate(n = 300,k = 150) == 266738846\n assert candidate(n = 500,k = 20) == 997277428\n assert candidate(n = 200,k = 100) == 515897308\n assert candidate(n = 75,k = 40) == 957213722\n assert candidate(n = 600,k = 400) == 156741878\n assert candidate(n = 90,k = 45) == 884068127\n assert candidate(n = 1000,k = 999) == 499500\n assert candidate(n = 300,k = 200) == 692591146\n assert candidate(n = 70,k = 35) == 834330443\n assert candidate(n = 25,k = 10) == 513911237\n assert candidate(n = 30,k = 15) == 439815546\n assert candidate(n = 900,k = 40) == 539248312\n assert candidate(n = 75,k = 35) == 48172892\n assert candidate(n = 400,k = 10) == 650177568\n assert candidate(n = 800,k = 200) == 252157911\n assert candidate(n = 50,k = 20) == 506372014\n assert candidate(n = 999,k = 999) == 1\n assert candidate(n = 500,k = 2) == 540925953\n assert candidate(n = 700,k = 350) == 411412946\n assert candidate(n = 999,k = 1) == 22779421\n assert candidate(n = 999,k = 499) == 23728871\n assert candidate(n = 900,k = 450) == 911433285\n assert candidate(n = 900,k = 900) == 1\n assert candidate(n = 150,k = 75) == 309130836\n assert candidate(n = 8,k = 4) == 6769\n assert candidate(n = 100,k = 10) == 451985432\n assert candidate(n = 30,k = 10) == 283914142\n assert candidate(n = 750,k = 100) == 677105109\n assert candidate(n = 25,k = 15) == 729045180\n assert candidate(n = 250,k = 249) == 31125\n assert candidate(n = 250,k = 200) == 168555168\n assert candidate(n = 1000,k = 1000) == 1\n assert candidate(n = 1000,k = 1) == 756641425\n assert candidate(n = 15,k = 7) == 409322830\n assert candidate(n = 600,k = 599) == 179700\n assert candidate(n = 800,k = 300) == 156733966\n assert candidate(n = 600,k = 300) == 326283128\n assert candidate(n = 750,k = 375) == 43563744\n assert candidate(n = 700,k = 30) == 785311933\n assert candidate(n = 800,k = 400) == 551599071\n assert candidate(n = 500,k = 50) == 982286335\n assert candidate(n = 999,k = 500) == 975713359\n assert candidate(n = 350,k = 175) == 62253251\n assert candidate(n = 400,k = 250) == 585657508\n assert candidate(n = 500,k = 250) == 112330193\n assert candidate(n = 50,k = 25) == 253549512\n", "comparison": "exact"}, "public_tests": ["3\n2", "5\n5", "20\n11"], "hints": ["Is there a way to build the solution from a base case?", "How many ways are there if we fix the position of one stick?"], "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().rearrangeSticks", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:16+00:00", "tests_total": 57, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "dynamic-programming", "combinatorics"]}, "language": "python", "interface": {"raw_signature": "def rearrangeSticks(self, n: int, k: int) -> int:", "container": "Solution", "callable": "rearrangeSticks", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1869, "task_id": "longer-contiguous-segments-of-ones-than-zeros", "difficulty": "Easy", "problem_description": "Given a binary string s, return true if the longest contiguous segment of 1's is strictly longer than the longest contiguous segment of 0's in s, or return false otherwise.\n\n- For example, in s = \"110100010\" the longest continuous segment of 1s has length 2, and the longest continuous segment of 0s has length 3.\n\nNote that if there are no 0's, then the longest continuous segment of 0's is considered to have a length 0. The same applies if there is no 1's.\n\nExample 1:\n\nInput: s = \"1101\"\nOutput: true\nExplanation:\nThe longest contiguous segment of 1s has length 2: \"1101\"\nThe longest contiguous segment of 0s has length 1: \"1101\"\nThe segment of 1s is longer, so return true.\n\nExample 2:\n\nInput: s = \"111000\"\nOutput: false\nExplanation:\nThe longest contiguous segment of 1s has length 3: \"111000\"\nThe longest contiguous segment of 0s has length 3: \"111000\"\nThe segment of 1s is not longer, so return false.\n\nExample 3:\n\nInput: s = \"110100010\"\nOutput: false\nExplanation:\nThe longest contiguous segment of 1s has length 2: \"110100010\"\nThe longest contiguous segment of 0s has length 3: \"110100010\"\nThe segment of 1s is not longer, so return false.\n\nConstraints:\n\n- 1 <= s.length <= 100\n- s[i] is either '0' or '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == True\n assert candidate(s = \"111000\") == False\n assert candidate(s = \"101010\") == False\n assert candidate(s = \"11100111\") == True\n assert candidate(s = \"11001100\") == False\n assert candidate(s = \"111001001\") == True\n assert candidate(s = \"1101\") == True\n assert candidate(s = \"0\") == False\n assert candidate(s = \"110100010\") == False\n assert candidate(s = \"01010101\") == False\n assert candidate(s = \"10101010\") == False\n assert candidate(s = \"1110011100010001111100000\") == False\n assert candidate(s = \"000111000\") == False\n assert candidate(s = \"001100110011\") == False\n assert candidate(s = \"0000\") == False\n assert candidate(s = \"1\") == True\n assert candidate(s = \"101010101010101010\") == False\n assert candidate(s = \"1110111011101110111\") == True\n assert candidate(s = \"000111000111000111000\") == False\n assert candidate(s = \"111111111111111111111111\") == True\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"111000111000111000\") == False\n assert candidate(s = \"001111001100110011110000111100001111100000\") == False\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"1111110000000000000000000000000000000000000000000000\") == False\n assert candidate(s = \"111100000110011000000111\") == False\n assert candidate(s = \"00000000000000000000000000000000\") == False\n assert candidate(s = \"000111000111000111000111000111000111000111000\") == False\n assert candidate(s = \"000011110000111100001111000011110000111100001111\") == False\n assert candidate(s = \"1111111111111111111\") == True\n assert candidate(s = \"1100110011001100\") == False\n assert candidate(s = \"111010101010101010101\") == True\n assert candidate(s = \"1010101010101010101\") == False\n assert candidate(s = \"111110000011111000001111100000\") == False\n assert candidate(s = \"11010101010101010101010101010101\") == True\n assert candidate(s = \"11110011000001111100110000011111001100000\") == False\n assert candidate(s = \"010101010101010101010101\") == False\n assert candidate(s = \"00000000111111110000000011111111\") == False\n assert candidate(s = \"0000000000000000000000001111111111111111111111111\") == True\n assert candidate(s = \"10101010101010101010101010\") == False\n assert candidate(s = \"111000000011111111111\") == True\n assert candidate(s = \"1010101010101010101010101010101\") == False\n assert candidate(s = \"1110000110000111\") == False\n assert candidate(s = \"00000000001111111111111111111111111111111\") == True\n assert candidate(s = \"1111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"111111110000000\") == True\n assert candidate(s = \"000000000000000000000001\") == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000011111\") == False\n assert candidate(s = \"000111000111000111\") == False\n assert candidate(s = \"111111111111111111110000000000000000111111111111\") == True\n assert candidate(s = \"10101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"10000111110000001111111110000000011111111111\") == True\n assert candidate(s = \"111111111111100000000000000011111111111111111111111111111\") == True\n assert candidate(s = \"111110000011111000001111100000111110000011111\") == False\n assert candidate(s = \"0001001001001001001001001\") == False\n assert candidate(s = \"000110001100011000110001100011\") == False\n assert candidate(s = \"0000000000\") == False\n assert candidate(s = \"111111111111111111111\") == True\n assert candidate(s = \"111110000001110000111111\") == False\n assert candidate(s = \"1010101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"111111010101010101010101010101010101010101010101010101\") == True\n assert candidate(s = \"0000000000000000\") == False\n assert candidate(s = \"000100010001000\") == False\n assert candidate(s = \"000111000111000111000111\") == False\n assert candidate(s = \"101010101010101010101010101010\") == False\n assert candidate(s = \"1001001001001001001001001001001001001001001\") == False\n assert candidate(s = \"111100001111000011110000111100001111\") == False\n assert candidate(s = \"111111000000111111000000\") == False\n assert candidate(s = \"111100001111000011110000\") == False\n assert candidate(s = \"101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"000000000000000000000\") == False\n assert candidate(s = \"111111110000000000000000000\") == False\n assert candidate(s = \"11111000001111100000\") == False\n assert candidate(s = \"11111111111111111111110000000000000000\") == True\n assert candidate(s = \"0011001100110011001100110011001100110011\") == False\n assert candidate(s = \"000000000000000011111111111\") == False\n assert candidate(s = \"00110011001100110011001100110011\") == False\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000000\") == False\n assert candidate(s = \"11110000111100001111\") == False\n assert candidate(s = \"11111000000000000000000000000000000000000000000000000\") == False\n assert candidate(s = \"110000000000000000000\") == False\n assert candidate(s = \"10101010101010101010101010101\") == False\n assert candidate(s = \"10101010101010101010101010101010101010\") == False\n assert candidate(s = \"010101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"000000011111111\") == True\n assert candidate(s = \"111111111100000000001111111111\") == False\n assert candidate(s = \"0011110000111100001111\") == False\n assert candidate(s = \"1111000001100100\") == False\n assert candidate(s = \"11111111111111111111\") == True\n assert candidate(s = \"1000000000000000000\") == False\n assert candidate(s = \"111001110011100\") == True\n assert candidate(s = \"1000111000111000111000111000111000111000\") == False\n assert candidate(s = \"1111111111111111\") == True\n assert candidate(s = \"111001110011100111001110011100\") == True\n assert candidate(s = \"101010101010101010101010101010101010101\") == False\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011\") == False\n assert candidate(s = \"00000111111111000000\") == True\n assert candidate(s = \"000000000000000000000000000000000000001\") == False\n assert candidate(s = \"110000111100001111000011110000111100001111\") == False\n assert candidate(s = \"100000011111111111100\") == True\n assert candidate(s = \"00000000001111111111\") == False\n assert candidate(s = \"010101010101010101010101010101\") == False\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"111000111000111000111\") == False\n assert candidate(s = \"11111000011111000011\") == True\n assert candidate(s = \"0000111111110000000\") == True\n assert candidate(s = \"111111111000000001111000000111110000\") == True\n assert candidate(s = \"11111111110000000000\") == False\n assert candidate(s = \"11111111110000000000000000000000000000000\") == False\n assert candidate(s = \"01010101010101010101010101010101\") == False\n assert candidate(s = \"111111000000000000000000000000\") == False\n assert candidate(s = \"000000000000000011111111111111111111000000000000\") == True\n assert candidate(s = \"11000001110000011100000111\") == False\n assert candidate(s = \"1010101010101010101010101010\") == False\n assert candidate(s = \"111100000000011111\") == False\n assert candidate(s = \"111000111000111000111000111\") == False\n assert candidate(s = \"0000111111110000\") == True\n assert candidate(s = \"0000000000000000000000000000000000000000000000000\") == False\n assert candidate(s = \"1111111111111111111111111111111111111110\") == True\n assert candidate(s = \"11110000011110000\") == False\n assert candidate(s = \"1110000111000111\") == False\n assert candidate(s = \"11111111111111111111111111111111\") == True\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"0000000000011111111111111100000000011111111111\") == True\n assert candidate(s = \"000000001010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"0101010101010101010101010101\") == False\n assert candidate(s = \"11100100010001000100010001000100\") == False\n assert candidate(s = \"000001111110000011111100000111111\") == True\n assert candidate(s = \"11001100110011001100110011001100110011\") == False\n assert candidate(s = \"00011100010001000100010001110001\") == False\n assert candidate(s = \"11001100110011001100110011001100110011001100\") == False\n assert candidate(s = \"111000011100001110000111\") == False\n assert candidate(s = \"001111110000000011111100000000\") == False\n assert candidate(s = \"010101010101010101010101010101010101010\") == False\n assert candidate(s = \"00000000000000000000\") == False\n assert candidate(s = \"1111000011110000\") == False\n assert candidate(s = \"10101010101010101010101010101010\") == False\n assert candidate(s = \"1001001001001001001001001\") == False\n assert candidate(s = \"1010101011111010\") == True\n assert candidate(s = \"0000000111111111111111111111111111111111111111100000\") == True\n assert candidate(s = \"000111000111000111000111000\") == False\n assert candidate(s = \"1010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"0110110110110110110110110\") == True\n assert candidate(s = \"1111111111111111111111110000000000000000000000000\") == False\n assert candidate(s = \"1111111111\") == True\n assert candidate(s = \"111111111100000000\") == True\n assert candidate(s = \"1001100110011001\") == False\n assert candidate(s = \"000000000000111111000000000011111\") == False\n assert candidate(s = \"001001001001001001001\") == False\n assert candidate(s = \"1100110011001100110011\") == False\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"111110000000000000000000000000000000000\") == False\n assert candidate(s = \"110110110110110110110\") == True\n assert candidate(s = \"0000000000000000000000001111111111111111111111111111\") == True\n assert candidate(s = \"10101010101010101010\") == False\n assert candidate(s = \"100110011001100110011001\") == False\n assert candidate(s = \"11001100110011001100110011\") == False\n assert candidate(s = \"010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"000000111111111111\") == True\n assert candidate(s = \"00011100010001000100010001000111\") == False\n", "comparison": "exact"}, "public_tests": ["\"1101\"", "\"111000\"", "\"110100010\""], "hints": ["Check every possible segment of 0s and 1s.", "Is there a way to iterate through the string to keep track of the current character and its count?"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().checkZeroOnes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:21+00:00", "tests_total": 161, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def checkZeroOnes(self, s: str) -> bool:", "container": "Solution", "callable": "checkZeroOnes", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1870, "task_id": "minimum-speed-to-arrive-on-time", "difficulty": "Medium", "problem_description": "You are given a floating-point number hour, representing the amount of time you have to reach the office. To commute to the office, you must take n trains in sequential order. You are also given an integer array dist of length n, where dist[i] describes the distance (in kilometers) of the i^th train ride.\n\nEach train can only depart at an integer hour, so you may need to wait in between each train ride.\n\n- For example, if the 1^st train ride takes 1.5 hours, you must wait for an additional 0.5 hours before you can depart on the 2^nd train ride at the 2 hour mark.\n\nReturn the minimum positive integer speed (in kilometers per hour) that all the trains must travel at for you to reach the office on time, or -1 if it is impossible to be on time.\n\nTests are generated such that the answer will not exceed 10^7 and hour will have at most two digits after the decimal point.\n\nExample 1:\n\nInput: dist = [1,3,2], hour = 6\nOutput: 1\nExplanation: At speed 1:\n- The first train ride takes 1/1 = 1 hour.\n- Since we are already at an integer hour, we depart immediately at the 1 hour mark. The second train takes 3/1 = 3 hours.\n- Since we are already at an integer hour, we depart immediately at the 4 hour mark. The third train takes 2/1 = 2 hours.\n- You will arrive at exactly the 6 hour mark.\n\nExample 2:\n\nInput: dist = [1,3,2], hour = 2.7\nOutput: 3\nExplanation: At speed 3:\n- The first train ride takes 1/3 = 0.33333 hours.\n- Since we are not at an integer hour, we wait until the 1 hour mark to depart. The second train ride takes 3/3 = 1 hour.\n- Since we are already at an integer hour, we depart immediately at the 2 hour mark. The third train takes 2/3 = 0.66667 hours.\n- You will arrive at the 2.66667 hour mark.\n\nExample 3:\n\nInput: dist = [1,3,2], hour = 1.9\nOutput: -1\nExplanation: It is impossible because the earliest the third train can depart is at the 2 hour mark.\n\nConstraints:\n\n- n == dist.length\n- 1 <= n <= 10^5\n- 1 <= dist[i] <= 10^5\n- 1 <= hour <= 10^9\n- There will be at most two digits after the decimal point in hour.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(dist = [5, 4, 3, 2, 1],hour = 5.5) == 4\n assert candidate(dist = [5, 4, 1, 2],hour = 3.5) == 5\n assert candidate(dist = [1, 2, 3, 4, 5],hour = 9.0) == 2\n assert candidate(dist = [1, 3, 2],hour = 1.9) == -1\n assert candidate(dist = [1, 1, 100000],hour = 2.01) == 10000000\n assert candidate(dist = [5, 5, 5, 5, 5],hour = 9.0) == 5\n assert candidate(dist = [100000],hour = 2.5) == 40000\n assert candidate(dist = [100000],hour = 1.0) == 100000\n assert candidate(dist = [10, 10, 10],hour = 3.5) == 10\n assert candidate(dist = [1, 3, 2],hour = 2.7) == 3\n assert candidate(dist = [1, 2, 3, 4, 5],hour = 10.0) == 2\n assert candidate(dist = [10, 10, 10],hour = 2.5) == 20\n assert candidate(dist = [1],hour = 1.0) == 1\n assert candidate(dist = [10, 10, 10],hour = 29.99) == 2\n assert candidate(dist = [1, 3, 2],hour = 6) == 1\n assert candidate(dist = [10, 10, 10],hour = 3.0) == 10\n assert candidate(dist = [5, 5, 5, 5],hour = 10.0) == 3\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 100000.0) == 1\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],hour = 19.99) == 11\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 4.5) == -1\n assert candidate(dist = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],hour = 50.0) == 20000\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],hour = 30.0) == 50\n assert candidate(dist = [100, 200, 300, 400, 500],hour = 15.5) == 100\n assert candidate(dist = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],hour = 15.0) == 100\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 10.1) == 1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 50.0) == 12\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 9.5) == 20\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],hour = 20.0) == 10\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],hour = 9.0) == -1\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],hour = 10.5) == 20\n assert candidate(dist = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],hour = 45.0) == 13334\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],hour = 15.0) == 25\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 30.5) == 20\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],hour = 14.0) == -1\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],hour = 10.0) == 100000\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000],hour = 25.0) == 20000\n assert candidate(dist = [100000, 1, 1, 1, 1],hour = 10.1) == 14286\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 9.99) == 11\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 2.5) == -1\n assert candidate(dist = [1, 2, 3, 4, 5],hour = 2.0) == -1\n assert candidate(dist = [99999, 99999, 99999, 99999],hour = 20.0) == 20000\n assert candidate(dist = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],hour = 50.0) == 1200\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],hour = 15.0) == 5\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 49.99) == 12\n assert candidate(dist = [1000, 2000, 3000],hour = 7.0) == 1000\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 5.5) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],hour = 25.5) == 14\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],hour = 15.0) == 5\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 5.5) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 25.0) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 20.0) == 4\n assert candidate(dist = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],hour = 9.99) == 101010\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 15.0) == 5\n assert candidate(dist = [1, 10, 100, 1000, 10000],hour = 12.0) == 1250\n assert candidate(dist = [10000, 20000, 30000, 40000, 50000],hour = 12.5) == 14286\n assert candidate(dist = [10, 20, 30, 40, 50],hour = 12.5) == 15\n assert candidate(dist = [10, 20, 30, 40, 50],hour = 12.5) == 15\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 10.0) == 1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 19.0) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 18.0) == 40\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 18.0) == 40\n assert candidate(dist = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],hour = 9.0) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 1.0) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 20.0) == 1\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],hour = 15.25) == 5\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],hour = 4.0) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 5.0) == -1\n assert candidate(dist = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],hour = 15.5) == 5\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],hour = 9.5) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 9.0) == -1\n assert candidate(dist = [99999, 99999, 99999, 99999, 99999],hour = 25.0) == 20000\n assert candidate(dist = [100, 200, 300, 400, 500],hour = 10.0) == 200\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],hour = 19.99) == 21\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],hour = 50.5) == 118\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],hour = 11.0) == 9\n assert candidate(dist = [100, 200, 300, 400, 500],hour = 14.0) == 125\n assert candidate(dist = [100, 200, 300, 400, 500],hour = 20.0) == 84\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 50.0) == -1\n assert candidate(dist = [1, 10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000],hour = 10.5) == 10000\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],hour = 10.0) == 19\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],hour = 25.0) == 70\n assert candidate(dist = [100000, 99999, 99998, 99997, 99996],hour = 5.0) == 100000\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],hour = 21.5) == 18\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 9.5) == 2\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 2.99) == -1\n assert candidate(dist = [5, 10, 15, 20, 25],hour = 9.0) == 10\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 9.99) == 102\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 5.0) == -1\n assert candidate(dist = [1, 100000, 1, 1, 1],hour = 10.1) == 14286\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 20.0) == 35\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],hour = 30.5) == 200\n assert candidate(dist = [99999, 99999, 99999],hour = 3.5) == 99999\n assert candidate(dist = [10000, 10000, 10000, 10000, 10000],hour = 25.0) == 2000\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],hour = 7.5) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 1.5) == -1\n", "comparison": "exact"}, "public_tests": ["[1,3,2]\n6", "[1,3,2]\n2.7", "[1,3,2]\n1.9"], "hints": ["Given the speed the trains are traveling at, can you find the total time it takes for you to arrive?", "Is there a cutoff where any speeds larger will always allow you to arrive on time?"], "metadata": {"canonical_parameter_names": ["dist", "hour"], "leetcode_dataset_entry_point": "Solution().minSpeedOnTime", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:23+00:00", "tests_total": 98, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "binary-search"]}, "language": "python", "interface": {"raw_signature": "def minSpeedOnTime(self, dist: list[int], hour: float) -> int:", "container": "Solution", "callable": "minSpeedOnTime", "parameters": [{"name": "dist", "type": "list[int]"}, {"name": "hour", "type": "float"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1871, "task_id": "jump-game-vii", "difficulty": "Medium", "problem_description": "You are given a 0-indexed binary string s and two integers minJump and maxJump. In the beginning, you are standing at index 0, which is equal to '0'. You can move from index i to index j if the following conditions are fulfilled:\n\n- i + minJump <= j <= min(i + maxJump, s.length - 1), and\n- s[j] == '0'.\n\nReturn true if you can reach index s.length - 1 in s, or false otherwise.\n\nExample 1:\n\nInput: s = \"011010\", minJump = 2, maxJump = 3\nOutput: true\nExplanation:\nIn the first step, move from index 0 to index 3.\nIn the second step, move from index 3 to index 5.\n\nExample 2:\n\nInput: s = \"01101110\", minJump = 2, maxJump = 3\nOutput: false\n\nConstraints:\n\n- 2 <= s.length <= 10^5\n- s[i] is either '0' or '1'.\n- s[0] == '0'\n- 1 <= minJump <= maxJump < s.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"0100100010001000\",minJump = 2,maxJump = 5) == True\n assert candidate(s = \"00001000\",minJump = 2,maxJump = 4) == True\n assert candidate(s = \"0010010010010010010010010010010010010010\",minJump = 2,maxJump = 4) == True\n assert candidate(s = \"011010\",minJump = 2,maxJump = 3) == True\n assert candidate(s = \"0100000\",minJump = 1,maxJump = 2) == True\n assert candidate(s = \"00001000\",minJump = 3,maxJump = 5) == True\n assert candidate(s = \"01010101\",minJump = 2,maxJump = 4) == False\n assert candidate(s = \"0101010101010101010101010101010101010101\",minJump = 5,maxJump = 10) == False\n assert candidate(s = \"0111111111111111111111111111111111111111\",minJump = 3,maxJump = 5) == False\n assert candidate(s = \"000000\",minJump = 1,maxJump = 2) == True\n assert candidate(s = \"001000\",minJump = 2,maxJump = 3) == True\n assert candidate(s = \"010101\",minJump = 1,maxJump = 2) == False\n assert candidate(s = \"00000000\",minJump = 1,maxJump = 2) == True\n assert candidate(s = \"00100\",minJump = 3,maxJump = 4) == True\n assert candidate(s = \"01101110\",minJump = 2,maxJump = 3) == False\n assert candidate(s = \"010000\",minJump = 1,maxJump = 3) == True\n assert candidate(s = \"00000000001000000000\",minJump = 4,maxJump = 7) == True\n assert candidate(s = \"0000011111000000000000000000\",minJump = 1,maxJump = 5) == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000000000000000000\",minJump = 5,maxJump = 10) == True\n assert candidate(s = \"0000000000000000000000000000\",minJump = 2,maxJump = 2) == False\n assert candidate(s = \"0111111111111111111111111110\",minJump = 10,maxJump = 20) == False\n assert candidate(s = \"0100000000000000000000000000\",minJump = 2,maxJump = 3) == True\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\",minJump = 10,maxJump = 20) == True\n assert candidate(s = \"01010101010101010101010101010101010101010101010101\",minJump = 5,maxJump = 15) == False\n assert candidate(s = \"0010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",minJump = 3,maxJump = 7) == False\n assert candidate(s = \"0000000000000000000000000001\",minJump = 1,maxJump = 1) == False\n assert candidate(s = \"000001000001000001000001000001000001000001000001\",minJump = 6,maxJump = 12) == False\n assert candidate(s = \"000111000111000111000111000111000111000111000111\",minJump = 3,maxJump = 6) == False\n assert candidate(s = \"01001001001001001001001000\",minJump = 5,maxJump = 10) == True\n assert candidate(s = \"001001001000\",minJump = 2,maxJump = 4) == True\n assert candidate(s = \"0000100100010001000100010001000100010001000100010000\",minJump = 5,maxJump = 15) == True\n assert candidate(s = \"0000000000000000000000000000000000000000000000000001000000000000000000000000\",minJump = 10,maxJump = 20) == True\n assert candidate(s = \"01001001001001001001001001001001001001001001001001\",minJump = 4,maxJump = 8) == False\n assert candidate(s = \"0000000000000000000000000000\",minJump = 5,maxJump = 5) == False\n assert candidate(s = \"010001000100010001000100010001000100010000\",minJump = 4,maxJump = 12) == True\n assert candidate(s = \"0000000000000000000000000000\",minJump = 1,maxJump = 10) == True\n assert candidate(s = \"0101010101010101010101010101\",minJump = 3,maxJump = 5) == False\n assert candidate(s = \"0100000000000000000000000000\",minJump = 10,maxJump = 10) == False\n assert candidate(s = \"0001010101010101010101010101010100\",minJump = 3,maxJump = 8) == True\n assert candidate(s = \"0000000000\",minJump = 4,maxJump = 6) == True\n assert candidate(s = \"0001000100010001000100010000\",minJump = 3,maxJump = 5) == True\n", "comparison": "exact"}, "public_tests": ["\"011010\"\n2\n3", "\"01101110\"\n2\n3"], "hints": ["Consider for each reachable index i the interval [i + a, i + b].", "Use partial sums to mark the intervals as reachable."], "metadata": {"canonical_parameter_names": ["s", "minJump", "maxJump"], "leetcode_dataset_entry_point": "Solution().canReach", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:25+00:00", "tests_total": 49, "tests_dropped": 8, "flags": [], "topic_tags": ["string", "dynamic-programming", "sliding-window", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def canReach(self, s: str, minJump: int, maxJump: int) -> bool:", "container": "Solution", "callable": "canReach", "parameters": [{"name": "s", "type": "str"}, {"name": "minJump", "type": "int"}, {"name": "maxJump", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1872, "task_id": "stone-game-viii", "difficulty": "Hard", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\n\nThere are n stones arranged in a row. On each player's turn, while the number of stones is more than one, they will do the following:\n\n1. Choose an integer x > 1, and remove the leftmost x stones from the row.\n2. Add the sum of the removed stones' values to the player's score.\n3. Place a new stone, whose value is equal to that sum, on the left side of the row.\n\nThe game stops when only one stone is left in the row.\n\nThe score difference between Alice and Bob is (Alice's score - Bob's score). Alice's goal is to maximize the score difference, and Bob's goal is the minimize the score difference.\n\nGiven an integer array stones of length n where stones[i] represents the value of the i^th stone from the left, return the score difference between Alice and Bob if they both play optimally.\n\nExample 1:\n\nInput: stones = [-1,2,-3,4,-5]\nOutput: 5\nExplanation:\n- Alice removes the first 4 stones, adds (-1) + 2 + (-3) + 4 = 2 to her score, and places a stone of\n value 2 on the left. stones = [2,-5].\n- Bob removes the first 2 stones, adds 2 + (-5) = -3 to his score, and places a stone of value -3 on\n the left. stones = [-3].\nThe difference between their scores is 2 - (-3) = 5.\n\nExample 2:\n\nInput: stones = [7,-6,5,10,5,-2,-6]\nOutput: 13\nExplanation:\n- Alice removes all stones, adds 7 + (-6) + 5 + 10 + 5 + (-2) + (-6) = 13 to her score, and places a\n stone of value 13 on the left. stones = [13].\nThe difference between their scores is 13 - 0 = 13.\n\nExample 3:\n\nInput: stones = [-10,-12]\nOutput: -22\nExplanation:\n- Alice can only make one move, which is to remove both stones. She adds (-10) + (-12) = -22 to her\n score and places a stone of value -22 on the left. stones = [-22].\nThe difference between their scores is (-22) - 0 = -22.\n\nConstraints:\n\n- n == stones.length\n- 2 <= n <= 10^5\n- -10^4 <= stones[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(stones = [10, -10, 20, -20, 30, -30]) == 30\n assert candidate(stones = [100, 200, -300, 400, -500, 600, -700, 800]) == 600\n assert candidate(stones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(stones = [-1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000]) == 0\n assert candidate(stones = [1, 2, 3, 4, 5]) == 15\n assert candidate(stones = [100, -100, 100, -100, 100]) == 100\n assert candidate(stones = [10, -10, 20, -20, 30, -30, 40, -40]) == 40\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(stones = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(stones = [-1, -2, -3, -4, -5]) == 5\n assert candidate(stones = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 50\n assert candidate(stones = [-10, -12]) == -22\n assert candidate(stones = [-5, -4, -3, -2, -1]) == 1\n assert candidate(stones = [7, -6, 5, 10, 5, -2, -6]) == 13\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(stones = [-1, 2, -3, 4, -5]) == 5\n assert candidate(stones = [100, -50, 25, -12, 6, -3, 1, -1, 3, -2, 5, -4, 7, -6, 9]) == 78\n assert candidate(stones = [-10000, 0, 10000, 0, -10000, 0, 10000, 0, -10000, 0, 10000, 0, -10000, 0, 10000, 0, -10000, 0, 10000, 0]) == 0\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(stones = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300, -1400, 1500]) == 800\n assert candidate(stones = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, -10000, -9000, -8000, -7000, -6000, -5000, -4000, -3000, -2000, -1000]) == 30000\n assert candidate(stones = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == 11055\n assert candidate(stones = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000]) == 1000\n assert candidate(stones = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 250\n assert candidate(stones = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000]) == 1000\n assert candidate(stones = [5, 10, -5, 20, -10, 25, -15, 30, -20, 35, -25, 40, -30, 45, -35, 50, -40, 55, -45, 60]) == 150\n assert candidate(stones = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(stones = [-5, 15, -25, 35, -45, 55, -65, 75, -85, 95, -105]) == 105\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(stones = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 10\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(stones = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 210\n assert candidate(stones = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]) == 16\n assert candidate(stones = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 10\n assert candidate(stones = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(stones = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 10\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == 1000\n assert candidate(stones = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0, -1, -3, -7, -15, -31]) == 1937\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n assert candidate(stones = [10000, -10000, 9999, -9999, 9998, -9998, 9997, -9997, 9996, -9996]) == 9996\n assert candidate(stones = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11]) == 11\n assert candidate(stones = [-10000, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1]) == -1\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1000, -900, -800, -700, -600]) == 3100\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(stones = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 20\n assert candidate(stones = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == 15\n assert candidate(stones = [10000, -5000, 2000, -1000, 500, -200, 100, -50, 20, -10]) == 6360\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 28\n assert candidate(stones = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 9\n assert candidate(stones = [10000, -5000, 5000, -2500, 2500, -1250, 1250, -625, 625, -312, 312, -156, 156, -78, 78, -39, 39, -19, 19, -9, 9]) == 10000\n assert candidate(stones = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(stones = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, 5]) == 10\n assert candidate(stones = [10000, -9999, 9998, -9997, 9996, -9995, 9994, -9993, 9992, -9991, 9990]) == 9995\n assert candidate(stones = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 8\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1200\n assert candidate(stones = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40, 45, -45, 50, -50]) == 50\n assert candidate(stones = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000, 1100, -1100, 1200, -1200]) == 1200\n assert candidate(stones = [-150, -140, -130, -120, -110, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 10\n assert candidate(stones = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10]) == 10\n assert candidate(stones = [10000, -9999, 9998, -9997, 9996, -9995, 9994, -9993, 9992, -9991]) == 9991\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(stones = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 0\n assert candidate(stones = [100, 200, -300, 400, -500, 600, -700, 800, -900, 1000]) == 700\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 300\n assert candidate(stones = [10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000]) == 10000\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(stones = [1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1]) == 1\n assert candidate(stones = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10000]) == 10014\n assert candidate(stones = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 20\n assert candidate(stones = [-5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5]) == 5\n", "comparison": "exact"}, "public_tests": ["[-1,2,-3,4,-5]", "[7,-6,5,10,5,-2,-6]", "[-10,-12]"], "hints": ["Let's note that the only thing that matters is how many stones were removed so we can maintain dp[numberOfRemovedStones]", "dp[x] = max(sum of all elements up to y - dp[y]) for all y > x"], "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().stoneGameVIII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:28+00:00", "tests_total": 79, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "math", "dynamic-programming", "minimax-algorithm", "prefix-sum", "game-theory", "zero-sum-game"]}, "language": "python", "interface": {"raw_signature": "def stoneGameVIII(self, stones: list[int]) -> int:", "container": "Solution", "callable": "stoneGameVIII", "parameters": [{"name": "stones", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1876, "task_id": "substrings-of-size-three-with-distinct-characters", "difficulty": "Easy", "problem_description": "A string is good if there are no repeated characters.\n\nGiven a string s, return the number of good substrings of length three in s.\n\nNote that if there are multiple occurrences of the same substring, every occurrence should be counted.\n\nA substring is a contiguous sequence of characters in a string.\n\nExample 1:\n\nInput: s = \"xyzzaz\"\nOutput: 1\nExplanation: There are 4 substrings of size 3: \"xyz\", \"yzz\", \"zza\", and \"zaz\".\nThe only good substring of length 3 is \"xyz\".\n\nExample 2:\n\nInput: s = \"aababcabc\"\nOutput: 4\nExplanation: There are 7 substrings of size 3: \"aab\", \"aba\", \"bab\", \"abc\", \"bca\", \"cab\", and \"abc\".\nThe good substrings are \"abc\", \"bca\", \"cab\", and \"abc\".\n\nConstraints:\n\n- 1 <= s.length <= 100\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"xyzxyzxyz\") == 7\n assert candidate(s = \"abcabcabc\") == 7\n assert candidate(s = \"xyzzaz\") == 1\n assert candidate(s = \"aabbcc\") == 0\n assert candidate(s = \"abacab\") == 2\n assert candidate(s = \"qqqppprrr\") == 0\n assert candidate(s = \"abac\") == 1\n assert candidate(s = \"abc\") == 1\n assert candidate(s = \"xyzxyz\") == 4\n assert candidate(s = \"abcdcba\") == 4\n assert candidate(s = \"aababcabc\") == 4\n assert candidate(s = \"abacaba\") == 2\n assert candidate(s = \"abca\") == 2\n assert candidate(s = \"pqr\") == 1\n assert candidate(s = \"aaa\") == 0\n assert candidate(s = \"aaaaa\") == 0\n assert candidate(s = \"xyz\") == 1\n assert candidate(s = \"abcdefg\") == 5\n assert candidate(s = \"pqrspqrs\") == 6\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 49\n assert candidate(s = \"abcdefghijkabcdefghijkabcdefghijkabcdefghijk\") == 42\n assert candidate(s = \"abcdabcdeabcdefabcdefg\") == 20\n assert candidate(s = \"abcdefghtijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"abcdefghijklijkijklmnopqrstuvwxyz\") == 31\n assert candidate(s = \"abcdefabcdefabcdef\") == 16\n assert candidate(s = \"abcabcabcabc\") == 10\n assert candidate(s = \"uniquecharacters\") == 13\n assert candidate(s = \"thisisateststringforcountinggoodsubstrings\") == 32\n assert candidate(s = \"mnopqrspqrspqrspqr\") == 16\n assert candidate(s = \"aaaabbbbcccc\") == 0\n assert candidate(s = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"abacabadabacabad\") == 7\n assert candidate(s = \"abababababababababababababababababab\") == 0\n assert candidate(s = \"mnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopq\") == 73\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\") == 34\n assert candidate(s = \"xyzzyxzyxzyxzyxzyxzyxzyxzyx\") == 23\n assert candidate(s = \"aaabbbcccddd\") == 0\n assert candidate(s = \"abcdbcefg\") == 7\n assert candidate(s = \"abacabadabcabcabcabc\") == 14\n assert candidate(s = \"pqrstuvwxyza\") == 10\n assert candidate(s = \"mnopqrstuvwxyzabcdefghijkl\") == 24\n assert candidate(s = \"abcdbca\") == 5\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 28\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzxyz\") == 2\n assert candidate(s = \"xyzabxyzabxyzabxyz\") == 16\n assert candidate(s = \"abcdefgabcdefgabcdefgabcdefgabcdefgabcdefg\") == 40\n assert candidate(s = \"abcababcbacbacbabc\") == 12\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 24\n assert candidate(s = \"ababababababababab\") == 0\n assert candidate(s = \"abcabcabcabcabcabc\") == 16\n assert candidate(s = \"aabbccddeeffgghhii\") == 0\n assert candidate(s = \"abacabacabacabacabacabacabacabacabacabac\") == 19\n assert candidate(s = \"abcdeffedcbaabcdeffedcbaabcdeffedcbaabcdeffedcba\") == 32\n assert candidate(s = \"abcdefgheijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"xyzzyxzyxzyxzyxzyx\") == 14\n assert candidate(s = \"zzzzzzzzz\") == 0\n assert candidate(s = \"xyzzyzzxyzzxyzzxyzzx\") == 7\n assert candidate(s = \"abcdexyz\") == 6\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaaa\") == 25\n assert candidate(s = \"abacabadabacaba\") == 6\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzz\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 76\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"abcdefgabcdefgabcdefgabcdefg\") == 26\n assert candidate(s = \"aabbccddeeffgghhiii\") == 0\n assert candidate(s = \"abacabadabcaba\") == 7\n assert candidate(s = \"mnopqmnopqmnopq\") == 13\n assert candidate(s = \"aabbccddeeffgg\") == 0\n assert candidate(s = \"uniquecharactersinthisstringareunique\") == 32\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(s = \"aabcaabcdaabcaabcdaabc\") == 11\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 24\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooo\") == 0\n assert candidate(s = \"abcdeabcdeabcde\") == 13\n assert candidate(s = \"ababababab\") == 0\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(s = \"abcdefgabcdefgabcdefg\") == 19\n assert candidate(s = \"abacdefghijklmnopqrstuvwxyz\") == 24\n assert candidate(s = \"xyzzazxyzzazxyzzaz\") == 7\n assert candidate(s = \"abababababababababababababababababababab\") == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabcabc\") == 25\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 22\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 50\n assert candidate(s = \"abacabadabcabc\") == 8\n assert candidate(s = \"abacabadaba\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\") == 31\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"thisisaverylongstringwithvariouscharacters\") == 37\n assert candidate(s = \"mississippi\") == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"repeatedrepeatedrepeatedrepeatedrepeated\") == 33\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"allcharactersareuniquehere\") == 19\n", "comparison": "exact"}, "public_tests": ["\"xyzzaz\"", "\"aababcabc\""], "hints": ["Try using a set to find out the number of distinct characters in a substring."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().countGoodSubstrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:33+00:00", "tests_total": 96, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string", "sliding-window", "counting"]}, "language": "python", "interface": {"raw_signature": "def countGoodSubstrings(self, s: str) -> int:", "container": "Solution", "callable": "countGoodSubstrings", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1877, "task_id": "minimize-maximum-pair-sum-in-array", "difficulty": "Medium", "problem_description": "The pair sum of a pair (a,b) is equal to a + b. The maximum pair sum is the largest pair sum in a list of pairs.\n\n- For example, if we have pairs (1,5), (2,3), and (4,4), the maximum pair sum would be max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8.\n\nGiven an array nums of even length n, pair up the elements of nums into n / 2 pairs such that:\n\n- Each element of nums is in exactly one pair, and\n- The maximum pair sum is minimized.\n\nReturn the minimized maximum pair sum after optimally pairing up the elements.\n\nExample 1:\n\nInput: nums = [3,5,2,3]\nOutput: 7\nExplanation: The elements can be paired up into pairs (3,3) and (5,2).\nThe maximum pair sum is max(3+3, 5+2) = max(6, 7) = 7.\n\nExample 2:\n\nInput: nums = [3,5,4,2,4,6]\nOutput: 8\nExplanation: The elements can be paired up into pairs (3,5), (4,4), and (6,2).\nThe maximum pair sum is max(3+5, 4+4, 6+2) = max(8, 8, 8) = 8.\n\nConstraints:\n\n- n == nums.length\n- 2 <= n <= 10^5\n- n is even.\n- 1 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 6, 2, 5, 3, 4]) == 7\n assert candidate(nums = [10, 10, 10, 10]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1]) == 100001\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 7\n assert candidate(nums = [1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [10, 10, 10, 10, 10, 10]) == 20\n assert candidate(nums = [3, 5, 4, 2, 4, 6]) == 8\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5]) == 10\n assert candidate(nums = [3, 5, 2, 3]) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 32\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 105\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 32\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994]) == 100001\n assert candidate(nums = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 99999]) == 100001\n assert candidate(nums = [5, 8, 12, 19, 22, 28, 33, 45, 50, 55]) == 60\n assert candidate(nums = [8, 3, 5, 7, 1, 9, 2, 6, 4, 10]) == 11\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [7, 3, 1, 4, 9, 8, 2, 5, 6, 10]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 17\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995]) == 100000\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 200000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 31\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [4, 1, 2, 3, 6, 5, 7, 8]) == 9\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995]) == 100000\n assert candidate(nums = [15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16]) == 17\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993]) == 100001\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 4, 6, 3, 7, 2, 8]) == 10\n assert candidate(nums = [34, 8, 64, 51, 32, 21]) == 72\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 55\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 11\n assert candidate(nums = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100000]) == 100002\n assert candidate(nums = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == 100001\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 11\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 1991\n assert candidate(nums = [23, 34, 45, 56, 67, 78, 89, 90]) == 123\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [2, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 9\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 100000\n assert candidate(nums = [100, 1, 2, 99, 3, 98, 4, 97]) == 101\n assert candidate(nums = [9, 1, 4, 8, 5, 7, 6, 2]) == 11\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996]) == 100000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14, 16]) == 17\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(nums = [8, 3, 2, 1, 6, 5, 4, 7]) == 9\n assert candidate(nums = [100000, 1, 100000, 2, 100000, 3, 100000, 4]) == 100004\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 31\n assert candidate(nums = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 50\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]) == 12\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12]) == 13\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 100000\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 9, 8, 11, 10]) == 12\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 100\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85]) == 100\n assert candidate(nums = [7, 10, 4, 17, 15, 9, 2, 12]) == 19\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 182, 189, 196, 203, 210]) == 217\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 170\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]) == 12\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 130\n assert candidate(nums = [100000, 99999, 1, 2, 99998, 3, 99997, 4, 99996, 5, 99995, 6]) == 100001\n assert candidate(nums = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == 100005\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000]) == 200000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 130\n assert candidate(nums = [100000, 1, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 100001\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12]) == 13\n assert candidate(nums = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 21\n assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995, 5]) == 100000\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995, 6, 99994]) == 100000\n assert candidate(nums = [15, 21, 33, 44, 55, 60, 65, 70, 75, 80, 85, 90]) == 125\n assert candidate(nums = [9, 3, 2, 8, 6, 5, 7, 4, 1, 10]) == 11\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 18, 17, 16, 15, 14, 13, 12]) == 19\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1]) == 100001\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 17\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 100000\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 101\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 24\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n assert candidate(nums = [9, 2, 8, 4, 5, 1, 6, 3, 7, 10]) == 11\n", "comparison": "exact"}, "public_tests": ["[3,5,2,3]", "[3,5,4,2,4,6]"], "hints": ["Would sorting help find the optimal order?", "Given a specific element, how would you minimize its specific pairwise sum?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minPairSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:35+00:00", "tests_total": 97, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "two-pointers", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minPairSum(self, nums: List[int]) -> int:", "container": "Solution", "callable": "minPairSum", "parameters": [{"name": "nums", "type": "List[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1878, "task_id": "get-biggest-three-rhombus-sums-in-a-grid", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix grid.\n\nA rhombus sum is the sum of the elements that form the border of a regular rhombus shape in grid. The rhombus must have the shape of a square rotated 45 degrees with each of the corners centered in a grid cell. Below is an image of four valid rhombus shapes with the corresponding colored cells that should be included in each rhombus sum:\n\nNote that the rhombus can have an area of 0, which is depicted by the purple rhombus in the bottom right corner.\n\nReturn the biggest three distinct rhombus sums in the grid in descending order. If there are less than three distinct values, return all of them.\n\nExample 1:\n\nInput: grid = [[3,4,5,1,3],[3,3,4,2,3],[20,30,200,40,10],[1,5,5,4,1],[4,3,2,2,5]]\nOutput: [228,216,211]\nExplanation: The rhombus shapes for the three biggest distinct rhombus sums are depicted above.\n- Blue: 20 + 3 + 200 + 5 = 228\n- Red: 200 + 2 + 10 + 4 = 216\n- Green: 5 + 200 + 4 + 2 = 211\n\nExample 2:\n\nInput: grid = [[1,2,3],[4,5,6],[7,8,9]]\nOutput: [20,9,8]\nExplanation: The rhombus shapes for the three biggest distinct rhombus sums are depicted above.\n- Blue: 4 + 2 + 6 + 8 = 20\n- Red: 9 (area 0 rhombus in the bottom right corner)\n- Green: 8 (area 0 rhombus in the bottom middle)\n\nExample 3:\n\nInput: grid = [[7,7,7]]\nOutput: [7]\nExplanation: All three possible rhombus sums are the same, so return [7].\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 50\n- 1 <= grid[i][j] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [104, 76, 72]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == [56, 52, 48]\n assert candidate(grid = [[7, 7, 7]]) == [7]\n assert candidate(grid = [[3, 4, 5, 1, 3], [3, 3, 4, 2, 3], [20, 30, 200, 40, 10], [1, 5, 5, 4, 1], [4, 3, 2, 2, 5]]) == [228, 216, 211]\n assert candidate(grid = [[5, 3, 5, 8], [15, 25, 35, 45], [60, 70, 80, 90], [10, 20, 30, 40]]) == [225, 185, 155]\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == [40, 20, 5]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == [4, 1]\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == [20, 5]\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == [20, 9, 8]\n assert candidate(grid = [[5, 3, 5, 5, 5], [3, 3, 3, 3, 3], [5, 5, 5, 5, 5], [3, 3, 3, 3, 3], [5, 5, 5, 5, 5]]) == [32, 16, 14]\n assert candidate(grid = [[10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10]]) == [80, 40, 10]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 3, 4, 3, 1], [1, 2, 3, 3, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]) == [18, 17, 12]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == [40, 20, 5]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10], [6, 7, 8, 9, 10, 11]]) == [56, 48, 40]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == [12, 8, 6]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [62, 61, 60]\n assert candidate(grid = [[25, 16, 32, 8, 4], [12, 24, 18, 36, 27], [6, 12, 24, 18, 36], [3, 6, 12, 24, 18], [1, 3, 6, 12, 24]]) == [170, 120, 116]\n assert candidate(grid = [[20, 10, 20, 10, 20], [10, 20, 10, 20, 10], [20, 10, 20, 10, 20], [10, 20, 10, 20, 10], [20, 10, 20, 10, 20]]) == [160, 80, 40]\n assert candidate(grid = [[50, 40, 30, 20, 10], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]) == [320, 220, 200]\n assert candidate(grid = [[10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24], [25, 26, 27, 28, 29], [30, 31, 32, 33, 34]]) == [176, 112, 108]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]]) == [176, 168, 128]\n assert candidate(grid = [[1, 10, 100, 1000, 10000], [10000, 1000, 100, 10, 1], [1, 10, 100, 1000, 10000], [10000, 1000, 100, 10, 1], [1, 10, 100, 1000, 10000]]) == [12221, 10120, 10000]\n assert candidate(grid = [[10, 20, 30, 40], [40, 30, 20, 10], [10, 20, 30, 40], [40, 30, 20, 10]]) == [100, 40, 30]\n assert candidate(grid = [[10, 15, 20, 25, 30], [5, 9, 12, 18, 22], [3, 6, 8, 10, 14], [1, 2, 3, 4, 5], [7, 11, 13, 17, 19]]) == [83, 69, 55]\n assert candidate(grid = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [13, 15, 17, 19, 21, 23], [25, 27, 29, 31, 33, 35], [37, 39, 41, 43, 45, 47], [49, 51, 53, 55, 57, 59]]) == [249, 233, 180]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 4, 6, 4, 2], [1, 5, 9, 5, 1]]) == [28, 22, 16]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == [176, 160, 156]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [20, 9, 8]\n assert candidate(grid = [[1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20], [5, 9, 13, 17, 21]]) == [88, 64, 60]\n assert candidate(grid = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12]]) == [60, 44, 38]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [88, 66, 44]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 3, 4, 3, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1]]) == [20, 18, 12]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [32, 30, 28]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == [127, 118, 109]\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8], [6, 7, 8, 9]]) == [28, 24, 20]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == [12, 8, 6]\n assert candidate(grid = [[5, 5, 5, 5], [5, 1, 1, 5], [5, 1, 1, 5], [5, 5, 5, 5]]) == [12, 5, 1]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 10, 10, 10, 10, 5], [5, 10, 15, 15, 10, 5], [5, 10, 15, 15, 10, 5], [5, 10, 10, 10, 10, 5], [5, 5, 5, 5, 5, 5]]) == [75, 50, 40]\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]) == [24, 20, 16]\n assert candidate(grid = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70], [40, 50, 60, 70, 80], [50, 60, 70, 80, 90]]) == [400, 280, 240]\n assert candidate(grid = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [3, 5, 7, 9, 11, 13], [4, 6, 8, 10, 12, 14], [5, 7, 9, 11, 13, 15], [6, 8, 10, 12, 14, 16]]) == [80, 72, 64]\n assert candidate(grid = [[1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1]]) == [8, 4, 2]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5], [5, 6, 6, 6, 6, 6, 5], [5, 6, 7, 7, 7, 6, 5], [5, 6, 7, 8, 7, 6, 5], [5, 6, 7, 7, 7, 6, 5], [5, 6, 6, 6, 6, 6, 5], [5, 5, 5, 5, 5, 5, 5]]) == [68, 52, 50]\n assert candidate(grid = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [110, 120, 130, 140, 150], [160, 170, 180, 190, 200], [210, 220, 230, 240, 250]]) == [1040, 760, 720]\n assert candidate(grid = [[100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000]]) == [400000, 100000]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == [80, 60, 40]\n assert candidate(grid = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [60, 70, 80, 90, 100], [55, 65, 75, 85, 95], [110, 120, 130, 140, 150]]) == [520, 400, 360]\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4], [3, 5, 7, 8, 1, 6, 4], [4, 6, 8, 3, 5, 7, 1], [9, 2, 5, 1, 8, 3, 6], [5, 7, 1, 6, 4, 9, 2], [6, 4, 9, 2, 7, 1, 5], [1, 8, 3, 7, 2, 5, 9]]) == [78, 55, 44]\n assert candidate(grid = [[8, 1, 2, 3, 4, 5], [6, 7, 8, 9, 1, 2], [3, 4, 5, 6, 7, 8], [9, 1, 2, 3, 4, 5], [5, 6, 7, 8, 9, 1], [2, 3, 4, 5, 6, 7]]) == [49, 48, 39]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [9, 7, 5, 3, 1, 3, 5, 7, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [9, 7, 5, 3, 1, 3, 5, 7, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == [80, 68, 67]\n assert candidate(grid = [[9, 9, 9, 9, 9, 9, 9], [9, 8, 8, 8, 8, 8, 9], [9, 8, 7, 7, 7, 8, 9], [9, 8, 7, 6, 7, 8, 9], [9, 8, 7, 7, 7, 8, 9], [9, 8, 8, 8, 8, 8, 9], [9, 9, 9, 9, 9, 9, 9]]) == [100, 62, 60]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 3, 4, 3, 2], [1, 2, 3, 3, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]) == [18, 17, 12]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [1, 2, 3, 4, 5]]) == [28, 15, 13]\n assert candidate(grid = [[5, 2, 1, 4, 3, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42]]) == [208, 200, 192]\n assert candidate(grid = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]) == [320, 220, 200]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [2, 3, 4, 5, 6, 7, 8, 9], [3, 4, 5, 6, 7, 8, 9, 10], [4, 5, 6, 7, 8, 9, 10, 11], [5, 6, 7, 8, 9, 10, 11, 12], [6, 7, 8, 9, 10, 11, 12, 13], [7, 8, 9, 10, 11, 12, 13, 14], [8, 9, 10, 11, 12, 13, 14, 15]]) == [108, 96, 88]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 8], [3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10, 11], [6, 7, 8, 9, 10, 11, 12], [7, 8, 9, 10, 11, 12, 13]]) == [84, 72, 64]\n assert candidate(grid = [[100000, 100000, 100000], [100000, 100000, 100000], [100000, 100000, 100000]]) == [400000, 100000]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [3, 4, 5, 6, 7, 8, 9, 10, 1, 2], [4, 5, 6, 7, 8, 9, 10, 1, 2, 3], [5, 6, 7, 8, 9, 10, 1, 2, 3, 4], [6, 7, 8, 9, 10, 1, 2, 3, 4, 5], [7, 8, 9, 10, 1, 2, 3, 4, 5, 6], [8, 9, 10, 1, 2, 3, 4, 5, 6, 7], [9, 10, 1, 2, 3, 4, 5, 6, 7, 8], [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == [90, 86, 84]\n assert candidate(grid = [[1, 10, 100, 1000, 10000], [10, 100, 1000, 10000, 1], [100, 1000, 10000, 1, 10], [1000, 10000, 1, 10, 100], [10000, 1, 10, 100, 1000]]) == [20330, 20200, 20020]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]]) == [300, 264, 256]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [32, 30, 28]\n assert candidate(grid = [[10, 1, 10, 1, 10], [1, 10, 1, 10, 1], [10, 1, 10, 1, 10], [1, 10, 1, 10, 1], [10, 1, 10, 1, 10]]) == [80, 40, 10]\n assert candidate(grid = [[5, 2, 3, 1, 4], [1, 5, 6, 2, 3], [4, 1, 7, 3, 2], [3, 8, 4, 6, 5], [9, 7, 6, 5, 4]]) == [36, 27, 24]\n assert candidate(grid = [[10, 11, 12], [13, 14, 15], [16, 17, 18]]) == [56, 18, 17]\n assert candidate(grid = [[8, 4, 2], [6, 2, 4], [1, 3, 6]]) == [17, 8, 6]\n assert candidate(grid = [[1, 2], [3, 4]]) == [4, 3, 2]\n assert candidate(grid = [[5, 9, 1, 9], [8, 7, 4, 8], [6, 6, 3, 2]]) == [27, 19, 9]\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == [20, 5]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [4, 2, 1, 2, 4], [1, 5, 9, 5, 1]]) == [24, 18, 14]\n assert candidate(grid = [[5, 1, 4, 3, 1], [2, 3, 5, 1, 4], [3, 4, 3, 4, 3], [4, 3, 5, 1, 3], [3, 4, 2, 4, 2]]) == [20, 18, 17]\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == [20, 16, 12]\n assert candidate(grid = [[10, 10, 10, 10, 10], [10, 20, 20, 20, 10], [10, 20, 30, 20, 10], [10, 20, 20, 20, 10], [10, 10, 10, 10, 10]]) == [120, 80, 60]\n assert candidate(grid = [[1, 2], [2, 3], [3, 4]]) == [4, 3, 2]\n assert candidate(grid = [[5, 3, 5, 3, 5], [3, 5, 3, 5, 3], [5, 3, 5, 3, 5], [3, 5, 3, 5, 3], [5, 3, 5, 3, 5]]) == [40, 20, 12]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24]]) == [68, 64, 60]\n assert candidate(grid = [[10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10]]) == [40, 10]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 4, 6, 4, 2], [3, 5, 7, 5, 3]]) == [26, 20, 16]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9]]) == [15, 14, 13]\n assert candidate(grid = [[5, 3, 2, 1], [4, 6, 7, 8], [1, 9, 10, 11], [12, 13, 14, 15]]) == [41, 30, 26]\n assert candidate(grid = [[100000, 100000], [100000, 100000]]) == [100000]\n assert candidate(grid = [[5, 3, 5, 5, 5], [3, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 3], [5, 5, 5, 3, 5]]) == [40, 20, 16]\n assert candidate(grid = [[5, 3, 5, 3], [5, 3, 5, 3], [5, 3, 5, 3], [5, 3, 5, 3]]) == [16, 5, 3]\n assert candidate(grid = [[5]]) == [5]\n assert candidate(grid = [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]]) == [36, 9]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [1, 1, 1, 1, 1]]) == [30, 19, 18]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == [12, 5, 4]\n assert candidate(grid = [[10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]]) == [40, 10]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]]) == [40, 20, 5]\n assert candidate(grid = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]]) == [440, 400, 280]\n assert candidate(grid = [[1, 2], [3, 4], [5, 6]]) == [6, 5, 4]\n assert candidate(grid = [[10, 10, 10], [10, 10, 10], [10, 10, 10]]) == [40, 10]\n assert candidate(grid = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == [20, 9, 8]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]) == [128, 120, 92]\n assert candidate(grid = [[5, 3, 2, 1], [9, 8, 7, 6], [5, 6, 7, 8], [1, 2, 3, 4]]) == [25, 24, 23]\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50]]) == [240, 120, 50]\n assert candidate(grid = [[9, 9, 9, 9, 9], [9, 8, 8, 8, 9], [9, 8, 7, 8, 9], [9, 8, 8, 8, 9], [9, 9, 9, 9, 9]]) == [68, 34, 32]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == [8, 4, 1]\n assert candidate(grid = [[10, 20, 30, 40], [15, 25, 35, 45], [20, 30, 40, 50], [25, 35, 45, 55]]) == [160, 140, 120]\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]) == [200, 90, 80]\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == [44, 40, 28]\n assert candidate(grid = [[5, 2, 10, 6], [8, 3, 9, 7], [1, 4, 8, 2], [7, 6, 5, 3]]) == [28, 23, 20]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]]) == [40, 20, 5]\n assert candidate(grid = [[8, 1, 6], [3, 5, 7], [4, 9, 2]]) == [20, 9, 8]\n assert candidate(grid = [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]]) == [72, 36, 9]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == [10, 9, 8]\n assert candidate(grid = [[1, 2], [2, 1]]) == [2, 1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == [8, 4, 1]\n assert candidate(grid = [[100000, 100000, 100000], [100000, 100000, 100000], [100000, 100000, 100000]]) == [400000, 100000]\n assert candidate(grid = [[9, 9, 9, 9], [9, 9, 9, 9], [9, 9, 9, 9], [9, 9, 9, 9]]) == [36, 9]\n assert candidate(grid = [[1]]) == [1]\n assert candidate(grid = [[5, 3, 8, 3, 7], [3, 2, 5, 7, 8], [1, 7, 3, 3, 2], [4, 8, 4, 2, 9], [6, 2, 3, 4, 8]]) == [33, 20, 19]\n", "comparison": "exact"}, "public_tests": ["[[3,4,5,1,3],[3,3,4,2,3],[20,30,200,40,10],[1,5,5,4,1],[4,3,2,2,5]]", "[[1,2,3],[4,5,6],[7,8,9]]", "[[7,7,7]]"], "hints": ["You need to maintain only the biggest 3 distinct sums", "The limits are small enough for you to iterate over all rhombus sizes then iterate over all possible borders to get the sums"], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().getBiggestThree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:38+00:00", "tests_total": 118, "tests_dropped": 6, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "math", "sorting", "heap-priority-queue", "matrix", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def getBiggestThree(self, grid: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "getBiggestThree", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1879, "task_id": "minimum-xor-sum-of-two-arrays", "difficulty": "Hard", "problem_description": "You are given two integer arrays nums1 and nums2 of length n.\n\nThe XOR sum of the two integer arrays is (nums1[0] XOR nums2[0]) + (nums1[1] XOR nums2[1]) + ... + (nums1[n - 1] XOR nums2[n - 1]) (0-indexed).\n\n- For example, the XOR sum of [1,2,3] and [3,2,1] is equal to (1 XOR 3) + (2 XOR 2) + (3 XOR 1) = 2 + 0 + 2 = 4.\n\nRearrange the elements of nums2 such that the resulting XOR sum is minimized.\n\nReturn the XOR sum after the rearrangement.\n\nExample 1:\n\nInput: nums1 = [1,2], nums2 = [2,3]\nOutput: 2\nExplanation: Rearrange nums2 so that it becomes [3,2].\nThe XOR sum is (1 XOR 3) + (2 XOR 2) = 2 + 0 = 2.\n\nExample 2:\n\nInput: nums1 = [1,0,3], nums2 = [5,3,4]\nOutput: 8\nExplanation: Rearrange nums2 so that it becomes [5,4,3].\nThe XOR sum is (1 XOR 5) + (0 XOR 4) + (3 XOR 3) = 4 + 4 + 0 = 8.\n\nConstraints:\n\n- n == nums1.length\n- n == nums2.length\n- 1 <= n <= 14\n- 0 <= nums1[i], nums2[i] <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [3, 4, 2],nums2 = [4, 2, 2]) == 1\n assert candidate(nums1 = [1, 2],nums2 = [2, 3]) == 2\n assert candidate(nums1 = [2, 3, 4, 5],nums2 = [5, 4, 3, 2]) == 0\n assert candidate(nums1 = [4, 6, 2],nums2 = [9, 3, 5]) == 17\n assert candidate(nums1 = [5, 10, 15],nums2 = [15, 10, 5]) == 0\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 20, 10]) == 0\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 1, 1],nums2 = [1, 1, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == 0\n assert candidate(nums1 = [5, 3, 4],nums2 = [1, 0, 3]) == 8\n assert candidate(nums1 = [14, 15, 16],nums2 = [13, 14, 15]) == 29\n assert candidate(nums1 = [7, 8, 9],nums2 = [9, 8, 7]) == 0\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [2, 2, 2, 2]) == 12\n assert candidate(nums1 = [7, 8, 9],nums2 = [10, 11, 12]) == 15\n assert candidate(nums1 = [10000000, 10000000, 10000000],nums2 = [10000000, 10000000, 10000000]) == 0\n assert candidate(nums1 = [3, 5, 7, 9],nums2 = [9, 7, 5, 3]) == 0\n assert candidate(nums1 = [0, 1, 2],nums2 = [3, 4, 5]) == 9\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [14, 28, 19],nums2 = [28, 14, 19]) == 0\n assert candidate(nums1 = [1],nums2 = [1]) == 0\n assert candidate(nums1 = [1, 0, 3],nums2 = [5, 3, 4]) == 8\n assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 14\n assert candidate(nums1 = [12, 14, 16, 18, 20, 22],nums2 = [21, 19, 17, 15, 13, 11]) == 34\n assert candidate(nums1 = [4, 1, 3, 2],nums2 = [7, 6, 5, 8]) == 18\n assert candidate(nums1 = [9999999, 8888888, 7777777, 6666666, 5555555],nums2 = [4444444, 3333333, 2222222, 1111111, 0]) == 28302135\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128],nums2 = [128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums1 = [7, 23, 15, 4, 8],nums2 = [17, 9, 3, 20, 12]) == 30\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8],nums2 = [8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27]) == 115\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 36\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 9999999, 999999, 99999, 9999, 999, 99],nums2 = [99, 999, 9999, 99999, 999999, 9999999, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 0\n assert candidate(nums1 = [7, 8, 9, 10, 11, 12],nums2 = [12, 11, 10, 9, 8, 7]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 220\n assert candidate(nums1 = [7, 13, 21, 31],nums2 = [3, 8, 15, 28]) == 34\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],nums2 = [70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums1 = [7, 8, 9, 10, 11],nums2 = [12, 13, 14, 15, 16]) == 39\n assert candidate(nums1 = [13, 17, 19, 23, 29, 31],nums2 = [31, 29, 23, 19, 17, 13]) == 0\n assert candidate(nums1 = [101, 202, 303, 404, 505, 606, 707, 808, 909],nums2 = [909, 808, 707, 606, 505, 404, 303, 202, 101]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [2, 4, 6, 8, 10, 12, 14, 16]) == 24\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 42\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],nums2 = [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800],nums2 = [800, 700, 600, 500, 400, 300, 200, 100]) == 0\n assert candidate(nums1 = [5, 8, 12, 7, 3],nums2 = [10, 6, 4, 15, 9]) == 15\n assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000],nums2 = [140000, 130000, 120000, 110000, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 14\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],nums2 = [140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(nums1 = [1, 0, 0, 0],nums2 = [0, 1, 1, 1]) == 2\n assert candidate(nums1 = [21, 17, 34, 19, 28, 42],nums2 = [45, 39, 27, 51, 18, 32]) == 101\n assert candidate(nums1 = [8, 6, 4, 2, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18],nums2 = [18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 2, 4, 6, 8]) == 0\n assert candidate(nums1 = [5, 6, 7, 8, 9, 10, 11, 12, 13],nums2 = [13, 12, 11, 10, 9, 8, 7, 6, 5]) == 0\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192],nums2 = [8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums1 = [9, 11, 7, 13, 17, 19, 23],nums2 = [29, 25, 21, 15, 13, 11, 7]) == 30\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7],nums2 = [7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [7, 23, 45, 6, 78],nums2 = [89, 12, 34, 56, 78]) == 146\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 0\n assert candidate(nums1 = [8, 16, 24, 32, 40, 48, 56, 64],nums2 = [64, 56, 48, 40, 32, 24, 16, 8]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 15\n assert candidate(nums1 = [9876543, 8765432, 7654321, 6543210, 5432109],nums2 = [4321098, 3210987, 2109876, 1098765, 987654]) == 28067535\n assert candidate(nums1 = [8, 16, 32, 64, 128, 256],nums2 = [256, 128, 64, 32, 16, 8]) == 0\n assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000],nums2 = [50000, 40000, 30000, 20000, 10000]) == 0\n assert candidate(nums1 = [123456, 789012, 345678, 901234, 567890, 678901, 789012, 890123, 901234, 123456, 234567, 345678, 456789, 567890],nums2 = [567890, 456789, 345678, 234567, 123456, 901234, 890123, 789012, 678901, 567890, 456789, 345678, 234567, 123456]) == 1656438\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53],nums2 = [53, 49, 45, 41, 37, 33, 29, 25, 21, 17, 13, 9, 5, 1]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70],nums2 = [70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10]) == 0\n assert candidate(nums1 = [7, 8, 9, 10, 11],nums2 = [11, 10, 9, 8, 7]) == 0\n assert candidate(nums1 = [2, 3, 5, 7, 11, 13, 17, 19],nums2 = [19, 17, 13, 11, 7, 5, 3, 2]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [10, 8, 6, 4, 2]) == 15\n assert candidate(nums1 = [256, 512, 1024, 2048, 4096],nums2 = [8192, 4096, 2048, 1024, 512]) == 8448\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400],nums2 = [1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 0\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],nums2 = [98, 91, 84, 77, 70, 63, 56, 49, 42, 35, 28, 21, 14, 7]) == 0\n assert candidate(nums1 = [23, 34, 45, 56, 67],nums2 = [67, 56, 45, 34, 23]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13],nums2 = [13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700],nums2 = [700, 600, 500, 400, 300, 200, 100]) == 0\n", "comparison": "exact"}, "public_tests": ["[1,2]\n[2,3]", "[1,0,3]\n[5,3,4]"], "hints": ["Since n <= 14, we can consider every subset of nums2.", "We can represent every subset of nums2 using bitmasks."], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minimumXORSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:40+00:00", "tests_total": 93, "tests_dropped": 14, "flags": [], "topic_tags": ["array", "dynamic-programming", "bit-manipulation", "bitmask", "hungarian-algorithm", "bipartite-graph", "successive-shortest-path-algorithm"]}, "language": "python", "interface": {"raw_signature": "def minimumXORSum(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "minimumXORSum", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1880, "task_id": "check-if-word-equals-summation-of-two-words", "difficulty": "Easy", "problem_description": "The letter value of a letter is its position in the alphabet starting from 0 (i.e. 'a' -> 0, 'b' -> 1, 'c' -> 2, etc.).\n\nThe numerical value of some string of lowercase English letters s is the concatenation of the letter values of each letter in s, which is then converted into an integer.\n\n- For example, if s = \"acb\", we concatenate each letter's letter value, resulting in \"021\". After converting it, we get 21.\n\nYou are given three strings firstWord, secondWord, and targetWord, each consisting of lowercase English letters 'a' through 'j' inclusive.\n\nReturn true if the summation of the numerical values of firstWord and secondWord equals the numerical value of targetWord, or false otherwise.\n\nExample 1:\n\nInput: firstWord = \"acb\", secondWord = \"cba\", targetWord = \"cdb\"\nOutput: true\nExplanation:\nThe numerical value of firstWord is \"acb\" -> \"021\" -> 21.\nThe numerical value of secondWord is \"cba\" -> \"210\" -> 210.\nThe numerical value of targetWord is \"cdb\" -> \"231\" -> 231.\nWe return true because 21 + 210 == 231.\n\nExample 2:\n\nInput: firstWord = \"aaa\", secondWord = \"a\", targetWord = \"aab\"\nOutput: false\nExplanation:\nThe numerical value of firstWord is \"aaa\" -> \"000\" -> 0.\nThe numerical value of secondWord is \"a\" -> \"0\" -> 0.\nThe numerical value of targetWord is \"aab\" -> \"001\" -> 1.\nWe return false because 0 + 0 != 1.\n\nExample 3:\n\nInput: firstWord = \"aaa\", secondWord = \"a\", targetWord = \"aaaa\"\nOutput: true\nExplanation:\nThe numerical value of firstWord is \"aaa\" -> \"000\" -> 0.\nThe numerical value of secondWord is \"a\" -> \"0\" -> 0.\nThe numerical value of targetWord is \"aaaa\" -> \"0000\" -> 0.\nWe return true because 0 + 0 == 0.\n\nConstraints:\n\n- 1 <= firstWord.length, secondWord.length, targetWord.length <= 8\n- firstWord, secondWord, and targetWord consist of lowercase English letters from 'a' to 'j' inclusive.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(firstWord = \"ij\",secondWord = \"ji\",targetWord = \"ii\") == False\n assert candidate(firstWord = \"fgh\",secondWord = \"ghf\",targetWord = \"ggg\") == False\n assert candidate(firstWord = \"ij\",secondWord = \"ji\",targetWord = \"jjj\") == False\n assert candidate(firstWord = \"b\",secondWord = \"c\",targetWord = \"d\") == True\n assert candidate(firstWord = \"i\",secondWord = \"j\",targetWord = \"ji\") == False\n assert candidate(firstWord = \"ab\",secondWord = \"ba\",targetWord = \"bb\") == True\n assert candidate(firstWord = \"j\",secondWord = \"j\",targetWord = \"i\") == False\n assert candidate(firstWord = \"a\",secondWord = \"a\",targetWord = \"b\") == False\n assert candidate(firstWord = \"aaa\",secondWord = \"a\",targetWord = \"aab\") == False\n assert candidate(firstWord = \"aaa\",secondWord = \"a\",targetWord = \"aaaa\") == True\n assert candidate(firstWord = \"acb\",secondWord = \"cba\",targetWord = \"cdb\") == True\n assert candidate(firstWord = \"j\",secondWord = \"j\",targetWord = \"jj\") == False\n assert candidate(firstWord = \"acacacac\",secondWord = \"bdbdbdbd\",targetWord = \"cececece\") == False\n assert candidate(firstWord = \"ijijij\",secondWord = \"jijiji\",targetWord = \"jjjjjjjj\") == False\n assert candidate(firstWord = \"j\",secondWord = \"jj\",targetWord = \"jjj\") == False\n assert candidate(firstWord = \"ijijij\",secondWord = \"ijijij\",targetWord = \"jjjjjjjj\") == False\n assert candidate(firstWord = \"hjihj\",secondWord = \"ihjih\",targetWord = \"jjjjj\") == False\n assert candidate(firstWord = \"aabbcc\",secondWord = \"ddeeff\",targetWord = \"gggggh\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"abcdefgh\",targetWord = \"hhhhhhhh\") == False\n assert candidate(firstWord = \"babababa\",secondWord = \"babababa\",targetWord = \"cacacaca\") == True\n assert candidate(firstWord = \"aaa\",secondWord = \"bbb\",targetWord = \"ccc\") == False\n assert candidate(firstWord = \"iiii\",secondWord = \"jjjj\",targetWord = \"jjjjjjjj\") == False\n assert candidate(firstWord = \"abc\",secondWord = \"def\",targetWord = \"defabc\") == False\n assert candidate(firstWord = \"a\",secondWord = \"b\",targetWord = \"c\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"hgfedcba\",targetWord = \"jjjjjjjj\") == False\n assert candidate(firstWord = \"jjjjj\",secondWord = \"jjjjj\",targetWord = \"jjjjjjj\") == False\n assert candidate(firstWord = \"aaaaaaaa\",secondWord = \"bbbbbbbb\",targetWord = \"cccccccc\") == False\n assert candidate(firstWord = \"aabbccdd\",secondWord = \"dccbbaaa\",targetWord = \"dddddddd\") == False\n assert candidate(firstWord = \"iiii\",secondWord = \"jjjj\",targetWord = \"jjjjjj\") == False\n assert candidate(firstWord = \"ijijijij\",secondWord = \"hghghghg\",targetWord = \"gggggggg\") == False\n assert candidate(firstWord = \"jijij\",secondWord = \"ijiji\",targetWord = \"jjjjjjj\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"hgfedcba\",targetWord = \"jjjjjjj\") == False\n assert candidate(firstWord = \"abcde\",secondWord = \"edcba\",targetWord = \"jjjjj\") == False\n assert candidate(firstWord = \"hgfedcba\",secondWord = \"abcdefgh\",targetWord = \"iiiiiiii\") == False\n assert candidate(firstWord = \"jijij\",secondWord = \"ijiji\",targetWord = \"jjjjj\") == False\n assert candidate(firstWord = \"j\",secondWord = \"ij\",targetWord = \"ji\") == True\n assert candidate(firstWord = \"jij\",secondWord = \"iji\",targetWord = \"jjjj\") == False\n", "comparison": "exact"}, "public_tests": ["\"acb\"\n\"cba\"\n\"cdb\"", "\"aaa\"\n\"a\"\n\"aab\"", "\"aaa\"\n\"a\"\n\"aaaa\""], "hints": ["Convert each character of each word to its numerical value.", "Check if the numerical values satisfies the condition."], "metadata": {"canonical_parameter_names": ["firstWord", "secondWord", "targetWord"], "leetcode_dataset_entry_point": "Solution().isSumEqual", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:42+00:00", "tests_total": 73, "tests_dropped": 36, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:", "container": "Solution", "callable": "isSumEqual", "parameters": [{"name": "firstWord", "type": "str"}, {"name": "secondWord", "type": "str"}, {"name": "targetWord", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1881, "task_id": "maximum-value-after-insertion", "difficulty": "Medium", "problem_description": "You are given a very large integer n, represented as a string, and an integer digit x. The digits in n and the digit x are in the inclusive range [1, 9], and n may represent a negative number.\n\nYou want to maximize n's numerical value by inserting x anywhere in the decimal representation of n. You cannot insert x to the left of the negative sign.\n\n- For example, if n = 73 and x = 6, it would be best to insert it between 7 and 3, making n = 763.\n- If n = -55 and x = 2, it would be best to insert it before the first 5, making n = -255.\n\nReturn a string representing the maximum value of n after the insertion.\n\nExample 1:\n\nInput: n = \"99\", x = 9\nOutput: \"999\"\nExplanation: The result is the same regardless of where you insert 9.\n\nExample 2:\n\nInput: n = \"-13\", x = 2\nOutput: \"-123\"\nExplanation: You can make n one of {-213, -123, -132}, and the largest of those three is -123.\n\nConstraints:\n\n- 1 <= n.length <= 10^5\n- 1 <= x <= 9\n- The digits in n are in the range [1, 9].\n- n is a valid representation of an integer.\n- In the case of a negative n, it will begin with '-'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = \"5486\",x = 7) == \"75486\"\n assert candidate(n = \"-11111\",x = 1) == \"-111111\"\n assert candidate(n = \"-123456789\",x = 5) == \"-1234556789\"\n assert candidate(n = \"987654321\",x = 5) == \"9876554321\"\n assert candidate(n = \"-98765\",x = 3) == \"-398765\"\n assert candidate(n = \"-1000\",x = 1) == \"-10001\"\n assert candidate(n = \"-987654321\",x = 5) == \"-5987654321\"\n assert candidate(n = \"-54321\",x = 4) == \"-454321\"\n assert candidate(n = \"123456789\",x = 5) == \"5123456789\"\n assert candidate(n = \"5\",x = 9) == \"95\"\n assert candidate(n = \"-1000\",x = 5) == \"-10005\"\n assert candidate(n = \"1000\",x = 1) == \"11000\"\n assert candidate(n = \"54321\",x = 6) == \"654321\"\n assert candidate(n = \"12345\",x = 3) == \"312345\"\n assert candidate(n = \"1000\",x = 5) == \"51000\"\n assert candidate(n = \"-973\",x = 8) == \"-8973\"\n assert candidate(n = \"-13\",x = 2) == \"-123\"\n assert candidate(n = \"54823\",x = 7) == \"754823\"\n assert candidate(n = \"1\",x = 1) == \"11\"\n assert candidate(n = \"99\",x = 9) == \"999\"\n assert candidate(n = \"-64823\",x = 7) == \"-647823\"\n assert candidate(n = \"567\",x = 8) == \"8567\"\n assert candidate(n = \"-9\",x = 1) == \"-19\"\n assert candidate(n = \"-9\",x = 9) == \"-99\"\n assert candidate(n = \"54893\",x = 7) == \"754893\"\n assert candidate(n = \"-987\",x = 7) == \"-7987\"\n assert candidate(n = \"-222222222\",x = 2) == \"-2222222222\"\n assert candidate(n = \"-1\",x = 1) == \"-11\"\n assert candidate(n = \"1000000000\",x = 9) == \"91000000000\"\n assert candidate(n = \"123123123\",x = 3) == \"3123123123\"\n assert candidate(n = \"-101010101\",x = 5) == \"-1010101015\"\n assert candidate(n = \"999999999\",x = 1) == \"9999999991\"\n assert candidate(n = \"500000000\",x = 5) == \"5500000000\"\n assert candidate(n = \"555555555\",x = 5) == \"5555555555\"\n assert candidate(n = \"-595959595\",x = 5) == \"-5595959595\"\n assert candidate(n = \"-123456789\",x = 3) == \"-1233456789\"\n assert candidate(n = \"222222222\",x = 1) == \"2222222221\"\n assert candidate(n = \"192837465\",x = 4) == \"4192837465\"\n assert candidate(n = \"-900000000\",x = 1) == \"-1900000000\"\n assert candidate(n = \"-999999999\",x = 9) == \"-9999999999\"\n assert candidate(n = \"-9876543210\",x = 1) == \"-19876543210\"\n assert candidate(n = \"9876543210\",x = 9) == \"99876543210\"\n assert candidate(n = \"-5432109876\",x = 9) == \"-54321098769\"\n assert candidate(n = \"-123456789\",x = 4) == \"-1234456789\"\n assert candidate(n = \"-199999999\",x = 9) == \"-1999999999\"\n assert candidate(n = \"-123123123\",x = 5) == \"-1231231235\"\n assert candidate(n = \"199999999\",x = 9) == \"9199999999\"\n assert candidate(n = \"123456789\",x = 9) == \"9123456789\"\n assert candidate(n = \"111111111\",x = 2) == \"2111111111\"\n assert candidate(n = \"53284769\",x = 5) == \"553284769\"\n assert candidate(n = \"9876543210\",x = 8) == \"98876543210\"\n assert candidate(n = \"9\",x = 1) == \"91\"\n assert candidate(n = \"987654321\",x = 9) == \"9987654321\"\n assert candidate(n = \"111000111\",x = 1) == \"1111000111\"\n assert candidate(n = \"-1000000000\",x = 9) == \"-10000000009\"\n assert candidate(n = \"-123456789\",x = 1) == \"-1123456789\"\n assert candidate(n = \"54321\",x = 3) == \"543321\"\n assert candidate(n = \"-9999999999\",x = 5) == \"-59999999999\"\n assert candidate(n = \"505050505\",x = 5) == \"5505050505\"\n assert candidate(n = \"121212121\",x = 3) == \"3121212121\"\n assert candidate(n = \"123454321\",x = 5) == \"5123454321\"\n assert candidate(n = \"333333333\",x = 3) == \"3333333333\"\n assert candidate(n = \"987654321\",x = 8) == \"9887654321\"\n assert candidate(n = \"11111111111111111111\",x = 2) == \"211111111111111111111\"\n assert candidate(n = \"-987654321\",x = 1) == \"-1987654321\"\n assert candidate(n = \"-500000000\",x = 5) == \"-5000000005\"\n assert candidate(n = \"-53284769\",x = 5) == \"-532584769\"\n assert candidate(n = \"101010101\",x = 5) == \"5101010101\"\n assert candidate(n = \"-9876543210\",x = 5) == \"-59876543210\"\n assert candidate(n = \"666666666\",x = 5) == \"6666666665\"\n assert candidate(n = \"111111111\",x = 1) == \"1111111111\"\n assert candidate(n = \"12345678901234567890\",x = 5) == \"512345678901234567890\"\n assert candidate(n = \"987654321\",x = 6) == \"9876654321\"\n assert candidate(n = \"-123456789\",x = 9) == \"-1234567899\"\n assert candidate(n = \"123456789\",x = 1) == \"1234567891\"\n assert candidate(n = \"-555555555\",x = 6) == \"-5555555556\"\n assert candidate(n = \"-333333333\",x = 2) == \"-2333333333\"\n assert candidate(n = \"595959595\",x = 9) == \"9595959595\"\n assert candidate(n = \"-54321\",x = 6) == \"-543216\"\n assert candidate(n = \"987654321\",x = 7) == \"9877654321\"\n assert candidate(n = \"9\",x = 9) == \"99\"\n assert candidate(n = \"-86420\",x = 1) == \"-186420\"\n assert candidate(n = \"-111111111\",x = 9) == \"-1111111119\"\n assert candidate(n = \"-54321\",x = 3) == \"-354321\"\n assert candidate(n = \"-505050505\",x = 5) == \"-5050505055\"\n assert candidate(n = \"100000000\",x = 9) == \"9100000000\"\n assert candidate(n = \"-9876543210987654321\",x = 9) == \"-98765432109876543219\"\n assert candidate(n = \"333333333\",x = 4) == \"4333333333\"\n assert candidate(n = \"-2222222222\",x = 1) == \"-12222222222\"\n assert candidate(n = \"122222222\",x = 2) == \"2122222222\"\n assert candidate(n = \"123456789\",x = 3) == \"3123456789\"\n assert candidate(n = \"-321321321\",x = 2) == \"-2321321321\"\n assert candidate(n = \"1122334455\",x = 6) == \"61122334455\"\n assert candidate(n = \"123456789\",x = 6) == \"6123456789\"\n assert candidate(n = \"1111111111\",x = 1) == \"11111111111\"\n assert candidate(n = \"-999999999\",x = 1) == \"-1999999999\"\n assert candidate(n = \"-333333333\",x = 3) == \"-3333333333\"\n assert candidate(n = \"-1122334455\",x = 3) == \"-11223334455\"\n assert candidate(n = \"-9876543210\",x = 8) == \"-89876543210\"\n assert candidate(n = \"98765432109876543210\",x = 5) == \"987655432109876543210\"\n assert candidate(n = \"-12345678901234567890\",x = 5) == \"-123455678901234567890\"\n assert candidate(n = \"1\",x = 9) == \"91\"\n assert candidate(n = \"-2000000000\",x = 1) == \"-12000000000\"\n assert candidate(n = \"11111\",x = 1) == \"111111\"\n assert candidate(n = \"100000000\",x = 1) == \"1100000000\"\n assert candidate(n = \"1234567890\",x = 5) == \"51234567890\"\n assert candidate(n = \"-999000999\",x = 9) == \"-9990009999\"\n assert candidate(n = \"1111111111\",x = 2) == \"21111111111\"\n assert candidate(n = \"-99999\",x = 1) == \"-199999\"\n assert candidate(n = \"555555555\",x = 6) == \"6555555555\"\n assert candidate(n = \"-98765432109876543210\",x = 5) == \"-598765432109876543210\"\n assert candidate(n = \"1999999999\",x = 2) == \"21999999999\"\n assert candidate(n = \"123123123\",x = 4) == \"4123123123\"\n assert candidate(n = \"86420\",x = 9) == \"986420\"\n assert candidate(n = \"-1\",x = 9) == \"-19\"\n assert candidate(n = \"-1000000000\",x = 1) == \"-10000000001\"\n assert candidate(n = \"989898989\",x = 7) == \"9898989897\"\n assert candidate(n = \"-222222222\",x = 3) == \"-2222222223\"\n assert candidate(n = \"192837465\",x = 8) == \"8192837465\"\n assert candidate(n = \"33333\",x = 3) == \"333333\"\n assert candidate(n = \"1000000000\",x = 1) == \"11000000000\"\n assert candidate(n = \"123456789\",x = 4) == \"4123456789\"\n assert candidate(n = \"-123456789\",x = 8) == \"-1234567889\"\n assert candidate(n = \"999999999\",x = 9) == \"9999999999\"\n", "comparison": "exact"}, "public_tests": ["\"99\"\n9", "\"-13\"\n2"], "hints": ["Note that if the number is negative it's the same as positive but you look for the minimum instead.", "In the case of maximum, if s[i] < x it's optimal that x is put before s[i].", "In the case of minimum, if s[i] > x it's optimal that x is put before s[i]."], "metadata": {"canonical_parameter_names": ["n", "x"], "leetcode_dataset_entry_point": "Solution().maxValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:44+00:00", "tests_total": 133, "tests_dropped": 9, "flags": [], "topic_tags": ["string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maxValue(self, n: str, x: int) -> str:", "container": "Solution", "callable": "maxValue", "parameters": [{"name": "n", "type": "str"}, {"name": "x", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1882, "task_id": "process-tasks-using-servers", "difficulty": "Medium", "problem_description": "You are given two 0-indexed integer arrays servers and tasks of lengths n and m respectively. servers[i] is the weight of the i^th server, and tasks[j] is the time needed to process the j^th task in seconds.\n\nTasks are assigned to the servers using a task queue. Initially, all servers are free, and the queue is empty.\n\nAt second j, the j^th task is inserted into the queue (starting with the 0^th task being inserted at second 0). As long as there are free servers and the queue is not empty, the task in the front of the queue will be assigned to a free server with the smallest weight, and in case of a tie, it is assigned to a free server with the smallest index.\n\nIf there are no free servers and the queue is not empty, we wait until a server becomes free and immediately assign the next task. If multiple servers become free at the same time, then multiple tasks from the queue will be assigned in order of insertion following the weight and index priorities above.\n\nA server that is assigned task j at second t will be free again at second t + tasks[j].\n\nBuild an array ans of length m, where ans[j] is the index of the server the j^th task will be assigned to.\n\nReturn the array ans.\n\nExample 1:\n\nInput: servers = [3,3,2], tasks = [1,2,3,2,1,2]\nOutput: [2,2,0,2,1,2]\nExplanation: Events in chronological order go as follows:\n- At second 0, task 0 is added and processed using server 2 until second 1.\n- At second 1, server 2 becomes free. Task 1 is added and processed using server 2 until second 3.\n- At second 2, task 2 is added and processed using server 0 until second 5.\n- At second 3, server 2 becomes free. Task 3 is added and processed using server 2 until second 5.\n- At second 4, task 4 is added and processed using server 1 until second 5.\n- At second 5, all servers become free. Task 5 is added and processed using server 2 until second 7.\n\nExample 2:\n\nInput: servers = [5,1,4,3,2], tasks = [2,1,2,4,5,2,1]\nOutput: [1,4,1,4,1,3,2]\nExplanation: Events in chronological order go as follows:\n- At second 0, task 0 is added and processed using server 1 until second 2.\n- At second 1, task 1 is added and processed using server 4 until second 2.\n- At second 2, servers 1 and 4 become free. Task 2 is added and processed using server 1 until second 4.\n- At second 3, task 3 is added and processed using server 4 until second 7.\n- At second 4, server 1 becomes free. Task 4 is added and processed using server 1 until second 9.\n- At second 5, task 5 is added and processed using server 3 until second 7.\n- At second 6, task 6 is added and processed using server 2 until second 7.\n\nConstraints:\n\n- servers.length == n\n- tasks.length == m\n- 1 <= n, m <= 2 * 10^5\n- 1 <= servers[i], tasks[j] <= 2 * 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(servers = [3, 3, 2],tasks = [1, 2, 3, 2, 1, 2]) == [2, 2, 0, 2, 1, 2]\n assert candidate(servers = [1, 1, 1],tasks = [10, 20, 30, 40, 50]) == [0, 1, 2, 0, 1]\n assert candidate(servers = [5, 1, 4, 3, 2],tasks = [2, 1, 2, 4, 5, 2, 1]) == [1, 4, 1, 4, 1, 3, 2]\n assert candidate(servers = [2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1],tasks = [10]) == [0]\n assert candidate(servers = [10, 20, 30],tasks = [3, 2, 1]) == [0, 1, 2]\n assert candidate(servers = [1, 2, 3],tasks = [3, 2, 1]) == [0, 1, 2]\n assert candidate(servers = [1, 2, 3, 4, 5],tasks = [5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4]\n assert candidate(servers = [10, 20, 30],tasks = [1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0]\n assert candidate(servers = [5, 4, 3, 2, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [4, 4, 3, 4, 2, 3, 1, 4, 0, 2]\n assert candidate(servers = [10, 20, 30],tasks = [1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0]\n assert candidate(servers = [2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 1, 1],tasks = [10, 10, 10, 10, 10]) == [0, 1, 2, 0, 1]\n assert candidate(servers = [1, 2, 3, 4, 5],tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7]\n assert candidate(servers = [5, 4, 3, 2, 1],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 5, 1, 3, 0, 5, 1, 4, 2, 3, 0, 3, 0, 5, 1, 3, 0, 4, 2]\n assert candidate(servers = [10, 15, 20, 25, 30],tasks = [5, 10, 15, 20, 25, 30, 35, 40]) == [0, 1, 2, 3, 4, 0, 1, 2]\n assert candidate(servers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [5, 15, 25, 35, 45, 55, 65]) == [0, 1, 2, 3, 4, 0, 1]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [1, 1, 1, 1, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],tasks = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 3, 6, 0, 9, 2, 4, 8, 10, 7, 5]\n assert candidate(servers = [3, 1, 2],tasks = [2, 3, 1, 2, 1, 3, 2, 1, 2, 3, 1, 2, 3]) == [1, 2, 1, 1, 2, 1, 2, 0, 1, 2, 1, 1, 2]\n assert candidate(servers = [3, 5, 2, 7, 6],tasks = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 0, 2, 1, 0, 4, 2, 3, 1]\n assert candidate(servers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(servers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],tasks = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 8, 9, 8, 9, 7, 8]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(servers = [5, 4, 3, 2, 1],tasks = [2, 3, 4, 5, 1, 2, 3, 4, 5]) == [4, 3, 4, 2, 3, 3, 4, 3, 2]\n assert candidate(servers = [100, 200, 150, 50],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2]\n assert candidate(servers = [100, 100, 100, 100, 100],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [20, 10, 30, 40, 50],tasks = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [1, 0, 2, 3, 4, 1, 0, 2, 3, 4]\n assert candidate(servers = [2, 3, 1, 4, 5, 2, 3, 1, 4, 5],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 7, 0, 5, 1, 6, 3, 8, 4, 9, 2, 7, 0, 5, 1, 6, 3, 8, 4, 9]\n assert candidate(servers = [15, 25, 5, 20, 10],tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [2, 4, 0, 3, 1, 2, 4, 0, 3, 1, 2, 4, 0, 3, 1, 2, 4, 0, 3, 1]\n assert candidate(servers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [2, 3, 5, 7, 11],tasks = [30, 10, 20, 40, 50, 15, 25, 35, 45, 55]) == [0, 1, 2, 3, 4, 1, 2, 1, 0, 3]\n assert candidate(servers = [7, 5, 3, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 3, 2, 3, 1, 2, 0, 3, 1, 2, 0, 3, 1, 2, 0]\n assert candidate(servers = [5, 3, 8, 6],tasks = [2, 6, 4, 1, 7, 3, 5]) == [1, 0, 1, 3, 3, 2, 1]\n assert candidate(servers = [3, 2, 1, 4, 5],tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [2, 1, 0, 3, 4, 2, 1, 0, 3, 4, 2, 1, 0, 3, 4]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [5, 3, 8, 6, 2],tasks = [2, 4, 1, 5, 7, 3, 6, 8, 9, 10]) == [4, 1, 4, 4, 0, 1, 3, 2, 4, 1]\n assert candidate(servers = [5, 1, 4, 3, 2, 6],tasks = [2, 1, 2, 4, 5, 2, 1, 3, 5, 7, 9, 11, 13, 15]) == [1, 4, 1, 4, 1, 3, 2, 4, 3, 1, 4, 2, 0, 3]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [7, 1, 1, 1, 1, 1],tasks = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]\n assert candidate(servers = [23, 45, 12, 67, 89, 34, 56, 78, 90, 10],tasks = [30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == [9, 2, 0, 5, 1, 6, 3, 7, 4, 8]\n assert candidate(servers = [100, 200, 300, 400, 500],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [3, 3, 3, 3, 3],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [100, 200, 300, 400, 500],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [3, 3, 3, 3, 3],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [10, 10, 10, 10],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0]\n assert candidate(servers = [100, 200, 300, 400, 500],tasks = [500, 400, 300, 200, 100, 500, 400, 300, 200, 100]) == [0, 1, 2, 3, 4, 4, 3, 2, 1, 0]\n assert candidate(servers = [2, 1, 3, 4],tasks = [4, 3, 2, 1, 5, 6, 7, 8, 9, 10]) == [1, 0, 2, 3, 1, 0, 2, 3, 1, 0]\n assert candidate(servers = [7, 8, 9, 10],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 0, 1, 2, 3, 3, 2]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [5, 5, 5, 5, 5],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [3, 5, 1, 4, 2],tasks = [15, 10, 5, 20, 25, 30, 5, 10, 15, 20]) == [2, 4, 0, 3, 1, 0, 4, 2, 4, 3]\n assert candidate(servers = [7, 8, 9, 10, 11],tasks = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 4]\n assert candidate(servers = [1, 10, 1, 10, 1, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 1, 1, 1, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [5, 10, 15, 20, 25],tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7]\n assert candidate(servers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],tasks = [29, 23, 19, 17, 13, 11, 7, 5, 3, 2]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [3, 2, 1, 4, 5],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [2, 1, 0, 3, 4, 2, 1, 0, 3, 4, 2, 1, 0, 3, 4]\n assert candidate(servers = [5, 3, 8, 6, 2],tasks = [2, 5, 7, 4, 9, 1, 3, 6, 8, 10]) == [4, 1, 4, 0, 3, 2, 1, 0, 2, 4]\n assert candidate(servers = [7, 11, 13, 17, 19, 23, 29],tasks = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == [0, 1, 0, 2, 1, 3, 4, 0, 5, 6, 2, 1, 3, 4, 0, 5, 6, 2, 1, 3]\n assert candidate(servers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [9, 9, 8, 9, 7, 8, 6, 9, 5, 7]\n assert candidate(servers = [1, 2, 3, 4, 5],tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [3, 2, 1],tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [2, 1, 0, 2, 1, 0, 2, 1, 0, 2]\n assert candidate(servers = [10, 20, 15, 25, 30],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 2, 0, 1, 2, 3, 0, 4, 1, 2, 3, 0, 4, 1]\n assert candidate(servers = [5, 3, 8, 6, 2],tasks = [4, 3, 6, 2, 5, 4, 3, 7]) == [4, 1, 0, 3, 4, 1, 3, 2]\n assert candidate(servers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [100, 200, 300, 400, 500],tasks = [500, 400, 300, 200, 100, 500, 400, 300, 200, 100]) == [0, 1, 2, 3, 4, 4, 3, 2, 1, 0]\n assert candidate(servers = [10, 5, 8, 3],tasks = [2, 8, 10, 3, 5, 7, 6, 4]) == [3, 1, 3, 2, 0, 2, 1, 0]\n assert candidate(servers = [5, 3, 7, 1, 4],tasks = [10, 5, 3, 8, 2, 1, 9, 6]) == [3, 1, 4, 0, 2, 4, 1, 4]\n assert candidate(servers = [1, 1, 1, 1, 1],tasks = [2, 3, 2, 4, 5, 2, 3, 1, 4, 5]) == [0, 1, 0, 2, 0, 1, 3, 1, 1, 0]\n assert candidate(servers = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [5, 5, 5, 5, 5],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [7, 7, 7, 7, 7],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [15, 10, 20, 5, 25],tasks = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]) == [3, 1, 0, 3, 2, 4, 1, 0, 3, 2, 4, 1, 0, 3]\n assert candidate(servers = [1, 2, 3, 4, 5],tasks = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 0, 1, 0, 2, 1, 1, 0, 1, 2]\n assert candidate(servers = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [1, 3, 5, 7, 9, 1, 3, 5, 7, 9]\n assert candidate(servers = [2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [1, 3, 2],tasks = [3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1]) == [0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [10, 1, 10, 1, 10, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 3, 1, 5, 3, 0, 1, 2, 5, 4, 3, 0, 1, 2]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [50, 25, 75, 100, 125],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [1, 0, 2, 3, 4, 1, 0, 2, 3, 4, 1, 0, 2, 3, 4]\n assert candidate(servers = [2, 4, 6, 8, 10],tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [0, 0, 1, 2, 0, 3, 4, 1, 2, 0]\n assert candidate(servers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],tasks = [97, 89, 83, 79, 73, 71, 67, 61, 59, 53, 47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 23]\n assert candidate(servers = [1, 1, 1, 1, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n", "comparison": "exact"}, "public_tests": ["[3,3,2]\n[1,2,3,2,1,2]", "[5,1,4,3,2]\n[2,1,2,4,5,2,1]"], "hints": ["You can maintain a Heap of available Servers and a Heap of unavailable servers", "Note that the tasks will be processed in the input order so you just need to find the x-th server that will be available according to the rules"], "metadata": {"canonical_parameter_names": ["servers", "tasks"], "leetcode_dataset_entry_point": "Solution().assignTasks", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:47+00:00", "tests_total": 111, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def assignTasks(self, servers: list[int], tasks: list[int]) -> list[int]:", "container": "Solution", "callable": "assignTasks", "parameters": [{"name": "servers", "type": "list[int]"}, {"name": "tasks", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1883, "task_id": "minimum-skips-to-arrive-at-meeting-on-time", "difficulty": "Hard", "problem_description": "You are given an integer hoursBefore, the number of hours you have to travel to your meeting. To arrive at your meeting, you have to travel through n roads. The road lengths are given as an integer array dist of length n, where dist[i] describes the length of the i^th road in kilometers. In addition, you are given an integer speed, which is the speed (in km/h) you will travel at.\n\nAfter you travel road i, you must rest and wait for the next integer hour before you can begin traveling on the next road. Note that you do not have to rest after traveling the last road because you are already at the meeting.\n\n- For example, if traveling a road takes 1.4 hours, you must wait until the 2 hour mark before traveling the next road. If traveling a road takes exactly 2 hours, you do not need to wait.\n\nHowever, you are allowed to skip some rests to be able to arrive on time, meaning you do not need to wait for the next integer hour. Note that this means you may finish traveling future roads at different hour marks.\n\n- For example, suppose traveling the first road takes 1.4 hours and traveling the second road takes 0.6 hours. Skipping the rest after the first road will mean you finish traveling the second road right at the 2 hour mark, letting you start traveling the third road immediately.\n\nReturn the minimum number of skips required to arrive at the meeting on time, or -1 if it is impossible.\n\nExample 1:\n\nInput: dist = [1,3,2], speed = 4, hoursBefore = 2\nOutput: 1\nExplanation:\nWithout skipping any rests, you will arrive in (1/4 + 3/4) + (3/4 + 1/4) + (2/4) = 2.5 hours.\nYou can skip the first rest to arrive in ((1/4 + 0) + (3/4 + 0)) + (2/4) = 1.5 hours.\nNote that the second rest is shortened because you finish traveling the second road at an integer hour due to skipping the first rest.\n\nExample 2:\n\nInput: dist = [7,3,5,5], speed = 2, hoursBefore = 10\nOutput: 2\nExplanation:\nWithout skipping any rests, you will arrive in (7/2 + 1/2) + (3/2 + 1/2) + (5/2 + 1/2) + (5/2) = 11.5 hours.\nYou can skip the first and third rest to arrive in ((7/2 + 0) + (3/2 + 0)) + ((5/2 + 0) + (5/2)) = 10 hours.\n\nExample 3:\n\nInput: dist = [7,3,5,5], speed = 1, hoursBefore = 10\nOutput: -1\nExplanation: It is impossible to arrive at the meeting on time even if you skip all the rests.\n\nConstraints:\n\n- n == dist.length\n- 1 <= n <= 1000\n- 1 <= dist[i] <= 10^5\n- 1 <= speed <= 10^6\n- 1 <= hoursBefore <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(dist = [10, 10, 10],speed = 5,hoursBefore = 6) == 0\n assert candidate(dist = [1, 1, 1, 1, 1],speed = 1,hoursBefore = 3) == -1\n assert candidate(dist = [5, 5, 5, 5, 5],speed = 10,hoursBefore = 2) == -1\n assert candidate(dist = [1, 1, 1, 1],speed = 1,hoursBefore = 4) == 0\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 10) == 0\n assert candidate(dist = [7, 3, 5, 5],speed = 1,hoursBefore = 10) == -1\n assert candidate(dist = [1, 2, 3, 4, 5],speed = 1,hoursBefore = 20) == 0\n assert candidate(dist = [1, 1, 1, 1, 1],speed = 1,hoursBefore = 4) == -1\n assert candidate(dist = [10, 10, 10],speed = 10,hoursBefore = 3) == 0\n assert candidate(dist = [5, 5, 5, 5, 5],speed = 5,hoursBefore = 5) == 0\n assert candidate(dist = [1, 1, 1, 1],speed = 1,hoursBefore = 3) == -1\n assert candidate(dist = [7, 3, 5, 5],speed = 2,hoursBefore = 10) == 2\n assert candidate(dist = [1, 3, 2],speed = 4,hoursBefore = 2) == 1\n assert candidate(dist = [100000, 100000, 100000],speed = 100000,hoursBefore = 3) == 0\n assert candidate(dist = [10, 10, 10],speed = 5,hoursBefore = 5) == -1\n assert candidate(dist = [5, 5, 5, 5, 5],speed = 10,hoursBefore = 3) == 2\n assert candidate(dist = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],speed = 2,hoursBefore = 15) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],speed = 15,hoursBefore = 15) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 1000,hoursBefore = 5) == -1\n assert candidate(dist = [7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5],speed = 2,hoursBefore = 100) == -1\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],speed = 2,hoursBefore = 10) == -1\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],speed = 10000,hoursBefore = 99) == -1\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],speed = 5,hoursBefore = 20) == 8\n assert candidate(dist = [10, 20, 30, 40, 50],speed = 25,hoursBefore = 10) == 0\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],speed = 5,hoursBefore = 50) == -1\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],speed = 100000,hoursBefore = 9) == -1\n assert candidate(dist = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],speed = 10,hoursBefore = 40) == -1\n assert candidate(dist = [1, 2, 3, 4, 5],speed = 100,hoursBefore = 1) == 4\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 3,hoursBefore = 100) == -1\n assert candidate(dist = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],speed = 100,hoursBefore = 20) == 7\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],speed = 2,hoursBefore = 100) == -1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = 5,hoursBefore = 30) == 0\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],speed = 1,hoursBefore = 50) == -1\n assert candidate(dist = [10, 21, 30, 40, 50, 60, 70, 80, 90, 100],speed = 10,hoursBefore = 55) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = 2,hoursBefore = 50) == -1\n assert candidate(dist = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],speed = 100000,hoursBefore = 9) == -1\n assert candidate(dist = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],speed = 5,hoursBefore = 20) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 5,hoursBefore = 35) == -1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = 15,hoursBefore = 15) == 0\n assert candidate(dist = [100, 200, 300, 400, 500],speed = 100,hoursBefore = 10) == -1\n assert candidate(dist = [123, 456, 789, 101, 202, 303],speed = 100,hoursBefore = 15) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 29) == -1\n assert candidate(dist = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1],speed = 4,hoursBefore = 5) == 6\n assert candidate(dist = [3, 6, 9, 12, 15, 18, 21],speed = 5,hoursBefore = 15) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 3,hoursBefore = 12) == -1\n assert candidate(dist = [5, 10, 15, 20, 25],speed = 5,hoursBefore = 10) == -1\n assert candidate(dist = [9, 8, 7, 6, 5, 4, 3, 2, 1],speed = 3,hoursBefore = 10) == -1\n assert candidate(dist = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],speed = 100,hoursBefore = 9) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 15) == -1\n assert candidate(dist = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],speed = 2,hoursBefore = 30) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = 1,hoursBefore = 105) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 20) == 0\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 19) == -1\n assert candidate(dist = [7, 3, 5, 5, 3, 7, 5, 3, 5, 5, 3, 7, 5, 3, 5, 5, 3, 7, 5, 3, 5, 5, 3, 7, 5, 3, 5, 5, 3, 7, 5, 3, 5, 5],speed = 2,hoursBefore = 50) == -1\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],speed = 10,hoursBefore = 6) == 4\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 100) == -1\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],speed = 2,hoursBefore = 15) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],speed = 100,hoursBefore = 60) == -1\n assert candidate(dist = [7, 3, 5, 5, 7, 3, 5, 5],speed = 2,hoursBefore = 15) == -1\n assert candidate(dist = [100, 200, 300, 400],speed = 100,hoursBefore = 8) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 5,hoursBefore = 12) == 4\n assert candidate(dist = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980],speed = 99999,hoursBefore = 10) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = 3,hoursBefore = 20) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 1,hoursBefore = 1000) == 0\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 25,hoursBefore = 20) == -1\n assert candidate(dist = [9, 7, 5, 3, 1],speed = 4,hoursBefore = 5) == -1\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],speed = 7,hoursBefore = 25) == -1\n assert candidate(dist = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],speed = 10,hoursBefore = 13) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 25) == -1\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35],speed = 7,hoursBefore = 20) == 5\n assert candidate(dist = [10000, 20000, 30000, 40000, 50000],speed = 10000,hoursBefore = 15) == 0\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 15,hoursBefore = 30) == -1\n assert candidate(dist = [3, 8, 2, 7, 5],speed = 4,hoursBefore = 10) == 0\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 100,hoursBefore = 50) == -1\n assert candidate(dist = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],speed = 100000,hoursBefore = 5) == 5\n assert candidate(dist = [9, 8, 7, 6, 5, 4, 3, 2, 1],speed = 5,hoursBefore = 15) == 0\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],speed = 3,hoursBefore = 30) == 0\n assert candidate(dist = [1, 3, 2, 4, 5],speed = 3,hoursBefore = 5) == 3\n assert candidate(dist = [999, 1000, 1001, 1002, 1003],speed = 1,hoursBefore = 5000) == -1\n assert candidate(dist = [100000, 100000, 100000, 100000],speed = 100000,hoursBefore = 4) == 0\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000],speed = 100000,hoursBefore = 4) == -1\n assert candidate(dist = [1000, 2000, 3000, 4000],speed = 1000,hoursBefore = 10) == 0\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000],speed = 100000,hoursBefore = 5) == 0\n assert candidate(dist = [100000, 90000, 80000, 70000, 60000],speed = 50000,hoursBefore = 10) == 0\n assert candidate(dist = [10, 20, 30, 40, 50],speed = 15,hoursBefore = 12) == 0\n assert candidate(dist = [100000, 100000, 100000],speed = 100000,hoursBefore = 2) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 15,hoursBefore = 25) == -1\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],speed = 1,hoursBefore = 100) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 50,hoursBefore = 35) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 100,hoursBefore = 30) == -1\n assert candidate(dist = [5, 10, 15, 20, 25],speed = 5,hoursBefore = 15) == 0\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],speed = 3,hoursBefore = 25) == 0\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 100,hoursBefore = 45) == -1\n assert candidate(dist = [99999, 99998, 99997, 99996],speed = 100000,hoursBefore = 399990) == 0\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 10) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],speed = 5,hoursBefore = 25) == -1\n assert candidate(dist = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],speed = 9,hoursBefore = 8) == -1\n assert candidate(dist = [50, 100, 150, 200, 250],speed = 50,hoursBefore = 10) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 10,hoursBefore = 5) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],speed = 3,hoursBefore = 25) == -1\n assert candidate(dist = [5, 10, 15, 20, 25],speed = 5,hoursBefore = 14) == -1\n assert candidate(dist = [100, 200, 300, 400, 500],speed = 1,hoursBefore = 1500) == 0\n assert candidate(dist = [5, 4, 3, 2, 1],speed = 1,hoursBefore = 15) == 0\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 20) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 2,hoursBefore = 15) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 5,hoursBefore = 10) == -1\n assert candidate(dist = [5, 15, 25, 35, 45],speed = 10,hoursBefore = 12) == -1\n assert candidate(dist = [100, 200, 300, 400, 500],speed = 50,hoursBefore = 25) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 500,hoursBefore = 12) == 4\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],speed = 30,hoursBefore = 35) == -1\n assert candidate(dist = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200],speed = 50,hoursBefore = 20) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 100,hoursBefore = 55) == 0\n assert candidate(dist = [1000, 2000, 3000, 4000, 5000],speed = 1000,hoursBefore = 20) == 0\n assert candidate(dist = [1000, 2000, 3000, 4000, 5000],speed = 1000,hoursBefore = 15) == 0\n", "comparison": "exact"}, "public_tests": ["[1,3,2]\n4\n2", "[7,3,5,5]\n2\n10", "[7,3,5,5]\n1\n10"], "hints": ["Is there something you can keep track of from one road to another?", "How would knowing the start time for each state help us solve the problem?"], "metadata": {"canonical_parameter_names": ["dist", "speed", "hoursBefore"], "leetcode_dataset_entry_point": "Solution().minSkips", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:49+00:00", "tests_total": 114, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def minSkips(self, dist: list[int], speed: int, hoursBefore: int) -> int:", "container": "Solution", "callable": "minSkips", "parameters": [{"name": "dist", "type": "list[int]"}, {"name": "speed", "type": "int"}, {"name": "hoursBefore", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1884, "task_id": "egg-drop-with-2-eggs-and-n-floors", "difficulty": "Medium", "problem_description": "You are given two identical eggs and you have access to a building with n floors labeled from 1 to n.\n\nYou know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor higher than f will break, and any egg dropped at or below floor f will not break.\n\nIn each move, you may take an unbroken egg and drop it from any floor x (where 1 <= x <= n). If the egg breaks, you can no longer use it. However, if the egg does not break, you may reuse it in future moves.\n\nReturn the minimum number of moves that you need to determine with certainty what the value of f is.\n\nExample 1:\n\nInput: n = 2\nOutput: 2\nExplanation: We can drop the first egg from floor 1 and the second egg from floor 2.\nIf the first egg breaks, we know that f = 0.\nIf the second egg breaks but the first egg didn't, we know that f = 1.\nOtherwise, if both eggs survive, we know that f = 2.\n\nExample 2:\n\nInput: n = 100\nOutput: 14\nExplanation: One optimal strategy is:\n- Drop the 1st egg at floor 9. If it breaks, we know f is between 0 and 8. Drop the 2nd egg starting from floor 1 and going up one at a time to find f within 8 more drops. Total drops is 1 + 8 = 9.\n- If the 1st egg does not break, drop the 1st egg again at floor 22. If it breaks, we know f is between 9 and 21. Drop the 2nd egg starting from floor 10 and going up one at a time to find f within 12 more drops. Total drops is 2 + 12 = 14.\n- If the 1st egg does not break again, follow a similar process dropping the 1st egg from floors 34, 45, 55, 64, 72, 79, 85, 90, 94, 97, 99, and 100.\nRegardless of the outcome, it takes at most 14 drops to determine f.\n\nConstraints:\n\n- 1 <= n <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 4\n assert candidate(n = 1000) == 45\n assert candidate(n = 5) == 3\n assert candidate(n = 81) == 13\n assert candidate(n = 999) == 45\n assert candidate(n = 15) == 5\n assert candidate(n = 64) == 11\n assert candidate(n = 450) == 30\n assert candidate(n = 600) == 35\n assert candidate(n = 6) == 3\n assert candidate(n = 2) == 2\n assert candidate(n = 100) == 14\n assert candidate(n = 500) == 32\n assert candidate(n = 50) == 10\n assert candidate(n = 1) == 1\n assert candidate(n = 10) == 4\n assert candidate(n = 300) == 24\n assert candidate(n = 990) == 44\n assert candidate(n = 850) == 41\n assert candidate(n = 125) == 16\n assert candidate(n = 900) == 42\n assert candidate(n = 995) == 45\n assert candidate(n = 505) == 32\n assert candidate(n = 650) == 36\n assert candidate(n = 550) == 33\n assert candidate(n = 460) == 30\n assert candidate(n = 99) == 14\n assert candidate(n = 501) == 32\n assert candidate(n = 250) == 22\n assert candidate(n = 75) == 12\n assert candidate(n = 997) == 45\n assert candidate(n = 925) == 43\n assert candidate(n = 504) == 32\n assert candidate(n = 350) == 26\n assert candidate(n = 503) == 32\n assert candidate(n = 150) == 17\n assert candidate(n = 800) == 40\n assert candidate(n = 200) == 20\n assert candidate(n = 400) == 28\n assert candidate(n = 750) == 39\n assert candidate(n = 502) == 32\n assert candidate(n = 950) == 44\n assert candidate(n = 700) == 37\n assert candidate(n = 366) == 27\n assert candidate(n = 998) == 45\n assert candidate(n = 25) == 7\n", "comparison": "exact"}, "public_tests": ["2", "100"], "hints": ["Is it really optimal to always drop the egg on the middle floor for each move?", "Can we create states based on the number of unbroken eggs and floors to build our solution?"], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().twoEggDrop", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:51+00:00", "tests_total": 46, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def twoEggDrop(self, n: int) -> int:", "container": "Solution", "callable": "twoEggDrop", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1886, "task_id": "determine-whether-matrix-can-be-obtained-by-rotation", "difficulty": "Easy", "problem_description": "Given two n x n binary matrices mat and target, return true if it is possible to make mat equal to target by rotating mat in 90-degree increments, or false otherwise.\n\nExample 1:\n\nInput: mat = [[0,1],[1,0]], target = [[1,0],[0,1]]\nOutput: true\nExplanation: We can rotate mat 90 degrees clockwise to make mat equal target.\n\nExample 2:\n\nInput: mat = [[0,1],[1,1]], target = [[1,0],[0,1]]\nOutput: false\nExplanation: It is impossible to make mat equal to target by rotating mat.\n\nExample 3:\n\nInput: mat = [[0,0,0],[0,1,0],[1,1,1]], target = [[1,1,1],[0,1,0],[0,0,0]]\nOutput: true\nExplanation: We can rotate mat 90 degrees clockwise two times to make mat equal target.\n\nConstraints:\n\n- n == mat.length == target.length\n- n == mat[i].length == target[i].length\n- 1 <= n <= 10\n- mat[i][j] and target[i][j] are either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 0, 0], [0, 1, 0], [0, 0, 1]],target = [[0, 0, 1], [0, 1, 0], [1, 0, 0]]) == True\n assert candidate(mat = [[0, 1], [1, 0]],target = [[1, 0], [0, 1]]) == True\n assert candidate(mat = [[1, 1], [0, 0]],target = [[0, 1], [0, 1]]) == True\n assert candidate(mat = [[1, 0], [0, 1]],target = [[0, 1], [1, 0]]) == True\n assert candidate(mat = [[1, 1, 0], [0, 1, 0], [0, 1, 1]],target = [[0, 0, 1], [0, 1, 0], [1, 1, 0]]) == False\n assert candidate(mat = [[0, 1], [1, 1]],target = [[1, 0], [0, 1]]) == False\n assert candidate(mat = [[0, 0, 0], [0, 1, 0], [1, 1, 1]],target = [[1, 1, 1], [0, 1, 0], [0, 0, 0]]) == True\n assert candidate(mat = [[1, 1, 0], [0, 0, 0], [0, 1, 1]],target = [[0, 0, 0], [0, 1, 1], [1, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 0, 0], [1, 0, 0, 1], [0, 1, 1, 0], [0, 0, 1, 1]],target = [[0, 0, 1, 1], [0, 1, 1, 0], [1, 0, 0, 1], [1, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 1], [0, 0]],target = [[0, 0], [1, 1]]) == True\n assert candidate(mat = [[1, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1]],target = [[1, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1]]) == True\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 0, 0, 1, 1], [1, 0, 0, 1, 1], [0, 1, 1, 0, 0], [0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 1], [0, 1, 1, 0, 0], [0, 1, 1, 0, 0], [1, 0, 0, 1, 1], [1, 1, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 1]],target = [[1, 1, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 0, 1]]) == False\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 0, 0, 0, 1], [1, 0, 0, 1, 0], [1, 0, 1, 0, 0], [1, 1, 0, 0, 0]],target = [[0, 0, 0, 1, 1], [0, 0, 1, 0, 1], [0, 1, 0, 0, 1], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1]]) == False\n assert candidate(mat = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]],target = [[0, 0, 1, 1], [0, 0, 1, 1], [1, 1, 0, 0], [1, 1, 0, 0]]) == True\n assert candidate(mat = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],target = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == True\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1]]) == False\n assert candidate(mat = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]],target = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == True\n assert candidate(mat = [[1, 1, 0, 0], [0, 0, 1, 1], [0, 1, 0, 1], [1, 0, 1, 0]],target = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == False\n assert candidate(mat = [[0, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 1, 0]],target = [[0, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 0]]) == False\n assert candidate(mat = [[0, 1, 1, 0], [1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 0]],target = [[0, 1, 1, 0], [1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 0]]) == True\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],target = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == True\n assert candidate(mat = [[0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1]],target = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],target = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == True\n assert candidate(mat = [[0, 1, 1, 0], [1, 1, 1, 1], [1, 0, 0, 1], [0, 1, 1, 0]],target = [[0, 1, 0, 1], [1, 1, 1, 1], [0, 0, 1, 0], [1, 1, 1, 1]]) == False\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 0, 0, 1], [1, 0, 1, 0], [1, 0, 0, 1], [1, 0, 1, 0]],target = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [0, 1, 1, 0, 1], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0]],target = [[0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 0, 1], [1, 0, 0, 1], [0, 0, 1, 1], [1, 0, 1, 0]],target = [[0, 1, 0, 1], [1, 1, 0, 0], [1, 0, 0, 1], [0, 1, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 1], [1, 0, 1], [1, 1, 1]],target = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == True\n assert candidate(mat = [[0, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [1, 0, 0, 0]],target = [[1, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) == True\n assert candidate(mat = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1], [1, 1, 1, 1]],target = [[1, 1, 1, 1], [1, 1, 1, 0], [1, 1, 0, 0], [1, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 0, 0, 0], [0, 1, 1, 1], [0, 1, 0, 1], [0, 1, 1, 0]],target = [[0, 1, 1, 0], [1, 0, 1, 0], [1, 1, 0, 1], [0, 0, 0, 1]]) == False\n assert candidate(mat = [[0, 1, 0, 0], [1, 1, 1, 0], [0, 1, 1, 1], [0, 0, 0, 1]],target = [[1, 0, 0, 0], [1, 1, 0, 1], [1, 1, 1, 0], [1, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],target = [[1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1]]) == True\n assert candidate(mat = [[0, 0, 1, 1], [0, 1, 0, 0], [1, 0, 0, 1], [1, 1, 0, 0]],target = [[0, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 0, 0, 0], [1, 1, 1, 1]]) == False\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],target = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == True\n assert candidate(mat = [[1, 1, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 1, 1]],target = [[1, 0, 1, 0], [1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 1, 0]]) == False\n assert candidate(mat = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]],target = [[1, 0, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 1], [0, 0, 1], [0, 0, 1]],target = [[1, 1, 1], [1, 0, 0], [1, 0, 0]]) == True\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],target = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],target = [[1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 0, 0, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 0, 0, 0]],target = [[0, 0, 0, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 1, 1]]) == False\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0]]) == False\n assert candidate(mat = [[0, 1, 0, 0], [1, 0, 0, 1], [0, 0, 1, 0], [1, 0, 0, 1]],target = [[1, 0, 0, 1], [0, 0, 1, 0], [1, 0, 0, 1], [0, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],target = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == True\n assert candidate(mat = [[1, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 1]],target = [[0, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 0]]) == True\n assert candidate(mat = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],target = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1]],target = [[0, 0, 0, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0]]) == False\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]],target = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == True\n assert candidate(mat = [[0, 0, 0, 1, 0], [0, 0, 1, 1, 0], [0, 1, 1, 0, 0], [1, 1, 0, 0, 0], [0, 1, 1, 0, 0]],target = [[0, 0, 1, 1, 0], [0, 0, 0, 1, 0], [0, 1, 1, 0, 0], [0, 0, 1, 1, 0], [0, 1, 1, 0, 0]]) == False\n assert candidate(mat = [[0, 1, 1, 0], [1, 1, 1, 1], [0, 0, 1, 0], [1, 1, 1, 1]],target = [[1, 0, 0, 0], [1, 1, 0, 1], [1, 1, 1, 1], [0, 0, 1, 1]]) == False\n assert candidate(mat = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]],target = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == True\n assert candidate(mat = [[0, 0, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 1, 0]],target = [[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1]]) == False\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]]) == False\n assert candidate(mat = [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]],target = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == True\n assert candidate(mat = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],target = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == True\n assert candidate(mat = [[0, 1, 1, 1], [1, 1, 0, 0], [1, 0, 0, 1], [1, 1, 1, 0]],target = [[1, 1, 1, 0], [1, 0, 0, 1], [0, 0, 1, 1], [1, 1, 0, 0]]) == False\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 1, 0]],target = [[0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],target = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 0, 1, 1], [0, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0]],target = [[0, 0, 1, 1], [1, 1, 0, 0], [1, 0, 1, 1], [0, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 0, 1]],target = [[1, 0, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 0, 1]]) == False\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]],target = [[0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == True\n assert candidate(mat = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]],target = [[1, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [1, 0, 0, 0, 1]]) == False\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],target = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == False\n assert candidate(mat = [[0, 1, 1, 0, 0], [1, 0, 1, 0, 1], [1, 1, 0, 1, 1], [0, 0, 1, 0, 0], [1, 0, 1, 0, 1]],target = [[0, 0, 1, 0, 0], [1, 1, 0, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0]]) == False\n assert candidate(mat = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 0], [1, 1, 0, 0]],target = [[0, 0, 1, 0], [0, 1, 1, 0], [1, 1, 0, 0], [0, 0, 1, 0]]) == False\n assert candidate(mat = [[0, 0, 1, 1], [0, 0, 1, 1], [1, 1, 0, 0], [1, 1, 0, 0]],target = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]]) == True\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 1], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [1, 1, 0, 0, 0], [1, 1, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 0, 1], [0, 1, 0], [1, 0, 1]],target = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == True\n assert candidate(mat = [[0, 0, 1], [0, 1, 0], [1, 0, 0]],target = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == True\n assert candidate(mat = [[1, 0, 0, 1, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [1, 0, 0, 1, 0], [1, 1, 0, 0, 1]],target = [[1, 1, 0, 1, 1], [0, 0, 1, 0, 0], [1, 0, 0, 1, 0], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1]]) == False\n assert candidate(mat = [[0, 1, 1, 1], [1, 0, 0, 0], [1, 0, 1, 0], [1, 0, 0, 1]],target = [[1, 0, 0, 1], [0, 1, 0, 1], [0, 0, 0, 1], [1, 1, 1, 0]]) == True\n assert candidate(mat = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]],target = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],target = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == True\n", "comparison": "exact"}, "public_tests": ["[[0,1],[1,0]]\n[[1,0],[0,1]]", "[[0,1],[1,1]]\n[[1,0],[0,1]]", "[[0,0,0],[0,1,0],[1,1,1]]\n[[1,1,1],[0,1,0],[0,0,0]]"], "hints": ["What is the maximum number of rotations you have to check?", "Is there a formula you can use to rotate a matrix 90 degrees?"], "metadata": {"canonical_parameter_names": ["mat", "target"], "leetcode_dataset_entry_point": "Solution().findRotation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:56+00:00", "tests_total": 79, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "matrix"]}, "language": "python", "interface": {"raw_signature": "def findRotation(self, mat: list[list[int]], target: list[list[int]]) -> bool:", "container": "Solution", "callable": "findRotation", "parameters": [{"name": "mat", "type": "list[list[int]]"}, {"name": "target", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1887, "task_id": "reduction-operations-to-make-the-array-elements-equal", "difficulty": "Medium", "problem_description": "Given an integer array nums, your goal is to make all elements in nums equal. To complete one operation, follow these steps:\n\n1. Find the largest value in nums. Let its index be i (0-indexed) and its value be largest. If there are multiple elements with the largest value, pick the smallest i.\n2. Find the next largest value in nums strictly smaller than largest. Let its value be nextLargest.\n3. Reduce nums[i] to nextLargest.\n\nReturn the number of operations to make all elements in nums equal.\n\nExample 1:\n\nInput: nums = [5,1,3]\nOutput: 3\nExplanation: It takes 3 operations to make all elements in nums equal:\n1. largest = 5 at index 0. nextLargest = 3. Reduce nums[0] to 3. nums = [3,1,3].\n2. largest = 3 at index 0. nextLargest = 1. Reduce nums[0] to 1. nums = [1,1,3].\n3. largest = 3 at index 2. nextLargest = 1. Reduce nums[2] to 1. nums = [1,1,1].\n\nExample 2:\n\nInput: nums = [1,1,1]\nOutput: 0\nExplanation: All elements in nums are already equal.\n\nExample 3:\n\nInput: nums = [1,1,2,2,3]\nOutput: 4\nExplanation: It takes 4 operations to make all elements in nums equal:\n1. largest = 3 at index 4. nextLargest = 2. Reduce nums[4] to 2. nums = [1,1,2,2,2].\n2. largest = 2 at index 2. nextLargest = 1. Reduce nums[2] to 1. nums = [1,1,1,2,2].\n3. largest = 2 at index 3. nextLargest = 1. Reduce nums[3] to 1. nums = [1,1,1,1,2].\n4. largest = 2 at index 4. nextLargest = 1. Reduce nums[4] to 1. nums = [1,1,1,1,1].\n\nConstraints:\n\n- 1 <= nums.length <= 5 * 10^4\n- 1 <= nums[i] <= 5 * 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 20\n assert candidate(nums = [4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 5, 2, 4, 3]) == 10\n assert candidate(nums = [1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3]) == 4\n assert candidate(nums = [3, 3, 2, 1, 2, 3, 3, 2, 1]) == 11\n assert candidate(nums = [4, 3, 2, 1, 4, 3, 2, 1]) == 12\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [5, 1, 3]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(nums = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == 18\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 60\n assert candidate(nums = [5, 3, 3, 3, 2, 2, 1, 1, 1, 1]) == 11\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 10\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9]) == 84\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 190\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 26\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 190\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5]) == 40\n assert candidate(nums = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 90\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 20\n assert candidate(nums = [4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 21\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 105\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 40\n assert candidate(nums = [4, 3, 3, 2, 2, 1, 1, 1, 1]) == 9\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991]) == 45\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]) == 32\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 140\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 435\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 50\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 85\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 435\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == 112\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991, 49990, 49989, 49988, 49987, 49986, 49985, 49984, 49983, 49982, 49981]) == 190\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 126\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3]) == 24\n assert candidate(nums = [30000, 20000, 10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1]) == 120\n assert candidate(nums = [5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 43\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 19\n assert candidate(nums = [10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 225\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 32\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4]) == 24\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 5, 5]) == 26\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 300\n assert candidate(nums = [1, 3, 2, 5, 4, 3, 2, 1, 4, 3, 2, 1, 3, 2, 1, 2, 1, 1]) == 23\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5]) == 30\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 174\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 190\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 20\n assert candidate(nums = [5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]) == 24\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 125\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 435\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 90\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 435\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 50\n assert candidate(nums = [1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 71\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 105\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(nums = [25000, 25000, 24999, 24998, 24997, 24996, 24995, 24994, 24993, 24992]) == 44\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 190\n assert candidate(nums = [5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1]) == 40\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 26\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 28\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991]) == 45\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 18\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 90\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 90\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5]) == 41\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 190\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 56\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 50\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]) == 24\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 50\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 25\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 135\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 20\n assert candidate(nums = [1, 3, 2, 3, 1, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 125\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2]) == 30\n assert candidate(nums = [5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1]) == 36\n", "comparison": "exact"}, "public_tests": ["[5,1,3]", "[1,1,1]", "[1,1,2,2,3]"], "hints": ["Sort the array.", "Try to reduce all elements with maximum value to the next maximum value in one operation."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().reductionOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:33:58+00:00", "tests_total": 99, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "sorting"]}, "language": "python", "interface": {"raw_signature": "def reductionOperations(self, nums: list[int]) -> int:", "container": "Solution", "callable": "reductionOperations", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1888, "task_id": "minimum-number-of-flips-to-make-the-binary-string-alternating", "difficulty": "Medium", "problem_description": "You are given a binary string s. You are allowed to perform two types of operations on the string in any sequence:\n\n- Type-1: Remove the character at the start of the string s and append it to the end of the string.\n- Type-2: Pick any character in s and flip its value, i.e., if its value is '0' it becomes '1' and vice-versa.\n\nReturn the minimum number of type-2 operations you need to perform such that s becomes alternating.\n\nThe string is called alternating if no two adjacent characters are equal.\n\n- For example, the strings \"010\" and \"1010\" are alternating, while the string \"0100\" is not.\n\nExample 1:\n\nInput: s = \"111000\"\nOutput: 2\nExplanation: Use the first operation two times to make s = \"100011\".\nThen, use the second operation on the third and sixth elements to make s = \"101010\".\n\nExample 2:\n\nInput: s = \"010\"\nOutput: 0\nExplanation: The string is already alternating.\n\nExample 3:\n\nInput: s = \"1110\"\nOutput: 1\nExplanation: Use the second operation on the second element to make s = \"1010\".\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s[i] is either '0' or '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"100100100\") == 3\n assert candidate(s = \"1111\") == 2\n assert candidate(s = \"110011\") == 3\n assert candidate(s = \"111000111000\") == 4\n assert candidate(s = \"11110000\") == 4\n assert candidate(s = \"1110\") == 1\n assert candidate(s = \"0000\") == 2\n assert candidate(s = \"010101010\") == 0\n assert candidate(s = \"01010\") == 0\n assert candidate(s = \"111000\") == 2\n assert candidate(s = \"111111\") == 3\n assert candidate(s = \"10101\") == 0\n assert candidate(s = \"010\") == 0\n assert candidate(s = \"00001111\") == 4\n assert candidate(s = \"000111\") == 2\n assert candidate(s = \"1001001001\") == 5\n assert candidate(s = \"11111\") == 2\n assert candidate(s = \"000000\") == 3\n assert candidate(s = \"010101\") == 0\n assert candidate(s = \"101010\") == 0\n assert candidate(s = \"00000\") == 2\n assert candidate(s = \"0001\") == 1\n assert candidate(s = \"111000111000111000\") == 6\n assert candidate(s = \"010101010101010101010101010101010101\") == 0\n assert candidate(s = \"0000000000111111111100000000001111111111\") == 20\n assert candidate(s = \"00011111000111110001111100011111\") == 12\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"00000000000000000000000000000000\") == 16\n assert candidate(s = \"0110110110110110110110110110\") == 14\n assert candidate(s = \"1010101010101010101010101\") == 0\n assert candidate(s = \"110100110100\") == 4\n assert candidate(s = \"1100110011001100\") == 8\n assert candidate(s = \"1010101010101010101\") == 0\n assert candidate(s = \"0101001101010011010100110101001101010011010100110101001\") == 12\n assert candidate(s = \"010101010101010101010101\") == 0\n assert candidate(s = \"11101001111010011110100111101001\") == 12\n assert candidate(s = \"00001111000011110000\") == 10\n assert candidate(s = \"000111000111000111\") == 6\n assert candidate(s = \"101010101010101010101010\") == 0\n assert candidate(s = \"11110101010101011111\") == 4\n assert candidate(s = \"0000000011111111000000001111\") == 14\n assert candidate(s = \"1100101010\") == 2\n assert candidate(s = \"101010101010101010101\") == 0\n assert candidate(s = \"1010101010\") == 0\n assert candidate(s = \"1010101010101010101010101010101011\") == 1\n assert candidate(s = \"010101010101010101\") == 0\n assert candidate(s = \"0000000000\") == 5\n assert candidate(s = \"101010101010101010101010101\") == 0\n assert candidate(s = \"1110011100\") == 5\n assert candidate(s = \"1100110011\") == 5\n assert candidate(s = \"111000111000111000111000111000\") == 10\n assert candidate(s = \"0000000000000000\") == 8\n assert candidate(s = \"000111000111000111000111\") == 8\n assert candidate(s = \"11100000111000001110000011100000111000001110000011100000\") == 21\n assert candidate(s = \"0101001101010011010100110101001101010011\") == 10\n assert candidate(s = \"1100110011001100110011001100110011001100\") == 20\n assert candidate(s = \"1010101010101010\") == 0\n assert candidate(s = \"010100010101\") == 1\n assert candidate(s = \"0101010101010101010101\") == 0\n assert candidate(s = \"111000111000111000111000111000111000\") == 12\n assert candidate(s = \"111101111011110111101111011110111101111011110111\") == 23\n assert candidate(s = \"01101010101010101011\") == 3\n assert candidate(s = \"01010101011\") == 0\n assert candidate(s = \"11111000001111100000\") == 8\n assert candidate(s = \"0101010101010101010101010101010101\") == 0\n assert candidate(s = \"000011110000111100001111000011110000\") == 18\n assert candidate(s = \"11001100110011001100110011001100110011001100110011001\") == 25\n assert candidate(s = \"111000011100001110000\") == 9\n assert candidate(s = \"0000111100001111000011110000\") == 14\n assert candidate(s = \"1110001110001110001110\") == 7\n assert candidate(s = \"11110000111100001111\") == 10\n assert candidate(s = \"01010101010101010101010101\") == 0\n assert candidate(s = \"10010010010010010010010010010\") == 12\n assert candidate(s = \"0101001101010011\") == 4\n assert candidate(s = \"1111111100000000111111110000\") == 14\n assert candidate(s = \"1000000000\") == 4\n assert candidate(s = \"11111111111111111111\") == 10\n assert candidate(s = \"000011110000\") == 6\n assert candidate(s = \"0011001100\") == 5\n assert candidate(s = \"1111111111111111\") == 8\n assert candidate(s = \"10101010101010101010101010101010101\") == 0\n assert candidate(s = \"00000000001111111111\") == 10\n assert candidate(s = \"101010101010101010101010101010101\") == 0\n assert candidate(s = \"00000111110000011111\") == 8\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111\") == 26\n assert candidate(s = \"1111100000111110000011111\") == 10\n assert candidate(s = \"111000111000111000111\") == 7\n assert candidate(s = \"11111111110000000000\") == 10\n assert candidate(s = \"11001100110011001100\") == 10\n assert candidate(s = \"11100011100011100011\") == 7\n assert candidate(s = \"01010101010101010101010101010101\") == 0\n assert candidate(s = \"10010010010010010010\") == 9\n assert candidate(s = \"1010101010101010101010101010\") == 0\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\") == 25\n assert candidate(s = \"1001001001001001001001\") == 11\n assert candidate(s = \"0000011111000001111100000\") == 10\n assert candidate(s = \"1111000011110000111100001111000011110000\") == 20\n assert candidate(s = \"111100001111\") == 6\n assert candidate(s = \"11110000111100001111000011110000\") == 16\n assert candidate(s = \"0000000000000000000000000111111111111111111111111\") == 23\n assert candidate(s = \"11001100110011001100110011001100110011001100110011001100110\") == 28\n assert candidate(s = \"101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"000111100011110001111\") == 9\n assert candidate(s = \"11111111111111111111111111111111\") == 16\n assert candidate(s = \"00011111000111110001111100011111000111110001111100011111\") == 21\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"00010110000101100001011000010110\") == 12\n assert candidate(s = \"0101010101010101010101010101\") == 0\n assert candidate(s = \"000111000111000111000111000111\") == 10\n assert candidate(s = \"11010101010101010110\") == 3\n assert candidate(s = \"111111111111111111111111111111111\") == 16\n assert candidate(s = \"0101010101\") == 0\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\") == 25\n assert candidate(s = \"00010001000100010001000\") == 6\n assert candidate(s = \"110011001100110011001100110011001\") == 15\n assert candidate(s = \"00110011001100110011\") == 10\n assert candidate(s = \"0111011101\") == 2\n assert candidate(s = \"010101010101010101010101010101010\") == 0\n assert candidate(s = \"00000000000000000000\") == 10\n assert candidate(s = \"1111000011110000\") == 8\n assert candidate(s = \"0101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"10101010101010101010101010101010\") == 0\n assert candidate(s = \"010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"1111100000\") == 4\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111111111111111\") == 33\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000\") == 26\n assert candidate(s = \"010101010101010101010\") == 0\n assert candidate(s = \"1111111111111111111111111000000000000000000000000\") == 23\n assert candidate(s = \"1010101010101010101010\") == 0\n assert candidate(s = \"1111111111\") == 5\n assert candidate(s = \"1111000011110000111100001111\") == 14\n assert candidate(s = \"00000000000000000000000000000\") == 14\n assert candidate(s = \"00011100011100011100\") == 7\n assert candidate(s = \"01010101010101010101\") == 0\n assert candidate(s = \"000000000000000000000000000000000\") == 16\n assert candidate(s = \"010101010101010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"11100000111000001110000011100000\") == 12\n assert candidate(s = \"101010101010101010101010101010101010\") == 0\n assert candidate(s = \"10101010100\") == 0\n assert candidate(s = \"11111111000000001111\") == 10\n assert candidate(s = \"01101101101101101101\") == 9\n assert candidate(s = \"10101010101010101010\") == 0\n assert candidate(s = \"00000000111111110000\") == 10\n assert candidate(s = \"11000011110000111100\") == 10\n assert candidate(s = \"11111111111111111111111111\") == 13\n assert candidate(s = \"111000111000111000111000\") == 8\n assert candidate(s = \"010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"10111011101110111011\") == 5\n assert candidate(s = \"001100110011\") == 6\n assert candidate(s = \"0000111100001111\") == 8\n", "comparison": "exact"}, "public_tests": ["\"111000\"", "\"010\"", "\"1110\""], "hints": ["Note what actually matters is how many 0s and 1s are in odd and even positions", "For every cyclic shift we need to count how many 0s and 1s are at each parity and convert the minimum between them for each parity"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minFlips", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:00+00:00", "tests_total": 153, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def minFlips(self, s: str) -> int:", "container": "Solution", "callable": "minFlips", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1889, "task_id": "minimum-space-wasted-from-packaging", "difficulty": "Hard", "problem_description": "You have n packages that you are trying to place in boxes, one package in each box. There are m suppliers that each produce boxes of different sizes (with infinite supply). A package can be placed in a box if the size of the package is less than or equal to the size of the box.\n\nThe package sizes are given as an integer array packages, where packages[i] is the size of the i^th package. The suppliers are given as a 2D integer array boxes, where boxes[j] is an array of box sizes that the j^th supplier produces.\n\nYou want to choose a single supplier and use boxes from them such that the total wasted space is minimized. For each package in a box, we define the space wasted to be size of the box - size of the package. The total wasted space is the sum of the space wasted in all the boxes.\n\n- For example, if you have to fit packages with sizes [2,3,5] and the supplier offers boxes of sizes [4,8], you can fit the packages of size-2 and size-3 into two boxes of size-4 and the package with size-5 into a box of size-8. This would result in a waste of (4-2) + (4-3) + (8-5) = 6.\n\nReturn the minimum total wasted space by choosing the box supplier optimally, or -1 if it is impossible to fit all the packages inside boxes. Since the answer may be large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: packages = [2,3,5], boxes = [[4,8],[2,8]]\nOutput: 6\nExplanation: It is optimal to choose the first supplier, using two size-4 boxes and one size-8 box.\nThe total waste is (4-2) + (4-3) + (8-5) = 6.\n\nExample 2:\n\nInput: packages = [2,3,5], boxes = [[1,4],[2,3],[3,4]]\nOutput: -1\nExplanation: There is no box that the package of size 5 can fit in.\n\nExample 3:\n\nInput: packages = [3,5,8,10,11,12], boxes = [[12],[11,9],[10,5,14]]\nOutput: 9\nExplanation: It is optimal to choose the third supplier, using two size-5 boxes, two size-10 boxes, and two size-14 boxes.\nThe total waste is (5-3) + (5-5) + (10-8) + (10-10) + (14-11) + (14-12) = 9.\n\nConstraints:\n\n- n == packages.length\n- m == boxes.length\n- 1 <= n <= 10^5\n- 1 <= m <= 10^5\n- 1 <= packages[i] <= 10^5\n- 1 <= boxes[j].length <= 10^5\n- 1 <= boxes[j][k] <= 10^5\n- sum(boxes[j].length) <= 10^5\n- The elements in boxes[j] are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(packages = [10, 20, 30],boxes = [[10], [20], [30], [40]]) == 30\n assert candidate(packages = [100000],boxes = [[100000]]) == 0\n assert candidate(packages = [10, 20, 30],boxes = [[10, 20, 30], [15, 25, 35]]) == 0\n assert candidate(packages = [1, 100000],boxes = [[1], [100000]]) == 99999\n assert candidate(packages = [2, 3, 5],boxes = [[4, 8], [2, 8]]) == 6\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 45\n assert candidate(packages = [3, 5, 8, 10, 11, 12],boxes = [[12], [11, 9], [10, 5, 14]]) == 9\n assert candidate(packages = [1, 2, 3, 4, 5],boxes = [[5, 5, 5, 5, 5]]) == 10\n assert candidate(packages = [1, 3, 5, 7, 9],boxes = [[2, 4, 6, 8, 10]]) == 5\n assert candidate(packages = [5, 5, 5, 5],boxes = [[5, 5, 5, 5]]) == 0\n assert candidate(packages = [2, 3, 5],boxes = [[1, 4], [2, 3], [3, 4]]) == -1\n assert candidate(packages = [10000, 20000, 30000, 40000, 50000],boxes = [[20000, 30000, 50000], [10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 15, 25, 35, 45]]) == 0\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 5, 9, 13, 17], [3, 7, 11, 15, 19]]) == 10\n assert candidate(packages = [50000, 50000, 50000, 50000, 50000],boxes = [[50000, 50000], [100000], [25000, 75000]]) == 0\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [5, 10, 15, 20, 25, 30]]) == 10\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]]) == 0\n assert candidate(packages = [99999, 99998, 99997, 99996, 99995],boxes = [[100000], [99999], [99998], [99997], [99996], [99995]]) == 10\n assert candidate(packages = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],boxes = [[4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22], [3, 7, 11, 15, 19, 23, 27, 31]]) == 9\n assert candidate(packages = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900],boxes = [[500, 600, 700, 800, 900, 1000], [900, 1000, 1100, 1200, 1300, 1400, 1500], [100, 200, 300, 400, 500, 600, 700, 800, 900]]) == 99\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],boxes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]]) == 0\n assert candidate(packages = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],boxes = [[3, 6, 9, 12, 15, 18, 21], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]]) == 10\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30], [1, 5, 9, 13, 17, 21, 25, 29]]) == 14\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 0\n assert candidate(packages = [5, 10, 15, 20, 25],boxes = [[5, 10, 15, 20, 25], [1, 2, 3, 4, 5], [26, 27, 28, 29, 30]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]]) == 0\n assert candidate(packages = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],boxes = [[5, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60]]) == 145\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1], [2], [3, 4, 5]]) == 0\n assert candidate(packages = [100000, 90000, 80000, 70000, 60000],boxes = [[95000, 100000], [85000, 90000, 95000], [75000, 80000, 85000], [65000, 70000, 75000, 80000]]) == 80000\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 11, 12], [9, 8, 7, 6, 5, 4, 3, 2, 1], [15, 20, 25, 30, 35]]) == 45\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1], [2], [1, 2, 3, 4, 5]]) == 0\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1], [2], [3]]) == 0\n assert candidate(packages = [100000],boxes = [[99999, 99998, 99997, 99996, 99995]]) == -1\n assert candidate(packages = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[5, 10, 15], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]) == 0\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1, 2, 3, 4, 5], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15]]) == 0\n assert candidate(packages = [25000, 50000, 75000, 100000],boxes = [[12500, 37500, 62500, 87500], [10000, 40000, 70000, 100000], [50000, 50000, 50000, 50000]]) == 60000\n assert candidate(packages = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],boxes = [[100], [200], [300], [400], [500], [600], [700], [800], [900], [1000]]) == 4500\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]]) == 0\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1], [2], [3]]) == 0\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],boxes = [[1, 3, 5, 7, 9, 11, 13, 15], [2, 4, 6, 8, 10, 12, 14], [16]]) == 7\n assert candidate(packages = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950],boxes = [[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], [50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]]) == 0\n assert candidate(packages = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10], [9, 10], [8, 9, 10], [7, 8, 9, 10], [6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10]]) == 10\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[1, 2, 3, 4, 5], [101, 102, 103, 104, 105], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]]) == 0\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 0\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[15, 25, 35, 45, 55, 65, 75, 85, 95, 105], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]]) == 0\n assert candidate(packages = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]]) == 0\n assert candidate(packages = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],boxes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [3, 6, 9, 12, 15, 18], [4, 8, 12, 16, 20]]) == 0\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120], [50, 60, 70, 80, 90, 100, 110, 120, 130, 140]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(packages = [1, 10, 100, 1000, 10000],boxes = [[5, 50, 500, 5000, 50000], [1, 2, 3, 4, 5], [9999, 99999]]) == 44444\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [10, 30, 50, 70, 90, 110], [20, 40, 60, 80, 100, 120]]) == 50\n assert candidate(packages = [1, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]]) == 14\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],boxes = [[1, 3, 5, 7, 9, 11, 13, 15], [2, 4, 6, 8, 10, 12, 14], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 0\n assert candidate(packages = [50000, 50000, 50000, 50000, 50000],boxes = [[49999], [50000], [50001]]) == 0\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [50, 50, 50, 50, 50, 50, 50, 50, 50, 50], [100, 100, 100, 100, 100, 100, 100, 100, 100, 100], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 450\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],boxes = [[20, 40], [10, 30], [5, 15, 25, 35]]) == 90\n assert candidate(packages = [50000, 40000, 30000, 20000, 10000],boxes = [[10000, 20000, 30000, 40000, 50000], [15000, 25000, 35000, 45000, 55000], [55000]]) == 0\n assert candidate(packages = [50, 60, 70, 80, 90, 100],boxes = [[40, 90], [50, 60, 100], [80, 95, 110]]) == 60\n assert candidate(packages = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],boxes = [[100], [256, 512, 1024], [2, 4, 8, 16, 32, 64, 128]]) == 1793\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 10, 10], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 5\n assert candidate(packages = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],boxes = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]]) == 0\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(packages = [10, 20, 30, 40, 50],boxes = [[5, 15, 25, 35, 45], [6, 16, 26, 36, 46], [7, 17, 27, 37, 47]]) == -1\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],boxes = [[1, 5, 9, 13, 17], [3, 7, 11, 15, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 10\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(packages = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]]) == 0\n assert candidate(packages = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40], [1, 9, 17, 25, 33], [5, 10, 15, 20, 25, 30, 35]]) == 10\n assert candidate(packages = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]]) == 25\n assert candidate(packages = [10000, 20000, 30000, 40000, 50000],boxes = [[5000, 15000, 25000, 35000, 45000, 55000], [10000, 20000, 30000, 40000, 50000]]) == 0\n assert candidate(packages = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],boxes = [[500, 600, 700, 800, 900, 1000], [900, 1000, 1100, 1200, 1300, 1400, 1500]]) == 1000\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[2, 3, 5, 7, 11], [1, 4, 9], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 9\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 20, 30], [5, 10, 15, 20, 25, 30], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 5\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == -1\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 10, 15, 20, 25], [3, 6, 9, 12, 15]]) == 0\n assert candidate(packages = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],boxes = [[1000, 2000], [500, 1500], [300, 700, 1100]]) == 1500\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],boxes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 0\n assert candidate(packages = [50000, 50000, 50000, 50000, 50000],boxes = [[50000], [50001], [50002], [50003], [50004]]) == 0\n assert candidate(packages = [1000, 2000, 3000, 4000, 5000],boxes = [[1000, 2000, 3000, 4000, 5000], [1500, 2500, 3500, 4500, 5500], [900, 1900, 2900, 3900, 4900]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 20], [5, 15], [3, 7, 12]]) == 18\n", "comparison": "exact"}, "public_tests": ["[2,3,5]\n[[4,8],[2,8]]", "[2,3,5]\n[[1,4],[2,3],[3,4]]", "[3,5,8,10,11,12]\n[[12],[11,9],[10,5,14]]"], "hints": ["Given a fixed size box, is there a way to quickly query which packages (i.e., count and sizes) should end up in that box size?", "Do we have to order the boxes a certain way to allow us to answer the query quickly?"], "metadata": {"canonical_parameter_names": ["packages", "boxes"], "leetcode_dataset_entry_point": "Solution().minWastedSpace", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:03+00:00", "tests_total": 93, "tests_dropped": 9, "flags": [], "topic_tags": ["array", "binary-search", "sorting", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minWastedSpace(self, packages: list[int], boxes: list[list[int]]) -> int:", "container": "Solution", "callable": "minWastedSpace", "parameters": [{"name": "packages", "type": "list[int]"}, {"name": "boxes", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1893, "task_id": "check-if-all-the-integers-in-a-range-are-covered", "difficulty": "Easy", "problem_description": "You are given a 2D integer array ranges and two integers left and right. Each ranges[i] = [start_i, end_i] represents an inclusive interval between start_i and end_i.\n\nReturn true if each integer in the inclusive range [left, right] is covered by at least one interval in ranges. Return false otherwise.\n\nAn integer x is covered by an interval ranges[i] = [start_i, end_i] if start_i <= x <= end_i.\n\nExample 1:\n\nInput: ranges = [[1,2],[3,4],[5,6]], left = 2, right = 5\nOutput: true\nExplanation: Every integer between 2 and 5 is covered:\n- 2 is covered by the first range.\n- 3 and 4 are covered by the second range.\n- 5 is covered by the third range.\n\nExample 2:\n\nInput: ranges = [[1,10],[10,20]], left = 21, right = 21\nOutput: false\nExplanation: 21 is not covered by any range.\n\nConstraints:\n\n- 1 <= ranges.length <= 50\n- 1 <= start_i <= end_i <= 50\n- 1 <= left <= right <= 50\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(ranges = [[5, 7], [1, 3]],left = 1,right = 7) == False\n assert candidate(ranges = [[5, 10], [15, 20]],left = 10,right = 15) == False\n assert candidate(ranges = [[1, 1], [2, 2], [3, 3]],left = 1,right = 3) == True\n assert candidate(ranges = [[1, 3], [3, 5], [5, 7]],left = 3,right = 5) == True\n assert candidate(ranges = [[10, 20], [21, 30]],left = 15,right = 25) == True\n assert candidate(ranges = [[1, 3], [5, 7]],left = 2,right = 6) == False\n assert candidate(ranges = [[1, 3], [5, 7], [9, 11]],left = 4,right = 6) == False\n assert candidate(ranges = [[5, 10], [15, 20]],left = 8,right = 12) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6]],left = 2,right = 5) == True\n assert candidate(ranges = [[1, 2], [4, 5]],left = 3,right = 4) == False\n assert candidate(ranges = [[1, 10], [10, 20]],left = 21,right = 21) == False\n assert candidate(ranges = [[1, 5], [6, 10]],left = 1,right = 10) == True\n assert candidate(ranges = [[1, 50]],left = 1,right = 50) == True\n assert candidate(ranges = [[5, 10], [10, 15]],left = 10,right = 10) == True\n assert candidate(ranges = [[5, 10], [11, 16], [17, 22], [23, 28]],left = 8,right = 25) == True\n assert candidate(ranges = [[3, 6], [7, 10], [11, 14], [15, 18]],left = 5,right = 17) == True\n assert candidate(ranges = [[1, 10], [15, 25], [30, 40]],left = 11,right = 14) == False\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],left = 5,right = 25) == True\n assert candidate(ranges = [[5, 15], [10, 20], [25, 35]],left = 7,right = 28) == False\n assert candidate(ranges = [[1, 2], [3, 5], [6, 8], [9, 11], [12, 14]],left = 1,right = 14) == True\n assert candidate(ranges = [[2, 5], [6, 9], [10, 15], [16, 20]],left = 3,right = 19) == True\n assert candidate(ranges = [[1, 3], [6, 8], [11, 13], [16, 18]],left = 5,right = 17) == False\n assert candidate(ranges = [[2, 6], [8, 12], [14, 18], [20, 24], [26, 30]],left = 3,right = 28) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],left = 1,right = 12) == True\n assert candidate(ranges = [[5, 5], [10, 10], [15, 15], [20, 20]],left = 5,right = 20) == False\n assert candidate(ranges = [[1, 50]],left = 1,right = 50) == True\n assert candidate(ranges = [[10, 20], [5, 15], [25, 35]],left = 12,right = 28) == False\n assert candidate(ranges = [[5, 7], [8, 10], [15, 20], [25, 30]],left = 7,right = 27) == False\n assert candidate(ranges = [[1, 4], [6, 9], [11, 14], [16, 19], [21, 24], [26, 29]],left = 1,right = 29) == False\n assert candidate(ranges = [[3, 6], [8, 11], [13, 16]],left = 4,right = 15) == False\n assert candidate(ranges = [[10, 15], [16, 20], [21, 25], [26, 30]],left = 12,right = 28) == True\n assert candidate(ranges = [[1, 5], [5, 10], [10, 15], [15, 20]],left = 6,right = 14) == True\n assert candidate(ranges = [[5, 8], [10, 13], [15, 18], [20, 23], [25, 28], [30, 33]],left = 3,right = 31) == False\n assert candidate(ranges = [[5, 10], [15, 25], [30, 35]],left = 25,right = 30) == False\n assert candidate(ranges = [[1, 20], [21, 40], [41, 50]],left = 1,right = 50) == True\n assert candidate(ranges = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],left = 1,right = 10) == True\n assert candidate(ranges = [[3, 7], [9, 13], [15, 19], [21, 25], [27, 31]],left = 6,right = 30) == False\n assert candidate(ranges = [[10, 15], [15, 20], [20, 25]],left = 12,right = 23) == True\n assert candidate(ranges = [[5, 5], [6, 6], [7, 7], [8, 8]],left = 5,right = 8) == True\n assert candidate(ranges = [[5, 8], [10, 15], [18, 23], [25, 30]],left = 8,right = 27) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],left = 1,right = 8) == True\n assert candidate(ranges = [[1, 2], [4, 6], [8, 10], [12, 14]],left = 3,right = 13) == False\n assert candidate(ranges = [[1, 3], [4, 6], [7, 9], [10, 12]],left = 1,right = 12) == True\n assert candidate(ranges = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],left = 1,right = 5) == True\n assert candidate(ranges = [[3, 7], [10, 14], [17, 21]],left = 5,right = 19) == False\n assert candidate(ranges = [[1, 2], [4, 8], [10, 15], [16, 20], [22, 25]],left = 1,right = 25) == False\n assert candidate(ranges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],left = 2,right = 5) == True\n assert candidate(ranges = [[2, 5], [7, 10], [12, 15], [17, 20], [22, 25], [27, 30]],left = 4,right = 29) == False\n assert candidate(ranges = [[2, 4], [5, 7], [8, 10], [11, 13]],left = 2,right = 13) == True\n assert candidate(ranges = [[1, 2], [4, 5], [7, 8], [10, 11]],left = 3,right = 9) == False\n assert candidate(ranges = [[10, 20], [21, 30], [31, 40], [41, 50]],left = 15,right = 45) == True\n assert candidate(ranges = [[10, 12], [15, 17], [20, 22]],left = 10,right = 22) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],left = 1,right = 10) == True\n assert candidate(ranges = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15]],left = 1,right = 15) == True\n assert candidate(ranges = [[5, 7], [7, 9], [9, 11], [11, 13]],left = 6,right = 12) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30]],left = 12,right = 17) == False\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30]],left = 1,right = 30) == True\n assert candidate(ranges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],left = 1,right = 6) == True\n assert candidate(ranges = [[3, 6], [8, 12], [15, 20], [22, 25], [27, 30]],left = 5,right = 28) == False\n assert candidate(ranges = [[5, 8], [10, 12], [15, 18]],left = 6,right = 17) == False\n assert candidate(ranges = [[1, 10], [12, 20], [22, 30]],left = 5,right = 25) == False\n assert candidate(ranges = [[5, 10], [12, 15], [16, 20], [22, 25]],left = 11,right = 21) == False\n assert candidate(ranges = [[1, 10], [15, 25], [30, 40]],left = 5,right = 35) == False\n assert candidate(ranges = [[1, 5], [10, 15], [20, 25], [30, 35]],left = 5,right = 30) == False\n assert candidate(ranges = [[3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13]],left = 3,right = 13) == False\n assert candidate(ranges = [[1, 10], [11, 20], [21, 30], [31, 40]],left = 5,right = 35) == True\n assert candidate(ranges = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],left = 25,right = 45) == True\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20]],left = 3,right = 19) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30], [35, 40]],left = 2,right = 38) == False\n assert candidate(ranges = [[2, 4], [6, 8], [10, 12], [14, 16], [18, 20], [22, 24]],left = 1,right = 24) == False\n assert candidate(ranges = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23]],left = 1,right = 23) == False\n assert candidate(ranges = [[2, 4], [5, 7], [8, 10], [11, 13], [14, 16]],left = 3,right = 15) == True\n assert candidate(ranges = [[2, 4], [5, 8], [9, 11], [12, 15], [16, 18], [19, 22]],left = 2,right = 22) == True\n assert candidate(ranges = [[2, 4], [6, 8], [10, 12], [14, 16], [18, 20]],left = 3,right = 19) == False\n assert candidate(ranges = [[10, 20], [20, 30], [30, 40]],left = 5,right = 45) == False\n assert candidate(ranges = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14], [16, 17], [19, 20]],left = 1,right = 20) == False\n assert candidate(ranges = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],left = 25,right = 45) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30]],left = 3,right = 28) == False\n assert candidate(ranges = [[3, 7], [8, 12], [13, 17], [18, 22]],left = 5,right = 20) == True\n assert candidate(ranges = [[1, 10], [20, 30], [40, 50]],left = 15,right = 35) == False\n assert candidate(ranges = [[1, 2], [4, 5], [7, 8], [10, 11]],left = 1,right = 11) == False\n assert candidate(ranges = [[2, 4], [7, 9], [12, 14], [17, 19]],left = 4,right = 19) == False\n assert candidate(ranges = [[1, 2], [2, 3], [3, 4], [4, 5]],left = 1,right = 5) == True\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],left = 1,right = 25) == True\n assert candidate(ranges = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],left = 5,right = 45) == True\n assert candidate(ranges = [[1, 3], [4, 7], [8, 10], [11, 15], [16, 20]],left = 5,right = 15) == True\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],left = 1,right = 10) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30], [35, 40]],left = 25,right = 35) == False\n assert candidate(ranges = [[5, 10], [11, 20], [21, 30]],left = 7,right = 29) == True\n assert candidate(ranges = [[1, 25], [26, 50]],left = 1,right = 50) == True\n assert candidate(ranges = [[3, 5], [8, 10], [13, 15], [18, 20]],left = 1,right = 20) == False\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30]],left = 1,right = 30) == False\n assert candidate(ranges = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15]],left = 2,right = 14) == True\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],left = 5,right = 10) == True\n assert candidate(ranges = [[2, 5], [6, 9], [10, 14]],left = 3,right = 13) == True\n assert candidate(ranges = [[1, 10], [15, 25], [30, 40]],left = 5,right = 20) == False\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20]],left = 1,right = 20) == True\n assert candidate(ranges = [[1, 3], [4, 6], [7, 9]],left = 1,right = 9) == True\n assert candidate(ranges = [[2, 4], [6, 8], [10, 12], [14, 16], [18, 20]],left = 1,right = 20) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],left = 2,right = 9) == True\n assert candidate(ranges = [[2, 5], [7, 10], [12, 15], [17, 20]],left = 3,right = 18) == False\n assert candidate(ranges = [[5, 9], [10, 14], [15, 19], [20, 24]],left = 8,right = 22) == True\n assert candidate(ranges = [[1, 4], [5, 8], [9, 12], [13, 16]],left = 3,right = 15) == True\n assert candidate(ranges = [[1, 10], [10, 20], [20, 30], [30, 40]],left = 1,right = 40) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30], [35, 40]],left = 10,right = 35) == False\n", "comparison": "exact"}, "public_tests": ["[[1,2],[3,4],[5,6]]\n2\n5", "[[1,10],[10,20]]\n21\n21"], "hints": ["Iterate over every integer point in the range [left, right].", "For each of these points check if it is included in one of the ranges."], "metadata": {"canonical_parameter_names": ["ranges", "left", "right"], "leetcode_dataset_entry_point": "Solution().isCovered", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:08+00:00", "tests_total": 105, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def isCovered(self, ranges: list[list[int]], left: int, right: int) -> bool:", "container": "Solution", "callable": "isCovered", "parameters": [{"name": "ranges", "type": "list[list[int]]"}, {"name": "left", "type": "int"}, {"name": "right", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1894, "task_id": "find-the-student-that-will-replace-the-chalk", "difficulty": "Medium", "problem_description": "There are n students in a class numbered from 0 to n - 1. The teacher will give each student a problem starting with the student number 0, then the student number 1, and so on until the teacher reaches the student number n - 1. After that, the teacher will restart the process, starting with the student number 0 again.\n\nYou are given a 0-indexed integer array chalk and an integer k. There are initially k pieces of chalk. When the student number i is given a problem to solve, they will use chalk[i] pieces of chalk to solve that problem. However, if the current number of chalk pieces is strictly less than chalk[i], then the student number i will be asked to replace the chalk.\n\nReturn the index of the student that will replace the chalk pieces.\n\nExample 1:\n\nInput: chalk = [5,1,5], k = 22\nOutput: 0\nExplanation: The students go in turns as follows:\n- Student number 0 uses 5 chalk, so k = 17.\n- Student number 1 uses 1 chalk, so k = 16.\n- Student number 2 uses 5 chalk, so k = 11.\n- Student number 0 uses 5 chalk, so k = 6.\n- Student number 1 uses 1 chalk, so k = 5.\n- Student number 2 uses 5 chalk, so k = 0.\nStudent number 0 does not have enough chalk, so they will have to replace it.\n\nExample 2:\n\nInput: chalk = [3,4,1,2], k = 25\nOutput: 1\nExplanation: The students go in turns as follows:\n- Student number 0 uses 3 chalk so k = 22.\n- Student number 1 uses 4 chalk so k = 18.\n- Student number 2 uses 1 chalk so k = 17.\n- Student number 3 uses 2 chalk so k = 15.\n- Student number 0 uses 3 chalk so k = 12.\n- Student number 1 uses 4 chalk so k = 8.\n- Student number 2 uses 1 chalk so k = 7.\n- Student number 3 uses 2 chalk so k = 5.\n- Student number 0 uses 3 chalk so k = 2.\nStudent number 1 does not have enough chalk, so they will have to replace it.\n\nConstraints:\n\n- chalk.length == n\n- 1 <= n <= 10^5\n- 1 <= chalk[i] <= 10^5\n- 1 <= k <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(chalk = [1, 2, 3, 4, 5],k = 15) == 0\n assert candidate(chalk = [1],k = 1000000000) == 0\n assert candidate(chalk = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 999999999) == 9\n assert candidate(chalk = [10, 10, 10],k = 100) == 1\n assert candidate(chalk = [100000],k = 1000000000) == 0\n assert candidate(chalk = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1000000000) == 0\n assert candidate(chalk = [3, 4, 1, 2],k = 25) == 1\n assert candidate(chalk = [5, 1, 5],k = 22) == 0\n assert candidate(chalk = [5, 1, 5],k = 1000000000) == 2\n assert candidate(chalk = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],k = 1000000000) == 6\n assert candidate(chalk = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 123456789) == 1\n assert candidate(chalk = [5, 8, 12, 3, 7],k = 500000000) == 1\n assert candidate(chalk = [7, 3, 2, 8, 6, 4],k = 987654321) == 4\n assert candidate(chalk = [1, 10, 100, 1000, 10000, 100000],k = 123456789) == 5\n assert candidate(chalk = [2, 3, 4, 5, 6, 7, 8, 9, 10],k = 100000000) == 8\n assert candidate(chalk = [10, 20, 30, 40, 50],k = 123456789) == 2\n assert candidate(chalk = [100, 200, 300, 400, 500],k = 999999999) == 3\n assert candidate(chalk = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 123456789) == 9\n assert candidate(chalk = [5, 1, 5, 2, 8],k = 1000000000) == 4\n assert candidate(chalk = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1000000000) == 9\n assert candidate(chalk = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 999999998) == 1\n assert candidate(chalk = [7, 14, 21, 28, 35],k = 123456789) == 4\n assert candidate(chalk = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 999999997) == 2\n assert candidate(chalk = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31],k = 1000000000) == 0\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 543210) == 7\n assert candidate(chalk = [5, 1, 5, 2, 6],k = 1000000000) == 4\n assert candidate(chalk = [5, 8, 3, 7, 2],k = 500000000) == 0\n assert candidate(chalk = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 8675309) == 6\n assert candidate(chalk = [5, 3, 7, 11],k = 50) == 3\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 897654321) == 12\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 500000000) == 2\n assert candidate(chalk = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 900000000) == 5\n assert candidate(chalk = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1000000000) == 5\n assert candidate(chalk = [10, 20, 30, 40, 50],k = 999999999) == 3\n assert candidate(chalk = [100000, 100000, 100000, 100000, 100000],k = 950000000) == 0\n assert candidate(chalk = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 999999999) == 9\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1000000000) == 8\n assert candidate(chalk = [2, 4, 6, 8, 10],k = 999999999) == 2\n assert candidate(chalk = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 987654321) == 1\n assert candidate(chalk = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 999999999) == 7\n assert candidate(chalk = [5, 8, 12, 3, 6],k = 1000000000) == 2\n assert candidate(chalk = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 800000000) == 8\n assert candidate(chalk = [99999, 99998, 99997, 99996, 99995],k = 1000000000) == 0\n assert candidate(chalk = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 987654321) == 2\n assert candidate(chalk = [1, 10, 100, 1000, 10000, 100000],k = 999999999) == 3\n assert candidate(chalk = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],k = 123456789) == 8\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 987654321) == 18\n assert candidate(chalk = [100, 200, 300, 400, 500],k = 1000000000) == 4\n assert candidate(chalk = [12345, 67890, 13579, 24680, 97531],k = 987654321) == 4\n assert candidate(chalk = [50000, 50000, 50000, 50000, 50000],k = 1000000000) == 0\n assert candidate(chalk = [3, 6, 1, 8, 4, 7],k = 999999999) == 3\n assert candidate(chalk = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100000000) == 9\n assert candidate(chalk = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 543210987) == 8\n assert candidate(chalk = [10, 15, 20, 25, 30],k = 123456789) == 4\n assert candidate(chalk = [3, 4, 1, 2, 5, 7, 8, 9, 10, 11],k = 987654321) == 5\n assert candidate(chalk = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 500000000) == 0\n assert candidate(chalk = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 456789123) == 7\n assert candidate(chalk = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 999999999) == 8\n assert candidate(chalk = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 1000000000) == 2\n assert candidate(chalk = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 1000000000) == 0\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 876543210) == 12\n assert candidate(chalk = [100000, 100000, 100000, 100000, 100000],k = 999999999) == 4\n assert candidate(chalk = [5000, 10000, 15000, 20000, 25000],k = 500000000) == 4\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 500000000) == 2\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 123456789) == 11\n assert candidate(chalk = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995, 5],k = 1000000000) == 0\n", "comparison": "exact"}, "public_tests": ["[5,1,5]\n22", "[3,4,1,2]\n25"], "hints": ["Subtract the sum of chalk from k until k is less than the sum of chalk.", "Now iterate over the array. If chalk[i] is less than k, this is the answer. Otherwise, subtract chalk[i] from k and continue."], "metadata": {"canonical_parameter_names": ["chalk", "k"], "leetcode_dataset_entry_point": "Solution().chalkReplacer", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:10+00:00", "tests_total": 92, "tests_dropped": 26, "flags": [], "topic_tags": ["array", "binary-search", "simulation", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def chalkReplacer(self, chalk: list[int], k: int) -> int:", "container": "Solution", "callable": "chalkReplacer", "parameters": [{"name": "chalk", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1895, "task_id": "largest-magic-square", "difficulty": "Medium", "problem_description": "A k x k magic square is a k x k grid filled with integers such that every row sum, every column sum, and both diagonal sums are all equal. The integers in the magic square do not have to be distinct. Every 1 x 1 grid is trivially a magic square.\n\nGiven an m x n integer grid, return the size (i.e., the side length k) of the largest magic square that can be found within this grid.\n\nExample 1:\n\nInput: grid = [[7,1,4,5,6],[2,5,1,6,4],[1,5,4,3,2],[1,2,7,3,4]]\nOutput: 3\nExplanation: The largest magic square has a size of 3.\nEvery row sum, column sum, and diagonal sum of this magic square is equal to 12.\n- Row sums: 5+1+6 = 5+4+3 = 2+7+3 = 12\n- Column sums: 5+5+2 = 1+4+7 = 6+3+3 = 12\n- Diagonal sums: 5+4+3 = 6+4+2 = 12\n\nExample 2:\n\nInput: grid = [[5,1,3,1],[9,3,3,1],[1,3,3,8]]\nOutput: 2\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 50\n- 1 <= grid[i][j] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[10, 20], [15, 25]]) == 1\n assert candidate(grid = [[7, 1, 4, 5, 6], [2, 5, 1, 6, 4], [1, 5, 4, 3, 2], [1, 2, 7, 3, 4]]) == 3\n assert candidate(grid = [[6, 3, 2, 8, 1, 9, 3, 2], [4, 7, 5, 4, 5, 3, 4, 7], [8, 4, 6, 8, 7, 2, 8, 1], [2, 9, 1, 5, 8, 7, 7, 3], [5, 4, 3, 1, 9, 4, 6, 3], [2, 8, 4, 9, 7, 8, 4, 1], [7, 8, 4, 5, 3, 9, 6, 4], [6, 3, 5, 9, 8, 7, 1, 9]]) == 1\n assert candidate(grid = [[8]]) == 1\n assert candidate(grid = [[16, 23, 17], [78, 32, 21], [17, 26, 79]]) == 1\n assert candidate(grid = [[5, 1, 3, 1], [9, 3, 3, 1], [1, 3, 3, 8]]) == 2\n assert candidate(grid = [[4, 3, 8, 4], [9, 5, 1, 9], [2, 7, 6, 2]]) == 3\n assert candidate(grid = [[16, 23, 17], [78, 32, 21], [17, 26, 78]]) == 1\n assert candidate(grid = [[1, 2], [3, 4]]) == 1\n assert candidate(grid = [[4, 9, 2], [3, 5, 7], [8, 1, 6]]) == 3\n assert candidate(grid = [[8, 1, 6, 13, 10], [3, 5, 7, 14, 11], [4, 9, 2, 15, 12], [15, 17, 24, 4, 5], [16, 23, 19, 6, 18]]) == 3\n assert candidate(grid = [[47, 36, 19, 73], [60, 22, 43, 19], [71, 23, 44, 39], [82, 24, 45, 40]]) == 1\n assert candidate(grid = [[2, 15, 13, 9], [16, 4, 6, 12], [9, 14, 7, 8], [10, 5, 11, 3]]) == 1\n assert candidate(grid = [[1, 16, 15, 4, 12], [8, 9, 10, 11, 14], [17, 2, 13, 14, 3], [12, 7, 6, 5, 18], [13, 8, 1, 12, 17]]) == 1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 1\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == 5\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4, 9, 2], [3, 5, 7, 8, 1, 6, 3, 5, 7], [4, 9, 2, 3, 5, 7, 4, 9, 2], [3, 5, 7, 4, 9, 2, 3, 5, 7], [8, 1, 6, 4, 9, 2, 3, 5, 7], [3, 5, 7, 8, 1, 6, 3, 5, 7], [4, 9, 2, 3, 5, 7, 8, 1, 6], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 3, 5, 7, 3, 5, 7]]) == 3\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]) == 1\n assert candidate(grid = [[3, 8, 4, 6], [6, 5, 7, 10], [5, 7, 8, 9], [8, 4, 5, 10]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [4, 3, 8, 1, 6, 7, 2, 9, 5], [9, 5, 1, 8, 4, 2, 7, 6, 3], [7, 9, 4, 8, 5, 2, 6, 3, 1], [3, 6, 7, 2, 9, 5, 8, 1, 4], [5, 8, 1, 9, 3, 6, 4, 7, 2], [2, 4, 6, 3, 1, 8, 5, 9, 7], [8, 7, 5, 6, 4, 9, 1, 2, 3], [6, 1, 9, 7, 2, 3, 5, 8, 4]]) == 1\n assert candidate(grid = [[5, 15, 25, 35, 45], [10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65]]) == 1\n assert candidate(grid = [[3, 8, 1, 2, 7], [8, 1, 2, 7, 3], [1, 2, 7, 3, 8], [2, 7, 3, 8, 1], [7, 3, 8, 1, 2]]) == 1\n assert candidate(grid = [[17, 24, 1, 8, 15], [23, 5, 7, 14, 16], [4, 6, 13, 20, 22], [10, 12, 19, 21, 3], [11, 18, 25, 2, 9]]) == 5\n assert candidate(grid = [[37, 21, 15, 13, 31], [21, 37, 31, 15, 13], [15, 21, 37, 13, 31], [31, 13, 21, 37, 15], [13, 31, 15, 21, 37]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[16, 3, 2, 13], [5, 10, 11, 8], [9, 6, 7, 12], [4, 15, 14, 1]]) == 4\n assert candidate(grid = [[20, 30, 25, 15, 10], [35, 25, 30, 20, 15], [20, 25, 30, 15, 35], [15, 30, 20, 25, 20], [10, 15, 25, 30, 20]]) == 1\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2, 1, 9], [7, 6, 5, 4, 3, 2, 1, 9, 8], [6, 5, 4, 3, 2, 1, 9, 8, 7], [5, 4, 3, 2, 1, 9, 8, 7, 6], [4, 3, 2, 1, 9, 8, 7, 6, 5], [3, 2, 1, 9, 8, 7, 6, 5, 4], [2, 1, 9, 8, 7, 6, 5, 4, 3], [1, 9, 8, 7, 6, 5, 4, 3, 2]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[16, 3, 2, 13], [5, 10, 11, 8], [9, 6, 7, 12], [4, 15, 14, 1]]) == 4\n assert candidate(grid = [[2, 7, 6, 9, 5], [9, 5, 1, 9, 7], [4, 3, 8, 4, 6], [1, 8, 3, 8, 2], [5, 4, 7, 5, 9]]) == 3\n assert candidate(grid = [[2, 7, 6], [9, 5, 1], [4, 3, 8], [15, 16, 17], [18, 19, 20]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 1\n assert candidate(grid = [[16, 23, 17], [78, 32, 21], [17, 23, 29]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == 5\n assert candidate(grid = [[2, 7, 6, 1, 8], [9, 5, 1, 3, 4], [8, 1, 6, 7, 2], [4, 9, 2, 8, 5], [3, 4, 5, 9, 6]]) == 1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == 1\n assert candidate(grid = [[3, 8, 4], [1, 6, 7], [6, 7, 2], [8, 1, 6], [7, 5, 3], [4, 9, 2]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4], [1, 6, 7, 8, 5, 4, 3], [6, 7, 2, 1, 3, 4, 5], [3, 5, 7, 4, 6, 8, 1], [5, 7, 4, 6, 8, 1, 3], [7, 4, 6, 8, 1, 3, 5], [4, 6, 8, 1, 3, 5, 7]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 7, 6, 3, 5, 9, 4, 8, 1], [4, 9, 2, 3, 5, 7, 8, 1, 6], [3, 5, 7, 4, 9, 2, 1, 6, 8], [8, 1, 6, 7, 2, 9, 4, 3, 5], [5, 4, 3, 6, 9, 2, 7, 8, 1], [6, 8, 1, 5, 3, 7, 2, 9, 4], [7, 6, 3, 1, 8, 4, 5, 2, 9]]) == 3\n assert candidate(grid = [[20, 9, 17, 12, 15, 14], [13, 18, 8, 11, 7, 10], [16, 21, 2, 14, 18, 12], [4, 19, 15, 22, 10, 6], [1, 12, 20, 17, 9, 23], [5, 24, 11, 23, 16, 4]]) == 1\n assert candidate(grid = [[3, 7, 5, 9, 11, 12], [10, 6, 14, 3, 13, 15], [4, 16, 1, 8, 17, 18], [9, 20, 12, 15, 5, 2], [13, 11, 19, 2, 6, 16], [17, 4, 22, 18, 10, 7]]) == 1\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70], [40, 50, 60, 70, 80]]) == 1\n assert candidate(grid = [[17, 24, 1, 8, 15], [23, 5, 7, 14, 16], [4, 6, 13, 20, 22], [10, 12, 19, 21, 3], [11, 18, 25, 2, 9]]) == 5\n assert candidate(grid = [[3, 5, 7, 9, 11], [6, 12, 4, 8, 2], [15, 1, 13, 3, 17], [10, 14, 5, 19, 16], [21, 25, 23, 20, 22]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4, 9, 2], [3, 5, 7, 8, 1, 6, 9, 2, 4], [4, 9, 2, 5, 8, 1, 6, 3, 7], [9, 2, 4, 7, 3, 5, 1, 6, 8], [1, 6, 8, 2, 4, 9, 3, 7, 5], [2, 4, 9, 6, 8, 3, 7, 5, 1], [7, 3, 5, 4, 9, 2, 8, 1, 6], [5, 8, 1, 9, 6, 4, 2, 7, 3], [6, 7, 3, 1, 2, 8, 5, 4, 9]]) == 3\n assert candidate(grid = [[2, 7, 6, 9, 5, 3], [9, 5, 1, 4, 1, 1], [4, 3, 8, 2, 4, 1], [8, 1, 6, 3, 5, 2], [3, 5, 7, 5, 3, 1], [6, 9, 2, 1, 7, 5]]) == 3\n assert candidate(grid = [[8, 1, 6, 7, 10, 12], [3, 5, 7, 8, 1, 11], [4, 9, 2, 13, 6, 7], [15, 14, 13, 12, 11, 10], [9, 8, 7, 6, 5, 4], [1, 2, 3, 4, 3, 2]]) == 3\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[4, 3, 8, 4], [9, 5, 1, 9], [2, 7, 6, 2], [6, 1, 8, 6], [7, 5, 3, 7]]) == 3\n assert candidate(grid = [[30, 5, 25], [5, 25, 30], [25, 30, 5], [5, 30, 25], [30, 25, 5], [25, 5, 30]]) == 1\n assert candidate(grid = [[35, 1, 6, 26, 19, 24], [3, 32, 7, 21, 23, 25], [31, 9, 2, 22, 27, 20], [8, 28, 33, 17, 10, 15], [30, 5, 34, 12, 14, 18], [4, 36, 29, 13, 16, 11]]) == 3\n assert candidate(grid = [[7, 12, 1, 14, 11, 2, 5], [13, 8, 10, 3, 4, 6, 15], [1, 14, 11, 2, 5, 7, 12], [13, 8, 10, 3, 4, 6, 15], [7, 12, 1, 14, 11, 2, 5], [13, 8, 10, 3, 4, 6, 15], [1, 14, 11, 2, 5, 7, 12]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(grid = [[25, 7, 2, 17], [14, 20, 16, 15], [13, 9, 6, 19], [18, 8, 23, 12]]) == 1\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[3, 10, 6, 7, 9], [1, 5, 7, 12, 8], [8, 11, 2, 5, 10], [9, 4, 3, 11, 13], [6, 7, 8, 10, 4]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 1\n assert candidate(grid = [[4, 9, 2, 16], [3, 5, 7, 12], [8, 1, 6, 10], [13, 14, 15, 11]]) == 3\n assert candidate(grid = [[3, 8, 4, 7, 2, 9], [2, 7, 3, 8, 4, 1], [1, 6, 2, 7, 3, 5], [5, 1, 6, 2, 7, 4], [4, 5, 1, 6, 2, 8], [8, 4, 5, 1, 6, 3]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4], [1, 6, 7, 8, 5, 3, 4], [6, 7, 2, 1, 9, 4, 3], [1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 8], [3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 1]]) == 1\n assert candidate(grid = [[3, 10, 4, 2, 15], [6, 8, 12, 14, 1], [9, 11, 5, 13, 7], [14, 1, 10, 6, 12], [16, 15, 9, 11, 5]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4, 9, 2], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 8, 1, 6, 3, 5, 7], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 8, 1, 6, 3, 5, 7], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 8, 1, 6, 3, 5, 7], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 8, 1, 6, 3, 5, 7]]) == 3\n assert candidate(grid = [[4, 3, 8, 4], [9, 5, 1, 9], [2, 7, 6, 2], [6, 1, 8, 6]]) == 3\n assert candidate(grid = [[2, 7, 6, 9, 5, 1], [9, 5, 1, 4, 3, 8], [4, 3, 8, 2, 4, 9], [3, 8, 4, 8, 4, 3], [8, 1, 6, 6, 7, 2], [6, 7, 2, 9, 5, 1]]) == 3\n assert candidate(grid = [[3, 8, 4, 8, 4], [1, 1, 6, 7, 2], [2, 9, 6, 2, 7], [8, 2, 9, 1, 8], [4, 8, 9, 2, 8]]) == 1\n assert candidate(grid = [[47, 38, 29, 20, 11, 2], [46, 37, 30, 21, 12, 3], [45, 36, 31, 22, 13, 4], [44, 35, 32, 23, 14, 5], [43, 34, 33, 24, 15, 6], [42, 39, 40, 25, 16, 7]]) == 1\n assert candidate(grid = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 1, 4, 3, 5], [3, 5, 1, 4, 2], [4, 3, 5, 2, 1]]) == 1\n assert candidate(grid = [[15, 15, 15, 15], [15, 15, 15, 15], [15, 15, 15, 15], [15, 15, 15, 15]]) == 4\n assert candidate(grid = [[2, 7, 6, 1, 8, 1], [8, 1, 6, 7, 2, 8], [6, 7, 2, 8, 1, 6], [1, 8, 1, 6, 7, 2], [8, 1, 6, 7, 2, 8], [6, 7, 2, 8, 1, 6]]) == 1\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]]) == 1\n assert candidate(grid = [[10, 20, 30, 40], [15, 25, 35, 45], [20, 30, 40, 50], [25, 35, 45, 55], [30, 40, 50, 60]]) == 1\n", "comparison": "exact"}, "public_tests": ["[[7,1,4,5,6],[2,5,1,6,4],[1,5,4,3,2],[1,2,7,3,4]]", "[[5,1,3,1],[9,3,3,1],[1,3,3,8]]"], "hints": ["Check all squares in the matrix and find the largest one."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().largestMagicSquare", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:13+00:00", "tests_total": 80, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "matrix", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def largestMagicSquare(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "largestMagicSquare", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1896, "task_id": "minimum-cost-to-change-the-final-value-of-expression", "difficulty": "Hard", "problem_description": "You are given a valid boolean expression as a string expression consisting of the characters '1','0','&' (bitwise AND operator),'|' (bitwise OR operator),'(', and ')'.\n\n- For example, \"()1|1\" and \"(1)&()\" are not valid while \"1\", \"(((1))|(0))\", and \"1|(0&(1))\" are valid expressions.\n\nReturn the minimum cost to change the final value of the expression.\n\n- For example, if expression = \"1|1|(0&0)&1\", its value is 1|1|(0&0)&1 = 1|1|0&1 = 1|0&1 = 1&1 = 1. We want to apply operations so that the new expression evaluates to 0.\n\nThe cost of changing the final value of an expression is the number of operations performed on the expression. The types of operations are described as follows:\n\n- Turn a '1' into a '0'.\n- Turn a '0' into a '1'.\n- Turn a '&' into a '|'.\n- Turn a '|' into a '&'.\n\nNote: '&' does not take precedence over '|' in the order of calculation. Evaluate parentheses first, then in left-to-right order.\n\nExample 1:\n\nInput: expression = \"1&(0|1)\"\nOutput: 1\nExplanation: We can turn \"1&(0|1)\" into \"1&(0&1)\" by changing the '|' to a '&' using 1 operation.\nThe new expression evaluates to 0.\n\nExample 2:\n\nInput: expression = \"(0&0)&(0&0&0)\"\nOutput: 3\nExplanation: We can turn \"(0&0)&(0&0&0)\" into \"(0|1)|(0&0&0)\" using 3 operations.\nThe new expression evaluates to 1.\n\nExample 3:\n\nInput: expression = \"(0|(1|0&1))\"\nOutput: 1\nExplanation: We can turn \"(0|(1|0&1))\" into \"(0|(0|0&1))\" using 1 operation.\nThe new expression evaluates to 0.\n\nConstraints:\n\n- 1 <= expression.length <= 10^5\n- expression only contains '1','0','&','|','(', and ')'\n- All parentheses are properly matched.\n- There will be no empty parentheses (i.e: \"()\" is not a substring of expression).\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(expression = \"(1&(0|1&(0|1)))\") == 1\n assert candidate(expression = \"(0&1&1)|(0|1)\") == 1\n assert candidate(expression = \"(1&1)|(0&0)\") == 1\n assert candidate(expression = \"(1&((0&0)|(1|1)))\") == 1\n assert candidate(expression = \"1&(1&(1&(1&1)))\") == 1\n assert candidate(expression = \"((1|1)&(0|0))\") == 1\n assert candidate(expression = \"1&(0|1)\") == 1\n assert candidate(expression = \"((1&1)|(0&0))\") == 1\n assert candidate(expression = \"(1&1&1)|(1|1|1)\") == 2\n assert candidate(expression = \"1|1|0&1\") == 1\n assert candidate(expression = \"(0&0)|((1&1)|(0&1))\") == 1\n assert candidate(expression = \"(1&((1&1)&(1&1)))\") == 1\n assert candidate(expression = \"((1&0)|(1&1))\") == 1\n assert candidate(expression = \"(0&0&0)|(0|0|0)\") == 1\n assert candidate(expression = \"0|1&(1|0)&1\") == 1\n assert candidate(expression = \"1|1|(0&0)&1\") == 1\n assert candidate(expression = \"(((0|1)&1)|(0&0))\") == 1\n assert candidate(expression = \"(1&((0&1)|0))\") == 1\n assert candidate(expression = \"(0|(1|0&1))\") == 1\n assert candidate(expression = \"(0|((0|0)|(0|0)))\") == 1\n assert candidate(expression = \"(1&0)|(1&1)\") == 1\n assert candidate(expression = \"(0&0)&(0&0&0)\") == 3\n assert candidate(expression = \"(0|(0|(0|(0|0))))\") == 1\n assert candidate(expression = \"((1|0)&(0|1))\") == 1\n assert candidate(expression = \"(1|0|0)&(1&1)\") == 1\n assert candidate(expression = \"((1&0)|(1|0))\") == 1\n assert candidate(expression = \"(1&(1&(1&(1&1))))\") == 1\n assert candidate(expression = \"(1&1&1)|(0|0|0)\") == 1\n assert candidate(expression = \"(1|(0&(1|0)))\") == 1\n assert candidate(expression = \"(0&1)|((1|0)&(0|1))\") == 1\n assert candidate(expression = \"0|(0|(0|(0|0)))\") == 1\n assert candidate(expression = \"(1&(0|(1&0)))\") == 1\n assert candidate(expression = \"((1&(1|0))&(0|1))\") == 1\n assert candidate(expression = \"(0&(((0|1)&(1|0))|((1&0)|(0|1))))\") == 1\n assert candidate(expression = \"((0&(((1|0)|(0&1))&(1&1)))|((1|0)|(0|1)))&(1|0)\") == 1\n assert candidate(expression = \"((0&(1|0))&(0&(1|0))&(0&(1|0)))\") == 2\n assert candidate(expression = \"(0|((1&0)|(0|1)&((1|0)&(1|0))))\") == 1\n assert candidate(expression = \"((1&((1|0)|(0|1)))&((0&0)|(1&(1&(1&1)))))\") == 1\n assert candidate(expression = \"((0|1)&(1|(0|1&0))&(1|(0&(1|0))))\") == 1\n assert candidate(expression = \"((1&((0|1)&(0|1)))|((0&(1|0))&(1|0)))\") == 1\n assert candidate(expression = \"(((0|0)|(1|1))&((0|0)|(1|1))&((0|0)|(1|1))&((0|0)|(1|1)))\") == 1\n assert candidate(expression = \"(((1|0)|(0&1))&((0|1)|(0&1))&((1|0)|(0&1))&((0|1)|(0&1)))\") == 1\n assert candidate(expression = \"((0&0)&(0&0)&(1|1)&((0|0)|(1|1)))\") == 1\n assert candidate(expression = \"((1&0)|(0|1)&((1|0)&(1|0)))\") == 1\n assert candidate(expression = \"((1|0)&(1&0)|(0|1)&(1|0))\") == 1\n assert candidate(expression = \"((1|0)|(0&1)&(0|1))\") == 1\n assert candidate(expression = \"(1|(((1|0)&(0|1)))&(((0&1)|(1&1))&(1|0)))|(0|1)\") == 2\n assert candidate(expression = \"((0&(1|0)&(1|0))|(0&(0|1)&(0|1)))\") == 1\n assert candidate(expression = \"(((0|1)&(0|1))&((1&0)|(1&0))&((0|1)&(0|1))&((1&0)|(1&0)))\") == 2\n assert candidate(expression = \"(((1|1)|(0|0))&(1&(1&(1&1))))\") == 1\n assert candidate(expression = \"((1&0)|((0&1)|(1|((1&0)|(0|1)))))\") == 1\n assert candidate(expression = \"(((0&(1|0))&(1&((0&1)|(1|0))))|((1&0)|(0&((1&0)|(0&1)))))\") == 1\n assert candidate(expression = \"(((1|0)&(0|1))&((1|0)&(0|1)))|(1&(0|((1&1)|(0&0))))\") == 2\n assert candidate(expression = \"(((0|1)&(1|0))|((1&(0|1))|(0&1)))\") == 2\n assert candidate(expression = \"(0|((1&0)|(0|1)&((1|0)|(0|1)&(1|0))))\") == 1\n assert candidate(expression = \"(((0|1)|(1&0))&((0&1)|(1|0)))\") == 1\n assert candidate(expression = \"((1&0)|(1&0)|(0|1)&(0|1))\") == 1\n assert candidate(expression = \"(1|(((1|0)&(1|0))|((0&1)|(0&1))))\") == 2\n assert candidate(expression = \"(1&(0|((1&1)|(0|0))))\") == 1\n assert candidate(expression = \"(1&(((0|1)&(0|1))&((1|0)|(0|1)&(1|0))))\") == 1\n assert candidate(expression = \"((0&((0&1)|(1|0)))|((1&((0&1)|(1|0)))&(1&(0&(1|0)))))\") == 1\n assert candidate(expression = \"((1&0)|(0|1)&((1|0)|(0|1)&(1|0)))\") == 1\n assert candidate(expression = \"(1|(0&(1|0))|(0&1))\") == 1\n assert candidate(expression = \"(0|((1&1)|(0&0)))&(1&(0|((1&1)|(0&0))))\") == 1\n assert candidate(expression = \"(1|(((0&(1|0))|(1&0))&((1|0)&(0|1))))\") == 1\n assert candidate(expression = \"(((1|0)&(0|1))|((0&1)|(1|0))|((1|0)&(0|1))|((0&1)|(1|0)))\") == 2\n assert candidate(expression = \"(((1&0)|(0&1))&((0&(1|0))|(1&((0&1)|(1|0)))))\") == 1\n assert candidate(expression = \"(((1&0)|(0|1))&((1|0)|(0&1)))\") == 1\n assert candidate(expression = \"((1&0)|(1&1))&(1|0)\") == 1\n assert candidate(expression = \"(((1|1)|(0&0))&((1&1)|(0|0))|(1|0))\") == 2\n assert candidate(expression = \"((1|((0&0)|(1&1)))&(1|0))|((0|1)&(1&1))\") == 2\n assert candidate(expression = \"(((1|0)&1)|(0&(1|0)))\") == 1\n assert candidate(expression = \"((0&1)|(1&(0|1)))&((1&0)|(1|1))\") == 1\n assert candidate(expression = \"(1&((0|1)&(0|1))&(0|1))\") == 1\n assert candidate(expression = \"((0|1)|(1|0)&(0|1)&(0|1))&((0|1)|(0|1))\") == 1\n assert candidate(expression = \"(1&((0&1)|(0&(1|0))&(1|0)))\") == 1\n assert candidate(expression = \"(1|((1|0)&(0|1)))|(((0&1)|(1&1))&(1|0))\") == 2\n assert candidate(expression = \"((0&((1|0)&(0|1)))|((0&(1|0))&(1|0)))\") == 1\n assert candidate(expression = \"(((0|1)&(0|1))&((1|0)|(0|1)&(1|0)))\") == 1\n assert candidate(expression = \"(1&(((0&0)|(1|1))&(1&((0&0)|(1|1)))))|((1&(0|((1&1)|(0&0))))&(1|0))\") == 2\n assert candidate(expression = \"(((1&1)&(0|0))|(1|0)&((1&0)|(0|1))&(1|0))\") == 1\n assert candidate(expression = \"((1|(0&(1&0)))&(0|(1|0)))\") == 1\n assert candidate(expression = \"((1&(0|1))|(0&(1|0)))\") == 1\n assert candidate(expression = \"(((0|1)|(0&1))&(1|(0&0)&(1|0)))\") == 1\n assert candidate(expression = \"(1|((0|1)&(0&1))|(1&0))\") == 1\n assert candidate(expression = \"((1&0)|(1&(0|1))|(0&(1|0)))\") == 1\n assert candidate(expression = \"((0|(1&0))&(((1|0)&(0|1))|((0&1)|(1|0))))\") == 1\n assert candidate(expression = \"(1&(((0|1)|(1&0))&(0|1)))\") == 1\n assert candidate(expression = \"(((1&(0|1))&((1&0)|(0&1)))|((0&(1|0))&(1&((0&1)|(1|0)))))\") == 1\n assert candidate(expression = \"((0|1)|((1&(0|1))&(0|1)))\") == 2\n assert candidate(expression = \"((0&1)|(0&1)|(0&1)|(0&1))\") == 1\n assert candidate(expression = \"(0|(1&0)|(0|1)&(1|0))\") == 1\n assert candidate(expression = \"((1&(0|((1|0)&(1|0))))&((1&(0|((1|0)&(1|0))))&((1&(0|((1|0)&(1|0))))))\") == 1\n assert candidate(expression = \"(1|((0&0)|(1&(0|1))))\") == 2\n assert candidate(expression = \"(0|((1&((0|1)|(1|0)))&(1|0)))\") == 1\n assert candidate(expression = \"((0|((1&0)|(0|1)))&(((1|0)&(0|1))|((0&1)|(1|0))))\") == 1\n assert candidate(expression = \"(1&((0|0)|(1&0))&(0&(1|0))&(0|1))\") == 1\n assert candidate(expression = \"(((1|1)|(0|0))&(1&0))|(0|1)\") == 1\n assert candidate(expression = \"(1&(0|((0|0)&(0|0))))|((1|0)&(1&1))\") == 1\n assert candidate(expression = \"((1&(0|1))&(1|0))\") == 1\n assert candidate(expression = \"(1|((1|0)|(0|1))&(0&1))\") == 1\n assert candidate(expression = \"((1&1)|(0&(1|0)))\") == 1\n assert candidate(expression = \"(0|((1&0)|(0|1)&(1|0)))\") == 1\n assert candidate(expression = \"(1|((0&(1|0))&(1&(0|1&0))))\") == 1\n assert candidate(expression = \"((0&(1|1))|((1&0)|(0&1)))\") == 1\n assert candidate(expression = \"(1&(((1|0)|(0&1))&(1&1)))|((0|1)&(1&1))\") == 2\n assert candidate(expression = \"(((0|1)&(0|1))&((1|0)&(1|0)))\") == 1\n assert candidate(expression = \"(((0|1)&(1|0))&((1&0)|(0|1)))\") == 1\n assert candidate(expression = \"((1&((0&1)|(1|0)))&((1|0)|(0&(1|0))))|((1&(0|((1&1)|(0&0))))&(1|0))\") == 2\n assert candidate(expression = \"(((0&0)|(1&(0|1)))&((1|0)|(0&((0&1)|(1|0)))))\") == 1\n assert candidate(expression = \"(((0|1)&(1|0))|((1&0)|(0&1)))\") == 1\n assert candidate(expression = \"(1&((1|0)|(0|1))&(0&(1|0))&(0|1)&((0|0)&(1|1)))\") == 2\n assert candidate(expression = \"((1&(1&(1&0)))|((0|1)|(0&1)))\") == 1\n assert candidate(expression = \"((1|0)&(0|1)|(0&(1|0)))\") == 1\n assert candidate(expression = \"(0|((1|0)&(0|1))&(1|0))\") == 1\n assert candidate(expression = \"((1&(0|((1&0)|(0&1))))&((0&(1|0))|(1&(0|1))))\") == 1\n assert candidate(expression = \"((1&(0|1))&(1&(0|1))&(1&(0|1))&(1&(0|1)))\") == 1\n assert candidate(expression = \"(1|((0&(1|0))|(1&(0|1))))\") == 2\n assert candidate(expression = \"((1|((0&(1&0))|(0|1)))&(0&((0&(1|0))|(1&(0|1)))))\") == 1\n assert candidate(expression = \"(0&((1&0)|(1|(0&1&0))))\") == 1\n assert candidate(expression = \"(1|((0&0)&(0|0))|(0|(1&1)))\") == 2\n assert candidate(expression = \"(((1|1)&(0&0))|(1&0))\") == 1\n assert candidate(expression = \"(((0|1)&(0|1))&(1|0)&(1|0))\") == 1\n assert candidate(expression = \"((0|0)&(0|0)&(1|1)|(0|0)&(0|0))\") == 2\n assert candidate(expression = \"(0&(((1|0)|(0&1))&(1&1)))|((1|0)|(0|1))\") == 1\n assert candidate(expression = \"((0&(0|1))|(0&(0|1))|(0&(0|1))|(0&(0|1)))\") == 1\n assert candidate(expression = \"((1&0)|(0|1)&(1|0))\") == 1\n assert candidate(expression = \"((0&1)|(1&(1|0)))\") == 1\n assert candidate(expression = \"((1&(1&1))|((0|0)|(0&0)))\") == 1\n assert candidate(expression = \"((1|(0&0)&(1|0))|(0&(0|1)&(0|1))&(0&(0|1)&(0|1)))\") == 1\n assert candidate(expression = \"(((1&0)|(0&1))&((1&(0|1))|(0&1)))\") == 1\n assert candidate(expression = \"((0|((1&(0|1))|(0&(1|0))))&(1&((0&1)|(1|0))))\") == 1\n assert candidate(expression = \"(((0|0)&(0|0))&((0|0)|(0|0)))\") == 2\n assert candidate(expression = \"(1&((1&((0&0)|(1|1)))|((1|(0|1))&(0&0))))\") == 1\n assert candidate(expression = \"((0&((1|0)|(0|1)))|((1&(0|1))&(0|1)))\") == 1\n assert candidate(expression = \"(((0&(1|0))|(1&0))&((1|0)&(0|1)))\") == 1\n assert candidate(expression = \"(((1&(0|1))|(0&(1|0)))|((1&(0|1))&(0|1)))\") == 2\n assert candidate(expression = \"((0&(0&0))|((1|1)&(1|1)))\") == 1\n assert candidate(expression = \"((1&(0|1))|(0&(0|1)&(0|1)))\") == 1\n assert candidate(expression = \"(1&((0|1)|(0|1))&(0&((1|0)|(1|0))))\") == 1\n assert candidate(expression = \"(((1&(0|1))|(0&1))&(1&((0|1)|(0&(1|0)))))\") == 1\n assert candidate(expression = \"(((1|0)&(0|1))|(0&(1|0))&(1&(0|1&0)))\") == 1\n assert candidate(expression = \"((1&(0|1))|(1&0))\") == 1\n assert candidate(expression = \"(1&(((0|1)&(0|1))&((1|0)&(1|0))))\") == 1\n assert candidate(expression = \"(1&(0|1&(0|1&(1|0))))\") == 1\n assert candidate(expression = \"(((1|0)|(0&1))&((1|0)|(0&1))&((1|0)|(0&1))&((1|0)|(0&1)))\") == 1\n assert candidate(expression = \"((((0|0)|(1&1))&((0|1)&(1|0)))|((0&1)|(1|0)))\") == 2\n assert candidate(expression = \"(1|((0&0)|(1&0))&(0&(1|0))&(0|1)&((1|0)|(0|1)))\") == 1\n assert candidate(expression = \"(((0|1)&(1|0))&(0|1))\") == 1\n assert candidate(expression = \"(((1|0)|(0&1))&((1&0)|(0|1)))\") == 1\n assert candidate(expression = \"(1|(((0|1)&(1|0))|(0&(1|0))))\") == 2\n assert candidate(expression = \"(1|(((1|0)&(0|1))|(1&(0&1))))\") == 2\n assert candidate(expression = \"(((1&0)|(1|0))&((1&1)|(0|0)))\") == 1\n assert candidate(expression = \"((0|1)|((0&1)&(1|0))&(1&(0|((1&1)|(0&0)))))\") == 1\n assert candidate(expression = \"(1|(((0&0)&(0|0))|((1|1)|(1&1))))\") == 2\n assert candidate(expression = \"(0&(((1|0)|(0|1))&(0|1))&(1|0))\") == 1\n assert candidate(expression = \"((0|0)|(1&1))&(((1|0)&(0|1))|(1&1))\") == 1\n assert candidate(expression = \"((1&(0|1))|((0&1)|((1|0)&(0|1))))\") == 2\n assert candidate(expression = \"(((1&1)&(0|0))|((0|0)|(1&1)))\") == 1\n assert candidate(expression = \"(((1|0)|(1|0))&((0&1)|(0&1))&((0&1)|(0&1))&((1|0)|(1|0)))\") == 1\n assert candidate(expression = \"((1&(0|1))&((0|1)|(1&0)))\") == 1\n assert candidate(expression = \"((1&(0|1))&((0|1)&(1|0)))\") == 1\n assert candidate(expression = \"(1&((0|1)&(0|1))|(1&0)&(0&1))\") == 1\n assert candidate(expression = \"(1|((0&(1|0))|((0|1)&(1&0))))\") == 1\n assert candidate(expression = \"((1&(0|1))|((0|1)|(1&(0|1&0))))\") == 2\n assert candidate(expression = \"(((1&(0&(1|0)))|((0&(1|0))|(0&1)))&((0&1)|(1&(0&1))))\") == 2\n assert candidate(expression = \"(1&(1|(0&0)&(1|0))|(0&(0|1)&(0|1)))\") == 1\n assert candidate(expression = \"(0|((((1|0)&(0|1))|((1&0)|(0|1)))|((1&(0&0))|(0|1))))\") == 1\n assert candidate(expression = \"(((0&0)|(1|1))&((0|1)|(1|0))&((1&0)|(0|1))&((0&0)|(1|1)))\") == 1\n assert candidate(expression = \"((0&(0|1))|((1|0)&1))\") == 1\n assert candidate(expression = \"(((0|1)&(1|0))|(0&(1|0)))\") == 1\n assert candidate(expression = \"(((0&1)|(1&0))|((1&1)&(0|0)))\") == 1\n assert candidate(expression = \"((0&(1|0))|((0&1)|(1&1)))&(1|0)\") == 1\n", "comparison": "exact"}, "public_tests": ["\"1&(0|1)\"", "\"(0&0)&(0&0&0)\"", "\"(0|(1|0&1))\""], "hints": ["How many possible states are there for a given expression?", "Is there a data structure that we can use to solve the problem optimally?"], "metadata": {"canonical_parameter_names": ["expression"], "leetcode_dataset_entry_point": "Solution().minOperationsToFlip", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:15+00:00", "tests_total": 173, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "string", "dynamic-programming", "stack"]}, "language": "python", "interface": {"raw_signature": "def minOperationsToFlip(self, expression: str) -> int:", "container": "Solution", "callable": "minOperationsToFlip", "parameters": [{"name": "expression", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1897, "task_id": "redistribute-characters-to-make-all-strings-equal", "difficulty": "Easy", "problem_description": "You are given an array of strings words (0-indexed).\n\nIn one operation, pick two distinct indices i and j, where words[i] is a non-empty string, and move any character from words[i] to any position in words[j].\n\nReturn true if you can make every string in words equal using any number of operations, and false otherwise.\n\nExample 1:\n\nInput: words = [\"abc\",\"aabc\",\"bc\"]\nOutput: true\nExplanation: Move the first 'a' in words[1] to the front of words[2],\nto make words[1] = \"abc\" and words[2] = \"abc\".\nAll the strings are now equal to \"abc\", so return true.\n\nExample 2:\n\nInput: words = [\"ab\",\"a\"]\nOutput: false\nExplanation: It is impossible to make all the strings equal using the operation.\n\nConstraints:\n\n- 1 <= words.length <= 100\n- 1 <= words[i].length <= 100\n- words[i] consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl']) == False\n assert candidate(words = ['aabbcc', 'abc', 'abc', 'abc']) == False\n assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba']) == True\n assert candidate(words = ['abcd', 'bcad', 'acdb', 'bdac']) == True\n assert candidate(words = ['hello', 'olelh', 'loleh']) == True\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == False\n assert candidate(words = ['a', 'a', 'a', 'a']) == True\n assert candidate(words = ['test', 'sett', 'stte']) == True\n assert candidate(words = ['abc', 'def', 'ghi']) == False\n assert candidate(words = ['xyz', 'zyx', 'yzx']) == True\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy']) == False\n assert candidate(words = ['ab', 'a']) == False\n assert candidate(words = ['same', 'same', 'same']) == True\n assert candidate(words = ['abcd', 'abcd', 'abcd', 'abcd']) == True\n assert candidate(words = ['one', 'two', 'three']) == False\n assert candidate(words = ['abc', 'aabc', 'bc']) == True\n assert candidate(words = ['aabbcc', 'abc', 'abc']) == False\n assert candidate(words = ['abcd', 'abcd', 'abcd']) == True\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same']) == True\n assert candidate(words = ['aabb', 'bbcc', 'ccdd', 'aabb', 'bbcc', 'ccdd', 'aabb', 'bbcc', 'ccdd']) == False\n assert candidate(words = ['abcdefghijklmnop', 'abcdefghijklmnop', 'abcdefghijklmnop', 'abcdefghijklmnop']) == True\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'zxy', 'yxz', 'xzy']) == True\n assert candidate(words = ['zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz']) == True\n assert candidate(words = ['repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat']) == True\n assert candidate(words = ['abcdabcd', 'bacdbacd', 'cdabdcab', 'dcbadacb']) == True\n assert candidate(words = ['xyz', 'yzx', 'zxy', 'zyx', 'yxz', 'xzy']) == True\n assert candidate(words = ['abcdefg', 'ghfedcb', 'fedcbaa', 'bcaefgd', 'abcdefg', 'ghfedcb', 'fedcbaa', 'bcaefgd', 'abcdefg', 'ghfedcb']) == False\n assert candidate(words = ['abcde', 'bcdea', 'cdeab', 'deabc', 'eabcd', 'fghij', 'ghijf', 'hijfg', 'ijfgh', 'jfgih']) == False\n assert candidate(words = ['hello', 'bello', 'hallo', 'hellb', 'hella', 'bellh', 'hblla']) == False\n assert candidate(words = ['abcde', 'edcba', 'bcdea', 'decab', 'acdeb']) == True\n assert candidate(words = ['hello', 'lohel', 'ohell', 'llohe', 'elloh']) == True\n assert candidate(words = ['python', 'typhon', 'typhno', 'hypton', 'hptyon', 'phyton', 'ptyhno', 'thpyon', 'ptyhon', 'phytom']) == False\n assert candidate(words = ['abacabadabacaba', 'bacabacabadabacab', 'acabacabadabacaba', 'cabacabadabacabaa']) == False\n assert candidate(words = ['aabbcc', 'abcabc', 'ccbaab', 'bcaacb']) == True\n assert candidate(words = ['aabbcc', 'abcabc', 'baccab', 'cbbaca', 'acabcb', 'bcacab']) == True\n assert candidate(words = ['hello', 'world', 'owrld', 'dlrow', 'llhow']) == False\n assert candidate(words = ['abcdef', 'fedcba', 'defabc', 'cabdef', 'bacdef', 'fabcde']) == True\n assert candidate(words = ['xyx', 'yxy', 'xyx', 'xyx', 'xyx', 'xyx', 'xyx', 'xyx', 'xyx', 'xyx']) == False\n assert candidate(words = ['mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq', 'mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq', 'mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq']) == True\n assert candidate(words = ['equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal']) == True\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccaabb', 'aabbbc', 'bbccaa']) == False\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']) == False\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'aaa', 'bbb', 'ccc', 'aaa', 'bbb', 'ccc']) == True\n assert candidate(words = ['qwertyuiop', 'poiuytrewq', 'oiuytrewqp', 'iuytrewqpo', 'uytrewqpoi', 'ytrewqpoiu']) == True\n assert candidate(words = ['abcdefg', 'bcdefga', 'cdefgab', 'defgabc', 'efgabcd', 'fgabcde', 'gabcdef']) == True\n assert candidate(words = ['aabb', 'bbaa', 'abab', 'abba', 'baab', 'baba', 'aaab', 'aaba', 'abaa', 'baaa', 'bbaa', 'abab', 'abba', 'baab', 'baba', 'aaab', 'aaba', 'abaa', 'baaa', 'bbaa']) == False\n assert candidate(words = ['aabbcc', 'abcabc', 'bcaabc', 'cababc']) == True\n assert candidate(words = ['apple', 'ppale', 'pleap', 'elppa', 'lappe']) == True\n assert candidate(words = ['aabbccddeeffgghhiijjooppllnnmmbbkkqqwwaass', 'aabbccddeeffgghhiijjooppllnnmmbbkkqqwwaass', 'aabbccddeeffgghhiijjooppllnnmmbbkkqqwwaass', 'aabbccddeeffgghhiijjooppllnnmmbbkkqqwwaass']) == True\n assert candidate(words = ['aabbcc', 'bbccaa', 'ccaabb']) == True\n assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == True\n assert candidate(words = ['xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx']) == True\n assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee']) == False\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same']) == True\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same']) == True\n assert candidate(words = ['aabbcc', 'abcabc', 'ccbaab']) == True\n assert candidate(words = ['unique', 'uniqueness', 'uniquely', 'uniques']) == False\n assert candidate(words = ['aaaaab', 'aaabbb', 'aabbbb', 'abbbbb', 'bbbbbz']) == False\n assert candidate(words = ['python', 'typhon', 'nothpy', 'hnotyp', 'npytho']) == True\n assert candidate(words = ['aabbcc', 'abcabc', 'ccbaab', 'baccab']) == True\n assert candidate(words = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']) == True\n assert candidate(words = ['abcdef', 'bcdefa', 'cdefab', 'defabc', 'efabcd', 'fabcde', 'abcdef', 'bcdefa', 'cdefab', 'defabc', 'efabcd', 'fabcde']) == True\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'xzy']) == True\n assert candidate(words = ['unique', 'characters', 'only', 'in', 'each', 'string', 'here']) == False\n assert candidate(words = ['abcdefgh', 'hgfedcba', 'abcdefg', 'gfedcba', 'abcdef', 'fedcba', 'abcde', 'edcba', 'abcd', 'dcba', 'abc', 'cba', 'ab', 'ba', 'a', 'b']) == False\n assert candidate(words = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm', 'qwertyuiop', 'asdfghjkl', 'zxcvbnm', 'qwertyuiop', 'asdfghjkl', 'zxcvbnm']) == False\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']) == False\n assert candidate(words = ['abracadabra', 'cadabraab', 'rabracada', 'abracadab', 'acadabrabr']) == False\n assert candidate(words = ['abcdef', 'bcdefa', 'cdefab', 'defabc', 'efabcd', 'fabcde']) == True\n assert candidate(words = ['qqq', 'www', 'eee', 'rrr', 'ttt', 'yyy', 'uuu', 'iii', 'ooo', 'ppp', 'lll', 'mmm', 'nnn', 'sss', 'ddd', 'fff', 'ggg', 'hhh', 'jjj', 'kkk']) == False\n assert candidate(words = ['apple', 'ppale', 'pplea', 'pelap', 'pepla']) == True\n assert candidate(words = ['racecar', 'carrace', 'ecarrac', 'rraceca', 'acecarr']) == True\n assert candidate(words = ['abcdefgh', 'hgfedcba', 'bacdefgh', 'defghabc', 'efghabcd']) == True\n assert candidate(words = ['abc', 'abcabc', 'abcabcabc', 'abcabcabcabc', 'abcabcabcabcabc', 'abcabcabcabcabcabc', 'abcabcabcabcabcabcabc', 'abcabcabcabcabcabcabcabc', 'abcabcabcabcabcabcabcabcabc', 'abcabcabcabcabcabcabcabcabcabc']) == False\n assert candidate(words = ['mississippi', 'ppiimiss', 'pisimmpi', 'ssippiim', 'pmissipi', 'iimpsspi', 'sspiimp', 'misipip', 'sipimp', 'impispi']) == False\n assert candidate(words = ['unique', 'enquie', 'unieqe', 'inequeu', 'niuquee', 'uqneiee', 'qnueiee']) == False\n assert candidate(words = ['aabbcc', 'abcabc', 'bcaabc', 'cababc', 'bcacab']) == True\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'xzy', 'yxz']) == True\n assert candidate(words = ['abcdabcd', 'dcbaabcd', 'abcdcdab', 'dcabcdab']) == True\n assert candidate(words = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'ffffff', 'gggggg', 'hhhhh', 'iiiii', 'jjjjj']) == False\n assert candidate(words = ['hello', 'world', 'world', 'hello']) == False\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'aab', 'bbc', 'cca']) == True\n assert candidate(words = ['aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz', 'zzxyyxwwvvttsrrqpponmlkjihgfedcba', 'abcdefghijlkmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba', 'zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba', 'qrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcd']) == False\n assert candidate(words = ['zzzz', 'zzz', 'zz', 'z']) == False\n assert candidate(words = ['python', 'programming', 'challenge', 'easy']) == False\n assert candidate(words = ['qwerty', 'wertyq', 'ertyqw', 'rtyqwe', 'tyqwre', 'yqwret', 'qwertyui', 'wertyuiq', 'ertyuiqw', 'rtyuiqwe', 'tyuiqwre', 'yuiqwret']) == False\n assert candidate(words = ['hello', 'olleh', 'loleh', 'elloh', 'lhleo', 'heoll']) == True\n assert candidate(words = ['abacabadabacaba', 'bacabacabacaba', 'cabacabacabacaba', 'dacabacabacaba', 'eacabacabacaba', 'facabacabacaba', 'gacabacabacaba', 'hacabacabacaba', 'iacabacabacaba', 'jacobacabacaba', 'kacabacabacaba']) == False\n", "comparison": "exact"}, "public_tests": ["[\"abc\",\"aabc\",\"bc\"]", "[\"ab\",\"a\"]"], "hints": ["Characters are independent—only the frequency of characters matters.", "It is possible to distribute characters if all characters can be divided equally among all strings."], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().makeEqual", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:17+00:00", "tests_total": 89, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def makeEqual(self, words: list[str]) -> bool:", "container": "Solution", "callable": "makeEqual", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1898, "task_id": "maximum-number-of-removable-characters", "difficulty": "Medium", "problem_description": "You are given two strings s and p where p is a subsequence of s. You are also given a distinct 0-indexed integer array removable containing a subset of indices of s (s is also 0-indexed).\n\nYou want to choose an integer k (0 <= k <= removable.length) such that, after removing k characters from s using the first k indices in removable, p is still a subsequence of s. More formally, you will mark the character at s[removable[i]] for each 0 <= i < k, then remove all marked characters and check if p is still a subsequence.\n\nReturn the maximum k you can choose such that p is still a subsequence of s after the removals.\n\nA subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.\n\nExample 1:\n\nInput: s = \"abcacb\", p = \"ab\", removable = [3,1,0]\nOutput: 2\nExplanation: After removing the characters at indices 3 and 1, \"abcacb\" becomes \"accb\".\n\"ab\" is a subsequence of \"accb\".\nIf we remove the characters at indices 3, 1, and 0, \"abcacb\" becomes \"ccb\", and \"ab\" is no longer a subsequence.\nHence, the maximum k is 2.\n\nExample 2:\n\nInput: s = \"abcbddddd\", p = \"abcd\", removable = [3,2,1,4,5,6]\nOutput: 1\nExplanation: After removing the character at index 3, \"abcbddddd\" becomes \"abcddddd\".\n\"abcd\" is a subsequence of \"abcddddd\".\n\nExample 3:\n\nInput: s = \"abcab\", p = \"abc\", removable = [0,1,2,3,4]\nOutput: 0\nExplanation: If you remove the first index in the array removable, \"abc\" is no longer a subsequence.\n\nConstraints:\n\n- 1 <= p.length <= s.length <= 10^5\n- 0 <= removable.length < s.length\n- 0 <= removable[i] < s.length\n- p is a subsequence of s.\n- s and p both consist of lowercase English letters.\n- The elements in removable are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"pqrstu\",p = \"psu\",removable = [5, 4, 3, 2, 1, 0]) == 0\n assert candidate(s = \"abcdefghij\",p = \"acegi\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(s = \"deeddeede\",p = \"dee\",removable = [5, 3, 4, 6]) == 4\n assert candidate(s = \"deeedbbcccbdaa\",p = \"ddccbb\",removable = [8, 2, 3, 0, 7]) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"acegikmoqsuwy\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 13\n assert candidate(s = \"zzzzzzzzzz\",p = \"zz\",removable = [1, 3, 5, 7]) == 4\n assert candidate(s = \"aaaabbbb\",p = \"ab\",removable = [2, 3, 4, 5]) == 4\n assert candidate(s = \"abcdef\",p = \"abc\",removable = [5, 4, 3, 2, 1, 0]) == 3\n assert candidate(s = \"aabcbcb\",p = \"abc\",removable = [3, 1, 0, 4]) == 2\n assert candidate(s = \"abcdxyz\",p = \"ad\",removable = [0, 1, 2, 3, 4, 5, 6]) == 0\n assert candidate(s = \"abcacb\",p = \"ab\",removable = [3, 1, 0]) == 2\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"acegikmoqsuwy\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 0\n assert candidate(s = \"ababababab\",p = \"aaaa\",removable = [0, 2, 4, 6, 8]) == 1\n assert candidate(s = \"mississippi\",p = \"issi\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(s = \"zpqom\",p = \"z\",removable = [0, 1, 2, 3, 4]) == 0\n assert candidate(s = \"abcab\",p = \"abc\",removable = [0, 1, 2, 3, 4]) == 0\n assert candidate(s = \"xyz\",p = \"xyz\",removable = [0, 1, 2]) == 0\n assert candidate(s = \"abcdef\",p = \"af\",removable = [1, 2, 3, 4]) == 4\n assert candidate(s = \"abcbddddd\",p = \"abcd\",removable = [3, 2, 1, 4, 5, 6]) == 1\n assert candidate(s = \"zazbzczdzezfzgzhzi\",p = \"abcdefg\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16]) == 9\n assert candidate(s = \"thisisaverylongstringthatweneedtoremovesomecharactersfrom\",p = \"thisisalong\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n assert candidate(s = \"mississippi\",p = \"miss\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(s = \"abcdefghijklnmopqrstuvwxyz\",p = \"zyxwvutsrqponmlkjihgfedcba\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(s = \"abracadabra\",p = \"aca\",removable = [1, 3, 5, 7, 9, 10]) == 5\n assert candidate(s = \"leetcodeleetcodeleetcode\",p = \"leetcode\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]) == 16\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",p = \"zzzz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 30\n assert candidate(s = \"abracadabra\",p = \"aa\",removable = [0, 2, 4, 6, 8, 10]) == 6\n assert candidate(s = \"abacabadabacaba\",p = \"abc\",removable = [2, 5, 8, 11, 14]) == 5\n assert candidate(s = \"abcdefghijklm\",p = \"abc\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(s = \"zzzzzzzzzz\",p = \"zz\",removable = [1, 3, 5, 7, 9]) == 5\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",p = \"abcdefghijklmnopqrstuvwxyz\",removable = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",p = \"zzzzz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 15\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"az\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 0\n assert candidate(s = \"abcdeffedcba\",p = \"abcdef\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 0\n assert candidate(s = \"mississippi\",p = \"issi\",removable = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(s = \"abcdefghijklmno\",p = \"def\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 3\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",p = \"zzzz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 16\n assert candidate(s = \"abcdefghijklmnop\",p = \"mnop\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 12\n assert candidate(s = \"banana\",p = \"ban\",removable = [0, 2, 4]) == 0\n assert candidate(s = \"aaaabbbbccccdddd\",p = \"abcd\",removable = [3, 7, 11, 15]) == 4\n assert candidate(s = \"abracadabra\",p = \"aca\",removable = [1, 3, 5, 7, 9]) == 5\n assert candidate(s = \"banana\",p = \"ban\",removable = [0, 1, 2, 3, 4, 5]) == 0\n assert candidate(s = \"abcdefffffghijklmnopqrstuvwxyz\",p = \"acegikmoqsuwy\",removable = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == 10\n assert candidate(s = \"aabbccddeeffgghhii\",p = \"abcdefghi\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == 9\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",p = \"abcdefghijklmnopqrstuvwxzy\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38]) == 0\n assert candidate(s = \"abcdabcdabcd\",p = \"abc\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 8\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",p = \"qz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(s = \"xyzzxyzzxyzz\",p = \"xyz\",removable = [0, 2, 4, 6, 8, 10]) == 4\n assert candidate(s = \"aaaaaaaaaaa\",p = \"aaaaa\",removable = [1, 3, 5, 7, 9]) == 5\n assert candidate(s = \"abababababababababab\",p = \"aabbaabb\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == 4\n assert candidate(s = \"xyzzxyzzxyzz\",p = \"xyz\",removable = [1, 3, 5, 7, 9, 11]) == 4\n assert candidate(s = \"mississippi\",p = \"issi\",removable = [3, 1, 0, 4, 5, 2, 6, 7, 8, 9, 10]) == 3\n assert candidate(s = \"abracadabra\",p = \"ac\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(s = \"bcaabcbabcabc\",p = \"abc\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",p = \"zzz\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"bdfhjlnprtvxz\",removable = [1, 5, 9, 13, 17, 21, 25]) == 0\n assert candidate(s = \"abcdeffedcba\",p = \"abcdef\",removable = [0, 2, 4, 6, 8, 10]) == 0\n assert candidate(s = \"mississippi\",p = \"miss\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"adgjmpsvy\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 0\n assert candidate(s = \"hellotherehowareyou\",p = \"heoy\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == 4\n assert candidate(s = \"aaaaabbbbbcccc\",p = \"abc\",removable = [5, 6, 7, 8, 9, 10]) == 4\n assert candidate(s = \"thisisaverylongstring\",p = \"tils\",removable = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 3\n assert candidate(s = \"leetcodeleetcodeleetcodeleetcode\",p = \"leetcodelt\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 16\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"acegikmoqsuwy\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 12\n assert candidate(s = \"abcdefghijabcdefghij\",p = \"acegik\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 0\n", "comparison": "exact"}, "public_tests": ["\"abcacb\"\n\"ab\"\n[3,1,0]", "\"abcbddddd\"\n\"abcd\"\n[3,2,1,4,5,6]", "\"abcab\"\n\"abc\"\n[0,1,2,3,4]"], "hints": ["First, we need to think about solving an easier problem, If we remove a set of indices from the string does P exist in S as a subsequence", "We can binary search the K and check by solving the above problem."], "metadata": {"canonical_parameter_names": ["s", "p", "removable"], "leetcode_dataset_entry_point": "Solution().maximumRemovals", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:20+00:00", "tests_total": 82, "tests_dropped": 17, "flags": [], "topic_tags": ["array", "two-pointers", "string", "binary-search"]}, "language": "python", "interface": {"raw_signature": "def maximumRemovals(self, s: str, p: str, removable: list[int]) -> int:", "container": "Solution", "callable": "maximumRemovals", "parameters": [{"name": "s", "type": "str"}, {"name": "p", "type": "str"}, {"name": "removable", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1899, "task_id": "merge-triplets-to-form-target-triplet", "difficulty": "Medium", "problem_description": "A triplet is an array of three integers. You are given a 2D integer array triplets, where triplets[i] = [a_i, b_i, c_i] describes the i^th triplet. You are also given an integer array target = [x, y, z] that describes the triplet you want to obtain.\n\nTo obtain target, you may apply the following operation on triplets any number of times (possibly zero):\n\n- Choose two indices (0-indexed) i and j (i != j) and update triplets[j] to become [max(a_i, a_j), max(b_i, b_j), max(c_i, c_j)].\n - For example, if triplets[i] = [2, 5, 3] and triplets[j] = [1, 7, 5], triplets[j] will be updated to [max(2, 1), max(5, 7), max(3, 5)] = [2, 7, 5].\n\nReturn true if it is possible to obtain the target triplet [x, y, z] as an element of triplets, or false otherwise.\n\nExample 1:\n\nInput: triplets = [[2,5,3],[1,8,4],[1,7,5]], target = [2,7,5]\nOutput: true\nExplanation: Perform the following operations:\n- Choose the first and last triplets [[2,5,3],[1,8,4],[1,7,5]]. Update the last triplet to be [max(2,1), max(5,7), max(3,5)] = [2,7,5]. triplets = [[2,5,3],[1,8,4],[2,7,5]]\nThe target triplet [2,7,5] is now an element of triplets.\n\nExample 2:\n\nInput: triplets = [[3,4,5],[4,5,6]], target = [3,2,5]\nOutput: false\nExplanation: It is impossible to have [3,2,5] as an element because there is no 2 in any of the triplets.\n\nExample 3:\n\nInput: triplets = [[2,5,3],[2,3,4],[1,2,5],[5,2,3]], target = [5,5,5]\nOutput: true\nExplanation: Perform the following operations:\n- Choose the first and third triplets [[2,5,3],[2,3,4],[1,2,5],[5,2,3]]. Update the third triplet to be [max(2,1), max(5,2), max(3,5)] = [2,5,5]. triplets = [[2,5,3],[2,3,4],[2,5,5],[5,2,3]].\n- Choose the third and fourth triplets [[2,5,3],[2,3,4],[2,5,5],[5,2,3]]. Update the fourth triplet to be [max(2,5), max(5,2), max(5,3)] = [5,5,5]. triplets = [[2,5,3],[2,3,4],[2,5,5],[5,5,5]].\nThe target triplet [5,5,5] is now an element of triplets.\n\nConstraints:\n\n- 1 <= triplets.length <= 10^5\n- triplets[i].length == target.length == 3\n- 1 <= a_i, b_i, c_i, x, y, z <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6]],target = [1, 2, 3]) == True\n assert candidate(triplets = [[3, 4, 5], [4, 5, 6]],target = [3, 2, 5]) == False\n assert candidate(triplets = [[2, 5, 3], [1, 8, 4], [1, 7, 5]],target = [2, 7, 5]) == True\n assert candidate(triplets = [[1000, 1000, 1000]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],target = [1, 2, 3]) == False\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [1, 2, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[2, 5, 3], [2, 3, 4], [1, 2, 5], [5, 2, 3]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 3, 3], [3, 1, 3], [3, 3, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 4], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1000, 1, 1], [1, 1000, 1], [1, 1, 1000], [500, 500, 500]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],target = [6, 6, 6]) == True\n assert candidate(triplets = [[1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 1, 3], [1, 3, 1], [3, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1]],target = [1, 2, 2]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]],target = [1, 2, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 1, 1], [10, 10, 10]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[100, 1, 1], [1, 100, 1], [1, 1, 100], [50, 50, 50], [10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40]],target = [50, 50, 50]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],target = [13, 14, 15]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10, 11]],target = [9, 10, 11]) == True\n assert candidate(triplets = [[999, 1, 1], [1, 999, 1], [1, 1, 999], [1000, 1000, 1000]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [3, 1, 2], [1, 3, 2], [2, 1, 3], [1, 1, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1], [1, 2, 1], [2, 1, 1]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[2, 5, 3], [1, 8, 4], [1, 7, 5], [3, 2, 1], [6, 6, 6], [9, 9, 9]],target = [3, 8, 9]) == False\n assert candidate(triplets = [[2, 5, 3], [1, 8, 4], [1, 7, 5], [3, 2, 1], [6, 6, 6], [9, 9, 9]],target = [2, 7, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]],target = [10, 10, 10]) == True\n assert candidate(triplets = [[2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]],target = [6, 7, 8]) == True\n assert candidate(triplets = [[1, 1000, 1], [2, 2, 999], [3, 3, 3], [4, 4, 4], [5, 5, 5]],target = [5, 1000, 999]) == True\n assert candidate(triplets = [[1000, 1, 1], [1, 1000, 1], [1, 1, 1000]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[999, 999, 999], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[1000, 1000, 1000], [999, 999, 999], [1, 1, 1]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 1], [10, 1, 2]],target = [10, 10, 10]) == True\n assert candidate(triplets = [[9, 8, 7], [6, 5, 4], [3, 2, 1], [10, 11, 12]],target = [10, 11, 12]) == True\n assert candidate(triplets = [[1000, 1000, 1000], [999, 999, 999], [998, 998, 998], [1, 2, 3]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [2, 2, 2], [2, 2, 2], [2, 2, 2], [3, 3, 3], [3, 3, 3], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [1, 3, 2]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [3, 2, 1]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1], [1, 1, 1], [2, 2, 2], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 3, 1], [2, 1, 2], [3, 2, 3], [4, 3, 4], [5, 4, 5]],target = [5, 5, 5]) == False\n assert candidate(triplets = [[1, 2, 3], [1, 2, 2], [2, 2, 3], [2, 2, 2], [3, 2, 3], [3, 2, 2], [3, 3, 3], [6, 6, 6], [9, 9, 9]],target = [9, 9, 9]) == True\n assert candidate(triplets = [[9, 5, 1], [5, 9, 1], [1, 9, 5], [5, 1, 9], [9, 1, 5]],target = [9, 9, 9]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1000, 1, 1], [1, 1000, 1], [1, 1, 1000], [1000, 1000, 1000]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 3, 2], [3, 2, 1], [2, 1, 3], [4, 4, 4]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 9, 1], [1, 1, 9], [9, 1, 1], [9, 9, 9], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[3, 3, 3], [3, 3, 3], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5]],target = [3, 3, 4]) == True\n assert candidate(triplets = [[1, 3, 1], [2, 1, 2], [3, 2, 1], [1, 2, 3], [2, 3, 1], [3, 1, 2]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 9, 9], [9, 1, 9], [9, 9, 1], [3, 3, 3], [2, 2, 2], [4, 4, 4]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [2, 3, 4], [5, 6, 7], [8, 9, 10], [3, 4, 5], [6, 7, 8], [9, 10, 11]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 3, 5], [3, 5, 1], [5, 1, 3], [2, 4, 6], [4, 6, 2], [6, 2, 4]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 3], [1, 2, 3], [2, 3, 4], [2, 3, 4]],target = [2, 3, 4]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 1, 1], [10, 10, 10], [2, 2, 2], [3, 3, 3], [5, 5, 5]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]],target = [7, 7, 7]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 4], [2, 3, 4], [3, 4, 5], [4, 5, 6]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 2], [2, 1, 1], [2, 1, 2], [1, 2, 1], [1, 2, 2], [2, 2, 1], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [1, 5, 1], [5, 1, 5], [1, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[10, 20, 30], [10, 25, 35], [15, 25, 30], [10, 20, 35], [10, 25, 30], [15, 20, 30]],target = [15, 25, 30]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [1, 5, 6], [4, 2, 6], [4, 5, 3]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 3, 5], [2, 2, 2], [3, 1, 4], [4, 4, 4], [5, 5, 5]],target = [5, 4, 5]) == False\n assert candidate(triplets = [[1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 2, 2], [2, 2, 1], [2, 1, 2], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],target = [15, 15, 15]) == False\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [999, 999, 999]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[2, 5, 3], [1, 8, 4], [1, 7, 5], [2, 7, 5], [5, 7, 5], [2, 7, 9]],target = [2, 7, 5]) == True\n assert candidate(triplets = [[1, 1, 2], [1, 2, 1], [2, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[5, 1, 1], [1, 5, 1], [1, 1, 5], [1, 1, 1], [1, 1, 1]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 2, 2], [2, 2, 2], [2, 3, 3], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [1, 2, 3], [2, 1, 3], [3, 2, 1]],target = [3, 3, 3]) == False\n assert candidate(triplets = [[500, 1, 1], [1, 500, 1], [1, 1, 500], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [500, 500, 500]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]],target = [6, 7, 8]) == True\n assert candidate(triplets = [[1, 100, 1], [100, 1, 1], [1, 1, 100], [100, 100, 1], [100, 1, 100], [1, 100, 100]],target = [100, 100, 100]) == True\n assert candidate(triplets = [[1, 5, 3], [1, 8, 4], [1, 7, 5], [1, 7, 9], [2, 5, 5], [1, 8, 8], [1, 7, 7]],target = [1, 8, 8]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 2, 1], [1, 1, 2], [2, 1, 1], [2, 2, 1], [2, 1, 2], [1, 2, 2], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],target = [10, 11, 12]) == True\n assert candidate(triplets = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50]],target = [30, 30, 30]) == True\n assert candidate(triplets = [[2, 1, 1], [1, 2, 1], [1, 1, 2], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[100, 200, 300], [300, 400, 500], [500, 600, 700], [700, 800, 900], [900, 1000, 100], [100, 300, 500], [200, 400, 600]],target = [100, 400, 600]) == False\n assert candidate(triplets = [[1000, 1000, 1000], [1000, 1000, 1000], [1000, 1000, 1000], [1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 2], [1, 2, 1], [2, 1, 1]],target = [1, 1, 2]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 2], [2, 2, 3], [2, 2, 2], [3, 2, 3], [3, 2, 2], [3, 3, 3], [6, 6, 6], [9, 9, 9]],target = [6, 6, 6]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]],target = [5, 6, 7]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [2, 1, 3], [3, 1, 2], [1, 3, 2], [1, 1, 1], [999, 999, 999]],target = [2, 2, 2]) == False\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],target = [9, 9, 9]) == True\n assert candidate(triplets = [[1, 999, 1], [999, 1, 1], [1, 1, 999], [999, 999, 1], [999, 1, 999], [1, 999, 999], [999, 999, 999]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[5, 1, 1], [1, 5, 1], [1, 1, 5], [5, 5, 1], [5, 1, 5], [1, 5, 5], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 1, 1], [10, 10, 10], [2, 2, 2], [3, 3, 3], [5, 5, 5]],target = [10, 10, 10]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [1, 3, 2], [3, 1, 2], [2, 1, 3], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 999], [1, 999, 1], [999, 1, 1], [999, 999, 1], [999, 1, 999], [999, 999, 999]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 2], [2, 2, 3], [2, 2, 2], [3, 2, 3], [3, 2, 2], [3, 3, 3], [6, 6, 6], [9, 9, 9]],target = [3, 2, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1], [2, 2, 2], [2, 2, 3]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1], [2, 1, 3], [1, 3, 2]],target = [1, 2, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[500, 500, 500], [1, 1, 1], [1000, 1000, 1000], [250, 250, 250], [750, 750, 750]],target = [500, 500, 500]) == True\n assert candidate(triplets = [[1, 1000, 1000], [1000, 1, 1000], [1000, 1000, 1], [250, 250, 250], [500, 500, 500], [750, 750, 750]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[3, 4, 5], [5, 6, 7], [8, 9, 10], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]],target = [8, 9, 10]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]],target = [5, 6, 7]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]],target = [5, 6, 7]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 2], [2, 2, 3], [2, 2, 2], [3, 2, 3], [3, 2, 2], [3, 3, 3]],target = [3, 2, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 3, 4], [5, 6, 7], [1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1], [2, 2, 2]],target = [2, 2, 2]) == True\n", "comparison": "exact"}, "public_tests": ["[[2,5,3],[1,8,4],[1,7,5]]\n[2,7,5]", "[[3,4,5],[4,5,6]]\n[3,2,5]", "[[2,5,3],[2,3,4],[1,2,5],[5,2,3]]\n[5,5,5]"], "hints": ["Which triplets do you actually care about?", "What property of max can you use to solve the problem?"], "metadata": {"canonical_parameter_names": ["triplets", "target"], "leetcode_dataset_entry_point": "Solution().mergeTriplets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:23+00:00", "tests_total": 119, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def mergeTriplets(self, triplets: list[list[int]], target: list[int]) -> bool:", "container": "Solution", "callable": "mergeTriplets", "parameters": [{"name": "triplets", "type": "list[list[int]]"}, {"name": "target", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1900, "task_id": "the-earliest-and-latest-rounds-where-players-compete", "difficulty": "Hard", "problem_description": "There is a tournament where n players are participating. The players are standing in a single row and are numbered from 1 to n based on their initial standing position (player 1 is the first player in the row, player 2 is the second player in the row, etc.).\n\nThe tournament consists of multiple rounds (starting from round number 1). In each round, the i^th player from the front of the row competes against the i^th player from the end of the row, and the winner advances to the next round. When the number of players is odd for the current round, the player in the middle automatically advances to the next round.\n\n- For example, if the row consists of players 1, 2, 4, 6, 7\n - Player 1 competes against player 7.\n - Player 2 competes against player 6.\n - Player 4 automatically advances to the next round.\n\nAfter each round is over, the winners are lined back up in the row based on the original ordering assigned to them initially (ascending order).\n\nThe players numbered firstPlayer and secondPlayer are the best in the tournament. They can win against any other player before they compete against each other. If any two other players compete against each other, either of them might win, and thus you may choose the outcome of this round.\n\nGiven the integers n, firstPlayer, and secondPlayer, return an integer array containing two values, the earliest possible round number and the latest possible round number in which these two players will compete against each other, respectively.\n\nExample 1:\n\nInput: n = 11, firstPlayer = 2, secondPlayer = 4\nOutput: [3,4]\nExplanation:\nOne possible scenario which leads to the earliest round number:\nFirst round: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11\nSecond round: 2, 3, 4, 5, 6, 11\nThird round: 2, 3, 4\nOne possible scenario which leads to the latest round number:\nFirst round: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11\nSecond round: 1, 2, 3, 4, 5, 6\nThird round: 1, 2, 4\nFourth round: 2, 4\n\nExample 2:\n\nInput: n = 5, firstPlayer = 1, secondPlayer = 5\nOutput: [1,1]\nExplanation: The players numbered 1 and 5 compete in the first round.\nThere is no way to make them compete in any other round.\n\nConstraints:\n\n- 2 <= n <= 28\n- 1 <= firstPlayer < secondPlayer <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,firstPlayer = 4,secondPlayer = 9) == [2, 4]\n assert candidate(n = 28,firstPlayer = 5,secondPlayer = 24) == [1, 1]\n assert candidate(n = 16,firstPlayer = 5,secondPlayer = 12) == [1, 1]\n assert candidate(n = 5,firstPlayer = 1,secondPlayer = 5) == [1, 1]\n assert candidate(n = 28,firstPlayer = 10,secondPlayer = 20) == [2, 5]\n assert candidate(n = 8,firstPlayer = 2,secondPlayer = 7) == [1, 1]\n assert candidate(n = 28,firstPlayer = 3,secondPlayer = 26) == [1, 1]\n assert candidate(n = 10,firstPlayer = 3,secondPlayer = 8) == [1, 1]\n assert candidate(n = 7,firstPlayer = 2,secondPlayer = 6) == [1, 1]\n assert candidate(n = 8,firstPlayer = 3,secondPlayer = 6) == [1, 1]\n assert candidate(n = 11,firstPlayer = 2,secondPlayer = 4) == [3, 4]\n assert candidate(n = 16,firstPlayer = 3,secondPlayer = 14) == [1, 1]\n assert candidate(n = 22,firstPlayer = 4,secondPlayer = 19) == [1, 1]\n assert candidate(n = 19,firstPlayer = 1,secondPlayer = 19) == [1, 1]\n assert candidate(n = 15,firstPlayer = 7,secondPlayer = 13) == [2, 4]\n assert candidate(n = 18,firstPlayer = 6,secondPlayer = 13) == [1, 1]\n assert candidate(n = 18,firstPlayer = 5,secondPlayer = 16) == [2, 5]\n assert candidate(n = 27,firstPlayer = 12,secondPlayer = 18) == [2, 5]\n assert candidate(n = 20,firstPlayer = 7,secondPlayer = 16) == [2, 5]\n assert candidate(n = 25,firstPlayer = 10,secondPlayer = 20) == [2, 5]\n assert candidate(n = 20,firstPlayer = 5,secondPlayer = 15) == [2, 5]\n assert candidate(n = 18,firstPlayer = 2,secondPlayer = 17) == [1, 1]\n assert candidate(n = 15,firstPlayer = 2,secondPlayer = 14) == [1, 1]\n assert candidate(n = 19,firstPlayer = 7,secondPlayer = 16) == [2, 5]\n assert candidate(n = 24,firstPlayer = 6,secondPlayer = 19) == [1, 1]\n assert candidate(n = 27,firstPlayer = 8,secondPlayer = 20) == [1, 1]\n assert candidate(n = 19,firstPlayer = 8,secondPlayer = 17) == [2, 5]\n assert candidate(n = 13,firstPlayer = 3,secondPlayer = 10) == [2, 4]\n assert candidate(n = 23,firstPlayer = 10,secondPlayer = 19) == [2, 5]\n assert candidate(n = 28,firstPlayer = 10,secondPlayer = 22) == [2, 5]\n assert candidate(n = 25,firstPlayer = 7,secondPlayer = 19) == [1, 1]\n assert candidate(n = 22,firstPlayer = 7,secondPlayer = 18) == [2, 5]\n assert candidate(n = 20,firstPlayer = 5,secondPlayer = 16) == [1, 1]\n assert candidate(n = 27,firstPlayer = 11,secondPlayer = 23) == [2, 5]\n assert candidate(n = 13,firstPlayer = 4,secondPlayer = 10) == [1, 1]\n assert candidate(n = 19,firstPlayer = 3,secondPlayer = 17) == [1, 1]\n assert candidate(n = 21,firstPlayer = 9,secondPlayer = 18) == [2, 5]\n assert candidate(n = 24,firstPlayer = 10,secondPlayer = 23) == [2, 5]\n assert candidate(n = 22,firstPlayer = 7,secondPlayer = 17) == [3, 5]\n assert candidate(n = 15,firstPlayer = 7,secondPlayer = 9) == [1, 1]\n assert candidate(n = 27,firstPlayer = 9,secondPlayer = 20) == [3, 5]\n assert candidate(n = 24,firstPlayer = 10,secondPlayer = 15) == [1, 1]\n assert candidate(n = 24,firstPlayer = 8,secondPlayer = 17) == [1, 1]\n assert candidate(n = 18,firstPlayer = 6,secondPlayer = 15) == [2, 5]\n assert candidate(n = 24,firstPlayer = 9,secondPlayer = 15) == [2, 5]\n assert candidate(n = 23,firstPlayer = 9,secondPlayer = 15) == [1, 1]\n assert candidate(n = 12,firstPlayer = 5,secondPlayer = 8) == [1, 1]\n assert candidate(n = 25,firstPlayer = 7,secondPlayer = 18) == [2, 5]\n assert candidate(n = 25,firstPlayer = 2,secondPlayer = 24) == [1, 1]\n assert candidate(n = 27,firstPlayer = 12,secondPlayer = 24) == [2, 5]\n assert candidate(n = 15,firstPlayer = 3,secondPlayer = 13) == [1, 1]\n assert candidate(n = 21,firstPlayer = 6,secondPlayer = 16) == [1, 1]\n assert candidate(n = 19,firstPlayer = 4,secondPlayer = 18) == [2, 4]\n assert candidate(n = 22,firstPlayer = 6,secondPlayer = 19) == [2, 5]\n assert candidate(n = 28,firstPlayer = 2,secondPlayer = 27) == [1, 1]\n assert candidate(n = 25,firstPlayer = 4,secondPlayer = 22) == [1, 1]\n assert candidate(n = 13,firstPlayer = 3,secondPlayer = 11) == [1, 1]\n assert candidate(n = 13,firstPlayer = 3,secondPlayer = 9) == [2, 4]\n assert candidate(n = 28,firstPlayer = 1,secondPlayer = 28) == [1, 1]\n assert candidate(n = 23,firstPlayer = 11,secondPlayer = 20) == [2, 5]\n assert candidate(n = 17,firstPlayer = 3,secondPlayer = 15) == [1, 1]\n assert candidate(n = 14,firstPlayer = 3,secondPlayer = 10) == [2, 4]\n assert candidate(n = 12,firstPlayer = 3,secondPlayer = 9) == [2, 4]\n assert candidate(n = 25,firstPlayer = 8,secondPlayer = 19) == [2, 5]\n assert candidate(n = 28,firstPlayer = 12,secondPlayer = 18) == [2, 5]\n assert candidate(n = 22,firstPlayer = 9,secondPlayer = 14) == [1, 1]\n assert candidate(n = 24,firstPlayer = 9,secondPlayer = 21) == [2, 5]\n assert candidate(n = 19,firstPlayer = 9,secondPlayer = 17) == [2, 5]\n assert candidate(n = 17,firstPlayer = 4,secondPlayer = 15) == [2, 4]\n assert candidate(n = 19,firstPlayer = 6,secondPlayer = 14) == [1, 1]\n assert candidate(n = 21,firstPlayer = 7,secondPlayer = 15) == [1, 1]\n assert candidate(n = 27,firstPlayer = 2,secondPlayer = 25) == [3, 3]\n assert candidate(n = 17,firstPlayer = 6,secondPlayer = 12) == [1, 1]\n assert candidate(n = 17,firstPlayer = 5,secondPlayer = 13) == [1, 1]\n assert candidate(n = 18,firstPlayer = 4,secondPlayer = 15) == [1, 1]\n assert candidate(n = 21,firstPlayer = 10,secondPlayer = 12) == [1, 1]\n assert candidate(n = 15,firstPlayer = 4,secondPlayer = 11) == [3, 4]\n assert candidate(n = 21,firstPlayer = 6,secondPlayer = 19) == [2, 5]\n assert candidate(n = 19,firstPlayer = 8,secondPlayer = 15) == [2, 5]\n assert candidate(n = 20,firstPlayer = 7,secondPlayer = 14) == [1, 1]\n assert candidate(n = 25,firstPlayer = 8,secondPlayer = 20) == [2, 5]\n assert candidate(n = 27,firstPlayer = 4,secondPlayer = 23) == [3, 5]\n assert candidate(n = 20,firstPlayer = 3,secondPlayer = 18) == [1, 1]\n assert candidate(n = 26,firstPlayer = 13,secondPlayer = 22) == [2, 5]\n assert candidate(n = 18,firstPlayer = 5,secondPlayer = 14) == [1, 1]\n assert candidate(n = 21,firstPlayer = 6,secondPlayer = 15) == [3, 5]\n assert candidate(n = 28,firstPlayer = 10,secondPlayer = 25) == [2, 5]\n", "comparison": "exact"}, "public_tests": ["11\n2\n4", "5\n1\n5"], "hints": ["Brute force using bitmasks and simulate the rounds.", "Calculate each state one time and save its solution."], "metadata": {"canonical_parameter_names": ["n", "firstPlayer", "secondPlayer"], "leetcode_dataset_entry_point": "Solution().earliestAndLatest", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:25+00:00", "tests_total": 87, "tests_dropped": 0, "flags": [], "topic_tags": ["dynamic-programming", "memoization"]}, "language": "python", "interface": {"raw_signature": "def earliestAndLatest(self, n: int, firstPlayer: int, secondPlayer: int) -> list[int]:", "container": "Solution", "callable": "earliestAndLatest", "parameters": [{"name": "n", "type": "int"}, {"name": "firstPlayer", "type": "int"}, {"name": "secondPlayer", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1901, "task_id": "find-a-peak-element-ii", "difficulty": "Medium", "problem_description": "A peak element in a 2D grid is an element that is strictly greater than all of its adjacent neighbors to the left, right, top, and bottom.\n\nGiven a 0-indexed m x n matrix mat where no two adjacent cells are equal, find any peak element mat[i][j] and return the length 2 array [i,j].\n\nYou may assume that the entire matrix is surrounded by an outer perimeter with the value -1 in each cell.\n\nYou must write an algorithm that runs in O(m log(n)) or O(n log(m)) time.\n\nExample 1:\n\nInput: mat = [[1,4],[3,2]]\nOutput: [0,1]\nExplanation: Both 3 and 4 are peak elements so [1,0] and [0,1] are both acceptable answers.\n\nExample 2:\n\nInput: mat = [[10,20,15],[21,30,14],[7,16,32]]\nOutput: [1,1]\nExplanation: Both 30 and 32 are peak elements so [1,1] and [2,2] are both acceptable answers.\n\nConstraints:\n\n- m == mat.length\n- n == mat[i].length\n- 1 <= m, n <= 500\n- 1 <= mat[i][j] <= 10^5\n- No two adjacent cells are equal.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1]]) == [0, 0]\n assert candidate(mat = [[1, 2, 3, 4, 5], [16, 17, 18, 19, 6], [15, 24, 25, 20, 7], [14, 23, 22, 21, 8], [13, 12, 11, 10, 9]]) == [2, 2]\n assert candidate(mat = [[1, 2, 3, 4, 5], [16, 17, 24, 25, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 18]]) == [1, 3]\n assert candidate(mat = [[10, 20, 15], [21, 30, 14], [7, 16, 32]]) == [1, 1]\n assert candidate(mat = [[1, 3, 5, 7], [10, 11, 16, 20], [23, 30, 34, 60]]) == [2, 3]\n assert candidate(mat = [[1, 4], [3, 2]]) == [0, 1]\n assert candidate(mat = [[5, 25, 15, 10], [100, 101, 102, 103], [99, 98, 97, 96], [50, 49, 48, 47]]) == [1, 3]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]]) == [2, 9]\n assert candidate(mat = [[1, 10, 20, 10, 1], [10, 20, 30, 20, 10], [20, 30, 40, 30, 20], [10, 20, 30, 20, 10], [1, 10, 20, 10, 1]]) == [2, 2]\n assert candidate(mat = [[1, 5, 9, 12], [10, 20, 25, 16], [8, 18, 24, 13], [7, 17, 19, 21]]) == [1, 2]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [9, 21, 29, 39, 49, 59, 69, 79, 89, 101], [8, 22, 28, 38, 48, 58, 68, 78, 88, 102], [7, 23, 27, 37, 47, 57, 67, 77, 87, 103], [6, 24, 26, 36, 46, 56, 66, 76, 86, 104], [5, 25, 25, 35, 45, 55, 65, 75, 85, 105], [4, 26, 24, 34, 44, 54, 64, 74, 84, 106], [3, 27, 23, 33, 43, 53, 63, 73, 83, 107], [2, 28, 22, 32, 42, 52, 62, 72, 82, 108], [1, 29, 21, 31, 41, 51, 61, 71, 81, 109]]) == [9, 9]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [8, 7, 6, 5, 4, 3, 2, 1, 10], [9, 10, 11, 12, 13, 14, 15, 16, 17], [16, 15, 14, 13, 12, 11, 10, 9, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27], [26, 25, 24, 23, 22, 21, 20, 19, 28], [29, 30, 31, 32, 33, 34, 35, 36, 37]]) == [6, 8]\n assert candidate(mat = [[999, 998, 997], [996, 995, 994], [993, 992, 991], [990, 989, 988], [987, 986, 985], [984, 983, 982], [981, 980, 979], [978, 977, 976], [975, 974, 973], [972, 971, 970]]) == [0, 0]\n assert candidate(mat = [[30, 27, 24, 21, 18, 15], [29, 26, 23, 20, 17, 14], [28, 25, 22, 19, 16, 13], [27, 24, 21, 18, 15, 12], [26, 23, 20, 17, 14, 11], [25, 22, 19, 16, 13, 10]]) == [0, 0]\n assert candidate(mat = [[100000, 99999, 99998], [99997, 99996, 99995], [99994, 99993, 99992], [99991, 99990, 99989], [99988, 99987, 99986]]) == [0, 0]\n assert candidate(mat = [[1, 2, 3, 4, 5], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == [2, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [15, 16, 17, 18, 19, 7], [14, 23, 24, 25, 20, 8], [13, 22, 31, 32, 21, 9], [12, 21, 30, 33, 22, 10], [11, 20, 29, 28, 27, 16]]) == [4, 3]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [25, 26, 27, 28, 29, 30, 31, 32, 10], [24, 39, 40, 41, 42, 43, 44, 33, 11], [23, 38, 51, 52, 53, 54, 45, 34, 12], [22, 37, 50, 59, 60, 55, 46, 35, 13], [21, 36, 49, 58, 61, 56, 47, 36, 14], [20, 35, 48, 57, 62, 50, 40, 30, 15], [19, 34, 47, 56, 63, 49, 39, 29, 16], [18, 33, 46, 55, 64, 48, 38, 28, 17]]) == [8, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == [2, 19]\n assert candidate(mat = [[50, 1, 100, 200, 300, 400, 500], [600, 501, 101, 201, 301, 401, 501], [601, 602, 102, 202, 302, 402, 502], [603, 604, 103, 203, 303, 403, 503], [604, 605, 104, 204, 304, 404, 504], [605, 606, 105, 205, 305, 405, 505]]) == [5, 1]\n assert candidate(mat = [[3, 8, 4, 5, 7], [2, 9, 6, 10, 3], [5, 7, 11, 12, 8], [1, 6, 9, 13, 4]]) == [3, 3]\n assert candidate(mat = [[100, 101, 102, 103, 104], [109, 108, 107, 106, 105], [110, 111, 112, 113, 114], [119, 118, 117, 116, 115]]) == [3, 0]\n assert candidate(mat = [[5, 25, 20], [15, 30, 21], [10, 19, 22], [14, 28, 27], [9, 23, 24]]) == [3, 1]\n assert candidate(mat = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]]) == [0, 24]\n assert candidate(mat = [[1, 3, 5, 7, 9], [10, 8, 6, 4, 2], [3, 5, 7, 9, 11], [12, 10, 8, 6, 4], [5, 7, 9, 11, 13]]) == [0, 4]\n assert candidate(mat = [[100, 200, 300, 400], [150, 250, 350, 450], [125, 225, 325, 425], [175, 275, 375, 475]]) == [1, 3]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [18, 17, 16, 15, 14, 13, 12, 11, 10], [19, 20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42, 43, 44, 45]]) == [4, 8]\n assert candidate(mat = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [10, 9, 8, 7, 6, 5, 4, 3, 2], [11, 10, 9, 8, 7, 6, 5, 4, 3], [12, 11, 10, 9, 8, 7, 6, 5, 4], [13, 12, 11, 10, 9, 8, 7, 6, 5]]) == [4, 0]\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15]]) == [2, 4]\n assert candidate(mat = [[1, 3, 5, 7, 9, 11], [12, 14, 16, 18, 20, 19], [13, 15, 17, 19, 21, 22], [25, 24, 23, 22, 21, 20], [26, 27, 28, 29, 30, 31]]) == [2, 5]\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [3, 5, 7, 9, 11, 13, 15], [4, 6, 8, 10, 12, 14, 16], [5, 7, 9, 11, 13, 15, 17]]) == [4, 6]\n assert candidate(mat = [[1, 2, 3, 4, 5], [16, 17, 18, 19, 6], [15, 24, 25, 20, 7], [14, 23, 22, 21, 8], [13, 12, 11, 10, 9], [26, 27, 28, 29, 30]]) == [2, 2]\n assert candidate(mat = [[5, 2, 1, 6, 7, 8, 10, 4, 9, 1], [15, 14, 13, 16, 17, 18, 20, 19, 21, 2], [22, 23, 24, 25, 26, 27, 28, 29, 30, 31]]) == [2, 9]\n assert candidate(mat = [[1, 2, 3], [6, 5, 4], [7, 8, 9]]) == [2, 2]\n assert candidate(mat = [[5, 25, 9, 20, 15], [30, 35, 28, 33, 26], [29, 40, 31, 36, 27], [24, 39, 32, 37, 34], [23, 38, 21, 22, 16]]) == [2, 1]\n assert candidate(mat = [[20, 30, 25, 10, 15], [100, 120, 115, 80, 85], [75, 82, 87, 55, 60], [65, 70, 67, 78, 77]]) == [1, 1]\n assert candidate(mat = [[10, 100, 1000], [9, 99, 999], [8, 88, 888], [7, 77, 777], [6, 66, 666], [5, 55, 555], [4, 44, 444], [3, 33, 333], [2, 22, 222], [1, 11, 111]]) == [0, 2]\n assert candidate(mat = [[2, 1, 3, 4, 5, 6, 7, 8, 9], [1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [2, 0]\n assert candidate(mat = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == [9, 0]\n assert candidate(mat = [[5, 2, 15, 10, 20], [6, 21, 16, 14, 19], [7, 17, 25, 23, 18], [8, 18, 24, 30, 22], [9, 29, 26, 27, 31]]) == [0, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [1, 0]\n assert candidate(mat = [[5, 10, 15, 20, 25], [9, 14, 19, 24, 29], [13, 18, 23, 28, 33], [17, 22, 27, 32, 37], [21, 26, 31, 36, 41]]) == [4, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]) == [0, 9]\n assert candidate(mat = [[50, 51, 52, 53, 54, 55, 56, 57, 58, 59], [100, 101, 102, 103, 104, 105, 106, 107, 108, 109], [99, 98, 97, 96, 95, 94, 93, 92, 91, 90], [80, 81, 82, 83, 84, 85, 86, 87, 88, 89], [79, 78, 77, 76, 75, 74, 73, 72, 71, 70], [60, 61, 62, 63, 64, 65, 66, 67, 68, 69], [59, 58, 57, 56, 55, 54, 53, 52, 51, 50], [40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [39, 38, 37, 36, 35, 34, 33, 32, 31, 30]]) == [1, 9]\n assert candidate(mat = [[1, 2, 3, 4], [8, 7, 6, 5], [9, 10, 11, 12], [16, 15, 14, 13], [17, 18, 19, 20]]) == [4, 3]\n assert candidate(mat = [[9, 8, 7, 6], [8, 7, 6, 5], [7, 6, 5, 4], [6, 5, 4, 3], [5, 4, 3, 2]]) == [0, 0]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [20, 19, 18, 17, 16, 15], [21, 22, 23, 24, 25, 26], [32, 31, 30, 29, 28, 27], [33, 34, 35, 36, 37, 38], [44, 43, 42, 41, 40, 39]]) == [5, 0]\n assert candidate(mat = [[10, 100, 30, 200, 40, 300], [9, 190, 25, 210, 35, 310], [18, 180, 27, 220, 45, 320], [17, 170, 26, 230, 44, 330], [16, 160, 24, 240, 43, 340], [15, 150, 23, 250, 42, 350]]) == [5, 5]\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]]) == [4, 4]\n assert candidate(mat = [[50, 49, 48, 47, 46, 45, 44, 43, 42, 41], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90]]) == [4, 9]\n assert candidate(mat = [[1, 10, 8, 11, 9], [16, 17, 18, 19, 6], [15, 24, 25, 20, 7], [14, 23, 22, 21, 8], [13, 12, 11, 10, 15]]) == [2, 2]\n assert candidate(mat = [[1, 100, 200, 300, 400, 500], [600, 501, 502, 503, 504, 505], [700, 601, 701, 702, 703, 704], [800, 701, 801, 802, 803, 804], [900, 801, 901, 902, 903, 904]]) == [4, 5]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [30, 31, 32, 33, 34, 35, 36, 37, 38, 39], [49, 48, 47, 46, 45, 44, 43, 42, 41, 40]]) == [3, 0]\n assert candidate(mat = [[1000, 999, 998, 997, 996], [995, 994, 993, 992, 991], [990, 989, 988, 987, 986], [985, 984, 983, 982, 981], [980, 979, 978, 977, 976]]) == [0, 0]\n assert candidate(mat = [[30, 28, 19, 27, 22], [25, 31, 26, 23, 21], [24, 29, 32, 20, 18], [17, 22, 21, 16, 15], [13, 14, 12, 11, 10]]) == [0, 0]\n assert candidate(mat = [[100, 101, 102, 103, 104, 105], [99, 106, 107, 108, 109, 110], [98, 111, 112, 113, 114, 115], [97, 116, 117, 118, 119, 120], [96, 121, 122, 123, 124, 125], [95, 126, 127, 128, 129, 130]]) == [5, 5]\n assert candidate(mat = [[5, 3, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15], [19, 18, 17, 16, 23, 22], [27, 28, 29, 30, 25, 24], [34, 33, 32, 31, 38, 37], [43, 42, 41, 40, 47, 46]]) == [5, 4]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1]]) == [3, 0]\n assert candidate(mat = [[1, 3, 2], [4, 6, 5], [7, 9, 8], [10, 12, 11], [13, 15, 14]]) == [4, 1]\n assert candidate(mat = [[1, 5, 7, 4, 6], [9, 8, 2, 1, 3], [12, 15, 13, 11, 10], [17, 18, 16, 20, 21]]) == [3, 4]\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]]) == [0, 9]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [0, 19]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60, 70], [70, 60, 50, 40, 30, 20, 10], [10, 30, 50, 70, 90, 110, 130], [130, 110, 90, 70, 50, 30, 10]]) == [0, 6]\n assert candidate(mat = [[100, 200, 300, 400], [400, 300, 200, 100], [100, 200, 300, 400], [400, 300, 200, 100]]) == [0, 3]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]]) == [4, 9]\n assert candidate(mat = [[1, 5, 9, 4], [6, 7, 3, 8], [2, 11, 13, 12], [10, 14, 15, 16]]) == [3, 3]\n assert candidate(mat = [[5, 20, 15, 25], [9, 10, 12, 8], [14, 6, 30, 7], [13, 16, 11, 18]]) == [2, 2]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60], [61, 62, 63, 64, 65, 59], [70, 69, 68, 67, 66, 71], [72, 73, 74, 75, 76, 77], [78, 79, 80, 81, 82, 83]]) == [4, 5]\n assert candidate(mat = [[50, 49, 48, 47, 46], [45, 44, 43, 42, 41], [40, 39, 38, 37, 36], [35, 34, 33, 32, 31], [30, 29, 28, 27, 26]]) == [0, 0]\n assert candidate(mat = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [12, 11, 10]]) == [3, 0]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]]) == [6, 2]\n assert candidate(mat = [[100, 200, 300, 400, 500, 600, 700, 800, 900], [901, 801, 701, 601, 501, 401, 301, 201, 101], [102, 202, 302, 402, 502, 602, 702, 802, 902], [903, 803, 703, 603, 503, 403, 303, 203, 103], [104, 204, 304, 404, 504, 604, 704, 804, 904], [905, 805, 705, 605, 505, 405, 305, 205, 105], [106, 206, 306, 406, 506, 606, 706, 806, 906], [907, 807, 707, 607, 507, 407, 307, 207, 107]]) == [0, 8]\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7]]) == [0, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2]]) == [0, 8]\n assert candidate(mat = [[100, 200, 300, 400, 500], [501, 502, 503, 504, 505], [1000, 1001, 1002, 1003, 1004], [1501, 1502, 1503, 1504, 1505], [2000, 2001, 2002, 2003, 2004]]) == [4, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [4, 4]\n assert candidate(mat = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == [9, 0]\n assert candidate(mat = [[10, 11, 12, 13, 14, 15, 16], [9, 8, 7, 6, 5, 4, 3], [2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7]]) == [0, 6]\n assert candidate(mat = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70], [35, 45, 55, 65, 75]]) == [5, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]]) == [4, 4]\n assert candidate(mat = [[1, 1000, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [0, 1]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60], [5, 15, 25, 35, 45, 55], [40, 50, 60, 70, 80, 90], [35, 45, 55, 65, 75, 85], [25, 35, 45, 55, 65, 75], [15, 25, 35, 45, 55, 65]]) == [2, 5]\n assert candidate(mat = [[5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [4, 4]\n assert candidate(mat = [[5, 20, 3, 5, 6], [21, 22, 23, 24, 5], [1, 2, 3, 25, 26], [17, 18, 19, 28, 29], [30, 31, 32, 33, 34]]) == [4, 4]\n assert candidate(mat = [[20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [0, 0]\n", "comparison": "exact"}, "public_tests": ["[[1,4],[3,2]]", "[[10,20,15],[21,30,14],[7,16,32]]"], "hints": ["Let's assume that the width of the array is bigger than the height, otherwise, we will split in another direction.", "Split the array into three parts: central column left side and right side.", "Go through the central column and two neighbor columns and look for maximum.", "If it's in the central column - this is our peak.", "If it's on the left side, run this algorithm on subarray left_side + central_column.", "If it's on the right side, run this algorithm on subarray right_side + central_column"], "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().findPeakGrid", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:27+00:00", "tests_total": 85, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def findPeakGrid(self, mat: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "findPeakGrid", "parameters": [{"name": "mat", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1903, "task_id": "largest-odd-number-in-string", "difficulty": "Easy", "problem_description": "You are given a string num, representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of num, or an empty string \"\" if no odd integer exists.\n\nA substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: num = \"52\"\nOutput: \"5\"\nExplanation: The only non-empty substrings are \"5\", \"2\", and \"52\". \"5\" is the only odd number.\n\nExample 2:\n\nInput: num = \"4206\"\nOutput: \"\"\nExplanation: There are no odd numbers in \"4206\".\n\nExample 3:\n\nInput: num = \"35427\"\nOutput: \"35427\"\nExplanation: \"35427\" is already an odd number.\n\nConstraints:\n\n- 1 <= num.length <= 10^5\n- num only consists of digits and does not contain any leading zeros.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"52\") == \"5\"\n assert candidate(num = \"9\") == \"9\"\n assert candidate(num = \"86420\") == \"\"\n assert candidate(num = \"1111111111\") == \"1111111111\"\n assert candidate(num = \"2468\") == \"\"\n assert candidate(num = \"1\") == \"1\"\n assert candidate(num = \"9876543210\") == \"987654321\"\n assert candidate(num = \"0\") == \"\"\n assert candidate(num = \"98765\") == \"98765\"\n assert candidate(num = \"2468013579\") == \"2468013579\"\n assert candidate(num = \"2222222222\") == \"\"\n assert candidate(num = \"8\") == \"\"\n assert candidate(num = \"987654321\") == \"987654321\"\n assert candidate(num = \"2\") == \"\"\n assert candidate(num = \"56789\") == \"56789\"\n assert candidate(num = \"321\") == \"321\"\n assert candidate(num = \"123\") == \"123\"\n assert candidate(num = \"1357924680\") == \"13579\"\n assert candidate(num = \"4206\") == \"\"\n assert candidate(num = \"123456789\") == \"123456789\"\n assert candidate(num = \"35427\") == \"35427\"\n assert candidate(num = \"24680\") == \"\"\n assert candidate(num = \"1234567890\") == \"123456789\"\n assert candidate(num = \"24681\") == \"24681\"\n assert candidate(num = \"11111\") == \"11111\"\n assert candidate(num = \"13579\") == \"13579\"\n assert candidate(num = \"13579135791357913577\") == \"13579135791357913577\"\n assert candidate(num = \"98765432109876543210\") == \"9876543210987654321\"\n assert candidate(num = \"10000000000000000000000000000000000000000000000002\") == \"1\"\n assert candidate(num = \"246802468024680246802468024680246802468024680\") == \"\"\n assert candidate(num = \"02468\") == \"\"\n assert candidate(num = \"9012345678\") == \"901234567\"\n assert candidate(num = \"0000000000\") == \"\"\n assert candidate(num = \"111222333444555\") == \"111222333444555\"\n assert candidate(num = \"135791357913579135791357913579135791357913579\") == \"135791357913579135791357913579135791357913579\"\n assert candidate(num = \"2468101214161820\") == \"2468101214161\"\n assert candidate(num = \"50505050505050505055\") == \"50505050505050505055\"\n assert candidate(num = \"902468013579\") == \"902468013579\"\n assert candidate(num = \"99999999999999999998\") == \"9999999999999999999\"\n assert candidate(num = \"987654321987654321987654321987654321987654321\") == \"987654321987654321987654321987654321987654321\"\n assert candidate(num = \"13579111315\") == \"13579111315\"\n assert candidate(num = \"0246802468024680246802468024680246802468024680\") == \"\"\n assert candidate(num = \"1234567890123456789012345678901234567890123456789\") == \"1234567890123456789012345678901234567890123456789\"\n assert candidate(num = \"1111111111111111111111111111111111111111111111111\") == \"1111111111111111111111111111111111111111111111111\"\n assert candidate(num = \"123456789012345678901\") == \"123456789012345678901\"\n assert candidate(num = \"246802468024680246805\") == \"246802468024680246805\"\n assert candidate(num = \"1000000000000000000000000000000000000000000000000\") == \"1\"\n assert candidate(num = \"5000000000000000000000000000000000000000000000003\") == \"5000000000000000000000000000000000000000000000003\"\n assert candidate(num = \"987654320\") == \"9876543\"\n assert candidate(num = \"111111111111111111111111111111111111111111111111\") == \"111111111111111111111111111111111111111111111111\"\n assert candidate(num = \"8642086420\") == \"\"\n assert candidate(num = \"10\") == \"1\"\n assert candidate(num = \"8080808080808080808080808080808080808080808080807\") == \"8080808080808080808080808080808080808080808080807\"\n assert candidate(num = \"1000000000000000000000000000000000000000000000001\") == \"1000000000000000000000000000000000000000000000001\"\n assert candidate(num = \"2468012345\") == \"2468012345\"\n assert candidate(num = \"0246802468\") == \"\"\n assert candidate(num = \"124\") == \"1\"\n assert candidate(num = \"246802468024680246802468024680\") == \"\"\n assert candidate(num = \"1000000000100000000010000000001000000000100000001\") == \"1000000000100000000010000000001000000000100000001\"\n assert candidate(num = \"1919191919191919191919191919191919191919191919\") == \"1919191919191919191919191919191919191919191919\"\n assert candidate(num = \"2000000002000000002\") == \"\"\n assert candidate(num = \"9999999998\") == \"999999999\"\n assert candidate(num = \"87654321\") == \"87654321\"\n assert candidate(num = \"10000000000000000001\") == \"10000000000000000001\"\n assert candidate(num = \"1357997531\") == \"1357997531\"\n assert candidate(num = \"987654321987654321987654321987654321987654321987654321\") == \"987654321987654321987654321987654321987654321987654321\"\n assert candidate(num = \"00000000000000000001\") == \"00000000000000000001\"\n assert candidate(num = \"987654321987654321987654321\") == \"987654321987654321987654321\"\n assert candidate(num = \"9999999999999999999999999999999999999999999999998\") == \"999999999999999999999999999999999999999999999999\"\n assert candidate(num = \"246801357924680\") == \"2468013579\"\n assert candidate(num = \"11111111111111111112\") == \"1111111111111111111\"\n assert candidate(num = \"20000000000000000000000000000000000000000000000002\") == \"\"\n assert candidate(num = \"13579111315171921\") == \"13579111315171921\"\n assert candidate(num = \"864200000\") == \"\"\n assert candidate(num = \"13579135791357913579\") == \"13579135791357913579\"\n assert candidate(num = \"2020202020202020202020202020202020202020202020\") == \"\"\n assert candidate(num = \"1001001001001001001001001001001001001001001001001\") == \"1001001001001001001001001001001001001001001001001\"\n assert candidate(num = \"24680246802468024689\") == \"24680246802468024689\"\n assert candidate(num = \"246810\") == \"24681\"\n assert candidate(num = \"999999999999999999\") == \"999999999999999999\"\n assert candidate(num = \"12345678909876543210\") == \"1234567890987654321\"\n assert candidate(num = \"99999999999999999999\") == \"99999999999999999999\"\n assert candidate(num = \"0123456789\") == \"0123456789\"\n assert candidate(num = \"1234567890123456789\") == \"1234567890123456789\"\n assert candidate(num = \"9876543210987654321098765432109876543210987654321\") == \"9876543210987654321098765432109876543210987654321\"\n assert candidate(num = \"101010101010101010101010101010101010101010101010101\") == \"101010101010101010101010101010101010101010101010101\"\n assert candidate(num = \"00000000000000000000000000000000000000000000000\") == \"\"\n assert candidate(num = \"2468024680246802468024680246802468024680246802468\") == \"\"\n assert candidate(num = \"9876543219\") == \"9876543219\"\n assert candidate(num = \"9876543210987654321098765432109876543210\") == \"987654321098765432109876543210987654321\"\n assert candidate(num = \"12345678901\") == \"12345678901\"\n assert candidate(num = \"2999999999999999999999999999999999999999999999998\") == \"299999999999999999999999999999999999999999999999\"\n assert candidate(num = \"999999999\") == \"999999999\"\n assert candidate(num = \"98765432101234567890\") == \"9876543210123456789\"\n assert candidate(num = \"11223344556677889900\") == \"112233445566778899\"\n assert candidate(num = \"543210987654321098765432109876543210987654321\") == \"543210987654321098765432109876543210987654321\"\n assert candidate(num = \"13579135791357913578\") == \"1357913579135791357\"\n assert candidate(num = \"100000000000000000001\") == \"100000000000000000001\"\n assert candidate(num = \"555555555555555555555555555555555555555555555555\") == \"555555555555555555555555555555555555555555555555\"\n assert candidate(num = \"123456789012345678902\") == \"1234567890123456789\"\n assert candidate(num = \"111222333444555666777888999\") == \"111222333444555666777888999\"\n assert candidate(num = \"864208642086420\") == \"\"\n assert candidate(num = \"024680246802468\") == \"\"\n assert candidate(num = \"9999999999\") == \"9999999999\"\n assert candidate(num = \"135791357913579135791357913579\") == \"135791357913579135791357913579\"\n assert candidate(num = \"9999999999999999999999999999999999999999999999999\") == \"9999999999999999999999999999999999999999999999999\"\n assert candidate(num = \"86420864208642086420\") == \"\"\n assert candidate(num = \"98765432109876543211\") == \"98765432109876543211\"\n assert candidate(num = \"01234567890123456789\") == \"01234567890123456789\"\n assert candidate(num = \"10000000000000000000\") == \"1\"\n assert candidate(num = \"1000000001\") == \"1000000001\"\n assert candidate(num = \"1999999999999999999999999999999999999999999999999\") == \"1999999999999999999999999999999999999999999999999\"\n assert candidate(num = \"24680246802468024680\") == \"\"\n assert candidate(num = \"222222222222222222222222222222222222222222222222\") == \"\"\n assert candidate(num = \"135790\") == \"13579\"\n assert candidate(num = \"8642097531\") == \"8642097531\"\n assert candidate(num = \"10000000000000000000000000000000000000000000000001\") == \"10000000000000000000000000000000000000000000000001\"\n assert candidate(num = \"123456789012345678901234567890\") == \"12345678901234567890123456789\"\n assert candidate(num = \"12345678901234567891\") == \"12345678901234567891\"\n assert candidate(num = \"1357913579135791357913579135791357913579135791357\") == \"1357913579135791357913579135791357913579135791357\"\n assert candidate(num = \"12345678901234567890123456789012345678901234567890\") == \"1234567890123456789012345678901234567890123456789\"\n assert candidate(num = \"246802468024680\") == \"\"\n assert candidate(num = \"987654321987654321\") == \"987654321987654321\"\n assert candidate(num = \"2222222222222222222222222222222222222222222222221\") == \"2222222222222222222222222222222222222222222222221\"\n assert candidate(num = \"9876543210987654321\") == \"9876543210987654321\"\n assert candidate(num = \"2222222222222222222222222222222222222222222222222\") == \"\"\n assert candidate(num = \"00000000000000000000\") == \"\"\n assert candidate(num = \"135791113151719\") == \"135791113151719\"\n assert candidate(num = \"987654321098765432\") == \"98765432109876543\"\n assert candidate(num = \"135791113151719111\") == \"135791113151719111\"\n assert candidate(num = \"11111111111111111111\") == \"11111111111111111111\"\n assert candidate(num = \"998877665544332211\") == \"998877665544332211\"\n assert candidate(num = \"12345678901234567890\") == \"1234567890123456789\"\n assert candidate(num = \"135791357913579\") == \"135791357913579\"\n assert candidate(num = \"09876543210987654321\") == \"09876543210987654321\"\n assert candidate(num = \"22222222221\") == \"22222222221\"\n assert candidate(num = \"10000000000000000000000000000000000000000001\") == \"10000000000000000000000000000000000000000001\"\n assert candidate(num = \"1357913579\") == \"1357913579\"\n assert candidate(num = \"22222222222222222222\") == \"\"\n assert candidate(num = \"9999999999999999999999999999999999999999998\") == \"999999999999999999999999999999999999999999\"\n", "comparison": "exact"}, "public_tests": ["\"52\"", "\"4206\"", "\"35427\""], "hints": ["In what order should you iterate through the digits?", "If an odd number exists, where must the number start from?"], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().largestOddNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:32+00:00", "tests_total": 140, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def largestOddNumber(self, num: str) -> str:", "container": "Solution", "callable": "largestOddNumber", "parameters": [{"name": "num", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1904, "task_id": "the-number-of-full-rounds-you-have-played", "difficulty": "Medium", "problem_description": "You are participating in an online chess tournament. There is a chess round that starts every 15 minutes. The first round of the day starts at 00:00, and after every 15 minutes, a new round starts.\n\n- For example, the second round starts at 00:15, the fourth round starts at 00:45, and the seventh round starts at 01:30.\n\nYou are given two strings loginTime and logoutTime where:\n\n- loginTime is the time you will login to the game, and\n- logoutTime is the time you will logout from the game.\n\nIf logoutTime is earlier than loginTime, this means you have played from loginTime to midnight and from midnight to logoutTime.\n\nReturn the number of full chess rounds you have played in the tournament.\n\nNote: All the given times follow the 24-hour clock. That means the first round of the day starts at 00:00 and the last round of the day starts at 23:45.\n\nExample 1:\n\nInput: loginTime = \"09:31\", logoutTime = \"10:14\"\nOutput: 1\nExplanation: You played one full round from 09:45 to 10:00.\nYou did not play the full round from 09:30 to 09:45 because you logged in at 09:31 after it began.\nYou did not play the full round from 10:00 to 10:15 because you logged out at 10:14 before it ended.\n\nExample 2:\n\nInput: loginTime = \"21:30\", logoutTime = \"03:00\"\nOutput: 22\nExplanation: You played 10 full rounds from 21:30 to 00:00 and 12 full rounds from 00:00 to 03:00.\n10 + 12 = 22.\n\nConstraints:\n\n- loginTime and logoutTime are in the format hh:mm.\n- 00 <= hh <= 23\n- 00 <= mm <= 59\n- loginTime and logoutTime are not equal.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(loginTime = \"11:59\",logoutTime = \"12:01\") == 0\n assert candidate(loginTime = \"14:30\",logoutTime = \"15:30\") == 4\n assert candidate(loginTime = \"00:01\",logoutTime = \"00:14\") == 0\n assert candidate(loginTime = \"14:20\",logoutTime = \"15:50\") == 5\n assert candidate(loginTime = \"00:00\",logoutTime = \"23:59\") == 95\n assert candidate(loginTime = \"18:14\",logoutTime = \"18:46\") == 2\n assert candidate(loginTime = \"14:30\",logoutTime = \"14:45\") == 1\n assert candidate(loginTime = \"23:45\",logoutTime = \"00:15\") == 2\n assert candidate(loginTime = \"22:15\",logoutTime = \"23:45\") == 6\n assert candidate(loginTime = \"15:30\",logoutTime = \"15:30\") == 0\n assert candidate(loginTime = \"14:20\",logoutTime = \"14:59\") == 1\n assert candidate(loginTime = \"05:45\",logoutTime = \"06:00\") == 1\n assert candidate(loginTime = \"09:31\",logoutTime = \"10:14\") == 1\n assert candidate(loginTime = \"00:01\",logoutTime = \"23:59\") == 94\n assert candidate(loginTime = \"07:45\",logoutTime = \"08:00\") == 1\n assert candidate(loginTime = \"11:59\",logoutTime = \"12:00\") == 0\n assert candidate(loginTime = \"23:45\",logoutTime = \"00:00\") == 1\n assert candidate(loginTime = \"05:00\",logoutTime = \"06:00\") == 4\n assert candidate(loginTime = \"01:10\",logoutTime = \"01:55\") == 2\n assert candidate(loginTime = \"01:15\",logoutTime = \"01:45\") == 2\n assert candidate(loginTime = \"07:15\",logoutTime = \"07:30\") == 1\n assert candidate(loginTime = \"01:05\",logoutTime = \"01:40\") == 1\n assert candidate(loginTime = \"21:30\",logoutTime = \"03:00\") == 22\n assert candidate(loginTime = \"13:00\",logoutTime = \"13:01\") == 0\n assert candidate(loginTime = \"12:00\",logoutTime = \"12:15\") == 1\n assert candidate(loginTime = \"05:30\",logoutTime = \"06:00\") == 2\n assert candidate(loginTime = \"08:45\",logoutTime = \"09:00\") == 1\n assert candidate(loginTime = \"01:00\",logoutTime = \"02:30\") == 6\n assert candidate(loginTime = \"18:15\",logoutTime = \"18:44\") == 1\n assert candidate(loginTime = \"10:15\",logoutTime = \"11:14\") == 3\n assert candidate(loginTime = \"19:10\",logoutTime = \"20:50\") == 6\n assert candidate(loginTime = \"07:00\",logoutTime = \"07:01\") == 0\n assert candidate(loginTime = \"12:16\",logoutTime = \"12:44\") == 0\n assert candidate(loginTime = \"20:44\",logoutTime = \"21:00\") == 1\n assert candidate(loginTime = \"12:30\",logoutTime = \"14:45\") == 9\n assert candidate(loginTime = \"11:15\",logoutTime = \"11:16\") == 0\n assert candidate(loginTime = \"14:30\",logoutTime = \"14:30\") == 0\n assert candidate(loginTime = \"18:45\",logoutTime = \"19:45\") == 4\n assert candidate(loginTime = \"18:00\",logoutTime = \"07:00\") == 52\n assert candidate(loginTime = \"07:15\",logoutTime = \"07:15\") == 0\n assert candidate(loginTime = \"08:15\",logoutTime = \"08:30\") == 1\n assert candidate(loginTime = \"02:10\",logoutTime = \"05:50\") == 14\n assert candidate(loginTime = \"08:25\",logoutTime = \"09:50\") == 5\n assert candidate(loginTime = \"01:00\",logoutTime = \"01:14\") == 0\n assert candidate(loginTime = \"12:30\",logoutTime = \"13:15\") == 3\n assert candidate(loginTime = \"03:45\",logoutTime = \"05:10\") == 5\n assert candidate(loginTime = \"06:30\",logoutTime = \"06:30\") == 0\n assert candidate(loginTime = \"17:45\",logoutTime = \"18:00\") == 1\n assert candidate(loginTime = \"20:00\",logoutTime = \"20:14\") == 0\n assert candidate(loginTime = \"23:59\",logoutTime = \"00:01\") == 0\n assert candidate(loginTime = \"07:07\",logoutTime = \"07:32\") == 1\n assert candidate(loginTime = \"06:59\",logoutTime = \"07:01\") == 0\n assert candidate(loginTime = \"14:23\",logoutTime = \"14:24\") == 0\n assert candidate(loginTime = \"12:10\",logoutTime = \"12:20\") == 0\n assert candidate(loginTime = \"05:00\",logoutTime = \"05:00\") == 0\n assert candidate(loginTime = \"02:30\",logoutTime = \"02:31\") == 0\n assert candidate(loginTime = \"20:00\",logoutTime = \"04:00\") == 32\n assert candidate(loginTime = \"21:15\",logoutTime = \"21:45\") == 2\n assert candidate(loginTime = \"00:45\",logoutTime = \"01:00\") == 1\n assert candidate(loginTime = \"21:10\",logoutTime = \"21:14\") == 0\n assert candidate(loginTime = \"12:45\",logoutTime = \"13:45\") == 4\n assert candidate(loginTime = \"00:10\",logoutTime = \"01:05\") == 3\n assert candidate(loginTime = \"14:00\",logoutTime = \"14:14\") == 0\n assert candidate(loginTime = \"17:10\",logoutTime = \"18:55\") == 6\n assert candidate(loginTime = \"06:30\",logoutTime = \"07:30\") == 4\n assert candidate(loginTime = \"00:44\",logoutTime = \"00:59\") == 0\n assert candidate(loginTime = \"16:00\",logoutTime = \"16:01\") == 0\n assert candidate(loginTime = \"09:00\",logoutTime = \"21:15\") == 49\n assert candidate(loginTime = \"15:10\",logoutTime = \"15:15\") == 0\n assert candidate(loginTime = \"14:00\",logoutTime = \"18:30\") == 18\n assert candidate(loginTime = \"20:00\",logoutTime = \"21:00\") == 4\n assert candidate(loginTime = \"11:10\",logoutTime = \"11:10\") == 0\n assert candidate(loginTime = \"11:45\",logoutTime = \"12:44\") == 3\n assert candidate(loginTime = \"07:45\",logoutTime = \"08:15\") == 2\n assert candidate(loginTime = \"10:00\",logoutTime = \"10:14\") == 0\n assert candidate(loginTime = \"07:05\",logoutTime = \"08:10\") == 3\n assert candidate(loginTime = \"08:45\",logoutTime = \"09:15\") == 2\n assert candidate(loginTime = \"16:45\",logoutTime = \"17:45\") == 4\n assert candidate(loginTime = \"07:01\",logoutTime = \"07:14\") == 0\n assert candidate(loginTime = \"11:46\",logoutTime = \"12:44\") == 2\n assert candidate(loginTime = \"09:00\",logoutTime = \"16:45\") == 31\n assert candidate(loginTime = \"13:30\",logoutTime = \"14:00\") == 2\n assert candidate(loginTime = \"20:00\",logoutTime = \"20:15\") == 1\n assert candidate(loginTime = \"00:00\",logoutTime = \"04:00\") == 16\n assert candidate(loginTime = \"00:00\",logoutTime = \"00:15\") == 1\n assert candidate(loginTime = \"07:07\",logoutTime = \"07:47\") == 2\n assert candidate(loginTime = \"13:46\",logoutTime = \"13:47\") == 0\n assert candidate(loginTime = \"13:15\",logoutTime = \"14:15\") == 4\n assert candidate(loginTime = \"14:16\",logoutTime = \"15:14\") == 2\n assert candidate(loginTime = \"21:00\",logoutTime = \"21:59\") == 3\n assert candidate(loginTime = \"07:00\",logoutTime = \"07:14\") == 0\n assert candidate(loginTime = \"01:01\",logoutTime = \"24:00\") == 91\n assert candidate(loginTime = \"17:15\",logoutTime = \"17:45\") == 2\n assert candidate(loginTime = \"12:00\",logoutTime = \"12:00\") == 0\n assert candidate(loginTime = \"03:45\",logoutTime = \"04:15\") == 2\n assert candidate(loginTime = \"04:45\",logoutTime = \"05:00\") == 1\n assert candidate(loginTime = \"00:00\",logoutTime = \"23:45\") == 95\n assert candidate(loginTime = \"02:20\",logoutTime = \"02:25\") == 0\n assert candidate(loginTime = \"09:45\",logoutTime = \"10:45\") == 4\n assert candidate(loginTime = \"22:00\",logoutTime = \"01:30\") == 14\n assert candidate(loginTime = \"07:07\",logoutTime = \"07:45\") == 2\n assert candidate(loginTime = \"22:45\",logoutTime = \"23:59\") == 4\n assert candidate(loginTime = \"05:00\",logoutTime = \"24:00\") == 76\n assert candidate(loginTime = \"02:30\",logoutTime = \"03:30\") == 4\n assert candidate(loginTime = \"13:23\",logoutTime = \"14:22\") == 3\n assert candidate(loginTime = \"16:20\",logoutTime = \"18:55\") == 9\n assert candidate(loginTime = \"00:00\",logoutTime = \"00:14\") == 0\n assert candidate(loginTime = \"08:20\",logoutTime = \"09:20\") == 3\n assert candidate(loginTime = \"12:05\",logoutTime = \"12:20\") == 0\n assert candidate(loginTime = \"03:33\",logoutTime = \"04:48\") == 4\n assert candidate(loginTime = \"23:00\",logoutTime = \"23:15\") == 1\n assert candidate(loginTime = \"13:46\",logoutTime = \"14:14\") == 0\n assert candidate(loginTime = \"15:00\",logoutTime = \"15:15\") == 1\n assert candidate(loginTime = \"13:15\",logoutTime = \"13:30\") == 1\n assert candidate(loginTime = \"15:00\",logoutTime = \"16:00\") == 4\n assert candidate(loginTime = \"03:00\",logoutTime = \"03:01\") == 0\n assert candidate(loginTime = \"09:00\",logoutTime = \"09:00\") == 0\n assert candidate(loginTime = \"00:00\",logoutTime = \"24:00\") == 96\n assert candidate(loginTime = \"19:40\",logoutTime = \"20:05\") == 1\n assert candidate(loginTime = \"16:00\",logoutTime = \"17:00\") == 4\n assert candidate(loginTime = \"12:46\",logoutTime = \"13:14\") == 0\n assert candidate(loginTime = \"03:45\",logoutTime = \"03:45\") == 0\n assert candidate(loginTime = \"00:15\",logoutTime = \"00:30\") == 1\n assert candidate(loginTime = \"08:30\",logoutTime = \"09:00\") == 2\n assert candidate(loginTime = \"23:15\",logoutTime = \"00:14\") == 3\n assert candidate(loginTime = \"05:55\",logoutTime = \"06:05\") == 0\n assert candidate(loginTime = \"00:15\",logoutTime = \"23:59\") == 94\n assert candidate(loginTime = \"10:00\",logoutTime = \"10:00\") == 0\n assert candidate(loginTime = \"01:59\",logoutTime = \"02:01\") == 0\n assert candidate(loginTime = \"06:59\",logoutTime = \"07:00\") == 0\n assert candidate(loginTime = \"23:40\",logoutTime = \"00:10\") == 1\n assert candidate(loginTime = \"09:00\",logoutTime = \"09:59\") == 3\n assert candidate(loginTime = \"06:30\",logoutTime = \"07:00\") == 2\n assert candidate(loginTime = \"01:45\",logoutTime = \"02:44\") == 3\n assert candidate(loginTime = \"18:00\",logoutTime = \"18:00\") == 0\n assert candidate(loginTime = \"01:14\",logoutTime = \"01:46\") == 2\n assert candidate(loginTime = \"23:55\",logoutTime = \"00:05\") == 0\n assert candidate(loginTime = \"09:00\",logoutTime = \"18:45\") == 39\n assert candidate(loginTime = \"01:46\",logoutTime = \"02:14\") == 0\n assert candidate(loginTime = \"09:10\",logoutTime = \"09:20\") == 0\n assert candidate(loginTime = \"09:00\",logoutTime = \"09:14\") == 0\n assert candidate(loginTime = \"18:25\",logoutTime = \"19:50\") == 5\n assert candidate(loginTime = \"23:00\",logoutTime = \"23:45\") == 3\n assert candidate(loginTime = \"07:05\",logoutTime = \"08:05\") == 3\n assert candidate(loginTime = \"23:30\",logoutTime = \"00:30\") == 4\n assert candidate(loginTime = \"10:00\",logoutTime = \"24:00\") == 56\n assert candidate(loginTime = \"06:30\",logoutTime = \"09:15\") == 11\n assert candidate(loginTime = \"06:45\",logoutTime = \"07:00\") == 1\n assert candidate(loginTime = \"00:30\",logoutTime = \"00:45\") == 1\n assert candidate(loginTime = \"21:00\",logoutTime = \"22:15\") == 5\n assert candidate(loginTime = \"14:45\",logoutTime = \"15:00\") == 1\n assert candidate(loginTime = \"00:05\",logoutTime = \"00:30\") == 1\n assert candidate(loginTime = \"11:59\",logoutTime = \"12:14\") == 0\n assert candidate(loginTime = \"18:45\",logoutTime = \"19:10\") == 1\n assert candidate(loginTime = \"13:30\",logoutTime = \"16:45\") == 13\n assert candidate(loginTime = \"09:44\",logoutTime = \"09:45\") == 0\n assert candidate(loginTime = \"08:29\",logoutTime = \"08:40\") == 0\n assert candidate(loginTime = \"14:30\",logoutTime = \"16:30\") == 8\n assert candidate(loginTime = \"01:05\",logoutTime = \"02:30\") == 5\n assert candidate(loginTime = \"00:00\",logoutTime = \"01:00\") == 4\n assert candidate(loginTime = \"05:15\",logoutTime = \"05:15\") == 0\n assert candidate(loginTime = \"13:20\",logoutTime = \"13:59\") == 1\n assert candidate(loginTime = \"09:59\",logoutTime = \"10:00\") == 0\n assert candidate(loginTime = \"10:10\",logoutTime = \"11:09\") == 3\n assert candidate(loginTime = \"01:10\",logoutTime = \"01:40\") == 1\n assert candidate(loginTime = \"13:00\",logoutTime = \"13:14\") == 0\n assert candidate(loginTime = \"23:01\",logoutTime = \"23:14\") == 0\n assert candidate(loginTime = \"19:15\",logoutTime = \"20:00\") == 3\n", "comparison": "exact"}, "public_tests": ["\"09:31\"\n\"10:14\"", "\"21:30\"\n\"03:00\""], "hints": ["Consider the day as 48 hours instead of 24.", "For each round check if you were playing."], "metadata": {"canonical_parameter_names": ["loginTime", "logoutTime"], "leetcode_dataset_entry_point": "Solution().numberOfRounds", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:34+00:00", "tests_total": 168, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "string"]}, "language": "python", "interface": {"raw_signature": "def numberOfRounds(self, loginTime: str, logoutTime: str) -> int:", "container": "Solution", "callable": "numberOfRounds", "parameters": [{"name": "loginTime", "type": "str"}, {"name": "logoutTime", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1905, "task_id": "count-sub-islands", "difficulty": "Medium", "problem_description": "You are given two m x n binary matrices grid1 and grid2 containing only 0's (representing water) and 1's (representing land). An island is a group of 1's connected 4-directionally (horizontal or vertical). Any cells outside of the grid are considered water cells.\n\nAn island in grid2 is considered a sub-island if there is an island in grid1 that contains all the cells that make up this island in grid2.\n\nReturn the number of islands in grid2 that are considered sub-islands.\n\nExample 1:\n\nInput: grid1 = [[1,1,1,0,0],[0,1,1,1,1],[0,0,0,0,0],[1,0,0,0,0],[1,1,0,1,1]], grid2 = [[1,1,1,0,0],[0,0,1,1,1],[0,1,0,0,0],[1,0,1,1,0],[0,1,0,1,0]]\nOutput: 3\nExplanation: In the picture above, the grid on the left is grid1 and the grid on the right is grid2.\nThe 1s colored red in grid2 are those considered to be part of a sub-island. There are three sub-islands.\n\nExample 2:\n\nInput: grid1 = [[1,0,1,0,1],[1,1,1,1,1],[0,0,0,0,0],[1,1,1,1,1],[1,0,1,0,1]], grid2 = [[0,0,0,0,0],[1,1,1,1,1],[0,1,0,1,0],[0,1,0,1,0],[1,0,0,0,1]]\nOutput: 2\nExplanation: In the picture above, the grid on the left is grid1 and the grid on the right is grid2.\nThe 1s colored red in grid2 are those considered to be part of a sub-island. There are two sub-islands.\n\nConstraints:\n\n- m == grid1.length == grid2.length\n- n == grid1[i].length == grid2[i].length\n- 1 <= m, n <= 500\n- grid1[i][j] and grid2[i][j] are either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid1 = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 0, 0, 0]],grid2 = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1]]) == 2\n assert candidate(grid1 = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],grid2 = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid1 = [[1, 1, 1], [0, 0, 0], [0, 0, 0]],grid2 = [[1, 1, 1], [0, 0, 0], [0, 0, 0]]) == 1\n assert candidate(grid1 = [[1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == 2\n assert candidate(grid1 = [[0, 0, 0], [0, 0, 0]],grid2 = [[0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [1, 1, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0], [1, 0, 1, 1, 1], [0, 0, 0, 0, 1], [1, 1, 0, 1, 1]]) == 2\n assert candidate(grid1 = [[1, 1, 1, 0, 0], [0, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 0, 1, 1]],grid2 = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [0, 1, 0, 0, 0], [1, 0, 1, 1, 0], [0, 1, 0, 1, 0]]) == 3\n assert candidate(grid1 = [[1, 0, 1], [0, 1, 0], [1, 0, 1]],grid2 = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 1\n assert candidate(grid1 = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 1, 0, 1]]) == 0\n assert candidate(grid1 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],grid2 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 1\n assert candidate(grid1 = [[1, 1, 1], [1, 0, 1], [1, 1, 1]],grid2 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 0, 0, 1, 1], [0, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1]],grid2 = [[1, 0, 0, 1, 1], [0, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 0, 1], [1, 0, 1, 0, 1]]) == 4\n assert candidate(grid1 = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1]],grid2 = [[1, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 0, 1]]) == 2\n assert candidate(grid1 = [[1, 1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0]],grid2 = [[1, 1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0]]) == 3\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 1, 0], [0, 0, 1, 0, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]],grid2 = [[1, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 1, 0], [0, 0, 1, 0, 1, 0, 0], [1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 3\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0]]) == 5\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 1, 1, 1], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[1, 1, 0, 0, 1, 1, 1, 1], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid1 = [[0, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0]],grid2 = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 50\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],grid2 = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 13\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]],grid2 = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]]) == 23\n assert candidate(grid1 = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 0], [0, 1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1, 1], [1, 1, 0, 1, 1, 0, 1]],grid2 = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 0, 1, 0], [0, 1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 1, 1, 1], [1, 1, 0, 1, 0, 0, 1]]) == 5\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],grid2 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 19\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 14\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 3\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]],grid2 = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]]) == 5\n assert candidate(grid1 = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 1\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 1, 0], [1, 1, 1, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1]],grid2 = [[1, 0, 1, 0, 1, 1, 0], [1, 1, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1]]) == 6\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 1], [1, 0, 0, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 3\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 0, 1]],grid2 = [[0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 0, 1]]) == 2\n assert candidate(grid1 = [[1, 1, 0, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 0, 0, 1, 0], [0, 0, 1, 0, 0]],grid2 = [[1, 1, 0, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 1, 0], [1, 1, 0, 1, 0], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid1 = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],grid2 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[1, 0, 0, 0, 0, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 27\n assert candidate(grid1 = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]],grid2 = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 19\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]],grid2 = [[1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 7\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid1 = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 3\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 0, 1], [0, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 1, 1], [1, 1, 1, 0, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0, 0, 1], [1, 0, 0, 1, 0, 0, 1], [0, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 1]]) == 6\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]],grid2 = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 4\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 1, 0, 0, 1], [1, 1, 1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 1, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 0, 0], [1, 0, 0, 0, 0, 1, 0, 0, 1], [1, 1, 1, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 1, 0, 1, 0, 1]]) == 8\n assert candidate(grid1 = [[1, 1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1]],grid2 = [[1, 1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 1, 1, 1], [0, 0, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1]]) == 6\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 0, 0, 0, 1], [0, 1, 1, 1, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]],grid2 = [[0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0]]) == 11\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1]]) == 7\n assert candidate(grid1 = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid1 = [[1, 0, 0, 1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0, 1, 0], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [0, 1, 0, 0, 1, 0, 0, 1, 0, 0], [1, 0, 1, 1, 0, 1, 1, 0, 1, 1], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0, 1, 0], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 17\n assert candidate(grid1 = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0, 1], [0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 0, 1, 1], [1, 0, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1]],grid2 = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0, 1], [0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 0, 1, 1], [1, 0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 3\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 1], [1, 1, 0, 1, 1, 0]],grid2 = [[1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 1], [1, 1, 0, 1, 1, 0]]) == 6\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1]],grid2 = [[0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0]]) == 9\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0, 1, 1], [1, 0, 1, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 0], [1, 0, 1, 1, 1, 0, 1], [1, 1, 0, 0, 0, 1, 1]]) == 4\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]],grid2 = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 14\n assert candidate(grid1 = [[1, 0, 0, 1, 0, 1, 1, 0, 0, 1], [0, 1, 0, 1, 0, 1, 1, 0, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 1, 0, 1, 1, 0, 0, 1], [0, 1, 0, 1, 0, 1, 1, 0, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 33\n assert candidate(grid1 = [[1, 1, 0, 0, 1], [1, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 0, 1], [1, 1, 0, 0, 1]],grid2 = [[1, 1, 0, 0, 1], [1, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 0, 0, 1], [1, 1, 0, 0, 1]]) == 4\n assert candidate(grid1 = [[1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]],grid2 = [[1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 46\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 0, 1]],grid2 = [[1, 1, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 1, 0], [0, 0, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 0, 0, 1]]) == 10\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid1 = [[1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 0, 0, 1, 1], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 0]]) == 26\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid1 = [[1, 0, 0, 1, 1, 0, 1], [0, 0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1]],grid2 = [[1, 0, 0, 1, 0, 0, 1], [0, 0, 1, 1, 0, 0, 0], [1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1]]) == 5\n", "comparison": "exact"}, "public_tests": ["[[1,1,1,0,0],[0,1,1,1,1],[0,0,0,0,0],[1,0,0,0,0],[1,1,0,1,1]]\n[[1,1,1,0,0],[0,0,1,1,1],[0,1,0,0,0],[1,0,1,1,0],[0,1,0,1,0]]", "[[1,0,1,0,1],[1,1,1,1,1],[0,0,0,0,0],[1,1,1,1,1],[1,0,1,0,1]]\n[[0,0,0,0,0],[1,1,1,1,1],[0,1,0,1,0],[0,1,0,1,0],[1,0,0,0,1]]"], "hints": ["Let's use floodfill to iterate over the islands of the second grid", "Let's note that if all the cells in an island in the second grid if they are represented by land in the first grid then they are connected hence making that island a sub-island"], "metadata": {"canonical_parameter_names": ["grid1", "grid2"], "leetcode_dataset_entry_point": "Solution().countSubIslands", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:37+00:00", "tests_total": 67, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "depth-first-search", "breadth-first-search", "union-find", "matrix"]}, "language": "python", "interface": {"raw_signature": "def countSubIslands(self, grid1: list[list[int]], grid2: list[list[int]]) -> int:", "container": "Solution", "callable": "countSubIslands", "parameters": [{"name": "grid1", "type": "list[list[int]]"}, {"name": "grid2", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1906, "task_id": "minimum-absolute-difference-queries", "difficulty": "Medium", "problem_description": "The minimum absolute difference of an array a is defined as the minimum value of |a[i] - a[j]|, where 0 <= i < j < a.length and a[i] != a[j]. If all elements of a are the same, the minimum absolute difference is -1.\n\n- For example, the minimum absolute difference of the array [5,2,3,7,2] is |2 - 3| = 1. Note that it is not 0 because a[i] and a[j] must be different.\n\nYou are given an integer array nums and the array queries where queries[i] = [l_i, r_i]. For each query i, compute the minimum absolute difference of the subarray nums[l_i...r_i] containing the elements of nums between the 0-based indices l_i and r_i (inclusive).\n\nReturn an array ans where ans[i] is the answer to the i^th query.\n\nA subarray is a contiguous sequence of elements in an array.\n\nThe value of |x| is defined as:\n\n- x if x >= 0.\n- -x if x < 0.\n\nExample 1:\n\nInput: nums = [1,3,4,8], queries = [[0,1],[1,2],[2,3],[0,3]]\nOutput: [2,1,4,1]\nExplanation: The queries are processed as follows:\n- queries[0] = [0,1]: The subarray is [1,3] and the minimum absolute difference is |1-3| = 2.\n- queries[1] = [1,2]: The subarray is [3,4] and the minimum absolute difference is |3-4| = 1.\n- queries[2] = [2,3]: The subarray is [4,8] and the minimum absolute difference is |4-8| = 4.\n- queries[3] = [0,3]: The subarray is [1,3,4,8] and the minimum absolute difference is |3-4| = 1.\n\nExample 2:\n\nInput: nums = [4,5,2,2,7,10], queries = [[2,3],[0,2],[0,5],[3,5]]\nOutput: [-1,1,1,3]\nExplanation: The queries are processed as follows:\n- queries[0] = [2,3]: The subarray is [2,2] and the minimum absolute difference is -1 because all the\n elements are the same.\n- queries[1] = [0,2]: The subarray is [4,5,2] and the minimum absolute difference is |4-5| = 1.\n- queries[2] = [0,5]: The subarray is [4,5,2,2,7,10] and the minimum absolute difference is |4-5| = 1.\n- queries[3] = [3,5]: The subarray is [2,7,10] and the minimum absolute difference is |7-10| = 3.\n\nConstraints:\n\n- 2 <= nums.length <= 10^5\n- 1 <= nums[i] <= 100\n- 1 <= queries.length <= 2 * 10^4\n- 0 <= l_i < r_i < nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1],queries = [[0, 4], [1, 3]]) == [-1, -1]\n assert candidate(nums = [5, 5, 5, 5],queries = [[0, 3], [1, 2], [2, 3], [0, 1]]) == [-1, -1, -1, -1]\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 5],queries = [[0, 3], [1, 2]]) == [-1, -1]\n assert candidate(nums = [4, 5, 2, 2, 7, 10],queries = [[2, 3], [0, 2], [0, 5], [3, 5]]) == [-1, 1, 1, 3]\n assert candidate(nums = [1, 3, 4, 8],queries = [[0, 1], [1, 2], [2, 3], [0, 3]]) == [2, 1, 4, 1]\n assert candidate(nums = [100, 1, 2, 3, 4, 100],queries = [[0, 5], [1, 4], [2, 3], [0, 1]]) == [1, 1, 1, 99]\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3],queries = [[0, 6], [1, 5], [2, 4]]) == [1, 1, 1]\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 5]\n assert candidate(nums = [9, 10, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 10], [2, 9], [5, 8], [1, 4], [3, 6]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [99, 99, 99, 99, 99]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 19], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [8, 8, 8, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8],queries = [[0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [0, 9], [10, 19], [5, 15], [1, 18]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [1, 1, 1, 1, 3, 1, 1]\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [0, 19], [9, 10]]) == [99, 99, 99, 99, 99, 99]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],queries = [[0, 29], [1, 28], [2, 27], [3, 26], [4, 25]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [5, 1, 4, 8, 2, 3, 7, 6],queries = [[0, 2], [1, 6], [3, 7], [0, 7], [2, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[0, 9], [0, 4], [5, 9], [2, 8], [1, 7]]) == [2, 2, 2, 2, 2]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 8], [0, 4]]) == [-1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 10, 12, 11, 14, 13, 15],queries = [[0, 14], [0, 4], [5, 14], [2, 12], [1, 10]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [50, 20, 30, 10, 40],queries = [[0, 4], [1, 3], [2, 4], [0, 3], [1, 4], [0, 2], [3, 4], [0, 1]]) == [10, 10, 10, 10, 10, 10, 30, 30]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],queries = [[0, 14], [1, 3], [5, 7], [9, 11], [0, 4], [6, 8]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [0, 19], [9, 10]]) == [1, 1, 1, 1, 1, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [42, 21, 17, 36, 21, 21, 17, 42, 36, 21],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4]]) == [4, 4, 4, 4, -1, 4]\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [10, 1, 2, 10, 1, 2, 10, 1, 2, 10],queries = [[0, 9], [0, 2], [3, 5], [6, 8], [1, 7]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 3, 2, 4, 3, 2, 1, 3, 2, 4],queries = [[0, 3], [1, 5], [2, 8], [3, 9], [0, 9]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],queries = [[0, 5], [5, 9], [0, 9], [2, 7], [1, 8]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 95]\n assert candidate(nums = [50, 40, 30, 20, 10, 20, 30, 40, 50, 60],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [10, 10, 10, 10, 10]\n assert candidate(nums = [3, 1, 5, 1, 3, 2, 5, 3, 2, 1],queries = [[0, 4], [4, 8], [0, 9], [1, 5], [5, 9]]) == [2, 1, 1, 1, 1]\n assert candidate(nums = [2, 5, 1, 4, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],queries = [[0, 9], [0, 4], [5, 9], [2, 8], [1, 7]]) == [10, 10, 10, 10, 10]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n assert candidate(nums = [5, 5, 1, 1, 9, 9, 5, 5, 1, 1, 9, 9],queries = [[0, 11], [0, 3], [2, 5], [4, 7], [6, 9], [8, 11]]) == [4, 4, 8, 4, 4, 8]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [0, 19], [9, 10]]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [20, 30, 10, 40, 50, 10, 20, 30, 40, 50],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [10, 10, 10, 10, 40]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 2], [2, 4], [4, 6], [6, 8], [1, 3], [3, 5], [5, 7], [7, 9]]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2],queries = [[0, 8], [1, 5], [2, 6], [3, 7], [4, 8], [0, 3], [5, 8], [0, 4]]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],queries = [[0, 9], [0, 4], [5, 9], [2, 8], [1, 7]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [10, 19], [0, 19], [5, 14], [1, 18]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [5, 2, 5, 2, 5, 2, 5, 2, 5, 2],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [3, 3, 3, 3, 3]\n assert candidate(nums = [50, 40, 30, 20, 10, 20, 30, 40, 50],queries = [[0, 4], [4, 8], [0, 8], [1, 7], [2, 6]]) == [10, 10, 10, 10, 10]\n assert candidate(nums = [1, 5, 3, 9, 7, 11, 13, 15, 17, 19],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 8], [0, 4], [1, 3], [2, 4], [1, 5], [3, 7], [0, 6]]) == [2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],queries = [[0, 10], [0, 5], [5, 10], [2, 8], [1, 9]]) == [5, 5, 5, 5, 5]\n assert candidate(nums = [7, 10, 4, 3, 20, 15],queries = [[0, 5], [1, 2], [2, 4], [3, 5], [0, 4], [1, 3], [2, 5], [0, 3]]) == [1, 6, 1, 5, 1, 1, 1, 1]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [4, 1, 3, 2, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 4], [2, 6], [0, 5], [3, 8], [4, 9], [0, 2], [7, 9]]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [10, 10, 10, 10, 10]\n assert candidate(nums = [50, 1, 51, 2, 52, 3, 53, 4, 54, 5, 55, 6, 56, 7, 57, 8, 58, 9, 59, 10],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 50]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [2, 4, 2, 4, 2, 4, 2, 4, 2, 4],queries = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [5, 6, 6, 5, 5, 6, 5, 6, 6, 5],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 8], [0, 4], [1, 3], [2, 4]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [2, 2, 2, 2, 2]\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 8], [0, 4], [1, 3], [2, 4], [1, 5], [3, 7], [0, 6], [4, 8], [0, 7], [2, 9]]) == [1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [-1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 95]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],queries = [[0, 14], [0, 4], [5, 14], [2, 12], [1, 10]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [10, 10, 10, 10, 10, 10, 10]\n", "comparison": "exact"}, "public_tests": ["[1,3,4,8]\n[[0,1],[1,2],[2,3],[0,3]]", "[4,5,2,2,7,10]\n[[2,3],[0,2],[0,5],[3,5]]"], "hints": ["How does the maximum value being 100 help us?", "How can we tell if a number exists in a given range?"], "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().minDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:39+00:00", "tests_total": 90, "tests_dropped": 16, "flags": [], "topic_tags": ["array", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minDifference(self, nums: list[int], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "minDifference", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1909, "task_id": "remove-one-element-to-make-the-array-strictly-increasing", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums, return true if it can be made strictly increasing after removing exactly one element, or false otherwise. If the array is already strictly increasing, return true.\n\nThe array nums is strictly increasing if nums[i - 1] < nums[i] for each index (1 <= i < nums.length).\n\nExample 1:\n\nInput: nums = [1,2,10,5,7]\nOutput: true\nExplanation: By removing 10 at index 2 from nums, it becomes [1,2,5,7].\n[1,2,5,7] is strictly increasing, so return true.\n\nExample 2:\n\nInput: nums = [2,3,1,2]\nOutput: false\nExplanation:\n[3,1,2] is the result of removing the element at index 0.\n[2,1,2] is the result of removing the element at index 1.\n[2,3,2] is the result of removing the element at index 2.\n[2,3,1] is the result of removing the element at index 3.\nNo resulting array is strictly increasing, so return false.\n\nExample 3:\n\nInput: nums = [1,1,1]\nOutput: false\nExplanation: The result of removing any element is [1,1].\n[1,1] is not strictly increasing, so return false.\n\nConstraints:\n\n- 2 <= nums.length <= 1000\n- 1 <= nums[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 5]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 2, 2, 3]) == True\n assert candidate(nums = [1, 1, 1]) == False\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 3]) == True\n assert candidate(nums = [3, 5, 4, 6, 7]) == True\n assert candidate(nums = [1, 2, 10, 5, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5]) == True\n assert candidate(nums = [10, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [5, 2, 3, 4]) == True\n assert candidate(nums = [100, 20, 30]) == True\n assert candidate(nums = [3, 2, 1]) == False\n assert candidate(nums = [5, 7, 1, 8]) == True\n assert candidate(nums = [1, 2, 3, 3, 4]) == True\n assert candidate(nums = [5, 4, 3, 2, 1]) == False\n assert candidate(nums = [1, 2, 2, 3, 4]) == True\n assert candidate(nums = [1, 2, 3]) == True\n assert candidate(nums = [2, 3, 1, 2]) == False\n assert candidate(nums = [100, 200, 150, 300]) == True\n assert candidate(nums = [100, 200, 150, 300, 400]) == True\n assert candidate(nums = [1, 3, 2, 4]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 19]) == True\n assert candidate(nums = [1, 2, 3, 5, 4, 3, 2, 6, 7, 8]) == False\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 8, 9]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 3]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 5, 15, 16, 17]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 21]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 22]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 5, 18, 19]) == True\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 8, 7, 9]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 1000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 11, 12, 13]) == True\n assert candidate(nums = [1, 5, 2, 3, 4, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9, 11]) == True\n assert candidate(nums = [1, 3, 2, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 5, 4, 3, 6, 7, 8]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 10, 8, 9, 11, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 14]) == True\n assert candidate(nums = [1, 2, 3, 5, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == False\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 20, 27]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 5]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 20, 23]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 11]) == True\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9, 11, 12]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == False\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 55]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 12, 13]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == True\n assert candidate(nums = [1, 3, 5, 4, 7, 9, 8, 10, 12, 14, 15]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 18]) == True\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 25]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 18, 21, 23, 25, 27, 29]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7, 8]) == True\n assert candidate(nums = [6, 7, 8, 9, 10, 5, 11, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 6, 7]) == True\n assert candidate(nums = [8, 9, 10, 2, 11, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 8, 10]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 2, 17, 19, 21]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 5, 19, 20]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 16, 17, 18]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 5, 21, 22]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 24]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 3]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 21]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 11, 12]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 12, 14]) == True\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [1, 2, 3, 10, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 15, 16, 17, 18, 19]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 7, 9, 10, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 23]) == True\n assert candidate(nums = [100, 200, 150, 250, 300]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 100, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 100, 4, 5, 6]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 25]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 4, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 15]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 10, 12, 14]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 3, 5, 7, 6, 8, 9]) == True\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 9, 8, 10, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 10, 5, 6]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10, 9, 11, 12]) == True\n assert candidate(nums = [1, 3, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 10, 11]) == False\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 9, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 8]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5]) == False\n assert candidate(nums = [3, 5, 6, 7, 8, 9, 10, 5, 11, 12]) == True\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 3, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 8, 9]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 3]) == True\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 3, 14]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 6]) == False\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 10, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 4, 11]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 5]) == True\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 17]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 11]) == True\n assert candidate(nums = [10, 20, 30, 25, 40, 50]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 5, 20, 21]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 16]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 20, 22]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 8, 9, 11, 12, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 10, 13, 14]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 6, 7, 8]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 10]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5, 6, 7, 8]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 4, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 20]) == True\n", "comparison": "exact"}, "public_tests": ["[1,2,10,5,7]", "[2,3,1,2]", "[1,1,1]"], "hints": ["For each index i in nums remove this index.", "If the array becomes sorted return true, otherwise revert to the original array and try different index."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().canBeIncreasing", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:44+00:00", "tests_total": 179, "tests_dropped": 1, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def canBeIncreasing(self, nums: list[int]) -> bool:", "container": "Solution", "callable": "canBeIncreasing", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1910, "task_id": "remove-all-occurrences-of-a-substring", "difficulty": "Medium", "problem_description": "Given two strings s and part, perform the following operation on s until all occurrences of the substring part are removed:\n\n- Find the leftmost occurrence of the substring part and remove it from s.\n\nReturn s after removing all occurrences of part.\n\nA substring is a contiguous sequence of characters in a string.\n\nExample 1:\n\nInput: s = \"daabcbaabcbc\", part = \"abc\"\nOutput: \"dab\"\nExplanation: The following operations are done:\n- s = \"daabcbaabcbc\", remove \"abc\" starting at index 2, so s = \"dabaabcbc\".\n- s = \"dabaabcbc\", remove \"abc\" starting at index 4, so s = \"dababc\".\n- s = \"dababc\", remove \"abc\" starting at index 3, so s = \"dab\".\nNow s has no occurrences of \"abc\".\n\nExample 2:\n\nInput: s = \"axxxxyyyyb\", part = \"xy\"\nOutput: \"ab\"\nExplanation: The following operations are done:\n- s = \"axxxxyyyyb\", remove \"xy\" starting at index 4 so s = \"axxxyyyb\".\n- s = \"axxxyyyb\", remove \"xy\" starting at index 3 so s = \"axxyyb\".\n- s = \"axxyyb\", remove \"xy\" starting at index 2 so s = \"axyb\".\n- s = \"axyb\", remove \"xy\" starting at index 1 so s = \"ab\".\nNow s has no occurrences of \"xy\".\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- 1 <= part.length <= 1000\n- s and part consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcd\",part = \"efg\") == \"abcd\"\n assert candidate(s = \"zzzz\",part = \"zz\") == \"\"\n assert candidate(s = \"abcdabcdabcd\",part = \"abcd\") == \"\"\n assert candidate(s = \"abcdefg\",part = \"xyz\") == \"abcdefg\"\n assert candidate(s = \"abcde\",part = \"f\") == \"abcde\"\n assert candidate(s = \"daabcbaabcbc\",part = \"abc\") == \"dab\"\n assert candidate(s = \"abcabcabc\",part = \"bca\") == \"abc\"\n assert candidate(s = \"axxxxyyyyb\",part = \"xy\") == \"ab\"\n assert candidate(s = \"hello\",part = \"ll\") == \"heo\"\n assert candidate(s = \"abcabcabc\",part = \"abc\") == \"\"\n assert candidate(s = \"aaaa\",part = \"aa\") == \"\"\n assert candidate(s = \"mississippi\",part = \"issi\") == \"mssippi\"\n assert candidate(s = \"abababab\",part = \"aba\") == \"bb\"\n assert candidate(s = \"aaaaaaa\",part = \"aa\") == \"a\"\n assert candidate(s = \"zzzzzzz\",part = \"zzz\") == \"z\"\n assert candidate(s = \"banana\",part = \"na\") == \"ba\"\n assert candidate(s = \"abcabcabc\",part = \"cab\") == \"abc\"\n assert candidate(s = \"aabababa\",part = \"aba\") == \"ba\"\n assert candidate(s = \"abababababababababab\",part = \"abab\") == \"\"\n assert candidate(s = \"qwertyuiopqwertyuiopqwertyuiop\",part = \"erty\") == \"qwuiopqwuiopqwuiop\"\n assert candidate(s = \"hellohellohellohellohello\",part = \"hello\") == \"\"\n assert candidate(s = \"abcdefghij\",part = \"xyz\") == \"abcdefghij\"\n assert candidate(s = \"abcdabcdabcdabcd\",part = \"dabc\") == \"abcd\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",part = \"xyz\") == \"abcdefghijklmnopqrstuvw\"\n assert candidate(s = \"aabbccddeeff\",part = \"bbcc\") == \"aaddeeff\"\n assert candidate(s = \"exampleexampleexampleexample\",part = \"exampleexample\") == \"\"\n assert candidate(s = \"aaaaaaabbbbbbbcccccc\",part = \"abc\") == \"aaaaaaabbbbbbbcccccc\"\n assert candidate(s = \"aaaaabbbbbcccc\",part = \"ab\") == \"cccc\"\n assert candidate(s = \"thisisaverylongstringthatwillbeusedtocheckthefunctionality\",part = \"is\") == \"thaverylongstringthatwillbeusedtocheckthefunctionality\"\n assert candidate(s = \"yyyyyyyyyyyyyyyyyyyy\",part = \"yyyy\") == \"\"\n assert candidate(s = \"lkjhgfedcba\",part = \"fe\") == \"lkjhgdcba\"\n assert candidate(s = \"hellohellohello\",part = \"lohe\") == \"hellllo\"\n assert candidate(s = \"abcdeabcdeabcdeabcde\",part = \"abc\") == \"dededede\"\n assert candidate(s = \"hellohellohellohello\",part = \"elloh\") == \"hello\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",part = \"abc\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"aaaaaaaaaabcdeeeeee\",part = \"aaa\") == \"abcdeeeeee\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\",part = \"qwerty\") == \"uiopasdfghjklzxcvbnmuiop\"\n assert candidate(s = \"zzzzzzzzzz\",part = \"zz\") == \"\"\n assert candidate(s = \"stackoverflow\",part = \"flow\") == \"stackover\"\n assert candidate(s = \"aaaaaaabaaaaa\",part = \"aaaa\") == \"aaaba\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",part = \"ghij\") == \"abcdefabcdefabcdef\"\n assert candidate(s = \"acabacabacabacabacab\",part = \"acab\") == \"\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",part = \"abcdefghij\") == \"\"\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccc\",part = \"abccba\") == \"aaaaaaaaaabbbbbbbbbbcccccc\"\n assert candidate(s = \"abcdefghij\",part = \"jihgfedcba\") == \"abcdefghij\"\n assert candidate(s = \"qwertyuiopqwertyuiop\",part = \"rty\") == \"qweuiopqweuiop\"\n assert candidate(s = \"ababababab\",part = \"aba\") == \"bbab\"\n assert candidate(s = \"aabbccddeeffgg\",part = \"bbcc\") == \"aaddeeffgg\"\n assert candidate(s = \"racecaracecaracecar\",part = \"aceca\") == \"rrrr\"\n assert candidate(s = \"xylophoneisfunxylophoneisfunxylophoneisfun\",part = \"xylophoneis\") == \"funfunfun\"\n assert candidate(s = \"abacabadabacaba\",part = \"abaca\") == \"badba\"\n assert candidate(s = \"supercalifragilisticexpialidocious\",part = \"cious\") == \"supercalifragilisticexpialido\"\n assert candidate(s = \"abababababababababab\",part = \"bab\") == \"aaaaa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",part = \"abcabc\") == \"\"\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\",part = \"defabc\") == \"abcdef\"\n assert candidate(s = \"abracadabra\",part = \"abra\") == \"cad\"\n assert candidate(s = \"aaabaaaabaaa\",part = \"aab\") == \"aaaaaa\"\n assert candidate(s = \"longstringwithsomerepeatedpatternpattern\",part = \"pattern\") == \"longstringwithsomerepeated\"\n assert candidate(s = \"programmingprogrammingprogramming\",part = \"gram\") == \"promingpromingproming\"\n assert candidate(s = \"abcabcabcabcabcabcabcabc\",part = \"abcabc\") == \"\"\n assert candidate(s = \"aaaaabaaaaabaaaaab\",part = \"ba\") == \"aaaaaaaaaaaaab\"\n assert candidate(s = \"hellohellohellohellohellohello\",part = \"ll\") == \"heoheoheoheoheoheo\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\",part = \"qwerty\") == \"uiopasdfghjklzxcvbnmuiopasdfghjklzxcvbnm\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\",part = \"xyzxyz\") == \"\"\n assert candidate(s = \"bananaapplebanana\",part = \"an\") == \"baappleba\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",part = \"mnop\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"xyxyxyxyxy\",part = \"xyx\") == \"yyxy\"\n assert candidate(s = \"hellohellohellohello\",part = \"llohe\") == \"hello\"\n assert candidate(s = \"aaaaabbbbbcccccd\",part = \"abc\") == \"aaaaabbbbbcccccd\"\n assert candidate(s = \"abcdabcdabcd\",part = \"cdab\") == \"abcd\"\n assert candidate(s = \"xyzxyzxyzxyz\",part = \"xyz\") == \"\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",part = \"nopqr\") == \"abcdefghijklmstuvwxyz\"\n assert candidate(s = \"xyzyxzyxzyxzyxzyxzyx\",part = \"zyx\") == \"xy\"\n assert candidate(s = \"zzzzzzzzzz\",part = \"zzz\") == \"z\"\n assert candidate(s = \"abcdefgabcdefgabcdefg\",part = \"efgabc\") == \"abcdddefg\"\n assert candidate(s = \"ababababab\",part = \"abab\") == \"ab\"\n assert candidate(s = \"xxxxxxxxxxxxxxxxxxxx\",part = \"xxx\") == \"xx\"\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",part = \"micro\") == \"pneumonoultrascopicsilicovolcanoconiosis\"\n assert candidate(s = \"abcdefgabcdefg\",part = \"def\") == \"abcgabcg\"\n assert candidate(s = \"aabbccddeeaabbccddeeaabbccddeeaabbccdd\",part = \"abcd\") == \"aabbccddeeaabbccddeeaabbccddeeaabbccdd\"\n assert candidate(s = \"abacabadabacabadabacaba\",part = \"abad\") == \"abacabacabacaba\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\",part = \"erty\") == \"qwuiopasdfghjklzxcvbnmqwuiop\"\n assert candidate(s = \"abcdabcdeabcdabcdeabcd\",part = \"bcde\") == \"abcdaabcdaabcd\"\n assert candidate(s = \"abcdabcdabcdabcd\",part = \"abcd\") == \"\"\n assert candidate(s = \"ababababababababababababababababababababababababababababababababab\",part = \"abab\") == \"ab\"\n assert candidate(s = \"abcdabcdabcdabcd\",part = \"abcdabcd\") == \"\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",part = \"zyx\") == \"wvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwerty\",part = \"erty\") == \"qwuiopasdfghjklzxcvbnmqw\"\n assert candidate(s = \"noonnoonnoonnoon\",part = \"noon\") == \"\"\n assert candidate(s = \"oneonetwoonethreeonefouronefiveonesixone\",part = \"oneone\") == \"twoonethreeonefouronefiveonesixone\"\n assert candidate(s = \"12345678901234567890\",part = \"345\") == \"12678901267890\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",part = \"def\") == \"abcghijklmnopqrstuvwxyz\"\n assert candidate(s = \"thisisaverylongstringwithrepeatedpatterns\",part = \"pattern\") == \"thisisaverylongstringwithrepeateds\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",part = \"mnop\") == \"qwertyuiopasdfghjklzxcvbnm\"\n assert candidate(s = \"abcdefghijabcdefghij\",part = \"cdefg\") == \"abhijabhij\"\n assert candidate(s = \"aaaaaaaaaaaabbbbbaaaaaaaaaaabbbbbaaaaaaaaaaabbbbbaaaaaaaaaaabbbbb\",part = \"aaaabbbb\") == \"aaaaaaaabaaaaaaabaaaaaaabaaaaaaab\"\n assert candidate(s = \"abcdefghabcdefghabcdefgh\",part = \"efgh\") == \"abcdabcdabcd\"\n assert candidate(s = \"thisisaverylongstringwithrepeatedpattern\",part = \"pattern\") == \"thisisaverylongstringwithrepeated\"\n assert candidate(s = \"abababababababab\",part = \"abab\") == \"\"\n assert candidate(s = \"abcdeabcdeabcdeabcde\",part = \"abcde\") == \"\"\n assert candidate(s = \"abababababababababab\",part = \"ababa\") == \"bbbab\"\n assert candidate(s = \"abcdeabcdeabcde\",part = \"bcde\") == \"aaa\"\n assert candidate(s = \"abcdefghij\",part = \"gh\") == \"abcdefij\"\n assert candidate(s = \"aabbccddeeff\",part = \"abc\") == \"aabbccddeeff\"\n assert candidate(s = \"xyxxyxyxyx\",part = \"xyx\") == \"y\"\n assert candidate(s = \"aaaaaa\",part = \"aa\") == \"\"\n assert candidate(s = \"abcdefabcdef\",part = \"defabc\") == \"abcdef\"\n assert candidate(s = \"zzzzzzzz\",part = \"zz\") == \"\"\n assert candidate(s = \"bananaanananasanananananana\",part = \"ana\") == \"bnnasnnna\"\n assert candidate(s = \"abcabcabcabcabcabc\",part = \"abcabc\") == \"\"\n assert candidate(s = \"aaaaaa\",part = \"a\") == \"\"\n assert candidate(s = \"abcdefghij\",part = \"efg\") == \"abcdhij\"\n assert candidate(s = \"onetwothreefourfivesixseveneightnineseven\",part = \"seven\") == \"onetwothreefourfivesixeightnine\"\n assert candidate(s = \"abcabcabcabcabcabc\",part = \"ab\") == \"cccccc\"\n assert candidate(s = \"mississippi\",part = \"iss\") == \"mippi\"\n assert candidate(s = \"aaaabbbbcccc\",part = \"bbcc\") == \"aaaa\"\n assert candidate(s = \"abracadabraabracadabra\",part = \"bracad\") == \"aabraaabra\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",part = \"abcdabcd\") == \"\"\n assert candidate(s = \"abababababababab\",part = \"aba\") == \"bbbb\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",part = \"zzzz\") == \"zz\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\",part = \"xyzxyz\") == \"\"\n assert candidate(s = \"aaaaaaaaaa\",part = \"aaa\") == \"a\"\n assert candidate(s = \"repeatedrepeatedrepeatedrepeated\",part = \"repeated\") == \"\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzz\",part = \"zzzz\") == \"zz\"\n assert candidate(s = \"repeatedsubstringrepeatedsubstring\",part = \"ted\") == \"repeasubstringrepeasubstring\"\n assert candidate(s = \"abcdefghijkabcdefghijkabcdefghijk\",part = \"efg\") == \"abcdhijkabcdhijkabcdhijk\"\n assert candidate(s = \"mnopqrsmnopqrsmnopqrs\",part = \"mnopqrs\") == \"\"\n assert candidate(s = \"ananasanananas\",part = \"ana\") == \"nasns\"\n assert candidate(s = \"zzzzz\",part = \"zz\") == \"z\"\n assert candidate(s = \"thisisaverylongstringwithrepeatedparts\",part = \"thisis\") == \"averylongstringwithrepeatedparts\"\n", "comparison": "exact"}, "public_tests": ["\"daabcbaabcbc\"\n\"abc\"", "\"axxxxyyyyb\"\n\"xy\""], "hints": ["Note that a new occurrence of pattern can appear if you remove an old one, For example, s = \"ababcc\" and pattern = \"abc\".", "You can maintain a stack of characters and if the last character of the pattern size in the stack match the pattern remove them"], "metadata": {"canonical_parameter_names": ["s", "part"], "leetcode_dataset_entry_point": "Solution().removeOccurrences", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:46+00:00", "tests_total": 130, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "stack", "simulation"]}, "language": "python", "interface": {"raw_signature": "def removeOccurrences(self, s: str, part: str) -> str:", "container": "Solution", "callable": "removeOccurrences", "parameters": [{"name": "s", "type": "str"}, {"name": "part", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1911, "task_id": "maximum-alternating-subsequence-sum", "difficulty": "Medium", "problem_description": "The alternating sum of a 0-indexed array is defined as the sum of the elements at even indices minus the sum of the elements at odd indices.\n\n- For example, the alternating sum of [4,2,5,3] is (4 + 5) - (2 + 3) = 4.\n\nGiven an array nums, return the maximum alternating sum of any subsequence of nums (after reindexing the elements of the subsequence).\n\nA subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the remaining elements' relative order. For example, [2,7,4] is a subsequence of [4,2,3,7,2,1,4] (the underlined elements), while [2,4,2] is not.\n\nExample 1:\n\nInput: nums = [4,2,5,3]\nOutput: 7\nExplanation: It is optimal to choose the subsequence [4,2,5] with alternating sum (4 + 5) - 2 = 7.\n\nExample 2:\n\nInput: nums = [5,6,7,8]\nOutput: 8\nExplanation: It is optimal to choose the subsequence [8] with alternating sum 8.\n\nExample 3:\n\nInput: nums = [6,2,1,2,4,5]\nOutput: 10\nExplanation: It is optimal to choose the subsequence [6,1,5] with alternating sum (6 + 5) - 1 = 10.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996]) == 100000\n assert candidate(nums = [4, 2, 5, 3]) == 7\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [6, 2, 1, 2, 4, 5]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [100]) == 100\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50]) == 50\n assert candidate(nums = [1, 100000, 1, 100000, 1]) == 199999\n assert candidate(nums = [5, 6, 7, 8]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [100000, 1, 100000, 1, 100000]) == 299998\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5]) == 54\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 100000\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == 499996\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 991\n assert candidate(nums = [100, 50, 100, 50, 100, 50, 100]) == 250\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 24\n assert candidate(nums = [100, 10, 200, 20, 300, 30, 400, 40, 500, 50]) == 1400\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 499976\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15]) == 106\n assert candidate(nums = [100000, 50000, 100000, 50000, 100000, 50000, 100000, 50000, 100000, 50000]) == 300000\n assert candidate(nums = [5, 3, 8, 1, 4, 7, 2, 6, 9]) == 23\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1000\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70]) == 110\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 6\n assert candidate(nums = [9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9]) == 65\n assert candidate(nums = [120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 120\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == 499996\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 9\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5]) == 30\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 100000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 19\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 11\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 15\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 7\n assert candidate(nums = [5, 3, 8, 12, 4, 9, 2, 7, 6, 10]) == 28\n assert candidate(nums = [10, 15, 10, 5, 20, 25, 30, 35, 40, 45]) == 55\n assert candidate(nums = [100000, 99999, 100000, 99998, 100000, 99997, 100000, 99996, 100000, 99995]) == 100010\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9]) == 15\n assert candidate(nums = [5, 3, 8, 6, 7, 2, 9, 4, 1, 10]) == 27\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 140\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 11\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50]) == 100\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 29\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 28\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 17\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 17\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [9, 7, 8, 5, 6, 3, 4, 1, 2, 10]) == 21\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 20\n assert candidate(nums = [5, 3, 8, 6, 11, 9, 14, 12, 17, 15, 20, 18, 23, 21, 25]) == 39\n assert candidate(nums = [5, 3, 6, 7, 2, 9, 4, 10, 1, 11]) == 32\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 11\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 13\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 20\n assert candidate(nums = [75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 75\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 21\n assert candidate(nums = [5, 1, 4, 2, 7, 3, 6, 8]) == 18\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]) == 46\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 13\n assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4]) == 399984\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 120\n assert candidate(nums = [10, 5, 15, 10, 20, 15, 25, 20, 30, 25]) == 50\n assert candidate(nums = [5, 1, 4, 2, 3]) == 9\n assert candidate(nums = [5, 1, 4, 2, 3, 1, 2, 1, 3, 2, 1]) == 12\n assert candidate(nums = [5, 3, 8, 12, 7, 10, 1, 15, 9, 20]) == 42\n assert candidate(nums = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == 499990\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 110\n assert candidate(nums = [100, 200, 150, 300, 250, 350, 400, 300, 450, 500]) == 700\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 5, 4, 6, 3, 7, 2, 8, 1, 9]) == 45\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 150\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 476\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 10000, 1000, 100, 10]) == 100000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 75\n assert candidate(nums = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 150\n", "comparison": "exact"}, "public_tests": ["[4,2,5,3]", "[5,6,7,8]", "[6,2,1,2,4,5]"], "hints": ["Is only tracking a single sum enough to solve the problem?", "How does tracking an odd sum and an even sum reduce the number of states?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxAlternatingSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:49+00:00", "tests_total": 96, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def maxAlternatingSum(self, nums: List[int]) -> int:", "container": "Solution", "callable": "maxAlternatingSum", "parameters": [{"name": "nums", "type": "List[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1913, "task_id": "maximum-product-difference-between-two-pairs", "difficulty": "Easy", "problem_description": "The product difference between two pairs (a, b) and (c, d) is defined as (a * b) - (c * d).\n\n- For example, the product difference between (5, 6) and (2, 7) is (5 * 6) - (2 * 7) = 16.\n\nGiven an integer array nums, choose four distinct indices w, x, y, and z such that the product difference between pairs (nums[w], nums[x]) and (nums[y], nums[z]) is maximized.\n\nReturn the maximum such product difference.\n\nExample 1:\n\nInput: nums = [5,6,2,7,4]\nOutput: 34\nExplanation: We can choose indices 1 and 3 for the first pair (6, 7) and indices 2 and 4 for the second pair (2, 4).\nThe product difference is (6 * 7) - (2 * 4) = 34.\n\nExample 2:\n\nInput: nums = [4,2,5,9,7,4,8]\nOutput: 64\nExplanation: We can choose indices 3 and 6 for the first pair (9, 8) and indices 1 and 5 for the second pair (2, 4).\nThe product difference is (9 * 8) - (2 * 4) = 64.\n\nConstraints:\n\n- 4 <= nums.length <= 10^4\n- 1 <= nums[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 6, 2, 7, 4]) == 34\n assert candidate(nums = [9, 5, 8, 6, 7, 3, 2, 1, 4]) == 70\n assert candidate(nums = [1, 2, 3, 4]) == 10\n assert candidate(nums = [4, 2, 5, 9, 7, 4, 8]) == 64\n assert candidate(nums = [10000, 1, 10000, 1]) == 99999999\n assert candidate(nums = [9, 5, 8, 6, 7, 3, 4, 2, 1]) == 70\n assert candidate(nums = [9, 5, 8, 3, 7]) == 57\n assert candidate(nums = [10000, 1, 10000, 1, 10000, 1]) == 99999999\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 88000000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 2080000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 896\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 880000\n assert candidate(nums = [2345, 1234, 5678, 6789, 3456, 4567, 7890, 8901]) == 67335160\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 11766\n assert candidate(nums = [5000, 5000, 5000, 5000, 1, 1, 1, 1]) == 24999999\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10000, 10000, 10000, 10000, 10000]) == 99999999\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 832\n assert candidate(nums = [10000, 10000, 10000, 10000, 9999, 9999, 9999, 9999]) == 19999\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 1, 9999]) == 49990000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 780\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 80\n assert candidate(nums = [10000, 1, 9999, 2, 9998, 3, 9997, 4, 9996, 5]) == 99989998\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996]) == 99989998\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 3258\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10000, 10000, 10000, 10000, 10000]) == 99999975\n assert candidate(nums = [10000, 9999, 1, 2]) == 99989998\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 159928\n assert candidate(nums = [8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 100, 200, 300, 400, 500, 600, 700, 800]) == 55980000\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19]) == 357\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 10, 20, 30, 40, 50]) == 899800\n assert candidate(nums = [5000, 5000, 5000, 5000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 24999999\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009]) == 16072\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 99\n assert candidate(nums = [10000, 10000, 10000, 10000, 1, 1, 1, 1]) == 99999999\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 2015\n assert candidate(nums = [3333, 6666, 4444, 7777, 2222, 8888, 1111, 9999]) == 86402470\n assert candidate(nums = [5000, 5000, 4999, 4999, 4998, 4998, 4997, 4997, 4996, 4996]) == 39984\n assert candidate(nums = [8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 500, 100, 50, 10, 5, 1, 2, 3, 4, 6, 7, 8]) == 55999998\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86]) == 2418\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996, 6, 9995, 7, 9994, 8, 9993, 9, 9992, 10, 9991]) == 99989998\n assert candidate(nums = [2, 3, 6, 7, 8, 10, 5, 4, 1, 9]) == 88\n assert candidate(nums = [10000, 10000, 10000, 1, 1, 1, 9999, 9999, 9999, 2]) == 99999999\n assert candidate(nums = [9999, 9998, 9997, 9996, 2, 3, 4, 5]) == 99969996\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 1672\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 378\n assert candidate(nums = [3, 9, 10, 2, 18, 15, 11, 1, 17, 7]) == 304\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996, 6, 9995, 7, 9994, 8]) == 99989998\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4]) == 899998\n assert candidate(nums = [1, 1, 1, 1, 10000, 10000, 10000, 10000, 9999, 9999, 9999, 9999]) == 99999999\n assert candidate(nums = [10000, 9999, 9998, 9997, 1, 2, 3, 4, 5, 6]) == 99989998\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997]) == 99989998\n assert candidate(nums = [5000, 5001, 4999, 4998, 5002, 5003]) == 40004\n assert candidate(nums = [1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000]) == 99999999\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 1, 2, 3, 4, 5]) == 25035010\n assert candidate(nums = [10000, 9999, 9998, 9997, 1, 2, 3, 4]) == 99989998\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 10000, 10000]) == 99999991\n assert candidate(nums = [1, 10000, 1, 10000, 1, 10000, 1, 10000]) == 99999999\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 8800\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 2080000\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 8627\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 208\n assert candidate(nums = [1500, 1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 2080000\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996]) == 99989998\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 880000\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97]) == 9898\n assert candidate(nums = [1, 2, 3, 4, 5, 10000, 9999, 9998, 9997, 9996]) == 99989998\n assert candidate(nums = [1, 1, 1, 1, 10000, 10000, 10000, 10000, 10000, 10000]) == 99999999\n assert candidate(nums = [2500, 2501, 2502, 2503, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 6262504\n assert candidate(nums = [5000, 4000, 3000, 2000, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 19999997\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 378\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 360\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10000, 9999]) == 99989999\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5]) == 899998\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985]) == 279790\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 8\n assert candidate(nums = [9999, 1, 9998, 2, 9997, 3, 9996, 4, 9995, 5, 9994, 6, 9993, 7, 9992, 8, 9991, 9, 9990, 10]) == 99970000\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011, 5012, 5013, 5014, 5015]) == 140210\n assert candidate(nums = [10000, 1, 9999, 2, 9998, 3, 9997, 4, 9996, 5]) == 99989998\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 99989998\n assert candidate(nums = [10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 189998\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 1, 2, 3, 4, 5]) == 24999998\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 1, 2, 3, 4, 5]) == 99970000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 8800\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10000]) == 49975\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 1810\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == 2485\n assert candidate(nums = [9999, 9998, 9997, 9996, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 99970000\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 89\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 661\n assert candidate(nums = [5000, 5001, 5002, 5003, 1, 2, 3, 4]) == 25025004\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 20800\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 5200\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10000]) == 89998\n", "comparison": "exact"}, "public_tests": ["[5,6,2,7,4]", "[4,2,5,9,7,4,8]"], "hints": ["If you only had to find the maximum product of 2 numbers in an array, which 2 numbers should you choose?", "We only need to worry about 4 numbers in the array."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxProductDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:51+00:00", "tests_total": 98, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "sorting", "quicksort"]}, "language": "python", "interface": {"raw_signature": "def maxProductDifference(self, nums: List[int]) -> int:", "container": "Solution", "callable": "maxProductDifference", "parameters": [{"name": "nums", "type": "List[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1914, "task_id": "cyclically-rotating-a-grid", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix grid, where m and n are both even integers, and an integer k.\n\nThe matrix is composed of several layers, which is shown in the below image, where each color is its own layer:\n\nA cyclic rotation of the matrix is done by cyclically rotating each layer in the matrix. To cyclically rotate a layer once, each element in the layer will take the place of the adjacent element in the counter-clockwise direction. An example rotation is shown below:\n\nReturn the matrix after applying k cyclic rotations to it.\n\nExample 1:\n\nInput: grid = [[40,10],[30,20]], k = 1\nOutput: [[10,20],[40,30]]\nExplanation: The figures above represent the grid at every state.\n\nExample 2:\n\nInput: grid = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]], k = 2\nOutput: [[3,4,8,12],[2,11,10,16],[1,7,6,15],[5,9,13,14]]\nExplanation: The figures above represent the grid at every state.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 2 <= m, n <= 50\n- Both m and n are even integers.\n- 1 <= grid[i][j] <=5000\n- 1 <= k <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8]],k = 1) == [[2, 4], [1, 6], [3, 8], [5, 7]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 4) == [[5, 6, 7, 8, 16, 24, 32, 40], [4, 14, 15, 23, 31, 39, 47, 48], [3, 13, 30, 38, 46, 45, 55, 56], [2, 12, 22, 28, 29, 44, 54, 64], [1, 11, 21, 36, 37, 43, 53, 63], [9, 10, 20, 19, 27, 35, 52, 62], [17, 18, 26, 34, 42, 50, 51, 61], [25, 33, 41, 49, 57, 58, 59, 60]]\n assert candidate(grid = [[100, 200, 300, 400], [500, 600, 700, 800], [900, 1000, 1100, 1200], [1300, 1400, 1500, 1600]],k = 10) == [[900, 500, 100, 200], [1300, 1100, 1000, 300], [1400, 700, 600, 400], [1500, 1600, 1200, 800]]\n assert candidate(grid = [[100, 101, 102], [99, 103, 104], [98, 105, 106]],k = 4) == [[106, 105, 98], [104, 103, 99], [102, 101, 100]]\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8]],k = 5) == [[7, 5], [8, 3], [6, 1], [4, 2]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]],k = 3) == [[4, 5, 6, 12, 18, 24], [3, 11, 17, 23, 29, 30], [2, 10, 21, 15, 28, 36], [1, 9, 22, 16, 27, 35], [7, 8, 14, 20, 26, 34], [13, 19, 25, 31, 32, 33]]\n assert candidate(grid = [[5000, 5000, 5000, 5000], [5000, 1, 2, 5000], [5000, 4, 3, 5000], [5000, 5000, 5000, 5000]],k = 1000000000) == [[5000, 5000, 5000, 5000], [5000, 1, 2, 5000], [5000, 4, 3, 5000], [5000, 5000, 5000, 5000]]\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 1000000000) == [[8, 12, 16, 15], [4, 6, 7, 14], [3, 10, 11, 13], [2, 1, 5, 9]]\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 2) == [[3, 4, 8, 12], [2, 11, 10, 16], [1, 7, 6, 15], [5, 9, 13, 14]]\n assert candidate(grid = [[40, 10], [30, 20]],k = 1) == [[10, 20], [40, 30]]\n assert candidate(grid = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]],k = 7) == [[150, 140, 130, 90], [160, 100, 60, 50], [120, 110, 70, 10], [80, 40, 30, 20]]\n assert candidate(grid = [[100, 101, 102, 103, 104, 105, 106, 107], [108, 11, 12, 13, 14, 15, 16, 109], [110, 17, 18, 19, 20, 21, 22, 111], [112, 23, 24, 25, 26, 27, 28, 113], [114, 29, 30, 31, 32, 33, 34, 115], [116, 35, 36, 37, 38, 39, 40, 117], [118, 41, 42, 43, 44, 45, 46, 119], [120, 121, 122, 123, 124, 125, 126, 127]],k = 10) == [[113, 115, 117, 119, 127, 126, 125, 124], [111, 46, 45, 44, 43, 42, 41, 123], [109, 40, 30, 24, 18, 19, 35, 122], [107, 34, 36, 32, 31, 20, 29, 121], [106, 28, 37, 26, 25, 21, 23, 120], [105, 22, 38, 39, 33, 27, 17, 118], [104, 16, 15, 14, 13, 12, 11, 116], [103, 102, 101, 100, 108, 110, 112, 114]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2]],k = 50) == [[1, 1, 1, 1, 1, 1, 1, 2], [1, 7, 6, 5, 4, 3, 2, 3], [2, 7, 5, 6, 6, 6, 2, 4], [3, 7, 4, 5, 4, 6, 2, 5], [4, 7, 3, 5, 4, 5, 2, 6], [5, 7, 3, 3, 3, 4, 2, 7], [6, 7, 6, 5, 4, 3, 2, 8], [7, 2, 2, 2, 2, 2, 2, 2]]\n assert candidate(grid = [[6, 7, 8, 9], [5, 2, 3, 10], [4, 1, 12, 11], [13, 14, 15, 16]],k = 3) == [[9, 10, 11, 16], [8, 1, 2, 15], [7, 12, 3, 14], [6, 5, 4, 13]]\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24], [25, 26, 27, 28], [29, 30, 31, 32]],k = 500000000) == [[1, 2, 3, 4], [5, 22, 18, 8], [9, 26, 14, 12], [13, 27, 10, 16], [17, 23, 6, 20], [21, 19, 7, 24], [25, 15, 11, 28], [29, 30, 31, 32]]\n assert candidate(grid = [[5000, 5000, 5000, 5000, 5000, 5000], [5000, 1, 2, 3, 4, 5000], [5000, 6, 7, 8, 9, 5000], [5000, 10, 11, 12, 13, 5000], [5000, 14, 15, 16, 17, 5000], [5000, 5000, 5000, 5000, 5000, 5000]],k = 1000000000) == [[5000, 5000, 5000, 5000, 5000, 5000], [5000, 9, 13, 17, 16, 5000], [5000, 4, 7, 8, 15, 5000], [5000, 3, 11, 12, 14, 5000], [5000, 2, 1, 6, 10, 5000], [5000, 5000, 5000, 5000, 5000, 5000]]\n assert candidate(grid = [[100, 101, 102, 103, 104], [99, 49, 50, 51, 105], [98, 48, 1, 2, 106], [97, 47, 46, 3, 107], [96, 95, 94, 93, 108]],k = 7) == [[107, 108, 93, 94, 95], [106, 48, 49, 50, 96], [105, 47, 1, 51, 97], [104, 46, 3, 2, 98], [103, 102, 101, 100, 99]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 25) == [[25, 17, 9, 1, 2, 3, 4, 5], [33, 15, 23, 31, 39, 47, 55, 6], [41, 14, 20, 21, 22, 30, 54, 7], [49, 13, 19, 29, 37, 38, 53, 8], [57, 12, 27, 28, 36, 46, 52, 16], [58, 11, 35, 43, 44, 45, 51, 24], [59, 10, 18, 26, 34, 42, 50, 32], [60, 61, 62, 63, 64, 56, 48, 40]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 13) == [[16, 11, 6, 1, 2], [21, 18, 17, 12, 3], [22, 19, 13, 7, 4], [23, 14, 9, 8, 5], [24, 25, 20, 15, 10]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 1]],k = 5) == [[1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 3, 2, 2, 1], [1, 2, 4, 3, 4, 4, 3, 1], [1, 2, 3, 4, 5, 3, 3, 2], [1, 2, 3, 4, 4, 3, 3, 2], [1, 2, 3, 3, 3, 3, 3, 2], [1, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 2, 2]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 10) == [[32, 40, 48, 56, 64, 63, 62, 61], [24, 55, 54, 53, 52, 51, 50, 60], [16, 47, 35, 27, 19, 20, 42, 59], [8, 39, 43, 37, 36, 21, 34, 58], [7, 31, 44, 29, 28, 22, 26, 57], [6, 23, 45, 46, 38, 30, 18, 49], [5, 15, 14, 13, 12, 11, 10, 41], [4, 3, 2, 1, 9, 17, 25, 33]]\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]],k = 100) == [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]\n assert candidate(grid = [[2, 3, 4, 5, 6, 7, 8], [1, 14, 13, 12, 11, 10, 9], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]],k = 25) == [[3, 4, 5, 6, 7, 8, 9], [2, 40, 39, 38, 37, 30, 21], [1, 41, 18, 19, 26, 23, 28], [15, 34, 17, 25, 33, 16, 35], [22, 27, 24, 31, 32, 14, 42], [29, 20, 10, 11, 12, 13, 49], [36, 43, 44, 45, 46, 47, 48]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48]],k = 100) == [[5, 6, 12, 18, 24, 30], [4, 17, 23, 29, 35, 36], [3, 11, 34, 33, 41, 42], [2, 10, 28, 27, 40, 48], [1, 9, 22, 21, 39, 47], [7, 8, 16, 15, 38, 46], [13, 14, 20, 26, 32, 45], [19, 25, 31, 37, 43, 44]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]],k = 5) == [[6, 12, 18, 24, 30, 36], [5, 23, 29, 28, 27, 35], [4, 17, 16, 22, 26, 34], [3, 11, 15, 21, 20, 33], [2, 10, 9, 8, 14, 32], [1, 7, 13, 19, 25, 31]]\n assert candidate(grid = [[9, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2]],k = 100) == [[6, 5, 4, 3, 2, 1, 1, 1], [7, 2, 3, 4, 5, 6, 7, 1], [2, 2, 6, 6, 6, 5, 7, 1], [2, 2, 6, 4, 5, 4, 7, 1], [2, 2, 5, 4, 5, 3, 7, 1], [2, 2, 4, 3, 3, 3, 7, 9], [2, 2, 3, 4, 5, 6, 7, 2], [2, 2, 8, 7, 6, 5, 4, 3]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80]],k = 1000000000) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 65, 64, 63, 62, 52, 42, 32, 22, 20], [21, 66, 23, 24, 25, 26, 27, 28, 12, 30], [31, 67, 33, 34, 35, 36, 37, 38, 13, 40], [41, 68, 43, 44, 45, 46, 47, 48, 14, 50], [51, 69, 53, 54, 55, 56, 57, 58, 15, 60], [61, 59, 49, 39, 29, 19, 18, 17, 16, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 20) == [[58, 57, 49, 41, 33, 25, 17, 9], [59, 10, 11, 12, 13, 14, 15, 1], [60, 18, 44, 43, 35, 27, 23, 2], [61, 26, 45, 28, 29, 19, 31, 3], [62, 34, 46, 36, 37, 20, 39, 4], [63, 42, 38, 30, 22, 21, 47, 5], [64, 50, 51, 52, 53, 54, 55, 6], [56, 48, 40, 32, 24, 16, 8, 7]]\n assert candidate(grid = [[9, 10, 11, 12, 13, 14], [8, 17, 18, 19, 20, 15], [7, 16, 25, 26, 21, 16], [6, 15, 24, 23, 22, 17], [5, 14, 13, 12, 11, 18], [4, 3, 2, 1, 0, 19]],k = 23) == [[12, 13, 14, 15, 16, 17], [11, 16, 17, 18, 19, 18], [10, 15, 24, 25, 20, 19], [9, 14, 23, 26, 21, 0], [8, 13, 12, 11, 22, 1], [7, 6, 5, 4, 3, 2]]\n assert candidate(grid = [[5000, 1, 2, 3, 4, 5, 6, 5000], [5000, 5000, 1, 2, 3, 4, 5000, 5000], [5000, 5000, 5000, 1, 2, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 1, 2, 5000, 5000, 5000], [5000, 5000, 1, 2, 3, 4, 5000, 5000], [5000, 1, 2, 3, 4, 5, 6, 5000], [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]],k = 1000000000) == [[5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 1, 2, 3, 4, 5000, 5000], [5000, 5000, 5000, 5000, 4, 3, 5000, 1], [5000, 5000, 5000, 5000, 5000, 2, 5000, 2], [5000, 5000, 2, 1, 2, 1, 5000, 3], [5000, 5000, 1, 5000, 5000, 5000, 5000, 4], [5000, 1, 2, 3, 4, 5, 6, 5], [5000, 5000, 5000, 5000, 5000, 5000, 5000, 6]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6]],k = 4) == [[1, 1, 2, 3, 4, 5], [1, 3, 4, 5, 5, 6], [1, 2, 3, 3, 5, 6], [1, 2, 4, 4, 5, 6], [1, 2, 2, 3, 4, 6], [2, 3, 4, 5, 6, 6]]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 1, 2, 3, 4, 5], [5, 6, 7, 8, 9, 5], [5, 10, 11, 12, 13, 5], [5, 14, 15, 16, 17, 5], [5, 5, 5, 5, 5, 5]],k = 15) == [[5, 5, 5, 5, 5, 5], [5, 4, 9, 13, 17, 5], [5, 3, 11, 7, 16, 5], [5, 2, 12, 8, 15, 5], [5, 1, 6, 10, 14, 5], [5, 5, 5, 5, 5, 5]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 50) == [[49, 41, 33, 25, 17, 9, 1, 2], [57, 55, 54, 53, 52, 51, 50, 3], [58, 47, 21, 22, 30, 38, 42, 4], [59, 39, 20, 37, 36, 46, 34, 5], [60, 31, 19, 29, 28, 45, 26, 6], [61, 23, 27, 35, 43, 44, 18, 7], [62, 15, 14, 13, 12, 11, 10, 8], [63, 64, 56, 48, 40, 32, 24, 16]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 15) == [[63, 62, 61, 60, 59, 58, 57, 49], [64, 50, 42, 34, 26, 18, 10, 41], [56, 51, 22, 30, 38, 46, 11, 33], [48, 52, 21, 36, 28, 45, 12, 25], [40, 53, 20, 37, 29, 44, 13, 17], [32, 54, 19, 27, 35, 43, 14, 9], [24, 55, 47, 39, 31, 23, 15, 1], [16, 8, 7, 6, 5, 4, 3, 2]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 5) == [[6, 7, 8, 16, 24, 32, 40, 48], [5, 15, 23, 31, 39, 47, 55, 56], [4, 14, 38, 46, 45, 44, 54, 64], [3, 13, 30, 29, 37, 43, 53, 63], [2, 12, 22, 28, 36, 35, 52, 62], [1, 11, 21, 20, 19, 27, 51, 61], [9, 10, 18, 26, 34, 42, 50, 60], [17, 25, 33, 41, 49, 57, 58, 59]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]],k = 15) == [[31, 25, 19, 13, 7, 1], [32, 11, 17, 23, 29, 2], [33, 10, 21, 15, 28, 3], [34, 9, 22, 16, 27, 4], [35, 8, 14, 20, 26, 5], [36, 30, 24, 18, 12, 6]]\n assert candidate(grid = [[1, 2, 3, 4], [12, 13, 14, 5], [11, 16, 15, 6], [10, 9, 8, 7]],k = 3) == [[4, 5, 6, 7], [3, 16, 13, 8], [2, 15, 14, 9], [1, 12, 11, 10]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48]],k = 1000000000) == [[44, 43, 37, 31, 25, 19], [45, 8, 9, 10, 11, 13], [46, 14, 15, 16, 17, 7], [47, 20, 21, 22, 23, 1], [48, 26, 27, 28, 29, 2], [42, 32, 33, 34, 35, 3], [36, 38, 39, 40, 41, 4], [30, 24, 18, 12, 6, 5]]\n assert candidate(grid = [[6, 7, 8, 9, 10], [5, 4, 3, 2, 11], [14, 13, 12, 1, 15], [19, 18, 17, 16, 20], [24, 23, 22, 21, 25]],k = 3) == [[9, 10, 11, 15, 20], [8, 1, 16, 17, 25], [7, 2, 12, 18, 21], [6, 3, 4, 13, 22], [5, 14, 19, 24, 23]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]],k = 15) == [[46, 45, 44, 43, 36, 29, 22], [47, 16, 9, 10, 11, 12, 15], [48, 23, 24, 17, 18, 13, 8], [49, 30, 31, 25, 19, 20, 1], [42, 37, 32, 33, 26, 27, 2], [35, 38, 39, 40, 41, 34, 3], [28, 21, 14, 7, 6, 5, 4]]\n assert candidate(grid = [[4, 3, 2, 1, 0], [9, 8, 7, 6, 5], [14, 13, 12, 11, 10], [19, 18, 17, 16, 15], [24, 23, 22, 21, 20]],k = 3) == [[1, 0, 5, 10, 15], [2, 11, 16, 17, 20], [3, 6, 12, 18, 21], [4, 7, 8, 13, 22], [9, 14, 19, 24, 23]]\n assert candidate(grid = [[10, 20, 30, 40, 50, 60], [70, 80, 90, 100, 110, 120], [130, 140, 150, 160, 170, 180], [190, 200, 210, 220, 230, 240], [250, 260, 270, 280, 290, 300], [310, 320, 330, 340, 350, 360]],k = 7) == [[180, 240, 300, 360, 350, 340], [120, 280, 270, 260, 200, 330], [60, 290, 210, 150, 140, 320], [50, 230, 220, 160, 80, 310], [40, 170, 110, 100, 90, 250], [30, 20, 10, 70, 130, 190]]\n assert candidate(grid = [[100, 101, 102, 103, 104, 105, 106, 107, 108, 109], [110, 1, 2, 3, 4, 5, 6, 7, 8, 111], [112, 9, 12, 13, 14, 15, 16, 17, 9, 113], [114, 8, 11, 18, 19, 20, 21, 10, 12, 115], [116, 7, 10, 19, 22, 23, 18, 11, 13, 117], [118, 6, 9, 20, 25, 24, 17, 12, 14, 119], [120, 5, 8, 21, 26, 27, 22, 13, 15, 121], [122, 4, 7, 28, 29, 30, 25, 14, 16, 123], [124, 3, 6, 31, 32, 33, 34, 26, 17, 125], [126, 2, 5, 35, 36, 37, 38, 39, 40, 127]],k = 15) == [[121, 123, 125, 127, 40, 39, 38, 37, 36, 35], [119, 26, 34, 33, 32, 31, 6, 3, 4, 5], [117, 17, 7, 8, 9, 10, 11, 12, 5, 2], [115, 16, 28, 21, 18, 17, 22, 13, 6, 126], [113, 15, 29, 20, 25, 22, 27, 14, 7, 124], [111, 14, 30, 19, 24, 23, 26, 15, 8, 122], [109, 13, 25, 18, 19, 20, 21, 16, 9, 120], [108, 12, 14, 13, 12, 11, 10, 17, 1, 118], [107, 9, 8, 7, 6, 5, 4, 3, 2, 116], [106, 105, 104, 103, 102, 101, 100, 110, 112, 114]]\n assert candidate(grid = [[100, 200, 300, 400], [201, 5, 6, 501], [202, 7, 8, 502], [303, 403, 503, 600]],k = 3) == [[400, 501, 502, 600], [300, 7, 5, 503], [200, 8, 6, 403], [100, 201, 202, 303]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]],k = 15) == [[31, 25, 19, 13, 7, 1], [32, 11, 17, 23, 29, 2], [33, 10, 21, 15, 28, 3], [34, 9, 22, 16, 27, 4], [35, 8, 14, 20, 26, 5], [36, 30, 24, 18, 12, 6]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [21, 22, 23, 24, 25, 7], [20, 35, 36, 37, 26, 8], [19, 34, 39, 38, 27, 9], [18, 33, 32, 31, 28, 10], [17, 16, 15, 14, 13, 11]],k = 3) == [[4, 5, 6, 7, 8, 9], [3, 25, 26, 27, 28, 10], [2, 24, 39, 36, 31, 11], [1, 23, 38, 37, 32, 13], [21, 22, 35, 34, 33, 14], [20, 19, 18, 17, 16, 15]]\n assert candidate(grid = [[5000, 1, 2, 5000, 3, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000]],k = 1000000000) == [[5000, 1, 2, 5000, 3, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000]]\n assert candidate(grid = [[100, 101, 102, 103], [104, 105, 106, 107], [108, 109, 110, 111], [112, 113, 114, 115]],k = 7) == [[114, 113, 112, 108], [115, 109, 105, 104], [111, 110, 106, 100], [107, 103, 102, 101]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 20) == [[58, 57, 49, 41, 33, 25, 17, 9], [59, 10, 11, 12, 13, 14, 15, 1], [60, 18, 44, 43, 35, 27, 23, 2], [61, 26, 45, 28, 29, 19, 31, 3], [62, 34, 46, 36, 37, 20, 39, 4], [63, 42, 38, 30, 22, 21, 47, 5], [64, 50, 51, 52, 53, 54, 55, 6], [56, 48, 40, 32, 24, 16, 8, 7]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 50) == [[3, 4, 5, 10, 15], [2, 9, 14, 19, 20], [1, 8, 13, 18, 25], [6, 7, 12, 17, 24], [11, 16, 21, 22, 23]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 7) == [[8, 16, 24, 32, 40, 48, 56, 64], [7, 31, 39, 47, 55, 54, 53, 63], [6, 23, 45, 44, 43, 35, 52, 62], [5, 15, 46, 36, 28, 27, 51, 61], [4, 14, 38, 37, 29, 19, 50, 60], [3, 13, 30, 22, 21, 20, 42, 59], [2, 12, 11, 10, 18, 26, 34, 58], [1, 9, 17, 25, 33, 41, 49, 57]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]],k = 1000000000) == [[81, 71, 61, 51, 41, 31, 21, 11, 1, 2], [91, 83, 82, 72, 62, 52, 42, 32, 22, 3], [92, 84, 23, 24, 25, 26, 27, 28, 12, 4], [93, 85, 33, 47, 57, 67, 66, 38, 13, 5], [94, 86, 43, 37, 45, 46, 65, 48, 14, 6], [95, 87, 53, 36, 55, 56, 64, 58, 15, 7], [96, 88, 63, 35, 34, 44, 54, 68, 16, 8], [97, 89, 73, 74, 75, 76, 77, 78, 17, 9], [98, 79, 69, 59, 49, 39, 29, 19, 18, 10], [99, 100, 90, 80, 70, 60, 50, 40, 30, 20]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]],k = 50) == [[60, 70, 80, 90, 100, 99, 98, 97, 96, 95], [50, 72, 62, 52, 42, 32, 22, 12, 13, 94], [40, 82, 78, 77, 76, 75, 74, 73, 14, 93], [30, 83, 68, 36, 37, 47, 57, 63, 15, 92], [20, 84, 58, 35, 56, 55, 67, 53, 16, 91], [10, 85, 48, 34, 46, 45, 66, 43, 17, 81], [9, 86, 38, 44, 54, 64, 65, 33, 18, 71], [8, 87, 28, 27, 26, 25, 24, 23, 19, 61], [7, 88, 89, 79, 69, 59, 49, 39, 29, 51], [6, 5, 4, 3, 2, 1, 11, 21, 31, 41]]\n", "comparison": "exact"}, "public_tests": ["[[40,10],[30,20]]\n1", "[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]\n2"], "hints": ["First, you need to consider each layer separately as an array.", "Just cycle this array and then re-assign it."], "metadata": {"canonical_parameter_names": ["grid", "k"], "leetcode_dataset_entry_point": "Solution().rotateGrid", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:53+00:00", "tests_total": 57, "tests_dropped": 4, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "matrix", "simulation"]}, "language": "python", "interface": {"raw_signature": "def rotateGrid(self, grid: List[List[int]], k: int) -> List[List[int]]:", "container": "Solution", "callable": "rotateGrid", "parameters": [{"name": "grid", "type": "List[List[int]]"}, {"name": "k", "type": "int"}], "return_type": "List[List[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1915, "task_id": "number-of-wonderful-substrings", "difficulty": "Medium", "problem_description": "A wonderful string is a string where at most one letter appears an odd number of times.\n\n- For example, \"ccjjc\" and \"abab\" are wonderful, but \"ab\" is not.\n\nGiven a string word that consists of the first ten lowercase English letters ('a' through 'j'), return the number of wonderful non-empty substrings in word. If the same substring appears multiple times in word, then count each occurrence separately.\n\nA substring is a contiguous sequence of characters in a string.\n\nExample 1:\n\nInput: word = \"aba\"\nOutput: 4\nExplanation: The four wonderful substrings are underlined below:\n- \"aba\" -> \"a\"\n- \"aba\" -> \"b\"\n- \"aba\" -> \"a\"\n- \"aba\" -> \"aba\"\n\nExample 2:\n\nInput: word = \"aabb\"\nOutput: 9\nExplanation: The nine wonderful substrings are underlined below:\n- \"aabb\" -> \"a\"\n- \"aabb\" -> \"aa\"\n- \"aabb\" -> \"aab\"\n- \"aabb\" -> \"aabb\"\n- \"aabb\" -> \"a\"\n- \"aabb\" -> \"abb\"\n- \"aabb\" -> \"b\"\n- \"aabb\" -> \"bb\"\n- \"aabb\" -> \"b\"\n\nExample 3:\n\nInput: word = \"he\"\nOutput: 2\nExplanation: The two wonderful substrings are underlined below:\n- \"he\" -> \"h\"\n- \"he\" -> \"e\"\n\nConstraints:\n\n- 1 <= word.length <= 10^5\n- word consists of lowercase English letters from 'a' to 'j'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aaaaaaaaaa\") == 55\n assert candidate(word = \"aabbccddeeffgghhiijj\") == 165\n assert candidate(word = \"aba\") == 4\n assert candidate(word = \"aaaabbbbcccc\") == 66\n assert candidate(word = \"babcbabcbab\") == 32\n assert candidate(word = \"abcdefghija\") == 11\n assert candidate(word = \"abcdcba\") == 10\n assert candidate(word = \"aaa\") == 6\n assert candidate(word = \"aabb\") == 9\n assert candidate(word = \"aabbccddeeffgg\") == 84\n assert candidate(word = \"abcdefghij\") == 10\n assert candidate(word = \"jihgfedcba\") == 10\n assert candidate(word = \"aabbccddeeff\") == 63\n assert candidate(word = \"abcabc\") == 9\n assert candidate(word = \"abacaba\") == 12\n assert candidate(word = \"jij\") == 4\n assert candidate(word = \"abcdefghijabcdefghij\") == 23\n assert candidate(word = \"abcde\") == 5\n assert candidate(word = \"ijji\") == 8\n assert candidate(word = \"jjjjj\") == 15\n assert candidate(word = \"jijijijiji\") == 40\n assert candidate(word = \"aabbaa\") == 19\n assert candidate(word = \"abcabcabc\") == 21\n assert candidate(word = \"he\") == 2\n assert candidate(word = \"a\") == 1\n assert candidate(word = \"abcdefghijabcdefghijabcdefghij\") == 63\n assert candidate(word = \"jijjjijijj\") == 41\n assert candidate(word = \"aaaaaaa\") == 28\n assert candidate(word = \"aaaaa\") == 15\n assert candidate(word = \"abacabadabacaba\") == 32\n assert candidate(word = \"aaaaaaaabbbbbbbbaaaaaaaabbbbbbbb\") == 464\n assert candidate(word = \"jihgfedcbajihgfedcbajihgfedcbajihgfedcbajihgfedcba\") == 176\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 1038\n assert candidate(word = \"jijijiijijijiijijijiijijijiijijijiijijijiijijiij\") == 879\n assert candidate(word = \"abcdefghijabcde\") == 15\n assert candidate(word = \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\") == 903\n assert candidate(word = \"acacacacacacacacacac\") == 155\n assert candidate(word = \"jijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjj\") == 5171\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 106\n assert candidate(word = \"aabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccdd\") == 4720\n assert candidate(word = \"aabbaaabbbaaabbaaa\") == 126\n assert candidate(word = \"jjiijjiijjjiiijjiiijjjijjjiiijjiiijjjijjjjj\") == 721\n assert candidate(word = \"aabbaabbaabbaabb\") == 120\n assert candidate(word = \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\") == 990\n assert candidate(word = \"aabbaabbaabbaabbccddeeffgghhiijj\") == 420\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabc\") == 225\n assert candidate(word = \"abcdeedcba\") == 23\n assert candidate(word = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjj\") == 640\n assert candidate(word = \"abcdabcdaabbccddeeffgghhiijj\") == 222\n assert candidate(word = \"ababababababababababababababababababababab\") == 672\n assert candidate(word = \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\") == 2485\n assert candidate(word = \"jijijiijjjijiiiiij\") == 132\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 176\n assert candidate(word = \"ababababababababababababab\") == 260\n assert candidate(word = \"aabbaaabbbaaabbaaabbba\") == 187\n assert candidate(word = \"acccabbbdcbaaaccbbaaccbbcdac\") == 161\n assert candidate(word = \"aabbaaabbbaaaabbbaaa\") == 159\n assert candidate(word = \"abcabcabcabcabc\") == 57\n assert candidate(word = \"jjjjjjjjjj\") == 55\n assert candidate(word = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 670\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 452\n assert candidate(word = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeee\") == 1025\n assert candidate(word = \"abcdefghijabcdeijfgh\") == 23\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 820\n assert candidate(word = \"aaaaaaaaaabbbbbbbbbbbbccccccccccdddddddddd\") == 738\n assert candidate(word = \"aabbccddeeaabbccddeeaabbccddeedcba\") == 403\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 715\n assert candidate(word = \"babababababababababa\") == 155\n assert candidate(word = \"aabbccddeeffgghhiijjijjiihhggeeffddccbbaa\") == 501\n assert candidate(word = \"aabbccddeeffgghhiijjabcdefghijabcdefghijabcdefghijabcdefghij\") == 363\n assert candidate(word = \"abcabccbaabccbaabcabccbaabccba\") == 225\n assert candidate(word = \"abcdefghijjihgfedcba\") == 48\n assert candidate(word = \"abacabadabacabadabacabad\") == 90\n assert candidate(word = \"abababababababababababababababab\") == 392\n assert candidate(word = \"abacabadabacabadabacabadabacabad\") == 154\n", "comparison": "exact"}, "public_tests": ["\"aba\"", "\"aabb\"", "\"he\""], "hints": ["For each prefix of the string, check which characters are of even frequency and which are not and represent it by a bitmask.", "Find the other prefixes whose masks differs from the current prefix mask by at most one bit."], "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().wonderfulSubstrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:55+00:00", "tests_total": 77, "tests_dropped": 2, "flags": [], "topic_tags": ["hash-table", "string", "bit-manipulation", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def wonderfulSubstrings(self, word: str) -> int:", "container": "Solution", "callable": "wonderfulSubstrings", "parameters": [{"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1916, "task_id": "count-ways-to-build-rooms-in-an-ant-colony", "difficulty": "Hard", "problem_description": "You are an ant tasked with adding n new rooms numbered 0 to n-1 to your colony. You are given the expansion plan as a 0-indexed integer array of length n, prevRoom, where prevRoom[i] indicates that you must build room prevRoom[i] before building room i, and these two rooms must be connected directly. Room 0 is already built, so prevRoom[0] = -1. The expansion plan is given such that once all the rooms are built, every room will be reachable from room 0.\n\nYou can only build one room at a time, and you can travel freely between rooms you have already built only if they are connected. You can choose to build any room as long as its previous room is already built.\n\nReturn the number of different orders you can build all the rooms in. Since the answer may be large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: prevRoom = [-1,0,1]\nOutput: 1\nExplanation: There is only one way to build the additional rooms: 0 → 1 → 2\n\nExample 2:\n\nInput: prevRoom = [-1,0,0,1,2]\nOutput: 6\nExplanation:\nThe 6 ways are:\n0 → 1 → 3 → 2 → 4\n0 → 2 → 4 → 1 → 3\n0 → 1 → 2 → 3 → 4\n0 → 1 → 2 → 4 → 3\n0 → 2 → 1 → 3 → 4\n0 → 2 → 1 → 4 → 3\n\nConstraints:\n\n- n == prevRoom.length\n- 2 <= n <= 10^5\n- prevRoom[0] == -1\n- 0 <= prevRoom[i] < n for all 1 <= i < n\n- Every room is reachable from room 0 once all the rooms are built.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9]) == 258365767\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2]) == 8\n assert candidate(prevRoom = [-1, 0, 0, 1, 2]) == 6\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2]) == 80\n assert candidate(prevRoom = [-1, 0, 1]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 0]) == 6\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 2, 2]) == 120\n assert candidate(prevRoom = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 896\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4]) == 1\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4]) == 3360\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 2, 2]) == 560\n assert candidate(prevRoom = [-1, 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12]) == 645120\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 203434154\n assert candidate(prevRoom = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 37717233\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8]) == 118354482\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14]) == 2\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 977384288\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 1\n assert candidate(prevRoom = [-1, 0, 1, 2, 1, 4, 2, 6, 5, 7, 5, 9, 8, 10, 9, 11, 12, 13, 14, 10]) == 245044800\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14]) == 645247453\n assert candidate(prevRoom = [-1, 0, 0, 2, 2, 1, 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 466985999\n assert candidate(prevRoom = [-1, 0, 1, 2, 0, 2, 3, 4, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 11, 12]) == 777509735\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 960269310\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12]) == 270200339\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == 815328371\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39]) == 558903913\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 1, 3, 4, 3, 5, 6, 7, 5, 8, 9, 10, 11, 12, 11, 13, 14, 15, 16, 17, 18]) == 574577861\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == 594293086\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 65279563\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 258365767\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6]) == 916824814\n assert candidate(prevRoom = [-1, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5]) == 499858301\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 144195955\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17]) == 977718734\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 927211300\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 214454105\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 881663664\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7]) == 182996126\n assert candidate(prevRoom = [-1, 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == 904828424\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 19170323\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 232266423\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10]) == 281601700\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 134837072\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35]) == 151296514\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == 580542770\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == 374254273\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 506880\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 4036032\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 457389881\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 862785756\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 259495482\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39]) == 104533170\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29]) == 944857254\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 185834123\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 0, 5, 6, 7, 8, 4, 11, 12, 13, 14, 10, 16, 17, 18, 19]) == 462\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 686400\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12]) == 846964197\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12]) == 839553459\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9]) == 864359005\n assert candidate(prevRoom = [-1, 0, 1, 0, 2, 3, 2, 4, 5, 6, 5, 7, 8, 9, 10, 11, 10, 11, 12, 13, 14, 15, 14, 15, 16, 17, 18, 19, 20]) == 696057029\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5]) == 495153778\n assert candidate(prevRoom = [-1, 0, 1, 2, 1, 4, 5, 6, 4, 8, 9, 5, 10, 11, 6, 12, 13, 7, 14, 15, 8, 16, 17, 9, 18, 19]) == 298444100\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 980653881\n assert candidate(prevRoom = [-1, 0, 1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 185998261\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 820019200\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 4, 4, 5, 6, 7, 7, 8, 8, 9, 9, 10, 11, 11, 12, 12, 13, 14, 15, 15, 16, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 316920121\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 645414306\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == 989258543\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 414301485\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7]) == 452706138\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 37717233\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 185998261\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34]) == 764478009\n assert candidate(prevRoom = [-1, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]) == 874133999\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 838387635\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 544962428\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 268444119\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 435629637\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11]) == 59583424\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29]) == 468972288\n assert candidate(prevRoom = [-1, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 930392109\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 466985999\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17]) == 715654985\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4]) == 199114634\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 1\n", "comparison": "exact"}, "public_tests": ["[-1,0,1]", "[-1,0,0,1,2]"], "hints": ["Use dynamic programming.", "Let dp[i] be the number of ways to solve the problem for the subtree of node i.", "Imagine you are trying to fill an array with the order of traversal, dp[i] equals the multiplications of the number of ways to distribute the subtrees of the children of i on the array using combinatorics, multiplied bu their dp values."], "metadata": {"canonical_parameter_names": ["prevRoom"], "leetcode_dataset_entry_point": "Solution().waysToBuildRooms", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:34:58+00:00", "tests_total": 89, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "math", "dynamic-programming", "tree", "depth-first-search", "graph", "topological-sort", "combinatorics", "dp-on-trees", "fermats-little-theorem"]}, "language": "python", "interface": {"raw_signature": "def waysToBuildRooms(self, prevRoom: List[int]) -> int:", "container": "Solution", "callable": "waysToBuildRooms", "parameters": [{"name": "prevRoom", "type": "List[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1920, "task_id": "build-array-from-permutation", "difficulty": "Easy", "problem_description": "Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it.\n\nA zero-based permutation nums is an array of distinct integers from 0 to nums.length - 1 (inclusive).\n\nExample 1:\n\nInput: nums = [0,2,1,5,3,4]\nOutput: [0,1,2,4,5,3]\nExplanation: The array ans is built as follows:\nans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]\n = [nums[0], nums[2], nums[1], nums[5], nums[3], nums[4]]\n = [0,1,2,4,5,3]\n\nExample 2:\n\nInput: nums = [5,0,1,2,3,4]\nOutput: [4,5,0,1,2,3]\nExplanation: The array ans is built as follows:\nans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]\n = [nums[5], nums[0], nums[1], nums[2], nums[3], nums[4]]\n = [4,5,0,1,2,3]\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 0 <= nums[i] < nums.length\n- The elements in nums are distinct.\n\nFollow-up: Can you solve it without using an extra space (i.e., O(1) memory)?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 0, 2, 1, 3]) == [3, 4, 2, 0, 1]\n assert candidate(nums = [3, 2, 1, 0]) == [0, 1, 2, 3]\n assert candidate(nums = [5, 0, 1, 2, 3, 4]) == [4, 5, 0, 1, 2, 3]\n assert candidate(nums = [1, 0, 3, 2]) == [0, 1, 2, 3]\n assert candidate(nums = [0, 1, 2, 3]) == [0, 1, 2, 3]\n assert candidate(nums = [0, 2, 1, 5, 3, 4]) == [0, 1, 2, 4, 5, 3]\n assert candidate(nums = [1, 0, 2, 3]) == [0, 1, 2, 3]\n assert candidate(nums = [4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4]\n assert candidate(nums = [1, 0]) == [0, 1]\n assert candidate(nums = [1, 5, 4, 3, 2, 0, 8, 7, 6, 9]) == [5, 0, 2, 3, 4, 1, 6, 7, 8, 9]\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [15, 2, 12, 11, 9, 4, 8, 13, 10, 7, 5, 6, 3, 14, 1, 0]) == [0, 12, 3, 6, 7, 9, 10, 14, 5, 13, 4, 8, 11, 1, 2, 15]\n assert candidate(nums = [15, 10, 5, 0, 14, 9, 4, 13, 8, 3, 12, 7, 2, 11, 6, 1]) == [1, 12, 9, 15, 6, 3, 14, 11, 8, 0, 2, 13, 5, 7, 4, 10]\n assert candidate(nums = [1, 3, 0, 2, 6, 5, 4, 7, 9, 8]) == [3, 2, 1, 0, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [8, 0, 4, 1, 3, 7, 6, 2, 5, 9]) == [5, 8, 3, 0, 1, 2, 6, 4, 7, 9]\n assert candidate(nums = [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(nums = [1, 2, 3, 0, 4, 5, 6]) == [2, 3, 0, 1, 4, 5, 6]\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(nums = [6, 2, 0, 4, 5, 1, 3]) == [3, 0, 6, 5, 1, 2, 4]\n assert candidate(nums = [9, 3, 2, 8, 4, 5, 7, 0, 6, 1]) == [1, 8, 2, 6, 4, 5, 0, 9, 7, 3]\n assert candidate(nums = [7, 5, 9, 8, 6, 0, 1, 2, 4, 3]) == [2, 0, 3, 4, 1, 7, 5, 9, 6, 8]\n assert candidate(nums = [13, 9, 1, 15, 0, 14, 6, 10, 5, 2, 12, 4, 11, 7, 3, 8]) == [7, 2, 9, 8, 13, 3, 6, 12, 14, 1, 11, 0, 4, 10, 15, 5]\n assert candidate(nums = [7, 5, 2, 4, 6, 0, 3, 1]) == [1, 0, 2, 6, 3, 7, 4, 5]\n assert candidate(nums = [1, 3, 0, 2]) == [3, 2, 1, 0]\n assert candidate(nums = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [6, 2, 0, 5, 1, 4, 3]) == [3, 0, 6, 4, 2, 1, 5]\n assert candidate(nums = [2, 0, 1, 4, 3, 6, 5, 8, 7, 9, 10, 11]) == [1, 2, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [24, 25, 28, 0, 7, 12, 17, 29, 15, 9, 23, 21, 20, 22, 5, 27, 10, 13, 16, 3, 18, 8, 19, 11, 1, 6, 26, 4, 14, 2]) == [1, 6, 14, 24, 29, 20, 13, 2, 27, 9, 11, 8, 18, 19, 12, 4, 23, 22, 10, 0, 16, 15, 3, 21, 25, 17, 26, 7, 5, 28]\n assert candidate(nums = [2, 1, 0, 4, 3, 5, 9, 8, 6, 7]) == [0, 1, 2, 3, 4, 5, 7, 6, 9, 8]\n assert candidate(nums = [4, 5, 6, 7, 0, 1, 2, 3, 8, 9]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 0, 3, 2, 5, 4]) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [0, 3, 1, 4, 2, 5, 7, 6]) == [0, 4, 3, 2, 1, 5, 6, 7]\n assert candidate(nums = [10, 7, 8, 9, 1, 5, 6, 0, 3, 4, 2]) == [2, 0, 3, 4, 7, 5, 6, 10, 9, 1, 8]\n assert candidate(nums = [5, 8, 6, 3, 1, 0, 9, 2, 4, 7]) == [0, 4, 9, 3, 8, 5, 7, 6, 1, 2]\n assert candidate(nums = [33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]\n assert candidate(nums = [75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75]\n assert candidate(nums = [0, 5, 2, 1, 6, 4, 3]) == [0, 4, 2, 5, 3, 6, 1]\n assert candidate(nums = [3, 0, 1, 4, 2]) == [4, 3, 0, 2, 1]\n assert candidate(nums = [6, 1, 0, 2, 3, 5, 4]) == [4, 1, 6, 0, 2, 5, 3]\n assert candidate(nums = [6, 0, 3, 1, 8, 9, 7, 4, 2, 5]) == [7, 6, 1, 0, 2, 5, 4, 8, 3, 9]\n assert candidate(nums = [2, 0, 1]) == [1, 2, 0]\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(nums = [2, 4, 3, 0, 1, 5, 6, 7, 8, 9]) == [3, 1, 0, 2, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [8, 2, 3, 0, 4, 1, 7, 5, 9, 6]) == [9, 3, 0, 8, 4, 2, 5, 1, 6, 7]\n assert candidate(nums = [4, 8, 3, 1, 7, 10, 5, 6, 9, 0, 2, 11]) == [7, 9, 1, 8, 6, 2, 10, 5, 0, 4, 3, 11]\n assert candidate(nums = [9, 4, 3, 7, 8, 0, 2, 1, 5, 6]) == [6, 8, 7, 1, 5, 9, 3, 4, 0, 2]\n assert candidate(nums = [4, 3, 0, 1, 2]) == [2, 1, 4, 3, 0]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [0, 5, 1, 4, 6, 2, 3, 7, 8, 9]) == [0, 2, 5, 6, 3, 1, 4, 7, 8, 9]\n assert candidate(nums = [7, 5, 6, 3, 2, 1, 4, 0]) == [0, 1, 4, 3, 6, 5, 2, 7]\n assert candidate(nums = [1, 3, 0, 2, 7, 5, 8, 4, 9, 6]) == [3, 2, 1, 0, 4, 5, 9, 7, 6, 8]\n assert candidate(nums = [6, 1, 3, 5, 7, 0, 2, 4, 9, 8]) == [2, 1, 5, 0, 4, 6, 3, 7, 8, 9]\n assert candidate(nums = [34, 5, 11, 14, 2, 8, 1, 25, 16, 18, 20, 4, 0, 13, 31, 33, 10, 17, 3, 32, 23, 26, 15, 19, 6, 29, 7, 28, 24, 30, 9, 22, 12, 27, 5, 21]) == [5, 8, 4, 31, 11, 16, 5, 29, 10, 3, 23, 2, 34, 13, 22, 27, 20, 17, 14, 12, 19, 7, 33, 32, 1, 30, 25, 24, 6, 9, 18, 15, 0, 28, 8, 26]\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [6, 0, 1, 2, 3, 4, 5, 7, 8, 9]) == [5, 6, 0, 1, 2, 3, 4, 7, 8, 9]\n assert candidate(nums = [0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [59, 48, 54, 28, 74, 33, 85, 64, 80, 68, 47, 22, 25, 63, 98, 70, 19, 34, 6, 5, 82, 44, 73, 14, 72, 31, 32, 86, 3, 18, 92, 56, 53, 50, 49, 97, 90, 9, 93, 69, 37, 10, 84, 95, 35, 38, 52, 11, 62, 16, 88, 60, 42, 51, 15, 41, 77, 45, 67, 78, 46, 13, 20, 65, 87, 21, 7, 58, 36, 83, 17, 23, 29, 39, 91, 75, 61, 12, 99, 27, 94, 26, 40, 55, 1, 89, 79, 24, 57, 8, 30, 0, 43, 81, 96, 71, 66, 4, 76, 2, 59]) == [78, 62, 15, 3, 91, 50, 89, 87, 94, 36, 11, 73, 31, 65, 76, 17, 5, 49, 85, 33, 40, 35, 39, 98, 29, 56, 53, 79, 28, 6, 43, 77, 51, 88, 16, 4, 30, 68, 81, 83, 9, 47, 1, 71, 97, 93, 42, 22, 20, 19, 57, 46, 84, 60, 70, 10, 12, 38, 58, 99, 52, 63, 82, 21, 24, 44, 64, 67, 90, 55, 34, 14, 18, 69, 0, 75, 13, 25, 2, 86, 96, 32, 37, 41, 48, 8, 27, 72, 45, 80, 92, 59, 95, 26, 66, 23, 7, 74, 61, 54, 78]\n assert candidate(nums = [4, 0, 3, 1, 2]) == [2, 4, 1, 0, 3]\n assert candidate(nums = [5, 8, 4, 2, 0, 6, 7, 9, 1, 3]) == [6, 1, 0, 4, 5, 7, 9, 3, 8, 2]\n assert candidate(nums = [9, 7, 2, 3, 8, 6, 5, 0, 1, 4]) == [4, 0, 2, 3, 1, 5, 6, 9, 7, 8]\n assert candidate(nums = [10, 0, 2, 4, 1, 5, 6, 8, 3, 9, 7]) == [7, 10, 2, 1, 0, 5, 6, 3, 4, 9, 8]\n assert candidate(nums = [5, 1, 4, 8, 2, 9, 6, 0, 3, 7]) == [9, 1, 2, 3, 4, 7, 6, 5, 8, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == [0, 5, 9, 4, 1, 6, 8, 3, 2, 7]\n assert candidate(nums = [8, 11, 1, 0, 14, 9, 4, 13, 8, 3, 12, 7, 6, 10, 2, 5]) == [8, 7, 11, 8, 2, 3, 14, 10, 8, 0, 6, 13, 4, 12, 1, 9]\n assert candidate(nums = [8, 5, 2, 1, 6, 9, 7, 3, 0, 4]) == [0, 9, 2, 5, 7, 4, 3, 1, 8, 6]\n assert candidate(nums = [64, 5, 37, 49, 46, 17, 27, 47, 53, 39, 19, 35, 50, 1, 28, 58, 44, 0, 13, 20, 4, 30, 59, 10, 56, 63, 3, 31, 18, 48, 36, 24, 55, 26, 57, 34, 14, 6, 2, 40, 33, 16, 60, 25, 54, 52, 21, 62, 43, 61, 29, 38, 45, 41, 32, 51, 23, 11, 12, 42, 8, 7, 22, 15, 9, 5, 65, 37, 49, 46, 17, 27, 47, 53, 39, 19, 35, 50, 1, 28, 58, 44, 0, 13, 20, 4, 30, 59, 10, 56, 63, 3, 31, 18, 48, 36, 24, 55, 26, 57, 34, 14, 6, 2, 40, 33, 16, 60, 25, 54, 52, 21, 62, 43, 61, 29, 38, 45, 41, 32, 51, 23, 11, 12, 42, 8, 7, 22, 15, 9, 5]) == [9, 17, 6, 61, 21, 0, 31, 62, 41, 40, 20, 34, 29, 5, 18, 12, 54, 64, 1, 4, 46, 36, 42, 19, 23, 15, 49, 24, 13, 43, 14, 56, 51, 3, 11, 57, 28, 27, 37, 33, 26, 44, 8, 63, 32, 45, 30, 22, 25, 7, 48, 2, 52, 16, 55, 38, 10, 35, 50, 60, 53, 47, 59, 58, 39, 17, 5, 6, 61, 21, 0, 31, 62, 41, 40, 20, 34, 29, 5, 18, 12, 54, 64, 1, 4, 46, 36, 42, 19, 23, 15, 49, 24, 13, 43, 14, 56, 51, 3, 11, 57, 28, 27, 37, 33, 26, 44, 8, 63, 32, 45, 30, 22, 25, 7, 48, 2, 52, 16, 55, 38, 10, 35, 50, 60, 53, 47, 59, 58, 39, 17]\n assert candidate(nums = [1, 3, 5, 7, 9, 0, 2, 4, 6, 8]) == [3, 7, 0, 4, 8, 1, 5, 9, 2, 6]\n assert candidate(nums = [0, 5, 9, 1, 7, 2, 8, 4, 6, 3]) == [0, 2, 3, 5, 4, 9, 6, 7, 8, 1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [29, 22, 15, 8, 1, 28, 21, 14, 7, 0, 27, 20, 13, 6, 2, 26, 19, 12, 5, 3, 25, 18, 11, 4, 24, 17, 10, 16, 9, 23]) == [23, 11, 26, 7, 22, 9, 18, 2, 14, 29, 16, 25, 6, 21, 15, 10, 3, 13, 28, 8, 17, 5, 20, 1, 24, 12, 27, 19, 0, 4]\n assert candidate(nums = [0, 1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [7, 0, 5, 3, 6, 2, 4, 1]) == [1, 7, 2, 3, 4, 5, 6, 0]\n assert candidate(nums = [0, 10, 6, 7, 4, 3, 9, 1, 8, 2, 5]) == [0, 5, 9, 1, 4, 7, 2, 10, 8, 6, 3]\n assert candidate(nums = [4, 5, 0, 1, 2, 3]) == [2, 3, 4, 5, 0, 1]\n assert candidate(nums = [7, 9, 6, 3, 5, 8, 4, 0, 2, 1]) == [0, 1, 4, 3, 8, 2, 5, 7, 6, 9]\n assert candidate(nums = [7, 8, 9, 0, 3, 2, 5, 4, 6, 1]) == [4, 6, 1, 7, 0, 9, 2, 3, 5, 8]\n assert candidate(nums = [2, 7, 4, 5, 1, 9, 3, 6, 8, 0]) == [4, 6, 1, 9, 7, 0, 5, 3, 8, 2]\n assert candidate(nums = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(nums = [2, 5, 8, 3, 9, 6, 1, 7, 4, 0]) == [8, 6, 4, 3, 0, 1, 5, 7, 9, 2]\n", "comparison": "exact"}, "public_tests": ["[0,2,1,5,3,4]", "[5,0,1,2,3,4]"], "hints": ["Just apply what's said in the statement.", "Notice that you can't apply it on the same array directly since some elements will change after application"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().buildArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:02+00:00", "tests_total": 81, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "simulation"]}, "language": "python", "interface": {"raw_signature": "def buildArray(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "buildArray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1921, "task_id": "eliminate-maximum-number-of-monsters", "difficulty": "Medium", "problem_description": "You are playing a video game where you are defending your city from a group of n monsters. You are given a 0-indexed integer array dist of size n, where dist[i] is the initial distance in kilometers of the i^th monster from the city.\n\nThe monsters walk toward the city at a constant speed. The speed of each monster is given to you in an integer array speed of size n, where speed[i] is the speed of the i^th monster in kilometers per minute.\n\nYou have a weapon that, once fully charged, can eliminate a single monster. However, the weapon takes one minute to charge. The weapon is fully charged at the very start.\n\nYou lose when any monster reaches your city. If a monster reaches the city at the exact moment the weapon is fully charged, it counts as a loss, and the game ends before you can use your weapon.\n\nReturn the maximum number of monsters that you can eliminate before you lose, or n if you can eliminate all the monsters before they reach the city.\n\nExample 1:\n\nInput: dist = [1,3,4], speed = [1,1,1]\nOutput: 3\nExplanation:\nIn the beginning, the distances of the monsters are [1,3,4]. You eliminate the first monster.\nAfter a minute, the distances of the monsters are [X,2,3]. You eliminate the second monster.\nAfter a minute, the distances of the monsters are [X,X,2]. You eliminate the third monster.\nAll 3 monsters can be eliminated.\n\nExample 2:\n\nInput: dist = [1,1,2,3], speed = [1,1,1,1]\nOutput: 1\nExplanation:\nIn the beginning, the distances of the monsters are [1,1,2,3]. You eliminate the first monster.\nAfter a minute, the distances of the monsters are [X,0,1,2], so you lose.\nYou can only eliminate 1 monster.\n\nExample 3:\n\nInput: dist = [3,2,4], speed = [5,3,2]\nOutput: 1\nExplanation:\nIn the beginning, the distances of the monsters are [3,2,4]. You eliminate the first monster.\nAfter a minute, the distances of the monsters are [X,0,2], so you lose.\nYou can only eliminate 1 monster.\n\nConstraints:\n\n- n == dist.length == speed.length\n- 1 <= n <= 10^5\n- 1 <= dist[i], speed[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(dist = [6, 7, 8],speed = [2, 2, 2]) == 3\n assert candidate(dist = [1, 2, 3],speed = [3, 2, 1]) == 1\n assert candidate(dist = [100, 200, 300],speed = [1, 1, 1]) == 3\n assert candidate(dist = [7, 14, 21],speed = [1, 2, 3]) == 3\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [3, 5, 7, 9],speed = [1, 2, 3, 4]) == 3\n assert candidate(dist = [1, 1, 2, 3],speed = [1, 1, 1, 1]) == 1\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [50, 40, 30, 20, 10]) == 5\n assert candidate(dist = [6, 4, 5],speed = [1, 2, 1]) == 3\n assert candidate(dist = [1, 2, 3, 4, 5],speed = [1, 2, 3, 4, 5]) == 1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(dist = [1, 3, 4],speed = [1, 1, 1]) == 3\n assert candidate(dist = [10, 20, 30],speed = [1, 2, 3]) == 3\n assert candidate(dist = [5, 10, 15, 20],speed = [5, 4, 3, 2]) == 4\n assert candidate(dist = [3, 2, 4],speed = [5, 3, 2]) == 1\n assert candidate(dist = [1, 2, 3, 4, 5],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [10, 5, 6, 12, 3],speed = [2, 1, 1, 1, 1]) == 5\n assert candidate(dist = [5, 5, 5],speed = [1, 1, 1]) == 3\n assert candidate(dist = [2, 4, 6],speed = [2, 2, 2]) == 3\n assert candidate(dist = [1],speed = [1]) == 1\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [10, 20, 30, 40, 50]) == 5\n assert candidate(dist = [5, 5, 5, 5],speed = [1, 1, 1, 1]) == 4\n assert candidate(dist = [6, 7, 12, 13, 14],speed = [3, 3, 4, 4, 5]) == 3\n assert candidate(dist = [6, 3, 4, 1],speed = [2, 1, 2, 1]) == 3\n assert candidate(dist = [10, 20, 30],speed = [5, 10, 15]) == 2\n assert candidate(dist = [10, 15, 20],speed = [2, 3, 4]) == 3\n assert candidate(dist = [10, 20, 30],speed = [5, 5, 5]) == 3\n assert candidate(dist = [100, 200, 300],speed = [10, 20, 30]) == 3\n assert candidate(dist = [10, 20, 30, 40],speed = [10, 10, 10, 10]) == 4\n assert candidate(dist = [1, 2, 3, 4, 5],speed = [5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [10, 10, 10, 10, 10],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [500, 1000, 1500, 2000, 2500],speed = [50, 100, 150, 200, 250]) == 5\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [1000, 900, 800, 700, 600],speed = [100, 200, 300, 400, 500]) == 5\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [9, 8, 7, 6, 5, 4, 3, 2, 1],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(dist = [2, 3, 4, 5, 6],speed = [2, 2, 2, 2, 2]) == 2\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [2, 3, 4, 5, 6]) == 5\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(dist = [10, 25, 40, 55, 70, 85],speed = [5, 5, 5, 5, 5, 5]) == 6\n assert candidate(dist = [10, 15, 20, 25],speed = [5, 4, 3, 2]) == 4\n assert candidate(dist = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [99, 98, 97, 96, 95],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [1000, 1500, 2000, 2500, 3000],speed = [100, 200, 300, 400, 500]) == 5\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [50, 40, 30, 20, 10]) == 5\n assert candidate(dist = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(dist = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [10, 20, 30, 40, 50]) == 5\n assert candidate(dist = [15, 15, 20, 25, 30],speed = [1, 2, 1, 2, 1]) == 5\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],speed = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(dist = [5, 15, 25, 35, 45],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(dist = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [5, 5, 5, 5, 5]) == 5\n assert candidate(dist = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(dist = [2, 4, 6, 8, 10],speed = [1, 2, 3, 4, 5]) == 2\n assert candidate(dist = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],speed = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(dist = [5, 10, 15, 20, 25, 30],speed = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [25, 25, 25, 25, 25],speed = [5, 5, 5, 5, 5]) == 5\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [2, 4, 6, 8, 10],speed = [1, 2, 3, 4, 5]) == 2\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [5, 15, 25, 35, 45],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(dist = [5, 10, 15, 20, 25, 30],speed = [1, 2, 3, 4, 5, 6]) == 5\n assert candidate(dist = [99, 198, 297, 396, 495, 594, 693, 792, 891, 990],speed = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99]) == 10\n assert candidate(dist = [3, 5, 7, 9, 11],speed = [1, 2, 3, 4, 5]) == 3\n assert candidate(dist = [10000, 20000, 30000, 40000, 50000],speed = [100, 200, 300, 400, 500]) == 5\n assert candidate(dist = [3, 6, 9, 12, 15],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [1, 2, 3, 4, 5],speed = [5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [2, 4, 5, 6, 8]) == 5\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [1000, 2000, 3000],speed = [10, 20, 30]) == 3\n assert candidate(dist = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(dist = [10, 25, 30, 45, 50, 65, 70, 85, 90, 105],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [2, 3, 4, 5, 6],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 15\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 10\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [10, 20, 30, 40, 50]) == 1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [2, 2, 2, 2, 1]) == 5\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 1\n assert candidate(dist = [9, 9, 9, 9, 9],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [100, 150, 200, 250, 300],speed = [25, 50, 75, 100, 125]) == 3\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [10, 11, 12, 13, 14],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(dist = [15, 10, 20, 30, 40],speed = [2, 5, 3, 4, 1]) == 5\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(dist = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(dist = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [50, 100, 150, 200, 250]) == 2\n assert candidate(dist = [3, 6, 9, 12, 15, 18],speed = [1, 2, 3, 4, 5, 6]) == 3\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(dist = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [9, 18, 27, 36, 45],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [15, 25, 35, 45, 55],speed = [5, 5, 5, 5, 5]) == 5\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [50, 50, 50, 50, 50]) == 5\n assert candidate(dist = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(dist = [2, 4, 6, 8, 10],speed = [2, 2, 2, 2, 2]) == 5\n assert candidate(dist = [7, 14, 21, 28, 35],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [100, 150, 200, 250, 300],speed = [5, 10, 15, 20, 25]) == 5\n assert candidate(dist = [100, 150, 200, 250, 300, 350, 400, 450, 500],speed = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 9\n", "comparison": "exact"}, "public_tests": ["[1,3,4]\n[1,1,1]", "[1,1,2,3]\n[1,1,1,1]", "[3,2,4]\n[5,3,2]"], "hints": ["Find the amount of time it takes each monster to arrive.", "Find the order in which the monsters will arrive."], "metadata": {"canonical_parameter_names": ["dist", "speed"], "leetcode_dataset_entry_point": "Solution().eliminateMaximum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:05+00:00", "tests_total": 127, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def eliminateMaximum(self, dist: list[int], speed: list[int]) -> int:", "container": "Solution", "callable": "eliminateMaximum", "parameters": [{"name": "dist", "type": "list[int]"}, {"name": "speed", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1923, "task_id": "longest-common-subpath", "difficulty": "Hard", "problem_description": "There is a country of n cities numbered from 0 to n - 1. In this country, there is a road connecting every pair of cities.\n\nThere are m friends numbered from 0 to m - 1 who are traveling through the country. Each one of them will take a path consisting of some cities. Each path is represented by an integer array that contains the visited cities in order. The path may contain a city more than once, but the same city will not be listed consecutively.\n\nGiven an integer n and a 2D integer array paths where paths[i] is an integer array representing the path of the i^th friend, return the length of the longest common subpath that is shared by every friend's path, or 0 if there is no common subpath at all.\n\nA subpath of a path is a contiguous sequence of cities within that path.\n\nExample 1:\n\nInput: n = 5, paths = [[0,1,2,3,4],\n [2,3,4],\n [4,0,1,2,3]]\nOutput: 2\nExplanation: The longest common subpath is [2,3].\n\nExample 2:\n\nInput: n = 3, paths = [[0],[1],[2]]\nOutput: 0\nExplanation: There is no common subpath shared by the three paths.\n\nExample 3:\n\nInput: n = 5, paths = [[0,1,2,3,4],\n [4,3,2,1,0]]\nOutput: 1\nExplanation: The possible longest common subpaths are [0], [1], [2], [3], and [4]. All have a length of 1.\n\nConstraints:\n\n- 1 <= n <= 10^5\n- m == paths.length\n- 2 <= m <= 10^5\n- sum(paths[i].length) <= 10^5\n- 0 <= paths[i][j] < n\n- The same city is not listed multiple times consecutively in paths[i].\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,paths = [[0], [0], [0]]) == 1\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0]]) == 1\n assert candidate(n = 3,paths = [[0], [1], [2]]) == 0\n assert candidate(n = 10,paths = [[0, 1, 2], [1, 2, 3], [2, 3, 4]]) == 1\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 0, 1, 2, 3, 4], [3, 4, 5, 6, 7, 8, 9, 0, 1, 2]]) == 5\n assert candidate(n = 7,paths = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) == 0\n assert candidate(n = 6,paths = [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 0], [2, 3, 4, 5, 0, 1]]) == 4\n assert candidate(n = 10,paths = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5]]) == 0\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [2, 3, 4], [4, 0, 1, 2, 3]]) == 2\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3], [6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5]]) == 9\n assert candidate(n = 9,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 0], [2, 3, 4, 5, 6, 7, 8, 0, 1], [3, 4, 5, 6, 7, 8, 0, 1, 2]]) == 6\n assert candidate(n = 100,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79], [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44]]) == 45\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3]]) == 16\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 0], [2, 3, 4, 5, 6, 0, 1], [3, 4, 5, 6, 0, 1, 2], [4, 5, 6, 0, 1, 2, 3], [5, 6, 0, 1, 2, 3, 4], [6, 0, 1, 2, 3, 4, 5], [0, 6, 5, 4, 3, 2, 1]]) == 1\n assert candidate(n = 8,paths = [[0, 1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1, 0], [2, 1, 0, 7, 6, 5, 4, 3], [3, 2, 1, 0, 7, 6, 5, 4]]) == 1\n assert candidate(n = 100,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39], [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]]) == 50\n assert candidate(n = 8,paths = [[0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 0], [2, 3, 4, 5, 6, 7, 0, 1], [3, 4, 5, 6, 7, 0, 1, 2], [4, 5, 6, 7, 0, 1, 2, 3], [5, 6, 7, 0, 1, 2, 3, 4], [6, 7, 0, 1, 2, 3, 4, 5], [7, 0, 1, 2, 3, 4, 5, 6]]) == 1\n assert candidate(n = 25,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(n = 100,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 70\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 0], [2, 3, 4, 5, 6, 0, 1], [3, 4, 5, 6, 0, 1, 2], [4, 5, 6, 0, 1, 2, 3], [5, 6, 0, 1, 2, 3, 4], [6, 0, 1, 2, 3, 4, 5]]) == 1\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1]]) == 13\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4], [10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 5\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(n = 50,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48]]) == 25\n assert candidate(n = 25,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 15\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 10\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4]]) == 5\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4]]) == 10\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4], [1, 2, 3, 4, 0], [2, 3, 4, 0, 1], [3, 4, 0, 1, 2], [4, 0, 1, 2, 3], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 0, 1, 2, 3, 4], [6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [7, 8, 9, 0, 1, 2, 3, 4, 5, 6], [8, 9, 0, 1, 2, 3, 4, 5, 6, 7], [9, 0, 1, 2, 3, 4, 5, 6, 7, 8]]) == 1\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1]]) == 18\n assert candidate(n = 25,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [2, 3, 4, 5, 6, 7, 8, 9, 0, 1], [3, 4, 5, 6, 7, 8, 9, 0, 1, 2], [4, 5, 6, 7, 8, 9, 0, 1, 2, 3], [5, 6, 7, 8, 9, 0, 1, 2, 3, 4], [6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [7, 8, 9, 0, 1, 2, 3, 4, 5, 6], [8, 9, 0, 1, 2, 3, 4, 5, 6, 7], [9, 0, 1, 2, 3, 4, 5, 6, 7, 8]]) == 1\n assert candidate(n = 25,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 10\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [1, 2, 3, 0, 4], [2, 3, 0, 1, 4], [3, 0, 1, 2, 4], [0, 1, 2, 3, 4]]) == 1\n assert candidate(n = 50,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]]) == 20\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4]]) == 10\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [1, 2, 3, 4, 0], [2, 3, 4, 0, 1], [3, 4, 0, 1, 2], [4, 0, 1, 2, 3]]) == 1\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 2, 4, 6, 8, 0, 2, 4, 6, 8], [0, 3, 6, 9, 0, 3, 6, 9, 0, 3]]) == 1\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [2, 3, 4, 5, 6, 7, 8, 9, 0, 1], [8, 9, 0, 1, 2, 3, 4, 5, 6, 7]]) == 1\n assert candidate(n = 30,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 10\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3]]) == 11\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2]]) == 5\n assert candidate(n = 50,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 30\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2]]) == 17\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [3, 4, 5, 6, 0, 1, 2], [6, 0, 1, 2, 3, 4, 5], [4, 5, 6, 0, 1, 2, 3], [2, 3, 4, 5, 6, 0, 1]]) == 2\n assert candidate(n = 12,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2]]) == 9\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 0, 1], [4, 5, 6, 0, 1, 2, 3], [6, 0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6, 0]]) == 2\n assert candidate(n = 12,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1], [4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3], [6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5], [8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7]]) == 4\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8], [15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 9\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [2, 3, 4, 5, 6, 7, 8, 9, 0, 1], [3, 4, 5, 6, 7, 8, 9, 0, 1, 2]]) == 7\n assert candidate(n = 100,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 90\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [5, 4, 3, 2, 1, 0, 14, 13, 12, 11, 10, 9, 8, 7, 6]]) == 1\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [6, 0, 1, 2, 3, 4, 5], [5, 6, 0, 1, 2, 3, 4], [4, 5, 6, 0, 1, 2, 3]]) == 4\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [1, 2, 3, 4], [2, 3, 4], [3, 4], [4]]) == 1\n", "comparison": "exact"}, "public_tests": ["5\n[[0,1,2,3,4],[2,3,4],[4,0,1,2,3]]", "3\n[[0],[1],[2]]", "5\n[[0,1,2,3,4],[4,3,2,1,0]]"], "hints": ["If there is a common path with length x, there is for sure a common path of length y where y < x.", "We can use binary search over the answer with the range [0, min(path[i].length)].", "Using binary search, we want to verify if we have a common path of length m. We can achieve this using hashing."], "metadata": {"canonical_parameter_names": ["n", "paths"], "leetcode_dataset_entry_point": "Solution().longestCommonSubpath", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:10+00:00", "tests_total": 55, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "binary-search", "rolling-hash", "suffix-array", "hash-function", "suffix-automaton", "suffix-tree"]}, "language": "python", "interface": {"raw_signature": "def longestCommonSubpath(self, n: int, paths: list[list[int]]) -> int:", "container": "Solution", "callable": "longestCommonSubpath", "parameters": [{"name": "n", "type": "int"}, {"name": "paths", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1925, "task_id": "count-square-sum-triples", "difficulty": "Easy", "problem_description": "A square triple (a,b,c) is a triple where a, b, and c are integers and a^2 + b^2 = c^2.\n\nGiven an integer n, return the number of square triples such that 1 <= a, b, c <= n.\n\nExample 1:\n\nInput: n = 5\nOutput: 2\nExplanation: The square triples are (3,4,5) and (4,3,5).\n\nExample 2:\n\nInput: n = 10\nOutput: 4\nExplanation: The square triples are (3,4,5), (4,3,5), (6,8,10), and (8,6,10).\n\nConstraints:\n\n- 1 <= n <= 250\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 250) == 330\n assert candidate(n = 5) == 2\n assert candidate(n = 15) == 8\n assert candidate(n = 200) == 254\n assert candidate(n = 20) == 12\n assert candidate(n = 100) == 104\n assert candidate(n = 50) == 40\n assert candidate(n = 1) == 0\n assert candidate(n = 10) == 4\n assert candidate(n = 25) == 16\n assert candidate(n = 150) == 178\n assert candidate(n = 80) == 78\n assert candidate(n = 230) == 302\n assert candidate(n = 125) == 142\n assert candidate(n = 75) == 74\n assert candidate(n = 240) == 314\n assert candidate(n = 199) == 250\n assert candidate(n = 120) == 132\n assert candidate(n = 225) == 296\n assert candidate(n = 249) == 324\n assert candidate(n = 190) == 236\n assert candidate(n = 175) == 214\n assert candidate(n = 180) == 218\n", "comparison": "exact"}, "public_tests": ["5", "10"], "hints": ["Iterate over all possible pairs (a,b) and check that the square root of a * a + b * b is an integers less than or equal n", "You can check that the square root of an integer is an integer using binary seach or a builtin function like sqrt"], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countTriples", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:14+00:00", "tests_total": 23, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def countTriples(self, n: int) -> int:", "container": "Solution", "callable": "countTriples", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1927, "task_id": "sum-game", "difficulty": "Medium", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\n\nYou are given a string num of even length consisting of digits and '?' characters. On each turn, a player will do the following if there is still at least one '?' in num:\n\n1. Choose an index i where num[i] == '?'.\n2. Replace num[i] with any digit between '0' and '9'.\n\nThe game ends when there are no more '?' characters in num.\n\nFor Bob to win, the sum of the digits in the first half of num must be equal to the sum of the digits in the second half. For Alice to win, the sums must not be equal.\n\n- For example, if the game ended with num = \"243801\", then Bob wins because 2+4+3 = 8+0+1. If the game ended with num = \"243803\", then Alice wins because 2+4+3 != 8+0+3.\n\nAssuming Alice and Bob play optimally, return true if Alice will win and false if Bob will win.\n\nExample 1:\n\nInput: num = \"5023\"\nOutput: false\nExplanation: There are no moves to be made.\nThe sum of the first half is equal to the sum of the second half: 5 + 0 = 2 + 3.\n\nExample 2:\n\nInput: num = \"25??\"\nOutput: true\nExplanation: Alice can replace one of the '?'s with '9' and it will be impossible for Bob to make the sums equal.\n\nExample 3:\n\nInput: num = \"?3295???\"\nOutput: false\nExplanation: It can be proven that Bob will always win. One possible outcome is:\n- Alice replaces the first '?' with '9'. num = \"93295???\".\n- Bob replaces one of the '?' in the right half with '9'. num = \"932959??\".\n- Alice replaces one of the '?' in the right half with '2'. num = \"9329592?\".\n- Bob replaces the last '?' in the right half with '7'. num = \"93295927\".\nBob wins because 9 + 3 + 2 + 9 = 5 + 9 + 2 + 7.\n\nConstraints:\n\n- 2 <= num.length <= 10^5\n- num.length is even.\n- num consists of only digits and '?'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"1???2???\") == True\n assert candidate(num = \"9?8?7?6?\") == True\n assert candidate(num = \"????2222\") == True\n assert candidate(num = \"98765432\") == True\n assert candidate(num = \"???45678\") == True\n assert candidate(num = \"9999????\") == True\n assert candidate(num = \"12??34??\") == True\n assert candidate(num = \"?3295???\") == False\n assert candidate(num = \"0000????\") == True\n assert candidate(num = \"12345678\") == True\n assert candidate(num = \"12345678??\") == True\n assert candidate(num = \"00112233\") == True\n assert candidate(num = \"????567890\") == True\n assert candidate(num = \"5023\") == False\n assert candidate(num = \"????1234\") == True\n assert candidate(num = \"????????\") == False\n assert candidate(num = \"00?0?0?0\") == True\n assert candidate(num = \"00000000\") == False\n assert candidate(num = \"1234567890\") == True\n assert candidate(num = \"99?9?9?9\") == True\n assert candidate(num = \"25??\") == True\n assert candidate(num = \"1234????\") == True\n assert candidate(num = \"11112222\") == True\n assert candidate(num = \"????5000500050005000\") == True\n assert candidate(num = \"8888888888????????????????\") == True\n assert candidate(num = \"1234567890????\") == True\n assert candidate(num = \"00000000001234567890\") == True\n assert candidate(num = \"1234????5678\") == True\n assert candidate(num = \"1111111111111111????\") == True\n assert candidate(num = \"12345678901234567890????????????????????\") == False\n assert candidate(num = \"98765432109876543210\") == False\n assert candidate(num = \"1010101010??????????????????????\") == True\n assert candidate(num = \"9999999999999999999999999999????????????????????????????????????????????????????????????????????????????????????????????????????????\") == True\n assert candidate(num = \"12345678????????????????12345678\") == False\n assert candidate(num = \"1111111111111111????????????????\") == True\n assert candidate(num = \"2468013579????????????????\") == False\n assert candidate(num = \"99999999998765432100\") == True\n assert candidate(num = \"5555555555555555????\") == True\n assert candidate(num = \"50005000500050005000????\") == True\n assert candidate(num = \"1111111111????????????????\") == True\n assert candidate(num = \"1111????2222\") == True\n assert candidate(num = \"????????5432109876\") == True\n assert candidate(num = \"2222222222????????????????\") == True\n assert candidate(num = \"1234567890123456789012345678901234567890????\") == True\n assert candidate(num = \"1234567890????????\") == True\n assert candidate(num = \"555555555555555555550000000000000000????????\") == True\n assert candidate(num = \"00009999????\") == True\n assert candidate(num = \"2468024680??????????????????????\") == True\n assert candidate(num = \"98765432109876543210????????????\") == True\n assert candidate(num = \"1111222233334444????\") == True\n assert candidate(num = \"243801????????????????243801\") == False\n assert candidate(num = \"12345678901234567890????????????????????????????????????????????????????\") == False\n assert candidate(num = \"222222222222222222222222222222222222222222222222????????????????????????????????????????????\") == True\n assert candidate(num = \"1234567890123456????\") == True\n assert candidate(num = \"12345678901234567890????????????????????????????????????????????????????????????????????????????????????????????????????????\") == False\n assert candidate(num = \"????????????\") == False\n assert candidate(num = \"502350235023????\") == True\n assert candidate(num = \"1234567890????????1234567890????????\") == False\n assert candidate(num = \"11111111????1111\") == True\n assert candidate(num = \"1111111111111111\") == False\n assert candidate(num = \"????????????????\") == False\n assert candidate(num = \"25??1234????????????????\") == True\n assert candidate(num = \"1234123412341234????\") == True\n assert candidate(num = \"0000000000000000000011111111111111111111\") == True\n assert candidate(num = \"5432109876????????\") == True\n assert candidate(num = \"????567890????567890\") == False\n assert candidate(num = \"1111111122222222????\") == True\n assert candidate(num = \"4444444444????????????????\") == True\n assert candidate(num = \"1234567890123456789012345678901234????\") == True\n assert candidate(num = \"999999999999????????????\") == True\n assert candidate(num = \"9876543210??????????????????????\") == False\n assert candidate(num = \"6666666666????????????????\") == True\n assert candidate(num = \"55555555555555555555555555555555\") == False\n assert candidate(num = \"9876543210????????????????\") == False\n assert candidate(num = \"0987654321????\") == True\n assert candidate(num = \"00000000000000001111111111111111????????????????\") == True\n assert candidate(num = \"0123456789????????\") == True\n assert candidate(num = \"0987654321098765\") == True\n assert candidate(num = \"1234567890????????????????\") == False\n assert candidate(num = \"????????1234567890\") == True\n assert candidate(num = \"9999999999999999999999999999????\") == True\n assert candidate(num = \"????0000????0000\") == False\n assert candidate(num = \"0000000000000000????????????????\") == True\n assert candidate(num = \"55555555555555555555555555555555????????????????\") == True\n assert candidate(num = \"0?????????????????????????????????\") == True\n assert candidate(num = \"9876987698769876????\") == True\n assert candidate(num = \"0000000000????????\") == True\n assert candidate(num = \"11111111111111111111????????????????\") == True\n assert candidate(num = \"1234567890????1234\") == True\n assert candidate(num = \"9999999999999999????\") == True\n assert candidate(num = \"1234567890??????????????????????\") == False\n assert candidate(num = \"9999????????\") == True\n assert candidate(num = \"1234567890????????1234567890????\") == False\n assert candidate(num = \"1010101010????????????????\") == True\n assert candidate(num = \"1234567890123456\") == True\n assert candidate(num = \"1234567890????????????????0123456789\") == False\n assert candidate(num = \"5555555555??????????????????????\") == True\n assert candidate(num = \"55555555????\") == True\n assert candidate(num = \"000000000000000000000000????????????????\") == True\n assert candidate(num = \"000099990000????????\") == False\n assert candidate(num = \"????????11111111\") == True\n assert candidate(num = \"1111111111????????????????????1111111111\") == False\n assert candidate(num = \"1234567890123456????????????????\") == True\n assert candidate(num = \"5023????5023????\") == False\n assert candidate(num = \"1234567890????????????????1234567890\") == False\n assert candidate(num = \"13579135791357913579????????????????????\") == True\n assert candidate(num = \"99999999999999991234\") == True\n assert candidate(num = \"????9876543210????\") == True\n assert candidate(num = \"99999999999999999999999999999999\") == False\n assert candidate(num = \"9999999999999999????????????????\") == True\n assert candidate(num = \"99999999999999999999\") == False\n assert candidate(num = \"9????9????\") == False\n assert candidate(num = \"99999999990000000000\") == True\n assert candidate(num = \"1122334455????????????????\") == True\n assert candidate(num = \"1111111122222222\") == True\n assert candidate(num = \"?????????????????????????????????1\") == True\n assert candidate(num = \"5555555544444444????\") == True\n assert candidate(num = \"1234567890123456789012345678901234567890????????????????????????????\") == True\n assert candidate(num = \"????1234567890??\") == True\n assert candidate(num = \"0000000000000000????\") == True\n assert candidate(num = \"00000000000000000000000000000000000000000000????????????????\") == True\n assert candidate(num = \"99999999????\") == True\n assert candidate(num = \"1020304050????????????????\") == True\n assert candidate(num = \"24680246802468024680????????????????????\") == True\n assert candidate(num = \"5000500050005000????\") == True\n assert candidate(num = \"0000000000000000000000000000????????????????????????????????\") == True\n assert candidate(num = \"9012345678????????????????8765432109\") == False\n assert candidate(num = \"????????9999999999\") == True\n assert candidate(num = \"98765432109876543210????????????????????\") == False\n assert candidate(num = \"9876543210????????????\") == False\n assert candidate(num = \"7777777777????????????????\") == True\n assert candidate(num = \"9753186420????????????????\") == False\n assert candidate(num = \"2222111144443333????\") == True\n assert candidate(num = \"5023????????????????????\") == True\n assert candidate(num = \"0000000000????????????????\") == True\n assert candidate(num = \"3333333333????????????????\") == True\n assert candidate(num = \"9876543210????????\") == True\n assert candidate(num = \"0000000000000000000000000000????\") == True\n assert candidate(num = \"12345678901234567890????????????\") == True\n assert candidate(num = \"123456789012345678901234567890\") == True\n assert candidate(num = \"5555555555????????????????\") == True\n assert candidate(num = \"9999????9999\") == False\n assert candidate(num = \"????2345????????????????5432????\") == False\n assert candidate(num = \"11223344556677889900????????????\") == False\n assert candidate(num = \"0000000099999999\") == True\n assert candidate(num = \"55555555555555555555555555555555????????????????????????????????????\") == True\n assert candidate(num = \"22222222222222222222222222222222????????????????????????????????????2222222222\") == True\n assert candidate(num = \"99999999????9999\") == True\n assert candidate(num = \"11111111111111111111\") == False\n assert candidate(num = \"20202020202020202020202020????????\") == True\n assert candidate(num = \"0101010101????????????????\") == True\n assert candidate(num = \"12345678901234567890\") == False\n assert candidate(num = \"9876543210????\") == True\n assert candidate(num = \"5555555555????????\") == True\n assert candidate(num = \"33333333333333333333333333333333333333333333333333????????????????????????????????????????????????????????????????????????????????333333333333\") == True\n assert candidate(num = \"11111111111111112222222222222222\") == True\n assert candidate(num = \"1?????????????????????????????????\") == True\n assert candidate(num = \"1234567890????????????????0987654321\") == False\n assert candidate(num = \"0000000000000000\") == False\n assert candidate(num = \"9999999999????????????????\") == True\n assert candidate(num = \"50505050????\") == True\n", "comparison": "exact"}, "public_tests": ["\"5023\"", "\"25??\"", "\"?3295???\""], "hints": ["Bob can always make the total sum of both sides equal in mod 9.", "Why does the difference between the number of question marks on the left and right side matter?"], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().sumGame", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:19+00:00", "tests_total": 168, "tests_dropped": 7, "flags": [], "topic_tags": ["math", "string", "greedy", "game-theory"]}, "language": "python", "interface": {"raw_signature": "def sumGame(self, num: str) -> bool:", "container": "Solution", "callable": "sumGame", "parameters": [{"name": "num", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1928, "task_id": "minimum-cost-to-reach-destination-in-time", "difficulty": "Hard", "problem_description": "There is a country of n cities numbered from 0 to n - 1 where all the cities are connected by bi-directional roads. The roads are represented as a 2D integer array edges where edges[i] = [x_i, y_i, time_i] denotes a road between cities x_i and y_i that takes time_i minutes to travel. There may be multiple roads of differing travel times connecting the same two cities, but no road connects a city to itself.\n\nEach time you pass through a city, you must pay a passing fee. This is represented as a 0-indexed integer array passingFees of length n where passingFees[j] is the amount of dollars you must pay when you pass through city j.\n\nIn the beginning, you are at city 0 and want to reach city n - 1 in maxTime minutes or less. The cost of your journey is the summation of passing fees for each city that you passed through at some moment of your journey (including the source and destination cities).\n\nGiven maxTime, edges, and passingFees, return the minimum cost to complete your journey, or -1 if you cannot complete it within maxTime minutes.\n\nExample 1:\n\nInput: maxTime = 30, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3]\nOutput: 11\nExplanation: The path to take is 0 -> 1 -> 2 -> 5, which takes 30 minutes and has $11 worth of passing fees.\n\nExample 2:\n\nInput: maxTime = 29, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3]\nOutput: 48\nExplanation: The path to take is 0 -> 3 -> 4 -> 5, which takes 26 minutes and has $48 worth of passing fees.\nYou cannot take path 0 -> 1 -> 2 -> 5 since it would take too long.\n\nExample 3:\n\nInput: maxTime = 25, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3]\nOutput: -1\nExplanation: There is no way to reach city 5 from city 0 within 25 minutes.\n\nConstraints:\n\n- 1 <= maxTime <= 1000\n- n == passingFees.length\n- 2 <= n <= 1000\n- n - 1 <= edges.length <= 1000\n- 0 <= x_i, y_i <= n - 1\n- 1 <= time_i <= 1000\n- 1 <= passingFees[j] <= 1000\n- The graph may contain multiple edges between two nodes.\n- The graph does not contain self loops.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(maxTime = 50,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1]],passingFees = [1, 2, 3, 4, 5, 6]) == 21\n assert candidate(maxTime = 5,edges = [[0, 1, 5], [0, 2, 5], [1, 3, 5], [2, 3, 5], [3, 4, 5]],passingFees = [10, 10, 10, 10, 10]) == -1\n assert candidate(maxTime = 10,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [0, 3, 15]],passingFees = [10, 1, 1, 10]) == -1\n assert candidate(maxTime = 20,edges = [[0, 1, 10], [1, 0, 10], [0, 2, 5], [2, 0, 5], [1, 3, 10], [3, 1, 10], [2, 3, 10], [3, 2, 10]],passingFees = [1, 2, 3, 4]) == 7\n assert candidate(maxTime = 15,edges = [[0, 1, 10], [1, 2, 10], [0, 2, 1]],passingFees = [3, 1, 2]) == 5\n assert candidate(maxTime = 10,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 10]],passingFees = [3, 2, 1]) == 4\n assert candidate(maxTime = 5,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 10]],passingFees = [1, 2, 3]) == -1\n assert candidate(maxTime = 29,edges = [[0, 1, 10], [1, 2, 10], [2, 5, 10], [0, 3, 1], [3, 4, 10], [4, 5, 15]],passingFees = [5, 1, 2, 20, 20, 3]) == 48\n assert candidate(maxTime = 50,edges = [[0, 1, 1], [0, 2, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1]],passingFees = [1, 1, 1, 1]) == 3\n assert candidate(maxTime = 50,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1]],passingFees = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(maxTime = 5,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 10]],passingFees = [3, 2, 1]) == -1\n assert candidate(maxTime = 30,edges = [[0, 1, 10], [1, 2, 10], [2, 5, 10], [0, 3, 1], [3, 4, 10], [4, 5, 15]],passingFees = [5, 1, 2, 20, 20, 3]) == 11\n assert candidate(maxTime = 25,edges = [[0, 1, 10], [1, 2, 10], [2, 5, 10], [0, 3, 1], [3, 4, 10], [4, 5, 15]],passingFees = [5, 1, 2, 20, 20, 3]) == -1\n assert candidate(maxTime = 5,edges = [[0, 1, 6], [1, 2, 5], [0, 2, 10]],passingFees = [1, 2, 3]) == -1\n assert candidate(maxTime = 10,edges = [[0, 1, 3], [1, 2, 3], [0, 2, 5]],passingFees = [1, 2, 3]) == 4\n assert candidate(maxTime = 50,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [0, 3, 15]],passingFees = [10, 20, 30, 40]) == 50\n assert candidate(maxTime = 20,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [0, 2, 5], [1, 3, 6]],passingFees = [1, 2, 3, 4]) == 7\n assert candidate(maxTime = 10,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 10]],passingFees = [1, 2, 3]) == 4\n assert candidate(maxTime = 1,edges = [[0, 1, 1]],passingFees = [1, 1]) == 2\n assert candidate(maxTime = 45,edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [0, 2, 25], [1, 3, 30], [2, 4, 10], [3, 5, 15], [0, 3, 35], [1, 4, 40], [2, 5, 20], [0, 4, 50], [1, 5, 55]],passingFees = [5, 4, 3, 2, 1, 6]) == 14\n assert candidate(maxTime = 150,edges = [[0, 1, 20], [1, 2, 30], [0, 2, 40], [2, 3, 10], [3, 4, 50], [0, 3, 10], [1, 4, 30], [4, 5, 20], [5, 6, 40], [6, 7, 30], [7, 5, 15], [6, 8, 10], [8, 9, 50], [9, 0, 20], [9, 1, 10], [1, 3, 25]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 55\n assert candidate(maxTime = 500,edges = [[0, 1, 5], [0, 2, 10], [1, 2, 15], [1, 3, 20], [2, 3, 25], [2, 4, 30], [3, 4, 35], [3, 5, 40], [4, 5, 45], [4, 6, 50], [5, 6, 55], [5, 7, 60], [6, 7, 65], [6, 8, 70], [7, 8, 75], [7, 9, 80], [8, 9, 85], [0, 3, 30], [0, 4, 40], [0, 5, 50], [1, 4, 45], [1, 5, 55], [1, 6, 65], [2, 5, 50], [2, 6, 60], [2, 7, 70], [3, 6, 65], [3, 7, 75], [3, 8, 80], [4, 7, 70], [4, 8, 80], [4, 9, 85], [5, 8, 80], [5, 9, 85], [6, 9, 85]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 160\n assert candidate(maxTime = 50,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 10, 5], [0, 10, 10], [1, 9, 15], [2, 8, 20], [3, 7, 25], [4, 6, 30]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == 60\n assert candidate(maxTime = 100,edges = [[0, 1, 20], [1, 2, 30], [2, 3, 10], [3, 4, 50], [0, 2, 40], [1, 3, 10], [2, 4, 20]],passingFees = [10, 5, 15, 20, 25]) == 50\n assert candidate(maxTime = 300,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 9, 9], [1, 0, 1], [2, 1, 2], [3, 2, 3], [4, 3, 4], [5, 4, 5], [6, 5, 6], [7, 6, 7], [8, 7, 8], [9, 8, 9]],passingFees = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(maxTime = 15,edges = [[0, 1, 4], [1, 2, 3], [0, 2, 6], [2, 3, 5], [3, 4, 7], [0, 3, 8], [1, 3, 2]],passingFees = [2, 3, 4, 1, 5]) == 8\n assert candidate(maxTime = 100,edges = [[0, 1, 50], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 10], [0, 5, 90], [1, 3, 25], [2, 4, 15]],passingFees = [10, 20, 30, 40, 50, 60]) == 70\n assert candidate(maxTime = 25,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [0, 5, 10], [1, 3, 5], [2, 4, 5], [0, 3, 7], [0, 4, 8], [1, 4, 4], [2, 5, 3]],passingFees = [1, 2, 3, 4, 5, 6]) == 7\n assert candidate(maxTime = 600,edges = [[0, 1, 15], [0, 5, 15], [1, 2, 25], [1, 6, 25], [2, 3, 35], [2, 7, 35], [3, 4, 45], [3, 8, 45], [4, 9, 55], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [0, 6, 25], [1, 7, 35], [2, 8, 45], [3, 9, 55], [0, 7, 35], [1, 8, 45], [2, 9, 55], [0, 8, 45], [1, 9, 55], [0, 9, 55], [5, 10, 5], [10, 6, 5], [6, 10, 5], [7, 10, 5], [10, 8, 5], [8, 10, 5], [9, 10, 5]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 180\n assert candidate(maxTime = 60,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [0, 3, 15], [0, 2, 10], [1, 3, 10], [3, 4, 10], [2, 4, 10], [0, 4, 20]],passingFees = [3, 2, 1, 2, 3]) == 6\n assert candidate(maxTime = 10,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [0, 3, 5], [0, 2, 1], [1, 3, 1]],passingFees = [1, 2, 3, 4]) == 5\n assert candidate(maxTime = 5,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5]],passingFees = [1, 1, 1, 1, 1]) == -1\n assert candidate(maxTime = 220,edges = [[0, 1, 50], [1, 2, 40], [2, 3, 30], [3, 4, 20], [4, 0, 10], [0, 2, 60], [1, 3, 50], [2, 4, 40], [0, 4, 50], [3, 2, 40]],passingFees = [1, 1, 1, 1, 1]) == 2\n assert candidate(maxTime = 300,edges = [[0, 1, 50], [1, 2, 50], [2, 3, 50], [3, 4, 50], [0, 2, 60], [1, 3, 60], [2, 4, 60], [0, 3, 70], [1, 4, 70], [0, 4, 80]],passingFees = [10, 20, 30, 40, 50]) == 60\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [0, 2, 30], [1, 3, 20], [2, 3, 10], [3, 4, 40], [1, 2, 5]],passingFees = [10, 15, 20, 25, 30]) == 80\n assert candidate(maxTime = 100,edges = [[0, 1, 20], [1, 2, 20], [2, 3, 20], [3, 4, 20], [4, 5, 20], [0, 3, 50], [3, 5, 50]],passingFees = [5, 10, 15, 20, 25, 30]) == 55\n assert candidate(maxTime = 200,edges = [[0, 1, 50], [1, 2, 40], [2, 3, 30], [3, 4, 20], [4, 0, 10], [0, 2, 60], [1, 3, 50], [2, 4, 40]],passingFees = [100, 200, 150, 50, 300]) == 400\n assert candidate(maxTime = 250,edges = [[0, 1, 5], [1, 2, 15], [2, 3, 25], [3, 4, 35], [4, 5, 45], [0, 5, 55], [1, 3, 25], [2, 4, 35], [0, 4, 45], [1, 4, 15]],passingFees = [5, 5, 5, 5, 5, 5]) == 10\n assert candidate(maxTime = 600,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [0, 4, 40], [4, 5, 50], [1, 5, 60], [2, 6, 70], [3, 6, 80], [4, 7, 90], [5, 8, 100], [6, 8, 110], [0, 7, 120], [0, 3, 130], [1, 6, 140], [2, 7, 150], [3, 8, 160], [4, 6, 170], [5, 7, 180], [6, 7, 190]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 140\n assert candidate(maxTime = 150,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 10, 5]],passingFees = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10], [0, 5, 5], [1, 6, 5], [2, 7, 5], [3, 8, 5], [4, 9, 5]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 55\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 3, 25], [1, 4, 40], [3, 4, 15], [4, 5, 5], [5, 6, 30], [6, 1, 25], [2, 6, 10]],passingFees = [10, 15, 20, 25, 30, 35, 40]) == 65\n assert candidate(maxTime = 30,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],passingFees = [5, 1, 2, 20, 20, 3, 5, 1, 2, 3]) == -1\n assert candidate(maxTime = 120,edges = [[0, 1, 20], [0, 2, 30], [0, 3, 10], [1, 2, 15], [1, 3, 20], [1, 4, 10], [2, 3, 25], [2, 4, 5], [3, 4, 15], [2, 5, 10], [3, 5, 20], [4, 5, 5], [0, 5, 20]],passingFees = [15, 25, 35, 45, 55, 65]) == 80\n assert candidate(maxTime = 200,edges = [[0, 1, 30], [0, 2, 20], [1, 2, 10], [1, 3, 40], [2, 4, 20], [3, 4, 10], [3, 5, 50], [4, 5, 30], [2, 5, 25], [5, 6, 10], [6, 7, 20], [6, 8, 15], [7, 8, 5], [8, 9, 10], [9, 0, 10]],passingFees = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(maxTime = 20,edges = [[0, 1, 5], [1, 2, 10], [0, 3, 15], [3, 4, 20], [2, 4, 25], [4, 5, 30]],passingFees = [5, 10, 15, 20, 25, 30]) == -1\n assert candidate(maxTime = 50,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 15], [3, 4, 10], [4, 5, 10], [0, 3, 25], [1, 4, 20]],passingFees = [10, 20, 30, 40, 50, 60]) == 140\n assert candidate(maxTime = 60,edges = [[0, 1, 10], [0, 2, 15], [0, 3, 20], [1, 2, 5], [1, 3, 10], [2, 3, 25], [1, 4, 10], [2, 4, 5], [3, 4, 15], [2, 5, 10], [3, 5, 20], [4, 5, 5]],passingFees = [10, 20, 30, 40, 50, 60]) == 100\n assert candidate(maxTime = 50,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 0, 5], [0, 2, 10], [1, 3, 10], [2, 4, 10]],passingFees = [1, 2, 3, 4, 5]) == 6\n assert candidate(maxTime = 80,edges = [[0, 1, 10], [1, 2, 20], [0, 2, 30], [2, 3, 40], [0, 3, 50], [3, 4, 60], [0, 4, 70]],passingFees = [5, 5, 5, 5, 5]) == 10\n assert candidate(maxTime = 50,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [0, 2, 4], [1, 3, 3], [2, 4, 2], [3, 5, 1]],passingFees = [1, 2, 3, 4, 5, 6]) == 13\n assert candidate(maxTime = 120,edges = [[0, 1, 15], [1, 2, 25], [2, 3, 35], [3, 4, 45], [0, 3, 65], [1, 4, 75], [2, 4, 85], [0, 4, 95], [3, 1, 105], [4, 2, 115]],passingFees = [50, 20, 30, 40, 60]) == 110\n assert candidate(maxTime = 20,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [0, 5, 10]],passingFees = [5, 10, 15, 20, 25, 30]) == 35\n assert candidate(maxTime = 500,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [0, 4, 40], [4, 5, 50], [1, 5, 60], [2, 6, 70], [3, 6, 80], [4, 7, 90], [5, 8, 100], [6, 8, 110], [0, 7, 120]],passingFees = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 18\n assert candidate(maxTime = 200,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [0, 3, 30], [1, 3, 30], [2, 4, 30], [3, 4, 30], [0, 4, 50]],passingFees = [1, 2, 3, 4, 5]) == 6\n assert candidate(maxTime = 550,edges = [[0, 1, 20], [0, 5, 20], [1, 2, 30], [1, 6, 30], [2, 3, 40], [2, 7, 40], [3, 4, 50], [3, 8, 50], [4, 9, 60], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [0, 6, 40], [1, 7, 50], [2, 8, 60], [3, 9, 70], [0, 7, 50], [1, 8, 60], [2, 9, 70], [0, 8, 60], [1, 9, 70], [0, 9, 70]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 110\n assert candidate(maxTime = 400,edges = [[0, 1, 30], [1, 2, 30], [2, 3, 30], [3, 4, 30], [0, 2, 50], [1, 3, 50], [2, 4, 50], [0, 3, 70], [1, 4, 70], [0, 4, 90], [0, 5, 40], [5, 4, 10], [4, 6, 60], [6, 5, 10], [5, 3, 20]],passingFees = [5, 15, 25, 35, 45, 55, 65]) == 115\n assert candidate(maxTime = 350,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 3, 20], [3, 4, 40], [0, 3, 30], [1, 2, 20], [0, 4, 50], [1, 4, 30], [2, 4, 40]],passingFees = [10, 20, 30, 40, 50]) == 60\n assert candidate(maxTime = 350,edges = [[0, 1, 50], [1, 2, 100], [2, 3, 150], [3, 4, 200], [4, 5, 250], [5, 6, 300], [6, 7, 350], [7, 8, 400], [8, 9, 450], [0, 9, 500]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == -1\n assert candidate(maxTime = 30,edges = [[0, 1, 5], [0, 2, 10], [1, 2, 3], [1, 3, 15], [2, 3, 20], [3, 4, 25]],passingFees = [1, 2, 3, 4, 5]) == -1\n assert candidate(maxTime = 180,edges = [[0, 1, 20], [0, 2, 30], [1, 3, 40], [2, 3, 20], [3, 4, 50], [0, 3, 30], [1, 2, 30], [0, 4, 60], [1, 4, 40]],passingFees = [10, 10, 10, 10, 10]) == 20\n assert candidate(maxTime = 150,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 0, 5], [0, 3, 10], [1, 4, 10], [2, 5, 10], [3, 6, 10], [4, 7, 10], [5, 8, 10], [6, 9, 10], [7, 0, 10], [8, 1, 10], [9, 2, 10]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 110\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [0, 5, 50], [0, 2, 40], [1, 3, 30], [2, 4, 20], [3, 5, 10], [0, 4, 60], [1, 5, 50]],passingFees = [5, 1, 2, 3, 4, 5]) == 10\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [0, 2, 15], [1, 2, 10], [1, 3, 20], [2, 4, 15], [3, 4, 20], [4, 5, 30], [3, 5, 40]],passingFees = [5, 1, 2, 3, 4, 5]) == 14\n assert candidate(maxTime = 35,edges = [[0, 1, 5], [1, 2, 3], [0, 2, 9], [1, 3, 7], [2, 4, 4], [0, 3, 6], [1, 4, 8], [3, 4, 2], [0, 4, 12]],passingFees = [1, 2, 3, 4, 5]) == 6\n assert candidate(maxTime = 25,edges = [[0, 1, 10], [1, 2, 15], [0, 2, 20], [2, 3, 5], [3, 4, 10], [4, 5, 15], [5, 6, 20], [6, 7, 25], [7, 8, 30], [8, 9, 10], [0, 9, 35]],passingFees = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(maxTime = 300,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [0, 3, 60], [1, 4, 70], [2, 5, 80], [0, 2, 90], [3, 5, 100]],passingFees = [10, 20, 30, 40, 50, 60]) == 100\n assert candidate(maxTime = 30,edges = [[0, 1, 5], [1, 2, 7], [2, 3, 6], [0, 3, 10], [1, 3, 2], [2, 4, 5], [3, 4, 3], [0, 4, 8]],passingFees = [10, 20, 15, 25, 30]) == 40\n assert candidate(maxTime = 400,edges = [[0, 1, 100], [1, 2, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [0, 5, 100], [0, 2, 100], [1, 3, 100], [2, 4, 100], [3, 5, 100]],passingFees = [5, 5, 5, 5, 5, 5]) == 10\n assert candidate(maxTime = 200,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10], [0, 2, 20], [1, 3, 20], [2, 4, 20], [3, 5, 20], [4, 6, 20], [5, 7, 20], [6, 8, 20], [7, 9, 20], [8, 1, 20], [9, 2, 20], [0, 3, 30], [1, 4, 30], [2, 5, 30], [3, 6, 30], [4, 7, 30], [5, 8, 30], [6, 9, 30], [7, 0, 30], [8, 1, 30], [9, 2, 30], [0, 4, 40], [1, 5, 40], [2, 6, 40], [3, 7, 40], [4, 8, 40], [5, 9, 40], [6, 0, 40], [7, 1, 40], [8, 2, 40], [9, 3, 40]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 55\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [0, 2, 5], [1, 3, 5], [0, 3, 2], [2, 4, 20], [3, 4, 10]],passingFees = [10, 5, 3, 20, 1]) == 14\n assert candidate(maxTime = 30,edges = [[0, 1, 10], [1, 2, 10], [2, 5, 10], [0, 3, 1], [3, 4, 10], [4, 5, 15], [1, 3, 1], [2, 4, 5]],passingFees = [5, 1, 2, 20, 20, 3]) == 11\n assert candidate(maxTime = 50,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [0, 9, 40]],passingFees = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 19\n assert candidate(maxTime = 200,edges = [[0, 1, 15], [0, 2, 20], [1, 3, 25], [2, 3, 15], [3, 4, 30], [0, 3, 15], [1, 2, 10]],passingFees = [10, 20, 30, 40, 50]) == 100\n assert candidate(maxTime = 180,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [0, 4, 50], [0, 2, 60], [1, 3, 70], [2, 4, 80], [3, 1, 90], [4, 0, 100]],passingFees = [50, 40, 30, 20, 10]) == 60\n assert candidate(maxTime = 300,edges = [[0, 1, 10], [1, 2, 20], [0, 3, 30], [3, 4, 40], [4, 5, 50], [0, 2, 60], [2, 3, 70], [1, 4, 80], [2, 5, 90]],passingFees = [5, 10, 15, 20, 25, 30]) == 50\n assert candidate(maxTime = 150,edges = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [0, 5, 50], [1, 3, 20], [2, 4, 25]],passingFees = [1, 1, 1, 1, 1, 1]) == 2\n assert candidate(maxTime = 220,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 20], [2, 3, 15], [3, 4, 25], [0, 3, 25], [1, 2, 15], [0, 4, 40], [1, 4, 25], [2, 4, 35]],passingFees = [5, 15, 25, 35, 45]) == 50\n assert candidate(maxTime = 15,edges = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [2, 3, 5], [0, 3, 1]],passingFees = [10, 20, 30, 40]) == 50\n assert candidate(maxTime = 40,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 15], [3, 4, 5], [4, 5, 5], [5, 6, 5], [0, 2, 25], [1, 3, 15], [2, 4, 25], [3, 5, 15], [0, 4, 40], [1, 5, 25]],passingFees = [3, 2, 1, 4, 2, 5, 3]) == 13\n assert candidate(maxTime = 200,edges = [[0, 1, 100], [1, 2, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [0, 3, 1], [3, 4, 1], [4, 5, 1], [0, 2, 1], [2, 4, 1]],passingFees = [5, 1, 2, 20, 20, 3]) == 30\n assert candidate(maxTime = 40,edges = [[0, 1, 3], [0, 2, 4], [1, 2, 2], [1, 3, 5], [2, 3, 6], [2, 4, 1], [3, 4, 7], [0, 4, 8], [1, 4, 3]],passingFees = [1, 2, 3, 4, 5]) == 6\n assert candidate(maxTime = 60,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],passingFees = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(maxTime = 150,edges = [[0, 1, 10], [1, 2, 20], [0, 2, 30], [2, 3, 10], [3, 0, 20], [1, 3, 10], [0, 3, 50], [1, 0, 20], [2, 1, 30], [3, 2, 40]],passingFees = [5, 15, 25, 35]) == 40\n assert candidate(maxTime = 60,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [0, 14, 60]],passingFees = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 18\n assert candidate(maxTime = 250,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [0, 9, 100]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 110\n assert candidate(maxTime = 500,edges = [[0, 1, 25], [1, 2, 25], [2, 3, 25], [3, 4, 25], [4, 5, 25], [5, 6, 25], [6, 7, 25], [7, 8, 25], [8, 9, 25], [9, 10, 25], [0, 9, 200], [9, 1, 200], [1, 10, 200], [10, 0, 200], [0, 10, 100], [1, 9, 100], [9, 2, 100], [2, 0, 100], [0, 8, 150], [8, 3, 150], [3, 1, 150], [1, 6, 150], [6, 4, 150], [4, 2, 150], [2, 7, 150], [7, 5, 150], [5, 8, 150]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 120\n assert candidate(maxTime = 400,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 4, 40], [3, 5, 50], [4, 6, 60], [1, 2, 70], [3, 4, 80], [2, 5, 90], [4, 5, 100]],passingFees = [5, 10, 15, 20, 25, 30, 35]) == 80\n assert candidate(maxTime = 100,edges = [[0, 1, 20], [1, 2, 20], [2, 3, 20], [3, 4, 20], [4, 5, 20], [5, 6, 20], [6, 7, 20], [7, 8, 20], [8, 9, 20], [9, 10, 20], [10, 11, 20], [11, 12, 20], [12, 13, 20], [13, 14, 20], [14, 15, 20], [15, 16, 20], [16, 17, 20], [17, 18, 20], [18, 19, 20], [0, 19, 90]],passingFees = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n assert candidate(maxTime = 80,edges = [[0, 1, 20], [0, 2, 30], [1, 3, 10], [2, 3, 10], [3, 4, 20], [0, 3, 10]],passingFees = [5, 5, 5, 5, 5]) == 15\n assert candidate(maxTime = 70,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 0, 5]],passingFees = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 20\n assert candidate(maxTime = 60,edges = [[0, 1, 20], [1, 2, 20], [2, 3, 20], [3, 4, 20], [0, 2, 10], [1, 3, 10], [2, 4, 10], [0, 3, 30], [1, 4, 30]],passingFees = [5, 15, 25, 35, 45]) == 65\n assert candidate(maxTime = 120,edges = [[0, 1, 10], [0, 2, 20], [1, 2, 30], [1, 3, 20], [2, 3, 10], [3, 4, 10], [0, 3, 20], [1, 2, 30]],passingFees = [5, 5, 5, 5, 5]) == 15\n assert candidate(maxTime = 800,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [0, 4, 40], [4, 5, 50], [1, 5, 60], [2, 6, 70], [3, 6, 80], [4, 7, 90], [5, 8, 100], [6, 8, 110], [0, 7, 120], [0, 3, 130], [1, 6, 140], [2, 7, 150], [3, 8, 160], [4, 6, 170], [5, 7, 180], [6, 7, 190], [1, 3, 200], [2, 4, 210], [3, 5, 220], [4, 8, 230], [5, 6, 240], [0, 8, 250], [1, 7, 260], [2, 8, 270], [3, 7, 280], [4, 7, 290], [0, 6, 300], [1, 8, 310], [2, 5, 320], [3, 4, 330]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 100\n assert candidate(maxTime = 20,edges = [[0, 1, 5], [1, 2, 3], [2, 3, 7], [0, 3, 12], [3, 4, 10], [2, 4, 2], [0, 4, 8]],passingFees = [4, 1, 2, 3, 5]) == 9\n assert candidate(maxTime = 200,edges = [[0, 1, 50], [1, 2, 50], [2, 3, 50], [3, 4, 50], [4, 5, 50], [0, 3, 60], [2, 4, 70]],passingFees = [10, 20, 30, 40, 50, 60]) == 160\n assert candidate(maxTime = 300,edges = [[0, 1, 50], [0, 2, 100], [1, 3, 200], [2, 3, 150], [3, 4, 250], [0, 3, 200], [1, 2, 100], [0, 4, 300], [1, 4, 150]],passingFees = [10, 20, 30, 40, 50]) == 60\n", "comparison": "exact"}, "public_tests": ["30\n[[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]]\n[5,1,2,20,20,3]", "29\n[[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]]\n[5,1,2,20,20,3]", "25\n[[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]]\n[5,1,2,20,20,3]"], "hints": ["Consider a new graph where each node is one of the old nodes at a specific time. For example, node 0 at time 5.", "You need to find the shortest path in the new graph."], "metadata": {"canonical_parameter_names": ["maxTime", "edges", "passingFees"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:21+00:00", "tests_total": 98, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "graph", "dijkstra"]}, "language": "python", "interface": {"raw_signature": "def minCost(self, maxTime: int, edges: list[list[int]], passingFees: list[int]) -> int:", "container": "Solution", "callable": "minCost", "parameters": [{"name": "maxTime", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "passingFees", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1929, "task_id": "concatenation-of-array", "difficulty": "Easy", "problem_description": "Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n (0-indexed).\n\nSpecifically, ans is the concatenation of two nums arrays.\n\nReturn the array ans.\n\nExample 1:\n\nInput: nums = [1,2,1]\nOutput: [1,2,1,1,2,1]\nExplanation: The array ans is formed as follows:\n- ans = [nums[0],nums[1],nums[2],nums[0],nums[1],nums[2]]\n- ans = [1,2,1,1,2,1]\n\nExample 2:\n\nInput: nums = [1,3,2,1]\nOutput: [1,3,2,1,1,3,2,1]\nExplanation: The array ans is formed as follows:\n- ans = [nums[0],nums[1],nums[2],nums[3],nums[0],nums[1],nums[2],nums[3]]\n- ans = [1,3,2,1,1,3,2,1]\n\nConstraints:\n\n- n == nums.length\n- 1 <= n <= 1000\n- 1 <= nums[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [5, 6, 7]) == [5, 6, 7, 5, 6, 7]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [1, 2, 1]) == [1, 2, 1, 1, 2, 1]\n assert candidate(nums = [1000, 999, 998, 997, 996]) == [1000, 999, 998, 997, 996, 1000, 999, 998, 997, 996]\n assert candidate(nums = [1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [999, 1000]) == [999, 1000, 999, 1000]\n assert candidate(nums = [1, 3, 2, 1]) == [1, 3, 2, 1, 1, 3, 2, 1]\n assert candidate(nums = [10, 20, 30, 40, 50]) == [10, 20, 30, 40, 50, 10, 20, 30, 40, 50]\n assert candidate(nums = [999, 1000, 999, 1000]) == [999, 1000, 999, 1000, 999, 1000, 999, 1000]\n assert candidate(nums = [5, 6, 7, 8, 9]) == [5, 6, 7, 8, 9, 5, 6, 7, 8, 9]\n assert candidate(nums = [5]) == [5, 5]\n assert candidate(nums = [1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10]) == [10, 10]\n assert candidate(nums = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992, 8, 991, 9, 990, 10]) == [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992, 8, 991, 9, 990, 10, 999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992, 8, 991, 9, 990, 10]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == [1, 2, 3, 2, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 2, 3, 2, 1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510]) == [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510]\n assert candidate(nums = [1000, 1, 999, 2, 998, 3, 997, 4, 996, 5]) == [1000, 1, 999, 2, 998, 3, 997, 4, 996, 5, 1000, 1, 999, 2, 998, 3, 997, 4, 996, 5]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [500, 250, 125, 62, 31, 15, 7, 3, 1]) == [500, 250, 125, 62, 31, 15, 7, 3, 1, 500, 250, 125, 62, 31, 15, 7, 3, 1]\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630]) == [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630]\n assert candidate(nums = [1000, 1, 200, 2, 300, 3, 400, 4]) == [1000, 1, 200, 2, 300, 3, 400, 4, 1000, 1, 200, 2, 300, 3, 400, 4]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209]) == [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209]\n assert candidate(nums = [999, 1000, 998, 999, 1000, 998, 999]) == [999, 1000, 998, 999, 1000, 998, 999, 999, 1000, 998, 999, 1000, 998, 999]\n assert candidate(nums = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]) == [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666]) == [333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666]\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970]) == [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]\n assert candidate(nums = [999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == [999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 998, 997, 996, 995, 994, 993, 992, 991, 990, 999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 998, 997, 996, 995, 994, 993, 992, 991, 990]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 1]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991]) == [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991, 1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]\n assert candidate(nums = [999, 1000, 999, 1000, 999, 1000, 999, 1000]) == [999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115]\n assert candidate(nums = [1000, 1, 1000, 1, 1000, 1, 1000]) == [1000, 1, 1000, 1, 1000, 1, 1000, 1000, 1, 1000, 1, 1000, 1, 1000]\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505]) == [123, 456, 789, 101, 202, 303, 404, 505, 123, 456, 789, 101, 202, 303, 404, 505]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840]) == [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840, 42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840]\n", "comparison": "exact"}, "public_tests": ["[1,2,1]", "[1,3,2,1]"], "hints": ["Build an array of size 2 * n and assign nums[i] to ans[i] and ans[i + n]"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().getConcatenation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:23+00:00", "tests_total": 71, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "simulation"]}, "language": "python", "interface": {"raw_signature": "def getConcatenation(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "getConcatenation", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1930, "task_id": "unique-length-3-palindromic-subsequences", "difficulty": "Medium", "problem_description": "Given a string s, return the number of unique palindromes of length three that are a subsequence of s.\n\nNote that even if there are multiple ways to obtain the same subsequence, it is still only counted once.\n\nA palindrome is a string that reads the same forwards and backwards.\n\nA subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.\n\n- For example, \"ace\" is a subsequence of \"abcde\".\n\nExample 1:\n\nInput: s = \"aabca\"\nOutput: 3\nExplanation: The 3 palindromic subsequences of length 3 are:\n- \"aba\" (subsequence of \"aabca\")\n- \"aaa\" (subsequence of \"aabca\")\n- \"aca\" (subsequence of \"aabca\")\n\nExample 2:\n\nInput: s = \"adc\"\nOutput: 0\nExplanation: There are no palindromic subsequences of length 3 in \"adc\".\n\nExample 3:\n\nInput: s = \"bbcbaba\"\nOutput: 4\nExplanation: The 4 palindromic subsequences of length 3 are:\n- \"bbb\" (subsequence of \"bbcbaba\")\n- \"bcb\" (subsequence of \"bbcbaba\")\n- \"bab\" (subsequence of \"bbcbaba\")\n- \"aba\" (subsequence of \"bbcbaba\")\n\nConstraints:\n\n- 3 <= s.length <= 10^5\n- s consists of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcba\") == 3\n assert candidate(s = \"madam\") == 3\n assert candidate(s = \"abcdedcba\") == 10\n assert candidate(s = \"aaaaa\") == 1\n assert candidate(s = \"adc\") == 0\n assert candidate(s = \"abcabcabc\") == 9\n assert candidate(s = \"abracadabra\") == 13\n assert candidate(s = \"aaa\") == 1\n assert candidate(s = \"racecar\") == 6\n assert candidate(s = \"abba\") == 1\n assert candidate(s = \"noon\") == 1\n assert candidate(s = \"abccba\") == 3\n assert candidate(s = \"aaaa\") == 1\n assert candidate(s = \"aabbcc\") == 0\n assert candidate(s = \"mississippi\") == 5\n assert candidate(s = \"aabca\") == 3\n assert candidate(s = \"bbcbaba\") == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(s = \"xyzzyx\") == 3\n assert candidate(s = \"level\") == 3\n assert candidate(s = \"abcdefg\") == 0\n assert candidate(s = \"aabacbaabacba\") == 8\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(s = \"noonmoonnoonmoonnoonmoonnoonmoonnoonmoonnoonmoonnoon\") == 9\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyyxwwvvuuttssrrqqppoonnmmllkkjjiihhggeeffddccbbaa\") == 352\n assert candidate(s = \"zzzzzzzyyyyxxxwwvvuttsrrqqppoonnmmllkkjjiihhggffeeddccba\") == 3\n assert candidate(s = \"zzzazzaaz\") == 4\n assert candidate(s = \"abacabadabacaba\") == 11\n assert candidate(s = \"ababababababababababababababababababababab\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 9\n assert candidate(s = \"ababcab\") == 6\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 16\n assert candidate(s = \"racecarcarcarecarracecarcarcarecarracecarcarcarecarracecar\") == 16\n assert candidate(s = \"abacdfgdcaba\") == 16\n assert candidate(s = \"aabbbaaabbbaaa\") == 4\n assert candidate(s = \"aaabaaaabaaaaabaaaabaaaaaabaaaa\") == 4\n assert candidate(s = \"aaaabaaaabaaaab\") == 4\n assert candidate(s = \"abcbabcbabcbabcbabcbabcbabcba\") == 9\n assert candidate(s = \"bababababababababababababababababababababa\") == 4\n assert candidate(s = \"abcbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbac\") == 9\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 4\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 325\n assert candidate(s = \"xyzyxyzyxyzyx\") == 9\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 650\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaedcba\") == 20\n assert candidate(s = \"abbaabbbaabbaabbbaabbaabbbaabbaabbbaabbaabbba\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 9\n assert candidate(s = \"abcdefghihgfedcbaabcdefghihgfedcba\") == 80\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 26\n assert candidate(s = \"aaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaab\") == 4\n assert candidate(s = \"abcbacbacbacbacbacbacbacbacbacbacbacbacb\") == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"babababababababababababababababababababababababababababababa\") == 4\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\") == 4\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzzzz\") == 26\n assert candidate(s = \"mamamadadadmmadammaddada\") == 9\n assert candidate(s = \"aabbccddeeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"ababababababababababababababababababababababababababab\") == 4\n assert candidate(s = \"aaaaaaaaaaaabbbbbbbbbbbbccccccccccdddddddddd\") == 4\n assert candidate(s = \"racecarcarcarecarracecarcarcarecarracecar\") == 16\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 9\n assert candidate(s = \"abacbacbacbacba\") == 9\n assert candidate(s = \"ababababababababababababababababababababababababababababababab\") == 4\n assert candidate(s = \"mississippississippiississippiississippiississippiississippi\") == 9\n assert candidate(s = \"abcabcabcabcabc\") == 9\n assert candidate(s = \"noonmoonnoonmoon\") == 8\n assert candidate(s = \"noonmoonnoonmoonnoonmoonnoonmoonnoonmoonnoonmoonnoonnoonmoon\") == 9\n assert candidate(s = \"aaaaabbbbbccccc\") == 3\n assert candidate(s = \"mississippississippiississippiississippiississippi\") == 9\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabad\") == 16\n assert candidate(s = \"zzzzzyyyxxwwvvuttsrrqqppoonnmmllkkjjiihhggffeeddccba\") == 2\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 9\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\") == 4\n", "comparison": "exact"}, "public_tests": ["\"aabca\"", "\"adc\"", "\"bbcbaba\""], "hints": ["What is the maximum number of length-3 palindromic strings?", "How can we keep track of the characters that appeared to the left of a given position?"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().countPalindromicSubsequence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:25+00:00", "tests_total": 75, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "bit-manipulation", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def countPalindromicSubsequence(self, s: str) -> int:", "container": "Solution", "callable": "countPalindromicSubsequence", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1931, "task_id": "painting-a-grid-with-three-different-colors", "difficulty": "Hard", "problem_description": "You are given two integers m and n. Consider an m x n grid where each cell is initially white. You can paint each cell red, green, or blue. All cells must be painted.\n\nReturn the number of ways to color the grid with no two adjacent cells having the same color. Since the answer can be very large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: m = 1, n = 1\nOutput: 3\nExplanation: The three possible colorings are shown in the image above.\n\nExample 2:\n\nInput: m = 1, n = 2\nOutput: 6\nExplanation: The six possible colorings are shown in the image above.\n\nExample 3:\n\nInput: m = 5, n = 5\nOutput: 580986\n\nConstraints:\n\n- 1 <= m <= 5\n- 1 <= n <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(m = 2,n = 4) == 162\n assert candidate(m = 4,n = 3) == 1122\n assert candidate(m = 5,n = 1) == 48\n assert candidate(m = 1,n = 2) == 6\n assert candidate(m = 5,n = 5) == 580986\n assert candidate(m = 3,n = 4) == 1122\n assert candidate(m = 1,n = 1) == 3\n assert candidate(m = 4,n = 2) == 162\n assert candidate(m = 3,n = 3) == 246\n assert candidate(m = 2,n = 3) == 54\n assert candidate(m = 5,n = 800) == 253729951\n assert candidate(m = 4,n = 4) == 7812\n assert candidate(m = 2,n = 800) == 351341125\n assert candidate(m = 5,n = 500) == 859596253\n assert candidate(m = 5,n = 250) == 385854418\n assert candidate(m = 1,n = 1000) == 32634808\n assert candidate(m = 4,n = 350) == 47085356\n assert candidate(m = 3,n = 10) == 10107954\n assert candidate(m = 4,n = 500) == 614795573\n assert candidate(m = 1,n = 5) == 48\n assert candidate(m = 1,n = 500) == 85724507\n assert candidate(m = 3,n = 50) == 151149117\n assert candidate(m = 4,n = 600) == 643128638\n assert candidate(m = 4,n = 750) == 346928514\n assert candidate(m = 3,n = 500) == 350959293\n assert candidate(m = 2,n = 100) == 772083415\n assert candidate(m = 5,n = 2) == 486\n assert candidate(m = 2,n = 900) == 360544652\n assert candidate(m = 2,n = 2) == 18\n assert candidate(m = 4,n = 1000) == 281273229\n assert candidate(m = 4,n = 998) == 16509421\n assert candidate(m = 3,n = 7) == 106494\n assert candidate(m = 3,n = 1000) == 650420578\n assert candidate(m = 5,n = 50) == 597561939\n assert candidate(m = 4,n = 100) == 80216004\n assert candidate(m = 4,n = 10) == 896895828\n assert candidate(m = 4,n = 999) == 772309689\n assert candidate(m = 4,n = 6) == 379602\n assert candidate(m = 2,n = 999) == 37925462\n assert candidate(m = 5,n = 100) == 714933866\n assert candidate(m = 2,n = 600) == 138487123\n assert candidate(m = 3,n = 1) == 12\n assert candidate(m = 5,n = 10) == 796884854\n assert candidate(m = 3,n = 800) == 314710698\n assert candidate(m = 4,n = 5) == 54450\n assert candidate(m = 5,n = 200) == 55054779\n assert candidate(m = 3,n = 750) == 493513580\n assert candidate(m = 5,n = 997) == 582030758\n assert candidate(m = 3,n = 900) == 999754739\n assert candidate(m = 3,n = 700) == 360760626\n assert candidate(m = 5,n = 300) == 194398079\n assert candidate(m = 4,n = 9) == 128643282\n assert candidate(m = 2,n = 1000) == 113776386\n assert candidate(m = 4,n = 700) == 795691966\n assert candidate(m = 4,n = 250) == 727847864\n assert candidate(m = 5,n = 3) == 5118\n assert candidate(m = 4,n = 800) == 197304781\n assert candidate(m = 3,n = 300) == 748221310\n assert candidate(m = 5,n = 1000) == 408208448\n assert candidate(m = 3,n = 20) == 690883140\n assert candidate(m = 2,n = 5) == 486\n", "comparison": "exact"}, "public_tests": ["1\n1", "1\n2", "5\n5"], "hints": ["Represent each colored column by a bitmask based on each cell color.", "Use bitmasks DP with state (currentCell, prevColumn)."], "metadata": {"canonical_parameter_names": ["m", "n"], "leetcode_dataset_entry_point": "Solution().colorTheGrid", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:28+00:00", "tests_total": 61, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["dynamic-programming", "graph-coloring"]}, "language": "python", "interface": {"raw_signature": "def colorTheGrid(self, m: int, n: int) -> int:", "container": "Solution", "callable": "colorTheGrid", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1935, "task_id": "maximum-number-of-words-you-can-type", "difficulty": "Easy", "problem_description": "There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly.\n\nGiven a string text of words separated by a single space (no leading or trailing spaces) and a string brokenLetters of all distinct letter keys that are broken, return the number of words in text you can fully type using this keyboard.\n\nExample 1:\n\nInput: text = \"hello world\", brokenLetters = \"ad\"\nOutput: 1\nExplanation: We cannot type \"world\" because the 'd' key is broken.\n\nExample 2:\n\nInput: text = \"leet code\", brokenLetters = \"lt\"\nOutput: 1\nExplanation: We cannot type \"leet\" because the 'l' and 't' keys are broken.\n\nExample 3:\n\nInput: text = \"leet code\", brokenLetters = \"e\"\nOutput: 0\nExplanation: We cannot type either word because the 'e' key is broken.\n\nConstraints:\n\n- 1 <= text.length <= 10^4\n- 0 <= brokenLetters.length <= 26\n- text consists of words separated by a single space without any leading or trailing spaces.\n- Each word only consists of lowercase English letters.\n- brokenLetters consists of distinct lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"jumped over the lazy dog\",brokenLetters = \"zg\") == 3\n assert candidate(text = \"nopqrstuvwxyz\",brokenLetters = \"xyz\") == 0\n assert candidate(text = \"xyzzzz\",brokenLetters = \"x\") == 0\n assert candidate(text = \"leet code\",brokenLetters = \"lt\") == 1\n assert candidate(text = \"programming is fun\",brokenLetters = \"fn\") == 1\n assert candidate(text = \"this is a test\",brokenLetters = \"xyz\") == 4\n assert candidate(text = \"mississippi\",brokenLetters = \"sip\") == 0\n assert candidate(text = \"python java cplusplus\",brokenLetters = \"ypx\") == 1\n assert candidate(text = \"same same same\",brokenLetters = \"aem\") == 0\n assert candidate(text = \"a b c d e\",brokenLetters = \"\") == 5\n assert candidate(text = \"aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu vv ww xx yy zz\",brokenLetters = \"xyz\") == 23\n assert candidate(text = \"abcdefghijk\",brokenLetters = \"abcde\") == 0\n assert candidate(text = \"leet code\",brokenLetters = \"e\") == 0\n assert candidate(text = \"single\",brokenLetters = \"s\") == 0\n assert candidate(text = \"unique words\",brokenLetters = \"\") == 2\n assert candidate(text = \"single\",brokenLetters = \"\") == 1\n assert candidate(text = \"abc def ghi\",brokenLetters = \"xyz\") == 3\n assert candidate(text = \"python programming\",brokenLetters = \"p\") == 0\n assert candidate(text = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",brokenLetters = \"\") == 26\n assert candidate(text = \"a quick brown fox\",brokenLetters = \"\") == 4\n assert candidate(text = \"abcd efgh ijkl mnop qrst uvwx yz\",brokenLetters = \"aeiou\") == 2\n assert candidate(text = \"python programming\",brokenLetters = \"th\") == 1\n assert candidate(text = \"abcdefghij\",brokenLetters = \"\") == 1\n assert candidate(text = \"hello hello hello\",brokenLetters = \"lo\") == 0\n assert candidate(text = \"hello world\",brokenLetters = \"ad\") == 1\n assert candidate(text = \"every good boy does fine\",brokenLetters = \"f\") == 4\n assert candidate(text = \"hello world abcdefghijklmnopqrstuvwxyz\",brokenLetters = \"\") == 3\n assert candidate(text = \"a b c d e f g\",brokenLetters = \"xyz\") == 7\n assert candidate(text = \"extreme example with all letters\",brokenLetters = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(text = \"this is a simple test\",brokenLetters = \"sti\") == 1\n assert candidate(text = \"singleword\",brokenLetters = \"w\") == 0\n assert candidate(text = \"abcdefghij klmnopqrstuvwxyz\",brokenLetters = \"xyz\") == 1\n assert candidate(text = \"university of california berkeley\",brokenLetters = \"bcdfg\") == 1\n assert candidate(text = \"congratulations on your success\",brokenLetters = \"cns\") == 1\n assert candidate(text = \"every good boy does fine\",brokenLetters = \"bd\") == 2\n assert candidate(text = \"hello world from the other side\",brokenLetters = \"dfr\") == 2\n assert candidate(text = \"complexity arises from multiple factors\",brokenLetters = \"ae\") == 1\n assert candidate(text = \"all the letters of the alphabet\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"keyboard malfunctioning example\",brokenLetters = \"kmb\") == 0\n assert candidate(text = \"short long longer longestword\",brokenLetters = \"nlg\") == 1\n assert candidate(text = \"repeated letters letters letters\",brokenLetters = \"r\") == 0\n assert candidate(text = \"quick brown fox jumps over the lazy dog\",brokenLetters = \"xyz\") == 6\n assert candidate(text = \"data structures and algorithms\",brokenLetters = \"dts\") == 0\n assert candidate(text = \"abcdef ghijklm nopqrst uvwxyz\",brokenLetters = \"mnop\") == 2\n assert candidate(text = \"multiple broken letters test\",brokenLetters = \"mlpt\") == 1\n assert candidate(text = \"abcdefghij klmnopqrstuvwxyz\",brokenLetters = \"jkl\") == 0\n assert candidate(text = \"mississippi river\",brokenLetters = \"is\") == 0\n assert candidate(text = \"no broken letters here\",brokenLetters = \"qwxz\") == 4\n assert candidate(text = \"programming is fun\",brokenLetters = \"funs\") == 0\n assert candidate(text = \"all unique characters\",brokenLetters = \"\") == 3\n assert candidate(text = \"quick brown fox jumps over the lazy dog\",brokenLetters = \"\") == 8\n assert candidate(text = \"hello world hello universe\",brokenLetters = \"d\") == 3\n assert candidate(text = \"supercalifragilisticexpialidocious\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"special symbols are not included !@#$%^&*()\",brokenLetters = \"\") == 6\n assert candidate(text = \"brokenkeyboard faultydevice\",brokenLetters = \"bdf\") == 0\n assert candidate(text = \"sequential typing test\",brokenLetters = \"qseq\") == 1\n assert candidate(text = \"unique letters in words\",brokenLetters = \"aeiouy\") == 0\n assert candidate(text = \"python code implementation\",brokenLetters = \"py\") == 1\n assert candidate(text = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",brokenLetters = \"qz\") == 24\n assert candidate(text = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",brokenLetters = \"abcdefghijkl\") == 14\n assert candidate(text = \"complex words like supercalifragilisticexpialidocious\",brokenLetters = \"xyz\") == 2\n assert candidate(text = \"this is a simple test case\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"one two three four five six seven eight nine ten\",brokenLetters = \"on\") == 4\n assert candidate(text = \"lets write some code\",brokenLetters = \"wrs\") == 1\n assert candidate(text = \"multiple broken letters scenario\",brokenLetters = \"aeiouy\") == 0\n assert candidate(text = \"complex problem solving required\",brokenLetters = \"abc\") == 2\n assert candidate(text = \"this is a simple test\",brokenLetters = \"s\") == 1\n assert candidate(text = \"all characters must be checked\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"quick brown fox jumps over lazy dog\",brokenLetters = \"qz\") == 5\n assert candidate(text = \"various broken keys test\",brokenLetters = \"var\") == 2\n assert candidate(text = \"quick brown fox jumps over the lazy dog\",brokenLetters = \"qz\") == 6\n assert candidate(text = \"a quick brown fox jumps over the lazy dog\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"beautiful scenery on the mountain top\",brokenLetters = \"mnt\") == 0\n assert candidate(text = \"vowels are often omitted\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"mississippi river flows smoothly\",brokenLetters = \"m\") == 2\n assert candidate(text = \"hello world from another dimension\",brokenLetters = \"ad\") == 2\n assert candidate(text = \"singlewordwithoutspaces\",brokenLetters = \"s\") == 0\n assert candidate(text = \"abcdefghijklmnopqrstuvwxyz\",brokenLetters = \"xyz\") == 0\n assert candidate(text = \"fuzzy wuzzy was a bear\",brokenLetters = \"f\") == 4\n assert candidate(text = \"algorithms and data structures\",brokenLetters = \"da\") == 1\n assert candidate(text = \"make america great again\",brokenLetters = \"mag\") == 0\n assert candidate(text = \"hello hello hello world\",brokenLetters = \"d\") == 3\n assert candidate(text = \"a aa aaa aaaa aaaaa\",brokenLetters = \"a\") == 0\n assert candidate(text = \"mississippi river\",brokenLetters = \"m\") == 1\n assert candidate(text = \"many many words with many repeated letters\",brokenLetters = \"mny\") == 4\n assert candidate(text = \"abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz\",brokenLetters = \"\") == 2\n assert candidate(text = \"alibaba cloud is amazing\",brokenLetters = \"aim\") == 1\n assert candidate(text = \"boundary conditions and edge cases\",brokenLetters = \"bace\") == 0\n assert candidate(text = \"the quick brown fox jumps over the lazy dog\",brokenLetters = \"\") == 9\n assert candidate(text = \"algorithm data structures\",brokenLetters = \"abcde\") == 0\n assert candidate(text = \"xylophone xylophone xylophone\",brokenLetters = \"xy\") == 0\n assert candidate(text = \"complex problem solving\",brokenLetters = \"cps\") == 0\n assert candidate(text = \"longer words with various letters\",brokenLetters = \"wv\") == 2\n assert candidate(text = \"every good boy does fine\",brokenLetters = \"boyd\") == 1\n assert candidate(text = \"the quick brown fox jumps over the lazy dog\",brokenLetters = \"qxyz\") == 6\n assert candidate(text = \"programming in python is fun\",brokenLetters = \"pqf\") == 2\n assert candidate(text = \"this is a test case with many words\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"repeated letters in words\",brokenLetters = \"r\") == 1\n assert candidate(text = \"mississippi river\",brokenLetters = \"r\") == 1\n assert candidate(text = \"edge cases require attention\",brokenLetters = \"ecr\") == 0\n assert candidate(text = \"short words\",brokenLetters = \"aef\") == 2\n assert candidate(text = \"all characters are broken here\",brokenLetters = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(text = \"this is a simple test\",brokenLetters = \"st\") == 1\n assert candidate(text = \"multiple words with repeated letters\",brokenLetters = \"w\") == 3\n assert candidate(text = \"python is a versatile programming language\",brokenLetters = \"p\") == 4\n assert candidate(text = \"this is a simple test case\",brokenLetters = \"\") == 6\n assert candidate(text = \"short words\",brokenLetters = \"ow\") == 0\n assert candidate(text = \"distinct distinct letters letters\",brokenLetters = \"distnl\") == 0\n assert candidate(text = \"the quick brown fox jumps over the lazy dog\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"let us escape from this困境\",brokenLetters = \"et\") == 2\n assert candidate(text = \"broken keyboards are annoying sometimes\",brokenLetters = \"bks\") == 2\n assert candidate(text = \"various combinations\",brokenLetters = \"vbc\") == 0\n assert candidate(text = \"every good boy does fine and gets chocolate\",brokenLetters = \"xyz\") == 6\n assert candidate(text = \"hello world from mars\",brokenLetters = \"mr\") == 1\n assert candidate(text = \"various punctuations are missing\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"quick brown fox jumps over the lazy dog\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"unique words in this sentence\",brokenLetters = \"uie\") == 1\n assert candidate(text = \"multiple words with repeated letters\",brokenLetters = \"r\") == 2\n assert candidate(text = \"one two three four five\",brokenLetters = \"one\") == 0\n assert candidate(text = \"computer science\",brokenLetters = \"xyz\") == 2\n assert candidate(text = \"this is a simple test case\",brokenLetters = \"s\") == 1\n assert candidate(text = \"multiple spaces between words are not allowed\",brokenLetters = \"\") == 7\n assert candidate(text = \"special characters !@#$%^&*()\",brokenLetters = \"s\") == 1\n assert candidate(text = \"banana apple orange\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"abcdefghijklmnopqrstuvwxyz\",brokenLetters = \"nopqrstuvwxyz\") == 0\n assert candidate(text = \"abcdef ghijklm nopqrstuvwxyz\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"spaceship traveling fast\",brokenLetters = \"spfc\") == 1\n assert candidate(text = \"unique characters only\",brokenLetters = \"uqnc\") == 0\n assert candidate(text = \"every good boy does fine\",brokenLetters = \"egbf\") == 0\n assert candidate(text = \"repeated repeated words words\",brokenLetters = \"dpw\") == 0\n assert candidate(text = \"abcdefghijklmnopqrstuvwxy z\",brokenLetters = \"z\") == 1\n assert candidate(text = \"complex problems require careful thought\",brokenLetters = \"th\") == 4\n assert candidate(text = \"all words can be typed\",brokenLetters = \"\") == 5\n assert candidate(text = \"abcdefg hijklm nopqrstuvwxyz\",brokenLetters = \"xyz\") == 2\n", "comparison": "exact"}, "public_tests": ["\"hello world\"\n\"ad\"", "\"leet code\"\n\"lt\"", "\"leet code\"\n\"e\""], "hints": ["Check each word separately if it can be typed.", "A word can be typed if all its letters are not broken."], "metadata": {"canonical_parameter_names": ["text", "brokenLetters"], "leetcode_dataset_entry_point": "Solution().canBeTypedWords", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:32+00:00", "tests_total": 135, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def canBeTypedWords(self, text: str, brokenLetters: str) -> int:", "container": "Solution", "callable": "canBeTypedWords", "parameters": [{"name": "text", "type": "str"}, {"name": "brokenLetters", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1936, "task_id": "add-minimum-number-of-rungs", "difficulty": "Medium", "problem_description": "You are given a strictly increasing integer array rungs that represents the height of rungs on a ladder. You are currently on the floor at height 0, and you want to reach the last rung.\n\nYou are also given an integer dist. You can only climb to the next highest rung if the distance between where you are currently at (the floor or on a rung) and the next rung is at most dist. You are able to insert rungs at any positive integer height if a rung is not already there.\n\nReturn the minimum number of rungs that must be added to the ladder in order for you to climb to the last rung.\n\nExample 1:\n\nInput: rungs = [1,3,5,10], dist = 2\nOutput: 2\nExplanation:\nYou currently cannot reach the last rung.\nAdd rungs at heights 7 and 8 to climb this ladder.\nThe ladder will now have rungs at [1,3,5,7,8,10].\n\nExample 2:\n\nInput: rungs = [3,6,8,10], dist = 3\nOutput: 0\nExplanation:\nThis ladder can be climbed without adding additional rungs.\n\nExample 3:\n\nInput: rungs = [3,4,6,7], dist = 2\nOutput: 1\nExplanation:\nYou currently cannot reach the first rung from the ground.\nAdd a rung at height 1 to climb this ladder.\nThe ladder will now have rungs at [1,3,4,6,7].\n\nConstraints:\n\n- 1 <= rungs.length <= 10^5\n- 1 <= rungs[i] <= 10^9\n- 1 <= dist <= 10^9\n- rungs is strictly increasing.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rungs = [1, 3, 5, 10],dist = 2) == 2\n assert candidate(rungs = [1, 2, 3, 4, 5],dist = 1) == 0\n assert candidate(rungs = [3, 6, 8, 10],dist = 3) == 0\n assert candidate(rungs = [10],dist = 10) == 0\n assert candidate(rungs = [1000000000],dist = 1) == 999999999\n assert candidate(rungs = [1, 1000000000],dist = 1) == 999999998\n assert candidate(rungs = [1, 5, 11, 20],dist = 4) == 3\n assert candidate(rungs = [3, 4, 6, 7],dist = 2) == 1\n assert candidate(rungs = [5],dist = 10) == 0\n assert candidate(rungs = [1, 5, 10, 16, 23, 31, 40, 50, 61, 73, 86, 100],dist = 14) == 0\n assert candidate(rungs = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 1) == 89\n assert candidate(rungs = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],dist = 10) == 0\n assert candidate(rungs = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],dist = 2) == 502\n assert candidate(rungs = [2, 8, 16, 32, 64, 128],dist = 15) == 7\n assert candidate(rungs = [100, 200, 300, 400, 500],dist = 150) == 0\n assert candidate(rungs = [2, 5, 10, 20, 35, 55, 80, 110, 145, 185, 230],dist = 5) == 36\n assert candidate(rungs = [1, 8, 15, 22, 29],dist = 5) == 4\n assert candidate(rungs = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],dist = 10) == 0\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],dist = 15) == 0\n assert candidate(rungs = [5, 10, 20, 40, 80, 160],dist = 10) == 11\n assert candidate(rungs = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],dist = 3) == 24\n assert candidate(rungs = [1, 7, 15, 30, 60],dist = 10) == 3\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],dist = 1) == 502\n assert candidate(rungs = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],dist = 20) == 47\n assert candidate(rungs = [10, 25, 45, 70, 100, 130, 160, 190, 220, 250],dist = 30) == 0\n assert candidate(rungs = [1, 6, 15, 30, 50],dist = 10) == 2\n assert candidate(rungs = [1, 1000000000],dist = 100000000) == 9\n assert candidate(rungs = [100, 200, 300, 400, 500],dist = 99) == 5\n assert candidate(rungs = [1, 8, 15, 22, 30],dist = 5) == 4\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 9) == 10\n assert candidate(rungs = [10, 15, 25, 40, 50],dist = 10) == 1\n assert candidate(rungs = [2, 5, 11, 21, 35, 50],dist = 5) == 6\n assert candidate(rungs = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59],dist = 6) == 0\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 1) == 90\n assert candidate(rungs = [1, 1000000000],dist = 100000000) == 9\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],dist = 14) == 0\n assert candidate(rungs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],dist = 1) == 0\n assert candidate(rungs = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],dist = 50) == 0\n assert candidate(rungs = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 100],dist = 10) == 0\n assert candidate(rungs = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190],dist = 20) == 0\n assert candidate(rungs = [10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],dist = 10) == 4\n assert candidate(rungs = [5, 10, 20, 40, 80, 160],dist = 25) == 4\n assert candidate(rungs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],dist = 1) == 10\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120],dist = 4) == 21\n assert candidate(rungs = [1, 4, 10, 20, 30],dist = 5) == 3\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],dist = 10) == 98\n assert candidate(rungs = [5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000],dist = 100000) == 6\n assert candidate(rungs = [3, 15, 25, 30, 45, 60, 85, 100],dist = 12) == 5\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28],dist = 3) == 5\n assert candidate(rungs = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],dist = 100) == 8\n assert candidate(rungs = [2, 6, 10, 14, 18, 22, 26],dist = 4) == 0\n assert candidate(rungs = [100, 200, 300, 400, 500],dist = 90) == 5\n assert candidate(rungs = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],dist = 100000) == 9995\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],dist = 1024) == 1013\n assert candidate(rungs = [5, 11, 19, 29, 41, 55, 71, 89, 109, 131],dist = 6) == 15\n assert candidate(rungs = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 9) == 9\n assert candidate(rungs = [2, 8, 14, 20, 26, 32, 38, 44, 50],dist = 6) == 0\n assert candidate(rungs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],dist = 3) == 0\n assert candidate(rungs = [1, 2, 4, 7, 13, 21],dist = 3) == 3\n assert candidate(rungs = [1000000000],dist = 500000000) == 1\n assert candidate(rungs = [1, 5, 15, 30, 50, 70, 100, 150, 200, 300],dist = 25) == 6\n assert candidate(rungs = [2, 8, 14, 22, 30, 40, 50],dist = 6) == 4\n assert candidate(rungs = [1, 1000000000],dist = 1) == 999999998\n assert candidate(rungs = [1, 100, 200, 300],dist = 50) == 3\n assert candidate(rungs = [3, 15, 35, 65, 100, 145, 195, 250, 310, 375],dist = 10) == 31\n assert candidate(rungs = [10, 25, 45, 60, 75, 90],dist = 15) == 1\n assert candidate(rungs = [10, 25, 45, 70, 100],dist = 15) == 3\n assert candidate(rungs = [1, 1000000000],dist = 500000000) == 1\n assert candidate(rungs = [5, 12, 24, 40, 60, 85, 100],dist = 10) == 6\n assert candidate(rungs = [1, 1000000000],dist = 1000000) == 999\n assert candidate(rungs = [2, 5, 9, 14, 20, 27, 35, 44, 54, 65],dist = 4) == 10\n assert candidate(rungs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],dist = 2) == 0\n assert candidate(rungs = [1, 9, 15, 25, 30],dist = 5) == 3\n assert candidate(rungs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],dist = 9) == 0\n assert candidate(rungs = [2, 8, 18, 32, 50, 72, 98],dist = 15) == 3\n assert candidate(rungs = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120],dist = 500) == 8\n assert candidate(rungs = [5, 10, 20, 40, 80, 160],dist = 10) == 11\n assert candidate(rungs = [1, 6, 11, 16, 21, 26],dist = 5) == 0\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 10) == 0\n assert candidate(rungs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],dist = 2) == 0\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],dist = 5) == 5\n assert candidate(rungs = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],dist = 1000000) == 996\n assert candidate(rungs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],dist = 3) == 0\n assert candidate(rungs = [1000000000],dist = 100000000) == 9\n assert candidate(rungs = [1, 1000000000],dist = 500000000) == 1\n assert candidate(rungs = [10, 1000000000],dist = 500000000) == 1\n assert candidate(rungs = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 9) == 9\n assert candidate(rungs = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56, 67, 79, 92, 106],dist = 5) == 13\n assert candidate(rungs = [2, 3, 6, 8, 15, 22, 30, 35, 40, 50],dist = 5) == 4\n assert candidate(rungs = [3, 9, 12, 21, 23, 29, 30],dist = 6) == 1\n assert candidate(rungs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],dist = 2) == 0\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],dist = 3) == 12\n assert candidate(rungs = [1, 10, 15, 20, 25, 30],dist = 5) == 1\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],dist = 15) == 0\n assert candidate(rungs = [5, 12, 22, 35, 50, 68, 89, 113, 141, 173, 209],dist = 7) == 23\n assert candidate(rungs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],dist = 1) == 0\n assert candidate(rungs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],dist = 1) == 10\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64],dist = 15) == 3\n assert candidate(rungs = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],dist = 2) == 38\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 9) == 10\n assert candidate(rungs = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],dist = 1000000) == 996\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],dist = 100) == 8\n", "comparison": "exact"}, "public_tests": ["[1,3,5,10]\n2", "[3,6,8,10]\n3", "[3,4,6,7]\n2"], "hints": ["Go as far as you can on the available rungs before adding new rungs.", "If you have to add a new rung, add it as high up as possible.", "Try using division to decrease the number of computations."], "metadata": {"canonical_parameter_names": ["rungs", "dist"], "leetcode_dataset_entry_point": "Solution().addRungs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:34+00:00", "tests_total": 102, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def addRungs(self, rungs: list[int], dist: int) -> int:", "container": "Solution", "callable": "addRungs", "parameters": [{"name": "rungs", "type": "list[int]"}, {"name": "dist", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1937, "task_id": "maximum-number-of-points-with-cost", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix points (0-indexed). Starting with 0 points, you want to maximize the number of points you can get from the matrix.\n\nTo gain points, you must pick one cell in each row. Picking the cell at coordinates (r, c) will add points[r][c] to your score.\n\nHowever, you will lose points if you pick a cell too far from the cell that you picked in the previous row. For every two adjacent rows r and r + 1 (where 0 <= r < m - 1), picking cells at coordinates (r, c_1) and (r + 1, c_2) will subtract abs(c_1 - c_2) from your score.\n\nReturn the maximum number of points you can achieve.\n\nabs(x) is defined as:\n\n- x for x >= 0.\n- -x for x < 0.\n\nExample 1:\n\nInput: points = [[1,2,3],[1,5,1],[3,1,1]]\nOutput: 9\nExplanation:\nThe blue cells denote the optimal cells to pick, which have coordinates (0, 2), (1, 1), and (2, 0).\nYou add 3 + 5 + 3 = 11 to your score.\nHowever, you must subtract abs(2 - 1) + abs(1 - 0) = 2 from your score.\nYour final score is 11 - 2 = 9.\n\nExample 2:\n\nInput: points = [[1,5],[2,3],[4,2]]\nOutput: 11\nExplanation:\nThe blue cells denote the optimal cells to pick, which have coordinates (0, 1), (1, 1), and (2, 0).\nYou add 5 + 3 + 4 = 12 to your score.\nHowever, you must subtract abs(1 - 1) + abs(1 - 0) = 1 from your score.\nYour final score is 12 - 1 = 11.\n\nConstraints:\n\n- m == points.length\n- n == points[r].length\n- 1 <= m, n <= 10^5\n- 1 <= m * n <= 10^5\n- 0 <= points[r][c] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[5, 10], [10, 5]]) == 19\n assert candidate(points = [[5, 2], [1, 2]]) == 6\n assert candidate(points = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9]]) == 15\n assert candidate(points = [[1, 2, 3], [1, 5, 1], [3, 1, 1]]) == 9\n assert candidate(points = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == 6\n assert candidate(points = [[1, 5], [2, 3], [4, 2]]) == 11\n assert candidate(points = [[1]]) == 1\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 15\n assert candidate(points = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == 25\n assert candidate(points = [[5, 3, 8, 6, 7, 2], [9, 4, 1, 5, 3, 8], [2, 6, 4, 9, 1, 5], [7, 3, 5, 2, 8, 6]]) == 28\n assert candidate(points = [[1, 3, 2], [4, 6, 5], [7, 9, 8], [10, 12, 11], [13, 15, 14]]) == 45\n assert candidate(points = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]]) == 15\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 2, 4, 6, 8, 10], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 121\n assert candidate(points = [[9, 5, 3, 1, 7], [2, 8, 6, 4, 0], [5, 1, 9, 3, 6], [4, 7, 2, 8, 5], [3, 6, 4, 1, 9]]) == 39\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]]) == 21\n assert candidate(points = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 28\n assert candidate(points = [[5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 20\n assert candidate(points = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 40\n assert candidate(points = [[5, 10, 15, 20, 25], [25, 20, 15, 10, 5], [5, 5, 5, 5, 5], [10, 15, 20, 25, 30], [30, 25, 20, 15, 10]]) == 103\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 12\n assert candidate(points = [[10, 20, 30, 40, 50, 60, 70], [70, 60, 50, 40, 30, 20, 10], [10, 70, 20, 60, 30, 50, 40]]) == 203\n assert candidate(points = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 40\n assert candidate(points = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(points = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1]]) == 106\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 4, 6, 8, 10, 9, 7, 5, 3, 1]]) == 21\n assert candidate(points = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]]) == 51\n assert candidate(points = [[5, 3, 1, 4], [3, 1, 4, 5], [1, 4, 5, 3], [4, 5, 3, 1]]) == 17\n assert candidate(points = [[5, 3, 8, 6], [2, 4, 7, 1], [3, 6, 9, 2], [8, 5, 2, 4]]) == 30\n assert candidate(points = [[9, 1, 5, 3, 7], [3, 9, 1, 5, 3], [7, 3, 9, 1, 5], [5, 7, 3, 9, 1], [1, 5, 7, 3, 9]]) == 41\n assert candidate(points = [[5, 2, 3, 1, 4], [1, 3, 2, 5, 4], [3, 4, 5, 2, 1], [4, 1, 2, 3, 5], [2, 5, 4, 1, 3]]) == 18\n assert candidate(points = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]]) == 15\n assert candidate(points = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]) == 180\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]]) == 45\n assert candidate(points = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(points = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 5\n assert candidate(points = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]]) == 50\n assert candidate(points = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 6, 2, 5, 3, 4]]) == 13\n assert candidate(points = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [9, 8, 7, 6, 5]]) == 27\n assert candidate(points = [[50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50]]) == 250\n assert candidate(points = [[100000, 100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000, 100000]]) == 300000\n assert candidate(points = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 1, 9, 1, 9, 1, 9, 1, 9], [1, 9, 1, 9, 1, 9, 1, 9, 1]]) == 27\n assert candidate(points = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 100], [100, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 100, 0], [0, 0, 0, 0, 0, 0, 0, 100, 0, 0], [0, 0, 0, 0, 0, 0, 100, 0, 0, 0]]) == 481\n assert candidate(points = [[100, 200, 300, 400, 500], [90, 80, 70, 60, 50], [10, 20, 30, 40, 50], [5, 15, 25, 35, 45]]) == 677\n assert candidate(points = [[1, 10, 2, 9, 3, 8, 4, 7, 5, 6], [10, 1, 9, 2, 8, 3, 7, 4, 6, 5], [5, 6, 4, 7, 3, 8, 2, 9, 1, 10]]) == 24\n assert candidate(points = [[10, 10, 10, 10, 10], [1, 1, 1, 1, 1], [9, 9, 9, 9, 9], [2, 2, 2, 2, 2]]) == 22\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 30\n assert candidate(points = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]]) == 12\n assert candidate(points = [[10, 6, 3, 9, 7], [1, 4, 5, 8, 2], [9, 7, 4, 3, 6], [2, 8, 1, 5, 9]]) == 31\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 110\n assert candidate(points = [[100, 100, 100], [100, 100, 100], [100, 100, 100], [100, 100, 100], [100, 100, 100]]) == 500\n assert candidate(points = [[5, 3, 8, 6, 2, 9], [1, 7, 4, 8, 5, 3], [6, 2, 9, 4, 8, 1], [3, 6, 5, 7, 2, 8]]) == 29\n assert candidate(points = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 50, 10, 50, 10], [50, 10, 50, 10, 50], [10, 20, 30, 40, 50]]) == 242\n assert candidate(points = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 4\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13]]) == 22\n assert candidate(points = [[1, 1, 1, 1, 1], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == 7\n assert candidate(points = [[100000, 90000, 80000, 70000, 60000], [50000, 40000, 30000, 20000, 10000], [90000, 80000, 70000, 60000, 50000], [40000, 30000, 20000, 10000, 9000]]) == 280000\n assert candidate(points = [[90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [99, 98, 97, 96, 95, 94, 93, 92, 91, 90], [90, 92, 94, 96, 98, 100, 98, 96, 94, 92]]) == 289\n assert candidate(points = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 20, 30, 40, 50, 60, 70, 80, 90], [90, 80, 70, 60, 50, 40, 30, 20, 10]]) == 182\n assert candidate(points = [[1000, 500, 250, 125], [125, 250, 500, 1000], [1000, 500, 250, 125], [125, 250, 500, 1000]]) == 3991\n assert candidate(points = [[5, 3, 1, 4, 2], [8, 6, 7, 5, 3], [0, 9, 8, 7, 6], [2, 3, 4, 5, 1]]) == 24\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 42\n assert candidate(points = [[50, 50, 50, 50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]]) == 150\n assert candidate(points = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 45\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 112\n assert candidate(points = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]]) == 41\n assert candidate(points = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 30, 50, 70, 90], [90, 70, 50, 30, 10]]) == 268\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]]) == 10\n assert candidate(points = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 1\n assert candidate(points = [[5, 3, 8, 2, 1], [1, 4, 2, 3, 8], [8, 1, 4, 2, 3], [3, 8, 1, 4, 2]]) == 25\n assert candidate(points = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [1, 2, 3, 4, 5], [9, 8, 7, 6, 5]]) == 106\n assert candidate(points = [[100000, 100000, 100000], [100000, 100000, 100000], [100000, 100000, 100000]]) == 300000\n assert candidate(points = [[100, 200], [150, 250], [200, 150], [250, 100], [300, 50]]) == 1199\n assert candidate(points = [[100, 90, 80, 70, 60, 50, 40, 30, 20, 10], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 201\n assert candidate(points = [[5, 3, 1], [1, 5, 3], [3, 1, 5], [5, 3, 1], [1, 5, 3]]) == 20\n assert candidate(points = [[10, 3, 5, 1, 2], [4, 6, 7, 3, 8], [2, 9, 1, 4, 6], [5, 3, 7, 9, 1], [8, 2, 6, 4, 5]]) == 36\n assert candidate(points = [[10, 1, 3, 5, 20], [5, 10, 15, 20, 25], [25, 20, 15, 10, 5]]) == 66\n assert candidate(points = [[1, 3, 1, 5, 1, 3, 1], [3, 1, 3, 1, 3, 1, 3], [1, 5, 1, 5, 1, 5, 1], [5, 1, 5, 1, 5, 1, 5]]) == 15\n assert candidate(points = [[100, 200, 300], [300, 200, 100], [200, 300, 200], [100, 100, 100]]) == 997\n assert candidate(points = [[100, 90, 80, 70, 60], [60, 70, 80, 90, 100], [100, 100, 100, 100, 100], [1, 2, 3, 4, 5]]) == 301\n assert candidate(points = [[7, 6, 8, 5, 9, 10], [10, 9, 8, 7, 6, 5], [5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6]]) == 31\n assert candidate(points = [[10, 15, 20, 25, 30], [5, 10, 15, 20, 25], [30, 25, 20, 15, 10], [1, 2, 3, 4, 5]]) == 82\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 32\n assert candidate(points = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 11\n assert candidate(points = [[10, 20, 30], [30, 20, 10], [20, 30, 10], [10, 20, 30], [30, 10, 20]]) == 144\n assert candidate(points = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]]) == 45\n assert candidate(points = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(points = [[10, 15, 20, 25], [25, 20, 15, 10], [10, 20, 30, 40], [40, 30, 20, 10]]) == 121\n assert candidate(points = [[7, 8, 9, 10, 11], [11, 10, 9, 8, 7], [7, 9, 11, 10, 8], [8, 10, 7, 9, 11]]) == 38\n assert candidate(points = [[5, 1, 3, 2, 4], [2, 6, 1, 4, 5], [3, 3, 5, 1, 2], [1, 2, 4, 6, 3]]) == 19\n", "comparison": "exact"}, "public_tests": ["[[1,2,3],[1,5,1],[3,1,1]]", "[[1,5],[2,3],[4,2]]"], "hints": ["Try using dynamic programming.", "dp[i][j] is the maximum number of points you can have if points[i][j] is the most recent cell you picked."], "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().maxPoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:37+00:00", "tests_total": 91, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "matrix"]}, "language": "python", "interface": {"raw_signature": "def maxPoints(self, points: list[list[int]]) -> int:", "container": "Solution", "callable": "maxPoints", "parameters": [{"name": "points", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1938, "task_id": "maximum-genetic-difference-query", "difficulty": "Hard", "problem_description": "There is a rooted tree consisting of n nodes numbered 0 to n - 1. Each node's number denotes its unique genetic value (i.e. the genetic value of node x is x). The genetic difference between two genetic values is defined as the bitwise-XOR of their values. You are given the integer array parents, where parents[i] is the parent for node i. If node x is the root of the tree, then parents[x] == -1.\n\nYou are also given the array queries where queries[i] = [node_i, val_i]. For each query i, find the maximum genetic difference between val_i and p_i, where p_i is the genetic value of any node that is on the path between node_i and the root (including node_i and the root). More formally, you want to maximize val_i XOR p_i.\n\nReturn an array ans where ans[i] is the answer to the i^th query.\n\nExample 1:\n\nInput: parents = [-1,0,1,1], queries = [[0,2],[3,2],[2,5]]\nOutput: [2,3,7]\nExplanation: The queries are processed as follows:\n- [0,2]: The node with the maximum genetic difference is 0, with a difference of 2 XOR 0 = 2.\n- [3,2]: The node with the maximum genetic difference is 1, with a difference of 2 XOR 1 = 3.\n- [2,5]: The node with the maximum genetic difference is 2, with a difference of 5 XOR 2 = 7.\n\nExample 2:\n\nInput: parents = [3,7,-1,2,0,7,0,2], queries = [[4,6],[1,15],[0,5]]\nOutput: [6,14,7]\nExplanation: The queries are processed as follows:\n- [4,6]: The node with the maximum genetic difference is 0, with a difference of 6 XOR 0 = 6.\n- [1,15]: The node with the maximum genetic difference is 1, with a difference of 15 XOR 1 = 14.\n- [0,5]: The node with the maximum genetic difference is 2, with a difference of 5 XOR 2 = 7.\n\nConstraints:\n\n- 2 <= parents.length <= 10^5\n- 0 <= parents[i] <= parents.length - 1 for every node i that is not the root.\n- parents[root] == -1\n- 1 <= queries.length <= 3 * 10^4\n- 0 <= node_i <= parents.length - 1\n- 0 <= val_i <= 2 * 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(parents = [-1, 0, 0, 1, 1],queries = [[0, 3], [2, 1], [3, 4], [4, 5]]) == [3, 3, 7, 5]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3],queries = [[4, 5], [7, 10], [2, 15]]) == [5, 13, 15]\n assert candidate(parents = [3, 7, -1, 2, 0, 7, 0, 2],queries = [[4, 6], [1, 15], [0, 5]]) == [6, 14, 7]\n assert candidate(parents = [0, 0, 0, 1, 1, 2, 2, 3, 3],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70]]) == [10, 21, 30, 43, 54, 62, 70]\n assert candidate(parents = [-1, 0, 0, 1, 1],queries = [[2, 3], [4, 4], [3, 5]]) == [3, 5, 6]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7],queries = [[8, 1], [7, 2], [6, 3], [5, 4], [4, 5], [3, 6], [2, 7], [1, 8], [0, 9]]) == [9, 7, 7, 7, 7, 7, 7, 9, 9]\n assert candidate(parents = [-1, 0, 1, 1, 3, 3],queries = [[0, 10], [5, 15], [3, 20]]) == [10, 15, 23]\n assert candidate(parents = [-1, 0, 0, 1, 1],queries = [[0, 3], [1, 2], [2, 1], [3, 4], [4, 5]]) == [3, 3, 3, 7, 5]\n assert candidate(parents = [-1, 0, 1, 1],queries = [[0, 2], [3, 2], [2, 5]]) == [2, 3, 7]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == [1, 3, 3, 7, 7, 7, 7]\n assert candidate(parents = [-1, 0, 0, 1],queries = [[0, 3], [2, 5], [3, 4]]) == [3, 7, 7]\n assert candidate(parents = [-1, 0, 1, 2, 3],queries = [[4, 1], [1, 2], [2, 3], [3, 4]]) == [5, 3, 3, 7]\n assert candidate(parents = [3, 3, -1, 0, 0],queries = [[4, 100000], [3, 100001], [2, 100002], [1, 100003], [0, 100004]]) == [0, 0, 100000, 0, 0]\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9],queries = [[0, 25], [1, 50], [2, 75], [3, 100], [4, 125], [5, 150], [6, 175], [7, 200], [8, 225], [9, 250], [10, 275], [11, 300], [12, 325], [13, 350], [14, 375], [15, 400], [16, 425], [17, 450], [18, 475], [19, 500], [20, 525], [21, 550], [22, 575], [23, 600], [24, 625], [25, 650], [26, 675], [27, 700]]) == [25, 51, 75, 103, 125, 151, 175, 207, 233, 251, 281, 301, 329, 351, 377, 415, 441, 467, 477, 502, 537, 563, 575, 603, 633, 659, 697, 703]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39]]) == [1, 3, 3, 7, 5, 6, 7, 15, 10, 14, 15, 14, 15, 14, 15, 31, 22, 26, 27, 29, 28, 28, 29, 29, 28, 31, 30, 30, 31, 30, 31, 63, 46, 50, 51, 53, 52, 52, 53]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100], [10, 110], [11, 120], [12, 130], [13, 140], [14, 150], [15, 160], [16, 170], [17, 180], [18, 190], [19, 200], [20, 210], [21, 220], [22, 230], [23, 240], [24, 250], [25, 260], [26, 270], [27, 280], [28, 290], [29, 300]]) == [10, 21, 30, 43, 54, 61, 71, 87, 90, 109, 110, 123, 142, 141, 152, 175, 186, 181, 191, 219, 212, 221, 240, 247, 253, 285, 276, 282, 318, 305]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19],queries = [[0, 100000], [1, 50000], [2, 25000], [3, 12500], [4, 6250], [5, 3125], [6, 1562], [7, 781], [8, 390], [9, 195], [10, 97], [11, 48], [12, 24], [13, 12], [14, 6], [15, 3], [16, 1], [17, 0], [18, 0], [19, 0], [0, 100000]]) == [100000, 50001, 25002, 12503, 6254, 3127, 1564, 782, 398, 202, 107, 59, 29, 14, 8, 12, 17, 17, 18, 19, 100000]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24],queries = [[0, 10101], [1, 10102], [2, 10103], [3, 10104], [4, 10105], [5, 10106], [6, 10107], [7, 10108], [8, 10109], [9, 10110], [10, 10111], [11, 10112], [12, 10113], [13, 10114], [14, 10115], [15, 10116], [16, 10117], [17, 10118], [18, 10119], [19, 10120], [20, 10121], [21, 10122], [22, 10123], [23, 10124], [24, 10125], [25, 10126], [26, 10127], [27, 10128], [28, 10129], [29, 10130], [30, 10131], [31, 10132], [32, 10133], [33, 10134], [34, 10135], [35, 10136], [36, 10137], [37, 10138], [38, 10139], [39, 10140]]) == [10101, 10103, 10103, 10107, 10109, 10111, 10109, 10111, 10110, 10111, 10111, 10123, 10125, 10127, 10125, 10123, 10133, 10135, 10133, 10139, 10141, 10143, 10141, 10139, 10133, 10135, 10133, 10141, 10140, 10140, 10141, 10139, 10165, 10167, 10165, 10171, 10173, 10175, 10173, 10171]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39],queries = [[39, 1], [38, 2], [37, 3], [36, 4], [35, 5], [34, 6], [33, 7], [32, 8], [31, 9], [30, 10], [29, 11], [28, 12], [27, 13], [26, 14], [25, 15], [24, 16], [23, 17], [22, 18], [21, 19], [20, 20], [19, 21], [18, 22], [17, 23], [16, 24], [15, 25], [14, 26], [13, 27], [12, 28], [11, 29], [10, 30], [9, 31], [8, 32], [7, 33], [6, 34], [5, 35], [4, 36], [3, 37], [2, 38], [1, 39], [0, 40]]) == [38, 36, 38, 32, 38, 36, 38, 40, 22, 20, 22, 16, 22, 20, 22, 27, 26, 24, 25, 29, 28, 30, 31, 31, 30, 28, 29, 30, 31, 31, 31, 40, 38, 36, 38, 37, 38, 38, 39, 40]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],queries = [[0, 1], [1, 3], [2, 7], [3, 15], [4, 31], [5, 63], [6, 127], [7, 255], [8, 511], [9, 1023], [10, 2047], [11, 4095], [12, 8191], [13, 16383], [14, 32767], [15, 65535]]) == [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]\n assert candidate(parents = [-1, 0, 0, 1, 1, 3, 3, 4, 4, 5, 5],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100]]) == [100, 201, 302, 403, 501, 605, 703, 807, 908, 1005, 1103]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29],queries = [[0, 5000], [1, 5001], [2, 5002], [3, 5003], [4, 5004], [5, 5005], [6, 5006], [7, 5007], [8, 5008], [9, 5009], [10, 5010], [11, 5011], [12, 5012], [13, 5013], [14, 5014], [15, 5015], [16, 5016], [17, 5017], [18, 5018], [19, 5019], [20, 5020], [21, 5021], [22, 5022], [23, 5023], [24, 5024], [25, 5025], [26, 5026], [27, 5027], [28, 5028], [29, 5029], [30, 5030], [31, 5031], [32, 5032], [33, 5033], [34, 5034], [35, 5035], [36, 5036], [37, 5037], [38, 5038], [39, 5039]]) == [5000, 5001, 5002, 5003, 5005, 5007, 5006, 5007, 5016, 5016, 5016, 5016, 5016, 5016, 5016, 5016, 5023, 5018, 5019, 5023, 5021, 5021, 5023, 5023, 5048, 5048, 5048, 5048, 5048, 5048, 5048, 5048, 5039, 5049, 5050, 5050, 5053, 5055, 5052, 5052]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],queries = [[0, 1000], [1, 2000], [2, 3000], [3, 4000], [4, 5000], [5, 6000], [6, 7000], [7, 8000], [8, 9000], [9, 10000], [10, 11000], [11, 12000], [12, 13000], [13, 14000], [14, 15000], [15, 16000], [16, 17000], [17, 18000], [18, 19000], [19, 20000], [20, 21000], [21, 22000], [22, 23000], [23, 24000], [24, 25000], [25, 26000], [26, 27000], [27, 28000], [28, 29000], [29, 30000], [30, 31000], [31, 32000]]) == [1000, 2001, 3002, 4003, 5004, 6005, 7006, 8007, 9003, 10009, 11004, 12011, 13005, 14013, 15006, 16015, 17016, 18008, 19003, 20019, 21020, 22010, 23004, 24023, 25008, 26012, 27005, 28027, 29012, 30014, 31006, 32031]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4],queries = [[0, 123], [1, 456], [2, 789], [3, 101], [4, 202], [5, 303], [6, 404], [7, 505], [8, 606], [9, 707], [10, 808], [11, 909]]) == [123, 457, 791, 102, 206, 303, 406, 510, 606, 714, 812, 909]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800]]) == [100, 201, 302, 403, 501, 605, 702, 807, 908, 1003, 1101, 1211, 1304, 1405, 1502, 1615, 1716, 1817]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],queries = [[0, 500], [1, 1000], [2, 1500], [3, 2000], [4, 2500], [5, 3000], [6, 3500], [7, 4000], [8, 4500], [9, 5000], [10, 5500], [11, 6000], [12, 6500], [13, 7000], [14, 7500], [15, 8000], [16, 8500], [17, 9000], [18, 9500], [19, 10000], [20, 10500], [21, 11000], [22, 11500], [23, 12000], [24, 12500], [25, 13000], [26, 13500], [27, 14000], [28, 14500], [29, 15000]]) == [500, 1001, 1502, 2003, 2501, 3005, 3502, 4007, 4508, 5004, 5501, 6011, 6504, 7006, 7502, 8015, 8503, 9017, 9503, 10009, 10512, 11004, 11514, 12023, 12511, 13009, 13502, 14013, 14520, 15006]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800], [18, 1900]]) == [100, 201, 302, 403, 503, 605, 703, 807, 908, 1007, 1103, 1211, 1311, 1407, 1503, 1615, 1716, 1817, 1918]\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == [1, 3, 3, 7, 5, 7, 7, 15, 11, 11, 11, 15, 13, 15, 15, 31, 20, 23, 21, 22]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800], [18, 1900], [19, 2000], [20, 2100], [21, 2200]]) == [100, 201, 302, 403, 501, 605, 702, 807, 908, 1003, 1101, 1211, 1304, 1405, 1502, 1615, 1716, 1817, 1918, 2008, 2109, 2203]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100], [10, 110], [11, 120], [12, 130], [13, 140], [14, 150], [15, 160], [16, 170], [17, 180], [18, 190], [19, 200], [20, 210], [21, 220], [22, 230], [23, 240], [24, 250], [25, 260], [26, 270], [27, 280], [28, 290], [29, 300]]) == [10, 21, 30, 43, 54, 62, 70, 87, 91, 109, 111, 125, 142, 142, 152, 175, 186, 188, 191, 219, 219, 221, 240, 251, 255, 285, 276, 286, 318, 305]\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800], [18, 1900], [19, 2000], [20, 2100], [21, 2200], [22, 2300], [23, 2400], [24, 2500], [25, 2600], [26, 2700], [27, 2800], [28, 2900], [29, 3000], [30, 3100], [31, 3200], [32, 3300], [33, 3400], [34, 3500], [35, 3600], [36, 3700], [37, 3800], [38, 3900], [39, 4000]]) == [100, 201, 302, 403, 500, 605, 701, 807, 908, 1002, 1102, 1211, 1304, 1403, 1503, 1615, 1716, 1817, 1918, 2004, 2100, 2205, 2301, 2423, 2524, 2609, 2710, 2806, 2901, 3007, 3101, 3231, 3301, 3433, 3501, 3635, 3708, 3837, 3902, 4009]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600]]) == [100, 201, 302, 403, 502, 605, 703, 807, 908, 1004, 1102, 1211, 1304, 1406, 1503, 1615]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],queries = [[0, 101], [1, 102], [2, 103], [3, 104], [4, 105], [5, 106], [6, 107], [7, 108], [8, 109], [9, 110], [10, 111], [11, 112], [12, 113], [13, 114], [14, 115], [15, 116], [16, 117], [17, 118], [18, 119], [19, 120]]) == [101, 103, 103, 107, 109, 111, 109, 111, 111, 111, 111, 123, 125, 127, 125, 123, 125, 126, 126, 124]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29],queries = [[0, 1000], [1, 2000], [2, 3000], [3, 4000], [4, 5000], [5, 6000], [6, 7000], [7, 8000], [8, 9000], [9, 10000], [10, 11000], [11, 12000], [12, 13000], [13, 14000], [14, 15000], [15, 16000], [16, 17000], [17, 18000], [18, 19000], [19, 20000], [20, 21000], [21, 22000], [22, 23000], [23, 24000], [24, 25000], [25, 26000], [26, 27000], [27, 28000], [28, 29000], [29, 30000], [30, 31000], [31, 32000], [32, 33000], [33, 34000], [34, 35000], [35, 36000], [36, 37000], [37, 38000], [38, 39000], [39, 40000], [40, 41000], [41, 42000], [42, 43000], [43, 44000], [44, 45000], [45, 46000], [46, 47000], [47, 48000], [48, 49000], [49, 50000], [50, 51000], [51, 52000], [52, 53000], [53, 54000], [54, 55000], [55, 56000], [56, 57000], [57, 58000], [58, 59000], [59, 60000]]) == [1000, 2001, 3002, 4003, 5004, 6005, 7006, 8007, 9002, 10009, 11003, 12011, 13003, 14013, 15004, 16015, 17016, 18005, 19005, 20019, 21020, 22006, 23007, 24023, 25008, 26008, 27002, 28027, 29012, 30009, 31002, 32031, 33003, 34033, 35003, 36011, 37036, 38012, 39038, 40039, 41004, 42041, 43004, 44014, 45028, 46014, 47030, 48047, 49004, 50017, 51005, 52016, 53052, 54005, 55022, 56055, 57018, 58025, 59006, 60019]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 1024], [1, 512], [2, 256], [3, 128], [4, 64], [5, 32], [6, 16], [7, 8], [8, 4], [9, 2], [10, 1], [11, 513], [12, 257], [13, 129], [14, 65], [15, 33]]) == [1024, 513, 258, 131, 68, 37, 22, 15, 12, 11, 11, 523, 269, 141, 79, 47]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49],queries = [[0, 3000], [1, 4000], [2, 5000], [3, 6000], [4, 7000], [5, 8000], [6, 9000], [7, 10000], [8, 11000], [9, 12000], [10, 13000], [11, 14000], [12, 15000], [13, 16000], [14, 17000], [15, 18000], [16, 19000], [17, 20000], [18, 21000], [19, 22000], [20, 23000], [21, 24000], [22, 25000], [23, 26000], [24, 27000], [25, 28000], [26, 29000], [27, 30000], [28, 31000], [29, 32000], [30, 33000], [31, 34000], [32, 35000], [33, 36000], [34, 37000], [35, 38000], [36, 39000], [37, 40000], [38, 41000], [39, 42000], [40, 43000], [41, 44000], [42, 45000], [43, 46000], [44, 47000], [45, 48000], [46, 49000], [47, 50000], [48, 51000], [49, 52000], [50, 53000], [51, 54000], [52, 55000], [53, 56000], [54, 57000], [55, 58000], [56, 59000], [57, 60000], [58, 61000], [59, 62000], [60, 63000], [61, 64000], [62, 65000], [63, 66000], [64, 67000], [65, 68000], [66, 69000], [67, 70000], [68, 71000], [69, 72000], [70, 73000], [71, 74000], [72, 75000], [73, 76000], [74, 77000], [75, 78000], [76, 79000], [77, 80000], [78, 81000], [79, 82000], [80, 83000], [81, 84000], [82, 85000], [83, 86000], [84, 87000], [85, 88000], [86, 89000], [87, 90000], [88, 91000], [89, 92000], [90, 93000], [91, 94000], [92, 95000], [93, 96000], [94, 97000], [95, 98000], [96, 99000], [97, 100000], [98, 101000], [99, 102000]]) == [3000, 4001, 5002, 6003, 7004, 8005, 9006, 10007, 11003, 12009, 13004, 14011, 15005, 16013, 17006, 18015, 19007, 20017, 21018, 22009, 23004, 24021, 25022, 26011, 27005, 28025, 29010, 30013, 31006, 32029, 33014, 34015, 35007, 36016, 37034, 38008, 39036, 40037, 41018, 42039, 43004, 44020, 45026, 46010, 47028, 48045, 49022, 50047, 51005, 52024, 53050, 54012, 55020, 56053, 57010, 58023, 59006, 60028, 61042, 62014, 63012, 64061, 65014, 66031, 67064, 68065, 69066, 70007, 71033, 72034, 73070, 74071, 75003, 76017, 77036, 78075, 79060, 80077, 81018, 82039, 83048, 84081, 85082, 86009, 87025, 88042, 89086, 90055, 91004, 92021, 93028, 94059, 95044, 96093, 97022, 98047, 99032, 100033, 101098, 102011]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800], [18, 1900], [19, 2000]]) == [100, 201, 302, 403, 501, 605, 702, 807, 908, 1004, 1101, 1211, 1304, 1406, 1502, 1615, 1716, 1817, 1918, 2009]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49],queries = [[0, 2000], [1, 3000], [2, 4000], [3, 5000], [4, 6000], [5, 7000], [6, 8000], [7, 9000], [8, 10000], [9, 11000], [10, 12000], [11, 13000], [12, 14000], [13, 15000], [14, 16000], [15, 17000], [16, 18000], [17, 19000], [18, 20000], [19, 21000], [20, 22000], [21, 23000], [22, 24000], [23, 25000], [24, 26000], [25, 27000], [26, 28000], [27, 29000], [28, 30000], [29, 31000], [30, 32000], [31, 33000], [32, 34000], [33, 35000], [34, 36000], [35, 37000], [36, 38000], [37, 39000], [38, 40000], [39, 41000], [40, 42000], [41, 43000], [42, 44000], [43, 45000], [44, 46000], [45, 47000], [46, 48000], [47, 49000], [48, 50000], [49, 51000]]) == [2000, 3001, 4002, 5003, 6004, 7005, 8006, 9007, 10008, 11007, 12010, 13007, 14012, 15007, 16014, 17007, 18015, 19007, 20018, 21019, 22015, 23007, 24022, 25023, 26015, 27007, 28026, 29023, 30015, 31007, 32030, 33023, 34032, 35007, 36031, 37035, 38015, 39037, 40038, 41023, 42040, 43007, 44031, 45039, 46015, 47039, 48046, 49023, 50047, 51007]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30],queries = [[0, 50], [1, 100], [2, 150], [3, 200], [4, 250], [5, 300], [6, 350], [7, 400], [8, 450], [9, 500], [10, 550], [11, 600], [12, 650], [13, 700], [14, 750], [15, 800], [16, 850], [17, 900], [18, 950], [19, 1000], [20, 1050], [21, 1100], [22, 1150], [23, 1200], [24, 1250], [25, 1300], [26, 1350], [27, 1400], [28, 1450], [29, 1500], [30, 1550], [31, 1600], [32, 1650], [33, 1700], [34, 1750], [35, 1800], [36, 1850], [37, 1900], [38, 1950], [39, 2000], [40, 2050], [41, 2100], [42, 2150], [43, 2200], [44, 2250], [45, 2300], [46, 2350], [47, 2400], [48, 2450], [49, 2500]]) == [50, 101, 150, 203, 254, 302, 350, 407, 458, 509, 556, 605, 655, 702, 750, 815, 853, 917, 958, 1019, 1054, 1113, 1151, 1211, 1274, 1304, 1372, 1406, 1462, 1502, 1552, 1631, 1661, 1716, 1780, 1835, 1851, 1918, 1976, 2039, 2090, 2109, 2162, 2227, 2278, 2301, 2360, 2423, 2466, 2549]\n assert candidate(parents = [-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50], [50, 51]]) == [1, 3, 3, 7, 5, 6, 7, 15, 9, 11, 11, 14, 15, 14, 15, 31, 18, 18, 19, 23, 22, 22, 23, 28, 29, 30, 30, 28, 29, 30, 31, 63, 39, 36, 37, 37, 37, 39, 39, 47, 46, 43, 43, 45, 45, 47, 47, 57, 56, 59, 58]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],queries = [[0, 1000], [1, 2000], [2, 3000], [3, 4000], [4, 5000], [5, 6000], [6, 7000], [7, 8000], [8, 9000], [9, 10000], [10, 11000], [11, 12000], [12, 13000], [13, 14000], [14, 15000]]) == [1000, 2001, 3002, 4003, 5004, 6005, 7006, 8007, 9007, 10009, 11007, 12011, 13007, 14013, 15007]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99],queries = [[0, 3000], [1, 4000], [2, 5000], [3, 6000], [4, 7000], [5, 8000], [6, 9000], [7, 10000], [8, 11000], [9, 12000], [10, 13000], [11, 14000], [12, 15000], [13, 16000], [14, 17000], [15, 18000], [16, 19000], [17, 20000], [18, 21000], [19, 22000], [20, 23000], [21, 24000], [22, 25000], [23, 26000], [24, 27000], [25, 28000], [26, 29000], [27, 30000], [28, 31000], [29, 32000], [30, 33000], [31, 34000], [32, 35000], [33, 36000], [34, 37000], [35, 38000], [36, 39000], [37, 40000], [38, 41000], [39, 42000], [40, 43000], [41, 44000], [42, 45000], [43, 46000], [44, 47000], [45, 48000], [46, 49000], [47, 50000], [48, 51000], [49, 52000], [50, 53000], [51, 54000], [52, 55000], [53, 56000], [54, 57000], [55, 58000], [56, 59000], [57, 60000], [58, 61000], [59, 62000], [60, 63000], [61, 64000], [62, 65000], [63, 66000], [64, 67000], [65, 68000], [66, 69000], [67, 70000], [68, 71000], [69, 72000], [70, 73000], [71, 74000], [72, 75000], [73, 76000], [74, 77000], [75, 78000], [76, 79000], [77, 80000], [78, 81000], [79, 82000], [80, 83000], [81, 84000], [82, 85000], [83, 86000], [84, 87000], [85, 88000], [86, 89000], [87, 90000], [88, 91000], [89, 92000], [90, 93000], [91, 94000], [92, 95000], [93, 96000], [94, 97000], [95, 98000], [96, 99000], [97, 100000], [98, 101000], [99, 102000]]) == [3000, 4001, 5002, 6003, 7004, 8005, 9006, 10007, 11007, 12009, 13007, 14011, 15007, 16013, 17007, 18015, 19007, 20017, 21018, 22015, 23007, 24021, 25022, 26015, 27007, 28025, 29023, 30015, 31007, 32029, 33023, 34015, 35007, 36031, 37034, 38015, 39036, 40037, 41023, 42039, 43007, 44031, 45039, 46015, 47039, 48045, 49023, 50047, 51007, 52031, 53050, 54015, 55039, 56053, 57023, 58047, 59007, 60031, 61055, 62015, 63039, 64061, 65023, 66047, 67064, 68065, 69066, 70015, 71039, 72063, 73070, 74071, 75007, 76031, 77055, 78075, 79071, 80077, 81023, 82047, 83071, 84081, 85082, 86015, 87039, 88063, 89086, 90079, 91007, 92031, 93055, 94079, 95071, 96093, 97023, 98047, 99071, 100095, 101098, 102015]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99],queries = [[0, 100000], [1, 100001], [2, 100002], [3, 100003], [4, 100004], [5, 100005], [6, 100006], [7, 100007], [8, 100008], [9, 100009], [10, 100010], [11, 100011], [12, 100012], [13, 100013], [14, 100014], [15, 100015], [16, 100016], [17, 100017], [18, 100018], [19, 100019], [20, 100020], [21, 100021], [22, 100022], [23, 100023], [24, 100024], [25, 100025], [26, 100026], [27, 100027], [28, 100028], [29, 100029], [30, 100030], [31, 100031], [32, 100032], [33, 100033], [34, 100034], [35, 100035], [36, 100036], [37, 100037], [38, 100038], [39, 100039], [40, 100040], [41, 100041], [42, 100042], [43, 100043], [44, 100044], [45, 100045], [46, 100046], [47, 100047], [48, 100048], [49, 100049], [50, 100050], [51, 100051], [52, 100052], [53, 100053], [54, 100054], [55, 100055], [56, 100056], [57, 100057], [58, 100058], [59, 100059], [60, 100060], [61, 100061], [62, 100062], [63, 100063], [64, 100064], [65, 100065], [66, 100066], [67, 100067], [68, 100068], [69, 100069], [70, 100070], [71, 100071], [72, 100072], [73, 100073], [74, 100074], [75, 100075], [76, 100076], [77, 100077], [78, 100078], [79, 100079], [80, 100080], [81, 100081], [82, 100082], [83, 100083], [84, 100084], [85, 100085], [86, 100086], [87, 100087], [88, 100088], [89, 100089], [90, 100090], [91, 100091], [92, 100092], [93, 100093], [94, 100094], [95, 100095], [96, 100096], [97, 100097], [98, 100098], [99, 100099]]) == [100000, 100001, 100003, 100003, 100007, 100007, 100007, 100007, 100015, 100015, 100015, 100015, 100015, 100015, 100015, 100015, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100064, 100065, 100067, 100067, 100071, 100071, 100071, 100071, 100079, 100079, 100079, 100079, 100079, 100079, 100079, 100079, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100192, 100193, 100195, 100195]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],queries = [[0, 100000], [1, 50000], [2, 25000], [3, 12500], [4, 6250], [5, 3125], [6, 1562], [7, 781], [8, 390], [9, 195], [10, 97], [11, 48], [12, 24], [13, 12], [14, 6], [15, 3], [16, 1], [17, 513], [18, 257], [19, 129], [20, 65], [21, 32], [22, 16], [23, 8], [24, 4], [25, 2], [26, 1], [27, 513], [28, 257], [29, 129], [30, 65]]) == [100000, 50001, 25002, 12503, 6254, 3127, 1567, 783, 398, 203, 107, 59, 31, 15, 15, 15, 17, 529, 275, 147, 85, 53, 31, 31, 28, 27, 27, 539, 285, 157, 95]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],queries = [[0, 2000], [1, 2001], [2, 2002], [3, 2003], [4, 2004], [5, 2005], [6, 2006], [7, 2007], [8, 2008], [9, 2009], [10, 2010], [11, 2011], [12, 2012], [13, 2013], [14, 2014], [15, 2015], [16, 2016], [17, 2017], [18, 2018], [19, 2019], [20, 2020], [21, 2021], [22, 2022], [23, 2023], [24, 2024], [25, 2025], [26, 2026], [27, 2027], [28, 2028], [29, 2029]]) == [2000, 2001, 2002, 2003, 2006, 2007, 2007, 2007, 2012, 2013, 2015, 2014, 2015, 2014, 2015, 2015, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],queries = [[0, 101], [1, 202], [2, 303], [3, 404], [4, 505], [5, 606], [6, 707], [7, 808], [8, 909], [9, 1010], [10, 1111], [11, 1212], [12, 1313], [13, 1414], [14, 1515], [15, 1616], [16, 1717], [17, 1818]]) == [101, 203, 303, 407, 509, 606, 709, 815, 911, 1019, 1117, 1214, 1325, 1419, 1516, 1631, 1725, 1822]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == [1, 3, 3, 7, 5, 7, 7, 15, 11, 10, 11, 15, 14, 15, 15, 31, 20, 23, 22, 21, 21, 23, 23, 31, 30, 26, 27, 30, 31, 30]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4],queries = [[0, 15], [1, 30], [2, 45], [3, 60], [4, 75], [5, 90], [6, 105], [7, 120], [8, 135], [9, 150]]) == [15, 31, 47, 63, 79, 95, 111, 127, 143, 159]\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14],queries = [[0, 65535], [1, 65534], [2, 65533], [3, 65532], [4, 65531], [5, 65530], [6, 65529], [7, 65528], [8, 65527], [9, 65526], [10, 65525], [11, 65524], [12, 65523], [13, 65522], [14, 65521], [15, 65520], [16, 65519], [17, 65518], [18, 65517], [19, 65516], [20, 65515], [21, 65514], [22, 65513], [23, 65512], [24, 65511], [25, 65510], [26, 65509], [27, 65508], [28, 65507], [29, 65506], [30, 65505], [31, 65504], [32, 65503], [33, 65502], [34, 65501], [35, 65500], [36, 65499], [37, 65498], [38, 65497], [39, 65496], [40, 65495], [41, 65494], [42, 65493], [43, 65492], [44, 65491], [45, 65490], [46, 65489], [47, 65488], [48, 65487], [49, 65486]]) == [65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],queries = [[0, 65536], [1, 32768], [2, 16384], [3, 8192], [4, 4096], [5, 2048], [6, 1024], [7, 512], [8, 256], [9, 128], [10, 64], [11, 32], [12, 16], [13, 8], [14, 4], [15, 2], [14, 1], [13, 3], [12, 7], [11, 15], [10, 31], [9, 63], [8, 127], [7, 255], [6, 511], [5, 1023], [4, 2047], [3, 4095], [2, 8191], [1, 16383], [0, 32767]]) == [65536, 32769, 16386, 8195, 4100, 2053, 1030, 519, 264, 137, 74, 43, 28, 14, 10, 13, 15, 14, 11, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],queries = [[15, 65535], [14, 32767], [13, 16383], [12, 8191], [11, 4095], [10, 2047], [9, 1023], [8, 511], [7, 255], [6, 127], [5, 63], [4, 31], [3, 15], [2, 7], [1, 3], [0, 1]]) == [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]\n", "comparison": "exact"}, "public_tests": ["[-1,0,1,1]\n[[0,2],[3,2],[2,5]]", "[3,7,-1,2,0,7,0,2]\n[[4,6],[1,15],[0,5]]"], "hints": ["How can we use a trie to store all the XOR values in the path from a node to the root?", "How can we dynamically add the XOR values with a DFS search?"], "metadata": {"canonical_parameter_names": ["parents", "queries"], "leetcode_dataset_entry_point": "Solution().maxGeneticDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:40+00:00", "tests_total": 59, "tests_dropped": 7, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "bit-manipulation", "depth-first-search", "trie"]}, "language": "python", "interface": {"raw_signature": "def maxGeneticDifference(self, parents: list[int], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "maxGeneticDifference", "parameters": [{"name": "parents", "type": "list[int]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1941, "task_id": "check-if-all-characters-have-equal-number-of-occurrences", "difficulty": "Easy", "problem_description": "Given a string s, return true if s is a good string, or false otherwise.\n\nA string s is good if all the characters that appear in s have the same number of occurrences (i.e., the same frequency).\n\nExample 1:\n\nInput: s = \"abacbc\"\nOutput: true\nExplanation: The characters that appear in s are 'a', 'b', and 'c'. All characters occur 2 times in s.\n\nExample 2:\n\nInput: s = \"aaabb\"\nOutput: false\nExplanation: The characters that appear in s are 'a' and 'b'.\n'a' occurs 3 times while 'b' occurs 2 times, which is not the same number of times.\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbccc\") == False\n assert candidate(s = \"abacbc\") == True\n assert candidate(s = \"abcabcabc\") == True\n assert candidate(s = \"qqqq\") == True\n assert candidate(s = \"aabbcc\") == True\n assert candidate(s = \"zzzzzzzzzz\") == True\n assert candidate(s = \"aabbc\") == False\n assert candidate(s = \"a\") == True\n assert candidate(s = \"abc\") == True\n assert candidate(s = \"aabb\") == True\n assert candidate(s = \"aabbccddeeff\") == True\n assert candidate(s = \"abcdabcd\") == True\n assert candidate(s = \"zzz\") == True\n assert candidate(s = \"xyz\") == True\n assert candidate(s = \"aaabb\") == False\n assert candidate(s = \"hello\") == False\n assert candidate(s = \"thisisnotagoodstring\") == False\n assert candidate(s = \"aaaabbbbccccdddd\") == True\n assert candidate(s = \"almostgoodbutoneextrab\") == False\n assert candidate(s = \"mnopqrstuvwxyzz\") == False\n assert candidate(s = \"uniquecharactersabcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(s = \"qwertyuioplkjhgfdsazxcvbnm\") == True\n assert candidate(s = \"kjhgfdsazxcvbnmlpoiuytrewq\") == True\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == True\n assert candidate(s = \"llllkkkkjjjjiiiihhhhggggffffeeeeeeee\") == False\n assert candidate(s = \"repeatedcharsrepeatedcharsrepeatedchars\") == False\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\") == False\n assert candidate(s = \"samefrequencyforallcharacters\") == False\n assert candidate(s = \"lmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmno\") == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == False\n assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrsmnopqrs\") == True\n assert candidate(s = \"abcdefabcdefabcdef\") == True\n assert candidate(s = \"abacadaeafagahaibiciidieifigihiiijijikikililimimioinioipoipiqiririsititiuiujujukukululumiumiujujukvkvkwlwlxmxmylynzozp\") == False\n assert candidate(s = \"mnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzqqqq\") == False\n assert candidate(s = \"abracadabra\") == False\n assert candidate(s = \"mnopqrstuvwxymnopqrstuvwxymnopqrstuvwxymnopqrstuvwxyn\") == False\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == True\n assert candidate(s = \"qwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiop\") == True\n assert candidate(s = \"abcdefabcdef\") == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == True\n assert candidate(s = \"almostgoodbutoneextraa\") == False\n assert candidate(s = \"abcdefghijklmnopabcdefghijklmnopabcdefghijklmnopabcdefghijklmnopabcdefghijklmnopabcdefghijklmnop\") == True\n assert candidate(s = \"jjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzzaaaaaa\") == False\n assert candidate(s = \"zzzzzyyyyxxxwwvvuuttssrrqqlloommnnppekkaaiioouuyy\") == False\n assert candidate(s = \"racecar\") == False\n assert candidate(s = \"almostgoodbutoneextrac\") == False\n assert candidate(s = \"xyzxyzxyz\") == True\n assert candidate(s = \"qwerqwerqwer\") == True\n assert candidate(s = \"abababababababab\") == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\") == True\n assert candidate(s = \"ppppppqqqqqrrrrrssssstttttuuuuuvvvvvwwwwwooooo\") == False\n assert candidate(s = \"ababababc\") == False\n assert candidate(s = \"mmnnnmmmnnnmmmnnnmmmnnnmmmnnnmmmnnnmmmnnnmm\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == False\n assert candidate(s = \"pqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrs\") == True\n assert candidate(s = \"mmnnooppqqrrssttuuvvwwxxyyzzqqwweerrttyyuuiihhggffeeddccba\") == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxy\") == True\n assert candidate(s = \"ppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == True\n assert candidate(s = \"mnopmnopmnopmnopmnopmnopmnopmnop\") == True\n assert candidate(s = \"xyzzzzzyzx\") == False\n assert candidate(s = \"abacabadabacabad\") == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxzyabcdefghijklmnopqrstuvwxzy\") == True\n assert candidate(s = \"abcdefghijklmnop\") == True\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzz\") == False\n assert candidate(s = \"zzzyyyxxxwwwwvvvvuuuuuuuuutttttttsssssssrrrrrrqqqqpppooooonnnnmmmmllllkkkkjjjjiiiihhhhhgggggfffffeeeeeeeee\") == False\n assert candidate(s = \"mnopqrmpqrno\") == True\n assert candidate(s = \"qqwweerrttyyuuuiooppppllkkiijjhgffeeddccba\") == False\n assert candidate(s = \"qrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s = \"mississippi\") == False\n assert candidate(s = \"xyzzxyzzxyzzxyzz\") == False\n assert candidate(s = \"oneonetwoonetwothree\") == False\n assert candidate(s = \"zxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnm\") == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(s = \"xyzxyzxyzxyz\") == True\n assert candidate(s = \"zzzzyyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == False\n assert candidate(s = \"qqqqwweerrrrtttyyyy\") == False\n assert candidate(s = \"abcdabcdabcdabcd\") == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(s = \"almostgoodbutoneextrad\") == False\n assert candidate(s = \"almostgoodbutoneextrae\") == False\n assert candidate(s = \"programming\") == False\n assert candidate(s = \"equalfrequenciesequalfrequencies\") == False\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabc\") == False\n assert candidate(s = \"almostgoodbutoneextraf\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghij\") == False\n", "comparison": "exact"}, "public_tests": ["\"abacbc\"", "\"aaabb\""], "hints": ["Build a dictionary containing the frequency of each character appearing in s", "Check if all values in the dictionary are the same."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().areOccurrencesEqual", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:44+00:00", "tests_total": 91, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def areOccurrencesEqual(self, s: str) -> bool:", "container": "Solution", "callable": "areOccurrencesEqual", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1942, "task_id": "the-number-of-the-smallest-unoccupied-chair", "difficulty": "Medium", "problem_description": "There is a party where n friends numbered from 0 to n - 1 are attending. There is an infinite number of chairs in this party that are numbered from 0 to infinity. When a friend arrives at the party, they sit on the unoccupied chair with the smallest number.\n\n- For example, if chairs 0, 1, and 5 are occupied when a friend comes, they will sit on chair number 2.\n\nWhen a friend leaves the party, their chair becomes unoccupied at the moment they leave. If another friend arrives at that same moment, they can sit in that chair.\n\nYou are given a 0-indexed 2D integer array times where times[i] = [arrival_i, leaving_i], indicating the arrival and leaving times of the i^th friend respectively, and an integer targetFriend. All arrival times are distinct.\n\nReturn the chair number that the friend numbered targetFriend will sit on.\n\nExample 1:\n\nInput: times = [[1,4],[2,3],[4,6]], targetFriend = 1\nOutput: 1\nExplanation:\n- Friend 0 arrives at time 1 and sits on chair 0.\n- Friend 1 arrives at time 2 and sits on chair 1.\n- Friend 1 leaves at time 3 and chair 1 becomes empty.\n- Friend 0 leaves at time 4 and chair 0 becomes empty.\n- Friend 2 arrives at time 4 and sits on chair 0.\nSince friend 1 sat on chair 1, we return 1.\n\nExample 2:\n\nInput: times = [[3,10],[1,5],[2,6]], targetFriend = 0\nOutput: 2\nExplanation:\n- Friend 1 arrives at time 1 and sits on chair 0.\n- Friend 2 arrives at time 2 and sits on chair 1.\n- Friend 0 arrives at time 3 and sits on chair 2.\n- Friend 1 leaves at time 5 and chair 0 becomes empty.\n- Friend 2 leaves at time 6 and chair 1 becomes empty.\n- Friend 0 leaves at time 10 and chair 2 becomes empty.\nSince friend 0 sat on chair 2, we return 2.\n\nConstraints:\n\n- n == times.length\n- 2 <= n <= 10^4\n- times[i].length == 2\n- 1 <= arrival_i < leaving_i <= 10^5\n- 0 <= targetFriend <= n - 1\n- Each arrival_i time is distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(times = [[5, 10], [1, 3], [2, 6], [7, 8]],targetFriend = 1) == 0\n assert candidate(times = [[5, 10], [1, 2], [3, 8]],targetFriend = 2) == 0\n assert candidate(times = [[2, 7], [7, 9], [1, 5]],targetFriend = 2) == 0\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5]],targetFriend = 3) == 0\n assert candidate(times = [[8, 12], [1, 6], [3, 5], [9, 10]],targetFriend = 2) == 1\n assert candidate(times = [[2, 5], [3, 7], [4, 9], [5, 10]],targetFriend = 2) == 2\n assert candidate(times = [[5, 15], [1, 20], [10, 25]],targetFriend = 2) == 2\n assert candidate(times = [[10, 20], [20, 30], [15, 25], [5, 15]],targetFriend = 2) == 0\n assert candidate(times = [[2, 5], [3, 9], [4, 7], [5, 8]],targetFriend = 2) == 2\n assert candidate(times = [[5, 10], [1, 3], [4, 8], [6, 9]],targetFriend = 3) == 2\n assert candidate(times = [[10, 20], [5, 10], [15, 25]],targetFriend = 1) == 0\n assert candidate(times = [[1, 4], [2, 3], [4, 6]],targetFriend = 1) == 1\n assert candidate(times = [[5, 10], [1, 3], [4, 6], [6, 7]],targetFriend = 1) == 0\n assert candidate(times = [[1, 3], [2, 5], [3, 6], [4, 7]],targetFriend = 2) == 0\n assert candidate(times = [[2, 5], [1, 3], [6, 7], [4, 8]],targetFriend = 1) == 0\n assert candidate(times = [[3, 10], [1, 5], [2, 6]],targetFriend = 0) == 2\n assert candidate(times = [[1, 2], [2, 5], [4, 7], [7, 9]],targetFriend = 0) == 0\n assert candidate(times = [[3, 4], [1, 5], [2, 6], [5, 7], [4, 8], [6, 9]],targetFriend = 3) == 0\n assert candidate(times = [[5, 8], [12, 15], [10, 14], [20, 25], [1, 4], [16, 18], [6, 9], [19, 22], [3, 7], [11, 13]],targetFriend = 8) == 1\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26]],targetFriend = 6) == 0\n assert candidate(times = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 110], [12, 120]],targetFriend = 11) == 10\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92]],targetFriend = 8) == 8\n assert candidate(times = [[1, 10], [2, 5], [3, 7], [8, 12], [6, 9], [11, 13]],targetFriend = 5) == 0\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86]],targetFriend = 7) == 7\n assert candidate(times = [[10, 20], [5, 15], [1, 10], [16, 30], [21, 40]],targetFriend = 3) == 1\n assert candidate(times = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14]],targetFriend = 2) == 2\n assert candidate(times = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]],targetFriend = 6) == 2\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],targetFriend = 8) == 0\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],targetFriend = 5) == 0\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28]],targetFriend = 7) == 0\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],targetFriend = 0) == 0\n assert candidate(times = [[5, 10], [1, 6], [7, 12], [15, 20], [2, 8]],targetFriend = 4) == 1\n assert candidate(times = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],targetFriend = 3) == 3\n assert candidate(times = [[3, 20], [1, 5], [7, 15], [10, 18], [2, 8], [13, 17]],targetFriend = 3) == 1\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],targetFriend = 4) == 0\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30], [31, 32], [33, 34], [35, 36], [37, 38], [39, 40], [41, 42], [43, 44], [45, 46], [47, 48], [49, 50]],targetFriend = 22) == 0\n assert candidate(times = [[1, 5], [2, 3], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]],targetFriend = 5) == 1\n assert candidate(times = [[10, 20], [1, 6], [3, 11], [7, 14], [15, 25]],targetFriend = 4) == 0\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86], [16, 85], [17, 84], [18, 83], [19, 82], [20, 81]],targetFriend = 15) == 15\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86]],targetFriend = 10) == 10\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],targetFriend = 6) == 0\n assert candidate(times = [[1, 50], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44], [8, 43], [9, 42], [10, 41]],targetFriend = 9) == 9\n assert candidate(times = [[1, 10], [2, 5], [3, 4], [6, 9], [7, 11]],targetFriend = 4) == 2\n assert candidate(times = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100]],targetFriend = 9) == 0\n assert candidate(times = [[1, 10], [2, 12], [3, 14], [4, 16], [5, 18], [6, 20]],targetFriend = 2) == 2\n assert candidate(times = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]],targetFriend = 9) == 9\n assert candidate(times = [[3, 8], [1, 5], [2, 6], [7, 10], [4, 9], [6, 12], [8, 15]],targetFriend = 2) == 1\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30], [31, 32], [33, 34], [35, 36], [37, 38], [39, 40]],targetFriend = 19) == 0\n assert candidate(times = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]],targetFriend = 4) == 0\n assert candidate(times = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14]],targetFriend = 10) == 0\n assert candidate(times = [[10, 20], [5, 15], [1, 8], [21, 25], [11, 18]],targetFriend = 2) == 0\n assert candidate(times = [[2, 4], [6, 8], [10, 12], [1, 3], [5, 7], [9, 11]],targetFriend = 0) == 1\n assert candidate(times = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],targetFriend = 5) == 0\n assert candidate(times = [[1, 10], [2, 5], [6, 12], [3, 9], [7, 15]],targetFriend = 2) == 1\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95]],targetFriend = 5) == 5\n assert candidate(times = [[1, 5], [2, 3], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15]],targetFriend = 7) == 2\n assert candidate(times = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]],targetFriend = 5) == 2\n assert candidate(times = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40]],targetFriend = 5) == 0\n assert candidate(times = [[1, 30], [2, 25], [3, 20], [4, 15], [5, 10], [6, 28], [7, 24], [8, 22], [9, 29], [10, 18], [11, 21], [12, 27], [13, 23], [14, 26], [15, 19], [16, 17]],targetFriend = 4) == 4\n assert candidate(times = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995], [7, 9994], [8, 9993], [9, 9992], [10, 9991]],targetFriend = 9) == 9\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],targetFriend = 0) == 0\n assert candidate(times = [[10, 20], [30, 40], [20, 30], [5, 15], [45, 55], [50, 60]],targetFriend = 4) == 0\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],targetFriend = 9) == 9\n assert candidate(times = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12]],targetFriend = 9) == 1\n assert candidate(times = [[1, 500], [2, 499], [3, 498], [4, 497], [5, 496], [6, 495], [7, 494], [8, 493], [9, 492], [10, 491], [11, 490], [12, 489], [13, 488], [14, 487], [15, 486]],targetFriend = 13) == 13\n assert candidate(times = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80]],targetFriend = 3) == 0\n assert candidate(times = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110]],targetFriend = 4) == 0\n assert candidate(times = [[10, 30], [20, 40], [30, 50], [40, 60], [50, 70], [60, 80], [70, 90], [80, 100], [90, 110], [100, 120], [110, 130], [120, 140], [130, 150], [140, 160], [150, 170], [160, 180], [170, 190], [180, 200], [190, 210], [200, 220]],targetFriend = 9) == 1\n assert candidate(times = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50]],targetFriend = 0) == 0\n assert candidate(times = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40]],targetFriend = 3) == 0\n assert candidate(times = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]],targetFriend = 8) == 0\n assert candidate(times = [[1, 100], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100]],targetFriend = 5) == 5\n assert candidate(times = [[1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21]],targetFriend = 5) == 5\n assert candidate(times = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],targetFriend = 6) == 6\n assert candidate(times = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995], [7, 9994]],targetFriend = 6) == 6\n assert candidate(times = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19]],targetFriend = 9) == 0\n assert candidate(times = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21]],targetFriend = 5) == 0\n assert candidate(times = [[1, 10], [11, 20], [2, 19], [12, 18], [3, 17]],targetFriend = 3) == 3\n assert candidate(times = [[1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12]],targetFriend = 4) == 4\n assert candidate(times = [[3, 8], [5, 10], [1, 4], [7, 12], [9, 15]],targetFriend = 3) == 2\n assert candidate(times = [[1, 10], [2, 12], [3, 14], [4, 16], [5, 18], [6, 20], [7, 22], [8, 24], [9, 26], [10, 28]],targetFriend = 9) == 0\n assert candidate(times = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]],targetFriend = 5) == 0\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],targetFriend = 5) == 0\n assert candidate(times = [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21]],targetFriend = 9) == 0\n assert candidate(times = [[1, 5], [1, 4], [1, 3], [1, 2], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7]],targetFriend = 8) == 0\n assert candidate(times = [[10, 25], [20, 30], [5, 15], [15, 20], [1, 10], [25, 35], [30, 40], [5, 10], [15, 20]],targetFriend = 5) == 0\n assert candidate(times = [[1, 10], [2, 5], [3, 6], [7, 12], [8, 9], [4, 11]],targetFriend = 2) == 2\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],targetFriend = 8) == 0\n assert candidate(times = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]],targetFriend = 7) == 3\n assert candidate(times = [[5, 10], [1, 6], [11, 16], [21, 26], [10, 15], [6, 11], [16, 21], [26, 31], [2, 7], [7, 12]],targetFriend = 8) == 1\n assert candidate(times = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [21, 40], [22, 39], [23, 38], [24, 37], [25, 36], [26, 35], [27, 34], [28, 33], [29, 32], [30, 31]],targetFriend = 15) == 5\n assert candidate(times = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60]],targetFriend = 5) == 0\n assert candidate(times = [[5, 10], [10, 20], [15, 25], [20, 30], [25, 35], [30, 40]],targetFriend = 3) == 0\n assert candidate(times = [[5, 10], [1, 2], [3, 4], [6, 7], [8, 9], [10, 11]],targetFriend = 1) == 0\n assert candidate(times = [[10, 20], [5, 15], [1, 11], [25, 35], [30, 40]],targetFriend = 4) == 1\n", "comparison": "exact"}, "public_tests": ["[[1,4],[2,3],[4,6]]\n1", "[[3,10],[1,5],[2,6]]\n0"], "hints": ["Sort times by arrival time.", "for each arrival_i find the smallest unoccupied chair and mark it as occupied until leaving_i."], "metadata": {"canonical_parameter_names": ["times", "targetFriend"], "leetcode_dataset_entry_point": "Solution().smallestChair", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:47+00:00", "tests_total": 101, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "hash-table", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def smallestChair(self, times: list[list[int]], targetFriend: int) -> int:", "container": "Solution", "callable": "smallestChair", "parameters": [{"name": "times", "type": "list[list[int]]"}, {"name": "targetFriend", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1943, "task_id": "describe-the-painting", "difficulty": "Medium", "problem_description": "There is a long and thin painting that can be represented by a number line. The painting was painted with multiple overlapping segments where each segment was painted with a unique color. You are given a 2D integer array segments, where segments[i] = [start_i, end_i, color_i] represents the half-closed segment [start_i, end_i) with color_i as the color.\n\nThe colors in the overlapping segments of the painting were mixed when it was painted. When two or more colors mix, they form a new color that can be represented as a set of mixed colors.\n\n- For example, if colors 2, 4, and 6 are mixed, then the resulting mixed color is {2,4,6}.\n\nFor the sake of simplicity, you should only output the sum of the elements in the set rather than the full set.\n\nYou want to describe the painting with the minimum number of non-overlapping half-closed segments of these mixed colors. These segments can be represented by the 2D array painting where painting[j] = [left_j, right_j, mix_j] describes a half-closed segment [left_j, right_j) with the mixed color sum of mix_j.\n\n- For example, the painting created with segments = [[1,4,5],[1,7,7]] can be described by painting = [[1,4,12],[4,7,7]] because:\n - [1,4) is colored {5,7} (with a sum of 12) from both the first and second segments.\n - [4,7) is colored {7} from only the second segment.\n\nReturn the 2D array painting describing the finished painting (excluding any parts that are not painted). You may return the segments in any order.\n\nA half-closed segment [a, b) is the section of the number line between points a and b including point a and not including point b.\n\nExample 1:\n\nInput: segments = [[1,4,5],[4,7,7],[1,7,9]]\nOutput: [[1,4,14],[4,7,16]]\nExplanation: The painting can be described as follows:\n- [1,4) is colored {5,9} (with a sum of 14) from the first and third segments.\n- [4,7) is colored {7,9} (with a sum of 16) from the second and third segments.\n\nExample 2:\n\nInput: segments = [[1,7,9],[6,8,15],[8,10,7]]\nOutput: [[1,6,9],[6,7,24],[7,8,15],[8,10,7]]\nExplanation: The painting can be described as follows:\n- [1,6) is colored 9 from the first segment.\n- [6,7) is colored {9,15} (with a sum of 24) from the first and second segments.\n- [7,8) is colored 15 from the second segment.\n- [8,10) is colored 7 from the third segment.\n\nExample 3:\n\nInput: segments = [[1,4,5],[1,4,7],[4,7,1],[4,7,11]]\nOutput: [[1,4,12],[4,7,12]]\nExplanation: The painting can be described as follows:\n- [1,4) is colored {5,7} (with a sum of 12) from the first and second segments.\n- [4,7) is colored {1,11} (with a sum of 12) from the third and fourth segments.\nNote that returning a single segment [1,7) is incorrect because the mixed color sets are different.\n\nConstraints:\n\n- 1 <= segments.length <= 2 * 10^4\n- segments[i].length == 3\n- 1 <= start_i < end_i <= 10^5\n- 1 <= color_i <= 10^9\n- Each color_i is distinct.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(segments=[[10, 20, 5], [15, 25, 3], [12, 18, 8]]), [[10, 12, 5], [12, 15, 13], [15, 18, 16], [18, 20, 8], [20, 25, 3]])\n assert answers_match(candidate(segments=[[1, 10, 100], [5, 15, 200], [12, 20, 300]]), [[1, 5, 100], [5, 10, 300], [10, 12, 200], [12, 15, 500], [15, 20, 300]])\n assert answers_match(candidate(segments=[[2, 5, 10], [3, 8, 20], [5, 6, 30]]), [[2, 3, 10], [3, 5, 30], [5, 6, 50], [6, 8, 20]])\n assert answers_match(candidate(segments=[[2, 5, 10], [3, 8, 20], [6, 10, 30]]), [[2, 3, 10], [3, 5, 30], [5, 6, 20], [6, 8, 50], [8, 10, 30]])\n assert answers_match(candidate(segments=[[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]), [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]])\n assert answers_match(candidate(segments=[[1, 4, 5], [1, 4, 7], [4, 7, 1], [4, 7, 11]]), [[1, 4, 12], [4, 7, 12]])\n assert answers_match(candidate(segments=[[5, 10, 1], [10, 15, 2], [15, 20, 3], [20, 25, 4]]), [[5, 10, 1], [10, 15, 2], [15, 20, 3], [20, 25, 4]])\n assert answers_match(candidate(segments=[[10, 20, 100], [15, 25, 200], [20, 30, 300]]), [[10, 15, 100], [15, 20, 300], [20, 25, 500], [25, 30, 300]])\n assert answers_match(candidate(segments=[[10, 20, 100], [20, 30, 200], [15, 25, 150]]), [[10, 15, 100], [15, 20, 250], [20, 25, 350], [25, 30, 200]])\n assert answers_match(candidate(segments=[[1, 3, 1], [3, 5, 2], [5, 7, 3], [7, 9, 4]]), [[1, 3, 1], [3, 5, 2], [5, 7, 3], [7, 9, 4]])\n assert answers_match(candidate(segments=[[1, 4, 5], [4, 7, 7], [1, 7, 9]]), [[1, 4, 14], [4, 7, 16]])\n assert answers_match(candidate(segments=[[1, 100000, 1000000000]]), [[1, 100000, 1000000000]])\n assert answers_match(candidate(segments=[[1, 7, 9], [6, 8, 15], [8, 10, 7]]), [[1, 6, 9], [6, 7, 24], [7, 8, 15], [8, 10, 7]])\n assert answers_match(candidate(segments=[[10, 15, 5], [12, 20, 15], [18, 25, 25]]), [[10, 12, 5], [12, 15, 20], [15, 18, 15], [18, 20, 40], [20, 25, 25]])\n assert answers_match(candidate(segments=[[1, 10, 5], [2, 9, 10], [3, 8, 15], [4, 7, 20]]), [[1, 2, 5], [2, 3, 15], [3, 4, 30], [4, 7, 50], [7, 8, 30], [8, 9, 15], [9, 10, 5]])\n assert answers_match(candidate(segments=[[1, 3, 1], [2, 5, 2], [3, 7, 3], [4, 8, 4], [5, 9, 5], [6, 10, 6]]), [[1, 2, 1], [2, 3, 3], [3, 4, 5], [4, 5, 9], [5, 6, 12], [6, 7, 18], [7, 8, 15], [8, 9, 11], [9, 10, 6]])\n assert answers_match(candidate(segments=[[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5]]), [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5]])\n assert answers_match(candidate(segments=[[10, 20, 500], [15, 25, 700], [20, 30, 900], [5, 25, 300], [25, 35, 800]]), [[5, 10, 300], [10, 15, 800], [15, 20, 1500], [20, 25, 1900], [25, 30, 1700], [30, 35, 800]])\n assert answers_match(candidate(segments=[[1000, 2000, 5000000], [1500, 2500, 10000000], [2000, 3000, 15000000], [1750, 2250, 12000000], [2250, 2750, 22000000], [2750, 3250, 25000000]]), [[1000, 1500, 5000000], [1500, 1750, 15000000], [1750, 2000, 27000000], [2000, 2250, 37000000], [2250, 2500, 47000000], [2500, 2750, 37000000], [2750, 3000, 40000000], [3000, 3250, 25000000]])\n assert answers_match(candidate(segments=[[1, 100, 1000000000], [50, 150, 1000000000], [100, 200, 1000000000], [150, 250, 1000000000], [200, 300, 1000000000]]), [[1, 50, 1000000000], [50, 100, 2000000000], [100, 150, 2000000000], [150, 200, 2000000000], [200, 250, 2000000000], [250, 300, 1000000000]])\n assert answers_match(candidate(segments=[[1, 4, 5], [2, 6, 7], [3, 7, 9], [4, 8, 11], [5, 9, 13], [6, 10, 15]]), [[1, 2, 5], [2, 3, 12], [3, 4, 21], [4, 5, 27], [5, 6, 40], [6, 7, 48], [7, 8, 39], [8, 9, 28], [9, 10, 15]])\n assert answers_match(candidate(segments=[[10000, 10005, 1], [10001, 10006, 2], [10002, 10007, 3], [10003, 10008, 4], [10004, 10009, 5]]), [[10000, 10001, 1], [10001, 10002, 3], [10002, 10003, 6], [10003, 10004, 10], [10004, 10005, 15], [10005, 10006, 14], [10006, 10007, 12], [10007, 10008, 9], [10008, 10009, 5]])\n assert answers_match(candidate(segments=[[5, 10, 10], [10, 15, 20], [15, 20, 30], [20, 25, 40], [25, 30, 50], [30, 35, 60], [35, 40, 70], [40, 45, 80], [45, 50, 90], [50, 55, 100]]), [[5, 10, 10], [10, 15, 20], [15, 20, 30], [20, 25, 40], [25, 30, 50], [30, 35, 60], [35, 40, 70], [40, 45, 80], [45, 50, 90], [50, 55, 100]])\n assert answers_match(candidate(segments=[[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000]]), [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000]])\n assert answers_match(candidate(segments=[[1, 100000, 1], [50000, 100000, 2], [1, 50000, 3], [25000, 75000, 4]]), [[1, 25000, 4], [25000, 50000, 8], [50000, 75000, 7], [75000, 100000, 3]])\n assert answers_match(candidate(segments=[[1, 5, 10], [2, 4, 20], [3, 6, 30], [4, 8, 40], [5, 9, 50], [6, 10, 60], [7, 11, 70], [8, 12, 80], [9, 13, 90]]), [[1, 2, 10], [2, 3, 30], [3, 4, 60], [4, 5, 80], [5, 6, 120], [6, 7, 150], [7, 8, 220], [8, 9, 260], [9, 10, 300], [10, 11, 240], [11, 12, 170], [12, 13, 90]])\n assert answers_match(candidate(segments=[[1, 3, 1000000000], [3, 5, 1000000000], [5, 7, 1000000000], [7, 9, 1000000000], [9, 11, 1000000000], [11, 13, 1000000000], [13, 15, 1000000000], [15, 17, 1000000000], [17, 19, 1000000000], [19, 21, 1000000000]]), [[1, 3, 1000000000], [3, 5, 1000000000], [5, 7, 1000000000], [7, 9, 1000000000], [9, 11, 1000000000], [11, 13, 1000000000], [13, 15, 1000000000], [15, 17, 1000000000], [17, 19, 1000000000], [19, 21, 1000000000]])\n assert answers_match(candidate(segments=[[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1]]), [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1]])\n assert answers_match(candidate(segments=[[1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 2, 4], [1, 2, 5], [1, 2, 6], [1, 2, 7], [1, 2, 8], [1, 2, 9], [1, 2, 10]]), [[1, 2, 55]])\n assert answers_match(candidate(segments=[[5, 15, 100], [10, 20, 200], [15, 25, 300], [20, 30, 400], [25, 35, 500]]), [[5, 10, 100], [10, 15, 300], [15, 20, 500], [20, 25, 700], [25, 30, 900], [30, 35, 500]])\n assert answers_match(candidate(segments=[[1, 100000, 1000000], [50000, 100000, 900000], [1, 50000, 800000]]), [[1, 50000, 1800000], [50000, 100000, 1900000]])\n assert answers_match(candidate(segments=[[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000], [6, 7, 1000000000], [7, 8, 1000000000], [8, 9, 1000000000], [9, 10, 1000000000], [10, 11, 1000000000]]), [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000], [6, 7, 1000000000], [7, 8, 1000000000], [8, 9, 1000000000], [9, 10, 1000000000], [10, 11, 1000000000]])\n assert answers_match(candidate(segments=[[1, 5, 1], [2, 4, 2], [3, 5, 3], [4, 6, 4], [5, 7, 5], [6, 8, 6]]), [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 8], [5, 6, 9], [6, 7, 11], [7, 8, 6]])\n assert answers_match(candidate(segments=[[100, 200, 500], [150, 250, 1000], [200, 300, 1500], [175, 225, 1200], [225, 275, 2200], [275, 325, 2500]]), [[100, 150, 500], [150, 175, 1500], [175, 200, 2700], [200, 225, 3700], [225, 250, 4700], [250, 275, 3700], [275, 300, 4000], [300, 325, 2500]])\n assert answers_match(candidate(segments=[[1, 20, 1], [2, 19, 2], [3, 18, 3], [4, 17, 4], [5, 16, 5], [6, 15, 6], [7, 14, 7], [8, 13, 8], [9, 12, 9], [10, 11, 10]]), [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 15], [6, 7, 21], [7, 8, 28], [8, 9, 36], [9, 10, 45], [10, 11, 55], [11, 12, 45], [12, 13, 36], [13, 14, 28], [14, 15, 21], [15, 16, 15], [16, 17, 10], [17, 18, 6], [18, 19, 3], [19, 20, 1]])\n assert answers_match(candidate(segments=[[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [20, 21, 20]]), [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [20, 21, 20]])\n assert answers_match(candidate(segments=[[1, 5, 1], [2, 6, 2], [3, 7, 3], [4, 8, 4], [5, 9, 5], [6, 10, 6], [7, 11, 7], [8, 12, 8], [9, 13, 9], [10, 14, 10]]), [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 14], [6, 7, 18], [7, 8, 22], [8, 9, 26], [9, 10, 30], [10, 11, 34], [11, 12, 27], [12, 13, 19], [13, 14, 10]])\n assert answers_match(candidate(segments=[[1, 5, 1], [1, 5, 2], [1, 5, 3], [1, 5, 4], [1, 5, 5], [1, 5, 6], [1, 5, 7], [1, 5, 8], [1, 5, 9], [1, 5, 10]]), [[1, 5, 55]])\n assert answers_match(candidate(segments=[[1, 5, 100], [2, 6, 200], [3, 7, 300], [4, 8, 400], [5, 9, 500], [6, 10, 600], [7, 11, 700], [8, 12, 800], [9, 13, 900], [10, 14, 1000]]), [[1, 2, 100], [2, 3, 300], [3, 4, 600], [4, 5, 1000], [5, 6, 1400], [6, 7, 1800], [7, 8, 2200], [8, 9, 2600], [9, 10, 3000], [10, 11, 3400], [11, 12, 2700], [12, 13, 1900], [13, 14, 1000]])\n assert answers_match(candidate(segments=[[1, 5, 1], [2, 4, 2], [3, 6, 3], [4, 8, 4], [5, 9, 5], [6, 10, 6]]), [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 8], [5, 6, 12], [6, 8, 15], [8, 9, 11], [9, 10, 6]])\n assert answers_match(candidate(segments=[[1, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 10, 10], [7, 11, 11], [8, 12, 12], [9, 13, 13], [10, 14, 14]]), [[1, 2, 5], [2, 3, 11], [3, 4, 18], [4, 5, 26], [5, 6, 30], [6, 7, 34], [7, 8, 38], [8, 9, 42], [9, 10, 46], [10, 11, 50], [11, 12, 39], [12, 13, 27], [13, 14, 14]])\n assert answers_match(candidate(segments=[[1, 10, 5], [5, 15, 7], [10, 20, 9], [1, 20, 3]]), [[1, 5, 8], [5, 10, 15], [10, 15, 19], [15, 20, 12]])\n assert answers_match(candidate(segments=[[1, 10, 10], [2, 8, 20], [5, 15, 30], [10, 20, 40], [15, 25, 50]]), [[1, 2, 10], [2, 5, 30], [5, 8, 60], [8, 10, 40], [10, 15, 70], [15, 20, 90], [20, 25, 50]])\n assert answers_match(candidate(segments=[[1, 3, 10], [2, 4, 20], [3, 5, 30], [4, 6, 40], [5, 7, 50], [6, 8, 60], [7, 9, 70], [8, 10, 80], [9, 11, 90], [10, 12, 100]]), [[1, 2, 10], [2, 3, 30], [3, 4, 50], [4, 5, 70], [5, 6, 90], [6, 7, 110], [7, 8, 130], [8, 9, 150], [9, 10, 170], [10, 11, 190], [11, 12, 100]])\n assert answers_match(candidate(segments=[[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]]), [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]])\n assert answers_match(candidate(segments=[[1, 10, 1000000000], [2, 9, 900000000], [3, 8, 800000000], [4, 7, 700000000], [5, 6, 600000000]]), [[1, 2, 1000000000], [2, 3, 1900000000], [3, 4, 2700000000], [4, 5, 3400000000], [5, 6, 4000000000], [6, 7, 3400000000], [7, 8, 2700000000], [8, 9, 1900000000], [9, 10, 1000000000]])\n assert answers_match(candidate(segments=[[1, 10, 5], [2, 8, 10], [3, 7, 15], [4, 6, 20]]), [[1, 2, 5], [2, 3, 15], [3, 4, 30], [4, 6, 50], [6, 7, 30], [7, 8, 15], [8, 10, 5]])\n assert answers_match(candidate(segments=[[2, 6, 7], [3, 8, 3], [5, 9, 5], [1, 4, 10], [6, 11, 2]]), [[1, 2, 10], [2, 3, 17], [3, 4, 20], [4, 5, 10], [5, 6, 15], [6, 8, 10], [8, 9, 7], [9, 11, 2]])\n assert answers_match(candidate(segments=[[5, 10, 1], [10, 15, 2], [15, 20, 3], [20, 25, 4], [25, 30, 5], [30, 35, 6], [35, 40, 7], [40, 45, 8], [45, 50, 9], [50, 55, 10]]), [[5, 10, 1], [10, 15, 2], [15, 20, 3], [20, 25, 4], [25, 30, 5], [30, 35, 6], [35, 40, 7], [40, 45, 8], [45, 50, 9], [50, 55, 10]])\n assert answers_match(candidate(segments=[[100, 200, 1], [150, 250, 2], [200, 300, 3], [250, 350, 4], [300, 400, 5], [350, 450, 6], [400, 500, 7], [450, 550, 8], [500, 600, 9], [550, 650, 10]]), [[100, 150, 1], [150, 200, 3], [200, 250, 5], [250, 300, 7], [300, 350, 9], [350, 400, 11], [400, 450, 13], [450, 500, 15], [500, 550, 17], [550, 600, 19], [600, 650, 10]])\n assert answers_match(candidate(segments=[[1, 100, 1], [50, 150, 2], [100, 200, 3], [150, 250, 4], [200, 300, 5]]), [[1, 50, 1], [50, 100, 3], [100, 150, 5], [150, 200, 7], [200, 250, 9], [250, 300, 5]])\n assert answers_match(candidate(segments=[[10, 20, 100], [15, 25, 200], [20, 30, 300], [12, 18, 150], [17, 23, 250]]), [[10, 12, 100], [12, 15, 250], [15, 17, 450], [17, 18, 700], [18, 20, 550], [20, 23, 750], [23, 25, 500], [25, 30, 300]])\n assert answers_match(candidate(segments=[[1, 3, 1000000000], [2, 4, 500000000], [3, 5, 300000000], [4, 6, 200000000], [5, 7, 100000000]]), [[1, 2, 1000000000], [2, 3, 1500000000], [3, 4, 800000000], [4, 5, 500000000], [5, 6, 300000000], [6, 7, 100000000]])\n assert answers_match(candidate(segments=[[10, 20, 5], [15, 25, 6], [20, 30, 7], [10, 30, 3], [25, 35, 8]]), [[10, 15, 8], [15, 20, 14], [20, 25, 16], [25, 30, 18], [30, 35, 8]])\n assert answers_match(candidate(segments=[[1, 50000, 1], [2, 50001, 2], [3, 50002, 3], [4, 50003, 4], [5, 50004, 5]]), [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 50000, 15], [50000, 50001, 14], [50001, 50002, 12], [50002, 50003, 9], [50003, 50004, 5]])\n assert answers_match(candidate(segments=[[1, 10, 5], [2, 9, 15], [3, 8, 25], [4, 7, 35], [5, 6, 45]]), [[1, 2, 5], [2, 3, 20], [3, 4, 45], [4, 5, 80], [5, 6, 125], [6, 7, 80], [7, 8, 45], [8, 9, 20], [9, 10, 5]])\n assert answers_match(candidate(segments=[[1, 10, 5], [5, 15, 10], [10, 20, 15]]), [[1, 5, 5], [5, 10, 15], [10, 15, 25], [15, 20, 15]])\n assert answers_match(candidate(segments=[[1, 100, 1], [50, 150, 2], [100, 200, 3], [150, 250, 4], [200, 300, 5], [250, 350, 6], [300, 400, 7], [350, 450, 8], [400, 500, 9], [450, 550, 10]]), [[1, 50, 1], [50, 100, 3], [100, 150, 5], [150, 200, 7], [200, 250, 9], [250, 300, 11], [300, 350, 13], [350, 400, 15], [400, 450, 17], [450, 500, 19], [500, 550, 10]])\n assert answers_match(candidate(segments=[[10, 20, 100], [15, 25, 50], [5, 15, 200]]), [[5, 10, 200], [10, 15, 300], [15, 20, 150], [20, 25, 50]])\n assert answers_match(candidate(segments=[[1, 10, 100], [5, 15, 200], [10, 20, 300], [15, 25, 400]]), [[1, 5, 100], [5, 10, 300], [10, 15, 500], [15, 20, 700], [20, 25, 400]])\n assert answers_match(candidate(segments=[[1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000]]), [[1, 2, 10000000000]])\n assert answers_match(candidate(segments=[[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000], [6, 7, 1000000000], [7, 8, 1000000000], [8, 9, 1000000000], [9, 10, 1000000000]]), [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000], [6, 7, 1000000000], [7, 8, 1000000000], [8, 9, 1000000000], [9, 10, 1000000000]])\n assert answers_match(candidate(segments=[[1, 100, 1], [1, 100, 2], [1, 100, 3], [1, 100, 4], [1, 100, 5], [1, 100, 6], [1, 100, 7], [1, 100, 8], [1, 100, 9], [1, 100, 10]]), [[1, 100, 55]])\n assert answers_match(candidate(segments=[[1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5]]), [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 15], [6, 7, 10], [7, 8, 6], [8, 9, 3], [9, 10, 1]])\n assert answers_match(candidate(segments=[[10, 20, 5], [5, 15, 10], [20, 30, 15], [15, 25, 20], [25, 35, 25], [30, 40, 30]]), [[5, 10, 10], [10, 15, 15], [15, 20, 25], [20, 25, 35], [25, 30, 40], [30, 35, 55], [35, 40, 30]])\n assert answers_match(candidate(segments=[[1, 3, 10], [3, 5, 20], [5, 7, 30], [7, 9, 40], [9, 11, 50], [11, 13, 60], [13, 15, 70]]), [[1, 3, 10], [3, 5, 20], [5, 7, 30], [7, 9, 40], [9, 11, 50], [11, 13, 60], [13, 15, 70]])\n assert answers_match(candidate(segments=[[1, 10, 1], [1, 10, 2], [1, 10, 3], [1, 10, 4], [1, 10, 5], [1, 10, 6], [1, 10, 7], [1, 10, 8], [1, 10, 9], [1, 10, 10]]), [[1, 10, 55]])\n assert answers_match(candidate(segments=[[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]]), [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]])\n assert answers_match(candidate(segments=[[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9]]), [[1, 2, 45], [2, 3, 44], [3, 4, 42], [4, 5, 39], [5, 6, 35], [6, 7, 30], [7, 8, 24], [8, 9, 17], [9, 10, 9]])\n assert answers_match(candidate(segments=[[5, 10, 10], [10, 15, 10], [15, 20, 10], [20, 25, 10], [25, 30, 10], [30, 35, 10], [35, 40, 10], [40, 45, 10], [45, 50, 10], [50, 55, 10]]), [[5, 10, 10], [10, 15, 10], [15, 20, 10], [20, 25, 10], [25, 30, 10], [30, 35, 10], [35, 40, 10], [40, 45, 10], [45, 50, 10], [50, 55, 10]])\n assert answers_match(candidate(segments=[[1, 1000, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1], [20, 1000, 1]]), [[1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 7, 2], [7, 8, 2], [8, 9, 2], [9, 10, 2], [10, 11, 2], [11, 12, 2], [12, 13, 2], [13, 14, 2], [14, 15, 2], [15, 16, 2], [16, 17, 2], [17, 18, 2], [18, 19, 2], [19, 20, 2], [20, 1000, 2]])\n assert answers_match(candidate(segments=[[1, 100, 1], [2, 99, 2], [3, 98, 3], [4, 97, 4], [5, 96, 5], [6, 95, 6], [7, 94, 7], [8, 93, 8], [9, 92, 9], [10, 91, 10]]), [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 15], [6, 7, 21], [7, 8, 28], [8, 9, 36], [9, 10, 45], [10, 91, 55], [91, 92, 45], [92, 93, 36], [93, 94, 28], [94, 95, 21], [95, 96, 15], [96, 97, 10], [97, 98, 6], [98, 99, 3], [99, 100, 1]])\n assert answers_match(candidate(segments=[[1, 10, 10], [2, 8, 20], [5, 15, 30], [10, 20, 40]]), [[1, 2, 10], [2, 5, 30], [5, 8, 60], [8, 10, 40], [10, 15, 70], [15, 20, 40]])\n assert answers_match(candidate(segments=[[10, 20, 100], [20, 30, 200], [30, 40, 300], [40, 50, 400], [50, 60, 500], [60, 70, 600], [70, 80, 700], [80, 90, 800], [90, 100, 900], [100, 110, 1000]]), [[10, 20, 100], [20, 30, 200], [30, 40, 300], [40, 50, 400], [50, 60, 500], [60, 70, 600], [70, 80, 700], [80, 90, 800], [90, 100, 900], [100, 110, 1000]])\n assert answers_match(candidate(segments=[[1, 3, 1000000000], [2, 4, 1000000000], [3, 5, 1000000000], [4, 6, 1000000000], [5, 7, 1000000000]]), [[1, 2, 1000000000], [2, 3, 2000000000], [3, 4, 2000000000], [4, 5, 2000000000], [5, 6, 2000000000], [6, 7, 1000000000]])\n assert answers_match(candidate(segments=[[10, 20, 5], [15, 25, 7], [20, 30, 9], [25, 35, 11], [30, 40, 13], [35, 45, 15], [40, 50, 17], [45, 55, 19], [50, 60, 21], [55, 65, 23]]), [[10, 15, 5], [15, 20, 12], [20, 25, 16], [25, 30, 20], [30, 35, 24], [35, 40, 28], [40, 45, 32], [45, 50, 36], [50, 55, 40], [55, 60, 44], [60, 65, 23]])\n assert answers_match(candidate(segments=[[1, 10000, 1], [2, 9999, 2], [3, 9998, 3], [4, 9997, 4], [5, 9996, 5]]), [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 9996, 15], [9996, 9997, 10], [9997, 9998, 6], [9998, 9999, 3], [9999, 10000, 1]])\n assert answers_match(candidate(segments=[[1, 5, 10], [2, 6, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50]]), [[1, 2, 10], [2, 3, 30], [3, 4, 60], [4, 5, 100], [5, 6, 140], [6, 7, 120], [7, 8, 90], [8, 9, 50]])\n assert answers_match(candidate(segments=[[10, 20, 1], [15, 25, 2], [20, 30, 3], [25, 35, 4], [30, 40, 5], [35, 45, 6], [40, 50, 7], [45, 55, 8], [50, 60, 9], [55, 65, 10]]), [[10, 15, 1], [15, 20, 3], [20, 25, 5], [25, 30, 7], [30, 35, 9], [35, 40, 11], [40, 45, 13], [45, 50, 15], [50, 55, 17], [55, 60, 19], [60, 65, 10]])\n assert answers_match(candidate(segments=[[1, 2, 9], [2, 3, 8], [3, 4, 7], [4, 5, 6], [5, 6, 5], [6, 7, 4], [7, 8, 3], [8, 9, 2], [9, 10, 1]]), [[1, 2, 9], [2, 3, 8], [3, 4, 7], [4, 5, 6], [5, 6, 5], [6, 7, 4], [7, 8, 3], [8, 9, 2], [9, 10, 1]])\n assert answers_match(candidate(segments=[[1, 5, 1], [2, 4, 2], [3, 6, 3], [1, 3, 4], [2, 5, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8]]), [[1, 2, 5], [2, 3, 12], [3, 4, 17], [4, 5, 16], [5, 6, 11]])\n assert answers_match(candidate(segments=[[1, 10, 1], [10, 20, 2], [20, 30, 3], [30, 40, 4], [40, 50, 5], [50, 60, 6], [60, 70, 7], [70, 80, 8], [80, 90, 9], [90, 100, 10]]), [[1, 10, 1], [10, 20, 2], [20, 30, 3], [30, 40, 4], [40, 50, 5], [50, 60, 6], [60, 70, 7], [70, 80, 8], [80, 90, 9], [90, 100, 10]])\n assert answers_match(candidate(segments=[[1, 10, 10], [2, 9, 20], [3, 8, 30], [4, 7, 40], [5, 6, 50], [1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5]]), [[1, 2, 11], [2, 3, 33], [3, 4, 66], [4, 5, 110], [5, 6, 165], [6, 7, 110], [7, 8, 66], [8, 9, 33], [9, 10, 11]])\n assert answers_match(candidate(segments=[[1, 5, 1], [1, 5, 2], [1, 5, 3], [1, 5, 4], [1, 5, 5], [1, 5, 6], [1, 5, 7], [1, 5, 8], [1, 5, 9], [1, 5, 10]]), [[1, 5, 55]])\n assert answers_match(candidate(segments=[[1, 100000, 1], [1, 100000, 2], [1, 100000, 3], [1, 100000, 4], [1, 100000, 5]]), [[1, 100000, 15]])\n assert answers_match(candidate(segments=[[10, 20, 1], [20, 30, 2], [30, 40, 3], [40, 50, 4], [50, 60, 5], [60, 70, 6], [70, 80, 7], [80, 90, 8], [90, 100, 9], [100, 110, 10]]), [[10, 20, 1], [20, 30, 2], [30, 40, 3], [40, 50, 4], [50, 60, 5], [60, 70, 6], [70, 80, 7], [80, 90, 8], [90, 100, 9], [100, 110, 10]])\n assert answers_match(candidate(segments=[[1, 100, 100], [20, 50, 200], [30, 40, 300], [40, 60, 400], [50, 70, 500], [60, 80, 600], [70, 90, 700], [80, 100, 800]]), [[1, 20, 100], [20, 30, 300], [30, 40, 600], [40, 50, 700], [50, 60, 1000], [60, 70, 1200], [70, 80, 1400], [80, 90, 1600], [90, 100, 900]])\n assert answers_match(candidate(segments=[[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9], [1, 11, 10]]), [[1, 2, 55], [2, 3, 54], [3, 4, 52], [4, 5, 49], [5, 6, 45], [6, 7, 40], [7, 8, 34], [8, 9, 27], [9, 10, 19], [10, 11, 10]])\n", "comparison": "unordered"}, "public_tests": ["[[1,4,5],[4,7,7],[1,7,9]]", "[[1,7,9],[6,8,15],[8,10,7]]", "[[1,4,5],[1,4,7],[4,7,1],[4,7,11]]"], "hints": ["Can we sort the segments in a way to help solve the problem?", "How can we dynamically keep track of the sum of the current segment(s)?"], "metadata": {"canonical_parameter_names": ["segments"], "leetcode_dataset_entry_point": "Solution().splitPainting", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:49+00:00", "tests_total": 98, "tests_dropped": 10, "flags": ["any_order", "has_images"], "topic_tags": ["array", "hash-table", "sorting", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def splitPainting(self, segments: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "splitPainting", "parameters": [{"name": "segments", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1944, "task_id": "number-of-visible-people-in-a-queue", "difficulty": "Hard", "problem_description": "There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers where heights[i] represents the height of the i^th person.\n\nA person can see another person to their right in the queue if everybody in between is shorter than both of them. More formally, the i^th person can see the j^th person if i < j and min(heights[i], heights[j]) > max(heights[i+1], heights[i+2], ..., heights[j-1]).\n\nReturn an array answer of length n where answer[i] is the number of people the i^th person can see to their right in the queue.\n\nExample 1:\n\nInput: heights = [10,6,8,5,11,9]\nOutput: [3,1,2,1,1,0]\nExplanation:\nPerson 0 can see person 1, 2, and 4.\nPerson 1 can see person 2.\nPerson 2 can see person 3 and 4.\nPerson 3 can see person 4.\nPerson 4 can see person 5.\nPerson 5 can see no one since nobody is to the right of them.\n\nExample 2:\n\nInput: heights = [5,1,2,3,10]\nOutput: [4,1,1,1,0]\n\nConstraints:\n\n- n == heights.length\n- 1 <= n <= 10^5\n- 1 <= heights[i] <= 10^5\n- All the values of heights are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(heights = [1]) == [0]\n assert candidate(heights = [1, 2, 3, 6, 5, 4, 10, 9, 8, 7]) == [1, 1, 1, 2, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 1, 2, 3, 10]) == [4, 1, 1, 1, 0]\n assert candidate(heights = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [5, 4, 3, 2, 1]) == [1, 1, 1, 1, 0]\n assert candidate(heights = [10, 6, 8, 5, 11, 9]) == [3, 1, 2, 1, 1, 0]\n assert candidate(heights = [3, 1, 2]) == [2, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5]) == [1, 1, 1, 1, 0]\n assert candidate(heights = [3, 1, 4, 2, 5]) == [2, 1, 2, 1, 0]\n assert candidate(heights = [100000]) == [0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 9, 2, 8, 3, 7, 4, 6, 5, 14, 13, 12, 11, 10]) == [1, 3, 1, 3, 1, 3, 1, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 9, 2, 8, 7, 6, 3, 4, 1, 10]) == [1, 3, 1, 2, 2, 3, 1, 2, 1, 0]\n assert candidate(heights = [10, 20, 15, 25, 30, 5, 35, 40, 45, 50]) == [1, 2, 1, 1, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 12, 14, 16, 18, 20, 11, 13, 15, 17, 19]) == [1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 5, 2, 6, 3, 7, 4, 8, 9, 10]) == [1, 2, 1, 2, 1, 2, 1, 1, 1, 0]\n assert candidate(heights = [5, 1, 3, 2, 4, 6, 7, 8, 9, 10]) == [4, 1, 2, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == [2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993, 9, 99992, 10, 99991]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [5, 1, 3, 2, 6, 4, 8, 7, 10, 9]) == [3, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [50, 10, 51, 11, 52, 12, 53, 13, 54, 14]) == [2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [2, 1, 5, 4, 3, 8, 7, 6, 10, 9, 14, 13, 12, 18, 17, 16, 20, 19, 22, 21]) == [2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [5, 3, 8, 6, 11, 9, 14, 12, 17, 15, 20, 18, 23, 21, 26, 24, 29, 27, 32, 30, 35, 33, 38, 36, 39]) == [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10]) == [1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 0]\n assert candidate(heights = [15, 10, 5, 14, 9, 4, 13, 8, 3, 12, 7, 2, 11, 6, 1]) == [2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 1, 1, 0]\n assert candidate(heights = [1, 5, 2, 6, 3, 7, 4, 8, 9, 10]) == [1, 2, 1, 2, 1, 2, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 11, 12, 13, 14, 15]) == [3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0]\n assert candidate(heights = [5, 4, 3, 2, 1, 10]) == [2, 2, 2, 2, 1, 0]\n assert candidate(heights = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 99999]) == [30, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [50000, 40000, 30000, 20000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == [1, 1, 1, 1, 5, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 10, 3, 9, 5, 8, 7, 2, 6, 4]) == [1, 2, 1, 2, 1, 1, 2, 1, 1, 0]\n assert candidate(heights = [10, 5, 6, 7, 1, 2, 3, 4, 8, 9]) == [5, 1, 1, 5, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 5, 4, 6, 7, 8, 9, 10]) == [1, 1, 1, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23]) == [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 8, 4, 9, 7, 6, 10, 3, 2, 1, 11, 14, 12, 13, 16, 15, 18, 17, 20, 19]) == [1, 2, 1, 2, 2, 1, 2, 2, 2, 1, 1, 3, 1, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 20, 2, 19, 3, 18, 4, 17, 5, 16, 6, 15, 7, 14, 8, 13, 9, 12, 10, 11]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 15, 11, 14, 12, 13, 20, 16, 19, 17, 18]) == [3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 3, 1, 3, 1, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [5, 3, 8, 6, 7, 2, 4, 1, 10, 9]) == [2, 1, 3, 1, 3, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 20, 15, 30, 25, 40, 35, 50, 45, 60, 55, 70, 65, 80, 75, 90, 85, 100, 95, 110]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16]) == [1, 3, 1, 3, 1, 3, 1, 3, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [10, 1, 20, 3, 40, 5, 60, 7, 80, 9, 100]) == [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9]) == [4, 1, 2, 1, 1, 1, 2, 1, 1, 0]\n assert candidate(heights = [100, 50, 75, 25, 60, 35, 80, 10, 90, 40]) == [4, 1, 3, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [50, 20, 40, 10, 30, 60, 70, 80, 90, 100]) == [3, 1, 3, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 15, 4, 3, 2, 1, 16, 17, 18, 19]) == [2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 9, 1, 4, 6, 8, 2, 3, 7, 10]) == [1, 5, 1, 1, 1, 4, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 105, 95, 85, 75, 65, 55, 45, 35, 25, 15]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [77, 73, 69, 65, 61, 57, 53, 49, 45, 41, 37, 33, 29, 25, 21, 17, 13, 9, 5, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15, 20, 19, 18, 17, 16]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == [2, 2, 2, 2, 2, 2, 2, 2, 1, 0]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == [1, 3, 1, 3, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100000, 99999, 99998, 99997, 99996, 99995]) == [1, 1, 1, 1, 1, 0]\n assert candidate(heights = [50, 40, 30, 20, 10, 5, 15, 25, 35, 45]) == [2, 3, 3, 3, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 6, 5, 4, 10, 9, 8, 7, 14, 13, 12, 11, 20, 19, 18, 17, 16, 15]) == [1, 2, 1, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 3, 8, 6, 7, 2, 4, 9, 1, 10]) == [2, 1, 3, 1, 3, 1, 1, 2, 1, 0]\n assert candidate(heights = [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 18]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 5, 3, 7, 2, 8, 4, 9, 6, 10]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == [2, 2, 2, 2, 1, 1, 1, 1, 1, 0]\n", "comparison": "exact"}, "public_tests": ["[10,6,8,5,11,9]", "[5,1,2,3,10]"], "hints": ["How to solve this problem in quadratic complexity ?", "For every subarray start at index i, keep finding new maximum values until a value larger than arr[i] is found.", "Since the limits are high, you need a linear solution.", "Use a stack to keep the values of the array sorted as you iterate the array from the end to the start.", "Keep popping from the stack the elements in sorted order until a value larger than arr[i] is found, these are the ones that person i can see."], "metadata": {"canonical_parameter_names": ["heights"], "leetcode_dataset_entry_point": "Solution().canSeePersonsCount", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:52+00:00", "tests_total": 123, "tests_dropped": 26, "flags": ["has_images"], "topic_tags": ["array", "stack", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def canSeePersonsCount(self, heights: list[int]) -> list[int]:", "container": "Solution", "callable": "canSeePersonsCount", "parameters": [{"name": "heights", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1945, "task_id": "sum-of-digits-of-string-after-convert", "difficulty": "Easy", "problem_description": "You are given a string s consisting of lowercase English letters, and an integer k. Your task is to convert the string into an integer by a special process, and then transform it by summing its digits repeatedly k times. More specifically, perform the following steps:\n\n1. Convert s into an integer by replacing each letter with its position in the alphabet (i.e. replace 'a' with 1, 'b' with 2, ..., 'z' with 26).\n2. Transform the integer by replacing it with the sum of its digits.\n3. Repeat the transform operation (step 2) k times in total.\n\nFor example, if s = \"zbax\" and k = 2, then the resulting integer would be 8 by the following operations:\n\n1. Convert: \"zbax\" ➝ \"(26)(2)(1)(24)\" ➝ \"262124\" ➝ 262124\n2. Transform #1: 262124 ➝ 2 + 6 + 2 + 1 + 2 + 4 ➝ 17\n3. Transform #2: 17 ➝ 1 + 7 ➝ 8\n\nReturn the resulting integer after performing the operations described above.\n\nExample 1:\n\nInput: s = \"iiii\", k = 1\nOutput: 36\nExplanation:\nThe operations are as follows:\n- Convert: \"iiii\" ➝ \"(9)(9)(9)(9)\" ➝ \"9999\" ➝ 9999\n- Transform #1: 9999 ➝ 9 + 9 + 9 + 9 ➝ 36\nThus the resulting integer is 36.\n\nExample 2:\n\nInput: s = \"leetcode\", k = 2\nOutput: 6\nExplanation:\nThe operations are as follows:\n- Convert: \"leetcode\" ➝ \"(12)(5)(5)(20)(3)(15)(4)(5)\" ➝ \"12552031545\" ➝ 12552031545\n- Transform #1: 12552031545 ➝ 1 + 2 + 5 + 5 + 2 + 0 + 3 + 1 + 5 + 4 + 5 ➝ 33\n- Transform #2: 33 ➝ 3 + 3 ➝ 6\nThus the resulting integer is 6.\n\nExample 3:\n\nInput: s = \"zbax\", k = 2\nOutput: 8\n\nConstraints:\n\n- 1 <= s.length <= 100\n- 1 <= k <= 10\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzz\",k = 1) == 32\n assert candidate(s = \"zzz\",k = 10) == 6\n assert candidate(s = \"programming\",k = 1) == 68\n assert candidate(s = \"abz\",k = 5) == 2\n assert candidate(s = \"a\",k = 1) == 1\n assert candidate(s = \"aaa\",k = 3) == 3\n assert candidate(s = \"challenge\",k = 2) == 4\n assert candidate(s = \"iiii\",k = 1) == 36\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == 135\n assert candidate(s = \"hello\",k = 1) == 25\n assert candidate(s = \"python\",k = 2) == 8\n assert candidate(s = \"abc\",k = 3) == 6\n assert candidate(s = \"zbax\",k = 2) == 8\n assert candidate(s = \"abcxyz\",k = 3) == 9\n assert candidate(s = \"leetcode\",k = 2) == 6\n assert candidate(s = \"a\",k = 10) == 1\n assert candidate(s = \"zzzz\",k = 3) == 5\n assert candidate(s = \"zzzzzzzzzz\",k = 1) == 80\n assert candidate(s = \"algorithms\",k = 4) == 5\n assert candidate(s = \"repeatthisoverandover\",k = 7) == 8\n assert candidate(s = \"zzzzzzzzzz\",k = 6) == 8\n assert candidate(s = \"interview\",k = 5) == 8\n assert candidate(s = \"artificialintelligence\",k = 7) == 5\n assert candidate(s = \"zzyxwvutsrqponmlkjihgfedcba\",k = 4) == 8\n assert candidate(s = \"singleletterx\",k = 10) == 8\n assert candidate(s = \"thisisaverylongstringwhichshouldbeconverted\",k = 4) == 2\n assert candidate(s = \"zzzzzzzzzz\",k = 3) == 8\n assert candidate(s = \"hippopotamus\",k = 10) == 7\n assert candidate(s = \"qwen\",k = 5) == 5\n assert candidate(s = \"datastructure\",k = 4) == 9\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 3) == 8\n assert candidate(s = \"repeatedlettersqqqq\",k = 6) == 7\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 2) == 9\n assert candidate(s = \"programming\",k = 3) == 5\n assert candidate(s = \"unbelievable\",k = 9) == 2\n assert candidate(s = \"mississippi\",k = 7) == 4\n assert candidate(s = \"zebra\",k = 6) == 7\n assert candidate(s = \"zzzzzzzzzz\",k = 10) == 8\n assert candidate(s = \"xyzxyz\",k = 3) == 6\n assert candidate(s = \"supercalifragilisticexpialidocious\",k = 5) == 1\n assert candidate(s = \"onetwothreefourfivesixseveneightnine\",k = 5) == 8\n assert candidate(s = \"generateadditionalinputs\",k = 8) == 2\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 4) == 8\n assert candidate(s = \"multifarious\",k = 7) == 2\n assert candidate(s = \"consecutivesimilar\",k = 8) == 1\n assert candidate(s = \"neuralnetwork\",k = 8) == 6\n assert candidate(s = \"developerslovepython\",k = 9) == 3\n assert candidate(s = \"algorithm\",k = 1) == 49\n assert candidate(s = \"wearethebestprogrammers\",k = 7) == 4\n assert candidate(s = \"xylophone\",k = 3) == 8\n assert candidate(s = \"alibabacloud\",k = 7) == 2\n assert candidate(s = \"aaaaaaaaaa\",k = 10) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 5) == 9\n assert candidate(s = \"elephant\",k = 8) == 9\n assert candidate(s = \"supercalifragilisticexpialidocious\",k = 4) == 1\n assert candidate(s = \"abcdefghij\",k = 5) == 1\n assert candidate(s = \"repeatedletters\",k = 4) == 2\n assert candidate(s = \"datastructures\",k = 5) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 3) == 9\n assert candidate(s = \"facetious\",k = 8) == 9\n assert candidate(s = \"numericalsum\",k = 7) == 5\n assert candidate(s = \"expertise\",k = 2) == 13\n assert candidate(s = \"codingcontest\",k = 6) == 4\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 4) == 9\n assert candidate(s = \"alibabacloud\",k = 2) == 11\n assert candidate(s = \"manytimesk\",k = 10) == 4\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 6) == 8\n assert candidate(s = \"giraffe\",k = 9) == 7\n assert candidate(s = \"qwen\",k = 10) == 5\n assert candidate(s = \"mississippi\",k = 8) == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 10) == 9\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 10) == 8\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 4\n assert candidate(s = \"solution\",k = 7) == 8\n assert candidate(s = \"abacaxabacax\",k = 5) == 1\n assert candidate(s = \"algorithms\",k = 5) == 5\n assert candidate(s = \"zzzzzzzzzz\",k = 5) == 8\n assert candidate(s = \"transform\",k = 8) == 7\n assert candidate(s = \"congratulations\",k = 5) == 9\n assert candidate(s = \"xylophone\",k = 4) == 8\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 2) == 8\n assert candidate(s = \"qwen\",k = 4) == 5\n assert candidate(s = \"leetcodeisfun\",k = 9) == 3\n assert candidate(s = \"programmingisfun\",k = 3) == 2\n assert candidate(s = \"machinelearning\",k = 6) == 7\n assert candidate(s = \"abcdefg\",k = 10) == 1\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",k = 6) == 5\n assert candidate(s = \"thisisaverylongandcomplexstring\",k = 6) == 1\n assert candidate(s = \"xylophone\",k = 5) == 8\n assert candidate(s = \"thisisanexampletocheckthecomplexity\",k = 4) == 1\n assert candidate(s = \"datastructure\",k = 5) == 9\n assert candidate(s = \"abacaxi\",k = 3) == 5\n assert candidate(s = \"abcdabcdabcd\",k = 4) == 3\n", "comparison": "exact"}, "public_tests": ["\"iiii\"\n1", "\"leetcode\"\n2", "\"zbax\"\n2"], "hints": ["First, let's note that after the first transform the value will be at most 100 * 10 which is not much", "After The first transform, we can just do the rest of the transforms by brute force"], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().getLucky", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:54+00:00", "tests_total": 93, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "simulation"]}, "language": "python", "interface": {"raw_signature": "def getLucky(self, s: str, k: int) -> int:", "container": "Solution", "callable": "getLucky", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1946, "task_id": "largest-number-after-mutating-substring", "difficulty": "Medium", "problem_description": "You are given a string num, which represents a large integer. You are also given a 0-indexed integer array change of length 10 that maps each digit 0-9 to another digit. More formally, digit d maps to digit change[d].\n\nYou may choose to mutate a single substring of num. To mutate a substring, replace each digit num[i] with the digit it maps to in change (i.e. replace num[i] with change[num[i]]).\n\nReturn a string representing the largest possible integer after mutating (or choosing not to) a single substring of num.\n\nA substring is a contiguous sequence of characters within the string.\n\nExample 1:\n\nInput: num = \"132\", change = [9,8,5,0,3,6,4,2,6,8]\nOutput: \"832\"\nExplanation: Replace the substring \"1\":\n- 1 maps to change[1] = 8.\nThus, \"132\" becomes \"832\".\n\"832\" is the largest number that can be created, so return it.\n\nExample 2:\n\nInput: num = \"021\", change = [9,4,3,5,7,2,1,9,0,6]\nOutput: \"934\"\nExplanation: Replace the substring \"021\":\n- 0 maps to change[0] = 9.\n- 2 maps to change[2] = 3.\n- 1 maps to change[1] = 4.\nThus, \"021\" becomes \"934\".\n\"934\" is the largest number that can be created, so return it.\n\nExample 3:\n\nInput: num = \"5\", change = [1,4,7,5,3,2,5,6,9,4]\nOutput: \"5\"\nExplanation: \"5\" is already the largest number that can be created, so return it.\n\nConstraints:\n\n- 1 <= num.length <= 10^5\n- num consists of only digits 0-9.\n- change.length == 10\n- 0 <= change[d] <= 9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"132\",change = [9, 8, 5, 0, 3, 6, 4, 2, 6, 8]) == \"832\"\n assert candidate(num = \"1111\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999\"\n assert candidate(num = \"5\",change = [1, 4, 7, 5, 3, 2, 5, 6, 9, 4]) == \"5\"\n assert candidate(num = \"9876543210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"9876543210\"\n assert candidate(num = \"3333\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"3333\"\n assert candidate(num = \"021\",change = [9, 4, 3, 5, 7, 2, 1, 9, 0, 6]) == \"934\"\n assert candidate(num = \"1234567890\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8765567890\"\n assert candidate(num = \"1001001001\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"8642086420\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9753197531\"\n assert candidate(num = \"1999999999\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"9999999999\"\n assert candidate(num = \"9999999999\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"9999999999\"\n assert candidate(num = \"1231231231\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"1231231231\"\n assert candidate(num = \"1001\",change = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == \"1111\"\n assert candidate(num = \"9000000009\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9111111119\"\n assert candidate(num = \"9876543210\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"9876543210\"\n assert candidate(num = \"0001112223\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"13579\",change = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == \"26579\"\n assert candidate(num = \"1357924680\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"1122334455\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1122334455\"\n assert candidate(num = \"5432109876\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"5567899876\"\n assert candidate(num = \"999888777666555444333222111000\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 9]) == \"999888777666555444333222111000\"\n assert candidate(num = \"11111111111111111111\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"99999999999999999999\"\n assert candidate(num = \"100100100\",change = [9, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"199100100\"\n assert candidate(num = \"100100\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"899899\"\n assert candidate(num = \"99999\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 9]) == \"99999\"\n assert candidate(num = \"2468013579\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"7568013579\"\n assert candidate(num = \"1000000001\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"9000000009\"\n assert candidate(num = \"9876543210\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9876556789\"\n assert candidate(num = \"9009\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9999\"\n assert candidate(num = \"0123456789\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"0123456789\"\n assert candidate(num = \"13579246801357924680\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"13579246801357924680\"\n assert candidate(num = \"10987654321\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"99999999999\"\n assert candidate(num = \"1234567890\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"1234567890\"\n assert candidate(num = \"9087654321\",change = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"9187654321\"\n assert candidate(num = \"1919191919\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8919191919\"\n assert candidate(num = \"5555555555\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"6666666666\"\n assert candidate(num = \"4444444444\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"4444444444\"\n assert candidate(num = \"1111\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"1111\"\n assert candidate(num = \"9876543210\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"9090909090\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 9]) == \"9090909090\"\n assert candidate(num = \"12345678901234567890\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"12345678901234567890\"\n assert candidate(num = \"1234567890\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"1234567891\"\n assert candidate(num = \"98765432109876543210\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"98765567899876543210\"\n assert candidate(num = \"9898989898\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"9898989898\"\n assert candidate(num = \"5432109876\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"5432109876\"\n assert candidate(num = \"9999999999\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9999999999\"\n assert candidate(num = \"0000000000\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9999999999\"\n assert candidate(num = \"2222\",change = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == \"3333\"\n assert candidate(num = \"1123344556677889900\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1123344556677889900\"\n assert candidate(num = \"8765432109\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8765567899\"\n assert candidate(num = \"2468013579\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"2468013579\"\n assert candidate(num = \"1000100010\",change = [9, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"1999100010\"\n assert candidate(num = \"9999999999\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"123456789012345678901234567890\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"987656789012345678901234567890\"\n assert candidate(num = \"3214567890\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"6785567890\"\n assert candidate(num = \"11223344556677889900\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"99887766556677889900\"\n assert candidate(num = \"543210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"543210\"\n assert candidate(num = \"1234554321\",change = [0, 1, 2, 3, 4, 6, 5, 6, 7, 8]) == \"1234664321\"\n assert candidate(num = \"9080706050\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9191817161\"\n assert candidate(num = \"99999999999999999999\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"99999999999999999999\"\n assert candidate(num = \"5678943210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"5678943210\"\n assert candidate(num = \"11223344556677889900\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"11223344556677889900\"\n assert candidate(num = \"9090909090\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9190909090\"\n assert candidate(num = \"2222222222\",change = [0, 1, 9, 3, 4, 5, 6, 7, 8, 9]) == \"9999999999\"\n assert candidate(num = \"0000000000\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"1111111111\"\n assert candidate(num = \"239847362876\",change = [8, 9, 5, 7, 6, 5, 4, 3, 2, 1]) == \"579847362876\"\n assert candidate(num = \"00000000000000000000\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"99999999999999999999\"\n assert candidate(num = \"123123123\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"987987987\"\n assert candidate(num = \"2468024680\",change = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == \"4868024680\"\n assert candidate(num = \"0000000000\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"1111111111\"\n assert candidate(num = \"2345678901\",change = [0, 1, 2, 9, 4, 5, 6, 7, 8, 3]) == \"2945678901\"\n assert candidate(num = \"999999\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 9]) == \"999999\"\n assert candidate(num = \"3333\",change = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == \"3333\"\n assert candidate(num = \"00112233445566778899\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"99999999999999999999\"\n assert candidate(num = \"8888888888\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"8888888888\"\n assert candidate(num = \"1234567890\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"2345678990\"\n assert candidate(num = \"1212121212\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1212121212\"\n assert candidate(num = \"2727272727\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"2727272727\"\n assert candidate(num = \"111222333\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"222333444\"\n assert candidate(num = \"111000111\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"111000111\"\n assert candidate(num = \"1919191919\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"9919191919\"\n assert candidate(num = \"86420\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"86579\"\n assert candidate(num = \"4444444444\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"4444444444\"\n assert candidate(num = \"0000000000\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"0000000000\"\n assert candidate(num = \"1357924680\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1357924680\"\n assert candidate(num = \"109876543210987654321\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"219876543210987654321\"\n assert candidate(num = \"09876543210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"09876543210\"\n assert candidate(num = \"0000000000\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"01234567890123456789\",change = [9, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"91234567890123456789\"\n assert candidate(num = \"3456789\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"6556789\"\n assert candidate(num = \"2222222222\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"2222222222\"\n assert candidate(num = \"12345678901234567890\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"98765678901234567890\"\n assert candidate(num = \"0123456789\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9876556789\"\n assert candidate(num = \"1234567890\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"9876567890\"\n assert candidate(num = \"888888\",change = [1, 2, 3, 4, 5, 6, 7, 8, 8, 9]) == \"888888\"\n assert candidate(num = \"56789\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"56789\"\n assert candidate(num = \"99999\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"99999\"\n assert candidate(num = \"5643210987\",change = [0, 1, 2, 3, 4, 9, 6, 7, 8, 9]) == \"9643210987\"\n assert candidate(num = \"54321098765432109876\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"55678998765432109876\"\n assert candidate(num = \"9234567890\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9345678990\"\n assert candidate(num = \"98765432109876543210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"98765432109876543210\"\n assert candidate(num = \"1234567890\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"12345678901234567890\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"87655678901234567890\"\n assert candidate(num = \"1111111111\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"1111111111\"\n assert candidate(num = \"1999\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"2999\"\n assert candidate(num = \"2736419850\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"7736419850\"\n assert candidate(num = \"505050\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"505050\"\n assert candidate(num = \"1010101010\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"000000\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == \"000000\"\n assert candidate(num = \"1212121212\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8787878787\"\n assert candidate(num = \"1122334455\",change = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == \"6677889955\"\n assert candidate(num = \"5555555555\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"9876543210\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9987654321\"\n assert candidate(num = \"1122334455\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8877665555\"\n assert candidate(num = \"1111111111\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"532532532\",change = [8, 9, 0, 7, 6, 5, 4, 3, 2, 1]) == \"572532532\"\n assert candidate(num = \"9321876543\",change = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9]) == \"9567876543\"\n assert candidate(num = \"0000\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9999\"\n assert candidate(num = \"5678912345\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"5678998765\"\n assert candidate(num = \"543210\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"654321\"\n assert candidate(num = \"1234567890\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1234567890\"\n assert candidate(num = \"5555555555\",change = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == \"5555555555\"\n assert candidate(num = \"5555\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"5555\"\n assert candidate(num = \"8888888888\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8888888888\"\n", "comparison": "exact"}, "public_tests": ["\"132\"\n[9,8,5,0,3,6,4,2,6,8]", "\"021\"\n[9,4,3,5,7,2,1,9,0,6]", "\"5\"\n[1,4,7,5,3,2,5,6,9,4]"], "hints": ["Should you change a digit if the new digit is smaller than the original?", "If changing the first digit and the last digit both make the number bigger, but you can only change one of them; which one should you change?", "Changing numbers closer to the front is always better"], "metadata": {"canonical_parameter_names": ["num", "change"], "leetcode_dataset_entry_point": "Solution().maximumNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:56+00:00", "tests_total": 125, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maximumNumber(self, num: str, change: list[int]) -> str:", "container": "Solution", "callable": "maximumNumber", "parameters": [{"name": "num", "type": "str"}, {"name": "change", "type": "list[int]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1947, "task_id": "maximum-compatibility-score-sum", "difficulty": "Medium", "problem_description": "There is a survey that consists of n questions where each question's answer is either 0 (no) or 1 (yes).\n\nThe survey was given to m students numbered from 0 to m - 1 and m mentors numbered from 0 to m - 1. The answers of the students are represented by a 2D integer array students where students[i] is an integer array that contains the answers of the i^th student (0-indexed). The answers of the mentors are represented by a 2D integer array mentors where mentors[j] is an integer array that contains the answers of the j^th mentor (0-indexed).\n\nEach student will be assigned to one mentor, and each mentor will have one student assigned to them. The compatibility score of a student-mentor pair is the number of answers that are the same for both the student and the mentor.\n\n- For example, if the student's answers were [1, 0, 1] and the mentor's answers were [0, 0, 1], then their compatibility score is 2 because only the second and the third answers are the same.\n\nYou are tasked with finding the optimal student-mentor pairings to maximize the sum of the compatibility scores.\n\nGiven students and mentors, return the maximum compatibility score sum that can be achieved.\n\nExample 1:\n\nInput: students = [[1,1,0],[1,0,1],[0,0,1]], mentors = [[1,0,0],[0,0,1],[1,1,0]]\nOutput: 8\nExplanation: We assign students to mentors in the following way:\n- student 0 to mentor 2 with a compatibility score of 3.\n- student 1 to mentor 0 with a compatibility score of 2.\n- student 2 to mentor 1 with a compatibility score of 3.\nThe compatibility score sum is 3 + 2 + 3 = 8.\n\nExample 2:\n\nInput: students = [[0,0],[0,0],[0,0]], mentors = [[1,1],[1,1],[1,1]]\nOutput: 0\nExplanation: The compatibility score of any student-mentor pair is 0.\n\nConstraints:\n\n- m == students.length == mentors.length\n- n == students[i].length == mentors[j].length\n- 1 <= m, n <= 8\n- students[i][k] is either 0 or 1.\n- mentors[j][k] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(students = [[1, 1, 0, 0], [0, 0, 1, 1]],mentors = [[1, 0, 1, 0], [0, 1, 0, 1]]) == 4\n assert candidate(students = [[1, 1], [0, 0]],mentors = [[0, 0], [1, 1]]) == 4\n assert candidate(students = [[1, 0], [0, 1]],mentors = [[1, 0], [0, 1]]) == 4\n assert candidate(students = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0]],mentors = [[1, 1, 1, 1], [0, 0, 0, 0], [0, 1, 0, 1]]) == 8\n assert candidate(students = [[1, 0, 1, 0], [0, 1, 0, 1]],mentors = [[0, 0, 1, 1], [1, 1, 0, 0]]) == 4\n assert candidate(students = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 1, 1]],mentors = [[0, 0, 0, 0], [1, 1, 1, 1], [0, 1, 0, 1]]) == 10\n assert candidate(students = [[1, 1, 0, 0], [0, 0, 1, 1]],mentors = [[0, 0, 1, 1], [1, 1, 0, 0]]) == 8\n assert candidate(students = [[1, 1, 1], [0, 0, 0]],mentors = [[1, 1, 1], [0, 0, 0]]) == 6\n assert candidate(students = [[0, 0], [0, 0], [0, 0]],mentors = [[1, 1], [1, 1], [1, 1]]) == 0\n assert candidate(students = [[1, 1, 1, 1], [0, 0, 0, 0]],mentors = [[1, 1, 1, 1], [0, 0, 0, 0]]) == 8\n assert candidate(students = [[0, 0, 0], [1, 1, 1], [0, 1, 0]],mentors = [[1, 1, 1], [0, 0, 0], [1, 0, 1]]) == 6\n assert candidate(students = [[1, 0, 1], [0, 1, 0]],mentors = [[0, 1, 0], [1, 0, 1]]) == 6\n assert candidate(students = [[1, 1, 0], [1, 0, 1], [0, 0, 1]],mentors = [[1, 0, 0], [0, 0, 1], [1, 1, 0]]) == 8\n assert candidate(students = [[1, 0], [0, 1]],mentors = [[0, 1], [1, 0]]) == 4\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]]) == 32\n assert candidate(students = [[1, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1]],mentors = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0], [1, 0, 1, 0, 0, 1, 1]]) == 40\n assert candidate(students = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 1, 0, 1, 0], [0, 0, 1, 0, 0]],mentors = [[0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 0, 1, 0, 0], [1, 1, 0, 1, 0]]) == 20\n assert candidate(students = [[1, 0, 1, 1, 0], [0, 1, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]],mentors = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 16\n assert candidate(students = [[1, 0, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0, 1, 1], [0, 0, 1, 0, 1, 1, 0, 0], [1, 0, 1, 0, 0, 1, 1, 0], [0, 1, 0, 1, 1, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]],mentors = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 0, 1, 1, 0], [0, 1, 0, 1, 1, 0, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1, 0, 1], [1, 1, 0, 1, 0, 0, 1, 1], [0, 0, 1, 0, 1, 1, 0, 0]]) == 64\n assert candidate(students = [[1, 1, 1], [0, 0, 0], [1, 0, 1], [0, 1, 0]],mentors = [[1, 0, 1], [0, 1, 0], [0, 0, 0], [1, 1, 1]]) == 12\n assert candidate(students = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],mentors = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 20\n assert candidate(students = [[1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],mentors = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0]]) == 28\n assert candidate(students = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1]],mentors = [[1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 1, 1]]) == 49\n assert candidate(students = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]],mentors = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 20\n assert candidate(students = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1]],mentors = [[1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == 20\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1]],mentors = [[1, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0]]) == 22\n assert candidate(students = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 24\n assert candidate(students = [[0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0]],mentors = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1]]) == 32\n assert candidate(students = [[0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]],mentors = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 20\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]],mentors = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 8\n assert candidate(students = [[1, 0, 1, 1, 0], [0, 1, 0, 0, 1], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0]],mentors = [[0, 1, 0, 0, 1], [1, 0, 1, 1, 0], [0, 0, 1, 1, 0], [1, 1, 0, 0, 1]]) == 20\n assert candidate(students = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 64\n assert candidate(students = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],mentors = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 20\n assert candidate(students = [[1, 0, 0, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [0, 1, 1, 0, 0]],mentors = [[0, 1, 1, 0, 0], [1, 0, 0, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0]]) == 20\n assert candidate(students = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 1]],mentors = [[0, 1, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1], [1, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 1]]) == 24\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],mentors = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]]) == 28\n assert candidate(students = [[1, 0, 1, 1, 0], [0, 1, 0, 0, 1], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1]],mentors = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 12\n assert candidate(students = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 1, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 0]],mentors = [[0, 1, 1, 0, 0, 1, 1, 0], [1, 0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 64\n assert candidate(students = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]]) == 24\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 64\n assert candidate(students = [[1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 1, 0, 1, 1, 0, 1]],mentors = [[0, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0, 1, 0]]) == 16\n assert candidate(students = [[0, 1, 1, 0, 1, 1], [1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1]],mentors = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 0, 1, 0, 0], [0, 1, 1, 0, 1, 1]]) == 24\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 64\n assert candidate(students = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 0, 0], [0, 0, 1, 1]],mentors = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1]]) == 12\n assert candidate(students = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]],mentors = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 64\n assert candidate(students = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0], [1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1]],mentors = [[0, 0, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1]]) == 28\n assert candidate(students = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],mentors = [[0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 24\n assert candidate(students = [[1, 0, 1, 1, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1], [1, 1, 1, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 0]],mentors = [[0, 0, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1]]) == 28\n assert candidate(students = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0]]) == 32\n assert candidate(students = [[1, 0, 1, 1, 0], [0, 1, 0, 1, 0], [1, 1, 1, 0, 1]],mentors = [[0, 1, 0, 0, 1], [1, 0, 1, 1, 0], [0, 1, 1, 0, 0]]) == 11\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 0, 1, 0, 1], [1, 0, 0, 1, 1, 0, 1, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0]]) == 60\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 28\n assert candidate(students = [[1, 1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 30\n assert candidate(students = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]],mentors = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 20\n assert candidate(students = [[1, 1, 0, 0, 1, 0, 1], [0, 0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0]],mentors = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 0, 1, 0], [1, 1, 0, 0, 1, 0, 1]]) == 42\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]],mentors = [[0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 48\n assert candidate(students = [[0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0]],mentors = [[1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1]]) == 36\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]],mentors = [[0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 48\n assert candidate(students = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]],mentors = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(students = [[0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]],mentors = [[1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == 30\n assert candidate(students = [[1, 0, 1, 1, 0, 1], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]],mentors = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 21\n assert candidate(students = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1]],mentors = [[1, 1, 0, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 15\n assert candidate(students = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],mentors = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 25\n assert candidate(students = [[1, 1, 0, 1], [1, 0, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]],mentors = [[0, 1, 1, 0], [1, 0, 0, 1], [1, 1, 0, 1], [0, 0, 1, 0]]) == 15\n assert candidate(students = [[0, 1, 1, 1, 1, 0], [1, 0, 0, 0, 1, 1], [1, 1, 0, 1, 0, 0], [0, 1, 0, 1, 1, 0], [0, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0]],mentors = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0]]) == 28\n assert candidate(students = [[1, 0, 0, 1, 1, 0, 1], [0, 1, 1, 0, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1]],mentors = [[0, 1, 1, 0, 0, 1, 0], [1, 0, 0, 1, 1, 0, 1], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0]]) == 28\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 1, 0, 1, 1, 0, 1]],mentors = [[0, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 48\n assert candidate(students = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 1], [1, 0, 0, 1, 0], [1, 1, 1, 0, 0]]) == 10\n", "comparison": "exact"}, "public_tests": ["[[1,1,0],[1,0,1],[0,0,1]]\n[[1,0,0],[0,0,1],[1,1,0]]", "[[0,0],[0,0],[0,0]]\n[[1,1],[1,1],[1,1]]"], "hints": ["Calculate the compatibility score for each student-mentor pair.", "Try every permutation of students with the original mentors array."], "metadata": {"canonical_parameter_names": ["students", "mentors"], "leetcode_dataset_entry_point": "Solution().maxCompatibilitySum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:35:58+00:00", "tests_total": 68, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming", "backtracking", "bit-manipulation", "bitmask", "hungarian-algorithm", "bipartite-graph", "successive-shortest-path-algorithm", "matching-graph", "perfect-matching", "minimum-cost-flow", "flow-network"]}, "language": "python", "interface": {"raw_signature": "def maxCompatibilitySum(self, students: list[list[int]], mentors: list[list[int]]) -> int:", "container": "Solution", "callable": "maxCompatibilitySum", "parameters": [{"name": "students", "type": "list[list[int]]"}, {"name": "mentors", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1948, "task_id": "delete-duplicate-folders-in-system", "difficulty": "Hard", "problem_description": "Due to a bug, there are many duplicate folders in a file system. You are given a 2D array paths, where paths[i] is an array representing an absolute path to the i^th folder in the file system.\n\n- For example, [\"one\", \"two\", \"three\"] represents the path \"/one/two/three\".\n\nTwo folders (not necessarily on the same level) are identical if they contain the same non-empty set of identical subfolders and underlying subfolder structure. The folders do not need to be at the root level to be identical. If two or more folders are identical, then mark the folders as well as all their subfolders.\n\n- For example, folders \"/a\" and \"/b\" in the file structure below are identical. They (as well as their subfolders) should all be marked:\n - /a\n - /a/x\n - /a/x/y\n - /a/z\n - /b\n - /b/x\n - /b/x/y\n - /b/z\n- However, if the file structure also included the path \"/b/w\", then the folders \"/a\" and \"/b\" would not be identical. Note that \"/a/x\" and \"/b/x\" would still be considered identical even with the added folder.\n\nOnce all the identical folders and their subfolders have been marked, the file system will delete all of them. The file system only runs the deletion once, so any folders that become identical after the initial deletion are not deleted.\n\nReturn the 2D array ans containing the paths of the remaining folders after deleting all the marked folders. The paths may be returned in any order.\n\nExample 1:\n\nInput: paths = [[\"a\"],[\"c\"],[\"d\"],[\"a\",\"b\"],[\"c\",\"b\"],[\"d\",\"a\"]]\nOutput: [[\"d\"],[\"d\",\"a\"]]\nExplanation: The file structure is as shown.\nFolders \"/a\" and \"/c\" (and their subfolders) are marked for deletion because they both contain an empty\nfolder named \"b\".\n\nExample 2:\n\nInput: paths = [[\"a\"],[\"c\"],[\"a\",\"b\"],[\"c\",\"b\"],[\"a\",\"b\",\"x\"],[\"a\",\"b\",\"x\",\"y\"],[\"w\"],[\"w\",\"y\"]]\nOutput: [[\"c\"],[\"c\",\"b\"],[\"a\"],[\"a\",\"b\"]]\nExplanation: The file structure is as shown.\nFolders \"/a/b/x\" and \"/w\" (and their subfolders) are marked for deletion because they both contain an empty folder named \"y\".\nNote that folders \"/a\" and \"/c\" are identical after the deletion, but they are not deleted because they were not marked beforehand.\n\nExample 3:\n\nInput: paths = [[\"a\",\"b\"],[\"c\",\"d\"],[\"c\"],[\"a\"]]\nOutput: [[\"c\"],[\"c\",\"d\"],[\"a\"],[\"a\",\"b\"]]\nExplanation: All folders are unique in the file system.\nNote that the returned array can be in a different order as the order does not matter.\n\nConstraints:\n\n- 1 <= paths.length <= 2 * 10^4\n- 1 <= paths[i].length <= 500\n- 1 <= paths[i][j].length <= 10\n- 1 <= sum(paths[i][j].length) <= 2 * 10^5\n- path[i][j] consists of lowercase English letters.\n- No two paths lead to the same folder.\n- For any folder not at the root level, its parent folder will also be in the input.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(paths=[['project'], ['project', 'src'], ['project', 'src', 'main'], ['project', 'src', 'test'], ['project', 'docs'], ['project', 'docs', 'api'], ['project', 'docs', 'user']]), [['project', 'docs', 'api'], ['project', 'docs', 'user'], ['project', 'docs'], ['project', 'src', 'main'], ['project', 'src', 'test'], ['project', 'src'], ['project']])\n assert answers_match(candidate(paths=[['x'], ['x', 'y'], ['x', 'z'], ['y'], ['y', 'x'], ['z'], ['z', 'x']]), [['x', 'y'], ['x', 'z'], ['x']])\n assert answers_match(candidate(paths=[['a', 'b'], ['c', 'd'], ['c'], ['a']]), [['a', 'b'], ['a'], ['c', 'd'], ['c']])\n assert answers_match(candidate(paths=[['home'], ['home', 'user'], ['home', 'user', 'documents'], ['home', 'guest'], ['home', 'guest', 'documents']]), [['home']])\n assert answers_match(candidate(paths=[['a'], ['a', 'b'], ['a', 'b', 'c'], ['a', 'b', 'c', 'd'], ['a', 'b', 'c', 'd', 'e'], ['f'], ['f', 'g'], ['f', 'g', 'h'], ['f', 'g', 'h', 'i'], ['f', 'g', 'h', 'i', 'j']]), [['a', 'b', 'c', 'd', 'e'], ['a', 'b', 'c', 'd'], ['a', 'b', 'c'], ['a', 'b'], ['a'], ['f', 'g', 'h', 'i', 'j'], ['f', 'g', 'h', 'i'], ['f', 'g', 'h'], ['f', 'g'], ['f']])\n assert answers_match(candidate(paths=[['root'], ['root', 'a'], ['root', 'b'], ['root', 'a', 'x'], ['root', 'b', 'x'], ['root', 'a', 'x', 'y'], ['root', 'b', 'x', 'y']]), [['root']])\n assert answers_match(candidate(paths=[['folder1'], ['folder1', 'sub1'], ['folder1', 'sub2'], ['folder2'], ['folder2', 'sub1'], ['folder2', 'sub2']]), [])\n assert answers_match(candidate(paths=[['a'], ['c'], ['a', 'b'], ['c', 'b'], ['a', 'b', 'x'], ['a', 'b', 'x', 'y'], ['w'], ['w', 'y']]), [['a', 'b'], ['a'], ['c', 'b'], ['c']])\n assert answers_match(candidate(paths=[['x'], ['x', 'y'], ['x', 'y', 'z'], ['x', 'y', 'z', 'w'], ['u'], ['u', 'v'], ['u', 'v', 'w']]), [['u'], ['x', 'y'], ['x']])\n assert answers_match(candidate(paths=[['m'], ['m', 'n'], ['n'], ['n', 'm'], ['m', 'n', 'o'], ['n', 'm', 'o']]), [['m'], ['n']])\n assert answers_match(candidate(paths=[['root'], ['root', 'folder1'], ['root', 'folder2'], ['root', 'folder1', 'subfolder1'], ['root', 'folder2', 'subfolder1']]), [['root']])\n assert answers_match(candidate(paths=[['m'], ['m', 'n'], ['p'], ['p', 'n']]), [])\n assert answers_match(candidate(paths=[['a'], ['c'], ['d'], ['a', 'b'], ['c', 'b'], ['d', 'a']]), [['d', 'a'], ['d']])\n assert answers_match(candidate(paths=[['x'], ['x', 'y'], ['x', 'y', 'z'], ['y'], ['y', 'z']]), [['x']])\n assert answers_match(candidate(paths=[['one'], ['one', 'two'], ['one', 'two', 'three'], ['two'], ['two', 'three']]), [['one']])\n assert answers_match(candidate(paths=[['p'], ['p', 'q'], ['p', 'q', 'r'], ['p', 'q', 'r', 's'], ['p', 'q', 'r', 't'], ['q'], ['q', 'r'], ['q', 'r', 's'], ['q', 'r', 't'], ['r'], ['r', 's'], ['r', 't'], ['s'], ['t'], ['u'], ['u', 'v'], ['u', 'v', 'w'], ['u', 'v', 'w', 'x'], ['u', 'v', 'w', 'y'], ['v'], ['v', 'w'], ['v', 'w', 'x'], ['v', 'w', 'y'], ['w'], ['w', 'x'], ['w', 'y'], ['x'], ['y']]), [['p'], ['s'], ['t'], ['u'], ['x'], ['y']])\n assert answers_match(candidate(paths=[['level1', 'level2', 'level3', 'level4'], ['level1', 'level2', 'level5', 'level4'], ['level1', 'level6', 'level3', 'level4'], ['level1', 'level6', 'level5', 'level4'], ['level1', 'level7', 'level8'], ['level1', 'level9', 'level10', 'level11'], ['level1', 'level9', 'level10', 'level12']]), [['level1', 'level7', 'level8'], ['level1', 'level7'], ['level1', 'level9', 'level10', 'level11'], ['level1', 'level9', 'level10', 'level12'], ['level1', 'level9', 'level10'], ['level1', 'level9'], ['level1']])\n assert answers_match(candidate(paths=[['home', 'user', 'docs'], ['home', 'user', 'photos'], ['home', 'guest', 'docs'], ['home', 'guest', 'photos'], ['home', 'user', 'docs', 'file1'], ['home', 'guest', 'docs', 'file1'], ['home', 'user', 'photos', 'image1'], ['home', 'guest', 'photos', 'image1'], ['home', 'user', 'docs', 'file2'], ['home', 'guest', 'docs', 'file2']]), [['home']])\n assert answers_match(candidate(paths=[['projects', 'proj1'], ['projects', 'proj2'], ['projects', 'proj1', 'src'], ['projects', 'proj2', 'src'], ['projects', 'proj1', 'src', 'main'], ['projects', 'proj2', 'src', 'main'], ['projects', 'proj1', 'src', 'test'], ['projects', 'proj2', 'src', 'test'], ['projects', 'proj1', 'src', 'main', 'file1'], ['projects', 'proj2', 'src', 'main', 'file1'], ['projects', 'proj1', 'src', 'test', 'test1'], ['projects', 'proj2', 'src', 'test', 'test1']]), [['projects']])\n assert answers_match(candidate(paths=[['alpha'], ['alpha', 'beta'], ['alpha', 'beta', 'gamma'], ['alpha', 'beta', 'delta'], ['alpha', 'epsilon'], ['alpha', 'epsilon', 'gamma'], ['alpha', 'epsilon', 'delta'], ['beta'], ['beta', 'gamma'], ['beta', 'delta'], ['epsilon'], ['epsilon', 'gamma'], ['epsilon', 'delta'], ['gamma'], ['delta'], ['charlie'], ['charlie', 'foxtrot'], ['charlie', 'foxtrot', 'gamma'], ['charlie', 'foxtrot', 'delta'], ['charlie', 'tango'], ['charlie', 'tango', 'gamma'], ['charlie', 'tango', 'delta']]), [['alpha'], ['charlie'], ['delta'], ['gamma']])\n assert answers_match(candidate(paths=[['project'], ['project', 'src'], ['project', 'docs'], ['project', 'src', 'main'], ['project', 'src', 'test'], ['project', 'docs', 'api'], ['project', 'docs', 'userguide'], ['project', 'src', 'main', 'java'], ['project', 'src', 'test', 'java'], ['project', 'docs', 'api', 'java'], ['project', 'docs', 'userguide', 'java'], ['project', 'src', 'main', 'java', 'utils'], ['project', 'src', 'test', 'java', 'utils'], ['project', 'docs', 'api', 'java', 'utils'], ['project', 'docs', 'userguide', 'java', 'utils']]), [['project', 'docs'], ['project', 'src'], ['project']])\n assert answers_match(candidate(paths=[['data', 'archive'], ['data', 'archive', '2021'], ['data', 'archive', '2022'], ['data', 'archive', '2023'], ['data', 'backup'], ['data', 'backup', '2021'], ['data', 'backup', '2022'], ['data', 'backup', '2023'], ['data', 'logs'], ['data', 'logs', 'server1'], ['data', 'logs', 'server2'], ['data', 'logs', 'server3'], ['data', 'temp'], ['data', 'temp', 'server1'], ['data', 'temp', 'server2'], ['data', 'temp', 'server3']]), [['data']])\n assert answers_match(candidate(paths=[['root', 'a'], ['root', 'b'], ['root', 'a', 'c'], ['root', 'b', 'c'], ['root', 'a', 'd'], ['root', 'b', 'd'], ['root', 'a', 'c', 'e'], ['root', 'b', 'c', 'e']]), [['root']])\n assert answers_match(candidate(paths=[['home'], ['home', 'user1'], ['home', 'user2'], ['home', 'user1', 'files'], ['home', 'user2', 'files'], ['home', 'user1', 'files', 'docs'], ['home', 'user2', 'files', 'docs'], ['home', 'user1', 'files', 'docs', 'report1'], ['home', 'user2', 'files', 'docs', 'report1'], ['home', 'user1', 'files', 'docs', 'report2'], ['home', 'user2', 'files', 'docs', 'report2']]), [['home']])\n assert answers_match(candidate(paths=[['x'], ['y'], ['z'], ['x', 'a'], ['y', 'a'], ['z', 'a'], ['x', 'a', 'b'], ['y', 'a', 'b'], ['z', 'a', 'b'], ['x', 'a', 'b', 'c'], ['y', 'a', 'b', 'c'], ['z', 'a', 'b', 'c'], ['x', 'd'], ['y', 'e'], ['z', 'f']]), [['x', 'd'], ['x'], ['y', 'e'], ['y'], ['z', 'f'], ['z']])\n assert answers_match(candidate(paths=[['root', 'a', 'b', 'c', 'd'], ['root', 'x', 'y', 'z', 'w'], ['root', 'a', 'b', 'c', 'd', 'e'], ['root', 'x', 'y', 'z', 'w', 'v'], ['root', 'a', 'b', 'f'], ['root', 'x', 'y', 'f'], ['root', 'a', 'g'], ['root', 'x', 'g'], ['root', 'a', 'h'], ['root', 'x', 'h'], ['root', 'a', 'i', 'j'], ['root', 'x', 'i', 'j'], ['root', 'a', 'i', 'k'], ['root', 'x', 'i', 'k']]), [['root', 'a', 'b', 'c', 'd', 'e'], ['root', 'a', 'b', 'c', 'd'], ['root', 'a', 'b', 'c'], ['root', 'a', 'b', 'f'], ['root', 'a', 'b'], ['root', 'a', 'g'], ['root', 'a', 'h'], ['root', 'a'], ['root', 'x', 'g'], ['root', 'x', 'h'], ['root', 'x', 'y', 'f'], ['root', 'x', 'y', 'z', 'w', 'v'], ['root', 'x', 'y', 'z', 'w'], ['root', 'x', 'y', 'z'], ['root', 'x', 'y'], ['root', 'x'], ['root']])\n assert answers_match(candidate(paths=[['root'], ['root', 'folder1'], ['root', 'folder2'], ['root', 'folder1', 'sub1'], ['root', 'folder2', 'sub1'], ['root', 'folder1', 'sub1', 'subsub1'], ['root', 'folder2', 'sub1', 'subsub1']]), [['root']])\n assert answers_match(candidate(paths=[['base'], ['base', 'folder1'], ['base', 'folder1', 'subfolder1'], ['base', 'folder1', 'subfolder2'], ['base', 'folder2'], ['base', 'folder2', 'subfolder1'], ['base', 'folder2', 'subfolder2'], ['base', 'folder3'], ['base', 'folder3', 'subfolder1'], ['base', 'folder3', 'subfolder2'], ['base', 'folder1', 'subfolder1', 'deep1'], ['base', 'folder2', 'subfolder1', 'deep1'], ['base', 'folder3', 'subfolder1', 'deep1']]), [['base']])\n assert answers_match(candidate(paths=[['system'], ['system', 'app1'], ['system', 'app1', 'data'], ['system', 'app2'], ['system', 'app2', 'data'], ['system', 'app3'], ['system', 'app3', 'data'], ['system', 'app3', 'logs'], ['system', 'app4'], ['system', 'app4', 'data'], ['system', 'app4', 'logs'], ['system', 'app4', 'temp'], ['system', 'app5'], ['system', 'app5', 'data'], ['system', 'app5', 'logs'], ['system', 'app5', 'temp'], ['system', 'app6'], ['system', 'app6', 'data'], ['system', 'app6', 'logs'], ['system', 'app6', 'temp'], ['system', 'app6', 'config'], ['system', 'app7'], ['system', 'app7', 'data'], ['system', 'app7', 'logs'], ['system', 'app7', 'temp'], ['system', 'app7', 'config'], ['system', 'app8'], ['system', 'app8', 'data'], ['system', 'app8', 'logs'], ['system', 'app8', 'temp'], ['system', 'app8', 'config'], ['system', 'app8', 'bin']]), [['system', 'app3', 'data'], ['system', 'app3', 'logs'], ['system', 'app3'], ['system', 'app8', 'bin'], ['system', 'app8', 'config'], ['system', 'app8', 'data'], ['system', 'app8', 'logs'], ['system', 'app8', 'temp'], ['system', 'app8'], ['system']])\n assert answers_match(candidate(paths=[['root', 'x'], ['root', 'y'], ['root', 'x', 'z'], ['root', 'y', 'z'], ['root', 'x', 'a'], ['root', 'y', 'a'], ['root', 'x', 'a', 'b'], ['root', 'y', 'a', 'b']]), [['root']])\n assert answers_match(candidate(paths=[['root', 'level1', 'level2', 'level3'], ['root', 'level1', 'level2', 'level4'], ['root', 'level5', 'level6'], ['root', 'level1', 'level2', 'level3', 'level7'], ['root', 'level5', 'level6', 'level7'], ['root', 'level1', 'level2', 'level3', 'level7', 'level8'], ['root', 'level5', 'level6', 'level7', 'level8']]), [['root', 'level1', 'level2', 'level4'], ['root', 'level1', 'level2'], ['root', 'level1'], ['root', 'level5'], ['root']])\n assert answers_match(candidate(paths=[['data'], ['data', 'backup'], ['data', 'backup', '2021'], ['data', 'backup', '2022'], ['data', 'backup', '2021', 'month1'], ['data', 'backup', '2022', 'month1'], ['data', 'backup', '2021', 'month2'], ['data', 'backup', '2022', 'month2'], ['data', 'backup', '2021', 'month1', 'day1'], ['data', 'backup', '2022', 'month1', 'day1'], ['data', 'backup', '2021', 'month1', 'day2'], ['data', 'backup', '2022', 'month1', 'day2'], ['data', 'backup', '2021', 'month2', 'day1'], ['data', 'backup', '2022', 'month2', 'day1'], ['data', 'backup', '2021', 'month2', 'day2'], ['data', 'backup', '2022', 'month2', 'day2'], ['data', 'backup', '2021', 'month1', 'day1', 'file1'], ['data', 'backup', '2022', 'month1', 'day1', 'file1'], ['data', 'backup', '2021', 'month1', 'day2', 'file1'], ['data', 'backup', '2022', 'month1', 'day2', 'file1'], ['data', 'backup', '2021', 'month2', 'day1', 'file1'], ['data', 'backup', '2022', 'month2', 'day1', 'file1'], ['data', 'backup', '2021', 'month2', 'day2', 'file1'], ['data', 'backup', '2022', 'month2', 'day2', 'file1']]), [['data', 'backup'], ['data']])\n assert answers_match(candidate(paths=[['root', 'dir1', 'subdir1'], ['root', 'dir1', 'subdir2'], ['root', 'dir2', 'subdir1'], ['root', 'dir2', 'subdir3'], ['root', 'dir3', 'subdir2'], ['root', 'dir3', 'subdir4']]), [['root', 'dir1', 'subdir1'], ['root', 'dir1', 'subdir2'], ['root', 'dir1'], ['root', 'dir2', 'subdir1'], ['root', 'dir2', 'subdir3'], ['root', 'dir2'], ['root', 'dir3', 'subdir2'], ['root', 'dir3', 'subdir4'], ['root', 'dir3'], ['root']])\n assert answers_match(candidate(paths=[['x'], ['x', 'y'], ['x', 'y', 'z'], ['x', 'y', 'w'], ['y'], ['y', 'z'], ['y', 'w'], ['a'], ['a', 'b'], ['a', 'b', 'c'], ['b'], ['b', 'c'], ['b', 'd'], ['c'], ['c', 'd'], ['d']]), [['a', 'b', 'c'], ['a', 'b'], ['a'], ['b', 'c'], ['b', 'd'], ['b'], ['c', 'd'], ['c'], ['d'], ['x']])\n assert answers_match(candidate(paths=[['base', 'level1', 'level2', 'level3'], ['other', 'level1', 'level2', 'level3'], ['base', 'level1', 'level2', 'level3', 'level4'], ['other', 'level1', 'level2', 'level3', 'level4'], ['base', 'level1', 'level2', 'level3', 'level4', 'level5'], ['other', 'level1', 'level2', 'level3', 'level4', 'level5'], ['base', 'level1', 'level2', 'other'], ['other', 'level1', 'level2', 'other']]), [])\n assert answers_match(candidate(paths=[['home', 'user1', 'documents'], ['home', 'user2', 'documents'], ['home', 'user1', 'documents', 'file1'], ['home', 'user2', 'documents', 'file1'], ['home', 'user1', 'pictures'], ['home', 'user2', 'pictures'], ['home', 'user1', 'pictures', 'photo1'], ['home', 'user2', 'pictures', 'photo1']]), [['home']])\n assert answers_match(candidate(paths=[['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h'], ['a', 'b', 'c', 'd', 'f'], ['f', 'g', 'h', 'i'], ['a', 'b', 'c', 'd', 'j'], ['j', 'k'], ['f', 'g', 'h', 'i', 'k']]), [['a', 'b', 'c', 'd', 'e'], ['a', 'b', 'c', 'd', 'f'], ['a', 'b', 'c', 'd', 'j'], ['a', 'b', 'c', 'd'], ['a', 'b', 'c'], ['a', 'b'], ['a'], ['f', 'g', 'h'], ['f', 'g'], ['f']])\n assert answers_match(candidate(paths=[['root', 'a', 'b', 'c'], ['root', 'x', 'y', 'z'], ['root', 'a', 'b', 'd'], ['root', 'x', 'y', 'd'], ['root', 'a', 'b', 'c', 'e'], ['root', 'x', 'y', 'z', 'e'], ['root', 'a', 'b', 'c', 'f'], ['root', 'x', 'y', 'z', 'f'], ['root', 'a', 'g'], ['root', 'x', 'g'], ['root', 'a', 'h'], ['root', 'x', 'h']]), [['root', 'a', 'b', 'd'], ['root', 'a', 'b'], ['root', 'a', 'g'], ['root', 'a', 'h'], ['root', 'a'], ['root', 'x', 'g'], ['root', 'x', 'h'], ['root', 'x', 'y', 'd'], ['root', 'x', 'y'], ['root', 'x'], ['root']])\n assert answers_match(candidate(paths=[['library', 'books', 'genre1'], ['library', 'books', 'genre2'], ['library', 'books', 'genre3'], ['library', 'books', 'genre1', 'author1'], ['library', 'books', 'genre3', 'author1'], ['library', 'books', 'genre2', 'author2'], ['library', 'books', 'genre3', 'author2'], ['library', 'books', 'genre1', 'author1', 'book1'], ['library', 'books', 'genre3', 'author1', 'book1']]), [['library', 'books', 'genre1'], ['library', 'books', 'genre2', 'author2'], ['library', 'books', 'genre2'], ['library', 'books', 'genre3', 'author2'], ['library', 'books', 'genre3'], ['library', 'books'], ['library']])\n assert answers_match(candidate(paths=[['a'], ['a', 'b'], ['a', 'b', 'c'], ['a', 'b', 'c', 'd'], ['a', 'b', 'c', 'd', 'e'], ['b'], ['b', 'c'], ['b', 'c', 'd'], ['b', 'c', 'd', 'e'], ['c'], ['c', 'd'], ['c', 'd', 'e'], ['d'], ['d', 'e'], ['e']]), [['a'], ['e']])\n assert answers_match(candidate(paths=[['folder1'], ['folder1', 'folder2'], ['folder1', 'folder2', 'folder3'], ['folder1', 'folder2', 'folder3', 'folder4'], ['folder1', 'folder2', 'folder3', 'folder5'], ['folder1', 'folder2', 'folder6'], ['folder1', 'folder2', 'folder6', 'folder7'], ['folder1', 'folder2', 'folder6', 'folder8'], ['folder1', 'folder9'], ['folder1', 'folder9', 'folder10'], ['folder1', 'folder9', 'folder10', 'folder11'], ['folder1', 'folder9', 'folder10', 'folder12'], ['folder1', 'folder9', 'folder13'], ['folder1', 'folder9', 'folder13', 'folder14'], ['folder1', 'folder9', 'folder13', 'folder15']]), [['folder1', 'folder2', 'folder3', 'folder4'], ['folder1', 'folder2', 'folder3', 'folder5'], ['folder1', 'folder2', 'folder3'], ['folder1', 'folder2', 'folder6', 'folder7'], ['folder1', 'folder2', 'folder6', 'folder8'], ['folder1', 'folder2', 'folder6'], ['folder1', 'folder2'], ['folder1', 'folder9', 'folder10', 'folder11'], ['folder1', 'folder9', 'folder10', 'folder12'], ['folder1', 'folder9', 'folder10'], ['folder1', 'folder9', 'folder13', 'folder14'], ['folder1', 'folder9', 'folder13', 'folder15'], ['folder1', 'folder9', 'folder13'], ['folder1', 'folder9'], ['folder1']])\n assert answers_match(candidate(paths=[['projects', 'projectA'], ['projects', 'projectB'], ['projects', 'projectA', 'src'], ['projects', 'projectB', 'src'], ['projects', 'projectA', 'src', 'module1'], ['projects', 'projectB', 'src', 'module1'], ['projects', 'projectA', 'src', 'module2'], ['projects', 'projectB', 'src', 'module2'], ['projects', 'projectA', 'src', 'module1', 'file1'], ['projects', 'projectB', 'src', 'module1', 'file1'], ['projects', 'projectA', 'src', 'module2', 'file2'], ['projects', 'projectB', 'src', 'module2', 'file3'], ['projects', 'projectA', 'src', 'module1', 'file4'], ['projects', 'projectB', 'src', 'module1', 'file5']]), [['projects', 'projectA', 'src', 'module1', 'file1'], ['projects', 'projectA', 'src', 'module1', 'file4'], ['projects', 'projectA', 'src', 'module1'], ['projects', 'projectA', 'src', 'module2', 'file2'], ['projects', 'projectA', 'src', 'module2'], ['projects', 'projectA', 'src'], ['projects', 'projectA'], ['projects', 'projectB', 'src', 'module1', 'file1'], ['projects', 'projectB', 'src', 'module1', 'file5'], ['projects', 'projectB', 'src', 'module1'], ['projects', 'projectB', 'src', 'module2', 'file3'], ['projects', 'projectB', 'src', 'module2'], ['projects', 'projectB', 'src'], ['projects', 'projectB'], ['projects']])\n assert answers_match(candidate(paths=[['dir1'], ['dir2'], ['dir3'], ['dir1', 'sub1'], ['dir2', 'sub2'], ['dir3', 'sub1'], ['dir1', 'sub1', 'subsub1'], ['dir2', 'sub2', 'subsub2'], ['dir3', 'sub1', 'subsub1'], ['dir1', 'sub1', 'subsub1', 'deeper1'], ['dir3', 'sub1', 'subsub1', 'deeper1']]), [['dir2', 'sub2', 'subsub2'], ['dir2', 'sub2'], ['dir2']])\n assert answers_match(candidate(paths=[['a'], ['a', 'b'], ['a', 'b', 'c'], ['a', 'b', 'd'], ['b'], ['b', 'c'], ['b', 'd'], ['c'], ['c', 'a'], ['c', 'a', 'b'], ['d'], ['d', 'a'], ['d', 'a', 'b']]), [['a']])\n assert answers_match(candidate(paths=[['folderA'], ['folderB'], ['folderA', 'subA'], ['folderB', 'subA'], ['folderA', 'subA', 'subsubA'], ['folderB', 'subA', 'subsubA'], ['folderC'], ['folderC', 'subB'], ['folderD'], ['folderD', 'subB', 'subsubB'], ['folderE'], ['folderE', 'subB', 'subsubB', 'deepB']]), [['folderC', 'subB'], ['folderC'], ['folderD', 'subB', 'subsubB'], ['folderD', 'subB'], ['folderD'], ['folderE', 'subB', 'subsubB', 'deepB'], ['folderE', 'subB', 'subsubB'], ['folderE', 'subB'], ['folderE']])\n assert answers_match(candidate(paths=[['main'], ['main', 'projects'], ['main', 'projects', 'project1'], ['main', 'projects', 'project2'], ['main', 'projects', 'project1', 'code'], ['main', 'projects', 'project2', 'code'], ['main', 'docs'], ['main', 'docs', 'project1'], ['main', 'docs', 'project2'], ['main', 'docs', 'project1', 'notes'], ['main', 'docs', 'project2', 'notes']]), [['main', 'docs'], ['main', 'projects'], ['main']])\n assert answers_match(candidate(paths=[['folder1', 'subfolder1', 'deepsub1'], ['folder2', 'subfolder2', 'deepsub2'], ['folder1', 'subfolder1', 'deepsub3'], ['folder2', 'subfolder2', 'deepsub3'], ['folder1', 'subfolder2'], ['folder2', 'subfolder2'], ['folder3', 'subfolder3']]), [['folder1', 'subfolder1', 'deepsub1'], ['folder1', 'subfolder1', 'deepsub3'], ['folder1', 'subfolder1'], ['folder1', 'subfolder2'], ['folder1'], ['folder2', 'subfolder2', 'deepsub2'], ['folder2', 'subfolder2', 'deepsub3'], ['folder2', 'subfolder2'], ['folder2'], ['folder3', 'subfolder3'], ['folder3']])\n assert answers_match(candidate(paths=[['root', 'a', 'x'], ['root', 'b', 'x'], ['root', 'a', 'y'], ['root', 'b', 'y'], ['root', 'a', 'x', 'z'], ['root', 'b', 'x', 'z'], ['root', 'a', 'w'], ['root', 'b', 'w']]), [['root']])\n assert answers_match(candidate(paths=[['a', 'b', 'c'], ['a', 'd', 'e'], ['a', 'd', 'e', 'f'], ['g', 'h', 'i'], ['g', 'j', 'k'], ['g', 'j', 'l'], ['a', 'b', 'c', 'm'], ['g', 'h', 'i', 'm'], ['n', 'o', 'p'], ['n', 'o', 'q'], ['n', 'r', 's'], ['n', 'r', 's', 't']]), [['a', 'b'], ['a', 'd', 'e', 'f'], ['a', 'd', 'e'], ['a', 'd'], ['a'], ['g', 'h'], ['g', 'j', 'k'], ['g', 'j', 'l'], ['g', 'j'], ['g'], ['n', 'o', 'p'], ['n', 'o', 'q'], ['n', 'o'], ['n', 'r', 's', 't'], ['n', 'r', 's'], ['n', 'r'], ['n']])\n assert answers_match(candidate(paths=[['x'], ['x', 'y'], ['x', 'y', 'z'], ['x', 'y', 'z', 'w'], ['y'], ['y', 'z'], ['y', 'z', 'w'], ['z'], ['z', 'w'], ['w']]), [['w'], ['x']])\n assert answers_match(candidate(paths=[['main', 'branch1'], ['main', 'branch2'], ['main', 'branch1', 'sub1'], ['main', 'branch2', 'sub1'], ['main', 'branch1', 'sub2'], ['main', 'branch2', 'sub2'], ['main', 'branch1', 'sub1', 'subsub1'], ['main', 'branch2', 'sub1', 'subsub1'], ['main', 'branch1', 'sub1', 'subsub2'], ['main', 'branch2', 'sub1', 'subsub2']]), [['main']])\n assert answers_match(candidate(paths=[['x'], ['y'], ['z'], ['x', 'a'], ['y', 'a'], ['z', 'a'], ['x', 'a', 'b'], ['y', 'a', 'b'], ['x', 'a', 'b', 'c'], ['y', 'a', 'b', 'c'], ['w'], ['w', 'd'], ['w', 'd', 'e'], ['w', 'd', 'e', 'f'], ['v'], ['v', 'd'], ['v', 'd', 'e'], ['v', 'd', 'e', 'f']]), [['z', 'a'], ['z']])\n assert answers_match(candidate(paths=[['level1'], ['level1', 'level2'], ['level1', 'level2', 'level3'], ['level1', 'level2', 'level3', 'level4'], ['level1', 'level2', 'level3', 'level4', 'level5'], ['levelA'], ['levelA', 'level2'], ['levelA', 'level2', 'level3'], ['levelA', 'level2', 'level3', 'level4'], ['levelA', 'level2', 'level3', 'level4', 'level5']]), [])\n assert answers_match(candidate(paths=[['root'], ['root', 'dir1'], ['root', 'dir1', 'subdir1'], ['root', 'dir2'], ['root', 'dir2', 'subdir1'], ['root', 'dir2', 'subdir2'], ['root', 'dir3'], ['root', 'dir3', 'subdir2'], ['root', 'dir4'], ['root', 'dir4', 'subdir1'], ['root', 'dir4', 'subdir2']]), [['root', 'dir1', 'subdir1'], ['root', 'dir1'], ['root', 'dir3', 'subdir2'], ['root', 'dir3'], ['root']])\n assert answers_match(candidate(paths=[['home', 'user1', 'docs'], ['home', 'user2', 'docs'], ['home', 'user1', 'music'], ['home', 'user2', 'music'], ['home', 'user1', 'docs', 'report'], ['home', 'user2', 'docs', 'report'], ['home', 'user1', 'music', 'song1'], ['home', 'user2', 'music', 'song2'], ['home', 'user1', 'docs', 'report', 'summary'], ['home', 'user2', 'docs', 'report', 'summary'], ['home', 'user1', 'docs', 'report', 'summary', 'details'], ['home', 'user2', 'docs', 'report', 'summary', 'details']]), [['home', 'user1', 'music', 'song1'], ['home', 'user1', 'music'], ['home', 'user1'], ['home', 'user2', 'music', 'song2'], ['home', 'user2', 'music'], ['home', 'user2'], ['home']])\n assert answers_match(candidate(paths=[['projects', 'proj1', 'src'], ['projects', 'proj2', 'src'], ['projects', 'proj3'], ['projects', 'proj1', 'src', 'main'], ['projects', 'proj2', 'src', 'main'], ['projects', 'proj1', 'docs'], ['projects', 'proj2', 'docs'], ['projects', 'proj3', 'docs']]), [['projects', 'proj3', 'docs'], ['projects', 'proj3'], ['projects']])\n assert answers_match(candidate(paths=[['alpha'], ['beta'], ['gamma'], ['alpha', 'delta'], ['beta', 'delta'], ['gamma', 'epsilon'], ['alpha', 'delta', 'zeta'], ['beta', 'delta', 'zeta'], ['alpha', 'delta', 'zeta', 'eta'], ['beta', 'delta', 'zeta', 'eta'], ['alpha', 'theta'], ['beta', 'theta'], ['gamma', 'theta']]), [['gamma', 'epsilon'], ['gamma', 'theta'], ['gamma']])\n assert answers_match(candidate(paths=[['project'], ['project', 'module1'], ['project', 'module1', 'file1'], ['project', 'module2'], ['project', 'module2', 'file1'], ['project', 'module3'], ['project', 'module3', 'file2'], ['project', 'module4'], ['project', 'module4', 'file3'], ['project', 'module5'], ['project', 'module5', 'file3'], ['project', 'module6'], ['project', 'module6', 'file4'], ['project', 'module7'], ['project', 'module7', 'file4'], ['project', 'module8'], ['project', 'module8', 'file5'], ['project', 'module8', 'file6']]), [['project', 'module3', 'file2'], ['project', 'module3'], ['project', 'module8', 'file5'], ['project', 'module8', 'file6'], ['project', 'module8'], ['project']])\n assert answers_match(candidate(paths=[['app', 'module1', 'service1'], ['app', 'module2', 'service2'], ['app', 'module3', 'service1'], ['app', 'module4', 'service4'], ['app', 'module1', 'service1', 'endpoint1'], ['app', 'module3', 'service1', 'endpoint1'], ['app', 'module5'], ['app', 'module5', 'endpoint2']]), [['app', 'module2', 'service2'], ['app', 'module2'], ['app', 'module4', 'service4'], ['app', 'module4'], ['app', 'module5', 'endpoint2'], ['app', 'module5'], ['app']])\n assert answers_match(candidate(paths=[['root', 'dir1', 'subdir1'], ['root', 'dir2', 'subdir1'], ['root', 'dir1', 'subdir2'], ['root', 'dir2', 'subdir2'], ['root', 'dir1', 'subdir1', 'subsubdir1'], ['root', 'dir2', 'subdir1', 'subsubdir1'], ['root', 'dir1', 'subdir3'], ['root', 'dir2', 'subdir3']]), [['root']])\n assert answers_match(candidate(paths=[['root'], ['root', 'child1'], ['root', 'child2'], ['root', 'child1', 'sub1'], ['root', 'child2', 'sub1'], ['root', 'child1', 'sub1', 'subsub1'], ['root', 'child2', 'sub1', 'subsub1'], ['root', 'child1', 'sub2'], ['root', 'child2', 'sub2'], ['root', 'child1', 'sub2', 'subsub2'], ['root', 'child2', 'sub2', 'subsub2'], ['root', 'child3'], ['root', 'child3', 'sub1'], ['root', 'child3', 'sub1', 'subsub1'], ['root', 'child3', 'sub2'], ['root', 'child3', 'sub2', 'subsub2']]), [['root']])\n assert answers_match(candidate(paths=[['home'], ['home', 'user1'], ['home', 'user1', 'documents'], ['home', 'user1', 'pictures'], ['home', 'user2'], ['home', 'user2', 'documents'], ['home', 'user2', 'pictures'], ['home', 'user3'], ['home', 'user3', 'documents'], ['home', 'user3', 'pictures'], ['home', 'user3', 'videos'], ['home', 'user4'], ['home', 'user4', 'documents'], ['home', 'user4', 'pictures'], ['home', 'user4', 'videos'], ['home', 'user5'], ['home', 'user5', 'documents'], ['home', 'user5', 'pictures'], ['home', 'user5', 'videos'], ['home', 'user6'], ['home', 'user6', 'documents'], ['home', 'user6', 'pictures'], ['home', 'user6', 'videos'], ['home', 'user6', 'music']]), [['home', 'user6', 'documents'], ['home', 'user6', 'music'], ['home', 'user6', 'pictures'], ['home', 'user6', 'videos'], ['home', 'user6'], ['home']])\n assert answers_match(candidate(paths=[['documents', 'work', 'reports'], ['documents', 'work', 'reports', 'monthly'], ['documents', 'work', 'reports', 'monthly', 'jan'], ['documents', 'work', 'reports', 'monthly', 'feb'], ['documents', 'work', 'reports', 'monthly', 'mar'], ['documents', 'home', 'reports'], ['documents', 'home', 'reports', 'monthly'], ['documents', 'home', 'reports', 'monthly', 'jan'], ['documents', 'home', 'reports', 'monthly', 'feb'], ['documents', 'home', 'reports', 'monthly', 'mar'], ['documents', 'finance', 'reports'], ['documents', 'finance', 'reports', 'monthly'], ['documents', 'finance', 'reports', 'monthly', 'jan'], ['documents', 'finance', 'reports', 'monthly', 'feb'], ['documents', 'finance', 'reports', 'monthly', 'mar']]), [['documents']])\n assert answers_match(candidate(paths=[['root', 'folder1', 'sub1'], ['root', 'folder2', 'sub1'], ['root', 'folder1', 'sub2'], ['root', 'folder2', 'sub2'], ['root', 'folder3', 'sub1'], ['root', 'folder4', 'sub1'], ['root', 'folder3', 'sub3'], ['root', 'folder4', 'sub3']]), [['root']])\n assert answers_match(candidate(paths=[['home', 'user1', 'docs', 'work'], ['home', 'user2', 'docs', 'work'], ['home', 'user1', 'docs', 'projects'], ['home', 'user2', 'docs', 'projects'], ['home', 'user1', 'downloads', 'movies'], ['home', 'user2', 'downloads', 'movies'], ['home', 'user1', 'downloads', 'music'], ['home', 'user2', 'downloads', 'music'], ['home', 'user1', 'pictures', 'vacation'], ['home', 'user2', 'pictures', 'vacation'], ['home', 'user1', 'pictures', 'wedding'], ['home', 'user2', 'pictures', 'wedding']]), [['home']])\n assert answers_match(candidate(paths=[['library'], ['library', 'section1'], ['library', 'section1', 'shelf1'], ['library', 'section1', 'shelf2'], ['library', 'section1', 'shelf3'], ['library', 'section2'], ['library', 'section2', 'shelf1'], ['library', 'section2', 'shelf2'], ['library', 'section2', 'shelf4'], ['library', 'section3'], ['library', 'section3', 'shelf3'], ['library', 'section3', 'shelf4'], ['library', 'section4'], ['library', 'section4', 'shelf5'], ['library', 'section4', 'shelf6'], ['library', 'section5'], ['library', 'section5', 'shelf5'], ['library', 'section5', 'shelf6'], ['library', 'section6'], ['library', 'section6', 'shelf7'], ['library', 'section6', 'shelf8'], ['library', 'section7'], ['library', 'section7', 'shelf9'], ['library', 'section7', 'shelf10']]), [['library', 'section1', 'shelf1'], ['library', 'section1', 'shelf2'], ['library', 'section1', 'shelf3'], ['library', 'section1'], ['library', 'section2', 'shelf1'], ['library', 'section2', 'shelf2'], ['library', 'section2', 'shelf4'], ['library', 'section2'], ['library', 'section3', 'shelf3'], ['library', 'section3', 'shelf4'], ['library', 'section3'], ['library', 'section6', 'shelf7'], ['library', 'section6', 'shelf8'], ['library', 'section6'], ['library', 'section7', 'shelf10'], ['library', 'section7', 'shelf9'], ['library', 'section7'], ['library']])\n assert answers_match(candidate(paths=[['home'], ['home', 'user1'], ['home', 'user2'], ['home', 'user1', 'documents'], ['home', 'user2', 'documents'], ['home', 'user1', 'pictures'], ['home', 'user2', 'pictures'], ['home', 'user1', 'documents', 'work'], ['home', 'user2', 'documents', 'work'], ['home', 'user1', 'documents', 'personal'], ['home', 'user2', 'documents', 'personal'], ['home', 'user1', 'pictures', 'vacation'], ['home', 'user2', 'pictures', 'vacation'], ['home', 'user1', 'pictures', 'travel'], ['home', 'user2', 'pictures', 'travel'], ['home', 'user1', 'pictures', 'travel', '2022'], ['home', 'user2', 'pictures', 'travel', '2022']]), [['home']])\n assert answers_match(candidate(paths=[['root'], ['root', 'dir1'], ['root', 'dir2'], ['root', 'dir1', 'dir3'], ['root', 'dir2', 'dir4'], ['root', 'dir2', 'dir3'], ['root', 'dir1', 'dir3', 'dir5'], ['root', 'dir2', 'dir3', 'dir5']]), [['root', 'dir1'], ['root', 'dir2', 'dir4'], ['root', 'dir2'], ['root']])\n", "comparison": "unordered"}, "public_tests": ["[[\"a\"],[\"c\"],[\"d\"],[\"a\",\"b\"],[\"c\",\"b\"],[\"d\",\"a\"]]", "[[\"a\"],[\"c\"],[\"a\",\"b\"],[\"c\",\"b\"],[\"a\",\"b\",\"x\"],[\"a\",\"b\",\"x\",\"y\"],[\"w\"],[\"w\",\"y\"]]", "[[\"a\",\"b\"],[\"c\",\"d\"],[\"c\"],[\"a\"]]"], "hints": ["Can we use a trie to build the folder structure?", "Can we utilize hashing to hash the folder structures?"], "metadata": {"canonical_parameter_names": ["paths"], "leetcode_dataset_entry_point": "Solution().deleteDuplicateFolder", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:01+00:00", "tests_total": 76, "tests_dropped": 8, "flags": ["any_order", "has_images"], "topic_tags": ["array", "hash-table", "string", "depth-first-search", "trie", "sorting", "hash-function"]}, "language": "python", "interface": {"raw_signature": "def deleteDuplicateFolder(self, paths: list[list[str]]) -> list[list[str]]:", "container": "Solution", "callable": "deleteDuplicateFolder", "parameters": [{"name": "paths", "type": "list[list[str]]"}], "return_type": "list[list[str]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1952, "task_id": "three-divisors", "difficulty": "Easy", "problem_description": "Given an integer n, return true if n has exactly three positive divisors. Otherwise, return false.\n\nAn integer m is a divisor of n if there exists an integer k such that n = k * m.\n\nExample 1:\n\nInput: n = 2\nOutput: false\nExplantion: 2 has only two divisors: 1 and 2.\n\nExample 2:\n\nInput: n = 4\nOutput: true\nExplantion: 4 has three divisors: 1, 2, and 4.\n\nConstraints:\n\n- 1 <= n <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 625) == False\n assert candidate(n = 3) == False\n assert candidate(n = 576) == False\n assert candidate(n = 729) == False\n assert candidate(n = 144) == False\n assert candidate(n = 49) == True\n assert candidate(n = 900) == False\n assert candidate(n = 324) == False\n assert candidate(n = 100) == False\n assert candidate(n = 841) == True\n assert candidate(n = 5) == False\n assert candidate(n = 289) == True\n assert candidate(n = 4) == True\n assert candidate(n = 64) == False\n assert candidate(n = 16) == False\n assert candidate(n = 10000) == False\n assert candidate(n = 484) == False\n assert candidate(n = 2) == False\n assert candidate(n = 225) == False\n assert candidate(n = 784) == False\n assert candidate(n = 1024) == False\n assert candidate(n = 101) == False\n assert candidate(n = 169) == True\n assert candidate(n = 256) == False\n assert candidate(n = 36) == False\n assert candidate(n = 529) == True\n assert candidate(n = 20) == False\n assert candidate(n = 676) == False\n assert candidate(n = 81) == False\n assert candidate(n = 15) == False\n assert candidate(n = 961) == True\n assert candidate(n = 400) == False\n assert candidate(n = 9) == True\n assert candidate(n = 196) == False\n assert candidate(n = 121) == True\n assert candidate(n = 361) == True\n assert candidate(n = 441) == False\n assert candidate(n = 7) == False\n assert candidate(n = 10) == False\n assert candidate(n = 25) == True\n assert candidate(n = 1089) == False\n assert candidate(n = 7225) == False\n assert candidate(n = 5929) == False\n assert candidate(n = 4761) == False\n assert candidate(n = 27) == False\n assert candidate(n = 6241) == True\n assert candidate(n = 8821) == False\n assert candidate(n = 2809) == True\n assert candidate(n = 1) == False\n assert candidate(n = 9604) == False\n assert candidate(n = 2601) == False\n assert candidate(n = 5329) == True\n assert candidate(n = 3025) == False\n assert candidate(n = 1009) == False\n assert candidate(n = 1681) == True\n assert candidate(n = 1225) == False\n assert candidate(n = 7921) == True\n assert candidate(n = 2401) == False\n assert candidate(n = 2025) == False\n assert candidate(n = 5625) == False\n assert candidate(n = 4489) == True\n assert candidate(n = 2209) == True\n assert candidate(n = 4225) == False\n assert candidate(n = 3969) == False\n assert candidate(n = 343) == False\n assert candidate(n = 6561) == False\n assert candidate(n = 5041) == True\n assert candidate(n = 8361) == False\n assert candidate(n = 1849) == True\n assert candidate(n = 3481) == True\n assert candidate(n = 6889) == True\n assert candidate(n = 1369) == True\n assert candidate(n = 7569) == False\n assert candidate(n = 3721) == True\n assert candidate(n = 3249) == False\n assert candidate(n = 9409) == True\n assert candidate(n = 9216) == False\n assert candidate(n = 1521) == False\n", "comparison": "exact"}, "public_tests": ["2", "4"], "hints": ["You can count the number of divisors and just check that they are 3", "Beware of the case of n equal 1 as some solutions might fail in it"], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().isThree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:06+00:00", "tests_total": 144, "tests_dropped": 66, "flags": [], "topic_tags": ["math", "enumeration", "number-theory", "prime-factorization", "sieve-theory"]}, "language": "python", "interface": {"raw_signature": "def isThree(self, n: int) -> bool:", "container": "Solution", "callable": "isThree", "parameters": [{"name": "n", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1953, "task_id": "maximum-number-of-weeks-for-which-you-can-work", "difficulty": "Medium", "problem_description": "There are n projects numbered from 0 to n - 1. You are given an integer array milestones where each milestones[i] denotes the number of milestones the i^th project has.\n\nYou can work on the projects following these two rules:\n\n- Every week, you will finish exactly one milestone of one project. You must work every week.\n- You cannot work on two milestones from the same project for two consecutive weeks.\n\nOnce all the milestones of all the projects are finished, or if the only milestones that you can work on will cause you to violate the above rules, you will stop working. Note that you may not be able to finish every project's milestones due to these constraints.\n\nReturn the maximum number of weeks you would be able to work on the projects without violating the rules mentioned above.\n\nExample 1:\n\nInput: milestones = [1,2,3]\nOutput: 6\nExplanation: One possible scenario is:\n- During the 1^st week, you will work on a milestone of project 0.\n- During the 2^nd week, you will work on a milestone of project 2.\n- During the 3^rd week, you will work on a milestone of project 1.\n- During the 4^th week, you will work on a milestone of project 2.\n- During the 5^th week, you will work on a milestone of project 1.\n- During the 6^th week, you will work on a milestone of project 2.\nThe total number of weeks is 6.\n\nExample 2:\n\nInput: milestones = [5,2,1]\nOutput: 7\nExplanation: One possible scenario is:\n- During the 1^st week, you will work on a milestone of project 0.\n- During the 2^nd week, you will work on a milestone of project 1.\n- During the 3^rd week, you will work on a milestone of project 0.\n- During the 4^th week, you will work on a milestone of project 1.\n- During the 5^th week, you will work on a milestone of project 0.\n- During the 6^th week, you will work on a milestone of project 2.\n- During the 7^th week, you will work on a milestone of project 0.\nThe total number of weeks is 7.\nNote that you cannot work on the last milestone of project 0 on 8^th week because it would violate the rules.\nThus, one milestone in project 0 will remain unfinished.\n\nConstraints:\n\n- n == milestones.length\n- 1 <= n <= 10^5\n- 1 <= milestones[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(milestones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(milestones = [3, 3, 3]) == 9\n assert candidate(milestones = [1, 1, 1, 1, 1]) == 5\n assert candidate(milestones = [10, 5, 1]) == 13\n assert candidate(milestones = [1000000000, 1, 1]) == 5\n assert candidate(milestones = [1, 2, 3]) == 6\n assert candidate(milestones = [5, 2, 1]) == 7\n assert candidate(milestones = [1000000000, 1000000000, 1000000000]) == 3000000000\n assert candidate(milestones = [1, 1, 1000000000]) == 5\n assert candidate(milestones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(milestones = [1]) == 1\n assert candidate(milestones = [1, 1000000000]) == 3\n assert candidate(milestones = [5, 5, 5, 5, 5, 5]) == 30\n assert candidate(milestones = [10, 1, 1]) == 5\n assert candidate(milestones = [1, 1000000000, 1]) == 5\n assert candidate(milestones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1200\n assert candidate(milestones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(milestones = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 200\n assert candidate(milestones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\n assert candidate(milestones = [1000000000, 1000000000, 1000000000]) == 3000000000\n assert candidate(milestones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 150\n assert candidate(milestones = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(milestones = [1000000000, 500000000, 100000000, 50000000, 10000000, 5000000, 1000000, 500000, 100000, 50000, 10000, 5000, 1000, 500, 100, 50, 10, 5, 1]) == 1333333333\n assert candidate(milestones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(milestones = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 10000\n assert candidate(milestones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(milestones = [1000000000, 999999999, 1, 2, 3, 4, 5]) == 2000000014\n assert candidate(milestones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(milestones = [100, 200, 300, 400]) == 1000\n assert candidate(milestones = [1000000000, 999999999, 888888888]) == 2888888887\n assert candidate(milestones = [1, 2, 3, 4, 5]) == 15\n assert candidate(milestones = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]) == 1596\n assert candidate(milestones = [500000000, 500000000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000000009\n assert candidate(milestones = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 1000\n assert candidate(milestones = [10, 10, 10, 10, 10, 10, 10, 10, 10, 100]) == 181\n assert candidate(milestones = [10, 10, 10, 10, 10]) == 50\n assert candidate(milestones = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 550\n assert candidate(milestones = [999999999, 1, 1, 1]) == 7\n assert candidate(milestones = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 550000\n assert candidate(milestones = [1000000000, 1000000000, 1000000000, 1]) == 3000000001\n assert candidate(milestones = [10, 20, 30, 40, 50]) == 150\n assert candidate(milestones = [5, 5, 5, 5, 5, 5]) == 30\n assert candidate(milestones = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == 5000000001\n assert candidate(milestones = [10, 20, 30, 40, 50]) == 150\n assert candidate(milestones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(milestones = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(milestones = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == 10000000001\n assert candidate(milestones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 64\n assert candidate(milestones = [100, 99, 98, 97, 96, 95]) == 585\n assert candidate(milestones = [999999999, 999999999, 1]) == 1999999999\n assert candidate(milestones = [1000000000, 500000000, 250000000, 125000000]) == 1750000001\n assert candidate(milestones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 32767\n assert candidate(milestones = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 90\n assert candidate(milestones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5500\n assert candidate(milestones = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 5500\n assert candidate(milestones = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 9999999945\n assert candidate(milestones = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 39\n assert candidate(milestones = [1000000000, 1000000000, 1000000000, 1000000000, 1]) == 4000000001\n assert candidate(milestones = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 101\n assert candidate(milestones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 40\n assert candidate(milestones = [2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1]) == 35\n assert candidate(milestones = [500000000, 500000000, 1]) == 1000000001\n assert candidate(milestones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 80\n assert candidate(milestones = [999999999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 39\n assert candidate(milestones = [100, 150, 200, 250]) == 700\n assert candidate(milestones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 50\n assert candidate(milestones = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 77\n assert candidate(milestones = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 110\n assert candidate(milestones = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]) == 1597\n assert candidate(milestones = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000]) == 4000000003\n assert candidate(milestones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(milestones = [500000000, 500000000, 500000000, 500000000]) == 2000000000\n assert candidate(milestones = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(milestones = [1, 2, 4, 8, 16, 32, 64]) == 127\n assert candidate(milestones = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711]) == 46365\n assert candidate(milestones = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]) == 680\n assert candidate(milestones = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]) == 376\n assert candidate(milestones = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 30\n assert candidate(milestones = [333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333]) == 3333333330\n assert candidate(milestones = [100, 1, 100, 1, 100, 1]) == 303\n", "comparison": "exact"}, "public_tests": ["[1,2,3]", "[5,2,1]"], "hints": ["Work on the project with the largest number of milestones as long as it is possible.", "Does the project with the largest number of milestones affect the number of weeks?"], "metadata": {"canonical_parameter_names": ["milestones"], "leetcode_dataset_entry_point": "Solution().numberOfWeeks", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:09+00:00", "tests_total": 80, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def numberOfWeeks(self, milestones: list[int]) -> int:", "container": "Solution", "callable": "numberOfWeeks", "parameters": [{"name": "milestones", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1954, "task_id": "minimum-garden-perimeter-to-collect-enough-apples", "difficulty": "Medium", "problem_description": "In a garden represented as an infinite 2D grid, there is an apple tree planted at every integer coordinate. The apple tree planted at an integer coordinate (i, j) has |i| + |j| apples growing on it.\n\nYou will buy an axis-aligned square plot of land that is centered at (0, 0).\n\nGiven an integer neededApples, return the minimum perimeter of a plot such that at least neededApples apples are inside or on the perimeter of that plot.\n\nThe value of |x| is defined as:\n\n- x if x >= 0\n- -x if x < 0\n\nExample 1:\n\nInput: neededApples = 1\nOutput: 8\nExplanation: A square plot of side length 1 does not contain any apples.\nHowever, a square plot of side length 2 has 12 apples inside (as depicted in the image above).\nThe perimeter is 2 * 4 = 8.\n\nExample 2:\n\nInput: neededApples = 13\nOutput: 16\n\nExample 3:\n\nInput: neededApples = 1000000000\nOutput: 5040\n\nConstraints:\n\n- 1 <= neededApples <= 10^15\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(neededApples = 10000000000) == 10856\n assert candidate(neededApples = 10) == 8\n assert candidate(neededApples = 50) == 16\n assert candidate(neededApples = 1000000) == 504\n assert candidate(neededApples = 13) == 16\n assert candidate(neededApples = 1000000000) == 5040\n assert candidate(neededApples = 1000000000000000) == 503968\n assert candidate(neededApples = 1000) == 48\n assert candidate(neededApples = 987654321) == 5016\n assert candidate(neededApples = 1000000000000) == 50400\n assert candidate(neededApples = 999999999999999) == 503968\n assert candidate(neededApples = 100) == 24\n assert candidate(neededApples = 100000000) == 2336\n assert candidate(neededApples = 123456789) == 2512\n assert candidate(neededApples = 1) == 8\n assert candidate(neededApples = 2000000000) == 6352\n assert candidate(neededApples = 50000000000) == 18568\n assert candidate(neededApples = 123456789012345) == 250944\n assert candidate(neededApples = 1000000001) == 5040\n assert candidate(neededApples = 10000) == 112\n assert candidate(neededApples = 5000000000) == 8616\n assert candidate(neededApples = 50000) == 184\n assert candidate(neededApples = 120) == 24\n assert candidate(neededApples = 5) == 8\n assert candidate(neededApples = 6) == 8\n assert candidate(neededApples = 20) == 16\n assert candidate(neededApples = 2000000000000) == 63496\n assert candidate(neededApples = 100000000000) == 23392\n assert candidate(neededApples = 2147483647) == 6504\n assert candidate(neededApples = 100000) == 232\n assert candidate(neededApples = 123456789123) == 25096\n assert candidate(neededApples = 987654321987) == 50192\n assert candidate(neededApples = 2500000000) == 6840\n assert candidate(neededApples = 468) == 40\n assert candidate(neededApples = 500000000000) == 40000\n assert candidate(neededApples = 20736) == 136\n assert candidate(neededApples = 256) == 32\n assert candidate(neededApples = 500000000000000) == 400000\n assert candidate(neededApples = 111111111111111) == 242280\n assert candidate(neededApples = 8000000000) == 10080\n assert candidate(neededApples = 12) == 8\n assert candidate(neededApples = 122500) == 248\n assert candidate(neededApples = 25200) == 144\n assert candidate(neededApples = 598593750000) == 42472\n assert candidate(neededApples = 9261000) == 1056\n assert candidate(neededApples = 754321098) == 4584\n assert candidate(neededApples = 876543210987654) == 482312\n assert candidate(neededApples = 100000000000000) == 233920\n assert candidate(neededApples = 400000000000000) == 371328\n assert candidate(neededApples = 987654321098765) == 501888\n assert candidate(neededApples = 5000) == 88\n assert candidate(neededApples = 10000000000000) == 108576\n assert candidate(neededApples = 3500) == 80\n assert candidate(neededApples = 1024) == 48\n assert candidate(neededApples = 18) == 16\n assert candidate(neededApples = 30000000000000) == 156592\n assert candidate(neededApples = 2) == 8\n assert candidate(neededApples = 500) == 40\n assert candidate(neededApples = 4) == 8\n assert candidate(neededApples = 3) == 8\n assert candidate(neededApples = 4608) == 80\n", "comparison": "exact"}, "public_tests": ["1", "13", "1000000000"], "hints": ["Find a formula for the number of apples inside a square with a side length L.", "Iterate over the possible lengths of the square until enough apples are collected."], "metadata": {"canonical_parameter_names": ["neededApples"], "leetcode_dataset_entry_point": "Solution().minimumPerimeter", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:11+00:00", "tests_total": 68, "tests_dropped": 7, "flags": ["figure_reference", "has_images"], "topic_tags": ["math", "binary-search"]}, "language": "python", "interface": {"raw_signature": "def minimumPerimeter(self, neededApples: int) -> int:", "container": "Solution", "callable": "minimumPerimeter", "parameters": [{"name": "neededApples", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1955, "task_id": "count-number-of-special-subsequences", "difficulty": "Hard", "problem_description": "A sequence is special if it consists of a positive number of 0s, followed by a positive number of 1s, then a positive number of 2s.\n\n- For example, [0,1,2] and [0,0,1,1,1,2] are special.\n- In contrast, [2,1,0], [1], and [0,1,2,0] are not special.\n\nGiven an array nums (consisting of only integers 0, 1, and 2), return the number of different subsequences that are special. Since the answer may be very large, return it modulo 10^9 + 7.\n\nA subsequence of an array is a sequence that can be derived from the array by deleting some or no elements without changing the order of the remaining elements. Two subsequences are different if the set of indices chosen are different.\n\nExample 1:\n\nInput: nums = [0,1,2,2]\nOutput: 3\nExplanation: The special subsequences are bolded [0,1,2,2], [0,1,2,2], and [0,1,2,2].\n\nExample 2:\n\nInput: nums = [2,2,0,0]\nOutput: 0\nExplanation: There are no special subsequences in [2,2,0,0].\n\nExample 3:\n\nInput: nums = [0,1,2,0,1,2]\nOutput: 7\nExplanation: The special subsequences are bolded:\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= nums[i] <= 2\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 1, 1, 2]) == 9\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2]) == 0\n assert candidate(nums = [0, 0, 0, 1, 1, 2]) == 21\n assert candidate(nums = [2, 2, 0, 0]) == 0\n assert candidate(nums = [0, 1, 2, 2]) == 3\n assert candidate(nums = [0, 1, 2, 2, 2]) == 7\n assert candidate(nums = [1, 2, 2, 0, 0, 1]) == 0\n assert candidate(nums = [0, 1, 2, 1, 2, 0, 1, 2]) == 19\n assert candidate(nums = [0, 1, 0, 1, 2]) == 5\n assert candidate(nums = [0, 1, 1, 1, 2, 2, 2]) == 49\n assert candidate(nums = [2, 1, 0, 1, 0, 2, 0]) == 1\n assert candidate(nums = [0, 1, 2, 0, 1, 0, 1, 2]) == 19\n assert candidate(nums = [2, 0, 1, 2, 0, 1, 2]) == 7\n assert candidate(nums = [2, 0, 1, 0, 1, 2]) == 5\n assert candidate(nums = [2, 0, 1, 0, 1, 2, 0, 1, 2]) == 27\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 2]) == 63\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 0, 1, 2, 0, 1, 2, 0]) == 7\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2]) == 51\n assert candidate(nums = [0, 1, 2, 0, 1, 2]) == 7\n assert candidate(nums = [0, 1, 2]) == 1\n assert candidate(nums = [0, 0, 1, 2, 1, 2]) == 15\n assert candidate(nums = [0, 0, 1, 1, 2, 2]) == 27\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2, 2]) == 119\n assert candidate(nums = [0, 0, 0, 1, 2, 2]) == 21\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2]) == 343\n assert candidate(nums = [0, 1, 0, 1, 2, 0, 1, 2]) == 27\n assert candidate(nums = [0, 1, 1, 2, 2, 2]) == 21\n assert candidate(nums = [1, 2, 0]) == 0\n assert candidate(nums = [2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2]) == 735\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 375309442\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2]) == 21567\n assert candidate(nums = [0, 0, 0, 0, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2]) == 9975\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 554508028\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 25039\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 133432831\n assert candidate(nums = [0, 1, 0, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 207\n assert candidate(nums = [2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0]) == 351\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 14415\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]) == 2048383\n assert candidate(nums = [0, 1, 0, 2, 0, 1, 0, 2, 1, 2]) == 55\n assert candidate(nums = [0, 1, 1, 0, 2, 2, 1, 1, 0, 2, 0, 1, 2]) == 135\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 6399\n assert candidate(nums = [2, 1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2]) == 735\n assert candidate(nums = [0, 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2]) == 3519\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 14175\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2, 0, 1, 2, 0, 1, 2]) == 2335\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2]) == 3999\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 0, 1, 2, 2]) == 3279\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2]) == 1575\n assert candidate(nums = [2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0]) == 0\n assert candidate(nums = [0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2]) == 71\n assert candidate(nums = [2, 2, 2, 1, 1, 1, 0, 0, 0, 2, 2, 2, 1, 1, 1, 0, 0, 0]) == 0\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2, 2]) == 1647\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 2]) == 423\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2]) == 26775\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 29295\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 2, 2]) == 135\n assert candidate(nums = [2, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 0, 1, 2]) == 4047\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2]) == 31\n assert candidate(nums = [2, 2, 2, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 1023\n assert candidate(nums = [2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 70599160\n assert candidate(nums = [0, 0, 1, 1, 1, 1, 2, 2, 0, 0, 1, 1, 2]) == 495\n assert candidate(nums = [0, 1, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2]) == 63\n assert candidate(nums = [0, 1, 1, 2, 0, 1, 2, 2, 1, 2, 0, 1, 2, 2, 1, 0, 1, 2, 2]) == 2847\n assert candidate(nums = [0, 0, 1, 1, 1, 1, 2, 2, 2, 2]) == 675\n assert candidate(nums = [0, 1, 2, 2, 1, 0, 1, 2, 2, 1, 0, 1, 2]) == 127\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2]) == 1575\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 2, 2, 2, 2]) == 255\n assert candidate(nums = [2, 0, 0, 0, 1, 1, 1, 2, 2, 2]) == 343\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 250047\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2]) == 8575\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 2, 2]) == 651\n assert candidate(nums = [2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 18943\n assert candidate(nums = [0, 1, 2, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2]) == 4609\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 534776319\n assert candidate(nums = [0, 1, 2, 0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 303\n assert candidate(nums = [0, 1, 1, 2, 2, 2, 2, 2, 0, 1, 2, 0, 1, 2, 2]) == 855\n assert candidate(nums = [2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 2815\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2]) == 3375\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 4287\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 20223\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 2815\n assert candidate(nums = [2, 2, 0, 0, 0, 1, 1, 1, 2, 2]) == 147\n assert candidate(nums = [2, 0, 0, 1, 1, 1, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2]) == 1647\n assert candidate(nums = [0, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 831\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 29791\n assert candidate(nums = [2, 2, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 451143\n assert candidate(nums = [2, 2, 2, 0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 335\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 1, 2, 0, 1, 2]) == 1855\n assert candidate(nums = [0, 1, 1, 1, 2, 2, 2, 2, 0, 1, 2]) == 227\n assert candidate(nums = [0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0, 1, 2]) == 1447\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2, 2, 2]) == 16095\n assert candidate(nums = [0, 1, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 7039\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 351\n assert candidate(nums = [0, 1, 2, 0, 0, 1, 1, 1, 2, 2, 0, 1, 2]) == 479\n assert candidate(nums = [2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 2943\n assert candidate(nums = [2, 2, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2]) == 735\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 2, 2]) == 975\n assert candidate(nums = [2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 2, 2]) == 2239\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2]) == 6727\n assert candidate(nums = [0, 0, 0, 1, 2, 2, 2, 1, 1, 1, 0, 0, 0]) == 49\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 783\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 704511\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2]) == 527\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2, 2, 2]) == 28639\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 2]) == 735\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 2943\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 2]) == 315\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 1323\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2]) == 3375\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 1, 2, 2, 2]) == 3087\n assert candidate(nums = [0, 1, 2, 1, 2, 0, 1, 2, 1, 2, 0, 1, 2]) == 167\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 351\n assert candidate(nums = [2, 1, 0, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2]) == 7423\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2]) == 4335\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 0, 1, 2]) == 3151\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 18943\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 274431\n assert candidate(nums = [0, 0, 1, 1, 2, 0, 1, 2, 0, 1, 2]) == 151\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2]) == 3591\n assert candidate(nums = [2, 2, 2, 0, 0, 0, 1, 1, 1]) == 0\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 111\n assert candidate(nums = [0, 0, 0, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2]) == 3367\n", "comparison": "exact"}, "public_tests": ["[0,1,2,2]", "[2,2,0,0]", "[0,1,2,0,1,2]"], "hints": ["Can we first solve a simpler problem? Counting the number of subsequences with 1s followed by 0s.", "How can we keep track of the partially matched subsequences to help us find the answer?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countSpecialSubsequences", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:14+00:00", "tests_total": 128, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def countSpecialSubsequences(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countSpecialSubsequences", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1957, "task_id": "delete-characters-to-make-fancy-string", "difficulty": "Easy", "problem_description": "A fancy string is a string where no three consecutive characters are equal.\n\nGiven a string s, delete the minimum possible number of characters from s to make it fancy.\n\nReturn the final string after the deletion. It can be shown that the answer will always be unique.\n\nExample 1:\n\nInput: s = \"leeetcode\"\nOutput: \"leetcode\"\nExplanation:\nRemove an 'e' from the first group of 'e's to create \"leetcode\".\nNo three consecutive characters are equal, so return \"leetcode\".\n\nExample 2:\n\nInput: s = \"aaabaaaa\"\nOutput: \"aabaa\"\nExplanation:\nRemove an 'a' from the first group of 'a's to create \"aabaaaa\".\nRemove two 'a's from the second group of 'a's to create \"aabaa\".\nNo three consecutive characters are equal, so return \"aabaa\".\n\nExample 3:\n\nInput: s = \"aab\"\nOutput: \"aab\"\nExplanation: No three consecutive characters are equal, so return \"aab\".\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists only of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzzzzzz\") == \"zz\"\n assert candidate(s = \"aaabbbccc\") == \"aabbcc\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aabbaa\") == \"aabbaa\"\n assert candidate(s = \"leeetcode\") == \"leetcode\"\n assert candidate(s = \"aaaaa\") == \"aa\"\n assert candidate(s = \"ccccccaaa\") == \"ccaa\"\n assert candidate(s = \"aabbccddd\") == \"aabbccdd\"\n assert candidate(s = \"cccaaa\") == \"ccaa\"\n assert candidate(s = \"aaa\") == \"aa\"\n assert candidate(s = \"aababab\") == \"aababab\"\n assert candidate(s = \"aaaabbbcccaa\") == \"aabbccaa\"\n assert candidate(s = \"aaaabbbbcccc\") == \"aabbcc\"\n assert candidate(s = \"zzzzzzzzzz\") == \"zz\"\n assert candidate(s = \"ababababc\") == \"ababababc\"\n assert candidate(s = \"abacadaeafag\") == \"abacadaeafag\"\n assert candidate(s = \"abc\") == \"abc\"\n assert candidate(s = \"aabbaaabbbaaa\") == \"aabbaabbaa\"\n assert candidate(s = \"aab\") == \"aab\"\n assert candidate(s = \"aabbcc\") == \"aabbcc\"\n assert candidate(s = \"mississippi\") == \"mississippi\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"xyzzzxxzzzz\") == \"xyzzxxzz\"\n assert candidate(s = \"aaabaaaa\") == \"aabaa\"\n assert candidate(s = \"abcdefg\") == \"abcdefg\"\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwwwxxxxyyyzzz\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"abcabcabcabc\") == \"abcabcabcabc\"\n assert candidate(s = \"pppaaabbbcccddddeeeffffggghhhhiiiijjjjjkkkkklllllmmmmmnnnnnooooooopppppqqqqqrrrrrssssstttttuuuuuuvvvvvvvvvvwwwwwwxxxxxyyyyzzzzz\") == \"ppaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"xyzzzzzzzzzyx\") == \"xyzzyx\"\n assert candidate(s = \"mnonononojmnonononojmnonononoj\") == \"mnonononojmnonononojmnonononoj\"\n assert candidate(s = \"pppqqqrssstttuuuvvvwwwxxyyyzzz\") == \"ppqqrssttuuvvwwxxyyzz\"\n assert candidate(s = \"aabbccddeeefff\") == \"aabbccddeeff\"\n assert candidate(s = \"abcdefghijjjjjklmnopqrstuvwxyz\") == \"abcdefghijjklmnopqrstuvwxyz\"\n assert candidate(s = \"nnneennneennneennn\") == \"nneenneenneenn\"\n", "comparison": "exact"}, "public_tests": ["\"leeetcode\"", "\"aaabaaaa\"", "\"aab\""], "hints": ["What's the optimal way to delete characters if three or more consecutive characters are equal?", "If three or more consecutive characters are equal, keep two of them and delete the rest."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().makeFancyString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:19+00:00", "tests_total": 34, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def makeFancyString(self, s: str) -> str:", "container": "Solution", "callable": "makeFancyString", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1959, "task_id": "minimum-total-space-wasted-with-k-resizing-operations", "difficulty": "Medium", "problem_description": "You are currently designing a dynamic array. You are given a 0-indexed integer array nums, where nums[i] is the number of elements that will be in the array at time i. In addition, you are given an integer k, the maximum number of times you can resize the array (to any size).\n\nThe size of the array at time t, size_t, must be at least nums[t] because there needs to be enough space in the array to hold all the elements. The space wasted at time t is defined as size_t - nums[t], and the total space wasted is the sum of the space wasted across every time t where 0 <= t < nums.length.\n\nReturn the minimum total space wasted if you can resize the array at most k times.\n\nNote: The array can have any size at the start and does not count towards the number of resizing operations.\n\nExample 1:\n\nInput: nums = [10,20], k = 0\nOutput: 10\nExplanation: size = [20,20].\nWe can set the initial size to be 20.\nThe total wasted space is (20 - 10) + (20 - 20) = 10.\n\nExample 2:\n\nInput: nums = [10,20,30], k = 1\nOutput: 10\nExplanation: size = [20,20,30].\nWe can set the initial size to be 20 and resize to 30 at time 2.\nThe total wasted space is (20 - 10) + (20 - 20) + (30 - 30) = 10.\n\nExample 3:\n\nInput: nums = [10,20,15,30,20], k = 2\nOutput: 15\nExplanation: size = [10,20,20,30,30].\nWe can set the initial size to 10, resize to 20 at time 1, and resize to 30 at time 3.\nThe total wasted space is (10 - 10) + (20 - 20) + (20 - 15) + (30 - 30) + (30 - 20) = 15.\n\nConstraints:\n\n- 1 <= nums.length <= 200\n- 1 <= nums[i] <= 10^6\n- 0 <= k <= nums.length - 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10, 10],k = 2) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30],k = 3) == 10\n assert candidate(nums = [10, 20, 30],k = 1) == 10\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 0) == 45\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7],k = 3) == 3\n assert candidate(nums = [100, 200, 150, 300, 200, 350],k = 2) == 250\n assert candidate(nums = [10, 20, 15, 30, 20],k = 2) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 0) == 90\n assert candidate(nums = [1, 2, 3, 4, 5],k = 4) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],k = 0) == 1000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 0) == 450\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500],k = 4) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 10\n assert candidate(nums = [5, 8, 6, 10],k = 1) == 5\n assert candidate(nums = [1, 3, 5, 7, 9],k = 4) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9) == 0\n assert candidate(nums = [5, 5, 5, 5, 5],k = 0) == 0\n assert candidate(nums = [1000000, 1000000, 1000000],k = 2) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 40\n assert candidate(nums = [10, 20],k = 0) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 5\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 0\n assert candidate(nums = [20, 10, 30, 25, 40],k = 2) == 15\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 0) == 0\n assert candidate(nums = [20, 10, 30, 25, 15],k = 2) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 2) == 4\n assert candidate(nums = [300, 200, 100, 400, 300, 200, 500, 400, 300, 600, 500, 400, 700, 600, 500, 800, 700, 600, 900, 800, 700, 1000, 900, 800, 1100, 1000, 900, 1200, 1100, 1000, 1300, 1200, 1100, 1400, 1300, 1200, 1500, 1400, 1300, 1600, 1500, 1400, 1700, 1600, 1500, 1800, 1700, 1600, 1900, 1800, 1700, 2000, 1900, 1800, 2100, 2000, 1900, 2200, 2100, 2000, 2300, 2200, 2100, 2400, 2300, 2200],k = 30) == 4800\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 14) == 15\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 10) == 33\n assert candidate(nums = [3, 5, 4, 7, 8, 6, 9],k = 2) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 18\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 120\n assert candidate(nums = [20, 15, 10, 5, 15, 20, 25, 30, 35, 40, 45, 50],k = 2) == 65\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 4) == 50\n assert candidate(nums = [300, 200, 100, 50, 25, 125, 62, 31, 15, 7, 3, 1],k = 5) == 186\n assert candidate(nums = [100, 200, 150, 300, 250, 350, 400],k = 2) == 250\n assert candidate(nums = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 50\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == 0\n assert candidate(nums = [10, 20, 30, 25, 40, 35, 50, 45, 60, 55],k = 4) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 0) == 190\n assert candidate(nums = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000],k = 9) == 5000\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 0) == 0\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 3) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 4) == 90\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 5) == 24\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100],k = 9) == 495\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994],k = 3) == 3\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 0) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 9) == 29\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4) == 50\n assert candidate(nums = [20, 10, 30, 25, 40, 35, 50, 45, 60, 55, 70, 65, 80, 75, 90, 85, 100, 95, 110, 105],k = 3) == 215\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(nums = [100, 200, 150, 100, 300, 250, 200, 350, 400, 300],k = 3) == 450\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 10) == 1985\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 0) == 1900\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == 90\n assert candidate(nums = [1000000, 500000, 750000, 250000, 100000],k = 2) == 400000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 4) == 150\n assert candidate(nums = [10, 5, 15, 10, 20, 15, 25, 20, 30, 25, 35, 30, 40, 35, 45],k = 6) == 45\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 0\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],k = 5) == 140629\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],k = 6) == 12\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 5) == 73729\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350],k = 2) == 250\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 120\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350, 500],k = 2) == 450\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100],k = 5) == 80\n assert candidate(nums = [10, 20, 30, 20, 10, 40, 30, 20, 50, 40, 30, 20, 60, 50, 40, 30],k = 5) == 130\n assert candidate(nums = [200, 150, 100, 50, 150, 200, 250, 300, 350, 400],k = 3) == 350\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 0) == 0\n assert candidate(nums = [500000, 400000, 300000, 200000, 100000, 100000, 200000, 300000, 400000, 500000, 100000, 200000, 300000, 400000, 500000, 100000, 200000, 300000, 400000, 500000],k = 7) == 1400000\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 5) == 81\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205],k = 7) == 160\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],k = 10) == 3788\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 5) == 0\n assert candidate(nums = [20, 10, 30, 5, 40, 25, 60, 35, 70, 45, 80, 55, 90, 65, 100, 75, 110, 85, 120, 95, 130, 105, 140, 115, 150, 125, 160, 135, 170, 145, 180, 155],k = 8) == 515\n assert candidate(nums = [10, 20, 10, 30, 10, 20, 30, 40, 50],k = 3) == 50\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100],k = 25) == 48\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 10\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 0) == 0\n assert candidate(nums = [100, 200, 150, 300, 250, 400],k = 2) == 200\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 9) == 45\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9],k = 25) == 119\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 15) == 140\n assert candidate(nums = [100, 200, 150, 100, 250, 200, 150, 300],k = 2) == 400\n assert candidate(nums = [200, 100, 200, 100, 200, 100, 200, 100, 200, 100],k = 4) == 300\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],k = 0) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 10) == 90\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == 1200\n assert candidate(nums = [500, 400, 300, 200, 100, 50, 25, 10, 5, 2, 1, 1, 2, 5, 10, 25, 50, 100, 200, 300, 400, 500],k = 10) == 264\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 90\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 8\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 7) == 16\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 10) == 100\n assert candidate(nums = [10, 20, 15, 30, 20, 25, 35, 40, 45, 50],k = 4) == 30\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],k = 5) == 9\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 0) == 450\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 6\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 0\n assert candidate(nums = [20, 15, 10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85],k = 5) == 100\n assert candidate(nums = [1000, 2000, 1500, 3000, 2500, 4000, 3500, 5000, 4500, 6000],k = 5) == 2000\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 0) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n", "comparison": "exact"}, "public_tests": ["[10,20]\n0", "[10,20,30]\n1", "[10,20,15,30,20]\n2"], "hints": ["Given a range, how can you find the minimum waste if you can't perform any resize operations?", "Can we build our solution using dynamic programming using the current index and the number of resizing operations performed as the states?"], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minSpaceWastedKResizing", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:23+00:00", "tests_total": 120, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "dynamic-programming", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minSpaceWastedKResizing(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "minSpaceWastedKResizing", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1960, "task_id": "maximum-product-of-the-length-of-two-palindromic-substrings", "difficulty": "Hard", "problem_description": "You are given a 0-indexed string s and are tasked with finding two non-intersecting palindromic substrings of odd length such that the product of their lengths is maximized.\n\nMore formally, you want to choose four integers i, j, k, l such that 0 <= i <= j < k <= l < s.length and both the substrings s[i...j] and s[k...l] are palindromes and have odd lengths. s[i...j] denotes a substring from index i to index j inclusive.\n\nReturn the maximum possible product of the lengths of the two non-intersecting palindromic substrings.\n\nA palindrome is a string that is the same forward and backward. A substring is a contiguous sequence of characters in a string.\n\nExample 1:\n\nInput: s = \"ababbb\"\nOutput: 9\nExplanation: Substrings \"aba\" and \"bbb\" are palindromes with odd length. product = 3 * 3 = 9.\n\nExample 2:\n\nInput: s = \"zaaaxbbby\"\nOutput: 9\nExplanation: Substrings \"aaa\" and \"bbb\" are palindromes with odd length. product = 3 * 3 = 9.\n\nConstraints:\n\n- 2 <= s.length <= 10^5\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"mnoonmmon\") == 1\n assert candidate(s = \"mamadmim\") == 9\n assert candidate(s = \"abcdcba\") == 5\n assert candidate(s = \"abcdedcba\") == 7\n assert candidate(s = \"mamad\") == 3\n assert candidate(s = \"aaaaa\") == 3\n assert candidate(s = \"abcdefghi\") == 1\n assert candidate(s = \"abacdfgdcaba\") == 9\n assert candidate(s = \"zaaaxbbby\") == 9\n assert candidate(s = \"noonnoon\") == 1\n assert candidate(s = \"abcde\") == 1\n assert candidate(s = \"racecar\") == 5\n assert candidate(s = \"abcdeedcba\") == 1\n assert candidate(s = \"banana\") == 5\n assert candidate(s = \"ababbb\") == 9\n assert candidate(s = \"abc\") == 1\n assert candidate(s = \"abcbabcbabcba\") == 35\n assert candidate(s = \"abcdefgh\") == 1\n assert candidate(s = \"abcd\") == 1\n assert candidate(s = \"mississippi\") == 7\n assert candidate(s = \"aabbccddeeffgghhiijj\") == 1\n assert candidate(s = \"mnoonmnonoomnm\") == 15\n assert candidate(s = \"abcdefg\") == 1\n assert candidate(s = \"aabbccddeeeffgg\") == 3\n assert candidate(s = \"abccbaabccbaabccbaabccba\") == 1\n assert candidate(s = \"aaaaaabbaaaaa\") == 25\n assert candidate(s = \"nunrunrunrun\") == 3\n assert candidate(s = \"abaaacbaaaaba\") == 9\n assert candidate(s = \"racecarlevelnoonracecar\") == 49\n assert candidate(s = \"deeeeefedeeeed\") == 15\n assert candidate(s = \"rotorrotor\") == 25\n assert candidate(s = \"abracadabra\") == 3\n assert candidate(s = \"abcabcabcabc\") == 1\n assert candidate(s = \"abcbaacbabcba\") == 25\n assert candidate(s = \"abcbacbacbacb\") == 5\n assert candidate(s = \"tattarrattat\") == 9\n assert candidate(s = \"repaperrelevelrepeepr\") == 35\n assert candidate(s = \"babadabababa\") == 25\n assert candidate(s = \"madaminnadammadam\") == 25\n assert candidate(s = \"abccbaabcdcba\") == 7\n assert candidate(s = \"aabaaaabaaaabaa\") == 25\n assert candidate(s = \"abcdeffedcbaffedcba\") == 1\n assert candidate(s = \"abccbaabccba\") == 1\n assert candidate(s = \"xyzabcbaedcbaxyz\") == 5\n assert candidate(s = \"levellevellevellevel\") == 75\n assert candidate(s = \"noonnoonnoonnoon\") == 1\n assert candidate(s = \"mississippimississippi\") == 49\n assert candidate(s = \"xyzxyzxyzxyz\") == 1\n assert candidate(s = \"abacdfgdcabaxyzzyzyzyzyzx\") == 27\n assert candidate(s = \"aabbbaabbbaabbbaaa\") == 49\n assert candidate(s = \"abacadaeafagahagaha\") == 21\n assert candidate(s = \"noonracecarnoon\") == 13\n assert candidate(s = \"aabbbaaabbbaaabbbaaabbbaaabbba\") == 221\n assert candidate(s = \"ababababababababa\") == 63\n assert candidate(s = \"abacabaabacabaabacaba\") == 49\n assert candidate(s = \"repel\") == 3\n assert candidate(s = \"levelnoonlevel\") == 25\n assert candidate(s = \"rotorlevelmadamracecar\") == 35\n assert candidate(s = \"noonnoonnoonnoonnoonnoon\") == 1\n assert candidate(s = \"kayak\") == 3\n assert candidate(s = \"mnopqrstuvuvwxyzyx\") == 15\n assert candidate(s = \"madamlevelmadam\") == 25\n assert candidate(s = \"babcbabcbabcba\") == 35\n assert candidate(s = \"abacadaeafagaha\") == 9\n assert candidate(s = \"leveloneleveleleveldoneleveldot\") == 55\n assert candidate(s = \"xyzzzzyzyzyzx\") == 21\n assert candidate(s = \"madaminnadam\") == 15\n assert candidate(s = \"abababababababab\") == 63\n assert candidate(s = \"racecarabcdeedcbacar\") == 21\n assert candidate(s = \"noon\") == 1\n assert candidate(s = \"abcbacbacb\") == 5\n assert candidate(s = \"ababababababababab\") == 81\n assert candidate(s = \"deeee\") == 3\n assert candidate(s = \"leveloneleveltwo\") == 25\n assert candidate(s = \"abcabcabcabcabcabc\") == 1\n assert candidate(s = \"xyzbcbzxyxzyzyzyz\") == 35\n assert candidate(s = \"abcdefggfedcba\") == 1\n assert candidate(s = \"aaaaabbbbbbaaaa\") == 25\n assert candidate(s = \"abcdeffedcba\") == 1\n assert candidate(s = \"ababcbaababcbaababcba\") == 25\n assert candidate(s = \"babcbabcbabcbabcbabcbabcbabcbabcbabcbabcba\") == 399\n assert candidate(s = \"ababaababaababa\") == 27\n assert candidate(s = \"abcbabcbaabcbabcba\") == 81\n assert candidate(s = \"mmabccbaakak\") == 3\n assert candidate(s = \"abcdefedcba\") == 9\n assert candidate(s = \"palindromeemordnilap\") == 1\n assert candidate(s = \"level\") == 3\n assert candidate(s = \"racecarlevelracecar\") == 49\n assert candidate(s = \"levellevellevel\") == 25\n assert candidate(s = \"aaaaabaaaaabaaaaabaaaaab\") == 143\n assert candidate(s = \"xyxzyxzyxzyx\") == 3\n assert candidate(s = \"nunabannun\") == 15\n assert candidate(s = \"deeeeefeeeed\") == 15\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzz\") == 143\n assert candidate(s = \"abababababababababab\") == 99\n assert candidate(s = \"madamimadamracecar\") == 77\n assert candidate(s = \"abbbbabbbaaaaaaaabbba\") == 49\n assert candidate(s = \"radar\") == 3\n assert candidate(s = \"abababa\") == 9\n assert candidate(s = \"abacabadabacaba\") == 49\n assert candidate(s = \"abacabadabacabada\") == 63\n assert candidate(s = \"bananaananab\") == 25\n assert candidate(s = \"aabbccddeeefffggg\") == 9\n assert candidate(s = \"redivider\") == 7\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 99\n assert candidate(s = \"abcabccbaabcabccba\") == 1\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 1\n assert candidate(s = \"deedlevel\") == 5\n assert candidate(s = \"abcbabcba\") == 15\n assert candidate(s = \"deifiedrotatordeified\") == 49\n assert candidate(s = \"noonnoonnoonnoonnoon\") == 1\n assert candidate(s = \"abcbadefgfe\") == 25\n assert candidate(s = \"anana\") == 3\n assert candidate(s = \"ababaabababababa\") == 55\n assert candidate(s = \"abracadabraabracadabra\") == 9\n assert candidate(s = \"detartrated\") == 9\n assert candidate(s = \"manamzzamanaplanacanalpanamazzamanaplanacanalpanamazzzzzz\") == 529\n assert candidate(s = \"xyxyxyxyxyxyxyxyx\") == 63\n assert candidate(s = \"madamimadam\") == 25\n assert candidate(s = \"levelonelevelonelevel\") == 25\n assert candidate(s = \"madamracecaramadam\") == 35\n assert candidate(s = \"aaabbaaabbaaa\") == 21\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"xylophonepiponolyx\") == 9\n assert candidate(s = \"racecarandracecar\") == 49\n assert candidate(s = \"aabaaaabaaba\") == 25\n assert candidate(s = \"racecarannakayak\") == 35\n assert candidate(s = \"kayakkayakkayakkayak\") == 75\n assert candidate(s = \"aaaaabbbbbaaaaa\") == 27\n assert candidate(s = \"mammadmooommom\") == 15\n assert candidate(s = \"aaaaabbbbbaaaaaabbbbaaaaa\") == 75\n assert candidate(s = \"racecarracecar\") == 49\n assert candidate(s = \"noonnoonnoon\") == 1\n assert candidate(s = \"repaper\") == 5\n assert candidate(s = \"racecarlevelrotorkayak\") == 35\n assert candidate(s = \"rotorrotorrotor\") == 25\n assert candidate(s = \"aaaaabaaabaaaabaaaaabaaaa\") == 99\n assert candidate(s = \"ababaababab\") == 25\n assert candidate(s = \"noonhighnoon\") == 1\n assert candidate(s = \"tacocattacocattaco\") == 49\n assert candidate(s = \"rotorrotorrotorrotor\") == 75\n assert candidate(s = \"bananaananananab\") == 45\n assert candidate(s = \"zzzyzyzyzyzyzyzyzyzyzyzyz\") == 121\n assert candidate(s = \"deeddeeddeed\") == 1\n assert candidate(s = \"aaaaaabbbbbaaaa\") == 35\n assert candidate(s = \"rotorresistor\") == 15\n assert candidate(s = \"xylophonelevel\") == 5\n assert candidate(s = \"aaabaaaabaaaaabaaaaaaab\") == 77\n assert candidate(s = \"aabbccddeeefffgggzzzzzzzzzzzzzzzzzzzz\") == 99\n assert candidate(s = \"abcdedcbaabcdedcbaabcdedcba\") == 81\n assert candidate(s = \"civic\") == 3\n assert candidate(s = \"rotor\") == 3\n assert candidate(s = \"qwertyuioplkjhgfdsazxcvbnmnbvcxzasdfghjklpoiuytrewq\") == 49\n assert candidate(s = \"abbaabbbaabba\") == 11\n assert candidate(s = \"abcdefghihgfedcba\") == 15\n assert candidate(s = \"tacocattaco\") == 7\n assert candidate(s = \"repaperrepaperrepaper\") == 49\n assert candidate(s = \"aabaaaabaa\") == 25\n assert candidate(s = \"reviled\") == 1\n assert candidate(s = \"amoreroma\") == 7\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjjkkkkllllmmmnnnooopppqqqqrrrrssssttttuuuuvvvvwwwwwxxxxxyyyyyzzzzzzyyyyyxxxwwvvuuttrrqqppoonnmlkkjjiihhggffeeddccbbaa\") == 25\n assert candidate(s = \"xyzyzyzyzyzyzyzyz\") == 63\n assert candidate(s = \"xyxzyzyzyzyzyzyx\") == 35\n assert candidate(s = \"zzzzzzyyyyyxxxwwvvuuttrrqqppoonnmlkkjjiihhggffeeddccbbaa\") == 25\n assert candidate(s = \"rotorabcdrotor\") == 25\n assert candidate(s = \"aabbccddeeeffgghhiii\") == 9\n assert candidate(s = \"abcdedcbabcdedcbabcdedcb\") == 135\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjjkkkkllllmmmnnnooopppqqqqrrrrssssttttuuuuvvvvwwwwwxxxxxyyyyyzzzzz\") == 25\n assert candidate(s = \"abcabcabcabcabc\") == 1\n assert candidate(s = \"deed\") == 1\n assert candidate(s = \"aaaaabbbbbbaaaaa\") == 25\n assert candidate(s = \"levelwasracecar\") == 35\n assert candidate(s = \"racecarabcdeedcba\") == 9\n", "comparison": "exact"}, "public_tests": ["\"ababbb\"", "\"zaaaxbbby\""], "hints": ["You can use Manacher's algorithm to get the maximum palindromic substring centered at each index", "After using Manacher's for each center use a line sweep from the center to the left and from the center to the right to find for each index the farthest center to it with distance ≤ palin[center]", "After that, find the maximum palindrome size for each prefix in the string and for each suffix and the answer would be max(prefix[i] * suffix[i + 1])"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxProduct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:25+00:00", "tests_total": 173, "tests_dropped": 0, "flags": [], "topic_tags": ["two-pointers", "string", "rolling-hash", "hash-function", "manacher", "palindromic-tree"]}, "language": "python", "interface": {"raw_signature": "def maxProduct(self, s: str) -> int:", "container": "Solution", "callable": "maxProduct", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1961, "task_id": "check-if-string-is-a-prefix-of-array", "difficulty": "Easy", "problem_description": "Given a string s and an array of strings words, determine whether s is a prefix string of words.\n\nA string s is a prefix string of words if s can be made by concatenating the first k strings in words for some positive k no larger than words.length.\n\nReturn true if s is a prefix string of words, or false otherwise.\n\nExample 1:\n\nInput: s = \"iloveleetcode\", words = [\"i\",\"love\",\"leetcode\",\"apples\"]\nOutput: true\nExplanation:\ns can be made by concatenating \"i\", \"love\", and \"leetcode\" together.\n\nExample 2:\n\nInput: s = \"iloveleetcode\", words = [\"apples\",\"i\",\"love\",\"leetcode\"]\nOutput: false\nExplanation:\nIt is impossible to make s using a prefix of arr.\n\nConstraints:\n\n- 1 <= words.length <= 100\n- 1 <= words[i].length <= 20\n- 1 <= s.length <= 1000\n- words[i] and s consist of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaaa\",words = ['aa', 'aa']) == True\n assert candidate(s = \"hello\",words = ['he', 'll', 'o']) == True\n assert candidate(s = \"abc\",words = ['a']) == False\n assert candidate(s = \"abc\",words = ['a', 'bc']) == True\n assert candidate(s = \"a\",words = ['a', 'b', 'c']) == True\n assert candidate(s = \"abcd\",words = ['a', 'bcd']) == True\n assert candidate(s = \"cat\",words = ['ca', 't']) == True\n assert candidate(s = \"abcd\",words = ['abc', 'd']) == True\n assert candidate(s = \"hello\",words = ['he', 'l', 'lo']) == True\n assert candidate(s = \"abc\",words = ['ab', 'c']) == True\n assert candidate(s = \"iloveleetcode\",words = ['apples', 'i', 'love', 'leetcode']) == False\n assert candidate(s = \"hello\",words = ['he', 'llo']) == True\n assert candidate(s = \"abcd\",words = ['a', 'b', 'c', 'd']) == True\n assert candidate(s = \"abcd\",words = ['ab', 'cd']) == True\n assert candidate(s = \"abcd\",words = ['abcd']) == True\n assert candidate(s = \"iloveleetcode\",words = ['i', 'love', 'leetcode', 'apples']) == True\n assert candidate(s = \"xyz\",words = ['x', 'y', 'z']) == True\n assert candidate(s = \"abc\",words = ['a', 'b', 'c']) == True\n assert candidate(s = \"abcd\",words = ['abc']) == False\n assert candidate(s = \"complexprefixstring\",words = ['complex', 'prefix', 'string', 'extra']) == True\n assert candidate(s = \"aquickbrownfox\",words = ['a', 'quick', 'brown', 'fox', 'jumps']) == True\n assert candidate(s = \"onetwothree\",words = ['one', 'two', 'three', 'four', 'five']) == True\n assert candidate(s = \"algorithm\",words = ['algo', 'r', 'ith', 'm']) == True\n assert candidate(s = \"python\",words = ['py', 'th', 'on', 'n']) == True\n assert candidate(s = \"complexprefix\",words = ['com', 'ple', 'xpre', 'fix']) == True\n assert candidate(s = \"concatenate\",words = ['con', 'cat', 'en', 'ate']) == True\n assert candidate(s = \"algorithms\",words = ['algo', 'rithm', 's', 'data']) == True\n assert candidate(s = \"abracadabra\",words = ['abra', 'ca', 'da', 'bra', 'bra']) == True\n assert candidate(s = \"substring\",words = ['sub', 'str', 'ing', 'example']) == True\n assert candidate(s = \"onetwothreefour\",words = ['one', 'two', 'three', 'four', 'five']) == True\n assert candidate(s = \"xyz\",words = ['x', 'y', 'z', 'w']) == True\n assert candidate(s = \"prefixstring\",words = ['pre', 'fix', 'string']) == True\n assert candidate(s = \"programming\",words = ['pro', 'gram', 'ming']) == True\n assert candidate(s = \"concatenate\",words = ['con', 'cat', 'e', 'nate']) == True\n assert candidate(s = \"thisisatest\",words = ['this', 'is', 'a', 'test', 'case']) == True\n assert candidate(s = \"substring\",words = ['sub', 'string', 'abc']) == True\n assert candidate(s = \"mississippi\",words = ['mis', 'si', 'ssippi', 'p']) == True\n assert candidate(s = \"prefixprefix\",words = ['pre', 'fix', 'pre', 'fix', 'pre', 'fix']) == True\n assert candidate(s = \"abcdef\",words = ['a', 'b', 'c', 'def', 'ghi']) == True\n assert candidate(s = \"thisisatest\",words = ['this', 'is', 'a', 'test', 'case']) == True\n assert candidate(s = \"abcdefg\",words = ['a', 'b', 'c', 'd', 'e', 'f', 'g']) == True\n assert candidate(s = \"aaabbbccc\",words = ['aaa', 'bbb', 'ccc', 'ddd']) == True\n assert candidate(s = \"hello\",words = ['h', 'he', 'hel', 'hell', 'hello']) == False\n assert candidate(s = \"abcdabc\",words = ['ab', 'c', 'd', 'abc', 'def']) == True\n assert candidate(s = \"complexstring\",words = ['com', 'plex', 'string', 'other']) == True\n assert candidate(s = \"abcdefghijk\",words = ['abcd', 'ef', 'gh', 'ijk']) == True\n assert candidate(s = \"uniqueprefix\",words = ['unique', 'prefix', 'not']) == True\n assert candidate(s = \"prefix\",words = ['pre', 'fix', 'e', 'f', 'g']) == True\n assert candidate(s = \"oneonetwo\",words = ['one', 'one', 'two', 'three']) == True\n assert candidate(s = \"xyzzy\",words = ['xy', 'zz', 'y', 'z']) == True\n assert candidate(s = \"partialmatch\",words = ['partial', 'non', 'matching', 'words']) == False\n assert candidate(s = \"prefixmatching\",words = ['pre', 'fix', 'mat', 'ching']) == True\n assert candidate(s = \"overlapexample\",words = ['over', 'lap', 'ex', 'ample']) == True\n assert candidate(s = \"boundary\",words = ['bound', 'ary', 'extra']) == True\n assert candidate(s = \"partialmatch\",words = ['par', 'tial', 'match', 'nomatch']) == True\n assert candidate(s = \"abcdabcd\",words = ['abcd', 'abcd', 'abcd']) == True\n assert candidate(s = \"oneonetwo\",words = ['one', 'one', 'two', 'three']) == True\n assert candidate(s = \"abcdefghij\",words = ['abc', 'def', 'ghi', 'j']) == True\n assert candidate(s = \"mississippi\",words = ['mis', 'si', 'ss', 'ippi']) == True\n assert candidate(s = \"matchmaking\",words = ['mat', 'ch', 'mak', 'ing']) == True\n assert candidate(s = \"abcdefg\",words = ['a', 'bc', 'de', 'fg', 'xyz']) == True\n assert candidate(s = \"prefix\",words = ['pre', 'fix', 'ed', 'abc']) == True\n assert candidate(s = \"prefix\",words = ['pre', 'fix', 'post']) == True\n assert candidate(s = \"mnopqr\",words = ['mn', 'op', 'qr', 'st']) == True\n assert candidate(s = \"programminglanguage\",words = ['pro', 'gram', 'ming', 'lan', 'guage']) == True\n assert candidate(s = \"hellohello\",words = ['hello', 'hello', 'world']) == True\n assert candidate(s = \"prefixstring\",words = ['pre', 'fix', 'str', 'ing']) == True\n assert candidate(s = \"hellothere\",words = ['he', 'll', 'o', 'there']) == True\n assert candidate(s = \"concatenation\",words = ['con', 'cat', 'en', 'ation']) == True\n assert candidate(s = \"hellohello\",words = ['hello', 'hello', 'hello']) == True\n assert candidate(s = \"hello\",words = ['h', 'e', 'l', 'l', 'o', 'world']) == True\n assert candidate(s = \"quickbrownfox\",words = ['quick', 'brown', 'fox', 'jump']) == True\n assert candidate(s = \"abcdefghi\",words = ['abc', 'def', 'ghi', 'jkl']) == True\n assert candidate(s = \"one\",words = ['on', 'e', 'extra']) == True\n assert candidate(s = \"notprefix\",words = ['prefix', 'not']) == False\n assert candidate(s = \"abcdefgh\",words = ['a', 'bc', 'def', 'gh']) == True\n assert candidate(s = \"prefixstring\",words = ['prefix', 'string', 'extra']) == True\n assert candidate(s = \"prefix\",words = ['pre', 'fi', 'x']) == True\n assert candidate(s = \"longword\",words = ['lo', 'ng', 'wor', 'd']) == True\n assert candidate(s = \"xxyyyzzz\",words = ['xx', 'yyy', 'zzz', 'a']) == True\n assert candidate(s = \"concatenation\",words = ['con', 'cat', 'en', 'ation']) == True\n assert candidate(s = \"unique\",words = ['un', 'iq', 'ue']) == True\n assert candidate(s = \"abcdefghij\",words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == True\n assert candidate(s = \"algorithm\",words = ['algo', 'r', 'ith', 'm']) == True\n assert candidate(s = \"variouslengths\",words = ['vari', 'ous', 'length', 's']) == True\n assert candidate(s = \"two\",words = ['tw', 'o', 'tw', 'o']) == True\n assert candidate(s = \"abcdabcd\",words = ['abc', 'd', 'abcd']) == True\n assert candidate(s = \"wordplay\",words = ['word', 'play', 'game', 'time']) == True\n assert candidate(s = \"programming\",words = ['pro', 'gram', 'ming', 'lang']) == True\n assert candidate(s = \"concatenation\",words = ['con', 'cat', 'enation', 'ation']) == True\n assert candidate(s = \"supercalifragilisticexpialidocious\",words = ['super', 'cali', 'fragilistic', 'expiali', 'docious']) == True\n assert candidate(s = \"abcdefghij\",words = ['a', 'bc', 'de', 'fghi', 'j']) == True\n assert candidate(s = \"algorithm\",words = ['algo', 'rith', 'm']) == True\n assert candidate(s = \"testcase\",words = ['tes', 't', 'ca', 'se']) == True\n assert candidate(s = \"concatenation\",words = ['con', 'cat', 'e', 'na', 'tion']) == True\n assert candidate(s = \"abcdefghij\",words = ['abc', 'def', 'ghi', 'j']) == True\n assert candidate(s = \"xyz\",words = ['x', 'y', 'z', 'a', 'b', 'c']) == True\n assert candidate(s = \"prefixtest\",words = ['pre', 'fix', 'test', 'suffix']) == True\n assert candidate(s = \"repeated\",words = ['rep', 'e', 'ated']) == True\n assert candidate(s = \"matchingprefix\",words = ['matching', 'prefix', 'matching', 'prefix']) == True\n assert candidate(s = \"abcdexyz\",words = ['abc', 'de', 'xyz', 'mnop']) == True\n assert candidate(s = \"aabbccdd\",words = ['aa', 'bb', 'cc', 'd', 'd']) == True\n assert candidate(s = \"abcdef\",words = ['a', 'b', 'c', 'def']) == True\n assert candidate(s = \"programmingisfun\",words = ['pro', 'gram', 'ming', 'is', 'fun']) == True\n assert candidate(s = \"short\",words = ['shor', 't']) == True\n assert candidate(s = \"mississippi\",words = ['mis', 'si', 's', 'ip', 'pi']) == False\n assert candidate(s = \"repeatedword\",words = ['repeated', 'word', 'repeated']) == True\n assert candidate(s = \"rapiddevelopment\",words = ['rap', 'id', 'devel', 'op', 'ment']) == True\n assert candidate(s = \"onetwothree\",words = ['one', 'two', 'three', 'four']) == True\n assert candidate(s = \"interviewquestion\",words = ['inter', 'view', 'quest', 'ion']) == True\n assert candidate(s = \"abcdabcd\",words = ['abcd', 'abcd']) == True\n assert candidate(s = \"longstring\",words = ['long', 'string', 'extrastuff']) == True\n assert candidate(s = \"xyz\",words = ['xy', 'z', 'a', 'b']) == True\n assert candidate(s = \"thisisatest\",words = ['this', 'is', 'a', 'test']) == True\n assert candidate(s = \"abcdefg\",words = ['abc', 'def', 'g', 'h']) == True\n assert candidate(s = \"hellothere\",words = ['he', 'll', 'ot', 'her', 'e']) == True\n assert candidate(s = \"buildingblocks\",words = ['building', 'block', 's']) == True\n assert candidate(s = \"abcdefghij\",words = ['abc', 'de', 'f', 'gh', 'ij']) == True\n assert candidate(s = \"prefixmatch\",words = ['prefix', 'ma', 'tch']) == True\n assert candidate(s = \"python\",words = ['py', 'th', 'on', 'o']) == True\n assert candidate(s = \"python\",words = ['py', 't', 'h', 'o', 'n', 'extra']) == True\n assert candidate(s = \"aabbcc\",words = ['aa', 'bb', 'cc', 'dd']) == True\n assert candidate(s = \"abacax\",words = ['aba', 'c', 'ax', 'a']) == True\n assert candidate(s = \"aabbcc\",words = ['aa', 'bb', 'cc', 'dd']) == True\n", "comparison": "exact"}, "public_tests": ["\"iloveleetcode\"\n[\"i\",\"love\",\"leetcode\",\"apples\"]", "\"iloveleetcode\"\n[\"apples\",\"i\",\"love\",\"leetcode\"]"], "hints": ["There are only words.length prefix strings.", "Create all of them and see if s is one of them."], "metadata": {"canonical_parameter_names": ["s", "words"], "leetcode_dataset_entry_point": "Solution().isPrefixString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:27+00:00", "tests_total": 125, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "two-pointers", "string"]}, "language": "python", "interface": {"raw_signature": "def isPrefixString(self, s: str, words: list[str]) -> bool:", "container": "Solution", "callable": "isPrefixString", "parameters": [{"name": "s", "type": "str"}, {"name": "words", "type": "list[str]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1962, "task_id": "remove-stones-to-minimize-the-total", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array piles, where piles[i] represents the number of stones in the i^th pile, and an integer k. You should apply the following operation exactly k times:\n\n- Choose any piles[i] and remove floor(piles[i] / 2) stones from it.\n\nNotice that you can apply the operation on the same pile more than once.\n\nReturn the minimum possible total number of stones remaining after applying the k operations.\n\nfloor(x) is the largest integer that is smaller than or equal to x (i.e., rounds x down).\n\nExample 1:\n\nInput: piles = [5,4,9], k = 2\nOutput: 12\nExplanation: Steps of a possible scenario are:\n- Apply the operation on pile 2. The resulting piles are [5,4,5].\n- Apply the operation on pile 0. The resulting piles are [3,4,5].\nThe total number of stones in [3,4,5] is 12.\n\nExample 2:\n\nInput: piles = [4,3,6,7], k = 3\nOutput: 12\nExplanation: Steps of a possible scenario are:\n- Apply the operation on pile 2. The resulting piles are [4,3,3,7].\n- Apply the operation on pile 3. The resulting piles are [4,3,3,4].\n- Apply the operation on pile 0. The resulting piles are [2,3,3,4].\nThe total number of stones in [2,3,3,4] is 12.\n\nConstraints:\n\n- 1 <= piles.length <= 10^5\n- 1 <= piles[i] <= 10^4\n- 1 <= k <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(piles = [1, 2, 3, 4, 5],k = 10) == 5\n assert candidate(piles = [10, 10, 10, 10],k = 4) == 20\n assert candidate(piles = [5, 4, 9],k = 2) == 12\n assert candidate(piles = [10, 10, 10],k = 1) == 25\n assert candidate(piles = [100, 200, 300],k = 10) == 57\n assert candidate(piles = [4, 3, 6, 7],k = 3) == 12\n assert candidate(piles = [100, 200, 300],k = 1) == 450\n assert candidate(piles = [10000, 10000, 10000],k = 10000) == 3\n assert candidate(piles = [100, 200, 300],k = 2) == 350\n assert candidate(piles = [100, 100, 100],k = 10) == 33\n assert candidate(piles = [1],k = 1) == 1\n assert candidate(piles = [10000, 10000, 10000],k = 10000) == 3\n assert candidate(piles = [10, 10, 10],k = 5) == 11\n assert candidate(piles = [1, 2, 3, 4, 5],k = 5) == 8\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 15\n assert candidate(piles = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1],k = 100) == 25\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000],k = 25000) == 5\n assert candidate(piles = [1000, 500, 250, 125],k = 10) == 252\n assert candidate(piles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == 20\n assert candidate(piles = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],k = 100) == 10\n assert candidate(piles = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 50) == 1441\n assert candidate(piles = [9999, 9998, 9997, 9996, 9995],k = 100) == 5\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(piles = [1000, 999, 998, 997, 996, 995],k = 15) == 1123\n assert candidate(piles = [10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19],k = 50) == 149\n assert candidate(piles = [9999],k = 10000) == 1\n assert candidate(piles = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 1000) == 10\n assert candidate(piles = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 100) == 10\n assert candidate(piles = [1, 10, 100, 1000, 10000],k = 100) == 5\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 50) == 10\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 117\n assert candidate(piles = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991],k = 1000) == 10\n assert candidate(piles = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 1000) == 20\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 32\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 10\n assert candidate(piles = [1, 100, 1000, 10000, 10000, 1000, 100, 1],k = 50000) == 8\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 100) == 50\n assert candidate(piles = [50, 25, 75, 200, 150],k = 5) == 201\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 20\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 20\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 20\n assert candidate(piles = [10000, 1000, 100, 10, 1],k = 15000) == 5\n assert candidate(piles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1000) == 20\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 200) == 10\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000],k = 1000) == 5\n assert candidate(piles = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 1000) == 10\n assert candidate(piles = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512],k = 100) == 20\n assert candidate(piles = [1000, 500, 250, 125, 63, 32, 16, 8, 4, 2, 1],k = 30) == 63\n assert candidate(piles = [999, 1000, 1001, 1002, 1003],k = 10) == 1253\n assert candidate(piles = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 2500) == 20\n assert candidate(piles = [10000, 5000, 2500, 1250, 625],k = 20) == 785\n assert candidate(piles = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 30) == 63\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000],k = 100000) == 5\n assert candidate(piles = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 1000) == 20\n assert candidate(piles = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 50) == 20\n assert candidate(piles = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],k = 50) == 1441\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 100) == 15\n assert candidate(piles = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 500) == 20\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 20\n assert candidate(piles = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 20) == 253\n assert candidate(piles = [9999, 9999, 9999, 9999],k = 100000) == 4\n assert candidate(piles = [1, 10, 100, 1000, 10000],k = 10) == 315\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 20\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1000) == 10\n assert candidate(piles = [500, 300, 200, 100],k = 5) == 400\n assert candidate(piles = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 30) == 31\n assert candidate(piles = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111],k = 10000) == 9\n assert candidate(piles = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 100) == 11\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 5000) == 31\n assert candidate(piles = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],k = 50) == 3130\n assert candidate(piles = [5000, 4000, 3000, 2000, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],k = 100) == 16\n assert candidate(piles = [10, 15, 20, 25, 30, 35, 40, 45, 50],k = 100) == 9\n assert candidate(piles = [9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999],k = 10000) == 20\n assert candidate(piles = [9999, 1, 2, 3, 4, 5],k = 10) == 25\n assert candidate(piles = [1000, 1000, 1000, 1000, 1000],k = 50) == 5\n assert candidate(piles = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],k = 100) == 10\n assert candidate(piles = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],k = 5000) == 10\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 50000) == 10\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 50) == 30\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 100) == 20\n", "comparison": "exact"}, "public_tests": ["[5,4,9]\n2", "[4,3,6,7]\n3"], "hints": ["Choose the pile with the maximum number of stones each time.", "Use a data structure that helps you find the mentioned pile each time efficiently.", "One such data structure is a Priority Queue."], "metadata": {"canonical_parameter_names": ["piles", "k"], "leetcode_dataset_entry_point": "Solution().minStoneSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:30+00:00", "tests_total": 83, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "greedy", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def minStoneSum(self, piles: list[int], k: int) -> int:", "container": "Solution", "callable": "minStoneSum", "parameters": [{"name": "piles", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1963, "task_id": "minimum-number-of-swaps-to-make-the-string-balanced", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string s of even length n. The string consists of exactly n / 2 opening brackets '[' and n / 2 closing brackets ']'.\n\nA string is called balanced if and only if:\n\n- It is the empty string, or\n- It can be written as AB, where both A and B are balanced strings, or\n- It can be written as [C], where C is a balanced string.\n\nYou may swap the brackets at any two indices any number of times.\n\nReturn the minimum number of swaps to make s balanced.\n\nExample 1:\n\nInput: s = \"][][\"\nOutput: 1\nExplanation: You can make the string balanced by swapping index 0 with index 3.\nThe resulting string is \"[[]]\".\n\nExample 2:\n\nInput: s = \"]]][[[\"\nOutput: 2\nExplanation: You can do the following to make the string balanced:\n- Swap index 0 with index 4. s = \"[]][][\".\n- Swap index 1 with index 5. s = \"[[][]]\".\nThe resulting string is \"[[][]]\".\n\nExample 3:\n\nInput: s = \"[]\"\nOutput: 0\nExplanation: The string is already balanced.\n\nConstraints:\n\n- n == s.length\n- 2 <= n <= 10^6\n- n is even.\n- s[i] is either '[' or ']'.\n- The number of opening brackets '[' equals n / 2, and the number of closing brackets ']' equals n / 2.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"[]][[]\") == 1\n assert candidate(s = \"[[[[]]]]\") == 0\n assert candidate(s = \"]][[[]]]\") == 0\n assert candidate(s = \"][][\") == 1\n assert candidate(s = \"]]][[][[\") == 2\n assert candidate(s = \"]]]][[[[\") == 2\n assert candidate(s = \"][[]][\") == 1\n assert candidate(s = \"[][][][]\") == 0\n assert candidate(s = \"[[[]]]\") == 0\n assert candidate(s = \"[[[]]][[]]\") == 0\n assert candidate(s = \"]][[][][\") == 1\n assert candidate(s = \"]]][[[\") == 2\n assert candidate(s = \"[][]\") == 0\n assert candidate(s = \"[]\") == 0\n assert candidate(s = \"]][[\") == 1\n assert candidate(s = \"]]][[[[[[]]]]]\") == 1\n assert candidate(s = \"]][[[]\") == 1\n assert candidate(s = \"[[]][]\") == 0\n assert candidate(s = \"][[][]\") == 1\n assert candidate(s = \"[[[][]]]\") == 0\n assert candidate(s = \"]]]]][[[[[[[]]]]]]\") == 1\n assert candidate(s = \"]]]]][[[[[][][]]]]]][[[[[][][]]]]]\") == 0\n assert candidate(s = \"[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]\") == 1\n assert candidate(s = \"][]]]][[[[[]][[]]]\") == 1\n assert candidate(s = \"]][[[[[[[[[[]]]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]\") == 1\n assert candidate(s = \"]][[[]]]]][[[[[]]]\") == 1\n assert candidate(s = \"]]][[][[[[[]]]]]]]\") == 0\n assert candidate(s = \"]]][[[][]]][[[[[[[]]]]]][][][[]][[\") == 2\n assert candidate(s = \"]][[[]]][][[[[[[[[]]]]]][][[\") == 2\n assert candidate(s = \"]]][[[[[[[]]]]]]][[[[[]]]]]][[[[]]]]]]]]\") == 0\n assert candidate(s = \"]]]]][[[[[[]]][]]]\") == 1\n assert candidate(s = \"]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[\") == 1\n assert candidate(s = \"]][[[]]][][[[]]]\") == 0\n assert candidate(s = \"[[][]]]][[[][][[]][][[]][[]]\") == 1\n assert candidate(s = \"[[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]]\") == 0\n assert candidate(s = \"]]][[[[[[[]]]]]]][[[[[]]]]]][[[[[]]]]]\") == 0\n assert candidate(s = \"]]][[[[]][]][][[][]][][[[]][]][][[[]]]\") == 1\n assert candidate(s = \"[][][][][][][][][][][][][][][][][][][][][][][][]\") == 0\n assert candidate(s = \"[[[[[[[[]]]]]]]][[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]\") == 0\n assert candidate(s = \"]]]]]][[[[[[\") == 3\n assert candidate(s = \"]]]]][[[[[]]]]\") == 1\n assert candidate(s = \"]]][[[[[[[]]]]][[[[[[]]]]]]][[[[\") == 3\n assert candidate(s = \"]]]]][[[[[]]]][[\") == 2\n assert candidate(s = \"]]][[[[[[[[[[[][][]][[]][]]]]]]][[[[[[[[[][][]][[]][]]]]]]][[[[[[[[[][][]][[]][]]]]]]][[[[[[[[[][]]]]]]]]]\") == 3\n assert candidate(s = \"]][[[[[[[]]]]]]][[[[[]]]]]\") == 0\n assert candidate(s = \"]]][[[]][[[[]]]][]]]]][][[[[]]]]\") == 0\n assert candidate(s = \"]]][[[[]]][][[[]]]\") == 1\n assert candidate(s = \"]][[[[[][]]]]]][[[[[][]]]]]][[[[[][]]]]][[\") == 1\n assert candidate(s = \"]]][[[[[[[]]]]]]\") == 1\n assert candidate(s = \"]][[[][]]][[\") == 1\n assert candidate(s = \"]][[[[[[[[[[]]]]]]]]][[[[[[[[[[[]]]]]]]]]][[[[[[[[[[[]]]]]]]]]]]\") == 1\n assert candidate(s = \"]][[[]]][][[\") == 1\n assert candidate(s = \"]]][[[]]][[[]]]]][[[[[]]]]\") == 1\n assert candidate(s = \"]]]]][[[[[[]]]]][[[[]]]]\") == 1\n assert candidate(s = \"]]][[[[[[[[[[[][][]][[]][]]]][][[[[[[[[][][]][[]][]]]][][[[[[[[[][][]][[]][]]]][][[[[[[[[][]]]]]]]]]\") == 6\n assert candidate(s = \"]]][[[]]]][[[[\") == 2\n assert candidate(s = \"]]]][][][[[[\") == 2\n assert candidate(s = \"]]][[[[[[[][]]]]]]\") == 1\n assert candidate(s = \"]][[[]][[[]][]]]\") == 0\n assert candidate(s = \"]]][[[[]][]]\") == 1\n", "comparison": "exact"}, "public_tests": ["\"][][\"", "\"]]][[[\"", "\"[]\""], "hints": ["Iterate over the string and keep track of the number of opening and closing brackets on each step.", "If the number of closing brackets is ever larger, you need to make a swap.", "Swap it with the opening bracket closest to the end of s."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minSwaps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:33+00:00", "tests_total": 91, "tests_dropped": 31, "flags": [], "topic_tags": ["two-pointers", "string", "stack", "greedy", "bracket-sequences"]}, "language": "python", "interface": {"raw_signature": "def minSwaps(self, s: str) -> int:", "container": "Solution", "callable": "minSwaps", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1964, "task_id": "find-the-longest-valid-obstacle-course-at-each-position", "difficulty": "Hard", "problem_description": "You want to build some obstacle courses. You are given a 0-indexed integer array obstacles of length n, where obstacles[i] describes the height of the i^th obstacle.\n\nFor every index i between 0 and n - 1 (inclusive), find the length of the longest obstacle course in obstacles such that:\n\n- You choose any number of obstacles between 0 and i inclusive.\n- You must include the i^th obstacle in the course.\n- You must put the chosen obstacles in the same order as they appear in obstacles.\n- Every obstacle (except the first) is taller than or the same height as the obstacle immediately before it.\n\nReturn an array ans of length n, where ans[i] is the length of the longest obstacle course for index i as described above.\n\nExample 1:\n\nInput: obstacles = [1,2,3,2]\nOutput: [1,2,3,3]\nExplanation: The longest valid obstacle course at each position is:\n- i = 0: [1], [1] has length 1.\n- i = 1: [1,2], [1,2] has length 2.\n- i = 2: [1,2,3], [1,2,3] has length 3.\n- i = 3: [1,2,3,2], [1,2,2] has length 3.\n\nExample 2:\n\nInput: obstacles = [2,2,1]\nOutput: [1,2,1]\nExplanation: The longest valid obstacle course at each position is:\n- i = 0: [2], [2] has length 1.\n- i = 1: [2,2], [2,2] has length 2.\n- i = 2: [2,2,1], [1] has length 1.\n\nExample 3:\n\nInput: obstacles = [3,1,5,6,4,2]\nOutput: [1,1,2,3,2,2]\nExplanation: The longest valid obstacle course at each position is:\n- i = 0: [3], [3] has length 1.\n- i = 1: [3,1], [1] has length 1.\n- i = 2: [3,1,5], [3,5] has length 2. [1,5] is also valid.\n- i = 3: [3,1,5,6], [3,5,6] has length 3. [1,5,6] is also valid.\n- i = 4: [3,1,5,6,4], [3,4] has length 2. [1,4] is also valid.\n- i = 5: [3,1,5,6,4,2], [1,2] has length 2.\n\nConstraints:\n\n- n == obstacles.length\n- 1 <= n <= 10^5\n- 1 <= obstacles[i] <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(obstacles = [1]) == [1]\n assert candidate(obstacles = [3, 1, 5, 6, 4, 2]) == [1, 1, 2, 3, 2, 2]\n assert candidate(obstacles = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5]\n assert candidate(obstacles = [10, 9, 2, 5, 3, 7, 101, 18]) == [1, 1, 1, 2, 2, 3, 4, 4]\n assert candidate(obstacles = [10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1]\n assert candidate(obstacles = [2, 2, 1]) == [1, 2, 1]\n assert candidate(obstacles = [1, 3, 5, 6, 8, 7, 9, 4, 10, 2]) == [1, 2, 3, 4, 5, 5, 6, 3, 7, 2]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(obstacles = [1, 3, 5, 7, 9]) == [1, 2, 3, 4, 5]\n assert candidate(obstacles = [1, 2, 3, 2]) == [1, 2, 3, 3]\n assert candidate(obstacles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12]\n assert candidate(obstacles = [5, 1, 5, 2, 5, 3, 5, 4, 5]) == [1, 1, 2, 2, 3, 3, 4, 4, 5]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 3, 4, 5, 6]\n assert candidate(obstacles = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]\n assert candidate(obstacles = [10, 10, 10, 1, 1, 1, 10, 10, 10, 1, 1, 1, 10, 10, 10]) == [1, 2, 3, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 8, 9]\n assert candidate(obstacles = [5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3, 4, 5, 6, 7, 8, 9, 10, 11, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(obstacles = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 2, 7, 3, 7, 4, 7, 5, 7, 6, 7]\n assert candidate(obstacles = [5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 5]) == [1, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 4]\n assert candidate(obstacles = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 2, 4, 5, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == [1, 2, 3, 3, 2, 4, 5, 5, 3, 6, 7, 7, 4, 8, 9]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]\n assert candidate(obstacles = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14]\n assert candidate(obstacles = [7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1]) == [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [3, 2, 1, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17, 16, 18, 17, 19, 18, 20, 19, 21, 20, 22, 21, 23, 22, 24, 23, 25, 24, 26, 25, 27, 26, 28, 27, 29, 28, 30, 29, 31, 30, 32, 31, 33, 32, 34, 33, 35, 34, 36, 35, 37, 36, 38, 37, 39, 38, 40, 39]) == [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38]\n assert candidate(obstacles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 2, 4, 6, 8, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 3, 4, 5, 6]\n assert candidate(obstacles = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7]\n assert candidate(obstacles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 10, 7, 8, 5, 6, 3, 4, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 4, 5, 6, 7]\n assert candidate(obstacles = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]\n assert candidate(obstacles = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]\n assert candidate(obstacles = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 19, 18, 17, 16, 15, 14, 13, 12]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(obstacles = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == [1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7]\n assert candidate(obstacles = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]\n assert candidate(obstacles = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16]\n assert candidate(obstacles = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1, 5, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 3, 2, 4, 5, 5, 4, 4, 3, 6, 7, 7, 6, 5, 5, 4]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 4, 5, 6, 7, 7, 6, 5, 3]\n assert candidate(obstacles = [100000, 99999, 99998, 100000, 100000, 99999, 99998, 99997, 99996, 99995]) == [1, 1, 1, 2, 3, 2, 2, 1, 1, 1]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 6, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(obstacles = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6]\n assert candidate(obstacles = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]\n assert candidate(obstacles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 10, 9, 8, 7, 6, 5, 4, 3]\n assert candidate(obstacles = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 1, 2, 3, 4, 5]\n assert candidate(obstacles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67]\n assert candidate(obstacles = [1, 2, 2, 3, 3, 2, 1, 4, 4, 3, 3, 5, 5, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7]) == [1, 2, 3, 4, 5, 4, 2, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]\n assert candidate(obstacles = [2, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2]) == [1, 2, 3, 4, 2, 3, 4, 5, 6, 7, 8, 9, 6, 7, 8, 9]\n assert candidate(obstacles = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 10, 7, 8, 5, 6, 3, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 2, 2, 3, 4, 5, 5, 6, 6, 7, 8, 9, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 13, 12, 11, 10, 8, 6, 5, 4, 2]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [10000000, 5000000, 7500000, 6000000, 8000000, 9000000, 4000000, 3000000, 2000000, 1000000]) == [1, 1, 2, 2, 3, 4, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(obstacles = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n assert candidate(obstacles = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 2, 6, 3, 6, 4, 6, 5, 6, 6]\n assert candidate(obstacles = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]\n assert candidate(obstacles = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 10, 9, 8, 7, 6, 5, 4, 3]\n assert candidate(obstacles = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == [1, 2, 3, 4, 5, 2, 3, 4, 5, 6]\n assert candidate(obstacles = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(obstacles = [1, 3, 5, 2, 4, 6, 3, 5, 7, 8, 4, 6, 9]) == [1, 2, 3, 2, 3, 4, 3, 4, 5, 6, 4, 5, 7]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == [1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7]\n assert candidate(obstacles = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 11, 10, 9, 8, 7, 6, 5, 3]\n assert candidate(obstacles = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(obstacles = [1, 2, 3, 2, 1, 3, 4, 5, 4, 3, 2, 4, 5, 6, 5, 4, 3, 4, 5]) == [1, 2, 3, 3, 2, 4, 5, 6, 6, 5, 4, 7, 8, 9, 9, 8, 6, 9, 10]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 4, 5, 6, 7, 7, 6, 5, 3, 6, 7, 8, 9]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(obstacles = [1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(obstacles = [3, 1, 2, 3, 4, 2, 1, 4, 3, 2, 5, 6, 4, 5, 7, 8, 9]) == [1, 1, 2, 3, 4, 3, 2, 5, 4, 4, 6, 7, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 2, 8, 3, 7, 4, 7, 5, 7, 6, 7, 9, 3, 10, 4, 8, 5, 8, 6, 8, 7, 8, 11]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(obstacles = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, 12, 13, 14, 15, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 2, 3, 4, 5]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 3, 4, 5, 6, 7, 8, 9, 10, 21]\n assert candidate(obstacles = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 7, 8, 9]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n assert candidate(obstacles = [5, 3, 4, 1, 2, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [1, 1, 2, 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7]\n assert candidate(obstacles = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]\n assert candidate(obstacles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == [1, 2, 3, 4, 2, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 10, 8, 9, 10, 8, 9, 10]\n assert candidate(obstacles = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]\n assert candidate(obstacles = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == [1, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9]\n assert candidate(obstacles = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 5, 3, 4, 5, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1]) == [1, 2, 3, 4, 5, 5, 6, 4, 6, 7, 3, 5, 7, 8, 2, 4, 6, 8, 9, 3]\n assert candidate(obstacles = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990, 9999989, 9999988, 9999987, 9999986, 9999985, 9999984, 9999983, 9999982, 9999981, 9999980, 9999979, 9999978, 9999977, 9999976, 9999975, 9999974, 9999973, 9999972, 9999971]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == [1, 1, 1, 2, 3, 3, 2, 4, 5, 6, 6, 5, 3, 6, 7, 8, 9]\n", "comparison": "exact"}, "public_tests": ["[1,2,3,2]", "[2,2,1]", "[3,1,5,6,4,2]"], "hints": ["Can you keep track of the minimum height for each obstacle course length?", "You can use binary search to find the longest previous obstacle course length that satisfies the conditions."], "metadata": {"canonical_parameter_names": ["obstacles"], "leetcode_dataset_entry_point": "Solution().longestObstacleCourseAtEachPosition", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:35+00:00", "tests_total": 128, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "binary-search", "binary-indexed-tree", "longest-increasing-subsequence"]}, "language": "python", "interface": {"raw_signature": "def longestObstacleCourseAtEachPosition(self, obstacles: list[int]) -> list[int]:", "container": "Solution", "callable": "longestObstacleCourseAtEachPosition", "parameters": [{"name": "obstacles", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1967, "task_id": "number-of-strings-that-appear-as-substrings-in-word", "difficulty": "Easy", "problem_description": "Given an array of strings patterns and a string word, return the number of strings in patterns that exist as a substring in word.\n\nA substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: patterns = [\"a\",\"abc\",\"bc\",\"d\"], word = \"abc\"\nOutput: 3\nExplanation:\n- \"a\" appears as a substring in \"abc\".\n- \"abc\" appears as a substring in \"abc\".\n- \"bc\" appears as a substring in \"abc\".\n- \"d\" does not appear as a substring in \"abc\".\n3 of the strings in patterns appear as a substring in word.\n\nExample 2:\n\nInput: patterns = [\"a\",\"b\",\"c\"], word = \"aaaaabbbbb\"\nOutput: 2\nExplanation:\n- \"a\" appears as a substring in \"aaaaabbbbb\".\n- \"b\" appears as a substring in \"aaaaabbbbb\".\n- \"c\" does not appear as a substring in \"aaaaabbbbb\".\n2 of the strings in patterns appear as a substring in word.\n\nExample 3:\n\nInput: patterns = [\"a\",\"a\",\"a\"], word = \"ab\"\nOutput: 3\nExplanation: Each of the patterns appears as a substring in word \"ab\".\n\nConstraints:\n\n- 1 <= patterns.length <= 100\n- 1 <= patterns[i].length <= 100\n- 1 <= word.length <= 100\n- patterns[i] and word consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(patterns = ['a', 'b', 'c'],word = \"aaaaabbbbb\") == 2\n assert candidate(patterns = ['aa', 'bb', 'cc'],word = \"abcabc\") == 0\n assert candidate(patterns = ['a', 'abc', 'bc', 'd'],word = \"abc\") == 3\n assert candidate(patterns = ['aaa'],word = \"aaaaa\") == 1\n assert candidate(patterns = ['abc'],word = \"abc\") == 1\n assert candidate(patterns = ['xyz', 'xy', 'yz'],word = \"xyz\") == 3\n assert candidate(patterns = ['hello', 'world'],word = \"helloworld\") == 2\n assert candidate(patterns = ['a', 'a', 'a'],word = \"ab\") == 3\n assert candidate(patterns = ['z'],word = \"abcz\") == 1\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e'],word = \"edcba\") == 5\n assert candidate(patterns = ['hello', 'world', 'foo', 'bar'],word = \"helloworldfoo\") == 3\n assert candidate(patterns = ['repeated', 'repeat', 'eat'],word = \"repeatedrepeat\") == 3\n assert candidate(patterns = ['this', 'is', 'a', 'test'],word = \"thisisatest\") == 4\n assert candidate(patterns = ['abc', 'cab', 'bac'],word = \"abacabcabc\") == 3\n assert candidate(patterns = ['aabb', 'bbcc', 'ccdd', 'ddaa'],word = \"aabbccdd\") == 3\n assert candidate(patterns = ['a', 'ab', 'abc', 'abcd'],word = \"abcd\") == 4\n assert candidate(patterns = ['a', 'aa', 'aaa', 'aaaa'],word = \"aaaaaaaa\") == 4\n assert candidate(patterns = ['overlapping', 'lapping', 'lappingo', 'verlapping'],word = \"overlappinglappingoverlappingoverlapping\") == 4\n assert candidate(patterns = ['hello', 'world', 'python', 'programming'],word = \"helloworldpythonprogramming\") == 4\n assert candidate(patterns = ['xyz', 'zyx', 'zxy'],word = \"xyzzyxzyxzxyzyx\") == 3\n assert candidate(patterns = ['xy', 'yx', 'xyz', 'zyx'],word = \"xyzzyx\") == 4\n assert candidate(patterns = ['lorem', 'ipsum', 'dolor', 'sit', 'amet'],word = \"loremipsumdolorsitamet\") == 5\n assert candidate(patterns = ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwx', 'vwxy', 'wxyz'],word = \"abcdefghijklmnopqrstuvwxyz\") == 23\n assert candidate(patterns = ['mnop', 'nopq', 'opqr', 'pqrs', 'qrst'],word = \"mnopqrstu\") == 5\n assert candidate(patterns = ['quick', 'brown', 'fox'],word = \"thequickbrownfox\") == 3\n assert candidate(patterns = ['abcd', 'abcde', 'abcdef'],word = \"abcdefgabcdefg\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'yxz', 'xzy', 'zyx'],word = \"zyxzyxzyxzyx\") == 4\n assert candidate(patterns = ['ab', 'ba', 'aba', 'bab'],word = \"abababab\") == 4\n assert candidate(patterns = ['aaaa', 'bbbb', 'cccc'],word = \"aaaabbbbccccaaaabbbbcccc\") == 3\n assert candidate(patterns = ['aba', 'bba', 'aaa', 'bbb'],word = \"abababababa\") == 1\n assert candidate(patterns = ['repeated', 'pattern', 'substring', 'string'],word = \"repeatedpatternsubstringstring\") == 4\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de', 'ef', 'fg'],word = \"abcdefg\") == 6\n assert candidate(patterns = ['repeated', 'substring', 'example'],word = \"repeatedsubstringexample\") == 3\n assert candidate(patterns = ['overlap', 'lap', 'ap', 'p'],word = \"overlaplapap\") == 4\n assert candidate(patterns = ['hello', 'world', 'python', 'programming'],word = \"programmingworldpython\") == 3\n assert candidate(patterns = ['longer', 'substrings', 'to', 'check'],word = \"thisisalongersubstringtocheck\") == 3\n assert candidate(patterns = ['unique', 'un', 'iq'],word = \"uniqueiq\") == 3\n assert candidate(patterns = ['substring', 'string', 'sub'],word = \"thisisjustasubstringexample\") == 3\n assert candidate(patterns = ['hello', 'world', 'hello', 'world'],word = \"helloworldhello\") == 4\n assert candidate(patterns = ['aaa', 'aa', 'a'],word = \"aaaaaaaaaaaa\") == 3\n assert candidate(patterns = ['z', 'zz', 'zzz'],word = \"zzzzzzzzz\") == 3\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de', 'ef'],word = \"abcdef\") == 5\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],word = \"abcdefghij\") == 10\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e', 'f'],word = \"abcdef\") == 6\n assert candidate(patterns = ['a', 'ab', 'abc', 'abcd', 'abcde'],word = \"abcde\") == 5\n assert candidate(patterns = ['one', 'two', 'three'],word = \"onetwothreeonetwothree\") == 3\n assert candidate(patterns = ['aaa', 'aab', 'aba', 'baa', 'aabaa', 'aaaba', 'aaba', 'baaa'],word = \"aaaabaaaa\") == 8\n assert candidate(patterns = ['hello', 'world', 'helloworld'],word = \"helloworld\") == 3\n assert candidate(patterns = ['quick', 'brown', 'fox'],word = \"thequickbrownfoxjumps\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'yzz', 'zzz'],word = \"xyzzyzyzzz\") == 3\n assert candidate(patterns = ['aaa', 'bbb', 'ccc', 'abc', 'bca', 'cab'],word = \"abcabcabc\") == 3\n assert candidate(patterns = ['abcd', 'dcba', 'abcdabcd'],word = \"abcdabcdabcdabcd\") == 2\n assert candidate(patterns = ['a', 'ab', 'abc', 'abcd', 'abcde'],word = \"abcdefghijklmnopqrstuvwxyz\") == 5\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl'],word = \"abcdefghijkl\") == 4\n assert candidate(patterns = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd'],word = \"abcdeabcdeabcdeabcde\") == 0\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de'],word = \"abcdefg\") == 4\n assert candidate(patterns = ['pattern', 'matching', 'substrings'],word = \"matchingpatternsubstring\") == 2\n assert candidate(patterns = ['ab', 'ba', 'abab', 'baba'],word = \"abababababababab\") == 4\n assert candidate(patterns = ['same', 'sub', 'string', 'test', 'case'],word = \"substringtestcase\") == 4\n assert candidate(patterns = ['aaaa', 'bbbb', 'cccc', 'ddd'],word = \"aaaabbbbccccddd\") == 4\n assert candidate(patterns = ['apple', 'banana', 'cherry'],word = \"cherrybananaapple\") == 3\n assert candidate(patterns = ['cat', 'dog', 'bird', 'fish'],word = \"fishdogcatbird\") == 4\n assert candidate(patterns = ['python', 'java', 'cpp'],word = \"pythonjavacpp\") == 3\n assert candidate(patterns = ['aaa', 'bbb', 'ccc', 'ddd'],word = \"aaabbbcccddd\") == 4\n assert candidate(patterns = ['test', 'sett', 'best'],word = \"bestsett\") == 2\n assert candidate(patterns = ['abc', 'bca', 'cab', 'abcabc'],word = \"abcabcabcabc\") == 4\n assert candidate(patterns = ['aaa', 'aa', 'a'],word = \"aaaaaaaaaa\") == 3\n assert candidate(patterns = ['quick', 'brown', 'fox', 'jump', 'over', 'lazy', 'dog'],word = \"thequickbrownfoxjumpsoverthelazydog\") == 7\n assert candidate(patterns = ['abc', 'cab', 'bca'],word = \"abcabcabcabc\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'xy', 'yx', 'xzy', 'yzx'],word = \"zyxwvutsrqponmlkjihgfedcba\") == 2\n assert candidate(patterns = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff'],word = \"abcdefabcdefabcdef\") == 0\n assert candidate(patterns = ['abc', 'def', 'ghi'],word = \"defabc\") == 2\n assert candidate(patterns = ['quick', 'brown', 'fox'],word = \"thequickbrownfoxjumpsoverthelazydog\") == 3\n assert candidate(patterns = ['aaa', 'aa', 'a'],word = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 3\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],word = \"abcdefghijabcdefghij\") == 10\n assert candidate(patterns = ['test', 'string', 'finding', 'substring'],word = \"teststringfindingsubstring\") == 4\n assert candidate(patterns = ['aa', 'aaa', 'aaaa'],word = \"aaaa\") == 3\n assert candidate(patterns = ['short', 'shot', 'dot'],word = \"shortshot\") == 2\n assert candidate(patterns = ['foo', 'bar', 'foobar', 'barfoo'],word = \"foobarbarfoobarfoo\") == 4\n assert candidate(patterns = ['aba', 'bab', 'aba'],word = \"ababababa\") == 3\n assert candidate(patterns = ['hello', 'world', 'python'],word = \"pythonworldhello\") == 3\n assert candidate(patterns = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'],word = \"abcacbcbacbacbcbac\") == 5\n assert candidate(patterns = ['banana', 'ana', 'nan', 'ban'],word = \"banananana\") == 4\n assert candidate(patterns = ['abc', 'abcd', 'abcde'],word = \"abcdefgh\") == 3\n assert candidate(patterns = ['abcd', 'dcba', 'abcd'],word = \"abcdcbaabcd\") == 3\n assert candidate(patterns = ['aaaa', 'bbbb', 'cccc', 'dddd'],word = \"abcdeabcdeabcde\") == 0\n assert candidate(patterns = ['longpattern', 'long', 'pattern'],word = \"longpatternlongpattern\") == 3\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de', 'ef', 'fg', 'gh', 'hi', 'ij'],word = \"abcdefghij\") == 9\n assert candidate(patterns = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz'],word = \"abcdefghijklmnopqrstuvwxyz\") == 24\n assert candidate(patterns = ['zzz', 'zzzz', 'zzzzz'],word = \"zzzzzzzzzz\") == 3\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de'],word = \"abcde\") == 4\n assert candidate(patterns = ['abc', 'bcd', 'cde', 'def'],word = \"abcdefg\") == 4\n assert candidate(patterns = ['abc', 'abcd', 'abcde', 'abcdef'],word = \"abcdefg\") == 4\n assert candidate(patterns = ['test', 'tset', 'sett', 'settset'],word = \"testsettsettset\") == 4\n assert candidate(patterns = ['small', 'medium', 'large', 'extra', 'huge'],word = \"smallmediumlargeextrahuge\") == 5\n assert candidate(patterns = ['pattern', 'tern', 'ternary', 'ternarysearch'],word = \"binarysearchternarysearch\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'yzx'],word = \"xyzzyxzyxzyx\") == 2\n assert candidate(patterns = ['abcd', 'efgh', 'ijkl'],word = \"efghijklabcd\") == 3\n assert candidate(patterns = ['abc', 'cab', 'bac', 'bca', 'acb', 'cba'],word = \"abcabcabc\") == 3\n assert candidate(patterns = ['abc', 'abcabc', 'abcabcabc'],word = \"abcabcabcabc\") == 3\n assert candidate(patterns = ['aaa', 'bbb', 'ccc'],word = \"abacabadabc\") == 0\n assert candidate(patterns = ['one', 'two', 'three', 'onetwothree'],word = \"onetwothreeonetwothree\") == 4\n assert candidate(patterns = ['search', 'sear', 'arch'],word = \"searchingthesearchinthesearch\") == 3\n assert candidate(patterns = ['overlap', 'lap', 'lapping'],word = \"lapping\") == 2\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl'],word = \"abcdefghijklmnopqrstuvwxyz\") == 4\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl'],word = \"abcdefghijk\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'wxy', 'uvw'],word = \"xyzzyxwxyuvw\") == 4\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl'],word = \"abcdefghij\") == 3\n assert candidate(patterns = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yz'],word = \"abcdefghijklmnopqrstuvwxyz\") == 7\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],word = \"abcdefghijklmnopqrstuvwxyz\") == 9\n assert candidate(patterns = ['zz', 'zzz', 'zzzz'],word = \"zzzzzzzzzz\") == 3\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],word = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(patterns = ['example', 'ample', 'mple', 'ple', 'le', 'e'],word = \"exampleexampleexample\") == 6\n assert candidate(patterns = ['ab', 'ba', 'ac', 'ca', 'bc', 'cb'],word = \"abcbaacbba\") == 5\n assert candidate(patterns = ['abc', 'def', 'ghi'],word = \"abcdefghi\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'yzx'],word = \"xyzzyxzyx\") == 2\n assert candidate(patterns = ['zzz', 'zz', 'z'],word = \"zzzzzzzzzz\") == 3\n assert candidate(patterns = ['pattern', 'tern', 'ternary', 'ary'],word = \"patternarypatternary\") == 4\n assert candidate(patterns = ['xyz', 'abc', 'def', 'ghi', 'jkl'],word = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(patterns = ['a', 'ab', 'abc', 'abcd'],word = \"abcdabcdabcd\") == 4\n", "comparison": "exact"}, "public_tests": ["[\"a\",\"abc\",\"bc\",\"d\"]\n\"abc\"", "[\"a\",\"b\",\"c\"]\n\"aaaaabbbbb\"", "[\"a\",\"a\",\"a\"]\n\"ab\""], "hints": ["Deal with each of the patterns individually.", "Use the built-in function in the language you are using to find if the pattern exists as a substring in word."], "metadata": {"canonical_parameter_names": ["patterns", "word"], "leetcode_dataset_entry_point": "Solution().numOfStrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:40+00:00", "tests_total": 122, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "string"]}, "language": "python", "interface": {"raw_signature": "def numOfStrings(self, patterns: list[str], word: str) -> int:", "container": "Solution", "callable": "numOfStrings", "parameters": [{"name": "patterns", "type": "list[str]"}, {"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1968, "task_id": "array-with-elements-not-equal-to-average-of-neighbors", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums of distinct integers. You want to rearrange the elements in the array such that every element in the rearranged array is not equal to the average of its neighbors.\n\nMore formally, the rearranged array should have the property such that for every i in the range 1 <= i < nums.length - 1, (nums[i-1] + nums[i+1]) / 2 is not equal to nums[i].\n\nReturn any rearrangement of nums that meets the requirements.\n\nExample 1:\n\nInput: nums = [1,2,3,4,5]\nOutput: [1,2,4,5,3]\nExplanation:\nWhen i=1, nums[i] = 2, and the average of its neighbors is (1+4) / 2 = 2.5.\nWhen i=2, nums[i] = 4, and the average of its neighbors is (2+5) / 2 = 3.5.\nWhen i=3, nums[i] = 5, and the average of its neighbors is (4+3) / 2 = 3.5.\n\nExample 2:\n\nInput: nums = [6,2,0,9,7]\nOutput: [9,7,6,2,0]\nExplanation:\nWhen i=1, nums[i] = 7, and the average of its neighbors is (9+6) / 2 = 7.5.\nWhen i=2, nums[i] = 6, and the average of its neighbors is (7+2) / 2 = 4.5.\nWhen i=3, nums[i] = 2, and the average of its neighbors is (6+0) / 2 = 3.\nNote that the original array [6,2,0,9,7] also satisfies the conditions.\n\nConstraints:\n\n- 3 <= nums.length <= 10^5\n- 0 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 100000, 50000, 25000, 75000]) == [0, 75000, 25000, 100000, 50000]\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == [10, 40, 20, 50, 30, 60]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13]) == [1, 9, 3, 11, 5, 13, 7]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7]) == [1, 5, 2, 6, 3, 7, 4]\n assert candidate(nums = [3, 1, 2, 5, 4]) == [1, 4, 2, 5, 3]\n assert candidate(nums = [10, 5, 1, 6, 2]) == [1, 6, 2, 10, 5]\n assert candidate(nums = [5, 1, 3, 2, 4]) == [1, 4, 2, 5, 3]\n assert candidate(nums = [5, 10, 15, 20, 25, 30]) == [5, 20, 10, 25, 15, 30]\n assert candidate(nums = [6, 2, 0, 9, 7]) == [0, 7, 2, 9, 6]\n assert candidate(nums = [0, 100, 50, 25, 75]) == [0, 75, 25, 100, 50]\n assert candidate(nums = [10, 20, 30, 40, 50]) == [10, 40, 20, 50, 30]\n assert candidate(nums = [5, 3, 1, 2, 4]) == [1, 4, 2, 5, 3]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [1, 4, 2, 5, 3]\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == [1, 7, 3, 9, 5, 11]\n assert candidate(nums = [10, 0, 5, 3, 8]) == [0, 8, 3, 10, 5]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == [100, 106, 101, 107, 102, 108, 103, 109, 104, 110, 105]\n assert candidate(nums = [31, 41, 59, 26, 53, 58, 97, 93, 23, 84, 62, 64, 33, 83, 27, 95, 0, 88, 49, 51]) == [0, 58, 23, 59, 26, 62, 27, 64, 31, 83, 33, 84, 41, 88, 49, 93, 51, 95, 53, 97]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == [7, 77, 14, 84, 21, 91, 28, 98, 35, 105, 42, 112, 49, 119, 56, 126, 63, 133, 70, 140]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 600, 200, 700, 300, 800, 400, 900, 500, 1000]\n assert candidate(nums = [85, 90, 80, 95, 75, 100, 70, 105, 65, 110]) == [65, 90, 70, 95, 75, 100, 80, 105, 85, 110]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [1, 32, 2, 64, 4, 128, 8, 256, 16, 512]\n assert candidate(nums = [100000, 50000, 25000, 12500, 62500, 31250, 93750, 46875, 15625, 78125]) == [12500, 50000, 15625, 62500, 25000, 78125, 31250, 93750, 46875, 100000]\n assert candidate(nums = [123, 456, 789, 234, 567, 890, 345, 678, 901, 12, 34, 56]) == [12, 456, 34, 567, 56, 678, 123, 789, 234, 890, 345, 901]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986]) == [9986, 9994, 9987, 9995, 9988, 9996, 9989, 9997, 9990, 9998, 9991, 9999, 9992, 10000, 9993]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [5, 3, 8, 6, 11, 9, 14, 12, 17, 15, 20, 18, 23, 21, 26, 24, 29, 27, 32, 30]) == [3, 18, 5, 20, 6, 21, 8, 23, 9, 24, 11, 26, 12, 27, 14, 29, 15, 30, 17, 32]\n assert candidate(nums = [100000, 0, 50000, 25000, 75000, 12500, 87500, 31250, 68750]) == [0, 68750, 12500, 75000, 25000, 87500, 31250, 100000, 50000]\n assert candidate(nums = [50, 25, 75, 37, 62, 88, 43, 91, 56, 12]) == [12, 56, 25, 62, 37, 75, 43, 88, 50, 91]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == [1, 5, 1, 5, 2, 5, 2, 6, 3, 6, 3, 7, 3, 8, 3, 9, 4, 9, 4, 9]\n assert candidate(nums = [5, 15, 10, 20, 25, 30, 35, 40, 45, 50]) == [5, 30, 10, 35, 15, 40, 20, 45, 25, 50]\n assert candidate(nums = [5, 15, 10, 20, 25, 12, 30, 18, 28]) == [5, 20, 10, 25, 12, 28, 15, 30, 18]\n assert candidate(nums = [8, 6, 4, 2, 0, 1, 3, 5, 7, 9]) == [0, 5, 1, 6, 2, 7, 3, 8, 4, 9]\n assert candidate(nums = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995, 6, 99994, 7, 99993]) == [1, 99994, 2, 99995, 3, 99996, 4, 99997, 5, 99998, 6, 99999, 7, 100000, 99993]\n assert candidate(nums = [8, 1, 6, 3, 9, 4, 5, 2, 7]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [42, 84, 21, 168, 105, 252, 175, 336, 245, 420, 315, 462, 368]) == [21, 252, 42, 315, 84, 336, 105, 368, 168, 420, 175, 462, 245]\n assert candidate(nums = [8192, 16384, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1, 256, 2, 512, 4, 1024, 8, 2048, 16, 4096, 32, 8192, 64, 16384, 128]\n assert candidate(nums = [1, 4, 2, 5, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15, 8]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0]) == [0, 55555, 11111, 66666, 22222, 77777, 33333, 88888, 44444, 99999]\n assert candidate(nums = [34, 7, 23, 32, 5, 62, 32, 2, 78, 1, 45, 67, 89, 12, 34, 56, 78, 90]) == [1, 34, 2, 45, 5, 56, 7, 62, 12, 67, 23, 78, 32, 78, 32, 89, 34, 90]\n assert candidate(nums = [101, 203, 305, 407, 509, 611, 713, 815, 917, 1019]) == [101, 611, 203, 713, 305, 815, 407, 917, 509, 1019]\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == [15, 90, 30, 105, 45, 120, 60, 135, 75, 150]\n assert candidate(nums = [10, 5, 8, 2, 6, 4, 9, 1, 7, 3]) == [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]\n assert candidate(nums = [1, 5, 3, 9, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == [1, 5, 1, 5, 2, 5, 3, 6, 3, 9, 4, 9]\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125]) == [15, 75, 25, 85, 35, 95, 45, 105, 55, 115, 65, 125]\n assert candidate(nums = [99999, 0, 50000, 25000, 75000, 1, 99998]) == [0, 75000, 1, 99998, 25000, 99999, 50000]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 30, 10, 35, 15, 40, 20, 45, 25, 50]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13]) == [1, 8, 2, 9, 3, 10, 4, 11, 5, 12, 6, 13, 7]\n assert candidate(nums = [85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == [85, 93, 86, 94, 87, 95, 88, 96, 89, 97, 90, 98, 91, 99, 92, 100]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40]) == [5, 25, 10, 30, 15, 35, 20, 40]\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == [99990, 99995, 99991, 99996, 99992, 99997, 99993, 99998, 99994, 99999]\n assert candidate(nums = [42, 84, 21, 105, 52, 7, 14, 35, 28, 70]) == [7, 42, 14, 52, 21, 70, 28, 84, 35, 105]\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == [1, 13, 2, 21, 3, 34, 5, 55, 8, 89]\n assert candidate(nums = [1000, 2000, 500, 3000, 1500, 4000, 2500, 5000, 3500]) == [500, 3000, 1000, 3500, 1500, 4000, 2000, 5000, 2500]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [5, 55, 15, 65, 25, 75, 35, 85, 45, 95]\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350, 500, 450, 600]) == [100, 350, 150, 400, 200, 450, 250, 500, 300, 600]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [7, 17, 8, 18, 9, 19, 10, 20, 11, 21, 12, 22, 13, 23, 14, 24, 15, 25, 16]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == [1, 256, 2, 512, 4, 1024, 8, 2048, 16, 4096, 32, 8192, 64, 16384, 128]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10]) == [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == [90, 95, 91, 96, 92, 97, 93, 98, 94, 99]\n assert candidate(nums = [10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009]) == [10000, 10005, 10001, 10006, 10002, 10007, 10003, 10008, 10004, 10009]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [2, 14, 4, 16, 6, 18, 8, 20, 10, 22, 12]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30, 16]\n assert candidate(nums = [50000, 25000, 75000, 12500, 87500, 31250, 68750, 15625, 93750]) == [12500, 68750, 15625, 75000, 25000, 87500, 31250, 93750, 50000]\n assert candidate(nums = [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180]) == [180, 191, 181, 192, 182, 193, 183, 194, 184, 195, 185, 196, 186, 197, 187, 198, 188, 199, 189, 200, 190]\n assert candidate(nums = [8, 6, 4, 2, 0, 1, 3, 5, 7, 9, 11, 13]) == [0, 6, 1, 7, 2, 8, 3, 9, 4, 11, 5, 13]\n assert candidate(nums = [50, 40, 30, 20, 10, 60, 70, 80, 90, 100, 110, 120]) == [10, 70, 20, 80, 30, 90, 40, 100, 50, 110, 60, 120]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15, 8]\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]\n assert candidate(nums = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100]) == [10, 60, 20, 70, 30, 80, 40, 90, 50, 100]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 5, 1, 6, 2, 7, 3, 8, 4, 9]\n assert candidate(nums = [23, 45, 12, 67, 89, 34, 56, 78, 90, 11, 32, 54]) == [11, 54, 12, 56, 23, 67, 32, 78, 34, 89, 45, 90]\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [1, 5, 1, 5, 2, 5, 3, 6, 3, 9, 4]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]) == [100, 111, 101, 112, 102, 113, 103, 114, 104, 115, 105, 116, 106, 117, 107, 118, 108, 119, 109, 120, 110]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == [10, 70, 20, 80, 30, 90, 40, 100, 50, 110, 60, 120]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [10, 90, 20, 100, 30, 110, 40, 120, 50, 130, 60, 140, 70, 150, 80]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == [7, 63, 14, 70, 21, 77, 28, 84, 35, 91, 42, 98, 49, 105, 56]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == [85, 93, 86, 94, 87, 95, 88, 96, 89, 97, 90, 98, 91, 99, 92, 100]\n assert candidate(nums = [1, 2, 3, 6, 5, 4, 7, 8, 9]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]) == [100, 800, 200, 900, 300, 1000, 400, 1100, 500, 1200, 600, 1300, 700]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == [85, 93, 86, 94, 87, 95, 88, 96, 89, 97, 90, 98, 91, 99, 92]\n assert candidate(nums = [8, 1, 6, 3, 5, 7, 2, 4, 9]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == [1, 100, 2, 200, 3, 300, 4, 400, 5, 500]\n assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995]) == [1, 99996, 2, 99997, 3, 99998, 4, 99999, 99995]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == [1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15, 8]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119]) == [7, 70, 14, 77, 21, 84, 28, 91, 35, 98, 42, 105, 49, 112, 56, 119, 63]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 60, 20, 70, 30, 80, 40, 90, 50, 100]\n assert candidate(nums = [8, 1, 4, 9, 3, 7, 6, 2, 5, 10]) == [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707]) == [101, 456, 123, 505, 202, 606, 303, 707, 404, 789]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 5, 1, 6, 2, 7, 3, 8, 4, 9]\n assert candidate(nums = [15, 10, 5, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == [5, 45, 10, 50, 15, 55, 20, 60, 25, 65, 30, 70, 35, 75, 40]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [5, 35, 10, 40, 15, 45, 20, 50, 25, 55, 30]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 600, 200, 700, 300, 800, 400, 900, 500, 1000]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [1000, 6000, 2000, 7000, 3000, 8000, 4000, 9000, 5000, 10000]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [10, 90, 20, 100, 30, 110, 40, 120, 50, 130, 60, 140, 70, 150, 80]\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350]) == [100, 300, 150, 350, 200, 400, 250]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7]) == [7, 17, 8, 18, 9, 19, 10, 20, 11, 21, 12, 22, 13, 23, 14, 24, 15, 25, 16]\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120]) == [12, 72, 24, 84, 36, 96, 48, 108, 60, 120]\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5]", "[6,2,0,9,7]"], "hints": ["A number can be the average of its neighbors if one neighbor is smaller than the number and the other is greater than the number.", "We can put numbers smaller than the median on odd indices and the rest on even indices."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().rearrangeArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:43+00:00", "tests_total": 115, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def rearrangeArray(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "rearrangeArray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1970, "task_id": "last-day-where-you-can-still-cross", "difficulty": "Hard", "problem_description": "There is a 1-based binary matrix where 0 represents land and 1 represents water. You are given integers row and col representing the number of rows and columns in the matrix, respectively.\n\nInitially on day 0, the entire matrix is land. However, each day a new cell becomes flooded with water. You are given a 1-based 2D array cells, where cells[i] = [r_i, c_i] represents that on the i^th day, the cell on the r_i^th row and c_i^th column (1-based coordinates) will be covered with water (i.e., changed to 1).\n\nYou want to find the last day that it is possible to walk from the top to the bottom by only walking on land cells. You can start from any cell in the top row and end at any cell in the bottom row. You can only travel in the four cardinal directions (left, right, up, and down).\n\nReturn the last day where it is possible to walk from the top to the bottom by only walking on land cells.\n\nExample 1:\n\nInput: row = 2, col = 2, cells = [[1,1],[2,1],[1,2],[2,2]]\nOutput: 2\nExplanation: The above image depicts how the matrix changes each day starting from day 0.\nThe last day where it is possible to cross from top to bottom is on day 2.\n\nExample 2:\n\nInput: row = 2, col = 2, cells = [[1,1],[1,2],[2,1],[2,2]]\nOutput: 1\nExplanation: The above image depicts how the matrix changes each day starting from day 0.\nThe last day where it is possible to cross from top to bottom is on day 1.\n\nExample 3:\n\nInput: row = 3, col = 3, cells = [[1,2],[2,1],[3,3],[2,2],[1,1],[1,3],[2,3],[3,2],[3,1]]\nOutput: 3\nExplanation: The above image depicts how the matrix changes each day starting from day 0.\nThe last day where it is possible to cross from top to bottom is on day 3.\n\nConstraints:\n\n- 2 <= row, col <= 2 * 10^4\n- 4 <= row * col <= 2 * 10^4\n- cells.length == row * col\n- 1 <= r_i <= row\n- 1 <= c_i <= col\n- All the values of cells are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(row = 3,col = 3,cells = [[1, 2], [2, 1], [3, 3], [2, 2], [1, 1], [1, 3], [2, 3], [3, 2], [3, 1]]) == 3\n assert candidate(row = 3,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4]]) == 3\n assert candidate(row = 4,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4]]) == 3\n assert candidate(row = 2,col = 2,cells = [[1, 1], [2, 1], [1, 2], [2, 2]]) == 2\n assert candidate(row = 2,col = 2,cells = [[1, 1], [1, 2], [2, 1], [2, 2]]) == 1\n assert candidate(row = 5,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [4, 2], [4, 3], [4, 4]]) == 4\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7]]) == 6\n assert candidate(row = 5,col = 4,cells = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4]]) == 15\n assert candidate(row = 6,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5], [4, 2], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5]]) == 5\n assert candidate(row = 5,col = 5,cells = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4]]) == 4\n assert candidate(row = 4,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 6], [3, 6], [4, 6], [4, 5], [4, 4], [4, 3], [4, 2], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5]]) == 5\n assert candidate(row = 4,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [4, 1], [4, 6], [4, 2], [4, 3], [4, 4], [4, 5]]) == 5\n assert candidate(row = 10,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5]]) == 4\n assert candidate(row = 8,col = 8,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 1], [2, 8], [3, 1], [3, 8], [4, 1], [4, 8], [5, 1], [5, 8], [6, 1], [6, 8], [7, 1], [7, 8], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 7], [3, 3], [3, 6], [3, 4], [3, 5], [4, 2], [4, 7], [4, 3], [4, 6], [4, 4], [4, 5], [5, 2], [5, 7], [5, 3], [5, 6], [5, 4], [5, 5], [6, 2], [6, 7], [6, 3], [6, 6], [6, 4], [6, 5], [7, 2], [7, 7], [7, 3], [7, 6], [7, 4], [7, 5]]) == 7\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 7], [3, 1], [3, 7], [4, 1], [4, 7], [5, 1], [5, 7], [6, 1], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 2], [3, 6], [3, 3], [3, 5], [3, 4], [4, 2], [4, 6], [4, 3], [4, 5], [4, 4], [5, 2], [5, 6], [5, 3], [5, 5], [5, 4], [6, 2], [6, 6], [6, 3], [6, 5], [6, 4]]) == 6\n assert candidate(row = 5,col = 5,cells = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == 20\n assert candidate(row = 10,col = 10,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 10], [3, 1], [3, 10], [4, 1], [4, 10], [5, 1], [5, 10], [6, 1], [6, 10], [7, 1], [7, 10], [8, 1], [8, 10], [9, 1], [9, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [6, 8], [6, 9], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9]]) == 9\n assert candidate(row = 6,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [5, 1], [5, 2], [5, 3], [5, 4], [4, 4], [4, 3], [4, 2], [4, 1], [3, 1], [3, 2], [3, 3], [3, 4], [2, 4], [2, 3], [2, 2], [2, 1]]) == 4\n assert candidate(row = 6,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5]]) == 4\n assert candidate(row = 5,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4], [5, 1], [5, 2], [5, 3], [5, 4]]) == 3\n assert candidate(row = 8,col = 8,cells = [[1, 4], [1, 5], [2, 4], [2, 5], [3, 4], [3, 5], [4, 4], [4, 5], [5, 4], [5, 5], [6, 4], [6, 5], [7, 4], [7, 5], [8, 4], [8, 5], [1, 1], [1, 2], [1, 3], [1, 6], [1, 7], [1, 8], [2, 1], [2, 2], [2, 3], [2, 6], [2, 7], [2, 8], [3, 1], [3, 2], [3, 3], [3, 6], [3, 7], [3, 8], [4, 1], [4, 2], [4, 3], [4, 6], [4, 7], [4, 8], [5, 1], [5, 2], [5, 3], [5, 6], [5, 7], [5, 8], [6, 1], [6, 2], [6, 3], [6, 6], [6, 7], [6, 8], [7, 1], [7, 2], [7, 3], [7, 6], [7, 7], [7, 8], [8, 1], [8, 2], [8, 3], [8, 6], [8, 7], [8, 8]]) == 21\n assert candidate(row = 5,col = 10,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 10], [3, 1], [3, 10], [4, 1], [4, 10], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 2], [3, 9], [3, 3], [3, 8], [3, 4], [3, 7], [3, 5], [3, 6], [4, 2], [4, 9], [4, 3], [4, 8], [4, 4], [4, 7], [4, 5], [4, 6]]) == 9\n assert candidate(row = 5,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 5], [3, 1], [3, 5], [4, 1], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [2, 2], [2, 3], [2, 4], [3, 2], [3, 4], [4, 2], [4, 3], [4, 4], [3, 3]]) == 4\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 7], [3, 1], [3, 7], [4, 1], [4, 7], [5, 1], [5, 7], [6, 1], [6, 7], [7, 1], [7, 7], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6]]) == 6\n assert candidate(row = 5,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 5], [3, 1], [3, 5], [4, 1], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [4, 2], [4, 3], [4, 4]]) == 4\n assert candidate(row = 7,col = 7,cells = [[1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [6, 4], [7, 4], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [7, 6], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 7]]) == 42\n assert candidate(row = 8,col = 8,cells = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [7, 8], [6, 8], [5, 8], [4, 8], [3, 8], [2, 8], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [7, 4], [6, 4], [5, 4], [4, 4], [3, 4], [2, 4], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [7, 6], [6, 6], [5, 6], [4, 6], [3, 6], [2, 6], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 7]]) == 14\n assert candidate(row = 5,col = 5,cells = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == 20\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 7], [3, 1], [3, 7], [4, 1], [4, 7], [5, 1], [5, 7], [6, 1], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6]]) == 6\n assert candidate(row = 8,col = 8,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 1], [2, 8], [3, 1], [3, 8], [4, 1], [4, 8], [5, 1], [5, 8], [6, 1], [6, 8], [7, 1], [7, 8], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7]]) == 7\n assert candidate(row = 6,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 1], [2, 6], [3, 1], [3, 6], [4, 1], [4, 6], [5, 1], [5, 6], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5], [4, 2], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5]]) == 5\n assert candidate(row = 8,col = 8,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 1], [2, 8], [3, 1], [3, 8], [4, 1], [4, 8], [5, 1], [5, 8], [6, 1], [6, 8], [7, 1], [7, 8], [8, 1], [8, 8], [8, 7], [8, 6], [8, 5], [8, 4], [8, 3], [8, 2], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7]]) == 7\n assert candidate(row = 10,col = 10,cells = [[1, 5], [1, 6], [2, 5], [2, 6], [3, 5], [3, 6], [4, 5], [4, 6], [5, 5], [5, 6], [6, 5], [6, 6], [7, 5], [7, 6], [8, 5], [8, 6], [9, 5], [9, 6], [10, 5], [10, 6], [1, 1], [1, 2], [1, 3], [1, 4], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 2], [2, 3], [2, 4], [2, 7], [2, 8], [2, 9], [2, 10], [3, 1], [3, 2], [3, 3], [3, 4], [3, 7], [3, 8], [3, 9], [3, 10], [4, 1], [4, 2], [4, 3], [4, 4], [4, 7], [4, 8], [4, 9], [4, 10], [5, 1], [5, 2], [5, 3], [5, 4], [5, 7], [5, 8], [5, 9], [5, 10], [6, 1], [6, 2], [6, 3], [6, 4], [6, 7], [6, 8], [6, 9], [6, 10], [7, 1], [7, 2], [7, 3], [7, 4], [7, 7], [7, 8], [7, 9], [7, 10], [8, 1], [8, 2], [8, 3], [8, 4], [8, 7], [8, 8], [8, 9], [8, 10], [9, 1], [9, 2], [9, 3], [9, 4], [9, 7], [9, 8], [9, 9], [9, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 7], [10, 8], [10, 9], [10, 10]]) == 27\n assert candidate(row = 5,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [5, 3], [5, 2], [5, 1], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 2], [4, 3]]) == 3\n assert candidate(row = 4,col = 5,cells = [[1, 2], [1, 3], [1, 4], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [4, 2], [4, 3], [4, 4], [1, 1], [2, 1], [3, 1], [4, 1], [1, 5], [2, 5], [3, 5], [4, 5]]) == 16\n", "comparison": "exact"}, "public_tests": ["2\n2\n[[1,1],[2,1],[1,2],[2,2]]", "2\n2\n[[1,1],[1,2],[2,1],[2,2]]", "3\n3\n[[1,2],[2,1],[3,3],[2,2],[1,1],[1,3],[2,3],[3,2],[3,1]]"], "hints": ["What graph algorithm allows us to find whether a path exists?", "Can we use binary search to help us solve the problem?"], "metadata": {"canonical_parameter_names": ["row", "col", "cells"], "leetcode_dataset_entry_point": "Solution().latestDayToCross", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:46+00:00", "tests_total": 54, "tests_dropped": 19, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "depth-first-search", "breadth-first-search", "union-find", "matrix"]}, "language": "python", "interface": {"raw_signature": "def latestDayToCross(self, row: int, col: int, cells: list[list[int]]) -> int:", "container": "Solution", "callable": "latestDayToCross", "parameters": [{"name": "row", "type": "int"}, {"name": "col", "type": "int"}, {"name": "cells", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1974, "task_id": "minimum-time-to-type-word-using-special-typewriter", "difficulty": "Easy", "problem_description": "There is a special typewriter with lowercase English letters 'a' to 'z' arranged in a circle with a pointer. A character can only be typed if the pointer is pointing to that character. The pointer is initially pointing to the character 'a'.\n\nEach second, you may perform one of the following operations:\n\n- Move the pointer one character counterclockwise or clockwise.\n- Type the character the pointer is currently on.\n\nGiven a string word, return the minimum number of seconds to type out the characters in word.\n\nExample 1:\n\nInput: word = \"abc\"\nOutput: 5\nExplanation:\nThe characters are printed as follows:\n- Type the character 'a' in 1 second since the pointer is initially on 'a'.\n- Move the pointer clockwise to 'b' in 1 second.\n- Type the character 'b' in 1 second.\n- Move the pointer clockwise to 'c' in 1 second.\n- Type the character 'c' in 1 second.\n\nExample 2:\n\nInput: word = \"bza\"\nOutput: 7\nExplanation:\nThe characters are printed as follows:\n- Move the pointer clockwise to 'b' in 1 second.\n- Type the character 'b' in 1 second.\n- Move the pointer counterclockwise to 'z' in 2 seconds.\n- Type the character 'z' in 1 second.\n- Move the pointer clockwise to 'a' in 1 second.\n- Type the character 'a' in 1 second.\n\nExample 3:\n\nInput: word = \"zjpc\"\nOutput: 34\nExplanation:\nThe characters are printed as follows:\n- Move the pointer counterclockwise to 'z' in 1 second.\n- Type the character 'z' in 1 second.\n- Move the pointer clockwise to 'j' in 10 seconds.\n- Type the character 'j' in 1 second.\n- Move the pointer clockwise to 'p' in 6 seconds.\n- Type the character 'p' in 1 second.\n- Move the pointer counterclockwise to 'c' in 13 seconds.\n- Type the character 'c' in 1 second.\n\nConstraints:\n\n- 1 <= word.length <= 100\n- word consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aaabbbccc\") == 11\n assert candidate(word = \"zyxwvut\") == 14\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 29\n assert candidate(word = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 178\n assert candidate(word = \"qpwoeirutyalskdjfhgzmxncbv\") == 191\n assert candidate(word = \"zjpc\") == 34\n assert candidate(word = \"abcdz\") == 12\n assert candidate(word = \"pqrstuvwxyzabcdefghijklmno\") == 62\n assert candidate(word = \"aaa\") == 3\n assert candidate(word = \"mnopqrstuvwxyzabcdefghijkl\") == 63\n assert candidate(word = \"z\") == 2\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaaaaaaaa\") == 26\n assert candidate(word = \"qpwoeirutyalskdjfhgzmxncbva\") == 197\n assert candidate(word = \"za\") == 4\n assert candidate(word = \"zzz\") == 4\n assert candidate(word = \"qpwoeirutyalskdjfhgzmxcvbn\") == 193\n assert candidate(word = \"mnonmonmomnonmon\") == 47\n assert candidate(word = \"a\") == 1\n assert candidate(word = \"bza\") == 7\n assert candidate(word = \"abc\") == 5\n assert candidate(word = \"az\") == 3\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\") == 52\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\") == 51\n assert candidate(word = \"abacabadabacaba\") == 37\n assert candidate(word = \"mnbvcxzlkjhgfdsapoiuytrewqmnbvcxzlkjhgfdsapoiuytrewq\") == 348\n assert candidate(word = \"adgjmpsvxzbehiklnortuwfyqc\") == 110\n assert candidate(word = \"bbaaccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 79\n assert candidate(word = \"aazzbbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 81\n assert candidate(word = \"mamamamamamamamamamamamamam\") == 351\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 47\n assert candidate(word = \"abcdezyxwvut\") == 27\n assert candidate(word = \"zaqwsxcderfvgytujnhytgfrdxcvbnmzaqwsxcderfv\") == 328\n assert candidate(word = \"mnopqrstuvmnopqrstuvmnopqrstuv\") == 87\n assert candidate(word = \"qwertyuioplkjhgfdsazxcvbnmnbvcxzlkjhgfdsapoiuytrewq\") == 323\n assert candidate(word = \"mamamamamamamamamamamamamamamamamamamamamamamamamamama\") == 702\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzz\") == 70\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 346\n assert candidate(word = \"lkjhgfdsapoiuytrewqzxcvbnm\") == 174\n assert candidate(word = \"mjmlkdjfhakjdhfkahdfkldshfklsjdhfkjd\") == 217\n assert candidate(word = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\") == 44\n assert candidate(word = \"lkjhgfdsapoiuytrewqmasdfghjkl\") == 178\n assert candidate(word = \"qponmlkjihgfedcba\") == 43\n assert candidate(word = \"jklmnopqrstuvwxyzaaaazzzzz\") == 53\n assert candidate(word = \"wvutsrqponmlkjihgfedcba\") == 49\n assert candidate(word = \"wertyuioplkjhgfdsamnbvcxzabcd\") == 164\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 33\n assert candidate(word = \"abcdpqrsuvxyzefghijkmnotwxyz\") == 79\n assert candidate(word = \"qwertypasdfghjklzxcvbnmqwertypasdfghjklzxcvbnm\") == 312\n assert candidate(word = \"bdfhjlnprtvxz\") == 38\n assert candidate(word = \"qzcvmlkjhgfdsapoiuytrwer\") == 157\n assert candidate(word = \"mnopqrstuvwxynmlkjihgfedcbazyxw\") == 83\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyza\") == 53\n assert candidate(word = \"zyzzzzzzzzzzzzzzzzzzzzzzzzz\") == 30\n assert candidate(word = \"qwerasdfzxcv\") == 99\n assert candidate(word = \"abcdefghijklnmopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 104\n assert candidate(word = \"abcdpqrsuvxyzefghijkmnotw\") == 73\n assert candidate(word = \"dcbazyxwvutsrqponmlkjihgfedcba\") == 62\n assert candidate(word = \"acdfghjklmnpqrstvwxyz\") == 46\n assert candidate(word = \"mnopqrstuzyxwvutsrqponmlkjihgfedcba\") == 85\n assert candidate(word = \"zxcvbnmlkjhgfdsapoiuytrewqzxcvbnmlkjhgfdsapoiuytrewq\") == 320\n assert candidate(word = \"lkjhgfdsapoiuytrewqzxcvbnmzxcvbnmlkjhgfdsapoiuytrewq\") == 342\n assert candidate(word = \"fedcbazyxwvutsrqponmlkjihg\") == 56\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbb\") == 40\n assert candidate(word = \"mnopqrlkjihgfedcbazyxwvut\") == 66\n assert candidate(word = \"qpwoeirutyalskdjfhgzxcvbnm\") == 172\n assert candidate(word = \"mlkjihgfedcba\") == 37\n assert candidate(word = \"yzab\") == 9\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 102\n assert candidate(word = \"qzmlkihgfedcba\") == 58\n assert candidate(word = \"bcadefghijklmnopqrstuvwxyz\") == 55\n assert candidate(word = \"aaaaaaaaaaaabbbbbbbbccccccccdddddd\") == 37\n assert candidate(word = \"llllllllllllllllllllllllllllllllllllllllllllllllllllllll\") == 67\n assert candidate(word = \"nlbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkb\") == 392\n assert candidate(word = \"lkjhgfdsazxcvbnmmnbvcxzlkjhgfdsa\") == 176\n assert candidate(word = \"mnopqrsvxyz\") == 36\n assert candidate(word = \"poiuytrewqlkjhgfdsamnbvcxzpoiuytrewqlkjhgfdsamnbvcxz\") == 341\n assert candidate(word = \"qwertypoiuytrewertyuiop\") == 178\n assert candidate(word = \"aaaaabbbbbcccccdddddeeeee\") == 29\n assert candidate(word = \"uqwertyuioplkjhgfdsamnbvcxz\") == 170\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 104\n assert candidate(word = \"qrstuvzxcvbnmlkjhgfedcba\") == 88\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 35\n assert candidate(word = \"qwerasdfzxcvqwerasdfzxcvqwerasdfzxcv\") == 287\n assert candidate(word = \"lkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkm\") == 136\n assert candidate(word = \"zazazazazazazazazazazazazazazaz\") == 62\n assert candidate(word = \"aazzzzyyyyxxxwwvvuuttrrssqqppoonnmmlkkjjiihhggffeeddaa\") == 82\n assert candidate(word = \"jqpnfjwmsvkmrekjijgqpxvukz\") == 175\n assert candidate(word = \"lkjhgfdsapoiuytrewqasdfghjklmnbvcxz\") == 212\n assert candidate(word = \"ejpmytlrzwhgodicuvnkxfsab\") == 190\n assert candidate(word = \"qwertyuioplkjhgfdsazxcvbnmqwertyuioplkjhgfdsazxcvbnm\") == 310\n assert candidate(word = \"qrstuvwxyzaeiou\") == 55\n assert candidate(word = \"aeiouyaeiouyaeiouyaeiouy\") == 126\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcbaa\") == 53\n assert candidate(word = \"poiuytrewqasdfghjklzxcvbnmpoiuytrewqasdfghjklzxcvbnmpoiuytrewq\") == 414\n assert candidate(word = \"abcdefghjklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 101\n assert candidate(word = \"qazwsxedcrfvtgbyhnujmikolpqwazxsedcrfvtgbyhnujmikolpqwaz\") == 361\n assert candidate(word = \"mzaixmsdcvnbmqwerty\") == 169\n assert candidate(word = \"zabcdefghijklmnopqrstuvwxyz\") == 54\n assert candidate(word = \"poiuytrewqlkjhgfdsamnbvcxz\") == 171\n assert candidate(word = \"zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx\") == 111\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaaaaaaaaab\") == 29\n assert candidate(word = \"pppppppppppppppppppppppppppp\") == 39\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 103\n assert candidate(word = \"abcdefghijkmnopqrstuvwxyz\") == 50\n assert candidate(word = \"azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 58\n assert candidate(word = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 97\n assert candidate(word = \"zaazaaazzaa\") == 17\n assert candidate(word = \"zzzaaazzzaaazzzaaazzzaaazzzaaazzz\") == 44\n assert candidate(word = \"zyxcbaqwertyuiopasdfghjklmnbvcxz\") == 181\n assert candidate(word = \"asdfghjklqwertyuiopzxcvbnm\") == 158\n assert candidate(word = \"pqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 82\n assert candidate(word = \"zabcdefghijklmnopqrstuvwxyza\") == 56\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzza\") == 54\n assert candidate(word = \"tgbnhyujmkiolpvcxz\") == 125\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnm\") == 176\n assert candidate(word = \"qazwsxedcrfvtgbyhnujmikolp\") == 177\n assert candidate(word = \"zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx\") == 118\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 77\n assert candidate(word = \"mnbvcxzlkjhgfdsapoiuytrewqasdfghjklpoiuytrewq\") == 295\n assert candidate(word = \"lkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkj\") == 135\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 103\n assert candidate(word = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\") == 64\n assert candidate(word = \"mnopqrstuvwx\") == 35\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcbaqwertyuiop\") == 129\n assert candidate(word = \"abacabadabacabadabacaba\") == 59\n assert candidate(word = \"fedcbazyxwvutsrqponmlkjihgfedcba\") == 68\n assert candidate(word = \"zaqwsxcderfvgytuhjnmkiolp\") == 156\n", "comparison": "exact"}, "public_tests": ["\"abc\"", "\"bza\"", "\"zjpc\""], "hints": ["There are only two possible directions you can go when you move to the next letter.", "When moving to the next letter, you will always go in the direction that takes the least amount of time."], "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().minTimeToType", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:53+00:00", "tests_total": 129, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minTimeToType(self, word: str) -> int:", "container": "Solution", "callable": "minTimeToType", "parameters": [{"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1975, "task_id": "maximum-matrix-sum", "difficulty": "Medium", "problem_description": "You are given an n x n integer matrix. You can do the following operation any number of times:\n\n- Choose any two adjacent elements of matrix and multiply each of them by -1.\n\nTwo elements are considered adjacent if and only if they share a border.\n\nYour goal is to maximize the summation of the matrix's elements. Return the maximum sum of the matrix's elements using the operation mentioned above.\n\nExample 1:\n\nInput: matrix = [[1,-1],[-1,1]]\nOutput: 4\nExplanation: We can follow the following steps to reach sum equals 4:\n- Multiply the 2 elements in the first row by -1.\n- Multiply the 2 elements in the first column by -1.\n\nExample 2:\n\nInput: matrix = [[1,2,3],[-1,-2,-3],[1,2,3]]\nOutput: 16\nExplanation: We can follow the following step to reach sum equals 16:\n- Multiply the 2 last elements in the second row by -1.\n\nConstraints:\n\n- n == matrix.length == matrix[i].length\n- 2 <= n <= 250\n- -10^5 <= matrix[i][j] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[-1, -2], [3, 4]]) == 10\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == 43\n assert candidate(matrix = [[1, 2], [3, -4]]) == 8\n assert candidate(matrix = [[1, 2, 3], [-1, -2, -3], [1, 2, 3]]) == 16\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(matrix = [[1, 2], [3, 4]]) == 10\n assert candidate(matrix = [[100000, -100000], [-100000, 100000]]) == 400000\n assert candidate(matrix = [[1, 0, -1], [0, 1, 0], [-1, 0, 1]]) == 5\n assert candidate(matrix = [[1, -2], [-3, 4]]) == 10\n assert candidate(matrix = [[1, -1], [-1, 1]]) == 4\n assert candidate(matrix = [[-10, -9, -8, -7, -6], [-5, -4, -3, -2, -1], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14]]) == 160\n assert candidate(matrix = [[-1, 2, -3, 4], [5, -6, 7, -8], [-9, 10, -11, 12], [13, -14, 15, -16]]) == 136\n assert candidate(matrix = [[-20, 15, 30], [5, -25, 40], [-10, 25, -35]]) == 205\n assert candidate(matrix = [[0, -100000, 100000, 0], [100000, 0, 0, -100000], [0, 100000, 0, -100000], [-100000, 0, 100000, 0]]) == 800000\n assert candidate(matrix = [[-1, -2, -3, -4], [5, 6, 7, 8], [-9, -10, -11, -12], [13, 14, 15, 16]]) == 136\n assert candidate(matrix = [[100000, 0, 0], [0, 0, 0], [0, 0, -100000]]) == 200000\n assert candidate(matrix = [[1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1]]) == 25\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(matrix = [[-1, 0, 1], [0, -2, 0], [1, 0, -1]]) == 6\n assert candidate(matrix = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]]) == 7\n assert candidate(matrix = [[10, 20, 30], [-40, -50, -60], [70, 80, 90]]) == 430\n assert candidate(matrix = [[-1, 2, -3, 4], [-5, 6, -7, 8], [9, -10, 11, -12], [13, -14, 15, -16]]) == 136\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, -25]]) == 47\n assert candidate(matrix = [[0, 0, 0], [0, -1, 0], [0, 0, 0]]) == 1\n assert candidate(matrix = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]]) == 7\n assert candidate(matrix = [[1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1]]) == 25\n assert candidate(matrix = [[1000, -1000, 1000, -1000], [1000, -1000, 1000, -1000], [-1000, 1000, -1000, 1000], [-1000, 1000, -1000, 1000]]) == 16000\n assert candidate(matrix = [[1, -2, 3, -4, 5], [-6, 7, -8, 9, -10], [11, -12, 13, -14, 15], [-16, 17, -18, 19, -20], [21, -22, 23, -24, 25]]) == 325\n assert candidate(matrix = [[-1, -1, 1, 1], [1, 1, -1, -1], [-1, -1, 1, 1], [1, 1, -1, -1]]) == 16\n assert candidate(matrix = [[-1, 1, -1, 1], [-1, 1, -1, 1], [-1, 1, -1, 1], [-1, 1, -1, 1]]) == 16\n assert candidate(matrix = [[-1, 2, -3, 4, -5], [5, -4, 3, -2, 1], [-1, 2, -3, 4, -5], [5, -4, 3, -2, 1], [-1, 2, -3, 4, -5]]) == 73\n assert candidate(matrix = [[-1, -2, -3, -4], [-5, -6, -7, -8], [-9, -10, -11, -12], [-13, -14, -15, -16]]) == 136\n assert candidate(matrix = [[-10000, 20000, -30000], [40000, -50000, 60000], [-70000, 80000, -90000]]) == 430000\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]) == 5050\n assert candidate(matrix = [[100000, 0, -100000, 0], [0, 100000, 0, -100000], [-100000, 0, 100000, 0], [0, -100000, 0, 100000]]) == 800000\n assert candidate(matrix = [[-1, 2, 3], [4, -5, 6], [-7, 8, -9]]) == 45\n assert candidate(matrix = [[-100000, 100000, -100000], [100000, -100000, 100000], [-100000, 100000, -100000]]) == 700000\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == 136\n assert candidate(matrix = [[-99999, 99999], [100000, -100000]]) == 399998\n assert candidate(matrix = [[-1, 2, -3, 4], [-5, 6, -7, 8], [-9, 10, -11, 12], [-13, 14, -15, 16]]) == 136\n assert candidate(matrix = [[-10, -20, -30, -40], [-50, -60, -70, -80], [-90, -100, -110, -120], [-130, -140, -150, -160]]) == 1360\n assert candidate(matrix = [[-100000, -100000], [-100000, -100000]]) == 400000\n assert candidate(matrix = [[-5, 3, -2], [-1, 4, -6], [7, -8, 9]]) == 43\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == 43\n assert candidate(matrix = [[1, 2, 3, 4, 5], [-6, -7, -8, -9, -10], [11, 12, 13, 14, 15], [-16, -17, -18, -19, -20], [21, 22, 23, 24, 25]]) == 325\n assert candidate(matrix = [[-50000, 50000, -60000], [60000, -70000, 70000], [-80000, 80000, -90000]]) == 510000\n assert candidate(matrix = [[-1, -2, -3, -4], [-5, -6, -7, -8], [-9, -10, -11, -12], [-13, -14, -15, -16]]) == 136\n assert candidate(matrix = [[-1, 2, -3, 4, -5], [6, -7, 8, -9, 10], [-11, 12, -13, 14, -15], [16, -17, 18, -19, 20], [-21, 22, -23, 24, -25]]) == 323\n assert candidate(matrix = [[-5, -4, -3, -2, -1], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]]) == 205\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [-11, -12, -13, -14, -15], [-16, -17, -18, -19, -20], [21, 22, 23, 24, 25]]) == 325\n assert candidate(matrix = [[1, -2, 3, -4, 5], [-6, 7, -8, 9, -10], [11, -12, 13, -14, 15], [-16, 17, -18, 19, -20], [21, -22, 23, -24, 25]]) == 325\n assert candidate(matrix = [[-99999, 99998, -99997, 99996], [99995, -99994, 99993, -99992], [-99991, 99990, -99989, 99988], [99987, -99986, 99985, -99984]]) == 1599864\n assert candidate(matrix = [[-10, -20, -30], [-40, -50, -60], [-70, -80, -90]]) == 430\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(matrix = [[-10, -20, -30], [-40, -50, -60], [-70, -80, -90]]) == 430\n assert candidate(matrix = [[-1, 0, 1, 0, -1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [-1, 0, 1, 0, -1]]) == 13\n assert candidate(matrix = [[-99999, 100000, 99999], [-100000, -99999, 100000], [99999, -100000, -99999]]) == 699997\n assert candidate(matrix = [[1, -1, 1, -1], [1, -1, 1, -1], [-1, 1, -1, 1], [-1, 1, -1, 1]]) == 16\n assert candidate(matrix = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]) == 450\n assert candidate(matrix = [[-5, -4, -3, -2, -1], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 223\n assert candidate(matrix = [[-1, -1, -1], [1, 1, 1], [-1, -1, -1]]) == 9\n assert candidate(matrix = [[-1, 0, 1], [-2, 0, 2], [-3, 0, 3]]) == 12\n assert candidate(matrix = [[-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1]]) == 36\n assert candidate(matrix = [[-10000, 10000, -10000, 10000, -10000], [10000, -10000, 10000, -10000, 10000], [-10000, 10000, -10000, 10000, -10000], [10000, -10000, 10000, -10000, 10000], [-10000, 10000, -10000, 10000, -10000]]) == 230000\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 25\n assert candidate(matrix = [[1, -1, 1, -1], [-1, 1, -1, 1], [1, -1, 1, -1], [-1, 1, -1, 1]]) == 16\n assert candidate(matrix = [[-100000, 100000, -100000, 100000], [100000, -100000, 100000, -100000], [-100000, 100000, -100000, 100000], [100000, -100000, 100000, -100000]]) == 1600000\n assert candidate(matrix = [[100, -100, 200], [-300, 400, -500], [600, -700, 800]]) == 3700\n assert candidate(matrix = [[1, -2, 3, -4, 5], [6, -7, 8, -9, 10], [11, -12, 13, -14, 15], [16, -17, 18, -19, 20], [21, -22, 23, -24, 25]]) == 325\n assert candidate(matrix = [[-2, 3, -4], [-1, -2, -3], [4, 5, -6]]) == 30\n assert candidate(matrix = [[0, 1, -1], [1, 0, -1], [-1, 1, 0]]) == 6\n assert candidate(matrix = [[100000, -100000, 100000], [-100000, 100000, -100000], [100000, -100000, 100000]]) == 900000\n assert candidate(matrix = [[-5, -4, 3], [2, 1, 0], [-1, 6, -7]]) == 29\n assert candidate(matrix = [[100000, 0, -100000], [-100000, 0, 100000], [0, 100000, 0]]) == 500000\n assert candidate(matrix = [[1, -1, 2, -2], [3, -3, 4, -4], [5, -5, 6, -6], [7, -7, 8, -8]]) == 72\n assert candidate(matrix = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 1\n assert candidate(matrix = [[-1, 2, -3, 4], [-5, 6, -7, 8], [-9, 10, -11, 12], [13, -14, 15, -16]]) == 136\n assert candidate(matrix = [[100, -200, 300, -400], [500, -600, 700, -800], [900, -1000, 1100, -1200], [-1300, 1400, -1500, 1600]]) == 13600\n assert candidate(matrix = [[-1, 2, -3, 4, -5], [6, -7, 8, -9, 10], [-11, 12, -13, 14, -15], [16, -17, 18, -19, 20], [-21, 22, -23, 24, -25]]) == 323\n assert candidate(matrix = [[100000, 100000], [100000, 100000]]) == 400000\n assert candidate(matrix = [[-1, 2, -3, 4], [-5, 6, -7, 8], [9, -10, 11, -12], [-13, 14, -15, 16]]) == 136\n", "comparison": "exact"}, "public_tests": ["[[1,-1],[-1,1]]", "[[1,2,3],[-1,-2,-3],[1,2,3]]"], "hints": ["Try to use the operation so that each row has only one negative number.", "If you have only one negative element you cannot convert it to positive."], "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().maxMatrixSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:55+00:00", "tests_total": 85, "tests_dropped": 4, "flags": ["has_images"], "topic_tags": ["array", "greedy", "matrix"]}, "language": "python", "interface": {"raw_signature": "def maxMatrixSum(self, matrix: list[list[int]]) -> int:", "container": "Solution", "callable": "maxMatrixSum", "parameters": [{"name": "matrix", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1976, "task_id": "number-of-ways-to-arrive-at-destination", "difficulty": "Medium", "problem_description": "You are in a city that consists of n intersections numbered from 0 to n - 1 with bi-directional roads between some intersections. The inputs are generated such that you can reach any intersection from any other intersection and that there is at most one road between any two intersections.\n\nYou are given an integer n and a 2D integer array roads where roads[i] = [u_i, v_i, time_i] means that there is a road between intersections u_i and v_i that takes time_i minutes to travel. You want to know in how many ways you can travel from intersection 0 to intersection n - 1 in the shortest amount of time.\n\nReturn the number of ways you can arrive at your destination in the shortest amount of time. Since the answer may be large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 7, roads = [[0,6,7],[0,1,2],[1,2,3],[1,3,3],[6,3,3],[3,5,1],[6,5,1],[2,5,1],[0,4,5],[4,6,2]]\nOutput: 4\nExplanation: The shortest amount of time it takes to go from intersection 0 to intersection 6 is 7 minutes.\nThe four ways to get there in 7 minutes are:\n- 0 ➝ 6\n- 0 ➝ 4 ➝ 6\n- 0 ➝ 1 ➝ 2 ➝ 5 ➝ 6\n- 0 ➝ 1 ➝ 3 ➝ 5 ➝ 6\n\nExample 2:\n\nInput: n = 2, roads = [[1,0,10]]\nOutput: 1\nExplanation: There is only one way to go from intersection 0 to intersection 1, and it takes 10 minutes.\n\nConstraints:\n\n- 1 <= n <= 200\n- n - 1 <= roads.length <= n * (n - 1) / 2\n- roads[i].length == 3\n- 0 <= u_i, v_i <= n - 1\n- 1 <= time_i <= 10^9\n- u_i!= v_i\n- There is at most one road connecting any two intersections.\n- You can reach any intersection from any other intersection.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,roads = [[0, 1, 1], [0, 2, 4], [0, 3, 3], [0, 4, 10], [1, 2, 2], [1, 3, 4], [1, 4, 6], [2, 3, 3], [2, 4, 5], [3, 4, 1]]) == 1\n assert candidate(n = 4,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5]]) == 1\n assert candidate(n = 3,roads = [[0, 1, 1], [1, 2, 1], [0, 2, 2]]) == 2\n assert candidate(n = 5,roads = [[0, 1, 2], [0, 4, 8], [1, 2, 6], [1, 4, 2], [2, 3, 3], [3, 4, 2]]) == 1\n assert candidate(n = 5,roads = [[0, 1, 1], [0, 2, 2], [1, 3, 1], [1, 4, 3], [2, 3, 3], [2, 4, 1], [3, 4, 1]]) == 2\n assert candidate(n = 6,roads = [[0, 1, 5], [1, 2, 3], [0, 2, 4], [2, 3, 1], [2, 4, 2], [3, 5, 1], [4, 5, 2]]) == 1\n assert candidate(n = 4,roads = [[0, 1, 1], [0, 2, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1]]) == 2\n assert candidate(n = 7,roads = [[0, 6, 7], [0, 1, 2], [1, 2, 3], [1, 3, 3], [6, 3, 3], [3, 5, 1], [6, 5, 1], [2, 5, 1], [0, 4, 5], [4, 6, 2]]) == 4\n assert candidate(n = 5,roads = [[0, 1, 2], [0, 2, 4], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1]]) == 1\n assert candidate(n = 5,roads = [[0, 1, 1], [0, 2, 1], [1, 2, 1], [1, 3, 1], [2, 4, 1], [3, 4, 1]]) == 1\n assert candidate(n = 4,roads = [[0, 1, 2], [0, 2, 4], [1, 2, 1], [1, 3, 1], [2, 3, 2]]) == 1\n assert candidate(n = 3,roads = [[0, 1, 2], [1, 2, 2], [0, 2, 3]]) == 1\n assert candidate(n = 6,roads = [[0, 1, 4], [1, 2, 4], [2, 3, 3], [3, 4, 2], [4, 5, 2]]) == 1\n assert candidate(n = 2,roads = [[1, 0, 10]]) == 1\n assert candidate(n = 4,roads = [[0, 1, 1], [0, 2, 5], [1, 2, 1], [2, 3, 1]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 4], [2, 3, 1], [2, 4, 2], [3, 5, 3], [3, 6, 2], [4, 5, 4], [4, 6, 1], [5, 7, 2], [6, 7, 1]]) == 2\n assert candidate(n = 8,roads = [[0, 1, 4], [1, 2, 5], [2, 3, 1], [3, 4, 2], [4, 5, 3], [5, 6, 4], [6, 7, 5], [0, 7, 20], [0, 2, 10], [1, 6, 15], [2, 5, 8], [3, 4, 7]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [0, 14, 70], [1, 13, 69], [2, 12, 68], [3, 11, 67], [4, 10, 66], [5, 9, 65], [6, 8, 64]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 1], [7, 8, 2], [8, 9, 1], [9, 10, 2], [10, 11, 3], [11, 12, 1], [12, 13, 2], [13, 14, 1]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 3], [0, 2, 5], [1, 2, 2], [1, 3, 4], [1, 4, 1], [2, 5, 3], [3, 4, 2], [4, 5, 6], [4, 6, 4], [4, 7, 2], [5, 7, 5], [6, 7, 1]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 7, 4], [4, 7, 4], [5, 6, 1], [5, 7, 2], [6, 7, 2]]) == 2\n assert candidate(n = 20,roads = [[0, 1, 2], [0, 2, 10], [0, 3, 5], [1, 4, 1], [1, 5, 3], [1, 6, 4], [2, 5, 2], [2, 7, 6], [3, 6, 5], [3, 8, 7], [4, 9, 1], [4, 10, 2], [5, 9, 4], [5, 10, 3], [5, 11, 1], [6, 11, 3], [7, 11, 2], [7, 12, 10], [8, 12, 5], [8, 13, 3], [9, 13, 4], [9, 14, 6], [10, 14, 5], [11, 14, 3], [11, 15, 2], [11, 16, 1], [12, 16, 2], [12, 17, 10], [13, 17, 5], [14, 17, 3], [14, 18, 2], [14, 19, 1], [15, 18, 2], [16, 19, 3], [17, 19, 1]]) == 2\n assert candidate(n = 6,roads = [[0, 1, 10], [0, 2, 10], [1, 3, 5], [1, 4, 2], [2, 3, 3], [2, 4, 4], [3, 5, 8], [4, 5, 1]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 6], [2, 4, 4], [2, 5, 1], [3, 6, 3], [3, 7, 2], [4, 7, 5], [4, 8, 3], [5, 8, 2], [5, 9, 4], [6, 9, 1], [7, 9, 3]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 6], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 4, 2], [2, 5, 1], [3, 6, 3], [3, 7, 2], [4, 7, 1], [4, 8, 4], [5, 8, 3], [5, 9, 2], [6, 10, 1], [7, 10, 2], [7, 11, 3], [8, 11, 1], [9, 11, 2]]) == 2\n assert candidate(n = 20,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 1], [1, 3, 2], [1, 4, 3], [2, 3, 1], [2, 4, 2], [2, 5, 3], [3, 4, 1], [3, 5, 2], [3, 6, 3], [4, 5, 1], [4, 6, 2], [4, 7, 3], [5, 6, 1], [5, 7, 2], [5, 8, 3], [6, 7, 1], [6, 8, 2], [6, 9, 3], [7, 8, 1], [7, 9, 2], [7, 10, 3], [8, 9, 1], [8, 10, 2], [8, 11, 3], [9, 10, 1], [9, 11, 2], [9, 12, 3], [10, 11, 1], [10, 12, 2], [10, 13, 3], [11, 12, 1], [11, 13, 2], [11, 14, 3], [12, 13, 1], [12, 14, 2], [12, 15, 3], [13, 14, 1], [13, 15, 2], [13, 16, 3], [14, 15, 1], [14, 16, 2], [14, 17, 3], [15, 16, 1], [15, 17, 2], [15, 18, 3], [16, 17, 1], [16, 18, 2], [16, 19, 3], [17, 18, 1], [17, 19, 2], [18, 19, 1]]) == 55403\n assert candidate(n = 15,roads = [[0, 1, 5], [0, 2, 5], [1, 3, 4], [1, 4, 4], [2, 5, 5], [2, 6, 5], [3, 7, 3], [3, 8, 3], [4, 9, 4], [4, 10, 4], [5, 11, 5], [5, 12, 5], [6, 13, 6], [6, 14, 6], [7, 11, 2], [8, 12, 2], [9, 13, 3], [10, 14, 3], [11, 14, 1], [12, 13, 1]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 2], [0, 2, 4], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [0, 3, 5], [1, 4, 3], [2, 5, 6], [3, 6, 7], [4, 7, 8], [5, 8, 9], [6, 9, 10]]) == 2\n assert candidate(n = 15,roads = [[0, 1, 5], [0, 2, 10], [1, 2, 3], [1, 3, 8], [2, 3, 6], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [9, 10, 7], [10, 11, 8], [11, 12, 9], [12, 13, 10], [13, 14, 11], [0, 5, 7], [1, 6, 4], [2, 7, 5], [3, 8, 6], [4, 9, 7], [5, 10, 8], [6, 11, 9], [7, 12, 10], [8, 13, 11], [9, 14, 12]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 2], [1, 3, 3], [2, 4, 4], [3, 4, 3], [3, 5, 5], [4, 6, 6], [5, 7, 7], [6, 8, 8], [7, 8, 9], [8, 9, 10], [0, 3, 4], [1, 4, 5], [2, 5, 6], [3, 6, 7], [4, 7, 8], [5, 8, 9], [6, 9, 10]]) == 2\n assert candidate(n = 9,roads = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 1], [1, 5, 2], [2, 5, 3], [2, 6, 2], [3, 6, 1], [3, 7, 2], [4, 8, 1], [5, 8, 2], [6, 8, 3], [7, 8, 4]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 5], [0, 2, 3], [1, 2, 2], [1, 3, 10], [2, 3, 6], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [0, 9, 15], [1, 8, 8], [2, 7, 7], [3, 6, 5]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 1], [0, 2, 1], [1, 3, 2], [2, 3, 2], [1, 4, 1], [2, 5, 1], [3, 6, 3], [4, 6, 3], [5, 7, 4], [6, 7, 4], [1, 5, 2], [2, 4, 2], [0, 3, 3], [0, 4, 3], [1, 2, 3], [3, 5, 4], [4, 5, 4]]) == 1\n assert candidate(n = 20,roads = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 10, 5], [10, 11, 5], [11, 12, 5], [12, 13, 5], [13, 14, 5], [14, 15, 5], [15, 16, 5], [16, 17, 5], [17, 18, 5], [18, 19, 5], [0, 19, 100], [1, 18, 99], [2, 17, 98], [3, 16, 97], [4, 15, 96], [5, 14, 95], [6, 13, 94], [7, 12, 93], [8, 11, 92], [9, 10, 91]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 5], [0, 2, 3], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 1], [7, 8, 2], [8, 9, 1], [9, 10, 2], [10, 11, 3], [11, 4, 1]]) == 2\n assert candidate(n = 10,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 45], [1, 8, 35], [2, 7, 25], [3, 6, 15], [4, 5, 5]]) == 5\n assert candidate(n = 10,roads = [[0, 1, 4], [0, 2, 3], [1, 3, 2], [1, 4, 1], [2, 3, 5], [2, 4, 2], [3, 5, 1], [4, 5, 3], [5, 6, 2], [5, 7, 1], [6, 8, 2], [7, 8, 1], [8, 9, 3]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 18]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 5], [0, 2, 4], [1, 2, 3], [1, 3, 2], [2, 3, 1], [2, 4, 6], [3, 4, 5], [3, 5, 7], [3, 6, 2], [4, 5, 4], [4, 6, 3], [4, 7, 10], [5, 6, 6], [5, 7, 8], [5, 8, 4], [6, 7, 7], [6, 8, 9], [7, 8, 11], [7, 9, 6], [8, 9, 3], [9, 10, 2], [9, 11, 5], [9, 12, 7], [10, 11, 3], [10, 12, 6], [11, 12, 4], [11, 13, 8], [11, 14, 2], [12, 13, 5], [12, 14, 9], [13, 14, 1]]) == 4\n assert candidate(n = 8,roads = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [0, 7, 70], [1, 6, 60], [2, 5, 50], [3, 4, 40]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 4], [1, 3, 5], [2, 3, 6], [2, 4, 7], [3, 4, 8], [3, 5, 9], [4, 5, 10], [5, 6, 11], [6, 7, 12], [7, 8, 13], [8, 9, 14], [9, 10, 15], [10, 11, 16], [11, 12, 17], [12, 13, 18], [13, 14, 19], [0, 14, 20], [1, 13, 21], [2, 12, 22], [3, 11, 23], [4, 10, 24], [5, 9, 25], [6, 8, 26], [7, 9, 27], [8, 11, 28], [9, 12, 29], [10, 13, 30], [11, 14, 31]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [1, 4, 5], [2, 5, 2], [2, 6, 3], [3, 6, 1], [3, 7, 2], [4, 7, 3], [4, 8, 4], [5, 8, 5], [5, 9, 6], [6, 9, 7], [6, 10, 8], [7, 10, 9], [7, 11, 10], [8, 11, 11], [9, 11, 12]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 1], [7, 8, 2], [8, 9, 1]]) == 1\n assert candidate(n = 9,roads = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 5, 6], [2, 6, 7], [3, 7, 8], [3, 8, 9], [4, 5, 10], [4, 6, 11], [5, 7, 12], [5, 8, 13], [6, 7, 14], [6, 8, 15], [7, 8, 16]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [1, 4, 1], [1, 5, 2], [2, 5, 3], [2, 6, 1], [3, 6, 2], [3, 7, 3], [4, 8, 1], [5, 8, 2], [5, 9, 3], [6, 9, 1], [6, 10, 2], [7, 10, 3], [8, 11, 1], [9, 11, 2], [9, 12, 3], [10, 12, 1], [10, 13, 2], [11, 14, 1], [12, 14, 2], [13, 14, 3]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 12, 120], [12, 13, 130], [13, 14, 140], [0, 14, 900], [1, 13, 800], [2, 12, 700], [3, 11, 600], [4, 10, 500], [5, 9, 400], [6, 8, 300], [7, 9, 200], [8, 10, 100]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [7, 9, 16], [8, 9, 17], [8, 10, 18], [9, 10, 19], [9, 11, 20], [10, 11, 21], [0, 7, 22], [1, 8, 23], [2, 9, 24], [3, 10, 25], [4, 11, 26], [5, 0, 27], [6, 1, 28], [7, 2, 29], [8, 3, 30], [9, 4, 31], [10, 5, 32], [11, 6, 33]]) == 1\n assert candidate(n = 20,roads = [[0, 1, 5], [1, 2, 4], [2, 3, 3], [3, 4, 2], [4, 5, 1], [5, 6, 1], [6, 7, 2], [7, 8, 3], [8, 9, 4], [9, 10, 5], [10, 11, 6], [11, 12, 7], [12, 13, 8], [13, 14, 9], [14, 15, 10], [15, 16, 11], [16, 17, 12], [17, 18, 13], [18, 19, 14], [0, 19, 95], [1, 18, 90], [2, 17, 85], [3, 16, 80], [4, 15, 75], [5, 14, 70], [6, 13, 65], [7, 12, 60], [8, 11, 55], [9, 10, 50]]) == 1\n assert candidate(n = 20,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [7, 9, 16], [8, 9, 17], [8, 10, 18], [9, 10, 19], [9, 11, 20], [10, 11, 21], [10, 12, 22], [11, 12, 23], [11, 13, 24], [12, 13, 25], [12, 14, 26], [13, 14, 27], [13, 15, 28], [14, 15, 29], [14, 16, 30], [15, 16, 31], [15, 17, 32], [16, 17, 33], [16, 18, 34], [17, 18, 35], [17, 19, 36], [18, 19, 37]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 2], [0, 2, 5], [1, 2, 1], [1, 3, 3], [2, 4, 2], [3, 4, 2], [3, 5, 1], [4, 5, 1], [4, 6, 4], [5, 6, 3], [5, 7, 5], [6, 7, 2], [6, 8, 6], [7, 8, 1], [7, 9, 3], [8, 9, 2]]) == 10\n assert candidate(n = 8,roads = [[0, 1, 3], [0, 2, 5], [1, 2, 2], [1, 3, 4], [2, 3, 1], [2, 4, 6], [3, 4, 3], [3, 5, 7], [4, 5, 2], [4, 6, 8], [5, 6, 1], [5, 7, 5], [6, 7, 4]]) == 4\n assert candidate(n = 12,roads = [[0, 1, 2], [0, 3, 1], [1, 2, 3], [1, 3, 2], [2, 4, 1], [2, 5, 2], [3, 4, 4], [3, 5, 3], [4, 6, 1], [4, 7, 2], [5, 6, 2], [5, 7, 3], [6, 8, 1], [6, 9, 2], [7, 8, 3], [7, 9, 4], [8, 10, 1], [8, 11, 2], [9, 10, 3], [9, 11, 4]]) == 2\n assert candidate(n = 18,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [7, 9, 16], [8, 9, 17], [8, 10, 18], [9, 10, 19], [9, 11, 20], [10, 11, 21], [10, 12, 22], [11, 12, 23], [11, 13, 24], [12, 13, 25], [12, 14, 26], [13, 14, 27], [13, 15, 28], [14, 15, 29], [14, 16, 30], [15, 16, 31], [15, 17, 32], [16, 17, 33], [0, 13, 34], [1, 14, 35], [2, 15, 36], [3, 16, 37], [4, 17, 38], [5, 0, 39], [6, 1, 40], [7, 2, 41], [8, 3, 42], [9, 4, 43], [10, 5, 44], [11, 6, 45], [12, 7, 46], [13, 8, 47], [14, 9, 48], [15, 10, 49], [16, 11, 50], [17, 12, 51]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 1], [0, 2, 4], [1, 3, 2], [1, 4, 5], [2, 3, 1], [2, 5, 6], [3, 4, 3], [3, 6, 7], [4, 5, 2], [4, 7, 8], [5, 6, 3], [5, 8, 4], [6, 7, 1], [6, 9, 5], [7, 8, 2], [8, 9, 3]]) == 3\n assert candidate(n = 12,roads = [[0, 1, 2], [0, 2, 5], [0, 3, 10], [1, 4, 1], [1, 5, 3], [1, 6, 4], [2, 5, 2], [2, 7, 6], [3, 6, 5], [3, 8, 7], [4, 9, 1], [4, 10, 2], [5, 9, 4], [5, 10, 3], [5, 11, 1], [6, 11, 3], [7, 11, 2], [8, 11, 5], [9, 11, 2], [10, 11, 4]]) == 2\n assert candidate(n = 10,roads = [[0, 1, 1], [0, 3, 5], [1, 2, 2], [1, 3, 4], [2, 3, 1], [3, 4, 1], [4, 5, 2], [5, 6, 1], [6, 7, 2], [7, 8, 1], [8, 9, 2], [0, 2, 3], [2, 4, 2], [4, 6, 1], [6, 8, 2], [1, 5, 3], [5, 7, 1], [7, 9, 2]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 10], [0, 2, 15], [1, 2, 5], [1, 3, 6], [1, 4, 8], [2, 3, 3], [2, 4, 7], [3, 4, 1], [3, 5, 2], [3, 6, 4], [4, 5, 9], [4, 6, 6], [5, 7, 5], [5, 8, 1], [6, 8, 3], [6, 9, 7], [7, 10, 4], [8, 10, 2], [8, 11, 6], [9, 11, 5], [10, 12, 3], [10, 13, 8], [11, 13, 1], [11, 14, 9], [12, 14, 2], [13, 14, 7]]) == 1\n assert candidate(n = 18,roads = [[0, 1, 10], [0, 2, 5], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 1], [7, 8, 2], [8, 9, 1], [9, 10, 2], [10, 11, 3], [11, 12, 1], [12, 13, 2], [13, 14, 1], [14, 15, 2], [15, 16, 3], [16, 17, 1]]) == 2\n assert candidate(n = 15,roads = [[0, 1, 10], [0, 2, 15], [0, 3, 5], [1, 2, 7], [1, 4, 4], [1, 5, 3], [2, 5, 2], [2, 6, 10], [3, 5, 6], [3, 7, 2], [4, 6, 5], [4, 8, 3], [5, 9, 1], [5, 10, 2], [6, 10, 4], [6, 11, 8], [7, 11, 2], [7, 12, 10], [8, 12, 5], [8, 13, 3], [9, 13, 4], [9, 14, 6], [10, 14, 5], [11, 14, 3]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 5], [0, 2, 3], [0, 3, 4], [1, 2, 2], [1, 3, 10], [2, 3, 6], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [9, 10, 7], [10, 11, 8], [0, 11, 60], [1, 10, 59], [2, 9, 58], [3, 8, 57], [4, 7, 56], [5, 6, 55]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [0, 5, 14], [1, 6, 15], [2, 7, 16], [0, 3, 17], [1, 4, 18], [2, 5, 19], [3, 6, 20], [4, 7, 21]]) == 1\n assert candidate(n = 18,roads = [[0, 1, 2], [0, 2, 10], [0, 3, 5], [1, 4, 1], [1, 5, 3], [1, 6, 4], [2, 5, 2], [2, 7, 6], [3, 6, 5], [3, 8, 7], [4, 9, 1], [4, 10, 2], [5, 9, 4], [5, 10, 3], [5, 11, 1], [6, 11, 3], [7, 11, 2], [7, 12, 10], [8, 12, 5], [8, 13, 3], [9, 13, 4], [9, 14, 6], [10, 14, 5], [11, 14, 3], [11, 15, 2], [11, 16, 1], [12, 16, 2], [12, 17, 10], [13, 17, 5], [14, 17, 3]]) == 1\n assert candidate(n = 7,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 5], [2, 4, 4], [3, 4, 2], [3, 5, 6], [4, 5, 3], [4, 6, 7], [5, 6, 1]]) == 2\n assert candidate(n = 8,roads = [[0, 1, 4], [0, 2, 1], [1, 2, 2], [1, 3, 5], [2, 3, 1], [2, 4, 2], [3, 4, 3], [3, 5, 1], [4, 5, 2], [4, 6, 1], [5, 6, 2], [5, 7, 3], [6, 7, 1]]) == 1\n", "comparison": "exact"}, "public_tests": ["7\n[[0,6,7],[0,1,2],[1,2,3],[1,3,3],[6,3,3],[3,5,1],[6,5,1],[2,5,1],[0,4,5],[4,6,2]]", "2\n[[1,0,10]]"], "hints": ["First use any shortest path algorithm to get edges where dist[u] + weight = dist[v], here dist[x] is the shortest distance between node 0 and x", "Using those edges only the graph turns into a dag now we just need to know the number of ways to get from node 0 to node n - 1 on a dag using dp"], "metadata": {"canonical_parameter_names": ["n", "roads"], "leetcode_dataset_entry_point": "Solution().countPaths", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:36:58+00:00", "tests_total": 64, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["dynamic-programming", "graph", "topological-sort", "shortest-path", "dijkstra"]}, "language": "python", "interface": {"raw_signature": "def countPaths(self, n: int, roads: list[list[int]]) -> int:", "container": "Solution", "callable": "countPaths", "parameters": [{"name": "n", "type": "int"}, {"name": "roads", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1977, "task_id": "number-of-ways-to-separate-numbers", "difficulty": "Hard", "problem_description": "You wrote down many positive integers in a string called num. However, you realized that you forgot to add commas to seperate the different numbers. You remember that the list of integers was non-decreasing and that no integer had leading zeros.\n\nReturn the number of possible lists of integers that you could have written down to get the string num. Since the answer may be large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: num = \"327\"\nOutput: 2\nExplanation: You could have written down the numbers:\n3, 27\n327\n\nExample 2:\n\nInput: num = \"094\"\nOutput: 0\nExplanation: No numbers can have leading zeros and all numbers must be positive.\n\nExample 3:\n\nInput: num = \"0\"\nOutput: 0\nExplanation: No numbers can have leading zeros and all numbers must be positive.\n\nConstraints:\n\n- 1 <= num.length <= 3500\n- num consists of digits '0' through '9'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"327\") == 2\n assert candidate(num = \"11110000111100001111\") == 30\n assert candidate(num = \"3333333333\") == 42\n assert candidate(num = \"123456789012345678901234567890\") == 1451\n assert candidate(num = \"0\") == 0\n assert candidate(num = \"10101\") == 2\n assert candidate(num = \"987654321\") == 8\n assert candidate(num = \"123\") == 3\n assert candidate(num = \"094\") == 0\n assert candidate(num = \"1111111111111111111111111111111\") == 6842\n assert candidate(num = \"9876543210987654321098765432109876543210\") == 1307\n assert candidate(num = \"101010\") == 3\n assert candidate(num = \"5555555\") == 15\n assert candidate(num = \"9999999999999999999999999999999\") == 6842\n assert candidate(num = \"100100100100100100100\") == 15\n assert candidate(num = \"24680\") == 6\n assert candidate(num = \"12345678901234567890\") == 287\n assert candidate(num = \"1234567890\") == 41\n assert candidate(num = \"11111\") == 7\n assert candidate(num = \"13579\") == 7\n assert candidate(num = \"12345\") == 7\n assert candidate(num = \"1001\") == 1\n assert candidate(num = \"999\") == 3\n assert candidate(num = \"111\") == 3\n assert candidate(num = \"1000000000000000000000000000000\") == 1\n assert candidate(num = \"112113114115116117118119120121\") == 1464\n assert candidate(num = \"11223344556677889900112233445566\") == 4050\n assert candidate(num = \"112233445566778899001122334455\") == 2836\n assert candidate(num = \"3330333033303330333033303330333\") == 481\n assert candidate(num = \"98765432109876543210\") == 67\n assert candidate(num = \"9999999999999999999999999999998\") == 5604\n assert candidate(num = \"123456789101112131415161718192021\") == 3405\n assert candidate(num = \"012345678901234567890123456789\") == 0\n assert candidate(num = \"987654321109876543211098765432110987654321\") == 1638\n assert candidate(num = \"1234567890123456789012345678901\") == 1716\n assert candidate(num = \"1000000000000000000000000000001\") == 1\n assert candidate(num = \"111222333444555666777888999000111222333444555\") == 41226\n assert candidate(num = \"1234567890123456789012345678901234567890\") == 6307\n assert candidate(num = \"1010101010101010101010101010101\") == 176\n assert candidate(num = \"212121212121212121212121212121\") == 1186\n assert candidate(num = \"11110001111000111100011110001111000111100011110001111000\") == 2300\n assert candidate(num = \"123456789876543211234567898765\") == 2137\n assert candidate(num = \"5555555555555555555555555555555555555555555555555\") == 173525\n assert candidate(num = \"123123123123123123123123123123\") == 1474\n assert candidate(num = \"111111111111111111111111111111111111111111111111\") == 147273\n assert candidate(num = \"321321321321321321321321321321\") == 809\n assert candidate(num = \"12312312312312312312312312312312\") == 2069\n assert candidate(num = \"1231231231231231231231231231230\") == 1641\n assert candidate(num = \"123456789876543211234567898765432112345678987654321\") == 41516\n assert candidate(num = \"123123123123123123123123123123123\") == 2438\n assert candidate(num = \"987654321109876543210987654321\") == 310\n assert candidate(num = \"121212121212121212121212121212\") == 1888\n assert candidate(num = \"1234567898765432109876543210987654321098765432109876543210\") == 81400\n assert candidate(num = \"00000000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(num = \"1122334455667788990011223344556677889900\") == 14863\n assert candidate(num = \"1001001001001001001001001001001\") == 42\n assert candidate(num = \"202020202020202020202020202020\") == 176\n assert candidate(num = \"987654321987654321987654321987\") == 423\n assert candidate(num = \"123123123123123123123123123123123123123123123123123123123\") == 78648\n assert candidate(num = \"11112222333344445555666677778888\") == 8349\n assert candidate(num = \"98979695949392919089888786858483\") == 454\n assert candidate(num = \"999000999000999000999000999000999000999000999000999000\") == 1027\n assert candidate(num = \"10203040506070809010\") == 41\n assert candidate(num = \"111222333444555666777888999000\") == 5513\n assert candidate(num = \"2222222222222222222222222222222\") == 6842\n assert candidate(num = \"1234123412341234123412341234123412341234\") == 7113\n assert candidate(num = \"999111999111999111999111999111\") == 987\n assert candidate(num = \"2333233323332333233323332333233323332333233323332333\") == 43205\n assert candidate(num = \"100100100100100100100100100100100100100100100100100\") == 297\n assert candidate(num = \"999999999999999999999999999999999999999999999999\") == 147273\n assert candidate(num = \"1234567891011121314151617181920\") == 2406\n assert candidate(num = \"987654321098765432109876543210\") == 326\n assert candidate(num = \"1231231231231231231231231231231\") == 1751\n assert candidate(num = \"101010101010101010101010101010101010101010101010101\") == 1958\n assert candidate(num = \"999990000099999000009999900000\") == 107\n assert candidate(num = \"999000999000999000999000999000\") == 98\n assert candidate(num = \"99999999988888888877777777666666665555555544444444333333332222222211111111\") == 299850\n assert candidate(num = \"11223344556677889900\") == 616\n assert candidate(num = \"1234567898765432109876543210987654321\") == 5367\n assert candidate(num = \"0123456789012345678901234567890\") == 0\n assert candidate(num = \"10101010101010101010101010101010\") == 231\n assert candidate(num = \"1111111111111111111122222222222222222\") == 21637\n assert candidate(num = \"1010101010101010101010101010102\") == 176\n assert candidate(num = \"22222222222222222222222222222222222222222222222\") == 124754\n assert candidate(num = \"1231231231231231231231231231231231231231231231231231231230\") == 85398\n assert candidate(num = \"12343211234567898765432109876543210\") == 2572\n assert candidate(num = \"123412341234123412341234123412\") == 1471\n assert candidate(num = \"12345432101234543210\") == 199\n assert candidate(num = \"0000000000000000000000000000001\") == 0\n assert candidate(num = \"123456789876543212345678987654321\") == 3452\n assert candidate(num = \"100100100100100100100100100100\") == 42\n assert candidate(num = \"00000000000000000000\") == 0\n assert candidate(num = \"10000000000000000000000000000000000000000000000\") == 1\n assert candidate(num = \"555555555555555555555555555555\") == 5604\n assert candidate(num = \"9999999999999999999999999999999999999999999999\") == 105558\n assert candidate(num = \"303030303030303030303030303030\") == 176\n assert candidate(num = \"1112131415161718192021222324252627282930\") == 12048\n assert candidate(num = \"1212121212121212121212121212121\") == 2059\n assert candidate(num = \"123412341234123412341234123412341234123412341234123412341\") == 69419\n assert candidate(num = \"1213141516171819202122232425262728293031323334353637383940\") == 97025\n assert candidate(num = \"0000000000000000000000000000000\") == 0\n assert candidate(num = \"1010101010101010101010101010101010101010101010\") == 1255\n assert candidate(num = \"1221221221221221221221221221221221221221221221221221\") == 46460\n assert candidate(num = \"123456789101112131415\") == 387\n assert candidate(num = \"1001001001001001001001001001000\") == 42\n", "comparison": "exact"}, "public_tests": ["\"327\"", "\"094\"", "\"0\""], "hints": ["If we know the current number has d digits, how many digits can the previous number have?", "Is there a quick way of calculating the number of possibilities for the previous number if we know that it must have less than or equal to d digits? Try to do some pre-processing."], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().numberOfCombinations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:00+00:00", "tests_total": 105, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def numberOfCombinations(self, num: str) -> int:", "container": "Solution", "callable": "numberOfCombinations", "parameters": [{"name": "num", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1979, "task_id": "find-greatest-common-divisor-of-array", "difficulty": "Easy", "problem_description": "Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums.\n\nThe greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers.\n\nExample 1:\n\nInput: nums = [2,5,6,9,10]\nOutput: 2\nExplanation:\nThe smallest number in nums is 2.\nThe largest number in nums is 10.\nThe greatest common divisor of 2 and 10 is 2.\n\nExample 2:\n\nInput: nums = [7,5,6,8,3]\nOutput: 1\nExplanation:\nThe smallest number in nums is 3.\nThe largest number in nums is 8.\nThe greatest common divisor of 3 and 8 is 1.\n\nExample 3:\n\nInput: nums = [3,3]\nOutput: 3\nExplanation:\nThe smallest number in nums is 3.\nThe largest number in nums is 3.\nThe greatest common divisor of 3 and 3 is 3.\n\nConstraints:\n\n- 2 <= nums.length <= 1000\n- 1 <= nums[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [42, 56, 14]) == 14\n assert candidate(nums = [1, 1000]) == 1\n assert candidate(nums = [17, 23, 37, 41]) == 1\n assert candidate(nums = [3, 3]) == 3\n assert candidate(nums = [7, 5, 6, 8, 3]) == 1\n assert candidate(nums = [1000, 1000]) == 1000\n assert candidate(nums = [48, 18, 30]) == 6\n assert candidate(nums = [10, 20, 30, 40, 50]) == 10\n assert candidate(nums = [100, 200, 300, 400, 500]) == 100\n assert candidate(nums = [17, 23, 19, 29, 31]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1000, 1]) == 1\n assert candidate(nums = [48, 18]) == 6\n assert candidate(nums = [2, 5, 6, 9, 10]) == 2\n assert candidate(nums = [48, 180, 120, 240]) == 48\n assert candidate(nums = [54, 24, 36]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [56, 98, 140, 224, 336]) == 56\n assert candidate(nums = [81, 27, 9, 3, 1]) == 1\n assert candidate(nums = [22, 44, 66, 88, 110, 132, 154]) == 22\n assert candidate(nums = [27, 54, 81, 108, 135, 162, 189]) == 27\n assert candidate(nums = [999, 1000]) == 1\n assert candidate(nums = [84, 60, 48, 36, 24]) == 12\n assert candidate(nums = [81, 27, 54, 162, 81]) == 27\n assert candidate(nums = [29, 29, 29, 29, 29, 29]) == 29\n assert candidate(nums = [83, 166, 332, 664, 996]) == 83\n assert candidate(nums = [999, 333, 666, 111, 222]) == 111\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136]) == 17\n assert candidate(nums = [1000, 1, 500, 250, 750, 200]) == 1\n assert candidate(nums = [60, 48, 36, 24, 12, 6, 3, 1]) == 1\n assert candidate(nums = [441, 49, 147, 343, 735]) == 49\n assert candidate(nums = [1, 1000, 2, 999, 3, 998]) == 1\n assert candidate(nums = [1000, 10, 50, 250, 500]) == 10\n assert candidate(nums = [44, 55, 66, 77, 88, 99]) == 11\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 15\n assert candidate(nums = [999, 998, 997, 996, 995]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500]) == 100\n assert candidate(nums = [31, 62, 93, 124, 155]) == 31\n assert candidate(nums = [77, 143, 209, 286, 187]) == 11\n assert candidate(nums = [42, 42, 42, 42, 42]) == 42\n assert candidate(nums = [98, 49, 147, 245, 343, 441, 539]) == 49\n assert candidate(nums = [17, 23, 29, 31, 37]) == 1\n assert candidate(nums = [13, 13, 13, 13, 13, 13, 13]) == 13\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130]) == 13\n assert candidate(nums = [999, 888, 777, 666, 555]) == 111\n assert candidate(nums = [1000, 750, 500, 250]) == 250\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260]) == 13\n assert candidate(nums = [54, 24, 36, 48, 60]) == 12\n assert candidate(nums = [1000, 1000, 1000, 1000]) == 1000\n assert candidate(nums = [999, 333, 111, 37, 1]) == 1\n assert candidate(nums = [231, 105, 77, 49, 33, 11, 7]) == 7\n assert candidate(nums = [77, 49, 14, 21, 28]) == 7\n assert candidate(nums = [997, 991, 983, 977, 971, 967, 953, 941, 929, 919, 907, 887, 883]) == 1\n assert candidate(nums = [50, 75, 100, 125, 150, 175, 200]) == 50\n assert candidate(nums = [210, 231, 273, 308, 357, 399]) == 21\n assert candidate(nums = [17, 34, 51, 68, 85]) == 17\n assert candidate(nums = [1, 1000]) == 1\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170]) == 17\n assert candidate(nums = [100, 150, 200, 250, 300]) == 100\n assert candidate(nums = [650, 520, 390, 780, 260]) == 260\n assert candidate(nums = [100, 200, 300, 400, 500, 600]) == 100\n assert candidate(nums = [17, 19, 23, 29, 31]) == 1\n assert candidate(nums = [123, 456, 789, 987, 654]) == 3\n assert candidate(nums = [33, 66, 99, 132, 165, 198, 231, 264]) == 33\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [13, 26, 39, 52, 65]) == 13\n assert candidate(nums = [12, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 12\n assert candidate(nums = [17, 34, 51, 68, 85, 102]) == 17\n assert candidate(nums = [1, 1000, 2, 500, 4]) == 1\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290, 319, 348, 377, 406, 435, 464, 493, 522, 551, 580]) == 29\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996]) == 1\n assert candidate(nums = [77, 49, 14, 28, 35, 56]) == 7\n assert candidate(nums = [500, 500, 500, 500, 500, 500]) == 500\n assert candidate(nums = [24, 36, 48, 60, 72, 84, 96]) == 24\n assert candidate(nums = [1000, 750, 500, 250, 125, 62, 31]) == 1\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111]) == 111\n assert candidate(nums = [41, 82, 123, 164, 205, 246, 287, 328]) == 41\n assert candidate(nums = [1, 1000, 500, 250, 125, 62, 31, 15]) == 1\n assert candidate(nums = [84, 112, 168, 224, 280]) == 28\n assert candidate(nums = [56, 98, 140, 182, 224]) == 56\n assert candidate(nums = [77, 154, 231, 308, 385, 462, 539, 616]) == 77\n assert candidate(nums = [60, 120, 180, 240, 300, 360]) == 60\n assert candidate(nums = [840, 756, 630, 504, 420]) == 420\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108]) == 12\n assert candidate(nums = [49, 63, 28, 91, 35]) == 7\n assert candidate(nums = [1000, 500, 250, 125, 62]) == 2\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [27, 81, 54, 162, 243]) == 27\n assert candidate(nums = [101, 202, 303, 404, 505]) == 101\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203]) == 29\n assert candidate(nums = [24, 36, 48, 60, 72, 84]) == 12\n assert candidate(nums = [840, 756, 672, 588, 504, 420, 336, 252, 168, 84]) == 84\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909]) == 101\n assert candidate(nums = [997, 991, 983, 977, 971]) == 1\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137]) == 1\n assert candidate(nums = [987, 654, 321, 123, 456, 789]) == 3\n assert candidate(nums = [101, 103, 107, 109, 113]) == 1\n assert candidate(nums = [23, 47, 17, 53, 31, 19, 89, 73]) == 1\n", "comparison": "exact"}, "public_tests": ["[2,5,6,9,10]", "[7,5,6,8,3]", "[3,3]"], "hints": ["Find the minimum and maximum in one iteration. Let them be mn and mx.", "Try all the numbers in the range [1, mn] and check the largest number which divides both of them."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findGCD", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:02+00:00", "tests_total": 117, "tests_dropped": 18, "flags": [], "topic_tags": ["array", "math", "number-theory", "euclidean-algorithm", "greatest-common-divisor"]}, "language": "python", "interface": {"raw_signature": "def findGCD(self, nums: list[int]) -> int:", "container": "Solution", "callable": "findGCD", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1980, "task_id": "find-unique-binary-string", "difficulty": "Medium", "problem_description": "Given an array of strings nums containing n unique binary strings each of length n, return a binary string of length n that does not appear in nums. If there are multiple answers, you may return any of them.\n\nExample 1:\n\nInput: nums = [\"01\",\"10\"]\nOutput: \"11\"\nExplanation: \"11\" does not appear in nums. \"00\" would also be correct.\n\nExample 2:\n\nInput: nums = [\"00\",\"01\"]\nOutput: \"11\"\nExplanation: \"11\" does not appear in nums. \"10\" would also be correct.\n\nExample 3:\n\nInput: nums = [\"111\",\"011\",\"001\"]\nOutput: \"101\"\nExplanation: \"101\" does not appear in nums. \"000\", \"010\", \"100\", and \"110\" would also be correct.\n\nConstraints:\n\n- n == nums.length\n- 1 <= n <= 16\n- nums[i].length == n\n- nums[i] is either '0' or '1'.\n- All the strings of nums are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = ['01', '10']) == \"00\"\n assert candidate(nums = ['00', '01']) == \"11\"\n assert candidate(nums = ['111', '011', '001']) == \"000\"\n assert candidate(nums = ['1101', '1011', '0111', '0011']) == \"0000\"\n assert candidate(nums = ['1100', '0011', '1010', '0101']) == \"0000\"\n assert candidate(nums = ['101010', '010101', '001100', '110011', '111100', '000011']) == \"000000\"\n assert candidate(nums = ['1100', '1011', '0011', '1110']) == \"0000\"\n assert candidate(nums = ['1101', '0010', '1001', '0110']) == \"0000\"\n assert candidate(nums = ['1100', '0101', '1010', '0011']) == \"0000\"\n assert candidate(nums = ['11111111', '00000000', '10101010', '01010101', '11001100', '00110011', '10011001', '01100110']) == \"10000000\"\n assert candidate(nums = ['1100', '1010', '0110', '0001']) == \"0000\"\n assert candidate(nums = ['1010', '0101', '1111', '0000']) == \"1000\"\n assert candidate(nums = ['1010', '0101', '1100', '0011']) == \"0000\"\n", "comparison": "exact"}, "public_tests": ["[\"01\",\"10\"]", "[\"00\",\"01\"]", "[\"111\",\"011\",\"001\"]"], "hints": ["We can convert the given strings into base 10 integers.", "Can we use recursion to generate all possible strings?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findDifferentBinaryString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:04+00:00", "tests_total": 54, "tests_dropped": 41, "flags": ["multiple_answers"], "topic_tags": ["array", "hash-table", "string", "backtracking"]}, "language": "python", "interface": {"raw_signature": "def findDifferentBinaryString(self, nums: list[str]) -> str:", "container": "Solution", "callable": "findDifferentBinaryString", "parameters": [{"name": "nums", "type": "list[str]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1981, "task_id": "minimize-the-difference-between-target-and-chosen-elements", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix mat and an integer target.\n\nChoose one integer from each row in the matrix such that the absolute difference between target and the sum of the chosen elements is minimized.\n\nReturn the minimum absolute difference.\n\nThe absolute difference between two numbers a and b is the absolute value of a - b.\n\nExample 1:\n\nInput: mat = [[1,2,3],[4,5,6],[7,8,9]], target = 13\nOutput: 0\nExplanation: One possible choice is to:\n- Choose 1 from the first row.\n- Choose 5 from the second row.\n- Choose 7 from the third row.\nThe sum of the chosen elements is 13, which equals the target, so the absolute difference is 0.\n\nExample 2:\n\nInput: mat = [[1],[2],[3]], target = 100\nOutput: 94\nExplanation: The best possible choice is to:\n- Choose 1 from the first row.\n- Choose 2 from the second row.\n- Choose 3 from the third row.\nThe sum of the chosen elements is 6, and the absolute difference is 94.\n\nExample 3:\n\nInput: mat = [[1,2,9,8,7]], target = 6\nOutput: 1\nExplanation: The best choice is to choose 7 from the first row.\nThe absolute difference is 1.\n\nConstraints:\n\n- m == mat.length\n- n == mat[i].length\n- 1 <= m, n <= 70\n- 1 <= mat[i][j] <= 70\n- 1 <= target <= 800\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1], [2], [3]],target = 100) == 94\n assert candidate(mat = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],target = 15) == 0\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],target = 13) == 0\n assert candidate(mat = [[7, 8, 9], [1, 2, 3], [4, 5, 6]],target = 20) == 2\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19]],target = 25) == 1\n assert candidate(mat = [[10, 20, 30], [5, 15, 25], [1, 10, 20]],target = 50) == 4\n assert candidate(mat = [[7, 8, 9], [10, 11, 12], [13, 14, 15]],target = 36) == 0\n assert candidate(mat = [[70, 70, 70], [70, 70, 70], [70, 70, 70]],target = 150) == 60\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15]],target = 20) == 0\n assert candidate(mat = [[70, 70, 70], [70, 70, 70], [70, 70, 70]],target = 100) == 110\n assert candidate(mat = [[1, 2, 9, 8, 7]],target = 6) == 1\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],target = 5) == 2\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7]],target = 21) == 0\n assert candidate(mat = [[70, 70, 70, 70, 70], [70, 70, 70, 70, 70], [70, 70, 70, 70, 70]],target = 800) == 590\n assert candidate(mat = [[2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [5, 10, 15, 20, 25], [7, 14, 21, 28, 35]],target = 100) == 15\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 1, 1, 1, 1]],target = 25) == 5\n assert candidate(mat = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [7, 17, 27, 37, 47]],target = 150) == 3\n assert candidate(mat = [[5, 15, 25], [5, 15, 25], [5, 15, 25], [5, 15, 25], [5, 15, 25]],target = 50) == 5\n assert candidate(mat = [[70, 1], [70, 1], [70, 1], [70, 1], [70, 1], [70, 1], [70, 1]],target = 200) == 14\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],target = 75) == 12\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]],target = 105) == 21\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21]],target = 50) == 8\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28]],target = 100) == 30\n assert candidate(mat = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 2, 3, 4, 5]],target = 85) == 1\n assert candidate(mat = [[60, 59, 58, 57, 56, 55, 54], [53, 52, 51, 50, 49, 48, 47], [46, 45, 44, 43, 42, 41, 40], [39, 38, 37, 36, 35, 34, 33], [32, 31, 30, 29, 28, 27, 26], [25, 24, 23, 22, 21, 20, 19]],target = 420) == 165\n assert candidate(mat = [[10, 20, 30, 40, 50, 60, 70], [70, 60, 50, 40, 30, 20, 10], [1, 2, 3, 4, 5, 6, 7]],target = 200) == 53\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5]],target = 50) == 35\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [20, 22, 24, 26, 28]],target = 50) == 0\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],target = 50) == 1\n assert candidate(mat = [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50, 55, 60]],target = 120) == 0\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 8], [3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 10]],target = 50) == 16\n assert candidate(mat = [[50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50]],target = 400) == 50\n assert candidate(mat = [[1, 70], [2, 69], [3, 68], [4, 67], [5, 66], [6, 65], [7, 64], [8, 63], [9, 62], [10, 61]],target = 400) == 1\n assert candidate(mat = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [1, 6, 11, 16, 21, 26, 31, 36, 41, 46], [2, 7, 12, 17, 22, 27, 32, 37, 42, 47], [3, 8, 13, 18, 23, 28, 33, 38, 43, 48]],target = 150) == 1\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6], [7, 7, 7, 7, 7, 7, 7]],target = 28) == 0\n assert candidate(mat = [[70, 69, 68, 67, 66, 65, 64], [63, 62, 61, 60, 59, 58, 57], [56, 55, 54, 53, 52, 51, 50], [49, 48, 47, 46, 45, 44, 43]],target = 260) == 22\n assert candidate(mat = [[70, 69, 68], [67, 66, 65], [64, 63, 62], [61, 60, 59], [58, 57, 56]],target = 250) == 60\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28]],target = 100) == 30\n assert candidate(mat = [[50, 49, 48, 47, 46, 45, 44], [43, 42, 41, 40, 39, 38, 37], [36, 35, 34, 33, 32, 31, 30]],target = 130) == 1\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],target = 10) == 6\n assert candidate(mat = [[3, 10, 7], [8, 6, 4], [15, 12, 9], [18, 16, 13]],target = 50) == 1\n assert candidate(mat = [[7, 8, 9], [1, 2, 3], [4, 5, 6], [10, 11, 12]],target = 25) == 0\n assert candidate(mat = [[7, 21, 42, 58], [9, 23, 46, 62], [11, 25, 49, 65], [13, 27, 51, 67], [15, 29, 53, 69]],target = 200) == 0\n assert candidate(mat = [[70, 60, 50, 40, 30], [20, 30, 40, 50, 60], [10, 20, 30, 40, 50]],target = 200) == 20\n assert candidate(mat = [[7, 17, 27, 37, 47], [8, 18, 28, 38, 48], [9, 19, 29, 39, 49], [10, 20, 30, 40, 50], [11, 21, 31, 41, 51]],target = 150) == 5\n assert candidate(mat = [[70, 69, 68, 67], [66, 65, 64, 63], [62, 61, 60, 59], [58, 57, 56, 55]],target = 260) == 4\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],target = 80) == 30\n assert candidate(mat = [[7, 8, 9], [4, 5, 6], [1, 2, 3], [7, 8, 9], [4, 5, 6], [1, 2, 3]],target = 30) == 0\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],target = 50) == 5\n assert candidate(mat = [[70, 60, 50, 40, 30], [10, 20, 30, 40, 50], [60, 50, 40, 30, 20], [1, 2, 3, 4, 5]],target = 180) == 1\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],target = 60) == 0\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [15, 17, 19, 21, 23, 25, 27]],target = 50) == 0\n assert candidate(mat = [[10, 20, 30], [11, 21, 31], [12, 22, 32], [13, 23, 33], [14, 24, 34]],target = 120) == 0\n assert candidate(mat = [[5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5]],target = 10) == 10\n assert candidate(mat = [[1, 3, 5, 7], [2, 4, 6, 8], [9, 11, 13, 15], [17, 19, 21, 23]],target = 30) == 1\n assert candidate(mat = [[1, 70], [1, 70], [1, 70], [1, 70], [1, 70], [1, 70], [1, 70]],target = 300) == 17\n assert candidate(mat = [[10, 20, 30], [15, 25, 35], [20, 30, 40], [25, 35, 45]],target = 120) == 0\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15]],target = 100) == 66\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4]],target = 20) == 10\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35]],target = 150) == 45\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],target = 1) == 5\n assert candidate(mat = [[5, 10, 15], [10, 20, 30], [15, 25, 35], [20, 30, 40], [25, 35, 45]],target = 100) == 0\n assert candidate(mat = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41]],target = 120) == 4\n assert candidate(mat = [[70, 70, 70], [70, 70, 70], [70, 70, 70], [70, 70, 70], [70, 70, 70], [70, 70, 70], [70, 70, 70]],target = 800) == 310\n assert candidate(mat = [[5, 15, 25], [10, 20, 30], [15, 25, 35], [20, 30, 40]],target = 100) == 0\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]],target = 50) == 0\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5]],target = 100) == 85\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19]],target = 50) == 12\n assert candidate(mat = [[5, 15, 25, 35], [10, 20, 30, 40], [15, 25, 35, 45], [20, 30, 40, 50], [25, 35, 45, 55]],target = 200) == 5\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19]],target = 30) == 0\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],target = 10) == 3\n assert candidate(mat = [[70, 60, 50, 40, 30, 20, 10], [65, 55, 45, 35, 25, 15, 5], [1, 2, 3, 4, 5, 6, 7]],target = 200) == 58\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 8, 12, 16, 20]],target = 40) == 0\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],target = 30) == 4\n assert candidate(mat = [[1, 5, 9, 14], [3, 7, 10, 17], [4, 8, 12, 19], [6, 11, 15, 20]],target = 45) == 0\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21]],target = 50) == 8\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]],target = 55) == 22\n assert candidate(mat = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4], [5, 5, 5, 5, 5]],target = 15) == 0\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27], [28, 29, 30]],target = 150) == 0\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]],target = 30) == 1\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42]],target = 200) == 53\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]],target = 49) == 0\n assert candidate(mat = [[7, 8, 9], [1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3], [4, 5, 6], [7, 8, 9]],target = 50) == 5\n assert candidate(mat = [[7, 8, 9], [1, 2, 3], [4, 5, 6], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]],target = 80) == 0\n assert candidate(mat = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4]],target = 25) == 15\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]],target = 100) == 16\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],target = 7) == 0\n", "comparison": "exact"}, "public_tests": ["[[1,2,3],[4,5,6],[7,8,9]]\n13", "[[1],[2],[3]]\n100", "[[1,2,9,8,7]]\n6"], "hints": ["The sum of chosen elements will not be too large. Consider using a hash set to record all possible sums while iterating each row.", "Instead of keeping track of all possible sums, since in each row, we are adding positive numbers, only keep those that can be a candidate, not exceeding the target by too much."], "metadata": {"canonical_parameter_names": ["mat", "target"], "leetcode_dataset_entry_point": "Solution().minimizeTheDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:07+00:00", "tests_total": 104, "tests_dropped": 17, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "matrix"]}, "language": "python", "interface": {"raw_signature": "def minimizeTheDifference(self, mat: list[list[int]], target: int) -> int:", "container": "Solution", "callable": "minimizeTheDifference", "parameters": [{"name": "mat", "type": "list[list[int]]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1982, "task_id": "find-array-given-subset-sums", "difficulty": "Hard", "problem_description": "You are given an integer n representing the length of an unknown array that you are trying to recover. You are also given an array sums containing the values of all 2^n subset sums of the unknown array (in no particular order).\n\nReturn the array ans of length n representing the unknown array. If multiple answers exist, return any of them.\n\nAn array sub is a subset of an array arr if sub can be obtained from arr by deleting some (possibly zero or all) elements of arr. The sum of the elements in sub is one possible subset sum of arr. The sum of an empty array is considered to be 0.\n\nNote: Test cases are generated such that there will always be at least one correct answer.\n\nExample 1:\n\nInput: n = 3, sums = [-3,-2,-1,0,0,1,2,3]\nOutput: [1,2,-3]\nExplanation: [1,2,-3] is able to achieve the given subset sums:\n- []: sum is 0\n- [1]: sum is 1\n- [2]: sum is 2\n- [1,2]: sum is 3\n- [-3]: sum is -3\n- [1,-3]: sum is -2\n- [2,-3]: sum is -1\n- [1,2,-3]: sum is 0\nNote that any permutation of [1,2,-3] and also any permutation of [-1,-2,3] will also be accepted.\n\nExample 2:\n\nInput: n = 2, sums = [0,0,0,0]\nOutput: [0,0]\nExplanation: The only correct answer is [0,0].\n\nExample 3:\n\nInput: n = 4, sums = [0,0,5,5,4,-1,4,9,9,-1,4,3,4,8,3,8]\nOutput: [0,-1,4,5]\nExplanation: [0,-1,4,5] is able to achieve the given subset sums.\n\nConstraints:\n\n- 1 <= n <= 15\n- sums.length == 2^n\n- -10^4 <= sums[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,sums = [-3, -2, -1, 0, 0, 1, 2, 3]) == [-1, -2, 3]\n assert candidate(n = 2,sums = [0, 0, 0, 0]) == [0, 0]\n assert candidate(n = 1,sums = [0, 5]) == [5]\n assert candidate(n = 3,sums = [3, 1, 2, 0, 4, 5, 6, 8]) == [1, 2, 4]\n assert candidate(n = 4,sums = [0, 0, 5, 5, 4, -1, 4, 9, 9, -1, 4, 3, 4, 8, 3, 8]) == [0, -1, 4, 5]\n assert candidate(n = 1,sums = [0, -1]) == [-1]\n assert candidate(n = 4,sums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == [0, 1, 2, 4]\n assert candidate(n = 4,sums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 2, 4, 8]\n assert candidate(n = 3,sums = [0, 2, 2, 4, 6, 6, 8, 10]) == [2, 2, 6]\n assert candidate(n = 3,sums = [1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 4]\n assert candidate(n = 4,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == [1, -2, 4, -8]\n assert candidate(n = 4,sums = [0, -1, -2, -3, -4, 1, 2, 3, 4, -5, 5, -6, 6, -7, 7, 8]) == [-1, -2, -4, 8]\n assert candidate(n = 3,sums = [10, 20, 30, 40, 50, 60, 70, 80]) == [10, 20, 40]\n assert candidate(n = 4,sums = [-1, -2, -3, -4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 2, -4, 8]\n assert candidate(n = 4,sums = [-9, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7]) == [-2, -3, -4, 8]\n assert candidate(n = 5,sums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == [1, 2, 4, 8, 16]\n assert candidate(n = 6,sums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]) == [1, 2, 4, 8, 16, 32]\n assert candidate(n = 4,sums = [-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [-1, -2, 4, 8]\n assert candidate(n = 4,sums = [-10, -7, -9, -8, -5, -6, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == [1, -2, 4, -8]\n assert candidate(n = 3,sums = [-4, -2, -1, 0, 0, 1, 2, 4]) == [2, 3, -4]\n assert candidate(n = 4,sums = [-6, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2]) == [-1, -1, 2, -4]\n assert candidate(n = 5,sums = [-15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [-1, -2, -4, -8, 15]\n assert candidate(n = 1,sums = [0, 2]) == [2]\n assert candidate(n = 6,sums = [-31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [-1, -2, -4, -8, -16, 31]\n assert candidate(n = 3,sums = [-5, -3, -2, -1, 0, 0, 1, 2]) == [-2, -3, 4]\n assert candidate(n = 3,sums = [-1, -1, -1, -1, -1, 0, 0, 0]) == [0, 0, 0]\n assert candidate(n = 1,sums = [0, 1]) == [1]\n assert candidate(n = 4,sums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == [0, 0, 1, 2]\n assert candidate(n = 1,sums = [0, 3]) == [3]\n assert candidate(n = 2,sums = [-1, 0, 1, 2]) == [-1, 2]\n assert candidate(n = 4,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == [1, -2, 4, -8]\n assert candidate(n = 1,sums = [0, -5]) == [-5]\n assert candidate(n = 4,sums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0]\n assert candidate(n = 2,sums = [-2, -1, 0, 1]) == [1, -2]\n assert candidate(n = 3,sums = [-3, -1, 0, 1, 2, 3, 4, 6]) == [2, -3, 4]\n assert candidate(n = 3,sums = [-1, -2, -3, 0, 1, 2, 3, 4]) == [-1, -2, 4]\n assert candidate(n = 1,sums = [0, 0]) == [0]\n assert candidate(n = 3,sums = [-3, -2, -1, -1, 0, 0, 1, 2]) == [-1, -2, 2]\n assert candidate(n = 3,sums = [1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 4]\n", "comparison": "exact"}, "public_tests": ["3\n[-3,-2,-1,0,0,1,2,3]", "2\n[0,0,0,0]", "4\n[0,0,5,5,4,-1,4,9,9,-1,4,3,4,8,3,8]"], "hints": ["What information do the two largest elements tell us?", "Can we use recursion to check all possible states?"], "metadata": {"canonical_parameter_names": ["n", "sums"], "leetcode_dataset_entry_point": "Solution().recoverArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:09+00:00", "tests_total": 89, "tests_dropped": 50, "flags": ["multiple_answers"], "topic_tags": ["array", "hash-table", "sorting", "counting"]}, "language": "python", "interface": {"raw_signature": "def recoverArray(self, n: int, sums: list[int]) -> list[int]:", "container": "Solution", "callable": "recoverArray", "parameters": [{"name": "n", "type": "int"}, {"name": "sums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1984, "task_id": "minimum-difference-between-highest-and-lowest-of-k-scores", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums, where nums[i] represents the score of the i^th student. You are also given an integer k.\n\nPick the scores of any k students from the array so that the difference between the highest and the lowest of the k scores is minimized.\n\nReturn the minimum possible difference.\n\nExample 1:\n\nInput: nums = [90], k = 1\nOutput: 0\nExplanation: There is one way to pick score(s) of one student:\n- [90]. The difference between the highest and lowest score is 90 - 90 = 0.\nThe minimum possible difference is 0.\n\nExample 2:\n\nInput: nums = [9,4,1,7], k = 2\nOutput: 2\nExplanation: There are six ways to pick score(s) of two students:\n- [9,4,1,7]. The difference between the highest and lowest score is 9 - 4 = 5.\n- [9,4,1,7]. The difference between the highest and lowest score is 9 - 1 = 8.\n- [9,4,1,7]. The difference between the highest and lowest score is 9 - 7 = 2.\n- [9,4,1,7]. The difference between the highest and lowest score is 4 - 1 = 3.\n- [9,4,1,7]. The difference between the highest and lowest score is 7 - 4 = 3.\n- [9,4,1,7]. The difference between the highest and lowest score is 7 - 1 = 6.\nThe minimum possible difference is 2.\n\nConstraints:\n\n- 1 <= k <= nums.length <= 1000\n- 0 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 9, 1, 32, 13],k = 3) == 8\n assert candidate(nums = [1, 5, 6, 14, 15],k = 3) == 5\n assert candidate(nums = [9, 4, 1, 7],k = 2) == 2\n assert candidate(nums = [8, 10, 2],k = 2) == 2\n assert candidate(nums = [1, 5, 9, 14, 18],k = 3) == 8\n assert candidate(nums = [4, 9, 1, 17, 6, 11, 22],k = 5) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],k = 1) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 0\n assert candidate(nums = [8, 10, 5, 7, 9, 3],k = 4) == 3\n assert candidate(nums = [4, 9, 1, 32, 13],k = 2) == 3\n assert candidate(nums = [90],k = 1) == 0\n assert candidate(nums = [8, 10, 12, 14, 16],k = 3) == 4\n assert candidate(nums = [4, 2, 1, 3],k = 2) == 1\n assert candidate(nums = [8, 8, 8, 8, 8],k = 5) == 0\n assert candidate(nums = [1, 5, 6, 14, 15],k = 2) == 1\n assert candidate(nums = [100000, 0, 1, 2, 99999],k = 2) == 1\n assert candidate(nums = [8, 10, 15, 17, 20, 23],k = 4) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 3\n assert candidate(nums = [1, 3, 6, 19, 20],k = 3) == 5\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 10) == 900\n assert candidate(nums = [5, 8, 12, 19, 23, 27, 31, 35, 39, 41, 45, 49, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99],k = 5) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 40\n assert candidate(nums = [28, 90, 3, 23, 90, 18, 39, 72, 45, 67],k = 5) == 27\n assert candidate(nums = [88, 22, 55, 77, 33, 44, 66, 11, 99, 0, 6, 3, 5, 7, 9, 1, 2, 4, 8, 10, 12, 14, 16, 18, 20, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 90, 92, 94, 96, 98],k = 10) == 9\n assert candidate(nums = [50, 40, 30, 20, 10, 90, 80, 70, 60, 100],k = 5) == 40\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 8) == 700\n assert candidate(nums = [1, 3, 6, 19, 20, 25, 28, 30, 31, 32, 33],k = 6) == 8\n assert candidate(nums = [500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50],k = 7) == 30\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 3) == 0\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 5) == 4\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020],k = 11) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400],k = 13) == 120\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980],k = 15) == 14\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],k = 3) == 2000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 15) == 140\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 7\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0, 99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0],k = 15) == 77777\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 10000, 20000, 30000, 40000, 50000],k = 10) == 40000\n assert candidate(nums = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120],k = 6) == 5\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717],k = 8) == 505\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],k = 30) == 29\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 90000, 9000, 900, 90],k = 3) == 89\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 4) == 3\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 5) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 9\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120],k = 10) == 72\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4) == 3\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 3, 9, 3, 2, 8, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0],k = 20) == 1\n assert candidate(nums = [5, 15, 30, 10, 20, 25, 40, 50],k = 5) == 20\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 11) == 1000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 40\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 6) == 50\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 1) == 0\n assert candidate(nums = [1, 3, 6, 19, 20, 25, 30, 35, 40, 45, 50],k = 6) == 21\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 3) == 20000\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109],k = 10) == 36\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 2) == 0\n assert candidate(nums = [80, 60, 40, 20, 0, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480],k = 7) == 120\n assert candidate(nums = [23, 45, 12, 67, 89, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90],k = 8) == 23\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 60\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == 200\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 60\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],k = 3) == 2\n assert candidate(nums = [45, 33, 21, 10, 1, 0, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],k = 25) == 41\n assert candidate(nums = [300, 200, 100, 50, 25, 10, 5, 3, 2, 1, 0, 1, 3, 5, 10, 25, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 15) == 99\n assert candidate(nums = [99999, 100000, 0, 1, 2, 99998, 3, 4, 5, 6],k = 4) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 0\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 210, 311, 412, 513, 614, 715, 816, 917, 1018],k = 8) == 77\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 90\n assert candidate(nums = [8, 18, 28, 38, 48, 58, 68, 78, 88, 98, 108, 118, 128, 138, 148, 158],k = 3) == 20\n assert candidate(nums = [34, 7, 23, 32, 5, 62],k = 4) == 27\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 7) == 60\n assert candidate(nums = [5, 8, 12, 18, 23, 30, 37, 45, 53, 62],k = 6) == 25\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 26) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 14\n assert candidate(nums = [89, 75, 91, 85, 92, 88, 76, 90, 86, 84],k = 4) == 3\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991],k = 10) == 9\n assert candidate(nums = [5, 8, 12, 18, 22, 27, 30, 35, 40, 45, 50],k = 5) == 17\n assert candidate(nums = [987, 654, 321, 654, 321, 987, 654, 321, 987, 654, 321, 987, 654, 321, 987],k = 6) == 333\n assert candidate(nums = [345, 678, 901, 234, 567, 890, 123, 456, 789],k = 4) == 223\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 9) == 16\n assert candidate(nums = [5, 23, 9, 56, 12, 89, 76, 45, 34, 67, 88, 90],k = 5) == 23\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10) == 0\n", "comparison": "exact"}, "public_tests": ["[90]\n1", "[9,4,1,7]\n2"], "hints": ["For the difference between the highest and lowest element to be minimized, the k chosen scores need to be as close to each other as possible.", "What if the array was sorted?", "After sorting the scores, any contiguous k scores are as close to each other as possible.", "Apply a sliding window solution to iterate over each contiguous k scores, and find the minimum of the differences of all windows."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minimumDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:14+00:00", "tests_total": 95, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "sliding-window", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minimumDifference(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "minimumDifference", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1985, "task_id": "find-the-kth-largest-integer-in-the-array", "difficulty": "Medium", "problem_description": "You are given an array of strings nums and an integer k. Each string in nums represents an integer without leading zeros.\n\nReturn the string that represents the k^th largest integer in nums.\n\nNote: Duplicate numbers should be counted distinctly. For example, if nums is [\"1\",\"2\",\"2\"], \"2\" is the first largest integer, \"2\" is the second-largest integer, and \"1\" is the third-largest integer.\n\nExample 1:\n\nInput: nums = [\"3\",\"6\",\"7\",\"10\"], k = 4\nOutput: \"3\"\nExplanation:\nThe numbers in nums sorted in non-decreasing order are [\"3\",\"6\",\"7\",\"10\"].\nThe 4^th largest integer in nums is \"3\".\n\nExample 2:\n\nInput: nums = [\"2\",\"21\",\"12\",\"1\"], k = 3\nOutput: \"2\"\nExplanation:\nThe numbers in nums sorted in non-decreasing order are [\"1\",\"2\",\"12\",\"21\"].\nThe 3^rd largest integer in nums is \"2\".\n\nExample 3:\n\nInput: nums = [\"0\",\"0\"], k = 2\nOutput: \"0\"\nExplanation:\nThe numbers in nums sorted in non-decreasing order are [\"0\",\"0\"].\nThe 2^nd largest integer in nums is \"0\".\n\nConstraints:\n\n- 1 <= k <= nums.length <= 10^4\n- 1 <= nums[i].length <= 100\n- nums[i] consists of only digits.\n- nums[i] will not have any leading zeros.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = ['100', '200', '300', '400', '500'],k = 2) == \"400\"\n assert candidate(nums = ['2', '21', '12', '1'],k = 3) == \"2\"\n assert candidate(nums = ['9', '8', '7', '6', '5', '4', '3', '2', '1'],k = 5) == \"5\"\n assert candidate(nums = ['100', '200', '300', '400'],k = 2) == \"300\"\n assert candidate(nums = ['9', '11', '8', '9', '10'],k = 5) == \"8\"\n assert candidate(nums = ['9', '11', '2', '22'],k = 2) == \"11\"\n assert candidate(nums = ['10', '20', '30', '40', '50'],k = 5) == \"10\"\n assert candidate(nums = ['10', '10', '10', '10'],k = 3) == \"10\"\n assert candidate(nums = ['0', '0'],k = 2) == \"0\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],k = 10) == \"1\"\n assert candidate(nums = ['100', '200', '300', '400'],k = 1) == \"400\"\n assert candidate(nums = ['10', '2', '11', '3', '7'],k = 1) == \"11\"\n assert candidate(nums = ['5', '3', '8', '6', '7'],k = 1) == \"8\"\n assert candidate(nums = ['1', '2', '2', '3', '3', '3'],k = 4) == \"2\"\n assert candidate(nums = ['10', '100', '1000', '10000'],k = 3) == \"100\"\n assert candidate(nums = ['3', '6', '7', '10'],k = 4) == \"3\"\n assert candidate(nums = ['100', '200', '300', '400', '500', '600', '700', '800', '900'],k = 9) == \"100\"\n assert candidate(nums = ['500', '50', '5000', '50000', '5'],k = 4) == \"50\"\n assert candidate(nums = ['987654321', '987654320', '987654319', '987654318', '987654317'],k = 5) == \"987654317\"\n assert candidate(nums = ['123456789', '987654321', '135792468', '246813579', '864209753'],k = 3) == \"246813579\"\n assert candidate(nums = ['1', '11', '111', '1111', '11111'],k = 3) == \"111\"\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999', '000'],k = 7) == \"333\"\n assert candidate(nums = ['500', '50', '5', '5000'],k = 3) == \"50\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15'],k = 10) == \"6\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000'],k = 5) == \"100\"\n assert candidate(nums = ['1', '3', '5', '7', '9', '11', '13', '15', '17', '19'],k = 7) == \"7\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415', '161718', '192021', '222324', '252627', '282930'],k = 5) == \"161718\"\n assert candidate(nums = ['1000000', '999999', '100000', '99999', '10000', '9999', '1000', '999', '100', '99', '10', '9'],k = 8) == \"999\"\n assert candidate(nums = ['999', '1000', '1001', '1002', '1003'],k = 2) == \"1002\"\n assert candidate(nums = ['987654321', '987654320', '987654319', '987654318', '987654317'],k = 4) == \"987654318\"\n assert candidate(nums = ['9876543210', '9876543211', '9876543212', '9876543213', '9876543214'],k = 5) == \"9876543210\"\n assert candidate(nums = ['123', '456', '789', '123', '456', '789', '123', '456', '789'],k = 5) == \"456\"\n assert candidate(nums = ['10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 3) == \"10000000\"\n assert candidate(nums = ['1000000000', '1000000001', '1000000002', '1000000003', '1000000004'],k = 2) == \"1000000003\"\n assert candidate(nums = ['100000000000000000000000000000000000000000000000000000000000000', '99999999999999999999999999999999999999999999999999999999999999'],k = 1) == \"100000000000000000000000000000000000000000000000000000000000000\"\n assert candidate(nums = ['0', '00', '000', '0000', '00000'],k = 3) == \"000\"\n assert candidate(nums = ['5000', '4000', '3000', '2000', '1000', '500', '400', '300', '200', '100'],k = 5) == \"1000\"\n assert candidate(nums = ['987654321', '87654321', '7654321', '654321', '54321', '4321', '321', '21', '1'],k = 3) == \"7654321\"\n assert candidate(nums = ['1', '1', '2', '2', '3', '3', '4', '4', '5', '5'],k = 8) == \"2\"\n assert candidate(nums = ['111111111', '222222222', '333333333', '444444444', '555555555', '666666666', '777777777', '888888888', '999999999'],k = 9) == \"111111111\"\n assert candidate(nums = ['1', '11', '111', '1111', '11111', '111111'],k = 6) == \"1\"\n assert candidate(nums = ['12345', '12345', '12345', '12345', '12345', '12345', '12345', '12345', '12345', '12345'],k = 8) == \"12345\"\n assert candidate(nums = ['99', '98', '97', '96', '95', '94', '93', '92', '91', '90'],k = 5) == \"95\"\n assert candidate(nums = ['10', '2', '3', '4', '5', '6', '7', '8', '9'],k = 1) == \"10\"\n assert candidate(nums = ['9876543210', '987654321', '98765432', '9876543', '987654', '98765', '9876', '987', '98', '9'],k = 5) == \"987654\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20'],k = 10) == \"11\"\n assert candidate(nums = ['1', '3', '5', '7', '9', '11', '13', '15', '17', '19'],k = 1) == \"19\"\n assert candidate(nums = ['11111111111111111111', '22222222222222222222', '33333333333333333333', '44444444444444444444', '55555555555555555555'],k = 2) == \"44444444444444444444\"\n assert candidate(nums = ['100', '1000', '10000', '100000', '1000000'],k = 4) == \"1000\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20'],k = 19) == \"2\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 7) == \"1000\"\n assert candidate(nums = ['1000', '999', '100', '99', '10', '9', '1'],k = 7) == \"1\"\n assert candidate(nums = ['9', '8', '7', '6', '5', '4', '3', '2', '1'],k = 9) == \"1\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 3) == \"10000000\"\n assert candidate(nums = ['999999999999999999', '888888888888888888', '777777777777777777', '666666666666666666', '555555555555555555'],k = 3) == \"777777777777777777\"\n assert candidate(nums = ['123', '123', '123', '123', '123', '123', '123', '123', '123', '123'],k = 10) == \"123\"\n assert candidate(nums = ['123456789', '987654321', '123456789', '987654321', '123456789', '987654321', '123456789', '987654321', '123456789', '987654321'],k = 5) == \"987654321\"\n assert candidate(nums = ['1000', '999', '888', '777', '666', '555', '444', '333', '222', '111'],k = 10) == \"111\"\n assert candidate(nums = ['123456789', '987654321', '111111111', '999999999', '222222222'],k = 3) == \"222222222\"\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999', '1111'],k = 6) == \"555\"\n assert candidate(nums = ['10000', '9999', '9998', '9997', '9996', '9995', '9994', '9993', '9992', '9991'],k = 6) == \"9995\"\n assert candidate(nums = ['1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000'],k = 1) == \"1000\"\n assert candidate(nums = ['9', '99', '999', '9999', '99999', '999999', '9999999', '99999999', '999999999'],k = 8) == \"99\"\n assert candidate(nums = ['1000000000', '999999999', '100000000', '99999999', '10000000', '9999999', '1000000', '999999', '100000', '99999'],k = 10) == \"99999\"\n assert candidate(nums = ['123456789', '987654321', '135792468', '246813579'],k = 4) == \"123456789\"\n assert candidate(nums = ['1000000000', '1000000001', '1000000002', '1000000003', '1000000004', '1000000005'],k = 2) == \"1000000004\"\n assert candidate(nums = ['100', '200', '300', '400', '500', '600', '700', '800', '900', '1000'],k = 10) == \"100\"\n assert candidate(nums = ['123456789012345678901234567890', '987654321098765432109876543210', '111111111111111111111111111111', '999999999999999999999999999999', '222222222222222222222222222222'],k = 3) == \"222222222222222222222222222222\"\n assert candidate(nums = ['11111', '22222', '33333', '44444', '55555', '66666', '77777', '88888', '99999', '100000'],k = 9) == \"22222\"\n assert candidate(nums = ['500', '500', '500', '500', '500', '500', '500', '500', '500', '500'],k = 5) == \"500\"\n assert candidate(nums = ['9', '19', '29', '39', '49', '59', '69', '79', '89', '99'],k = 1) == \"99\"\n assert candidate(nums = ['9', '8', '7', '6', '5', '4', '3', '2', '1'],k = 1) == \"9\"\n assert candidate(nums = ['9', '99', '999', '9999', '99999'],k = 3) == \"999\"\n assert candidate(nums = ['1111111111', '2222222222', '3333333333', '4444444444', '5555555555'],k = 1) == \"5555555555\"\n assert candidate(nums = ['9999999999', '8888888888', '7777777777', '6666666666', '5555555555', '4444444444', '3333333333', '2222222222', '1111111111', '0'],k = 10) == \"0\"\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999', '1111', '2222', '3333', '4444', '5555', '6666', '7777', '8888', '9999'],k = 15) == \"444\"\n assert candidate(nums = ['9999999999', '8888888888', '7777777777', '6666666666', '5555555555'],k = 3) == \"7777777777\"\n assert candidate(nums = ['1000', '1000', '1000', '1000', '1000', '1000'],k = 3) == \"1000\"\n assert candidate(nums = ['1111111111', '2222222222', '3333333333', '4444444444', '5555555555', '6666666666', '7777777777', '8888888888', '9999999999', '10000000000'],k = 2) == \"9999999999\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000'],k = 5) == \"10\"\n assert candidate(nums = ['9', '29', '39', '49', '59', '69', '79', '89', '99', '109'],k = 8) == \"39\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15'],k = 15) == \"1\"\n assert candidate(nums = ['123456789', '987654321', '111111111', '222222222', '333333333'],k = 4) == \"123456789\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415'],k = 1) == \"131415\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415', '161718', '192021', '222324', '252627', '282930'],k = 4) == \"192021\"\n assert candidate(nums = ['5', '10', '15', '20', '25', '30', '35', '40'],k = 7) == \"10\"\n assert candidate(nums = ['1000000000', '999999999', '1000000000', '999999999', '1000000000', '999999999', '1000000000', '999999999', '1000000000', '999999999'],k = 8) == \"999999999\"\n assert candidate(nums = ['999999999999999999', '1000000000000000000', '999999999999999998'],k = 1) == \"1000000000000000000\"\n assert candidate(nums = ['100', '1000', '10', '1'],k = 2) == \"100\"\n assert candidate(nums = ['100', '200', '300', '400', '500', '600', '700', '800', '900'],k = 7) == \"300\"\n assert candidate(nums = ['1234567890', '1234567891', '1234567892', '1234567893', '1234567894', '1234567895', '1234567896', '1234567897', '1234567898', '1234567899'],k = 9) == \"1234567891\"\n assert candidate(nums = ['987654321', '98765432', '9876543', '987654', '98765', '9876', '987', '98', '9'],k = 8) == \"98\"\n assert candidate(nums = ['99999', '88888', '77777', '66666', '55555', '44444', '33333', '22222', '11111'],k = 9) == \"11111\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000'],k = 3) == \"100\"\n assert candidate(nums = ['10000', '10001', '10002', '10003', '10004', '10005', '10006', '10007', '10008', '10009'],k = 8) == \"10002\"\n assert candidate(nums = ['123456789', '987654321', '111111111', '222222222', '333333333'],k = 2) == \"333333333\"\n assert candidate(nums = ['999999999999999999', '999999999999999998', '1000000000000000000'],k = 2) == \"999999999999999999\"\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999', '111', '222', '333', '444', '555', '666', '777', '888', '999', '111', '222'],k = 15) == \"222\"\n assert candidate(nums = ['999999999999999999', '1000000000000000000', '999999999999999998'],k = 2) == \"999999999999999999\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 10) == \"1\"\n assert candidate(nums = ['100', '200', '300', '400', '500', '600', '700', '800', '900', '1000'],k = 7) == \"400\"\n assert candidate(nums = ['999', '998', '997', '996', '995', '994', '993', '992', '991', '990'],k = 10) == \"990\"\n assert candidate(nums = ['1', '11', '111', '1111', '11111', '111111', '1111111', '11111111', '111111111', '1111111111'],k = 3) == \"11111111\"\n assert candidate(nums = ['9876543210', '102030405060708090', '123456789', '987654321', '1000000000', '999999999', '1111111111', '2222222222', '3333333333', '4444444444'],k = 3) == \"4444444444\"\n assert candidate(nums = ['9', '99', '999', '9999', '99999', '999999', '9999999', '99999999', '999999999', '9999999999'],k = 5) == \"999999\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415', '161718', '192021', '222324', '252627', '282930'],k = 6) == \"131415\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415', '161718'],k = 3) == \"101112\"\n assert candidate(nums = ['1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000'],k = 5) == \"1000\"\n assert candidate(nums = ['1000000', '999999', '888888', '777777', '666666'],k = 2) == \"999999\"\n assert candidate(nums = ['999', '998', '997', '996', '995', '994', '993', '992', '991', '990'],k = 5) == \"995\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 5) == \"100000\"\n assert candidate(nums = ['12345678901234567890', '12345678901234567891', '12345678901234567892'],k = 2) == \"12345678901234567891\"\n assert candidate(nums = ['999', '888', '777', '666', '555', '444', '333', '222', '111', '0'],k = 1) == \"999\"\n", "comparison": "exact"}, "public_tests": ["[\"3\",\"6\",\"7\",\"10\"]\n4", "[\"2\",\"21\",\"12\",\"1\"]\n3", "[\"0\",\"0\"]\n2"], "hints": ["If two numbers have different lengths, which one will be larger?", "The longer number is the larger number.", "If two numbers have the same length, which one will be larger?", "Compare the two numbers starting from the most significant digit. Once you have found the first digit that differs, the one with the larger digit is the larger number."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().kthLargestNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:16+00:00", "tests_total": 113, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "string", "divide-and-conquer", "sorting", "heap-priority-queue", "quickselect"]}, "language": "python", "interface": {"raw_signature": "def kthLargestNumber(self, nums: list[str], k: int) -> str:", "container": "Solution", "callable": "kthLargestNumber", "parameters": [{"name": "nums", "type": "list[str]"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1986, "task_id": "minimum-number-of-work-sessions-to-finish-the-tasks", "difficulty": "Medium", "problem_description": "There are n tasks assigned to you. The task times are represented as an integer array tasks of length n, where the i^th task takes tasks[i] hours to finish. A work session is when you work for at most sessionTime consecutive hours and then take a break.\n\nYou should finish the given tasks in a way that satisfies the following conditions:\n\n- If you start a task in a work session, you must complete it in the same work session.\n- You can start a new task immediately after finishing the previous one.\n- You may complete the tasks in any order.\n\nGiven tasks and sessionTime, return the minimum number of work sessions needed to finish all the tasks following the conditions above.\n\nThe tests are generated such that sessionTime is greater than or equal to the maximum element in tasks[i].\n\nExample 1:\n\nInput: tasks = [1,2,3], sessionTime = 3\nOutput: 2\nExplanation: You can finish the tasks in two work sessions.\n- First work session: finish the first and the second tasks in 1 + 2 = 3 hours.\n- Second work session: finish the third task in 3 hours.\n\nExample 2:\n\nInput: tasks = [3,1,3,1,1], sessionTime = 8\nOutput: 2\nExplanation: You can finish the tasks in two work sessions.\n- First work session: finish all the tasks except the last one in 3 + 1 + 3 + 1 = 8 hours.\n- Second work session: finish the last task in 1 hour.\n\nExample 3:\n\nInput: tasks = [1,2,3,4,5], sessionTime = 15\nOutput: 1\nExplanation: You can finish all the tasks in one work session.\n\nConstraints:\n\n- n == tasks.length\n- 1 <= n <= 14\n- 1 <= tasks[i] <= 10\n- max(tasks[i]) <= sessionTime <= 15\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [1, 3, 2, 4],sessionTime = 5) == 2\n assert candidate(tasks = [5, 7, 4, 2, 6],sessionTime = 10) == 3\n assert candidate(tasks = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],sessionTime = 12) == 5\n assert candidate(tasks = [1, 2, 3],sessionTime = 3) == 2\n assert candidate(tasks = [5, 5, 5, 5],sessionTime = 5) == 4\n assert candidate(tasks = [9, 9, 9, 9],sessionTime = 9) == 4\n assert candidate(tasks = [2, 3, 3, 4, 6],sessionTime = 6) == 3\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 2) == 7\n assert candidate(tasks = [7, 7, 7, 7],sessionTime = 14) == 2\n assert candidate(tasks = [10, 10, 10, 10],sessionTime = 10) == 4\n assert candidate(tasks = [10, 10, 10],sessionTime = 10) == 3\n assert candidate(tasks = [2, 3, 4, 5, 1],sessionTime = 6) == 3\n assert candidate(tasks = [1, 2, 3, 4, 5],sessionTime = 15) == 1\n assert candidate(tasks = [7, 2, 7, 2, 7],sessionTime = 12) == 3\n assert candidate(tasks = [8, 8, 8, 8, 8, 8, 8, 8],sessionTime = 15) == 8\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],sessionTime = 10) == 14\n assert candidate(tasks = [1, 2, 3, 4],sessionTime = 10) == 1\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 15) == 5\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 14) == 1\n assert candidate(tasks = [3, 1, 3, 1, 1],sessionTime = 8) == 2\n assert candidate(tasks = [7, 2, 4, 3, 5],sessionTime = 12) == 2\n assert candidate(tasks = [1, 2, 3, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7],sessionTime = 10) == 6\n assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1],sessionTime = 10) == 6\n assert candidate(tasks = [7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7],sessionTime = 13) == 5\n assert candidate(tasks = [2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5],sessionTime = 12) == 5\n assert candidate(tasks = [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6],sessionTime = 12) == 5\n assert candidate(tasks = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1],sessionTime = 11) == 7\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],sessionTime = 15) == 14\n assert candidate(tasks = [10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 15) == 4\n assert candidate(tasks = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],sessionTime = 14) == 7\n assert candidate(tasks = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2],sessionTime = 8) == 5\n assert candidate(tasks = [3, 6, 7, 9, 10, 1, 2, 4, 5, 8, 2, 3, 4, 6],sessionTime = 10) == 7\n assert candidate(tasks = [7, 8, 7, 8, 7, 8, 7, 8],sessionTime = 15) == 4\n assert candidate(tasks = [7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7],sessionTime = 12) == 5\n assert candidate(tasks = [2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],sessionTime = 14) == 6\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6],sessionTime = 10) == 6\n assert candidate(tasks = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5],sessionTime = 10) == 4\n assert candidate(tasks = [8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 15) == 4\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 15) == 5\n assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7],sessionTime = 15) == 6\n assert candidate(tasks = [3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1],sessionTime = 7) == 5\n assert candidate(tasks = [10, 10, 10, 10, 1, 2, 3, 4],sessionTime = 15) == 4\n assert candidate(tasks = [9, 1, 4, 8, 3, 2, 5, 6, 7, 10, 1, 2, 3, 4],sessionTime = 10) == 7\n assert candidate(tasks = [7, 7, 7, 7, 7, 7, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 14) == 4\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 5) == 14\n assert candidate(tasks = [10, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 10, 1, 2],sessionTime = 10) == 8\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 10) == 4\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],sessionTime = 30) == 5\n assert candidate(tasks = [7, 3, 4, 5, 6, 2, 8, 9, 10, 1, 2, 3, 4, 5],sessionTime = 10) == 7\n assert candidate(tasks = [10, 10, 10, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4],sessionTime = 14) == 4\n assert candidate(tasks = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5],sessionTime = 10) == 5\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],sessionTime = 14) == 4\n assert candidate(tasks = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],sessionTime = 9) == 5\n assert candidate(tasks = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],sessionTime = 12) == 6\n assert candidate(tasks = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],sessionTime = 9) == 5\n assert candidate(tasks = [2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7],sessionTime = 12) == 6\n assert candidate(tasks = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],sessionTime = 10) == 5\n assert candidate(tasks = [1, 2, 3, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2],sessionTime = 8) == 5\n assert candidate(tasks = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],sessionTime = 10) == 14\n assert candidate(tasks = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5],sessionTime = 9) == 5\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 10) == 7\n assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4],sessionTime = 20) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4],sessionTime = 10) == 4\n assert candidate(tasks = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],sessionTime = 16) == 7\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1],sessionTime = 10) == 14\n assert candidate(tasks = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],sessionTime = 13) == 5\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 10) == 7\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2],sessionTime = 6) == 4\n assert candidate(tasks = [10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 10) == 5\n assert candidate(tasks = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],sessionTime = 4) == 7\n assert candidate(tasks = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],sessionTime = 6) == 6\n assert candidate(tasks = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],sessionTime = 10) == 6\n assert candidate(tasks = [9, 6, 3, 2, 1, 9, 6, 3, 2, 1, 9, 6, 3, 2],sessionTime = 10) == 7\n assert candidate(tasks = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],sessionTime = 13) == 3\n assert candidate(tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2],sessionTime = 10) == 5\n assert candidate(tasks = [10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 15) == 6\n assert candidate(tasks = [10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 10) == 5\n assert candidate(tasks = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4],sessionTime = 8) == 4\n assert candidate(tasks = [1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7],sessionTime = 12) == 6\n assert candidate(tasks = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],sessionTime = 4) == 6\n assert candidate(tasks = [3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1],sessionTime = 9) == 4\n assert candidate(tasks = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],sessionTime = 15) == 5\n assert candidate(tasks = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],sessionTime = 12) == 7\n assert candidate(tasks = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5],sessionTime = 6) == 7\n assert candidate(tasks = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],sessionTime = 8) == 4\n assert candidate(tasks = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1],sessionTime = 8) == 14\n assert candidate(tasks = [3, 2, 3, 2, 3, 2, 3, 2],sessionTime = 5) == 4\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],sessionTime = 10) == 6\n assert candidate(tasks = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],sessionTime = 14) == 5\n assert candidate(tasks = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2],sessionTime = 5) == 6\n assert candidate(tasks = [2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5],sessionTime = 10) == 5\n assert candidate(tasks = [7, 7, 7, 7, 6, 6, 6, 5, 5, 4, 4, 3, 3, 2],sessionTime = 15) == 5\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],sessionTime = 8) == 7\n assert candidate(tasks = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7],sessionTime = 14) == 5\n assert candidate(tasks = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],sessionTime = 12) == 6\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 20) == 4\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],sessionTime = 20) == 7\n", "comparison": "exact"}, "public_tests": ["[1,2,3]\n3", "[3,1,3,1,1]\n8", "[1,2,3,4,5]\n15"], "hints": ["Try all possible ways of assignment.", "If we can store the assignments in form of a state then we can reuse that state and solve the problem in a faster way."], "metadata": {"canonical_parameter_names": ["tasks", "sessionTime"], "leetcode_dataset_entry_point": "Solution().minSessions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:19+00:00", "tests_total": 123, "tests_dropped": 26, "flags": [], "topic_tags": ["array", "dynamic-programming", "backtracking", "bit-manipulation", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def minSessions(self, tasks: list[int], sessionTime: int) -> int:", "container": "Solution", "callable": "minSessions", "parameters": [{"name": "tasks", "type": "list[int]"}, {"name": "sessionTime", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1987, "task_id": "number-of-unique-good-subsequences", "difficulty": "Hard", "problem_description": "You are given a binary string binary. A subsequence of binary is considered good if it is not empty and has no leading zeros (with the exception of \"0\").\n\nFind the number of unique good subsequences of binary.\n\n- For example, if binary = \"001\", then all the good subsequences are [\"0\", \"0\", \"1\"], so the unique good subsequences are \"0\" and \"1\". Note that subsequences \"00\", \"01\", and \"001\" are not good because they have leading zeros.\n\nReturn the number of unique good subsequences of binary. Since the answer may be very large, return it modulo 10^9 + 7.\n\nA subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.\n\nExample 1:\n\nInput: binary = \"001\"\nOutput: 2\nExplanation: The good subsequences of binary are [\"0\", \"0\", \"1\"].\nThe unique good subsequences are \"0\" and \"1\".\n\nExample 2:\n\nInput: binary = \"11\"\nOutput: 2\nExplanation: The good subsequences of binary are [\"1\", \"1\", \"11\"].\nThe unique good subsequences are \"1\" and \"11\".\n\nExample 3:\n\nInput: binary = \"101\"\nOutput: 5\nExplanation: The good subsequences of binary are [\"1\", \"0\", \"1\", \"10\", \"11\", \"101\"].\nThe unique good subsequences are \"0\", \"1\", \"10\", \"11\", and \"101\".\n\nConstraints:\n\n- 1 <= binary.length <= 10^5\n- binary consists of only '0's and '1's.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(binary = \"101\") == 5\n assert candidate(binary = \"1111\") == 4\n assert candidate(binary = \"1\") == 1\n assert candidate(binary = \"010101\") == 13\n assert candidate(binary = \"111000111\") == 43\n assert candidate(binary = \"10000100001\") == 64\n assert candidate(binary = \"1001001\") == 26\n assert candidate(binary = \"1010101010\") == 144\n assert candidate(binary = \"00000\") == 1\n assert candidate(binary = \"000000\") == 1\n assert candidate(binary = \"0000000000\") == 1\n assert candidate(binary = \"000\") == 1\n assert candidate(binary = \"001\") == 2\n assert candidate(binary = \"11\") == 2\n assert candidate(binary = \"0101010101\") == 89\n assert candidate(binary = \"1100110011\") == 99\n assert candidate(binary = \"0101010\") == 21\n assert candidate(binary = \"0\") == 1\n assert candidate(binary = \"111111\") == 6\n assert candidate(binary = \"100101010\") == 76\n assert candidate(binary = \"1000000000000000000000000000000000000000000000000000000000000001\") == 127\n assert candidate(binary = \"1101\") == 8\n assert candidate(binary = \"1001010\") == 29\n assert candidate(binary = \"01010101\") == 34\n assert candidate(binary = \"11010\") == 13\n assert candidate(binary = \"11111\") == 5\n assert candidate(binary = \"1111111111\") == 10\n assert candidate(binary = \"00000000000000000000000000000000000000000001\") == 2\n assert candidate(binary = \"11011011011011011011\") == 7953\n assert candidate(binary = \"10000000000000000001\") == 39\n assert candidate(binary = \"010101010101010101010101\") == 75025\n assert candidate(binary = \"11111111111111111111111111111111111111111110\") == 87\n assert candidate(binary = \"100000000000000000000000\") == 25\n assert candidate(binary = \"101010101010101010101010101010101010101010101010101\") == 316290802\n assert candidate(binary = \"10101010101010101010\") == 17711\n assert candidate(binary = \"010101010101010101010101010101010101010101010101010\") == 951279875\n assert candidate(binary = \"0000000011111111\") == 9\n assert candidate(binary = \"11110000111100001111000011110000\") == 121393\n assert candidate(binary = \"110110110110\") == 265\n assert candidate(binary = \"11111000001111100000\") == 836\n assert candidate(binary = \"1010101010101\") == 610\n assert candidate(binary = \"111000111000\") == 142\n assert candidate(binary = \"1001001001001001001001001001001001\") == 3650401\n assert candidate(binary = \"0101010101010101010101010101\") == 514229\n assert candidate(binary = \"010101010101\") == 233\n assert candidate(binary = \"1010101010101010101010101010101010101010\") == 267914296\n assert candidate(binary = \"0101010101010101\") == 1597\n assert candidate(binary = \"1111111111111111111111111111111111111111\") == 40\n assert candidate(binary = \"11001100110011001100\") == 8119\n assert candidate(binary = \"000000000001\") == 2\n assert candidate(binary = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110\") == 199\n assert candidate(binary = \"01010101010101010101010101010101010101010101010\") == 807526948\n assert candidate(binary = \"10101010101010101010101\") == 75025\n assert candidate(binary = \"1001001001\") == 97\n assert candidate(binary = \"11001010010111\") == 545\n assert candidate(binary = \"000111111111111111111111111111111111111111111111111\") == 49\n assert candidate(binary = \"111111111111111111111111\") == 24\n assert candidate(binary = \"11111111111111111111111111111111111111111111\") == 44\n assert candidate(binary = \"1001001001001001001001001001001001001001001001001001001001\") == 379190178\n assert candidate(binary = \"000000000000000000000000000000000000000000000000001\") == 2\n assert candidate(binary = \"0101010101010101010101010101010101010101\") == 165580141\n assert candidate(binary = \"110110110110110110\") == 3691\n assert candidate(binary = \"1111000011110000\") == 377\n assert candidate(binary = \"000000000000\") == 1\n assert candidate(binary = \"1111100000011111\") == 191\n assert candidate(binary = \"1111111111111111111111111111\") == 28\n assert candidate(binary = \"111000111000111000111000111000111000111000111000111000111\") == 619446900\n assert candidate(binary = \"110101010101\") == 377\n assert candidate(binary = \"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\") == 2\n assert candidate(binary = \"1001001001001001\") == 1351\n assert candidate(binary = \"1100110011001100\") == 1393\n assert candidate(binary = \"00000000000000000000000000000000\") == 1\n assert candidate(binary = \"01010101010101010101010101010101010101010101\") == 134903163\n assert candidate(binary = \"1010101010101010101010101010101010101010101010101011\") == 681301736\n assert candidate(binary = \"10111001001010011001\") == 8492\n assert candidate(binary = \"11111111111111111110\") == 39\n assert candidate(binary = \"111000111000111000111000111000111000111000111000\") == 239244622\n assert candidate(binary = \"101010101010\") == 377\n assert candidate(binary = \"000000000011111111110000000000\") == 111\n assert candidate(binary = \"00000000000000000000\") == 1\n assert candidate(binary = \"1111100000111110000011111\") == 4341\n assert candidate(binary = \"100100100100100100100100100100100100100100100100100\") == 694626305\n assert candidate(binary = \"000111000111000\") == 142\n assert candidate(binary = \"001100110011\") == 99\n assert candidate(binary = \"11000110001100011000\") == 4401\n assert candidate(binary = \"1000000000000000001\") == 37\n assert candidate(binary = \"111100001111000011110000111100001111000011110000111\") == 133957148\n assert candidate(binary = \"10010101010101010101\") == 15127\n assert candidate(binary = \"01010101010101010101\") == 10946\n assert candidate(binary = \"0001111111000\") == 29\n", "comparison": "exact"}, "public_tests": ["\"001\"", "\"11\"", "\"101\""], "hints": ["The number of unique good subsequences is equal to the number of unique decimal values there are for all possible subsequences.", "Find the answer at each index based on the previous indexes' answers."], "metadata": {"canonical_parameter_names": ["binary"], "leetcode_dataset_entry_point": "Solution().numberOfUniqueGoodSubsequences", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:21+00:00", "tests_total": 90, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def numberOfUniqueGoodSubsequences(self, binary: str) -> int:", "container": "Solution", "callable": "numberOfUniqueGoodSubsequences", "parameters": [{"name": "binary", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1991, "task_id": "find-the-middle-index-in-array", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums, find the leftmost middleIndex (i.e., the smallest amongst all the possible ones).\n\nA middleIndex is an index where nums[0] + nums[1] + ... + nums[middleIndex-1] == nums[middleIndex+1] + nums[middleIndex+2] + ... + nums[nums.length-1].\n\nIf middleIndex == 0, the left side sum is considered to be 0. Similarly, if middleIndex == nums.length - 1, the right side sum is considered to be 0.\n\nReturn the leftmost middleIndex that satisfies the condition, or -1 if there is no such index.\n\nExample 1:\n\nInput: nums = [2,3,-1,8,4]\nOutput: 3\nExplanation: The sum of the numbers before index 3 is: 2 + 3 + -1 = 4\nThe sum of the numbers after index 3 is: 4 = 4\n\nExample 2:\n\nInput: nums = [1,-1,4]\nOutput: 2\nExplanation: The sum of the numbers before index 2 is: 1 + -1 = 0\nThe sum of the numbers after index 2 is: 0\n\nExample 3:\n\nInput: nums = [2,5]\nOutput: -1\nExplanation: There is no valid middleIndex.\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- -1000 <= nums[i] <= 1000\n\nNote: This question is the same as 724: https://leetcode.com/problems/find-pivot-index/\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, -1, 4]) == 2\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1, 100]) == -1\n assert candidate(nums = [0, 1]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5]) == -1\n assert candidate(nums = [2, 5]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums = [1, 0]) == 0\n assert candidate(nums = [2, 3, -1, 8, 4]) == 3\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == -1\n assert candidate(nums = [-1, -1, -1, -1]) == -1\n assert candidate(nums = [1, 7, 3, 6, 5, 6]) == 3\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [1000, -1000, 1000, -1000]) == -1\n assert candidate(nums = [1, 1]) == -1\n assert candidate(nums = [1, 2, 3]) == -1\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000]) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [1000, -500, 250, 250, -1000, 500, 500, 0, 0, 0]) == 0\n assert candidate(nums = [100, 0, -100, 0, 100, 0, -100]) == 3\n assert candidate(nums = [100, -50, 25, 25, -100, 50, 50]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [0, 1, 0, -1, 0, 1, 0, -1, 0]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == -1\n assert candidate(nums = [7, 1, 5, 2, -4, 3, 0, 1, -2, 3]) == -1\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == -1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == 0\n assert candidate(nums = [5, -10, 10, 5, 0]) == -1\n assert candidate(nums = [-5, 5, -5, 5, -5, 5]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == -1\n assert candidate(nums = [3, -2, 1, 6, -4, 2, 5]) == -1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40]) == 6\n assert candidate(nums = [100, 200, -300, 400, -500, 600, -700, 800]) == -1\n assert candidate(nums = [7, 1, 5, 2, -4, 3, 0]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == -1\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == -1\n assert candidate(nums = [1000, -1000, 0, 1000, -1000]) == 2\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -1\n assert candidate(nums = [-1000, 500, -250, 125, -62, 31, -15, 7, -3, 1]) == -1\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5]) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == -1\n assert candidate(nums = [-1, -2, -3, -4, -5, 15]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == 9\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [1, -2, 3, 4, -3, 2]) == -1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, -210]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [10, -10, 0, 5, -5, 5, -5]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == -1\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000]) == -1\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40]) == -1\n assert candidate(nums = [0, 1, 0, -1, 0, 1, 0, -1]) == 0\n assert candidate(nums = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == -1\n assert candidate(nums = [1000, -1000, 500, -500, 250, -250, 125, -125]) == -1\n assert candidate(nums = [0, 1, 2, 3, 4, 3, 2, 1, 0]) == 4\n assert candidate(nums = [1, -1, 0, 1, -1]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(nums = [10, 20, 30, 10, 10, 30]) == -1\n assert candidate(nums = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1, 0]) == -1\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000]) == -1\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6, 3, -3, 1, -1]) == -1\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == -1\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == -1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 9\n assert candidate(nums = [1000, -1000, 500, -500, 250, -250]) == -1\n assert candidate(nums = [1000, -1000, 500, -500, 0, 0]) == 4\n assert candidate(nums = [7, 1, 5, 2, -4, 3, 0, 0, 0, 0]) == -1\n assert candidate(nums = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1, 1]) == -1\n assert candidate(nums = [-10, 10, -20, 20, -30, 30]) == -1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 0]) == 20\n", "comparison": "exact"}, "public_tests": ["[2,3,-1,8,4]", "[1,-1,4]", "[2,5]"], "hints": ["Could we go from left to right and check to see if an index is a middle index?", "Do we need to sum every number to the left and right of an index each time?", "Use a prefix sum array where prefix[i] = nums[0] + nums[1] + ... + nums[i]."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findMiddleIndex", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:25+00:00", "tests_total": 94, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def findMiddleIndex(self, nums: list[int]) -> int:", "container": "Solution", "callable": "findMiddleIndex", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1992, "task_id": "find-all-groups-of-farmland", "difficulty": "Medium", "problem_description": "You are given a 0-indexed m x n binary matrix land where a 0 represents a hectare of forested land and a 1 represents a hectare of farmland.\n\nTo keep the land organized, there are designated rectangular areas of hectares that consist entirely of farmland. These rectangular areas are called groups. No two groups are adjacent, meaning farmland in one group is not four-directionally adjacent to another farmland in a different group.\n\nland can be represented by a coordinate system where the top left corner of land is (0, 0) and the bottom right corner of land is (m-1, n-1). Find the coordinates of the top left and bottom right corner of each group of farmland. A group of farmland with a top left corner at (r_1, c_1) and a bottom right corner at (r_2, c_2) is represented by the 4-length array [r_1, c_1, r_2, c_2].\n\nReturn a 2D array containing the 4-length arrays described above for each group of farmland in land. If there are no groups of farmland, return an empty array. You may return the answer in any order.\n\nExample 1:\n\nInput: land = [[1,0,0],[0,1,1],[0,1,1]]\nOutput: [[0,0,0,0],[1,1,2,2]]\nExplanation:\nThe first group has a top left corner at land[0][0] and a bottom right corner at land[0][0].\nThe second group has a top left corner at land[1][1] and a bottom right corner at land[2][2].\n\nExample 2:\n\nInput: land = [[1,1],[1,1]]\nOutput: [[0,0,1,1]]\nExplanation:\nThe first group has a top left corner at land[0][0] and a bottom right corner at land[1][1].\n\nExample 3:\n\nInput: land = [[0]]\nOutput: []\nExplanation:\nThere are no groups of farmland.\n\nConstraints:\n\n- m == land.length\n- n == land[i].length\n- 1 <= m, n <= 300\n- land consists of only 0's and 1's.\n- Groups of farmland are rectangular in shape.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(land=[[0]]), [])\n assert answers_match(candidate(land=[[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]]), [[0, 0, 0, 1], [1, 2, 1, 3], [2, 0, 2, 1], [3, 2, 3, 3]])\n assert answers_match(candidate(land=[[1, 0, 1], [0, 0, 0], [1, 1, 1]]), [[0, 0, 0, 0], [0, 2, 0, 2], [2, 0, 2, 2]])\n assert answers_match(candidate(land=[[1, 0, 1], [0, 0, 0], [1, 1, 0]]), [[0, 0, 0, 0], [0, 2, 0, 2], [2, 0, 2, 1]])\n assert answers_match(candidate(land=[[0, 0, 0], [0, 0, 0], [0, 0, 0]]), [])\n assert answers_match(candidate(land=[[1, 1, 1], [1, 0, 1], [1, 1, 1]]), [[0, 0, 2, 2]])\n assert answers_match(candidate(land=[[1, 0, 1], [0, 1, 0], [1, 0, 1]]), [[0, 0, 0, 0], [0, 2, 0, 2], [1, 1, 1, 1], [2, 0, 2, 0], [2, 2, 2, 2]])\n assert answers_match(candidate(land=[[1, 1], [1, 1]]), [[0, 0, 1, 1]])\n assert answers_match(candidate(land=[[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]]), [[0, 0, 1, 1], [2, 2, 3, 3]])\n assert answers_match(candidate(land=[[1, 0, 0, 0], [0, 1, 1, 1], [0, 1, 1, 1], [0, 0, 0, 0]]), [[0, 0, 0, 0], [1, 1, 2, 3]])\n assert answers_match(candidate(land=[[1, 0, 0], [0, 1, 1], [0, 1, 1]]), [[0, 0, 0, 0], [1, 1, 2, 2]])\n assert answers_match(candidate(land=[[0, 1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1, 1, 0], [1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1]]), [[0, 1, 1, 2], [0, 5, 1, 6], [3, 0, 4, 2], [3, 4, 4, 6], [6, 0, 7, 1], [6, 6, 7, 7]])\n assert answers_match(candidate(land=[[1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1]]), [[0, 0, 1, 1], [2, 2, 3, 4], [4, 5, 5, 5]])\n assert answers_match(candidate(land=[[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]), [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [0, 6, 0, 6], [1, 1, 1, 1], [1, 3, 1, 3], [1, 5, 1, 5], [1, 7, 1, 7], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [2, 6, 2, 6], [3, 1, 3, 1], [3, 3, 3, 3], [3, 5, 3, 5], [3, 7, 3, 7], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4], [4, 6, 4, 6]])\n assert answers_match(candidate(land=[[1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1]]), [[0, 0, 1, 3]])\n assert answers_match(candidate(land=[[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]), [[0, 0, 1, 5], [3, 0, 4, 5]])\n assert answers_match(candidate(land=[[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]), [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [1, 1, 1, 1], [1, 3, 1, 3], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [3, 1, 3, 1], [3, 3, 3, 3], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4]])\n assert answers_match(candidate(land=[[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]]), [[1, 1, 3, 3]])\n assert answers_match(candidate(land=[[1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 1, 1]]), [[0, 0, 0, 2], [0, 6, 0, 8], [2, 0, 2, 2], [2, 4, 2, 6], [3, 7, 4, 8], [4, 0, 4, 4]])\n assert answers_match(candidate(land=[[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]), [[0, 0, 5, 5], [2, 2, 3, 3]])\n assert answers_match(candidate(land=[[1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1]]), [[0, 0, 1, 1], [0, 3, 1, 4], [0, 6, 1, 7], [0, 9, 1, 9], [3, 0, 4, 1], [3, 3, 4, 4], [3, 6, 4, 7], [3, 9, 4, 9], [6, 0, 7, 1], [6, 3, 7, 4], [6, 6, 7, 7], [6, 9, 7, 9]])\n assert answers_match(candidate(land=[[1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0]]), [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [0, 6, 0, 6], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [2, 6, 2, 6], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4], [4, 6, 4, 6]])\n assert answers_match(candidate(land=[[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 1, 1], [1, 0, 0, 0]]), [[0, 0, 3, 0], [2, 2, 2, 3]])\n assert answers_match(candidate(land=[[1, 0, 0, 0, 0, 1], [1, 1, 0, 0, 1, 1], [0, 1, 0, 0, 1, 0], [1, 1, 0, 0, 1, 1], [0, 1, 0, 0, 1, 0]]), [[0, 0, 1, 1], [0, 5, 1, 5], [1, 4, 4, 4], [3, 0, 3, 1]])\n assert answers_match(candidate(land=[[1, 0, 0, 0, 1, 0, 1, 1, 0, 0], [0, 1, 1, 0, 1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1]]), [[0, 0, 0, 0], [0, 4, 3, 7], [0, 6, 1, 7], [1, 1, 1, 2], [2, 9, 3, 9], [3, 1, 3, 1], [5, 2, 5, 4], [5, 8, 5, 9]])\n assert answers_match(candidate(land=[[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1]]), [[0, 0, 2, 2], [0, 6, 2, 8], [4, 0, 6, 2], [4, 6, 6, 8]])\n assert answers_match(candidate(land=[[1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0], [0, 1, 0, 1, 1, 0], [0, 0, 1, 0, 0, 1]]), [[0, 0, 0, 2], [1, 3, 2, 4], [2, 1, 2, 1], [3, 2, 3, 2], [3, 5, 3, 5]])\n assert answers_match(candidate(land=[[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]), [[0, 0, 2, 7], [4, 0, 6, 7]])\n assert answers_match(candidate(land=[[1, 0, 0, 0, 1, 0], [0, 1, 1, 0, 0, 1], [0, 1, 1, 0, 0, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]]), [[0, 0, 0, 0], [0, 4, 0, 4], [1, 1, 2, 2], [1, 5, 4, 5], [3, 3, 4, 5]])\n assert answers_match(candidate(land=[[1, 0, 0, 1, 0], [1, 1, 0, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 0, 1], [0, 1, 1, 0, 1]]), [[0, 0, 1, 1], [0, 3, 1, 3], [3, 0, 3, 2], [3, 4, 4, 4]])\n assert answers_match(candidate(land=[[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]), [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [0, 6, 0, 6], [1, 1, 1, 1], [1, 3, 1, 3], [1, 5, 1, 5], [1, 7, 1, 7], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [2, 6, 2, 6], [3, 1, 3, 1], [3, 3, 3, 3], [3, 5, 3, 5], [3, 7, 3, 7], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4], [4, 6, 4, 6], [5, 1, 5, 1], [5, 3, 5, 3], [5, 5, 5, 5], [5, 7, 5, 7]])\n assert answers_match(candidate(land=[[1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1]]), [[0, 0, 1, 3], [2, 4, 3, 5]])\n assert answers_match(candidate(land=[[0, 1, 1, 0, 0, 0], [1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [0, 0, 1, 1, 0, 0]]), [[0, 1, 1, 1], [1, 0, 2, 0], [1, 4, 2, 4], [2, 3, 2, 4], [3, 1, 3, 2], [3, 5, 3, 5]])\n assert answers_match(candidate(land=[[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]), [[1, 1, 3, 3]])\n assert answers_match(candidate(land=[[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 0, 1], [1, 0, 0, 1]]), [[1, 1, 2, 2], [4, 0, 4, 3], [6, 0, 7, 0], [6, 3, 7, 3]])\n assert answers_match(candidate(land=[[1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]), [[0, 0, 1, 1], [1, 4, 2, 5], [3, 2, 3, 3]])\n assert answers_match(candidate(land=[[1, 1, 1, 1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 0, 0, 1, 1, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1, 0, 1], [0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]), [[0, 0, 1, 3], [0, 9, 3, 9], [1, 6, 3, 7], [2, 4, 3, 7], [4, 2, 4, 3]])\n assert answers_match(candidate(land=[[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1], [0, 0, 1, 0, 0]]), [[0, 0, 0, 0], [0, 2, 1, 3], [0, 4, 0, 4], [1, 1, 2, 1], [2, 0, 2, 1], [3, 2, 3, 2]])\n assert answers_match(candidate(land=[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]), [[1, 1, 3, 4], [1, 8, 4, 9], [3, 6, 4, 9], [3, 11, 4, 12]])\n assert answers_match(candidate(land=[[1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1]]), [[0, 0, 1, 3], [2, 4, 4, 6], [4, 2, 4, 6]])\n assert answers_match(candidate(land=[[1, 1, 1, 0, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]]), [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 7, 7]])\n assert answers_match(candidate(land=[[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 1, 1]]), [[1, 1, 3, 5], [5, 3, 7, 7]])\n assert answers_match(candidate(land=[[1, 1, 0, 1, 1], [1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [1, 1, 0, 1, 1], [1, 1, 0, 1, 1]]), [[0, 0, 1, 1], [0, 3, 1, 4], [3, 0, 4, 1], [3, 3, 4, 4]])\n assert answers_match(candidate(land=[[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 0, 0, 0]]), [[1, 1, 2, 2], [1, 4, 2, 5], [3, 6, 4, 7], [5, 3, 5, 4]])\n assert answers_match(candidate(land=[[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]), [[1, 1, 4, 4]])\n assert answers_match(candidate(land=[[1, 1, 0, 0, 1], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [1, 0, 0, 0, 1]]), [[0, 0, 1, 1], [0, 4, 1, 4], [2, 2, 3, 3], [4, 0, 4, 0], [4, 4, 4, 4]])\n assert answers_match(candidate(land=[[1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 1, 1, 0], [0, 0, 0, 1, 0, 0, 1], [1, 1, 1, 0, 0, 1, 0]]), [[0, 0, 0, 3], [1, 4, 2, 5], [2, 0, 2, 2], [3, 3, 3, 3], [3, 6, 3, 6], [4, 0, 4, 2], [4, 5, 4, 5]])\n assert answers_match(candidate(land=[[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]), [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [0, 6, 0, 6], [1, 1, 1, 1], [1, 3, 1, 3], [1, 5, 1, 5], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [2, 6, 2, 6], [3, 1, 3, 1], [3, 3, 3, 3], [3, 5, 3, 5], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4], [4, 6, 4, 6]])\n assert answers_match(candidate(land=[[0, 0, 0, 0, 0], [0, 1, 1, 0, 0], [0, 1, 1, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 0], [0, 0, 0, 1, 1]]), [[1, 1, 2, 2], [4, 0, 4, 3]])\n assert answers_match(candidate(land=[[1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1, 1]]), [[0, 0, 1, 2], [0, 6, 1, 7], [2, 4, 3, 5], [4, 0, 4, 1], [4, 6, 4, 7]])\n assert answers_match(candidate(land=[[1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0]]), [[0, 0, 1, 2], [2, 3, 3, 5], [4, 0, 5, 0], [4, 2, 5, 2]])\n assert answers_match(candidate(land=[[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1]]), [[0, 0, 1, 1], [0, 5, 1, 6], [2, 2, 3, 4], [4, 0, 5, 1], [4, 5, 5, 6]])\n assert answers_match(candidate(land=[[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0], [1, 0, 0, 1, 1], [0, 0, 0, 1, 1]]), [[0, 0, 0, 0], [0, 4, 0, 4], [1, 1, 1, 3], [3, 0, 3, 0], [3, 3, 4, 4]])\n assert answers_match(candidate(land=[[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]), [[0, 0, 4, 0]])\n assert answers_match(candidate(land=[[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1]]), [[0, 0, 0, 0], [0, 3, 0, 3], [1, 1, 2, 2], [1, 4, 2, 4], [3, 0, 3, 0], [3, 3, 3, 3], [4, 1, 4, 2], [4, 4, 4, 4]])\n assert answers_match(candidate(land=[[1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0]]), [[0, 0, 1, 3], [2, 4, 3, 7], [5, 0, 5, 3]])\n assert answers_match(candidate(land=[[1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 1, 1], [0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0]]), [[0, 0, 1, 2], [1, 4, 2, 5], [3, 0, 4, 1]])\n assert answers_match(candidate(land=[[1, 1, 0, 0, 0], [1, 1, 0, 1, 1], [0, 0, 0, 1, 1], [1, 1, 0, 0, 0], [1, 1, 0, 0, 0]]), [[0, 0, 1, 1], [1, 3, 2, 4], [3, 0, 4, 1]])\n assert answers_match(candidate(land=[[1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]]), [[0, 0, 1, 1], [1, 4, 2, 5], [3, 0, 3, 3]])\n assert answers_match(candidate(land=[[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]), [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [1, 1, 1, 1], [1, 3, 1, 3], [1, 5, 1, 5], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [3, 1, 3, 1], [3, 3, 3, 3], [3, 5, 3, 5], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4]])\n assert answers_match(candidate(land=[[1, 0, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0]]), [[0, 0, 0, 0], [0, 4, 0, 5], [1, 1, 2, 3], [3, 0, 3, 0], [3, 4, 3, 5], [4, 1, 4, 3]])\n assert answers_match(candidate(land=[[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0]]), [[0, 0, 2, 2], [0, 6, 0, 8], [1, 4, 1, 4], [2, 6, 2, 8], [3, 3, 5, 5], [4, 1, 4, 7]])\n assert answers_match(candidate(land=[[0, 1, 1, 0, 0, 1], [0, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 1]]), [[0, 1, 0, 2], [0, 5, 0, 5], [1, 4, 2, 5], [2, 0, 2, 2], [4, 0, 4, 1], [4, 3, 4, 5]])\n assert answers_match(candidate(land=[[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]), [[1, 1, 2, 2]])\n assert answers_match(candidate(land=[[1, 1, 1, 1, 0, 0], [1, 0, 0, 1, 1, 0], [1, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 1]]), [[0, 0, 2, 0]])\n assert answers_match(candidate(land=[[0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1]]), [[0, 1, 4, 1], [0, 3, 4, 3], [0, 5, 4, 5], [1, 0, 1, 5], [3, 0, 3, 5]])\n assert answers_match(candidate(land=[[1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1]]), [[0, 0, 0, 0], [0, 4, 0, 5], [2, 0, 2, 1], [2, 4, 2, 5], [4, 0, 4, 1], [4, 4, 4, 5]])\n assert answers_match(candidate(land=[[1, 0, 0, 0, 0, 1], [0, 1, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1]]), [[0, 0, 0, 0], [0, 5, 0, 5], [1, 1, 2, 2], [1, 4, 2, 4], [3, 3, 3, 3], [3, 5, 3, 5]])\n assert answers_match(candidate(land=[[1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0]]), [[0, 0, 1, 1], [0, 6, 1, 7], [2, 2, 3, 3], [4, 0, 4, 1], [4, 4, 4, 5]])\n assert answers_match(candidate(land=[[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]), [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [1, 1, 1, 1], [1, 3, 1, 3], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [3, 1, 3, 1], [3, 3, 3, 3]])\n assert answers_match(candidate(land=[[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]]), [[0, 0, 0, 1], [0, 4, 0, 5], [0, 8, 0, 9], [1, 6, 1, 7], [2, 0, 2, 1], [2, 4, 2, 5], [2, 8, 2, 9], [3, 6, 3, 7], [4, 0, 4, 1], [4, 4, 4, 5], [4, 8, 4, 9]])\n assert answers_match(candidate(land=[[1, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1]]), [[0, 0, 0, 0], [0, 5, 0, 5], [1, 2, 2, 3], [4, 0, 4, 0], [4, 5, 4, 5]])\n assert answers_match(candidate(land=[[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]), [[0, 1, 0, 1], [0, 3, 0, 3], [0, 5, 0, 5], [0, 7, 0, 7], [0, 9, 0, 9], [1, 0, 1, 0], [1, 2, 1, 2], [1, 4, 1, 4], [1, 6, 1, 6], [1, 8, 1, 8], [2, 1, 2, 1], [2, 3, 2, 3], [2, 5, 2, 5], [2, 7, 2, 7], [2, 9, 2, 9], [3, 0, 3, 0], [3, 2, 3, 2], [3, 4, 3, 4], [3, 6, 3, 6], [3, 8, 3, 8]])\n assert answers_match(candidate(land=[[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]), [[0, 0, 2, 5]])\n", "comparison": "unordered"}, "public_tests": ["[[1,0,0],[0,1,1],[0,1,1]]", "[[1,1],[1,1]]", "[[0]]"], "hints": ["Since every group of farmland is rectangular, the top left corner of each group will have the smallest x-coordinate and y-coordinate of any farmland in the group.", "Similarly, the bottom right corner of each group will have the largest x-coordinate and y-coordinate of any farmland in the group.", "Use DFS to traverse through different groups of farmlands and keep track of the smallest and largest x-coordinate and y-coordinates you have seen in each group."], "metadata": {"canonical_parameter_names": ["land"], "leetcode_dataset_entry_point": "Solution().findFarmland", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:28+00:00", "tests_total": 74, "tests_dropped": 0, "flags": ["any_order", "has_images"], "topic_tags": ["array", "depth-first-search", "breadth-first-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def findFarmland(self, land: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "findFarmland", "parameters": [{"name": "land", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1994, "task_id": "the-number-of-good-subsets", "difficulty": "Hard", "problem_description": "You are given an integer array nums. We call a subset of nums good if its product can be represented as a product of one or more distinct prime numbers.\n\n- For example, if nums = [1, 2, 3, 4]:\n - [2, 3], [1, 2, 3], and [1, 3] are good subsets with products 6 = 2*3, 6 = 2*3, and 3 = 3 respectively.\n - [1, 4] and [4] are not good subsets with products 4 = 2*2 and 4 = 2*2 respectively.\n\nReturn the number of different good subsets in nums modulo 10^9 + 7.\n\nA subset of nums is any array that can be obtained by deleting some (possibly none or all) elements from nums. Two subsets are different if and only if the chosen indices to delete are different.\n\nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: 6\nExplanation: The good subsets are:\n- [1,2]: product is 2, which is the product of distinct prime 2.\n- [1,2,3]: product is 6, which is the product of distinct primes 2 and 3.\n- [1,3]: product is 3, which is the product of distinct prime 3.\n- [2]: product is 2, which is the product of distinct prime 2.\n- [2,3]: product is 6, which is the product of distinct primes 2 and 3.\n- [3]: product is 3, which is the product of distinct prime 3.\n\nExample 2:\n\nInput: nums = [4,2,3,15]\nOutput: 5\nExplanation: The good subsets are:\n- [2]: product is 2, which is the product of distinct prime 2.\n- [2,3]: product is 6, which is the product of distinct primes 2 and 3.\n- [2,15]: product is 30, which is the product of distinct primes 2, 3, and 5.\n- [3]: product is 3, which is the product of distinct prime 3.\n- [15]: product is 15, which is the product of distinct primes 3 and 5.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 30\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 3, 2, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == 59048.0\n assert candidate(nums = [1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 8184.0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10.0\n assert candidate(nums = [1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 142.0\n assert candidate(nums = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 703.0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 20.0\n assert candidate(nums = [30, 26, 28, 12, 14, 22, 2, 4, 18, 20, 16, 8, 10, 24, 6, 5, 15, 3, 25, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29]) == 3327.0\n assert candidate(nums = [1, 2, 3, 4]) == 6.0\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6654.0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20.0\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 20.0\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29]) == 127.0\n assert candidate(nums = [4, 2, 3, 15]) == 5.0\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == 59048.0\n assert candidate(nums = [30, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3326.0\n assert candidate(nums = [30, 28, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 6.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 1023.0\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 30]) == 72.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 59048.0\n assert candidate(nums = [10, 20, 30, 1, 2, 3, 5, 7]) == 42.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30]) == 14.0\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 5, 5, 5, 7, 7, 7, 11, 11, 11, 13, 13, 13, 17, 17, 17, 19, 19, 19, 23, 23, 23, 29, 29, 29]) == 1048575.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 6, 10, 14, 15, 21, 22, 26, 30, 4, 9, 16, 25, 28, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3406848.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 18, 20, 21, 22, 25, 26, 27, 30]) == 14.0\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 20.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 1, 1]) == 13308.0\n assert candidate(nums = [2, 3, 2, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29, 30, 30, 30]) == 65609.0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 43.0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 6654.0\n assert candidate(nums = [4, 6, 10, 14, 15, 21, 22, 26, 27, 30]) == 14.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 72693241.0\n assert candidate(nums = [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]) == 27.0\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 11, 11, 11, 11]) == 3124.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 14.0\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 255.0\n assert candidate(nums = [1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30]) == 4604.0\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 11, 11, 11, 11]) == 4998.0\n assert candidate(nums = [6, 15, 10, 14, 21, 22, 26, 22, 21, 14, 10, 15, 6, 30, 30, 30, 30, 30, 30, 30]) == 40.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 6, 10, 14, 15, 21, 22, 26, 30, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3406848.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 2303.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18]) == 2111.0\n assert candidate(nums = [4, 9, 16, 25, 28, 10, 14, 21, 22, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 16.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 9765624.0\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29, 30, 30, 30, 30, 30]) == 69983.0\n assert candidate(nums = [4, 8, 9, 12, 18, 20, 24, 25, 27, 28, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7]) == 9984.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 30, 30]) == 16.0\n assert candidate(nums = [1, 6, 10, 15, 21, 22, 26, 30]) == 24.0\n assert candidate(nums = [1, 6, 8, 9, 10, 12, 14, 15, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 28.0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 6654.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 3327.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 1548287.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 1047552.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30, 15, 6, 10, 21, 22]) == 5246.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 72693241.0\n assert candidate(nums = [1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 8184.0\n assert candidate(nums = [1, 2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29, 30, 30]) == 126844.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 6, 10, 14, 15, 21, 22, 26, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 8958.0\n assert candidate(nums = [1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 28.0\n assert candidate(nums = [30, 28, 15, 10, 6, 3, 2, 1]) == 18.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 59048.0\n assert candidate(nums = [15, 10, 21, 30, 22, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 32.0\n assert candidate(nums = [30, 28, 26, 22, 21, 14, 10, 15, 6, 4, 8, 9, 12, 18, 20, 24, 25, 27, 1, 1]) == 56.0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1054.0\n assert candidate(nums = [10, 15, 21, 22, 26, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 25.0\n assert candidate(nums = [8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 13.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 30, 30, 30, 30]) == 18.0\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 30.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 30, 30, 1, 1, 1, 1, 1, 1]) == 1024.0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30]) == 691088.0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 14.0\n assert candidate(nums = [30, 15, 6, 10, 21, 22, 26, 27, 28, 3, 5, 7, 11, 13, 17, 19, 23, 29, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2292736.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30, 2, 3, 5, 7, 11, 13, 17, 19, 23]) == 40823.0\n assert candidate(nums = [1, 2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == 118096.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30]) == 2302.0\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3406848.0\n assert candidate(nums = [6, 15, 10, 14, 21, 22, 26, 22, 21, 14, 10, 15, 6, 30, 2, 3, 5, 7, 11, 13]) == 359.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1047552.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30, 30, 30]) == 1407.0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 20.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 6, 10, 14, 15, 21, 22, 26, 30, 1]) == 13308.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 30, 30]) == 16.0\n assert candidate(nums = [1, 1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 16368.0\n assert candidate(nums = [4, 8, 9, 12, 16, 18, 20, 24, 25, 27, 28, 1, 2, 3, 5, 7, 11, 13, 17, 19]) == 510.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == 1048575.0\n assert candidate(nums = [8, 9, 12, 18, 20, 24, 25, 27, 28, 30]) == 1.0\n assert candidate(nums = [1, 1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30]) == 13308.0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 24166.0\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]", "[4,2,3,15]"], "hints": ["Consider only the numbers which have a good prime factorization.", "Use brute force to find all possible good subsets and then calculate its frequency in nums."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numberOfGoodSubsets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:30+00:00", "tests_total": 108, "tests_dropped": 17, "flags": [], "topic_tags": ["array", "hash-table", "math", "dynamic-programming", "bit-manipulation", "counting", "number-theory", "bitmask", "sieve-theory"]}, "language": "python", "interface": {"raw_signature": "def numberOfGoodSubsets(self, nums: list[int]) -> int:", "container": "Solution", "callable": "numberOfGoodSubsets", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1995, "task_id": "count-special-quadruplets", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums, return the number of distinct quadruplets (a, b, c, d) such that:\n\n- nums[a] + nums[b] + nums[c] == nums[d], and\n- a < b < c < d\n\nExample 1:\n\nInput: nums = [1,2,3,6]\nOutput: 1\nExplanation: The only quadruplet that satisfies the requirement is (0, 1, 2, 3) because 1 + 2 + 3 == 6.\n\nExample 2:\n\nInput: nums = [3,3,6,4,5]\nOutput: 0\nExplanation: There are no such quadruplets in [3,3,6,4,5].\n\nExample 3:\n\nInput: nums = [1,1,1,3,5]\nOutput: 4\nExplanation: The 4 quadruplets that satisfy the requirement are:\n- (0, 1, 2, 3): 1 + 1 + 1 == 3\n- (0, 1, 3, 4): 1 + 1 + 3 == 5\n- (0, 2, 3, 4): 1 + 1 + 3 == 5\n- (1, 2, 3, 4): 1 + 1 + 3 == 5\n\nConstraints:\n\n- 4 <= nums.length <= 50\n- 1 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 6]) == 1\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1]) == 0\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 12\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 11\n assert candidate(nums = [3, 3, 6, 4, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [1, 1, 1, 3, 5]) == 4\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36]) == 3\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66]) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 147\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 11\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10]) == 40\n assert candidate(nums = [4, 3, 2, 1, 8, 7, 6, 5, 12, 11, 10, 9, 16, 15, 14, 13, 20, 19, 18, 17]) == 143\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 19]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 12]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15]) == 21\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99]) == 817\n assert candidate(nums = [50, 25, 25, 75, 50, 50, 100, 50, 75, 100]) == 7\n assert candidate(nums = [5, 5, 5, 5, 15, 15, 15, 15, 25, 25, 25, 25, 35, 35, 35, 35]) == 304\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 174\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 60]) == 123\n assert candidate(nums = [1, 2, 3, 6, 3, 6, 9, 12, 15, 18, 21, 24]) == 34\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 927\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 15, 5, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 358\n assert candidate(nums = [5, 5, 5, 5, 5, 15, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 1, 4, 3, 6, 2, 7, 8, 9, 10]) == 10\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 53\n assert candidate(nums = [2, 2, 2, 6, 6, 6, 18, 18, 18]) == 6\n assert candidate(nums = [1, 1, 1, 1, 4, 1, 1, 1, 1, 5]) == 0\n assert candidate(nums = [3, 3, 6, 4, 5, 5, 5, 15, 15, 15, 15, 30, 30, 30, 30]) == 16\n assert candidate(nums = [1, 2, 3, 4, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, 32, 33]) == 19\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 30]) == 21\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20]) == 11\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 244\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 5, 5, 15, 15, 15, 30]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 244\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11]) == 39\n assert candidate(nums = [7, 1, 2, 4, 5, 3, 8, 6, 9, 10]) == 10\n assert candidate(nums = [3, 3, 3, 9, 3, 3, 3, 3, 3, 3, 9, 3]) == 85\n assert candidate(nums = [5, 5, 5, 15, 15, 25, 25]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 147\n assert candidate(nums = [2, 2, 2, 6, 2, 2, 2, 6, 2, 2, 2, 6, 2, 2, 2]) == 105\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 15, 15]) == 420\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 147\n assert candidate(nums = [5, 5, 5, 15, 10, 15, 20]) == 5\n assert candidate(nums = [8, 2, 2, 4, 6, 10, 2, 6, 2, 12, 8, 4]) == 22\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 53\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]) == 0\n assert candidate(nums = [1, 2, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54]) == 119\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 83\n assert candidate(nums = [8, 8, 8, 8, 32, 8, 8, 8, 8, 8, 8, 8]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 5, 1, 8, 3, 9, 4, 6]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 586\n assert candidate(nums = [5, 5, 5, 5, 5, 15, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 1, 2, 3, 3, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 13, 13, 14, 15]) == 218\n assert candidate(nums = [5, 1, 4, 2, 8, 10, 7]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 2972\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15]) == 21\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 147\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 0\n assert candidate(nums = [5, 1, 5, 5, 5, 5, 5, 10]) == 0\n assert candidate(nums = [30, 20, 10, 60, 50, 40, 100, 90, 80, 70]) == 10\n assert candidate(nums = [1, 2, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39]) == 43\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 21]) == 76\n assert candidate(nums = [2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 166\n assert candidate(nums = [5, 15, 10, 10, 10, 10, 25, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 120\n assert candidate(nums = [1, 2, 3, 6, 7, 8, 11, 12, 15, 16, 19, 20, 23, 24, 27, 28]) == 61\n assert candidate(nums = [9, 5, 3, 7, 2, 8, 10, 6, 4, 12, 1, 11]) == 9\n assert candidate(nums = [7, 3, 6, 2, 4, 8, 10, 15, 1, 9]) == 5\n assert candidate(nums = [3, 3, 3, 6, 9, 12, 15, 18, 21, 24, 27]) == 38\n", "comparison": "exact"}, "public_tests": ["[1,2,3,6]", "[3,3,6,4,5]", "[1,1,1,3,5]"], "hints": ["N is very small, how can we use that?", "Can we check every possible quadruplet?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countQuadruplets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:32+00:00", "tests_total": 107, "tests_dropped": 18, "flags": [], "topic_tags": ["array", "hash-table", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def countQuadruplets(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countQuadruplets", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1996, "task_id": "the-number-of-weak-characters-in-the-game", "difficulty": "Medium", "problem_description": "You are playing a game that contains multiple characters, and each of the characters has two main properties: attack and defense. You are given a 2D integer array properties where properties[i] = [attack_i, defense_i] represents the properties of the i^th character in the game.\n\nA character is said to be weak if any other character has both attack and defense levels strictly greater than this character's attack and defense levels. More formally, a character i is said to be weak if there exists another character j where attack_j > attack_i and defense_j > defense_i.\n\nReturn the number of weak characters.\n\nExample 1:\n\nInput: properties = [[5,5],[6,3],[3,6]]\nOutput: 0\nExplanation: No character has strictly greater attack and defense than the other.\n\nExample 2:\n\nInput: properties = [[2,2],[3,3]]\nOutput: 1\nExplanation: The first character is weak because the second character has a strictly greater attack and defense.\n\nExample 3:\n\nInput: properties = [[1,5],[10,4],[4,3]]\nOutput: 1\nExplanation: The third character is weak because the second character has a strictly greater attack and defense.\n\nConstraints:\n\n- 2 <= properties.length <= 10^5\n- properties[i].length == 2\n- 1 <= attack_i, defense_i <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(properties = [[5, 5], [6, 3], [3, 6], [2, 2], [1, 1]]) == 2\n assert candidate(properties = [[2, 2], [3, 3]]) == 1\n assert candidate(properties = [[5, 1], [5, 10], [4, 10], [4, 4], [3, 14], [3, 6], [2, 10], [1, 14], [1, 4]]) == 4\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 4\n assert candidate(properties = [[5, 5], [6, 3], [3, 6]]) == 0\n assert candidate(properties = [[10, 1], [5, 1], [7, 10], [4, 1], [5, 9], [6, 9], [7, 2], [1, 10]]) == 4\n assert candidate(properties = [[1, 5], [10, 4], [4, 3], [5, 6], [7, 8], [8, 7], [9, 9], [2, 2]]) == 6\n assert candidate(properties = [[1, 10], [10, 1], [4, 4], [4, 5]]) == 0\n assert candidate(properties = [[1, 5], [10, 4], [4, 3], [3, 15], [1, 20]]) == 2\n assert candidate(properties = [[1, 5], [10, 4], [4, 3]]) == 1\n assert candidate(properties = [[5, 5], [6, 3], [3, 6], [2, 2], [1, 1], [6, 7]]) == 4\n assert candidate(properties = [[1, 5], [1, 5], [1, 5], [10, 4], [4, 3]]) == 1\n assert candidate(properties = [[10, 1], [5, 1], [7, 10], [4, 11], [12, 1], [8, 4], [9, 7]]) == 2\n assert candidate(properties = [[6, 9], [7, 5], [7, 9], [7, 10], [10, 4], [10, 7], [8, 4]]) == 3\n assert candidate(properties = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 4\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 3\n assert candidate(properties = [[100000, 100000], [1, 1], [2, 2], [3, 3], [4, 4]]) == 4\n assert candidate(properties = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991], [11, 99990], [12, 99989], [13, 99988], [14, 99987], [15, 99986], [16, 99985], [17, 99984], [18, 99983], [19, 99982], [20, 99981]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [2, 1], [2, 2], [1, 3], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [1, 4], [2, 4], [3, 4], [4, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 16\n assert candidate(properties = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991]]) == 0\n assert candidate(properties = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [9, 5], [8, 5], [7, 5], [6, 5], [5, 5]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 2]]) == 8\n assert candidate(properties = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [1, 11]]) == 9\n assert candidate(properties = [[100000, 100000], [1, 1], [2, 2], [99999, 99999], [50000, 50000], [10000, 10000]]) == 5\n assert candidate(properties = [[100000, 100000], [99999, 99999], [99998, 99998], [99997, 99997], [99996, 99996], [99995, 99995], [99994, 99994], [99993, 99993], [99992, 99992], [99991, 99991]]) == 9\n assert candidate(properties = [[100000, 1], [1, 100000], [50000, 50000], [25000, 75000], [75000, 25000]]) == 0\n assert candidate(properties = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3]]) == 20\n assert candidate(properties = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [10, 9], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 10]]) == 17\n assert candidate(properties = [[5, 9], [5, 7], [5, 5], [5, 3], [5, 1], [10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [10, 1]]) == 5\n assert candidate(properties = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 17\n assert candidate(properties = [[1, 10], [10, 1], [2, 9], [9, 2], [3, 8], [8, 3], [4, 7], [7, 4], [5, 6], [6, 5]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [2, 10], [3, 9], [4, 8], [5, 7], [6, 6], [7, 5], [8, 4], [9, 3], [10, 2], [1, 10]]) == 16\n assert candidate(properties = [[1, 1], [1, 10], [1, 100], [1, 1000], [1, 10000], [1, 100000], [10, 1], [10, 10], [10, 100], [10, 1000], [10, 10000], [10, 100000]]) == 5\n assert candidate(properties = [[10, 9], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 10]]) == 8\n assert candidate(properties = [[100000, 100000], [99999, 99999], [99998, 99998], [99997, 99997], [99996, 99996]]) == 4\n assert candidate(properties = [[10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [10, 1], [9, 10], [8, 10], [7, 10], [6, 10], [5, 10], [4, 10], [3, 10], [2, 10], [1, 10]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [10, 10]]) == 9\n assert candidate(properties = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [1, 90], [2, 89], [3, 88], [4, 87], [5, 86], [6, 85], [7, 84], [8, 83], [9, 82], [10, 81], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 18\n assert candidate(properties = [[50, 50], [51, 49], [52, 48], [53, 47], [54, 46], [55, 45], [56, 44], [57, 43], [58, 42], [59, 41], [60, 40]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]]) == 9\n assert candidate(properties = [[100000, 1], [99999, 2], [99998, 3], [99997, 4], [99996, 5], [99995, 6], [99994, 7], [99993, 8], [99992, 9], [99991, 10]]) == 0\n assert candidate(properties = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 8\n assert candidate(properties = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 13\n assert candidate(properties = [[10, 5], [9, 6], [8, 7], [7, 8], [6, 9], [5, 10], [4, 11], [3, 12], [2, 13], [1, 14], [10, 15], [9, 16], [8, 17], [7, 18], [6, 19], [5, 20], [4, 21], [3, 22], [2, 23], [1, 24]]) == 9\n assert candidate(properties = [[100000, 1], [1, 100000], [50000, 50000], [90000, 20000], [20000, 90000]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == 8\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [4, 12], [5, 13], [5, 14], [5, 15]]) == 12\n assert candidate(properties = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]]) == 9\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 9\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5], [2, 4], [2, 3], [2, 2], [2, 1], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == 8\n assert candidate(properties = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 9\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 14\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [5, 1], [5, 2], [5, 3]]) == 8\n assert candidate(properties = [[1, 5], [2, 10], [3, 15], [4, 20], [5, 25], [6, 30], [7, 35], [8, 40], [9, 45], [10, 50], [5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45]]) == 17\n assert candidate(properties = [[1, 10], [1, 20], [1, 30], [1, 40], [1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [1, 100]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 0\n assert candidate(properties = [[5, 9], [7, 7], [4, 3], [1, 10], [6, 6], [8, 2], [3, 5]]) == 3\n assert candidate(properties = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [15, 6], [25, 11], [35, 16], [45, 21], [55, 26], [10, 7], [20, 12], [30, 17], [40, 22], [50, 27]]) == 13\n assert candidate(properties = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 1], [8, 2], [9, 3], [10, 4]]) == 8\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 14\n assert candidate(properties = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995]]) == 0\n assert candidate(properties = [[20, 39], [19, 37], [18, 35], [17, 33], [16, 31], [15, 29], [14, 27], [13, 25], [12, 23], [11, 21], [10, 19], [9, 17], [8, 15], [7, 13], [6, 11], [5, 9], [4, 7], [3, 5], [2, 3], [1, 1]]) == 19\n assert candidate(properties = [[1, 100000], [100000, 1], [50000, 50000], [75000, 25000], [25000, 75000], [1, 1], [100000, 100000]]) == 4\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 0\n assert candidate(properties = [[1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1]]) == 0\n assert candidate(properties = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 9\n assert candidate(properties = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [100, 9], [100, 10], [99, 11], [98, 12], [97, 13], [96, 14], [95, 15], [94, 16], [93, 17], [92, 18], [91, 19], [90, 20]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 17\n assert candidate(properties = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 0\n assert candidate(properties = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14]]) == 9\n assert candidate(properties = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [1, 11]]) == 0\n assert candidate(properties = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [1, 90], [2, 89], [3, 88], [4, 87], [5, 86], [6, 85], [7, 84], [8, 83], [9, 82], [10, 81]]) == 9\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 4\n assert candidate(properties = [[5, 5], [5, 6], [6, 5], [6, 6], [1, 1], [1, 2], [2, 1], [2, 2], [7, 7], [8, 8]]) == 9\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [10, 9], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 1]]) == 18\n assert candidate(properties = [[10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [9, 10], [8, 10], [7, 10], [6, 10], [5, 10]]) == 0\n assert candidate(properties = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]) == 8\n assert candidate(properties = [[1, 5], [1, 5], [1, 5], [10, 4], [4, 3], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 8\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 10]]) == 8\n assert candidate(properties = [[1, 50000], [50000, 1], [2, 49999], [49999, 2], [3, 49998], [49998, 3], [4, 49997], [49997, 4], [5, 49996], [49996, 5], [6, 49995], [49995, 6], [7, 49994], [49994, 7], [8, 49993], [49993, 8], [9, 49992], [49992, 9], [10, 49991], [49991, 10]]) == 0\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]]) == 11\n assert candidate(properties = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 9], [11, 8], [12, 7], [13, 6], [14, 5], [15, 4]]) == 8\n assert candidate(properties = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19], [11, 21], [12, 23], [13, 25], [14, 27], [15, 29], [16, 31], [17, 33], [18, 35], [19, 37], [20, 39]]) == 19\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [4, 5], [3, 5], [2, 5], [1, 5], [5, 4], [5, 3], [5, 2], [5, 1]]) == 4\n assert candidate(properties = [[50, 50], [40, 40], [30, 30], [20, 20], [10, 10], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == 9\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 8\n assert candidate(properties = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10]]) == 5\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]]) == 0\n assert candidate(properties = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]]) == 0\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 10]]) == 17\n assert candidate(properties = [[9, 8], [8, 9], [7, 10], [6, 11], [5, 12], [4, 13], [3, 14], [2, 15], [1, 16], [10, 7], [11, 6], [12, 5], [13, 4], [14, 3], [15, 2], [16, 1]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 16\n assert candidate(properties = [[1, 50], [50, 1], [2, 49], [49, 2], [3, 48], [48, 3], [4, 47], [47, 4], [5, 46], [46, 5], [6, 45], [45, 6], [7, 44], [44, 7], [8, 43], [43, 8], [9, 42], [42, 9], [10, 41], [41, 10]]) == 0\n assert candidate(properties = [[9, 7], [9, 8], [9, 9], [10, 7], [10, 8], [10, 9], [11, 7], [11, 8], [11, 9]]) == 4\n assert candidate(properties = [[1, 100000], [100000, 1], [50000, 50000], [75000, 25000], [25000, 75000]]) == 0\n assert candidate(properties = [[5, 10], [10, 5], [15, 15], [20, 10], [25, 15], [30, 20], [35, 25], [40, 30], [45, 35], [50, 40]]) == 9\n assert candidate(properties = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 9\n", "comparison": "exact"}, "public_tests": ["[[5,5],[6,3],[3,6]]", "[[2,2],[3,3]]", "[[1,5],[10,4],[4,3]]"], "hints": ["Sort the array on the basis of the attack values and group characters with the same attack together. How can you use these groups?", "Characters in one group will always have a lesser attack value than the characters of the next group. Hence, we will only need to check if there is a higher defense value present in the next groups."], "metadata": {"canonical_parameter_names": ["properties"], "leetcode_dataset_entry_point": "Solution().numberOfWeakCharacters", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:35+00:00", "tests_total": 99, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "stack", "greedy", "sorting", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def numberOfWeakCharacters(self, properties: list[list[int]]) -> int:", "container": "Solution", "callable": "numberOfWeakCharacters", "parameters": [{"name": "properties", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1997, "task_id": "first-day-where-you-have-been-in-all-the-rooms", "difficulty": "Medium", "problem_description": "There are n rooms you need to visit, labeled from 0 to n - 1. Each day is labeled, starting from 0. You will go in and visit one room a day.\n\nInitially on day 0, you visit room 0. The order you visit the rooms for the coming days is determined by the following rules and a given 0-indexed array nextVisit of length n:\n\n- Assuming that on a day, you visit room i,\n- if you have been in room i an odd number of times (including the current visit), on the next day you will visit a room with a lower or equal room number specified by nextVisit[i] where 0 <= nextVisit[i] <= i;\n- if you have been in room i an even number of times (including the current visit), on the next day you will visit room (i + 1) mod n.\n\nReturn the label of the first day where you have been in all the rooms. It can be shown that such a day exists. Since the answer may be very large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: nextVisit = [0,0]\nOutput: 2\nExplanation:\n- On day 0, you visit room 0. The total times you have been in room 0 is 1, which is odd.\n On the next day you will visit room nextVisit[0] = 0\n- On day 1, you visit room 0, The total times you have been in room 0 is 2, which is even.\n On the next day you will visit room (0 + 1) mod 2 = 1\n- On day 2, you visit room 1. This is the first day where you have been in all the rooms.\n\nExample 2:\n\nInput: nextVisit = [0,0,2]\nOutput: 6\nExplanation:\nYour room visiting order for each day is: [0,0,1,0,0,1,2,...].\nDay 6 is the first day where you have been in all the rooms.\n\nExample 3:\n\nInput: nextVisit = [0,1,2,0]\nOutput: 6\nExplanation:\nYour room visiting order for each day is: [0,0,1,1,2,2,3,...].\nDay 6 is the first day where you have been in all the rooms.\n\nConstraints:\n\n- n == nextVisit.length\n- 2 <= n <= 10^5\n- 0 <= nextVisit[i] <= i\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nextVisit = [0, 0, 2]) == 6\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5]) == 10\n assert candidate(nextVisit = [0, 1, 1, 1, 1]) == 16\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1022\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1]) == 42\n assert candidate(nextVisit = [0, 1, 2, 3, 2, 1, 0, 1, 2, 3]) == 230\n assert candidate(nextVisit = [0, 1, 0, 2]) == 10\n assert candidate(nextVisit = [0, 1, 2, 0]) == 6\n assert candidate(nextVisit = [0, 1, 1, 1, 1, 1]) == 32\n assert candidate(nextVisit = [0, 1, 1, 0, 1, 1, 0]) == 72\n assert candidate(nextVisit = [0, 1, 0, 2, 1]) == 18\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 682\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 0]) == 10\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 18\n assert candidate(nextVisit = [0, 1, 1, 0, 1, 2]) == 36\n assert candidate(nextVisit = [0, 1, 1, 0]) == 8\n assert candidate(nextVisit = [0, 0]) == 2\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == 328\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 0, 0, 0, 0]) == 670\n assert candidate(nextVisit = [0, 1, 0, 3, 2, 5, 4, 7, 6, 9]) == 58\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1022\n assert candidate(nextVisit = [0, 0, 2, 1, 4, 3, 5, 6, 7, 8, 9]) == 98\n assert candidate(nextVisit = [0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0]) == 599186\n assert candidate(nextVisit = [0, 1, 1, 2, 2, 2, 3, 3, 3, 3]) == 358\n assert candidate(nextVisit = [0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18]) == 56\n assert candidate(nextVisit = [0, 1, 0, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 633246732\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 38\n assert candidate(nextVisit = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 110\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2044\n assert candidate(nextVisit = [0, 1, 0, 3, 2, 1, 4, 5, 2, 3, 6, 7, 8, 9]) == 3802\n assert candidate(nextVisit = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 524288\n assert candidate(nextVisit = [0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0]) == 13851577\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 461127067\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1048574\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 44739242\n assert candidate(nextVisit = [0, 1, 0, 2, 1, 0, 3, 2, 1, 0]) == 556\n assert candidate(nextVisit = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 786430\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1048574\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 699050\n assert candidate(nextVisit = [0, 1, 2, 3, 2, 1, 2, 3, 4, 3, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9]) == 198234\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10258\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 41964584\n assert candidate(nextVisit = [0, 1, 1, 2, 2, 3, 3, 4, 4, 5]) == 308\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 63550\n assert candidate(nextVisit = [0, 1, 1, 3, 2, 2, 5]) == 34\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 38954\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 0]) == 18\n assert candidate(nextVisit = [0, 1, 0, 2, 3, 2, 5, 4]) == 82\n assert candidate(nextVisit = [0, 1, 2, 3, 2, 3, 4, 3, 4, 5]) == 154\n assert candidate(nextVisit = [0, 1, 0, 3, 0, 1, 0, 5, 0, 1, 0, 3, 0, 1, 0, 7, 0, 1, 0, 3, 0, 1]) == 1543578\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 3, 2, 3, 4, 5]) == 106\n assert candidate(nextVisit = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 57521884\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10258\n assert candidate(nextVisit = [0, 1, 2, 0, 4, 0, 6, 0, 8, 0, 10, 0, 12, 0, 14, 0, 16, 0, 18, 0, 20]) == 5114\n assert candidate(nextVisit = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0]) == 438\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3]) == 123366\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20126903\n assert candidate(nextVisit = [0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 0, 10]) == 943314207\n assert candidate(nextVisit = [0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3]) == 229862\n assert candidate(nextVisit = [0, 1, 0, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 89816588\n assert candidate(nextVisit = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0]) == 855298880\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 40\n assert candidate(nextVisit = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 512\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 640520038\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 147483632\n assert candidate(nextVisit = [0, 1, 2, 0, 3, 2, 5, 6, 7, 8, 9, 10, 0]) == 220\n assert candidate(nextVisit = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 590\n assert candidate(nextVisit = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 512\n assert candidate(nextVisit = [0, 1, 0, 1, 2, 3, 4, 5, 6, 7]) == 334\n", "comparison": "exact"}, "public_tests": ["[0,0]", "[0,0,2]", "[0,1,2,0]"], "hints": ["The only way to get to room i+1 is when you are visiting room i and room i has been visited an even number of times.", "After visiting room i an odd number of times, you are required to visit room nextVisit[i] where nextVisit[i] <= i. It takes a fixed amount of days for you to come back from room nextVisit[i] to room i. Then, you have visited room i even number of times.nextVisit[i]", "Can you use Dynamic Programming to avoid recomputing the number of days it takes to visit room i from room nextVisit[i]?"], "metadata": {"canonical_parameter_names": ["nextVisit"], "leetcode_dataset_entry_point": "Solution().firstDayBeenInAllRooms", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:38+00:00", "tests_total": 110, "tests_dropped": 41, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def firstDayBeenInAllRooms(self, nextVisit: list[int]) -> int:", "container": "Solution", "callable": "firstDayBeenInAllRooms", "parameters": [{"name": "nextVisit", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1998, "task_id": "gcd-sort-of-an-array", "difficulty": "Hard", "problem_description": "You are given an integer array nums, and you can perform the following operation any number of times on nums:\n\n- Swap the positions of two elements nums[i] and nums[j] if gcd(nums[i], nums[j]) > 1 where gcd(nums[i], nums[j]) is the greatest common divisor of nums[i] and nums[j].\n\nReturn true if it is possible to sort nums in non-decreasing order using the above swap method, or false otherwise.\n\nExample 1:\n\nInput: nums = [7,21,3]\nOutput: true\nExplanation: We can sort [7,21,3] by performing the following operations:\n- Swap 7 and 21 because gcd(7,21) = 7. nums = [21,7,3]\n- Swap 21 and 3 because gcd(21,3) = 3. nums = [3,7,21]\n\nExample 2:\n\nInput: nums = [5,2,6,2]\nOutput: false\nExplanation: It is impossible to sort the array because 5 cannot be swapped with any other element.\n\nExample 3:\n\nInput: nums = [10,5,9,3,15]\nOutput: true\nWe can sort [10,5,9,3,15] by performing the following operations:\n- Swap 10 and 15 because gcd(10,15) = 5. nums = [15,5,9,3,10]\n- Swap 15 and 3 because gcd(15,3) = 3. nums = [3,5,9,15,10]\n- Swap 10 and 15 because gcd(10,15) = 5. nums = [3,5,9,10,15]\n\nConstraints:\n\n- 1 <= nums.length <= 3 * 10^4\n- 2 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [12, 15, 18, 20, 25]) == True\n assert candidate(nums = [7, 21, 3]) == True\n assert candidate(nums = [8, 4, 12, 6]) == True\n assert candidate(nums = [2, 3, 5, 7, 11]) == True\n assert candidate(nums = [2, 4, 6, 8, 10]) == True\n assert candidate(nums = [18, 9, 27, 3, 6]) == True\n assert candidate(nums = [3, 9, 6, 18, 27]) == True\n assert candidate(nums = [37, 49, 111, 143, 169]) == True\n assert candidate(nums = [100, 200, 400, 800, 1600]) == True\n assert candidate(nums = [22, 44, 11, 66, 33]) == True\n assert candidate(nums = [100, 200, 300, 400, 500]) == True\n assert candidate(nums = [83, 97, 101, 103, 107]) == True\n assert candidate(nums = [100000, 99998, 99999, 99997, 99996]) == False\n assert candidate(nums = [10, 5, 9, 3, 15]) == True\n assert candidate(nums = [105, 70, 30, 210, 42]) == True\n assert candidate(nums = [30, 42, 70, 105, 35]) == True\n assert candidate(nums = [5, 2, 6, 2]) == False\n assert candidate(nums = [56, 72, 88, 104, 120, 136, 152]) == True\n assert candidate(nums = [121, 132, 143, 154, 165, 176, 187, 198, 209]) == True\n assert candidate(nums = [48, 64, 80, 96, 112]) == True\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119]) == True\n assert candidate(nums = [210, 315, 420, 525, 630, 735]) == True\n assert candidate(nums = [105, 45, 63, 21, 315]) == True\n assert candidate(nums = [100, 50, 25, 125, 200, 150]) == True\n assert candidate(nums = [91, 182, 273, 364, 455]) == True\n assert candidate(nums = [121, 132, 143, 154, 165, 176]) == True\n assert candidate(nums = [16, 32, 48, 64, 80, 96, 112, 128, 144]) == True\n assert candidate(nums = [70, 35, 28, 56, 14, 18]) == True\n assert candidate(nums = [14, 21, 28, 35, 42, 49, 56, 63, 70]) == True\n assert candidate(nums = [32, 48, 64, 80, 96, 112]) == True\n assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310]) == True\n assert candidate(nums = [30, 25, 20, 15, 10, 5]) == True\n assert candidate(nums = [30, 45, 60, 75, 90, 105]) == True\n assert candidate(nums = [44, 55, 66, 77, 88, 99, 110, 121]) == True\n assert candidate(nums = [15, 20, 25, 30, 35]) == True\n assert candidate(nums = [33, 66, 99, 132, 165]) == True\n assert candidate(nums = [49, 14, 7, 98, 28]) == True\n assert candidate(nums = [6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189]) == True\n assert candidate(nums = [49, 42, 28, 35, 70]) == True\n assert candidate(nums = [123, 246, 369, 492, 615, 738, 861, 984]) == True\n assert candidate(nums = [84, 126, 168, 210, 252, 294, 336, 378, 420]) == True\n assert candidate(nums = [84, 28, 42, 70, 56]) == True\n assert candidate(nums = [101, 202, 303, 404, 505, 606]) == True\n assert candidate(nums = [56, 14, 28, 7, 98, 49]) == True\n assert candidate(nums = [45, 30, 60, 90, 120, 150]) == True\n assert candidate(nums = [100, 50, 75, 25, 150]) == True\n assert candidate(nums = [15, 25, 35, 45, 55, 65]) == True\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184]) == True\n assert candidate(nums = [121, 221, 143, 169, 13]) == True\n assert candidate(nums = [100, 200, 300, 400, 500]) == True\n assert candidate(nums = [462, 882, 924, 1092, 1260]) == True\n assert candidate(nums = [360, 720, 1080, 1440, 1800, 2160]) == True\n assert candidate(nums = [1000, 500, 250, 125, 625]) == True\n assert candidate(nums = [48, 120, 180, 240, 300]) == True\n assert candidate(nums = [16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240]) == True\n assert candidate(nums = [210, 70, 35, 14, 105]) == True\n assert candidate(nums = [1024, 2048, 512, 256, 128]) == True\n assert candidate(nums = [56, 112, 168, 224, 280]) == True\n assert candidate(nums = [100, 25, 50, 20, 40]) == True\n assert candidate(nums = [24, 36, 48, 12, 60]) == True\n assert candidate(nums = [99, 33, 66, 22, 11, 132]) == True\n assert candidate(nums = [21, 42, 63, 84, 105]) == True\n assert candidate(nums = [13, 26, 39, 52, 65, 78]) == True\n assert candidate(nums = [30, 45, 60, 75, 90]) == True\n assert candidate(nums = [77, 154, 231, 308, 385]) == True\n assert candidate(nums = [91, 130, 169, 182, 273, 338]) == True\n assert candidate(nums = [22, 15, 45, 33, 10, 55]) == True\n assert candidate(nums = [18, 27, 36, 45, 54, 63, 72, 81, 90]) == True\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == True\n assert candidate(nums = [171, 342, 513, 684, 855]) == True\n assert candidate(nums = [33, 55, 66, 88, 110, 121, 132, 143]) == True\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]) == True\n assert candidate(nums = [45, 90, 135, 180, 225]) == True\n assert candidate(nums = [20, 40, 60, 80, 100, 120, 140, 160, 180]) == True\n assert candidate(nums = [100, 50, 25, 20, 125]) == True\n assert candidate(nums = [18, 24, 30, 36, 42]) == True\n assert candidate(nums = [1000, 250, 500, 200, 750, 125, 375, 625, 875, 1250]) == True\n assert candidate(nums = [102, 136, 170, 204, 238, 272, 306, 340, 374]) == True\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190]) == True\n assert candidate(nums = [27, 54, 81, 108, 135, 162, 189, 216]) == True\n assert candidate(nums = [119, 238, 357, 476, 595]) == True\n assert candidate(nums = [81, 27, 54, 162, 324, 486]) == True\n assert candidate(nums = [84, 12, 14, 21, 63]) == True\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105]) == True\n assert candidate(nums = [18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108]) == True\n assert candidate(nums = [49, 63, 77, 91, 105, 119, 133, 147, 161, 175, 189, 203, 217]) == True\n assert candidate(nums = [72, 108, 144, 180, 216, 252, 288, 324, 360, 396]) == True\n assert candidate(nums = [225, 150, 100, 50, 25, 75]) == True\n assert candidate(nums = [121, 110, 99, 88, 77, 66, 55, 44, 33, 22, 11]) == True\n assert candidate(nums = [22, 44, 66, 88, 110, 132, 154, 176, 198]) == True\n assert candidate(nums = [1000, 500, 250, 125, 2000]) == True\n assert candidate(nums = [135, 90, 45, 60, 30]) == True\n assert candidate(nums = [9, 18, 27, 36, 45, 54]) == True\n assert candidate(nums = [17, 34, 51, 68, 85]) == True\n assert candidate(nums = [105, 15, 35, 21, 63]) == True\n assert candidate(nums = [81, 135, 207, 279, 351, 423]) == True\n assert candidate(nums = [36, 48, 60, 72, 84, 96]) == True\n assert candidate(nums = [180, 120, 90, 60, 45, 30, 20, 15, 10, 5]) == True\n assert candidate(nums = [28, 14, 42, 70, 98]) == True\n assert candidate(nums = [17, 19, 23, 29, 31, 37]) == True\n assert candidate(nums = [81, 27, 54, 108, 162]) == True\n assert candidate(nums = [121, 11, 22, 33, 44, 55]) == True\n assert candidate(nums = [165, 330, 495, 660, 825]) == True\n assert candidate(nums = [49, 98, 147, 196, 245]) == True\n assert candidate(nums = [121, 44, 88, 22, 176]) == True\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85]) == True\n assert candidate(nums = [100, 101, 102, 103, 104, 105]) == True\n assert candidate(nums = [17, 19, 23, 29, 31]) == True\n assert candidate(nums = [315, 105, 35, 7, 14, 21, 42, 63, 84]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == True\n assert candidate(nums = [13, 26, 39, 52, 65]) == True\n assert candidate(nums = [15, 25, 35, 45, 55]) == True\n assert candidate(nums = [7, 49, 343, 2401, 16807]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152]) == True\n assert candidate(nums = [14, 21, 35, 49, 70]) == True\n assert candidate(nums = [33, 66, 99, 132, 165, 198]) == True\n assert candidate(nums = [18, 24, 30, 36, 42, 48]) == True\n assert candidate(nums = [22, 44, 66, 88, 110]) == True\n assert candidate(nums = [84, 56, 28, 14, 7, 49, 35]) == True\n assert candidate(nums = [48, 64, 80, 96, 112, 128]) == True\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768]) == True\n assert candidate(nums = [56, 63, 70, 77, 84, 91]) == True\n assert candidate(nums = [99, 33, 66, 132, 264]) == True\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250]) == True\n assert candidate(nums = [77, 91, 143, 1001, 1001, 143]) == True\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700]) == True\n assert candidate(nums = [77, 55, 99, 110, 132]) == True\n assert candidate(nums = [30, 45, 60, 15, 90]) == True\n assert candidate(nums = [72, 24, 16, 8, 40]) == True\n assert candidate(nums = [42, 21, 7, 14, 28]) == True\n assert candidate(nums = [77, 143, 169, 187, 209, 221, 247, 299, 323, 341]) == True\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(nums = [121, 143, 169, 187, 209]) == True\n assert candidate(nums = [14, 21, 28, 35, 42, 49, 56, 63]) == True\n assert candidate(nums = [14, 21, 28, 35, 42, 49]) == True\n assert candidate(nums = [49, 147, 245, 343, 441, 539]) == True\n assert candidate(nums = [22, 15, 10, 18, 30]) == True\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149]) == True\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81]) == True\n assert candidate(nums = [16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(nums = [102, 204, 306, 408, 510]) == True\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000]) == True\n assert candidate(nums = [60, 120, 180, 240, 300, 360]) == True\n assert candidate(nums = [42, 28, 70, 14, 35]) == True\n assert candidate(nums = [22, 33, 44, 55, 66]) == True\n assert candidate(nums = [77, 49, 35, 21, 14, 7]) == True\n assert candidate(nums = [23, 46, 69, 92, 115]) == True\n assert candidate(nums = [101, 202, 303, 404, 505]) == True\n assert candidate(nums = [102, 68, 34, 17, 51, 85]) == True\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117]) == True\n assert candidate(nums = [100, 105, 140, 210, 70]) == True\n assert candidate(nums = [11, 22, 33, 44, 55, 66]) == True\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153]) == True\n assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192, 16384]) == True\n assert candidate(nums = [1000, 500, 250, 125, 2000, 10000, 2500]) == True\n assert candidate(nums = [30, 45, 60, 75, 90, 105, 120]) == True\n assert candidate(nums = [12, 18, 24, 30, 36, 42]) == True\n assert candidate(nums = [25, 45, 65, 85, 105]) == True\n assert candidate(nums = [100, 200, 150, 300, 250]) == True\n assert candidate(nums = [14, 28, 42, 56, 70]) == True\n assert candidate(nums = [81, 135, 225, 315, 405, 525, 675]) == True\n assert candidate(nums = [121, 132, 220, 110, 55]) == True\n", "comparison": "exact"}, "public_tests": ["[7,21,3]", "[5,2,6,2]", "[10,5,9,3,15]"], "hints": ["Can we build a graph with all the prime numbers and the original array?", "We can use union-find to determine which indices are connected (i.e., which indices can be swapped)."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().gcdSort", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:40+00:00", "tests_total": 168, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "math", "union-find", "sorting", "number-theory", "prime-factorization", "euclidean-algorithm", "greatest-common-divisor"]}, "language": "python", "interface": {"raw_signature": "def gcdSort(self, nums: list[int]) -> bool:", "container": "Solution", "callable": "gcdSort", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2000, "task_id": "reverse-prefix-of-word", "difficulty": "Easy", "problem_description": "Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing.\n\n- For example, if word = \"abcdefd\" and ch = \"d\", then you should reverse the segment that starts at 0 and ends at 3 (inclusive). The resulting string will be \"dcbaefd\".\n\nReturn the resulting string.\n\nExample 1:\n\nInput: word = \"abcdefd\", ch = \"d\"\nOutput: \"dcbaefd\"\nExplanation: The first occurrence of \"d\" is at index 3.\nReverse the part of word from 0 to 3 (inclusive), the resulting string is \"dcbaefd\".\n\nExample 2:\n\nInput: word = \"xyxzxe\", ch = \"z\"\nOutput: \"zxyxxe\"\nExplanation: The first and only occurrence of \"z\" is at index 3.\nReverse the part of word from 0 to 3 (inclusive), the resulting string is \"zxyxxe\".\n\nExample 3:\n\nInput: word = \"abcd\", ch = \"z\"\nOutput: \"abcd\"\nExplanation: \"z\" does not exist in word.\nYou should not do any reverse operation, the resulting string is \"abcd\".\n\nConstraints:\n\n- 1 <= word.length <= 250\n- word consists of lowercase English letters.\n- ch is a lowercase English letter.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"abcdef\",ch = \"f\") == \"fedcba\"\n assert candidate(word = \"madam\",ch = \"d\") == \"damam\"\n assert candidate(word = \"abcdefd\",ch = \"d\") == \"dcbaefd\"\n assert candidate(word = \"abcd\",ch = \"z\") == \"abcd\"\n assert candidate(word = \"a\",ch = \"a\") == \"a\"\n assert candidate(word = \"python\",ch = \"y\") == \"ypthon\"\n assert candidate(word = \"operation\",ch = \"p\") == \"poeration\"\n assert candidate(word = \"xyxzxe\",ch = \"z\") == \"zxyxxe\"\n assert candidate(word = \"segment\",ch = \"t\") == \"tnemges\"\n assert candidate(word = \"hello\",ch = \"l\") == \"lehlo\"\n assert candidate(word = \"racecar\",ch = \"e\") == \"ecarcar\"\n assert candidate(word = \"abcdef\",ch = \"g\") == \"abcdef\"\n assert candidate(word = \"example\",ch = \"m\") == \"maxeple\"\n assert candidate(word = \"reverse\",ch = \"r\") == \"reverse\"\n assert candidate(word = \"abcdef\",ch = \"a\") == \"abcdef\"\n assert candidate(word = \"supercalifragilisticexpialidocious\",ch = \"x\") == \"xecitsiligarfilacrepuspialidocious\"\n assert candidate(word = \"abracadabra\",ch = \"r\") == \"rbaacadabra\"\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\",ch = \"a\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(word = \"unbelievable\",ch = \"e\") == \"ebnulievable\"\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",ch = \"m\") == \"mlkjihgfedcbanopqrstuvwxyz\"\n assert candidate(word = \"supercalifragilisticexpialidocious\",ch = \"c\") == \"crepusalifragilisticexpialidocious\"\n assert candidate(word = \"interview\",ch = \"w\") == \"weivretni\"\n assert candidate(word = \"unpredictable\",ch = \"d\") == \"derpnuictable\"\n assert candidate(word = \"beautifulization\",ch = \"z\") == \"zilufituaebation\"\n assert candidate(word = \"characterization\",ch = \"c\") == \"characterization\"\n assert candidate(word = \"communication\",ch = \"m\") == \"mocmunication\"\n assert candidate(word = \"reversethispart\",ch = \"e\") == \"erversethispart\"\n assert candidate(word = \"reinforce\",ch = \"e\") == \"erinforce\"\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\",ch = \"q\") == \"qrstuvwxyzponmlkjihgfedcba\"\n assert candidate(word = \"unbelievable\",ch = \"l\") == \"lebnuievable\"\n assert candidate(word = \"nothingtoreverse\",ch = \"x\") == \"nothingtoreverse\"\n assert candidate(word = \"characterization\",ch = \"a\") == \"ahcracterization\"\n assert candidate(word = \"quickbrownfox\",ch = \"o\") == \"orbkciuqwnfox\"\n assert candidate(word = \"banana\",ch = \"n\") == \"nabana\"\n assert candidate(word = \"qwertyuiop\",ch = \"p\") == \"poiuytrewq\"\n assert candidate(word = \"qwertyuiop\",ch = \"q\") == \"qwertyuiop\"\n assert candidate(word = \"boundary\",ch = \"d\") == \"dnuobary\"\n assert candidate(word = \"continuous\",ch = \"s\") == \"suounitnoc\"\n assert candidate(word = \"interoperability\",ch = \"i\") == \"interoperability\"\n assert candidate(word = \"aaaaaa\",ch = \"a\") == \"aaaaaa\"\n assert candidate(word = \"quizzically\",ch = \"q\") == \"quizzically\"\n assert candidate(word = \"congratulations\",ch = \"g\") == \"gnocratulations\"\n assert candidate(word = \"aabbccddeeff\",ch = \"f\") == \"feeddccbbaaf\"\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\",ch = \"m\") == \"mnopqrstuvwxyzlkjihgfedcba\"\n assert candidate(word = \"concatenation\",ch = \"c\") == \"concatenation\"\n assert candidate(word = \"implementation\",ch = \"i\") == \"implementation\"\n assert candidate(word = \"establishment\",ch = \"b\") == \"batselishment\"\n assert candidate(word = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllll\",ch = \"l\") == \"lkjihgfedcballlllllllllllllllllllllllllllllllllllllllllllll\"\n assert candidate(word = \"abcdefg\",ch = \"g\") == \"gfedcba\"\n assert candidate(word = \"development\",ch = \"p\") == \"polevedment\"\n assert candidate(word = \"unfortunately\",ch = \"r\") == \"rofnutunately\"\n assert candidate(word = \"challenges\",ch = \"e\") == \"ellahcnges\"\n assert candidate(word = \"thisisaverylongwordthatneedstoreversed\",ch = \"n\") == \"nolyrevasisihtgwordthatneedstoreversed\"\n assert candidate(word = \"interview\",ch = \"e\") == \"etnirview\"\n assert candidate(word = \"abcdeffedcba\",ch = \"f\") == \"fedcbafedcba\"\n assert candidate(word = \"classification\",ch = \"l\") == \"lcassification\"\n assert candidate(word = \"thisisateststring\",ch = \"t\") == \"thisisateststring\"\n assert candidate(word = \"mississippi\",ch = \"i\") == \"imssissippi\"\n assert candidate(word = \"unbelievable\",ch = \"b\") == \"bnuelievable\"\n assert candidate(word = \"mississippi\",ch = \"s\") == \"simsissippi\"\n assert candidate(word = \"congratulations\",ch = \"l\") == \"lutargnocations\"\n assert candidate(word = \"synchronous\",ch = \"c\") == \"cnyshronous\"\n assert candidate(word = \"algorithm\",ch = \"l\") == \"lagorithm\"\n assert candidate(word = \"abracadabra\",ch = \"c\") == \"carbaadabra\"\n assert candidate(word = \"zzzzzzzzzzzzzzzz\",ch = \"z\") == \"zzzzzzzzzzzzzzzz\"\n assert candidate(word = \"development\",ch = \"l\") == \"levedopment\"\n assert candidate(word = \"identification\",ch = \"i\") == \"identification\"\n assert candidate(word = \"beautiful\",ch = \"t\") == \"tuaebiful\"\n assert candidate(word = \"asdfghjklzxcvbnm\",ch = \"m\") == \"mnbvcxzlkjhgfdsa\"\n assert candidate(word = \"representation\",ch = \"r\") == \"representation\"\n assert candidate(word = \"congratulations\",ch = \"t\") == \"targnoculations\"\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",ch = \"q\") == \"qppoonnmmllkkjjiihhggffeeddccbbaaqrrssttuuvvwwxxyyzz\"\n assert candidate(word = \"sequence\",ch = \"q\") == \"qesuence\"\n assert candidate(word = \"environment\",ch = \"v\") == \"vneironment\"\n assert candidate(word = \"algorithm\",ch = \"g\") == \"glaorithm\"\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",ch = \"z\") == \"zyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaaz\"\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",ch = \"z\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(word = \"abcdefghij\",ch = \"e\") == \"edcbafghij\"\n assert candidate(word = \"solution\",ch = \"u\") == \"ulostion\"\n assert candidate(word = \"environment\",ch = \"n\") == \"nevironment\"\n assert candidate(word = \"environmentally\",ch = \"v\") == \"vneironmentally\"\n assert candidate(word = \"algorithm\",ch = \"o\") == \"oglarithm\"\n assert candidate(word = \"single\",ch = \"l\") == \"lgnise\"\n assert candidate(word = \"supercalifragilisticexpialidocious\",ch = \"f\") == \"filacrepusragilisticexpialidocious\"\n assert candidate(word = \"abcdefg\",ch = \"z\") == \"abcdefg\"\n assert candidate(word = \"double\",ch = \"x\") == \"double\"\n assert candidate(word = \"algorithms\",ch = \"a\") == \"algorithms\"\n assert candidate(word = \"algorithm\",ch = \"r\") == \"roglaithm\"\n assert candidate(word = \"characterization\",ch = \"h\") == \"hcaracterization\"\n assert candidate(word = \"xyzzyx\",ch = \"z\") == \"zyxzyx\"\n assert candidate(word = \"subsequence\",ch = \"q\") == \"qesbusuence\"\n assert candidate(word = \"reversal\",ch = \"a\") == \"asreverl\"\n assert candidate(word = \"a\",ch = \"b\") == \"a\"\n assert candidate(word = \"visualization\",ch = \"i\") == \"ivsualization\"\n assert candidate(word = \"incomprehensible\",ch = \"h\") == \"herpmocniensible\"\n assert candidate(word = \"hellothere\",ch = \"e\") == \"ehllothere\"\n assert candidate(word = \"reverseprefix\",ch = \"r\") == \"reverseprefix\"\n assert candidate(word = \"pneumonoultramicroscopicsilicovolcanoconiosis\",ch = \"o\") == \"omuenpnoultramicroscopicsilicovolcanoconiosis\"\n assert candidate(word = \"uniquecharacters\",ch = \"u\") == \"uniquecharacters\"\n assert candidate(word = \"alphabetization\",ch = \"b\") == \"bahplaetization\"\n assert candidate(word = \"standardization\",ch = \"i\") == \"idradnatszation\"\n assert candidate(word = \"automation\",ch = \"o\") == \"otuamation\"\n assert candidate(word = \"mnopqr\",ch = \"r\") == \"rqponm\"\n assert candidate(word = \"pronunciation\",ch = \"u\") == \"unorpnciation\"\n assert candidate(word = \"abacaxa\",ch = \"a\") == \"abacaxa\"\n assert candidate(word = \"reversal\",ch = \"r\") == \"reversal\"\n assert candidate(word = \"congratulations\",ch = \"u\") == \"utargnoclations\"\n assert candidate(word = \"performance\",ch = \"f\") == \"frepormance\"\n assert candidate(word = \"nevertheless\",ch = \"n\") == \"nevertheless\"\n assert candidate(word = \"multifaceted\",ch = \"f\") == \"fitlumaceted\"\n assert candidate(word = \"reversal\",ch = \"v\") == \"verersal\"\n assert candidate(word = \"thisisaverylongwordthatshouldtestthelimitsofthefunction\",ch = \"t\") == \"thisisaverylongwordthatshouldtestthelimitsofthefunction\"\n assert candidate(word = \"sophistication\",ch = \"s\") == \"sophistication\"\n assert candidate(word = \"xylophone\",ch = \"o\") == \"olyxphone\"\n assert candidate(word = \"visualization\",ch = \"z\") == \"zilausivation\"\n assert candidate(word = \"pneumonoultramicroscopicsilicovolcanoconiosis\",ch = \"u\") == \"uenpmonoultramicroscopicsilicovolcanoconiosis\"\n assert candidate(word = \"xyzxyzxyz\",ch = \"x\") == \"xyzxyzxyz\"\n assert candidate(word = \"challenge\",ch = \"e\") == \"ellahcnge\"\n assert candidate(word = \"perseverance\",ch = \"v\") == \"vesreperance\"\n assert candidate(word = \"abcdefghijk\",ch = \"i\") == \"ihgfedcbajk\"\n assert candidate(word = \"mississippi\",ch = \"p\") == \"pississimpi\"\n assert candidate(word = \"programming\",ch = \"g\") == \"gorpramming\"\n assert candidate(word = \"responsibilities\",ch = \"s\") == \"serponsibilities\"\n assert candidate(word = \"synchronization\",ch = \"n\") == \"nyschronization\"\n assert candidate(word = \"floccinaucinihilipilification\",ch = \"f\") == \"floccinaucinihilipilification\"\n assert candidate(word = \"operationalization\",ch = \"o\") == \"operationalization\"\n assert candidate(word = \"specializations\",ch = \"a\") == \"aicepslizations\"\n assert candidate(word = \"optimization\",ch = \"t\") == \"tpoimization\"\n assert candidate(word = \"abcdefghijk\",ch = \"h\") == \"hgfedcbaijk\"\n assert candidate(word = \"xylophone\",ch = \"p\") == \"polyxhone\"\n assert candidate(word = \"hellohellohello\",ch = \"l\") == \"lehlohellohello\"\n assert candidate(word = \"concatenation\",ch = \"n\") == \"noccatenation\"\n", "comparison": "exact"}, "public_tests": ["\"abcdefd\"\n\"d\"", "\"xyxzxe\"\n\"z\"", "\"abcd\"\n\"z\""], "hints": ["Find the first index where ch appears.", "Find a way to reverse a substring of word."], "metadata": {"canonical_parameter_names": ["word", "ch"], "leetcode_dataset_entry_point": "Solution().reversePrefix", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:44+00:00", "tests_total": 133, "tests_dropped": 1, "flags": [], "topic_tags": ["two-pointers", "string", "stack"]}, "language": "python", "interface": {"raw_signature": "def reversePrefix(self, word: str, ch: str) -> str:", "container": "Solution", "callable": "reversePrefix", "parameters": [{"name": "word", "type": "str"}, {"name": "ch", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2001, "task_id": "number-of-pairs-of-interchangeable-rectangles", "difficulty": "Medium", "problem_description": "You are given n rectangles represented by a 0-indexed 2D integer array rectangles, where rectangles[i] = [width_i, height_i] denotes the width and height of the i^th rectangle.\n\nTwo rectangles i and j (i < j) are considered interchangeable if they have the same width-to-height ratio. More formally, two rectangles are interchangeable if width_i/height_i == width_j/height_j (using decimal division, not integer division).\n\nReturn the number of pairs of interchangeable rectangles in rectangles.\n\nExample 1:\n\nInput: rectangles = [[4,8],[3,6],[10,20],[15,30]]\nOutput: 6\nExplanation: The following are the interchangeable pairs of rectangles by index (0-indexed):\n- Rectangle 0 with rectangle 1: 4/8 == 3/6.\n- Rectangle 0 with rectangle 2: 4/8 == 10/20.\n- Rectangle 0 with rectangle 3: 4/8 == 15/30.\n- Rectangle 1 with rectangle 2: 3/6 == 10/20.\n- Rectangle 1 with rectangle 3: 3/6 == 15/30.\n- Rectangle 2 with rectangle 3: 10/20 == 15/30.\n\nExample 2:\n\nInput: rectangles = [[4,5],[7,8]]\nOutput: 0\nExplanation: There are no interchangeable pairs of rectangles.\n\nConstraints:\n\n- n == rectangles.length\n- 1 <= n <= 10^5\n- rectangles[i].length == 2\n- 1 <= width_i, height_i <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 10\n assert candidate(rectangles = [[5, 10], [10, 20], [20, 40], [40, 80]]) == 6\n assert candidate(rectangles = [[2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(rectangles = [[4, 5], [7, 8]]) == 0\n assert candidate(rectangles = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50]]) == 10\n assert candidate(rectangles = [[5, 10], [10, 20], [15, 30], [20, 40]]) == 6\n assert candidate(rectangles = [[4, 8], [3, 6], [10, 20], [15, 30]]) == 6\n assert candidate(rectangles = [[1, 2], [2, 4], [3, 6], [4, 8]]) == 6\n assert candidate(rectangles = [[2, 3], [3, 4], [4, 6], [6, 9]]) == 3\n assert candidate(rectangles = [[2, 3], [3, 2], [6, 9], [9, 6]]) == 2\n assert candidate(rectangles = [[10, 5], [5, 10], [20, 10], [10, 20], [30, 15]]) == 4\n assert candidate(rectangles = [[1, 2], [2, 4], [4, 8], [8, 16]]) == 6\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 45\n assert candidate(rectangles = [[2, 4], [4, 8], [8, 16], [16, 32], [32, 64], [64, 128]]) == 15\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]]) == 66\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]]) == 55\n assert candidate(rectangles = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]]) == 45\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15]]) == 10\n assert candidate(rectangles = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90], [50, 100]]) == 45\n assert candidate(rectangles = [[7, 10], [14, 20], [21, 30], [28, 40], [35, 50], [42, 60], [49, 70], [56, 80], [63, 90], [70, 100], [77, 110], [84, 120]]) == 66\n assert candidate(rectangles = [[10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90]]) == 28\n assert candidate(rectangles = [[100, 200], [150, 300], [200, 400], [250, 500], [300, 600], [350, 700], [400, 800], [450, 900], [500, 1000]]) == 36\n assert candidate(rectangles = [[2, 5], [4, 10], [6, 15], [8, 20], [10, 25], [12, 30], [14, 35], [16, 40], [18, 45], [20, 50]]) == 45\n assert candidate(rectangles = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20], [11, 22], [12, 24]]) == 66\n assert candidate(rectangles = [[100, 200], [200, 400], [300, 600], [400, 800], [500, 1000], [600, 1200], [700, 1400], [800, 1600], [900, 1800], [1000, 2000]]) == 45\n assert candidate(rectangles = [[3, 9], [6, 18], [9, 27], [12, 36], [15, 45], [18, 54], [21, 63], [24, 72], [27, 81], [30, 90]]) == 45\n assert candidate(rectangles = [[1000, 2000], [1500, 3000], [2000, 4000], [2500, 5000], [3000, 6000], [3500, 7000], [4000, 8000], [4500, 9000], [5000, 10000]]) == 36\n assert candidate(rectangles = [[1, 1], [1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2], [1, 4], [4, 1], [2, 4], [4, 2], [3, 4], [4, 3]]) == 2\n assert candidate(rectangles = [[10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90], [50, 100]]) == 36\n assert candidate(rectangles = [[10, 5], [5, 10], [2, 1], [1, 2], [4, 2], [2, 4], [8, 4], [4, 8], [16, 8], [8, 16]]) == 20\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27], [10, 30], [11, 33], [12, 36], [13, 39]]) == 78\n assert candidate(rectangles = [[3, 4], [6, 8], [9, 12], [12, 16], [15, 20], [18, 24], [21, 28], [24, 32]]) == 28\n assert candidate(rectangles = [[5, 15], [10, 30], [15, 45], [20, 60], [25, 75]]) == 10\n assert candidate(rectangles = [[3, 9], [9, 27], [27, 81], [81, 243], [243, 729]]) == 10\n assert candidate(rectangles = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20], [11, 22], [12, 24], [13, 26], [14, 28], [15, 30]]) == 105\n assert candidate(rectangles = [[10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90], [50, 100], [55, 110]]) == 45\n assert candidate(rectangles = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == 0\n assert candidate(rectangles = [[1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2], [1, 4], [4, 1], [2, 4], [4, 2]]) == 2\n assert candidate(rectangles = [[5, 15], [10, 30], [15, 45], [20, 60], [25, 75], [30, 90], [35, 105], [40, 120]]) == 28\n assert candidate(rectangles = [[1, 100000], [2, 50000], [3, 33333], [4, 25000], [5, 20000], [6, 16667], [7, 14286], [8, 12500], [9, 11111], [10, 10000]]) == 0\n assert candidate(rectangles = [[2, 3], [4, 6], [6, 9], [8, 12], [10, 15], [12, 18], [14, 21], [16, 24], [18, 27], [20, 30]]) == 45\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27], [10, 30]]) == 45\n assert candidate(rectangles = [[2, 4], [4, 8], [8, 16], [16, 32], [32, 64], [64, 128], [128, 256], [256, 512], [512, 1024], [1024, 2048]]) == 45\n assert candidate(rectangles = [[5, 4], [10, 8], [15, 12], [20, 16], [25, 20], [30, 24], [35, 28], [40, 32], [45, 36], [50, 40]]) == 45\n assert candidate(rectangles = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 110], [12, 120], [13, 130], [14, 140], [15, 150]]) == 105\n assert candidate(rectangles = [[11, 22], [22, 44], [33, 66], [44, 88], [55, 110], [66, 132], [77, 154], [88, 176]]) == 28\n assert candidate(rectangles = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]]) == 45\n assert candidate(rectangles = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]]) == 45\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 105\n assert candidate(rectangles = [[1, 4], [2, 8], [3, 12], [4, 16], [5, 20], [6, 24], [7, 28], [8, 32], [9, 36], [10, 40]]) == 45\n assert candidate(rectangles = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 0\n assert candidate(rectangles = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]]) == 45\n assert candidate(rectangles = [[3, 4], [6, 8], [9, 12], [12, 16], [15, 20], [18, 24], [21, 28], [24, 32], [27, 36], [30, 40]]) == 45\n assert candidate(rectangles = [[3, 5], [6, 10], [9, 15], [12, 20], [15, 25], [18, 30]]) == 15\n assert candidate(rectangles = [[8, 12], [16, 24], [24, 36], [32, 48], [40, 60], [48, 72], [56, 84], [64, 96]]) == 28\n assert candidate(rectangles = [[100, 200], [200, 400], [300, 600], [400, 800], [500, 1000], [600, 1200]]) == 15\n assert candidate(rectangles = [[2, 1], [4, 2], [6, 3], [8, 4], [10, 5], [12, 6], [14, 7], [16, 8], [18, 9], [20, 10]]) == 45\n assert candidate(rectangles = [[100, 200], [200, 400], [300, 600], [400, 800], [500, 1000]]) == 10\n assert candidate(rectangles = [[3, 7], [6, 14], [9, 21], [12, 28], [15, 35], [18, 42], [21, 49], [24, 56], [27, 63], [30, 70]]) == 45\n assert candidate(rectangles = [[3, 9], [1, 3], [2, 6], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24]]) == 28\n assert candidate(rectangles = [[7, 14], [14, 28], [28, 56], [56, 112], [112, 224], [224, 448]]) == 15\n assert candidate(rectangles = [[3, 5], [6, 10], [9, 15], [12, 20], [15, 25], [18, 30], [21, 35], [24, 40], [27, 45], [30, 50]]) == 45\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21]]) == 21\n assert candidate(rectangles = [[7, 14], [14, 28], [21, 42], [28, 56], [35, 70], [42, 84]]) == 15\n assert candidate(rectangles = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 0\n assert candidate(rectangles = [[1, 1], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 0\n assert candidate(rectangles = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11]]) == 0\n assert candidate(rectangles = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 45\n assert candidate(rectangles = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9], [1000, 10]]) == 45\n assert candidate(rectangles = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]]) == 45\n assert candidate(rectangles = [[100000, 1], [1, 100000], [50000, 2], [2, 50000], [1, 1], [1, 2], [2, 1]]) == 0\n assert candidate(rectangles = [[1, 5], [2, 10], [3, 15], [4, 20], [5, 25], [6, 30], [7, 35], [8, 40], [9, 45], [10, 50], [11, 55], [12, 60]]) == 66\n assert candidate(rectangles = [[7, 14], [14, 28], [21, 42], [28, 56], [35, 70], [42, 84], [49, 98]]) == 21\n assert candidate(rectangles = [[3, 1], [6, 2], [9, 3], [12, 4], [15, 5], [18, 6], [21, 7], [24, 8], [27, 9], [30, 10]]) == 45\n assert candidate(rectangles = [[3, 4], [6, 8], [9, 12], [12, 16], [15, 20], [18, 24], [21, 28]]) == 21\n assert candidate(rectangles = [[1, 2], [2, 4], [4, 8], [8, 16], [16, 32], [32, 64], [64, 128], [128, 256], [256, 512], [512, 1024]]) == 45\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27], [10, 30], [11, 33], [12, 36]]) == 66\n assert candidate(rectangles = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90], [50, 100], [55, 110], [60, 120]]) == 66\n assert candidate(rectangles = [[7, 14], [14, 28], [21, 42], [28, 56], [35, 70], [42, 84], [49, 98], [56, 112]]) == 28\n assert candidate(rectangles = [[1, 2], [1, 3], [2, 4], [2, 6], [3, 6], [3, 9], [4, 8], [4, 12], [5, 10], [5, 15]]) == 20\n assert candidate(rectangles = [[5, 10], [15, 30], [25, 50], [35, 70], [45, 90], [55, 110], [65, 130], [75, 150], [85, 170], [95, 190]]) == 45\n assert candidate(rectangles = [[5, 7], [10, 14], [15, 21], [20, 28], [25, 35], [30, 42], [35, 49], [40, 56]]) == 28\n", "comparison": "exact"}, "public_tests": ["[[4,8],[3,6],[10,20],[15,30]]", "[[4,5],[7,8]]"], "hints": ["Store the rectangle height and width ratio in a hashmap.", "Traverse the ratios, and for each ratio, use the frequency of the ratio to add to the total pair count."], "metadata": {"canonical_parameter_names": ["rectangles"], "leetcode_dataset_entry_point": "Solution().interchangeableRectangles", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:47+00:00", "tests_total": 84, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "hash-table", "math", "counting", "number-theory"]}, "language": "python", "interface": {"raw_signature": "def interchangeableRectangles(self, rectangles: list[list[int]]) -> int:", "container": "Solution", "callable": "interchangeableRectangles", "parameters": [{"name": "rectangles", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2002, "task_id": "maximum-product-of-the-length-of-two-palindromic-subsequences", "difficulty": "Medium", "problem_description": "Given a string s, find two disjoint palindromic subsequences of s such that the product of their lengths is maximized. The two subsequences are disjoint if they do not both pick a character at the same index.\n\nReturn the maximum possible product of the lengths of the two palindromic subsequences.\n\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters. A string is palindromic if it reads the same forward and backward.\n\nExample 1:\n\nInput: s = \"leetcodecom\"\nOutput: 9\nExplanation: An optimal solution is to choose \"ete\" for the 1^st subsequence and \"cdc\" for the 2^nd subsequence.\nThe product of their lengths is: 3 * 3 = 9.\n\nExample 2:\n\nInput: s = \"bb\"\nOutput: 1\nExplanation: An optimal solution is to choose \"b\" (the first character) for the 1^st subsequence and \"b\" (the second character) for the 2^nd subsequence.\nThe product of their lengths is: 1 * 1 = 1.\n\nExample 3:\n\nInput: s = \"accbcaxxcxx\"\nOutput: 25\nExplanation: An optimal solution is to choose \"accca\" for the 1^st subsequence and \"xxcxx\" for the 2^nd subsequence.\nThe product of their lengths is: 5 * 5 = 25.\n\nConstraints:\n\n- 2 <= s.length <= 12\n- s consists of lowercase English letters only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"xyzyx\") == 6\n assert candidate(s = \"aabbcc\") == 4\n assert candidate(s = \"aaaa\") == 4\n assert candidate(s = \"accbcaxxcxx\") == 25\n assert candidate(s = \"madam\") == 6\n assert candidate(s = \"noon\") == 4\n assert candidate(s = \"racecar\") == 12\n assert candidate(s = \"deified\") == 12\n assert candidate(s = \"noonhighnoon\") == 35\n assert candidate(s = \"abcdcba\") == 12\n assert candidate(s = \"abacaba\") == 12\n assert candidate(s = \"level\") == 6\n assert candidate(s = \"abcdedcba\") == 20\n assert candidate(s = \"abcde\") == 1\n assert candidate(s = \"rotor\") == 6\n assert candidate(s = \"leetcodecom\") == 9\n assert candidate(s = \"bb\") == 1\n assert candidate(s = \"refer\") == 6\n assert candidate(s = \"aaabbbccc\") == 9\n assert candidate(s = \"xxyyzzxxyyzz\") == 36\n assert candidate(s = \"noonnoonnoon\") == 36\n assert candidate(s = \"repaper\") == 12\n assert candidate(s = \"abbaabbaabba\") == 36\n assert candidate(s = \"xyzzyxzyxz\") == 25\n assert candidate(s = \"aababababab\") == 30\n assert candidate(s = \"xyzyzyzyzyzy\") == 30\n assert candidate(s = \"aabbbbaa\") == 16\n assert candidate(s = \"abababa\") == 12\n assert candidate(s = \"babadab\") == 9\n assert candidate(s = \"referrefer\") == 25\n assert candidate(s = \"rotorrotor\") == 25\n assert candidate(s = \"abracadabra\") == 25\n assert candidate(s = \"abacdfgdcaba\") == 35\n assert candidate(s = \"mammam\") == 9\n assert candidate(s = \"abccbaabcba\") == 30\n assert candidate(s = \"redderredder\") == 36\n assert candidate(s = \"redivider\") == 20\n assert candidate(s = \"racecarabc\") == 15\n assert candidate(s = \"noonnoon\") == 16\n assert candidate(s = \"abcdzdcba\") == 20\n assert candidate(s = \"levelup\") == 6\n assert candidate(s = \"rotorositor\") == 25\n assert candidate(s = \"zzzzzzzzzzzz\") == 36\n assert candidate(s = \"xyzyxzyzyx\") == 25\n assert candidate(s = \"deeee\") == 4\n assert candidate(s = \"abcbaabcba\") == 25\n assert candidate(s = \"deeeevee\") == 12\n assert candidate(s = \"aaabaaa\") == 12\n assert candidate(s = \"aabbccddeeff\") == 4\n assert candidate(s = \"levellevel\") == 25\n assert candidate(s = \"madamimadam\") == 30\n assert candidate(s = \"mississippi\") == 24\n assert candidate(s = \"xyzzazxy\") == 15\n assert candidate(s = \"xyxxyxyxyxyx\") == 35\n assert candidate(s = \"programming\") == 12\n assert candidate(s = \"zyxzyxzyxzyx\") == 36\n assert candidate(s = \"zzzzzyzzzz\") == 25\n assert candidate(s = \"aabbaabbaa\") == 25\n assert candidate(s = \"xyzabcdcba\") == 12\n assert candidate(s = \"optimization\") == 15\n assert candidate(s = \"abccbaabc\") == 15\n", "comparison": "exact"}, "public_tests": ["\"leetcodecom\"", "\"bb\"", "\"accbcaxxcxx\""], "hints": ["Could you generate all possible pairs of disjoint subsequences?", "Could you find the maximum length palindrome in each subsequence for a pair of disjoint subsequences?"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxProduct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:49+00:00", "tests_total": 81, "tests_dropped": 20, "flags": ["has_images"], "topic_tags": ["string", "dynamic-programming", "backtracking", "bit-manipulation", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def maxProduct(self, s: str) -> int:", "container": "Solution", "callable": "maxProduct", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2003, "task_id": "smallest-missing-genetic-value-in-each-subtree", "difficulty": "Hard", "problem_description": "There is a family tree rooted at 0 consisting of n nodes numbered 0 to n - 1. You are given a 0-indexed integer array parents, where parents[i] is the parent for node i. Since node 0 is the root, parents[0] == -1.\n\nThere are 10^5 genetic values, each represented by an integer in the inclusive range [1, 10^5]. You are given a 0-indexed integer array nums, where nums[i] is a distinct genetic value for node i.\n\nReturn an array ans of length n where ans[i] is the smallest genetic value that is missing from the subtree rooted at node i.\n\nThe subtree rooted at a node x contains node x and all of its descendant nodes.\n\nExample 1:\n\nInput: parents = [-1,0,0,2], nums = [1,2,3,4]\nOutput: [5,1,1,1]\nExplanation: The answer for each subtree is calculated as follows:\n- 0: The subtree contains nodes [0,1,2,3] with values [1,2,3,4]. 5 is the smallest missing value.\n- 1: The subtree contains only node 1 with value 2. 1 is the smallest missing value.\n- 2: The subtree contains nodes [2,3] with values [3,4]. 1 is the smallest missing value.\n- 3: The subtree contains only node 3 with value 4. 1 is the smallest missing value.\n\nExample 2:\n\nInput: parents = [-1,0,1,0,3,3], nums = [5,4,6,2,1,3]\nOutput: [7,1,1,4,2,1]\nExplanation: The answer for each subtree is calculated as follows:\n- 0: The subtree contains nodes [0,1,2,3,4,5] with values [5,4,6,2,1,3]. 7 is the smallest missing value.\n- 1: The subtree contains nodes [1,2] with values [4,6]. 1 is the smallest missing value.\n- 2: The subtree contains only node 2 with value 6. 1 is the smallest missing value.\n- 3: The subtree contains nodes [3,4,5] with values [2,1,3]. 4 is the smallest missing value.\n- 4: The subtree contains only node 4 with value 1. 2 is the smallest missing value.\n- 5: The subtree contains only node 5 with value 3. 1 is the smallest missing value.\n\nExample 3:\n\nInput: parents = [-1,2,3,0,2,4,1], nums = [2,3,4,5,6,7,8]\nOutput: [1,1,1,1,1,1,1]\nExplanation: The value 1 is missing from all the subtrees.\n\nConstraints:\n\n- n == parents.length == nums.length\n- 2 <= n <= 10^5\n- 0 <= parents[i] <= n - 1 for i != 0\n- parents[0] == -1\n- parents represents a valid tree.\n- 1 <= nums[i] <= 10^5\n- Each nums[i] is distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(parents = [-1, 0, 0, 2],nums = [1, 2, 3, 4]) == [5, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 0, 3, 3],nums = [5, 4, 6, 2, 1, 3]) == [7, 1, 1, 4, 2, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2],nums = [1, 2, 3, 4, 5, 6, 7]) == [8, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 2, 3, 0, 2, 4, 1],nums = [2, 3, 4, 5, 6, 7, 8]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3],nums = [7, 1, 3, 2, 6, 5, 4]) == [8, 2, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],nums = [5, 1, 12, 13, 1, 2, 6, 7, 8, 9, 3, 4, 10, 11, 14, 15]) == [16, 5, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3],nums = [10, 1, 2, 9, 8, 7, 6, 5, 4]) == [3, 2, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == [19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 0, 6, 7, 8],nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [10, 6, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [11, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4],nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == [12, 4, 1, 1, 2, 1, 1, 1, 1, 2, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [11, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums = [5, 1, 3, 7, 9, 2, 6, 4, 8, 10, 11]) == [12, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],nums = [2, 1, 14, 13, 8, 15, 6, 9, 4, 10, 5, 11, 3, 12, 7, 16]) == [17, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 3, 1, 3, 1, 1, 1, 1, 2]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [23, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],nums = [20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [21, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4],nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 101]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums = [10, 20, 30, 40, 1, 11, 21, 31, 41, 2, 12, 22, 32, 42, 3, 13, 23, 33, 4, 14, 24, 29]) == [5, 5, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == [23, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums = [40, 30, 20, 10, 35, 31, 25, 21, 34, 32, 24, 22, 33, 26, 23, 27, 36, 28, 29, 37, 38, 39]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 3, 3, 4, 4],nums = [1, 2, 3, 4, 5, 6, 7, 8]) == [9, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums = [10, 9, 1, 2, 3, 4, 5, 6, 7, 8, 15, 16, 17, 18, 19, 20]) == [11, 10, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],nums = [3, 1, 2, 5, 7, 8, 10, 12, 13, 9, 4, 6, 11, 14, 15, 16, 17, 18, 19, 20, 21]) == [22, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13]) == [14, 4, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == [12, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3],nums = [13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [14, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 22]) == [23, 2, 2, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3],nums = [8, 9, 10, 1, 2, 3, 4, 5, 6]) == [7, 3, 1, 2, 1, 1, 1, 1, 1]\n", "comparison": "exact"}, "public_tests": ["[-1,0,0,2]\n[1,2,3,4]", "[-1,0,1,0,3,3]\n[5,4,6,2,1,3]", "[-1,2,3,0,2,4,1]\n[2,3,4,5,6,7,8]"], "hints": ["If the subtree doesn't contain 1, then the missing value will always be 1.", "What data structure allows us to dynamically update the values that are currently not present?"], "metadata": {"canonical_parameter_names": ["parents", "nums"], "leetcode_dataset_entry_point": "Solution().smallestMissingValueSubtree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:52+00:00", "tests_total": 38, "tests_dropped": 4, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "tree", "depth-first-search", "union-find"]}, "language": "python", "interface": {"raw_signature": "def smallestMissingValueSubtree(self, parents: list[int], nums: list[int]) -> list[int]:", "container": "Solution", "callable": "smallestMissingValueSubtree", "parameters": [{"name": "parents", "type": "list[int]"}, {"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2006, "task_id": "count-number-of-pairs-with-absolute-difference-k", "difficulty": "Easy", "problem_description": "Given an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] - nums[j]| == k.\n\nThe value of |x| is defined as:\n\n- x if x >= 0.\n- -x if x < 0.\n\nExample 1:\n\nInput: nums = [1,2,2,1], k = 1\nOutput: 4\nExplanation: The pairs with an absolute difference of 1 are:\n- [1,2,2,1]\n- [1,2,2,1]\n- [1,2,2,1]\n- [1,2,2,1]\n\nExample 2:\n\nInput: nums = [1,3], k = 3\nOutput: 0\nExplanation: There are no pairs with an absolute difference of 3.\n\nExample 3:\n\nInput: nums = [3,2,1,5,4], k = 2\nOutput: 3\nExplanation: The pairs with an absolute difference of 2 are:\n- [3,2,1,5,4]\n- [3,2,1,5,4]\n- [3,2,1,5,4]\n\nConstraints:\n\n- 1 <= nums.length <= 200\n- 1 <= nums[i] <= 100\n- 1 <= k <= 99\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 1, 100, 1, 100],k = 99) == 6\n assert candidate(nums = [5, 4, 3, 2, 1],k = 4) == 1\n assert candidate(nums = [3, 2, 1, 5, 4],k = 2) == 3\n assert candidate(nums = [5, 1, 4, 1],k = 2) == 0\n assert candidate(nums = [1, 3],k = 3) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],k = 20) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 4\n assert candidate(nums = [1, 2, 2, 1],k = 1) == 4\n assert candidate(nums = [100, 1, 100, 1],k = 99) == 4\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 4) == 32\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82],k = 9) == 9\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93],k = 99) == 1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86],k = 1) == 14\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],k = 4) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 20\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 3, 6, 9, 12, 15],k = 3) == 22\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 1) == 40\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],k = 4) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50],k = 30) == 16\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 1) == 36\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43],k = 1) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 4\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 8) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50],k = 10) == 16\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 5, 15, 25, 35, 45],k = 10) == 22\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],k = 4) == 13\n assert candidate(nums = [55, 45, 35, 25, 15, 5, 5, 15, 25, 35, 45],k = 10) == 18\n assert candidate(nums = [99, 100, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94],k = 1) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 2) == 19\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],k = 2) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 9\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 9) == 1\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 1) == 9\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 1) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == 17\n assert candidate(nums = [99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9],k = 97) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1) == 14\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],k = 9) == 26\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30],k = 10) == 11\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 1) == 9\n assert candidate(nums = [50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55],k = 1) == 125\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 2) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 32\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85],k = 2) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 15\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 2) == 12\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 2) == 19\n assert candidate(nums = [10, 10, 10, 10, 11, 11, 12, 12, 13],k = 1) == 14\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33],k = 3) == 10\n assert candidate(nums = [10, 20, 30, 20, 10, 30, 20, 10, 30],k = 10) == 18\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 2) == 32\n assert candidate(nums = [90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40],k = 5) == 10\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 2) == 14\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85],k = 3) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 19\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 10) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],k = 2) == 24\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 1) == 16\n assert candidate(nums = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 9],k = 10) == 10\n assert candidate(nums = [10, 12, 15, 7, 5, 3, 10, 15],k = 5) == 7\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],k = 9) == 11\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 9\n assert candidate(nums = [10, 10, 20, 20, 30, 30],k = 10) == 8\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79],k = 4) == 19\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 10) == 9\n assert candidate(nums = [100, 1, 100, 2, 100, 3, 100, 4, 100, 5],k = 99) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 5\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],k = 4) == 24\n assert candidate(nums = [8, 18, 28, 38, 48, 58, 68, 78, 88, 98],k = 10) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 36\n assert candidate(nums = [50, 60, 70, 80, 90, 50, 60, 70, 80, 90, 50, 60],k = 20) == 16\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50],k = 1) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 1) == 29\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 1) == 32\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 2) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 13\n assert candidate(nums = [50, 50, 50, 51, 51, 52, 52, 52, 53, 53],k = 1) == 18\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 4) == 13\n assert candidate(nums = [5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15],k = 5) == 50\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 3) == 8\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 6\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91],k = 9) == 10\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 1\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],k = 7) == 13\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100],k = 9) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 60\n", "comparison": "exact"}, "public_tests": ["[1,2,2,1]\n1", "[1,3]\n3", "[3,2,1,5,4]\n2"], "hints": ["Can we check every possible pair?", "Can we use a nested for loop to solve this problem?"], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countKDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:56+00:00", "tests_total": 106, "tests_dropped": 18, "flags": [], "topic_tags": ["array", "hash-table", "counting"]}, "language": "python", "interface": {"raw_signature": "def countKDifference(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "countKDifference", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2007, "task_id": "find-original-array-from-doubled-array", "difficulty": "Medium", "problem_description": "An integer array original is transformed into a doubled array changed by appending twice the value of every element in original, and then randomly shuffling the resulting array.\n\nGiven an array changed, return original if changed is a doubled array. If changed is not a doubled array, return an empty array. The elements in original may be returned in any order.\n\nExample 1:\n\nInput: changed = [1,3,4,2,6,8]\nOutput: [1,3,4]\nExplanation: One possible original array could be [1,3,4]:\n- Twice the value of 1 is 1 * 2 = 2.\n- Twice the value of 3 is 3 * 2 = 6.\n- Twice the value of 4 is 4 * 2 = 8.\nOther original arrays could be [4,3,1] or [3,1,4].\n\nExample 2:\n\nInput: changed = [6,3,0,1]\nOutput: []\nExplanation: changed is not a doubled array.\n\nExample 3:\n\nInput: changed = [1]\nOutput: []\nExplanation: changed is not a doubled array.\n\nConstraints:\n\n- 1 <= changed.length <= 10^5\n- 0 <= changed[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(changed=[2, 1, 4, 2, 8, 4]), [1, 2, 4])\n assert answers_match(candidate(changed=[2, 4, 2, 4]), [2, 2])\n assert answers_match(candidate(changed=[1, 2, 3, 6, 9, 18]), [1, 3, 9])\n assert answers_match(candidate(changed=[8, 4, 2, 1, 16, 8, 4, 2]), [1, 2, 4, 8])\n assert answers_match(candidate(changed=[5, 3, 10, 0, 6, 9, 18, 15]), [])\n assert answers_match(candidate(changed=[0, 0, 0, 0]), [0, 0])\n assert answers_match(candidate(changed=[100, 200, 300, 400, 500, 1000]), [])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 6, 8, 12, 16]), [])\n assert answers_match(candidate(changed=[1, 2, 3, 6, 12, 24, 48, 96]), [1, 3, 12, 48])\n assert answers_match(candidate(changed=[5, 3, 10, 15, 2, 6]), [])\n assert answers_match(candidate(changed=[1, 3, 4, 2, 6, 8]), [1, 3, 4])\n assert answers_match(candidate(changed=[1, 2]), [1])\n assert answers_match(candidate(changed=[1]), [])\n assert answers_match(candidate(changed=[2, 1, 2, 4, 4, 8]), [1, 2, 4])\n assert answers_match(candidate(changed=[6, 3, 0, 1]), [])\n assert answers_match(candidate(changed=[5, 10, 15, 20, 25, 50]), [])\n assert answers_match(candidate(changed=[1, 2, 3, 6, 4, 8]), [1, 3, 4])\n assert answers_match(candidate(changed=[2, 4, 2, 4, 8, 8]), [])\n assert answers_match(candidate(changed=[2, 1]), [1])\n assert answers_match(candidate(changed=[5, 3, 10, 15, 20, 6]), [])\n assert answers_match(candidate(changed=[3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 60, 120, 180, 240, 300]), [])\n assert answers_match(candidate(changed=[3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]), [])\n assert answers_match(candidate(changed=[3, 6, 6, 12, 12, 12, 24, 24, 24, 24, 24, 24, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48]), [])\n assert answers_match(candidate(changed=[2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024]), [2, 2, 8, 8, 32, 32, 128, 128, 512, 512])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 6, 8, 9, 12, 12, 16, 18, 24, 24, 32, 36, 48, 48, 64, 72, 96, 96, 128, 144, 192, 192]), [])\n assert answers_match(candidate(changed=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]), [])\n assert answers_match(candidate(changed=[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]), [])\n assert answers_match(candidate(changed=[19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 380, 570, 760, 950, 1140, 1330, 1520, 1710, 1900]), [])\n assert answers_match(candidate(changed=[1, 1, 2, 2, 3, 3, 6, 6, 9, 9, 12, 12, 18, 18, 24, 24, 36, 36, 48, 48, 54, 54, 72, 72, 96, 96, 108, 108, 144, 144, 192, 192]), [])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, 40]), [])\n assert answers_match(candidate(changed=[1, 1, 2, 2, 3, 3, 6, 6, 9, 9, 18, 18]), [1, 1, 3, 3, 9, 9])\n assert answers_match(candidate(changed=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]), [])\n assert answers_match(candidate(changed=[0, 0, 0, 0, 0, 0]), [0, 0, 0])\n assert answers_match(candidate(changed=[2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256]), [])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 6, 8, 9, 12, 12, 16, 18, 24, 24, 32, 36, 48, 48, 64, 72, 96, 96, 128, 144, 192, 192, 256, 288, 384, 384]), [])\n assert answers_match(candidate(changed=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19])\n assert answers_match(candidate(changed=[3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]), [])\n assert answers_match(candidate(changed=[11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 222, 333, 444, 555, 666, 777, 888, 999, 1100, 2200, 3300, 4400, 5500, 6600, 7700, 8800, 9900]), [])\n assert answers_match(candidate(changed=[7, 14, 7, 14, 28, 28, 56, 56, 112, 112, 224, 224]), [7, 7, 28, 28, 112, 112])\n assert answers_match(candidate(changed=[1, 2, 3, 6, 9, 18, 27, 54, 81, 162, 243, 486, 729, 1458, 2187, 4374, 6561, 13122, 19683, 39366]), [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683])\n assert answers_match(candidate(changed=[3, 6, 12, 15, 30, 60, 75, 150, 225, 450, 900]), [])\n assert answers_match(candidate(changed=[1, 2, 2, 4, 4, 4, 8, 8, 8, 8, 16, 16, 16, 16, 16, 32, 32, 32, 32, 32, 64, 64, 64, 64, 64, 128, 128, 128, 128, 128, 256, 256, 256, 256, 256, 512, 512, 512, 512, 512, 1024, 1024, 1024, 1024, 1024, 2048, 2048, 2048, 2048, 2048]), [])\n assert answers_match(candidate(changed=[5, 10, 15, 20, 25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400]), [])\n assert answers_match(candidate(changed=[15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 300, 450, 600, 750, 900]), [])\n assert answers_match(candidate(changed=[1023, 2046, 3069, 4092, 5115, 6138, 7161, 8184, 9207, 10230, 2046, 4092, 6138, 8184, 10230, 12276, 14322, 16368, 18414, 20460, 3069, 6138, 9207, 12276, 15345, 18414, 21483, 24540, 27597, 30654]), [])\n assert answers_match(candidate(changed=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]), [])\n assert answers_match(candidate(changed=[7, 14, 14, 21, 28, 28, 35, 42, 42, 56, 56, 70, 70, 84, 84, 105, 105, 140, 140, 168, 168, 210, 210, 280, 280]), [])\n assert answers_match(candidate(changed=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 40, 80, 120, 160, 200, 240, 280, 320, 360, 400]), [5, 10, 15, 20, 20, 25, 30, 35, 40, 40, 45, 50, 60, 80, 100, 120, 140, 160, 180, 200])\n assert answers_match(candidate(changed=[23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 460, 690, 920, 1150, 1380, 1610, 1840, 2070, 2300]), [])\n assert answers_match(candidate(changed=[0, 0, 0, 0, 0, 0, 0]), [])\n assert answers_match(candidate(changed=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60]), [])\n assert answers_match(candidate(changed=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]), [])\n assert answers_match(candidate(changed=[1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40]), [])\n assert answers_match(candidate(changed=[13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 260, 520, 780, 1040, 1300]), [])\n assert answers_match(candidate(changed=[1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]), [])\n assert answers_match(candidate(changed=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]), [])\n assert answers_match(candidate(changed=[1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32]), [])\n assert answers_match(candidate(changed=[1, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256]), [])\n assert answers_match(candidate(changed=[5, 10, 10, 20, 20, 40, 40, 80, 80, 160, 160, 320, 320]), [])\n assert answers_match(candidate(changed=[3, 6, 9, 18, 27, 54, 81, 162, 243, 486]), [3, 9, 27, 81, 243])\n assert answers_match(candidate(changed=[1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024]), [])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40]), [])\n assert answers_match(candidate(changed=[17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 340, 510, 680, 850, 1020, 1190, 1360, 1530, 1700]), [])\n assert answers_match(candidate(changed=[1, 2, 2, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16]), [])\n assert answers_match(candidate(changed=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000]), [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000])\n assert answers_match(candidate(changed=[5, 10, 10, 15, 20, 20, 25, 30, 30, 40, 40, 50, 50, 60, 60, 75, 75, 100, 100, 120, 120, 150, 150, 200, 200]), [])\n assert answers_match(candidate(changed=[3, 6, 9, 12, 18, 24, 36, 48, 54, 72, 96, 108, 144, 192, 216, 288, 384, 432, 576, 768, 864, 1152, 1536, 1728, 2304, 3072, 3456, 4608, 6144, 6912, 9216, 12288, 13824, 18432, 24576, 27648, 36864, 49152, 55296, 73728, 98304]), [])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024]), [])\n assert answers_match(candidate(changed=[1, 1, 2, 2, 3, 3, 4, 4, 6, 6, 8, 8, 12, 12, 16, 16, 24, 24, 32, 32, 48, 48, 64, 64, 96, 96, 128, 128]), [1, 1, 3, 3, 4, 4, 12, 12, 16, 16, 48, 48, 64, 64])\n assert answers_match(candidate(changed=[2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]), [])\n assert answers_match(candidate(changed=[9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225, 234, 243, 252, 261, 270]), [])\n assert answers_match(candidate(changed=[1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64, 128, 128, 128, 256, 256, 256, 512, 512, 512]), [1, 1, 1, 4, 4, 4, 16, 16, 16, 64, 64, 64, 256, 256, 256])\n assert answers_match(candidate(changed=[2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]), [2, 8, 32, 128, 512])\n assert answers_match(candidate(changed=[2, 4, 4, 8, 8, 16, 16, 32, 32, 64]), [2, 4, 8, 16, 32])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200]), [])\n assert answers_match(candidate(changed=[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 140, 280, 420, 560, 700]), [])\n assert answers_match(candidate(changed=[1, 2, 2, 3, 6, 6, 12, 12, 24, 24, 48, 48]), [])\n assert answers_match(candidate(changed=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512]), [1, 4, 16, 64, 256])\n assert answers_match(candidate(changed=[1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024, 2048, 2048, 4096, 4096, 8192, 8192, 16384, 16384]), [])\n assert answers_match(candidate(changed=[2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64]), [])\n assert answers_match(candidate(changed=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]), [])\n assert answers_match(candidate(changed=[10, 20, 30, 40, 50, 60, 20, 40, 60, 80, 100, 120, 40, 80, 120, 160, 200, 240, 80, 160, 240, 320, 400, 480, 160, 320, 480, 640, 800, 960]), [])\n assert answers_match(candidate(changed=[3, 3, 6, 6, 9, 9, 18, 18, 27, 27]), [])\n assert answers_match(candidate(changed=[1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024]), [1, 2, 4, 8, 16, 32, 64, 128, 256, 512])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40]), [])\n assert answers_match(candidate(changed=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]), [5, 10, 15, 20, 25, 30, 35, 40, 45, 50])\n assert answers_match(candidate(changed=[1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64]), [])\n assert answers_match(candidate(changed=[2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]), [2, 8, 32, 128, 512, 2048, 8192, 32768])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 60, 120, 180, 240, 300]), [])\n assert answers_match(candidate(changed=[9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 180, 360, 540, 720, 900]), [])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]), [])\n assert answers_match(candidate(changed=[9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 18, 36, 54, 72, 90, 108, 126, 144, 162, 180]), [])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]), [])\n assert answers_match(candidate(changed=[10, 20, 30, 40, 50, 60, 20, 40, 60, 80, 100, 120]), [10, 20, 30, 40, 50, 60])\n assert answers_match(candidate(changed=[1, 2, 2, 4, 4, 8, 8, 16, 16, 32]), [1, 2, 4, 8, 16])\n assert answers_match(candidate(changed=[11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 22, 44, 66, 88, 110, 132, 154, 176, 198, 220, 33, 66, 99, 132, 165, 198, 231, 264, 297, 330]), [])\n assert answers_match(candidate(changed=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150]), [])\n assert answers_match(candidate(changed=[1, 1, 2, 3, 3, 6, 6, 12, 12, 24, 24, 48, 48, 96, 96, 192, 192, 384, 384, 768, 768, 1536, 1536, 3072, 3072, 6144, 6144, 12288, 12288, 24576, 24576]), [])\n assert answers_match(candidate(changed=[29, 58, 87, 116, 145, 174, 203, 232, 261, 290, 580, 870, 1160, 1450, 1740, 2030, 2320, 2610, 2900]), [])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 1088, 1152, 1216, 1280, 1344, 1408, 1472, 1536, 1600, 128, 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1408, 1536, 1664, 1792, 1920, 2048, 2176, 2304, 2432, 2560, 2688, 2816, 2944, 3072, 3200, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5632, 5888, 6144, 6400]), [])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]), [])\n assert answers_match(candidate(changed=[5, 10, 10, 20, 20, 40, 40, 80, 80, 160, 160, 320, 320, 640, 640, 1280, 1280, 2560, 2560, 5120]), [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560])\n assert answers_match(candidate(changed=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140, 160, 180, 200, 240, 280, 320, 360, 400]), [])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])\n assert answers_match(candidate(changed=[1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512]), [1, 1, 4, 4, 16, 16, 64, 64, 256, 256])\n assert answers_match(candidate(changed=[1, 2, 3, 6, 9, 12, 18, 27, 36, 54, 81, 108, 162, 243, 324, 486, 729, 972, 1458, 2187]), [])\n assert answers_match(candidate(changed=[100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]), [])\n assert answers_match(candidate(changed=[5, 10, 15, 20, 25, 50, 75, 100, 125, 250, 375, 500, 625, 1250]), [])\n assert answers_match(candidate(changed=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40]), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20])\n assert answers_match(candidate(changed=[100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200]), [100, 400, 1600, 6400, 25600])\n assert answers_match(candidate(changed=[1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024]), [])\n assert answers_match(candidate(changed=[1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 24, 30, 40, 60, 120]), [])\n assert answers_match(candidate(changed=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), [0, 0, 0, 0, 0])\n", "comparison": "unordered"}, "public_tests": ["[1,3,4,2,6,8]", "[6,3,0,1]", "[1]"], "hints": ["If changed is a doubled array, you should be able to delete elements and their doubled values until the array is empty.", "Which element is guaranteed to not be a doubled value? It is the smallest element.", "After removing the smallest element and its double from changed, is there another number that is guaranteed to not be a doubled value?"], "metadata": {"canonical_parameter_names": ["changed"], "leetcode_dataset_entry_point": "Solution().findOriginalArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:37:59+00:00", "tests_total": 124, "tests_dropped": 11, "flags": ["any_order"], "topic_tags": ["array", "hash-table", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def findOriginalArray(self, changed: list[int]) -> list[int]:", "container": "Solution", "callable": "findOriginalArray", "parameters": [{"name": "changed", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2008, "task_id": "maximum-earnings-from-taxi", "difficulty": "Medium", "problem_description": "There are n points on a road you are driving your taxi on. The n points on the road are labeled from 1 to n in the direction you are going, and you want to drive from point 1 to point n to make money by picking up passengers. You cannot change the direction of the taxi.\n\nThe passengers are represented by a 0-indexed 2D integer array rides, where rides[i] = [start_i, end_i, tip_i] denotes the i^th passenger requesting a ride from point start_i to point end_i who is willing to give a tip_i dollar tip.\n\nFor each passenger i you pick up, you earn end_i - start_i + tip_i dollars. You may only drive at most one passenger at a time.\n\nGiven n and rides, return the maximum number of dollars you can earn by picking up the passengers optimally.\n\nNote: You may drop off a passenger and pick up a different passenger at the same point.\n\nExample 1:\n\nInput: n = 5, rides = [[2,5,4],[1,5,1]]\nOutput: 7\nExplanation: We can pick up passenger 0 to earn 5 - 2 + 4 = 7 dollars.\n\nExample 2:\n\nInput: n = 20, rides = [[1,6,1],[3,10,2],[10,12,3],[11,12,2],[12,15,2],[13,18,1]]\nOutput: 20\nExplanation: We will pick up the following passengers:\n- Drive passenger 1 from point 3 to point 10 for a profit of 10 - 3 + 2 = 9 dollars.\n- Drive passenger 2 from point 10 to point 12 for a profit of 12 - 10 + 3 = 5 dollars.\n- Drive passenger 5 from point 13 to point 18 for a profit of 18 - 13 + 1 = 6 dollars.\nWe earn 9 + 5 + 6 = 20 dollars in total.\n\nConstraints:\n\n- 1 <= n <= 10^5\n- 1 <= rides.length <= 3 * 10^4\n- rides[i].length == 3\n- 1 <= start_i < end_i <= n\n- 1 <= tip_i <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 100,rides = [[1, 10, 50], [20, 30, 25], [50, 60, 100], [70, 80, 75], [90, 100, 200]]) == 499\n assert candidate(n = 10,rides = [[1, 3, 2], [2, 5, 3], [4, 6, 1]]) == 7\n assert candidate(n = 30,rides = [[1, 10, 10], [10, 20, 10], [20, 30, 10]]) == 59\n assert candidate(n = 15,rides = [[1, 2, 5], [2, 3, 10], [3, 4, 20], [4, 5, 30]]) == 69\n assert candidate(n = 5,rides = [[2, 5, 4], [1, 5, 1]]) == 7\n assert candidate(n = 15,rides = [[1, 4, 1], [2, 6, 2], [3, 7, 3], [4, 8, 4], [5, 9, 5]]) == 13\n assert candidate(n = 10,rides = [[1, 3, 2], [2, 5, 3], [4, 8, 2], [6, 10, 3]]) == 13\n assert candidate(n = 100,rides = [[1, 10, 50], [2, 20, 60], [3, 30, 70], [4, 40, 80], [5, 50, 90]]) == 135\n assert candidate(n = 30,rides = [[1, 15, 10], [16, 30, 5]]) == 43\n assert candidate(n = 15,rides = [[1, 4, 3], [3, 7, 4], [7, 10, 5]]) == 16\n assert candidate(n = 15,rides = [[1, 4, 5], [2, 6, 3], [3, 8, 7], [5, 9, 4]]) == 16\n assert candidate(n = 20,rides = [[1, 6, 1], [3, 10, 2], [10, 12, 3], [11, 12, 2], [12, 15, 2], [13, 18, 1]]) == 20\n assert candidate(n = 10,rides = [[1, 3, 5], [2, 5, 2], [5, 8, 3]]) == 13\n assert candidate(n = 10,rides = [[1, 3, 2], [2, 5, 3], [5, 7, 2], [6, 9, 1]]) == 10\n assert candidate(n = 100000,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1]]) == 20\n assert candidate(n = 1000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 1000, 999]]) == 2043\n assert candidate(n = 30000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [29998, 29999, 1], [29999, 30000, 100]]) == 112\n assert candidate(n = 10000,rides = [[1, 500, 100], [501, 1000, 200], [1001, 1500, 300], [1501, 2000, 400], [2001, 2500, 500], [2501, 3000, 600], [3001, 3500, 700], [3501, 4000, 800], [4001, 4500, 900], [4501, 5000, 1000], [5001, 10000, 4500]]) == 19989\n assert candidate(n = 75000,rides = [[1, 25000, 10000], [25000, 50000, 10000], [50000, 75000, 10000]]) == 104999\n assert candidate(n = 5000,rides = [[1, 2500, 2500], [2501, 5000, 2500], [1, 5000, 5000]]) == 9999\n assert candidate(n = 100,rides = [[1, 5, 10], [5, 10, 10], [10, 15, 10], [15, 20, 10], [20, 25, 10], [25, 30, 10], [30, 35, 10], [35, 40, 10], [40, 45, 10], [45, 50, 10], [50, 55, 10], [55, 60, 10], [60, 65, 10], [65, 70, 10], [70, 75, 10], [75, 80, 10], [80, 85, 10], [85, 90, 10], [90, 95, 10], [95, 100, 10]]) == 299\n assert candidate(n = 1000,rides = [[1, 500, 1000], [501, 1000, 500], [1, 250, 200], [251, 500, 150], [501, 750, 125], [751, 1000, 100]]) == 2498\n assert candidate(n = 50000,rides = [[1, 5, 5], [2, 6, 7], [3, 7, 8], [4, 8, 9], [5, 9, 10], [6, 10, 12], [7, 11, 14], [8, 12, 16], [9, 13, 18], [10, 14, 20]]) == 51\n assert candidate(n = 30000,rides = [[1, 10000, 5000], [10001, 20000, 5000], [20001, 30000, 5000], [1, 20000, 10000], [10001, 30000, 10000], [1, 30000, 15000]]) == 44999\n assert candidate(n = 30000,rides = [[1, 10000, 5000], [10001, 20000, 10000], [20001, 30000, 15000], [1, 5000, 2500], [5001, 10000, 5000], [10001, 15000, 7500], [15001, 20000, 10000], [20001, 25000, 12500], [25001, 30000, 15000], [1, 2000, 1000], [2001, 4000, 2000], [4001, 6000, 3000], [6001, 8000, 4000], [8001, 10000, 5000], [10001, 12000, 6000], [12001, 14000, 7000], [14001, 16000, 8000], [16001, 18000, 9000], [18001, 20000, 10000], [20001, 22000, 11000], [22001, 24000, 12000], [24001, 26000, 13000], [26001, 28000, 14000], [28001, 30000, 15000]]) == 149985\n assert candidate(n = 30000,rides = [[1, 30000, 15000], [2, 29999, 14999], [3, 29998, 14998], [4, 29997, 14997], [5, 29996, 14996], [6, 29995, 14995], [7, 29994, 14994], [8, 29993, 14993], [9, 29992, 14992], [10, 29991, 14991]]) == 44999\n assert candidate(n = 50000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5]]) == 20\n assert candidate(n = 80000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 80000, 79999]]) == 160043\n assert candidate(n = 100000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]]) == 135\n assert candidate(n = 50000,rides = [[1, 1000, 500], [1001, 2000, 1000], [2001, 3000, 1500], [3001, 4000, 2000], [4001, 5000, 2500], [5001, 10000, 3000], [10001, 15000, 3500], [15001, 20000, 4000], [20001, 25000, 4500], [25001, 30000, 5000], [30001, 35000, 5500], [35001, 40000, 6000], [40001, 45000, 6500], [45001, 50000, 7000]]) == 102486\n assert candidate(n = 10000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [20, 21, 20], [21, 22, 21], [22, 23, 22], [23, 24, 23], [24, 25, 24], [25, 26, 25], [26, 27, 26], [27, 28, 27], [28, 29, 28], [29, 30, 29], [30, 31, 30], [31, 32, 31], [32, 33, 32], [33, 34, 33], [34, 35, 34], [35, 36, 35], [36, 37, 36], [37, 38, 37], [38, 39, 38], [39, 40, 39], [40, 41, 40]]) == 860\n assert candidate(n = 200,rides = [[1, 100, 50], [2, 199, 49], [3, 198, 48], [4, 197, 47], [5, 196, 46], [6, 195, 45], [7, 194, 44], [8, 193, 43], [9, 192, 42], [10, 191, 41]]) == 246\n assert candidate(n = 100,rides = [[10, 20, 10], [20, 30, 20], [30, 40, 30], [40, 50, 40], [50, 60, 50], [60, 70, 60], [70, 80, 70], [80, 90, 80], [90, 100, 90], [1, 10, 5], [2, 20, 15], [3, 30, 25], [4, 40, 35], [5, 50, 45], [6, 60, 55], [7, 70, 65], [8, 80, 75], [9, 90, 85], [10, 100, 95]]) == 554\n assert candidate(n = 10000,rides = [[1, 10000, 10000], [2, 9999, 9999], [3, 9998, 9998], [4, 9997, 9997], [5, 9996, 9996]]) == 19999\n assert candidate(n = 10000,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1]]) == 38\n assert candidate(n = 50,rides = [[1, 3, 2], [3, 5, 3], [5, 7, 2], [7, 9, 1], [9, 11, 5], [11, 13, 4], [13, 15, 6], [15, 17, 2], [17, 19, 3], [19, 21, 7], [21, 23, 4], [23, 25, 5], [25, 27, 2], [27, 29, 3], [29, 31, 1], [31, 33, 5], [33, 35, 4], [35, 37, 6], [37, 39, 2], [39, 41, 3], [41, 43, 7], [43, 45, 4], [45, 47, 5], [47, 49, 2], [49, 50, 3]]) == 140\n assert candidate(n = 100,rides = [[1, 10, 50], [11, 20, 50], [21, 30, 50], [31, 40, 50], [41, 50, 50], [51, 60, 50], [61, 70, 50], [71, 80, 50], [81, 90, 50], [91, 100, 50]]) == 590\n assert candidate(n = 30000,rides = [[1, 10, 50], [11, 20, 100], [21, 30, 150], [31, 40, 200], [41, 50, 250], [51, 60, 300], [61, 70, 350], [71, 80, 400], [81, 90, 450], [91, 100, 500], [101, 30000, 29900]]) == 62639\n assert candidate(n = 20000,rides = [[1, 5, 10], [2, 6, 15], [3, 7, 20], [4, 8, 25], [5, 9, 30], [6, 10, 35], [7, 11, 40], [8, 12, 45], [9, 13, 50], [10, 20000, 19950]]) == 39998\n assert candidate(n = 1000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]) == 54\n assert candidate(n = 100000,rides = [[1, 100000, 100000]]) == 199999\n assert candidate(n = 30000,rides = [[1, 30000, 10000], [10000, 20000, 15000], [20000, 30000, 20000], [5000, 15000, 10000]]) == 55000\n assert candidate(n = 50000,rides = [[1, 25000, 25000], [25000, 50000, 25000], [5000, 10000, 5000], [15000, 20000, 5000], [30000, 35000, 5000]]) == 99999\n assert candidate(n = 50,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [20, 21, 20], [21, 22, 21], [22, 23, 22], [23, 24, 23], [24, 25, 24], [25, 26, 25], [26, 27, 26], [27, 28, 27], [28, 29, 28], [29, 30, 29], [30, 31, 30], [31, 32, 31], [32, 33, 32], [33, 34, 33], [34, 35, 34], [35, 36, 35], [36, 37, 36], [37, 38, 37], [38, 39, 38], [39, 40, 39], [40, 41, 40], [41, 42, 41], [42, 43, 42], [43, 44, 43], [44, 45, 44], [45, 46, 45], [46, 47, 46], [47, 48, 47], [48, 49, 48], [49, 50, 49]]) == 1274\n assert candidate(n = 50,rides = [[1, 10, 5], [1, 10, 3], [1, 10, 1], [10, 20, 5], [10, 20, 3], [10, 20, 1], [20, 30, 5], [20, 30, 3], [20, 30, 1]]) == 44\n assert candidate(n = 70000,rides = [[1, 10000, 10000], [10001, 20000, 10000], [20001, 30000, 10000], [30001, 40000, 10000], [40001, 50000, 10000], [50001, 60000, 10000], [60001, 70000, 10000]]) == 139993\n assert candidate(n = 100000,rides = [[1, 50000, 50000], [50000, 100000, 50000], [25000, 75000, 30000]]) == 199999\n assert candidate(n = 50000,rides = [[1, 10, 100], [10, 20, 100], [20, 30, 100], [30, 40, 100], [40, 50, 100], [50, 60, 100], [60, 70, 100], [70, 80, 100], [80, 90, 100], [90, 100, 100]]) == 1099\n assert candidate(n = 10000,rides = [[1, 5000, 1000], [5001, 10000, 2000], [2001, 4000, 1500], [4001, 6000, 1200], [6001, 8000, 1800], [8001, 10000, 1600], [3001, 4500, 800], [4501, 6500, 1300], [6501, 8500, 1700], [8501, 9500, 1400]]) == 14096\n assert candidate(n = 50000,rides = [[1, 10, 10], [10, 20, 20], [20, 30, 30], [30, 40, 40], [40, 50, 50], [50, 60, 60], [60, 70, 70], [70, 80, 80], [80, 90, 90], [90, 100, 100], [100, 50000, 49900]]) == 100449\n assert candidate(n = 90000,rides = [[1, 10, 1], [11, 20, 2], [21, 30, 3], [31, 40, 4], [41, 50, 5], [51, 60, 6], [61, 70, 7], [71, 80, 8], [81, 90, 9], [91, 100, 10], [101, 110, 11], [111, 120, 12], [121, 130, 13], [131, 140, 14], [141, 150, 15], [151, 160, 16], [161, 170, 17], [171, 180, 18], [181, 190, 19], [191, 200, 20]]) == 390\n assert candidate(n = 90000,rides = [[1, 30000, 30000], [30001, 60000, 30000], [60001, 90000, 30000], [1, 60000, 60000], [30001, 90000, 60000], [1, 90000, 90000]]) == 179999\n assert candidate(n = 5000,rides = [[1, 3, 1], [2, 4, 1], [3, 5, 1], [4, 6, 1], [5, 7, 1], [6, 8, 1], [7, 9, 1], [8, 10, 1], [9, 11, 1], [10, 12, 1], [11, 13, 1], [12, 14, 1], [13, 15, 1], [14, 16, 1], [15, 17, 1], [16, 18, 1], [17, 19, 1], [18, 20, 1], [19, 21, 1], [20, 22, 1], [21, 23, 1], [22, 24, 1], [23, 25, 1], [24, 26, 1], [25, 27, 1], [26, 28, 1], [27, 29, 1], [28, 30, 1], [29, 31, 1], [30, 32, 1], [31, 33, 1], [32, 34, 1], [33, 35, 1], [34, 36, 1], [35, 37, 1], [36, 38, 1], [37, 39, 1], [38, 40, 1]]) == 57\n assert candidate(n = 10000,rides = [[1, 5, 50], [2, 6, 40], [3, 7, 30], [4, 8, 20], [5, 9, 10], [6, 10, 5]]) == 68\n assert candidate(n = 1000,rides = [[1, 10, 5], [2, 15, 10], [5, 100, 50], [10, 50, 25], [15, 90, 45], [20, 80, 35], [25, 70, 30], [30, 60, 25], [35, 55, 20], [40, 45, 15]]) == 145\n assert candidate(n = 50000,rides = [[1, 10000, 10000], [10001, 20000, 20000], [20001, 30000, 30000], [30001, 40000, 40000], [40001, 50000, 50000]]) == 199995\n assert candidate(n = 100,rides = [[1, 10, 5], [11, 20, 10], [21, 30, 15], [31, 40, 20], [41, 50, 25], [51, 60, 30], [61, 70, 35], [71, 80, 40], [81, 90, 45], [91, 100, 50]]) == 365\n assert candidate(n = 100000,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1], [20, 21, 1], [21, 22, 1], [22, 23, 1], [23, 24, 1], [24, 25, 1], [25, 26, 1], [26, 27, 1], [27, 28, 1], [28, 29, 1], [29, 30, 1], [30, 31, 1], [31, 32, 1], [32, 33, 1], [33, 34, 1], [34, 35, 1], [35, 36, 1], [36, 37, 1], [37, 38, 1], [38, 39, 1], [39, 40, 1], [40, 41, 1], [41, 42, 1], [42, 43, 1], [43, 44, 1], [44, 45, 1], [45, 46, 1], [46, 47, 1], [47, 48, 1], [48, 49, 1], [49, 50, 1], [50, 51, 1], [51, 52, 1], [52, 53, 1], [53, 54, 1], [54, 55, 1], [55, 56, 1], [56, 57, 1], [57, 58, 1], [58, 59, 1], [59, 60, 1], [60, 61, 1], [61, 62, 1], [62, 63, 1], [63, 64, 1], [64, 65, 1], [65, 66, 1], [66, 67, 1], [67, 68, 1], [68, 69, 1], [69, 70, 1], [70, 71, 1], [71, 72, 1], [72, 73, 1], [73, 74, 1], [74, 75, 1], [75, 76, 1], [76, 77, 1], [77, 78, 1], [78, 79, 1], [79, 80, 1], [80, 81, 1], [81, 82, 1], [82, 83, 1], [83, 84, 1], [84, 85, 1], [85, 86, 1], [86, 87, 1], [87, 88, 1], [88, 89, 1], [89, 90, 1], [90, 91, 1], [91, 92, 1], [92, 93, 1], [93, 94, 1], [94, 95, 1], [95, 96, 1], [96, 97, 1], [97, 98, 1], [98, 99, 1], [99, 100, 1], [100, 101, 1], [101, 102, 1], [102, 103, 1], [103, 104, 1], [104, 105, 1], [105, 106, 1], [106, 107, 1], [107, 108, 1], [108, 109, 1], [109, 110, 1], [110, 111, 1], [111, 112, 1], [112, 113, 1], [113, 114, 1], [114, 115, 1], [115, 116, 1], [116, 117, 1], [117, 118, 1], [118, 119, 1], [119, 120, 1], [120, 121, 1], [121, 122, 1], [122, 123, 1], [123, 124, 1], [124, 125, 1], [125, 126, 1], [126, 127, 1], [127, 128, 1], [128, 129, 1], [129, 130, 1], [130, 131, 1], [131, 132, 1], [132, 133, 1], [133, 134, 1], [134, 135, 1], [135, 136, 1], [136, 137, 1], [137, 138, 1], [138, 139, 1], [139, 140, 1], [140, 141, 1], [141, 142, 1], [142, 143, 1], [143, 144, 1], [144, 145, 1], [145, 146, 1], [146, 147, 1], [147, 148, 1], [148, 149, 1], [149, 150, 1], [150, 151, 1], [151, 152, 1], [152, 153, 1], [153, 154, 1], [154, 155, 1], [155, 156, 1], [156, 157, 1], [157, 158, 1], [158, 159, 1], [159, 160, 1], [160, 161, 1], [161, 162, 1], [162, 163, 1], [163, 164, 1], [164, 165, 1], [165, 166, 1], [166, 167, 1], [167, 168, 1], [168, 169, 1], [169, 170, 1], [170, 171, 1], [171, 172, 1], [172, 173, 1], [173, 174, 1], [174, 175, 1], [175, 176, 1], [176, 177, 1], [177, 178, 1], [178, 179, 1], [179, 180, 1], [180, 181, 1], [181, 182, 1], [182, 183, 1], [183, 184, 1], [184, 185, 1], [185, 186, 1], [186, 187, 1], [187, 188, 1], [188, 189, 1], [189, 190, 1], [190, 191, 1], [191, 192, 1], [192, 193, 1], [193, 194, 1], [194, 195, 1], [195, 196, 1], [196, 197, 1], [197, 198, 1], [198, 199, 1], [199, 200, 1]]) == 398\n assert candidate(n = 100000,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 100000, 99999]]) == 200007\n assert candidate(n = 100000,rides = [[1, 100000, 100000], [50000, 100000, 50000], [25000, 75000, 25000], [1, 50000, 10000], [50001, 100000, 10000]]) == 199999\n assert candidate(n = 20,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1]]) == 38\n assert candidate(n = 100000,rides = [[1, 100000, 1], [1, 100000, 2], [1, 100000, 3], [1, 100000, 4], [1, 100000, 5], [1, 100000, 6], [1, 100000, 7], [1, 100000, 8], [1, 100000, 9], [1, 100000, 10]]) == 100009\n assert candidate(n = 15,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14]]) == 119\n assert candidate(n = 60000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [59999, 60000, 100000]]) == 100028\n assert candidate(n = 80000,rides = [[1, 20000, 1000], [20000, 40000, 1000], [40000, 60000, 1000], [60000, 80000, 1000]]) == 83999\n assert candidate(n = 10000,rides = [[1, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 10, 10], [7, 11, 10], [8, 12, 10], [9, 13, 10], [10, 14, 10]]) == 42\n assert candidate(n = 10000,rides = [[1, 10, 5], [2, 11, 5], [3, 12, 5], [4, 13, 5], [5, 14, 5], [6, 15, 5], [7, 16, 5], [8, 17, 5], [9, 18, 5], [10, 19, 5], [11, 20, 5], [12, 21, 5], [13, 22, 5], [14, 23, 5], [15, 24, 5], [16, 25, 5], [17, 26, 5], [18, 27, 5], [19, 28, 5], [20, 29, 5], [21, 30, 5], [22, 31, 5], [23, 32, 5], [24, 33, 5], [25, 34, 5], [26, 35, 5], [27, 36, 5], [28, 37, 5], [29, 38, 5], [30, 39, 5], [31, 40, 5], [32, 41, 5], [33, 42, 5], [34, 43, 5], [35, 44, 5], [36, 45, 5], [37, 46, 5], [38, 47, 5], [39, 48, 5], [40, 49, 5], [41, 50, 5], [42, 51, 5], [43, 52, 5], [44, 53, 5], [45, 54, 5], [46, 55, 5], [47, 56, 5], [48, 57, 5], [49, 58, 5], [50, 59, 5], [51, 60, 5], [52, 61, 5], [53, 62, 5], [54, 63, 5], [55, 64, 5], [56, 65, 5], [57, 66, 5], [58, 67, 5], [59, 68, 5], [60, 69, 5], [61, 70, 5], [62, 71, 5], [63, 72, 5], [64, 73, 5], [65, 74, 5], [66, 75, 5], [67, 76, 5], [68, 77, 5], [69, 78, 5], [70, 79, 5], [71, 80, 5], [72, 81, 5], [73, 82, 5], [74, 83, 5], [75, 84, 5], [76, 85, 5], [77, 86, 5], [78, 87, 5], [79, 88, 5], [80, 89, 5], [81, 90, 5], [82, 91, 5], [83, 92, 5], [84, 93, 5], [85, 94, 5], [86, 95, 5], [87, 96, 5], [88, 97, 5], [89, 98, 5], [90, 99, 5], [91, 100, 5]]) == 154\n", "comparison": "exact"}, "public_tests": ["5\n[[2,5,4],[1,5,1]]", "20\n[[1,6,1],[3,10,2],[10,12,3],[11,12,2],[12,15,2],[13,18,1]]"], "hints": ["Can we sort the array to help us solve the problem?", "We can use dynamic programming to keep track of the maximum at each position."], "metadata": {"canonical_parameter_names": ["n", "rides"], "leetcode_dataset_entry_point": "Solution().maxTaxiEarnings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:02+00:00", "tests_total": 71, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "hash-table", "binary-search", "dynamic-programming", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxTaxiEarnings(self, n: int, rides: list[list[int]]) -> int:", "container": "Solution", "callable": "maxTaxiEarnings", "parameters": [{"name": "n", "type": "int"}, {"name": "rides", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2009, "task_id": "minimum-number-of-operations-to-make-array-continuous", "difficulty": "Hard", "problem_description": "You are given an integer array nums. In one operation, you can replace any element in nums with any integer.\n\nnums is considered continuous if both of the following conditions are fulfilled:\n\n- All elements in nums are unique.\n- The difference between the maximum element and the minimum element in nums equals nums.length - 1.\n\nFor example, nums = [4, 2, 5, 3] is continuous, but nums = [1, 2, 3, 5, 6] is not continuous.\n\nReturn the minimum number of operations to make nums continuous.\n\nExample 1:\n\nInput: nums = [4,2,5,3]\nOutput: 0\nExplanation: nums is already continuous.\n\nExample 2:\n\nInput: nums = [1,2,3,5,6]\nOutput: 1\nExplanation: One possible solution is to change the last element to 4.\nThe resulting array is [1,2,3,5,4], which is continuous.\n\nExample 3:\n\nInput: nums = [1,10,100,1000]\nOutput: 3\nExplanation: One possible solution is to:\n- Change the second element to 2.\n- Change the third element to 3.\n- Change the fourth element to 4.\nThe resulting array is [1,2,3,4], which is continuous.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10]) == 3\n assert candidate(nums = [4, 2, 5, 3]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5]) == 2\n assert candidate(nums = [5, 6, 7, 8, 9, 1]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1000000000, 1, 2, 3, 4]) == 1\n assert candidate(nums = [1000000000]) == 0\n assert candidate(nums = [100, 101, 102, 1]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5]) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 5\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [2, 3, 5, 8, 9, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [1, 10, 100, 1000]) == 3\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [10, 5, 1, 2, 7]) == 2\n assert candidate(nums = [1, 2, 2, 3, 4]) == 1\n assert candidate(nums = [1, 2, 3, 5, 6]) == 1\n assert candidate(nums = [10, 5, 7, 11, 6]) == 2\n assert candidate(nums = [5, 3, 1, 2, 4]) == 0\n assert candidate(nums = [10, 5, 3, 11, 6]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [5, 3, 1, 4, 2]) == 0\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 4\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 6\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 16\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 14\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 9\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998]) == 3\n assert candidate(nums = [1, 1000000000]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 7\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 19\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496]) == 24\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 120, 131, 142, 153, 164, 175, 186, 197, 208, 219]) == 18\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 4, 5, 5, 6]) == 4\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 9\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 10\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [5, 6, 15, 16, 25, 26, 35, 36, 45, 46, 55, 56, 65, 66, 75, 76, 85, 86, 95, 96]) == 16\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [3, 7, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996, 6, 999999995]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(nums = [2, 1, 3, 4, 7, 6, 5, 8, 9, 10]) == 0\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 4\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 20, 21, 22, 23, 25, 26, 27, 28, 30, 31, 32, 33, 35, 36, 37, 38, 40]) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 15\n assert candidate(nums = [1, 3, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 7\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 12\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15, 15, 16]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20]) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100, 109, 118, 127, 136, 145, 154, 163, 172, 181, 190, 199, 208, 217, 226]) == 23\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 18\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 13\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 12\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5]) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == 5\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 8\n assert candidate(nums = [1000000, 1000001, 1000002, 1000004, 1000005, 1000007, 1000008, 1000010, 1000011, 1000013]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 9\n assert candidate(nums = [5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 20]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 14\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 100, 101, 200, 201, 300, 301, 400, 401, 500, 501, 600, 601, 700, 701, 800, 801, 900, 901, 1000]) == 18\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 18\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 22\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 20\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500]) == 45\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 8\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996]) == 5\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 200, 201, 202, 203, 204]) == 5\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 18\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 7\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 30\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 5\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 14\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 9\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209]) == 10\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 10\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971]) == 0\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 13\n", "comparison": "exact"}, "public_tests": ["[4,2,5,3]", "[1,2,3,5,6]", "[1,10,100,1000]"], "hints": ["Sort the array.", "For every index do a binary search to get the possible right end of the window and calculate the possible answer."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:04+00:00", "tests_total": 136, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "hash-table", "binary-search", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def minOperations(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2011, "task_id": "final-value-of-variable-after-performing-operations", "difficulty": "Easy", "problem_description": "There is a programming language with only four operations and one variable X:\n\n- ++X and X++ increments the value of the variable X by 1.\n- --X and X-- decrements the value of the variable X by 1.\n\nInitially, the value of X is 0.\n\nGiven an array of strings operations containing a list of operations, return the final value of X after performing all the operations.\n\nExample 1:\n\nInput: operations = [\"--X\",\"X++\",\"X++\"]\nOutput: 1\nExplanation: The operations are performed as follows:\nInitially, X = 0.\n--X: X is decremented by 1, X = 0 - 1 = -1.\nX++: X is incremented by 1, X = -1 + 1 = 0.\nX++: X is incremented by 1, X = 0 + 1 = 1.\n\nExample 2:\n\nInput: operations = [\"++X\",\"++X\",\"X++\"]\nOutput: 3\nExplanation: The operations are performed as follows:\nInitially, X = 0.\n++X: X is incremented by 1, X = 0 + 1 = 1.\n++X: X is incremented by 1, X = 1 + 1 = 2.\nX++: X is incremented by 1, X = 2 + 1 = 3.\n\nExample 3:\n\nInput: operations = [\"X++\",\"++X\",\"--X\",\"X--\"]\nOutput: 0\nExplanation: The operations are performed as follows:\nInitially, X = 0.\nX++: X is incremented by 1, X = 0 + 1 = 1.\n++X: X is incremented by 1, X = 1 + 1 = 2.\n--X: X is decremented by 1, X = 2 - 1 = 1.\nX--: X is decremented by 1, X = 1 - 1 = 0.\n\nConstraints:\n\n- 1 <= operations.length <= 100\n- operations[i] will be either \"++X\", \"X++\", \"--X\", or \"X--\".\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(operations = ['X++', '++X', '--X', 'X--']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++']) == 5\n assert candidate(operations = ['--X', '--X', 'X--', 'X--']) == -4\n assert candidate(operations = ['++X', '++X', '++X', '++X']) == 4\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++']) == 4\n assert candidate(operations = ['--X', 'X++', 'X++']) == 1\n assert candidate(operations = ['--X', '--X', '--X', '--X']) == -4\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X']) == -5\n assert candidate(operations = ['--X', '--X', 'X++', '++X']) == 0\n assert candidate(operations = ['++X', '++X', 'X++']) == 3\n assert candidate(operations = ['--X', '--X', 'X++', '++X', '--X']) == -1\n assert candidate(operations = ['++X', 'X--', '--X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X--', '++X', '--X']) == 0\n assert candidate(operations = ['++X', '++X', '++X', '++X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -12\n assert candidate(operations = ['X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', 'X++', 'X++', 'X++']) == 1\n assert candidate(operations = ['--X', '--X', 'X++', 'X++', 'X--', 'X--', 'X++', '++X', '--X', 'X++', '--X', '++X', 'X--', '--X', 'X++', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == 0\n assert candidate(operations = ['++X', '++X', '++X', '++X', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--']) == -6\n assert candidate(operations = ['--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++']) == 0\n assert candidate(operations = ['X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X']) == -16\n assert candidate(operations = ['++X', '--X', '++X', '--X', '++X', '--X']) == 0\n assert candidate(operations = ['++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--']) == 0\n assert candidate(operations = ['X--', '--X', 'X++', '++X', '--X', 'X--', '--X', '++X', 'X++']) == -1\n assert candidate(operations = ['++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', '--X', 'X++', 'X++', '--X', '--X', 'X++', '--X', 'X++', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X']) == 1\n assert candidate(operations = ['--X', '--X', 'X--', 'X++', '++X', '++X', 'X--', '--X', '++X', '--X']) == -2\n assert candidate(operations = ['++X', 'X--', '--X', 'X++', 'X--', '++X', 'X--', '--X', 'X++', '++X']) == 0\n assert candidate(operations = ['++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++']) == 2\n assert candidate(operations = ['++X', 'X--', '--X', 'X++', '++X', '--X', 'X++']) == 1\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '++X', '++X', '++X', '++X', '++X', '++X', '++X', '++X', '++X', '++X']) == -5\n assert candidate(operations = ['++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X']) == 0\n assert candidate(operations = ['++X', '++X', '--X', '--X', '++X', '++X', '--X', '--X', '++X', '++X', '--X', '--X', '++X', '++X', '--X', '--X', '++X', '++X']) == 2\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -12\n assert candidate(operations = ['X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == 0\n assert candidate(operations = ['++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X']) == 0\n assert candidate(operations = ['X++', '--X', '++X', 'X--', '++X', 'X++', '--X', '--X', '++X', 'X++']) == 2\n assert candidate(operations = ['++X', '++X', '++X', '++X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -4\n assert candidate(operations = ['X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == 0\n assert candidate(operations = ['--X', 'X++', '++X', '--X', 'X++', '--X', 'X--', 'X++', '--X', '++X']) == 0\n assert candidate(operations = ['++X', '++X', '++X', '--X', '--X', '--X', '++X', 'X++', '--X']) == 1\n assert candidate(operations = ['++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == -1\n assert candidate(operations = ['--X', '--X', 'X++', 'X--', 'X--', 'X--', 'X--', 'X--', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 0\n assert candidate(operations = ['++X', '--X', 'X++', '++X', '--X', 'X--', '++X', 'X++']) == 2\n assert candidate(operations = ['--X', 'X--', '--X', 'X--', '--X', 'X--', '++X', 'X++', '++X', 'X++', '++X', 'X++', '++X', 'X++']) == 2\n assert candidate(operations = ['X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X']) == 0\n assert candidate(operations = ['--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X--', 'X--', 'X--', 'X--', 'X++', 'X++', 'X--', 'X--']) == 0\n assert candidate(operations = ['X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -4\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X']) == -5\n assert candidate(operations = ['X++', 'X++', '--X', '--X', '++X', 'X--', '++X', '--X', '++X', '--X']) == 0\n assert candidate(operations = ['X++', 'X++', '++X', '--X', 'X--', 'X--', '--X', '++X', 'X--', '--X']) == -2\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 12\n assert candidate(operations = ['--X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', '--X', 'X++', '--X', '++X', 'X--', '--X', 'X++']) == -2\n assert candidate(operations = ['--X', '--X', '--X', '--X', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 4\n assert candidate(operations = ['--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == -1\n assert candidate(operations = ['X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', '++X', 'X++', '--X', '--X', '++X', 'X++']) == 2\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X', '--X', '++X', '++X', '++X', '++X', '++X', '++X', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 8\n assert candidate(operations = ['--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 57\n assert candidate(operations = ['X++', '--X', '++X', 'X--', '++X', '--X', 'X++', '++X', '--X', 'X--']) == 0\n assert candidate(operations = ['--X', '--X', '--X', '--X', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 37\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++']) == 2\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X']) == 0\n assert candidate(operations = ['X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == 0\n assert candidate(operations = ['--X', '--X', '--X', 'X++', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', 'X--', 'X--', '++X', '++X']) == 0\n assert candidate(operations = ['X++', 'X--', '++X', '--X', 'X++', 'X--', '++X', '--X', 'X++', 'X--', '++X', '--X', 'X++', 'X--', '++X', '--X', 'X++', 'X--', '++X', '--X']) == 0\n assert candidate(operations = ['X++', 'X--', '++X', '--X', 'X--', '++X', 'X--', '++X', 'X--', '++X', 'X--', '++X']) == 0\n assert candidate(operations = ['X++', '--X', '++X', '--X', 'X++', '--X', 'X--']) == -1\n assert candidate(operations = ['--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 2\n assert candidate(operations = ['X--', 'X--', '--X', '--X', 'X++', 'X++', '++X']) == -1\n assert candidate(operations = ['X++', 'X++', 'X++', '--X', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', 'X++', '--X', '--X']) == 1\n assert candidate(operations = ['++X', '++X', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++']) == 2\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X', '++X', '++X', '++X', '++X', '++X', 'X++', 'X++', 'X++']) == 3\n assert candidate(operations = ['++X', 'X++', '--X', 'X--', '++X', '--X', 'X++', '++X']) == 2\n assert candidate(operations = ['X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X']) == 2\n assert candidate(operations = ['X++', '++X', 'X++', '++X', '--X', '--X', 'X--', '--X', 'X++', '++X', '--X', 'X--', '++X', 'X++']) == 2\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -4\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X++', 'X++', '--X', '--X', '--X']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == 0\n assert candidate(operations = ['X--', '--X', 'X++', '++X', 'X--', 'X--', '--X', '++X', 'X--', 'X--', 'X++', '++X']) == -2\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X--', 'X++', '--X', 'X++', 'X--', '++X', '--X']) == 0\n assert candidate(operations = ['++X', 'X--', '++X', 'X--', '++X', 'X--', '++X', 'X--', '++X', 'X--', '++X', 'X--']) == 0\n assert candidate(operations = ['X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X']) == 0\n assert candidate(operations = ['--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++']) == 0\n assert candidate(operations = ['++X', '++X', '++X', '--X', 'X--', '--X', 'X--', '--X', '++X', '--X']) == -2\n", "comparison": "exact"}, "public_tests": ["[\"--X\",\"X++\",\"X++\"]", "[\"++X\",\"++X\",\"X++\"]", "[\"X++\",\"++X\",\"--X\",\"X--\"]"], "hints": ["There are only two operations to keep track of.", "Use a variable to store the value after each operation."], "metadata": {"canonical_parameter_names": ["operations"], "leetcode_dataset_entry_point": "Solution().finalValueAfterOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:07+00:00", "tests_total": 88, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "string", "simulation"]}, "language": "python", "interface": {"raw_signature": "def finalValueAfterOperations(self, operations: list[str]) -> int:", "container": "Solution", "callable": "finalValueAfterOperations", "parameters": [{"name": "operations", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2012, "task_id": "sum-of-beauty-in-the-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. For each index i (1 <= i <= nums.length - 2) the beauty of nums[i] equals:\n\n- 2, if nums[j] < nums[i] < nums[k], for all 0 <= j < i and for all i < k <= nums.length - 1.\n- 1, if nums[i - 1] < nums[i] < nums[i + 1], and the previous condition is not satisfied.\n- 0, if none of the previous conditions holds.\n\nReturn the sum of beauty of all nums[i] where 1 <= i <= nums.length - 2.\n\nExample 1:\n\nInput: nums = [1,2,3]\nOutput: 2\nExplanation: For each index i in the range 1 <= i <= 1:\n- The beauty of nums[1] equals 2.\n\nExample 2:\n\nInput: nums = [2,4,6,4]\nOutput: 1\nExplanation: For each index i in the range 1 <= i <= 2:\n- The beauty of nums[1] equals 1.\n- The beauty of nums[2] equals 0.\n\nExample 3:\n\nInput: nums = [3,2,1]\nOutput: 0\nExplanation: For each index i in the range 1 <= i <= 1:\n- The beauty of nums[1] equals 0.\n\nConstraints:\n\n- 3 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 100, 8, 6, 90, 101]) == 1\n assert candidate(nums = [9, 7, 5, 3, 1]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [5, 3, 4, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 0\n assert candidate(nums = [2, 4, 6, 4]) == 1\n assert candidate(nums = [1, 100, 101, 102, 99]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [5, 1, 4, 3, 6, 7]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 14\n assert candidate(nums = [3, 2, 1]) == 0\n assert candidate(nums = [1, 5, 2, 5, 3, 5, 4, 5]) == 0\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 0\n assert candidate(nums = [1, 3, 2, 3, 5, 2, 6, 2]) == 1\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 0\n assert candidate(nums = [1, 2, 3]) == 2\n assert candidate(nums = [1, 3, 2, 5, 4, 6]) == 0\n assert candidate(nums = [1, 6, 4, 3, 5, 7, 8]) == 3\n assert candidate(nums = [1, 5, 2, 4, 3, 6]) == 0\n assert candidate(nums = [1, 5, 3, 7, 9, 11, 13, 2, 14]) == 3\n assert candidate(nums = [10, 20, 15, 25, 20, 30, 25, 35, 30, 40, 35, 45, 40, 50, 45]) == 0\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9, 8, 9, 10]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 94, 93, 92, 91]) == 16\n assert candidate(nums = [5, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15]) == 10\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [10, 20, 30, 25, 24, 35, 40, 39, 45, 50]) == 6\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3]) == 2\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [3, 1, 4, 2, 5, 8, 7, 10, 9, 12, 11]) == 2\n assert candidate(nums = [1, 5, 3, 4, 2, 8, 6, 7, 9, 11, 10]) == 3\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 24\n assert candidate(nums = [5, 3, 4, 2, 6, 1, 7, 9, 8, 10]) == 2\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8]) == 0\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 35, 40, 2, 45]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10]) == 4\n assert candidate(nums = [10, 20, 11, 30, 12, 40, 13, 50, 14, 60, 15]) == 0\n assert candidate(nums = [1, 2, 3, 100, 2, 3, 4, 5, 6, 7]) == 6\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == 0\n assert candidate(nums = [1, 10, 3, 5, 8, 12, 7, 6, 9, 11, 15, 14, 13, 16, 18, 17, 20, 19, 21, 22]) == 8\n assert candidate(nums = [90, 100, 110, 120, 115, 130, 140, 150, 145, 160, 170, 180, 175, 190, 200]) == 14\n assert candidate(nums = [1, 3, 5, 4, 6, 7, 2, 8, 9, 10]) == 6\n assert candidate(nums = [1, 2, 3, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 22\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == 46\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009]) == 16\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 0\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 8, 7, 10, 9, 12, 11]) == 2\n assert candidate(nums = [1, 20, 3, 40, 5, 60, 7, 80, 9, 100]) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9]) == 8\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 0\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15]) == 16\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 46\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 8\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 3\n assert candidate(nums = [5, 1, 4, 3, 6, 8, 2, 9, 7, 10]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24]) == 0\n assert candidate(nums = [1, 20, 3, 15, 4, 10, 5, 25, 6]) == 0\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 8, 7, 9, 11]) == 6\n assert candidate(nums = [5, 1, 4, 3, 6, 2, 8, 7, 10, 9]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 28\n assert candidate(nums = [5, 1, 3, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 23\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [10, 20, 30, 25, 40, 35, 50, 45, 60, 55]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 56\n assert candidate(nums = [10, 20, 30, 25, 40, 35, 50, 45, 60]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 25\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12]) == 4\n assert candidate(nums = [10, 20, 30, 25, 35, 40, 45, 50, 39, 41]) == 6\n assert candidate(nums = [1, 100, 50, 200, 150, 250, 200, 300, 250, 350, 300, 400, 350, 450, 400, 500, 450, 550, 500, 600]) == 0\n assert candidate(nums = [10, 20, 30, 15, 25, 35, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 14\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 21]) == 0\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 0\n assert candidate(nums = [30, 20, 10, 25, 15, 5, 35, 25, 15, 40, 30, 20, 50, 40, 30]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 26\n assert candidate(nums = [5, 3, 4, 2, 1, 6, 7, 8]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 20]) == 17\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 22\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 14\n assert candidate(nums = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 99999]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11]) == 8\n assert candidate(nums = [1, 2, 5, 3, 6, 4, 7, 8, 10, 9]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10]) == 21\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 0\n assert candidate(nums = [5, 8, 3, 9, 4, 10, 6, 11, 7, 12]) == 0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 1\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991]) == 0\n assert candidate(nums = [20, 10, 30, 5, 25, 15, 35, 40, 50, 60]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 36\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 25\n assert candidate(nums = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4, 104]) == 0\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 9, 10, 11, 12, 13, 14, 15]) == 12\n assert candidate(nums = [3, 1, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15]) == 4\n assert candidate(nums = [1, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 22\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == 0\n assert candidate(nums = [10, 11, 9, 12, 8, 13, 7, 14, 6, 15, 5, 16, 4, 17, 3, 18, 2, 19, 1, 20]) == 0\n assert candidate(nums = [5, 1, 4, 3, 6, 8, 2, 9, 7]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50]) == 11\n assert candidate(nums = [50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90, 110, 100, 120, 110, 130, 120, 140, 130]) == 0\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, 23, 24, 25, 26]) == 8\n assert candidate(nums = [1, 5, 3, 4, 6, 2, 7, 8, 9, 10]) == 7\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == 16\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 0\n assert candidate(nums = [10, 20, 30, 29, 28, 27, 26, 25, 24, 23]) == 2\n assert candidate(nums = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 16\n assert candidate(nums = [1, 3, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 10]) == 21\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10, 11, 12, 13, 14, 15]) == 14\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 11, 10, 13, 15]) == 8\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 35, 40, 2, 45, 50]) == 4\n assert candidate(nums = [1, 2, 100, 3, 4, 101, 5, 6, 102, 7, 8]) == 4\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 0\n assert candidate(nums = [10, 20, 30, 25, 35, 40, 36, 45, 50, 55]) == 8\n assert candidate(nums = [5, 1, 4, 3, 6, 2, 7, 8, 10, 9]) == 4\n", "comparison": "exact"}, "public_tests": ["[1,2,3]", "[2,4,6,4]", "[3,2,1]"], "hints": ["Use suffix/prefix arrays.", "prefix[i] records the maximum value in range (0, i - 1) inclusive.", "suffix[i] records the minimum value in range (i + 1, n - 1) inclusive."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumOfBeauties", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:09+00:00", "tests_total": 136, "tests_dropped": 4, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def sumOfBeauties(self, nums: list[int]) -> int:", "container": "Solution", "callable": "sumOfBeauties", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2014, "task_id": "longest-subsequence-repeated-k-times", "difficulty": "Hard", "problem_description": "You are given a string s of length n, and an integer k. You are tasked to find the longest subsequence repeated k times in string s.\n\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n\nA subsequence seq is repeated k times in the string s if seq * k is a subsequence of s, where seq * k represents a string constructed by concatenating seq k times.\n\n- For example, \"bba\" is repeated 2 times in the string \"bababcba\", because the string \"bbabba\", constructed by concatenating \"bba\" 2 times, is a subsequence of the string \"bababcba\".\n\nReturn the longest subsequence repeated k times in string s. If multiple such subsequences are found, return the lexicographically largest one. If there is no such subsequence, return an empty string.\n\nExample 1:\n\nInput: s = \"letsleetcode\", k = 2\nOutput: \"let\"\nExplanation: There are two longest subsequences repeated 2 times: \"let\" and \"ete\".\n\"let\" is the lexicographically largest one.\n\nExample 2:\n\nInput: s = \"bb\", k = 2\nOutput: \"b\"\nExplanation: The longest subsequence repeated 2 times is \"b\".\n\nExample 3:\n\nInput: s = \"ab\", k = 2\nOutput: \"\"\nExplanation: There is no subsequence repeated 2 times. Empty string is returned.\n\nConstraints:\n\n- n == s.length\n- 2 <= k <= 2000\n- 2 <= n < min(2001, k * 8)\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbcc\",k = 3) == \"\"\n assert candidate(s = \"zzzzzzzzz\",k = 4) == \"zz\"\n assert candidate(s = \"zzzzzzzzzz\",k = 5) == \"zz\"\n assert candidate(s = \"abcabcabcabc\",k = 4) == \"abc\"\n assert candidate(s = \"abcdabcabc\",k = 3) == \"abc\"\n assert candidate(s = \"abababababab\",k = 3) == \"abab\"\n assert candidate(s = \"aabbbccccc\",k = 3) == \"c\"\n assert candidate(s = \"letsleetcode\",k = 2) == \"let\"\n assert candidate(s = \"ab\",k = 2) == \"\"\n assert candidate(s = \"zzzzzzzzzzzzzz\",k = 5) == \"zz\"\n assert candidate(s = \"aaaabbbbcccc\",k = 2) == \"cc\"\n assert candidate(s = \"aaaabbbb\",k = 2) == \"bb\"\n assert candidate(s = \"aabbccddeeff\",k = 2) == \"f\"\n assert candidate(s = \"abcabcabc\",k = 3) == \"abc\"\n assert candidate(s = \"abcdabcdabcd\",k = 3) == \"abcd\"\n assert candidate(s = \"bb\",k = 2) == \"b\"\n assert candidate(s = \"abcdeabcdeabcde\",k = 3) == \"abcde\"\n assert candidate(s = \"aabbcc\",k = 2) == \"c\"\n assert candidate(s = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",k = 16) == \"qq\"\n assert candidate(s = \"mnopmnopmnop\",k = 6) == \"\"\n assert candidate(s = \"abcabcabcabc\",k = 3) == \"cab\"\n assert candidate(s = \"abcdefabcdefabcdefabcdef\",k = 4) == \"abcdef\"\n assert candidate(s = \"aabbaaccdd\",k = 3) == \"a\"\n assert candidate(s = \"abcdefgabcdefgabcdefg\",k = 3) == \"abcdefg\"\n assert candidate(s = \"kkkkkkkkkkkkkkkk\",k = 16) == \"k\"\n assert candidate(s = \"abcdefghijklaaaaaaabbbbbbbbbccccccccc\",k = 5) == \"cc\"\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 8) == \"yxyx\"\n assert candidate(s = \"abababababababababababababab\",k = 7) == \"abab\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 5) == \"zzzz\"\n assert candidate(s = \"aabaaaabbbaaa\",k = 4) == \"aa\"\n assert candidate(s = \"ababababababababababababababababab\",k = 10) == \"ba\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\",k = 5) == \"cabcab\"\n assert candidate(s = \"mississippi\",k = 2) == \"ssi\"\n assert candidate(s = \"ppppqqrrrrrssstttt\",k = 3) == \"t\"\n assert candidate(s = \"abcabcabcabcabcabcabc\",k = 3) == \"cabcab\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzz\",k = 10) == \"z\"\n assert candidate(s = \"abcabcabcabcabcabc\",k = 3) == \"abcabc\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 20) == \"zzz\"\n assert candidate(s = \"abababababababab\",k = 8) == \"ab\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 5) == \"abcabc\"\n assert candidate(s = \"aaabbbcccddd\",k = 3) == \"d\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 10) == \"abc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabca\",k = 5) == \"bcabca\"\n assert candidate(s = \"zzzzzzzzzzzz\",k = 5) == \"zz\"\n assert candidate(s = \"aaaabbbbccccdddddd\",k = 4) == \"d\"\n assert candidate(s = \"aabbccddeeffgg\",k = 2) == \"g\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 20) == \"z\"\n assert candidate(s = \"ababababababab\",k = 4) == \"ba\"\n assert candidate(s = \"ababababababababab\",k = 5) == \"ba\"\n assert candidate(s = \"aaaaaaaaaa\",k = 2) == \"aaaaa\"\n assert candidate(s = \"qwertyqwertyqwerty\",k = 3) == \"qwerty\"\n assert candidate(s = \"ababababababababababababababababab\",k = 16) == \"ba\"\n assert candidate(s = \"aabbccddeeefff\",k = 2) == \"f\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == \"zzzz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 25) == \"z\"\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiii\",k = 4) == \"\"\n assert candidate(s = \"abcdabcdbacdb\",k = 2) == \"cdab\"\n assert candidate(s = \"xyxyxyxyxyxy\",k = 4) == \"yx\"\n assert candidate(s = \"abcabcabcabcabcabcabcabc\",k = 4) == \"abcabc\"\n assert candidate(s = \"aabaaabaaabaaabaaab\",k = 5) == \"aab\"\n assert candidate(s = \"abcabcabcabcabc\",k = 5) == \"abc\"\n assert candidate(s = \"mmmmmmnnnnnnnnnnoooooo\",k = 5) == \"nn\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\",k = 8) == \"abcd\"\n assert candidate(s = \"zzzzzzzzzzzzz\",k = 5) == \"zz\"\n assert candidate(s = \"aaabbbcccdddeeefff\",k = 4) == \"\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\",k = 10) == \"zxy\"\n assert candidate(s = \"zzzzyyyxxxwww\",k = 4) == \"z\"\n assert candidate(s = \"xyzxyzxyzxyzxyz\",k = 4) == \"zxy\"\n", "comparison": "exact"}, "public_tests": ["\"letsleetcode\"\n2", "\"bb\"\n2", "\"ab\"\n2"], "hints": ["The length of the longest subsequence does not exceed n/k. Do you know why?", "Find the characters that could be included in the potential answer. A character occurring more than or equal to k times can be used in the answer up to (count of the character / k) times.", "Try all possible candidates in reverse lexicographic order, and check the string for the subsequence condition."], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().longestSubsequenceRepeatedK", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:11+00:00", "tests_total": 89, "tests_dropped": 21, "flags": ["has_images"], "topic_tags": ["hash-table", "two-pointers", "string", "backtracking", "counting", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def longestSubsequenceRepeatedK(self, s: str, k: int) -> str:", "container": "Solution", "callable": "longestSubsequenceRepeatedK", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2016, "task_id": "maximum-difference-between-increasing-elements", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums of size n, find the maximum difference between nums[i] and nums[j] (i.e., nums[j] - nums[i]), such that 0 <= i < j < n and nums[i] < nums[j].\n\nReturn the maximum difference. If no such i and j exists, return -1.\n\nExample 1:\n\nInput: nums = [7,1,5,4]\nOutput: 4\nExplanation:\nThe maximum difference occurs with i = 1 and j = 2, nums[j] - nums[i] = 5 - 1 = 4.\nNote that with i = 1 and j = 0, the difference nums[j] - nums[i] = 7 - 1 = 6, but i > j, so it is not valid.\n\nExample 2:\n\nInput: nums = [9,4,3,2]\nOutput: -1\nExplanation:\nThere is no i and j such that i < j and nums[i] < nums[j].\n\nExample 3:\n\nInput: nums = [1,5,2,10]\nOutput: 9\nExplanation:\nThe maximum difference occurs with i = 0 and j = 3, nums[j] - nums[i] = 10 - 1 = 9.\n\nConstraints:\n\n- n == nums.length\n- 2 <= n <= 1000\n- 1 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [9, 4, 3, 2]) == -1\n assert candidate(nums = [5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 2, 999999999]) == 999999998\n assert candidate(nums = [1, 100, 1, 100, 1]) == 99\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [1, 999999999, 2, 999999998]) == 999999998\n assert candidate(nums = [10, 20, 20, 10, 30]) == 20\n assert candidate(nums = [1, 5, 2, 10]) == 9\n assert candidate(nums = [1, 1, 1, 1]) == -1\n assert candidate(nums = [1, 3, 2, 4, 3, 5]) == 4\n assert candidate(nums = [10, 1, 10, 1, 10]) == 9\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [7, 1, 5, 4]) == 4\n assert candidate(nums = [1, 3, 6, 7, 9, 14, 10]) == 13\n assert candidate(nums = [1, 2, 1, 2, 1]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 11]) == 1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 8\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [1000000000, 999999999, 999999998, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1000000000, 999999999, 1, 1000000000, 2, 999999998, 3, 1000000000, 4, 999999997]) == 999999999\n assert candidate(nums = [100, 100, 100, 100, 101, 100, 100, 100]) == 1\n assert candidate(nums = [2, 3, 10, 6, 4, 8, 1, 5, 7, 9]) == 8\n assert candidate(nums = [10, 1, 2, 8, 1, 5, 6, 3, 9]) == 8\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 18\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997]) == 999999999\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 38\n assert candidate(nums = [3, 2, 1, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 29\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 1\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 9\n assert candidate(nums = [1, 3, 2, 3, 100, 1, 2, 3, 4]) == 99\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 9\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 31]) == 30\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 1\n assert candidate(nums = [2, 1, 5, 3, 4, 8, 7, 6, 9, 10, 1]) == 9\n assert candidate(nums = [8, 11, 9, 8, 10, 12]) == 4\n assert candidate(nums = [10, 9, 10, 8, 9, 7, 8, 6, 7, 5, 6, 4, 5, 3, 4, 2, 3, 1, 2]) == 1\n assert candidate(nums = [1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 9\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 150]) == 50\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 90\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 9\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == 14\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 11, 12, 13]) == 12\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == -1\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 10\n assert candidate(nums = [999999999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 99\n assert candidate(nums = [3, 3, 3, 1, 2, 2, 2, 5, 5, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12]) == 11\n assert candidate(nums = [1, 2, 3, 100, 1, 2, 3, 101, 1, 2, 3, 102, 1, 2, 3, 103, 1, 2, 3, 104]) == 103\n assert candidate(nums = [3, 3, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 8\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 2\n assert candidate(nums = [5, 1, 4, 3, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 18\n assert candidate(nums = [5, 2, 6, 1, 9, 4, 3, 7, 8]) == 8\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 10, 40, 35, 45, 50]) == 45\n assert candidate(nums = [1, 5, 3, 7, 9, 2, 6, 8, 4, 10]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1]) == 90\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(nums = [5, 3, 6, 7, 2, 5, 4, 8, 9, 1]) == 7\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 21]) == 20\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [5, 4, 3, 2, 1, 10]) == 9\n assert candidate(nums = [3, 3, 3, 1, 1, 1, 2, 2, 2, 5, 5, 5, 4, 4, 4]) == 4\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 9\n assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == 10\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 9\n assert candidate(nums = [5, 11, 2, 14, 1, 3, 10, 6, 12, 4, 15, 8]) == 14\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == -1\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4, 104, 5, 105, 6, 106, 7, 107, 8, 108, 9, 109, 10]) == 108\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [5, 1, 9, 2, 8, 3, 7, 4, 6, 10, 1, 9, 2, 8, 3, 7, 4, 6, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [50, 20, 30, 10, 40, 60, 25, 35, 55, 45, 70, 65, 80, 75, 90, 85, 100, 95]) == 90\n assert candidate(nums = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 11\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11]) == 10\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996]) == 999999999\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 100, 5, 6, 7, 8, 9, 10]) == 99\n assert candidate(nums = [5, 2, 3, 1, 4, 7, 6, 8]) == 7\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 9\n assert candidate(nums = [100, 100, 100, 100, 101, 100, 100, 100, 100, 100]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18]) == 99\n assert candidate(nums = [50, 25, 75, 100, 200, 150, 175, 225, 275, 300, 250, 325, 350]) == 325\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40]) == 40\n assert candidate(nums = [10, 5, 1, 7, 3, 6, 4]) == 6\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4, 104, 5]) == 103\n assert candidate(nums = [5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9]) == 4\n", "comparison": "exact"}, "public_tests": ["[7,1,5,4]", "[9,4,3,2]", "[1,5,2,10]"], "hints": ["Could you keep track of the minimum element visited while traversing?", "We have a potential candidate for the answer if the prefix min is less than nums[i]."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:16+00:00", "tests_total": 118, "tests_dropped": 5, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def maximumDifference(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maximumDifference", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2017, "task_id": "grid-game", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 2D array grid of size 2 x n, where grid[r][c] represents the number of points at position (r, c) on the matrix. Two robots are playing a game on this matrix.\n\nBoth robots initially start at (0, 0) and want to reach (1, n-1). Each robot may only move to the right ((r, c) to (r, c + 1)) or down ((r, c) to (r + 1, c)).\n\nAt the start of the game, the first robot moves from (0, 0) to (1, n-1), collecting all the points from the cells on its path. For all cells (r, c) traversed on the path, grid[r][c] is set to 0. Then, the second robot moves from (0, 0) to (1, n-1), collecting the points on its path. Note that their paths may intersect with one another.\n\nThe first robot wants to minimize the number of points collected by the second robot. In contrast, the second robot wants to maximize the number of points it collects. If both robots play optimally, return the number of points collected by the second robot.\n\nExample 1:\n\nInput: grid = [[2,5,4],[1,5,1]]\nOutput: 4\nExplanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.\nThe cells visited by the first robot are set to 0.\nThe second robot will collect 0 + 0 + 4 + 0 = 4 points.\n\nExample 2:\n\nInput: grid = [[3,3,1],[8,5,2]]\nOutput: 4\nExplanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.\nThe cells visited by the first robot are set to 0.\nThe second robot will collect 0 + 3 + 1 + 0 = 4 points.\n\nExample 3:\n\nInput: grid = [[1,3,1,15],[1,3,3,1]]\nOutput: 7\nExplanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.\nThe cells visited by the first robot are set to 0.\nThe second robot will collect 0 + 1 + 3 + 3 + 0 = 7 points.\n\nConstraints:\n\n- grid.length == 2\n- n == grid[r].length\n- 1 <= n <= 5 * 10^4\n- 1 <= grid[r][c] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == 9\n assert candidate(grid = [[1, 3, 1, 15], [1, 3, 3, 1]]) == 7\n assert candidate(grid = [[2, 5, 4], [1, 5, 1]]) == 4\n assert candidate(grid = [[10, 10, 10], [1, 1, 1]]) == 2\n assert candidate(grid = [[3, 3, 1], [8, 5, 2]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]]) == 9\n assert candidate(grid = [[100, 200, 300, 400, 500], [500, 400, 300, 200, 100]]) == 900\n assert candidate(grid = [[100000, 100000, 100000, 100000, 100000], [1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 10, 3, 40, 5, 60, 7, 80, 9, 100], [100, 9, 80, 7, 60, 5, 40, 3, 20, 1]]) == 256\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[100000, 100000, 100000], [1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]]) == 19\n assert candidate(grid = [[100000, 90000, 80000, 70000, 60000, 50000], [50000, 60000, 70000, 80000, 90000, 100000]]) == 180000\n assert candidate(grid = [[23456, 12345, 67890, 45678, 34567], [76543, 89012, 12345, 67890, 54321]]) == 148135\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 84\n assert candidate(grid = [[100000, 1, 100000, 1, 100000, 1], [1, 100000, 1, 100000, 1, 100000]]) == 100002\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 155\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 15\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 7\n assert candidate(grid = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 75\n assert candidate(grid = [[5, 10, 15, 20, 25, 30, 35], [35, 30, 25, 20, 15, 10, 5]]) == 90\n assert candidate(grid = [[7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [16, 15, 14, 13, 12, 11, 10, 9, 8, 7]]) == 70\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10]]) == 90\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 25\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 8\n assert candidate(grid = [[5, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 5]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 27\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]) == 35\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(grid = [[100000, 99999, 99998, 99997, 99996], [1, 2, 3, 4, 5]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]]) == 9\n assert candidate(grid = [[99999, 99998, 99997, 99996, 99995], [1, 2, 3, 4, 5]]) == 10\n assert candidate(grid = [[1, 1, 100000], [100000, 1, 1]]) == 100000\n assert candidate(grid = [[100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1], [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]]) == 200003\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 13\n assert candidate(grid = [[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]]) == 4000\n assert candidate(grid = [[100000, 99999, 99998, 99997, 99996], [1, 2, 3, 4, 5]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 6\n assert candidate(grid = [[10, 20, 30, 40, 50, 60], [60, 50, 40, 30, 20, 10]]) == 150\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 13\n assert candidate(grid = [[1, 100, 1], [100, 1, 100]]) == 100\n assert candidate(grid = [[1, 100000, 1, 100000, 1], [100000, 1, 100000, 1, 100000]]) == 100001\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 40\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10]]) == 90\n assert candidate(grid = [[5, 4, 3, 2, 1], [1, 2, 3, 4, 5]]) == 3\n assert candidate(grid = [[100, 200, 300, 400, 500], [500, 400, 300, 200, 100]]) == 900\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 234\n assert candidate(grid = [[1, 99999, 99999, 99999, 99999], [99999, 99999, 99999, 99999, 99999]]) == 199998\n assert candidate(grid = [[5, 10, 15, 20, 25, 30], [30, 25, 20, 15, 10, 5]]) == 75\n assert candidate(grid = [[100000, 100000, 100000, 100000], [1, 1, 1, 1]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 40\n assert candidate(grid = [[100000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999]]) == 18\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 5, 5, 5, 5]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 9\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]]) == 23\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 84\n assert candidate(grid = [[1, 5, 2, 7, 3, 8, 4, 9], [9, 4, 8, 3, 7, 2, 5, 1]]) == 24\n assert candidate(grid = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2]]) == 3\n assert candidate(grid = [[100000, 100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000, 100000]]) == 200000\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 8\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 950\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 234\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100000], [100000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 100004\n assert candidate(grid = [[5000, 5000, 5000, 5000, 5000], [1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 155\n assert candidate(grid = [[100000, 100000, 100000, 100000, 100000], [1, 2, 3, 4, 5]]) == 10\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 30\n assert candidate(grid = [[1, 10, 100, 1000, 10000], [10000, 1000, 100, 10, 1]]) == 11000\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 15\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]]) == 9\n assert candidate(grid = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]]) == 200\n", "comparison": "exact"}, "public_tests": ["[[2,5,4],[1,5,1]]", "[[3,3,1],[8,5,2]]", "[[1,3,1,15],[1,3,3,1]]"], "hints": ["There are n choices for when the first robot moves to the second row.", "Can we use prefix sums to help solve this problem?"], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().gridGame", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:19+00:00", "tests_total": 75, "tests_dropped": 2, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "matrix", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def gridGame(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "gridGame", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2018, "task_id": "check-if-word-can-be-placed-in-crossword", "difficulty": "Medium", "problem_description": "You are given an m x n matrix board, representing the current state of a crossword puzzle. The crossword contains lowercase English letters (from solved words), ' ' to represent any empty cells, and '#' to represent any blocked cells.\n\nA word can be placed horizontally (left to right or right to left) or vertically (top to bottom or bottom to top) in the board if:\n\n- It does not occupy a cell containing the character '#'.\n- The cell each letter is placed in must either be ' ' (empty) or match the letter already on the board.\n- There must not be any empty cells ' ' or other lowercase letters directly left or right of the word if the word was placed horizontally.\n- There must not be any empty cells ' ' or other lowercase letters directly above or below the word if the word was placed vertically.\n\nGiven a string word, return true if word can be placed in board, or false otherwise.\n\nExample 1:\n\nInput: board = [[\"#\", \" \", \"#\"], [\" \", \" \", \"#\"], [\"#\", \"c\", \" \"]], word = \"abc\"\nOutput: true\nExplanation: The word \"abc\" can be placed as shown above (top to bottom).\n\nExample 2:\n\nInput: board = [[\" \", \"#\", \"a\"], [\" \", \"#\", \"c\"], [\" \", \"#\", \"a\"]], word = \"ac\"\nOutput: false\nExplanation: It is impossible to place the word because there will always be a space/letter above or below it.\n\nExample 3:\n\nInput: board = [[\"#\", \" \", \"#\"], [\" \", \" \", \"#\"], [\"#\", \" \", \"c\"]], word = \"ca\"\nOutput: true\nExplanation: The word \"ca\" can be placed as shown above (right to left).\n\nConstraints:\n\n- m == board.length\n- n == board[i].length\n- 1 <= m * n <= 2 * 10^5\n- board[i][j] will be ' ', '#', or a lowercase English letter.\n- 1 <= word.length <= max(m, n)\n- word will contain only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', '#'], ['#', ' ', 'c']],word = \"ca\") == True\n assert candidate(board = [['a'], ['b'], ['c'], ['d'], ['e']],word = \"abcde\") == True\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', '#'], ['#', ' ', 'c']],word = \"ca\") == True\n assert candidate(board = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']],word = \"ihg\") == True\n assert candidate(board = [['a', ' ', 'a'], [' ', ' ', ' '], ['a', ' ', 'a']],word = \"aba\") == True\n assert candidate(board = [['#', ' ', '#'], ['a', 'b', 'c'], ['#', ' ', '#']],word = \"cba\") == True\n assert candidate(board = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']],word = \"def\") == True\n assert candidate(board = [['a', 'b', 'c'], ['#', '#', '#'], ['g', 'h', 'i']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' '], ['#', 'a', '#'], [' ', ' ', ' ']],word = \"a\") == True\n assert candidate(board = [['#', '#', '#'], ['#', ' ', '#'], ['#', ' ', '#']],word = \"a\") == True\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', '#'], ['#', 'c', ' ']],word = \"abc\") == True\n assert candidate(board = [[' ', '#', 'a'], [' ', '#', 'c'], [' ', '#', 'a']],word = \"ac\") == False\n assert candidate(board = [[' ', '#', 'a'], [' ', '#', 'c'], [' ', '#', 'a']],word = \"ac\") == False\n assert candidate(board = [[' ', ' ', ' ', '#'], [' ', ' ', ' ', '#'], [' ', ' ', ' ', '#']],word = \"test\") == False\n assert candidate(board = [['#', '#', '#'], [' ', ' ', ' '], ['#', '#', '#']],word = \"ab\") == False\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', '#'], ['#', 'c', ' ']],word = \"abc\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"test\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ']],word = \"abcd\") == True\n assert candidate(board = [['#', '#', 'a', '#', '#'], ['#', '#', 'b', '#', '#'], ['#', '#', 'c', '#', '#'], ['#', '#', 'd', '#', '#'], ['#', '#', '#', '#', '#']],word = \"abcd\") == True\n assert candidate(board = [[' ', ' ', '#', '#', '#', ' '], [' ', ' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ', ' '], [' ', ' ', '#', '#', '#', ' ']],word = \"test\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['a', 'b', 'c', 'd', 'e'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abcde\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], [' ', 'a', ' ', 'b', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"find\") == False\n assert candidate(board = [[' ', '#', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', ' ', ' ', '#']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', ' ', ' ', '#'], ['#', '#', '#', '#']],word = \"a\") == False\n assert candidate(board = [['a', 'b', 'c'], ['#', '#', '#'], [' ', ' ', ' '], [' ', ' ', ' '], ['#', 'a', 'b']],word = \"abc\") == True\n assert candidate(board = [[' ', '#', ' ', ' ', '#', ' '], ['#', ' ', '#', ' ', '#', '#'], [' ', '#', ' ', '#', ' ', ' '], ['#', '#', ' ', '#', ' ', '#']],word = \"hello\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"ghijkl\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', 'a', ' ', ' '], ['#', ' ', 'b', ' '], ['#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], ['#', 'a', ' ', ' '], ['#', ' ', 'b', ' '], ['#', ' ', ' ', 'c']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"hello\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [['#', ' ', '#', ' '], [' ', ' ', ' ', ' '], [' ', ' ', '#', ' '], [' ', ' ', ' ', ' ']],word = \"ab\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', 'a', ' ', ' '], [' ', ' ', 'b', ' '], ['#', ' ', ' ', 'c']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', ' ', ' ', 'a'], ['#', '#', 'b', 'c']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['a', 'b', 'c', 'd', 'e'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', '#', '#', ' '], [' ', ' ', ' ', ' ']],word = \"ab\") == True\n assert candidate(board = [[' ', '#', ' ', '#', ' '], ['#', 'a', '#', ' ', '#'], ['#', '#', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', ' ']],word = \"abc\") == False\n assert candidate(board = [['#', '#', '#'], ['#', ' ', '#'], ['#', ' ', '#'], ['#', '#', '#']],word = \"ab\") == True\n assert candidate(board = [['#', '#', '#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', ' ', ' ', '#'], ['#', ' ', '#', '#', '#', ' ', '#'], ['#', ' ', '#', 'a', '#', ' ', '#'], ['#', ' ', '#', 'b', '#', ' ', '#'], ['#', ' ', '#', 'c', '#', ' ', '#'], ['#', '#', '#', '#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [['#', 'a', '#'], ['#', '#', '#'], ['#', 'a', '#']],word = \"aa\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['#', 'a', '#', 'c', '#'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"ac\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], ['#', 'a', 'b', '#'], [' ', ' ', ' ', ' '], ['#', 'd', 'c', '#']],word = \"abcd\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', 'a', ' ', 'b', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"ab\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', ' ', ' ', '#'], ['#', '#', ' ', '#', '#', ' ', '#'], ['#', ' ', 'a', ' ', ' ', ' ', '#'], ['#', '#', ' ', 'b', '#', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', '#']],word = \"abc\") == True\n assert candidate(board = [[' ', '#', ' ', '#', ' '], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], [' ', '#', ' ', '#', ' ']],word = \"test\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['e', 'd', 'c', 'b', 'a'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['#', 'a', 'b', 'c', '#'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"cba\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', 'a', ' ', ' ', '#'], ['#', ' ', ' ', 'b', '#'], ['#', ' ', 'c', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', '#', ' ', ' '], ['#', ' ', 'a', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', 'c', ' ', '#'], [' ', ' ', '#', ' ', ' ']],word = \"play\") == False\n assert candidate(board = [[' ', '#', '#', '#', ' '], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', '#', '#', '#', ' ']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"mnopqr\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"abcdef\") == True\n assert candidate(board = [['#', '#', '#', '#'], ['#', ' ', ' ', '#'], ['#', ' ', ' ', '#'], ['#', '#', '#', '#']],word = \"word\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' '], ['#', 'a', ' ', ' ', 'b', '#'], ['#', ' ', ' ', ' ', ' ', '#'], ['#', 'c', ' ', ' ', 'd', '#'], ['#', ' ', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#', '#']],word = \"abcd\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"abc\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', 'a', ' ', ' '], [' ', ' ', 'b', ' '], [' ', ' ', ' ', 'c']],word = \"abc\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ']],word = \"world\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#']],word = \"abcdef\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#', ' ', '#'], ['#', 'a', '#', 'b', '#', 'c', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', 'd', '#', 'e', '#', 'f', '#'], ['#', ' ', '#', ' ', '#', ' ', '#']],word = \"abcdef\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', 'a', '#', '#'], ['#', '#', 'b', '#', '#'], ['#', '#', 'c', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"abc\") == False\n assert candidate(board = [[' ', '#', ' ', ' ', ' '], [' ', ' ', ' ', '#', ' '], [' ', '#', ' ', ' ', ' '], [' ', ' ', ' ', '#', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', '#', ' ', ' '], ['#', 'a', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [['a', 'b', ' ', 'd', 'e'], ['#', '#', 'c', '#', '#'], ['e', 'd', ' ', 'b', 'a'], ['#', '#', 'c', '#', '#'], ['a', 'b', ' ', 'd', 'e']],word = \"abcde\") == True\n assert candidate(board = [[' ', '#', '#', '#', ' '], ['#', 'a', '#', 'b', '#'], ['#', '#', '#', '#', '#'], ['#', 'c', '#', 'd', '#'], [' ', '#', '#', '#', ' ']],word = \"abcd\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', 'a', '#', ' '], ['#', 'b', '#', ' '], ['#', 'c', '#', ' ']],word = \"abc\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"abcdef\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"abcd\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], ['#', '#', ' ', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', ' ', '#', '#'], ['#', ' ', ' ', ' ', '#']],word = \"game\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', '#', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', 'k', ' ', ' ', 'l', ' '], ['#', ' ', ' ', ' ', ' ', ' ', 'm'], ['#', '#', '#', '#', '#', '#', '#']],word = \"klm\") == True\n assert candidate(board = [['#', ' ', '#'], [' ', 'a', ' '], ['#', ' ', '#'], [' ', 'b', ' '], ['#', ' ', '#']],word = \"aba\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#']],word = \"a\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' '], ['#', 'a', '#', 'b', '#', 'c'], [' ', ' ', ' ', ' ', ' ', ' '], ['#', 'd', '#', 'e', '#', 'f'], [' ', ' ', ' ', ' ', ' ', ' ']],word = \"abcdef\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"world\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', 'j'], ['#', ' ', '#', ' ', '#', ' ', 'i'], ['#', ' ', ' ', ' ', ' ', ' ', 'h'], ['#', ' ', '#', ' ', '#', ' ', 'g'], ['#', ' ', ' ', ' ', ' ', ' ', 'f'], ['#', '#', '#', '#', '#', '#', '#']],word = \"ghij\") == False\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', ' '], [' ', ' ', '#'], [' ', '#', ' ']],word = \"abc\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], [' ', ' ', '#', ' ', ' '], [' ', 'a', '#', 'b', ' '], ['#', ' ', '#', ' ', '#']],word = \"abcd\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', 'a', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"aaa\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', ' ', ' ', '#'], [' ', 'g', ' ', 'h', ' ', 'i', ' '], ['#', ' ', '#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#', '#', '#']],word = \"ghji\") == True\n assert candidate(board = [['#', '#', '#', '#'], ['#', ' ', ' ', ' '], ['#', ' ', '#', ' '], ['#', ' ', ' ', ' '], ['#', '#', '#', '#']],word = \"code\") == False\n assert candidate(board = [['#', 'a', 'b', 'c'], ['#', 'd', 'e', 'f'], ['#', 'g', 'h', 'i'], ['#', 'j', 'k', 'l']],word = \"mnop\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abcd\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', ' '], ['#', ' ', 'a', ' ', ' '], ['#', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', ' ']],word = \"abc\") == False\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', 'a', '#', 'b', '#'], ['#', '#', '#', '#', '#'], ['#', 'c', '#', 'd', '#'], ['#', '#', '#', '#', '#']],word = \"abcd\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', '#', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', 'n', ' ', ' ', 'o', ' '], ['#', ' ', ' ', ' ', ' ', ' ', 'p'], ['#', '#', '#', '#', '#', '#', '#']],word = \"pon\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"abc\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', 'a', 'b', 'c', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', '#'], [' ', ' ', ' ', '#'], [' ', ' ', ' ', '#'], [' ', ' ', ' ', '#'], ['a', 'b', 'c', 'd']],word = \"abcd\") == True\n assert candidate(board = [[' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' ']],word = \"abacaba\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#', ' ', '#'], [' ', 'a', ' ', 'b', ' ', 'c', ' '], ['#', ' ', '#', ' ', '#', ' ', '#'], [' ', 'd', ' ', 'e', ' ', 'f', ' ']],word = \"abcdef\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', 'a', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', 'c', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"race\") == False\n assert candidate(board = [['#', ' ', ' ', '#'], [' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', ' ', ' ', '#']],word = \"word\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#', ' ', '#'], ['#', 'g', '#', 'h', '#', 'i', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', 'j', '#', 'k', '#', 'l', '#'], ['#', ' ', '#', ' ', '#', ' ', '#']],word = \"ghijkl\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#']],word = \"word\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', '#', ' ', ' '], [' ', ' ', ' ', ' ']],word = \"a\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', ' ', '#'], ['#', 'b', 'c', '#'], ['#', ' ', ' ', '#'], ['#', 'd', ' ', 'e']],word = \"bcde\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"hello\") == False\n assert candidate(board = [['a', 'b', 'c', 'd', 'e'], ['#', '#', '#', '#', '#'], ['e', 'd', 'c', 'b', 'a'], ['#', '#', '#', '#', '#'], ['a', 'b', 'c', 'd', 'e']],word = \"abcde\") == True\n assert candidate(board = [['#', '#', '#'], ['a', ' ', 'a'], ['#', ' ', '#'], ['b', ' ', 'b'], ['#', '#', '#']],word = \"aba\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"java\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', 'a', ' ', 'a', ' '], ['#', ' ', '#', ' ', '#'], [' ', 'b', ' ', 'b', ' '], ['#', ' ', '#', ' ', '#']],word = \"abba\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', 'a', 'b', 'c', ' '], ['#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [['#', '#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', ' ', '#'], ['#', ' ', 'a', 'b', ' ', '#'], ['#', ' ', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#', '#']],word = \"ab\") == False\n assert candidate(board = [[' ', ' ', '#', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', '#', ' ', ' ']],word = \"hello\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], ['#', ' ', 'a', ' ', '#'], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"a\") == True\n assert candidate(board = [['a', ' ', ' ', '#'], [' ', 'b', ' ', '#'], [' ', ' ', 'c', ' '], ['#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"car\") == True\n assert candidate(board = [['#', '#', '#'], ['#', '#', '#'], ['#', '#', '#']],word = \"a\") == False\n assert candidate(board = [['a', 'b', 'c'], ['d', '#', 'e'], ['f', 'g', 'h'], ['i', 'j', 'k']],word = \"def\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', '#', 'a', '#', ' '], [' ', '#', ' ', '#', ' '], [' ', '#', 'b', '#', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"ba\") == False\n assert candidate(board = [['#', ' ', '#'], ['a', ' ', 'b'], ['#', ' ', '#'], ['c', ' ', 'd'], ['#', ' ', '#']],word = \"abcd\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', '#', '#', ' '], [' ', '#', '#', ' '], [' ', ' ', ' ', ' ']],word = \"abcd\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [[' ', '#', ' ', '#', ' '], ['#', 'a', '#', 'c', '#'], [' ', '#', ' ', '#', ' '], ['#', ' ', '#', 'a', '#']],word = \"ca\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', 'a', 'b', 'c'], [' ', ' ', ' ', ' ']],word = \"abc\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', '#'], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', '#'], ['#', ' ', '#', ' ', '#']],word = \"abcde\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', 'c', 'b', 'a', ' '], ['#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"cross\") == True\n", "comparison": "exact"}, "public_tests": ["[[\"#\",\" \",\"#\"],[\" \",\" \",\"#\"],[\"#\",\"c\",\" \"]]\n\"abc\"", "[[\" \",\"#\",\"a\"],[\" \",\"#\", \"c\"],[\" \",\"#\",\"a\"]]\n\"ac\"", "[[\"#\",\" \",\"#\"],[\" \",\" \",\"#\"],[\"#\",\" \",\"c\"]]\n\"ca\""], "hints": ["Check all possible placements for the word.", "There is a limited number of places where a word can start."], "metadata": {"canonical_parameter_names": ["board", "word"], "leetcode_dataset_entry_point": "Solution().placeWordInCrossword", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:22+00:00", "tests_total": 134, "tests_dropped": 13, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "matrix", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def placeWordInCrossword(self, board: list[list[str]], word: str) -> bool:", "container": "Solution", "callable": "placeWordInCrossword", "parameters": [{"name": "board", "type": "list[list[str]]"}, {"name": "word", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2019, "task_id": "the-score-of-students-solving-math-expression", "difficulty": "Hard", "problem_description": "You are given a string s that contains digits 0-9, addition symbols '+', and multiplication symbols '*' only, representing a valid math expression of single digit numbers (e.g., 3+5*2). This expression was given to n elementary school students. The students were instructed to get the answer of the expression by following this order of operations:\n\n1. Compute multiplication, reading from left to right; Then,\n2. Compute addition, reading from left to right.\n\nYou are given an integer array answers of length n, which are the submitted answers of the students in no particular order. You are asked to grade the answers, by following these rules:\n\n- If an answer equals the correct answer of the expression, this student will be rewarded 5 points;\n- Otherwise, if the answer could be interpreted as if the student applied the operators in the wrong order but had correct arithmetic, this student will be rewarded 2 points;\n- Otherwise, this student will be rewarded 0 points.\n\nReturn the sum of the points of the students.\n\nExample 1:\n\nInput: s = \"7+3*1*2\", answers = [20,13,42]\nOutput: 7\nExplanation: As illustrated above, the correct answer of the expression is 13, therefore one student is rewarded 5 points: [20,13,42]\nA student might have applied the operators in this wrong order: ((7+3)*1)*2 = 20. Therefore one student is rewarded 2 points: [20,13,42]\nThe points for the students are: [2,5,0]. The sum of the points is 2+5+0=7.\n\nExample 2:\n\nInput: s = \"3+5*2\", answers = [13,0,10,13,13,16,16]\nOutput: 19\nExplanation: The correct answer of the expression is 13, therefore three students are rewarded 5 points each: [13,0,10,13,13,16,16]\nA student might have applied the operators in this wrong order: ((3+5)*2 = 16. Therefore two students are rewarded 2 points: [13,0,10,13,13,16,16]\nThe points for the students are: [5,0,0,5,5,2,2]. The sum of the points is 5+0+0+5+5+2+2=19.\n\nExample 3:\n\nInput: s = \"6+0*1\", answers = [12,9,6,4,8,6]\nOutput: 10\nExplanation: The correct answer of the expression is 6.\nIf a student had incorrectly done (6+0)*1, the answer would also be 6.\nBy the rules of grading, the students will still be rewarded 5 points (as they got the correct answer), not 2 points.\nThe points for the students are: [0,0,5,0,0,5]. The sum of the points is 10.\n\nConstraints:\n\n- 3 <= s.length <= 31\n- s represents a valid expression that contains only digits 0-9, '+', and '*' only.\n- All the integer operands in the expression are in the inclusive range [0, 9].\n- 1 <= The count of all operators ('+' and '*') in the math expression <= 15\n- Test data are generated such that the correct answer of the expression is in the range of [0, 1000].\n- Test data are generated such that value never exceeds 10^9 in intermediate steps of multiplication.\n- n == answers.length\n- 1 <= n <= 10^4\n- 0 <= answers[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"3+5*2\",answers = [13, 0, 10, 13, 13, 16, 16]) == 19\n assert candidate(s = \"1+2*3+4*5\",answers = [14, 23, 13, 47, 23, 53]) == 2\n assert candidate(s = \"7+3*1*2\",answers = [20, 13, 42]) == 7\n assert candidate(s = \"5*4+3+2\",answers = [27, 20, 17, 25, 20, 30]) == 5\n assert candidate(s = \"5*3+2*2\",answers = [19, 17, 15, 13, 21]) == 5\n assert candidate(s = \"9*7+3*8\",answers = [78, 108, 70, 63, 136, 54, 110, 39, 103, 97]) == 0\n assert candidate(s = \"1+2*3+4\",answers = [11, 13, 15, 9]) == 9\n assert candidate(s = \"6+0*1\",answers = [12, 9, 6, 4, 8, 6]) == 10\n assert candidate(s = \"1+2*3+4\",answers = [23, 18, 21, 9, 10, 17, 14, 22, 20, 15]) == 4\n assert candidate(s = \"9+8*7+6*5+4*3+2*1\",answers = [268, 280, 292, 304, 316, 328, 340, 352, 364, 376]) == 0\n assert candidate(s = \"5+6*2+7*3+8*1\",answers = [63, 104, 80, 77, 63, 120]) == 2\n assert candidate(s = \"1*5+2*7+3*6+4\",answers = [56, 50, 47, 53, 58, 45, 51, 46, 49, 52]) == 2\n assert candidate(s = \"2*9+5*6*7+8\",answers = [226, 488, 628, 624, 226, 508]) == 0\n assert candidate(s = \"4*6+3*2+5*1+7*8+9*0\",answers = [74, 76, 78, 80, 82, 84, 86, 88, 90, 92]) == 2\n assert candidate(s = \"7+6*5+4*3+2*1\",answers = [181, 175, 169, 163, 157, 151, 145, 139, 133, 127]) == 4\n assert candidate(s = \"1*2*3*4*5+6\",answers = [126, 12, 36, 24, 126, 126]) == 15\n assert candidate(s = \"9*8+7*6+5*4\",answers = [203, 230, 247, 274, 263, 290, 307, 334, 343, 370]) == 0\n assert candidate(s = \"1+2*3+4*5+6\",answers = [71, 51, 83, 47, 79, 53, 77, 67, 89, 57, 59, 73, 41, 87, 85, 61, 65, 75]) == 20\n assert candidate(s = \"9+8*2*4+1\",answers = [153, 73, 161, 177, 145, 153]) == 4\n assert candidate(s = \"8*7+9*6+4\",answers = [158, 202, 156, 134, 164, 148, 162, 174]) == 0\n assert candidate(s = \"9+7*8+5*4\",answers = [155, 143, 139, 147, 135, 149, 153, 151, 157]) == 0\n assert candidate(s = \"7*3+1*2*4+6*5\",answers = [62, 122, 86, 74, 62, 86]) == 2\n assert candidate(s = \"1+2+3+4+5+6+7+8+9\",answers = [45, 44, 46, 43, 47, 42, 48, 41, 49]) == 5\n assert candidate(s = \"5*5*5+4*4*4+3*3*3+2*2*2+1*1*1\",answers = [657, 681, 679, 678, 680, 677, 676, 675, 674, 673, 672, 671, 670, 669, 668, 667, 666, 665, 664, 663]) == 14\n assert candidate(s = \"1*2*3+4*5+6*7+8*9\",answers = [204, 205, 203, 206, 202, 207, 201]) == 2\n assert candidate(s = \"8*9+7*6+5*4+3*2\",answers = [167, 173, 179, 185, 191, 197, 203, 209, 215, 221]) == 0\n assert candidate(s = \"3+8*5*2+7+6*4\",answers = [173, 185, 197, 209, 221, 233, 245, 257, 269, 281]) == 0\n assert candidate(s = \"5*6+7*2+8*1+9\",answers = [104, 100, 111, 110, 115, 120, 108, 116, 106, 118]) == 0\n assert candidate(s = \"2*3+4*5+6\",answers = [30, 46, 28, 52, 34, 38, 40, 42, 44, 50]) == 4\n assert candidate(s = \"3*4+2*5+1*6+8\",answers = [58, 54, 59, 65, 62, 68, 63, 66, 57, 60]) == 2\n assert candidate(s = \"5+9*3+8*2\",answers = [89, 71, 106, 58, 95, 125, 86, 92, 91]) == 2\n assert candidate(s = \"8*7+6*5+4*3+2*1\",answers = [134, 135, 133, 136, 132, 137, 131]) == 0\n assert candidate(s = \"1*2*3*4*5+6+7+8+9\",answers = [120, 150, 315, 369, 225, 252, 360, 270, 288]) == 7\n assert candidate(s = \"6+3*5*2+9*1\",answers = [48, 39, 69, 102, 57, 78]) == 0\n assert candidate(s = \"4*3+2*8+1*7+6\",answers = [63, 59, 66, 71, 60, 69, 64, 73, 68, 61]) == 0\n assert candidate(s = \"2*9+8*7+6*5+4*3\",answers = [192, 172, 162, 152, 187, 202, 207, 182, 197, 177, 167, 157, 184, 169, 159, 179, 199, 174, 189]) == 4\n assert candidate(s = \"1*2+3*4+5*6+7*8+9\",answers = [159, 173, 187, 201, 215, 229, 243, 257, 271, 285]) == 4\n assert candidate(s = \"6+5*4+3*2+1\",answers = [55, 51, 47, 43, 39, 35, 31, 27, 23, 19]) == 4\n assert candidate(s = \"9+1*8+2*3+7*4\",answers = [77, 81, 90, 83, 94, 100, 88, 97, 91, 105]) == 2\n assert candidate(s = \"9*8+7*6+5*4+3*2+1*0\",answers = [168, 172, 176, 180, 184, 188, 192, 196, 200, 204]) == 2\n assert candidate(s = \"2+3*4+5*6+7\",answers = [157, 172, 187, 202, 217, 232, 247, 262, 277, 292]) == 6\n assert candidate(s = \"9*0+8*1+7*2\",answers = [23, 15, 16, 8, 3, 17, 24, 22, 18, 9]) == 5\n assert candidate(s = \"1*2+3*4+5*6+7*8+9*0\",answers = [120, 93, 115, 132, 108, 114, 102, 130, 128, 124, 123, 125, 126, 127, 129, 121, 122, 131, 133, 134]) == 2\n assert candidate(s = \"1+1*1+1*1+1*1+1*1+1*1+1*1+1*1\",answers = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 25\n assert candidate(s = \"9*8+7*6+5*4+3*2+1\",answers = [383, 410, 437, 464, 491, 518, 545, 572, 599, 626]) == 4\n assert candidate(s = \"3*3+2*2+1*1\",answers = [15, 12, 13, 14, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(s = \"7*1+6*2+5*3\",answers = [47, 37, 41, 43, 49, 53, 55, 57, 61, 63]) == 2\n assert candidate(s = \"4*1*3+5*2\",answers = [22, 14, 16, 17, 18, 19, 20, 21, 23]) == 5\n assert candidate(s = \"9+8*7+6*5+4*3+2*1\",answers = [383, 357, 347, 358, 356, 365, 359, 348, 350, 351, 349, 352, 353, 354, 355, 346, 345, 364, 366, 367]) == 2\n assert candidate(s = \"8*2+3*9+4*1+5\",answers = [69, 76, 108, 98, 63, 110, 95, 80, 73, 83]) == 0\n assert candidate(s = \"8+9*2+3*4*5+6\",answers = [222, 185, 223, 197, 196, 231, 229, 226, 220, 225, 221, 228, 227, 219, 218, 217, 230, 232, 233, 234]) == 2\n assert candidate(s = \"9*9+8*8+7*7+6*6\",answers = [320, 311, 314, 317, 323, 332, 335, 338, 341, 347, 344, 350, 353, 356, 359, 365, 368, 371, 374, 380, 383, 386, 389, 395, 392, 398]) == 0\n assert candidate(s = \"8*9+7*6+5*4+3*2+1\",answers = [163, 177, 181, 185, 189, 193, 197, 201, 205, 209]) == 4\n assert candidate(s = \"9*2+1*6+4*5+8*3\",answers = [124, 122, 121, 126, 125, 123, 127, 120, 128, 119]) == 2\n assert candidate(s = \"2+3*4+5*6\",answers = [106, 110, 74, 86, 62, 140, 106, 128]) == 0\n assert candidate(s = \"9*3+8*2+7*1\",answers = [55, 63, 95, 100, 111, 120, 123, 115, 116, 119, 102, 87, 90, 83, 93]) == 0\n assert candidate(s = \"1*9+8*2+3*7+5\",answers = [85, 100, 80, 88, 93, 95, 91, 107, 105, 98]) == 0\n assert candidate(s = \"1*2+3*4+5*6\",answers = [101, 39, 45, 81, 29, 143, 51, 17, 135, 65]) == 0\n assert candidate(s = \"6*4+3*2+1*5+7\",answers = [45, 43, 47, 52, 46, 44, 48, 50, 49, 51]) == 2\n assert candidate(s = \"2*3+4*5+6*7+8*9+0\",answers = [234, 248, 262, 276, 290, 304, 318, 332, 346, 360]) == 0\n assert candidate(s = \"2+3*4+5*6+7\",answers = [107, 110, 113, 104, 116, 109, 115, 108, 111, 112]) == 2\n assert candidate(s = \"8*7+4*2+1\",answers = [65, 100, 57, 60, 93, 120, 81, 65, 96, 104]) == 10\n assert candidate(s = \"2*3+5*6+7\",answers = [41, 101, 38, 47, 110, 83, 37, 53, 61, 56]) == 2\n assert candidate(s = \"9*8+7*6+5*4+3*2+1\",answers = [234, 197, 207, 198, 209, 205, 214, 218, 216, 215, 213, 212, 210, 211, 208, 206, 204, 203, 202, 201]) == 2\n assert candidate(s = \"5*5+4*4+3*3+2*2\",answers = [105, 85, 135, 90, 110, 100, 120, 115, 130, 95, 101, 125, 80, 91, 87, 83, 89]) == 6\n assert candidate(s = \"1*3+2*4+5*6+7*8\",answers = [109, 113, 137, 141, 145, 149, 153, 161, 165, 169]) == 2\n assert candidate(s = \"3*6+2*7+8*9\",answers = [134, 132, 136, 130, 128, 138, 140, 126, 142]) == 2\n assert candidate(s = \"1*2+3*4+5*6+7*8\",answers = [497, 524, 551, 578, 605, 632, 659, 686, 713, 740]) == 2\n assert candidate(s = \"1+2+3+4+5+6+7+8+9+0\",answers = [45, 46, 44, 43, 47, 48, 42]) == 5\n assert candidate(s = \"4*2+1*3+5*6+7\",answers = [51, 49, 67, 51, 67, 69]) == 0\n assert candidate(s = \"9*1+8*2+7*3+6\",answers = [92, 110, 113, 92, 113, 110]) == 0\n assert candidate(s = \"8+7*6+5*4+3*2+1*0\",answers = [177, 185, 184, 186, 183, 182, 181, 180, 179, 178, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167]) == 2\n assert candidate(s = \"1*2+3*4+5*6+7*8+9*0\",answers = [88, 92, 96, 100, 104, 108, 112, 116, 120, 124]) == 7\n assert candidate(s = \"8*3+2*7+9*5+4*1\",answers = [124, 116, 127, 119, 118, 120, 121, 117, 126, 122]) == 2\n assert candidate(s = \"9*8+7*6+5*4+3*2+1*0\",answers = [162, 178, 194, 210, 226, 242, 258, 274, 290, 306]) == 4\n assert candidate(s = \"3*5+2*4+6\",answers = [33, 50, 38, 46, 40, 64, 54, 28, 58, 42]) == 0\n assert candidate(s = \"9+8*7+6*5+4*3+2*1+0\",answers = [389, 388, 390, 391, 387, 392, 386]) == 2\n assert candidate(s = \"1+2*3+4*5+6*7+8*9\",answers = [528, 526, 527, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545]) == 10\n assert candidate(s = \"2*3+4*5+6*7\",answers = [65, 51, 47, 45, 41, 37, 35, 31, 29, 27]) == 0\n assert candidate(s = \"5*3*6+2*8+1\",answers = [91, 100, 110, 120, 95, 93, 99, 105, 94, 101, 97, 96, 102, 98, 103, 92, 90, 104, 106, 91]) == 0\n assert candidate(s = \"3+5*6+7*2+8\",answers = [109, 119, 80, 103, 109, 119]) == 2\n assert candidate(s = \"8*3+4*2+5\",answers = [37, 70, 100, 61, 51, 41, 37]) == 12\n assert candidate(s = \"6*3+4*2+1+5*3\",answers = [44, 53, 49, 41, 57, 61, 56, 67, 65, 46]) == 2\n assert candidate(s = \"3*3*3*3*3+2+1\",answers = [244, 242, 243, 245, 246, 247]) == 5\n assert candidate(s = \"8*6+5*3+2*1\",answers = [56, 51, 106, 103, 83, 96, 90, 113, 78, 111, 54, 122]) == 0\n assert candidate(s = \"7*6+5*4+3*2+1*0\",answers = [62, 57, 67, 72, 69, 75, 77, 74, 71, 52, 64, 76, 78, 73, 53, 65, 70, 66, 68, 61, 56, 60, 59, 58, 55, 54, 51, 50, 49]) == 7\n assert candidate(s = \"8*3+7*2+9*4\",answers = [118, 154, 106, 94, 210, 142, 126, 130, 182, 166]) == 0\n assert candidate(s = \"5*3+2*8+9*7\",answers = [108, 131, 128, 136, 119, 131, 142, 123, 127, 131]) == 0\n assert candidate(s = \"3*8+2*6+5*9+1*7\",answers = [140, 138, 137, 142, 141, 139, 143, 136, 144, 145]) == 2\n assert candidate(s = \"1+2*3+4*5+6*7+8*9\",answers = [277, 278, 276, 275, 279, 280, 274]) == 2\n assert candidate(s = \"4*4+3*3+2*2+1*1\",answers = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(s = \"9*3+8*2+7*6+5\",answers = [139, 167, 145, 151, 146, 158, 147, 148, 152, 150]) == 2\n assert candidate(s = \"7*2+3*9+1*6+5*8\",answers = [155, 148, 149, 151, 147, 152, 150, 146, 154, 153]) == 0\n assert candidate(s = \"1+2*3+4*5+6\",answers = [78, 54, 72, 86, 94, 104, 118, 126, 138, 158]) == 0\n assert candidate(s = \"3*6+2*5+4*7\",answers = [54, 59, 66, 74, 81, 83, 88, 60, 71, 78]) == 0\n assert candidate(s = \"8*7+5*6+2\",answers = [65, 106, 122, 158, 162, 232, 250, 188, 210, 202]) == 0\n assert candidate(s = \"7*6+5*3+2*4+1\",answers = [74, 78, 83, 79, 87, 81, 85, 76, 82, 86]) == 0\n assert candidate(s = \"5+4*3+2*1+0\",answers = [19, 25, 17, 15, 23, 27, 30]) == 7\n assert candidate(s = \"2+5*3*2+4\",answers = [40, 42, 38, 50, 36, 74, 68, 54, 82, 80]) == 7\n assert candidate(s = \"5*9+4*8+3*7\",answers = [102, 105, 116, 121, 135, 132, 93, 113, 143, 150]) == 0\n assert candidate(s = \"4+3*2*1+5\",answers = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3]) == 7\n assert candidate(s = \"3*3+2*2+1*1\",answers = [14, 16, 12, 18, 15, 13, 17, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 19]) == 7\n assert candidate(s = \"6+7*8+9*2\",answers = [169, 137, 154, 131, 166, 152, 145, 158, 170]) == 0\n assert candidate(s = \"1*2*3*4*5\",answers = [120, 20, 60, 30, 10, 240, 15, 40, 6]) == 5\n assert candidate(s = \"5+9*8+7*6+4*3+2*1\",answers = [279, 283, 287, 291, 295, 299, 303, 307, 311, 315]) == 2\n", "comparison": "exact"}, "public_tests": ["\"7+3*1*2\"\n[20,13,42]", "\"3+5*2\"\n[13,0,10,13,13,16,16]", "\"6+0*1\"\n[12,9,6,4,8,6]"], "hints": ["The number of operators in the equation is less. Could you find the right answer then generate all possible answers using different orders of operations?", "Divide the equation into blocks separated by the operators, and use memoization on the results of blocks for optimization.", "Use set and the max limit of the answer for further optimization."], "metadata": {"canonical_parameter_names": ["s", "answers"], "leetcode_dataset_entry_point": "Solution().scoreOfStudents", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:24+00:00", "tests_total": 109, "tests_dropped": 4, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "hash-table", "math", "string", "dynamic-programming", "stack", "memoization"]}, "language": "python", "interface": {"raw_signature": "def scoreOfStudents(self, s: str, answers: list[int]) -> int:", "container": "Solution", "callable": "scoreOfStudents", "parameters": [{"name": "s", "type": "str"}, {"name": "answers", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2022, "task_id": "convert-1d-array-into-2d-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with m rows and n columns using all the elements from original.\n\nThe elements from indices 0 to n - 1 (inclusive) of original should form the first row of the constructed 2D array, the elements from indices n to 2 * n - 1 (inclusive) should form the second row of the constructed 2D array, and so on.\n\nReturn an m x n 2D array constructed according to the above procedure, or an empty 2D array if it is impossible.\n\nExample 1:\n\nInput: original = [1,2,3,4], m = 2, n = 2\nOutput: [[1,2],[3,4]]\nExplanation: The constructed 2D array should contain 2 rows and 2 columns.\nThe first group of n=2 elements in original, [1,2], becomes the first row in the constructed 2D array.\nThe second group of n=2 elements in original, [3,4], becomes the second row in the constructed 2D array.\n\nExample 2:\n\nInput: original = [1,2,3], m = 1, n = 3\nOutput: [[1,2,3]]\nExplanation: The constructed 2D array should contain 1 row and 3 columns.\nPut all three elements in original into the first row of the constructed 2D array.\n\nExample 3:\n\nInput: original = [1,2], m = 1, n = 1\nOutput: []\nExplanation: There are 2 elements in original.\nIt is impossible to fit 2 elements in a 1x1 2D array, so return an empty 2D array.\n\nConstraints:\n\n- 1 <= original.length <= 5 * 10^4\n- 1 <= original[i] <= 10^5\n- 1 <= m, n <= 4 * 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(original = [5, 6, 7, 8, 9, 10, 11, 12],m = 4,n = 2) == [[5, 6], [7, 8], [9, 10], [11, 12]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9],m = 3,n = 3) == [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n assert candidate(original = [9, 10, 11, 12, 13, 14],m = 2,n = 3) == [[9, 10, 11], [12, 13, 14]]\n assert candidate(original = [1, 2],m = 1,n = 1) == []\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8],m = 4,n = 2) == [[1, 2], [3, 4], [5, 6], [7, 8]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],m = 3,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]\n assert candidate(original = [3, 3, 3, 3, 3, 3],m = 2,n = 3) == [[3, 3, 3], [3, 3, 3]]\n assert candidate(original = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,n = 3) == [[9, 8, 7], [6, 5, 4], [3, 2, 1]]\n assert candidate(original = [1, 2, 3, 4, 5, 6],m = 2,n = 3) == [[1, 2, 3], [4, 5, 6]]\n assert candidate(original = [10, 20, 30, 40, 50],m = 5,n = 1) == [[10], [20], [30], [40], [50]]\n assert candidate(original = [5, 6, 7, 8, 9, 10],m = 2,n = 3) == [[5, 6, 7], [8, 9, 10]]\n assert candidate(original = [42, 43, 44, 45, 46, 47, 48, 49, 50],m = 3,n = 3) == [[42, 43, 44], [45, 46, 47], [48, 49, 50]]\n assert candidate(original = [1, 2, 3, 4],m = 2,n = 2) == [[1, 2], [3, 4]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 2,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]\n assert candidate(original = [25, 26, 27],m = 3,n = 1) == [[25], [26], [27]]\n assert candidate(original = [1, 2, 3],m = 1,n = 3) == [[1, 2, 3]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],m = 4,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]\n assert candidate(original = [5, 6, 7, 8, 9],m = 1,n = 5) == [[5, 6, 7, 8, 9]]\n assert candidate(original = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24],m = 5,n = 2) == [[15, 16], [17, 18], [19, 20], [21, 22], [23, 24]]\n assert candidate(original = [1],m = 1,n = 1) == [[1]]\n assert candidate(original = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41],m = 3,n = 4) == [[30, 31, 32, 33], [34, 35, 36, 37], [38, 39, 40, 41]]\n assert candidate(original = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],m = 4,n = 3) == [[10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]]\n assert candidate(original = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],m = 6,n = 6) == []\n assert candidate(original = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 7,n = 5) == []\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 5,n = 6) == [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]\n assert candidate(original = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],m = 5,n = 2) == [[1000, 2000], [3000, 4000], [5000, 6000], [7000, 8000], [9000, 10000]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],m = 5,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]\n assert candidate(original = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],m = 3,n = 4) == [[100, 200, 300, 400], [500, 600, 700, 800], [900, 1000, 1100, 1200]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],m = 10,n = 5) == [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39], [41, 43, 45, 47, 49], [51, 53, 55, 57, 59], [61, 63, 65, 67, 69], [71, 73, 75, 77, 79], [81, 83, 85, 87, 89], [91, 93, 95, 97, 99]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 5,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],m = 5,n = 5) == [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39], [41, 43, 45, 47, 49]]\n assert candidate(original = [12345],m = 1,n = 1) == [[12345]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],m = 5,n = 8) == [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 3,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]\n assert candidate(original = [99, 88, 77, 66, 55, 44, 33, 22, 11],m = 3,n = 3) == [[99, 88, 77], [66, 55, 44], [33, 22, 11]]\n assert candidate(original = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 4,n = 4) == [[5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]\n assert candidate(original = [42],m = 1,n = 1) == [[42]]\n assert candidate(original = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255],m = 5,n = 5) == []\n assert candidate(original = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160],m = 5,n = 4) == [[8, 16, 24, 32], [40, 48, 56, 64], [72, 80, 88, 96], [104, 112, 120, 128], [136, 144, 152, 160]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],m = 10,n = 5) == [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39], [41, 43, 45, 47, 49], [51, 53, 55, 57, 59], [61, 63, 65, 67, 69], [71, 73, 75, 77, 79], [81, 83, 85, 87, 89], [91, 93, 95, 97, 99]]\n assert candidate(original = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,n = 3) == [[9, 8, 7], [6, 5, 4], [3, 2, 1]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10,n = 1) == [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],m = 6,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24]]\n assert candidate(original = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240],m = 6,n = 4) == [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160], [170, 180, 190, 200], [210, 220, 230, 240]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60],m = 6,n = 10) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60]]\n assert candidate(original = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,n = 5) == [[15, 14, 13, 12, 11], [10, 9, 8, 7, 6], [5, 4, 3, 2, 1]]\n assert candidate(original = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],m = 5,n = 5) == [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30], [32, 34, 36, 38, 40], [42, 44, 46, 48, 50]]\n assert candidate(original = [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],m = 10,n = 10) == []\n assert candidate(original = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 6,n = 5) == []\n assert candidate(original = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],m = 2,n = 5) == [[1000, 2000, 3000, 4000, 5000], [6000, 7000, 8000, 9000, 10000]]\n assert candidate(original = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],m = 3,n = 4) == [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],m = 10,n = 10) == []\n assert candidate(original = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70],m = 5,n = 6) == [[99, 98, 97, 96, 95, 94], [93, 92, 91, 90, 89, 88], [87, 86, 85, 84, 83, 82], [81, 80, 79, 78, 77, 76], [75, 74, 73, 72, 71, 70]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],m = 7,n = 7) == []\n assert candidate(original = [5, 15, 25, 35, 45, 55, 65, 75],m = 2,n = 4) == [[5, 15, 25, 35], [45, 55, 65, 75]]\n assert candidate(original = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],m = 5,n = 3) == [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50, 55, 60], [65, 70, 75]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],m = 10,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40], [41, 42, 43, 44, 45], [46, 47, 48, 49, 50]]\n assert candidate(original = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 10,n = 10) == []\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60],m = 6,n = 10) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60]]\n assert candidate(original = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],m = 4,n = 4) == [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60], [65, 70, 75, 80]]\n assert candidate(original = [1, 2, 3, 4, 5],m = 1,n = 5) == [[1, 2, 3, 4, 5]]\n assert candidate(original = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],m = 7,n = 3) == [[42, 42, 42], [42, 42, 42], [42, 42, 42], [42, 42, 42], [42, 42, 42], [42, 42, 42], [42, 42, 42]]\n assert candidate(original = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90],m = 6,n = 3) == [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50, 55, 60], [65, 70, 75], [80, 85, 90]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],m = 8,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40]]\n assert candidate(original = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120],m = 6,n = 10) == [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [22, 24, 26, 28, 30, 32, 34, 36, 38, 40], [42, 44, 46, 48, 50, 52, 54, 56, 58, 60], [62, 64, 66, 68, 70, 72, 74, 76, 78, 80], [82, 84, 86, 88, 90, 92, 94, 96, 98, 100], [102, 104, 106, 108, 110, 112, 114, 116, 118, 120]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 4,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],m = 4,n = 4) == [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23], [25, 27, 29, 31]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 5,n = 6) == [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],m = 10,n = 10) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27],m = 3,n = 9) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],m = 4,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]\n assert candidate(original = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],m = 4,n = 5) == [[3, 6, 9, 12, 15], [18, 21, 24, 27, 30], [33, 36, 39, 42, 45], [48, 51, 54, 57, 60]]\n assert candidate(original = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],m = 2,n = 5) == [[5, 10, 15, 20, 25], [30, 35, 40, 45, 50]]\n assert candidate(original = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],m = 4,n = 5) == [[99, 98, 97, 96, 95], [94, 93, 92, 91, 90], [89, 88, 87, 86, 85], [84, 83, 82, 81, 80]]\n assert candidate(original = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400],m = 4,n = 6) == [[100, 200, 300, 400, 500, 600], [700, 800, 900, 1000, 1100, 1200], [1300, 1400, 1500, 1600, 1700, 1800], [1900, 2000, 2100, 2200, 2300, 2400]]\n assert candidate(original = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],m = 4,n = 4) == [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]]\n assert candidate(original = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],m = 2,n = 5) == [[1000, 2000, 3000, 4000, 5000], [6000, 7000, 8000, 9000, 10000]]\n assert candidate(original = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020, 2121, 2222, 2323, 2424, 2525],m = 5,n = 5) == [[101, 202, 303, 404, 505], [606, 707, 808, 909, 1010], [1111, 1212, 1313, 1414, 1515], [1616, 1717, 1818, 1919, 2020], [2121, 2222, 2323, 2424, 2525]]\n assert candidate(original = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986],m = 3,n = 5) == [[100000, 99999, 99998, 99997, 99996], [99995, 99994, 99993, 99992, 99991], [99990, 99989, 99988, 99987, 99986]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],m = 5,n = 10) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]]\n assert candidate(original = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],m = 5,n = 3) == [[10, 20, 30], [40, 50, 60], [70, 80, 90], [100, 110, 120], [130, 140, 150]]\n assert candidate(original = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135],m = 9,n = 4) == [[100, 101, 102, 103], [104, 105, 106, 107], [108, 109, 110, 111], [112, 113, 114, 115], [116, 117, 118, 119], [120, 121, 122, 123], [124, 125, 126, 127], [128, 129, 130, 131], [132, 133, 134, 135]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],m = 2,n = 13) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]]\n assert candidate(original = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],m = 5,n = 3) == [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200], [1300, 1400, 1500]]\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]\n2\n2", "[1,2,3]\n1\n3", "[1,2]\n1\n1"], "hints": ["When is it possible to convert original into a 2D array and when is it impossible?", "It is possible if and only if m * n == original.length", "If it is possible to convert original to a 2D array, keep an index i such that original[i] is the next element to add to the 2D array."], "metadata": {"canonical_parameter_names": ["original", "m", "n"], "leetcode_dataset_entry_point": "Solution().construct2DArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:29+00:00", "tests_total": 85, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "matrix", "simulation"]}, "language": "python", "interface": {"raw_signature": "def construct2DArray(self, original: list[int], m: int, n: int) -> list[list[int]]:", "container": "Solution", "callable": "construct2DArray", "parameters": [{"name": "original", "type": "list[int]"}, {"name": "m", "type": "int"}, {"name": "n", "type": "int"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2023, "task_id": "number-of-pairs-of-strings-with-concatenation-equal-to-target", "difficulty": "Medium", "problem_description": "Given an array of digit strings nums and a digit string target, return the number of pairs of indices (i, j) (where i != j) such that the concatenation of nums[i] + nums[j] equals target.\n\nExample 1:\n\nInput: nums = [\"777\",\"7\",\"77\",\"77\"], target = \"7777\"\nOutput: 4\nExplanation: Valid pairs are:\n- (0, 1): \"777\" + \"7\"\n- (1, 0): \"7\" + \"777\"\n- (2, 3): \"77\" + \"77\"\n- (3, 2): \"77\" + \"77\"\n\nExample 2:\n\nInput: nums = [\"123\",\"4\",\"12\",\"34\"], target = \"1234\"\nOutput: 2\nExplanation: Valid pairs are:\n- (0, 1): \"123\" + \"4\"\n- (2, 3): \"12\" + \"34\"\n\nExample 3:\n\nInput: nums = [\"1\",\"1\",\"1\"], target = \"11\"\nOutput: 6\nExplanation: Valid pairs are:\n- (0, 1): \"1\" + \"1\"\n- (1, 0): \"1\" + \"1\"\n- (0, 2): \"1\" + \"1\"\n- (2, 0): \"1\" + \"1\"\n- (1, 2): \"1\" + \"1\"\n- (2, 1): \"1\" + \"1\"\n\nConstraints:\n\n- 2 <= nums.length <= 100\n- 1 <= nums[i].length <= 100\n- 2 <= target.length <= 100\n- nums[i] and target consist of digits.\n- nums[i] and target do not have leading zeros.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = ['777', '7', '77', '77'],target = \"7777\") == 4\n assert candidate(nums = ['10', '11', '1'],target = \"101\") == 1\n assert candidate(nums = ['1234', '56', '78', '9'],target = \"123456\") == 1\n assert candidate(nums = ['99', '9', '999'],target = \"9999\") == 2\n assert candidate(nums = ['50', '2', '5', '0'],target = \"5025\") == 0\n assert candidate(nums = ['10', '100', '1'],target = \"10100\") == 1\n assert candidate(nums = ['123', '4', '12', '34'],target = \"1234\") == 2\n assert candidate(nums = ['50', '5', '500'],target = \"505\") == 1\n assert candidate(nums = ['1', '1', '1'],target = \"11\") == 6\n assert candidate(nums = ['123', '234', '345', '456', '567', '678', '789', '890'],target = \"123234\") == 1\n assert candidate(nums = ['66', '666', '6666', '66666'],target = \"66666666\") == 2\n assert candidate(nums = ['33', '3', '333', '3333', '33'],target = \"333333\") == 4\n assert candidate(nums = ['555', '55', '5', '5555'],target = \"555555\") == 2\n assert candidate(nums = ['1', '1', '2', '2', '3', '3'],target = \"11\") == 2\n assert candidate(nums = ['78', '87', '7', '8'],target = \"7887\") == 1\n assert candidate(nums = ['7777', '777', '77', '7'],target = \"7777777\") == 2\n assert candidate(nums = ['0', '00', '000', '0000'],target = \"0000\") == 2\n assert candidate(nums = ['001', '010', '100', '1'],target = \"1001\") == 2\n assert candidate(nums = ['15', '51', '1515', '151', '515'],target = \"151515\") == 3\n assert candidate(nums = ['10', '01', '100', '001', '1000', '0001'],target = \"1001\") == 1\n assert candidate(nums = ['789', '897', '978', '78', '89', '97'],target = \"789897\") == 1\n assert candidate(nums = ['10', '20', '30', '40', '50'],target = \"1020\") == 1\n assert candidate(nums = ['1234', '5678', '4321', '8765'],target = \"12345678\") == 1\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999'],target = \"111222\") == 1\n assert candidate(nums = ['5', '55', '555', '5555', '55555'],target = \"555555\") == 4\n assert candidate(nums = ['9', '99', '999', '9999'],target = \"999999\") == 2\n assert candidate(nums = ['18', '81', '181', '818', '1818'],target = \"181818\") == 3\n assert candidate(nums = ['20', '02', '2', '2002'],target = \"200202\") == 1\n assert candidate(nums = ['5', '55', '555', '5555'],target = \"55555\") == 4\n assert candidate(nums = ['9', '99', '999', '9999', '99999'],target = \"999999\") == 4\n assert candidate(nums = ['90', '09', '9', '0'],target = \"9009\") == 1\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9'],target = \"12\") == 1\n assert candidate(nums = ['111', '222', '333', '111', '222'],target = \"111222\") == 4\n assert candidate(nums = ['222', '2222', '2', '22', '22222'],target = \"22222222\") == 2\n assert candidate(nums = ['1234', '5678', '12', '34', '56', '78'],target = \"12345678\") == 1\n assert candidate(nums = ['111', '222', '333', '444'],target = \"111222\") == 1\n assert candidate(nums = ['98765', '4321', '9876', '54321'],target = \"987654321\") == 2\n assert candidate(nums = ['90', '909', '09', '9'],target = \"90909\") == 2\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '09'],target = \"09\") == 1\n assert candidate(nums = ['100000', '10000', '1000', '100', '10', '1'],target = \"10000010000\") == 1\n assert candidate(nums = ['0', '0', '0', '0'],target = \"00\") == 12\n assert candidate(nums = ['8', '88', '888', '8888'],target = \"88888\") == 4\n assert candidate(nums = ['123', '456', '789', '0', '1', '2'],target = \"123456\") == 1\n assert candidate(nums = ['111111', '11111', '1111', '111', '11'],target = \"111111111\") == 4\n assert candidate(nums = ['100', '200', '300', '400', '500'],target = \"100200\") == 1\n assert candidate(nums = ['123', '234', '345', '456', '567'],target = \"123234\") == 1\n assert candidate(nums = ['1234', '4321', '2341', '3412', '5678', '8765', '6785', '7856'],target = \"12344321\") == 1\n assert candidate(nums = ['123', '345', '567', '789'],target = \"123345\") == 1\n assert candidate(nums = ['10', '20', '30', '40', '50'],target = \"2030\") == 1\n assert candidate(nums = ['0000', '000', '00', '0'],target = \"00000000\") == 0\n assert candidate(nums = ['0001', '10', '01', '1'],target = \"00011\") == 1\n assert candidate(nums = ['123', '456', '789', '0'],target = \"123456\") == 1\n assert candidate(nums = ['16', '61', '161', '6', '1661'],target = \"166161\") == 1\n assert candidate(nums = ['21', '12', '22', '11', '2112'],target = \"211221\") == 1\n assert candidate(nums = ['42', '424', '2', '4'],target = \"4242\") == 1\n assert candidate(nums = ['777', '77', '7', '7777'],target = \"777777\") == 2\n assert candidate(nums = ['11', '11', '11', '11', '11'],target = \"1111\") == 20\n assert candidate(nums = ['19', '91', '191', '9', '1991'],target = \"199191\") == 1\n assert candidate(nums = ['987654321', '123456789', '1234', '4321'],target = \"987654321123456789\") == 1\n assert candidate(nums = ['111111', '1111', '111', '11', '1'],target = \"111111111111\") == 0\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],target = \"12\") == 1\n assert candidate(nums = ['1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],target = \"11\") == 90\n assert candidate(nums = ['101', '101', '101', '101'],target = \"101101\") == 12\n assert candidate(nums = ['8888', '888', '88', '8', '88', '888', '8888'],target = \"88888888\") == 2\n assert candidate(nums = ['22', '2', '222', '2222'],target = \"222222\") == 2\n assert candidate(nums = ['123456', '654321', '1234', '4321', '5678', '8765'],target = \"123456654321\") == 1\n assert candidate(nums = ['12', '21', '11', '22'],target = \"1221\") == 1\n assert candidate(nums = ['55', '555', '5555', '55555'],target = \"5555555\") == 4\n assert candidate(nums = ['14', '41', '144', '4'],target = \"1441\") == 1\n assert candidate(nums = ['8', '88', '888', '8888', '88888', '888888'],target = \"8888888\") == 6\n assert candidate(nums = ['12', '23', '34', '45', '56'],target = \"2345\") == 1\n assert candidate(nums = ['12345', '54321', '123', '321', '12', '21'],target = \"1234554321\") == 1\n assert candidate(nums = ['55', '5', '555', '5555'],target = \"55555\") == 4\n assert candidate(nums = ['987', '654', '321', '654'],target = \"987654\") == 2\n assert candidate(nums = ['111', '11', '1', '1111', '11111'],target = \"1111111\") == 4\n assert candidate(nums = ['1234', '4321', '2341', '3412'],target = \"12344321\") == 1\n assert candidate(nums = ['101', '01', '10', '1'],target = \"1010\") == 0\n assert candidate(nums = ['8', '88', '888', '8888', '88888'],target = \"888888888\") == 2\n assert candidate(nums = ['6', '66', '666', '6666'],target = \"666666\") == 2\n assert candidate(nums = ['10', '01', '0', '1'],target = \"1001\") == 1\n assert candidate(nums = ['10', '20', '30', '40', '50', '60', '70', '80', '90'],target = \"1020\") == 1\n assert candidate(nums = ['111', '11', '1', '1111'],target = \"111111\") == 2\n assert candidate(nums = ['1', '2', '3', '4', '5'],target = \"12\") == 1\n assert candidate(nums = ['111', '222', '112', '121', '211'],target = \"111222\") == 1\n assert candidate(nums = ['12345', '23456', '34567', '45678', '56789'],target = \"1234523456\") == 1\n assert candidate(nums = ['12', '12', '12', '12'],target = \"1212\") == 12\n assert candidate(nums = ['555', '55', '5', '5555', '55555'],target = \"5555555\") == 4\n assert candidate(nums = ['23', '32', '232', '2', '3223'],target = \"233223\") == 1\n assert candidate(nums = ['11', '22', '33', '44', '55', '66', '77', '88', '99'],target = \"1122\") == 1\n assert candidate(nums = ['123', '321', '213', '132', '231', '312'],target = \"123213\") == 1\n assert candidate(nums = ['12', '21', '121', '212'],target = \"1212\") == 0\n assert candidate(nums = ['555', '555', '555', '555', '555'],target = \"555555\") == 20\n assert candidate(nums = ['89', '98', '8998', '9889'],target = \"899889\") == 2\n assert candidate(nums = ['22', '222', '2', '2222'],target = \"222222\") == 2\n assert candidate(nums = ['23', '32', '123', '456', '654', '321'],target = \"23456\") == 1\n assert candidate(nums = ['9876', '8765', '7654', '6543', '5432', '4321', '3210', '2109'],target = \"98768765\") == 1\n assert candidate(nums = ['1010', '0101', '10', '01', '101', '010'],target = \"10100101\") == 1\n assert candidate(nums = ['90', '80', '70', '60'],target = \"7080\") == 1\n assert candidate(nums = ['101', '010', '10', '01'],target = \"101010\") == 1\n assert candidate(nums = ['9', '99', '999', '9999'],target = \"99999999\") == 0\n assert candidate(nums = ['5050', '50', '5', '500', '5000'],target = \"505050\") == 2\n assert candidate(nums = ['12', '21', '121', '112'],target = \"12112\") == 2\n assert candidate(nums = ['13', '31', '1', '3'],target = \"1331\") == 1\n assert candidate(nums = ['2', '22', '222', '2222', '22222'],target = \"222222\") == 4\n assert candidate(nums = ['2020', '20', '2', '0202'],target = \"202020\") == 2\n assert candidate(nums = ['12', '23', '34', '45', '56', '67', '78', '89'],target = \"1223\") == 1\n assert candidate(nums = ['999', '99', '9', '9999'],target = \"9999999\") == 2\n assert candidate(nums = ['00', '0', '000', '0000'],target = \"000000\") == 2\n assert candidate(nums = ['17', '71', '1717', '717', '177'],target = \"171717\") == 2\n assert candidate(nums = ['987', '876', '765', '654', '543'],target = \"987876\") == 1\n assert candidate(nums = ['12', '23', '34', '45', '56', '67', '78', '89', '90'],target = \"1223\") == 1\n assert candidate(nums = ['12', '12', '12', '12', '12', '12', '12', '12', '12', '12'],target = \"1212\") == 90\n assert candidate(nums = ['00', '000', '0000', '00000'],target = \"00000000\") == 2\n assert candidate(nums = ['1010', '10', '1', '101', '10101'],target = \"10101010\") == 0\n assert candidate(nums = ['12', '23', '34', '45', '56'],target = \"1223\") == 1\n assert candidate(nums = ['55', '5', '555', '5555'],target = \"5555\") == 2\n assert candidate(nums = ['1234', '456', '12', '3456'],target = \"123456\") == 1\n assert candidate(nums = ['45', '54', '4', '5'],target = \"4554\") == 1\n assert candidate(nums = ['10', '01', '100', '1'],target = \"101\") == 2\n assert candidate(nums = ['100', '10', '1', '1000'],target = \"1001000\") == 1\n assert candidate(nums = ['1111', '111', '11', '1'],target = \"11111111\") == 0\n assert candidate(nums = ['11', '111', '1111', '11111'],target = \"111111111\") == 2\n assert candidate(nums = ['9876', '8769', '7698', '6987', '987', '876', '769', '698'],target = \"98768769\") == 1\n assert candidate(nums = ['12345', '67890', '123', '4567890'],target = \"1234567890\") == 2\n assert candidate(nums = ['9', '9', '9', '9', '9', '9', '9', '9', '9', '9'],target = \"99\") == 90\n assert candidate(nums = ['123', '456', '789', '1234'],target = \"123456\") == 1\n assert candidate(nums = ['1234', '5678', '91011', '121314'],target = \"12345678\") == 1\n", "comparison": "exact"}, "public_tests": ["[\"777\",\"7\",\"77\",\"77\"]\n\"7777\"", "[\"123\",\"4\",\"12\",\"34\"]\n\"1234\"", "[\"1\",\"1\",\"1\"]\n\"11\""], "hints": ["Try to concatenate every two different strings from the list.", "Count the number of pairs with concatenation equals to target."], "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().numOfPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:31+00:00", "tests_total": 127, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def numOfPairs(self, nums: list[str], target: str) -> int:", "container": "Solution", "callable": "numOfPairs", "parameters": [{"name": "nums", "type": "list[str]"}, {"name": "target", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2024, "task_id": "maximize-the-confusion-of-an-exam", "difficulty": "Medium", "problem_description": "A teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false. He wants to confuse the students by maximizing the number of consecutive questions with the same answer (multiple trues or multiple falses in a row).\n\nYou are given a string answerKey, where answerKey[i] is the original answer to the i^th question. In addition, you are given an integer k, the maximum number of times you may perform the following operation:\n\n- Change the answer key for any question to 'T' or 'F' (i.e., set answerKey[i] to 'T' or 'F').\n\nReturn the maximum number of consecutive 'T's or 'F's in the answer key after performing the operation at most k times.\n\nExample 1:\n\nInput: answerKey = \"TTFF\", k = 2\nOutput: 4\nExplanation: We can replace both the 'F's with 'T's to make answerKey = \"TTTT\".\nThere are four consecutive 'T's.\n\nExample 2:\n\nInput: answerKey = \"TFFT\", k = 1\nOutput: 3\nExplanation: We can replace the first 'T' with an 'F' to make answerKey = \"FFFT\".\nAlternatively, we can replace the second 'T' with an 'F' to make answerKey = \"TFFF\".\nIn both cases, there are three consecutive 'F's.\n\nExample 3:\n\nInput: answerKey = \"TTFTTFTT\", k = 1\nOutput: 5\nExplanation: We can replace the first 'F' to make answerKey = \"TTTTTFTT\"\nAlternatively, we can replace the second 'F' to make answerKey = \"TTFTTTTT\".\nIn both cases, there are five consecutive 'T's.\n\nConstraints:\n\n- n == answerKey.length\n- 1 <= n <= 5 * 10^4\n- answerKey[i] is either 'T' or 'F'\n- 1 <= k <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(answerKey = \"TTTTFFFF\",k = 2) == 6\n assert candidate(answerKey = \"FFFFFF\",k = 3) == 6\n assert candidate(answerKey = \"TFFTFFTFFTFT\",k = 3) == 10\n assert candidate(answerKey = \"TFTFTFTF\",k = 2) == 5\n assert candidate(answerKey = \"FFTFFT\",k = 2) == 6\n assert candidate(answerKey = \"FFTTFFTTFF\",k = 5) == 10\n assert candidate(answerKey = \"FFTFFTFF\",k = 2) == 8\n assert candidate(answerKey = \"TFTFTFTFTF\",k = 4) == 9\n assert candidate(answerKey = \"T\",k = 1) == 1\n assert candidate(answerKey = \"FFTFFTFF\",k = 3) == 8\n assert candidate(answerKey = \"TTFF\",k = 2) == 4\n assert candidate(answerKey = \"TFTFTFTF\",k = 4) == 8\n assert candidate(answerKey = \"FTFTFTFT\",k = 2) == 5\n assert candidate(answerKey = \"TTFTTFTT\",k = 1) == 5\n assert candidate(answerKey = \"FFFFFFFF\",k = 5) == 8\n assert candidate(answerKey = \"FFFFFFT\",k = 2) == 7\n assert candidate(answerKey = \"FTFTFTFTFTFT\",k = 5) == 11\n assert candidate(answerKey = \"TTTTFFT\",k = 1) == 5\n assert candidate(answerKey = \"TTTTTTFTTTTT\",k = 2) == 12\n assert candidate(answerKey = \"TFFTFFTT\",k = 3) == 7\n assert candidate(answerKey = \"TTTTFFTFFT\",k = 3) == 8\n assert candidate(answerKey = \"FTFFTFFT\",k = 3) == 8\n assert candidate(answerKey = \"TTTTTTTT\",k = 3) == 8\n assert candidate(answerKey = \"TFFT\",k = 1) == 3\n assert candidate(answerKey = \"FFFFFFF\",k = 3) == 7\n assert candidate(answerKey = \"FFFFF\",k = 3) == 5\n assert candidate(answerKey = \"TFFFFF\",k = 2) == 6\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\",k = 20) == 38\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFT\",k = 4) == 9\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFF\",k = 10) == 16\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFT\",k = 8) == 16\n assert candidate(answerKey = \"TTTTTTTFFFFFFFFFFFFFFTTTTTTTTTTTTTTTTTTTTTT\",k = 15) == 43\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTT\",k = 5) == 16\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 25) == 51\n assert candidate(answerKey = \"TFFTFTFTFTFTFTFTFTFT\",k = 10) == 20\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTTTT\",k = 15) == 24\n assert candidate(answerKey = \"TTFTFTFFTFTF\",k = 4) == 10\n assert candidate(answerKey = \"TFFFFFFFFFTTTTTTTTTT\",k = 6) == 16\n assert candidate(answerKey = \"TTFTFTFTFT\",k = 4) == 10\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFT\",k = 8) == 17\n assert candidate(answerKey = \"TFFTFFTFFTFFTFFTFFTFFTFFTFFT\",k = 21) == 28\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTF\",k = 10) == 20\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 20) == 32\n assert candidate(answerKey = \"FFFFFFFFTTTTTTTT\",k = 5) == 13\n assert candidate(answerKey = \"TFFTFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFT\",k = 7) == 23\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 20) == 28\n assert candidate(answerKey = \"FFFFFFFFFTTTTTTTTT\",k = 5) == 14\n assert candidate(answerKey = \"FTTFTTFTTFFTFTTFFT\",k = 11) == 18\n assert candidate(answerKey = \"FFFFFFFFTTTTTTFFFFFFFFTTTTTTTTT\",k = 9) == 25\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTF\",k = 10) == 16\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTT\",k = 10) == 16\n assert candidate(answerKey = \"FFFFFFFFTTTTTTTTTTFT\",k = 2) == 13\n assert candidate(answerKey = \"TTTFFFFTTTFFTFTFFF\",k = 3) == 9\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 20) == 41\n assert candidate(answerKey = \"FTTTFTTFTTFTTFTTFT\",k = 7) == 18\n assert candidate(answerKey = \"TFTFTFTFTF\",k = 5) == 10\n assert candidate(answerKey = \"FFFTTTFFFFTTTTFF\",k = 5) == 12\n assert candidate(answerKey = \"TTFFFFFFFFTTTTTTTTTTTTFFFFFFF\",k = 8) == 22\n assert candidate(answerKey = \"TTTFFFTTTFFFTTTFFF\",k = 5) == 11\n assert candidate(answerKey = \"FFFFFFFFFTTTTTTTTTTTTTT\",k = 10) == 23\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFT\",k = 2) == 5\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFT\",k = 5) == 12\n assert candidate(answerKey = \"FFTTFFTTFFTTFFTTFF\",k = 10) == 18\n assert candidate(answerKey = \"TTTTFFFFFFFFFFFFTTTTTTTTTTTT\",k = 15) == 28\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFTFTFTFT\",k = 12) == 22\n assert candidate(answerKey = \"TTTTTTTTTTFFFFFFFFFFFFFFFFF\",k = 11) == 27\n assert candidate(answerKey = \"TTTTTTTTTFFFFFFF\",k = 5) == 14\n assert candidate(answerKey = \"FTFFTFFTFFTFFTFFTFF\",k = 10) == 19\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 7) == 16\n assert candidate(answerKey = \"FFFFFFFFFTTTTT\",k = 5) == 14\n assert candidate(answerKey = \"TFFTFTFTFFTTFTFT\",k = 3) == 9\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTF\",k = 6) == 13\n assert candidate(answerKey = \"TTTFTFTFTFTFTFTF\",k = 6) == 15\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTT\",k = 15) == 17\n assert candidate(answerKey = \"FFTFTFTFTFFTFTFTFT\",k = 6) == 15\n assert candidate(answerKey = \"FFFFFFFFTTTTTFFFFF\",k = 4) == 12\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFTTTTTTTTTTTTTTTT\",k = 8) == 38\n assert candidate(answerKey = \"FFFFFFFFTTTTTTTTTT\",k = 12) == 18\n assert candidate(answerKey = \"TTTTTTFFTFFTFFFF\",k = 4) == 12\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTF\",k = 9) == 18\n assert candidate(answerKey = \"TTTTTTTTTTFFTTFFTT\",k = 5) == 18\n assert candidate(answerKey = \"TTTFFFFTTTFFFFTTTFFFFTTT\",k = 6) == 18\n assert candidate(answerKey = \"TTFFTTFFTFFTFFTT\",k = 7) == 15\n assert candidate(answerKey = \"FFTTFFFTTF\",k = 2) == 7\n assert candidate(answerKey = \"FFFFFFFFFTTTTTTT\",k = 6) == 15\n assert candidate(answerKey = \"TTFTTTFTFTFTFTFFTFTF\",k = 4) == 12\n assert candidate(answerKey = \"TTTTTTTTTTFFFFFFFFFF\",k = 8) == 18\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 20) == 36\n assert candidate(answerKey = \"TTTFFFFTTTTFTTTFFTTT\",k = 7) == 20\n assert candidate(answerKey = \"TFFTFTFTFTFTFTFTFT\",k = 8) == 17\n assert candidate(answerKey = \"TTFFFTFTFTFTFFFT\",k = 6) == 15\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFT\",k = 5) == 11\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 20) == 38\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 25) == 32\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 15) == 31\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTF\",k = 20) == 41\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFT\",k = 9) == 18\n assert candidate(answerKey = \"TTTTTFFTTTTFFTT\",k = 4) == 15\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 15) == 28\n assert candidate(answerKey = \"FFTFTFFTFTFFTFTFFTFT\",k = 5) == 14\n assert candidate(answerKey = \"TTFFFFFFFFFFFFFFFFFT\",k = 3) == 20\n assert candidate(answerKey = \"TFFTFFTFFTFFTFFTFF\",k = 10) == 18\n assert candidate(answerKey = \"FFFFFFFFTTTTTTTTFFFFFFFFTTTTTTTT\",k = 8) == 24\n assert candidate(answerKey = \"TTTTTTFTTTTTFTTTTTFTTTTT\",k = 7) == 24\n assert candidate(answerKey = \"TFFFFFFFTTTTTTTTTT\",k = 10) == 18\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTF\",k = 15) == 20\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\",k = 25) == 30\n assert candidate(answerKey = \"FTTFTTFTTFFTFTTFFTFFTFTTFTT\",k = 22) == 27\n assert candidate(answerKey = \"TTFFFFFFFFFFFFFFFFFF\",k = 10) == 20\n assert candidate(answerKey = \"FFFFFFFFFTTTTTTT\",k = 7) == 16\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTFTFTFTFTF\",k = 18) == 28\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 10) == 21\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTT\",k = 15) == 22\n assert candidate(answerKey = \"FFTTFFTFFTFFTFFT\",k = 4) == 12\n assert candidate(answerKey = \"TTTTTFFFFF\",k = 2) == 7\n assert candidate(answerKey = \"TTTFFFTTTFFFTTTFFFTTTFFFTTTFFTFTFFTT\",k = 15) == 32\n assert candidate(answerKey = \"TFFTFFTTFFTTFFTTFFTT\",k = 9) == 19\n assert candidate(answerKey = \"FTFTFTTTTTFTFTFT\",k = 6) == 16\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTTTTTTTT\",k = 20) == 28\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFF\",k = 15) == 17\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFT\",k = 8) == 17\n assert candidate(answerKey = \"TFFTFFTFFTFFTFFTFFTFFTFFTFFT\",k = 12) == 28\n assert candidate(answerKey = \"TTTTFFTTFFTTFF\",k = 4) == 12\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 12) == 25\n assert candidate(answerKey = \"TFFFFFFFTTTTTTTT\",k = 7) == 16\n assert candidate(answerKey = \"TFFTFFTFFTFFTFFTFFTFFT\",k = 7) == 21\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 20) == 29\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 24) == 32\n assert candidate(answerKey = \"TTFTTTTTTTTTTTTTTTTT\",k = 1) == 20\n assert candidate(answerKey = \"TTFFTFTFFTFFTFTFFTFFTFFTTFFTFTFFTFFTFFTFFTFTFFTFF\",k = 6) == 19\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFTFTFTFTFT\",k = 12) == 24\n assert candidate(answerKey = \"TTTTTTTTTFFFFFFF\",k = 6) == 15\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFF\",k = 15) == 24\n", "comparison": "exact"}, "public_tests": ["\"TTFF\"\n2", "\"TFFT\"\n1", "\"TTFTTFTT\"\n1"], "hints": ["Can we use the maximum length at the previous position to help us find the answer for the current position?", "Can we use binary search to find the maximum consecutive same answer at every position?"], "metadata": {"canonical_parameter_names": ["answerKey", "k"], "leetcode_dataset_entry_point": "Solution().maxConsecutiveAnswers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:34+00:00", "tests_total": 141, "tests_dropped": 8, "flags": [], "topic_tags": ["string", "binary-search", "sliding-window", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maxConsecutiveAnswers(self, answerKey: str, k: int) -> int:", "container": "Solution", "callable": "maxConsecutiveAnswers", "parameters": [{"name": "answerKey", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2025, "task_id": "maximum-number-of-ways-to-partition-an-array", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums of length n. The number of ways to partition nums is the number of pivot indices that satisfy both conditions:\n\n- 1 <= pivot < n\n- nums[0] + nums[1] + ... + nums[pivot - 1] == nums[pivot] + nums[pivot + 1] + ... + nums[n - 1]\n\nYou are also given an integer k. You can choose to change the value of one element of nums to k, or to leave the array unchanged.\n\nReturn the maximum possible number of ways to partition nums to satisfy both conditions after changing at most one element.\n\nExample 1:\n\nInput: nums = [2,-1,2], k = 3\nOutput: 1\nExplanation: One optimal approach is to change nums[0] to k. The array becomes [3,-1,2].\nThere is one way to partition the array:\n- For pivot = 2, we have the partition [3,-1 | 2]: 3 + -1 == 2.\n\nExample 2:\n\nInput: nums = [0,0,0], k = 1\nOutput: 2\nExplanation: The optimal approach is to leave the array unchanged.\nThere are two ways to partition the array:\n- For pivot = 1, we have the partition [0 | 0,0]: 0 == 0 + 0.\n- For pivot = 2, we have the partition [0,0 | 0]: 0 + 0 == 0.\n\nExample 3:\n\nInput: nums = [22,4,-25,-20,-15,15,-16,7,19,-10,0,-13,-14], k = -33\nOutput: 4\nExplanation: One optimal approach is to change nums[2] to k. The array becomes [22,4,-33,-20,-15,15,-16,7,19,-10,0,-13,-14].\nThere are four ways to partition the array.\n\nConstraints:\n\n- n == nums.length\n- 2 <= n <= 10^5\n- -10^5 <= k, nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 0\n assert candidate(nums = [0, 0, 0],k = 1) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [100000, -100000, 100000, -100000],k = 0) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5],k = -3) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = -5) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0],k = 1) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 55) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5],k = -15) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [2, -1, 2],k = 3) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],k = 9) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1],k = 0) == 3\n assert candidate(nums = [22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14],k = -33) == 4\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],k = 15000) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000],k = 0) == 4\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100],k = 50) == 9\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 60) == 0\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1) == 14\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1],k = 0) == 3\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 0) == 1\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1],k = 0) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15],k = 0) == 1\n assert candidate(nums = [22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14, 22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14],k = -33) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20],k = 5) == 1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40],k = 0) == 3\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996],k = 50000) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 105) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 15) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 525) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9],k = 0) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 210) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = -5) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1],k = 2) == 4\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 50) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1],k = 0) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000],k = 0) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 55) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 0) == 7\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400],k = 50) == 3\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 420) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 780) == 0\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100],k = 0) == 1\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000, -100000],k = 0) == 2\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000],k = 10500) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 0) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 1) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 2100) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 110) == 0\n assert candidate(nums = [-100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000],k = 0) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 1910) == 1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40],k = 0) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 1\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000],k = 0) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 65) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 100) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 1275) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 10) == 0\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 0) == 5\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 5) == 10\n assert candidate(nums = [-100000, 0, 100000, 0, -100000, 0, 100000, 0, -100000],k = 50000) == 0\n assert candidate(nums = [10000, -10000, 20000, -20000, 30000, -30000, 40000, -40000, 50000],k = -10000) == 3\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1],k = 0) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 1\n assert candidate(nums = [10000, -5000, 20000, -10000, 15000, -5000, 20000, -10000, 15000],k = 10000) == 2\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40],k = 0) == 3\n assert candidate(nums = [22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14, 30, -30],k = -33) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 120) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 500) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 0) == 4\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5],k = 10) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 100) == 1\n assert candidate(nums = [22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14],k = 100) == 0\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 5) == 1\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 0) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 50) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 0\n assert candidate(nums = [-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000],k = 5000) == 3\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 120) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 20) == 0\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90],k = 0) == 2\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 1) == 2\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 10) == 1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 0) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = -55) == 0\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 55000) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 225) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = -50) == 1\n assert candidate(nums = [-100000, -90000, -80000, -70000, -60000, -50000, -40000, -30000, -20000, -10000],k = -55000) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 14\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 0) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],k = 210) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 275) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],k = -10) == 1\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],k = 50000) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 55) == 0\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 1) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900],k = 4500) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 550) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 190) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 100) == 0\n", "comparison": "exact"}, "public_tests": ["[2,-1,2]\n3", "[0,0,0]\n1", "[22,4,-25,-20,-15,15,-16,7,19,-10,0,-13,-14]\n-33"], "hints": ["A pivot point splits the array into equal prefix and suffix. If no change is made to the array, the goal is to find the number of pivot p such that prefix[p-1] == suffix[p].", "Consider how prefix and suffix will change when we change a number nums[i] to k.", "When sweeping through each element, can you find the total number of pivots where the difference of prefix and suffix happens to equal to the changes of k-nums[i]."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().waysToPartition", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:36+00:00", "tests_total": 117, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "hash-table", "counting", "enumeration", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def waysToPartition(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "waysToPartition", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2027, "task_id": "minimum-moves-to-convert-string", "difficulty": "Easy", "problem_description": "You are given a string s consisting of n characters which are either 'X' or 'O'.\n\nA move is defined as selecting three consecutive characters of s and converting them to 'O'. Note that if a move is applied to the character 'O', it will stay the same.\n\nReturn the minimum number of moves required so that all the characters of s are converted to 'O'.\n\nExample 1:\n\nInput: s = \"XXX\"\nOutput: 1\nExplanation: XXX -> OOO\nWe select all the 3 characters and convert them in one move.\n\nExample 2:\n\nInput: s = \"XXOX\"\nOutput: 2\nExplanation: XXOX -> OOOX -> OOOO\nWe select the first 3 characters in the first move, and convert them to 'O'.\nThen we select the last 3 characters and convert them so that the final string contains all 'O's.\n\nExample 3:\n\nInput: s = \"OOOO\"\nOutput: 0\nExplanation: There are no 'X's in s to convert.\n\nConstraints:\n\n- 3 <= s.length <= 1000\n- s[i] is either 'X' or 'O'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"XXXXXXXXXX\") == 4\n assert candidate(s = \"OOXOOX\") == 2\n assert candidate(s = \"OOXOOXOOXO\") == 3\n assert candidate(s = \"OOXXOOXXOO\") == 2\n assert candidate(s = \"XXOX\") == 2\n assert candidate(s = \"OXOXOXOXOX\") == 3\n assert candidate(s = \"XOOOXXOOOX\") == 3\n assert candidate(s = \"XXX\") == 1\n assert candidate(s = \"OOOO\") == 0\n assert candidate(s = \"XOOXOX\") == 2\n assert candidate(s = \"OXOXOX\") == 2\n assert candidate(s = \"OOOXXOOOXXOOO\") == 2\n assert candidate(s = \"XOXOXOXOXO\") == 3\n assert candidate(s = \"XXXXXX\") == 2\n assert candidate(s = \"XOOXOOXOOX\") == 4\n assert candidate(s = \"XXXXXXXXX\") == 3\n assert candidate(s = \"XOXOXO\") == 2\n assert candidate(s = \"OOXXOOX\") == 2\n assert candidate(s = \"OOXOXO\") == 1\n assert candidate(s = \"XOOOOXOOXOXXXX\") == 4\n assert candidate(s = \"XOOXOXOOXOXOXO\") == 4\n assert candidate(s = \"OOXOXOXXOXXOOXOX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 8\n assert candidate(s = \"XOXOOXOXOOXOXOXOXOOXOXOXOOXOXOXOOXO\") == 9\n assert candidate(s = \"XOOXOXOOXOOXOOXOOXOOXOOXOOXOOX\") == 10\n assert candidate(s = \"XOXOXXOOXOXOXXXOXO\") == 5\n assert candidate(s = \"XOOXOXOOXOXOOXOXOOX\") == 5\n assert candidate(s = \"OOXOOXOOXOOXOO\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXO\") == 7\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 12\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 9\n assert candidate(s = \"XOOOXOOOXOOOXOOOXOOO\") == 5\n assert candidate(s = \"XOOXOXOXOXOXOXOX\") == 5\n assert candidate(s = \"OOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"OOOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXOOOOXXOOOOXXOOOOXXOOOOXXOOOOXXOOOOXXOOOOXX\") == 8\n assert candidate(s = \"OOXXOOXXOOXXXX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 9\n assert candidate(s = \"XOOXXOOXXOOXXOOXX\") == 5\n assert candidate(s = \"XOXOXOXOXOOOXOXO\") == 4\n assert candidate(s = \"XXXOXOXOXOXO\") == 3\n assert candidate(s = \"XXOOXOXOXOXOXX\") == 4\n assert candidate(s = \"OXXOXOXOXOXO\") == 3\n assert candidate(s = \"XXXXXXXXXXXXXXXXXXX\") == 7\n assert candidate(s = \"OOXOXOXOXOOO\") == 2\n assert candidate(s = \"OXOXOXOXOXOX\") == 3\n assert candidate(s = \"XXOOXOXOXOXOXXOXOXXOXOXXOXOXXOXOXX\") == 10\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 14\n assert candidate(s = \"XOXOXOXOXOXO\") == 3\n assert candidate(s = \"XOOOXXXXOOOXXXXOOO\") == 5\n assert candidate(s = \"XXOXOXOXOXOXOXOXOXOXOXOXOX\") == 7\n assert candidate(s = \"XXOOXXOOXXOOXXOOXXOOX\") == 6\n assert candidate(s = \"XXXXXXXXXXXXXXXX\") == 6\n assert candidate(s = \"XXXOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"XOXXXXXXXXXOXOXOXOXOXOXOXO\") == 8\n assert candidate(s = \"XOXOXXXXXXXXXOXXXXXXXXXOXXXXXXXXXOXXXXXXXXXO\") == 13\n assert candidate(s = \"OOXOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 12\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXOXOX\") == 6\n assert candidate(s = \"OOXXOOXXOOXXOOXXOOXXOO\") == 5\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXOXOXOX\") == 6\n assert candidate(s = \"XXXXXXXXXOOOOOOOOOXXXXXXXXX\") == 6\n assert candidate(s = \"XXOOXXOOXXOOXXOOXX\") == 5\n assert candidate(s = \"XOOXOOXOOXOOXOOX\") == 6\n assert candidate(s = \"OOXOXOXOXOXOXOXOXOXOXOXOXOXOXOOO\") == 7\n assert candidate(s = \"OOXOOXOOXOOXOOXO\") == 5\n assert candidate(s = \"XXXXXXXXXXXXX\") == 5\n assert candidate(s = \"XXOOXOXOXOXOXO\") == 4\n assert candidate(s = \"XXXOOOOXOXOOXOXO\") == 3\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXO\") == 6\n assert candidate(s = \"XXOOXXOOXXOOXX\") == 4\n assert candidate(s = \"XOOXOOXOOXOXOX\") == 5\n assert candidate(s = \"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXOOXOXOXOXOXOXOXO\") == 5\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOX\") == 7\n assert candidate(s = \"OOOXXXOOOXXXOOO\") == 2\n assert candidate(s = \"XXXOXOXOXXXO\") == 3\n assert candidate(s = \"XOXOXXOOXOXO\") == 3\n assert candidate(s = \"OXXXXOOOXXXXOOOXXX\") == 5\n assert candidate(s = \"OOOXOXOXOXOXOXOOOO\") == 3\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOXOOX\") == 8\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOO\") == 6\n assert candidate(s = \"OOXOOXOOXOOXOOX\") == 5\n assert candidate(s = \"XXXXXXXXXXXXXXXXXXXXXXXX\") == 8\n assert candidate(s = \"OOXOXOXOXOXOXOOO\") == 3\n assert candidate(s = \"XOXXOXXOXXOXXOXX\") == 6\n assert candidate(s = \"XXOOXOXOXOXOXOXOXOXX\") == 6\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXO\") == 13\n assert candidate(s = \"XOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"OXOXOXOXOXOXOX\") == 4\n assert candidate(s = \"XXOXOXOXOXOXOXOXOXOX\") == 6\n assert candidate(s = \"XXXXOXXXXOXXXXO\") == 5\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 7\n assert candidate(s = \"XOOXOXOOXOXOOXOXOOXOXOOX\") == 6\n assert candidate(s = \"OOOOXXOOXXOOXX\") == 3\n assert candidate(s = \"XXOOXXOOXXOOXXOOXXOOXXOOXXOOX\") == 8\n assert candidate(s = \"XXXXOOXXXXOOXXXXOO\") == 6\n assert candidate(s = \"XXOXXOXXOXXOXX\") == 5\n assert candidate(s = \"OOOOOOOOOOOOO\") == 0\n assert candidate(s = \"OOXXXXXXOOXXXXXXOOXXXXXX\") == 6\n assert candidate(s = \"XOXOXXXOXOXOXXX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXO\") == 5\n assert candidate(s = \"XOXOXOOXOXOX\") == 4\n assert candidate(s = \"XXOOXXOOXXOOXXOOXXOO\") == 5\n assert candidate(s = \"XXXXXXXXXXXXXXXXXX\") == 6\n assert candidate(s = \"XXXXXXXXXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 13\n assert candidate(s = \"XXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 9\n assert candidate(s = \"XXOXOXOXOXOXOXOX\") == 5\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOXOOXOOX\") == 9\n assert candidate(s = \"XOOOXOOOXOOOXOOO\") == 4\n assert candidate(s = \"OOXXOOXXOOXXOO\") == 3\n assert candidate(s = \"XOXOXOXOXOXOX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXO\") == 5\n assert candidate(s = \"XXOXOXOXOXOX\") == 4\n assert candidate(s = \"OOXOXOXOXO\") == 2\n assert candidate(s = \"XOOOXXOOOOXXOOOXXOOO\") == 4\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOOXOOX\") == 8\n assert candidate(s = \"XXOXOXOXOXOXOX\") == 4\n assert candidate(s = \"OXOXOXOXOXOXOXOXOX\") == 5\n assert candidate(s = \"OXOOXOOXOOXOOXOOXOOXOOX\") == 8\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOOXOOXOOXOO\") == 9\n assert candidate(s = \"OXXOXOXXOXOXXOXO\") == 5\n assert candidate(s = \"XXXXXXXXOXOXO\") == 4\n assert candidate(s = \"XXXXXXXXOOOXXXXX\") == 5\n assert candidate(s = \"OOXXOOXXOOXXOOXXOOXXOOXXOO\") == 6\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOO\") == 12\n assert candidate(s = \"XOOXOXXOXOXXOX\") == 5\n assert candidate(s = \"OOOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOO\") == 9\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXO\") == 5\n assert candidate(s = \"OXOXOXOXOXOXO\") == 3\n assert candidate(s = \"XXXXOXXXXOXXXXOXXXXOXXXXOXXXXOXXXXO\") == 11\n assert candidate(s = \"XOXOXXXXXXXXOXXXXXXXXX\") == 7\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOX\") == 12\n assert candidate(s = \"XOOOXXOOOXXOOOXXOOO\") == 4\n assert candidate(s = \"OOOXOXOXOXOXOXOXOXOXOXOOOO\") == 5\n assert candidate(s = \"XOXXOXOXXOXOXXOXOXXOXXO\") == 7\n assert candidate(s = \"OOXOXOXOXOXOXOXOXOXOXOXOXO\") == 6\n assert candidate(s = \"OOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXOXXOXXOXXO\") == 4\n assert candidate(s = \"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"OXOXOXOXOXOXOXOX\") == 4\n assert candidate(s = \"XXXXXXXXXXXXXXXXXOOOOOOOOOOOO\") == 6\n assert candidate(s = \"OOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXXXXXXXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 11\n assert candidate(s = \"XXXOOXOXOOXOXX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"XOOOOXOOOOXOOOOXOOOO\") == 4\n assert candidate(s = \"XOOXXOOXXOOXXOOX\") == 5\n assert candidate(s = \"OOOXOXOXOXOXOOOO\") == 3\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOX\") == 12\n assert candidate(s = \"XOOOOXOOOXOOO\") == 3\n assert candidate(s = \"XXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXX\") == 11\n assert candidate(s = \"OOXOXOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"XOXOXOOXOXOXOO\") == 4\n assert candidate(s = \"XOOOOXOOOOXOOOOXOOOOXOOOO\") == 5\n assert candidate(s = \"XOOXOXOXOXOX\") == 4\n assert candidate(s = \"OOXOOOXOOOXOOOXOOOXOOOXOOOXOOOXOOOXOOOXOOO\") == 10\n assert candidate(s = \"XXOOXXOOXXOO\") == 3\n assert candidate(s = \"XXXXXXXXOOOOXXXXXXXX\") == 6\n assert candidate(s = \"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\") == 14\n assert candidate(s = \"XXXXXXXXXXXXXXXXX\") == 6\n assert candidate(s = \"XOXOOXOXOOXOXOXO\") == 4\n assert candidate(s = \"OXOOXOOOXOXOOXOO\") == 4\n assert candidate(s = \"XXOXOXXOXOXOXXOX\") == 5\n assert candidate(s = \"OOOOOOOOOOOOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXXXXXXXXXXXXX\") == 5\n", "comparison": "exact"}, "public_tests": ["\"XXX\"", "\"XXOX\"", "\"OOOO\""], "hints": ["Find the smallest substring you need to consider at a time.", "Try delaying a move as long as possible."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumMoves", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:39+00:00", "tests_total": 166, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minimumMoves(self, s: str) -> int:", "container": "Solution", "callable": "minimumMoves", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2028, "task_id": "find-missing-observations", "difficulty": "Medium", "problem_description": "You have observations of n + m 6-sided dice rolls with each face numbered from 1 to 6. n of the observations went missing, and you only have the observations of m rolls. Fortunately, you have also calculated the average value of the n + m rolls.\n\nYou are given an integer array rolls of length m where rolls[i] is the value of the i^th observation. You are also given the two integers mean and n.\n\nReturn an array of length n containing the missing observations such that the average value of the n + m rolls is exactly mean. If there are multiple valid answers, return any of them. If no such array exists, return an empty array.\n\nThe average value of a set of k numbers is the sum of the numbers divided by k.\n\nNote that mean is an integer, so the sum of the n + m rolls should be divisible by n + m.\n\nExample 1:\n\nInput: rolls = [3,2,4,3], mean = 4, n = 2\nOutput: [6,6]\nExplanation: The mean of all n + m rolls is (3 + 2 + 4 + 3 + 6 + 6) / 6 = 4.\n\nExample 2:\n\nInput: rolls = [1,5,6], mean = 3, n = 4\nOutput: [2,3,2,2]\nExplanation: The mean of all n + m rolls is (1 + 5 + 6 + 2 + 3 + 2 + 2) / 7 = 3.\n\nExample 3:\n\nInput: rolls = [1,2,3,4], mean = 6, n = 4\nOutput: []\nExplanation: It is impossible for the mean to be 6 no matter what the 4 missing rolls are.\n\nConstraints:\n\n- m == rolls.length\n- 1 <= n, m <= 10^5\n- 1 <= rolls[i], mean <= 6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rolls = [1, 2],mean = 3,n = 2) == [5, 4]\n assert candidate(rolls = [1, 3, 5],mean = 2,n = 2) == []\n assert candidate(rolls = [5, 5, 5, 5],mean = 5,n = 4) == [5, 5, 5, 5]\n assert candidate(rolls = [5, 6, 6, 6],mean = 5,n = 3) == [4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6],mean = 6,n = 3) == [6, 6, 6]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 3,n = 6) == [3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 2, 3, 4],mean = 6,n = 4) == []\n assert candidate(rolls = [1, 5, 6],mean = 3,n = 4) == [3, 2, 2, 2]\n assert candidate(rolls = [5, 5, 5, 5],mean = 5,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1],mean = 2,n = 6) == [3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [3, 2, 4, 3],mean = 4,n = 2) == [6, 6]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 5,n = 6) == [4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 1, 1, 1],mean = 2,n = 4) == [3, 3, 3, 3]\n assert candidate(rolls = [3],mean = 4,n = 1) == [5]\n assert candidate(rolls = [6],mean = 6,n = 1) == [6]\n assert candidate(rolls = [1, 1, 1],mean = 2,n = 3) == [3, 3, 3]\n assert candidate(rolls = [6, 6, 6],mean = 5,n = 3) == [4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],mean = 3,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6],mean = 3,n = 6) == [3, 3, 3, 2, 2, 2]\n assert candidate(rolls = [1],mean = 6,n = 5) == []\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 6,n = 15) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 4,n = 3) == [6, 6, 6]\n assert candidate(rolls = [1, 1, 1, 1],mean = 2,n = 10) == [3, 3, 3, 3, 2, 2, 2, 2, 2, 2]\n assert candidate(rolls = [1, 1, 1, 1, 1],mean = 5,n = 5) == []\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 4,n = 20) == []\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 3,n = 3) == [3, 3, 3]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 12) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 6, 3, 4, 2, 5],mean = 3,n = 5) == [3, 3, 2, 2, 2]\n assert candidate(rolls = [2, 4, 6, 1, 3, 5],mean = 4,n = 3) == [5, 5, 5]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1],mean = 4,n = 12) == [5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 6, 1, 6, 1, 6],mean = 4,n = 3) == [5, 5, 5]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 6,n = 10) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 2, 3, 4, 5],mean = 4,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],mean = 4,n = 20) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3],mean = 5,n = 5) == []\n assert candidate(rolls = [5, 1, 5, 1, 5, 1],mean = 4,n = 2) == []\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1],mean = 4,n = 18) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],mean = 3,n = 15) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 15) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 1, 1, 1, 1],mean = 2,n = 10) == [3, 3, 3, 3, 3, 2, 2, 2, 2, 2]\n assert candidate(rolls = [6, 5, 4, 3, 2, 1],mean = 3,n = 7) == [3, 3, 3, 3, 2, 2, 2]\n assert candidate(rolls = [1, 2, 3],mean = 2,n = 9) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(rolls = [4, 4, 4, 4, 4, 4, 4, 4],mean = 4,n = 1) == [4]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2],mean = 2,n = 12) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 20) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [2, 3, 4, 5, 6],mean = 4,n = 6) == [4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6],mean = 4,n = 3) == [5, 5, 5]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 6,n = 12) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [6, 4, 6, 4, 6, 4],mean = 5,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 3,n = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 5,n = 12) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [6, 5, 4, 3, 2, 1],mean = 4,n = 10) == [5, 5, 5, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [5, 1, 5, 1, 5, 1],mean = 3,n = 6) == [3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [4, 4, 4, 4, 4, 4],mean = 5,n = 1) == []\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 5,n = 10) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 6,n = 6) == [6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 20) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 1,n = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 6,n = 6) == [6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 1, 2, 2, 3, 3],mean = 3,n = 3) == [5, 5, 5]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 6) == [5, 5, 5, 4, 4, 4]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 6,n = 18) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 6, 1, 6, 1, 6],mean = 4,n = 6) == [5, 5, 5, 4, 4, 4]\n assert candidate(rolls = [1, 6, 1, 6, 1, 6],mean = 4,n = 3) == [5, 5, 5]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2],mean = 3,n = 4) == [5, 5, 5, 4]\n assert candidate(rolls = [1, 2, 3, 4, 5],mean = 2,n = 1) == []\n assert candidate(rolls = [2, 4, 6, 5, 4, 3, 2],mean = 4,n = 5) == [5, 5, 4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 5,n = 5) == [4, 4, 4, 4, 3]\n assert candidate(rolls = [6, 6, 6, 6],mean = 4,n = 8) == [3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 5,n = 20) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 10) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [6, 5, 4, 3, 2, 1],mean = 4,n = 5) == [5, 5, 5, 4, 4]\n assert candidate(rolls = [1, 2, 3, 4, 5],mean = 3,n = 5) == [3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],mean = 4,n = 5) == [6, 6, 6, 5, 5]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],mean = 4,n = 12) == [5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 4,n = 5) == []\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 4,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 3,n = 10) == [2, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rolls = [4, 5, 6, 1, 2, 3],mean = 4,n = 6) == [5, 5, 5, 4, 4, 4]\n assert candidate(rolls = [1, 2, 2, 3, 3, 4, 5, 6],mean = 3,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 2, 2]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 5) == [4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],mean = 4,n = 5) == [5, 5, 5, 4, 4]\n assert candidate(rolls = [5, 5, 5, 5, 5],mean = 5,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 18) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5],mean = 4,n = 6) == [3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 5,n = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 4,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1],mean = 2,n = 9) == [3, 3, 3, 3, 3, 3, 3, 2, 2]\n assert candidate(rolls = [4, 4, 4, 4, 4, 4],mean = 4,n = 3) == [4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],mean = 4,n = 5) == [6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 3,n = 20) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [6],mean = 1,n = 5) == []\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 4,n = 3) == [6, 6, 6]\n assert candidate(rolls = [6, 6, 6, 6, 6],mean = 6,n = 1) == [6]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],mean = 4,n = 12) == [5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 4,n = 10) == [5, 5, 5, 5, 5, 5, 4, 4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6],mean = 5,n = 2) == [3, 3]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 5,n = 3) == [3, 3, 3]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 5,n = 20) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [3, 3, 3, 3, 3],mean = 5,n = 5) == []\n assert candidate(rolls = [6, 5, 4, 3, 2, 1],mean = 4,n = 6) == [5, 5, 5, 4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 6,n = 10) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6],mean = 4,n = 5) == [5, 5, 5, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 4,n = 5) == [6, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 20) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],mean = 5,n = 10) == []\n assert candidate(rolls = [1, 2, 3, 4, 5],mean = 3,n = 7) == [3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 1, 2, 2, 3, 3],mean = 3,n = 6) == [4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 10) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],mean = 3,n = 5) == [3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 2, 3],mean = 4,n = 3) == [6, 6, 6]\n", "comparison": "exact"}, "public_tests": ["[3,2,4,3]\n4\n2", "[1,5,6]\n3\n4", "[1,2,3,4]\n6\n4"], "hints": ["What should the sum of the n rolls be?", "Could you generate an array of size n such that each element is between 1 and 6?"], "metadata": {"canonical_parameter_names": ["rolls", "mean", "n"], "leetcode_dataset_entry_point": "Solution().missingRolls", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:41+00:00", "tests_total": 116, "tests_dropped": 3, "flags": ["multiple_answers"], "topic_tags": ["array", "math", "simulation"]}, "language": "python", "interface": {"raw_signature": "def missingRolls(self, rolls: list[int], mean: int, n: int) -> list[int]:", "container": "Solution", "callable": "missingRolls", "parameters": [{"name": "rolls", "type": "list[int]"}, {"name": "mean", "type": "int"}, {"name": "n", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2029, "task_id": "stone-game-ix", "difficulty": "Medium", "problem_description": "Alice and Bob continue their games with stones. There is a row of n stones, and each stone has an associated value. You are given an integer array stones, where stones[i] is the value of the i^th stone.\n\nAlice and Bob take turns, with Alice starting first. On each turn, the player may remove any stone from stones. The player who removes a stone loses if the sum of the values of all removed stones is divisible by 3. Bob will win automatically if there are no remaining stones (even if it is Alice's turn).\n\nAssuming both players play optimally, return true if Alice wins and false if Bob wins.\n\nExample 1:\n\nInput: stones = [2,1]\nOutput: true\nExplanation: The game will be played as follows:\n- Turn 1: Alice can remove either stone.\n- Turn 2: Bob removes the remaining stone.\nThe sum of the removed stones is 1 + 2 = 3 and is divisible by 3. Therefore, Bob loses and Alice wins the game.\n\nExample 2:\n\nInput: stones = [2]\nOutput: false\nExplanation: Alice will remove the only stone, and the sum of the values on the removed stones is 2.\nSince all the stones are removed and the sum of values is not divisible by 3, Bob wins the game.\n\nExample 3:\n\nInput: stones = [5,1,2,4,3]\nOutput: false\nExplanation: Bob will always win. One possible way for Bob to win is shown below:\n- Turn 1: Alice can remove the second stone with value 1. Sum of removed stones = 1.\n- Turn 2: Bob removes the fifth stone with value 3. Sum of removed stones = 1 + 3 = 4.\n- Turn 3: Alices removes the fourth stone with value 4. Sum of removed stones = 1 + 3 + 4 = 8.\n- Turn 4: Bob removes the third stone with value 2. Sum of removed stones = 1 + 3 + 4 + 2 = 10.\n- Turn 5: Alice removes the first stone with value 5. Sum of removed stones = 1 + 3 + 4 + 2 + 5 = 15.\nAlice loses the game because the sum of the removed stones (15) is divisible by 3. Bob wins the game.\n\nConstraints:\n\n- 1 <= stones.length <= 10^5\n- 1 <= stones[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(stones = [3, 6, 9, 12, 15]) == False\n assert candidate(stones = [2, 1]) == True\n assert candidate(stones = [1, 2, 3, 6, 9, 12, 15]) == False\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [3, 3, 3]) == False\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 1]) == False\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [1, 5, 9, 13, 17, 21]) == True\n assert candidate(stones = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [5, 1, 2, 4, 3]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21]) == False\n assert candidate(stones = [1, 5, 7, 11, 13, 17, 19]) == True\n assert candidate(stones = [10, 20, 30, 40, 50]) == False\n assert candidate(stones = [3, 6, 9]) == False\n assert candidate(stones = [1, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73]) == True\n assert candidate(stones = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == True\n assert candidate(stones = [2]) == False\n assert candidate(stones = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == True\n assert candidate(stones = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == False\n assert candidate(stones = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == True\n assert candidate(stones = [1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2]) == True\n assert candidate(stones = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == False\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3]) == True\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == False\n assert candidate(stones = [1, 2, 4, 5, 7, 8, 10, 11]) == True\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(stones = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == False\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == False\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == True\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80]) == False\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1]) == True\n assert candidate(stones = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28]) == False\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == False\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29]) == False\n assert candidate(stones = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == False\n assert candidate(stones = [5, 1, 2, 4, 3, 5, 1, 2, 4, 3, 5, 1, 2, 4, 3, 5, 1, 2, 4, 3, 5, 1, 2, 4, 3, 5, 1, 2, 4, 3]) == True\n assert candidate(stones = [1, 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 8, 8, 8, 9, 10, 10, 10, 11, 12, 12, 12, 13, 14, 15, 16, 16, 17, 18, 18, 19, 19, 20]) == False\n assert candidate(stones = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == False\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(stones = [3, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51]) == False\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(stones = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17]) == True\n assert candidate(stones = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4]) == True\n assert candidate(stones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == True\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == False\n assert candidate(stones = [1, 2, 2, 2, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1]) == True\n assert candidate(stones = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == False\n assert candidate(stones = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88]) == False\n assert candidate(stones = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(stones = [3, 6, 9, 12, 15, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22]) == False\n assert candidate(stones = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == True\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87]) == False\n assert candidate(stones = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == False\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(stones = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == True\n assert candidate(stones = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == True\n assert candidate(stones = [3, 6, 9, 2, 5, 8, 11, 14, 17, 20]) == True\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == False\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29]) == True\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [1, 2, 2, 1, 2, 1, 2, 2, 1]) == True\n assert candidate(stones = [1, 2, 2, 2, 3, 3, 3, 3, 4, 5, 6, 6, 6, 6, 7, 8, 9]) == False\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == False\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59]) == False\n assert candidate(stones = [1001, 1004, 1007, 1010, 1013, 1016, 1019, 1022, 1025, 1028, 1031, 1034, 1037, 1040, 1043, 1046, 1049, 1052, 1055, 1058]) == False\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == True\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(stones = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == True\n assert candidate(stones = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]) == False\n assert candidate(stones = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == True\n assert candidate(stones = [1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6]) == True\n assert candidate(stones = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == False\n assert candidate(stones = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180]) == False\n assert candidate(stones = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == True\n assert candidate(stones = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1]) == True\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7]) == True\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == False\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86, 89]) == False\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == False\n assert candidate(stones = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58]) == False\n assert candidate(stones = [1, 2, 2, 1, 2, 2, 1, 2]) == True\n assert candidate(stones = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(stones = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == False\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == False\n assert candidate(stones = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(stones = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]) == True\n assert candidate(stones = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == True\n", "comparison": "exact"}, "public_tests": ["[2,1]", "[2]", "[5,1,2,4,3]"], "hints": ["There are limited outcomes given the current sum and the stones remaining.", "Can we greedily simulate starting with taking a stone with remainder 1 or 2 divided by 3?"], "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().stoneGameIX", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:44+00:00", "tests_total": 108, "tests_dropped": 4, "flags": ["figure_reference"], "topic_tags": ["array", "math", "greedy", "minimax-algorithm", "counting", "game-theory", "nim-game", "zero-sum-game"]}, "language": "python", "interface": {"raw_signature": "def stoneGameIX(self, stones: list[int]) -> bool:", "container": "Solution", "callable": "stoneGameIX", "parameters": [{"name": "stones", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2030, "task_id": "smallest-k-length-subsequence-with-occurrences-of-a-letter", "difficulty": "Hard", "problem_description": "You are given a string s, an integer k, a letter letter, and an integer repetition.\n\nReturn the lexicographically smallest subsequence of s of length k that has the letter letter appear at least repetition times. The test cases are generated so that the letter appears in s at least repetition times.\n\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n\nA string a is lexicographically smaller than a string b if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b.\n\nExample 1:\n\nInput: s = \"leet\", k = 3, letter = \"e\", repetition = 1\nOutput: \"eet\"\nExplanation: There are four subsequences of length 3 that have the letter 'e' appear at least 1 time:\n- \"lee\" (from \"leet\")\n- \"let\" (from \"leet\")\n- \"let\" (from \"leet\")\n- \"eet\" (from \"leet\")\nThe lexicographically smallest subsequence among them is \"eet\".\n\nExample 2:\n\nInput: s = \"leetcode\", k = 4, letter = \"e\", repetition = 2\nOutput: \"ecde\"\nExplanation: \"ecde\" is the lexicographically smallest subsequence of length 4 that has the letter \"e\" appear at least 2 times.\n\nExample 3:\n\nInput: s = \"bb\", k = 2, letter = \"b\", repetition = 2\nOutput: \"bb\"\nExplanation: \"bb\" is the only subsequence of length 2 that has the letter \"b\" appear at least 2 times.\n\nConstraints:\n\n- 1 <= repetition <= k <= s.length <= 5 * 10^4\n- s consists of lowercase English letters.\n- letter is a lowercase English letter, and appears in s at least repetition times.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"bb\",k = 2,letter = \"b\",repetition = 2) == \"bb\"\n assert candidate(s = \"leetcode\",k = 4,letter = \"e\",repetition = 2) == \"ecde\"\n assert candidate(s = \"leet\",k = 3,letter = \"e\",repetition = 1) == \"eet\"\n assert candidate(s = \"aabbc\",k = 3,letter = \"a\",repetition = 1) == \"aab\"\n assert candidate(s = \"abacabad\",k = 4,letter = \"a\",repetition = 2) == \"aaaa\"\n assert candidate(s = \"zzzzz\",k = 3,letter = \"z\",repetition = 3) == \"zzz\"\n assert candidate(s = \"abcdedcba\",k = 5,letter = \"d\",repetition = 1) == \"abcda\"\n assert candidate(s = \"zzzzzaaaaa\",k = 5,letter = \"a\",repetition = 3) == \"aaaaa\"\n assert candidate(s = \"apple\",k = 3,letter = \"p\",repetition = 1) == \"ape\"\n assert candidate(s = \"abacabadabacaba\",k = 7,letter = \"a\",repetition = 3) == \"aaaaaaa\"\n assert candidate(s = \"azbzczdz\",k = 4,letter = \"z\",repetition = 2) == \"abzz\"\n assert candidate(s = \"abcdedcba\",k = 5,letter = \"c\",repetition = 1) == \"abcba\"\n assert candidate(s = \"xyzxyzxyz\",k = 5,letter = \"z\",repetition = 2) == \"xxyzz\"\n assert candidate(s = \"abcdedcba\",k = 5,letter = \"c\",repetition = 2) == \"abcca\"\n assert candidate(s = \"zzzz\",k = 2,letter = \"z\",repetition = 2) == \"zz\"\n assert candidate(s = \"abcabcabc\",k = 6,letter = \"a\",repetition = 2) == \"aababc\"\n assert candidate(s = \"abcdabcdabcd\",k = 9,letter = \"b\",repetition = 3) == \"ababcabcd\"\n assert candidate(s = \"elephant\",k = 4,letter = \"e\",repetition = 1) == \"eant\"\n assert candidate(s = \"zazbzazbzazb\",k = 8,letter = \"z\",repetition = 4) == \"abzazbzz\"\n assert candidate(s = \"babcbabcbabc\",k = 5,letter = \"b\",repetition = 3) == \"aabbb\"\n assert candidate(s = \"abcdedcbaabcdedcbaabcdedcba\",k = 15,letter = \"c\",repetition = 3) == \"aaabcaabcdedcba\"\n assert candidate(s = \"aaaaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\",k = 20,letter = \"c\",repetition = 4) == \"aaaaaaaaaaaabbbbcccc\"\n assert candidate(s = \"aaaaaabbbbbbcccccc\",k = 12,letter = \"b\",repetition = 4) == \"aaaaaabbbbbb\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 26,letter = \"z\",repetition = 1) == \"aabcdefghijklmnopqrstuvwxz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 13,letter = \"m\",repetition = 1) == \"abcdefghijklm\"\n assert candidate(s = \"mississippi\",k = 5,letter = \"i\",repetition = 2) == \"iiipi\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\",k = 26,letter = \"a\",repetition = 2) == \"ayxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"ababababababababababababababababababababababab\",k = 10,letter = \"a\",repetition = 3) == \"aaaaaaaaaa\"\n assert candidate(s = \"xyzyxyzyxyzyxyzyzyzyxyzyzyzyzyzyxyzyxyzyzyzyzyzy\",k = 15,letter = \"x\",repetition = 3) == \"xxxxxxxyyyyzyzy\"\n assert candidate(s = \"aabbccddeeff\",k = 8,letter = \"c\",repetition = 3) == \"aabbccd\"\n assert candidate(s = \"zzzzzaaaaabbbb\",k = 10,letter = \"a\",repetition = 4) == \"zaaaaabbbb\"\n assert candidate(s = \"mississippi\",k = 4,letter = \"i\",repetition = 2) == \"iiii\"\n assert candidate(s = \"mississippi\",k = 6,letter = \"i\",repetition = 2) == \"iiippi\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 50,letter = \"z\",repetition = 10) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 20,letter = \"a\",repetition = 2) == \"aabbccddeeffgghhiijj\"\n assert candidate(s = \"banana\",k = 4,letter = \"a\",repetition = 2) == \"aana\"\n assert candidate(s = \"abcdabcdabcd\",k = 8,letter = \"b\",repetition = 3) == \"abababcd\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 10,letter = \"m\",repetition = 2) == \"abcdefghm\"\n assert candidate(s = \"abracadabra\",k = 7,letter = \"a\",repetition = 3) == \"aaaabra\"\n assert candidate(s = \"zyxzyxzyx\",k = 5,letter = \"x\",repetition = 2) == \"xxzyx\"\n assert candidate(s = \"abracadabraabracadabra\",k = 12,letter = \"a\",repetition = 4) == \"aaaaaaaaabra\"\n assert candidate(s = \"racecar\",k = 5,letter = \"e\",repetition = 1) == \"acear\"\n assert candidate(s = \"abcdabcabcabc\",k = 9,letter = \"c\",repetition = 3) == \"aabcabcac\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwerty\",k = 12,letter = \"r\",repetition = 2) == \"erabnmqwerty\"\n assert candidate(s = \"xyzyzyzyzyx\",k = 7,letter = \"y\",repetition = 3) == \"xyyyyyx\"\n", "comparison": "exact"}, "public_tests": ["\"leet\"\n3\n\"e\"\n1", "\"leetcode\"\n4\n\"e\"\n2", "\"bb\"\n2\n\"b\"\n2"], "hints": ["Use stack. For every character to be appended, decide how many character(s) from the stack needs to get popped based on the stack length and the count of the required character.", "Pop the extra characters out from the stack and return the characters in the stack (reversed)."], "metadata": {"canonical_parameter_names": ["s", "k", "letter", "repetition"], "leetcode_dataset_entry_point": "Solution().smallestSubsequence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:46+00:00", "tests_total": 45, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["string", "stack", "greedy", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def smallestSubsequence(self, s: str, k: int, letter: str, repetition: int) -> str:", "container": "Solution", "callable": "smallestSubsequence", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}, {"name": "letter", "type": "str"}, {"name": "repetition", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2032, "task_id": "two-out-of-three", "difficulty": "Easy", "problem_description": "Given three integer arrays nums1, nums2, and nums3, return a distinct array containing all the values that are present in at least two out of the three arrays. You may return the values in any order.\n\nExample 1:\n\nInput: nums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3]\nOutput: [3,2]\nExplanation: The values that are present in at least two arrays are:\n- 3, in all three arrays.\n- 2, in nums1 and nums2.\n\nExample 2:\n\nInput: nums1 = [3,1], nums2 = [2,3], nums3 = [1,2]\nOutput: [2,3,1]\nExplanation: The values that are present in at least two arrays are:\n- 2, in nums2 and nums3.\n- 3, in nums1 and nums2.\n- 1, in nums1 and nums3.\n\nExample 3:\n\nInput: nums1 = [1,2,2], nums2 = [4,3,3], nums3 = [5]\nOutput: []\nExplanation: No value is present in at least two arrays.\n\nConstraints:\n\n- 1 <= nums1.length, nums2.length, nums3.length <= 100\n- 1 <= nums1[i], nums2[j], nums3[k] <= 100\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(nums1=[5, 6, 7], nums2=[5, 6, 8], nums3=[7, 6, 9]), [5, 6, 7])\n assert answers_match(candidate(nums1=[100], nums2=[100], nums3=[100]), [100])\n assert answers_match(candidate(nums1=[5, 5, 5], nums2=[5, 5, 5], nums3=[5, 5, 5]), [5])\n assert answers_match(candidate(nums1=[10, 20, 30], nums2=[40, 50, 60], nums3=[10, 50, 90]), [10, 50])\n assert answers_match(candidate(nums1=[1, 2, 3], nums2=[4, 5, 6], nums3=[7, 8, 9]), [])\n assert answers_match(candidate(nums1=[10, 20, 30], nums2=[20, 30, 40], nums3=[30, 40, 50]), [20, 30, 40])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5], nums2=[5, 4, 3, 2, 1], nums3=[1, 3, 5, 7, 9]), [1, 2, 3, 4, 5])\n assert answers_match(candidate(nums1=[1, 2], nums2=[2, 3], nums3=[3, 4]), [2, 3])\n assert answers_match(candidate(nums1=[1, 2, 2], nums2=[4, 3, 3], nums3=[5]), [])\n assert answers_match(candidate(nums1=[1, 1, 3, 2], nums2=[2, 3], nums3=[3]), [2, 3])\n assert answers_match(candidate(nums1=[3, 1], nums2=[2, 3], nums3=[1, 2]), [1, 2, 3])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5], nums2=[5, 6, 7, 8, 9], nums3=[3, 4, 5, 10, 11]), [3, 4, 5])\n assert answers_match(candidate(nums1=[10], nums2=[10, 20], nums3=[10, 30]), [10])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], nums2=[5, 6, 7, 8, 9, 10, 11, 12, 13, 14], nums3=[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]), [5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], nums2=[11, 12, 13, 14, 15, 16, 17, 18, 19, 20], nums3=[21, 22, 23, 24, 25, 26, 27, 28, 29, 30]), [])\n assert answers_match(candidate(nums1=[10, 20, 30, 40, 50], nums2=[15, 25, 35, 45, 55], nums3=[20, 30, 40, 50, 60]), [20, 30, 40, 50])\n assert answers_match(candidate(nums1=[1, 2, 3, 1, 2, 3], nums2=[3, 4, 5, 3, 4, 5], nums3=[5, 6, 7, 5, 6, 7]), [3, 5])\n assert answers_match(candidate(nums1=[99, 98, 97, 96, 95], nums2=[94, 93, 92, 91, 90], nums3=[95, 94, 93, 92, 91]), [91, 92, 93, 94, 95])\n assert answers_match(candidate(nums1=[6, 7, 8, 9, 10], nums2=[1, 2, 3, 4, 5], nums3=[5, 6, 7]), [5, 6, 7])\n assert answers_match(candidate(nums1=[50, 50, 50, 50], nums2=[50, 50, 50, 50], nums3=[50, 50, 50, 50]), [50])\n assert answers_match(candidate(nums1=[5, 10, 15, 20], nums2=[10, 20, 30, 40], nums3=[15, 20, 25, 30]), [10, 15, 20, 30])\n assert answers_match(candidate(nums1=[50, 51, 52, 53, 54, 55], nums2=[55, 56, 57, 58, 59], nums3=[59, 60, 61, 62, 63]), [55, 59])\n assert answers_match(candidate(nums1=[7, 7, 7, 7, 7], nums2=[7, 7, 7, 7, 8], nums3=[7, 7, 7, 7, 9]), [7])\n assert answers_match(candidate(nums1=[15, 25, 35, 45, 55], nums2=[55, 65, 75, 85, 95], nums3=[15, 25, 35, 45, 55]), [15, 25, 35, 45, 55])\n assert answers_match(candidate(nums1=[1, 1, 1, 1, 1], nums2=[2, 2, 2, 2, 2], nums3=[1, 2, 3, 4, 5]), [1, 2])\n assert answers_match(candidate(nums1=[10, 20, 30, 40, 50], nums2=[5, 15, 25, 35, 45], nums3=[10, 25, 40, 55]), [10, 25, 40])\n assert answers_match(candidate(nums1=[10, 20, 30, 40, 50], nums2=[5, 15, 25, 35, 45], nums3=[10, 20, 30, 40, 50]), [10, 20, 30, 40, 50])\n assert answers_match(candidate(nums1=[60, 61, 62, 63], nums2=[63, 64, 65, 66], nums3=[66, 67, 68, 69]), [63, 66])\n assert answers_match(candidate(nums1=[1, 1, 2, 2], nums2=[2, 2, 3, 3], nums3=[3, 3, 1, 1]), [1, 2, 3])\n assert answers_match(candidate(nums1=[50, 51, 52, 53, 54], nums2=[55, 56, 57, 58, 59], nums3=[50, 51, 52, 53, 54]), [50, 51, 52, 53, 54])\n assert answers_match(candidate(nums1=[1, 1, 1, 2, 2, 3], nums2=[2, 2, 2, 3, 3, 3], nums3=[3, 3, 3, 4, 4, 4]), [2, 3])\n assert answers_match(candidate(nums1=[10, 20, 30, 40, 50], nums2=[50, 60, 70, 80, 90], nums3=[90, 10, 20, 30, 100]), [10, 20, 30, 50, 90])\n assert answers_match(candidate(nums1=[10, 20, 30, 40], nums2=[40, 50, 60], nums3=[10, 50, 70]), [10, 40, 50])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5, 6], nums2=[2, 3, 4, 5, 6, 7], nums3=[3, 4, 5, 6, 7, 8]), [2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(nums1=[99, 98, 97], nums2=[96, 95, 94], nums3=[93, 92, 91]), [])\n assert answers_match(candidate(nums1=[7, 14, 21, 28], nums2=[14, 28, 42, 56], nums3=[21, 42, 63, 84]), [14, 21, 28, 42])\n assert answers_match(candidate(nums1=[99, 100], nums2=[1, 2], nums3=[3, 4]), [])\n assert answers_match(candidate(nums1=[1, 1, 1, 1], nums2=[1, 1, 1, 1], nums3=[2, 2, 2, 2]), [1])\n assert answers_match(candidate(nums1=[90, 91, 92], nums2=[91, 92, 93], nums3=[92, 93, 94]), [91, 92, 93])\n assert answers_match(candidate(nums1=[10, 20, 30], nums2=[20, 30, 40], nums3=[30, 40, 50]), [20, 30, 40])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5], nums2=[4, 5, 6, 7, 8], nums3=[5, 8, 9, 10, 11]), [4, 5, 8])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5], nums2=[5, 4, 3, 2, 1], nums3=[1, 3, 5, 7, 9]), [1, 2, 3, 4, 5])\n assert answers_match(candidate(nums1=[20, 30, 40, 50], nums2=[50, 60, 70, 80], nums3=[80, 90, 100, 20]), [20, 50, 80])\n assert answers_match(candidate(nums1=[10, 20, 30], nums2=[30, 40, 50], nums3=[50, 60, 70]), [30, 50])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], nums2=[11, 12, 13, 14, 15, 16, 17, 18, 19, 20], nums3=[21, 22, 23, 24, 25, 1, 2, 3]), [1, 2, 3])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], nums2=[11, 12, 13, 14, 15, 16, 17, 18, 19, 20], nums3=[5, 10, 15, 20]), [5, 10, 15, 20])\n assert answers_match(candidate(nums1=[1, 3, 5, 7, 9], nums2=[2, 4, 6, 8, 10], nums3=[1, 4, 7, 10]), [1, 4, 7, 10])\n assert answers_match(candidate(nums1=[10, 20, 30], nums2=[30, 40, 50], nums3=[50, 60, 70, 10]), [10, 30, 50])\n assert answers_match(candidate(nums1=[99, 98, 97, 96, 95], nums2=[94, 95, 96, 97, 98], nums3=[93, 94, 95, 96, 97]), [94, 95, 96, 97, 98])\n assert answers_match(candidate(nums1=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], nums2=[5, 15, 25, 35, 45, 55, 65, 75, 85, 95], nums3=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]), [5, 10, 15, 20, 25, 30, 35, 40, 45, 50])\n assert answers_match(candidate(nums1=[4, 5, 6], nums2=[7, 8, 9], nums3=[4, 7, 10]), [4, 7])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5], nums2=[4, 5, 6, 7, 8], nums3=[7, 8, 9, 10, 1]), [1, 4, 5, 7, 8])\n assert answers_match(candidate(nums1=[10, 20, 30, 40], nums2=[30, 40, 50, 60], nums3=[50, 60, 70, 80]), [30, 40, 50, 60])\n assert answers_match(candidate(nums1=[10, 20, 30, 40, 50], nums2=[60, 70, 80, 90, 10], nums3=[11, 22, 33, 44, 50]), [10, 50])\n assert answers_match(candidate(nums1=[1, 3, 5, 7, 9], nums2=[2, 4, 6, 8, 10], nums3=[1, 3, 5, 7, 9]), [1, 3, 5, 7, 9])\n assert answers_match(candidate(nums1=[1, 3, 5, 7, 9, 11], nums2=[2, 4, 6, 8, 10, 12], nums3=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])\n assert answers_match(candidate(nums1=[10, 20, 30, 40], nums2=[20, 30, 40, 50], nums3=[30, 40, 50, 60]), [20, 30, 40, 50])\n assert answers_match(candidate(nums1=[10], nums2=[20, 30, 40, 50, 10], nums3=[10, 60, 70, 80, 90]), [10])\n assert answers_match(candidate(nums1=[9, 8, 7, 6, 5, 4, 3, 2, 1], nums2=[1, 3, 5, 7, 9], nums3=[2, 4, 6, 8, 10]), [1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5], nums2=[5, 6, 7, 8, 9], nums3=[9, 1, 2, 3]), [1, 2, 3, 5, 9])\n assert answers_match(candidate(nums1=[1, 3, 5, 7, 9], nums2=[2, 4, 6, 8, 10], nums3=[1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])\n assert answers_match(candidate(nums1=[1, 2, 3], nums2=[4, 5, 6], nums3=[7, 8, 9]), [])\n assert answers_match(candidate(nums1=[60, 61, 62, 63, 64], nums2=[65, 66, 67, 68, 69], nums3=[60, 61, 62, 63, 64, 65]), [60, 61, 62, 63, 64, 65])\n assert answers_match(candidate(nums1=[1, 1, 1, 1], nums2=[1, 2, 3, 4], nums3=[1, 5, 6, 7]), [1])\n assert answers_match(candidate(nums1=[90, 91, 92, 93], nums2=[91, 92, 93, 94], nums3=[92, 93, 94, 95]), [91, 92, 93, 94])\n assert answers_match(candidate(nums1=[10, 20, 30], nums2=[30, 40, 50], nums3=[50, 60, 10]), [10, 30, 50])\n assert answers_match(candidate(nums1=[1, 3, 5, 7, 9], nums2=[2, 4, 6, 8, 10], nums3=[1, 5, 9, 10, 11]), [1, 5, 9, 10])\n assert answers_match(candidate(nums1=[1, 2], nums2=[1, 3], nums3=[1, 4]), [1])\n assert answers_match(candidate(nums1=[10, 20, 30, 40, 50], nums2=[10, 20, 60, 70, 80], nums3=[30, 40, 50, 60, 90]), [10, 20, 30, 40, 50, 60])\n assert answers_match(candidate(nums1=[1, 3, 5, 7, 9], nums2=[2, 4, 6, 8, 10], nums3=[3, 6, 9, 12]), [3, 6, 9])\n assert answers_match(candidate(nums1=[1, 1, 1, 1], nums2=[1, 2, 2, 2], nums3=[1, 2, 3, 3]), [1, 2])\n assert answers_match(candidate(nums1=[99, 98, 97], nums2=[97, 96, 95], nums3=[95, 94, 93]), [95, 97])\n assert answers_match(candidate(nums1=[50, 51, 52, 53, 54], nums2=[50, 55, 56, 57, 58], nums3=[50, 51, 59, 60, 61]), [50, 51])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5], nums2=[5, 6, 7, 8, 9], nums3=[9, 10, 1, 11, 12]), [1, 5, 9])\n assert answers_match(candidate(nums1=[1, 4, 7, 9], nums2=[2, 4, 7, 10], nums3=[3, 4, 8, 9]), [4, 7, 9])\n assert answers_match(candidate(nums1=[7, 8, 9], nums2=[10, 11, 12], nums3=[13, 14, 15]), [])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5], nums2=[3, 4, 5, 6, 7], nums3=[5, 6, 7, 8, 9]), [3, 4, 5, 6, 7])\n assert answers_match(candidate(nums1=[1, 2, 3], nums2=[4, 5, 6], nums3=[1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])\n assert answers_match(candidate(nums1=[10, 20, 30, 40, 50], nums2=[20, 30, 40, 50, 60], nums3=[30, 40, 50, 60, 70]), [20, 30, 40, 50, 60])\n assert answers_match(candidate(nums1=[1, 3, 5, 7, 9], nums2=[2, 4, 6, 8, 10], nums3=[5, 10, 15, 20, 25]), [5, 10])\n assert answers_match(candidate(nums1=[1, 3, 5, 7, 9], nums2=[2, 4, 6, 8, 10], nums3=[3, 4, 5, 6, 7]), [3, 4, 5, 6, 7])\n assert answers_match(candidate(nums1=[2, 4, 6, 8, 10], nums2=[1, 3, 5, 7, 9], nums3=[2, 4, 6, 8, 10]), [2, 4, 6, 8, 10])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], nums2=[2, 3, 4, 5, 6, 7, 8, 9, 10, 1], nums3=[3, 4, 5, 6, 7, 8, 9, 10, 1, 2]), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])\n assert answers_match(candidate(nums1=[5, 10, 15, 20, 25], nums2=[25, 30, 35, 40, 45], nums3=[45, 50, 55, 60, 65]), [25, 45])\n assert answers_match(candidate(nums1=[1, 2, 3], nums2=[1, 2, 4, 5], nums3=[2, 3, 4, 6]), [1, 2, 3, 4])\n assert answers_match(candidate(nums1=[5, 10, 15, 20, 25], nums2=[10, 15, 20, 25, 30], nums3=[15, 20, 25, 30, 35]), [10, 15, 20, 25, 30])\n assert answers_match(candidate(nums1=[33, 44, 55, 66], nums2=[22, 33, 44, 55], nums3=[11, 22, 33, 44]), [22, 33, 44, 55])\n assert answers_match(candidate(nums1=[20, 30, 40, 50], nums2=[20, 30, 40], nums3=[20, 30]), [20, 30, 40])\n assert answers_match(candidate(nums1=[5, 15, 25, 35], nums2=[5, 15, 45, 55], nums3=[5, 25, 45, 65]), [5, 15, 25, 45])\n assert answers_match(candidate(nums1=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], nums2=[11, 12, 13, 14, 15, 16, 17, 18, 19, 20], nums3=[1, 11, 3, 13, 5, 15, 7, 17, 9, 19]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19])\n assert answers_match(candidate(nums1=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], nums2=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], nums3=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])\n assert answers_match(candidate(nums1=[1, 1, 2, 2, 3, 3], nums2=[1, 2, 3, 4, 5, 6], nums3=[3, 4, 5, 6, 7, 8]), [1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(nums1=[1, 1, 2, 2, 3, 3, 4, 4, 5, 5], nums2=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], nums3=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]), [1, 2, 3, 4, 5, 7, 9])\n assert answers_match(candidate(nums1=[90, 91, 92], nums2=[92, 93, 94], nums3=[94, 95, 96, 97, 90]), [90, 92, 94])\n assert answers_match(candidate(nums1=[1, 1, 2, 2, 3], nums2=[3, 3, 4, 4, 5], nums3=[5, 5, 6, 6, 7]), [3, 5])\n assert answers_match(candidate(nums1=[1, 1, 1, 1, 1], nums2=[1, 1, 1, 1, 2], nums3=[2, 2, 2, 2, 2]), [1, 2])\n", "comparison": "unordered"}, "public_tests": ["[1,1,3,2]\n[2,3]\n[3]", "[3,1]\n[2,3]\n[1,2]", "[1,2,2]\n[4,3,3]\n[5]"], "hints": ["What data structure can we use to help us quickly find whether an element belongs in an array?", "Can we count the frequencies of the elements in each array?"], "metadata": {"canonical_parameter_names": ["nums1", "nums2", "nums3"], "leetcode_dataset_entry_point": "Solution().twoOutOfThree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:50+00:00", "tests_total": 100, "tests_dropped": 4, "flags": ["any_order"], "topic_tags": ["array", "hash-table", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def twoOutOfThree(self, nums1: list[int], nums2: list[int], nums3: list[int]) -> list[int]:", "container": "Solution", "callable": "twoOutOfThree", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}, {"name": "nums3", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2033, "task_id": "minimum-operations-to-make-a-uni-value-grid", "difficulty": "Medium", "problem_description": "You are given a 2D integer grid of size m x n and an integer x. In one operation, you can add x to or subtract x from any element in the grid.\n\nA uni-value grid is a grid where all the elements of it are equal.\n\nReturn the minimum number of operations to make the grid uni-value. If it is not possible, return -1.\n\nExample 1:\n\nInput: grid = [[2,4],[6,8]], x = 2\nOutput: 4\nExplanation: We can make every element equal to 4 by doing the following:\n- Add x to 2 once.\n- Subtract x from 6 once.\n- Subtract x from 8 twice.\nA total of 4 operations were used.\n\nExample 2:\n\nInput: grid = [[1,5],[2,3]], x = 1\nOutput: 5\nExplanation: We can make every element equal to 3.\n\nExample 3:\n\nInput: grid = [[1,2],[3,4]], x = 2\nOutput: -1\nExplanation: It is impossible to make every element equal.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 10^5\n- 1 <= m * n <= 10^5\n- 1 <= x, grid[i][j] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 5], [2, 3]],x = 1) == 5\n assert candidate(grid = [[10, 10], [10, 10]],x = 5) == 0\n assert candidate(grid = [[10, 10], [10, 10]],x = 3) == 0\n assert candidate(grid = [[10, 12], [14, 16]],x = 2) == 4\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],x = 1) == 0\n assert candidate(grid = [[2, 4], [6, 8]],x = 2) == 4\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 1) == 20\n assert candidate(grid = [[1, 2], [3, 4]],x = 2) == -1\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],x = 5) == 0\n assert candidate(grid = [[1, 1, 1], [1, 1, 1]],x = 3) == 0\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 2) == -1\n assert candidate(grid = [[1, 1], [2, 2]],x = 3) == -1\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],x = 1) == 0\n assert candidate(grid = [[1, 2, 3], [6, 5, 4], [7, 8, 9]],x = 1) == 20\n assert candidate(grid = [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23]],x = 2) == 36\n assert candidate(grid = [[7, 14, 21, 28, 35], [42, 49, 56, 63, 70], [77, 84, 91, 98, 105], [112, 119, 126, 133, 140]],x = 7) == 100\n assert candidate(grid = [[100, 200, 300], [400, 500, 600], [700, 800, 900]],x = 100) == 20\n assert candidate(grid = [[5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],x = 1) == 36\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18]],x = 1) == 81\n assert candidate(grid = [[1, 2], [3, 4], [5, 6]],x = 1) == 9\n assert candidate(grid = [[1, 5, 9], [13, 17, 21], [25, 29, 33]],x = 4) == 20\n assert candidate(grid = [[7, 14, 21], [14, 28, 42], [21, 42, 63]],x = 7) == 17\n assert candidate(grid = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],x = 1) == 8\n assert candidate(grid = [[2, 4, 6, 8], [10, 12, 14, 16], [18, 20, 22, 24]],x = 2) == 36\n assert candidate(grid = [[1, 2], [3, 4], [5, 7]],x = 2) == -1\n assert candidate(grid = [[7, 7, 7], [7, 8, 7], [7, 7, 7]],x = 1) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],x = 1) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],x = 2) == -1\n assert candidate(grid = [[7, 11, 15], [19, 23, 27], [31, 35, 39]],x = 2) == 40\n assert candidate(grid = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],x = 1) == 6\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],x = 15) == -1\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11]],x = 2) == -1\n assert candidate(grid = [[3, 6, 9, 12], [15, 18, 21, 24], [27, 30, 33, 36], [39, 42, 45, 48]],x = 3) == 64\n assert candidate(grid = [[100, 200], [300, 400]],x = 100) == 4\n assert candidate(grid = [[1001, 1002, 1003, 1004], [1005, 1006, 1007, 1008], [1009, 1010, 1011, 1012]],x = 1) == 36\n assert candidate(grid = [[3, 6, 9, 12], [6, 12, 18, 24], [9, 18, 27, 36], [12, 24, 36, 48]],x = 3) == 54\n assert candidate(grid = [[1, 3, 5], [7, 9, 11], [13, 15, 17]],x = 2) == 20\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 2, 1]],x = 1) == 1\n assert candidate(grid = [[5000, 5000, 5000], [5000, 5000, 5000], [5000, 5000, 5000]],x = 1000) == 0\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 3) == -1\n assert candidate(grid = [[5, 10, 15], [20, 25, 30], [35, 40, 45]],x = 5) == 20\n assert candidate(grid = [[2, 4, 6], [8, 10, 12], [14, 16, 18]],x = 2) == 20\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],x = 7) == -1\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],x = 1) == 100\n assert candidate(grid = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100]],x = 10) == 25\n assert candidate(grid = [[10, 20, 30], [20, 30, 40], [30, 40, 50]],x = 10) == 8\n assert candidate(grid = [[2, 4, 6], [8, 10, 12], [14, 16, 18]],x = 5) == -1\n assert candidate(grid = [[4, 8, 12, 16], [8, 16, 24, 32], [12, 24, 36, 48], [16, 32, 48, 64]],x = 4) == 54\n assert candidate(grid = [[4, 8, 12], [16, 20, 24], [28, 32, 36]],x = 4) == 20\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 2]],x = 1) == 1\n assert candidate(grid = [[101, 202, 303], [404, 505, 606], [707, 808, 909]],x = 101) == 20\n assert candidate(grid = [[7, 14, 21, 28], [35, 42, 49, 56], [63, 70, 77, 84]],x = 7) == 36\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],x = 5) == -1\n assert candidate(grid = [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29]],x = 2) == 56\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 4) == -1\n assert candidate(grid = [[1, 5, 9], [2, 6, 10], [3, 7, 11]],x = 2) == -1\n assert candidate(grid = [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39]],x = 2) == 100\n assert candidate(grid = [[101, 102, 103], [104, 105, 106], [107, 108, 109]],x = 1) == 20\n assert candidate(grid = [[1, 4, 7, 10], [13, 16, 19, 22], [25, 28, 31, 34]],x = 3) == 36\n assert candidate(grid = [[1, 2, 3], [2, 3, 4], [3, 4, 5]],x = 1) == 8\n assert candidate(grid = [[1, 5, 9], [2, 6, 10], [3, 7, 11]],x = 3) == -1\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 10]],x = 5) == 1\n assert candidate(grid = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60]],x = 5) == 36\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 10) == -1\n assert candidate(grid = [[5, 9, 13], [17, 21, 25], [29, 33, 37]],x = 4) == 20\n assert candidate(grid = [[3, 6, 9], [12, 15, 18], [21, 24, 27]],x = 3) == 20\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],x = 10) == 20\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],x = 5) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 2, 1, 1]],x = 1) == 1\n assert candidate(grid = [[3, 3, 3, 3, 3], [3, 3, 3, 3, 3], [3, 3, 3, 3, 4]],x = 1) == 1\n assert candidate(grid = [[3, 9, 15], [12, 15, 18], [21, 24, 27]],x = 3) == 17\n assert candidate(grid = [[5, 15, 25, 35], [45, 55, 65, 75], [85, 95, 105, 115], [125, 135, 145, 155]],x = 10) == 64\n assert candidate(grid = [[2, 4, 6], [8, 10, 12], [14, 16, 18]],x = 3) == -1\n assert candidate(grid = [[100, 102, 104], [106, 108, 110], [112, 114, 116]],x = 2) == 20\n assert candidate(grid = [[3, 9, 15], [21, 27, 33], [39, 45, 51]],x = 6) == 20\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 2, 1]],x = 1) == 1\n assert candidate(grid = [[5, 15, 25], [35, 45, 55], [65, 75, 85]],x = 10) == 20\n assert candidate(grid = [[1, 1, 1, 2], [1, 1, 2, 2], [1, 2, 2, 3]],x = 1) == 7\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],x = 1) == 0\n assert candidate(grid = [[123, 456, 789], [1011, 1213, 1415], [1617, 1819, 2021]],x = 3) == -1\n assert candidate(grid = [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23], [25, 27, 29, 31]],x = 2) == 64\n assert candidate(grid = [[5, 10, 15, 20], [10, 20, 30, 40], [15, 30, 45, 60]],x = 5) == 30\n assert candidate(grid = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30]],x = 2) == 56\n assert candidate(grid = [[1, 5, 9, 13, 17], [21, 25, 29, 33, 37], [41, 45, 49, 53, 57]],x = 4) == 56\n assert candidate(grid = [[2, 4, 6, 8], [10, 12, 14, 16], [18, 20, 22, 24], [26, 28, 30, 32]],x = 2) == 64\n assert candidate(grid = [[7, 14, 21], [28, 35, 42], [49, 56, 63]],x = 7) == 20\n assert candidate(grid = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120]],x = 10) == 36\n assert candidate(grid = [[5, 15, 25, 35], [45, 55, 65, 75], [85, 95, 105, 115]],x = 10) == 36\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],x = 1) == 36\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],x = 1) == 56\n assert candidate(grid = [[3, 6, 9, 12], [15, 18, 21, 24], [27, 30, 33, 36]],x = 3) == 36\n assert candidate(grid = [[1, 4, 7, 10], [2, 5, 8, 11], [3, 6, 9, 12]],x = 3) == -1\n assert candidate(grid = [[4, 8, 12, 16], [20, 24, 28, 32], [36, 40, 44, 48]],x = 4) == 36\n assert candidate(grid = [[2, 4, 6], [8, 10, 12], [14, 16, 18]],x = 1) == 40\n assert candidate(grid = [[11, 22, 33], [44, 55, 66], [77, 88, 99]],x = 11) == 20\n", "comparison": "exact"}, "public_tests": ["[[2,4],[6,8]]\n2", "[[1,5],[2,3]]\n1", "[[1,2],[3,4]]\n2"], "hints": ["Is it possible to make two integers a and b equal if they have different remainders dividing by x?", "If it is possible, which number should you select to minimize the number of operations?", "What if the elements are sorted?"], "metadata": {"canonical_parameter_names": ["grid", "x"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:53+00:00", "tests_total": 95, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "math", "sorting", "matrix"]}, "language": "python", "interface": {"raw_signature": "def minOperations(self, grid: list[list[int]], x: int) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "grid", "type": "list[list[int]]"}, {"name": "x", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2035, "task_id": "partition-array-into-two-arrays-to-minimize-sum-difference", "difficulty": "Hard", "problem_description": "You are given an integer array nums of 2 * n integers. You need to partition nums into two arrays of length n to minimize the absolute difference of the sums of the arrays. To partition nums, put each element of nums into one of the two arrays.\n\nReturn the minimum possible absolute difference.\n\nExample 1:\n\nInput: nums = [3,9,7,3]\nOutput: 2\nExplanation: One optimal partition is: [3,9] and [7,3].\nThe absolute difference between the sums of the arrays is abs((3 + 9) - (7 + 3)) = 2.\n\nExample 2:\n\nInput: nums = [-36,36]\nOutput: 72\nExplanation: One optimal partition is: [-36] and [36].\nThe absolute difference between the sums of the arrays is abs((-36) - (36)) = 72.\n\nExample 3:\n\nInput: nums = [2,-1,0,4,-2,-9]\nOutput: 0\nExplanation: One optimal partition is: [2,4,-9] and [-1,0,-2].\nThe absolute difference between the sums of the arrays is abs((2 + 4 + -9) - (-1 + 0 + -2)) = 0.\n\nConstraints:\n\n- 1 <= n <= 15\n- nums.length == 2 * n\n- -10^7 <= nums[i] <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 9, 7, 3]) == 2\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]) == 0\n assert candidate(nums = [10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000]) == 5000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 30]) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000, 1250000, -1250000]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, -1, 0, 4, -2, -9]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40]) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(nums = [10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000]) == 0\n assert candidate(nums = [10000000, -10000000, 10000000, -10000000, 10000000, -10000000]) == 20000000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 0\n assert candidate(nums = [-36, 36]) == 72\n assert candidate(nums = [-1, -2, -3, -4, -5, -6]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]) == 0\n assert candidate(nums = [-1000, 1000, -1500, 1500, -2000, 2000, -2500, 2500, -3000, 3000, -3500, 3500, -4000, 4000, -4500, 4500]) == 0\n assert candidate(nums = [987654, -987654, 876543, -876543, 765432, -765432, 654321, -654321, 543210, -543210, 432109, -432109, 321098, -321098, 210987, -210987]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 0\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000, 125000, -125000, 62500, -62500, 31250, -31250, 15625, -15625, 7812, -7812]) == 0\n assert candidate(nums = [5, -5, 15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75]) == 0\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800]) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(nums = [1234567, -7654321, 8901234, -4321098, 5678901, -1234567, 8765432, -2345678, 9876543, -3456789, 4567890, -5678901, 6789012, -6789012, 7890123, -7890123]) == 7307\n assert candidate(nums = [1000000, -1000000, 2000000, -2000000, 3000000, -3000000, 4000000, -4000000, 5000000, -5000000, 6000000, -6000000, 7000000, -7000000, 8000000, -8000000]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 1\n assert candidate(nums = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, -10000000, -10000000, -10000000, -10000000, -10000000, -10000000]) == 0\n assert candidate(nums = [0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == 0\n assert candidate(nums = [-9, 9, -8, 8, -7, 7, -6, 6, -5, 5, -4, 4, -3, 3, -2, 2]) == 0\n assert candidate(nums = [-1000, 1000, -2000, 2000, -3000, 3000, -4000, 4000, -5000, 5000, -6000, 6000, -7000, 7000, -8000, 8000]) == 0\n assert candidate(nums = [1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [12345, -12345, 67890, -67890, 11111, -11111, 22222, -22222, 33333, -33333, 44444, -44444, 55555, -55555, 66666, -66666]) == 0\n assert candidate(nums = [123, 456, 789, -123, -456, -789, 321, 654, 987, -321, -654, -987, 234, 567, 890, -234, -567, -890]) == 4\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16]) == 0\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 0\n assert candidate(nums = [-10000, 10000, -20000, 20000, -30000, 30000, -40000, 40000, -50000, 50000, -60000, 60000, -70000, 70000, -80000, 80000]) == 0\n assert candidate(nums = [5, 2, 9, 11, 15, 18, 3, 7, 14, 6, 10, 4, 8, 13, 1, 12]) == 0\n assert candidate(nums = [100000, -100000, 200000, -200000, 300000, -300000, 400000, -400000, 500000, -500000, 600000, -600000, 700000, -700000, 800000, -800000]) == 0\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]) == 0\n assert candidate(nums = [-100, -200, -300, -400, -500, 500, 400, 300, 200, 100, 0, 100, 200, 300, 400, 500]) == 100\n assert candidate(nums = [9999999, -9999999, 4999999, -4999999, 2499999, -2499999, 1249999, -1249999, 624999, -624999, 312499, -312499, 156249, -156249, 78124, -78124]) == 0\n assert candidate(nums = [1000, -500, 2000, -1500, 3000, -2500, 4000, -3500, 5000, -4500, 6000, -5500, 7000, -6500, 8000, -7500]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 0\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80]) == 0\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300, -1400, 1500, -1600]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]) == 0\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000, 750000, -750000, 375000, -375000, 187500, -187500, 937500, -937500, 468750, -468750]) == 0\n assert candidate(nums = [-7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 0\n assert candidate(nums = [100, 200, 300, 400, -500, 600, -700, 800, -900, 1000, -1100, 1200, -1300, 1400, -1500, 1600]) == 0\n assert candidate(nums = [-5, 5, -10, 10, -15, 15, -20, 20, -25, 25, -30, 30, -35, 35, -40, 40]) == 0\n assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500, -600, 600, -700, 700, -800, 800]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]) == 0\n assert candidate(nums = [-5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 0\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50, -60, 60, -70, 70, -80, 80]) == 0\n assert candidate(nums = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11, 33, 55, 77, 99, 22, 44]) == 3\n assert candidate(nums = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000, 0, -1000000, -2000000, -3000000, -4000000, -5000000]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [10000000, -9999999, 9999998, -9999997, 9999996, -9999995, 9999994, -9999993, 9999992, -9999991, 9999990, -9999989, 9999988, -9999987, 9999986, -9999985]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100000]) == 99999\n assert candidate(nums = [9999999, -9999999, 8888888, -8888888, 7777777, -7777777, 6666666, -6666666, 5555555, -5555555, 4444444, -4444444, 3333333, -3333333, 2222222, -2222222]) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 0\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8]) == 0\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 0\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [5, 3, 8, 1, 9, 2, 6, 4, 7, 0, 11, 13, 15, 17, 19, 21]) == 1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 0\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16]) == 0\n", "comparison": "exact"}, "public_tests": ["[3,9,7,3]", "[-36,36]", "[2,-1,0,4,-2,-9]"], "hints": ["The target sum for the two partitions is sum(nums) / 2.", "Could you reduce the time complexity if you arbitrarily divide nums into two halves (two arrays)? Meet-in-the-Middle?", "For both halves, pre-calculate a 2D array where the kth index will store all possible sum values if only k elements from this half are added.", "For each sum of k elements in the first half, find the best sum of n-k elements in the second half such that the two sums add up to a value closest to the target sum from hint 1. These two subsets will form one array of the partition."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:38:55+00:00", "tests_total": 88, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["array", "two-pointers", "binary-search", "dynamic-programming", "bit-manipulation", "meet-in-the-middle", "sorting", "ordered-set", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def minimumDifference(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minimumDifference", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2037, "task_id": "minimum-number-of-moves-to-seat-everyone", "difficulty": "Easy", "problem_description": "There are n availabe seats and n students standing in a room. You are given an array seats of length n, where seats[i] is the position of the i^th seat. You are also given the array students of length n, where students[j] is the position of the j^th student.\n\nYou may perform the following move any number of times:\n\n- Increase or decrease the position of the i^th student by 1 (i.e., moving the i^th student from position x to x + 1 or x - 1)\n\nReturn the minimum number of moves required to move each student to a seat such that no two students are in the same seat.\n\nNote that there may be multiple seats or students in the same position at the beginning.\n\nExample 1:\n\nInput: seats = [3,1,5], students = [2,7,4]\nOutput: 4\nExplanation: The students are moved as follows:\n- The first student is moved from position 2 to position 1 using 1 move.\n- The second student is moved from position 7 to position 5 using 2 moves.\n- The third student is moved from position 4 to position 3 using 1 move.\nIn total, 1 + 2 + 1 = 4 moves were used.\n\nExample 2:\n\nInput: seats = [4,1,5,9], students = [1,3,2,6]\nOutput: 7\nExplanation: The students are moved as follows:\n- The first student is not moved.\n- The second student is moved from position 3 to position 4 using 1 move.\n- The third student is moved from position 2 to position 5 using 3 moves.\n- The fourth student is moved from position 6 to position 9 using 3 moves.\nIn total, 0 + 1 + 3 + 3 = 7 moves were used.\n\nExample 3:\n\nInput: seats = [2,2,6,6], students = [1,3,2,6]\nOutput: 4\nExplanation: Note that there are two seats at position 2 and two seats at position 6.\nThe students are moved as follows:\n- The first student is moved from position 1 to position 2 using 1 move.\n- The second student is moved from position 3 to position 6 using 3 moves.\n- The third student is not moved.\n- The fourth student is not moved.\nIn total, 1 + 3 + 0 + 0 = 4 moves were used.\n\nConstraints:\n\n- n == seats.length == students.length\n- 1 <= n <= 100\n- 1 <= seats[i], students[j] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(seats = [5, 5, 5, 5],students = [5, 5, 5, 5]) == 0\n assert candidate(seats = [10, 20, 30],students = [5, 15, 25]) == 15\n assert candidate(seats = [4, 1, 5, 9],students = [1, 3, 2, 6]) == 7\n assert candidate(seats = [1, 1, 1, 1],students = [1, 1, 1, 1]) == 0\n assert candidate(seats = [3, 1, 5],students = [2, 7, 4]) == 4\n assert candidate(seats = [1, 1, 1],students = [1, 1, 1]) == 0\n assert candidate(seats = [50, 50, 50],students = [49, 50, 51]) == 2\n assert candidate(seats = [10, 20, 30],students = [15, 25, 35]) == 15\n assert candidate(seats = [10, 20, 30],students = [1, 2, 3]) == 54\n assert candidate(seats = [100, 1, 50],students = [50, 100, 1]) == 0\n assert candidate(seats = [10, 20, 30, 40, 50],students = [5, 15, 25, 35, 45]) == 25\n assert candidate(seats = [100, 1, 50, 50],students = [50, 1, 100, 50]) == 0\n assert candidate(seats = [100, 1, 2, 3, 4],students = [1, 2, 3, 4, 100]) == 0\n assert candidate(seats = [100, 90, 80, 70],students = [70, 80, 90, 100]) == 0\n assert candidate(seats = [50, 50, 50],students = [50, 50, 50]) == 0\n assert candidate(seats = [10, 1, 100],students = [5, 10, 99]) == 5\n assert candidate(seats = [1, 2, 3, 4, 5],students = [5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [2, 2, 6, 6],students = [1, 3, 2, 6]) == 4\n assert candidate(seats = [1, 3, 5, 7, 9],students = [2, 4, 6, 8, 10]) == 5\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 495\n assert candidate(seats = [5, 5, 5, 5, 5, 5],students = [1, 2, 3, 4, 5, 6]) == 11\n assert candidate(seats = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 495\n assert candidate(seats = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],students = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]) == 95\n assert candidate(seats = [20, 30, 40, 50, 60, 70, 80],students = [15, 25, 35, 45, 55, 65, 75]) == 35\n assert candidate(seats = [50, 50, 50, 50, 50, 50],students = [45, 45, 45, 55, 55, 55]) == 30\n assert candidate(seats = [3, 3, 8, 8, 10, 10, 13, 13],students = [2, 3, 6, 8, 9, 10, 12, 15]) == 7\n assert candidate(seats = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],students = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 0\n assert candidate(seats = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],students = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28]) == 20\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],students = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],students = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == 0\n assert candidate(seats = [1, 100, 1, 100, 1, 100],students = [50, 50, 50, 50, 50, 50]) == 297\n assert candidate(seats = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],students = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 300\n assert candidate(seats = [90, 80, 70, 60, 50, 40, 30],students = [10, 20, 30, 40, 50, 60, 70]) == 140\n assert candidate(seats = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],students = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 495\n assert candidate(seats = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],students = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 250\n assert candidate(seats = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],students = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 30\n assert candidate(seats = [99, 100, 1, 2, 3, 4],students = [5, 6, 7, 8, 9, 1]) == 191\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],students = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [30, 10, 20, 40, 50, 60],students = [5, 15, 25, 35, 45, 55]) == 30\n assert candidate(seats = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 980\n assert candidate(seats = [1, 5, 9, 13, 17, 21, 25, 29],students = [2, 6, 10, 14, 18, 22, 26, 30]) == 8\n assert candidate(seats = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],students = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 9\n assert candidate(seats = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],students = [99, 97, 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(seats = [5, 5, 5, 5, 5],students = [1, 2, 3, 4, 5]) == 10\n assert candidate(seats = [2, 2, 2, 3, 3, 3, 5, 5, 5, 6, 6, 6],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 32\n assert candidate(seats = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41],students = [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 50\n assert candidate(seats = [8, 12, 20, 25, 30, 35],students = [5, 10, 15, 22, 31, 36]) == 15\n assert candidate(seats = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],students = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 90\n assert candidate(seats = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],students = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59]) == 450\n assert candidate(seats = [5, 3, 8, 9, 2, 10],students = [4, 6, 7, 1, 11, 15]) == 11\n assert candidate(seats = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],students = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29]) == 10\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],students = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 45\n assert candidate(seats = [50, 50, 50, 50, 50],students = [49, 50, 51, 52, 53]) == 7\n assert candidate(seats = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 130\n assert candidate(seats = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],students = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]) == 40\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(seats = [2, 3, 5, 6, 8, 11, 13],students = [1, 4, 7, 9, 10, 12, 15]) == 12\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],students = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],students = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 540\n assert candidate(seats = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],students = [1, 7, 13, 19, 24, 29, 34, 38, 44, 49]) == 17\n assert candidate(seats = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],students = [6, 5, 5, 4, 4, 3, 3, 2, 2, 1]) == 0\n assert candidate(seats = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],students = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 0\n assert candidate(seats = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(seats = [1, 3, 6, 8, 10, 15],students = [2, 4, 5, 7, 9, 16]) == 6\n assert candidate(seats = [50, 40, 30, 20, 10, 100, 90, 80, 70, 60],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 495\n assert candidate(seats = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],students = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]) == 90\n assert candidate(seats = [3, 8, 15, 22, 29],students = [1, 6, 13, 21, 28]) == 8\n assert candidate(seats = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],students = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == 20\n assert candidate(seats = [1, 2, 3, 4, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 42\n assert candidate(seats = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],students = [3, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57]) == 35\n assert candidate(seats = [1, 4, 6, 9, 12, 15],students = [3, 5, 7, 10, 13, 16]) == 7\n assert candidate(seats = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],students = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 210\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],students = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],students = [45, 46, 47, 48, 49, 51, 52, 53, 54, 55]) == 30\n assert candidate(seats = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 100\n assert candidate(seats = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 31\n assert candidate(seats = [2, 3, 5, 7, 11, 13, 17, 19],students = [1, 4, 6, 8, 10, 12, 14, 16]) == 12\n assert candidate(seats = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],students = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 15\n assert candidate(seats = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],students = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(seats = [1, 3, 6, 8, 10, 15],students = [2, 4, 7, 9, 11, 16]) == 6\n assert candidate(seats = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99]) == 10\n assert candidate(seats = [95, 96, 97, 98, 99, 100],students = [1, 2, 3, 4, 5, 6]) == 564\n assert candidate(seats = [5, 15, 25, 35, 45, 55],students = [1, 7, 17, 27, 37, 47]) == 44\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 540\n assert candidate(seats = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 890\n assert candidate(seats = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],students = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 0\n assert candidate(seats = [5, 6, 8, 10, 15, 17, 20, 25, 30, 35],students = [4, 5, 7, 10, 12, 16, 18, 22, 28, 34]) == 15\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 50\n assert candidate(seats = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10],students = [1, 3, 3, 5, 5, 7, 7, 9, 9, 11]) == 10\n assert candidate(seats = [20, 20, 20, 20, 20],students = [19, 20, 21, 22, 23]) == 7\n assert candidate(seats = [95, 55, 10, 30, 70],students = [5, 90, 60, 40, 80]) == 35\n assert candidate(seats = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],students = [1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24]) == 800\n assert candidate(seats = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6],students = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == 3\n", "comparison": "exact"}, "public_tests": ["[3,1,5]\n[2,7,4]", "[4,1,5,9]\n[1,3,2,6]", "[2,2,6,6]\n[1,3,2,6]"], "hints": ["Can we sort the arrays to help solve the problem?", "Can we greedily match each student to a seat?", "The smallest positioned student will go to the smallest positioned chair, and then the next smallest positioned student will go to the next smallest positioned chair, and so on."], "metadata": {"canonical_parameter_names": ["seats", "students"], "leetcode_dataset_entry_point": "Solution().minMovesToSeat", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:00+00:00", "tests_total": 101, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "greedy", "sorting", "counting-sort"]}, "language": "python", "interface": {"raw_signature": "def minMovesToSeat(self, seats: list[int], students: list[int]) -> int:", "container": "Solution", "callable": "minMovesToSeat", "parameters": [{"name": "seats", "type": "list[int]"}, {"name": "students", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2038, "task_id": "remove-colored-pieces-if-both-neighbors-are-the-same-color", "difficulty": "Medium", "problem_description": "There are n pieces arranged in a line, and each piece is colored either by 'A' or by 'B'. You are given a string colors of length n where colors[i] is the color of the i^th piece.\n\nAlice and Bob are playing a game where they take alternating turns removing pieces from the line. In this game, Alice moves first.\n\n- Alice is only allowed to remove a piece colored 'A' if both its neighbors are also colored 'A'. She is not allowed to remove pieces that are colored 'B'.\n- Bob is only allowed to remove a piece colored 'B' if both its neighbors are also colored 'B'. He is not allowed to remove pieces that are colored 'A'.\n- Alice and Bob cannot remove pieces from the edge of the line.\n- If a player cannot make a move on their turn, that player loses and the other player wins.\n\nAssuming Alice and Bob play optimally, return true if Alice wins, or return false if Bob wins.\n\nExample 1:\n\nInput: colors = \"AAABABB\"\nOutput: true\nExplanation:\nAAABABB -> AABABB\nAlice moves first.\nShe removes the second 'A' from the left since that is the only 'A' whose neighbors are both 'A'.\n\nNow it's Bob's turn.\nBob cannot make a move on his turn since there are no 'B's whose neighbors are both 'B'.\nThus, Alice wins, so return true.\n\nExample 2:\n\nInput: colors = \"AA\"\nOutput: false\nExplanation:\nAlice has her turn first.\nThere are only two 'A's and both are on the edge of the line, so she cannot move on her turn.\nThus, Bob wins, so return false.\n\nExample 3:\n\nInput: colors = \"ABBBBBBBAAA\"\nOutput: false\nExplanation:\nABBBBBBBAAA -> ABBBBBBBAA\nAlice moves first.\nHer only option is to remove the second to last 'A' from the right.\n\nABBBBBBBAA -> ABBBBBBAA\nNext is Bob's turn.\nHe has many options for which 'B' piece to remove. He can pick any.\n\nOn Alice's second turn, she has no more pieces that she can remove.\nThus, Bob wins, so return false.\n\nConstraints:\n\n- 1 <= colors.length <= 10^5\n- colors consists of only the letters 'A' and 'B'\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(colors = \"AABBAABB\") == False\n assert candidate(colors = \"AAAAAAAAA\") == True\n assert candidate(colors = \"AAABAAAAABBBB\") == True\n assert candidate(colors = \"ABABABABAB\") == False\n assert candidate(colors = \"AABBBBAAA\") == False\n assert candidate(colors = \"BBBBB\") == False\n assert candidate(colors = \"BBBAAAABB\") == True\n assert candidate(colors = \"AAAAAAAA\") == True\n assert candidate(colors = \"AAAAA\") == True\n assert candidate(colors = \"AAABBBAAABBBA\") == False\n assert candidate(colors = \"AAABABB\") == True\n assert candidate(colors = \"AABBBBAA\") == False\n assert candidate(colors = \"AAAABBBB\") == False\n assert candidate(colors = \"BBBBBBBBB\") == False\n assert candidate(colors = \"ABBBBBBBAAA\") == False\n assert candidate(colors = \"ABABABABABA\") == False\n assert candidate(colors = \"ABABABAB\") == False\n assert candidate(colors = \"AAAAABBAAA\") == True\n assert candidate(colors = \"AABAABBBBAAA\") == False\n assert candidate(colors = \"ABABAB\") == False\n assert candidate(colors = \"BBBAAABB\") == False\n assert candidate(colors = \"ABAAABAA\") == True\n assert candidate(colors = \"AA\") == False\n assert candidate(colors = \"BBBBAAAABBB\") == False\n assert candidate(colors = \"AAAABBBAA\") == True\n assert candidate(colors = \"AABBBAAABBB\") == False\n assert candidate(colors = \"ABABABABABABAB\") == False\n assert candidate(colors = \"AAABBBAAABBBAABBBAAABBBAABBB\") == False\n assert candidate(colors = \"AABBABBABBABBABBABBA\") == False\n assert candidate(colors = \"ABAABAABAABAABAABA\") == False\n assert candidate(colors = \"BBBBBBBBBBAAAABBB\") == False\n assert candidate(colors = \"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AAABAAAABBAAABBBBAAAABBB\") == True\n assert candidate(colors = \"AABAABAABAABAABAA\") == False\n assert candidate(colors = \"AABBBAAABBBAABBAAABBBAABB\") == False\n assert candidate(colors = \"BBBBBBBBBBABBBBBBBBB\") == False\n assert candidate(colors = \"ABABABABABABABABABABAB\") == False\n assert candidate(colors = \"ABABABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AABBBAAABBBAAABBB\") == False\n assert candidate(colors = \"AABBAABBBAABBBAABBBAABBA\") == False\n assert candidate(colors = \"ABABABABABABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"AAABAAAAAAAAABBBBBBB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBB\") == True\n assert candidate(colors = \"ABABABABABABABABA\") == False\n assert candidate(colors = \"BBBBBBBBBBAAAAAAAAAAB\") == False\n assert candidate(colors = \"BBBAAAABBBAAAABBBAAAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"BBABBABBABBABBABB\") == False\n assert candidate(colors = \"BAAAAAAAAAABBBBBBBBBB\") == False\n assert candidate(colors = \"AAABAAABBBAAABBBBAA\") == False\n assert candidate(colors = \"AABBBAAAABBBAAB\") == False\n assert candidate(colors = \"AABBAAAABBAAAABB\") == True\n assert candidate(colors = \"BBBAABBBAAABBBAABBB\") == False\n assert candidate(colors = \"AAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAAABBBBBBBBBBB\") == False\n assert candidate(colors = \"AAAABBBBBBAAAABBBBBB\") == False\n assert candidate(colors = \"AAAAAABAAAAAABAAAAAAB\") == True\n assert candidate(colors = \"BBBAAAAAAAAABBBBBB\") == True\n assert candidate(colors = \"BBABABABABABABABABAB\") == False\n assert candidate(colors = \"AAABBBAAABBBAAABBBAAABBBAAABBBAAABBB\") == False\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"AAAAAAAABBBBBBBBBB\") == False\n assert candidate(colors = \"ABBBAAAAABBAAAAAAA\") == True\n assert candidate(colors = \"BBBAAAABBAAAABBAAAABBAAAABBAAAABB\") == True\n assert candidate(colors = \"AAAABAAAABBAAAABBAAAABBAAAABBAAAAB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAABBBBBBBBBBBB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"AABBBAAAAABBBBAAA\") == True\n assert candidate(colors = \"AAAAAAAAAABBBBBBBBBB\") == False\n assert candidate(colors = \"AAABBBAAAABBBAAABBBAAABBBAA\") == True\n assert candidate(colors = \"AAABAAAABAAABAAAABAA\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"AAAAAAAAABBBBBBBBAABBBBBBBBA\") == False\n assert candidate(colors = \"BBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"ABABABAAAABBBABAABAB\") == True\n assert candidate(colors = \"ABBBAAAABBAAAABBBA\") == True\n assert candidate(colors = \"AAABBBAABBBAAABBBA\") == False\n assert candidate(colors = \"AAABBBAABBBAABBBAAB\") == False\n assert candidate(colors = \"AAABBBAAAABBBAAABBBAA\") == True\n assert candidate(colors = \"ABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"BBBAAAABBBAAAABAA\") == True\n assert candidate(colors = \"AAABBBAAAABBBAAAABBBAAA\") == True\n assert candidate(colors = \"BBBBBAABAAAAAAABBB\") == True\n assert candidate(colors = \"AAABBAAAABBAAAABBAAAABBBAAAABB\") == True\n assert candidate(colors = \"BBBBBAAAAAAAAABBBBB\") == True\n assert candidate(colors = \"AAAAAAAAABBBBBBBBBBBB\") == False\n assert candidate(colors = \"BABAABABABABABABAB\") == False\n assert candidate(colors = \"AAABBBBAABBBBAA\") == False\n assert candidate(colors = \"BBAAABBBAAABBBAAABB\") == True\n assert candidate(colors = \"AAABAAABAAABAAABA\") == True\n assert candidate(colors = \"AAABBBAAABBBAAABBBAAABBBAAABBB\") == False\n assert candidate(colors = \"BBBBBBBBBB\") == False\n assert candidate(colors = \"BBAAAABBBAAABBBAAABB\") == True\n assert candidate(colors = \"AAAAAAAAAABBBBBBBB\") == True\n assert candidate(colors = \"BBBBBAAAABBBBBBBAAAAA\") == False\n assert candidate(colors = \"BBBBBAAAABBBBBAAAABBBBBAAAABBBBB\") == False\n assert candidate(colors = \"AAAAABBBBBAAAAABBBBBAAAAA\") == True\n assert candidate(colors = \"ABBBAAAABBAAAABBBAABA\") == True\n assert candidate(colors = \"AAAABBBBAAAABBBBAAAABBBB\") == False\n assert candidate(colors = \"BBBBAAAABBBBBBBBAAA\") == False\n assert candidate(colors = \"ABABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBB\") == True\n assert candidate(colors = \"BBBBBBAAAABBBBBBBBAAA\") == False\n assert candidate(colors = \"AABAAAAAAABBBBBBBBA\") == False\n assert candidate(colors = \"BBBAABBBAAAABBBAAABBB\") == False\n assert candidate(colors = \"ABABABABAAAAAAAABBBBBBBB\") == False\n assert candidate(colors = \"BBAAAABBBAAAABBAAA\") == True\n assert candidate(colors = \"BBAABBAAAABBAAAABBBB\") == True\n assert candidate(colors = \"AAABBBAABBAAABBBAAAAAAABBBB\") == True\n assert candidate(colors = \"AAAAABBAAAABBAAAAB\") == True\n assert candidate(colors = \"ABBBAAAABBBBAAA\") == False\n assert candidate(colors = \"BBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"BBBBBBAAAAAAAAAA\") == True\n assert candidate(colors = \"BBAAAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"ABBBAAAABBBAAAABB\") == True\n assert candidate(colors = \"BBBBBAABBBBAABBBBAABBBBA\") == False\n assert candidate(colors = \"BBBBBBBBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"BBBBBBBAAAAAAAAAAAABB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"ABABABABABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"BBBBAAAABBBBBAAAABBBBBAAAABB\") == False\n assert candidate(colors = \"AABAAABAABAAABAAA\") == True\n assert candidate(colors = \"ABABABABABABABABAB\") == False\n assert candidate(colors = \"BBBAAAABBAAAABBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAABBBBBBBBBBBAAAAAAAAAAAAAAAAABBBBBBBBBBB\") == True\n assert candidate(colors = \"AABBBAAABBAAAABBAAAAB\") == True\n assert candidate(colors = \"AAABAAABAAABAAABAAABAAAB\") == True\n assert candidate(colors = \"ABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"AAAAAABBBBBBAAA\") == True\n assert candidate(colors = \"BBBAAAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"ABABABABABABABABABABA\") == False\n assert candidate(colors = \"AAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AAAABBAABBABBAABBBAAA\") == True\n assert candidate(colors = \"ABAAAABBBBAABBBBAA\") == False\n assert candidate(colors = \"AAABAAAABBBBAAAABBBBAAAABBBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAABBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"BABAABBAABBBBAAAABBBB\") == False\n assert candidate(colors = \"AABBAABBAABBAAA\") == True\n assert candidate(colors = \"AAAAAAAAABBBBBBBB\") == True\n assert candidate(colors = \"BBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"BBAABBAAAABBBBAAAAABBBAAABBBAAABBBB\") == True\n assert candidate(colors = \"AAAAAAAAABBAAAAAAAAA\") == True\n assert candidate(colors = \"AAAABBBAAAABBB\") == True\n assert candidate(colors = \"AABBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAABBBBBBBBBBAAA\") == False\n assert candidate(colors = \"AAAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAABBBBBBB\") == True\n assert candidate(colors = \"BBAAAABBAAAABBAAAABBAAAABBB\") == True\n assert candidate(colors = \"AABBBAAAABBBAAA\") == True\n assert candidate(colors = \"BBBBBBBBAAAABBBBBBB\") == False\n assert candidate(colors = \"BBBBBAAAABBBBBAAAABBBBBAAAABBBBBAAAABBBBBAAAABBBBB\") == False\n assert candidate(colors = \"BBABABABBABABABBABABABBB\") == False\n assert candidate(colors = \"BBAABBAAAABBAAAABBAAAABBB\") == True\n assert candidate(colors = \"BBBAAAABBAAAABBB\") == True\n assert candidate(colors = \"BBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AAAABBBBAAAA\") == True\n assert candidate(colors = \"BBBBAABBBAABBBAAB\") == False\n assert candidate(colors = \"AAAAAAAAAA\") == True\n assert candidate(colors = \"BBBBBBAAAABBBBBBAAAABBBBBB\") == False\n assert candidate(colors = \"BAAABAAABAAABBB\") == True\n assert candidate(colors = \"AAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAABBBBAAAABBBBAAAAA\") == True\n assert candidate(colors = \"BBBAAAAAAAABBBBBB\") == True\n assert candidate(colors = \"AAABBBAABBBAAABBBAABBB\") == False\n assert candidate(colors = \"BABABABABABABABAB\") == False\n assert candidate(colors = \"AABAAAAABBAAABAAAAABB\") == True\n assert candidate(colors = \"BBBBBAAAABBBBBAAAABBBBBAAAABBBBBAAAABBBBB\") == False\n assert candidate(colors = \"BBBAAABBBAAABBBAAA\") == False\n assert candidate(colors = \"AAABAAAAAAAABBBBBBB\") == True\n assert candidate(colors = \"BBBBBBBBAAAAAAAAAA\") == True\n assert candidate(colors = \"ABABABABABABABABABAB\") == False\n assert candidate(colors = \"ABBBBAAAAAABBBBBAAA\") == False\n assert candidate(colors = \"AAABAAABBBABBAAA\") == True\n assert candidate(colors = \"AABBBAAAAAAAAABBBBB\") == True\n assert candidate(colors = \"BBAAAABBBAAAABBBAAAABBBAAA\") == True\n assert candidate(colors = \"BBBBBBBAAAAAAAAAA\") == True\n assert candidate(colors = \"AABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAAABBBBBBBBAAAAAAAAAABBBBBBBB\") == True\n assert candidate(colors = \"AABAAABAAABAAABAAABAAABAAABAAABAAAB\") == True\n assert candidate(colors = \"BBBBBAAAABBBBBAAAAABBBBBAAABBBAAAB\") == False\n", "comparison": "exact"}, "public_tests": ["\"AAABABB\"", "\"AA\"", "\"ABBBBBBBAAA\""], "hints": ["Does the number of moves a player can make depend on what the other player does? No", "How many moves can Alice make if colors == \"AAAAAA\"", "If a group of n consecutive pieces has the same color, the player can take n - 2 of those pieces if n is greater than or equal to 3"], "metadata": {"canonical_parameter_names": ["colors"], "leetcode_dataset_entry_point": "Solution().winnerOfGame", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:02+00:00", "tests_total": 182, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "string", "greedy", "game-theory"]}, "language": "python", "interface": {"raw_signature": "def winnerOfGame(self, colors: str) -> bool:", "container": "Solution", "callable": "winnerOfGame", "parameters": [{"name": "colors", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2039, "task_id": "the-time-when-the-network-becomes-idle", "difficulty": "Medium", "problem_description": "There is a network of n servers, labeled from 0 to n - 1. You are given a 2D integer array edges, where edges[i] = [u_i, v_i] indicates there is a message channel between servers u_i and v_i, and they can pass any number of messages to each other directly in one second. You are also given a 0-indexed integer array patience of length n.\n\nAll servers are connected, i.e., a message can be passed from one server to any other server(s) directly or indirectly through the message channels.\n\nThe server labeled 0 is the master server. The rest are data servers. Each data server needs to send its message to the master server for processing and wait for a reply. Messages move between servers optimally, so every message takes the least amount of time to arrive at the master server. The master server will process all newly arrived messages instantly and send a reply to the originating server via the reversed path the message had gone through.\n\nAt the beginning of second 0, each data server sends its message to be processed. Starting from second 1, at the beginning of every second, each data server will check if it has received a reply to the message it sent (including any newly arrived replies) from the master server:\n\n- If it has not, it will resend the message periodically. The data server i will resend the message every patience[i] second(s), i.e., the data server i will resend the message if patience[i] second(s) have elapsed since the last time the message was sent from this server.\n- Otherwise, no more resending will occur from this server.\n\nThe network becomes idle when there are no messages passing between servers or arriving at servers.\n\nReturn the earliest second starting from which the network becomes idle.\n\nExample 1:\n\nInput: edges = [[0,1],[1,2]], patience = [0,2,1]\nOutput: 8\nExplanation:\nAt (the beginning of) second 0,\n- Data server 1 sends its message (denoted 1A) to the master server.\n- Data server 2 sends its message (denoted 2A) to the master server.\n\nAt second 1,\n- Message 1A arrives at the master server. Master server processes message 1A instantly and sends a reply 1A back.\n- Server 1 has not received any reply. 1 second (1 < patience[1] = 2) elapsed since this server has sent the message, therefore it does not resend the message.\n- Server 2 has not received any reply. 1 second (1 == patience[2] = 1) elapsed since this server has sent the message, therefore it resends the message (denoted 2B).\n\nAt second 2,\n- The reply 1A arrives at server 1. No more resending will occur from server 1.\n- Message 2A arrives at the master server. Master server processes message 2A instantly and sends a reply 2A back.\n- Server 2 resends the message (denoted 2C).\n...\nAt second 4,\n- The reply 2A arrives at server 2. No more resending will occur from server 2.\n...\nAt second 7, reply 2D arrives at server 2.\n\nStarting from the beginning of the second 8, there are no messages passing between servers or arriving at servers.\nThis is the time when the network becomes idle.\n\nExample 2:\n\nInput: edges = [[0,1],[0,2],[1,2]], patience = [0,10,10]\nOutput: 3\nExplanation: Data servers 1 and 2 receive a reply back at the beginning of second 2.\nFrom the beginning of the second 3, the network becomes idle.\n\nConstraints:\n\n- n == patience.length\n- 2 <= n <= 10^5\n- patience[0] == 0\n- 1 <= patience[i] <= 10^5 for 1 <= i < n\n- 1 <= edges.length <= min(10^5, n * (n - 1) / 2)\n- edges[i].length == 2\n- 0 <= u_i, v_i < n\n- u_i != v_i\n- There are no duplicate edges.\n- Each server can directly or indirectly reach another server.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [[0, 1], [1, 2]],patience = [0, 2, 1]) == 8\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]],patience = [0, 5, 5, 5]) == 3\n assert candidate(edges = [[0, 1], [1, 3], [3, 4], [2, 4]],patience = [0, 1, 2, 3, 4]) == 15\n assert candidate(edges = [[0, 1], [1, 2], [2, 0]],patience = [0, 2, 1]) == 4\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4]],patience = [0, 1, 2, 3, 4]) == 13\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],patience = [0, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],patience = [0, 5, 4, 3, 2, 1, 6, 7, 8, 9]) == 28\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4]],patience = [0, 5, 2, 3, 1]) == 16\n assert candidate(edges = [[0, 1], [0, 2], [1, 2]],patience = [0, 10, 10]) == 3\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],patience = [0, 1, 2, 3, 4, 5, 6]) == 8\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],patience = [0, 1, 1, 5, 2, 3, 6]) == 8\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],patience = [0, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]],patience = [0, 4, 3, 2, 1, 5]) == 4\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 0], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [12, 14]],patience = [0, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15]) == 13\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(edges = [[0, 1], [1, 2], [2, 0], [0, 3], [3, 4], [4, 5], [5, 0], [0, 6], [6, 7], [7, 8], [8, 9], [9, 0]],patience = [0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 5\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10]],patience = [0, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 9\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 5, 7, 3, 2, 1, 6, 4, 8, 9, 11]) == 11\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 23\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]],patience = [0, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 9\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 58\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 7\n assert candidate(edges = [[0, 1], [1, 2], [0, 3], [3, 4], [2, 4], [4, 5], [5, 6]],patience = [0, 2, 1, 3, 4, 5, 6]) == 15\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0]],patience = [0, 100, 90, 80, 70, 60, 50, 40, 30]) == 9\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],patience = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26]],patience = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 16\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0], [0, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 0]],patience = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 11\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],patience = [0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == 12\n assert candidate(edges = [[0, 1], [0, 3], [1, 2], [1, 4], [2, 5], [2, 7], [3, 6], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 20]],patience = [0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == 9\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],patience = [0, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 5\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 7\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]],patience = [0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12]) == 27\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 7\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 20], [19, 21], [20, 22], [11, 23], [12, 24], [13, 25], [14, 26], [15, 27], [16, 28], [17, 29], [29, 30], [28, 31], [27, 32], [26, 33], [25, 34], [24, 35], [23, 36]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]) == 13\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [7, 22], [8, 23], [8, 24], [8, 25]],patience = [0, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == 7\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],patience = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900]) == 29\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20]],patience = [0, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 12\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]],patience = [0, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 3\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],patience = [0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11]) == 12\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12]],patience = [0, 7, 7, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2]) == 7\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 9\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 15, 10, 20, 5, 12, 8, 6, 4, 7, 3]) == 11\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 0]],patience = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58]) == 31\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 6], [1, 7], [2, 8], [2, 9], [3, 10], [3, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [8, 21], [9, 22], [9, 23], [10, 24], [10, 25], [11, 26], [11, 27], [12, 28], [12, 29], [13, 30], [13, 31], [14, 32], [14, 33], [15, 34], [15, 35]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 7\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 5, 5, 3, 3, 1, 1, 4, 4, 2, 2]) == 11\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]],patience = [0, 3, 2, 1, 6, 5, 4, 7, 8, 9, 12, 11, 10, 15, 14, 13, 18, 17, 16, 19, 20, 21, 24, 23, 22, 27, 26, 25, 28, 29, 30, 31, 32, 33, 34, 35]) == 9\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39]],patience = [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 119\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 5], [5, 6], [6, 0], [0, 7], [7, 8], [8, 9], [9, 0]],patience = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],patience = [0, 2, 5, 3, 4, 7, 8, 6, 1, 9, 10]) == 12\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]],patience = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 116\n", "comparison": "exact"}, "public_tests": ["[[0,1],[1,2]]\n[0,2,1]", "[[0,1],[0,2],[1,2]]\n[0,10,10]"], "hints": ["What method can you use to find the shortest time taken for a message from a data server to reach the master server? How can you use this value and the server's patience value to determine the time at which the server sends its last message?", "What is the time when the last message sent from a server gets back to the server?", "For each data server, by the time the server receives the first returned messages, how many messages has the server sent?"], "metadata": {"canonical_parameter_names": ["edges", "patience"], "leetcode_dataset_entry_point": "Solution().networkBecomesIdle", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:05+00:00", "tests_total": 51, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "breadth-first-search", "graph"]}, "language": "python", "interface": {"raw_signature": "def networkBecomesIdle(self, edges: list[list[int]], patience: list[int]) -> int:", "container": "Solution", "callable": "networkBecomesIdle", "parameters": [{"name": "edges", "type": "list[list[int]]"}, {"name": "patience", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2040, "task_id": "kth-smallest-product-of-two-sorted-arrays", "difficulty": "Hard", "problem_description": "Given two sorted 0-indexed integer arrays nums1 and nums2 as well as an integer k, return the k^th (1-based) smallest product of nums1[i] * nums2[j] where 0 <= i < nums1.length and 0 <= j < nums2.length.\n\nExample 1:\n\nInput: nums1 = [2,5], nums2 = [3,4], k = 2\nOutput: 8\nExplanation: The 2 smallest products are:\n- nums1[0] * nums2[0] = 2 * 3 = 6\n- nums1[0] * nums2[1] = 2 * 4 = 8\nThe 2^nd smallest product is 8.\n\nExample 2:\n\nInput: nums1 = [-4,-2,0,3], nums2 = [2,4], k = 6\nOutput: 0\nExplanation: The 6 smallest products are:\n- nums1[0] * nums2[1] = (-4) * 4 = -16\n- nums1[0] * nums2[0] = (-4) * 2 = -8\n- nums1[1] * nums2[1] = (-2) * 4 = -8\n- nums1[1] * nums2[0] = (-2) * 2 = -4\n- nums1[2] * nums2[0] = 0 * 2 = 0\n- nums1[2] * nums2[1] = 0 * 4 = 0\nThe 6^th smallest product is 0.\n\nExample 3:\n\nInput: nums1 = [-2,-1,0,1,2], nums2 = [-3,-1,2,4,5], k = 3\nOutput: -6\nExplanation: The 3 smallest products are:\n- nums1[0] * nums2[4] = (-2) * 5 = -10\n- nums1[0] * nums2[3] = (-2) * 4 = -8\n- nums1[4] * nums2[0] = 2 * (-3) = -6\nThe 3^rd smallest product is -6.\n\nConstraints:\n\n- 1 <= nums1.length, nums2.length <= 5 * 10^4\n- -10^5 <= nums1[i], nums2[j] <= 10^5\n- 1 <= k <= nums1.length * nums2.length\n- nums1 and nums2 are sorted.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [-100000, 100000],nums2 = [-100000, 100000],k = 1) == -10000000000\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1],k = 4) == 0\n assert candidate(nums1 = [-100000, -50000, 0, 50000, 100000],nums2 = [-100000, -50000, 0, 50000, 100000],k = 12) == 0\n assert candidate(nums1 = [-10, -9, -8, -7, -6],nums2 = [-5, -4, -3, -2, -1],k = 1) == 6\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],k = 25) == 90\n assert candidate(nums1 = [2, 5],nums2 = [3, 4],k = 2) == 8\n assert candidate(nums1 = [-4, -2, 0, 3],nums2 = [2, 4],k = 6) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5],k = 10) == 5\n assert candidate(nums1 = [-100000, 100000],nums2 = [-100000, 100000],k = 2) == -10000000000\n assert candidate(nums1 = [-5, -3, -1, 1, 3, 5],nums2 = [-5, -3, -1, 1, 3, 5],k = 18) == -1\n assert candidate(nums1 = [-2, -1, 0, 1, 2],nums2 = [-3, -1, 2, 4, 5],k = 3) == -6\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5],k = 25) == 25\n assert candidate(nums1 = [-10, -5, -1],nums2 = [1, 5, 10],k = 5) == -10\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6],k = 5) == 10\n assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0],k = 5) == 0\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0],k = 12) == 0\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [-5, -4, -3, -2, -1],k = 12) == 6\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-10000, 0, 10000],k = 7) == 0\n assert candidate(nums1 = [-25, -15, -5, 5, 15, 25],nums2 = [-25, -15, -5, 0, 5, 15, 25],k = 30) == 75\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],k = 25) == 1\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-10000, -5000, 0, 5000, 10000],k = 7) == -125000000\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [-1, -1, -1, -1, -1],k = 25) == -1\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 50) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],k = 20) == 50\n assert candidate(nums1 = [-9, -3, 0, 1, 5],nums2 = [-6, -2, 1, 4, 7],k = 9) == -3\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-100, -50, 0, 50, 100],k = 10) == 0\n assert candidate(nums1 = [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5],nums2 = [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5],k = 49) == -2\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],k = 24) == 72\n assert candidate(nums1 = [-100, -50, 0, 50, 100],nums2 = [-200, -100, 0, 100, 200],k = 10) == 0\n assert candidate(nums1 = [-10, -5, -1, 0, 1, 5, 10],nums2 = [-20, -15, -10, -5, 0, 5, 10, 15, 20],k = 20) == -15\n assert candidate(nums1 = [-50, -25, 0, 25, 50],nums2 = [-50, -25, 0, 25, 50],k = 12) == 0\n assert candidate(nums1 = [100000],nums2 = [-100000, 0, 100000],k = 2) == 0\n assert candidate(nums1 = [-100000, 100000],nums2 = [-1, 1],k = 1) == -100000\n assert candidate(nums1 = [-1000, -900, -800],nums2 = [800, 900, 1000],k = 8) == -720000\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [-9, -7, -5, -3, -1],k = 15) == -15\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 15) == 0\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 13) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 45) == 20\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 2, 3, 4, 5],k = 20) == 1500\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000],nums2 = [-10000, -20000, -30000, -40000, -50000],k = 12) == -900000000\n assert candidate(nums1 = [-2, -1, 0, 1, 2],nums2 = [-2, -1, 0, 1, 2, 3, 4, 5],k = 15) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [2, 4, 6, 8, 10, 12],k = 36) == 132\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-5, -10, -15, -20, -25],k = 10) == -600\n assert candidate(nums1 = [-1000, -500, -100, 0, 100, 500, 1000],nums2 = [-1000, -500, -100, 0, 100, 500, 1000],k = 48) == 1000000\n assert candidate(nums1 = [-2, 0, 2],nums2 = [-2, 0, 2],k = 3) == 0\n assert candidate(nums1 = [-1, -1, 0, 1, 1],nums2 = [-1, -1, 0, 1, 1],k = 12) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 100) == 380\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1],k = 3) == 0\n assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000],nums2 = [-1, -2, -3, -4, -5],k = 15) == -90000\n assert candidate(nums1 = [-10000, -5000, -1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000, 5000, 10000],nums2 = [-10000, -5000, -1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000, 5000, 10000],k = 361) == 100000000\n assert candidate(nums1 = [-1, 1],nums2 = [-100000, 100000],k = 1) == -100000\n assert candidate(nums1 = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 324) == 40\n assert candidate(nums1 = [-1, -1, -1, -1, -1],nums2 = [-1, -1, -1, -1, -1],k = 1) == 1\n assert candidate(nums1 = [-3, -2, -1, 0, 1, 2, 3],nums2 = [-3, -2, -1, 0, 1, 2, 3],k = 21) == 0\n assert candidate(nums1 = [-1, -1, -1, -1, -1],nums2 = [-1, -1, -1, -1, -1],k = 20) == 1\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-100000, -10000, -1000, -100, -10, -1, 0, 1, 10, 100, 1000, 10000, 100000],k = 13) == 0\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1],k = 5) == 0\n assert candidate(nums1 = [-5, -3, -1, 1, 3, 5],nums2 = [-5, -3, -1, 1, 3, 5],k = 15) == -3\n assert candidate(nums1 = [-9, -7, -5, -3, -1],nums2 = [-9, -7, -5, -3, -1],k = 24) == 63\n assert candidate(nums1 = [-1, -1, -1, -1],nums2 = [-1, -1, -1, -1],k = 10) == 1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 240\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1],k = 4) == 0\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums1 = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 100) == -15\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-2, -1, 0, 1, 2],k = 8) == -5\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 10) == 0\n assert candidate(nums1 = [-1, -1, -1, -1],nums2 = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 5) == 1\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],k = 12) == 20\n assert candidate(nums1 = [-1000, -900, -800, -700, -600],nums2 = [-1000, -900, -800, -700, -600],k = 20) == 800000\n assert candidate(nums1 = [-100, -50, 0, 50, 100],nums2 = [-100, -50, 0, 50, 100],k = 12) == 0\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 12) == 0\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-100000, -50000, -10000, -5000, -1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000],k = 50) == 5\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 25) == 100\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-100, 0, 100],k = 4) == 0\n assert candidate(nums1 = [-5, -3, -1, 0, 1, 3, 5],nums2 = [-6, -4, -2, 0, 2, 4, 6],k = 15) == -4\n assert candidate(nums1 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 441) == 100\n assert candidate(nums1 = [-5, -3, -1, 1, 3, 5],nums2 = [-6, -4, -2, 0, 2, 4, 6],k = 15) == -4\n assert candidate(nums1 = [-9, -7, -5, -3, -1],nums2 = [1, 3, 5, 7, 9],k = 10) == -27\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [-5, -4, -3, -2, -1],k = 25) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 24\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 45) == -36\n assert candidate(nums1 = [-3, -2, -1, 0, 1, 2, 3],nums2 = [-3, -2, -1, 0, 1, 2, 3],k = 20) == 0\n assert candidate(nums1 = [-1, -1, -1, -1, 1, 1, 1, 1],nums2 = [-1, -1, -1, -1, 1, 1, 1, 1],k = 32) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [-9, -7, -5, -3, -1],k = 25) == -1\n assert candidate(nums1 = [-50000, -40000, -30000, 0, 30000, 40000, 50000],nums2 = [-50000, 0, 50000],k = 20) == 2500000000\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [-5, -4, -3, -2, -1],k = 15) == -6\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 20) == 50\n assert candidate(nums1 = [-1, 1, -1, 1, -1],nums2 = [-1, 1, -1, 1, -1],k = 10) == -1\n assert candidate(nums1 = [-9, -6, -3, 0, 3, 6, 9],nums2 = [-9, -6, -3, 0, 3, 6, 9],k = 49) == 81\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-20, -15, -10, -5, 0, 5, 10, 15, 20],k = 30) == 25\n assert candidate(nums1 = [-100, -50, -25, -10, -5, -1, 0, 1, 5, 10, 25, 50, 100],nums2 = [-100, -50, -25, -10, -5, -1, 0, 1, 5, 10, 25, 50, 100],k = 100) == 5\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5],k = 25) == -1\n", "comparison": "exact"}, "public_tests": ["[2,5]\n[3,4]\n2", "[-4,-2,0,3]\n[2,4]\n6", "[-2,-1,0,1,2]\n[-3,-1,2,4,5]\n3"], "hints": ["Can we split this problem into four cases depending on the sign of the numbers?", "Can we binary search the value?"], "metadata": {"canonical_parameter_names": ["nums1", "nums2", "k"], "leetcode_dataset_entry_point": "Solution().kthSmallestProduct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:07+00:00", "tests_total": 108, "tests_dropped": 15, "flags": [], "topic_tags": ["array", "binary-search"]}, "language": "python", "interface": {"raw_signature": "def kthSmallestProduct(self, nums1: list[int], nums2: list[int], k: int) -> int:", "container": "Solution", "callable": "kthSmallestProduct", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2042, "task_id": "check-if-numbers-are-ascending-in-a-sentence", "difficulty": "Easy", "problem_description": "A sentence is a list of tokens separated by a single space with no leading or trailing spaces. Every token is either a positive number consisting of digits 0-9 with no leading zeros, or a word consisting of lowercase English letters.\n\n- For example, \"a puppy has 2 eyes 4 legs\" is a sentence with seven tokens: \"2\" and \"4\" are numbers and the other tokens such as \"puppy\" are words.\n\nGiven a string s representing a sentence, you need to check if all the numbers in s are strictly increasing from left to right (i.e., other than the last number, each number is strictly smaller than the number on its right in s).\n\nReturn true if so, or false otherwise.\n\nExample 1:\n\nInput: s = \"1 box has 3 blue 4 red 6 green and 12 yellow marbles\"\nOutput: true\nExplanation: The numbers in s are: 1, 3, 4, 6, 12.\nThey are strictly increasing from left to right: 1 < 3 < 4 < 6 < 12.\n\nExample 2:\n\nInput: s = \"hello world 5 x 5\"\nOutput: false\nExplanation: The numbers in s are: 5, 5. They are not strictly increasing.\n\nExample 3:\n\nInput: s = \"sunset is at 7 51 pm overnight lows will be in the low 50 and 60 s\"\nOutput: false\nExplanation: The numbers in s are: 7, 51, 50, 60. They are not strictly increasing.\n\nConstraints:\n\n- 3 <= s.length <= 200\n- s consists of lowercase English letters, spaces, and digits from 0 to 9, inclusive.\n- The number of tokens in s is between 2 and 100, inclusive.\n- The tokens in s are separated by a single space.\n- There are at least two numbers in s.\n- Each number in s is a positive number less than 100, with no leading zeros.\n- s contains no leading or trailing spaces.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"start 99 end 100\") == True\n assert candidate(s = \"1 apple 2 banana 3 cherry 4 date\") == True\n assert candidate(s = \"100 99 98 97 96\") == False\n assert candidate(s = \"5 15 25 35 45 55\") == True\n assert candidate(s = \"there are 10 cars 20 bikes and 30 trucks\") == True\n assert candidate(s = \"the times 10 20 30 40 50 are correct\") == True\n assert candidate(s = \"5 6 7 8 9 10 11\") == True\n assert candidate(s = \"the quick brown fox jumps over 1 lazy 2 dogs\") == True\n assert candidate(s = \"10 20 30 40 50\") == True\n assert candidate(s = \"start 1 end 2\") == True\n assert candidate(s = \"5 6 7 8 7\") == False\n assert candidate(s = \"but 100 99 98 are not\") == False\n assert candidate(s = \"100 99 98 97 96 95 94 93 92 91 90\") == False\n assert candidate(s = \"9 10 11 12 13\") == True\n assert candidate(s = \"i have 1 cat 2 dogs and 3 fish\") == True\n assert candidate(s = \"the temperature rose from 23 to 28 degrees\") == True\n assert candidate(s = \"hello world 5 x 5\") == False\n assert candidate(s = \"start 1 end 1\") == False\n assert candidate(s = \"the temperature is 23 degrees and will rise to 28 by afternoon\") == True\n assert candidate(s = \"he has 3 cats and 7 dogs\") == True\n assert candidate(s = \"the temperature is 23 degrees and rising to 28\") == True\n assert candidate(s = \"1 2 3 4 5 6 7 8 9\") == True\n assert candidate(s = \"2 apple 3 4 banana 5 6\") == True\n assert candidate(s = \"i have 1 apple 2 oranges and 3 bananas\") == True\n assert candidate(s = \"i saw 1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"i have 1 cat 2 dogs and 3 hamsters\") == True\n assert candidate(s = \"sunset is at 7 51 pm overnight lows will be in the low 50 and 60 s\") == False\n assert candidate(s = \"9 10 11\") == True\n assert candidate(s = \"1 2 3 apple 4 5\") == True\n assert candidate(s = \"9 8 7 6 5 4 3 2 1\") == False\n assert candidate(s = \"0 is not a valid number 1 is\") == False\n assert candidate(s = \"3 14 15 9 26 53 59\") == False\n assert candidate(s = \"3 5 7 9 11 13 15\") == True\n assert candidate(s = \"the temperature is 23 degrees and will rise to 30\") == True\n assert candidate(s = \"5 6 7 8 9 10\") == True\n assert candidate(s = \"100 99\") == False\n assert candidate(s = \"100 101 102\") == True\n assert candidate(s = \"10 20 30 25 40\") == False\n assert candidate(s = \"1 box has 3 blue 4 red 6 green and 12 yellow marbles\") == True\n assert candidate(s = \"one two 3 four 5 six 7\") == True\n assert candidate(s = \"she sold 12 eggs for 24 dollars\") == True\n assert candidate(s = \"we started with 50 employees and now we have 75\") == True\n assert candidate(s = \"the quick brown fox jumps over 13 lazy dogs and 14 sleeping cats\") == True\n assert candidate(s = \"there are 100 ants 110 bees and 120 wasps\") == True\n assert candidate(s = \"the measurements are 10 20 30 40 50 60 70\") == True\n assert candidate(s = \"1 car 2 trucks 3 motorcycles 4 bicycles\") == True\n assert candidate(s = \"she ate 2 apples and then 3 apples later\") == True\n assert candidate(s = \"123 124 125 126 127 128 129\") == True\n assert candidate(s = \"she turned 21 years old in 2022 and will turn 22 in 2023\") == False\n assert candidate(s = \"the heights are 30 45 60 75 90\") == True\n assert candidate(s = \"the sequence of numbers is 1 2 4 8 16 32 and 64\") == True\n assert candidate(s = \"he scored 50 60 75 80 and 90 in exams\") == True\n assert candidate(s = \"repeating numbers 1 1 2 2 3 3\") == False\n assert candidate(s = \"the journey took 3 hours and 4 hours on different days\") == True\n assert candidate(s = \"in the year 2001 we had 1 event in 2003 we had 4 events in 2005 we had 6 events\") == False\n assert candidate(s = \"lets count 1 2 3 4 5 6 7 8 9 10 and check if they are increasing\") == True\n assert candidate(s = \"the sequence is 1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"the temperature decreased from 30 degrees to 25 degrees then to 20 degrees\") == False\n assert candidate(s = \"3 little pigs 10 11 12 13 14 15\") == True\n assert candidate(s = \"1 one 2 two 3 three 4 four 5 five 6 six 7 seven\") == True\n assert candidate(s = \"in the year 1990 1995 there were 2000 2005 cars\") == True\n assert candidate(s = \"the sequence 1 3 5 7 9 is strictly increasing\") == True\n assert candidate(s = \"12 monkeys and 13 apes and 14 elephants\") == True\n assert candidate(s = \"the areas are 1 4 9 16 25 36 and 49\") == True\n assert candidate(s = \"a1 b2 c3 6 7 8 9 10\") == True\n assert candidate(s = \"1000 apples 2000 bananas 3000 cherries 4000 dates\") == True\n assert candidate(s = \"the book had 5 chapters and the next book had 8 chapters\") == True\n assert candidate(s = \"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25\") == True\n assert candidate(s = \"a1 b2 c3 4 d5 e6 f7 g8 h9 i10\") == True\n assert candidate(s = \"we have 100 books 200 magazines and 300 newspapers\") == True\n assert candidate(s = \"42 is the answer to life 43 the universe and 44 everything\") == True\n assert candidate(s = \"he received 10 calls in the morning and 15 in the afternoon\") == True\n assert candidate(s = \"the temperature rose from 20 degrees to 22 and then to 25\") == True\n assert candidate(s = \"one 2 three 4 five 6 seven 8 nine 10\") == True\n assert candidate(s = \"12 monkeys and 13 gorillas but only 7 chimpanzees\") == False\n assert candidate(s = \"the temperature was 10 degrees at 1 oclock and 12 degrees at 2 oclock and 15 degrees at 3 oclock\") == False\n assert candidate(s = \"the temperature rose from 20 to 22 then to 25\") == True\n assert candidate(s = \"the times are 12 24 36 48 and 60\") == True\n assert candidate(s = \"the weights are 1 2 3 5 8 13 and 21\") == True\n assert candidate(s = \"she baked 5 cakes 10 muffins and 15 brownies\") == True\n assert candidate(s = \"the steps are 100 200 300 400 500\") == True\n assert candidate(s = \"there are 100 ants 200 bees 300 flies and 400 spiders\") == True\n assert candidate(s = \"the number 10 comes before 20 and 30\") == True\n assert candidate(s = \"the sales increased from 100 units to 150 units last quarter\") == True\n assert candidate(s = \"the numbers 1 2 3 4 5 6 7 8 9 10 are in ascending order\") == True\n assert candidate(s = \"the increments are 1 2 3 4 5 6 7 8\") == True\n assert candidate(s = \"alpha 1 beta 2 gamma 3 delta 4 epsilon 5 zeta 6 eta 7 theta 8 iota 9 kappa 10 lambda 11 mu 12 nu 13 xi 14 omicron 15 pi 16 rho 17 sigma 18 tau 19 upsilon 20 phi 21 chi 22 psi 23 omega 24\") == True\n assert candidate(s = \"the sequence of numbers is 1 3 6 10 15 21 and 28\") == True\n assert candidate(s = \"in the year 1800 there were 1801 people in this town 1802\") == True\n assert candidate(s = \"20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39\") == True\n assert candidate(s = \"she baked 5 cakes 10 pies and 15 tarts\") == True\n assert candidate(s = \"the positions are 10 20 30 40 50 60 and 70\") == True\n assert candidate(s = \"58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77\") == True\n assert candidate(s = \"the volumes are 10 100 1000 10000 and 100000\") == True\n assert candidate(s = \"the temperature rose from 10 to 20 then to 30 degrees\") == True\n assert candidate(s = \"in the year 2000 we had 100 participants and in 2005 we had 150 participants\") == False\n assert candidate(s = \"the project took 1 month and then 2 months to complete\") == True\n assert candidate(s = \"the sequence 1 3 5 7 9 11 13 15 17 19 is strictly increasing\") == True\n assert candidate(s = \"the numbers are 1 2 3 but then 2 again\") == False\n assert candidate(s = \"a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20\") == True\n assert candidate(s = \"increasing by one 1 2 3 4 5 6 7 8 9\") == True\n assert candidate(s = \"the temperature today is 30 degrees 31 tomorrow 32 the day after\") == True\n assert candidate(s = \"the sequence is 1 3 5 7 9 11 13\") == True\n assert candidate(s = \"the garden has 1 tulip 3 roses 5 daisies 7 sunflowers\") == True\n assert candidate(s = \"we planted 50 trees 100 bushes and 200 flowers\") == True\n assert candidate(s = \"in 1999 there were 2000 cars and in 2001 there were 2002 cars\") == True\n assert candidate(s = \"we collected 15 apples 20 oranges and 25 bananas\") == True\n assert candidate(s = \"one 1 two 2 three 3 four 4 five 5 six 6 seven 7 eight 8 nine 9 ten 10 eleven 11\") == True\n assert candidate(s = \"3 cats 5 dogs 7 birds 9 fish\") == True\n assert candidate(s = \"99 98 97 96 95 94 93 92 91 90\") == False\n assert candidate(s = \"she sold 1 apple 2 oranges 3 bananas 4 grapes 5 watermelons 6 pineapples\") == True\n assert candidate(s = \"the speed increased from 20 kmph to 30 kmph and then to 40 kmph\") == True\n assert candidate(s = \"the distances are 1000 2000 3000 4000 and 5000\") == True\n assert candidate(s = \"we climbed 100 meters then 200 meters and finally 300 meters\") == True\n assert candidate(s = \"the time is 12 13 14 15 16 17 18 19 20 21 22 23\") == True\n assert candidate(s = \"there were 5 kids 6 teenagers 7 adults in the room\") == True\n assert candidate(s = \"the company grew from 1000 employees to 1500 employees last year\") == True\n assert candidate(s = \"he won 1 race and then 2 races in a row\") == True\n assert candidate(s = \"the first year 1990 was followed by 1991 and then 1992\") == True\n assert candidate(s = \"1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10\") == False\n assert candidate(s = \"the sequence 10 20 30 40 50 60 70 80 90 100 is ascending\") == True\n assert candidate(s = \"in the year 2020 2021 2022 and 2023\") == True\n assert candidate(s = \"the ages are 5 10 15 20 25 30\") == True\n assert candidate(s = \"the numbers 10 20 30 40 50 are increasing\") == True\n assert candidate(s = \"in the sequence 2 4 6 8 10 12 14 16 18 20 all numbers are in increasing order\") == True\n assert candidate(s = \"there are 2 cars 4 trucks and 6 motorcycles\") == True\n assert candidate(s = \"random 5 10 20 15 25 30 29 35 40 45\") == False\n assert candidate(s = \"20 apples and 25 oranges but only 15 bananas\") == False\n assert candidate(s = \"a quick brown fox jumps over 1 lazy dog then 2 sleepy dogs\") == True\n assert candidate(s = \"the ages are 25 30 35 40 45 50 55\") == True\n assert candidate(s = \"she sold sea shells by the sea shore 1 2 3 4 5 6 7 8 9 10 11 12\") == True\n assert candidate(s = \"39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58\") == True\n assert candidate(s = \"there are 100 bottles of beer on the wall 101 102 103\") == True\n assert candidate(s = \"in the year 2020 we had 21 cars 23 trucks and 25 buses\") == False\n assert candidate(s = \"compare these numbers 10 20 30 40 50 60 70 80 90 100\") == True\n assert candidate(s = \"decreasing numbers 5 4 3 2 1\") == False\n assert candidate(s = \"there are 30 apples 40 oranges 50 bananas 60 grapes 70 strawberries 80 blueberries\") == True\n assert candidate(s = \"the temperature rose from 20 to 25 to 30 degrees\") == True\n assert candidate(s = \"random order 1 3 2 4 5\") == False\n assert candidate(s = \"a1 b2 c3 d4 e5 f6 g7 h8 i9 j10 11 12 13 14 15 16 17 18 19 20\") == True\n assert candidate(s = \"the chapters are numbered 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\") == True\n assert candidate(s = \"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20\") == True\n assert candidate(s = \"the ages are 5 10 15 20 25 30 35 40\") == True\n assert candidate(s = \"the quick brown fox jumps over 1 lazy dog 2\") == True\n assert candidate(s = \"she played 1 game 2 matches 3 tournaments\") == True\n assert candidate(s = \"we counted 1 bird 2 cats 3 dogs 4 elephants 5 foxes 6 giraffes 7 hippos\") == True\n assert candidate(s = \"she saw 5 stars 10 planets and 15 galaxies\") == True\n assert candidate(s = \"23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43\") == True\n assert candidate(s = \"even numbers 2 4 6 8 10 12 14 16 18 20\") == True\n assert candidate(s = \"strictly increasing 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\") == True\n assert candidate(s = \"in a race 10 runners came first 20 second and 30 third\") == True\n assert candidate(s = \"the clock struck 1 pm 2 pm 3 pm 4 pm\") == True\n assert candidate(s = \"the sequence of numbers is 3 9 27 81 and 243\") == True\n assert candidate(s = \"mixed numbers 1 20 2 30 3\") == False\n assert candidate(s = \"in the year 2000 2001 2002 the world changed\") == True\n assert candidate(s = \"a sequence of 1 2 3 4 5 6 7 8 9 10 numbers\") == True\n assert candidate(s = \"a sequence of numbers like 10 20 30 40 50 should be increasing\") == True\n assert candidate(s = \"the values are 2 4 8 16 32\") == True\n assert candidate(s = \"42 cats 43 dogs 44 elephants 45 flamingos\") == True\n assert candidate(s = \"77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96\") == True\n assert candidate(s = \"abc 1 def 2 ghi 3 jkl 4 mno 5 pqr 6 stu 7 vwx 8 yz 9 10\") == True\n assert candidate(s = \"nested numbers like 10 in 11 the 12 and 13 final\") == True\n assert candidate(s = \"99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115\") == True\n assert candidate(s = \"99 100 101 102 103 104 105 106\") == True\n assert candidate(s = \"96 97 98 99 100 101 102 103 104 105 106 107 108 109 110\") == True\n assert candidate(s = \"the children are 1 year old 2 years old 3 years old 4 years old\") == True\n assert candidate(s = \"100 apples 101 oranges 102 bananas\") == True\n assert candidate(s = \"my password is 123 and my pin is 124 and my secret number is 125\") == True\n assert candidate(s = \"the team scored 2 goals in the first half and 3 goals in the second half\") == True\n assert candidate(s = \"the prices are 5 10 15 20 25\") == True\n assert candidate(s = \"decreasing numbers 20 19 18 17 16 15 14 13 12 11 10\") == False\n assert candidate(s = \"the sequence is 1 4 9 16 25 and 36\") == True\n assert candidate(s = \"there are 3 cats 5 dogs and 7 birds in the zoo\") == True\n assert candidate(s = \"the quick brown fox jumps over the lazy dog 1 2 3 4 5\") == True\n assert candidate(s = \"he collected 2 seashells by the sea 4 on the beach and 6 in the sand\") == True\n assert candidate(s = \"1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"a quick brown fox jumps over the lazy dog 1 2 3 4 5\") == True\n assert candidate(s = \"there are 100 apples 101 oranges and 102 bananas\") == True\n assert candidate(s = \"the levels are 10 20 30 40 50 60 70 80 90\") == True\n assert candidate(s = \"007 is not a valid number but 7 8 9 are valid numbers\") == False\n assert candidate(s = \"two digit numbers 10 20 30 40 50\") == True\n assert candidate(s = \"the quick brown fox jumps over the lazy dog 1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"99 100 99 101 102 103 104 105 106 107 108 109 110 111 112 113 114\") == False\n assert candidate(s = \"a series of 1 3 5 7 9 11 13 15 17 19 odd numbers\") == True\n assert candidate(s = \"we have 10 apples 20 oranges 30 bananas and 30 grapes\") == False\n assert candidate(s = \"the number sequence is 1 2 3 4 5 6 7 8 9\") == True\n assert candidate(s = \"he ran 1 mile in 5 minutes then 2 miles in 10 minutes\") == False\n assert candidate(s = \"99 bottles of beer on the wall 98 bottles of beer\") == False\n assert candidate(s = \"the heights are 100 200 300 400 and 500\") == True\n assert candidate(s = \"the numbers 5 10 15 20 25 30 35 40 45 50 are increasing\") == True\n assert candidate(s = \"30 apples 40 oranges 50 bananas 60 grapes\") == True\n assert candidate(s = \"a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10\") == True\n assert candidate(s = \"21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40\") == True\n assert candidate(s = \"the counts are 1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"the first 2 books have 3 chapters each and the 5 next books have 6 chapters each\") == True\n assert candidate(s = \"1234 5678 91011 121314\") == True\n assert candidate(s = \"the temperature rose from 5 degrees to 10 degrees then to 15 degrees\") == True\n assert candidate(s = \"single digit numbers 1 2 3 4 5\") == True\n assert candidate(s = \"a quick brown fox jumps over 1 3 5 lazy dogs\") == True\n assert candidate(s = \"she has 10 red balloons 20 blue ones and 30 green ones\") == True\n assert candidate(s = \"a 1 digit number 10 two digit numbers 100 three digit numbers\") == True\n assert candidate(s = \"in the series 2 4 6 8 10 the numbers are strictly increasing\") == True\n assert candidate(s = \"we planted 1 tree 2 bushes 3 flowers 4 vines and 5 cacti\") == True\n assert candidate(s = \"the sequence is 1 1 2 3 5 8 and 13\") == False\n", "comparison": "exact"}, "public_tests": ["\"1 box has 3 blue 4 red 6 green and 12 yellow marbles\"", "\"hello world 5 x 5\"", "\"sunset is at 7 51 pm overnight lows will be in the low 50 and 60 s\""], "hints": ["Use string tokenization of your language to extract all the tokens of the string easily.", "For each token extracted, how can you tell if it is a number? Does the first letter being a digit mean something?", "Compare the number with the previously occurring number to check if ascending order is maintained."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().areNumbersAscending", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:09+00:00", "tests_total": 204, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def areNumbersAscending(self, s: str) -> bool:", "container": "Solution", "callable": "areNumbersAscending", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2044, "task_id": "count-number-of-maximum-bitwise-or-subsets", "difficulty": "Medium", "problem_description": "Given an integer array nums, find the maximum possible bitwise OR of a subset of nums and return the number of different non-empty subsets with the maximum bitwise OR.\n\nAn array a is a subset of an array b if a can be obtained from b by deleting some (possibly zero) elements of b. Two subsets are considered different if the indices of the elements chosen are different.\n\nThe bitwise OR of an array a is equal to a[0] OR a[1] OR ... OR a[a.length - 1] (0-indexed).\n\nExample 1:\n\nInput: nums = [3,1]\nOutput: 2\nExplanation: The maximum possible bitwise OR of a subset is 3. There are 2 subsets with a bitwise OR of 3:\n- [3]\n- [3,1]\n\nExample 2:\n\nInput: nums = [2,2,2]\nOutput: 7\nExplanation: All non-empty subsets of [2,2,2] have a bitwise OR of 2. There are 2^3 - 1 = 7 total subsets.\n\nExample 3:\n\nInput: nums = [3,2,1,5]\nOutput: 6\nExplanation: The maximum possible bitwise OR of a subset is 7. There are 6 subsets with a bitwise OR of 7:\n- [3,5]\n- [3,1,5]\n- [3,2,5]\n- [3,2,1,5]\n- [2,5]\n- [2,1,5]\n\nConstraints:\n\n- 1 <= nums.length <= 16\n- 1 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [15, 15, 15]) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 255\n assert candidate(nums = [3, 2, 1, 5]) == 6\n assert candidate(nums = [6, 2, 1, 3, 4]) == 17\n assert candidate(nums = [6, 2, 1, 5, 4]) == 17\n assert candidate(nums = [5, 1, 1, 2, 5]) == 12\n assert candidate(nums = [1, 3, 5, 7, 9]) == 10\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [2, 2, 2]) == 7\n assert candidate(nums = [1, 3, 7, 15, 31]) == 16\n assert candidate(nums = [15, 15, 15, 15]) == 15\n assert candidate(nums = [1, 2, 4, 8]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50]) == 16\n assert candidate(nums = [5, 5, 5, 5, 5]) == 31\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 65535\n assert candidate(nums = [15, 7, 3, 1]) == 8\n assert candidate(nums = [16, 8, 4, 2, 1]) == 1\n assert candidate(nums = [3, 1]) == 2\n assert candidate(nums = [1, 3, 7, 15]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 255\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 65535\n assert candidate(nums = [10, 20, 30, 40]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 64594\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35]) == 52\n assert candidate(nums = [5, 10, 15, 20, 25, 30]) == 44\n assert candidate(nums = [1, 2, 4, 8, 16, 32]) == 1\n assert candidate(nums = [8, 4, 2, 1, 15, 7, 3]) == 85\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 65535\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3]) == 32768\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 64594\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 859\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 128, 64, 32, 16, 8, 4, 2, 1]) == 6561\n assert candidate(nums = [16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384]) == 65535\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 32767\n assert candidate(nums = [32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 1\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 16203\n assert candidate(nums = [31, 15, 7, 3, 1, 31, 15, 7, 3, 1, 31, 15, 7, 3, 1, 31]) == 61440\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 32297\n assert candidate(nums = [13, 7, 15, 3, 1, 8, 2, 4]) == 205\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 32297\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 64897\n assert candidate(nums = [1, 5, 11, 5, 1, 11, 5, 1, 11, 5, 1, 11, 5, 1]) == 14880\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1023]) == 32768\n assert candidate(nums = [15, 7, 3, 1]) == 8\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 255\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 511\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64]) == 1\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 65535\n assert candidate(nums = [15, 15, 15, 15, 15]) == 31\n assert candidate(nums = [31, 15, 7, 3, 1]) == 16\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 1\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1]) == 128\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 64594\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 32768\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 512\n assert candidate(nums = [31, 28, 29, 30, 31, 30, 29, 28]) == 228\n assert candidate(nums = [17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17]) == 65535\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 171\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1]) == 109\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 65535\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384]) == 21\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]) == 22336\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 255\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64]) == 109\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 257\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 65535\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40]) == 150\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128]) == 1\n assert candidate(nums = [31, 14, 7, 3, 1, 31, 14, 7, 3, 1]) == 768\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255]) == 255\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 62449\n assert candidate(nums = [14, 7, 3, 1, 14, 7, 3, 1]) == 189\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 65535\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562]) == 13\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8]) == 255\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1, 1, 1, 1, 1, 1]) == 32768\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 128, 64, 32, 16, 8, 4, 2, 1]) == 6561\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144]) == 48108\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == 6561\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == 170\n assert candidate(nums = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]) == 65535\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 512\n assert candidate(nums = [32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 16384\n assert candidate(nums = [5, 3, 10, 14, 15, 1, 2, 8, 4, 6, 7, 11, 12, 13, 9]) == 32297\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 48609\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 59421\n assert candidate(nums = [127, 63, 31, 15, 7, 3, 1]) == 64\n assert candidate(nums = [5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40]) == 59922\n assert candidate(nums = [31, 15, 7, 3, 1, 63, 127, 255, 511, 1023, 1, 2, 4, 8, 16, 32]) == 32768\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128]) == 1\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1]) == 128\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32767]) == 32769\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72]) == 109\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]) == 32768\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240]) == 63775\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1]) == 1\n assert candidate(nums = [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14]) == 65535\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 65535\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 32297\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3]) == 12611\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127]) == 64\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64]) == 1\n assert candidate(nums = [7, 3, 2, 1, 6, 5, 4, 8, 10, 9, 11, 12, 13, 14, 15, 16]) == 32297\n assert candidate(nums = [12, 14, 7, 1, 9, 3, 11]) == 102\n", "comparison": "exact"}, "public_tests": ["[3,1]", "[2,2,2]", "[3,2,1,5]"], "hints": ["Can we enumerate all possible subsets?", "The maximum bitwise-OR is the bitwise-OR of the whole array."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countMaxOrSubsets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:12+00:00", "tests_total": 113, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "backtracking", "bit-manipulation", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def countMaxOrSubsets(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countMaxOrSubsets", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2045, "task_id": "second-minimum-time-to-reach-destination", "difficulty": "Hard", "problem_description": "A city is represented as a bi-directional connected graph with n vertices where each vertex is labeled from 1 to n (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [u_i, v_i] denotes a bi-directional edge between vertex u_i and vertex v_i. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself. The time taken to traverse any edge is time minutes.\n\nEach vertex has a traffic signal which changes its color from green to red and vice versa every change minutes. All signals change at the same time. You can enter a vertex at any time, but can leave a vertex only when the signal is green. You cannot wait at a vertex if the signal is green.\n\nThe second minimum value is defined as the smallest value strictly larger than the minimum value.\n\n- For example the second minimum value of [2, 3, 4] is 3, and the second minimum value of [2, 2, 4] is 4.\n\nGiven n, edges, time, and change, return the second minimum time it will take to go from vertex 1 to vertex n.\n\nNotes:\n\n- You can go through any vertex any number of times, including 1 and n.\n- You can assume that when the journey starts, all signals have just turned green.\n\nExample 1:\n\nInput: n = 5, edges = [[1,2],[1,3],[1,4],[3,4],[4,5]], time = 3, change = 5\nOutput: 13\nExplanation:\nThe figure on the left shows the given graph.\nThe blue path in the figure on the right is the minimum time path.\nThe time taken is:\n- Start at 1, time elapsed=0\n- 1 -> 4: 3 minutes, time elapsed=3\n- 4 -> 5: 3 minutes, time elapsed=6\nHence the minimum time needed is 6 minutes.\n\nThe red path shows the path to get the second minimum time.\n- Start at 1, time elapsed=0\n- 1 -> 3: 3 minutes, time elapsed=3\n- 3 -> 4: 3 minutes, time elapsed=6\n- Wait at 4 for 4 minutes, time elapsed=10\n- 4 -> 5: 3 minutes, time elapsed=13\nHence the second minimum time is 13 minutes.\n\nExample 2:\n\nInput: n = 2, edges = [[1,2]], time = 3, change = 2\nOutput: 11\nExplanation:\nThe minimum time path is 1 -> 2 with time = 3 minutes.\nThe second minimum time path is 1 -> 2 -> 1 -> 2 with time = 11 minutes.\n\nConstraints:\n\n- 2 <= n <= 10^4\n- n - 1 <= edges.length <= min(2 * 10^4, n * (n - 1) / 2)\n- edges[i].length == 2\n- 1 <= u_i, v_i <= n\n- u_i != v_i\n- There are no duplicate edges.\n- Each vertex can be reached directly or indirectly from every other vertex.\n- 1 <= time, change <= 10^3\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 2,edges = [[1, 2]],time = 3,change = 2) == 11\n assert candidate(n = 3,edges = [[1, 2], [2, 3]],time = 2,change = 3) == 10\n assert candidate(n = 3,edges = [[1, 2], [2, 3]],time = 5,change = 5) == 35\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 5], [4, 5], [5, 6]],time = 2,change = 4) == 18\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 4], [1, 4]],time = 2,change = 3) == 8\n assert candidate(n = 4,edges = [[1, 2], [1, 3], [3, 4], [2, 4]],time = 2,change = 3) == 10\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6]],time = 4,change = 7) == 32\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [3, 4], [4, 5]],time = 3,change = 5) == 13\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 4]],time = 5,change = 7) == 33\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 5], [5, 6]],time = 4,change = 7) == 22\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 4], [4, 1]],time = 2,change = 3) == 8\n assert candidate(n = 14,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],time = 1,change = 2) == 29\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 9], [10, 11], [12, 13], [14, 15]],time = 8,change = 11) == 38\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 12], [11, 12], [1, 12]],time = 5,change = 7) == 19\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]],time = 2,change = 3) == 8\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 7], [6, 8], [7, 9], [8, 10]],time = 3,change = 5) == 13\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],time = 5,change = 4) == 29\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 8], [9, 10], [11, 12]],time = 3,change = 4) == 14\n assert candidate(n = 50,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35], [18, 36], [18, 37], [19, 38], [19, 39], [20, 40], [20, 41], [21, 42], [21, 43], [22, 44], [22, 45], [23, 46], [23, 47], [24, 48], [24, 49], [25, 50]],time = 3,change = 5) == 33\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 24], [13, 25]],time = 5,change = 7) == 38\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 6], [3, 7], [4, 6], [4, 7], [5, 6], [5, 7]],time = 5,change = 8) == 26\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = 8,change = 12) == 184\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]],time = 4,change = 6) == 28\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 12], [11, 12]],time = 3,change = 5) == 26\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 10], [9, 11], [12, 14], [13, 15]],time = 5,change = 8) == 26\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11]],time = 9,change = 12) == 57\n assert candidate(n = 11,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [1, 5], [1, 6], [1, 7], [2, 8], [2, 9], [3, 10], [3, 11]],time = 6,change = 8) == 28\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9]],time = 7,change = 10) == 47\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 3,change = 5) == 53\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20]],time = 6,change = 9) == 42\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 13], [13, 14], [14, 15]],time = 5,change = 8) == 37\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 7]],time = 4,change = 5) == 24\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7]],time = 3,change = 4) == 22\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],time = 3,change = 5) == 43\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = 4,change = 7) == 92\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]],time = 7,change = 9) == 43\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 11], [11, 12], [5, 7], [4, 6]],time = 3,change = 7) == 20\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 10]],time = 7,change = 10) == 47\n assert candidate(n = 14,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [1, 5], [1, 7], [2, 8], [2, 10], [3, 9], [3, 11], [4, 12], [4, 14], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]],time = 6,change = 13) == 18\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = 3,change = 4) == 14\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 6], [7, 8], [9, 10]],time = 4,change = 5) == 14\n assert candidate(n = 16,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 7], [4, 6], [4, 7], [5, 8], [5, 9], [6, 8], [6, 10], [7, 9], [7, 10], [8, 11], [8, 12], [9, 11], [9, 12], [10, 13], [10, 14], [11, 13], [11, 15], [12, 14], [12, 15], [13, 16], [14, 16], [15, 16]],time = 5,change = 10) == 50\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8]],time = 4,change = 6) == 28\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = 4,change = 6) == 124\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 7], [4, 6], [4, 7], [5, 8], [5, 9], [6, 8], [6, 10], [7, 9], [7, 10], [8, 11], [8, 12], [9, 11], [10, 12]],time = 8,change = 12) == 64\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 2,change = 3) == 32\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20]],time = 5,change = 8) == 42\n assert candidate(n = 18,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18]],time = 5,change = 6) == 101\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 8], [9, 10]],time = 2,change = 4) == 12\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],time = 4,change = 7) == 22\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11], [2, 3], [5, 7], [6, 8], [9, 10]],time = 3,change = 5) == 16\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 5], [4, 6], [5, 7], [5, 8], [6, 9], [7, 9], [8, 9]],time = 5,change = 7) == 24\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = 3,change = 5) == 93\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],time = 4,change = 6) == 28\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],time = 7,change = 10) == 54\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 7], [4, 6], [4, 7], [5, 8], [6, 8], [7, 8]],time = 6,change = 5) == 46\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [7, 12]],time = 2,change = 3) == 14\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [4, 6], [5, 6]],time = 10,change = 12) == 34\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 10], [5, 15], [9, 19]],time = 4,change = 6) == 32\n assert candidate(n = 16,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [8, 9], [10, 11], [12, 13], [14, 15], [16, 15]],time = 3,change = 5) == 16\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [1, 12]],time = 2,change = 3) == 8\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 6,change = 8) == 86\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],time = 6,change = 9) == 42\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = 3,change = 6) == 123\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 10], [9, 11], [12, 14], [13, 15]],time = 2,change = 5) == 12\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 8], [9, 10], [11, 12]],time = 3,change = 5) == 16\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = 4,change = 3) == 94\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 6], [7, 8], [8, 9], [5, 8], [6, 7], [5, 7], [6, 8]],time = 4,change = 6) == 16\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],time = 3,change = 4) == 22\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = 7,change = 9) == 97\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],time = 6,change = 8) == 28\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 12], [9, 13], [10, 14], [11, 15]],time = 2,change = 3) == 10\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 9]],time = 6,change = 5) == 36\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = 3,change = 5) == 63\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 7], [6, 7]],time = 5,change = 4) == 29\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 9], [10, 11], [12, 13], [14, 15]],time = 5,change = 6) == 22\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [24, 25]],time = 3,change = 6) == 18\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 7,change = 13) == 137\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [1, 4], [1, 5], [2, 6], [3, 4], [3, 6]],time = 7,change = 10) == 27\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],time = 3,change = 4) == 19\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 9], [10, 11], [12, 13], [14, 15]],time = 3,change = 7) == 17\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],time = 3,change = 5) == 26\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 5], [4, 6], [5, 7], [6, 7]],time = 7,change = 5) == 47\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]],time = 6,change = 5) == 56\n", "comparison": "exact"}, "public_tests": ["5\n[[1,2],[1,3],[1,4],[3,4],[4,5]]\n3\n5", "2\n[[1,2]]\n3\n2"], "hints": ["How much is change actually necessary while calculating the required path?", "How many extra edges do we need to add to the shortest path?"], "metadata": {"canonical_parameter_names": ["n", "edges", "time", "change"], "leetcode_dataset_entry_point": "Solution().secondMinimum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:14+00:00", "tests_total": 84, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["breadth-first-search", "graph", "shortest-path", "dijkstra", "k-shortest-path"]}, "language": "python", "interface": {"raw_signature": "def secondMinimum(self, n: int, edges: list[list[int]], time: int, change: int) -> int:", "container": "Solution", "callable": "secondMinimum", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "time", "type": "int"}, {"name": "change", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2047, "task_id": "number-of-valid-words-in-a-sentence", "difficulty": "Easy", "problem_description": "A sentence consists of lowercase letters ('a' to 'z'), digits ('0' to '9'), hyphens ('-'), punctuation marks ('!', '.', and ','), and spaces (' ') only. Each sentence can be broken down into one or more tokens separated by one or more spaces ' '.\n\nA token is a valid word if all three of the following are true:\n\n- It only contains lowercase letters, hyphens, and/or punctuation (no digits).\n- There is at most one hyphen '-'. If present, it must be surrounded by lowercase characters (\"a-b\" is valid, but \"-ab\" and \"ab-\" are not valid).\n- There is at most one punctuation mark. If present, it must be at the end of the token (\"ab,\", \"cd!\", and \".\" are valid, but \"a!b\" and \"c.,\" are not valid).\n\nExamples of valid words include \"a-b.\", \"afad\", \"ba-c\", \"a!\", and \"!\".\n\nGiven a string sentence, return the number of valid words in sentence.\n\nExample 1:\n\nInput: sentence = \"cat and dog\"\nOutput: 3\nExplanation: The valid words in the sentence are \"cat\", \"and\", and \"dog\".\n\nExample 2:\n\nInput: sentence = \"!this 1-s b8d!\"\nOutput: 0\nExplanation: There are no valid words in the sentence.\n\"!this\" is invalid because it starts with a punctuation mark.\n\"1-s\" and \"b8d\" are invalid because they contain digits.\n\nExample 3:\n\nInput: sentence = \"alice and bob are playing stone-game10\"\nOutput: 5\nExplanation: The valid words in the sentence are \"alice\", \"and\", \"bob\", \"are\", and \"playing\".\n\"stone-game10\" is invalid because it contains digits.\n\nConstraints:\n\n- 1 <= sentence.length <= 1000\n- sentence only contains lowercase English letters, digits, ' ', '-', '!', '.', and ','.\n- There will be at least 1 token.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence = \"no-digits123 or symbols#allowed\") == 2\n assert candidate(sentence = \"a.b.c\") == 0\n assert candidate(sentence = \"hello-world, this-is-a-test\") == 1\n assert candidate(sentence = \"hello-\") == 0\n assert candidate(sentence = \"a-\") == 0\n assert candidate(sentence = \"singleletter a b c d e f g\") == 8\n assert candidate(sentence = \"valid-words only\") == 2\n assert candidate(sentence = \"a\") == 1\n assert candidate(sentence = \"hello world! this is a test.\") == 6\n assert candidate(sentence = \"hello-world, my.name-is Qwen\") == 2\n assert candidate(sentence = \"ending-with-punctuation!\") == 0\n assert candidate(sentence = \"invalid--double-dash\") == 0\n assert candidate(sentence = \"multiple spaces between words\") == 4\n assert candidate(sentence = \"123\") == 0\n assert candidate(sentence = \"multiple--hyphens\") == 0\n assert candidate(sentence = \"valid-hyphenated-word\") == 0\n assert candidate(sentence = \"-invalid invalid- invalid-!\") == 0\n assert candidate(sentence = \"well-well, well!\") == 2\n assert candidate(sentence = \"singleletter\") == 1\n assert candidate(sentence = \"a! b. c?\") == 3\n assert candidate(sentence = \"hello-world\") == 1\n assert candidate(sentence = \"a-b-c\") == 0\n assert candidate(sentence = \"-world\") == 0\n assert candidate(sentence = \"a-b-c d-e f-g\") == 2\n assert candidate(sentence = \"-b\") == 0\n assert candidate(sentence = \"no-digits-allowed 123 456-789\") == 0\n assert candidate(sentence = \"alice and bob are playing stone-game10\") == 5\n assert candidate(sentence = \"no-dash-here\") == 0\n assert candidate(sentence = \"a-b!\") == 1\n assert candidate(sentence = \"valid-word here!\") == 2\n assert candidate(sentence = \"a-b- c d\") == 2\n assert candidate(sentence = \"valid-word here and another-valid one!\") == 5\n assert candidate(sentence = \"a-b-c-d.e.f!\") == 0\n assert candidate(sentence = \"singleletter a b c\") == 4\n assert candidate(sentence = \"a-b. afad ba-c a! .\") == 5\n assert candidate(sentence = \"a.b-c\") == 0\n assert candidate(sentence = \"hello!world\") == 0\n assert candidate(sentence = \",\") == 1\n assert candidate(sentence = \"a!b\") == 0\n assert candidate(sentence = \"-ab cd- ef-\") == 0\n assert candidate(sentence = \"hello-world, my name is john-doe.\") == 5\n assert candidate(sentence = \"!this 1-s b8d!\") == 0\n assert candidate(sentence = \"trailingpunctuation. comma, exclamation!\") == 3\n assert candidate(sentence = \"punctuation,in,middle,a-b.c\") == 0\n assert candidate(sentence = \"invalid-end-\") == 0\n assert candidate(sentence = \"-invalid start\") == 1\n assert candidate(sentence = \"valid-word here! and here.\") == 4\n assert candidate(sentence = \"!\") == 1\n assert candidate(sentence = \"valid-word-here!\") == 0\n assert candidate(sentence = \"punctuation,at,end.\") == 0\n assert candidate(sentence = \"a-b.c\") == 0\n assert candidate(sentence = \"cat and dog\") == 3\n assert candidate(sentence = \".\") == 1\n assert candidate(sentence = \"-invalid-start\") == 0\n assert candidate(sentence = \"a.b\") == 0\n assert candidate(sentence = \"hello-world!\") == 1\n assert candidate(sentence = \"punctuation! marks, are: allowed?\") == 4\n assert candidate(sentence = \"punctuation.only,\") == 0\n assert candidate(sentence = \"valid-word- valid-word-\") == 0\n assert candidate(sentence = \"word-with-digit1\") == 0\n assert candidate(sentence = \"punctuation-after-hyphen-! invalid\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation-1,\") == 0\n assert candidate(sentence = \"valid-word, valid-word!\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word?\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word@123\") == 1\n assert candidate(sentence = \"valid-word-with-hyphen-and-punctuation!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!\") == 1\n assert candidate(sentence = \"valid-word, invalid-word2\") == 1\n assert candidate(sentence = \"word-with-hyphen-and-punctuation-after-hyphen-,\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen-1b\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-1b-\") == 0\n assert candidate(sentence = \"valid-word-123\") == 0\n assert candidate(sentence = \"word-with-punctuation,at,end.\") == 0\n assert candidate(sentence = \"multiple---hyphens-in-a-row\") == 0\n assert candidate(sentence = \"word-with-hyphen-\") == 0\n assert candidate(sentence = \"word-with-digit-in-middle-1word\") == 0\n assert candidate(sentence = \"punctuation-inside-word!word\") == 0\n assert candidate(sentence = \"a-b-c d-e-f g-h\") == 1\n assert candidate(sentence = \"word-with-punctuation-and-digit1!\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation-after-hyphen-!\") == 0\n assert candidate(sentence = \"-word-with-leading-hyphen\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-b--1\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc\") == 1\n assert candidate(sentence = \"word-with-punctuation! word-without\") == 1\n assert candidate(sentence = \"word. word- word!\") == 2\n assert candidate(sentence = \"hyphenated-word- is valid\") == 2\n assert candidate(sentence = \"no-spaces\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen-1-word\") == 0\n assert candidate(sentence = \"word! word- word. word?\") == 3\n assert candidate(sentence = \"hyphen-at-end-\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word!\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@!\") == 1\n assert candidate(sentence = \"multiple---hyphens\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-exclamation!\") == 0\n assert candidate(sentence = \"valid-word- valid-word!\") == 1\n assert candidate(sentence = \"word word, word! word.\") == 4\n assert candidate(sentence = \"word-with-digit-and-hyphen-b--\") == 0\n assert candidate(sentence = \"valid-word- word-with-hyphen\") == 0\n assert candidate(sentence = \"word-with-digit1-and-punctuation!\") == 0\n assert candidate(sentence = \"punctuation-in-middle-of-word!word\") == 0\n assert candidate(sentence = \"word!word\") == 0\n assert candidate(sentence = \"singleletter singleletter! singleletter.\") == 3\n assert candidate(sentence = \"word-with-digit-at-end1!\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-1--b\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#\") == 1\n assert candidate(sentence = \"word-with-punctuation-and-hyphen-word-123\") == 0\n assert candidate(sentence = \"multiple--dashes are invalid\") == 2\n assert candidate(sentence = \"word-with-punctuation.at.end,invalid\") == 0\n assert candidate(sentence = \"word-with-digit1-and-punctuation.\") == 0\n assert candidate(sentence = \"valid-word-with-punctuation-at-end,\") == 0\n assert candidate(sentence = \"single-hyphenated-word a-b\") == 1\n assert candidate(sentence = \"123 word- word! word?\") == 2\n assert candidate(sentence = \"a.b!\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation, word-with-hyphen-and-punctuation.\") == 0\n assert candidate(sentence = \"valid-word- valid-word- valid-word\") == 1\n assert candidate(sentence = \"punctuation-only! and !only-punctuation\") == 2\n assert candidate(sentence = \"hello-world- is not valid\") == 3\n assert candidate(sentence = \"word-with-valid-hyphen word-with--invalid-hyphen\") == 0\n assert candidate(sentence = \"valid-word valid-word- valid-word\") == 2\n assert candidate(sentence = \"word-with-digit-and-hyphen-and-punctuation-1-word!\") == 0\n assert candidate(sentence = \"invalid-1word and valid-word\") == 2\n assert candidate(sentence = \"word-with-punctuation,at,end!\") == 0\n assert candidate(sentence = \"word- word\") == 1\n assert candidate(sentence = \"word-with-punctuations!word-with-punctuations!word-with-punctuations.\") == 0\n assert candidate(sentence = \"valid-ending-punctuation.\") == 0\n assert candidate(sentence = \"word-with-punctuation,word\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!\") == 1\n assert candidate(sentence = \"word..\") == 0\n assert candidate(sentence = \"word-with-multiple-hyphens-and-punctuation-,\") == 0\n assert candidate(sentence = \"multiple-spaces between words\") == 3\n assert candidate(sentence = \"word-with-hyphen-123\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word-\") == 1\n assert candidate(sentence = \"word-with-punctuations!word-with-punctuations!word-with-punctuations!word-with-punctuations!word-with-punctuations.\") == 0\n assert candidate(sentence = \"valid!word\") == 0\n assert candidate(sentence = \"word- word- valid\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-123\") == 1\n assert candidate(sentence = \"a--b\") == 0\n assert candidate(sentence = \"word-hyphenated-word word- word. word?\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen-b1\") == 0\n assert candidate(sentence = \"word- word! word@\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc-def,word\") == 1\n assert candidate(sentence = \"word-with-hyphen- valid-word\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation1-,\") == 0\n assert candidate(sentence = \"validwordwithmultiplepunctuations,,,\") == 0\n assert candidate(sentence = \"valid-word-with-hyphen-and-comma, valid.\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#\") == 1\n assert candidate(sentence = \"word,word,word\") == 0\n assert candidate(sentence = \"valid-word-with-punctuation-at-end!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123!\") == 1\n assert candidate(sentence = \"word,with,commas and.punctuations\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word@!\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123?\") == 1\n assert candidate(sentence = \"valid-word, valid-word. valid-word! valid-word\") == 4\n assert candidate(sentence = \"word-with-hyphen-and-punctuation,\") == 0\n assert candidate(sentence = \"word-with-space-in-word\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation word-with-hyphen-and-punctuation-\") == 0\n assert candidate(sentence = \"multiple---hyphens-in-word\") == 0\n assert candidate(sentence = \"word,word\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word?\") == 2\n assert candidate(sentence = \"123 456 789\") == 0\n assert candidate(sentence = \"punctuation!in!the!middle\") == 0\n assert candidate(sentence = \"multiple-punctuation,,\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-digit-1\") == 0\n assert candidate(sentence = \"word-with-digit123\") == 0\n assert candidate(sentence = \"word-with-digit123 and another-word!\") == 2\n assert candidate(sentence = \"a!b.c\") == 0\n assert candidate(sentence = \"multiple-punctuation!!\") == 0\n assert candidate(sentence = \"word-with123-hyphen\") == 0\n assert candidate(sentence = \"only!only only.only only-\") == 0\n assert candidate(sentence = \"word1 word2- word3- word4\") == 0\n assert candidate(sentence = \"word-with-hyphen- word\") == 1\n assert candidate(sentence = \"valid-word\") == 1\n assert candidate(sentence = \"-word\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word\") == 1\n assert candidate(sentence = \"word-with-1digit\") == 0\n assert candidate(sentence = \"word-with-punctuations,word-with-punctuations,word-with-punctuations,word-with-punctuations,word-with-punctuations!\") == 0\n assert candidate(sentence = \"valid-word, and invalid-word1\") == 2\n assert candidate(sentence = \"word-with-punctuation-in-middle.a\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word@?\") == 2\n assert candidate(sentence = \"word-with-hyphen-and-period.\") == 0\n assert candidate(sentence = \"word-with-multiple-hyphens-and-punctuation-,and valid-word!\") == 1\n assert candidate(sentence = \"word-with-punctuations,word-with-punctuations.\") == 0\n assert candidate(sentence = \"valid-word followed-by-number123\") == 1\n assert candidate(sentence = \"single-punctuation!\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@123\") == 1\n assert candidate(sentence = \"word word- word! word-\") == 2\n assert candidate(sentence = \"word-! word- word-\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc123\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen-and-punctuation-word-1.\") == 0\n assert candidate(sentence = \"word-with-hyphen word-with-hyphen- word-with-hyphen\") == 0\n assert candidate(sentence = \"valid-word! another-valid-word?\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation1,\") == 0\n assert candidate(sentence = \"word-with-punctuation.at-end\") == 0\n assert candidate(sentence = \"valid-word, invalid-word123\") == 1\n assert candidate(sentence = \"!valid valid. valid-\") == 1\n assert candidate(sentence = \"valid-word.\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation1-.\") == 0\n assert candidate(sentence = \"a a-b a-b-c a-b-c-d\") == 2\n assert candidate(sentence = \"word-with-trailing-punctuation,\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation-after-hyphen-.\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@123\") == 1\n assert candidate(sentence = \"multiple spaces\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word?\") == 1\n assert candidate(sentence = \"multiple-punctuation..\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc-123\") == 1\n assert candidate(sentence = \"word! word- word. word-\") == 2\n assert candidate(sentence = \"valid-word followed-by-digits123\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen--b-1\") == 0\n assert candidate(sentence = \"hello-world- is-not-valid\") == 0\n assert candidate(sentence = \"word-with-punctuations!word-with-punctuations!\") == 0\n assert candidate(sentence = \"-a\") == 0\n assert candidate(sentence = \"nohyphens here!\") == 2\n assert candidate(sentence = \"word-with-punctuation-at-start!word\") == 0\n assert candidate(sentence = \"leading!and-trailing!punctuation!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def!\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc\") == 1\n assert candidate(sentence = \"no-dashes-here but-here-are-too-many-dashes\") == 0\n assert candidate(sentence = \"word-hyphen- word\") == 1\n assert candidate(sentence = \"valid-word-with-hyphen-and-punctuation.\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation!\") == 0\n assert candidate(sentence = \"valid-word, valid-word. valid-word!\") == 3\n assert candidate(sentence = \"word-with-punctuation.at.end.\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word-\") == 1\n assert candidate(sentence = \"a!b!c\") == 0\n assert candidate(sentence = \"word-with-number1234 and valid-word\") == 2\n assert candidate(sentence = \"word,word!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word@\") == 2\n assert candidate(sentence = \"word1 word2 word3 word4\") == 0\n assert candidate(sentence = \"word-with-punctuation,at,end!invalid\") == 0\n assert candidate(sentence = \"complex-word-with-punctuation,\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc-def!\") == 1\n assert candidate(sentence = \"word-with-punctuations!word-with-punctuations!word-with-punctuations!word-with-punctuations.\") == 0\n assert candidate(sentence = \"single-letter-word a\") == 1\n assert candidate(sentence = \"word-with-trailing-hyphen-\") == 0\n assert candidate(sentence = \"punctuation.multiple\") == 0\n assert candidate(sentence = \"multi-hyphen-word-123\") == 0\n assert candidate(sentence = \"word-with-hyphen word-with-hyphen-\") == 0\n assert candidate(sentence = \"valid-word a valid-word- valid-word\") == 3\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc123\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation-1.\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-b-1--\") == 0\n assert candidate(sentence = \"word!word!\") == 0\n assert candidate(sentence = \"!word .word ,word\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation- word\") == 1\n assert candidate(sentence = \"invalid-punctuation, invalid-punctuation! invalid-punctuation?\") == 3\n assert candidate(sentence = \"a.b.c.d\") == 0\n assert candidate(sentence = \"multi-hyphenated-word-should-fail\") == 0\n assert candidate(sentence = \"valid-word!\") == 1\n assert candidate(sentence = \"punctuation!in!middle\") == 0\n assert candidate(sentence = \"trailing-hyphen- invalid-hyphen-\") == 0\n assert candidate(sentence = \"single-letter a\") == 2\n assert candidate(sentence = \"word-with-digit-and-hyphen--b1\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-period-and-comma,./\") == 0\n assert candidate(sentence = \"word-with-punctuations! word\") == 1\n assert candidate(sentence = \"word-with-2-hyphens-a-b-c\") == 0\n assert candidate(sentence = \"word-with--double-hyphen\") == 0\n assert candidate(sentence = \"a.b-c!d.e\") == 0\n assert candidate(sentence = \"this-is-valid-1\") == 0\n assert candidate(sentence = \"valid-word! valid-word!\") == 2\n assert candidate(sentence = \"word-with-hyphen-and-digit1-\") == 0\n assert candidate(sentence = \"a!b-c.d.e\") == 0\n assert candidate(sentence = \"a.b-c.d.e\") == 0\n assert candidate(sentence = \"word-with-digit-and-punctuation1-!\") == 0\n assert candidate(sentence = \"1word 12word word3\") == 0\n assert candidate(sentence = \"word-with-punctuation,word-with-punctuation, word-with-punctuation!word-with-punctuation.\") == 0\n assert candidate(sentence = \"a!b.c-d.e\") == 0\n assert candidate(sentence = \"valid-word-1 valid-word-2\") == 0\n assert candidate(sentence = \"word!word another-word,\") == 1\n assert candidate(sentence = \"a.b-c.d!e\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def\") == 1\n assert candidate(sentence = \"a-b.c.d\") == 0\n assert candidate(sentence = \"mid,dash\") == 0\n assert candidate(sentence = \"valid.word\") == 0\n assert candidate(sentence = \"valid-word valid-word-\") == 1\n assert candidate(sentence = \"word-with-punctuations,word\") == 0\n assert candidate(sentence = \"word-with-digit-and-punctuation1.\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-word-1\") == 0\n assert candidate(sentence = \"word-!\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-comma,\") == 0\n assert candidate(sentence = \"-hyphen-at-start\") == 0\n assert candidate(sentence = \"single-punctuation-mark.\") == 0\n assert candidate(sentence = \"!invalid-start-word invalid-end-word!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def!\") == 1\n assert candidate(sentence = \"a-b-c-d\") == 0\n assert candidate(sentence = \"word-with-punctuations,word-with-punctuations,word-with-punctuations!\") == 0\n assert candidate(sentence = \"word-with-digit-at-end1.\") == 0\n assert candidate(sentence = \"valid-word-!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc-def\") == 1\n assert candidate(sentence = \"multiple-hyphens-in--one-word\") == 0\n assert candidate(sentence = \"a valid-word- valid-word valid-word-\") == 2\n assert candidate(sentence = \"double--hyphen invalid\") == 1\n assert candidate(sentence = \"validwordwithmultiplepunctuations...\") == 0\n assert candidate(sentence = \"!a-b\") == 0\n assert candidate(sentence = \"word! word- word. word@\") == 3\n assert candidate(sentence = \"valid-word- valid-word valid-word\") == 2\n assert candidate(sentence = \"leading-hyphen invalid-hyphen\") == 2\n assert candidate(sentence = \"a.b.c!\") == 0\n assert candidate(sentence = \"invalid-word- punctuation-here.\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def\") == 1\n assert candidate(sentence = \"valid-word-here, and-this.is!ok\") == 0\n assert candidate(sentence = \"valid-word, valid-word.\") == 2\n assert candidate(sentence = \"valid-word valid-word valid-word-\") == 2\n assert candidate(sentence = \"word-h word-hyphenated word-!\") == 2\n assert candidate(sentence = \"another!valid!word\") == 0\n assert candidate(sentence = \"word-with.punctuation\") == 0\n assert candidate(sentence = \"valid-word- valid-hyphenated-word\") == 0\n assert candidate(sentence = \"valid-word word-with-hyphen-\") == 1\n assert candidate(sentence = \"word-with-hyphen-and-punctuation! word-with-hyphen-and-punctuation!\") == 0\n assert candidate(sentence = \"single-letter a valid-word\") == 3\n assert candidate(sentence = \"valid-word-with-hyphen-and-punctuation,\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation.\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word!\") == 1\n assert candidate(sentence = \"end! punctuation\") == 2\n assert candidate(sentence = \"word-with-digit-at-end1\") == 0\n assert candidate(sentence = \"hyphenated-word-\") == 0\n assert candidate(sentence = \"valid-word,\") == 1\n assert candidate(sentence = \"-word-with-hyphen\") == 0\n assert candidate(sentence = \"only-allowed-here\") == 0\n assert candidate(sentence = \"word-with-digit-in-hyphen-1-word\") == 0\n assert candidate(sentence = \"mixed-case Words Are Invalid\") == 4\n assert candidate(sentence = \"-leading-hyphen\") == 0\n assert candidate(sentence = \"word-with-punctuation!at!the!end\") == 0\n assert candidate(sentence = \"validwordwithmultiplepunctuations!!!\") == 0\n assert candidate(sentence = \"valid-word word-with-hyphen\") == 1\n assert candidate(sentence = \"word-with-digit1-and-punctuation,\") == 0\n assert candidate(sentence = \"word-with-hyphen123\") == 0\n assert candidate(sentence = \"word-with-punctuation!at!end\") == 0\n assert candidate(sentence = \"word-hyphenated word- word. word?\") == 3\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123\") == 1\n assert candidate(sentence = \"word-with-digit-at-end1,\") == 0\n assert candidate(sentence = \"word word- word! word?\") == 3\n assert candidate(sentence = \"valid-word,another-valid-word\") == 0\n assert candidate(sentence = \"trailing-punctuations,, are! invalid\") == 2\n assert candidate(sentence = \"word-with-punctuation!and-more\") == 0\n assert candidate(sentence = \"123abc and abc123 are invalid\") == 3\n assert candidate(sentence = \"word-with-digit-and-hyphen--b\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-b-1\") == 0\n assert candidate(sentence = \"valid-word! valid-word, valid-word.\") == 3\n assert candidate(sentence = \"no-hyphens allowed\") == 2\n assert candidate(sentence = \"word-with-digit-and-punctuation-1!\") == 0\n assert candidate(sentence = \"multiple spaces between words\") == 4\n assert candidate(sentence = \"triple-hyphen---word\") == 0\n assert candidate(sentence = \"punctuation,,comma and space\") == 2\n assert candidate(sentence = \"valid-word-2!\") == 0\n assert candidate(sentence = \"word-with-digit1-and-hyphen-b\") == 0\n assert candidate(sentence = \"valid-hyphen-word word- word\") == 1\n assert candidate(sentence = \"word- word- word- word.\") == 1\n assert candidate(sentence = \"word!!\") == 0\n assert candidate(sentence = \"trailing-hyphen-\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@\") == 1\n assert candidate(sentence = \"word- word- word- word\") == 1\n assert candidate(sentence = \"word-!!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-123\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation1!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#\") == 1\n assert candidate(sentence = \"word-with-multiple-punctuations!!!\") == 0\n assert candidate(sentence = \"word-with-punctuations!.\") == 0\n assert candidate(sentence = \"word1- word2- word3- word4-\") == 0\n assert candidate(sentence = \"multiple--hyphens-are!invalid\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc123\") == 1\n assert candidate(sentence = \"valid-word- valid-word- valid-word-\") == 0\n assert candidate(sentence = \"valid-word-with-punctuation-at-end.\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen1-b\") == 0\n assert candidate(sentence = \"multi-hyphen-usage-is-not-allowed\") == 0\n assert candidate(sentence = \"word-with! punctuation\") == 2\n assert candidate(sentence = \"valid-word valid-word valid-word\") == 3\n assert candidate(sentence = \"valid-word-1 valid-word-2 valid-word-3\") == 0\n assert candidate(sentence = \"word-with-punctuations,word-with-punctuations,word-with-punctuations,word-with-punctuations!\") == 0\n assert candidate(sentence = \"word-with-digit-in-hyphen-word-1\") == 0\n assert candidate(sentence = \"word-\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-1-b\") == 0\n assert candidate(sentence = \"valid,word valid.word valid-word!\") == 1\n", "comparison": "exact"}, "public_tests": ["\"cat and dog\"", "\"!this 1-s b8d!\"", "\"alice and bob are playing stone-game10\""], "hints": ["Iterate through the string to split it by spaces.", "Count the number of characters of each type (letters, numbers, hyphens, and punctuations)."], "metadata": {"canonical_parameter_names": ["sentence"], "leetcode_dataset_entry_point": "Solution().countValidWords", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:19+00:00", "tests_total": 377, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def countValidWords(self, sentence: str) -> int:", "container": "Solution", "callable": "countValidWords", "parameters": [{"name": "sentence", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2048, "task_id": "next-greater-numerically-balanced-number", "difficulty": "Medium", "problem_description": "An integer x is numerically balanced if for every digit d in the number x, there are exactly d occurrences of that digit in x.\n\nGiven an integer n, return the smallest numerically balanced number strictly greater than n.\n\nExample 1:\n\nInput: n = 1\nOutput: 22\nExplanation:\n22 is numerically balanced since:\n- The digit 2 occurs 2 times.\nIt is also the smallest numerically balanced number strictly greater than 1.\n\nExample 2:\n\nInput: n = 1000\nOutput: 1333\nExplanation:\n1333 is numerically balanced since:\n- The digit 1 occurs 1 time.\n- The digit 3 occurs 3 times.\nIt is also the smallest numerically balanced number strictly greater than 1000.\nNote that 1022 cannot be the answer because 0 appeared more than 0 times.\n\nExample 3:\n\nInput: n = 3000\nOutput: 3133\nExplanation:\n3133 is numerically balanced since:\n- The digit 1 occurs 1 time.\n- The digit 3 occurs 3 times.\nIt is also the smallest numerically balanced number strictly greater than 3000.\n\nConstraints:\n\n- 0 <= n <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 1\n assert candidate(n = 122333) == 123233\n assert candidate(n = 3000) == 3133\n assert candidate(n = 1222) == 1333\n assert candidate(n = 55555) == 122333\n assert candidate(n = 1234) == 1333\n assert candidate(n = 112233) == 122333\n assert candidate(n = 122133) == 122333\n assert candidate(n = 999999) == 1224444\n assert candidate(n = 123456) == 132233\n assert candidate(n = 1) == 22\n assert candidate(n = 1000) == 1333\n assert candidate(n = 987654) == 1224444\n assert candidate(n = 122) == 212\n assert candidate(n = 122444) == 123233\n assert candidate(n = 666666) == 1224444\n assert candidate(n = 444444) == 515555\n assert candidate(n = 123321) == 123323\n assert candidate(n = 98765) == 122333\n assert candidate(n = 400000) == 422444\n assert candidate(n = 111) == 122\n assert candidate(n = 1000000) == 1224444\n assert candidate(n = 4444) == 14444\n", "comparison": "exact"}, "public_tests": ["1", "1000", "3000"], "hints": ["How far away can the next greater numerically balanced number be from n?", "With the given constraints, what is the largest numerically balanced number?"], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().nextBeautifulNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:21+00:00", "tests_total": 58, "tests_dropped": 35, "flags": [], "topic_tags": ["hash-table", "math", "backtracking", "counting", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def nextBeautifulNumber(self, n: int) -> int:", "container": "Solution", "callable": "nextBeautifulNumber", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2049, "task_id": "count-nodes-with-the-highest-score", "difficulty": "Medium", "problem_description": "There is a binary tree rooted at 0 consisting of n nodes. The nodes are labeled from 0 to n - 1. You are given a 0-indexed integer array parents representing the tree, where parents[i] is the parent of node i. Since node 0 is the root, parents[0] == -1.\n\nEach node has a score. To find the score of a node, consider if the node and the edges connected to it were removed. The tree would become one or more non-empty subtrees. The size of a subtree is the number of the nodes in it. The score of the node is the product of the sizes of all those subtrees.\n\nReturn the number of nodes that have the highest score.\n\nExample 1:\n\nInput: parents = [-1,2,0,2,0]\nOutput: 3\nExplanation:\n- The score of node 0 is: 3 * 1 = 3\n- The score of node 1 is: 4 = 4\n- The score of node 2 is: 1 * 1 * 2 = 2\n- The score of node 3 is: 4 = 4\n- The score of node 4 is: 4 = 4\nThe highest score is 4, and three nodes (node 1, node 3, and node 4) have the highest score.\n\nExample 2:\n\nInput: parents = [-1,2,0]\nOutput: 2\nExplanation:\n- The score of node 0 is: 2 = 2\n- The score of node 1 is: 2 = 2\n- The score of node 2 is: 1 * 1 = 1\nThe highest score is 2, and two nodes (node 0 and node 1) have the highest score.\n\nConstraints:\n\n- n == parents.length\n- 2 <= n <= 10^5\n- parents[0] == -1\n- 0 <= parents[i] <= n - 1 for i != 0\n- parents represents a valid binary tree.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3]) == 5\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2]) == 1\n assert candidate(parents = [-1, 2, 0, 2, 0]) == 3\n assert candidate(parents = [-1, 0, 1, 2, 3]) == 3\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 2\n assert candidate(parents = [-1, 0, 1, 2, 2]) == 3\n assert candidate(parents = [-1, 0, 0, 1, 1]) == 3\n assert candidate(parents = [-1, 1, 1, 2, 2, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2]) == 3\n assert candidate(parents = [-1, 0, 1, 1, 3, 3]) == 4\n assert candidate(parents = [-1, 2, 0]) == 2\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63, 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, 74, 74, 75, 75, 76, 76, 77, 77, 78, 78, 79, 79, 80, 80, 81, 81, 82, 82, 83, 83, 84, 84, 85, 85, 86, 86, 87, 87, 88, 88, 89, 89, 90, 90]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 2\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30]) == 2\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30, 32, 32, 34, 34, 36, 36]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200]) == 2\n assert candidate(parents = [-1, 0, 1, 0, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4]) == 2\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 2\n assert candidate(parents = [-1, 0, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30, 32, 32]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 1\n", "comparison": "exact"}, "public_tests": ["[-1,2,0,2,0]", "[-1,2,0]"], "hints": ["For each node, you need to find the sizes of the subtrees rooted in each of its children. Maybe DFS?", "How to determine the number of nodes in the rest of the tree? Can you subtract the size of the subtree rooted at the node from the total number of nodes of the tree?", "Use these values to compute the score of the node. Track the maximum score, and how many nodes achieve such score."], "metadata": {"canonical_parameter_names": ["parents"], "leetcode_dataset_entry_point": "Solution().countHighestScoreNodes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:23+00:00", "tests_total": 79, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "tree", "depth-first-search", "binary-tree", "dp-on-trees"]}, "language": "python", "interface": {"raw_signature": "def countHighestScoreNodes(self, parents: list[int]) -> int:", "container": "Solution", "callable": "countHighestScoreNodes", "parameters": [{"name": "parents", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2050, "task_id": "parallel-courses-iii", "difficulty": "Hard", "problem_description": "You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given a 2D integer array relations where relations[j] = [prevCourse_j, nextCourse_j] denotes that course prevCourse_j has to be completed before course nextCourse_j (prerequisite relationship). Furthermore, you are given a 0-indexed integer array time where time[i] denotes how many months it takes to complete the (i+1)^th course.\n\nYou must find the minimum number of months needed to complete all the courses following these rules:\n\n- You may start taking a course at any time if the prerequisites are met.\n- Any number of courses can be taken at the same time.\n\nReturn the minimum number of months needed to complete all the courses.\n\nNote: The test cases are generated such that it is possible to complete every course (i.e., the graph is a directed acyclic graph).\n\nExample 1:\n\nInput: n = 3, relations = [[1,3],[2,3]], time = [3,2,5]\nOutput: 8\nExplanation: The figure above represents the given graph and the time required to complete each course.\nWe start course 1 and course 2 simultaneously at month 0.\nCourse 1 takes 3 months and course 2 takes 2 months to complete respectively.\nThus, the earliest time we can start course 3 is at month 3, and the total time required is 3 + 5 = 8 months.\n\nExample 2:\n\nInput: n = 5, relations = [[1,5],[2,5],[3,5],[3,4],[4,5]], time = [1,2,3,4,5]\nOutput: 12\nExplanation: The figure above represents the given graph and the time required to complete each course.\nYou can start courses 1, 2, and 3 at month 0.\nYou can complete them after 1, 2, and 3 months respectively.\nCourse 4 can be taken only after course 3 is completed, i.e., after 3 months. It is completed after 3 + 4 = 7 months.\nCourse 5 can be taken only after courses 1, 2, 3, and 4 have been completed, i.e., after max(1,2,3,7) = 7 months.\nThus, the minimum time needed to complete all the courses is 7 + 5 = 12 months.\n\nConstraints:\n\n- 1 <= n <= 5 * 10^4\n- 0 <= relations.length <= min(n * (n - 1) / 2, 5 * 10^4)\n- relations[j].length == 2\n- 1 <= prevCourse_j, nextCourse_j <= n\n- prevCourse_j != nextCourse_j\n- All the pairs [prevCourse_j, nextCourse_j] are unique.\n- time.length == n\n- 1 <= time[i] <= 10^4\n- The given graph is a directed acyclic graph.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,relations = [[1, 2], [1, 3], [2, 4], [3, 4]],time = [4, 2, 3, 1]) == 8\n assert candidate(n = 3,relations = [[1, 3], [2, 3]],time = [3, 2, 5]) == 8\n assert candidate(n = 6,relations = [[1, 2], [2, 3], [3, 4], [1, 5], [5, 6], [4, 6]],time = [1, 2, 3, 4, 5, 6]) == 16\n assert candidate(n = 1,relations = [],time = [5]) == 5\n assert candidate(n = 4,relations = [[1, 2], [2, 3], [3, 4]],time = [1, 2, 3, 4]) == 10\n assert candidate(n = 5,relations = [[1, 5], [2, 5], [3, 5], [3, 4], [4, 5]],time = [1, 2, 3, 4, 5]) == 12\n assert candidate(n = 9,relations = [[1, 4], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],time = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10], [10, 11], [10, 12]],time = [2, 3, 4, 1, 5, 6, 7, 8, 9, 3, 12, 4]) == 37\n assert candidate(n = 8,relations = [[1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8]],time = [2, 3, 2, 3, 2, 3, 4, 5]) == 11\n assert candidate(n = 8,relations = [[1, 2], [2, 4], [1, 3], [3, 5], [3, 6], [4, 6], [5, 7], [6, 7], [7, 8]],time = [1, 3, 2, 4, 5, 6, 1, 8]) == 23\n assert candidate(n = 20,relations = [[1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9]],time = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 100\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [5, 6], [5, 7], [4, 8], [7, 8], [8, 9], [9, 10]],time = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 50\n assert candidate(n = 12,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]],time = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 126\n assert candidate(n = 11,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 66\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 13], [9, 14], [10, 15], [11, 15]],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 62\n assert candidate(n = 12,relations = [[1, 6], [2, 6], [3, 6], [4, 7], [5, 7], [6, 8], [6, 9], [7, 10], [8, 11], [9, 11], [10, 12], [11, 12]],time = [1, 1, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7]) == 20\n assert candidate(n = 25,relations = [[1, 6], [2, 6], [3, 7], [4, 7], [5, 7], [6, 8], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]],time = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 64\n assert candidate(n = 15,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15]],time = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 95\n assert candidate(n = 8,relations = [[1, 3], [2, 3], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7], [7, 8]],time = [10, 20, 30, 40, 50, 60, 70, 80]) == 300\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 17\n assert candidate(n = 15,relations = [[1, 6], [2, 6], [3, 7], [4, 7], [5, 7], [6, 8], [7, 8], [8, 9], [8, 10], [9, 11], [10, 11], [11, 12], [11, 13], [12, 14], [13, 14], [14, 15]],time = [4, 5, 2, 6, 3, 1, 8, 9, 2, 7, 5, 6, 4, 3, 10]) == 54\n assert candidate(n = 7,relations = [[1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [4, 5], [5, 7], [6, 7]],time = [2, 3, 4, 5, 1, 6, 7]) == 16\n assert candidate(n = 11,relations = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],time = [1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(n = 6,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 6]],time = [1, 2, 3, 4, 5, 6]) == 15\n assert candidate(n = 12,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 73\n assert candidate(n = 8,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [6, 8]],time = [5, 3, 10, 2, 8, 4, 1, 6]) == 33\n assert candidate(n = 12,relations = [[1, 5], [2, 5], [3, 5], [1, 6], [2, 6], [3, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = [2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7]) == 32\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [3, 6], [4, 6], [5, 6], [6, 7], [7, 8], [7, 9], [7, 10], [8, 11], [9, 11], [10, 11], [11, 12], [12, 13], [12, 14], [12, 15]],time = [2, 3, 4, 5, 1, 6, 7, 8, 9, 2, 5, 1, 3, 4, 5]) == 40\n assert candidate(n = 20,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(n = 7,relations = [[1, 2], [1, 4], [2, 3], [2, 5], [4, 6], [5, 6], [6, 7]],time = [5, 4, 3, 2, 1, 10, 15]) == 35\n assert candidate(n = 15,relations = [[1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 40\n assert candidate(n = 30,relations = [[1, 10], [2, 10], [3, 11], [4, 11], [5, 11], [6, 12], [7, 12], [8, 12], [9, 12], [10, 13], [11, 13], [12, 14], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]],time = [2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1]) == 62\n assert candidate(n = 12,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [7, 10], [8, 11], [9, 11], [10, 12], [11, 12]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 42\n assert candidate(n = 8,relations = [[1, 3], [2, 3], [3, 4], [1, 5], [2, 5], [5, 6], [6, 7], [7, 8]],time = [2, 3, 1, 2, 4, 3, 2, 1]) == 13\n assert candidate(n = 12,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [1, 6], [1, 7], [1, 8], [2, 9], [2, 10], [3, 11], [4, 12]],time = [3, 2, 5, 1, 6, 7, 4, 8, 9, 2, 5, 1]) == 53\n assert candidate(n = 7,relations = [[1, 4], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [4, 6], [5, 6], [4, 7], [5, 7]],time = [3, 2, 5, 4, 3, 7, 5]) == 16\n assert candidate(n = 9,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],time = [3, 2, 5, 4, 3, 2, 5, 4, 3, 2]) == 18\n assert candidate(n = 9,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [1, 6], [1, 7], [2, 8], [3, 9]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 47\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [8, 11], [9, 12], [9, 13], [10, 14], [11, 14], [12, 15], [13, 15]],time = [2, 3, 2, 4, 3, 1, 5, 6, 7, 8, 4, 3, 2, 5, 6]) == 28\n assert candidate(n = 20,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20]],time = [2, 3, 4, 5, 1, 6, 7, 8, 9, 2, 5, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == 105\n assert candidate(n = 13,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [6, 8], [7, 9], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]],time = [4, 3, 5, 2, 6, 7, 8, 9, 3, 4, 10, 1, 2]) == 51\n assert candidate(n = 15,relations = [[1, 10], [1, 11], [2, 10], [3, 11], [4, 12], [5, 12], [6, 13], [7, 13], [8, 14], [9, 14], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15]],time = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1]) == 16\n assert candidate(n = 20,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(n = 15,relations = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 7], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = [2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1]) == 35\n assert candidate(n = 9,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],time = [4, 3, 2, 1, 4, 3, 2, 1, 4]) == 24\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7], [7, 8]],time = [5, 4, 3, 2, 1, 1, 2, 3]) == 17\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8]],time = [10, 20, 30, 40, 50, 60, 70, 80]) == 210\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(n = 20,relations = [[1, 5], [2, 6], [3, 7], [4, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 13], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19], [12, 20], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 20]],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 12\n assert candidate(n = 20,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [8, 11], [9, 12], [9, 13], [10, 14], [11, 14], [12, 15], [13, 15], [14, 16], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 138\n assert candidate(n = 7,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7]],time = [3, 2, 5, 4, 1, 6, 8]) == 27\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7], [7, 8], [8, 9], [9, 10]],time = [1, 2, 3, 2, 3, 2, 3, 4, 5, 6]) == 27\n assert candidate(n = 6,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],time = [1000, 2000, 3000, 4000, 5000, 6000]) == 21000\n assert candidate(n = 7,relations = [[1, 4], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7]],time = [1, 1, 1, 3, 2, 2, 1]) == 7\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [5, 7], [6, 8], [7, 8], [8, 9], [9, 10]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 47\n", "comparison": "exact"}, "public_tests": ["3\n[[1,3],[2,3]]\n[3,2,5]", "5\n[[1,5],[2,5],[3,5],[3,4],[4,5]]\n[1,2,3,4,5]"], "hints": ["What is the earliest time a course can be taken?", "How would you solve the problem if all courses take equal time?", "How would you generalize this approach?"], "metadata": {"canonical_parameter_names": ["n", "relations", "time"], "leetcode_dataset_entry_point": "Solution().minimumTime", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:26+00:00", "tests_total": 60, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "dynamic-programming", "graph", "topological-sort", "directed-acyclic-graph"]}, "language": "python", "interface": {"raw_signature": "def minimumTime(self, n: int, relations: list[list[int]], time: list[int]) -> int:", "container": "Solution", "callable": "minimumTime", "parameters": [{"name": "n", "type": "int"}, {"name": "relations", "type": "list[list[int]]"}, {"name": "time", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2053, "task_id": "kth-distinct-string-in-an-array", "difficulty": "Easy", "problem_description": "A distinct string is a string that is present only once in an array.\n\nGiven an array of strings arr, and an integer k, return the k^th distinct string present in arr. If there are fewer than k distinct strings, return an empty string \"\".\n\nNote that the strings are considered in the order in which they appear in the array.\n\nExample 1:\n\nInput: arr = [\"d\",\"b\",\"c\",\"b\",\"c\",\"a\"], k = 2\nOutput: \"a\"\nExplanation:\nThe only distinct strings in arr are \"d\" and \"a\".\n\"d\" appears 1^st, so it is the 1^st distinct string.\n\"a\" appears 2^nd, so it is the 2^nd distinct string.\nSince k == 2, \"a\" is returned.\n\nExample 2:\n\nInput: arr = [\"aaa\",\"aa\",\"a\"], k = 1\nOutput: \"aaa\"\nExplanation:\nAll strings in arr are distinct, so the 1^st string \"aaa\" is returned.\n\nExample 3:\n\nInput: arr = [\"a\",\"b\",\"a\"], k = 3\nOutput: \"\"\nExplanation:\nThe only distinct string is \"b\". Since there are fewer than 3 distinct strings, we return an empty string \"\".\n\nConstraints:\n\n- 1 <= k <= arr.length <= 1000\n- 1 <= arr[i].length <= 5\n- arr[i] consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = ['a'],k = 1) == \"a\"\n assert candidate(arr = ['a', 'a', 'b', 'b', 'c', 'c', 'd'],k = 1) == \"d\"\n assert candidate(arr = ['aaa', 'aa', 'a'],k = 1) == \"aaa\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f'],k = 6) == \"f\"\n assert candidate(arr = ['hello', 'world', 'hello', 'world'],k = 2) == \"\"\n assert candidate(arr = ['x', 'y', 'z', 'x', 'y', 'z'],k = 2) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],k = 10) == \"j\"\n assert candidate(arr = ['same', 'same', 'same', 'same'],k = 1) == \"\"\n assert candidate(arr = ['a', 'b', 'a'],k = 3) == \"\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five'],k = 5) == \"five\"\n assert candidate(arr = ['a', 'a', 'a', 'a', 'a'],k = 1) == \"\"\n assert candidate(arr = ['test', 'test', 'test'],k = 1) == \"\"\n assert candidate(arr = ['d', 'b', 'c', 'b', 'c', 'a'],k = 2) == \"a\"\n assert candidate(arr = ['xyz', 'zyx', 'zyx', 'xyz', 'zyx'],k = 1) == \"\"\n assert candidate(arr = ['same', 'word', 'same', 'word', 'same', 'word', 'same', 'word', 'same'],k = 1) == \"\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],k = 7) == \"seven\"\n assert candidate(arr = ['x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y'],k = 1) == \"\"\n assert candidate(arr = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab', 'cdef', 'ghij', 'klmn', 'opqr', 'stuv', 'wxyz'],k = 13) == \"wxyz\"\n assert candidate(arr = ['abcd', 'abc', 'ab', 'a', 'abcd', 'abc', 'ab', 'a', 'abcd', 'abc', 'ab', 'a'],k = 3) == \"\"\n assert candidate(arr = ['abc', 'def', 'ghi', 'abc', 'jkl', 'ghi', 'mno'],k = 4) == \"\"\n assert candidate(arr = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],k = 1) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 26) == \"z\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 27) == \"\"\n assert candidate(arr = ['xy', 'yx', 'xx', 'yy', 'xz', 'zx', 'yz', 'zy', 'xxyy', 'xyxy', 'yxyx', 'yxyy', 'xyyx', 'xyyy', 'yyxx', 'yyxy', 'yyyx', 'yyyy'],k = 10) == \"xyxy\"\n assert candidate(arr = ['xyz', 'zyx', 'wxy', 'yxw', 'uvw', 'vuw', 'wuv', 'abc', 'cab', 'bac'],k = 2) == \"zyx\"\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abc', 'def', 'ghi'],k = 5) == \"vwx\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd'],k = 10) == \"\"\n assert candidate(arr = ['aaaaa', 'aaaab', 'aaaba', 'aabaa', 'abaaa', 'baaaa', 'abcde', 'bcdea', 'cdeab', 'decab', 'efghi', 'fghie', 'ghief', 'hiefg', 'iefgh', 'jklmn', 'klmno', 'lmnop', 'mnopq', 'nopqr', 'opqrs', 'pqrst', 'qrstu', 'rstuv', 'stuvw', 'tuvwx', 'uvwxy', 'vwxyz'],k = 15) == \"iefgh\"\n assert candidate(arr = ['loop', 'pool', 'look', 'cool', 'cool', 'lopo', 'loopo'],k = 3) == \"look\"\n assert candidate(arr = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba'],k = 25) == \"dabc\"\n assert candidate(arr = ['same', 'word', 'same', 'word', 'same'],k = 2) == \"\"\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],k = 9) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 15) == \"o\"\n assert candidate(arr = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd'],k = 2) == \"\"\n assert candidate(arr = ['abcd', 'ab', 'a', 'abcde', 'abcd', 'abc', 'ab', 'a'],k = 3) == \"\"\n assert candidate(arr = ['aabb', 'abab', 'bbaa', 'abba', 'baab', 'baba', 'aabb', 'abab'],k = 1) == \"bbaa\"\n assert candidate(arr = ['a', 'a', 'a', 'b', 'b', 'c', 'c', 'c', 'c', 'd', 'd', 'd', 'd', 'd'],k = 4) == \"\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],k = 5) == \"five\"\n assert candidate(arr = ['abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba'],k = 20) == \"dacb\"\n assert candidate(arr = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'],k = 10) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 5) == \"e\"\n assert candidate(arr = ['aabb', 'abab', 'abba', 'baab', 'baba', 'bbaa', 'aaaa', 'bbbb', 'cccc', 'dddd'],k = 5) == \"baba\"\n assert candidate(arr = ['aaa', 'aab', 'aac', 'aad', 'aae', 'aaf', 'aag', 'aah', 'aai', 'aaj', 'aak'],k = 10) == \"aaj\"\n assert candidate(arr = ['a', 'ab', 'abc', 'abcd', 'abcde', 'a', 'ab', 'abc', 'abcd'],k = 3) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 10) == \"m\"\n assert candidate(arr = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],k = 1) == \"\"\n assert candidate(arr = ['aaaaa', 'aaaab', 'aaaba', 'aabaa', 'abaaa', 'baaaa', 'abcde', 'bcdea', 'cdeab', 'decab'],k = 8) == \"bcdea\"\n assert candidate(arr = ['abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd'],k = 1) == \"\"\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],k = 5) == \"mno\"\n assert candidate(arr = ['x', 'y', 'x', 'y', 'x', 'y', 'z', 'w', 'z', 'w', 'z', 'w', 'v', 'u', 'v', 'u', 't', 's', 'r', 'q', 'p'],k = 10) == \"\"\n assert candidate(arr = ['abcd', 'dcba', 'adbc', 'bdac', 'cadb', 'dacb', 'abcd', 'dcba'],k = 5) == \"\"\n assert candidate(arr = ['abc', 'def', 'abc', 'def', 'abc', 'def', 'abc', 'def', 'ghi', 'jkl'],k = 3) == \"\"\n assert candidate(arr = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba'],k = 3) == \"\"\n assert candidate(arr = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],k = 5) == \"\"\n", "comparison": "exact"}, "public_tests": ["[\"d\",\"b\",\"c\",\"b\",\"c\",\"a\"]\n2", "[\"aaa\",\"aa\",\"a\"]\n1", "[\"a\",\"b\",\"a\"]\n3"], "hints": ["Try 'mapping' the strings to check if they are unique or not."], "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().kthDistinct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:30+00:00", "tests_total": 110, "tests_dropped": 56, "flags": [], "topic_tags": ["array", "hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def kthDistinct(self, arr: list[str], k: int) -> str:", "container": "Solution", "callable": "kthDistinct", "parameters": [{"name": "arr", "type": "list[str]"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2054, "task_id": "two-best-non-overlapping-events", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 2D integer array of events where events[i] = [startTime_i, endTime_i, value_i]. The i^th event starts at startTime_iand ends at endTime_i, and if you attend this event, you will receive a value of value_i. You can choose at most two non-overlapping events to attend such that the sum of their values is maximized.\n\nReturn this maximum sum.\n\nNote that the start time and end time is inclusive: that is, you cannot attend two events where one of them starts and the other ends at the same time. More specifically, if you attend an event with end time t, the next event must start at or after t + 1.\n\nExample 1:\n\nInput: events = [[1,3,2],[4,5,2],[2,4,3]]\nOutput: 4\nExplanation: Choose the green events, 0 and 1 for a sum of 2 + 2 = 4.\n\nExample 2:\n\nInput: events = [[1,3,2],[4,5,2],[1,5,5]]\nOutput: 5\nExplanation: Choose event 2 for a sum of 5.\n\nExample 3:\n\nInput: events = [[1,5,3],[1,5,1],[6,6,5]]\nOutput: 8\nExplanation: Choose events 0 and 2 for a sum of 3 + 5 = 8.\n\nConstraints:\n\n- 2 <= events.length <= 10^5\n- events[i].length == 3\n- 1 <= startTime_i <= endTime_i <= 10^9\n- 1 <= value_i <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(events = [[1, 1000000000, 1000000], [1000000000, 1000000000, 1000000]]) == 1000000\n assert candidate(events = [[1, 10, 1], [2, 3, 2], [4, 5, 3], [6, 7, 4], [8, 9, 5]]) == 9\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]]) == 19\n assert candidate(events = [[10, 20, 15], [20, 30, 10], [1, 10, 5]]) == 15\n assert candidate(events = [[1, 10, 4], [1, 10, 5], [5, 10, 3]]) == 5\n assert candidate(events = [[1, 3, 2], [4, 5, 2], [2, 4, 3]]) == 4\n assert candidate(events = [[1, 3, 2], [4, 5, 2], [1, 5, 5]]) == 5\n assert candidate(events = [[1, 2, 4], [3, 4, 3], [2, 3, 1]]) == 7\n assert candidate(events = [[1, 5, 3], [1, 5, 1], [6, 6, 5]]) == 8\n assert candidate(events = [[1, 3, 5], [2, 5, 6], [4, 6, 7], [5, 7, 8]]) == 13\n assert candidate(events = [[1, 5, 10], [6, 10, 10], [11, 15, 10], [16, 20, 10]]) == 20\n assert candidate(events = [[2, 2, 1], [3, 3, 2], [4, 4, 3], [5, 5, 4], [6, 6, 5]]) == 9\n assert candidate(events = [[1, 10, 10], [2, 3, 5], [4, 5, 7], [6, 7, 9]]) == 16\n assert candidate(events = [[1, 2, 100], [3, 4, 200], [5, 6, 300], [7, 8, 400], [9, 10, 500], [11, 12, 600]]) == 1100\n assert candidate(events = [[1, 5, 1], [1, 4, 2], [2, 5, 3], [2, 4, 4], [3, 6, 5], [3, 5, 6], [4, 7, 7], [4, 6, 8], [5, 8, 9], [5, 7, 10]]) == 14\n assert candidate(events = [[1, 10, 5], [1, 10, 6], [1, 10, 7], [1, 10, 8], [1, 10, 9]]) == 9\n assert candidate(events = [[1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 2, 4], [1, 2, 5], [1, 2, 6], [1, 2, 7], [1, 2, 8], [1, 2, 9], [1, 2, 10], [1, 2, 11], [1, 2, 12], [1, 2, 13], [1, 2, 14], [1, 2, 15]]) == 15\n assert candidate(events = [[1, 3, 1], [2, 3, 2], [3, 3, 3], [4, 5, 4], [5, 5, 5], [6, 7, 6], [7, 7, 7]]) == 12\n assert candidate(events = [[1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5], [11, 20, 6], [12, 19, 7], [13, 18, 8], [14, 17, 9], [15, 16, 10]]) == 15\n assert candidate(events = [[1, 1000000, 1], [1000001, 2000000, 2], [2000001, 3000000, 3], [3000001, 4000000, 4], [4000001, 5000000, 5], [5000001, 6000000, 6], [6000001, 7000000, 7], [7000001, 8000000, 8], [8000001, 9000000, 9], [9000001, 10000000, 10]]) == 19\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7]]) == 13\n assert candidate(events = [[1, 5, 5], [6, 10, 10], [11, 15, 15], [16, 20, 20], [21, 25, 25]]) == 45\n assert candidate(events = [[1, 2, 100], [3, 4, 200], [5, 6, 300], [7, 8, 400], [9, 10, 500]]) == 900\n assert candidate(events = [[1, 5, 1], [6, 10, 2], [11, 15, 3], [16, 20, 4], [21, 25, 5], [26, 30, 6]]) == 11\n assert candidate(events = [[1, 2, 1000000], [2, 3, 900000], [3, 4, 800000], [4, 5, 700000], [5, 6, 600000], [6, 7, 500000], [7, 8, 400000], [8, 9, 300000], [9, 10, 200000], [10, 11, 100000]]) == 1800000\n assert candidate(events = [[1, 1000000000, 1], [2, 1000000000, 2], [3, 1000000000, 3], [4, 1000000000, 4], [5, 1000000000, 5]]) == 5\n assert candidate(events = [[1, 1000000000, 1], [1000000000, 1000000000, 1000000]]) == 1000000\n assert candidate(events = [[1, 5, 10], [2, 6, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50]]) == 50\n assert candidate(events = [[1, 100, 1], [101, 200, 2], [201, 300, 3], [301, 400, 4], [401, 500, 5], [501, 600, 6], [601, 700, 7], [701, 800, 8], [801, 900, 9], [901, 1000, 10]]) == 19\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500]]) == 800\n assert candidate(events = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40], [5, 5, 50], [6, 6, 60], [7, 7, 70], [8, 8, 80], [9, 9, 90], [10, 10, 100], [11, 11, 110], [12, 12, 120], [13, 13, 130], [14, 14, 140], [15, 15, 150]]) == 290\n assert candidate(events = [[1, 1, 10], [2, 2, 9], [3, 3, 8], [4, 4, 7], [5, 5, 6], [6, 6, 5], [7, 7, 4], [8, 8, 3], [9, 9, 2], [10, 10, 1], [11, 11, 100], [12, 12, 99], [13, 13, 98], [14, 14, 97], [15, 15, 96]]) == 199\n assert candidate(events = [[1, 1, 1000000], [2, 2, 999999], [3, 3, 999998], [4, 4, 999997], [5, 5, 999996]]) == 1999999\n assert candidate(events = [[1, 5, 100], [5, 10, 200], [10, 15, 300], [15, 20, 400], [20, 25, 500], [25, 30, 600], [30, 35, 700], [35, 40, 800], [40, 45, 900], [45, 50, 1000]]) == 1800\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120], [13, 14, 130], [14, 15, 140], [15, 16, 150]]) == 280\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7], [15, 16, 8], [17, 18, 9], [19, 20, 10], [21, 22, 11], [23, 24, 12], [25, 26, 13], [27, 28, 14], [29, 30, 15]]) == 29\n assert candidate(events = [[1, 2, 10], [3, 4, 20], [5, 6, 30], [7, 8, 40], [9, 10, 50], [11, 12, 60], [13, 14, 70], [15, 16, 80], [17, 18, 90], [19, 20, 100], [21, 22, 110], [23, 24, 120], [25, 26, 130], [27, 28, 140], [29, 30, 150]]) == 290\n assert candidate(events = [[1, 2, 1000000], [3, 4, 999999], [5, 6, 999998], [7, 8, 999997], [9, 10, 999996], [11, 12, 999995], [13, 14, 999994], [15, 16, 999993], [17, 18, 999992], [19, 20, 999991]]) == 1999999\n assert candidate(events = [[1, 5, 1000000], [1, 5, 900000], [1, 5, 800000], [1, 5, 700000], [1, 5, 600000], [1, 5, 500000], [1, 5, 400000], [1, 5, 300000], [1, 5, 200000], [1, 5, 100000]]) == 1000000\n assert candidate(events = [[1, 2, 10], [1, 2, 11], [1, 2, 12], [1, 2, 13], [1, 2, 14], [1, 2, 15]]) == 15\n assert candidate(events = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9], [1, 10, 10]]) == 10\n assert candidate(events = [[10, 20, 100], [20, 30, 200], [30, 40, 300], [40, 50, 400], [50, 60, 500], [60, 70, 600]]) == 1000\n assert candidate(events = [[1, 1, 100], [2, 2, 200], [3, 3, 300], [4, 4, 400], [5, 5, 500], [6, 6, 600], [7, 7, 700], [8, 8, 800], [9, 9, 900], [10, 10, 1000]]) == 1900\n assert candidate(events = [[1, 10, 1], [2, 11, 2], [3, 12, 3], [4, 13, 4], [5, 14, 5], [6, 15, 6], [7, 16, 7], [8, 17, 8], [9, 18, 9], [10, 19, 10]]) == 10\n assert candidate(events = [[1, 3, 100], [2, 5, 200], [3, 7, 300], [4, 10, 400], [5, 12, 500], [6, 15, 600], [7, 17, 700], [8, 18, 800], [9, 19, 900]]) == 1200\n assert candidate(events = [[1, 2, 10], [1, 3, 20], [1, 4, 30], [1, 5, 40], [1, 6, 50], [1, 7, 60], [1, 8, 70], [1, 9, 80], [1, 10, 90]]) == 90\n assert candidate(events = [[1, 5, 3], [1, 5, 1], [6, 6, 5], [7, 8, 4]]) == 9\n assert candidate(events = [[1, 5, 1], [2, 6, 2], [3, 7, 3], [4, 8, 4], [5, 9, 5], [6, 10, 6], [7, 11, 7], [8, 12, 8], [9, 13, 9], [10, 14, 10]]) == 15\n assert candidate(events = [[1, 10, 1], [2, 20, 2], [3, 30, 3], [4, 40, 4], [5, 50, 5], [6, 60, 6], [7, 70, 7], [8, 80, 8], [9, 90, 9], [10, 100, 10]]) == 10\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600], [61, 70, 700], [71, 80, 800], [81, 90, 900], [91, 100, 1000], [1, 50, 500000], [51, 100, 500000]]) == 1000000\n assert candidate(events = [[1, 3, 5], [3, 5, 5], [5, 7, 5], [7, 9, 5], [9, 11, 5]]) == 10\n assert candidate(events = [[1, 100, 1], [2, 99, 2], [3, 98, 3], [4, 97, 4], [5, 96, 5], [6, 95, 6], [7, 94, 7], [8, 93, 8], [9, 92, 9], [10, 91, 10]]) == 10\n assert candidate(events = [[1, 5, 10], [2, 6, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50], [6, 10, 60], [7, 11, 70], [8, 12, 80], [9, 13, 90], [10, 14, 100]]) == 150\n assert candidate(events = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1]]) == 2\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50]]) == 80\n assert candidate(events = [[1, 5, 10], [2, 5, 20], [3, 5, 30], [4, 5, 40], [5, 5, 50], [6, 10, 60], [7, 10, 70], [8, 10, 80], [9, 10, 90], [10, 10, 100]]) == 150\n assert candidate(events = [[1, 1, 1000000], [1000000000, 1000000000, 1], [500000000, 500000000, 2], [600000000, 600000000, 3], [700000000, 700000000, 4], [800000000, 800000000, 5]]) == 1000005\n assert candidate(events = [[1, 10, 5], [10, 20, 10], [20, 30, 15], [30, 40, 20], [40, 50, 25], [50, 60, 30], [60, 70, 35], [70, 80, 40], [80, 90, 45], [90, 100, 50]]) == 90\n assert candidate(events = [[1, 1, 1000000], [2, 2, 999999], [3, 3, 999998], [4, 4, 999997], [5, 5, 999996], [6, 6, 999995], [7, 7, 999994], [8, 8, 999993], [9, 9, 999992], [10, 10, 999991]]) == 1999999\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]]) == 28\n assert candidate(events = [[1, 5, 3], [2, 4, 5], [6, 8, 7], [9, 11, 10], [12, 15, 12], [16, 20, 15]]) == 27\n assert candidate(events = [[1, 10, 10], [2, 3, 20], [4, 5, 30], [6, 7, 40], [8, 9, 50], [11, 12, 60]]) == 110\n assert candidate(events = [[1, 10, 10], [11, 20, 20], [21, 30, 30], [31, 40, 40], [41, 50, 50], [51, 60, 60], [61, 70, 70], [71, 80, 80], [81, 90, 90], [91, 100, 100]]) == 190\n assert candidate(events = [[1, 3, 1], [4, 6, 2], [7, 9, 3], [10, 12, 4], [13, 15, 5], [16, 18, 6], [19, 21, 7], [22, 24, 8], [25, 27, 9], [28, 30, 10]]) == 19\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14]]) == 26\n assert candidate(events = [[1, 3, 3], [3, 5, 2], [5, 7, 1], [7, 9, 4], [9, 11, 5], [11, 13, 6]]) == 10\n assert candidate(events = [[1, 2, 5], [3, 4, 10], [5, 6, 15], [7, 8, 20], [9, 10, 25], [11, 12, 30], [13, 14, 35], [15, 16, 40]]) == 75\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7], [15, 16, 8], [17, 18, 9], [19, 20, 10]]) == 19\n assert candidate(events = [[1, 1000000000, 10], [2, 999999999, 20], [3, 999999998, 30], [4, 999999997, 40], [5, 999999996, 50], [6, 999999995, 60], [7, 999999994, 70], [8, 999999993, 80], [9, 999999992, 90], [10, 999999991, 100]]) == 100\n assert candidate(events = [[1, 1, 1000000], [2, 2, 1000000], [3, 3, 1000000], [4, 4, 1000000], [5, 5, 1000000], [6, 6, 1000000], [7, 7, 1000000], [8, 8, 1000000], [9, 9, 1000000], [10, 10, 1000000]]) == 2000000\n assert candidate(events = [[1, 1000000000, 1], [2, 1000000000, 2], [3, 1000000000, 3]]) == 3\n assert candidate(events = [[1, 10, 1], [10, 20, 2], [20, 30, 3], [30, 40, 4], [40, 50, 5], [50, 60, 6], [60, 70, 7], [70, 80, 8], [80, 90, 9], [90, 100, 10], [1, 100, 11], [2, 99, 12], [3, 98, 13], [4, 97, 14], [5, 96, 15]]) == 18\n assert candidate(events = [[1, 3, 2], [2, 4, 3], [3, 5, 4], [4, 6, 5], [5, 7, 6], [6, 8, 7], [7, 9, 8], [8, 10, 9], [9, 11, 10]]) == 17\n assert candidate(events = [[1, 1000000000, 1], [2, 1000000000, 2], [3, 1000000000, 3], [4, 1000000000, 4]]) == 4\n assert candidate(events = [[1, 3, 10], [2, 5, 8], [4, 6, 6], [7, 8, 5], [8, 10, 7], [9, 12, 4]]) == 17\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13], [14, 14, 14], [15, 15, 15]]) == 29\n assert candidate(events = [[1, 2, 50], [3, 4, 60], [5, 6, 70], [7, 8, 80], [9, 10, 90], [11, 12, 100], [13, 14, 110], [15, 16, 120], [17, 18, 130], [19, 20, 140], [21, 22, 150], [23, 24, 160], [25, 26, 170], [27, 28, 180], [29, 30, 190]]) == 370\n assert candidate(events = [[1, 3, 10], [2, 4, 20], [3, 5, 30], [4, 6, 40], [5, 7, 50], [6, 8, 60], [7, 9, 70], [8, 10, 80]]) == 130\n assert candidate(events = [[1, 2, 100], [3, 5, 200], [6, 8, 300], [9, 10, 400], [11, 12, 500]]) == 900\n assert candidate(events = [[1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 2, 4], [1, 2, 5], [1, 2, 6], [1, 2, 7], [1, 2, 8], [1, 2, 9], [1, 2, 10]]) == 10\n assert candidate(events = [[1, 5, 5], [2, 6, 10], [3, 7, 15], [4, 8, 20], [5, 9, 25], [6, 10, 30], [7, 11, 35], [8, 12, 40], [9, 13, 45], [10, 14, 50]]) == 75\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8]]) == 14\n assert candidate(events = [[1, 3, 2], [1, 3, 3], [1, 3, 4], [1, 3, 5], [1, 3, 6], [1, 3, 7], [1, 3, 8], [1, 3, 9], [1, 3, 10], [1, 3, 11], [1, 3, 12], [1, 3, 13], [1, 3, 14], [1, 3, 15], [1, 3, 16]]) == 16\n assert candidate(events = [[1, 1000000000, 1000000], [2, 999999999, 999999], [3, 999999998, 999998]]) == 1000000\n assert candidate(events = [[1, 5, 10], [2, 6, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50], [6, 10, 60], [7, 11, 70], [8, 12, 80], [9, 13, 90], [10, 14, 100], [11, 15, 110], [12, 16, 120], [13, 17, 130], [14, 18, 140], [15, 19, 150]]) == 250\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600], [61, 70, 700], [71, 80, 800], [81, 90, 900], [91, 100, 1000]]) == 1900\n assert candidate(events = [[1, 1000000000, 1000000], [2, 3, 500000], [4, 5, 600000], [6, 7, 400000], [8, 9, 700000], [10, 1000000000, 800000]]) == 1500000\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12]]) == 22\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]]) == 18\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]) == 16\n", "comparison": "exact"}, "public_tests": ["[[1,3,2],[4,5,2],[2,4,3]]", "[[1,3,2],[4,5,2],[1,5,5]]", "[[1,5,3],[1,5,1],[6,6,5]]"], "hints": ["How can sorting the events on the basis of their start times help? How about end times?", "How can we quickly get the maximum score of an interval not intersecting with the interval we chose?"], "metadata": {"canonical_parameter_names": ["events"], "leetcode_dataset_entry_point": "Solution().maxTwoEvents", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:33+00:00", "tests_total": 97, "tests_dropped": 7, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "dynamic-programming", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def maxTwoEvents(self, events: list[list[int]]) -> int:", "container": "Solution", "callable": "maxTwoEvents", "parameters": [{"name": "events", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2055, "task_id": "plates-between-candles", "difficulty": "Medium", "problem_description": "There is a long table with a line of plates and candles arranged on top of it. You are given a 0-indexed string s consisting of characters '*' and '|' only, where a '*' represents a plate and a '|' represents a candle.\n\nYou are also given a 0-indexed 2D integer array queries where queries[i] = [left_i, right_i] denotes the substring s[left_i...right_i] (inclusive). For each query, you need to find the number of plates between candles that are in the substring. A plate is considered between candles if there is at least one candle to its left and at least one candle to its right in the substring.\n\n- For example, s = \"||**||**|*\", and a query [3, 8] denotes the substring \"*||**|\". The number of plates between candles in this substring is 2, as each of the two plates has at least one candle in the substring to its left and right.\n\nReturn an integer array answer where answer[i] is the answer to the i^th query.\n\nExample 1:\n\nInput: s = \"**|**|***|\", queries = [[2,5],[5,9]]\nOutput: [2,3]\nExplanation:\n- queries[0] has two plates between candles.\n- queries[1] has three plates between candles.\n\nExample 2:\n\nInput: s = \"***|**|*****|**||**|*\", queries = [[1,17],[4,5],[14,17],[5,11],[15,16]]\nOutput: [9,0,0,0,0]\nExplanation:\n- queries[0] has nine plates between candles.\n- The other queries have zero plates between candles.\n\nConstraints:\n\n- 3 <= s.length <= 10^5\n- s consists of '*' and '|' characters.\n- 1 <= queries.length <= 10^5\n- queries[i].length == 2\n- 0 <= left_i <= right_i < s.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"**|**|***|\",queries = [[2, 5], [5, 9]]) == [2, 3]\n assert candidate(s = \"***||***\",queries = [[0, 5], [2, 4]]) == [0, 0]\n assert candidate(s = \"*|*|*|*|*|*|*|\",queries = [[0, 7], [1, 6], [2, 5]]) == [3, 2, 1]\n assert candidate(s = \"|||***|||\",queries = [[0, 8], [1, 7], [2, 6]]) == [3, 3, 3]\n assert candidate(s = \"||*|*|*|*|*|*|\",queries = [[0, 10], [1, 9], [2, 8], [3, 7]]) == [4, 4, 2, 2]\n assert candidate(s = \"|||****|****|****||\",queries = [[0, 10], [5, 15], [1, 4]]) == [4, 4, 0]\n assert candidate(s = \"*|*|*|*|*|\",queries = [[0, 5], [1, 4]]) == [2, 1]\n assert candidate(s = \"|*|*|*|*|*|*|*|*|*|*|\",queries = [[0, 10], [1, 9], [2, 8], [3, 7]]) == [5, 3, 3, 1]\n assert candidate(s = \"|||*****|||\",queries = [[0, 2], [3, 8], [7, 10]]) == [0, 0, 0]\n assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|*|\",queries = [[0, 11], [1, 10], [2, 9], [3, 8]]) == [5, 4, 3, 2]\n assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|\",queries = [[0, 10], [1, 9], [2, 8], [3, 7]]) == [4, 4, 2, 2]\n assert candidate(s = \"***|**|*****|**||**|*\",queries = [[1, 17], [4, 5], [14, 17], [5, 11], [15, 16]]) == [9, 0, 0, 0, 0]\n assert candidate(s = \"***||****|**|\",queries = [[0, 4], [5, 8], [9, 11]]) == [0, 0, 0]\n", "comparison": "exact"}, "public_tests": ["\"**|**|***|\"\n[[2,5],[5,9]]", "\"***|**|*****|**||**|*\"\n[[1,17],[4,5],[14,17],[5,11],[15,16]]"], "hints": ["Can you find the indices of the most left and right candles for a given substring, perhaps by using binary search (or better) over an array of indices of all the bars?", "Once the indices of the most left and right bars are determined, how can you efficiently count the number of plates within the range? Prefix sums?"], "metadata": {"canonical_parameter_names": ["s", "queries"], "leetcode_dataset_entry_point": "Solution().platesBetweenCandles", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:35+00:00", "tests_total": 13, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "string", "binary-search", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def platesBetweenCandles(self, s: str, queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "platesBetweenCandles", "parameters": [{"name": "s", "type": "str"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2056, "task_id": "number-of-valid-move-combinations-on-chessboard", "difficulty": "Hard", "problem_description": "There is an 8 x 8 chessboard containing n pieces (rooks, queens, or bishops). You are given a string array pieces of length n, where pieces[i] describes the type (rook, queen, or bishop) of the i^th piece. In addition, you are given a 2D integer array positions also of length n, where positions[i] = [r_i, c_i] indicates that the i^th piece is currently at the 1-based coordinate (r_i, c_i) on the chessboard.\n\nWhen making a move for a piece, you choose a destination square that the piece will travel toward and stop on.\n\n- A rook can only travel horizontally or vertically from (r, c) to the direction of (r+1, c), (r-1, c), (r, c+1), or (r, c-1).\n- A queen can only travel horizontally, vertically, or diagonally from (r, c) to the direction of (r+1, c), (r-1, c), (r, c+1), (r, c-1), (r+1, c+1), (r+1, c-1), (r-1, c+1), (r-1, c-1).\n- A bishop can only travel diagonally from (r, c) to the direction of (r+1, c+1), (r+1, c-1), (r-1, c+1), (r-1, c-1).\n\nYou must make a move for every piece on the board simultaneously. A move combination consists of all the moves performed on all the given pieces. Every second, each piece will instantaneously travel one square towards their destination if they are not already at it. All pieces start traveling at the 0^th second. A move combination is invalid if, at a given time, two or more pieces occupy the same square.\n\nReturn the number of valid move combinations.\n\nNotes:\n\n- No two pieces will start in the same square.\n- You may choose the square a piece is already on as its destination.\n- If two pieces are directly adjacent to each other, it is valid for them to move past each other and swap positions in one second.\n\nExample 1:\n\nInput: pieces = [\"rook\"], positions = [[1,1]]\nOutput: 15\nExplanation: The image above shows the possible squares the piece can move to.\n\nExample 2:\n\nInput: pieces = [\"queen\"], positions = [[1,1]]\nOutput: 22\nExplanation: The image above shows the possible squares the piece can move to.\n\nExample 3:\n\nInput: pieces = [\"bishop\"], positions = [[4,3]]\nOutput: 12\nExplanation: The image above shows the possible squares the piece can move to.\n\nConstraints:\n\n- n == pieces.length\n- n == positions.length\n- 1 <= n <= 4\n- pieces only contains the strings \"rook\", \"queen\", and \"bishop\".\n- There will be at most one queen on the chessboard.\n- 1 <= r_i, c_i <= 8\n- Each positions[i] is distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pieces = ['bishop'],positions = [[4, 3]]) == 12\n assert candidate(pieces = ['queen', 'rook'],positions = [[1, 1], [2, 2]]) == 309\n assert candidate(pieces = ['rook', 'rook'],positions = [[1, 1], [8, 8]]) == 223\n assert candidate(pieces = ['queen', 'rook'],positions = [[2, 2], [5, 5]]) == 340\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[1, 1], [5, 5], [8, 8]]) == 2907\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[1, 1], [2, 2], [3, 3]]) == 3289\n assert candidate(pieces = ['rook', 'rook'],positions = [[1, 1], [1, 3]]) == 189\n assert candidate(pieces = ['rook'],positions = [[1, 1]]) == 15\n assert candidate(pieces = ['rook', 'bishop'],positions = [[1, 1], [4, 3]]) == 173\n assert candidate(pieces = ['bishop', 'bishop'],positions = [[2, 2], [7, 7]]) == 80\n assert candidate(pieces = ['bishop', 'bishop'],positions = [[2, 2], [6, 6]]) == 84\n assert candidate(pieces = ['queen', 'bishop'],positions = [[1, 1], [4, 4]]) == 280\n assert candidate(pieces = ['bishop', 'rook', 'bishop'],positions = [[3, 4], [5, 5], [7, 6]]) == 1265\n assert candidate(pieces = ['queen'],positions = [[1, 1]]) == 22\n assert candidate(pieces = ['rook', 'bishop'],positions = [[1, 1], [4, 4]]) == 205\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[1, 1], [5, 5], [4, 3]]) == 4421\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[1, 1], [2, 2], [4, 3]]) == 3161\n assert candidate(pieces = ['rook', 'bishop', 'rook', 'bishop'],positions = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 16893\n assert candidate(pieces = ['queen', 'rook'],positions = [[1, 1], [8, 8]]) == 327\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[1, 1], [8, 8], [1, 8]]) == 4163\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[3, 3], [5, 5], [7, 2]]) == 3589\n assert candidate(pieces = ['queen', 'bishop', 'bishop'],positions = [[1, 1], [8, 8], [1, 8]]) == 1232\n assert candidate(pieces = ['queen', 'rook', 'bishop', 'rook'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 32176\n assert candidate(pieces = ['queen', 'rook', 'bishop', 'rook'],positions = [[1, 1], [8, 8], [3, 3], [6, 6]]) == 44166\n assert candidate(pieces = ['queen', 'queen'],positions = [[3, 3], [6, 6]]) == 638\n assert candidate(pieces = ['rook', 'rook', 'rook', 'rook'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 33009\n assert candidate(pieces = ['bishop', 'bishop', 'rook', 'rook'],positions = [[1, 1], [8, 8], [4, 4], [5, 5]]) == 7561\n assert candidate(pieces = ['queen', 'bishop', 'rook', 'bishop'],positions = [[1, 1], [8, 8], [4, 4], [4, 1]]) == 15440\n assert candidate(pieces = ['rook', 'rook', 'rook'],positions = [[1, 1], [1, 8], [8, 1]]) == 2753\n assert candidate(pieces = ['rook', 'queen', 'bishop', 'rook'],positions = [[1, 1], [8, 8], [4, 4], [2, 2]]) == 51937\n assert candidate(pieces = ['rook', 'queen', 'bishop', 'rook'],positions = [[1, 1], [5, 5], [8, 8], [8, 1]]) == 38251\n assert candidate(pieces = ['queen', 'rook', 'rook', 'bishop'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 29034\n assert candidate(pieces = ['queen', 'queen', 'rook'],positions = [[3, 3], [4, 4], [2, 2]]) == 8446\n assert candidate(pieces = ['queen', 'bishop', 'rook', 'rook'],positions = [[1, 1], [8, 8], [1, 8], [8, 1]]) == 29034\n assert candidate(pieces = ['queen', 'rook'],positions = [[4, 4], [7, 7]]) == 400\n assert candidate(pieces = ['rook', 'rook', 'bishop'],positions = [[1, 1], [8, 8], [4, 4]]) == 3034\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[2, 2], [7, 7], [3, 8]]) == 2590\n assert candidate(pieces = ['rook', 'rook'],positions = [[4, 4], [5, 5]]) == 193\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[1, 4], [4, 4], [7, 4]]) == 3784\n assert candidate(pieces = ['rook', 'bishop', 'queen'],positions = [[1, 1], [8, 8], [4, 4]]) == 2681\n assert candidate(pieces = ['bishop', 'bishop', 'bishop', 'bishop'],positions = [[2, 2], [2, 7], [7, 2], [7, 7]]) == 6400\n assert candidate(pieces = ['queen', 'bishop', 'rook'],positions = [[8, 1], [1, 8], [4, 4]]) == 2110\n assert candidate(pieces = ['queen', 'bishop', 'rook'],positions = [[2, 2], [3, 3], [5, 5]]) == 3484\n assert candidate(pieces = ['bishop', 'rook', 'queen', 'rook'],positions = [[3, 3], [4, 4], [5, 5], [6, 6]]) == 44433\n assert candidate(pieces = ['queen', 'bishop', 'bishop'],positions = [[1, 1], [3, 3], [6, 6]]) == 2162\n assert candidate(pieces = ['rook', 'queen', 'rook', 'bishop'],positions = [[1, 1], [5, 5], [8, 1], [1, 8]]) == 41166\n assert candidate(pieces = ['rook', 'rook', 'queen'],positions = [[1, 1], [1, 8], [8, 8]]) == 4163\n assert candidate(pieces = ['bishop', 'rook', 'queen'],positions = [[3, 3], [4, 3], [3, 4]]) == 3142\n assert candidate(pieces = ['rook', 'rook', 'bishop', 'bishop'],positions = [[1, 2], [1, 7], [2, 1], [2, 8]]) == 10952\n assert candidate(pieces = ['bishop', 'rook', 'rook', 'bishop'],positions = [[1, 2], [3, 3], [6, 7], [8, 6]]) == 10473\n assert candidate(pieces = ['rook', 'bishop', 'bishop', 'queen'],positions = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 26725\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[1, 1], [8, 8], [4, 4]]) == 4145\n assert candidate(pieces = ['bishop', 'rook', 'queen', 'rook'],positions = [[1, 8], [2, 2], [5, 5], [8, 1]]) == 42649\n assert candidate(pieces = ['queen', 'rook', 'bishop', 'rook'],positions = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 35461\n assert candidate(pieces = ['rook', 'rook', 'rook'],positions = [[1, 1], [2, 2], [3, 3]]) == 2709\n assert candidate(pieces = ['rook', 'bishop'],positions = [[2, 2], [3, 6]]) == 172\n assert candidate(pieces = ['queen', 'queen'],positions = [[1, 1], [8, 8]]) == 462\n assert candidate(pieces = ['rook', 'bishop'],positions = [[1, 1], [8, 1]]) == 118\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[1, 1], [2, 2], [3, 3]]) == 2842\n assert candidate(pieces = ['bishop', 'bishop', 'rook', 'rook'],positions = [[2, 2], [7, 7], [1, 1], [8, 8]]) == 13998\n assert candidate(pieces = ['queen', 'bishop', 'bishop', 'rook'],positions = [[4, 4], [3, 3], [6, 6], [1, 1]]) == 39585\n assert candidate(pieces = ['rook', 'rook', 'rook'],positions = [[1, 1], [8, 8], [4, 4]]) == 3079\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[1, 1], [4, 5], [8, 2]]) == 2308\n assert candidate(pieces = ['bishop', 'bishop'],positions = [[3, 3], [6, 6]]) == 124\n assert candidate(pieces = ['bishop', 'rook', 'rook'],positions = [[1, 1], [8, 1], [8, 8]]) == 1600\n assert candidate(pieces = ['rook', 'rook', 'bishop', 'queen'],positions = [[1, 1], [8, 8], [3, 3], [6, 6]]) == 56730\n assert candidate(pieces = ['rook', 'bishop', 'rook'],positions = [[2, 2], [3, 3], [4, 4]]) == 2185\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[1, 1], [5, 5], [5, 6]]) == 4182\n assert candidate(pieces = ['rook', 'rook', 'bishop', 'bishop'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 12485\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[4, 4], [1, 1], [8, 8]]) == 5890\n assert candidate(pieces = ['bishop', 'bishop', 'rook'],positions = [[2, 2], [7, 7], [1, 8]]) == 1112\n assert candidate(pieces = ['bishop', 'bishop', 'rook', 'rook'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 12485\n assert candidate(pieces = ['bishop', 'rook', 'rook', 'queen'],positions = [[4, 4], [1, 1], [1, 8], [8, 8]]) == 49107\n assert candidate(pieces = ['queen', 'rook', 'bishop', 'rook'],positions = [[3, 3], [5, 5], [2, 2], [6, 6]]) == 37434\n assert candidate(pieces = ['queen', 'bishop'],positions = [[2, 2], [7, 7]]) == 220\n assert candidate(pieces = ['queen', 'queen', 'queen'],positions = [[2, 2], [3, 3], [4, 4]]) == 13103\n assert candidate(pieces = ['queen', 'bishop'],positions = [[1, 1], [8, 8]]) == 156\n assert candidate(pieces = ['queen', 'queen'],positions = [[2, 2], [7, 7]]) == 548\n assert candidate(pieces = ['bishop', 'bishop', 'rook', 'rook'],positions = [[2, 2], [3, 3], [6, 6], [7, 7]]) == 18260\n assert candidate(pieces = ['rook', 'bishop', 'queen'],positions = [[3, 3], [6, 6], [5, 5]]) == 4230\n assert candidate(pieces = ['rook', 'bishop', 'rook', 'bishop'],positions = [[1, 1], [8, 8], [2, 2], [7, 7]]) == 10336\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[1, 1], [1, 8], [8, 1]]) == 4286\n assert candidate(pieces = ['queen', 'rook'],positions = [[4, 4], [8, 1]]) == 412\n assert candidate(pieces = ['rook', 'rook', 'queen', 'bishop'],positions = [[1, 1], [8, 8], [4, 4], [5, 5]]) == 74604\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[5, 5], [1, 1], [8, 8]]) == 5890\n assert candidate(pieces = ['bishop', 'bishop', 'rook'],positions = [[2, 2], [7, 7], [4, 4]]) == 1150\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[4, 4], [1, 1], [8, 8]]) == 2681\n assert candidate(pieces = ['queen', 'bishop', 'rook'],positions = [[3, 3], [6, 6], [1, 1]]) == 4107\n assert candidate(pieces = ['queen', 'queen'],positions = [[1, 2], [8, 7]]) == 476\n assert candidate(pieces = ['queen', 'queen'],positions = [[2, 3], [3, 2]]) == 518\n assert candidate(pieces = ['bishop', 'bishop'],positions = [[1, 1], [8, 8]]) == 44\n assert candidate(pieces = ['bishop', 'bishop', 'bishop'],positions = [[2, 2], [5, 5], [8, 8]]) == 460\n assert candidate(pieces = ['rook', 'rook'],positions = [[1, 1], [1, 8]]) == 205\n assert candidate(pieces = ['rook', 'rook', 'bishop'],positions = [[1, 1], [8, 1], [4, 4]]) == 2764\n assert candidate(pieces = ['queen', 'queen', 'rook'],positions = [[1, 1], [8, 8], [4, 4]]) == 6380\n assert candidate(pieces = ['rook', 'queen', 'bishop', 'rook'],positions = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 41894\n assert candidate(pieces = ['queen', 'rook'],positions = [[1, 1], [8, 1]]) == 309\n assert candidate(pieces = ['bishop', 'bishop', 'bishop'],positions = [[2, 3], [4, 5], [6, 7]]) == 728\n assert candidate(pieces = ['bishop', 'bishop', 'bishop'],positions = [[2, 2], [4, 4], [6, 6]]) == 792\n", "comparison": "exact"}, "public_tests": ["[\"rook\"]\n[[1,1]]", "[\"queen\"]\n[[1,1]]", "[\"bishop\"]\n[[4,3]]"], "hints": ["N is small, we can generate all possible move combinations.", "For each possible move combination, determine which ones are valid."], "metadata": {"canonical_parameter_names": ["pieces", "positions"], "leetcode_dataset_entry_point": "Solution().countCombinations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:38+00:00", "tests_total": 100, "tests_dropped": 1, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "string", "backtracking", "simulation"]}, "language": "python", "interface": {"raw_signature": "def countCombinations(self, pieces: list[str], positions: list[list[int]]) -> int:", "container": "Solution", "callable": "countCombinations", "parameters": [{"name": "pieces", "type": "list[str]"}, {"name": "positions", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2057, "task_id": "smallest-index-with-equal-value", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums, return the smallest index i of nums such that i mod 10 == nums[i], or -1 if such index does not exist.\n\nx mod y denotes the remainder when x is divided by y.\n\nExample 1:\n\nInput: nums = [0,1,2]\nOutput: 0\nExplanation:\ni=0: 0 mod 10 = 0 == nums[0].\ni=1: 1 mod 10 = 1 == nums[1].\ni=2: 2 mod 10 = 2 == nums[2].\nAll indices have i mod 10 == nums[i], so we return the smallest index 0.\n\nExample 2:\n\nInput: nums = [4,3,2,1]\nOutput: 2\nExplanation:\ni=0: 0 mod 10 = 0 != nums[0].\ni=1: 1 mod 10 = 1 != nums[1].\ni=2: 2 mod 10 = 2 == nums[2].\ni=3: 3 mod 10 = 3 != nums[3].\n2 is the only index which has i mod 10 == nums[i].\n\nExample 3:\n\nInput: nums = [1,2,3,4,5,6,7,8,9,0]\nOutput: -1\nExplanation: No index satisfies i mod 10 == nums[i].\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 0 <= nums[i] <= 9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 5, 0, 5, 0, 5, 0, 5, 0, 5]) == 0\n assert candidate(nums = [4, 3, 2, 1]) == 2\n assert candidate(nums = [7, 8, 9, 0, 1, 2, 3, 4, 5, 6]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9]) == 9\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n assert candidate(nums = [3, 6, 9, 2, 5, 8, 1, 4, 7, 0]) == -1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [3, 0, 1, 4, 2, 5, 9, 6, 7, 8]) == 5\n assert candidate(nums = [0, 1, 2]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 4\n assert candidate(nums = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5, 0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == 0\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7]) == 3\n assert candidate(nums = [0, 2, 4, 6, 8, 0, 2, 4, 6, 8]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9]) == 9\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == -1\n assert candidate(nums = [4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5]) == 2\n assert candidate(nums = [6, 3, 8, 6, 2, 9, 1, 3, 4, 7, 6, 3, 8, 6, 2, 9, 1, 3, 4, 7]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3]) == 1\n assert candidate(nums = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == -1\n assert candidate(nums = [1, 3, 5, 7, 9, 0, 2, 4, 6, 8, 1, 3, 5, 7, 9, 0, 2, 4, 6, 8, 1, 3, 5, 7, 9, 0, 2, 4, 6, 8]) == -1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == -1\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9]) == 4\n assert candidate(nums = [4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 9\n assert candidate(nums = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2]) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == -1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 4\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [9, 0, 9, 0, 9, 0, 9, 0, 9, 0]) == -1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 3\n assert candidate(nums = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == -1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(nums = [1, 0, 9, 8, 7, 6, 5, 4, 3, 2]) == -1\n assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == -1\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [8, 6, 4, 2, 0, 9, 7, 5, 3, 1]) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [6, 3, 9, 2, 4, 1, 5, 8, 0, 7, 6, 3, 9, 2, 4, 1, 5, 8, 0, 7, 6, 3, 9, 2, 4, 1, 5, 8, 0, 7, 6, 3, 9, 2, 4, 1, 5, 8, 0, 7]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n", "comparison": "exact"}, "public_tests": ["[0,1,2]", "[4,3,2,1]", "[1,2,3,4,5,6,7,8,9,0]"], "hints": ["Starting with i=0, check the condition for each index. The first one you find to be true is the smallest index."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().smallestEqual", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:40+00:00", "tests_total": 98, "tests_dropped": 12, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def smallestEqual(self, nums: list[int]) -> int:", "container": "Solution", "callable": "smallestEqual", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2059, "task_id": "minimum-operations-to-convert-number", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the number x:\n\nIf 0 <= x <= 1000, then for any index i in the array (0 <= i < nums.length), you can set x to any of the following:\n\n- x + nums[i]\n- x - nums[i]\n- x ^ nums[i] (bitwise-XOR)\n\nNote that you can use each nums[i] any number of times in any order. Operations that set x to be out of the range 0 <= x <= 1000 are valid, but no more operations can be done afterward.\n\nReturn the minimum number of operations needed to convert x = start into goal, and -1 if it is not possible.\n\nExample 1:\n\nInput: nums = [2,4,12], start = 2, goal = 12\nOutput: 2\nExplanation: We can go from 2 → 14 → 12 with the following 2 operations.\n- 2 + 12 = 14\n- 14 - 2 = 12\n\nExample 2:\n\nInput: nums = [3,5,7], start = 0, goal = -4\nOutput: 2\nExplanation: We can go from 0 → 3 → -4 with the following 2 operations.\n- 0 + 3 = 3\n- 3 - 7 = -4\nNote that the last operation sets x out of the range 0 <= x <= 1000, which is valid.\n\nExample 3:\n\nInput: nums = [2,8,16], start = 0, goal = 1\nOutput: -1\nExplanation: There is no way to convert 0 into 1.\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- -10^9 <= nums[i], goal <= 10^9\n- 0 <= start <= 1000\n- start != goal\n- All the integers in nums are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30],start = 100,goal = 50) == 2\n assert candidate(nums = [5, 15, 25],start = 10,goal = 30) == 2\n assert candidate(nums = [10, 20, 30],start = 100,goal = 300) == 7\n assert candidate(nums = [1, 3, 5, 7, 9],start = 0,goal = 10) == 2\n assert candidate(nums = [1, 3, 5, 7, 9],start = 1000,goal = 0) == 112\n assert candidate(nums = [10, 20, 30, 40, 50],start = 100,goal = 0) == 2\n assert candidate(nums = [10, 20, 30],start = 100,goal = 200) == 4\n assert candidate(nums = [500, 501, 502],start = 500,goal = 505) == 4\n assert candidate(nums = [1000, -1000, 500],start = 0,goal = 1000) == 1\n assert candidate(nums = [7, 14, 28],start = 1,goal = 28) == 4\n assert candidate(nums = [100, 200, 300],start = 100,goal = 1000) == 3\n assert candidate(nums = [100, 200, 300],start = 500,goal = 1000) == 2\n assert candidate(nums = [1],start = 0,goal = 1000) == 1000\n assert candidate(nums = [7, 14, 21],start = 7,goal = 0) == 1\n assert candidate(nums = [1000],start = 1000,goal = 0) == 1\n assert candidate(nums = [2, 4, 12],start = 2,goal = 12) == 2\n assert candidate(nums = [1, 1000],start = 0,goal = 1001) == 2\n assert candidate(nums = [-1, -2, -3],start = 5,goal = -5) == 1\n assert candidate(nums = [100, 200, 300],start = 500,goal = 100) == 2\n assert candidate(nums = [1, 1000],start = 500,goal = 1500) == 1\n assert candidate(nums = [3, 5, 7],start = 0,goal = -4) == 2\n assert candidate(nums = [1, 2, 3],start = 1000,goal = 0) == 334\n assert candidate(nums = [10, 20, 30],start = 50,goal = 110) == 2\n assert candidate(nums = [2, 8, 16],start = 0,goal = 1) == -1\n assert candidate(nums = [1000, 500, 250],start = 1,goal = 1000) == -1\n assert candidate(nums = [1, 2, 3, 4, 5],start = 1,goal = 5) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],start = 5,goal = 0) == 1\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 50,goal = 1000) == 10\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],start = 1,goal = 1000) == 3\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],start = 1000,goal = 0) == 22\n assert candidate(nums = [128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],start = 500,goal = 1000) == -1\n assert candidate(nums = [256, 512, 768, 1024],start = 0,goal = 1024) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 500,goal = 1) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 10,goal = 1000) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],start = 1000,goal = 0) == 20\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],start = 500,goal = 1000) == 6\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113],start = 0,goal = 999) == 9\n assert candidate(nums = [13, 21, 34, 55, 89, 144, 233, 377, 610, 987],start = 500,goal = 1000) == 3\n assert candidate(nums = [256, 128, 64, 32, 16, 8, 4, 2, 1],start = 500,goal = 999) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],start = 1000,goal = 0) == 18\n assert candidate(nums = [999, 1, 2, 3, 4, 5],start = 0,goal = 999) == 1\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],start = 512,goal = 0) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 5,goal = 100) == 10\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],start = 50,goal = 999) == 10\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],start = 1,goal = 98) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 100,goal = 1000) == 48\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],start = 500,goal = 1000) == 17\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 100,goal = 256) == 3\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 25,goal = 1000) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],start = 1,goal = 999) == 36\n assert candidate(nums = [10, 20, 30, 40, 50],start = 500,goal = -100) == -1\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29],start = 1,goal = 999) == 36\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],start = 50,goal = 999) == 21\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 500,goal = 0) == 5\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31],start = 1,goal = 1000) == 33\n assert candidate(nums = [13, 19, 23, 29, 31, 37, 41, 43, 47, 53],start = 200,goal = 300) == 2\n assert candidate(nums = [1, 10, 100, 1000],start = 1,goal = 1000) == 2\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 500,goal = 0) == 3\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 100,goal = 1000) == 10\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41],start = 100,goal = 999) == 23\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],start = 10,goal = 1000) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 1,goal = 1000) == 5\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900],start = 0,goal = 1000) == 2\n assert candidate(nums = [333, 667, 999],start = 1,goal = 999) == 2\n assert candidate(nums = [999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008],start = 1,goal = 1000) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 0,goal = 1000) == 4\n assert candidate(nums = [64, 128, 256, 512],start = 100,goal = 1024) == -1\n assert candidate(nums = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144],start = 10,goal = 200) == 3\n assert candidate(nums = [123, 456, 789],start = 321,goal = 654) == 2\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 1000,goal = 0) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290],start = 50,goal = 1000) == 4\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],start = 100,goal = 0) == 3\n assert candidate(nums = [999, 1000, 1001, 1002, 1003],start = 500,goal = 1500) == 1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],start = 100,goal = 200) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 0,goal = 500) == 5\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 500,goal = 1000) == 1\n assert candidate(nums = [100, 200, 300, 400, 500],start = 10,goal = 999) == -1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],start = 100,goal = 999) == 31\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110],start = 100,goal = 1000) == 9\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1000],start = 500,goal = 1500) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 100,goal = 2048) == -1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 100,goal = 511) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 50,goal = 1000) == 10\n assert candidate(nums = [123, 456, 789],start = 100,goal = 900) == 6\n assert candidate(nums = [29, 31, 37, 41, 43, 47, 53, 59, 61, 67],start = 5,goal = 1000) == 15\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 50,goal = 500) == 6\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],start = 1,goal = 1000000000) == 2\n assert candidate(nums = [333, 667, 999],start = 500,goal = 1000) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 500,goal = 400) == 6\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99],start = 500,goal = 200) == 4\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],start = 200,goal = 500) == 8\n assert candidate(nums = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26],start = 500,goal = 550) == 2\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],start = 1,goal = 1000) == 11\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 50,goal = 990) == 10\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 100,goal = -100) == -1\n assert candidate(nums = [13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],start = 500,goal = 999) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 0,goal = 500) == 10\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],start = 100,goal = 1000) == 10\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 50,goal = 999) == 11\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 500,goal = 1024) == 3\n assert candidate(nums = [100, 200, 300, 400, 500],start = 999,goal = 1) == -1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 512,goal = 1000) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 50,goal = 150) == 1\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],start = 50,goal = 987) == 3\n assert candidate(nums = [23, 45, 67, 89, 101],start = 100,goal = 1) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 500,goal = 1024) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 1,goal = 999) == 54\n assert candidate(nums = [100, 200, 300, 400, 500],start = 100,goal = 500) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 500,goal = 1005) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 1,goal = 1001) == 100\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],start = 1,goal = 999) == 1\n assert candidate(nums = [100, 200, 300, 400, 500],start = 50,goal = 500) == -1\n assert candidate(nums = [-1, 1, -2, 2, -4, 4, -8, 8, -16, 16],start = 500,goal = 1) == 33\n assert candidate(nums = [666, 333, 111, 777, 888, 999, 222, 444, 555],start = 111,goal = 777) == 1\n assert candidate(nums = [-100, -50, -25, 0, 25, 50, 100],start = 50,goal = 250) == 2\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],start = 1,goal = 1000) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],start = 1000,goal = 1) == 50\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],start = 10,goal = 99) == 4\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 500,goal = 999) == 4\n", "comparison": "exact"}, "public_tests": ["[2,4,12]\n2\n12", "[3,5,7]\n0\n-4", "[2,8,16]\n0\n1"], "hints": ["Once x drops below 0 or goes above 1000, is it possible to continue performing operations on x?", "How can you use BFS to find the minimum operations?"], "metadata": {"canonical_parameter_names": ["nums", "start", "goal"], "leetcode_dataset_entry_point": "Solution().minimumOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:44+00:00", "tests_total": 134, "tests_dropped": 15, "flags": [], "topic_tags": ["array", "breadth-first-search"]}, "language": "python", "interface": {"raw_signature": "def minimumOperations(self, nums: list[int], start: int, goal: int) -> int:", "container": "Solution", "callable": "minimumOperations", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "start", "type": "int"}, {"name": "goal", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2060, "task_id": "check-if-an-original-string-exists-given-two-encoded-strings", "difficulty": "Hard", "problem_description": "An original string, consisting of lowercase English letters, can be encoded by the following steps:\n\n- Arbitrarily split it into a sequence of some number of non-empty substrings.\n- Arbitrarily choose some elements (possibly none) of the sequence, and replace each with its length (as a numeric string).\n- Concatenate the sequence as the encoded string.\n\nFor example, one way to encode an original string \"abcdefghijklmnop\" might be:\n\n- Split it as a sequence: [\"ab\", \"cdefghijklmn\", \"o\", \"p\"].\n- Choose the second and third elements to be replaced by their lengths, respectively. The sequence becomes [\"ab\", \"12\", \"1\", \"p\"].\n- Concatenate the elements of the sequence to get the encoded string: \"ab121p\".\n\nGiven two encoded strings s1 and s2, consisting of lowercase English letters and digits 1-9 (inclusive), return true if there exists an original string that could be encoded as both s1 and s2. Otherwise, return false.\n\nNote: The test cases are generated such that the number of consecutive digits in s1 and s2 does not exceed 3.\n\nExample 1:\n\nInput: s1 = \"internationalization\", s2 = \"i18n\"\nOutput: true\nExplanation: It is possible that \"internationalization\" was the original string.\n- \"internationalization\"\n -> Split: [\"internationalization\"]\n -> Do not replace any element\n -> Concatenate: \"internationalization\", which is s1.\n- \"internationalization\"\n -> Split: [\"i\", \"nternationalizatio\", \"n\"]\n -> Replace: [\"i\", \"18\", \"n\"]\n -> Concatenate: \"i18n\", which is s2\n\nExample 2:\n\nInput: s1 = \"l123e\", s2 = \"44\"\nOutput: true\nExplanation: It is possible that \"leetcode\" was the original string.\n- \"leetcode\"\n -> Split: [\"l\", \"e\", \"et\", \"cod\", \"e\"]\n -> Replace: [\"l\", \"1\", \"2\", \"3\", \"e\"]\n -> Concatenate: \"l123e\", which is s1.\n- \"leetcode\"\n -> Split: [\"leet\", \"code\"]\n -> Replace: [\"4\", \"4\"]\n -> Concatenate: \"44\", which is s2.\n\nExample 3:\n\nInput: s1 = \"a5b\", s2 = \"c5b\"\nOutput: false\nExplanation: It is impossible.\n- The original string encoded as s1 must start with the letter 'a'.\n- The original string encoded as s2 must start with the letter 'c'.\n\nConstraints:\n\n- 1 <= s1.length, s2.length <= 40\n- s1 and s2 consist of digits 1-9 (inclusive), and lowercase English letters only.\n- The number of consecutive digits in s1 and s2 does not exceed 3.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"a1b\",s2 = \"a1b1\") == False\n assert candidate(s1 = \"ab123cd\",s2 = \"a3bcd\") == False\n assert candidate(s1 = \"ab123cd\",s2 = \"abc5\") == False\n assert candidate(s1 = \"123\",s2 = \"onetwothree\") == False\n assert candidate(s1 = \"1a\",s2 = \"a\") == False\n assert candidate(s1 = \"a9b\",s2 = \"a10b\") == False\n assert candidate(s1 = \"a1b1c1d1\",s2 = \"abcd\") == False\n assert candidate(s1 = \"a1a1a1\",s2 = \"a3a3\") == False\n assert candidate(s1 = \"a1b1\",s2 = \"ab\") == False\n assert candidate(s1 = \"a5b\",s2 = \"c5b\") == False\n assert candidate(s1 = \"abc\",s2 = \"3\") == True\n assert candidate(s1 = \"h3ll0\",s2 = \"hello\") == False\n assert candidate(s1 = \"123\",s2 = \"3\") == False\n assert candidate(s1 = \"a1b2c3\",s2 = \"a1b23c\") == True\n assert candidate(s1 = \"internationalization\",s2 = \"i18n\") == True\n assert candidate(s1 = \"a1b\",s2 = \"ab\") == False\n assert candidate(s1 = \"a1b2c3\",s2 = \"a1b5\") == False\n assert candidate(s1 = \"z1x2c3v\",s2 = \"zx9\") == False\n assert candidate(s1 = \"a1b2c3d4\",s2 = \"a1b2c34d\") == True\n assert candidate(s1 = \"1a1b1c\",s2 = \"3abc\") == False\n assert candidate(s1 = \"a\",s2 = \"1\") == True\n assert candidate(s1 = \"ab1\",s2 = \"a1b\") == True\n assert candidate(s1 = \"123\",s2 = \"321\") == True\n assert candidate(s1 = \"ab\",s2 = \"a2\") == False\n assert candidate(s1 = \"a2b\",s2 = \"aaab\") == True\n assert candidate(s1 = \"a1b1\",s2 = \"2\") == False\n assert candidate(s1 = \"a1b2c3\",s2 = \"abc6\") == False\n assert candidate(s1 = \"abc\",s2 = \"abc\") == True\n assert candidate(s1 = \"hello\",s2 = \"5\") == True\n assert candidate(s1 = \"l123e\",s2 = \"44\") == True\n assert candidate(s1 = \"123abc\",s2 = \"3abc\") == False\n assert candidate(s1 = \"a5b5c5\",s2 = \"abc15\") == True\n assert candidate(s1 = \"a2b2c2\",s2 = \"aabbcc\") == False\n assert candidate(s1 = \"abc12def45\",s2 = \"abcdef123\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i\",s2 = \"abcdefghi\") == False\n assert candidate(s1 = \"x9y8z7\",s2 = \"xyz321\") == True\n assert candidate(s1 = \"a1b2c3\",s2 = \"abc123\") == False\n assert candidate(s1 = \"123abc456\",s2 = \"9abc10\") == False\n assert candidate(s1 = \"123456\",s2 = \"654321\") == True\n assert candidate(s1 = \"abcdefghij123456789012\",s2 = \"abcdefghij123456789012\") == True\n assert candidate(s1 = \"1a2b3c4d\",s2 = \"aabbcccdddd\") == False\n assert candidate(s1 = \"abc12def45\",s2 = \"abcdef19\") == False\n assert candidate(s1 = \"abc1def2ghi3\",s2 = \"a1b1c1d1e1f1g1h1i1\") == False\n assert candidate(s1 = \"a1b1c1\",s2 = \"abc1\") == False\n assert candidate(s1 = \"1a2b3c4d\",s2 = \"1234abcd\") == True\n assert candidate(s1 = \"11a2b\",s2 = \"aaaaaaaaaab\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j0\",s2 = \"abcdefghij10\") == False\n assert candidate(s1 = \"abcdefghij123456789\",s2 = \"abcdefghij1234567891\") == False\n assert candidate(s1 = \"a5b5c5d5e5\",s2 = \"abcde25\") == True\n assert candidate(s1 = \"a2b3c4d5e6f7g8h9i10\",s2 = \"abcdefghi10\") == False\n assert candidate(s1 = \"abcdefghij1234567890\",s2 = \"abcdefghij123456789\") == True\n assert candidate(s1 = \"abc123def\",s2 = \"abc12def3\") == True\n assert candidate(s1 = \"a12b34c56\",s2 = \"a12b34c56\") == True\n assert candidate(s1 = \"l10n\",s2 = \"leetcode\") == False\n assert candidate(s1 = \"1a2b3c4d5e\",s2 = \"a1b2c3d4e5\") == True\n assert candidate(s1 = \"123abc\",s2 = \"321cba\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i10j\",s2 = \"abcdefghij1\") == False\n assert candidate(s1 = \"a4b2c3\",s2 = \"aaaaabbbccc\") == False\n assert candidate(s1 = \"a3b\",s2 = \"aaab\") == False\n assert candidate(s1 = \"a2b3c4\",s2 = \"aaabbbcccc\") == False\n assert candidate(s1 = \"a2b3c\",s2 = \"aabbccc\") == False\n assert candidate(s1 = \"abc123def456ghi789\",s2 = \"abcdef789ghi123456\") == True\n assert candidate(s1 = \"a2b3c4\",s2 = \"a9\") == False\n assert candidate(s1 = \"abc123def\",s2 = \"abcdef123\") == True\n assert candidate(s1 = \"123abc\",s2 = \"12abc3\") == True\n assert candidate(s1 = \"111abc222def333\",s2 = \"333abc222def111\") == True\n assert candidate(s1 = \"abcdefghij1234567891\",s2 = \"abcdefghij123456789\") == False\n assert candidate(s1 = \"12abc\",s2 = \"a1b2c\") == True\n assert candidate(s1 = \"x1y2z3\",s2 = \"xyz123\") == False\n assert candidate(s1 = \"11abc\",s2 = \"abcdefghij1\") == False\n assert candidate(s1 = \"a5b5c5\",s2 = \"aaaaabbbbbccccc\") == False\n assert candidate(s1 = \"a5b3c2d\",s2 = \"abc10d\") == True\n assert candidate(s1 = \"9z\",s2 = \"zzzzzzzzz\") == False\n assert candidate(s1 = \"a1b2c3d4e5\",s2 = \"a1b2c3d4e5\") == True\n assert candidate(s1 = \"a1b1c1\",s2 = \"a1b1c1d0\") == False\n assert candidate(s1 = \"a12b\",s2 = \"aaaaaaaaaaaaab\") == True\n assert candidate(s1 = \"abcde123fghi\",s2 = \"abcdefghi123\") == True\n assert candidate(s1 = \"abc123def456\",s2 = \"abcdef123456\") == True\n assert candidate(s1 = \"123abc123\",s2 = \"321cba321\") == True\n assert candidate(s1 = \"abcdefghij1234567891\",s2 = \"abcdefghij1234567891\") == True\n assert candidate(s1 = \"a2b3c4\",s2 = \"ab2c3d4\") == False\n assert candidate(s1 = \"123abc\",s2 = \"15c\") == False\n assert candidate(s1 = \"abc12def\",s2 = \"a15f\") == False\n assert candidate(s1 = \"l123e\",s2 = \"leetcode\") == True\n assert candidate(s1 = \"abc12def\",s2 = \"abcdefghijkl\") == False\n assert candidate(s1 = \"1234\",s2 = \"1234\") == True\n assert candidate(s1 = \"abc12\",s2 = \"ab11c\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i10j\",s2 = \"abcdefghij10\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10\",s2 = \"abcdefghij10\") == False\n assert candidate(s1 = \"12ab3c\",s2 = \"a1b2c3\") == True\n assert candidate(s1 = \"abc1def2ghi3jkl4mno5pqr6stu7vwx8yz9\",s2 = \"a1b2c3d4e5f6g7h8i9jklmnopqrstuvwxyz\") == False\n assert candidate(s1 = \"a1b2c3d4\",s2 = \"a111b1111c11111d111111\") == False\n assert candidate(s1 = \"a9b8c7d6e5f4g3h2i1\",s2 = \"abcdefghi123456789\") == True\n assert candidate(s1 = \"abcdefghij123456789\",s2 = \"abcdefghij1234567890\") == True\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1\",s2 = \"abcdefghij\") == False\n assert candidate(s1 = \"abcde1234567890\",s2 = \"0987654321edcba\") == True\n assert candidate(s1 = \"1a1b1c\",s2 = \"abc1\") == False\n assert candidate(s1 = \"abcd1234\",s2 = \"a3b2cd4\") == False\n assert candidate(s1 = \"ab1cd2ef3\",s2 = \"a1b1c1d1e1f1\") == False\n assert candidate(s1 = \"l10n\",s2 = \"leet1c2d\") == False\n assert candidate(s1 = \"1a2b3c4d5e\",s2 = \"11111\") == False\n assert candidate(s1 = \"123456789\",s2 = \"abcdefghi9\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i10\",s2 = \"abcdefghij10\") == False\n assert candidate(s1 = \"a9b\",s2 = \"aaaaaaaaaab\") == True\n assert candidate(s1 = \"l10e\",s2 = \"leetcode\") == False\n assert candidate(s1 = \"12ab34cd56\",s2 = \"15abcd\") == False\n assert candidate(s1 = \"123abc\",s2 = \"abc123\") == True\n assert candidate(s1 = \"abcdefghij12345678901234\",s2 = \"abcdefghij12345678901234\") == True\n assert candidate(s1 = \"leetcode\",s2 = \"l2e8\") == False\n assert candidate(s1 = \"a1b2c3\",s2 = \"a12b3c\") == True\n assert candidate(s1 = \"1a2b3c\",s2 = \"6\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i10j11k12\",s2 = \"abcdefghijk11lm12\") == False\n assert candidate(s1 = \"123abc456def789ghi101112\",s2 = \"123abc456def789ghi101112\") == True\n assert candidate(s1 = \"123abc456\",s2 = \"9abc101\") == False\n assert candidate(s1 = \"1a2a3a4a5a6a7a8a9a\",s2 = \"aaaaaaaaaab\") == False\n assert candidate(s1 = \"abcdefghij123456789\",s2 = \"abcdefghij123456789\") == True\n assert candidate(s1 = \"a1b2c3d4\",s2 = \"abcd\") == False\n assert candidate(s1 = \"a9b9c\",s2 = \"abcdefghiabcdefghi\") == False\n assert candidate(s1 = \"abc123\",s2 = \"a1b1c123\") == False\n assert candidate(s1 = \"abcdefghij123456789\",s2 = \"abcdefghij12345678\") == True\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9\",s2 = \"abcdefghi\") == False\n assert candidate(s1 = \"abc11\",s2 = \"abcdefghij1\") == False\n assert candidate(s1 = \"abcdefghij1234567890123\",s2 = \"abcdefghij1234567890123\") == True\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\",s2 = \"abcdefghijklmnopqrst1020\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1\",s2 = \"abcdefghi1\") == False\n assert candidate(s1 = \"a5b2c3\",s2 = \"aaaaaaaaabbccc\") == False\n assert candidate(s1 = \"a5b5c5d5\",s2 = \"10abcde5\") == False\n assert candidate(s1 = \"abcde123\",s2 = \"a4bcd3\") == True\n assert candidate(s1 = \"abc123\",s2 = \"123abc\") == True\n assert candidate(s1 = \"a12b3c4\",s2 = \"a1b22c4\") == False\n assert candidate(s1 = \"1a2b3c\",s2 = \"a1b2c3\") == True\n assert candidate(s1 = \"abc123def\",s2 = \"a1b1c3d4e5f6\") == False\n assert candidate(s1 = \"9a9b9c9d\",s2 = \"81abcd\") == False\n assert candidate(s1 = \"x9y9z9\",s2 = \"xxxxxxxxxxxyyyyyyyyzzzzzzzzz\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15\",s2 = \"abcdefghijklmnop123456789101112131415\") == False\n assert candidate(s1 = \"abc1def2ghi3\",s2 = \"abcdefghi\") == False\n assert candidate(s1 = \"a9b9c9\",s2 = \"aaaaaaaaabbbbbbbbcccccccccc\") == False\n assert candidate(s1 = \"abc123\",s2 = \"a1b2c3123\") == False\n assert candidate(s1 = \"a1b1c\",s2 = \"abc\") == False\n assert candidate(s1 = \"a1b2c3d4\",s2 = \"abcd10\") == False\n assert candidate(s1 = \"a2b3c4d5e6f7g8h9i10j11\",s2 = \"abcdefghij10jk11\") == False\n assert candidate(s1 = \"abcdefghij12345678901\",s2 = \"abcdefghij12345678901\") == True\n assert candidate(s1 = \"a1b2c3d4e5\",s2 = \"15\") == False\n assert candidate(s1 = \"1a2b3c\",s2 = \"abc123\") == False\n assert candidate(s1 = \"ab3c\",s2 = \"abc3\") == True\n assert candidate(s1 = \"abcde12345\",s2 = \"abcde54321\") == True\n assert candidate(s1 = \"abc1def2ghi3\",s2 = \"abcdefg1h1i\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11\",s2 = \"abcdefghijk11\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11\",s2 = \"abcdefghijk123\") == False\n assert candidate(s1 = \"abcdefghij1234567890\",s2 = \"abcdefghij1234567890\") == True\n assert candidate(s1 = \"a10b\",s2 = \"aaaaaaaaaab\") == False\n", "comparison": "exact"}, "public_tests": ["\"internationalization\"\n\"i18n\"", "\"l123e\"\n\"44\"", "\"a5b\"\n\"c5b\""], "hints": ["For s1 and s2, divide each into a sequence of single alphabet strings and digital strings. The problem now becomes comparing if two sequences are equal.", "A single alphabet string has no variation, but a digital string has variations. For example: \"124\" can be interpreted as 1+2+4, 12+4, 1+24, and 124 wildcard characters.", "There are four kinds of comparisons: a single alphabet vs another; a single alphabet vs a number, a number vs a single alphabet, and a number vs another number. In the case of a number vs another (a single alphabet or a number), can you decrease the number by the min length of both?", "There is a recurrence relation in the search which ends when either a single alphabet != another, or one sequence ran out, or both sequences ran out."], "metadata": {"canonical_parameter_names": ["s1", "s2"], "leetcode_dataset_entry_point": "Solution().possiblyEquals", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:47+00:00", "tests_total": 195, "tests_dropped": 44, "flags": [], "topic_tags": ["string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def possiblyEquals(self, s1: str, s2: str) -> bool:", "container": "Solution", "callable": "possiblyEquals", "parameters": [{"name": "s1", "type": "str"}, {"name": "s2", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2062, "task_id": "count-vowel-substrings-of-a-string", "difficulty": "Easy", "problem_description": "A substring is a contiguous (non-empty) sequence of characters within a string.\n\nA vowel substring is a substring that only consists of vowels ('a', 'e', 'i', 'o', and 'u') and has all five vowels present in it.\n\nGiven a string word, return the number of vowel substrings in word.\n\nExample 1:\n\nInput: word = \"aeiouu\"\nOutput: 2\nExplanation: The vowel substrings of word are as follows (underlined):\n- \"aeiouu\"\n- \"aeiouu\"\n\nExample 2:\n\nInput: word = \"unicornarihan\"\nOutput: 0\nExplanation: Not all 5 vowels are present, so there are no vowel substrings.\n\nExample 3:\n\nInput: word = \"cuaieuouac\"\nOutput: 7\nExplanation: The vowel substrings of word are as follows (underlined):\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n\nConstraints:\n\n- 1 <= word.length <= 100\n- word consists of lowercase English letters only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aeiou\") == 1\n assert candidate(word = \"aeiofvuaeiou\") == 3\n assert candidate(word = \"uoiea\") == 1\n assert candidate(word = \"aeiouxaeeiaouoieua\") == 28\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiu\") == 175\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuoo\") == 55\n assert candidate(word = \"aeiouaeiouaeiou\") == 66\n assert candidate(word = \"unicornarihan\") == 0\n assert candidate(word = \"aaaaaeeeeeeiiiiioooooouuuuu\") == 25\n assert candidate(word = \"aeiouu\") == 2\n assert candidate(word = \"a\") == 0\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(word = \"vowelsaeiou\") == 1\n assert candidate(word = \"cuaieuouac\") == 7\n assert candidate(word = \"aeiooauuieoiau\") == 41\n assert candidate(word = \"bcdfeioau\") == 1\n assert candidate(word = \"zzzzzaeiouzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiou\") == 43\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 496\n assert candidate(word = \"aeiouxyzaeiouaeiou\") == 22\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 1326\n assert candidate(word = \"aeiouxyzaeiou\") == 2\n assert candidate(word = \"xyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 63\n assert candidate(word = \"aeiouuuueeiooiaaaeeoioioiaaaeeuuuiooiiuaeiouaeiouaeiouaeiouaeiou\") == 1565\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiou\") == 231\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiou\") == 63\n assert candidate(word = \"uoieaueoiaueoiaueoiaueoi\") == 208\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 666\n assert candidate(word = \"aeioubcdfghjklmnpqrstvwxyzaeiou\") == 2\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 63\n assert candidate(word = \"aeioubaeioucaeioudeaeioufaeioubaeioucaeioudeaeioufaeioubaeioucaeioudeaeiouf\") == 15\n assert candidate(word = \"bcdaeioufghijklmnopqrstuvwxyz\") == 1\n assert candidate(word = \"aeiouwxyzaeiouwxyzaeiouwxyzaeiouwxyz\") == 4\n assert candidate(word = \"xayaioeoiuaueoieoiauiouio\") == 139\n assert candidate(word = \"aeioubaeiouaeioubaeiouxyzaeiouaeiouaeioubaeiou\") == 90\n assert candidate(word = \"aeioubaeioucaeiou\") == 3\n assert candidate(word = \"bcaeiouaeiouaieouacb\") == 77\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyz\") == 42\n assert candidate(word = \"aieouaeiouaieouaeiouaieouaeiouaieou\") == 490\n assert candidate(word = \"aeiouuueeiooiaaaeeoioioiaaaeeuuuiooiiu\") == 348\n assert candidate(word = \"aeioubaeiouaeioucaeiou\") == 23\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouzzzzzzzzz\") == 231\n assert candidate(word = \"aeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyz\") == 8\n assert candidate(word = \"aeiouxyzzyxwvutsrqponmlkjihgfedcbaeiouaeiou\") == 22\n assert candidate(word = \"aeiouxyaeiouaeiou\") == 22\n assert candidate(word = \"aeeeeiiiioouuuaeiouaaaeioueee\") == 247\n assert candidate(word = \"aeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyz\") == 5\n assert candidate(word = \"aeioucaeioubaeiouaeiou\") == 23\n assert candidate(word = \"aeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiou\") == 5\n assert candidate(word = \"xyzaeiouaeiouxyzaeiouaeiouxyz\") == 42\n assert candidate(word = \"mnopqrstuvwxyaeiouaeiouxyzaeiouxyzzyxwvutsrqponmlkjihgfedcbaeiou\") == 23\n assert candidate(word = \"bcaeiouc\") == 1\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 4656\n assert candidate(word = \"aeioueoiuaeiouaeioua\") == 125\n assert candidate(word = \"aabbccddeeeffgghhiijjkkllmmnnooouuupppqqrrsstttuuuvvvwwxxyyzz\") == 0\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 1081\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 105\n assert candidate(word = \"aeiouaeiouxxxaeiouaeiou\") == 42\n assert candidate(word = \"aebcioudfeiauoceioua\") == 2\n assert candidate(word = \"aouieaeioueaouieaeiou\") == 139\n assert candidate(word = \"aeiouaeiouabcdeiouaeiouabcdeiouaeiou\") == 64\n assert candidate(word = \"zzzzzvvvvvaeeeiioouuuaeiou\") == 44\n assert candidate(word = \"uoieaueoiaueoiaueoiaueoiaeiou\") == 317\n assert candidate(word = \"bcdfeaioueaiouaeioueaioueaiou\") == 229\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 1596\n assert candidate(word = \"ueaiaoueoiuaeiouaeiouaeiou\") == 245\n assert candidate(word = \"aeiaeiouoieiouaeiou\") == 93\n assert candidate(word = \"uoieaueoiaueoiaueoiaueoiaeiouaeiouaeiouaeiouaeiou\") == 1027\n assert candidate(word = \"aeiooouiaeiouaeiou\") == 92\n assert candidate(word = \"aeioubaeiouaeioubaeiouxyzaeiouaeiouaeioubaeiouxyzaeiouaeioubaeiou\") == 112\n assert candidate(word = \"aabbccddeeffggahhiiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(word = \"xyzaeiouaeiouxyz\") == 21\n assert candidate(word = \"aeioueoiuaeiouaeioueoiuaeiouaeioueoiu\") == 529\n assert candidate(word = \"zzzzzaeiouzzzzzzzzzz\") == 1\n assert candidate(word = \"zbcdefghijklmnopqrstuvwxyaeiou\") == 1\n assert candidate(word = \"bcdfgohueaioeuncdfeoiu\") == 5\n assert candidate(word = \"aeioubaeioucaeioudaeioubaeioucaeioudaeioubaeioucaeiou\") == 9\n assert candidate(word = \"xaaaeeeiiiiooooouuuuuaaaeiiiou\") == 131\n assert candidate(word = \"eiaouoieaueioaeioaeiaoueioea\") == 253\n assert candidate(word = \"aeiouaeiouaeiouxyzaeiouaeiouaeiouxyzaeiouaeiou\") == 153\n assert candidate(word = \"aeiouxyzaeiouxyzaeiouxyz\") == 3\n assert candidate(word = \"mnopqrstuvwxyaeiouaeiouxyz\") == 21\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 84\n assert candidate(word = \"xyzaeiouaeiouaeiouaeiouaeiouaeiouxyz\") == 351\n assert candidate(word = \"baeiouaeiouaeiouaeiouaeiou\") == 231\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(word = \"aeioubaeioucaeioudeaeiouf\") == 5\n assert candidate(word = \"oiueaeiouaeiouaeiouaeiouaeiouaeiou\") == 461\n assert candidate(word = \"aeioubaeiouaeiouaeiouaeiou\") == 137\n assert candidate(word = \"zzzzzaeiouzzzzz\") == 1\n assert candidate(word = \"baeioucaeiouaeioucb\") == 22\n assert candidate(word = \"eiouaeioua\") == 21\n assert candidate(word = \"aeioubaeiouaeioubaeiou\") == 23\n assert candidate(word = \"xyzabcdeioufghijklmnopqrstuvwaeiou\") == 1\n assert candidate(word = \"aeiouaeeeeeiioouuuuuaeiou\") == 146\n assert candidate(word = \"abcdeioua\") == 1\n assert candidate(word = \"aeioubaeioucaeioudeaeioufaeioubaeioucaeioudeaeiouf\") == 10\n assert candidate(word = \"aeioueaioueaioueaioueaioueaiou\") == 350\n assert candidate(word = \"aeioubaeiouaeioubaeiouaeiou\") == 43\n assert candidate(word = \"aeiouaeiouaebcdeaeiouaeiou\") == 63\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiou\") == 351\n assert candidate(word = \"aeiouaeiouaeiouaeiou\") == 136\n assert candidate(word = \"xyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiou\") == 84\n assert candidate(word = \"aeiouzyxwvutsrqponmlkjihgfedcbaeiou\") == 2\n assert candidate(word = \"aeiouzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(word = \"aeiouxyzzyxwvutsrqponmlkjihgfedcbaeiouaeiouaeiouxyzaeiouxyzzyxwvutsrqponmlkjihgfedcbaeiou\") == 69\n assert candidate(word = \"eiouaeiouaeiouaeiouaeiouaeiou\") == 325\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 147\n assert candidate(word = \"xzaeiouaeiouaeiouaeiouaeioux\") == 231\n", "comparison": "exact"}, "public_tests": ["\"aeiouu\"", "\"unicornarihan\"", "\"cuaieuouac\""], "hints": ["While generating substrings starting at any index, do you need to continue generating larger substrings if you encounter a consonant?", "Can you store the count of characters to avoid generating substrings altogether?"], "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().countVowelSubstrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:51+00:00", "tests_total": 110, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def countVowelSubstrings(self, word: str) -> int:", "container": "Solution", "callable": "countVowelSubstrings", "parameters": [{"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2063, "task_id": "vowels-of-all-substrings", "difficulty": "Medium", "problem_description": "Given a string word, return the sum of the number of vowels ('a', 'e', 'i', 'o', and 'u') in every substring of word.\n\nA substring is a contiguous (non-empty) sequence of characters within a string.\n\nNote: Due to the large constraints, the answer may not fit in a signed 32-bit integer. Please be careful during the calculations.\n\nExample 1:\n\nInput: word = \"aba\"\nOutput: 6\nExplanation:\nAll possible substrings are: \"a\", \"ab\", \"aba\", \"b\", \"ba\", and \"a\".\n- \"b\" has 0 vowels in it\n- \"a\", \"ab\", \"ba\", and \"a\" have 1 vowel each\n- \"aba\" has 2 vowels in it\nHence, the total sum of vowels = 0 + 1 + 1 + 1 + 1 + 2 = 6.\n\nExample 2:\n\nInput: word = \"abc\"\nOutput: 3\nExplanation:\nAll possible substrings are: \"a\", \"ab\", \"abc\", \"b\", \"bc\", and \"c\".\n- \"a\", \"ab\", and \"abc\" have 1 vowel each\n- \"b\", \"bc\", and \"c\" have 0 vowels each\nHence, the total sum of vowels = 1 + 1 + 1 + 0 + 0 + 0 = 3.\n\nExample 3:\n\nInput: word = \"ltcd\"\nOutput: 0\nExplanation: There are no vowels in any substring of \"ltcd\".\n\nConstraints:\n\n- 1 <= word.length <= 10^5\n- word consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"e\") == 1\n assert candidate(word = \"aeiou\") == 35\n assert candidate(word = \"abc\") == 3\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiuiauuuuaeioaaaaeaiaioieoieiieoioioieouieiiaiaeiieoieouuiooaoaaiiaeiieeiooieiei\") == 209934\n assert candidate(word = \"bcbcbcbcbc\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiu\") == 4960\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiuiaoiuuaeiuuaieiiaaaeeiuuoiuuuuuuu\") == 43680\n assert candidate(word = \"ltcd\") == 0\n assert candidate(word = \"aba\") == 6\n assert candidate(word = \"u\") == 1\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\") == 604\n assert candidate(word = \"a\") == 1\n assert candidate(word = \"o\") == 1\n assert candidate(word = \"b\") == 0\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"i\") == 1\n assert candidate(word = \"bbaaeekkeeaabbaaeekkeeaabbaaeekkeeaabb\") == 6576\n assert candidate(word = \"uvijqet\") == 34\n assert candidate(word = \"aieouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 16215\n assert candidate(word = \"uuygqijetbvrcw\") == 150\n assert candidate(word = \"mississippi\") == 98\n assert candidate(word = \"vowels\") == 22\n assert candidate(word = \"aeiouaeiouaeiou\") == 680\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 3412\n assert candidate(word = \"cccccdcccc\") == 0\n assert candidate(word = \"aovnwqoeirqoweoirqoweoirquw\") == 1949\n assert candidate(word = \"congratulations\") == 299\n assert candidate(word = \"xyzaeiouxyzaeiouxyz\") == 820\n assert candidate(word = \"bcbcbcbcbcbcbcbcbcbc\") == 0\n assert candidate(word = \"vvvuuuooooiiiaaaaeeeee\") == 1900\n assert candidate(word = \"consonants\") == 76\n assert candidate(word = \"vowelvowelvowel\") == 278\n assert candidate(word = \"supercalifragilisticexpialidocious\") == 3282\n assert candidate(word = \"aquickbrownfoxjumpsoverthelazydog\") == 2016\n assert candidate(word = \"leetcode\") == 58\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 3860\n assert candidate(word = \"sequence\") == 62\n assert candidate(word = \"aovvoaoaueuioeaueoaiouaoieaouioeaouioiea\") == 11218\n assert candidate(word = \"aeeee\") == 35\n assert candidate(word = \"aeioouaeiou\") == 286\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"bbbbbbbbbbbbbbbbbbbbbbba\") == 24\n assert candidate(word = \"hello\") == 13\n assert candidate(word = \"uoiea\") == 35\n assert candidate(word = \"bcdfghjklmnpqrstvwxyz\") == 0\n assert candidate(word = \"ffaaabbbccc\") == 94\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiou\") == 2925\n assert candidate(word = \"qweoiauoieqweoiauoieqweoiauoie\") == 4016\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 4562\n assert candidate(word = \"rhythms\") == 0\n assert candidate(word = \"bbbbbebbbb\") == 30\n assert candidate(word = \"aabbccddeeeffgg\") == 221\n assert candidate(word = \"beautiful\") == 101\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiou\") == 4960\n assert candidate(word = \"dddddeoeddd\") == 103\n assert candidate(word = \"aeiouaeiouaeiouaeiou\") == 1540\n assert candidate(word = \"vowel\") == 16\n assert candidate(word = \"xylophone\") == 54\n assert candidate(word = \"repetitiveeeee\") == 350\n assert candidate(word = \"repetition\") == 118\n assert candidate(word = \"characters\") == 78\n assert candidate(word = \"uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\") == 13244\n assert candidate(word = \"uvaeiouz\") == 98\n assert candidate(word = \"aovylqjwhepfuciphg\") == 280\n assert candidate(word = \"uoieaoueioauoiea\") == 816\n assert candidate(word = \"zzzzzzzzzzz\") == 0\n assert candidate(word = \"eeeeeaeeee\") == 220\n assert candidate(word = \"aaaaabaaaaa\") == 250\n assert candidate(word = \"abacaxabayabac\") == 280\n assert candidate(word = \"aeiouaeiou\") == 220\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"programming\") == 90\n assert candidate(word = \"aeiaoeiaoeiaoeiaoeiaoeiaoeiaoeiaoeiaoei\") == 10660\n assert candidate(word = \"ouqofyrcjgz\") == 63\n assert candidate(word = \"aeiaeaieaa\") == 220\n assert candidate(word = \"vowelsarefun\") == 158\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 4718\n", "comparison": "exact"}, "public_tests": ["\"aba\"", "\"abc\"", "\"ltcd\""], "hints": ["Since generating substrings is not an option, can we count the number of substrings a vowel appears in?", "How much does each vowel contribute to the total sum?"], "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().countVowels", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:53+00:00", "tests_total": 80, "tests_dropped": 1, "flags": [], "topic_tags": ["math", "string", "dynamic-programming", "combinatorics"]}, "language": "python", "interface": {"raw_signature": "def countVowels(self, word: str) -> int:", "container": "Solution", "callable": "countVowels", "parameters": [{"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2064, "task_id": "minimized-maximum-of-products-distributed-to-any-store", "difficulty": "Medium", "problem_description": "You are given an integer n indicating there are n specialty retail stores. There are m product types of varying amounts, which are given as a 0-indexed integer array quantities, where quantities[i] represents the number of products of the i^th product type.\n\nYou need to distribute all products to the retail stores following these rules:\n\n- A store can only be given at most one product type but can be given any amount of it.\n- After distribution, each store will have been given some number of products (possibly 0). Let x represent the maximum number of products given to any store. You want x to be as small as possible, i.e., you want to minimize the maximum number of products that are given to any store.\n\nReturn the minimum possible x.\n\nExample 1:\n\nInput: n = 6, quantities = [11,6]\nOutput: 3\nExplanation: One optimal way is:\n- The 11 products of type 0 are distributed to the first four stores in these amounts: 2, 3, 3, 3\n- The 6 products of type 1 are distributed to the other two stores in these amounts: 3, 3\nThe maximum number of products given to any store is max(2, 3, 3, 3, 3, 3) = 3.\n\nExample 2:\n\nInput: n = 7, quantities = [15,10,10]\nOutput: 5\nExplanation: One optimal way is:\n- The 15 products of type 0 are distributed to the first three stores in these amounts: 5, 5, 5\n- The 10 products of type 1 are distributed to the next two stores in these amounts: 5, 5\n- The 10 products of type 2 are distributed to the last two stores in these amounts: 5, 5\nThe maximum number of products given to any store is max(5, 5, 5, 5, 5, 5, 5) = 5.\n\nExample 3:\n\nInput: n = 1, quantities = [100000]\nOutput: 100000\nExplanation: The only optimal way is:\n- The 100000 products of type 0 are distributed to the only store.\nThe maximum number of products given to any store is max(100000) = 100000.\n\nConstraints:\n\n- m == quantities.length\n- 1 <= m <= n <= 10^5\n- 1 <= quantities[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,quantities = [10, 20, 30, 40, 50]) == 50\n assert candidate(n = 3,quantities = [100, 100, 100]) == 100\n assert candidate(n = 10,quantities = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100000]) == 100000\n assert candidate(n = 3,quantities = [1, 100000]) == 50000\n assert candidate(n = 2,quantities = [50000, 50000]) == 50000\n assert candidate(n = 50000,quantities = [1, 2, 3, 4, 5]) == 1\n assert candidate(n = 10,quantities = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == 100000\n assert candidate(n = 2,quantities = [100000, 100000]) == 100000\n assert candidate(n = 7,quantities = [15, 10, 10]) == 5\n assert candidate(n = 10,quantities = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(n = 5,quantities = [10, 10, 10, 10, 10]) == 10\n assert candidate(n = 5,quantities = [1, 1, 1, 1, 1]) == 1\n assert candidate(n = 6,quantities = [11, 6]) == 3\n assert candidate(n = 5,quantities = [1, 2, 3, 4, 5]) == 5\n assert candidate(n = 100000,quantities = [1]) == 1\n assert candidate(n = 10,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(n = 50000,quantities = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 4\n assert candidate(n = 50000,quantities = [100000, 100000]) == 4\n assert candidate(n = 100,quantities = [100000]) == 1000\n assert candidate(n = 10,quantities = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(n = 3,quantities = [50, 50, 50]) == 50\n assert candidate(n = 2,quantities = [100, 1]) == 100\n assert candidate(n = 3,quantities = [100, 200, 300]) == 300\n assert candidate(n = 1,quantities = [100000]) == 100000\n assert candidate(n = 100000,quantities = [100000]) == 1\n assert candidate(n = 8,quantities = [12, 24, 36, 48, 60, 72, 84, 96]) == 96\n assert candidate(n = 100000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(n = 80000,quantities = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]) == 2\n assert candidate(n = 50000,quantities = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(n = 100000,quantities = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == 2\n assert candidate(n = 75000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 1\n assert candidate(n = 100000,quantities = [10000, 20000, 30000, 40000, 50000]) == 2\n assert candidate(n = 45000,quantities = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 35\n assert candidate(n = 15000,quantities = [50000, 40000, 30000, 20000, 10000]) == 10\n assert candidate(n = 80000,quantities = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 1\n assert candidate(n = 20000,quantities = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1\n assert candidate(n = 90000,quantities = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == 3\n assert candidate(n = 10,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(n = 40000,quantities = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, 483, 482, 481, 480, 479, 478, 477, 476, 475, 474, 473, 472, 471, 470]) == 1\n assert candidate(n = 100000,quantities = [100000, 50000, 30000, 20000, 10000]) == 3\n assert candidate(n = 40000,quantities = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 1\n assert candidate(n = 30000,quantities = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500]) == 2\n assert candidate(n = 50000,quantities = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999]) == 20\n assert candidate(n = 30000,quantities = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == 6\n assert candidate(n = 60000,quantities = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980]) == 34\n assert candidate(n = 10,quantities = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 500\n assert candidate(n = 60000,quantities = [15000, 15000, 15000, 15000, 15000, 15000]) == 2\n assert candidate(n = 99999,quantities = [100000, 99999, 99998, 99997, 99996, 99995]) == 7\n assert candidate(n = 80000,quantities = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019]) == 1\n assert candidate(n = 6,quantities = [10, 20, 30, 40, 50, 60]) == 60\n assert candidate(n = 15,quantities = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 150\n assert candidate(n = 90000,quantities = [90000, 100, 200, 300, 400, 500, 600, 700, 800]) == 2\n assert candidate(n = 7,quantities = [5, 15, 25, 35, 45, 55, 65]) == 65\n assert candidate(n = 10,quantities = [1000, 2000, 3000, 4000, 5000]) == 2000\n assert candidate(n = 50000,quantities = [1, 10, 100, 1000, 10000, 100000]) == 3\n assert candidate(n = 100000,quantities = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 4\n assert candidate(n = 30000,quantities = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 8\n assert candidate(n = 20000,quantities = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 1\n assert candidate(n = 40000,quantities = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 14\n assert candidate(n = 75000,quantities = [99999, 1, 2, 3, 4, 5]) == 2\n assert candidate(n = 50000,quantities = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1\n assert candidate(n = 45000,quantities = [45000, 22500, 15000, 11250, 9000]) == 3\n assert candidate(n = 25000,quantities = [10000, 20000, 30000, 40000, 50000]) == 7\n assert candidate(n = 50000,quantities = [10000, 15000, 20000, 25000, 30000]) == 2\n assert candidate(n = 100000,quantities = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 1\n assert candidate(n = 90000,quantities = [9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000]) == 2\n assert candidate(n = 10000,quantities = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 22\n assert candidate(n = 75000,quantities = [20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000]) == 3\n assert candidate(n = 100000,quantities = [50000, 50000, 50000, 50000]) == 2\n assert candidate(n = 90000,quantities = [1, 10, 100, 1000, 10000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 17\n assert candidate(n = 99999,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(n = 50000,quantities = [25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000]) == 5\n assert candidate(n = 50000,quantities = [100000]) == 2\n assert candidate(n = 75000,quantities = [75000, 75000, 75000, 75000, 75000, 75000, 75000, 75000, 75000, 75000]) == 10\n assert candidate(n = 60000,quantities = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 10\n assert candidate(n = 50000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 1\n assert candidate(n = 100000,quantities = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(n = 50000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(n = 20,quantities = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110]) == 110\n assert candidate(n = 10000,quantities = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 10\n assert candidate(n = 30000,quantities = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1\n assert candidate(n = 80000,quantities = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == 1\n assert candidate(n = 45000,quantities = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980]) == 45\n assert candidate(n = 90000,quantities = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(n = 3,quantities = [99999, 99999, 99999]) == 99999\n assert candidate(n = 60000,quantities = [1, 10, 100, 1000, 10000, 100000]) == 2\n assert candidate(n = 60000,quantities = [99999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(n = 60000,quantities = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999]) == 34\n assert candidate(n = 80000,quantities = [8000, 8001, 8002, 8003, 8004, 8005, 8006, 8007, 8008, 8009]) == 2\n assert candidate(n = 20000,quantities = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 100\n assert candidate(n = 30000,quantities = [30000, 30001, 30002, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, 30018, 30019]) == 21\n assert candidate(n = 100000,quantities = [50000, 50000, 50000, 50000, 50000]) == 3\n assert candidate(n = 100000,quantities = [10000, 15000, 20000, 25000, 30000]) == 1\n assert candidate(n = 75000,quantities = [12345, 67890, 11111, 22222, 33333, 44444, 55555]) == 4\n assert candidate(n = 50000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(n = 30000,quantities = [9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999]) == 11\n assert candidate(n = 100,quantities = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 20\n assert candidate(n = 80000,quantities = [20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000]) == 17\n", "comparison": "exact"}, "public_tests": ["6\n[11,6]", "7\n[15,10,10]", "1\n[100000]"], "hints": ["There exists a monotonic nature such that when x is smaller than some number, there will be no way to distribute, and when x is not smaller than that number, there will always be a way to distribute.", "If you are given a number k, where the number of products given to any store does not exceed k, could you determine if all products can be distributed?", "Implement a function canDistribute(k), which returns true if you can distribute all products such that any store will not be given more than k products, and returns false if you cannot. Use this function to binary search for the smallest possible k."], "metadata": {"canonical_parameter_names": ["n", "quantities"], "leetcode_dataset_entry_point": "Solution().minimizedMaximum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:56+00:00", "tests_total": 108, "tests_dropped": 10, "flags": [], "topic_tags": ["array", "binary-search", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minimizedMaximum(self, n: int, quantities: list[int]) -> int:", "container": "Solution", "callable": "minimizedMaximum", "parameters": [{"name": "n", "type": "int"}, {"name": "quantities", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2065, "task_id": "maximum-path-quality-of-a-graph", "difficulty": "Hard", "problem_description": "There is an undirected graph with n nodes numbered from 0 to n - 1 (inclusive). You are given a 0-indexed integer array values where values[i] is the value of the i^th node. You are also given a 0-indexed 2D integer array edges, where each edges[j] = [u_j, v_j, time_j] indicates that there is an undirected edge between the nodes u_j and v_j,and it takes time_j seconds to travel between the two nodes. Finally, you are given an integer maxTime.\n\nA valid path in the graph is any path that starts at node 0, ends at node 0, and takes at most maxTime seconds to complete. You may visit the same node multiple times. The quality of a valid path is the sum of the values of the unique nodes visited in the path (each node's value is added at most once to the sum).\n\nReturn the maximum quality of a valid path.\n\nNote: There are at most four edges connected to each node.\n\nExample 1:\n\nInput: values = [0,32,10,43], edges = [[0,1,10],[1,2,15],[0,3,10]], maxTime = 49\nOutput: 75\nExplanation:\nOne possible path is 0 -> 1 -> 0 -> 3 -> 0. The total time taken is 10 + 10 + 10 + 10 = 40 <= 49.\nThe nodes visited are 0, 1, and 3, giving a maximal path quality of 0 + 32 + 43 = 75.\n\nExample 2:\n\nInput: values = [5,10,15,20], edges = [[0,1,10],[1,2,10],[0,3,10]], maxTime = 30\nOutput: 25\nExplanation:\nOne possible path is 0 -> 3 -> 0. The total time taken is 10 + 10 = 20 <= 30.\nThe nodes visited are 0 and 3, giving a maximal path quality of 5 + 20 = 25.\n\nExample 3:\n\nInput: values = [1,2,3,4], edges = [[0,1,10],[1,2,11],[2,3,12],[1,3,13]], maxTime = 50\nOutput: 7\nExplanation:\nOne possible path is 0 -> 1 -> 3 -> 1 -> 0. The total time taken is 10 + 13 + 13 + 10 = 46 <= 50.\nThe nodes visited are 0, 1, and 3, giving a maximal path quality of 1 + 2 + 4 = 7.\n\nConstraints:\n\n- n == values.length\n- 1 <= n <= 1000\n- 0 <= values[i] <= 10^8\n- 0 <= edges.length <= 2000\n- edges[j].length == 3\n- 0 <= u_j< v_j <= n - 1\n- 10 <= time_j, maxTime <= 100\n- All the pairs [u_j, v_j] are unique.\n- There are at most four edges connected to each node.\n- The graph may not be connected.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 4, 40]],maxTime = 100) == 70\n assert candidate(values = [100, 200, 300, 400],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 0, 10]],maxTime = 50) == 1000\n assert candidate(values = [5, 5, 5, 5, 5],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 0, 10]],maxTime = 40) == 15\n assert candidate(values = [5, 5, 5, 5],edges = [[0, 1, 10], [0, 2, 10], [2, 3, 10]],maxTime = 25) == 10\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10]],maxTime = 50) == 3\n assert candidate(values = [1, 2, 3, 4, 5],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10]],maxTime = 20) == 4\n assert candidate(values = [1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10]],maxTime = 40) == 3\n assert candidate(values = [5, 10, 15, 20],edges = [[0, 1, 10], [1, 2, 10], [0, 3, 10]],maxTime = 30) == 25\n assert candidate(values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10]],maxTime = 100) == 27\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],maxTime = 90) == 25\n assert candidate(values = [5, 5, 5, 5, 5, 5],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10]],maxTime = 30) == 10\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10]],maxTime = 50) == 90\n assert candidate(values = [5, 5, 5, 5],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 3, 10]],maxTime = 30) == 10\n assert candidate(values = [1, 2, 3, 4],edges = [[0, 1, 10], [1, 2, 11], [2, 3, 12], [1, 3, 13]],maxTime = 50) == 7\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [0, 2, 20], [1, 3, 15], [2, 3, 25], [3, 4, 10]],maxTime = 60) == 70\n assert candidate(values = [1, 2, 3, 4],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10]],maxTime = 10) == 1\n assert candidate(values = [1, 2, 3, 4, 5, 6],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10]],maxTime = 60) == 12\n assert candidate(values = [0, 32, 10, 43],edges = [[0, 1, 10], [1, 2, 15], [0, 3, 10]],maxTime = 49) == 75\n assert candidate(values = [10, 20, 30],edges = [[0, 1, 10], [1, 2, 10]],maxTime = 25) == 30\n assert candidate(values = [10, 20, 30],edges = [[0, 1, 10], [1, 2, 20]],maxTime = 30) == 30\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 0, 10]],maxTime = 50) == 150\n assert candidate(values = [10],edges = [],maxTime = 100) == 10\n assert candidate(values = [100, 0, 0, 0],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10]],maxTime = 10) == 100\n assert candidate(values = [100, 50, 200, 300, 150, 250, 400],edges = [[0, 1, 20], [0, 2, 30], [0, 3, 40], [1, 4, 10], [1, 5, 20], [2, 6, 30], [3, 6, 40], [4, 5, 50], [5, 6, 60]],maxTime = 120) == 700\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10]],maxTime = 80) == 2500\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 7, 10], [6, 8, 10], [7, 8, 10], [7, 9, 10], [8, 9, 10]],maxTime = 50) == 110\n assert candidate(values = [10, 10, 10, 10, 10],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 40) == 40\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [1, 6, 10], [1, 7, 10], [2, 8, 10], [2, 9, 10], [3, 10, 10], [3, 11, 10], [4, 12, 10], [4, 13, 10], [5, 14, 10], [5, 15, 10], [6, 16, 10], [6, 17, 10], [7, 18, 10], [7, 19, 10], [8, 14, 10], [8, 15, 10], [9, 16, 10], [9, 17, 10], [10, 18, 10], [10, 19, 10], [11, 14, 10], [11, 15, 10], [12, 16, 10], [12, 17, 10], [13, 18, 10], [13, 19, 10]],maxTime = 100) == 10\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],edges = [[0, 1, 10], [0, 2, 20], [1, 3, 15], [2, 4, 25], [3, 5, 10], [4, 6, 15], [5, 7, 20], [6, 8, 10], [7, 9, 15], [8, 10, 20], [9, 11, 10]],maxTime = 120) == 210\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10]],maxTime = 80) == 8\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10], [0, 2, 15], [1, 3, 15], [2, 4, 15], [3, 5, 15], [4, 6, 15], [5, 7, 15], [6, 8, 15], [7, 9, 15], [8, 0, 15], [9, 1, 15]],maxTime = 150) == 550\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 0, 10]],maxTime = 50) == 70\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],maxTime = 55) == 600\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10]],maxTime = 50) == 9\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 100) == 5\n assert candidate(values = [10, 20, 30, 40, 50, 60],edges = [[0, 1, 10], [0, 2, 10], [1, 2, 15], [1, 3, 20], [2, 4, 25], [3, 4, 30], [4, 5, 15]],maxTime = 70) == 90\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10], [8, 0, 10]],maxTime = 90) == 310\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 7, 10], [6, 8, 10], [7, 8, 10], [8, 9, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [2, 7, 10], [3, 8, 10], [4, 9, 10], [5, 6, 10]],maxTime = 60) == 37\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [3, 8, 10], [4, 9, 10], [4, 10, 10], [5, 11, 10], [5, 12, 10], [6, 13, 10], [6, 14, 10], [7, 15, 10], [7, 16, 10], [8, 17, 10], [8, 18, 10], [9, 19, 10]],maxTime = 150) == 8\n assert candidate(values = [1, 2, 3, 4, 5],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 40) == 9\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10]],maxTime = 100) == 310\n assert candidate(values = [100, 200, 100, 200, 100, 200, 100, 200],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10]],maxTime = 50) == 500\n assert candidate(values = [50, 20, 30, 40],edges = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 2, 15], [1, 3, 25], [2, 3, 10]],maxTime = 40) == 80\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 35) == 100\n assert candidate(values = [5, 10, 15, 20, 25, 30],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [0, 3, 35], [1, 4, 40]],maxTime = 100) == 50\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [5, 6, 35], [6, 7, 40], [0, 7, 10]],maxTime = 100) == 80\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10]],maxTime = 80) == 27\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10]],maxTime = 50) == 20\n assert candidate(values = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10], [0, 5, 10], [1, 6, 10], [2, 7, 10], [3, 8, 10], [4, 9, 10]],maxTime = 150) == 550\n assert candidate(values = [30, 20, 10, 40, 50],edges = [[0, 1, 10], [0, 2, 15], [0, 3, 20], [0, 4, 25], [1, 2, 5], [1, 3, 15], [1, 4, 25], [2, 3, 10], [2, 4, 20], [3, 4, 5]],maxTime = 60) == 150\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 15, 10], [15, 16, 10], [16, 17, 10], [17, 18, 10], [18, 19, 10]],maxTime = 190) == 275\n assert candidate(values = [9, 8, 7, 6, 5, 4, 3, 2, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [1, 4, 10], [1, 5, 10], [2, 6, 10], [2, 7, 10], [3, 8, 10], [4, 8, 10], [5, 6, 10]],maxTime = 60) == 31\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],edges = [[0, 1, 10], [1, 2, 10], [0, 3, 10], [3, 4, 10], [2, 5, 10], [5, 6, 10], [4, 7, 10], [7, 8, 10], [6, 9, 10]],maxTime = 100) == 145\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 15], [0, 2, 20], [1, 3, 25], [2, 4, 30], [3, 5, 35], [4, 6, 40], [5, 7, 45], [6, 8, 50], [7, 9, 55], [8, 9, 60]],maxTime = 150) == 13\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [1, 4, 10], [1, 5, 10], [2, 6, 10], [2, 7, 10], [3, 8, 10], [3, 9, 10]],maxTime = 50) == 150\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 0, 10]],maxTime = 140) == 850\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10]],maxTime = 100) == 510\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 10], [5, 6, 30], [6, 7, 10], [7, 8, 25], [8, 9, 20], [9, 10, 15], [10, 11, 20], [11, 12, 15], [12, 13, 10], [13, 14, 30]],maxTime = 200) == 210\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10]],maxTime = 90) == 3500\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [1, 6, 10], [2, 7, 10], [2, 8, 10], [3, 9, 10], [3, 10, 10], [4, 11, 10], [4, 12, 10], [5, 13, 10], [6, 14, 10], [7, 15, 10], [8, 16, 10], [9, 17, 10], [10, 18, 10], [11, 19, 10], [12, 13, 10], [14, 15, 10], [16, 17, 10], [18, 19, 10]],maxTime = 150) == 142\n assert candidate(values = [100, 200, 300, 400, 500],edges = [[0, 1, 20], [0, 2, 30], [1, 3, 25], [2, 4, 35], [3, 4, 40]],maxTime = 150) == 1500\n assert candidate(values = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10], [3, 4, 15], [5, 6, 15]],maxTime = 120) == 950\n assert candidate(values = [100, 200, 300, 400, 500],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 0, 10]],maxTime = 50) == 1500\n assert candidate(values = [50, 20, 10, 30, 40, 60],edges = [[0, 1, 10], [1, 2, 15], [1, 3, 20], [2, 3, 25], [3, 4, 10], [4, 5, 30]],maxTime = 100) == 150\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 3, 10], [3, 4, 10], [1, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 1, 10]],maxTime = 60) == 22\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 7, 10], [6, 8, 10], [7, 8, 10]],maxTime = 100) == 40\n assert candidate(values = [5, 10, 15, 20, 25, 30],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [0, 5, 35]],maxTime = 70) == 35\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],maxTime = 90) == 15\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10], [0, 3, 30], [1, 5, 30], [2, 4, 30]],maxTime = 90) == 450\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [0, 2, 15], [1, 3, 20], [2, 4, 25], [3, 5, 10], [4, 6, 30], [5, 7, 10], [6, 8, 25], [7, 9, 20]],maxTime = 150) == 3100\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 9, 10], [7, 9, 10], [8, 9, 10]],maxTime = 50) == 15\n assert candidate(values = [50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 20], [1, 3, 15], [2, 3, 25], [3, 4, 10], [4, 5, 15]],maxTime = 100) == 380\n assert candidate(values = [100, 200, 300, 400, 500],edges = [[0, 1, 20], [1, 2, 30], [2, 3, 25], [3, 4, 35], [4, 0, 40]],maxTime = 120) == 800\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 0, 10], [1, 3, 15], [2, 4, 20]],maxTime = 50) == 150\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10], [0, 5, 20], [1, 6, 20], [2, 7, 20], [3, 8, 20], [4, 9, 20]],maxTime = 120) == 275\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 7, 10], [6, 8, 10], [7, 8, 10], [8, 9, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [2, 7, 10], [3, 8, 10], [4, 9, 10], [5, 6, 10], [0, 5, 10], [1, 6, 10], [2, 3, 10], [3, 9, 10], [4, 5, 10], [6, 9, 10], [7, 9, 10]],maxTime = 100) == 5500\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 15, 10]],maxTime = 150) == 40\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 0, 10]],maxTime = 150) == 1180\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [0, 5, 10], [0, 6, 10], [0, 7, 10], [0, 8, 10], [0, 9, 10], [1, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 15, 10], [15, 16, 10], [16, 17, 10], [17, 18, 10], [18, 19, 10]],maxTime = 50) == 3\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [3, 8, 10], [4, 9, 10], [5, 6, 10], [7, 8, 10], [8, 9, 10]],maxTime = 90) == 390\n assert candidate(values = [100, 200, 300, 400, 500],edges = [[0, 1, 20], [0, 2, 20], [1, 3, 20], [2, 3, 20], [3, 4, 20], [1, 2, 20]],maxTime = 80) == 1000\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10]],maxTime = 90) == 350\n assert candidate(values = [8, 6, 7, 5, 3, 0, 9],edges = [[0, 1, 15], [1, 2, 20], [2, 3, 25], [3, 4, 30], [4, 5, 35], [5, 6, 40], [6, 0, 45]],maxTime = 100) == 21\n assert candidate(values = [5, 10, 15, 20, 25, 30],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [0, 5, 10]],maxTime = 100) == 70\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10], [9, 0, 10]],maxTime = 100) == 390\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10]],maxTime = 150) == 360\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 9, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],maxTime = 80) == 35\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 30) == 100\n", "comparison": "exact"}, "public_tests": ["[0,32,10,43]\n[[0,1,10],[1,2,15],[0,3,10]]\n49", "[5,10,15,20]\n[[0,1,10],[1,2,10],[0,3,10]]\n30", "[1,2,3,4]\n[[0,1,10],[1,2,11],[2,3,12],[1,3,13]]\n50"], "hints": ["How many nodes can you visit within maxTime seconds?", "Can you try every valid path?"], "metadata": {"canonical_parameter_names": ["values", "edges", "maxTime"], "leetcode_dataset_entry_point": "Solution().maximalPathQuality", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:39:58+00:00", "tests_total": 89, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "backtracking", "graph"]}, "language": "python", "interface": {"raw_signature": "def maximalPathQuality(self, values: list[int], edges: list[list[int]], maxTime: int) -> int:", "container": "Solution", "callable": "maximalPathQuality", "parameters": [{"name": "values", "type": "list[int]"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "maxTime", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2068, "task_id": "check-whether-two-strings-are-almost-equivalent", "difficulty": "Easy", "problem_description": "Two strings word1 and word2 are considered almost equivalent if the differences between the frequencies of each letter from 'a' to 'z' between word1 and word2 is at most 3.\n\nGiven two strings word1 and word2, each of length n, return true if word1 and word2 are almost equivalent, or false otherwise.\n\nThe frequency of a letter x is the number of times it occurs in the string.\n\nExample 1:\n\nInput: word1 = \"aaaa\", word2 = \"bccb\"\nOutput: false\nExplanation: There are 4 'a's in \"aaaa\" but 0 'a's in \"bccb\".\nThe difference is 4, which is more than the allowed 3.\n\nExample 2:\n\nInput: word1 = \"abcdeef\", word2 = \"abaaacc\"\nOutput: true\nExplanation: The differences between the frequencies of each letter in word1 and word2 are at most 3:\n- 'a' appears 1 time in word1 and 4 times in word2. The difference is 3.\n- 'b' appears 1 time in word1 and 1 time in word2. The difference is 0.\n- 'c' appears 1 time in word1 and 2 times in word2. The difference is 1.\n- 'd' appears 1 time in word1 and 0 times in word2. The difference is 1.\n- 'e' appears 2 times in word1 and 0 times in word2. The difference is 2.\n- 'f' appears 1 time in word1 and 0 times in word2. The difference is 1.\n\nExample 3:\n\nInput: word1 = \"cccddabba\", word2 = \"babababab\"\nOutput: true\nExplanation: The differences between the frequencies of each letter in word1 and word2 are at most 3:\n- 'a' appears 2 times in word1 and 4 times in word2. The difference is 2.\n- 'b' appears 2 times in word1 and 5 times in word2. The difference is 3.\n- 'c' appears 3 times in word1 and 0 times in word2. The difference is 3.\n- 'd' appears 2 times in word1 and 0 times in word2. The difference is 2.\n\nConstraints:\n\n- n == word1.length == word2.length\n- 1 <= n <= 100\n- word1 and word2 consist only of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"cccddabba\",word2 = \"babababab\") == True\n assert candidate(word1 = \"aaa\",word2 = \"bbb\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"ccbbaa\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(word1 = \"pqrstu\",word2 = \"utsrpq\") == True\n assert candidate(word1 = \"mnop\",word2 = \"ponm\") == True\n assert candidate(word1 = \"abcabcabc\",word2 = \"bcbcbcbcb\") == True\n assert candidate(word1 = \"aaaa\",word2 = \"bccb\") == False\n assert candidate(word1 = \"xyz\",word2 = \"zyx\") == True\n assert candidate(word1 = \"abcdeef\",word2 = \"abaaacc\") == True\n assert candidate(word1 = \"abc\",word2 = \"abc\") == True\n assert candidate(word1 = \"hello\",word2 = \"world\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggeeffddccbbaa\") == True\n assert candidate(word1 = \"abcabcabc\",word2 = \"abcabcabc\") == True\n assert candidate(word1 = \"zzzz\",word2 = \"zzzz\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"bbccdd\") == True\n assert candidate(word1 = \"abc\",word2 = \"xyz\") == True\n assert candidate(word1 = \"zzz\",word2 = \"zzz\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"abcabc\") == True\n assert candidate(word1 = \"abcdef\",word2 = \"fedcba\") == True\n assert candidate(word1 = \"abcd\",word2 = \"dcba\") == True\n assert candidate(word1 = \"abc\",word2 = \"def\") == True\n assert candidate(word1 = \"abcdefg\",word2 = \"gfedcba\") == True\n assert candidate(word1 = \"almostequivalent\",word2 = \"equivalentalmost\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(word1 = \"abacabadabacabad\",word2 = \"babaabacabacabac\") == True\n assert candidate(word1 = \"aabbaabbaabb\",word2 = \"bbaabbaabbab\") == True\n assert candidate(word1 = \"frequency\",word2 = \"requeency\") == True\n assert candidate(word1 = \"xyzxyzxyzxyzxyz\",word2 = \"zyxzyxzyxzyxzyx\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza\") == True\n assert candidate(word1 = \"xyzxyzxyzxyzxyzxyz\",word2 = \"xyzxyzxyzxyzxyzxyx\") == True\n assert candidate(word1 = \"xylophone\",word2 = \"polyxhnon\") == True\n assert candidate(word1 = \"aaaabbbb\",word2 = \"bbbbaaaa\") == True\n assert candidate(word1 = \"testtesttest\",word2 = \"setttestsett\") == True\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcba\") == True\n assert candidate(word1 = \"banana\",word2 = \"nanaba\") == True\n assert candidate(word1 = \"almostequivalent\",word2 = \"quivalentalmosta\") == True\n assert candidate(word1 = \"frequency\",word2 = \"frequncey\") == True\n assert candidate(word1 = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",word2 = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqz\") == True\n assert candidate(word1 = \"frequencycheck\",word2 = \"checkfrequency\") == True\n assert candidate(word1 = \"aabbbccc\",word2 = \"bbaaccdd\") == True\n assert candidate(word1 = \"abcdefghijabcdefghij\",word2 = \"abcdefghijabcdefghii\") == True\n assert candidate(word1 = \"abababababababab\",word2 = \"babababababababa\") == True\n assert candidate(word1 = \"aaabbbccc\",word2 = \"bbbaacccd\") == True\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"bcbcbcbcbcbc\") == False\n assert candidate(word1 = \"asdfghjkl\",word2 = \"lkjhgfdsa\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"acabacabacababa\") == True\n assert candidate(word1 = \"hellothere\",word2 = \"heellooerr\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"equaldiffffe\",word2 = \"equaldifffff\") == True\n assert candidate(word1 = \"racecar\",word2 = \"carrace\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"bississippi\") == True\n assert candidate(word1 = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkk\",word2 = \"ffffgggghhhhiiiijjjjkkkkaaaabbbbccccddddeeee\") == True\n assert candidate(word1 = \"pythonprogramming\",word2 = \"programmingpython\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"abcdefghijk\",word2 = \"abcdefghijl\") == True\n assert candidate(word1 = \"aaaaaaaaaaa\",word2 = \"bbbbbbbbbbb\") == False\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"ababababababababababababababababababababab\",word2 = \"bababababababababababababababababababababa\") == True\n assert candidate(word1 = \"banana\",word2 = \"ananaa\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"cbacabacabacabc\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"abcdabcdabcdabcd\",word2 = \"bcdbcdbcdbcdbcdb\") == False\n assert candidate(word1 = \"abcdabcdabcdabcd\",word2 = \"dcbaabcdabcdabcd\") == True\n assert candidate(word1 = \"abcdefghij\",word2 = \"abcdefghix\") == True\n assert candidate(word1 = \"abcdefghi\",word2 = \"ihgfedcba\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyza\",word2 = \"bcdefghijklmnopqrstuvwxyzzz\") == True\n assert candidate(word1 = \"frequency\",word2 = \"frequnecy\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(word1 = \"abcde\",word2 = \"fghij\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyzz\",word2 = \"abcdefghijklmnopqrstuvwxyyz\") == True\n assert candidate(word1 = \"aabbbcccdddee\",word2 = \"eeedddcccbbaa\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"abacabadabacaba\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"abcabcabcabcabc\") == True\n assert candidate(word1 = \"qwerasdfzxcv\",word2 = \"asdfzxcvqwer\") == True\n assert candidate(word1 = \"mnopqr\",word2 = \"mnopqz\") == True\n assert candidate(word1 = \"mnopqr\",word2 = \"rqponm\") == True\n assert candidate(word1 = \"abcdefg\",word2 = \"ghijklm\") == True\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"dcbaefghefgh\") == True\n assert candidate(word1 = \"aaaabbbbcccc\",word2 = \"ddddeeeeffff\") == False\n assert candidate(word1 = \"programming\",word2 = \"grammipnorg\") == True\n assert candidate(word1 = \"aaaabbbbccccdddd\",word2 = \"ddddccccbbbbaaaa\") == True\n", "comparison": "exact"}, "public_tests": ["\"aaaa\"\n\"bccb\"", "\"abcdeef\"\n\"abaaacc\"", "\"cccddabba\"\n\"babababab\""], "hints": ["What data structure can we use to count the frequency of each character?", "Are there edge cases where a character is present in one string but not the other?"], "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().checkAlmostEquivalent", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:02+00:00", "tests_total": 148, "tests_dropped": 65, "flags": [], "topic_tags": ["hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def checkAlmostEquivalent(self, word1: str, word2: str) -> bool:", "container": "Solution", "callable": "checkAlmostEquivalent", "parameters": [{"name": "word1", "type": "str"}, {"name": "word2", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2070, "task_id": "most-beautiful-item-for-each-query", "difficulty": "Medium", "problem_description": "You are given a 2D integer array items where items[i] = [price_i, beauty_i] denotes the price and beauty of an item respectively.\n\nYou are also given a 0-indexed integer array queries. For each queries[j], you want to determine the maximum beauty of an item whose price is less than or equal to queries[j]. If no such item exists, then the answer to this query is 0.\n\nReturn an array answer of the same length as queries where answer[j] is the answer to the j^th query.\n\nExample 1:\n\nInput: items = [[1,2],[3,2],[2,4],[5,6],[3,5]], queries = [1,2,3,4,5,6]\nOutput: [2,4,5,5,6,6]\nExplanation:\n- For queries[0]=1, [1,2] is the only item which has price <= 1. Hence, the answer for this query is 2.\n- For queries[1]=2, the items which can be considered are [1,2] and [2,4].\n The maximum beauty among them is 4.\n- For queries[2]=3 and queries[3]=4, the items which can be considered are [1,2], [3,2], [2,4], and [3,5].\n The maximum beauty among them is 5.\n- For queries[4]=5 and queries[5]=6, all items can be considered.\n Hence, the answer for them is the maximum beauty of all items, i.e., 6.\n\nExample 2:\n\nInput: items = [[1,2],[1,2],[1,3],[1,4]], queries = [1]\nOutput: [4]\nExplanation:\nThe price of every item is equal to 1, so we choose the item with the maximum beauty 4.\nNote that multiple items can have the same price and/or beauty.\n\nExample 3:\n\nInput: items = [[10,1000]], queries = [5]\nOutput: [0]\nExplanation:\nNo item has a price less than or equal to 5, so no item can be chosen.\nHence, the answer to the query is 0.\n\nConstraints:\n\n- 1 <= items.length, queries.length <= 10^5\n- items[i].length == 2\n- 1 <= price_i, beauty_i, queries[j] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(items = [[10, 1000]],queries = [5]) == [0]\n assert candidate(items = [[100, 5], [50, 4], [200, 3], [150, 2], [300, 1]],queries = [50, 100, 150, 200, 250, 300]) == [4, 5, 5, 5, 5, 5]\n assert candidate(items = [[1, 5], [2, 9], [3, 12], [4, 15], [5, 18]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [5, 12, 18, 18, 18, 18, 18, 18, 18, 18]\n assert candidate(items = [[5, 10], [4, 4], [6, 8], [7, 12]],queries = [3, 5, 7, 10]) == [0, 10, 12, 12]\n assert candidate(items = [[5, 10], [3, 5], [10, 15], [1, 1]],queries = [3, 7, 10]) == [5, 10, 15]\n assert candidate(items = [[1, 2], [1, 2], [1, 3], [1, 4]],queries = [1]) == [4]\n assert candidate(items = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]],queries = [1, 2, 3, 4, 5, 6]) == [5, 5, 5, 5, 5, 5]\n assert candidate(items = [[5, 1], [3, 2], [7, 4], [2, 3]],queries = [8, 6, 4, 2, 1]) == [4, 3, 3, 3, 0]\n assert candidate(items = [[1, 2], [3, 2], [2, 4], [5, 6], [3, 5]],queries = [1, 2, 3, 4, 5, 6]) == [2, 4, 5, 5, 6, 6]\n assert candidate(items = [[5, 10], [7, 15], [8, 20]],queries = [6, 9, 12]) == [10, 20, 20]\n assert candidate(items = [[100, 1], [99, 2], [98, 3], [97, 4], [96, 5]],queries = [96, 97, 98, 99, 100]) == [5, 5, 5, 5, 5]\n assert candidate(items = [[5, 1], [3, 2], [7, 4], [2, 6], [9, 8]],queries = [1, 3, 5, 7, 9, 11]) == [0, 6, 6, 6, 8, 8]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [5, 4, 3, 2, 1]) == [5, 4, 3, 2, 1]\n assert candidate(items = [[2, 3], [5, 5], [6, 7], [8, 8]],queries = [1, 4, 6, 9]) == [0, 3, 7, 8]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(items = [[1, 1], [2, 3], [2, 5], [3, 4], [3, 6], [4, 7], [4, 8], [5, 9]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 5, 6, 8, 9, 9, 9, 9, 9]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700], [80, 800], [90, 900], [100, 1000]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(items = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],queries = [4, 5, 6]) == [0, 10, 10]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]],queries = [1, 1, 1, 1, 1]) == [6, 6, 6, 6, 6]\n assert candidate(items = [[1, 1000], [1, 900], [1, 800], [1, 700], [1, 600], [1, 500], [1, 400], [1, 300], [1, 200], [1, 100]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]\n assert candidate(items = [[1, 10], [2, 15], [3, 5], [4, 20], [5, 10], [6, 25], [7, 30], [8, 20], [9, 5], [10, 15]],queries = [1, 3, 5, 7, 9, 10]) == [10, 15, 20, 30, 30, 30]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]\n assert candidate(items = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]\n assert candidate(items = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == [0, 10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100]\n assert candidate(items = [[1, 100], [10, 200], [100, 300], [1000, 400], [10000, 500]],queries = [1, 5, 50, 500, 5000, 50000, 100000]) == [100, 100, 200, 300, 400, 500, 500]\n assert candidate(items = [[2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],queries = [99, 199, 299, 399, 499, 599, 699, 799, 899, 999, 1001]) == [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 3, 5, 7, 9, 11]) == [1, 3, 5, 7, 9, 10]\n assert candidate(items = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50]],queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [0, 0, 5, 5, 10, 10, 10, 15, 15, 20]\n assert candidate(items = [[50, 100], [25, 200], [75, 150], [100, 250], [125, 300]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == [0, 0, 200, 200, 200, 200, 200, 200, 200, 250, 250, 250, 300]\n assert candidate(items = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5]],queries = [10]) == [5]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [10, 60], [15, 70], [20, 80], [25, 90], [30, 100]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [10, 30, 50, 50, 50, 60, 60, 70, 70, 70, 80, 80, 90, 90, 90, 100]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(items = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5]],queries = [5, 10, 15]) == [0, 5, 5]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(items = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],queries = [5, 4, 3, 2, 1]) == [10, 10, 10, 10, 10]\n assert candidate(items = [[1, 10], [10, 1], [100, 100], [1000, 1], [10000, 10000], [100000, 1], [1000000, 1000000]],queries = [1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000, 500000, 1000000, 1500000]) == [10, 10, 10, 10, 100, 100, 100, 100, 10000, 10000, 10000, 10000, 1000000, 1000000]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[100, 500], [200, 1000], [300, 1500], [400, 2000], [500, 2500]],queries = [50, 150, 250, 350, 450, 550]) == [0, 500, 1000, 1500, 2000, 2500]\n assert candidate(items = [[1, 10], [3, 20], [2, 30], [5, 40], [4, 50]],queries = [1, 2, 3, 4, 5]) == [10, 30, 30, 50, 50]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1]) == [10]\n assert candidate(items = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [1, 5, 9, 13, 17, 19, 19, 19, 19, 19]\n assert candidate(items = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(items = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]],queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(items = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8], [100000000, 9], [1000000000, 10]],queries = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [5, 6, 7, 8, 9, 10, 10, 10, 10, 10]\n assert candidate(items = [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]],queries = [15, 25, 35, 45, 55]) == [5, 5, 5, 5, 5]\n assert candidate(items = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10]],queries = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1]) == [10]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20]\n assert candidate(items = [[1, 10], [10, 20], [100, 30], [1000, 40], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8], [100000000, 9], [1000000000, 10]],queries = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [10, 20, 30, 40, 40, 40, 40, 40, 40, 40]\n assert candidate(items = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500]],queries = [5, 15, 25, 35, 45, 55]) == [0, 100, 200, 300, 400, 500]\n assert candidate(items = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [50, 150, 250, 350, 450, 550]) == [0, 100, 200, 300, 400, 500]\n assert candidate(items = [[1, 100], [50, 50], [100, 10], [150, 1], [200, 50], [250, 100], [300, 150], [350, 200], [400, 250], [450, 300]],queries = [25, 50, 75, 125, 175, 225, 275, 325, 375, 425]) == [100, 100, 100, 100, 100, 100, 100, 150, 200, 250]\n assert candidate(items = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]\n assert candidate(items = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [0, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(items = [[1000000000, 1], [999999999, 2], [999999998, 3], [999999997, 4], [999999996, 5]],queries = [1, 2, 3, 4, 5]) == [0, 0, 0, 0, 0]\n assert candidate(items = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [10, 15, 20, 25]) == [10, 16, 20, 20]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],queries = [1, 3, 5, 7, 9, 11, 13, 15]) == [1, 3, 5, 7, 9, 11, 13, 15]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(items = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5]],queries = [4, 5, 6]) == [0, 5, 5]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],queries = [1]) == [5]\n assert candidate(items = [[1, 2], [3, 5], [2, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]],queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [6, 8, 12, 16, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(items = [[1, 100], [100, 1], [1, 200], [100, 2], [1, 300], [100, 3], [1, 400], [100, 4], [1, 500], [100, 5]],queries = [1, 50, 100, 150, 200]) == [500, 500, 500, 500, 500]\n assert candidate(items = [[1, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1000000000], [1000000000, 1]],queries = [500000000, 1000000000]) == [1000000000, 1000000000]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]\n assert candidate(items = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5]\n assert candidate(items = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9]],queries = [1, 2, 3, 4, 5, 6]) == [0, 0, 0, 0, 9, 9]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 20, 30, 40, 50, 50, 50, 50, 50, 50]\n assert candidate(items = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996]],queries = [1, 2, 3, 4, 5]) == [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]\n assert candidate(items = [[5, 20], [5, 18], [5, 16], [5, 14], [5, 12], [5, 10], [5, 8], [5, 6], [5, 4], [5, 2]],queries = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(items = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1], [2, 2], [2, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10]],queries = [2, 4, 6, 8, 10]) == [3, 7, 10, 10, 10]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1000000000], [1000000000, 1]],queries = [1, 1000000000]) == [1000000000, 1000000000]\n assert candidate(items = [[100, 500], [200, 400], [300, 300], [400, 200], [500, 100]],queries = [50, 150, 250, 350, 450, 550]) == [0, 500, 500, 500, 500, 500]\n assert candidate(items = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(items = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700], [80, 800], [90, 900], [100, 1000]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(items = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],queries = [1, 3, 5, 7, 9, 11]) == [100, 300, 500, 700, 900, 1000]\n assert candidate(items = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]],queries = [1, 5, 10, 15, 20, 25, 30]) == [1, 9, 19, 19, 19, 19, 19]\n assert candidate(items = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]\n", "comparison": "exact"}, "public_tests": ["[[1,2],[3,2],[2,4],[5,6],[3,5]]\n[1,2,3,4,5,6]", "[[1,2],[1,2],[1,3],[1,4]]\n[1]", "[[10,1000]]\n[5]"], "hints": ["Can we process the queries in a smart order to avoid repeatedly checking the same items?", "How can we use the answer to a query for other queries?"], "metadata": {"canonical_parameter_names": ["items", "queries"], "leetcode_dataset_entry_point": "Solution().maximumBeauty", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:05+00:00", "tests_total": 106, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "binary-search", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maximumBeauty(self, items: list[list[int]], queries: list[int]) -> list[int]:", "container": "Solution", "callable": "maximumBeauty", "parameters": [{"name": "items", "type": "list[list[int]]"}, {"name": "queries", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2071, "task_id": "maximum-number-of-tasks-you-can-assign", "difficulty": "Hard", "problem_description": "You have n tasks and m workers. Each task has a strength requirement stored in a 0-indexed integer array tasks, with the i^th task requiring tasks[i] strength to complete. The strength of each worker is stored in a 0-indexed integer array workers, with the j^th worker having workers[j] strength. Each worker can only be assigned to a single task and must have a strength greater than or equal to the task's strength requirement (i.e., workers[j] >= tasks[i]).\n\nAdditionally, you have pills magical pills that will increase a worker's strength by strength. You can decide which workers receive the magical pills, however, you may only give each worker at most one magical pill.\n\nGiven the 0-indexed integer arrays tasks and workers and the integers pills and strength, return the maximum number of tasks that can be completed.\n\nExample 1:\n\nInput: tasks = [3,2,1], workers = [0,3,3], pills = 1, strength = 1\nOutput: 3\nExplanation:\nWe can assign the magical pill and tasks as follows:\n- Give the magical pill to worker 0.\n- Assign worker 0 to task 2 (0 + 1 >= 1)\n- Assign worker 1 to task 1 (3 >= 2)\n- Assign worker 2 to task 0 (3 >= 3)\n\nExample 2:\n\nInput: tasks = [5,4], workers = [0,0,0], pills = 1, strength = 5\nOutput: 1\nExplanation:\nWe can assign the magical pill and tasks as follows:\n- Give the magical pill to worker 0.\n- Assign worker 0 to task 0 (0 + 5 >= 5)\n\nExample 3:\n\nInput: tasks = [10,15,30], workers = [0,10,10,10,10], pills = 3, strength = 10\nOutput: 2\nExplanation:\nWe can assign the magical pills and tasks as follows:\n- Give the magical pill to worker 0 and worker 1.\n- Assign worker 0 to task 0 (0 + 10 >= 10)\n- Assign worker 1 to task 1 (10 + 10 >= 15)\nThe last pill is not given because it will not make any worker strong enough for the last task.\n\nConstraints:\n\n- n == tasks.length\n- m == workers.length\n- 1 <= n, m <= 5 * 10^4\n- 0 <= pills <= m\n- 0 <= tasks[i], workers[j], strength <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [100, 200, 300],workers = [50, 150, 250, 350],pills = 2,strength = 100) == 3\n assert candidate(tasks = [10, 20, 30],workers = [30, 40, 50],pills = 0,strength = 10) == 3\n assert candidate(tasks = [10, 15, 30],workers = [0, 10, 10, 10, 10],pills = 3,strength = 10) == 2\n assert candidate(tasks = [100, 200, 300],workers = [100, 100, 100, 100, 100],pills = 2,strength = 100) == 2\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 5,strength = 5) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 0,strength = 1) == 5\n assert candidate(tasks = [5, 5, 5, 5],workers = [1, 1, 1, 1],pills = 4,strength = 4) == 4\n assert candidate(tasks = [100, 200, 300],workers = [150, 250, 350],pills = 1,strength = 100) == 3\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 0,strength = 2) == 5\n assert candidate(tasks = [100, 200, 300],workers = [150, 250, 350],pills = 2,strength = 50) == 3\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [5, 15, 25, 35, 45],pills = 2,strength = 10) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 2,strength = 5) == 5\n assert candidate(tasks = [5, 4],workers = [0, 0, 0],pills = 1,strength = 5) == 1\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [1, 2, 3, 4, 5],pills = 5,strength = 10) == 1\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [5, 15, 25, 35, 45],pills = 0,strength = 10) == 4\n assert candidate(tasks = [9, 8, 7, 6, 5],workers = [4, 4, 4, 4, 4],pills = 5,strength = 5) == 5\n assert candidate(tasks = [3, 6, 7, 11],workers = [6, 8, 9],pills = 2,strength = 3) == 3\n assert candidate(tasks = [1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1],pills = 5,strength = 0) == 5\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [5, 15, 25, 35, 45],pills = 5,strength = 10) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 5,strength = 0) == 5\n assert candidate(tasks = [1, 1, 1, 1],workers = [1, 1, 1, 1],pills = 4,strength = 0) == 4\n assert candidate(tasks = [1, 10, 100, 1000],workers = [1, 10, 100, 1000],pills = 2,strength = 500) == 4\n assert candidate(tasks = [3, 2, 1],workers = [0, 3, 3],pills = 1,strength = 1) == 3\n assert candidate(tasks = [1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1],pills = 0,strength = 0) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],pills = 10,strength = 5) == 20\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pills = 0,strength = 1) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],workers = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],pills = 10,strength = 5) == 30\n assert candidate(tasks = [3, 6, 9, 12, 15],workers = [3, 6, 9, 12, 15],pills = 2,strength = 3) == 5\n assert candidate(tasks = [1000000000, 1000000000, 1000000000],workers = [1000000000, 1000000000, 1000000000],pills = 3,strength = 0) == 3\n assert candidate(tasks = [1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1],pills = 3,strength = 1) == 5\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],pills = 10,strength = 0) == 10\n assert candidate(tasks = [50, 100, 150, 200, 250],workers = [40, 80, 120, 160, 200],pills = 3,strength = 60) == 4\n assert candidate(tasks = [5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],pills = 5,strength = 20) == 11\n assert candidate(tasks = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],workers = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],pills = 5,strength = 1) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500],workers = [100, 150, 200, 250, 300],pills = 2,strength = 100) == 4\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pills = 10,strength = 0) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 5,strength = 10) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [1, 1, 1, 1, 1],pills = 5,strength = 4) == 5\n assert candidate(tasks = [3, 6, 9, 12, 15],workers = [3, 6, 9, 12, 15],pills = 0,strength = 10) == 5\n assert candidate(tasks = [500000000, 500000000, 500000000, 500000000, 500000000],workers = [500000000, 500000000, 500000000, 500000000, 500000000],pills = 5,strength = 0) == 5\n assert candidate(tasks = [1, 3, 5, 7, 9],workers = [10, 20, 30, 40, 50],pills = 2,strength = 5) == 5\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pills = 5,strength = 0) == 10\n assert candidate(tasks = [1000000000],workers = [999999999],pills = 1,strength = 1) == 1\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [10, 20, 30, 40, 50],pills = 2,strength = 5) == 5\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950],pills = 5,strength = 100) == 9\n assert candidate(tasks = [1000, 2000, 3000],workers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pills = 5,strength = 500) == 1\n assert candidate(tasks = [5, 15, 25, 35, 45],workers = [1, 11, 21, 31, 41],pills = 2,strength = 10) == 4\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],workers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],pills = 15,strength = 1) == 15\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 5,strength = 1) == 10\n assert candidate(tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],workers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],pills = 10,strength = 0) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],workers = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400],pills = 10,strength = 20) == 20\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pills = 10,strength = 0) == 10\n assert candidate(tasks = [1000, 2000, 3000, 4000, 5000],workers = [500, 1000, 1500, 2000, 2500],pills = 4,strength = 1000) == 3\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [10, 20, 30, 40, 50],pills = 0,strength = 0) == 5\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],workers = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145],pills = 7,strength = 50) == 15\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],pills = 5,strength = 5) == 10\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15],workers = [2, 4, 6, 8, 10, 12, 14, 16],pills = 3,strength = 2) == 8\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pills = 5,strength = 2) == 10\n assert candidate(tasks = [5, 10, 15, 20, 25, 30],workers = [10, 15, 20, 25, 30, 35],pills = 3,strength = 5) == 6\n assert candidate(tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 3,strength = 5) == 10\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pills = 5,strength = 50) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],pills = 5,strength = 10) == 20\n assert candidate(tasks = [100, 200, 300, 400, 500],workers = [150, 250, 350, 450, 550],pills = 3,strength = 100) == 5\n assert candidate(tasks = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 3,strength = 20) == 10\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],workers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pills = 5,strength = 1) == 10\n assert candidate(tasks = [5, 15, 25, 35, 45],workers = [1, 1, 1, 1, 1],pills = 5,strength = 40) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],pills = 10,strength = 4) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pills = 5,strength = 50) == 10\n assert candidate(tasks = [50, 50, 50, 50, 50],workers = [100, 100, 100, 100, 100],pills = 2,strength = 10) == 5\n assert candidate(tasks = [500, 400, 300, 200, 100],workers = [100, 200, 300, 400, 500],pills = 2,strength = 100) == 5\n assert candidate(tasks = [100, 150, 200, 250, 300],workers = [50, 100, 150, 200, 250],pills = 2,strength = 50) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pills = 5,strength = 1) == 10\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],pills = 10,strength = 0) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500],workers = [100, 200, 300, 400, 500],pills = 5,strength = 500) == 5\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 5,strength = 0) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],workers = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 7,strength = 3) == 15\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],workers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pills = 5,strength = 0) == 10\n assert candidate(tasks = [999999999, 999999998, 999999997, 999999996, 999999995],workers = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],pills = 2,strength = 1) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 0,strength = 1) == 10\n assert candidate(tasks = [5, 25, 50, 75, 100],workers = [10, 20, 30, 40, 50],pills = 3,strength = 20) == 3\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pills = 0,strength = 0) == 10\n assert candidate(tasks = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 10,strength = 9) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],workers = [900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800],pills = 10,strength = 200) == 20\n assert candidate(tasks = [1, 5, 9, 13, 17, 21, 25],workers = [2, 6, 10, 14, 18, 22, 26],pills = 3,strength = 1) == 7\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 4,strength = 10) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pills = 5,strength = 1) == 10\n assert candidate(tasks = [500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],workers = [500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],pills = 3,strength = 200) == 11\n assert candidate(tasks = [1000, 2000, 3000, 4000, 5000],workers = [500, 1500, 2500, 3500, 4500],pills = 2,strength = 1000) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 10,strength = 1) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pills = 5,strength = 1) == 10\n assert candidate(tasks = [1000000000, 1000000000],workers = [1000000000, 1000000000],pills = 1,strength = 0) == 2\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 10,strength = 10) == 10\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],pills = 5,strength = 10) == 2\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],pills = 5,strength = 1) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 0,strength = 0) == 10\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],workers = [20, 22, 24, 26, 28, 30, 32, 34, 36, 38],pills = 5,strength = 10) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],workers = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 5,strength = 10) == 20\n assert candidate(tasks = [90, 80, 70, 60, 50, 40, 30, 20, 10],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90],pills = 4,strength = 20) == 9\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pills = 0,strength = 100) == 10\n assert candidate(tasks = [50, 60, 70, 80, 90],workers = [40, 50, 60, 70, 80],pills = 3,strength = 10) == 4\n assert candidate(tasks = [500, 500, 500, 500, 500],workers = [250, 250, 250, 250, 250],pills = 5,strength = 250) == 5\n assert candidate(tasks = [10, 10, 10, 10, 10],workers = [1, 1, 1, 1, 1],pills = 5,strength = 9) == 5\n assert candidate(tasks = [1000000000, 1000000000, 1000000000],workers = [1000000000, 1000000000, 1000000000],pills = 1,strength = 0) == 3\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950],pills = 5,strength = 50) == 9\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950],pills = 10,strength = 100) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500, 600],workers = [100, 200, 300, 400, 500, 600],pills = 0,strength = 0) == 6\n assert candidate(tasks = [1000000000],workers = [1000000000],pills = 0,strength = 0) == 1\n assert candidate(tasks = [5, 15, 25, 35, 45, 55],workers = [10, 20, 30, 40, 50, 60],pills = 3,strength = 10) == 6\n assert candidate(tasks = [1000000000],workers = [1000000000],pills = 1,strength = 0) == 1\n assert candidate(tasks = [9, 8, 7, 6, 5, 4, 3, 2, 1],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9],pills = 0,strength = 2) == 9\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],pills = 5,strength = 10) == 10\n assert candidate(tasks = [1, 3, 5, 7, 9],workers = [2, 4, 6, 8, 10],pills = 2,strength = 1) == 5\n assert candidate(tasks = [10000, 20000, 30000, 40000, 50000],workers = [1000, 2000, 3000, 4000, 5000],pills = 5,strength = 10000) == 1\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],pills = 5,strength = 5) == 9\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [100, 200, 300, 400, 500],pills = 5,strength = 500) == 5\n assert candidate(tasks = [500000000, 500000000],workers = [500000000, 500000000],pills = 2,strength = 0) == 2\n assert candidate(tasks = [50, 100, 150, 200, 250],workers = [100, 150, 200, 250, 300],pills = 3,strength = 50) == 5\n assert candidate(tasks = [9, 18, 27, 36, 45, 54],workers = [12, 24, 36, 48, 60, 72],pills = 5,strength = 6) == 6\n assert candidate(tasks = [10, 10, 10, 10, 10],workers = [10, 10, 10, 10, 10],pills = 5,strength = 0) == 5\n", "comparison": "exact"}, "public_tests": ["[3,2,1]\n[0,3,3]\n1\n1", "[5,4]\n[0,0,0]\n1\n5", "[10,15,30]\n[0,10,10,10,10]\n3\n10"], "hints": ["Is it possible to assign the first k smallest tasks to the workers?", "How can you efficiently try every k?"], "metadata": {"canonical_parameter_names": ["tasks", "workers", "pills", "strength"], "leetcode_dataset_entry_point": "Solution().maxTaskAssign", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:08+00:00", "tests_total": 119, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "two-pointers", "binary-search", "greedy", "queue", "sorting", "monotonic-queue"]}, "language": "python", "interface": {"raw_signature": "def maxTaskAssign(self, tasks: list[int], workers: list[int], pills: int, strength: int) -> int:", "container": "Solution", "callable": "maxTaskAssign", "parameters": [{"name": "tasks", "type": "list[int]"}, {"name": "workers", "type": "list[int]"}, {"name": "pills", "type": "int"}, {"name": "strength", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2073, "task_id": "time-needed-to-buy-tickets", "difficulty": "Easy", "problem_description": "There are n people in a line queuing to buy tickets, where the 0^th person is at the front of the line and the (n - 1)^th person is at the back of the line.\n\nYou are given a 0-indexed integer array tickets of length n where the number of tickets that the i^th person would like to buy is tickets[i].\n\nEach person takes exactly 1 second to buy a ticket. A person can only buy 1 ticket at a time and has to go back to the end of the line (which happens instantaneously) in order to buy more tickets. If a person does not have any tickets left to buy, the person will leave the line.\n\nReturn the time taken for the person initially at position k (0-indexed) to finish buying tickets.\n\nExample 1:\n\nInput: tickets = [2,3,2], k = 2\nOutput: 6\nExplanation:\n- The queue starts as [2,3,2], where the kth person is underlined.\n- After the person at the front has bought a ticket, the queue becomes [3,2,1] at 1 second.\n- Continuing this process, the queue becomes [2,1,2] at 2 seconds.\n- Continuing this process, the queue becomes [1,2,1] at 3 seconds.\n- Continuing this process, the queue becomes [2,1] at 4 seconds. Note: the person at the front left the queue.\n- Continuing this process, the queue becomes [1,1] at 5 seconds.\n- Continuing this process, the queue becomes [1] at 6 seconds. The kth person has bought all their tickets, so return 6.\n\nExample 2:\n\nInput: tickets = [5,1,1,1], k = 0\nOutput: 8\nExplanation:\n- The queue starts as [5,1,1,1], where the kth person is underlined.\n- After the person at the front has bought a ticket, the queue becomes [1,1,1,4] at 1 second.\n- Continuing this process for 3 seconds, the queue becomes [4] at 4 seconds.\n- Continuing this process for 4 seconds, the queue becomes [] at 8 seconds. The kth person has bought all their tickets, so return 8.\n\nConstraints:\n\n- n == tickets.length\n- 1 <= n <= 100\n- 1 <= tickets[i] <= 100\n- 0 <= k < n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tickets = [5, 1, 1, 1],k = 0) == 8\n assert candidate(tickets = [4, 3, 2, 1],k = 1) == 9\n assert candidate(tickets = [100, 100, 100],k = 1) == 299\n assert candidate(tickets = [1],k = 0) == 1\n assert candidate(tickets = [10, 10, 10],k = 2) == 30\n assert candidate(tickets = [10, 10, 10],k = 0) == 28\n assert candidate(tickets = [10, 10, 10],k = 1) == 29\n assert candidate(tickets = [1, 2, 3, 4, 5],k = 4) == 15\n assert candidate(tickets = [2, 3, 2],k = 2) == 6\n assert candidate(tickets = [100, 100, 100],k = 2) == 300\n assert candidate(tickets = [1, 1, 1, 1],k = 2) == 3\n assert candidate(tickets = [1, 1, 1, 1],k = 1) == 2\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 19) == 110\n assert candidate(tickets = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 10) == 59\n assert candidate(tickets = [9, 3, 5, 7, 1, 2, 6],k = 4) == 5\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 91\n assert candidate(tickets = [7, 2, 9, 1, 8, 3, 6, 4, 5],k = 6) == 39\n assert candidate(tickets = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 15) == 86\n assert candidate(tickets = [1, 2, 3, 4, 5, 4, 3, 2, 1],k = 8) == 9\n assert candidate(tickets = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 15) == 76\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 91\n assert candidate(tickets = [25, 30, 15, 20, 10],k = 3) == 85\n assert candidate(tickets = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == 44\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 4) == 25\n assert candidate(tickets = [5, 2, 3, 1, 4],k = 2) == 11\n assert candidate(tickets = [5, 1, 2, 3, 4],k = 0) == 15\n assert candidate(tickets = [3, 1, 5, 4, 2],k = 3) == 14\n assert candidate(tickets = [7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 99\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 10\n assert candidate(tickets = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 8) == 29\n assert candidate(tickets = [9, 3, 8, 4, 6, 7, 5, 2, 1],k = 1) == 19\n assert candidate(tickets = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19) == 20\n assert candidate(tickets = [1, 5, 3, 4, 2, 6, 7, 8],k = 5) == 31\n assert candidate(tickets = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 15) == 28\n assert candidate(tickets = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2],k = 10) == 192\n assert candidate(tickets = [5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1],k = 19) == 20\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 81\n assert candidate(tickets = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4) == 395\n assert candidate(tickets = [1, 2, 3, 4, 3, 2, 1],k = 5) == 12\n assert candidate(tickets = [5, 3, 5, 2, 4, 1, 3],k = 3) == 11\n assert candidate(tickets = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4],k = 10) == 43\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 85\n assert candidate(tickets = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5) == 16\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 45\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 9) == 90\n assert candidate(tickets = [1, 2, 3, 4, 5, 4, 3, 2, 1],k = 4) == 25\n assert candidate(tickets = [2, 6, 3, 4, 5, 1],k = 2) == 13\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 10\n assert candidate(tickets = [20, 1, 20, 1, 20],k = 2) == 61\n assert candidate(tickets = [25, 30, 5, 10, 15],k = 1) == 85\n assert candidate(tickets = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 8) == 9\n assert candidate(tickets = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 4) == 35\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 40\n assert candidate(tickets = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 0) == 45\n assert candidate(tickets = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 0) == 1\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 156\n assert candidate(tickets = [5, 4, 3, 2, 1],k = 0) == 15\n assert candidate(tickets = [4, 2, 3, 3, 1, 4, 2, 3],k = 5) == 22\n assert candidate(tickets = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 50) == 104\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == 210\n assert candidate(tickets = [5, 6, 7, 8, 9],k = 2) == 30\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 49) == 162\n assert candidate(tickets = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 6\n assert candidate(tickets = [10, 15, 5, 20, 25, 30, 5],k = 4) == 104\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 0) == 55\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 35\n assert candidate(tickets = [1, 5, 2, 3, 4, 5],k = 5) == 20\n assert candidate(tickets = [3, 1, 5, 2, 4, 6],k = 3) == 9\n assert candidate(tickets = [20, 15, 10, 5, 1],k = 0) == 51\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == 1\n assert candidate(tickets = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 19) == 20\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 41\n assert candidate(tickets = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 11\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 156\n assert candidate(tickets = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 9) == 30\n assert candidate(tickets = [10, 1, 10, 1, 10, 1, 10],k = 3) == 4\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 0) == 163\n assert candidate(tickets = [10, 5, 4, 6, 3, 8, 2],k = 4) == 19\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 55\n assert candidate(tickets = [2, 5, 3, 4, 1, 2],k = 2) == 13\n assert candidate(tickets = [10, 20, 30, 40, 50],k = 2) == 118\n assert candidate(tickets = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 0) == 393\n assert candidate(tickets = [3, 2, 1, 4, 5, 6],k = 5) == 21\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 238\n assert candidate(tickets = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 5) == 36\n assert candidate(tickets = [20, 15, 10, 5, 1],k = 1) == 46\n assert candidate(tickets = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 9) == 10\n assert candidate(tickets = [3, 3, 3, 3, 3],k = 2) == 13\n assert candidate(tickets = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 96\n assert candidate(tickets = [50, 50, 50, 50, 50],k = 2) == 248\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 7) == 38\n assert candidate(tickets = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],k = 9) == 110\n assert candidate(tickets = [7, 8, 9, 10, 11, 12, 13, 14],k = 5) == 79\n assert candidate(tickets = [3, 5, 2, 4, 1],k = 2) == 8\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 24\n assert candidate(tickets = [1, 1, 1, 2, 2, 2, 3, 3, 3],k = 6) == 16\n assert candidate(tickets = [5, 4, 3, 2, 1],k = 2) == 12\n assert candidate(tickets = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 8) == 29\n assert candidate(tickets = [50, 30, 20, 10, 90, 80, 70, 60],k = 4) == 410\n", "comparison": "exact"}, "public_tests": ["[2,3,2]\n2", "[5,1,1,1]\n0"], "hints": ["Loop through the line of people and decrement the number of tickets for each to buy one at a time as if simulating the line moving forward. Keep track of how many tickets have been sold up until person k has no more tickets to buy.", "Remember that those who have no more tickets to buy will leave the line."], "metadata": {"canonical_parameter_names": ["tickets", "k"], "leetcode_dataset_entry_point": "Solution().timeRequiredToBuy", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:10+00:00", "tests_total": 99, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "queue", "simulation"]}, "language": "python", "interface": {"raw_signature": "def timeRequiredToBuy(self, tickets: list[int], k: int) -> int:", "container": "Solution", "callable": "timeRequiredToBuy", "parameters": [{"name": "tickets", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2075, "task_id": "decode-the-slanted-ciphertext", "difficulty": "Medium", "problem_description": "A string originalText is encoded using a slanted transposition cipher to a string encodedText with the help of a matrix having a fixed number of rows rows.\n\noriginalText is placed first in a top-left to bottom-right manner.\n\nThe blue cells are filled first, followed by the red cells, then the yellow cells, and so on, until we reach the end of originalText. The arrow indicates the order in which the cells are filled. All empty cells are filled with ' '. The number of columns is chosen such that the rightmost column will not be empty after filling in originalText.\n\nencodedText is then formed by appending all characters of the matrix in a row-wise fashion.\n\nThe characters in the blue cells are appended first to encodedText, then the red cells, and so on, and finally the yellow cells. The arrow indicates the order in which the cells are accessed.\n\nFor example, if originalText = \"cipher\" and rows = 3, then we encode it in the following manner:\n\nThe blue arrows depict how originalText is placed in the matrix, and the red arrows denote the order in which encodedText is formed. In the above example, encodedText = \"ch ie pr\".\n\nGiven the encoded string encodedText and number of rows rows, return the original string originalText.\n\nNote: originalText does not have any trailing spaces ' '. The test cases are generated such that there is only one possible originalText.\n\nExample 1:\n\nInput: encodedText = \"ch ie pr\", rows = 3\nOutput: \"cipher\"\nExplanation: This is the same example described in the problem description.\n\nExample 2:\n\nInput: encodedText = \"iveo eed l te olc\", rows = 4\nOutput: \"i love leetcode\"\nExplanation: The figure above denotes the matrix that was used to encode originalText.\nThe blue arrows show how we can find originalText from encodedText.\n\nExample 3:\n\nInput: encodedText = \"coding\", rows = 1\nOutput: \"coding\"\nExplanation: Since there is only 1 row, both originalText and encodedText are the same.\n\nConstraints:\n\n- 0 <= encodedText.length <= 10^6\n- encodedText consists of lowercase English letters and ' ' only.\n- encodedText is a valid encoding of some originalText that does not have trailing spaces.\n- 1 <= rows <= 1000\n- The testcases are generated such that there is only one possible originalText.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(encodedText = \"a\",rows = 1) == \"a\"\n assert candidate(encodedText = \"abcd efg hijk\",rows = 3) == \"aeibfjcgd\"\n assert candidate(encodedText = \"a b c d\",rows = 2) == \"a c b\"\n assert candidate(encodedText = \"coding\",rows = 1) == \"coding\"\n assert candidate(encodedText = \"abc def ghi jkl mno\",rows = 5) == \"adgbec\"\n assert candidate(encodedText = \"ab c de\",rows = 2) == \"a bd ec\"\n assert candidate(encodedText = \"ch ie pr\",rows = 3) == \"cipher\"\n assert candidate(encodedText = \"iveo eed l te olc\",rows = 4) == \"i love leetcode\"\n assert candidate(encodedText = \"python programming is fun\",rows = 4) == \"ppm yriftonuhggorn\"\n assert candidate(encodedText = \"algorithms and data structures\",rows = 5) == \"ah telmdrsgsauo trai\"\n assert candidate(encodedText = \"hello world from leetcode challenges\",rows = 6) == \"hrmt nel c gld ocl do fw\"\n assert candidate(encodedText = \"t a c o s e q u i r r e s e l l f o o d s o u p\",rows = 5) == \"t e s q f a s o u o c e u i o o l r s\"\n assert candidate(encodedText = \"one two three four five six\",rows = 3) == \"oh nrfeei ev e t wf oos ui rx\"\n assert candidate(encodedText = \"programming challenges are fun\",rows = 4) == \"pilrrneeogn g gfrceahm\"\n assert candidate(encodedText = \"filling the matrix in a slanted manner\",rows = 6) == \"f t aaitr nnlhi tnlexaei n g\"\n assert candidate(encodedText = \"p y trh e t s o n a\",rows = 3) == \"pe y t t nrs h\"\n assert candidate(encodedText = \"m e t a l l i c a\",rows = 3) == \"mai elc t\"\n assert candidate(encodedText = \"\",rows = 10) == \"\"\n assert candidate(encodedText = \"padding with spaces at the end \",rows = 5) == \"pwc aiet dtsh dh e i n g a s\"\n assert candidate(encodedText = \"a b c d e f g h i\",rows = 9) == \"abcd\"\n assert candidate(encodedText = \"qo su me ve rt\",rows = 5) == \"qsmvoue\"\n assert candidate(encodedText = \"sh jfuew xq z r e\",rows = 3) == \"sw h x jqrf u\"\n assert candidate(encodedText = \"this is a test string\",rows = 5) == \"ti ghstsi esa\"\n assert candidate(encodedText = \"abcdef ghijkl mnopqr stuvwx yz\",rows = 5) == \"agmsybhntzcioudjpekf\"\n assert candidate(encodedText = \"a quick brown fox jumps over the lazy dog\",rows = 6) == \"a fp z bostqrx uo iwc\"\n assert candidate(encodedText = \"wcy hmu eai xfi\",rows = 3) == \"wu c xy f ei ah\"\n assert candidate(encodedText = \"two words\",rows = 1) == \"two words\"\n assert candidate(encodedText = \"th qzih xof c \",rows = 3) == \"th h c x qoz\"\n assert candidate(encodedText = \"ab c d e f g h i j\",rows = 10) == \"a b ef d c\"\n assert candidate(encodedText = \"programming in python is fun\",rows = 3) == \"pgnr oiignsr apfmyumti\"\n assert candidate(encodedText = \"spaces in between words\",rows = 4) == \"s twpiwoanerc ede ns\"\n assert candidate(encodedText = \"qjewukcuvm xs ezmrg\",rows = 4) == \"qcsmju rev wmu\"\n assert candidate(encodedText = \"this is a longer example to test the decoding function\",rows = 8) == \"t epteharlei esle oi\"\n assert candidate(encodedText = \"q w e r t y u i o p\",rows = 4) == \"q y r w\"\n assert candidate(encodedText = \"a q o q r s\",rows = 6) == \"aqoq\"\n assert candidate(encodedText = \"abcdefghi jklmnop qrstuv wx yz\",rows = 5) == \"ahntybiouzc pvdj ekf\"\n assert candidate(encodedText = \"i s l a n d o f d r e a m s\",rows = 3) == \"i r s e o l a f a m n\"\n assert candidate(encodedText = \"s h e e l s s f i r e\",rows = 5) == \"se hls e\"\n assert candidate(encodedText = \"abc def ghi jkl mno pqr stu vwx yz\",rows = 6) == \"afjosb k cgl hd\"\n assert candidate(encodedText = \"hello world this is a test\",rows = 5) == \"hwtsteoh elri slls od\"\n assert candidate(encodedText = \"c o n s t a n t i n o p o l i s\",rows = 6) == \"csnno ott n\"\n assert candidate(encodedText = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",rows = 5) == \"a l w g r b m x h s c n y i t d o j e\"\n assert candidate(encodedText = \"this is a test of the emergency broadcast system\",rows = 6) == \"t tedththnceieecamss ys te i mso\"\n assert candidate(encodedText = \"x w v u t s r q p o n m l k j i h g f e d c b a\",rows = 26) == \"x\"\n assert candidate(encodedText = \"keep it secret keep it safe\",rows = 6) == \"kicketre p\"\n assert candidate(encodedText = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",rows = 26) == \"a\"\n assert candidate(encodedText = \"hello world from the other side\",rows = 4) == \"hr eeltrldh l esof rw\"\n assert candidate(encodedText = \"data structures and algorithms\",rows = 8) == \"d uast\"\n assert candidate(encodedText = \"abcdefghij klmnopqrst uvwxyz\",rows = 3) == \"a tbk cludmvenwfoxgpyhqi\"\n assert candidate(encodedText = \"singleword\",rows = 10) == \"s\"\n assert candidate(encodedText = \"the quick brown fox jumps over the lazy dog\",rows = 6) == \"tkfshdh o eoebxo r vqojuwi\"\n assert candidate(encodedText = \"thisisaverylongstringthatwillbereconstructedusingtheslantedciphertechnique\",rows = 7) == \"tlhcunehoaostcintniehsgwsndnisitgcstlrtarluvibenr\"\n assert candidate(encodedText = \"one\",rows = 1) == \"one\"\n assert candidate(encodedText = \"z y x w v u t s r q p o n m l k j i h g f e d c b a\",rows = 5) == \"z o d t i y n c s h x m b r g w l q v\"\n assert candidate(encodedText = \"t h e q u i c k b r o w n f o x j u m p s o v e r t h e l a z y d o g\",rows = 7) == \"tcnjohy hk uve ebfme d qropr uox i\"\n assert candidate(encodedText = \"abcdefgh ijklmnop qrstuvwx yz this is a test\",rows = 5) == \"ajs ibkt sclu dmv aenw foxtgp h\"\n assert candidate(encodedText = \"a quick movement of the enemy will jeopardize five gunboats\",rows = 7) == \"aofme b v yofoqet piumhwaieeicn kt\"\n assert candidate(encodedText = \"slantedtranspositioncipheriscomplexandfun\",rows = 7) == \"sdpoeltonarsnat\"\n assert candidate(encodedText = \"one two three four five six seven eight nine ten eleven twelve\",rows = 4) == \"oun nr ee el fietigvwvheoetn tsnthiiwrxnee eles ef\"\n assert candidate(encodedText = \"abcdefghij\",rows = 1) == \"abcdefghij\"\n assert candidate(encodedText = \"x y z \",rows = 3) == \"x zy\"\n assert candidate(encodedText = \"machine learning is fascinating\",rows = 7) == \"mnagaerc h\"\n assert candidate(encodedText = \"lqtk e o mu yzfe ot i g rya wne l oxtesn gdeo\",rows = 5) == \"luie q gtygldkz e frooeeyx aoo\"\n assert candidate(encodedText = \"p r o g r a m m i n g l a n g u a g e s\",rows = 5) == \"p n g a n r g e m g o m g\"\n assert candidate(encodedText = \"wecoloveleetcode\",rows = 2) == \"weeectocloodvee\"\n assert candidate(encodedText = \"example of a very long encoded text\",rows = 7) == \"e eon x rnca aygm po lfe\"\n assert candidate(encodedText = \"longer text with multiple spaces in between\",rows = 3) == \"lheo snm guielnrt ibtpeeltxewt e sewpi\"\n assert candidate(encodedText = \"it wof eit ss dp\",rows = 4) == \"iftst w\"\n assert candidate(encodedText = \"a b c d e\",rows = 5) == \"a b c\"\n assert candidate(encodedText = \"abcd efgh ijkl mnop qrst uvwx yz\",rows = 5) == \"ag rxbhms c ntdio je\"\n assert candidate(encodedText = \"the quick brown fox jumps over lazy dogs\",rows = 4) == \"trmzhopyews n dq ooufvgioescxrk\"\n assert candidate(encodedText = \"thisisaverylongtextthatneedstobeencodedusingaslantedtranspositioncipher\",rows = 8) == \"trtsdsaohyttelnilhodasoabuintesgnatv\"\n assert candidate(encodedText = \"spaces are handled correctly\",rows = 5) == \"s h tp a laancycrdoeels\"\n assert candidate(encodedText = \"f l e x i b l e r e s o u r c e s\",rows = 5) == \"fi oe lbrus ele x\"\n assert candidate(encodedText = \"t h e q u i c k b r o w n f o x j u m p s o v e r l a z y d o g s\",rows = 3) == \"t v n h e e r f o q l x u a i z j c y u k m d p b o s r g o\"\n assert candidate(encodedText = \"a b c d e f g h i\",rows = 9) == \"a de c b\"\n assert candidate(encodedText = \"python programming is fun\",rows = 3) == \"po ygitrsha omfnmu ip\"\n assert candidate(encodedText = \"spaces between words are preserved\",rows = 3) == \"sn p a c pewrsoe rs de srb ve et dwae\"\n assert candidate(encodedText = \"keep calm and code on\",rows = 2) == \"knede pc ocdael mo\"\n assert candidate(encodedText = \"abcdefgh ijklmnop qrstuv wxyz\",rows = 4) == \"a p bi wcjqxdkryelsfmg\"\n assert candidate(encodedText = \"decoding slanted transposition cipher is challenging\",rows = 7) == \"d si gestipcclrthoaaidnnitn\"\n assert candidate(encodedText = \"a quick brown fox jumps over the lazy dog\",rows = 3) == \"af otqxhu eij culkma pzbsyr oodwvn\"\n assert candidate(encodedText = \"the quick brown fox jumps over the lazy dog and then some more text to fill\",rows = 8) == \"tbj der hrutonefeomhg wpe sqns au lifocok\"\n assert candidate(encodedText = \"empty string test\",rows = 1) == \"empty string test\"\n assert candidate(encodedText = \"u p d o w n w i d e t h i n g s\",rows = 4) == \"uwdi pnen g dwt o\"\n assert candidate(encodedText = \"this is a test of the emergency broadcast system\",rows = 5) == \"tteythe isebsstmry eosiorasfg a\"\n assert candidate(encodedText = \"shorttext\",rows = 1) == \"shorttext\"\n assert candidate(encodedText = \"a quick brown fox jumps over the lazy dog\",rows = 5) == \"arjry ou qwmtdunphoi secf ko\"\n assert candidate(encodedText = \"a bcd efgh ijklm nopqrst uvwxy z\",rows = 5) == \"aekry fls gmtz h b nc d\"\n assert candidate(encodedText = \"one two three four five six seven eight nine ten\",rows = 4) == \"o x nf neosi uentrvew e ofnt i etvenheir e\"\n assert candidate(encodedText = \"a b c d e\",rows = 5) == \"abcd\"\n assert candidate(encodedText = \"thisisaverylongtextthatneedstobeencodedproperly\",rows = 6) == \"teeeerhrxenoiytdcsltsiohsna\"\n assert candidate(encodedText = \"the quick brown fox jumps over a lazy dog\",rows = 3) == \"tneh ref oaqx u lijacuzkmy p bsdr o\"\n assert candidate(encodedText = \"one two three four five six seven\",rows = 3) == \"oeene e s fitoxwu ors e v e ntfh\"\n assert candidate(encodedText = \"pythonprogramminglanguageisawesome\",rows = 5) == \"priuwyonaetggghrloan\"\n assert candidate(encodedText = \"sl yz vx qu tm\",rows = 4) == \"sz l\"\n assert candidate(encodedText = \"this is a long encoded text for testing\",rows = 7) == \"tsln fsh octoi noes gd a\"\n assert candidate(encodedText = \"abcdefghij klmnopqrst uvwxyz\",rows = 3) == \"a b ck dl emufnvgowhpxiqyjr\"\n assert candidate(encodedText = \"a quick brown fox jumps over the lazy dog\",rows = 4) == \"awsl n aq ozufvyioe cxrdk o jtbur\"\n assert candidate(encodedText = \"a b c d e\",rows = 5) == \"a b c\"\n assert candidate(encodedText = \"a bcd efgh ijklm nopqrst uvwxyz\",rows = 6) == \"a mqu r eibfc\"\n assert candidate(encodedText = \"a a a a a a a a a a\",rows = 10) == \"aaa\"\n assert candidate(encodedText = \"exampleofasingleword\",rows = 1) == \"exampleofasingleword\"\n assert candidate(encodedText = \"the quick brown fox jumps over lazy dogs\",rows = 5) == \"t xvdhb eoerjrg ou sqwmlunpi c\"\n assert candidate(encodedText = \"a very long text that is used to test the edge cases of the problem statement\",rows = 10) == \"ao ea ntut vghsee aerttye\"\n assert candidate(encodedText = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",rows = 6) == \"ae n w j s f o xb k t g pc l hd\"\n assert candidate(encodedText = \"onewordonly\",rows = 1) == \"onewordonly\"\n assert candidate(encodedText = \"python is an interpreted high level general purpose programming language\",rows = 6) == \"piiepayngrrntthaoghe lguorl ranpepag rvumeieermstlp e adn\"\n assert candidate(encodedText = \"abcdefghijklmnopqrstuvwxyz\",rows = 10) == \"adb\"\n assert candidate(encodedText = \"abcdefghijklmnopqrstuvwxyz\",rows = 26) == \"a\"\n assert candidate(encodedText = \"slantedtranspositioncipherexample\",rows = 10) == \"strlea\"\n", "comparison": "exact"}, "public_tests": ["\"ch ie pr\"\n3", "\"iveo eed l te olc\"\n4", "\"coding\"\n1"], "hints": ["How can you use rows and encodedText to find the number of columns of the matrix?", "Once you have the number of rows and columns, you can create the matrix and place encodedText in it. How should you place it in the matrix?", "How should you traverse the matrix to \"decode\" originalText?"], "metadata": {"canonical_parameter_names": ["encodedText", "rows"], "leetcode_dataset_entry_point": "Solution().decodeCiphertext", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:15+00:00", "tests_total": 112, "tests_dropped": 1, "flags": ["figure_reference", "has_images"], "topic_tags": ["string", "simulation"]}, "language": "python", "interface": {"raw_signature": "def decodeCiphertext(self, encodedText: str, rows: int) -> str:", "container": "Solution", "callable": "decodeCiphertext", "parameters": [{"name": "encodedText", "type": "str"}, {"name": "rows", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2076, "task_id": "process-restricted-friend-requests", "difficulty": "Hard", "problem_description": "You are given an integer n indicating the number of people in a network. Each person is labeled from 0 to n - 1.\n\nYou are also given a 0-indexed 2D integer array restrictions, where restrictions[i] = [x_i, y_i] means that person x_i and person y_i cannot become friends, either directly or indirectly through other people.\n\nInitially, no one is friends with each other. You are given a list of friend requests as a 0-indexed 2D integer array requests, where requests[j] = [u_j, v_j] is a friend request between person u_j and person v_j.\n\nA friend request is successful if u_j and v_j can be friends. Each friend request is processed in the given order (i.e., requests[j] occurs before requests[j + 1]), and upon a successful request, u_j and v_j become direct friends for all future friend requests.\n\nReturn a boolean array result, where each result[j] is true if the j^th friend request is successful or false if it is not.\n\nNote: If u_j and v_j are already direct friends, the request is still successful.\n\nExample 1:\n\nInput: n = 3, restrictions = [[0,1]], requests = [[0,2],[2,1]]\nOutput: [true,false]\nExplanation:\nRequest 0: Person 0 and person 2 can be friends, so they become direct friends.\nRequest 1: Person 2 and person 1 cannot be friends since person 0 and person 1 would be indirect friends (1--2--0).\n\nExample 2:\n\nInput: n = 3, restrictions = [[0,1]], requests = [[1,2],[0,2]]\nOutput: [true,false]\nExplanation:\nRequest 0: Person 1 and person 2 can be friends, so they become direct friends.\nRequest 1: Person 0 and person 2 cannot be friends since person 0 and person 1 would be indirect friends (0--2--1).\n\nExample 3:\n\nInput: n = 5, restrictions = [[0,1],[1,2],[2,3]], requests = [[0,4],[1,2],[3,1],[3,4]]\nOutput: [true,false,true,false]\nExplanation:\nRequest 0: Person 0 and person 4 can be friends, so they become direct friends.\nRequest 1: Person 1 and person 2 cannot be friends since they are directly restricted.\nRequest 2: Person 3 and person 1 can be friends, so they become direct friends.\nRequest 3: Person 3 and person 4 cannot be friends since person 0 and person 1 would be indirect friends (0--4--3--1).\n\nConstraints:\n\n- 2 <= n <= 1000\n- 0 <= restrictions.length <= 1000\n- restrictions[i].length == 2\n- 0 <= x_i, y_i <= n - 1\n- x_i != y_i\n- 1 <= requests.length <= 1000\n- requests[j].length == 2\n- 0 <= u_j, v_j <= n - 1\n- u_j != v_j\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,restrictions = [[0, 2], [1, 3]],requests = [[0, 1], [2, 3], [0, 3]]) == [True, True, False]\n assert candidate(n = 4,restrictions = [],requests = [[0, 1], [1, 2], [2, 3], [3, 0]]) == [True, True, True, True]\n assert candidate(n = 4,restrictions = [[0, 2], [1, 3]],requests = [[0, 1], [2, 3], [1, 2]]) == [True, True, False]\n assert candidate(n = 5,restrictions = [[0, 1], [1, 2], [2, 3]],requests = [[0, 4], [1, 2], [3, 1], [3, 4]]) == [True, False, True, False]\n assert candidate(n = 6,restrictions = [[1, 4], [2, 5]],requests = [[0, 3], [1, 2], [3, 4]]) == [True, True, True]\n assert candidate(n = 6,restrictions = [[0, 1], [2, 3], [4, 5]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 0], [5, 1]]) == [True, True, True, True, True, True]\n assert candidate(n = 6,restrictions = [[0, 1], [2, 3], [4, 5]],requests = [[0, 2], [1, 3], [4, 5], [2, 4]]) == [True, True, False, True]\n assert candidate(n = 3,restrictions = [[0, 1]],requests = [[1, 2], [0, 2]]) == [True, False]\n assert candidate(n = 3,restrictions = [[0, 1]],requests = [[0, 2], [2, 1]]) == [True, False]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],requests = [[0, 5], [2, 7], [4, 9], [1, 6]]) == [True, True, True, True]\n assert candidate(n = 12,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]],requests = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [0, 5], [2, 7], [4, 9], [6, 11]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 7,restrictions = [[0, 6], [1, 5], [2, 4]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0]]) == [True, True, True, False, True, True, False]\n assert candidate(n = 20,restrictions = [[0, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 10]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 9,restrictions = [[0, 3], [1, 4], [2, 5], [6, 8]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 0], [7, 1], [8, 2]]) == [True, True, False, True, True, True, True, False, True, True, False, False, True, True, True, False, False, True]\n assert candidate(n = 7,restrictions = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 0], [5, 1], [6, 2]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0]]) == [True, True, False, True, True, False, False]\n assert candidate(n = 10,restrictions = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 9]],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 3], [5, 2], [6, 1], [7, 0], [8, 5], [9, 4]]) == [True, True, True, True, False, True, False, True, True, False, False, False, False, True, False]\n assert candidate(n = 15,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 0], [14, 1]]) == [True, True, True, True, True, True, True, True, True, True, True, True, False, False, False]\n assert candidate(n = 8,restrictions = [[0, 4], [1, 5], [2, 6], [3, 7]],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [0, 5]]) == [True, True, True, True, False]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [True, True, True, True, False]\n assert candidate(n = 8,restrictions = [[0, 7], [1, 6], [2, 5], [3, 4]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]]) == [True, True, True, False, True, True, True, False]\n assert candidate(n = 9,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 0], [8, 1]],requests = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 0], [6, 1], [7, 2], [8, 3]]) == [True, True, True, True, False, False, False, False, False]\n assert candidate(n = 12,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False]\n assert candidate(n = 15,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 12], [12, 9], [13, 14], [14, 13]],requests = [[0, 3], [1, 4], [2, 0], [3, 1], [4, 2], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 5], [11, 6], [12, 7]]) == [True, True, False, False, False, False, True, True, True, False, True, True, True]\n assert candidate(n = 12,restrictions = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [0, 11]]) == [True, True, True, True, True, True, True]\n assert candidate(n = 8,restrictions = [[0, 4], [1, 5], [2, 6], [3, 7]],requests = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [0, 5], [1, 6], [2, 7], [3, 4]]) == [True, True, True, True, True, True, True, True, False, False, False, False]\n assert candidate(n = 8,restrictions = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4]],requests = [[0, 4], [1, 5], [2, 6], [3, 7], [0, 5], [1, 6], [2, 7], [3, 4]]) == [True, True, True, True, False, False, False, False]\n assert candidate(n = 8,restrictions = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4]],requests = [[0, 4], [1, 5], [2, 6], [3, 7]]) == [True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],requests = [[0, 5], [2, 7], [4, 9], [1, 6], [3, 8]]) == [True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]],requests = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 0], [9, 1]]) == [True, True, True, True, True, True]\n assert candidate(n = 7,restrictions = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 0], [5, 1], [6, 2]],requests = [[0, 6], [1, 5], [2, 4], [3, 0], [4, 1], [5, 2], [6, 3]]) == [True, False, True, False, False, False, False]\n assert candidate(n = 15,restrictions = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [True, True, True, True, False, True, True, True, True, False, True, True, True, True]\n assert candidate(n = 8,restrictions = [[0, 2], [1, 3], [4, 6], [5, 7]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 0], [6, 1], [7, 2]]) == [True, False, True, True, True, False, True, True, False, False, True, False, False, False, True, False]\n assert candidate(n = 15,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 0]],requests = [[0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 1]]) == [True, True, True, True, True, True, False, True]\n assert candidate(n = 9,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 8]],requests = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 8], [0, 7], [1, 6], [2, 5], [3, 4]]) == [False, True, True, True, True, False, False, False, False]\n assert candidate(n = 10,restrictions = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 0]]) == [True, True, True, True, False, True, True, True, True, False, True, True, False, True, False]\n assert candidate(n = 10,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 0], [9, 1]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 15,restrictions = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]]) == [True, True, True, True, False, True, True, True, True, False, True, True, True, True, True]\n assert candidate(n = 7,restrictions = [[0, 2], [1, 3], [4, 6]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 3], [1, 4], [2, 5]]) == [True, False, True, True, True, False, True, False, False, True]\n assert candidate(n = 12,restrictions = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 6], [0, 7], [1, 8], [2, 9], [3, 10], [4, 11], [5, 6]]) == [True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False]\n assert candidate(n = 10,restrictions = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 0], [6, 1], [7, 2], [8, 3], [9, 4]]) == [True, True, False, True, True, False, False, False, False, False]\n assert candidate(n = 15,restrictions = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 0], [14, 1]],requests = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 0]]) == [True, True, True, True, True, True, False, True]\n assert candidate(n = 12,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],requests = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 0], [7, 1], [8, 2], [9, 3], [10, 4], [11, 5]]) == [True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 7,restrictions = [[0, 2], [1, 3], [4, 6]],requests = [[0, 1], [2, 3], [4, 5], [5, 6], [0, 3], [2, 5]]) == [True, True, True, False, False, True]\n assert candidate(n = 9,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 0], [8, 1]]) == [True, True, True, True, True, True, False, False, False]\n assert candidate(n = 9,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 0]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 0], [8, 1], [0, 4]]) == [True, True, True, True, True, True, False, False, True, True]\n assert candidate(n = 15,restrictions = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == [True, True, True, True, True, True, True, False, True, True, True, True, True, True, False, False, False, False, False, False, False, True]\n assert candidate(n = 5,restrictions = [[0, 2], [1, 3]],requests = [[0, 1], [2, 3], [1, 4], [3, 4]]) == [True, True, True, False]\n assert candidate(n = 7,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],requests = [[0, 6], [1, 5], [2, 4], [3, 0], [4, 1], [5, 2], [6, 3]]) == [True, True, True, True, False, False, True]\n assert candidate(n = 20,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0]],requests = [[0, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 1], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [True, True, True, True, False]\n assert candidate(n = 8,restrictions = [[0, 1], [2, 3], [4, 5], [5, 6], [6, 7]],requests = [[0, 2], [1, 4], [3, 5], [5, 7], [0, 7], [4, 6]]) == [True, True, True, True, False, True]\n assert candidate(n = 15,restrictions = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14]],requests = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 0], [12, 1], [13, 2], [14, 3]]) == [True, True, True, True, True, True, True, True, True, True, True, False, False, False, False]\n assert candidate(n = 8,restrictions = [[0, 2], [1, 3], [4, 6], [5, 7]],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [0, 2], [1, 3], [4, 6], [5, 7], [0, 4], [2, 6], [1, 5], [3, 7], [0, 6], [2, 4], [1, 7], [3, 5]]) == [True, True, True, True, False, False, False, False, True, True, True, True, False, False, False, False]\n assert candidate(n = 7,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0]],requests = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 0], [5, 1], [6, 2]]) == [True, True, True, False, False, False, False]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],requests = [[0, 9], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(n = 12,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],requests = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 0], [7, 1], [8, 2], [9, 3], [10, 4], [11, 5]]) == [True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]],requests = [[0, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5]]) == [True, True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == [True, True, True, True, False, True, True, True, True, False]\n assert candidate(n = 8,restrictions = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 7]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [0, 7], [1, 6]]) == [True, True, True, True, True, True, False, False]\n assert candidate(n = 12,restrictions = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],requests = [[0, 5], [1, 4], [2, 3], [6, 11], [7, 10], [8, 9], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [True, True, True, True, True, True, False, False, False, False, False, False]\n assert candidate(n = 10,restrictions = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 12,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]],requests = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [True, True, True, True, True, True, True, True, True, True, False, False]\n assert candidate(n = 11,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 0], [10, 1]]) == [True, True, True, True, True, True, True, True, True, False, False]\n assert candidate(n = 20,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]],requests = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [12, 14], [13, 15], [16, 18], [17, 19], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False]\n assert candidate(n = 12,restrictions = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 7], [1, 8], [2, 9], [3, 10], [4, 11], [5, 6]]) == [True, True, True, True, True, False, False, False, False, False, False]\n assert candidate(n = 15,restrictions = [[0, 7], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [True, True, True, True, True, True, False, True, True, True, True, True, True, False]\n assert candidate(n = 9,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 0], [8, 1], [0, 8], [1, 7], [2, 6], [3, 5], [4, 3], [5, 2], [6, 1], [7, 0], [8, 6], [0, 4], [1, 5], [2, 7], [3, 8]]) == [True, True, True, True, True, True, True, False, False, True, True, True, True, False, False, False, False, True, True, True, False, False]\n assert candidate(n = 12,restrictions = [[0, 3], [1, 4], [2, 5], [6, 9], [7, 10], [8, 11]],requests = [[0, 1], [1, 2], [3, 4], [4, 5], [6, 7], [7, 8], [9, 10], [10, 11], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, True]\n assert candidate(n = 6,restrictions = [[0, 1], [2, 3], [4, 5]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [0, 5], [1, 4]]) == [True, True, True, True, False, False]\n assert candidate(n = 10,restrictions = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == [True, True, True, True, False, True, True, True, True, False]\n assert candidate(n = 8,restrictions = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]],requests = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [0, 1], [2, 3], [4, 5], [6, 7]]) == [True, True, True, True, True, False, False, False, False]\n", "comparison": "exact"}, "public_tests": ["3\n[[0,1]]\n[[0,2],[2,1]]", "3\n[[0,1]]\n[[1,2],[0,2]]", "5\n[[0,1],[1,2],[2,3]]\n[[0,4],[1,2],[3,1],[3,4]]"], "hints": ["For each request, we could loop through all restrictions. Can you think of doing a check-in close to O(1)?", "Could you use Union Find?"], "metadata": {"canonical_parameter_names": ["n", "restrictions", "requests"], "leetcode_dataset_entry_point": "Solution().friendRequests", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:17+00:00", "tests_total": 72, "tests_dropped": 0, "flags": [], "topic_tags": ["union-find", "graph"]}, "language": "python", "interface": {"raw_signature": "def friendRequests(self, n: int, restrictions: list[list[int]], requests: list[list[int]]) -> list[bool]:", "container": "Solution", "callable": "friendRequests", "parameters": [{"name": "n", "type": "int"}, {"name": "restrictions", "type": "list[list[int]]"}, {"name": "requests", "type": "list[list[int]]"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2078, "task_id": "two-furthest-houses-with-different-colors", "difficulty": "Easy", "problem_description": "There are n houses evenly lined up on the street, and each house is beautifully painted. You are given a 0-indexed integer array colors of length n, where colors[i] represents the color of the i^th house.\n\nReturn the maximum distance between two houses with different colors.\n\nThe distance between the i^th and j^th houses is abs(i - j), where abs(x) is the absolute value of x.\n\nExample 1:\n\nInput: colors = [1,1,1,6,1,1,1]\nOutput: 3\nExplanation: In the above image, color 1 is blue, and color 6 is red.\nThe furthest two houses with different colors are house 0 and house 3.\nHouse 0 has color 1, and house 3 has color 6. The distance between them is abs(0 - 3) = 3.\nNote that houses 3 and 6 can also produce the optimal answer.\n\nExample 2:\n\nInput: colors = [1,8,3,8,3]\nOutput: 4\nExplanation: In the above image, color 1 is blue, color 8 is yellow, and color 3 is green.\nThe furthest two houses with different colors are house 0 and house 4.\nHouse 0 has color 1, and house 4 has color 3. The distance between them is abs(0 - 4) = 4.\n\nExample 3:\n\nInput: colors = [0,1]\nOutput: 1\nExplanation: The furthest two houses with different colors are house 0 and house 1.\nHouse 0 has color 0, and house 1 has color 1. The distance between them is abs(0 - 1) = 1.\n\nConstraints:\n\n- n == colors.length\n- 2 <= n <= 100\n- 0 <= colors[i] <= 100\n- Test data are generated such that at least two houses have different colors.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(colors = [10, 20, 10, 10, 10]) == 3\n assert candidate(colors = [10, 20, 30, 40, 50]) == 4\n assert candidate(colors = [100, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 9\n assert candidate(colors = [3, 1, 3, 3, 3]) == 3\n assert candidate(colors = [1, 1, 1, 6, 1, 1, 1]) == 3\n assert candidate(colors = [1, 2, 3, 4, 5]) == 4\n assert candidate(colors = [5, 5, 5, 5, 1]) == 4\n assert candidate(colors = [5, 5, 5, 5, 5, 2]) == 5\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(colors = [7, 7, 7, 7, 7, 7, 7, 7, 7, 8]) == 9\n assert candidate(colors = [1, 1, 2, 1, 1]) == 2\n assert candidate(colors = [1, 1, 2, 1, 1, 1, 1]) == 4\n assert candidate(colors = [100, 99, 98, 97, 96, 95]) == 5\n assert candidate(colors = [2, 2, 2, 2, 3, 2]) == 4\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 2]) == 9\n assert candidate(colors = [0, 1]) == 1\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 9\n assert candidate(colors = [1, 1, 1, 1, 1, 2]) == 5\n assert candidate(colors = [1, 8, 3, 8, 3]) == 4\n assert candidate(colors = [1, 1, 2, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(colors = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 2]) == 7\n assert candidate(colors = [100, 0, 100, 100, 100]) == 3\n assert candidate(colors = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 9\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 2, 1]) == 8\n assert candidate(colors = [4, 4, 4, 4, 4, 4, 4, 4, 4, 2]) == 9\n assert candidate(colors = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 18\n assert candidate(colors = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 0]) == 30\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1]) == 33\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 32\n assert candidate(colors = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 32\n assert candidate(colors = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 57\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 55\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 20\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 29\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 21\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 31\n assert candidate(colors = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 71\n assert candidate(colors = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 29\n assert candidate(colors = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 29\n assert candidate(colors = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10]) == 20\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 52\n assert candidate(colors = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 77\n assert candidate(colors = [10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 10]) == 54\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == 80\n assert candidate(colors = [34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35]) == 81\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 59\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 77\n assert candidate(colors = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 19\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 21\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 57\n assert candidate(colors = [7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 9]) == 75\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 17\n assert candidate(colors = [1, 1, 1, 1, 2, 1, 1, 1, 1, 1]) == 5\n assert candidate(colors = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 29\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 52\n assert candidate(colors = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 55\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 57\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1]) == 19\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]) == 55\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 90\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 19\n assert candidate(colors = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 99\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6]) == 56\n assert candidate(colors = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 75\n assert candidate(colors = [34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35]) == 56\n assert candidate(colors = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 77\n assert candidate(colors = [1, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 8\n assert candidate(colors = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(colors = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1]) == 53\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5, 5]) == 10\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 45\n assert candidate(colors = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]) == 52\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 68\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 78\n assert candidate(colors = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 2]) == 78\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 17\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == 30\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == 77\n assert candidate(colors = [1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1]) == 5\n assert candidate(colors = [100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100]) == 29\n assert candidate(colors = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 0]) == 71\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(colors = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 11\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 87\n assert candidate(colors = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 19\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1]) == 49\n", "comparison": "exact"}, "public_tests": ["[1,1,1,6,1,1,1]", "[1,8,3,8,3]", "[0,1]"], "hints": ["The constraints are small. Can you try the combination of every two houses?", "Greedily, the maximum distance will come from either the pair of the leftmost house and possibly some house on the right with a different color, or the pair of the rightmost house and possibly some house on the left with a different color."], "metadata": {"canonical_parameter_names": ["colors"], "leetcode_dataset_entry_point": "Solution().maxDistance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:22+00:00", "tests_total": 90, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maxDistance(self, colors: list[int]) -> int:", "container": "Solution", "callable": "maxDistance", "parameters": [{"name": "colors", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2079, "task_id": "watering-plants", "difficulty": "Medium", "problem_description": "You want to water n plants in your garden with a watering can. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the i^th plant is located at x = i. There is a river at x = -1 that you can refill your watering can at.\n\nEach plant needs a specific amount of water. You will water the plants in the following way:\n\n- Water the plants in order from left to right.\n- After watering the current plant, if you do not have enough water to completely water the next plant, return to the river to fully refill the watering can.\n- You cannot refill the watering can early.\n\nYou are initially at the river (i.e., x = -1). It takes one step to move one unit on the x-axis.\n\nGiven a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the i^th plant needs, and an integer capacity representing the watering can capacity, return the number of steps needed to water all the plants.\n\nExample 1:\n\nInput: plants = [2,2,3,3], capacity = 5\nOutput: 14\nExplanation: Start at the river with a full watering can:\n- Walk to plant 0 (1 step) and water it. Watering can has 3 units of water.\n- Walk to plant 1 (1 step) and water it. Watering can has 1 unit of water.\n- Since you cannot completely water plant 2, walk back to the river to refill (2 steps).\n- Walk to plant 2 (3 steps) and water it. Watering can has 2 units of water.\n- Since you cannot completely water plant 3, walk back to the river to refill (3 steps).\n- Walk to plant 3 (4 steps) and water it.\nSteps needed = 1 + 1 + 2 + 3 + 3 + 4 = 14.\n\nExample 2:\n\nInput: plants = [1,1,1,4,2,3], capacity = 4\nOutput: 30\nExplanation: Start at the river with a full watering can:\n- Water plants 0, 1, and 2 (3 steps). Return to river (3 steps).\n- Water plant 3 (4 steps). Return to river (4 steps).\n- Water plant 4 (5 steps). Return to river (5 steps).\n- Water plant 5 (6 steps).\nSteps needed = 3 + 3 + 4 + 4 + 5 + 5 + 6 = 30.\n\nExample 3:\n\nInput: plants = [7,7,7,7,7,7,7], capacity = 8\nOutput: 49\nExplanation: You have to refill before watering each plant.\nSteps needed = 1 + 1 + 2 + 2 + 3 + 3 + 4 + 4 + 5 + 5 + 6 + 6 + 7 = 49.\n\nConstraints:\n\n- n == plants.length\n- 1 <= n <= 1000\n- 1 <= plants[i] <= 10^6\n- max(plants[i]) <= capacity <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(plants = [1000000],capacity = 1000000) == 1\n assert candidate(plants = [3, 2, 4, 2, 1],capacity = 6) == 17\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 1) == 100\n assert candidate(plants = [5, 5, 5, 5, 5],capacity = 5) == 25\n assert candidate(plants = [10, 10, 10],capacity = 10) == 9\n assert candidate(plants = [1, 1, 1, 4, 2, 3],capacity = 4) == 30\n assert candidate(plants = [1, 2, 3, 4, 5],capacity = 10) == 13\n assert candidate(plants = [1, 2, 3],capacity = 6) == 3\n assert candidate(plants = [5, 8, 6],capacity = 10) == 9\n assert candidate(plants = [1, 1, 1, 1, 1],capacity = 5) == 5\n assert candidate(plants = [2, 2, 3, 3],capacity = 5) == 14\n assert candidate(plants = [3, 2, 4, 2, 1],capacity = 4) == 17\n assert candidate(plants = [7, 7, 7, 7, 7, 7, 7],capacity = 8) == 49\n assert candidate(plants = [2, 4, 5, 1, 2],capacity = 6) == 17\n assert candidate(plants = [10],capacity = 10) == 1\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 15) == 146\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacity = 5) == 961\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 25) == 242\n assert candidate(plants = [9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 10) == 41\n assert candidate(plants = [2, 3, 2, 1, 4, 2, 1, 3, 2, 1, 4, 2, 1],capacity = 6) == 77\n assert candidate(plants = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],capacity = 3) == 138\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacity = 50) == 88\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacity = 10) == 362\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 10) == 200\n assert candidate(plants = [2, 4, 5, 1, 2],capacity = 5) == 17\n assert candidate(plants = [7, 2, 5, 9, 3, 8, 4, 6, 1, 1, 1, 1],capacity = 15) == 42\n assert candidate(plants = [1, 3, 2, 4, 2, 1, 3, 2, 1, 4, 2, 1],capacity = 5) == 78\n assert candidate(plants = [5, 8, 6, 10, 2, 1, 1, 1, 1, 1],capacity = 12) == 32\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = 20) == 152\n assert candidate(plants = [2, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8],capacity = 12) == 71\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 10) == 54\n assert candidate(plants = [9, 1, 5, 3, 7, 8, 4, 2],capacity = 10) == 42\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],capacity = 20) == 213\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacity = 30) == 2881\n assert candidate(plants = [2, 4, 6, 8, 10],capacity = 10) == 23\n assert candidate(plants = [1000000, 500000, 1000000, 500000, 1000000, 500000],capacity = 1000000) == 36\n assert candidate(plants = [100, 200, 300, 400, 500],capacity = 1000) == 13\n assert candidate(plants = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],capacity = 3) == 900\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],capacity = 150) == 68\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacity = 15) == 4499\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = 10) == 88\n assert candidate(plants = [1, 3, 2, 5, 4, 3, 2, 1],capacity = 5) == 50\n assert candidate(plants = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],capacity = 3) == 400\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = 18) == 52\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 10) == 249\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = 15) == 68\n assert candidate(plants = [9, 1, 2, 3, 4, 5, 6, 7, 8],capacity = 10) == 65\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 10) == 200\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],capacity = 20) == 88\n assert candidate(plants = [5, 8, 6, 7, 4, 9],capacity = 12) == 28\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 4) == 400\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 5) == 84\n assert candidate(plants = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],capacity = 5) == 200\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 25) == 180\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacity = 15) == 225\n assert candidate(plants = [2, 4, 6, 8, 10],capacity = 12) == 19\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 10) == 127\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 2) == 511\n assert candidate(plants = [3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],capacity = 4) == 407\n assert candidate(plants = [5, 8, 6, 7, 9, 4, 2],capacity = 10) == 37\n assert candidate(plants = [7, 3, 5, 8, 10, 2, 6, 4, 9, 1],capacity = 15) == 52\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],capacity = 20) == 78\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 1) == 6724\n assert candidate(plants = [7, 3, 6, 2, 5, 4, 9, 1, 8],capacity = 12) == 49\n assert candidate(plants = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],capacity = 15) == 126\n assert candidate(plants = [100, 200, 100],capacity = 150) == 9\n assert candidate(plants = [100, 200, 300, 400, 500],capacity = 1000) == 13\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 15) == 38\n assert candidate(plants = [100, 200, 300, 400, 500],capacity = 500) == 23\n assert candidate(plants = [5, 8, 6, 10, 2, 9, 4],capacity = 12) == 41\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 5) == 2878\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 10) == 10082\n assert candidate(plants = [1000000, 1000000, 1000000],capacity = 1000000) == 9\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 10) == 249\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacity = 10) == 146\n assert candidate(plants = [9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 5) == 67\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 15) == 46\n assert candidate(plants = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],capacity = 14) == 200\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacity = 25) == 296\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacity = 20) == 177\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacity = 15) == 368\n assert candidate(plants = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],capacity = 14) == 200\n assert candidate(plants = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],capacity = 10) == 276\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 1) == 900\n", "comparison": "exact"}, "public_tests": ["[2,2,3,3]\n5", "[1,1,1,4,2,3]\n4", "[7,7,7,7,7,7,7]\n8"], "hints": ["Simulate the process.", "Return to refill the container once you meet a plant that needs more water than you have."], "metadata": {"canonical_parameter_names": ["plants", "capacity"], "leetcode_dataset_entry_point": "Solution().wateringPlants", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:24+00:00", "tests_total": 84, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "simulation"]}, "language": "python", "interface": {"raw_signature": "def wateringPlants(self, plants: list[int], capacity: int) -> int:", "container": "Solution", "callable": "wateringPlants", "parameters": [{"name": "plants", "type": "list[int]"}, {"name": "capacity", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2081, "task_id": "sum-of-k-mirror-numbers", "difficulty": "Hard", "problem_description": "A k-mirror number is a positive integer without leading zeros that reads the same both forward and backward in base-10 as well as in base-k.\n\n- For example, 9 is a 2-mirror number. The representation of 9 in base-10 and base-2 are 9 and 1001 respectively, which read the same both forward and backward.\n- On the contrary, 4 is not a 2-mirror number. The representation of 4 in base-2 is 100, which does not read the same both forward and backward.\n\nGiven the base k and the number n, return the sum of the n smallest k-mirror numbers.\n\nExample 1:\n\nInput: k = 2, n = 5\nOutput: 25\nExplanation:\nThe 5 smallest 2-mirror numbers and their representations in base-2 are listed as follows:\n base-10 base-2\n 1 1\n 3 11\n 5 101\n 7 111\n 9 1001\nTheir sum = 1 + 3 + 5 + 7 + 9 = 25.\n\nExample 2:\n\nInput: k = 3, n = 7\nOutput: 499\nExplanation:\nThe 7 smallest 3-mirror numbers are and their representations in base-3 are listed as follows:\n base-10 base-3\n 1 1\n 2 2\n 4 11\n 8 22\n 121 11111\n 151 12121\n 212 21212\nTheir sum = 1 + 2 + 4 + 8 + 121 + 151 + 212 = 499.\n\nExample 3:\n\nInput: k = 7, n = 17\nOutput: 20379000\nExplanation: The 17 smallest 7-mirror numbers are:\n1, 2, 3, 4, 5, 6, 8, 121, 171, 242, 292, 16561, 65656, 2137312, 4602064, 6597956, 6958596\n\nConstraints:\n\n- 2 <= k <= 9\n- 1 <= n <= 30\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 2,n = 1) == 1\n assert candidate(k = 5,n = 8) == 638\n assert candidate(k = 8,n = 15) == 5818\n assert candidate(k = 9,n = 5) == 15\n assert candidate(k = 9,n = 6) == 21\n assert candidate(k = 8,n = 9) == 158\n assert candidate(k = 4,n = 8) == 1498\n assert candidate(k = 9,n = 30) == 18627530\n assert candidate(k = 2,n = 10) == 1772\n assert candidate(k = 4,n = 10) == 3224\n assert candidate(k = 3,n = 7) == 499\n assert candidate(k = 5,n = 10) == 1940\n assert candidate(k = 9,n = 10) == 509\n assert candidate(k = 9,n = 20) == 156242\n assert candidate(k = 4,n = 15) == 233041\n assert candidate(k = 6,n = 12) == 1297\n assert candidate(k = 8,n = 20) == 94182\n assert candidate(k = 3,n = 5) == 136\n assert candidate(k = 5,n = 15) == 20526195\n assert candidate(k = 2,n = 5) == 25\n assert candidate(k = 2,n = 30) == 2609044274\n assert candidate(k = 7,n = 17) == 20379000\n assert candidate(k = 7,n = 28) == 115121130305\n assert candidate(k = 5,n = 25) == 6849225412\n assert candidate(k = 3,n = 20) == 2863752\n assert candidate(k = 8,n = 28) == 7054305\n assert candidate(k = 9,n = 15) == 3203\n assert candidate(k = 5,n = 20) == 1000828708\n assert candidate(k = 7,n = 15) == 6822448\n assert candidate(k = 6,n = 25) == 7009551\n assert candidate(k = 8,n = 25) == 1651182\n assert candidate(k = 6,n = 30) == 28888231\n assert candidate(k = 2,n = 25) == 20005383\n assert candidate(k = 6,n = 28) == 19806423\n assert candidate(k = 4,n = 22) == 22726545\n assert candidate(k = 9,n = 29) == 16185088\n assert candidate(k = 5,n = 28) == 19101218022\n assert candidate(k = 9,n = 27) == 11349704\n assert candidate(k = 8,n = 17) == 27727\n assert candidate(k = 6,n = 15) == 4383\n assert candidate(k = 5,n = 30) == 43401017264\n assert candidate(k = 4,n = 28) == 721411086\n assert candidate(k = 3,n = 28) == 44192979\n assert candidate(k = 4,n = 20) == 12448815\n assert candidate(k = 9,n = 25) == 7586042\n assert candidate(k = 7,n = 19) == 91104965\n assert candidate(k = 9,n = 28) == 13750746\n assert candidate(k = 2,n = 28) == 759196316\n assert candidate(k = 4,n = 25) == 38898160\n assert candidate(k = 6,n = 20) == 156389\n assert candidate(k = 3,n = 30) == 155059889\n assert candidate(k = 8,n = 18) == 41058\n assert candidate(k = 7,n = 20) == 321578997\n assert candidate(k = 7,n = 25) == 3428700695\n assert candidate(k = 8,n = 30) == 66619574\n assert candidate(k = 6,n = 18) == 41849\n assert candidate(k = 7,n = 30) == 241030621167\n", "comparison": "exact"}, "public_tests": ["2\n5", "3\n7", "7\n17"], "hints": ["Since we need to reduce search space, instead of checking if every number is a palindrome in base-10, can we try to \"generate\" the palindromic numbers?", "If you are provided with a d digit number, how can you generate a palindrome with 2*d or 2*d - 1 digit?", "Try brute-forcing and checking if the palindrome you generated is a \"k-Mirror\" number."], "metadata": {"canonical_parameter_names": ["k", "n"], "leetcode_dataset_entry_point": "Solution().kMirror", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:26+00:00", "tests_total": 59, "tests_dropped": 2, "flags": [], "topic_tags": ["math", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def kMirror(self, k: int, n: int) -> int:", "container": "Solution", "callable": "kMirror", "parameters": [{"name": "k", "type": "int"}, {"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2085, "task_id": "count-common-words-with-one-occurrence", "difficulty": "Easy", "problem_description": "Given two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.\n\nExample 1:\n\nInput: words1 = [\"leetcode\",\"is\",\"amazing\",\"as\",\"is\"], words2 = [\"amazing\",\"leetcode\",\"is\"]\nOutput: 2\nExplanation:\n- \"leetcode\" appears exactly once in each of the two arrays. We count this string.\n- \"amazing\" appears exactly once in each of the two arrays. We count this string.\n- \"is\" appears in each of the two arrays, but there are 2 occurrences of it in words1. We do not count this string.\n- \"as\" appears once in words1, but does not appear in words2. We do not count this string.\nThus, there are 2 strings that appear exactly once in each of the two arrays.\n\nExample 2:\n\nInput: words1 = [\"b\",\"bb\",\"bbb\"], words2 = [\"a\",\"aa\",\"aaa\"]\nOutput: 0\nExplanation: There are no strings that appear in each of the two arrays.\n\nExample 3:\n\nInput: words1 = [\"a\",\"ab\"], words2 = [\"a\",\"a\",\"a\",\"ab\"]\nOutput: 1\nExplanation: The only string that appears exactly once in each of the two arrays is \"ab\".\n\nConstraints:\n\n- 1 <= words1.length, words2.length <= 1000\n- 1 <= words1[i].length, words2[j].length <= 30\n- words1[i] and words2[j] consists only of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words1 = ['one'],words2 = ['two']) == 0\n assert candidate(words1 = ['unique'],words2 = ['unique']) == 1\n assert candidate(words1 = ['b', 'bb', 'bbb'],words2 = ['a', 'aa', 'aaa']) == 0\n assert candidate(words1 = ['distinct'],words2 = ['distinct', 'distinct']) == 0\n assert candidate(words1 = ['a', 'b', 'c'],words2 = ['c', 'b', 'a']) == 3\n assert candidate(words1 = ['same', 'same'],words2 = ['same', 'same', 'same']) == 0\n assert candidate(words1 = ['a', 'ab'],words2 = ['a', 'a', 'a', 'ab']) == 1\n assert candidate(words1 = ['hello', 'world'],words2 = ['hello', 'world', 'hello']) == 1\n assert candidate(words1 = ['hello', 'world'],words2 = ['hello', 'world']) == 2\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'date']) == 2\n assert candidate(words1 = ['leetcode', 'is', 'amazing', 'as', 'is'],words2 = ['amazing', 'leetcode', 'is']) == 2\n assert candidate(words1 = ['repeat', 'repeat'],words2 = ['repeat', 'repeat']) == 0\n assert candidate(words1 = ['abc', 'def', 'ghi', 'jkl'],words2 = ['def', 'ghi', 'jkl', 'mno', 'pqr', 'abc', 'def', 'ghi', 'jkl']) == 1\n assert candidate(words1 = ['alpha', 'beta', 'gamma', 'delta'],words2 = ['delta', 'gamma', 'beta', 'alpha', 'alpha', 'beta', 'gamma', 'delta']) == 0\n assert candidate(words1 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five'],words2 = ['two', 'three', 'four', 'five', 'six', 'seven', 'eight']) == 4\n assert candidate(words1 = ['hello', 'world', 'hello'],words2 = ['world', 'hello', 'hello', 'world']) == 0\n assert candidate(words1 = ['cat', 'dog', 'bird', 'fish'],words2 = ['cat', 'dog', 'bird', 'fish', 'dog', 'bird']) == 2\n assert candidate(words1 = ['hello', 'hello', 'world'],words2 = ['hello', 'world', 'world', 'world']) == 0\n assert candidate(words1 = ['cat', 'dog', 'fish'],words2 = ['dog', 'cat', 'bird', 'fish', 'dog', 'fish']) == 1\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e'],words2 = ['f', 'g', 'h', 'i', 'j']) == 0\n assert candidate(words1 = ['alpha', 'beta', 'gamma', 'delta'],words2 = ['alpha', 'beta', 'gamma', 'delta', 'delta']) == 3\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five', 'six'],words2 = ['three', 'four', 'seven', 'eight', 'nine', 'one', 'two']) == 4\n assert candidate(words1 = ['one', 'two', 'three', 'four'],words2 = ['four', 'three', 'two', 'one', 'one', 'two', 'three', 'four', 'four', 'three', 'two', 'one']) == 0\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],words2 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 0\n assert candidate(words1 = ['same', 'word', 'multiple'],words2 = ['same', 'word', 'multiple', 'same', 'word', 'multiple']) == 0\n assert candidate(words1 = ['test', 'case', 'one'],words2 = ['case', 'test', 'one', 'one', 'test', 'case']) == 0\n assert candidate(words1 = ['same', 'word', 'repeated'],words2 = ['same', 'word', 'repeated', 'same', 'word', 'repeated']) == 0\n assert candidate(words1 = ['hello', 'world', 'hello', 'world'],words2 = ['hello', 'world', 'hello', 'world', 'hello', 'world']) == 0\n assert candidate(words1 = ['x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],words2 = ['a', 'b', 'b', 'c', 'd', 'd', 'e', 'f', 'f', 'g']) == 4\n assert candidate(words1 = ['car', 'truck', 'bus', 'van', 'car', 'truck'],words2 = ['bus', 'van', 'motorcycle', 'bicycle', 'bus', 'van', 'truck']) == 0\n assert candidate(words1 = ['cat', 'dog', 'fish', 'bird'],words2 = ['dog', 'cat', 'cat', 'fish', 'dog', 'bird']) == 2\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e'],words2 = ['f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e']) == 5\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],words2 = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']) == 0\n assert candidate(words1 = ['same', 'word', 'repeated', 'multiple', 'times'],words2 = ['times', 'repeated', 'multiple', 'same', 'word', 'word']) == 4\n assert candidate(words1 = ['one', 'two', 'three', 'four'],words2 = ['four', 'three', 'two', 'one', 'one', 'two', 'three', 'four']) == 0\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'cherry', 'apple']) == 2\n assert candidate(words1 = ['a', 'b', 'c', 'd'],words2 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 4\n assert candidate(words1 = ['a', 'b', 'c', 'd'],words2 = ['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd']) == 0\n assert candidate(words1 = ['x', 'y', 'z', 'w', 'v'],words2 = ['x', 'y', 'z', 'w', 'v', 'x', 'y', 'z', 'w', 'v', 'x', 'y', 'z', 'w', 'v', 'x', 'y', 'z', 'w', 'v']) == 0\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e'],words2 = ['e', 'd', 'c', 'b', 'a', 'a', 'b', 'c', 'd', 'e']) == 0\n assert candidate(words1 = ['unique', 'words', 'only', 'once', 'here'],words2 = ['words', 'only', 'once', 'here', 'unique', 'twice', 'unique']) == 4\n assert candidate(words1 = ['x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['cat', 'dog', 'elephant', 'frog', 'cat'],words2 = ['dog', 'frog', 'giraffe', 'elephant', 'hippo']) == 3\n assert candidate(words1 = ['cat', 'dog', 'fish'],words2 = ['fish', 'dog', 'cat', 'dog', 'cat']) == 1\n assert candidate(words1 = ['python', 'java', 'c', 'cpp'],words2 = ['python', 'java', 'java', 'csharp']) == 1\n assert candidate(words1 = ['unique', 'words', 'only', 'here'],words2 = ['here', 'only', 'words', 'unique', 'unique']) == 3\n assert candidate(words1 = ['hello', 'world', 'hello'],words2 = ['world', 'hello', 'world', 'hello', 'world', 'hello']) == 0\n assert candidate(words1 = ['hello', 'world', 'python', 'java', 'csharp'],words2 = ['python', 'java', 'csharp', 'hello', 'ruby', 'scala', 'world', 'python', 'java']) == 3\n assert candidate(words1 = ['x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['unique', 'word', 'only', 'in', 'this', 'array'],words2 = ['unique', 'only', 'word', 'in', 'that', 'array']) == 5\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'cherry', 'apple', 'apple']) == 2\n assert candidate(words1 = ['apple', 'banana', 'cherry', 'date'],words2 = ['banana', 'cherry', 'fig', 'grape']) == 2\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'apple', 'cherry', 'date']) == 2\n assert candidate(words1 = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abc'],words2 = ['mno', 'pqr', 'stu', 'vwx', 'yz', 'abc', 'def', 'ghi', 'jkl', 'mno']) == 7\n assert candidate(words1 = ['apple', 'banana', 'cherry', 'date'],words2 = ['banana', 'date', 'fig', 'grape', 'apple']) == 3\n assert candidate(words1 = ['apple', 'banana', 'cherry', 'date', 'elderberry'],words2 = ['banana', 'cherry', 'elderberry', 'fig', 'grape', 'apple', 'date']) == 5\n assert candidate(words1 = ['a', 'b', 'c', 'a', 'b', 'c'],words2 = ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c']) == 0\n assert candidate(words1 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['sun', 'moon', 'star', 'planet', 'sun', 'moon'],words2 = ['star', 'planet', 'comet', 'asteroid', 'planet', 'star']) == 0\n assert candidate(words1 = ['alpha', 'beta', 'gamma', 'delta', 'epsilon'],words2 = ['gamma', 'delta', 'zeta', 'eta', 'theta', 'epsilon', 'delta']) == 2\n assert candidate(words1 = ['python', 'java', 'csharp'],words2 = ['java', 'csharp', 'python', 'python']) == 2\n assert candidate(words1 = ['cat', 'dog', 'mouse'],words2 = ['dog', 'cat', 'cat', 'mouse', 'dog']) == 1\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'cherry', 'apple', 'banana']) == 2\n assert candidate(words1 = ['same', 'words', 'in', 'both', 'arrays'],words2 = ['same', 'words', 'in', 'both', 'arrays']) == 5\n assert candidate(words1 = ['single'],words2 = ['single', 'single', 'single', 'single']) == 0\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['cherry', 'banana', 'apple', 'apple']) == 2\n assert candidate(words1 = ['abc', 'def', 'ghi'],words2 = ['def', 'ghi', 'jkl', 'def', 'ghi']) == 0\n assert candidate(words1 = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault'],words2 = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'grault']) == 6\n assert candidate(words1 = ['foo', 'bar', 'baz', 'qux'],words2 = ['foo', 'bar', 'qux', 'quux']) == 3\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'cherry', 'banana']) == 2\n assert candidate(words1 = ['hello', 'hello', 'world'],words2 = ['world', 'world', 'hello', 'hello', 'hello']) == 0\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five'],words2 = ['five', 'four', 'three', 'two', 'one']) == 5\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'cherry', 'cherry']) == 2\n assert candidate(words1 = ['unique', 'words', 'only'],words2 = ['only', 'words', 'unique', 'words']) == 2\n assert candidate(words1 = ['red', 'blue', 'green'],words2 = ['red', 'red', 'blue', 'green', 'blue', 'green']) == 0\n assert candidate(words1 = ['cat', 'dog', 'mouse', 'elephant'],words2 = ['dog', 'mouse', 'cat', 'tiger', 'elephant', 'dog']) == 3\n assert candidate(words1 = ['test', 'case', 'input'],words2 = ['input', 'test', 'case', 'input', 'test', 'case', 'input', 'test', 'case']) == 0\n assert candidate(words1 = ['hello', 'world', 'hello', 'world'],words2 = ['hello', 'world', 'world', 'hello']) == 0\n assert candidate(words1 = ['first', 'second', 'third', 'fourth'],words2 = ['fourth', 'third', 'second', 'first', 'first', 'second', 'third', 'fourth', 'first', 'second', 'third', 'fourth']) == 0\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five'],words2 = ['two', 'three', 'five', 'six', 'seven', 'eight', 'nine', 'one', 'four']) == 5\n assert candidate(words1 = ['repeated', 'repeated', 'words', 'in', 'both', 'arrays'],words2 = ['repeated', 'words', 'in', 'both', 'arrays', 'arrays']) == 3\n assert candidate(words1 = ['x', 'y', 'z'],words2 = ['z', 'y', 'x']) == 3\n assert candidate(words1 = ['a', 'b', 'c', 'd'],words2 = ['a', 'a', 'b', 'c', 'c', 'd', 'd', 'd']) == 1\n assert candidate(words1 = ['single'],words2 = ['single']) == 1\n assert candidate(words1 = ['hello', 'world', 'python', 'java'],words2 = ['python', 'java', 'hello', 'world', 'world', 'hello']) == 2\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e'],words2 = ['a', 'a', 'b', 'c', 'c', 'd', 'e', 'e']) == 2\n assert candidate(words1 = ['python', 'java', 'c', 'cpp'],words2 = ['java', 'c', 'cpp', 'ruby']) == 3\n assert candidate(words1 = ['unique', 'string', 'in', 'each', 'array'],words2 = ['different', 'string', 'in', 'each', 'array']) == 4\n assert candidate(words1 = ['single'],words2 = ['single', 'single', 'single']) == 0\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'cherry', 'date']) == 2\n assert candidate(words1 = ['repeat', 'repeat', 'repeat'],words2 = ['repeat', 'repeat', 'repeat', 'repeat']) == 0\n assert candidate(words1 = ['red', 'blue', 'green', 'yellow', 'red'],words2 = ['blue', 'green', 'purple', 'yellow', 'blue', 'green']) == 1\n assert candidate(words1 = ['foo', 'bar', 'baz', 'qux', 'quux'],words2 = ['qux', 'quux', 'foo', 'bar', 'baz', 'corge', 'grault', 'foo']) == 4\n assert candidate(words1 = ['example', 'test', 'case'],words2 = ['test', 'case', 'example', 'example', 'test', 'case']) == 0\n assert candidate(words1 = ['unique'],words2 = ['unique', 'unique', 'unique']) == 0\n assert candidate(words1 = ['x', 'y', 'z', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'],words2 = ['x', 'y', 'z', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a', 'x', 'y', 'z']) == 23\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g'],words2 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c', 'd', 'e', 'f', 'g']) == 0\n assert candidate(words1 = ['unique'],words2 = ['unique', 'unique', 'unique', 'unique']) == 0\n", "comparison": "exact"}, "public_tests": ["[\"leetcode\",\"is\",\"amazing\",\"as\",\"is\"]\n[\"amazing\",\"leetcode\",\"is\"]", "[\"b\",\"bb\",\"bbb\"]\n[\"a\",\"aa\",\"aaa\"]", "[\"a\",\"ab\"]\n[\"a\",\"a\",\"a\",\"ab\"]"], "hints": ["Could you try every word?", "Could you use a hash map to achieve a good complexity?"], "metadata": {"canonical_parameter_names": ["words1", "words2"], "leetcode_dataset_entry_point": "Solution().countWords", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:31+00:00", "tests_total": 103, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def countWords(self, words1: list[str], words2: list[str]) -> int:", "container": "Solution", "callable": "countWords", "parameters": [{"name": "words1", "type": "list[str]"}, {"name": "words2", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2086, "task_id": "minimum-number-of-food-buckets-to-feed-the-hamsters", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string hamsters where hamsters[i] is either:\n\n- 'H' indicating that there is a hamster at index i, or\n- '.' indicating that index i is empty.\n\nYou will add some number of food buckets at the empty indices in order to feed the hamsters. A hamster can be fed if there is at least one food bucket to its left or to its right. More formally, a hamster at index i can be fed if you place a food bucket at index i - 1 and/or at index i + 1.\n\nReturn the minimum number of food buckets you should place at empty indices to feed all the hamsters or -1 if it is impossible to feed all of them.\n\nExample 1:\n\nInput: hamsters = \"H..H\"\nOutput: 2\nExplanation: We place two food buckets at indices 1 and 2.\nIt can be shown that if we place only one food bucket, one of the hamsters will not be fed.\n\nExample 2:\n\nInput: hamsters = \".H.H.\"\nOutput: 1\nExplanation: We place one food bucket at index 2.\n\nExample 3:\n\nInput: hamsters = \".HHH.\"\nOutput: -1\nExplanation: If we place a food bucket at every empty index as shown, the hamster at index 2 will not be able to eat.\n\nConstraints:\n\n- 1 <= hamsters.length <= 10^5\n- hamsters[i] is either'H' or '.'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(hamsters = \"H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H\") == 3\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H\") == 5\n assert candidate(hamsters = \".....\") == 0\n assert candidate(hamsters = \".\") == 0\n assert candidate(hamsters = \"H..H\") == 2\n assert candidate(hamsters = \"H.H\") == 1\n assert candidate(hamsters = \"H....H\") == 2\n assert candidate(hamsters = \"H.H.H.H.H\") == 3\n assert candidate(hamsters = \"HHHH\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H\") == 4\n assert candidate(hamsters = \"HH\") == -1\n assert candidate(hamsters = \"H.H.HH\") == -1\n assert candidate(hamsters = \".HHH.\") == -1\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == 8\n assert candidate(hamsters = \"HH.HH.HH\") == -1\n assert candidate(hamsters = \"H.H.H\") == 2\n assert candidate(hamsters = \"HH.H.H.H.H\") == -1\n assert candidate(hamsters = \"H.H.H.H\") == 2\n assert candidate(hamsters = \"HH.HH\") == -1\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \".H.H.\") == 1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H\") == 4\n assert candidate(hamsters = \"H.HH\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H.H\") == 7\n assert candidate(hamsters = \"HHHHHH\") == -1\n assert candidate(hamsters = \"HH.H.H\") == -1\n assert candidate(hamsters = \"HH.H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H\") == 5\n assert candidate(hamsters = \"HH.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == 10\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"HH.H.HH\") == -1\n assert candidate(hamsters = \"......\") == 0\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H\") == 6\n assert candidate(hamsters = \"...\") == 0\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == 9\n assert candidate(hamsters = \"H.H.HH.H.H\") == 4\n assert candidate(hamsters = \"H.....H\") == 2\n assert candidate(hamsters = \"H.H.H.H.H.H.H\") == 4\n assert candidate(hamsters = \"H.....H\") == 2\n assert candidate(hamsters = \".......\") == 0\n assert candidate(hamsters = \"HH.HHHHH.HH\") == -1\n assert candidate(hamsters = \".H.H.\") == 1\n assert candidate(hamsters = \"H.H.H.H.HH\") == -1\n assert candidate(hamsters = \"........\") == 0\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H\") == 5\n assert candidate(hamsters = \"..H.H..\") == 1\n assert candidate(hamsters = \"H.H.H.H.H\") == 3\n assert candidate(hamsters = \"HH.H.H.HH\") == -1\n assert candidate(hamsters = \"HH\") == -1\n assert candidate(hamsters = \"H.HH.H\") == 2\n assert candidate(hamsters = \"HH.HH.HH.HH.HH.HH.HH.HH\") == -1\n assert candidate(hamsters = \"...\") == 0\n assert candidate(hamsters = \"H.\") == 1\n assert candidate(hamsters = \"H.H..H.H\") == 2\n assert candidate(hamsters = \"H.......H\") == 2\n assert candidate(hamsters = \"..H..H..\") == 2\n assert candidate(hamsters = \"HHHHH\") == -1\n assert candidate(hamsters = \"HH.HH\") == -1\n assert candidate(hamsters = \"HH.H.H.H.HH\") == -1\n assert candidate(hamsters = \"H...H\") == 2\n assert candidate(hamsters = \"HH.HHH.HH\") == -1\n assert candidate(hamsters = \"........\") == 0\n assert candidate(hamsters = \"H.H.H.HH.H\") == 3\n assert candidate(hamsters = \"HH.HH.HH.HH\") == -1\n assert candidate(hamsters = \"H.H.H.H\") == 2\n assert candidate(hamsters = \".\") == 0\n assert candidate(hamsters = \"HHHHHHHHHH\") == -1\n assert candidate(hamsters = \".HHH.\") == -1\n assert candidate(hamsters = \"H.H.H.HH\") == -1\n assert candidate(hamsters = \".H\") == 1\n assert candidate(hamsters = \".H.H.H.H.\") == 2\n assert candidate(hamsters = \"H.H.H\") == 2\n assert candidate(hamsters = \"H\") == -1\n assert candidate(hamsters = \".........\") == 0\n assert candidate(hamsters = \".H.H.H.H.H.H.H.H.H.\") == 5\n assert candidate(hamsters = \".H.H.H.H.H.H.H.H.\") == 4\n assert candidate(hamsters = \"HHHHHHH\") == -1\n assert candidate(hamsters = \"HH...HH\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H\") == 6\n assert candidate(hamsters = \"H......H\") == 2\n assert candidate(hamsters = \"H.H\") == 1\n assert candidate(hamsters = \"HH.HH.HH.HH.HH\") == -1\n assert candidate(hamsters = \"H..H\") == 2\n assert candidate(hamsters = \"HH..HH\") == -1\n assert candidate(hamsters = \"HHHH\") == -1\n", "comparison": "exact"}, "public_tests": ["\"H..H\"", "\".H.H.\"", "\".HHH.\""], "hints": ["When is it impossible to feed all the hamsters?", "When one or more hamsters do not have an empty space adjacent to it.", "Assuming all previous hamsters are fed. If there is a hamster at index i and you are able to place a bucket at index i - 1 or i + 1, where should you put it?", "It is always better to place a bucket at index i + 1 because it can feed the next hamster as well."], "metadata": {"canonical_parameter_names": ["hamsters"], "leetcode_dataset_entry_point": "Solution().minimumBuckets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:33+00:00", "tests_total": 91, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["string", "dynamic-programming", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minimumBuckets(self, hamsters: str) -> int:", "container": "Solution", "callable": "minimumBuckets", "parameters": [{"name": "hamsters", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2087, "task_id": "minimum-cost-homecoming-of-a-robot-in-a-grid", "difficulty": "Medium", "problem_description": "There is an m x n grid, where (0, 0) is the top-left cell and (m - 1, n - 1) is the bottom-right cell. You are given an integer array startPos where startPos = [start_row, start_col] indicates that initially, a robot is at the cell (start_row, start_col). You are also given an integer array homePos where homePos = [home_row, home_col] indicates that its home is at the cell (home_row, home_col).\n\nThe robot needs to go to its home. It can move one cell in four directions: left, right, up, or down, and it can not move outside the boundary. Every move incurs some cost. You are further given two 0-indexed integer arrays: rowCosts of length m and colCosts of length n.\n\n- If the robot moves up or down into a cell whose row is r, then this move costs rowCosts[r].\n- If the robot moves left or right into a cell whose column is c, then this move costs colCosts[c].\n\nReturn the minimum total cost for this robot to return home.\n\nExample 1:\n\nInput: startPos = [1, 0], homePos = [2, 3], rowCosts = [5, 4, 3], colCosts = [8, 2, 6, 7]\nOutput: 18\nExplanation: One optimal path is that:\nStarting from (1, 0)\n-> It goes down to (2, 0). This move costs rowCosts[2] = 3.\n-> It goes right to (2, 1). This move costs colCosts[1] = 2.\n-> It goes right to (2, 2). This move costs colCosts[2] = 6.\n-> It goes right to (2, 3). This move costs colCosts[3] = 7.\nThe total cost is 3 + 2 + 6 + 7 = 18\n\nExample 2:\n\nInput: startPos = [0, 0], homePos = [0, 0], rowCosts = [5], colCosts = [26]\nOutput: 0\nExplanation: The robot is already at its home. Since no moves occur, the total cost is 0.\n\nConstraints:\n\n- m == rowCosts.length\n- n == colCosts.length\n- 1 <= m, n <= 10^5\n- 0 <= rowCosts[r], colCosts[c] <= 10^4\n- startPos.length == 2\n- homePos.length == 2\n- 0 <= start_row, home_row < m\n- 0 <= start_col, home_col < n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(startPos = [2, 2],homePos = [0, 0],rowCosts = [1, 10, 1],colCosts = [1, 10, 1]) == 22\n assert candidate(startPos = [3, 3],homePos = [0, 0],rowCosts = [10, 20, 30, 40],colCosts = [5, 15, 25, 35]) == 105\n assert candidate(startPos = [1, 0],homePos = [2, 3],rowCosts = [5, 4, 3],colCosts = [8, 2, 6, 7]) == 18\n assert candidate(startPos = [0, 0],homePos = [2, 2],rowCosts = [1, 10, 1],colCosts = [1, 10, 1]) == 22\n assert candidate(startPos = [0, 0],homePos = [2, 2],rowCosts = [1, 1, 1],colCosts = [1, 1, 1]) == 4\n assert candidate(startPos = [1, 1],homePos = [1, 1],rowCosts = [1, 2, 3],colCosts = [4, 5, 6]) == 0\n assert candidate(startPos = [2, 2],homePos = [0, 0],rowCosts = [1, 1, 1],colCosts = [1, 1, 1]) == 4\n assert candidate(startPos = [0, 1],homePos = [2, 1],rowCosts = [3, 2, 1],colCosts = [4, 5]) == 3\n assert candidate(startPos = [0, 0],homePos = [0, 0],rowCosts = [5],colCosts = [26]) == 0\n assert candidate(startPos = [2, 2],homePos = [2, 2],rowCosts = [1, 2],colCosts = [3, 4]) == 0\n assert candidate(startPos = [3, 2],homePos = [0, 0],rowCosts = [1, 2, 3, 4],colCosts = [5, 6, 7]) == 17\n assert candidate(startPos = [0, 1],homePos = [3, 3],rowCosts = [3, 2, 1, 4],colCosts = [4, 3, 2, 1]) == 10\n assert candidate(startPos = [0, 2],homePos = [2, 2],rowCosts = [10, 20, 30],colCosts = [5, 5, 5]) == 50\n assert candidate(startPos = [2, 3],homePos = [1, 1],rowCosts = [1, 1, 1],colCosts = [1, 1, 1, 1]) == 3\n assert candidate(startPos = [2, 3],homePos = [1, 0],rowCosts = [5, 4, 3],colCosts = [8, 2, 6, 7]) == 20\n assert candidate(startPos = [0, 1],homePos = [2, 2],rowCosts = [1, 2, 3],colCosts = [4, 5, 6]) == 11\n assert candidate(startPos = [3, 3],homePos = [7, 7],rowCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(startPos = [1, 2],homePos = [3, 4],rowCosts = [5, 4, 3, 2],colCosts = [1, 2, 3, 4, 5]) == 14\n assert candidate(startPos = [0, 4],homePos = [4, 0],rowCosts = [1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1]) == 8\n assert candidate(startPos = [9, 0],homePos = [9, 9],rowCosts = [100],colCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 540\n assert candidate(startPos = [0, 0],homePos = [9, 9],rowCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],colCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 99\n assert candidate(startPos = [9, 0],homePos = [0, 9],rowCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],colCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 99\n assert candidate(startPos = [2, 3],homePos = [2, 3],rowCosts = [5, 4, 3],colCosts = [8, 2, 6, 7]) == 0\n assert candidate(startPos = [5, 2],homePos = [0, 0],rowCosts = [1, 2, 3, 4, 5, 6],colCosts = [6, 5, 4, 3, 2, 1]) == 26\n assert candidate(startPos = [2, 1],homePos = [2, 1],rowCosts = [1000, 2000, 3000, 4000],colCosts = [5000, 6000, 7000, 8000, 9000]) == 0\n assert candidate(startPos = [0, 9],homePos = [0, 0],rowCosts = [1],colCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 450\n assert candidate(startPos = [2, 3],homePos = [4, 1],rowCosts = [3, 2, 1, 4, 5],colCosts = [6, 7, 8, 9]) == 24\n assert candidate(startPos = [1, 2],homePos = [3, 4],rowCosts = [1, 2, 3, 4],colCosts = [4, 3, 2, 1]) == 8\n assert candidate(startPos = [0, 9],homePos = [9, 0],rowCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],colCosts = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1080\n assert candidate(startPos = [5, 2],homePos = [2, 5],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [60, 50, 40, 30, 20, 10]) == 180\n assert candidate(startPos = [1, 1],homePos = [3, 3],rowCosts = [5, 10, 15, 20],colCosts = [10, 20, 30, 40]) == 105\n assert candidate(startPos = [2, 2],homePos = [7, 2],rowCosts = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],colCosts = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(startPos = [2, 4],homePos = [2, 4],rowCosts = [100, 200, 300],colCosts = [100, 200, 300, 400, 500]) == 0\n assert candidate(startPos = [2, 2],homePos = [2, 2],rowCosts = [100, 200, 300, 400, 500],colCosts = [100, 200, 300, 400, 500]) == 0\n assert candidate(startPos = [0, 5],homePos = [5, 0],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [60, 50, 40, 30, 20, 10]) == 400\n assert candidate(startPos = [1, 2],homePos = [4, 3],rowCosts = [100, 200, 300, 400, 500],colCosts = [10, 20, 30, 40]) == 1240\n assert candidate(startPos = [0, 3],homePos = [3, 0],rowCosts = [10, 20, 30, 40],colCosts = [5, 6, 7, 8]) == 108\n assert candidate(startPos = [4, 4],homePos = [0, 0],rowCosts = [10, 20, 30, 40, 50],colCosts = [1, 2, 3, 4, 5]) == 110\n assert candidate(startPos = [1, 3],homePos = [4, 1],rowCosts = [2, 3, 5, 7, 11],colCosts = [13, 17, 19, 23]) == 59\n assert candidate(startPos = [5, 0],homePos = [0, 5],rowCosts = [1, 1, 1, 1, 1],colCosts = [1, 2, 3, 4, 5]) == 19\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [1, 1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1, 1]) == 10\n assert candidate(startPos = [3, 3],homePos = [0, 0],rowCosts = [10000, 9000, 8000, 7000],colCosts = [6000, 5000, 4000, 3000]) == 42000\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [6, 5, 4, 3, 2, 1]) == 170\n assert candidate(startPos = [0, 5],homePos = [5, 0],rowCosts = [2, 2, 2, 2, 2, 2],colCosts = [2, 2, 2, 2, 2, 2]) == 20\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],colCosts = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 550\n assert candidate(startPos = [3, 3],homePos = [1, 1],rowCosts = [100, 200, 300, 400],colCosts = [400, 300, 200, 100]) == 1000\n assert candidate(startPos = [7, 7],homePos = [2, 2],rowCosts = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2],colCosts = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 60\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [9, 8, 7, 6, 5, 4],colCosts = [3, 2, 1, 4, 5, 6]) == 50\n assert candidate(startPos = [0, 0],homePos = [4, 5],rowCosts = [10, 20, 30, 40, 50],colCosts = [5, 15, 25, 35, 45, 55]) == 315\n assert candidate(startPos = [4, 4],homePos = [6, 6],rowCosts = [5, 1, 2, 3, 4, 3, 2, 1, 5, 10],colCosts = [10, 1, 2, 3, 4, 3, 2, 1, 5, 10]) == 10\n assert candidate(startPos = [3, 3],homePos = [0, 0],rowCosts = [10, 20, 30, 40],colCosts = [40, 30, 20, 10]) == 150\n assert candidate(startPos = [0, 0],homePos = [5, 5],rowCosts = [1, 2, 3, 4, 5, 6],colCosts = [6, 5, 4, 3, 2, 1]) == 35\n assert candidate(startPos = [0, 9],homePos = [9, 0],rowCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 18\n assert candidate(startPos = [3, 2],homePos = [0, 0],rowCosts = [1, 1, 1, 1],colCosts = [1, 1, 1]) == 5\n assert candidate(startPos = [1, 0],homePos = [3, 2],rowCosts = [1, 1, 1, 1],colCosts = [1, 1, 1]) == 4\n assert candidate(startPos = [1, 2],homePos = [3, 0],rowCosts = [1, 1, 1, 1],colCosts = [1, 1, 1]) == 4\n assert candidate(startPos = [0, 0],homePos = [4, 4],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 4, 3, 2, 1]) == 24\n assert candidate(startPos = [10, 5],homePos = [10, 5],rowCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],colCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(startPos = [0, 0],homePos = [3, 3],rowCosts = [1, 2, 3, 4],colCosts = [1, 1, 1, 1]) == 12\n assert candidate(startPos = [5, 5],homePos = [1, 1],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [15, 25, 35, 45, 55, 65]) == 300\n assert candidate(startPos = [2, 2],homePos = [4, 4],rowCosts = [1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1]) == 4\n assert candidate(startPos = [0, 4],homePos = [4, 0],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 10, 15, 20, 25]) == 64\n assert candidate(startPos = [2, 0],homePos = [2, 4],rowCosts = [1, 2, 3],colCosts = [10, 20, 30, 40, 50]) == 140\n assert candidate(startPos = [3, 1],homePos = [0, 3],rowCosts = [5, 10, 15, 20],colCosts = [1, 2, 3, 4]) == 37\n assert candidate(startPos = [5, 5],homePos = [5, 5],rowCosts = [1, 1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1, 1]) == 0\n assert candidate(startPos = [2, 2],homePos = [2, 2],rowCosts = [100, 200, 300],colCosts = [100, 200, 300]) == 0\n assert candidate(startPos = [2, 2],homePos = [2, 2],rowCosts = [1000, 2000, 3000],colCosts = [100, 200, 300]) == 0\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [5, 15, 25, 35, 45, 55]) == 275\n assert candidate(startPos = [0, 3],homePos = [4, 0],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 4, 3, 2, 1]) == 26\n assert candidate(startPos = [3, 4],homePos = [0, 0],rowCosts = [10, 20, 30, 40],colCosts = [5, 15, 25, 35, 45]) == 140\n assert candidate(startPos = [4, 4],homePos = [4, 4],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 4, 3, 2, 1]) == 0\n assert candidate(startPos = [2, 2],homePos = [4, 4],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 4, 3, 2, 1]) == 12\n assert candidate(startPos = [4, 4],homePos = [1, 1],rowCosts = [5, 10, 15, 20, 25],colCosts = [1, 2, 3, 4, 5]) == 54\n assert candidate(startPos = [0, 2],homePos = [4, 2],rowCosts = [10, 20, 30, 40, 50],colCosts = [1, 2, 3]) == 140\n assert candidate(startPos = [4, 0],homePos = [0, 4],rowCosts = [10, 20, 30, 40, 50],colCosts = [50, 40, 30, 20, 10]) == 200\n assert candidate(startPos = [0, 5],homePos = [5, 0],rowCosts = [1, 1, 1, 1, 1, 1],colCosts = [99, 98, 97, 96, 95, 94]) == 490\n assert candidate(startPos = [1, 1],homePos = [3, 3],rowCosts = [1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1]) == 4\n assert candidate(startPos = [3, 0],homePos = [0, 3],rowCosts = [1, 2, 3, 4],colCosts = [1, 1, 1, 1, 1]) == 9\n assert candidate(startPos = [4, 0],homePos = [4, 4],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 10, 15, 20, 25]) == 70\n assert candidate(startPos = [1, 5],homePos = [3, 2],rowCosts = [1, 2, 3, 4],colCosts = [5, 4, 3, 2, 1]) == 13\n", "comparison": "exact"}, "public_tests": ["[1,0]\n[2,3]\n[5,4,3]\n[8,2,6,7]", "[0,0]\n[0,0]\n[5]\n[26]"], "hints": ["Irrespective of what path the robot takes, it will have to traverse all the rows between startRow and homeRow and all the columns between startCol and homeCol.", "Hence, making any other move other than traversing the required rows and columns will potentially incur more cost which can be avoided."], "metadata": {"canonical_parameter_names": ["startPos", "homePos", "rowCosts", "colCosts"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:36+00:00", "tests_total": 80, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minCost(self, startPos: list[int], homePos: list[int], rowCosts: list[int], colCosts: list[int]) -> int:", "container": "Solution", "callable": "minCost", "parameters": [{"name": "startPos", "type": "list[int]"}, {"name": "homePos", "type": "list[int]"}, {"name": "rowCosts", "type": "list[int]"}, {"name": "colCosts", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2088, "task_id": "count-fertile-pyramids-in-a-land", "difficulty": "Hard", "problem_description": "A farmer has a rectangular grid of land with m rows and n columns that can be divided into unit cells. Each cell is either fertile (represented by a 1) or barren (represented by a 0). All cells outside the grid are considered barren.\n\nA pyramidal plot of land can be defined as a set of cells with the following criteria:\n\n1. The number of cells in the set has to be greater than 1 and all cells must be fertile.\n2. The apex of a pyramid is the topmost cell of the pyramid. The height of a pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r <= i <= r + h - 1 and c - (i - r) <= j <= c + (i - r).\n\nAn inverse pyramidal plot of land can be defined as a set of cells with similar criteria:\n\n1. The number of cells in the set has to be greater than 1 and all cells must be fertile.\n2. The apex of an inverse pyramid is the bottommost cell of the inverse pyramid. The height of an inverse pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r - h + 1 <= i <= r and c - (r - i) <= j <= c + (r - i).\n\nSome examples of valid and invalid pyramidal (and inverse pyramidal) plots are shown below. Black cells indicate fertile cells.\n\nGiven a 0-indexed m x n binary matrix grid representing the farmland, return the total number of pyramidal and inverse pyramidal plots that can be found in grid.\n\nExample 1:\n\nInput: grid = [[0,1,1,0],[1,1,1,1]]\nOutput: 2\nExplanation: The 2 possible pyramidal plots are shown in blue and red respectively.\nThere are no inverse pyramidal plots in this grid.\nHence total number of pyramidal and inverse pyramidal plots is 2 + 0 = 2.\n\nExample 2:\n\nInput: grid = [[1,1,1],[1,1,1]]\nOutput: 2\nExplanation: The pyramidal plot is shown in blue, and the inverse pyramidal plot is shown in red.\nHence the total number of plots is 1 + 1 = 2.\n\nExample 3:\n\nInput: grid = [[1,1,1,1,0],[1,1,1,1,1],[1,1,1,1,1],[0,1,0,0,1]]\nOutput: 13\nExplanation: There are 7 pyramidal plots, 3 of which are shown in the 2nd and 3rd figures.\nThere are 6 inverse pyramidal plots, 2 of which are shown in the last figure.\nThe total number of plots is 7 + 6 = 13.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 1000\n- 1 <= m * n <= 10^5\n- grid[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 0], [1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 30\n assert candidate(grid = [[1, 1, 0, 1], [1, 1, 1, 1], [0, 1, 1, 0]]) == 3\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 14\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 8\n assert candidate(grid = [[1, 1, 1], [1, 1, 1]]) == 2\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [0, 1, 0, 0, 1]]) == 13\n assert candidate(grid = [[0, 1, 1, 0, 0, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1]]) == 4\n assert candidate(grid = [[1, 1], [1, 1]]) == 0\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0]]) == 32\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0]]) == 54\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 120\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0]]) == 24\n assert candidate(grid = [[1, 1, 1, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1]]) == 34\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 8\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 36\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 24\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 41\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0]]) == 88\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 80\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0]]) == 16\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1140\n assert candidate(grid = [[0, 0, 1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0]]) == 75\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 12\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 8\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]]) == 50\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 128\n assert candidate(grid = [[1, 0, 1, 0, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0]]) == 19\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 18\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == 40\n assert candidate(grid = [[1, 1, 1, 0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 14\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 0, 1, 1, 0, 1]]) == 14\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 100\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0]]) == 177\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 8\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 24\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 53\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 200\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 54\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0]]) == 112\n", "comparison": "exact"}, "public_tests": ["[[0,1,1,0],[1,1,1,1]]", "[[1,1,1],[1,1,1]]", "[[1,1,1,1,0],[1,1,1,1,1],[1,1,1,1,1],[0,1,0,0,1]]"], "hints": ["Think about how dynamic programming can help solve the problem.", "For any fixed cell (r, c), can you calculate the maximum height of the pyramid for which it is the apex? Let us denote this value as dp[r][c].", "How will the values at dp[r+1][c-1] and dp[r+1][c+1] help in determining the value at dp[r][c]?", "For the cell (r, c), is there a relation between the number of pyramids for which it serves as the apex and dp[r][c]? How does it help in calculating the answer?"], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().countPyramids", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:38+00:00", "tests_total": 74, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "dynamic-programming", "matrix"]}, "language": "python", "interface": {"raw_signature": "def countPyramids(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "countPyramids", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2089, "task_id": "find-target-indices-after-sorting-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums and a target element target.\n\nA target index is an index i such that nums[i] == target.\n\nReturn a list of the target indices of nums after sorting nums in non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing order.\n\nExample 1:\n\nInput: nums = [1,2,5,2,3], target = 2\nOutput: [1,2]\nExplanation: After sorting, nums is [1,2,2,3,5].\nThe indices where nums[i] == 2 are 1 and 2.\n\nExample 2:\n\nInput: nums = [1,2,5,2,3], target = 3\nOutput: [3]\nExplanation: After sorting, nums is [1,2,2,3,5].\nThe index where nums[i] == 3 is 3.\n\nExample 3:\n\nInput: nums = [1,2,5,2,3], target = 5\nOutput: [4]\nExplanation: After sorting, nums is [1,2,2,3,5].\nThe index where nums[i] == 5 is 4.\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 1 <= nums[i], target <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 99, 98, 97, 96],target = 98) == [2]\n assert candidate(nums = [10, 20, 30, 40, 50],target = 50) == [4]\n assert candidate(nums = [7, 7, 7, 7, 7],target = 8) == []\n assert candidate(nums = [10, 20, 30, 40, 50],target = 25) == []\n assert candidate(nums = [50, 40, 30, 20, 10],target = 15) == []\n assert candidate(nums = [100, 100, 100],target = 100) == [0, 1, 2]\n assert candidate(nums = [1, 2, 5, 2, 3],target = 3) == [3]\n assert candidate(nums = [2, 4, 6, 8, 10],target = 2) == [0]\n assert candidate(nums = [5, 5, 5, 5, 5],target = 5) == [0, 1, 2, 3, 4]\n assert candidate(nums = [1, 1, 1, 1, 1],target = 1) == [0, 1, 2, 3, 4]\n assert candidate(nums = [5, 4, 3, 2, 1],target = 3) == [2]\n assert candidate(nums = [1, 3, 5, 7, 9],target = 2) == []\n assert candidate(nums = [1, 2, 2, 2, 3, 4],target = 2) == [1, 2, 3]\n assert candidate(nums = [1, 2, 5, 2, 3],target = 2) == [1, 2]\n assert candidate(nums = [50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4]\n assert candidate(nums = [5, 5, 5, 5, 5],target = 6) == []\n assert candidate(nums = [1, 3, 5, 7, 9],target = 10) == []\n assert candidate(nums = [100, 1, 100, 1, 100],target = 1) == [0, 1]\n assert candidate(nums = [1, 2, 5, 2, 3],target = 5) == [4]\n assert candidate(nums = [1, 1, 1, 1, 1],target = 2) == []\n assert candidate(nums = [1, 3, 5, 7, 9],target = 4) == []\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 4) == [6, 7]\n assert candidate(nums = [5, 4, 3, 2, 1],target = 3) == [2]\n assert candidate(nums = [90, 80, 70, 60, 50, 40, 30, 20, 10],target = 45) == []\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 50) == [4]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],target = 95) == [5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10],target = 7) == [6]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],target = 5) == [4]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],target = 27) == [8]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],target = 4) == [3]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],target = 5) == [4]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],target = 35) == [6]\n assert candidate(nums = [100, 100, 99, 99, 98, 98, 97, 97],target = 99) == [4, 5]\n assert candidate(nums = [45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31],target = 37) == [6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 1) == [0]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 8) == [3]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 10) == []\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5) == [4]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 20) == []\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],target = 4) == [3]\n assert candidate(nums = [42, 24, 36, 18, 54, 30, 48, 27, 60, 39],target = 30) == [3]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],target = 5) == [4]\n assert candidate(nums = [100, 50, 30, 70, 20],target = 30) == [1]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 50) == [4]\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],target = 8) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [42, 23, 37, 23, 42, 37],target = 37) == [2, 3]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 4) == [7, 8, 9, 10]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7],target = 15) == [8]\n assert candidate(nums = [100, 99, 98, 97, 96, 95],target = 98) == [3]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],target = 55) == [5]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = 15) == [7]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 10) == [9]\n assert candidate(nums = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1],target = 2) == [5, 6, 7, 8, 9]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 55) == []\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 1) == [0]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],target = 35) == [4]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],target = 3) == [6, 7, 8]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 20) == [9]\n assert candidate(nums = [100, 99, 98, 97, 96],target = 97) == [1]\n assert candidate(nums = [8, 6, 6, 6, 8, 6, 8, 6, 8, 6, 6, 6, 6, 6],target = 6) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [42, 27, 89, 10, 56, 23, 50, 78, 34, 67],target = 50) == [5]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 8) == []\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 10) == [18, 19]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 40) == [3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 11) == []\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],target = 5) == [4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10) == [9]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],target = 13) == [12]\n assert candidate(nums = [50, 20, 30, 40, 10],target = 30) == [2]\n assert candidate(nums = [100, 1, 50, 20, 30, 60, 40],target = 30) == [2]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 6) == [5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [14]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],target = 10) == [9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15) == [14]\n assert candidate(nums = [50, 50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 8) == [7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 11) == []\n assert candidate(nums = [10, 20, 30, 40, 50],target = 20) == [1]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],target = 20) == [5, 6, 7, 8, 9]\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [5]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 17) == []\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],target = 95) == [4]\n assert candidate(nums = [50, 20, 30, 10, 40],target = 30) == [2]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 6) == []\n assert candidate(nums = [3, 1, 2, 5, 4, 2, 3, 3, 5, 1],target = 3) == [4, 5, 6]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1],target = 2) == []\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 6) == []\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 18) == [8]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5) == [4]\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100],target = 1) == [0, 1, 2]\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3],target = 2) == [3, 4, 5]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5) == [4]\n assert candidate(nums = [50, 20, 30, 40, 10],target = 20) == [1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 10) == []\n assert candidate(nums = [50, 20, 30, 40, 10, 60, 70, 80, 90, 100],target = 40) == [3]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 10) == [9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 21) == []\n assert candidate(nums = [3, 1, 2, 5, 4],target = 4) == [3]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [8]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10],target = 15) == [5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 55) == []\n assert candidate(nums = [10, 20, 10, 20, 10, 20],target = 10) == [0, 1, 2]\n assert candidate(nums = [50, 40, 30, 20, 10],target = 30) == [2]\n assert candidate(nums = [50, 40, 30, 20, 10],target = 20) == [1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [14]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 6) == [5]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],target = 25) == [12]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 5) == [4]\n assert candidate(nums = [3, 1, 2, 4, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 3) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(nums = [42, 37, 58, 54, 19, 91, 49, 100, 65, 28, 74, 99, 96, 33, 80, 78, 60, 82, 97, 71],target = 74) == [11]\n", "comparison": "exact"}, "public_tests": ["[1,2,5,2,3]\n2", "[1,2,5,2,3]\n3", "[1,2,5,2,3]\n5"], "hints": ["Try \"sorting\" the array first.", "Now find all indices in the array whose values are equal to target."], "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().targetIndices", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:40+00:00", "tests_total": 118, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "binary-search", "sorting"]}, "language": "python", "interface": {"raw_signature": "def targetIndices(self, nums: list[int], target: int) -> list[int]:", "container": "Solution", "callable": "targetIndices", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2090, "task_id": "k-radius-subarray-averages", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums of n integers, and an integer k.\n\nThe k-radius average for a subarray of nums centered at some index i with the radius k is the average of all elements in nums between the indices i - k and i + k (inclusive). If there are less than k elements before or after the index i, then the k-radius average is -1.\n\nBuild and return an array avgs of length n where avgs[i] is the k-radius average for the subarray centered at index i.\n\nThe average of x elements is the sum of the x elements divided by x, using integer division. The integer division truncates toward zero, which means losing its fractional part.\n\n- For example, the average of four elements 2, 3, 1, and 5 is (2 + 3 + 1 + 5) / 4 = 11 / 4 = 2.75, which truncates to 2.\n\nExample 1:\n\nInput: nums = [7,4,3,9,1,8,5,2,6], k = 3\nOutput: [-1,-1,-1,5,4,4,-1,-1,-1]\nExplanation:\n- avg[0], avg[1], and avg[2] are -1 because there are less than k elements before each index.\n- The sum of the subarray centered at index 3 with radius 3 is: 7 + 4 + 3 + 9 + 1 + 8 + 5 = 37.\n Using integer division, avg[3] = 37 / 7 = 5.\n- For the subarray centered at index 4, avg[4] = (4 + 3 + 9 + 1 + 8 + 5 + 2) / 7 = 4.\n- For the subarray centered at index 5, avg[5] = (3 + 9 + 1 + 8 + 5 + 2 + 6) / 7 = 4.\n- avg[6], avg[7], and avg[8] are -1 because there are less than k elements after each index.\n\nExample 2:\n\nInput: nums = [100000], k = 0\nOutput: [100000]\nExplanation:\n- The sum of the subarray centered at index 0 with radius 0 is: 100000.\n avg[0] = 100000 / 1 = 100000.\n\nExample 3:\n\nInput: nums = [8], k = 100000\nOutput: [-1]\nExplanation:\n- avg[0] is -1 because there are less than k elements before and after index 0.\n\nConstraints:\n\n- n == nums.length\n- 1 <= n <= 10^5\n- 0 <= nums[i], k <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0],k = 2) == [-1, -1, 0, -1, -1]\n assert candidate(nums = [100000],k = 0) == [100000]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == [-1, -1, -1, -1, 5, 5, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 2) == [-1, -1, 3, 4, 5, 6, 7, -1, -1]\n assert candidate(nums = [8],k = 100000) == [-1]\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == [-1, -1, 3, -1, -1]\n assert candidate(nums = [5],k = 0) == [5]\n assert candidate(nums = [5, 5, 5, 5, 5],k = 1) == [-1, 5, 5, 5, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == [-1, -1, -1, -1, 5, 6, -1, -1, -1, -1]\n assert candidate(nums = [7, 4, 3, 9, 1, 8, 5, 2, 6],k = 3) == [-1, -1, -1, 5, 4, 4, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == [-1, 2, 3, 4, -1]\n assert candidate(nums = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],k = 3) == [-1, -1, -1, 102, 103, 104, 105, 106, 107, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 8, 9, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 0) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5) == [-1, -1, -1, -1, -1, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 12) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 5) == [-1, -1, -1, -1, -1, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, -1, -1, -1, -1, -1]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 0) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == [-1, -1, -1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 3) == [-1, -1, -1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4) == [-1, -1, -1, -1, 5, 4, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 3) == [-1, -1, -1, 2, 1, 1, 1, 2, -1, -1, -1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == [-1, -1, -1, -1, 6, 5, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 2) == [-1, -1, 3, 2, 1, 1, 1, 2, 3, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 3) == [-1, -1, -1, 7, 9, 11, 13, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 4) == [-1, -1, -1, -1, 0, 0, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2) == [-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 4) == [-1, -1, -1, -1, 5000, 6000, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == [-1, -1, -1, -1, -1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 2) == [-1, -1, 99998, 99997, 99996, 99995, 99994, 99993, -1, -1]\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],k = 4) == [-1, -1, -1, -1, 99995, 99994, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 4) == [-1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 6) == [-1, -1, -1, -1, -1, -1, 7, 8, 9, 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == [-1, 8, 7, 6, 5, 4, 3, 2, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 8) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 8) == [-1, -1, -1, -1, -1, -1, -1, -1, 90, 100, 110, 120, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0],k = 4) == [-1, -1, -1, -1, 55555, 44444, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 4) == [-1, -1, -1, -1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 0) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 4) == [-1, -1, -1, -1, 60000, 50000, -1, -1, -1, -1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 2) == [-1, -1, 15, 20, 25, 30, 35, 40, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 5, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0],k = 2) == [-1, -1, 60000, 40000, 60000, 40000, 60000, 40000, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5) == [-1, -1, -1, -1, -1, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 5) == [-1, -1, -1, -1, -1, 600, 700, 800, 900, 1000, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == [-1, -1, -1, -1, -1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 3) == [-1, -1, -1, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 0) == [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 4) == [-1, -1, -1, -1, 5, 6, 7, 8, 9, 10, 11, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == [-1, -1, -1, 40, 50, 60, 70, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == [-1, -1, -1, 0, 0, 0, 0, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1],k = 1) == [-1, 5, 5, 5, 5, 4, 6, 4, -1]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 5) == [-1, -1, -1, -1, -1, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 2) == [-1, -1, 3, 2, 1, 1, 1, 2, 3, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 2) == [-1, -1, 80000, 70000, 60000, 50000, 40000, 30000, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2) == [-1, -1, 30, 40, 50, 60, 70, 80, -1, -1]\n assert candidate(nums = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],k = 4) == [-1, -1, -1, -1, 99999, 99999, -1, -1, -1, -1]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 4) == [-1, -1, -1, -1, 100000, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == [-1, -1, -1, 40, 50, 60, 70, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 15, 17, 19, 21, 23, 25, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == [-1, -1, 300, 400, 500, 600, 700, 800, -1, -1]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == [-1, -1, -1, -1, -1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 4) == [-1, -1, -1, -1, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 1) == [-1, 3, 5, 7, 9, 11, 13, 15, 17, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [6, 10, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 2) == [-1, -1, 5, 5, 4, 4, 5, 5, 4, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2) == [-1, -1, 0, 0, 0, 0, 0, 0, -1, -1]\n", "comparison": "exact"}, "public_tests": ["[7,4,3,9,1,8,5,2,6]\n3", "[100000]\n0", "[8]\n100000"], "hints": ["To calculate the average of a subarray, you need the sum and the K. K is already given. How could you quickly calculate the sum of a subarray?", "Use the Prefix Sums method to calculate the subarray sums.", "It is possible that the sum of all the elements does not fit in a 32-bit integer type. Be sure to use a 64-bit integer type for the prefix sum array."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().getAverages", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:42+00:00", "tests_total": 94, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def getAverages(self, nums: list[int], k: int) -> list[int]:", "container": "Solution", "callable": "getAverages", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2091, "task_id": "removing-minimum-and-maximum-from-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of distinct integers nums.\n\nThere is an element in nums that has the lowest value and an element that has the highest value. We call them the minimum and maximum respectively. Your goal is to remove both these elements from the array.\n\nA deletion is defined as either removing an element from the front of the array or removing an element from the back of the array.\n\nReturn the minimum number of deletions it would take to remove both the minimum and maximum element from the array.\n\nExample 1:\n\nInput: nums = [2,10,7,5,4,1,8,6]\nOutput: 5\nExplanation:\nThe minimum element in the array is nums[5], which is 1.\nThe maximum element in the array is nums[1], which is 10.\nWe can remove both the minimum and maximum by removing 2 elements from the front and 3 elements from the back.\nThis results in 2 + 3 = 5 deletions, which is the minimum number possible.\n\nExample 2:\n\nInput: nums = [0,-4,19,1,8,-2,-3,5]\nOutput: 3\nExplanation:\nThe minimum element in the array is nums[1], which is -4.\nThe maximum element in the array is nums[2], which is 19.\nWe can remove both the minimum and maximum by removing 3 elements from the front.\nThis results in only 3 deletions, which is the minimum number possible.\n\nExample 3:\n\nInput: nums = [101]\nOutput: 1\nExplanation:\nThere is only one element in the array, which makes it both the minimum and maximum element.\nWe can remove it with 1 deletion.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- -10^5 <= nums[i] <= 10^5\n- The integers in nums are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 10, 7, 5, 4, 1, 8, 6]) == 5\n assert candidate(nums = [100000, -100000, 50000, -50000]) == 2\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [101]) == 1\n assert candidate(nums = [3, 1, 2, 4, 5]) == 3\n assert candidate(nums = [100000, -100000, 50000, -50000, 0]) == 2\n assert candidate(nums = [0, -4, 19, 1, 8, -2, -3, 5]) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [1, 3, 2]) == 2\n assert candidate(nums = [3, 1]) == 2\n assert candidate(nums = [3, 2, 1]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 2\n assert candidate(nums = [-1, 1]) == 2\n assert candidate(nums = [5, 3, 1, 2, 4]) == 3\n assert candidate(nums = [5, 3, 1, 4, 2]) == 3\n assert candidate(nums = [99, 97, 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59, 57, 55, 53, 51]) == 2\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991, -99990, -99989, -99988, -99987, -99986, -99985, -99984, -99983, -99982, -99981, -99980, -99979, -99978, -99977, -99976, -99975, -99974, -99973, -99972, -99971, -99970, 100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970]) == 32\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 2\n assert candidate(nums = [-50000, 49999, -49999, 49998, -49998, 49997, -49997, 49996, -49996, 49995]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 2\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [3, 1, 2, 5, 4, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [-7, 10, 5, -3, 2, 8, 0, -1, 6, 4]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 2\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(nums = [3, 7, 1, 9, 5, 2, 8, 4, 6]) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500]) == 6\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 2\n assert candidate(nums = [30, 20, 10, 0, -10, -20, -30, 40, 50, 60, 70, 80, 90, 100]) == 8\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995]) == 2\n assert candidate(nums = [-1, -5, -3, -7, -2, -6, -4]) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500, 0]) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14]) == 13\n assert candidate(nums = [9, 3, 5, 2, 7, 6, 1, 8, 4]) == 4\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 75000, -75000, 12500, -12500]) == 2\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 2\n assert candidate(nums = [3, 1, 2, 5, 4]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1]) == 2\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == 2\n assert candidate(nums = [5, 2, 8, 3, 7, 6, 4, 10, 1, 9]) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 2\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 2\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 2\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 2\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 8, 7, 10, 9]) == 4\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [-5, -10, -3, -1, -8, -2, -7, -4, -6, -9]) == 4\n assert candidate(nums = [3, 1, 2]) == 2\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -1]) == 2\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7]) == 22\n assert candidate(nums = [40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21]) == 2\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, 0]) == 3\n assert candidate(nums = [1, 10, 3, 8, 5, 2, 7, 4, 6, 9]) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 6\n assert candidate(nums = [1000, 100, 10, 1, 0, -1, -10, -100, -1000, 500, 50, 5, 0.5, 0.05, 0.005, 0.0005, 5e-05]) == 9\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500, 6250, -6250]) == 2\n assert candidate(nums = [-10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2\n assert candidate(nums = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(nums = [10, 2, 8, 6, 7, 3, 5, 1, 9, 4]) == 4\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 11\n assert candidate(nums = [-100000, 100000, 1, -1, 50000, -50000, 99999, -99999, 42, -42]) == 2\n assert candidate(nums = [7, 3, 5, 2, 8, 6, 4, 1]) == 4\n assert candidate(nums = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 2\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [20, 18, 19, 16, 17, 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 1]) == 2\n assert candidate(nums = [9, 3, 15, 1, 12, 7, 8, 6, 10, 2]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6]) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 8, 18, 28, 38, 48, 58, 68, 78, 88, 98, 7, 17, 27, 37, 47, 57, 67, 77, 87, 97, 6, 16, 26, 36, 46, 56, 66, 76, 86, 96, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 4, 14, 24, 34, 44, 54, 64, 74, 84, 94, 3, 13, 23, 33, 43, 53, 63, 73, 83, 93, 2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 1, 11, 21, 31, 41, 51, 61, 71, 81, 91]) == 20\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 2\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993, 9, 99992, 10, 99991, 11, 99990, 12, 99989, 13, 99988, 14, 99987, 15, 99986, 16, 99985, 17, 99984, 18, 99983, 19, 99982, 20, 99981, 21, 99980, 22, 99979, 23, 99978, 24, 99977, 25, 99976, 26, 99975, 27, 99974, 28, 99973, 29, 99972, 30, 99971]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7]) == 2\n", "comparison": "exact"}, "public_tests": ["[2,10,7,5,4,1,8,6]", "[0,-4,19,1,8,-2,-3,5]", "[101]"], "hints": ["There can only be three scenarios for deletions such that both minimum and maximum elements are removed:", "Scenario 1: Both elements are removed by only deleting from the front.", "Scenario 2: Both elements are removed by only deleting from the back.", "Scenario 3: Delete from the front to remove one of the elements, and delete from the back to remove the other element.", "Compare which of the three scenarios results in the minimum number of moves."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumDeletions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:45+00:00", "tests_total": 102, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minimumDeletions(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minimumDeletions", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2092, "task_id": "find-all-people-with-secret", "difficulty": "Hard", "problem_description": "You are given an integer n indicating there are n people numbered from 0 to n - 1. You are also given a 0-indexed 2D integer array meetings where meetings[i] = [x_i, y_i, time_i] indicates that person x_i and person y_i have a meeting at time_i. A person may attend multiple meetings at the same time. Finally, you are given an integer firstPerson.\n\nPerson 0 has a secret and initially shares the secret with a person firstPerson at time 0. This secret is then shared every time a meeting takes place with a person that has the secret. More formally, for every meeting, if a person x_i has the secret at time_i, then they will share the secret with person y_i, and vice versa.\n\nThe secrets are shared instantaneously. That is, a person may receive the secret and share it with people in other meetings within the same time frame.\n\nReturn a list of all the people that have the secret after all the meetings have taken place. You may return the answer in any order.\n\nExample 1:\n\nInput: n = 6, meetings = [[1,2,5],[2,3,8],[1,5,10]], firstPerson = 1\nOutput: [0,1,2,3,5]\nExplanation:\nAt time 0, person 0 shares the secret with person 1.\nAt time 5, person 1 shares the secret with person 2.\nAt time 8, person 2 shares the secret with person 3.\nAt time 10, person 1 shares the secret with person 5.\nThus, people 0, 1, 2, 3, and 5 know the secret after all the meetings.\n\nExample 2:\n\nInput: n = 4, meetings = [[3,1,3],[1,2,2],[0,3,3]], firstPerson = 3\nOutput: [0,1,3]\nExplanation:\nAt time 0, person 0 shares the secret with person 3.\nAt time 2, neither person 1 nor person 2 know the secret.\nAt time 3, person 3 shares the secret with person 0 and person 1.\nThus, people 0, 1, and 3 know the secret after all the meetings.\n\nExample 3:\n\nInput: n = 5, meetings = [[3,4,2],[1,2,1],[2,3,1]], firstPerson = 1\nOutput: [0,1,2,3,4]\nExplanation:\nAt time 0, person 0 shares the secret with person 1.\nAt time 1, person 1 shares the secret with person 2, and person 2 shares the secret with person 3.\nNote that person 2 can share the secret at the same time as receiving it.\nAt time 2, person 3 shares the secret with person 4.\nThus, people 0, 1, 2, 3, and 4 know the secret after all the meetings.\n\nConstraints:\n\n- 2 <= n <= 10^5\n- 1 <= meetings.length <= 10^5\n- meetings[i].length == 3\n- 0 <= x_i, y_i<= n - 1\n- x_i != y_i\n- 1 <= time_i <= 10^5\n- 1 <= firstPerson <= n - 1\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(n=3, meetings=[[0, 1, 10], [1, 2, 20]], firstPerson=1), [0, 1, 2])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=3, meetings=[[0, 1, 1], [1, 2, 2], [0, 2, 3]], firstPerson=2), [0, 1, 2])\n assert answers_match(candidate(n=5, meetings=[[3, 4, 2], [1, 2, 1], [2, 3, 1]], firstPerson=1), [0, 1, 2, 3, 4])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 10], [1, 2, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=4, meetings=[[3, 1, 3], [1, 2, 2], [0, 3, 3]], firstPerson=3), [0, 1, 3])\n assert answers_match(candidate(n=7, meetings=[[0, 2, 1], [1, 3, 2], [2, 4, 3], [3, 5, 4], [4, 6, 5]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=3, meetings=[[0, 1, 10], [1, 2, 20], [2, 0, 30]], firstPerson=2), [0, 1, 2])\n assert answers_match(candidate(n=3, meetings=[[0, 1, 1], [1, 2, 2], [0, 2, 3]], firstPerson=1), [0, 1, 2])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=6, meetings=[[1, 2, 5], [2, 3, 8], [1, 5, 10]], firstPerson=1), [0, 1, 2, 3, 5])\n assert answers_match(candidate(n=7, meetings=[[0, 2, 1], [1, 3, 1], [4, 5, 1], [5, 6, 1]], firstPerson=2), [0, 2])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 0, 75]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [1, 5, 2], [2, 6, 2], [3, 7, 2], [4, 8, 2], [5, 9, 3], [6, 9, 3], [7, 9, 3], [8, 9, 3]], firstPerson=9), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 2], [2, 0, 3], [3, 4, 4], [4, 5, 5], [5, 3, 6], [6, 7, 7], [7, 8, 8], [8, 6, 9], [9, 10, 10], [10, 11, 11], [11, 9, 12]], firstPerson=1), [0, 1, 2])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3]], firstPerson=2), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=11, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 0, 11]], firstPerson=10), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 0, 1], [0, 5, 2], [1, 6, 2], [2, 7, 2], [3, 8, 2], [4, 9, 2], [5, 10, 2], [6, 11, 2], [7, 0, 2], [8, 1, 2], [9, 2, 2], [10, 3, 2], [11, 4, 2]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])\n assert answers_match(candidate(n=20, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19]], firstPerson=10), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12]], firstPerson=6), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])\n assert answers_match(candidate(n=20, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20]], firstPerson=10), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 7, 9], [1, 6, 10], [2, 5, 11], [3, 4, 12]], firstPerson=4), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 2, 11], [1, 3, 12], [2, 4, 13], [3, 5, 14], [4, 6, 15], [5, 7, 16], [6, 8, 17], [7, 9, 18], [8, 0, 19], [9, 1, 20]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])\n assert answers_match(candidate(n=6, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 0, 6]], firstPerson=1), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 0, 1]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])\n assert answers_match(candidate(n=9, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 0, 9], [0, 5, 10]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8])\n assert answers_match(candidate(n=20, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 0, 1]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 10], [0, 2, 10], [1, 3, 20], [1, 4, 20], [2, 5, 30], [2, 6, 30], [3, 7, 40], [3, 8, 40], [4, 9, 50], [4, 10, 50], [5, 11, 60], [5, 12, 60], [6, 13, 70], [6, 14, 70]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=10, meetings=[[0, 9, 1], [1, 8, 2], [2, 7, 3], [3, 6, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]], firstPerson=5), [0, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=6, meetings=[[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50]], firstPerson=1), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 0, 2], [1, 3, 3], [2, 4, 3], [3, 5, 3], [4, 6, 3], [5, 7, 3], [6, 8, 3], [7, 9, 3], [8, 0, 3], [9, 1, 3]], firstPerson=4), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=10, meetings=[[0, 9, 1], [1, 8, 2], [2, 7, 3], [3, 6, 4], [4, 5, 5], [5, 4, 5], [6, 3, 4], [7, 2, 3], [8, 1, 2], [9, 0, 1]], firstPerson=5), [0, 4, 5, 9])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 7, 4], [3, 8, 4], [4, 9, 5], [4, 10, 5], [5, 11, 6], [5, 12, 6], [6, 13, 7], [6, 14, 7]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [0, 5, 1], [0, 6, 1], [0, 7, 1], [0, 8, 1], [0, 9, 1]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=9, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 0, 9], [0, 2, 10], [1, 3, 11], [2, 4, 12], [3, 5, 13], [4, 6, 14], [5, 7, 15], [6, 8, 16], [7, 0, 17], [8, 1, 18]], firstPerson=4), [0, 1, 2, 3, 4, 5, 6, 7, 8])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [1, 3, 9], [3, 5, 10], [5, 7, 11], [7, 1, 12]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5]], firstPerson=4), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12], [0, 11, 13]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 4, 4], [3, 5, 5], [4, 6, 6], [5, 6, 7]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [0, 6, 70]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 9, 11], [1, 8, 12], [2, 7, 13], [3, 6, 14], [4, 5, 15]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 4, 4], [3, 5, 5], [4, 6, 6], [5, 6, 7]], firstPerson=2), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=6, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5]], firstPerson=1), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(n=10, meetings=[[0, 9, 10], [1, 2, 10], [3, 4, 10], [5, 6, 10], [7, 8, 10], [1, 3, 10], [2, 4, 10], [5, 7, 10], [6, 8, 10]], firstPerson=1), [0, 1, 2, 3, 4, 9])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 2], [2, 0, 3], [0, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 11]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 5, 3], [5, 6, 3], [6, 7, 4], [7, 8, 4], [8, 9, 5]], firstPerson=4), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [2, 3, 2], [4, 5, 3], [6, 7, 4], [0, 2, 5], [1, 3, 6], [2, 4, 7], [3, 5, 8], [4, 6, 9], [5, 7, 10]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 0, 5]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=6, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 5, 3], [5, 0, 3], [1, 4, 4], [2, 5, 5]], firstPerson=2), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [5, 6, 35], [6, 0, 40]], firstPerson=6), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 3, 9], [1, 5, 10]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=10, meetings=[[0, 4, 5], [4, 5, 5], [0, 1, 6], [1, 2, 6], [2, 3, 7], [3, 4, 7], [4, 6, 8], [5, 7, 9], [6, 8, 10], [7, 9, 11]], firstPerson=4), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=20, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20]], firstPerson=19), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15], [0, 7, 16], [7, 11, 17], [11, 14, 18]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 0, 7], [0, 6, 8]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 1], [2, 3, 1], [4, 5, 1], [6, 7, 1], [8, 9, 1], [10, 11, 1], [12, 13, 1], [13, 14, 1], [0, 2, 2], [1, 3, 2], [4, 6, 2], [5, 7, 2], [8, 10, 2], [9, 11, 2], [12, 14, 2], [13, 0, 3], [14, 1, 3], [0, 4, 3], [1, 5, 3], [2, 6, 3], [3, 7, 3], [4, 8, 3], [5, 9, 3], [6, 10, 3], [7, 11, 3], [8, 12, 3], [9, 13, 3], [10, 14, 3]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 4, 4], [3, 5, 5], [4, 6, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 11], [0, 3, 12], [1, 5, 13], [2, 4, 14]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10]], firstPerson=9), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 1], [1, 2, 2], [0, 3, 3], [3, 4, 4], [0, 5, 5], [5, 6, 6], [2, 4, 7], [1, 6, 8]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=6, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [0, 5, 6]], firstPerson=1), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=10, meetings=[[0, 9, 10], [1, 8, 10], [2, 7, 10], [3, 6, 10], [4, 5, 10], [0, 1, 20], [1, 2, 20], [2, 3, 20], [3, 4, 20], [4, 5, 20]], firstPerson=9), [0, 1, 2, 3, 4, 5, 9])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12], [0, 6, 13], [1, 7, 14], [2, 8, 15], [3, 9, 16], [4, 10, 17], [5, 11, 18]], firstPerson=6), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])\n assert answers_match(candidate(n=6, meetings=[[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5]], firstPerson=1), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(n=9, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 0, 9], [0, 2, 10], [1, 3, 11], [2, 4, 12], [3, 5, 13], [4, 6, 14], [5, 7, 15], [6, 8, 16], [7, 0, 17], [8, 1, 18]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 10], [1, 2, 11], [2, 3, 12], [3, 4, 13], [4, 5, 14], [5, 6, 15], [6, 7, 16], [7, 8, 17], [8, 9, 18], [9, 10, 19], [10, 11, 20], [11, 12, 21], [12, 13, 22], [13, 14, 23]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 0, 1]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 4], [1, 5, 5], [2, 6, 6], [3, 6, 6], [4, 5, 5], [4, 6, 6], [5, 6, 6]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6])\n", "comparison": "unordered"}, "public_tests": ["6\n[[1,2,5],[2,3,8],[1,5,10]]\n1", "4\n[[3,1,3],[1,2,2],[0,3,3]]\n3", "5\n[[3,4,2],[1,2,1],[2,3,1]]\n1"], "hints": ["Could you model all the meetings happening at the same time as a graph?", "What data structure can you use to efficiently share the secret?", "You can use the union-find data structure to quickly determine who knows the secret and share the secret."], "metadata": {"canonical_parameter_names": ["n", "meetings", "firstPerson"], "leetcode_dataset_entry_point": "Solution().findAllPeople", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:48+00:00", "tests_total": 84, "tests_dropped": 4, "flags": ["any_order"], "topic_tags": ["depth-first-search", "breadth-first-search", "union-find", "graph", "sorting"]}, "language": "python", "interface": {"raw_signature": "def findAllPeople(self, n: int, meetings: list[list[int]], firstPerson: int) -> list[int]:", "container": "Solution", "callable": "findAllPeople", "parameters": [{"name": "n", "type": "int"}, {"name": "meetings", "type": "list[list[int]]"}, {"name": "firstPerson", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2094, "task_id": "finding-3-digit-even-numbers", "difficulty": "Easy", "problem_description": "You are given an integer array digits, where each element is a digit. The array may contain duplicates.\n\nYou need to find all the unique integers that follow the given requirements:\n\n- The integer consists of the concatenation of three elements from digits in any arbitrary order.\n- The integer does not have leading zeros.\n- The integer is even.\n\nFor example, if the given digits were [1, 2, 3], integers 132 and 312 follow the requirements.\n\nReturn a sorted array of the unique integers.\n\nExample 1:\n\nInput: digits = [2,1,3,0]\nOutput: [102,120,130,132,210,230,302,310,312,320]\nExplanation: All the possible integers that follow the requirements are in the output array.\nNotice that there are no odd integers or integers with leading zeros.\n\nExample 2:\n\nInput: digits = [2,2,8,8,2]\nOutput: [222,228,282,288,822,828,882]\nExplanation: The same digit can be used as many times as it appears in digits.\nIn this example, the digit 8 is used twice each time in 288, 828, and 882.\n\nExample 3:\n\nInput: digits = [3,7,5]\nOutput: []\nExplanation: No even integers can be formed using the given digits.\n\nConstraints:\n\n- 3 <= digits.length <= 100\n- 0 <= digits[i] <= 9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(digits = [1, 1, 1, 1, 1, 1]) == []\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(digits = [2, 4, 6, 8, 0]) == [204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 0, 2, 4, 3, 5, 7, 9]) == [102, 104, 120, 124, 130, 132, 134, 140, 142, 150, 152, 154, 170, 172, 174, 190, 192, 194, 204, 210, 214, 230, 234, 240, 250, 254, 270, 274, 290, 294, 302, 304, 310, 312, 314, 320, 324, 340, 342, 350, 352, 354, 370, 372, 374, 390, 392, 394, 402, 410, 412, 420, 430, 432, 450, 452, 470, 472, 490, 492, 502, 504, 510, 512, 514, 520, 524, 530, 532, 534, 540, 542, 570, 572, 574, 590, 592, 594, 702, 704, 710, 712, 714, 720, 724, 730, 732, 734, 740, 742, 750, 752, 754, 790, 792, 794, 902, 904, 910, 912, 914, 920, 924, 930, 932, 934, 940, 942, 950, 952, 954, 970, 972, 974]\n assert candidate(digits = [2, 1, 3, 0]) == [102, 120, 130, 132, 210, 230, 302, 310, 312, 320]\n assert candidate(digits = [0, 2, 4, 6, 8]) == [204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 0, 0, 0]) == [100]\n assert candidate(digits = [2, 4, 6, 8]) == [246, 248, 264, 268, 284, 286, 426, 428, 462, 468, 482, 486, 624, 628, 642, 648, 682, 684, 824, 826, 842, 846, 862, 864]\n assert candidate(digits = [1, 3, 5, 7, 9]) == []\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [2, 2, 8, 8, 2]) == [222, 228, 282, 288, 822, 828, 882]\n assert candidate(digits = [3, 7, 5]) == []\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [0, 0, 0]) == []\n assert candidate(digits = [0, 2, 2, 2, 4, 4, 4, 6, 6, 6, 8, 8, 8]) == [202, 204, 206, 208, 220, 222, 224, 226, 228, 240, 242, 244, 246, 248, 260, 262, 264, 266, 268, 280, 282, 284, 286, 288, 402, 404, 406, 408, 420, 422, 424, 426, 428, 440, 442, 444, 446, 448, 460, 462, 464, 466, 468, 480, 482, 484, 486, 488, 602, 604, 606, 608, 620, 622, 624, 626, 628, 640, 642, 644, 646, 648, 660, 662, 664, 666, 668, 680, 682, 684, 686, 688, 802, 804, 806, 808, 820, 822, 824, 826, 828, 840, 842, 844, 846, 848, 860, 862, 864, 866, 868, 880, 882, 884, 886, 888]\n assert candidate(digits = [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]) == [100, 102, 110, 112, 120, 122, 130, 132, 200, 202, 210, 212, 220, 222, 230, 232, 300, 302, 310, 312, 320, 322, 330, 332]\n assert candidate(digits = [9, 9, 9, 0, 0, 0, 1, 1, 1, 2]) == [100, 102, 110, 112, 120, 190, 192, 200, 210, 290, 900, 902, 910, 912, 920, 990, 992]\n assert candidate(digits = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [0, 0, 0, 1, 1, 1, 2, 2, 2]) == [100, 102, 110, 112, 120, 122, 200, 202, 210, 212, 220, 222]\n assert candidate(digits = [0, 0, 2, 4, 6, 8]) == [200, 204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 400, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 600, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 800, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 0]) == [990]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0]) == [200, 202, 220, 222]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 0, 0, 0, 1, 1, 1]) == [100, 110, 190, 900, 910, 990]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]) == [100, 110]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == [888]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 0]) == [550]\n assert candidate(digits = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [2, 2, 0, 0, 8, 8]) == [200, 202, 208, 220, 228, 280, 282, 288, 800, 802, 808, 820, 822, 828, 880, 882]\n assert candidate(digits = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [800, 808, 880, 888]\n assert candidate(digits = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == [112, 114, 122, 124, 132, 134, 142, 144, 212, 214, 222, 224, 232, 234, 242, 244, 312, 314, 322, 324, 332, 334, 342, 344, 412, 414, 422, 424, 432, 434, 442, 444]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0]) == [550]\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == [200, 202, 204, 206, 208, 220, 224, 226, 228, 240, 242, 244, 246, 248, 260, 262, 264, 266, 268, 280, 282, 284, 286, 288, 400, 402, 404, 406, 408, 420, 422, 424, 426, 428, 440, 442, 446, 448, 460, 462, 464, 466, 468, 480, 482, 484, 486, 488, 600, 602, 604, 606, 608, 620, 622, 624, 626, 628, 640, 642, 644, 646, 648, 660, 662, 664, 668, 680, 682, 684, 686, 688, 800, 802, 804, 806, 808, 820, 822, 824, 826, 828, 840, 842, 844, 846, 848, 860, 862, 864, 866, 868, 880, 882, 884, 886]\n assert candidate(digits = [0, 0, 1, 2, 4, 6]) == [100, 102, 104, 106, 120, 124, 126, 140, 142, 146, 160, 162, 164, 200, 204, 206, 210, 214, 216, 240, 246, 260, 264, 400, 402, 406, 410, 412, 416, 420, 426, 460, 462, 600, 602, 604, 610, 612, 614, 620, 624, 640, 642]\n assert candidate(digits = [4, 4, 4, 4, 4, 4, 4]) == [444]\n assert candidate(digits = [4, 4, 4, 4, 1, 1, 1, 1, 0, 0, 0, 0]) == [100, 104, 110, 114, 140, 144, 400, 404, 410, 414, 440, 444]\n assert candidate(digits = [0, 2, 2, 0, 4, 6, 8]) == [200, 202, 204, 206, 208, 220, 224, 226, 228, 240, 242, 246, 248, 260, 262, 264, 268, 280, 282, 284, 286, 400, 402, 406, 408, 420, 422, 426, 428, 460, 462, 468, 480, 482, 486, 600, 602, 604, 608, 620, 622, 624, 628, 640, 642, 648, 680, 682, 684, 800, 802, 804, 806, 820, 822, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [112, 122, 212, 222]\n assert candidate(digits = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [124, 126, 128, 132, 134, 136, 138, 142, 146, 148, 152, 154, 156, 158, 162, 164, 168, 172, 174, 176, 178, 182, 184, 186, 192, 194, 196, 198, 214, 216, 218, 234, 236, 238, 246, 248, 254, 256, 258, 264, 268, 274, 276, 278, 284, 286, 294, 296, 298, 312, 314, 316, 318, 324, 326, 328, 342, 346, 348, 352, 354, 356, 358, 362, 364, 368, 372, 374, 376, 378, 382, 384, 386, 392, 394, 396, 398, 412, 416, 418, 426, 428, 432, 436, 438, 452, 456, 458, 462, 468, 472, 476, 478, 482, 486, 492, 496, 498, 512, 514, 516, 518, 524, 526, 528, 532, 534, 536, 538, 542, 546, 548, 562, 564, 568, 572, 574, 576, 578, 582, 584, 586, 592, 594, 596, 598, 612, 614, 618, 624, 628, 632, 634, 638, 642, 648, 652, 654, 658, 672, 674, 678, 682, 684, 692, 694, 698, 712, 714, 716, 718, 724, 726, 728, 732, 734, 736, 738, 742, 746, 748, 752, 754, 756, 758, 762, 764, 768, 782, 784, 786, 792, 794, 796, 798, 812, 814, 816, 824, 826, 832, 834, 836, 842, 846, 852, 854, 856, 862, 864, 872, 874, 876, 892, 894, 896, 912, 914, 916, 918, 924, 926, 928, 932, 934, 936, 938, 942, 946, 948, 952, 954, 956, 958, 962, 964, 968, 972, 974, 976, 978, 982, 984, 986]\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [100, 102, 110, 112, 120, 122, 200, 202, 210, 212, 220, 222]\n assert candidate(digits = [2, 4, 6, 8, 0, 0, 0, 0, 0, 0]) == [200, 204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 400, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 600, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 800, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == [112, 114, 116, 118, 122, 124, 126, 128, 132, 134, 136, 138, 142, 144, 146, 148, 152, 154, 156, 158, 162, 164, 166, 168, 172, 174, 176, 178, 182, 184, 186, 188, 192, 194, 196, 198, 212, 214, 216, 218, 222, 224, 226, 228, 232, 234, 236, 238, 242, 244, 246, 248, 252, 254, 256, 258, 262, 264, 266, 268, 272, 274, 276, 278, 282, 284, 286, 288, 292, 294, 296, 298, 312, 314, 316, 318, 322, 324, 326, 328, 332, 334, 336, 338, 342, 344, 346, 348, 352, 354, 356, 358, 362, 364, 366, 368, 372, 374, 376, 378, 382, 384, 386, 388, 392, 394, 396, 398, 412, 414, 416, 418, 422, 424, 426, 428, 432, 434, 436, 438, 442, 444, 446, 448, 452, 454, 456, 458, 462, 464, 466, 468, 472, 474, 476, 478, 482, 484, 486, 488, 492, 494, 496, 498, 512, 514, 516, 518, 522, 524, 526, 528, 532, 534, 536, 538, 542, 544, 546, 548, 552, 554, 556, 558, 562, 564, 566, 568, 572, 574, 576, 578, 582, 584, 586, 588, 592, 594, 596, 598, 612, 614, 616, 618, 622, 624, 626, 628, 632, 634, 636, 638, 642, 644, 646, 648, 652, 654, 656, 658, 662, 664, 666, 668, 672, 674, 676, 678, 682, 684, 686, 688, 692, 694, 696, 698, 712, 714, 716, 718, 722, 724, 726, 728, 732, 734, 736, 738, 742, 744, 746, 748, 752, 754, 756, 758, 762, 764, 766, 768, 772, 774, 776, 778, 782, 784, 786, 788, 792, 794, 796, 798, 812, 814, 816, 818, 822, 824, 826, 828, 832, 834, 836, 838, 842, 844, 846, 848, 852, 854, 856, 858, 862, 864, 866, 868, 872, 874, 876, 878, 882, 884, 886, 888, 892, 894, 896, 898, 912, 914, 916, 918, 922, 924, 926, 928, 932, 934, 936, 938, 942, 944, 946, 948, 952, 954, 956, 958, 962, 964, 966, 968, 972, 974, 976, 978, 982, 984, 986, 988, 992, 994, 996, 998]\n assert candidate(digits = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 666, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == [112]\n assert candidate(digits = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == [112, 122, 132, 212, 222, 232, 312, 322, 332]\n assert candidate(digits = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [1, 0, 2, 3, 4, 5, 6, 7, 8, 9]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(digits = [5, 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222, 252, 522, 552]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == [112, 122, 212, 222]\n assert candidate(digits = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [100, 110]\n assert candidate(digits = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [118, 188, 818, 888]\n assert candidate(digits = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == [500, 550]\n assert candidate(digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0]) == [100, 102, 104, 106, 108, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2]) == [200, 202, 220, 222]\n assert candidate(digits = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == [100, 102, 104, 120, 124, 130, 132, 134, 140, 142, 150, 152, 154, 200, 204, 210, 214, 230, 234, 240, 250, 254, 300, 302, 304, 310, 312, 314, 320, 324, 340, 342, 350, 352, 354, 400, 402, 410, 412, 420, 430, 432, 450, 452, 500, 502, 504, 510, 512, 514, 520, 524, 530, 532, 534, 540, 542]\n assert candidate(digits = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == [444]\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == []\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == [112, 122, 212, 222]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == [122, 124, 126, 132, 134, 136, 142, 144, 146, 152, 154, 156, 162, 164, 166, 212, 214, 216, 224, 226, 232, 234, 236, 242, 244, 246, 252, 254, 256, 262, 264, 266, 312, 314, 316, 322, 324, 326, 332, 334, 336, 342, 344, 346, 352, 354, 356, 362, 364, 366, 412, 414, 416, 422, 424, 426, 432, 434, 436, 442, 446, 452, 454, 456, 462, 464, 466, 512, 514, 516, 522, 524, 526, 532, 534, 536, 542, 544, 546, 552, 554, 556, 562, 564, 566, 612, 614, 616, 622, 624, 626, 632, 634, 636, 642, 644, 646, 652, 654, 656, 662, 664]\n assert candidate(digits = [0, 1, 2, 2, 4, 6, 8, 8, 8, 9]) == [102, 104, 106, 108, 120, 122, 124, 126, 128, 140, 142, 146, 148, 160, 162, 164, 168, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 240, 242, 246, 248, 260, 262, 264, 268, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 402, 406, 408, 410, 412, 416, 418, 420, 422, 426, 428, 460, 462, 468, 480, 482, 486, 488, 490, 492, 496, 498, 602, 604, 608, 610, 612, 614, 618, 620, 622, 624, 628, 640, 642, 648, 680, 682, 684, 688, 690, 692, 694, 698, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 840, 842, 846, 848, 860, 862, 864, 868, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 940, 942, 946, 948, 960, 962, 964, 968, 980, 982, 984, 986, 988]\n assert candidate(digits = [2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [112, 114, 122, 124, 132, 134, 142, 144, 152, 154, 212, 214, 224, 232, 234, 242, 244, 252, 254, 312, 314, 322, 324, 332, 334, 342, 344, 352, 354, 412, 414, 422, 424, 432, 434, 442, 452, 454, 512, 514, 522, 524, 532, 534, 542, 544, 552, 554]\n assert candidate(digits = [7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == [778, 788, 878, 888]\n assert candidate(digits = [0, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == [102, 110, 112, 120, 122, 130, 132, 202, 210, 212, 220, 222, 230, 232, 302, 310, 312, 320, 322, 330, 332]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [5, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8]) == [200, 202, 204, 206, 208, 220, 222, 224, 226, 228, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 280, 282, 284, 286, 288, 400, 402, 404, 406, 408, 420, 422, 424, 426, 428, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 480, 482, 484, 486, 488, 500, 502, 504, 506, 508, 520, 522, 524, 526, 528, 540, 542, 544, 546, 548, 560, 562, 564, 566, 568, 580, 582, 584, 586, 588, 600, 602, 604, 606, 608, 620, 622, 624, 626, 628, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 666, 668, 680, 682, 684, 686, 688, 800, 802, 804, 806, 808, 820, 822, 824, 826, 828, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 880, 882, 884, 886, 888]\n", "comparison": "exact"}, "public_tests": ["[2,1,3,0]", "[2,2,8,8,2]", "[3,7,5]"], "hints": ["The range of possible answers includes all even numbers between 100 and 999 inclusive. Could you check each possible answer to see if it could be formed from the digits in the array?"], "metadata": {"canonical_parameter_names": ["digits"], "leetcode_dataset_entry_point": "Solution().findEvenNumbers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:53+00:00", "tests_total": 91, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "recursion", "sorting", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def findEvenNumbers(self, digits: list[int]) -> list[int]:", "container": "Solution", "callable": "findEvenNumbers", "parameters": [{"name": "digits", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2097, "task_id": "valid-arrangement-of-pairs", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array pairs where pairs[i] = [start_i, end_i]. An arrangement of pairs is valid if for every index i where 1 <= i < pairs.length, we have end_{i-1} == start_i.\n\nReturn any valid arrangement of pairs.\n\nNote: The inputs will be generated such that there exists a valid arrangement of pairs.\n\nExample 1:\n\nInput: pairs = [[5,1],[4,5],[11,9],[9,4]]\nOutput: [[11,9],[9,4],[4,5],[5,1]]\nExplanation:\nThis is a valid arrangement since end_{i-1} always equals start_i.\nend_0 = 9 == 9 = start_1\nend_1 = 4 == 4 = start_2\nend_2 = 5 == 5 = start_3\n\nExample 2:\n\nInput: pairs = [[1,3],[3,2],[2,1]]\nOutput: [[1,3],[3,2],[2,1]]\nExplanation:\nThis is a valid arrangement since end_{i-1} always equals start_i.\nend_0 = 3 == 3 = start_1\nend_1 = 2 == 2 = start_2\nThe arrangements [[2,1],[1,3],[3,2]] and [[3,2],[2,1],[1,3]] are also valid.\n\nExample 3:\n\nInput: pairs = [[1,2],[1,3],[2,1]]\nOutput: [[1,2],[2,1],[1,3]]\nExplanation:\nThis is a valid arrangement since end_{i-1} always equals start_i.\nend_0 = 2 == 2 = start_1\nend_1 = 1 == 1 = start_2\n\nConstraints:\n\n- 1 <= pairs.length <= 10^5\n- pairs[i].length == 2\n- 0 <= start_i, end_i <= 10^9\n- start_i != end_i\n- No two pairs are exactly the same.\n- There exists a valid arrangement of pairs.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pairs = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [[0, 1], [1, 2], [2, 3], [3, 4]]\n assert candidate(pairs = [[0, 1], [1, 2], [2, 3], [3, 0]]) == [[0, 1], [1, 2], [2, 3], [3, 0]]\n assert candidate(pairs = [[1, 2], [1, 3], [2, 1]]) == [[1, 2], [2, 1], [1, 3]]\n assert candidate(pairs = [[10, 20], [20, 30], [30, 40], [40, 50]]) == [[10, 20], [20, 30], [30, 40], [40, 50]]\n assert candidate(pairs = [[1, 3], [3, 2], [2, 1]]) == [[1, 3], [3, 2], [2, 1]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 100]]) == [[100, 200], [200, 300], [300, 100]]\n assert candidate(pairs = [[10, 20], [20, 30], [30, 40], [40, 10]]) == [[10, 20], [20, 30], [30, 40], [40, 10]]\n assert candidate(pairs = [[5, 1], [4, 5], [11, 9], [9, 4]]) == [[11, 9], [9, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 1]]) == [[1, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 1]]\n assert candidate(pairs = [[7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7]]) == [[7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5], [5, 2], [2, 4], [4, 1]]) == [[1, 3], [3, 5], [5, 2], [2, 4], [4, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5]]) == [[1, 3], [3, 5], [5, 1], [1, 2], [2, 3], [3, 4], [4, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 11], [11, 12], [12, 13], [13, 1]]) == [[1, 11], [11, 12], [12, 13], [13, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 10], [10, 11], [11, 1]]) == [[1, 10], [10, 11], [11, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]) == [[1, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5]]) == [[1, 3], [3, 5], [5, 1], [1, 2], [2, 3], [3, 4], [4, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1]]\n assert candidate(pairs = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1]]) == [[1, 5], [5, 1], [1, 4], [4, 1], [1, 3], [3, 1], [1, 2], [2, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1], [1, 60], [60, 70], [70, 80], [80, 1]]) == [[1, 60], [60, 70], [70, 80], [80, 1], [1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1]]\n assert candidate(pairs = [[5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]) == [[5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 100], [100, 400], [400, 500], [500, 100]]) == [[100, 400], [400, 500], [500, 100], [100, 200], [200, 300], [300, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [2, 7], [7, 8], [8, 9], [9, 10], [10, 2]]) == [[1, 2], [2, 7], [7, 8], [8, 9], [9, 10], [10, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]\n assert candidate(pairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 1], [1, 13], [13, 2]]) == [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 1], [1, 13], [13, 2]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 1], [1, 3], [3, 2], [2, 4], [4, 3], [3, 1], [1, 4], [4, 2], [2, 1]]) == [[1, 4], [4, 2], [2, 1], [1, 3], [3, 1], [1, 2], [2, 4], [4, 3], [3, 2], [2, 3], [3, 4], [4, 1]]\n assert candidate(pairs = [[1, 2], [3, 1], [2, 3], [4, 2], [3, 5], [5, 4], [4, 1]]) == [[3, 5], [5, 4], [4, 2], [4, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [7, 8], [8, 9], [9, 10], [10, 7]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]\n assert candidate(pairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 10], [10, 30], [30, 50], [50, 20], [20, 40], [40, 10]]) == [[10, 30], [30, 50], [50, 20], [20, 40], [40, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 10]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 10], [10, 11], [11, 1], [12, 13], [13, 14], [14, 12]]) == [[1, 10], [10, 11], [11, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 999], [999, 2], [2, 998], [998, 3], [3, 997], [997, 4], [4, 996], [996, 5], [5, 995], [995, 1]]) == [[1, 999], [999, 2], [2, 998], [998, 3], [3, 997], [997, 4], [4, 996], [996, 5], [5, 995], [995, 1]]\n assert candidate(pairs = [[1, 9], [9, 7], [7, 3], [3, 5], [5, 1], [1, 8], [8, 6], [6, 2], [2, 4], [4, 1]]) == [[1, 8], [8, 6], [6, 2], [2, 4], [4, 1], [1, 9], [9, 7], [7, 3], [3, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == [[1, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 4]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1000000, 2000000], [2000000, 3000000], [3000000, 1000000], [500000, 1000000]]) == [[500000, 1000000], [1000000, 2000000], [2000000, 3000000], [3000000, 1000000]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 7], [7, 4], [8, 9], [9, 10], [10, 8]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 4]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1000, 2000], [2000, 3000], [3000, 1000], [1000, 4000], [4000, 5000], [5000, 6000], [6000, 1000]]) == [[1000, 4000], [4000, 5000], [5000, 6000], [6000, 1000], [1000, 2000], [2000, 3000], [3000, 1000]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]\n assert candidate(pairs = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 5]]) == [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 5]]\n assert candidate(pairs = [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 6], [6, 7], [7, 8], [8, 1], [1, 9], [9, 10], [10, 1]]) == [[1, 9], [9, 10], [10, 1], [1, 6], [6, 7], [7, 8], [8, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[5, 6], [6, 5], [5, 7], [7, 5], [5, 8], [8, 5], [5, 9], [9, 5], [5, 10], [10, 5]]) == [[5, 10], [10, 5], [5, 9], [9, 5], [5, 8], [8, 5], [5, 7], [7, 5], [5, 6], [6, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 1], [1, 20], [20, 3], [3, 21], [21, 1]]) == [[1, 20], [20, 3], [3, 21], [21, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 1]]\n assert candidate(pairs = [[7, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 12], [12, 8]]) == [[7, 12], [12, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 8]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 100]]\n assert candidate(pairs = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 5]]) == [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 5]]\n assert candidate(pairs = [[7, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 9], [9, 11], [11, 8]]) == [[7, 9], [9, 11], [11, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 8]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 11], [14, 15], [15, 16], [16, 14], [17, 18], [18, 19], [19, 20], [20, 17]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 9], [9, 10], [10, 11], [11, 12], [12, 1], [1, 13], [13, 14], [14, 15], [15, 1], [1, 16], [16, 17], [17, 18], [18, 1]]) == [[1, 16], [16, 17], [17, 18], [18, 1], [1, 13], [13, 14], [14, 15], [15, 1], [1, 9], [9, 10], [10, 11], [11, 12], [12, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]\n assert candidate(pairs = [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1]]) == [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 10], [10, 2]]) == [[1, 10], [10, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 2]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100], [100, 600], [600, 700], [700, 800], [800, 900], [900, 100]]) == [[100, 600], [600, 700], [700, 800], [800, 900], [900, 100], [100, 200], [200, 300], [300, 400], [400, 500], [500, 100]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1], [60, 70], [70, 80], [80, 90], [90, 100], [100, 60]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1]]\n assert candidate(pairs = [[5, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]) == [[5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5], [5, 1], [1, 2], [2, 3], [3, 4], [4, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 4], [4, 7], [7, 1]]) == [[1, 4], [4, 5], [5, 6], [6, 4], [4, 7], [7, 8], [8, 9], [9, 7], [7, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 1]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 1]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 1]]\n assert candidate(pairs = [[1, 1000000000], [1000000000, 999999999], [999999999, 888888888], [888888888, 1]]) == [[1, 1000000000], [1000000000, 999999999], [999999999, 888888888], [888888888, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 10], [10, 11], [11, 12], [12, 1]]) == [[1, 10], [10, 11], [11, 12], [12, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 11], [14, 15], [15, 16], [16, 14], [17, 18], [18, 19], [19, 20], [20, 17], [21, 22], [22, 23], [23, 21]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [1, 4], [4, 5], [5, 1], [1, 6], [6, 7], [7, 1]]) == [[1, 6], [6, 7], [7, 1], [1, 4], [4, 5], [5, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 3]]) == [[3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 3]]\n assert candidate(pairs = [[11, 22], [22, 33], [33, 44], [44, 55], [55, 66], [66, 77], [77, 88], [88, 99], [99, 11]]) == [[11, 22], [22, 33], [33, 44], [44, 55], [55, 66], [66, 77], [77, 88], [88, 99], [99, 11]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100], [100, 300], [300, 500], [500, 200]]) == [[100, 300], [300, 500], [500, 200], [200, 300], [300, 400], [400, 500], [500, 100], [100, 200]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1], [1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1]]) == [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1], [1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 5]]) == [[1, 2], [2, 3], [3, 4], [4, 1]]\n assert candidate(pairs = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1], [1, 7], [7, 1], [1, 8], [8, 1], [1, 9], [9, 1], [1, 10], [10, 1]]) == [[1, 10], [10, 1], [1, 9], [9, 1], [1, 8], [8, 1], [1, 7], [7, 1], [1, 6], [6, 1], [1, 5], [5, 1], [1, 4], [4, 1], [1, 3], [3, 1], [1, 2], [2, 1]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 1], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 4]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 4], [4, 1]]\n assert candidate(pairs = [[123, 456], [456, 789], [789, 101], [101, 112], [112, 234], [234, 345], [345, 123]]) == [[123, 456], [456, 789], [789, 101], [101, 112], [112, 234], [234, 345], [345, 123]]\n", "comparison": "exact"}, "public_tests": ["[[5,1],[4,5],[11,9],[9,4]]", "[[1,3],[3,2],[2,1]]", "[[1,2],[1,3],[2,1]]"], "hints": ["Could you convert this into a graph problem?", "Consider the pairs as edges and each number as a node.", "We have to find an Eulerian path of this graph. Hierholzer’s algorithm can be used."], "metadata": {"canonical_parameter_names": ["pairs"], "leetcode_dataset_entry_point": "Solution().validArrangement", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:00+00:00", "tests_total": 79, "tests_dropped": 0, "flags": ["multiple_answers"], "topic_tags": ["array", "depth-first-search", "graph", "eulerian-circuit", "eulerian-path", "semi-eulerian-graph"]}, "language": "python", "interface": {"raw_signature": "def validArrangement(self, pairs: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "validArrangement", "parameters": [{"name": "pairs", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2099, "task_id": "find-subsequence-of-length-k-with-the-largest-sum", "difficulty": "Easy", "problem_description": "You are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum.\n\nReturn any such subsequence as an integer array of length k.\n\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n\nExample 1:\n\nInput: nums = [2,1,3,3], k = 2\nOutput: [3,3]\nExplanation:\nThe subsequence has the largest sum of 3 + 3 = 6.\n\nExample 2:\n\nInput: nums = [-1,-2,3,4], k = 3\nOutput: [-1,3,4]\nExplanation:\nThe subsequence has the largest sum of -1 + 3 + 4 = 6.\n\nExample 3:\n\nInput: nums = [3,4,3,3], k = 2\nOutput: [3,4]\nExplanation:\nThe subsequence has the largest sum of 3 + 4 = 7.\nAnother possible subsequence is [4, 3].\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- -10^5 <= nums[i] <= 10^5\n- 1 <= k <= nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 3, 1, 2, 4],k = 5) == [5, 3, 1, 2, 4]\n assert candidate(nums = [10, 10, 10, 10, 10],k = 3) == [10, 10, 10]\n assert candidate(nums = [0, 0, 0, 0],k = 2) == [0, 0]\n assert candidate(nums = [-1, -2, 3, 4],k = 3) == [-1, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == [3, 4, 5]\n assert candidate(nums = [5, 1, 2, 3, 4],k = 3) == [5, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == [6, 7, 8, 9, 10]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [-1, -2, -3, -4],k = 2) == [-1, -2]\n assert candidate(nums = [-1, -1, -1, -1, -1],k = 3) == [-1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500],k = 4) == [200, 300, 400, 500]\n assert candidate(nums = [1],k = 1) == [1]\n assert candidate(nums = [2, 1, 3, 3],k = 2) == [3, 3]\n assert candidate(nums = [-10, -20, -30, -40],k = 2) == [-10, -20]\n assert candidate(nums = [5, 4, 3, 2, 1],k = 4) == [5, 4, 3, 2]\n assert candidate(nums = [100000, -100000, 50000, -50000, 0],k = 2) == [100000, 50000]\n assert candidate(nums = [10, -2, 0, 5],k = 2) == [10, 5]\n assert candidate(nums = [5, 1, 2, 4, 3],k = 3) == [5, 4, 3]\n assert candidate(nums = [3, 4, 3, 3],k = 2) == [4, 3]\n assert candidate(nums = [-5, -4, -3, -2, -1],k = 2) == [-2, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10) == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 15) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],k = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == [100, 90, 80]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 7) == [50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 3) == [-1, -2, -3]\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],k = 4) == [300, 500, 700, 900]\n assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50],k = 7) == [10, 20, 30, 40, 50, -10, -20]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 7) == [-1, -2, -3, -4, -5, -6, -7]\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 6) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [100000, -50000, 100000, -50000, 100000],k = 3) == [100000, 100000, 100000]\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],k = 5) == [10, 30, 50, 70, 90]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 15) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 3) == [-1, -2, -3]\n assert candidate(nums = [100, 200, 300, 400, 500],k = 1) == [500]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50],k = 5) == [10, 20, 30, 40, 50]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],k = 7) == [70, 80, 90, 100, 110, 120, 130]\n assert candidate(nums = [-10, 100, -20, 200, -30, 300, -40, 400, -50, 500, -60, 600, -70, 700, -80, 800],k = 8) == [100, 200, 300, 400, 500, 600, 700, 800]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [10, -1, 2, 9, 3, 8, 4, 7, 5, 6],k = 5) == [10, 9, 8, 7, 6]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 15) == [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],k = 3) == [99999, 99998, 99997]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == [100, 90, 80]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 8) == [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 7) == [10, 9, 8, 7, 6, 5, 4]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == [1, 1, 1]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100],k = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, -1, 2, -3, 4, -5, 6, -7, 8, -9],k = 5) == [10, 2, 4, 6, 8]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90],k = 15) == [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == [9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 5) == [100, 200, 300, 400, 500]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 15) == [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, -1, -2, -3, -4, -5]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 4) == [-1, -2, -3, -4]\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300],k = 7) == [100, 300, 500, 700, 900, 1100, 1300]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == [6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 4) == [50, 50, 50, 50]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [60, 70, 80, 90, 100]\n assert candidate(nums = [100000, -100000, 50000, -50000, 0, 25000, -25000, 75000, -75000],k = 3) == [100000, 50000, 75000]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],k = 10) == [7, 6, 9, 8, 11, 10, 13, 12, 15, 14]\n assert candidate(nums = [-100, -200, -300, -400, -500],k = 3) == [-100, -200, -300]\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 8) == [1000, 900, 800, 700, 600, 500, 400, 300]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 5) == [1, 3, 5, 7, 9]\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 3) == [-10, -20, -30]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 10) == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 6) == [1, -1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 10) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 6) == [9, 8, 7, 6, 5, 4]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == [0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == [9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [10000, -10000, 20000, -20000, 30000, -30000, 40000, -40000],k = 4) == [10000, 20000, 30000, 40000]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 3) == [-1, -2, -3]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8, 10],k = 5) == [9, 6, 7, 8, 10]\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500],k = 10) == [300, 400, 500, 300, 400, 500, 200, 300, 400, 500]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 20) == [21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 6) == [25, 30, 35, 40, 45, 50]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110],k = 5) == [-10, -20, -30, -40, -50]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == [15, 14, 13, 12, 11, 10, 9, 8]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1],k = 10) == [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 8) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [-10, -20, -30, -40, -50, 100, 200],k = 3) == [-10, 100, 200]\n", "comparison": "exact"}, "public_tests": ["[2,1,3,3]\n2", "[-1,-2,3,4]\n3", "[3,4,3,3]\n2"], "hints": ["From a greedy perspective, what k elements should you pick?", "Could you sort the array while maintaining the index?"], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxSubsequence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:05+00:00", "tests_total": 99, "tests_dropped": 1, "flags": ["multiple_answers"], "topic_tags": ["array", "hash-table", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def maxSubsequence(self, nums: list[int], k: int) -> list[int]:", "container": "Solution", "callable": "maxSubsequence", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2100, "task_id": "find-good-days-to-rob-the-bank", "difficulty": "Medium", "problem_description": "You and a gang of thieves are planning on robbing a bank. You are given a 0-indexed integer array security, where security[i] is the number of guards on duty on the i^th day. The days are numbered starting from 0. You are also given an integer time.\n\nThe i^th day is a good day to rob the bank if:\n\n- There are at least time days before and after the i^th day,\n- The number of guards at the bank for the time days before i are non-increasing, and\n- The number of guards at the bank for the time days after i are non-decreasing.\n\nMore formally, this means day i is a good day to rob the bank if and only if security[i - time] >= security[i - time + 1] >= ... >= security[i] <= ... <= security[i + time - 1] <= security[i + time].\n\nReturn a list of all days (0-indexed) that are good days to rob the bank. The order that the days are returned in does not matter.\n\nExample 1:\n\nInput: security = [5,3,3,3,5,6,2], time = 2\nOutput: [2,3]\nExplanation:\nOn day 2, we have security[0] >= security[1] >= security[2] <= security[3] <= security[4].\nOn day 3, we have security[1] >= security[2] >= security[3] <= security[4] <= security[5].\nNo other days satisfy this condition, so days 2 and 3 are the only good days to rob the bank.\n\nExample 2:\n\nInput: security = [1,1,1,1,1], time = 0\nOutput: [0,1,2,3,4]\nExplanation:\nSince time equals 0, every day is a good day to rob the bank, so return every day.\n\nExample 3:\n\nInput: security = [1,2,3,4,5,6], time = 2\nOutput: []\nExplanation:\nNo day has 2 days before it that have a non-increasing number of guards.\nThus, no day is a good day to rob the bank, so return an empty list.\n\nConstraints:\n\n- 1 <= security.length <= 10^5\n- 0 <= security[i], time <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(security = [3, 3, 5, 5, 5, 5, 2, 2, 2, 3],time = 2) == [6, 7]\n assert candidate(security = [1, 1, 1, 1, 1],time = 0) == [0, 1, 2, 3, 4]\n assert candidate(security = [1, 2, 2, 3, 3, 4, 5, 5, 6, 6],time = 1) == [2, 4, 7]\n assert candidate(security = [6, 5, 4, 3, 2, 1],time = 2) == []\n assert candidate(security = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],time = 1) == [2, 4, 6, 8]\n assert candidate(security = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],time = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(security = [1, 2, 2, 3, 3, 4],time = 1) == [2, 4]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [1, 2, 2, 3, 3, 4, 5],time = 1) == [2, 4]\n assert candidate(security = [3, 3, 5, 5, 5, 5, 2, 2, 1, 1],time = 2) == []\n assert candidate(security = [1, 1, 1, 2, 2, 2, 3, 3, 3],time = 2) == [2, 5]\n assert candidate(security = [100, 90, 80, 70, 60, 50, 60, 70, 80, 90, 100],time = 4) == [5]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3],time = 3) == [3]\n assert candidate(security = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],time = 4) == [4, 5]\n assert candidate(security = [1],time = 0) == [0]\n assert candidate(security = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],time = 2) == []\n assert candidate(security = [3, 3, 5, 5, 5, 5, 4, 4, 4, 3],time = 3) == []\n assert candidate(security = [1, 2, 3, 4, 5, 6],time = 2) == []\n assert candidate(security = [1, 2, 3, 3, 3, 3, 2, 2, 1],time = 2) == []\n assert candidate(security = [5, 3, 3, 3, 5, 6, 2],time = 2) == [2, 3]\n assert candidate(security = [1, 2, 3, 2, 1, 0, 1, 0, 1, 2, 3],time = 1) == [5, 7]\n assert candidate(security = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],time = 2) == [5]\n assert candidate(security = [1, 2, 2, 3, 4, 5, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [6, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 3) == []\n assert candidate(security = [1, 2],time = 1) == []\n assert candidate(security = [2, 1],time = 1) == []\n assert candidate(security = [1, 3, 3, 3, 3, 2, 2, 2, 2],time = 2) == [5, 6]\n assert candidate(security = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],time = 5) == [23]\n assert candidate(security = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],time = 2) == [2, 6, 10, 14, 18, 22, 26]\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7],time = 2) == [8]\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 5) == [10]\n assert candidate(security = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],time = 3) == [11]\n assert candidate(security = [5, 3, 3, 3, 3, 5, 6, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1],time = 3) == [3, 11, 12, 13]\n assert candidate(security = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1],time = 2) == [3, 6, 9, 13, 16, 19]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5],time = 2) == []\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(security = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],time = 2) == []\n assert candidate(security = [1, 2, 3, 2, 1, 0, 1, 0, 1, 2, 3, 2, 1, 0, 1],time = 2) == []\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5],time = 2) == [8, 16]\n assert candidate(security = [7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7],time = 3) == [4, 8, 9, 10, 11, 15]\n assert candidate(security = [1, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2],time = 1) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],time = 3) == [11]\n assert candidate(security = [1, 3, 2, 2, 2, 1, 2, 2, 2, 3, 1, 1, 1],time = 1) == [2, 3, 5, 7, 8, 10, 11]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],time = 4) == [8, 9, 17]\n assert candidate(security = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],time = 2) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]\n assert candidate(security = [1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2],time = 2) == [4, 8, 12]\n assert candidate(security = [10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10],time = 4) == [12]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 4) == [4, 5]\n assert candidate(security = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],time = 5) == [10]\n assert candidate(security = [5, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4],time = 5) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],time = 6) == [10, 11, 12, 13, 14]\n assert candidate(security = [5, 3, 3, 3, 5, 6, 2, 2, 2, 1, 1, 1, 2, 2, 2],time = 3) == [9, 10, 11]\n assert candidate(security = [1, 2, 2, 1, 0, 0, 1, 1, 2, 2],time = 1) == [4, 5, 7]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],time = 4) == [19]\n assert candidate(security = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],time = 4) == [9]\n assert candidate(security = [5, 3, 3, 3, 5, 6, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 2) == [2, 3, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 5) == [5, 6, 7, 8, 9, 10, 11]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 5) == []\n assert candidate(security = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0],time = 4) == []\n assert candidate(security = [2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 2, 1, 1, 2, 2],time = 2) == [5, 6, 12, 13]\n assert candidate(security = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],time = 3) == [4]\n assert candidate(security = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],time = 2) == []\n assert candidate(security = [10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 4) == []\n assert candidate(security = [1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 10, 11, 12, 11, 12, 13],time = 4) == []\n assert candidate(security = [3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],time = 2) == [2, 5, 6, 7, 8, 9, 12]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5],time = 3) == [8, 16]\n assert candidate(security = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],time = 1) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],time = 3) == [10]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 4) == [10]\n assert candidate(security = [5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5],time = 4) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5],time = 2) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],time = 8) == [10]\n assert candidate(security = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],time = 7) == [7, 8, 9]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 4) == [10]\n assert candidate(security = [3, 2, 1, 2, 1, 0, 1, 0, 1, 2, 3, 2, 1, 2, 1, 0, 1, 0, 1, 2],time = 2) == []\n assert candidate(security = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],time = 3) == [11, 23]\n assert candidate(security = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],time = 3) == [5]\n assert candidate(security = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 1],time = 3) == []\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(security = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],time = 3) == []\n assert candidate(security = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],time = 5) == [10, 11]\n assert candidate(security = [9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 4) == [4]\n assert candidate(security = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1],time = 2) == [4, 5, 8, 9, 12, 13, 16, 17, 20, 21]\n assert candidate(security = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5],time = 2) == [2, 5, 6, 7, 8, 9, 12, 13, 14, 17, 18, 19, 22, 23, 24, 27]\n assert candidate(security = [3, 3, 5, 5, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],time = 3) == [5]\n assert candidate(security = [3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0],time = 3) == [4, 8, 12, 13]\n assert candidate(security = [1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2],time = 2) == [4, 5, 6, 10, 11, 12, 16, 17, 18]\n assert candidate(security = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11],time = 3) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 4) == [5, 20]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 7) == [19]\n assert candidate(security = [1, 2, 3, 2, 1, 2, 1, 2, 3, 4, 3, 2, 1, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],time = 3) == [5]\n assert candidate(security = [1, 3, 2, 3, 1, 2, 3, 2, 1, 2, 1, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 3, 2, 1],time = 2) == [13]\n assert candidate(security = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 5) == [5]\n assert candidate(security = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 2) == [2, 3, 4, 5, 6, 7]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 5, 5, 6, 7, 8, 9, 10],time = 3) == [5, 6, 7]\n assert candidate(security = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],time = 5) == [5, 6, 7, 8, 9, 10]\n assert candidate(security = [8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8],time = 2) == [2, 5, 6, 7, 8, 9, 12]\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46]\n assert candidate(security = [1, 3, 2, 3, 2, 1, 2, 3, 2, 1],time = 1) == [2, 5]\n assert candidate(security = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],time = 5) == []\n assert candidate(security = [1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 5, 6, 7, 8, 9],time = 2) == [5, 11]\n assert candidate(security = [8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],time = 6) == [7]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 12) == [12, 13]\n assert candidate(security = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],time = 7) == []\n assert candidate(security = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],time = 2) == [3, 4, 5, 6, 7, 8, 9]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10],time = 2) == [5]\n assert candidate(security = [5, 5, 4, 4, 4, 5, 6, 7, 8, 8],time = 2) == [2, 3, 4]\n assert candidate(security = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],time = 2) == [10, 11]\n assert candidate(security = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 3) == [4]\n assert candidate(security = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1],time = 3) == []\n assert candidate(security = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],time = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]\n assert candidate(security = [3, 3, 5, 5, 5, 5, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 1, 1, 1],time = 3) == [11]\n assert candidate(security = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3],time = 2) == [4, 8, 12]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]\n assert candidate(security = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],time = 2) == []\n assert candidate(security = [1, 3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],time = 2) == []\n assert candidate(security = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 5) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(security = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1],time = 1) == [1, 4, 5, 8, 9, 12, 13, 16, 17, 20]\n", "comparison": "exact"}, "public_tests": ["[5,3,3,3,5,6,2]\n2", "[1,1,1,1,1]\n0", "[1,2,3,4,5,6]\n2"], "hints": ["The trivial solution is to check the time days before and after each day. There are a lot of repeated operations using this solution. How could we optimize this solution?", "We can use precomputation to make the solution faster.", "Use an array to store the number of days before the i^th day that is non-increasing, and another array to store the number of days after the i^th day that is non-decreasing."], "metadata": {"canonical_parameter_names": ["security", "time"], "leetcode_dataset_entry_point": "Solution().goodDaysToRobBank", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:07+00:00", "tests_total": 123, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def goodDaysToRobBank(self, security: list[int], time: int) -> list[int]:", "container": "Solution", "callable": "goodDaysToRobBank", "parameters": [{"name": "security", "type": "list[int]"}, {"name": "time", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2101, "task_id": "detonate-the-maximum-bombs", "difficulty": "Medium", "problem_description": "You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb.\n\nThe bombs are represented by a 0-indexed 2D integer array bombs where bombs[i] = [x_i, y_i, r_i]. x_i and y_i denote the X-coordinate and Y-coordinate of the location of the i^th bomb, whereas r_i denotes the radius of its range.\n\nYou may choose to detonate a single bomb. When a bomb is detonated, it will detonate all bombs that lie in its range. These bombs will further detonate the bombs that lie in their ranges.\n\nGiven the list of bombs, return the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb.\n\nExample 1:\n\nInput: bombs = [[2,1,3],[6,1,4]]\nOutput: 2\nExplanation:\nThe above figure shows the positions and ranges of the 2 bombs.\nIf we detonate the left bomb, the right bomb will not be affected.\nBut if we detonate the right bomb, both bombs will be detonated.\nSo the maximum bombs that can be detonated is max(1, 2) = 2.\n\nExample 2:\n\nInput: bombs = [[1,1,5],[10,10,5]]\nOutput: 1\nExplanation:\nDetonating either bomb will not detonate the other bomb, so the maximum number of bombs that can be detonated is 1.\n\nExample 3:\n\nInput: bombs = [[1,2,3],[2,3,1],[3,4,2],[4,5,3],[5,6,4]]\nOutput: 5\nExplanation:\nThe best bomb to detonate is bomb 0 because:\n- Bomb 0 detonates bombs 1 and 2. The red circle denotes the range of bomb 0.\n- Bomb 2 detonates bomb 3. The blue circle denotes the range of bomb 2.\n- Bomb 3 detonates bomb 4. The green circle denotes the range of bomb 3.\nThus all 5 bombs are detonated.\n\nConstraints:\n\n- 1 <= bombs.length <= 100\n- bombs[i].length == 3\n- 1 <= x_i, y_i, r_i <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5]]) == 1\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1]]) == 1\n assert candidate(bombs = [[1, 1, 100], [1, 1, 50], [1, 1, 25]]) == 3\n assert candidate(bombs = [[1, 1, 10], [10, 10, 10], [5, 5, 5]]) == 2\n assert candidate(bombs = [[1, 1, 10], [10, 10, 1], [5, 5, 5]]) == 2\n assert candidate(bombs = [[1, 1, 5], [10, 10, 5]]) == 1\n assert candidate(bombs = [[1, 2, 3], [2, 3, 1], [3, 4, 2], [4, 5, 3], [5, 6, 4]]) == 5\n assert candidate(bombs = [[5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1]]) == 1\n assert candidate(bombs = [[100, 100, 1], [101, 101, 1], [102, 102, 1]]) == 1\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2]]) == 4\n assert candidate(bombs = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 3\n assert candidate(bombs = [[2, 1, 3], [6, 1, 4]]) == 2\n assert candidate(bombs = [[1, 1, 3], [2, 2, 3], [3, 3, 3], [4, 4, 3]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1]]) == 1\n assert candidate(bombs = [[5, 5, 3], [6, 6, 1], [7, 7, 4]]) == 3\n assert candidate(bombs = [[5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8]]) == 4\n assert candidate(bombs = [[10, 10, 10], [20, 20, 10], [30, 30, 10]]) == 1\n assert candidate(bombs = [[10, 10, 1], [20, 10, 1], [30, 10, 1], [40, 10, 1], [50, 10, 1], [60, 10, 1], [70, 10, 1], [80, 10, 1], [90, 10, 1], [100, 10, 1]]) == 1\n assert candidate(bombs = [[100, 100, 10], [100, 110, 10], [100, 120, 10], [110, 100, 10], [110, 110, 10], [110, 120, 10], [120, 100, 10], [120, 110, 10], [120, 120, 10]]) == 9\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5]]) == 1\n assert candidate(bombs = [[50, 50, 10], [60, 60, 20], [70, 70, 30], [80, 80, 40], [90, 90, 50]]) == 5\n assert candidate(bombs = [[10, 10, 3], [10, 13, 3], [13, 10, 3], [13, 13, 3], [16, 16, 3], [16, 19, 3], [19, 16, 3], [19, 19, 3]]) == 4\n assert candidate(bombs = [[1, 1, 10], [1, 10, 10], [10, 1, 10], [10, 10, 10], [15, 15, 15], [15, 5, 15], [5, 15, 15], [20, 20, 5]]) == 8\n assert candidate(bombs = [[50, 50, 5], [55, 50, 5], [60, 50, 5], [65, 50, 5], [70, 50, 5], [75, 50, 5], [80, 50, 5], [85, 50, 5], [90, 50, 5], [95, 50, 5], [100, 50, 5], [105, 50, 5], [110, 50, 5], [115, 50, 5], [120, 50, 5], [125, 50, 5], [130, 50, 5], [135, 50, 5], [140, 50, 5], [145, 50, 5]]) == 20\n assert candidate(bombs = [[100, 100, 10], [110, 100, 10], [120, 100, 10], [130, 100, 10], [140, 100, 10], [150, 100, 10], [160, 100, 10], [170, 100, 10], [180, 100, 10]]) == 9\n assert candidate(bombs = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1]]) == 1\n assert candidate(bombs = [[50, 50, 5], [60, 50, 5], [70, 50, 5], [80, 50, 5], [50, 60, 5], [50, 70, 5], [50, 80, 5], [50, 90, 5], [50, 100, 5], [60, 60, 15]]) == 6\n assert candidate(bombs = [[100, 100, 50], [200, 100, 50], [100, 200, 50], [200, 200, 50], [150, 150, 100]]) == 5\n assert candidate(bombs = [[10, 10, 1], [20, 20, 1], [30, 30, 1], [40, 40, 1], [50, 50, 1], [60, 60, 1], [70, 70, 1], [80, 80, 1], [90, 90, 1], [100, 100, 100]]) == 8\n assert candidate(bombs = [[5, 5, 5], [5, 15, 5], [15, 5, 5], [15, 15, 5], [10, 10, 20]]) == 5\n assert candidate(bombs = [[1, 1, 5], [2, 2, 10], [3, 3, 2], [4, 4, 8], [5, 5, 1]]) == 5\n assert candidate(bombs = [[1, 1, 100], [1, 1, 100], [1, 1, 100], [1, 1, 100], [1, 1, 100]]) == 5\n assert candidate(bombs = [[50, 50, 15], [60, 50, 20], [70, 50, 10], [50, 60, 25], [50, 70, 12], [50, 80, 5]]) == 6\n assert candidate(bombs = [[1, 1, 10], [10, 1, 10], [1, 10, 10], [10, 10, 10], [5, 5, 5], [15, 15, 15]]) == 6\n assert candidate(bombs = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9], [1, 10, 10]]) == 10\n assert candidate(bombs = [[1, 1, 10], [20, 20, 10], [30, 30, 10], [40, 40, 10], [50, 50, 10], [60, 60, 10]]) == 1\n assert candidate(bombs = [[100, 100, 50], [200, 200, 50], [300, 300, 50], [100, 200, 60], [200, 300, 70]]) == 1\n assert candidate(bombs = [[10, 10, 1], [15, 15, 2], [20, 20, 3], [25, 25, 4], [30, 30, 5]]) == 1\n assert candidate(bombs = [[5, 5, 1], [5, 6, 1], [5, 7, 1], [5, 8, 1], [5, 9, 1]]) == 5\n assert candidate(bombs = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40], [5, 5, 50], [6, 6, 60]]) == 6\n assert candidate(bombs = [[5, 5, 20], [10, 5, 20], [15, 5, 20], [20, 5, 20], [25, 5, 20], [30, 5, 20], [35, 5, 20], [40, 5, 20], [45, 5, 20], [50, 5, 20]]) == 10\n assert candidate(bombs = [[1, 1, 100], [200, 200, 100], [400, 400, 100], [600, 600, 100], [800, 800, 100], [1000, 1000, 100], [1200, 1200, 100], [1400, 1400, 100], [1600, 1600, 100], [1800, 1800, 100]]) == 1\n assert candidate(bombs = [[10, 10, 15], [20, 20, 15], [30, 30, 15], [40, 40, 15], [50, 50, 15], [60, 60, 15], [70, 70, 15], [80, 80, 15], [90, 90, 15]]) == 9\n assert candidate(bombs = [[10, 10, 15], [20, 20, 15], [30, 30, 15], [40, 40, 15], [50, 50, 15], [60, 60, 15], [70, 70, 15]]) == 7\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]]) == 10\n assert candidate(bombs = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]]) == 8\n assert candidate(bombs = [[100, 100, 100], [200, 100, 100], [300, 100, 100], [400, 100, 100], [500, 100, 100], [600, 100, 100], [700, 100, 100], [800, 100, 100], [900, 100, 100]]) == 9\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1]]) == 1\n assert candidate(bombs = [[10, 10, 5], [15, 10, 5], [20, 10, 5], [25, 10, 5], [30, 10, 5], [35, 10, 5], [40, 10, 5], [45, 10, 5]]) == 8\n assert candidate(bombs = [[1, 1, 100], [1, 101, 100], [101, 101, 100], [101, 1, 100], [51, 51, 100], [51, 1, 100], [1, 51, 100], [101, 51, 100], [51, 101, 100]]) == 9\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2], [5, 5, 2], [6, 6, 2]]) == 6\n assert candidate(bombs = [[10, 10, 20], [30, 30, 20], [50, 50, 20], [70, 70, 20], [90, 90, 20], [110, 110, 20], [130, 130, 20], [150, 150, 20], [170, 170, 20], [190, 190, 20], [210, 210, 20], [230, 230, 20], [250, 250, 20], [270, 270, 20], [290, 290, 20]]) == 1\n assert candidate(bombs = [[5, 5, 2], [10, 5, 2], [15, 5, 2], [20, 5, 2], [25, 5, 2], [30, 5, 2], [35, 5, 2], [40, 5, 2], [45, 5, 2], [50, 5, 2], [55, 5, 2]]) == 1\n assert candidate(bombs = [[10, 10, 15], [20, 20, 25], [30, 30, 35], [40, 40, 45], [50, 50, 55]]) == 5\n assert candidate(bombs = [[100, 100, 100], [200, 200, 50], [300, 300, 25], [400, 400, 12.5]]) == 1\n assert candidate(bombs = [[5, 5, 10], [15, 5, 10], [5, 15, 10], [15, 15, 10], [10, 10, 5]]) == 5\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2], [5, 5, 2], [6, 6, 2], [7, 7, 2], [8, 8, 2], [9, 9, 2]]) == 9\n assert candidate(bombs = [[10, 10, 25], [15, 10, 15], [10, 15, 20], [5, 10, 10], [10, 5, 15]]) == 5\n assert candidate(bombs = [[1, 1, 3], [4, 4, 3], [7, 1, 3], [4, 7, 3], [10, 10, 3]]) == 2\n assert candidate(bombs = [[1, 1, 5], [1, 6, 5], [6, 1, 5], [6, 6, 5], [3, 3, 1]]) == 5\n assert candidate(bombs = [[1, 1, 1000], [2, 2, 1000], [3, 3, 1000], [4, 4, 1000], [5, 5, 1000], [6, 6, 1000], [7, 7, 1000], [8, 8, 1000]]) == 8\n assert candidate(bombs = [[100, 100, 50], [150, 100, 50], [200, 100, 50], [250, 100, 50], [300, 100, 50], [350, 100, 50], [400, 100, 50], [450, 100, 50]]) == 8\n assert candidate(bombs = [[10, 10, 5], [15, 10, 5], [10, 15, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13], [14, 14, 14], [15, 15, 15]]) == 15\n assert candidate(bombs = [[5, 5, 5], [10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5]]) == 1\n assert candidate(bombs = [[50, 50, 50], [60, 60, 50], [70, 70, 50], [80, 80, 50], [90, 90, 50], [100, 100, 50]]) == 6\n assert candidate(bombs = [[50, 50, 50], [100, 100, 50], [150, 150, 50], [200, 200, 50], [250, 250, 50], [300, 300, 50], [350, 350, 50], [400, 400, 50], [450, 450, 50]]) == 1\n assert candidate(bombs = [[10, 10, 5], [15, 15, 3], [20, 20, 4], [25, 25, 2], [30, 30, 6]]) == 1\n assert candidate(bombs = [[10, 10, 15], [15, 15, 15], [20, 20, 15], [25, 25, 15], [30, 30, 15]]) == 5\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5]]) == 1\n assert candidate(bombs = [[1, 1, 100], [101, 101, 100], [201, 201, 100], [301, 301, 100], [401, 401, 100]]) == 1\n assert candidate(bombs = [[5, 5, 3], [7, 5, 3], [9, 5, 3], [11, 5, 3], [13, 5, 3]]) == 5\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5], [5, 5, 5], [6, 6, 5], [7, 7, 5], [8, 8, 5], [9, 9, 5]]) == 9\n assert candidate(bombs = [[10000, 10000, 5000], [15000, 10000, 10000], [20000, 10000, 3000], [10000, 20000, 6000], [25000, 25000, 8000]]) == 3\n assert candidate(bombs = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9]]) == 9\n assert candidate(bombs = [[1000, 1000, 1000], [2000, 2000, 500], [3000, 3000, 250], [4000, 4000, 125]]) == 1\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]]) == 5\n assert candidate(bombs = [[10, 10, 50], [20, 20, 40], [30, 30, 30], [40, 40, 20], [50, 50, 10]]) == 5\n assert candidate(bombs = [[5, 5, 10], [10, 10, 10], [15, 15, 10], [20, 20, 10], [25, 25, 10], [30, 30, 10], [35, 35, 10]]) == 7\n assert candidate(bombs = [[10, 10, 10], [20, 20, 10], [30, 30, 10], [40, 40, 10], [50, 50, 10], [60, 60, 10], [70, 70, 10], [80, 80, 10], [90, 90, 10], [100, 100, 10], [110, 110, 10], [120, 120, 10], [130, 130, 10], [140, 140, 10], [150, 150, 10]]) == 1\n assert candidate(bombs = [[1, 1, 10], [10, 1, 5], [10, 10, 15], [20, 20, 10]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]]) == 7\n assert candidate(bombs = [[1, 1, 10], [10, 1, 5], [1, 10, 5], [5, 5, 2], [7, 7, 7]]) == 5\n assert candidate(bombs = [[1, 1, 10000], [2, 2, 10000], [3, 3, 10000], [4, 4, 10000], [5, 5, 10000], [6, 6, 10000], [7, 7, 10000], [8, 8, 10000], [9, 9, 10000], [10, 10, 10000]]) == 10\n assert candidate(bombs = [[10, 10, 1], [11, 11, 2], [12, 12, 3], [13, 13, 4], [14, 14, 5], [15, 15, 6], [16, 16, 7], [17, 17, 8], [18, 18, 9], [19, 19, 10]]) == 10\n assert candidate(bombs = [[1, 1, 10], [11, 1, 10], [21, 1, 10], [1, 11, 10], [11, 11, 10], [21, 11, 10], [1, 21, 10], [11, 21, 10], [21, 21, 10]]) == 9\n assert candidate(bombs = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 5\n assert candidate(bombs = [[1, 1, 10], [2, 1, 10], [3, 1, 10], [4, 1, 10], [5, 1, 10], [6, 1, 10], [7, 1, 10], [8, 1, 10], [9, 1, 10], [10, 1, 10]]) == 10\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5], [5, 5, 5], [6, 6, 5], [7, 7, 5], [8, 8, 5], [9, 9, 5], [10, 10, 5], [11, 11, 5], [12, 12, 5], [13, 13, 5], [14, 14, 5], [15, 15, 5]]) == 15\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]]) == 9\n assert candidate(bombs = [[5, 5, 5], [10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5], [45, 45, 5], [50, 50, 5]]) == 1\n assert candidate(bombs = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5], [50, 50, 5], [60, 60, 5], [70, 70, 5], [80, 80, 5], [90, 90, 5], [100, 100, 5], [110, 110, 5], [120, 120, 5], [130, 130, 5], [140, 140, 5], [150, 150, 5]]) == 1\n assert candidate(bombs = [[10, 10, 3], [12, 12, 2], [15, 15, 1], [18, 18, 4], [20, 20, 5]]) == 2\n assert candidate(bombs = [[10, 10, 5], [15, 10, 10], [20, 10, 3], [10, 20, 6], [25, 25, 8]]) == 3\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13]]) == 13\n assert candidate(bombs = [[100, 100, 50], [200, 200, 50], [300, 300, 50], [250, 250, 100]]) == 3\n assert candidate(bombs = [[1, 1, 5], [5, 1, 5], [9, 1, 5], [13, 1, 5]]) == 4\n", "comparison": "exact"}, "public_tests": ["[[2,1,3],[6,1,4]]", "[[1,1,5],[10,10,5]]", "[[1,2,3],[2,3,1],[3,4,2],[4,5,3],[5,6,4]]"], "hints": ["How can we model the relationship between different bombs? Can \"graphs\" help us?", "Bombs are nodes and are connected to other bombs in their range by directed edges.", "If we know which bombs will be affected when any bomb is detonated, how can we find the total number of bombs that will be detonated if we start from a fixed bomb?", "Run a Depth First Search (DFS) from every node, and all the nodes it reaches are the bombs that will be detonated."], "metadata": {"canonical_parameter_names": ["bombs"], "leetcode_dataset_entry_point": "Solution().maximumDetonation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:09+00:00", "tests_total": 115, "tests_dropped": 17, "flags": ["has_images"], "topic_tags": ["array", "math", "depth-first-search", "breadth-first-search", "graph", "geometry"]}, "language": "python", "interface": {"raw_signature": "def maximumDetonation(self, bombs: list[list[int]]) -> int:", "container": "Solution", "callable": "maximumDetonation", "parameters": [{"name": "bombs", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2103, "task_id": "rings-and-rods", "difficulty": "Easy", "problem_description": "There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9.\n\nYou are given a string rings of length 2n that describes the n rings that are placed onto the rods. Every two characters in rings forms a color-position pair that is used to describe each ring where:\n\n- The first character of the i^th pair denotes the i^th ring's color ('R', 'G', 'B').\n- The second character of the i^th pair denotes the rod that the i^th ring is placed on ('0' to '9').\n\nFor example, \"R3G2B1\" describes n == 3 rings: a red ring placed onto the rod labeled 3, a green ring placed onto the rod labeled 2, and a blue ring placed onto the rod labeled 1.\n\nReturn the number of rods that have all three colors of rings on them.\n\nExample 1:\n\nInput: rings = \"B0B6G0R6R0R6G9\"\nOutput: 1\nExplanation:\n- The rod labeled 0 holds 3 rings with all colors: red, green, and blue.\n- The rod labeled 6 holds 3 rings, but it only has red and blue.\n- The rod labeled 9 holds only a green ring.\nThus, the number of rods with all three colors is 1.\n\nExample 2:\n\nInput: rings = \"B0R0G0R9R0B0G0\"\nOutput: 1\nExplanation:\n- The rod labeled 0 holds 6 rings with all colors: red, green, and blue.\n- The rod labeled 9 holds only a red ring.\nThus, the number of rods with all three colors is 1.\n\nExample 3:\n\nInput: rings = \"G4\"\nOutput: 0\nExplanation:\nOnly one ring is given. Thus, no rods have all three colors.\n\nConstraints:\n\n- rings.length == 2 * n\n- 1 <= n <= 100\n- rings[i] where i is even is either 'R', 'G', or 'B' (0-indexed).\n- rings[i] where i is odd is a digit from '0' to '9' (0-indexed).\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2\") == 3\n assert candidate(rings = \"R9G9B9R9G9B9R9G9B9\") == 1\n assert candidate(rings = \"G4\") == 0\n assert candidate(rings = \"R0G0R0G0R0G0\") == 0\n assert candidate(rings = \"G0G1G2G3G4G5G6G7G8G9\") == 0\n assert candidate(rings = \"B0B1B2B3B4B5B6B7B8B9\") == 0\n assert candidate(rings = \"G1G2G3G4G5G6G7G8G9G0\") == 0\n assert candidate(rings = \"R1R2R3R4R5R6R7R8R9R0\") == 0\n assert candidate(rings = \"B0B6G0R6R0R6G9\") == 1\n assert candidate(rings = \"R9G9B9\") == 1\n assert candidate(rings = \"B1B2B3B4B5B6B7B8B9B0\") == 0\n assert candidate(rings = \"R0R0G0G0B0B0R1R1G1G1B1B1\") == 2\n assert candidate(rings = \"B0R0G0R9R0B0G0\") == 1\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9\") == 0\n assert candidate(rings = \"R1R1R1G1G1G1B1B1B1\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0R1R2R3R4R5R6R7R8R9\") == 0\n assert candidate(rings = \"R9G9B9R9G9B9\") == 1\n assert candidate(rings = \"R0G0B0R1G0B0R2G0B0R3G0B0R4G0B0R5G0B0R6G0B0R7G0B0R8G0B0R9G0B0\") == 1\n assert candidate(rings = \"R5G5B5R5G5B5R5G5B5\") == 1\n assert candidate(rings = \"R1G1B1R2G2B2R3G3B3\") == 3\n assert candidate(rings = \"B9B9B9G9G9G9R9R9R9\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R1G1B1R2G2B2\") == 2\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R2G2B2R4G4B4R6G6B6R8G8B8\") == 5\n assert candidate(rings = \"R9G9B9R8G8B8R7G7B7\") == 3\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1R2G2B2R2G2B2R2G2B2R2G2B2\") == 3\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G2B3R4G5B6R7G8B9\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G2B3R4G5B6R7G8B9R0G1B2R3G4B5\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R0G0B0R1G1B1R2G2B2R3G3B3R0G0B0\") == 4\n assert candidate(rings = \"R0R0G0G0B0B0R1R1G1G1B1B1R2R2G2G2B2B2R3R3G3G3B3B3R4R4G4G4B4B4R5R5G5G5B5B5\") == 6\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G0B1R2G0B2R3G0B3R4G0B4R5G0B5R6G0B6R7G0B7R8G0B8R9G0B9R0G0B0R1G0B1R2G0B2R3G0B3R4G0B4R5G0B5R6G0B6R7G0B7R8G0B8R9G0B9\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R1G1B1\") == 10\n assert candidate(rings = \"R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1\") == 10\n assert candidate(rings = \"R0R0R0R0R0R0R0R0R0R0G0G0G0G0G0G0G0G0G0G0G0G0B0B0B0B0B0B0B0B0B0B0\") == 1\n assert candidate(rings = \"R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2\") == 0\n assert candidate(rings = \"R0G0B0R0G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 9\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0\") == 10\n assert candidate(rings = \"R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3\") == 0\n assert candidate(rings = \"R0G0B0R1G0B0R2G0B0R3G0B0R4G0B0R5G0B0R6G0B0R7G0B0R8G0B0R9G0B0R0G0B0R1G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R9G9B9R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R0G0B0R0G0B0\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G1B1R2G2B2R3G3B3\") == 4\n assert candidate(rings = \"R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3\") == 0\n assert candidate(rings = \"R9G9B9R8G8B8R7G7B7R6G6B6R5G5B5R4G4B4R3G3B3R2G2B2R1G1B1R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R2G2B2R2G2B2R2G2B2R3G3B3\") == 4\n assert candidate(rings = \"R0R0R0R0R0R1R1R1R1R1R2R2R2R2R2R3R3R3R3R3R4R4R4R4R4R5R5R5R5R5R6R6R6R6R6R7R7R7R7R7R8R8R8R8R8R9R9R9R9R9\") == 0\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0G0B0R1G1B1R1G1B2G2B2R2G2B3G3B3R3G3B4G4B4R4G4B5G5B5R5G5B6G6B6R6G6B7G7B7R7G7B8G8B8R8G8B9G9B9R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R8G8B8\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1\") == 2\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1\") == 2\n assert candidate(rings = \"R9G8B7R6G5B4R3G2B1R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5\") == 6\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R7G7B7R7G7B7R7G7B7\") == 10\n assert candidate(rings = \"R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2\") == 0\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R9G9B9R8G8B8R7G7B7R6G6B6R5G5B5R4G4B4R3G3B3R2G2B2R1G1B1R0G0B0\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G2B3R4G5B6R7G8B9R0G1B2R3G4B5R6G7B8R9G0\") == 10\n assert candidate(rings = \"R0B0G1R1B1G2R2B2G3R3B3G4R4B4G5R5B5G6R6B6G7R7B7G8R8B8G9R9B9\") == 9\n assert candidate(rings = \"R0G0B0G0B0R0B0G0R0R0G0B0R0G0B0R0R0G0R0G0B0R0B0G0R0G0R0B0G0R0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0\") == 0\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R6G6B6R6G6B6R6G6B6R6G6B6\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4\") == 10\n assert candidate(rings = \"R0R0R0G0G0G0B0B0B0R1R1R1G1G1G1B1B1B1R2R2R2G2G2G2B2B2B2\") == 3\n assert candidate(rings = \"R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0R0R0R0R0R0R0R0R0R0G0G0G0G0G0G0G0G0G0G0G0B0B0B0B0B0B0B0B0B0B0B0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4\") == 10\n assert candidate(rings = \"R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2\") == 0\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1\") == 2\n assert candidate(rings = \"G0B0R0G1B1R1G2B2R2G3B3R3G4B4R4G5B5R5G6B6R6G7B7R7G8B8R8G9B9R9G0B0R0G1B1R1G2B2R2G3B3R3G4B4R4G5B5R5G6B6R6G7B7R7G8B8R8G9B9R9\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0\") == 1\n assert candidate(rings = \"B9G9R9B8G8R8B7G7R7B6G6R6B5G5R5B4G4R4B3G3R3B2G2R2B1G1R1B0G0R0B9G9R9B8G8R8B7G7R7B6G6R6B5G5R5B4G4R4B3G3R3B2G2R2B1G1R1B0G0R0\") == 10\n assert candidate(rings = \"R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0\") == 10\n assert candidate(rings = \"B0G0B0G0B0R1G1R1G1R1B2G2B2G2G2R3G3R3G3G3B4G4B4G4G4R5G5R5G5G5B6G6B6G6G6R7G7R7G7G7B8G8B8G8G8R9G9R9G9G9B9G9B9G9G9\") == 1\n assert candidate(rings = \"G0B0R0G1B1R1G2B2R2G3B3R3G4B4R4G5B5R5G6B6R6G7B7R7G8B8R8G9B9R9G0B1R2G3B4R5G6B7R8G9B0\") == 10\n assert candidate(rings = \"R0G0B0R0G1B1R0G2B2R0G3B3R0G4B4R0G5B5R0G6B6R0G7B7R0G8B8R0G9B9\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0\") == 10\n assert candidate(rings = \"R0B1G2R3B4G5R6B7G8R9B0G1R2B3G4R5B6G7R8B9G0R1B2G3R4B5G6R7B8G9\") == 10\n assert candidate(rings = \"B9G8R7B6G5R4B3G2R1B0G9R8B7G6R5B4G3R2B1G0R9B8G7R6B5G4R3B2G1R0\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n", "comparison": "exact"}, "public_tests": ["\"B0B6G0R6R0R6G9\"", "\"B0R0G0R9R0B0G0\"", "\"G4\""], "hints": ["For every rod, look through ‘rings’ to see if the rod contains all colors.", "Create 3 booleans, 1 for each color, to store if that color is present for the current rod. If all 3 are true after looking through the string, then the rod contains all the colors."], "metadata": {"canonical_parameter_names": ["rings"], "leetcode_dataset_entry_point": "Solution().countPoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:12+00:00", "tests_total": 99, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def countPoints(self, rings: str) -> int:", "container": "Solution", "callable": "countPoints", "parameters": [{"name": "rings", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2104, "task_id": "sum-of-subarray-ranges", "difficulty": "Medium", "problem_description": "You are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the subarray.\n\nReturn the sum of all subarray ranges of nums.\n\nA subarray is a contiguous non-empty sequence of elements within an array.\n\nExample 1:\n\nInput: nums = [1,2,3]\nOutput: 4\nExplanation: The 6 subarrays of nums are the following:\n[1], range = largest - smallest = 1 - 1 = 0\n[2], range = 2 - 2 = 0\n[3], range = 3 - 3 = 0\n[1,2], range = 2 - 1 = 1\n[2,3], range = 3 - 2 = 1\n[1,2,3], range = 3 - 1 = 2\nSo the sum of all ranges is 0 + 0 + 0 + 1 + 1 + 2 = 4.\n\nExample 2:\n\nInput: nums = [1,3,3]\nOutput: 4\nExplanation: The 6 subarrays of nums are the following:\n[1], range = largest - smallest = 1 - 1 = 0\n[3], range = 3 - 3 = 0\n[3], range = 3 - 3 = 0\n[1,3], range = 3 - 1 = 2\n[3,3], range = 3 - 3 = 0\n[1,3,3], range = 3 - 1 = 2\nSo the sum of all ranges is 0 + 0 + 0 + 2 + 0 + 2 = 4.\n\nExample 3:\n\nInput: nums = [4,-2,-3,4,1]\nOutput: 59\nExplanation: The sum of all subarray ranges of nums is 59.\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- -10^9 <= nums[i] <= 10^9\n\nFollow-up: Could you find a solution with O(n) time complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, -2, -3, -4]) == 10\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 165\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 165\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 30\n assert candidate(nums = [4, -2, -3, 4, 1]) == 59\n assert candidate(nums = [3, 2, 2, 2, 1]) == 8\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 20000000000\n assert candidate(nums = [10, 20, 30, 40, 50]) == 200\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 20\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 20\n assert candidate(nums = [100, 100, 100, 100]) == 0\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == 12000000000\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == 700\n assert candidate(nums = [10, 20, 30, 40, 50]) == 200\n assert candidate(nums = [1, 2, 2, 2, 3]) == 8\n assert candidate(nums = [5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [-10, -20, -30, -40, -50]) == 200\n assert candidate(nums = [1, 3, 3]) == 4\n assert candidate(nums = [1, 2, 3]) == 4\n assert candidate(nums = [-10, 100, -20, 200, -30, 300]) == 3580\n assert candidate(nums = [5]) == 0\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == 66\n assert candidate(nums = [-1, 4, -2, 3, -3]) == 60\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 45\n assert candidate(nums = [1, 0, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 384\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 16500\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 64\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50]) == 2400\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 190\n assert candidate(nums = [10, 20, 30, 25, 15, 10, 5, 2, 1, 0]) == 743\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 105\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 560\n assert candidate(nums = [5, 3, 8, 1, 4]) == 57\n assert candidate(nums = [10, 20, 30, 25, 15, 5]) == 240\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4]) == 168\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == 12000000000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 330\n assert candidate(nums = [5, 1, 4, 2, 8, 3]) == 77\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == 60\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 1540\n assert candidate(nums = [100, 200, 300, 400, 500, -500, -400, -300, -200, -100]) == 29000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 560\n assert candidate(nums = [100, 200, 300, 400, 500]) == 2000\n assert candidate(nums = [10, 20, 30, 40, 50, -50, -40, -30, -20, -10]) == 2900\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 20000000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 635\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == 36000\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1540\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 40\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 10, 1, 0, 1, 10, 100]) == 1149\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == 66\n assert candidate(nums = [9, -8, 7, -6, 5, -4, 3, -2, 1]) == 444\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 330\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 80\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1]) == 28\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 480\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 1655\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 240\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40]) == 1680\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10]) == 210\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 45\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000, -250000000]) == 21000000000\n assert candidate(nums = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 5600\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1650\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 330\n assert candidate(nums = [5, 8, 6, 7, 9, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1736\n assert candidate(nums = [9, 7, 5, 3, 1]) == 40\n assert candidate(nums = [5, 8, 3, 7, 9, 1]) == 87\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0]) == 22000\n assert candidate(nums = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10]) == 180\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 20\n assert candidate(nums = [10, -5, 3, 7, -2, 8]) == 172\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1]) == 42\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 165\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 330\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [-1, -5, -9, -3, -6]) == 59\n assert candidate(nums = [100, 200, 300, 400, 500, 600]) == 3500\n assert candidate(nums = [1, 5, 3, 7, 9, 2, 6, 8, 4, 10]) == 283\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 560\n assert candidate(nums = [5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 165\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5]) == 240\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 1650\n assert candidate(nums = [5, 2, 9, 1, 5, 6]) == 99\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 328\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 651\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1540\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 285\n assert candidate(nums = [100, -100, 200, -200, 300]) == 4000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 8550\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 235\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 6150\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1000000000, 1000000000, -1000000000, -1000000000]) == 8000000000\n assert candidate(nums = [-1, 2, -3, 4, -5]) == 70\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000]) == 15250000000\n assert candidate(nums = [100, -200, 300, -400, 500]) == 7000\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 220\n assert candidate(nums = [5, 3, 1, 2, 4]) == 27\n assert candidate(nums = [5, 2, 3, 1, 4, 6, 8, 7, 9, 0]) == 244\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2660\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 45\n assert candidate(nums = [5, 3, 8, 1, 4]) == 57\n assert candidate(nums = [5, 2, 4, 6, 1, 3]) == 60\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1]) == 56\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 330\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1650\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 90\n assert candidate(nums = [5, 3, 8, 2, 7]) == 53\n assert candidate(nums = [5, 1, 4, 3, 2]) == 29\n assert candidate(nums = [1, 2, 3, -1, -2, -3, 4, 5, 6]) == 201\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 2135\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 1650\n assert candidate(nums = [1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 3]) == 392\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 165000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 5600\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7]) == 560\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1540\n", "comparison": "exact"}, "public_tests": ["[1,2,3]", "[1,3,3]", "[4,-2,-3,4,1]"], "hints": ["Can you get the max/min of a certain subarray by using the max/min of a smaller subarray within it?", "Notice that the max of the subarray from index i to j is equal to max of (max of the subarray from index i to j-1) and nums[j]."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().subArrayRanges", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:14+00:00", "tests_total": 127, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "stack", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def subArrayRanges(self, nums: list[int]) -> int:", "container": "Solution", "callable": "subArrayRanges", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2105, "task_id": "watering-plants-ii", "difficulty": "Medium", "problem_description": "Alice and Bob want to water n plants in their garden. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the i^th plant is located at x = i.\n\nEach plant needs a specific amount of water. Alice and Bob have a watering can each, initially full. They water the plants in the following way:\n\n- Alice waters the plants in order from left to right, starting from the 0^th plant. Bob waters the plants in order from right to left, starting from the (n - 1)^th plant. They begin watering the plants simultaneously.\n- It takes the same amount of time to water each plant regardless of how much water it needs.\n- Alice/Bob must water the plant if they have enough in their can to fully water it. Otherwise, they first refill their can (instantaneously) then water the plant.\n- In case both Alice and Bob reach the same plant, the one with more water currently in his/her watering can should water this plant. If they have the same amount of water, then Alice should water this plant.\n\nGiven a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the i^th plant needs, and two integers capacityA and capacityB representing the capacities of Alice's and Bob's watering cans respectively, return the number of times they have to refill to water all the plants.\n\nExample 1:\n\nInput: plants = [2,2,3,3], capacityA = 5, capacityB = 5\nOutput: 1\nExplanation:\n- Initially, Alice and Bob have 5 units of water each in their watering cans.\n- Alice waters plant 0, Bob waters plant 3.\n- Alice and Bob now have 3 units and 2 units of water respectively.\n- Alice has enough water for plant 1, so she waters it. Bob does not have enough water for plant 2, so he refills his can then waters it.\nSo, the total number of times they have to refill to water all the plants is 0 + 0 + 1 + 0 = 1.\n\nExample 2:\n\nInput: plants = [2,2,3,3], capacityA = 3, capacityB = 4\nOutput: 2\nExplanation:\n- Initially, Alice and Bob have 3 units and 4 units of water in their watering cans respectively.\n- Alice waters plant 0, Bob waters plant 3.\n- Alice and Bob now have 1 unit of water each, and need to water plants 1 and 2 respectively.\n- Since neither of them have enough water for their current plants, they refill their cans and then water the plants.\nSo, the total number of times they have to refill to water all the plants is 0 + 1 + 1 + 0 = 2.\n\nExample 3:\n\nInput: plants = [5], capacityA = 10, capacityB = 8\nOutput: 0\nExplanation:\n- There is only one plant.\n- Alice's watering can has 10 units of water, whereas Bob's can has 8 units. Since Alice has more water in her can, she waters this plant.\nSo, the total number of times they have to refill is 0.\n\nConstraints:\n\n- n == plants.length\n- 1 <= n <= 10^5\n- 1 <= plants[i] <= 10^6\n- max(plants[i]) <= capacityA, capacityB <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(plants = [5],capacityA = 10,capacityB = 8) == 0\n assert candidate(plants = [1000000, 1000000, 1000000],capacityA = 1000000,capacityB = 1000000) == 1\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 15,capacityB = 15) == 3\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 10) == 5\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 15,capacityB = 15) == 3\n assert candidate(plants = [2, 2, 3, 3],capacityA = 5,capacityB = 5) == 1\n assert candidate(plants = [1000000],capacityA = 1000000,capacityB = 1000000) == 0\n assert candidate(plants = [2, 2, 3, 3],capacityA = 3,capacityB = 4) == 2\n assert candidate(plants = [1, 10, 1, 10, 1, 10, 1, 10],capacityA = 10,capacityB = 10) == 6\n assert candidate(plants = [5, 8, 6],capacityA = 10,capacityB = 10) == 1\n assert candidate(plants = [10, 10, 10, 10, 10],capacityA = 10,capacityB = 10) == 3\n assert candidate(plants = [1, 2, 3, 4, 5],capacityA = 5,capacityB = 5) == 2\n assert candidate(plants = [10, 8, 6, 4, 2],capacityA = 10,capacityB = 8) == 2\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 5,capacityB = 5) == 8\n assert candidate(plants = [1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 3\n assert candidate(plants = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],capacityA = 150,capacityB = 100) == 4\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 50,capacityB = 50) == 5\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 29\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],capacityA = 30,capacityB = 30) == 8\n assert candidate(plants = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],capacityA = 10,capacityB = 12) == 17\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 20,capacityB = 20) == 5\n assert candidate(plants = [1000000, 500000, 1000000, 500000, 1000000, 500000, 1000000, 500000, 1000000, 500000],capacityA = 1000000,capacityB = 1000000) == 8\n assert candidate(plants = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],capacityA = 15,capacityB = 15) == 18\n assert candidate(plants = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],capacityA = 20,capacityB = 30) == 9\n assert candidate(plants = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],capacityA = 10,capacityB = 10) == 12\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],capacityA = 55,capacityB = 65) == 8\n assert candidate(plants = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],capacityA = 5,capacityB = 5) == 22\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],capacityA = 15,capacityB = 20) == 6\n assert candidate(plants = [10, 20, 30, 40, 50, 40, 30, 20, 10],capacityA = 25,capacityB = 25) == 7\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 1000000,capacityB = 1000000) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 20,capacityB = 25) == 11\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 5,capacityB = 5) == 0\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 1000000,capacityB = 1000000) == 3\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 30,capacityB = 35) == 7\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],capacityA = 50,capacityB = 60) == 16\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacityA = 100,capacityB = 100) == 11\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 10,capacityB = 10) == 12\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 10,capacityB = 10) == 16\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 10,capacityB = 35) == 9\n assert candidate(plants = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 15,capacityB = 20) == 6\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 5) == 7\n assert candidate(plants = [100, 150, 200, 250, 300, 350, 400, 450, 500],capacityA = 200,capacityB = 300) == 8\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 28\n assert candidate(plants = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 10) == 16\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],capacityA = 50,capacityB = 50) == 8\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],capacityA = 150,capacityB = 150) == 8\n assert candidate(plants = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981],capacityA = 2000000,capacityB = 2000000) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 20,capacityB = 10) == 13\n assert candidate(plants = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],capacityA = 150,capacityB = 120) == 4\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],capacityA = 15,capacityB = 15) == 19\n assert candidate(plants = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],capacityA = 30,capacityB = 60) == 8\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 2,capacityB = 2) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacityA = 7,capacityB = 8) == 12\n assert candidate(plants = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250],capacityA = 500,capacityB = 500) == 11\n assert candidate(plants = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],capacityA = 25,capacityB = 25) == 7\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 10,capacityB = 10) == 16\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],capacityA = 25,capacityB = 30) == 19\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 5,capacityB = 5) == 28\n assert candidate(plants = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],capacityA = 50,capacityB = 50) == 115\n assert candidate(plants = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61],capacityA = 1000000,capacityB = 500000) == 1\n assert candidate(plants = [1000000, 500000, 1000000, 500000],capacityA = 1000000,capacityB = 1000000) == 2\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],capacityA = 20,capacityB = 20) == 10\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 5,capacityB = 10) == 13\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 5,capacityB = 5) == 8\n assert candidate(plants = [3, 2, 4, 1, 2, 4, 3, 1, 2, 3],capacityA = 5,capacityB = 5) == 4\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 28\n assert candidate(plants = [500, 400, 300, 200, 100, 100, 200, 300, 400, 500],capacityA = 500,capacityB = 500) == 6\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],capacityA = 15,capacityB = 15) == 7\n assert candidate(plants = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],capacityA = 100,capacityB = 100) == 18\n assert candidate(plants = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],capacityA = 500000,capacityB = 500000) == 3\n assert candidate(plants = [5, 7, 3, 8, 6, 10, 4, 9, 2, 1],capacityA = 10,capacityB = 12) == 5\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 2,capacityB = 2) == 8\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 15,capacityB = 15) == 7\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 500000,capacityB = 500000) == 10\n assert candidate(plants = [100, 200, 150, 50, 300, 250, 350, 400, 450, 500],capacityA = 500,capacityB = 600) == 4\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 2000000,capacityB = 1500000) == 6\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],capacityA = 14,capacityB = 16) == 12\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],capacityA = 25,capacityB = 20) == 10\n assert candidate(plants = [100, 200, 300, 400, 500, 400, 300, 200, 100],capacityA = 300,capacityB = 300) == 5\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacityA = 25,capacityB = 20) == 4\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacityA = 5,capacityB = 5) == 18\n assert candidate(plants = [3, 2, 4, 2, 1, 2, 4, 3, 2, 1, 3, 2, 4, 2, 1],capacityA = 5,capacityB = 5) == 7\n assert candidate(plants = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],capacityA = 500,capacityB = 400) == 8\n assert candidate(plants = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],capacityA = 1000000,capacityB = 1000000) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacityA = 15,capacityB = 15) == 8\n assert candidate(plants = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71],capacityA = 150,capacityB = 150) == 26\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],capacityA = 10,capacityB = 10) == 7\n assert candidate(plants = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5],capacityA = 10,capacityB = 10) == 9\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],capacityA = 25,capacityB = 25) == 14\n assert candidate(plants = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],capacityA = 5,capacityB = 5) == 13\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacityA = 5,capacityB = 5) == 20\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacityA = 10,capacityB = 10) == 11\n assert candidate(plants = [5, 8, 6, 7, 5, 4, 3, 2, 1, 9],capacityA = 10,capacityB = 8) == 7\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],capacityA = 20,capacityB = 25) == 11\n assert candidate(plants = [9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 10) == 4\n assert candidate(plants = [10, 5, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 25,capacityB = 30) == 8\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 18\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 5,capacityB = 5) == 18\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],capacityA = 12,capacityB = 15) == 20\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 15,capacityB = 15) == 8\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],capacityA = 25,capacityB = 30) == 8\n assert candidate(plants = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],capacityA = 100,capacityB = 100) == 5\n", "comparison": "exact"}, "public_tests": ["[2,2,3,3]\n5\n5", "[2,2,3,3]\n3\n4", "[5]\n10\n8"], "hints": ["Try \"simulating\" the process.", "Since watering each plant takes the same amount of time, where will Alice and Bob meet if they start watering the plants simultaneously? How can you use this to optimize your solution?", "What will you do when both Alice and Bob have to water the same plant?"], "metadata": {"canonical_parameter_names": ["plants", "capacityA", "capacityB"], "leetcode_dataset_entry_point": "Solution().minimumRefill", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:16+00:00", "tests_total": 104, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "two-pointers", "simulation"]}, "language": "python", "interface": {"raw_signature": "def minimumRefill(self, plants: list[int], capacityA: int, capacityB: int) -> int:", "container": "Solution", "callable": "minimumRefill", "parameters": [{"name": "plants", "type": "list[int]"}, {"name": "capacityA", "type": "int"}, {"name": "capacityB", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2106, "task_id": "maximum-fruits-harvested-after-at-most-k-steps", "difficulty": "Hard", "problem_description": "Fruits are available at some positions on an infinite x-axis. You are given a 2D integer array fruits where fruits[i] = [position_i, amount_i] depicts amount_i fruits at the position position_i. fruits is already sorted by position_i in ascending order, and each position_i is unique.\n\nYou are also given an integer startPos and an integer k. Initially, you are at the position startPos. From any position, you can either walk to the left or right. It takes one step to move one unit on the x-axis, and you can walk at most k steps in total. For every position you reach, you harvest all the fruits at that position, and the fruits will disappear from that position.\n\nReturn the maximum total number of fruits you can harvest.\n\nExample 1:\n\nInput: fruits = [[2,8],[6,3],[8,6]], startPos = 5, k = 4\nOutput: 9\nExplanation:\nThe optimal way is to:\n- Move right to position 6 and harvest 3 fruits\n- Move right to position 8 and harvest 6 fruits\nYou moved 3 steps and harvested 3 + 6 = 9 fruits in total.\n\nExample 2:\n\nInput: fruits = [[0,9],[4,1],[5,7],[6,2],[7,4],[10,9]], startPos = 5, k = 4\nOutput: 14\nExplanation:\nYou can move at most k = 4 steps, so you cannot reach position 0 nor 10.\nThe optimal way is to:\n- Harvest the 7 fruits at the starting position 5\n- Move left to position 4 and harvest 1 fruit\n- Move right to position 6 and harvest 2 fruits\n- Move right to position 7 and harvest 4 fruits\nYou moved 1 + 3 = 4 steps and harvested 7 + 1 + 2 + 4 = 14 fruits in total.\n\nExample 3:\n\nInput: fruits = [[0,3],[6,4],[8,5]], startPos = 3, k = 2\nOutput: 0\nExplanation:\nYou can move at most k = 2 steps and cannot reach any position with fruits.\n\nConstraints:\n\n- 1 <= fruits.length <= 10^5\n- fruits[i].length == 2\n- 0 <= startPos, position_i <= 2 * 10^5\n- position_{i-1} < position_i for any i > 0 (0-indexed)\n- 1 <= amount_i <= 10^4\n- 0 <= k <= 2 * 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(fruits = [[0, 9], [4, 1], [5, 7], [6, 2], [7, 4], [10, 9]],startPos = 5,k = 4) == 14\n assert candidate(fruits = [[1, 100], [50, 100], [100, 100]],startPos = 75,k = 25) == 100\n assert candidate(fruits = [[100000, 10000]],startPos = 90000,k = 20000) == 10000\n assert candidate(fruits = [[0, 1], [2, 1], [4, 1], [6, 1], [8, 1], [10, 1]],startPos = 5,k = 5) == 3\n assert candidate(fruits = [[1, 100], [2, 100], [3, 100], [4, 100], [5, 100], [6, 100], [7, 100], [8, 100], [9, 100], [10, 100]],startPos = 5,k = 10) == 800\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],startPos = 1,k = 5) == 15\n assert candidate(fruits = [[1, 10], [2, 10], [3, 10]],startPos = 1,k = 5) == 30\n assert candidate(fruits = [[1, 2], [3, 4], [5, 6]],startPos = 4,k = 3) == 10\n assert candidate(fruits = [[1, 5], [2, 3], [4, 8], [6, 7], [8, 2]],startPos = 5,k = 5) == 18\n assert candidate(fruits = [[1, 10000], [20000, 10000]],startPos = 10000,k = 10000) == 10000\n assert candidate(fruits = [[10, 5], [20, 5], [30, 5], [40, 5], [50, 5]],startPos = 30,k = 15) == 10\n assert candidate(fruits = [[10000, 10000], [20000, 10000], [30000, 10000]],startPos = 20000,k = 10000) == 20000\n assert candidate(fruits = [[0, 3], [6, 4], [8, 5]],startPos = 3,k = 2) == 0\n assert candidate(fruits = [[1, 2], [3, 4], [7, 8], [10, 10]],startPos = 5,k = 5) == 18\n assert candidate(fruits = [[1, 2], [3, 4], [5, 6], [7, 8]],startPos = 4,k = 5) == 18\n assert candidate(fruits = [[10, 10], [20, 20], [30, 30]],startPos = 15,k = 10) == 20\n assert candidate(fruits = [[2, 8], [6, 3], [8, 6]],startPos = 5,k = 4) == 9\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],startPos = 8,k = 6) == 77\n assert candidate(fruits = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8], [17, 9], [19, 10]],startPos = 10,k = 9) == 40\n assert candidate(fruits = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9]],startPos = 45,k = 30) == 18\n assert candidate(fruits = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8], [17, 9]],startPos = 8,k = 12) == 39\n assert candidate(fruits = [[5, 20], [10, 15], [15, 10], [20, 5], [25, 10]],startPos = 12,k = 10) == 35\n assert candidate(fruits = [[1, 5], [4, 10], [6, 15], [10, 20], [15, 25], [20, 30]],startPos = 10,k = 15) == 75\n assert candidate(fruits = [[1, 1000], [10, 1000], [20, 1000], [30, 1000], [40, 1000]],startPos = 25,k = 20) == 2000\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]],startPos = 6,k = 10) == 72\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],startPos = 1,k = 10) == 55\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],startPos = 5,k = 5) == 45\n assert candidate(fruits = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9]],startPos = 50,k = 30) == 26\n assert candidate(fruits = [[2, 5], [5, 5], [7, 5], [10, 5], [15, 5], [20, 5], [25, 5], [30, 5]],startPos = 15,k = 15) == 25\n assert candidate(fruits = [[1, 50], [2, 50], [3, 50], [4, 50], [5, 50], [6, 50], [7, 50], [8, 50], [9, 50], [10, 50]],startPos = 5,k = 10) == 400\n assert candidate(fruits = [[5, 15], [10, 20], [15, 25], [20, 30], [25, 35], [30, 40]],startPos = 18,k = 12) == 105\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],startPos = 5,k = 4) == 35\n assert candidate(fruits = [[1, 5], [3, 10], [6, 15], [8, 20], [10, 25]],startPos = 5,k = 7) == 60\n assert candidate(fruits = [[5, 100], [10, 200], [15, 300], [20, 400], [25, 500], [30, 600], [35, 700], [40, 800], [45, 900]],startPos = 20,k = 20) == 3000\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],startPos = 5,k = 9) == 52\n assert candidate(fruits = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]],startPos = 5,k = 12) == 35\n assert candidate(fruits = [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]],startPos = 7,k = 10) == 55\n assert candidate(fruits = [[2, 8], [5, 10], [7, 3], [11, 15], [15, 7]],startPos = 8,k = 10) == 28\n assert candidate(fruits = [[5, 2], [10, 4], [15, 6], [20, 8], [25, 10], [30, 12], [35, 14]],startPos = 18,k = 25) == 50\n assert candidate(fruits = [[1, 100], [10, 100], [20, 100], [30, 100], [40, 100], [50, 100]],startPos = 25,k = 20) == 200\n assert candidate(fruits = [[1, 100], [100, 200], [200, 300], [300, 400], [400, 500]],startPos = 250,k = 200) == 900\n assert candidate(fruits = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8], [17, 9], [19, 10]],startPos = 10,k = 10) == 40\n assert candidate(fruits = [[1, 5], [10, 5], [20, 5], [30, 5], [40, 5], [50, 5], [60, 5], [70, 5], [80, 5], [90, 5], [100, 5]],startPos = 50,k = 40) == 25\n assert candidate(fruits = [[1, 1000], [2, 1000], [3, 1000], [4, 1000], [5, 1000], [6, 1000], [7, 1000], [8, 1000], [9, 1000], [10, 1000]],startPos = 5,k = 9) == 8000\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]],startPos = 7,k = 6) == 70\n assert candidate(fruits = [[1, 2000], [2, 2000], [3, 2000], [4, 2000], [5, 2000], [6, 2000], [7, 2000], [8, 2000], [9, 2000], [10, 2000]],startPos = 5,k = 10) == 16000\n assert candidate(fruits = [[2, 3], [4, 6], [6, 9], [8, 12], [10, 15]],startPos = 6,k = 8) == 42\n assert candidate(fruits = [[5, 100], [10, 200], [15, 300], [20, 400], [25, 500]],startPos = 12,k = 22) == 1400\n assert candidate(fruits = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],startPos = 5,k = 9) == 49\n assert candidate(fruits = [[2, 9], [5, 8], [12, 7], [18, 6], [25, 5], [32, 4], [39, 3], [46, 2], [53, 1]],startPos = 25,k = 20) == 26\n assert candidate(fruits = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],startPos = 10,k = 15) == 98\n assert candidate(fruits = [[1, 10], [4, 20], [6, 30], [9, 40], [12, 50], [15, 60], [18, 70], [21, 80], [24, 90]],startPos = 12,k = 18) == 390\n assert candidate(fruits = [[5, 3], [10, 5], [15, 8], [20, 12], [25, 15], [30, 20]],startPos = 18,k = 12) == 47\n assert candidate(fruits = [[2, 5], [4, 3], [5, 10], [7, 2], [8, 6], [10, 1]],startPos = 6,k = 7) == 21\n assert candidate(fruits = [[5, 1], [7, 2], [9, 3], [11, 4], [13, 5]],startPos = 10,k = 6) == 12\n assert candidate(fruits = [[1, 50], [2, 60], [3, 70], [4, 80], [5, 90], [6, 100], [7, 110], [8, 120], [9, 130], [10, 140]],startPos = 5,k = 15) == 950\n assert candidate(fruits = [[1, 10], [5, 20], [10, 30], [15, 40], [20, 50]],startPos = 15,k = 18) == 120\n assert candidate(fruits = [[5, 2], [10, 3], [15, 4], [20, 5], [25, 6], [30, 7], [35, 8], [40, 9]],startPos = 22,k = 12) == 18\n assert candidate(fruits = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],startPos = 8,k = 12) == 10\n assert candidate(fruits = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],startPos = 8,k = 7) == 8\n assert candidate(fruits = [[1, 1000], [5, 1000], [10, 1000], [15, 1000], [20, 1000], [25, 1000], [30, 1000], [35, 1000], [40, 1000]],startPos = 20,k = 25) == 5000\n assert candidate(fruits = [[1, 100], [5, 200], [10, 300], [15, 400], [20, 500]],startPos = 10,k = 18) == 1200\n assert candidate(fruits = [[1, 5], [3, 5], [5, 5], [7, 5], [9, 5], [11, 5], [13, 5], [15, 5], [17, 5], [19, 5]],startPos = 10,k = 9) == 25\n assert candidate(fruits = [[2, 8], [6, 3], [8, 6], [12, 4], [14, 2], [18, 10], [20, 7]],startPos = 10,k = 12) == 23\n assert candidate(fruits = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11], [120, 12], [130, 13], [140, 14], [150, 15]],startPos = 80,k = 30) == 38\n assert candidate(fruits = [[1, 10], [3, 20], [5, 30], [7, 40], [9, 50], [11, 60], [13, 70], [15, 80], [17, 90]],startPos = 8,k = 14) == 390\n assert candidate(fruits = [[0, 100], [10, 100], [20, 100], [30, 100], [40, 100]],startPos = 20,k = 10) == 200\n assert candidate(fruits = [[5, 10], [15, 10], [25, 10], [35, 10], [45, 10], [55, 10], [65, 10]],startPos = 15,k = 35) == 40\n assert candidate(fruits = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],startPos = 5,k = 10) == 520\n assert candidate(fruits = [[1, 2], [4, 3], [7, 4], [10, 5], [13, 6], [16, 7], [19, 8], [22, 9], [25, 10]],startPos = 10,k = 10) == 26\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],startPos = 5,k = 9) == 52\n assert candidate(fruits = [[1, 1000], [2000, 1000], [3000, 1000], [4000, 1000], [5000, 1000]],startPos = 2500,k = 2000) == 2000\n assert candidate(fruits = [[5, 5], [15, 5], [25, 5], [35, 5], [45, 5], [55, 5], [65, 5]],startPos = 30,k = 25) == 15\n assert candidate(fruits = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80]],startPos = 25,k = 15) == 260\n assert candidate(fruits = [[2, 8], [6, 3], [8, 6], [12, 7], [16, 5]],startPos = 5,k = 8) == 16\n assert candidate(fruits = [[1, 10000], [2, 10000], [3, 10000], [4, 10000], [5, 10000]],startPos = 3,k = 100000) == 50000\n assert candidate(fruits = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],startPos = 50,k = 50) == 450\n assert candidate(fruits = [[1, 3], [4, 7], [6, 2], [8, 8], [10, 5]],startPos = 5,k = 7) == 22\n assert candidate(fruits = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]],startPos = 55,k = 30) == 105\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],startPos = 3,k = 15) == 55\n assert candidate(fruits = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700], [80, 800], [90, 900], [100, 1000]],startPos = 50,k = 40) == 3500\n assert candidate(fruits = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 1]],startPos = 55,k = 45) == 5\n assert candidate(fruits = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7]],startPos = 20,k = 20) == 22\n assert candidate(fruits = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],startPos = 55,k = 45) == 400\n assert candidate(fruits = [[2, 5], [5, 10], [10, 8], [15, 7], [20, 6]],startPos = 12,k = 15) == 25\n assert candidate(fruits = [[5, 5], [15, 5], [25, 5], [35, 5], [45, 5], [55, 5]],startPos = 30,k = 18) == 10\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],startPos = 8,k = 10) == 99\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],startPos = 10,k = 15) == 182\n assert candidate(fruits = [[0, 9], [4, 1], [5, 7], [6, 2], [7, 4], [10, 9], [12, 5], [15, 6], [18, 7]],startPos = 5,k = 10) == 33\n assert candidate(fruits = [[1, 1], [3, 1], [5, 1], [7, 1], [9, 1], [11, 1], [13, 1], [15, 1], [17, 1], [19, 1]],startPos = 10,k = 9) == 5\n assert candidate(fruits = [[1, 5], [3, 10], [5, 15], [7, 20], [9, 25], [11, 30], [13, 35], [15, 40], [17, 45], [19, 50]],startPos = 10,k = 15) == 245\n assert candidate(fruits = [[1, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000]],startPos = 2500,k = 2500) == 12000\n assert candidate(fruits = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8]],startPos = 22,k = 15) == 18\n assert candidate(fruits = [[2, 1], [5, 3], [8, 5], [11, 2], [14, 6]],startPos = 7,k = 9) == 13\n assert candidate(fruits = [[10, 5], [15, 10], [20, 15], [25, 20], [30, 25], [35, 30]],startPos = 20,k = 25) == 100\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],startPos = 5,k = 15) == 45\n assert candidate(fruits = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],startPos = 5,k = 4) == 25\n assert candidate(fruits = [[1, 100], [10, 100], [20, 100], [30, 100], [40, 100]],startPos = 25,k = 20) == 200\n assert candidate(fruits = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8], [17, 9], [19, 10]],startPos = 10,k = 8) == 30\n assert candidate(fruits = [[10, 5], [20, 5], [30, 5], [40, 5], [50, 5], [60, 5], [70, 5], [80, 5]],startPos = 40,k = 25) == 15\n assert candidate(fruits = [[2, 8], [6, 3], [8, 6], [10, 9], [12, 4], [14, 2], [16, 5]],startPos = 5,k = 8) == 22\n assert candidate(fruits = [[0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14]],startPos = 6,k = 6) == 44\n assert candidate(fruits = [[1, 5], [10, 10], [20, 15], [30, 20], [40, 25], [50, 30]],startPos = 25,k = 20) == 45\n assert candidate(fruits = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45]],startPos = 25,k = 20) == 105\n assert candidate(fruits = [[0, 100], [10, 100], [20, 100], [30, 100], [40, 100], [50, 100]],startPos = 25,k = 40) == 400\n assert candidate(fruits = [[10, 5000], [20, 5000], [30, 5000], [40, 5000], [50, 5000], [60, 5000], [70, 5000]],startPos = 35,k = 29) == 15000\n assert candidate(fruits = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]],startPos = 5,k = 12) == 35\n assert candidate(fruits = [[1, 1000], [5, 2000], [10, 3000], [20, 4000], [30, 5000]],startPos = 15,k = 18) == 9000\n assert candidate(fruits = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12]],startPos = 4,k = 10) == 68\n assert candidate(fruits = [[1, 1000], [10, 2000], [20, 3000], [30, 4000], [40, 5000], [50, 6000]],startPos = 25,k = 25) == 15000\n assert candidate(fruits = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50], [600, 60], [700, 70], [800, 80], [900, 90]],startPos = 500,k = 300) == 260\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],startPos = 10,k = 10) == 165\n assert candidate(fruits = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600]],startPos = 3,k = 10) == 2100\n assert candidate(fruits = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],startPos = 55,k = 40) == 30\n", "comparison": "exact"}, "public_tests": ["[[2,8],[6,3],[8,6]]\n5\n4", "[[0,9],[4,1],[5,7],[6,2],[7,4],[10,9]]\n5\n4", "[[0,3],[6,4],[8,5]]\n3\n2"], "hints": ["Does an optimal path have very few patterns? For example, could a path that goes left, turns and goes right, then turns again and goes left be any better than a path that simply goes left, turns, and goes right?", "The optimal path turns at most once. That is, the optimal path is one of these: to go left only; to go right only; to go left, turn and go right; or to go right, turn and go left.", "Moving x steps left then k-x steps right gives you a range of positions that you can reach.", "Use prefix sums to get the sum of all fruits for each possible range.", "Use a similar strategy for all the paths that go right, then turn and go left."], "metadata": {"canonical_parameter_names": ["fruits", "startPos", "k"], "leetcode_dataset_entry_point": "Solution().maxTotalFruits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:19+00:00", "tests_total": 114, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "sliding-window", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maxTotalFruits(self, fruits: list[list[int]], startPos: int, k: int) -> int:", "container": "Solution", "callable": "maxTotalFruits", "parameters": [{"name": "fruits", "type": "list[list[int]]"}, {"name": "startPos", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2108, "task_id": "find-first-palindromic-string-in-the-array", "difficulty": "Easy", "problem_description": "Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string \"\".\n\nA string is palindromic if it reads the same forward and backward.\n\nExample 1:\n\nInput: words = [\"abc\",\"car\",\"ada\",\"racecar\",\"cool\"]\nOutput: \"ada\"\nExplanation: The first string that is palindromic is \"ada\".\nNote that \"racecar\" is also palindromic, but it is not the first.\n\nExample 2:\n\nInput: words = [\"notapalindrome\",\"racecar\"]\nOutput: \"racecar\"\nExplanation: The first and only string that is palindromic is \"racecar\".\n\nExample 3:\n\nInput: words = [\"def\",\"ghi\"]\nOutput: \"\"\nExplanation: There are no palindromic strings, so the empty string is returned.\n\nConstraints:\n\n- 1 <= words.length <= 100\n- 1 <= words[i].length <= 100\n- words[i] consists only of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['hello', 'world', 'python', 'madam']) == \"madam\"\n assert candidate(words = ['hello', 'world', 'python']) == \"\"\n assert candidate(words = ['abba', 'abcba', 'abcdedcba', 'nonpalindrome']) == \"abba\"\n assert candidate(words = ['level', 'deified', 'civic', 'rotor']) == \"level\"\n assert candidate(words = ['abccba', 'def', 'ghi', 'jklmnoponmlkj']) == \"abccba\"\n assert candidate(words = ['abc', 'car', 'ada', 'racecar', 'cool']) == \"ada\"\n assert candidate(words = ['madam', 'refer', 'level', 'world']) == \"madam\"\n assert candidate(words = ['madam', 'racecar', 'refer', 'deed', 'peep', 'noon']) == \"madam\"\n assert candidate(words = ['reviled', 'civic', 'rotor', 'redder', 'repaper', 'deed']) == \"civic\"\n assert candidate(words = ['a', 'b', 'c', 'd', 'e']) == \"a\"\n assert candidate(words = ['a', 'b', 'c']) == \"a\"\n assert candidate(words = ['racecar', 'ada', 'cool', 'abc']) == \"racecar\"\n assert candidate(words = ['noon', 'level', 'deified', 'rotor', 'redder']) == \"noon\"\n assert candidate(words = ['notapalindrome', 'racecar']) == \"racecar\"\n assert candidate(words = ['racecar', 'car', 'level']) == \"racecar\"\n assert candidate(words = ['noon', 'moon', 'refer', 'deed']) == \"noon\"\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst']) == \"\"\n assert candidate(words = ['madam', 'refer', 'deed', 'peep', 'level']) == \"madam\"\n assert candidate(words = ['abacaba', 'racecar', 'kayak', 'detartrated', 'repaper']) == \"abacaba\"\n assert candidate(words = ['hello', 'world', 'python', 'programming']) == \"\"\n assert candidate(words = ['level', 'deified', 'civic', 'rotor', 'kayak', 'reviled']) == \"level\"\n assert candidate(words = ['noon', 'level', 'world', 'deified']) == \"noon\"\n assert candidate(words = ['abccba', 'defed', 'ghi', 'jkllkj']) == \"abccba\"\n assert candidate(words = ['def', 'ghi']) == \"\"\n assert candidate(words = ['noon', 'civic', 'rotor', 'deified']) == \"noon\"\n assert candidate(words = ['abcba', 'xyz', 'madam', 'noon']) == \"abcba\"\n assert candidate(words = ['step', 'on', 'no', 'pets']) == \"\"\n assert candidate(words = ['noon', 'racecar', 'kayak', 'reviled', 'civic', 'madam', 'refer', 'deed', 'detartrated', 'repaper']) == \"noon\"\n assert candidate(words = ['notapalindrome', 'almostapalindrome', 'palindromebutnot', 'thisisnotapalindrome', 'palindromic', 'palindrome', 'palindromes', 'palindromicly']) == \"\"\n assert candidate(words = ['abba', 'acca', 'adda', 'aedd', 'aeeea', 'aeeeea', 'aeeeeea', 'aeeeeeea']) == \"abba\"\n assert candidate(words = ['algorithm', 'datastructure', 'python', 'java', 'csharp', 'javascript', 'typescript', 'ruby', 'swift', 'kotlin']) == \"\"\n assert candidate(words = ['notapalindrome', 'stillnotapalindrome', 'palindrome', 'palindromic', 'racecar', 'noon', 'level']) == \"racecar\"\n assert candidate(words = ['a', 'bb', 'ccc', 'dddd', 'eeeee', 'ffffff', 'ggggggg', 'hhhhhhhh', 'iiiiiiiii', 'jjjjjjjjjj']) == \"a\"\n assert candidate(words = ['abccba', 'defed', 'fedcbafedcba', 'zxyzyx', 'mnoponm', 'qwertyytrewq', 'poiuytghjklkjhgfdsapoiuytrewq']) == \"abccba\"\n assert candidate(words = ['racecar', 'level', 'civic', 'rotor', 'deified', 'repaper', 'reviver', 'rotator']) == \"racecar\"\n assert candidate(words = ['nonpalindrome', 'notapalindrome', 'neverpalindrome', 'nopalin', 'palindromeisnothere', 'stillnotapalindrome']) == \"\"\n assert candidate(words = ['racecar', 'refer', 'reviler', 'repaper', 'rotor', 'level', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats', 'ananab', 'banana', 'anana', 'level', 'deed', 'civic', 'rotor', 'detartrated', 'redivider', 'deified', 'racecar']) == \"racecar\"\n assert candidate(words = ['noon', 'civic', 'rotor', 'deed', 'peep', 'reed']) == \"noon\"\n assert candidate(words = ['x', 'y', 'z', 'aa', 'bb', 'cc', 'aaa', 'bbb', 'ccc', 'aaaa', 'bbbb', 'cccc', 'abcba', 'abccba', 'abba', 'racecar', 'madam', 'refer', 'deed', 'peep']) == \"x\"\n assert candidate(words = ['nonpalindromic', 'string', 'without', 'any', 'palindrome', 'here']) == \"\"\n assert candidate(words = ['deed', 'peep', 'noon', 'radar', 'repaper', 'reviver', 'rotator']) == \"deed\"\n assert candidate(words = ['racecar', 'deified', 'civic', 'rotor', 'level', 'repaper', 'rotor', 'reviled', 'detartrated', 'redivider', 'deed', 'peep', 'radar', 'redder', 'refer', 'rotator', 'reviver', 'rotor', 'racecar', 'madam', 'refer', 'racecar', 'deified', 'civic', 'rotor', 'level', 'repaper', 'rotor', 'reviled', 'detartrated', 'redivider', 'deed', 'peep', 'radar', 'redder', 'refer', 'rotator', 'reviver', 'rotor', 'racecar', 'madam', 'refer', 'racecar', 'deified', 'civic', 'rotor', 'level', 'repaper', 'rotor', 'reviled', 'detartrated', 'redivider', 'deed', 'peep', 'radar', 'redder', 'refer', 'rotator', 'reviver', 'rotor', 'racecar', 'madam', 'refer']) == \"racecar\"\n assert candidate(words = ['aabbccdd', 'ddccbbaa', 'abcdeedcba', 'abcdefghihgfedcba', 'abcdefghijkjihgfedcba', 'abcdefghijllkjihgfedcba', 'abcdefghijllkjihgfedcbaf', 'mnopqrstsrqponm']) == \"abcdeedcba\"\n assert candidate(words = ['a', 'bb', 'ccc', 'dddd', 'eeeee']) == \"a\"\n assert candidate(words = ['xylophone', 'guitar', 'piano', 'violin', 'flute', 'saxophone', 'trombone', 'trumpet', 'harp', 'xylophone', 'guitar', 'piano', 'violin', 'flute', 'saxophone', 'trombone', 'trumpet', 'harp', 'a', 'ab', 'aba', 'abcba', 'abcdedcba', 'abcdecba', 'abba', 'abcba']) == \"a\"\n assert candidate(words = ['racecar', 'refer', 'deed', 'peep', 'wow', 'madam', 'rotor', 'level']) == \"racecar\"\n assert candidate(words = ['zzzzzzzz', 'zzzyzzzz', 'zzzyyzzz', 'zzzyyyzz', 'zzzyyyyzzz', 'zzzyyyyyzzzz', 'zzzyyyyyyzzzzz']) == \"zzzzzzzz\"\n assert candidate(words = ['notapalindrome', 'noon', 'racecar', 'rotor', 'notapalindrome', 'reviled', 'detartrated', 'redivider', 'notapalindrome', 'deed', 'peep', 'radar', 'redder', 'refer', 'rotator', 'reviver', 'rotor', 'racecar', 'madam', 'refer', 'notapalindrome']) == \"noon\"\n assert candidate(words = ['noon', 'level', 'rotor', 'deified', 'civic', 'radar']) == \"noon\"\n assert candidate(words = ['abcdcba', 'dcba', 'efgh', 'hgef', 'ijkl', 'lkji', 'mnop', 'ponm', 'qrst', 'tsrq', 'uvw', 'wvu', 'xyz', 'zyx', 'racecar', 'level', 'deified', 'rotor', 'deed', 'peep', 'wow', 'civic', 'radar', 'refer', 'detartrated', 'repaper']) == \"abcdcba\"\n assert candidate(words = ['this', 'is', 'not', 'a', 'palindrome', 'racecar', 'madam', 'refer', 'repaper', 'rotor', 'level', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats', 'ananab', 'banana', 'anana', 'level', 'deed', 'civic', 'rotor', 'detartrated', 'redivider', 'deified', 'racecar']) == \"a\"\n assert candidate(words = ['repaper', 'deed', 'civic', 'level', 'rotor', 'kayak', 'racecar', 'reviled']) == \"repaper\"\n assert candidate(words = ['bobby', 'radar', 'level', 'rotor', 'deed', 'peep', 'wow', 'madam']) == \"radar\"\n assert candidate(words = ['abccba', 'abcde', 'fghij', 'klmno', 'pqrst', 'xyzzyx', 'mnopqr', 'stuvuts']) == \"abccba\"\n assert candidate(words = ['abccba', 'bcb', 'a', 'bb', 'ccc', 'dddd', 'eeeee', 'ffffff', 'ggggggg', 'hhhhhhhh', 'iiiiiiiii', 'jjjjjjjjjj']) == \"abccba\"\n assert candidate(words = ['abcdedcba', 'abcdecba', 'abba', 'abcba', 'a', 'ab', 'aba', 'noon', 'civic', 'rotor', 'level', 'deified', 'redivider', 'detartrated', 'deed', 'peep', 'racecar', 'refer', 'reviler', 'repaper', 'rotor', 'level', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats', 'ananab', 'banana', 'anana', 'level', 'deed', 'civic', 'rotor', 'detartrated', 'redivider', 'deified', 'racecar']) == \"abcdedcba\"\n assert candidate(words = ['verylongpalindromesequenceeosuqeeqosuerosequencemosuqeeqoserev', 'nonpalindrome', 'anotherlongword', 'racecar', 'level', 'deified']) == \"racecar\"\n assert candidate(words = ['nonpalindrome', 'another', 'longwordthatshouldnotbeapalindrome', 'almostapalindromemordnilapalmo', 'racecar', 'noon']) == \"racecar\"\n assert candidate(words = ['aabbcc', 'racecar', 'level', 'noon', 'civic', 'rotor', 'kayak']) == \"racecar\"\n assert candidate(words = ['aabb', 'abba', 'abcba', 'abcdedcba', 'abcdeedcba', 'abcdefgfedcba', 'ghijklmnonmlkjihg', 'poiuytrewqmrewtuyiop']) == \"abba\"\n assert candidate(words = ['noon', 'civic', 'rotor', 'level', 'deified', 'redivider', 'detartrated', 'deed', 'peep', 'racecar', 'refer', 'reviler', 'repaper', 'rotor', 'level', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats', 'ananab', 'banana', 'anana', 'level', 'deed', 'civic', 'rotor', 'detartrated', 'redivider', 'deified', 'racecar']) == \"noon\"\n assert candidate(words = ['abacaba', 'bcb', 'abcba', 'a', 'racecar', 'level', 'deified', 'rotor', 'deed', 'peep', 'wow', 'civic', 'radar', 'refer', 'detartrated', 'repaper']) == \"abacaba\"\n assert candidate(words = ['madam', 'refer', 'stats', 'civic', 'rotor', 'kayak']) == \"madam\"\n assert candidate(words = ['zxcvbnm', 'mnbvcxz', 'qwertyuiop', 'poiuytrewq', 'asdfghjkl', 'lkjhgfdsa', 'qwertyuiopasdfghjklzxcvbnm', 'mnbvcxzlkjhgfdsapoiuytrewq', 'noon', 'civic', 'rotor', 'level', 'deified', 'redivider', 'detartrated', 'deed', 'peep', 'racecar', 'refer', 'reviler', 'repaper', 'rotor', 'level', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats', 'ananab', 'banana', 'anana', 'level', 'deed', 'civic', 'rotor', 'detartrated', 'redivider', 'deified', 'racecar']) == \"noon\"\n assert candidate(words = ['madam', 'refer', 'deed', 'peep', 'reed', 'level', 'deified', 'repaper', 'deed', 'wow', 'did', 'civic', 'rotor', 'kayak', 'reviled', 'redder', 'repaper', 'peep', 'deed', 'madam', 'refer', 'civic', 'rotor', 'kayak', 'reviled']) == \"madam\"\n assert candidate(words = ['no', 'on', 'civic', 'rotor', 'deed', 'peep', 'noon', 'radar', 'racecar', 'redder', 'repaper', 'level', 'deified']) == \"civic\"\n assert candidate(words = ['level', 'deified', 'civic', 'rotor', 'refer', 'deed', 'peep', 'wow', 'madam']) == \"level\"\n assert candidate(words = ['xylophone', 'keyboard', 'guitar', 'piano', 'violin', 'flute', 'drums', 'harp', 'saxophone', 'trumpet']) == \"\"\n assert candidate(words = ['xylophone', 'guitar', 'piano', 'drums', 'violin', 'harp', 'flute', 'trumpet']) == \"\"\n assert candidate(words = ['a', 'bb', 'ccc', 'dddd', 'eeeee', 'ffffff']) == \"a\"\n assert candidate(words = ['aabb', 'bbcc', 'ccdd', 'ddeeff', 'ffeeggee', 'hhiijjkk', 'llmmnnoopp', 'qqrrssttuuvvww', 'xxxyyyyzzzz']) == \"\"\n assert candidate(words = ['racecar', 'refer', 'deified', 'civic', 'level', 'rotor', 'kayak', 'reviled', 'deed', 'noon', 'madam', 'repaper', 'elppa', 'stuvuts', 'xyzzyx']) == \"racecar\"\n assert candidate(words = ['noon', 'level', 'deified', 'rotor', 'repaper', 'reviled', 'detartrated', 'redivider', 'deed', 'peep', 'radar', 'redder', 'refer', 'rotator', 'reviver', 'rotor', 'racecar', 'madam', 'refer']) == \"noon\"\n assert candidate(words = ['qwerty', 'asdfgh', 'zxcvbn', 'police', 'museum', 'kayak']) == \"kayak\"\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'abcba', 'abccba', 'abcdcba', 'abcdeba', 'abcdefedcba', 'abcdeedcba']) == \"a\"\n assert candidate(words = ['ab', 'aba', 'abcba', 'abcdedcba', 'abcdeedcba', 'abcdefgfedcba']) == \"aba\"\n assert candidate(words = ['banana', 'ananab', 'mango', 'orange', 'grape', 'apple', 'elppa']) == \"\"\n assert candidate(words = ['noon', 'level', 'civic', 'rotor', 'deified', 'repaper', 'reviver', 'rotator', 'a', 'bb', 'ccc', 'dddd', 'eeeee', 'ffffff', 'ggggggg', 'hhhhhhhh', 'iiiiiiiii', 'jjjjjjjjjj']) == \"noon\"\n assert candidate(words = ['xyzzyx', 'xyzyx', 'xyx', 'xx', 'x', 'aaa', 'abba', 'abcba', 'abcdedcba', 'abcdefghihgfedcba']) == \"xyzzyx\"\n assert candidate(words = ['madam', 'refer', 'level', 'deified', 'rotor', 'kayak', 'reviled', 'rotor', 'redder', 'repaper']) == \"madam\"\n assert candidate(words = ['aaaaaaaa', 'abccba', 'abcddcba', 'abcdedcba', 'abcdefghihgfedcba', 'abcdefghgfedcba', 'abcdeffedcba']) == \"aaaaaaaa\"\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']) == \"a\"\n assert candidate(words = ['abba', 'acca', 'adca', 'aeia', 'afda', 'agga']) == \"abba\"\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyz']) == \"a\"\n assert candidate(words = ['abcdeedcba', 'fghihgf', 'jklmlkj', 'nopon', 'qrsrstq', 'tuvut', 'xyzzyx', 'abcdedcba', 'fghigfh', 'jklkjl', 'mnoponm', 'qrstsrq', 'tuvutuv', 'xyzyx', 'abccba', 'madam', 'refer', 'noon', 'peep', 'deed', 'racecar', 'repaper', 'redder']) == \"abcdeedcba\"\n assert candidate(words = ['level', 'deified', 'civic', 'rotor', 'kayak', 'madam', 'racecar', 'refer', 'reviled']) == \"level\"\n assert candidate(words = ['aabbcc', 'baccab', 'racecar', 'madam', 'refer', 'reviler', 'repaper', 'repaper', 'rotor', 'level', 'kayak', 'stats', 'rotor', 'refer', 'reviler', 'repaper', 'rotor', 'level', 'kayak', 'stats']) == \"baccab\"\n assert candidate(words = ['notapalindrome', 'almostapalindrome', 'palindromebutnot', 'thisisnotapalindrome', 'palindromic', 'palindrome', 'palindromes', 'palindromicly', 'a', 'aa', 'aaa', 'aaaa', 'abcba', 'abccba', 'abcdcba', 'abcdeba', 'abcdefedcba', 'abcdeedcba']) == \"a\"\n assert candidate(words = ['anana', 'banana', 'ananab', 'level', 'deed', 'civic', 'rotor', 'detartrated', 'redivider', 'deified', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats', 'repaper', 'reviler', 'rotor', 'level', 'kayak', 'stats']) == \"anana\"\n assert candidate(words = ['abccba', 'defg', 'hijklm', 'nopqrst', 'uvwxyz']) == \"abccba\"\n assert candidate(words = ['deified', 'repaper', 'detartrated', 'reviled', 'redder', 'repaid', 'deed']) == \"deified\"\n assert candidate(words = ['aabbccddeeff', 'ffeeddccbbaa', 'abcdefedcba', 'abcdefgihgfedcba', 'abcdefghijkjihgfedcba', 'abcdefghijllkjihgfedcba', 'abcdefghijllkjihgfedcbaf']) == \"abcdefedcba\"\n assert candidate(words = ['thisisnotapalindrome', 'neitheristhis', 'butthisoneis', 'civic', 'rotor', 'madam', 'refer', 'noon', 'deed', 'racecar', 'repaper', 'redder', 'level', 'deified', 'abccba', 'abcba', 'abba', 'baab', 'abcdedcba', 'fghigfh', 'jklkjl', 'mnoponm', 'qrstsrq', 'tuvutuv', 'xyzyx']) == \"civic\"\n assert candidate(words = ['noon', 'level', 'deified', 'rotor', 'reviled']) == \"noon\"\n assert candidate(words = ['level', 'deified', 'rotor', 'redder', 'repaper', 'deed', 'peep', 'wow', 'civic', 'radar']) == \"level\"\n assert candidate(words = ['madam', 'refer', 'level', 'deified', 'rotor', 'reviled']) == \"madam\"\n assert candidate(words = ['deified', 'level', 'civic', 'rotor', 'kayak', 'reviled', 'madam', 'refer', 'noon', 'peep', 'redder', 'repaper', 'racecar', 'deed']) == \"deified\"\n assert candidate(words = ['aabb', 'bbaa', 'abba', 'baab', 'abcba', 'abccba', 'madam', 'refer', 'noon', 'deed', 'racecar', 'repaper', 'redder', 'civic', 'rotor', 'kayak', 'reviled', 'deified', 'level', 'rotor', 'redder', 'repaper', 'level', 'deified']) == \"abba\"\n assert candidate(words = ['xylophone', 'guitar', 'piano', 'drums', 'flute', 'violin', 'harp']) == \"\"\n assert candidate(words = ['abcd', 'dcba', 'efgh', 'hgef', 'ijkl', 'lkji', 'mnop', 'ponm', 'qrst', 'tsrq', 'uvw', 'wvu', 'xyz', 'zyx']) == \"\"\n assert candidate(words = ['noon', 'civic', 'rotor', 'level', 'deified', 'redivider', 'detartrated', 'deed', 'peep', 'racecar']) == \"noon\"\n", "comparison": "exact"}, "public_tests": ["[\"abc\",\"car\",\"ada\",\"racecar\",\"cool\"]", "[\"notapalindrome\",\"racecar\"]", "[\"def\",\"ghi\"]"], "hints": ["Iterate through the elements in order. As soon as the current element is a palindrome, return it.", "To check if an element is a palindrome, can you reverse the string?"], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().firstPalindrome", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:23+00:00", "tests_total": 104, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "two-pointers", "string"]}, "language": "python", "interface": {"raw_signature": "def firstPalindrome(self, words: list[str]) -> str:", "container": "Solution", "callable": "firstPalindrome", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2109, "task_id": "adding-spaces-to-a-string", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given index.\n\n- For example, given s = \"EnjoyYourCoffee\" and spaces = [5, 9], we place spaces before 'Y' and 'C', which are at indices 5 and 9 respectively. Thus, we obtain \"Enjoy Your Coffee\".\n\nReturn the modified string after the spaces have been added.\n\nExample 1:\n\nInput: s = \"LeetcodeHelpsMeLearn\", spaces = [8,13,15]\nOutput: \"Leetcode Helps Me Learn\"\nExplanation:\nThe indices 8, 13, and 15 correspond to the underlined characters in \"LeetcodeHelpsMeLearn\".\nWe then place spaces before those characters.\n\nExample 2:\n\nInput: s = \"icodeinpython\", spaces = [1,5,7,9]\nOutput: \"i code in py thon\"\nExplanation:\nThe indices 1, 5, 7, and 9 correspond to the underlined characters in \"icodeinpython\".\nWe then place spaces before those characters.\n\nExample 3:\n\nInput: s = \"spacing\", spaces = [0,1,2,3,4,5,6]\nOutput: \" s p a c i n g\"\nExplanation:\nWe are also able to place spaces before the first character of the string.\n\nConstraints:\n\n- 1 <= s.length <= 3 * 10^5\n- s consists only of lowercase and uppercase English letters.\n- 1 <= spaces.length <= 3 * 10^5\n- 0 <= spaces[i] <= s.length - 1\n- All the values of spaces are strictly increasing.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"spacing\",spaces = [0, 1, 2, 3, 4, 5, 6]) == \" s p a c i n g\"\n assert candidate(s = \"icodeinpython\",spaces = [1, 5, 7, 9]) == \"i code in py thon\"\n assert candidate(s = \"A\",spaces = [0]) == \" A\"\n assert candidate(s = \"icodeinpython\",spaces = [1, 5, 7, 9]) == \"i code in py thon\"\n assert candidate(s = \"InsertSpacesEverywhere\",spaces = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20]) == \"I n s e r t S p a c e s E v e r yw h e re\"\n assert candidate(s = \"LeetcodeHelpsMeLearn\",spaces = [8, 13, 15]) == \"Leetcode Helps Me Learn\"\n assert candidate(s = \"spacing\",spaces = [0, 1, 2, 3, 4, 5, 6]) == \" s p a c i n g\"\n assert candidate(s = \"PythonProgramming\",spaces = [6]) == \"Python Programming\"\n assert candidate(s = \"LeetcodeHelpsMeLearn\",spaces = [8, 13, 15]) == \"Leetcode Helps Me Learn\"\n assert candidate(s = \"AlibabaCloudisAmazing\",spaces = [7, 13, 19]) == \"Alibaba Cloudi sAmazi ng\"\n assert candidate(s = \"AugmentedReality\",spaces = [8, 14]) == \"Augmente dReali ty\"\n assert candidate(s = \"ParallelAndDistributedComputing\",spaces = [8, 26]) == \"Parallel AndDistributedComp uting\"\n assert candidate(s = \"Short\",spaces = [1, 2]) == \"S h ort\"\n assert candidate(s = \"InsertSpacesHere\",spaces = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == \"I n s e r t S p a c e sHere\"\n assert candidate(s = \"AlgorithmDesignAndAnalysis\",spaces = [9, 18, 22]) == \"Algorithm DesignAnd Anal ysis\"\n assert candidate(s = \"InformationSecurity\",spaces = [16]) == \"InformationSecur ity\"\n assert candidate(s = \"ComputerNetworking\",spaces = [13]) == \"ComputerNetwo rking\"\n assert candidate(s = \"HelloWorldFromPython\",spaces = [5, 11, 15]) == \"Hello WorldF romP ython\"\n assert candidate(s = \"OneTwoThreeFourFiveSixSevenEightNineTen\",spaces = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == \"One Two Thr eeF our Fiv eSi xSe ven Eig htNineTen\"\n assert candidate(s = \"EndWithSpaces\",spaces = [10, 11, 12]) == \"EndWithSpa c e s\"\n assert candidate(s = \"MultipleSpacesInARow\",spaces = [12, 13, 14, 15]) == \"MultipleSpac e s I nARow\"\n assert candidate(s = \"ZebraCrossing\",spaces = [5, 10]) == \"Zebra Cross ing\"\n assert candidate(s = \"abcdefghij\",spaces = [1, 3, 5, 7, 9]) == \"a bc de fg hi j\"\n assert candidate(s = \"BlockchainTechnology\",spaces = [9, 18]) == \"Blockchai nTechnolo gy\"\n assert candidate(s = \"BoundaryEdgeCases\",spaces = [0, 14]) == \" BoundaryEdgeCa ses\"\n assert candidate(s = \"ComplexPattern\",spaces = [1, 3, 5, 7, 9, 11]) == \"C om pl ex Pa tt ern\"\n assert candidate(s = \"ThisIsAVeryLongStringWithoutSpaces\",spaces = [4, 8, 12, 17, 21, 27, 32]) == \"This IsAV eryL ongSt ring Withou tSpac es\"\n assert candidate(s = \"ComputerVision\",spaces = [12]) == \"ComputerVisi on\"\n assert candidate(s = \"VirtualReality\",spaces = [7, 13]) == \"Virtual Realit y\"\n assert candidate(s = \"MultipleConsecutiveSpaces\",spaces = [7, 8, 9, 10, 11]) == \"Multipl e C o n secutiveSpaces\"\n assert candidate(s = \"OneBigSpaceInTheMiddle\",spaces = [10]) == \"OneBigSpac eInTheMiddle\"\n assert candidate(s = \"CloudComputingServices\",spaces = [5, 14, 21]) == \"Cloud Computing Service s\"\n assert candidate(s = \"MultipleSpaces\",spaces = [2, 5, 8, 11]) == \"Mu lti ple Spa ces\"\n assert candidate(s = \"TestStringWithSeveralSpaces\",spaces = [4, 8, 12, 16, 20, 24]) == \"Test Stri ngWi thSe vera lSpa ces\"\n assert candidate(s = \"AdvancedAlgorithmDesign\",spaces = [7, 21]) == \"Advance dAlgorithmDesi gn\"\n assert candidate(s = \"NaturalLanguageProcessing\",spaces = [11, 21]) == \"NaturalLang uageProces sing\"\n assert candidate(s = \"NeuralNetworks\",spaces = [6, 13]) == \"Neural Network s\"\n assert candidate(s = \"QuickBrownFox\",spaces = [5, 11]) == \"Quick BrownF ox\"\n assert candidate(s = \"SingleCharacter\",spaces = [0]) == \" SingleCharacter\"\n assert candidate(s = \"InternetOfThings\",spaces = [8, 13, 15]) == \"Internet OfThi ng s\"\n assert candidate(s = \"InternetOfThings\",spaces = [8, 14]) == \"Internet OfThin gs\"\n assert candidate(s = \"DataStructuresAndAlgorithms\",spaces = [4, 16, 23]) == \"Data StructuresAn dAlgori thms\"\n assert candidate(s = \"PythonIsFun\",spaces = [6, 8]) == \"Python Is Fun\"\n assert candidate(s = \"AddingSpacesEverywhere\",spaces = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == \"A dd in gS pa ce sE ve ry where\"\n assert candidate(s = \"SingleWord\",spaces = [5]) == \"Singl eWord\"\n assert candidate(s = \"EdgeCasesAtTheEnd\",spaces = [13, 14, 15]) == \"EdgeCasesAtTh e E nd\"\n assert candidate(s = \"RoboticsEngineering\",spaces = [8, 17]) == \"Robotics Engineeri ng\"\n assert candidate(s = \"QwenIsPowerful\",spaces = [4, 8, 12]) == \"Qwen IsPo werf ul\"\n assert candidate(s = \"TheQuickBrownFoxJumpsOverTheLazyDog\",spaces = [3, 9, 15, 21, 25, 30, 34]) == \"The QuickB rownFo xJumps Over TheLa zyDo g\"\n assert candidate(s = \"AddingSpacesInAString\",spaces = [5, 12, 16]) == \"Addin gSpaces InAS tring\"\n assert candidate(s = \"SingleSpaceAtEnd\",spaces = [13]) == \"SingleSpaceAt End\"\n assert candidate(s = \"ProgrammingLanguages\",spaces = [11]) == \"Programming Languages\"\n assert candidate(s = \"OneWord\",spaces = [0]) == \" OneWord\"\n assert candidate(s = \"ConsecutiveSpaces\",spaces = [4, 5, 11, 12]) == \"Cons e cutive S paces\"\n assert candidate(s = \"aLongStringWithoutSpaces\",spaces = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == \"a L o n g S t r i n g W i t h o u t S p a ces\"\n assert candidate(s = \"DatabaseSystems\",spaces = [10]) == \"DatabaseSy stems\"\n assert candidate(s = \"DistributedSystems\",spaces = [13]) == \"DistributedSy stems\"\n assert candidate(s = \"BlockChainTechnology\",spaces = [9, 18]) == \"BlockChai nTechnolo gy\"\n assert candidate(s = \"Alphabet\",spaces = [1, 2, 3, 4, 5, 6]) == \"A l p h a b et\"\n assert candidate(s = \"a\",spaces = [0]) == \" a\"\n assert candidate(s = \"AlibabaCloudServices\",spaces = [7, 18]) == \"Alibaba CloudServic es\"\n assert candidate(s = \"AlgorithmsAndDataStructures\",spaces = [10, 15, 20]) == \"Algorithms AndDa taStr uctures\"\n assert candidate(s = \"TestEdgeCases\",spaces = [0, 4, 8, 12]) == \" Test Edge Case s\"\n assert candidate(s = \"EdgeCasesHandled\",spaces = [0, 11, 13]) == \" EdgeCasesHa nd led\"\n assert candidate(s = \"CyberSecurity\",spaces = [10]) == \"CyberSecur ity\"\n assert candidate(s = \"StartWithSpaces\",spaces = [0, 1, 2]) == \" S t artWithSpaces\"\n assert candidate(s = \"ComputerVision\",spaces = [8, 13]) == \"Computer Visio n\"\n assert candidate(s = \"abcdefg\",spaces = [1, 2, 3, 4, 5, 6]) == \"a b c d e f g\"\n assert candidate(s = \"OperatingSystems\",spaces = [12]) == \"OperatingSys tems\"\n assert candidate(s = \"ArtificialIntelligence\",spaces = [9, 19]) == \"Artificia lIntellige nce\"\n assert candidate(s = \"AlgorithmsAndDataStructures\",spaces = [10, 15, 20, 25]) == \"Algorithms AndDa taStr uctur es\"\n", "comparison": "exact"}, "public_tests": ["\"LeetcodeHelpsMeLearn\"\n[8,13,15]", "\"icodeinpython\"\n[1,5,7,9]", "\"spacing\"\n[0,1,2,3,4,5,6]"], "hints": ["Create a new string, initially empty, as the modified string. Iterate through the original string and append each character of the original string to the new string. However, each time you reach a character that requires a space before it, append a space before appending the character.", "Since the array of indices for the space locations is sorted, use a pointer to keep track of the next index to place a space. Only increment the pointer once a space has been appended.", "Ensure that your append operation can be done in O(1)."], "metadata": {"canonical_parameter_names": ["s", "spaces"], "leetcode_dataset_entry_point": "Solution().addSpaces", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:26+00:00", "tests_total": 127, "tests_dropped": 56, "flags": [], "topic_tags": ["array", "two-pointers", "string", "simulation"]}, "language": "python", "interface": {"raw_signature": "def addSpaces(self, s: str, spaces: list[int]) -> str:", "container": "Solution", "callable": "addSpaces", "parameters": [{"name": "s", "type": "str"}, {"name": "spaces", "type": "list[int]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2110, "task_id": "number-of-smooth-descent-periods-of-a-stock", "difficulty": "Medium", "problem_description": "You are given an integer array prices representing the daily price history of a stock, where prices[i] is the stock price on the i^th day.\n\nA smooth descent period of a stock consists of one or more contiguous days such that the price on each day is lower than the price on the preceding day by exactly 1. The first day of the period is exempted from this rule.\n\nReturn the number of smooth descent periods.\n\nExample 1:\n\nInput: prices = [3,2,1,4]\nOutput: 7\nExplanation: There are 7 smooth descent periods:\n[3], [2], [1], [4], [3,2], [2,1], and [3,2,1]\nNote that a period with one day is a smooth descent period by the definition.\n\nExample 2:\n\nInput: prices = [8,6,7,7]\nOutput: 4\nExplanation: There are 4 smooth descent periods: [8], [6], [7], and [7]\nNote that [8,6] is not a smooth descent period as 8 - 6 ≠ 1.\n\nExample 3:\n\nInput: prices = [1]\nOutput: 1\nExplanation: There is 1 smooth descent period: [1]\n\nConstraints:\n\n- 1 <= prices.length <= 10^5\n- 1 <= prices[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(prices = [10, 9, 4, 3, 2, 1]) == 13\n assert candidate(prices = [3, 3, 3, 3, 3]) == 5\n assert candidate(prices = [100000, 99999, 99998, 99997, 99996, 99995]) == 21\n assert candidate(prices = [8, 6, 7, 7]) == 4\n assert candidate(prices = [1]) == 1\n assert candidate(prices = [10, 9, 10, 9, 8, 7, 8, 7, 6, 5]) == 23\n assert candidate(prices = [3, 3, 3, 3, 3, 3, 3]) == 7\n assert candidate(prices = [5, 4, 5, 4, 3, 2, 1]) == 18\n assert candidate(prices = [3, 2, 1, 4]) == 7\n assert candidate(prices = [1, 3, 2, 1, 4, 3, 2, 1]) == 17\n assert candidate(prices = [5, 4, 3, 4, 3, 2, 1]) == 16\n assert candidate(prices = [5]) == 1\n assert candidate(prices = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 55\n assert candidate(prices = [10, 9, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 51\n assert candidate(prices = [1, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 19\n assert candidate(prices = [5, 4, 3, 2, 1]) == 15\n assert candidate(prices = [1, 2, 3, 4, 5]) == 5\n assert candidate(prices = [10, 9, 8, 9, 8, 7, 6, 5, 6, 7]) == 23\n assert candidate(prices = [2, 1, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 37\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 65\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 36\n assert candidate(prices = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 66\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(prices = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 210\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(prices = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 166\n assert candidate(prices = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11]) == 135\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5]) == 76\n assert candidate(prices = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == 210\n assert candidate(prices = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 29\n assert candidate(prices = [3, 2, 1, 2, 1, 3, 2, 1, 2, 1, 3, 2, 1, 2, 1]) == 27\n assert candidate(prices = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 28\n assert candidate(prices = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 465\n assert candidate(prices = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 60\n assert candidate(prices = [7, 6, 5, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1]) == 73\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 6, 5, 4, 3, 2, 1]) == 42\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 64\n assert candidate(prices = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 29\n assert candidate(prices = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991, 49990, 49989, 49988, 49987, 49986, 49985, 49984, 49983, 49982, 49981]) == 210\n assert candidate(prices = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 70\n assert candidate(prices = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 41\n assert candidate(prices = [1, 3, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2]) == 40\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 54\n assert candidate(prices = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 44\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(prices = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75]) == 325\n assert candidate(prices = [10, 9, 8, 10, 9, 8, 7, 6, 5, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(prices = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 210\n assert candidate(prices = [10, 9, 8, 7, 10, 9, 8, 7, 6, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 86\n assert candidate(prices = [10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9]) == 33\n assert candidate(prices = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5]) == 37\n assert candidate(prices = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 170\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 19\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 64\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(prices = [7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 109\n assert candidate(prices = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 231\n assert candidate(prices = [10, 9, 8, 9, 8, 7, 8, 7, 6, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 60\n assert candidate(prices = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1]) == 38\n assert candidate(prices = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 136\n assert candidate(prices = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 49\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 110\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(prices = [10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 201\n assert candidate(prices = [10, 9, 8, 9, 8, 7, 6, 7, 8, 9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 5, 6, 7, 8, 9]) == 62\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 25\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 19\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 19\n assert candidate(prices = [3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 80\n assert candidate(prices = [10, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 147\n assert candidate(prices = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 55\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 28\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 119\n assert candidate(prices = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4]) == 40\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 29\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 110\n assert candidate(prices = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 24\n assert candidate(prices = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5050\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3]) == 22\n assert candidate(prices = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5]) == 44\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 64\n assert candidate(prices = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20]) == 211\n assert candidate(prices = [5, 6, 5, 4, 3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 41\n assert candidate(prices = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980]) == 210\n assert candidate(prices = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 69\n assert candidate(prices = [10, 9, 10, 9, 8, 7, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5]) == 48\n assert candidate(prices = [1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 81\n assert candidate(prices = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 66\n assert candidate(prices = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 14\n assert candidate(prices = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 35\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(prices = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 325\n assert candidate(prices = [5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 26\n assert candidate(prices = [10, 9, 8, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4]) == 70\n assert candidate(prices = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 11\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(prices = [7, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 79\n assert candidate(prices = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n", "comparison": "exact"}, "public_tests": ["[3,2,1,4]", "[8,6,7,7]", "[1]"], "hints": ["Any array is a series of adjacent longest possible smooth descent periods. For example, [5,3,2,1,7,6] is [5] + [3,2,1] + [7,6].", "Think of a 2-pointer approach to traverse the array and find each longest possible period.", "Suppose you found the longest possible period with a length of k. How many periods are within that period? How can you count them quickly? Think of the formula to calculate the sum of 1, 2, 3, ..., k."], "metadata": {"canonical_parameter_names": ["prices"], "leetcode_dataset_entry_point": "Solution().getDescentPeriods", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:29+00:00", "tests_total": 116, "tests_dropped": 16, "flags": [], "topic_tags": ["array", "math", "two-pointers", "dynamic-programming", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def getDescentPeriods(self, prices: list[int]) -> int:", "container": "Solution", "callable": "getDescentPeriods", "parameters": [{"name": "prices", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2111, "task_id": "minimum-operations-to-make-the-array-k-increasing", "difficulty": "Hard", "problem_description": "You are given a 0-indexed array arr consisting of n positive integers, and a positive integer k.\n\nThe array arr is called K-increasing if arr[i-k] <= arr[i] holds for every index i, where k <= i <= n-1.\n\n- For example, arr = [4, 1, 5, 2, 6, 2] is K-increasing for k = 2 because:\n - arr[0] <= arr[2] (4 <= 5)\n - arr[1] <= arr[3] (1 <= 2)\n - arr[2] <= arr[4] (5 <= 6)\n - arr[3] <= arr[5] (2 <= 2)\n- However, the same arr is not K-increasing for k = 1 (because arr[0] > arr[1]) or k = 3 (because arr[0] > arr[3]).\n\nIn one operation, you can choose an index i and change arr[i] into any positive integer.\n\nReturn the minimum number of operations required to make the array K-increasing for the given k.\n\nExample 1:\n\nInput: arr = [5,4,3,2,1], k = 1\nOutput: 4\nExplanation:\nFor k = 1, the resultant array has to be non-decreasing.\nSome of the K-increasing arrays that can be formed are [5,6,7,8,9], [1,1,1,1,1], [2,2,3,4,4]. All of them require 4 operations.\nIt is suboptimal to change the array to, for example, [6,7,8,9,10] because it would take 5 operations.\nIt can be shown that we cannot make the array K-increasing in less than 4 operations.\n\nExample 2:\n\nInput: arr = [4,1,5,2,6,2], k = 2\nOutput: 0\nExplanation:\nThis is the same example as the one in the problem description.\nHere, for every index i where 2 <= i <= 5, arr[i-2] <= arr[i].\nSince the given array is already K-increasing, we do not need to perform any operations.\n\nExample 3:\n\nInput: arr = [4,1,5,2,6,2], k = 3\nOutput: 2\nExplanation:\nIndices 3 and 5 are the only ones not satisfying arr[i-3] <= arr[i] for 3 <= i <= 5.\nOne of the ways we can make the array K-increasing is by changing arr[3] to 4 and arr[5] to 5.\nThe array will now be [4,1,5,4,6,5].\nNote that there can be other ways to make the array K-increasing, but none of them require less than 2 operations.\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- 1 <= arr[i], k <= arr.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 2, 2, 2, 2],k = 1) == 0\n assert candidate(arr = [4, 1, 5, 2, 6, 2],k = 3) == 2\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1) == 0\n assert candidate(arr = [6, 5, 4, 3, 2, 1],k = 2) == 4\n assert candidate(arr = [5, 4, 3, 2, 1],k = 1) == 4\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6],k = 2) == 0\n assert candidate(arr = [5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(arr = [1, 2, 3, 4, 5],k = 1) == 0\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 0\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 5\n assert candidate(arr = [1, 2, 3, 4, 5],k = 5) == 0\n assert candidate(arr = [7, 4, 2, 6, 3, 5, 1, 8],k = 3) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1],k = 2) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 0\n assert candidate(arr = [2, 2, 2, 2, 2],k = 5) == 0\n assert candidate(arr = [9, 4, 2, 3, 1, 5, 7, 8, 6, 10],k = 1) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6],k = 1) == 0\n assert candidate(arr = [4, 1, 5, 2, 6, 2],k = 2) == 0\n assert candidate(arr = [1, 1, 1, 1, 1],k = 1) == 0\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(arr = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 4) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 0\n assert candidate(arr = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 20\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == 0\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 3, 5, 7, 4, 6, 8],k = 2) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == 0\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 16\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 7) == 0\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 0\n assert candidate(arr = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 2) == 0\n assert candidate(arr = [9, 7, 5, 3, 1, 10, 8, 6, 4, 2, 11],k = 5) == 0\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10],k = 5) == 7\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 8, 7, 9, 11, 10, 12, 14, 13, 15, 17, 16, 18, 20, 19, 21, 23, 22, 24, 26, 25, 27, 29, 28, 30, 32, 31, 33, 35, 34, 36, 38, 37, 39, 41, 40, 42, 44, 43, 45, 47, 46, 48, 50, 49],k = 3) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 4) == 0\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 0\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10) == 0\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4],k = 5) == 4\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 4) == 4\n assert candidate(arr = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9],k = 3) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 5) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 7\n assert candidate(arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 27\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 1) == 0\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 3) == 0\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15],k = 3) == 0\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 20) == 0\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],k = 2) == 0\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 18\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 0\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 9\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 1) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 10) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],k = 5) == 5\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],k = 2) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 2) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 0\n assert candidate(arr = [1, 3, 2, 4, 6, 5, 7, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20],k = 3) == 0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 0\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],k = 2) == 3\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 1) == 0\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 29) == 0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9],k = 1) == 12\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 2) == 4\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 2) == 0\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4],k = 5) == 9\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == 14\n assert candidate(arr = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 0\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 2) == 0\n assert candidate(arr = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11],k = 3) == 0\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 4) == 0\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 12\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 25\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 0\n assert candidate(arr = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5],k = 2) == 0\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10],k = 2) == 0\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 3) == 8\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 0\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 2) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(arr = [5, 3, 8, 6, 2, 7, 4, 9, 1],k = 2) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 0\n", "comparison": "exact"}, "public_tests": ["[5,4,3,2,1]\n1", "[4,1,5,2,6,2]\n2", "[4,1,5,2,6,2]\n3"], "hints": ["Can we divide the array into non-overlapping subsequences and simplify the problem?", "In the final array, arr[i-k] ≤ arr[i] should hold. We can use this to divide the array into at most k non-overlapping sequences, where arr[i] will belong to the (i%k)th sequence.", "Now our problem boils down to performing the minimum operations on each sequence such that it becomes non-decreasing. Our answer will be the sum of operations on each sequence.", "Which indices of a sequence should we not change in order to count the minimum operations? Can finding the longest non-decreasing subsequence of the sequence help?"], "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().kIncreasing", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:31+00:00", "tests_total": 133, "tests_dropped": 38, "flags": [], "topic_tags": ["array", "binary-search", "longest-increasing-subsequence"]}, "language": "python", "interface": {"raw_signature": "def kIncreasing(self, arr: list[int], k: int) -> int:", "container": "Solution", "callable": "kIncreasing", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2114, "task_id": "maximum-number-of-words-found-in-sentences", "difficulty": "Easy", "problem_description": "A sentence is a list of words that are separated by a single space with no leading or trailing spaces.\n\nYou are given an array of strings sentences, where each sentences[i] represents a single sentence.\n\nReturn the maximum number of words that appear in a single sentence.\n\nExample 1:\n\nInput: sentences = [\"alice and bob love leetcode\", \"i think so too\", \"this is great thanks very much\"]\nOutput: 6\nExplanation:\n- The first sentence, \"alice and bob love leetcode\", has 5 words in total.\n- The second sentence, \"i think so too\", has 4 words in total.\n- The third sentence, \"this is great thanks very much\", has 6 words in total.\nThus, the maximum number of words in a single sentence comes from the third sentence, which has 6 words.\n\nExample 2:\n\nInput: sentences = [\"please wait\", \"continue to fight\", \"continue to win\"]\nOutput: 3\nExplanation: It is possible that multiple sentences contain the same number of words.\nIn this example, the second and third sentences (underlined) have the same number of words.\n\nConstraints:\n\n- 1 <= sentences.length <= 100\n- 1 <= sentences[i].length <= 100\n- sentences[i] consists only of lowercase English letters and ' ' only.\n- sentences[i] does not have leading or trailing spaces.\n- All the words in sentences[i] are separated by a single space.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentences = ['short', 'tiny', 'minuscule']) == 1\n assert candidate(sentences = ['one']) == 1\n assert candidate(sentences = ['alice and bob love leetcode', 'i think so too', 'this is great thanks very much']) == 6\n assert candidate(sentences = ['singleword', 'two words', 'three words here']) == 3\n assert candidate(sentences = ['one two three four five six seven eight nine ten']) == 10\n assert candidate(sentences = ['please wait', 'continue to fight', 'continue to win']) == 3\n assert candidate(sentences = ['hello world', 'hi there']) == 2\n assert candidate(sentences = ['singleword', 'another word', 'yet another example']) == 3\n assert candidate(sentences = ['a quick brown fox', 'jumps over the lazy dog']) == 5\n assert candidate(sentences = ['one two three', 'four five six seven', 'eight nine ten eleven twelve']) == 5\n assert candidate(sentences = ['a b c d e f g h i j k l m n o p q r s t u v w x y z']) == 26\n assert candidate(sentences = ['longer sentences with more words to test the function', 'another sentence to check the word count correctly', 'yet another example sentence for validation', 'this is the last sentence for this test case']) == 9\n assert candidate(sentences = ['equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal']) == 1\n assert candidate(sentences = ['all questions asked by five watched experts amaze the judge', 'jackdaws love my big sphinx of quartz', 'the five boxing wizards jump quickly on this new sentence']) == 10\n assert candidate(sentences = ['tiny', 'shorter', 'shortest', 'a bit longer', 'the longest sentence in the list']) == 6\n assert candidate(sentences = ['the quick brown fox jumps over the lazy dog', 'this sentence is longer than the previous one', 'a']) == 9\n assert candidate(sentences = ['once upon a time in a world far far away', 'there lived a king and a queen', 'who were very very happy together']) == 10\n assert candidate(sentences = ['singleword', 'two words', 'three words are', 'four words are here', 'five words are here now', 'six words are here now indeed', 'seven words are here now indeed truly']) == 7\n assert candidate(sentences = ['this sentence has twelve words in it indeed', 'this one has seven words']) == 8\n assert candidate(sentences = ['a short sentence', 'a much longer sentence with many more words in it', 'tiny', 'an even longer sentence that seems to go on and on and on']) == 13\n assert candidate(sentences = ['one two three', 'four five six seven', 'eight nine ten eleven twelve', 'thirteen fourteen fifteen sixteen seventeen']) == 5\n assert candidate(sentences = ['equal number of words here', 'equal number of words here', 'equal number of words here']) == 5\n assert candidate(sentences = ['this is a single word', 'this is a two word phrase', 'this sentence has three words in it']) == 7\n assert candidate(sentences = ['one two three', 'four five six seven eight', 'nine ten eleven twelve thirteen fourteen fifteen']) == 7\n assert candidate(sentences = ['a b c d e f g h i j k l m n o p q r s t u v w x y z', 'this is a sentence with many many many words indeed']) == 26\n assert candidate(sentences = ['this is a test sentence with exactly ten words in it', 'another test sentence here with ten words too', 'and yet another test sentence that has ten words']) == 11\n assert candidate(sentences = ['singleword', 'anotherword', 'yetanotherword', 'onemoreword']) == 1\n assert candidate(sentences = ['python is fun', 'data structures and algorithms', 'object oriented programming is powerful']) == 5\n assert candidate(sentences = ['this is a test', 'another test sentence', 'yet another example to consider', 'the longest sentence in this batch is this one here']) == 10\n assert candidate(sentences = ['the quick brown fox jumps over the lazy dog', 'pack my box with five dozen liquor jugs']) == 9\n assert candidate(sentences = ['abcd efgh ijkl mnop qrst uvwx yz', 'abcd efgh ijkl mnop qrst uvwx yz abcd', 'abcd efgh ijkl mnop qrst uvwx yz abcd efgh', 'abcd efgh ijkl mnop qrst uvwx yz abcd efgh ijkl mnop']) == 11\n assert candidate(sentences = ['the quick brown fox jumps over the lazy dog', 'every good boy does fine', 'to be or not to be that is the question']) == 10\n assert candidate(sentences = ['a b c d e f g h i j k l m n o p q r s t u v w x y z', 'the rain in spain stays mainly in the plain', 'i am six']) == 26\n assert candidate(sentences = ['a b c d e f g h i j k l m n o p q r s t u v w x y z', 'a b c d e f g h i j k l m n o p q r s t u v w x y', 'a b c d e f g h i j k l m n o p q r s t u v w x']) == 26\n assert candidate(sentences = ['words words words words words words words words words words', 'just a couple', 'quite a bit more words than before']) == 10\n assert candidate(sentences = ['the best way to achieve success is through hard work', 'persistence is key to overcoming challenges', 'never give up on your dreams']) == 10\n assert candidate(sentences = ['a b c d e f g h i j k l m n o p q r s t u v w x y z', 'quick fox jumps', 'lazy dog']) == 26\n assert candidate(sentences = ['one', 'two words', 'three words here', 'four words here now', 'five words here now indeed', 'six words here now indeed truly']) == 6\n assert candidate(sentences = ['the quick brown fox jumps over the lazy dog', 'every good boy does fine', 'pack my box with five dozen liquor jugs']) == 9\n assert candidate(sentences = ['a b c d e f g h i j k l m n o p q r s t u v w x y z', 'short sentence']) == 26\n assert candidate(sentences = ['one', 'two three', 'four five six', 'seven eight nine ten', 'eleven twelve thirteen fourteen fifteen']) == 5\n assert candidate(sentences = ['the quick brown fox jumps over the lazy dog', 'pack my box with five dozen liquor jugs', 'how vexingly quick daft zebras jump']) == 9\n assert candidate(sentences = ['repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat', 'different repeat different repeat', 'unique sentence']) == 10\n assert candidate(sentences = ['a quick brown fox jumps over the lazy dog', 'this is a longer sentence with more words in it', 'short']) == 10\n assert candidate(sentences = ['equal length words here', 'equal length words here', 'equal length words here']) == 4\n assert candidate(sentences = ['one two three four five', 'six seven eight nine ten eleven', 'twelve thirteen fourteen fifteen sixteen seventeen', 'eighteen nineteen twenty']) == 6\n assert candidate(sentences = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'mnopqrstuvwxyzabcdefghijkl']) == 1\n assert candidate(sentences = ['equal length', 'equal length', 'equal length', 'equal length', 'equal length', 'equal length']) == 2\n assert candidate(sentences = ['lorem ipsum dolor sit amet', 'consectetur adipiscing elit', 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua']) == 11\n assert candidate(sentences = ['the quick brown fox jumps over the lazy dog', 'a quick movement of the enemy will jeopardize six gunboats', 'five boxing wizards jump quickly']) == 10\n assert candidate(sentences = ['an apple a day keeps the doctor away', 'once upon a time in a land far far away', 'hello world hello universe']) == 10\n assert candidate(sentences = ['the longest sentence in this list is the last one which contains many many words indeed']) == 16\n assert candidate(sentences = ['the quick brown fox jumps over the lazy dog', 'how now brown cow', 'she sells sea shells by the sea shore']) == 9\n assert candidate(sentences = ['a b c d e f g h i j k l m n o p q r s t u v w x y z', 'jumps over the lazy dog']) == 26\n assert candidate(sentences = ['the secret to a happy life is simple', 'be kind to others', 'live each day to the fullest', 'love what you do']) == 8\n assert candidate(sentences = ['a b c d e f g h i j k l m n o p q r s t u v w x y z', 'i am a sentence with many words indeed', 'this is another test sentence']) == 26\n assert candidate(sentences = ['abc', 'def ghi jkl', 'mno pqr stu vwx yz', 'a b c d e f g h i j k l m n o p q r s t u v w x y z']) == 26\n assert candidate(sentences = ['python is a great programming language', 'java is also a great programming language', 'c plus plus is another popular language']) == 7\n assert candidate(sentences = ['singleword', 'two words', 'three words here', 'four words are in this', 'five words make a phrase', 'six words is a complete sentence']) == 6\n assert candidate(sentences = ['longer sentences are more challenging to process correctly', 'even longer sentences that contain a greater number of words for testing', 'tiny']) == 12\n assert candidate(sentences = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij']) == 1\n assert candidate(sentences = ['to be or not to be that is the question', 'that is the question indeed', 'whether tis nobler in the mind to suffer']) == 10\n assert candidate(sentences = ['python is great', 'i love programming', 'data science is fascinating', 'machine learning and ai are transforming industries']) == 7\n assert candidate(sentences = ['this is a very long sentence indeed that should test the boundaries of the problem constraints']) == 16\n assert candidate(sentences = ['singleword', 'two words', 'three words here', 'four words make a sentence', 'five words in this sentence']) == 5\n assert candidate(sentences = ['complex sentences are interesting', 'they can have many clauses and ideas', 'and sometimes they even have subordinate clauses']) == 7\n assert candidate(sentences = ['very very very long sentence to test the length', 'short sentence', 'another medium length sentence here']) == 9\n assert candidate(sentences = ['very long sentence with many many many words indeed', 'short one', 'medium length sentence']) == 9\n assert candidate(sentences = ['a singleword', 'two words here', 'three words in this', 'four words make up']) == 4\n assert candidate(sentences = ['this is a sentence with seven words', 'another one with five words', 'and yet another with eight words here']) == 7\n assert candidate(sentences = ['a b c d e f g h i j k l m n o p q r s t u v w x y z', 'the cat in the hat']) == 26\n assert candidate(sentences = ['this is a longer sentence with more words', 'tiny', 'another sentence with quite a few words indeed']) == 8\n assert candidate(sentences = ['python is an amazing language for data science and machine learning', 'the early morning sun illuminated the dew covered grass', 'she sells sea shells by the sea shore']) == 11\n assert candidate(sentences = ['same same same same same same same', 'another same same same', 'and yet another same same']) == 7\n assert candidate(sentences = ['one', 'two three', 'four five six', 'seven eight nine ten']) == 4\n", "comparison": "exact"}, "public_tests": ["[\"alice and bob love leetcode\",\"i think so too\",\"this is great thanks very much\"]", "[\"please wait\",\"continue to fight\",\"continue to win\"]"], "hints": ["Process each sentence separately and count the number of words by looking for the number of space characters in the sentence and adding it by 1."], "metadata": {"canonical_parameter_names": ["sentences"], "leetcode_dataset_entry_point": "Solution().mostWordsFound", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:36+00:00", "tests_total": 78, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "string"]}, "language": "python", "interface": {"raw_signature": "def mostWordsFound(self, sentences: list[str]) -> int:", "container": "Solution", "callable": "mostWordsFound", "parameters": [{"name": "sentences", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2115, "task_id": "find-all-possible-recipes-from-given-supplies", "difficulty": "Medium", "problem_description": "You have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The i^th recipe has the name recipes[i], and you can create it if you have all the needed ingredients from ingredients[i]. A recipe can also be an ingredient for other recipes, i.e., ingredients[i] may contain a string that is in recipes.\n\nYou are also given a string array supplies containing all the ingredients that you initially have, and you have an infinite supply of all of them.\n\nReturn a list of all the recipes that you can create. You may return the answer in any order.\n\nNote that two recipes may contain each other in their ingredients.\n\nExample 1:\n\nInput: recipes = [\"bread\"], ingredients = [[\"yeast\",\"flour\"]], supplies = [\"yeast\",\"flour\",\"corn\"]\nOutput: [\"bread\"]\nExplanation:\nWe can create \"bread\" since we have the ingredients \"yeast\" and \"flour\".\n\nExample 2:\n\nInput: recipes = [\"bread\",\"sandwich\"], ingredients = [[\"yeast\",\"flour\"],[\"bread\",\"meat\"]], supplies = [\"yeast\",\"flour\",\"meat\"]\nOutput: [\"bread\",\"sandwich\"]\nExplanation:\nWe can create \"bread\" since we have the ingredients \"yeast\" and \"flour\".\nWe can create \"sandwich\" since we have the ingredient \"meat\" and can create the ingredient \"bread\".\n\nExample 3:\n\nInput: recipes = [\"bread\",\"sandwich\",\"burger\"], ingredients = [[\"yeast\",\"flour\"],[\"bread\",\"meat\"],[\"sandwich\",\"meat\",\"bread\"]], supplies = [\"yeast\",\"flour\",\"meat\"]\nOutput: [\"bread\",\"sandwich\",\"burger\"]\nExplanation:\nWe can create \"bread\" since we have the ingredients \"yeast\" and \"flour\".\nWe can create \"sandwich\" since we have the ingredient \"meat\" and can create the ingredient \"bread\".\nWe can create \"burger\" since we have the ingredient \"meat\" and can create the ingredients \"bread\" and \"sandwich\".\n\nConstraints:\n\n- n == recipes.length == ingredients.length\n- 1 <= n <= 100\n- 1 <= ingredients[i].length, supplies.length <= 100\n- 1 <= recipes[i].length, ingredients[i][j].length, supplies[k].length <= 10\n- recipes[i], ingredients[i][j], and supplies[k] consist only of lowercase English letters.\n- All the values of recipes and supplies combined are unique.\n- Each ingredients[i] does not contain any duplicate values.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(recipes=['bread', 'sandwich'], ingredients=[['yeast', 'flour'], ['bread', 'meat']], supplies=['yeast', 'flour', 'meat']), ['bread', 'sandwich'])\n assert answers_match(candidate(recipes=['pasta', 'salad'], ingredients=[['noodles', 'sauce'], ['lettuce', 'tomato']], supplies=['noodles', 'sauce', 'lettuce']), ['pasta'])\n assert answers_match(candidate(recipes=['bread', 'sandwich', 'burger'], ingredients=[['yeast', 'flour'], ['bread', 'meat'], ['sandwich', 'meat', 'bread']], supplies=['yeast', 'flour', 'meat']), ['bread', 'sandwich', 'burger'])\n assert answers_match(candidate(recipes=['cake', 'muffin'], ingredients=[['flour', 'sugar'], ['flour', 'eggs']], supplies=['flour', 'sugar']), ['cake'])\n assert answers_match(candidate(recipes=['bread'], ingredients=[['yeast', 'flour']], supplies=['yeast', 'flour', 'corn']), ['bread'])\n assert answers_match(candidate(recipes=['cake', 'muffin', 'brownie'], ingredients=[['flour', 'sugar', 'eggs'], ['flour', 'sugar', 'butter'], ['flour', 'sugar', 'chocolate']], supplies=['flour', 'sugar', 'eggs']), ['cake'])\n assert answers_match(candidate(recipes=['cake', 'muffin'], ingredients=[['flour', 'sugar', 'eggs'], ['flour', 'sugar', 'eggs', 'butter']], supplies=['flour', 'sugar', 'eggs', 'butter']), ['cake', 'muffin'])\n assert answers_match(candidate(recipes=['pizza', 'pasta'], ingredients=[['dough', 'tomato', 'cheese'], ['noodles', 'sauce']], supplies=['dough', 'tomato', 'cheese', 'noodles', 'sauce']), ['pizza', 'pasta'])\n assert answers_match(candidate(recipes=['soup', 'stew'], ingredients=[['water', 'vegetables', 'spices'], ['water', 'meat', 'vegetables', 'spices']], supplies=['water', 'vegetables', 'spices']), ['soup'])\n assert answers_match(candidate(recipes=['sushi', 'ramen'], ingredients=[['rice', 'seaweed', 'salmon'], ['noodles', 'water', 'meat', 'vegetables']], supplies=['rice', 'noodles', 'water', 'meat']), [])\n assert answers_match(candidate(recipes=['cake', 'pudding', 'pie'], ingredients=[['flour', 'sugar', 'eggs'], ['milk', 'sugar', 'flour'], ['crust', 'fruit', 'filling']], supplies=['flour', 'sugar', 'eggs', 'milk', 'crust', 'fruit', 'filling']), ['cake', 'pudding', 'pie'])\n assert answers_match(candidate(recipes=['cake', 'brownie'], ingredients=[['flour', 'sugar', 'eggs'], ['flour', 'cocoa', 'sugar']], supplies=['flour', 'sugar', 'eggs']), ['cake'])\n assert answers_match(candidate(recipes=['omelette', 'pancake', 'waffle'], ingredients=[['eggs', 'milk'], ['flour', 'eggs', 'milk'], ['flour', 'eggs', 'milk', 'butter']], supplies=['eggs', 'milk', 'flour', 'butter', 'sugar']), ['omelette', 'pancake', 'waffle'])\n assert answers_match(candidate(recipes=['bread', 'sandwich', 'burger', 'wrap'], ingredients=[['yeast', 'flour'], ['bread', 'meat'], ['bread', 'meat', 'cheese'], ['bread', 'cheese', 'lettuce']], supplies=['yeast', 'flour', 'meat', 'cheese', 'lettuce']), ['bread', 'sandwich', 'burger', 'wrap'])\n assert answers_match(candidate(recipes=['soup', 'stew'], ingredients=[['carrot', 'onion'], ['carrot', 'potato', 'beef']], supplies=['carrot', 'onion', 'beef', 'potato', 'pepper']), ['soup', 'stew'])\n assert answers_match(candidate(recipes=['pizza', 'pasta', 'omelette'], ingredients=[['dough', 'tomato', 'cheese'], ['noodles', 'sauce'], ['eggs', 'milk']], supplies=['dough', 'tomato', 'cheese', 'noodles', 'sauce', 'eggs', 'milk', 'flour']), ['pizza', 'pasta', 'omelette'])\n assert answers_match(candidate(recipes=['juice', 'smoothie'], ingredients=[['fruit', 'water'], ['fruit', 'yogurt', 'banana']], supplies=['fruit', 'water', 'yogurt', 'banana', 'milk']), ['juice', 'smoothie'])\n assert answers_match(candidate(recipes=['steak', 'chicken', 'beef'], ingredients=[['beef', 'salt'], ['chicken', 'pepper'], ['salt', 'spice']], supplies=['salt', 'pepper', 'spice', 'chicken']), ['beef', 'chicken', 'steak'])\n assert answers_match(candidate(recipes=['soup', 'stew'], ingredients=[['water', 'vegetables', 'meat'], ['water', 'vegetables', 'meat', 'tomato']], supplies=['water', 'vegetables', 'meat', 'tomato', 'salt']), ['soup', 'stew'])\n assert answers_match(candidate(recipes=['pizza', 'taco', 'pasta'], ingredients=[['dough', 'tomato', 'cheese'], ['tortilla', 'meat', 'cheese'], ['noodles', 'sauce', 'meat']], supplies=['dough', 'tomato', 'cheese', 'tortilla', 'meat', 'noodles', 'sauce']), ['pizza', 'taco', 'pasta'])\n assert answers_match(candidate(recipes=['smoothie', 'juice'], ingredients=[['banana', 'orange', 'milk'], ['apple', 'orange', 'water']], supplies=['banana', 'orange', 'water']), [])\n assert answers_match(candidate(recipes=['omelette', 'frittata'], ingredients=[['eggs', 'cheese'], ['eggs', 'cheese', 'spinach', 'tomato']], supplies=['eggs', 'cheese', 'spinach']), ['omelette'])\n assert answers_match(candidate(recipes=['omelette', 'pancakes'], ingredients=[['eggs', 'milk'], ['eggs', 'flour', 'milk']], supplies=['eggs', 'milk', 'flour', 'butter']), ['omelette', 'pancakes'])\n assert answers_match(candidate(recipes=['sandwich', 'burger', 'omelet'], ingredients=[['bread', 'meat', 'cheese'], ['bread', 'patty', 'cheese'], ['eggs', 'cheese', 'spinach']], supplies=['bread', 'meat', 'cheese', 'patty', 'eggs', 'spinach']), ['sandwich', 'burger', 'omelet'])\n assert answers_match(candidate(recipes=['cake', 'brownie'], ingredients=[['sugar', 'flour', 'eggs'], ['sugar', 'chocolate', 'eggs']], supplies=['sugar', 'eggs']), [])\n assert answers_match(candidate(recipes=['cake', 'pie', 'tiramisu'], ingredients=[['flour', 'eggs', 'sugar'], ['apple', 'flour', 'sugar'], ['cake', 'coffee', 'mascarpone']], supplies=['flour', 'eggs', 'sugar', 'apple', 'coffee', 'mascarpone']), ['cake', 'pie', 'tiramisu'])\n assert answers_match(candidate(recipes=['soup', 'stew', 'salad', 'sandwich'], ingredients=[['carrot', 'onion'], ['carrot', 'potato', 'beef'], ['lettuce', 'cucumber'], ['bread', 'cheese']], supplies=['carrot', 'onion', 'beef', 'potato', 'pepper', 'lettuce', 'cucumber', 'bread', 'cheese', 'eggs']), ['soup', 'stew', 'salad', 'sandwich'])\n assert answers_match(candidate(recipes=['pancake', 'waffle', 'muffin'], ingredients=[['flour', 'eggs', 'milk'], ['flour', 'eggs', 'milk', 'butter'], ['flour', 'sugar', 'eggs']], supplies=['flour', 'eggs', 'milk', 'butter', 'sugar']), ['pancake', 'waffle', 'muffin'])\n assert answers_match(candidate(recipes=['pizza', 'pasta', 'soup'], ingredients=[['dough', 'tomato', 'cheese'], ['noodles', 'sauce'], ['carrots', 'onions', 'water']], supplies=['dough', 'tomato', 'noodles', 'carrots']), [])\n assert answers_match(candidate(recipes=['a', 'b', 'c', 'd'], ingredients=[['e', 'f'], ['a', 'g'], ['b', 'h'], ['c', 'i']], supplies=['e', 'f', 'g', 'h', 'i']), ['a', 'b', 'c', 'd'])\n assert answers_match(candidate(recipes=['beer', 'wine'], ingredients=[['grains', 'water', 'hops'], ['grapes', 'yeast', 'sugar']], supplies=['grains', 'water', 'hops', 'grapes', 'yeast', 'sugar']), ['beer', 'wine'])\n assert answers_match(candidate(recipes=['pizza', 'pasta', 'salad'], ingredients=[['dough', 'sauce', 'cheese'], ['noodles', 'sauce'], ['lettuce', 'tomato']], supplies=['dough', 'cheese', 'noodles', 'sauce', 'lettuce', 'tomato', 'spinach']), ['pizza', 'pasta', 'salad'])\n assert answers_match(candidate(recipes=['smoothie', 'juice'], ingredients=[['banana', 'strawberry', 'milk'], ['apple', 'orange', 'water']], supplies=['banana', 'strawberry', 'milk', 'apple', 'orange']), ['smoothie'])\n assert answers_match(candidate(recipes=['omelette', 'pancake'], ingredients=[['eggs', 'milk'], ['flour', 'eggs', 'milk']], supplies=['eggs', 'milk', 'flour', 'butter']), ['omelette', 'pancake'])\n assert answers_match(candidate(recipes=['bread', 'toast', 'baguette'], ingredients=[['flour', 'yeast'], ['bread'], ['flour', 'yeast', 'oil']], supplies=['flour', 'yeast', 'oil', 'butter']), ['bread', 'baguette', 'toast'])\n assert answers_match(candidate(recipes=['soup', 'stew', 'omelette'], ingredients=[['water', 'vegetables', 'salt'], ['water', 'meat', 'vegetables'], ['eggs', 'cheese', 'pepper']], supplies=['water', 'vegetables', 'meat', 'eggs', 'cheese', 'pepper']), ['stew', 'omelette'])\n assert answers_match(candidate(recipes=['pizza', 'fries', 'burger'], ingredients=[['dough', 'tomato', 'cheese'], ['potato', 'salt'], ['patty', 'cheese', 'bun']], supplies=['dough', 'tomato', 'cheese', 'potato', 'salt', 'patty', 'bun']), ['pizza', 'fries', 'burger'])\n assert answers_match(candidate(recipes=['sushi', 'ramen'], ingredients=[['rice', 'fish', 'seaweed'], ['noodles', 'broth', 'egg']], supplies=['rice', 'fish', 'seaweed', 'noodles', 'broth', 'egg']), ['sushi', 'ramen'])\n assert answers_match(candidate(recipes=['soup', 'stew', 'salad'], ingredients=[['carrot', 'onion'], ['carrot', 'potato', 'beef'], ['lettuce', 'cucumber']], supplies=['carrot', 'onion', 'beef', 'potato', 'pepper', 'lettuce', 'cucumber']), ['soup', 'stew', 'salad'])\n assert answers_match(candidate(recipes=['cake', 'pie'], ingredients=[['flour', 'eggs', 'sugar'], ['apple', 'flour', 'sugar']], supplies=['flour', 'eggs', 'sugar', 'milk']), ['cake'])\n assert answers_match(candidate(recipes=['pasta', 'pizza', 'lasagna'], ingredients=[['noodles', 'sauce'], ['dough', 'sauce', 'cheese'], ['noodles', 'sauce', 'cheese', 'milk']], supplies=['noodles', 'sauce', 'cheese', 'dough', 'milk']), ['pasta', 'pizza', 'lasagna'])\n assert answers_match(candidate(recipes=['omelette', 'pancake'], ingredients=[['eggs', 'cheese', 'bacon'], ['flour', 'eggs', 'milk']], supplies=['eggs', 'flour', 'milk']), ['pancake'])\n assert answers_match(candidate(recipes=['pizza', 'sandwich', 'omelette', 'burger'], ingredients=[['dough', 'tomato', 'cheese'], ['bread', 'cheese', 'meat'], ['egg', 'milk', 'cheese'], ['patty', 'cheese', 'bun']], supplies=['dough', 'tomato', 'cheese', 'bread', 'meat', 'egg', 'milk', 'patty', 'bun']), ['pizza', 'sandwich', 'omelette', 'burger'])\n assert answers_match(candidate(recipes=['cake', 'pudding', 'pie'], ingredients=[['flour', 'eggs', 'sugar'], ['milk', 'cornstarch'], ['crust', 'apple', 'sugar']], supplies=['flour', 'eggs', 'milk', 'sugar']), ['cake'])\n assert answers_match(candidate(recipes=['salad', 'soup', 'stew'], ingredients=[['lettuce', 'tomato', 'onion'], ['carrot', 'potato', 'beef'], ['carrot', 'potato', 'beef', 'tomato']], supplies=['lettuce', 'tomato', 'onion', 'carrot', 'potato']), ['salad'])\n assert answers_match(candidate(recipes=['omelette', 'scramble', 'frittata'], ingredients=[['eggs', 'cheese'], ['eggs'], ['eggs', 'cheese', 'spinach']], supplies=['eggs', 'cheese', 'spinach', 'milk']), ['scramble', 'omelette', 'frittata'])\n assert answers_match(candidate(recipes=['cake', 'brownie', 'pudding'], ingredients=[['flour', 'sugar', 'eggs', 'milk'], ['flour', 'sugar', 'chocolate'], ['milk', 'sugar', 'gelatin']], supplies=['flour', 'sugar', 'eggs', 'milk', 'chocolate', 'gelatin']), ['cake', 'brownie', 'pudding'])\n assert answers_match(candidate(recipes=['soup', 'stew', 'chili'], ingredients=[['water', 'carrot', 'potato'], ['water', 'tomato', 'carrot', 'potato'], ['water', 'tomato', 'beef', 'potato']], supplies=['water', 'carrot', 'potato', 'tomato', 'beef']), ['soup', 'stew', 'chili'])\n assert answers_match(candidate(recipes=['pizza', 'lasagna', 'taco'], ingredients=[['dough', 'tomato', 'cheese'], ['pasta', 'mozzarella', 'sauce'], ['tortilla', 'meat', 'cheese']], supplies=['dough', 'tomato', 'cheese', 'pasta', 'mozzarella', 'sauce', 'tortilla', 'meat']), ['pizza', 'lasagna', 'taco'])\n assert answers_match(candidate(recipes=['bread', 'cake', 'pudding'], ingredients=[['flour', 'yeast', 'water'], ['flour', 'eggs', 'sugar'], ['milk', 'cornstarch', 'water']], supplies=['flour', 'yeast', 'eggs', 'sugar', 'milk']), ['cake'])\n assert answers_match(candidate(recipes=['cake', 'brownie', 'tiramisu'], ingredients=[['flour', 'sugar', 'eggs'], ['flour', 'sugar', 'chocolate'], ['coffee', 'brownie', 'cream']], supplies=['flour', 'sugar', 'eggs', 'chocolate', 'coffee', 'cream']), ['cake', 'brownie', 'tiramisu'])\n assert answers_match(candidate(recipes=['pizza', 'calzone', 'taco', 'burrito'], ingredients=[['dough', 'sauce', 'cheese'], ['dough', 'cheese', 'meat'], ['tortilla', 'meat', 'lettuce'], ['tortilla', 'meat', 'beans']], supplies=['dough', 'sauce', 'cheese', 'meat', 'tortilla', 'lettuce', 'beans']), ['pizza', 'calzone', 'taco', 'burrito'])\n assert answers_match(candidate(recipes=['steak', 'chicken', 'beef'], ingredients=[['meat', 'seasoning'], ['meat', 'vegetables'], ['meat', 'sauce']], supplies=['meat', 'seasoning', 'vegetables']), ['steak', 'chicken'])\n assert answers_match(candidate(recipes=['taco', 'burrito'], ingredients=[['tortilla', 'beef', 'cheese'], ['tortilla', 'chicken', 'cheese', 'lettuce']], supplies=['tortilla', 'cheese', 'lettuce']), [])\n assert answers_match(candidate(recipes=['muffin', 'brownie', 'cupcake'], ingredients=[['flour', 'eggs', 'milk', 'sugar'], ['flour', 'eggs', 'chocolate', 'sugar'], ['muffin', 'icing']], supplies=['flour', 'eggs', 'milk', 'sugar', 'chocolate', 'icing']), ['muffin', 'brownie', 'cupcake'])\n assert answers_match(candidate(recipes=['soup', 'stew'], ingredients=[['water', 'carrot', 'potato'], ['water', 'tomato', 'carrot', 'potato']], supplies=['water', 'carrot', 'potato', 'tomato']), ['soup', 'stew'])\n assert answers_match(candidate(recipes=['taco', 'burrito'], ingredients=[['shell', 'meat', 'cheese'], ['wrap', 'meat', 'cheese', 'lettuce']], supplies=['shell', 'wrap', 'meat', 'cheese', 'lettuce', 'tomato']), ['taco', 'burrito'])\n assert answers_match(candidate(recipes=['cake', 'brownie'], ingredients=[['flour', 'eggs', 'sugar'], ['flour', 'eggs', 'chocolate']], supplies=['flour', 'eggs', 'sugar', 'chocolate']), ['cake', 'brownie'])\n assert answers_match(candidate(recipes=['cake', 'muffin', 'brownie'], ingredients=[['flour', 'sugar', 'eggs'], ['flour', 'sugar', 'eggs', 'butter'], ['flour', 'sugar', 'chocolate']], supplies=['flour', 'sugar', 'eggs', 'butter', 'chocolate']), ['cake', 'muffin', 'brownie'])\n assert answers_match(candidate(recipes=['muffin', 'pancake', 'scone'], ingredients=[['flour', 'sugar', 'milk'], ['flour', 'eggs', 'milk'], ['flour', 'butter', 'milk']], supplies=['flour', 'eggs', 'butter', 'milk']), ['pancake', 'scone'])\n assert answers_match(candidate(recipes=['juice', 'smoothie'], ingredients=[['orange', 'apple'], ['banana', 'orange', 'milk']], supplies=['orange', 'apple', 'banana', 'milk', 'water']), ['juice', 'smoothie'])\n assert answers_match(candidate(recipes=['pancake', 'waffle', 'omelette'], ingredients=[['flour', 'eggs', 'milk'], ['flour', 'eggs', 'syrup'], ['eggs', 'milk', 'cheese']], supplies=['flour', 'eggs', 'milk', 'syrup', 'cheese']), ['pancake', 'waffle', 'omelette'])\n assert answers_match(candidate(recipes=['pizza', 'pasta'], ingredients=[['dough', 'sauce', 'cheese'], ['noodles', 'sauce']], supplies=['dough', 'sauce', 'cheese', 'noodles', 'tomato']), ['pizza', 'pasta'])\n assert answers_match(candidate(recipes=['pizza', 'spaghetti'], ingredients=[['dough', 'sauce', 'cheese'], ['pasta', 'sauce', 'meat']], supplies=['dough', 'sauce', 'pasta']), [])\n", "comparison": "unordered"}, "public_tests": ["[\"bread\"]\n[[\"yeast\",\"flour\"]]\n[\"yeast\",\"flour\",\"corn\"]", "[\"bread\",\"sandwich\"]\n[[\"yeast\",\"flour\"],[\"bread\",\"meat\"]]\n[\"yeast\",\"flour\",\"meat\"]", "[\"bread\",\"sandwich\",\"burger\"]\n[[\"yeast\",\"flour\"],[\"bread\",\"meat\"],[\"sandwich\",\"meat\",\"bread\"]]\n[\"yeast\",\"flour\",\"meat\"]"], "hints": ["Can we use a data structure to quickly query whether we have a certain ingredient?", "Once we verify that we can make a recipe, we can add it to our ingredient data structure. We can then check if we can make more recipes as a result of this."], "metadata": {"canonical_parameter_names": ["recipes", "ingredients", "supplies"], "leetcode_dataset_entry_point": "Solution().findAllRecipes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:39+00:00", "tests_total": 103, "tests_dropped": 39, "flags": ["any_order"], "topic_tags": ["array", "hash-table", "string", "graph", "topological-sort", "directed-acyclic-graph"]}, "language": "python", "interface": {"raw_signature": "def findAllRecipes(self, recipes: list[str], ingredients: list[list[str]], supplies: list[str]) -> list[str]:", "container": "Solution", "callable": "findAllRecipes", "parameters": [{"name": "recipes", "type": "list[str]"}, {"name": "ingredients", "type": "list[list[str]]"}, {"name": "supplies", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2116, "task_id": "check-if-a-parentheses-string-can-be-valid", "difficulty": "Medium", "problem_description": "A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true:\n\n- It is ().\n- It can be written as AB (A concatenated with B), where A and B are valid parentheses strings.\n- It can be written as (A), where A is a valid parentheses string.\n\nYou are given a parentheses string s and a string locked, both of length n. locked is a binary string consisting only of '0's and '1's. For each index i of locked,\n\n- If locked[i] is '1', you cannot change s[i].\n- But if locked[i] is '0', you can change s[i] to either '(' or ')'.\n\nReturn true if you can make s a valid parentheses string. Otherwise, return false.\n\nExample 1:\n\nInput: s = \"))()))\", locked = \"010100\"\nOutput: true\nExplanation: locked[1] == '1' and locked[3] == '1', so we cannot change s[1] or s[3].\nWe change s[0] and s[4] to '(' while leaving s[2] and s[5] unchanged to make s valid.\n\nExample 2:\n\nInput: s = \"()()\", locked = \"0000\"\nOutput: true\nExplanation: We do not need to make any changes because s is already valid.\n\nExample 3:\n\nInput: s = \")\", locked = \"0\"\nOutput: false\nExplanation: locked permits us to change s[0].\nChanging s[0] to either '(' or ')' will not make s valid.\n\nExample 4:\n\nInput: s = \"(((())(((())\", locked = \"111111010111\"\nOutput: true\nExplanation: locked permits us to change s[6] and s[8].\nWe change s[6] and s[8] to ')' to make s valid.\n\nConstraints:\n\n- n == s.length == locked.length\n- 1 <= n <= 10^5\n- s[i] is either '(' or ')'.\n- locked[i] is either '0' or '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(((())(((())\",locked = \"111111010111\") == True\n assert candidate(s = \"()))()\",locked = \"010100\") == True\n assert candidate(s = \"()()\",locked = \"0000\") == True\n assert candidate(s = \")\",locked = \"0\") == False\n assert candidate(s = \"()()()()()()()()\",locked = \"0000000000000000\") == True\n assert candidate(s = \"(((((())))))\",locked = \"000000000000\") == True\n assert candidate(s = \"((((()))))))\",locked = \"000111000111\") == True\n assert candidate(s = \"(()())\",locked = \"100101\") == True\n assert candidate(s = \"((()()(()))\",locked = \"10000000000\") == False\n assert candidate(s = \"(((())))()()\",locked = \"000010000000\") == True\n assert candidate(s = \"()((()))()((()))\",locked = \"0011110000111100\") == True\n assert candidate(s = \"(()())\",locked = \"000000\") == True\n assert candidate(s = \"(()(()))\",locked = \"00101000\") == True\n assert candidate(s = \"((()()(())))\",locked = \"010000101001\") == True\n assert candidate(s = \"((((((()))))\",locked = \"000000000001\") == True\n assert candidate(s = \"(()))(\",locked = \"101010\") == True\n assert candidate(s = \"((((((((((((()))))))))))\",locked = \"111111111111110000000000\") == False\n assert candidate(s = \"(((((())))()())\",locked = \"010010000001000\") == False\n assert candidate(s = \"((())())\",locked = \"10010010\") == True\n assert candidate(s = \"((((()))))((((()))))\",locked = \"11111111111111111111\") == True\n assert candidate(s = \"()()(()(()))\",locked = \"000001100100\") == True\n assert candidate(s = \"(()(()(()(()))))\",locked = \"1010101010101010\") == True\n assert candidate(s = \"((((((()))))))\",locked = \"01010101010101\") == True\n assert candidate(s = \"(((())))(((())))\",locked = \"1111111111111111\") == True\n assert candidate(s = \"())(()\",locked = \"001010\") == True\n assert candidate(s = \"(((())))\",locked = \"11111111\") == True\n assert candidate(s = \"((()))\",locked = \"000000\") == True\n assert candidate(s = \"((())()(()))\",locked = \"110101001101\") == True\n assert candidate(s = \"(((((())))))\",locked = \"111111100001\") == True\n assert candidate(s = \"((())()(()))\",locked = \"101010101010\") == True\n assert candidate(s = \"(((((())))))\",locked = \"111100001111\") == True\n assert candidate(s = \"(((((((())))))))\",locked = \"0101010101010101\") == True\n assert candidate(s = \"()()()()\",locked = \"11111111\") == True\n assert candidate(s = \")()(()(()))(\",locked = \"010101010100\") == True\n assert candidate(s = \"()()()()()()()()()()\",locked = \"00000000000000000000\") == True\n assert candidate(s = \"(()(()))()()\",locked = \"010100101000\") == True\n assert candidate(s = \"(()(()))((()(())))\",locked = \"010010010010110010\") == True\n assert candidate(s = \"()(()())\",locked = \"10010010\") == True\n assert candidate(s = \"(()())((()))\",locked = \"000000000000\") == True\n assert candidate(s = \"((())()(()))\",locked = \"101001010100\") == True\n assert candidate(s = \"((())()(()))\",locked = \"000000000000\") == True\n assert candidate(s = \"()()()()\",locked = \"00000000\") == True\n assert candidate(s = \"(((((())))))\",locked = \"011100111001\") == True\n assert candidate(s = \"(()())()()()\",locked = \"000000000000\") == True\n assert candidate(s = \")(()(()(()))\",locked = \"011001101001\") == True\n", "comparison": "exact"}, "public_tests": ["\"))()))\"\n\"010100\"", "\"()()\"\n\"0000\"", "\")\"\n\"0\"", "\"(((())(((())\"\n\"111111010111\""], "hints": ["Can an odd length string ever be valid?", "From left to right, if a locked ')' is encountered, it must be balanced with either a locked '(' or an unlocked index on its left. If neither exist, what conclusion can be drawn? If both exist, which one is more preferable to use?", "After the above, we may have locked indices of '(' and additional unlocked indices. How can you balance out the locked '(' now? What if you cannot balance any locked '('?"], "metadata": {"canonical_parameter_names": ["s", "locked"], "leetcode_dataset_entry_point": "Solution().canBeValid", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:41+00:00", "tests_total": 81, "tests_dropped": 36, "flags": ["has_images"], "topic_tags": ["string", "stack", "greedy", "bracket-sequences"]}, "language": "python", "interface": {"raw_signature": "def canBeValid(self, s: str, locked: str) -> bool:", "container": "Solution", "callable": "canBeValid", "parameters": [{"name": "s", "type": "str"}, {"name": "locked", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2117, "task_id": "abbreviating-the-product-of-a-range", "difficulty": "Hard", "problem_description": "You are given two positive integers left and right with left <= right. Calculate the product of all integers in the inclusive range [left, right].\n\nSince the product may be very large, you will abbreviate it following these steps:\n\n1. Count all trailing zeros in the product and remove them. Let us denote this count as C.\n - For example, there are 3 trailing zeros in 1000, and there are 0 trailing zeros in 546.\n2. Denote the remaining number of digits in the product as d. If d > 10, then express the product as
... where 
 denotes the first 5 digits of the product, and  denotes the last 5 digits of the product after removing all trailing zeros. If d <= 10, we keep it unchanged.\n  - For example, we express 1234567654321 as 12345...54321, but 1234567 is represented as 1234567.\n3. Finally, represent the product as a string \"
...eC\".\n  - For example, 12345678987600000 will be represented as \"12345...89876e5\".\n\nReturn a string denoting the abbreviated product of all integers in the inclusive range [left, right].\n\nExample 1:\n\nInput: left = 1, right = 4\nOutput: \"24e0\"\nExplanation: The product is 1 × 2 × 3 × 4 = 24.\nThere are no trailing zeros, so 24 remains the same. The abbreviation will end with \"e0\".\nSince the number of digits is 2, which is less than 10, we do not have to abbreviate it further.\nThus, the final representation is \"24e0\".\n\nExample 2:\n\nInput: left = 2, right = 11\nOutput: \"399168e2\"\nExplanation: The product is 39916800.\nThere are 2 trailing zeros, which we remove to get 399168. The abbreviation will end with \"e2\".\nThe number of digits after removing the trailing zeros is 6, so we do not abbreviate it further.\nHence, the abbreviated product is \"399168e2\".\n\nExample 3:\n\nInput: left = 371, right = 375\nOutput: \"7219856259e3\"\nExplanation: The product is 7219856259000.\n\nConstraints:\n\n- 1 <= left <= right <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(left = 100,right = 105) == \"1158727752e3\"\n    assert candidate(left = 1,right = 10000) == \"28462...79008e2499\"\n    assert candidate(left = 10,right = 20) == \"6704425728e3\"\n    assert candidate(left = 371,right = 375) == \"7219856259e3\"\n    assert candidate(left = 1000,right = 1010) == \"10563...82688e5\"\n    assert candidate(left = 5000,right = 5010) == \"49367...34144e6\"\n    assert candidate(left = 1234,right = 1238) == \"28846...40584e1\"\n    assert candidate(left = 999,right = 1000) == \"999e3\"\n    assert candidate(left = 1,right = 10) == \"36288e2\"\n    assert candidate(left = 1234,right = 1240) == \"44318...63424e2\"\n    assert candidate(left = 5,right = 5) == \"5e0\"\n    assert candidate(left = 1000,right = 1000) == \"1e3\"\n    assert candidate(left = 10,right = 15) == \"36036e2\"\n    assert candidate(left = 1000,right = 1004) == \"10100...50024e3\"\n    assert candidate(left = 500,right = 510) == \"54464...59744e5\"\n    assert candidate(left = 1,right = 100) == \"93326...16864e24\"\n    assert candidate(left = 995,right = 1000) == \"98508...27388e4\"\n    assert candidate(left = 9995,right = 10000) == \"99850...73988e5\"\n    assert candidate(left = 1,right = 4) == \"24e0\"\n    assert candidate(left = 2,right = 11) == \"399168e2\"\n    assert candidate(left = 500,right = 505) == \"16099...69356e4\"\n    assert candidate(left = 5000,right = 5005) == \"15671...18506e5\"\n    assert candidate(left = 5,right = 10) == \"1512e2\"\n    assert candidate(left = 8000,right = 8003) == \"40990...04048e3\"\n    assert candidate(left = 5555,right = 6666) == \"28137...34688e279\"\n    assert candidate(left = 9000,right = 9005) == \"53232...19508e4\"\n    assert candidate(left = 100,right = 150) == \"61219...44768e15\"\n    assert candidate(left = 5,right = 20) == \"10137...00736e4\"\n    assert candidate(left = 3000,right = 3100) == \"81710...90592e27\"\n    assert candidate(left = 1234,right = 1244) == \"10562...94176e2\"\n    assert candidate(left = 1,right = 5000) == \"42285...33472e1249\"\n    assert candidate(left = 9000,right = 9050) == \"53429...51328e15\"\n    assert candidate(left = 100,right = 1000) == \"43116...46048e227\"\n    assert candidate(left = 6000,right = 6005) == \"46772...86472e4\"\n    assert candidate(left = 7000,right = 7020) == \"57553...63648e7\"\n    assert candidate(left = 100,right = 200) == \"84505...02048e27\"\n    assert candidate(left = 1234,right = 1250) == \"39811...24736e7\"\n    assert candidate(left = 4000,right = 4100) == \"22481...83456e27\"\n    assert candidate(left = 1000,right = 1050) == \"35045...20832e15\"\n    assert candidate(left = 4995,right = 5000) == \"15578...18494e5\"\n    assert candidate(left = 9500,right = 10000) == \"29333...52864e128\"\n    assert candidate(left = 2000,right = 3000) == \"25024...18624e252\"\n    assert candidate(left = 6000,right = 6100) == \"90528...09184e27\"\n    assert candidate(left = 100,right = 2000) == \"35534...18272e477\"\n    assert candidate(left = 7000,right = 7050) == \"15097...01664e15\"\n    assert candidate(left = 5500,right = 5510) == \"14071...33184e5\"\n    assert candidate(left = 9999,right = 10000) == \"9999e4\"\n    assert candidate(left = 8000,right = 8010) == \"86491...39904e5\"\n    assert candidate(left = 5,right = 50) == \"12672...06688e12\"\n    assert candidate(left = 5000,right = 6000) == \"31736...43584e253\"\n    assert candidate(left = 8000,right = 8020) == \"94684...81312e7\"\n    assert candidate(left = 8000,right = 9000) == \"12498...67872e253\"\n    assert candidate(left = 6500,right = 6530) == \"17034...07232e10\"\n    assert candidate(left = 3000,right = 3010) == \"18042...06464e5\"\n    assert candidate(left = 1000,right = 9999) == \"70734...94464e2249\"\n    assert candidate(left = 5000,right = 5015) == \"15629...41184e7\"\n    assert candidate(left = 3000,right = 3025) == \"28318...52192e9\"\n    assert candidate(left = 1234,right = 5678) == \"11390...64288e1112\"\n    assert candidate(left = 1000,right = 2000) == \"82415...74464e253\"\n    assert candidate(left = 9000,right = 9999) == \"31626...93632e250\"\n    assert candidate(left = 4321,right = 4325) == \"15098...31038e2\"\n    assert candidate(left = 8765,right = 8780) == \"12301...69504e5\"\n    assert candidate(left = 9990,right = 10000) == \"99451...72288e6\"\n    assert candidate(left = 2000,right = 2010) == \"21050...98176e5\"\n    assert candidate(left = 9990,right = 9999) == \"99451...72288e2\"\n    assert candidate(left = 5000,right = 5050) == \"57259...77056e16\"\n    assert candidate(left = 2500,right = 2600) == \"11420...49216e28\"\n    assert candidate(left = 2500,right = 2510) == \"24371...13072e6\"\n    assert candidate(left = 3000,right = 4000) == \"13222...08128e254\"\n    assert candidate(left = 1000,right = 10000) == \"70734...94464e2253\"\n    assert candidate(left = 7500,right = 7510) == \"42545...13216e6\"\n    assert candidate(left = 9000,right = 9010) == \"31573...64992e5\"\n", "comparison": "exact"}, "public_tests": ["1\n4", "2\n11", "371\n375"], "hints": ["Calculating the number of trailing zeros, the last five digits, and the first five digits can all be done separately.", "Use a prime factorization property to find the number of trailing zeros. Use modulo to find the last 5 digits. Use a logarithm property to find the first 5 digits.", "The number of trailing zeros C is nothing but the number of times the product is completely divisible by 10. Since 2 and 5 are the only prime factors of 10, C will be equal to the minimum number of times 2 or 5 appear in the prime factorization of the product.", "Iterate through the integers from left to right. For every integer, keep dividing it by 2 as long as it is divisible by 2 and C occurrences of 2 haven't been removed in total. Repeat this process for 5. Finally, multiply the integer under modulo of 10^5 with the product obtained till now to obtain the last five digits.", "The product P can be represented as P=10^(x+y) where x is the integral part and y is the fractional part of x+y. Using the property \"if S = A * B, then log(S) = log(A) + log(B)\", we can write x+y = log_10(P) = sum(log_10(i)) for each integer i in [left, right]. Once we obtain the sum, the first five digits can be represented as floor(10^(y+4))."], "metadata": {"canonical_parameter_names": ["left", "right"], "leetcode_dataset_entry_point": "Solution().abbreviateProduct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:43+00:00", "tests_total": 74, "tests_dropped": 2, "flags": [], "topic_tags": ["math", "number-theory"]}, "language": "python", "interface": {"raw_signature": "def abbreviateProduct(self, left: int, right: int) -> str:", "container": "Solution", "callable": "abbreviateProduct", "parameters": [{"name": "left", "type": "int"}, {"name": "right", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2119, "task_id": "a-number-after-a-double-reversal", "difficulty": "Easy", "problem_description": "Reversing an integer means to reverse all its digits.\n\n- For example, reversing 2021 gives 1202. Reversing 12300 gives 321 as the leading zeros are not retained.\n\nGiven an integer num, reverse num to get reversed1, then reverse reversed1 to get reversed2. Return true if reversed2 equals num. Otherwise return false.\n\nExample 1:\n\nInput: num = 526\nOutput: true\nExplanation: Reverse num to get 625, then reverse 625 to get 526, which equals num.\n\nExample 2:\n\nInput: num = 1800\nOutput: false\nExplanation: Reverse num to get 81, then reverse 81 to get 18, which does not equal num.\n\nExample 3:\n\nInput: num = 0\nOutput: true\nExplanation: Reverse num to get 0, then reverse 0 to get 0, which equals num.\n\nConstraints:\n\n- 0 <= num <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num = 1001) == True\n    assert candidate(num = 1000000) == False\n    assert candidate(num = 999999) == True\n    assert candidate(num = 1200) == False\n    assert candidate(num = 0) == True\n    assert candidate(num = 1800) == False\n    assert candidate(num = 526) == True\n    assert candidate(num = 100) == False\n    assert candidate(num = 123) == True\n    assert candidate(num = 10) == False\n    assert candidate(num = 10001) == True\n    assert candidate(num = 500500) == False\n    assert candidate(num = 100001) == True\n    assert candidate(num = 1000) == False\n    assert candidate(num = 101010) == False\n    assert candidate(num = 100000) == False\n    assert candidate(num = 123456) == True\n    assert candidate(num = 10000) == False\n", "comparison": "exact"}, "public_tests": ["526", "1800", "0"], "hints": ["Other than the number 0 itself, any number that ends with 0 would lose some digits permanently when reversed."], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().isSameAfterReversals", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:45+00:00", "tests_total": 66, "tests_dropped": 48, "flags": [], "topic_tags": ["math"]}, "language": "python", "interface": {"raw_signature": "def isSameAfterReversals(self, num: int) -> bool:", "container": "Solution", "callable": "isSameAfterReversals", "parameters": [{"name": "num", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2120, "task_id": "execution-of-all-suffix-instructions-staying-in-a-grid", "difficulty": "Medium", "problem_description": "There is an n x n grid, with the top-left cell at (0, 0) and the bottom-right cell at (n - 1, n - 1). You are given the integer n and an integer array startPos where startPos = [start_row, start_col] indicates that a robot is initially at cell (start_row, start_col).\n\nYou are also given a 0-indexed string s of length m where s[i] is the i^th instruction for the robot: 'L' (move left), 'R' (move right), 'U' (move up), and 'D' (move down).\n\nThe robot can begin executing from any i^th instruction in s. It executes the instructions one by one towards the end of s but it stops if either of these conditions is met:\n\n- The next instruction will move the robot off the grid.\n- There are no more instructions left to execute.\n\nReturn an array answer of length m where answer[i] is the number of instructions the robot can execute if the robot begins executing from the i^th instruction in s.\n\nExample 1:\n\nInput: n = 3, startPos = [0,1], s = \"RRDDLU\"\nOutput: [1,5,4,3,1,0]\nExplanation: Starting from startPos and beginning execution from the i^th instruction:\n- 0^th: \"RRDDLU\". Only one instruction \"R\" can be executed before it moves off the grid.\n- 1^st:  \"RDDLU\". All five instructions can be executed while it stays in the grid and ends at (1, 1).\n- 2^nd:   \"DDLU\". All four instructions can be executed while it stays in the grid and ends at (1, 0).\n- 3^rd:    \"DLU\". All three instructions can be executed while it stays in the grid and ends at (0, 0).\n- 4^th:     \"LU\". Only one instruction \"L\" can be executed before it moves off the grid.\n- 5^th:      \"U\". If moving up, it would move off the grid.\n\nExample 2:\n\nInput: n = 2, startPos = [1,1], s = \"LURD\"\nOutput: [4,1,0,0]\nExplanation:\n- 0^th: \"LURD\".\n- 1^st:  \"URD\".\n- 2^nd:   \"RD\".\n- 3^rd:    \"D\".\n\nExample 3:\n\nInput: n = 1, startPos = [0,0], s = \"LRUD\"\nOutput: [0,0,0,0]\nExplanation: No matter which instruction the robot begins execution from, it would move off the grid.\n\nConstraints:\n\n- m == s.length\n- 1 <= n, m <= 500\n- startPos.length == 2\n- 0 <= start_row, start_col < n\n- s consists of 'L', 'R', 'U', and 'D'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 1,startPos = [0, 0],s = \"LRUD\") == [0, 0, 0, 0]\n    assert candidate(n = 4,startPos = [2, 2],s = \"DDDD\") == [1, 1, 1, 1]\n    assert candidate(n = 5,startPos = [2, 2],s = \"LUDDRL\") == [6, 5, 4, 3, 2, 1]\n    assert candidate(n = 4,startPos = [0, 3],s = \"RRRR\") == [0, 0, 0, 0]\n    assert candidate(n = 3,startPos = [2, 0],s = \"RRU\") == [3, 2, 1]\n    assert candidate(n = 4,startPos = [1, 2],s = \"LURDLU\") == [6, 5, 4, 3, 2, 1]\n    assert candidate(n = 4,startPos = [2, 2],s = \"UUDDLLRR\") == [8, 7, 1, 5, 4, 3, 1, 1]\n    assert candidate(n = 3,startPos = [0, 1],s = \"RRDDLU\") == [1, 5, 4, 3, 1, 0]\n    assert candidate(n = 4,startPos = [3, 0],s = \"DDDD\") == [0, 0, 0, 0]\n    assert candidate(n = 5,startPos = [0, 0],s = \"DRDLUR\") == [6, 5, 1, 0, 0, 1]\n    assert candidate(n = 2,startPos = [1, 1],s = \"LURD\") == [4, 1, 0, 0]\n    assert candidate(n = 5,startPos = [3, 3],s = \"DDDDRRRRUUUULLLL\") == [1, 1, 1, 2, 1, 1, 1, 4, 3, 6, 5, 4, 3, 3, 2, 1]\n    assert candidate(n = 3,startPos = [0, 2],s = \"LLD\") == [3, 2, 1]\n    assert candidate(n = 4,startPos = [2, 2],s = \"UDLRUDLR\") == [8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 5,startPos = [0, 0],s = \"RRRRUUUUDDDDLLLL\") == [4, 3, 2, 1, 0, 0, 0, 0, 4, 3, 2, 1, 0, 0, 0, 0]\n    assert candidate(n = 5,startPos = [3, 3],s = \"RRRDDDDLLLLUUUU\") == [1, 1, 2, 1, 1, 1, 4, 3, 6, 5, 4, 3, 3, 2, 1]\n    assert candidate(n = 7,startPos = [3, 3],s = \"LDRURLDRU\") == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 15,startPos = [14, 0],s = \"LLLLDDDDDDDDDDDDUUUUUUUUUUUUUUUU\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 14, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 6,startPos = [2, 2],s = \"UDLRUDLR\") == [8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 8,startPos = [1, 6],s = \"RULDDRRULLUUDD\") == [6, 10, 12, 3, 2, 1, 4, 3, 3, 2, 1, 3, 2, 1]\n    assert candidate(n = 9,startPos = [8, 0],s = \"DDDDDDDDDDDDDDDDDD\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(n = 5,startPos = [0, 4],s = \"LLLLDDRRRRUUUU\") == [12, 8, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(n = 13,startPos = [1, 1],s = \"LRRUDLRLRLUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUD\") == [94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 8,startPos = [0, 0],s = \"RRRRDDDDLLLLUUUUDDDDLLLLUUUU\") == [20, 10, 8, 6, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(n = 10,startPos = [7, 2],s = \"DRLLURDDRLUUDDRR\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 7,startPos = [3, 3],s = \"LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR\") == [34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 5,startPos = [4, 4],s = \"LULULULULULULULULULU\") == [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 6,startPos = [0, 5],s = \"LLLLDDRRUUDDLLRRUUDDLLRRUUDD\") == [28, 27, 26, 4, 2, 1, 0, 0, 0, 0, 18, 6, 4, 2, 0, 0, 0, 0, 10, 6, 4, 2, 0, 0, 0, 0, 2, 1]\n    assert candidate(n = 10,startPos = [5, 5],s = \"LRUDLRUDLRUD\") == [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 8,startPos = [7, 0],s = \"RRRRDDDDLLLLUUUU\") == [4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 4, 3, 2, 1]\n    assert candidate(n = 6,startPos = [2, 3],s = \"LRRUDLRLRLUDUDUDUD\") == [18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 11,startPos = [3, 3],s = \"LRRLDDUUDDUUDDRRLLRRRRUUUUDDDDLLLL\") == [34, 33, 32, 31, 30, 29, 19, 27, 26, 25, 15, 23, 22, 21, 11, 10, 9, 8, 7, 6, 5, 4, 3, 10, 9, 8, 7, 6, 5, 4, 3, 3, 2, 1]\n    assert candidate(n = 400,startPos = [0, 0],s = \"RRRRUUUUDDDDLLLL\") == [4, 3, 2, 1, 0, 0, 0, 0, 4, 3, 2, 1, 0, 0, 0, 0]\n    assert candidate(n = 7,startPos = [0, 6],s = \"LLLLLLLLLLLLLLLLLLL\") == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 6,startPos = [3, 3],s = \"LURDLURDLURDLURD\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 7,startPos = [0, 6],s = \"LLLLLLLLRRRRRRRRUUUUUUUDDDDDDD\") == [6, 6, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 7,startPos = [3, 3],s = \"LLLLDDDDRRRRUUUU\") == [3, 6, 5, 4, 3, 6, 5, 4, 3, 6, 5, 4, 3, 3, 2, 1]\n    assert candidate(n = 9,startPos = [4, 4],s = \"LURDLURDLURDLURD\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 5,startPos = [2, 2],s = \"LRLRLRLRLRLRLRLR\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 300,startPos = [299, 299],s = \"DDDDRRRRUUUULLLL\") == [0, 0, 0, 0, 0, 0, 0, 0, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 12,startPos = [5, 5],s = \"UDLRUDLRUDLRUDLRUDLR\") == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 10,startPos = [5, 2],s = \"DDUUDDUUDDUUDDUUDDUUDDUUDDUUDDUU\") == [32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 6,startPos = [5, 0],s = \"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\") == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1]\n    assert candidate(n = 15,startPos = [14, 14],s = \"LLLLLLLLLLLLLLL\") == [14, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 9,startPos = [4, 4],s = \"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\") == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1]\n    assert candidate(n = 6,startPos = [0, 5],s = \"DDDDDDRRRRRDDDRRLUUL\") == [5, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 3, 2, 1, 0, 0, 1, 0, 0, 1]\n    assert candidate(n = 8,startPos = [7, 0],s = \"RRRRRRRRUUUUUUUUDDDDDDDDLLLLLLLL\") == [7, 14, 13, 12, 11, 10, 9, 8, 7, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(n = 5,startPos = [0, 4],s = \"LLLLDDDDRRRRUUUU\") == [16, 10, 8, 6, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(n = 5,startPos = [0, 4],s = \"RRRRRRRRRRRRRRRRRRRR\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(n = 9,startPos = [1, 1],s = \"DRDLDRDLDRDLDRDLDRDLDRDLDRDLDRDL\") == [14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 7,startPos = [3, 3],s = \"LUDDRRUULLDD\") == [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 5,startPos = [0, 0],s = \"RLRLRLRLRLRLRLRLRLRL\") == [20, 0, 18, 0, 16, 0, 14, 0, 12, 0, 10, 0, 8, 0, 6, 0, 4, 0, 2, 0]\n    assert candidate(n = 10,startPos = [5, 5],s = \"LLLLUUUUDDDDRRRRLLLLUUUUDDDDRRRR\") == [32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 5,startPos = [2, 2],s = \"DDRRUULLUU\") == [10, 8, 6, 5, 4, 4, 4, 3, 2, 1]\n    assert candidate(n = 8,startPos = [1, 1],s = \"DDDDUUUUDDDDUUUUDDDDUUUUDDDDUUUUDDDDUUUU\") == [40, 39, 5, 3, 1, 1, 1, 33, 32, 31, 5, 3, 1, 1, 1, 25, 24, 23, 5, 3, 1, 1, 1, 17, 16, 15, 5, 3, 1, 1, 1, 9, 8, 7, 5, 3, 1, 1, 1, 1]\n    assert candidate(n = 6,startPos = [4, 5],s = \"RRRDDDDLUUUULLLRRUUDD\") == [0, 0, 0, 1, 1, 1, 12, 10, 9, 9, 11, 10, 9, 8, 2, 0, 0, 4, 3, 1, 1]\n    assert candidate(n = 12,startPos = [6, 6],s = \"RRDDLLUUDDRRLLUUDDRRLLUUDDRRLLUUDDRRLLUUDD\") == [42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 11,startPos = [5, 5],s = \"DDDDDDDDDDDDLLLLLLLLLLLLUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\") == [5, 5, 5, 5, 5, 5, 5, 10, 9, 8, 7, 6, 5, 5, 5, 5, 5, 5, 5, 10, 9, 8, 7, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1]\n    assert candidate(n = 20,startPos = [19, 0],s = \"RRRRRRRRRRRRRRRRRRRRLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == [19, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(n = 8,startPos = [4, 4],s = \"UDLRUDLRUDLRUDLR\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 4,startPos = [2, 3],s = \"LLLDDDLLLLUUUUDDDD\") == [4, 3, 2, 1, 1, 4, 3, 5, 4, 3, 2, 2, 5, 3, 1, 1, 1, 1]\n    assert candidate(n = 5,startPos = [4, 0],s = \"DDDDDDDDDDDDDDDDDDDD\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(n = 10,startPos = [5, 5],s = \"UUUUDDDDLLLLRRRR\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 8,startPos = [7, 7],s = \"LLLLUUUUDDDDRRRRLLLLUUUUDDDD\") == [28, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 12, 11, 10, 9, 8, 6, 4, 2, 0, 0, 0, 0]\n    assert candidate(n = 6,startPos = [4, 1],s = \"LDDRRULUDR\") == [2, 1, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 7,startPos = [6, 6],s = \"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\") == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 5,startPos = [2, 2],s = \"LUDDRRUUDDLL\") == [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 4,startPos = [2, 0],s = \"RRRDDDLLLLUUUUDDDD\") == [4, 3, 2, 1, 1, 1, 0, 0, 0, 0, 2, 2, 5, 3, 1, 1, 1, 1]\n    assert candidate(n = 5,startPos = [2, 2],s = \"RRDDLLUUURRDDDLLUUU\") == [19, 18, 17, 16, 4, 3, 2, 12, 11, 4, 3, 2, 7, 6, 4, 3, 2, 2, 1]\n    assert candidate(n = 10,startPos = [0, 0],s = \"RRRDDDLLLUUUDDDRRRLUUDLLUURDDLL\") == [30, 7, 5, 3, 2, 1, 0, 0, 0, 0, 0, 0, 18, 12, 6, 4, 3, 2, 0, 0, 0, 1, 0, 0, 0, 0, 4, 2, 1, 0, 0]\n    assert candidate(n = 3,startPos = [1, 1],s = \"RLLDDRRUUULLDD\") == [4, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1]\n    assert candidate(n = 9,startPos = [4, 4],s = \"DDDDDDDDUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\") == [4, 4, 4, 4, 12, 10, 8, 6, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1]\n    assert candidate(n = 6,startPos = [2, 2],s = \"LRLRLRLRLRLRLR\") == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 8,startPos = [0, 7],s = \"RRRRRRRRUUUUUUUUDDDDDDDDLDDDDDDD\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 9,startPos = [8, 0],s = \"RRRRRRRRDDDDDDDDDLLLLLLLLLLLLUUUUUUUUUUUUUUUU\") == [8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 12,startPos = [0, 11],s = \"LLLLLLLLLLLL\") == [11, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 9,startPos = [5, 4],s = \"UUDDLLRRUUDDLLRR\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 10,startPos = [5, 5],s = \"UUUUDDDDLLLLRRRRUUUUDDDDLLLLRRRR\") == [32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 20,startPos = [10, 10],s = \"LDRURLDRURLDRURLDRU\") == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 15,startPos = [7, 7],s = \"RRRRUUUULLLLDDDDRRRRUUUULLLLDDDD\") == [32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 7,startPos = [3, 3],s = \"UUUUDDDDLLLLRRRRUUDDLL\") == [3, 10, 9, 8, 3, 6, 5, 4, 3, 13, 12, 11, 3, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 9,startPos = [0, 8],s = \"LLLLLLLLUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\") == [8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(n = 7,startPos = [1, 1],s = \"DDRRLLUUDDRRLLUUDDRRLLUU\") == [24, 23, 5, 4, 1, 2, 1, 17, 16, 15, 5, 4, 1, 2, 1, 9, 8, 7, 5, 4, 1, 2, 1, 1]\n    assert candidate(n = 10,startPos = [2, 5],s = \"RRLLRRLLRRLLRRLLRRLLRRLLRRLLRRLL\") == [32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(n = 10,startPos = [5, 5],s = \"UUUUUUUUUUDDDDDDDDDDLLLLLLLLLLRRRRRRRRRR\") == [5, 5, 5, 5, 5, 14, 12, 10, 8, 6, 4, 4, 4, 4, 4, 4, 9, 8, 7, 6, 5, 5, 5, 5, 5, 14, 12, 10, 8, 6, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1]\n    assert candidate(n = 10,startPos = [9, 0],s = \"RRRRRRRRRRUUUUUUUUUUDDDDDDDDDDDLLLLLLLLLL\") == [9, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(n = 12,startPos = [6, 6],s = \"UUUUUUUUUUUUDDDDDDDDDDDDLLLLLLLLLLLLRRRRRRRRRRRR\") == [6, 6, 6, 6, 6, 6, 17, 15, 13, 11, 9, 7, 5, 5, 5, 5, 5, 5, 5, 11, 10, 9, 8, 7, 6, 6, 6, 6, 6, 6, 17, 15, 13, 11, 9, 7, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1]\n    assert candidate(n = 8,startPos = [3, 4],s = \"RRDLULLLUUDDDDRRRRLU\") == [20, 19, 18, 17, 16, 15, 14, 13, 9, 8, 7, 6, 5, 4, 3, 5, 4, 3, 2, 1]\n    assert candidate(n = 10,startPos = [5, 5],s = \"LURDLURDLURDLURDLURDLURD\") == [24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n", "comparison": "exact"}, "public_tests": ["3\n[0,1]\n\"RRDDLU\"", "2\n[1,1]\n\"LURD\"", "1\n[0,0]\n\"LRUD\""], "hints": ["The constraints are not very large. Can we simulate the execution by starting from each index of s?", "Before any of the stopping conditions is met, stop the simulation for that index and set the answer for that index."], "metadata": {"canonical_parameter_names": ["n", "startPos", "s"], "leetcode_dataset_entry_point": "Solution().executeInstructions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:48+00:00", "tests_total": 89, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["string", "simulation"]}, "language": "python", "interface": {"raw_signature": "def executeInstructions(self, n: int, startPos: list[int], s: str) -> list[int]:", "container": "Solution", "callable": "executeInstructions", "parameters": [{"name": "n", "type": "int"}, {"name": "startPos", "type": "list[int]"}, {"name": "s", "type": "str"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2121, "task_id": "intervals-between-identical-elements", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of n integers arr.\n\nThe interval between two elements in arr is defined as the absolute difference between their indices. More formally, the interval between arr[i] and arr[j] is |i - j|.\n\nReturn an array intervals of length n where intervals[i] is the sum of intervals between arr[i] and each element in arr with the same value as arr[i].\n\nNote: |x| is the absolute value of x.\n\nExample 1:\n\nInput: arr = [2,1,3,1,2,3,3]\nOutput: [4,2,7,2,4,4,5]\nExplanation:\n- Index 0: Another 2 is found at index 4. |0 - 4| = 4\n- Index 1: Another 1 is found at index 3. |1 - 3| = 2\n- Index 2: Two more 3s are found at indices 5 and 6. |2 - 5| + |2 - 6| = 7\n- Index 3: Another 1 is found at index 1. |3 - 1| = 2\n- Index 4: Another 2 is found at index 0. |4 - 0| = 4\n- Index 5: Two more 3s are found at indices 2 and 6. |5 - 2| + |5 - 6| = 4\n- Index 6: Two more 3s are found at indices 2 and 5. |6 - 2| + |6 - 5| = 5\n\nExample 2:\n\nInput: arr = [10,5,10,10]\nOutput: [5,0,3,4]\nExplanation:\n- Index 0: Two more 10s are found at indices 2 and 3. |0 - 2| + |0 - 3| = 5\n- Index 1: There is only one 5 in the array, so its sum of intervals to identical elements is 0.\n- Index 2: Two more 10s are found at indices 0 and 3. |2 - 0| + |2 - 3| = 3\n- Index 3: Two more 10s are found at indices 0 and 2. |3 - 0| + |3 - 2| = 4\n\nConstraints:\n\n- n == arr.length\n- 1 <= n <= 10^5\n- 1 <= arr[i] <= 10^5\n\nNote: This question is the same as  2615: Sum of Distances.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(arr = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == [20, 0, 14, 0, 12, 0, 14, 0, 20, 0]\n    assert candidate(arr = [5, 4, 3, 2, 1]) == [0, 0, 0, 0, 0]\n    assert candidate(arr = [1, 3, 2, 3, 1, 4, 2, 3, 1, 4, 2]) == [12, 8, 12, 6, 8, 4, 8, 10, 12, 4, 12]\n    assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n    assert candidate(arr = [1, 2, 3, 4, 5]) == [0, 0, 0, 0, 0]\n    assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n    assert candidate(arr = [10, 5, 10, 10]) == [5, 0, 3, 4]\n    assert candidate(arr = [5, 5, 5, 5, 5]) == [10, 7, 6, 7, 10]\n    assert candidate(arr = [1, 1, 1, 1, 1]) == [10, 7, 6, 7, 10]\n    assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4]) == [1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(arr = [2, 1, 3, 1, 2, 3, 3]) == [4, 2, 7, 2, 4, 4, 5]\n    assert candidate(arr = [1, 2, 2, 1, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [3, 1, 1, 3, 3, 2, 3, 6, 4, 4, 6, 10, 7, 6, 7, 10, 15, 11, 9, 9, 11, 15]\n    assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42]\n    assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == [10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 10, 10, 7, 6, 7, 10]\n    assert candidate(arr = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == [38, 34, 30, 26, 22, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 22, 26, 30, 34, 38]\n    assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n    assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [15, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]\n    assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n    assert candidate(arr = [30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(arr = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100, 10, 110]) == [90, 0, 74, 0, 62, 0, 54, 0, 50, 0, 50, 0, 54, 0, 62, 0, 74, 0, 90, 0]\n    assert candidate(arr = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n    assert candidate(arr = [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == [1, 1, 1, 1, 3, 2, 3, 6, 4, 4, 6, 10, 7, 6, 7, 10, 15, 11, 9, 9, 11, 15, 21, 16, 13, 12, 13, 16, 21]\n    assert candidate(arr = [5, 3, 2, 5, 3, 5, 2, 5, 2, 5, 2, 3]) == [24, 13, 18, 15, 10, 13, 10, 15, 10, 21, 14, 17]\n    assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n    assert candidate(arr = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [15, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]\n    assert candidate(arr = [100000, 50000, 100000, 25000, 100000, 12500, 100000, 6250, 100000, 3125]) == [20, 0, 14, 0, 12, 0, 14, 0, 20, 0]\n    assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n    assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [145, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 48, 43, 40, 39, 40, 43, 48, 55, 64]\n    assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [30, 30, 30, 30, 30, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 30, 30, 30, 30, 30]\n    assert candidate(arr = [100000, 100000, 99999, 99999, 99998, 99998, 99997, 99997, 99996, 99996, 99995, 99995]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [861, 821, 783, 747, 713, 681, 651, 623, 597, 573, 551, 531, 513, 497, 483, 471, 461, 453, 447, 443, 441, 441, 443, 447, 453, 461, 471, 483, 497, 513, 531, 551, 573, 597, 623, 651, 681, 713, 747, 783, 821, 861]\n    assert candidate(arr = [5, 3, 2, 3, 5, 3, 2, 5, 2, 2, 5, 2, 3]) == [21, 17, 26, 13, 13, 13, 14, 13, 12, 13, 19, 19, 27]\n    assert candidate(arr = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n    assert candidate(arr = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 1]) == [21, 3, 19, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 36]\n    assert candidate(arr = [5, 2, 5, 5, 3, 2, 5, 3, 5]) == [19, 4, 13, 12, 3, 4, 15, 3, 21]\n    assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(arr = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99999]) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10]\n    assert candidate(arr = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == [20, 20, 14, 14, 12, 12, 14, 14, 20, 20]\n    assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == [51, 47, 45, 51, 47, 45, 51, 47, 45, 51, 47, 45, 51, 47, 45, 45, 47, 51, 45, 47, 51, 45, 47, 51, 45, 47, 51, 45, 47, 51]\n    assert candidate(arr = [1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2]) == [57, 63, 47, 45, 48, 38, 33, 39, 35, 27, 36, 38, 27, 39, 47, 33, 48, 62, 45, 63]\n    assert candidate(arr = [10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40, 50, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50]) == [43, 47, 43, 39, 35, 33, 31, 29, 27, 27, 27, 27, 19, 19, 30, 32, 34, 27, 29, 43, 47, 51, 37]\n    assert candidate(arr = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == [69, 57, 45, 47, 49, 33, 38, 40, 27, 35, 37, 27, 38, 40, 33, 47, 49, 45, 62, 64]\n    assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [48, 65, 63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 39, 51, 53, 55, 57, 59, 61, 63, 65, 67]\n    assert candidate(arr = [100000, 99999, 100000, 99998, 100000, 99997, 100000, 99996, 100000, 99995]) == [20, 0, 14, 0, 12, 0, 14, 0, 20, 0]\n    assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [0, 1, 1, 3, 2, 3, 6, 4, 4, 6, 10, 7, 6, 7, 10, 15, 11, 9, 9, 11, 15]\n    assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n    assert candidate(arr = [7, 4, 7, 2, 7, 4, 2, 7, 4, 2, 7]) == [23, 11, 17, 9, 15, 7, 6, 18, 10, 9, 27]\n    assert candidate(arr = [7, 3, 7, 3, 7, 3, 7, 3, 7, 3]) == [20, 20, 14, 14, 12, 12, 14, 14, 20, 20]\n    assert candidate(arr = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2]) == [30, 40, 24, 28, 31, 21, 16, 20, 27, 25, 6, 11, 20, 32, 40, 0, 6, 17, 32, 50]\n    assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\n    assert candidate(arr = [50000, 1, 50000, 2, 50000, 3, 50000, 4, 50000, 5, 50000, 6, 50000, 7, 50000, 8, 50000, 9, 50000, 10]) == [90, 0, 74, 0, 62, 0, 54, 0, 50, 0, 50, 0, 54, 0, 62, 0, 74, 0, 90, 0]\n    assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n    assert candidate(arr = [5, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [6, 13, 5, 5, 5, 9, 6, 5, 5, 5, 14]\n    assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == [0, 1, 1, 3, 2, 3, 6, 4, 4, 6, 10, 7, 6, 7, 10, 15, 11, 9, 9, 11, 15, 21, 16, 13, 12, 13, 16, 21]\n    assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [22, 20, 22, 20, 22, 20, 22, 20, 22, 20, 20, 22, 20, 22, 20, 22, 20, 22, 20, 22]\n    assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [300, 277, 256, 237, 220, 205, 192, 181, 172, 165, 160, 157, 156, 157, 160, 165, 172, 181, 192, 205, 220, 237, 256, 277, 300]\n    assert candidate(arr = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [36, 34, 28, 26, 20, 18, 12, 10, 3, 2, 3, 10, 12, 18, 20, 26, 28, 34, 36]\n    assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42, 40, 42]\n    assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [26, 24, 24, 22, 22, 20, 20, 18, 18, 16, 24, 22, 20, 18, 16, 34, 32, 30, 28, 26]\n    assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == [25, 29, 25, 21, 17, 17, 17, 17, 17, 17, 17, 17, 9, 10, 23, 27, 31, 26]\n    assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\n    assert candidate(arr = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [105, 92, 81, 72, 65, 60, 57, 56, 57, 60, 65, 72, 81, 92, 105]\n    assert candidate(arr = [5, 3, 5, 2, 3, 3, 5, 3, 2, 2, 5]) == [18, 13, 14, 11, 7, 7, 14, 11, 6, 7, 22]\n    assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n    assert candidate(arr = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(arr = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == [20, 20, 14, 14, 12, 12, 14, 14, 20, 20]\n    assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n    assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(arr = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18]\n    assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [50, 50, 50, 50, 50, 35, 35, 35, 35, 35, 30, 30, 30, 30, 30, 35, 35, 35, 35, 35, 50, 50, 50, 50, 50]\n    assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [46, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 30, 32, 34, 36, 38, 40, 42, 44, 28, 38, 50, 52, 54, 56, 58, 60, 62, 64, 38]\n    assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == [37, 16, 14, 12, 10, 8, 6, 4, 2, 0, 2, 4, 6, 8, 10, 12, 14, 16, 19, 20]\n    assert candidate(arr = [7, 1, 7, 2, 7, 3, 7, 4, 7, 5, 7, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == [154, 0, 130, 0, 110, 0, 94, 0, 82, 0, 74, 0, 70, 70, 72, 76, 82, 90, 100, 112]\n    assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n    assert candidate(arr = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == [15, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]\n    assert candidate(arr = [7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n    assert candidate(arr = [9, 7, 5, 3, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1]) == [39, 33, 27, 21, 30, 17, 19, 21, 23, 20, 17, 19, 21, 23, 20, 27, 29, 31, 33, 30]\n    assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == [3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3]\n    assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n", "comparison": "exact"}, "public_tests": ["[2,1,3,1,2,3,3]", "[10,5,10,10]"], "hints": ["For each unique value found in the array, store a sorted list of indices of elements that have this value in the array.", "One way of doing this is to use a HashMap that maps the values to their list of indices. Update this mapping as you iterate through the array.", "Process each list of indices separately and get the sum of intervals for the elements of that value by utilizing prefix sums.", "For each element, keep track of the sum of indices of the identical elements that have come before and that will come after respectively. Use this to calculate the sum of intervals for that element to the rest of the elements with identical values."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().getDistances", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:50+00:00", "tests_total": 89, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "hash-table", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def getDistances(self, arr: list[int]) -> list[int]:", "container": "Solution", "callable": "getDistances", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2122, "task_id": "recover-the-original-array", "difficulty": "Hard", "problem_description": "Alice had a 0-indexed array arr consisting of n positive integers. She chose an arbitrary positive integer k and created two new 0-indexed integer arrays lower and higher in the following manner:\n\n1. lower[i] = arr[i] - k, for every index i where 0 <= i < n\n2. higher[i] = arr[i] + k, for every index i where 0 <= i < n\n\nUnfortunately, Alice lost all three arrays. However, she remembers the integers that were present in the arrays lower and higher, but not the array each integer belonged to. Help Alice and recover the original array.\n\nGiven an array nums consisting of 2n integers, where exactly n of the integers were present in lower and the remaining in higher, return the original array arr. In case the answer is not unique, return any valid array.\n\nNote: The test cases are generated such that there exists at least one valid array arr.\n\nExample 1:\n\nInput: nums = [2,10,6,4,8,12]\nOutput: [3,7,11]\nExplanation:\nIf arr = [3,7,11] and k = 1, we get lower = [2,6,10] and higher = [4,8,12].\nCombining lower and higher gives us [2,6,10,4,8,12], which is a permutation of nums.\nAnother valid possibility is that arr = [5,7,9] and k = 3. In that case, lower = [2,4,6] and higher = [8,10,12].\n\nExample 2:\n\nInput: nums = [1,1,3,3]\nOutput: [2,2]\nExplanation:\nIf arr = [2,2] and k = 1, we get lower = [1,1] and higher = [3,3].\nCombining lower and higher gives us [1,1,3,3], which is equal to nums.\nNote that arr cannot be [1,3] because in that case, the only possible way to obtain [1,1,3,3] is with k = 0.\nThis is invalid since k must be positive.\n\nExample 3:\n\nInput: nums = [5,435]\nOutput: [220]\nExplanation:\nThe only possible combination is arr = [220] and k = 215. Using them, we get lower = [5] and higher = [435].\n\nConstraints:\n\n- 2 * n == nums.length\n- 1 <= n <= 1000\n- 1 <= nums[i] <= 10^9\n- The test cases are generated such that there exists at least one valid array arr.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [3, 1, 5, 7, 9, 11]) == [2, 6, 10]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60]) == [15, 35, 55]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == [2, 3, 6, 7]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6]) == []\n    assert candidate(nums = [2, 10, 6, 4, 8, 12]) == [3, 7, 11]\n    assert candidate(nums = [1, 3, 5, 7]) == [2, 6]\n    assert candidate(nums = [7, 9, 11, 13, 15, 17]) == [8, 12, 16]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600]) == [150, 350, 550]\n    assert candidate(nums = [9, 11, 13, 15, 17, 19]) == [10, 14, 18]\n    assert candidate(nums = [5, 435]) == [220]\n    assert candidate(nums = [1, 1, 3, 3]) == [2, 2]\n    assert candidate(nums = [1000000000, 1]) == []\n    assert candidate(nums = [2, 2, 2, 2]) == []\n    assert candidate(nums = [3, 9, 3, 9, 5, 7]) == []\n    assert candidate(nums = [3, 3, 3, 9, 9, 9]) == [6, 6, 6]\n    assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]\n    assert candidate(nums = [10, 22, 30, 42, 50, 62, 70, 82, 90, 102, 110, 122]) == [16, 36, 56, 76, 96, 116]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [2, 6, 10, 14, 18, 22, 26, 30]\n    assert candidate(nums = [10, 100, 20, 110, 30, 120, 40, 130, 50, 140, 60, 150, 70, 160, 80, 170]) == [15, 35, 55, 75, 105, 125, 145, 165]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98]\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16]) == [2, 3, 6, 7, 10, 11, 14, 15, 18, 19]\n    assert candidate(nums = [2, 4, 8, 10, 16, 18, 24, 26, 32, 34, 40, 42, 48, 50, 56, 58, 64, 66, 72, 74, 80, 82, 88, 90, 96, 98, 104, 106, 112, 114, 120, 122, 128, 130, 136, 138, 144, 146, 152, 154, 160, 162, 168, 170, 176, 178, 184, 186, 192, 194, 200]) == [3, 9, 17, 25, 33, 41, 49, 57, 65, 73, 81, 89, 97, 105, 113, 121, 129, 137, 145, 153, 161, 169, 177, 185, 193]\n    assert candidate(nums = [1, 3, 3, 5, 7, 7, 9, 11, 11, 13, 15, 17, 17, 19]) == []\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [2, 6, 10, 14, 18, 22, 26, 30]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16]) == [3, 7, 11, 15]\n    assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29]) == []\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == [150, 350, 550, 750, 950, 1150, 1350, 1550, 1750, 1950]\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == []\n    assert candidate(nums = [5, 9, 13, 17, 21, 25, 29, 33]) == [7, 15, 23, 31]\n    assert candidate(nums = [10, 20, 15, 25, 30, 40, 35, 45, 50, 60, 55, 65, 70, 80, 75, 85]) == [15, 20, 35, 40, 55, 60, 75, 80]\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == [3, 11, 19, 27, 35]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [2, 3, 6, 7, 10, 11, 14, 15]\n    assert candidate(nums = [7, 21, 14, 28, 21, 42, 28, 56, 35, 70, 42, 84, 49, 98, 56, 112]) == []\n    assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996, 6, 999999995]) == [499999998, 499999999, 500000000, 500000001, 500000002, 500000003]\n    assert candidate(nums = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == [11, 15, 19, 23, 27, 31, 35, 39]\n    assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997]) == [2, 3, 999999998, 999999999]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80]) == [15, 35, 55, 75]\n    assert candidate(nums = [5, 5, 5, 5, 9, 9, 9, 9]) == [7, 7, 7, 7]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11]) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == []\n    assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10]) == []\n    assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39]) == [5, 13, 21, 29, 37]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46]\n    assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69]) == [6, 18, 30, 42, 54, 66]\n    assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45]) == [6, 18, 30, 42]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == []\n    assert candidate(nums = [5, 5, 5, 5, 10, 10, 10, 10, 15, 15, 15, 15]) == []\n    assert candidate(nums = [10, 22, 34, 46, 58, 70, 82, 94, 106, 118, 130, 142, 154, 166, 178]) == [16, 40, 64, 88, 112, 136, 160]\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == [2, 3, 3, 4, 6, 7, 7, 8, 10, 11, 11]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == [150, 350, 550, 750, 950, 1150]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == []\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [2, 6, 10, 14, 18, 22, 26]\n    assert candidate(nums = [2, 6, 10, 4, 8, 12, 16, 20]) == []\n    assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14]) == []\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53]) == [3, 11, 19, 27, 35, 43, 51]\n    assert candidate(nums = [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49]) == [7, 15, 23, 31, 39, 47]\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]) == []\n    assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20]) == []\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == [3, 7, 11, 15, 19, 23, 27, 31]\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115]) == [10, 30, 50, 70, 90, 110]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == [150, 350, 550, 750, 950, 1150, 1350, 1550]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == [3, 7, 11, 15, 19, 23, 27, 31, 35, 39]\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [10, 30, 50, 70, 90]\n    assert candidate(nums = [10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86]) == [12, 20, 28, 36, 44, 52, 60, 68, 76, 84]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == []\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [2, 3, 6, 7, 10, 11, 14, 15, 18, 19]\n    assert candidate(nums = [1, 1, 1, 1, 3, 3, 3, 3]) == [2, 2, 2, 2]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == [3, 7, 11, 15, 19, 23, 27, 31]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == [3, 7, 11, 15, 19, 23]\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == [6, 9, 18, 21, 30, 33, 42, 45, 54, 57]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == []\n    assert candidate(nums = [1, 2, 5, 6, 9, 10, 13, 14, 17, 18]) == []\n    assert candidate(nums = [1, 9, 17, 25, 33, 41, 49, 57, 65, 73, 81, 89, 97, 105]) == [5, 21, 37, 53, 69, 85, 101]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200]) == [10, 15, 30, 35, 50, 55, 70, 75, 90, 95, 110, 115, 130, 135, 150, 155, 170, 175, 190, 195]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [2, 6, 10, 14, 18]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [15, 35, 55, 75, 95]\n    assert candidate(nums = [2, 14, 8, 6, 10, 18, 12, 4]) == []\n    assert candidate(nums = [100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175]) == [105, 110, 125, 130, 145, 150, 165, 170]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == [15, 35, 55, 75, 95, 115, 135, 155, 175, 195, 215, 235]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == [15, 35, 55, 75, 95, 115, 135, 155]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [3, 7, 11, 15, 19]\n    assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == [15, 20, 35, 40, 55, 60, 75, 80, 95, 100]\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == [3, 11, 19, 27, 35]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [15, 35, 55, 75, 95, 115, 135]\n    assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165]) == [20, 40, 60, 80, 100, 120, 140, 160]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [2, 3, 6, 7, 10, 11, 14, 15, 18, 19]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == [15, 35, 55, 75, 95, 115]\n    assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47]) == [5, 13, 21, 29, 37, 45]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]) == [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99]\n    assert candidate(nums = [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65]) == [7, 15, 23, 31, 39, 47, 55, 63]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [10, 15, 30, 35, 50, 55, 70, 75, 90, 95]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == [15, 35, 55, 75, 95, 115, 135, 155, 175, 195, 215, 235]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [2, 6, 10, 14, 18, 22, 26, 30, 34, 38]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == [15, 35, 55, 75, 95, 115, 135, 155]\n    assert candidate(nums = [1, 1, 1, 1, 5, 5, 5, 5]) == [3, 3, 3, 3]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [15, 35, 55, 75, 95]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [3, 7, 11, 15, 19]\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == []\n    assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125]) == [20, 40, 60, 80, 100, 120]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]) == [10, 15, 30, 35, 50, 55, 70, 75]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == [2, 6, 10, 14, 18, 22]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80]) == [15, 35, 55, 75]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [150, 350, 550, 750, 950]\n    assert candidate(nums = [100, 101, 200, 201, 300, 301, 400, 401]) == [150, 151, 350, 351]\n", "comparison": "exact"}, "public_tests": ["[2,10,6,4,8,12]", "[1,1,3,3]", "[5,435]"], "hints": ["If we fix the value of k, how can we check if an original array exists for the fixed k?", "The smallest value of nums is obtained by subtracting k from the smallest value of the original array. How can we use this to reduce the search space for finding a valid k?", "You can compute every possible k by using the smallest value of nums (as lower[i]) against every other value in nums (as the corresponding higher[i]).", "For every computed k, greedily pair up the values in nums. This can be done sorting nums, then using a map to store previous values and searching that map for a corresponding lower[i] for the current nums[j] (as higher[i])."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().recoverArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:52+00:00", "tests_total": 111, "tests_dropped": 6, "flags": ["multiple_answers"], "topic_tags": ["array", "hash-table", "two-pointers", "sorting", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def recoverArray(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "recoverArray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2124, "task_id": "check-if-all-as-appears-before-all-bs", "difficulty": "Easy", "problem_description": "Given a string s consisting of only the characters 'a' and 'b', return true if every 'a' appears before every 'b' in the string. Otherwise, return false.\n\nExample 1:\n\nInput: s = \"aaabbb\"\nOutput: true\nExplanation:\nThe 'a's are at indices 0, 1, and 2, while the 'b's are at indices 3, 4, and 5.\nHence, every 'a' appears before every 'b' and we return true.\n\nExample 2:\n\nInput: s = \"abab\"\nOutput: false\nExplanation:\nThere is an 'a' at index 2 and a 'b' at index 1.\nHence, not every 'a' appears before every 'b' and we return false.\n\nExample 3:\n\nInput: s = \"bbb\"\nOutput: true\nExplanation:\nThere are no 'a's, hence, every 'a' appears before every 'b' and we return true.\n\nConstraints:\n\n- 1 <= s.length <= 100\n- s[i] is either 'a' or 'b'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"b\") == True\n    assert candidate(s = \"aaaaabbbbb\") == True\n    assert candidate(s = \"bbb\") == True\n    assert candidate(s = \"ab\") == True\n    assert candidate(s = \"aabbaa\") == False\n    assert candidate(s = \"ba\") == False\n    assert candidate(s = \"bba\") == False\n    assert candidate(s = \"aaa\") == True\n    assert candidate(s = \"aabbaabb\") == False\n    assert candidate(s = \"aaabbb\") == True\n    assert candidate(s = \"a\") == True\n    assert candidate(s = \"aabbabbb\") == False\n    assert candidate(s = \"abab\") == False\n    assert candidate(s = \"abbb\") == True\n    assert candidate(s = \"aaaaaaaaaabbbbbbbbbb\") == True\n    assert candidate(s = \"abababbabababbab\") == False\n    assert candidate(s = \"baaa\") == False\n    assert candidate(s = \"bbbbbbbbbb\") == True\n    assert candidate(s = \"aabababababbb\") == False\n    assert candidate(s = \"bbbbbaaaaaaaaa\") == False\n    assert candidate(s = \"ababbab\") == False\n    assert candidate(s = \"aaaabbbbbaaabb\") == False\n    assert candidate(s = \"baaabbb\") == False\n    assert candidate(s = \"bbaaabbb\") == False\n    assert candidate(s = \"abbbab\") == False\n    assert candidate(s = \"aabbbbbba\") == False\n    assert candidate(s = \"aabbbbbaaab\") == False\n    assert candidate(s = \"aabaa\") == False\n    assert candidate(s = \"aabaaabba\") == False\n    assert candidate(s = \"aabbbbabbab\") == False\n    assert candidate(s = \"aaaaaaaaaa\") == True\n    assert candidate(s = \"babbaabbaabbaabb\") == False\n    assert candidate(s = \"baaabaaa\") == False\n    assert candidate(s = \"bbbbbbbaaaaaa\") == False\n    assert candidate(s = \"aaaababbbb\") == False\n    assert candidate(s = \"aabbbbaaa\") == False\n    assert candidate(s = \"aaaa\") == True\n    assert candidate(s = \"bbbbbbbbbaaaaaaaaa\") == False\n    assert candidate(s = \"bbbbbaaaa\") == False\n    assert candidate(s = \"aabbaabbabba\") == False\n    assert candidate(s = \"aaaaaaaaa\") == True\n    assert candidate(s = \"aaabbaabbb\") == False\n    assert candidate(s = \"bbbbbaaaaa\") == False\n    assert candidate(s = \"aaabba\") == False\n    assert candidate(s = \"bbbbaaab\") == False\n    assert candidate(s = \"aabbabb\") == False\n    assert candidate(s = \"bbab\") == False\n    assert candidate(s = \"baaaab\") == False\n    assert candidate(s = \"bbbbabaa\") == False\n    assert candidate(s = \"aabbbbba\") == False\n    assert candidate(s = \"baaabbbb\") == False\n    assert candidate(s = \"bbbaaa\") == False\n    assert candidate(s = \"abbbbaaaaa\") == False\n    assert candidate(s = \"aaaaaabbbbbb\") == True\n    assert candidate(s = \"aaabbbaa\") == False\n    assert candidate(s = \"bbbbba\") == False\n    assert candidate(s = \"aaaabbbbaaaa\") == False\n    assert candidate(s = \"bab\") == False\n    assert candidate(s = \"bbaabbba\") == False\n    assert candidate(s = \"aaaaabbbbbaaa\") == False\n    assert candidate(s = \"baaaabbb\") == False\n    assert candidate(s = \"aabbaabbb\") == False\n    assert candidate(s = \"aaaabbbbba\") == False\n    assert candidate(s = \"bababababa\") == False\n    assert candidate(s = \"abbbbaaa\") == False\n    assert candidate(s = \"bbaaaabbb\") == False\n    assert candidate(s = \"aabbbbbbaaaa\") == False\n    assert candidate(s = \"aaabb\") == True\n    assert candidate(s = \"aabaaaabbb\") == False\n    assert candidate(s = \"aaaaaaaaaabbbbbbbb\") == True\n    assert candidate(s = \"aaabbbaaab\") == False\n    assert candidate(s = \"ababababababab\") == False\n    assert candidate(s = \"aabbabaa\") == False\n    assert candidate(s = \"bbbbaa\") == False\n    assert candidate(s = \"aaaaaaaaaaabbbbbbbbbbb\") == True\n    assert candidate(s = \"bbbbbaab\") == False\n    assert candidate(s = \"bbbbbaaabbaabbaabb\") == False\n    assert candidate(s = \"abbbbbba\") == False\n    assert candidate(s = \"aaaaaaaaabbbbbbbb\") == True\n    assert candidate(s = \"bbbaaaaa\") == False\n    assert candidate(s = \"abbbba\") == False\n    assert candidate(s = \"aaaabbbbbbba\") == False\n    assert candidate(s = \"aaaaaab\") == True\n    assert candidate(s = \"babababaab\") == False\n    assert candidate(s = \"abababab\") == False\n    assert candidate(s = \"aaaaa\") == True\n    assert candidate(s = \"bbaaaa\") == False\n    assert candidate(s = \"aabbbbaa\") == False\n    assert candidate(s = \"aababbaa\") == False\n    assert candidate(s = \"aabbbbbaa\") == False\n    assert candidate(s = \"abbbbbbaaaaa\") == False\n    assert candidate(s = \"aaabbbbbba\") == False\n    assert candidate(s = \"bbbbbbbbaaaa\") == False\n    assert candidate(s = \"aaaaaaaaaabbbbbbbbbbb\") == True\n    assert candidate(s = \"bbbbbaaaaabbb\") == False\n    assert candidate(s = \"bbaabbabaa\") == False\n    assert candidate(s = \"aabb\") == True\n    assert candidate(s = \"ababbabababbab\") == False\n    assert candidate(s = \"bbbbbbbbbaaaaa\") == False\n    assert candidate(s = \"aaaabbbaaabb\") == False\n    assert candidate(s = \"bababaaaabbbb\") == False\n    assert candidate(s = \"bbaaa\") == False\n    assert candidate(s = \"aabbaaabaaaabbbb\") == False\n    assert candidate(s = \"aabababb\") == False\n    assert candidate(s = \"bbbb\") == True\n    assert candidate(s = \"aabbaabbbb\") == False\n    assert candidate(s = \"baaaaa\") == False\n    assert candidate(s = \"bbbbbaaaaabbbb\") == False\n    assert candidate(s = \"aabbaaa\") == False\n    assert candidate(s = \"ababab\") == False\n    assert candidate(s = \"babbba\") == False\n    assert candidate(s = \"bbbbbbbb\") == True\n    assert candidate(s = \"aaabbbab\") == False\n    assert candidate(s = \"bbaaaaaaab\") == False\n    assert candidate(s = \"aaaaabbbbbbbba\") == False\n    assert candidate(s = \"bbbbaaaaaa\") == False\n    assert candidate(s = \"aabbabbbaabbb\") == False\n    assert candidate(s = \"bababababab\") == False\n    assert candidate(s = \"bbbaa\") == False\n    assert candidate(s = \"bbbbbbbbb\") == True\n    assert candidate(s = \"baaaabbbb\") == False\n    assert candidate(s = \"aaaaabbbbbbbbb\") == True\n    assert candidate(s = \"aabbba\") == False\n    assert candidate(s = \"bababbababababab\") == False\n    assert candidate(s = \"bbbbbbbbbaaab\") == False\n    assert candidate(s = \"baab\") == False\n    assert candidate(s = \"baaabb\") == False\n    assert candidate(s = \"ababababbabababb\") == False\n    assert candidate(s = \"bababbab\") == False\n    assert candidate(s = \"ababababab\") == False\n    assert candidate(s = \"bbbaaaaabbbbbbbbaaaa\") == False\n    assert candidate(s = \"aabbbbbaaaa\") == False\n    assert candidate(s = \"aabbbbb\") == True\n    assert candidate(s = \"bbaa\") == False\n    assert candidate(s = \"bbbaababbb\") == False\n    assert candidate(s = \"bbbbaaaa\") == False\n    assert candidate(s = \"baaab\") == False\n    assert candidate(s = \"aaaaaabbbbba\") == False\n    assert candidate(s = \"abaaa\") == False\n    assert candidate(s = \"bbbaaabbb\") == False\n    assert candidate(s = \"babababa\") == False\n    assert candidate(s = \"aab\") == True\n    assert candidate(s = \"bbbbbbbaaaaaaaaa\") == False\n    assert candidate(s = \"abbbabab\") == False\n    assert candidate(s = \"bbbbaabbaabb\") == False\n    assert candidate(s = \"aabbbba\") == False\n    assert candidate(s = \"aaaaaaaa\") == True\n    assert candidate(s = \"aababbababaa\") == False\n    assert candidate(s = \"aabbababab\") == False\n    assert candidate(s = \"abbbbaaaab\") == False\n    assert candidate(s = \"bbaaabbaaab\") == False\n    assert candidate(s = \"aabbaab\") == False\n", "comparison": "exact"}, "public_tests": ["\"aaabbb\"", "\"abab\"", "\"bbb\""], "hints": ["You can check the opposite: check if there is a ‘b’ before an ‘a’. Then, negate and return that answer.", "s should not have any occurrences of “ba” as a substring."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().checkString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:57+00:00", "tests_total": 152, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def checkString(self, s: str) -> bool:", "container": "Solution", "callable": "checkString", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2125, "task_id": "number-of-laser-beams-in-a-bank", "difficulty": "Medium", "problem_description": "Anti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, which is an m x n 2D matrix. bank[i] represents the i^th row, consisting of '0's and '1's. '0' means the cell is empty, while'1' means the cell has a security device.\n\nThere is one laser beam between any two security devices if both conditions are met:\n\n- The two devices are located on two different rows: r_1 and r_2, where r_1 < r_2.\n- For each row i where r_1 < i < r_2, there are no security devices in the i^th row.\n\nLaser beams are independent, i.e., one beam does not interfere nor join with another.\n\nReturn the total number of laser beams in the bank.\n\nExample 1:\n\nInput: bank = [\"011001\",\"000000\",\"010100\",\"001000\"]\nOutput: 8\nExplanation: Between each of the following device pairs, there is one beam. In total, there are 8 beams:\n * bank[0][1] -- bank[2][1]\n * bank[0][1] -- bank[2][3]\n * bank[0][2] -- bank[2][1]\n * bank[0][2] -- bank[2][3]\n * bank[0][5] -- bank[2][1]\n * bank[0][5] -- bank[2][3]\n * bank[2][1] -- bank[3][2]\n * bank[2][3] -- bank[3][2]\nNote that there is no beam between any device on the 0^th row with any on the 3^rd row.\nThis is because the 2^nd row contains security devices, which breaks the second condition.\n\nExample 2:\n\nInput: bank = [\"000\",\"111\",\"000\"]\nOutput: 0\nExplanation: There does not exist two devices located on two different rows.\n\nConstraints:\n\n- m == bank.length\n- n == bank[i].length\n- 1 <= m, n <= 500\n- bank[i][j] is either '0' or '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(bank = ['00000', '00000', '00000', '00000']) == 0\n    assert candidate(bank = ['001', '000', '101', '000', '110']) == 6\n    assert candidate(bank = ['111', '000', '111']) == 9\n    assert candidate(bank = ['0000', '0000', '0000', '0000']) == 0\n    assert candidate(bank = ['11111', '11111', '11111']) == 50\n    assert candidate(bank = ['000', '000', '000']) == 0\n    assert candidate(bank = ['101', '010', '101', '010']) == 6\n    assert candidate(bank = ['000', '111', '000']) == 0\n    assert candidate(bank = ['001', '000', '110', '000', '101']) == 6\n    assert candidate(bank = ['1', '0', '1', '0', '1']) == 2\n    assert candidate(bank = ['111', '000', '111', '000', '111']) == 18\n    assert candidate(bank = ['10101', '01010', '10101', '01010']) == 18\n    assert candidate(bank = ['001', '010', '100']) == 2\n    assert candidate(bank = ['111', '111', '111', '111']) == 27\n    assert candidate(bank = ['101', '000', '101', '111']) == 10\n    assert candidate(bank = ['1010', '0101', '1010', '0101']) == 12\n    assert candidate(bank = ['1111', '0000', '1111', '0000']) == 16\n    assert candidate(bank = ['000', '000', '000', '111']) == 0\n    assert candidate(bank = ['000', '000', '000', '000']) == 0\n    assert candidate(bank = ['11111', '00000', '00000', '00000', '11111']) == 25\n    assert candidate(bank = ['11111', '00000', '11111', '00000']) == 25\n    assert candidate(bank = ['00000', '00001', '00010', '00100', '01000', '10000']) == 4\n    assert candidate(bank = ['011001', '000000', '010100', '001000']) == 8\n    assert candidate(bank = ['1', '1', '1', '1']) == 3\n    assert candidate(bank = ['1100', '0011', '0000', '1100']) == 8\n    assert candidate(bank = ['00100', '01010', '10001']) == 6\n    assert candidate(bank = ['01010', '01010', '01010', '01010']) == 12\n    assert candidate(bank = ['1111', '0000', '1111', '0000', '1111']) == 32\n    assert candidate(bank = ['000000', '110111', '000000', '111011', '000000', '101010', '000000']) == 40\n    assert candidate(bank = ['1010101010', '0101010101', '0000000000', '1111111111', '0000000000', '1010101010']) == 125\n    assert candidate(bank = ['11111111111111111111', '00000000000000000000', '11111111111111111111', '00000000000000000000', '11111111111111111111']) == 800\n    assert candidate(bank = ['100100', '001100', '010101', '101010', '000000', '111111']) == 37\n    assert candidate(bank = ['10101', '01010', '10101', '01010', '10101']) == 24\n    assert candidate(bank = ['00100', '01010', '10001', '01010', '10001', '01010']) == 18\n    assert candidate(bank = ['100000', '010000', '001000', '000100', '000010', '000001']) == 5\n    assert candidate(bank = ['1111111111', '0000000000', '1010101010', '0101010101', '0000000000', '1111111111']) == 125\n    assert candidate(bank = ['101010', '101010', '101010', '101010', '101010', '101010']) == 45\n    assert candidate(bank = ['10001', '01010', '00100', '00000', '10001', '01010', '00100']) == 14\n    assert candidate(bank = ['10000001', '00100100', '00011000', '00000000', '11111111', '00000000', '10101010']) == 56\n    assert candidate(bank = ['000', '111', '101', '010', '111', '000', '111']) == 20\n    assert candidate(bank = ['01010101', '00000000', '10101010', '00000000', '10101010', '00000000', '10101010']) == 48\n    assert candidate(bank = ['110011', '000000', '010100', '001000', '000000', '101010']) == 13\n    assert candidate(bank = ['000000000', '000000000', '000000000', '000000000', '111111111', '000000000', '111111111', '000000000', '000000000', '000000000']) == 81\n    assert candidate(bank = ['11111', '00000', '10001', '00100', '00000', '10001']) == 14\n    assert candidate(bank = ['11111', '10001', '01110', '10001', '11111']) == 32\n    assert candidate(bank = ['000000000', '000101000', '000000000', '000010000', '000000000', '100000001']) == 4\n    assert candidate(bank = ['000000', '000000', '000000', '000000', '000000', '000000']) == 0\n    assert candidate(bank = ['0101010101', '1010101010', '0101010101', '1010101010', '0101010101', '1010101010', '0101010101', '1010101010', '0101010101', '1010101010']) == 225\n    assert candidate(bank = ['10000001', '00000000', '00010000', '00000000', '00001000', '00000000', '00000100', '00000000']) == 4\n    assert candidate(bank = ['00000', '00000', '00000', '00000', '11111', '11111', '00000', '11111']) == 50\n    assert candidate(bank = ['111', '111', '111', '111', '111', '111', '111']) == 54\n    assert candidate(bank = ['00000', '00000', '00000', '00000', '00000', '11111', '00000', '11111', '00000', '11111']) == 50\n    assert candidate(bank = ['1110011', '0000000', '0111011', '0010100', '1111111', '0000000', '1000010']) == 63\n    assert candidate(bank = ['00000', '00100', '01110', '00100', '00000', '11111']) == 11\n    assert candidate(bank = ['101010', '010101', '101010', '000000', '010101']) == 27\n    assert candidate(bank = ['000000', '101010', '010101', '000000', '101010']) == 18\n    assert candidate(bank = ['0000000000', '0000000000', '0000000000', '1111111111', '0000000000', '1010101010', '0101010101', '0000000000']) == 75\n    assert candidate(bank = ['0010100', '1011011', '0000000', '0000000', '1100110', '0000000', '1001001', '0101010', '0000000', '0000000', '0000000', '1111111']) == 72\n    assert candidate(bank = ['111', '000', '000', '000', '111', '111', '000', '000', '111', '111']) == 36\n    assert candidate(bank = ['1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1']) == 7\n    assert candidate(bank = ['1111111111', '0000000000', '0000000000', '0000000000', '0000000000', '0000000000', '0000000000', '0000000000', '1111111111', '0000000000']) == 100\n    assert candidate(bank = ['110000', '001100', '000011', '001100', '110000', '000000', '110000', '001100', '000011', '001100']) == 32\n    assert candidate(bank = ['111111', '000000', '000000', '000000', '111111', '000000', '111111']) == 72\n    assert candidate(bank = ['101010', '010101', '101010', '000000', '111111']) == 36\n    assert candidate(bank = ['1', '0', '1', '0', '1', '0', '1']) == 3\n    assert candidate(bank = ['000000000000000000', '111111111111111111', '000000000000000000', '000000000000000000', '111111111111111111', '000000000000000000', '111111111111111111']) == 648\n    assert candidate(bank = ['1010101010', '0101010101', '0000000000', '1111111111', '0000000000', '1010101010', '0101010101']) == 150\n    assert candidate(bank = ['1010101010', '0000000000', '0000000000', '1010101010', '0000000000', '0000000000', '1010101010']) == 50\n    assert candidate(bank = ['00000', '11111', '10101', '01010', '11111', '00000']) == 31\n    assert candidate(bank = ['00000000', '00000000', '00000000', '00000001', '00000010', '00000100', '00001000', '00010000', '00100000', '01000000', '10000000', '00000000', '00000000', '00000000']) == 7\n    assert candidate(bank = ['1', '0', '1', '0', '1', '0', '1', '0', '1']) == 4\n    assert candidate(bank = ['00000', '10001', '01010', '00100', '10001', '01010', '00100', '10001', '01010', '00100']) == 22\n    assert candidate(bank = ['000000', '100101', '001000', '000100', '111111', '000000', '110111']) == 40\n    assert candidate(bank = ['010101010101010101', '101010101010101010', '000000000000000000', '000000000000000000', '111111111111111111', '000000000000000000', '101010101010101010']) == 405\n    assert candidate(bank = ['111000', '000111', '111000', '000111', '111000', '000111']) == 45\n    assert candidate(bank = ['0000000', '0000000', '0000000', '0000000', '0000000', '0000000', '1111111', '1111111']) == 49\n    assert candidate(bank = ['111111', '010101', '111111', '000000', '111111']) == 72\n    assert candidate(bank = ['0101010101', '0000000000', '1111111111', '0000000000', '1111111111', '0000000000', '0101010101', '1010101010', '0000000000', '1111111111']) == 275\n    assert candidate(bank = ['0000000', '0000000', '0101010', '0000000', '1010101', '0000000', '0101010']) == 24\n    assert candidate(bank = ['000000', '000000', '101010', '010101', '101010', '000000']) == 18\n    assert candidate(bank = ['1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0']) == 9\n    assert candidate(bank = ['110101', '000000', '011001', '000000', '100100']) == 18\n    assert candidate(bank = ['1001', '0110', '0000', '1101', '0010', '1010', '0101', '0000', '1111']) == 27\n    assert candidate(bank = ['111111', '000000', '000000', '000000', '111111', '000000', '111111', '000000', '111111']) == 108\n    assert candidate(bank = ['0000000000000000000000', '1111111111111111111111', '0000000000000000000000', '0000000000000000000000', '0000000000000000000000', '0000000000000000000000', '1111111111111111111111']) == 484\n    assert candidate(bank = ['111', '111', '000', '111', '111', '000', '111', '111', '000', '111']) == 54\n    assert candidate(bank = ['01010101', '10101010', '00000000', '11111111', '01010101']) == 80\n    assert candidate(bank = ['111000', '000111', '111000', '000111', '111000']) == 36\n    assert candidate(bank = ['00000', '11100', '00111', '01010', '10101', '11111', '00000', '11100', '00111', '01010', '10101']) == 72\n    assert candidate(bank = ['111111', '000000', '000000', '000000', '000000', '111111']) == 36\n    assert candidate(bank = ['0000000001', '0000000010', '0000000100', '0000001000', '0000010000', '0000100000', '0001000000', '0010000000', '0100000000', '1000000000']) == 9\n    assert candidate(bank = ['000000', '000100', '100010', '001000', '010000', '100001', '111111']) == 19\n    assert candidate(bank = ['00000', '00000', '00000', '11111', '00000', '11111', '00000', '11111']) == 50\n    assert candidate(bank = ['10001', '01100', '00000', '00000', '00000', '01100', '10001', '10001', '01100', '00000', '00000', '10001']) == 24\n    assert candidate(bank = ['01110', '00000', '11001', '00000', '01110', '00000', '10010']) == 24\n    assert candidate(bank = ['111111', '111111', '111111', '111111', '111111', '111111']) == 180\n    assert candidate(bank = ['111000', '000111', '111000', '000111', '111000', '000111', '111000', '000111']) == 63\n    assert candidate(bank = ['00100', '01010', '00000', '10001', '01010']) == 10\n    assert candidate(bank = ['1010101010', '0101010101', '1010101010', '0000000000', '0000000000', '1010101010', '0101010101', '1010101010']) == 125\n    assert candidate(bank = ['0000000', '0011000', '0000000', '1100110', '0000000', '0101010', '0000000', '1000100']) == 26\n    assert candidate(bank = ['110101', '000000', '101010', '000000', '110101']) == 24\n    assert candidate(bank = ['100100', '011011', '000000', '000000', '100100', '011011']) == 24\n    assert candidate(bank = ['001000', '001000', '001000', '001000', '001000', '001000']) == 5\n    assert candidate(bank = ['1100011', '0000000', '0110101', '0011001', '1010101', '1111111', '0000000', '1111111']) == 117\n    assert candidate(bank = ['010101', '101010', '010101', '101010', '010101', '101010', '010101']) == 54\n    assert candidate(bank = ['11111', '00000', '00000', '00000', '11111', '00000', '00000', '11111']) == 50\n    assert candidate(bank = ['111111', '000000', '110011', '001100', '111111', '000000', '111111']) == 80\n    assert candidate(bank = ['110000', '001100', '000011', '000000', '110000', '001100', '000011']) == 20\n    assert candidate(bank = ['0000000', '0010000', '0000100', '0000010', '0000001', '0000000', '0000000']) == 3\n    assert candidate(bank = ['000000', '000000', '000000', '000000', '110111', '000000', '101010']) == 15\n    assert candidate(bank = ['1111111', '0000000', '0101010', '0000000', '1010101', '0000000', '1111111']) == 61\n    assert candidate(bank = ['001000', '010100', '000010', '100001', '000000', '100100', '010010', '001001']) == 18\n    assert candidate(bank = ['000000', '010101', '101010', '000000', '111111', '000000']) == 27\n    assert candidate(bank = ['000000', '000100', '001010', '010001', '100010', '010100', '100001', '001000']) == 20\n    assert candidate(bank = ['1010101', '0101010', '1010101', '0101010', '1010101']) == 48\n    assert candidate(bank = ['1111111111', '0000000000', '1111111111', '0000000000', '1111111111', '0000000000', '1111111111', '0000000000', '1111111111', '0000000000']) == 400\n    assert candidate(bank = ['1111111111', '0000000000', '0000000000', '0000000000', '0000000000', '1111111111']) == 100\n", "comparison": "exact"}, "public_tests": ["[\"011001\",\"000000\",\"010100\",\"001000\"]", "[\"000\",\"111\",\"000\"]"], "hints": ["What is the commonality between security devices on the same row?", "Each device on the same row has the same number of beams pointing towards the devices on the next row with devices.", "If you were given an integer array where each element is the number of security devices on each row, can you solve it?", "Convert the input to such an array, skip any row with no security device, then find the sum of the product between adjacent elements."], "metadata": {"canonical_parameter_names": ["bank"], "leetcode_dataset_entry_point": "Solution().numberOfBeams", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:00+00:00", "tests_total": 117, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "math", "string", "matrix"]}, "language": "python", "interface": {"raw_signature": "def numberOfBeams(self, bank: list[str]) -> int:", "container": "Solution", "callable": "numberOfBeams", "parameters": [{"name": "bank", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2126, "task_id": "destroying-asteroids", "difficulty": "Medium", "problem_description": "You are given an integer mass, which represents the original mass of a planet. You are further given an integer array asteroids, where asteroids[i] is the mass of the i^th asteroid.\n\nYou can arrange for the planet to collide with the asteroids in any arbitrary order. If the mass of the planet is greater than or equal to the mass of the asteroid, the asteroid is destroyed and the planet gains the mass of the asteroid. Otherwise, the planet is destroyed.\n\nReturn true if all asteroids can be destroyed. Otherwise, return false.\n\nExample 1:\n\nInput: mass = 10, asteroids = [3,9,19,5,21]\nOutput: true\nExplanation: One way to order the asteroids is [9,19,5,3,21]:\n- The planet collides with the asteroid with a mass of 9. New planet mass: 10 + 9 = 19\n- The planet collides with the asteroid with a mass of 19. New planet mass: 19 + 19 = 38\n- The planet collides with the asteroid with a mass of 5. New planet mass: 38 + 5 = 43\n- The planet collides with the asteroid with a mass of 3. New planet mass: 43 + 3 = 46\n- The planet collides with the asteroid with a mass of 21. New planet mass: 46 + 21 = 67\nAll asteroids are destroyed.\n\nExample 2:\n\nInput: mass = 5, asteroids = [4,9,23,4]\nOutput: false\nExplanation:\nThe planet cannot ever gain enough mass to destroy the asteroid with a mass of 23.\nAfter the planet destroys the other asteroids, it will have a mass of 5 + 4 + 9 + 4 = 22.\nThis is less than 23, so a collision would not destroy the last asteroid.\n\nConstraints:\n\n- 1 <= mass <= 10^5\n- 1 <= asteroids.length <= 10^5\n- 1 <= asteroids[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(mass = 1,asteroids = [100000]) == False\n    assert candidate(mass = 1,asteroids = [1, 2, 3, 4, 5]) == True\n    assert candidate(mass = 5,asteroids = [4, 9, 23, 4]) == False\n    assert candidate(mass = 10,asteroids = [10, 10, 10, 10, 10]) == True\n    assert candidate(mass = 20,asteroids = [10, 10, 10, 10, 10]) == True\n    assert candidate(mass = 10,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n    assert candidate(mass = 100000,asteroids = [100000]) == True\n    assert candidate(mass = 10,asteroids = [5, 5, 5, 5, 5]) == True\n    assert candidate(mass = 1,asteroids = [1, 1, 1, 1, 1]) == True\n    assert candidate(mass = 1,asteroids = [1, 1, 1, 1]) == True\n    assert candidate(mass = 10,asteroids = [3, 9, 19, 5, 21]) == True\n    assert candidate(mass = 1,asteroids = [2, 2, 2, 2, 2]) == False\n    assert candidate(mass = 100,asteroids = [10, 20, 30, 40, 50]) == True\n    assert candidate(mass = 25,asteroids = [5, 10, 15]) == True\n    assert candidate(mass = 6,asteroids = [1, 2, 3, 4, 5, 6]) == True\n    assert candidate(mass = 30,asteroids = [15, 15, 15, 15, 15]) == True\n    assert candidate(mass = 100,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n    assert candidate(mass = 1000,asteroids = [500, 250, 125, 62, 31, 15, 7, 3, 1]) == True\n    assert candidate(mass = 20,asteroids = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n    assert candidate(mass = 50,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 100]) == False\n    assert candidate(mass = 25,asteroids = [10, 20, 5, 15, 25, 30, 5, 10, 20, 5]) == True\n    assert candidate(mass = 500,asteroids = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n    assert candidate(mass = 30,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n    assert candidate(mass = 100,asteroids = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == True\n    assert candidate(mass = 1,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 100000]) == False\n    assert candidate(mass = 25,asteroids = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == True\n    assert candidate(mass = 150,asteroids = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == True\n    assert candidate(mass = 10,asteroids = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == True\n    assert candidate(mass = 300,asteroids = [250, 200, 150, 100, 50, 300]) == True\n    assert candidate(mass = 100,asteroids = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == True\n    assert candidate(mass = 100,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n    assert candidate(mass = 9,asteroids = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n    assert candidate(mass = 50,asteroids = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == True\n    assert candidate(mass = 25,asteroids = [20, 10, 5, 15, 25, 30, 35, 40, 45, 50]) == True\n    assert candidate(mass = 1000,asteroids = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == True\n    assert candidate(mass = 1,asteroids = [100000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n    assert candidate(mass = 1000,asteroids = [900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 25, 10, 5, 1]) == True\n    assert candidate(mass = 1,asteroids = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n    assert candidate(mass = 1000,asteroids = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == True\n    assert candidate(mass = 200,asteroids = [100, 50, 150, 75, 25, 125, 225, 175, 200, 130]) == True\n    assert candidate(mass = 75,asteroids = [50, 25, 12, 6, 3, 1, 50, 25, 12, 6, 3, 1, 50, 25, 12, 6, 3, 1]) == True\n    assert candidate(mass = 1,asteroids = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n    assert candidate(mass = 5,asteroids = [3, 7, 2, 8, 6, 4, 10, 1]) == True\n    assert candidate(mass = 15,asteroids = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n    assert candidate(mass = 5,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n    assert candidate(mass = 20,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n    assert candidate(mass = 10,asteroids = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == True\n    assert candidate(mass = 5,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n    assert candidate(mass = 30,asteroids = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20]) == True\n    assert candidate(mass = 25,asteroids = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == True\n    assert candidate(mass = 75,asteroids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n    assert candidate(mass = 25,asteroids = [20, 15, 10, 5, 30, 25, 35, 40, 45, 50]) == True\n    assert candidate(mass = 1,asteroids = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n    assert candidate(mass = 10,asteroids = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == False\n    assert candidate(mass = 10,asteroids = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == True\n    assert candidate(mass = 50,asteroids = [100, 50, 25, 12, 6, 3, 1]) == True\n    assert candidate(mass = 200,asteroids = [100, 150, 50, 200, 250, 300, 350, 400, 450, 500]) == True\n    assert candidate(mass = 10,asteroids = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == True\n    assert candidate(mass = 1,asteroids = [2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == True\n    assert candidate(mass = 1,asteroids = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n    assert candidate(mass = 50,asteroids = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n    assert candidate(mass = 50000,asteroids = [10000, 20000, 15000, 5000, 25000, 30000, 40000, 60000]) == True\n    assert candidate(mass = 500,asteroids = [100, 200, 150, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000]) == True\n    assert candidate(mass = 5,asteroids = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10]) == True\n    assert candidate(mass = 50,asteroids = [100, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == True\n    assert candidate(mass = 100,asteroids = [20, 30, 50, 10, 40, 60, 70]) == True\n    assert candidate(mass = 10000,asteroids = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990]) == True\n    assert candidate(mass = 100,asteroids = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n    assert candidate(mass = 100,asteroids = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n    assert candidate(mass = 100,asteroids = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n    assert candidate(mass = 50,asteroids = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == True\n    assert candidate(mass = 5,asteroids = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n    assert candidate(mass = 50000,asteroids = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == True\n    assert candidate(mass = 20,asteroids = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20]) == True\n    assert candidate(mass = 15,asteroids = [20, 25, 30, 5, 10, 15, 35, 40]) == True\n    assert candidate(mass = 10,asteroids = [1, 100000, 2, 99999, 3, 99998, 4, 99997]) == False\n    assert candidate(mass = 15,asteroids = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n    assert candidate(mass = 120,asteroids = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == True\n    assert candidate(mass = 50,asteroids = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == True\n    assert candidate(mass = 15,asteroids = [10, 5, 15, 20, 25, 5]) == True\n    assert candidate(mass = 25,asteroids = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == True\n    assert candidate(mass = 100000,asteroids = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n    assert candidate(mass = 50,asteroids = [10, 20, 30, 40, 50]) == True\n    assert candidate(mass = 100,asteroids = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == True\n    assert candidate(mass = 15,asteroids = [1, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n    assert candidate(mass = 25,asteroids = [24, 23, 22, 21, 20, 19, 18, 17, 16, 15]) == True\n    assert candidate(mass = 5,asteroids = [1, 3, 2, 4, 6, 8, 7, 5, 9, 10]) == True\n    assert candidate(mass = 20,asteroids = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == True\n", "comparison": "exact"}, "public_tests": ["10\n[3,9,19,5,21]", "5\n[4,9,23,4]"], "hints": ["Choosing the asteroid to collide with can be done greedily.", "If an asteroid will destroy the planet, then every bigger asteroid will also destroy the planet.", "You only need to check the smallest asteroid at each collision. If it will destroy the planet, then every other asteroid will also destroy the planet.", "Sort the asteroids in non-decreasing order by mass, then greedily try to collide with the asteroids in that order."], "metadata": {"canonical_parameter_names": ["mass", "asteroids"], "leetcode_dataset_entry_point": "Solution().asteroidsDestroyed", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:02+00:00", "tests_total": 88, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def asteroidsDestroyed(self, mass: int, asteroids: list[int]) -> bool:", "container": "Solution", "callable": "asteroidsDestroyed", "parameters": [{"name": "mass", "type": "int"}, {"name": "asteroids", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2127, "task_id": "maximum-employees-to-be-invited-to-a-meeting", "difficulty": "Hard", "problem_description": "A company is organizing a meeting and has a list of n employees, waiting to be invited. They have arranged for a large circular table, capable of seating any number of employees.\n\nThe employees are numbered from 0 to n - 1. Each employee has a favorite person and they will attend the meeting only if they can sit next to their favorite person at the table. The favorite person of an employee is not themself.\n\nGiven a 0-indexed integer array favorite, where favorite[i] denotes the favorite person of the i^th employee, return the maximum number of employees that can be invited to the meeting.\n\nExample 1:\n\nInput: favorite = [2,2,1,2]\nOutput: 3\nExplanation:\nThe above figure shows how the company can invite employees 0, 1, and 2, and seat them at the round table.\nAll employees cannot be invited because employee 2 cannot sit beside employees 0, 1, and 3, simultaneously.\nNote that the company can also invite employees 1, 2, and 3, and give them their desired seats.\nThe maximum number of employees that can be invited to the meeting is 3.\n\nExample 2:\n\nInput: favorite = [1,2,0]\nOutput: 3\nExplanation:\nEach employee is the favorite person of at least one other employee, and the only way the company can invite them is if they invite every employee.\nThe seating arrangement will be the same as that in the figure given in example 1:\n- Employee 0 will sit between employees 2 and 1.\n- Employee 1 will sit between employees 0 and 2.\n- Employee 2 will sit between employees 1 and 0.\nThe maximum number of employees that can be invited to the meeting is 3.\n\nExample 3:\n\nInput: favorite = [3,0,1,4,1]\nOutput: 4\nExplanation:\nThe above figure shows how the company will invite employees 0, 1, 3, and 4, and seat them at the round table.\nEmployee 2 cannot be invited because the two spots next to their favorite employee 1 are taken.\nSo the company leaves them out of the meeting.\nThe maximum number of employees that can be invited to the meeting is 4.\n\nConstraints:\n\n- n == favorite.length\n- 2 <= n <= 10^5\n- 0 <= favorite[i] <= n - 1\n- favorite[i] != i\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(favorite = [1, 0, 0, 2]) == 4\n    assert candidate(favorite = [5, 4, 3, 2, 1, 0]) == 6\n    assert candidate(favorite = [2, 0, 1, 4, 5, 3]) == 3\n    assert candidate(favorite = [5, 4, 0, 2, 0, 1]) == 4\n    assert candidate(favorite = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 10\n    assert candidate(favorite = [1, 2, 0]) == 3\n    assert candidate(favorite = [3, 0, 1, 4, 1]) == 4\n    assert candidate(favorite = [1, 0, 3, 2]) == 4\n    assert candidate(favorite = [3, 3, 0, 2]) == 3\n    assert candidate(favorite = [2, 2, 1, 2]) == 3\n    assert candidate(favorite = [1, 0, 0, 2, 1, 4, 2]) == 6\n    assert candidate(favorite = [1, 0, 3, 4, 2]) == 3\n    assert candidate(favorite = [1, 0, 3, 2, 5, 4]) == 6\n    assert candidate(favorite = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1]) == 8\n    assert candidate(favorite = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == 10\n    assert candidate(favorite = [2, 2, 1, 0, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 11\n    assert candidate(favorite = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 15, 14, 13, 12]) == 16\n    assert candidate(favorite = [1, 2, 0, 5, 6, 3, 4, 9, 7, 8]) == 4\n    assert candidate(favorite = [1, 2, 0, 4, 5, 3, 7, 8, 9, 6]) == 4\n    assert candidate(favorite = [1, 2, 3, 0, 1, 2, 3, 4, 5, 6]) == 4\n    assert candidate(favorite = [1, 3, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15]) == 16\n    assert candidate(favorite = [1, 2, 0, 4, 5, 3, 7, 8, 9, 10, 11, 12, 13, 14, 6]) == 9\n    assert candidate(favorite = [3, 0, 1, 0, 7, 6, 5, 4, 9, 8]) == 10\n    assert candidate(favorite = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 16\n    assert candidate(favorite = [2, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1]) == 15\n    assert candidate(favorite = [2, 0, 1, 5, 3, 4, 8, 6, 7, 12, 9, 10, 11, 16, 13, 14, 15, 18, 19, 17]) == 4\n    assert candidate(favorite = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == 10\n    assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]) == 40\n    assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12, 13, 14, 10]) == 10\n    assert candidate(favorite = [1, 3, 0, 2, 5, 4, 7, 6, 9, 8]) == 6\n    assert candidate(favorite = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 20\n    assert candidate(favorite = [2, 2, 1, 2, 3, 3, 5, 5, 7, 7]) == 6\n    assert candidate(favorite = [1, 4, 3, 6, 5, 8, 7, 2, 9, 0]) == 6\n    assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 0, 10, 11, 12, 8, 9, 15, 16, 13, 14, 18, 19, 17]) == 8\n    assert candidate(favorite = [3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 1, 0]) == 8\n    assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 10\n    assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0]) == 15\n    assert candidate(favorite = [2, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 9\n    assert candidate(favorite = [1, 0, 3, 4, 5, 6, 7, 8, 9, 2]) == 8\n    assert candidate(favorite = [3, 2, 1, 0, 8, 8, 8, 8, 5, 5, 5, 5, 11, 11, 11, 11]) == 9\n    assert candidate(favorite = [1, 2, 0, 4, 5, 6, 3, 8, 9, 7]) == 4\n    assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 13, 14, 15, 12]) == 12\n    assert candidate(favorite = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1]) == 10\n    assert candidate(favorite = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == 10\n    assert candidate(favorite = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5]) == 8\n    assert candidate(favorite = [1, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 2]) == 13\n    assert candidate(favorite = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10]) == 10\n    assert candidate(favorite = [1, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 0]) == 16\n    assert candidate(favorite = [1, 3, 5, 7, 9, 0, 2, 4, 6, 8]) == 10\n    assert candidate(favorite = [2, 0, 3, 2, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 21\n    assert candidate(favorite = [3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18]) == 20\n    assert candidate(favorite = [3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12]) == 16\n    assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]) == 16\n    assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 10\n    assert candidate(favorite = [3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 18\n    assert candidate(favorite = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 4\n    assert candidate(favorite = [2, 3, 1, 0, 6, 7, 8, 9, 5, 10, 11, 4]) == 8\n    assert candidate(favorite = [7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 11, 10, 13, 12, 15, 14]) == 16\n    assert candidate(favorite = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == 22\n    assert candidate(favorite = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 14, 15, 12, 13]) == 6\n    assert candidate(favorite = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 20\n    assert candidate(favorite = [1, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]) == 41\n    assert candidate(favorite = [3, 0, 1, 4, 5, 3, 5, 6, 7, 8]) == 3\n", "comparison": "exact"}, "public_tests": ["[2,2,1,2]", "[1,2,0]", "[3,0,1,4,1]"], "hints": ["From the given array favorite, create a graph where for every index i, there is a directed edge from favorite[i] to i. The graph will be a combination of cycles and chains of acyclic edges. Now, what are the ways in which we can choose employees to sit at the table?", "The first way by which we can choose employees is by selecting a cycle of the graph. It can be proven that in this case, the employees that do not lie in the cycle can never be seated at the table (unless the cycle has a length of 2).", "The second way is by combining acyclic chains. At most two chains can be combined by a cycle of length 2, where each chain ends on one of the employees in the cycle."], "metadata": {"canonical_parameter_names": ["favorite"], "leetcode_dataset_entry_point": "Solution().maximumInvitations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:04+00:00", "tests_total": 127, "tests_dropped": 64, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "dynamic-programming", "depth-first-search", "graph", "topological-sort", "kosarajus-algorithm", "tarjans-scc-algorithm"]}, "language": "python", "interface": {"raw_signature": "def maximumInvitations(self, favorite: list[int]) -> int:", "container": "Solution", "callable": "maximumInvitations", "parameters": [{"name": "favorite", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2129, "task_id": "capitalize-the-title", "difficulty": "Easy", "problem_description": "You are given a string title consisting of one or more words separated by a single space, where each word consists of English letters. Capitalize the string by changing the capitalization of each word such that:\n\n- If the length of the word is 1 or 2 letters, change all letters to lowercase.\n- Otherwise, change the first letter to uppercase and the remaining letters to lowercase.\n\nReturn the capitalized title.\n\nExample 1:\n\nInput: title = \"capiTalIze tHe titLe\"\nOutput: \"Capitalize The Title\"\nExplanation:\nSince all the words have a length of at least 3, the first letter of each word is uppercase, and the remaining letters are lowercase.\n\nExample 2:\n\nInput: title = \"First leTTeR of EACH Word\"\nOutput: \"First Letter of Each Word\"\nExplanation:\nThe word \"of\" has length 2, so it is all lowercase.\nThe remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.\n\nExample 3:\n\nInput: title = \"i lOve leetcode\"\nOutput: \"i Love Leetcode\"\nExplanation:\nThe word \"i\" has length 1, so it is lowercase.\nThe remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.\n\nConstraints:\n\n- 1 <= title.length <= 100\n- title consists of words separated by a single space without any leading or trailing spaces.\n- Each word consists of uppercase and lowercase English letters and is non-empty.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(title = \"ai and ml\") == \"ai And ml\"\n    assert candidate(title = \"First leTTeR of EACH Word\") == \"First Letter of Each Word\"\n    assert candidate(title = \"tHis iS a tEsT\") == \"This is a Test\"\n    assert candidate(title = \"a b c\") == \"a b c\"\n    assert candidate(title = \"HELLO WORLD\") == \"Hello World\"\n    assert candidate(title = \"a b c d e f g\") == \"a b c d e f g\"\n    assert candidate(title = \"sMaLl wOrDs\") == \"Small Words\"\n    assert candidate(title = \"mY nAmE is Qwen\") == \"my Name is Qwen\"\n    assert candidate(title = \"abc\") == \"Abc\"\n    assert candidate(title = \"mY sOLution IS Awesome\") == \"my Solution is Awesome\"\n    assert candidate(title = \"ab\") == \"ab\"\n    assert candidate(title = \"Python Programming\") == \"Python Programming\"\n    assert candidate(title = \"this is a test\") == \"This is a Test\"\n    assert candidate(title = \"i lOve leetcode\") == \"i Love Leetcode\"\n    assert candidate(title = \"mY NaMe Is Qwen\") == \"my Name is Qwen\"\n    assert candidate(title = \"capiTalIze tHe titLe\") == \"Capitalize The Title\"\n    assert candidate(title = \"Alibaba Cloud\") == \"Alibaba Cloud\"\n    assert candidate(title = \"machine learning\") == \"Machine Learning\"\n    assert candidate(title = \"tHis is a TeSt\") == \"This is a Test\"\n    assert candidate(title = \"a\") == \"a\"\n    assert candidate(title = \"hello world\") == \"Hello World\"\n    assert candidate(title = \"tHis is A tEsT cASE\") == \"This is a Test Case\"\n    assert candidate(title = \"data science\") == \"Data Science\"\n    assert candidate(title = \"data science and machine learning\") == \"Data Science And Machine Learning\"\n    assert candidate(title = \"the quick\") == \"The Quick\"\n    assert candidate(title = \"tiny a big BIGGEST\") == \"Tiny a Big Biggest\"\n    assert candidate(title = \"advanced DATABASE MANAGEMENT SYSTEM\") == \"Advanced Database Management System\"\n    assert candidate(title = \"FLASK and DJANGO web FRAMEWORKS\") == \"Flask And Django Web Frameworks\"\n    assert candidate(title = \"sINGLEcHaRaCters AND twOCHaRaCters\") == \"Singlecharacters And Twocharacters\"\n    assert candidate(title = \"PYTHON pROGRAMMING\") == \"Python Programming\"\n    assert candidate(title = \"pyThOn cOdInG chAlLenge\") == \"Python Coding Challenge\"\n    assert candidate(title = \"data sCience and MaChine LeArning\") == \"Data Science And Machine Learning\"\n    assert candidate(title = \"PYTHON programming LANGUAGE\") == \"Python Programming Language\"\n    assert candidate(title = \"DESIGN PATTERNS in software ENGINEERING\") == \"Design Patterns in Software Engineering\"\n    assert candidate(title = \"lowercase with small words like a and the\") == \"Lowercase With Small Words Like a And The\"\n    assert candidate(title = \"wHy cApItAlIzE sOmE wOrDs\") == \"Why Capitalize Some Words\"\n    assert candidate(title = \"data sCience and MaChInE lEaRnInG\") == \"Data Science And Machine Learning\"\n    assert candidate(title = \"WEB DEVELOPMENT essentials\") == \"Web Development Essentials\"\n    assert candidate(title = \"an\") == \"an\"\n    assert candidate(title = \"Data Science and Machine Learning\") == \"Data Science And Machine Learning\"\n    assert candidate(title = \"INformation TECHNOLOGY\") == \"Information Technology\"\n    assert candidate(title = \"cryptography and SECURITY\") == \"Cryptography And Security\"\n    assert candidate(title = \"UPPER lower CASE\") == \"Upper Lower Case\"\n    assert candidate(title = \"SOFTWARE ENGINEERING principles\") == \"Software Engineering Principles\"\n    assert candidate(title = \"LONGEST wORD\") == \"Longest Word\"\n    assert candidate(title = \"pYtHoN pRoGrAmMiNg\") == \"Python Programming\"\n    assert candidate(title = \"multiple     spaces   here\") == \"Multiple Spaces Here\"\n    assert candidate(title = \"sInGlE\") == \"Single\"\n    assert candidate(title = \"openai gpt four\") == \"Openai Gpt Four\"\n    assert candidate(title = \"user INTERFACE and user EXPERIENCE\") == \"User Interface And User Experience\"\n    assert candidate(title = \"VIRTUALIZATION technology\") == \"Virtualization Technology\"\n    assert candidate(title = \"in the land OF wonder AND magic\") == \"in The Land of Wonder And Magic\"\n    assert candidate(title = \"CoMpLeX wOrDs LiKe SuPeRcAlIfR aNd qUiXoTtIc\") == \"Complex Words Like Supercalifr And Quixottic\"\n    assert candidate(title = \"tHis is A tEsT String\") == \"This is a Test String\"\n    assert candidate(title = \"INTERNET of THINGS iot\") == \"Internet of Things Iot\"\n    assert candidate(title = \"tHiS is a sHoRt TeSt\") == \"This is a Short Test\"\n    assert candidate(title = \"python programming LANGUAGE\") == \"Python Programming Language\"\n    assert candidate(title = \"a quick brown fox jumps over the lazy dog\") == \"a Quick Brown Fox Jumps Over The Lazy Dog\"\n    assert candidate(title = \"UPPERCASE lowercase MIXEDcase\") == \"Uppercase Lowercase Mixedcase\"\n    assert candidate(title = \"a SHORT story IN a SMALL town\") == \"a Short Story in a Small Town\"\n    assert candidate(title = \"single\") == \"Single\"\n    assert candidate(title = \"data STRUCTURE and ALGORITHMS\") == \"Data Structure And Algorithms\"\n    assert candidate(title = \"this is a test STRING with MIXED CASE\") == \"This is a Test String With Mixed Case\"\n    assert candidate(title = \"to be or not to be\") == \"to be or Not to be\"\n    assert candidate(title = \"wordlengthsofthreetwoone\") == \"Wordlengthsofthreetwoone\"\n    assert candidate(title = \"wiTh lOnG wOrDs liKe suPercalifragilisticexpialidocious\") == \"With Long Words Like Supercalifragilisticexpialidocious\"\n    assert candidate(title = \"this is a longer sentence with more words to test the function\") == \"This is a Longer Sentence With More Words to Test The Function\"\n    assert candidate(title = \"very Very LONG title with MANY Words indeed\") == \"Very Very Long Title With Many Words Indeed\"\n    assert candidate(title = \"Algorithms and DATA structures\") == \"Algorithms And Data Structures\"\n    assert candidate(title = \"tEsTiNg WoRdS wItH vArIoUs lEnGtHs\") == \"Testing Words With Various Lengths\"\n    assert candidate(title = \"a quick brown fox\") == \"a Quick Brown Fox\"\n    assert candidate(title = \"tExT pRoCeSsInG\") == \"Text Processing\"\n    assert candidate(title = \"the quick BROWN fox JUMPS OVER the LAZY DOG\") == \"The Quick Brown Fox Jumps Over The Lazy Dog\"\n    assert candidate(title = \"algorithms and data structures\") == \"Algorithms And Data Structures\"\n    assert candidate(title = \"a short AND a LONG word\") == \"a Short And a Long Word\"\n    assert candidate(title = \"AlGoRiThM aNd dAtA sTrUcTuRe\") == \"Algorithm And Data Structure\"\n    assert candidate(title = \"data sCIENCE and maCHine LEARNING\") == \"Data Science And Machine Learning\"\n    assert candidate(title = \"cOnsIdEr tHiS eXaMpLe\") == \"Consider This Example\"\n    assert candidate(title = \"cloud COMPUTING\") == \"Cloud Computing\"\n    assert candidate(title = \"fLASK aNd dJANGO\") == \"Flask And Django\"\n    assert candidate(title = \"To be OR not TO be\") == \"to be or Not to be\"\n    assert candidate(title = \"multiple words of varying length and CASE\") == \"Multiple Words of Varying Length And Case\"\n    assert candidate(title = \"network SECURITY\") == \"Network Security\"\n    assert candidate(title = \"programming IN python\") == \"Programming in Python\"\n    assert candidate(title = \"the QUICK brown FOX jumps OVER the LAZY dog\") == \"The Quick Brown Fox Jumps Over The Lazy Dog\"\n    assert candidate(title = \"MiXcAsE wOrDlEnGtH\") == \"Mixcase Wordlength\"\n    assert candidate(title = \"in\") == \"in\"\n    assert candidate(title = \"wiTh grEat pOwEr cOmEs gReAt rEsPoNsIbIlItY\") == \"With Great Power Comes Great Responsibility\"\n    assert candidate(title = \"algorithms AND dataSTRUCTURES\") == \"Algorithms And Datastructures\"\n    assert candidate(title = \"wiTh gReAt pOWeR cOmEs gReAt rEsPoNsIbIlItY\") == \"With Great Power Comes Great Responsibility\"\n    assert candidate(title = \"A B c D E F G\") == \"a b c d e f g\"\n    assert candidate(title = \"AI and MACHINE LEARNING\") == \"ai And Machine Learning\"\n    assert candidate(title = \"big DATA ANALYSIS\") == \"Big Data Analysis\"\n    assert candidate(title = \"mUlTiPlE sMaLl wOrDs\") == \"Multiple Small Words\"\n    assert candidate(title = \"LEETcode IS coOL\") == \"Leetcode is Cool\"\n    assert candidate(title = \"two Words\") == \"Two Words\"\n    assert candidate(title = \"introduction to ARTIFICIAL INTELLIGENCE\") == \"Introduction to Artificial Intelligence\"\n    assert candidate(title = \"sOlVe tHe rObOt wOrLd cHAlLeNgEs\") == \"Solve The Robot World Challenges\"\n    assert candidate(title = \"mIxEd cAsE iNpUt\") == \"Mixed Case Input\"\n    assert candidate(title = \"EACH WORD IN THE TITLE\") == \"Each Word in The Title\"\n    assert candidate(title = \"programming in PYTHON\") == \"Programming in Python\"\n    assert candidate(title = \"one two three four five six seven eight nine ten\") == \"One Two Three Four Five Six Seven Eight Nine Ten\"\n    assert candidate(title = \"very very LONG words in THIS sentence\") == \"Very Very Long Words in This Sentence\"\n    assert candidate(title = \"leet code CHALLENGE\") == \"Leet Code Challenge\"\n    assert candidate(title = \"the\") == \"The\"\n    assert candidate(title = \"double two\") == \"Double Two\"\n    assert candidate(title = \"a B c D E F G\") == \"a b c d e f g\"\n    assert candidate(title = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\") == \"a b c d e f g h i j k l m n o p q r s t u v w x y z\"\n    assert candidate(title = \"in The HoLlyWoOd\") == \"in The Hollywood\"\n    assert candidate(title = \"tHis is a tEsT string\") == \"This is a Test String\"\n    assert candidate(title = \"MiXeD CaSe wOrDs\") == \"Mixed Case Words\"\n    assert candidate(title = \"multiple small words in here\") == \"Multiple Small Words in Here\"\n    assert candidate(title = \"in the HEART of the CITY\") == \"in The Heart of The City\"\n    assert candidate(title = \"randomly CaPiTaLiZed WoRds\") == \"Randomly Capitalized Words\"\n    assert candidate(title = \"To BE OR NOT to BE\") == \"to be or Not to be\"\n    assert candidate(title = \"MiNiMaL MaXiMaL\") == \"Minimal Maximal\"\n    assert candidate(title = \"HELLO wORLD\") == \"Hello World\"\n    assert candidate(title = \"THE quick BROWN fox JUMPS OVER the LAZY dog\") == \"The Quick Brown Fox Jumps Over The Lazy Dog\"\n    assert candidate(title = \"data SCIENCE and MACHINE LEARNING\") == \"Data Science And Machine Learning\"\n    assert candidate(title = \"pYthon programming lanGuage\") == \"Python Programming Language\"\n    assert candidate(title = \"OpenAI GPT-4\") == \"Openai Gpt-4\"\n    assert candidate(title = \"triple three words\") == \"Triple Three Words\"\n    assert candidate(title = \"eNcYcLopEdIa oF pHySiCs aNd mAtHeMaTiCs\") == \"Encyclopedia of Physics And Mathematics\"\n    assert candidate(title = \"a a a a a a a\") == \"a a a a a a a\"\n    assert candidate(title = \"openAI GPT AND machineLEARNING\") == \"Openai Gpt And Machinelearning\"\n    assert candidate(title = \"PYTHON programming\") == \"Python Programming\"\n    assert candidate(title = \"sOFTWARE dEVELOPMENT\") == \"Software Development\"\n    assert candidate(title = \"tHiS iS a TeSt CaSe\") == \"This is a Test Case\"\n    assert candidate(title = \"wEb dEveLopMeNt fOr bEgInNeRs\") == \"Web Development For Beginners\"\n    assert candidate(title = \"one\") == \"One\"\n    assert candidate(title = \"Data STRUCTURES and ALGORITHMs\") == \"Data Structures And Algorithms\"\n    assert candidate(title = \"aBcDeFgHiJ kLmNoPqRsT\") == \"Abcdefghij Klmnopqrst\"\n    assert candidate(title = \"Python Programming Language\") == \"Python Programming Language\"\n    assert candidate(title = \"blockCHAIN technology\") == \"Blockchain Technology\"\n    assert candidate(title = \"Python Programming Is Fun\") == \"Python Programming is Fun\"\n    assert candidate(title = \"LoNg WoRdS aNd sHoRt wOrDs\") == \"Long Words And Short Words\"\n    assert candidate(title = \"tHe qUiCk bRoWn fOx\") == \"The Quick Brown Fox\"\n", "comparison": "exact"}, "public_tests": ["\"capiTalIze tHe titLe\"", "\"First leTTeR of EACH Word\"", "\"i lOve leetcode\""], "hints": ["Firstly, try to find all the words present in the string.", "On the basis of each word's lengths, simulate the process explained in Problem."], "metadata": {"canonical_parameter_names": ["title"], "leetcode_dataset_entry_point": "Solution().capitalizeTitle", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:09+00:00", "tests_total": 137, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def capitalizeTitle(self, title: str) -> str:", "container": "Solution", "callable": "capitalizeTitle", "parameters": [{"name": "title", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2131, "task_id": "longest-palindrome-by-concatenating-two-letter-words", "difficulty": "Medium", "problem_description": "You are given an array of strings words. Each element of words consists of two lowercase English letters.\n\nCreate the longest possible palindrome by selecting some elements from words and concatenating them in any order. Each element can be selected at most once.\n\nReturn the length of the longest palindrome that you can create. If it is impossible to create any palindrome, return 0.\n\nA palindrome is a string that reads the same forward and backward.\n\nExample 1:\n\nInput: words = [\"lc\",\"cl\",\"gg\"]\nOutput: 6\nExplanation: One longest palindrome is \"lc\" + \"gg\" + \"cl\" = \"lcggcl\", of length 6.\nNote that \"clgglc\" is another longest palindrome that can be created.\n\nExample 2:\n\nInput: words = [\"ab\",\"ty\",\"yt\",\"lc\",\"cl\",\"ab\"]\nOutput: 8\nExplanation: One longest palindrome is \"ty\" + \"lc\" + \"cl\" + \"yt\" = \"tylcclyt\", of length 8.\nNote that \"lcyttycl\" is another longest palindrome that can be created.\n\nExample 3:\n\nInput: words = [\"cc\",\"ll\",\"xx\"]\nOutput: 2\nExplanation: One longest palindrome is \"cc\", of length 2.\nNote that \"ll\" is another longest palindrome that can be created, and so is \"xx\".\n\nConstraints:\n\n- 1 <= words.length <= 10^5\n- words[i].length == 2\n- words[i] consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(words = ['xy', 'yx', 'xy', 'yx', 'xy', 'yx']) == 12\n    assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'ee']) == 2\n    assert candidate(words = ['ab', 'ba', 'xy', 'yx', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz']) == 22\n    assert candidate(words = ['ab', 'ba', 'cc', 'dd', 'dc', 'ca', 'ac']) == 10\n    assert candidate(words = ['cc', 'll', 'xx']) == 2\n    assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz']) == 104\n    assert candidate(words = ['ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba']) == 16\n    assert candidate(words = ['mn', 'nm', 'op', 'po', 'qp', 'pq', 'rs', 'sr', 'tu', 'ut', 'vu', 'uv']) == 24\n    assert candidate(words = ['zz', 'aa', 'bb', 'cc', 'zz', 'aa']) == 10\n    assert candidate(words = ['ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba']) == 52\n    assert candidate(words = ['ab', 'ty', 'yt', 'lc', 'cl', 'ab']) == 8\n    assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj']) == 2\n    assert candidate(words = ['lc', 'cl', 'gg']) == 6\n    assert candidate(words = ['aa', 'aa', 'aa', 'aa']) == 8\n    assert candidate(words = ['aa', 'aa', 'aa', 'aa', 'aa']) == 10\n    assert candidate(words = ['ab', 'ba', 'cc', 'dd', 'ab', 'ba']) == 10\n    assert candidate(words = ['ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy']) == 52\n    assert candidate(words = ['ab', 'ba', 'ab', 'ba', 'ab', 'ba']) == 12\n    assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz']) == 2\n    assert candidate(words = ['aa', 'aa', 'aa', 'bb', 'bb', 'cc', 'cc', 'cc', 'cc', 'dd', 'dd', 'dd', 'dd']) == 26\n    assert candidate(words = ['aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa', 'aa']) == 52\n    assert candidate(words = ['aa', 'aa', 'aa', 'aa', 'ab', 'ba', 'ab', 'ba', 'ac', 'ca', 'ac', 'ca', 'ad', 'da', 'ad', 'da', 'ae', 'ea', 'ae', 'ea', 'af', 'fa', 'af', 'fa', 'ag', 'ga', 'ag', 'ga', 'ah', 'ha', 'ah', 'ha', 'ai', 'ia', 'ai', 'ia', 'aj', 'ja', 'aj', 'ja', 'ak', 'ka', 'ak', 'ka', 'al', 'la', 'al', 'la', 'am', 'ma', 'am', 'ma', 'an', 'na', 'an', 'na', 'ao', 'oa', 'ao', 'oa', 'ap', 'pa', 'ap', 'pa', 'aq', 'qa', 'aq', 'qa', 'ar', 'ra', 'ar', 'ra', 'as', 'sa', 'as', 'sa', 'at', 'ta', 'at', 'ta', 'au', 'ua', 'au', 'ua', 'av', 'va', 'av', 'va', 'aw', 'wa', 'aw', 'wa', 'ax', 'xa', 'ax', 'xa', 'ay', 'ya', 'ay', 'ya', 'az', 'za', 'az', 'za', 'bb', 'bb', 'bb', 'bb', 'cc', 'cc', 'cc', 'cc', 'dd', 'dd', 'dd', 'dd', 'ee', 'ee', 'ee', 'ee', 'ff', 'ff', 'ff', 'ff', 'gg', 'gg', 'gg', 'gg', 'hh', 'hh', 'hh', 'hh', 'ii', 'ii', 'ii', 'ii', 'jj', 'jj', 'jj', 'jj', 'kk', 'kk', 'kk', 'kk', 'll', 'll', 'll', 'll', 'mm', 'mm', 'mm', 'mm', 'nn', 'nn', 'nn', 'nn', 'oo', 'oo', 'oo', 'oo', 'pp', 'pp', 'pp', 'pp', 'qq', 'qq', 'qq', 'qq', 'rr', 'rr', 'rr', 'rr', 'ss', 'ss', 'ss', 'ss', 'tt', 'tt', 'tt', 'tt', 'uu', 'uu', 'uu', 'uu', 'vv', 'vv', 'vv', 'vv', 'ww', 'ww', 'ww', 'ww', 'xx', 'xx', 'xx', 'xx', 'yy', 'yy', 'yy', 'yy', 'zz', 'zz', 'zz', 'zz']) == 408\n    assert candidate(words = ['ab', 'ba', 'xy', 'yx', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji']) == 24\n    assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz', 'zz', 'yy', 'xx', 'ww', 'vv', 'uu', 'tt', 'ss', 'rr', 'qq', 'pp', 'oo', 'nn', 'mm', 'll', 'kk', 'jj', 'ii', 'hh', 'gg', 'ff', 'ee', 'dd', 'cc', 'bb', 'aa']) == 104\n    assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd']) == 18\n    assert candidate(words = ['zz', 'zz', 'xy', 'yx', 'yx', 'xy', 'ab', 'ba', 'ab', 'ba', 'zz', 'zz']) == 24\n    assert candidate(words = ['ab', 'ba', 'xy', 'yx', 'zy', 'yz', 'ab', 'ba', 'xy', 'yx', 'zy', 'yz', 'ab', 'ba', 'xy', 'yx', 'zy', 'yz', 'ab', 'ba', 'xy', 'yx', 'zy', 'yz', 'ab', 'ba', 'xy', 'yx', 'zy', 'yz', 'ab', 'ba', 'xy', 'yx', 'zy', 'yz']) == 72\n    assert candidate(words = ['xy', 'yx', 'xx', 'yy', 'xy', 'yx', 'xx', 'yy', 'xy', 'yx', 'xx', 'yy']) == 22\n    assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz']) == 18\n    assert candidate(words = ['aa', 'bb', 'aa', 'bb', 'cc', 'dd', 'cc', 'dd', 'ee', 'ff', 'ee', 'ff']) == 24\n    assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd']) == 64\n    assert candidate(words = ['xy', 'yx', 'zz', 'zz', 'yx', 'xz', 'zx', 'zz']) == 14\n    assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'aa', 'bb', 'cc', 'dd', 'aa']) == 18\n    assert candidate(words = ['ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk']) == 24\n    assert candidate(words = ['aa', 'aa', 'aa', 'aa', 'bb', 'bb', 'bb', 'bb', 'cc', 'cc', 'cc', 'cc', 'dd', 'dd', 'dd', 'dd', 'ee', 'ee', 'ee', 'ee', 'ff', 'ff', 'ff', 'ff', 'gg', 'gg', 'gg', 'gg', 'hh', 'hh', 'hh', 'hh']) == 64\n    assert candidate(words = ['ab', 'ba', 'xy', 'yx', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'ab', 'ba', 'xy', 'yx', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy']) == 112\n    assert candidate(words = ['ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'cd', 'dc', 'cd', 'dc', 'ef', 'fe', 'ef', 'fe', 'gh', 'hg', 'gh', 'hg']) == 36\n    assert candidate(words = ['ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz']) == 54\n    assert candidate(words = ['xy', 'yx', 'yx', 'xy', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx', 'xy', 'xy', 'yx', 'yx']) == 304\n    assert candidate(words = ['ab', 'ba', 'ac', 'ca', 'ad', 'da', 'bc', 'cb', 'bd', 'db']) == 20\n    assert candidate(words = ['ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'zx', 'xz', 'ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'zx', 'xz']) == 112\n    assert candidate(words = ['xy', 'yx', 'yy', 'xx', 'zz', 'zz', 'zz', 'zz', 'xy', 'yx', 'xx', 'yy', 'zz', 'zz']) == 28\n    assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz', 'xy', 'yx', 'xz', 'zx', 'yz', 'zy', 'yx', 'zx', 'yz', 'zy', 'yx', 'zx', 'yz', 'zy', 'yx', 'zx', 'yz', 'zy', 'yx', 'zx', 'yz', 'zy']) == 30\n    assert candidate(words = ['ab', 'ba', 'cd', 'dc', 'cd', 'dc', 'ab', 'ba', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg']) == 76\n    assert candidate(words = ['ab', 'ba', 'ac', 'ca', 'ad', 'da', 'ae', 'ea', 'af', 'fa', 'ag', 'ga', 'ah', 'ha', 'ai', 'ia', 'aj', 'ja', 'ak', 'ka', 'al', 'la', 'am', 'ma', 'an', 'na', 'ao', 'oa', 'ap', 'pa', 'aq', 'qa', 'ar', 'ra', 'as', 'sa', 'at', 'ta', 'au', 'ua', 'av', 'va', 'aw', 'wa', 'ax', 'xa', 'ay', 'ya', 'az', 'za', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz']) == 102\n    assert candidate(words = ['mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'aa', 'bb', 'cc', 'dd']) == 30\n    assert candidate(words = ['ab', 'ba', 'xy', 'yx', 'zy', 'yz', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp']) == 14\n    assert candidate(words = ['ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'zx', 'xz', 'yz', 'zy', 'zx', 'xz', 'yz', 'zy', 'zx', 'xz', 'yz', 'zy', 'zx', 'xz', 'yz', 'zy', 'zx', 'xz']) == 88\n    assert candidate(words = ['qq', 'ww', 'ee', 'rr', 'tt', 'yy', 'uu', 'ii', 'oo', 'pp', 'aa', 'ss', 'dd', 'ff', 'gg', 'hh', 'jj', 'kk', 'll', 'zz', 'xx', 'cc', 'vv', 'bb', 'nn', 'mm', 'll', 'kk', 'jj', 'ii', 'hh', 'gg', 'ff', 'dd', 'ss', 'aa', 'pp', 'oo', 'nn', 'mm', 'zz', 'xx', 'vv', 'cc', 'uu', 'tt', 'rr', 'ee', 'ww', 'qq']) == 98\n    assert candidate(words = ['ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zz']) == 92\n    assert candidate(words = ['ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'zz', 'zz', 'aa', 'aa', 'bb', 'bb', 'cc', 'cc', 'dd', 'dd', 'ee', 'ee', 'ff', 'ff', 'gg', 'gg', 'hh', 'hh', 'ii', 'ii', 'jj', 'jj', 'kk', 'kk', 'll', 'll', 'mm', 'mm', 'nn', 'nn', 'oo', 'oo', 'pp', 'pp', 'qq', 'qq', 'rr', 'rr', 'ss', 'ss', 'tt', 'tt', 'uu', 'uu', 'vv', 'vv', 'ww', 'ww', 'xx', 'xx', 'yy', 'yy']) == 156\n    assert candidate(words = ['aa', 'bb', 'cc', 'aa', 'bb', 'cc', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz', 'aa', 'bb', 'cc']) == 26\n", "comparison": "exact"}, "public_tests": ["[\"lc\",\"cl\",\"gg\"]", "[\"ab\",\"ty\",\"yt\",\"lc\",\"cl\",\"ab\"]", "[\"cc\",\"ll\",\"xx\"]"], "hints": ["A palindrome must be mirrored over the center. Suppose we have a palindrome. If we prepend the word \"ab\" on the left, what must we append on the right to keep it a palindrome?", "We must append \"ba\" on the right. The number of times we can do this is the minimum of (occurrences of \"ab\") and (occurrences of \"ba\").", "For words that are already palindromes, e.g. \"aa\", we can prepend and append these in pairs as described in the previous hint. We can also use exactly one in the middle to form an even longer palindrome."], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().longestPalindrome", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:13+00:00", "tests_total": 52, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "string", "greedy", "counting"]}, "language": "python", "interface": {"raw_signature": "def longestPalindrome(self, words: list[str]) -> int:", "container": "Solution", "callable": "longestPalindrome", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2132, "task_id": "stamping-the-grid", "difficulty": "Hard", "problem_description": "You are given an m x n binary matrix grid where each cell is either 0 (empty) or 1 (occupied).\n\nYou are then given stamps of size stampHeight x stampWidth. We want to fit the stamps such that they follow the given restrictions and requirements:\n\n1. Cover all the empty cells.\n2. Do not cover any of the occupied cells.\n3. We can put as many stamps as we want.\n4. Stamps can overlap with each other.\n5. Stamps are not allowed to be rotated.\n6. Stamps must stay completely inside the grid.\n\nReturn true if it is possible to fit the stamps while following the given restrictions and requirements. Otherwise, return false.\n\nExample 1:\n\nInput: grid = [[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0]], stampHeight = 4, stampWidth = 3\nOutput: true\nExplanation: We have two overlapping stamps (labeled 1 and 2 in the image) that are able to cover all the empty cells.\n\nExample 2:\n\nInput: grid = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]], stampHeight = 2, stampWidth = 2\nOutput: false\nExplanation: There is no way to fit the stamps onto all the empty cells without the stamps going outside the grid.\n\nConstraints:\n\n- m == grid.length\n- n == grid[r].length\n- 1 <= m, n <= 10^5\n- 1 <= m * n <= 2 * 10^5\n- grid[r][c] is either 0 or 1.\n- 1 <= stampHeight, stampWidth <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],stampHeight = 2,stampWidth = 2) == True\n    assert candidate(grid = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],stampHeight = 1,stampWidth = 1) == True\n    assert candidate(grid = [[0, 0], [0, 0]],stampHeight = 1,stampWidth = 1) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == True\n    assert candidate(grid = [[1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0]],stampHeight = 4,stampWidth = 3) == True\n    assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],stampHeight = 2,stampWidth = 2) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 2) == False\n    assert candidate(grid = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]],stampHeight = 3,stampWidth = 3) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 4) == True\n    assert candidate(grid = [[1, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],stampHeight = 3,stampWidth = 3) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]],stampHeight = 5,stampWidth = 5) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 5) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 1, 0], [0, 1, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 1, 0], [0, 1, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 2,stampWidth = 3) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 5,stampWidth = 5) == True\n    assert candidate(grid = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 4) == True\n    assert candidate(grid = [[1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1]],stampHeight = 2,stampWidth = 3) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 5) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == True\n    assert candidate(grid = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0]],stampHeight = 2,stampWidth = 3) == False\n    assert candidate(grid = [[1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 1, 0]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 4) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\n    assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 4) == False\n    assert candidate(grid = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1]],stampHeight = 2,stampWidth = 2) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 4) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 4) == False\n    assert candidate(grid = [[0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0]],stampHeight = 2,stampWidth = 2) == True\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]],stampHeight = 2,stampWidth = 2) == True\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]],stampHeight = 2,stampWidth = 3) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 5,stampWidth = 10) == True\n    assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1]],stampHeight = 3,stampWidth = 3) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1, 0]],stampHeight = 3,stampWidth = 2) == False\n    assert candidate(grid = [[0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0]],stampHeight = 2,stampWidth = 2) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 5,stampWidth = 4) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],stampHeight = 2,stampWidth = 4) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0]],stampHeight = 2,stampWidth = 3) == False\n    assert candidate(grid = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 4) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 3) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 4) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 5) == True\n    assert candidate(grid = [[0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 2) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 5) == True\n    assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]],stampHeight = 2,stampWidth = 3) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]],stampHeight = 2,stampWidth = 3) == True\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0]],stampHeight = 2,stampWidth = 3) == False\n    assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0]],stampHeight = 3,stampWidth = 3) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]],stampHeight = 3,stampWidth = 4) == True\n    assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\n    assert candidate(grid = [[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1]],stampHeight = 3,stampWidth = 2) == False\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]],stampHeight = 1,stampWidth = 1) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 5) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 4) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 4) == False\n    assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],stampHeight = 5,stampWidth = 4) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 5,stampWidth = 5) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],stampHeight = 4,stampWidth = 4) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]],stampHeight = 2,stampWidth = 3) == False\n    assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]],stampHeight = 2,stampWidth = 2) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 3) == True\n    assert candidate(grid = [[0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0]],stampHeight = 2,stampWidth = 2) == False\n    assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]],stampHeight = 3,stampWidth = 2) == False\n", "comparison": "exact"}, "public_tests": ["[[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0]]\n4\n3", "[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]\n2\n2"], "hints": ["Can we use prefix sums here?"], "metadata": {"canonical_parameter_names": ["grid", "stampHeight", "stampWidth"], "leetcode_dataset_entry_point": "Solution().possibleToStamp", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:16+00:00", "tests_total": 81, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "greedy", "matrix", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def possibleToStamp(self, grid: list[list[int]], stampHeight: int, stampWidth: int) -> bool:", "container": "Solution", "callable": "possibleToStamp", "parameters": [{"name": "grid", "type": "list[list[int]]"}, {"name": "stampHeight", "type": "int"}, {"name": "stampWidth", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2133, "task_id": "check-if-every-row-and-column-contains-all-numbers", "difficulty": "Easy", "problem_description": "An n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive).\n\nGiven an n x n integer matrix matrix, return true if the matrix is valid. Otherwise, return false.\n\nExample 1:\n\nInput: matrix = [[1,2,3],[3,1,2],[2,3,1]]\nOutput: true\nExplanation: In this case, n = 3, and every row and column contains the numbers 1, 2, and 3.\nHence, we return true.\n\nExample 2:\n\nInput: matrix = [[1,1,1],[1,2,3],[1,2,3]]\nOutput: false\nExplanation: In this case, n = 3, but the first row and the first column do not contain the numbers 2 or 3.\nHence, we return false.\n\nConstraints:\n\n- n == matrix.length == matrix[i].length\n- 1 <= n <= 100\n- 1 <= matrix[i][j] <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(matrix = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]]) == True\n    assert candidate(matrix = [[4, 3, 2, 1], [1, 4, 3, 2], [2, 1, 4, 3], [3, 2, 1, 4]]) == True\n    assert candidate(matrix = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == False\n    assert candidate(matrix = [[1]]) == True\n    assert candidate(matrix = [[1, 1, 1], [1, 2, 3], [1, 2, 3]]) == False\n    assert candidate(matrix = [[1, 2, 3], [3, 1, 2], [2, 3, 1]]) == True\n    assert candidate(matrix = [[1, 2], [2, 1]]) == True\n    assert candidate(matrix = [[4, 3, 2, 1], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2]]) == False\n    assert candidate(matrix = [[7, 4, 3, 8, 5, 6, 2, 1], [1, 5, 6, 2, 8, 3, 7, 4], [8, 1, 7, 4, 2, 5, 3, 6], [2, 6, 5, 3, 7, 1, 8, 5], [6, 7, 8, 5, 1, 4, 5, 2], [3, 8, 4, 6, 5, 2, 1, 7], [5, 2, 1, 7, 6, 8, 4, 3], [4, 3, 2, 1, 4, 7, 6, 5]]) == False\n    assert candidate(matrix = [[4, 3, 2, 1], [1, 2, 3, 4], [2, 4, 1, 3], [3, 1, 4, 2]]) == True\n    assert candidate(matrix = [[7, 2, 5, 3, 8, 9, 4, 6, 1], [6, 4, 9, 1, 7, 5, 3, 2, 8], [1, 8, 3, 6, 4, 2, 5, 7, 9], [8, 9, 4, 5, 6, 7, 2, 1, 3], [5, 6, 7, 8, 9, 3, 1, 4, 2], [3, 1, 2, 4, 5, 6, 8, 9, 7], [2, 7, 6, 9, 1, 4, 9, 3, 5], [4, 5, 8, 2, 3, 1, 6, 7, 9], [9, 3, 1, 7, 2, 8, 4, 5, 6]]) == False\n    assert candidate(matrix = [[4, 3, 2, 1], [3, 2, 1, 4], [2, 1, 4, 3], [1, 4, 3, 2]]) == True\n    assert candidate(matrix = [[2, 3, 1, 4], [3, 1, 4, 2], [1, 4, 2, 3], [4, 2, 3, 1]]) == True\n    assert candidate(matrix = [[7, 3, 5, 1, 6, 2, 4], [4, 6, 2, 5, 3, 7, 1], [1, 2, 4, 7, 1, 5, 3], [5, 4, 3, 6, 7, 1, 2], [3, 1, 6, 2, 4, 5, 7], [2, 7, 1, 4, 5, 3, 6], [6, 5, 7, 3, 2, 4, 1]]) == False\n    assert candidate(matrix = [[7, 6, 5, 4, 3, 2, 1], [1, 7, 6, 5, 4, 3, 2], [2, 1, 7, 6, 5, 4, 3], [3, 2, 1, 7, 6, 5, 4], [4, 3, 2, 1, 7, 6, 5], [5, 4, 3, 2, 1, 7, 6], [6, 5, 4, 3, 2, 1, 7]]) == True\n    assert candidate(matrix = [[7, 6, 5, 4, 3, 2, 1], [2, 7, 6, 5, 4, 3, 1], [4, 3, 2, 1, 7, 6, 5], [6, 5, 4, 3, 2, 1, 7], [3, 2, 1, 7, 6, 5, 4], [1, 7, 6, 5, 4, 3, 2], [5, 4, 3, 2, 1, 7, 6]]) == False\n    assert candidate(matrix = [[2, 3, 1], [3, 1, 2], [1, 2, 3]]) == True\n    assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [3, 4, 5, 6, 7, 8, 9, 10, 1, 2], [4, 5, 6, 7, 8, 9, 10, 1, 2, 3], [5, 6, 7, 8, 9, 10, 1, 2, 3, 4], [6, 7, 8, 9, 10, 1, 2, 3, 4, 5], [7, 8, 9, 10, 1, 2, 3, 4, 5, 6], [8, 9, 10, 1, 2, 3, 4, 5, 6, 7], [9, 10, 1, 2, 3, 4, 5, 6, 7, 8], [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == True\n    assert candidate(matrix = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 4, 1, 3], [3, 1, 4, 2]]) == True\n    assert candidate(matrix = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]) == True\n    assert candidate(matrix = [[9, 5, 7, 4, 3, 8, 1, 2, 6], [4, 2, 6, 8, 7, 1, 3, 9, 5], [8, 1, 3, 9, 5, 4, 7, 6, 2], [5, 7, 4, 3, 8, 6, 9, 1, 2], [2, 8, 1, 6, 9, 5, 4, 3, 7], [3, 6, 9, 1, 2, 7, 8, 5, 4], [7, 4, 2, 5, 1, 9, 6, 8, 3], [6, 9, 5, 7, 4, 3, 2, 1, 8], [1, 3, 8, 2, 6, 2, 5, 4, 9]]) == False\n    assert candidate(matrix = [[2, 3, 1, 4], [1, 4, 2, 3], [3, 1, 4, 2], [4, 2, 3, 1]]) == True\n    assert candidate(matrix = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 1], [3, 4, 5, 6, 7, 8, 9, 1, 2], [4, 5, 6, 7, 8, 9, 1, 2, 3], [5, 6, 7, 8, 9, 1, 2, 3, 4], [6, 7, 8, 9, 1, 2, 3, 4, 5], [7, 8, 9, 1, 2, 3, 4, 5, 6], [8, 9, 1, 2, 3, 4, 5, 6, 7], [9, 1, 2, 3, 4, 5, 6, 7, 8]]) == False\n    assert candidate(matrix = [[5, 2, 1, 4, 3], [3, 5, 4, 2, 1], [4, 1, 3, 5, 2], [2, 4, 5, 1, 3], [1, 3, 2, 3, 4]]) == False\n    assert candidate(matrix = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 9, 8, 7, 6, 5, 4, 3, 2], [2, 1, 9, 8, 7, 6, 5, 4, 3], [3, 2, 1, 9, 8, 7, 6, 5, 4], [4, 3, 2, 1, 9, 8, 7, 6, 5], [5, 4, 3, 2, 1, 9, 8, 7, 6], [6, 5, 4, 3, 2, 1, 9, 8, 7], [7, 6, 5, 4, 3, 2, 1, 9, 8], [8, 7, 6, 5, 4, 3, 2, 1, 9]]) == True\n    assert candidate(matrix = [[5, 3, 4, 1, 2], [1, 2, 5, 3, 4], [2, 4, 1, 5, 3], [3, 5, 2, 4, 1], [4, 1, 3, 2, 5]]) == True\n    assert candidate(matrix = [[5, 1, 4, 2, 3], [2, 3, 5, 4, 1], [4, 5, 2, 1, 3], [3, 4, 1, 5, 2], [1, 2, 3, 3, 4]]) == False\n    assert candidate(matrix = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [3, 4, 5, 6, 7, 8, 9, 10, 1, 2], [4, 5, 6, 7, 8, 9, 10, 1, 2, 3], [5, 6, 7, 8, 9, 10, 1, 2, 3, 4], [6, 7, 8, 9, 10, 1, 2, 3, 4, 5], [7, 8, 9, 10, 1, 2, 3, 4, 5, 6], [8, 9, 10, 1, 2, 3, 4, 5, 6, 7], [9, 10, 1, 2, 3, 4, 5, 6, 7, 8]]) == False\n    assert candidate(matrix = [[8, 7, 6, 5, 4, 3, 2, 1], [1, 8, 7, 6, 5, 4, 3, 2], [2, 1, 8, 7, 6, 5, 4, 3], [3, 2, 1, 8, 7, 6, 5, 4], [4, 3, 2, 1, 8, 7, 6, 5], [5, 4, 3, 2, 1, 8, 7, 6], [6, 5, 4, 3, 2, 1, 8, 7], [7, 6, 5, 4, 3, 2, 1, 8]]) == True\n    assert candidate(matrix = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 10], [8, 7, 6, 5, 4, 3, 2, 1, 10, 9], [7, 6, 5, 4, 3, 2, 1, 10, 9, 8], [6, 5, 4, 3, 2, 1, 10, 9, 8, 7], [5, 4, 3, 2, 1, 10, 9, 8, 7, 6], [4, 3, 2, 1, 10, 9, 8, 7, 6, 5], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [2, 1, 10, 9, 8, 7, 6, 5, 4, 3], [1, 10, 9, 8, 7, 6, 5, 4, 3, 2]]) == True\n    assert candidate(matrix = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 10], [8, 7, 6, 5, 4, 3, 2, 1, 10, 9], [7, 6, 5, 4, 3, 2, 1, 10, 9, 8], [6, 5, 4, 3, 2, 1, 10, 9, 8, 7], [5, 4, 3, 2, 1, 10, 9, 8, 7, 6], [4, 3, 2, 1, 10, 9, 8, 7, 6, 5], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [2, 1, 10, 9, 8, 7, 6, 5, 4, 3], [1, 10, 9, 8, 7, 6, 5, 4, 3, 2]]) == True\n    assert candidate(matrix = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 1, 10, 9, 8, 7, 6, 5, 4, 3], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [4, 3, 2, 1, 10, 9, 8, 7, 6, 5], [5, 4, 3, 2, 1, 10, 9, 8, 7, 6], [6, 5, 4, 3, 2, 1, 10, 9, 8, 7], [7, 6, 5, 4, 3, 2, 1, 10, 9, 8], [8, 7, 6, 5, 4, 3, 2, 1, 10, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == False\n    assert candidate(matrix = [[9, 3, 1, 4, 2, 6, 8, 7, 5], [6, 7, 2, 1, 9, 5, 3, 4, 8], [1, 4, 8, 6, 3, 7, 2, 5, 9], [8, 5, 9, 7, 4, 2, 6, 1, 3], [4, 2, 6, 8, 5, 3, 1, 9, 7], [7, 1, 3, 9, 6, 4, 5, 8, 2], [5, 8, 4, 2, 1, 9, 7, 3, 6], [2, 6, 7, 3, 8, 1, 4, 9, 5], [3, 9, 5, 5, 7, 8, 9, 2, 4]]) == False\n    assert candidate(matrix = [[9, 7, 5, 2, 6, 8, 3, 1, 4], [4, 3, 1, 7, 9, 5, 8, 2, 6], [6, 8, 2, 4, 1, 3, 7, 9, 5], [3, 5, 9, 6, 7, 1, 2, 4, 8], [8, 2, 4, 9, 5, 7, 6, 3, 1], [1, 6, 7, 3, 8, 4, 9, 5, 2], [5, 9, 6, 1, 2, 8, 4, 7, 3], [7, 4, 8, 5, 3, 9, 1, 6, 2], [2, 1, 3, 8, 4, 6, 5, 7, 9]]) == False\n    assert candidate(matrix = [[9, 5, 1, 6, 7, 2, 8, 4, 3], [2, 8, 7, 4, 1, 3, 6, 9, 5], [6, 4, 3, 8, 2, 5, 9, 1, 7], [5, 9, 6, 1, 4, 7, 3, 2, 8], [8, 2, 4, 9, 3, 1, 5, 7, 6], [7, 1, 9, 5, 6, 8, 4, 3, 2], [3, 6, 5, 7, 9, 4, 2, 8, 1], [4, 7, 8, 2, 5, 6, 1, 3, 9], [1, 3, 2, 3, 8, 9, 7, 5, 4]]) == False\n    assert candidate(matrix = [[2, 3, 1], [1, 2, 3], [3, 1, 2]]) == True\n    assert candidate(matrix = [[7, 5, 6, 4, 3, 2, 1], [1, 7, 5, 6, 4, 3, 2], [2, 1, 7, 5, 6, 4, 3], [3, 2, 1, 7, 5, 6, 4], [4, 3, 2, 1, 7, 5, 6], [5, 4, 3, 2, 1, 7, 5], [6, 5, 4, 3, 2, 1, 7]]) == False\n    assert candidate(matrix = [[6, 5, 4, 3, 2, 1], [1, 6, 5, 4, 3, 2], [2, 1, 6, 5, 4, 3], [3, 2, 1, 6, 5, 4], [4, 3, 2, 1, 6, 5], [5, 4, 3, 2, 1, 6]]) == True\n    assert candidate(matrix = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]) == True\n    assert candidate(matrix = [[6, 5, 4, 3, 2, 1], [2, 1, 6, 5, 4, 3], [4, 3, 2, 1, 6, 5], [5, 4, 3, 2, 1, 6], [3, 2, 1, 6, 5, 4], [1, 6, 5, 4, 3, 2]]) == True\n    assert candidate(matrix = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 10, 9, 8, 7, 6, 5, 4, 3, 2], [2, 1, 10, 9, 8, 7, 6, 5, 4, 3], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [4, 3, 2, 1, 10, 9, 8, 7, 6, 5], [5, 4, 3, 2, 1, 10, 9, 8, 7, 6], [6, 5, 4, 3, 2, 1, 10, 9, 8, 7], [7, 6, 5, 4, 3, 2, 1, 10, 9, 8], [8, 7, 6, 5, 4, 3, 2, 1, 10, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]]) == True\n    assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 1, 5, 4], [4, 5, 2, 1, 3], [3, 1, 4, 3, 2]]) == False\n    assert candidate(matrix = [[2, 3, 1, 5, 4], [4, 1, 5, 2, 3], [5, 4, 2, 3, 1], [1, 5, 3, 4, 2], [3, 2, 4, 1, 5]]) == True\n    assert candidate(matrix = [[5, 3, 4, 1, 2], [2, 1, 5, 3, 4], [4, 5, 3, 2, 1], [1, 4, 2, 5, 3], [3, 2, 1, 4, 5]]) == True\n    assert candidate(matrix = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2, 1, 9], [7, 6, 5, 4, 3, 2, 1, 9, 8], [6, 5, 4, 3, 2, 1, 9, 8, 7], [5, 4, 3, 2, 1, 9, 8, 7, 6], [4, 3, 2, 1, 9, 8, 7, 6, 5], [3, 2, 1, 9, 8, 7, 6, 5, 4], [2, 1, 9, 8, 7, 6, 5, 4, 3], [1, 9, 8, 7, 6, 5, 4, 3, 2]]) == True\n    assert candidate(matrix = [[1, 2, 3, 4], [3, 4, 1, 2], [2, 1, 4, 3], [4, 3, 2, 1]]) == True\n    assert candidate(matrix = [[1, 2, 3], [2, 1, 3], [3, 2, 1]]) == False\n    assert candidate(matrix = [[5, 1, 2, 3, 4], [1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3]]) == True\n    assert candidate(matrix = [[9, 3, 7, 1, 2, 8, 5, 6, 4], [5, 8, 4, 7, 6, 2, 3, 9, 1], [6, 1, 2, 5, 9, 3, 4, 7, 8], [7, 4, 9, 2, 5, 6, 1, 3, 8], [8, 6, 5, 9, 3, 1, 7, 4, 2], [2, 7, 3, 6, 4, 8, 9, 1, 5], [1, 5, 6, 8, 7, 9, 2, 4, 3], [3, 9, 1, 4, 2, 5, 8, 6, 7], [4, 2, 8, 3, 1, 7, 6, 5, 9]]) == False\n    assert candidate(matrix = [[1, 2, 3], [2, 1, 3], [3, 1, 2]]) == False\n    assert candidate(matrix = [[10, 6, 3, 7, 5, 9, 1, 2, 4, 8], [7, 4, 1, 5, 9, 2, 6, 3, 8, 10], [1, 9, 2, 6, 3, 8, 10, 4, 5, 7], [4, 5, 9, 1, 2, 6, 8, 7, 10, 3], [6, 8, 5, 4, 7, 3, 2, 1, 9, 10], [2, 3, 10, 8, 6, 4, 5, 9, 7, 1], [8, 2, 7, 9, 4, 1, 3, 10, 6, 5], [9, 7, 6, 3, 1, 5, 10, 2, 4, 8], [5, 1, 8, 10, 3, 7, 4, 6, 1, 9], [3, 10, 4, 2, 8, 9, 7, 5, 2, 6]]) == False\n", "comparison": "exact"}, "public_tests": ["[[1,2,3],[3,1,2],[2,3,1]]", "[[1,1,1],[1,2,3],[1,2,3]]"], "hints": ["Use for loops to check each row for every number from 1 to n. Similarly, do the same for each column.", "For each check, you can keep a set of the unique elements in the checked row/col. By the end of the check, the size of the set should be n."], "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().checkValid", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:18+00:00", "tests_total": 57, "tests_dropped": 6, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "matrix"]}, "language": "python", "interface": {"raw_signature": "def checkValid(self, matrix: list[list[int]]) -> bool:", "container": "Solution", "callable": "checkValid", "parameters": [{"name": "matrix", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2134, "task_id": "minimum-swaps-to-group-all-1s-together-ii", "difficulty": "Medium", "problem_description": "A swap is defined as taking two distinct positions in an array and swapping the values in them.\n\nA circular array is defined as an array where we consider the first element and the last element to be adjacent.\n\nGiven a binary circular array nums, return the minimum number of swaps required to group all 1's present in the array together at any location.\n\nExample 1:\n\nInput: nums = [0,1,0,1,1,0,0]\nOutput: 1\nExplanation: Here are a few of the ways to group all the 1's together:\n[0,0,1,1,1,0,0] using 1 swap.\n[0,1,1,1,0,0,0] using 1 swap.\n[1,1,0,0,0,0,1] using 2 swaps (using the circular property of the array).\nThere is no way to group all 1's together with 0 swaps.\nThus, the minimum number of swaps required is 1.\n\nExample 2:\n\nInput: nums = [0,1,1,1,0,0,1,1,0]\nOutput: 2\nExplanation: Here are a few of the ways to group all the 1's together:\n[1,1,1,0,0,0,0,1,1] using 2 swaps (using the circular property of the array).\n[1,1,1,1,1,0,0,0,0] using 2 swaps.\nThere is no way to group all 1's together with 0 or 1 swaps.\nThus, the minimum number of swaps required is 2.\n\nExample 3:\n\nInput: nums = [1,1,0,0,1]\nOutput: 0\nExplanation: All the 1's are already grouped together due to the circular property of the array.\nThus, the minimum number of swaps required is 0.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- nums[i] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 0, 0, 0, 1, 1, 1, 0, 0, 1]) == 2\n    assert candidate(nums = [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0]) == 2\n    assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1]) == 0\n    assert candidate(nums = [0, 1, 0, 1, 1, 0, 0]) == 1\n    assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n    assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1]) == 2\n    assert candidate(nums = [1, 1, 0, 0, 1]) == 0\n    assert candidate(nums = [1, 0, 0, 1, 0, 1]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [0, 1, 1, 1, 0, 0, 1, 1, 0]) == 2\n    assert candidate(nums = [0, 0, 1, 0, 0, 0, 0, 1, 0]) == 1\n    assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1]) == 1\n    assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n    assert candidate(nums = [0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n    assert candidate(nums = [1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0]) == 3\n    assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1]) == 2\n    assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == 5\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1]) == 2\n    assert candidate(nums = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0]) == 4\n    assert candidate(nums = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 7\n    assert candidate(nums = [0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 6\n    assert candidate(nums = [0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1]) == 2\n    assert candidate(nums = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]) == 5\n    assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(nums = [1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1]) == 6\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 5\n    assert candidate(nums = [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 4\n    assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == 5\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1]) == 3\n    assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == 9\n    assert candidate(nums = [0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0]) == 4\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1]) == 4\n    assert candidate(nums = [1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1]) == 3\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 7\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 5\n    assert candidate(nums = [1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 8\n    assert candidate(nums = [1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0]) == 5\n    assert candidate(nums = [0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == 3\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 7\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 10\n    assert candidate(nums = [1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0]) == 6\n    assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == 7\n    assert candidate(nums = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 3\n    assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]) == 6\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 3\n    assert candidate(nums = [1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 4\n    assert candidate(nums = [1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0]) == 3\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 7\n    assert candidate(nums = [1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1]) == 10\n    assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 6\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == 4\n    assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 7\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 3\n    assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]) == 0\n    assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 5\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 5\n    assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == 4\n    assert candidate(nums = [1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == 6\n    assert candidate(nums = [1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 5\n    assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == 3\n    assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 8\n    assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 5\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 4\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 17\n    assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == 3\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0]) == 10\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 6\n    assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 2\n    assert candidate(nums = [1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 3\n    assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 5\n    assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 4\n    assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0]) == 5\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 8\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 4\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 5\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0]) == 4\n    assert candidate(nums = [1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1]) == 3\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 8\n    assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 3\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == 3\n", "comparison": "exact"}, "public_tests": ["[0,1,0,1,1,0,0]", "[0,1,1,1,0,0,1,1,0]", "[1,1,0,0,1]"], "hints": ["Notice that the number of 1’s to be grouped together is fixed. It is the number of 1's the whole array has.", "Call this number total. We should then check for every subarray of size total (possibly wrapped around), how many swaps are required to have the subarray be all 1’s.", "The number of swaps required is the number of 0’s in the subarray.", "To eliminate the circular property of the array, we can append the original array to itself. Then, we check each subarray of length total.", "How do we avoid recounting the number of 0’s in the subarray each time? The Sliding Window technique can help."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minSwaps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:20+00:00", "tests_total": 117, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def minSwaps(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minSwaps", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2135, "task_id": "count-words-obtained-after-adding-a-letter", "difficulty": "Medium", "problem_description": "You are given two 0-indexed arrays of strings startWords and targetWords. Each string consists of lowercase English letters only.\n\nFor each string in targetWords, check if it is possible to choose a string from startWords and perform a conversion operation on it to be equal to that from targetWords.\n\nThe conversion operation is described in the following two steps:\n\n1. Append any lowercase letter that is not present in the string to its end.\n  - For example, if the string is \"abc\", the letters 'd', 'e', or 'y' can be added to it, but not 'a'. If 'd' is added, the resulting string will be \"abcd\".\n2. Rearrange the letters of the new string in any arbitrary order.\n  - For example, \"abcd\" can be rearranged to \"acbd\", \"bacd\", \"cbda\", and so on. Note that it can also be rearranged to \"abcd\" itself.\n\nReturn the number of strings in targetWords that can be obtained by performing the operations on any string of startWords.\n\nNote that you will only be verifying if the string in targetWords can be obtained from a string in startWords by performing the operations. The strings in startWords do not actually change during this process.\n\nExample 1:\n\nInput: startWords = [\"ant\",\"act\",\"tack\"], targetWords = [\"tack\",\"act\",\"acti\"]\nOutput: 2\nExplanation:\n- In order to form targetWords[0] = \"tack\", we use startWords[1] = \"act\", append 'k' to it, and rearrange \"actk\" to \"tack\".\n- There is no string in startWords that can be used to obtain targetWords[1] = \"act\".\n  Note that \"act\" does exist in startWords, but we must append one letter to the string before rearranging it.\n- In order to form targetWords[2] = \"acti\", we use startWords[1] = \"act\", append 'i' to it, and rearrange \"acti\" to \"acti\" itself.\n\nExample 2:\n\nInput: startWords = [\"ab\",\"a\"], targetWords = [\"abc\",\"abcd\"]\nOutput: 1\nExplanation:\n- In order to form targetWords[0] = \"abc\", we use startWords[0] = \"ab\", add 'c' to it, and rearrange it to \"abc\".\n- There is no string in startWords that can be used to obtain targetWords[1] = \"abcd\".\n\nConstraints:\n\n- 1 <= startWords.length, targetWords.length <= 5 * 10^4\n- 1 <= startWords[i].length, targetWords[j].length <= 26\n- Each string of startWords and targetWords consists of lowercase English letters only.\n- No letter occurs more than once in any string of startWords or targetWords.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(startWords = ['ant', 'act', 'tack'],targetWords = ['tack', 'act', 'acti']) == 2\n    assert candidate(startWords = ['ab', 'a'],targetWords = ['abc', 'abcd']) == 1\n    assert candidate(startWords = ['pqrst', 'vwxyz', 'abcdef'],targetWords = ['qrstuvw', 'vwxyzab', 'abcdefg', 'pqrstuv', 'mnopqr']) == 1\n    assert candidate(startWords = ['python', 'java', 'c'],targetWords = ['pythonx', 'javaz', 'cb']) == 3\n    assert candidate(startWords = ['abcdexyz', 'mnopqr', 'stuv'],targetWords = ['abcdexyzw', 'mnopqrs', 'stuvq']) == 3\n    assert candidate(startWords = ['python', 'java', 'csharp'],targetWords = ['pythonic', 'javacoffee', 'csharptool', 'pythonjava', 'javacsharp']) == 0\n    assert candidate(startWords = ['abc', 'def', 'ghi', 'jkl', 'mno'],targetWords = ['abcd', 'abce', 'abcf', 'abck', 'abcm']) == 5\n    assert candidate(startWords = ['xyz', 'uvw', 'rst'],targetWords = ['xyza', 'uvwq', 'rstv', 'rstw']) == 4\n    assert candidate(startWords = ['abcd', 'bcde', 'cdef'],targetWords = ['abcde', 'bcdefg', 'abcdef', 'bcd']) == 1\n    assert candidate(startWords = ['a', 'bc', 'def', 'ghij', 'klmno'],targetWords = ['ab', 'bcd', 'cdef', 'defgh', 'efghij', 'fghijk']) == 3\n    assert candidate(startWords = ['abcde', 'fghij', 'klmno'],targetWords = ['bcdef', 'ghijk', 'klmnoa', 'mnopqr', 'stuvwx']) == 1\n    assert candidate(startWords = ['hello', 'world', 'abc'],targetWords = ['helloa', 'worldb', 'abcd']) == 3\n    assert candidate(startWords = ['mnopqr', 'stuvwx', 'yzabcd'],targetWords = ['mnopqrs', 'stuvwxy', 'yzabcde', 'mnopqrst', 'stuvwxyz', 'yzabcdef', 'mnopqrstuv', 'stuvwxyzab', 'yzabcdefg', 'mnopqrstu', 'stuvwxyzabc', 'yzabcdefg', 'mnopqrstuvw', 'stuvwxyzabcd', 'yzabcdefgh', 'mnopqrstuvwx', 'stuvwxyzabcde', 'yzabcdefgij', 'mnopqrstuvwxy', 'stuvwxyzabcdef', 'yzabcdefgijk']) == 3\n    assert candidate(startWords = ['xyz', 'uvw', 'qrst'],targetWords = ['xyza', 'uvwxy', 'qrstuv', 'qrstuvw', 'uvwq']) == 2\n    assert candidate(startWords = ['mnopqr', 'stuvwx', 'yzabcd', 'efghij', 'klmno'],targetWords = ['mnopqrs', 'stuvwxy', 'yzabcdx', 'efghijk', 'klmnop', 'abcdefgh']) == 5\n    assert candidate(startWords = ['abc', 'def', 'ghi'],targetWords = ['abcd', 'abcf', 'defg', 'ghij']) == 4\n    assert candidate(startWords = ['abc', 'def', 'ghi'],targetWords = ['abcd', 'efg', 'hij', 'defg', 'ghik']) == 3\n    assert candidate(startWords = ['xyz', 'mnop', 'qrst'],targetWords = ['xyzw', 'mnopq', 'qrstuvw']) == 2\n    assert candidate(startWords = ['a', 'b', 'c', 'd'],targetWords = ['ab', 'bc', 'cd', 'da', 'abc', 'bcd', 'cda', 'dab']) == 4\n    assert candidate(startWords = ['abcdefghij', 'klmnopqr', 'stuvwxyz'],targetWords = ['abcdefghijk', 'klmnopqrs', 'stuvwxyzab', 'abcdefghijl', 'klmnopqrt', 'stuvwxyzabc', 'abcdefghijm', 'klmnopqru', 'stuvwxyzabcd', 'abcdefghijn', 'klmnopqrv', 'stuvwxyzabcde', 'abcdefghijo', 'klmnopqrw', 'stuvwxyzabcdef', 'abcdefghijp', 'klmnopqrx', 'stuvwxyzabcdefg', 'abcdefghirq', 'klmnopqry', 'stuvwxyzabcdefgh', 'abcdefghirs', 'klmnopqrz', 'stuvwxyzabcdefghi', 'abcdefghirt', 'klmnopqs', 'stuvwxyzabcdefghij', 'abcdefghiru', 'klmnopqt', 'stuvwxyzabcdefghijk', 'abcdefghirv', 'klmnopqu', 'stuvwxyzabcdefghijl', 'abcdefghirw', 'klmnopqv', 'stuvwxyzabcdefghijm', 'abcdefghirx', 'klmnopqw', 'stuvwxyzabcdefghijn', 'abcdefghiry', 'klmnopqx', 'stuvwxyzabcdefghijo', 'abcdefghirz', 'klmnopqy', 'stuvwxyzabcdefghijp', 'klmnopqz', 'stuvwxyzabcdefghirq']) == 14\n    assert candidate(startWords = ['quick', 'brown', 'fox'],targetWords = ['quicks', 'brownf', 'foxj', 'quickm', 'brownx']) == 5\n    assert candidate(startWords = ['a', 'b', 'c'],targetWords = ['ab', 'bc', 'ca', 'abc', 'abcd']) == 3\n    assert candidate(startWords = ['abc', 'def', 'ghi'],targetWords = ['abcd', 'efg', 'ghij']) == 2\n    assert candidate(startWords = ['zebra', 'dog', 'cat'],targetWords = ['zebrao', 'doge', 'taco']) == 3\n    assert candidate(startWords = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],targetWords = ['ab', 'bc', 'cd', 'de', 'ef', 'fg', 'gh', 'ha']) == 8\n    assert candidate(startWords = ['abcdefgh', 'ijklmnop', 'qrstuvwxyz'],targetWords = ['abcdefghi', 'ijklmnopq', 'qrstuvwxyzx', 'abcdefghjkl', 'ijklmnopqr']) == 2\n    assert candidate(startWords = ['xyz', 'abc', 'uvw', 'def', 'ghi'],targetWords = ['xyzab', 'uvwxy', 'defgh', 'abcdef', 'mnopq']) == 0\n    assert candidate(startWords = ['pqr', 'stu', 'vwx'],targetWords = ['pqrs', 'stuv', 'vwxy', 'pqrst', 'stuvw', 'vwxys', 'mnopq']) == 3\n    assert candidate(startWords = ['quick', 'brown', 'fox'],targetWords = ['quickly', 'brownly', 'foxes', 'quickbrown', 'brownfox']) == 0\n    assert candidate(startWords = ['a', 'b', 'c', 'd'],targetWords = ['ab', 'bc', 'cd', 'abc', 'abcd']) == 3\n    assert candidate(startWords = ['aabbcc', 'ddeeff', 'gghhii'],targetWords = ['aabbccx', 'ddeeffx', 'gghhia', 'ddeeffg', 'gghhiih']) == 2\n    assert candidate(startWords = ['abc', 'de', 'fgh', 'xyz'],targetWords = ['abcd', 'def', 'efg', 'xyzz']) == 2\n    assert candidate(startWords = ['jump', 'over', 'lazy'],targetWords = ['jumpo', 'overj', 'lazyr', 'jumpr', 'overv']) == 4\n    assert candidate(startWords = ['mnop', 'qrst', 'uvwx'],targetWords = ['mnopq', 'qrstu', 'vwxyz', 'mnopqr', 'qrstuv']) == 2\n    assert candidate(startWords = ['abcd', 'efgh', 'ijkl'],targetWords = ['abcde', 'efghi', 'ijklm', 'abcdx', 'efghy', 'ijklz']) == 6\n    assert candidate(startWords = ['hello', 'world', 'abc'],targetWords = ['helloz', 'worldy', 'abcd']) == 3\n    assert candidate(startWords = ['mnop', 'qrst', 'uvwx'],targetWords = ['mnopq', 'qrstuv', 'uvwxy', 'mnopqr', 'qrstuvw', 'uvwxzy', 'mnopqrst', 'qrstuvwx', 'uvwxyza', 'mnopqrstuvwxyz']) == 2\n    assert candidate(startWords = ['programming', 'is', 'fun'],targetWords = ['programmings', 'isis', 'funny', 'programmingis', 'isfun']) == 0\n    assert candidate(startWords = ['jump', 'over', 'lazy'],targetWords = ['jumped', 'overly', 'lazily', 'jumpover', 'overlazy']) == 0\n    assert candidate(startWords = ['abcdefghij'],targetWords = ['abcdefghijk', 'abcdefghijl', 'abcdefghijm', 'abcdefghijn', 'abcdefghijo', 'abcdefghijp', 'abcdefghijq', 'abcdefghijr', 'abcdefghjis', 'abcdefghijt', 'abcdefghiju', 'abcdefghijv', 'abcdefghijw', 'abcdefghijx', 'abcdefghijy', 'abcdefghijz']) == 16\n    assert candidate(startWords = ['abc', 'bcd', 'efg'],targetWords = ['abcd', 'bcde', 'efgh']) == 3\n    assert candidate(startWords = ['zebra', 'panda', 'giraffe'],targetWords = ['zebrac', 'pandaf', 'giraffeb', 'zebrad', 'pandaq']) == 5\n    assert candidate(startWords = ['jump', 'over', 'lazy'],targetWords = ['jumper', 'overt', 'lazier']) == 1\n    assert candidate(startWords = ['a', 'b', 'c'],targetWords = ['ab', 'bc', 'ca', 'abc', 'abcd', 'abcde']) == 3\n    assert candidate(startWords = ['xyz', 'wxy', 'uvw'],targetWords = ['xyza', 'wxyb', 'uvwz', 'uvwxy']) == 3\n    assert candidate(startWords = ['abcdefgh', 'ijklmnop', 'qrstuvwxyz', 'abcxyz', 'uvwxy'],targetWords = ['abcdefghi', 'ijklmnopq', 'qrstuvwxyzx', 'abcxyzw', 'uvwxyza', 'mnopqrstu']) == 3\n    assert candidate(startWords = ['abcd', 'efgh', 'ijkl'],targetWords = ['abcde', 'efghi', 'jklmn', 'abcd']) == 2\n    assert candidate(startWords = ['abcd', 'efgh', 'ijkl'],targetWords = ['abcde', 'efghi', 'ijklm', 'mnop']) == 3\n    assert candidate(startWords = ['xyz', 'uvw', 'rst'],targetWords = ['xyza', 'uvwq', 'rstu', 'rstuv']) == 3\n    assert candidate(startWords = ['abc', 'def', 'ghi'],targetWords = ['abcd', 'defg', 'ghij', 'hijk', 'mnop', 'qrst', 'uvw', 'xyz']) == 3\n    assert candidate(startWords = ['quick', 'brown', 'fox'],targetWords = ['quickly', 'brownie', 'foxy', 'quicklybrown', 'brownief', 'quickbrown', 'quickfox', 'brownfox']) == 1\n    assert candidate(startWords = ['quick', 'brown', 'fox'],targetWords = ['quickly', 'brownish', 'foxy']) == 1\n    assert candidate(startWords = ['apple', 'banana', 'cherry'],targetWords = ['appleb', 'bananac', 'cherryd', 'applef', 'bananag']) == 4\n    assert candidate(startWords = ['abcd', 'efgh', 'ijkl'],targetWords = ['abcde', 'efghi', 'ijklm']) == 3\n    assert candidate(startWords = ['one', 'two', 'three'],targetWords = ['onet', 'twot', 'threet', 'oneto', 'twoto', 'threeto', 'onetwo', 'twotwo', 'threetwo', 'onetwothree', 'twotwothree', 'threetwothree', 'onetwofour', 'twotwofour', 'threetwofour']) == 1\n    assert candidate(startWords = ['abcd', 'efgh', 'ijkl'],targetWords = ['abcde', 'efghi', 'ijklm', 'mnopq']) == 3\n    assert candidate(startWords = ['hello', 'world'],targetWords = ['hellow', 'worlds', 'dlrow']) == 2\n    assert candidate(startWords = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],targetWords = ['ab', 'bc', 'cd', 'de', 'ef', 'fg', 'gh', 'hi', 'ij', 'jk', 'kl', 'lm', 'mn', 'no', 'op', 'pq', 'qr', 'rs', 'st', 'tu', 'uv', 'vw', 'wx', 'xy', 'yz', 'za']) == 26\n    assert candidate(startWords = ['pqr', 'stu', 'vwx', 'yz', 'abc'],targetWords = ['pqrs', 'stuv', 'vwxy', 'yzab', 'uvwxy', 'mnopq']) == 3\n    assert candidate(startWords = ['abcd', 'efgh', 'ijkl', 'mnop'],targetWords = ['abcde', 'efghi', 'ijklm', 'nopqr']) == 3\n    assert candidate(startWords = ['hello', 'world'],targetWords = ['ehllo', 'dlrow', 'owrld', 'helloa', 'worldb']) == 2\n    assert candidate(startWords = ['a', 'b', 'c', 'd'],targetWords = ['ab', 'bc', 'cd', 'de', 'ef', 'fg', 'gh', 'hi', 'ij', 'jk', 'kl', 'lm', 'mn', 'no', 'op', 'pq', 'qr', 'rs', 'st', 'tu', 'uv', 'vw', 'wx', 'xy', 'yz', 'za']) == 5\n    assert candidate(startWords = ['mnopq', 'rstuv', 'wxyz'],targetWords = ['mnopqr', 'rstuvw', 'wxyza', 'mnopqs', 'rstuvx', 'wxyzab', 'mnopqt', 'rstuvy', 'wxyzac', 'mnopqu', 'rstuvz', 'wxyzad', 'mnopqv', 'rstuvw', 'wxyzae']) == 11\n    assert candidate(startWords = ['a', 'b', 'c', 'd'],targetWords = ['ab', 'bc', 'cd', 'da']) == 4\n", "comparison": "exact"}, "public_tests": ["[\"ant\",\"act\",\"tack\"]\n[\"tack\",\"act\",\"acti\"]", "[\"ab\",\"a\"]\n[\"abc\",\"abcd\"]"], "hints": ["Which data structure can be used to efficiently check if a string exists in startWords?", "After appending a letter, all letters of a string can be rearranged in any possible way. How can we use this to reduce our search space while checking if a string in targetWords can be obtained from a string in startWords?"], "metadata": {"canonical_parameter_names": ["startWords", "targetWords"], "leetcode_dataset_entry_point": "Solution().wordCount", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:23+00:00", "tests_total": 68, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "hash-table", "string", "bit-manipulation", "sorting"]}, "language": "python", "interface": {"raw_signature": "def wordCount(self, startWords: list[str], targetWords: list[str]) -> int:", "container": "Solution", "callable": "wordCount", "parameters": [{"name": "startWords", "type": "list[str]"}, {"name": "targetWords", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2136, "task_id": "earliest-possible-day-of-full-bloom", "difficulty": "Hard", "problem_description": "You have n flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two 0-indexed integer arrays plantTime and growTime, of length n each:\n\n- plantTime[i] is the number of full days it takes you to plant the i^th seed. Every day, you can work on planting exactly one seed. You do not have to work on planting the same seed on consecutive days, but the planting of a seed is not complete until you have worked plantTime[i] days on planting it in total.\n- growTime[i] is the number of full days it takes the i^th seed to grow after being completely planted. After the last day of its growth, the flower blooms and stays bloomed forever.\n\nFrom the beginning of day 0, you can plant the seeds in any order.\n\nReturn the earliest possible day where all seeds are blooming.\n\nExample 1:\n\nInput: plantTime = [1,4,3], growTime = [2,3,1]\nOutput: 9\nExplanation: The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms.\nOne optimal way is:\nOn day 0, plant the 0^th seed. The seed grows for 2 full days and blooms on day 3.\nOn days 1, 2, 3, and 4, plant the 1^st seed. The seed grows for 3 full days and blooms on day 8.\nOn days 5, 6, and 7, plant the 2^nd seed. The seed grows for 1 full day and blooms on day 9.\nThus, on day 9, all the seeds are blooming.\n\nExample 2:\n\nInput: plantTime = [1,2,3,2], growTime = [2,1,2,1]\nOutput: 9\nExplanation: The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms.\nOne optimal way is:\nOn day 1, plant the 0^th seed. The seed grows for 2 full days and blooms on day 4.\nOn days 0 and 3, plant the 1^st seed. The seed grows for 1 full day and blooms on day 5.\nOn days 2, 4, and 5, plant the 2^nd seed. The seed grows for 2 full days and blooms on day 8.\nOn days 6 and 7, plant the 3^rd seed. The seed grows for 1 full day and blooms on day 9.\nThus, on day 9, all the seeds are blooming.\n\nExample 3:\n\nInput: plantTime = [1], growTime = [1]\nOutput: 2\nExplanation: On day 0, plant the 0^th seed. The seed grows for 1 full day and blooms on day 2.\nThus, on day 2, all the seeds are blooming.\n\nConstraints:\n\n- n == plantTime.length == growTime.length\n- 1 <= n <= 10^5\n- 1 <= plantTime[i], growTime[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(plantTime = [1],growTime = [1]) == 2\n    assert candidate(plantTime = [2, 2, 2],growTime = [3, 3, 3]) == 9\n    assert candidate(plantTime = [2, 2, 2],growTime = [3, 2, 1]) == 7\n    assert candidate(plantTime = [10000, 10000],growTime = [10000, 10000]) == 30000\n    assert candidate(plantTime = [1, 1, 1, 1, 1],growTime = [5, 4, 3, 2, 1]) == 6\n    assert candidate(plantTime = [3, 2, 1],growTime = [10, 20, 30]) == 31\n    assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n    assert candidate(plantTime = [1, 3, 5, 7],growTime = [7, 5, 3, 1]) == 17\n    assert candidate(plantTime = [10, 20, 30],growTime = [1, 2, 3]) == 61\n    assert candidate(plantTime = [5, 5, 5],growTime = [5, 5, 5]) == 20\n    assert candidate(plantTime = [5, 4, 3, 2, 1],growTime = [1, 2, 3, 4, 5]) == 16\n    assert candidate(plantTime = [3, 2, 1],growTime = [2, 1, 3]) == 7\n    assert candidate(plantTime = [2, 3, 4],growTime = [3, 2, 1]) == 10\n    assert candidate(plantTime = [10000, 10000],growTime = [1, 1]) == 20001\n    assert candidate(plantTime = [1, 4, 3],growTime = [2, 3, 1]) == 9\n    assert candidate(plantTime = [100, 200, 300],growTime = [100, 200, 300]) == 700\n    assert candidate(plantTime = [2, 2, 2, 2],growTime = [4, 3, 2, 1]) == 9\n    assert candidate(plantTime = [1, 2, 3, 2],growTime = [2, 1, 2, 1]) == 9\n    assert candidate(plantTime = [1, 1, 1, 1],growTime = [1, 1, 1, 1]) == 5\n    assert candidate(plantTime = [10, 5, 7],growTime = [4, 6, 8]) == 26\n    assert candidate(plantTime = [5, 2, 4],growTime = [3, 1, 2]) == 12\n    assert candidate(plantTime = [3, 3, 3],growTime = [3, 3, 3]) == 12\n    assert candidate(plantTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],growTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 105\n    assert candidate(plantTime = [5, 10, 15, 20],growTime = [20, 15, 10, 5]) == 55\n    assert candidate(plantTime = [5, 10, 15, 20],growTime = [20, 15, 10, 5]) == 55\n    assert candidate(plantTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],growTime = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 101\n    assert candidate(plantTime = [100, 200, 300, 400],growTime = [1000, 500, 700, 200]) == 1200\n    assert candidate(plantTime = [500, 500, 500, 500, 500],growTime = [500, 500, 500, 500, 500]) == 3000\n    assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1501\n    assert candidate(plantTime = [1000, 2000, 3000, 4000, 5000],growTime = [1, 2, 3, 4, 5]) == 15001\n    assert candidate(plantTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 101\n    assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 21\n    assert candidate(plantTime = [10, 20, 30, 40, 50],growTime = [50, 40, 30, 20, 10]) == 160\n    assert candidate(plantTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 56\n    assert candidate(plantTime = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],growTime = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6]) == 556\n    assert candidate(plantTime = [100, 200, 300, 400, 500],growTime = [500, 400, 300, 200, 100]) == 1600\n    assert candidate(plantTime = [10, 20, 30, 40, 50],growTime = [5, 10, 15, 20, 25]) == 155\n    assert candidate(plantTime = [5, 10, 4, 6, 8],growTime = [10, 2, 7, 4, 5]) == 35\n    assert candidate(plantTime = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],growTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 35\n    assert candidate(plantTime = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16],growTime = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7]) == 122\n    assert candidate(plantTime = [5, 4, 1, 3, 2],growTime = [8, 7, 6, 5, 4]) == 19\n    assert candidate(plantTime = [5, 3, 8, 6],growTime = [10, 7, 2, 4]) == 24\n    assert candidate(plantTime = [1, 3, 5, 7, 9],growTime = [9, 7, 5, 3, 1]) == 26\n    assert candidate(plantTime = [5, 4, 3, 2, 1],growTime = [10, 20, 30, 40, 50]) == 51\n    assert candidate(plantTime = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60],growTime = [60, 55, 50, 45, 40, 35, 30, 25, 20, 15]) == 390\n    assert candidate(plantTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],growTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 551\n    assert candidate(plantTime = [7, 5, 9, 3, 6, 4, 8],growTime = [2, 8, 1, 5, 4, 7, 3]) == 43\n    assert candidate(plantTime = [100, 200, 150, 300],growTime = [50, 100, 200, 150]) == 800\n    assert candidate(plantTime = [5, 3, 8, 6],growTime = [10, 7, 2, 4]) == 24\n    assert candidate(plantTime = [10, 5, 7, 3, 8],growTime = [15, 12, 6, 4, 9]) == 37\n    assert candidate(plantTime = [7, 6, 5, 4, 3, 2, 1],growTime = [1, 2, 3, 4, 5, 6, 7]) == 29\n    assert candidate(plantTime = [10, 5, 15, 20],growTime = [1, 1, 1, 1]) == 51\n    assert candidate(plantTime = [5, 10, 3, 1, 4],growTime = [10, 5, 7, 8, 2]) == 25\n    assert candidate(plantTime = [5, 1, 8, 3, 2],growTime = [10, 6, 2, 4, 5]) == 21\n    assert candidate(plantTime = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 61\n    assert candidate(plantTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],growTime = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 560\n    assert candidate(plantTime = [500, 400, 300, 200, 100],growTime = [5, 4, 3, 2, 1]) == 1501\n    assert candidate(plantTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 121\n    assert candidate(plantTime = [100, 50, 75, 25],growTime = [50, 100, 75, 25]) == 275\n    assert candidate(plantTime = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],growTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 5510\n    assert candidate(plantTime = [1, 1, 1, 1, 1],growTime = [1000, 1000, 1000, 1000, 1000]) == 1005\n    assert candidate(plantTime = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],growTime = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 31\n    assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 16\n    assert candidate(plantTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],growTime = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 211\n    assert candidate(plantTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],growTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 110\n    assert candidate(plantTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],growTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 56\n    assert candidate(plantTime = [100, 200, 300, 400, 500],growTime = [1000, 2000, 3000, 4000, 5000]) == 5500\n    assert candidate(plantTime = [1000, 2000, 3000, 4000, 5000],growTime = [5000, 4000, 3000, 2000, 1000]) == 16000\n    assert candidate(plantTime = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 31\n    assert candidate(plantTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 56\n    assert candidate(plantTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],growTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 105\n    assert candidate(plantTime = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],growTime = [9, 7, 3, 8, 5, 3, 8, 2, 9, 4, 6]) == 46\n    assert candidate(plantTime = [4, 4, 4, 4, 4, 4, 4, 4],growTime = [1, 2, 3, 4, 5, 6, 7, 8]) == 33\n    assert candidate(plantTime = [1, 3, 5, 7, 9],growTime = [9, 7, 5, 3, 1]) == 26\n    assert candidate(plantTime = [10, 10, 10, 10, 10],growTime = [20, 20, 20, 20, 20]) == 70\n    assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n    assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 10001\n    assert candidate(plantTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],growTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 110\n    assert candidate(plantTime = [1, 1, 1, 1, 1],growTime = [10000, 9999, 9998, 9997, 9996]) == 10001\n    assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 101\n    assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11\n    assert candidate(plantTime = [1, 10, 100, 1000, 10000],growTime = [10000, 1000, 100, 10, 1]) == 11112\n    assert candidate(plantTime = [100, 200, 300, 400, 500],growTime = [1, 2, 3, 4, 5]) == 1501\n    assert candidate(plantTime = [7, 14, 21, 28, 35],growTime = [10, 20, 30, 40, 50]) == 118\n    assert candidate(plantTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],growTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 110\n    assert candidate(plantTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],growTime = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 121\n    assert candidate(plantTime = [100, 200, 150, 300],growTime = [500, 400, 300, 200]) == 950\n    assert candidate(plantTime = [4, 4, 4, 4, 4],growTime = [9, 8, 7, 6, 5]) == 25\n    assert candidate(plantTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],growTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 56\n    assert candidate(plantTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],growTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 103\n    assert candidate(plantTime = [3, 5, 7, 9, 11, 13, 15],growTime = [2, 4, 6, 8, 10, 12, 14]) == 65\n    assert candidate(plantTime = [100, 200, 300, 400, 500],growTime = [1, 1, 1, 1, 1]) == 1501\n    assert candidate(plantTime = [4, 3, 2, 1, 5, 6, 7, 8, 9, 10],growTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 56\n    assert candidate(plantTime = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],growTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 21\n    assert candidate(plantTime = [50, 40, 30, 20, 10],growTime = [1, 2, 3, 4, 5]) == 151\n    assert candidate(plantTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],growTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 101\n    assert candidate(plantTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],growTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 551\n    assert candidate(plantTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],growTime = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 560\n    assert candidate(plantTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],growTime = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16\n    assert candidate(plantTime = [7, 6, 5, 4, 3, 2, 1],growTime = [1, 2, 3, 4, 5, 6, 7]) == 29\n    assert candidate(plantTime = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],growTime = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 46\n", "comparison": "exact"}, "public_tests": ["[1,4,3]\n[2,3,1]", "[1,2,3,2]\n[2,1,2,1]", "[1]\n[1]"], "hints": ["List the planting like the diagram above shows, where a row represents the timeline of a seed. A row i is above another row j if the last day planting seed i is ahead of the last day for seed j. Does it have any advantage to spend some days to plant seed j before completely planting seed i?", "No. It does not help seed j but could potentially delay the completion of seed i, resulting in a worse final answer. Remaining focused is a part of the optimal solution.", "Sort the seeds by their growTime in descending order. Can you prove why this strategy is the other part of the optimal solution? Note the bloom time of a seed is the sum of plantTime of all seeds preceding this seed plus the growTime of this seed.", "There is no way to improve this strategy. The seed to bloom last dominates the final answer. Exchanging the planting of this seed with another seed with either a larger or smaller growTime will result in a potentially worse answer."], "metadata": {"canonical_parameter_names": ["plantTime", "growTime"], "leetcode_dataset_entry_point": "Solution().earliestFullBloom", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:26+00:00", "tests_total": 102, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def earliestFullBloom(self, plantTime: list[int], growTime: list[int]) -> int:", "container": "Solution", "callable": "earliestFullBloom", "parameters": [{"name": "plantTime", "type": "list[int]"}, {"name": "growTime", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2138, "task_id": "divide-a-string-into-groups-of-size-k", "difficulty": "Easy", "problem_description": "A string s can be partitioned into groups of size k using the following procedure:\n\n- The first group consists of the first k characters of the string, the second group consists of the next k characters of the string, and so on. Each element can be a part of exactly one group.\n- For the last group, if the string does not have k characters remaining, a character fill is used to complete the group.\n\nNote that the partition is done so that after removing the fill character from the last group (if it exists) and concatenating all the groups in order, the resultant string should be s.\n\nGiven the string s, the size of each group k and the character fill, return a string array denoting the composition of every group s has been divided into, using the above procedure.\n\nExample 1:\n\nInput: s = \"abcdefghi\", k = 3, fill = \"x\"\nOutput: [\"abc\",\"def\",\"ghi\"]\nExplanation:\nThe first 3 characters \"abc\" form the first group.\nThe next 3 characters \"def\" form the second group.\nThe last 3 characters \"ghi\" form the third group.\nSince all groups can be completely filled by characters from the string, we do not need to use fill.\nThus, the groups formed are \"abc\", \"def\", and \"ghi\".\n\nExample 2:\n\nInput: s = \"abcdefghij\", k = 3, fill = \"x\"\nOutput: [\"abc\",\"def\",\"ghi\",\"jxx\"]\nExplanation:\nSimilar to the previous example, we are forming the first three groups \"abc\", \"def\", and \"ghi\".\nFor the last group, we can only use the character 'j' from the string. To complete this group, we add 'x' twice.\nThus, the 4 groups formed are \"abc\", \"def\", \"ghi\", and \"jxx\".\n\nConstraints:\n\n- 1 <= s.length <= 100\n- s consists of lowercase English letters only.\n- 1 <= k <= 100\n- fill is a lowercase English letter.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"abcdefghij\",k = 3,fill = \"x\") == ['abc', 'def', 'ghi', 'jxx']\n    assert candidate(s = \"abcdefg\",k = 2,fill = \"z\") == ['ab', 'cd', 'ef', 'gz']\n    assert candidate(s = \"abcdefghi\",k = 3,fill = \"x\") == ['abc', 'def', 'ghi']\n    assert candidate(s = \"a\",k = 1,fill = \"y\") == ['a']\n    assert candidate(s = \"python\",k = 6,fill = \"q\") == ['python']\n    assert candidate(s = \"programming\",k = 1,fill = \"a\") == ['p', 'r', 'o', 'g', 'r', 'a', 'm', 'm', 'i', 'n', 'g']\n    assert candidate(s = \"hello\",k = 2,fill = \"q\") == ['he', 'll', 'oq']\n    assert candidate(s = \"abc\",k = 5,fill = \"z\") == ['abczz']\n    assert candidate(s = \"a\",k = 5,fill = \"y\") == ['ayyyy']\n    assert candidate(s = \"boundarycase\",k = 8,fill = \"b\") == ['boundary', 'casebbbb']\n    assert candidate(s = \"thisisaverylongstring\",k = 5,fill = \"p\") == ['thisi', 'saver', 'ylong', 'strin', 'gpppp']\n    assert candidate(s = \"abcdexyz\",k = 2,fill = \"g\") == ['ab', 'cd', 'ex', 'yz']\n    assert candidate(s = \"repeatedcharacters\",k = 7,fill = \"e\") == ['repeate', 'dcharac', 'terseee']\n    assert candidate(s = \"interview\",k = 2,fill = \"z\") == ['in', 'te', 'rv', 'ie', 'wz']\n    assert candidate(s = \"abcdefg\",k = 7,fill = \"z\") == ['abcdefg']\n    assert candidate(s = \"abcdefghijk\",k = 5,fill = \"m\") == ['abcde', 'fghij', 'kmmmm']\n    assert candidate(s = \"abcdef\",k = 8,fill = \"n\") == ['abcdefnn']\n    assert candidate(s = \"programming\",k = 3,fill = \"a\") == ['pro', 'gra', 'mmi', 'nga']\n    assert candidate(s = \"complexstringwithfill\",k = 9,fill = \"r\") == ['complexst', 'ringwithf', 'illrrrrrr']\n    assert candidate(s = \"abcd\",k = 5,fill = \"t\") == ['abcdt']\n    assert candidate(s = \"almostfill\",k = 9,fill = \"l\") == ['almostfil', 'lllllllll']\n    assert candidate(s = \"partitioning\",k = 3,fill = \"z\") == ['par', 'tit', 'ion', 'ing']\n    assert candidate(s = \"abcdefgxyz\",k = 1,fill = \"m\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z']\n    assert candidate(s = \"abcdefg\",k = 1,fill = \"d\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g']\n    assert candidate(s = \"hello\",k = 4,fill = \"o\") == ['hell', 'oooo']\n    assert candidate(s = \"abcdefghijabcdefghij\",k = 11,fill = \"c\") == ['abcdefghija', 'bcdefghijcc']\n    assert candidate(s = \"repeatthispattern\",k = 8,fill = \"m\") == ['repeatth', 'ispatter', 'nmmmmmmm']\n    assert candidate(s = \"ab\",k = 2,fill = \"l\") == ['ab']\n    assert candidate(s = \"example\",k = 2,fill = \"z\") == ['ex', 'am', 'pl', 'ez']\n    assert candidate(s = \"fill\",k = 1,fill = \"f\") == ['f', 'i', 'l', 'l']\n    assert candidate(s = \"thisisaverylongstringthatneedstobedivided\",k = 5,fill = \"a\") == ['thisi', 'saver', 'ylong', 'strin', 'gthat', 'needs', 'tobed', 'ivide', 'daaaa']\n    assert candidate(s = \"abcdefghijk\",k = 1,fill = \"m\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']\n    assert candidate(s = \"short\",k = 5,fill = \"q\") == ['short']\n    assert candidate(s = \"thisisaverylongstring\",k = 5,fill = \"m\") == ['thisi', 'saver', 'ylong', 'strin', 'gmmmm']\n    assert candidate(s = \"abcdefghij\",k = 2,fill = \"w\") == ['ab', 'cd', 'ef', 'gh', 'ij']\n    assert candidate(s = \"hello\",k = 4,fill = \"p\") == ['hell', 'oppp']\n    assert candidate(s = \"almostfullgroup\",k = 10,fill = \"a\") == ['almostfull', 'groupaaaaa']\n    assert candidate(s = \"qwen\",k = 2,fill = \"q\") == ['qw', 'en']\n    assert candidate(s = \"hello\",k = 1,fill = \"b\") == ['h', 'e', 'l', 'l', 'o']\n    assert candidate(s = \"abcd\",k = 2,fill = \"p\") == ['ab', 'cd']\n    assert candidate(s = \"partitioning\",k = 5,fill = \"p\") == ['parti', 'tioni', 'ngppp']\n    assert candidate(s = \"thisisanexample\",k = 3,fill = \"y\") == ['thi', 'sis', 'ane', 'xam', 'ple']\n    assert candidate(s = \"abcdefg\",k = 10,fill = \"q\") == ['abcdefgqqq']\n    assert candidate(s = \"samecharacter\",k = 2,fill = \"s\") == ['sa', 'me', 'ch', 'ar', 'ac', 'te', 'rs']\n    assert candidate(s = \"fillingwithx\",k = 7,fill = \"x\") == ['filling', 'withxxx']\n    assert candidate(s = \"longerstring\",k = 6,fill = \"p\") == ['longer', 'string']\n    assert candidate(s = \"algorithm\",k = 4,fill = \"m\") == ['algo', 'rith', 'mmmm']\n    assert candidate(s = \"xylophone\",k = 6,fill = \"o\") == ['xyloph', 'oneooo']\n    assert candidate(s = \"thisisaverylongstringthatneedstobedivided\",k = 5,fill = \"x\") == ['thisi', 'saver', 'ylong', 'strin', 'gthat', 'needs', 'tobed', 'ivide', 'dxxxx']\n    assert candidate(s = \"abcdeabcdeabcdea\",k = 4,fill = \"w\") == ['abcd', 'eabc', 'deab', 'cdea']\n    assert candidate(s = \"xyz\",k = 1,fill = \"v\") == ['x', 'y', 'z']\n    assert candidate(s = \"evenlydivisible\",k = 2,fill = \"q\") == ['ev', 'en', 'ly', 'di', 'vi', 'si', 'bl', 'eq']\n    assert candidate(s = \"programming\",k = 3,fill = \"w\") == ['pro', 'gra', 'mmi', 'ngw']\n    assert candidate(s = \"boundarycase\",k = 9,fill = \"b\") == ['boundaryc', 'asebbbbbb']\n    assert candidate(s = \"onemoretestcase\",k = 6,fill = \"t\") == ['onemor', 'etestc', 'asettt']\n    assert candidate(s = \"abcdefg\",k = 3,fill = \"v\") == ['abc', 'def', 'gvv']\n    assert candidate(s = \"equalgroups\",k = 5,fill = \"w\") == ['equal', 'group', 'swwww']\n    assert candidate(s = \"equalgroups\",k = 3,fill = \"c\") == ['equ', 'alg', 'rou', 'psc']\n    assert candidate(s = \"quickbrownfox\",k = 3,fill = \"y\") == ['qui', 'ckb', 'row', 'nfo', 'xyy']\n    assert candidate(s = \"abcdef\",k = 7,fill = \"n\") == ['abcdefn']\n    assert candidate(s = \"abcdefghij\",k = 4,fill = \"x\") == ['abcd', 'efgh', 'ijxx']\n    assert candidate(s = \"abcdef\",k = 7,fill = \"z\") == ['abcdefz']\n    assert candidate(s = \"zebra\",k = 1,fill = \"x\") == ['z', 'e', 'b', 'r', 'a']\n    assert candidate(s = \"abcdef\",k = 2,fill = \"o\") == ['ab', 'cd', 'ef']\n    assert candidate(s = \"thisisalongstring\",k = 4,fill = \"x\") == ['this', 'isal', 'ongs', 'trin', 'gxxx']\n    assert candidate(s = \"partitioning\",k = 7,fill = \"f\") == ['partiti', 'oningff']\n    assert candidate(s = \"example\",k = 10,fill = \"z\") == ['examplezzz']\n    assert candidate(s = \"abcdefghij\",k = 4,fill = \"e\") == ['abcd', 'efgh', 'ijee']\n    assert candidate(s = \"programmingisfun\",k = 5,fill = \"a\") == ['progr', 'ammin', 'gisfu', 'naaaa']\n    assert candidate(s = \"thisisaverylongstringthatwillneedfilling\",k = 7,fill = \"a\") == ['thisisa', 'verylon', 'gstring', 'thatwil', 'lneedfi', 'llingaa']\n    assert candidate(s = \"onetwothreefourfive\",k = 6,fill = \"j\") == ['onetwo', 'threef', 'ourfiv', 'ejjjjj']\n    assert candidate(s = \"world\",k = 10,fill = \"c\") == ['worldccccc']\n    assert candidate(s = \"xyz\",k = 10,fill = \"a\") == ['xyzaaaaaaa']\n    assert candidate(s = \"abcdefgxyz\",k = 4,fill = \"a\") == ['abcd', 'efgx', 'yzaa']\n    assert candidate(s = \"abcdefghijk\",k = 4,fill = \"x\") == ['abcd', 'efgh', 'ijkx']\n    assert candidate(s = \"partition\",k = 1,fill = \"m\") == ['p', 'a', 'r', 't', 'i', 't', 'i', 'o', 'n']\n    assert candidate(s = \"algorithms\",k = 7,fill = \"b\") == ['algorit', 'hmsbbbb']\n    assert candidate(s = \"repeatedcharacterstest\",k = 7,fill = \"z\") == ['repeate', 'dcharac', 'terstes', 'tzzzzzz']\n    assert candidate(s = \"almostfull\",k = 4,fill = \"i\") == ['almo', 'stfu', 'llii']\n    assert candidate(s = \"filler\",k = 11,fill = \"l\") == ['fillerlllll']\n    assert candidate(s = \"abcdefghijk\",k = 3,fill = \"n\") == ['abc', 'def', 'ghi', 'jkn']\n    assert candidate(s = \"elephants\",k = 3,fill = \"p\") == ['ele', 'pha', 'nts']\n    assert candidate(s = \"short\",k = 10,fill = \"p\") == ['shortppppp']\n    assert candidate(s = \"abcd\",k = 6,fill = \"w\") == ['abcdww']\n    assert candidate(s = \"abcdef\",k = 2,fill = \"x\") == ['ab', 'cd', 'ef']\n    assert candidate(s = \"quickbrownfox\",k = 4,fill = \"x\") == ['quic', 'kbro', 'wnfo', 'xxxx']\n    assert candidate(s = \"qwert\",k = 10,fill = \"n\") == ['qwertnnnnn']\n    assert candidate(s = \"machinelearning\",k = 8,fill = \"d\") == ['machinel', 'earningd']\n    assert candidate(s = \"abcdef\",k = 1,fill = \"z\") == ['a', 'b', 'c', 'd', 'e', 'f']\n    assert candidate(s = \"short\",k = 10,fill = \"b\") == ['shortbbbbb']\n    assert candidate(s = \"programming\",k = 7,fill = \"a\") == ['program', 'mingaaa']\n    assert candidate(s = \"datastructure\",k = 5,fill = \"a\") == ['datas', 'truct', 'ureaa']\n    assert candidate(s = \"abcdefghijkmnopqrstuvwxyz\",k = 5,fill = \"x\") == ['abcde', 'fghij', 'kmnop', 'qrstu', 'vwxyz']\n    assert candidate(s = \"abcdefghijk\",k = 3,fill = \"p\") == ['abc', 'def', 'ghi', 'jkp']\n    assert candidate(s = \"divisiblebyk\",k = 2,fill = \"h\") == ['di', 'vi', 'si', 'bl', 'eb', 'yk']\n    assert candidate(s = \"qwenassistant\",k = 7,fill = \"a\") == ['qwenass', 'istanta']\n    assert candidate(s = \"cloudcomputing\",k = 6,fill = \"c\") == ['cloudc', 'omputi', 'ngcccc']\n    assert candidate(s = \"longerstringexample\",k = 6,fill = \"n\") == ['longer', 'string', 'exampl', 'ennnnn']\n    assert candidate(s = \"abcdefghijklnm\",k = 4,fill = \"r\") == ['abcd', 'efgh', 'ijkl', 'nmrr']\n    assert candidate(s = \"algorithm\",k = 5,fill = \"b\") == ['algor', 'ithmb']\n    assert candidate(s = \"quickbrownfox\",k = 3,fill = \"m\") == ['qui', 'ckb', 'row', 'nfo', 'xmm']\n    assert candidate(s = \"abcd\",k = 4,fill = \"x\") == ['abcd']\n    assert candidate(s = \"almostfull\",k = 8,fill = \"o\") == ['almostfu', 'lloooooo']\n", "comparison": "exact"}, "public_tests": ["\"abcdefghi\"\n3\n\"x\"", "\"abcdefghij\"\n3\n\"x\""], "hints": ["Using the length of the string and k, can you count the number of groups the string can be divided into?", "Try completing each group using characters from the string. If there aren’t enough characters for the last group, use the fill character to complete the group."], "metadata": {"canonical_parameter_names": ["s", "k", "fill"], "leetcode_dataset_entry_point": "Solution().divideString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:30+00:00", "tests_total": 110, "tests_dropped": 7, "flags": [], "topic_tags": ["string", "simulation"]}, "language": "python", "interface": {"raw_signature": "def divideString(self, s: str, k: int, fill: str) -> list[str]:", "container": "Solution", "callable": "divideString", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}, {"name": "fill", "type": "str"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2139, "task_id": "minimum-moves-to-reach-target-score", "difficulty": "Medium", "problem_description": "You are playing a game with integers. You start with the integer 1 and you want to reach the integer target.\n\nIn one move, you can either:\n\n- Increment the current integer by one (i.e., x = x + 1).\n- Double the current integer (i.e., x = 2 * x).\n\nYou can use the increment operation any number of times, however, you can only use the double operation at most maxDoubles times.\n\nGiven the two integers target and maxDoubles, return the minimum number of moves needed to reach target starting with 1.\n\nExample 1:\n\nInput: target = 5, maxDoubles = 0\nOutput: 4\nExplanation: Keep incrementing by 1 until you reach target.\n\nExample 2:\n\nInput: target = 19, maxDoubles = 2\nOutput: 7\nExplanation: Initially, x = 1\nIncrement 3 times so x = 4\nDouble once so x = 8\nIncrement once so x = 9\nDouble again so x = 18\nIncrement once so x = 19\n\nExample 3:\n\nInput: target = 10, maxDoubles = 4\nOutput: 4\nExplanation: Initially, x = 1\nIncrement once so x = 2\nDouble once so x = 4\nIncrement once so x = 5\nDouble again so x = 10\n\nConstraints:\n\n- 1 <= target <= 10^9\n- 0 <= maxDoubles <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(target = 2,maxDoubles = 1) == 1\n    assert candidate(target = 6,maxDoubles = 0) == 5\n    assert candidate(target = 1000000000,maxDoubles = 100) == 41\n    assert candidate(target = 8,maxDoubles = 3) == 3\n    assert candidate(target = 100,maxDoubles = 10) == 8\n    assert candidate(target = 256,maxDoubles = 8) == 8\n    assert candidate(target = 3,maxDoubles = 1) == 2\n    assert candidate(target = 3,maxDoubles = 2) == 2\n    assert candidate(target = 7,maxDoubles = 1) == 4\n    assert candidate(target = 100,maxDoubles = 5) == 8\n    assert candidate(target = 10,maxDoubles = 4) == 4\n    assert candidate(target = 100,maxDoubles = 0) == 99\n    assert candidate(target = 100,maxDoubles = 1) == 50\n    assert candidate(target = 5,maxDoubles = 0) == 4\n    assert candidate(target = 7,maxDoubles = 0) == 6\n    assert candidate(target = 1,maxDoubles = 5) == 0\n    assert candidate(target = 1,maxDoubles = 1) == 0\n    assert candidate(target = 1,maxDoubles = 10) == 0\n    assert candidate(target = 20,maxDoubles = 0) == 19\n    assert candidate(target = 19,maxDoubles = 2) == 7\n    assert candidate(target = 6,maxDoubles = 1) == 3\n    assert candidate(target = 1023,maxDoubles = 10) == 18\n    assert candidate(target = 1000000000,maxDoubles = 50) == 41\n    assert candidate(target = 8193,maxDoubles = 13) == 14\n    assert candidate(target = 4095,maxDoubles = 10) == 22\n    assert candidate(target = 32768,maxDoubles = 16) == 15\n    assert candidate(target = 123456789,maxDoubles = 30) == 41\n    assert candidate(target = 987654321,maxDoubles = 25) == 66\n    assert candidate(target = 32767,maxDoubles = 15) == 28\n    assert candidate(target = 524288,maxDoubles = 20) == 19\n    assert candidate(target = 246813579,maxDoubles = 0) == 246813578\n    assert candidate(target = 333333333,maxDoubles = 100) == 43\n    assert candidate(target = 8192,maxDoubles = 12) == 13\n    assert candidate(target = 15,maxDoubles = 1) == 8\n    assert candidate(target = 63,maxDoubles = 3) == 12\n    assert candidate(target = 16,maxDoubles = 4) == 4\n    assert candidate(target = 255,maxDoubles = 7) == 14\n    assert candidate(target = 2,maxDoubles = 2) == 1\n    assert candidate(target = 8192,maxDoubles = 13) == 13\n    assert candidate(target = 131072,maxDoubles = 18) == 17\n    assert candidate(target = 4,maxDoubles = 1) == 2\n    assert candidate(target = 131071,maxDoubles = 17) == 32\n    assert candidate(target = 8,maxDoubles = 0) == 7\n    assert candidate(target = 1,maxDoubles = 0) == 0\n    assert candidate(target = 999999999,maxDoubles = 100) == 49\n    assert candidate(target = 777777777,maxDoubles = 75) == 46\n    assert candidate(target = 95,maxDoubles = 6) == 11\n    assert candidate(target = 500,maxDoubles = 9) == 13\n    assert candidate(target = 999999999,maxDoubles = 0) == 999999998\n    assert candidate(target = 987654321,maxDoubles = 50) == 45\n    assert candidate(target = 19,maxDoubles = 1) == 10\n    assert candidate(target = 1001,maxDoubles = 10) == 15\n    assert candidate(target = 8,maxDoubles = 4) == 3\n    assert candidate(target = 16,maxDoubles = 5) == 4\n    assert candidate(target = 23,maxDoubles = 3) == 7\n    assert candidate(target = 65535,maxDoubles = 16) == 30\n    assert candidate(target = 16,maxDoubles = 3) == 4\n    assert candidate(target = 31,maxDoubles = 3) == 8\n    assert candidate(target = 500000,maxDoubles = 15) == 32\n    assert candidate(target = 47,maxDoubles = 5) == 9\n    assert candidate(target = 1023,maxDoubles = 0) == 1022\n    assert candidate(target = 199999999,maxDoubles = 100) == 46\n    assert candidate(target = 500,maxDoubles = 0) == 499\n    assert candidate(target = 987654321,maxDoubles = 0) == 987654320\n    assert candidate(target = 2048,maxDoubles = 15) == 11\n    assert candidate(target = 19,maxDoubles = 3) == 6\n    assert candidate(target = 123456789,maxDoubles = 50) == 41\n    assert candidate(target = 1023,maxDoubles = 5) == 40\n    assert candidate(target = 10000,maxDoubles = 100) == 17\n    assert candidate(target = 4,maxDoubles = 2) == 2\n    assert candidate(target = 15,maxDoubles = 3) == 6\n    assert candidate(target = 23456789,maxDoubles = 20) == 51\n    assert candidate(target = 8,maxDoubles = 2) == 3\n    assert candidate(target = 4095,maxDoubles = 12) == 22\n    assert candidate(target = 11,maxDoubles = 2) == 5\n    assert candidate(target = 511,maxDoubles = 8) == 16\n    assert candidate(target = 127,maxDoubles = 4) == 14\n    assert candidate(target = 1000000,maxDoubles = 0) == 999999\n    assert candidate(target = 9,maxDoubles = 1) == 5\n    assert candidate(target = 32768,maxDoubles = 15) == 15\n    assert candidate(target = 8192,maxDoubles = 0) == 8191\n    assert candidate(target = 123456,maxDoubles = 20) == 21\n    assert candidate(target = 987654321,maxDoubles = 10) == 964519\n    assert candidate(target = 262143,maxDoubles = 18) == 34\n    assert candidate(target = 128,maxDoubles = 7) == 7\n    assert candidate(target = 131072,maxDoubles = 16) == 17\n    assert candidate(target = 1048576,maxDoubles = 21) == 20\n    assert candidate(target = 31,maxDoubles = 5) == 8\n    assert candidate(target = 987654321,maxDoubles = 45) == 45\n    assert candidate(target = 65536,maxDoubles = 17) == 16\n    assert candidate(target = 127,maxDoubles = 6) == 12\n    assert candidate(target = 2,maxDoubles = 0) == 1\n    assert candidate(target = 16,maxDoubles = 0) == 15\n    assert candidate(target = 1023,maxDoubles = 9) == 18\n    assert candidate(target = 500000000,maxDoubles = 10) == 488291\n    assert candidate(target = 25,maxDoubles = 3) == 6\n    assert candidate(target = 1024,maxDoubles = 10) == 10\n    assert candidate(target = 8191,maxDoubles = 10) == 26\n    assert candidate(target = 16384,maxDoubles = 16) == 14\n    assert candidate(target = 678901234,maxDoubles = 50) == 45\n    assert candidate(target = 7,maxDoubles = 3) == 4\n    assert candidate(target = 63,maxDoubles = 5) == 10\n    assert candidate(target = 999999999,maxDoubles = 1) == 500000000\n    assert candidate(target = 1048575,maxDoubles = 20) == 38\n    assert candidate(target = 64,maxDoubles = 6) == 6\n    assert candidate(target = 135792468,maxDoubles = 10) == 132623\n    assert candidate(target = 8,maxDoubles = 1) == 4\n    assert candidate(target = 1048576,maxDoubles = 20) == 20\n    assert candidate(target = 123456789,maxDoubles = 25) == 41\n    assert candidate(target = 888888888,maxDoubles = 88) == 46\n    assert candidate(target = 32,maxDoubles = 5) == 5\n    assert candidate(target = 65535,maxDoubles = 0) == 65534\n    assert candidate(target = 1000000000,maxDoubles = 1) == 500000000\n    assert candidate(target = 16,maxDoubles = 1) == 8\n    assert candidate(target = 2047,maxDoubles = 10) == 20\n    assert candidate(target = 2048,maxDoubles = 10) == 11\n    assert candidate(target = 16,maxDoubles = 2) == 5\n    assert candidate(target = 1000,maxDoubles = 10) == 14\n    assert candidate(target = 1000000000,maxDoubles = 0) == 999999999\n    assert candidate(target = 999999999,maxDoubles = 50) == 49\n    assert candidate(target = 65535,maxDoubles = 15) == 30\n    assert candidate(target = 7,maxDoubles = 2) == 4\n    assert candidate(target = 31,maxDoubles = 4) == 8\n    assert candidate(target = 262144,maxDoubles = 19) == 18\n    assert candidate(target = 524287,maxDoubles = 19) == 36\n    assert candidate(target = 19,maxDoubles = 4) == 6\n    assert candidate(target = 268435456,maxDoubles = 28) == 28\n    assert candidate(target = 1000000000,maxDoubles = 30) == 41\n    assert candidate(target = 512,maxDoubles = 9) == 9\n    assert candidate(target = 16383,maxDoubles = 14) == 26\n    assert candidate(target = 8973424,maxDoubles = 50) == 32\n", "comparison": "exact"}, "public_tests": ["5\n0", "19\n2", "10\n4"], "hints": ["Solve the opposite problem: start at the given score and move to 1.", "It is better to use the move of the second type once we can to lose more scores fast."], "metadata": {"canonical_parameter_names": ["target", "maxDoubles"], "leetcode_dataset_entry_point": "Solution().minMoves", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:32+00:00", "tests_total": 140, "tests_dropped": 9, "flags": [], "topic_tags": ["math", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minMoves(self, target: int, maxDoubles: int) -> int:", "container": "Solution", "callable": "minMoves", "parameters": [{"name": "target", "type": "int"}, {"name": "maxDoubles", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2140, "task_id": "solving-questions-with-brainpower", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 2D integer array questions where questions[i] = [points_i, brainpower_i].\n\nThe array describes the questions of an exam, where you have to process the questions in order (i.e., starting from question 0) and make a decision whether to solve or skip each question. Solving question i will earn you points_i points but you will be unable to solve each of the next brainpower_i questions. If you skip question i, you get to make the decision on the next question.\n\n- For example, given questions = [[3, 2], [4, 3], [4, 4], [2, 5]]:\n  - If question 0 is solved, you will earn 3 points but you will be unable to solve questions 1 and 2.\n  - If instead, question 0 is skipped and question 1 is solved, you will earn 4 points but you will be unable to solve questions 2 and 3.\n\nReturn the maximum points you can earn for the exam.\n\nExample 1:\n\nInput: questions = [[3,2],[4,3],[4,4],[2,5]]\nOutput: 5\nExplanation: The maximum points can be earned by solving questions 0 and 3.\n- Solve question 0: Earn 3 points, will be unable to solve the next 2 questions\n- Unable to solve questions 1 and 2\n- Solve question 3: Earn 2 points\nTotal points earned: 3 + 2 = 5. There is no other way to earn 5 or more points.\n\nExample 2:\n\nInput: questions = [[1,1],[2,2],[3,3],[4,4],[5,5]]\nOutput: 7\nExplanation: The maximum points can be earned by solving questions 1 and 4.\n- Skip question 0\n- Solve question 1: Earn 2 points, will be unable to solve the next 2 questions\n- Unable to solve questions 2 and 3\n- Solve question 4: Earn 5 points\nTotal points earned: 2 + 5 = 7. There is no other way to earn 7 or more points.\n\nConstraints:\n\n- 1 <= questions.length <= 10^5\n- questions[i].length == 2\n- 1 <= points_i, brainpower_i <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(questions = [[5, 10], [10, 5], [15, 1]]) == 15\n    assert candidate(questions = [[10, 1], [10, 1], [10, 1], [10, 1], [10, 1]]) == 30\n    assert candidate(questions = [[5, 1], [2, 2], [3, 3], [1, 1], [4, 4]]) == 9\n    assert candidate(questions = [[1, 5], [2, 3], [3, 2], [4, 1]]) == 4\n    assert candidate(questions = [[5, 1], [2, 2], [1, 1]]) == 6\n    assert candidate(questions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 6\n    assert candidate(questions = [[1, 99], [2, 98], [3, 97], [4, 96], [5, 95]]) == 5\n    assert candidate(questions = [[3, 2], [4, 3], [4, 4], [2, 5]]) == 5\n    assert candidate(questions = [[100000, 99999], [1, 1], [1, 1], [1, 1], [1, 1]]) == 100000\n    assert candidate(questions = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 3\n    assert candidate(questions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 7\n    assert candidate(questions = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 10\n    assert candidate(questions = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]]) == 100\n    assert candidate(questions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == 11\n    assert candidate(questions = [[10, 2], [5, 1], [1, 3], [8, 4], [6, 1]]) == 18\n    assert candidate(questions = [[50, 4], [30, 1], [20, 2], [10, 3], [5, 5], [1, 6], [2, 7], [3, 8]]) == 53\n    assert candidate(questions = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 22\n    assert candidate(questions = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 9\n    assert candidate(questions = [[10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10], [100, 11], [110, 12], [120, 13], [130, 14], [140, 15], [150, 16]]) == 230\n    assert candidate(questions = [[50000, 10000], [10000, 5000], [5000, 1000], [1000, 500], [500, 100], [100, 50]]) == 50000\n    assert candidate(questions = [[100, 100], [200, 99], [300, 98], [400, 97], [500, 96], [600, 95], [700, 94], [800, 93], [900, 92], [1000, 91]]) == 1000\n    assert candidate(questions = [[3, 1], [4, 2], [5, 3], [6, 4], [7, 5], [8, 6], [9, 7], [10, 8]]) == 18\n    assert candidate(questions = [[100000, 99999], [2, 1], [3, 2], [4, 3], [5, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 100000\n    assert candidate(questions = [[1000, 500], [900, 450], [800, 400], [700, 350], [600, 300], [500, 250], [400, 200], [300, 150], [200, 100], [100, 50]]) == 1000\n    assert candidate(questions = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8]]) == 120\n    assert candidate(questions = [[1, 99999], [2, 99998], [3, 99997], [4, 99996], [5, 99995]]) == 5\n    assert candidate(questions = [[1, 99999], [2, 99998], [3, 99997], [4, 99996], [5, 99995], [6, 99994], [7, 99993], [8, 99992], [9, 99991], [10, 99990]]) == 10\n    assert candidate(questions = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 8\n    assert candidate(questions = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 10\n    assert candidate(questions = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 10\n    assert candidate(questions = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991]]) == 10\n    assert candidate(questions = [[100, 99], [90, 98], [80, 97], [70, 96], [60, 95], [50, 94], [40, 93], [30, 92], [20, 91], [10, 90]]) == 100\n    assert candidate(questions = [[1, 100000], [2, 100000], [3, 100000], [4, 100000], [5, 100000], [6, 100000]]) == 6\n    assert candidate(questions = [[1, 99998], [2, 99997], [3, 99996], [4, 99995], [5, 99994], [6, 99993], [7, 99992], [8, 99991], [9, 99990], [10, 99989]]) == 10\n    assert candidate(questions = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 10\n    assert candidate(questions = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 15\n    assert candidate(questions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 15\n    assert candidate(questions = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6]]) == 80\n    assert candidate(questions = [[5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1], [5, 1], [3, 1]]) == 50\n    assert candidate(questions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]]) == 19\n    assert candidate(questions = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991]]) == 10\n    assert candidate(questions = [[100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1], [100000, 1]]) == 1000000\n    assert candidate(questions = [[100, 10], [90, 9], [80, 8], [70, 7], [60, 6], [50, 5], [40, 4], [30, 3], [20, 2], [10, 1]]) == 100\n    assert candidate(questions = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7]]) == 110\n    assert candidate(questions = [[10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10], [100, 11]]) == 150\n    assert candidate(questions = [[10000, 9999], [9999, 9998], [9998, 9997], [9997, 9996], [9996, 9995], [9995, 9994], [9994, 9993], [9993, 9992], [9992, 9991], [9991, 9990]]) == 10000\n    assert candidate(questions = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]]) == 4\n    assert candidate(questions = [[20, 3], [15, 2], [10, 5], [5, 1], [1, 1], [2, 2], [3, 3]]) == 24\n    assert candidate(questions = [[1, 10], [10, 1], [100, 10], [1000, 100], [10000, 1000], [100000, 10000]]) == 100010\n", "comparison": "exact"}, "public_tests": ["[[3,2],[4,3],[4,4],[2,5]]", "[[1,1],[2,2],[3,3],[4,4],[5,5]]"], "hints": ["For each question, we can either solve it or skip it. How can we use Dynamic Programming to decide the most optimal option for each problem?", "We store for each question the maximum points we can earn if we started the exam on that question.", "If we skip a question, then the answer for it will be the same as the answer for the next question.", "If we solve a question, then the answer for it will be the points of the current question plus the answer for the next solvable question.", "The maximum of these two values will be the answer to the current question."], "metadata": {"canonical_parameter_names": ["questions"], "leetcode_dataset_entry_point": "Solution().mostPoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:35+00:00", "tests_total": 108, "tests_dropped": 59, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def mostPoints(self, questions: list[list[int]]) -> int:", "container": "Solution", "callable": "mostPoints", "parameters": [{"name": "questions", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2141, "task_id": "maximum-running-time-of-n-computers", "difficulty": "Hard", "problem_description": "You have n computers. You are given the integer n and a 0-indexed integer array batteries where the i^th battery can run a computer for batteries[i] minutes. You are interested in running all n computers simultaneously using the given batteries.\n\nInitially, you can insert at most one battery into each computer. After that and at any integer time moment, you can remove a battery from a computer and insert another battery any number of times. The inserted battery can be a totally new battery or a battery from another computer. You may assume that the removing and inserting processes take no time.\n\nNote that the batteries cannot be recharged.\n\nReturn the maximum number of minutes you can run all the n computers simultaneously.\n\nExample 1:\n\nInput: n = 2, batteries = [3,3,3]\nOutput: 4\nExplanation:\nInitially, insert battery 0 into the first computer and battery 1 into the second computer.\nAfter two minutes, remove battery 1 from the second computer and insert battery 2 instead. Note that battery 1 can still run for one minute.\nAt the end of the third minute, battery 0 is drained, and you need to remove it from the first computer and insert battery 1 instead.\nBy the end of the fourth minute, battery 1 is also drained, and the first computer is no longer running.\nWe can run the two computers simultaneously for at most 4 minutes, so we return 4.\n\nExample 2:\n\nInput: n = 2, batteries = [1,1,1,1]\nOutput: 2\nExplanation:\nInitially, insert battery 0 into the first computer and battery 2 into the second computer.\nAfter one minute, battery 0 and battery 2 are drained so you need to remove them and insert battery 1 into the first computer and battery 3 into the second computer.\nAfter another minute, battery 1 and battery 3 are also drained so the first and second computers are no longer running.\nWe can run the two computers simultaneously for at most 2 minutes, so we return 2.\n\nConstraints:\n\n- 1 <= n <= batteries.length <= 10^5\n- 1 <= batteries[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 5,batteries = [1, 2, 3, 4, 5]) == 1\n    assert candidate(n = 4,batteries = [10, 10, 3, 5]) == 3\n    assert candidate(n = 2,batteries = [1000000000, 1000000000]) == 1000000000\n    assert candidate(n = 2,batteries = [9, 4, 10]) == 11\n    assert candidate(n = 3,batteries = [10, 20, 30, 40]) == 30\n    assert candidate(n = 3,batteries = [5, 8, 5]) == 5\n    assert candidate(n = 10,batteries = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1000000000\n    assert candidate(n = 5,batteries = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 18\n    assert candidate(n = 4,batteries = [1, 2, 3, 4, 5]) == 3\n    assert candidate(n = 2,batteries = [1, 1, 1, 1]) == 2\n    assert candidate(n = 2,batteries = [3, 3, 3]) == 4\n    assert candidate(n = 1,batteries = [5]) == 5\n    assert candidate(n = 1,batteries = [100]) == 100\n    assert candidate(n = 1,batteries = [10]) == 10\n    assert candidate(n = 5,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n    assert candidate(n = 10,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n    assert candidate(n = 3,batteries = [10, 10, 3, 5]) == 8\n    assert candidate(n = 3,batteries = [1, 2, 3, 4, 5, 6]) == 7\n    assert candidate(n = 3,batteries = [10, 10, 10]) == 10\n    assert candidate(n = 5,batteries = [1, 1, 1, 1, 1000000000]) == 1\n    assert candidate(n = 3,batteries = [2, 6, 4, 5]) == 5\n    assert candidate(n = 4,batteries = [5, 5, 5, 5, 5]) == 6\n    assert candidate(n = 5,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n    assert candidate(n = 3,batteries = [1, 2, 999999999]) == 1\n    assert candidate(n = 2,batteries = [10, 20]) == 10\n    assert candidate(n = 2,batteries = [2, 3, 4, 5]) == 7\n    assert candidate(n = 3,batteries = [5, 5, 5, 5, 5]) == 8\n    assert candidate(n = 4,batteries = [8, 8, 8, 8, 8, 8]) == 12\n    assert candidate(n = 10,batteries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 110\n    assert candidate(n = 5,batteries = [500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 350\n    assert candidate(n = 10,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 11\n    assert candidate(n = 4,batteries = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 2500000000\n    assert candidate(n = 5,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n    assert candidate(n = 15,batteries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 3100\n    assert candidate(n = 5,batteries = [10, 20, 30, 40, 50, 60]) == 30\n    assert candidate(n = 5,batteries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 420\n    assert candidate(n = 4,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 13\n    assert candidate(n = 10,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 1\n    assert candidate(n = 4,batteries = [100, 100, 100, 1]) == 1\n    assert candidate(n = 5,batteries = [1000000, 2000000, 3000000, 4000000, 5000000]) == 1000000\n    assert candidate(n = 3,batteries = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 70\n    assert candidate(n = 3,batteries = [1000000000, 1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 13\n    assert candidate(n = 15,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 100]) == 3\n    assert candidate(n = 2,batteries = [1, 1000000000]) == 1\n    assert candidate(n = 5,batteries = [10, 20, 30, 40, 50]) == 10\n    assert candidate(n = 10,batteries = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n    assert candidate(n = 10,batteries = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 1]) == 50\n    assert candidate(n = 3,batteries = [1000000000, 1000000000, 1000000000, 1]) == 1000000000\n    assert candidate(n = 6,batteries = [100, 100, 100, 100, 100, 100, 1]) == 100\n    assert candidate(n = 7,batteries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1714\n    assert candidate(n = 4,batteries = [100, 100, 100, 100, 1, 1, 1, 1]) == 101\n    assert candidate(n = 5,batteries = [10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 18\n    assert candidate(n = 5,batteries = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 18\n    assert candidate(n = 1,batteries = [1000000000]) == 1000000000\n    assert candidate(n = 4,batteries = [2, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 16\n    assert candidate(n = 2,batteries = [1000000000, 1]) == 1\n    assert candidate(n = 4,batteries = [1, 1, 1, 1, 1000000000, 1000000000, 1000000000, 1000000000]) == 1000000001\n    assert candidate(n = 4,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 52\n    assert candidate(n = 8,batteries = [8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n    assert candidate(n = 7,batteries = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 46\n    assert candidate(n = 7,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n    assert candidate(n = 5,batteries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 110\n    assert candidate(n = 10,batteries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(n = 5,batteries = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 2000\n    assert candidate(n = 10,batteries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 500\n    assert candidate(n = 3,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 108\n    assert candidate(n = 6,batteries = [100, 100, 100, 100, 100, 100, 1, 1, 1, 1]) == 100\n    assert candidate(n = 8,batteries = [8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 24\n    assert candidate(n = 5,batteries = [999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999]) == 1999999998\n    assert candidate(n = 4,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 13\n    assert candidate(n = 5,batteries = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 125\n    assert candidate(n = 3,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n    assert candidate(n = 15,batteries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 110\n    assert candidate(n = 6,batteries = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 30\n    assert candidate(n = 8,batteries = [50, 40, 30, 20, 10, 5, 3, 1, 2, 4, 6, 8, 7, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 75\n    assert candidate(n = 5,batteries = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 200\n    assert candidate(n = 8,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n    assert candidate(n = 4,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 116\n    assert candidate(n = 9,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 23\n    assert candidate(n = 3,batteries = [1, 1000000000, 1]) == 1\n    assert candidate(n = 3,batteries = [1000, 1000, 1000, 1, 1, 1, 1, 1, 1, 1]) == 1002\n    assert candidate(n = 7,batteries = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 85\n    assert candidate(n = 2,batteries = [1000000000, 1000000000]) == 1000000000\n    assert candidate(n = 5,batteries = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 250\n    assert candidate(n = 3,batteries = [1000000000, 1000000000, 1000000000, 1000000000, 1]) == 1333333333\n    assert candidate(n = 5,batteries = [1, 1, 1, 1, 1, 1000]) == 1\n    assert candidate(n = 7,batteries = [50, 40, 30, 20, 10, 5, 1, 1, 1, 1, 1, 1, 1]) == 6\n    assert candidate(n = 8,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n    assert candidate(n = 5,batteries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n    assert candidate(n = 2,batteries = [1000000000, 1000000000, 1000000000, 1000000000]) == 2000000000\n    assert candidate(n = 3,batteries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n    assert candidate(n = 7,batteries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 70\n    assert candidate(n = 4,batteries = [100, 100, 100, 100, 1]) == 100\n    assert candidate(n = 6,batteries = [100, 100, 100, 100, 100, 100, 1, 1, 1, 1, 1, 1]) == 101\n    assert candidate(n = 10,batteries = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 999999991\n    assert candidate(n = 3,batteries = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 30\n    assert candidate(n = 10,batteries = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n    assert candidate(n = 4,batteries = [1000000000, 1000000000, 1000000000, 1000000000, 1]) == 1000000000\n    assert candidate(n = 5,batteries = [10, 20, 30, 40, 50, 60]) == 30\n    assert candidate(n = 6,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n    assert candidate(n = 3,batteries = [10, 20, 30, 40, 50]) == 50\n    assert candidate(n = 10,batteries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 100\n    assert candidate(n = 7,batteries = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 14\n    assert candidate(n = 6,batteries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 90\n    assert candidate(n = 7,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n    assert candidate(n = 4,batteries = [10, 20, 30, 40, 50]) == 30\n    assert candidate(n = 2,batteries = [999999999, 1]) == 1\n    assert candidate(n = 6,batteries = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 57\n    assert candidate(n = 7,batteries = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 28\n    assert candidate(n = 6,batteries = [1000, 2000, 3000, 4000, 5000, 6000]) == 1000\n    assert candidate(n = 10,batteries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1100\n    assert candidate(n = 3,batteries = [1000000000, 1000000000, 1000000000, 1000000000]) == 1333333333\n    assert candidate(n = 5,batteries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n    assert candidate(n = 20,batteries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n", "comparison": "exact"}, "public_tests": ["2\n[3,3,3]", "2\n[1,1,1,1]"], "hints": ["For a given running time, can you determine if it is possible to run all n computers simultaneously?", "Try to use Binary Search to find the maximal running time"], "metadata": {"canonical_parameter_names": ["n", "batteries"], "leetcode_dataset_entry_point": "Solution().maxRunTime", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:37+00:00", "tests_total": 114, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxRunTime(self, n: int, batteries: list[int]) -> int:", "container": "Solution", "callable": "maxRunTime", "parameters": [{"name": "n", "type": "int"}, {"name": "batteries", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2144, "task_id": "minimum-cost-of-buying-candies-with-discount", "difficulty": "Easy", "problem_description": "A shop is selling candies at a discount. For every two candies sold, the shop gives a third candy for free.\n\nThe customer can choose any candy to take away for free as long as the cost of the chosen candy is less than or equal to the minimum cost of the two candies bought.\n\n- For example, if there are 4 candies with costs 1, 2, 3, and 4, and the customer buys candies with costs 2 and 3, they can take the candy with cost 1 for free, but not the candy with cost 4.\n\nGiven a 0-indexed integer array cost, where cost[i] denotes the cost of the i^th candy, return the minimum cost of buying all the candies.\n\nExample 1:\n\nInput: cost = [1,2,3]\nOutput: 5\nExplanation: We buy the candies with costs 2 and 3, and take the candy with cost 1 for free.\nThe total cost of buying all candies is 2 + 3 = 5. This is the only way we can buy the candies.\nNote that we cannot buy candies with costs 1 and 3, and then take the candy with cost 2 for free.\nThe cost of the free candy has to be less than or equal to the minimum cost of the purchased candies.\n\nExample 2:\n\nInput: cost = [6,5,7,9,2,2]\nOutput: 23\nExplanation: The way in which we can get the minimum cost is described below:\n- Buy candies with costs 9 and 7\n- Take the candy with cost 6 for free\n- We buy candies with costs 5 and 2\n- Take the last remaining candy with cost 2 for free\nHence, the minimum cost to buy all candies is 9 + 7 + 5 + 2 = 23.\n\nExample 3:\n\nInput: cost = [5,5]\nOutput: 10\nExplanation: Since there are only 2 candies, we buy both of them. There is not a third candy we can take for free.\nHence, the minimum cost to buy all candies is 5 + 5 = 10.\n\nConstraints:\n\n- 1 <= cost.length <= 100\n- 1 <= cost[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(cost = [100]) == 100\n    assert candidate(cost = [1, 1, 1, 1, 1, 1]) == 4\n    assert candidate(cost = [10, 20, 30, 40, 50]) == 120\n    assert candidate(cost = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 663\n    assert candidate(cost = [10, 20]) == 30\n    assert candidate(cost = [1]) == 1\n    assert candidate(cost = [100, 100, 100, 100, 100, 100]) == 400\n    assert candidate(cost = [80, 80, 80, 80, 80, 80, 80, 80, 80, 80]) == 560\n    assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n    assert candidate(cost = [5, 5]) == 10\n    assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 40\n    assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 40\n    assert candidate(cost = [3, 2, 1]) == 5\n    assert candidate(cost = [1, 2]) == 3\n    assert candidate(cost = [1, 2, 3]) == 5\n    assert candidate(cost = [6, 5, 7, 9, 2, 2]) == 23\n    assert candidate(cost = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75]) == 1483\n    assert candidate(cost = [5, 4, 3, 2, 1, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51]) == 2575\n    assert candidate(cost = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 700\n    assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 70\n    assert candidate(cost = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 1700\n    assert candidate(cost = [3, 6, 1, 9, 4, 8, 2, 7, 5, 10]) == 40\n    assert candidate(cost = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 663\n    assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 130\n    assert candidate(cost = [30, 15, 45, 10, 25, 55, 5, 35, 20, 40, 60, 65, 50, 70, 75, 80, 85, 90, 95, 100, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]) == 2433\n    assert candidate(cost = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94, 6, 93, 7, 92, 8, 91, 9, 90, 10]) == 700\n    assert candidate(cost = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3333\n    assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 14\n    assert candidate(cost = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 350\n    assert candidate(cost = [1, 3, 2, 6, 5, 4, 9, 8, 7, 12, 11, 10]) == 56\n    assert candidate(cost = [10, 20, 30, 40, 50, 60]) == 160\n    assert candidate(cost = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 400\n    assert candidate(cost = [3, 6, 1, 8, 2, 7, 4, 5, 9]) == 33\n    assert candidate(cost = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 147\n    assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 56\n    assert candidate(cost = [100, 1, 100, 2, 100, 3, 100, 4, 100, 5, 100, 6, 100, 7, 100, 8, 100, 9, 100, 10]) == 737\n    assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 40\n    assert candidate(cost = [45, 45, 45, 45, 45, 45, 45, 45, 45, 45]) == 315\n    assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 42\n    assert candidate(cost = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 707\n    assert candidate(cost = [100, 50, 25, 10, 5, 1, 100, 50, 25, 10, 5, 1]) == 301\n    assert candidate(cost = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 760\n    assert candidate(cost = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == 17\n    assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 225\n    assert candidate(cost = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10]) == 707\n    assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 14\n    assert candidate(cost = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 1253\n    assert candidate(cost = [33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33]) == 528\n    assert candidate(cost = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 84\n    assert candidate(cost = [30, 40, 10, 50, 60, 20]) == 160\n    assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 65\n    assert candidate(cost = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50]) == 2567\n    assert candidate(cost = [50, 40, 30, 20, 10, 5, 4, 3, 2, 1]) == 128\n    assert candidate(cost = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86]) == 935\n    assert candidate(cost = [1, 3, 2, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13]) == 85\n    assert candidate(cost = [1, 3, 2, 4, 6, 5, 7, 9, 8, 11, 13, 12, 15, 17, 16, 19, 21, 20, 23, 25, 24, 27, 29, 28, 31, 33, 32, 35, 37, 36, 39, 41, 40, 43, 45, 44, 47, 49, 48, 50]) == 680\n    assert candidate(cost = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 1253\n    assert candidate(cost = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == 1700\n    assert candidate(cost = [45, 30, 10, 20, 50, 60, 15, 25, 35, 40]) == 240\n    assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 77\n    assert candidate(cost = [100, 100, 100, 99, 99, 99, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 92, 91, 91, 91, 90, 90, 90, 89, 89, 89, 88, 88, 88, 87, 87, 87, 86, 86, 86, 85, 85, 85]) == 2960\n    assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 3400\n    assert candidate(cost = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 15, 14, 13, 12, 11]) == 85\n    assert candidate(cost = [30, 10, 20, 40, 50, 60]) == 160\n    assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 147\n    assert candidate(cost = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 400\n    assert candidate(cost = [30, 10, 40, 20, 50, 60, 70]) == 210\n    assert candidate(cost = [45, 30, 75, 60, 90, 15, 10, 5]) == 255\n    assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 400\n    assert candidate(cost = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 500\n    assert candidate(cost = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 1400\n    assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 85\n    assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 320\n    assert candidate(cost = [5, 4, 3, 2, 1, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86]) == 947\n    assert candidate(cost = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 3500\n    assert candidate(cost = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 867\n    assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 40\n    assert candidate(cost = [23, 45, 12, 89, 34, 78, 67, 56, 90, 11]) == 370\n    assert candidate(cost = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 70\n    assert candidate(cost = [8, 12, 15, 7, 10, 14, 9]) == 55\n    assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 43\n    assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n    assert candidate(cost = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 735\n    assert candidate(cost = [42, 23, 65, 12, 89, 34, 78, 56, 90, 21, 33, 55, 77, 66, 88, 44, 55, 66, 77, 88]) == 808\n", "comparison": "exact"}, "public_tests": ["[1,2,3]", "[6,5,7,9,2,2]", "[5,5]"], "hints": ["If we consider costs from high to low, what is the maximum cost of a single candy that we can get for free?", "How can we generalize this approach to maximize the costs of the candies we get for free?", "Can “sorting” the array help us find the minimum cost?"], "metadata": {"canonical_parameter_names": ["cost"], "leetcode_dataset_entry_point": "Solution().minimumCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:41+00:00", "tests_total": 96, "tests_dropped": 12, "flags": [], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minimumCost(self, cost: list[int]) -> int:", "container": "Solution", "callable": "minimumCost", "parameters": [{"name": "cost", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2145, "task_id": "count-the-hidden-sequences", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of n integers differences, which describes the differences between each pair of consecutive integers of a hidden sequence of length (n + 1). More formally, call the hidden sequence hidden, then we have that differences[i] = hidden[i + 1] - hidden[i].\n\nYou are further given two integers lower and upper that describe the inclusive range of values [lower, upper] that the hidden sequence can contain.\n\n- For example, given differences = [1, -3, 4], lower = 1, upper = 6, the hidden sequence is a sequence of length 4 whose elements are in between 1 and 6 (inclusive).\n  - [3, 4, 1, 5] and [4, 5, 2, 6] are possible hidden sequences.\n  - [5, 6, 3, 7] is not possible since it contains an element greater than 6.\n  - [1, 2, 3, 4] is not possible since the differences are not correct.\n\nReturn the number of possible hidden sequences there are. If there are no possible sequences, return 0.\n\nExample 1:\n\nInput: differences = [1,-3,4], lower = 1, upper = 6\nOutput: 2\nExplanation: The possible hidden sequences are:\n- [3, 4, 1, 5]\n- [4, 5, 2, 6]\nThus, we return 2.\n\nExample 2:\n\nInput: differences = [3,-4,5,1,-2], lower = -4, upper = 5\nOutput: 4\nExplanation: The possible hidden sequences are:\n- [-3, 0, -4, 1, 2, 0]\n- [-2, 1, -3, 2, 3, 1]\n- [-1, 2, -2, 3, 4, 2]\n- [0, 3, -1, 4, 5, 3]\nThus, we return 4.\n\nExample 3:\n\nInput: differences = [4,-7,2], lower = 3, upper = 6\nOutput: 0\nExplanation: There are no possible hidden sequences. Thus, we return 0.\n\nConstraints:\n\n- n == differences.length\n- 1 <= n <= 10^5\n- -10^5 <= differences[i] <= 10^5\n- -10^5 <= lower <= upper <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(differences = [0, 0, 0],lower = 1,upper = 1) == 1\n    assert candidate(differences = [5, -5, 5, -5],lower = -10,upper = 10) == 16\n    assert candidate(differences = [3, -4, 5, 1, -2],lower = -4,upper = 5) == 4\n    assert candidate(differences = [1, -3, 4],lower = 1,upper = 6) == 2\n    assert candidate(differences = [-1, -1, -1],lower = -3,upper = 3) == 4\n    assert candidate(differences = [-1],lower = -2,upper = -1) == 1\n    assert candidate(differences = [-1, -2, -3, -4, -5],lower = -100,upper = 1) == 87\n    assert candidate(differences = [100000, -100000, 100000, -100000],lower = -100000,upper = 100000) == 100001\n    assert candidate(differences = [10, -5, 15, -10],lower = -10,upper = 10) == 1\n    assert candidate(differences = [0, 0, 0],lower = 1,upper = 5) == 5\n    assert candidate(differences = [1, 1, 1],lower = -5,upper = -1) == 2\n    assert candidate(differences = [100000, -100000],lower = -100000,upper = 100000) == 100001\n    assert candidate(differences = [1, 2, 3],lower = 0,upper = 10) == 5\n    assert candidate(differences = [-1, -2, -3],lower = -10,upper = 0) == 5\n    assert candidate(differences = [10, -10, 10, -10],lower = -5,upper = 5) == 1\n    assert candidate(differences = [100000, -100000, 100000],lower = -100000,upper = 100000) == 100001\n    assert candidate(differences = [0, 0, 0],lower = 0,upper = 0) == 1\n    assert candidate(differences = [1],lower = 1,upper = 2) == 1\n    assert candidate(differences = [-1, -2, -3],lower = -5,upper = 5) == 5\n    assert candidate(differences = [-1, -1, -1],lower = 1,upper = 5) == 2\n    assert candidate(differences = [1, 2, 3, 4, 5],lower = 1,upper = 100) == 85\n    assert candidate(differences = [0, 0, 0],lower = 0,upper = 10) == 11\n    assert candidate(differences = [4, -7, 2],lower = 3,upper = 6) == 0\n    assert candidate(differences = [2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],lower = -15,upper = 15) == 21\n    assert candidate(differences = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],lower = -10,upper = 10) == 11\n    assert candidate(differences = [2, 3, 4, 5, 6, 7, 8, 9, 10],lower = 0,upper = 100) == 47\n    assert candidate(differences = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10],lower = 0,upper = 500) == 0\n    assert candidate(differences = [5, 10, 15, 20, 25, 30],lower = 0,upper = 100) == 0\n    assert candidate(differences = [1000, -500, 200, -100, 50, -25, 10],lower = -1000,upper = 1000) == 1001\n    assert candidate(differences = [-5, -10, -15, -20, -25, -30],lower = -100,upper = 0) == 0\n    assert candidate(differences = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],lower = 0,upper = 2) == 2\n    assert candidate(differences = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],lower = 10,upper = 60) == 1\n    assert candidate(differences = [5, -2, 8, -3, 7],lower = -5,upper = 20) == 11\n    assert candidate(differences = [10000, -20000, 30000, -40000, 50000],lower = -100000,upper = 100000) == 150001\n    assert candidate(differences = [-1, 2, -1, 2, -1],lower = -10,upper = 10) == 18\n    assert candidate(differences = [-1, 0, 1, 0, -1],lower = -5,upper = 5) == 10\n    assert candidate(differences = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],lower = -20,upper = -10) == 0\n    assert candidate(differences = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],lower = 1,upper = 50) == 20\n    assert candidate(differences = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],lower = 0,upper = 1) == 1\n    assert candidate(differences = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],lower = 0,upper = 10) == 1\n    assert candidate(differences = [50000, -50000, 50000, -50000, 50000, -50000, 50000, -50000],lower = -100000,upper = 100000) == 150001\n    assert candidate(differences = [-1, 1, -1, 1, -1],lower = 0,upper = 5) == 5\n    assert candidate(differences = [10000, -10000, 20000, -20000],lower = -50000,upper = 50000) == 80001\n    assert candidate(differences = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],lower = -10,upper = 10) == 11\n    assert candidate(differences = [-5, 10, -15, 20, -25],lower = -30,upper = 30) == 36\n    assert candidate(differences = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],lower = 5,upper = 5) == 1\n    assert candidate(differences = [0, 0, 0, 0, 0],lower = -1,upper = 1) == 3\n    assert candidate(differences = [-1, 2, -3, 4, -5, 6, -7, 8],lower = -10,upper = 10) == 13\n    assert candidate(differences = [-1, 2, -3, 4, -5, 6, -7],lower = -20,upper = 20) == 34\n    assert candidate(differences = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],lower = 0,upper = 100) == 0\n    assert candidate(differences = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],lower = 1,upper = 1000) == 450\n    assert candidate(differences = [5, -2, 3, 7, -4],lower = 1,upper = 20) == 7\n    assert candidate(differences = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],lower = -100,upper = 0) == 0\n    assert candidate(differences = [5, -5, 5, -5, 5, -5],lower = -10,upper = 10) == 16\n    assert candidate(differences = [0, 0, 0, 0, 0],lower = 1,upper = 1) == 1\n    assert candidate(differences = [-1, 2, -2, 1, -1],lower = -5,upper = 5) == 9\n    assert candidate(differences = [10, 20, 30, 40, 50],lower = 0,upper = 200) == 51\n    assert candidate(differences = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],lower = 1,upper = 10) == 0\n    assert candidate(differences = [50, -25, 75, -37, 100, -50, 125, -62, 150, -75, 175, -87, 200, -93, 225, -100, 250, -112, 275, -125],lower = 0,upper = 300) == 0\n    assert candidate(differences = [100000, -100000, 100000, -100000, 100000],lower = -50000,upper = 50000) == 1\n    assert candidate(differences = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],lower = -100,upper = 100) == 151\n    assert candidate(differences = [1, -1, 1, -1, 1],lower = 1,upper = 5) == 4\n    assert candidate(differences = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],lower = -55,upper = -45) == 0\n    assert candidate(differences = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],lower = -10,upper = 0) == 0\n    assert candidate(differences = [1, 2, -3, 4, -5, 6],lower = 1,upper = 10) == 4\n    assert candidate(differences = [100, -50, 200, -100, 50, -200, 100],lower = -1000,upper = 1000) == 1751\n    assert candidate(differences = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1],lower = -1,upper = 1) == 2\n    assert candidate(differences = [-1, -2, -3, -4, -5, -6],lower = -15,upper = -5) == 0\n    assert candidate(differences = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],lower = -1000,upper = 1) == 452\n    assert candidate(differences = [-15, 14, -13, 12, -11, 10, -9, 8, -7, 6, -5, 4, -3, 2, -1],lower = -20,upper = 20) == 26\n    assert candidate(differences = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],lower = -10,upper = 10) == 16\n    assert candidate(differences = [5, 10, -15, 20, -25],lower = -100,upper = 100) == 176\n    assert candidate(differences = [100000, -50000, 50000, -100000, 50000],lower = -100000,upper = 100000) == 100001\n    assert candidate(differences = [100, -50, 25, -10, 5],lower = 0,upper = 200) == 101\n    assert candidate(differences = [-5, -5, -5, -5, -5, -5, -5, -5, -5, -5],lower = -50,upper = 0) == 1\n    assert candidate(differences = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],lower = 10,upper = 20) == 0\n    assert candidate(differences = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],lower = 100,upper = 1000) == 351\n    assert candidate(differences = [5, -2, 3, -4, 1],lower = 1,upper = 10) == 4\n    assert candidate(differences = [2, -1, 3, -2, 4, -3, 5, -4],lower = -5,upper = 10) == 8\n    assert candidate(differences = [0, 0, 0, 0, 0],lower = 0,upper = 10) == 11\n    assert candidate(differences = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],lower = -10,upper = -1) == 0\n    assert candidate(differences = [5, -2, 3, -1, 4],lower = -5,upper = 5) == 2\n    assert candidate(differences = [100000, -50000, 25000, -12500, 6250, -3125, 1562, -781, 390, -195],lower = 0,upper = 100000) == 1\n    assert candidate(differences = [-10, 20, -30, 40, -50, 60],lower = -20,upper = 20) == 0\n    assert candidate(differences = [-10, -20, -30, -40, -50],lower = -200,upper = 0) == 51\n    assert candidate(differences = [5, 10, -5, -10, 15, -15, 20, -20],lower = -100,upper = 100) == 181\n    assert candidate(differences = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],lower = -10,upper = 0) == 1\n    assert candidate(differences = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],lower = 0,upper = 50) == 1\n    assert candidate(differences = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],lower = -50,upper = 50) == 91\n    assert candidate(differences = [20, -10, 30, -15, 5, -1],lower = -100,upper = 100) == 161\n    assert candidate(differences = [2, 3, -2, 1, -3, 2],lower = -5,upper = 15) == 16\n    assert candidate(differences = [2, 3, -5, 2, 3, -5],lower = -3,upper = 3) == 2\n    assert candidate(differences = [100, -50, 25, -10, 5],lower = -20,upper = 200) == 121\n    assert candidate(differences = [-100000, 50000, -50000, 100000, -50000],lower = -100000,upper = 100000) == 100001\n    assert candidate(differences = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],lower = -1,upper = 1) == 3\n    assert candidate(differences = [1, -1, 1, -1, 1, -1],lower = 1,upper = 5) == 4\n    assert candidate(differences = [1, 2, 3, -1, -2, -3, 1, 2, 3, -1, -2, -3],lower = -5,upper = 5) == 5\n    assert candidate(differences = [10, -10, 10, -10, 10, -10, 10, -10],lower = 0,upper = 20) == 11\n    assert candidate(differences = [10, -20, 30, -40, 50],lower = 5,upper = 15) == 0\n    assert candidate(differences = [2, 4, -6, 8, -10, 12, -14],lower = -15,upper = 15) == 17\n    assert candidate(differences = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],lower = 0,upper = 10) == 0\n    assert candidate(differences = [10, 20, 30, 40, 50],lower = 100,upper = 200) == 0\n    assert candidate(differences = [5, -5, 10, -10, 15, -15],lower = -50,upper = 50) == 86\n    assert candidate(differences = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],lower = -50,upper = 0) == 0\n    assert candidate(differences = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],lower = -1,upper = 1) == 2\n    assert candidate(differences = [5, -2, 8, -6, 3],lower = 2,upper = 12) == 0\n    assert candidate(differences = [100, -50, 25, -12, 6, -3, 1],lower = 0,upper = 500) == 401\n    assert candidate(differences = [1, 2, 3, 4, 5, 6],lower = 5,upper = 15) == 0\n    assert candidate(differences = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],lower = 0,upper = 50) == 0\n    assert candidate(differences = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],lower = -10,upper = 10) == 16\n    assert candidate(differences = [0, 0, 0, 0, 0],lower = 0,upper = 0) == 1\n    assert candidate(differences = [5, -2, 3, -4, 7, -1],lower = -5,upper = 15) == 12\n    assert candidate(differences = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],lower = 0,upper = 0) == 1\n    assert candidate(differences = [-3, -3, -3, -3, -3, -3, -3, -3, -3, -3],lower = -50,upper = -1) == 20\n    assert candidate(differences = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16],lower = -100,upper = 100) == 185\n    assert candidate(differences = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15],lower = -50,upper = 50) == 86\n    assert candidate(differences = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],lower = -1000,upper = -100) == 351\n    assert candidate(differences = [5, -2, 3, 7, -5, 8, -6],lower = -10,upper = 20) == 15\n    assert candidate(differences = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],lower = -5,upper = 5) == 1\n    assert candidate(differences = [-1, -2, -3, -4, -5],lower = -15,upper = -5) == 0\n", "comparison": "exact"}, "public_tests": ["[1,-3,4]\n1\n6", "[3,-4,5,1,-2]\n-4\n5", "[4,-7,2]\n3\n6"], "hints": ["Fix the first element of the hidden sequence to any value x and ignore the given bounds. Notice that we can then determine all the other elements of the sequence by using the differences array.", "We will also be able to determine the difference between the minimum and maximum elements of the sequence. Notice that the value of x does not affect this.", "We now have the ‘range’ of the sequence (difference between min and max element), we can then calculate how many ways there are to fit this range into the given range of lower to upper.", "Answer is (upper - lower + 1) - (range of sequence)"], "metadata": {"canonical_parameter_names": ["differences", "lower", "upper"], "leetcode_dataset_entry_point": "Solution().numberOfArrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:44+00:00", "tests_total": 123, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def numberOfArrays(self, differences: list[int], lower: int, upper: int) -> int:", "container": "Solution", "callable": "numberOfArrays", "parameters": [{"name": "differences", "type": "list[int]"}, {"name": "lower", "type": "int"}, {"name": "upper", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2146, "task_id": "k-highest-ranked-items-within-a-price-range", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 2D integer array grid of size m x n that represents a map of the items in a shop. The integers in the grid represent the following:\n\n- 0 represents a wall that you cannot pass through.\n- 1 represents an empty cell that you can freely move to and from.\n- All other positive integers represent the price of an item in that cell. You may also freely move to and from these item cells.\n\nIt takes 1 step to travel between adjacent grid cells.\n\nYou are also given integer arrays pricing and start where pricing = [low, high] and start = [row, col] indicates that you start at the position (row, col) and are interested only in items with a price in the range of [low, high] (inclusive). You are further given an integer k.\n\nYou are interested in the positions of the k highest-ranked items whose prices are within the given price range. The rank is determined by the first of these criteria that is different:\n\n1. Distance, defined as the length of the shortest path from the start (shorter distance has a higher rank).\n2. Price (lower price has a higher rank, but it must be in the price range).\n3. The row number (smaller row number has a higher rank).\n4. The column number (smaller column number has a higher rank).\n\nReturn the k highest-ranked items within the price range sorted by their rank (highest to lowest). If there are fewer than k reachable items within the price range, return all of them.\n\nExample 1:\n\nInput: grid = [[1,2,0,1],[1,3,0,1],[0,2,5,1]], pricing = [2,5], start = [0,0], k = 3\nOutput: [[0,1],[1,1],[2,1]]\nExplanation: You start at (0,0).\nWith a price range of [2,5], we can take items from (0,1), (1,1), (2,1) and (2,2).\nThe ranks of these items are:\n- (0,1) with distance 1\n- (1,1) with distance 2\n- (2,1) with distance 3\n- (2,2) with distance 4\nThus, the 3 highest ranked items in the price range are (0,1), (1,1), and (2,1).\n\nExample 2:\n\nInput: grid = [[1,2,0,1],[1,3,3,1],[0,2,5,1]], pricing = [2,3], start = [2,3], k = 2\nOutput: [[2,1],[1,2]]\nExplanation: You start at (2,3).\nWith a price range of [2,3], we can take items from (0,1), (1,1), (1,2) and (2,1).\nThe ranks of these items are:\n- (2,1) with distance 2, price 2\n- (1,2) with distance 2, price 3\n- (1,1) with distance 3\n- (0,1) with distance 4\nThus, the 2 highest ranked items in the price range are (2,1) and (1,2).\n\nExample 3:\n\nInput: grid = [[1,1,1],[0,0,1],[2,3,4]], pricing = [2,3], start = [0,0], k = 3\nOutput: [[2,1],[2,0]]\nExplanation: You start at (0,0).\nWith a price range of [2,3], we can take items from (2,0) and (2,1).\nThe ranks of these items are:\n- (2,1) with distance 5\n- (2,0) with distance 6\nThus, the 2 highest ranked items in the price range are (2,1) and (2,0).\nNote that k = 3 but there are only 2 reachable items within the price range.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 10^5\n- 1 <= m * n <= 10^5\n- 0 <= grid[i][j] <= 10^5\n- pricing.length == 2\n- 2 <= low <= high <= 10^5\n- start.length == 2\n- 0 <= row <= m - 1\n- 0 <= col <= n - 1\n- grid[row][col] > 0\n- 1 <= k <= m * n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[1, 1, 1], [0, 0, 1], [2, 3, 4]],pricing = [2, 3],start = [0, 0],k = 3) == [[2, 1], [2, 0]]\n    assert candidate(grid = [[1, 2, 0, 1], [1, 3, 3, 1], [0, 2, 5, 1]],pricing = [2, 3],start = [2, 3],k = 2) == [[2, 1], [1, 2]]\n    assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],pricing = [15, 85],start = [1, 1],k = 5) == [[1, 1], [0, 1], [1, 0], [1, 2], [2, 1]]\n    assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 1, 1], [1, 1, 1, 1]],pricing = [1, 1],start = [0, 0],k = 10) == [[0, 0], [0, 1], [1, 0], [0, 2], [2, 0], [0, 3], [2, 1], [3, 0], [1, 3], [2, 2]]\n    assert candidate(grid = [[1, 2, 0, 1], [1, 3, 0, 1], [0, 2, 5, 1]],pricing = [2, 5],start = [0, 0],k = 3) == [[0, 1], [1, 1], [2, 1]]\n    assert candidate(grid = [[1, 3, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 1, 1], [1, 0, 1, 1, 1]],pricing = [2, 3],start = [0, 0],k = 1) == [[0, 1]]\n    assert candidate(grid = [[100, 200, 0, 300], [400, 500, 600, 700], [0, 0, 800, 0], [900, 1000, 1100, 1200]],pricing = [300, 900],start = [1, 1],k = 8) == [[1, 1], [1, 0], [1, 2], [1, 3], [2, 2], [0, 3], [3, 0]]\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],pricing = [1, 9],start = [0, 0],k = 9) == [[0, 0], [0, 1], [1, 0], [0, 2], [1, 1], [2, 0], [1, 2], [2, 1], [2, 2]]\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],pricing = [1, 1],start = [2, 2],k = 15) == [[2, 2], [1, 2], [2, 1], [2, 3], [3, 2], [0, 2], [1, 1], [1, 3], [2, 0], [2, 4], [3, 1], [3, 3], [4, 2], [0, 1], [0, 3]]\n    assert candidate(grid = [[1, 2, 3, 4, 5], [0, 0, 0, 0, 0], [5, 4, 3, 2, 1], [0, 0, 0, 0, 0], [1, 2, 3, 4, 5]],pricing = [2, 4],start = [1, 1],k = 7) == [[0, 1], [2, 1], [0, 2], [2, 2], [2, 3], [0, 3]]\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 10, 20, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 30, 40, 1, 0], [0, 0, 1, 1, 0, 0]],pricing = [5, 30],start = [1, 1],k = 5) == [[1, 2], [1, 3], [3, 2]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],pricing = [5, 25],start = [1, 1],k = 15) == [[1, 1], [1, 0], [1, 2], [2, 1], [1, 3], [2, 0], [2, 2], [1, 4], [2, 3], [0, 4], [1, 5], [2, 4], [0, 5], [1, 6], [0, 6]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]],pricing = [5, 25],start = [0, 5],k = 15) == [[0, 5], [0, 4], [1, 5], [1, 4], [2, 5], [1, 3], [2, 4], [3, 5], [1, 2], [2, 3], [3, 4], [1, 1], [2, 2], [3, 3], [1, 0]]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 1], [1, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 1], [1, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 1], [1, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],pricing = [4, 6],start = [5, 5],k = 20) == [[5, 5], [5, 6], [4, 5], [5, 4], [4, 4], [7, 5], [4, 3], [2, 5], [7, 4], [8, 5], [2, 6], [7, 3], [8, 6], [1, 5], [2, 4], [8, 4], [1, 4], [1, 3]]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]],pricing = [1, 1],start = [3, 3],k = 10) == [[2, 3], [3, 2], [2, 2]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],pricing = [2, 8],start = [1, 1],k = 15) == [[1, 1], [0, 1], [2, 1], [1, 2], [0, 2], [2, 2], [1, 3], [0, 3], [2, 3], [1, 4], [0, 4], [2, 4], [1, 5], [0, 5], [2, 5]]\n    assert candidate(grid = [[5, 0, 5, 0, 5], [0, 5, 0, 5, 0], [5, 0, 5, 0, 5], [0, 5, 0, 5, 0], [5, 0, 5, 0, 5]],pricing = [4, 6],start = [0, 0],k = 10) == [[0, 0]]\n    assert candidate(grid = [[1, 2, 3, 4, 5], [0, 0, 0, 0, 0], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [0, 0, 0, 0, 0], [5, 4, 3, 2, 1]],pricing = [2, 4],start = [1, 1],k = 12) == [[0, 1], [2, 1], [3, 1], [0, 2], [2, 2], [2, 3], [3, 2], [0, 3], [3, 3]]\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],pricing = [5, 15],start = [0, 2],k = 10) == [[1, 2], [1, 1], [2, 2], [2, 1], [3, 2], [2, 0], [3, 1], [4, 2], [3, 0], [4, 1]]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 1], [1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1]],pricing = [1, 1],start = [2, 2],k = 7) == [[1, 2], [2, 1], [2, 3], [3, 2], [0, 2], [2, 0], [4, 2]]\n    assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],pricing = [1, 1],start = [2, 2],k = 5) == [[2, 2]]\n    assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]],pricing = [1, 1],start = [0, 0],k = 1) == [[0, 0]]\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 1, 1], [1, 0, 1, 1, 1]],pricing = [2, 3],start = [0, 0],k = 5) == []\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]],pricing = [1, 1],start = [3, 3],k = 20) == []\n    assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],pricing = [10, 20],start = [0, 0],k = 10) == [[2, 0], [2, 1], [3, 0], [2, 2], [3, 1], [1, 4], [2, 3], [3, 2], [2, 4], [3, 3]]\n    assert candidate(grid = [[1, 2, 0, 0, 5], [0, 3, 4, 0, 6], [7, 0, 8, 9, 0], [0, 10, 11, 0, 12], [13, 0, 14, 15, 0]],pricing = [1, 15],start = [0, 4],k = 15) == [[0, 4], [1, 4]]\n    assert candidate(grid = [[0, 0, 0, 0], [0, 10, 20, 0], [0, 30, 40, 0], [0, 0, 0, 0]],pricing = [10, 40],start = [1, 1],k = 2) == [[1, 1], [1, 2]]\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]],pricing = [1, 1],start = [2, 2],k = 4) == [[1, 2], [2, 1], [2, 3], [3, 2]]\n    assert candidate(grid = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [110, 120, 130, 140, 150, 160, 170, 180, 190, 200], [210, 220, 230, 240, 250, 260, 270, 280, 290, 300], [310, 320, 330, 340, 350, 360, 370, 380, 390, 400], [410, 420, 430, 440, 450, 460, 470, 480, 490, 500]],pricing = [200, 400],start = [2, 5],k = 12) == [[2, 5], [2, 4], [2, 6], [3, 5], [2, 3], [2, 7], [3, 4], [3, 6], [2, 2], [2, 8], [3, 3], [3, 7]]\n    assert candidate(grid = [[1, 1, 0, 1, 1], [1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [1, 1, 0, 1, 1], [1, 1, 0, 1, 1]],pricing = [1, 1],start = [2, 2],k = 5) == []\n    assert candidate(grid = [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200]],pricing = [250, 1050],start = [1, 1],k = 8) == [[1, 1], [1, 0], [1, 2], [2, 1], [0, 2], [2, 0], [2, 2], [3, 0]]\n    assert candidate(grid = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]],pricing = [15, 95],start = [0, 9],k = 8) == [[0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1]]\n    assert candidate(grid = [[1, 2, 3, 0, 5], [0, 6, 0, 7, 8], [9, 10, 11, 12, 0], [13, 14, 0, 15, 16]],pricing = [5, 15],start = [0, 0],k = 5) == [[1, 1], [2, 1], [2, 0], [2, 2], [3, 1]]\n    assert candidate(grid = [[5, 15, 25, 35, 45], [10, 20, 30, 40, 50], [55, 65, 75, 85, 95]],pricing = [10, 90],start = [1, 2],k = 15) == [[1, 2], [1, 1], [0, 2], [1, 3], [2, 2], [1, 0], [0, 1], [0, 3], [1, 4], [2, 1], [2, 3], [0, 4], [2, 0]]\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 2, 3, 0], [0, 4, 5, 6, 0], [0, 7, 8, 9, 0], [0, 0, 0, 0, 0]],pricing = [1, 9],start = [2, 2],k = 8) == [[2, 2], [1, 2], [2, 1], [2, 3], [3, 2], [1, 1], [1, 3], [3, 1]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],pricing = [1, 10],start = [0, 0],k = 10) == [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]],pricing = [5, 35],start = [1, 2],k = 12) == [[1, 2], [1, 1], [1, 3], [2, 2], [1, 0], [1, 4], [2, 1], [2, 3], [3, 2], [0, 4], [1, 5], [2, 0]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],pricing = [5, 15],start = [0, 0],k = 10) == [[1, 0], [1, 1], [1, 2], [0, 4], [1, 3], [0, 5], [1, 4], [0, 6], [0, 7], [0, 8]]\n    assert candidate(grid = [[10, 0, 30, 40, 50], [10, 0, 30, 40, 50], [10, 20, 0, 40, 50], [10, 20, 30, 0, 50], [10, 20, 30, 40, 0]],pricing = [20, 40],start = [0, 0],k = 5) == [[2, 1], [3, 1], [4, 1], [3, 2], [4, 2]]\n    assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 0, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],pricing = [5, 15],start = [2, 2],k = 10) == [[1, 2], [2, 1], [2, 3], [1, 1], [1, 3], [2, 0], [2, 4], [1, 0], [1, 4], [0, 4]]\n    assert candidate(grid = [[100, 200, 300, 400, 500], [600, 700, 0, 800, 900], [1000, 1100, 1200, 1300, 0], [0, 1400, 1500, 1600, 1700]],pricing = [300, 1500],start = [1, 1],k = 10) == [[1, 1], [1, 0], [2, 1], [0, 2], [2, 0], [2, 2], [3, 1], [0, 3], [2, 3], [3, 2]]\n    assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],pricing = [1, 1],start = [0, 0],k = 8) == [[0, 0]]\n    assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]],pricing = [1, 1],start = [2, 2],k = 15) == [[2, 2]]\n    assert candidate(grid = [[5, 0, 5, 0, 5, 0, 5, 0, 5], [0, 5, 0, 5, 0, 5, 0, 5, 0], [5, 0, 5, 0, 5, 0, 5, 0, 5], [0, 5, 0, 5, 0, 5, 0, 5, 0], [5, 0, 5, 0, 5, 0, 5, 0, 5]],pricing = [5, 5],start = [4, 4],k = 15) == [[4, 4]]\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]],pricing = [1, 1],start = [2, 2],k = 8) == [[1, 2], [2, 1], [1, 1], [1, 3], [3, 1], [1, 4], [4, 1], [2, 4]]\n    assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 1, 1, 1, 1, 1, 1, 1, 1, 5], [5, 1, 5, 5, 5, 5, 5, 5, 1, 5], [5, 1, 5, 1, 1, 1, 1, 5, 1, 5], [5, 1, 5, 1, 5, 5, 1, 5, 1, 5], [5, 1, 5, 1, 5, 0, 1, 5, 1, 5], [5, 1, 5, 1, 1, 1, 1, 5, 1, 5], [5, 1, 5, 5, 5, 5, 5, 5, 1, 5], [5, 1, 1, 1, 1, 1, 1, 1, 1, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]],pricing = [1, 5],start = [5, 5],k = 20) == [[5, 6], [6, 5], [4, 5], [5, 4], [3, 5], [4, 6], [5, 3], [6, 4], [6, 6], [4, 4], [5, 7], [7, 5], [3, 4], [3, 6], [4, 3], [5, 8], [6, 3], [8, 5], [2, 5], [4, 7]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],pricing = [1, 10],start = [0, 0],k = 15) == [[0, 0], [0, 1], [1, 0], [2, 0], [0, 2], [1, 1], [2, 1], [0, 3], [1, 2], [3, 0], [4, 0], [2, 2], [0, 4], [1, 3], [3, 1]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],pricing = [5, 9],start = [2, 4],k = 20) == [[2, 4], [1, 4], [2, 5], [3, 4], [0, 4], [1, 5], [3, 5], [4, 4], [1, 3], [2, 6], [3, 3], [0, 5], [4, 5], [1, 2], [2, 7], [3, 2], [0, 6], [4, 6], [1, 1], [2, 8]]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]],pricing = [1, 1],start = [4, 4],k = 20) == [[4, 4]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],pricing = [5, 25],start = [0, 0],k = 15) == [[1, 0], [1, 1], [2, 0], [1, 2], [2, 1], [0, 4], [1, 3], [2, 2], [0, 5], [1, 4], [2, 3], [0, 6], [1, 5], [2, 4], [0, 7]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],pricing = [3, 8],start = [0, 0],k = 15) == [[0, 2], [0, 3], [1, 2], [2, 2], [0, 4], [1, 3], [2, 3], [0, 5], [1, 4], [1, 5], [2, 4], [0, 6], [1, 6], [2, 5], [0, 7]]\n    assert candidate(grid = [[10, 10, 10, 10, 10], [10, 2, 2, 2, 10], [10, 2, 3, 2, 10], [10, 2, 2, 2, 10], [10, 10, 10, 10, 10]],pricing = [2, 3],start = [2, 2],k = 8) == [[2, 2], [1, 2], [2, 1], [2, 3], [3, 2], [1, 1], [1, 3], [3, 1]]\n    assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],pricing = [1, 1],start = [0, 0],k = 15) == [[0, 0]]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]],pricing = [1, 1],start = [3, 3],k = 5) == [[2, 3], [3, 2], [3, 4], [4, 3], [2, 2]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1]],pricing = [3, 7],start = [2, 4],k = 15) == [[2, 4], [2, 3], [1, 4], [3, 4], [2, 5], [2, 2], [1, 5], [3, 5], [0, 4], [4, 4], [1, 3], [3, 3], [2, 6], [1, 6], [3, 6]]\n    assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]],pricing = [3, 8],start = [4, 4],k = 10) == [[3, 4], [4, 3], [2, 4], [3, 3], [4, 2], [1, 4], [2, 3], [3, 2], [4, 1], [0, 4]]\n    assert candidate(grid = [[100, 200, 300, 400, 500], [100, 200, 300, 400, 500], [100, 200, 300, 400, 500], [100, 200, 300, 400, 500], [100, 200, 300, 400, 500]],pricing = [150, 450],start = [2, 2],k = 15) == [[2, 2], [2, 1], [1, 2], [3, 2], [2, 3], [1, 1], [3, 1], [0, 2], [4, 2], [1, 3], [3, 3], [0, 1], [4, 1], [0, 3], [4, 3]]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],pricing = [1, 1],start = [0, 0],k = 20) == [[0, 0], [0, 1], [1, 0], [0, 2], [1, 1], [2, 0], [0, 3], [1, 2], [2, 1], [3, 0], [0, 4], [1, 3], [2, 2], [3, 1], [4, 0], [0, 5], [1, 4], [2, 3], [3, 2], [4, 1]]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],pricing = [2, 8],start = [4, 4],k = 20) == []\n    assert candidate(grid = [[5, 10, 15, 20, 25, 30], [35, 40, 45, 50, 55, 60], [65, 70, 75, 80, 85, 90]],pricing = [20, 70],start = [1, 2],k = 12) == [[1, 2], [1, 1], [1, 3], [0, 3], [1, 0], [1, 4], [2, 1], [0, 4], [1, 5], [2, 0], [0, 5]]\n    assert candidate(grid = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]],pricing = [15, 45],start = [2, 2],k = 10) == [[2, 2], [1, 2], [3, 2], [2, 3], [0, 2], [4, 2], [1, 3], [3, 3], [2, 4], [0, 3]]\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],pricing = [1, 100],start = [2, 2],k = 1) == []\n    assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]],pricing = [1, 1],start = [1, 1],k = 3) == [[0, 1], [1, 0], [0, 0]]\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],pricing = [1, 1],start = [2, 2],k = 8) == []\n    assert candidate(grid = [[100, 200, 300, 400, 500], [600, 700, 800, 900, 1000], [1100, 1200, 1300, 1400, 1500], [1600, 1700, 1800, 1900, 2000], [2100, 2200, 2300, 2400, 2500]],pricing = [500, 2000],start = [2, 2],k = 10) == [[2, 2], [1, 2], [2, 1], [2, 3], [3, 2], [1, 1], [1, 3], [2, 0], [2, 4], [3, 1]]\n    assert candidate(grid = [[5, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],pricing = [1, 5],start = [2, 2],k = 10) == [[3, 2], [3, 1], [3, 3], [4, 2], [3, 0], [3, 4], [4, 1], [4, 3], [2, 0], [2, 4]]\n    assert candidate(grid = [[5, 2, 3, 4, 1], [0, 0, 0, 0, 0], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]],pricing = [1, 20],start = [0, 0],k = 15) == [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]]\n    assert candidate(grid = [[1, 2, 3, 0, 0], [4, 5, 6, 0, 0], [7, 8, 9, 0, 0], [10, 11, 12, 0, 0], [13, 14, 15, 0, 0]],pricing = [5, 10],start = [0, 0],k = 10) == [[1, 1], [2, 0], [1, 2], [2, 1], [3, 0], [2, 2]]\n    assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],pricing = [1, 1],start = [2, 2],k = 5) == [[2, 2]]\n    assert candidate(grid = [[10, 15, 20, 0, 25], [5, 0, 30, 0, 35], [40, 45, 50, 55, 60]],pricing = [10, 50],start = [0, 0],k = 7) == [[0, 0], [0, 1], [0, 2], [2, 0], [1, 2], [2, 1], [2, 2]]\n    assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]],pricing = [1, 1],start = [0, 0],k = 10) == [[0, 0]]\n    assert candidate(grid = [[100000, 0, 100000, 0, 100000], [0, 100000, 0, 100000, 0], [100000, 0, 100000, 0, 100000], [0, 100000, 0, 100000, 0], [100000, 0, 100000, 0, 100000]],pricing = [50000, 150000],start = [1, 1],k = 12) == [[1, 1]]\n    assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [1, 2, 3, 4, 5]],pricing = [3, 7],start = [0, 0],k = 8) == [[1, 0], [0, 2], [1, 1], [1, 2], [2, 1], [0, 3], [0, 4], [2, 2]]\n    assert candidate(grid = [[1, 2, 3, 0, 4, 5, 6], [7, 8, 9, 0, 10, 11, 12], [0, 0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18, 19]],pricing = [1, 18],start = [2, 2],k = 5) == [[2, 2], [2, 3], [3, 2], [1, 2], [0, 2]]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],pricing = [1, 1],start = [4, 5],k = 10) == [[4, 5], [4, 4], [5, 4], [6, 4], [7, 4], [8, 4], [9, 4], [9, 3], [9, 5], [9, 2]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],pricing = [1, 10],start = [4, 0],k = 10) == [[4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9]]\n    assert candidate(grid = [[10, 10, 10, 10], [10, 0, 0, 10], [10, 10, 10, 10], [10, 10, 10, 10]],pricing = [5, 15],start = [1, 1],k = 1) == [[0, 1]]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 2, 3, 4, 5, 6, 7, 0, 1], [1, 0, 8, 9, 10, 11, 12, 13, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],pricing = [2, 12],start = [2, 2],k = 7) == [[2, 2], [2, 3], [3, 2], [2, 4], [3, 3], [2, 5], [3, 4]]\n    assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 0, 0, 0, 1], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5]],pricing = [2, 4],start = [2, 2],k = 5) == [[1, 2], [3, 2], [1, 3], [3, 3], [0, 2]]\n", "comparison": "exact"}, "public_tests": ["[[1,2,0,1],[1,3,0,1],[0,2,5,1]]\n[2,5]\n[0,0]\n3", "[[1,2,0,1],[1,3,3,1],[0,2,5,1]]\n[2,3]\n[2,3]\n2", "[[1,1,1],[0,0,1],[2,3,4]]\n[2,3]\n[0,0]\n3"], "hints": ["Could you determine the rank of every item efficiently?", "We can perform a breadth-first search from the starting position and know the length of the shortest path from start to every item.", "Sort all the items according to the conditions listed in the problem, and return the first k (or all if less than k exist) items as the answer."], "metadata": {"canonical_parameter_names": ["grid", "pricing", "start", "k"], "leetcode_dataset_entry_point": "Solution().highestRankedKItems", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:46+00:00", "tests_total": 79, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "breadth-first-search", "sorting", "heap-priority-queue", "matrix"]}, "language": "python", "interface": {"raw_signature": "def highestRankedKItems(self, grid: list[list[int]], pricing: list[int], start: list[int], k: int) -> list[list[int]]:", "container": "Solution", "callable": "highestRankedKItems", "parameters": [{"name": "grid", "type": "list[list[int]]"}, {"name": "pricing", "type": "list[int]"}, {"name": "start", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2147, "task_id": "number-of-ways-to-divide-a-long-corridor", "difficulty": "Hard", "problem_description": "Along a long library corridor, there is a line of seats and decorative plants. You are given a 0-indexed string corridor of length n consisting of letters 'S' and 'P' where each 'S' represents a seat and each 'P' represents a plant.\n\nOne room divider has already been installed to the left of index 0, and another to the right of index n - 1. Additional room dividers can be installed. For each position between indices i - 1 and i (1 <= i <= n - 1), at most one divider can be installed.\n\nDivide the corridor into non-overlapping sections, where each section has exactly two seats with any number of plants. There may be multiple ways to perform the division. Two ways are different if there is a position with a room divider installed in the first way but not in the second way.\n\nReturn the number of ways to divide the corridor. Since the answer may be very large, return it modulo 10^9 + 7. If there is no way, return 0.\n\nExample 1:\n\nInput: corridor = \"SSPPSPS\"\nOutput: 3\nExplanation: There are 3 different ways to divide the corridor.\nThe black bars in the above image indicate the two room dividers already installed.\nNote that in each of the ways, each section has exactly two seats.\n\nExample 2:\n\nInput: corridor = \"PPSPSP\"\nOutput: 1\nExplanation: There is only 1 way to divide the corridor, by not installing any additional dividers.\nInstalling any would create some section that does not have exactly two seats.\n\nExample 3:\n\nInput: corridor = \"S\"\nOutput: 0\nExplanation: There is no way to divide the corridor because there will always be a section that does not have exactly two seats.\n\nConstraints:\n\n- n == corridor.length\n- 1 <= n <= 10^5\n- corridor[i] is either 'S' or 'P'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(corridor = \"PPPPSSPPPPSSPPPP\") == 5\n    assert candidate(corridor = \"SSSSSSSSSS\") == 1\n    assert candidate(corridor = \"SPSPSPSP\") == 2\n    assert candidate(corridor = \"SSSPPSS\") == 0\n    assert candidate(corridor = \"PSSPSPSPPS\") == 0\n    assert candidate(corridor = \"SS\") == 1\n    assert candidate(corridor = \"PPPP\") == 0\n    assert candidate(corridor = \"SSPPSS\") == 3\n    assert candidate(corridor = \"SSSSPPSSSS\") == 3\n    assert candidate(corridor = \"SSPSSP\") == 2\n    assert candidate(corridor = \"SSPSSPSS\") == 4\n    assert candidate(corridor = \"SSPPPPPSSPPPPSS\") == 30\n    assert candidate(corridor = \"SSPSPSPSPS\") == 4\n    assert candidate(corridor = \"SSSS\") == 1\n    assert candidate(corridor = \"SSSPPPSS\") == 0\n    assert candidate(corridor = \"SSSPPS\") == 1\n    assert candidate(corridor = \"PPSSPPSSPP\") == 3\n    assert candidate(corridor = \"SSPPSSPPSS\") == 9\n    assert candidate(corridor = \"SSPPSPS\") == 3\n    assert candidate(corridor = \"SSPPSPPS\") == 3\n    assert candidate(corridor = \"S\") == 0\n    assert candidate(corridor = \"PPSPSP\") == 1\n    assert candidate(corridor = \"SPPSPPSPPS\") == 3\n    assert candidate(corridor = \"PPSPSPSPSPSPSPSPSP\") == 8\n    assert candidate(corridor = \"SSSPSSSSPPSSPPSSSSPPSSSSPPSSSSSSSSSS\") == 0\n    assert candidate(corridor = \"SPPSPSPSPSPSPSPSPS\") == 0\n    assert candidate(corridor = \"SSPSSPSSPSSPSSPSSPSS\") == 64\n    assert candidate(corridor = \"PPSSPPSPSSPPSS\") == 0\n    assert candidate(corridor = \"SSPPSSSSSSSSPPSSSSSSSSPPSSSSSSSSSS\") == 27\n    assert candidate(corridor = \"SSPPSSPPSSPPSS\") == 27\n    assert candidate(corridor = \"SPSSPSSPSSPSSPSS\") == 0\n    assert candidate(corridor = \"PPPPPPSSPPPPSSPPPP\") == 5\n    assert candidate(corridor = \"SSPPPPPPSSPPPPSSPPPPSSPPSS\") == 525\n    assert candidate(corridor = \"PPSSPPSSPPSSPPSS\") == 27\n    assert candidate(corridor = \"PPPPSSPPPPSSPPPPSSPPPPSSPPPPSSPPPP\") == 625\n    assert candidate(corridor = \"SSSPSPSPSPSPSSSSPSPS\") == 0\n    assert candidate(corridor = \"SSPPSPSPSSSSPPPPSS\") == 30\n    assert candidate(corridor = \"SSPPSSSSSSSSSSSSSS\") == 3\n    assert candidate(corridor = \"PPPPPPPPPPPPPPPPPP\") == 0\n    assert candidate(corridor = \"SPPSPSPSPSPSPSPSPSPS\") == 16\n    assert candidate(corridor = \"SPSPPSPSPPSPSPPSPSPP\") == 27\n    assert candidate(corridor = \"PPSSPPSSPPSSPP\") == 9\n    assert candidate(corridor = \"SSPSPSPSPSPS\") == 0\n    assert candidate(corridor = \"SSSPSSSPSSSPSSSPSS\") == 4\n    assert candidate(corridor = \"PPSSPPSSSSSSSSSSSS\") == 3\n    assert candidate(corridor = \"SSPPPPPPPPSSPPPPSS\") == 45\n    assert candidate(corridor = \"SSPPSSSSSSPPSS\") == 9\n    assert candidate(corridor = \"SSPPPPPPSSPPPPPSS\") == 42\n    assert candidate(corridor = \"SSSSPPPPSSPPSSPPSSSSPPPPSSSSSS\") == 225\n    assert candidate(corridor = \"SSPPPPSSPPSS\") == 15\n    assert candidate(corridor = \"SSSSPPPPSSPPPPSSSSPPPPSS\") == 125\n    assert candidate(corridor = \"SSPPPPSSPPPPSSPPPPSSPPPPSS\") == 625\n    assert candidate(corridor = \"SSPPSPSSSSSSSSSSPPSS\") == 0\n    assert candidate(corridor = \"SPPSPPSPPSPPS\") == 0\n    assert candidate(corridor = \"SSPSPPSPSPSPSPPPSS\") == 0\n    assert candidate(corridor = \"SSPPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSS\") == 177147\n    assert candidate(corridor = \"PPPPPPSPPPPSPPPPSPPPPS\") == 5\n    assert candidate(corridor = \"SSSSSSSSSSSSSSSS\") == 1\n    assert candidate(corridor = \"SSPPSPSSPPSPSSPPSPSS\") == 0\n    assert candidate(corridor = \"PPSSPPSSPPSS\") == 9\n    assert candidate(corridor = \"SSPPSPSPSPSPSPSPSPSPSPSPSPSPSPSPSPSPSPSPSPS\") == 1536\n    assert candidate(corridor = \"SSSPSSPPSSPPSSSSPPSSPPSSPPSSSSPPSSSS\") == 0\n    assert candidate(corridor = \"SSSSSSSSSSSSSSSSSSSSSSSSSS\") == 1\n    assert candidate(corridor = \"SSPPSSPPSSPPSSPPSSSSPPSSSSPPSSSS\") == 729\n    assert candidate(corridor = \"SSPPSPPPSPSPPS\") == 6\n    assert candidate(corridor = \"SSPPPPSSPPPPSSPPSSPPPPSS\") == 375\n    assert candidate(corridor = \"SSPPPPPPSPPPPPSSSSPP\") == 0\n    assert candidate(corridor = \"PPSSSSPPPPSS\") == 5\n    assert candidate(corridor = \"SSPPSPPPSSSSPPSPSS\") == 6\n    assert candidate(corridor = \"PPPPPPSSPPSS\") == 3\n    assert candidate(corridor = \"SSPPSPSSPPSPSSPPSPSSPPSPSS\") == 36\n    assert candidate(corridor = \"SSSPSSSPSSSPSSSPSSSPSSSPSSS\") == 0\n    assert candidate(corridor = \"SSSPSSSSPPSSPPSSSSPPSSSSPPSSSS\") == 0\n    assert candidate(corridor = \"SPPPPPPPPPPP\") == 0\n    assert candidate(corridor = \"PPPPSPSPPPPSPSPPPPSP\") == 0\n    assert candidate(corridor = \"PPSSPPSSPPSSPPSSPPSSPPSSPPSS\") == 729\n    assert candidate(corridor = \"PPPPPPPPPPPPPPPPPPPP\") == 0\n    assert candidate(corridor = \"SSPSSPSSPSSPSSPSSPSSPSS\") == 128\n    assert candidate(corridor = \"SSPPPPSPSPPPSS\") == 20\n    assert candidate(corridor = \"PPSSPSSPPSSPSSPPSSPSSPPSS\") == 216\n    assert candidate(corridor = \"SSPPPSSPPPSSPPPSS\") == 64\n    assert candidate(corridor = \"SSPSSSPSSPSSPSSPSS\") == 0\n    assert candidate(corridor = \"SSPPSSPPSSPPSSPPSSPPSSPPSS\") == 729\n    assert candidate(corridor = \"PPSSPPPPSSPPPPSS\") == 25\n    assert candidate(corridor = \"SPSSSPSSSPSSSPSSSPSS\") == 0\n    assert candidate(corridor = \"PSPSPSPSPSPSPSPSPS\") == 0\n    assert candidate(corridor = \"SSPPSSPSPSPSSP\") == 12\n    assert candidate(corridor = \"SSSSSSSSSSSSSSSSSS\") == 1\n    assert candidate(corridor = \"SSPPSSPPSSPPSPSSPPSS\") == 0\n    assert candidate(corridor = \"SSPPSPSPPPSSSPPSS\") == 0\n    assert candidate(corridor = \"SSPPSSSSPPSSSSPPS\") == 0\n    assert candidate(corridor = \"SSPPPPPPSSSSSSSSSS\") == 7\n    assert candidate(corridor = \"SSPPPPSSPPPPSSSSPPPPSSSSPPPPSSSS\") == 625\n    assert candidate(corridor = \"SSSSSSSSSSPPPPPPSS\") == 7\n    assert candidate(corridor = \"SSSSPPSSSSSSPPSSSS\") == 9\n    assert candidate(corridor = \"SSPSSPSSPSSPSSPSSPSSPSSPSSPS\") == 0\n    assert candidate(corridor = \"SSPPSPSPSPPSS\") == 0\n    assert candidate(corridor = \"PPSSPPPPSSPPSSPP\") == 15\n    assert candidate(corridor = \"SPSSSPSSSPSSSPSS\") == 4\n    assert candidate(corridor = \"PSPPSPSPSPSPSPSPSPSP\") == 0\n    assert candidate(corridor = \"SSSSSSPPSSSSSSPPSSSSSSPPSSSSSS\") == 27\n    assert candidate(corridor = \"SSPPSSPSSPPSSPSSPPSS\") == 108\n    assert candidate(corridor = \"SSSPSPSPSPSPSPSPSPSPSP\") == 16\n    assert candidate(corridor = \"PPPPPPSSPPPP\") == 1\n    assert candidate(corridor = \"PPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSS\") == 19683\n    assert candidate(corridor = \"SSPPSPSSPSPSSPSPSSPSPSS\") == 24\n    assert candidate(corridor = \"SSSPPSSSPPPSSS\") == 0\n    assert candidate(corridor = \"SSSSSSSSSSSS\") == 1\n    assert candidate(corridor = \"SSSSSPPPSSSSSPPPSSSS\") == 4\n    assert candidate(corridor = \"SSSSSSSSPPPPPPPPSSSSSSSSPPPPPPPPSSSS\") == 81\n    assert candidate(corridor = \"SSSSSS\") == 1\n    assert candidate(corridor = \"SSPPPPPPSSSSSSPPSSPP\") == 21\n    assert candidate(corridor = \"SSPSPSPSPSPSPSPSPSPSPSPSPSPSPS\") == 128\n    assert candidate(corridor = \"SSPPSSPPSSPPSSPPSS\") == 81\n    assert candidate(corridor = \"SSSSPPPPSSSSPPPPSSSS\") == 25\n    assert candidate(corridor = \"SSPSPPSSPSPPSSPSPPSS\") == 0\n    assert candidate(corridor = \"SPSPSP\") == 0\n    assert candidate(corridor = \"SSPPPPSPSSPPPSS\") == 0\n    assert candidate(corridor = \"SSSSPSPSPSPS\") == 4\n    assert candidate(corridor = \"PPPPPP\") == 0\n    assert candidate(corridor = \"SSPPPPPPPPPPSSPPPPSSPPSS\") == 165\n    assert candidate(corridor = \"SSPPSSPPSSPPSSPPSSPPSSPPSSPPSSPPSS\") == 6561\n    assert candidate(corridor = \"SSPPPPSSPPPPSSPPSS\") == 75\n    assert candidate(corridor = \"SSSSSSSSSSSSSSSSSSSS\") == 1\n    assert candidate(corridor = \"SSSSPPPPSSSSPPSSSS\") == 15\n    assert candidate(corridor = \"PPPPPPPPPPPPPPPP\") == 0\n    assert candidate(corridor = \"SSSPSPSPSPSPSPSPSPSS\") == 16\n    assert candidate(corridor = \"SSPPSPSSSSPPSPSSSS\") == 6\n    assert candidate(corridor = \"SSPSSPSSPSSPSSPSS\") == 32\n    assert candidate(corridor = \"SSPPSSPPSSPPSSPPSSPP\") == 81\n    assert candidate(corridor = \"PPPPSSPPPPSSPPPPSSPPPPSSPPPPSS\") == 625\n    assert candidate(corridor = \"SSPPSSPPSSPPSSPPSSPPSSPPSSPPSS\") == 2187\n    assert candidate(corridor = \"SSSSPPSSSSPPSSSS\") == 9\n    assert candidate(corridor = \"SSSSSSPPPPSSSSPPPPSSSSSSPPPP\") == 25\n    assert candidate(corridor = \"SSPPSSPPSSPPSSPPSSPPSS\") == 243\n    assert candidate(corridor = \"SSPPSSPPSSPPSSSS\") == 27\n    assert candidate(corridor = \"SSPSPSPSPSPSPSPS\") == 0\n    assert candidate(corridor = \"SSPPSPSPSPSPSS\") == 12\n    assert candidate(corridor = \"SPSPSPSPSPSPSPSPSPSP\") == 16\n    assert candidate(corridor = \"SSPPSSSSPPPPSSSSSSSS\") == 15\n    assert candidate(corridor = \"PPPPSSPPSSPPSSPPPP\") == 9\n    assert candidate(corridor = \"SPSPPSPSPPSPSPPSPSPPSP\") == 0\n    assert candidate(corridor = \"PPSPSPSPSPSPPSPSPS\") == 8\n    assert candidate(corridor = \"SPSPSPSPPSPS\") == 6\n    assert candidate(corridor = \"SSPPSSPPSSPPSSSSPPSSPPSSSSPPSS\") == 729\n", "comparison": "exact"}, "public_tests": ["\"SSPPSPS\"", "\"PPSPSP\"", "\"S\""], "hints": ["Divide the corridor into segments. Each segment has two seats, starts precisely with one seat, and ends precisely with the other seat.", "How many dividers can you install between two adjacent segments? You must install precisely one. Otherwise, you would have created a section with not exactly two seats.", "If there are k plants between two adjacent segments, there are k + 1 positions (ways) you could install the divider you must install.", "The problem now becomes: Find the product of all possible positions between every two adjacent segments."], "metadata": {"canonical_parameter_names": ["corridor"], "leetcode_dataset_entry_point": "Solution().numberOfWays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:49+00:00", "tests_total": 145, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["math", "string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def numberOfWays(self, corridor: str) -> int:", "container": "Solution", "callable": "numberOfWays", "parameters": [{"name": "corridor", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2148, "task_id": "count-elements-with-strictly-smaller-and-greater-elements", "difficulty": "Easy", "problem_description": "Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.\n\nExample 1:\n\nInput: nums = [11,7,2,15]\nOutput: 2\nExplanation: The element 7 has the element 2 strictly smaller than it and the element 11 strictly greater than it.\nElement 11 has element 7 strictly smaller than it and element 15 strictly greater than it.\nIn total there are 2 elements having both a strictly smaller and a strictly greater element appear in nums.\n\nExample 2:\n\nInput: nums = [-3,3,3,90]\nOutput: 2\nExplanation: The element 3 has the element -3 strictly smaller than it and the element 90 strictly greater than it.\nSince there are two elements with the value 3, in total there are 2 elements having both a strictly smaller and a strictly greater element appear in nums.\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- -10^5 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 4\n    assert candidate(nums = [-100000, 100000]) == 0\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n    assert candidate(nums = [100000, -100000, 0, 1, 2]) == 3\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 8, 9]) == 1\n    assert candidate(nums = [1]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 3, 3]) == 2\n    assert candidate(nums = [100000, -100000, 0, 10, 20]) == 3\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 6\n    assert candidate(nums = [11, 7, 2, 15]) == 2\n    assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [5, 5, 5, 5]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 3\n    assert candidate(nums = [0]) == 0\n    assert candidate(nums = [100, 200, 300, 400, 500]) == 3\n    assert candidate(nums = [0, 0, 0, 1]) == 0\n    assert candidate(nums = [-1, 0, 1]) == 1\n    assert candidate(nums = [1, 2]) == 0\n    assert candidate(nums = [1, 2, 3, 3, 3, 4, 5]) == 5\n    assert candidate(nums = [-3, 3, 3, 90]) == 2\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n    assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 10, 11]) == 12\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n    assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000]) == 19\n    assert candidate(nums = [50000, -50000, 0, 1000, 500, 250, 750, 150, 300, 600]) == 8\n    assert candidate(nums = [100000, 100000, 99999, 99999, 50000, 50000, -50000, -50000, -99999, -99999, -100000, -100000]) == 8\n    assert candidate(nums = [50, 20, 30, 40, 10, 60, 70, 80, 90, 100]) == 8\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n    assert candidate(nums = [50000, -50000, 25000, -25000, 12500, -12500, 6250, -6250, 3125, -3125]) == 8\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7]) == 8\n    assert candidate(nums = [-1000, -500, -250, -100, -50, -25, 0, 25, 50, 100, 250, 500, 1000]) == 11\n    assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 6\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 13\n    assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50]) == 8\n    assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996]) == 8\n    assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10]) == 8\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 8\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 13\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 18\n    assert candidate(nums = [10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12]) == 4\n    assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 6\n    assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 8\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 18\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 28\n    assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == 6\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 0\n    assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 0\n    assert candidate(nums = [10, 10, 10, 10, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15]) == 4\n    assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991, 49990, 49989, 49988, 49987, 49986, 49985, 49984, 49983, 49982, 49981]) == 18\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 13\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 15\n    assert candidate(nums = [-100000, 100000, -90000, 90000, -80000, 80000, -70000, 70000, -60000, 60000]) == 8\n    assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90]) == 9\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500]) == 12\n    assert candidate(nums = [10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 16\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 13\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 16\n    assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 6\n    assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 10\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000]) == 0\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 5]) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 23\n    assert candidate(nums = [-10000, -9999, -9998, -9997, -9996, -9995, -9994, -9993, -9992, -9991]) == 8\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10]) == 8\n    assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, -1, -1, -1, -1]) == 4\n    assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 0\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1, 10, 100, 1000, 10000, 100000]) == 8\n    assert candidate(nums = [50, 50, 50, 50, 50, 49, 48, 47, 46, 45, 51, 52, 53, 54, 55]) == 13\n    assert candidate(nums = [-100000, -99999, -99998, -99997, -99996]) == 3\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 18\n    assert candidate(nums = [10000, 10000, 10001, 10001, 9999, 9999, 9998, 9998, 10002, 10002]) == 6\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 18\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 8\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 18\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 9\n    assert candidate(nums = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n    assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 28\n    assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 14\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 23\n    assert candidate(nums = [30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 13\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 15\n    assert candidate(nums = [300, 200, 100, 400, 500, 600, 150, 250, 350, 450]) == 8\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -10, -20, -30, -40, -50]) == 13\n    assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == 6\n    assert candidate(nums = [1, 100000, -1, -100000, 50000, 50001, 50002, 50003, 50004, 50005]) == 8\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 9\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 13\n    assert candidate(nums = [-1000, -2000, -3000, -4000, -5000, -6000, -7000, -8000, -9000, -10000, -1000, -2000, -3000, -4000, -5000]) == 12\n    assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 16\n    assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 12\n    assert candidate(nums = [50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 9\n    assert candidate(nums = [100, 101, 99, 102, 98, 103, 97, 104, 96, 105]) == 8\n    assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 8\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 9\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 14\n    assert candidate(nums = [100000, 100000, 100000, 99999, 99999, 99998, 99998, 99997, 99997, 99996]) == 6\n    assert candidate(nums = [-50000, 50000, 0, 1, 2, -1, -2, -3, 3, 4, -4, 5, -5, 6, -6]) == 13\n    assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == 16\n    assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 8\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 8\n    assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 7, 8, 9, 10]) == 18\n    assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 18\n    assert candidate(nums = [50000, 50000, 50000, 40000, 60000, 30000, 70000, 20000, 80000, 10000]) == 8\n    assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == 8\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 18\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 8\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 1000, 2000, 3000, 4000, 5000]) == 12\n    assert candidate(nums = [12345, -12345, 67890, -67890, 11111, -11111, 22222, -22222, 33333, -33333, 44444, -44444, 55555, -55555]) == 12\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 13\n    assert candidate(nums = [-100000, -50000, -10000, -5000, -1000, -500, -100, -50, -10, -5, 0, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000]) == 19\n    assert candidate(nums = [10, 20, 20, 30, 30, 40, 40, 50, 50]) == 6\n", "comparison": "exact"}, "public_tests": ["[11,7,2,15]", "[-3,3,3,90]"], "hints": ["All the elements in the array should be counted except for the minimum and maximum elements.", "If the array has n elements, the answer will be n - count(min(nums)) - count(max(nums))", "This formula will not work in case the array has all the elements equal, why?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countElements", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:51+00:00", "tests_total": 120, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "sorting", "counting"]}, "language": "python", "interface": {"raw_signature": "def countElements(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countElements", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2149, "task_id": "rearrange-array-elements-by-sign", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers.\n\nYou should return the array of nums such that the array follows the given conditions:\n\n1. Every consecutive pair of integers have opposite signs.\n2. For all integers with the same sign, the order in which they were present in nums is preserved.\n3. The rearranged array begins with a positive integer.\n\nReturn the modified array after rearranging the elements to satisfy the aforementioned conditions.\n\nExample 1:\n\nInput: nums = [3,1,-2,-5,2,-4]\nOutput: [3,-2,1,-5,2,-4]\nExplanation:\nThe positive integers in nums are [3,1,2]. The negative integers are [-2,-5,-4].\nThe only possible way to rearrange them such that they satisfy all conditions is [3,-2,1,-5,2,-4].\nOther ways such as [1,-2,2,-5,3,-4], [3,1,2,-2,-5,-4], [-2,3,-5,1,-4,2] are incorrect because they do not satisfy one or more conditions.\n\nExample 2:\n\nInput: nums = [-1,1]\nOutput: [1,-1]\nExplanation:\n1 is the only positive integer and -1 the only negative integer in nums.\nSo nums is rearranged to [1,-1].\n\nConstraints:\n\n- 2 <= nums.length <= 2 * 10^5\n- nums.length is even\n- 1 <= |nums[i]| <= 10^5\n- nums consists of equal number of positive and negative integers.\n\nIt is not required to do the modifications in-place.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [4, 2, -3, -1, 5, -6]) == [4, -3, 2, -1, 5, -6]\n    assert candidate(nums = [1, -1, 2, -2, 3, -3]) == [1, -1, 2, -2, 3, -3]\n    assert candidate(nums = [4, -3, 2, -5, 6, -7]) == [4, -3, 2, -5, 6, -7]\n    assert candidate(nums = [3, 1, -2, -5, 2, -4]) == [3, -2, 1, -5, 2, -4]\n    assert candidate(nums = [10, -10, 20, -20, 30, -30]) == [10, -10, 20, -20, 30, -30]\n    assert candidate(nums = [7, 10, -5, -3, 2, -8]) == [7, -5, 10, -3, 2, -8]\n    assert candidate(nums = [-1, 1]) == [1, -1]\n    assert candidate(nums = [8, 5, -7, -3, 4, -6]) == [8, -7, 5, -3, 4, -6]\n    assert candidate(nums = [5, -5, 6, -6, 7, -7]) == [5, -5, 6, -6, 7, -7]\n    assert candidate(nums = [9, -2, 6, -1, 3, -4]) == [9, -2, 6, -1, 3, -4]\n    assert candidate(nums = [4, -3, 2, -1, 6, -5]) == [4, -3, 2, -1, 6, -5]\n    assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40, 45, -45, 50, -50]) == [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40, 45, -45, 50, -50]\n    assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]\n    assert candidate(nums = [-2, 2, -4, 4, -6, 6, -8, 8, -10, 10, -12, 12, -14, 14, -16, 16, -18, 18, -20, 20]) == [2, -2, 4, -4, 6, -6, 8, -8, 10, -10, 12, -12, 14, -14, 16, -16, 18, -18, 20, -20]\n    assert candidate(nums = [21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30]) == [21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30]\n    assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600]) == [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600]\n    assert candidate(nums = [6, -2, 3, -1, 7, -5, 8, -4, 9, -6, 10, -8, 11, -7, 12, -9]) == [6, -2, 3, -1, 7, -5, 8, -4, 9, -6, 10, -8, 11, -7, 12, -9]\n    assert candidate(nums = [5, 15, 25, 35, 45, -5, -15, -25, -35, -45, 65, -65]) == [5, -5, 15, -15, 25, -25, 35, -35, 45, -45, 65, -65]\n    assert candidate(nums = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, -21, -19, -17, -15, -13, -11, -9, -7, -5, -3]) == [21, -21, 19, -19, 17, -17, 15, -15, 13, -13, 11, -11, 9, -9, 7, -7, 5, -5, 3, -3]\n    assert candidate(nums = [12, -12, 24, -24, 36, -36, 48, -48, 60, -60, 72, -72]) == [12, -12, 24, -24, 36, -36, 48, -48, 60, -60, 72, -72]\n    assert candidate(nums = [42, -84, 21, -42, 63, -126, 84, -168, 105, -210]) == [42, -84, 21, -42, 63, -126, 84, -168, 105, -210]\n    assert candidate(nums = [2, 4, 6, 8, 10, -2, -4, -6, -8, -10, 12, 14, -12, -14, 16, -16, 18, -18]) == [2, -2, 4, -4, 6, -6, 8, -8, 10, -10, 12, -12, 14, -14, 16, -16, 18, -18]\n    assert candidate(nums = [10, -11, 20, -21, 30, -31, 40, -41, 50, -51, 60, -61, 70, -71, 80, -81, 90, -91, 100, -101, 110, -111, 120, -121]) == [10, -11, 20, -21, 30, -31, 40, -41, 50, -51, 60, -61, 70, -71, 80, -81, 90, -91, 100, -101, 110, -111, 120, -121]\n    assert candidate(nums = [10, 20, 30, -1, -2, -3, 40, -4, 50, -5]) == [10, -1, 20, -2, 30, -3, 40, -4, 50, -5]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\n    assert candidate(nums = [-10, 11, -12, 13, -14, 15, -16, 17, -18, 19]) == [11, -10, 13, -12, 15, -14, 17, -16, 19, -18]\n    assert candidate(nums = [100000, 50000, -50000, -100000, 25000, -25000, 12500, -12500, 6250, -6250]) == [100000, -50000, 50000, -100000, 25000, -25000, 12500, -12500, 6250, -6250]\n    assert candidate(nums = [20, 10, -10, -20, 30, 40, -30, -40, 50, 60, -50, -60]) == [20, -10, 10, -20, 30, -30, 40, -40, 50, -50, 60, -60]\n    assert candidate(nums = [2, 4, 6, 8, 10, -2, -4, -6, -8, -10, 12, 14, 16, 18, 20, -12, -14, -16, -18, -20]) == [2, -2, 4, -4, 6, -6, 8, -8, 10, -10, 12, -12, 14, -14, 16, -16, 18, -18, 20, -20]\n    assert candidate(nums = [15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75, 85, -85]) == [15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75, 85, -85]\n    assert candidate(nums = [5, 10, -5, -10, 15, 20, -15, -20, 25, 30, -25, -30]) == [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30]\n    assert candidate(nums = [5, -3, 2, -8, 6, -1, 4, -7]) == [5, -3, 2, -8, 6, -1, 4, -7]\n    assert candidate(nums = [100, 200, -100, -200, 300, -300, 400, -400, 500, -500]) == [100, -100, 200, -200, 300, -300, 400, -400, 500, -500]\n    assert candidate(nums = [50, -25, 75, -37, 100, -50, 125, -62, 150, -75, 175, -87, 200, -100]) == [50, -25, 75, -37, 100, -50, 125, -62, 150, -75, 175, -87, 200, -100]\n    assert candidate(nums = [100000, 200000, -100000, -200000, 300000, 400000, -300000, -400000, 500000, -500000]) == [100000, -100000, 200000, -200000, 300000, -300000, 400000, -400000, 500000, -500000]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, -1, -3, -5, -7, -9, -11, -13, -15]) == [1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 11, -11, 13, -13, 15, -15]\n    assert candidate(nums = [5, -5, 15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65]) == [5, -5, 15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65]\n    assert candidate(nums = [5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14]) == [5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14]\n    assert candidate(nums = [7, -7, 14, -14, 21, -21, 28, -28, 35, -35]) == [7, -7, 14, -14, 21, -21, 28, -28, 35, -35]\n    assert candidate(nums = [100, 200, -50, -150, 300, -250, 400, -350, 500, -450]) == [100, -50, 200, -150, 300, -250, 400, -350, 500, -450]\n    assert candidate(nums = [15, 3, -9, -6, 12, -5, 20, -7, 18, -11]) == [15, -9, 3, -6, 12, -5, 20, -7, 18, -11]\n    assert candidate(nums = [99, -98, 97, -96, 95, -94, 93, -92, 91, -90, 89, -88, 87, -86, 85, -84]) == [99, -98, 97, -96, 95, -94, 93, -92, 91, -90, 89, -88, 87, -86, 85, -84]\n    assert candidate(nums = [50, -50, 25, -25, 75, -75, 100, -100, 200, -200, 300, -300]) == [50, -50, 25, -25, 75, -75, 100, -100, 200, -200, 300, -300]\n    assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40]) == [10, -10, 20, -20, 30, -30, 40, -40]\n    assert candidate(nums = [7, -7, 14, -14, 21, -21, 28, -28, 35, -35, 42, -42, 49, -49, 56, -56]) == [7, -7, 14, -14, 21, -21, 28, -28, 35, -35, 42, -42, 49, -49, 56, -56]\n    assert candidate(nums = [15, -20, 25, -30, 35, -40, 45, -50, 55, -60]) == [15, -20, 25, -30, 35, -40, 45, -50, 55, -60]\n    assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000, 6000, -6000]) == [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000, 6000, -6000]\n    assert candidate(nums = [1, 3, 5, 7, 9, -1, -3, -5, -7, -9, 2, 4, 6, 8, 10, -2, -4, -6, -8, -10]) == [1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 2, -2, 4, -4, 6, -6, 8, -8, 10, -10]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, -1, -3, -5, -7, -9, -11]) == [1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 11, -11]\n    assert candidate(nums = [31, 41, 59, 26, -31, -41, -59, -26, 53, 58, 97, 93, -53, -58, -97, -93, 23, 84, -23, -84]) == [31, -31, 41, -41, 59, -59, 26, -26, 53, -53, 58, -58, 97, -97, 93, -93, 23, -23, 84, -84]\n    assert candidate(nums = [-9, 1, -8, 2, -7, 3, -6, 4, -5, 5, -4, 6, -3, 7, -2, 8, -1, 9]) == [1, -9, 2, -8, 3, -7, 4, -6, 5, -5, 6, -4, 7, -3, 8, -2, 9, -1]\n    assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500]) == [100, -100, 200, -200, 300, -300, 400, -400, 500, -500]\n    assert candidate(nums = [9, 11, -9, -11, 12, 13, -12, -13, 14, -14, 15, -15, 16, -16]) == [9, -9, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16]\n    assert candidate(nums = [1, 1, 1, 1, -1, -1, -1, -1, 2, 2, 2, 2, -2, -2, -2, -2, 3, 3, 3, 3, -3, -3, -3, -3]) == [1, -1, 1, -1, 1, -1, 1, -1, 2, -2, 2, -2, 2, -2, 2, -2, 3, -3, 3, -3, 3, -3, 3, -3]\n    assert candidate(nums = [7, -7, 6, -6, 5, -5, 4, -4, 3, -3, 2, -2, 1, -1]) == [7, -7, 6, -6, 5, -5, 4, -4, 3, -3, 2, -2, 1, -1]\n    assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1563, 782, 391, 195, -100000, -50000, -25000, -12500, -6250, -3125, -1563, -782, -391, -195]) == [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500, 6250, -6250, 3125, -3125, 1563, -1563, 782, -782, 391, -391, 195, -195]\n    assert candidate(nums = [6, -6, 5, -5, 4, -4, 3, -3, 2, -2, 1, -1]) == [6, -6, 5, -5, 4, -4, 3, -3, 2, -2, 1, -1]\n    assert candidate(nums = [9, -9, 8, -8, 7, -7, 6, -6, 5, -5, 4, -4, 3, -3, 2, -2, 1, -1]) == [9, -9, 8, -8, 7, -7, 6, -6, 5, -5, 4, -4, 3, -3, 2, -2, 1, -1]\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]\n    assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000, 6000, -6000, 7000, -7000, 8000, -8000, 9000, -9000, 10000, -10000]) == [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000, 6000, -6000, 7000, -7000, 8000, -8000, 9000, -9000, 10000, -10000]\n    assert candidate(nums = [10, 20, -10, 30, -20, 40, -30, 50, -40, 60, -50, -60, 70, 80, -70, -80]) == [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80]\n    assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12]) == [2, -1, 4, -3, 6, -5, 8, -7, 10, -9, 12, -11]\n    assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50]) == [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]\n    assert candidate(nums = [7, 14, -7, -14, 21, 28, -21, -28, 35, 42, -35, -42, 49, 56, -49, -56]) == [7, -7, 14, -14, 21, -21, 28, -28, 35, -35, 42, -42, 49, -49, 56, -56]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, -1, -2, -3, -4, -5, -6]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]\n    assert candidate(nums = [7, 11, -3, -8, 9, -4, 6, -2, 13, -5]) == [7, -3, 11, -8, 9, -4, 6, -2, 13, -5]\n    assert candidate(nums = [22, 33, -22, -33, 44, 55, -44, -55, 66, 77, -66, -77, 88, 99, -88, -99, 11, 22, -11, -22]) == [22, -22, 33, -33, 44, -44, 55, -55, 66, -66, 77, -77, 88, -88, 99, -99, 11, -11, 22, -22]\n    assert candidate(nums = [100, -99, 101, -98, 102, -97, 103, -96, 104, -95]) == [100, -99, 101, -98, 102, -97, 103, -96, 104, -95]\n    assert candidate(nums = [10, 15, -5, -10, 20, -20, 25, -25]) == [10, -5, 15, -10, 20, -20, 25, -25]\n    assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000]) == [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000]\n    assert candidate(nums = [34, 56, -34, -56, 78, 90, -78, -90, 12, 34, -12, -34, 56, 78, -56, -78]) == [34, -34, 56, -56, 78, -78, 90, -90, 12, -12, 34, -34, 56, -56, 78, -78]\n    assert candidate(nums = [101, 202, 303, 404, 505, -101, -202, -303, -404, -505, 606, 707, -606, -707, 808, 909, -808, -909]) == [101, -101, 202, -202, 303, -303, 404, -404, 505, -505, 606, -606, 707, -707, 808, -808, 909, -909]\n    assert candidate(nums = [15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75, 85, -85, 95, -95, 105, -105, 115, -115, 125, -125]) == [15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75, 85, -85, 95, -95, 105, -105, 115, -115, 125, -125]\n    assert candidate(nums = [21, -21, 32, -32, 43, -43, 54, -54, 65, -65, 76, -76, 87, -87, 98, -98, 109, -109, 120, -120]) == [21, -21, 32, -32, 43, -43, 54, -54, 65, -65, 76, -76, 87, -87, 98, -98, 109, -109, 120, -120]\n    assert candidate(nums = [10, 9, -10, -9, 8, 7, -8, -7, 6, 5, -6, -5, 4, 3, -4, -3, 2, 1, -2, -1]) == [10, -10, 9, -9, 8, -8, 7, -7, 6, -6, 5, -5, 4, -4, 3, -3, 2, -2, 1, -1]\n    assert candidate(nums = [21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28]) == [21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28]\n    assert candidate(nums = [9, -9, 7, -7, 5, -5, 3, -3, 1, -1]) == [9, -9, 7, -7, 5, -5, 3, -3, 1, -1]\n    assert candidate(nums = [3, -3, 6, -6, 9, -9, 12, -12, 15, -15, 18, -18, 21, -21, 24, -24, 27, -27]) == [3, -3, 6, -6, 9, -9, 12, -12, 15, -15, 18, -18, 21, -21, 24, -24, 27, -27]\n    assert candidate(nums = [6, -6, 3, -3, 9, -9, 12, -12, 15, -15, 18, -18]) == [6, -6, 3, -3, 9, -9, 12, -12, 15, -15, 18, -18]\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]\n    assert candidate(nums = [7, 3, -3, -7, 9, -9, 11, -11, 13, -13]) == [7, -3, 3, -7, 9, -9, 11, -11, 13, -13]\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12]\n    assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == [2, -1, 4, -3, 6, -5, 8, -7, 10, -9]\n    assert candidate(nums = [15, -5, 20, -10, 25, -15, 30, -20, 35, -25, 40, -30, 45, -35]) == [15, -5, 20, -10, 25, -15, 30, -20, 35, -25, 40, -30, 45, -35]\n    assert candidate(nums = [7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13]) == [7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13]\n    assert candidate(nums = [100, -50, 75, -25, 125, -62, 150, -87, 200, -12]) == [100, -50, 75, -25, 125, -62, 150, -87, 200, -12]\n    assert candidate(nums = [10, 20, -10, -20, 30, -30, 40, -40]) == [10, -10, 20, -20, 30, -30, 40, -40]\n    assert candidate(nums = [20, -30, 21, -31, 22, -32, 23, -33, 24, -34, 25, -35]) == [20, -30, 21, -31, 22, -32, 23, -33, 24, -34, 25, -35]\n    assert candidate(nums = [13, -13, 11, -11, 9, -9, 7, -7, 5, -5, 3, -3, 1, -1, 14, -14, 12, -12, 10, -10, 8, -8, 6, -6, 4, -4, 2, -2]) == [13, -13, 11, -11, 9, -9, 7, -7, 5, -5, 3, -3, 1, -1, 14, -14, 12, -12, 10, -10, 8, -8, 6, -6, 4, -4, 2, -2]\n    assert candidate(nums = [7, 10, -1, -4, 9, -2, 6, -8]) == [7, -1, 10, -4, 9, -2, 6, -8]\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]\n    assert candidate(nums = [1, 3, 5, 7, -1, -3, -5, -7, 9, 11, -9, -11, 13, 15, -13, -15]) == [1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 11, -11, 13, -13, 15, -15]\n    assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25, -25]) == [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25, -25]\n    assert candidate(nums = [10, -1, 12, -2, 14, -3, 15, -4, 16, -5]) == [10, -1, 12, -2, 14, -3, 15, -4, 16, -5]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, -10, -20, -30, -40, -50, -60]) == [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60]\n    assert candidate(nums = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, -20, -18, -16, -14, -12, -10, -8, -6, -4, -2]) == [20, -20, 18, -18, 16, -16, 14, -14, 12, -12, 10, -10, 8, -8, 6, -6, 4, -4, 2, -2]\n    assert candidate(nums = [7, 10, -2, -8, 1, -3, 9, -4, 5, -6]) == [7, -2, 10, -8, 1, -3, 9, -4, 5, -6]\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]\n", "comparison": "exact"}, "public_tests": ["[3,1,-2,-5,2,-4]", "[-1,1]"], "hints": ["Divide the array into two parts- one comprising of only positive integers and the other of negative integers.", "Merge the two parts to get the resultant array."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().rearrangeArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:53+00:00", "tests_total": 99, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "two-pointers", "simulation"]}, "language": "python", "interface": {"raw_signature": "def rearrangeArray(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "rearrangeArray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2150, "task_id": "find-all-lonely-numbers-in-the-array", "difficulty": "Medium", "problem_description": "You are given an integer array nums. A number x is lonely when it appears only once, and no adjacent numbers (i.e. x + 1 and x - 1) appear in the array.\n\nReturn all lonely numbers in nums. You may return the answer in any order.\n\nExample 1:\n\nInput: nums = [10,6,5,8]\nOutput: [10,8]\nExplanation:\n- 10 is a lonely number since it appears exactly once and 9 and 11 does not appear in nums.\n- 8 is a lonely number since it appears exactly once and 7 and 9 does not appear in nums.\n- 5 is not a lonely number since 6 appears in nums and vice versa.\nHence, the lonely numbers in nums are [10, 8].\nNote that [8, 10] may also be returned.\n\nExample 2:\n\nInput: nums = [1,3,5,3]\nOutput: [1,5]\nExplanation:\n- 1 is a lonely number since it appears exactly once and 0 and 2 does not appear in nums.\n- 5 is a lonely number since it appears exactly once and 4 and 6 does not appear in nums.\n- 3 is not a lonely number since it appears twice.\nHence, the lonely numbers in nums are [1, 5].\nNote that [5, 1] may also be returned.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= nums[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n    \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n    if isinstance(result, list) and isinstance(expected, list):\n        return sorted(result, key=repr) == sorted(expected, key=repr)\n    return result == expected\n\n\ndef check(candidate):\n    assert answers_match(candidate(nums=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), [])\n    assert answers_match(candidate(nums=[2, 4, 6, 8, 10, 12, 14]), [2, 4, 6, 8, 10, 12, 14])\n    assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), [])\n    assert answers_match(candidate(nums=[10, 6, 5, 8]), [10, 8])\n    assert answers_match(candidate(nums=[7, 7, 7, 7, 7, 7, 7]), [])\n    assert answers_match(candidate(nums=[1, 1, 2, 2, 3, 3, 4, 4, 5, 5]), [])\n    assert answers_match(candidate(nums=[1, 2, 3, 5, 7, 9, 11]), [5, 7, 9, 11])\n    assert answers_match(candidate(nums=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), [])\n    assert answers_match(candidate(nums=[1, 2, 3, 5, 7, 8, 10]), [5, 10])\n    assert answers_match(candidate(nums=[1, 1, 3, 3, 5, 5, 7, 7, 9, 9]), [])\n    assert answers_match(candidate(nums=[2]), [2])\n    assert answers_match(candidate(nums=[5, 5, 5, 5, 5]), [])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0]), [])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1]), [])\n    assert answers_match(candidate(nums=[1, 2, 3, 4, 5]), [])\n    assert answers_match(candidate(nums=[1, 2, 4, 6, 8, 10]), [4, 6, 8, 10])\n    assert answers_match(candidate(nums=[1, 1, 2, 3, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9, 10, 10]), [])\n    assert answers_match(candidate(nums=[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]), [])\n    assert answers_match(candidate(nums=[1000000]), [1000000])\n    assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]), [])\n    assert answers_match(candidate(nums=[0, 1, 2, 3, 4, 5, 6]), [])\n    assert answers_match(candidate(nums=[1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10]), [])\n    assert answers_match(candidate(nums=[7, 7, 8, 8, 9, 9, 10, 10, 11, 11]), [])\n    assert answers_match(candidate(nums=[1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]), [])\n    assert answers_match(candidate(nums=[1, 3, 5, 3]), [1, 5])\n    assert answers_match(candidate(nums=[1, 1, 1, 2, 2, 2, 3, 3, 3]), [])\n    assert answers_match(candidate(nums=[5]), [5])\n    assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]), [])\n    assert answers_match(candidate(nums=[5, 7, 9, 11, 13, 15]), [5, 7, 9, 11, 13, 15])\n    assert answers_match(candidate(nums=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31])\n    assert answers_match(candidate(nums=[1, 3, 6, 8, 10, 12, 15, 17, 19, 21, 24, 26, 28, 30, 33, 35, 37]), [1, 3, 6, 8, 10, 12, 15, 17, 19, 21, 24, 26, 28, 30, 33, 35, 37])\n    assert answers_match(candidate(nums=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]), [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100])\n    assert answers_match(candidate(nums=[500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520]), [])\n    assert answers_match(candidate(nums=[100000, 99998, 100002, 99996, 99994, 100004, 100006, 100010, 100012, 100014]), [100000, 99998, 100002, 99996, 99994, 100004, 100006, 100010, 100012, 100014])\n    assert answers_match(candidate(nums=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]), [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000])\n    assert answers_match(candidate(nums=[1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]), [4, 6, 8, 10, 12, 14, 16, 18, 20])\n    assert answers_match(candidate(nums=[100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]), [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000])\n    assert answers_match(candidate(nums=[1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29]), [])\n    assert answers_match(candidate(nums=[1000000, 999998, 999999, 1, 0, 2, 3, 4, 5, 6, 7, 8, 9]), [])\n    assert answers_match(candidate(nums=[100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130]), [])\n    assert answers_match(candidate(nums=[3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17, 19, 20, 21, 23, 24, 25, 27, 28]), [])\n    assert answers_match(candidate(nums=[3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117]), [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117])\n    assert answers_match(candidate(nums=[5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]), [])\n    assert answers_match(candidate(nums=[8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136]), [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136])\n    assert answers_match(candidate(nums=[1, 2, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55]), [4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55])\n    assert answers_match(candidate(nums=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29])\n    assert answers_match(candidate(nums=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59])\n    assert answers_match(candidate(nums=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39])\n    assert answers_match(candidate(nums=[999999, 999997, 999995, 999993, 999991, 999989, 999987, 999985, 999983, 999981, 999979, 999977, 999975]), [999999, 999997, 999995, 999993, 999991, 999989, 999987, 999985, 999983, 999981, 999979, 999977, 999975])\n    assert answers_match(candidate(nums=[1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]), [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50])\n    assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]), [])\n    assert answers_match(candidate(nums=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59])\n    assert answers_match(candidate(nums=[1, 1, 2, 3, 3, 5, 7, 8, 8, 10, 11, 13, 13, 15]), [5, 15])\n    assert answers_match(candidate(nums=[2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78]), [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78])\n    assert answers_match(candidate(nums=[1, 2, 2, 3, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 10]), [])\n    assert answers_match(candidate(nums=[100, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125]), [103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125])\n    assert answers_match(candidate(nums=[2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59]), [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59])\n    assert answers_match(candidate(nums=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85]), [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85])\n    assert answers_match(candidate(nums=[8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160]), [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160])\n    assert answers_match(candidate(nums=[5, 5, 5, 5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45]), [45])\n    assert answers_match(candidate(nums=[15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]), [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100])\n    assert answers_match(candidate(nums=[5, 9, 15, 21, 27, 33, 39, 45, 51, 57]), [5, 9, 15, 21, 27, 33, 39, 45, 51, 57])\n    assert answers_match(candidate(nums=[1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100]), [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100])\n    assert answers_match(candidate(nums=[10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70]), [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70])\n    assert answers_match(candidate(nums=[11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89]), [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89])\n    assert answers_match(candidate(nums=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50]), [5, 10, 15, 20, 25, 30, 35, 40, 45, 50])\n    assert answers_match(candidate(nums=[100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120]), [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120])\n    assert answers_match(candidate(nums=[100, 102, 104, 105, 107, 109, 110, 112, 114]), [100, 102, 107, 112, 114])\n    assert answers_match(candidate(nums=[1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]), [])\n    assert answers_match(candidate(nums=[3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]), [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42])\n    assert answers_match(candidate(nums=[11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]), [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220])\n    assert answers_match(candidate(nums=[42, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]), [45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99])\n    assert answers_match(candidate(nums=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125]), [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125])\n    assert answers_match(candidate(nums=[1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]), [])\n    assert answers_match(candidate(nums=[2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35]), [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35])\n    assert answers_match(candidate(nums=[10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90]), [])\n    assert answers_match(candidate(nums=[10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]), [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])\n    assert answers_match(candidate(nums=[100000, 100001, 100003, 100005, 100007, 100009, 100011, 100013, 100015, 100017]), [100003, 100005, 100007, 100009, 100011, 100013, 100015, 100017])\n    assert answers_match(candidate(nums=[1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38]), [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38])\n    assert answers_match(candidate(nums=[10, 11, 12, 14, 15, 16, 18, 19, 20, 22, 23, 24, 26, 27, 28]), [])\n    assert answers_match(candidate(nums=[1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51]), [1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51])\n    assert answers_match(candidate(nums=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49])\n    assert answers_match(candidate(nums=[1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77]), [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77])\n    assert answers_match(candidate(nums=[1, 1, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]), [])\n    assert answers_match(candidate(nums=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40])\n    assert answers_match(candidate(nums=[0, 0, 0, 1, 1, 2, 3, 4, 4, 5, 5, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 13, 14, 15, 16]), [])\n    assert answers_match(candidate(nums=[1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58]), [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58])\n    assert answers_match(candidate(nums=[5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]), [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41])\n    assert answers_match(candidate(nums=[5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]), [])\n    assert answers_match(candidate(nums=[500000, 500002, 500004, 500006, 500008, 500010, 500012, 500014, 500016, 500018, 500020]), [500000, 500002, 500004, 500006, 500008, 500010, 500012, 500014, 500016, 500018, 500020])\n    assert answers_match(candidate(nums=[3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]), [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60])\n    assert answers_match(candidate(nums=[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175]), [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175])\n    assert answers_match(candidate(nums=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]), [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384])\n    assert answers_match(candidate(nums=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32])\n    assert answers_match(candidate(nums=[3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]), [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60])\n    assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]), [])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]), [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39])\n    assert answers_match(candidate(nums=[50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78]), [50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78])\n    assert answers_match(candidate(nums=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]), [5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43])\n    assert answers_match(candidate(nums=[1, 2, 2, 2, 3, 4, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 13, 13, 14, 15, 16, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]), [])\n    assert answers_match(candidate(nums=[1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 29, 30, 33, 34]), [])\n    assert answers_match(candidate(nums=[6, 7, 8, 10, 11, 12, 14, 15, 16, 18, 19, 20, 22, 23, 24, 26, 27, 28, 30, 31]), [])\n    assert answers_match(candidate(nums=[1, 2, 3, 6, 7, 8, 11, 12, 13, 16, 17, 18, 21, 22, 23, 26, 27, 28, 31, 32, 33, 36, 37, 38, 41, 42, 43]), [])\n    assert answers_match(candidate(nums=[5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81]), [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81])\n    assert answers_match(candidate(nums=[1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26]), [])\n    assert answers_match(candidate(nums=[2, 4, 7, 9, 11, 13, 16, 18, 20, 22, 25, 27, 29, 31, 34, 36, 38]), [2, 4, 7, 9, 11, 13, 16, 18, 20, 22, 25, 27, 29, 31, 34, 36, 38])\n    assert answers_match(candidate(nums=[1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, 1018, 1020, 1022, 1024]), [1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, 1018, 1020, 1022, 1024])\n    assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]), [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200])\n    assert answers_match(candidate(nums=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40])\n    assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]), [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250])\n    assert answers_match(candidate(nums=[1000000, 999998, 999996, 999994, 999992, 999990, 999988]), [1000000, 999998, 999996, 999994, 999992, 999990, 999988])\n    assert answers_match(candidate(nums=[2, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52]), [2, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52])\n    assert answers_match(candidate(nums=[100000, 100001, 100003, 100005, 100007, 100009, 100011, 100013, 100015, 100017, 100019, 100021, 100023, 100025, 100027, 100029, 100031]), [100003, 100005, 100007, 100009, 100011, 100013, 100015, 100017, 100019, 100021, 100023, 100025, 100027, 100029, 100031])\n    assert answers_match(candidate(nums=[1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29]), [])\n    assert answers_match(candidate(nums=[1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31]), [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31])\n    assert answers_match(candidate(nums=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]), [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200])\n    assert answers_match(candidate(nums=[5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]), [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195])\n    assert answers_match(candidate(nums=[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]), [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140])\n    assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]), [])\n    assert answers_match(candidate(nums=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42]), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42])\n    assert answers_match(candidate(nums=[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]), [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98])\n    assert answers_match(candidate(nums=[1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]), [])\n    assert answers_match(candidate(nums=[1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]), [5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946])\n    assert answers_match(candidate(nums=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39])\n    assert answers_match(candidate(nums=[3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43]), [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43])\n    assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]), [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200])\n    assert answers_match(candidate(nums=[5, 7, 12, 15, 16, 18, 20, 22, 25, 26, 27, 30]), [5, 7, 12, 18, 20, 22, 30])\n    assert answers_match(candidate(nums=[100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138]), [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138])\n    assert answers_match(candidate(nums=[1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 15, 16, 16, 17, 18, 19, 20]), [])\n    assert answers_match(candidate(nums=[1000, 1002, 1003, 1005, 1007, 1008, 1010, 1011, 1013, 1015, 1017, 1019]), [1000, 1005, 1013, 1015, 1017, 1019])\n    assert answers_match(candidate(nums=[1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]), [])\n    assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]), [10, 20, 30, 40, 50, 60, 70, 80, 90, 100])\n    assert answers_match(candidate(nums=[3, 4, 7, 8, 11, 12, 15, 16, 19, 20, 23, 24, 27, 28, 31, 32, 35, 36]), [])\n    assert answers_match(candidate(nums=[1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]), [])\n    assert answers_match(candidate(nums=[2, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63]), [2, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63])\n    assert answers_match(candidate(nums=[1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81]), [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81])\n    assert answers_match(candidate(nums=[15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300]), [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300])\n    assert answers_match(candidate(nums=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]), [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55])\n    assert answers_match(candidate(nums=[100, 101, 103, 104, 106, 108, 110, 111, 113, 115, 117, 119]), [106, 108, 113, 115, 117, 119])\n    assert answers_match(candidate(nums=[2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74]), [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74])\n    assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]), [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150])\n    assert answers_match(candidate(nums=[1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20]), [])\n    assert answers_match(candidate(nums=[4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60]), [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60])\n    assert answers_match(candidate(nums=[42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840]), [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840])\n", "comparison": "unordered"}, "public_tests": ["[10,6,5,8]", "[1,3,5,3]"], "hints": ["For a given element x, how can you quickly check if x - 1 and x + 1 are present in the array without reiterating through the entire array?", "Use a set or a hash map."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findLonely", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:55+00:00", "tests_total": 148, "tests_dropped": 4, "flags": ["any_order"], "topic_tags": ["array", "hash-table", "counting"]}, "language": "python", "interface": {"raw_signature": "def findLonely(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "findLonely", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2151, "task_id": "maximum-good-people-based-on-statements", "difficulty": "Hard", "problem_description": "There are two types of persons:\n\n- The good person: The person who always tells the truth.\n- The bad person: The person who might tell the truth and might lie.\n\nYou are given a 0-indexed 2D integer array statements of size n x n that represents the statements made by n people about each other. More specifically, statements[i][j] could be one of the following:\n\n- 0 which represents a statement made by person i that person j is a bad person.\n- 1 which represents a statement made by person i that person j is a good person.\n- 2 represents that no statement is made by person i about person j.\n\nAdditionally, no person ever makes a statement about themselves. Formally, we have that statements[i][i] = 2 for all 0 <= i < n.\n\nReturn the maximum number of people who can be good based on the statements made by the n people.\n\nExample 1:\n\nInput: statements = [[2,1,2],[1,2,2],[2,0,2]]\nOutput: 2\nExplanation: Each person makes a single statement.\n- Person 0 states that person 1 is good.\n- Person 1 states that person 0 is good.\n- Person 2 states that person 1 is bad.\nLet's take person 2 as the key.\n- Assuming that person 2 is a good person:\n    - Based on the statement made by person 2, person 1 is a bad person.\n    - Now we know for sure that person 1 is bad and person 2 is good.\n    - Based on the statement made by person 1, and since person 1 is bad, they could be:\n        - telling the truth. There will be a contradiction in this case and this assumption is invalid.\n        - lying. In this case, person 0 is also a bad person and lied in their statement.\n    - Following that person 2 is a good person, there will be only one good person in the group.\n- Assuming that person 2 is a bad person:\n    - Based on the statement made by person 2, and since person 2 is bad, they could be:\n        - telling the truth. Following this scenario, person 0 and 1 are both bad as explained before.\n            - Following that person 2 is bad but told the truth, there will be no good persons in the group.\n        - lying. In this case person 1 is a good person.\n            - Since person 1 is a good person, person 0 is also a good person.\n            - Following that person 2 is bad and lied, there will be two good persons in the group.\nWe can see that at most 2 persons are good in the best case, so we return 2.\nNote that there is more than one way to arrive at this conclusion.\n\nExample 2:\n\nInput: statements = [[2,0],[0,2]]\nOutput: 1\nExplanation: Each person makes a single statement.\n- Person 0 states that person 1 is bad.\n- Person 1 states that person 0 is bad.\nLet's take person 0 as the key.\n- Assuming that person 0 is a good person:\n    - Based on the statement made by person 0, person 1 is a bad person and was lying.\n    - Following that person 0 is a good person, there will be only one good person in the group.\n- Assuming that person 0 is a bad person:\n    - Based on the statement made by person 0, and since person 0 is bad, they could be:\n        - telling the truth. Following this scenario, person 0 and 1 are both bad.\n            - Following that person 0 is bad but told the truth, there will be no good persons in the group.\n        - lying. In this case person 1 is a good person.\n            - Following that person 0 is bad and lied, there will be only one good person in the group.\nWe can see that at most, one person is good in the best case, so we return 1.\nNote that there is more than one way to arrive at this conclusion.\n\nConstraints:\n\n- n == statements.length == statements[i].length\n- 2 <= n <= 15\n- statements[i][j] is either 0, 1, or 2.\n- statements[i][i] == 2\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(statements = [[2, 1, 2], [1, 2, 2], [2, 0, 2]]) == 2\n    assert candidate(statements = [[2, 1, 0, 2], [1, 2, 2, 0], [0, 2, 2, 1], [2, 0, 1, 2]]) == 2\n    assert candidate(statements = [[2, 2], [2, 2]]) == 2\n    assert candidate(statements = [[2, 1, 0, 0], [0, 2, 1, 0], [1, 1, 2, 0], [0, 0, 0, 2]]) == 1\n    assert candidate(statements = [[2, 1, 1], [0, 2, 1], [0, 0, 2]]) == 1\n    assert candidate(statements = [[2, 2, 0, 0], [2, 2, 0, 0], [0, 0, 2, 1], [0, 0, 1, 2]]) == 2\n    assert candidate(statements = [[2, 0, 0], [0, 2, 0], [0, 0, 2]]) == 1\n    assert candidate(statements = [[2, 2, 2], [2, 2, 2], [2, 2, 2]]) == 3\n    assert candidate(statements = [[2, 0, 0, 0, 0], [0, 2, 1, 1, 1], [0, 1, 2, 1, 0], [0, 1, 1, 2, 1], [0, 1, 0, 1, 2]]) == 1\n    assert candidate(statements = [[2, 1], [0, 2]]) == 1\n    assert candidate(statements = [[2, 1, 0], [1, 2, 1], [0, 1, 2]]) == 0\n    assert candidate(statements = [[2, 2, 2, 2], [2, 2, 0, 2], [2, 0, 2, 2], [2, 2, 2, 2]]) == 3\n    assert candidate(statements = [[2, 0, 0, 0], [0, 2, 0, 0], [0, 0, 2, 0], [0, 0, 0, 2]]) == 1\n    assert candidate(statements = [[2, 1, 1], [1, 2, 1], [1, 1, 2]]) == 3\n    assert candidate(statements = [[2, 0], [0, 2]]) == 1\n    assert candidate(statements = [[2, 2, 2, 0], [2, 2, 2, 1], [2, 2, 2, 0], [1, 0, 1, 2]]) == 2\n    assert candidate(statements = [[2, 0, 1], [0, 2, 1], [1, 1, 2]]) == 0\n    assert candidate(statements = [[2, 0, 1, 2], [1, 2, 0, 2], [0, 0, 2, 1], [2, 2, 1, 2]]) == 2\n    assert candidate(statements = [[2, 0, 0, 1, 0, 1], [0, 2, 1, 0, 0, 0], [0, 1, 2, 1, 1, 0], [1, 0, 1, 2, 1, 1], [0, 0, 1, 1, 2, 0], [1, 0, 0, 1, 0, 2]]) == 0\n    assert candidate(statements = [[2, 1, 0, 2, 1, 2, 1, 2, 0], [1, 2, 2, 0, 1, 0, 1, 0, 1], [0, 2, 2, 1, 0, 1, 0, 1, 0], [2, 0, 1, 2, 0, 2, 1, 2, 1], [1, 1, 0, 0, 2, 1, 0, 1, 0], [2, 0, 1, 2, 1, 2, 1, 2, 0], [1, 0, 1, 0, 0, 1, 2, 1, 1], [2, 1, 0, 2, 0, 2, 1, 2, 0], [0, 1, 0, 1, 0, 0, 1, 0, 2]]) == 0\n    assert candidate(statements = [[2, 1, 0, 2, 1], [1, 2, 1, 0, 2], [0, 1, 2, 1, 0], [2, 0, 1, 2, 0], [1, 2, 0, 0, 2]]) == 0\n    assert candidate(statements = [[2, 0, 2, 1, 0, 2, 0], [0, 2, 0, 0, 2, 0, 1], [2, 0, 2, 0, 2, 1, 0], [1, 0, 0, 2, 0, 0, 1], [0, 2, 2, 0, 2, 0, 0], [2, 0, 1, 0, 0, 2, 1], [0, 1, 0, 1, 0, 1, 2]]) == 1\n    assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2], [2, 2, 1, 0, 0, 0, 0], [2, 1, 2, 1, 0, 0, 0], [2, 0, 1, 2, 1, 0, 0], [2, 0, 0, 1, 2, 1, 0], [2, 0, 0, 0, 1, 2, 1], [2, 0, 0, 0, 0, 1, 2]]) == 1\n    assert candidate(statements = [[2, 0, 0, 1, 1, 0], [0, 2, 1, 0, 1, 1], [0, 1, 2, 1, 0, 0], [1, 0, 1, 2, 1, 1], [1, 1, 0, 1, 2, 0], [0, 1, 0, 1, 0, 2]]) == 0\n    assert candidate(statements = [[2, 2, 2, 1, 0, 0, 1, 0], [2, 2, 1, 1, 0, 2, 2, 0], [2, 1, 2, 2, 0, 0, 2, 1], [1, 1, 2, 2, 2, 1, 0, 0], [0, 0, 0, 2, 2, 0, 2, 1], [0, 2, 0, 1, 0, 2, 2, 1], [1, 2, 2, 0, 2, 2, 2, 0], [0, 0, 1, 0, 1, 1, 0, 2]]) == 0\n    assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 0, 0, 0, 0, 0, 0, 0, 0], [2, 0, 2, 0, 0, 0, 0, 0, 0, 0], [2, 0, 0, 2, 0, 0, 0, 0, 0, 0], [2, 0, 0, 0, 2, 0, 0, 0, 0, 0], [2, 0, 0, 0, 0, 2, 0, 0, 0, 0], [2, 0, 0, 0, 0, 0, 2, 0, 0, 0], [2, 0, 0, 0, 0, 0, 0, 2, 0, 0], [2, 0, 0, 0, 0, 0, 0, 0, 2, 0], [2, 0, 0, 0, 0, 0, 0, 0, 0, 2]]) == 2\n    assert candidate(statements = [[2, 1, 1, 0, 0], [1, 2, 1, 0, 0], [1, 1, 2, 1, 1], [0, 0, 1, 2, 0], [0, 0, 1, 0, 2]]) == 0\n    assert candidate(statements = [[2, 1, 0, 1, 0], [1, 2, 1, 0, 1], [0, 1, 2, 0, 0], [1, 0, 0, 2, 1], [0, 1, 0, 1, 2]]) == 0\n    assert candidate(statements = [[2, 0, 0, 1, 0, 0], [0, 2, 1, 0, 1, 0], [0, 1, 2, 0, 0, 1], [1, 0, 0, 2, 1, 0], [0, 1, 0, 1, 2, 0], [0, 0, 1, 0, 0, 2]]) == 0\n    assert candidate(statements = [[2, 0, 1, 0, 1, 1, 0, 1, 0], [0, 2, 1, 0, 1, 0, 1, 1, 0], [1, 1, 2, 0, 1, 0, 0, 0, 1], [0, 0, 0, 2, 1, 1, 1, 0, 1], [1, 1, 1, 1, 2, 1, 0, 0, 0], [1, 0, 0, 1, 1, 2, 1, 0, 1], [0, 1, 0, 1, 0, 1, 2, 1, 0], [1, 1, 0, 0, 0, 0, 1, 2, 1], [0, 0, 1, 1, 0, 1, 0, 1, 2]]) == 0\n    assert candidate(statements = [[2, 0, 1, 1, 0, 0, 1, 0, 1, 1], [0, 2, 0, 0, 1, 1, 0, 1, 0, 0], [1, 0, 2, 1, 0, 1, 0, 1, 1, 0], [1, 0, 1, 2, 0, 1, 1, 0, 0, 1], [0, 1, 0, 0, 2, 1, 0, 1, 1, 0], [0, 1, 1, 1, 1, 2, 0, 0, 1, 1], [1, 0, 1, 0, 0, 0, 2, 1, 1, 0], [0, 1, 0, 1, 1, 0, 1, 2, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 2, 0], [1, 0, 0, 1, 0, 1, 0, 1, 0, 2]]) == 0\n    assert candidate(statements = [[2, 1, 0, 0, 0, 0, 0, 0], [1, 2, 1, 0, 0, 0, 0, 0], [0, 1, 2, 1, 0, 0, 0, 0], [0, 0, 1, 2, 1, 0, 0, 0], [0, 0, 0, 1, 2, 1, 0, 0], [0, 0, 0, 0, 1, 2, 1, 0], [0, 0, 0, 0, 0, 1, 2, 1], [0, 0, 0, 0, 0, 0, 1, 2]]) == 0\n    assert candidate(statements = [[2, 2, 1, 0, 2, 0, 2, 1, 0, 1, 2], [2, 2, 0, 1, 2, 0, 2, 0, 1, 0, 2], [1, 0, 2, 2, 0, 1, 2, 1, 2, 0, 1], [0, 1, 2, 2, 1, 0, 2, 0, 1, 2, 0], [2, 2, 0, 1, 2, 0, 2, 0, 1, 0, 2], [0, 0, 1, 0, 0, 2, 2, 0, 0, 1, 1], [2, 2, 2, 0, 2, 2, 2, 0, 2, 0, 2], [1, 0, 1, 0, 0, 0, 0, 2, 1, 0, 1], [0, 1, 2, 1, 1, 0, 2, 1, 2, 0, 0], [1, 0, 0, 2, 0, 1, 0, 0, 0, 2, 1], [2, 2, 1, 0, 2, 1, 2, 1, 0, 1, 2]]) == 1\n    assert candidate(statements = [[2, 0, 1, 1, 0, 1, 0], [0, 2, 0, 0, 1, 0, 1], [1, 0, 2, 0, 0, 1, 0], [1, 0, 0, 2, 1, 0, 1], [0, 1, 0, 1, 2, 1, 0], [1, 0, 1, 0, 1, 2, 1], [0, 1, 0, 1, 0, 1, 2]]) == 0\n    assert candidate(statements = [[2, 2, 2, 0, 1, 0], [2, 2, 0, 1, 0, 1], [2, 0, 2, 1, 1, 0], [0, 1, 1, 2, 2, 2], [1, 0, 1, 2, 2, 0], [0, 1, 0, 2, 0, 2]]) == 0\n    assert candidate(statements = [[2, 0, 1, 0, 1, 1], [0, 2, 0, 0, 0, 0], [1, 0, 2, 1, 1, 0], [0, 0, 1, 2, 0, 1], [1, 0, 1, 0, 2, 1], [1, 0, 0, 1, 1, 2]]) == 1\n    assert candidate(statements = [[2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 2]]) == 1\n    assert candidate(statements = [[2, 1, 0, 2, 1], [1, 2, 1, 2, 0], [0, 1, 2, 0, 2], [2, 2, 0, 2, 1], [1, 0, 2, 1, 2]]) == 0\n    assert candidate(statements = [[2, 0, 0, 0, 0, 0, 0], [0, 2, 1, 1, 1, 1, 0], [0, 1, 2, 1, 0, 0, 1], [0, 1, 1, 2, 1, 0, 1], [0, 1, 0, 1, 2, 1, 0], [0, 1, 0, 0, 1, 2, 1], [0, 0, 1, 1, 0, 1, 2]]) == 1\n    assert candidate(statements = [[2, 2, 2, 0, 0, 0, 0, 0], [2, 2, 0, 2, 0, 0, 0, 0], [2, 0, 2, 0, 2, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 2, 0, 2, 0, 2], [0, 0, 0, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 2, 0, 2]]) == 2\n    assert candidate(statements = [[2, 2, 1, 0, 0], [2, 2, 0, 0, 1], [1, 0, 2, 0, 1], [0, 0, 0, 2, 0], [0, 1, 1, 0, 2]]) == 1\n    assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2], [2, 2, 0, 0, 0, 0, 0], [2, 0, 2, 0, 1, 0, 1], [2, 0, 0, 2, 0, 1, 0], [2, 0, 1, 0, 2, 0, 1], [2, 0, 0, 1, 0, 2, 0], [2, 0, 1, 0, 1, 0, 2]]) == 4\n    assert candidate(statements = [[2, 1, 0, 0, 0, 0, 1], [1, 2, 1, 1, 1, 0, 0], [0, 1, 2, 0, 1, 1, 1], [0, 1, 0, 2, 1, 0, 0], [0, 1, 1, 1, 2, 1, 0], [0, 0, 1, 0, 1, 2, 1], [1, 0, 1, 0, 0, 1, 2]]) == 0\n    assert candidate(statements = [[2, 2, 0, 1, 1, 0], [2, 2, 1, 1, 0, 0], [0, 1, 2, 0, 1, 1], [1, 1, 0, 2, 0, 1], [1, 0, 1, 0, 2, 0], [0, 0, 1, 1, 0, 2]]) == 0\n    assert candidate(statements = [[2, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 2, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 2, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 2, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 2, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]]) == 10\n    assert candidate(statements = [[2, 0, 1, 1, 0, 0], [0, 2, 2, 1, 1, 0], [1, 2, 2, 0, 0, 1], [1, 1, 0, 2, 2, 1], [0, 1, 0, 2, 2, 0], [0, 0, 1, 1, 0, 2]]) == 0\n    assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 0, 0, 1, 1, 0, 0], [2, 0, 2, 1, 2, 0, 1, 1], [2, 0, 1, 2, 0, 1, 0, 1], [2, 1, 2, 0, 2, 0, 1, 0], [2, 1, 0, 1, 0, 2, 1, 0], [2, 0, 1, 0, 1, 1, 2, 1], [2, 0, 1, 1, 0, 0, 1, 2]]) == 1\n    assert candidate(statements = [[2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2]]) == 8\n    assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 12\n    assert candidate(statements = [[2, 2, 2, 2, 1, 0], [2, 2, 2, 1, 0, 2], [2, 2, 2, 1, 2, 1], [2, 1, 1, 2, 0, 1], [1, 0, 2, 0, 2, 2], [0, 2, 1, 1, 2, 2]]) == 4\n    assert candidate(statements = [[2, 1, 0, 0, 0, 0, 0, 0, 0], [1, 2, 1, 1, 1, 1, 1, 1, 1], [0, 1, 2, 0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 0, 0, 0, 0, 0], [0, 1, 0, 0, 2, 0, 0, 0, 0], [0, 1, 0, 0, 0, 2, 0, 0, 0], [0, 1, 0, 0, 0, 0, 2, 0, 0], [0, 1, 0, 0, 0, 0, 0, 2, 0], [0, 1, 0, 0, 0, 0, 0, 0, 2]]) == 0\n    assert candidate(statements = [[2, 2, 1, 0, 0, 0, 0, 0], [2, 2, 0, 1, 0, 0, 0, 0], [1, 0, 2, 0, 1, 0, 0, 0], [0, 1, 0, 2, 0, 1, 0, 0], [0, 0, 1, 0, 2, 0, 1, 0], [0, 0, 0, 1, 0, 2, 0, 1], [0, 0, 0, 0, 1, 0, 2, 0], [0, 0, 0, 0, 0, 1, 0, 2]]) == 0\n    assert candidate(statements = [[2, 1, 1, 0, 1], [1, 2, 0, 1, 0], [1, 0, 2, 0, 1], [0, 1, 0, 2, 1], [1, 0, 1, 1, 2]]) == 0\n    assert candidate(statements = [[2, 1, 1, 1, 0, 1], [1, 2, 0, 0, 1, 0], [1, 0, 2, 1, 0, 0], [1, 0, 1, 2, 1, 0], [0, 1, 0, 1, 2, 1], [1, 0, 0, 0, 1, 2]]) == 0\n    assert candidate(statements = [[2, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 2, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 2, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 2, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0, 2, 0], [0, 0, 0, 0, 1, 0, 0, 1, 0, 2]]) == 2\n    assert candidate(statements = [[2, 2, 2, 2, 0, 0, 0, 0], [2, 2, 2, 2, 0, 0, 0, 0], [2, 2, 2, 2, 0, 0, 0, 0], [2, 2, 2, 2, 0, 0, 0, 0], [0, 0, 0, 0, 2, 2, 2, 2], [0, 0, 0, 0, 2, 2, 2, 2], [0, 0, 0, 0, 2, 2, 2, 2], [0, 0, 0, 0, 2, 2, 2, 2]]) == 4\n    assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 1, 1, 1, 1, 1], [2, 2, 2, 1, 2, 2, 2, 2, 2], [2, 2, 2, 1, 2, 2, 2, 2, 2], [2, 2, 2, 1, 2, 2, 2, 2, 2], [2, 2, 2, 1, 2, 2, 2, 2, 2], [2, 2, 2, 1, 2, 2, 2, 2, 2]]) == 9\n    assert candidate(statements = [[2, 1, 1, 0, 1, 2, 0], [1, 2, 0, 1, 0, 1, 0], [1, 0, 2, 1, 0, 0, 1], [0, 1, 1, 2, 0, 0, 0], [1, 0, 0, 0, 2, 1, 1], [2, 1, 0, 0, 1, 2, 0], [0, 0, 1, 0, 1, 0, 2]]) == 0\n    assert candidate(statements = [[2, 0, 0, 1, 0, 0], [0, 2, 1, 0, 1, 1], [0, 1, 2, 1, 0, 0], [1, 0, 1, 2, 0, 1], [0, 1, 0, 0, 2, 0], [0, 1, 0, 1, 0, 2]]) == 0\n    assert candidate(statements = [[2, 2, 1, 0, 0, 0, 0], [2, 2, 1, 0, 0, 0, 0], [1, 1, 2, 1, 1, 1, 0], [0, 0, 1, 2, 1, 0, 1], [0, 0, 1, 1, 2, 1, 0], [0, 0, 1, 0, 1, 2, 1], [0, 0, 0, 1, 0, 1, 2]]) == 0\n    assert candidate(statements = [[2, 1, 2, 0, 2, 1, 2, 0, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 0, 2, 1, 2, 0, 2, 1], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2], [2, 1, 2, 0, 2, 1, 2, 0, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 0, 2, 1, 2, 0, 2, 1], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2], [2, 1, 2, 0, 2, 1, 2, 0, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]]) == 8\n    assert candidate(statements = [[2, 1, 1, 1, 0, 1, 1, 0], [1, 2, 0, 0, 1, 0, 1, 0], [1, 0, 2, 1, 0, 0, 0, 1], [1, 0, 1, 2, 1, 0, 1, 0], [0, 1, 0, 1, 2, 1, 1, 0], [1, 0, 0, 0, 1, 2, 0, 1], [1, 1, 0, 1, 1, 0, 2, 0], [0, 0, 1, 0, 0, 1, 0, 2]]) == 0\n    assert candidate(statements = [[2, 1, 1, 1, 0, 0], [1, 2, 0, 0, 1, 1], [1, 0, 2, 1, 0, 0], [1, 0, 1, 2, 1, 0], [0, 1, 0, 1, 2, 1], [0, 1, 0, 0, 1, 2]]) == 0\n    assert candidate(statements = [[2, 1, 1, 0, 0, 0, 0, 0, 0], [1, 2, 0, 1, 0, 0, 0, 0, 0], [1, 0, 2, 0, 1, 0, 0, 0, 0], [0, 1, 0, 2, 0, 1, 0, 0, 0], [0, 0, 1, 0, 2, 0, 1, 0, 0], [0, 0, 0, 1, 0, 2, 0, 1, 0], [0, 0, 0, 0, 1, 0, 2, 0, 1], [0, 0, 0, 0, 0, 1, 0, 2, 0], [0, 0, 0, 0, 0, 0, 1, 0, 2]]) == 0\n    assert candidate(statements = [[2, 2, 2, 1, 2, 0, 1, 0], [2, 2, 2, 0, 2, 1, 0, 1], [2, 2, 2, 1, 0, 0, 0, 0], [1, 0, 1, 2, 2, 1, 0, 0], [2, 2, 0, 2, 2, 0, 1, 0], [0, 1, 0, 1, 0, 2, 0, 1], [1, 0, 0, 0, 1, 0, 2, 0], [0, 1, 0, 0, 0, 1, 0, 2]]) == 0\n    assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2], [2, 2, 1, 1, 0, 0, 0], [2, 1, 2, 0, 2, 1, 0], [2, 1, 0, 2, 2, 0, 1], [2, 0, 2, 2, 2, 1, 1], [2, 0, 1, 0, 1, 2, 0], [2, 0, 0, 1, 1, 0, 2]]) == 1\n    assert candidate(statements = [[2, 1, 0, 2, 1, 2], [1, 2, 2, 0, 1, 0], [0, 2, 2, 1, 0, 1], [2, 0, 1, 2, 0, 2], [1, 1, 0, 0, 2, 1], [2, 0, 1, 2, 1, 2]]) == 0\n    assert candidate(statements = [[2, 1, 2, 0, 1, 0, 1, 0, 0], [1, 2, 0, 1, 0, 1, 0, 1, 1], [2, 0, 2, 1, 0, 0, 1, 0, 0], [0, 1, 1, 2, 0, 0, 0, 1, 1], [1, 0, 0, 0, 2, 1, 1, 0, 0], [0, 1, 0, 1, 1, 2, 0, 1, 1], [1, 0, 1, 0, 1, 0, 2, 0, 0], [0, 1, 0, 1, 0, 1, 0, 2, 1], [0, 1, 0, 1, 0, 1, 0, 1, 2]]) == 0\n    assert candidate(statements = [[2, 1, 0, 0, 0, 0, 0, 0], [1, 2, 0, 0, 0, 0, 0, 0], [0, 0, 2, 0, 1, 1, 0, 0], [0, 0, 0, 2, 0, 0, 1, 0], [0, 0, 1, 0, 2, 0, 0, 1], [0, 0, 1, 0, 0, 2, 1, 0], [0, 0, 0, 1, 0, 1, 2, 0], [0, 0, 0, 0, 1, 0, 0, 2]]) == 2\n    assert candidate(statements = [[2, 1, 1, 0, 0, 0, 0, 0, 0], [1, 2, 0, 1, 0, 0, 0, 0, 0], [1, 0, 2, 1, 0, 0, 0, 0, 0], [0, 1, 1, 2, 0, 1, 0, 0, 0], [0, 0, 0, 0, 2, 0, 1, 0, 1], [0, 0, 0, 1, 0, 2, 0, 1, 0], [0, 0, 0, 0, 1, 0, 2, 1, 0], [0, 0, 0, 0, 0, 1, 1, 2, 0], [0, 0, 0, 0, 1, 0, 0, 0, 2]]) == 0\n    assert candidate(statements = [[2, 2, 2, 2, 2, 2, 2], [2, 2, 0, 1, 1, 1, 0], [2, 0, 2, 0, 1, 0, 0], [2, 1, 0, 2, 0, 1, 1], [2, 1, 1, 0, 2, 0, 1], [2, 1, 0, 1, 0, 2, 0], [2, 0, 0, 1, 1, 0, 2]]) == 1\n", "comparison": "exact"}, "public_tests": ["[[2,1,2],[1,2,2],[2,0,2]]", "[[2,0],[0,2]]"], "hints": ["You should test every possible assignment of good and bad people, using a bitmask.", "In each bitmask, if the person i is good, then his statements should be consistent with the bitmask in order for the assignment to be valid.", "If the assignment is valid, count how many people are good and keep track of the maximum."], "metadata": {"canonical_parameter_names": ["statements"], "leetcode_dataset_entry_point": "Solution().maximumGood", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:42:58+00:00", "tests_total": 75, "tests_dropped": 4, "flags": ["has_images"], "topic_tags": ["array", "backtracking", "bit-manipulation", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def maximumGood(self, statements: list[list[int]]) -> int:", "container": "Solution", "callable": "maximumGood", "parameters": [{"name": "statements", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2154, "task_id": "keep-multiplying-found-values-by-two", "difficulty": "Easy", "problem_description": "You are given an array of integers nums. You are also given an integer original which is the first number that needs to be searched for in nums.\n\nYou then do the following steps:\n\n1. If original is found in nums, multiply it by two (i.e., set original = 2 * original).\n2. Otherwise, stop the process.\n3. Repeat this process with the new number as long as you keep finding the number.\n\nReturn the final value of original.\n\nExample 1:\n\nInput: nums = [5,3,6,1,12], original = 3\nOutput: 24\nExplanation:\n- 3 is found in nums. 3 is multiplied by 2 to obtain 6.\n- 6 is found in nums. 6 is multiplied by 2 to obtain 12.\n- 12 is found in nums. 12 is multiplied by 2 to obtain 24.\n- 24 is not found in nums. Thus, 24 is returned.\n\nExample 2:\n\nInput: nums = [2,7,9], original = 4\nOutput: 4\nExplanation:\n- 4 is not found in nums. Thus, 4 is returned.\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 1 <= nums[i], original <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [10, 20, 30, 40, 50],original = 5) == 5\n    assert candidate(nums = [1000, 500, 250, 125, 625],original = 5) == 5\n    assert candidate(nums = [3, 6, 9, 12, 15],original = 3) == 24\n    assert candidate(nums = [1, 2, 4, 8],original = 1) == 16\n    assert candidate(nums = [8, 16, 32, 64, 128],original = 8) == 256\n    assert candidate(nums = [2, 7, 9],original = 4) == 4\n    assert candidate(nums = [1000, 1000, 1000, 1000, 1000],original = 1000) == 2000\n    assert candidate(nums = [1, 3, 5, 7, 9],original = 2) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50],original = 10) == 80\n    assert candidate(nums = [2, 2, 2, 2, 2],original = 2) == 4\n    assert candidate(nums = [8, 16, 32, 64, 128, 256, 512],original = 4) == 4\n    assert candidate(nums = [1000, 500, 250, 125, 62, 31],original = 1) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1],original = 1) == 2\n    assert candidate(nums = [1, 2, 4, 8, 16],original = 1) == 32\n    assert candidate(nums = [4, 8, 16, 32, 64],original = 2) == 2\n    assert candidate(nums = [5, 3, 6, 1, 12],original = 3) == 24\n    assert candidate(nums = [1000, 500, 250, 125],original = 125) == 2000\n    assert candidate(nums = [10, 20, 40, 80, 160],original = 10) == 320\n    assert candidate(nums = [7, 14, 28, 56, 112],original = 7) == 224\n    assert candidate(nums = [1, 3, 5, 7, 9],original = 1) == 2\n    assert candidate(nums = [7, 14, 28, 56, 112, 224, 448],original = 7) == 896\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21],original = 3) == 24\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],original = 10) == 160\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],original = 1) == 2\n    assert candidate(nums = [2, 3, 5, 6, 7, 10, 11, 13, 14, 17, 19, 21, 22, 23, 26, 29, 31],original = 2) == 4\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180],original = 9) == 288\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],original = 2) == 32\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],original = 2) == 2\n    assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80],original = 4) == 128\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],original = 1) == 2\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],original = 1) == 2\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],original = 1) == 2\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],original = 2) == 4\n    assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300],original = 15) == 480\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],original = 10) == 160\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],original = 1) == 1024\n    assert candidate(nums = [4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144],original = 4) == 8\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],original = 1) == 32\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],original = 10) == 320\n    assert candidate(nums = [3, 9, 27, 81, 243, 729],original = 3) == 6\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],original = 1) == 2\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],original = 13) == 208\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],original = 7) == 112\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220],original = 11) == 352\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],original = 10) == 320\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],original = 5) == 80\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],original = 7) == 112\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],original = 1) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],original = 1) == 16\n    assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66],original = 6) == 96\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],original = 1) == 2\n    assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180],original = 6) == 192\n    assert candidate(nums = [13, 26, 52, 104, 208, 416, 832],original = 13) == 1664\n    assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],original = 1) == 2\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],original = 5) == 80\n    assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],original = 15) == 240\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],original = 7) == 224\n    assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],original = 990) == 1980\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260],original = 13) == 416\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],original = 5) == 160\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],original = 9) == 144\n    assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509],original = 500) == 1000\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],original = 7) == 112\n    assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340],original = 17) == 544\n    assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100],original = 4) == 128\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31],original = 2) == 4\n    assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400],original = 1) == 2\n    assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980],original = 980) == 1960\n    assert candidate(nums = [1, 2, 3, 5, 6, 10, 12, 15, 20, 30, 60, 120, 240, 480, 960],original = 1) == 4\n    assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896],original = 7) == 1792\n    assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120],original = 8) == 128\n    assert candidate(nums = [11, 22, 44, 88, 176, 352, 704],original = 11) == 1408\n    assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512],original = 2) == 1024\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],original = 3) == 6\n", "comparison": "exact"}, "public_tests": ["[5,3,6,1,12]\n3", "[2,7,9]\n4"], "hints": ["Repeatedly iterate through the array and check if the current value of original is in the array.", "If original is not found, stop and return its current value.", "Otherwise, multiply original by 2 and repeat the process.", "Use set data structure to check the existence faster."], "metadata": {"canonical_parameter_names": ["nums", "original"], "leetcode_dataset_entry_point": "Solution().findFinalValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:02+00:00", "tests_total": 115, "tests_dropped": 41, "flags": [], "topic_tags": ["array", "hash-table", "sorting", "simulation"]}, "language": "python", "interface": {"raw_signature": "def findFinalValue(self, nums: list[int], original: int) -> int:", "container": "Solution", "callable": "findFinalValue", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "original", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2155, "task_id": "all-divisions-with-the-highest-score-of-a-binary-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed binary array nums of length n. nums can be divided at index i (where 0 <= i <= n) into two arrays (possibly empty) nums_left and nums_right:\n\n- nums_left has all the elements of nums between index 0 and i - 1 (inclusive), while nums_right has all the elements of nums between index i and n - 1 (inclusive).\n- If i == 0, nums_left is empty, while nums_right has all the elements of nums.\n- If i == n, nums_left has all the elements of nums, while nums_right is empty.\n\nThe division score of an index i is the sum of the number of 0's in nums_left and the number of 1's in nums_right.\n\nReturn all distinct indices that have the highest possible division score. You may return the answer in any order.\n\nExample 1:\n\nInput: nums = [0,0,1,0]\nOutput: [2,4]\nExplanation: Division at index\n- 0: nums_left is []. nums_right is [0,0,1,0]. The score is 0 + 1 = 1.\n- 1: nums_left is [0]. nums_right is [0,1,0]. The score is 1 + 1 = 2.\n- 2: nums_left is [0,0]. nums_right is [1,0]. The score is 2 + 1 = 3.\n- 3: nums_left is [0,0,1]. nums_right is [0]. The score is 2 + 0 = 2.\n- 4: nums_left is [0,0,1,0]. nums_right is []. The score is 3 + 0 = 3.\nIndices 2 and 4 both have the highest possible division score 3.\nNote the answer [4,2] would also be accepted.\n\nExample 2:\n\nInput: nums = [0,0,0]\nOutput: [3]\nExplanation: Division at index\n- 0: nums_left is []. nums_right is [0,0,0]. The score is 0 + 0 = 0.\n- 1: nums_left is [0]. nums_right is [0,0]. The score is 1 + 0 = 1.\n- 2: nums_left is [0,0]. nums_right is [0]. The score is 2 + 0 = 2.\n- 3: nums_left is [0,0,0]. nums_right is []. The score is 3 + 0 = 3.\nOnly index 3 has the highest possible division score 3.\n\nExample 3:\n\nInput: nums = [1,1]\nOutput: [0]\nExplanation: Division at index\n- 0: nums_left is []. nums_right is [1,1]. The score is 0 + 2 = 2.\n- 1: nums_left is [1]. nums_right is [1]. The score is 0 + 1 = 1.\n- 2: nums_left is [1,1]. nums_right is []. The score is 0 + 0 = 0.\nOnly index 0 has the highest possible division score 2.\n\nConstraints:\n\n- n == nums.length\n- 1 <= n <= 10^5\n- nums[i] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n    \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n    if isinstance(result, list) and isinstance(expected, list):\n        return sorted(result, key=repr) == sorted(expected, key=repr)\n    return result == expected\n\n\ndef check(candidate):\n    assert answers_match(candidate(nums=[1, 0, 0, 0, 1, 1, 1]), [4])\n    assert answers_match(candidate(nums=[0, 0, 0]), [3])\n    assert answers_match(candidate(nums=[0, 0, 1, 0]), [2, 4])\n    assert answers_match(candidate(nums=[0, 1, 0, 1, 0, 1]), [1, 3, 5])\n    assert answers_match(candidate(nums=[1, 0, 1, 0, 1]), [0, 2, 4])\n    assert answers_match(candidate(nums=[1, 1]), [0])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 0, 0]), [7])\n    assert answers_match(candidate(nums=[0, 1, 0, 1, 0]), [1, 3, 5])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1]), [0])\n    assert answers_match(candidate(nums=[1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]), [6, 16])\n    assert answers_match(candidate(nums=[0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1]), [4, 8])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]), [0, 12, 24])\n    assert answers_match(candidate(nums=[1, 0, 1, 0, 1, 0, 1, 0]), [0, 2, 4, 6, 8])\n    assert answers_match(candidate(nums=[0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]), [1, 5, 9, 13, 17, 21, 25, 29])\n    assert answers_match(candidate(nums=[1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]), [5, 11, 17])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0]), [0, 8, 16, 24])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1]), [6, 18, 30])\n    assert answers_match(candidate(nums=[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29])\n    assert answers_match(candidate(nums=[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]), [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), [0])\n    assert answers_match(candidate(nums=[0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1]), [1])\n    assert answers_match(candidate(nums=[1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]), [0])\n    assert answers_match(candidate(nums=[1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1]), [16])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]), [0])\n    assert answers_match(candidate(nums=[1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]), [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40])\n    assert answers_match(candidate(nums=[1, 0, 0, 1, 0, 0, 1, 1, 0, 0]), [6, 10])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1]), [4])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), [10])\n    assert answers_match(candidate(nums=[0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]), [1, 5, 9, 13, 17])\n    assert answers_match(candidate(nums=[0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]), [3, 17])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]), [22])\n    assert answers_match(candidate(nums=[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]), [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22])\n    assert answers_match(candidate(nums=[0, 0, 0, 1, 1, 1, 0, 0, 0]), [3, 9])\n    assert answers_match(candidate(nums=[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]), [1, 3, 5, 7, 9, 11, 13, 15, 17])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]), [0, 12])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 1, 1, 1, 1, 1]), [5])\n    assert answers_match(candidate(nums=[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]), [0, 2, 4, 6, 8, 10, 12, 14, 16])\n    assert answers_match(candidate(nums=[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]), [2, 6, 10, 14])\n    assert answers_match(candidate(nums=[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]), [1])\n    assert answers_match(candidate(nums=[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0]), [0, 12, 24])\n    assert answers_match(candidate(nums=[0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]), [2])\n    assert answers_match(candidate(nums=[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]), [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 0, 0, 0, 0, 1, 1]), [0, 8])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1]), [4, 12, 20, 28])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), [12])\n    assert answers_match(candidate(nums=[0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1]), [1])\n    assert answers_match(candidate(nums=[0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0]), [3])\n    assert answers_match(candidate(nums=[1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0]), [30])\n    assert answers_match(candidate(nums=[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]), [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68])\n    assert answers_match(candidate(nums=[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]), [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20])\n    assert answers_match(candidate(nums=[1, 0, 1, 0, 1, 0, 1, 0, 1, 0]), [0, 2, 4, 6, 8, 10])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 0, 0, 0, 0, 0]), [0, 10])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]), [0])\n    assert answers_match(candidate(nums=[0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]), [1, 5, 9, 13, 17, 21, 25])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), [30])\n    assert answers_match(candidate(nums=[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]), [2, 6, 10, 14, 18, 22])\n    assert answers_match(candidate(nums=[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), [15])\n    assert answers_match(candidate(nums=[0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]), [38])\n    assert answers_match(candidate(nums=[0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0]), [22])\n    assert answers_match(candidate(nums=[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]), [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]), [4, 12])\n    assert answers_match(candidate(nums=[1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]), [0, 4, 8, 12])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0])\n    assert answers_match(candidate(nums=[0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]), [1])\n    assert answers_match(candidate(nums=[1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0]), [6])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]), [9])\n    assert answers_match(candidate(nums=[0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0]), [2])\n    assert answers_match(candidate(nums=[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]), [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), [20])\n    assert answers_match(candidate(nums=[1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]), [3, 7, 11, 15, 19])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0]), [5, 15])\n    assert answers_match(candidate(nums=[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33])\n    assert answers_match(candidate(nums=[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [15])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]), [8])\n    assert answers_match(candidate(nums=[0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]), [3, 9, 15, 21])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1]), [0, 10])\n    assert answers_match(candidate(nums=[1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]), [0, 4, 8, 12, 16, 20])\n    assert answers_match(candidate(nums=[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25])\n    assert answers_match(candidate(nums=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]), [31])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1]), [0, 8, 10])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0])\n    assert answers_match(candidate(nums=[1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]), [3, 7, 11, 15, 19, 23, 27])\n    assert answers_match(candidate(nums=[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]), [2, 6, 10])\n    assert answers_match(candidate(nums=[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19])\n    assert answers_match(candidate(nums=[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), [27])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]), [0, 16])\n    assert answers_match(candidate(nums=[0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1]), [2])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]), [0, 8, 16])\n    assert answers_match(candidate(nums=[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]), [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32])\n    assert answers_match(candidate(nums=[1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]), [0, 4, 8, 12, 16, 20, 24, 28])\n    assert answers_match(candidate(nums=[1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]), [0, 6, 12])\n    assert answers_match(candidate(nums=[1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1]), [0, 8, 12])\n", "comparison": "unordered"}, "public_tests": ["[0,0,1,0]", "[0,0,0]", "[1,1]"], "hints": ["When you iterate the array, maintain the number of zeros and ones on the left side. Can you quickly calculate the number of ones on the right side?", "The number of ones on the right side equals the number of ones in the whole array minus the number of ones on the left side.", "Alternatively, you can quickly calculate it by using a prefix sum array."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxScoreIndices", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:05+00:00", "tests_total": 98, "tests_dropped": 0, "flags": ["any_order"], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def maxScoreIndices(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "maxScoreIndices", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2156, "task_id": "find-substring-with-given-hash-value", "difficulty": "Hard", "problem_description": "The hash of a 0-indexed string s of length k, given integers p and m, is computed using the following function:\n\n- hash(s, p, m) = (val(s[0]) * p^0 + val(s[1]) * p^1 + ... + val(s[k-1]) * p^{k-1}) mod m.\n\nWhere val(s[i]) represents the index of s[i] in the alphabet from val('a') = 1 to val('z') = 26.\n\nYou are given a string s and the integers power, modulo, k, and hashValue. Return sub, the first substring of s of length k such that hash(sub, power, modulo) == hashValue.\n\nThe test cases will be generated such that an answer always exists.\n\nA substring is a contiguous non-empty sequence of characters within a string.\n\nExample 1:\n\nInput: s = \"leetcode\", power = 7, modulo = 20, k = 2, hashValue = 0\nOutput: \"ee\"\nExplanation: The hash of \"ee\" can be computed to be hash(\"ee\", 7, 20) = (5 * 1 + 5 * 7) mod 20 = 40 mod 20 = 0.\n\"ee\" is the first substring of length 2 with hashValue 0. Hence, we return \"ee\".\n\nExample 2:\n\nInput: s = \"fbxzaad\", power = 31, modulo = 100, k = 3, hashValue = 32\nOutput: \"fbx\"\nExplanation: The hash of \"fbx\" can be computed to be hash(\"fbx\", 31, 100) = (6 * 1 + 2 * 31 + 24 * 31^2) mod 100 = 23132 mod 100 = 32.\nThe hash of \"bxz\" can be computed to be hash(\"bxz\", 31, 100) = (2 * 1 + 24 * 31 + 26 * 31^2) mod 100 = 25732 mod 100 = 32.\n\"fbx\" is the first substring of length 3 with hashValue 32. Hence, we return \"fbx\".\nNote that \"bxz\" also has a hash of 32 but it appears later than \"fbx\".\n\nConstraints:\n\n- 1 <= k <= s.length <= 2 * 10^4\n- 1 <= power, modulo <= 10^9\n- 0 <= hashValue < modulo\n- s consists of lowercase English letters only.\n- The test cases are generated such that an answer always exists.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"abracadabra\",power = 5,modulo = 11,k = 3,hashValue = 4) == \"dab\"\n    assert candidate(s = \"leetcode\",power = 7,modulo = 20,k = 2,hashValue = 0) == \"ee\"\n    assert candidate(s = \"fbxzaad\",power = 31,modulo = 100,k = 3,hashValue = 32) == \"fbx\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",power = 26,modulo = 101,k = 5,hashValue = 53) == \"vwxyz\"\n    assert candidate(s = \"a\",power = 1,modulo = 1,k = 1,hashValue = 0) == \"a\"\n    assert candidate(s = \"zaz\",power = 26,modulo = 29,k = 2,hashValue = 27) == \"az\"\n    assert candidate(s = \"a\",power = 13,modulo = 97,k = 1,hashValue = 1) == \"a\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",power = 13,modulo = 50,k = 5,hashValue = 37) == \"klmno\"\n    assert candidate(s = \"abcde\",power = 2,modulo = 11,k = 3,hashValue = 7) == \"cde\"\n    assert candidate(s = \"a\",power = 5,modulo = 13,k = 1,hashValue = 1) == \"a\"\n    assert candidate(s = \"mmcp\",power = 13,modulo = 457,k = 2,hashValue = 33) == \"cp\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",power = 29,modulo = 101,k = 20,hashValue = 95) == \"zzzzzzzzzzzzzzzzzzzz\"\n    assert candidate(s = \"hellothereeveryone\",power = 37,modulo = 101,k = 6,hashValue = 74) == \"eryone\"\n    assert candidate(s = \"a\",power = 7,modulo = 13,k = 1,hashValue = 1) == \"a\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",power = 11,modulo = 79,k = 20,hashValue = 10) == \"zzzzzzzzzzzzzzzzzzzz\"\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",power = 19,modulo = 83,k = 15,hashValue = 28) == \"abcabcabcabcabc\"\n    assert candidate(s = \"powerrangers\",power = 29,modulo = 97,k = 4,hashValue = 53) == \"gers\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",power = 17,modulo = 53,k = 10,hashValue = 49) == \"qrstuvwxyz\"\n    assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",power = 2,modulo = 13,k = 8,hashValue = 7) == \"bcdefghi\"\n    assert candidate(s = \"thisisjustanexampleofalongsstringwithseveralhashvalues\",power = 3,modulo = 100,k = 4,hashValue = 15) == \"lues\"\n    assert candidate(s = \"mississippiisaverypopularstring\",power = 23,modulo = 107,k = 9,hashValue = 62) == \"larstring\"\n    assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",power = 29,modulo = 999983,k = 9,hashValue = 456789) == \"bcdefghij\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",power = 10,modulo = 10007,k = 10,hashValue = 7007) == \"zzzzzzzzzz\"\n    assert candidate(s = \"abacabadabacaba\",power = 10,modulo = 61,k = 5,hashValue = 31) == \"acaba\"\n    assert candidate(s = \"thisisaverylongstringthatwillbeusedtohashandfindthesubstring\",power = 19,modulo = 1000003,k = 12,hashValue = 876543) == \"thesubstring\"\n    assert candidate(s = \"xyzabcxyz\",power = 17,modulo = 101,k = 4,hashValue = 70) == \"cxyz\"\n    assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\",power = 11,modulo = 997,k = 12,hashValue = 896) == \"erthelazydog\"\n    assert candidate(s = \"banana\",power = 5,modulo = 10007,k = 2,hashValue = 22) == \"na\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",power = 19,modulo = 47,k = 15,hashValue = 29) == \"onmlkjihgfedcba\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzz\",power = 23,modulo = 999983,k = 15,hashValue = 123456) == \"zzzzzzzzzzzzzzz\"\n    assert candidate(s = \"thepowerofhashing\",power = 17,modulo = 10007,k = 9,hashValue = 9999) == \"ofhashing\"\n    assert candidate(s = \"racecarannakayak\",power = 37,modulo = 109,k = 7,hashValue = 87) == \"nakayak\"\n    assert candidate(s = \"abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde\",power = 7,modulo = 13,k = 5,hashValue = 5) == \"eabcd\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",power = 27,modulo = 10007,k = 26,hashValue = 4750) == \"abcdefghijklmnopqrstuvwxyz\"\n    assert candidate(s = \"ababababababababababababababababababababababababab\",power = 23,modulo = 29,k = 7,hashValue = 17) == \"bababab\"\n    assert candidate(s = \"aaaaabbbbbccccdddddeeeeefffffggggghhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\",power = 11,modulo = 100000007,k = 13,hashValue = 111222) == \"mmmnnnnnooooo\"\n    assert candidate(s = \"thisisaverylongstringthatshouldworkwiththehashingfunctioncorrectly\",power = 13,modulo = 107,k = 25,hashValue = 67) == \"ehashingfunctioncorrectly\"\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",power = 97,modulo = 10007,k = 6,hashValue = 10001) == \"cdabcd\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",power = 17,modulo = 89,k = 10,hashValue = 67) == \"qrstuvwxyz\"\n    assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzz\",power = 11,modulo = 97,k = 6,hashValue = 76) == \"xyzzxy\"\n    assert candidate(s = \"abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde\",power = 5,modulo = 17,k = 14,hashValue = 11) == \"abcdeabcdeabcd\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",power = 13,modulo = 101,k = 10,hashValue = 97) == \"qrstuvwxyz\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",power = 13,modulo = 101,k = 10,hashValue = 60) == \"xyzabcdefg\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",power = 23,modulo = 41,k = 7,hashValue = 35) == \"cdefghi\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",power = 5,modulo = 1000,k = 7,hashValue = 500) == \"wxxyyzz\"\n    assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\",power = 41,modulo = 997,k = 12,hashValue = 500) == \"abcdefabcdef\"\n", "comparison": "exact"}, "public_tests": ["\"leetcode\"\n7\n20\n2\n0", "\"fbxzaad\"\n31\n100\n3\n32"], "hints": ["How can we update the hash value efficiently while iterating instead of recalculating it each time?", "Use the rolling hash method."], "metadata": {"canonical_parameter_names": ["s", "power", "modulo", "k", "hashValue"], "leetcode_dataset_entry_point": "Solution().subStrHash", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:07+00:00", "tests_total": 96, "tests_dropped": 50, "flags": [], "topic_tags": ["string", "sliding-window", "rolling-hash", "hash-function"]}, "language": "python", "interface": {"raw_signature": "def subStrHash(self, s: str, power: int, modulo: int, k: int, hashValue: int) -> str:", "container": "Solution", "callable": "subStrHash", "parameters": [{"name": "s", "type": "str"}, {"name": "power", "type": "int"}, {"name": "modulo", "type": "int"}, {"name": "k", "type": "int"}, {"name": "hashValue", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2157, "task_id": "groups-of-strings", "difficulty": "Hard", "problem_description": "You are given a 0-indexed array of strings words. Each string consists of lowercase English letters only. No letter occurs more than once in any string of words.\n\nTwo strings s1 and s2 are said to be connected if the set of letters of s2 can be obtained from the set of letters of s1 by any one of the following operations:\n\n- Adding exactly one letter to the set of the letters of s1.\n- Deleting exactly one letter from the set of the letters of s1.\n- Replacing exactly one letter from the set of the letters of s1 with any letter, including itself.\n\nThe array words can be divided into one or more non-intersecting groups. A string belongs to a group if any one of the following is true:\n\n- It is connected to at least one other string of the group.\n- It is the only string present in the group.\n\nNote that the strings in words should be grouped in such a manner that a string belonging to a group cannot be connected to a string present in any other group. It can be proved that such an arrangement is always unique.\n\nReturn an array ans of size 2 where:\n\n- ans[0] is the maximum number of groups words can be divided into, and\n- ans[1] is the size of the largest group.\n\nExample 1:\n\nInput: words = [\"a\",\"b\",\"ab\",\"cde\"]\nOutput: [2,3]\nExplanation:\n- words[0] can be used to obtain words[1] (by replacing 'a' with 'b'), and words[2] (by adding 'b'). So words[0] is connected to words[1] and words[2].\n- words[1] can be used to obtain words[0] (by replacing 'b' with 'a'), and words[2] (by adding 'a'). So words[1] is connected to words[0] and words[2].\n- words[2] can be used to obtain words[0] (by deleting 'b'), and words[1] (by deleting 'a'). So words[2] is connected to words[0] and words[1].\n- words[3] is not connected to any string in words.\nThus, words can be divided into 2 groups [\"a\",\"b\",\"ab\"] and [\"cde\"]. The size of the largest group is 3.\n\nExample 2:\n\nInput: words = [\"a\",\"ab\",\"abc\"]\nOutput: [1,3]\nExplanation:\n- words[0] is connected to words[1].\n- words[1] is connected to words[0] and words[2].\n- words[2] is connected to words[1].\nSince all strings are connected to each other, they should be grouped together.\nThus, the size of the largest group is 3.\n\nConstraints:\n\n- 1 <= words.length <= 2 * 10^4\n- 1 <= words[i].length <= 26\n- words[i] consists of lowercase English letters only.\n- No letter occurs more than once in words[i].\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(words = ['abc', 'bcd', 'ace', 'bce']) == [1, 4]\n    assert candidate(words = ['abcd', 'ac', 'ab', 'abc', 'a']) == [1, 5]\n    assert candidate(words = ['abcd', 'abce', 'abcf', 'abde', 'acde', 'bcde', 'abcde']) == [1, 7]\n    assert candidate(words = ['a', 'b', 'ab', 'cde']) == [2, 3]\n    assert candidate(words = ['abcd', 'ab', 'cd', 'a', 'b', 'c', 'd']) == [2, 6]\n    assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g']) == [1, 7]\n    assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']) == [9, 1]\n    assert candidate(words = ['a', 'ab', 'abc']) == [1, 3]\n    assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']) == [1, 26]\n    assert candidate(words = ['abc', 'abcd', 'abde', 'acde', 'bcde']) == [1, 5]\n    assert candidate(words = ['abc', 'bcd', 'ace', 'xyz']) == [2, 3]\n    assert candidate(words = ['xyz', 'xy', 'yz', 'xz', 'x', 'y', 'z']) == [1, 7]\n    assert candidate(words = ['abc', 'bcd', 'ace', 'bd', 'abcde']) == [2, 4]\n    assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijl', 'abcdefghijkml', 'abcdefghijkmn', 'abcdefghijkop', 'abcdefghijkmnop', 'abcdefghijkmnopq']) == [5, 30]\n    assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij', 'fghijk', 'ghijkl', 'hijklm', 'ijklmn', 'jklmno', 'klmnop', 'lmnopq', 'mnopqr', 'nopqrs', 'opqrst', 'pqrstu', 'qrstuv', 'rstuvw', 'stuvwx', 'tuvwxy', 'uvwxyz']) == [1, 21]\n    assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij', 'fghijk', 'ghijkl', 'hijklm', 'ijklmn', 'jklmno', 'klmnop', 'lmnopq', 'mnopqr', 'nopqrs', 'opqrst', 'pqrs']) == [2, 15]\n    assert candidate(words = ['abc', 'ab', 'a', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij']) == [1, 10]\n    assert candidate(words = ['pqrst', 'pqrstuvw', 'pqrstu', 'pqrs', 'pqr', 'pq', 'p', 'qrstuv', 'qrstu', 'qrst', 'qrs', 'qr', 'q', 'rstuv', 'rstu', 'rst', 'rs', 'r', 'stuv', 'stu', 'st', 's', 'tuv', 'tu', 't', 'uv', 'u', 'v']) == [2, 27]\n    assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstu']) == [2, 4]\n    assert candidate(words = ['abc', 'abcd', 'ab', 'a', 'bc', 'b', 'c', 'ac', 'd', 'de', 'def', 'defg', 'defgh', 'defghi', 'defghij', 'defghijk', 'defghijkl', 'defghijklm', 'defghijklmn', 'defghijklmno', 'defghijklmnop', 'defghijklmnopq', 'defghijklmnopqr', 'defghijklmnopqrs', 'defghijklmnopqrst', 'defghijklmnopqrstu', 'defghijklmnopqrstuv', 'defghijklmnopqrstuvw', 'defghijklmnopqrstuvwx', 'defghijklmnopqrstuvwxy', 'defghijklmnopqrstuvwxyz']) == [1, 31]\n    assert candidate(words = ['ab', 'ac', 'ad', 'bc', 'bd', 'cd', 'abc', 'abd', 'acd', 'bcd', 'abcd', 'abcde', 'abcf', 'abcdg', 'abde', 'acde', 'bcde', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyz']) == [4, 17]\n    assert candidate(words = ['ab', 'ac', 'ad', 'bc', 'bd', 'cd', 'abcd', 'abef', 'acde', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwx', 'vwxy', 'wxyz']) == [3, 24]\n    assert candidate(words = ['abc', 'abd', 'abe', 'abf', 'abg', 'abh', 'abi', 'abj', 'abk', 'abl', 'abm', 'abn', 'abo', 'abp', 'abq', 'abr', 'abs', 'abt', 'abu', 'abv', 'abw', 'abx', 'aby', 'abz', 'acb', 'adb', 'aeb', 'afb', 'agb', 'ahb', 'aib', 'ajb', 'akb', 'alb', 'amb', 'anb', 'aob', 'apb', 'aqb', 'arb', 'asb', 'atb', 'aub', 'avb', 'awb', 'axb', 'ayb', 'azb']) == [1, 48]\n    assert candidate(words = ['abcd', 'abcf', 'acdf', 'bcdf', 'abcdg', 'abcfg', 'abdfg', 'acdfg', 'bcdfg', 'abcdef', 'abcdfg', 'abcfgh', 'abcdefg', 'abcdefh', 'abcddef', 'abcedef', 'abcfdef', 'abcdefg', 'abcdefh', 'abcdefi', 'abcdefj', 'abcdefk', 'abcdefl', 'abcdefm', 'abcdefn', 'abcdefo', 'abcdefp', 'abcdefq', 'abcdefr', 'abcdefs', 'abcdeft', 'abcdefu', 'abcdefv', 'abcdefw', 'abcdefx', 'abcdefy', 'abcdefz']) == [1, 37]\n    assert candidate(words = ['a', 'b', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh']) == [1, 9]\n    assert candidate(words = ['xyz', 'xy', 'xz', 'yz', 'x', 'y', 'z', 'abc', 'ab', 'ac', 'bc', 'a', 'b', 'c', 'abcd', 'abce', 'abcf', 'abde', 'acde', 'bcde', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmnop']) == [2, 30]\n    assert candidate(words = ['xyz', 'xy', 'yz', 'xz', 'x', 'y', 'z', 'xyw', 'yzw', 'xzw', 'w', 'xyzw']) == [1, 12]\n    assert candidate(words = ['abc', 'ac', 'ab', 'b', 'c', 'bcd', 'bc', 'cd', 'd', 'abcd', 'abdc', 'bacd', 'cabd', 'acbd', 'bcad', 'bcda']) == [1, 16]\n    assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqr', 'abcdefghijklmnopq', 'abcdefghijklmnop', 'abcdefghijklmno']) == [3, 4]\n    assert candidate(words = ['abcdefg', 'abc', 'def', 'ghijkl', 'mnopqr', 'stuv', 'wxyz', 'abcdefghij']) == [8, 1]\n    assert candidate(words = ['xyz', 'xy', 'xz', 'yz', 'a', 'b', 'c', 'abc', 'abcd']) == [3, 4]\n    assert candidate(words = ['abcd', 'abce', 'abcf', 'abde', 'acde', 'bcde', 'abcde', 'abcdf', 'abcef', 'abdef', 'acdef', 'bcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyz']) == [2, 20]\n    assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zabcd', 'efghi', 'jklmn', 'opqrs', 'tuvwx', 'yzabc', 'defgh', 'ijklm', 'nopqr', 'stuvw', 'xyzab', 'cdefg', 'hijkl', 'mnopq', 'rstuv', 'wxyza', 'bcdef', 'ghijk', 'lmnop', 'opqrs', 'tuvwx', 'yzabc']) == [11, 22]\n    assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab', 'cdef', 'ghij', 'klmn', 'opqr', 'stuv', 'wxyz', 'abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab']) == [14, 3]\n    assert candidate(words = ['abcd', 'abcf', 'abdf', 'acdf', 'bcdf', 'abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij', 'fghijk', 'ghijkl', 'hijklm', 'ijklmn', 'jklmno', 'klmnop', 'lmnopq', 'mnopqr', 'nopqrs', 'opqrst', 'pqrstu', 'qrstuv', 'rstuvw', 'stuvwx', 'tuvwxy', 'uvwxy']) == [2, 21]\n    assert candidate(words = ['pqr', 'pq', 'pr', 'qr', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']) == [1, 30]\n    assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvw']) == [1, 4]\n    assert candidate(words = ['abcd', 'abef', 'acgh', 'bcdf', 'cdef', 'efgh', 'efgi', 'efgj', 'efgk', 'efgl', 'efgm', 'efgn', 'efgo', 'efgp', 'efgq', 'efgr', 'efgs', 'efgt', 'efgu', 'efgv', 'efgw', 'efgx', 'efgy', 'efgz']) == [4, 19]\n    assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqr', 'abcdefghijklmnopq', 'abcdefghijklmnop', 'abcdefghijklmno', 'abcdefghijklmn', 'abcdefghijklm', 'abcdefghijkl', 'abcdefghijk', 'abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a']) == [2, 18]\n    assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']) == [1, 26]\n    assert candidate(words = ['abcd', 'abce', 'abcf', 'abde', 'acde', 'bcde', 'abcde', 'abcd', 'abce', 'abcf', 'abde', 'acde', 'bcde', 'abcde']) == [1, 14]\n    assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba']) == [1, 30]\n    assert candidate(words = ['a', 'b', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstvwxy', 'abcdefghijklmnopqrstuvwxyz']) == [3, 24]\n    assert candidate(words = ['abcdef', 'abc', 'def', 'abcd', 'abef', 'acdf', 'bcde', 'abcf', 'abcdg', 'abcde', 'abcdefg']) == [2, 10]\n    assert candidate(words = ['mnop', 'mno', 'mnp', 'mop', 'nop', 'npp', 'ppp', 'pp', 'p', 'z', 'zz', 'zzz', 'zzzz', 'zzzzz', 'zzzzzz', 'zzzzzzz', 'zzzzzzzz', 'zzzzzzzzz', 'zzzzzzzzzz']) == [1, 19]\n    assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abcdefghi', 'jklmnopqr', 'stuvwxyz', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'z', 'abcdefghijkl', 'mnopqrstu', 'vwxyz', 'abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yz']) == [18, 4]\n    assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzab', 'cdefgh', 'ijklmn', 'opqrst', 'uvwxyl', 'zabcde', 'fghijk', 'lmnopq', 'rstuvw', 'xylzab', 'cdefgh', 'ijklmn', 'opqrst', 'vwxyza', 'yzabcd', 'efghij', 'klmnop', 'qrstuv', 'wxylza', 'bcdefg', 'hijklm', 'nopqrs', 'tuvwxy', 'zabcde', 'fghijk', 'lmnopq', 'rstuvw', 'wxylza', 'cdefgh', 'ijklmn', 'opqrst', 'vwxyza', 'yzabcd']) == [15, 9]\n    assert candidate(words = ['xyz', 'xy', 'xz', 'yz', 'x', 'y', 'z', 'xyza', 'xyzb', 'xyzc', 'xyzd', 'xyze', 'xyzf', 'xyzg', 'xyzh', 'xyzi', 'xyzj', 'xyzk', 'xyzl', 'xyzm', 'xyzn', 'xyzo', 'xyzp', 'xyzq', 'xyxr', 'xyxs', 'xyxt', 'xyxu', 'xyxv', 'xyxw', 'xyxx', 'xyxy', 'xyxz']) == [1, 33]\n    assert candidate(words = ['a', 'b', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyz']) == [2, 15]\n    assert candidate(words = ['abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'e', 'f', 'g']) == [1, 13]\n    assert candidate(words = ['abc', 'abd', 'acd', 'bcd', 'abcde', 'bcdef', 'cdefg', 'defgh', 'efghi', 'fghij']) == [2, 6]\n    assert candidate(words = ['abcdef', 'abcdeg', 'abcef', 'bcdef', 'acdef', 'abdef', 'abcdf', 'abcdg', 'abc', 'ab', 'ac', 'ad', 'ae', 'af', 'ag', 'a', 'b', 'c', 'd', 'e', 'f', 'g']) == [2, 14]\n    assert candidate(words = ['ab', 'ac', 'ad', 'ae', 'af', 'ag', 'ah', 'ai', 'aj', 'ak', 'al', 'am', 'an', 'ao', 'ap', 'aq', 'ar', 'as', 'at', 'au', 'av', 'aw', 'ax', 'ay', 'az', 'ba', 'ca', 'da', 'ea', 'fa', 'ga', 'ha', 'ia', 'ja', 'ka', 'la', 'ma', 'na', 'oa', 'pa', 'qa', 'ra', 'sa', 'ta', 'ua', 'va', 'wa', 'xa', 'ya', 'za']) == [1, 50]\n    assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvwxy']) == [1, 25]\n    assert candidate(words = ['abcdef', 'abcde', 'abcef', 'abdef', 'acdef', 'bcdef', 'abcdefg', 'abcdefgh', 'abcdefghi']) == [1, 9]\n    assert candidate(words = ['a', 'b', 'c', 'ab', 'bc', 'ac', 'abc', 'abcd', 'abce', 'abcf', 'abde', 'acde', 'bcde', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmnop', 'abcdefghijklmnopq', 'abcdefghijklmnopqr', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrst', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyz', 'mnopqrstuvwxy', 'mnopqrstuvwx', 'mnopqrstuvw', 'mnopqrstuv', 'mnopqrstu', 'mnopqrst', 'mnopqr', 'mnopq', 'mnop', 'mon', 'mo', 'm', 'nopqrstuvwxyz', 'nopqrstuvwx', 'nopqrstuvw', 'nopqrstuv', 'nopqrstu', 'nopqrst', 'nopqr', 'nopq', 'nop', 'no', 'n', 'opqrstuvwxyz', 'opqrstuvwx', 'opqrstuvw', 'opqrstuv', 'opqrstu', 'opqrst', 'opqr', 'opq', 'op', 'o', 'pqrstuvwxyz', 'pqrstuvwx', 'pqrstuvw', 'pqrstuv', 'pqrstu', 'pqrs', 'pqr', 'pq', 'p']) == [3, 42]\n    assert candidate(words = ['mnopqr', 'mnopqs', 'mnopqt', 'mnoprs', 'mnoprt', 'mnopst', 'mnoqrs', 'mnoqrt', 'mnoqst', 'mnoprs', 'mnoprt', 'mnopst', 'mnoqrt', 'mnoqst', 'mnoprt', 'mnopst', 'mnoqrs', 'mnopqr', 'mnopqs', 'mnopqt', 'mnoprs', 'mnoprt', 'mnopst', 'mnoqrt', 'mnoqst', 'mnoprt', 'mnopst']) == [1, 27]\n    assert candidate(words = ['abcd', 'abce', 'abcf', 'abde', 'acde', 'bcde', 'abcde', 'bcdef', 'acdef', 'abcef', 'abdef', 'acdefg', 'bcdefg', 'cdefgh', 'defghi']) == [1, 15]\n    assert candidate(words = ['xyz', 'xy', 'xz', 'yz', 'x', 'y', 'z', 'xyzu', 'xyvz', 'xywz', 'xyxz', 'xyyz', 'xyzv', 'xyzw', 'xyzz', 'xzu', 'xvz', 'xwz', 'xxz', 'xzz', 'yzu', 'yvz', 'ywz', 'yyz', 'yzv', 'yzw', 'yzz', 'zvu', 'zwv', 'zzv', 'zzw', 'zzz', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwx', 'vwxy', 'wxyz', 'vwxyz', 'vwxyza', 'vwxyzab', 'vwxyzabc', 'vwxyzabcd']) == [1, 84]\n    assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'ab', 'bc', 'cd', 'de', 'ef', 'fg', 'gh', 'hi', 'ij', 'jk', 'kl', 'lm', 'mn', 'no', 'op', 'pq', 'qr', 'rs', 'st', 'tu', 'uv', 'vw', 'wx', 'xy', 'yz']) == [1, 51]\n    assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstu']) == [1, 10]\n    assert candidate(words = ['abc', 'abd', 'acd', 'bcd', 'abcd', 'ab', 'ac', 'ad', 'bc', 'bd', 'cd', 'a', 'b', 'c', 'd']) == [1, 15]\n    assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstu']) == [1, 13]\n    assert candidate(words = ['abc', 'abd', 'acd', 'bcd', 'abcd', 'ab', 'bc', 'cd', 'ac', 'a', 'b', 'c', 'd']) == [1, 13]\n    assert candidate(words = ['pqrst', 'pqsrt', 'pqrst', 'pqrsu', 'pqrs', 'pqrt', 'pqst', 'prst', 'qrst', 'pq', 'qr', 'qs', 'qt', 'pr', 'ps', 'pt', 'rs', 'rt', 'st', 'p', 'q', 'r', 's', 't']) == [2, 15]\n    assert candidate(words = ['abcdefghij', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b']) == [2, 33]\n    assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwx', 'abcdefghijklmnopqrstuvw', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrstuv', 'abcdefghijklmnopqrstu', 'abcdefghijklmnopqrs', 'abcdefghijklmnopqrt', 'abcdefghijklmnopqr', 'abcdefghijklmnopq', 'abcdefghijklmnop', 'abcdefghijklmno', 'abcdefghijklmn', 'abcdefghijklm', 'abcdefghijkl', 'abcdefghijk', 'abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a']) == [3, 20]\n", "comparison": "exact"}, "public_tests": ["[\"a\",\"b\",\"ab\",\"cde\"]", "[\"a\",\"ab\",\"abc\"]"], "hints": ["Can we build a graph from words, where there exists an edge between nodes i and j if words[i] and words[j] are connected?", "The problem now boils down to finding the total number of components and the size of the largest component in the graph.", "How can we use bit masking to reduce the search space while adding edges to node i?"], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().groupStrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:10+00:00", "tests_total": 70, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "hash-table", "string", "bit-manipulation", "union-find"]}, "language": "python", "interface": {"raw_signature": "def groupStrings(self, words: list[str]) -> list[int]:", "container": "Solution", "callable": "groupStrings", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2160, "task_id": "minimum-sum-of-four-digit-number-after-splitting-digits", "difficulty": "Easy", "problem_description": "You are given a positive integer num consisting of exactly four digits. Split num into two new integers new1 and new2 by using the digits found in num. Leading zeros are allowed in new1 and new2, and all the digits found in num must be used.\n\n- For example, given num = 2932, you have the following digits: two 2's, one 9 and one 3. Some of the possible pairs [new1, new2] are [22, 93], [23, 92], [223, 9] and [2, 329].\n\nReturn the minimum possible sum of new1 and new2.\n\nExample 1:\n\nInput: num = 2932\nOutput: 52\nExplanation: Some possible pairs [new1, new2] are [29, 23], [223, 9], etc.\nThe minimum sum can be obtained by the pair [29, 23]: 29 + 23 = 52.\n\nExample 2:\n\nInput: num = 4009\nOutput: 13\nExplanation: Some possible pairs [new1, new2] are [0, 49], [490, 0], etc.\nThe minimum sum can be obtained by the pair [4, 9]: 4 + 9 = 13.\n\nConstraints:\n\n- 1000 <= num <= 9999\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num = 8765) == 125\n    assert candidate(num = 2309) == 32\n    assert candidate(num = 5678) == 125\n    assert candidate(num = 1098) == 27\n    assert candidate(num = 1111) == 22\n    assert candidate(num = 3333) == 66\n    assert candidate(num = 4009) == 13\n    assert candidate(num = 9999) == 198\n    assert candidate(num = 1000) == 1\n    assert candidate(num = 2932) == 52\n    assert candidate(num = 9876) == 147\n    assert candidate(num = 4321) == 37\n    assert candidate(num = 1234) == 37\n    assert candidate(num = 2020) == 4\n    assert candidate(num = 6666) == 132\n    assert candidate(num = 5631) == 51\n    assert candidate(num = 7899) == 168\n    assert candidate(num = 8821) == 46\n    assert candidate(num = 9503) == 44\n    assert candidate(num = 3867) == 105\n    assert candidate(num = 5555) == 110\n    assert candidate(num = 6789) == 147\n    assert candidate(num = 1928) == 47\n    assert candidate(num = 9900) == 18\n    assert candidate(num = 6600) == 12\n    assert candidate(num = 4444) == 88\n    assert candidate(num = 4628) == 74\n    assert candidate(num = 1119) == 30\n    assert candidate(num = 2229) == 51\n    assert candidate(num = 6644) == 92\n    assert candidate(num = 1122) == 24\n    assert candidate(num = 7824) == 75\n    assert candidate(num = 3223) == 46\n    assert candidate(num = 1201) == 13\n    assert candidate(num = 9990) == 108\n    assert candidate(num = 1221) == 24\n    assert candidate(num = 2345) == 59\n    assert candidate(num = 1357) == 52\n    assert candidate(num = 1199) == 38\n    assert candidate(num = 5600) == 11\n    assert candidate(num = 6677) == 134\n    assert candidate(num = 2099) == 38\n    assert candidate(num = 3939) == 78\n    assert candidate(num = 5611) == 31\n    assert candidate(num = 7700) == 14\n    assert candidate(num = 7711) == 34\n    assert candidate(num = 2288) == 56\n    assert candidate(num = 9009) == 18\n    assert candidate(num = 5647) == 103\n    assert candidate(num = 3928) == 67\n    assert candidate(num = 7654) == 103\n    assert candidate(num = 1991) == 38\n    assert candidate(num = 8231) == 41\n    assert candidate(num = 1001) == 2\n    assert candidate(num = 8888) == 176\n    assert candidate(num = 3456) == 81\n    assert candidate(num = 6084) == 54\n    assert candidate(num = 7209) == 36\n    assert candidate(num = 2468) == 74\n    assert candidate(num = 2019) == 21\n    assert candidate(num = 1129) == 31\n    assert candidate(num = 5551) == 70\n    assert candidate(num = 5234) == 59\n    assert candidate(num = 2233) == 46\n    assert candidate(num = 6633) == 72\n    assert candidate(num = 1299) == 48\n    assert candidate(num = 3030) == 6\n    assert candidate(num = 1100) == 2\n    assert candidate(num = 7891) == 97\n    assert candidate(num = 3405) == 39\n    assert candidate(num = 7111) == 28\n    assert candidate(num = 2244) == 48\n    assert candidate(num = 8800) == 16\n    assert candidate(num = 1298) == 47\n    assert candidate(num = 7777) == 154\n    assert candidate(num = 6530) == 41\n    assert candidate(num = 7770) == 84\n    assert candidate(num = 9000) == 9\n    assert candidate(num = 9123) == 42\n    assert candidate(num = 5670) == 63\n    assert candidate(num = 1179) == 36\n    assert candidate(num = 1987) == 97\n    assert candidate(num = 4466) == 92\n", "comparison": "exact"}, "public_tests": ["2932", "4009"], "hints": ["Notice that the most optimal way to obtain the minimum possible sum using 4 digits is by summing up two 2-digit numbers.", "We can use the two smallest digits out of the four as the digits found in the tens place respectively.", "Similarly, we use the final 2 larger digits as the digits found in the ones place."], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().minimumSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:14+00:00", "tests_total": 83, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minimumSum(self, num: int) -> int:", "container": "Solution", "callable": "minimumSum", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2161, "task_id": "partition-array-according-to-given-pivot", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied:\n\n- Every element less than pivot appears before every element greater than pivot.\n- Every element equal to pivot appears in between the elements less than and greater than pivot.\n- The relative order of the elements less than pivot and the elements greater than pivot is maintained.\n  - More formally, consider every p_i, p_j where p_i is the new position of the i^th element and p_j is the new position of the j^th element. If i < j and both elements are smaller (or larger) than pivot, then p_i < p_j.\n\nReturn nums after the rearrangement.\n\nExample 1:\n\nInput: nums = [9,12,5,10,14,3,10], pivot = 10\nOutput: [9,5,3,10,10,12,14]\nExplanation:\nThe elements 9, 5, and 3 are less than the pivot so they are on the left side of the array.\nThe elements 12 and 14 are greater than the pivot so they are on the right side of the array.\nThe relative ordering of the elements less than and greater than pivot is also maintained. [9, 5, 3] and [12, 14] are the respective orderings.\n\nExample 2:\n\nInput: nums = [-3,4,3,2], pivot = 2\nOutput: [-3,2,4,3]\nExplanation:\nThe element -3 is less than the pivot so it is on the left side of the array.\nThe elements 4 and 3 are greater than the pivot so they are on the right side of the array.\nThe relative ordering of the elements less than and greater than pivot is also maintained. [-3] and [4, 3] are the respective orderings.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- -10^6 <= nums[i] <= 10^6\n- pivot equals to an element of nums.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [0, 0, 1, 1, 0, 1, 0, 1, 0, 0],pivot = 0) == [0, 0, 0, 0, 0, 0, 1, 1, 1, 1]\n    assert candidate(nums = [1, 1, 1, 1, 1],pivot = 1) == [1, 1, 1, 1, 1]\n    assert candidate(nums = [0, 0, 1, 1, 0, 1, 0, 1, 0, 0],pivot = 1) == [0, 0, 0, 0, 0, 0, 1, 1, 1, 1]\n    assert candidate(nums = [5, 4, 3, 2, 1],pivot = 3) == [2, 1, 3, 5, 4]\n    assert candidate(nums = [10, 10, 10, 10],pivot = 10) == [10, 10, 10, 10]\n    assert candidate(nums = [5, 5, 5, 5, 5],pivot = 5) == [5, 5, 5, 5, 5]\n    assert candidate(nums = [4, 3, 2, 2, 5, 2, 3],pivot = 2) == [2, 2, 2, 4, 3, 5, 3]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pivot = 5) == [4, 3, 2, 1, 5, 10, 9, 8, 7, 6]\n    assert candidate(nums = [10, 10, 10, 10, 10],pivot = 10) == [10, 10, 10, 10, 10]\n    assert candidate(nums = [10, 9, 8, 7, 6],pivot = 8) == [7, 6, 8, 10, 9]\n    assert candidate(nums = [5, -1, 3, 2, 4, 6, 0],pivot = 4) == [-1, 3, 2, 0, 4, 5, 6]\n    assert candidate(nums = [10, 9, 8, 7, 6],pivot = 7) == [6, 7, 10, 9, 8]\n    assert candidate(nums = [9, 12, 5, 10, 14, 3, 10],pivot = 10) == [9, 5, 3, 10, 10, 12, 14]\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3],pivot = 3) == [3, 3, 3, 3, 3, 3, 3]\n    assert candidate(nums = [5, -10, 4],pivot = 5) == [-10, 4, 5]\n    assert candidate(nums = [-3, 4, 3, 2],pivot = 2) == [-3, 2, 4, 3]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pivot = 5) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [1, 2, 3, 4, 5],pivot = 3) == [1, 2, 3, 4, 5]\n    assert candidate(nums = [1000000, -1000000, 500000, -500000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],pivot = 0) == [-1000000, -500000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000000, 500000]\n    assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],pivot = 0) == [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, 0, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]\n    assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100],pivot = 300) == [100, 200, 200, 100, 300, 300, 400, 500, 400]\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 3, 9, 3, 2, 8, 5, 6, 9, 0],pivot = 5) == [3, 1, 4, 1, 2, 3, 3, 2, 3, 4, 2, 4, 3, 3, 3, 2, 0, 2, 4, 1, 1, 3, 3, 2, 0, 5, 5, 5, 5, 5, 9, 6, 9, 7, 9, 8, 6, 6, 8, 7, 9, 8, 8, 9, 7, 9, 8, 6, 9]\n    assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25],pivot = 13) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 13, 14, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25]\n    assert candidate(nums = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],pivot = 10) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 19, 18, 17, 16, 15, 14, 13, 12, 11]\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],pivot = 10) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],pivot = 3) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pivot = 10) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],pivot = 50) == [10, 20, 30, 40, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 60, 70, 80, 90, 100]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pivot = 5) == [1, 2, 3, 4, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 6, 7, 8, 9, 10]\n    assert candidate(nums = [7, 6, 5, 1, 0, 8, 9, 10, 11, 2, 3, 4],pivot = 5) == [1, 0, 2, 3, 4, 5, 7, 6, 8, 9, 10, 11]\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 10, 20, 30, 40, 60, 70, 80, 90, 100, 50],pivot = 50) == [10, 20, 30, 40, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 60, 70, 80, 90, 100]\n    assert candidate(nums = [3, 6, 3, 8, 8, 6, 1, 2, 1, 2, 6, 8, 3, 6, 8, 3, 6, 3, 6, 8],pivot = 6) == [3, 3, 1, 2, 1, 2, 3, 3, 3, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8]\n    assert candidate(nums = [10, 20, 5, 15, 0, 25, 10, 5, 30, 10],pivot = 10) == [5, 0, 5, 10, 10, 10, 20, 15, 25, 30]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pivot = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],pivot = 0) == [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [7, 5, 3, 8, 2, 9, 1, 4, 6, 0, 11, 12, 13],pivot = 5) == [3, 2, 1, 4, 0, 5, 7, 8, 9, 6, 11, 12, 13]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],pivot = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n    assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500],pivot = 300) == [100, 200, 200, 100, 0, -100, -200, -300, -400, -500, 300, 300, 400, 500, 400]\n    assert candidate(nums = [-1, -2, -3, -4, -5, 0, 5, 4, 3, 2, 1],pivot = 0) == [-1, -2, -3, -4, -5, 0, 5, 4, 3, 2, 1]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pivot = 500) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10],pivot = 10) == [10, 10, 10, 10, 10, 10, 10, 10]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pivot = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pivot = 8) == [7, 6, 5, 4, 3, 2, 1, 8, 15, 14, 13, 12, 11, 10, 9]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],pivot = 5) == [4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 5, 9, 8, 7, 6, 9, 8, 7, 6]\n    assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],pivot = 31250) == [15625, 7812, 3906, 1953, 31250, 1000000, 500000, 250000, 125000, 62500]\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],pivot = 5) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 6, 7, 8, 9]\n    assert candidate(nums = [-10, -20, -30, -40, -50, -40, -30, -20, -10],pivot = -30) == [-40, -50, -40, -30, -30, -10, -20, -20, -10]\n    assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3],pivot = 2) == [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3]\n    assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],pivot = 995) == [994, 993, 992, 991, 995, 1000, 999, 998, 997, 996]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],pivot = 5) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n    assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],pivot = 0) == [-1, -2, -3, -4, -5, 0, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pivot = 8) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],pivot = 0) == [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],pivot = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n    assert candidate(nums = [7, 1, 5, 2, 3, 6, 4, 5, 8, 1, 9, 5, 5, 5],pivot = 5) == [1, 2, 3, 4, 1, 5, 5, 5, 5, 5, 7, 6, 8, 9]\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],pivot = 7) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n    assert candidate(nums = [-10, 100, -50, 50, -20, 20, -30, 30, -40, 40],pivot = 0) == [-10, -50, -20, -30, -40, 100, 50, 20, 30, 40]\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pivot = 15) == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 20, 19, 18, 17, 16]\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5],pivot = 5) == [3, 1, 4, 1, 2, 3, 2, 3, 5, 5, 5, 5, 5, 9, 6, 9, 6]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 5, 5, 5, 5, 4, 3, 2, 1, 0],pivot = 5) == [4, 3, 2, 1, 0, 5, 5, 5, 5, 5, 10, 9, 8, 7, 6]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],pivot = 3) == [2, 1, 0, -1, -2, -3, -4, -5, 3, 10, 9, 8, 7, 6, 5, 4]\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30],pivot = 50) == [40, 30, 20, 10, 0, -10, -20, -30, 50, 100, 90, 80, 70, 60]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pivot = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],pivot = 30) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],pivot = 5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],pivot = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],pivot = 5) == [3, 1, 4, 1, 2, 3, 5, 5, 5, 9, 6]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pivot = 5) == [4, 3, 2, 1, 4, 3, 2, 1, 5, 5, 10, 9, 8, 7, 6, 10, 9, 8, 7, 6]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pivot = 6) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 6, 6, 7, 8, 9, 10, 7, 8, 9, 10, 7, 8, 9, 10]\n    assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10],pivot = 5) == [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7],pivot = 0) == [-1, -2, -3, -4, -5, -6, -7, 0, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pivot = 5) == [1, 2, 3, 4, 4, 3, 2, 1, 5, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],pivot = -5) == [-6, -7, -8, -9, -10, -5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4]\n    assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 11, 13, 15, 17, 19],pivot = 10) == [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 11, 13, 15, 17, 19]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],pivot = 5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],pivot = 25) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pivot = 7) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],pivot = -5) == [-6, -7, -8, -9, -10, -5, -1, -2, -3, -4]\n    assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],pivot = 2) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3]\n    assert candidate(nums = [2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1],pivot = 2) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]\n    assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000, 0, 1000000, -1000000],pivot = 0) == [-1000000, -500000, -250000, -1000000, 0, 1000000, 500000, 250000, 1000000]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 1, 3, 5, 7, 9],pivot = 10) == [1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]\n    assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],pivot = 3) == [1, 2, 1, 2, 1, 2, 1, 2, 3, 3, 3, 3, 4, 5, 4, 5, 4, 5, 4, 5]\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],pivot = -8) == [-9, -10, -11, -12, -13, -14, -15, -8, -1, -2, -3, -4, -5, -6, -7]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pivot = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100],pivot = 500) == [100, 200, 300, 400, 100, 500, 600, 700, 800, 900, 1000]\n    assert candidate(nums = [7, 3, 5, 10, 8, 5, 1, 9, 4, 5],pivot = 5) == [3, 1, 4, 5, 5, 5, 7, 10, 8, 9]\n    assert candidate(nums = [-1000000, -500000, -250000, -125000, -62500, -31250, -15625, -7812, -3906, -1953],pivot = -125000) == [-1000000, -500000, -250000, -125000, -62500, -31250, -15625, -7812, -3906, -1953]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pivot = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],pivot = 5) == [1, 2, 3, 4, 1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9]\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 7],pivot = 21) == [7, 14, 7, 21, 28, 35, 42, 49, 56, 63, 70]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],pivot = 5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n    assert candidate(nums = [1000000, 100000, 10000, 1000, 100, 10, 1, 0, -1, -10, -100, -1000, -10000, -100000, -1000000],pivot = 100) == [10, 1, 0, -1, -10, -100, -1000, -10000, -100000, -1000000, 100, 1000000, 100000, 10000, 1000]\n    assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],pivot = -500) == [-600, -700, -800, -900, -1000, -500, -100, -200, -300, -400]\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],pivot = 10) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n    assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],pivot = 125000) == [62500, 31250, 15625, 7812, 3906, 1953, 125000, 1000000, 500000, 250000]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],pivot = 70) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],pivot = 15) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],pivot = 25) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pivot = 10) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]\n    assert candidate(nums = [3, 8, 2, 4, 5, 7, 9, 1],pivot = 5) == [3, 2, 4, 1, 5, 8, 7, 9]\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000],pivot = 7000) == [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000]\n    assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500],pivot = 300) == [100, 200, 100, 200, 100, 200, 300, 300, 300, 400, 500, 400, 500, 400, 500]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25],pivot = 25) == [5, 10, 15, 20, 5, 10, 15, 20, 25, 25, 30, 35, 40, 45, 50]\n    assert candidate(nums = [5, 3, 1, 2, 4, 1, 5, 3, 2, 4, 1, 5, 3, 2, 4, 1, 5, 3, 2, 4, 1, 5, 3, 2, 4],pivot = 3) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 3, 3, 3, 3, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4]\n", "comparison": "exact"}, "public_tests": ["[9,12,5,10,14,3,10]\n10", "[-3,4,3,2]\n2"], "hints": ["Could you put the elements smaller than the pivot and greater than the pivot in a separate list as in the sequence that they occur?", "With the separate lists generated, could you then generate the result?"], "metadata": {"canonical_parameter_names": ["nums", "pivot"], "leetcode_dataset_entry_point": "Solution().pivotArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:17+00:00", "tests_total": 105, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "two-pointers", "simulation"]}, "language": "python", "interface": {"raw_signature": "def pivotArray(self, nums: list[int], pivot: int) -> list[int]:", "container": "Solution", "callable": "pivotArray", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "pivot", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2162, "task_id": "minimum-cost-to-set-cooking-time", "difficulty": "Medium", "problem_description": "A generic microwave supports cooking times for:\n\n- at least 1 second.\n- at most 99 minutes and 99 seconds.\n\nTo set the cooking time, you push at most four digits. The microwave normalizes what you push as four digits by prepending zeroes. It interprets the first two digits as the minutes and the last two digits as the seconds. It then adds them up as the cooking time. For example,\n\n- You push 9 5 4 (three digits). It is normalized as 0954 and interpreted as 9 minutes and 54 seconds.\n- You push 0 0 0 8 (four digits). It is interpreted as 0 minutes and 8 seconds.\n- You push 8 0 9 0. It is interpreted as 80 minutes and 90 seconds.\n- You push 8 1 3 0. It is interpreted as 81 minutes and 30 seconds.\n\nYou are given integers startAt, moveCost, pushCost, and targetSeconds. Initially, your finger is on the digit startAt. Moving the finger above any specific digit costs moveCost units of fatigue. Pushing the digit below the finger once costs pushCost units of fatigue.\n\nThere can be multiple ways to set the microwave to cook for targetSeconds seconds but you are interested in the way with the minimum cost.\n\nReturn the minimum cost to set targetSeconds seconds of cooking time.\n\nRemember that one minute consists of 60 seconds.\n\nExample 1:\n\nInput: startAt = 1, moveCost = 2, pushCost = 1, targetSeconds = 600\nOutput: 6\nExplanation: The following are the possible ways to set the cooking time.\n- 1 0 0 0, interpreted as 10 minutes and 0 seconds.\n  The finger is already on digit 1, pushes 1 (with cost 1), moves to 0 (with cost 2), pushes 0 (with cost 1), pushes 0 (with cost 1), and pushes 0 (with cost 1).\n  The cost is: 1 + 2 + 1 + 1 + 1 = 6. This is the minimum cost.\n- 0 9 6 0, interpreted as 9 minutes and 60 seconds. That is also 600 seconds.\n  The finger moves to 0 (with cost 2), pushes 0 (with cost 1), moves to 9 (with cost 2), pushes 9 (with cost 1), moves to 6 (with cost 2), pushes 6 (with cost 1), moves to 0 (with cost 2), and pushes 0 (with cost 1).\n  The cost is: 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 = 12.\n- 9 6 0, normalized as 0960 and interpreted as 9 minutes and 60 seconds.\n  The finger moves to 9 (with cost 2), pushes 9 (with cost 1), moves to 6 (with cost 2), pushes 6 (with cost 1), moves to 0 (with cost 2), and pushes 0 (with cost 1).\n  The cost is: 2 + 1 + 2 + 1 + 2 + 1 = 9.\n\nExample 2:\n\nInput: startAt = 0, moveCost = 1, pushCost = 2, targetSeconds = 76\nOutput: 6\nExplanation: The optimal way is to push two digits: 7 6, interpreted as 76 seconds.\nThe finger moves to 7 (with cost 1), pushes 7 (with cost 2), moves to 6 (with cost 1), and pushes 6 (with cost 2). The total cost is: 1 + 2 + 1 + 2 = 6\nNote other possible ways are 0076, 076, 0116, and 116, but none of them produces the minimum cost.\n\nConstraints:\n\n- 0 <= startAt <= 9\n- 1 <= moveCost, pushCost <= 10^5\n- 1 <= targetSeconds <= 6039\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(startAt = 1,moveCost = 2,pushCost = 1,targetSeconds = 600) == 6\n    assert candidate(startAt = 0,moveCost = 1,pushCost = 2,targetSeconds = 76) == 6\n    assert candidate(startAt = 2,moveCost = 2,pushCost = 3,targetSeconds = 599) == 15\n    assert candidate(startAt = 6,moveCost = 3,pushCost = 2,targetSeconds = 3599) == 20\n    assert candidate(startAt = 9,moveCost = 5,pushCost = 10,targetSeconds = 99) == 20\n    assert candidate(startAt = 5,moveCost = 1,pushCost = 1,targetSeconds = 120) == 5\n    assert candidate(startAt = 3,moveCost = 3,pushCost = 2,targetSeconds = 300) == 12\n    assert candidate(startAt = 8,moveCost = 2,pushCost = 1,targetSeconds = 1) == 3\n    assert candidate(startAt = 7,moveCost = 4,pushCost = 5,targetSeconds = 180) == 23\n    assert candidate(startAt = 4,moveCost = 1,pushCost = 1,targetSeconds = 6039) == 5\n    assert candidate(startAt = 7,moveCost = 6,pushCost = 3,targetSeconds = 59) == 18\n    assert candidate(startAt = 8,moveCost = 3,pushCost = 5,targetSeconds = 3001) == 29\n    assert candidate(startAt = 9,moveCost = 2,pushCost = 1,targetSeconds = 1) == 3\n    assert candidate(startAt = 9,moveCost = 1,pushCost = 10,targetSeconds = 6039) == 40\n    assert candidate(startAt = 4,moveCost = 30,pushCost = 20,targetSeconds = 1234) == 170\n    assert candidate(startAt = 0,moveCost = 6,pushCost = 5,targetSeconds = 99) == 16\n    assert candidate(startAt = 6,moveCost = 5,pushCost = 1,targetSeconds = 480) == 13\n    assert candidate(startAt = 0,moveCost = 1,pushCost = 10,targetSeconds = 1000) == 44\n    assert candidate(startAt = 1,moveCost = 8,pushCost = 5,targetSeconds = 1234) == 36\n    assert candidate(startAt = 7,moveCost = 200,pushCost = 150,targetSeconds = 99) == 500\n    assert candidate(startAt = 9,moveCost = 5,pushCost = 2,targetSeconds = 6039) == 8\n    assert candidate(startAt = 8,moveCost = 2,pushCost = 2,targetSeconds = 2039) == 14\n    assert candidate(startAt = 6,moveCost = 2,pushCost = 1,targetSeconds = 99) == 4\n    assert candidate(startAt = 6,moveCost = 1,pushCost = 1,targetSeconds = 59) == 4\n    assert candidate(startAt = 5,moveCost = 15,pushCost = 25,targetSeconds = 2345) == 160\n    assert candidate(startAt = 7,moveCost = 2,pushCost = 1,targetSeconds = 99) == 4\n    assert candidate(startAt = 1,moveCost = 20,pushCost = 5,targetSeconds = 900) == 60\n    assert candidate(startAt = 2,moveCost = 5,pushCost = 3,targetSeconds = 5999) == 27\n    assert candidate(startAt = 9,moveCost = 10,pushCost = 1,targetSeconds = 1234) == 34\n    assert candidate(startAt = 2,moveCost = 1,pushCost = 5,targetSeconds = 240) == 17\n    assert candidate(startAt = 9,moveCost = 5,pushCost = 3,targetSeconds = 6039) == 12\n    assert candidate(startAt = 1,moveCost = 4,pushCost = 4,targetSeconds = 3159) == 28\n    assert candidate(startAt = 4,moveCost = 3,pushCost = 7,targetSeconds = 60) == 20\n    assert candidate(startAt = 8,moveCost = 3,pushCost = 7,targetSeconds = 119) == 30\n    assert candidate(startAt = 0,moveCost = 20,pushCost = 10,targetSeconds = 3600) == 80\n    assert candidate(startAt = 3,moveCost = 2,pushCost = 3,targetSeconds = 3540) == 18\n    assert candidate(startAt = 3,moveCost = 5,pushCost = 3,targetSeconds = 5999) == 27\n    assert candidate(startAt = 6,moveCost = 3,pushCost = 7,targetSeconds = 2900) == 40\n    assert candidate(startAt = 5,moveCost = 5,pushCost = 3,targetSeconds = 5999) == 27\n    assert candidate(startAt = 0,moveCost = 7,pushCost = 2,targetSeconds = 4567) == 36\n    assert candidate(startAt = 9,moveCost = 10,pushCost = 1,targetSeconds = 6039) == 4\n    assert candidate(startAt = 5,moveCost = 7,pushCost = 2,targetSeconds = 5432) == 29\n    assert candidate(startAt = 1,moveCost = 1,pushCost = 10,targetSeconds = 300) == 32\n    assert candidate(startAt = 4,moveCost = 10,pushCost = 1,targetSeconds = 1800) == 24\n    assert candidate(startAt = 8,moveCost = 10,pushCost = 5,targetSeconds = 900) == 50\n    assert candidate(startAt = 5,moveCost = 7,pushCost = 4,targetSeconds = 1234) == 37\n    assert candidate(startAt = 2,moveCost = 15,pushCost = 3,targetSeconds = 480) == 39\n    assert candidate(startAt = 1,moveCost = 100,pushCost = 50,targetSeconds = 120) == 350\n    assert candidate(startAt = 6,moveCost = 50,pushCost = 25,targetSeconds = 1800) == 200\n    assert candidate(startAt = 7,moveCost = 1,pushCost = 2,targetSeconds = 6000) == 11\n    assert candidate(startAt = 3,moveCost = 2,pushCost = 3,targetSeconds = 300) == 13\n    assert candidate(startAt = 2,moveCost = 4,pushCost = 6,targetSeconds = 2345) == 40\n    assert candidate(startAt = 0,moveCost = 1,pushCost = 1000,targetSeconds = 60) == 2002\n    assert candidate(startAt = 4,moveCost = 7,pushCost = 4,targetSeconds = 360) == 26\n    assert candidate(startAt = 5,moveCost = 20,pushCost = 10,targetSeconds = 3540) == 80\n    assert candidate(startAt = 9,moveCost = 7,pushCost = 4,targetSeconds = 5999) == 30\n    assert candidate(startAt = 4,moveCost = 3,pushCost = 4,targetSeconds = 1000) == 28\n    assert candidate(startAt = 1,moveCost = 1,pushCost = 9,targetSeconds = 50) == 20\n    assert candidate(startAt = 6,moveCost = 2,pushCost = 1,targetSeconds = 59) == 6\n    assert candidate(startAt = 9,moveCost = 10,pushCost = 2,targetSeconds = 5959) == 28\n    assert candidate(startAt = 0,moveCost = 2,pushCost = 1,targetSeconds = 120) == 7\n    assert candidate(startAt = 4,moveCost = 2,pushCost = 3,targetSeconds = 60) == 10\n    assert candidate(startAt = 7,moveCost = 4,pushCost = 2,targetSeconds = 60) == 12\n    assert candidate(startAt = 3,moveCost = 2,pushCost = 3,targetSeconds = 4321) == 20\n    assert candidate(startAt = 3,moveCost = 5,pushCost = 3,targetSeconds = 2345) == 27\n    assert candidate(startAt = 8,moveCost = 2,pushCost = 3,targetSeconds = 100) == 15\n    assert candidate(startAt = 7,moveCost = 9,pushCost = 3,targetSeconds = 3598) == 48\n    assert candidate(startAt = 8,moveCost = 7,pushCost = 4,targetSeconds = 1000) == 44\n    assert candidate(startAt = 2,moveCost = 15,pushCost = 3,targetSeconds = 123) == 39\n    assert candidate(startAt = 5,moveCost = 10,pushCost = 5,targetSeconds = 3149) == 40\n    assert candidate(startAt = 1,moveCost = 9,pushCost = 2,targetSeconds = 999) == 26\n    assert candidate(startAt = 8,moveCost = 15,pushCost = 8,targetSeconds = 4321) == 92\n    assert candidate(startAt = 1,moveCost = 1,pushCost = 1,targetSeconds = 359) == 5\n    assert candidate(startAt = 5,moveCost = 1,pushCost = 10,targetSeconds = 3959) == 43\n    assert candidate(startAt = 9,moveCost = 2,pushCost = 4,targetSeconds = 5999) == 20\n    assert candidate(startAt = 2,moveCost = 6,pushCost = 2,targetSeconds = 5678) == 32\n    assert candidate(startAt = 8,moveCost = 3,pushCost = 4,targetSeconds = 6039) == 19\n    assert candidate(startAt = 3,moveCost = 5,pushCost = 3,targetSeconds = 5400) == 22\n    assert candidate(startAt = 6,moveCost = 3,pushCost = 4,targetSeconds = 999) == 25\n    assert candidate(startAt = 3,moveCost = 1,pushCost = 5,targetSeconds = 90) == 12\n    assert candidate(startAt = 0,moveCost = 10,pushCost = 1,targetSeconds = 5999) == 34\n    assert candidate(startAt = 9,moveCost = 1,pushCost = 2,targetSeconds = 123) == 9\n    assert candidate(startAt = 3,moveCost = 4,pushCost = 2,targetSeconds = 300) == 14\n    assert candidate(startAt = 5,moveCost = 7,pushCost = 3,targetSeconds = 1234) == 33\n    assert candidate(startAt = 8,moveCost = 5,pushCost = 3,targetSeconds = 60) == 16\n    assert candidate(startAt = 8,moveCost = 3,pushCost = 2,targetSeconds = 99) == 7\n    assert candidate(startAt = 3,moveCost = 2,pushCost = 3,targetSeconds = 60) == 10\n    assert candidate(startAt = 9,moveCost = 5,pushCost = 10,targetSeconds = 5999) == 50\n    assert candidate(startAt = 8,moveCost = 3,pushCost = 5,targetSeconds = 59) == 16\n    assert candidate(startAt = 2,moveCost = 4,pushCost = 5,targetSeconds = 720) == 32\n    assert candidate(startAt = 4,moveCost = 4,pushCost = 4,targetSeconds = 5432) == 28\n    assert candidate(startAt = 7,moveCost = 7,pushCost = 8,targetSeconds = 1) == 15\n    assert candidate(startAt = 0,moveCost = 5,pushCost = 10,targetSeconds = 360) == 40\n    assert candidate(startAt = 0,moveCost = 7,pushCost = 1,targetSeconds = 5999) == 25\n    assert candidate(startAt = 6,moveCost = 4,pushCost = 6,targetSeconds = 200) == 30\n    assert candidate(startAt = 9,moveCost = 10,pushCost = 1,targetSeconds = 5432) == 34\n    assert candidate(startAt = 2,moveCost = 2,pushCost = 3,targetSeconds = 3600) == 16\n    assert candidate(startAt = 5,moveCost = 10,pushCost = 5,targetSeconds = 3999) == 50\n    assert candidate(startAt = 2,moveCost = 10,pushCost = 5,targetSeconds = 3660) == 50\n    assert candidate(startAt = 0,moveCost = 3,pushCost = 7,targetSeconds = 90) == 20\n    assert candidate(startAt = 3,moveCost = 1,pushCost = 1,targetSeconds = 599) == 6\n    assert candidate(startAt = 7,moveCost = 6,pushCost = 4,targetSeconds = 4567) == 34\n    assert candidate(startAt = 3,moveCost = 20,pushCost = 5,targetSeconds = 300) == 55\n    assert candidate(startAt = 4,moveCost = 6,pushCost = 2,targetSeconds = 900) == 26\n    assert candidate(startAt = 1,moveCost = 5,pushCost = 1,targetSeconds = 540) == 13\n    assert candidate(startAt = 6,moveCost = 15,pushCost = 5,targetSeconds = 999) == 65\n    assert candidate(startAt = 5,moveCost = 1,pushCost = 2,targetSeconds = 480) == 8\n    assert candidate(startAt = 0,moveCost = 3,pushCost = 2,targetSeconds = 120) == 12\n    assert candidate(startAt = 2,moveCost = 1,pushCost = 1,targetSeconds = 99) == 3\n    assert candidate(startAt = 1,moveCost = 6,pushCost = 1,targetSeconds = 59) == 14\n    assert candidate(startAt = 7,moveCost = 2,pushCost = 6,targetSeconds = 1000) == 32\n    assert candidate(startAt = 4,moveCost = 4,pushCost = 3,targetSeconds = 1500) == 24\n    assert candidate(startAt = 0,moveCost = 1,pushCost = 1,targetSeconds = 1234) == 7\n    assert candidate(startAt = 2,moveCost = 20,pushCost = 10,targetSeconds = 1020) == 100\n    assert candidate(startAt = 4,moveCost = 8,pushCost = 2,targetSeconds = 100) == 30\n    assert candidate(startAt = 7,moveCost = 5,pushCost = 2,targetSeconds = 1234) == 23\n", "comparison": "exact"}, "public_tests": ["1\n2\n1\n600", "0\n1\n2\n76"], "hints": ["Define a separate function Cost(mm, ss) where 0 <= mm <= 99 and 0 <= ss <= 99. This function should calculate the cost of setting the cooking time to mm minutes and ss seconds", "The range of the minutes is small (i.e., [0, 99]), how can you use that?", "For every mm in [0, 99], calculate the needed ss to make mm:ss equal to targetSeconds and minimize the cost of setting the cooking time to mm:ss", "Be careful in some cases when ss is not in the valid range [0, 99]."], "metadata": {"canonical_parameter_names": ["startAt", "moveCost", "pushCost", "targetSeconds"], "leetcode_dataset_entry_point": "Solution().minCostSetTime", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:19+00:00", "tests_total": 118, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["math", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def minCostSetTime(self, startAt: int, moveCost: int, pushCost: int, targetSeconds: int) -> int:", "container": "Solution", "callable": "minCostSetTime", "parameters": [{"name": "startAt", "type": "int"}, {"name": "moveCost", "type": "int"}, {"name": "pushCost", "type": "int"}, {"name": "targetSeconds", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2163, "task_id": "minimum-difference-in-sums-after-removal-of-elements", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums consisting of 3 * n elements.\n\nYou are allowed to remove any subsequence of elements of size exactly n from nums. The remaining 2 * n elements will be divided into two equal parts:\n\n- The first n elements belonging to the first part and their sum is sum_first.\n- The next n elements belonging to the second part and their sum is sum_second.\n\nThe difference in sums of the two parts is denoted as sum_first - sum_second.\n\n- For example, if sum_first = 3 and sum_second = 2, their difference is 1.\n- Similarly, if sum_first = 2 and sum_second = 3, their difference is -1.\n\nReturn the minimum difference possible between the sums of the two parts after the removal of n elements.\n\nExample 1:\n\nInput: nums = [3,1,2]\nOutput: -1\nExplanation: Here, nums has 3 elements, so n = 1.\nThus we have to remove 1 element from nums and divide the array into two equal parts.\n- If we remove nums[0] = 3, the array will be [1,2]. The difference in sums of the two parts will be 1 - 2 = -1.\n- If we remove nums[1] = 1, the array will be [3,2]. The difference in sums of the two parts will be 3 - 2 = 1.\n- If we remove nums[2] = 2, the array will be [3,1]. The difference in sums of the two parts will be 3 - 1 = 2.\nThe minimum difference between sums of the two parts is min(-1,1,2) = -1.\n\nExample 2:\n\nInput: nums = [7,9,5,8,1,3]\nOutput: 1\nExplanation: Here n = 2. So we must remove 2 elements and divide the remaining array into two parts containing two elements each.\nIf we remove nums[2] = 5 and nums[3] = 8, the resultant array will be [7,9,1,3]. The difference in sums will be (7+9) - (1+3) = 12.\nTo obtain the minimum difference, we should remove nums[1] = 9 and nums[4] = 1. The resultant array becomes [7,5,8,3]. The difference in sums of the two parts is (7+5) - (8+3) = 1.\nIt can be shown that it is not possible to obtain a difference smaller than 1.\n\nConstraints:\n\n- nums.length == 3 * n\n- 1 <= n <= 10^5\n- 1 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50, 60]) == -80\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == -180\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == -18\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == -36\n    assert candidate(nums = [1, 2, 3, 100, 100, 100]) == -197\n    assert candidate(nums = [1, 2, 3, 4, 5, 6]) == -8\n    assert candidate(nums = [100000, 1, 100000, 1, 100000, 1]) == -99999\n    assert candidate(nums = [3, 1, 2]) == -1\n    assert candidate(nums = [7, 9, 5, 8, 1, 3]) == 1\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 50\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6]) == -147\n    assert candidate(nums = [5, 3, 8, 1, 4, 7, 2, 6, 9]) == -14\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == -18000\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12]) == -20\n    assert candidate(nums = [10, 20, 30, 40, 50, 60]) == -80\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n    assert candidate(nums = [120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 160\n    assert candidate(nums = [2, 1, 3, 2, 1, 3, 2, 1, 3]) == -4\n    assert candidate(nums = [3, 3, 3, 2, 2, 2, 1, 1, 1]) == 3\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == -54\n    assert candidate(nums = [1, 2, 3, 100, 200, 300, 4, 5, 6]) == -594\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n    assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8]) == -12\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == -12\n    assert candidate(nums = [1, 100000, 1, 2, 100000, 2, 3, 100000, 3, 4, 100000, 4]) == -200002\n    assert candidate(nums = [3, 5, 2, 8, 1, 9]) == -12\n    assert candidate(nums = [6, 1, 5, 2, 4, 3]) == -4\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == -100\n    assert candidate(nums = [99999, 99999, 99999, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [3, 2, 1, 6, 5, 4, 9, 8, 7]) == -18\n    assert candidate(nums = [1, 1, 1, 1, 100000, 100000, 100000, 100000, 100000]) == -299997\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]) == 2\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 1, 2, 3]) == 9\n    assert candidate(nums = [100000, 1, 2, 3, 100000, 4, 5, 6, 100000]) == -200000\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == -50\n    assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14]) == -34\n    assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 0\n    assert candidate(nums = [100000, 100000, 100000, 1, 1, 1, 100000, 100000, 100000]) == -299997\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == -1800\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == -3\n    assert candidate(nums = [9, 7, 5, 3, 1, 11, 13, 15, 17, 19, 21, 23]) == -64\n    assert candidate(nums = [100000, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == -99999\n    assert candidate(nums = [200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100]) == -200\n    assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995]) == -199989\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1, 10, 100]) == -110889\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == -32\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10, 12]) == -26\n    assert candidate(nums = [1, 2, 100000, 3, 100000, 4, 5, 100000, 6]) == -200000\n    assert candidate(nums = [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == -199998\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == -1800\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1, 10, 100, 1000, 10000, 100000]) == -218889\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 2, 4, 6]) == -18\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == -16\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == -36\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27]) == -162\n    assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5]) == -199994\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == -3200\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == -180\n    assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100]) == -200\n    assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88]) == 16\n    assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1, 5, 3, 8]) == -13\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == -50\n    assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == -30\n    assert candidate(nums = [30000, 20000, 10000, 50000, 40000, 60000, 90000, 80000, 70000]) == -180000\n    assert candidate(nums = [1, 1, 1, 100000, 100000, 100000, 1, 1, 1]) == -299997\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 100000, 100000, 100000]) == -299997\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 100000, 100000, 100000]) == -299997\n    assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95]) == -284\n    assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == -300\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == -320\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == -360\n    assert candidate(nums = [99999, 99998, 99997, 1, 2, 3, 4, 5, 6]) == -9\n    assert candidate(nums = [1, 2, 3, 100000, 100000, 100000]) == -199997\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992]) == 9\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == -16\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1]) == -2\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == -10\n    assert candidate(nums = [12345, 67890, 54321, 98765, 43210, 87654, 32109, 76543, 21098]) == -128406\n    assert candidate(nums = [9, 3, 6, 3, 9, 3, 6, 3, 9, 3, 6, 3, 9, 3, 6, 3, 9, 3, 6, 3, 9, 3, 6, 3]) == -21\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 1, 2, 3, 4, 5, 6]) == 199976\n    assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1]) == -10\n    assert candidate(nums = [50, 50, 50, 1, 1, 1, 100, 100, 100]) == -297\n    assert candidate(nums = [50, 25, 100, 75, 150, 125, 200, 175, 225]) == -450\n    assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == -199998\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == -20\n    assert candidate(nums = [50000, 40000, 30000, 20000, 10000, 90000, 80000, 70000, 60000]) == -180000\n    assert candidate(nums = [5, 4, 3, 2, 1, 9, 8, 7, 6]) == -18\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == -72\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20]) == 90\n    assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995]) == -199989\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == -18\n    assert candidate(nums = [7, 3, 5, 1, 9, 4, 6, 8, 2, 10, 12, 11]) == -28\n    assert candidate(nums = [1, 3, 5, 2, 4, 6]) == -7\n    assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8]) == -15\n    assert candidate(nums = [3, 1, 2, 5, 4, 6, 9, 7, 8]) == -18\n    assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6]) == -12\n    assert candidate(nums = [100000, 100000, 1, 1, 100000, 100000, 1, 1, 100000]) == -199998\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n    assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995]) == -299984\n    assert candidate(nums = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6]) == -1497\n    assert candidate(nums = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18]) == -36\n    assert candidate(nums = [6, 2, 8, 4, 10, 12, 1, 3, 5, 7, 9, 11]) == -22\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 1, 2, 3]) == -900\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n", "comparison": "exact"}, "public_tests": ["[3,1,2]", "[7,9,5,8,1,3]"], "hints": ["The lowest possible difference can be obtained when the sum of the first n elements in the resultant array is minimum, and the sum of the next n elements is maximum.", "For every index i, think about how you can find the minimum possible sum of n elements with indices lesser or equal to i, if possible.", "Similarly, for every index i, try to find the maximum possible sum of n elements with indices greater or equal to i, if possible.", "Now for all indices, check if we can consider it as the partitioning index and hence find the answer."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:22+00:00", "tests_total": 117, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "dynamic-programming", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def minimumDifference(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minimumDifference", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2164, "task_id": "sort-even-and-odd-indices-independently", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums. Rearrange the values of nums according to the following rules:\n\n1. Sort the values at odd indices of nums in non-increasing order.\n  - For example, if nums = [4,1,2,3] before this step, it becomes [4,3,2,1] after. The values at odd indices 1 and 3 are sorted in non-increasing order.\n2. Sort the values at even indices of nums in non-decreasing order.\n  - For example, if nums = [4,1,2,3] before this step, it becomes [2,1,4,3] after. The values at even indices 0 and 2 are sorted in non-decreasing order.\n\nReturn the array formed after rearranging the values of nums.\n\nExample 1:\n\nInput: nums = [4,1,2,3]\nOutput: [2,3,4,1]\nExplanation:\nFirst, we sort the values present at odd indices (1 and 3) in non-increasing order.\nSo, nums changes from [4,1,2,3] to [4,3,2,1].\nNext, we sort the values present at even indices (0 and 2) in non-decreasing order.\nSo, nums changes from [4,1,2,3] to [2,3,4,1].\nThus, the array formed after rearranging the values is [2,3,4,1].\n\nExample 2:\n\nInput: nums = [2,1]\nOutput: [2,1]\nExplanation:\nSince there is exactly one odd index and one even index, no rearrangement of values takes place.\nThe resultant array formed is [2,1], which is the same as the initial array.\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 1 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1]) == [1]\n    assert candidate(nums = [100, 99, 98, 97, 96, 95]) == [96, 99, 98, 97, 100, 95]\n    assert candidate(nums = [1, 3, 2, 2, 3, 1]) == [1, 3, 2, 2, 3, 1]\n    assert candidate(nums = [1, 9, 3, 7, 5, 6, 2, 8, 4]) == [1, 9, 2, 8, 3, 7, 4, 6, 5]\n    assert candidate(nums = [5, 3, 2, 4, 1, 6]) == [1, 6, 2, 4, 5, 3]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70]) == [10, 60, 30, 40, 50, 20, 70]\n    assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5]) == [1, 9, 2, 8, 3, 7, 4, 6, 5]\n    assert candidate(nums = [10, 20, 30, 40, 50]) == [10, 40, 30, 20, 50]\n    assert candidate(nums = [4, 1, 2, 3]) == [2, 3, 4, 1]\n    assert candidate(nums = [5, 3, 2, 8, 1, 4]) == [1, 8, 2, 4, 5, 3]\n    assert candidate(nums = [2, 1]) == [2, 1]\n    assert candidate(nums = [5, 6, 3, 4, 7]) == [3, 6, 5, 4, 7]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 9, 4, 7, 6, 5, 8, 3, 10, 1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 10, 3, 8, 5, 6, 7, 4, 9, 2]\n    assert candidate(nums = [1, 9, 3, 7, 5, 11, 2, 8, 4, 6, 10, 12, 14, 13, 15]) == [1, 13, 2, 12, 3, 11, 4, 9, 5, 8, 10, 7, 14, 6, 15]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == [2, 19, 4, 17, 6, 15, 8, 13, 10, 11, 12, 9, 14, 7, 16, 5, 18, 3, 20, 1]\n    assert candidate(nums = [7, 5, 9, 3, 8, 6, 10, 2, 4]) == [4, 6, 7, 5, 8, 3, 9, 2, 10]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == [1, 20, 3, 18, 5, 16, 7, 14, 9, 12, 11, 10, 13, 8, 15, 6, 17, 4, 19, 2, 21]\n    assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 15, 2, 13, 3, 11, 4, 9, 5, 7, 6, 6, 7, 5, 8, 4, 10, 3, 12, 2, 14, 1]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [1, 31, 5, 27, 9, 23, 13, 19, 17, 15, 21, 11, 25, 7, 29, 3]\n    assert candidate(nums = [9, 7, 5, 3, 1, 8, 6, 4, 2]) == [1, 8, 2, 7, 5, 4, 6, 3, 9]\n    assert candidate(nums = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 15, 4, 13, 6, 11, 8, 9, 10, 7, 12, 5, 14, 3, 16, 1]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == [1, 11, 2, 10, 3, 9, 4, 8, 5, 7, 6, 6, 7, 5, 8, 4, 9, 3, 10, 2, 11, 1]\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [2, 9, 3, 6, 4, 3, 5, 1, 5, 1, 5]\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 19, 4, 17, 6, 15, 8, 13, 10, 11, 12, 9, 14, 7, 16, 5, 18, 3, 20, 1]\n    assert candidate(nums = [50, 40, 30, 20, 10, 5, 45, 35, 25, 15, 55, 45, 35, 25, 15, 5, 65, 55, 45, 35, 25, 15, 5]) == [5, 55, 10, 45, 15, 40, 25, 35, 25, 35, 30, 25, 35, 20, 45, 15, 45, 15, 50, 5, 55, 5, 65]\n    assert candidate(nums = [64, 34, 25, 12, 22, 11, 90]) == [22, 34, 25, 12, 64, 11, 90]\n    assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95]) == [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95]\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 14, 3, 12, 5, 10, 7, 8, 9, 6, 11, 4, 13, 2, 15]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [34, 23, 12, 45, 56, 78, 89, 90, 100, 11, 22, 33]) == [12, 90, 22, 78, 34, 45, 56, 33, 89, 23, 100, 11]\n    assert candidate(nums = [15, 10, 25, 20, 35, 30, 45, 40, 55, 50, 65, 60]) == [15, 60, 25, 50, 35, 40, 45, 30, 55, 20, 65, 10]\n    assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]\n    assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10]) == [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == [1, 59, 5, 55, 9, 51, 13, 47, 17, 43, 21, 39, 25, 35, 29, 31, 33, 27, 37, 23, 41, 19, 45, 15, 49, 11, 53, 7, 57, 3]\n    assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 14, 3, 12, 5, 10, 7, 8, 9, 6, 11, 4, 13, 2, 15]\n    assert candidate(nums = [42, 84, 21, 63, 42, 84, 21, 63, 42, 84, 21, 63]) == [21, 84, 21, 84, 21, 84, 42, 63, 42, 63, 42, 63]\n    assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 20, 3, 18, 5, 16, 7, 14, 9, 12, 11, 10, 13, 8, 15, 6, 17, 4, 19, 2]\n    assert candidate(nums = [34, 78, 23, 67, 89, 45, 12, 90, 100, 56, 34, 23, 56, 78, 90, 12]) == [12, 90, 23, 78, 34, 78, 34, 67, 56, 56, 89, 45, 90, 23, 100, 12]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 14, 3, 12, 5, 10, 7, 8, 9, 6, 11, 4, 13, 2, 15]\n    assert candidate(nums = [33, 1, 66, 2, 99, 3, 44, 4, 77, 5, 88, 6, 11, 7, 22, 8, 55, 9, 33, 10]) == [11, 10, 22, 9, 33, 8, 33, 7, 44, 6, 55, 5, 66, 4, 77, 3, 88, 2, 99, 1]\n    assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5]) == [96, 5, 97, 4, 98, 3, 99, 2, 100, 1]\n    assert candidate(nums = [7, 11, 5, 15, 3, 19, 1, 23, 9, 29, 6, 33, 2, 37, 8, 41]) == [1, 41, 2, 37, 3, 33, 5, 29, 6, 23, 7, 19, 8, 15, 9, 11]\n    assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [3, 29, 7, 25, 11, 21, 15, 17, 19, 13, 23, 9, 27, 5, 31, 1]\n    assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [21, 30, 23, 28, 25, 26, 27, 24, 29, 22, 31]\n    assert candidate(nums = [25, 20, 15, 10, 5, 30, 25, 20, 15, 10, 5, 35, 30, 25, 20, 15, 10, 5, 40, 35, 30, 25, 20, 15, 10, 5]) == [5, 35, 5, 35, 10, 30, 10, 25, 15, 25, 15, 20, 20, 20, 20, 15, 25, 15, 25, 10, 30, 10, 30, 5, 40, 5]\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n    assert candidate(nums = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94, 6, 93, 7, 92, 8, 91, 9, 90, 10]) == [90, 10, 91, 9, 92, 8, 93, 7, 94, 6, 95, 5, 96, 4, 97, 3, 98, 2, 99, 1]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [1, 27, 5, 23, 9, 19, 13, 15, 17, 11, 21, 7, 25, 3, 29]\n    assert candidate(nums = [8, 1, 6, 3, 4, 5, 2, 7, 10, 9, 12, 11, 14, 13, 16, 15]) == [2, 15, 4, 13, 6, 11, 8, 9, 10, 7, 12, 5, 14, 3, 16, 1]\n    assert candidate(nums = [23, 18, 34, 15, 29, 10, 40, 25, 39, 20, 22, 35, 41, 5, 38]) == [22, 35, 23, 25, 29, 20, 34, 18, 38, 15, 39, 10, 40, 5, 41]\n    assert candidate(nums = [5, 1, 9, 3, 7, 5, 3, 2, 6, 8, 4, 10, 12, 11]) == [3, 11, 4, 10, 5, 8, 6, 5, 7, 3, 9, 2, 12, 1]\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == [90, 99, 92, 97, 94, 95, 96, 93, 98, 91, 100]\n    assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10]) == [91, 10, 92, 9, 93, 8, 94, 7, 95, 6, 96, 5, 97, 4, 98, 3, 99, 2, 100, 1]\n    assert candidate(nums = [45, 67, 23, 89, 12, 34, 56, 78, 90]) == [12, 89, 23, 78, 45, 67, 56, 34, 90]\n    assert candidate(nums = [8, 1, 6, 3, 5, 7, 4, 9, 2]) == [2, 9, 4, 7, 5, 3, 6, 1, 8]\n    assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 5, 5]) == [1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 5, 5]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 20, 3, 18, 5, 16, 7, 14, 9, 12, 11, 10, 13, 8, 15, 6, 17, 4, 19, 2]\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n    assert candidate(nums = [50, 51, 49, 52, 48, 53, 47, 54, 46, 55, 45, 56, 44, 57, 43, 58]) == [43, 58, 44, 57, 45, 56, 46, 55, 47, 54, 48, 53, 49, 52, 50, 51]\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n    assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == [1, 15, 2, 13, 4, 11, 6, 9, 8, 7, 10, 5, 12, 3, 14]\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89]) == [90, 99, 92, 97, 94, 95, 96, 93, 98, 91, 100, 89]\n    assert candidate(nums = [55, 22, 66, 33, 77, 44, 88, 55, 99, 66, 11, 77, 33, 44, 22, 88]) == [11, 88, 22, 77, 33, 66, 55, 55, 66, 44, 77, 44, 88, 33, 99, 22]\n    assert candidate(nums = [50, 10, 40, 20, 30, 30, 20, 40, 10, 50]) == [10, 50, 20, 40, 30, 30, 40, 20, 50, 10]\n    assert candidate(nums = [1, 9, 3, 7, 5, 11, 2, 8, 6, 4, 10]) == [1, 11, 2, 9, 3, 8, 5, 7, 6, 4, 10]\n    assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 29, 4, 27, 6, 25, 8, 23, 10, 21, 12, 19, 14, 17, 16, 15, 18, 13, 20, 11, 22, 9, 24, 7, 26, 5, 28, 3, 30, 1]\n    assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16]) == [1, 20, 3, 18, 5, 16, 7, 14, 9, 12, 11, 10, 13, 8, 15, 6, 17, 4, 19, 2]\n    assert candidate(nums = [8, 2, 4, 6, 10, 1, 9, 3, 7, 5, 11, 13, 15, 17, 19, 21]) == [4, 21, 7, 17, 8, 13, 9, 6, 10, 5, 11, 3, 15, 2, 19, 1]\n    assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6]) == [95, 6, 96, 5, 97, 4, 98, 3, 99, 2, 100, 1]\n    assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95]) == [95, 5, 96, 4, 97, 3, 98, 2, 99, 1, 100]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == [2, 40, 6, 36, 10, 32, 14, 28, 18, 24, 22, 20, 26, 16, 30, 12, 34, 8, 38, 4]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n    assert candidate(nums = [50, 25, 45, 15, 35, 5, 20, 10, 30, 40]) == [20, 40, 30, 25, 35, 15, 45, 10, 50, 5]\n    assert candidate(nums = [7, 5, 3, 1, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14]) == [2, 15, 3, 12, 6, 11, 7, 8, 9, 5, 10, 4, 13, 1, 14]\n    assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == [1, 10, 4, 7, 5, 6, 8, 3, 9, 2]\n    assert candidate(nums = [45, 32, 21, 18, 30, 29, 20, 19, 25, 15, 35, 10, 40, 5, 50, 1]) == [20, 32, 21, 29, 25, 19, 30, 18, 35, 15, 40, 10, 45, 5, 50, 1]\n    assert candidate(nums = [34, 78, 12, 56, 90, 32, 45, 89, 23, 67, 54, 10, 76, 9, 5, 11]) == [5, 89, 12, 78, 23, 67, 34, 56, 45, 32, 54, 11, 76, 10, 90, 9]\n    assert candidate(nums = [5, 1, 9, 3, 7, 5, 11, 7, 13, 9, 15, 11, 17, 13, 19, 15, 21, 17, 23, 19, 25, 21, 27, 23, 29, 25, 31, 27, 33, 29, 35]) == [5, 29, 7, 27, 9, 25, 11, 23, 13, 21, 15, 19, 17, 17, 19, 15, 21, 13, 23, 11, 25, 9, 27, 7, 29, 5, 31, 3, 33, 1, 35]\n    assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10]) == [1, 10, 3, 8, 5, 6, 7, 4, 9, 2]\n    assert candidate(nums = [42, 24, 31, 29, 48, 17, 11, 35, 22, 44, 55, 50, 47, 60, 53, 58, 65, 62, 63, 68, 70, 72, 71, 80, 79, 78, 77, 76, 75, 74, 73]) == [11, 80, 22, 78, 31, 76, 42, 74, 47, 72, 48, 68, 53, 62, 55, 60, 63, 58, 65, 50, 70, 44, 71, 35, 73, 29, 75, 24, 77, 17, 79]\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n    assert candidate(nums = [40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [4, 38, 8, 34, 12, 30, 16, 26, 20, 22, 24, 18, 28, 14, 32, 10, 36, 6, 40, 2]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [1, 16, 3, 14, 5, 12, 7, 10, 9, 8, 11, 6, 13, 4, 15, 2]\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n    assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10]) == [1, 11, 2, 9, 4, 7, 6, 5, 8, 3, 10]\n    assert candidate(nums = [5, 9, 1, 8, 3, 7, 2, 6, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 30, 2, 28, 3, 26, 4, 24, 5, 22, 11, 20, 13, 18, 15, 16, 17, 14, 19, 12, 21, 10, 23, 9, 25, 8, 27, 7, 29, 6]\n", "comparison": "exact"}, "public_tests": ["[4,1,2,3]", "[2,1]"], "hints": ["Try to separate the elements at odd indices from the elements at even indices.", "Sort the two groups of elements individually.", "Combine them to form the resultant array."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sortEvenOdd", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:24+00:00", "tests_total": 107, "tests_dropped": 20, "flags": [], "topic_tags": ["array", "sorting"]}, "language": "python", "interface": {"raw_signature": "def sortEvenOdd(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "sortEvenOdd", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2165, "task_id": "smallest-value-of-the-rearranged-number", "difficulty": "Medium", "problem_description": "You are given an integer num. Rearrange the digits of num such that its value is minimized and it does not contain any leading zeros.\n\nReturn the rearranged number with minimal value.\n\nNote that the sign of the number does not change after rearranging the digits.\n\nExample 1:\n\nInput: num = 310\nOutput: 103\nExplanation: The possible arrangements for the digits of 310 are 013, 031, 103, 130, 301, 310.\nThe arrangement with the smallest value that does not contain any leading zeros is 103.\n\nExample 2:\n\nInput: num = -7605\nOutput: -7650\nExplanation: Some possible arrangements for the digits of -7605 are -7650, -6705, -5076, -0567.\nThe arrangement with the smallest value that does not contain any leading zeros is -7650.\n\nConstraints:\n\n- -10^15 <= num <= 10^15\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num = 2020) == 2002\n    assert candidate(num = 10) == 10\n    assert candidate(num = -10000000000) == -10000000000\n    assert candidate(num = 10000000000) == 10000000000\n    assert candidate(num = 10001) == 10001\n    assert candidate(num = 123456789) == 123456789\n    assert candidate(num = 9876543210) == 1023456789\n    assert candidate(num = 310) == 103\n    assert candidate(num = 1000) == 1000\n    assert candidate(num = -10001) == -11000\n    assert candidate(num = -9876543210) == -9876543210\n    assert candidate(num = 1001) == 1001\n    assert candidate(num = 987654321) == 123456789\n    assert candidate(num = -100) == -100\n    assert candidate(num = 0) == 0\n    assert candidate(num = -7605) == -7650\n    assert candidate(num = -1001) == -1100\n    assert candidate(num = -123456789) == -987654321\n    assert candidate(num = 100) == 100\n    assert candidate(num = -12345) == -54321\n    assert candidate(num = 54321) == 12345\n    assert candidate(num = -10) == -10\n    assert candidate(num = -900) == -900\n    assert candidate(num = -600500400300201) == -654321000000000\n    assert candidate(num = -999999999) == -999999999\n    assert candidate(num = 101010101010101) == 100000001111111\n    assert candidate(num = 505050505050505) == 500000005555555\n    assert candidate(num = -123456789012345) == -987655443322110\n    assert candidate(num = -1230456) == -6543210\n    assert candidate(num = 1000000000) == 1000000000\n    assert candidate(num = -202020202020202) == -222222220000000\n    assert candidate(num = 213004005) == 100002345\n    assert candidate(num = -999999999999999) == -999999999999999\n    assert candidate(num = -987654321012345) == -987655443322110\n    assert candidate(num = -543210000) == -543210000\n    assert candidate(num = -12000210) == -22110000\n    assert candidate(num = -99999999999999) == -99999999999999\n    assert candidate(num = 101010101) == 100001111\n    assert candidate(num = 303030303030303) == 300000003333333\n    assert candidate(num = 56789) == 56789\n    assert candidate(num = 1230000000) == 1000000023\n    assert candidate(num = 100000000000001) == 100000000000001\n    assert candidate(num = 1000100) == 1000001\n    assert candidate(num = 120030400500600) == 100000000023456\n    assert candidate(num = 20000000000000) == 20000000000000\n    assert candidate(num = 1000000000000000) == 1000000000000000\n    assert candidate(num = -111111111111111) == -111111111111111\n    assert candidate(num = -300000000000000) == -300000000000000\n    assert candidate(num = 100000000000000) == 100000000000000\n    assert candidate(num = 202020202020202) == 200000002222222\n    assert candidate(num = 1002003004) == 1000000234\n    assert candidate(num = 1000000001) == 1000000001\n    assert candidate(num = -123456789098765) == -998877665543210\n    assert candidate(num = -200100000000000) == -210000000000000\n    assert candidate(num = -111222333) == -333222111\n    assert candidate(num = -9999999999999) == -9999999999999\n    assert candidate(num = 12003004005) == 10000002345\n    assert candidate(num = 999999999) == 999999999\n    assert candidate(num = -50000000000000) == -50000000000000\n    assert candidate(num = 1111111111111) == 1111111111111\n    assert candidate(num = 1010101010) == 1000001111\n    assert candidate(num = -111000000) == -111000000\n    assert candidate(num = -1) == -1\n    assert candidate(num = -543210987654321) == -987655443322110\n    assert candidate(num = 2003005006) == 2000000356\n    assert candidate(num = 30000123) == 10000233\n    assert candidate(num = 1000002) == 1000002\n    assert candidate(num = 999999999999999) == 999999999999999\n    assert candidate(num = -999888777666) == -999888777666\n    assert candidate(num = 100001000010000) == 100000000000011\n    assert candidate(num = 500000000000000) == 500000000000000\n    assert candidate(num = -222222222) == -222222222\n    assert candidate(num = -200000000000001) == -210000000000000\n    assert candidate(num = 2000000001) == 1000000002\n    assert candidate(num = -100000000000001) == -110000000000000\n    assert candidate(num = 111000222333) == 100011222333\n    assert candidate(num = -900000000000001) == -910000000000000\n    assert candidate(num = -1000000000000000) == -1000000000000000\n    assert candidate(num = 111111111111111) == 111111111111111\n    assert candidate(num = -303030303030303) == -333333330000000\n    assert candidate(num = 503020104) == 100002345\n    assert candidate(num = 900000000000000) == 900000000000000\n    assert candidate(num = 200000000000001) == 100000000000002\n    assert candidate(num = -50006007008) == -87650000000\n    assert candidate(num = 100020003000) == 100000000023\n    assert candidate(num = 99999999999999) == 99999999999999\n    assert candidate(num = 3003003) == 3000033\n    assert candidate(num = -10000100001000) == -11100000000000\n    assert candidate(num = -100000000000000) == -100000000000000\n    assert candidate(num = 1234567890) == 1023456789\n    assert candidate(num = 10000000000000) == 10000000000000\n    assert candidate(num = -2100300) == -3210000\n    assert candidate(num = 123456789012345) == 101223344556789\n    assert candidate(num = 123000456) == 100023456\n    assert candidate(num = -987000000000000) == -987000000000000\n    assert candidate(num = -202020202) == -222220000\n    assert candidate(num = 2003004005) == 2000000345\n    assert candidate(num = -1234567890) == -9876543210\n    assert candidate(num = -5000000) == -5000000\n    assert candidate(num = -56789) == -98765\n", "comparison": "exact"}, "public_tests": ["310", "-7605"], "hints": ["For positive numbers, the leading digit should be the smallest nonzero digit. Then the remaining digits follow in ascending order.", "For negative numbers, the digits should be arranged in descending order."], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().smallestNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:26+00:00", "tests_total": 121, "tests_dropped": 21, "flags": [], "topic_tags": ["math", "sorting"]}, "language": "python", "interface": {"raw_signature": "def smallestNumber(self, num: int) -> int:", "container": "Solution", "callable": "smallestNumber", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2167, "task_id": "minimum-time-to-remove-all-cars-containing-illegal-goods", "difficulty": "Hard", "problem_description": "You are given a 0-indexed binary string s which represents a sequence of train cars. s[i] = '0' denotes that the i^th car does not contain illegal goods and s[i] = '1' denotes that the i^th car does contain illegal goods.\n\nAs the train conductor, you would like to get rid of all the cars containing illegal goods. You can do any of the following three operations any number of times:\n\n1. Remove a train car from the left end (i.e., remove s[0]) which takes 1 unit of time.\n2. Remove a train car from the right end (i.e., remove s[s.length - 1]) which takes 1 unit of time.\n3. Remove a train car from anywhere in the sequence which takes 2 units of time.\n\nReturn the minimum time to remove all the cars containing illegal goods.\n\nNote that an empty sequence of cars is considered to have no cars containing illegal goods.\n\nExample 1:\n\nInput: s = \"1100101\"\nOutput: 5\nExplanation:\nOne way to remove all the cars containing illegal goods from the sequence is to\n- remove a car from the left end 2 times. Time taken is 2 * 1 = 2.\n- remove a car from the right end. Time taken is 1.\n- remove the car containing illegal goods found in the middle. Time taken is 2.\nThis obtains a total time of 2 + 1 + 2 = 5.\n\nAn alternative way is to\n- remove a car from the left end 2 times. Time taken is 2 * 1 = 2.\n- remove a car from the right end 3 times. Time taken is 3 * 1 = 3.\nThis also obtains a total time of 2 + 3 = 5.\n\n5 is the minimum time taken to remove all the cars containing illegal goods.\nThere are no other ways to remove them with less time.\n\nExample 2:\n\nInput: s = \"0010\"\nOutput: 2\nExplanation:\nOne way to remove all the cars containing illegal goods from the sequence is to\n- remove a car from the left end 3 times. Time taken is 3 * 1 = 3.\nThis obtains a total time of 3.\n\nAnother way to remove all the cars containing illegal goods from the sequence is to\n- remove the car containing illegal goods found in the middle. Time taken is 2.\nThis obtains a total time of 2.\n\nAnother way to remove all the cars containing illegal goods from the sequence is to\n- remove a car from the right end 2 times. Time taken is 2 * 1 = 2.\nThis obtains a total time of 2.\n\n2 is the minimum time taken to remove all the cars containing illegal goods.\nThere are no other ways to remove them with less time.\n\nConstraints:\n\n- 1 <= s.length <= 2 * 10^5\n- s[i] is either '0' or '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"100100100100\") == 7\n    assert candidate(s = \"110110110110110110110110110110110110110110110110\") == 47\n    assert candidate(s = \"1100101\") == 5\n    assert candidate(s = \"1001001001\") == 6\n    assert candidate(s = \"11111\") == 5\n    assert candidate(s = \"111111\") == 6\n    assert candidate(s = \"0101010101\") == 9\n    assert candidate(s = \"0\") == 0\n    assert candidate(s = \"000000\") == 0\n    assert candidate(s = \"0010\") == 2\n    assert candidate(s = \"111000111\") == 6\n    assert candidate(s = \"00000\") == 0\n    assert candidate(s = \"000111000\") == 6\n    assert candidate(s = \"1010101010\") == 9\n    assert candidate(s = \"101101101101101\") == 14\n    assert candidate(s = \"111100001111\") == 8\n    assert candidate(s = \"1\") == 1\n    assert candidate(s = \"101010101010101\") == 14\n    assert candidate(s = \"1101001010111001010111001010111001010111001010111001\") == 50\n    assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101\") == 62\n    assert candidate(s = \"111000111000111000\") == 15\n    assert candidate(s = \"11010101010101010101010101010101010101\") == 37\n    assert candidate(s = \"0000000000000000000000000000000000000000000000\") == 0\n    assert candidate(s = \"010101010101010101010101010101010101\") == 35\n    assert candidate(s = \"111111111111111111111111111111111111111111111111\") == 48\n    assert candidate(s = \"10101010101010101010101010101010101010101010101010\") == 49\n    assert candidate(s = \"1000100010001000100010001000100010001000100010001000\") == 25\n    assert candidate(s = \"000000000000000000000000000000000000000001\") == 1\n    assert candidate(s = \"111011101110111011101110111011101110111011101110\") == 47\n    assert candidate(s = \"010101010101010101010101\") == 23\n    assert candidate(s = \"00001111000011110000\") == 16\n    assert candidate(s = \"111000111000111\") == 12\n    assert candidate(s = \"100011110000111100001111\") == 20\n    assert candidate(s = \"10101010101010101010101010101010101010101010101\") == 46\n    assert candidate(s = \"101010101010101010101010101010101010101010101010101010\") == 53\n    assert candidate(s = \"110101010101010101010101010101010101010101010101\") == 47\n    assert candidate(s = \"111111111110111111111111\") == 23\n    assert candidate(s = \"1100110011001100110011001100110011001100110011001100\") == 50\n    assert candidate(s = \"1000000000000000000001\") == 2\n    assert candidate(s = \"000001000001000001000001\") == 7\n    assert candidate(s = \"000000000000000000000000000000000000000000000000000000\") == 0\n    assert candidate(s = \"11110000000000001111\") == 8\n    assert candidate(s = \"111111000000111111000000\") == 18\n    assert candidate(s = \"111100001111000011110000\") == 20\n    assert candidate(s = \"0010101010101010101010101010101010101010101010101010\") == 50\n    assert candidate(s = \"0111111111111111111111111111111111111110\") == 39\n    assert candidate(s = \"011011011011011011011011011011011011011011011011\") == 47\n    assert candidate(s = \"1010101010101010101010101010101010101010101010101011\") == 51\n    assert candidate(s = \"00001010101010101000\") == 14\n    assert candidate(s = \"1110010100101001010010100101001010010100101001010010\") == 41\n    assert candidate(s = \"11111111111111111111111111111111111111111111111\") == 47\n    assert candidate(s = \"010101010101010101010101010101010101010101010101\") == 47\n    assert candidate(s = \"010101010101010101010101010101010101010101010101010101010101010101010101\") == 71\n    assert candidate(s = \"000000000000111111111111000000000000111111111111\") == 36\n    assert candidate(s = \"111000111000111000111000111000111000111000111000111000111000\") == 57\n    assert candidate(s = \"110011001100110011001100110011001100110011001100\") == 46\n    assert candidate(s = \"101010101010101010101010101010101010101\") == 38\n    assert candidate(s = \"00000000000000000000000000000000000000000000000\") == 0\n    assert candidate(s = \"1110001110001110001110001110001110001110001110001110\") == 49\n    assert candidate(s = \"000000000000000011111111111111110000000000000000\") == 32\n    assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010101010\") == 63\n    assert candidate(s = \"000110001100011000110001100011000110001100011000110001100011\") == 46\n    assert candidate(s = \"1111111111111111111111111111111111111111111111111111\") == 52\n    assert candidate(s = \"00110011001100110011001100\") == 24\n    assert candidate(s = \"1000000000000000000000000000000000000000000000000000\") == 1\n    assert candidate(s = \"111100001111000011110000111100001111000011110000\") == 44\n    assert candidate(s = \"01010101010101010101010101010101\") == 31\n    assert candidate(s = \"11110000111100001111000011110000111100001111000011110000\") == 52\n    assert candidate(s = \"00000000111111110000000011111111000000001111111100000000\") == 48\n    assert candidate(s = \"0000011111000001111100000111110000011111000001111100\") == 47\n    assert candidate(s = \"1101010101010101010101\") == 21\n    assert candidate(s = \"010101010101010101010101010101010101010101010101010101\") == 53\n    assert candidate(s = \"1111100000111110000011111000001111100000111110000011\") == 47\n    assert candidate(s = \"000000000000000\") == 0\n    assert candidate(s = \"00000000000000000000000000000000000000000000000000001\") == 1\n    assert candidate(s = \"111111111111111111111111111111111111111111111111111111\") == 54\n    assert candidate(s = \"100010001000100010001000100010001000100010001000\") == 23\n    assert candidate(s = \"1111111111111111111111111111111111111111\") == 40\n    assert candidate(s = \"0001001001001001001001001001001001001001001001001001\") == 33\n    assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001\") == 38\n    assert candidate(s = \"1001100110011001100110011001100110011001100110011001100110011001\") == 62\n    assert candidate(s = \"0101010101010101010101010101010101010101010101010101\") == 51\n    assert candidate(s = \"00000000000000000000\") == 0\n    assert candidate(s = \"111111000000111111000000111111000000111111000000111111000000\") == 54\n    assert candidate(s = \"01010101010101010101010101010101010101010101010101010101\") == 55\n    assert candidate(s = \"1110000111100001111000011110000111100001111000011110\") == 48\n    assert candidate(s = \"11010101010101010101\") == 19\n    assert candidate(s = \"1010101010101010101010101010101010101010101010\") == 45\n    assert candidate(s = \"0000000000000000000000000000000000000000000000000000\") == 0\n    assert candidate(s = \"1010101010101010101010\") == 21\n    assert candidate(s = \"0000000000000000000000000000000000000000000000001\") == 1\n    assert candidate(s = \"1111000001111000001111\") == 16\n    assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011001100\") == 62\n    assert candidate(s = \"1010101010101010101010101010101010101010101010101010\") == 51\n    assert candidate(s = \"011001100110011001100110011001100110011001100110\") == 46\n    assert candidate(s = \"000000000001000000000001\") == 3\n    assert candidate(s = \"10000000000000000001\") == 2\n    assert candidate(s = \"011011011011011011011011011011011011011011011011011011011011011011011011\") == 71\n    assert candidate(s = \"0001111111000000111111111000000111111111100000011111\") == 46\n    assert candidate(s = \"10101010101010101010\") == 19\n    assert candidate(s = \"0000000000000000000000\") == 0\n", "comparison": "exact"}, "public_tests": ["\"1100101\"", "\"0010\""], "hints": ["Build an array withoutFirst where withoutFirst[i] stores the minimum time to remove all the cars containing illegal goods from the ‘suffix’ of the sequence starting from the ith car without using any type 1 operations.", "Next, build an array onlyFirst where onlyFirst[i] stores the minimum time to remove all the cars containing illegal goods from the ‘prefix’ of the sequence ending on the ith car using only type 1 operations.", "Finally, we can compare the best way to split the operations amongst these two types by finding the minimum time across all onlyFirst[i] + withoutFirst[i + 1]."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumTime", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:28+00:00", "tests_total": 101, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def minimumTime(self, s: str) -> int:", "container": "Solution", "callable": "minimumTime", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2169, "task_id": "count-operations-to-obtain-zero", "difficulty": "Easy", "problem_description": "You are given two non-negative integers num1 and num2.\n\nIn one operation, if num1 >= num2, you must subtract num2 from num1, otherwise subtract num1 from num2.\n\n- For example, if num1 = 5 and num2 = 4, subtract num2 from num1, thus obtaining num1 = 1 and num2 = 4. However, if num1 = 4 and num2 = 5, after one operation, num1 = 4 and num2 = 1.\n\nReturn the number of operations required to make either num1 = 0 or num2 = 0.\n\nExample 1:\n\nInput: num1 = 2, num2 = 3\nOutput: 3\nExplanation:\n- Operation 1: num1 = 2, num2 = 3. Since num1 < num2, we subtract num1 from num2 and get num1 = 2, num2 = 3 - 2 = 1.\n- Operation 2: num1 = 2, num2 = 1. Since num1 > num2, we subtract num2 from num1.\n- Operation 3: num1 = 1, num2 = 1. Since num1 == num2, we subtract num2 from num1.\nNow num1 = 0 and num2 = 1. Since num1 == 0, we do not need to perform any further operations.\nSo the total number of operations required is 3.\n\nExample 2:\n\nInput: num1 = 10, num2 = 10\nOutput: 1\nExplanation:\n- Operation 1: num1 = 10, num2 = 10. Since num1 == num2, we subtract num2 from num1 and get num1 = 10 - 10 = 0.\nNow num1 = 0 and num2 = 10. Since num1 == 0, we are done.\nSo the total number of operations required is 1.\n\nConstraints:\n\n- 0 <= num1, num2 <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num1 = 0,num2 = 5) == 0\n    assert candidate(num1 = 100,num2 = 1) == 100\n    assert candidate(num1 = 123,num2 = 456) == 12\n    assert candidate(num1 = 8,num2 = 12) == 3\n    assert candidate(num1 = 1,num2 = 1) == 1\n    assert candidate(num1 = 100000,num2 = 100000) == 1\n    assert candidate(num1 = 100000,num2 = 1) == 100000\n    assert candidate(num1 = 100,num2 = 50) == 2\n    assert candidate(num1 = 5,num2 = 0) == 0\n    assert candidate(num1 = 2,num2 = 3) == 3\n    assert candidate(num1 = 10,num2 = 10) == 1\n    assert candidate(num1 = 7,num2 = 3) == 5\n    assert candidate(num1 = 81,num2 = 27) == 3\n    assert candidate(num1 = 99999,num2 = 1) == 99999\n    assert candidate(num1 = 333,num2 = 111) == 3\n    assert candidate(num1 = 10000,num2 = 9999) == 10000\n    assert candidate(num1 = 2020,num2 = 1870) == 22\n    assert candidate(num1 = 60,num2 = 20) == 3\n    assert candidate(num1 = 101,num2 = 100) == 101\n    assert candidate(num1 = 42,num2 = 29) == 10\n    assert candidate(num1 = 100000,num2 = 0) == 0\n    assert candidate(num1 = 45678,num2 = 45678) == 1\n    assert candidate(num1 = 88888,num2 = 22222) == 4\n    assert candidate(num1 = 618,num2 = 359) == 15\n    assert candidate(num1 = 100000,num2 = 99999) == 100000\n    assert candidate(num1 = 42,num2 = 7) == 6\n    assert candidate(num1 = 98765,num2 = 43210) == 1241\n    assert candidate(num1 = 2,num2 = 34567) == 17285\n    assert candidate(num1 = 1,num2 = 99999) == 99999\n    assert candidate(num1 = 1000,num2 = 333) == 336\n    assert candidate(num1 = 88888,num2 = 11111) == 8\n    assert candidate(num1 = 9,num2 = 1) == 9\n    assert candidate(num1 = 1000,num2 = 1) == 1000\n    assert candidate(num1 = 55555,num2 = 22222) == 4\n    assert candidate(num1 = 87,num2 = 3) == 29\n    assert candidate(num1 = 15,num2 = 10) == 3\n    assert candidate(num1 = 60000,num2 = 30000) == 2\n    assert candidate(num1 = 22222,num2 = 11111) == 2\n    assert candidate(num1 = 65536,num2 = 1) == 65536\n    assert candidate(num1 = 65432,num2 = 12345) == 80\n    assert candidate(num1 = 20,num2 = 30) == 3\n    assert candidate(num1 = 50000,num2 = 25000) == 2\n    assert candidate(num1 = 13579,num2 = 24680) == 39\n    assert candidate(num1 = 777,num2 = 111) == 7\n    assert candidate(num1 = 88888,num2 = 44444) == 2\n    assert candidate(num1 = 12345,num2 = 54321) == 177\n    assert candidate(num1 = 5000,num2 = 7500) == 3\n    assert candidate(num1 = 25,num2 = 5) == 5\n    assert candidate(num1 = 23456,num2 = 65432) == 44\n    assert candidate(num1 = 45678,num2 = 87654) == 45\n    assert candidate(num1 = 12345,num2 = 67890) == 418\n    assert candidate(num1 = 42,num2 = 30) == 5\n    assert candidate(num1 = 789,num2 = 987) == 70\n    assert candidate(num1 = 99999,num2 = 99999) == 1\n    assert candidate(num1 = 456,num2 = 123) == 12\n    assert candidate(num1 = 0,num2 = 0) == 0\n    assert candidate(num1 = 55,num2 = 20) == 6\n    assert candidate(num1 = 33333,num2 = 22222) == 3\n    assert candidate(num1 = 54321,num2 = 12345) == 177\n    assert candidate(num1 = 1,num2 = 100000) == 100000\n    assert candidate(num1 = 32768,num2 = 16384) == 2\n    assert candidate(num1 = 1000,num2 = 100) == 10\n    assert candidate(num1 = 2,num2 = 8) == 4\n    assert candidate(num1 = 75,num2 = 25) == 3\n    assert candidate(num1 = 83456,num2 = 37821) == 38\n    assert candidate(num1 = 23456,num2 = 12345) == 262\n    assert candidate(num1 = 123,num2 = 321) == 11\n    assert candidate(num1 = 8,num2 = 3) == 5\n    assert candidate(num1 = 50,num2 = 25) == 2\n    assert candidate(num1 = 13,num2 = 13) == 1\n    assert candidate(num1 = 12345,num2 = 1) == 12345\n    assert candidate(num1 = 55555,num2 = 55555) == 1\n    assert candidate(num1 = 3,num2 = 8) == 5\n    assert candidate(num1 = 30000,num2 = 15000) == 2\n    assert candidate(num1 = 999,num2 = 999) == 1\n    assert candidate(num1 = 56789,num2 = 12345) == 260\n    assert candidate(num1 = 25,num2 = 15) == 4\n", "comparison": "exact"}, "public_tests": ["2\n3", "10\n10"], "hints": ["Try simulating the process until either of the two integers is zero.", "Count the number of operations done."], "metadata": {"canonical_parameter_names": ["num1", "num2"], "leetcode_dataset_entry_point": "Solution().countOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:33+00:00", "tests_total": 78, "tests_dropped": 1, "flags": [], "topic_tags": ["math", "simulation"]}, "language": "python", "interface": {"raw_signature": "def countOperations(self, num1: int, num2: int) -> int:", "container": "Solution", "callable": "countOperations", "parameters": [{"name": "num1", "type": "int"}, {"name": "num2", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2170, "task_id": "minimum-operations-to-make-the-array-alternating", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums consisting of n positive integers.\n\nThe array nums is called alternating if:\n\n- nums[i - 2] == nums[i], where 2 <= i <= n - 1.\n- nums[i - 1] != nums[i], where 1 <= i <= n - 1.\n\nIn one operation, you can choose an index i and change nums[i] into any positive integer.\n\nReturn the minimum number of operations required to make the array alternating.\n\nExample 1:\n\nInput: nums = [3,1,3,2,4,3]\nOutput: 3\nExplanation:\nOne way to make the array alternating is by converting it to [3,1,3,1,3,1].\nThe number of operations required in this case is 3.\nIt can be proven that it is not possible to make the array alternating in less than 3 operations.\n\nExample 2:\n\nInput: nums = [1,2,2,2,2]\nOutput: 2\nExplanation:\nOne way to make the array alternating is by converting it to [1,2,1,2,1].\nThe number of operations required in this case is 2.\nNote that the array cannot be converted to [2,2,2,2,2] because in this case nums[0] == nums[1] which violates the conditions of an alternating array.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 4\n    assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5]) == 0\n    assert candidate(nums = [2, 2, 2, 2, 2, 1]) == 2\n    assert candidate(nums = [1, 3, 1, 3, 2, 3, 1, 3, 1, 3]) == 1\n    assert candidate(nums = [1]) == 0\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n    assert candidate(nums = [1, 3, 2, 3, 2, 3]) == 1\n    assert candidate(nums = [100000, 1, 100000, 1, 100000, 1]) == 0\n    assert candidate(nums = [3, 1, 3, 2, 4, 3]) == 3\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 18\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 3\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == 3\n    assert candidate(nums = [2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [2, 3, 2, 3, 2, 3]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 7\n    assert candidate(nums = [1, 1, 1, 1, 1]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 4\n    assert candidate(nums = [1, 2, 2, 2, 2]) == 2\n    assert candidate(nums = [1, 3, 1, 3, 1, 3]) == 0\n    assert candidate(nums = [100000, 99999, 100000, 99999, 100000]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5]) == 3\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 2\n    assert candidate(nums = [100000, 99999, 100000, 99999, 100000]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5]) == 3\n    assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 3\n    assert candidate(nums = [1, 100000, 1, 100000, 1, 100000, 1]) == 0\n    assert candidate(nums = [1, 3, 5, 3, 1]) == 1\n    assert candidate(nums = [1, 3, 1, 3, 1, 3, 1]) == 0\n    assert candidate(nums = [10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9]) == 0\n    assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15]) == 13\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 10\n    assert candidate(nums = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100, 10, 110]) == 9\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 13\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 0\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3]) == 1\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 23\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n    assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 14\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 17\n    assert candidate(nums = [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == 0\n    assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == 13\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 24\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 28\n    assert candidate(nums = [100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101]) == 0\n    assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n    assert candidate(nums = [3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2]) == 24\n    assert candidate(nums = [99999, 1, 99999, 2, 99999, 3, 99999, 4, 99999, 5]) == 4\n    assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 20\n    assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1]) == 5\n    assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 0\n    assert candidate(nums = [2, 1, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 2, 10, 2, 11]) == 9\n    assert candidate(nums = [42, 17, 42, 17, 42, 17, 42, 17, 42, 17, 42, 17, 42, 17, 42, 17]) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == 11\n    assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 0\n    assert candidate(nums = [9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1]) == 0\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 10\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 18\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 16\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 18\n    assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2]) == 13\n    assert candidate(nums = [7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11]) == 16\n    assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 0\n    assert candidate(nums = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5]) == 0\n    assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 6, 5, 7, 5, 8, 5, 9, 5, 10]) == 9\n    assert candidate(nums = [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == 0\n    assert candidate(nums = [50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51]) == 0\n    assert candidate(nums = [5, 6, 5, 7, 5, 8, 5, 9, 5, 10, 5, 11, 5, 12]) == 6\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 18\n    assert candidate(nums = [99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999]) == 0\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 10\n    assert candidate(nums = [2, 1, 2, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1]) == 3\n    assert candidate(nums = [100000, 99999, 100000, 99999, 100000, 99999, 100000, 99999, 100000, 99999]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 14\n    assert candidate(nums = [1, 2, 1, 3, 4, 1, 2, 1, 3, 4, 1, 2, 1, 3, 4, 1, 2, 1, 3, 4, 1]) == 14\n    assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 16\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6]) == 12\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1]) == 5\n    assert candidate(nums = [10, 9, 10, 8, 10, 7, 10, 6, 10, 5, 10, 4, 10, 3, 10, 2, 10, 1]) == 8\n    assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 6, 5, 7, 5, 8, 5, 9, 5, 10]) == 9\n    assert candidate(nums = [100000, 99999, 100000, 99998, 100000, 99997, 100000, 99996, 100000, 99995]) == 4\n    assert candidate(nums = [2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 5\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15]) == 41\n    assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 11\n    assert candidate(nums = [1, 2, 1, 2, 3, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1]) == 3\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 18\n    assert candidate(nums = [9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8]) == 0\n    assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 0\n    assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11]) == 10\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 16\n    assert candidate(nums = [99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n    assert candidate(nums = [7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7]) == 0\n    assert candidate(nums = [6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2]) == 0\n    assert candidate(nums = [2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 5\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 28\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 15\n    assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11]) == 9\n    assert candidate(nums = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8]) == 12\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 24\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 15\n    assert candidate(nums = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5, 100000]) == 4\n    assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 0\n    assert candidate(nums = [50000, 50000, 50001, 50001, 50002, 50002, 50003, 50003, 50004, 50004, 50005, 50005, 50006, 50006, 50007, 50007]) == 14\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 30\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n    assert candidate(nums = [99999, 99998, 99999, 99998, 99999, 99998, 99999, 99998, 99999, 99997]) == 1\n    assert candidate(nums = [7, 5, 7, 2, 7, 5, 7, 5, 7, 5, 7, 5, 7, 5, 7, 5]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 48\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 11\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 24\n    assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 0\n    assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 0\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 17\n    assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 0\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 3\n    assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 0\n", "comparison": "exact"}, "public_tests": ["[3,1,3,2,4,3]", "[1,2,2,2,2]"], "hints": ["Count the frequency of each element in odd positions in the array. Do the same for elements in even positions.", "To minimize the number of operations we need to maximize the number of elements we keep from the original array.", "What are the possible combinations of elements we can choose from odd indices and even indices so that the number of unchanged elements is maximized?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:35+00:00", "tests_total": 135, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "counting"]}, "language": "python", "interface": {"raw_signature": "def minimumOperations(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minimumOperations", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2171, "task_id": "removing-minimum-number-of-magic-beans", "difficulty": "Medium", "problem_description": "You are given an array of positive integers beans, where each integer represents the number of magic beans found in a particular magic bag.\n\nRemove any number of beans (possibly none) from each bag such that the number of beans in each remaining non-empty bag (still containing at least one bean) is equal. Once a bean has been removed from a bag, you are not allowed to return it to any of the bags.\n\nReturn the minimum number of magic beans that you have to remove.\n\nExample 1:\n\nInput: beans = [4,1,6,5]\nOutput: 4\nExplanation:\n- We remove 1 bean from the bag with only 1 bean.\n  This results in the remaining bags: [4,0,6,5]\n- Then we remove 2 beans from the bag with 6 beans.\n  This results in the remaining bags: [4,0,4,5]\n- Then we remove 1 bean from the bag with 5 beans.\n  This results in the remaining bags: [4,0,4,4]\nWe removed a total of 1 + 2 + 1 = 4 beans to make the remaining non-empty bags have an equal number of beans.\nThere are no other solutions that remove 4 beans or fewer.\n\nExample 2:\n\nInput: beans = [2,10,3,2]\nOutput: 7\nExplanation:\n- We remove 2 beans from one of the bags with 2 beans.\n  This results in the remaining bags: [0,10,3,2]\n- Then we remove 2 beans from the other bag with 2 beans.\n  This results in the remaining bags: [0,10,3,0]\n- Then we remove 3 beans from the bag with 3 beans.\n  This results in the remaining bags: [0,10,0,0]\nWe removed a total of 2 + 2 + 3 = 7 beans to make the remaining non-empty bags have an equal number of beans.\nThere are no other solutions that removes 7 beans or fewer.\n\nConstraints:\n\n- 1 <= beans.length <= 10^5\n- 1 <= beans[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(beans = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(beans = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n    assert candidate(beans = [4, 1, 6, 5]) == 4\n    assert candidate(beans = [5, 5, 5, 5]) == 0\n    assert candidate(beans = [1, 2, 3, 4, 5, 6, 7, 8, 9, 100000]) == 45\n    assert candidate(beans = [10, 10, 10, 10]) == 0\n    assert candidate(beans = [5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 18\n    assert candidate(beans = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 9\n    assert candidate(beans = [1, 2, 3, 4, 5]) == 6\n    assert candidate(beans = [100000, 99999, 99998, 99997, 99996]) == 10\n    assert candidate(beans = [100000, 1, 100000, 1, 100000]) == 2\n    assert candidate(beans = [1]) == 0\n    assert candidate(beans = [100000]) == 0\n    assert candidate(beans = [5, 5, 5, 5, 5]) == 0\n    assert candidate(beans = [1, 1, 1, 1, 1]) == 0\n    assert candidate(beans = [99999, 99999, 99999, 99999, 99999]) == 0\n    assert candidate(beans = [2, 10, 3, 2]) == 7\n    assert candidate(beans = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 25\n    assert candidate(beans = [5, 4, 3, 2, 1]) == 6\n    assert candidate(beans = [100000, 1, 100000, 1, 100000]) == 2\n    assert candidate(beans = [100000, 100000, 100000, 100000, 100000]) == 0\n    assert candidate(beans = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 19\n    assert candidate(beans = [1, 100000, 1, 100000]) == 2\n    assert candidate(beans = [10, 1, 10, 1, 10]) == 2\n    assert candidate(beans = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100000]) == 19\n    assert candidate(beans = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100000]) == 9\n    assert candidate(beans = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100]) == 55\n    assert candidate(beans = [9, 7, 3, 8, 6, 4]) == 13\n    assert candidate(beans = [100, 50, 150, 200, 250, 300]) == 450\n    assert candidate(beans = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 0\n    assert candidate(beans = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 25\n    assert candidate(beans = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n    assert candidate(beans = [50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1]) == 313\n    assert candidate(beans = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 2500\n    assert candidate(beans = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 1]) == 1\n    assert candidate(beans = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == 99803\n    assert candidate(beans = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 50\n    assert candidate(beans = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 625\n    assert candidate(beans = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 3, 1]) == 259\n    assert candidate(beans = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 100\n    assert candidate(beans = [1, 99999, 2, 99998, 3, 99997, 4, 99996]) == 16\n    assert candidate(beans = [50, 50, 50, 50, 50, 1, 1, 1, 1, 1]) == 5\n    assert candidate(beans = [50000, 50000, 50000, 50000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 16\n    assert candidate(beans = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n    assert candidate(beans = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 190\n    assert candidate(beans = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 18\n    assert candidate(beans = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 12\n    assert candidate(beans = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 190\n    assert candidate(beans = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n    assert candidate(beans = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 78\n    assert candidate(beans = [10, 20, 30, 40, 50]) == 60\n    assert candidate(beans = [10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40, 50, 50, 50]) == 180\n    assert candidate(beans = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 45\n    assert candidate(beans = [210, 190, 171, 153, 136, 120, 105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1]) == 805\n    assert candidate(beans = [5, 7, 8, 9, 9, 10, 10, 10, 10, 10]) == 24\n    assert candidate(beans = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 560\n    assert candidate(beans = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 120\n    assert candidate(beans = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n    assert candidate(beans = [50000, 50000, 50000, 50000, 50000, 1, 2, 3, 4, 5]) == 15\n    assert candidate(beans = [100, 100, 200, 200, 300, 300, 400, 400, 500, 500]) == 1200\n    assert candidate(beans = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 120\n    assert candidate(beans = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 225\n    assert candidate(beans = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n    assert candidate(beans = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 10\n    assert candidate(beans = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60]) == 130\n    assert candidate(beans = [99999, 100000, 99998, 100000, 99997, 100000]) == 12\n    assert candidate(beans = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 50\n    assert candidate(beans = [2, 4, 6, 8, 10, 8, 6, 4, 2]) == 20\n    assert candidate(beans = [1, 10, 100, 1000, 10000, 100000, 100000, 10000, 1000, 100]) == 22211\n    assert candidate(beans = [20000, 20000, 20000, 20000, 20000, 10000, 10000, 10000, 10000, 10000, 10000]) == 50000\n    assert candidate(beans = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 805\n    assert candidate(beans = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n    assert candidate(beans = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n    assert candidate(beans = [1, 10, 100, 1000, 10000, 100000, 1, 10, 100, 1000, 10000, 100000, 1, 10, 100, 1000, 10000, 100000, 1, 10]) == 33344\n    assert candidate(beans = [99999, 99999, 99999, 99999, 99999, 1, 2, 3, 4, 5]) == 15\n    assert candidate(beans = [99999, 99998, 99997, 99996, 99995]) == 10\n    assert candidate(beans = [33, 33, 33, 33, 33, 1, 2, 3, 4, 5]) == 15\n    assert candidate(beans = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 45\n    assert candidate(beans = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 500\n    assert candidate(beans = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 250000\n    assert candidate(beans = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 0\n    assert candidate(beans = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496]) == 2915\n    assert candidate(beans = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 250\n    assert candidate(beans = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 50\n    assert candidate(beans = [5, 1, 1, 1, 5, 5, 5, 1, 5, 1, 1, 5]) == 6\n    assert candidate(beans = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 9\n    assert candidate(beans = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(beans = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n    assert candidate(beans = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 120\n    assert candidate(beans = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 5600\n    assert candidate(beans = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 12\n    assert candidate(beans = [7, 5, 9, 3, 6, 2, 8, 1, 4, 10]) == 25\n    assert candidate(beans = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 2500\n    assert candidate(beans = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(beans = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == 150\n    assert candidate(beans = [50000, 50000, 50000, 50000, 50000, 1, 1, 1]) == 3\n    assert candidate(beans = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 25000\n    assert candidate(beans = [3, 6, 1, 9, 4, 2, 8, 7, 5]) == 20\n    assert candidate(beans = [50, 40, 30, 20, 10, 50, 40, 30, 20, 10, 50, 40, 30, 20, 10, 50, 40, 30, 20, 10]) == 240\n    assert candidate(beans = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]) == 312\n    assert candidate(beans = [1, 100, 1000, 10000, 100000]) == 11101\n    assert candidate(beans = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 1]) == 1\n    assert candidate(beans = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 25\n    assert candidate(beans = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 24\n    assert candidate(beans = [10, 10, 20, 20, 30, 30, 40, 40]) == 80\n    assert candidate(beans = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 31\n", "comparison": "exact"}, "public_tests": ["[4,1,6,5]", "[2,10,3,2]"], "hints": ["Notice that if we choose to make x bags of beans empty, we should choose the x bags with the least amount of beans.", "Notice that if the minimum number of beans in a non-empty bag is m, then the best way to make all bags have an equal amount of beans is to reduce all the bags to have m beans.", "Can we iterate over how many bags we should remove and choose the one that minimizes the total amount of beans to remove?", "Sort the bags of beans first."], "metadata": {"canonical_parameter_names": ["beans"], "leetcode_dataset_entry_point": "Solution().minimumRemoval", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:38+00:00", "tests_total": 107, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "greedy", "sorting", "enumeration", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minimumRemoval(self, beans: list[int]) -> int:", "container": "Solution", "callable": "minimumRemoval", "parameters": [{"name": "beans", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2172, "task_id": "maximum-and-sum-of-array", "difficulty": "Hard", "problem_description": "You are given an integer array nums of length n and an integer numSlots such that 2 * numSlots >= n. There are numSlots slots numbered from 1 to numSlots.\n\nYou have to place all n integers into the slots such that each slot contains at most two numbers. The AND sum of a given placement is the sum of the bitwise AND of every number with its respective slot number.\n\n- For example, the AND sum of placing the numbers [1, 3] into slot 1 and [4, 6] into slot 2 is equal to (1 AND 1) + (3 AND 1) + (4 AND 2) + (6 AND 2) = 1 + 1 + 0 + 2 = 4.\n\nReturn the maximum possible AND sum of nums given numSlots slots.\n\nExample 1:\n\nInput: nums = [1,2,3,4,5,6], numSlots = 3\nOutput: 9\nExplanation: One possible placement is [1, 4] into slot 1, [2, 6] into slot 2, and [3, 5] into slot 3.\nThis gives the maximum AND sum of (1 AND 1) + (4 AND 1) + (2 AND 2) + (6 AND 2) + (3 AND 3) + (5 AND 3) = 1 + 0 + 2 + 2 + 3 + 1 = 9.\n\nExample 2:\n\nInput: nums = [1,3,10,4,7,1], numSlots = 9\nOutput: 24\nExplanation: One possible placement is [1, 1] into slot 1, [3] into slot 3, [4] into slot 4, [7] into slot 7, and [10] into slot 9.\nThis gives the maximum AND sum of (1 AND 1) + (1 AND 1) + (3 AND 3) + (4 AND 4) + (7 AND 7) + (10 AND 9) = 1 + 1 + 3 + 4 + 7 + 8 = 24.\nNote that slots 2, 5, 6, and 8 are empty which is permitted.\n\nConstraints:\n\n- n == nums.length\n- 1 <= numSlots <= 9\n- 1 <= n <= 2 * numSlots\n- 1 <= nums[i] <= 15\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 1, 1],numSlots = 2) == 2\n    assert candidate(nums = [1, 2, 3],numSlots = 2) == 5\n    assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15],numSlots = 8) == 52\n    assert candidate(nums = [15, 15, 15],numSlots = 2) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6],numSlots = 3) == 9\n    assert candidate(nums = [7, 11, 4, 1, 3, 10, 4, 9],numSlots = 5) == 23\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numSlots = 8) == 8\n    assert candidate(nums = [1, 2],numSlots = 1) == 1\n    assert candidate(nums = [4, 10, 7, 6, 9, 8, 3, 9, 8, 1, 2, 6, 8, 7, 8],numSlots = 9) == 72\n    assert candidate(nums = [1, 1, 1, 1, 1, 1],numSlots = 3) == 4\n    assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],numSlots = 6) == 42\n    assert candidate(nums = [1, 3, 10, 4, 7, 1],numSlots = 9) == 24\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numSlots = 8) == 8\n    assert candidate(nums = [7, 11, 4, 1],numSlots = 3) == 7\n    assert candidate(nums = [1, 2, 3],numSlots = 3) == 6\n    assert candidate(nums = [1],numSlots = 1) == 1\n    assert candidate(nums = [15, 10, 5, 1, 14, 9, 4, 2, 13, 8, 3, 6, 12, 7, 11],numSlots = 8) == 71\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],numSlots = 9) == 84\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15],numSlots = 9) == 84\n    assert candidate(nums = [15, 10, 5, 3, 8, 2, 7, 1, 14, 12, 9, 13, 4, 6, 11],numSlots = 8) == 71\n    assert candidate(nums = [15, 7, 8, 9, 10, 11, 12, 13, 14, 1, 2, 3, 4, 5, 6, 15, 1, 2],numSlots = 9) == 90\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],numSlots = 9) == 84\n    assert candidate(nums = [8, 5, 6, 7, 1, 2, 3, 4, 9, 10, 11, 12, 13, 14, 15],numSlots = 8) == 71\n    assert candidate(nums = [11, 5, 7, 3, 14, 10, 9, 8],numSlots = 4) == 19\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1],numSlots = 9) == 85\n    assert candidate(nums = [12, 6, 7, 10, 5, 11, 4, 8, 15, 14, 2, 13, 3, 9, 1],numSlots = 8) == 71\n    assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],numSlots = 9) == 86\n    assert candidate(nums = [5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6],numSlots = 9) == 84\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],numSlots = 9) == 84\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],numSlots = 8) == 71\n    assert candidate(nums = [14, 3, 5, 7, 10, 2, 8, 13],numSlots = 4) == 19\n    assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8],numSlots = 5) == 29\n    assert candidate(nums = [7, 5, 2, 9, 1, 12, 3, 8, 6, 11, 14, 15],numSlots = 6) == 40\n    assert candidate(nums = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],numSlots = 7) == 49\n    assert candidate(nums = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],numSlots = 8) == 64\n    assert candidate(nums = [14, 7, 9, 12, 11, 8, 5, 10, 3, 2, 15, 6, 1, 4, 13],numSlots = 8) == 71\n    assert candidate(nums = [13, 9, 7, 5, 3, 1],numSlots = 4) == 16\n    assert candidate(nums = [15, 13, 11, 9, 7, 5, 3, 1],numSlots = 4) == 20\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],numSlots = 9) == 90\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],numSlots = 8) == 71\n    assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9],numSlots = 8) == 71\n    assert candidate(nums = [14, 14, 14, 14, 14, 14, 14, 14, 14, 14],numSlots = 5) == 24\n    assert candidate(nums = [8, 6, 4, 2, 10, 14, 12, 1],numSlots = 5) == 21\n    assert candidate(nums = [15, 8, 7, 1, 2, 3, 14, 9, 10, 11, 12, 13, 4, 5, 6],numSlots = 8) == 71\n    assert candidate(nums = [3, 5, 15, 7, 9, 11, 13, 14, 12, 10],numSlots = 6) == 39\n    assert candidate(nums = [10, 14, 7, 11, 8, 12, 13, 9, 6, 4, 5, 2, 3, 15, 1],numSlots = 8) == 71\n    assert candidate(nums = [8, 9, 10, 11, 12, 13, 14],numSlots = 7) == 21\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],numSlots = 9) == 90\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],numSlots = 8) == 40\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14],numSlots = 8) == 71\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],numSlots = 6) == 39\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15],numSlots = 8) == 72\n    assert candidate(nums = [1, 13, 5, 9, 11, 15, 3, 7, 14, 12, 2, 6, 10, 4, 8],numSlots = 8) == 71\n    assert candidate(nums = [14, 7, 13, 5, 11, 6, 2, 9],numSlots = 4) == 20\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],numSlots = 8) == 72\n    assert candidate(nums = [9, 6, 11, 12, 14, 15, 7, 8, 10],numSlots = 5) == 26\n    assert candidate(nums = [1, 3, 2, 5, 4, 6, 8, 7, 15, 14, 13, 12, 11, 10, 9],numSlots = 9) == 84\n    assert candidate(nums = [7, 13, 11, 1, 15, 5, 9, 3, 14, 12, 8, 10, 6, 2, 4],numSlots = 8) == 71\n    assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1],numSlots = 4) == 19\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],numSlots = 8) == 40\n    assert candidate(nums = [14, 12, 10, 8, 6, 4, 2, 15, 13, 11, 9, 7, 5, 3, 1],numSlots = 8) == 71\n    assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9],numSlots = 8) == 71\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],numSlots = 9) == 84\n    assert candidate(nums = [15, 1, 7, 15, 9, 7, 3, 10, 2, 14, 11, 13, 5, 4, 6, 8],numSlots = 9) == 87\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 1, 3, 5, 7, 9, 11, 13, 15],numSlots = 9) == 86\n    assert candidate(nums = [15, 9, 6, 11, 13, 7, 12, 1, 5, 3, 2, 4, 8, 14, 10],numSlots = 8) == 71\n    assert candidate(nums = [10, 15, 9, 4, 14, 8, 13, 7, 12, 2, 3, 11, 6, 5, 1],numSlots = 8) == 71\n    assert candidate(nums = [5, 14, 12, 3, 7, 9, 1, 13, 11, 8, 6, 4, 2, 15, 10],numSlots = 8) == 71\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5,6]\n3", "[1,3,10,4,7,1]\n9"], "hints": ["Can you think of a dynamic programming solution to this problem?", "Can you use a bitmask to represent the state of the slots?"], "metadata": {"canonical_parameter_names": ["nums", "numSlots"], "leetcode_dataset_entry_point": "Solution().maximumANDSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:40+00:00", "tests_total": 89, "tests_dropped": 21, "flags": [], "topic_tags": ["array", "dynamic-programming", "bit-manipulation", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def maximumANDSum(self, nums: list[int], numSlots: int) -> int:", "container": "Solution", "callable": "maximumANDSum", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "numSlots", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2176, "task_id": "count-equal-and-divisible-pairs-in-an-array", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums of length n and an integer k, return the number of pairs (i, j) where 0 <= i < j < n, such that nums[i] == nums[j] and (i * j) is divisible by k.\n\nExample 1:\n\nInput: nums = [3,1,2,2,2,1,3], k = 2\nOutput: 4\nExplanation:\nThere are 4 pairs that meet all the requirements:\n- nums[0] == nums[6], and 0 * 6 == 0, which is divisible by 2.\n- nums[2] == nums[3], and 2 * 3 == 6, which is divisible by 2.\n- nums[2] == nums[4], and 2 * 4 == 8, which is divisible by 2.\n- nums[3] == nums[4], and 3 * 4 == 12, which is divisible by 2.\n\nExample 2:\n\nInput: nums = [1,2,3,4], k = 1\nOutput: 0\nExplanation: Since no value in nums is repeated, there are no pairs (i,j) that meet all the requirements.\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 1 <= nums[i], k <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 0\n    assert candidate(nums = [6, 6, 6, 6],k = 2) == 5\n    assert candidate(nums = [3, 1, 2, 2, 2, 1, 3],k = 2) == 4\n    assert candidate(nums = [9, 9, 9],k = 9) == 2\n    assert candidate(nums = [10, 20, 10, 20, 10],k = 10) == 2\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 30\n    assert candidate(nums = [10, 20, 10, 20, 10],k = 5) == 2\n    assert candidate(nums = [1, 1, 1, 1],k = 1) == 6\n    assert candidate(nums = [7, 11, 7, 11, 7, 11],k = 3) == 4\n    assert candidate(nums = [1, 3, 1, 3, 1, 3],k = 3) == 4\n    assert candidate(nums = [7, 3, 8, 7, 3, 8, 7],k = 7) == 2\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7],k = 1) == 28\n    assert candidate(nums = [2, 4, 6, 8, 10],k = 2) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 70\n    assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 0\n    assert candidate(nums = [100, 100, 100],k = 3) == 2\n    assert candidate(nums = [1, 2, 3, 4],k = 1) == 0\n    assert candidate(nums = [5, 5, 5, 5],k = 2) == 5\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 45\n    assert candidate(nums = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99],k = 99) == 21\n    assert candidate(nums = [2, 3, 4, 2, 5, 3, 2, 2, 4, 2],k = 4) == 5\n    assert candidate(nums = [25, 10, 10, 25, 10, 10, 25, 25, 25, 10, 10, 25],k = 10) == 12\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 25) == 63\n    assert candidate(nums = [9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8],k = 2) == 120\n    assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 100) == 129\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 465\n    assert candidate(nums = [15, 15, 10, 15, 10, 15, 10, 15, 10],k = 15) == 5\n    assert candidate(nums = [9, 1, 9, 1, 9, 1, 9, 1, 9, 1],k = 3) == 14\n    assert candidate(nums = [21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21],k = 7) == 140\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 2) == 15\n    assert candidate(nums = [3, 5, 3, 3, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5],k = 15) == 23\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 2) == 10\n    assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 4) == 95\n    assert candidate(nums = [15, 25, 15, 25, 15, 25, 15, 25],k = 4) == 6\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 190\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 1) == 0\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 10) == 120\n    assert candidate(nums = [60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60],k = 15) == 418\n    assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],k = 4) == 56\n    assert candidate(nums = [5, 5, 5, 5, 10, 10, 10, 10],k = 5) == 6\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 2) == 330\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 20\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 25) == 210\n    assert candidate(nums = [10, 20, 10, 20, 10, 20, 10],k = 5) == 5\n    assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11],k = 1) == 45\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 7\n    assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 20) == 392\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 4) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 25) == 69\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 145\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 2) == 145\n    assert candidate(nums = [11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11],k = 4) == 95\n    assert candidate(nums = [10, 20, 30, 10, 20, 30, 10, 20],k = 5) == 3\n    assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],k = 10) == 2\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 17\n    assert candidate(nums = [21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21],k = 7) == 21\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 8) == 152\n    assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 100) == 9\n    assert candidate(nums = [2, 4, 6, 8, 10, 2, 4, 6, 8, 10],k = 10) == 1\n    assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 4) == 25\n    assert candidate(nums = [10, 20, 10, 30, 10, 20, 10],k = 5) == 4\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 30\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 10) == 563\n    assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],k = 6) == 215\n    assert candidate(nums = [15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50, 55, 55, 60, 60],k = 10) == 4\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 50) == 164\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 6) == 8\n    assert candidate(nums = [5, 15, 25, 5, 25, 15, 5, 15, 25, 5],k = 10) == 3\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],k = 3) == 15\n    assert candidate(nums = [15, 15, 25, 25, 15, 25, 15, 25, 15, 25],k = 5) == 8\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 3) == 30\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 8) == 65\n    assert candidate(nums = [6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3],k = 9) == 28\n    assert candidate(nums = [2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4],k = 2) == 210\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 14) == 45\n    assert candidate(nums = [11, 11, 22, 22, 33, 33, 44, 44, 55, 55, 66, 66, 77, 77, 88, 88, 99, 99, 100, 100],k = 11) == 2\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70],k = 10) == 0\n    assert candidate(nums = [10, 20, 10, 30, 10, 40, 10],k = 10) == 3\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 18) == 0\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 17\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 5) == 70\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 18\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 7) == 140\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 9) == 28\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 11, 22, 33, 44, 55, 66, 77, 88, 99],k = 11) == 2\n", "comparison": "exact"}, "public_tests": ["[3,1,2,2,2,1,3]\n2", "[1,2,3,4]\n1"], "hints": ["For every possible pair of indices (i, j) where i < j, check if it satisfies the given conditions."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:45+00:00", "tests_total": 89, "tests_dropped": 2, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def countPairs(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2177, "task_id": "find-three-consecutive-integers-that-sum-to-a-given-number", "difficulty": "Medium", "problem_description": "Given an integer num, return three consecutive integers (as a sorted array) that sum to num. If num cannot be expressed as the sum of three consecutive integers, return an empty array.\n\nExample 1:\n\nInput: num = 33\nOutput: [10,11,12]\nExplanation: 33 can be expressed as 10 + 11 + 12 = 33.\n10, 11, 12 are 3 consecutive integers, so we return [10, 11, 12].\n\nExample 2:\n\nInput: num = 4\nOutput: []\nExplanation: There is no way to express 4 as the sum of 3 consecutive integers.\n\nConstraints:\n\n- 0 <= num <= 10^15\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num = 9) == [2, 3, 4]\n    assert candidate(num = 1000000000001) == []\n    assert candidate(num = 0) == [-1, 0, 1]\n    assert candidate(num = 4) == []\n    assert candidate(num = 33) == [10, 11, 12]\n    assert candidate(num = 1000000000000) == []\n    assert candidate(num = 3) == [0, 1, 2]\n    assert candidate(num = 15) == [4, 5, 6]\n    assert candidate(num = 100000000000000) == []\n    assert candidate(num = 300000000000003) == [100000000000000, 100000000000001, 100000000000002]\n    assert candidate(num = 3000000000) == [999999999, 1000000000, 1000000001]\n    assert candidate(num = 3000000000000) == [999999999999, 1000000000000, 1000000000001]\n    assert candidate(num = 999) == [332, 333, 334]\n    assert candidate(num = 1000000000003) == []\n    assert candidate(num = 27) == [8, 9, 10]\n    assert candidate(num = 45) == [14, 15, 16]\n    assert candidate(num = 999999999999) == [333333333332, 333333333333, 333333333334]\n    assert candidate(num = 300000000000000) == [99999999999999, 100000000000000, 100000000000001]\n    assert candidate(num = 99) == [32, 33, 34]\n    assert candidate(num = 1234567890125) == []\n    assert candidate(num = 3000000000001) == []\n    assert candidate(num = 123456789) == [41152262, 41152263, 41152264]\n    assert candidate(num = 777777777777777) == [259259259259258, 259259259259259, 259259259259260]\n    assert candidate(num = 2999999999997) == [999999999998, 999999999999, 1000000000000]\n    assert candidate(num = 299999999999997) == [99999999999998, 99999999999999, 100000000000000]\n    assert candidate(num = 105) == [34, 35, 36]\n    assert candidate(num = 999999999999999) == [333333333333332, 333333333333333, 333333333333334]\n    assert candidate(num = 1000) == []\n    assert candidate(num = 81) == [26, 27, 28]\n    assert candidate(num = 1000000000002) == [333333333333, 333333333334, 333333333335]\n    assert candidate(num = 987654321) == [329218106, 329218107, 329218108]\n    assert candidate(num = 7500000000000) == [2499999999999, 2500000000000, 2500000000001]\n    assert candidate(num = 1001) == []\n    assert candidate(num = 21) == [6, 7, 8]\n    assert candidate(num = 123456789012345) == [41152263004114, 41152263004115, 41152263004116]\n    assert candidate(num = 6) == [1, 2, 3]\n    assert candidate(num = 299792458) == []\n    assert candidate(num = 2) == []\n    assert candidate(num = 1) == []\n    assert candidate(num = 100) == []\n    assert candidate(num = 1500000000000) == [499999999999, 500000000000, 500000000001]\n    assert candidate(num = 999999999) == [333333332, 333333333, 333333334]\n    assert candidate(num = 500000000000001) == [166666666666666, 166666666666667, 166666666666668]\n    assert candidate(num = 1000000) == []\n    assert candidate(num = 1234567890123) == [411522630040, 411522630041, 411522630042]\n    assert candidate(num = 1234567890124) == []\n    assert candidate(num = 1000000000000000) == []\n    assert candidate(num = 180) == [59, 60, 61]\n    assert candidate(num = 101) == []\n    assert candidate(num = 8999999999997) == [2999999999998, 2999999999999, 3000000000000]\n", "comparison": "exact"}, "public_tests": ["33", "4"], "hints": ["Notice that if a solution exists, we can represent them as x-1, x, x+1. What does this tell us about the number?", "Notice the sum of the numbers will be 3x. Can you solve for x?"], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().sumOfThree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:47+00:00", "tests_total": 52, "tests_dropped": 2, "flags": [], "topic_tags": ["math", "simulation"]}, "language": "python", "interface": {"raw_signature": "def sumOfThree(self, num: int) -> list[int]:", "container": "Solution", "callable": "sumOfThree", "parameters": [{"name": "num", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2178, "task_id": "maximum-split-of-positive-even-integers", "difficulty": "Medium", "problem_description": "You are given an integer finalSum. Split it into a sum of a maximum number of unique positive even integers.\n\n- For example, given finalSum = 12, the following splits are valid (unique positive even integers summing up to finalSum): (12), (2 + 10), (2 + 4 + 6), and (4 + 8). Among them, (2 + 4 + 6) contains the maximum number of integers. Note that finalSum cannot be split into (2 + 2 + 4 + 4) as all the numbers should be unique.\n\nReturn a list of integers that represent a valid split containing a maximum number of integers. If no valid split exists for finalSum, return an empty list. You may return the integers in any order.\n\nExample 1:\n\nInput: finalSum = 12\nOutput: [2,4,6]\nExplanation: The following are valid splits: (12), (2 + 10), (2 + 4 + 6), and (4 + 8).\n(2 + 4 + 6) has the maximum number of integers, which is 3. Thus, we return [2,4,6].\nNote that [2,6,4], [6,2,4], etc. are also accepted.\n\nExample 2:\n\nInput: finalSum = 7\nOutput: []\nExplanation: There are no valid splits for the given finalSum.\nThus, we return an empty array.\n\nExample 3:\n\nInput: finalSum = 28\nOutput: [6,8,2,12]\nExplanation: The following are valid splits: (2 + 26), (6 + 8 + 2 + 12), and (4 + 24).\n(6 + 8 + 2 + 12) has the maximum number of integers, which is 4. Thus, we return [6,8,2,12].\nNote that [10,2,4,12], [6,2,4,16], etc. are also accepted.\n\nConstraints:\n\n- 1 <= finalSum <= 10^10\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n    \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n    if isinstance(result, list) and isinstance(expected, list):\n        return sorted(result, key=repr) == sorted(expected, key=repr)\n    return result == expected\n\n\ndef check(candidate):\n    assert answers_match(candidate(finalSum=10), [2, 8])\n    assert answers_match(candidate(finalSum=7), [])\n    assert answers_match(candidate(finalSum=28), [2, 4, 6, 16])\n    assert answers_match(candidate(finalSum=2), [2])\n    assert answers_match(candidate(finalSum=12), [2, 4, 6])\n    assert answers_match(candidate(finalSum=100), [2, 4, 6, 8, 10, 12, 14, 16, 28])\n    assert answers_match(candidate(finalSum=198), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 42])\n    assert answers_match(candidate(finalSum=300), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 60])\n    assert answers_match(candidate(finalSum=2048), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 156])\n    assert answers_match(candidate(finalSum=4), [4])\n    assert answers_match(candidate(finalSum=512), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 50])\n    assert answers_match(candidate(finalSum=60), [2, 4, 6, 8, 10, 12, 18])\n    assert answers_match(candidate(finalSum=50), [2, 4, 6, 8, 10, 20])\n    assert answers_match(candidate(finalSum=101), [])\n    assert answers_match(candidate(finalSum=200), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 44])\n    assert answers_match(candidate(finalSum=32), [2, 4, 6, 8, 12])\n    assert answers_match(candidate(finalSum=123456789), [])\n    assert answers_match(candidate(finalSum=8192), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 182])\n    assert answers_match(candidate(finalSum=254), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 44])\n    assert answers_match(candidate(finalSum=256), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 46])\n    assert answers_match(candidate(finalSum=9999999999), [])\n    assert answers_match(candidate(finalSum=450), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 70])\n    assert answers_match(candidate(finalSum=8), [2, 6])\n    assert answers_match(candidate(finalSum=30), [2, 4, 6, 8, 10])\n    assert answers_match(candidate(finalSum=1998), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 106])\n    assert answers_match(candidate(finalSum=3), [])\n    assert answers_match(candidate(finalSum=128), [2, 4, 6, 8, 10, 12, 14, 16, 18, 38])\n    assert answers_match(candidate(finalSum=5050), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 220])\n    assert answers_match(candidate(finalSum=100000), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 1090])\n    assert answers_match(candidate(finalSum=1000000), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 666, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998, 1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, 1018, 1020, 1022, 1024, 1026, 1028, 1030, 1032, 1034, 1036, 1038, 1040, 1042, 1044, 1046, 1048, 1050, 1052, 1054, 1056, 1058, 1060, 1062, 1064, 1066, 1068, 1070, 1072, 1074, 1076, 1078, 1080, 1082, 1084, 1086, 1088, 1090, 1092, 1094, 1096, 1098, 1100, 1102, 1104, 1106, 1108, 1110, 1112, 1114, 1116, 1118, 1120, 1122, 1124, 1126, 1128, 1130, 1132, 1134, 1136, 1138, 1140, 1142, 1144, 1146, 1148, 1150, 1152, 1154, 1156, 1158, 1160, 1162, 1164, 1166, 1168, 1170, 1172, 1174, 1176, 1178, 1180, 1182, 1184, 1186, 1188, 1190, 1192, 1194, 1196, 1198, 1200, 1202, 1204, 1206, 1208, 1210, 1212, 1214, 1216, 1218, 1220, 1222, 1224, 1226, 1228, 1230, 1232, 1234, 1236, 1238, 1240, 1242, 1244, 1246, 1248, 1250, 1252, 1254, 1256, 1258, 1260, 1262, 1264, 1266, 1268, 1270, 1272, 1274, 1276, 1278, 1280, 1282, 1284, 1286, 1288, 1290, 1292, 1294, 1296, 1298, 1300, 1302, 1304, 1306, 1308, 1310, 1312, 1314, 1316, 1318, 1320, 1322, 1324, 1326, 1328, 1330, 1332, 1334, 1336, 1338, 1340, 1342, 1344, 1346, 1348, 1350, 1352, 1354, 1356, 1358, 1360, 1362, 1364, 1366, 1368, 1370, 1372, 1374, 1376, 1378, 1380, 1382, 1384, 1386, 1388, 1390, 1392, 1394, 1396, 1398, 1400, 1402, 1404, 1406, 1408, 1410, 1412, 1414, 1416, 1418, 1420, 1422, 1424, 1426, 1428, 1430, 1432, 1434, 1436, 1438, 1440, 1442, 1444, 1446, 1448, 1450, 1452, 1454, 1456, 1458, 1460, 1462, 1464, 1466, 1468, 1470, 1472, 1474, 1476, 1478, 1480, 1482, 1484, 1486, 1488, 1490, 1492, 1494, 1496, 1498, 1500, 1502, 1504, 1506, 1508, 1510, 1512, 1514, 1516, 1518, 1520, 1522, 1524, 1526, 1528, 1530, 1532, 1534, 1536, 1538, 1540, 1542, 1544, 1546, 1548, 1550, 1552, 1554, 1556, 1558, 1560, 1562, 1564, 1566, 1568, 1570, 1572, 1574, 1576, 1578, 1580, 1582, 1584, 1586, 1588, 1590, 1592, 1594, 1596, 1598, 1600, 1602, 1604, 1606, 1608, 1610, 1612, 1614, 1616, 1618, 1620, 1622, 1624, 1626, 1628, 1630, 1632, 1634, 1636, 1638, 1640, 1642, 1644, 1646, 1648, 1650, 1652, 1654, 1656, 1658, 1660, 1662, 1664, 1666, 1668, 1670, 1672, 1674, 1676, 1678, 1680, 1682, 1684, 1686, 1688, 1690, 1692, 1694, 1696, 1698, 1700, 1702, 1704, 1706, 1708, 1710, 1712, 1714, 1716, 1718, 1720, 1722, 1724, 1726, 1728, 1730, 1732, 1734, 1736, 1738, 1740, 1742, 1744, 1746, 1748, 1750, 1752, 1754, 1756, 1758, 1760, 1762, 1764, 1766, 1768, 1770, 1772, 1774, 1776, 1778, 1780, 1782, 1784, 1786, 1788, 1790, 1792, 1794, 1796, 1798, 1800, 1802, 1804, 1806, 1808, 1810, 1812, 1814, 1816, 1818, 1820, 1822, 1824, 1826, 1828, 1830, 1832, 1834, 1836, 1838, 1840, 1842, 1844, 1846, 1848, 1850, 1852, 1854, 1856, 1858, 1860, 1862, 1864, 1866, 1868, 1870, 1872, 1874, 1876, 1878, 1880, 1882, 1884, 1886, 1888, 1890, 1892, 1894, 1896, 1898, 1900, 1902, 1904, 1906, 1908, 1910, 1912, 1914, 1916, 1918, 1920, 1922, 1924, 1926, 1928, 1930, 1932, 1934, 1936, 1938, 1940, 1942, 1944, 1946, 1948, 1950, 1952, 1954, 1956, 1958, 1960, 1962, 1964, 1966, 1968, 1970, 1972, 1974, 1976, 1978, 1980, 1982, 1984, 1986, 1988, 1990, 1992, 1994, 1996, 2998])\n    assert answers_match(candidate(finalSum=1024), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 94])\n    assert answers_match(candidate(finalSum=64), [2, 4, 6, 8, 10, 12, 22])\n    assert answers_match(candidate(finalSum=26), [2, 4, 6, 14])\n    assert answers_match(candidate(finalSum=498), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 78])\n    assert answers_match(candidate(finalSum=18), [2, 4, 12])\n    assert answers_match(candidate(finalSum=1111111111), [])\n    assert answers_match(candidate(finalSum=500), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 80])\n    assert answers_match(candidate(finalSum=16), [2, 4, 10])\n    assert answers_match(candidate(finalSum=2000), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 108])\n    assert answers_match(candidate(finalSum=20), [2, 4, 6, 8])\n    assert answers_match(candidate(finalSum=1000), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 70])\n    assert answers_match(candidate(finalSum=1999), [])\n    assert answers_match(candidate(finalSum=150), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40])\n    assert answers_match(candidate(finalSum=88), [2, 4, 6, 8, 10, 12, 14, 32])\n    assert answers_match(candidate(finalSum=1), [])\n    assert answers_match(candidate(finalSum=1000000001), [])\n    assert answers_match(candidate(finalSum=10000), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 298])\n    assert answers_match(candidate(finalSum=42), [2, 4, 6, 8, 10, 12])\n    assert answers_match(candidate(finalSum=37), [])\n    assert answers_match(candidate(finalSum=33), [])\n", "comparison": "unordered"}, "public_tests": ["12", "7", "28"], "hints": ["First, check if finalSum is divisible by 2. If it isn’t, then we cannot split it into even integers.", "Let k be the number of elements in our split. As we want the maximum number of elements, we should try to use the first k - 1 even elements to grow our sum as slowly as possible.", "Thus, we find the maximum sum of the first k - 1 even elements which is less than finalSum.", "We then add the difference over to the kth element."], "metadata": {"canonical_parameter_names": ["finalSum"], "leetcode_dataset_entry_point": "Solution().maximumEvenSplit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:49+00:00", "tests_total": 50, "tests_dropped": 0, "flags": ["any_order"], "topic_tags": ["math", "backtracking", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maximumEvenSplit(self, finalSum: int) -> list[int]:", "container": "Solution", "callable": "maximumEvenSplit", "parameters": [{"name": "finalSum", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2179, "task_id": "count-good-triplets-in-an-array", "difficulty": "Hard", "problem_description": "You are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1].\n\nA good triplet is a set of 3 distinct values which are present in increasing order by position both in nums1 and nums2. In other words, if we consider pos1_v as the index of the value v in nums1 and pos2_v as the index of the value v in nums2, then a good triplet will be a set (x, y, z) where 0 <= x, y, z <= n - 1, such that pos1_x < pos1_y < pos1_z and pos2_x < pos2_y < pos2_z.\n\nReturn the total number of good triplets.\n\nExample 1:\n\nInput: nums1 = [2,0,1,3], nums2 = [0,1,2,3]\nOutput: 1\nExplanation:\nThere are 4 triplets (x,y,z) such that pos1_x < pos1_y < pos1_z. They are (2,0,1), (2,0,3), (2,1,3), and (0,1,3).\nOut of those triplets, only the triplet (0,1,3) satisfies pos2_x < pos2_y < pos2_z. Hence, there is only 1 good triplet.\n\nExample 2:\n\nInput: nums1 = [4,0,1,3,2], nums2 = [4,1,0,2,3]\nOutput: 4\nExplanation: The 4 good triplets are (4,0,3), (4,0,2), (4,1,3), and (4,1,2).\n\nConstraints:\n\n- n == nums1.length == nums2.length\n- 3 <= n <= 10^5\n- 0 <= nums1[i], nums2[i] <= n - 1\n- nums1 and nums2 are permutations of [0, 1, ..., n - 1].\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 0]) == 0\n    assert candidate(nums1 = [0, 1, 2, 3],nums2 = [3, 2, 1, 0]) == 0\n    assert candidate(nums1 = [1, 0, 3, 2],nums2 = [2, 3, 0, 1]) == 0\n    assert candidate(nums1 = [2, 0, 1, 3],nums2 = [0, 1, 2, 3]) == 1\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5],nums2 = [0, 1, 2, 3, 4, 5]) == 20\n    assert candidate(nums1 = [3, 2, 1, 0],nums2 = [3, 2, 1, 0]) == 4\n    assert candidate(nums1 = [0, 1, 2, 3, 4],nums2 = [0, 1, 2, 3, 4]) == 10\n    assert candidate(nums1 = [3, 2, 1, 0],nums2 = [0, 1, 2, 3]) == 0\n    assert candidate(nums1 = [0, 1, 2],nums2 = [2, 1, 0]) == 0\n    assert candidate(nums1 = [5, 4, 3, 2, 1, 0],nums2 = [5, 4, 3, 2, 1, 0]) == 20\n    assert candidate(nums1 = [4, 0, 1, 3, 2],nums2 = [4, 1, 0, 2, 3]) == 4\n    assert candidate(nums1 = [1, 0, 2, 3],nums2 = [3, 2, 1, 0]) == 0\n    assert candidate(nums1 = [1, 0, 3, 2, 5, 4],nums2 = [0, 5, 2, 4, 3, 1]) == 2\n    assert candidate(nums1 = [5, 3, 4, 0, 2, 1],nums2 = [1, 2, 0, 5, 4, 3]) == 0\n    assert candidate(nums1 = [5, 1, 4, 2, 3, 0, 6],nums2 = [0, 1, 2, 3, 4, 5, 6]) == 5\n    assert candidate(nums1 = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 84\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0],nums2 = [9, 1, 3, 5, 7, 0, 2, 4, 6, 8]) == 68\n    assert candidate(nums1 = [7, 3, 5, 0, 2, 6, 4, 1],nums2 = [1, 0, 4, 6, 2, 7, 5, 3]) == 0\n    assert candidate(nums1 = [5, 2, 6, 0, 3, 1, 4],nums2 = [0, 1, 2, 3, 4, 5, 6]) == 3\n    assert candidate(nums1 = [10, 7, 2, 9, 3, 5, 1, 6, 8, 0, 4],nums2 = [4, 0, 5, 8, 10, 6, 9, 2, 1, 7, 3]) == 5\n    assert candidate(nums1 = [6, 3, 2, 1, 5, 0, 4],nums2 = [3, 2, 5, 6, 4, 0, 1]) == 8\n    assert candidate(nums1 = [2, 4, 6, 1, 3, 5, 0],nums2 = [6, 5, 0, 1, 2, 3, 4]) == 2\n    assert candidate(nums1 = [1, 4, 5, 6, 7, 8, 9, 0, 2, 3],nums2 = [5, 6, 7, 8, 9, 0, 1, 4, 2, 3]) == 60\n    assert candidate(nums1 = [2, 8, 0, 1, 5, 9, 6, 7, 4, 3],nums2 = [7, 6, 3, 5, 8, 0, 9, 1, 2, 4]) == 8\n    assert candidate(nums1 = [2, 1, 3, 0, 5, 4],nums2 = [0, 4, 5, 1, 3, 2]) == 0\n    assert candidate(nums1 = [1, 3, 2, 5, 4, 0, 6, 7],nums2 = [0, 1, 2, 3, 4, 5, 6, 7]) == 26\n    assert candidate(nums1 = [1, 2, 0, 3, 4, 5],nums2 = [0, 1, 5, 3, 2, 4]) == 3\n    assert candidate(nums1 = [2, 1, 3, 0, 5, 4],nums2 = [5, 4, 2, 0, 3, 1]) == 0\n    assert candidate(nums1 = [3, 0, 1, 4, 2, 5],nums2 = [2, 1, 0, 5, 3, 4]) == 0\n    assert candidate(nums1 = [4, 2, 3, 5, 1, 0],nums2 = [1, 5, 4, 2, 0, 3]) == 2\n    assert candidate(nums1 = [0, 3, 1, 5, 2, 4],nums2 = [5, 2, 4, 0, 3, 1]) == 2\n    assert candidate(nums1 = [7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7]) == 0\n    assert candidate(nums1 = [0, 3, 2, 5, 4, 1],nums2 = [2, 3, 1, 0, 5, 4]) == 3\n    assert candidate(nums1 = [1, 0, 7, 6, 5, 4, 3, 2],nums2 = [3, 2, 5, 7, 6, 0, 4, 1]) == 1\n    assert candidate(nums1 = [2, 4, 1, 3, 5, 0, 6],nums2 = [5, 6, 2, 0, 4, 1, 3]) == 4\n    assert candidate(nums1 = [3, 0, 1, 4, 2, 5],nums2 = [5, 2, 4, 3, 1, 0]) == 0\n    assert candidate(nums1 = [2, 4, 6, 8, 0, 3, 5, 7, 9, 1],nums2 = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == 68\n    assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n    assert candidate(nums1 = [3, 1, 2, 5, 4, 0, 6],nums2 = [6, 0, 5, 2, 1, 4, 3]) == 0\n    assert candidate(nums1 = [2, 1, 0, 3, 4, 5, 6, 7, 8],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8]) == 65\n    assert candidate(nums1 = [5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5]) == 0\n    assert candidate(nums1 = [9, 5, 4, 7, 6, 3, 8, 0, 1, 2],nums2 = [0, 2, 1, 9, 3, 5, 4, 8, 7, 6]) == 14\n    assert candidate(nums1 = [8, 6, 7, 5, 3, 0, 9, 4, 2, 1],nums2 = [1, 2, 4, 9, 0, 3, 5, 7, 8, 6]) == 0\n    assert candidate(nums1 = [6, 2, 0, 4, 5, 1, 3],nums2 = [4, 2, 0, 6, 3, 5, 1]) == 7\n    assert candidate(nums1 = [7, 2, 4, 3, 0, 6, 5, 1],nums2 = [4, 0, 7, 1, 3, 6, 2, 5]) == 12\n    assert candidate(nums1 = [6, 4, 8, 5, 3, 9, 1, 2, 7, 0],nums2 = [7, 1, 2, 6, 0, 8, 5, 3, 4, 9]) == 12\n    assert candidate(nums1 = [6, 3, 0, 4, 2, 5, 1],nums2 = [5, 1, 2, 6, 0, 4, 3]) == 1\n    assert candidate(nums1 = [5, 2, 4, 0, 3, 1],nums2 = [3, 1, 0, 5, 4, 2]) == 0\n    assert candidate(nums1 = [8, 5, 7, 6, 2, 9, 3, 4, 0, 1],nums2 = [4, 0, 8, 7, 5, 6, 1, 2, 9, 3]) == 36\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n    assert candidate(nums1 = [3, 0, 5, 2, 7, 6, 1, 4, 8],nums2 = [7, 5, 8, 4, 0, 3, 6, 1, 2]) == 4\n    assert candidate(nums1 = [5, 1, 4, 2, 3, 0, 8, 6, 7, 9],nums2 = [1, 0, 2, 3, 4, 5, 6, 7, 8, 9]) == 46\n    assert candidate(nums1 = [5, 3, 4, 0, 2, 1],nums2 = [1, 0, 2, 5, 4, 3]) == 0\n    assert candidate(nums1 = [0, 4, 1, 5, 2, 6, 3, 7],nums2 = [7, 3, 6, 2, 5, 1, 4, 0]) == 0\n    assert candidate(nums1 = [6, 0, 1, 5, 2, 3, 4],nums2 = [1, 3, 5, 4, 6, 2, 0]) == 3\n    assert candidate(nums1 = [0, 2, 1, 4, 3],nums2 = [4, 0, 1, 2, 3]) == 2\n    assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n    assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n    assert candidate(nums1 = [4, 3, 7, 8, 9, 1, 5, 6, 2, 0],nums2 = [6, 5, 0, 2, 1, 8, 9, 7, 3, 4]) == 0\n    assert candidate(nums1 = [7, 5, 6, 3, 4, 1, 2, 0],nums2 = [3, 6, 2, 7, 0, 1, 4, 5]) == 2\n    assert candidate(nums1 = [8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8]) == 0\n    assert candidate(nums1 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 240\n    assert candidate(nums1 = [10, 1, 5, 9, 8, 2, 6, 7, 3, 4, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 13\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n    assert candidate(nums1 = [7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7]) == 0\n    assert candidate(nums1 = [0, 4, 1, 5, 2, 6, 3],nums2 = [1, 2, 3, 4, 5, 6, 0]) == 4\n    assert candidate(nums1 = [3, 0, 2, 4, 5, 1, 6],nums2 = [6, 1, 3, 5, 0, 2, 4]) == 4\n    assert candidate(nums1 = [1, 9, 2, 8, 3, 7, 4, 6, 5, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 20\n    assert candidate(nums1 = [3, 0, 5, 2, 4, 1],nums2 = [4, 1, 0, 5, 3, 2]) == 1\n    assert candidate(nums1 = [0, 2, 5, 3, 1, 4],nums2 = [1, 4, 3, 0, 2, 5]) == 1\n    assert candidate(nums1 = [8, 6, 7, 2, 5, 4, 3, 0, 1],nums2 = [1, 0, 2, 5, 4, 3, 8, 7, 6]) == 4\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 0],nums2 = [0, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums1 = [5, 3, 2, 4, 1, 6, 0],nums2 = [0, 3, 1, 5, 2, 4, 6]) == 8\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums2 = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums1 = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 84\n    assert candidate(nums1 = [7, 3, 0, 4, 6, 1, 5, 2],nums2 = [5, 2, 6, 0, 3, 7, 4, 1]) == 3\n    assert candidate(nums1 = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5],nums2 = [5, 4, 6, 3, 7, 2, 8, 1, 9, 0]) == 0\n    assert candidate(nums1 = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 84\n    assert candidate(nums1 = [5, 0, 2, 1, 3, 4],nums2 = [0, 1, 4, 2, 5, 3]) == 3\n    assert candidate(nums1 = [3, 1, 2, 0, 7, 5, 6, 4],nums2 = [7, 5, 6, 4, 3, 1, 2, 0]) == 8\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums2 = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 120\n    assert candidate(nums1 = [3, 5, 7, 0, 2, 4, 6, 8, 1, 9],nums2 = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8]) == 19\n    assert candidate(nums1 = [2, 5, 3, 1, 0, 4],nums2 = [3, 5, 1, 4, 0, 2]) == 4\n    assert candidate(nums1 = [5, 3, 8, 6, 2, 7, 4, 0, 1, 9],nums2 = [9, 1, 0, 2, 4, 6, 3, 8, 7, 5]) == 1\n    assert candidate(nums1 = [1, 6, 3, 2, 7, 4, 5, 0],nums2 = [0, 5, 7, 2, 3, 1, 6, 4]) == 1\n    assert candidate(nums1 = [4, 7, 1, 8, 3, 0, 9, 2, 5, 6],nums2 = [9, 2, 6, 0, 7, 3, 5, 8, 4, 1]) == 3\n    assert candidate(nums1 = [6, 3, 0, 5, 2, 8, 1, 7, 4, 9],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 28\n    assert candidate(nums1 = [4, 0, 3, 5, 2, 6, 1, 7],nums2 = [1, 5, 0, 3, 6, 2, 4, 7]) == 9\n    assert candidate(nums1 = [2, 1, 4, 3, 6, 5, 8, 7, 0, 9],nums2 = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == 10\n    assert candidate(nums1 = [5, 1, 4, 3, 2, 0],nums2 = [0, 2, 1, 5, 4, 3]) == 2\n    assert candidate(nums1 = [9, 7, 1, 5, 6, 8, 0, 2, 3, 4],nums2 = [7, 4, 1, 5, 6, 0, 8, 2, 9, 3]) == 50\n    assert candidate(nums1 = [0, 1, 5, 4, 3, 2, 6],nums2 = [6, 0, 5, 3, 2, 1, 4]) == 6\n    assert candidate(nums1 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n    assert candidate(nums1 = [6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6]) == 0\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n    assert candidate(nums1 = [0, 3, 1, 6, 5, 4, 2],nums2 = [1, 6, 4, 5, 3, 0, 2]) == 7\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 0, 2, 4, 6, 8],nums2 = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == 20\n    assert candidate(nums1 = [1, 3, 2, 0, 5, 4],nums2 = [4, 0, 5, 2, 1, 3]) == 0\n    assert candidate(nums1 = [2, 0, 4, 3, 5, 1],nums2 = [5, 4, 1, 0, 3, 2]) == 0\n", "comparison": "exact"}, "public_tests": ["[2,0,1,3]\n[0,1,2,3]", "[4,0,1,3,2]\n[4,1,0,2,3]"], "hints": ["For every value y, how can you find the number of values x (0 ≤ x, y ≤ n - 1) such that x appears before y in both of the arrays?", "Similarly, for every value y, try finding the number of values z (0 ≤ y, z ≤ n - 1) such that z appears after y in both of the arrays.", "Now, for every value y, count the number of good triplets that can be formed if y is considered as the middle element."], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().goodTriplets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:51+00:00", "tests_total": 100, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "binary-search", "divide-and-conquer", "binary-indexed-tree", "segment-tree", "merge-sort", "ordered-set"]}, "language": "python", "interface": {"raw_signature": "def goodTriplets(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "goodTriplets", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2180, "task_id": "count-integers-with-even-digit-sum", "difficulty": "Easy", "problem_description": "Given a positive integer num, return the number of positive integers less than or equal to num whose digit sums are even.\n\nThe digit sum of a positive integer is the sum of all its digits.\n\nExample 1:\n\nInput: num = 4\nOutput: 2\nExplanation:\nThe only integers less than or equal to 4 whose digit sums are even are 2 and 4.\n\nExample 2:\n\nInput: num = 30\nOutput: 14\nExplanation:\nThe 14 integers less than or equal to 30 whose digit sums are even are\n2, 4, 6, 8, 11, 13, 15, 17, 19, 20, 22, 24, 26, and 28.\n\nConstraints:\n\n- 1 <= num <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num = 30) == 14\n    assert candidate(num = 10) == 4\n    assert candidate(num = 999) == 499\n    assert candidate(num = 500) == 249\n    assert candidate(num = 4) == 2\n    assert candidate(num = 2) == 1\n    assert candidate(num = 1) == 0\n    assert candidate(num = 100) == 49\n    assert candidate(num = 750) == 375\n    assert candidate(num = 1000) == 499\n    assert candidate(num = 432) == 215\n    assert candidate(num = 666) == 333\n    assert candidate(num = 456) == 227\n    assert candidate(num = 250) == 124\n    assert candidate(num = 345) == 172\n    assert candidate(num = 99) == 49\n    assert candidate(num = 222) == 111\n    assert candidate(num = 200) == 100\n    assert candidate(num = 444) == 222\n    assert candidate(num = 555) == 277\n    assert candidate(num = 888) == 444\n    assert candidate(num = 123) == 61\n    assert candidate(num = 789) == 394\n    assert candidate(num = 333) == 166\n    assert candidate(num = 375) == 187\n    assert candidate(num = 256) == 127\n    assert candidate(num = 800) == 400\n    assert candidate(num = 678) == 338\n    assert candidate(num = 623) == 311\n    assert candidate(num = 600) == 300\n    assert candidate(num = 777) == 388\n    assert candidate(num = 850) == 424\n    assert candidate(num = 899) == 449\n    assert candidate(num = 299) == 149\n", "comparison": "exact"}, "public_tests": ["4", "30"], "hints": ["Iterate through all integers from 1 to num.", "For any integer, extract the individual digits to compute their sum and check if it is even."], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().countEven", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:54+00:00", "tests_total": 34, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "simulation"]}, "language": "python", "interface": {"raw_signature": "def countEven(self, num: int) -> int:", "container": "Solution", "callable": "countEven", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2182, "task_id": "construct-string-with-repeat-limit", "difficulty": "Medium", "problem_description": "You are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears more than repeatLimit times in a row. You do not have to use all characters from s.\n\nReturn the lexicographically largest repeatLimitedString possible.\n\nA string a is lexicographically larger than a string b if in the first position where a and b differ, string a has a letter that appears later in the alphabet than the corresponding letter in b. If the first min(a.length, b.length) characters do not differ, then the longer string is the lexicographically larger one.\n\nExample 1:\n\nInput: s = \"cczazcc\", repeatLimit = 3\nOutput: \"zzcccac\"\nExplanation: We use all of the characters from s to construct the repeatLimitedString \"zzcccac\".\nThe letter 'a' appears at most 1 time in a row.\nThe letter 'c' appears at most 3 times in a row.\nThe letter 'z' appears at most 2 times in a row.\nHence, no letter appears more than repeatLimit times in a row and the string is a valid repeatLimitedString.\nThe string is the lexicographically largest repeatLimitedString possible so we return \"zzcccac\".\nNote that the string \"zzcccca\" is lexicographically larger but the letter 'c' appears more than 3 times in a row, so it is not a valid repeatLimitedString.\n\nExample 2:\n\nInput: s = \"aababab\", repeatLimit = 2\nOutput: \"bbabaa\"\nExplanation: We use only some of the characters from s to construct the repeatLimitedString \"bbabaa\".\nThe letter 'a' appears at most 2 times in a row.\nThe letter 'b' appears at most 2 times in a row.\nHence, no letter appears more than repeatLimit times in a row and the string is a valid repeatLimitedString.\nThe string is the lexicographically largest repeatLimitedString possible so we return \"bbabaa\".\nNote that the string \"bbabaaa\" is lexicographically larger but the letter 'a' appears more than 2 times in a row, so it is not a valid repeatLimitedString.\n\nConstraints:\n\n- 1 <= repeatLimit <= s.length <= 10^5\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"aabbccddeeff\",repeatLimit = 1) == \"fefedcdcbaba\"\n    assert candidate(s = \"aabbccddeeff\",repeatLimit = 3) == \"ffeeddccbbaa\"\n    assert candidate(s = \"cczazcc\",repeatLimit = 3) == \"zzcccac\"\n    assert candidate(s = \"zzzzzzyyy\",repeatLimit = 2) == \"zzyzzyzzy\"\n    assert candidate(s = \"zzzzzzzzz\",repeatLimit = 3) == \"zzz\"\n    assert candidate(s = \"aababab\",repeatLimit = 2) == \"bbabaa\"\n    assert candidate(s = \"leetcode\",repeatLimit = 3) == \"toleeedc\"\n    assert candidate(s = \"a\",repeatLimit = 1) == \"a\"\n    assert candidate(s = \"aabbcc\",repeatLimit = 1) == \"cbcba\"\n    assert candidate(s = \"bbccddeee\",repeatLimit = 2) == \"eededccbb\"\n    assert candidate(s = \"abcd\",repeatLimit = 1) == \"dcba\"\n    assert candidate(s = \"zzzzzzzzzz\",repeatLimit = 2) == \"zz\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",repeatLimit = 2) == \"zz\"\n    assert candidate(s = \"abcabcabc\",repeatLimit = 1) == \"cbcbcba\"\n    assert candidate(s = \"aaaaaabbbccc\",repeatLimit = 1) == \"cbcbcba\"\n    assert candidate(s = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpppppppppppppppppppppppppppppppp\",repeatLimit = 5) == \"qqqqqpqqqqqpqqqqqpqqqqqpqqqqqpqqqqqpqqppppp\"\n    assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeeffffffffggggggggghhhhhhhhhiiiiiiiiijjjjjjjjkkkkkkkkklllllllllmmmmmmmmmnnnnnnnnnoooooooooppppppppqqqqqqqqqrrrrrrrrrssssssssstttttttttuuuuuuuuuvvvvvvvvvwwwwwwwwwxxxxxxxxxyyyyyyyyzzzzzzzzz\",repeatLimit = 4) == \"zzzzyzzzzyzyyyyxyyxxxxwxxxxwwwwvwwwwvvvvuvvvvuuuutuuuuttttsttttssssrssssrrrrqrrrrqqqqpqqqqppppopppoooonoooonnnnmnnnnmmmmlmmmmllllkllllkkkkjkkkkjjjjijjjiiiihiiiihhhhghhhhggggfggggffffefffeeeedeeeeddddcdddccccbcccbbbbabbbaaaa\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",repeatLimit = 5) == \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\"\n    assert candidate(s = \"mmmmmmmllllllkkkkkkjjjjjjiiiiiihhhhhhggggggffffffeeeeee\",repeatLimit = 4) == \"mmmmlmmmllllklkkkkjkjjjjijiiiihihhhhghggggfgffffefeeee\"\n    assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\",repeatLimit = 1) == \"zyxwvutsrqponmlkjihgfedcba\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 10) == \"zzzzzzzzzz\"\n    assert candidate(s = \"aabbbccccddeeeffffgggghhhhiiiiijjjjkkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxxyyyyyzzzzzzzzzzzz\",repeatLimit = 4) == \"zzzzyzzzzyzzzzyyyxxxxwxwwwvvvvuuuuttttssssrrrrqqqqppppoooonnnnmmmmllllkkkkjkjjjiiiihihhhggggffffeeeddccccbbbaa\"\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",repeatLimit = 2) == \"zyxwvutsrqponmlkjihgfedcba\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",repeatLimit = 1) == \"zyzyxwxwvuvutstsrqrqpoponmnmlklkjijihghgfefedcdcbaba\"\n    assert candidate(s = \"aaaabbbbccccddddeeeeffffgggg\",repeatLimit = 4) == \"ggggffffeeeeddddccccbbbbaaaa\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzyyyyyyyyyyyxxxxxxxxwwwwwwvvvvvvuuuuuuutttttttttssssrrrrqqqqqqqqpppponnnnmmmmlllkkkjjjiiiihhggggffffffeedddcccbba\",repeatLimit = 1) == \"zyzyzyzyzyzyzyzyzyzyzyzxzxzxzxwxwxwxwxwvwvuvuvuvuvutututststststrtrtrqrqpqpqpqpqoqnqnmnmnmlmlklkjkjijihihigfgfgfgfefefdcdcdcbab\"\n    assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxxyyyyyzzzzz\",repeatLimit = 2) == \"zzyzzyzyyxyxxwxxwwvwvvuvuututtstssrsrrqrqqpqppopoononnmnmmlmllklkkjkjjijiihihhggfgffeededdccbcbbaa\"\n    assert candidate(s = \"pppppppppooooooonnnnmmmllllkkkkjjjjiiiihhhhhggggfffffeeeee\",repeatLimit = 4) == \"ppppoppppopoooononnnmmmllllkkkkjjjjiiiihhhhghgggffffefeeee\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",repeatLimit = 2) == \"zyxwvutsrqponmlkjihgfedcba\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzyyyyyyyyyyyxxxxxxxxwwwwwwvvvvvvuuuuuuutttttttttssssrrrrqqqqqqqqpppponnnnmmmmlllkkkjjjiiiihhggggffffffeedddcccbba\",repeatLimit = 5) == \"zzzzzyzzzzzyzzzzzyyyyyxyyyyxxxxxwxxwwwwwvvvvvuvuuuuututttttstttsssrrrrqqqqqpqqqppponnnnmmmmlllkkkjjjiiiihhggggfffffefedddcccbba\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\",repeatLimit = 1) == \"zyxwvutsrqponmlkjihgfedcba\"\n    assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeefffffff\",repeatLimit = 3) == \"fffefffefeeedeeededddcdddcccbcccbcbbbabbbaaa\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 1) == \"z\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzyyyyyyyyyyyxxxxxxxxwwwwwwvvvvvvuuuuuuutttttttttssssrrrrqqqqqqqqpppponnnnmmmmlllkkkjjjiiiihhggggffffffeedddcccbba\",repeatLimit = 3) == \"zzzyzzzyzzzyzzzyzzzyyyxyyyxyxxxwxxxwwwvwwvvvuvvuuutuuutttstttsttssrrrqrqqqpqqqpqpponnnmnmmmlllkkkjjjiiihihgggfgfffeffedddcccbba\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzyyyyyyyyyyyxxxxxxxxwwwwwwvvvvvvuuuuuuutttttttttssssrrrrqqqqqqqqpppponnnnmmmmlllkkkjjjiiiihhggggffffffeedddcccbba\",repeatLimit = 10) == \"zzzzzzzzzzyzzzzzyyyyyyyyyyxxxxxxxxwwwwwwvvvvvvuuuuuuutttttttttssssrrrrqqqqqqqqpppponnnnmmmmlllkkkjjjiiiihhggggffffffeedddcccbba\"\n    assert candidate(s = \"xyzzzzzzzzzzyx\",repeatLimit = 5) == \"zzzzzyzzzzzyxx\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzyyyyyyyyyyyxxxxxxxxwwwwwwvvvvvvuuuuuuutttttttttssssrrrrqqqqqqqqpppponnnnmmmmlllkkkjjjiiiihhggggffffffeedddcccbba\",repeatLimit = 2) == \"zzyzzyzzyzzyzzyzzyzzyzyyxyyxxwxxwxxwxwwvwvvuvvuvuutuututtsttsttstsrrqrrqqpqqpqqpqponnmnnmmlmllkkjkjjiihiihggfggffeffefddcdccbba\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 5) == \"zzzzzyzzzzzxzzzzzwzzzzzvzzzzzuzzzzztzzzzzszzzzzrzzqponmlkjihgfedcba\"\n    assert candidate(s = \"nnnnnnnnnmmmmmmmmmllllllllllkkkkkkkkkkjjjjjjjjjjiiiiiiiiiihhhhhhhhhhggggggggggffffffeeeeeeeeddddddddccccccccbbbaaaaaaaa\",repeatLimit = 10) == \"nnnnnnnnnmmmmmmmmmllllllllllkkkkkkkkkkjjjjjjjjjjiiiiiiiiiihhhhhhhhhhggggggggggffffffeeeeeeeeddddddddccccccccbbbaaaaaaaa\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 5) == \"zzzzz\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 5) == \"zzzzz\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 5) == \"zzzzz\"\n    assert candidate(s = \"mnlkjihgfedcba\",repeatLimit = 1) == \"nmlkjihgfedcba\"\n    assert candidate(s = \"aaaaaaaaaaaabbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccdddddddddddddddddddddddddddddddddddddddddd\",repeatLimit = 5) == \"dddddcdddddcdddddcdddddcdddddcdddddcdddddcdddddcddcccccbcccccbcccccbcccccbbbbbabbbbbabbbbbabaaaaa\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 1) == \"z\"\n    assert candidate(s = \"pppppqqqqqrrrrrssssstttttuuuuuvvvvvwwwwwxxxxxyyyyyzzzzz\",repeatLimit = 2) == \"zzyzzyzyyxyxxwxxwwvwwvvuvvuutuuttsttssrssrrqrrqqpqqpp\"\n    assert candidate(s = \"aaaaaaaaaaaaaabbbbbbbbbbbbccccccccccccddddddddddddd\",repeatLimit = 3) == \"dddcdddcdddcdddcdcccbcccbccbbbabbbabbbabaaa\"\n    assert candidate(s = \"zzzzzyyyyxxxxwwvvuttrrssqqppoonnmmllkkjjiihhggffeeddccbbaaa\",repeatLimit = 10) == \"zzzzzyyyyxxxxwwvvuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaaa\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 3) == \"zzz\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 15) == \"zzzzzzzzzzzzzzz\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 10) == \"zzzzzzzzzz\"\n    assert candidate(s = \"zzzzzyyyyxxwwvvuuuutttssrrqqppoonnmmllkkjjiihhhggffeeddccbbaa\",repeatLimit = 2) == \"zzyzzyzyyxxwwvvuutuuttssrrqqppoonnmmllkkjjiihhghgffeeddccbbaa\"\n    assert candidate(s = \"abacabadabacaba\",repeatLimit = 2) == \"dccbbabbaa\"\n    assert candidate(s = \"ssssssssssssssssssssssssssssssss\",repeatLimit = 2) == \"ss\"\n    assert candidate(s = \"zzzzzzzyyyy\",repeatLimit = 3) == \"zzzyzzzyzyy\"\n    assert candidate(s = \"pppppppppppppppppppppppppppppppp\",repeatLimit = 3) == \"ppp\"\n    assert candidate(s = \"zzzzzyyyyxxxxwwvvuttrrssqqppoonnmmllkkjjiihhggffeeddccbbaaa\",repeatLimit = 2) == \"zzyzzyzyyxxwxxwvvuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 5) == \"zzzzz\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",repeatLimit = 4) == \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 10) == \"zzzzzzzzzz\"\n    assert candidate(s = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",repeatLimit = 7) == \"qqqqqqq\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",repeatLimit = 1) == \"z\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",repeatLimit = 1) == \"zyxwvutsrqponmlkjihgfedcba\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",repeatLimit = 3) == \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\"\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",repeatLimit = 10) == \"zyxwvutsrqponmlkjihgfedcba\"\n", "comparison": "exact"}, "public_tests": ["\"cczazcc\"\n3", "\"aababab\"\n2"], "hints": ["Start constructing the string in descending order of characters.", "When repeatLimit is reached, pick the next largest character."], "metadata": {"canonical_parameter_names": ["s", "repeatLimit"], "leetcode_dataset_entry_point": "Solution().repeatLimitedString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:43:59+00:00", "tests_total": 66, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string", "greedy", "heap-priority-queue", "counting"]}, "language": "python", "interface": {"raw_signature": "def repeatLimitedString(self, s: str, repeatLimit: int) -> str:", "container": "Solution", "callable": "repeatLimitedString", "parameters": [{"name": "s", "type": "str"}, {"name": "repeatLimit", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2183, "task_id": "count-array-pairs-divisible-by-k", "difficulty": "Hard", "problem_description": "Given a 0-indexed integer array nums of length n and an integer k, return the number of pairs (i, j) such that:\n\n- 0 <= i < j <= n - 1 and\n- nums[i] * nums[j] is divisible by k.\n\nExample 1:\n\nInput: nums = [1,2,3,4,5], k = 2\nOutput: 7\nExplanation:\nThe 7 pairs of indices whose corresponding products are divisible by 2 are\n(0, 1), (0, 3), (1, 2), (1, 3), (1, 4), (2, 3), and (3, 4).\nTheir products are 2, 4, 6, 8, 10, 12, and 20 respectively.\nOther pairs such as (0, 2) and (2, 4) have products 3 and 15 respectively, which are not divisible by 2.\n\nExample 2:\n\nInput: nums = [1,2,3,4], k = 5\nOutput: 0\nExplanation: There does not exist any pair of indices whose corresponding product is divisible by 5.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i], k <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [7, 7, 7, 7, 7],k = 7) == 10\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 10\n    assert candidate(nums = [5, 5, 5, 5],k = 5) == 6\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == 7\n    assert candidate(nums = [6, 12, 18, 24],k = 12) == 6\n    assert candidate(nums = [1, 3, 5, 7, 9],k = 3) == 7\n    assert candidate(nums = [7, 14, 21, 28, 35],k = 7) == 10\n    assert candidate(nums = [2, 4, 6, 8, 10],k = 3) == 4\n    assert candidate(nums = [10, 20, 30, 40],k = 10) == 6\n    assert candidate(nums = [5, 10, 15, 20, 25],k = 5) == 10\n    assert candidate(nums = [7, 14, 21, 28],k = 7) == 6\n    assert candidate(nums = [1, 3, 5, 7, 9],k = 2) == 0\n    assert candidate(nums = [2, 4, 6, 8, 10],k = 4) == 10\n    assert candidate(nums = [1, 2, 3, 4],k = 5) == 0\n    assert candidate(nums = [3, 5, 7, 11],k = 1) == 6\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 45\n    assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240],k = 12) == 190\n    assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],k = 101) == 45\n    assert candidate(nums = [100, 200, 300, 400, 500, 600],k = 100) == 15\n    assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 5) == 45\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 13) == 45\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 13) == 45\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 6) == 185\n    assert candidate(nums = [24, 48, 72, 96, 120],k = 24) == 10\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 9) == 45\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24],k = 3) == 28\n    assert candidate(nums = [5, 10, 15, 20, 25, 30],k = 5) == 15\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 1) == 190\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 190\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 45\n    assert candidate(nums = [8, 12, 18, 24, 30, 36, 42],k = 6) == 21\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 10\n    assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255],k = 17) == 105\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 45\n    assert candidate(nums = [15, 25, 35, 45, 55],k = 15) == 7\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 5) == 105\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195],k = 13) == 105\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 14) == 35\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132],k = 11) == 66\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 45\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77],k = 11) == 21\n    assert candidate(nums = [7, 14, 28, 56, 112],k = 14) == 10\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81],k = 9) == 36\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 100000) == 9\n    assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],k = 100000) == 15\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99],k = 9) == 55\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996],k = 5) == 4\n    assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],k = 8) == 45\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 17\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 4) == 45\n    assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170],k = 17) == 45\n    assert candidate(nums = [13, 26, 39, 52, 65],k = 13) == 10\n    assert candidate(nums = [6, 12, 18, 24, 30],k = 12) == 10\n    assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],k = 15) == 45\n    assert candidate(nums = [77, 154, 231, 308, 385, 462, 539, 616, 693, 770],k = 11) == 45\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],k = 9) == 66\n    assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],k = 21) == 45\n    assert candidate(nums = [6, 12, 18, 24, 30],k = 6) == 10\n    assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],k = 101) == 45\n    assert candidate(nums = [9, 18, 27, 36, 45],k = 9) == 10\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 16) == 101\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 190\n    assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],k = 21) == 45\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 1) == 190\n    assert candidate(nums = [49, 98, 147, 196, 245, 294, 343, 392, 441, 490],k = 49) == 45\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 11) == 45\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 9) == 45\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 0\n    assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190],k = 19) == 45\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 3) == 60\n    assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],k = 100) == 32\n    assert candidate(nums = [15, 30, 45, 60, 75, 90, 105],k = 15) == 21\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],k = 7) == 105\n    assert candidate(nums = [6, 8, 10, 12, 14, 16, 18],k = 12) == 15\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21],k = 3) == 21\n    assert candidate(nums = [8, 16, 32, 64, 128],k = 8) == 10\n    assert candidate(nums = [15, 30, 45, 60, 75],k = 15) == 10\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 3) == 112\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135],k = 9) == 105\n    assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90],k = 6) == 105\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 5) == 66\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 3) == 45\n    assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],k = 15) == 45\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],k = 2) == 300\n    assert candidate(nums = [15, 25, 35, 45, 55],k = 5) == 10\n    assert candidate(nums = [6, 12, 18, 24, 30, 36],k = 12) == 15\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 9) == 45\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 7) == 45\n    assert candidate(nums = [11, 22, 33, 44, 55],k = 11) == 10\n    assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120],k = 8) == 105\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260],k = 13) == 190\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 3) == 45\n    assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230],k = 23) == 45\n    assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64],k = 16) == 28\n    assert candidate(nums = [25, 50, 75, 100, 125, 150],k = 25) == 15\n    assert candidate(nums = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116],k = 11) == 37\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 3) == 34\n    assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],k = 5) == 44\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 20) == 10\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 11) == 45\n    assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96],k = 8) == 66\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5]\n2", "[1,2,3,4]\n5"], "hints": ["For any element in the array, what is the smallest number it should be multiplied with such that the product is divisible by k?", "The smallest number which should be multiplied with nums[i] so that the product is divisible by k is k / gcd(k, nums[i]). Now think about how you can store and update the count of such numbers present in the array efficiently."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:01+00:00", "tests_total": 102, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "math", "counting", "number-theory", "euclidean-algorithm", "greatest-common-divisor"]}, "language": "python", "interface": {"raw_signature": "def countPairs(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2185, "task_id": "counting-words-with-a-given-prefix", "difficulty": "Easy", "problem_description": "You are given an array of strings words and a string pref.\n\nReturn the number of strings in words that contain pref as a prefix.\n\nA prefix of a string s is any leading contiguous substring of s.\n\nExample 1:\n\nInput: words = [\"pay\",\"attention\",\"practice\",\"attend\"], pref = \"at\"\nOutput: 2\nExplanation: The 2 strings that contain \"at\" as a prefix are: \"attention\" and \"attend\".\n\nExample 2:\n\nInput: words = [\"leetcode\",\"win\",\"loops\",\"success\"], pref = \"code\"\nOutput: 0\nExplanation: There are no strings that contain \"code\" as a prefix.\n\nConstraints:\n\n- 1 <= words.length <= 100\n- 1 <= words[i].length, pref.length <= 100\n- words[i] and pref consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(words = ['test', 'testing', 'tested', 'testing'],pref = \"test\") == 4\n    assert candidate(words = ['abc', 'bcd', 'cde'],pref = \"a\") == 1\n    assert candidate(words = ['hello', 'world', 'helium', 'helper'],pref = \"hel\") == 3\n    assert candidate(words = ['banana', 'bandana', 'banner', 'balance'],pref = \"ban\") == 3\n    assert candidate(words = ['hello', 'hell', 'hero', 'herald'],pref = \"he\") == 4\n    assert candidate(words = ['pay', 'attention', 'practice', 'attend'],pref = \"at\") == 2\n    assert candidate(words = ['hello', 'world'],pref = \"hi\") == 0\n    assert candidate(words = ['hello', 'hell', 'helper'],pref = \"hel\") == 3\n    assert candidate(words = ['apple', 'apricot', 'application'],pref = \"app\") == 2\n    assert candidate(words = ['apple', 'apricot', 'application', 'appetite'],pref = \"app\") == 3\n    assert candidate(words = ['cat', 'caterpillar', 'catalog', 'category'],pref = \"cat\") == 4\n    assert candidate(words = ['apple', 'apricot', 'banana', 'apex'],pref = \"ap\") == 3\n    assert candidate(words = ['banana', 'band', 'ball'],pref = \"ba\") == 3\n    assert candidate(words = ['banana', 'bandana', 'baptism'],pref = \"ban\") == 2\n    assert candidate(words = ['apple', 'application', 'apricot', 'apex'],pref = \"ap\") == 4\n    assert candidate(words = ['leetcode', 'win', 'loops', 'success'],pref = \"code\") == 0\n    assert candidate(words = ['database', 'datacenter', 'datamine', 'data'],pref = \"data\") == 4\n    assert candidate(words = ['integration', 'integrate', 'interact', 'interactive'],pref = \"inte\") == 4\n    assert candidate(words = ['algorithm', 'array', 'application', 'arithmetic'],pref = \"arr\") == 1\n    assert candidate(words = ['intersection', 'interface', 'internal', 'interact'],pref = \"inter\") == 4\n    assert candidate(words = ['unpredictable', 'unpredicted', 'unpredictably', 'unpredicting'],pref = \"unpred\") == 4\n    assert candidate(words = ['prefix', 'prepend', 'presentation', 'preference'],pref = \"pre\") == 4\n    assert candidate(words = ['challenge', 'champion', 'chance', 'character'],pref = \"cha\") == 4\n    assert candidate(words = ['management', 'manager', 'manufacture', 'maintain'],pref = \"man\") == 3\n    assert candidate(words = ['interpolation', 'interpolate', 'interpolator', 'interpolated'],pref = \"inter\") == 4\n    assert candidate(words = ['technology', 'technique', 'technical', 'technological'],pref = \"tech\") == 4\n    assert candidate(words = ['universe', 'uniform', 'unique', 'unit'],pref = \"uni\") == 4\n    assert candidate(words = ['programming', 'python', 'problem', 'project', 'practice'],pref = \"pro\") == 3\n    assert candidate(words = ['document', 'documentation', 'documentary', 'documents'],pref = \"docu\") == 4\n    assert candidate(words = ['environment', 'envelope', 'encyclopedia', 'enterprise'],pref = \"env\") == 2\n    assert candidate(words = ['interview', 'international', 'internet', 'introduce'],pref = \"inter\") == 3\n    assert candidate(words = ['communication', 'community', 'commemoration', 'commentary'],pref = \"comm\") == 4\n    assert candidate(words = ['algorithm', 'array', 'application', 'apricot'],pref = \"app\") == 1\n    assert candidate(words = ['cryptography', 'cryptanalysis', 'cryptographic', 'cryptology'],pref = \"crypto\") == 3\n    assert candidate(words = ['interact', 'interaction', 'interactive', 'interior', 'intercept'],pref = \"inter\") == 5\n    assert candidate(words = ['fantastic', 'fancy', 'fantasy', 'fanatic'],pref = \"fan\") == 4\n    assert candidate(words = ['pseudo', 'pseudocode', 'pseudorandom', 'pseudoscience'],pref = \"pseudo\") == 4\n    assert candidate(words = ['mathematical', 'mathematics', 'mathematically', 'mathematize'],pref = \"math\") == 4\n    assert candidate(words = ['programming', 'problem', 'prefix', 'preference'],pref = \"pre\") == 2\n    assert candidate(words = ['biography', 'biologist', 'biological', 'biographical'],pref = \"bio\") == 4\n    assert candidate(words = ['unbelievable', 'universe', 'unique', 'unanimous'],pref = \"un\") == 4\n    assert candidate(words = ['congratulations', 'congratulate', 'congratulatory', 'congregate', 'congruity'],pref = \"cong\") == 5\n    assert candidate(words = ['supplementary', 'supplement', 'supplier', 'suppose'],pref = \"sup\") == 4\n    assert candidate(words = ['community', 'commune', 'communicate', 'common'],pref = \"comm\") == 4\n    assert candidate(words = ['extraterrestrial', 'extraterrestrial', 'extraterrestrial', 'extraterrestrial'],pref = \"extra\") == 4\n    assert candidate(words = ['algorithm', 'array', 'application', 'applet'],pref = \"app\") == 2\n    assert candidate(words = ['abracadabra', 'abstract', 'absorb', 'academic'],pref = \"abs\") == 2\n    assert candidate(words = ['congruence', 'congruent', 'congruently', 'congruency'],pref = \"congru\") == 4\n    assert candidate(words = ['meticulous', 'meticulate', 'metaphor', 'metaphysics'],pref = \"metic\") == 2\n    assert candidate(words = ['biological', 'biography', 'biologist', 'biology', 'bioluminescence'],pref = \"biol\") == 4\n    assert candidate(words = ['application', 'approach', 'appetizer', 'append'],pref = \"app\") == 4\n    assert candidate(words = ['scientific', 'scientist', 'science', 'sciences'],pref = \"sci\") == 4\n    assert candidate(words = ['communication', 'community', 'common', 'commodity'],pref = \"com\") == 4\n    assert candidate(words = ['quantization', 'quantize', 'quantitative', 'quantitative'],pref = \"quant\") == 4\n    assert candidate(words = ['prefix', 'prepend', 'presentation', 'premature'],pref = \"pre\") == 4\n    assert candidate(words = ['continuous', 'concurrent', 'conclusion', 'condition'],pref = \"con\") == 4\n    assert candidate(words = ['programming', 'program', 'pro', 'professor'],pref = \"pro\") == 4\n    assert candidate(words = ['management', 'manager', 'manage', 'mandate'],pref = \"man\") == 4\n    assert candidate(words = ['transformation', 'transmit', 'transparent', 'transient'],pref = \"tran\") == 4\n    assert candidate(words = ['administrator', 'administration', 'administrative', 'administratively'],pref = \"admin\") == 4\n    assert candidate(words = ['circumstance', 'circuit', 'circulate', 'circulation', 'circular'],pref = \"circu\") == 5\n    assert candidate(words = ['characterization', 'character', 'characteristic', 'characterization'],pref = \"char\") == 4\n    assert candidate(words = ['environment', 'envy', 'envelope', 'evening'],pref = \"env\") == 3\n    assert candidate(words = ['database', 'data', 'datagram', 'datastructure'],pref = \"data\") == 4\n    assert candidate(words = ['celebration', 'celebrate', 'celebrity', 'celebratory', 'celestial'],pref = \"celeb\") == 4\n    assert candidate(words = ['cryptography', 'crypt', 'crypto', 'cryptanalysis'],pref = \"crypt\") == 4\n    assert candidate(words = ['photography', 'photo', 'photobook', 'photographer'],pref = \"photo\") == 4\n    assert candidate(words = ['magnify', 'magnificent', 'magnetic', 'magnetism'],pref = \"mag\") == 4\n    assert candidate(words = ['organization', 'organize', 'organ', 'organically'],pref = \"org\") == 4\n    assert candidate(words = ['algorithm', 'algebra', 'almond', 'alert'],pref = \"alg\") == 2\n    assert candidate(words = ['algorithm', 'array', 'application', 'apple'],pref = \"app\") == 2\n    assert candidate(words = ['communication', 'community', 'commitment', 'common'],pref = \"comm\") == 4\n    assert candidate(words = ['developer', 'debug', 'deploy', 'document'],pref = \"de\") == 3\n    assert candidate(words = ['perpendicular', 'perpendicularity', 'perpendicularity', 'perpendicularly'],pref = \"perpendicular\") == 4\n    assert candidate(words = ['environment', 'engine', 'error', 'example'],pref = \"en\") == 2\n    assert candidate(words = ['university', 'uniform', 'unique', 'universe'],pref = \"uni\") == 4\n    assert candidate(words = ['community', 'communist', 'common', 'comment'],pref = \"comm\") == 4\n    assert candidate(words = ['literature', 'literacy', 'literary', 'literate'],pref = \"lit\") == 4\n    assert candidate(words = ['sequoia', 'sequence', 'series', 'serial'],pref = \"ser\") == 2\n    assert candidate(words = ['communication', 'community', 'companion', 'commune'],pref = \"comm\") == 3\n    assert candidate(words = ['algorithm', 'algebra', 'alignment', 'algorithmic'],pref = \"algo\") == 2\n    assert candidate(words = ['character', 'chart', 'chapter', 'charge'],pref = \"char\") == 3\n    assert candidate(words = ['transport', 'trap', 'trapezium', 'traverse'],pref = \"tra\") == 4\n    assert candidate(words = ['communication', 'commute', 'community', 'commotion', 'common'],pref = \"comm\") == 5\n    assert candidate(words = ['environment', 'energy', 'engage', 'engageable'],pref = \"en\") == 4\n    assert candidate(words = ['identification', 'individual', 'idea', 'illegal'],pref = \"iden\") == 1\n    assert candidate(words = ['supreme', 'superior', 'surpass', 'surround'],pref = \"sur\") == 2\n    assert candidate(words = ['transformation', 'transmit', 'transit', 'transformation', 'transition'],pref = \"trans\") == 5\n    assert candidate(words = ['automation', 'automatic', 'automate', 'auto'],pref = \"auto\") == 4\n    assert candidate(words = ['configuration', 'compute', 'container', 'cloud'],pref = \"con\") == 2\n    assert candidate(words = ['communication', 'community', 'commitment', 'compassionate'],pref = \"comm\") == 3\n    assert candidate(words = ['programming', 'program', 'pro', 'progress'],pref = \"pro\") == 4\n    assert candidate(words = ['absolutely', 'absolute', 'absorb', 'abnormal'],pref = \"abs\") == 3\n    assert candidate(words = ['statistics', 'statistical', 'statue', 'status'],pref = \"stat\") == 4\n    assert candidate(words = ['prefix', 'prefixes', 'preferring', 'preference'],pref = \"pref\") == 4\n    assert candidate(words = ['congratulations', 'congratulate', 'congratulatory', 'congratulated'],pref = \"congrat\") == 4\n    assert candidate(words = ['environment', 'essential', 'establish', 'engage'],pref = \"en\") == 2\n    assert candidate(words = ['substitution', 'substitute', 'substituted', 'substituting'],pref = \"sub\") == 4\n    assert candidate(words = ['distribution', 'distribute', 'disastrous', 'discuss', 'disease'],pref = \"dis\") == 5\n    assert candidate(words = ['development', 'deploy', 'debug', 'document'],pref = \"de\") == 3\n    assert candidate(words = ['super', 'superhero', 'supercalifragilisticexpialidocious', 'supervillain'],pref = \"super\") == 4\n    assert candidate(words = ['maintenance', 'maintain', 'maintenance', 'maintained'],pref = \"maint\") == 4\n    assert candidate(words = ['python', 'pyramid', 'pythia', 'pyrotechnic'],pref = \"pyt\") == 2\n    assert candidate(words = ['algorithm', 'algebra', 'alibi', 'alien', 'alimony'],pref = \"ali\") == 3\n    assert candidate(words = ['remarkable', 'remark', 'remember', 'remind'],pref = \"rem\") == 4\n    assert candidate(words = ['septagon', 'septagonal', 'septembre', 'septenary'],pref = \"sept\") == 4\n    assert candidate(words = ['programming', 'progress', 'prompt', 'priority'],pref = \"pro\") == 3\n    assert candidate(words = ['document', 'documentation', 'documentary', 'documents'],pref = \"doc\") == 4\n    assert candidate(words = ['monarch', 'monarchy', 'monarchic', 'monarchically'],pref = \"monarch\") == 4\n    assert candidate(words = ['hemisphere', 'hemispherical', 'hemispheres', 'hemispheric'],pref = \"hemis\") == 4\n    assert candidate(words = ['environment', 'engage', 'enhance', 'enforce', 'ensure'],pref = \"enf\") == 1\n    assert candidate(words = ['persistent', 'perspective', 'personality', 'person', 'personnel'],pref = \"pers\") == 5\n    assert candidate(words = ['prefix', 'preference', 'presentation', 'prevent', 'president'],pref = \"pre\") == 5\n    assert candidate(words = ['parallelogram', 'parallelepiped', 'parallel', 'parallelograms'],pref = \"parallel\") == 4\n    assert candidate(words = ['intelligence', 'integrate', 'intensity', 'interact'],pref = \"inte\") == 4\n    assert candidate(words = ['information', 'infrastructure', 'insurance', 'initial'],pref = \"in\") == 4\n    assert candidate(words = ['transport', 'transmit', 'transformation', 'transition'],pref = \"trans\") == 4\n    assert candidate(words = ['establish', 'estimate', 'essential', 'establishment'],pref = \"est\") == 3\n    assert candidate(words = ['algorithm', 'algebra', 'alchemist', 'alchemy'],pref = \"alg\") == 2\n    assert candidate(words = ['environment', 'envelope', 'engage', 'enhance'],pref = \"en\") == 4\n    assert candidate(words = ['transport', 'transmit', 'transit', 'transformation', 'transition'],pref = \"trans\") == 5\n    assert candidate(words = ['programming', 'problem', 'process', 'productivity'],pref = \"pro\") == 4\n    assert candidate(words = ['programming', 'pro', 'processor', 'productivity'],pref = \"pro\") == 4\n    assert candidate(words = ['encyclopedia', 'encyclopedias', 'encyclopedic', 'encyclopedically'],pref = \"ency\") == 4\n    assert candidate(words = ['apple', 'application', 'appetite', 'apparent'],pref = \"app\") == 4\n    assert candidate(words = ['zebra', 'zephyr', 'zoo', 'zealous'],pref = \"ze\") == 3\n    assert candidate(words = ['prefix', 'prefixes', 'preference', 'preferring'],pref = \"pref\") == 4\n    assert candidate(words = ['communication', 'community', 'commitment', 'commission'],pref = \"com\") == 4\n    assert candidate(words = ['hypothesis', 'historical', 'hyphen', 'hydrogen'],pref = \"hy\") == 3\n    assert candidate(words = ['transformation', 'transfer', 'transform', 'transformer'],pref = \"trans\") == 4\n    assert candidate(words = ['transaction', 'transfer', 'transition', 'transportation'],pref = \"tran\") == 4\n    assert candidate(words = ['abracadabra', 'abrakadabras', 'abracadabrac', 'abracadabrad'],pref = \"abrac\") == 3\n    assert candidate(words = ['interview', 'integrate', 'interaction', 'interface'],pref = \"inte\") == 4\n    assert candidate(words = ['fantastic', 'fantasy', 'fancy', 'fantastician'],pref = \"fant\") == 3\n    assert candidate(words = ['communication', 'communicate', 'communist', 'commune'],pref = \"comm\") == 4\n    assert candidate(words = ['environment', 'environ', 'environmental', 'envelope'],pref = \"env\") == 4\n    assert candidate(words = ['education', 'educational', 'educate', 'educator'],pref = \"edu\") == 4\n    assert candidate(words = ['automation', 'automobile', 'automatic', 'automate'],pref = \"auto\") == 4\n    assert candidate(words = ['customization', 'customize', 'custom', 'customarily'],pref = \"cust\") == 4\n    assert candidate(words = ['environment', 'encourage', 'endure', 'ensure'],pref = \"en\") == 4\n    assert candidate(words = ['prefix', 'predict', 'prevent', 'preach', 'prelude'],pref = \"pre\") == 5\n    assert candidate(words = ['elephant', 'elegant', 'elephantine', 'election'],pref = \"ele\") == 4\n    assert candidate(words = ['celebration', 'celebrity', 'celebratory', 'celebration'],pref = \"celeb\") == 4\n    assert candidate(words = ['achievement', 'achieve', 'achiever', 'achievable'],pref = \"achi\") == 4\n    assert candidate(words = ['development', 'debug', 'document', 'disk'],pref = \"de\") == 2\n    assert candidate(words = ['prefix', 'preference', 'prevent', 'president'],pref = \"pre\") == 4\n    assert candidate(words = ['automobile', 'automatic', 'automate', 'automaton'],pref = \"auto\") == 4\n    assert candidate(words = ['terrific', 'terrify', 'terrestrial', 'territory'],pref = \"terr\") == 4\n    assert candidate(words = ['synchronization', 'synchronous', 'synchronize', 'synchronized'],pref = \"synch\") == 4\n    assert candidate(words = ['abbreviation', 'abrupt', 'absorb', 'absolute'],pref = \"abs\") == 2\n    assert candidate(words = ['repetition', 'reproductive', 'represent', 'reputation', 'reprehend'],pref = \"rep\") == 5\n    assert candidate(words = ['apple', 'application', 'applicant', 'appetite'],pref = \"app\") == 4\n    assert candidate(words = ['xylophone', 'xylography', 'xylophone', 'xylophone'],pref = \"xy\") == 4\n", "comparison": "exact"}, "public_tests": ["[\"pay\",\"attention\",\"practice\",\"attend\"]\n\"at\"", "[\"leetcode\",\"win\",\"loops\",\"success\"]\n\"code\""], "hints": ["Go through each word in words and increment the answer if pref is a prefix of the word."], "metadata": {"canonical_parameter_names": ["words", "pref"], "leetcode_dataset_entry_point": "Solution().prefixCount", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:06+00:00", "tests_total": 153, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "string", "string-matching"]}, "language": "python", "interface": {"raw_signature": "def prefixCount(self, words: list[str], pref: str) -> int:", "container": "Solution", "callable": "prefixCount", "parameters": [{"name": "words", "type": "list[str]"}, {"name": "pref", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2186, "task_id": "minimum-number-of-steps-to-make-two-strings-anagram-ii", "difficulty": "Medium", "problem_description": "You are given two strings s and t. In one step, you can append any character to either s or t.\n\nReturn the minimum number of steps to make s and t anagrams of each other.\n\nAn anagram of a string is a string that contains the same characters with a different (or the same) ordering.\n\nExample 1:\n\nInput: s = \"leetcode\", t = \"coats\"\nOutput: 7\nExplanation:\n- In 2 steps, we can append the letters in \"as\" onto s = \"leetcode\", forming s = \"leetcodeas\".\n- In 5 steps, we can append the letters in \"leede\" onto t = \"coats\", forming t = \"coatsleede\".\n\"leetcodeas\" and \"coatsleede\" are now anagrams of each other.\nWe used a total of 2 + 5 = 7 steps.\nIt can be shown that there is no way to make them anagrams of each other with less than 7 steps.\n\nExample 2:\n\nInput: s = \"night\", t = \"thing\"\nOutput: 0\nExplanation: The given strings are already anagrams of each other. Thus, we do not need any further steps.\n\nConstraints:\n\n- 1 <= s.length, t.length <= 2 * 10^5\n- s and t consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"aaaa\",t = \"bbbb\") == 8\n    assert candidate(s = \"aabbcc\",t = \"abc\") == 3\n    assert candidate(s = \"anagram\",t = \"nagaram\") == 0\n    assert candidate(s = \"rat\",t = \"car\") == 2\n    assert candidate(s = \"xyz\",t = \"zyxwvut\") == 4\n    assert candidate(s = \"leetcode\",t = \"coats\") == 7\n    assert candidate(s = \"aaaaa\",t = \"bbbbb\") == 10\n    assert candidate(s = \"ab\",t = \"ba\") == 0\n    assert candidate(s = \"night\",t = \"thing\") == 0\n    assert candidate(s = \"abacabadaba\",t = \"zzzzz\") == 16\n    assert candidate(s = \"aa\",t = \"bb\") == 4\n    assert candidate(s = \"a\",t = \"a\") == 0\n    assert candidate(s = \"abcd\",t = \"dcba\") == 0\n    assert candidate(s = \"abc\",t = \"def\") == 6\n    assert candidate(s = \"a\",t = \"b\") == 2\n    assert candidate(s = \"abacabadabacaba\",t = \"abcde\") == 12\n    assert candidate(s = \"same\",t = \"same\") == 0\n    assert candidate(s = \"aabbccddeeff\",t = \"abcdef\") == 6\n    assert candidate(s = \"oneonetwothree\",t = \"threeonetwoone\") == 0\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"aaaaaaaaaaaaaaaaaaaaaaaaaa\") == 50\n    assert candidate(s = \"thisisateststring\",t = \"testingstring\") == 8\n    assert candidate(s = \"anagram\",t = \"mangaar\") == 0\n    assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",t = \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 88\n    assert candidate(s = \"hello\",t = \"world\") == 6\n    assert candidate(s = \"mississippi\",t = \"ississimppimiss\") == 4\n    assert candidate(s = \"pythonprogramming\",t = \"javaprogramming\") == 10\n    assert candidate(s = \"repeatrepeatrepeat\",t = \"peatpeatpeatre\") == 4\n    assert candidate(s = \"xxyyzz\",t = \"zzzzyyxx\") == 2\n    assert candidate(s = \"deified\",t = \"deified\") == 0\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",t = \"abcdefghijklmnopqrstuvwxyz\") == 0\n    assert candidate(s = \"pythonprogramming\",t = \"programmingpython\") == 0\n    assert candidate(s = \"thisisalongstringsample\",t = \"samplesamplealongstringthisis\") == 6\n    assert candidate(s = \"complexinputfortesting\",t = \"testingfortestingcomplex\") == 6\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzxxccvvaabbeeffgghhiijjkkllmmnnooppqqrrssttuuvvww\") == 6\n    assert candidate(s = \"abracadabra\",t = \"barbarian\") == 6\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 1\n    assert candidate(s = \"abracadabra\",t = \"abrakadabracadabra\") == 7\n    assert candidate(s = \"balancedstring\",t = \"stringbalanced\") == 0\n    assert candidate(s = \"abcdefghij\",t = \"abcdefghijjihgfedcba\") == 10\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxy\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n    assert candidate(s = \"aaabbbccc\",t = \"bbbaaaccc\") == 0\n    assert candidate(s = \"thisisatest\",t = \"testthisis\") == 1\n    assert candidate(s = \"encyclopedia\",t = \"dictionary\") == 8\n    assert candidate(s = \"mississippi\",t = \"missisippi\") == 1\n    assert candidate(s = \"aaaaabbbbbcccccd\",t = \"dddddccccbbbbbaaaaa\") == 5\n    assert candidate(s = \"repeatedcharacterss\",t = \"charactersrepeatedss\") == 1\n    assert candidate(s = \"thisisananagram\",t = \"isananagramthis\") == 0\n    assert candidate(s = \"abcdefg\",t = \"hijklmn\") == 14\n    assert candidate(s = \"aaaabbbbccccdddd\",t = \"ddddccccbbbbaaaa\") == 0\n    assert candidate(s = \"rhinoceros\",t = \"orchestrer\") == 6\n    assert candidate(s = \"samecharacters\",t = \"characterssame\") == 0\n    assert candidate(s = \"onetwothreefourfivesixseveneightnine\",t = \"nineseveneightsixfvierthreeonotwo\") == 3\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyz\") == 1\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 0\n    assert candidate(s = \"anagram\",t = \"manga\") == 2\n    assert candidate(s = \"samestring\",t = \"samestring\") == 0\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"abcdefghijklmnopqrstuvwxyz\") == 26\n    assert candidate(s = \"thisisaverylongstringthatwearegoingtouseasourtestcase\",t = \"anotherlongstringthatwillbeusedasourtestcase\") == 17\n    assert candidate(s = \"uniquecharacters\",t = \"charactersunique\") == 0\n    assert candidate(s = \"elephant\",t = \"television\") == 8\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",t = \"abcdefghijklmnopqrstuvwxyz\") == 44\n    assert candidate(s = \"repeatedcharactersrepeated\",t = \"charactersrepeatedcharacters\") == 10\n    assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",t = \"doglazytheoverjumpsonbrowquickthe\") == 2\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n    assert candidate(s = \"abcd\",t = \"efghijklmnopqrstuvwxyz\") == 26\n    assert candidate(s = \"a\",t = \"abcdefghijklmnopqrstuvwxyz\") == 25\n    assert candidate(s = \"level\",t = \"level\") == 0\n    assert candidate(s = \"equalnumberofchars\",t = \"equalnumberofchars\") == 0\n    assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n    assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == 25\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 0\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",t = \"zzzzzzzzzzzzzzzzzzzz\") == 68\n    assert candidate(s = \"longstringwithrepeatedcharacters\",t = \"characterswithrepeatedlongstring\") == 0\n    assert candidate(s = \"uniquecharacters\",t = \"differentcharacters\") == 9\n    assert candidate(s = \"mississippi\",t = \"pensil\") == 11\n    assert candidate(s = \"xyxxyxyxyx\",t = \"yyxyxyxyxy\") == 4\n    assert candidate(s = \"abracadabra\",t = \"abracadabracadabra\") == 7\n    assert candidate(s = \"redder\",t = \"redder\") == 0\n    assert candidate(s = \"hello\",t = \"billion\") == 6\n    assert candidate(s = \"xylophone\",t = \"xylophon\") == 1\n    assert candidate(s = \"thqwhrwhrwhr\",t = \"tttttttttttt\") == 22\n    assert candidate(s = \"xylophone\",t = \"polyrhythm\") == 9\n    assert candidate(s = \"unique\",t = \"distinct\") == 10\n    assert candidate(s = \"mississippi\",t = \"pensylvania\") == 16\n    assert candidate(s = \"xyzxyzxyz\",t = \"abcabcabc\") == 18\n    assert candidate(s = \"racecar\",t = \"carrace\") == 0\n    assert candidate(s = \"abcdefg\",t = \"hijklmnopqrstuvwxyz\") == 26\n    assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",t = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 0\n    assert candidate(s = \"abcde\",t = \"fghij\") == 10\n    assert candidate(s = \"abcdabcdabcdabcd\",t = \"dcba\") == 12\n    assert candidate(s = \"longerstringwithmorecharacters\",t = \"shortstring\") == 19\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n    assert candidate(s = \"longerstringhere\",t = \"short\") == 11\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzzyyxxwwvvuuttssrrqqppoonnmlkkjjiihhggffeeeeddccbbaa\") == 5\n    assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",t = \"thequickbrownfoxjumpsoverthelazydog\") == 0\n    assert candidate(s = \"abcdefghijkllllllllllllmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 11\n    assert candidate(s = \"xxyyzz\",t = \"xxxyyyzzz\") == 3\n    assert candidate(s = \"elephant\",t = \"relevant\") == 4\n    assert candidate(s = \"pythonprogramming\",t = \"java\") == 19\n    assert candidate(s = \"mississippi\",t = \"pennsylvania\") == 17\n    assert candidate(s = \"aaaaa\",t = \"bbbbbbaaaaa\") == 6\n    assert candidate(s = \"rotor\",t = \"rotor\") == 0\n", "comparison": "exact"}, "public_tests": ["\"leetcode\"\n\"coats\"", "\"night\"\n\"thing\""], "hints": ["Notice that for anagrams, the order of the letters is irrelevant.", "For each letter, we can count its frequency in s and t.", "For each letter, its contribution to the answer is the absolute difference between its frequency in s and t."], "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().minSteps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:09+00:00", "tests_total": 110, "tests_dropped": 8, "flags": [], "topic_tags": ["hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def minSteps(self, s: str, t: str) -> int:", "container": "Solution", "callable": "minSteps", "parameters": [{"name": "s", "type": "str"}, {"name": "t", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2187, "task_id": "minimum-time-to-complete-trips", "difficulty": "Medium", "problem_description": "You are given an array time where time[i] denotes the time taken by the i^th bus to complete one trip.\n\nEach bus can make multiple trips successively; that is, the next trip can start immediately after completing the current trip. Also, each bus operates independently; that is, the trips of one bus do not influence the trips of any other bus.\n\nYou are also given an integer totalTrips, which denotes the number of trips all buses should make in total. Return the minimum time required for all buses to complete at least totalTrips trips.\n\nExample 1:\n\nInput: time = [1,2,3], totalTrips = 5\nOutput: 3\nExplanation:\n- At time t = 1, the number of trips completed by each bus are [1,0,0].\n  The total number of trips completed is 1 + 0 + 0 = 1.\n- At time t = 2, the number of trips completed by each bus are [2,1,0].\n  The total number of trips completed is 2 + 1 + 0 = 3.\n- At time t = 3, the number of trips completed by each bus are [3,1,1].\n  The total number of trips completed is 3 + 1 + 1 = 5.\nSo the minimum time needed for all buses to complete at least 5 trips is 3.\n\nExample 2:\n\nInput: time = [2], totalTrips = 1\nOutput: 2\nExplanation:\nThere is only one bus, and it will complete its first trip at t = 2.\nSo the minimum time needed to complete 1 trip is 2.\n\nConstraints:\n\n- 1 <= time.length <= 10^5\n- 1 <= time[i], totalTrips <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(time = [1, 2, 3],totalTrips = 5) == 3\n    assert candidate(time = [10000000],totalTrips = 10000000) == 100000000000000\n    assert candidate(time = [10, 20, 30],totalTrips = 100) == 550\n    assert candidate(time = [1, 1, 1, 1, 1],totalTrips = 100000) == 20000\n    assert candidate(time = [1, 1, 1, 1, 1],totalTrips = 10000) == 2000\n    assert candidate(time = [5, 10, 15],totalTrips = 9) == 30\n    assert candidate(time = [5, 10, 15],totalTrips = 10) == 30\n    assert candidate(time = [2],totalTrips = 1) == 2\n    assert candidate(time = [1, 1, 1, 1],totalTrips = 10) == 3\n    assert candidate(time = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],totalTrips = 15000) == 3000\n    assert candidate(time = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],totalTrips = 500) == 305\n    assert candidate(time = [7, 14, 21, 28, 35, 42],totalTrips = 100) == 294\n    assert candidate(time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],totalTrips = 50000) == 13900\n    assert candidate(time = [3, 6, 9, 12],totalTrips = 20) == 30\n    assert candidate(time = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],totalTrips = 100000) == 100000\n    assert candidate(time = [100, 200, 300, 400],totalTrips = 500) == 24000\n    assert candidate(time = [5, 8, 12, 16, 20],totalTrips = 100) == 195\n    assert candidate(time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],totalTrips = 100) == 36\n    assert candidate(time = [2, 3, 5, 7, 11, 13, 17, 19],totalTrips = 50) == 36\n    assert candidate(time = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],totalTrips = 50000) == 21408\n    assert candidate(time = [2, 3, 4, 5, 6, 7, 8, 9, 10],totalTrips = 50) == 28\n    assert candidate(time = [3, 5, 7, 9],totalTrips = 20) == 27\n    assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],totalTrips = 5000) == 17090\n    assert candidate(time = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],totalTrips = 1500) == 1539\n    assert candidate(time = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],totalTrips = 1000000) == 250000\n    assert candidate(time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],totalTrips = 5000) == 1392\n    assert candidate(time = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],totalTrips = 150) == 132\n    assert candidate(time = [100, 200, 300, 400, 500],totalTrips = 1500) == 65800\n    assert candidate(time = [10, 20, 30, 40, 50],totalTrips = 50) == 230\n    assert candidate(time = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],totalTrips = 1000000) == 500004\n    assert candidate(time = [1, 2, 4, 8, 16, 32, 64, 128],totalTrips = 1000) == 504\n    assert candidate(time = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],totalTrips = 5000) == 731\n    assert candidate(time = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],totalTrips = 10000) == 2500\n    assert candidate(time = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],totalTrips = 1000) == 655\n    assert candidate(time = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],totalTrips = 1000) == 500\n    assert candidate(time = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],totalTrips = 15000) == 6425\n    assert candidate(time = [3, 6, 9, 12],totalTrips = 25) == 36\n    assert candidate(time = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],totalTrips = 15000) == 46107\n    assert candidate(time = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],totalTrips = 5000) == 2500\n    assert candidate(time = [3, 6, 9, 12, 15],totalTrips = 20) == 30\n    assert candidate(time = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],totalTrips = 100) == 49\n    assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],totalTrips = 1000) == 3430\n    assert candidate(time = [1, 2, 4, 8, 16, 32, 64],totalTrips = 5000) == 2521\n    assert candidate(time = [100, 200, 300, 400, 500],totalTrips = 5000) == 219000\n    assert candidate(time = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],totalTrips = 10000) == 17080\n    assert candidate(time = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],totalTrips = 1023) == 512\n    assert candidate(time = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],totalTrips = 50000) == 17072000\n    assert candidate(time = [7, 14, 21, 28, 35],totalTrips = 30) == 98\n    assert candidate(time = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],totalTrips = 100) == 18\n    assert candidate(time = [10000000, 9999999, 9999998, 9999997, 9999996],totalTrips = 10000000) == 20000000000000\n    assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],totalTrips = 500) == 1720\n    assert candidate(time = [10000, 5000, 2500, 1250, 625],totalTrips = 1000000) == 322581250\n    assert candidate(time = [3, 6, 9, 12, 15],totalTrips = 25) == 36\n    assert candidate(time = [1, 2, 4, 8, 16, 32, 64],totalTrips = 1000) == 506\n    assert candidate(time = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],totalTrips = 10000) == 17080\n    assert candidate(time = [2, 5, 7, 10],totalTrips = 20) == 22\n    assert candidate(time = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],totalTrips = 1000) == 1400\n    assert candidate(time = [2, 4, 6, 8, 10, 12, 14],totalTrips = 70) == 56\n    assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],totalTrips = 10000) == 34160\n    assert candidate(time = [2, 5, 8, 11],totalTrips = 20) == 24\n    assert candidate(time = [3, 6, 9, 12, 15, 18],totalTrips = 100) == 126\n    assert candidate(time = [3, 9, 27, 81],totalTrips = 100) == 207\n    assert candidate(time = [100, 200, 300, 400, 500],totalTrips = 5000) == 219000\n    assert candidate(time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],totalTrips = 10000) == 3016\n    assert candidate(time = [100000, 200000, 300000, 400000, 500000],totalTrips = 1000000) == 43795700000\n    assert candidate(time = [3, 6, 9, 12],totalTrips = 20) == 30\n    assert candidate(time = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40],totalTrips = 1000) == 1372\n    assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],totalTrips = 20000) == 60300\n    assert candidate(time = [10000, 20000, 30000, 40000],totalTrips = 100000) == 480000000\n    assert candidate(time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],totalTrips = 100000) == 34144\n    assert candidate(time = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],totalTrips = 3000) == 1959\n    assert candidate(time = [100, 200, 300, 400, 500],totalTrips = 1000) == 43900\n    assert candidate(time = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],totalTrips = 25000) == 15072\n    assert candidate(time = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],totalTrips = 150) == 265\n    assert candidate(time = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630],totalTrips = 10000) == 126672\n    assert candidate(time = [7, 14, 21, 28, 35],totalTrips = 100) == 315\n    assert candidate(time = [10, 20, 30, 40, 50, 60],totalTrips = 100) == 420\n    assert candidate(time = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],totalTrips = 2500) == 5870\n    assert candidate(time = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],totalTrips = 200000) == 277965\n    assert candidate(time = [4, 8, 12, 16, 20],totalTrips = 50) == 92\n    assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],totalTrips = 10000) == 34160\n    assert candidate(time = [2, 3, 5, 7, 11],totalTrips = 30) == 25\n    assert candidate(time = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],totalTrips = 20000) == 88790\n    assert candidate(time = [1, 2, 4, 8, 16, 32, 64],totalTrips = 100000) == 50396\n    assert candidate(time = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],totalTrips = 200) == 96\n    assert candidate(time = [7, 14, 21, 28, 35, 42],totalTrips = 100) == 294\n    assert candidate(time = [2, 3, 5, 7],totalTrips = 20) == 18\n    assert candidate(time = [3, 6, 9, 12],totalTrips = 15) == 24\n    assert candidate(time = [7, 14, 21, 28, 35],totalTrips = 50) == 161\n    assert candidate(time = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],totalTrips = 500000) == 48814545\n    assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],totalTrips = 200) == 700\n    assert candidate(time = [10000, 20000, 30000],totalTrips = 100000) == 545460000\n    assert candidate(time = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],totalTrips = 1000000) == 550002\n    assert candidate(time = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],totalTrips = 1000000) == 403282\n    assert candidate(time = [7, 14, 21, 28],totalTrips = 25) == 84\n    assert candidate(time = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],totalTrips = 300) == 184\n    assert candidate(time = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],totalTrips = 100000) == 38597\n    assert candidate(time = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],totalTrips = 100000) == 50050\n    assert candidate(time = [1, 3, 7, 15],totalTrips = 30) == 21\n    assert candidate(time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],totalTrips = 1000) == 343\n    assert candidate(time = [4, 5, 6, 7, 8],totalTrips = 30) == 36\n    assert candidate(time = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],totalTrips = 200) == 490\n    assert candidate(time = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],totalTrips = 500) == 110\n", "comparison": "exact"}, "public_tests": ["[1,2,3]\n5", "[2]\n1"], "hints": ["For a given amount of time, how can we count the total number of trips completed by all buses within that time?", "Consider using binary search."], "metadata": {"canonical_parameter_names": ["time", "totalTrips"], "leetcode_dataset_entry_point": "Solution().minimumTime", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:12+00:00", "tests_total": 103, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "binary-search"]}, "language": "python", "interface": {"raw_signature": "def minimumTime(self, time: list[int], totalTrips: int) -> int:", "container": "Solution", "callable": "minimumTime", "parameters": [{"name": "time", "type": "list[int]"}, {"name": "totalTrips", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2188, "task_id": "minimum-time-to-finish-the-race", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array tires where tires[i] = [f_i, r_i] indicates that the i^th tire can finish its x^th successive lap in f_i * r_i^(x-1) seconds.\n\n- For example, if f_i = 3 and r_i = 2, then the tire would finish its 1^st lap in 3 seconds, its 2^nd lap in 3 * 2 = 6 seconds, its 3^rd lap in 3 * 2^2 = 12 seconds, etc.\n\nYou are also given an integer changeTime and an integer numLaps.\n\nThe race consists of numLaps laps and you may start the race with any tire. You have an unlimited supply of each tire and after every lap, you may change to any given tire (including the current tire type) if you wait changeTime seconds.\n\nReturn the minimum time to finish the race.\n\nExample 1:\n\nInput: tires = [[2,3],[3,4]], changeTime = 5, numLaps = 4\nOutput: 21\nExplanation:\nLap 1: Start with tire 0 and finish the lap in 2 seconds.\nLap 2: Continue with tire 0 and finish the lap in 2 * 3 = 6 seconds.\nLap 3: Change tires to a new tire 0 for 5 seconds and then finish the lap in another 2 seconds.\nLap 4: Continue with tire 0 and finish the lap in 2 * 3 = 6 seconds.\nTotal time = 2 + 6 + 5 + 2 + 6 = 21 seconds.\nThe minimum time to complete the race is 21 seconds.\n\nExample 2:\n\nInput: tires = [[1,10],[2,2],[3,4]], changeTime = 6, numLaps = 5\nOutput: 25\nExplanation:\nLap 1: Start with tire 1 and finish the lap in 2 seconds.\nLap 2: Continue with tire 1 and finish the lap in 2 * 2 = 4 seconds.\nLap 3: Change tires to a new tire 1 for 6 seconds and then finish the lap in another 2 seconds.\nLap 4: Continue with tire 1 and finish the lap in 2 * 2 = 4 seconds.\nLap 5: Change tires to tire 0 for 6 seconds then finish the lap in another 1 second.\nTotal time = 2 + 4 + 6 + 2 + 4 + 6 + 1 = 25 seconds.\nThe minimum time to complete the race is 25 seconds.\n\nConstraints:\n\n- 1 <= tires.length <= 10^5\n- tires[i].length == 2\n- 1 <= f_i, changeTime <= 10^5\n- 2 <= r_i <= 10^5\n- 1 <= numLaps <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(tires = [[2, 3], [3, 4]],changeTime = 5,numLaps = 4) == 21\n    assert candidate(tires = [[5, 2], [3, 3]],changeTime = 4,numLaps = 3) == 17\n    assert candidate(tires = [[5, 5], [3, 3]],changeTime = 10,numLaps = 6) == 56\n    assert candidate(tires = [[100000, 2]],changeTime = 100000,numLaps = 1000) == 199900000\n    assert candidate(tires = [[5, 2]],changeTime = 3,numLaps = 3) == 21\n    assert candidate(tires = [[10, 10], [5, 5], [2, 2]],changeTime = 5,numLaps = 3) == 13\n    assert candidate(tires = [[10, 5], [20, 2]],changeTime = 7,numLaps = 8) == 129\n    assert candidate(tires = [[1, 2]],changeTime = 3,numLaps = 1) == 1\n    assert candidate(tires = [[5, 5], [10, 2]],changeTime = 7,numLaps = 3) == 29\n    assert candidate(tires = [[10, 5], [2, 2]],changeTime = 1,numLaps = 10) == 29\n    assert candidate(tires = [[5, 2]],changeTime = 3,numLaps = 2) == 13\n    assert candidate(tires = [[1, 10], [2, 2], [3, 4]],changeTime = 6,numLaps = 5) == 25\n    assert candidate(tires = [[1, 2]],changeTime = 3,numLaps = 10) == 27\n    assert candidate(tires = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],changeTime = 5,numLaps = 750) == 4495\n    assert candidate(tires = [[2, 3], [3, 4], [5, 6], [7, 8]],changeTime = 5,numLaps = 15) == 93\n    assert candidate(tires = [[1, 100000], [2, 90000], [3, 80000], [4, 70000], [5, 60000], [6, 50000], [7, 40000], [8, 30000], [9, 20000], [10, 10000]],changeTime = 100000,numLaps = 1000) == 99900500\n    assert candidate(tires = [[10, 5], [2, 2], [3, 3]],changeTime = 6,numLaps = 20) == 114\n    assert candidate(tires = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],changeTime = 1,numLaps = 900) == 1799\n    assert candidate(tires = [[1, 5], [2, 3], [3, 2]],changeTime = 7,numLaps = 15) == 92\n    assert candidate(tires = [[1, 2], [1, 3], [1, 4], [1, 5]],changeTime = 1,numLaps = 50) == 99\n    assert candidate(tires = [[5, 3], [2, 8], [7, 2]],changeTime = 5,numLaps = 200) == 1395\n    assert candidate(tires = [[100, 100], [200, 200], [300, 300]],changeTime = 50,numLaps = 1000) == 149950\n    assert candidate(tires = [[2, 10], [3, 9], [4, 8], [5, 7], [6, 6], [7, 5], [8, 4], [9, 3], [10, 2]],changeTime = 5,numLaps = 500) == 3495\n    assert candidate(tires = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]],changeTime = 20,numLaps = 500) == 12480\n    assert candidate(tires = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],changeTime = 5,numLaps = 50) == 195\n    assert candidate(tires = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],changeTime = 50,numLaps = 750) == 12100\n    assert candidate(tires = [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],changeTime = 10,numLaps = 999) == 8984\n    assert candidate(tires = [[1, 2], [3, 4], [5, 6]],changeTime = 10,numLaps = 15) == 75\n    assert candidate(tires = [[2, 3], [3, 4], [1, 5]],changeTime = 5,numLaps = 10) == 50\n    assert candidate(tires = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],changeTime = 10,numLaps = 25) == 190\n    assert candidate(tires = [[2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8]],changeTime = 7,numLaps = 50) == 318\n    assert candidate(tires = [[100, 2], [200, 3], [300, 4], [400, 5]],changeTime = 150,numLaps = 600) == 134850\n    assert candidate(tires = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],changeTime = 10,numLaps = 1000) == 7990\n    assert candidate(tires = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],changeTime = 1,numLaps = 1000) == 1999\n    assert candidate(tires = [[1000, 2], [500, 3], [250, 4]],changeTime = 500,numLaps = 100) == 74500\n    assert candidate(tires = [[5, 3], [7, 4], [2, 2]],changeTime = 10,numLaps = 20) == 150\n    assert candidate(tires = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6]],changeTime = 5,numLaps = 500) == 5495\n    assert candidate(tires = [[1, 2], [1, 3], [1, 4], [1, 5]],changeTime = 1,numLaps = 100) == 199\n    assert candidate(tires = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],changeTime = 100000,numLaps = 1) == 1\n    assert candidate(tires = [[1, 10000], [2, 5000], [3, 1000], [4, 500], [5, 250], [6, 125], [7, 62], [8, 31], [9, 15], [10, 7]],changeTime = 1000,numLaps = 1000) == 522400\n    assert candidate(tires = [[1, 10], [2, 5], [3, 3]],changeTime = 15,numLaps = 500) == 6485\n    assert candidate(tires = [[1, 10], [2, 2], [3, 4], [4, 5]],changeTime = 5,numLaps = 30) == 160\n    assert candidate(tires = [[100, 100], [200, 50], [300, 25]],changeTime = 100,numLaps = 300) == 59900\n    assert candidate(tires = [[10, 10], [20, 20], [30, 30]],changeTime = 50,numLaps = 750) == 44950\n    assert candidate(tires = [[2, 2], [3, 2], [4, 2], [5, 2], [6, 2]],changeTime = 10,numLaps = 500) == 3990\n    assert candidate(tires = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],changeTime = 15,numLaps = 50) == 470\n    assert candidate(tires = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],changeTime = 5,numLaps = 15) == 55\n    assert candidate(tires = [[3, 5], [2, 3], [4, 4]],changeTime = 10,numLaps = 15) == 128\n    assert candidate(tires = [[5, 10], [3, 3], [2, 2]],changeTime = 10,numLaps = 20) == 150\n    assert candidate(tires = [[100000, 100000], [50000, 50000], [25000, 25000], [12500, 12500], [6250, 6250]],changeTime = 100000,numLaps = 1000) == 106150000\n    assert candidate(tires = [[100, 10], [50, 5], [25, 2]],changeTime = 20,numLaps = 1000) == 44980\n    assert candidate(tires = [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],changeTime = 3,numLaps = 40) == 197\n    assert candidate(tires = [[10, 10], [20, 20], [30, 30]],changeTime = 100,numLaps = 50) == 5150\n    assert candidate(tires = [[1, 2], [2, 3], [3, 4], [4, 5]],changeTime = 1,numLaps = 1) == 1\n    assert candidate(tires = [[10000, 2], [5000, 3], [1000, 4], [500, 5], [250, 6], [125, 7], [62, 8], [31, 9], [15, 10], [7, 11]],changeTime = 10000,numLaps = 1000) == 3639260\n    assert candidate(tires = [[3, 2], [4, 3], [5, 4], [6, 5], [7, 6]],changeTime = 15,numLaps = 30) == 345\n    assert candidate(tires = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]],changeTime = 5,numLaps = 200) == 795\n    assert candidate(tires = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],changeTime = 10,numLaps = 1000) == 14990\n    assert candidate(tires = [[1, 2], [1, 3], [1, 4], [1, 5]],changeTime = 5,numLaps = 15) == 55\n    assert candidate(tires = [[5, 2], [8, 3], [1, 2]],changeTime = 20,numLaps = 20) == 155\n    assert candidate(tires = [[5, 2], [10, 2], [15, 2]],changeTime = 20,numLaps = 1000) == 17480\n    assert candidate(tires = [[9, 9], [8, 8], [7, 7], [6, 6], [5, 5]],changeTime = 10,numLaps = 800) == 11990\n    assert candidate(tires = [[2, 3], [5, 7], [8, 9]],changeTime = 5,numLaps = 20) == 125\n    assert candidate(tires = [[5, 3], [10, 2], [2, 6]],changeTime = 7,numLaps = 15) == 128\n    assert candidate(tires = [[5, 2], [3, 3], [4, 4]],changeTime = 10,numLaps = 20) == 210\n    assert candidate(tires = [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],changeTime = 7,numLaps = 60) == 443\n    assert candidate(tires = [[1, 2], [2, 3], [3, 4], [4, 5]],changeTime = 5,numLaps = 30) == 115\n    assert candidate(tires = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]],changeTime = 1,numLaps = 1000) == 1999\n    assert candidate(tires = [[50, 50], [25, 25], [10, 10], [5, 5], [2, 2]],changeTime = 25,numLaps = 750) == 9725\n    assert candidate(tires = [[100000, 2], [50000, 3]],changeTime = 50000,numLaps = 500) == 49950000\n    assert candidate(tires = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],changeTime = 5,numLaps = 50) == 195\n    assert candidate(tires = [[3, 5], [5, 3], [7, 2]],changeTime = 15,numLaps = 200) == 3285\n    assert candidate(tires = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2]],changeTime = 10,numLaps = 200) == 1125\n    assert candidate(tires = [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],changeTime = 20,numLaps = 800) == 11180\n    assert candidate(tires = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],changeTime = 5,numLaps = 50) == 195\n    assert candidate(tires = [[10, 10], [5, 5], [1, 2]],changeTime = 5,numLaps = 30) == 115\n    assert candidate(tires = [[1, 100000], [2, 50000], [3, 25000], [4, 10000], [5, 5000]],changeTime = 100000,numLaps = 1000) == 62402500\n    assert candidate(tires = [[10, 10], [20, 20], [30, 30]],changeTime = 15,numLaps = 100) == 2485\n    assert candidate(tires = [[1, 10], [2, 20], [3, 30], [4, 40]],changeTime = 100,numLaps = 500) == 27650\n    assert candidate(tires = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2]],changeTime = 100,numLaps = 900) == 23480\n    assert candidate(tires = [[1000, 1000], [1000, 1000], [1000, 1000]],changeTime = 100000,numLaps = 1000) == 100900000\n    assert candidate(tires = [[2, 3], [5, 7], [3, 4]],changeTime = 8,numLaps = 100) == 792\n    assert candidate(tires = [[2, 5], [3, 4], [4, 3]],changeTime = 10,numLaps = 100) == 1090\n    assert candidate(tires = [[1, 10], [2, 5], [3, 2]],changeTime = 10,numLaps = 999) == 9482\n    assert candidate(tires = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],changeTime = 25,numLaps = 1000) == 27475\n    assert candidate(tires = [[1, 100], [2, 50], [3, 25], [4, 10]],changeTime = 5,numLaps = 50) == 295\n    assert candidate(tires = [[1, 2], [1, 3], [1, 4]],changeTime = 5,numLaps = 50) == 195\n    assert candidate(tires = [[7, 2], [6, 3], [5, 4], [4, 5], [3, 6], [2, 7], [1, 8]],changeTime = 8,numLaps = 100) == 842\n    assert candidate(tires = [[5, 2], [4, 3], [3, 4], [2, 5]],changeTime = 1,numLaps = 999) == 2996\n    assert candidate(tires = [[1000, 100], [500, 50], [250, 25], [100, 10], [50, 5]],changeTime = 500,numLaps = 500) == 199500\n    assert candidate(tires = [[2, 2], [3, 3], [4, 4]],changeTime = 10,numLaps = 25) == 190\n    assert candidate(tires = [[100, 100], [50, 50], [25, 25], [10, 10]],changeTime = 20,numLaps = 50) == 1480\n    assert candidate(tires = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],changeTime = 1,numLaps = 1000) == 1999\n    assert candidate(tires = [[2, 5], [1, 3], [3, 2], [2, 4]],changeTime = 7,numLaps = 30) == 158\n    assert candidate(tires = [[1, 2], [2, 3], [3, 4], [4, 5]],changeTime = 2,numLaps = 100) == 248\n    assert candidate(tires = [[1, 2], [1, 2], [1, 2], [1, 2]],changeTime = 10,numLaps = 50) == 275\n    assert candidate(tires = [[100000, 100000]],changeTime = 100000,numLaps = 1000) == 199900000\n    assert candidate(tires = [[1, 1000], [2, 500], [3, 250]],changeTime = 50,numLaps = 20) == 970\n", "comparison": "exact"}, "public_tests": ["[[2,3],[3,4]]\n5\n4", "[[1,10],[2,2],[3,4]]\n6\n5"], "hints": ["What is the maximum number of times we would want to go around the track without changing tires?", "Can we precompute the minimum time to go around the track x times without changing tires?", "Can we use dynamic programming to solve this efficiently using the precomputed values?"], "metadata": {"canonical_parameter_names": ["tires", "changeTime", "numLaps"], "leetcode_dataset_entry_point": "Solution().minimumFinishTime", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:14+00:00", "tests_total": 100, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def minimumFinishTime(self, tires: list[list[int]], changeTime: int, numLaps: int) -> int:", "container": "Solution", "callable": "minimumFinishTime", "parameters": [{"name": "tires", "type": "list[list[int]]"}, {"name": "changeTime", "type": "int"}, {"name": "numLaps", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2190, "task_id": "most-frequent-number-following-key-in-an-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums. You are also given an integer key, which is present in nums.\n\nFor every unique integer target in nums, count the number of times target immediately follows an occurrence of key in nums. In other words, count the number of indices i such that:\n\n- 0 <= i <= nums.length - 2,\n- nums[i] == key and,\n- nums[i + 1] == target.\n\nReturn the target with the maximum count. The test cases will be generated such that the target with maximum count is unique.\n\nExample 1:\n\nInput: nums = [1,100,200,1,100], key = 1\nOutput: 100\nExplanation: For target = 100, there are 2 occurrences at indices 1 and 4 which follow an occurrence of key.\nNo other integers follow an occurrence of key, so we return 100.\n\nExample 2:\n\nInput: nums = [2,2,2,2,3], key = 2\nOutput: 2\nExplanation: For target = 2, there are 3 occurrences at indices 1, 2, and 3 which follow an occurrence of key.\nFor target = 3, there is only one occurrence at index 4 which follows an occurrence of key.\ntarget = 2 has the maximum number of occurrences following an occurrence of key, so we return 2.\n\nConstraints:\n\n- 2 <= nums.length <= 1000\n- 1 <= nums[i] <= 1000\n- The test cases will be generated such that the answer is unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],key = 1) == 2\n    assert candidate(nums = [1, 2, 2, 3, 2, 1, 2, 4],key = 2) == 2\n    assert candidate(nums = [3, 1, 3, 1, 3, 1, 3, 1, 3, 2],key = 1) == 3\n    assert candidate(nums = [10, 20, 20, 10, 10, 30, 20, 10],key = 10) == 20\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],key = 5) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2],key = 1) == 2\n    assert candidate(nums = [2, 2, 2, 2, 3],key = 2) == 2\n    assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],key = 5) == 1\n    assert candidate(nums = [5, 1, 5, 1, 5, 1, 5],key = 5) == 1\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3],key = 3) == 3\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3],key = 1) == 2\n    assert candidate(nums = [5, 1, 4, 1, 5, 1, 4, 1, 5],key = 1) == 4\n    assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 1, 2, 1],key = 1) == 2\n    assert candidate(nums = [1, 3, 2, 3, 2, 1, 3, 2, 1],key = 3) == 2\n    assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4],key = 5) == 1\n    assert candidate(nums = [1, 100, 200, 1, 100],key = 1) == 100\n    assert candidate(nums = [500, 100, 500, 200, 500, 300, 500, 400, 500, 500, 500, 600],key = 500) == 500\n    assert candidate(nums = [666, 111, 666, 222, 666, 333, 666, 444, 666, 555, 666, 111, 666, 222, 666, 333, 666, 444, 666, 555, 666, 111, 666, 222, 666, 333, 666, 444, 666, 555],key = 666) == 111\n    assert candidate(nums = [9, 5, 9, 9, 1, 9, 5, 9, 5, 5],key = 9) == 5\n    assert candidate(nums = [10, 20, 30, 10, 20, 10, 30, 10, 20, 10, 30, 10, 20, 10, 30],key = 10) == 20\n    assert candidate(nums = [11, 22, 33, 44, 11, 22, 33, 44, 11, 22, 33, 44, 11],key = 11) == 22\n    assert candidate(nums = [100, 200, 100, 300, 100, 200, 100, 400, 100, 500, 100, 600, 100, 700],key = 100) == 200\n    assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 1, 5, 2, 5, 3, 5, 4, 5, 1, 5, 2],key = 5) == 1\n    assert candidate(nums = [7, 8, 9, 7, 8, 7, 9, 7, 8, 7, 8, 7, 8, 7, 9],key = 7) == 8\n    assert candidate(nums = [4, 6, 4, 4, 4, 3, 4, 6, 4, 4, 6, 4],key = 4) == 4\n    assert candidate(nums = [7, 3, 7, 4, 7, 5, 7, 6, 7, 3, 7, 4],key = 7) == 3\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],key = 5) == 5\n    assert candidate(nums = [10, 11, 10, 12, 10, 13, 10, 14, 10, 15, 10, 16, 10, 17, 10, 18],key = 10) == 11\n    assert candidate(nums = [8, 2, 8, 3, 8, 4, 8, 5, 8, 6, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],key = 8) == 8\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 1) == 2\n    assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10],key = 1) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],key = 1) == 2\n    assert candidate(nums = [99, 88, 77, 66, 55, 99, 88, 77, 66, 55, 99, 88, 77, 66],key = 99) == 88\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1],key = 9) == 1\n    assert candidate(nums = [4, 5, 4, 6, 4, 7, 4, 8, 4, 9, 4, 10, 4, 11, 4, 12, 4, 13, 4, 14],key = 4) == 5\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2],key = 1) == 1\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1],key = 1) == 1\n    assert candidate(nums = [123, 456, 123, 789, 123, 456, 123, 789, 123, 456, 123, 789, 123, 456, 123, 789, 123, 456, 123, 789, 123, 456, 123, 789, 123, 456, 123, 789],key = 123) == 456\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],key = 3) == 3\n    assert candidate(nums = [11, 22, 11, 33, 11, 44, 11, 55, 11, 66, 11, 77, 11, 88, 11, 99, 11, 100, 11, 111],key = 11) == 22\n    assert candidate(nums = [42, 10, 42, 20, 42, 30, 42, 10, 42, 20, 42, 30, 42, 10],key = 42) == 10\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3],key = 3) == 3\n    assert candidate(nums = [3, 3, 3, 4, 4, 4, 3, 4, 3, 4, 3, 3, 4, 3, 3, 3, 4, 3, 3, 3, 3, 4, 3, 3, 3, 4, 3, 3],key = 3) == 3\n    assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500],key = 100) == 200\n    assert candidate(nums = [3, 7, 3, 8, 3, 7, 3, 8, 3, 9],key = 3) == 7\n    assert candidate(nums = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300, 100],key = 100) == 200\n    assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990],key = 999) == 998\n    assert candidate(nums = [42, 84, 42, 168, 42, 210, 42, 252, 42, 294, 42, 336],key = 42) == 84\n    assert candidate(nums = [7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3, 7, 3, 3],key = 7) == 3\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8],key = 7) == 7\n    assert candidate(nums = [7, 3, 7, 7, 4, 7, 3, 7, 3, 7, 5],key = 7) == 3\n    assert candidate(nums = [9, 3, 9, 5, 9, 3, 9, 5, 9, 2, 9],key = 9) == 3\n    assert candidate(nums = [42, 13, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 13],key = 42) == 42\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],key = 1) == 2\n    assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10],key = 1) == 2\n    assert candidate(nums = [500, 400, 300, 200, 100, 500, 400, 300, 200, 100, 500, 400],key = 500) == 400\n    assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50],key = 10) == 20\n    assert candidate(nums = [6, 7, 8, 9, 10, 6, 7, 8, 9, 10, 6, 7, 8, 9, 10, 6, 7, 8, 9, 10, 6],key = 6) == 7\n    assert candidate(nums = [3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1],key = 3) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],key = 5) == 6\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 1, 5, 9],key = 5) == 9\n    assert candidate(nums = [8, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 8, 1],key = 8) == 8\n    assert candidate(nums = [9, 1, 2, 9, 1, 2, 9, 1, 2, 9, 1, 2, 9, 1],key = 9) == 1\n    assert candidate(nums = [999, 1, 999, 2, 999, 3, 999, 4, 999, 5, 999, 1, 999, 2, 999, 3, 999, 4, 999, 5],key = 999) == 1\n    assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],key = 4) == 4\n    assert candidate(nums = [100, 200, 300, 100, 100, 200, 100, 300, 100, 200, 100, 300, 100],key = 100) == 200\n    assert candidate(nums = [500, 600, 500, 700, 500, 800, 500, 900, 500, 1000],key = 500) == 600\n    assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 5, 5, 6, 6, 6, 5, 6, 6, 6, 5, 6],key = 5) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 10) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5],key = 1) == 2\n    assert candidate(nums = [1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2],key = 1) == 1\n    assert candidate(nums = [500, 400, 300, 200, 100, 500, 400, 300, 200, 100, 500, 400, 300, 200, 100, 500, 400, 300, 200, 100],key = 500) == 400\n    assert candidate(nums = [200, 300, 200, 300, 200, 300, 200, 300, 200, 300, 200, 300, 200, 300, 200, 300, 200, 300, 200, 200],key = 200) == 300\n    assert candidate(nums = [7, 7, 7, 8, 9, 8, 10, 8, 7, 11, 7, 8, 8, 9],key = 7) == 7\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 1) == 2\n    assert candidate(nums = [10, 1, 10, 2, 10, 3, 10, 4, 10, 5, 10, 6, 10, 7, 10, 8, 10, 9, 10, 1, 10, 2, 10, 3, 10, 4, 10, 5],key = 10) == 1\n    assert candidate(nums = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60],key = 10) == 20\n    assert candidate(nums = [6, 1, 6, 2, 6, 3, 6, 4, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],key = 6) == 6\n    assert candidate(nums = [3, 1, 9, 3, 1, 9, 3, 1, 9, 10],key = 3) == 1\n    assert candidate(nums = [7, 3, 7, 2, 7, 7, 3, 3, 2, 7],key = 7) == 3\n    assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43],key = 42) == 42\n    assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],key = 2) == 1\n    assert candidate(nums = [999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999],key = 999) == 1000\n    assert candidate(nums = [888, 999, 777, 888, 999, 777, 888, 999, 777, 888, 999, 777, 888, 999, 777, 888, 999, 777, 888, 999, 777, 888, 999, 777, 888, 999, 777, 888, 999],key = 888) == 999\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 10, 20, 30, 40, 50, 60, 70, 80, 90, 10, 90],key = 10) == 20\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 100, 200, 300, 400, 500, 600, 700, 800, 900, 100, 100],key = 100) == 200\n    assert candidate(nums = [15, 20, 15, 25, 15, 30, 15, 35, 15, 40, 15, 45, 15, 50, 15, 55, 15, 60, 15, 65, 15, 70, 15, 75, 15, 80, 15, 85, 15, 90, 15, 95, 15, 100],key = 15) == 20\n    assert candidate(nums = [666, 777, 666, 888, 666, 999, 666, 111, 666, 222, 666, 333, 666, 444, 666, 555],key = 666) == 777\n    assert candidate(nums = [555, 666, 555, 666, 555, 666, 555, 666, 555, 666, 555, 666, 555, 666, 555, 666, 555, 666, 555, 777],key = 555) == 666\n    assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 1],key = 1) == 2\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],key = 7) == 7\n    assert candidate(nums = [2, 3, 4, 3, 2, 3, 4, 5, 6, 4, 3, 2, 3, 4, 3, 3, 3, 4],key = 3) == 4\n    assert candidate(nums = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 30],key = 10) == 30\n    assert candidate(nums = [123, 456, 123, 789, 123, 101, 123, 102, 123, 103, 123, 104],key = 123) == 456\n    assert candidate(nums = [100, 200, 100, 300, 400, 500, 600, 100, 700, 800, 900, 100, 100, 100, 100, 100],key = 100) == 100\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9],key = 9) == 8\n    assert candidate(nums = [42, 99, 42, 55, 42, 99, 42, 66, 42, 55, 42, 99],key = 42) == 99\n    assert candidate(nums = [7, 11, 7, 11, 7, 11, 7, 8, 7, 9],key = 7) == 11\n    assert candidate(nums = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 50],key = 50) == 100\n    assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10],key = 10) == 20\n    assert candidate(nums = [999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 999, 1, 2, 3, 4, 5, 6, 7, 8, 999],key = 999) == 1\n", "comparison": "exact"}, "public_tests": ["[1,100,200,1,100]\n1", "[2,2,2,2,3]\n2"], "hints": ["Count the number of times each target value follows the key in the array.", "Choose the target with the maximum count and return it."], "metadata": {"canonical_parameter_names": ["nums", "key"], "leetcode_dataset_entry_point": "Solution().mostFrequent", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:19+00:00", "tests_total": 103, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "hash-table", "counting"]}, "language": "python", "interface": {"raw_signature": "def mostFrequent(self, nums: list[int], key: int) -> int:", "container": "Solution", "callable": "mostFrequent", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "key", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2191, "task_id": "sort-the-jumbled-numbers", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array mapping which represents the mapping rule of a shuffled decimal system. mapping[i] = j means digit i should be mapped to digit j in this system.\n\nThe mapped value of an integer is the new integer obtained by replacing each occurrence of digit i in the integer with mapping[i] for all 0 <= i <= 9.\n\nYou are also given another integer array nums. Return the array nums sorted in non-decreasing order based on the mapped values of its elements.\n\nNotes:\n\n- Elements with the same mapped values should appear in the same relative order as in the input.\n- The elements of nums should only be sorted based on their mapped values and not be replaced by them.\n\nExample 1:\n\nInput: mapping = [8,9,4,0,2,1,3,5,7,6], nums = [991,338,38]\nOutput: [338,38,991]\nExplanation:\nMap the number 991 as follows:\n1. mapping[9] = 6, so all occurrences of the digit 9 will become 6.\n2. mapping[1] = 9, so all occurrences of the digit 1 will become 9.\nTherefore, the mapped value of 991 is 669.\n338 maps to 007, or 7 after removing the leading zeros.\n38 maps to 07, which is also 7 after removing leading zeros.\nSince 338 and 38 share the same mapped value, they should remain in the same relative order, so 338 comes before 38.\nThus, the sorted array is [338,38,991].\n\nExample 2:\n\nInput: mapping = [0,1,2,3,4,5,6,7,8,9], nums = [789,456,123]\nOutput: [123,456,789]\nExplanation: 789 maps to 789, 456 maps to 456, and 123 maps to 123. Thus, the sorted array is [123,456,789].\n\nConstraints:\n\n- mapping.length == 10\n- 0 <= mapping[i] <= 9\n- All the values of mapping[i] are unique.\n- 1 <= nums.length <= 3 * 10^4\n- 0 <= nums[i] < 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(mapping = [5, 8, 9, 2, 1, 6, 7, 0, 3, 4],nums = [345, 123, 678]) == [345, 678, 123]\n    assert candidate(mapping = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5],nums = [10, 100, 1000, 10000]) == [10, 100, 1000, 10000]\n    assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [90, 12, 34]) == [90, 12, 34]\n    assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [10, 20, 30, 40, 50]) == [10, 20, 30, 40, 50]\n    assert candidate(mapping = [8, 9, 4, 0, 2, 1, 3, 5, 7, 6],nums = [991, 338, 38]) == [338, 38, 991]\n    assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [10, 20, 30]) == [30, 20, 10]\n    assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [123, 456, 789]) == [789, 456, 123]\n    assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [90, 81, 72]) == [90, 72, 81]\n    assert candidate(mapping = [5, 8, 9, 0, 1, 2, 3, 4, 6, 7],nums = [555, 888, 999]) == [555, 888, 999]\n    assert candidate(mapping = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums = [789, 456, 123]) == [123, 456, 789]\n    assert candidate(mapping = [5, 8, 1, 2, 9, 4, 6, 0, 3, 7],nums = [512, 345, 890]) == [345, 890, 512]\n    assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [100, 200, 300]) == [300, 200, 100]\n    assert candidate(mapping = [5, 8, 9, 2, 1, 6, 3, 7, 0, 4],nums = [12, 34, 56, 78, 90]) == [34, 90, 56, 78, 12]\n    assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [1234, 5678, 91011]) == [5678, 1234, 91011]\n    assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [12345, 67890, 11111]) == [67890, 12345, 11111]\n    assert candidate(mapping = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4],nums = [123, 456, 789]) == [789, 123, 456]\n    assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [10, 20, 30]) == [10, 20, 30]\n    assert candidate(mapping = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8],nums = [13579, 24680, 101010, 202020, 303030, 123123123]) == [13579, 101010, 24680, 303030, 202020, 123123123]\n    assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [999999999, 888888888, 777777777, 666666666, 555555555]) == [999999999, 888888888, 777777777, 666666666, 555555555]\n    assert candidate(mapping = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8],nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 0]) == [111, 0, 222, 333, 444, 555, 666, 777, 888, 999]\n    assert candidate(mapping = [5, 9, 8, 2, 7, 6, 3, 1, 4, 0],nums = [555, 999, 888, 222, 777, 666, 333, 111, 444, 0]) == [999, 0, 777, 333, 666, 888, 555, 444, 222, 111]\n    assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [101010, 202020, 303030, 404040, 505050]) == [505050, 404040, 303030, 202020, 101010]\n    assert candidate(mapping = [6, 5, 4, 3, 2, 1, 0, 9, 8, 7],nums = [654321, 123456, 987654]) == [654321, 123456, 987654]\n    assert candidate(mapping = [0, 2, 1, 4, 3, 6, 5, 8, 7, 9],nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == [222222222, 123456789, 111111111, 444444444, 333333333, 666666666, 555555555, 888888888, 777777777, 987654321, 999999999]\n    assert candidate(mapping = [5, 0, 1, 2, 3, 4, 6, 7, 8, 9],nums = [501234, 55555, 12345]) == [12345, 55555, 501234]\n    assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [987654321, 876543210, 765432109]) == [987654321, 765432109, 876543210]\n    assert candidate(mapping = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8],nums = [900, 899, 798, 697, 596, 495, 394, 293, 192, 91]) == [91, 192, 293, 394, 495, 596, 697, 798, 899, 900]\n    assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 0]) == [999, 0, 111, 222, 333, 444, 555, 666, 777, 888]\n    assert candidate(mapping = [2, 1, 4, 3, 6, 5, 8, 7, 0, 9],nums = [24680, 13579, 112233]) == [13579, 24680, 112233]\n    assert candidate(mapping = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6],nums = [543210, 109876, 210987, 678905, 432109]) == [543210, 432109, 210987, 109876, 678905]\n    assert candidate(mapping = [7, 6, 5, 4, 3, 2, 1, 0, 9, 8],nums = [7654321, 6543210, 5432109, 4321098, 3210987]) == [7654321, 6543210, 5432109, 4321098, 3210987]\n    assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [111111111, 222222222, 333333333, 444444444]) == [111111111, 222222222, 333333333, 444444444]\n    assert candidate(mapping = [0, 2, 1, 3, 4, 5, 6, 7, 8, 9],nums = [987654321, 123456789]) == [123456789, 987654321]\n    assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [123456789, 234567890, 345678901, 456789012]) == [123456789, 234567890, 345678901, 456789012]\n    assert candidate(mapping = [0, 2, 1, 4, 3, 6, 5, 8, 7, 9],nums = [123456789, 987654321, 43210]) == [43210, 123456789, 987654321]\n    assert candidate(mapping = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0],nums = [13579, 24680, 97531, 86420, 12345]) == [97531, 12345, 13579, 24680, 86420]\n    assert candidate(mapping = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums = [987654321, 123456789, 111111111]) == [987654321, 123456789, 111111111]\n    assert candidate(mapping = [0, 2, 1, 4, 3, 6, 5, 8, 7, 9],nums = [10000, 20001, 30002, 40003, 50004, 60005, 70006, 80007, 90008]) == [20001, 10000, 40003, 30002, 60005, 50004, 80007, 70006, 90008]\n    assert candidate(mapping = [2, 0, 4, 6, 8, 1, 3, 5, 7, 9],nums = [123456789, 987654321, 246801357]) == [123456789, 246801357, 987654321]\n    assert candidate(mapping = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5],nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == [2222, 4444, 6666, 8888, 9999, 7777, 5555, 3333, 1111]\n    assert candidate(mapping = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0],nums = [99999, 88888, 77777, 66666, 55555]) == [99999, 55555, 66666, 77777, 88888]\n    assert candidate(mapping = [3, 4, 5, 6, 7, 8, 9, 0, 1, 2],nums = [10000, 10001, 10010, 10100, 11000, 123456789, 987654321]) == [10000, 10001, 10010, 10100, 11000, 987654321, 123456789]\n    assert candidate(mapping = [9, 7, 5, 3, 1, 8, 6, 4, 2, 0],nums = [999, 777, 555, 333, 111, 888, 666, 444, 222, 0]) == [999, 0, 444, 888, 333, 777, 222, 666, 111, 555]\n    assert candidate(mapping = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9],nums = [13579, 24680, 11111, 22222]) == [11111, 13579, 22222, 24680]\n    assert candidate(mapping = [2, 0, 1, 3, 4, 5, 6, 7, 8, 9],nums = [20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == [21, 22, 20, 23, 24, 25, 26, 27, 28, 29]\n    assert candidate(mapping = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9],nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == [888, 777, 666, 555, 444, 333, 222, 111, 999]\n    assert candidate(mapping = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8],nums = [1122, 2233, 3344, 4455, 5566]) == [1122, 3344, 2233, 5566, 4455]\n    assert candidate(mapping = [8, 6, 4, 2, 0, 9, 7, 5, 3, 1],nums = [24680, 13579, 86420, 97531]) == [97531, 86420, 24680, 13579]\n    assert candidate(mapping = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums = [1, 10, 100, 1000, 10000, 100000]) == [1, 10, 100, 1000, 10000, 100000]\n    assert candidate(mapping = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 0]) == [999, 0, 111, 222, 333, 444, 555, 666, 777, 888]\n    assert candidate(mapping = [2, 0, 9, 1, 5, 6, 3, 8, 4, 7],nums = [1029, 2056, 3084, 4073]) == [1029, 3084, 4073, 2056]\n    assert candidate(mapping = [8, 3, 5, 2, 7, 1, 9, 4, 0, 6],nums = [321, 654, 987, 123, 456, 789]) == [321, 123, 789, 987, 456, 654]\n    assert candidate(mapping = [9, 0, 8, 1, 7, 2, 6, 3, 5, 4],nums = [999999999, 111111111, 123456789, 987654321, 135792468, 864201357]) == [111111111, 135792468, 123456789, 999999999, 987654321, 864201357]\n    assert candidate(mapping = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums = [123456789, 987654321, 111222333]) == [987654321, 123456789, 111222333]\n    assert candidate(mapping = [9, 7, 5, 3, 1, 8, 6, 4, 2, 0],nums = [97531, 86420, 13579]) == [97531, 86420, 13579]\n", "comparison": "exact"}, "public_tests": ["[8,9,4,0,2,1,3,5,7,6]\n[991,338,38]", "[0,1,2,3,4,5,6,7,8,9]\n[789,456,123]"], "hints": ["Map the original numbers to new numbers by the mapping rule and sort the new numbers.", "To maintain the same relative order for equal mapped values, use the index in the original input array as a tiebreaker."], "metadata": {"canonical_parameter_names": ["mapping", "nums"], "leetcode_dataset_entry_point": "Solution().sortJumbled", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:21+00:00", "tests_total": 110, "tests_dropped": 55, "flags": [], "topic_tags": ["array", "sorting"]}, "language": "python", "interface": {"raw_signature": "def sortJumbled(self, mapping: list[int], nums: list[int]) -> list[int]:", "container": "Solution", "callable": "sortJumbled", "parameters": [{"name": "mapping", "type": "list[int]"}, {"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2192, "task_id": "all-ancestors-of-a-node-in-a-directed-acyclic-graph", "difficulty": "Medium", "problem_description": "You are given a positive integer n representing the number of nodes of a Directed Acyclic Graph (DAG). The nodes are numbered from 0 to n - 1 (inclusive).\n\nYou are also given a 2D integer array edges, where edges[i] = [from_i, to_i] denotes that there is a unidirectional edge from from_i to to_i in the graph.\n\nReturn a list answer, where answer[i] is the list of ancestors of the i^th node, sorted in ascending order.\n\nA node u is an ancestor of another node v if u can reach v via a set of edges.\n\nExample 1:\n\nInput: n = 8, edgeList = [[0,3],[0,4],[1,3],[2,4],[2,7],[3,5],[3,6],[3,7],[4,6]]\nOutput: [[],[],[],[0,1],[0,2],[0,1,3],[0,1,2,3,4],[0,1,2,3]]\nExplanation:\nThe above diagram represents the input graph.\n- Nodes 0, 1, and 2 do not have any ancestors.\n- Node 3 has two ancestors 0 and 1.\n- Node 4 has two ancestors 0 and 2.\n- Node 5 has three ancestors 0, 1, and 3.\n- Node 6 has five ancestors 0, 1, 2, 3, and 4.\n- Node 7 has four ancestors 0, 1, 2, and 3.\n\nExample 2:\n\nInput: n = 5, edgeList = [[0,1],[0,2],[0,3],[0,4],[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]\nOutput: [[],[0],[0,1],[0,1,2],[0,1,2,3]]\nExplanation:\nThe above diagram represents the input graph.\n- Node 0 does not have any ancestor.\n- Node 1 has one ancestor 0.\n- Node 2 has two ancestors 0 and 1.\n- Node 3 has three ancestors 0, 1, and 2.\n- Node 4 has four ancestors 0, 1, 2, and 3.\n\nConstraints:\n\n- 1 <= n <= 1000\n- 0 <= edges.length <= min(2000, n * (n - 1) / 2)\n- edges[i].length == 2\n- 0 <= from_i, to_i <= n - 1\n- from_i != to_i\n- There are no duplicate edges.\n- The graph is directed and acyclic.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 6,edges = [[0, 2], [2, 3], [1, 3], [4, 5]]) == [[], [], [0], [0, 1, 2], [], [4]]\n    assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3]]) == [[], [0], [0, 1], [0, 1, 2]]\n    assert candidate(n = 8,edges = [[0, 3], [0, 4], [1, 3], [2, 4], [2, 7], [3, 5], [3, 6], [3, 7], [4, 6]]) == [[], [], [], [0, 1], [0, 2], [0, 1, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3]]\n    assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2]]\n    assert candidate(n = 3,edges = [[0, 1], [0, 2]]) == [[], [0], [0]]\n    assert candidate(n = 1,edges = []) == [[]]\n    assert candidate(n = 5,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3]]\n    assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4]]\n    assert candidate(n = 25,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 19], [14, 20], [15, 21], [16, 22], [17, 23], [18, 24]]) == [[], [0], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 3], [0, 3], [0, 1, 4], [0, 1, 5], [0, 2, 6], [0, 2, 7], [0, 3, 8], [0, 3, 9], [0, 1, 4, 10], [0, 1, 5, 11], [0, 2, 6, 12], [0, 2, 7, 13], [0, 3, 8, 14], [0, 3, 9, 15], [0, 1, 4, 10, 16], [0, 1, 5, 11, 17], [0, 2, 6, 12, 18]]\n    assert candidate(n = 12,edges = [[0, 3], [1, 3], [2, 3], [0, 4], [1, 4], [2, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 9], [8, 9], [9, 10], [10, 11]]) == [[], [], [], [0, 1, 2], [0, 1, 2], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n    assert candidate(n = 12,edges = [[0, 3], [1, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [6, 9], [7, 10], [8, 10], [9, 11]]) == [[], [], [], [0, 1], [2], [0, 1, 3], [0, 1, 3], [2, 4], [2, 4], [0, 1, 3, 5, 6], [2, 4, 7, 8], [0, 1, 3, 5, 6, 9]]\n    assert candidate(n = 14,edges = [[0, 4], [1, 4], [2, 5], [2, 6], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 10], [6, 11], [7, 12], [8, 12], [9, 13], [10, 13], [11, 13]]) == [[], [], [], [], [0, 1], [2], [2, 3], [0, 1, 4], [0, 1, 4], [2, 5], [2, 3, 5, 6], [2, 3, 6], [0, 1, 4, 7, 8], [2, 3, 5, 6, 9, 10, 11]]\n    assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n    assert candidate(n = 10,edges = [[0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 5], [2, 6], [3, 6], [4, 6], [5, 7], [6, 7], [6, 8], [7, 9], [8, 9]]) == [[], [], [0, 1], [0, 1], [0], [1], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 6], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n    assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 16], [8, 17], [9, 17], [9, 18], [10, 18], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3], [0, 1, 4], [0, 1, 4], [0, 2, 5], [0, 2, 5], [0, 2, 6], [0, 2, 6], [0, 1, 3, 7], [0, 1, 3, 7, 8], [0, 1, 3, 4, 8, 9], [0, 1, 4, 9, 10], [0, 1, 2, 4, 5, 6, 10, 11, 12, 13, 14]]\n    assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 8], [8, 9], [9, 10], [10, 11]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3, 7], [0, 1, 3, 4, 7, 8], [0, 1, 3, 4, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n    assert candidate(n = 18,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17]]) == [[], [0], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 3], [0, 3], [0, 1, 4], [0, 1, 5], [0, 2, 6], [0, 2, 7], [0, 3, 8], [0, 3, 9], [0, 1, 4, 10], [0, 1, 5, 11]]\n    assert candidate(n = 10,edges = [[0, 5], [1, 5], [2, 6], [3, 6], [4, 7], [5, 8], [6, 8], [7, 9], [8, 9]]) == [[], [], [], [], [], [0, 1], [2, 3], [4], [0, 1, 2, 3, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n    assert candidate(n = 15,edges = [[0, 3], [0, 4], [1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [[], [], [], [0, 1, 2], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 4], [0, 1, 2, 4], [0, 1, 2, 3, 5], [0, 1, 2, 3, 5], [0, 1, 2, 3, 6], [0, 1, 2, 3, 6]]\n    assert candidate(n = 18,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 5], [2, 6], [3, 6], [3, 7], [4, 8], [5, 8], [5, 9], [6, 9], [6, 10], [7, 10], [8, 11], [9, 11], [9, 12], [10, 12], [11, 13], [12, 13], [12, 14], [13, 15], [14, 15], [14, 16], [15, 17]]) == [[], [0], [0], [0], [0, 1], [0, 1, 2], [0, 2, 3], [0, 3], [0, 1, 2, 4, 5], [0, 1, 2, 3, 5, 6], [0, 2, 3, 6, 7], [0, 1, 2, 3, 4, 5, 6, 8, 9], [0, 1, 2, 3, 5, 6, 7, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [0, 1, 2, 3, 5, 6, 7, 9, 10, 12], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [0, 1, 2, 3, 5, 6, 7, 9, 10, 12, 14], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]\n    assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 9], [5, 8], [5, 10], [6, 9], [6, 10], [7, 11], [8, 11], [9, 11], [10, 11], [11, 12], [11, 13], [12, 14], [12, 15], [13, 14], [13, 16], [14, 17], [15, 17], [15, 18], [16, 18], [16, 19], [17, 19], [18, 19]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3, 4], [0, 1, 2, 3, 5], [0, 1, 2, 4, 6], [0, 2, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]]\n    assert candidate(n = 20,edges = [[0, 5], [0, 10], [0, 15], [1, 5], [1, 6], [2, 6], [2, 7], [3, 7], [3, 8], [4, 8], [4, 9], [5, 10], [5, 11], [6, 11], [6, 12], [7, 12], [7, 13], [8, 13], [8, 14], [9, 14], [10, 15], [10, 16], [11, 16], [11, 17], [12, 17], [12, 18], [13, 18], [13, 19], [14, 19]]) == [[], [], [], [], [], [0, 1], [1, 2], [2, 3], [3, 4], [4], [0, 1, 5], [0, 1, 2, 5, 6], [1, 2, 3, 6, 7], [2, 3, 4, 7, 8], [3, 4, 8, 9], [0, 1, 5, 10], [0, 1, 2, 5, 6, 10, 11], [0, 1, 2, 3, 5, 6, 7, 11, 12], [1, 2, 3, 4, 6, 7, 8, 12, 13], [2, 3, 4, 7, 8, 9, 13, 14]]\n    assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 8], [8, 9], [9, 10]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3, 7], [0, 1, 3, 4, 7, 8], [0, 1, 3, 4, 7, 8, 9], [0, 2, 5, 6]]\n    assert candidate(n = 15,edges = [[0, 5], [0, 6], [1, 5], [1, 7], [2, 6], [2, 8], [3, 7], [3, 9], [4, 8], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14]]) == [[], [], [], [], [], [0, 1], [0, 2], [1, 3], [2, 4], [3], [4], [0, 1, 5], [0, 2, 6], [1, 3, 7], [2, 4, 8]]\n    assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n    assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [1, 8], [1, 9], [2, 9]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n    assert candidate(n = 9,edges = [[0, 1], [0, 4], [0, 5], [1, 2], [1, 3], [2, 4], [2, 6], [3, 5], [3, 7], [4, 6], [4, 8], [5, 7], [6, 8], [7, 8]]) == [[], [0], [0, 1], [0, 1], [0, 1, 2], [0, 1, 3], [0, 1, 2, 4], [0, 1, 3, 5], [0, 1, 2, 3, 4, 5, 6, 7]]\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 8], [5, 9], [6, 9]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3, 4], [0, 2, 5, 6]]\n    assert candidate(n = 16,edges = [[0, 3], [1, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 10], [6, 11], [7, 12], [8, 12], [9, 13], [10, 13], [10, 14], [11, 14], [12, 15], [13, 15], [14, 15]]) == [[], [], [], [0, 1], [2], [0, 1, 3], [0, 1, 3], [2, 4], [2, 4], [0, 1, 3, 5], [0, 1, 3, 5, 6], [0, 1, 3, 6], [2, 4, 7, 8], [0, 1, 3, 5, 6, 9, 10], [0, 1, 3, 5, 6, 10, 11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [3, 5], [4, 5], [4, 6], [5, 6], [5, 7], [6, 7], [6, 8], [7, 8], [7, 9], [8, 9]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 10], [5, 11], [6, 12], [6, 13], [7, 12], [7, 13], [8, 14], [9, 14], [10, 14], [11, 14], [12, 14], [13, 14]]) == [[], [0], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 3], [0, 3], [0, 1, 4, 5], [0, 1, 4, 5], [0, 2, 6, 7], [0, 2, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]]\n    assert candidate(n = 12,edges = [[0, 3], [0, 4], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 11], [8, 11], [9, 10], [10, 11]]) == [[], [], [], [0, 1], [0, 1], [2], [2], [0, 1, 3], [0, 1, 3], [0, 1, 4], [0, 1, 2, 4, 5, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n    assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3], [0, 1, 4], [0, 1, 4], [0, 2, 5], [0, 2, 5], [0, 2, 6], [0, 2, 6], [0, 1, 3, 7], [0, 1, 3, 7], [0, 1, 3, 8], [0, 1, 3, 8], [0, 1, 2, 4, 5, 6, 9, 10, 11, 12, 13, 14]]\n    assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3], [0, 1, 4], [0, 1, 4], [0, 2, 5]]\n    assert candidate(n = 30,edges = [[0, 15], [1, 16], [2, 17], [3, 18], [4, 19], [5, 20], [6, 21], [7, 22], [8, 23], [9, 24], [10, 25], [11, 26], [12, 27], [13, 28], [14, 29], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 8], [4, 9], [5, 9], [6, 9]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3, 4], [0, 1, 2, 4, 5, 6]]\n    assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6]]) == [[], [0], [0, 1], [0, 1], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5]]\n    assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]]\n    assert candidate(n = 14,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [7, 11], [8, 12], [9, 13], [10, 13]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3], [0, 1, 4], [0, 1, 4], [0, 1, 2, 3, 5, 7], [0, 1, 2, 3, 5, 8], [0, 1, 2, 4, 6, 9, 10]]\n    assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [4, 5], [5, 6], [5, 7], [6, 8], [7, 8]]) == [[], [0], [0], [0, 1, 2], [0, 1, 2], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6, 7]]\n    assert candidate(n = 10,edges = [[0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 6], [4, 5], [4, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 9], [8, 9]]) == [[], [], [0, 1], [0, 1], [0, 1], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n    assert candidate(n = 11,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3], [0, 1, 4], [0, 1, 4], [0, 2, 5], [0, 2, 5], [0, 2, 6], [0, 2, 6]]\n    assert candidate(n = 15,edges = [[0, 5], [0, 6], [1, 6], [1, 7], [2, 7], [2, 8], [3, 8], [3, 9], [4, 9], [4, 10], [5, 11], [6, 11], [7, 12], [8, 12], [9, 13], [10, 13], [11, 14], [12, 14]]) == [[], [], [], [], [], [0], [0, 1], [1, 2], [2, 3], [3, 4], [4], [0, 1, 5, 6], [1, 2, 3, 7, 8], [3, 4, 9, 10], [0, 1, 2, 3, 5, 6, 7, 8, 11, 12]]\n    assert candidate(n = 20,edges = [[0, 5], [0, 6], [1, 7], [1, 8], [2, 9], [2, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [6, 15], [7, 16], [8, 16], [9, 17], [10, 17], [11, 18], [12, 18], [13, 19], [14, 19], [15, 19], [16, 19], [17, 19], [18, 19]]) == [[], [], [], [], [], [0], [0], [1], [1], [2], [2], [3], [3], [4], [4], [0, 5, 6], [1, 7, 8], [2, 9, 10], [3, 11, 12], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]]\n    assert candidate(n = 15,edges = [[0, 5], [1, 5], [1, 6], [2, 7], [2, 8], [3, 8], [3, 9], [4, 9], [4, 10], [5, 11], [5, 12], [6, 12], [7, 13], [7, 14], [8, 14], [9, 14]]) == [[], [], [], [], [], [0, 1], [1], [2], [2, 3], [3, 4], [4], [0, 1, 5], [0, 1, 5, 6], [2, 7], [2, 3, 4, 7, 8, 9]]\n    assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 8]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3, 4], [0, 1, 2, 3, 4, 5, 6, 7]]\n    assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 5], [3, 6], [4, 6], [4, 7], [5, 7], [6, 8], [7, 8]]) == [[], [0], [0], [0, 1, 2], [0, 1], [0, 2], [0, 1, 2, 3, 4], [0, 1, 2, 4, 5], [0, 1, 2, 3, 4, 5, 6, 7]]\n    assert candidate(n = 12,edges = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10], [10, 11]]) == [[], [], [], [], [0], [1], [2], [3], [0, 1, 4, 5], [2, 3, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 11], [8, 12]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3], [0, 1, 3], [0, 1, 4], [0, 1, 4], [0, 1, 2, 3, 5, 7], [0, 1, 2, 3, 5, 8], [0, 2, 6], [0, 2, 6]]\n    assert candidate(n = 20,edges = [[0, 5], [0, 6], [1, 7], [1, 8], [2, 9], [2, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [8, 19], [9, 19], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19]]) == [[], [], [], [], [], [0], [0], [1], [1], [2], [2], [3], [3], [4], [4], [0, 5], [0, 5], [0, 6], [0, 6], [1, 2, 3, 4, 7, 8, 9, 10, 11, 12, 13, 14]]\n    assert candidate(n = 20,edges = [[0, 5], [1, 5], [2, 6], [3, 6], [4, 7], [5, 8], [5, 9], [6, 10], [6, 11], [7, 12], [8, 13], [9, 13], [10, 14], [10, 15], [11, 14], [12, 15], [13, 16], [13, 17], [14, 18], [14, 19], [15, 18], [16, 19]]) == [[], [], [], [], [], [0, 1], [2, 3], [4], [0, 1, 5], [0, 1, 5], [2, 3, 6], [2, 3, 6], [4, 7], [0, 1, 5, 8, 9], [2, 3, 6, 10, 11], [2, 3, 4, 6, 7, 10, 12], [0, 1, 5, 8, 9, 13], [0, 1, 5, 8, 9, 13], [2, 3, 4, 6, 7, 10, 11, 12, 14, 15], [0, 1, 2, 3, 5, 6, 8, 9, 10, 11, 13, 14, 16]]\n    assert candidate(n = 10,edges = [[0, 5], [0, 6], [1, 5], [1, 7], [2, 6], [2, 8], [3, 7], [3, 9], [4, 8], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]]) == [[], [], [], [], [], [0, 1], [0, 2], [1, 3], [2, 4], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n    assert candidate(n = 20,edges = [[0, 10], [1, 10], [2, 10], [3, 11], [4, 11], [5, 11], [6, 12], [7, 12], [8, 12], [9, 13], [10, 14], [11, 14], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19]]) == [[], [], [], [], [], [], [], [], [], [], [0, 1, 2], [3, 4, 5], [6, 7, 8], [9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12], [9, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14], [9, 13, 15], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16], [9, 13, 15, 17]]\n    assert candidate(n = 11,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 9], [5, 8], [5, 10], [6, 9], [6, 10], [7, 10], [8, 10], [9, 10]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3, 4], [0, 1, 2, 3, 5], [0, 1, 2, 4, 6], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]\n    assert candidate(n = 20,edges = [[0, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [0, 2], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [], [0, 1, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 5], [2, 6], [3, 6], [4, 7], [5, 7], [6, 7], [7, 8], [8, 9]]) == [[], [0], [0], [0], [0, 1], [0, 1, 2], [0, 2, 3], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n    assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8], [5, 9], [5, 10], [6, 9], [6, 10], [7, 11], [8, 11], [9, 11], [10, 11]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3, 4], [0, 1, 3, 4], [0, 2, 5, 6], [0, 2, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9]]) == [[], [0], [0], [0, 1], [0, 1], [0, 2], [0, 2], [0, 1, 3, 4], [0, 2, 5, 6], [0, 1, 3, 4, 7]]\n    assert candidate(n = 25,edges = [[0, 12], [0, 13], [1, 12], [1, 13], [2, 14], [2, 15], [3, 15], [3, 16], [4, 16], [4, 17], [5, 17], [5, 18], [6, 18], [6, 19], [7, 19], [7, 20], [8, 20], [8, 21], [9, 21], [9, 22], [10, 22], [10, 23], [11, 23], [11, 24]]) == [[], [], [], [], [], [], [], [], [], [], [], [], [0, 1], [0, 1], [2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11]]\n    assert candidate(n = 20,edges = [[0, 10], [0, 11], [1, 10], [1, 11], [2, 12], [2, 13], [3, 13], [3, 14], [4, 14], [4, 15], [5, 15], [5, 16], [6, 16], [6, 17], [7, 17], [7, 18], [8, 18], [8, 19], [9, 19]]) == [[], [], [], [], [], [], [], [], [], [], [0, 1], [0, 1], [2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]\n    assert candidate(n = 12,edges = [[0, 5], [0, 6], [1, 6], [1, 7], [2, 7], [2, 8], [3, 8], [3, 9], [4, 9], [5, 10], [6, 10], [7, 10], [8, 11], [9, 11], [10, 11]]) == [[], [], [], [], [], [0], [0, 1], [1, 2], [2, 3], [3, 4], [0, 1, 2, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n", "comparison": "exact"}, "public_tests": ["8\n[[0,3],[0,4],[1,3],[2,4],[2,7],[3,5],[3,6],[3,7],[4,6]]", "5\n[[0,1],[0,2],[0,3],[0,4],[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]"], "hints": ["Consider how reversing each edge of the graph can help us.", "How can performing BFS/DFS on the reversed graph help us find the ancestors of every node?"], "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().getAncestors", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:24+00:00", "tests_total": 63, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["depth-first-search", "breadth-first-search", "graph", "topological-sort", "directed-acyclic-graph"]}, "language": "python", "interface": {"raw_signature": "def getAncestors(self, n: int, edges: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "getAncestors", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2193, "task_id": "minimum-number-of-moves-to-make-palindrome", "difficulty": "Hard", "problem_description": "You are given a string s consisting only of lowercase English letters.\n\nIn one move, you can select any two adjacent characters of s and swap them.\n\nReturn the minimum number of moves needed to make s a palindrome.\n\nNote that the input will be generated such that s can always be converted to a palindrome.\n\nExample 1:\n\nInput: s = \"aabb\"\nOutput: 2\nExplanation:\nWe can obtain two palindromes from s, \"abba\" and \"baab\".\n- We can obtain \"abba\" from s in 2 moves: \"aabb\" -> \"abab\" -> \"abba\".\n- We can obtain \"baab\" from s in 2 moves: \"aabb\" -> \"abab\" -> \"baab\".\nThus, the minimum number of moves needed to make s a palindrome is 2.\n\nExample 2:\n\nInput: s = \"letelt\"\nOutput: 2\nExplanation:\nOne of the palindromes we can obtain from s in 2 moves is \"lettel\".\nOne of the ways we can obtain it is \"letelt\" -> \"letetl\" -> \"lettel\".\nOther palindromes such as \"tleelt\" can also be obtained in 2 moves.\nIt can be shown that it is not possible to obtain a palindrome in less than 2 moves.\n\nConstraints:\n\n- 1 <= s.length <= 2000\n- s consists only of lowercase English letters.\n- s can be converted to a palindrome using a finite number of moves.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"abcba\") == 0\n    assert candidate(s = \"letelt\") == 2\n    assert candidate(s = \"abcdcba\") == 0\n    assert candidate(s = \"aabbaa\") == 0\n    assert candidate(s = \"abcdedcba\") == 0\n    assert candidate(s = \"mamad\") == 3\n    assert candidate(s = \"aabbc\") == 4\n    assert candidate(s = \"aabb\") == 2\n    assert candidate(s = \"racecar\") == 0\n    assert candidate(s = \"abcdefgfedcba\") == 0\n    assert candidate(s = \"noon\") == 0\n    assert candidate(s = \"deeee\") == 2\n    assert candidate(s = \"nnnnn\") == 0\n    assert candidate(s = \"aabbcc\") == 6\n    assert candidate(s = \"elvtoelvtoe\") == 6\n    assert candidate(s = \"aabbab\") == 3\n    assert candidate(s = \"asflkj\") == 5\n    assert candidate(s = \"abca\") == 1\n    assert candidate(s = \"abcdefghgfedcba\") == 0\n    assert candidate(s = \"zzzyzzyzz\") == 1\n    assert candidate(s = \"noonappa\") == 8\n    assert candidate(s = \"abcdcbad\") == 3\n    assert candidate(s = \"aabaaabbaaaaaabbbbaa\") == 11\n    assert candidate(s = \"aabbaabbaabb\") == 6\n    assert candidate(s = \"jlvaj\") == 1\n    assert candidate(s = \"xyzyzyzyzyx\") == 0\n    assert candidate(s = \"qpwoeirutoip\") == 12\n    assert candidate(s = \"abbbacaba\") == 3\n    assert candidate(s = \"abcabcabcabc\") == 6\n    assert candidate(s = \"noonnoon\") == 0\n    assert candidate(s = \"aaaaabbbb\") == 10\n    assert candidate(s = \"mnopqponmlkjihgfedcbaaaabbbccc\") == 161\n    assert candidate(s = \"aabbccddeeefffgggggffffeeeeddccbaaabb\") == 37\n    assert candidate(s = \"lplllp\") == 1\n    assert candidate(s = \"aabbbbaaa\") == 2\n    assert candidate(s = \"aaabbbcccdddcccbbaaa\") == 5\n    assert candidate(s = \"mmnmm\") == 0\n    assert candidate(s = \"mnvovnm\") == 0\n    assert candidate(s = \"aabbccddeee\") == 24\n    assert candidate(s = \"xyzzyx\") == 0\n    assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmmlkjhgfdsapoiuytrewq\") == 9\n    assert candidate(s = \"aabbaabbaabbaabb\") == 8\n    assert candidate(s = \"abcdddcb\") == 4\n    assert candidate(s = \"abcdxyzzyxcba\") == 3\n    assert candidate(s = \"aabbccddeeeeddcbaabbaa\") == 22\n    assert candidate(s = \"aabbccddeeefffgggghhhggggfffeeeedddccbbaa\") == 20\n    assert candidate(s = \"aaaabbbbccccddddeeeeffffggggggg\") == 204\n    assert candidate(s = \"ppqqrrssrqqpp\") == 1\n    assert candidate(s = \"aaabbbb\") == 6\n    assert candidate(s = \"abcdedcbaa\") == 4\n    assert candidate(s = \"aabbccddeeffeecdccbbaa\") == 7\n    assert candidate(s = \"aabbccddeeefffggggffffeeeeddccbaaabb\") == 38\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 0\n    assert candidate(s = \"abcdeedcba\") == 0\n    assert candidate(s = \"abacabad\") == 4\n    assert candidate(s = \"xyzyxzyxzyxzyx\") == 2\n    assert candidate(s = \"aaabbbaaa\") == 0\n    assert candidate(s = \"aabbabaa\") == 1\n    assert candidate(s = \"abcbaabcba\") == 0\n    assert candidate(s = \"zazbzazbzaz\") == 0\n    assert candidate(s = \"abcdeffedcba\") == 0\n    assert candidate(s = \"abcbca\") == 1\n    assert candidate(s = \"abcdefedcba\") == 0\n    assert candidate(s = \"aabbccdd\") == 12\n    assert candidate(s = \"level\") == 0\n    assert candidate(s = \"abcabcba\") == 1\n    assert candidate(s = \"aaaabbbb\") == 8\n    assert candidate(s = \"madam\") == 0\n    assert candidate(s = \"aabababaab\") == 3\n    assert candidate(s = \"aabccbaa\") == 0\n    assert candidate(s = \"abacabadabacaba\") == 0\n    assert candidate(s = \"aabbccddeeeffffgggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwxxyyzz\") == 1192\n    assert candidate(s = \"qwertewq\") == 1\n    assert candidate(s = \"qwertytrewq\") == 0\n    assert candidate(s = \"abcbad\") == 3\n    assert candidate(s = \"abbaaccdaabb\") == 5\n    assert candidate(s = \"aababbaaabbbbbaaaaa\") == 8\n    assert candidate(s = \"aabaaa\") == 1\n    assert candidate(s = \"aaabaaaabbaa\") == 4\n    assert candidate(s = \"xyzyzyx\") == 0\n    assert candidate(s = \"abccba\") == 0\n    assert candidate(s = \"zxcvbnmlkjhgfdasqwertyuiopoiuytrewqasdfghjklmnbvcxz\") == 1\n    assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbaaaaaaaaa\") == 6\n    assert candidate(s = \"aabbccddeeeeddcbbbaa\") == 10\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 650\n    assert candidate(s = \"aabbabba\") == 2\n    assert candidate(s = \"mmnnllkkjjiihhggffeeddccbbaa\") == 182\n    assert candidate(s = \"aaaaabbbaaaa\") == 2\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n    assert candidate(s = \"nnnmmmnnn\") == 0\n    assert candidate(s = \"repaper\") == 0\n    assert candidate(s = \"abacdfgdcaba\") == 1\n    assert candidate(s = \"aabbccddeeefffgggfhheeeddccbaa\") == 22\n    assert candidate(s = \"abbaabba\") == 0\n    assert candidate(s = \"zyxzyzyx\") == 4\n    assert candidate(s = \"abcddcba\") == 0\n    assert candidate(s = \"rotor\") == 0\n    assert candidate(s = \"abcdefghihgfedcba\") == 0\n    assert candidate(s = \"aabbccddeeeffggffeeddccbbaa\") == 3\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaedcba\") == 115\n    assert candidate(s = \"aabbccddeeeffffgggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\") == 1311\n    assert candidate(s = \"levellol\") == 6\n    assert candidate(s = \"mississippi\") == 13\n    assert candidate(s = \"abcdeffgfedcba\") == 1\n    assert candidate(s = \"aabbccddeedcbaa\") == 6\n", "comparison": "exact"}, "public_tests": ["\"aabb\"", "\"letelt\""], "hints": ["Consider a greedy strategy.", "Let’s start by making the leftmost and rightmost characters match with some number of swaps.", "If we figure out how to do that using the minimum number of swaps, then we can delete the leftmost and rightmost characters and solve the problem recursively."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minMovesToMakePalindrome", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:26+00:00", "tests_total": 105, "tests_dropped": 0, "flags": [], "topic_tags": ["two-pointers", "string", "greedy", "binary-indexed-tree"]}, "language": "python", "interface": {"raw_signature": "def minMovesToMakePalindrome(self, s: str) -> int:", "container": "Solution", "callable": "minMovesToMakePalindrome", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2194, "task_id": "cells-in-a-range-on-an-excel-sheet", "difficulty": "Easy", "problem_description": "A cell (r, c) of an excel sheet is represented as a string \"\" where:\n\n-  denotes the column number c of the cell. It is represented by alphabetical letters.\n  - For example, the 1^st column is denoted by 'A', the 2^nd by 'B', the 3^rd by 'C', and so on.\n-  is the row number r of the cell. The r^th row is represented by the integer r.\n\nYou are given a string s in the format \":\", where  represents the column c1,  represents the row r1,  represents the column c2, and  represents the row r2, such that r1 <= r2 and c1 <= c2.\n\nReturn the list of cells (x, y) such that r1 <= x <= r2 and c1 <= y <= c2. The cells should be represented as strings in the format mentioned above and be sorted in non-decreasing order first by columns and then by rows.\n\nExample 1:\n\nInput: s = \"K1:L2\"\nOutput: [\"K1\",\"K2\",\"L1\",\"L2\"]\nExplanation:\nThe above diagram shows the cells which should be present in the list.\nThe red arrows denote the order in which the cells should be presented.\n\nExample 2:\n\nInput: s = \"A1:F1\"\nOutput: [\"A1\",\"B1\",\"C1\",\"D1\",\"E1\",\"F1\"]\nExplanation:\nThe above diagram shows the cells which should be present in the list.\nThe red arrow denotes the order in which the cells should be presented.\n\nConstraints:\n\n- s.length == 5\n- 'A' <= s[0] <= s[3] <= 'Z'\n- '1' <= s[1] <= s[4] <= '9'\n- s consists of uppercase English letters, digits and ':'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"D4:H6\") == ['D4', 'D5', 'D6', 'E4', 'E5', 'E6', 'F4', 'F5', 'F6', 'G4', 'G5', 'G6', 'H4', 'H5', 'H6']\n    assert candidate(s = \"K1:L2\") == ['K1', 'K2', 'L1', 'L2']\n    assert candidate(s = \"A1:F1\") == ['A1', 'B1', 'C1', 'D1', 'E1', 'F1']\n    assert candidate(s = \"B2:D3\") == ['B2', 'B3', 'C2', 'C3', 'D2', 'D3']\n    assert candidate(s = \"Z1:Z9\") == ['Z1', 'Z2', 'Z3', 'Z4', 'Z5', 'Z6', 'Z7', 'Z8', 'Z9']\n    assert candidate(s = \"Z1:Z5\") == ['Z1', 'Z2', 'Z3', 'Z4', 'Z5']\n    assert candidate(s = \"A1:A1\") == ['A1']\n    assert candidate(s = \"B2:C3\") == ['B2', 'B3', 'C2', 'C3']\n    assert candidate(s = \"Y2:Z8\") == ['Y2', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7', 'Y8', 'Z2', 'Z3', 'Z4', 'Z5', 'Z6', 'Z7', 'Z8']\n    assert candidate(s = \"L2:W7\") == ['L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'O2', 'O3', 'O4', 'O5', 'O6', 'O7', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'U2', 'U3', 'U4', 'U5', 'U6', 'U7', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7']\n    assert candidate(s = \"Y5:Z8\") == ['Y5', 'Y6', 'Y7', 'Y8', 'Z5', 'Z6', 'Z7', 'Z8']\n    assert candidate(s = \"T1:U8\") == ['T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'U1', 'U2', 'U3', 'U4', 'U5', 'U6', 'U7', 'U8']\n    assert candidate(s = \"D5:D5\") == ['D5']\n    assert candidate(s = \"J2:L3\") == ['J2', 'J3', 'K2', 'K3', 'L2', 'L3']\n    assert candidate(s = \"A1:Z9\") == ['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'E1', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'E8', 'E9', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'G9', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'I1', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7', 'I8', 'I9', 'J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'K1', 'K2', 'K3', 'K4', 'K5', 'K6', 'K7', 'K8', 'K9', 'L1', 'L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'L8', 'L9', 'M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8', 'M9', 'N1', 'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'N8', 'N9', 'O1', 'O2', 'O3', 'O4', 'O5', 'O6', 'O7', 'O8', 'O9', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'R9', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'U1', 'U2', 'U3', 'U4', 'U5', 'U6', 'U7', 'U8', 'U9', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9', 'W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8', 'W9', 'X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8', 'X9', 'Y1', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7', 'Y8', 'Y9', 'Z1', 'Z2', 'Z3', 'Z4', 'Z5', 'Z6', 'Z7', 'Z8', 'Z9']\n    assert candidate(s = \"S1:T7\") == ['S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7']\n    assert candidate(s = \"M3:P7\") == ['M3', 'M4', 'M5', 'M6', 'M7', 'N3', 'N4', 'N5', 'N6', 'N7', 'O3', 'O4', 'O5', 'O6', 'O7', 'P3', 'P4', 'P5', 'P6', 'P7']\n    assert candidate(s = \"F4:H7\") == ['F4', 'F5', 'F6', 'F7', 'G4', 'G5', 'G6', 'G7', 'H4', 'H5', 'H6', 'H7']\n    assert candidate(s = \"Q1:Z2\") == ['Q1', 'Q2', 'R1', 'R2', 'S1', 'S2', 'T1', 'T2', 'U1', 'U2', 'V1', 'V2', 'W1', 'W2', 'X1', 'X2', 'Y1', 'Y2', 'Z1', 'Z2']\n    assert candidate(s = \"M1:N6\") == ['M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'N1', 'N2', 'N3', 'N4', 'N5', 'N6']\n    assert candidate(s = \"M3:N4\") == ['M3', 'M4', 'N3', 'N4']\n    assert candidate(s = \"T2:U5\") == ['T2', 'T3', 'T4', 'T5', 'U2', 'U3', 'U4', 'U5']\n    assert candidate(s = \"N3:O5\") == ['N3', 'N4', 'N5', 'O3', 'O4', 'O5']\n    assert candidate(s = \"G1:V9\") == ['G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'G9', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'I1', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7', 'I8', 'I9', 'J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'K1', 'K2', 'K3', 'K4', 'K5', 'K6', 'K7', 'K8', 'K9', 'L1', 'L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'L8', 'L9', 'M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8', 'M9', 'N1', 'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'N8', 'N9', 'O1', 'O2', 'O3', 'O4', 'O5', 'O6', 'O7', 'O8', 'O9', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'R9', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'U1', 'U2', 'U3', 'U4', 'U5', 'U6', 'U7', 'U8', 'U9', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9']\n    assert candidate(s = \"D1:D9\") == ['D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9']\n    assert candidate(s = \"R1:T4\") == ['R1', 'R2', 'R3', 'R4', 'S1', 'S2', 'S3', 'S4', 'T1', 'T2', 'T3', 'T4']\n    assert candidate(s = \"Y1:Z2\") == ['Y1', 'Y2', 'Z1', 'Z2']\n    assert candidate(s = \"I2:J5\") == ['I2', 'I3', 'I4', 'I5', 'J2', 'J3', 'J4', 'J5']\n    assert candidate(s = \"E3:G7\") == ['E3', 'E4', 'E5', 'E6', 'E7', 'F3', 'F4', 'F5', 'F6', 'F7', 'G3', 'G4', 'G5', 'G6', 'G7']\n    assert candidate(s = \"V5:X8\") == ['V5', 'V6', 'V7', 'V8', 'W5', 'W6', 'W7', 'W8', 'X5', 'X6', 'X7', 'X8']\n    assert candidate(s = \"N5:N9\") == ['N5', 'N6', 'N7', 'N8', 'N9']\n    assert candidate(s = \"X1:Y2\") == ['X1', 'X2', 'Y1', 'Y2']\n    assert candidate(s = \"F3:K8\") == ['F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'I3', 'I4', 'I5', 'I6', 'I7', 'I8', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'K3', 'K4', 'K5', 'K6', 'K7', 'K8']\n    assert candidate(s = \"J2:T6\") == ['J2', 'J3', 'J4', 'J5', 'J6', 'K2', 'K3', 'K4', 'K5', 'K6', 'L2', 'L3', 'L4', 'L5', 'L6', 'M2', 'M3', 'M4', 'M5', 'M6', 'N2', 'N3', 'N4', 'N5', 'N6', 'O2', 'O3', 'O4', 'O5', 'O6', 'P2', 'P3', 'P4', 'P5', 'P6', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'R2', 'R3', 'R4', 'R5', 'R6', 'S2', 'S3', 'S4', 'S5', 'S6', 'T2', 'T3', 'T4', 'T5', 'T6']\n    assert candidate(s = \"X1:X9\") == ['X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8', 'X9']\n    assert candidate(s = \"D1:G3\") == ['D1', 'D2', 'D3', 'E1', 'E2', 'E3', 'F1', 'F2', 'F3', 'G1', 'G2', 'G3']\n    assert candidate(s = \"A1:Z1\") == ['A1', 'B1', 'C1', 'D1', 'E1', 'F1', 'G1', 'H1', 'I1', 'J1', 'K1', 'L1', 'M1', 'N1', 'O1', 'P1', 'Q1', 'R1', 'S1', 'T1', 'U1', 'V1', 'W1', 'X1', 'Y1', 'Z1']\n    assert candidate(s = \"T1:U5\") == ['T1', 'T2', 'T3', 'T4', 'T5', 'U1', 'U2', 'U3', 'U4', 'U5']\n    assert candidate(s = \"B1:Z9\") == ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'E1', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'E8', 'E9', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'G9', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'I1', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7', 'I8', 'I9', 'J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'K1', 'K2', 'K3', 'K4', 'K5', 'K6', 'K7', 'K8', 'K9', 'L1', 'L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'L8', 'L9', 'M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8', 'M9', 'N1', 'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'N8', 'N9', 'O1', 'O2', 'O3', 'O4', 'O5', 'O6', 'O7', 'O8', 'O9', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'R9', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'U1', 'U2', 'U3', 'U4', 'U5', 'U6', 'U7', 'U8', 'U9', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9', 'W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8', 'W9', 'X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8', 'X9', 'Y1', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7', 'Y8', 'Y9', 'Z1', 'Z2', 'Z3', 'Z4', 'Z5', 'Z6', 'Z7', 'Z8', 'Z9']\n    assert candidate(s = \"P1:S4\") == ['P1', 'P2', 'P3', 'P4', 'Q1', 'Q2', 'Q3', 'Q4', 'R1', 'R2', 'R3', 'R4', 'S1', 'S2', 'S3', 'S4']\n    assert candidate(s = \"R2:S6\") == ['R2', 'R3', 'R4', 'R5', 'R6', 'S2', 'S3', 'S4', 'S5', 'S6']\n    assert candidate(s = \"M1:N1\") == ['M1', 'N1']\n    assert candidate(s = \"G2:H2\") == ['G2', 'H2']\n    assert candidate(s = \"C2:Y7\") == ['C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'K2', 'K3', 'K4', 'K5', 'K6', 'K7', 'L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'O2', 'O3', 'O4', 'O5', 'O6', 'O7', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'U2', 'U3', 'U4', 'U5', 'U6', 'U7', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7']\n    assert candidate(s = \"X3:Y7\") == ['X3', 'X4', 'X5', 'X6', 'X7', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7']\n    assert candidate(s = \"C3:D7\") == ['C3', 'C4', 'C5', 'C6', 'C7', 'D3', 'D4', 'D5', 'D6', 'D7']\n    assert candidate(s = \"C1:D5\") == ['C1', 'C2', 'C3', 'C4', 'C5', 'D1', 'D2', 'D3', 'D4', 'D5']\n    assert candidate(s = \"A1:X9\") == ['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'E1', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'E8', 'E9', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'G9', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'I1', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7', 'I8', 'I9', 'J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'K1', 'K2', 'K3', 'K4', 'K5', 'K6', 'K7', 'K8', 'K9', 'L1', 'L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'L8', 'L9', 'M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8', 'M9', 'N1', 'N2', 'N3', 'N4', 'N5', 'N6', 'N7', 'N8', 'N9', 'O1', 'O2', 'O3', 'O4', 'O5', 'O6', 'O7', 'O8', 'O9', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'R9', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'U1', 'U2', 'U3', 'U4', 'U5', 'U6', 'U7', 'U8', 'U9', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9', 'W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8', 'W9', 'X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8', 'X9']\n    assert candidate(s = \"H8:H8\") == ['H8']\n    assert candidate(s = \"G7:H9\") == ['G7', 'G8', 'G9', 'H7', 'H8', 'H9']\n    assert candidate(s = \"Y1:Z3\") == ['Y1', 'Y2', 'Y3', 'Z1', 'Z2', 'Z3']\n    assert candidate(s = \"X1:Y6\") == ['X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'Y1', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6']\n    assert candidate(s = \"D1:F9\") == ['D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'E1', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'E8', 'E9', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9']\n    assert candidate(s = \"B4:E8\") == ['B4', 'B5', 'B6', 'B7', 'B8', 'C4', 'C5', 'C6', 'C7', 'C8', 'D4', 'D5', 'D6', 'D7', 'D8', 'E4', 'E5', 'E6', 'E7', 'E8']\n    assert candidate(s = \"D5:H7\") == ['D5', 'D6', 'D7', 'E5', 'E6', 'E7', 'F5', 'F6', 'F7', 'G5', 'G6', 'G7', 'H5', 'H6', 'H7']\n    assert candidate(s = \"X1:Z1\") == ['X1', 'Y1', 'Z1']\n    assert candidate(s = \"S1:Z3\") == ['S1', 'S2', 'S3', 'T1', 'T2', 'T3', 'U1', 'U2', 'U3', 'V1', 'V2', 'V3', 'W1', 'W2', 'W3', 'X1', 'X2', 'X3', 'Y1', 'Y2', 'Y3', 'Z1', 'Z2', 'Z3']\n    assert candidate(s = \"I5:K7\") == ['I5', 'I6', 'I7', 'J5', 'J6', 'J7', 'K5', 'K6', 'K7']\n    assert candidate(s = \"J1:K5\") == ['J1', 'J2', 'J3', 'J4', 'J5', 'K1', 'K2', 'K3', 'K4', 'K5']\n    assert candidate(s = \"M5:T8\") == ['M5', 'M6', 'M7', 'M8', 'N5', 'N6', 'N7', 'N8', 'O5', 'O6', 'O7', 'O8', 'P5', 'P6', 'P7', 'P8', 'Q5', 'Q6', 'Q7', 'Q8', 'R5', 'R6', 'R7', 'R8', 'S5', 'S6', 'S7', 'S8', 'T5', 'T6', 'T7', 'T8']\n    assert candidate(s = \"A2:A9\") == ['A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9']\n    assert candidate(s = \"J2:L5\") == ['J2', 'J3', 'J4', 'J5', 'K2', 'K3', 'K4', 'K5', 'L2', 'L3', 'L4', 'L5']\n    assert candidate(s = \"G5:I8\") == ['G5', 'G6', 'G7', 'G8', 'H5', 'H6', 'H7', 'H8', 'I5', 'I6', 'I7', 'I8']\n    assert candidate(s = \"A3:C6\") == ['A3', 'A4', 'A5', 'A6', 'B3', 'B4', 'B5', 'B6', 'C3', 'C4', 'C5', 'C6']\n    assert candidate(s = \"Q1:R9\") == ['Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'R9']\n    assert candidate(s = \"X5:Z9\") == ['X5', 'X6', 'X7', 'X8', 'X9', 'Y5', 'Y6', 'Y7', 'Y8', 'Y9', 'Z5', 'Z6', 'Z7', 'Z8', 'Z9']\n    assert candidate(s = \"T1:U4\") == ['T1', 'T2', 'T3', 'T4', 'U1', 'U2', 'U3', 'U4']\n    assert candidate(s = \"A1:A9\") == ['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9']\n    assert candidate(s = \"F1:F9\") == ['F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9']\n    assert candidate(s = \"M5:O8\") == ['M5', 'M6', 'M7', 'M8', 'N5', 'N6', 'N7', 'N8', 'O5', 'O6', 'O7', 'O8']\n    assert candidate(s = \"J1:K3\") == ['J1', 'J2', 'J3', 'K1', 'K2', 'K3']\n    assert candidate(s = \"F2:J7\") == ['F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7']\n    assert candidate(s = \"A1:B1\") == ['A1', 'B1']\n    assert candidate(s = \"G5:H8\") == ['G5', 'G6', 'G7', 'G8', 'H5', 'H6', 'H7', 'H8']\n    assert candidate(s = \"R3:X8\") == ['R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'U3', 'U4', 'U5', 'U6', 'U7', 'U8', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8']\n    assert candidate(s = \"C3:F7\") == ['C3', 'C4', 'C5', 'C6', 'C7', 'D3', 'D4', 'D5', 'D6', 'D7', 'E3', 'E4', 'E5', 'E6', 'E7', 'F3', 'F4', 'F5', 'F6', 'F7']\n    assert candidate(s = \"C1:C5\") == ['C1', 'C2', 'C3', 'C4', 'C5']\n    assert candidate(s = \"H1:H9\") == ['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9']\n    assert candidate(s = \"C4:E6\") == ['C4', 'C5', 'C6', 'D4', 'D5', 'D6', 'E4', 'E5', 'E6']\n    assert candidate(s = \"E5:F7\") == ['E5', 'E6', 'E7', 'F5', 'F6', 'F7']\n    assert candidate(s = \"P1:Q9\") == ['P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9']\n    assert candidate(s = \"V1:W3\") == ['V1', 'V2', 'V3', 'W1', 'W2', 'W3']\n    assert candidate(s = \"C4:D8\") == ['C4', 'C5', 'C6', 'C7', 'C8', 'D4', 'D5', 'D6', 'D7', 'D8']\n    assert candidate(s = \"F1:H4\") == ['F1', 'F2', 'F3', 'F4', 'G1', 'G2', 'G3', 'G4', 'H1', 'H2', 'H3', 'H4']\n    assert candidate(s = \"G1:H1\") == ['G1', 'H1']\n    assert candidate(s = \"W3:X6\") == ['W3', 'W4', 'W5', 'W6', 'X3', 'X4', 'X5', 'X6']\n    assert candidate(s = \"N3:Q6\") == ['N3', 'N4', 'N5', 'N6', 'O3', 'O4', 'O5', 'O6', 'P3', 'P4', 'P5', 'P6', 'Q3', 'Q4', 'Q5', 'Q6']\n    assert candidate(s = \"J4:L7\") == ['J4', 'J5', 'J6', 'J7', 'K4', 'K5', 'K6', 'K7', 'L4', 'L5', 'L6', 'L7']\n    assert candidate(s = \"F2:H5\") == ['F2', 'F3', 'F4', 'F5', 'G2', 'G3', 'G4', 'G5', 'H2', 'H3', 'H4', 'H5']\n    assert candidate(s = \"X5:Y8\") == ['X5', 'X6', 'X7', 'X8', 'Y5', 'Y6', 'Y7', 'Y8']\n    assert candidate(s = \"W2:Y5\") == ['W2', 'W3', 'W4', 'W5', 'X2', 'X3', 'X4', 'X5', 'Y2', 'Y3', 'Y4', 'Y5']\n    assert candidate(s = \"W1:X3\") == ['W1', 'W2', 'W3', 'X1', 'X2', 'X3']\n    assert candidate(s = \"P1:Q1\") == ['P1', 'Q1']\n", "comparison": "exact"}, "public_tests": ["\"K1:L2\"", "\"A1:F1\""], "hints": ["From the given string, find the corresponding rows and columns.", "Iterate through the columns in ascending order and for each column, iterate through the rows in ascending order to obtain the required cells in sorted order."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().cellsInRange", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:28+00:00", "tests_total": 175, "tests_dropped": 82, "flags": ["has_images"], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def cellsInRange(self, s: str) -> list[str]:", "container": "Solution", "callable": "cellsInRange", "parameters": [{"name": "s", "type": "str"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2195, "task_id": "append-k-integers-with-minimal-sum", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer k. Append k unique positive integers that do not appear in nums to nums such that the resulting total sum is minimum.\n\nReturn the sum of the k integers appended to nums.\n\nExample 1:\n\nInput: nums = [1,4,25,10,25], k = 2\nOutput: 5\nExplanation: The two unique positive integers that do not appear in nums which we append are 2 and 3.\nThe resulting sum of nums is 1 + 4 + 25 + 10 + 25 + 2 + 3 = 70, which is the minimum.\nThe sum of the two integers appended is 2 + 3 = 5, so we return 5.\n\nExample 2:\n\nInput: nums = [5,6], k = 6\nOutput: 25\nExplanation: The six unique positive integers that do not appear in nums which we append are 1, 2, 3, 4, 7, and 8.\nThe resulting sum of nums is 5 + 6 + 1 + 2 + 3 + 4 + 7 + 8 = 36, which is the minimum.\nThe sum of the six integers appended is 1 + 2 + 3 + 4 + 7 + 8 = 25, so we return 25.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^9\n- 1 <= k <= 10^8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 21\n    assert candidate(nums = [1, 4, 25, 10, 25],k = 2) == 5\n    assert candidate(nums = [1000000000],k = 100000) == 5000050000\n    assert candidate(nums = [1000000000],k = 1) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9],k = 10) == 95\n    assert candidate(nums = [1],k = 1) == 2\n    assert candidate(nums = [1, 3, 5, 7, 9],k = 5) == 30\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 5) == 15\n    assert candidate(nums = [5, 6],k = 6) == 25\n    assert candidate(nums = [1, 1, 1, 1, 1],k = 1) == 2\n    assert candidate(nums = [1000000000],k = 100000000) == 5000000050000000\n    assert candidate(nums = [10, 20, 30],k = 5) == 15\n    assert candidate(nums = [5, 15, 25, 35, 45],k = 15) == 133\n    assert candidate(nums = [100, 200, 300, 400, 500],k = 50) == 1275\n    assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],k = 50) == 1445\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 155\n    assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 1\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 30) == 603\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],k = 25) == 442\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 65\n    assert candidate(nums = [1],k = 1000000) == 500001500000\n    assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 50) == 1513\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 50) == 1390\n    assert candidate(nums = [999999998, 999999999, 1000000000],k = 100000) == 5000050000\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 20) == 210\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 100000) == 5000050000\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 110\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 25) == 950\n    assert candidate(nums = [1, 2, 3, 6, 7, 8, 11, 12, 13, 16, 17, 18],k = 15) == 264\n    assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000],k = 500000) == 125000250000\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 10) == 57\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == 126\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 15) == 215\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 20) == 233\n    assert candidate(nums = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5],k = 15) == 175\n    assert candidate(nums = [1000000000],k = 1000000) == 500000500000\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 155\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 241\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 570\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 1390\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 25) == 391\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 1390\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 50000) == 1250025000\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 25) == 391\n    assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 100) == 6940\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 10) == 100\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 610\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 30) == 691\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 100) == 6815\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 10) == 105\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 115\n    assert candidate(nums = [500000000, 600000000, 700000000, 800000000, 900000000],k = 100000) == 5000050000\n    assert candidate(nums = [5, 15, 25, 35, 45],k = 10) == 61\n    assert candidate(nums = [2, 4, 6, 8, 10],k = 5) == 25\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 25) == 361\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 21\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 50) == 2775\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 100\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 10) == 63\n    assert candidate(nums = [2],k = 1000000) == 500001499999\n    assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23],k = 15) == 224\n    assert candidate(nums = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46],k = 20) == 315\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 50) == 3275\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 15) == 225\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250],k = 100) == 5556\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125],k = 35) == 766\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 100) == 10050\n    assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000],k = 100000) == 5000050000\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 223\n    assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98],k = 25) == 433\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 100) == 5556\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 50) == 1275\n    assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29],k = 20) == 520\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 15) == 215\n    assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 15) == 160\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 50) == 1275\n    assert candidate(nums = [999999990, 999999991, 999999992, 999999993, 999999994],k = 5) == 15\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 110\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 100000) == 5000050000\n    assert candidate(nums = [3, 9, 2, 8, 6, 7],k = 3) == 10\n    assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240],k = 30) == 534\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 115\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 65\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 20) == 365\n    assert candidate(nums = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 100) == 6330\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 223\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 20) == 810\n    assert candidate(nums = [999999998, 999999999, 1000000000],k = 3) == 6\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 20) == 365\n    assert candidate(nums = [1000000000],k = 500000) == 125000250000\n    assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],k = 20) == 295\n    assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625],k = 200) == 21990\n    assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000],k = 10000) == 50005000\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 25) == 391\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 100) == 10050\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 7050\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],k = 25) == 442\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 255\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 30\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 15) == 141\n    assert candidate(nums = [3, 5, 7, 9, 11],k = 10) == 85\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 30) == 1215\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 500000) == 125000250000\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 50) == 2775\n    assert candidate(nums = [5, 15, 25, 35, 45],k = 10) == 61\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 7050\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 100) == 6050\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 110\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 15) == 225\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10) == 56\n", "comparison": "exact"}, "public_tests": ["[1,4,25,10,25]\n2", "[5,6]\n6"], "hints": ["The k smallest numbers that do not appear in nums will result in the minimum sum.", "Recall that the sum of the first n positive numbers is equal to n * (n+1) / 2.", "Initialize the answer as the sum of 1 to k. Then, adjust the answer depending on the values in nums."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minimalKSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:30+00:00", "tests_total": 111, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "math", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minimalKSum(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "minimalKSum", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2197, "task_id": "replace-non-coprime-numbers-in-array", "difficulty": "Hard", "problem_description": "You are given an array of integers nums. Perform the following steps:\n\n1. Find any two adjacent numbers in nums that are non-coprime.\n2. If no such numbers are found, stop the process.\n3. Otherwise, delete the two numbers and replace them with their LCM (Least Common Multiple).\n4. Repeat this process as long as you keep finding two adjacent non-coprime numbers.\n\nReturn the final modified array. It can be shown that replacing adjacent non-coprime numbers in any arbitrary order will lead to the same result.\n\nThe test cases are generated such that the values in the final array are less than or equal to 10^8.\n\nTwo values x and y are non-coprime if GCD(x, y) > 1 where GCD(x, y) is the Greatest Common Divisor of x and y.\n\nExample 1:\n\nInput: nums = [6,4,3,2,7,6,2]\nOutput: [12,7,6]\nExplanation:\n- (6, 4) are non-coprime with LCM(6, 4) = 12. Now, nums = [12,3,2,7,6,2].\n- (12, 3) are non-coprime with LCM(12, 3) = 12. Now, nums = [12,2,7,6,2].\n- (12, 2) are non-coprime with LCM(12, 2) = 12. Now, nums = [12,7,6,2].\n- (6, 2) are non-coprime with LCM(6, 2) = 6. Now, nums = [12,7,6].\nThere are no more adjacent non-coprime numbers in nums.\nThus, the final modified array is [12,7,6].\nNote that there are other ways to obtain the same resultant array.\n\nExample 2:\n\nInput: nums = [2,2,1,1,3,3,3]\nOutput: [2,1,1,3]\nExplanation:\n- (3, 3) are non-coprime with LCM(3, 3) = 3. Now, nums = [2,2,1,1,3,3].\n- (3, 3) are non-coprime with LCM(3, 3) = 3. Now, nums = [2,2,1,1,3].\n- (2, 2) are non-coprime with LCM(2, 2) = 2. Now, nums = [2,1,1,3].\nThere are no more adjacent non-coprime numbers in nums.\nThus, the final modified array is [2,1,1,3].\nNote that there are other ways to obtain the same resultant array.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^5\n- The test cases are generated such that the values in the final array are less than or equal to 10^8.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [4, 6, 8, 10, 12]) == [120]\n    assert candidate(nums = [100000, 100000, 100000, 100000]) == [100000]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [2, 2, 1, 1, 3, 3, 3]) == [2, 1, 1, 3]\n    assert candidate(nums = [9, 27, 81, 243, 729]) == [729]\n    assert candidate(nums = [42, 56, 70, 84, 98]) == [5880]\n    assert candidate(nums = [7, 3, 5, 2, 8, 6]) == [7, 3, 5, 24]\n    assert candidate(nums = [9, 3, 6, 12, 24, 48]) == [144]\n    assert candidate(nums = [100, 200, 300, 400, 500]) == [6000]\n    assert candidate(nums = [7, 11, 13, 17, 19]) == [7, 11, 13, 17, 19]\n    assert candidate(nums = [7, 3, 5, 2, 11]) == [7, 3, 5, 2, 11]\n    assert candidate(nums = [5, 10, 15, 20, 25]) == [300]\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [9]\n    assert candidate(nums = [5, 10, 15, 20]) == [60]\n    assert candidate(nums = [60, 45, 30, 15, 5]) == [180]\n    assert candidate(nums = [6, 4, 3, 2, 7, 6, 2]) == [12, 7, 6]\n    assert candidate(nums = [8, 12, 18, 24, 30]) == [360]\n    assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]\n    assert candidate(nums = [4, 6, 8, 10, 12, 14, 16]) == [1680]\n    assert candidate(nums = [2, 3, 5, 6, 9, 15, 20, 30, 45]) == [180]\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == [17640]\n    assert candidate(nums = [225, 315, 405, 15, 21, 27, 33, 39, 45]) == [2027025]\n    assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125]) == [100000]\n    assert candidate(nums = [9, 3, 27, 81, 243, 729, 2187]) == [2187]\n    assert candidate(nums = [9, 15, 18, 24, 30, 36, 45]) == [360]\n    assert candidate(nums = [210, 154, 110, 77, 49, 35, 21, 7]) == [16170]\n    assert candidate(nums = [360, 420, 480, 12, 15, 18, 21, 24, 27]) == [30240]\n    assert candidate(nums = [25, 15, 10, 20, 12, 30, 18]) == [900]\n    assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [1024]\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == [2522520]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n    assert candidate(nums = [9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]) == [1081080]\n    assert candidate(nums = [14, 21, 35, 56, 98, 112]) == [11760]\n    assert candidate(nums = [72, 48, 32, 16, 8, 4, 2]) == [288]\n    assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [720720]\n    assert candidate(nums = [10, 15, 20, 25, 30, 35, 40]) == [4200]\n    assert candidate(nums = [525, 630, 735, 15, 21, 27, 33, 39, 45]) == [9459450]\n    assert candidate(nums = [12, 18, 24, 30, 36, 42, 48, 54, 60]) == [15120]\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49]) == [2940]\n    assert candidate(nums = [21, 28, 35, 42, 49, 56, 63, 70, 77, 84]) == [194040]\n    assert candidate(nums = [204, 260, 312, 13, 17, 21, 23, 29, 31]) == [185640, 23, 29, 31]\n    assert candidate(nums = [18, 24, 30, 12, 15, 20, 25, 35, 40]) == [12600]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [12600]\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130]) == [32760]\n    assert candidate(nums = [15, 10, 20, 25, 30, 35, 40, 45, 50]) == [12600]\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]\n    assert candidate(nums = [1000, 1250, 1500, 1750, 2000, 2250, 2500]) == [630000]\n    assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500]) == [126000]\n    assert candidate(nums = [9, 15, 21, 27, 33, 39, 45, 51, 57, 63]) == [43648605]\n    assert candidate(nums = [256, 192, 128, 64, 32, 16, 8, 4, 2]) == [768]\n    assert candidate(nums = [110, 154, 198, 11, 14, 18, 22, 26, 30]) == [90090]\n    assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == [32768]\n    assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [72747675]\n    assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95]) == [72747675]\n    assert candidate(nums = [210, 273, 330, 21, 27, 33, 39, 45, 51]) == [4594590]\n    assert candidate(nums = [18, 27, 36, 45, 54, 63, 72, 81, 90, 99]) == [249480]\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165]) == [3963960]\n    assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == [101, 102, 103, 104, 105, 106, 107, 108, 109, 110]\n    assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500]) == [126000]\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == [17640]\n    assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [138600]\n    assert candidate(nums = [12, 15, 20, 25, 30, 35]) == [2100]\n    assert candidate(nums = [495, 595, 693, 11, 13, 17, 19, 23, 29]) == [58905, 13, 17, 19, 23, 29]\n    assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [1024]\n    assert candidate(nums = [100, 25, 50, 20, 40, 80, 160]) == [800]\n    assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [720720]\n    assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [138600]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n    assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == [254520]\n    assert candidate(nums = [100, 50, 25, 125, 200, 80]) == [2000]\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110]) == [27720]\n    assert candidate(nums = [8, 4, 2, 1, 2, 4, 8, 16, 32, 64]) == [8, 1, 64]\n    assert candidate(nums = [21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == [2522520]\n    assert candidate(nums = [25, 45, 65, 85, 105, 125]) == [1740375]\n    assert candidate(nums = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]\n    assert candidate(nums = [63, 77, 91, 14, 18, 22, 26, 30, 34]) == [1531530]\n    assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n    assert candidate(nums = [210, 105, 35, 10, 5, 7, 14, 28, 56]) == [840]\n    assert candidate(nums = [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560]) == [2560]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [25200]\n    assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == [59049]\n    assert candidate(nums = [98, 49, 21, 14, 7, 3, 1]) == [294, 1]\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90]) == [2162160]\n    assert candidate(nums = [100, 75, 150, 25, 50, 125, 200]) == [3000]\n    assert candidate(nums = [121, 143, 169, 11, 13, 17, 19, 23, 29]) == [20449, 17, 19, 23, 29]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [5040]\n    assert candidate(nums = [98, 42, 56, 28, 14, 7, 1]) == [1176, 1]\n    assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n    assert candidate(nums = [18, 27, 36, 45, 54, 63]) == [3780]\n    assert candidate(nums = [45, 90, 135, 270, 540, 1080, 2160]) == [2160]\n    assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240]) == [10240]\n    assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250]) == [63000]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700]) == [42000]\n    assert candidate(nums = [20, 30, 40, 50, 60, 70, 80, 90, 100]) == [25200]\n    assert candidate(nums = [231, 105, 63, 21, 7, 1]) == [3465, 1]\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == [7560]\n    assert candidate(nums = [720, 360, 180, 90, 45, 22, 11]) == [7920]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [1163962800]\n    assert candidate(nums = [49, 42, 35, 28, 21, 14, 7]) == [2940]\n    assert candidate(nums = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109]\n    assert candidate(nums = [9, 15, 45, 30, 18, 60, 20]) == [180]\n    assert candidate(nums = [42, 56, 70, 84, 98, 112, 126, 140, 154, 168, 182, 196]) == [5045040]\n    assert candidate(nums = [6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]) == [1081080]\n    assert candidate(nums = [42, 56, 98, 14, 28, 49, 7, 35]) == [5880]\n    assert candidate(nums = [12, 18, 24, 30, 36, 42, 48, 54, 60, 66]) == [166320]\n    assert candidate(nums = [105, 135, 165, 15, 25, 35, 45, 55, 65]) == [675675]\n    assert candidate(nums = [100, 75, 50, 25, 10, 5, 1]) == [300, 1]\n    assert candidate(nums = [12, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [1163962800]\n    assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120]) == [5120]\n    assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1024, 1]\n    assert candidate(nums = [12, 18, 24, 30, 36, 42, 48, 54, 60, 66]) == [166320]\n    assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == [1536]\n    assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == [59049]\n    assert candidate(nums = [18, 24, 30, 42, 54, 66, 78, 90, 102, 114]) == [349188840]\n    assert candidate(nums = [1000, 1500, 2000, 2500, 3000]) == [30000]\n    assert candidate(nums = [144, 180, 216, 12, 15, 18, 21, 24, 27]) == [15120]\n    assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 15625]) == [500000]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [252000]\n", "comparison": "exact"}, "public_tests": ["[6,4,3,2,7,6,2]", "[2,2,1,1,3,3,3]"], "hints": ["Notice that the order of merging two numbers into their LCM does not matter so we can greedily merge elements to its left if possible.", "If a new value is formed, we should recursively check if it can be merged with the value to its left.", "To simulate the merge efficiently, we can maintain a stack that stores processed elements. When we iterate through the array, we only compare with the top of the stack (which is the value to its left)."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().replaceNonCoprimes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:36+00:00", "tests_total": 134, "tests_dropped": 13, "flags": [], "topic_tags": ["array", "math", "stack", "number-theory", "least-common-multiple", "greatest-common-divisor"]}, "language": "python", "interface": {"raw_signature": "def replaceNonCoprimes(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "replaceNonCoprimes", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2200, "task_id": "find-all-k-distant-indices-in-an-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums and two integers key and k. A k-distant index is an index i of nums for which there exists at least one index j such that |i - j| <= k and nums[j] == key.\n\nReturn a list of all k-distant indices sorted in increasing order.\n\nExample 1:\n\nInput: nums = [3,4,9,1,3,9,5], key = 9, k = 1\nOutput: [1,2,3,4,5,6]\nExplanation: Here, nums[2] == key and nums[5] == key.\n- For index 0, |0 - 2| > k and |0 - 5| > k, so there is no j where |0 - j| <= k and nums[j] == key. Thus, 0 is not a k-distant index.\n- For index 1, |1 - 2| <= k and nums[2] == key, so 1 is a k-distant index.\n- For index 2, |2 - 2| <= k and nums[2] == key, so 2 is a k-distant index.\n- For index 3, |3 - 2| <= k and nums[2] == key, so 3 is a k-distant index.\n- For index 4, |4 - 5| <= k and nums[5] == key, so 4 is a k-distant index.\n- For index 5, |5 - 5| <= k and nums[5] == key, so 5 is a k-distant index.\n- For index 6, |6 - 5| <= k and nums[5] == key, so 6 is a k-distant index.\nThus, we return [1,2,3,4,5,6] which is sorted in increasing order.\n\nExample 2:\n\nInput: nums = [2,2,2,2,2], key = 2, k = 2\nOutput: [0,1,2,3,4]\nExplanation: For all indices i in nums, there exists some index j such that |i - j| <= k and nums[j] == key, so every index is a k-distant index.\nHence, we return [0,1,2,3,4].\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 1 <= nums[i] <= 1000\n- key is an integer from the array nums.\n- 1 <= k <= nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [5, 1, 4, 1, 5],key = 5,k = 2) == [0, 1, 2, 3, 4]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1],key = 1,k = 3) == [0, 1, 2, 3, 4, 5]\n    assert candidate(nums = [1, 3, 5, 7, 9],key = 3,k = 2) == [0, 1, 2, 3]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5],key = 5,k = 3) == [0, 1, 2, 3, 4, 5]\n    assert candidate(nums = [10, 20, 30, 40, 50, 20],key = 20,k = 2) == [0, 1, 2, 3, 4, 5]\n    assert candidate(nums = [1, 2, 3, 4, 5],key = 1,k = 2) == [0, 1, 2]\n    assert candidate(nums = [2, 2, 2, 2, 2],key = 2,k = 2) == [0, 1, 2, 3, 4]\n    assert candidate(nums = [1, 2, 3, 4, 5],key = 5,k = 2) == [2, 3, 4]\n    assert candidate(nums = [10, 20, 30, 40, 50],key = 30,k = 2) == [0, 1, 2, 3, 4]\n    assert candidate(nums = [5, 1, 5, 1, 5],key = 5,k = 1) == [0, 1, 2, 3, 4]\n    assert candidate(nums = [3, 4, 9, 1, 3, 9, 5],key = 9,k = 1) == [1, 2, 3, 4, 5, 6]\n    assert candidate(nums = [5, 4, 3, 2, 1],key = 1,k = 1) == [3, 4]\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],key = 60,k = 3) == [1, 2, 3, 4, 5, 6, 7]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],key = 50,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n    assert candidate(nums = [10, 20, 30, 40, 50, 20, 30, 40, 50],key = 20,k = 2) == [0, 1, 2, 3, 4, 5, 6, 7]\n    assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],key = 5,k = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n    assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],key = 996,k = 3) == [1, 2, 3, 4, 5, 6, 7]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 5,k = 2) == [2, 3, 4, 5, 6]\n    assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4],key = 4,k = 2) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],key = 11,k = 4) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],key = 7,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],key = 1,k = 3) == [5, 6, 7, 8]\n    assert candidate(nums = [7, 3, 4, 7, 1, 7, 5, 7, 3, 7],key = 7,k = 2) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],key = 16,k = 4) == [3, 4, 5, 6, 7, 8, 9, 10, 11]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],key = 500,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],key = 3,k = 4) == [3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],key = 7,k = 2) == [10, 11, 12, 13, 14, 15]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],key = 5,k = 2) == [6, 7, 8, 9, 10, 11]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],key = 10,k = 2) == [2, 3, 4, 5, 6]\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],key = 13,k = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],key = 7,k = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],key = 10,k = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],key = 6,k = 3) == [1, 2, 3, 4, 5, 6, 7]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],key = 7,k = 5) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n    assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10],key = 30,k = 1) == [1, 2, 3, 5, 6, 7]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],key = 3,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],key = 7,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],key = 15,k = 2) == [5, 6, 7, 8, 9]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],key = 100,k = 5) == [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],key = 500,k = 2) == [2, 3, 4, 5, 6]\n    assert candidate(nums = [999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000],key = 999,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],key = 5,k = 2) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 5,k = 2) == [2, 3, 4, 5, 6]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],key = 3,k = 1) == [3, 4, 5, 6]\n    assert candidate(nums = [7, 1, 5, 3, 6, 2, 4, 8, 9, 7, 5, 3, 1],key = 7,k = 3) == [0, 1, 2, 3, 6, 7, 8, 9, 10, 11, 12]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],key = 10,k = 5) == [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],key = 80,k = 5) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],key = 50,k = 3) == [1, 2, 3, 4, 5, 6, 7]\n    assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],key = 5,k = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 10,k = 4) == [5, 6, 7, 8, 9]\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],key = 49,k = 5) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],key = 10,k = 3) == [6, 7, 8, 9, 10, 11, 12]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],key = 3,k = 1) == [3, 4, 5, 6]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],key = 25,k = 3) == [1, 2, 3, 4, 5, 6, 7]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],key = 60,k = 1) == [4, 5, 6]\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],key = 1,k = 3) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],key = 30,k = 1) == [1, 2, 3]\n    assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],key = 1,k = 2) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],key = 8,k = 3) == [4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],key = 3,k = 2) == [2, 3, 4, 5, 6, 7]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],key = 10,k = 5) == [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n    assert candidate(nums = [7, 1, 5, 3, 9, 5, 7, 5, 2, 5],key = 5,k = 1) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],key = 7,k = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n    assert candidate(nums = [100, 200, 300, 400, 500, 300, 200, 100],key = 300,k = 2) == [0, 1, 2, 3, 4, 5, 6, 7]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],key = 13,k = 4) == [2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],key = 3,k = 3) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],key = 15,k = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],key = 8,k = 5) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],key = 50,k = 4) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],key = 500,k = 3) == [1, 2, 3, 4, 5, 6, 7]\n    assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19],key = 7,k = 2) == [0, 1, 2, 3, 4]\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],key = 13,k = 2) == [3, 4, 5, 6, 7]\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],key = 5,k = 2) == [2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],key = 10,k = 4) == [5, 6, 7, 8, 9, 10, 11, 12, 13]\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],key = 5,k = 1) == [3, 4, 5, 7, 8, 9, 10]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],key = 3,k = 2) == [2, 3, 4, 5, 6, 7]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 5,k = 1) == [3, 4, 5]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],key = 5,k = 3) == [2, 3, 4, 5, 6, 7, 8]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],key = 5,k = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],key = 5,k = 2) == [2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],key = 5,k = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],key = 15,k = 6) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],key = 5,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18]\n    assert candidate(nums = [1, 3, 2, 3, 1, 3, 2, 3, 1, 3],key = 3,k = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],key = 5,k = 2) == [2, 3, 4, 5, 6]\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],key = 7,k = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],key = 15,k = 5) == [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],key = 9,k = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],key = 90,k = 4) == [4, 5, 6, 7, 8, 9, 10, 11, 12]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],key = 15,k = 3) == [4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],key = 7,k = 3) == [0, 1, 2, 3, 4, 5, 6]\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42],key = 21,k = 6) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n    assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],key = 5,k = 2) == [2, 3, 4, 5, 6, 10, 11, 12, 13, 14]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],key = 19,k = 7) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n    assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],key = 3,k = 3) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n", "comparison": "exact"}, "public_tests": ["[3,4,9,1,3,9,5]\n9\n1", "[2,2,2,2,2]\n2\n2"], "hints": ["For every occurrence of key in nums, find all indices within distance k from it.", "Use a hash table to remove duplicate indices."], "metadata": {"canonical_parameter_names": ["nums", "key", "k"], "leetcode_dataset_entry_point": "Solution().findKDistantIndices", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:40+00:00", "tests_total": 107, "tests_dropped": 12, "flags": [], "topic_tags": ["array", "two-pointers"]}, "language": "python", "interface": {"raw_signature": "def findKDistantIndices(self, nums: list[int], key: int, k: int) -> list[int]:", "container": "Solution", "callable": "findKDistantIndices", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "key", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2201, "task_id": "count-artifacts-that-can-be-extracted", "difficulty": "Medium", "problem_description": "There is an n x n 0-indexed grid with some artifacts buried in it. You are given the integer n and a 0-indexed 2D integer array artifacts describing the positions of the rectangular artifacts where artifacts[i] = [r1_i, c1_i, r2_i, c2_i] denotes that the i^th artifact is buried in the subgrid where:\n\n- (r1_i, c1_i) is the coordinate of the top-left cell of the i^th artifact and\n- (r2_i, c2_i) is the coordinate of the bottom-right cell of the i^th artifact.\n\nYou will excavate some cells of the grid and remove all the mud from them. If the cell has a part of an artifact buried underneath, it will be uncovered. If all the parts of an artifact are uncovered, you can extract it.\n\nGiven a 0-indexed 2D integer array dig where dig[i] = [r_i, c_i] indicates that you will excavate the cell (r_i, c_i), return the number of artifacts that you can extract.\n\nThe test cases are generated such that:\n\n- No two artifacts overlap.\n- Each artifact only covers at most 4 cells.\n- The entries of dig are unique.\n\nExample 1:\n\nInput: n = 2, artifacts = [[0,0,0,0],[0,1,1,1]], dig = [[0,0],[0,1]]\nOutput: 1\nExplanation:\nThe different colors represent different artifacts. Excavated cells are labeled with a 'D' in the grid.\nThere is 1 artifact that can be extracted, namely the red artifact.\nThe blue artifact has one part in cell (1,1) which remains uncovered, so we cannot extract it.\nThus, we return 1.\n\nExample 2:\n\nInput: n = 2, artifacts = [[0,0,0,0],[0,1,1,1]], dig = [[0,0],[0,1],[1,1]]\nOutput: 2\nExplanation: Both the red and blue artifacts have all parts uncovered (labeled with a 'D') and can be extracted, so we return 2.\n\nConstraints:\n\n- 1 <= n <= 1000\n- 1 <= artifacts.length, dig.length <= min(n^2, 10^5)\n- artifacts[i].length == 4\n- dig[i].length == 2\n- 0 <= r1_i, c1_i, r2_i, c2_i, r_i, c_i <= n - 1\n- r1_i <= r2_i\n- c1_i <= c2_i\n- No two artifacts will overlap.\n- The number of cells covered by an artifact is at most 4.\n- The entries of dig are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 4,artifacts = [[0, 0, 0, 0], [1, 1, 2, 2], [3, 3, 3, 3]],dig = [[0, 0], [1, 1], [2, 2], [3, 3]]) == 2\n    assert candidate(n = 5,artifacts = [[0, 0, 0, 1], [1, 1, 2, 2], [3, 3, 4, 4]],dig = [[0, 0], [0, 1], [1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4]]) == 3\n    assert candidate(n = 5,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 4, 4]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4]]) == 3\n    assert candidate(n = 3,artifacts = [[0, 0, 0, 1], [1, 0, 1, 1], [2, 0, 2, 1]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]) == 3\n    assert candidate(n = 3,artifacts = [[0, 0, 0, 1], [1, 1, 2, 2]],dig = [[0, 0], [0, 1], [1, 1], [1, 2], [2, 1], [2, 2]]) == 2\n    assert candidate(n = 3,artifacts = [[0, 0, 0, 1], [1, 1, 2, 2]],dig = [[0, 0], [0, 1], [1, 1], [2, 2]]) == 1\n    assert candidate(n = 4,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3]]) == 2\n    assert candidate(n = 3,artifacts = [[0, 0, 1, 1], [1, 2, 2, 2]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 2]]) == 2\n    assert candidate(n = 4,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],dig = [[0, 0], [1, 1], [2, 2], [3, 3]]) == 4\n    assert candidate(n = 5,artifacts = [[0, 0, 0, 1], [1, 1, 1, 2], [2, 2, 2, 3], [3, 3, 3, 4]],dig = [[0, 0], [0, 1], [1, 1], [1, 2], [2, 2], [2, 3], [3, 3], [3, 4]]) == 4\n    assert candidate(n = 3,artifacts = [[0, 0, 1, 1], [1, 1, 2, 2]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2]]) == 1\n    assert candidate(n = 3,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2]],dig = [[0, 0], [1, 1], [2, 2]]) == 3\n    assert candidate(n = 2,artifacts = [[0, 0, 0, 0], [0, 1, 1, 1]],dig = [[0, 0], [0, 1], [1, 1]]) == 2\n    assert candidate(n = 2,artifacts = [[0, 0, 0, 0], [0, 1, 1, 1]],dig = [[0, 0], [0, 1]]) == 1\n    assert candidate(n = 3,artifacts = [[0, 0, 0, 1], [1, 1, 1, 2]],dig = [[0, 0], [0, 1], [1, 1]]) == 1\n    assert candidate(n = 7,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 6, 6], [0, 2, 1, 3], [2, 4, 3, 6], [4, 0, 5, 2]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [4, 0], [4, 1], [4, 2], [5, 0], [5, 1], [5, 2], [6, 6]]) == 4\n    assert candidate(n = 8,artifacts = [[0, 0, 1, 2], [2, 3, 3, 4], [4, 5, 5, 6], [6, 7, 7, 7]],dig = [[0, 0], [0, 1], [0, 2], [2, 3], [2, 4], [3, 3], [3, 4], [4, 5], [4, 6], [5, 5], [5, 6], [6, 7], [7, 7]]) == 3\n    assert candidate(n = 10,artifacts = [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 8, 8], [7, 7, 9, 9]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5], [5, 3], [5, 4], [5, 5], [6, 6], [6, 7], [6, 8], [7, 6], [7, 7], [7, 8], [8, 6], [8, 7], [8, 8], [7, 7], [7, 8], [9, 7], [9, 8], [9, 9]]) == 3\n    assert candidate(n = 9,artifacts = [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 8, 8]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [6, 6], [6, 7], [6, 8], [7, 6], [7, 7], [7, 8], [8, 6], [8, 7], [8, 8]]) == 2\n    assert candidate(n = 10,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7], [8, 8, 9, 9]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9]]) == 5\n    assert candidate(n = 7,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 4, 4], [5, 5, 6, 6]],dig = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == 1\n    assert candidate(n = 8,artifacts = [[0, 0, 0, 1], [1, 0, 1, 1], [2, 0, 2, 1], [3, 0, 3, 1], [4, 0, 4, 1], [5, 0, 5, 1], [6, 0, 6, 1], [7, 0, 7, 1]],dig = [[0, 0], [1, 1], [2, 0], [3, 1], [4, 0], [5, 1], [6, 0], [7, 1], [0, 1], [1, 0], [2, 1], [3, 0], [4, 1], [5, 0], [6, 1], [7, 0]]) == 8\n    assert candidate(n = 20,artifacts = [[0, 0, 0, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7], [8, 8, 9, 9], [10, 10, 11, 11], [12, 12, 13, 13], [14, 14, 15, 15], [16, 16, 17, 17], [18, 18, 19, 19]],dig = [[0, 0], [0, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9], [10, 10], [10, 11], [11, 10], [11, 11], [12, 12], [12, 13], [13, 12], [13, 13], [14, 14], [14, 15], [15, 14], [15, 15], [16, 16], [16, 17], [17, 16], [17, 17], [18, 18], [18, 19], [19, 18], [19, 19]]) == 10\n    assert candidate(n = 15,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7], [8, 8, 9, 9], [10, 10, 11, 11], [12, 12, 13, 13], [14, 14, 14, 14]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9], [10, 10], [10, 11], [11, 10], [11, 11], [12, 12], [12, 13], [13, 12], [13, 13], [14, 14]]) == 8\n    assert candidate(n = 15,artifacts = [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 8, 8], [9, 9, 11, 11], [12, 12, 14, 14]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5], [5, 3], [5, 4], [5, 5], [6, 6], [6, 7], [6, 8], [7, 6], [7, 7], [7, 8], [8, 6], [8, 7], [8, 8], [9, 9], [9, 10], [9, 11], [10, 9], [10, 10], [10, 11], [11, 9], [11, 10], [11, 11], [12, 12], [12, 13], [12, 14], [13, 12], [13, 13], [13, 14], [14, 12], [14, 13], [14, 14]]) == 5\n    assert candidate(n = 20,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8], [9, 9, 9, 9], [10, 10, 10, 10], [11, 11, 11, 11], [12, 12, 12, 12], [13, 13, 13, 13], [14, 14, 14, 14], [15, 15, 15, 15], [16, 16, 16, 16], [17, 17, 17, 17], [18, 18, 18, 18], [19, 19, 19, 19]],dig = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]]) == 20\n    assert candidate(n = 500,artifacts = [[0, 0, 1, 1], [498, 498, 499, 499]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [498, 498], [498, 499], [499, 498], [499, 499]]) == 2\n    assert candidate(n = 7,artifacts = [[0, 0, 0, 3], [1, 1, 2, 2], [3, 3, 4, 4], [5, 5, 6, 6]],dig = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6]]) == 4\n    assert candidate(n = 7,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 6, 6]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6]]) == 4\n    assert candidate(n = 15,artifacts = [[0, 0, 0, 3], [1, 1, 1, 4], [2, 2, 2, 5], [3, 3, 3, 6], [4, 4, 4, 7], [5, 5, 5, 8], [6, 6, 6, 9], [7, 7, 7, 10], [8, 8, 8, 11], [9, 9, 9, 12]],dig = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [1, 4], [2, 2], [2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [5, 7], [5, 8], [6, 6], [6, 7], [6, 8], [6, 9], [7, 7], [7, 8], [7, 9], [7, 10], [8, 8], [8, 9], [8, 10], [8, 11], [9, 9], [9, 10], [9, 11], [9, 12]]) == 10\n    assert candidate(n = 6,artifacts = [[0, 0, 2, 1], [3, 2, 4, 3], [1, 4, 2, 5], [4, 0, 5, 1]],dig = [[0, 0], [0, 1], [1, 4], [1, 5], [2, 0], [2, 1], [3, 2], [3, 3], [4, 0], [4, 1], [4, 2], [4, 3], [5, 0], [5, 1]]) == 2\n    assert candidate(n = 1000,artifacts = [[0, 0, 0, 0], [999, 999, 999, 999]],dig = [[0, 0], [999, 999]]) == 2\n    assert candidate(n = 12,artifacts = [[0, 0, 0, 2], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7], [8, 8, 9, 9], [10, 10, 11, 11]],dig = [[0, 0], [0, 1], [0, 2], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9], [10, 10], [10, 11], [11, 10], [11, 11]]) == 6\n    assert candidate(n = 5,artifacts = [[0, 0, 1, 2], [2, 0, 3, 1], [4, 2, 4, 4]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [3, 0], [3, 1], [4, 2], [4, 3], [4, 4]]) == 3\n    assert candidate(n = 100,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [98, 98, 98, 98], [99, 99, 99, 99]],dig = [[0, 0], [1, 1], [98, 98], [99, 99]]) == 4\n    assert candidate(n = 20,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7], [8, 8, 9, 9], [10, 10, 11, 11], [12, 12, 13, 13], [14, 14, 15, 15], [16, 16, 17, 17], [18, 18, 19, 19]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9], [10, 10], [10, 11], [11, 10], [11, 11], [12, 12], [12, 13], [13, 12], [13, 13], [14, 14], [14, 15], [15, 14], [15, 15], [16, 16], [16, 17], [17, 16], [17, 17], [18, 18], [18, 19], [19, 18], [19, 19]]) == 10\n    assert candidate(n = 1000,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [998, 998, 999, 999]],dig = [[0, 0], [1, 1], [998, 998], [999, 999]]) == 2\n    assert candidate(n = 6,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]],dig = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 6\n    assert candidate(n = 10,artifacts = [[0, 0, 2, 1], [3, 3, 5, 4], [6, 6, 8, 7]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1], [3, 3], [3, 4], [4, 3], [4, 4], [5, 3], [5, 4], [6, 6], [6, 7], [7, 6], [7, 7], [8, 6], [8, 7]]) == 3\n    assert candidate(n = 8,artifacts = [[0, 0, 0, 1], [1, 2, 2, 3], [3, 4, 4, 5], [5, 6, 6, 7]],dig = [[0, 0], [0, 1], [1, 2], [1, 3], [2, 2], [2, 3], [3, 4], [3, 5], [4, 4], [4, 5], [5, 6], [5, 7], [6, 6], [6, 7]]) == 4\n    assert candidate(n = 10,artifacts = [[0, 0, 0, 1], [1, 1, 1, 2], [2, 2, 2, 3], [3, 3, 3, 4], [4, 4, 4, 5], [5, 5, 5, 6], [6, 6, 6, 7], [7, 7, 7, 8], [8, 8, 8, 9], [9, 9, 9, 9]],dig = [[0, 0], [0, 1], [1, 1], [1, 2], [2, 2], [2, 3], [3, 3], [3, 4], [4, 4], [4, 5], [5, 5], [5, 6], [6, 6], [6, 7], [7, 7], [7, 8], [8, 8], [8, 9], [9, 9]]) == 10\n    assert candidate(n = 12,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7], [8, 8, 9, 9], [10, 10, 11, 11]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9], [10, 10], [10, 11], [11, 10], [11, 11]]) == 6\n    assert candidate(n = 7,artifacts = [[0, 0, 1, 1], [2, 2, 2, 3], [3, 3, 4, 4], [5, 5, 6, 6]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6]]) == 4\n    assert candidate(n = 10,artifacts = [[0, 0, 2, 2], [3, 3, 4, 4], [5, 5, 6, 6], [7, 7, 8, 8], [1, 1, 2, 2], [3, 5, 4, 6], [7, 9, 8, 9]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [7, 8], [7, 9], [8, 7], [8, 8], [8, 9], [3, 5], [3, 6], [4, 5], [4, 6]]) == 7\n    assert candidate(n = 8,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 0], [7, 1]]) == 4\n    assert candidate(n = 5,artifacts = [[0, 0, 1, 1], [1, 2, 2, 3], [3, 4, 3, 4]],dig = [[0, 0], [0, 1], [1, 2], [1, 3], [2, 2], [2, 3], [3, 4]]) == 2\n    assert candidate(n = 9,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7], [8, 8, 8, 8], [0, 2, 1, 3], [2, 4, 3, 6], [4, 0, 5, 2], [6, 4, 7, 6]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [4, 0], [4, 1], [4, 2], [5, 0], [5, 1], [5, 2], [6, 4], [6, 5], [6, 6], [7, 4], [7, 5], [7, 6], [8, 8]]) == 5\n    assert candidate(n = 20,artifacts = [[0, 0, 3, 3], [4, 4, 7, 7], [8, 8, 11, 11], [12, 12, 15, 15], [16, 16, 19, 19]],dig = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [2, 3], [3, 0], [3, 1], [3, 2], [3, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 4], [5, 5], [5, 6], [5, 7], [6, 4], [6, 5], [6, 6], [6, 7], [7, 4], [7, 5], [7, 6], [7, 7], [8, 8], [8, 9], [8, 10], [8, 11], [9, 8], [9, 9], [9, 10], [9, 11], [10, 8], [10, 9], [10, 10], [10, 11], [11, 8], [11, 9], [11, 10], [11, 11], [12, 12], [12, 13], [12, 14], [12, 15], [13, 12], [13, 13], [13, 14], [13, 15], [14, 12], [14, 13], [14, 14], [14, 15], [15, 12], [15, 13], [15, 14], [15, 15], [16, 16], [16, 17], [16, 18], [16, 19], [17, 16], [17, 17], [17, 18], [17, 19], [18, 16], [18, 17], [18, 18], [18, 19], [19, 16], [19, 17], [19, 18], [19, 19]]) == 5\n    assert candidate(n = 10,artifacts = [[0, 0, 1, 1], [3, 3, 4, 4], [6, 6, 7, 7], [9, 9, 9, 9]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [3, 3], [3, 4], [4, 3], [4, 4], [6, 6], [6, 7], [7, 6], [7, 7], [9, 9]]) == 4\n    assert candidate(n = 6,artifacts = [[0, 0, 0, 1], [1, 1, 1, 2], [2, 2, 2, 3], [3, 3, 3, 4], [4, 4, 4, 5], [5, 5, 5, 5]],dig = [[0, 0], [0, 1], [1, 1], [1, 2], [2, 2], [2, 3], [3, 3], [3, 4], [4, 4], [4, 5], [5, 5]]) == 6\n    assert candidate(n = 1000,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]],dig = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 5\n    assert candidate(n = 10,artifacts = [[0, 0, 1, 1], [3, 3, 5, 5], [7, 7, 9, 9]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [4, 4], [5, 3], [5, 4], [5, 5], [7, 7], [7, 8], [7, 9], [8, 7], [8, 8], [8, 9], [9, 7], [9, 8], [9, 9]]) == 2\n    assert candidate(n = 10,artifacts = [[0, 0, 0, 3], [1, 1, 2, 2], [3, 3, 3, 3]],dig = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [2, 1], [2, 2], [3, 3]]) == 3\n    assert candidate(n = 10,artifacts = [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 8, 8], [9, 9, 9, 9]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5], [5, 3], [5, 4], [5, 5], [6, 6], [6, 7], [6, 8], [7, 6], [7, 7], [7, 8], [8, 6], [8, 7], [8, 8], [9, 9]]) == 4\n    assert candidate(n = 8,artifacts = [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 7, 7]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5], [5, 3], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7]]) == 3\n    assert candidate(n = 8,artifacts = [[0, 0, 0, 1], [1, 1, 1, 2], [2, 2, 2, 3], [3, 3, 3, 4], [4, 4, 4, 5], [5, 5, 5, 6], [6, 6, 6, 7], [0, 2, 1, 3], [2, 4, 3, 5], [4, 6, 5, 7]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [1, 3], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [3, 5], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6], [5, 7], [6, 6], [6, 7]]) == 7\n    assert candidate(n = 5,artifacts = [[0, 0, 2, 2], [1, 1, 3, 3]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2]]) == 1\n    assert candidate(n = 15,artifacts = [[1, 1, 2, 2], [3, 3, 4, 4], [5, 5, 6, 6], [7, 7, 8, 8]],dig = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [7, 8], [8, 7], [8, 8]]) == 4\n    assert candidate(n = 15,artifacts = [[0, 0, 0, 1], [1, 0, 1, 1], [2, 0, 2, 1], [3, 0, 3, 1], [4, 0, 4, 1], [5, 0, 5, 1], [6, 0, 6, 1], [7, 0, 7, 1], [8, 0, 8, 1], [9, 0, 9, 1], [10, 0, 10, 1], [11, 0, 11, 1], [12, 0, 12, 1], [13, 0, 13, 1], [14, 0, 14, 1]],dig = [[0, 0], [1, 1], [2, 0], [3, 1], [4, 0], [5, 1], [6, 0], [7, 1], [8, 0], [9, 1], [10, 0], [11, 1], [12, 0], [13, 1], [14, 0]]) == 0\n    assert candidate(n = 9,artifacts = [[0, 0, 1, 1], [2, 2, 3, 3], [4, 4, 5, 5], [6, 6, 7, 7], [8, 8, 8, 8]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8]]) == 5\n    assert candidate(n = 10,artifacts = [[0, 0, 1, 1], [3, 3, 4, 4], [6, 6, 7, 7], [8, 8, 9, 9]],dig = [[0, 0], [0, 1], [1, 0], [1, 1], [3, 3], [3, 4], [4, 3], [4, 4], [6, 6], [6, 7], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9]]) == 4\n    assert candidate(n = 10,artifacts = [[0, 0, 0, 1], [1, 0, 1, 1], [2, 0, 2, 1], [3, 0, 3, 1], [4, 0, 4, 1], [5, 0, 5, 1], [6, 0, 6, 1], [7, 0, 7, 1], [8, 0, 8, 1], [9, 0, 9, 1]],dig = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 1], [1, 0], [2, 1], [3, 0], [4, 1], [5, 0], [6, 1], [7, 0], [8, 1], [9, 0]]) == 2\n    assert candidate(n = 8,artifacts = [[0, 0, 0, 2], [1, 1, 1, 3], [2, 2, 2, 4], [3, 3, 3, 5], [4, 4, 4, 6], [5, 5, 5, 7], [6, 6, 6, 7]],dig = [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [1, 3], [2, 2], [2, 3], [2, 4], [3, 3], [3, 4], [3, 5], [4, 4], [4, 5], [4, 6], [5, 5], [5, 6], [5, 7], [6, 6], [6, 7]]) == 7\n    assert candidate(n = 10,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8], [9, 9, 9, 9]],dig = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 10\n    assert candidate(n = 9,artifacts = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]],dig = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == 9\n    assert candidate(n = 10,artifacts = [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 8, 8], [7, 7, 9, 9]],dig = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5], [5, 3], [5, 4], [5, 5], [6, 6], [6, 7], [6, 8], [7, 6], [7, 7], [7, 8], [8, 6], [8, 7], [8, 8], [7, 7], [9, 9]]) == 3\n", "comparison": "exact"}, "public_tests": ["2\n[[0,0,0,0],[0,1,1,1]]\n[[0,0],[0,1]]", "2\n[[0,0,0,0],[0,1,1,1]]\n[[0,0],[0,1],[1,1]]"], "hints": ["Check if each coordinate of each artifact has been excavated. How can we do this quickly without iterating over the dig array every time?", "Consider marking all excavated cells in a 2D boolean array."], "metadata": {"canonical_parameter_names": ["n", "artifacts", "dig"], "leetcode_dataset_entry_point": "Solution().digArtifacts", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:43+00:00", "tests_total": 66, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "simulation"]}, "language": "python", "interface": {"raw_signature": "def digArtifacts(self, n: int, artifacts: list[list[int]], dig: list[list[int]]) -> int:", "container": "Solution", "callable": "digArtifacts", "parameters": [{"name": "n", "type": "int"}, {"name": "artifacts", "type": "list[list[int]]"}, {"name": "dig", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2202, "task_id": "maximize-the-topmost-element-after-k-moves", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums representing the contents of a pile, where nums[0] is the topmost element of the pile.\n\nIn one move, you can perform either of the following:\n\n- If the pile is not empty, remove the topmost element of the pile.\n- If there are one or more removed elements, add any one of them back onto the pile. This element becomes the new topmost element.\n\nYou are also given an integer k, which denotes the total number of moves to be made.\n\nReturn the maximum value of the topmost element of the pile possible after exactly k moves. In case it is not possible to obtain a non-empty pile after k moves, return -1.\n\nExample 1:\n\nInput: nums = [5,2,2,4,0,6], k = 4\nOutput: 5\nExplanation:\nOne of the ways we can end with 5 at the top of the pile after 4 moves is as follows:\n- Step 1: Remove the topmost element = 5. The pile becomes [2,2,4,0,6].\n- Step 2: Remove the topmost element = 2. The pile becomes [2,4,0,6].\n- Step 3: Remove the topmost element = 2. The pile becomes [4,0,6].\n- Step 4: Add 5 back onto the pile. The pile becomes [5,4,0,6].\nNote that this is not the only way to end with 5 at the top of the pile. It can be shown that 5 is the largest answer possible after 4 moves.\n\nExample 2:\n\nInput: nums = [2], k = 1\nOutput: -1\nExplanation:\nIn the first move, our only option is to pop the topmost element of the pile.\nSince it is not possible to obtain a non-empty pile after one move, we return -1.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= nums[i], k <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [7, 7, 7, 7, 7],k = 2) == 7\n    assert candidate(nums = [9, 8, 7, 6, 5],k = 5) == 9\n    assert candidate(nums = [10],k = 2) == 10\n    assert candidate(nums = [8, 6, 4, 2, 0],k = 7) == 8\n    assert candidate(nums = [7, 7, 7, 7, 7],k = 3) == 7\n    assert candidate(nums = [1000000000],k = 0) == 1000000000\n    assert candidate(nums = [5, 4, 3, 2, 1],k = 2) == 5\n    assert candidate(nums = [1],k = 2) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9],k = 10) == 9\n    assert candidate(nums = [3, 3, 3, 3, 3, 3],k = 1000000000) == 3\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 4\n    assert candidate(nums = [2],k = 1) == -1\n    assert candidate(nums = [9, 7, 5, 3, 1],k = 5) == 9\n    assert candidate(nums = [10],k = 0) == 10\n    assert candidate(nums = [1, 3, 5, 7, 9],k = 2) == 5\n    assert candidate(nums = [9],k = 0) == 9\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n    assert candidate(nums = [0, 0, 0, 0, 0],k = 5) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9],k = 0) == 1\n    assert candidate(nums = [1000000000],k = 1000000000) == 1000000000\n    assert candidate(nums = [1, 1, 1, 1, 1],k = 5) == 1\n    assert candidate(nums = [5, 2, 2, 4, 0, 6],k = 4) == 5\n    assert candidate(nums = [1, 2],k = 2) == 1\n    assert candidate(nums = [3, 3, 3, 3, 3],k = 5) == 3\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == 9\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 9) == 9\n    assert candidate(nums = [1, 1, 1, 1, 1],k = 0) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 0) == 1\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5) == 9\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11) == 10\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5) == 100\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 6\n    assert candidate(nums = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2],k = 9) == 20\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 10\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 15) == 19\n    assert candidate(nums = [3, 7, 2, 8, 6, 4, 1, 9],k = 3) == 8\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11) == 10\n    assert candidate(nums = [5, 2, 9, 1, 5, 6, 7, 3, 4, 8],k = 15) == 9\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 7) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 19) == 10\n    assert candidate(nums = [5, 2, 2, 4, 0, 6],k = 6) == 5\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 9\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 7) == 9\n    assert candidate(nums = [90, 80, 70, 60, 50, 40, 30, 20, 10],k = 7) == 90\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 90\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 5\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 60\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 10\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],k = 9) == 20\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 18) == 19\n    assert candidate(nums = [1],k = 1000000000) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 8) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 90\n    assert candidate(nums = [1000000000, 1000000000, 1000000000],k = 2) == 1000000000\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 20) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 8\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 11) == 1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 20) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 10\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 2) == 30\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 21) == 10\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 25) == 20\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 19\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 10) == 9\n    assert candidate(nums = [5, 1, 3, 2, 8, 7],k = 3) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 10\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 1\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 10\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],k = 7) == 1\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 10) == 7\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 9\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 10) == 9\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 11) == 20\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],k = 3) == 7\n    assert candidate(nums = [5, 2, 9, 1, 5, 6],k = 3) == 5\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 8) == 45\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 3) == 40\n    assert candidate(nums = [7, 3, 5, 4, 1, 9, 8, 6, 2],k = 6) == 8\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 60\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 8) == 9\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 1\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 10) == 100\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 10) == 7\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 999999) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 5) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 10\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 8) == 9\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15) == 1\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 14) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 12) == 13\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 100) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 13) == 10\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 17\n    assert candidate(nums = [7, 1, 5, 3, 6, 4],k = 3) == 7\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9) == 1\n    assert candidate(nums = [3, 7, 2, 5, 8, 6, 1],k = 10) == 8\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 999999999) == 100\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 6\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 6, 7, 9],k = 100) == 9\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 10\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 20) == 19\n    assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 9) == 100\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 7) == 9\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 10) == 9\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],k = 9) == 5\n    assert candidate(nums = [5, 1, 3, 2, 8, 7],k = 6) == 8\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 18) == 10\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 9) == 5\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],k = 12) == 14\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2) == 30\n    assert candidate(nums = [1, 1, 1, 1, 1, 1],k = 10) == 1\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5) == 12\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 20) == 19\n    assert candidate(nums = [100, 90, 80, 70, 60],k = 6) == 100\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 4\n    assert candidate(nums = [1000000000, 999999999, 888888888, 777777777],k = 4) == 1000000000\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 4) == 100\n    assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 9) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 12) == 10\n    assert candidate(nums = [5, 3, 1, 4, 9, 8],k = 5) == 8\n    assert candidate(nums = [100, 200, 300, 400, 500],k = 2) == 300\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 11) == 9\n    assert candidate(nums = [1, 3, 5, 7, 9],k = 5) == 7\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 9) == 2\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 15) == 100\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 0) == 1\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 7) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 10\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 9\n    assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 9) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == 1\n    assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666],k = 10) == 1000000000\n    assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9],k = 8) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 100) == 10\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 9\n    assert candidate(nums = [5, 4, 3, 2, 1],k = 2) == 5\n    assert candidate(nums = [50, 50, 50, 50, 50],k = 4) == 50\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 9) == 5\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 1) == 20\n", "comparison": "exact"}, "public_tests": ["[5,2,2,4,0,6]\n4", "[2]\n1"], "hints": ["For each index i, how can we check if nums[i] can be present at the top of the pile or not after k moves?", "For which conditions will we end up with an empty pile?"], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumTop", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:45+00:00", "tests_total": 148, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maximumTop(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "maximumTop", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2203, "task_id": "minimum-weighted-subgraph-with-the-required-paths", "difficulty": "Hard", "problem_description": "You are given an integer n denoting the number of nodes of a weighted directed graph. The nodes are numbered from 0 to n - 1.\n\nYou are also given a 2D integer array edges where edges[i] = [from_i, to_i, weight_i] denotes that there exists a directed edge from from_i to to_i with weight weight_i.\n\nLastly, you are given three distinct integers src1, src2, and dest denoting three distinct nodes of the graph.\n\nReturn the minimum weight of a subgraph of the graph such that it is possible to reach dest from both src1 and src2 via a set of edges of this subgraph. In case such a subgraph does not exist, return -1.\n\nA subgraph is a graph whose vertices and edges are subsets of the original graph. The weight of a subgraph is the sum of weights of its constituent edges.\n\nExample 1:\n\nInput: n = 6, edges = [[0,2,2],[0,5,6],[1,0,3],[1,4,5],[2,1,1],[2,3,3],[2,3,4],[3,4,2],[4,5,1]], src1 = 0, src2 = 1, dest = 5\nOutput: 9\nExplanation:\nThe above figure represents the input graph.\nThe blue edges represent one of the subgraphs that yield the optimal answer.\nNote that the subgraph [[1,0,3],[0,5,6]] also yields the optimal answer. It is not possible to get a subgraph with less weight satisfying all the constraints.\n\nExample 2:\n\nInput: n = 3, edges = [[0,1,1],[2,1,1]], src1 = 0, src2 = 1, dest = 2\nOutput: -1\nExplanation:\nThe above figure represents the input graph.\nIt can be seen that there does not exist any path from node 1 to node 2, hence there are no subgraphs satisfying all the constraints.\n\nConstraints:\n\n- 3 <= n <= 10^5\n- 0 <= edges.length <= 10^5\n- edges[i].length == 3\n- 0 <= from_i, to_i, src1, src2, dest <= n - 1\n- from_i != to_i\n- src1, src2, and dest are pairwise distinct.\n- 1 <= weight[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 6,edges = [[0, 2, 2], [0, 5, 6], [1, 0, 3], [1, 4, 5], [2, 1, 1], [2, 3, 3], [2, 3, 4], [3, 4, 2], [4, 5, 1]],src1 = 0,src2 = 1,dest = 5) == 9\n    assert candidate(n = 6,edges = [[1, 2, 2], [1, 3, 1], [2, 4, 5], [3, 4, 3], [4, 5, 2]],src1 = 1,src2 = 2,dest = 5) == 9\n    assert candidate(n = 3,edges = [[0, 1, 1], [2, 1, 1]],src1 = 0,src2 = 1,dest = 2) == -1\n    assert candidate(n = 5,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 0, 50]],src1 = 0,src2 = 2,dest = 4) == 100\n    assert candidate(n = 4,edges = [[0, 1, 2], [0, 2, 2], [1, 3, 1], [2, 3, 1]],src1 = 0,src2 = 1,dest = 3) == 3\n    assert candidate(n = 5,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 0, 5]],src1 = 0,src2 = 1,dest = 4) == 10\n    assert candidate(n = 5,edges = [[0, 1, 10], [0, 2, 5], [1, 3, 1], [1, 4, 2], [2, 3, 4], [2, 4, 3]],src1 = 0,src2 = 1,dest = 4) == 10\n    assert candidate(n = 5,edges = [[0, 1, 10], [0, 2, 3], [1, 3, 2], [2, 1, 4], [2, 3, 8], [2, 4, 2]],src1 = 0,src2 = 2,dest = 3) == 9\n    assert candidate(n = 4,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 1, 4]],src1 = 0,src2 = 2,dest = 3) == 6\n    assert candidate(n = 5,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [2, 3, 1], [2, 4, 4]],src1 = 0,src2 = 2,dest = 3) == 4\n    assert candidate(n = 4,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 1], [2, 3, 3]],src1 = 0,src2 = 1,dest = 3) == 3\n    assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 1], [1, 4, 2], [2, 5, 1], [2, 6, 2], [3, 6, 1], [4, 6, 2]],src1 = 0,src2 = 1,dest = 6) == 3\n    assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12]],src1 = 0,src2 = 6,dest = 11) == 66\n    assert candidate(n = 10,edges = [[0, 1, 20], [0, 2, 30], [1, 3, 40], [1, 4, 50], [2, 4, 60], [2, 5, 70], [3, 6, 80], [3, 7, 90], [4, 7, 100], [4, 8, 110], [5, 8, 120], [5, 9, 130], [6, 9, 140], [7, 9, 150]],src1 = 0,src2 = 2,dest = 9) == 230\n    assert candidate(n = 6,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 4, 4], [3, 5, 5], [4, 5, 6]],src1 = 0,src2 = 1,dest = 5) == 9\n    assert candidate(n = 20,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20], [0, 10, 1], [1, 11, 2], [2, 12, 3], [3, 13, 4], [4, 14, 5], [5, 15, 6], [6, 16, 7], [7, 17, 8], [8, 18, 9], [9, 19, 10], [10, 0, 11], [11, 1, 12], [12, 2, 13], [13, 3, 14], [14, 4, 15], [15, 5, 16], [16, 6, 17], [17, 7, 18], [18, 8, 19], [19, 9, 20]],src1 = 0,src2 = 2,dest = 19) == 55\n    assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 4, 6], [3, 5, 7], [3, 6, 8], [4, 5, 9], [4, 6, 10], [5, 7, 11], [6, 7, 12]],src1 = 0,src2 = 3,dest = 7) == 22\n    assert candidate(n = 15,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 3], [1, 4, 1], [2, 3, 1], [2, 4, 5], [3, 5, 2], [4, 5, 3], [5, 6, 4], [6, 7, 1], [7, 8, 3], [8, 9, 2], [9, 10, 4], [10, 11, 5], [11, 12, 6], [12, 13, 7], [13, 14, 8]],src1 = 0,src2 = 1,dest = 14) == 46\n    assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 8, 9], [6, 7, 10]],src1 = 0,src2 = 2,dest = 8) == 16\n    assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 4, 6], [3, 5, 7], [3, 6, 8], [4, 5, 9], [4, 6, 10], [5, 7, 11], [6, 7, 12], [7, 8, 13], [8, 9, 14], [8, 10, 15], [9, 11, 16], [10, 11, 17]],src1 = 0,src2 = 5,dest = 11) == 65\n    assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12], [0, 5, 1], [1, 6, 2], [2, 7, 3], [3, 8, 4], [4, 9, 5], [5, 10, 6], [6, 11, 7], [7, 0, 8], [8, 1, 9], [9, 2, 10], [10, 3, 11], [11, 4, 12]],src1 = 0,src2 = 2,dest = 11) == 21\n    assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 4, 6], [3, 5, 7], [3, 6, 8], [4, 5, 9], [4, 6, 10], [5, 7, 11], [6, 7, 12], [7, 8, 13]],src1 = 0,src2 = 4,dest = 8) == 38\n    assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 2], [2, 4, 3], [3, 5, 1], [3, 6, 2], [4, 5, 2], [4, 6, 3], [5, 7, 1], [6, 7, 2]],src1 = 0,src2 = 2,dest = 7) == 6\n    assert candidate(n = 7,edges = [[0, 1, 3], [0, 2, 5], [1, 2, 2], [1, 3, 8], [2, 3, 4], [2, 4, 9], [3, 4, 1], [3, 5, 6], [4, 5, 7], [4, 6, 10], [5, 6, 5]],src1 = 0,src2 = 2,dest = 6) == 20\n    assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 3, 1], [2, 5, 7], [3, 6, 3], [4, 6, 2], [5, 6, 6]],src1 = 0,src2 = 2,dest = 6) == 7\n    assert candidate(n = 10,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 9, 15], [1, 8, 14], [2, 7, 13], [3, 6, 12], [4, 5, 11]],src1 = 0,src2 = 1,dest = 9) == 24\n    assert candidate(n = 8,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 3], [1, 4, 5], [2, 4, 1], [2, 5, 6], [3, 6, 7], [4, 6, 8], [4, 7, 9], [5, 7, 3], [6, 7, 10]],src1 = 0,src2 = 1,dest = 7) == 16\n    assert candidate(n = 12,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12], [11, 0, 13], [0, 5, 1], [1, 6, 2], [2, 7, 3], [3, 8, 4], [4, 9, 5], [5, 10, 6], [6, 11, 7], [7, 0, 8], [8, 1, 9], [9, 2, 10], [10, 3, 11], [11, 4, 12]],src1 = 0,src2 = 6,dest = 11) == 11\n    assert candidate(n = 8,edges = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 0, 40], [0, 3, 2], [1, 4, 3], [2, 5, 4], [3, 6, 5], [4, 7, 6]],src1 = 0,src2 = 1,dest = 7) == 14\n    assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [0, 3, 5], [1, 4, 6], [2, 5, 7], [3, 6, 8], [4, 7, 9], [5, 8, 10], [6, 9, 11]],src1 = 0,src2 = 2,dest = 9) == 25\n    assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 7, 8], [5, 7, 9], [6, 7, 10]],src1 = 0,src2 = 1,dest = 7) == 11\n    assert candidate(n = 8,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [1, 4, 40], [2, 5, 50], [2, 6, 60], [3, 7, 70], [4, 7, 80], [5, 7, 90], [6, 7, 100]],src1 = 0,src2 = 2,dest = 7) == 160\n    assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 4, 6], [3, 5, 7], [4, 5, 8], [5, 6, 9]],src1 = 0,src2 = 1,dest = 6) == 20\n    assert candidate(n = 10,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10]],src1 = 0,src2 = 5,dest = 9) == 45\n    assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 5, 6], [3, 6, 7], [3, 7, 8], [4, 7, 9], [4, 8, 10], [5, 8, 11], [6, 8, 12]],src1 = 0,src2 = 2,dest = 8) == 19\n    assert candidate(n = 15,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15]],src1 = 0,src2 = 7,dest = 14) == 105\n    assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 1], [1, 4, 4], [2, 1, 2], [2, 3, 6], [3, 4, 2], [4, 5, 7], [5, 6, 1], [6, 7, 2], [7, 8, 3], [8, 9, 1]],src1 = 0,src2 = 2,dest = 9) == 22\n    assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 4], [2, 5, 6], [2, 6, 7], [3, 7, 8], [4, 8, 1], [5, 9, 2], [6, 9, 3], [7, 9, 9], [8, 9, 6]],src1 = 0,src2 = 2,dest = 9) == 11\n    assert candidate(n = 11,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [1, 4, 40], [2, 4, 50], [2, 5, 60], [3, 6, 70], [3, 7, 80], [4, 7, 90], [4, 8, 100], [5, 8, 110], [5, 9, 120], [6, 9, 130], [6, 10, 140], [7, 10, 150], [8, 10, 160]],src1 = 0,src2 = 2,dest = 10) == 310\n    assert candidate(n = 15,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 5, 6], [2, 6, 7], [3, 7, 8], [3, 8, 9], [4, 8, 10], [4, 9, 11], [5, 9, 12], [5, 10, 13], [6, 10, 14], [6, 11, 15], [7, 11, 16], [7, 12, 17], [8, 12, 18], [9, 12, 19], [10, 13, 20], [11, 13, 21], [12, 14, 22]],src1 = 0,src2 = 5,dest = 14) == 62\n    assert candidate(n = 15,edges = [[0, 1, 10], [0, 5, 20], [1, 2, 5], [1, 3, 15], [2, 4, 10], [3, 6, 20], [4, 7, 5], [5, 8, 15], [6, 9, 20], [7, 10, 10], [8, 11, 20], [9, 12, 25], [10, 13, 15], [11, 14, 25], [12, 13, 5], [13, 14, 20]],src1 = 0,src2 = 5,dest = 14) == 80\n    assert candidate(n = 7,edges = [[0, 1, 10], [0, 2, 5], [1, 3, 1], [1, 4, 2], [2, 5, 4], [2, 6, 5], [3, 4, 3], [4, 5, 2], [5, 6, 1]],src1 = 0,src2 = 1,dest = 6) == 14\n    assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 7, 8], [5, 7, 9], [6, 7, 10], [3, 4, 11], [5, 6, 12]],src1 = 0,src2 = 2,dest = 7) == 16\n    assert candidate(n = 15,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 1], [1, 4, 2], [2, 5, 4], [2, 6, 5], [3, 7, 6], [4, 8, 7], [5, 9, 8], [6, 10, 9], [7, 11, 10], [8, 12, 11], [9, 13, 12], [10, 14, 13], [11, 14, 14]],src1 = 0,src2 = 1,dest = 14) == 33\n    assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 8, 10], [7, 9, 11], [8, 9, 12]],src1 = 0,src2 = 2,dest = 9) == 16\n    assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 10, 10], [7, 11, 11], [8, 12, 12], [9, 13, 13], [10, 14, 14], [11, 14, 15], [12, 14, 16]],src1 = 0,src2 = 2,dest = 14) == 32\n    assert candidate(n = 7,edges = [[0, 1, 5], [0, 2, 10], [1, 3, 3], [1, 4, 4], [2, 1, 6], [2, 4, 8], [2, 5, 7], [3, 6, 2], [4, 6, 5], [5, 6, 1]],src1 = 0,src2 = 2,dest = 6) == 16\n    assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 10, 10], [7, 11, 11], [8, 12, 12], [9, 13, 13], [10, 14, 14], [11, 12, 15], [12, 13, 16], [13, 14, 17]],src1 = 0,src2 = 1,dest = 14) == 58\n    assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 9, 10]],src1 = 0,src2 = 1,dest = 9) == -1\n    assert candidate(n = 10,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 1], [1, 4, 3], [2, 5, 2], [2, 6, 5], [3, 7, 1], [4, 7, 2], [5, 8, 3], [6, 8, 4], [7, 9, 5], [8, 9, 6]],src1 = 0,src2 = 2,dest = 9) == 15\n    assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 6], [2, 3, 5], [2, 5, 1], [3, 6, 3], [4, 6, 2], [5, 6, 7]],src1 = 0,src2 = 1,dest = 6) == 9\n    assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 0, 7], [0, 6, 8], [1, 5, 9], [2, 4, 10]],src1 = 0,src2 = 3,dest = 6) == 21\n    assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 4], [2, 3, 1], [2, 5, 7], [3, 6, 3], [4, 6, 2], [5, 7, 6], [6, 8, 2], [7, 8, 5], [8, 9, 10]],src1 = 0,src2 = 1,dest = 9) == 21\n    assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 10, 10], [7, 11, 11], [8, 11, 12], [9, 11, 13], [10, 11, 14]],src1 = 0,src2 = 2,dest = 11) == 29\n    assert candidate(n = 6,edges = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 0, 600]],src1 = 0,src2 = 3,dest = 5) == 1500\n    assert candidate(n = 20,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [0, 19, 1]],src1 = 0,src2 = 10,dest = 19) == 136\n    assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 3], [1, 3, 2], [1, 4, 4], [2, 1, 4], [2, 3, 8], [2, 4, 2], [3, 5, 1], [4, 5, 3], [5, 6, 2], [6, 7, 1], [7, 8, 3], [8, 9, 2], [9, 6, 4]],src1 = 0,src2 = 2,dest = 8) == 14\n    assert candidate(n = 6,edges = [[0, 1, 1000], [1, 2, 2000], [2, 3, 3000], [3, 4, 4000], [4, 5, 5000], [5, 0, 6000], [0, 2, 1500], [1, 3, 2500], [2, 4, 3500], [3, 5, 4500]],src1 = 0,src2 = 1,dest = 5) == 8000\n", "comparison": "exact"}, "public_tests": ["6\n[[0,2,2],[0,5,6],[1,0,3],[1,4,5],[2,1,1],[2,3,3],[2,3,4],[3,4,2],[4,5,1]]\n0\n1\n5", "3\n[[0,1,1],[2,1,1]]\n0\n1\n2"], "hints": ["Consider what the paths from src1 to dest and src2 to dest would look like in the optimal solution.", "It can be shown that in an optimal solution, the two paths from src1 and src2 will coincide at one node, and the remaining part to dest will be the same for both paths. Now consider how to find the node where the paths will coincide.", "How can algorithms for finding the shortest path between two nodes help us?"], "metadata": {"canonical_parameter_names": ["n", "edges", "src1", "src2", "dest"], "leetcode_dataset_entry_point": "Solution().minimumWeight", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:48+00:00", "tests_total": 58, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["graph", "heap-priority-queue", "shortest-path"]}, "language": "python", "interface": {"raw_signature": "def minimumWeight(self, n: int, edges: list[list[int]], src1: int, src2: int, dest: int) -> int:", "container": "Solution", "callable": "minimumWeight", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "src1", "type": "int"}, {"name": "src2", "type": "int"}, {"name": "dest", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2206, "task_id": "divide-array-into-equal-pairs", "difficulty": "Easy", "problem_description": "You are given an integer array nums consisting of 2 * n integers.\n\nYou need to divide nums into n pairs such that:\n\n- Each element belongs to exactly one pair.\n- The elements present in a pair are equal.\n\nReturn true if nums can be divided into n pairs, otherwise return false.\n\nExample 1:\n\nInput: nums = [3,2,3,2,2,2]\nOutput: true\nExplanation:\nThere are 6 elements in nums, so they should be divided into 6 / 2 = 3 pairs.\nIf nums is divided into the pairs (2, 2), (3, 3), and (2, 2), it will satisfy all the conditions.\n\nExample 2:\n\nInput: nums = [1,2,3,4]\nOutput: false\nExplanation:\nThere is no way to divide nums into 4 / 2 = 2 pairs such that the pairs satisfy every condition.\n\nConstraints:\n\n- nums.length == 2 * n\n- 1 <= n <= 500\n- 1 <= nums[i] <= 500\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4]) == True\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2]) == True\n    assert candidate(nums = [1, 2, 1, 3, 2, 3]) == True\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == True\n    assert candidate(nums = [100, 100, 200, 200, 300, 300]) == True\n    assert candidate(nums = [100, 200, 100, 200, 100, 200]) == False\n    assert candidate(nums = [4, 4, 5, 5, 6, 6, 7, 7]) == True\n    assert candidate(nums = [1, 1, 2, 2, 3, 3]) == True\n    assert candidate(nums = [1, 2, 3, 4]) == False\n    assert candidate(nums = [4, 4, 5, 5, 6, 6]) == True\n    assert candidate(nums = [5, 5, 6, 6, 7, 7, 8, 8]) == True\n    assert candidate(nums = [499, 499, 500, 500, 1, 1]) == True\n    assert candidate(nums = [1, 2, 3, 4, 3, 2]) == False\n    assert candidate(nums = [2, 3, 2, 3, 2, 3]) == False\n    assert candidate(nums = [1, 2, 3, 4, 5, 6]) == False\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == True\n    assert candidate(nums = [10, 10, 10, 10, 10, 10]) == True\n    assert candidate(nums = [3, 2, 3, 2, 2, 2]) == True\n    assert candidate(nums = [8, 8, 8, 8, 9, 9, 9, 9]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n    assert candidate(nums = [5, 5, 5, 5, 5, 5]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == False\n    assert candidate(nums = [7, 7, 8, 8, 9, 9, 10, 10]) == True\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2]) == True\n    assert candidate(nums = [500, 500, 499, 499, 498, 498]) == True\n    assert candidate(nums = [1, 2, 1, 2, 3, 3]) == True\n    assert candidate(nums = [499, 499, 498, 498, 497, 497]) == True\n    assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == True\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n    assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499]) == True\n    assert candidate(nums = [499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490]) == True\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == True\n    assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == True\n    assert candidate(nums = [50, 50, 50, 50, 20, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 10, 10, 10, 10, 60, 60, 60, 60, 70, 70, 70, 70]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == False\n    assert candidate(nums = [250, 250, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n    assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n    assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493]) == True\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == True\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == True\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == True\n    assert candidate(nums = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250]) == True\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n    assert candidate(nums = [100, 100, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107]) == True\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n    assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490, 489, 489, 488, 488, 487, 487, 486, 486]) == True\n    assert candidate(nums = [450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450]) == True\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6]) == False\n    assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100, 110, 110, 120, 120, 130, 130, 140, 140, 150, 150]) == True\n    assert candidate(nums = [100, 100, 200, 200, 300, 300, 400, 400, 500, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == True\n    assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490, 489, 489, 488, 488, 487, 487, 486, 486, 485, 485, 484, 484, 483, 483, 482, 482, 481, 481, 480, 480]) == True\n    assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100, 110, 110, 120, 120]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n    assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495]) == True\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4]) == True\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 12, 13, 13]) == True\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n    assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491]) == True\n    assert candidate(nums = [100, 100, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113]) == True\n    assert candidate(nums = [3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 7, 7, 7, 7, 9, 9, 9, 9, 8, 8, 8, 8, 6, 6, 6, 6, 4, 4, 4, 4]) == True\n    assert candidate(nums = [10, 10, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30]) == True\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == False\n    assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490, 489, 489, 488, 488, 487, 487, 486, 486, 485, 485]) == True\n    assert candidate(nums = [100, 100, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120]) == True\n    assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == True\n    assert candidate(nums = [499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490]) == True\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10]) == True\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == True\n    assert candidate(nums = [1, 2, 2, 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n    assert candidate(nums = [250, 250, 251, 251, 252, 252, 253, 253, 254, 254, 255, 255, 256, 256, 257, 257, 258, 258, 259, 259, 260, 260]) == True\n    assert candidate(nums = [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250]) == True\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == True\n    assert candidate(nums = [100, 100, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108]) == True\n    assert candidate(nums = [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150]) == True\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == False\n", "comparison": "exact"}, "public_tests": ["[3,2,3,2,2,2]", "[1,2,3,4]"], "hints": ["For any number x in the range [1, 500], count the number of elements in nums whose values are equal to x.", "The elements with equal value can be divided completely into pairs if and only if their count is even."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().divideArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:52+00:00", "tests_total": 91, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "hash-table", "bit-manipulation", "counting"]}, "language": "python", "interface": {"raw_signature": "def divideArray(self, nums: list[int]) -> bool:", "container": "Solution", "callable": "divideArray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2207, "task_id": "maximize-number-of-subsequences-in-a-string", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string text and another 0-indexed string pattern of length 2, both of which consist of only lowercase English letters.\n\nYou can add either pattern[0] or pattern[1] anywhere in text exactly once. Note that the character can be added even at the beginning or at the end of text.\n\nReturn the maximum number of times pattern can occur as a subsequence of the modified text.\n\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n\nExample 1:\n\nInput: text = \"abdcdbc\", pattern = \"ac\"\nOutput: 4\nExplanation:\nIf we add pattern[0] = 'a' in between text[1] and text[2], we get \"abadcdbc\". Now, the number of times \"ac\" occurs as a subsequence is 4.\nSome other strings which have 4 subsequences \"ac\" after adding a character to text are \"aabdcdbc\" and \"abdacdbc\".\nHowever, strings such as \"abdcadbc\", \"abdccdbc\", and \"abdcdbcc\", although obtainable, have only 3 subsequences \"ac\" and are thus suboptimal.\nIt can be shown that it is not possible to get more than 4 subsequences \"ac\" by adding only one character.\n\nExample 2:\n\nInput: text = \"aabb\", pattern = \"ab\"\nOutput: 6\nExplanation:\nSome of the strings which can be obtained from text and have 6 subsequences \"ab\" are \"aaabb\", \"aaabb\", and \"aabbb\".\n\nConstraints:\n\n- 1 <= text.length <= 10^5\n- pattern.length == 2\n- text and pattern consist only of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(text = \"bbbb\",pattern = \"bb\") == 10\n    assert candidate(text = \"aaaaa\",pattern = \"aa\") == 15\n    assert candidate(text = \"zzzz\",pattern = \"zz\") == 10\n    assert candidate(text = \"abdcdbc\",pattern = \"ac\") == 4\n    assert candidate(text = \"abc\",pattern = \"ca\") == 1\n    assert candidate(text = \"babab\",pattern = \"ba\") == 6\n    assert candidate(text = \"zzz\",pattern = \"zz\") == 6\n    assert candidate(text = \"abcabc\",pattern = \"aa\") == 3\n    assert candidate(text = \"a\",pattern = \"ab\") == 1\n    assert candidate(text = \"ab\",pattern = \"ba\") == 1\n    assert candidate(text = \"aabb\",pattern = \"ab\") == 6\n    assert candidate(text = \"aaa\",pattern = \"aa\") == 6\n    assert candidate(text = \"b\",pattern = \"ab\") == 1\n    assert candidate(text = \"aaaa\",pattern = \"aa\") == 10\n    assert candidate(text = \"xyzxyz\",pattern = \"yx\") == 3\n    assert candidate(text = \"abcabc\",pattern = \"ac\") == 5\n    assert candidate(text = \"xyz\",pattern = \"xz\") == 2\n    assert candidate(text = \"abxyabxyabxy\",pattern = \"bx\") == 9\n    assert candidate(text = \"zxyzxyzxyz\",pattern = \"yz\") == 10\n    assert candidate(text = \"xyzyzyzyzyzx\",pattern = \"yx\") == 10\n    assert candidate(text = \"zzzzzzzzzzz\",pattern = \"zz\") == 66\n    assert candidate(text = \"pqrsrstq\",pattern = \"pq\") == 4\n    assert candidate(text = \"bbabbaaa\",pattern = \"ba\") == 18\n    assert candidate(text = \"ababababab\",pattern = \"ba\") == 15\n    assert candidate(text = \"aaaaabbbbb\",pattern = \"ab\") == 30\n    assert candidate(text = \"aaabbbccc\",pattern = \"ac\") == 12\n    assert candidate(text = \"abacabacaba\",pattern = \"ac\") == 12\n    assert candidate(text = \"abcdefabcdef\",pattern = \"cf\") == 5\n    assert candidate(text = \"bbaabb\",pattern = \"ba\") == 8\n    assert candidate(text = \"bcbcbcbcbb\",pattern = \"bc\") == 16\n    assert candidate(text = \"bbaabaabaabbb\",pattern = \"ab\") == 31\n    assert candidate(text = \"bbbbba\",pattern = \"ba\") == 10\n    assert candidate(text = \"acbacbacba\",pattern = \"ac\") == 10\n    assert candidate(text = \"mnopqr\",pattern = \"pq\") == 2\n    assert candidate(text = \"xyxzyxzyxzyx\",pattern = \"yx\") == 15\n    assert candidate(text = \"zzyzxzyzxzy\",pattern = \"yz\") == 12\n    assert candidate(text = \"xyyxxyyxxyy\",pattern = \"yx\") == 18\n    assert candidate(text = \"aabbccdd\",pattern = \"ac\") == 6\n    assert candidate(text = \"abcdabcdabcd\",pattern = \"ac\") == 9\n    assert candidate(text = \"mississippi\",pattern = \"is\") == 10\n    assert candidate(text = \"zzzzzzzzzz\",pattern = \"zz\") == 55\n    assert candidate(text = \"ababababab\",pattern = \"ab\") == 20\n    assert candidate(text = \"aabbaabbaabbaabbaabbaabbaabbaabb\",pattern = \"bb\") == 136\n    assert candidate(text = \"qwertyuiop\",pattern = \"qp\") == 2\n    assert candidate(text = \"aaaaaaa\",pattern = \"aa\") == 28\n    assert candidate(text = \"abcdabcdabcd\",pattern = \"da\") == 6\n    assert candidate(text = \"zzzzz\",pattern = \"zz\") == 15\n    assert candidate(text = \"abababababab\",pattern = \"ba\") == 21\n    assert candidate(text = \"abababababa\",pattern = \"ab\") == 21\n    assert candidate(text = \"abcabcabcabc\",pattern = \"ac\") == 14\n    assert candidate(text = \"aabbbcc\",pattern = \"ac\") == 6\n    assert candidate(text = \"aabbaabbaabbaabbaabb\",pattern = \"aa\") == 55\n    assert candidate(text = \"babcbabcba\",pattern = \"bc\") == 11\n    assert candidate(text = \"aabbccddeeff\",pattern = \"bf\") == 6\n    assert candidate(text = \"abcabcabc\",pattern = \"ab\") == 9\n    assert candidate(text = \"bcbcbcbcbc\",pattern = \"bc\") == 20\n    assert candidate(text = \"xyxxyxyxyx\",pattern = \"yx\") == 17\n    assert candidate(text = \"abcabcabcabcabcabc\",pattern = \"ca\") == 21\n    assert candidate(text = \"xzyxzyxzyz\",pattern = \"zy\") == 10\n    assert candidate(text = \"zzzzzz\",pattern = \"zz\") == 21\n    assert candidate(text = \"aabbbaaabbbb\",pattern = \"ab\") == 33\n    assert candidate(text = \"aaabbb\",pattern = \"ab\") == 12\n    assert candidate(text = \"nnaaaannaa\",pattern = \"an\") == 14\n    assert candidate(text = \"xyxyxyxyxy\",pattern = \"yx\") == 15\n    assert candidate(text = \"cccccc\",pattern = \"cc\") == 21\n    assert candidate(text = \"abacabadabacaba\",pattern = \"ba\") == 24\n    assert candidate(text = \"bababababababababa\",pattern = \"bb\") == 45\n    assert candidate(text = \"dcbabcdabcba\",pattern = \"ab\") == 9\n    assert candidate(text = \"xyzzyxzyxzyxzyx\",pattern = \"zy\") == 19\n    assert candidate(text = \"aaaaaabbbb\",pattern = \"ab\") == 30\n    assert candidate(text = \"cccccccc\",pattern = \"cc\") == 36\n    assert candidate(text = \"babcbacbab\",pattern = \"bc\") == 10\n    assert candidate(text = \"abcdefghijklmnopqrstuvwxyz\",pattern = \"zy\") == 1\n    assert candidate(text = \"zzzyyy\",pattern = \"yz\") == 3\n    assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\",pattern = \"zz\") == 406\n    assert candidate(text = \"mnopqrqpomn\",pattern = \"mn\") == 5\n    assert candidate(text = \"aabbaabb\",pattern = \"bb\") == 10\n    assert candidate(text = \"aabbccddeeffgg\",pattern = \"ag\") == 6\n    assert candidate(text = \"ccbaaa\",pattern = \"ab\") == 3\n    assert candidate(text = \"xyzzyxzyzxzyxzyx\",pattern = \"yz\") == 20\n    assert candidate(text = \"aaaaaaaaa\",pattern = \"aa\") == 45\n    assert candidate(text = \"aabbaabb\",pattern = \"ab\") == 16\n    assert candidate(text = \"bababababababa\",pattern = \"ba\") == 35\n    assert candidate(text = \"bababababa\",pattern = \"ba\") == 20\n    assert candidate(text = \"zyxwvutsrqponmlkjihgfedcba\",pattern = \"yz\") == 1\n    assert candidate(text = \"qqqqqqqqqq\",pattern = \"qp\") == 10\n    assert candidate(text = \"qwertyuiopasdfghjklzxcvbnm\",pattern = \"mn\") == 1\n    assert candidate(text = \"abcabcdabc\",pattern = \"bc\") == 9\n    assert candidate(text = \"zzzzyyyy\",pattern = \"zy\") == 20\n    assert candidate(text = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",pattern = \"xz\") == 6\n    assert candidate(text = \"abacabacab\",pattern = \"ac\") == 11\n    assert candidate(text = \"fedcba\",pattern = \"ab\") == 1\n    assert candidate(text = \"ccccbbbaaa\",pattern = \"ba\") == 12\n    assert candidate(text = \"mmnnnmmnnm\",pattern = \"mn\") == 19\n    assert candidate(text = \"abcabcabc\",pattern = \"ba\") == 6\n    assert candidate(text = \"xyzxyzxyzxyz\",pattern = \"yx\") == 10\n    assert candidate(text = \"qqqqqppppp\",pattern = \"pq\") == 5\n    assert candidate(text = \"aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbb\",pattern = \"ba\") == 20\n    assert candidate(text = \"abbaba\",pattern = \"ab\") == 7\n    assert candidate(text = \"zzzzzzzzzzzzz\",pattern = \"zz\") == 91\n    assert candidate(text = \"zzyzxzyzxzyz\",pattern = \"yz\") == 16\n    assert candidate(text = \"aabbaabb\",pattern = \"aa\") == 10\n    assert candidate(text = \"abcabcabcabcabc\",pattern = \"ab\") == 20\n    assert candidate(text = \"babbabababababababa\",pattern = \"ba\") == 63\n    assert candidate(text = \"aaabbbcccddd\",pattern = \"ad\") == 12\n    assert candidate(text = \"abcdef\",pattern = \"fe\") == 1\n    assert candidate(text = \"bbbbbbbbbb\",pattern = \"bb\") == 55\n    assert candidate(text = \"bbbbbaaaaa\",pattern = \"ab\") == 5\n    assert candidate(text = \"abcde\",pattern = \"ae\") == 2\n    assert candidate(text = \"abracadabra\",pattern = \"ra\") == 10\n    assert candidate(text = \"abcdefghij\",pattern = \"ae\") == 2\n    assert candidate(text = \"aaabbbccc\",pattern = \"ab\") == 12\n    assert candidate(text = \"abcdefghij\",pattern = \"aj\") == 2\n    assert candidate(text = \"xyzzyxzyxzyxzyxzyxzyxzyx\",pattern = \"zx\") == 43\n    assert candidate(text = \"mmnmmnmmn\",pattern = \"mn\") == 18\n    assert candidate(text = \"aabbccddeeff\",pattern = \"ef\") == 6\n    assert candidate(text = \"zzzzzzzz\",pattern = \"zz\") == 36\n    assert candidate(text = \"ccccccc\",pattern = \"cc\") == 28\n    assert candidate(text = \"abcabcabc\",pattern = \"bc\") == 9\n    assert candidate(text = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",pattern = \"az\") == 6\n    assert candidate(text = \"abcdefghij\",pattern = \"af\") == 2\n    assert candidate(text = \"bbbbbaaaaa\",pattern = \"ba\") == 30\n    assert candidate(text = \"xyzyxzyxzy\",pattern = \"yx\") == 9\n    assert candidate(text = \"aabccbaa\",pattern = \"ac\") == 8\n    assert candidate(text = \"abacabadabacaba\",pattern = \"ab\") == 24\n    assert candidate(text = \"aabccccdddd\",pattern = \"cd\") == 20\n    assert candidate(text = \"aaaaaaaaaa\",pattern = \"aa\") == 55\n    assert candidate(text = \"aaaabbbb\",pattern = \"ab\") == 20\n    assert candidate(text = \"aaaaaaaaaaaabbbbbbbbbbbb\",pattern = \"ab\") == 156\n    assert candidate(text = \"abcdefghijklnmopqrstuvwxyz\",pattern = \"az\") == 2\n    assert candidate(text = \"abcd\",pattern = \"da\") == 1\n    assert candidate(text = \"abcdabcdabcd\",pattern = \"ad\") == 9\n    assert candidate(text = \"lkjqwpmr\",pattern = \"qw\") == 2\n    assert candidate(text = \"aabbaabbcc\",pattern = \"ab\") == 16\n    assert candidate(text = \"abcabcabc\",pattern = \"ac\") == 9\n    assert candidate(text = \"baabbaab\",pattern = \"ba\") == 12\n", "comparison": "exact"}, "public_tests": ["\"abdcdbc\"\n\"ac\"", "\"aabb\"\n\"ab\""], "hints": ["Find the optimal position to add pattern[0] so that the number of subsequences is maximized. Similarly, find the optimal position to add pattern[1].", "For each of the above cases, count the number of times the pattern occurs as a subsequence in text. The larger count is the required answer."], "metadata": {"canonical_parameter_names": ["text", "pattern"], "leetcode_dataset_entry_point": "Solution().maximumSubsequenceCount", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:55+00:00", "tests_total": 138, "tests_dropped": 2, "flags": [], "topic_tags": ["string", "greedy", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maximumSubsequenceCount(self, text: str, pattern: str) -> int:", "container": "Solution", "callable": "maximumSubsequenceCount", "parameters": [{"name": "text", "type": "str"}, {"name": "pattern", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2208, "task_id": "minimum-operations-to-halve-array-sum", "difficulty": "Medium", "problem_description": "You are given an array nums of positive integers. In one operation, you can choose any number from nums and reduce it to exactly half the number. (Note that you may choose this reduced number in future operations.)\n\nReturn the minimum number of operations to reduce the sum of nums by at least half.\n\nExample 1:\n\nInput: nums = [5,19,8,1]\nOutput: 3\nExplanation: The initial sum of nums is equal to 5 + 19 + 8 + 1 = 33.\nThe following is one of the ways to reduce the sum by at least half:\nPick the number 19 and reduce it to 9.5.\nPick the number 9.5 and reduce it to 4.75.\nPick the number 8 and reduce it to 4.\nThe final array is [5, 4.75, 4, 1] with a total sum of 5 + 4.75 + 4 + 1 = 14.75.\nThe sum of nums has been reduced by 33 - 14.75 = 18.25, which is at least half of the initial sum, 18.25 >= 33/2 = 16.5.\nOverall, 3 operations were used so we return 3.\nIt can be shown that we cannot reduce the sum by at least half in less than 3 operations.\n\nExample 2:\n\nInput: nums = [3,8,20]\nOutput: 3\nExplanation: The initial sum of nums is equal to 3 + 8 + 20 = 31.\nThe following is one of the ways to reduce the sum by at least half:\nPick the number 20 and reduce it to 10.\nPick the number 10 and reduce it to 5.\nPick the number 3 and reduce it to 1.5.\nThe final array is [1.5, 8, 5] with a total sum of 1.5 + 8 + 5 = 14.5.\nThe sum of nums has been reduced by 31 - 14.5 = 16.5, which is at least half of the initial sum, 16.5 >= 31/2 = 15.5.\nOverall, 3 operations were used so we return 3.\nIt can be shown that we cannot reduce the sum by at least half in less than 3 operations.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [10, 10, 10, 10]) == 4\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n    assert candidate(nums = [100, 100, 100, 100]) == 4\n    assert candidate(nums = [3, 8, 20]) == 3\n    assert candidate(nums = [10000000]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n    assert candidate(nums = [5, 19, 8, 1]) == 3\n    assert candidate(nums = [10, 20, 30, 40, 50]) == 5\n    assert candidate(nums = [10, 10, 10, 10, 10]) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 10\n    assert candidate(nums = [10, 20, 30, 40]) == 4\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 3\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == 13\n    assert candidate(nums = [9999999, 9999998, 9999997, 9999996, 9999995]) == 5\n    assert candidate(nums = [5000000, 5000000, 5000000, 5000000, 5000000]) == 5\n    assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == 3\n    assert candidate(nums = [1000, 500, 250, 125, 62.5, 31.25]) == 3\n    assert candidate(nums = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250]) == 3\n    assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584]) == 3\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 12\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 24\n    assert candidate(nums = [1, 1000000, 100000, 10000, 1000]) == 2\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 9\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 3\n    assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 9\n    assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 9\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 16\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 3\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 3\n    assert candidate(nums = [5000000, 3000000, 2000000, 1000000, 500000, 300000, 200000, 100000]) == 4\n    assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 3\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n    assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 15\n    assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250]) == 3\n    assert candidate(nums = [1234567, 2345678, 3456789, 4567890, 5678901, 6789012, 7890123, 8901234, 9012345]) == 8\n    assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500]) == 16\n    assert candidate(nums = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062, 19531]) == 3\n    assert candidate(nums = [9999999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n    assert candidate(nums = [1000000, 2000000, 3000000, 4000000]) == 4\n    assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1]) == 10\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 18\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 3\n    assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 9\n    assert candidate(nums = [10000, 20000, 30000, 40000, 50000]) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n    assert candidate(nums = [1, 10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062, 19531, 9765, 4882, 2441, 1220, 610, 305, 152, 76, 38]) == 3\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000]) == 2\n    assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 20\n    assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 10\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 12\n    assert candidate(nums = [1000000, 999999, 999998, 999997, 999996]) == 5\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 25\n    assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100000]) == 2\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 14\n    assert candidate(nums = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062.5, 19531.25]) == 3\n    assert candidate(nums = [10000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 2\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 2\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 20\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 20\n    assert candidate(nums = [9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990]) == 10\n    assert candidate(nums = [5000000, 5000000, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n    assert candidate(nums = [9999999, 8888888, 7777777, 6666666, 5555555, 4444444, 3333333, 2222222, 1111111]) == 8\n    assert candidate(nums = [9999999, 1, 1, 1]) == 2\n    assert candidate(nums = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000]) == 9\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 16\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 12\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 12\n    assert candidate(nums = [9999999, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n    assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 9\n    assert candidate(nums = [5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000]) == 10\n    assert candidate(nums = [5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062.5, 19531.25, 9765.625]) == 3\n    assert candidate(nums = [5000000, 3000000, 2000000, 4000000, 1000000]) == 5\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 20\n    assert candidate(nums = [5000000, 4000000, 3000000, 2000000, 1000000, 500000, 250000, 125000, 62500, 31250]) == 5\n", "comparison": "exact"}, "public_tests": ["[5,19,8,1]", "[3,8,20]"], "hints": ["It is always optimal to halve the largest element.", "What data structure allows for an efficient query of the maximum element?", "Use a heap or priority queue to maintain the current elements."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().halveArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:57+00:00", "tests_total": 81, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "greedy", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def halveArray(self, nums: list[int]) -> int:", "container": "Solution", "callable": "halveArray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2209, "task_id": "minimum-white-tiles-after-covering-with-carpets", "difficulty": "Hard", "problem_description": "You are given a 0-indexed binary string floor, which represents the colors of tiles on a floor:\n\n- floor[i] = '0' denotes that the i^th tile of the floor is colored black.\n- On the other hand, floor[i] = '1' denotes that the i^th tile of the floor is colored white.\n\nYou are also given numCarpets and carpetLen. You have numCarpets black carpets, each of length carpetLen tiles. Cover the tiles with the given carpets such that the number of white tiles still visible is minimum. Carpets may overlap one another.\n\nReturn the minimum number of white tiles still visible.\n\nExample 1:\n\nInput: floor = \"10110101\", numCarpets = 2, carpetLen = 2\nOutput: 2\nExplanation:\nThe figure above shows one way of covering the tiles with the carpets such that only 2 white tiles are visible.\nNo other way of covering the tiles with the carpets can leave less than 2 white tiles visible.\n\nExample 2:\n\nInput: floor = \"11111\", numCarpets = 2, carpetLen = 3\nOutput: 0\nExplanation:\nThe figure above shows one way of covering the tiles with the carpets such that no white tiles are visible.\nNote that the carpets are able to overlap one another.\n\nConstraints:\n\n- 1 <= carpetLen <= floor.length <= 1000\n- floor[i] is either '0' or '1'.\n- 1 <= numCarpets <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(floor = \"111100001111\",numCarpets = 4,carpetLen = 4) == 0\n    assert candidate(floor = \"110011\",numCarpets = 3,carpetLen = 2) == 0\n    assert candidate(floor = \"11111\",numCarpets = 2,carpetLen = 3) == 0\n    assert candidate(floor = \"1010101010\",numCarpets = 5,carpetLen = 1) == 0\n    assert candidate(floor = \"11001100\",numCarpets = 3,carpetLen = 2) == 0\n    assert candidate(floor = \"11010110\",numCarpets = 3,carpetLen = 1) == 2\n    assert candidate(floor = \"10110101\",numCarpets = 2,carpetLen = 2) == 2\n    assert candidate(floor = \"1110111\",numCarpets = 1,carpetLen = 4) == 3\n    assert candidate(floor = \"111000111\",numCarpets = 2,carpetLen = 4) == 0\n    assert candidate(floor = \"00000\",numCarpets = 1,carpetLen = 1) == 0\n    assert candidate(floor = \"00000\",numCarpets = 1,carpetLen = 2) == 0\n    assert candidate(floor = \"1111001111001111001111001111001111001111001111001111001111\",numCarpets = 12,carpetLen = 5) == 0\n    assert candidate(floor = \"110011001100110011001100110011001100110011001100\",numCarpets = 5,carpetLen = 3) == 14\n    assert candidate(floor = \"10101010101010101010101010101010101010101010\",numCarpets = 20,carpetLen = 5) == 0\n    assert candidate(floor = \"110011001100110011001100110011001100110011001100\",numCarpets = 15,carpetLen = 4) == 0\n    assert candidate(floor = \"010101010101010101010101010101010101010101010101\",numCarpets = 10,carpetLen = 5) == 0\n    assert candidate(floor = \"111101010101010101010101010101010101010101\",numCarpets = 10,carpetLen = 7) == 0\n    assert candidate(floor = \"110001001001001001001001001001001001001001001001\",numCarpets = 20,carpetLen = 4) == 0\n    assert candidate(floor = \"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 20,carpetLen = 5) == 0\n    assert candidate(floor = \"1111000011110000111100001111\",numCarpets = 6,carpetLen = 4) == 0\n    assert candidate(floor = \"0000000000000000000000000000\",numCarpets = 10,carpetLen = 10) == 0\n    assert candidate(floor = \"11111111111111111111111111111111111111\",numCarpets = 1000,carpetLen = 1) == 0\n    assert candidate(floor = \"11111000001111111100\",numCarpets = 4,carpetLen = 4) == 0\n    assert candidate(floor = \"11110111101111011110111101\",numCarpets = 10,carpetLen = 2) == 1\n    assert candidate(floor = \"010101010101010101010101010101010101010101010101\",numCarpets = 18,carpetLen = 7) == 0\n    assert candidate(floor = \"101010101010101010101010101010101010101010101010\",numCarpets = 25,carpetLen = 2) == 0\n    assert candidate(floor = \"10000000000000000000000000\",numCarpets = 1,carpetLen = 10) == 0\n    assert candidate(floor = \"11100011111000111000\",numCarpets = 5,carpetLen = 4) == 0\n    assert candidate(floor = \"111111111111111111111111111111111111111111111111\",numCarpets = 10,carpetLen = 5) == 0\n    assert candidate(floor = \"10101010101010101010101010101010101010101010101010\",numCarpets = 15,carpetLen = 4) == 0\n    assert candidate(floor = \"10001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000\",numCarpets = 25,carpetLen = 8) == 0\n    assert candidate(floor = \"00001111000011110000111100001111\",numCarpets = 12,carpetLen = 4) == 0\n    assert candidate(floor = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",numCarpets = 50,carpetLen = 10) == 0\n    assert candidate(floor = \"0000000000000000000000000000000000000000\",numCarpets = 20,carpetLen = 5) == 0\n    assert candidate(floor = \"1010101010101010101010101010101010101010101010101010\",numCarpets = 10,carpetLen = 2) == 16\n    assert candidate(floor = \"10010010010010010010010010010010010010\",numCarpets = 10,carpetLen = 3) == 3\n    assert candidate(floor = \"01010101010101010101\",numCarpets = 5,carpetLen = 4) == 0\n    assert candidate(floor = \"0001111111000111111000111111\",numCarpets = 6,carpetLen = 5) == 0\n    assert candidate(floor = \"01010101010101010101010101010101010101\",numCarpets = 8,carpetLen = 2) == 11\n    assert candidate(floor = \"11111000011111000011111000011111\",numCarpets = 4,carpetLen = 5) == 0\n    assert candidate(floor = \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",numCarpets = 100,carpetLen = 10) == 0\n    assert candidate(floor = \"0101010101010101010101010101\",numCarpets = 10,carpetLen = 3) == 0\n    assert candidate(floor = \"11100011100011100011\",numCarpets = 6,carpetLen = 3) == 0\n    assert candidate(floor = \"11111111111111111111\",numCarpets = 3,carpetLen = 5) == 5\n    assert candidate(floor = \"111111000011111100001111110000111111\",numCarpets = 8,carpetLen = 5) == 0\n    assert candidate(floor = \"1111111111111111111111111111111111111111\",numCarpets = 16,carpetLen = 10) == 0\n    assert candidate(floor = \"1010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 20,carpetLen = 6) == 0\n    assert candidate(floor = \"11001100110011001100110011001100\",numCarpets = 8,carpetLen = 2) == 0\n    assert candidate(floor = \"00100100100100100100100100\",numCarpets = 10,carpetLen = 3) == 0\n    assert candidate(floor = \"11111111111111111111111111\",numCarpets = 15,carpetLen = 2) == 0\n    assert candidate(floor = \"1111011011111100001101110111\",numCarpets = 5,carpetLen = 6) == 0\n    assert candidate(floor = \"111111111111111111111111111111111111111111111111\",numCarpets = 50,carpetLen = 1) == 0\n    assert candidate(floor = \"110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100\",numCarpets = 15,carpetLen = 4) == 24\n    assert candidate(floor = \"11101110111011101110111011\",numCarpets = 7,carpetLen = 4) == 0\n    assert candidate(floor = \"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 15,carpetLen = 4) == 18\n    assert candidate(floor = \"100110011001100110011001100110011001\",numCarpets = 8,carpetLen = 4) == 2\n    assert candidate(floor = \"10101010101010101010101010101010\",numCarpets = 7,carpetLen = 4) == 2\n    assert candidate(floor = \"1111000011110000111100001111000011110000111100001111000011110000111100001111000011110000\",numCarpets = 10,carpetLen = 7) == 4\n    assert candidate(floor = \"111100001111000011110000111100001111000011110000\",numCarpets = 5,carpetLen = 4) == 4\n    assert candidate(floor = \"11111111111111111111111111\",numCarpets = 10,carpetLen = 6) == 0\n    assert candidate(floor = \"10001000100010001000100010001000\",numCarpets = 9,carpetLen = 3) == 0\n    assert candidate(floor = \"111000111000111000111000111000111000\",numCarpets = 10,carpetLen = 2) == 2\n    assert candidate(floor = \"111111000000111111000000111111000000111111000000111111\",numCarpets = 15,carpetLen = 7) == 0\n    assert candidate(floor = \"111111111111111111111111111111111111\",numCarpets = 10,carpetLen = 7) == 0\n    assert candidate(floor = \"11111111111111111111111111111111\",numCarpets = 5,carpetLen = 5) == 7\n    assert candidate(floor = \"01010101010101010101010101\",numCarpets = 10,carpetLen = 5) == 0\n    assert candidate(floor = \"1010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 30,carpetLen = 4) == 0\n    assert candidate(floor = \"1010101010101010101010101010\",numCarpets = 10,carpetLen = 5) == 0\n    assert candidate(floor = \"01010101010101010101\",numCarpets = 3,carpetLen = 2) == 7\n    assert candidate(floor = \"11111111111111111111\",numCarpets = 5,carpetLen = 5) == 0\n    assert candidate(floor = \"1111000011110000111100001111000011110000111100001111000011110000111100001111000011110000\",numCarpets = 30,carpetLen = 5) == 0\n    assert candidate(floor = \"11110000111100001111\",numCarpets = 4,carpetLen = 5) == 0\n    assert candidate(floor = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",numCarpets = 50,carpetLen = 12) == 0\n    assert candidate(floor = \"10101010101010101010101010\",numCarpets = 15,carpetLen = 2) == 0\n    assert candidate(floor = \"11010101010101010101\",numCarpets = 5,carpetLen = 3) == 1\n    assert candidate(floor = \"11101110111011101110111011101110\",numCarpets = 10,carpetLen = 2) == 6\n    assert candidate(floor = \"000000000000000000000000000000000000000000000000\",numCarpets = 10,carpetLen = 15) == 0\n    assert candidate(floor = \"11111111111111111111111111111111\",numCarpets = 15,carpetLen = 5) == 0\n    assert candidate(floor = \"111111111111111111111111111111111111111111111111\",numCarpets = 25,carpetLen = 10) == 0\n    assert candidate(floor = \"11111111000000001111111100000000\",numCarpets = 3,carpetLen = 8) == 0\n    assert candidate(floor = \"110110110110110110110110110110110110110110110110\",numCarpets = 12,carpetLen = 6) == 0\n    assert candidate(floor = \"1111000011110000111100001111000011110000111100001111\",numCarpets = 10,carpetLen = 8) == 0\n    assert candidate(floor = \"01010101010101010101010101010101010101010101\",numCarpets = 4,carpetLen = 7) == 6\n    assert candidate(floor = \"1111111111111111111111111111\",numCarpets = 15,carpetLen = 4) == 0\n    assert candidate(floor = \"11111111111111111111\",numCarpets = 6,carpetLen = 5) == 0\n    assert candidate(floor = \"111111111100000000000000111111111111111111111111\",numCarpets = 5,carpetLen = 10) == 0\n    assert candidate(floor = \"100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100\",numCarpets = 20,carpetLen = 6) == 0\n    assert candidate(floor = \"1111100000111110000011111\",numCarpets = 3,carpetLen = 6) == 0\n    assert candidate(floor = \"01010101010101010101010101010101\",numCarpets = 10,carpetLen = 3) == 0\n    assert candidate(floor = \"11110111101111011110\",numCarpets = 5,carpetLen = 3) == 2\n    assert candidate(floor = \"00101010101010101010\",numCarpets = 5,carpetLen = 3) == 0\n    assert candidate(floor = \"11111111111111111111\",numCarpets = 10,carpetLen = 2) == 0\n    assert candidate(floor = \"111000111000111000111000111000111\",numCarpets = 8,carpetLen = 4) == 0\n    assert candidate(floor = \"10101010101010101010\",numCarpets = 5,carpetLen = 3) == 0\n    assert candidate(floor = \"11110000111100001111000011110000\",numCarpets = 6,carpetLen = 4) == 0\n    assert candidate(floor = \"10101010101010101010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 20,carpetLen = 5) == 0\n    assert candidate(floor = \"111000111000111000111\",numCarpets = 4,carpetLen = 3) == 0\n    assert candidate(floor = \"10101010101010101010\",numCarpets = 3,carpetLen = 4) == 4\n    assert candidate(floor = \"000000000000000000000000000000000000000000000000\",numCarpets = 10,carpetLen = 3) == 0\n    assert candidate(floor = \"1001001001001001001001001\",numCarpets = 7,carpetLen = 4) == 0\n    assert candidate(floor = \"01010101010101010101010101010101010101010101010101010101010\",numCarpets = 25,carpetLen = 3) == 0\n    assert candidate(floor = \"11111111111111111111\",numCarpets = 5,carpetLen = 3) == 5\n    assert candidate(floor = \"101010101010101010101010101010101010\",numCarpets = 15,carpetLen = 6) == 0\n    assert candidate(floor = \"111101110111011101110111011101110111\",numCarpets = 5,carpetLen = 4) == 12\n    assert candidate(floor = \"1010101010101010101010101010\",numCarpets = 8,carpetLen = 3) == 0\n    assert candidate(floor = \"000101001010100110010010001000101010010101010101\",numCarpets = 15,carpetLen = 3) == 0\n    assert candidate(floor = \"11001100110011001100\",numCarpets = 8,carpetLen = 3) == 0\n    assert candidate(floor = \"1110111011101110111011101110111011101110111011101110111011101110\",numCarpets = 8,carpetLen = 3) == 24\n", "comparison": "exact"}, "public_tests": ["\"10110101\"\n2\n2", "\"11111\"\n2\n3"], "hints": ["Can you think of a DP solution?", "Let DP[i][j] denote the minimum number of white tiles still visible from indices i to floor.length-1 after covering with at most j carpets.", "The transition will be whether to put down the carpet at position i (if possible), or not."], "metadata": {"canonical_parameter_names": ["floor", "numCarpets", "carpetLen"], "leetcode_dataset_entry_point": "Solution().minimumWhiteTiles", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:59+00:00", "tests_total": 110, "tests_dropped": 2, "flags": ["figure_reference", "has_images"], "topic_tags": ["string", "dynamic-programming", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:", "container": "Solution", "callable": "minimumWhiteTiles", "parameters": [{"name": "floor", "type": "str"}, {"name": "numCarpets", "type": "int"}, {"name": "carpetLen", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2210, "task_id": "count-hills-and-valleys-in-an-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums. An index i is part of a hill in nums if the closest non-equal neighbors of i are smaller than nums[i]. Similarly, an index i is part of a valley in nums if the closest non-equal neighbors of i are larger than nums[i]. Adjacent indices i and j are part of the same hill or valley if nums[i] == nums[j].\n\nNote that for an index to be part of a hill or valley, it must have a non-equal neighbor on both the left and right of the index.\n\nReturn the number of hills and valleys in nums.\n\nExample 1:\n\nInput: nums = [2,4,1,1,6,5]\nOutput: 3\nExplanation:\nAt index 0: There is no non-equal neighbor of 2 on the left, so index 0 is neither a hill nor a valley.\nAt index 1: The closest non-equal neighbors of 4 are 2 and 1. Since 4 > 2 and 4 > 1, index 1 is a hill.\nAt index 2: The closest non-equal neighbors of 1 are 4 and 6. Since 1 < 4 and 1 < 6, index 2 is a valley.\nAt index 3: The closest non-equal neighbors of 1 are 4 and 6. Since 1 < 4 and 1 < 6, index 3 is a valley, but note that it is part of the same valley as index 2.\nAt index 4: The closest non-equal neighbors of 6 are 1 and 5. Since 6 > 1 and 6 > 5, index 4 is a hill.\nAt index 5: There is no non-equal neighbor of 5 on the right, so index 5 is neither a hill nor a valley.\nThere are 3 hills and valleys so we return 3.\n\nExample 2:\n\nInput: nums = [6,6,5,5,4,1]\nOutput: 0\nExplanation:\nAt index 0: There is no non-equal neighbor of 6 on the left, so index 0 is neither a hill nor a valley.\nAt index 1: There is no non-equal neighbor of 6 on the left, so index 1 is neither a hill nor a valley.\nAt index 2: The closest non-equal neighbors of 5 are 6 and 4. Since 5 < 6 and 5 > 4, index 2 is neither a hill nor a valley.\nAt index 3: The closest non-equal neighbors of 5 are 6 and 4. Since 5 < 6 and 5 > 4, index 3 is neither a hill nor a valley.\nAt index 4: The closest non-equal neighbors of 4 are 5 and 1. Since 4 < 5 and 4 > 1, index 4 is neither a hill nor a valley.\nAt index 5: There is no non-equal neighbor of 1 on the right, so index 5 is neither a hill nor a valley.\nThere are 0 hills and valleys so we return 0.\n\nConstraints:\n\n- 3 <= nums.length <= 100\n- 1 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [5, 4, 3, 3, 2, 1]) == 0\n    assert candidate(nums = [1, 2, 2, 3, 4, 5]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 0\n    assert candidate(nums = [100, 99, 100, 98, 99, 100]) == 3\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [100, 90, 80, 70, 60, 50]) == 0\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums = [5, 4, 4, 3, 3, 2, 2, 1]) == 0\n    assert candidate(nums = [3, 3, 3, 2, 2, 1, 1]) == 0\n    assert candidate(nums = [1, 3, 2, 3, 1]) == 3\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n    assert candidate(nums = [1, 3, 2, 4, 3, 5]) == 4\n    assert candidate(nums = [3, 1, 2, 1, 3, 2, 1]) == 4\n    assert candidate(nums = [2, 4, 1, 1, 6, 5]) == 3\n    assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [1, 2, 2, 1, 2, 2, 1]) == 3\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 1, 1]) == 1\n    assert candidate(nums = [1, 3, 2, 1, 2, 3, 1]) == 3\n    assert candidate(nums = [6, 6, 5, 5, 4, 1]) == 0\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1]) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [1, 3, 3, 3, 2, 2, 2, 1]) == 1\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [1, 2, 2, 2, 3]) == 0\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3]) == 2\n    assert candidate(nums = [1, 3, 1, 2, 1, 3, 1]) == 5\n    assert candidate(nums = [1, 2, 3, 2, 1]) == 1\n    assert candidate(nums = [10, 9, 8, 7, 8, 9, 10]) == 1\n    assert candidate(nums = [1, 1, 2, 2, 1, 1, 2, 2]) == 2\n    assert candidate(nums = [50, 50, 49, 51, 49, 51, 50]) == 4\n    assert candidate(nums = [9, 8, 9, 8, 9, 8, 9]) == 5\n    assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3]) == 3\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 96, 97, 98, 99, 100]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2]) == 9\n    assert candidate(nums = [3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3]) == 11\n    assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 4, 3, 2, 1]) == 5\n    assert candidate(nums = [3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1]) == 10\n    assert candidate(nums = [50, 50, 50, 50, 51, 50, 50, 50, 50, 51, 50, 50, 50, 50]) == 3\n    assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 4, 3, 2, 1, 1, 1]) == 1\n    assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2]) == 5\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9]) == 12\n    assert candidate(nums = [10, 9, 8, 7, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 6, 7, 8, 9]) == 3\n    assert candidate(nums = [1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == 17\n    assert candidate(nums = [100, 90, 100, 90, 100, 90, 100, 80, 90, 80]) == 8\n    assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4]) == 10\n    assert candidate(nums = [1, 2, 2, 3, 3, 2, 2, 1, 1]) == 1\n    assert candidate(nums = [3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 3, 3, 2, 2, 1, 1, 2, 2]) == 3\n    assert candidate(nums = [1, 3, 2, 3, 1, 3, 2, 1, 2, 3, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10]) == 1\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 2, 3, 1, 2, 1]) == 7\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 1\n    assert candidate(nums = [2, 2, 2, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 1\n    assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 2\n    assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 28\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3]) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5]) == 3\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 14\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n    assert candidate(nums = [3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 8\n    assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 2, 1, 3, 2, 3, 1]) == 9\n    assert candidate(nums = [1, 2, 2, 1, 2, 3, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 7\n    assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 7\n    assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n    assert candidate(nums = [5, 5, 5, 5, 5, 1, 5, 5, 5, 5, 5]) == 1\n    assert candidate(nums = [10, 20, 10, 30, 10, 20, 10, 30, 10, 20, 10]) == 9\n    assert candidate(nums = [50, 51, 52, 51, 50, 51, 52, 51, 50, 51, 52, 51]) == 5\n    assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4]) == 8\n    assert candidate(nums = [1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1]) == 9\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 5, 7, 4, 8, 3, 9, 2, 10]) == 18\n    assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2]) == 4\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 9\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9]) == 12\n    assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2]) == 8\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n    assert candidate(nums = [30, 20, 10, 20, 30, 20, 10, 20, 30, 20, 10]) == 4\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 13\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 8\n    assert candidate(nums = [1, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 5\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 0\n    assert candidate(nums = [2, 2, 2, 3, 3, 2, 2, 2, 1, 1, 2, 2, 2]) == 2\n    assert candidate(nums = [3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 8\n    assert candidate(nums = [5, 4, 3, 2, 1, 2, 1, 2, 1, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9]) == 13\n    assert candidate(nums = [100, 99, 98, 97, 98, 99, 100, 99, 98, 97, 96, 97, 98, 99, 100, 99]) == 4\n    assert candidate(nums = [1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1]) == 5\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 3\n    assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2]) == 8\n    assert candidate(nums = [1, 1, 1, 2, 3, 4, 5, 5, 5, 4, 3, 2, 1, 1, 1]) == 1\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 96, 97, 98, 99, 100]) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1]) == 3\n    assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 2, 1]) == 5\n    assert candidate(nums = [8, 7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 5]) == 8\n    assert candidate(nums = [7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 0\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 19\n    assert candidate(nums = [2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 14\n    assert candidate(nums = [10, 9, 8, 7, 6, 7, 8, 9, 10, 9]) == 2\n    assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2]) == 3\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 9\n    assert candidate(nums = [1, 3, 2, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 2, 3, 2, 1, 3, 2, 1, 2, 3, 2, 1, 3, 2, 1, 2, 3]) == 16\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 6\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10]) == 3\n    assert candidate(nums = [10, 9, 8, 7, 8, 9, 10, 9, 8, 7, 6]) == 2\n    assert candidate(nums = [1, 1, 2, 3, 4, 3, 2, 1, 1, 2, 3, 4, 3, 2, 1, 1, 2, 3, 4]) == 4\n    assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 3\n    assert candidate(nums = [1, 2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2]) == 7\n    assert candidate(nums = [1, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 5, 6, 7, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 7, 8]) == 10\n    assert candidate(nums = [50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50]) == 17\n    assert candidate(nums = [2, 2, 2, 1, 2, 2, 3, 2, 2, 2, 1, 2, 2, 3, 2, 2, 2, 1, 2, 2]) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 2\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9]) == 2\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 1\n    assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 11\n    assert candidate(nums = [1, 3, 2, 1, 2, 1, 2, 1, 2, 1, 3, 2, 1, 2, 1]) == 11\n    assert candidate(nums = [1, 2, 2, 2, 3, 2, 2, 2, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 7\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 8\n    assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 3, 4]) == 8\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 11\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 0\n    assert candidate(nums = [3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 14\n    assert candidate(nums = [20, 21, 20, 22, 21, 23, 22, 24, 23, 25, 24, 23, 22, 21, 20, 19, 20, 21, 22, 21]) == 11\n    assert candidate(nums = [1, 3, 3, 3, 2, 2, 2, 1, 3, 3, 3, 2, 2, 2]) == 3\n    assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 2, 1]) == 5\n    assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 3\n    assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 3\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 13\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2]) == 2\n    assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1]) == 9\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 18\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 18\n    assert candidate(nums = [10, 9, 8, 7, 8, 9, 10, 9, 8, 7, 6, 7, 8, 9, 10]) == 3\n    assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6]) == 11\n    assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 2, 2, 2]) == 1\n    assert candidate(nums = [3, 3, 3, 2, 2, 1, 1, 1, 2, 2, 3, 3, 3, 2, 2, 1, 1, 1]) == 2\n    assert candidate(nums = [1, 2, 2, 1, 2, 3, 3, 2, 1, 2, 3, 4, 4, 3, 2, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 8\n    assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n    assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 2\n    assert candidate(nums = [9, 8, 7, 8, 7, 8, 9, 10, 9, 10, 9, 8, 7, 8, 7, 6, 5, 4, 5, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8]) == 13\n    assert candidate(nums = [3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 1\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 3, 3, 2, 2, 1]) == 1\n    assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10]) == 7\n", "comparison": "exact"}, "public_tests": ["[2,4,1,1,6,5]", "[6,6,5,5,4,1]"], "hints": ["For each index, could you find the closest non-equal neighbors?", "Ensure that adjacent indices that are part of the same hill or valley are not double-counted."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countHillValley", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:01+00:00", "tests_total": 154, "tests_dropped": 0, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def countHillValley(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countHillValley", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2211, "task_id": "count-collisions-on-a-road", "difficulty": "Medium", "problem_description": "There are n cars on an infinitely long road. The cars are numbered from 0 to n - 1 from left to right and each car is present at a unique point.\n\nYou are given a 0-indexed string directions of length n. directions[i] can be either 'L', 'R', or 'S' denoting whether the i^th car is moving towards the left, towards the right, or staying at its current point respectively. Each moving car has the same speed.\n\nThe number of collisions can be calculated as follows:\n\n- When two cars moving in opposite directions collide with each other, the number of collisions increases by 2.\n- When a moving car collides with a stationary car, the number of collisions increases by 1.\n\nAfter a collision, the cars involved can no longer move and will stay at the point where they collided. Other than that, cars cannot change their state or direction of motion.\n\nReturn the total number of collisions that will happen on the road.\n\nExample 1:\n\nInput: directions = \"RLRSLL\"\nOutput: 5\nExplanation:\nThe collisions that will happen on the road are:\n- Cars 0 and 1 will collide with each other. Since they are moving in opposite directions, the number of collisions becomes 0 + 2 = 2.\n- Cars 2 and 3 will collide with each other. Since car 3 is stationary, the number of collisions becomes 2 + 1 = 3.\n- Cars 3 and 4 will collide with each other. Since car 3 is stationary, the number of collisions becomes 3 + 1 = 4.\n- Cars 4 and 5 will collide with each other. After car 4 collides with car 3, it will stay at the point of collision and get hit by car 5. The number of collisions becomes 4 + 1 = 5.\nThus, the total number of collisions that will happen on the road is 5.\n\nExample 2:\n\nInput: directions = \"LLRR\"\nOutput: 0\nExplanation:\nNo cars will collide with each other. Thus, the total number of collisions that will happen on the road is 0.\n\nConstraints:\n\n- 1 <= directions.length <= 10^5\n- directions[i] is either 'L', 'R', or 'S'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(directions = \"SSRLSL\") == 3\n    assert candidate(directions = \"LRLRLR\") == 4\n    assert candidate(directions = \"RRRR\") == 0\n    assert candidate(directions = \"LRRSLRLR\") == 5\n    assert candidate(directions = \"LSRL\") == 2\n    assert candidate(directions = \"SSSS\") == 0\n    assert candidate(directions = \"RLSLRL\") == 5\n    assert candidate(directions = \"RSLSLSLS\") == 4\n    assert candidate(directions = \"SSSRRSLL\") == 4\n    assert candidate(directions = \"LRSLSR\") == 2\n    assert candidate(directions = \"RLSL\") == 3\n    assert candidate(directions = \"RLLLLLL\") == 7\n    assert candidate(directions = \"RRRRRRS\") == 6\n    assert candidate(directions = \"LLRR\") == 0\n    assert candidate(directions = \"RRLR\") == 3\n    assert candidate(directions = \"SSLSLS\") == 2\n    assert candidate(directions = \"RLRRLL\") == 6\n    assert candidate(directions = \"RRRSSSLL\") == 5\n    assert candidate(directions = \"SSSSS\") == 0\n    assert candidate(directions = \"LLLLL\") == 0\n    assert candidate(directions = \"RLRSLL\") == 5\n    assert candidate(directions = \"LSLR\") == 1\n    assert candidate(directions = \"LLLL\") == 0\n    assert candidate(directions = \"RSLRS\") == 3\n    assert candidate(directions = \"RSLRLRLS\") == 6\n    assert candidate(directions = \"RRSLRR\") == 3\n    assert candidate(directions = \"LRLR\") == 2\n    assert candidate(directions = \"RRRSSSLLLRRR\") == 6\n    assert candidate(directions = \"LSRLSL\") == 3\n    assert candidate(directions = \"LRLL\") == 3\n    assert candidate(directions = \"SSRLSS\") == 2\n    assert candidate(directions = \"RRRRR\") == 0\n    assert candidate(directions = \"RSLR\") == 2\n    assert candidate(directions = \"SSS\") == 0\n    assert candidate(directions = \"LRRLRRLL\") == 7\n    assert candidate(directions = \"RSLRSL\") == 4\n    assert candidate(directions = \"LSSRLL\") == 3\n    assert candidate(directions = \"RSLRLR\") == 4\n    assert candidate(directions = \"SSRSLLS\") == 3\n    assert candidate(directions = \"RRRRRSSSSSLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLSSSSSSSSSSS\") == 43\n    assert candidate(directions = \"LRLRLRLRLRLR\") == 10\n    assert candidate(directions = \"RRLRLRLRLRLRLRLRLRLR\") == 19\n    assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 0\n    assert candidate(directions = \"SSRSLRRRLLSLSSS\") == 8\n    assert candidate(directions = \"RRRRRSSLLLLLRRRR\") == 10\n    assert candidate(directions = \"RLLLLRRRRLLLLRRRRRLLLLRRRR\") == 22\n    assert candidate(directions = \"RSSSSRRRRRRRRRRSSSLL\") == 13\n    assert candidate(directions = \"RRRRRRRRRRSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 10\n    assert candidate(directions = \"LRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n    assert candidate(directions = \"RLRLRLRLRLRLRLRL\") == 16\n    assert candidate(directions = \"RRRSSLLLLRRRSSLLLL\") == 14\n    assert candidate(directions = \"RRRLRSSRRRLRRRRRSLRRRRRR\") == 15\n    assert candidate(directions = \"RLRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 2\n    assert candidate(directions = \"RSLRRSLRRSLR\") == 8\n    assert candidate(directions = \"LLLSRSSRRRLRRRRRSLRRRRRR\") == 11\n    assert candidate(directions = \"RLRSLLRSLLRSLLRSLLRS\") == 15\n    assert candidate(directions = \"LLLLLLLLLLSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n    assert candidate(directions = \"RSLRSLRSLRSLRSLRSLRSLRSLRL\") == 18\n    assert candidate(directions = \"LLLLSSSSRRRRRRRRRLLLLL\") == 14\n    assert candidate(directions = \"RRRRSSSSLLLLRRRRRRSSSSLLLLRRRRRRSSSSLLLL\") == 28\n    assert candidate(directions = \"RRRRRRRRRRRR\") == 0\n    assert candidate(directions = \"SLRLRLRLRLRSLSLSL\") == 13\n    assert candidate(directions = \"LLLLSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSRRRRRR\") == 0\n    assert candidate(directions = \"RSSSSRRRLLLLRRRSL\") == 12\n    assert candidate(directions = \"RRRRRRRRRRSSSSSSSSSLLLLLLLL\") == 18\n    assert candidate(directions = \"LRRRRRLLLLLS\") == 10\n    assert candidate(directions = \"SLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 44\n    assert candidate(directions = \"LLLLLLLLLLLLLLLL\") == 0\n    assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n    assert candidate(directions = \"RRRSLSLSSSLLLLRRRS\") == 12\n    assert candidate(directions = \"LLLLRRRRRRRR\") == 0\n    assert candidate(directions = \"RLRSRLRSRLRSRLRS\") == 12\n    assert candidate(directions = \"SSSSSSSSSSSSSSRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLLLLLLLLLLLLLLLLLLLLSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 52\n    assert candidate(directions = \"RLRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 2\n    assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n    assert candidate(directions = \"SSSSSSSSSSSS\") == 0\n    assert candidate(directions = \"RSLRSLSRLRSLSR\") == 8\n    assert candidate(directions = \"RRRSLSLRSLRRRRLLL\") == 14\n    assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRR\") == 0\n    assert candidate(directions = \"SSSSSRRRRRSSSSS\") == 5\n    assert candidate(directions = \"RRRRSSSLLLLLRRRR\") == 9\n    assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRRRR\") == 44\n    assert candidate(directions = \"SSRRRRLLLLSSRRRRLLLLSS\") == 16\n    assert candidate(directions = \"RSLRSLSRLSRLSRLRSLSR\") == 12\n    assert candidate(directions = \"RRRRRRRRLLLLLLLL\") == 16\n    assert candidate(directions = \"SLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 46\n    assert candidate(directions = \"RRRLLRRRLLLLLSS\") == 13\n    assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRRRRRRR\") == 43\n    assert candidate(directions = \"LLLLLRRRRRLLLLLRRRRRLLLLLRRRRRLLLLLRRRRR\") == 30\n    assert candidate(directions = \"LLLLRRRRRRSSSSSLLLL\") == 10\n    assert candidate(directions = \"RLRLRLRLRLRL\") == 12\n    assert candidate(directions = \"RLRSLRSLRSLRSLRS\") == 11\n    assert candidate(directions = \"RRRRRRRRRRRRRRRR\") == 0\n    assert candidate(directions = \"SLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 48\n    assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRR\") == 44\n    assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 0\n    assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRRRRRR\") == 44\n    assert candidate(directions = \"SSSSSSRRRRRSSSSSSSSS\") == 5\n    assert candidate(directions = \"LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR\") == 38\n    assert candidate(directions = \"SSSLRRRLLSSL\") == 7\n    assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n    assert candidate(directions = \"RRRLRLRLRLRLRLRLRLRLRLRLRLRRRRRRRRRRRR\") == 26\n    assert candidate(directions = \"SSSSRRRRLLLLRRRRLLLL\") == 16\n    assert candidate(directions = \"RRRRRLSLLSLLLL\") == 12\n    assert candidate(directions = \"SSSSSSSSSSSSSSSS\") == 0\n    assert candidate(directions = \"RRRRRSSSSLLLLLLLL\") == 13\n    assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 0\n    assert candidate(directions = \"RLRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 2\n    assert candidate(directions = \"SSRRRRRSSSSLLLSSSL\") == 9\n    assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSS\") == 0\n    assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 0\n    assert candidate(directions = \"RLRRLLRLRRLLRLRR\") == 14\n    assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLSSSS\") == 0\n    assert candidate(directions = \"RRRRSSSSSSRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRL\") == 38\n    assert candidate(directions = \"LSRSSRSLLRSRLS\") == 7\n    assert candidate(directions = \"LLLLLLRRRRRRLLLLRRRRRR\") == 10\n    assert candidate(directions = \"LLLLSSSSRRRRSSSSLLLL\") == 8\n    assert candidate(directions = \"SSSSSSSSSSSRRRRRRSSSSSSLLLLLLLLSSSSSSSSSSS\") == 14\n    assert candidate(directions = \"RRRSSLRLRLRSLL\") == 11\n    assert candidate(directions = \"RSLSLRLSLSLRLSLR\") == 10\n    assert candidate(directions = \"SSSSSRRRRRSSSSSLLLLL\") == 10\n    assert candidate(directions = \"SSSSRRRRSSSSSSSSSSSSSSSSSSS\") == 4\n    assert candidate(directions = \"SSSSRRRRRRLLLLSSSSSLLLL\") == 14\n    assert candidate(directions = \"SSLRRRSSLLSL\") == 7\n    assert candidate(directions = \"RRSSSLRSLSSSRRSSSLRSL\") == 10\n    assert candidate(directions = \"LSLSLSLSLSLSLSLSLRRRRRR\") == 8\n    assert candidate(directions = \"LLLLSSRRRRSSSSRRRR\") == 4\n    assert candidate(directions = \"RSLSRSLSRSLSRS\") == 7\n    assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n    assert candidate(directions = \"RSLRSSLSRSSL\") == 6\n    assert candidate(directions = \"LRLRLRLRLRLRLRLRLRLR\") == 18\n    assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRRRRRR\") == 43\n    assert candidate(directions = \"RRRRRSSSLLLLLLLLRRRR\") == 13\n    assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n    assert candidate(directions = \"LLLLRRRRSSSSLLRRRR\") == 6\n    assert candidate(directions = \"LRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n    assert candidate(directions = \"LLLSRLRLRLRLRLL\") == 11\n    assert candidate(directions = \"RRRRSSSSLLLL\") == 8\n    assert candidate(directions = \"RLRLRLRLRLRLRLRLRLRL\") == 20\n    assert candidate(directions = \"LLLLRRRRSSSSLLLL\") == 8\n    assert candidate(directions = \"LRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n    assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLL\") == 46\n    assert candidate(directions = \"RRRRRRRRRSSSSSSSLLLLLLLLSSSSSSSSSSSSSSSSSS\") == 17\n    assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRLLSSSSSSSSSSSSSSSSSL\") == 22\n    assert candidate(directions = \"RLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRL\") == 40\n    assert candidate(directions = \"LRRRSLRRRLSLSLLSLRR\") == 12\n    assert candidate(directions = \"LRRRLRRLLRLLRLRRRLLR\") == 18\n    assert candidate(directions = \"RRRRLLLLRRRRLLLLRRRRLLLLRRRRLLLLRRRRLLLL\") == 40\n    assert candidate(directions = \"SRLRSRLRSRLRSRLRSRLRSRLRSRLRSRLRSRLRSR\") == 27\n    assert candidate(directions = \"RRRRRSSLLLLLLLLLL\") == 15\n    assert candidate(directions = \"SSSSRRRRLLLLSSSS\") == 8\n    assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n    assert candidate(directions = \"SSSSRRRRLLLLSSSSRRRR\") == 8\n    assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n    assert candidate(directions = \"SRRRRRLRRRRLLSRRRRLLL\") == 19\n    assert candidate(directions = \"RRRLLLLLSSSSRRRLLLLL\") == 16\n    assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n    assert candidate(directions = \"RLLLLLRRRRRR\") == 6\n    assert candidate(directions = \"RSLRRSLSLSLSLSLSL\") == 10\n    assert candidate(directions = \"RLRSLRSLRSLRSLRSLRSLRSLRSLRSLRSLR\") == 22\n    assert candidate(directions = \"RRRRRRRRRRLLLLLLLLLL\") == 20\n    assert candidate(directions = \"RRRRSSSLLLLLLLRRRRRR\") == 11\n    assert candidate(directions = \"SSSSRRRRLLLLLRRRRLLLLLSSSSRRRRLLLLLRRRRLLLLL\") == 36\n    assert candidate(directions = \"LLLLLLLLLLSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSRRRR\") == 0\n    assert candidate(directions = \"RRRRRRRRRRRRRRSSSLSSSSSSSSSSSSSSSSSSSSSSSL\") == 16\n    assert candidate(directions = \"RRRRRRSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSLLLLLL\") == 12\n    assert candidate(directions = \"RRRRLLLLSSSSRRRLLL\") == 14\n    assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLL\") == 0\n    assert candidate(directions = \"RLRRRLRLRLRLRLRLRLRLRLRLRLRR\") == 26\n    assert candidate(directions = \"RRRRRSSSSSSLLLLSSSSSS\") == 9\n    assert candidate(directions = \"SSRRRRRLLLLLSS\") == 10\n    assert candidate(directions = \"RRRRRRRRRRRRRLLLLLLLLLLLL\") == 25\n    assert candidate(directions = \"RRRRRRRRRRSSSSSSSSSSSSSSSSSSSSSSSSSSSSSLLLL\") == 14\n    assert candidate(directions = \"RSLSLRSLRRSLRSLRL\") == 12\n    assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n    assert candidate(directions = \"RSSSSSSRRRRRRRLLLLLLLLLLLLLRRRRRR\") == 21\n    assert candidate(directions = \"RLRSLRLRSLRL\") == 10\n", "comparison": "exact"}, "public_tests": ["\"RLRSLL\"", "\"LLRR\""], "hints": ["In what circumstances does a moving car not collide with another car?", "If we disregard the moving cars that do not collide with another car, what does each moving car contribute to the answer?", "Will stationary cars contribute towards the answer?"], "metadata": {"canonical_parameter_names": ["directions"], "leetcode_dataset_entry_point": "Solution().countCollisions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:04+00:00", "tests_total": 177, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "stack", "simulation"]}, "language": "python", "interface": {"raw_signature": "def countCollisions(self, directions: str) -> int:", "container": "Solution", "callable": "countCollisions", "parameters": [{"name": "directions", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2212, "task_id": "maximum-points-in-an-archery-competition", "difficulty": "Medium", "problem_description": "Alice and Bob are opponents in an archery competition. The competition has set the following rules:\n\n1. Alice first shoots numArrows arrows and then Bob shoots numArrows arrows.\n2. The points are then calculated as follows:\n  1. The target has integer scoring sections ranging from 0 to 11 inclusive.\n  2. For each section of the target with score k (in between 0 to 11), say Alice and Bob have shot a_k and b_k arrows on that section respectively. If a_k >= b_k, then Alice takes k points. If a_k < b_k, then Bob takes k points.\n  3. However, if a_k == b_k == 0, then nobody takes k points.\n\n-\nFor example, if Alice and Bob both shot 2 arrows on the section with score 11, then Alice takes 11 points. On the other hand, if Alice shot 0 arrows on the section with score 11 and Bob shot 2 arrows on that same section, then Bob takes 11 points.\n\nYou are given the integer numArrows and an integer array aliceArrows of size 12, which represents the number of arrows Alice shot on each scoring section from 0 to 11. Now, Bob wants to maximize the total number of points he can obtain.\n\nReturn the array bobArrows which represents the number of arrows Bob shot on each scoring section from 0 to 11. The sum of the values in bobArrows should equal numArrows.\n\nIf there are multiple ways for Bob to earn the maximum total points, return any one of them.\n\nExample 1:\n\nInput: numArrows = 9, aliceArrows = [1,1,0,1,0,0,2,1,0,1,2,0]\nOutput: [0,0,0,0,1,1,0,0,1,2,3,1]\nExplanation: The table above shows how the competition is scored.\nBob earns a total point of 4 + 5 + 8 + 9 + 10 + 11 = 47.\nIt can be shown that Bob cannot obtain a score higher than 47 points.\n\nExample 2:\n\nInput: numArrows = 3, aliceArrows = [0,0,1,0,0,0,0,0,0,0,0,2]\nOutput: [0,0,0,0,0,0,0,0,1,1,1,0]\nExplanation: The table above shows how the competition is scored.\nBob earns a total point of 8 + 9 + 10 = 27.\nIt can be shown that Bob cannot obtain a score higher than 27 points.\n\nConstraints:\n\n- 1 <= numArrows <= 10^5\n- aliceArrows.length == bobArrows.length == 12\n- 0 <= aliceArrows[i], bobArrows[i] <= numArrows\n- sum(aliceArrows[i]) == numArrows\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(numArrows = 100000,aliceArrows = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == [9991, 0, 0, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001]\n    assert candidate(numArrows = 5,aliceArrows = [0, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2]\n    assert candidate(numArrows = 15,aliceArrows = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3]\n    assert candidate(numArrows = 12,aliceArrows = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2]\n    assert candidate(numArrows = 20,aliceArrows = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4]\n    assert candidate(numArrows = 3,aliceArrows = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2]) == [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0]\n    assert candidate(numArrows = 9,aliceArrows = [1, 1, 0, 1, 0, 0, 2, 1, 0, 1, 2, 0]) == [0, 0, 0, 0, 1, 1, 0, 0, 1, 2, 3, 1]\n    assert candidate(numArrows = 5,aliceArrows = [2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]\n    assert candidate(numArrows = 10,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(numArrows = 9,aliceArrows = [2, 3, 2, 2, 2, 3, 2, 2, 2, 3, 2, 2]) == [0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 3]\n    assert candidate(numArrows = 20,aliceArrows = [3, 0, 2, 1, 4, 0, 2, 1, 3, 0, 2, 1]) == [1, 1, 0, 2, 0, 1, 3, 2, 4, 1, 3, 2]\n    assert candidate(numArrows = 100,aliceArrows = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [1, 0, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n    assert candidate(numArrows = 50,aliceArrows = [10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0]) == [0, 0, 11, 11, 11, 11, 1, 1, 1, 1, 1, 1]\n    assert candidate(numArrows = 80,aliceArrows = [0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15]) == [11, 0, 1, 0, 1, 16, 1, 16, 1, 16, 1, 16]\n    assert candidate(numArrows = 85,aliceArrows = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [19, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(numArrows = 72,aliceArrows = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [0, 0, 0, 0, 0, 9, 10, 11, 0, 13, 14, 15]\n    assert candidate(numArrows = 99,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [22, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n    assert candidate(numArrows = 90,aliceArrows = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == [2, 0, 0, 0, 0, 0, 0, 0, 19, 21, 23, 25]\n    assert candidate(numArrows = 25,aliceArrows = [2, 2, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3]) == [0, 0, 0, 0, 0, 3, 4, 4, 3, 3, 4, 4]\n    assert candidate(numArrows = 30,aliceArrows = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 29]) == [10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]\n    assert candidate(numArrows = 30,aliceArrows = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [3, 0, 0, 0, 0, 0, 7, 6, 5, 4, 3, 2]\n    assert candidate(numArrows = 77,aliceArrows = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == [41, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1]\n    assert candidate(numArrows = 85,aliceArrows = [0, 0, 5, 10, 15, 20, 0, 0, 0, 0, 0, 0]) == [24, 1, 6, 11, 16, 21, 1, 1, 1, 1, 1, 1]\n    assert candidate(numArrows = 80,aliceArrows = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == [38, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2]\n    assert candidate(numArrows = 60,aliceArrows = [2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == [27, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2, 4]\n    assert candidate(numArrows = 25,aliceArrows = [0, 0, 0, 0, 5, 4, 3, 2, 1, 0, 0, 0]) == [0, 0, 1, 1, 6, 5, 4, 3, 2, 1, 1, 1]\n    assert candidate(numArrows = 66,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 0, 0, 4, 5, 0, 7, 8, 9, 10, 11, 12]\n    assert candidate(numArrows = 20,aliceArrows = [1, 3, 2, 4, 1, 2, 3, 4, 2, 1, 3, 2]) == [0, 0, 0, 0, 0, 3, 0, 5, 3, 2, 4, 3]\n    assert candidate(numArrows = 50,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50]) == [40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n    assert candidate(numArrows = 90,aliceArrows = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1]) == [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 2]\n    assert candidate(numArrows = 40,aliceArrows = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0]) == [6, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 1]\n    assert candidate(numArrows = 23,aliceArrows = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [2, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3]\n    assert candidate(numArrows = 85,aliceArrows = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == [1, 0, 0, 0, 0, 0, 0, 0, 18, 20, 22, 24]\n    assert candidate(numArrows = 20,aliceArrows = [1, 3, 2, 5, 0, 0, 4, 3, 1, 2, 3, 1]) == [0, 0, 3, 0, 1, 1, 0, 4, 2, 3, 4, 2]\n    assert candidate(numArrows = 20,aliceArrows = [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 4]) == [2, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 5]\n    assert candidate(numArrows = 90,aliceArrows = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [3, 0, 0, 0, 0, 0, 0, 41, 46, 0, 0, 0]\n    assert candidate(numArrows = 30,aliceArrows = [0, 3, 0, 0, 5, 0, 0, 0, 3, 0, 0, 0]) == [8, 4, 1, 1, 6, 1, 1, 1, 4, 1, 1, 1]\n    assert candidate(numArrows = 30,aliceArrows = [6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]) == [0, 0, 0, 4, 3, 2, 1, 2, 3, 4, 5, 6]\n    assert candidate(numArrows = 50,aliceArrows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [0, 0, 0, 0, 0, 0, 8, 9, 10, 11, 12, 0]\n    assert candidate(numArrows = 75,aliceArrows = [15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [64, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(numArrows = 100,aliceArrows = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [34, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n    assert candidate(numArrows = 75,aliceArrows = [10, 5, 5, 5, 10, 5, 5, 5, 10, 5, 5, 5]) == [5, 0, 6, 6, 11, 6, 6, 6, 11, 6, 6, 6]\n    assert candidate(numArrows = 60,aliceArrows = [0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10]) == [0, 1, 1, 1, 1, 1, 0, 11, 11, 11, 11, 11]\n    assert candidate(numArrows = 15,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]) == [5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n    assert candidate(numArrows = 40,aliceArrows = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0]) == [1, 1, 0, 1, 0, 1, 11, 1, 11, 1, 11, 1]\n    assert candidate(numArrows = 25,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 0, 0, 0, 0, 0, 7, 8, 0, 10, 0, 0]\n    assert candidate(numArrows = 25,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25]) == [15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n    assert candidate(numArrows = 120,aliceArrows = [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 100]) == [2, 0, 1, 3, 1, 3, 1, 3, 1, 3, 1, 101]\n    assert candidate(numArrows = 85,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85]) == [75, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n    assert candidate(numArrows = 120,aliceArrows = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == [43, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n    assert candidate(numArrows = 40,aliceArrows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1]) == [0, 0, 0, 0, 0, 0, 8, 9, 10, 11, 0, 2]\n    assert candidate(numArrows = 20,aliceArrows = [0, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n    assert candidate(numArrows = 100,aliceArrows = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [3, 0, 0, 0, 0, 0, 0, 0, 46, 51, 0, 0]\n    assert candidate(numArrows = 60,aliceArrows = [0, 5, 0, 0, 0, 0, 5, 0, 0, 0, 0, 5]) == [34, 6, 1, 1, 1, 1, 6, 1, 1, 1, 1, 6]\n    assert candidate(numArrows = 8,aliceArrows = [3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0]) == [3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]\n    assert candidate(numArrows = 40,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 0, 0, 0, 0, 0, 0, 8, 9, 0, 11, 12]\n    assert candidate(numArrows = 25,aliceArrows = [4, 3, 5, 3, 4, 5, 6, 3, 4, 5, 6, 2]) == [0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 3]\n    assert candidate(numArrows = 12,aliceArrows = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3]\n    assert candidate(numArrows = 120,aliceArrows = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [104, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]\n    assert candidate(numArrows = 30,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 11, 0]\n    assert candidate(numArrows = 99,aliceArrows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0]) == [23, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1]\n    assert candidate(numArrows = 60,aliceArrows = [0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10]) == [0, 0, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11]\n    assert candidate(numArrows = 20,aliceArrows = [5, 3, 4, 2, 6, 3, 7, 2, 4, 5, 6, 3]) == [0, 0, 0, 0, 0, 0, 0, 3, 0, 6, 7, 4]\n    assert candidate(numArrows = 80,aliceArrows = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == [0, 0, 0, 0, 0, 0, 0, 18, 19, 0, 21, 22]\n    assert candidate(numArrows = 150,aliceArrows = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [2, 0, 0, 0, 0, 0, 0, 41, 0, 51, 56, 0]\n    assert candidate(numArrows = 50,aliceArrows = [0, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0]) == [19, 1, 1, 1, 11, 1, 1, 1, 11, 1, 1, 1]\n    assert candidate(numArrows = 60,aliceArrows = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0]) == [29, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1]\n    assert candidate(numArrows = 25,aliceArrows = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n    assert candidate(numArrows = 42,aliceArrows = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == [0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 0, 0]\n    assert candidate(numArrows = 60,aliceArrows = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]) == [1, 0, 0, 0, 0, 0, 0, 0, 28, 31, 0, 0]\n    assert candidate(numArrows = 20,aliceArrows = [3, 2, 1, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == [0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, 0]\n    assert candidate(numArrows = 50,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50]) == [40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n    assert candidate(numArrows = 88,aliceArrows = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [22, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(numArrows = 70,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70]) == [60, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n    assert candidate(numArrows = 100,aliceArrows = [10, 10, 0, 10, 0, 0, 20, 10, 0, 10, 20, 0]) == [9, 11, 1, 11, 1, 1, 21, 11, 1, 11, 21, 1]\n    assert candidate(numArrows = 85,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n    assert candidate(numArrows = 120,aliceArrows = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72]) == [4, 0, 0, 0, 0, 0, 0, 0, 55, 61, 0, 0]\n    assert candidate(numArrows = 50,aliceArrows = [5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0]) == [29, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(numArrows = 55,aliceArrows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0]) == [0, 0, 0, 0, 6, 7, 8, 0, 10, 11, 12, 1]\n    assert candidate(numArrows = 150,aliceArrows = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0]) == [49, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1]\n    assert candidate(numArrows = 20,aliceArrows = [0, 3, 1, 2, 0, 4, 1, 0, 5, 2, 1, 1]) == [0, 0, 0, 3, 1, 0, 2, 1, 6, 3, 2, 2]\n    assert candidate(numArrows = 60,aliceArrows = [0, 10, 20, 30, 40, 50, 60, 0, 0, 0, 0, 0]) == [3, 0, 21, 31, 0, 0, 0, 1, 1, 1, 1, 1]\n    assert candidate(numArrows = 100,aliceArrows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [12, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n    assert candidate(numArrows = 120,aliceArrows = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [43, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n    assert candidate(numArrows = 50,aliceArrows = [10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0]) == [10, 0, 11, 11, 11, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(numArrows = 40,aliceArrows = [2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 1, 0]) == [21, 1, 2, 1, 4, 1, 3, 1, 2, 1, 2, 1]\n    assert candidate(numArrows = 60,aliceArrows = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60]) == [50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n    assert candidate(numArrows = 50,aliceArrows = [0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [2, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6]\n    assert candidate(numArrows = 90,aliceArrows = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [46, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n    assert candidate(numArrows = 75,aliceArrows = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [9, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n    assert candidate(numArrows = 75,aliceArrows = [0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 20, 20]) == [7, 1, 1, 1, 1, 1, 0, 0, 0, 21, 21, 21]\n    assert candidate(numArrows = 100,aliceArrows = [10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0]) == [49, 11, 11, 11, 11, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(numArrows = 18,aliceArrows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1]) == [0, 0, 0, 0, 0, 7, 0, 9, 0, 0, 0, 2]\n    assert candidate(numArrows = 30,aliceArrows = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == [1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 11]\n    assert candidate(numArrows = 75,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n    assert candidate(numArrows = 10,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 1]\n    assert candidate(numArrows = 100,aliceArrows = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [78, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n    assert candidate(numArrows = 60,aliceArrows = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [38, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n    assert candidate(numArrows = 7,aliceArrows = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 2, 2]\n    assert candidate(numArrows = 100,aliceArrows = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == [1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n    assert candidate(numArrows = 30,aliceArrows = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == [0, 0, 0, 0, 0, 0, 14, 16, 0, 0, 0, 0]\n    assert candidate(numArrows = 90,aliceArrows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [13, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n    assert candidate(numArrows = 30,aliceArrows = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n    assert candidate(numArrows = 100,aliceArrows = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0]) == [44, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]\n    assert candidate(numArrows = 10,aliceArrows = [3, 1, 2, 2, 3, 1, 4, 2, 3, 4, 5, 1]) == [0, 0, 0, 0, 0, 0, 0, 3, 0, 5, 0, 2]\n    assert candidate(numArrows = 60,aliceArrows = [3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 2, 3, 4, 0, 6, 7, 8, 9, 10, 11]\n    assert candidate(numArrows = 75,aliceArrows = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6]) == [43, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7]\n    assert candidate(numArrows = 120,aliceArrows = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [43, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n    assert candidate(numArrows = 100,aliceArrows = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == [64, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1]\n", "comparison": "exact"}, "public_tests": ["9\n[1,1,0,1,0,0,2,1,0,1,2,0]", "3\n[0,0,1,0,0,0,0,0,0,0,0,2]"], "hints": ["To obtain points for some certain section x, what is the minimum number of arrows Bob must shoot?", "Given the small number of sections, can we brute force which sections Bob wants to win?", "For every set of sections Bob wants to win, check if we have the required amount of arrows. If we do, it is a valid selection."], "metadata": {"canonical_parameter_names": ["numArrows", "aliceArrows"], "leetcode_dataset_entry_point": "Solution().maximumBobPoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:06+00:00", "tests_total": 109, "tests_dropped": 0, "flags": ["multiple_answers", "has_images"], "topic_tags": ["array", "backtracking", "bit-manipulation", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def maximumBobPoints(self, numArrows: int, aliceArrows: list[int]) -> list[int]:", "container": "Solution", "callable": "maximumBobPoints", "parameters": [{"name": "numArrows", "type": "int"}, {"name": "aliceArrows", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2213, "task_id": "longest-substring-of-one-repeating-character", "difficulty": "Hard", "problem_description": "You are given a 0-indexed string s. You are also given a 0-indexed string queryCharacters of length k and a 0-indexed array of integer indices queryIndices of length k, both of which are used to describe k queries.\n\nThe i^th query updates the character in s at index queryIndices[i] to the character queryCharacters[i].\n\nReturn an array lengths of length k where lengths[i] is the length of the longest substring of s consisting of only one repeating character after the i^th query is performed.\n\nExample 1:\n\nInput: s = \"babacc\", queryCharacters = \"bcb\", queryIndices = [1,3,3]\nOutput: [3,3,4]\nExplanation:\n- 1^st query updates s = \"bbbacc\". The longest substring consisting of one repeating character is \"bbb\" with length 3.\n- 2^nd query updates s = \"bbbccc\".\n  The longest substring consisting of one repeating character can be \"bbb\" or \"ccc\" with length 3.\n- 3^rd query updates s = \"bbbbcc\". The longest substring consisting of one repeating character is \"bbbb\" with length 4.\nThus, we return [3,3,4].\n\nExample 2:\n\nInput: s = \"abyzz\", queryCharacters = \"aa\", queryIndices = [2,1]\nOutput: [2,3]\nExplanation:\n- 1^st query updates s = \"abazz\". The longest substring consisting of one repeating character is \"zz\" with length 2.\n- 2^nd query updates s = \"aaazz\". The longest substring consisting of one repeating character is \"aaa\" with length 3.\nThus, we return [2,3].\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of lowercase English letters.\n- k == queryCharacters.length == queryIndices.length\n- 1 <= k <= 10^5\n- queryCharacters consists of lowercase English letters.\n- 0 <= queryIndices[i] < s.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"abcde\",queryCharacters = \"aaaaa\",queryIndices = [0, 1, 2, 3, 4]) == [1, 2, 3, 4, 5]\n    assert candidate(s = \"abyzz\",queryCharacters = \"aa\",queryIndices = [2, 1]) == [2, 3]\n    assert candidate(s = \"abcde\",queryCharacters = \"ee\",queryIndices = [2, 4]) == [1, 1]\n    assert candidate(s = \"zzzzz\",queryCharacters = \"abcd\",queryIndices = [0, 1, 2, 3]) == [4, 3, 2, 1]\n    assert candidate(s = \"babacc\",queryCharacters = \"bcb\",queryIndices = [1, 3, 3]) == [3, 3, 4]\n    assert candidate(s = \"abcde\",queryCharacters = \"ee\",queryIndices = [0, 4]) == [1, 1]\n    assert candidate(s = \"aaaaa\",queryCharacters = \"bb\",queryIndices = [1, 3]) == [3, 1]\n    assert candidate(s = \"z\",queryCharacters = \"z\",queryIndices = [0]) == [1]\n    assert candidate(s = \"zzzzz\",queryCharacters = \"xy\",queryIndices = [0, 4]) == [4, 3]\n    assert candidate(s = \"aaaaa\",queryCharacters = \"b\",queryIndices = [2]) == [2]\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",queryCharacters = \"zzzzzzzzzzzzzzzzzzzz\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n    assert candidate(s = \"ababababab\",queryCharacters = \"aaaaaaaaaa\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 3, 3, 5, 5, 7, 7, 9, 9, 10]\n    assert candidate(s = \"abcdefghij\",queryCharacters = \"jjjjjjjjjj\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 10, 10]\n    assert candidate(s = \"abcdefg\",queryCharacters = \"hijklmn\",queryIndices = [0, 1, 2, 3, 4, 5, 6]) == [1, 1, 1, 1, 1, 1, 1]\n    assert candidate(s = \"abacabadabacaba\",queryCharacters = \"aaaaaaaaaaaaaaa\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15]\n    assert candidate(s = \"aabbccddeeffgghhiijjkk\",queryCharacters = \"llll\",queryIndices = [2, 4, 6, 8]) == [2, 2, 2, 2]\n    assert candidate(s = \"zzzzzzzzzz\",queryCharacters = \"yyyyyyyyyy\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 8, 7, 6, 5, 6, 7, 8, 9, 10]\n    assert candidate(s = \"aabbaabb\",queryCharacters = \"cccc\",queryIndices = [1, 3, 5, 7]) == [2, 2, 2, 1]\n    assert candidate(s = \"pppqqqrrrsssttt\",queryCharacters = \"uuuuuuuuuuuuuuu\",queryIndices = [2, 5, 8, 11, 14, 2, 5, 8, 11, 14, 2, 5, 8, 11, 14]) == [3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n    assert candidate(s = \"xyzzxxxyyy\",queryCharacters = \"zzz\",queryIndices = [1, 3, 5]) == [3, 3, 3]\n    assert candidate(s = \"abababababababab\",queryCharacters = \"cccccccc\",queryIndices = [0, 2, 4, 6, 8, 10, 12, 14]) == [1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(s = \"mnopqrstu\",queryCharacters = \"aaaaaaaaa\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(s = \"abcdefghij\",queryCharacters = \"z\",queryIndices = [5]) == [1]\n    assert candidate(s = \"aaabbbccc\",queryCharacters = \"dddddd\",queryIndices = [0, 3, 6, 1, 4, 7]) == [3, 3, 2, 2, 2, 2]\n    assert candidate(s = \"aabaaa\",queryCharacters = \"bbccc\",queryIndices = [1, 1, 3, 3, 4]) == [3, 3, 2, 2, 2]\n    assert candidate(s = \"abcabcabc\",queryCharacters = \"aaa\",queryIndices = [0, 3, 6]) == [1, 1, 1]\n    assert candidate(s = \"abcabcabc\",queryCharacters = \"ddddddd\",queryIndices = [0, 3, 6, 1, 4, 7, 2]) == [1, 1, 1, 2, 2, 2, 5]\n    assert candidate(s = \"aabbaa\",queryCharacters = \"bb\",queryIndices = [0, 4]) == [2, 3]\n    assert candidate(s = \"abcdabcdabcdabcd\",queryCharacters = \"zzzz\",queryIndices = [1, 3, 5, 7]) == [1, 1, 1, 1]\n    assert candidate(s = \"abcabcabcabc\",queryCharacters = \"dddddddddddd\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n    assert candidate(s = \"mississippi\",queryCharacters = \"llll\",queryIndices = [0, 1, 2, 3]) == [2, 2, 3, 4]\n    assert candidate(s = \"xyxxyxyxyx\",queryCharacters = \"zzzzzzzzzz\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [2, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(s = \"aabbbccccc\",queryCharacters = \"bbb\",queryIndices = [2, 3, 7]) == [5, 5, 3]\n    assert candidate(s = \"abccba\",queryCharacters = \"bbccc\",queryIndices = [2, 3, 2, 3, 4]) == [2, 4, 2, 2, 3]\n    assert candidate(s = \"xyxyxyxyxyxy\",queryCharacters = \"zzzzzzzzzzzz\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n    assert candidate(s = \"aaaaaaaaaa\",queryCharacters = \"bbbbbbbbbb\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 8, 7, 6, 5, 6, 7, 8, 9, 10]\n    assert candidate(s = \"abcdefg\",queryCharacters = \"zzzzzzz\",queryIndices = [6, 5, 4, 3, 2, 1, 0]) == [1, 2, 3, 4, 5, 6, 7]\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",queryCharacters = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 26]\n    assert candidate(s = \"mmmmnnnnoooo\",queryCharacters = \"ppppqqqqrrrr\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n    assert candidate(s = \"abccba\",queryCharacters = \"cccccc\",queryIndices = [1, 2, 3, 4, 5, 0]) == [3, 3, 3, 4, 5, 6]\n    assert candidate(s = \"abcdefghij\",queryCharacters = \"abcdefghij\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(s = \"abcdeabcdeabcdeabcde\",queryCharacters = \"abcdeabcdeabcdeabcde\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(s = \"aabbccddeeffgg\",queryCharacters = \"hhhhhhhh\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7]) == [2, 2, 3, 4, 5, 6, 7, 8]\n    assert candidate(s = \"aabbcc\",queryCharacters = \"ffffff\",queryIndices = [0, 1, 2, 3, 4, 5]) == [2, 2, 3, 4, 5, 6]\n    assert candidate(s = \"mmmmmmmmmm\",queryCharacters = \"llllllllll\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 8, 7, 6, 5, 6, 7, 8, 9, 10]\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",queryCharacters = \"abcdefghijklmnopqrstuvwxyz\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(s = \"xyxyxyxyxyx\",queryCharacters = \"yyyyy\",queryIndices = [1, 3, 5, 7, 9]) == [1, 1, 1, 1, 1]\n    assert candidate(s = \"abcdefghij\",queryCharacters = \"jjjjj\",queryIndices = [8, 7, 6, 5, 4]) == [2, 3, 4, 5, 6]\n    assert candidate(s = \"abcdefghij\",queryCharacters = \"aaaaaaaaaa\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(s = \"abcdefghijabcdefghij\",queryCharacters = \"jjjjjjjjjj\",queryIndices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [2, 3, 4, 5, 6, 7, 8, 9, 11, 11]\n    assert candidate(s = \"abababababab\",queryCharacters = \"cccc\",queryIndices = [0, 2, 4, 6]) == [1, 1, 1, 1]\n    assert candidate(s = \"aabbccddeeff\",queryCharacters = \"abcdef\",queryIndices = [1, 3, 5, 7, 9, 11]) == [2, 2, 2, 2, 2, 2]\n    assert candidate(s = \"abacaba\",queryCharacters = \"aaaaa\",queryIndices = [1, 2, 3, 4, 5]) == [3, 3, 5, 5, 7]\n    assert candidate(s = \"xyzxyzxyzxyz\",queryCharacters = \"zzzz\",queryIndices = [0, 1, 2, 3]) == [1, 3, 3, 4]\n    assert candidate(s = \"zzzzzzzzzz\",queryCharacters = \"aaaaaaaaaa\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 8, 7, 6, 5, 6, 7, 8, 9, 10]\n    assert candidate(s = \"abcdabcdabcd\",queryCharacters = \"aaaabbbb\",queryIndices = [0, 1, 8, 9, 4, 5, 10, 11]) == [1, 2, 2, 2, 2, 2, 2, 2]\n    assert candidate(s = \"aabbccddeeff\",queryCharacters = \"hhhhhhh\",queryIndices = [1, 3, 5, 7, 9, 11, 1]) == [2, 2, 2, 2, 2, 1, 1]\n    assert candidate(s = \"aabbccddeeff\",queryCharacters = \"zzzzzz\",queryIndices = [1, 3, 5, 7, 9, 11]) == [2, 2, 2, 2, 2, 1]\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",queryCharacters = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 26]\n    assert candidate(s = \"aabbaa\",queryCharacters = \"cccccc\",queryIndices = [0, 1, 2, 3, 4, 5]) == [2, 2, 3, 4, 5, 6]\n    assert candidate(s = \"zzzzzzyyyyy\",queryCharacters = \"xyyxz\",queryIndices = [0, 5, 6, 7, 10]) == [5, 6, 6, 4, 4]\n    assert candidate(s = \"aaaaaaaaaaabbbbbbbbbbbcccccccccc\",queryCharacters = \"dddddddddd\",queryIndices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [11, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n    assert candidate(s = \"abacabadabacaba\",queryCharacters = \"zzzzzzzzzzz\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n    assert candidate(s = \"abababab\",queryCharacters = \"bbbbbbbb\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7]) == [2, 2, 4, 4, 6, 6, 8, 8]\n    assert candidate(s = \"abacabadabacaba\",queryCharacters = \"ccccccc\",queryIndices = [0, 1, 2, 3, 4, 5, 6]) == [1, 2, 4, 4, 5, 6, 7]\n    assert candidate(s = \"aabbccddeeff\",queryCharacters = \"gggggg\",queryIndices = [0, 1, 2, 3, 4, 5]) == [2, 2, 3, 4, 5, 6]\n    assert candidate(s = \"zzzzzzzzzzzz\",queryCharacters = \"aaaaaaaaaa\",queryIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [11, 10, 9, 8, 7, 6, 7, 8, 9, 10]\n    assert candidate(s = \"abccbaabc\",queryCharacters = \"cccc\",queryIndices = [2, 3, 5, 6]) == [2, 2, 2, 2]\n    assert candidate(s = \"xyxyxyxyxyx\",queryCharacters = \"aaaaaa\",queryIndices = [0, 2, 4, 6, 8, 10]) == [1, 1, 1, 1, 1, 1]\n", "comparison": "exact"}, "public_tests": ["\"babacc\"\n\"bcb\"\n[1,3,3]", "\"abyzz\"\n\"aa\"\n[2,1]"], "hints": ["Use a segment tree to perform fast point updates and range queries.", "We need each segment tree node to store the length of the longest substring of that segment consisting of only 1 repeating character.", "We will also have each segment tree node store the leftmost and rightmost character of the segment, the max length of a prefix substring consisting of only 1 repeating character, and the max length of a suffix substring consisting of only 1 repeating character.", "Use this information to properly merge the two segment tree nodes together."], "metadata": {"canonical_parameter_names": ["s", "queryCharacters", "queryIndices"], "leetcode_dataset_entry_point": "Solution().longestRepeating", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:09+00:00", "tests_total": 80, "tests_dropped": 11, "flags": [], "topic_tags": ["array", "string", "segment-tree", "ordered-set"]}, "language": "python", "interface": {"raw_signature": "def longestRepeating(self, s: str, queryCharacters: str, queryIndices: list[int]) -> list[int]:", "container": "Solution", "callable": "longestRepeating", "parameters": [{"name": "s", "type": "str"}, {"name": "queryCharacters", "type": "str"}, {"name": "queryIndices", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2215, "task_id": "find-the-difference-of-two-arrays", "difficulty": "Easy", "problem_description": "Given two 0-indexed integer arrays nums1 and nums2, return a list answer of size 2 where:\n\n- answer[0] is a list of all distinct integers in nums1 which are not present in nums2.\n- answer[1] is a list of all distinct integers in nums2 which are not present in nums1.\n\nNote that the integers in the lists may be returned in any order.\n\nExample 1:\n\nInput: nums1 = [1,2,3], nums2 = [2,4,6]\nOutput: [[1,3],[4,6]]\nExplanation:\nFor nums1, nums1[1] = 2 is present at index 0 of nums2, whereas nums1[0] = 1 and nums1[2] = 3 are not present in nums2. Therefore, answer[0] = [1,3].\nFor nums2, nums2[0] = 2 is present at index 1 of nums1, whereas nums2[1] = 4 and nums2[2] = 6 are not present in nums1. Therefore, answer[1] = [4,6].\n\nExample 2:\n\nInput: nums1 = [1,2,3,3], nums2 = [1,1,2,2]\nOutput: [[3],[]]\nExplanation:\nFor nums1, nums1[2] and nums1[3] are not present in nums2. Since nums1[2] == nums1[3], their value is only included once and answer[0] = [3].\nEvery integer in nums2 is present in nums1. Therefore, answer[1] = [].\n\nConstraints:\n\n- 1 <= nums1.length, nums2.length <= 1000\n- -1000 <= nums1[i], nums2[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums1 = [0, -1, -2],nums2 = [1, -1, 2]) == [[0, -2], [1, 2]]\n    assert candidate(nums1 = [5, 7, 8],nums2 = [9, 10, 5]) == [[8, 7], [9, 10]]\n    assert candidate(nums1 = [10, 20, 30],nums2 = [5, 15, 25, 35]) == [[10, 20, 30], [25, 35, 5, 15]]\n    assert candidate(nums1 = [5, 7, 8],nums2 = [9, 10, 11]) == [[8, 5, 7], [9, 10, 11]]\n    assert candidate(nums1 = [1000, -1000],nums2 = [-1000, 1000]) == [[], []]\n    assert candidate(nums1 = [1000, -1000],nums2 = [-1000, 1000]) == [[], []]\n    assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == [[], []]\n    assert candidate(nums1 = [1, 3, 5, 7],nums2 = [2, 4, 6, 8]) == [[1, 3, 5, 7], [8, 2, 4, 6]]\n    assert candidate(nums1 = [1, 2, 3, 3],nums2 = [1, 1, 2, 2]) == [[3], []]\n    assert candidate(nums1 = [100, 200, 300],nums2 = [100, 200, 300]) == [[], []]\n    assert candidate(nums1 = [1, 1, 1, 1],nums2 = [2, 2, 2, 2]) == [[1], [2]]\n    assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]\n    assert candidate(nums1 = [-1, -2, -3],nums2 = [-3, -4, -5]) == [[-1, -2], [-5, -4]]\n    assert candidate(nums1 = [10, 20, 30],nums2 = [30, 40, 50]) == [[10, 20], [40, 50]]\n    assert candidate(nums1 = [5, 7, 9],nums2 = [5, 8, 10]) == [[9, 7], [8, 10]]\n    assert candidate(nums1 = [-1, -2, -3],nums2 = [-2, -3, -4]) == [[-1], [-4]]\n    assert candidate(nums1 = [1],nums2 = [2]) == [[1], [2]]\n    assert candidate(nums1 = [-1000, 0, 1000],nums2 = [0]) == [[-1000, 1000], []]\n    assert candidate(nums1 = [5, 6, 7],nums2 = [7, 8, 9]) == [[5, 6], [8, 9]]\n    assert candidate(nums1 = [1, 2, 3],nums2 = [2, 4, 6]) == [[1, 3], [4, 6]]\n    assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == [[1, 2, 3], [4, 5, 6]]\n    assert candidate(nums1 = [-1, 0, 1],nums2 = [0, 1, 2]) == [[-1], [2]]\n    assert candidate(nums1 = [0],nums2 = [0]) == [[], []]\n    assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0]) == [[], []]\n    assert candidate(nums1 = [10, 20, 30],nums2 = [15, 25, 35]) == [[10, 20, 30], [25, 35, 15]]\n    assert candidate(nums1 = [-1, -2, -3, -4, -5, 0, 5, 10],nums2 = [-5, -4, -3, -2, -1, 0, 1, 2]) == [[10, 5], [1, 2]]\n    assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0]) == [[], []]\n    assert candidate(nums1 = [6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5]) == [[6, 7, 8, 9, 10], [1, 2, 3, 4, 5]]\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4],nums2 = [4, 4, 5, 5, 6, 6, 7, 7]) == [[1, 2, 3], [5, 6, 7]]\n    assert candidate(nums1 = [-5, -10, -15, -20],nums2 = [-10, -15, -20, -25]) == [[-5], [-25]]\n    assert candidate(nums1 = [1000, 999, 998, 997, 996],nums2 = [996, 995, 994, 993, 992]) == [[1000, 997, 998, 999], [992, 993, 994, 995]]\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4],nums2 = [2, 2, 3, 3, 5, 5, 6, 6]) == [[1, 4], [5, 6]]\n    assert candidate(nums1 = [10, 20, 30, 40],nums2 = [30, 40, 50, 60]) == [[10, 20], [50, 60]]\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [[1, 2, 3, 4], [11, 12, 13, 14]]\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [[], []]\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], []]\n    assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5]) == [[], []]\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [100, 200, 300, 400, 500]) == [[], []]\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [200, 400, 600, 800, 1000]) == [[100, 500, 300], [800, 1000, 600]]\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 3, 5, 7, 9]) == [[2, 4, 6, 8, 10], []]\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]\n    assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 1, 1, 1]) == [[0], [1]]\n    assert candidate(nums1 = [-1, -2, -3, -4],nums2 = [-3, -4, -5, -6]) == [[-1, -2], [-6, -5]]\n    assert candidate(nums1 = [1, 2, 2, 3, 4, 4, 5],nums2 = [2, 4, 6, 7, 8, 8, 9]) == [[1, 3, 5], [8, 9, 6, 7]]\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [2, 2, 4, 4, 5, 5]) == [[1, 3], [4, 5]]\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]\n    assert candidate(nums1 = [1, 2, 3],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [[], [4, 5, 6, 7, 8, 9, 10]]\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [[], [35, 45, 15, 55, 25]]\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], []]\n    assert candidate(nums1 = [100, 200, 300, 400],nums2 = [300, 400, 500, 600]) == [[200, 100], [600, 500]]\n    assert candidate(nums1 = [-1000, -999, -998],nums2 = [-1000, -999, -997]) == [[-998], [-997]]\n    assert candidate(nums1 = [1000, -1000, 0, 500, -500],nums2 = [-1000, 0, 500, -500, 1000]) == [[], []]\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [2, 4, 6, 8, 10, 12, 14, 16]) == [[1, 3, 5, 7, 9, 11, 13, 15], [2, 4, 6, 8, 10, 12, 14, 16]]\n    assert candidate(nums1 = [100, -50, 0, 200, 300],nums2 = [-50, 0, 100, 400, 500]) == [[200, 300], [400, 500]]\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [[], []]\n    assert candidate(nums1 = [100, 200, 300, 400],nums2 = [100, 300, 500, 600]) == [[200, 400], [600, 500]]\n    assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [-5, -4, -3, -2, -1]) == [[], []]\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == [[], []]\n    assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 1, 2, 3, 4, 5]) == [[], [1, 2, 3, 4, 5]]\n    assert candidate(nums1 = [-1, 0, 1],nums2 = [0, -1, 2]) == [[1], [2]]\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [[1], [2]]\n    assert candidate(nums1 = [-1000, -500, 0, 500, 1000],nums2 = [-1000, -500, 0, 500, 1000]) == [[], []]\n    assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [-1000, -900, -800, -700, -600, -500, -400, -300, -200, -100]) == [[800, 900, 100, 1000, 200, 300, 400, 500, 600, 700], [-800, -700, -600, -500, -400, -900, -300, -200, -1000, -100]]\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [3, 3, 4, 4, 5, 5]) == [[1, 2], [4, 5]]\n    assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [[100, 70, 40, 10, 80, 50, 20, 90, 60, 30], [65, 35, 5, 75, 45, 15, 85, 55, 25, 95]]\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 60, 70, 80, 90]) == [[40, 10, 20, 30], [80, 90, 60, 70]]\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45, 55]) == [[40, 10, 50, 20, 30], [35, 5, 45, 15, 55, 25]]\n    assert candidate(nums1 = [500, 501, 502, 503, 504],nums2 = [502, 503, 504, 505, 506]) == [[500, 501], [505, 506]]\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [[], []]\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == [[40, 10, 50, 20, 30], [35, 5, 45, 15, 25]]\n    assert candidate(nums1 = [-1000, 1000, 0],nums2 = [0, -1000, 1000]) == [[], []]\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [2, 4, 6, 8, 10, 12]) == [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12]]\n    assert candidate(nums1 = [100, 200, 300],nums2 = [300, 200, 100, 400, 500]) == [[], [400, 500]]\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [[1, 3, 5, 7, 9], [12, 14, 16, 18, 20]]\n    assert candidate(nums1 = [500, 501, 502, 503, 504, 505],nums2 = [503, 504, 505, 506, 507, 508]) == [[500, 501, 502], [506, 507, 508]]\n    assert candidate(nums1 = [-1, -2, -3],nums2 = [-3, -4, -5]) == [[-1, -2], [-5, -4]]\n    assert candidate(nums1 = [10, 20, 30],nums2 = [30, 20, 10]) == [[], []]\n    assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]\n    assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [[], []]\n    assert candidate(nums1 = [100, -50, 200, 300, -100],nums2 = [-50, 200, 400, 500, -100]) == [[100, 300], [400, 500]]\n    assert candidate(nums1 = [1000, 500, -500, -1000],nums2 = [500, -500, 1000, -1000]) == [[], []]\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 6, 7, 8, 9]) == [[1, 2, 3, 4], [8, 9, 6, 7]]\n    assert candidate(nums1 = [1000, -1000, 500, -500, 0],nums2 = [0, 500, -500, 1000, -1000]) == [[], []]\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100]) == [[], []]\n    assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [[], []]\n    assert candidate(nums1 = [10, 20, 30],nums2 = [30, 40, 50, 10, 20]) == [[], [40, 50]]\n    assert candidate(nums1 = [500, 600, 700],nums2 = [800, 900, 1000, 500, 600]) == [[700], [800, 1000, 900]]\n    assert candidate(nums1 = [100, -50, 23, 7, 3, 100],nums2 = [-50, 23, 8, 9, 100, 101]) == [[3, 7], [8, 9, 101]]\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5]) == [[], []]\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5],nums2 = [5, 6, 7, 8, 9, 0]) == [[1, 2, 3, 4], [8, 9, 6, 7]]\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [150, 250, 350, 450, 550]) == [[100, 200, 300, 400, 500], [450, 550, 150, 250, 350]]\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 600, 700, 800, 900]) == [[200, 100, 400, 300], [800, 700, 600, 900]]\n    assert candidate(nums1 = [-10, -20, -30],nums2 = [-30, -40, -50, -10]) == [[-20], [-40, -50]]\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10]) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]\n    assert candidate(nums1 = [100, 200, 300, 400],nums2 = [100, 200, 300, 500]) == [[400], [500]]\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [101, 201, 301, 401, 501]) == [[100, 200, 300, 400, 500], [101, 201, 301, 401, 501]]\n    assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [-5, -6, -7, -8, -9]) == [[-4, -3, -2, -1], [-8, -7, -6, -9]]\n    assert candidate(nums1 = [0, -1, -2, -3, -4],nums2 = [-2, -4, -6, -8, -10]) == [[0, -3, -1], [-8, -6, -10]]\n    assert candidate(nums1 = [100, 200, 300],nums2 = [100, 200, 300, 400, 500]) == [[], [400, 500]]\n    assert candidate(nums1 = [-1, -2, -3, -4],nums2 = [-4, -5, -6, -7]) == [[-3, -1, -2], [-7, -6, -5]]\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5],nums2 = [3, 4, 5, 6, 7, 8]) == [[0, 1, 2], [8, 6, 7]]\n    assert candidate(nums1 = [-1000, -500, 0, 500, 1000],nums2 = [1000, 500, 0, -500, -1000]) == [[], []]\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55]) == [[40, 10, 50, 20, 30], [35, 45, 15, 55, 25]]\n    assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46]) == [[35, 5, 40, 10, 45, 15, 50, 20, 25, 30], [1, 36, 6, 41, 11, 46, 16, 21, 26, 31]]\n    assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],nums2 = [3, 3, 4, 4, 5, 5, 6, 6]) == [[1, 2], [5, 6]]\n    assert candidate(nums1 = [-1000, -999, -998, -997],nums2 = [-999, -998, -997, -996]) == [[-1000], [-996]]\n", "comparison": "exact"}, "public_tests": ["[1,2,3]\n[2,4,6]", "[1,2,3,3]\n[1,1,2,2]"], "hints": ["For each integer in nums1, check if it exists in nums2.", "Do the same for each integer in nums2."], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().findDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:13+00:00", "tests_total": 112, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "hash-table"]}, "language": "python", "interface": {"raw_signature": "def findDifference(self, nums1: list[int], nums2: list[int]) -> list[list[int]]:", "container": "Solution", "callable": "findDifference", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2216, "task_id": "minimum-deletions-to-make-array-beautiful", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. The array nums is beautiful if:\n\n- nums.length is even.\n- nums[i] != nums[i + 1] for all i % 2 == 0.\n\nNote that an empty array is considered beautiful.\n\nYou can delete any number of elements from nums. When you delete an element, all the elements to the right of the deleted element will be shifted one unit to the left to fill the gap created and all the elements to the left of the deleted element will remain unchanged.\n\nReturn the minimum number of elements to delete from nums to make it beautiful.\n\nExample 1:\n\nInput: nums = [1,1,2,3,5]\nOutput: 1\nExplanation: You can delete either nums[0] or nums[1] to make nums = [1,2,3,5] which is beautiful. It can be proven you need at least 1 deletion to make nums beautiful.\n\nExample 2:\n\nInput: nums = [1,1,2,2,3,3]\nOutput: 2\nExplanation: You can delete nums[0] and nums[5] to make nums = [1,2,2,3] which is beautiful. It can be proven you need at least 2 deletions to make nums beautiful.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1]) == 1\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000]) == 6\n    assert candidate(nums = [1, 1, 2, 2, 3, 3]) == 2\n    assert candidate(nums = [100000, 100000, 99999, 99999, 99998, 99998]) == 2\n    assert candidate(nums = [2, 2, 2, 2, 2, 2]) == 6\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 5]) == 1\n    assert candidate(nums = [0, 1, 0, 1, 0, 1]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 2\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4]) == 1\n    assert candidate(nums = [1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n    assert candidate(nums = [1, 1, 2, 3, 5]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 6\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 1\n    assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2]) == 5\n    assert candidate(nums = [1, 3, 2, 3, 3, 2]) == 0\n    assert candidate(nums = [1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5]) == 16\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5]) == 2\n    assert candidate(nums = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 2\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == 6\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 24\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 10\n    assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 20\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 8\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 1\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 1\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == 2\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n    assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 12\n    assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 24\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 11\n    assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 10, 11, 11, 12, 13, 14]) == 4\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15]) == 0\n    assert candidate(nums = [10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100]) == 1\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 12\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1\n    assert candidate(nums = [1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 3\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 2\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 2\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 0, 1, 1, 2, 2]) == 2\n    assert candidate(nums = [1, 2, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 2\n    assert candidate(nums = [5, 5, 4, 4, 4, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0]) == 6\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 7, 8, 8, 9, 9]) == 2\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 1\n    assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 2\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 1\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4]) == 4\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5]) == 8\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 16\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 8\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 25\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 1\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 0\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 1\n    assert candidate(nums = [1, 2, 3, 3, 4, 5, 5, 6, 7, 8]) == 2\n    assert candidate(nums = [100000, 99999, 99999, 99998, 99998, 99997, 99997, 99996]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n    assert candidate(nums = [100000, 100000, 99999, 99999, 99998, 99998, 99997, 99997, 99996, 99996, 99995, 99995, 99994, 99994, 99993, 99993, 99992, 99992, 99991, 99991, 99990, 99990, 99989, 99989, 99988, 99988]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10]) == 15\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 82\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 12\n    assert candidate(nums = [1, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2]) == 8\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 6\n    assert candidate(nums = [1, 1, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 13\n    assert candidate(nums = [1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 2\n    assert candidate(nums = [1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n    assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 12\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1\n    assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9]) == 0\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n    assert candidate(nums = [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5]) == 8\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 22\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [100000, 100000, 99999, 99999, 99998, 99998, 99997, 99997]) == 2\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 3\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000]) == 6\n    assert candidate(nums = [1, 2, 3, 3, 3, 4, 5, 5, 5, 6, 6, 6, 7, 8, 9, 9, 9]) == 7\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n    assert candidate(nums = [1, 1, 2, 2, 3, 4, 4, 4, 5, 5, 6, 6, 7, 8, 8, 9, 9, 10, 10]) == 5\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9]) == 20\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n    assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == 3\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 11\n    assert candidate(nums = [1, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 0\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n    assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100, 110]) == 1\n    assert candidate(nums = [100000, 100000, 99999, 99999, 99998, 99998, 99997, 99997, 99996, 99996]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 1\n    assert candidate(nums = [1, 2, 3, 3, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9, 10]) == 5\n    assert candidate(nums = [1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7]) == 2\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 2\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 31\n    assert candidate(nums = [1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 10, 10]) == 3\n    assert candidate(nums = [1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n", "comparison": "exact"}, "public_tests": ["[1,1,2,3,5]", "[1,1,2,2,3,3]"], "hints": ["Delete as many adjacent equal elements as necessary.", "If the length of nums is odd after the entire process, delete the last element."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minDeletion", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:15+00:00", "tests_total": 125, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "stack", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minDeletion(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minDeletion", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2217, "task_id": "find-palindrome-with-fixed-length", "difficulty": "Medium", "problem_description": "Given an integer array queries and a positive integer intLength, return an array answer where answer[i] is either the queries[i]^th smallest positive palindrome of length intLength or -1 if no such palindrome exists.\n\nA palindrome is a number that reads the same backwards and forwards. Palindromes cannot have leading zeros.\n\nExample 1:\n\nInput: queries = [1,2,3,4,5,90], intLength = 3\nOutput: [101,111,121,131,141,999]\nExplanation:\nThe first few palindromes of length 3 are:\n101, 111, 121, 131, 141, 151, 161, 171, 181, 191, 202, ...\nThe 90^th palindrome of length 3 is 999.\n\nExample 2:\n\nInput: queries = [2,4,6], intLength = 4\nOutput: [1111,1331,1551]\nExplanation:\nThe first six palindromes of length 4 are:\n1001, 1111, 1221, 1331, 1441, and 1551.\n\nConstraints:\n\n- 1 <= queries.length <= 5 * 10^4\n- 1 <= queries[i] <= 10^9\n- 1 <= intLength <= 15\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(queries = [10, 20, 30],intLength = 2) == [-1, -1, -1]\n    assert candidate(queries = [1, 3, 5, 7, 9],intLength = 5) == [10001, 10201, 10401, 10601, 10801]\n    assert candidate(queries = [50000],intLength = 15) == [100499999994001]\n    assert candidate(queries = [1, 1000000],intLength = 15) == [100000000000001, 109999999999901]\n    assert candidate(queries = [1, 2, 3, 4, 5, 90],intLength = 3) == [101, 111, 121, 131, 141, 999]\n    assert candidate(queries = [10, 20, 30],intLength = 6) == [109901, 119911, 129921]\n    assert candidate(queries = [2, 4, 6],intLength = 4) == [1111, 1331, 1551]\n    assert candidate(queries = [100, 200, 300],intLength = 7) == [1099901, 1199911, 1299921]\n    assert candidate(queries = [1, 10, 100, 1000],intLength = 7) == [1000001, 1009001, 1099901, 1999991]\n    assert candidate(queries = [10, 20, 30],intLength = 6) == [109901, 119911, 129921]\n    assert candidate(queries = [100, 200, 300],intLength = 7) == [1099901, 1199911, 1299921]\n    assert candidate(queries = [1, 1, 1, 1],intLength = 1) == [1, 1, 1, 1]\n    assert candidate(queries = [1, 100000000],intLength = 1) == [1, -1]\n    assert candidate(queries = [5000000],intLength = 1) == [-1]\n    assert candidate(queries = [1000000000],intLength = 15) == [-1]\n    assert candidate(queries = [1, 10, 100, 1000, 10000],intLength = 5) == [10001, 10901, 19991, -1, -1]\n    assert candidate(queries = [100000],intLength = 15) == [100999999999001]\n    assert candidate(queries = [1, 2, 3],intLength = 1) == [1, 2, 3]\n    assert candidate(queries = [5, 15, 25],intLength = 2) == [55, -1, -1]\n    assert candidate(queries = [123456, 654321],intLength = 10) == [-1, -1]\n    assert candidate(queries = [50000, 100000, 150000, 200000, 250000, 300000, 350000, 400000],intLength = 13) == [1049999999401, 1099999999901, 1149999999411, 1199999999911, 1249999999421, 1299999999921, 1349999999431, 1399999999931]\n    assert candidate(queries = [100, 1000, 10000, 100000, 1000000],intLength = 15) == [100000999000001, 100009999900001, 100099999990001, 100999999999001, 109999999999901]\n    assert candidate(queries = [1, 9, 99, 999, 9999, 99999],intLength = 15) == [100000000000001, 100000080000001, 100000989000001, 100009989900001, 100099989990001, 100999989999001]\n    assert candidate(queries = [1, 10, 100, 1000, 10000, 100000],intLength = 3) == [101, 191, -1, -1, -1, -1]\n    assert candidate(queries = [90000000, 95000000, 99000000],intLength = 15) == [999999999999999, -1, -1]\n    assert candidate(queries = [123456789],intLength = 15) == [-1]\n    assert candidate(queries = [1, 123456, 987654, 999999],intLength = 5) == [10001, -1, -1, -1]\n    assert candidate(queries = [98765, 43210, 54321, 67890],intLength = 5) == [-1, -1, -1, -1]\n    assert candidate(queries = [1000000, 2000000, 3000000, 4000000, 5000000],intLength = 11) == [-1, -1, -1, -1, -1]\n    assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],intLength = 5) == [10001, 10101, 10201, 10301, 10401, 10501, 10601, 10701, 10801, 10901]\n    assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],intLength = 15) == [100000000000001, 100000010000001, 100000020000001, 100000030000001, 100000040000001, 100000050000001, 100000060000001, 100000070000001, 100000080000001, 100000090000001]\n    assert candidate(queries = [123, 456, 789, 101112, 131415],intLength = 11) == [10012221001, 10045554001, 10078887001, 20111111102, 23141414132]\n    assert candidate(queries = [1, 10, 100, 1000, 10000],intLength = 9) == [100000001, 100090001, 100999001, 109999901, 199999991]\n    assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],intLength = 9) == [100000001, 100010001, 100020001, 100030001, 100040001, 100050001, 100060001, 100070001, 100080001, 100090001]\n    assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],intLength = 2) == [11, 22, 33, 44, 55, 66, 77, 88, 99, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(queries = [1, 2, 3, 4, 5, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],intLength = 5) == [10001, 10101, 10201, 10301, 10401, 19991, 29992, 39993, 49994, 59995, 69996, 79997, 89998, 99999, -1]\n    assert candidate(queries = [100000000, 200000000, 300000000],intLength = 12) == [-1, -1, -1]\n    assert candidate(queries = [100000000, 100000001, 100000002],intLength = 13) == [-1, -1, -1]\n    assert candidate(queries = [500000000, 600000000, 700000000],intLength = 9) == [-1, -1, -1]\n    assert candidate(queries = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50],intLength = 14) == [10000000000001, 10000044000001, 10000099000001, 10000144100001, 10000199100001, 10000244200001, 10000299200001, 10000344300001, 10000399300001, 10000444400001, 10000499400001]\n    assert candidate(queries = [100000, 200000, 300000],intLength = 11) == [19999999991, 29999999992, 39999999993]\n    assert candidate(queries = [10000, 20000, 30000, 40000, 50000],intLength = 13) == [1009999999001, 1019999999101, 1029999999201, 1039999999301, 1049999999401]\n    assert candidate(queries = [500000, 600000, 700000, 800000],intLength = 13) == [1499999999941, 1599999999951, 1699999999961, 1799999999971]\n    assert candidate(queries = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000],intLength = 6) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(queries = [10000, 10001, 10002, 10003, 10004],intLength = 6) == [-1, -1, -1, -1, -1]\n    assert candidate(queries = [5000, 6000, 7000, 8000, 9000, 10000],intLength = 11) == [10499999401, 10599999501, 10699999601, 10799999701, 10899999801, 10999999901]\n    assert candidate(queries = [999999999],intLength = 15) == [-1]\n    assert candidate(queries = [1000, 2000, 3000, 4000, 5000],intLength = 6) == [-1, -1, -1, -1, -1]\n    assert candidate(queries = [1, 5, 10, 15, 20, 25, 30],intLength = 5) == [10001, 10401, 10901, 11411, 11911, 12421, 12921]\n    assert candidate(queries = [100000, 100001, 100002],intLength = 11) == [19999999991, 20000000002, 20000100002]\n    assert candidate(queries = [1000, 2000, 3000, 4000, 5000],intLength = 5) == [-1, -1, -1, -1, -1]\n    assert candidate(queries = [50000, 150000, 250000],intLength = 11) == [14999999941, 24999999942, 34999999943]\n    assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],intLength = 2) == [11, 22, 33, 44, 55, 66, 77, 88, 99, -1, -1, -1, -1, -1, -1]\n    assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],intLength = 4) == [1001, 1111, 1221, 1331, 1441, 1551, 1661, 1771, 1881, 1991, 2002, 2112, 2222, 2332, 2442, 2552, 2662, 2772, 2882, 2992]\n    assert candidate(queries = [1, 50000000, 100000000],intLength = 15) == [100000000000001, 599999999999995, -1]\n    assert candidate(queries = [5000000, 6000000, 7000000],intLength = 11) == [-1, -1, -1]\n    assert candidate(queries = [10, 20, 30, 40, 50],intLength = 5) == [10901, 11911, 12921, 13931, 14941]\n    assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],intLength = 14) == [10000000000001, 10000011000001, 10000022000001, 10000033000001, 10000044000001, 10000055000001, 10000066000001, 10000077000001, 10000088000001, 10000099000001]\n    assert candidate(queries = [100000, 99999, 88888],intLength = 15) == [100999999999001, 100999989999001, 100888878888001]\n    assert candidate(queries = [999999, 999998, 999997],intLength = 7) == [-1, -1, -1]\n    assert candidate(queries = [123456, 654321, 111111],intLength = 9) == [-1, -1, -1]\n    assert candidate(queries = [1, 2, 3, 4, 5, 1000000, 2000000, 3000000, 4000000, 5000000],intLength = 7) == [1000001, 1001001, 1002001, 1003001, 1004001, -1, -1, -1, -1, -1]\n    assert candidate(queries = [1000000, 2000000, 3000000, 4000000, 5000000],intLength = 15) == [109999999999901, 119999999999911, 129999999999921, 139999999999931, 149999999999941]\n    assert candidate(queries = [12345, 67890, 111111, 222222, 333333],intLength = 7) == [-1, -1, -1, -1, -1]\n    assert candidate(queries = [1, 100000000, 50000000, 25000000, 75000000, 90000000, 100000000, 85000000, 65000000, 45000000],intLength = 8) == [10000001, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(queries = [100, 200, 300, 400, 500],intLength = 15) == [100000999000001, 100001999100001, 100002999200001, 100003999300001, 100004999400001]\n    assert candidate(queries = [10000, 20000, 30000],intLength = 7) == [-1, -1, -1]\n    assert candidate(queries = [1, 123456, 987654, 1000000],intLength = 5) == [10001, -1, -1, -1]\n    assert candidate(queries = [10000, 20000, 30000, 40000, 50000],intLength = 8) == [-1, -1, -1, -1, -1]\n    assert candidate(queries = [1000, 2000, 3000, 4000, 5000],intLength = 11) == [10099999001, 10199999101, 10299999201, 10399999301, 10499999401]\n    assert candidate(queries = [1, 10, 100, 1000, 10000, 100000],intLength = 11) == [10000000001, 10000900001, 10009990001, 10099999001, 10999999901, 19999999991]\n    assert candidate(queries = [5000, 10000, 15000, 20000],intLength = 10) == [1499999941, 1999999991, 2499999942, 2999999992]\n    assert candidate(queries = [999999, 888888, 777777, 666666, 555555],intLength = 10) == [-1, -1, -1, -1, -1]\n    assert candidate(queries = [1, 1000000, 9999999, 10000000],intLength = 13) == [1000000000001, 1999999999991, -1, -1]\n    assert candidate(queries = [98765, 43210, 11111, 22222, 33333],intLength = 11) == [19876467891, 14320902341, 11111011111, 12222122221, 13333233331]\n    assert candidate(queries = [500000, 600000, 700000],intLength = 13) == [1499999999941, 1599999999951, 1699999999961]\n    assert candidate(queries = [987654321],intLength = 15) == [-1]\n    assert candidate(queries = [123456789],intLength = 9) == [-1]\n    assert candidate(queries = [123456789, 987654321, 500000000, 300000000, 200000000],intLength = 15) == [-1, -1, -1, -1, -1]\n    assert candidate(queries = [123, 456, 789],intLength = 10) == [1012222101, 1045555401, 1078888701]\n    assert candidate(queries = [100000, 200000, 300000],intLength = 9) == [-1, -1, -1]\n    assert candidate(queries = [100000000],intLength = 15) == [-1]\n    assert candidate(queries = [999999999, 999999998, 999999997, 999999996, 999999995],intLength = 15) == [-1, -1, -1, -1, -1]\n    assert candidate(queries = [1, 999999999],intLength = 15) == [100000000000001, -1]\n    assert candidate(queries = [100000, 1000000, 10000000, 100000000, 1000000000],intLength = 11) == [19999999991, -1, -1, -1, -1]\n    assert candidate(queries = [5000, 10000, 15000, 20000],intLength = 7) == [5999995, -1, -1, -1]\n    assert candidate(queries = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],intLength = 9) == [100000001, 100090001, 100999001, 109999901, 199999991, -1, -1, -1, -1, -1]\n    assert candidate(queries = [500, 1000, 1500, 2000, 2500, 3000],intLength = 7) == [1499941, 1999991, 2499942, 2999992, 3499943, 3999993]\n    assert candidate(queries = [1000000000],intLength = 9) == [-1]\n    assert candidate(queries = [10000, 20000, 30000, 40000],intLength = 11) == [10999999901, 11999999911, 12999999921, 13999999931]\n    assert candidate(queries = [987654, 987655, 987656, 987657, 987658],intLength = 13) == [1987653567891, 1987654567891, 1987655567891, 1987656567891, 1987657567891]\n    assert candidate(queries = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95],intLength = 3) == [101, 141, 191, 242, 292, 343, 393, 444, 494, 545, 595, 646, 696, 747, 797, 848, 898, 949, 999, -1]\n    assert candidate(queries = [123456789, 987654321, 567891234],intLength = 15) == [-1, -1, -1]\n    assert candidate(queries = [1, 123456789, 987654321, 500000000],intLength = 9) == [100000001, -1, -1, -1]\n    assert candidate(queries = [1000000, 1000001, 1000002, 1000003, 1000004],intLength = 13) == [1999999999991, 2000000000002, 2000001000002, 2000002000002, 2000003000002]\n    assert candidate(queries = [5000, 10000, 15000, 20000],intLength = 9) == [149999941, 199999991, 249999942, 299999992]\n    assert candidate(queries = [100000000, 99999999, 88888888, 77777777],intLength = 13) == [-1, -1, -1, -1]\n    assert candidate(queries = [123456789],intLength = 10) == [-1]\n    assert candidate(queries = [100000000, 99999999, 99999998, 99999997, 99999996],intLength = 2) == [-1, -1, -1, -1, -1]\n    assert candidate(queries = [1000000, 1000001, 1000002],intLength = 15) == [109999999999901, 110000000000011, 110000010000011]\n    assert candidate(queries = [999999, 999998, 999997, 999996, 999995],intLength = 6) == [-1, -1, -1, -1, -1]\n    assert candidate(queries = [100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1],intLength = 11) == [-1, -1, -1, 19999999991, 10999999901, 10099999001, 10009990001, 10000900001, 10000000001]\n    assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],intLength = 2) == [11, 22, 33, 44, 55, 66, 77, 88, 99, -1]\n    assert candidate(queries = [1, 10, 100, 1000, 10000, 100000],intLength = 14) == [10000000000001, 10000099000001, 10000999900001, 10009999990001, 10099999999001, 10999999999901]\n    assert candidate(queries = [987654321, 123456789],intLength = 8) == [-1, -1]\n    assert candidate(queries = [10000000, 10000001, 10000002, 10000003, 10000004],intLength = 7) == [-1, -1, -1, -1, -1]\n    assert candidate(queries = [500000, 500001, 500002, 500003, 500004],intLength = 13) == [1499999999941, 1500000000051, 1500001000051, 1500002000051, 1500003000051]\n    assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 1000, 10000, 100000, 1000000],intLength = 5) == [10001, 10101, 10201, 10301, 10401, 10501, 10601, 10701, 10801, 10901, 19991, -1, -1, -1, -1]\n    assert candidate(queries = [99999999, 100000000, 100000001],intLength = 9) == [-1, -1, -1]\n    assert candidate(queries = [500000, 500001, 500002, 500003, 500004, 500005],intLength = 13) == [1499999999941, 1500000000051, 1500001000051, 1500002000051, 1500003000051, 1500004000051]\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5,90]\n3", "[2,4,6]\n4"], "hints": ["For any value of queries[i] and intLength, how can you check if there exists at least queries[i] palindromes of length intLength?", "Since a palindrome reads the same forwards and backwards, consider how you can efficiently find the first half (ceil(intLength/2) digits) of the palindrome."], "metadata": {"canonical_parameter_names": ["queries", "intLength"], "leetcode_dataset_entry_point": "Solution().kthPalindrome", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:18+00:00", "tests_total": 110, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "math"]}, "language": "python", "interface": {"raw_signature": "def kthPalindrome(self, queries: list[int], intLength: int) -> list[int]:", "container": "Solution", "callable": "kthPalindrome", "parameters": [{"name": "queries", "type": "list[int]"}, {"name": "intLength", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2218, "task_id": "maximum-value-of-k-coins-from-piles", "difficulty": "Hard", "problem_description": "There are n piles of coins on a table. Each pile consists of a positive number of coins of assorted denominations.\n\nIn one move, you can choose any coin on top of any pile, remove it, and add it to your wallet.\n\nGiven a list piles, where piles[i] is a list of integers denoting the composition of the i^th pile from top to bottom, and a positive integer k, return the maximum total value of coins you can have in your wallet if you choose exactly k coins optimally.\n\nExample 1:\n\nInput: piles = [[1,100,3],[7,8,9]], k = 2\nOutput: 101\nExplanation:\nThe above diagram shows the different ways we can choose k coins.\nThe maximum total we can obtain is 101.\n\nExample 2:\n\nInput: piles = [[100],[100],[100],[100],[100],[100],[1,1,1,1,1,1,700]], k = 7\nOutput: 706\nExplanation:\nThe maximum total can be obtained if we choose all coins from the last pile.\n\nConstraints:\n\n- n == piles.length\n- 1 <= n <= 1000\n- 1 <= piles[i][j] <= 10^5\n- 1 <= k <= sum(piles[i].length) <= 2000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(piles = [[30, 10], [50, 20, 10]],k = 3) == 100\n    assert candidate(piles = [[1, 2], [3, 4], [5, 6]],k = 5) == 19\n    assert candidate(piles = [[10, 20], [5, 5, 5, 5], [1, 1, 1, 1, 1]],k = 5) == 45\n    assert candidate(piles = [[1, 2, 3], [4, 5, 6]],k = 3) == 15\n    assert candidate(piles = [[30, 10, 20], [10, 20, 30], [5, 5, 5]],k = 5) == 100\n    assert candidate(piles = [[1], [2], [3], [4], [5]],k = 3) == 12\n    assert candidate(piles = [[10]],k = 1) == 10\n    assert candidate(piles = [[10, 20, 30], [30, 20, 10], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 10) == 124\n    assert candidate(piles = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 5) == 33\n    assert candidate(piles = [[1, 100, 3], [7, 8, 9]],k = 2) == 101\n    assert candidate(piles = [[100], [100], [100], [100], [100], [100], [1, 1, 1, 1, 1, 1, 700]],k = 7) == 706\n    assert candidate(piles = [[3, 1, 5], [1, 2, 3], [4, 6]],k = 3) == 13\n    assert candidate(piles = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]],k = 4) == 16\n    assert candidate(piles = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],k = 10) == 55\n    assert candidate(piles = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]],k = 25) == 55\n    assert candidate(piles = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],k = 10) == 55\n    assert candidate(piles = [[1, 3, 5, 7, 9], [2, 4, 6, 8], [10, 20, 30, 40, 50, 60]],k = 12) == 237\n    assert candidate(piles = [[10000, 20000, 30000, 40000, 50000], [10000, 20000, 30000, 40000, 50000], [10000, 20000, 30000, 40000, 50000]],k = 10) == 300000\n    assert candidate(piles = [[100, 90, 80], [70, 60, 50, 40], [30, 20, 10]],k = 7) == 490\n    assert candidate(piles = [[1, 100, 3, 50], [7, 8, 9, 100], [1, 2, 3, 4, 5]],k = 7) == 228\n    assert candidate(piles = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]],k = 10) == 550\n    assert candidate(piles = [[5, 1, 2, 3], [4, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 8) == 100\n    assert candidate(piles = [[100, 200, 300, 400], [500, 600, 700, 800], [900, 1000, 1100, 1200], [1300, 1400, 1500, 1600]],k = 8) == 10000\n    assert candidate(piles = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [8, 8, 8, 8, 8, 8, 8, 8, 8, 8], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]],k = 50) == 400\n    assert candidate(piles = [[1000, 900, 800], [700, 600, 500], [400, 300, 200], [100, 90, 80], [70, 60, 50], [40, 30, 20], [10, 9, 8], [7, 6, 5]],k = 20) == 5959\n    assert candidate(piles = [[1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1]],k = 10) == 10\n    assert candidate(piles = [[1000, 2000, 3000], [1000, 1000, 1000, 1000], [500, 500, 500, 500, 500, 500], [200, 200, 200]],k = 10) == 11500\n    assert candidate(piles = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]],k = 15) == 40\n    assert candidate(piles = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]],k = 20) == 210\n    assert candidate(piles = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4]],k = 10) == 35\n    assert candidate(piles = [[10, 20], [30, 40, 50, 60], [70, 80, 90], [100]],k = 7) == 460\n    assert candidate(piles = [[10, 15, 20], [25, 30, 35], [40, 45, 50], [5, 10, 15], [1, 2, 3]],k = 12) == 300\n    assert candidate(piles = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]],k = 15) == 195\n    assert candidate(piles = [[99999, 99998, 99997, 99996, 99995], [99994, 99993, 99992, 99991, 99990], [99989, 99988, 99987, 99986, 99985], [99984, 99983, 99982, 99981, 99980]],k = 15) == 1499880\n    assert candidate(piles = [[1, 2], [3, 4, 5], [6, 7, 8, 9], [10, 11, 12, 13, 14]],k = 8) == 81\n    assert candidate(piles = [[10, 20, 30], [5, 15, 25], [1, 2, 3], [9, 18, 27]],k = 8) == 134\n    assert candidate(piles = [[1000, 500, 250, 125, 62, 31, 15, 7, 3, 1], [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]],k = 20) == 3017\n    assert candidate(piles = [[100, 90, 80, 70, 60], [50, 40, 30, 20, 10], [1, 2, 3, 4, 5]],k = 10) == 550\n    assert candidate(piles = [[10, 20, 30], [40, 50, 60, 70], [80, 90]],k = 8) == 420\n    assert candidate(piles = [[100000], [100000], [100000], [100000], [100000], [100000], [100000]],k = 7) == 700000\n    assert candidate(piles = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70]],k = 6) == 270\n    assert candidate(piles = [[5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2]],k = 15) == 59\n    assert candidate(piles = [[10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10], [10]],k = 15) == 150\n    assert candidate(piles = [[100000], [100000], [100000], [100000], [100000], [100000], [100000], [100000], [100000], [100000]],k = 5) == 500000\n    assert candidate(piles = [[1, 2, 3, 4, 5], [10, 20, 30, 40, 50], [100, 200, 300, 400, 500], [1000, 2000, 3000, 4000, 5000]],k = 10) == 16500\n    assert candidate(piles = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],k = 15) == 105\n    assert candidate(piles = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],k = 10) == 55\n    assert candidate(piles = [[1, 10, 30, 50], [10, 20, 30, 40], [5, 15, 25, 35]],k = 10) == 211\n    assert candidate(piles = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1000]],k = 10) == 1009\n    assert candidate(piles = [[10, 20, 30], [1, 2, 3, 4, 5], [100, 200], [50, 60, 70]],k = 7) == 510\n    assert candidate(piles = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [10, 9, 8, 7, 6]],k = 15) == 95\n    assert candidate(piles = [[1000, 900, 800], [700, 600], [500, 400, 300, 200, 100]],k = 12) == 5500\n    assert candidate(piles = [[1], [1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 20) == 20\n    assert candidate(piles = [[100, 100, 100], [100, 100, 100], [100, 100, 100], [100, 100, 100]],k = 8) == 800\n    assert candidate(piles = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]],k = 15) == 140\n    assert candidate(piles = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1]],k = 15) == 70\n    assert candidate(piles = [[1000, 2000, 3000], [1500, 2500, 3500], [1200, 2200, 3200]],k = 5) == 10900\n    assert candidate(piles = [[10, 20, 30, 40], [5, 15, 25], [100], [50, 75]],k = 6) == 285\n    assert candidate(piles = [[1, 1000, 2000], [3000, 4000, 5000], [6000, 7000, 8000], [9000, 10000, 11000]],k = 6) == 51000\n    assert candidate(piles = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]],k = 25) == 135\n    assert candidate(piles = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]],k = 20) == 40\n    assert candidate(piles = [[10, 20, 30], [15, 25, 35, 45], [5, 10, 15, 20, 25]],k = 10) == 210\n    assert candidate(piles = [[1, 100, 3], [7, 8, 9], [4, 5, 6], [10, 20, 30], [1000, 2000, 3000]],k = 12) == 6189\n    assert candidate(piles = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]],k = 10) == 155\n    assert candidate(piles = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 15) == 320\n    assert candidate(piles = [[10, 20, 30, 40], [50, 60, 70], [80, 90, 100, 110, 120], [130, 140]],k = 10) == 950\n    assert candidate(piles = [[100], [200], [300], [400], [500], [600], [700], [800], [900], [1000]],k = 5) == 4000\n    assert candidate(piles = [[50], [20], [10], [5]],k = 3) == 80\n    assert candidate(piles = [[9, 7, 5, 3, 1], [8, 6, 4, 2], [10, 20, 30], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 15) == 108\n    assert candidate(piles = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 4, 6, 8, 10], [10, 8, 6, 4, 2]],k = 15) == 78\n    assert candidate(piles = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [2, 12, 22, 32, 42]],k = 10) == 275\n    assert candidate(piles = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]],k = 20) == 210\n    assert candidate(piles = [[1000, 2000], [100, 200, 300, 400, 500], [50]],k = 8) == 4550\n    assert candidate(piles = [[5, 10, 15], [20, 25, 30, 35, 40], [1, 1, 1, 1, 1, 1, 1], [99, 98, 97, 96]],k = 10) == 545\n    assert candidate(piles = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1000]],k = 20) == 1038\n    assert candidate(piles = [[10, 20, 30, 40, 50], [5, 10, 15, 20, 25], [1, 2, 3, 4, 5], [100, 200, 300, 400, 500]],k = 10) == 1650\n    assert candidate(piles = [[1000, 2000, 3000], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [500, 600, 700, 800, 900], [10, 20, 30, 40, 50]],k = 15) == 9653\n    assert candidate(piles = [[1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18]],k = 12) == 147\n    assert candidate(piles = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1]],k = 10) == 300\n    assert candidate(piles = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]],k = 14) == 105\n    assert candidate(piles = [[5, 4, 3, 2, 1], [10, 9, 8, 7, 6], [15, 14, 13, 12, 11]],k = 15) == 120\n    assert candidate(piles = [[100, 200, 300], [400, 500, 600], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],k = 15) == 2145\n    assert candidate(piles = [[100, 200, 300], [50, 60, 70, 80], [10, 20, 30, 40, 50]],k = 15) == 1010\n    assert candidate(piles = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]],k = 18) == 90\n    assert candidate(piles = [[5, 1, 2], [3, 10, 1], [4, 4, 4], [2, 8, 6]],k = 6) == 34\n    assert candidate(piles = [[1, 100, 3], [7, 8, 9], [5, 6, 7], [4, 5, 6]],k = 10) == 152\n    assert candidate(piles = [[1, 1, 1, 1, 1], [2, 2, 2], [3, 3], [4], [5, 5, 5, 5]],k = 10) == 36\n    assert candidate(piles = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13], [6, 8, 10, 12, 14], [7, 9, 11, 13, 15], [8, 10, 12, 14, 16], [9, 11, 13, 15, 17], [10, 12, 14, 16, 18]],k = 25) == 300\n    assert candidate(piles = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 15) == 95\n    assert candidate(piles = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],k = 15) == 120\n    assert candidate(piles = [[10, 20, 30], [5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 8) == 81\n    assert candidate(piles = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]],k = 8) == 100\n    assert candidate(piles = [[100, 200], [50, 150, 250], [200, 300, 400, 500], [300, 400, 500, 600, 700]],k = 15) == 4650\n    assert candidate(piles = [[1, 2], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23]],k = 12) == 201\n", "comparison": "exact"}, "public_tests": ["[[1,100,3],[7,8,9]]\n2", "[[100],[100],[100],[100],[100],[100],[1,1,1,1,1,1,700]]\n7"], "hints": ["For each pile i, what will be the total value of coins we can collect if we choose the first j coins?", "How can we use dynamic programming to combine the results from different piles to find the most optimal answer?"], "metadata": {"canonical_parameter_names": ["piles", "k"], "leetcode_dataset_entry_point": "Solution().maxValueOfCoins", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:20+00:00", "tests_total": 96, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maxValueOfCoins(self, piles: list[list[int]], k: int) -> int:", "container": "Solution", "callable": "maxValueOfCoins", "parameters": [{"name": "piles", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2220, "task_id": "minimum-bit-flips-to-convert-number", "difficulty": "Easy", "problem_description": "A bit flip of a number x is choosing a bit in the binary representation of x and flipping it from either 0 to 1 or 1 to 0.\n\n- For example, for x = 7, the binary representation is 111 and we may choose any bit (including any leading zeros not shown) and flip it. We can flip the first bit from the right to get 110, flip the second bit from the right to get 101, flip the fifth bit from the right (a leading zero) to get 10111, etc.\n\nGiven two integers start and goal, return the minimum number of bit flips to convert start to goal.\n\nExample 1:\n\nInput: start = 10, goal = 7\nOutput: 3\nExplanation: The binary representation of 10 and 7 are 1010 and 0111 respectively. We can convert 10 to 7 in 3 steps:\n- Flip the first bit from the right: 1010 -> 1011.\n- Flip the third bit from the right: 1011 -> 1111.\n- Flip the fourth bit from the right: 1111 -> 0111.\nIt can be shown we cannot convert 10 to 7 in less than 3 steps. Hence, we return 3.\n\nExample 2:\n\nInput: start = 3, goal = 4\nOutput: 3\nExplanation: The binary representation of 3 and 4 are 011 and 100 respectively. We can convert 3 to 4 in 3 steps:\n- Flip the first bit from the right: 011 -> 010.\n- Flip the second bit from the right: 010 -> 000.\n- Flip the third bit from the right: 000 -> 100.\nIt can be shown we cannot convert 3 to 4 in less than 3 steps. Hence, we return 3.\n\nConstraints:\n\n- 0 <= start, goal <= 10^9\n\nNote: This question is the same as 461: Hamming Distance.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(start = 123456789,goal = 987654321) == 15\n    assert candidate(start = 5,goal = 2) == 3\n    assert candidate(start = 1000000000,goal = 500000000) == 14\n    assert candidate(start = 8,goal = 15) == 3\n    assert candidate(start = 15,goal = 8) == 3\n    assert candidate(start = 5,goal = 8) == 3\n    assert candidate(start = 1000000000,goal = 999999999) == 10\n    assert candidate(start = 1023,goal = 0) == 10\n    assert candidate(start = 3,goal = 4) == 3\n    assert candidate(start = 29,goal = 15) == 2\n    assert candidate(start = 10,goal = 7) == 3\n    assert candidate(start = 54321,goal = 12345) == 5\n    assert candidate(start = 1023,goal = 512) == 9\n    assert candidate(start = 512,goal = 256) == 2\n    assert candidate(start = 0,goal = 0) == 0\n    assert candidate(start = 255,goal = 0) == 8\n    assert candidate(start = 15,goal = 0) == 4\n    assert candidate(start = 1,goal = 1) == 0\n    assert candidate(start = 1,goal = 1023) == 9\n    assert candidate(start = 5,goal = 10) == 4\n    assert candidate(start = 111111111,goal = 999999999) == 13\n    assert candidate(start = 101010101,goal = 111111111) == 10\n    assert candidate(start = 987654321,goal = 123456789) == 15\n    assert candidate(start = 1000000000,goal = 0) == 13\n    assert candidate(start = 888888888,goal = 111111111) == 18\n    assert candidate(start = 67890,goal = 54321) == 9\n    assert candidate(start = 536870912,goal = 858993459) == 15\n    assert candidate(start = 1048575,goal = 2097151) == 1\n    assert candidate(start = 987654321,goal = 876543219) == 11\n    assert candidate(start = 123,goal = 321) == 5\n    assert candidate(start = 1000000000,goal = 1) == 14\n    assert candidate(start = 999999999,goal = 111111111) == 13\n    assert candidate(start = 999999999,goal = 999999998) == 1\n    assert candidate(start = 293847,goal = 987654) == 11\n    assert candidate(start = 111111111,goal = 222222222) == 14\n    assert candidate(start = 1001001,goal = 1100110) == 15\n    assert candidate(start = 123456789,goal = 123456788) == 1\n    assert candidate(start = 500000000,goal = 500000001) == 1\n    assert candidate(start = 33554431,goal = 67108864) == 26\n    assert candidate(start = 8388607,goal = 8388608) == 24\n    assert candidate(start = 13579,goal = 24680) == 8\n    assert candidate(start = 134217727,goal = 268435455) == 1\n    assert candidate(start = 54321,goal = 100000) == 7\n    assert candidate(start = 16777215,goal = 8388608) == 23\n    assert candidate(start = 86420,goal = 13579) == 10\n    assert candidate(start = 1,goal = 1000000000) == 14\n    assert candidate(start = 0,goal = 1000000000) == 13\n    assert candidate(start = 789012345,goal = 543210987) == 16\n    assert candidate(start = 123456789,goal = 987654322) == 17\n    assert candidate(start = 134217728,goal = 268435455) == 27\n    assert candidate(start = 536870912,goal = 268435456) == 2\n    assert candidate(start = 54321,goal = 65432) == 8\n    assert candidate(start = 268435455,goal = 67108863) == 2\n    assert candidate(start = 999999999,goal = 888888888) == 17\n    assert candidate(start = 135792468,goal = 246813579) == 16\n    assert candidate(start = 8675309,goal = 5309867) == 12\n    assert candidate(start = 999999999,goal = 1) == 20\n    assert candidate(start = 1048575,goal = 1) == 19\n    assert candidate(start = 100000000,goal = 1) == 13\n    assert candidate(start = 134217728,goal = 134217729) == 1\n    assert candidate(start = 67890,goal = 98765) == 10\n    assert candidate(start = 1234,goal = 5678) == 8\n    assert candidate(start = 67890,goal = 12345) == 8\n    assert candidate(start = 123456,goal = 654321) == 8\n    assert candidate(start = 65535,goal = 32768) == 15\n    assert candidate(start = 555555555,goal = 444444444) == 20\n", "comparison": "exact"}, "public_tests": ["10\n7", "3\n4"], "hints": ["If the value of a bit in start and goal differ, then we need to flip that bit.", "Consider using the XOR operation to determine which bits need a bit flip."], "metadata": {"canonical_parameter_names": ["start", "goal"], "leetcode_dataset_entry_point": "Solution().minBitFlips", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:25+00:00", "tests_total": 85, "tests_dropped": 19, "flags": [], "topic_tags": ["bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def minBitFlips(self, start: int, goal: int) -> int:", "container": "Solution", "callable": "minBitFlips", "parameters": [{"name": "start", "type": "int"}, {"name": "goal", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2221, "task_id": "find-triangular-sum-of-an-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums, where nums[i] is a digit between 0 and 9 (inclusive).\n\nThe triangular sum of nums is the value of the only element present in nums after the following process terminates:\n\n1. Let nums comprise of n elements. If n == 1, end the process. Otherwise, create a new 0-indexed integer array newNums of length n - 1.\n2. For each index i, where 0 <= i < n - 1, assign the value of newNums[i] as (nums[i] + nums[i+1]) % 10, where % denotes modulo operator.\n3. Replace the array nums with newNums.\n4. Repeat the entire process starting from step 1.\n\nReturn the triangular sum of nums.\n\nExample 1:\n\nInput: nums = [1,2,3,4,5]\nOutput: 8\nExplanation:\nThe above diagram depicts the process from which we obtain the triangular sum of the array.\n\nExample 2:\n\nInput: nums = [5]\nOutput: 5\nExplanation:\nSince there is only one element in nums, the triangular sum is the value of that element itself.\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 0 <= nums[i] <= 9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 6\n    assert candidate(nums = [4, 3, 2, 1]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n    assert candidate(nums = [1, 2]) == 3\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n    assert candidate(nums = [0]) == 0\n    assert candidate(nums = [1, 0, 1, 0, 1, 0]) == 6\n    assert candidate(nums = [5]) == 5\n    assert candidate(nums = [1, 0, 1, 0, 1]) == 8\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 6\n    assert candidate(nums = [9, 9, 9, 9, 9]) == 4\n    assert candidate(nums = [0, 0, 0, 0]) == 0\n    assert candidate(nums = [6, 7, 3, 5, 9, 4, 2, 8, 1, 0]) == 0\n    assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 8\n    assert candidate(nums = [9, 9, 9, 9]) == 2\n    assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 2\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 6\n    assert candidate(nums = [6, 3, 8, 1, 7, 4, 9, 2, 5, 0, 6, 3, 8, 1, 7, 4, 9, 2, 5, 0]) == 6\n    assert candidate(nums = [8, 6, 7, 5, 3, 0, 9, 1, 2, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == 2\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9]) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]) == 6\n    assert candidate(nums = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1]) == 6\n    assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 2\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 8\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [8, 1, 9, 1, 8, 1, 9, 1, 8, 1, 9, 1, 8, 1, 9, 1, 8, 1, 9, 1]) == 4\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0]) == 4\n    assert candidate(nums = [7, 1, 5, 9, 2, 6, 5, 3, 5, 7]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 4\n    assert candidate(nums = [0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8]) == 2\n    assert candidate(nums = [7, 3, 1, 4, 6, 2, 9, 0, 5]) == 2\n    assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 8\n    assert candidate(nums = [7, 3, 5, 1, 9, 8, 7, 6, 4, 2, 0]) == 8\n    assert candidate(nums = [7, 1, 3, 5, 2, 8, 6, 4, 9, 0, 7, 1, 3, 5, 2, 8, 6, 4, 9, 0]) == 7\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n    assert candidate(nums = [3, 6, 9, 2, 5, 8, 1, 4, 7, 0]) == 8\n    assert candidate(nums = [6, 2, 8, 4, 0, 1, 3, 5, 7, 9]) == 8\n    assert candidate(nums = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == 2\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n    assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == 4\n    assert candidate(nums = [3, 6, 9, 2, 5, 8, 1, 4, 7, 0, 3, 6, 9, 2, 5, 8, 1, 4, 7, 0]) == 2\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6]) == 5\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 0\n    assert candidate(nums = [8, 1, 4, 1, 8, 1, 4, 1, 8, 1, 4]) == 4\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 6\n    assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 8\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n    assert candidate(nums = [9, 2, 3, 4, 5, 6, 7, 8, 1, 0, 9, 2, 3, 4, 5, 6, 7, 8, 1, 0]) == 8\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 6, 7, 9]) == 8\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 6\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2]) == 2\n    assert candidate(nums = [6, 2, 9, 5, 4, 8, 7, 1, 3, 6, 2, 9, 5, 4, 8, 7, 1, 3, 6, 2]) == 8\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 4\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 6\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1]) == 6\n    assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == 4\n    assert candidate(nums = [5, 3, 8, 9, 1, 4, 6, 7]) == 7\n    assert candidate(nums = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9]) == 0\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 6\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 4\n    assert candidate(nums = [8, 6, 4, 2, 0, 9, 7, 5, 3, 1, 8, 6, 4, 2, 0, 9, 7, 5, 3, 1]) == 6\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 6\n    assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9]) == 0\n    assert candidate(nums = [7, 3, 5, 2, 8, 6, 4, 9, 1, 0, 7, 3, 5, 2, 8, 6, 4, 9, 1, 0]) == 5\n    assert candidate(nums = [7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0]) == 8\n    assert candidate(nums = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n    assert candidate(nums = [6, 2, 8, 4, 0, 1, 5, 9, 3, 7]) == 2\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2]) == 8\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 0\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 6\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 5\n    assert candidate(nums = [0, 9, 0, 9, 0, 9, 0, 9, 0, 9]) == 4\n    assert candidate(nums = [1, 0, 9, 0, 8, 0, 7, 0, 6, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1, 0]) == 7\n    assert candidate(nums = [7, 3, 1, 2, 5, 8, 6, 4, 9, 0]) == 5\n    assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [7, 1, 9, 3, 7, 1, 9, 3, 7, 1, 9, 3, 7, 1, 9, 3, 7, 1, 9, 3]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 4\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 6\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9]) == 0\n    assert candidate(nums = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 4\n    assert candidate(nums = [2, 7, 1, 8, 2, 8, 1, 8, 2, 8, 4, 5, 9, 0, 4, 5, 2, 3, 5, 3]) == 3\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 4\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5]", "[5]"], "hints": ["Try simulating the entire process.", "To reduce space, use a temporary array to update nums in every step instead of creating a new array at each step."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().triangularSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:27+00:00", "tests_total": 96, "tests_dropped": 4, "flags": ["has_images"], "topic_tags": ["array", "math", "simulation", "combinatorics", "number-theory"]}, "language": "python", "interface": {"raw_signature": "def triangularSum(self, nums: list[int]) -> int:", "container": "Solution", "callable": "triangularSum", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2222, "task_id": "number-of-ways-to-select-buildings", "difficulty": "Medium", "problem_description": "You are given a 0-indexed binary string s which represents the types of buildings along a street where:\n\n- s[i] = '0' denotes that the i^th building is an office and\n- s[i] = '1' denotes that the i^th building is a restaurant.\n\nAs a city official, you would like to select 3 buildings for random inspection. However, to ensure variety, no two consecutive buildings out of the selected buildings can be of the same type.\n\n- For example, given s = \"001101\", we cannot select the 1^st, 3^rd, and 5^th buildings as that would form \"011\" which is not allowed due to having two consecutive buildings of the same type.\n\nReturn the number of valid ways to select 3 buildings.\n\nExample 1:\n\nInput: s = \"001101\"\nOutput: 6\nExplanation:\nThe following sets of indices selected are valid:\n- [0,2,4] from \"001101\" forms \"010\"\n- [0,3,4] from \"001101\" forms \"010\"\n- [1,2,4] from \"001101\" forms \"010\"\n- [1,3,4] from \"001101\" forms \"010\"\n- [2,4,5] from \"001101\" forms \"101\"\n- [3,4,5] from \"001101\" forms \"101\"\nNo other selection is valid. Thus, there are 6 total ways.\n\nExample 2:\n\nInput: s = \"11100\"\nOutput: 0\nExplanation: It can be shown that there are no valid selections.\n\nConstraints:\n\n- 3 <= s.length <= 10^5\n- s[i] is either '0' or '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"100100100\") == 24\n    assert candidate(s = \"101010101\") == 30\n    assert candidate(s = \"000111000\") == 27\n    assert candidate(s = \"111\") == 0\n    assert candidate(s = \"0000000001\") == 0\n    assert candidate(s = \"01010\") == 5\n    assert candidate(s = \"010101010\") == 30\n    assert candidate(s = \"1001001\") == 12\n    assert candidate(s = \"011001100\") == 28\n    assert candidate(s = \"101101101\") == 27\n    assert candidate(s = \"10101\") == 5\n    assert candidate(s = \"1111111110\") == 0\n    assert candidate(s = \"1010101010101010101\") == 285\n    assert candidate(s = \"001001001\") == 24\n    assert candidate(s = \"001101\") == 6\n    assert candidate(s = \"1001001001\") == 36\n    assert candidate(s = \"11111\") == 0\n    assert candidate(s = \"0011001100\") == 40\n    assert candidate(s = \"000\") == 0\n    assert candidate(s = \"010101\") == 8\n    assert candidate(s = \"1100110011\") == 40\n    assert candidate(s = \"101010\") == 8\n    assert candidate(s = \"11100\") == 0\n    assert candidate(s = \"0101010101\") == 40\n    assert candidate(s = \"00000\") == 0\n    assert candidate(s = \"0110110\") == 12\n    assert candidate(s = \"110011001\") == 28\n    assert candidate(s = \"010101001010101010\") == 240\n    assert candidate(s = \"101010101010101010\") == 240\n    assert candidate(s = \"000111000111000111000\") == 378\n    assert candidate(s = \"101010101010101\") == 140\n    assert candidate(s = \"010101010101010101010101010101010101\") == 1938\n    assert candidate(s = \"111111111111111111111111111111111111111111111111\") == 0\n    assert candidate(s = \"001001001001001001001001001001001001001001001001\") == 4080\n    assert candidate(s = \"00000000000000000000000000000000\") == 0\n    assert candidate(s = \"100001000010000100001\") == 240\n    assert candidate(s = \"10101010101010101010101010\") == 728\n    assert candidate(s = \"1010101010101010101010101010101\") == 1240\n    assert candidate(s = \"111000111000111\") == 135\n    assert candidate(s = \"110011001100110011001\") == 380\n    assert candidate(s = \"000111000111000111\") == 216\n    assert candidate(s = \"101010101010101010101010\") == 572\n    assert candidate(s = \"010010100101001010010100101001\") == 1074\n    assert candidate(s = \"101010101010101010101\") == 385\n    assert candidate(s = \"1010101010\") == 40\n    assert candidate(s = \"111111111100000000111111111\") == 720\n    assert candidate(s = \"111111111111111111111\") == 0\n    assert candidate(s = \"010101010101010101\") == 240\n    assert candidate(s = \"010010010010010010\") == 216\n    assert candidate(s = \"101010101010101010101010101\") == 819\n    assert candidate(s = \"000000000000000000000000000\") == 0\n    assert candidate(s = \"000111000111000111000111\") == 540\n    assert candidate(s = \"101010101010101010101010101010\") == 1120\n    assert candidate(s = \"110011001100\") == 64\n    assert candidate(s = \"110011001100110011\") == 240\n    assert candidate(s = \"111100001111000011110000\") == 512\n    assert candidate(s = \"10011001100110011001\") == 330\n    assert candidate(s = \"01001001001001\") == 100\n    assert candidate(s = \"0101010101010101010101010101010\") == 1240\n    assert candidate(s = \"100100100100100100\") == 210\n    assert candidate(s = \"000000000000000000000\") == 0\n    assert candidate(s = \"000111000111\") == 54\n    assert candidate(s = \"0101010101010101010101010101010101\") == 1632\n    assert candidate(s = \"000000000011111111000000000\") == 720\n    assert candidate(s = \"010101010101010101010101010\") == 819\n    assert candidate(s = \"10101010101010101010101010101010101010101010101010101010\") == 7308\n    assert candidate(s = \"111111000000111111\") == 216\n    assert candidate(s = \"111111111111111111111111111111111111111111111111111\") == 0\n    assert candidate(s = \"01010010100101001010\") == 320\n    assert candidate(s = \"1111111000000111111000000\") == 468\n    assert candidate(s = \"1001001001001001001001001001001001001001001001\") == 3600\n    assert candidate(s = \"0100100101010010010100100\") == 614\n    assert candidate(s = \"0000011111\") == 0\n    assert candidate(s = \"11111111111111111111\") == 0\n    assert candidate(s = \"1101010101010101010101010101010101\") == 1632\n    assert candidate(s = \"00000001111111100000001111111110000000\") == 2170\n    assert candidate(s = \"0011011011100101010101010\") == 633\n    assert candidate(s = \"110011001100110\") == 136\n    assert candidate(s = \"000001111110000011111\") == 300\n    assert candidate(s = \"0110110110110110110110110110110110110110110110\") == 3600\n    assert candidate(s = \"111111111111111111\") == 0\n    assert candidate(s = \"1010101010101010101010101010101010\") == 1632\n    assert candidate(s = \"10101010100000001010101010\") == 630\n    assert candidate(s = \"000000000000000000000000000000000000000000000000000\") == 0\n    assert candidate(s = \"00000000000011111111111\") == 0\n    assert candidate(s = \"00000111110000011111\") == 250\n    assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001\") == 56316\n    assert candidate(s = \"00110011001100110011001100\") == 728\n    assert candidate(s = \"01010111100001110101\") == 320\n    assert candidate(s = \"11001100110011001100\") == 320\n    assert candidate(s = \"11100011100011100011\") == 324\n    assert candidate(s = \"01010101010101010101010101010101\") == 1360\n    assert candidate(s = \"1010101010101010101010101010\") == 910\n    assert candidate(s = \"01110111011101110111\") == 240\n    assert candidate(s = \"111000111000\") == 54\n    assert candidate(s = \"10110110110110110110110110110110110\") == 1584\n    assert candidate(s = \"111111000111111000\") == 162\n    assert candidate(s = \"11111100000011111100000011111100000\") == 1620\n    assert candidate(s = \"11110000111100001111000011110000\") == 1280\n    assert candidate(s = \"010101010101\") == 70\n    assert candidate(s = \"01010101010101010101010101010101010\") == 1785\n    assert candidate(s = \"1100110011001100110011001\") == 644\n    assert candidate(s = \"11111111111111111111111111111111\") == 0\n    assert candidate(s = \"011001100110011001\") == 240\n    assert candidate(s = \"1111111111100000000000\") == 0\n    assert candidate(s = \"011011011011011011011011011\") == 720\n    assert candidate(s = \"000111000111000111000111000111000\") == 1485\n    assert candidate(s = \"101010101010010101\") == 240\n    assert candidate(s = \"0101010101010101010101010101\") == 910\n    assert candidate(s = \"01101001101001101001101001101001\") == 1360\n    assert candidate(s = \"0110011001100110011001\") == 440\n    assert candidate(s = \"111110000011111000001\") == 325\n    assert candidate(s = \"01010101011111110101010101\") == 630\n    assert candidate(s = \"000011110000111100001111\") == 512\n    assert candidate(s = \"10001000100010001000\") == 240\n    assert candidate(s = \"1001001001001001001001001001001001\") == 1452\n    assert candidate(s = \"100010001000100010001000100010001000100010001000\") == 3432\n    assert candidate(s = \"00001111000011110000111100001111\") == 1280\n    assert candidate(s = \"1110001110001110001110001110001110\") == 1620\n    assert candidate(s = \"000000000000000000000000000000000000000000000000\") == 0\n    assert candidate(s = \"00110011001100110011\") == 320\n    assert candidate(s = \"11101110111\") == 39\n    assert candidate(s = \"0000010000100001\") == 92\n    assert candidate(s = \"1010101010101\") == 91\n    assert candidate(s = \"00000000000000000000\") == 0\n    assert candidate(s = \"1111100000\") == 0\n    assert candidate(s = \"0001100011000110001100011\") == 600\n    assert candidate(s = \"1001001001001001001001001\") == 576\n    assert candidate(s = \"00011110001111000111\") == 300\n    assert candidate(s = \"001010010010100\") == 131\n    assert candidate(s = \"000000000000000000\") == 0\n    assert candidate(s = \"11010101010101010101\") == 330\n    assert candidate(s = \"01010101010101\") == 112\n    assert candidate(s = \"101010101010101010101010101010101010101010101010\") == 4600\n    assert candidate(s = \"10100101001010010100101001010010\") == 1302\n    assert candidate(s = \"110110110110110110110110110110110110110110110110\") == 4080\n    assert candidate(s = \"010101010101010101010\") == 385\n    assert candidate(s = \"1010101010101010101010\") == 440\n    assert candidate(s = \"1010101010101010101010101010101010101010\") == 2660\n    assert candidate(s = \"1111100001111000011110000\") == 560\n    assert candidate(s = \"0110110110110110110110110110110110\") == 1452\n    assert candidate(s = \"01010101010101010101010101010101010101010101\") == 3542\n    assert candidate(s = \"01101101101101101101101101101101101101101101\") == 3150\n    assert candidate(s = \"00000011111100000011111100000011111\") == 1620\n    assert candidate(s = \"01010101010101010101\") == 330\n    assert candidate(s = \"11001100110011\") == 112\n    assert candidate(s = \"000001111100000111\") == 200\n    assert candidate(s = \"1001001001001001001001001001\") == 810\n    assert candidate(s = \"00101010101010101010\") == 330\n    assert candidate(s = \"01101101101101101101\") == 294\n    assert candidate(s = \"10101010101010101010\") == 330\n    assert candidate(s = \"111110000001111100000\") == 300\n    assert candidate(s = \"111111111111111111111111111\") == 0\n    assert candidate(s = \"1101010101\") == 40\n    assert candidate(s = \"111000111000111000111000\") == 540\n    assert candidate(s = \"01110111011101110111011101110111011101110111\") == 2640\n    assert candidate(s = \"110110110110110110\") == 210\n    assert candidate(s = \"0000000000011111111111\") == 0\n    assert candidate(s = \"10101000011110101010\") == 322\n    assert candidate(s = \"000111000111000\") == 135\n    assert candidate(s = \"011110111101111011110\") == 240\n    assert candidate(s = \"000111111000111110\") == 192\n", "comparison": "exact"}, "public_tests": ["\"001101\"", "\"11100\""], "hints": ["There are only 2 valid patterns: ‘101’ and ‘010’. Think about how we can construct these 2 patterns from smaller patterns.", "Count the number of subsequences of the form ‘01’ or ‘10’ first. Let n01[i] be the number of ‘01’ subsequences that exist in the prefix of s up to the ith building. How can you compute n01[i]?", "Let n0[i] and n1[i] be the number of ‘0’s and ‘1’s that exists in the prefix of s up to i respectively. Then n01[i] = n01[i – 1] if s[i] == ‘0’, otherwise n01[i] = n01[i – 1] + n0[i – 1].", "The same logic applies to building the n10 array and subsequently the n101 and n010 arrays for the number of ‘101’ and ‘010‘ subsequences."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numberOfWays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:29+00:00", "tests_total": 162, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def numberOfWays(self, s: str) -> int:", "container": "Solution", "callable": "numberOfWays", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2223, "task_id": "sum-of-scores-of-built-strings", "difficulty": "Hard", "problem_description": "You are building a string s of length n one character at a time, prepending each new character to the front of the string. The strings are labeled from 1 to n, where the string with length i is labeled s_i.\n\n- For example, for s = \"abaca\", s_1 == \"a\", s_2 == \"ca\", s_3 == \"aca\", etc.\n\nThe score of s_i is the length of the longest common prefix between s_i and s_n (Note that s == s_n).\n\nGiven the final string s, return the sum of the score of every s_i.\n\nExample 1:\n\nInput: s = \"babab\"\nOutput: 9\nExplanation:\nFor s_1 == \"b\", the longest common prefix is \"b\" which has a score of 1.\nFor s_2 == \"ab\", there is no common prefix so the score is 0.\nFor s_3 == \"bab\", the longest common prefix is \"bab\" which has a score of 3.\nFor s_4 == \"abab\", there is no common prefix so the score is 0.\nFor s_5 == \"babab\", the longest common prefix is \"babab\" which has a score of 5.\nThe sum of the scores is 1 + 0 + 3 + 0 + 5 = 9, so we return 9.\n\nExample 2:\n\nInput: s = \"azbazbzaz\"\nOutput: 14\nExplanation:\nFor s_2 == \"az\", the longest common prefix is \"az\" which has a score of 2.\nFor s_6 == \"azbzaz\", the longest common prefix is \"azb\" which has a score of 3.\nFor s_9 == \"azbazbzaz\", the longest common prefix is \"azbazbzaz\" which has a score of 9.\nFor all other s_i, the score is 0.\nThe sum of the scores is 2 + 3 + 9 = 14, so we return 14.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"xyzxyzxyz\") == 18\n    assert candidate(s = \"abcabcabc\") == 18\n    assert candidate(s = \"aabbcc\") == 7\n    assert candidate(s = \"abacabadabacaba\") == 32\n    assert candidate(s = \"zzzzz\") == 15\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 26\n    assert candidate(s = \"abacaba\") == 12\n    assert candidate(s = \"babab\") == 9\n    assert candidate(s = \"azbazbzaz\") == 14\n    assert candidate(s = \"abcde\") == 5\n    assert candidate(s = \"zazazaz\") == 16\n    assert candidate(s = \"aaaaa\") == 15\n    assert candidate(s = \"aabbaabb\") == 14\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n    assert candidate(s = \"a\") == 1\n    assert candidate(s = \"abcdefg\") == 7\n    assert candidate(s = \"aabbccddeeff\") == 13\n    assert candidate(s = \"aaaaaaaaaabbbbbbbbbb\") == 65\n    assert candidate(s = \"abacabadabacabadabacaba\") == 60\n    assert candidate(s = \"abcdefgfedcbabcdefgfedcbabcdefgfedcbabcdefgfedcbabcdefgfedcb\") == 180\n    assert candidate(s = \"xyxyxyxyxyxyxyxy\") == 72\n    assert candidate(s = \"zxyzyxzyxzyxzyxzyxzyxzyx\") == 31\n    assert candidate(s = \"aaaabbbbccccaaaabbbbcccc\") == 48\n    assert candidate(s = \"mississippimississippimississippimississippi\") == 110\n    assert candidate(s = \"aaaaaaaaaabaaaa\") == 70\n    assert candidate(s = \"rotorrotor\") == 17\n    assert candidate(s = \"abracadabra\") == 18\n    assert candidate(s = \"abcabcabcabc\") == 30\n    assert candidate(s = \"abcabcabcabcabcd\") == 46\n    assert candidate(s = \"zzzzzzzzzzzzzzz\") == 120\n    assert candidate(s = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkiijjhhggffeeddccbbbaaa\") == 55\n    assert candidate(s = \"aaaaaaaaaabaaaaaaaaab\") == 111\n    assert candidate(s = \"abcabcabcabcabcabca\") == 70\n    assert candidate(s = \"abcabcabcabca\") == 35\n    assert candidate(s = \"abcdabcdabcd\") == 24\n    assert candidate(s = \"abacabadabacabad\") == 34\n    assert candidate(s = \"abababababababababababababababab\") == 272\n    assert candidate(s = \"aaaaabbbbccccdddd\") == 27\n    assert candidate(s = \"aaaaabbbbbccccdddd\") == 28\n    assert candidate(s = \"aaaaabbbbb\") == 20\n    assert candidate(s = \"aaaaabbbbccccddddeeeee\") == 32\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\") == 234\n    assert candidate(s = \"abcdefedcbafedcbafedcba\") == 26\n    assert candidate(s = \"mississippimississippi\") == 33\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabc\") == 273\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 630\n    assert candidate(s = \"aabbaabbaabbaabb\") == 44\n    assert candidate(s = \"bananaananabanana\") == 23\n    assert candidate(s = \"abcabcabcabcabcabcab\") == 77\n    assert candidate(s = \"abcabcabcabcabcabcabc\") == 84\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 612\n    assert candidate(s = \"qwertyuiopqwertyuiop\") == 30\n    assert candidate(s = \"aabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccdd\") == 145\n    assert candidate(s = \"abcdefghjihgfedcba\") == 19\n    assert candidate(s = \"acabacabacabacabacabacabacabacabacabacab\") == 230\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 165\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 360\n    assert candidate(s = \"abcabcabcab\") == 26\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 408\n    assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 26\n    assert candidate(s = \"abcdefedcbafedcbafedcbafedcbafedcbafedcbafedcbafedcbafedcbafedcba\") == 75\n    assert candidate(s = \"abcdeedcbaabcdeedcba\") == 32\n    assert candidate(s = \"ababababababab\") == 56\n    assert candidate(s = \"abcdeedcba\") == 11\n    assert candidate(s = \"abababababababab\") == 72\n    assert candidate(s = \"noon\") == 5\n    assert candidate(s = \"abababababab\") == 42\n    assert candidate(s = \"ababababababababab\") == 90\n    assert candidate(s = \"abcabcabcabcabcabc\") == 63\n    assert candidate(s = \"aabbccddeeffgghhii\") == 19\n    assert candidate(s = \"abcdabcdabcdabcd\") == 40\n    assert candidate(s = \"level\") == 6\n    assert candidate(s = \"levellevellevel\") == 33\n    assert candidate(s = \"abcdabcdabcdabcdabcd\") == 60\n    assert candidate(s = \"abcdefghijk\") == 11\n    assert candidate(s = \"aaaaaaaaaaa\") == 66\n    assert candidate(s = \"qwertyuiopqwertyuiopqwertyuiopqwertyuiop\") == 100\n    assert candidate(s = \"bananaananab\") == 13\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 210\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 666\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 315\n    assert candidate(s = \"banana\") == 6\n    assert candidate(s = \"zzyzxzyzxzyzxzyz\") == 24\n    assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\") == 272\n    assert candidate(s = \"zxyzyxzyxzyxzyxzyx\") == 23\n    assert candidate(s = \"abracadabraabracadabra\") == 47\n    assert candidate(s = \"abcdedcbaabcdedcba\") == 29\n    assert candidate(s = \"abcdefghij\") == 10\n    assert candidate(s = \"abcdedcbafedcbafedcbafedcbafedcba\") == 38\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 53\n    assert candidate(s = \"aabbccddeeffgghhiijj\") == 21\n    assert candidate(s = \"aabbccddeeffaabbccddeeff\") == 38\n    assert candidate(s = \"aaaaaabbccddeeffgg\") == 33\n    assert candidate(s = \"aaaaabbbbbaaaaa\") == 40\n    assert candidate(s = \"racecarracecar\") == 23\n    assert candidate(s = \"abacabadabacabadabacabad\") == 63\n    assert candidate(s = \"deified\") == 8\n    assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 525\n    assert candidate(s = \"aaaaaabbbbbccccc\") == 31\n    assert candidate(s = \"aaaaaabbbbccccdddd\") == 33\n    assert candidate(s = \"abcbaabcbaabcba\") == 33\n    assert candidate(s = \"ababababcabababa\") == 44\n    assert candidate(s = \"abcdabcdbabc\") == 19\n    assert candidate(s = \"abababababababababababab\") == 156\n    assert candidate(s = \"ababababab\") == 30\n    assert candidate(s = \"abacabadabacabadabacab\") == 55\n    assert candidate(s = \"civic\") == 6\n    assert candidate(s = \"rotor\") == 6\n    assert candidate(s = \"racecar\") == 8\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabc\") == 135\n    assert candidate(s = \"abcdefghijabcdefghij\") == 30\n    assert candidate(s = \"zazbzcbzazbzcb\") == 25\n    assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 108\n    assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == 46\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\") == 198\n    assert candidate(s = \"abcabcabcabcabcab\") == 57\n    assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 2211\n    assert candidate(s = \"abcdefabcdeabcdeabc\") == 32\n    assert candidate(s = \"mississippi\") == 11\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzz\") == 71\n    assert candidate(s = \"hellohellohellohello\") == 50\n    assert candidate(s = \"abcabcabcabcabc\") == 45\n    assert candidate(s = \"xyzzzyxyzzzyxyzzzyxyzzzy\") == 60\n", "comparison": "exact"}, "public_tests": ["\"babab\"", "\"azbazbzaz\""], "hints": ["Each s_i is a suffix of the string s, so consider algorithms that can determine the longest prefix that is also a suffix.", "Could you use the Z array from the Z algorithm to find the score of each s_i?"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().sumScores", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:32+00:00", "tests_total": 123, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "binary-search", "rolling-hash", "suffix-array", "string-matching", "hash-function", "z-algorithm", "knuth-morris-pratt-algorithm"]}, "language": "python", "interface": {"raw_signature": "def sumScores(self, s: str) -> int:", "container": "Solution", "callable": "sumScores", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2224, "task_id": "minimum-number-of-operations-to-convert-time", "difficulty": "Easy", "problem_description": "You are given two strings current and correct representing two 24-hour times.\n\n24-hour times are formatted as \"HH:MM\", where HH is between 00 and 23, and MM is between 00 and 59. The earliest 24-hour time is 00:00, and the latest is 23:59.\n\nIn one operation you can increase the time current by 1, 5, 15, or 60 minutes. You can perform this operation any number of times.\n\nReturn the minimum number of operations needed to convert current to correct.\n\nExample 1:\n\nInput: current = \"02:30\", correct = \"04:35\"\nOutput: 3\nExplanation:\nWe can convert current to correct in 3 operations as follows:\n- Add 60 minutes to current. current becomes \"03:30\".\n- Add 60 minutes to current. current becomes \"04:30\".\n- Add 5 minutes to current. current becomes \"04:35\".\nIt can be proven that it is not possible to convert current to correct in fewer than 3 operations.\n\nExample 2:\n\nInput: current = \"11:00\", correct = \"11:01\"\nOutput: 1\nExplanation: We only have to add one minute to current, so the minimum number of operations needed is 1.\n\nConstraints:\n\n- current and correct are in the format \"HH:MM\"\n- current <= correct\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(current = \"01:59\",correct = \"02:00\") == 1\n    assert candidate(current = \"00:01\",correct = \"00:02\") == 1\n    assert candidate(current = \"02:30\",correct = \"04:35\") == 3\n    assert candidate(current = \"12:00\",correct = \"13:00\") == 1\n    assert candidate(current = \"00:00\",correct = \"23:59\") == 32\n    assert candidate(current = \"23:45\",correct = \"23:59\") == 6\n    assert candidate(current = \"00:01\",correct = \"00:05\") == 4\n    assert candidate(current = \"01:15\",correct = \"01:20\") == 1\n    assert candidate(current = \"12:45\",correct = \"15:30\") == 5\n    assert candidate(current = \"23:00\",correct = \"23:15\") == 1\n    assert candidate(current = \"09:15\",correct = \"09:15\") == 0\n    assert candidate(current = \"12:34\",correct = \"12:59\") == 3\n    assert candidate(current = \"11:00\",correct = \"11:01\") == 1\n    assert candidate(current = \"18:00\",correct = \"18:14\") == 6\n    assert candidate(current = \"15:30\",correct = \"16:45\") == 2\n    assert candidate(current = \"12:45\",correct = \"12:45\") == 0\n    assert candidate(current = \"01:00\",correct = \"02:00\") == 1\n    assert candidate(current = \"21:45\",correct = \"22:00\") == 1\n    assert candidate(current = \"12:00\",correct = \"12:15\") == 1\n    assert candidate(current = \"09:40\",correct = \"10:00\") == 2\n    assert candidate(current = \"05:30\",correct = \"05:35\") == 1\n    assert candidate(current = \"01:59\",correct = \"03:00\") == 2\n    assert candidate(current = \"23:59\",correct = \"23:59\") == 0\n    assert candidate(current = \"22:45\",correct = \"23:40\") == 5\n    assert candidate(current = \"06:40\",correct = \"06:55\") == 1\n    assert candidate(current = \"09:50\",correct = \"10:10\") == 2\n    assert candidate(current = \"06:10\",correct = \"06:25\") == 1\n    assert candidate(current = \"06:30\",correct = \"07:00\") == 2\n    assert candidate(current = \"05:47\",correct = \"06:02\") == 1\n    assert candidate(current = \"09:47\",correct = \"18:23\") == 12\n    assert candidate(current = \"14:20\",correct = \"14:40\") == 2\n    assert candidate(current = \"03:33\",correct = \"04:08\") == 3\n    assert candidate(current = \"20:15\",correct = \"21:10\") == 5\n    assert candidate(current = \"08:30\",correct = \"09:40\") == 3\n    assert candidate(current = \"05:40\",correct = \"07:20\") == 5\n    assert candidate(current = \"17:45\",correct = \"19:00\") == 2\n    assert candidate(current = \"19:55\",correct = \"20:10\") == 1\n    assert candidate(current = \"14:50\",correct = \"15:05\") == 1\n    assert candidate(current = \"14:59\",correct = \"15:10\") == 3\n    assert candidate(current = \"05:55\",correct = \"06:00\") == 1\n    assert candidate(current = \"01:01\",correct = \"02:56\") == 6\n    assert candidate(current = \"08:20\",correct = \"08:35\") == 1\n    assert candidate(current = \"05:00\",correct = \"09:55\") == 9\n    assert candidate(current = \"09:30\",correct = \"20:35\") == 12\n    assert candidate(current = \"07:30\",correct = \"07:31\") == 1\n    assert candidate(current = \"01:23\",correct = \"02:18\") == 5\n    assert candidate(current = \"17:55\",correct = \"18:00\") == 1\n    assert candidate(current = \"16:50\",correct = \"18:25\") == 4\n    assert candidate(current = \"10:05\",correct = \"14:40\") == 7\n    assert candidate(current = \"01:05\",correct = \"02:10\") == 2\n    assert candidate(current = \"03:15\",correct = \"03:30\") == 1\n    assert candidate(current = \"20:30\",correct = \"22:35\") == 3\n    assert candidate(current = \"18:10\",correct = \"19:10\") == 1\n    assert candidate(current = \"03:00\",correct = \"07:15\") == 5\n    assert candidate(current = \"03:14\",correct = \"06:09\") == 7\n    assert candidate(current = \"07:45\",correct = \"08:30\") == 3\n    assert candidate(current = \"09:14\",correct = \"09:44\") == 2\n    assert candidate(current = \"01:01\",correct = \"04:04\") == 6\n    assert candidate(current = \"13:59\",correct = \"14:00\") == 1\n    assert candidate(current = \"02:22\",correct = \"02:27\") == 1\n    assert candidate(current = \"05:30\",correct = \"05:45\") == 1\n    assert candidate(current = \"11:20\",correct = \"12:55\") == 4\n    assert candidate(current = \"17:30\",correct = \"18:05\") == 3\n    assert candidate(current = \"11:59\",correct = \"12:04\") == 1\n    assert candidate(current = \"08:37\",correct = \"09:02\") == 3\n    assert candidate(current = \"16:00\",correct = \"16:16\") == 2\n    assert candidate(current = \"18:34\",correct = \"19:50\") == 3\n    assert candidate(current = \"19:10\",correct = \"21:25\") == 3\n    assert candidate(current = \"05:05\",correct = \"11:10\") == 7\n    assert candidate(current = \"13:20\",correct = \"17:50\") == 6\n    assert candidate(current = \"20:59\",correct = \"21:59\") == 1\n    assert candidate(current = \"04:30\",correct = \"06:10\") == 5\n    assert candidate(current = \"16:25\",correct = \"17:00\") == 3\n    assert candidate(current = \"08:59\",correct = \"09:00\") == 1\n    assert candidate(current = \"03:23\",correct = \"03:58\") == 3\n    assert candidate(current = \"14:45\",correct = \"20:30\") == 8\n    assert candidate(current = \"19:47\",correct = \"21:00\") == 6\n    assert candidate(current = \"00:01\",correct = \"23:59\") == 31\n    assert candidate(current = \"22:25\",correct = \"22:40\") == 1\n    assert candidate(current = \"17:30\",correct = \"20:00\") == 4\n    assert candidate(current = \"14:10\",correct = \"15:35\") == 4\n    assert candidate(current = \"00:01\",correct = \"00:06\") == 1\n    assert candidate(current = \"01:15\",correct = \"02:45\") == 3\n    assert candidate(current = \"13:47\",correct = \"18:23\") == 8\n    assert candidate(current = \"09:00\",correct = \"09:09\") == 5\n    assert candidate(current = \"06:55\",correct = \"07:10\") == 1\n    assert candidate(current = \"13:45\",correct = \"15:30\") == 4\n    assert candidate(current = \"13:45\",correct = \"15:10\") == 4\n    assert candidate(current = \"09:55\",correct = \"11:40\") == 4\n    assert candidate(current = \"20:15\",correct = \"21:25\") == 3\n    assert candidate(current = \"11:59\",correct = \"12:00\") == 1\n    assert candidate(current = \"17:31\",correct = \"20:00\") == 9\n    assert candidate(current = \"01:01\",correct = \"22:59\") == 29\n    assert candidate(current = \"12:25\",correct = \"14:15\") == 5\n    assert candidate(current = \"10:30\",correct = \"10:55\") == 3\n    assert candidate(current = \"13:25\",correct = \"13:40\") == 1\n    assert candidate(current = \"16:10\",correct = \"16:55\") == 3\n    assert candidate(current = \"07:40\",correct = \"07:55\") == 1\n    assert candidate(current = \"05:20\",correct = \"06:50\") == 3\n    assert candidate(current = \"08:30\",correct = \"20:45\") == 13\n    assert candidate(current = \"14:15\",correct = \"14:15\") == 0\n    assert candidate(current = \"13:45\",correct = \"14:10\") == 3\n    assert candidate(current = \"09:05\",correct = \"09:10\") == 1\n    assert candidate(current = \"17:00\",correct = \"18:30\") == 3\n    assert candidate(current = \"20:50\",correct = \"21:50\") == 1\n    assert candidate(current = \"12:45\",correct = \"13:30\") == 3\n    assert candidate(current = \"18:44\",correct = \"19:59\") == 2\n    assert candidate(current = \"05:20\",correct = \"05:25\") == 1\n    assert candidate(current = \"05:45\",correct = \"10:30\") == 7\n    assert candidate(current = \"03:00\",correct = \"04:59\") == 10\n    assert candidate(current = \"10:10\",correct = \"11:55\") == 4\n    assert candidate(current = \"04:59\",correct = \"05:00\") == 1\n    assert candidate(current = \"01:45\",correct = \"02:00\") == 1\n    assert candidate(current = \"00:59\",correct = \"01:00\") == 1\n    assert candidate(current = \"13:12\",correct = \"13:57\") == 3\n    assert candidate(current = \"19:50\",correct = \"21:00\") == 3\n    assert candidate(current = \"10:10\",correct = \"10:55\") == 3\n    assert candidate(current = \"09:01\",correct = \"09:16\") == 1\n    assert candidate(current = \"22:15\",correct = \"23:00\") == 3\n    assert candidate(current = \"17:00\",correct = \"19:45\") == 5\n    assert candidate(current = \"06:30\",correct = \"08:45\") == 3\n    assert candidate(current = \"22:00\",correct = \"23:00\") == 1\n    assert candidate(current = \"14:45\",correct = \"15:05\") == 2\n    assert candidate(current = \"04:55\",correct = \"05:00\") == 1\n    assert candidate(current = \"10:05\",correct = \"10:10\") == 1\n    assert candidate(current = \"13:47\",correct = \"15:12\") == 4\n    assert candidate(current = \"09:45\",correct = \"11:20\") == 4\n    assert candidate(current = \"17:40\",correct = \"18:20\") == 4\n    assert candidate(current = \"22:15\",correct = \"22:50\") == 3\n    assert candidate(current = \"08:00\",correct = \"08:05\") == 1\n    assert candidate(current = \"14:05\",correct = \"14:14\") == 5\n    assert candidate(current = \"00:05\",correct = \"01:05\") == 1\n    assert candidate(current = \"01:23\",correct = \"05:47\") == 10\n    assert candidate(current = \"22:15\",correct = \"23:45\") == 3\n    assert candidate(current = \"20:30\",correct = \"22:45\") == 3\n", "comparison": "exact"}, "public_tests": ["\"02:30\"\n\"04:35\"", "\"11:00\"\n\"11:01\""], "hints": ["Convert the times to minutes.", "Use the operation with the biggest value possible at each step."], "metadata": {"canonical_parameter_names": ["current", "correct"], "leetcode_dataset_entry_point": "Solution().convertTime", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:34+00:00", "tests_total": 138, "tests_dropped": 3, "flags": [], "topic_tags": ["string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def convertTime(self, current: str, correct: str) -> int:", "container": "Solution", "callable": "convertTime", "parameters": [{"name": "current", "type": "str"}, {"name": "correct", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2225, "task_id": "find-players-with-zero-or-one-losses", "difficulty": "Medium", "problem_description": "You are given an integer array matches where matches[i] = [winner_i, loser_i] indicates that the player winner_i defeated player loser_i in a match.\n\nReturn a list answer of size 2 where:\n\n- answer[0] is a list of all players that have not lost any matches.\n- answer[1] is a list of all players that have lost exactly one match.\n\nThe values in the two lists should be returned in increasing order.\n\nNote:\n\n- You should only consider the players that have played at least one match.\n- The testcases will be generated such that no two matches will have the same outcome.\n\nExample 1:\n\nInput: matches = [[1,3],[2,3],[3,6],[5,6],[5,7],[4,5],[4,8],[4,9],[10,4],[10,9]]\nOutput: [[1,2,10],[4,5,7,8]]\nExplanation:\nPlayers 1, 2, and 10 have not lost any matches.\nPlayers 4, 5, 7, and 8 each have lost one match.\nPlayers 3, 6, and 9 each have lost two matches.\nThus, answer[0] = [1,2,10] and answer[1] = [4,5,7,8].\n\nExample 2:\n\nInput: matches = [[2,3],[1,3],[5,4],[6,4]]\nOutput: [[1,2,5,6],[]]\nExplanation:\nPlayers 1, 2, 5, and 6 have not lost any matches.\nPlayers 3 and 4 each have lost two matches.\nThus, answer[0] = [1,2,5,6] and answer[1] = [].\n\nConstraints:\n\n- 1 <= matches.length <= 10^5\n- matches[i].length == 2\n- 1 <= winner_i, loser_i <= 10^5\n- winner_i != loser_i\n- All matches[i] are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(matches = [[1, 2]]) == [[1], [2]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == [[], [1, 2, 3, 4, 5]]\n    assert candidate(matches = [[100, 200], [200, 300], [100, 300], [400, 500]]) == [[100, 400], [200, 500]]\n    assert candidate(matches = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5]]) == [[1], [2, 3, 5]]\n    assert candidate(matches = [[5, 3], [5, 4], [4, 5], [3, 4]]) == [[], [3, 5]]\n    assert candidate(matches = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600]]) == [[100], [200, 300, 400, 500, 600]]\n    assert candidate(matches = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]\n    assert candidate(matches = [[1, 3], [2, 3], [3, 6], [5, 6], [5, 7], [4, 5], [4, 8], [4, 9], [10, 4], [10, 9]]) == [[1, 2, 10], [4, 5, 7, 8]]\n    assert candidate(matches = [[100, 200], [200, 300], [100, 300]]) == [[100], [200]]\n    assert candidate(matches = [[100000, 1], [99999, 2], [99998, 3], [99997, 4], [99996, 5]]) == [[99996, 99997, 99998, 99999, 100000], [1, 2, 3, 4, 5]]\n    assert candidate(matches = [[2, 3], [1, 3], [5, 4], [6, 4]]) == [[1, 2, 5, 6], []]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5]]) == [[1], [2, 3, 4, 5]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 3], [3, 5], [5, 7], [7, 9], [2, 4], [4, 6], [6, 8], [8, 10]]) == [[], [1, 2]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5], [4, 1], [5, 2], [6, 7], [7, 8], [8, 9], [9, 6], [7, 9], [8, 6], [9, 7]]) == [[], [8]]\n    assert candidate(matches = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [4, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7]]) == [[1], [2]]\n    assert candidate(matches = [[10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 10], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 21]]) == [[], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]\n    assert candidate(matches = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [100, 300], [300, 500], [500, 700], [700, 900], [100, 400], [400, 600], [600, 800], [800, 1000], [100, 500], [500, 900], [100, 600], [600, 1000], [100, 700], [100, 800], [100, 900], [100, 1000]]) == [[100], [200]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == [[1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [10, 11], [11, 10], [12, 13], [13, 12], [14, 15], [15, 14], [16, 17], [17, 16], [18, 19], [19, 18], [20, 21], [21, 20]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]]\n    assert candidate(matches = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 2], [10, 1]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n    assert candidate(matches = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9], [11, 12], [12, 11]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]\n    assert candidate(matches = [[1, 3], [2, 3], [3, 6], [5, 6], [5, 7], [4, 5], [4, 8], [4, 9], [10, 4], [10, 9], [11, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30], [29, 31], [30, 32], [31, 33], [32, 34], [33, 35], [34, 36], [35, 37], [36, 38], [37, 39], [38, 40], [39, 41], [40, 42], [41, 43], [42, 44], [43, 45], [44, 46], [45, 47], [46, 48], [47, 49], [48, 50], [49, 51], [50, 52], [51, 53], [52, 54], [53, 55], [54, 56], [55, 57], [56, 58], [57, 59], [58, 60], [59, 61], [60, 62], [61, 63], [62, 64], [63, 65], [64, 66], [65, 67], [66, 68], [67, 69], [68, 70], [69, 71], [70, 72], [71, 73], [72, 74], [73, 75], [74, 76], [75, 77], [76, 78], [77, 79], [78, 80], [79, 81], [80, 82], [81, 83], [82, 84], [83, 85], [84, 86], [85, 87], [86, 88], [87, 89], [88, 90], [89, 91], [90, 92], [91, 93], [92, 94], [93, 95], [94, 96], [95, 97], [96, 98], [97, 99], [98, 100], [99, 101], [100, 102], [101, 103], [102, 104], [103, 105], [104, 106], [105, 107], [106, 108], [107, 109], [108, 110], [109, 111], [110, 112], [111, 113], [112, 114], [113, 115], [114, 116], [115, 117], [116, 118], [117, 119], [118, 120], [119, 121], [120, 122], [121, 123], [122, 124], [123, 125], [124, 126], [125, 127], [126, 128], [127, 129], [128, 130], [129, 131], [130, 132], [131, 133], [132, 134], [133, 135], [134, 136], [135, 137], [136, 138], [137, 139], [138, 140], [139, 141], [140, 142], [141, 143], [142, 144], [143, 145], [144, 146], [145, 147], [146, 148], [147, 149], [148, 150], [149, 151], [150, 152], [151, 153], [152, 154], [153, 155], [154, 156], [155, 157], [156, 158], [157, 159], [158, 160], [159, 161], [160, 162], [161, 163], [162, 164], [163, 165], [164, 166], [165, 167], [166, 168], [167, 169], [168, 170], [169, 171], [170, 172], [171, 173], [172, 174], [173, 175], [174, 176], [175, 177], [176, 178], [177, 179], [178, 180], [179, 181], [180, 182], [181, 183], [182, 184], [183, 185], [184, 186], [185, 187], [186, 188], [187, 189], [188, 190], [189, 191], [190, 192], [191, 193], [192, 194], [193, 195], [194, 196], [195, 197], [196, 198], [197, 199], [198, 200], [199, 201], [200, 202]]) == [[1, 2, 10, 11], [4, 5, 7, 8, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202]]\n    assert candidate(matches = [[1, 10], [2, 10], [3, 11], [4, 11], [5, 12], [6, 12], [7, 13], [8, 13], [9, 14], [10, 15], [11, 15], [12, 16], [13, 16], [14, 17], [15, 18], [16, 18], [17, 19], [18, 20], [19, 20]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [14, 17, 19]]\n    assert candidate(matches = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 1], [12, 2], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == [[], [1, 2, 3, 4, 5, 6]]\n    assert candidate(matches = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 1], [10, 2]]) == [[], []]\n    assert candidate(matches = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9], [11, 12], [12, 11], [13, 14], [14, 13], [15, 16], [16, 15], [17, 18], [18, 17], [19, 20], [20, 19]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]\n    assert candidate(matches = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 1]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 1]]) == [[], [2]]\n    assert candidate(matches = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]) == [[1], [2, 5, 6, 7, 8, 9, 10]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 3], [3, 5], [5, 7], [7, 9], [9, 1], [2, 4], [4, 6], [6, 8], [8, 10], [10, 2]]) == [[], []]\n    assert candidate(matches = [[1, 10], [2, 10], [3, 11], [4, 11], [5, 12], [6, 12], [7, 13], [8, 13], [9, 14], [1, 15], [2, 15], [3, 16], [4, 16], [5, 17], [6, 17], [7, 18], [8, 18], [9, 19]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [14, 19]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]\n    assert candidate(matches = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]]) == [[1], [2]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5], [2, 4], [4, 1], [5, 3]]) == [[], [2]]\n    assert candidate(matches = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 12], [8, 12], [9, 13], [10, 13], [11, 14], [12, 14], [13, 15], [14, 15], [1, 16], [2, 16], [3, 17], [4, 17], [5, 18], [6, 18], [7, 19], [8, 19], [9, 20], [10, 20], [11, 21], [12, 21], [13, 22], [14, 22], [15, 23], [16, 23], [17, 24], [18, 24], [19, 25], [20, 25], [21, 26], [22, 26], [23, 27], [24, 27], [25, 28], [26, 28], [27, 29], [28, 29]]) == [[1], [2, 3, 4, 5, 6, 7, 8, 9, 10]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [2, 6], [3, 7], [4, 8], [5, 9]]) == [[], [2, 3, 4, 5, 10]]\n    assert candidate(matches = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [2, 3], [3, 2], [2, 4], [4, 2], [2, 5], [5, 2], [2, 6], [6, 2], [2, 7], [7, 2], [2, 8], [8, 2], [2, 9], [9, 2], [2, 10], [10, 2]]) == [[], []]\n    assert candidate(matches = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [4, 1], [4, 2], [4, 3], [5, 6], [6, 7], [7, 5], [7, 8], [8, 6], [8, 9], [9, 7], [9, 10], [10, 8]]) == [[], [1, 5, 9, 10]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 9]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n    assert candidate(matches = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 1100], [1100, 1200], [1200, 1300], [1300, 1400], [1400, 1500], [1500, 1600], [1600, 1700], [1700, 1800], [1800, 1900], [1900, 2000], [2000, 2100]]) == [[100], [200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100]]\n    assert candidate(matches = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 10], [9, 10]]) == [[1], [2, 3]]\n    assert candidate(matches = [[5, 1], [2, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 2], [9, 3], [10, 4]]) == [[], [1, 2, 5, 6, 7, 8, 9, 10]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [1, 10]]) == [[], []]\n    assert candidate(matches = [[1, 4], [1, 5], [2, 4], [2, 6], [3, 5], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25], [22, 26], [23, 27], [24, 28], [25, 29], [26, 30], [27, 31], [28, 32], [29, 33], [30, 34], [31, 35], [32, 36], [33, 37], [34, 38], [35, 39], [36, 40], [37, 41], [38, 42], [39, 43], [40, 44], [41, 45], [42, 46], [43, 47], [44, 48], [45, 49], [46, 50], [47, 51], [48, 52], [49, 53], [50, 54], [51, 55], [52, 56], [53, 57], [54, 58], [55, 59], [56, 60], [57, 61], [58, 62], [59, 63], [60, 64], [61, 65], [62, 66], [63, 67], [64, 68], [65, 69], [66, 70], [67, 71], [68, 72], [69, 73], [70, 74], [71, 75], [72, 76], [73, 77], [74, 78], [75, 79], [76, 80], [77, 81], [78, 82], [79, 83], [80, 84], [81, 85], [82, 86], [83, 87], [84, 88], [85, 89], [86, 90], [87, 91], [88, 92], [89, 93], [90, 94], [91, 95], [92, 96], [93, 97], [94, 98], [95, 99], [96, 100]]) == [[1, 2, 3], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]\n    assert candidate(matches = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9], [11, 12], [12, 11], [13, 14], [14, 13], [15, 16], [16, 15], [17, 18], [18, 17], [19, 20], [20, 19], [1, 11], [11, 1], [2, 12], [12, 2], [3, 13], [13, 3], [4, 14], [14, 4], [5, 15], [15, 5], [6, 16], [16, 6], [7, 17], [17, 7], [8, 18], [18, 8], [9, 19], [19, 9], [10, 20], [20, 10]]) == [[], []]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [7, 8], [8, 9], [9, 10], [10, 7]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n    assert candidate(matches = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [[1], [2, 5, 6, 7, 8]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 19], [19, 16], [20, 21], [21, 22], [22, 20], [23, 24], [24, 25], [25, 23], [26, 27], [27, 28], [28, 29], [29, 26]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]]\n    assert candidate(matches = [[1, 10], [2, 10], [3, 10], [4, 11], [5, 11], [6, 12], [7, 12], [8, 13], [9, 13], [10, 14], [11, 14], [12, 15], [13, 15], [14, 16], [15, 16]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], []]\n    assert candidate(matches = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 1]]) == [[], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]]\n    assert candidate(matches = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [[1], [2, 5, 6, 7, 8, 9, 10]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 10]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]\n    assert candidate(matches = [[10, 11], [12, 13], [11, 12], [13, 10], [14, 15], [16, 17], [15, 16], [17, 14], [18, 19], [19, 20]]) == [[18], [10, 11, 12, 13, 14, 15, 16, 17, 19, 20]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 10], [10, 2], [2, 11], [11, 3], [3, 12], [12, 4], [4, 13], [13, 5], [5, 14], [14, 6], [6, 15], [15, 7], [7, 16], [16, 8], [8, 17], [17, 9], [9, 18], [18, 10], [10, 19], [19, 1]]) == [[], [11, 12, 13, 14, 15, 16, 17, 18, 19]]\n    assert candidate(matches = [[10, 1], [11, 10], [12, 11], [13, 12], [14, 13], [15, 14], [1, 15]]) == [[], [1, 10, 11, 12, 13, 14, 15]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 21], [21, 19], [22, 23], [23, 24], [24, 22], [25, 26], [26, 27], [27, 25], [28, 29], [29, 30], [30, 28]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]\n    assert candidate(matches = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [1, 3], [2, 4], [5, 7], [6, 8], [9, 11], [10, 12], [13, 15], [14, 16], [17, 19], [18, 20]]) == [[1, 5, 9, 13, 17], [2, 3, 6, 7, 10, 11, 14, 15, 18, 19]]\n    assert candidate(matches = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22]]) == [[1, 2], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]]\n    assert candidate(matches = [[1, 2], [2, 3], [3, 1], [1, 4], [4, 5], [5, 6], [6, 4], [4, 7], [7, 8], [8, 9], [9, 10], [10, 7]]) == [[], [1, 2, 3, 5, 6, 8, 9, 10]]\n    assert candidate(matches = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9], [11, 12], [12, 11], [13, 14], [14, 13], [15, 16], [16, 15], [17, 18], [18, 17], [19, 20], [20, 19], [21, 22], [22, 21], [23, 24], [24, 23], [25, 26], [26, 25], [27, 28], [28, 27], [29, 30], [30, 29], [31, 32], [32, 31], [33, 34], [34, 33], [35, 36], [36, 35], [37, 38], [38, 37], [39, 40], [40, 39]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]\n    assert candidate(matches = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19], [11, 20], [12, 21], [13, 22], [14, 23], [15, 24], [16, 25], [17, 26], [18, 27], [19, 28], [20, 29], [21, 30], [22, 31], [23, 32], [24, 33], [25, 34], [26, 35], [27, 36], [28, 37], [29, 38], [30, 39], [31, 40], [32, 1], [33, 2], [34, 3], [35, 4], [36, 5], [37, 6], [38, 7], [39, 8], [40, 9]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]\n    assert candidate(matches = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [2, 3], [4, 5], [6, 7], [8, 9], [10, 1]]) == [[], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n    assert candidate(matches = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [7, 22], [8, 23], [8, 24], [8, 25], [9, 26], [9, 27], [9, 28], [10, 29], [10, 30], [10, 31]]) == [[1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]]\n", "comparison": "exact"}, "public_tests": ["[[1,3],[2,3],[3,6],[5,6],[5,7],[4,5],[4,8],[4,9],[10,4],[10,9]]", "[[2,3],[1,3],[5,4],[6,4]]"], "hints": ["Count the number of times a player loses while iterating through the matches."], "metadata": {"canonical_parameter_names": ["matches"], "leetcode_dataset_entry_point": "Solution().findWinners", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:36+00:00", "tests_total": 69, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "hash-table", "sorting", "counting"]}, "language": "python", "interface": {"raw_signature": "def findWinners(self, matches: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "findWinners", "parameters": [{"name": "matches", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2226, "task_id": "maximum-candies-allocated-to-k-children", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array candies. Each element in the array denotes a pile of candies of size candies[i]. You can divide each pile into any number of sub piles, but you cannot merge two piles together.\n\nYou are also given an integer k. You should allocate piles of candies to k children such that each child gets the same number of candies. Each child can be allocated candies from only one pile of candies and some piles of candies may go unused.\n\nReturn the maximum number of candies each child can get.\n\nExample 1:\n\nInput: candies = [5,8,6], k = 3\nOutput: 5\nExplanation: We can divide candies[1] into 2 piles of size 5 and 3, and candies[2] into 2 piles of size 5 and 1. We now have five piles of candies of sizes 5, 5, 3, 5, and 1. We can allocate the 3 piles of size 5 to 3 children. It can be proven that each child cannot receive more than 5 candies.\n\nExample 2:\n\nInput: candies = [2,5], k = 11\nOutput: 0\nExplanation: There are 11 children but only 7 candies in total, so it is impossible to ensure each child receives at least one candy. Thus, each child gets no candy and the answer is 0.\n\nConstraints:\n\n- 1 <= candies.length <= 10^5\n- 1 <= candies[i] <= 10^7\n- 1 <= k <= 10^12\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(candies = [10000000, 10000000, 10000000],k = 10000000) == 2\n    assert candidate(candies = [7, 14, 10, 7],k = 3) == 7\n    assert candidate(candies = [5, 8, 6],k = 3) == 5\n    assert candidate(candies = [3, 9, 7],k = 6) == 3\n    assert candidate(candies = [10, 20, 30, 40, 50],k = 15) == 10\n    assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 1\n    assert candidate(candies = [7, 10, 10, 10],k = 4) == 7\n    assert candidate(candies = [10000000],k = 1) == 10000000\n    assert candidate(candies = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 5) == 7\n    assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 6\n    assert candidate(candies = [10, 20, 30, 40, 50],k = 3) == 30\n    assert candidate(candies = [10, 20, 30, 40, 50],k = 30) == 5\n    assert candidate(candies = [10000000, 10000000, 10000000],k = 3) == 10000000\n    assert candidate(candies = [1000000],k = 1) == 1000000\n    assert candidate(candies = [2, 5],k = 11) == 0\n    assert candidate(candies = [7, 7, 7, 7, 7],k = 5) == 7\n    assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1\n    assert candidate(candies = [1, 2, 3, 4, 5],k = 15) == 1\n    assert candidate(candies = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],k = 300000) == 1\n    assert candidate(candies = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 500000) == 40\n    assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 60\n    assert candidate(candies = [10000000, 5000000, 2500000, 1250000, 625000],k = 1000000) == 19\n    assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 1\n    assert candidate(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 50) == 1\n    assert candidate(candies = [10000000],k = 10000001) == 0\n    assert candidate(candies = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 1000000000) == 0\n    assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1000000000) == 0\n    assert candidate(candies = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000],k = 45000000) == 1\n    assert candidate(candies = [10000000, 10000000, 10000000, 10000000, 10000000],k = 1000000) == 50\n    assert candidate(candies = [1000000, 999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111],k = 1000000) == 5\n    assert candidate(candies = [10000000, 10000000, 10000000, 10000000, 10000000],k = 5000000) == 10\n    assert candidate(candies = [9999999, 9999999, 9999999, 9999999, 9999999],k = 1) == 9999999\n    assert candidate(candies = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 10) == 1000000\n    assert candidate(candies = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 100) == 10\n    assert candidate(candies = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 5000000) == 2\n    assert candidate(candies = [5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000],k = 10) == 5000000\n    assert candidate(candies = [1234567, 8901234, 5678901, 2345678, 9012345],k = 10000000) == 2\n    assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1000000) == 0\n    assert candidate(candies = [5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000],k = 5) == 5000000\n    assert candidate(candies = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000],k = 1000000000000) == 0\n    assert candidate(candies = [9999999, 9999999, 9999999, 9999999, 9999999],k = 49999995) == 1\n    assert candidate(candies = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 10) == 9\n    assert candidate(candies = [5000000, 5000000, 5000000, 5000000, 5000000],k = 10000000) == 2\n    assert candidate(candies = [10000000, 10000000, 10000000],k = 1000000) == 29\n    assert candidate(candies = [10000000, 10000000, 10000000],k = 3000000) == 10\n    assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 0\n    assert candidate(candies = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 50) == 100\n    assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 1\n    assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 7\n    assert candidate(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 100) == 3\n    assert candidate(candies = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 15000) == 1\n    assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1\n    assert candidate(candies = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 10) == 400\n    assert candidate(candies = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 25) == 10\n    assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 3\n    assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19) == 1\n    assert candidate(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 20) == 13\n    assert candidate(candies = [10000000, 1000000, 100000, 10000, 1000, 100, 10, 1],k = 10000000) == 1\n    assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 30) == 1\n    assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 45) == 1\n    assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1000000000) == 0\n    assert candidate(candies = [1000000, 1000000, 1000000, 1000000, 1000000],k = 4) == 1000000\n    assert candidate(candies = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000],k = 10000000) == 10\n    assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 55) == 10\n    assert candidate(candies = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250],k = 1000000) == 19\n    assert candidate(candies = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000],k = 50000000) == 2\n    assert candidate(candies = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 100) == 4\n    assert candidate(candies = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 25) == 600\n    assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 55) == 1\n    assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 35) == 1\n    assert candidate(candies = [9999999, 9999998, 9999997, 9999996, 9999995],k = 1000000000000) == 0\n    assert candidate(candies = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 20) == 5\n    assert candidate(candies = [10000, 20000, 30000, 40000, 50000],k = 150000) == 1\n    assert candidate(candies = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 1024) == 1\n    assert candidate(candies = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 500000000) == 0\n    assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1\n    assert candidate(candies = [1000000, 1000000, 1000000, 1000000, 1000000],k = 250000) == 20\n    assert candidate(candies = [10000000, 10000000, 10000000, 10000000, 10000000],k = 5) == 10000000\n    assert candidate(candies = [5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000],k = 5000000) == 10\n    assert candidate(candies = [10000000, 5000000, 3000000, 2000000, 1000000],k = 1000000) == 20\n", "comparison": "exact"}, "public_tests": ["[5,8,6]\n3", "[2,5]\n11"], "hints": ["For a fixed number of candies c, how can you check if each child can get c candies?", "Use binary search to find the maximum c as the answer."], "metadata": {"canonical_parameter_names": ["candies", "k"], "leetcode_dataset_entry_point": "Solution().maximumCandies", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:39+00:00", "tests_total": 82, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "binary-search"]}, "language": "python", "interface": {"raw_signature": "def maximumCandies(self, candies: list[int], k: int) -> int:", "container": "Solution", "callable": "maximumCandies", "parameters": [{"name": "candies", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2231, "task_id": "largest-number-after-digit-swaps-by-parity", "difficulty": "Easy", "problem_description": "You are given a positive integer num. You may swap any two digits of num that have the same parity (i.e. both odd digits or both even digits).\n\nReturn the largest possible value of num after any number of swaps.\n\nExample 1:\n\nInput: num = 1234\nOutput: 3412\nExplanation: Swap the digit 3 with the digit 1, this results in the number 3214.\nSwap the digit 2 with the digit 4, this results in the number 3412.\nNote that there may be other sequences of swaps but it can be shown that 3412 is the largest possible number.\nAlso note that we may not swap the digit 4 with the digit 1 since they are of different parities.\n\nExample 2:\n\nInput: num = 65875\nOutput: 87655\nExplanation: Swap the digit 8 with the digit 6, this results in the number 85675.\nSwap the first digit 5 with the digit 7, this results in the number 87655.\nNote that there may be other sequences of swaps but it can be shown that 87655 is the largest possible number.\n\nConstraints:\n\n- 1 <= num <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num = 24680) == 86420\n    assert candidate(num = 987654321) == 987654321\n    assert candidate(num = 13524687) == 75386421\n    assert candidate(num = 1000000) == 1000000\n    assert candidate(num = 2222) == 2222\n    assert candidate(num = 222222) == 222222\n    assert candidate(num = 111111) == 111111\n    assert candidate(num = 1111) == 1111\n    assert candidate(num = 975318642) == 975318642\n    assert candidate(num = 13579) == 97531\n    assert candidate(num = 2468) == 8642\n    assert candidate(num = 135246) == 531642\n    assert candidate(num = 111) == 111\n    assert candidate(num = 1234) == 3412\n    assert candidate(num = 65875) == 87655\n    assert candidate(num = 198765432) == 978563412\n    assert candidate(num = 1000000000) == 1000000000\n    assert candidate(num = 123456789) == 987654321\n    assert candidate(num = 973518642) == 975318642\n    assert candidate(num = 973159731) == 997753311\n", "comparison": "exact"}, "public_tests": ["1234", "65875"], "hints": ["The bigger digit should appear first (more to the left) because it contributes more to the value of the number.", "Get all the even digits, as well as odd digits. Sort them separately.", "Reconstruct the number by giving the earlier digits the highest available digit of the same parity."], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().largestInteger", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:43+00:00", "tests_total": 78, "tests_dropped": 58, "flags": [], "topic_tags": ["sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def largestInteger(self, num: int) -> int:", "container": "Solution", "callable": "largestInteger", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2232, "task_id": "minimize-result-by-adding-parentheses-to-expression", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string expression of the form \"+\" where  and  represent positive integers.\n\nAdd a pair of parentheses to expression such that after the addition of parentheses, expression is a valid mathematical expression and evaluates to the smallest possible value. The left parenthesis must be added to the left of '+' and the right parenthesis must be added to the right of '+'.\n\nReturn expression after adding a pair of parentheses such that expression evaluates to the smallest possible value. If there are multiple answers that yield the same result, return any of them.\n\nThe input has been generated such that the original value of expression, and the value of expression after adding any pair of parentheses that meets the requirements fits within a signed 32-bit integer.\n\nExample 1:\n\nInput: expression = \"247+38\"\nOutput: \"2(47+38)\"\nExplanation: The expression evaluates to 2 * (47 + 38) = 2 * 85 = 170.\nNote that \"2(4)7+38\" is invalid because the right parenthesis must be to the right of the '+'.\nIt can be shown that 170 is the smallest possible value.\n\nExample 2:\n\nInput: expression = \"12+34\"\nOutput: \"1(2+3)4\"\nExplanation: The expression evaluates to 1 * (2 + 3) * 4 = 1 * 5 * 4 = 20.\n\nExample 3:\n\nInput: expression = \"999+999\"\nOutput: \"(999+999)\"\nExplanation: The expression evaluates to 999 + 999 = 1998.\n\nConstraints:\n\n- 3 <= expression.length <= 10\n- expression consists of digits from '1' to '9' and '+'.\n- expression starts and ends with digits.\n- expression contains exactly one '+'.\n- The original value of expression, and the value of expression after adding any pair of parentheses that meets the requirements fits within a signed 32-bit integer.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(expression = \"56+78\") == \"(56+78)\"\n    assert candidate(expression = \"5+6\") == \"(5+6)\"\n    assert candidate(expression = \"3+8\") == \"(3+8)\"\n    assert candidate(expression = \"111+222\") == \"1(11+22)2\"\n    assert candidate(expression = \"3+2\") == \"(3+2)\"\n    assert candidate(expression = \"5+678\") == \"(5+67)8\"\n    assert candidate(expression = \"247+38\") == \"2(47+38)\"\n    assert candidate(expression = \"3+12\") == \"(3+1)2\"\n    assert candidate(expression = \"11+11\") == \"1(1+1)1\"\n    assert candidate(expression = \"8+9\") == \"(8+9)\"\n    assert candidate(expression = \"1+2\") == \"(1+2)\"\n    assert candidate(expression = \"123+456\") == \"1(23+45)6\"\n    assert candidate(expression = \"9+9\") == \"(9+9)\"\n    assert candidate(expression = \"12+34\") == \"1(2+3)4\"\n    assert candidate(expression = \"88+11\") == \"8(8+1)1\"\n    assert candidate(expression = \"999+999\") == \"(999+999)\"\n    assert candidate(expression = \"1+9\") == \"(1+9)\"\n    assert candidate(expression = \"333+444\") == \"(333+444)\"\n    assert candidate(expression = \"555+666\") == \"(555+666)\"\n    assert candidate(expression = \"9+99\") == \"(9+99)\"\n    assert candidate(expression = \"9+1\") == \"(9+1)\"\n    assert candidate(expression = \"5+9\") == \"(5+9)\"\n    assert candidate(expression = \"1+1\") == \"(1+1)\"\n    assert candidate(expression = \"12+3\") == \"1(2+3)\"\n    assert candidate(expression = \"555+555\") == \"(555+555)\"\n    assert candidate(expression = \"123+4\") == \"1(23+4)\"\n    assert candidate(expression = \"9+876\") == \"(9+87)6\"\n    assert candidate(expression = \"12345+6789\") == \"1(2345+6789)\"\n    assert candidate(expression = \"56+789\") == \"(56+789)\"\n    assert candidate(expression = \"1111+2222\") == \"1(111+222)2\"\n    assert candidate(expression = \"123+4567\") == \"1(23+456)7\"\n    assert candidate(expression = \"6666+7777\") == \"(6666+7777)\"\n    assert candidate(expression = \"9999+1\") == \"9(999+1)\"\n    assert candidate(expression = \"12+345\") == \"1(2+34)5\"\n    assert candidate(expression = \"567+89\") == \"(567+89)\"\n    assert candidate(expression = \"8+7654\") == \"(8+765)4\"\n    assert candidate(expression = \"987+654\") == \"(987+654)\"\n    assert candidate(expression = \"33+44\") == \"(33+44)\"\n    assert candidate(expression = \"1234+56789\") == \"1(234+5678)9\"\n    assert candidate(expression = \"99+11\") == \"9(9+1)1\"\n    assert candidate(expression = \"333+666\") == \"(333+666)\"\n    assert candidate(expression = \"345+678\") == \"(345+678)\"\n    assert candidate(expression = \"123+45\") == \"1(23+45)\"\n    assert candidate(expression = \"5+55\") == \"(5+5)5\"\n    assert candidate(expression = \"678+9\") == \"6(78+9)\"\n    assert candidate(expression = \"12+345678\") == \"1(2+34)5678\"\n    assert candidate(expression = \"12+3456789\") == \"1(2+34)56789\"\n    assert candidate(expression = \"99+88\") == \"(99+88)\"\n    assert candidate(expression = \"9+1234\") == \"(9+123)4\"\n    assert candidate(expression = \"1234+56\") == \"1(234+56)\"\n    assert candidate(expression = \"44+555\") == \"(44+55)5\"\n    assert candidate(expression = \"9+87654321\") == \"(9+8765432)1\"\n    assert candidate(expression = \"2222+3333\") == \"2(222+333)3\"\n    assert candidate(expression = \"1+999\") == \"(1+99)9\"\n    assert candidate(expression = \"9876+5432\") == \"(9876+5432)\"\n    assert candidate(expression = \"4321+9\") == \"43(21+9)\"\n    assert candidate(expression = \"5432+1\") == \"543(2+1)\"\n    assert candidate(expression = \"1+9999\") == \"(1+999)9\"\n    assert candidate(expression = \"3456+789\") == \"3(456+789)\"\n    assert candidate(expression = \"5555+666\") == \"5(555+666)\"\n    assert candidate(expression = \"123+6\") == \"1(23+6)\"\n    assert candidate(expression = \"8888+9999\") == \"(8888+9999)\"\n    assert candidate(expression = \"213+456\") == \"(213+456)\"\n    assert candidate(expression = \"23+4567\") == \"(23+456)7\"\n    assert candidate(expression = \"9+8765432\") == \"(9+876543)2\"\n    assert candidate(expression = \"111+111\") == \"1(11+11)1\"\n    assert candidate(expression = \"99+1\") == \"9(9+1)\"\n    assert candidate(expression = \"3+9999\") == \"(3+999)9\"\n    assert candidate(expression = \"234+567\") == \"(234+567)\"\n    assert candidate(expression = \"2+9999\") == \"(2+999)9\"\n    assert candidate(expression = \"4321+876\") == \"4(321+876)\"\n    assert candidate(expression = \"11+111\") == \"1(1+11)1\"\n    assert candidate(expression = \"5+6789\") == \"(5+678)9\"\n    assert candidate(expression = \"1+23456\") == \"(1+2)3456\"\n    assert candidate(expression = \"999+1\") == \"9(99+1)\"\n    assert candidate(expression = \"4444+5555\") == \"(4444+5555)\"\n    assert candidate(expression = \"55+55\") == \"(55+55)\"\n    assert candidate(expression = \"777+888\") == \"(777+888)\"\n    assert candidate(expression = \"98765+4321\") == \"9(8765+432)1\"\n    assert candidate(expression = \"654+321\") == \"6(54+32)1\"\n    assert candidate(expression = \"77+88\") == \"(77+88)\"\n    assert candidate(expression = \"222+333\") == \"2(22+33)3\"\n    assert candidate(expression = \"123+45678\") == \"1(23+4567)8\"\n    assert candidate(expression = \"9+8765\") == \"(9+876)5\"\n    assert candidate(expression = \"5678+123\") == \"5(678+123)\"\n    assert candidate(expression = \"1234+567\") == \"1(234+567)\"\n    assert candidate(expression = \"234+56789\") == \"(234+5678)9\"\n    assert candidate(expression = \"987654+321\") == \"987(654+32)1\"\n    assert candidate(expression = \"876+54\") == \"(876+54)\"\n    assert candidate(expression = \"123456+789\") == \"1(23456+789)\"\n    assert candidate(expression = \"9876+543\") == \"(9876+543)\"\n    assert candidate(expression = \"789+12\") == \"7(89+12)\"\n    assert candidate(expression = \"1111+1111\") == \"1(111+111)1\"\n    assert candidate(expression = \"55+5\") == \"5(5+5)\"\n    assert candidate(expression = \"1+99999\") == \"(1+9999)9\"\n    assert candidate(expression = \"11+22\") == \"1(1+2)2\"\n    assert candidate(expression = \"321+654\") == \"(321+654)\"\n    assert candidate(expression = \"55+66\") == \"(55+66)\"\n    assert candidate(expression = \"56789+12\") == \"5(6789+12)\"\n    assert candidate(expression = \"1234+5678\") == \"1(234+5678)\"\n    assert candidate(expression = \"6+66\") == \"(6+6)6\"\n    assert candidate(expression = \"54321+6789\") == \"5(4321+6789)\"\n    assert candidate(expression = \"123+456789\") == \"1(23+456)789\"\n    assert candidate(expression = \"54+32\") == \"5(4+3)2\"\n    assert candidate(expression = \"21+89\") == \"(21+89)\"\n", "comparison": "exact"}, "public_tests": ["\"247+38\"", "\"12+34\"", "\"999+999\""], "hints": ["The maximum length of expression is very low. We can try every possible spot to place the parentheses.", "Every possibility of expression is of the form a * (b + c) * d where a, b, c, d represent integers. Note the edge cases where a and/or d do not exist, in which case use 1 instead of them."], "metadata": {"canonical_parameter_names": ["expression"], "leetcode_dataset_entry_point": "Solution().minimizeResult", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:46+00:00", "tests_total": 134, "tests_dropped": 29, "flags": ["multiple_answers"], "topic_tags": ["string", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def minimizeResult(self, expression: str) -> str:", "container": "Solution", "callable": "minimizeResult", "parameters": [{"name": "expression", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2233, "task_id": "maximum-product-after-k-increments", "difficulty": "Medium", "problem_description": "You are given an array of non-negative integers nums and an integer k. In one operation, you may choose any element from nums and increment it by 1.\n\nReturn the maximum product of nums after at most k operations. Since the answer may be very large, return it modulo 10^9 + 7. Note that you should maximize the product before taking the modulo.\n\nExample 1:\n\nInput: nums = [0,4], k = 5\nOutput: 20\nExplanation: Increment the first number 5 times.\nNow nums = [5, 4], with a product of 5 * 4 = 20.\nIt can be shown that 20 is maximum product possible, so we return 20.\nNote that there may be other ways to increment nums to have the maximum product.\n\nExample 2:\n\nInput: nums = [6,3,3,2], k = 2\nOutput: 216\nExplanation: Increment the second number 1 time and increment the fourth number 1 time.\nNow nums = [6, 4, 3, 3], with a product of 6 * 4 * 3 * 3 = 216.\nIt can be shown that 216 is maximum product possible, so we return 216.\nNote that there may be other ways to increment nums to have the maximum product.\n\nConstraints:\n\n- 1 <= nums.length, k <= 10^5\n- 0 <= nums[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 7776\n    assert candidate(nums = [1, 2, 3, 4],k = 3) == 108\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 94500000\n    assert candidate(nums = [0, 4],k = 5) == 20\n    assert candidate(nums = [0, 0, 0, 0],k = 10) == 36\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 540\n    assert candidate(nums = [5, 5, 5, 5],k = 4) == 1296\n    assert candidate(nums = [1, 1, 1, 1, 1],k = 10) == 243\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 508243680\n    assert candidate(nums = [9, 9, 9, 9],k = 8) == 14641\n    assert candidate(nums = [10, 10, 10],k = 5) == 1584\n    assert candidate(nums = [6, 3, 3, 2],k = 2) == 216\n    assert candidate(nums = [0, 0, 0, 0],k = 1) == 0\n    assert candidate(nums = [1, 2, 3],k = 6) == 64\n    assert candidate(nums = [10, 20, 30],k = 15) == 15180\n    assert candidate(nums = [1, 2, 3],k = 3) == 27\n    assert candidate(nums = [1, 1, 1, 1],k = 10) == 144\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 10000) == 500226898\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 55) == 937424426\n    assert candidate(nums = [100, 100, 100, 100, 100],k = 250) == 937499475\n    assert candidate(nums = [1, 2, 3, 4, 5, 6],k = 10) == 18750\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 200) == 138022365\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 1000) == 24010000\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 100) == 858490890\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 45) == 1000000000\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 50) == 836777896\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 100) == 385000049\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 500) == 514152040\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 508243680\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 50) == 209024971\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 48999587\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 20) == 248832\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == 4900\n    assert candidate(nums = [100, 200, 300, 400, 500],k = 1000) == 999781257\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 100) == 460935215\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 414469870\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 50) == 60466176\n    assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 20) == 786432\n    assert candidate(nums = [999999, 999998, 999997, 999996],k = 10000) == 58871243\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 913512597\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 50) == 904899965\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 200) == 340513509\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 150) == 322349693\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100000) == 570617225\n    assert candidate(nums = [1, 3, 5, 7, 9],k = 20) == 59049\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 30) == 176221081\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 235146240\n    assert candidate(nums = [1, 10, 100, 1000, 10000],k = 10000) == 49587669\n    assert candidate(nums = [999999, 999998, 999997, 999996, 999995],k = 100000) == 817421264\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 50) == 999999937\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8],k = 200) == 73636025\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1024\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 50) == 608131681\n    assert candidate(nums = [1, 3, 5, 7, 9],k = 25) == 100000\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 937424426\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 50) == 73741817\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 100) == 911705284\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 30) == 60466176\n    assert candidate(nums = [1, 10, 100, 1000, 10000],k = 100000) == 501184279\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 1048576\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 937424426\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 235146240\n    assert candidate(nums = [1],k = 100000) == 100001\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 100) == 312500000\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 50) == 467201634\n    assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 100000) == 346266448\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 10) == 3125\n    assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996],k = 10000) == 607510375\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 50) == 73741817\n    assert candidate(nums = [5, 4, 3, 2, 1, 0, 0, 0, 0, 0],k = 25) == 983040\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 30) == 54000000\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1000) == 461240680\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 105099888\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 30) == 191102976\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 20) == 16807\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 550731776\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 100) == 47899023\n    assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996],k = 10000) == 233771963\n    assert candidate(nums = [1, 10, 100, 1000, 10000],k = 50000) == 901582326\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 50) == 650386593\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1000) == 889950771\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 100) == 312500000\n    assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 5000) == 881212280\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 785571733\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 15) == 7776\n", "comparison": "exact"}, "public_tests": ["[0,4]\n5", "[6,3,3,2]\n2"], "hints": ["If you can increment only once, which number should you increment?", "We should always prioritize the smallest number. What kind of data structure could we use?", "Use a min heap to hold all the numbers. Each time we do an operation, replace the top of the heap x by x + 1."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumProduct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:48+00:00", "tests_total": 101, "tests_dropped": 16, "flags": [], "topic_tags": ["array", "greedy", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def maximumProduct(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "maximumProduct", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2234, "task_id": "maximum-total-beauty-of-the-gardens", "difficulty": "Hard", "problem_description": "Alice is a caretaker of n gardens and she wants to plant flowers to maximize the total beauty of all her gardens.\n\nYou are given a 0-indexed integer array flowers of size n, where flowers[i] is the number of flowers already planted in the i^th garden. Flowers that are already planted cannot be removed. You are then given another integer newFlowers, which is the maximum number of flowers that Alice can additionally plant. You are also given the integers target, full, and partial.\n\nA garden is considered complete if it has at least target flowers. The total beauty of the gardens is then determined as the sum of the following:\n\n- The number of complete gardens multiplied by full.\n- The minimum number of flowers in any of the incomplete gardens multiplied by partial. If there are no incomplete gardens, then this value will be 0.\n\nReturn the maximum total beauty that Alice can obtain after planting at most newFlowers flowers.\n\nExample 1:\n\nInput: flowers = [1,3,1,1], newFlowers = 7, target = 6, full = 12, partial = 1\nOutput: 14\nExplanation: Alice can plant\n- 2 flowers in the 0^th garden\n- 3 flowers in the 1^st garden\n- 1 flower in the 2^nd garden\n- 1 flower in the 3^rd garden\nThe gardens will then be [3,6,2,2]. She planted a total of 2 + 3 + 1 + 1 = 7 flowers.\nThere is 1 garden that is complete.\nThe minimum number of flowers in the incomplete gardens is 2.\nThus, the total beauty is 1 * 12 + 2 * 1 = 12 + 2 = 14.\nNo other way of planting flowers can obtain a total beauty higher than 14.\n\nExample 2:\n\nInput: flowers = [2,4,5,3], newFlowers = 10, target = 5, full = 2, partial = 6\nOutput: 30\nExplanation: Alice can plant\n- 3 flowers in the 0^th garden\n- 0 flowers in the 1^st garden\n- 0 flowers in the 2^nd garden\n- 2 flowers in the 3^rd garden\nThe gardens will then be [5,4,5,5]. She planted a total of 3 + 0 + 0 + 2 = 5 flowers.\nThere are 3 gardens that are complete.\nThe minimum number of flowers in the incomplete gardens is 4.\nThus, the total beauty is 3 * 2 + 4 * 6 = 6 + 24 = 30.\nNo other way of planting flowers can obtain a total beauty higher than 30.\nNote that Alice could make all the gardens complete but in this case, she would obtain a lower total beauty.\n\nConstraints:\n\n- 1 <= flowers.length <= 10^5\n- 1 <= flowers[i], target <= 10^5\n- 1 <= newFlowers <= 10^10\n- 1 <= full, partial <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(flowers = [10, 20, 30, 40, 50],newFlowers = 100,target = 25,full = 5,partial = 2) == 68\n    assert candidate(flowers = [1, 1, 1, 1],newFlowers = 15,target = 3,full = 5,partial = 3) == 21\n    assert candidate(flowers = [5, 5, 5, 5],newFlowers = 10,target = 5,full = 10,partial = 5) == 40\n    assert candidate(flowers = [10, 20, 30],newFlowers = 100,target = 25,full = 50,partial = 10) == 340\n    assert candidate(flowers = [10, 1, 2, 3],newFlowers = 15,target = 10,full = 5,partial = 2) == 20\n    assert candidate(flowers = [1, 2, 3, 4, 5],newFlowers = 15,target = 5,full = 10,partial = 5) == 60\n    assert candidate(flowers = [5, 5, 5, 5],newFlowers = 10,target = 5,full = 10,partial = 1) == 40\n    assert candidate(flowers = [2, 4, 5, 3],newFlowers = 10,target = 5,full = 2,partial = 6) == 30\n    assert candidate(flowers = [100000, 100000, 100000],newFlowers = 300000,target = 100000,full = 100000,partial = 100000) == 300000\n    assert candidate(flowers = [1, 2, 3, 4, 5],newFlowers = 15,target = 4,full = 20,partial = 5) == 100\n    assert candidate(flowers = [1, 2, 3, 4, 5],newFlowers = 15,target = 5,full = 10,partial = 3) == 52\n    assert candidate(flowers = [5, 5, 5, 5],newFlowers = 10,target = 5,full = 10,partial = 10) == 40\n    assert candidate(flowers = [5, 5, 5, 5],newFlowers = 10,target = 5,full = 2,partial = 6) == 8\n    assert candidate(flowers = [1, 1, 1, 1],newFlowers = 20,target = 3,full = 7,partial = 3) == 28\n    assert candidate(flowers = [1, 3, 1, 1],newFlowers = 7,target = 6,full = 12,partial = 1) == 14\n    assert candidate(flowers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],newFlowers = 100,target = 10,full = 100,partial = 1) == 1000\n    assert candidate(flowers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],newFlowers = 100,target = 10,full = 30,partial = 20) == 450\n    assert candidate(flowers = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],newFlowers = 1000000,target = 50000,full = 500,partial = 250) == 12504250\n    assert candidate(flowers = [50000, 100000, 25000, 75000],newFlowers = 100000,target = 80000,full = 500,partial = 200) == 16001300\n    assert candidate(flowers = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],newFlowers = 10000,target = 2000,full = 1000,partial = 500) == 1008500\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 50,target = 7,full = 15,partial = 3) == 153\n    assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],newFlowers = 500,target = 55,full = 15,partial = 7) == 513\n    assert candidate(flowers = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],newFlowers = 1000000,target = 90000,full = 1000,partial = 500) == 10000\n    assert candidate(flowers = [1, 10, 100, 1000, 10000, 100000],newFlowers = 100000,target = 50000,full = 1000,partial = 500) == 11112000\n    assert candidate(flowers = [1, 5, 9, 13, 17, 21],newFlowers = 25,target = 15,full = 10,partial = 3) == 74\n    assert candidate(flowers = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],newFlowers = 1000000,target = 100000,full = 1,partial = 1) == 10\n    assert candidate(flowers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],newFlowers = 5000,target = 500,full = 100,partial = 50) == 25850\n    assert candidate(flowers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],newFlowers = 50,target = 10,full = 15,partial = 5) == 180\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],newFlowers = 50,target = 8,full = 50,partial = 10) == 770\n    assert candidate(flowers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],newFlowers = 50,target = 8,full = 20,partial = 5) == 215\n    assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 100,target = 5,full = 20,partial = 15) == 240\n    assert candidate(flowers = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],newFlowers = 100,target = 4,full = 100,partial = 50) == 1050\n    assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 1000,target = 5,full = 10,partial = 1) == 100\n    assert candidate(flowers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],newFlowers = 50,target = 5,full = 100,partial = 50) == 1000\n    assert candidate(flowers = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],newFlowers = 150,target = 35,full = 20,partial = 3) == 249\n    assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 1000,target = 10,full = 20,partial = 10) == 270\n    assert candidate(flowers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],newFlowers = 1000,target = 5,full = 100,partial = 50) == 1000\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],newFlowers = 100,target = 10,full = 30,partial = 15) == 555\n    assert candidate(flowers = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],newFlowers = 1000000,target = 100000,full = 100000,partial = 100000) == 8030300000\n    assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],newFlowers = 1000,target = 100,full = 50,partial = 25) == 3175\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 10000000000,target = 1,full = 100,partial = 50) == 1000\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],newFlowers = 500,target = 20,full = 150,partial = 75) == 5775\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],newFlowers = 500,target = 15,full = 25,partial = 10) == 615\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 50,target = 5,full = 10,partial = 3) == 102\n    assert candidate(flowers = [99990, 99991, 99992, 99993, 99994, 99995, 99996, 99997, 99998, 99999],newFlowers = 100000,target = 100000,full = 100000,partial = 100000) == 10000800000\n    assert candidate(flowers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],newFlowers = 100,target = 11,full = 50,partial = 25) == 950\n    assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 100,target = 5,full = 50,partial = 20) == 530\n    assert candidate(flowers = [90, 90, 90, 90, 90, 90, 90, 90, 90, 90],newFlowers = 100,target = 95,full = 1000,partial = 500) == 56000\n    assert candidate(flowers = [90000, 80000, 70000, 60000, 50000],newFlowers = 300000,target = 100000,full = 1000,partial = 500) == 50003500\n    assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 1,target = 1,full = 100,partial = 50) == 1000\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],newFlowers = 300,target = 15,full = 100,partial = 50) == 2600\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 50,target = 10,full = 20,partial = 10) == 270\n    assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 10000000000,target = 2,full = 1,partial = 1) == 10\n    assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],newFlowers = 1000,target = 60,full = 50,partial = 25) == 1925\n    assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 1000,target = 5,full = 100,partial = 10) == 1000\n    assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],newFlowers = 1000,target = 55,full = 50,partial = 10) == 990\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 50,target = 7,full = 20,partial = 5) == 210\n    assert candidate(flowers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],newFlowers = 100,target = 10,full = 20,partial = 5) == 225\n    assert candidate(flowers = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],newFlowers = 1000000,target = 100000,full = 100000,partial = 50000) == 1000000\n    assert candidate(flowers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],newFlowers = 50,target = 10,full = 20,partial = 10) == 270\n    assert candidate(flowers = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],newFlowers = 500,target = 3,full = 20,partial = 10) == 200\n    assert candidate(flowers = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],newFlowers = 500,target = 45,full = 50,partial = 10) == 890\n    assert candidate(flowers = [5, 5, 5, 5, 5],newFlowers = 25,target = 7,full = 50,partial = 5) == 250\n    assert candidate(flowers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],newFlowers = 3000,target = 500,full = 50,partial = 25) == 12925\n    assert candidate(flowers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],newFlowers = 50,target = 10,full = 10,partial = 1) == 100\n    assert candidate(flowers = [50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97],newFlowers = 100000,target = 10000,full = 1000,partial = 500) == 5008500\n    assert candidate(flowers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],newFlowers = 20,target = 6,full = 20,partial = 10) == 230\n    assert candidate(flowers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],newFlowers = 5000,target = 500,full = 1000,partial = 100) == 58900\n    assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],newFlowers = 1000,target = 60,full = 50,partial = 10) == 1040\n    assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 1000,target = 5,full = 100,partial = 50) == 2100\n    assert candidate(flowers = [50, 30, 20, 10, 5],newFlowers = 150,target = 25,full = 10,partial = 5) == 160\n    assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 1000,target = 2,full = 50,partial = 25) == 4250\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 30,target = 6,full = 10,partial = 3) == 105\n    assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 1000,target = 5,full = 100,partial = 50) == 8400\n    assert candidate(flowers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],newFlowers = 100,target = 10,full = 20,partial = 10) == 270\n    assert candidate(flowers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],newFlowers = 1000,target = 40,full = 50,partial = 20) == 1230\n    assert candidate(flowers = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20],newFlowers = 200,target = 25,full = 100,partial = 50) == 2100\n    assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],newFlowers = 500,target = 40,full = 20,partial = 10) == 570\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],newFlowers = 700,target = 20,full = 50,partial = 20) == 1580\n    assert candidate(flowers = [100, 200, 300, 400, 500],newFlowers = 1000,target = 350,full = 15,partial = 5) == 1805\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 15,target = 5,full = 100,partial = 10) == 1000\n    assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],newFlowers = 150,target = 80,full = 150,partial = 75) == 4950\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 30,target = 7,full = 10,partial = 5) == 120\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 1,target = 1,full = 1000,partial = 500) == 10000\n    assert candidate(flowers = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],newFlowers = 200,target = 55,full = 100,partial = 50) == 3600\n    assert candidate(flowers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],newFlowers = 50,target = 10,full = 100,partial = 50) == 1350\n    assert candidate(flowers = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],newFlowers = 1000000,target = 50000,full = 1000,partial = 500) == 25008500\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 250,target = 5,full = 100,partial = 50) == 1100\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],newFlowers = 500,target = 15,full = 75,partial = 35) == 1915\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 50,target = 8,full = 20,partial = 10) == 250\n    assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 100,target = 5,full = 100,partial = 50) == 1100\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 50,target = 7,full = 100,partial = 50) == 1200\n    assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 100,target = 5,full = 50,partial = 25) == 1050\n    assert candidate(flowers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],newFlowers = 250,target = 30,full = 200,partial = 100) == 4700\n    assert candidate(flowers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],newFlowers = 100,target = 7,full = 20,partial = 5) == 210\n    assert candidate(flowers = [1, 2, 3, 4, 5],newFlowers = 1000000,target = 10,full = 100000,partial = 10000) == 500000\n    assert candidate(flowers = [2, 4, 6, 8, 10, 12, 14],newFlowers = 30,target = 15,full = 7,partial = 5) == 71\n    assert candidate(flowers = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],newFlowers = 10000,target = 995,full = 100,partial = 50) == 50600\n    assert candidate(flowers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],newFlowers = 500,target = 75,full = 1000,partial = 100) == 16400\n    assert candidate(flowers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],newFlowers = 5000,target = 750,full = 250,partial = 125) == 97125\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],newFlowers = 200,target = 10,full = 50,partial = 25) == 925\n    assert candidate(flowers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],newFlowers = 50,target = 10,full = 10,partial = 1) == 100\n    assert candidate(flowers = [100000, 99999, 99998, 99997, 99996, 99995],newFlowers = 150000,target = 100000,full = 100000,partial = 100000) == 10000400000\n    assert candidate(flowers = [1, 5, 9, 13, 17, 21],newFlowers = 20,target = 15,full = 10,partial = 3) == 67\n    assert candidate(flowers = [50, 40, 30, 20, 10],newFlowers = 100,target = 35,full = 100,partial = 50) == 2100\n    assert candidate(flowers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],newFlowers = 100,target = 5,full = 5,partial = 2) == 53\n", "comparison": "exact"}, "public_tests": ["[1,3,1,1]\n7\n6\n12\n1", "[2,4,5,3]\n10\n5\n2\n6"], "hints": ["Say we choose k gardens to be complete, is there an optimal way of choosing which gardens to plant more flowers to achieve this?", "For a given k, we should greedily fill-up the k gardens with the most flowers planted already. This gives us the most remaining flowers to fill up the other gardens.", "After sorting flowers, we can thus try every possible k and what is left is to find the highest minimum flowers we can obtain by planting the remaining flowers in the other gardens.", "To find the highest minimum in the other gardens, we can use binary search to find the most optimal way of planting."], "metadata": {"canonical_parameter_names": ["flowers", "newFlowers", "target", "full", "partial"], "leetcode_dataset_entry_point": "Solution().maximumBeauty", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:50+00:00", "tests_total": 113, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "two-pointers", "binary-search", "greedy", "sorting", "enumeration", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maximumBeauty(self, flowers: list[int], newFlowers: int, target: int, full: int, partial: int) -> int:", "container": "Solution", "callable": "maximumBeauty", "parameters": [{"name": "flowers", "type": "list[int]"}, {"name": "newFlowers", "type": "int"}, {"name": "target", "type": "int"}, {"name": "full", "type": "int"}, {"name": "partial", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2235, "task_id": "add-two-integers", "difficulty": "Easy", "problem_description": "Given two integers num1 and num2, return the sum of the two integers.\n\nExample 1:\n\nInput: num1 = 12, num2 = 5\nOutput: 17\nExplanation: num1 is 12, num2 is 5, and their sum is 12 + 5 = 17, so 17 is returned.\n\nExample 2:\n\nInput: num1 = -10, num2 = 4\nOutput: -6\nExplanation: num1 + num2 = -6, so -6 is returned.\n\nConstraints:\n\n- -100 <= num1, num2 <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num1 = 100,num2 = -100) == 0\n    assert candidate(num1 = -10,num2 = 4) == -6\n    assert candidate(num1 = 25,num2 = 25) == 50\n    assert candidate(num1 = -50,num2 = 50) == 0\n    assert candidate(num1 = 99,num2 = 1) == 100\n    assert candidate(num1 = -50,num2 = 25) == -25\n    assert candidate(num1 = -30,num2 = -70) == -100\n    assert candidate(num1 = 100,num2 = 100) == 200\n    assert candidate(num1 = 12,num2 = 5) == 17\n    assert candidate(num1 = 0,num2 = 0) == 0\n    assert candidate(num1 = -100,num2 = -100) == -200\n    assert candidate(num1 = -99,num2 = -1) == -100\n    assert candidate(num1 = 50,num2 = -50) == 0\n    assert candidate(num1 = -45,num2 = -55) == -100\n    assert candidate(num1 = -73,num2 = -27) == -100\n    assert candidate(num1 = 80,num2 = -30) == 50\n    assert candidate(num1 = 23,num2 = -23) == 0\n    assert candidate(num1 = -75,num2 = 20) == -55\n    assert candidate(num1 = 100,num2 = 0) == 100\n    assert candidate(num1 = 0,num2 = -100) == -100\n    assert candidate(num1 = -1,num2 = -99) == -100\n    assert candidate(num1 = -45,num2 = 65) == 20\n    assert candidate(num1 = 22,num2 = 78) == 100\n    assert candidate(num1 = 98,num2 = 2) == 100\n    assert candidate(num1 = 45,num2 = -55) == -10\n    assert candidate(num1 = -75,num2 = 25) == -50\n    assert candidate(num1 = -88,num2 = 12) == -76\n    assert candidate(num1 = -75,num2 = -25) == -100\n    assert candidate(num1 = 1,num2 = 99) == 100\n    assert candidate(num1 = -100,num2 = 0) == -100\n    assert candidate(num1 = 42,num2 = -42) == 0\n    assert candidate(num1 = -49,num2 = 51) == 2\n    assert candidate(num1 = -99,num2 = 1) == -98\n    assert candidate(num1 = 0,num2 = 100) == 100\n    assert candidate(num1 = 45,num2 = -45) == 0\n    assert candidate(num1 = 50,num2 = -60) == -10\n    assert candidate(num1 = 88,num2 = 12) == 100\n    assert candidate(num1 = -45,num2 = 55) == 10\n    assert candidate(num1 = 67,num2 = -33) == 34\n    assert candidate(num1 = -33,num2 = -67) == -100\n    assert candidate(num1 = -30,num2 = 70) == 40\n    assert candidate(num1 = -67,num2 = 33) == -34\n    assert candidate(num1 = 99,num2 = -1) == 98\n    assert candidate(num1 = 73,num2 = 27) == 100\n    assert candidate(num1 = 75,num2 = -25) == 50\n    assert candidate(num1 = -45,num2 = 45) == 0\n    assert candidate(num1 = -100,num2 = 100) == 0\n    assert candidate(num1 = -23,num2 = 23) == 0\n    assert candidate(num1 = 67,num2 = 33) == 100\n    assert candidate(num1 = 50,num2 = 50) == 100\n    assert candidate(num1 = -50,num2 = -50) == -100\n    assert candidate(num1 = 28,num2 = -28) == 0\n    assert candidate(num1 = 45,num2 = 55) == 100\n    assert candidate(num1 = 33,num2 = 67) == 100\n    assert candidate(num1 = 75,num2 = 25) == 100\n    assert candidate(num1 = 49,num2 = 51) == 100\n    assert candidate(num1 = -23,num2 = 77) == 54\n    assert candidate(num1 = 37,num2 = 63) == 100\n    assert candidate(num1 = 29,num2 = 71) == 100\n", "comparison": "exact"}, "public_tests": ["12\n5", "-10\n4"], "hints": [], "metadata": {"canonical_parameter_names": ["num1", "num2"], "leetcode_dataset_entry_point": "Solution().sum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:53+00:00", "tests_total": 59, "tests_dropped": 0, "flags": [], "topic_tags": ["math"]}, "language": "python", "interface": {"raw_signature": "def sum(self, num1: int, num2: int) -> int:", "container": "Solution", "callable": "sum", "parameters": [{"name": "num1", "type": "int"}, {"name": "num2", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2239, "task_id": "find-closest-number-to-zero", "difficulty": "Easy", "problem_description": "Given an integer array nums of size n, return the number with the value closest to 0 in nums. If there are multiple answers, return the number with the largest value.\n\nExample 1:\n\nInput: nums = [-4,-2,1,4,8]\nOutput: 1\nExplanation:\nThe distance from -4 to 0 is |-4| = 4.\nThe distance from -2 to 0 is |-2| = 2.\nThe distance from 1 to 0 is |1| = 1.\nThe distance from 4 to 0 is |4| = 4.\nThe distance from 8 to 0 is |8| = 8.\nThus, the closest number to 0 in the array is 1.\n\nExample 2:\n\nInput: nums = [2,-1,1]\nOutput: 1\nExplanation: 1 and -1 are both the closest numbers to 0, so 1 being larger is returned.\n\nConstraints:\n\n- 1 <= n <= 1000\n- -10^5 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [3, -3, 2, -2, 1, -1]) == 1\n    assert candidate(nums = [100000, -100000, 50000, -50000]) == 50000\n    assert candidate(nums = [100000, -100000, 50000, -50000]) == 50000\n    assert candidate(nums = [7, -10, 4, 3, -20, 2]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n    assert candidate(nums = [0, 5, -5]) == 0\n    assert candidate(nums = [-5, -3, -1, -4, -2]) == -1\n    assert candidate(nums = [0, 1, -1]) == 0\n    assert candidate(nums = [-1]) == -1\n    assert candidate(nums = [-10, -9, 9, 10]) == 9\n    assert candidate(nums = [-5, -5, -5, -5, -5]) == -5\n    assert candidate(nums = [1]) == 1\n    assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3]) == 0\n    assert candidate(nums = [-100000, 100000]) == 100000\n    assert candidate(nums = [-10, -5, 0, 5, 10]) == 0\n    assert candidate(nums = [-10, 10, 0]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5]) == 5\n    assert candidate(nums = [-5, -4, -3, -2, -1]) == -1\n    assert candidate(nums = [-4, -2, 1, 4, 8]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n    assert candidate(nums = [100000, -100000, 50000, -50000, 0]) == 0\n    assert candidate(nums = [0]) == 0\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 1\n    assert candidate(nums = [-100000]) == -100000\n    assert candidate(nums = [-10, -3, -1, 0, 1, 3, 10]) == 0\n    assert candidate(nums = [100000]) == 100000\n    assert candidate(nums = [-10, -5, 0, 5, 10]) == 0\n    assert candidate(nums = [-5, -4, -3, -2, -1]) == -1\n    assert candidate(nums = [5, 3, 1, 4, 2]) == 1\n    assert candidate(nums = [2, -1, 1]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 1\n    assert candidate(nums = [12345, -12345, 11111, -11111, 22222, -22222, 33333, -33333, 44444, -44444, 55555, -55555, 66666, -66666, 77777, -77777, 88888, -88888, 99999, -99999]) == 11111\n    assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, -1, -3, -7, -15, -31, -62, -125, -250, -500, -1000]) == 1\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 7\n    assert candidate(nums = [5000, -5000, 2500, -2500, 1250, -1250, 625, -625, 312, -312, 156, -156]) == 156\n    assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980, -9980, -9981, -9982, -9983, -9984, -9985, -9986, -9987, -9988, -9989, -9990, -9991, -9992, -9993, -9994, -9995, -9996, -9997, -9998, -9999, -10000]) == 9980\n    assert candidate(nums = [-1, -1, -1, -1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 0]) == 0\n    assert candidate(nums = [-1, -2, -3, -4, -5, 0, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums = [-99999, -50000, -10000, -1000, -100, -10, -1, 0, 1, 10, 100, 1000, 10000, 50000, 99999]) == 0\n    assert candidate(nums = [-50, -25, 0, 25, 50, -12, 12, -7, 7, -3, 3, -1, 1]) == 0\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n    assert candidate(nums = [-50000, -49999, 49999, 50000, 0]) == 0\n    assert candidate(nums = [-10000, -9999, -9998, -9997, 9997, 9998, 9999, 10000, 0]) == 0\n    assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20]) == 0\n    assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900]) == 100\n    assert candidate(nums = [50, -50, 25, -25, 12, -12, 6, -6, 3, -3, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [3, -1, -3, 1, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 1\n    assert candidate(nums = [-50000, -25000, -12500, -6250, -3125, -1562, -781, -390, -195, -97, -48, -24, -12, -6, -3, -1, 1, 3, 6, 12, 24, 48, 97, 195, 390, 781, 1562, 3125, 6250, 12500, 25000, 50000]) == 1\n    assert candidate(nums = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100, 5, -5, 15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75, 85, -85, 95, -95]) == 0\n    assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500, 0]) == 0\n    assert candidate(nums = [0, -1, 1, -100000, 100000]) == 0\n    assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == -1\n    assert candidate(nums = [82345, -82345, 67890, -67890, 54321, -54321, 43210, -43210, 32109, -32109, 21098, -21098]) == 21098\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n    assert candidate(nums = [1, -1, 100000, -100000, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 1\n    assert candidate(nums = [-7, -14, -21, -28, -35, -42, -49, -56, -63, -70]) == -7\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [0, -100000, 100000, -99999, 99999]) == 0\n    assert candidate(nums = [-1000, 1000, 0, 500, -500, 250, -250, 125, -125, 62, -62, 31, -31, 15, -15, 7, -7, 3, -3, 1, -1]) == 0\n    assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, -14, 14, -15, 15]) == 1\n    assert candidate(nums = [-100000, -99999, 99999, 100000]) == 99999\n    assert candidate(nums = [1000, 1001, 999, 998, 1002, 997, 1003, 996, 1004, 995, 0, -1, -2, -3, -4]) == 0\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, -100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70]) == 70\n    assert candidate(nums = [-50, -25, 0, 25, 50]) == 0\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 0\n    assert candidate(nums = [98765, 43210, 87654, 32109, 76543, 21098, 65432, 10987, 54321, 9876, 4321, 8765, 3210, 7654, 2109, 6543, 1098, 5432, 987, 432, 876, 321, 765, 210, 654, 109, 543, 98, 43, 87, 32, 76, 21, 65, 10, 5, 0]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 1\n    assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991, -49991, -49992, -49993, -49994, -49995, -49996, -49997, -49998, -49999, -50000]) == 49991\n    assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n    assert candidate(nums = [99998, -99998, 99999, -99999, 0]) == 0\n    assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9]) == 1\n    assert candidate(nums = [-98765, 98765, -87654, 87654, -76543, 76543, -65432, 65432, -54321, 54321, -43210, 43210, -32109, 32109, -21098, 21098, -10987, 10987, -9876, 9876]) == 9876\n    assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 100\n    assert candidate(nums = [-33333, 33333, -66666, 66666, -100000, 100000, 0, 1, -1, 2, -2]) == 0\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970, -100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991, -99990, -99989, -99988, -99987, -99986, -99985, -99984, -99983, -99982, -99981, -99980, -99979, -99978, -99977, -99976, -99975, -99974, -99973, -99972, -99971, -99970]) == 99970\n    assert candidate(nums = [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == -1\n    assert candidate(nums = [50000, -50000, 49999, -49999, 49998, -49998, 100000, -100000]) == 49998\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980, 9979, 9978, 9977, 9976, 9975, 9974, 9973, 9972, 9971, 9970, 9969, 9968, 9967, 9966, 9965, 9964, 9963, 9962, 9961, 9960, 9959, 9958, 9957, 9956, 9955, 9954, 9953, 9952, 9951, 9950, 9949, 9948, 9947, 9946, 9945, 9944, 9943, 9942, 9941, 9940, 9939, 9938, 9937, 9936, 9935, 9934, 9933, 9932, 9931, 9930, 9929, 9928, 9927, 9926, 9925, 9924, 9923, 9922, 9921, 9920, 9919, 9918, 9917, 9916, 9915, 9914, 9913, 9912, 9911, 9910, 9909, 9908, 9907, 9906, 9905, 9904, 9903, 9902, 9901, 9900, 9899, 9898, 9897, 9896, 9895, 9894, 9893, 9892, 9891, 9890, 9889, 9888, 9887, 9886, 9885, 9884, 9883, 9882, 9881, 9880, 9879, 9878, 9877, 9876, 9875, 9874, 9873, 9872, 9871, 9870, 9869, 9868, 9867, 9866, 9865, 9864, 9863, 9862, 9861, 9860, 9859, 9858, 9857, 9856, 9855, 9854, 9853, 9852, 9851, 9850, 9849, 9848, 9847, 9846, 9845, 9844, 9843, 9842, 9841, 9840, 9839, 9838, 9837, 9836, 9835, 9834, 9833, 9832, 9831, 9830, 9829, 9828, 9827, 9826, 9825, 9824, 9823, 9822, 9821, 9820, 9819, 9818, 9817, 9816, 9815, 9814, 9813, 9812, 9811, 9810, 9809, 9808, 9807, 9806, 9805, 9804, 9803, 9802, 9801, 9800]) == 9800\n    assert candidate(nums = [-1000, -500, -250, -125, -62, -31, -15, -7, -3, -1, 1, 3, 7, 15, 31, 62, 125, 250, 500, 1000]) == 1\n    assert candidate(nums = [-5000, 5000, -1000, 1000, -2000, 2000, -3000, 3000, -4000, 4000, -6000, 6000, -7000, 7000, -8000, 8000]) == 1000\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n    assert candidate(nums = [100000, -99999, 99999, -100000, 50000, -49999, 49999, -50000]) == 49999\n    assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n    assert candidate(nums = [-99999, -99998, -99997, 99997, 99998, 99999]) == 99997\n    assert candidate(nums = [-50000, 50000, -49999, 49999, -49998, 49998, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 1\n    assert candidate(nums = [0, -100000, 100000, -99999, 99999, -99998, 99998, -99997, 99997, -99996, 99996, -99995, 99995, -99994, 99994, -99993, 99993, -99992, 99992, -99991, 99991, -99990, 99990, -99989, 99989, -99988, 99988, -99987, 99987, -99986, 99986, -99985, 99985, -99984, 99984, -99983, 99983, -99982, 99982, -99981, 99981, -99980, 99980, -99979, 99979, -99978, 99978, -99977, 99977, -99976, 99976, -99975, 99975, -99974, 99974, -99973, 99973, -99972, 99972, -99971, 99971, -99970, 99970]) == 0\n    assert candidate(nums = [10000, -10000, 5000, -5000, 1000, -1000, 500, -500, 100, -100, 50, -50, 10, -10, 5, -5, 1, -1]) == 1\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [23, -23, 46, -46, 92, -92, 184, -184, 368, -368, 736, -736, 1472, -1472, 2944, -2944]) == 23\n    assert candidate(nums = [-100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991, -99990, -99989, -99988, -99987, -99986, -99985, -99984, -99983, -99982, -99981, -99980, -99979, -99978, -99977, -99976, -99975, -99974, -99973, -99972, -99971, -99970]) == -99970\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 0\n    assert candidate(nums = [100, 200, -150, 150, 0, -50, 50, -200]) == 0\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, -100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90]) == 90\n    assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000]) == 100\n    assert candidate(nums = [99999, -99999, 99998, -99998, 99997, -99997, 99996, -99996, 99995, -99995, 0]) == 0\n    assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 1\n    assert candidate(nums = [98765, -98765, 43210, -43210, 86421, -86421, 12345, -12345, 0]) == 0\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12]) == 1\n    assert candidate(nums = [-1000, -999, -998, 998, 999, 1000, 500, -500, 250, -250]) == 250\n    assert candidate(nums = [99995, 99996, 99997, 99998, 99999, -99995, -99996, -99997, -99998, -99999]) == 99995\n    assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40]) == 5\n    assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 0\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25]) == -1\n    assert candidate(nums = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, -99991, -99992, -99993, -99994, -99995, -99996, -99997, -99998, -99999, -100000]) == 99991\n    assert candidate(nums = [-10000, -5000, -1000, -500, -100, -50, -10, -5, -1, 1, 5, 10, 50, 100, 500, 1000, 5000, 10000]) == 1\n    assert candidate(nums = [-54321, 54321, -12345, 12345, -6789, 6789, -3456, 3456, -789, 789]) == 789\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 1\n    assert candidate(nums = [-99999, 99999, -50000, 50000, -25000, 25000, -12500, 12500, -6250, 6250, -3125, 3125]) == 3125\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20]) == 1\n    assert candidate(nums = [3, 5, -3, -5, 7, -7, 2, -2, 0]) == 0\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [-50000, -25000, -10000, -5000, -1000, -500, -100, -50, -10, -1, 0, 1, 10, 50, 100, 500, 1000, 5000, 10000, 25000, 50000]) == 0\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970]) == 99970\n    assert candidate(nums = [-99999, -99998, -99997, -99996, 99996, 99997, 99998, 99999]) == 99996\n    assert candidate(nums = [-500, -250, 0, 250, 500, -249, 249]) == 0\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 0]) == 0\n    assert candidate(nums = [0, -1, 1, -100000, 100000, -99999, 99999, -10, 10, -5, 5, -2, 2, -3, 3]) == 0\n", "comparison": "exact"}, "public_tests": ["[-4,-2,1,4,8]", "[2,-1,1]"], "hints": ["Keep track of the number closest to 0 as you iterate through the array.", "Ensure that if multiple numbers are closest to 0, you store the one with the largest value."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findClosestNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:59+00:00", "tests_total": 128, "tests_dropped": 1, "flags": ["multiple_answers"], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def findClosestNumber(self, nums: list[int]) -> int:", "container": "Solution", "callable": "findClosestNumber", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2240, "task_id": "number-of-ways-to-buy-pens-and-pencils", "difficulty": "Medium", "problem_description": "You are given an integer total indicating the amount of money you have. You are also given two integers cost1 and cost2 indicating the price of a pen and pencil respectively. You can spend part or all of your money to buy multiple quantities (or none) of each kind of writing utensil.\n\nReturn the number of distinct ways you can buy some number of pens and pencils.\n\nExample 1:\n\nInput: total = 20, cost1 = 10, cost2 = 5\nOutput: 9\nExplanation: The price of a pen is 10 and the price of a pencil is 5.\n- If you buy 0 pens, you can buy 0, 1, 2, 3, or 4 pencils.\n- If you buy 1 pen, you can buy 0, 1, or 2 pencils.\n- If you buy 2 pens, you cannot buy any pencils.\nThe total number of ways to buy pens and pencils is 5 + 3 + 1 = 9.\n\nExample 2:\n\nInput: total = 5, cost1 = 10, cost2 = 10\nOutput: 1\nExplanation: The price of both pens and pencils are 10, which cost more than total, so you cannot buy any writing utensils. Therefore, there is only 1 way: buy 0 pens and 0 pencils.\n\nConstraints:\n\n- 1 <= total, cost1, cost2 <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(total = 20,cost1 = 10,cost2 = 5) == 9\n    assert candidate(total = 1000,cost1 = 1,cost2 = 1) == 501501\n    assert candidate(total = 5,cost1 = 10,cost2 = 10) == 1\n    assert candidate(total = 5,cost1 = 10,cost2 = 10) == 1\n    assert candidate(total = 100,cost1 = 1,cost2 = 1) == 5151\n    assert candidate(total = 50,cost1 = 7,cost2 = 11) == 23\n    assert candidate(total = 100,cost1 = 20,cost2 = 30) == 14\n    assert candidate(total = 50,cost1 = 10,cost2 = 20) == 12\n    assert candidate(total = 1000000,cost1 = 500000,cost2 = 500000) == 6\n    assert candidate(total = 20,cost1 = 10,cost2 = 5) == 9\n    assert candidate(total = 1000000,cost1 = 500000,cost2 = 500000) == 6\n    assert candidate(total = 1000000,cost1 = 500000,cost2 = 300000) == 7\n    assert candidate(total = 10,cost1 = 3,cost2 = 7) == 6\n    assert candidate(total = 10,cost1 = 5,cost2 = 2) == 10\n    assert candidate(total = 1,cost1 = 1,cost2 = 1) == 3\n    assert candidate(total = 50,cost1 = 25,cost2 = 20) == 6\n    assert candidate(total = 100,cost1 = 1,cost2 = 1) == 5151\n    assert candidate(total = 500,cost1 = 250,cost2 = 250) == 6\n    assert candidate(total = 1,cost1 = 2,cost2 = 3) == 1\n    assert candidate(total = 500,cost1 = 5,cost2 = 7) == 3665\n    assert candidate(total = 150,cost1 = 25,cost2 = 15) == 40\n    assert candidate(total = 100,cost1 = 100,cost2 = 100) == 3\n    assert candidate(total = 1234,cost1 = 123,cost2 = 456) == 21\n    assert candidate(total = 800,cost1 = 120,cost2 = 30) == 105\n    assert candidate(total = 100,cost1 = 50,cost2 = 100) == 4\n    assert candidate(total = 100,cost1 = 50,cost2 = 50) == 6\n    assert candidate(total = 1000,cost1 = 100,cost2 = 200) == 36\n    assert candidate(total = 100000,cost1 = 1000,cost2 = 500) == 10201\n    assert candidate(total = 999999,cost1 = 99999,cost2 = 1) == 5500055\n    assert candidate(total = 80,cost1 = 8,cost2 = 5) == 95\n    assert candidate(total = 200,cost1 = 15,cost2 = 4) == 368\n    assert candidate(total = 1000,cost1 = 150,cost2 = 100) == 44\n    assert candidate(total = 100,cost1 = 7,cost2 = 3) == 265\n    assert candidate(total = 1000,cost1 = 150,cost2 = 75) == 56\n    assert candidate(total = 1000000,cost1 = 999999,cost2 = 999999) == 3\n    assert candidate(total = 123456,cost1 = 11111,cost2 = 22222) == 42\n    assert candidate(total = 100000,cost1 = 33333,cost2 = 33333) == 10\n    assert candidate(total = 999999,cost1 = 1000,cost2 = 999) == 501501\n    assert candidate(total = 10000,cost1 = 100,cost2 = 50) == 10201\n    assert candidate(total = 200,cost1 = 50,cost2 = 25) == 25\n    assert candidate(total = 500000,cost1 = 999999,cost2 = 1) == 500001\n    assert candidate(total = 150,cost1 = 5,cost2 = 3) == 796\n    assert candidate(total = 999999,cost1 = 100000,cost2 = 50000) == 110\n    assert candidate(total = 123456,cost1 = 12345,cost2 = 6543) == 109\n    assert candidate(total = 10000,cost1 = 50,cost2 = 30) == 33634\n    assert candidate(total = 500,cost1 = 250,cost2 = 100) == 10\n    assert candidate(total = 100000,cost1 = 1,cost2 = 1) == 5000150001\n    assert candidate(total = 250,cost1 = 75,cost2 = 25) == 26\n    assert candidate(total = 500,cost1 = 150,cost2 = 125) == 11\n    assert candidate(total = 1000,cost1 = 10,cost2 = 1) == 50601\n    assert candidate(total = 999,cost1 = 1,cost2 = 1) == 500500\n    assert candidate(total = 1000,cost1 = 500,cost2 = 250) == 9\n    assert candidate(total = 200,cost1 = 10,cost2 = 100) == 33\n    assert candidate(total = 120,cost1 = 30,cost2 = 20) == 19\n    assert candidate(total = 60,cost1 = 20,cost2 = 30) == 7\n    assert candidate(total = 999999,cost1 = 1,cost2 = 2) == 250000500000\n    assert candidate(total = 300,cost1 = 150,cost2 = 100) == 7\n    assert candidate(total = 150,cost1 = 50,cost2 = 50) == 10\n    assert candidate(total = 1000,cost1 = 333,cost2 = 111) == 22\n    assert candidate(total = 100,cost1 = 25,cost2 = 30) == 11\n    assert candidate(total = 500,cost1 = 150,cost2 = 50) == 26\n    assert candidate(total = 999999,cost1 = 99999,cost2 = 99999) == 66\n    assert candidate(total = 800,cost1 = 400,cost2 = 200) == 9\n    assert candidate(total = 120,cost1 = 40,cost2 = 60) == 7\n    assert candidate(total = 600,cost1 = 100,cost2 = 150) == 19\n    assert candidate(total = 500,cost1 = 250,cost2 = 200) == 6\n    assert candidate(total = 500000,cost1 = 1,cost2 = 2) == 62500500001\n    assert candidate(total = 999999,cost1 = 1,cost2 = 1) == 500000500000\n    assert candidate(total = 75,cost1 = 15,cost2 = 10) == 27\n    assert candidate(total = 200,cost1 = 1,cost2 = 1) == 20301\n    assert candidate(total = 1000,cost1 = 500,cost2 = 100) == 18\n    assert candidate(total = 100,cost1 = 1,cost2 = 2) == 2601\n    assert candidate(total = 70,cost1 = 5,cost2 = 3) == 185\n    assert candidate(total = 300,cost1 = 100,cost2 = 150) == 7\n    assert candidate(total = 1000,cost1 = 300,cost2 = 500) == 7\n    assert candidate(total = 999999,cost1 = 999999,cost2 = 1) == 1000001\n    assert candidate(total = 1000000,cost1 = 1,cost2 = 1) == 500001500001\n    assert candidate(total = 1000000,cost1 = 1,cost2 = 1000000) == 1000002\n    assert candidate(total = 1000,cost1 = 5,cost2 = 3) == 33634\n    assert candidate(total = 5000,cost1 = 50,cost2 = 100) == 2601\n    assert candidate(total = 100000,cost1 = 20000,cost2 = 30000) == 14\n    assert candidate(total = 1000,cost1 = 100,cost2 = 10) == 561\n    assert candidate(total = 100,cost1 = 30,cost2 = 70) == 6\n    assert candidate(total = 100,cost1 = 30,cost2 = 7) == 34\n    assert candidate(total = 123456,cost1 = 123,cost2 = 456) == 136511\n    assert candidate(total = 300,cost1 = 50,cost2 = 25) == 49\n    assert candidate(total = 100,cost1 = 5,cost2 = 3) == 364\n    assert candidate(total = 10000,cost1 = 100,cost2 = 10) == 50601\n    assert candidate(total = 200,cost1 = 150,cost2 = 50) == 7\n    assert candidate(total = 500,cost1 = 100,cost2 = 50) == 36\n    assert candidate(total = 999999,cost1 = 100000,cost2 = 10000) == 550\n    assert candidate(total = 500,cost1 = 100,cost2 = 10) == 156\n    assert candidate(total = 300,cost1 = 50,cost2 = 75) == 19\n    assert candidate(total = 100,cost1 = 99,cost2 = 1) == 103\n    assert candidate(total = 100,cost1 = 25,cost2 = 7) == 39\n    assert candidate(total = 200,cost1 = 7,cost2 = 11) == 285\n    assert candidate(total = 300,cost1 = 150,cost2 = 50) == 12\n    assert candidate(total = 100,cost1 = 50,cost2 = 25) == 9\n    assert candidate(total = 120,cost1 = 20,cost2 = 15) == 33\n    assert candidate(total = 500,cost1 = 200,cost2 = 150) == 8\n    assert candidate(total = 1,cost1 = 1,cost2 = 2) == 2\n", "comparison": "exact"}, "public_tests": ["20\n10\n5", "5\n10\n10"], "hints": ["Fix the number of pencils purchased and calculate the number of ways to buy pens.", "Sum up the number of ways to buy pens for each amount of pencils purchased to get the answer."], "metadata": {"canonical_parameter_names": ["total", "cost1", "cost2"], "leetcode_dataset_entry_point": "Solution().waysToBuyPensPencils", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:01+00:00", "tests_total": 102, "tests_dropped": 1, "flags": [], "topic_tags": ["math", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def waysToBuyPensPencils(self, total: int, cost1: int, cost2: int) -> int:", "container": "Solution", "callable": "waysToBuyPensPencils", "parameters": [{"name": "total", "type": "int"}, {"name": "cost1", "type": "int"}, {"name": "cost2", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2242, "task_id": "maximum-score-of-a-node-sequence", "difficulty": "Hard", "problem_description": "There is an undirected graph with n nodes, numbered from 0 to n - 1.\n\nYou are given a 0-indexed integer array scores of length n where scores[i] denotes the score of node i. You are also given a 2D integer array edges where edges[i] = [a_i, b_i] denotes that there exists an undirected edge connecting nodes a_i and b_i.\n\nA node sequence is valid if it meets the following conditions:\n\n- There is an edge connecting every pair of adjacent nodes in the sequence.\n- No node appears more than once in the sequence.\n\nThe score of a node sequence is defined as the sum of the scores of the nodes in the sequence.\n\nReturn the maximum score of a valid node sequence with a length of 4. If no such sequence exists, return -1.\n\nExample 1:\n\nInput: scores = [5,2,9,8,4], edges = [[0,1],[1,2],[2,3],[0,2],[1,3],[2,4]]\nOutput: 24\nExplanation: The figure above shows the graph and the chosen node sequence [0,1,2,3].\nThe score of the node sequence is 5 + 2 + 9 + 8 = 24.\nIt can be shown that no other node sequence has a score of more than 24.\nNote that the sequences [3,1,2,0] and [1,0,2,3] are also valid and have a score of 24.\nThe sequence [0,3,2,4] is not valid since no edge connects nodes 0 and 3.\n\nExample 2:\n\nInput: scores = [9,20,6,4,11,12], edges = [[0,3],[5,3],[2,4],[1,3]]\nOutput: -1\nExplanation: The figure above shows the graph.\nThere are no valid node sequences of length 4, so we return -1.\n\nConstraints:\n\n- n == scores.length\n- 4 <= n <= 5 * 10^4\n- 1 <= scores[i] <= 10^8\n- 0 <= edges.length <= 5 * 10^4\n- edges[i].length == 2\n- 0 <= a_i, b_i <= n - 1\n- a_i != b_i\n- There are no duplicate edges.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(scores = [5, 2, 9, 8, 4],edges = [[0, 1], [1, 2], [2, 3], [0, 2], [1, 3], [2, 4]]) == 24\n    assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 4\n    assert candidate(scores = [10, 10, 10, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 0]]) == 40\n    assert candidate(scores = [9, 20, 6, 4, 11, 12],edges = [[0, 3], [5, 3], [2, 4], [1, 3]]) == -1\n    assert candidate(scores = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 40\n    assert candidate(scores = [10, 20, 30, 40, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 140\n    assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]]) == 20\n    assert candidate(scores = [10, 10, 10, 10, 10, 10, 10, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 40\n    assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 20\n    assert candidate(scores = [1, 2, 3, 4],edges = [[0, 1], [1, 2], [2, 3]]) == 10\n    assert candidate(scores = [90, 80, 70, 60, 50, 40, 30, 20, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 8], [1, 7], [2, 6], [3, 5]]) == 300\n    assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 5], [6, 7], [8, 9], [0, 4], [1, 3], [2, 5], [4, 6], [5, 7], [0, 8], [1, 9], [4, 7], [6, 8], [7, 9], [0, 5], [1, 6], [2, 4], [3, 7], [0, 7], [1, 8], [2, 9], [3, 6], [4, 8], [5, 9]]) == 340\n    assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]]) == 540\n    assert candidate(scores = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 111100000\n    assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 3400\n    assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 0], [14, 1]]) == 540\n    assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 2], [1, 3], [4, 6], [5, 7], [0, 4], [1, 5], [2, 6], [3, 7], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [0, 8], [1, 6], [2, 7], [3, 8], [4, 9]]) == 34\n    assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0], [0, 5], [5, 10], [10, 15]]) == 4\n    assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 540\n    assert candidate(scores = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 340000000\n    assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 4], [5, 9]]) == 34\n    assert candidate(scores = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 0]]) == 200\n    assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 340\n    assert candidate(scores = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 0]]) == 48\n    assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 19]]) == 4\n    assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]]) == 2200\n    assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 20\n    assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]]) == 180\n    assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1]]) == -1\n    assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 2], [1, 3], [4, 6], [5, 7]]) == 3400\n    assert candidate(scores = [5, 15, 10, 20, 25, 30, 5, 10, 15, 20],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 3], [3, 6], [6, 9], [1, 4], [4, 7]]) == 85\n    assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 0], [19, 1]]) == 74\n    assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 34\n    assert candidate(scores = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 0]]) == 64\n    assert candidate(scores = [5, 10, 15, 20, 25, 30, 35, 40],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [0, 7], [5, 6], [5, 4], [6, 3], [7, 0]]) == 130\n    assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 9], [0, 1], [1, 9], [1, 2], [2, 9], [2, 3], [3, 9], [3, 4], [4, 9], [4, 5], [5, 9], [5, 6], [6, 9], [6, 7], [7, 9], [7, 8], [8, 9]]) == 34\n    assert candidate(scores = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 4], [3, 7], [3, 8]]) == 330000000\n    assert candidate(scores = [50, 20, 30, 40, 10, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 4], [5, 9]]) == 340\n    assert candidate(scores = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 400\n    assert candidate(scores = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 0], [1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 1], [1, 5], [5, 9], [9, 13], [13, 1]]) == 270\n    assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 0]]) == 20\n    assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 0]]) == 3400\n    assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 4\n    assert candidate(scores = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 40\n    assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0], [0, 9], [9, 14], [14, 19], [19, 4], [4, 9], [9, 14], [0, 7], [7, 12], [12, 17]]) == 740\n    assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == 114\n    assert candidate(scores = [9, 8, 7, 6, 5, 4, 3, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8]]) == 30\n    assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [0, 14]]) == 540\n    assert candidate(scores = [100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 2], [2, 4], [4, 6], [6, 0]]) == 400000000\n    assert candidate(scores = [100000000, 99999999, 99999998, 99999997, 99999996, 99999995, 99999994, 99999993],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 7], [1, 3], [2, 4], [0, 5], [1, 6], [0, 6], [2, 7]]) == 399999994\n    assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 9], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [11, 13], [12, 14], [15, 17], [16, 18]]) == 740\n    assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 2], [1, 3], [4, 6], [5, 7], [2, 4], [3, 5]]) == 20\n    assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39]]) == 154\n    assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 0], [8, 1], [9, 2]]) == 3400\n    assert candidate(scores = [100000000, 99999999, 99999998, 99999997, 99999996, 99999995, 99999994, 99999993, 99999992, 99999991, 99999990, 99999989, 99999988, 99999987, 99999986],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 399999994\n    assert candidate(scores = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0], [0, 7], [7, 12], [12, 4], [1, 8], [8, 13]]) == 104\n    assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == 20\n    assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 0]]) == 540\n    assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 4\n    assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 54\n    assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]]) == 340\n    assert candidate(scores = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 144\n    assert candidate(scores = [100, 200, 300, 400, 500],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [0, 2], [1, 3], [2, 0], [3, 1], [4, 2]]) == 1400\n    assert candidate(scores = [100000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 4], [5, 9]]) == 100000024\n    assert candidate(scores = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == 340000000\n    assert candidate(scores = [50, 40, 30, 20, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 140\n    assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0], [0, 7], [7, 12], [12, 4], [1, 8], [8, 13]]) == 54\n    assert candidate(scores = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 340\n    assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 6], [6, 3], [3, 9], [9, 1], [1, 7], [7, 4], [4, 10], [10, 5], [5, 11], [11, 2], [2, 8], [8, 0]]) == 420\n    assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 340\n    assert candidate(scores = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 0], [24, 1]]) == 200\n    assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [1, 7], [2, 8], [2, 9], [3, 10], [3, 11], [4, 12], [4, 13], [5, 14]]) == 310\n    assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14]]) == -1\n    assert candidate(scores = [100, 200, 150, 300, 250, 400, 350, 500, 450, 600],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 4], [4, 8], [8, 3], [3, 7], [7, 2], [2, 6], [6, 1], [1, 5]]) == 1900\n    assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 0], [9, 1]]) == 28\n    assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 19]]) == 74\n    assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [0, 14]]) == 5400\n", "comparison": "exact"}, "public_tests": ["[5,2,9,8,4]\n[[0,1],[1,2],[2,3],[0,2],[1,3],[2,4]]", "[9,20,6,4,11,12]\n[[0,3],[5,3],[2,4],[1,3]]"], "hints": ["For every node sequence of length 4, there are 3 relevant edges. How can we consider valid triplets of edges?", "Fix the middle 2 nodes connected by an edge in the node sequence. Can you determine the other 2 nodes that will give the highest possible score?", "The other 2 nodes must each be connected to one of the middle nodes. If we only consider nodes with the highest scores, how many should we store to ensure we don’t choose duplicate nodes?", "For each node, we should store the 3 adjacent nodes with the highest scores to ensure we can find a sequence with no duplicate nodes via the method above."], "metadata": {"canonical_parameter_names": ["scores", "edges"], "leetcode_dataset_entry_point": "Solution().maximumScore", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:04+00:00", "tests_total": 80, "tests_dropped": 3, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "graph", "sorting", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def maximumScore(self, scores: list[int], edges: list[list[int]]) -> int:", "container": "Solution", "callable": "maximumScore", "parameters": [{"name": "scores", "type": "list[int]"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2243, "task_id": "calculate-digit-sum-of-a-string", "difficulty": "Easy", "problem_description": "You are given a string s consisting of digits and an integer k.\n\nA round can be completed if the length of s is greater than k. In one round, do the following:\n\n1. Divide s into consecutive groups of size k such that the first k characters are in the first group, the next k characters are in the second group, and so on. Note that the size of the last group can be smaller than k.\n2. Replace each group of s with a string representing the sum of all its digits. For example, \"346\" is replaced with \"13\" because 3 + 4 + 6 = 13.\n3. Merge consecutive groups together to form a new string. If the length of the string is greater than k, repeat from step 1.\n\nReturn s after all rounds have been completed.\n\nExample 1:\n\nInput: s = \"11111222223\", k = 3\nOutput: \"135\"\nExplanation:\n- For the first round, we divide s into groups of size 3: \"111\", \"112\", \"222\", and \"23\".\n  Then we calculate the digit sum of each group: 1 + 1 + 1 = 3, 1 + 1 + 2 = 4, 2 + 2 + 2 = 6, and 2 + 3 = 5.\n  So, s becomes \"3\" + \"4\" + \"6\" + \"5\" = \"3465\" after the first round.\n- For the second round, we divide s into \"346\" and \"5\".\n  Then we calculate the digit sum of each group: 3 + 4 + 6 = 13, 5 = 5.\n  So, s becomes \"13\" + \"5\" = \"135\" after second round.\nNow, s.length <= k, so we return \"135\" as the answer.\n\nExample 2:\n\nInput: s = \"00000000\", k = 3\nOutput: \"000\"\nExplanation:\nWe divide s into \"000\", \"000\", and \"00\".\nThen we calculate the digit sum of each group: 0 + 0 + 0 = 0, 0 + 0 + 0 = 0, and 0 + 0 = 0.\ns becomes \"0\" + \"0\" + \"0\" = \"000\", whose length is equal to k, so we return \"000\".\n\nConstraints:\n\n- 1 <= s.length <= 100\n- 2 <= k <= 100\n- s consists of digits only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"00000000\",k = 3) == \"000\"\n    assert candidate(s = \"111\",k = 5) == \"111\"\n    assert candidate(s = \"987654321\",k = 2) == \"36\"\n    assert candidate(s = \"11111222223\",k = 3) == \"135\"\n    assert candidate(s = \"9876543210\",k = 2) == \"36\"\n    assert candidate(s = \"123\",k = 5) == \"123\"\n    assert candidate(s = \"9999999999\",k = 5) == \"4545\"\n    assert candidate(s = \"1234567890\",k = 2) == \"99\"\n    assert candidate(s = \"111\",k = 2) == \"21\"\n    assert candidate(s = \"56789\",k = 4) == \"269\"\n    assert candidate(s = \"999999999999999999\",k = 5) == \"2214\"\n    assert candidate(s = \"9876543210\",k = 5) == \"3510\"\n    assert candidate(s = \"22222222222222222222222222222222\",k = 10) == \"2020204\"\n    assert candidate(s = \"369121518212427303336394245485154576063666972757881848790939699\",k = 12) == \"414756647424\"\n    assert candidate(s = \"222222222222222222222222222222222\",k = 7) == \"165\"\n    assert candidate(s = \"56565656565656565656\",k = 8) == \"444422\"\n    assert candidate(s = \"0123456789012345678901234567890123456789\",k = 10) == \"45454545\"\n    assert candidate(s = \"1001001001001001001001001001001\",k = 5) == \"92\"\n    assert candidate(s = \"55555555555555555555555555555555555555555555555555\",k = 33) == \"16585\"\n    assert candidate(s = \"8888888888888888888888888888888888888888888888888\",k = 18) == \"144144104\"\n    assert candidate(s = \"55555555555555555555555555555555555555555555555555\",k = 5) == \"1816\"\n    assert candidate(s = \"9999999999999999999999999999999999999999999999999\",k = 25) == \"225216\"\n    assert candidate(s = \"111111111111111111111111111111111111111111111111111\",k = 11) == \"111111117\"\n    assert candidate(s = \"13579135791357913579\",k = 3) == \"73\"\n    assert candidate(s = \"0123456789012345678901234567890123456789012345678901234567890\",k = 11) == \"585\"\n    assert candidate(s = \"00000000000000000000\",k = 15) == \"00\"\n    assert candidate(s = \"01234567890123456789012345678901234567890123456789\",k = 12) == \"4650545817\"\n    assert candidate(s = \"99999999999999999999999999999999\",k = 15) == \"13513518\"\n    assert candidate(s = \"246802468024680246802468024680246802468024680246802468024680246\",k = 7) == \"22257\"\n    assert candidate(s = \"11111111111111111111\",k = 20) == \"11111111111111111111\"\n    assert candidate(s = \"19876543210987654321098765432109876543210987654321\",k = 23) == \"10810810\"\n    assert candidate(s = \"3336669991234567890123456789012345678901234567890\",k = 22) == \"1059930\"\n    assert candidate(s = \"555555555555555555555555555555555555555555555555\",k = 4) == \"168\"\n    assert candidate(s = \"4738691209384762938746293874623987462938746293874623987462938\",k = 6) == \"243\"\n    assert candidate(s = \"2222222222222222222222222222222222222222222222\",k = 3) == \"281\"\n    assert candidate(s = \"111222333444555666777888999000111222333444555\",k = 9) == \"184572936\"\n    assert candidate(s = \"9999999999\",k = 4) == \"189\"\n    assert candidate(s = \"432143214321432143214321432143214321432143214321\",k = 6) == \"201612\"\n    assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111111111\",k = 10) == \"59\"\n    assert candidate(s = \"12345678901234567890\",k = 4) == \"9126\"\n    assert candidate(s = \"4321098765432109876543210987654321098765432109876\",k = 7) == \"3415\"\n    assert candidate(s = \"9999999999999999999999999999999999999999999999999999999999999\",k = 2) == \"99\"\n    assert candidate(s = \"5972841563974856321\",k = 4) == \"86\"\n    assert candidate(s = \"111111111111111111111111111111111111111111111111111111111111\",k = 40) == \"4020\"\n    assert candidate(s = \"111222333444555666777888999000111\",k = 8) == \"381\"\n    assert candidate(s = \"10101010101010101010101010101010101010101010101010\",k = 10) == \"55555\"\n    assert candidate(s = \"111111111111111111111111111111111111111111111111111\",k = 25) == \"25251\"\n    assert candidate(s = \"55555555555555555555555555555555555555555555555555\",k = 20) == \"10010050\"\n    assert candidate(s = \"000000000000000000000000000000000000000000000000000\",k = 25) == \"000\"\n    assert candidate(s = \"1234512345123451234512345123451234\",k = 6) == \"2413\"\n    assert candidate(s = \"11111222223333344444\",k = 5) == \"122\"\n    assert candidate(s = \"012345678901234567890123456789012345678901234567890123456789\",k = 5) == \"1314\"\n    assert candidate(s = \"123456789012345678901234567890\",k = 10) == \"454545\"\n    assert candidate(s = \"923847239874239874239874239874239874239874239874239874239874\",k = 10) == \"537\"\n    assert candidate(s = \"9876543210987654321098765432109876543210\",k = 15) == \"805545\"\n    assert candidate(s = \"112233445566778899001122334455667788990011223344\",k = 12) == \"42546638\"\n    assert candidate(s = \"55555555555555555555\",k = 10) == \"5050\"\n    assert candidate(s = \"24681357911131517191\",k = 7) == \"292324\"\n    assert candidate(s = \"123123123123123123123123123123123123123123123123123123123123123123123123123123123123\",k = 22) == \"43444536\"\n    assert candidate(s = \"111122223333444455556666777788889999\",k = 8) == \"279\"\n    assert candidate(s = \"000000000000000000000000000000000000000000000000000000000000\",k = 20) == \"000\"\n    assert candidate(s = \"1111111111222222222233333333334444444444\",k = 8) == \"262\"\n    assert candidate(s = \"11111111111111111111111111111111\",k = 7) == \"77774\"\n    assert candidate(s = \"222444666888000222444666888000\",k = 12) == \"603624\"\n    assert candidate(s = \"123456789123456789123456789123456789123456789\",k = 11) == \"485256609\"\n    assert candidate(s = \"12345678901234567890123456789012345678901234567890\",k = 15) == \"60756030\"\n    assert candidate(s = \"123456789012345678901234567890123456789012345678901234567890\",k = 8) == \"3024\"\n    assert candidate(s = \"13579135791357913579\",k = 6) == \"217\"\n    assert candidate(s = \"43210987654321098765432109876543210987654321098765\",k = 15) == \"55805535\"\n    assert candidate(s = \"111222333444555666777888999\",k = 6) == \"2214\"\n    assert candidate(s = \"10101010101010101010\",k = 5) == \"3232\"\n    assert candidate(s = \"12312312312312312312\",k = 3) == \"21\"\n    assert candidate(s = \"55555555555555555555555555555555\",k = 10) == \"50505010\"\n    assert candidate(s = \"98765432109876543210987654321098765432109876543210\",k = 6) == \"262215\"\n    assert candidate(s = \"1234567890098765432112345678900987654321\",k = 25) == \"10575\"\n    assert candidate(s = \"999999999999999999999999999999999999999999999999999\",k = 10) == \"459\"\n    assert candidate(s = \"99999999999999999999\",k = 9) == \"818118\"\n    assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111\",k = 13) == \"1313131310\"\n    assert candidate(s = \"55555555555555555555555555555555555555555555555555\",k = 10) == \"5050505050\"\n    assert candidate(s = \"87654321098765432109\",k = 6) == \"189\"\n    assert candidate(s = \"0987654321098765432109876543210987654321098765432109876543210987654321\",k = 18) == \"87837966\"\n    assert candidate(s = \"111122223333444455556666777788889999\",k = 5) == \"153\"\n    assert candidate(s = \"48375926195487326594873265984736259847326598473265984732659\",k = 12) == \"6364726064\"\n    assert candidate(s = \"111111111111111111111111111111111111111111111111111\",k = 9) == \"999996\"\n    assert candidate(s = \"987654321098765432109876543210\",k = 11) == \"545328\"\n    assert candidate(s = \"24680246802468024680\",k = 4) == \"5129\"\n    assert candidate(s = \"000111222333444555666777888999\",k = 11) == \"155565\"\n    assert candidate(s = \"101010101010101010101010101010101010101010101010101\",k = 8) == \"4444442\"\n    assert candidate(s = \"00000000000000000000000000000000000000000000000000\",k = 12) == \"00000\"\n    assert candidate(s = \"99999999999999999999999999999999999999999999999999999999999999999999\",k = 20) == \"18018018072\"\n    assert candidate(s = \"56789012345678901234567890\",k = 6) == \"2015\"\n    assert candidate(s = \"111222333444555666777888999000111222333444555666777888999000\",k = 9) == \"4518\"\n    assert candidate(s = \"8888888888888888888888888888888888888888\",k = 2) == \"41\"\n    assert candidate(s = \"99999999999999999999999999999999999999999999999999\",k = 20) == \"18018090\"\n    assert candidate(s = \"0000000000000000000000000000000000000000\",k = 100) == \"0000000000000000000000000000000000000000\"\n    assert candidate(s = \"102030405060708090\",k = 3) == \"711\"\n    assert candidate(s = \"987654321098765432109876543210\",k = 3) == \"99\"\n    assert candidate(s = \"9999999999\",k = 2) == \"99\"\n    assert candidate(s = \"12345678901234567890\",k = 10) == \"4545\"\n    assert candidate(s = \"98765432109876543210987654321098765432109876543210\",k = 18) == \"898551\"\n    assert candidate(s = \"12345678901234567890\",k = 7) == \"282735\"\n    assert candidate(s = \"111222333444555666777888999000111222333444555666777888999000\",k = 10) == \"4113\"\n    assert candidate(s = \"543210543210543210543210543210\",k = 12) == \"303015\"\n    assert candidate(s = \"987654321098765432109876543210987654321098765432109876543210\",k = 12) == \"6258545046\"\n", "comparison": "exact"}, "public_tests": ["\"11111222223\"\n3", "\"00000000\"\n3"], "hints": ["Try simulating the entire process to find the final answer."], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().digitSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:06+00:00", "tests_total": 109, "tests_dropped": 5, "flags": [], "topic_tags": ["string", "simulation"]}, "language": "python", "interface": {"raw_signature": "def digitSum(self, s: str, k: int) -> str:", "container": "Solution", "callable": "digitSum", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2244, "task_id": "minimum-rounds-to-complete-all-tasks", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array tasks, where tasks[i] represents the difficulty level of a task. In each round, you can complete either 2 or 3 tasks of the same difficulty level.\n\nReturn the minimum rounds required to complete all the tasks, or -1 if it is not possible to complete all the tasks.\n\nExample 1:\n\nInput: tasks = [2,2,3,3,2,4,4,4,4,4]\nOutput: 4\nExplanation: To complete all the tasks, a possible plan is:\n- In the first round, you complete 3 tasks of difficulty level 2.\n- In the second round, you complete 2 tasks of difficulty level 3.\n- In the third round, you complete 3 tasks of difficulty level 4.\n- In the fourth round, you complete 2 tasks of difficulty level 4.\nIt can be shown that all the tasks cannot be completed in fewer than 4 rounds, so the answer is 4.\n\nExample 2:\n\nInput: tasks = [2,3,3]\nOutput: -1\nExplanation: There is only 1 task of difficulty level 2, but in each round, you can only complete either 2 or 3 tasks of the same difficulty level. Hence, you cannot complete all the tasks, and the answer is -1.\n\nConstraints:\n\n- 1 <= tasks.length <= 10^5\n- 1 <= tasks[i] <= 10^9\n\nNote: This question is the same as 2870: Minimum Number of Operations to Make Array Empty.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(tasks = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 5\n    assert candidate(tasks = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 5\n    assert candidate(tasks = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 7\n    assert candidate(tasks = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n    assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n    assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 3\n    assert candidate(tasks = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 5\n    assert candidate(tasks = [1]) == -1\n    assert candidate(tasks = [2, 3, 3]) == -1\n    assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n    assert candidate(tasks = [2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 7\n    assert candidate(tasks = [1, 1, 1, 1, 1, 1]) == 2\n    assert candidate(tasks = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 8\n    assert candidate(tasks = [10, 10, 10, 20, 20, 30, 30, 30, 30]) == 4\n    assert candidate(tasks = [2, 2, 3, 3, 2, 4, 4, 4, 4, 4]) == 4\n    assert candidate(tasks = [1, 2, 3, 4, 5]) == -1\n    assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5]) == 3\n    assert candidate(tasks = [5, 5, 5, 5, 5, 5]) == 2\n    assert candidate(tasks = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == 6\n    assert candidate(tasks = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 5\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n    assert candidate(tasks = [1, 1, 1, 2, 2, 2, 3]) == -1\n    assert candidate(tasks = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 4\n    assert candidate(tasks = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 15\n    assert candidate(tasks = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == -1\n    assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 9\n    assert candidate(tasks = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 9\n    assert candidate(tasks = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 11\n    assert candidate(tasks = [2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 13\n    assert candidate(tasks = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 300, 300, 300, 300, 300]) == 10\n    assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 11\n    assert candidate(tasks = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 14\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == 16\n    assert candidate(tasks = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 15\n    assert candidate(tasks = [400, 400, 400, 400, 500, 500, 500, 500, 500, 600, 600, 600, 600, 600, 600, 700, 700, 700, 700, 700, 700, 700]) == 9\n    assert candidate(tasks = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 13\n    assert candidate(tasks = [1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 17\n    assert candidate(tasks = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 16\n    assert candidate(tasks = [3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 14\n    assert candidate(tasks = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == -1\n    assert candidate(tasks = [100, 100, 100, 101, 101, 101, 101, 101, 102, 102, 102, 103, 103, 103, 103, 103, 103, 104, 104]) == 7\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n    assert candidate(tasks = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 16\n    assert candidate(tasks = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 13\n    assert candidate(tasks = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == -1\n    assert candidate(tasks = [7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 11\n    assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == 8\n    assert candidate(tasks = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 19\n    assert candidate(tasks = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 15\n    assert candidate(tasks = [6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 13\n    assert candidate(tasks = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 12\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == -1\n    assert candidate(tasks = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 10\n    assert candidate(tasks = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 14\n    assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 7\n    assert candidate(tasks = [1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 14\n    assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 9\n", "comparison": "exact"}, "public_tests": ["[2,2,3,3,2,4,4,4,4,4]", "[2,3,3]"], "hints": ["Which data structure can you use to store the number of tasks of each difficulty level?", "For any particular difficulty level, what can be the optimal strategy to complete the tasks using minimum rounds?", "When can we not complete all tasks of a difficulty level?"], "metadata": {"canonical_parameter_names": ["tasks"], "leetcode_dataset_entry_point": "Solution().minimumRounds", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:09+00:00", "tests_total": 58, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "counting"]}, "language": "python", "interface": {"raw_signature": "def minimumRounds(self, tasks: list[int]) -> int:", "container": "Solution", "callable": "minimumRounds", "parameters": [{"name": "tasks", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2245, "task_id": "maximum-trailing-zeros-in-a-cornered-path", "difficulty": "Medium", "problem_description": "You are given a 2D integer array grid of size m x n, where each cell contains a positive integer.\n\nA cornered path is defined as a set of adjacent cells with at most one turn. More specifically, the path should exclusively move either horizontally or vertically up to the turn (if there is one), without returning to a previously visited cell. After the turn, the path will then move exclusively in the alternate direction: move vertically if it moved horizontally, and vice versa, also without returning to a previously visited cell.\n\nThe product of a path is defined as the product of all the values in the path.\n\nReturn the maximum number of trailing zeros in the product of a cornered path found in grid.\n\nNote:\n\n- Horizontal movement means moving in either the left or right direction.\n- Vertical movement means moving in either the up or down direction.\n\nExample 1:\n\nInput: grid = [[23,17,15,3,20],[8,1,20,27,11],[9,4,6,2,21],[40,9,1,10,6],[22,7,4,5,3]]\nOutput: 3\nExplanation: The grid on the left shows a valid cornered path.\nIt has a product of 15 * 20 * 6 * 1 * 10 = 18000 which has 3 trailing zeros.\nIt can be shown that this is the maximum trailing zeros in the product of a cornered path.\n\nThe grid in the middle is not a cornered path as it has more than one turn.\nThe grid on the right is not a cornered path as it requires a return to a previously visited cell.\n\nExample 2:\n\nInput: grid = [[4,3,2],[7,6,1],[8,8,8]]\nOutput: 0\nExplanation: The grid is shown in the figure above.\nThere are no cornered paths in the grid that result in a product with a trailing zero.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 10^5\n- 1 <= m * n <= 10^5\n- 1 <= grid[i][j] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == 0\n    assert candidate(grid = [[5, 10, 15], [20, 25, 30], [35, 40, 45]]) == 5\n    assert candidate(grid = [[2, 4, 6, 8], [10, 20, 30, 40], [50, 60, 70, 80]]) == 6\n    assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 0\n    assert candidate(grid = [[23, 17, 15, 3, 20], [8, 1, 20, 27, 11], [9, 4, 6, 2, 21], [40, 9, 1, 10, 6], [22, 7, 4, 5, 3]]) == 3\n    assert candidate(grid = [[10, 5, 2], [6, 3, 8], [4, 7, 1]]) == 2\n    assert candidate(grid = [[2, 5], [10, 5]]) == 2\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 1\n    assert candidate(grid = [[4, 3, 2], [7, 6, 1], [8, 8, 8]]) == 0\n    assert candidate(grid = [[2, 4, 8, 16], [3, 6, 12, 24], [5, 10, 20, 40]]) == 4\n    assert candidate(grid = [[8, 8, 8, 8], [5, 5, 5, 5], [10, 10, 10, 10], [20, 20, 20, 20]]) == 6\n    assert candidate(grid = [[4, 5, 25, 20], [8, 12, 15, 30], [10, 6, 2, 24], [20, 2, 5, 4]]) == 6\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]) == 5\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 6\n    assert candidate(grid = [[5, 10, 15, 20, 25, 30], [35, 40, 45, 50, 55, 60], [65, 70, 75, 80, 85, 90], [95, 100, 105, 110, 115, 120], [125, 130, 135, 140, 145, 150], [155, 160, 165, 170, 175, 180]]) == 13\n    assert candidate(grid = [[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 24\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 3\n    assert candidate(grid = [[25, 50, 75, 100], [5, 10, 15, 20], [1, 2, 3, 4], [125, 250, 375, 500]]) == 9\n    assert candidate(grid = [[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]]) == 1\n    assert candidate(grid = [[12, 15, 25, 20, 5], [2, 4, 16, 40, 100], [10, 20, 30, 40, 50], [5, 10, 15, 20, 25]]) == 9\n    assert candidate(grid = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70], [40, 50, 60, 70, 80], [50, 60, 70, 80, 90]]) == 11\n    assert candidate(grid = [[125, 250, 500], [25, 50, 100], [5, 10, 20]]) == 7\n    assert candidate(grid = [[1, 3, 5, 7, 9], [2, 6, 10, 14, 18], [4, 12, 20, 28, 36], [8, 24, 40, 56, 72], [16, 48, 80, 112, 144]]) == 5\n    assert candidate(grid = [[1, 2, 4, 8, 16], [3, 6, 12, 24, 48], [5, 10, 20, 40, 80], [7, 14, 28, 56, 112], [9, 18, 36, 72, 144]]) == 5\n    assert candidate(grid = [[10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10]]) == 9\n    assert candidate(grid = [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 90]]) == 1\n    assert candidate(grid = [[8, 12, 15, 25, 20, 5], [4, 16, 40, 100, 8, 2], [10, 20, 30, 40, 50, 10], [5, 10, 15, 20, 25, 12], [2, 6, 10, 15, 20, 25], [3, 5, 10, 15, 20, 25]]) == 11\n    assert candidate(grid = [[2, 3, 5, 7, 11], [13, 17, 19, 23, 29], [31, 37, 41, 43, 47], [53, 59, 61, 67, 71], [73, 79, 83, 89, 97]]) == 1\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 0\n    assert candidate(grid = [[2, 4, 8, 16, 32, 64, 128], [1, 3, 5, 7, 9, 11, 13], [25, 50, 75, 100, 125, 150, 175]]) == 11\n    assert candidate(grid = [[4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4]]) == 0\n    assert candidate(grid = [[4, 8, 16, 32, 64], [2, 4, 8, 16, 32], [1, 2, 4, 8, 16], [128, 64, 32, 16, 8], [4, 2, 1, 2, 4]]) == 0\n    assert candidate(grid = [[2, 3, 5, 7, 11], [4, 6, 10, 14, 22], [8, 12, 20, 28, 44], [16, 24, 40, 56, 88], [32, 48, 80, 112, 176]]) == 5\n    assert candidate(grid = [[20, 25, 30, 35, 40], [45, 50, 55, 60, 65], [70, 75, 80, 85, 90], [95, 100, 105, 110, 115], [120, 125, 130, 135, 140]]) == 10\n    assert candidate(grid = [[20, 40, 60, 80, 100], [10, 20, 30, 40, 50], [1, 2, 3, 4, 5], [5, 10, 15, 20, 25], [2, 4, 6, 8, 10]]) == 12\n    assert candidate(grid = [[2, 3, 5, 7, 11, 13, 17, 19, 23, 29], [30, 31, 37, 41, 43, 47, 53, 59, 61, 67], [71, 73, 79, 83, 89, 97, 101, 103, 107, 109]]) == 2\n    assert candidate(grid = [[2, 3, 5, 7], [15, 21, 25, 35], [50, 75, 125, 175], [100, 150, 250, 350]]) == 7\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]]) == 7\n    assert candidate(grid = [[8, 6, 2, 10, 5], [2, 5, 1, 9, 4], [3, 6, 5, 1, 7], [8, 4, 3, 9, 6], [5, 2, 1, 8, 4]]) == 3\n    assert candidate(grid = [[2, 5, 10, 20, 25], [4, 8, 12, 16, 32], [3, 6, 9, 12, 15], [5, 10, 15, 20, 25], [2, 4, 8, 16, 32]]) == 8\n    assert candidate(grid = [[400, 200, 100], [200, 100, 50], [100, 50, 25]]) == 10\n    assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 2\n    assert candidate(grid = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [11, 22, 33, 44, 55]]) == 9\n    assert candidate(grid = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55], [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275], [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33]]) == 14\n    assert candidate(grid = [[32, 32, 32, 32, 32], [64, 64, 64, 64, 64], [128, 128, 128, 128, 128], [256, 256, 256, 256, 256], [512, 512, 512, 512, 512]]) == 0\n    assert candidate(grid = [[12, 18, 15, 30, 25], [16, 20, 24, 10, 5], [21, 14, 7, 35, 40], [8, 12, 16, 40, 25], [15, 25, 35, 20, 40]]) == 9\n    assert candidate(grid = [[999, 1000, 500, 250], [10, 5, 2, 1], [15, 3, 6, 12], [7, 14, 28, 56], [21, 42, 84, 168]]) == 9\n    assert candidate(grid = [[50, 25, 10, 5, 2], [2, 5, 10, 25, 50], [10, 25, 50, 125, 250], [250, 125, 50, 25, 10], [10, 25, 50, 125, 250]]) == 7\n    assert candidate(grid = [[3, 6, 9, 12, 15], [18, 21, 24, 27, 30], [33, 36, 39, 42, 45], [48, 51, 54, 57, 60]]) == 4\n    assert candidate(grid = [[2, 5, 2, 5, 2, 5, 2, 5, 2, 5], [5, 2, 5, 2, 5, 2, 5, 2, 5, 2], [2, 5, 2, 5, 2, 5, 2, 5, 2, 5], [5, 2, 5, 2, 5, 2, 5, 2, 5, 2]]) == 6\n    assert candidate(grid = [[20, 5, 10], [4, 15, 50], [10, 10, 10]]) == 5\n    assert candidate(grid = [[20, 50, 25], [5, 10, 15], [2, 4, 8]]) == 6\n    assert candidate(grid = [[2, 5, 10, 20], [1, 10, 100, 1000], [4, 20, 100, 500], [8, 40, 200, 1000]]) == 13\n    assert candidate(grid = [[12, 25, 50], [6, 100, 200], [15, 5, 5]]) == 6\n    assert candidate(grid = [[2, 4, 8, 16, 32], [3, 6, 12, 24, 48], [5, 10, 20, 40, 80], [15, 30, 60, 120, 240], [45, 90, 180, 360, 720]]) == 7\n    assert candidate(grid = [[2, 5, 2, 5, 2, 5, 2, 5, 2, 5], [5, 2, 5, 2, 5, 2, 5, 2, 5, 2], [2, 5, 2, 5, 2, 5, 2, 5, 2, 5], [5, 2, 5, 2, 5, 2, 5, 2, 5, 2], [2, 5, 2, 5, 2, 5, 2, 5, 2, 5], [5, 2, 5, 2, 5, 2, 5, 2, 5, 2]]) == 7\n    assert candidate(grid = [[100, 200, 300, 400, 500], [2, 4, 6, 8, 10], [5, 10, 15, 20, 25], [10, 20, 30, 40, 50]]) == 15\n    assert candidate(grid = [[2, 3, 5, 7, 11], [13, 17, 19, 23, 29], [31, 37, 41, 43, 47], [53, 59, 61, 67, 71], [73, 79, 83, 89, 97]]) == 1\n    assert candidate(grid = [[2, 3, 5, 7, 11, 13, 17, 19, 23, 29], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [4, 8, 12, 16, 20, 24, 28, 32, 36, 40], [25, 50, 75, 100, 125, 150, 175, 200, 225, 250], [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]]) == 15\n    assert candidate(grid = [[1000, 1000, 1000], [1000, 1000, 1000], [1000, 1000, 1000]]) == 15\n    assert candidate(grid = [[12, 15, 20, 25, 30], [24, 30, 35, 40, 45], [50, 55, 60, 65, 70], [75, 80, 85, 90, 95], [100, 105, 110, 115, 120]]) == 11\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [3, 4, 5, 6, 7, 8, 9, 10, 1, 2], [4, 5, 6, 7, 8, 9, 10, 1, 2, 3], [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]]) == 3\n    assert candidate(grid = [[998, 999, 1000], [1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == 4\n    assert candidate(grid = [[2, 4, 8, 16, 32], [3, 6, 12, 24, 48], [5, 10, 20, 40, 80], [7, 14, 28, 56, 112], [11, 22, 44, 88, 176]]) == 5\n    assert candidate(grid = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [25, 50, 75, 100, 125, 150, 175, 200, 225, 250], [3, 6, 9, 12, 15, 18, 21, 24, 27, 30], [35, 70, 105, 140, 175, 210, 245, 280, 315, 350], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]]) == 16\n    assert candidate(grid = [[6, 2, 3, 10, 15], [2, 4, 5, 20, 25], [3, 6, 9, 30, 45], [4, 8, 12, 40, 60], [5, 10, 15, 50, 75]]) == 9\n    assert candidate(grid = [[25, 16, 4, 2], [5, 10, 20, 8], [1, 12, 6, 4], [3, 6, 9, 15]]) == 5\n    assert candidate(grid = [[4, 3, 2, 1, 5], [7, 6, 1, 8, 9], [8, 8, 8, 1, 2], [1, 1, 1, 3, 4]]) == 1\n    assert candidate(grid = [[8, 16, 32, 64, 128], [4, 8, 16, 32, 64], [2, 4, 8, 16, 32], [1, 2, 4, 8, 16], [1, 1, 1, 1, 2]]) == 0\n    assert candidate(grid = [[2, 5, 10, 15], [20, 25, 30, 35], [40, 45, 50, 55], [60, 65, 70, 75]]) == 7\n    assert candidate(grid = [[5, 10, 15, 20, 25], [1, 2, 3, 4, 5], [6, 12, 18, 24, 30], [7, 14, 21, 28, 35], [8, 16, 24, 32, 40]]) == 7\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 3\n    assert candidate(grid = [[1, 2, 4, 8, 16, 32, 64, 128, 256, 512], [512, 256, 128, 64, 32, 16, 8, 4, 2, 1], [1, 5, 10, 15, 20, 25, 30, 35, 40, 45], [45, 40, 35, 30, 25, 20, 15, 10, 5, 1]]) == 11\n    assert candidate(grid = [[12, 34, 56, 78, 90], [23, 45, 67, 89, 101], [123, 145, 167, 189, 201], [11, 22, 33, 44, 55], [66, 77, 88, 99, 110]]) == 3\n    assert candidate(grid = [[4, 8, 16, 32, 64, 128, 256], [3, 6, 12, 24, 48, 96, 192], [5, 10, 20, 40, 80, 160, 320], [7, 14, 28, 56, 112, 224, 448]]) == 7\n    assert candidate(grid = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 3\n", "comparison": "exact"}, "public_tests": ["[[23,17,15,3,20],[8,1,20,27,11],[9,4,6,2,21],[40,9,1,10,6],[22,7,4,5,3]]", "[[4,3,2],[7,6,1],[8,8,8]]"], "hints": ["What actually tells us the trailing zeros of the product of a path?", "It is the sum of the exponents of 2 and sum of the exponents of 5 of the prime factorizations of the numbers on that path. The smaller of the two is the answer for that path.", "We can then treat each cell as the elbow point and calculate the largest minimum (sum of 2 exponents, sum of 5 exponents) from the combination of top-left, top-right, bottom-left and bottom-right.", "To do this efficiently, we should use the prefix sum technique."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maxTrailingZeros", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:11+00:00", "tests_total": 84, "tests_dropped": 8, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "matrix", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maxTrailingZeros(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "maxTrailingZeros", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2246, "task_id": "longest-path-with-different-adjacent-characters", "difficulty": "Hard", "problem_description": "You are given a tree (i.e. a connected, undirected graph that has no cycles) rooted at node 0 consisting of n nodes numbered from 0 to n - 1. The tree is represented by a 0-indexed array parent of size n, where parent[i] is the parent of node i. Since node 0 is the root, parent[0] == -1.\n\nYou are also given a string s of length n, where s[i] is the character assigned to node i.\n\nReturn the length of the longest path in the tree such that no pair of adjacent nodes on the path have the same character assigned to them.\n\nExample 1:\n\nInput: parent = [-1,0,0,1,1,2], s = \"abacbe\"\nOutput: 3\nExplanation: The longest path where each two adjacent nodes have different characters in the tree is the path: 0 -> 1 -> 3. The length of this path is 3, so 3 is returned.\nIt can be proven that there is no longer path that satisfies the conditions.\n\nExample 2:\n\nInput: parent = [-1,0,0,0], s = \"aabc\"\nOutput: 3\nExplanation: The longest path where each two adjacent nodes have different characters is the path: 2 -> 0 -> 3. The length of this path is 3, so 3 is returned.\n\nConstraints:\n\n- n == parent.length == s.length\n- 1 <= n <= 10^5\n- 0 <= parent[i] <= n - 1 for all i >= 1\n- parent[0] == -1\n- parent represents a valid tree.\n- s consists of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(parent = [-1, 0, 0, 2, 2, 2],s = \"abbccc\") == 4\n    assert candidate(parent = [-1, 0, 0, 0],s = \"aabc\") == 3\n    assert candidate(parent = [-1, 0, 0, 1, 1, 2],s = \"abacbe\") == 3\n    assert candidate(parent = [-1, 0, 1, 2, 3, 4, 5],s = \"abcdefg\") == 7\n    assert candidate(parent = [-1, 0, 0, 0, 0, 0, 0],s = \"abcdefg\") == 3\n    assert candidate(parent = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],s = \"aabbaaccddcceeddffgeee\") == 5\n    assert candidate(parent = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 4],s = \"abcdefghij\") == 6\n    assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 4, 5, 6],s = \"aabbccddeee\") == 5\n    assert candidate(parent = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7],s = \"abcdefghijklmnopqrstuvwx\") == 7\n    assert candidate(parent = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3],s = \"aababbccdd\") == 3\n    assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],s = \"abcdefghij\") == 6\n    assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4],s = \"aaabbbcccdd\") == 5\n", "comparison": "exact"}, "public_tests": ["[-1,0,0,1,1,2]\n\"abacbe\"", "[-1,0,0,0]\n\"aabc\""], "hints": ["Do a DFS from the root. At each node, calculate the longest path we can make from two branches of that subtree.", "To do that, we need to find the length of the longest path from each of the node’s children."], "metadata": {"canonical_parameter_names": ["parent", "s"], "leetcode_dataset_entry_point": "Solution().longestPath", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:14+00:00", "tests_total": 49, "tests_dropped": 37, "flags": ["has_images"], "topic_tags": ["array", "string", "tree", "depth-first-search", "graph", "topological-sort"]}, "language": "python", "interface": {"raw_signature": "def longestPath(self, parent: list[int], s: str) -> int:", "container": "Solution", "callable": "longestPath", "parameters": [{"name": "parent", "type": "list[int]"}, {"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2248, "task_id": "intersection-of-multiple-arrays", "difficulty": "Easy", "problem_description": "Given a 2D integer array nums where nums[i] is a non-empty array of distinct positive integers, return the list of integers that are present in each array of nums sorted in ascending order.\n\nExample 1:\n\nInput: nums = [[3,1,2,4,5],[1,2,3,4],[3,4,5,6]]\nOutput: [3,4]\nExplanation:\nThe only integers present in each of nums[0] = [3,1,2,4,5], nums[1] = [1,2,3,4], and nums[2] = [3,4,5,6] are 3 and 4, so we return [3,4].\n\nExample 2:\n\nInput: nums = [[1,2,3],[4,5,6]]\nOutput: []\nExplanation:\nThere does not exist any integer present both in nums[0] and nums[1], so we return an empty list [].\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 1 <= sum(nums[i].length) <= 1000\n- 1 <= nums[i][j] <= 1000\n- All the values of nums[i] are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [30, 60, 70]]) == [30]\n    assert candidate(nums = [[3, 1, 2, 4, 5], [1, 2, 3, 4], [3, 4, 5, 6]]) == [3, 4]\n    assert candidate(nums = [[10, 20, 30], [20, 30, 40], [30, 40, 50]]) == [30]\n    assert candidate(nums = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) == []\n    assert candidate(nums = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7]]) == [3, 4, 5]\n    assert candidate(nums = [[5, 10], [10, 15], [15, 20], [20, 25], [5, 25]]) == []\n    assert candidate(nums = [[10, 20, 30], [10, 20, 40], [10, 30, 40]]) == [10]\n    assert candidate(nums = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]) == [3, 4]\n    assert candidate(nums = [[1, 2], [2, 3], [3, 4]]) == []\n    assert candidate(nums = [[1, 2, 3, 4, 5], [2, 3, 5, 7], [3, 5, 8, 9]]) == [3, 5]\n    assert candidate(nums = [[1, 2, 3], [4, 5, 6]]) == []\n    assert candidate(nums = [[10, 20, 30], [10, 20, 40], [10, 30, 50]]) == [10]\n    assert candidate(nums = [[2, 4, 6, 8, 10], [2, 4, 6, 8, 10, 12], [2, 4, 6, 8, 10, 12, 14], [2, 4, 6, 8, 10, 12, 14, 16]]) == [2, 4, 6, 8, 10]\n    assert candidate(nums = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 1, 2]]) == [1, 2, 3]\n    assert candidate(nums = [[1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 7]]) == [1, 2, 3]\n    assert candidate(nums = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [9, 10, 11, 12, 1], [1, 3, 5, 7, 9]]) == []\n    assert candidate(nums = [[5, 10, 15, 20, 25], [15, 20, 25, 30, 35], [20, 25, 30, 35, 40], [25, 30, 35, 40, 45], [30, 35, 40, 45, 50]]) == []\n    assert candidate(nums = [[7, 14, 21, 28, 35], [14, 21, 28, 42, 56], [21, 28, 35, 42, 56, 70]]) == [21, 28]\n    assert candidate(nums = [[1, 3, 5, 7, 9], [3, 5, 7, 9, 11], [5, 7, 9, 11, 13], [7, 9, 11, 13, 15]]) == [7, 9]\n    assert candidate(nums = [[10, 20, 30], [30, 40, 50], [20, 30, 40], [30, 50, 60]]) == [30]\n    assert candidate(nums = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [30, 50, 60]]) == [30]\n    assert candidate(nums = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60], [50, 60, 70], [60, 70, 80], [70, 80, 90], [80, 90, 100], [90, 100, 110]]) == []\n    assert candidate(nums = [[10, 20, 30, 40, 50], [10, 30, 50, 70], [10, 30, 50, 90]]) == [10, 30, 50]\n    assert candidate(nums = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 10]]) == []\n    assert candidate(nums = [[100, 200, 300], [300, 400, 500], [500, 600, 700], [700, 800, 900], [900, 1000, 100]]) == []\n    assert candidate(nums = [[5, 10, 15, 20], [10, 15, 25, 30], [15, 20, 30, 35], [20, 25, 30, 35]]) == []\n    assert candidate(nums = [[500, 501, 502, 503, 504, 505], [503, 504, 505, 506, 507, 508], [505, 506, 507, 508, 509, 510], [507, 508, 509, 510, 511, 512], [509, 510, 511, 512, 513, 514]]) == []\n    assert candidate(nums = [[7, 11, 13], [11, 13, 15], [11, 13, 17], [11, 13, 19]]) == [11, 13]\n    assert candidate(nums = [[5, 10, 15, 20], [5, 20, 25, 30], [5, 10, 20, 35], [5, 10, 15, 20, 40]]) == [5, 20]\n    assert candidate(nums = [[999], [999, 998], [999, 998, 997], [999, 998, 997, 996]]) == [999]\n    assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]) == [3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [[5, 10, 15], [10, 15, 20], [15, 20, 25], [20, 25, 30], [25, 30, 35]]) == []\n    assert candidate(nums = [[1, 3, 5, 7, 9], [3, 5, 7, 9, 11], [5, 7, 9, 11, 13], [7, 9, 11, 13, 15], [9, 11, 13, 15, 17]]) == [9]\n    assert candidate(nums = [[5, 15, 25], [5, 25, 35], [25, 35, 45], [15, 25, 35], [5, 15, 25, 35]]) == [25]\n    assert candidate(nums = [[100, 200, 300], [100, 400, 500], [100, 600, 700], [100, 800, 900]]) == [100]\n    assert candidate(nums = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [1, 5, 9, 13, 17]]) == [1, 5]\n    assert candidate(nums = [[100, 200, 300, 400, 500], [100, 200, 300, 400, 600], [100, 200, 300, 500, 600], [100, 200, 400, 500, 600]]) == [100, 200]\n    assert candidate(nums = [[1, 3, 5, 7, 9], [2, 3, 5, 8, 9], [3, 4, 5, 7, 9], [3, 5, 6, 7, 9]]) == [3, 5, 9]\n    assert candidate(nums = [[10, 20, 30], [30, 40, 50], [10, 30, 50, 70], [30, 80, 90, 100]]) == [30]\n    assert candidate(nums = [[100, 200, 300], [200, 300, 400], [300, 400, 500], [400, 500, 600]]) == []\n    assert candidate(nums = [[100, 200, 300], [200, 300, 400], [300, 400, 500], [400, 500, 600], [500, 600, 700]]) == []\n    assert candidate(nums = [[10, 20, 30, 40], [20, 30, 40, 50], [30, 40, 50, 60], [40, 50, 60, 70]]) == [40]\n    assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]]) == [9, 10]\n    assert candidate(nums = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == []\n    assert candidate(nums = [[5, 10, 15, 20, 25], [15, 20, 25, 30, 35], [20, 25, 30, 35, 40], [25, 30, 35, 40, 45]]) == [25]\n    assert candidate(nums = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 3, 5, 7, 11, 13, 17, 19, 23, 29], [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]]) == [3, 5, 7, 11, 13, 17, 19]\n    assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8, 10], [3, 6, 9, 12], [6, 12, 18]]) == [6]\n    assert candidate(nums = [[10, 20, 30], [10, 20, 30, 40], [10, 20, 30, 40, 50], [10, 20, 30, 40, 50, 60]]) == [10, 20, 30]\n    assert candidate(nums = [[50, 100, 150, 200], [100, 150, 200, 250], [150, 200, 250, 300], [200, 250, 300, 350], [250, 300, 350, 400]]) == []\n    assert candidate(nums = [[100, 200, 300], [101, 201, 301], [102, 202, 302], [103, 203, 303], [104, 204, 304], [105, 205, 305]]) == []\n    assert candidate(nums = [[100, 200, 300], [200, 300, 400], [300, 400, 500], [300, 600, 900]]) == [300]\n    assert candidate(nums = [[7, 14, 21, 28], [14, 21, 28, 35], [21, 28, 35, 42], [28, 35, 42, 49]]) == [28]\n    assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == []\n    assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]]) == [4, 8]\n    assert candidate(nums = [[300, 301, 302, 303, 304, 305], [300, 301, 302, 303, 304, 305, 306], [300, 301, 302, 303, 304, 305, 307, 308]]) == [300, 301, 302, 303, 304, 305]\n    assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 2, 3, 4, 5]]) == []\n    assert candidate(nums = [[999, 1000], [1000, 999], [999, 1000, 998], [1000, 999, 998], [998, 999, 1000], [998, 1000, 999]]) == [999, 1000]\n    assert candidate(nums = [[1, 1000], [1, 999], [1, 998], [1, 997], [1, 996]]) == [1]\n    assert candidate(nums = [[999, 1000], [999], [999, 1000, 998], [998, 999, 997], [999, 998, 997, 1000]]) == [999]\n    assert candidate(nums = [[2, 4, 6, 8, 10, 12], [4, 8, 12, 16, 20], [6, 12, 18, 24, 30], [8, 16, 24, 32, 40], [10, 20, 30, 40, 50]]) == []\n    assert candidate(nums = [[5, 15, 25, 35, 45], [15, 25, 35, 45, 55], [5, 15, 25, 35, 45, 65], [15, 25, 35, 45, 75]]) == [15, 25, 35, 45]\n    assert candidate(nums = [[11, 22, 33, 44, 55], [22, 33, 44, 55, 66], [33, 44, 55, 66, 77], [44, 55, 66, 77, 88], [55, 66, 77, 88, 99]]) == [55]\n    assert candidate(nums = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 5, 9], [2, 6, 10]]) == []\n    assert candidate(nums = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [20, 30, 40, 50, 60, 70, 80, 90, 100, 110], [30, 40, 50, 60, 70, 80, 90, 100, 110, 120]]) == [30, 40, 50, 60, 70, 80, 90, 100]\n    assert candidate(nums = [[10, 20, 30, 40], [10, 20, 50], [10, 30, 40, 50]]) == [10]\n    assert candidate(nums = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70], [40, 50, 60, 70, 80], [50, 60, 70, 80, 90]]) == [50]\n    assert candidate(nums = [[7, 14, 21, 28], [14, 21, 28, 35], [21, 28, 35, 42], [28, 35, 42, 49], [35, 42, 49, 56], [42, 49, 56, 63]]) == []\n    assert candidate(nums = [[1], [2], [3], [4], [5]]) == []\n    assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [2, 4, 6, 8, 10, 12, 14], [1, 3, 5, 7, 9, 11, 13, 15]]) == []\n    assert candidate(nums = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60]]) == []\n    assert candidate(nums = [[100], [100, 200], [100, 200, 300], [100, 200, 300, 400], [100, 200, 300, 400, 500]]) == [100]\n    assert candidate(nums = [[1], [1, 2], [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5]]) == [1]\n    assert candidate(nums = [[1, 3, 5, 7, 9], [2, 3, 5, 8, 9], [3, 5, 9, 11, 13], [3, 9, 15, 18, 21]]) == [3, 9]\n    assert candidate(nums = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [10, 15, 20, 25, 30, 35, 40, 45, 50, 55], [15, 20, 25, 30, 35, 40, 45, 50, 55, 60], [20, 25, 30, 35, 40, 45, 50, 55, 60, 65]]) == [20, 25, 30, 35, 40, 45, 50]\n    assert candidate(nums = [[500, 501, 502, 503, 504], [501, 502, 503, 504, 505], [502, 503, 504, 505, 506], [503, 504, 505, 506, 507]]) == [503, 504]\n    assert candidate(nums = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10, 1], [1, 11, 12], [12, 2, 13], [13, 14, 3]]) == []\n    assert candidate(nums = [[1, 10, 100, 1000], [10, 100, 1000, 200], [100, 1000, 200, 300], [1000, 200, 300, 400]]) == [1000]\n    assert candidate(nums = [[7, 14, 21, 28, 35], [14, 28, 42, 56, 70], [21, 42, 63, 84, 105], [14, 21, 28, 35, 42]]) == []\n    assert candidate(nums = [[7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12], [11, 12, 13]]) == []\n    assert candidate(nums = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 4, 7], [2, 5, 8], [3, 6, 9]]) == []\n    assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]) == [3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [[5, 10, 15, 20, 25], [10, 15, 20, 25, 30], [15, 20, 25, 30, 35], [20, 25, 30, 35, 40]]) == [20, 25]\n    assert candidate(nums = [[100, 200, 300, 400], [400, 500, 600, 700], [300, 400, 500, 600], [400, 600, 800, 900]]) == [400]\n    assert candidate(nums = [[500], [500, 501, 502], [500, 502, 503], [500, 501, 503]]) == [500]\n    assert candidate(nums = [[101, 202, 303], [202, 303, 404], [303, 404, 505], [404, 505, 606], [505, 606, 707], [606, 707, 808], [707, 808, 909]]) == []\n    assert candidate(nums = [[7, 14, 21], [14, 21, 28], [21, 28, 35], [7, 14, 21, 28, 35]]) == [21]\n", "comparison": "exact"}, "public_tests": ["[[3,1,2,4,5],[1,2,3,4],[3,4,5,6]]", "[[1,2,3],[4,5,6]]"], "hints": ["Keep a count of the number of times each integer occurs in nums.", "Since all integers of nums[i] are distinct, if an integer is present in each array, its count will be equal to the total number of arrays."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().intersection", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:18+00:00", "tests_total": 93, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "hash-table", "sorting", "counting"]}, "language": "python", "interface": {"raw_signature": "def intersection(self, nums: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "intersection", "parameters": [{"name": "nums", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2249, "task_id": "count-lattice-points-inside-a-circle", "difficulty": "Medium", "problem_description": "Given a 2D integer array circles where circles[i] = [x_i, y_i, r_i] represents the center (x_i, y_i) and radius r_i of the i^th circle drawn on a grid, return the number of lattice points that are present inside at least one circle.\n\nNote:\n\n- A lattice point is a point with integer coordinates.\n- Points that lie on the circumference of a circle are also considered to be inside it.\n\nExample 1:\n\nInput: circles = [[2,2,1]]\nOutput: 5\nExplanation:\nThe figure above shows the given circle.\nThe lattice points present inside the circle are (1, 2), (2, 1), (2, 2), (2, 3), and (3, 2) and are shown in green.\nOther points such as (1, 1) and (1, 3), which are shown in red, are not considered inside the circle.\nHence, the number of lattice points present inside at least one circle is 5.\n\nExample 2:\n\nInput: circles = [[2,2,2],[3,4,1]]\nOutput: 16\nExplanation:\nThe figure above shows the given circles.\nThere are exactly 16 lattice points which are present inside at least one circle.\nSome of them are (0, 2), (2, 0), (2, 4), (3, 2), and (4, 4).\n\nConstraints:\n\n- 1 <= circles.length <= 200\n- circles[i].length == 3\n- 1 <= x_i, y_i <= 100\n- 1 <= r_i <= min(x_i, y_i)\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(circles = [[1, 1, 1], [2, 2, 2], [3, 3, 3]]) == 33\n    assert candidate(circles = [[10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5]]) == 276\n    assert candidate(circles = [[2, 2, 1]]) == 5\n    assert candidate(circles = [[10, 10, 5], [20, 20, 5], [30, 30, 5]]) == 243\n    assert candidate(circles = [[2, 2, 2], [3, 4, 1]]) == 16\n    assert candidate(circles = [[100, 100, 1]]) == 5\n    assert candidate(circles = [[100, 100, 50]]) == 7845\n    assert candidate(circles = [[50, 50, 50]]) == 7845\n    assert candidate(circles = [[50, 50, 40], [60, 60, 10]]) == 5025\n    assert candidate(circles = [[100, 100, 100]]) == 31417\n    assert candidate(circles = [[1, 1, 1]]) == 5\n    assert candidate(circles = [[5, 5, 1], [5, 5, 2], [5, 5, 3]]) == 29\n    assert candidate(circles = [[10, 10, 5]]) == 81\n    assert candidate(circles = [[50, 50, 10], [40, 40, 10], [30, 30, 10]]) == 833\n    assert candidate(circles = [[1, 1, 1], [3, 3, 1]]) == 10\n    assert candidate(circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1]]) == 11\n    assert candidate(circles = [[50, 50, 20], [60, 60, 10]]) == 1314\n    assert candidate(circles = [[10, 10, 1], [20, 20, 1], [30, 30, 1]]) == 15\n    assert candidate(circles = [[10, 10, 5], [20, 20, 10], [30, 30, 15]]) == 950\n    assert candidate(circles = [[50, 50, 50], [50, 50, 30]]) == 7845\n    assert candidate(circles = [[50, 50, 10], [50, 60, 10], [50, 70, 10], [50, 80, 10], [50, 90, 10], [50, 100, 10], [50, 40, 10], [50, 30, 10], [50, 20, 10], [50, 10, 10]]) == 2027\n    assert candidate(circles = [[100, 100, 10], [90, 90, 15], [80, 80, 20], [70, 70, 25]]) == 2685\n    assert candidate(circles = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5], [50, 50, 5], [60, 60, 5], [70, 70, 5], [80, 80, 5], [90, 90, 5]]) == 729\n    assert candidate(circles = [[30, 30, 5], [40, 40, 5], [50, 50, 5], [60, 60, 5], [70, 70, 5], [80, 80, 5], [90, 90, 5]]) == 567\n    assert candidate(circles = [[50, 50, 20], [50, 50, 15], [50, 50, 10], [50, 50, 5]]) == 1257\n    assert candidate(circles = [[10, 10, 10], [10, 20, 10], [10, 30, 10], [10, 40, 10], [10, 50, 10], [10, 60, 10]]) == 1267\n    assert candidate(circles = [[1, 1, 1], [99, 1, 1], [1, 99, 1], [99, 99, 1], [50, 50, 5]]) == 101\n    assert candidate(circles = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5], [50, 50, 5], [60, 60, 5], [70, 70, 5], [80, 80, 5], [90, 90, 5], [100, 100, 5]]) == 810\n    assert candidate(circles = [[50, 50, 20], [60, 50, 20], [70, 50, 20], [80, 50, 20]]) == 2433\n    assert candidate(circles = [[25, 25, 10], [25, 75, 10], [75, 25, 10], [75, 75, 10]]) == 1268\n    assert candidate(circles = [[50, 50, 1], [50, 50, 2], [50, 50, 3], [50, 50, 4], [50, 50, 5]]) == 81\n    assert candidate(circles = [[10, 10, 5], [10, 20, 5], [10, 30, 5], [10, 40, 5], [10, 50, 5], [10, 60, 5]]) == 481\n    assert candidate(circles = [[30, 30, 10], [60, 30, 10], [30, 60, 10], [60, 60, 10], [45, 45, 15]]) == 1837\n    assert candidate(circles = [[50, 50, 20], [50, 70, 20], [50, 30, 20], [30, 50, 20], [70, 50, 20]]) == 4113\n    assert candidate(circles = [[1, 50, 1], [50, 1, 1], [50, 99, 1], [99, 50, 1]]) == 20\n    assert candidate(circles = [[10, 10, 10], [20, 10, 10], [30, 10, 10], [40, 10, 10], [50, 10, 10], [60, 10, 10]]) == 1267\n    assert candidate(circles = [[10, 10, 5], [15, 15, 10], [20, 20, 15], [25, 25, 20]]) == 1329\n    assert candidate(circles = [[25, 25, 15], [50, 25, 15], [75, 25, 15], [25, 50, 15], [50, 50, 15], [75, 50, 15], [25, 75, 15], [50, 75, 15], [75, 75, 15]]) == 5733\n    assert candidate(circles = [[25, 25, 10], [25, 75, 10], [75, 25, 10], [75, 75, 10], [50, 50, 20]]) == 2525\n    assert candidate(circles = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) == 56\n    assert candidate(circles = [[50, 50, 50], [30, 30, 30], [70, 70, 30], [20, 20, 20], [80, 80, 20]]) == 8687\n    assert candidate(circles = [[90, 90, 5], [80, 80, 5], [70, 70, 5], [60, 60, 5]]) == 324\n    assert candidate(circles = [[1, 99, 1], [99, 1, 1], [50, 50, 45], [25, 25, 25], [75, 75, 25]]) == 7605\n    assert candidate(circles = [[20, 20, 5], [20, 30, 5], [30, 20, 5], [30, 30, 5], [40, 40, 5], [40, 50, 5], [50, 40, 5], [50, 50, 5]]) == 640\n    assert candidate(circles = [[10, 10, 1], [20, 20, 1], [30, 30, 1], [40, 40, 1], [50, 50, 1], [60, 60, 1], [70, 70, 1], [80, 80, 1], [90, 90, 1], [10, 90, 1], [90, 10, 1]]) == 55\n    assert candidate(circles = [[50, 50, 20], [70, 50, 20], [50, 70, 20], [50, 30, 20]]) == 3447\n    assert candidate(circles = [[10, 10, 1], [11, 11, 2], [12, 12, 3], [13, 13, 4], [14, 14, 5], [15, 15, 6], [16, 16, 7], [17, 17, 8], [18, 18, 9], [19, 19, 10]]) == 347\n    assert candidate(circles = [[10, 10, 10], [20, 10, 10], [10, 20, 10], [20, 20, 10], [15, 15, 10]]) == 797\n    assert candidate(circles = [[90, 90, 10], [80, 80, 15], [70, 70, 5], [60, 60, 20]]) == 2036\n    assert candidate(circles = [[50, 50, 50], [60, 60, 20], [70, 70, 10], [80, 80, 5], [90, 90, 2], [100, 100, 1]]) == 7863\n    assert candidate(circles = [[50, 50, 1], [50, 51, 1], [51, 50, 1], [51, 51, 1], [1, 1, 1], [99, 99, 1], [1, 99, 1], [99, 1, 1]]) == 32\n    assert candidate(circles = [[50, 50, 50], [40, 40, 40], [30, 30, 30], [20, 20, 20], [10, 10, 10], [60, 60, 10], [70, 70, 10], [80, 80, 10], [90, 90, 10]]) == 8613\n    assert candidate(circles = [[50, 50, 25], [25, 25, 25], [75, 75, 25]]) == 5171\n    assert candidate(circles = [[10, 10, 5], [20, 10, 5], [30, 10, 5], [40, 10, 5], [50, 10, 5], [60, 10, 5]]) == 481\n    assert candidate(circles = [[10, 10, 1], [11, 11, 1], [12, 12, 1], [13, 13, 1], [14, 14, 1], [15, 15, 1], [16, 16, 1], [17, 17, 1], [18, 18, 1], [19, 19, 1], [20, 20, 1]]) == 35\n    assert candidate(circles = [[50, 50, 5], [50, 60, 5], [50, 70, 5], [50, 80, 5], [50, 90, 5]]) == 401\n    assert candidate(circles = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5]]) == 324\n    assert candidate(circles = [[100, 100, 10], [90, 90, 20], [80, 80, 15], [70, 70, 25]]) == 2875\n    assert candidate(circles = [[25, 25, 15], [75, 75, 15], [25, 75, 15], [75, 25, 15], [50, 50, 10]]) == 3153\n    assert candidate(circles = [[10, 10, 5], [20, 20, 15], [30, 30, 10], [40, 40, 20]]) == 1904\n    assert candidate(circles = [[25, 25, 5], [25, 30, 5], [25, 35, 5], [25, 40, 5], [25, 45, 5]]) == 269\n    assert candidate(circles = [[25, 25, 15], [45, 25, 15], [25, 45, 15], [45, 45, 15]]) == 2213\n    assert candidate(circles = [[10, 90, 10], [90, 10, 10], [50, 50, 20], [60, 40, 15]]) == 2133\n    assert candidate(circles = [[10, 50, 10], [20, 50, 10], [30, 50, 10], [40, 50, 10], [50, 50, 10], [60, 50, 10]]) == 1267\n    assert candidate(circles = [[30, 30, 20], [40, 40, 20], [50, 50, 20], [60, 60, 20]]) == 2925\n    assert candidate(circles = [[10, 10, 5], [30, 30, 5], [50, 50, 5], [70, 70, 5], [90, 90, 5]]) == 405\n    assert candidate(circles = [[10, 10, 5], [15, 15, 3], [20, 20, 7]]) == 244\n    assert candidate(circles = [[50, 50, 20], [60, 60, 20], [70, 70, 20], [80, 80, 20], [90, 90, 20]]) == 3481\n    assert candidate(circles = [[50, 50, 50], [60, 60, 50], [70, 70, 50], [80, 80, 50]]) == 12075\n    assert candidate(circles = [[10, 10, 5], [15, 15, 10], [20, 20, 15], [25, 25, 20], [30, 30, 25], [35, 35, 30], [40, 40, 35], [45, 45, 40], [50, 50, 45], [55, 55, 50]]) == 8352\n    assert candidate(circles = [[10, 10, 1], [11, 11, 1], [12, 12, 1], [13, 13, 1], [14, 14, 1], [15, 15, 1], [16, 16, 1], [17, 17, 1], [18, 18, 1], [19, 19, 1]]) == 32\n    assert candidate(circles = [[75, 75, 30], [25, 25, 15], [50, 50, 10]]) == 3795\n    assert candidate(circles = [[10, 10, 5], [20, 20, 10], [30, 30, 15], [40, 40, 20], [50, 50, 25]]) == 2761\n    assert candidate(circles = [[30, 30, 20], [30, 70, 20], [70, 30, 20], [70, 70, 20], [50, 50, 20]]) == 5369\n    assert candidate(circles = [[50, 50, 10], [51, 51, 5], [52, 52, 15], [53, 53, 20]]) == 1257\n    assert candidate(circles = [[1, 1, 1], [99, 99, 1], [50, 50, 40]]) == 5035\n    assert candidate(circles = [[1, 1, 1], [99, 99, 1], [50, 50, 50]]) == 7855\n    assert candidate(circles = [[1, 1, 1], [1, 100, 1], [100, 1, 1], [100, 100, 1], [50, 50, 45]]) == 6381\n    assert candidate(circles = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]]) == 90\n    assert candidate(circles = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]]) == 347\n    assert candidate(circles = [[100, 100, 100], [1, 1, 1], [99, 99, 1]]) == 31422\n    assert candidate(circles = [[50, 50, 10], [50, 60, 10], [50, 70, 10], [50, 80, 10]]) == 887\n", "comparison": "exact"}, "public_tests": ["[[2,2,1]]", "[[2,2,2],[3,4,1]]"], "hints": ["For each circle, how can you check whether or not a lattice point lies inside it?", "Since you need to reduce the search space, consider the minimum and maximum possible values of the coordinates of a lattice point contained in any circle."], "metadata": {"canonical_parameter_names": ["circles"], "leetcode_dataset_entry_point": "Solution().countLatticePoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:21+00:00", "tests_total": 114, "tests_dropped": 32, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "hash-table", "math", "geometry", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def countLatticePoints(self, circles: list[list[int]]) -> int:", "container": "Solution", "callable": "countLatticePoints", "parameters": [{"name": "circles", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2250, "task_id": "count-number-of-rectangles-containing-each-point", "difficulty": "Medium", "problem_description": "You are given a 2D integer array rectangles where rectangles[i] = [l_i, h_i] indicates that i^th rectangle has a length of l_i and a height of h_i. You are also given a 2D integer array points where points[j] = [x_j, y_j] is a point with coordinates (x_j, y_j).\n\nThe i^th rectangle has its bottom-left corner point at the coordinates (0, 0) and its top-right corner point at (l_i, h_i).\n\nReturn an integer array count of length points.length where count[j] is the number of rectangles that contain the j^th point.\n\nThe i^th rectangle contains the j^th point if 0 <= x_j <= l_i and 0 <= y_j <= h_i. Note that points that lie on the edges of a rectangle are also considered to be contained by that rectangle.\n\nExample 1:\n\nInput: rectangles = [[1,2],[2,3],[2,5]], points = [[2,1],[1,4]]\nOutput: [2,1]\nExplanation:\nThe first rectangle contains no points.\nThe second rectangle contains only the point (2, 1).\nThe third rectangle contains the points (2, 1) and (1, 4).\nThe number of rectangles that contain the point (2, 1) is 2.\nThe number of rectangles that contain the point (1, 4) is 1.\nTherefore, we return [2, 1].\n\nExample 2:\n\nInput: rectangles = [[1,1],[2,2],[3,3]], points = [[1,3],[1,1]]\nOutput: [1,3]\nExplanation:\nThe first rectangle contains only the point (1, 1).\nThe second rectangle contains only the point (1, 1).\nThe third rectangle contains the points (1, 3) and (1, 1).\nThe number of rectangles that contain the point (1, 3) is 1.\nThe number of rectangles that contain the point (1, 1) is 3.\nTherefore, we return [1, 3].\n\nConstraints:\n\n- 1 <= rectangles.length, points.length <= 5 * 10^4\n- rectangles[i].length == points[j].length == 2\n- 1 <= l_i, x_j <= 10^9\n- 1 <= h_i, y_j <= 100\n- All the rectangles are unique.\n- All the points are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(rectangles = [[1, 2], [2, 3], [2, 5]],points = [[2, 1], [1, 4]]) == [2, 1]\n    assert candidate(rectangles = [[10, 100], [9, 99], [8, 98], [7, 97]],points = [[10, 100], [9, 99], [8, 98], [7, 97]]) == [1, 2, 3, 4]\n    assert candidate(rectangles = [[10, 1], [9, 10], [10, 10], [1, 1]],points = [[5, 5], [6, 6], [7, 7]]) == [2, 2, 2]\n    assert candidate(rectangles = [[1, 1], [2, 2], [3, 3]],points = [[1, 3], [1, 1]]) == [1, 3]\n    assert candidate(rectangles = [[5, 100], [10, 99], [15, 98], [20, 97], [25, 96], [30, 95]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [6, 6, 6, 6, 6, 5, 5, 5, 5, 5]\n    assert candidate(rectangles = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [9, 7, 5, 3, 1, 0, 0, 0, 0]\n    assert candidate(rectangles = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[10, 100], [20, 99], [30, 98], [40, 97], [50, 96], [60, 95], [70, 94], [80, 93], [90, 92], [100, 91]],points = [[5, 95], [15, 90], [25, 85], [35, 80], [45, 75], [55, 70], [65, 65], [75, 60], [85, 55], [95, 50]]) == [6, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[500000000, 100], [600000000, 100], [700000000, 100], [800000000, 100]],points = [[400000000, 50], [550000000, 55], [650000000, 65], [750000000, 75]]) == [4, 3, 2, 1]\n    assert candidate(rectangles = [[100, 100], [200, 100], [300, 100], [400, 100], [500, 100], [600, 100], [700, 100], [800, 100], [900, 100], [1000, 100], [1100, 100], [1200, 100], [1300, 100], [1400, 100], [1500, 100], [1600, 100], [1700, 100], [1800, 100], [1900, 100], [2000, 100]],points = [[50, 50], [250, 50], [450, 50], [650, 50], [850, 50], [1050, 50], [1250, 50], [1450, 50], [1650, 50], [1850, 50]]) == [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]\n    assert candidate(rectangles = [[1, 100], [1, 99], [1, 98], [1, 97], [1, 96], [1, 95], [1, 94], [1, 93], [1, 92], [1, 91]],points = [[1, 100], [1, 99], [1, 98], [1, 97], [1, 96], [1, 95], [1, 94], [1, 93], [1, 92], [1, 91]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[300000000, 100], [600000000, 90], [900000000, 80], [1200000000, 70], [1500000000, 60]],points = [[150000000, 65], [450000000, 75], [750000000, 85], [1050000000, 95], [1350000000, 100]]) == [4, 2, 0, 0, 0]\n    assert candidate(rectangles = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 47], [1, 48], [1, 49], [1, 50], [1, 51], [1, 52], [1, 53], [1, 54], [1, 55], [1, 56], [1, 57], [1, 58], [1, 59], [1, 60], [1, 61], [1, 62], [1, 63], [1, 64], [1, 65], [1, 66], [1, 67], [1, 68], [1, 69], [1, 70], [1, 71], [1, 72], [1, 73], [1, 74], [1, 75], [1, 76], [1, 77], [1, 78], [1, 79], [1, 80], [1, 81], [1, 82], [1, 83], [1, 84], [1, 85], [1, 86], [1, 87], [1, 88], [1, 89], [1, 90], [1, 91], [1, 92], [1, 93], [1, 94], [1, 95], [1, 96], [1, 97], [1, 98], [1, 99], [1, 100]],points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 47], [1, 48], [1, 49], [1, 50], [1, 51], [1, 52], [1, 53], [1, 54], [1, 55], [1, 56], [1, 57], [1, 58], [1, 59], [1, 60], [1, 61], [1, 62], [1, 63], [1, 64], [1, 65], [1, 66], [1, 67], [1, 68], [1, 69], [1, 70], [1, 71], [1, 72], [1, 73], [1, 74], [1, 75], [1, 76], [1, 77], [1, 78], [1, 79], [1, 80], [1, 81], [1, 82], [1, 83], [1, 84], [1, 85], [1, 86], [1, 87], [1, 88], [1, 89], [1, 90], [1, 91], [1, 92], [1, 93], [1, 94], [1, 95], [1, 96], [1, 97], [1, 98], [1, 99], [1, 100]]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[500, 90], [1000, 80], [1500, 70], [2000, 60], [2500, 50]],points = [[250, 55], [750, 75], [1250, 85], [1750, 95], [2250, 100]]) == [4, 1, 0, 0, 0]\n    assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[5, 100], [10, 99], [15, 98], [20, 97], [25, 96], [30, 95], [35, 94], [40, 93], [45, 92], [50, 91]],points = [[1, 95], [6, 90], [11, 85], [16, 80], [21, 75], [26, 70], [31, 65], [36, 60], [41, 55], [46, 50]]) == [6, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],points = [[50, 1], [150, 2], [250, 3], [350, 4], [450, 5]]) == [5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]]) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(rectangles = [[500000000, 100], [499999999, 99], [500000000, 98], [1, 97]],points = [[250000000, 50], [300000000, 60], [350000000, 70]]) == [3, 3, 3]\n    assert candidate(rectangles = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],points = [[50, 10], [150, 20], [250, 30], [350, 40], [450, 50]]) == [0, 0, 0, 0, 0]\n    assert candidate(rectangles = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [10, 8, 6, 5, 5, 5, 5, 5, 5, 5]\n    assert candidate(rectangles = [[100, 100], [99, 100], [98, 100], [97, 100], [96, 100], [95, 100], [94, 100], [93, 100], [92, 100], [91, 100], [90, 100]],points = [[50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]) == [11, 11, 11, 11, 11]\n    assert candidate(rectangles = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(rectangles = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 100]],points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 100]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9], [1000, 10]],points = [[50, 1], [150, 2], [250, 3], [350, 4], [450, 5], [550, 6], [650, 7], [750, 8], [850, 9], [950, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[1000000000, 100], [500000000, 100], [250000000, 100], [125000000, 100], [62500000, 100]],points = [[500000000, 50], [250000000, 50], [125000000, 50], [62500000, 50], [31250000, 50]]) == [2, 3, 4, 5, 5]\n    assert candidate(rectangles = [[1000000000, 100], [999999999, 99], [999999998, 98], [999999997, 97], [999999996, 96], [999999995, 95], [999999994, 94], [999999993, 93], [999999992, 92], [999999991, 91]],points = [[500000000, 50], [500000001, 50], [500000002, 50], [500000003, 50], [500000004, 50], [500000005, 50], [500000006, 50], [500000007, 50], [500000008, 50], [500000009, 50]]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n    assert candidate(rectangles = [[500000000, 50], [600000000, 60], [700000000, 70], [800000000, 80], [900000000, 90]],points = [[250000000, 25], [350000000, 35], [450000000, 45], [550000000, 55]]) == [5, 5, 5, 4]\n    assert candidate(rectangles = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [5, 5, 5, 5, 5]\n    assert candidate(rectangles = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],points = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],points = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450]]) == [1, 0, 0, 0, 0]\n    assert candidate(rectangles = [[1000000000, 100], [999999999, 99], [1000000000, 98], [1, 97]],points = [[500000000, 50], [600000000, 51], [700000000, 52], [800000000, 53]]) == [3, 3, 3, 3]\n    assert candidate(rectangles = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],points = [[1, 1], [10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]) == [10, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n    assert candidate(rectangles = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],points = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],points = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],points = [[1, 90], [2, 89], [3, 88], [4, 87], [5, 86], [6, 85], [7, 84], [8, 83], [9, 82], [10, 81]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[1, 100], [1, 99], [1, 98], [1, 97], [1, 96]],points = [[1, 100], [1, 99], [1, 98], [1, 97], [1, 96]]) == [1, 2, 3, 4, 5]\n    assert candidate(rectangles = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],points = [[3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[5, 100], [10, 99], [15, 98], [20, 97], [25, 96], [30, 95]],points = [[5, 95], [10, 90], [15, 85], [20, 80], [25, 75], [30, 70]]) == [6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],points = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450], [550, 550], [650, 650], [750, 750], [850, 850], [950, 950]]) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(rectangles = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [100, 9], [100, 10]],points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[500000000, 100], [500000001, 99], [500000002, 98], [500000003, 97], [500000004, 96]],points = [[500000000, 99], [500000001, 98], [500000002, 97]]) == [2, 2, 2]\n    assert candidate(rectangles = [[100, 100], [200, 95], [300, 90], [400, 85], [500, 80], [600, 75], [700, 70], [800, 65], [900, 60], [1000, 55]],points = [[50, 50], [150, 55], [250, 60], [350, 65], [450, 70], [550, 75], [650, 80], [750, 85], [850, 90], [950, 95]]) == [10, 9, 7, 5, 3, 1, 0, 0, 0, 0]\n    assert candidate(rectangles = [[500000000, 50], [600000000, 60], [700000000, 70], [800000000, 80]],points = [[100000000, 10], [200000000, 20], [300000000, 30], [400000000, 40], [500000000, 50], [600000000, 60], [700000000, 70], [800000000, 80]]) == [4, 4, 4, 4, 4, 3, 2, 1]\n    assert candidate(rectangles = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[1000000000, 100], [1000000000, 99], [1000000000, 98], [1000000000, 97], [1000000000, 96]],points = [[500000000, 50], [500000000, 49], [500000000, 48], [500000000, 47], [500000000, 46]]) == [5, 5, 5, 5, 5]\n    assert candidate(rectangles = [[500000000, 100], [500000001, 100], [500000002, 100], [500000003, 100], [500000004, 100]],points = [[499999999, 50], [500000000, 50], [500000001, 50], [500000002, 50], [500000003, 50]]) == [5, 5, 4, 3, 2]\n    assert candidate(rectangles = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n    assert candidate(rectangles = [[50, 50], [75, 75], [100, 100], [25, 25]],points = [[30, 30], [40, 40], [60, 60], [80, 80], [90, 90]]) == [3, 3, 2, 1, 1]\n    assert candidate(rectangles = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],points = [[1, 1], [10, 10], [2, 2], [20, 20], [3, 3], [30, 30], [4, 4], [40, 40], [5, 5], [50, 50]]) == [10, 1, 9, 0, 8, 0, 7, 0, 6, 0]\n    assert candidate(rectangles = [[10, 100], [20, 100], [30, 100], [40, 100], [50, 100]],points = [[5, 50], [15, 50], [25, 50], [35, 50], [45, 50]]) == [5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1]],points = [[15, 1], [25, 1], [35, 1], [45, 1], [55, 1]]) == [4, 3, 2, 1, 0]\n    assert candidate(rectangles = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [100, 9], [100, 10], [100, 11], [100, 12], [100, 13], [100, 14], [100, 15], [100, 16], [100, 17], [100, 18], [100, 19], [100, 20], [100, 21], [100, 22], [100, 23], [100, 24], [100, 25], [100, 26], [100, 27], [100, 28], [100, 29], [100, 30], [100, 31], [100, 32], [100, 33], [100, 34], [100, 35], [100, 36], [100, 37], [100, 38], [100, 39], [100, 40], [100, 41], [100, 42], [100, 43], [100, 44], [100, 45], [100, 46], [100, 47], [100, 48], [100, 49], [100, 50], [100, 51], [100, 52], [100, 53], [100, 54], [100, 55], [100, 56], [100, 57], [100, 58], [100, 59], [100, 60], [100, 61], [100, 62], [100, 63], [100, 64], [100, 65], [100, 66], [100, 67], [100, 68], [100, 69], [100, 70], [100, 71], [100, 72], [100, 73], [100, 74], [100, 75], [100, 76], [100, 77], [100, 78], [100, 79], [100, 80], [100, 81], [100, 82], [100, 83], [100, 84], [100, 85], [100, 86], [100, 87], [100, 88], [100, 89], [100, 90], [100, 91], [100, 92], [100, 93], [100, 94], [100, 95], [100, 96], [100, 97], [100, 98], [100, 99]],points = [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [50, 11], [50, 12], [50, 13], [50, 14], [50, 15], [50, 16], [50, 17], [50, 18], [50, 19], [50, 20], [50, 21], [50, 22], [50, 23], [50, 24], [50, 25], [50, 26], [50, 27], [50, 28], [50, 29], [50, 30], [50, 31], [50, 32], [50, 33], [50, 34], [50, 35], [50, 36], [50, 37], [50, 38], [50, 39], [50, 40], [50, 41], [50, 42], [50, 43], [50, 44], [50, 45], [50, 46], [50, 47], [50, 48], [50, 49], [50, 50], [50, 51], [50, 52], [50, 53], [50, 54], [50, 55], [50, 56], [50, 57], [50, 58], [50, 59], [50, 60], [50, 61], [50, 62], [50, 63], [50, 64], [50, 65], [50, 66], [50, 67], [50, 68], [50, 69], [50, 70], [50, 71], [50, 72], [50, 73], [50, 74], [50, 75], [50, 76], [50, 77], [50, 78], [50, 79], [50, 80], [50, 81], [50, 82], [50, 83], [50, 84], [50, 85], [50, 86], [50, 87], [50, 88], [50, 89], [50, 90], [50, 91], [50, 92], [50, 93], [50, 94], [50, 95], [50, 96], [50, 97], [50, 98], [50, 99]]) == [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],points = [[5, 100], [6, 99], [7, 98], [8, 97], [9, 96], [10, 95], [11, 94], [12, 93], [13, 92], [14, 91]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(rectangles = [[1000000000, 1], [999999999, 2], [999999998, 3], [999999997, 4], [999999996, 5]],points = [[1000000000, 1], [999999999, 2], [999999998, 3], [999999997, 4], [999999996, 5]]) == [1, 1, 1, 1, 1]\n    assert candidate(rectangles = [[1, 100], [1, 99], [1, 98], [1, 97], [1, 96], [1, 95]],points = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(rectangles = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],points = [[9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [9, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(rectangles = [[9, 90], [8, 80], [7, 70], [6, 60], [5, 50], [4, 40], [3, 30], [2, 20], [1, 10]],points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n", "comparison": "exact"}, "public_tests": ["[[1,2],[2,3],[2,5]]\n[[2,1],[1,4]]", "[[1,1],[2,2],[3,3]]\n[[1,3],[1,1]]"], "hints": ["The heights of the rectangles and the y-coordinates of the points are only at most 100, so for each point, we can iterate over the possible heights of the rectangles that contain a given point.", "For a given point and height, can we efficiently count how many rectangles with that height contain our point?", "Sort the rectangles at each height and use binary search."], "metadata": {"canonical_parameter_names": ["rectangles", "points"], "leetcode_dataset_entry_point": "Solution().countRectangles", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:23+00:00", "tests_total": 64, "tests_dropped": 3, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "binary-search", "binary-indexed-tree", "sorting"]}, "language": "python", "interface": {"raw_signature": "def countRectangles(self, rectangles: list[list[int]], points: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "countRectangles", "parameters": [{"name": "rectangles", "type": "list[list[int]]"}, {"name": "points", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2251, "task_id": "number-of-flowers-in-full-bloom", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array flowers, where flowers[i] = [start_i, end_i] means the i^th flower will be in full bloom from start_i to end_i (inclusive). You are also given a 0-indexed integer array people of size n, where people[i] is the time that the i^th person will arrive to see the flowers.\n\nReturn an integer array answer of size n, where answer[i] is the number of flowers that are in full bloom when the i^th person arrives.\n\nExample 1:\n\nInput: flowers = [[1,6],[3,7],[9,12],[4,13]], people = [2,3,7,11]\nOutput: [1,2,2,2]\nExplanation: The figure above shows the times when the flowers are in full bloom and when the people arrive.\nFor each person, we return the number of flowers in full bloom during their arrival.\n\nExample 2:\n\nInput: flowers = [[1,10],[3,3]], people = [3,3,2]\nOutput: [2,2,1]\nExplanation: The figure above shows the times when the flowers are in full bloom and when the people arrive.\nFor each person, we return the number of flowers in full bloom during their arrival.\n\nConstraints:\n\n- 1 <= flowers.length <= 5 * 10^4\n- flowers[i].length == 2\n- 1 <= start_i <= end_i <= 10^9\n- 1 <= people.length <= 5 * 10^4\n- 1 <= people[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(flowers = [[1, 10], [3, 3]],people = [3, 3, 2]) == [2, 2, 1]\n    assert candidate(flowers = [[1, 100]],people = [50, 100, 150]) == [1, 1, 0]\n    assert candidate(flowers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 2], [2, 3], [3, 4]],people = [1, 2, 3, 4]) == [1, 2, 2, 1]\n    assert candidate(flowers = [[5, 10], [15, 20], [1, 5]],people = [6, 12, 4]) == [1, 0, 1]\n    assert candidate(flowers = [[1, 1000000000]],people = [1, 500000000, 1000000000]) == [1, 1, 1]\n    assert candidate(flowers = [[5, 10], [15, 20], [25, 30]],people = [10, 20, 30, 40]) == [1, 1, 1, 0]\n    assert candidate(flowers = [[1, 6], [3, 7], [9, 12], [4, 13]],people = [2, 3, 7, 11]) == [1, 2, 2, 2]\n    assert candidate(flowers = [[1, 1000000000]],people = [1, 1000000000]) == [1, 1]\n    assert candidate(flowers = [[5, 11], [8, 8], [8, 9], [10, 10], [9, 11], [5, 7]],people = [6, 10, 7]) == [2, 3, 2]\n    assert candidate(flowers = [[1, 1], [2, 2], [3, 3]],people = [1, 2, 3]) == [1, 1, 1]\n    assert candidate(flowers = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],people = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n    assert candidate(flowers = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],people = [3, 6, 8, 10, 15]) == [3, 5, 3, 1, 0]\n    assert candidate(flowers = [[1, 10], [1, 10], [1, 10], [1, 10], [1, 10]],people = [1, 5, 10]) == [5, 5, 5]\n    assert candidate(flowers = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(flowers = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]\n    assert candidate(flowers = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],people = [1, 5, 10, 15]) == [1, 2, 2, 0]\n    assert candidate(flowers = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23]],people = [2, 6, 10, 14, 18, 22, 24]) == [1, 1, 1, 1, 1, 1, 0]\n    assert candidate(flowers = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996]],people = [1, 1000000000, 500000000, 250000000, 750000000]) == [1, 1, 5, 5, 5]\n    assert candidate(flowers = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997]],people = [1, 2, 3, 4, 999999999, 1000000000]) == [1, 2, 3, 4, 2, 1]\n    assert candidate(flowers = [[100000000, 200000000], [300000000, 400000000], [500000000, 600000000]],people = [150000000, 350000000, 550000000]) == [1, 1, 1]\n    assert candidate(flowers = [[2, 5], [8, 10], [12, 14], [18, 22], [26, 28], [30, 34]],people = [2, 5, 8, 10, 12, 14, 18, 22, 26, 28, 30, 34]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],people = [5, 6, 7, 8, 9, 10]) == [5, 5, 4, 3, 2, 1]\n    assert candidate(flowers = [[1, 6], [3, 7], [9, 12], [4, 13], [14, 17], [18, 21], [22, 25]],people = [2, 3, 7, 11, 15, 19, 23]) == [1, 2, 2, 2, 1, 1, 1]\n    assert candidate(flowers = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300]],people = [1, 50, 100, 150, 200, 250, 300]) == [1, 2, 3, 3, 3, 2, 1]\n    assert candidate(flowers = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[5, 15], [10, 20], [15, 25], [20, 30], [25, 35]],people = [10, 15, 20, 25, 30, 35]) == [2, 3, 3, 3, 2, 1]\n    assert candidate(flowers = [[5, 20], [20, 30], [10, 25], [15, 35], [25, 40]],people = [10, 15, 20, 25, 30, 35, 40]) == [2, 3, 4, 4, 3, 2, 1]\n    assert candidate(flowers = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],people = [5, 15, 25, 35, 45, 55]) == [1, 1, 1, 1, 1, 0]\n    assert candidate(flowers = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15], [16, 18], [19, 21], [22, 24], [25, 27], [28, 30]],people = [1, 3, 4, 6, 7, 9, 10, 12, 13, 15, 16, 18, 19, 21, 22, 24, 25, 27, 28, 30]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],people = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 100]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21]],people = [2, 6, 10, 14, 18, 22]) == [1, 1, 1, 1, 1, 0]\n    assert candidate(flowers = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110]],people = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],people = [3, 8, 13, 18, 23]) == [1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 3, 3, 3, 3, 2, 1]\n    assert candidate(flowers = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 0, 0, 0, 0, 0]\n    assert candidate(flowers = [[1, 6], [3, 7], [9, 12], [4, 13], [10, 15], [16, 20], [21, 25], [26, 30]],people = [2, 5, 6, 7, 10, 15, 20, 25, 30]) == [1, 3, 3, 2, 3, 1, 1, 1, 1]\n    assert candidate(flowers = [[10, 15], [15, 20], [20, 25], [25, 30]],people = [12, 17, 22, 27]) == [1, 1, 1, 1]\n    assert candidate(flowers = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35]],people = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33]) == [0, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 1000], [500, 1500], [1000, 2000], [1500, 2500], [2000, 3000], [2500, 3500], [3000, 4000], [3500, 4500], [4000, 5000], [4500, 5500]],people = [1, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000]) == [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2]\n    assert candidate(flowers = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]],people = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n    assert candidate(flowers = [[1, 5], [2, 3], [4, 6], [7, 8], [9, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 2, 2, 2, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50]],people = [5, 15, 25, 35, 45]) == [1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5]],people = [1, 2, 3, 4, 5]) == [5, 5, 5, 5, 5]\n    assert candidate(flowers = [[1, 5], [2, 9], [6, 8], [4, 7], [9, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 2, 3, 3, 3, 3, 2, 2, 1]\n    assert candidate(flowers = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n    assert candidate(flowers = [[2, 11], [4, 12], [8, 15], [9, 16], [10, 17]],people = [5, 10, 15, 20]) == [2, 5, 3, 0]\n    assert candidate(flowers = [[1, 1000000000], [2, 500000000], [500000000, 1000000000]],people = [1, 250000000, 500000000, 750000000, 1000000000]) == [1, 2, 3, 2, 2]\n    assert candidate(flowers = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],people = [50, 55, 60, 65, 70, 75, 80, 85, 90, 95]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 6]\n    assert candidate(flowers = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]\n    assert candidate(flowers = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996], [6, 999999995]],people = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 999999995, 999999997, 1000000000]) == [1, 3, 5, 6, 6, 6, 6, 6, 6, 6, 6, 4, 1]\n    assert candidate(flowers = [[1, 10], [5, 15], [10, 20], [15, 25], [20, 30]],people = [1, 6, 11, 16, 21]) == [1, 2, 2, 2, 2]\n    assert candidate(flowers = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n    assert candidate(flowers = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15], [16, 18], [19, 21]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [9, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(flowers = [[10, 12], [12, 14], [14, 16], [16, 18], [18, 20], [20, 22], [22, 24], [24, 26], [26, 28]],people = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]) == [1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1]\n    assert candidate(flowers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]\n    assert candidate(flowers = [[1, 5], [2, 8], [3, 9], [10, 15], [12, 18], [16, 20]],people = [1, 3, 5, 7, 10, 12, 15, 18, 20]) == [1, 3, 3, 2, 1, 2, 2, 2, 1]\n    assert candidate(flowers = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],people = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 500000000], [500000001, 1000000000]],people = [250000000, 750000000, 1000000000]) == [1, 1, 1]\n    assert candidate(flowers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 1000], [1, 1000], [1, 1000], [1, 1000], [1, 1000], [1, 1000], [1, 1000], [1, 1000], [1, 1000], [1, 1000]],people = [1, 500, 1000]) == [10, 10, 10]\n    assert candidate(flowers = [[1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n    assert candidate(flowers = [[10, 20], [10, 20], [10, 20], [10, 20], [10, 20], [10, 20], [10, 20], [10, 20], [10, 20], [10, 20]],people = [5, 15, 25]) == [0, 10, 0]\n    assert candidate(flowers = [[1, 6], [6, 11], [11, 16], [16, 21]],people = [1, 5, 6, 10, 11, 15, 16, 20, 21]) == [1, 1, 2, 1, 2, 1, 2, 1, 1]\n    assert candidate(flowers = [[100, 110], [110, 120], [120, 130], [130, 140], [140, 150], [150, 160], [160, 170], [170, 180], [180, 190]],people = [105, 115, 125, 135, 145, 155, 165, 175, 185]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],people = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15], [16, 18], [19, 21]],people = [2, 5, 8, 11, 14, 17, 20]) == [1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996]],people = [1, 2, 3, 4, 5, 1000000000, 999999999, 999999998, 999999997, 999999996]) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]\n    assert candidate(flowers = [[1, 10000], [10001, 20000], [20001, 30000], [30001, 40000], [40001, 50000]],people = [5000, 15000, 25000, 35000, 45000]) == [1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996]],people = [1, 500000000, 1000000000]) == [1, 5, 1]\n    assert candidate(flowers = [[1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000]],people = [1, 1000000000, 500000000, 250000000, 750000000]) == [10, 10, 10, 10, 10]\n    assert candidate(flowers = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n    assert candidate(flowers = [[1, 100], [10, 90], [20, 80], [30, 70], [40, 60], [50, 50]],people = [1, 50, 100, 150]) == [1, 6, 1, 0]\n    assert candidate(flowers = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350]],people = [50, 100, 150, 200, 250, 300, 350]) == [2, 3, 3, 3, 3, 2, 1]\n    assert candidate(flowers = [[100, 200], [150, 250], [200, 300], [250, 350], [300, 400]],people = [50, 100, 150, 200, 250, 300, 350, 400, 450]) == [0, 1, 2, 3, 3, 3, 2, 1, 0]\n    assert candidate(flowers = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]],people = [1, 2, 3, 4, 5]) == [10, 10, 10, 10, 10]\n    assert candidate(flowers = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1]\n    assert candidate(flowers = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]],people = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1]\n    assert candidate(flowers = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(flowers = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996], [6, 999999995], [7, 999999994], [8, 999999993], [9, 999999992], [10, 999999991]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(flowers = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],people = [3, 8, 13, 18, 23, 28]) == [1, 1, 1, 1, 1, 0]\n    assert candidate(flowers = [[1, 5], [10, 15], [20, 25], [30, 35], [40, 45]],people = [3, 8, 13, 18, 23, 28, 33, 38, 43]) == [1, 0, 1, 0, 1, 0, 1, 0, 1]\n    assert candidate(flowers = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996], [6, 999999995], [7, 999999994], [8, 999999993], [9, 999999992], [10, 999999991]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 999999991, 999999992, 999999993, 999999994, 999999995, 999999996, 999999997, 999999998, 999999999, 1000000000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(flowers = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [35, 45], [40, 50], [45, 55], [50, 60], [55, 65]],people = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65]) == [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1]\n    assert candidate(flowers = [[5, 15], [10, 20], [15, 25], [20, 30], [25, 35]],people = [5, 8, 10, 12, 15, 18, 20, 23, 25, 28, 30]) == [1, 1, 2, 2, 3, 2, 3, 2, 3, 2, 2]\n    assert candidate(flowers = [[1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(flowers = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],people = [1, 5, 9]) == [1, 2, 2]\n    assert candidate(flowers = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100]],people = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 100]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 5], [10, 20], [25, 35], [40, 50], [55, 60]],people = [5, 15, 25, 35, 45, 55, 60]) == [1, 1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35]],people = [8, 13, 18, 23, 28, 33]) == [1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000]],people = [1, 1000000000]) == [10, 10]\n    assert candidate(flowers = [[1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000]],people = [1, 500000000, 1000000000]) == [5, 5, 5]\n    assert candidate(flowers = [[1, 3], [1, 3], [1, 3], [1, 3], [1, 3]],people = [1, 2, 3, 4, 5]) == [5, 5, 5, 0, 0]\n    assert candidate(flowers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],people = [1, 5, 9, 13, 17, 20]) == [1, 1, 1, 1, 1, 1]\n    assert candidate(flowers = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],people = [1, 3, 5, 7, 9]) == [1, 2, 2, 2, 2]\n    assert candidate(flowers = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n    assert candidate(flowers = [[1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000], [1, 1000000000]],people = [1, 1000000000, 500000000, 250000000, 750000000]) == [5, 5, 5, 5, 5]\n    assert candidate(flowers = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],people = [5, 15, 25, 35, 45, 55, 1, 11, 21, 31, 41]) == [1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1]\n", "comparison": "exact"}, "public_tests": ["[[1,6],[3,7],[9,12],[4,13]]\n[2,3,7,11]", "[[1,10],[3,3]]\n[3,3,2]"], "hints": ["Notice that for any given time t, the number of flowers blooming at time t is equal to the number of flowers that have started blooming minus the number of flowers that have already stopped blooming.", "We can obtain these values efficiently using binary search.", "We can store the starting times in sorted order, which then allows us to binary search to find how many flowers have started blooming for a given time t.", "We do the same for the ending times to find how many flowers have stopped blooming at time t."], "metadata": {"canonical_parameter_names": ["flowers", "people"], "leetcode_dataset_entry_point": "Solution().fullBloomFlowers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:26+00:00", "tests_total": 105, "tests_dropped": 5, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "hash-table", "binary-search", "sorting", "prefix-sum", "ordered-set"]}, "language": "python", "interface": {"raw_signature": "def fullBloomFlowers(self, flowers: list[list[int]], people: list[int]) -> list[int]:", "container": "Solution", "callable": "fullBloomFlowers", "parameters": [{"name": "flowers", "type": "list[list[int]]"}, {"name": "people", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2255, "task_id": "count-prefixes-of-a-given-string", "difficulty": "Easy", "problem_description": "You are given a string array words and a string s, where words[i] and s comprise only of lowercase English letters.\n\nReturn the number of strings in words that are a prefix of s.\n\nA prefix of a string is a substring that occurs at the beginning of the string. A substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: words = [\"a\",\"b\",\"c\",\"ab\",\"bc\",\"abc\"], s = \"abc\"\nOutput: 3\nExplanation:\nThe strings in words which are a prefix of s = \"abc\" are:\n\"a\", \"ab\", and \"abc\".\nThus the number of strings in words which are a prefix of s is 3.\n\nExample 2:\n\nInput: words = [\"a\",\"a\"], s = \"aa\"\nOutput: 2\nExplanation:\nBoth of the strings are a prefix of s.\nNote that the same string can occur multiple times in words, and it should be counted each time.\n\nConstraints:\n\n- 1 <= words.length <= 1000\n- 1 <= words[i].length, s.length <= 10\n- words[i] and s consist of lowercase English letters only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(words = ['hello', 'hell', 'he', 'h'],s = \"hello\") == 4\n    assert candidate(words = ['short'],s = \"shorter\") == 1\n    assert candidate(words = ['same', 'same'],s = \"same\") == 2\n    assert candidate(words = ['hello'],s = \"h\") == 0\n    assert candidate(words = ['hello'],s = \"hello\") == 1\n    assert candidate(words = ['d', 'do', 'dog', 'doge'],s = \"doge\") == 4\n    assert candidate(words = ['prefix'],s = \"prefix\") == 1\n    assert candidate(words = ['same', 'same', 'same'],s = \"same\") == 3\n    assert candidate(words = ['world'],s = \"world\") == 1\n    assert candidate(words = ['a', 'b', 'c'],s = \"abcde\") == 1\n    assert candidate(words = ['a'],s = \"a\") == 1\n    assert candidate(words = ['not', 'a', 'prefix'],s = \"example\") == 0\n    assert candidate(words = ['test', 'testing', 't'],s = \"testing\") == 3\n    assert candidate(words = ['xyz', 'xy', 'x'],s = \"xyz\") == 3\n    assert candidate(words = ['abcd'],s = \"abc\") == 0\n    assert candidate(words = ['a', 'b', 'c'],s = \"d\") == 0\n    assert candidate(words = ['test', 'testing', 'tested'],s = \"testing\") == 2\n    assert candidate(words = ['a', 'a'],s = \"aa\") == 2\n    assert candidate(words = ['abc'],s = \"abc\") == 1\n    assert candidate(words = ['abc', 'abcd', 'abcde'],s = \"abcdef\") == 3\n    assert candidate(words = ['z', 'zz', 'zzz'],s = \"zzzz\") == 3\n    assert candidate(words = ['cat', 'bat', 'rat'],s = \"car\") == 0\n    assert candidate(words = ['a', 'b', 'c', 'ab', 'bc', 'abc'],s = \"abc\") == 3\n    assert candidate(words = ['h'],s = \"hello\") == 1\n    assert candidate(words = ['a'],s = \"b\") == 0\n    assert candidate(words = ['yes', 'no'],s = \"yesman\") == 1\n    assert candidate(words = ['prefix'],s = \"prefixing\") == 1\n    assert candidate(words = ['hello', 'he', 'h'],s = \"hello\") == 3\n    assert candidate(words = ['test'],s = \"testing\") == 1\n    assert candidate(words = ['a', 'ab', 'abc', 'abcd'],s = \"abcd\") == 4\n    assert candidate(words = ['ab', 'abc', 'abcd'],s = \"abcd\") == 3\n    assert candidate(words = ['test', 'testing', 'tested', 'te'],s = \"testing\") == 3\n    assert candidate(words = ['unique', 'uniq', 'un'],s = \"unique\") == 3\n    assert candidate(words = ['different', 'dif', 'diff', 'differ'],s = \"different\") == 4\n    assert candidate(words = ['prefix', 'pre', 'pred'],s = \"predicate\") == 2\n    assert candidate(words = ['example', 'examp', 'exam', 'exa', 'ex', 'e'],s = \"example\") == 6\n    assert candidate(words = ['prefix', 'prefi', 'pref', 'pre'],s = \"prefix\") == 4\n    assert candidate(words = ['abc', 'abcd', 'ab', 'a'],s = \"abcd\") == 4\n    assert candidate(words = ['complex', 'com', 'comp', 'comple', 'complexe'],s = \"complex\") == 4\n    assert candidate(words = ['a', 'aa', 'aaa', 'aaaa'],s = \"aaaaa\") == 4\n    assert candidate(words = ['example', 'ex', 'exa', 'exam', 'examp', 'examp'],s = \"example\") == 6\n    assert candidate(words = ['complex', 'comple', 'compl', 'comp'],s = \"complexity\") == 4\n    assert candidate(words = ['hello', 'hell', 'he'],s = \"hello\") == 3\n    assert candidate(words = ['abcde', 'bcde', 'cde', 'de', 'e'],s = \"abcde\") == 1\n    assert candidate(words = ['abc', 'def', 'ghi'],s = \"abcdefghi\") == 1\n    assert candidate(words = ['not', 'no', 'n'],s = \"note\") == 3\n    assert candidate(words = ['multiple', 'multip', 'multi', 'mult', 'mult'],s = \"multiple\") == 5\n    assert candidate(words = ['word', 'words', 'wording'],s = \"word\") == 1\n    assert candidate(words = ['prefix', 'pre', 'p'],s = \"prefix\") == 3\n    assert candidate(words = ['overlap', 'over', 'ov', 'o'],s = \"overlap\") == 4\n    assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa'],s = \"aaaaaaaa\") == 5\n    assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa'],s = \"aaaaa\") == 5\n    assert candidate(words = ['short', 'shorter', 'shortest'],s = \"short\") == 1\n    assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg'],s = \"abcdefgh\") == 7\n    assert candidate(words = ['short', 'shot', 'sh', 's'],s = \"shortstory\") == 3\n    assert candidate(words = ['abcd', 'abc', 'ab', 'a'],s = \"a\") == 1\n    assert candidate(words = ['longword', 'long', 'lo', 'l', 'lon', 'longw'],s = \"longword\") == 6\n    assert candidate(words = ['a', 'b', 'c', 'd', 'e'],s = \"abcde\") == 1\n    assert candidate(words = ['prefix', 'pre', 'p'],s = \"prefix\") == 3\n    assert candidate(words = ['prefix', 'pre', 'pref', 'prefi', 'prefixe'],s = \"prefix\") == 4\n    assert candidate(words = ['aaa', 'aa', 'a'],s = \"aaaaa\") == 3\n    assert candidate(words = ['one', 'two', 'three', 'four'],s = \"one\") == 1\n    assert candidate(words = ['different', 'diff', 'diffe', 'differen', 'differen'],s = \"different\") == 5\n    assert candidate(words = ['unique', 'uniq', 'un', 'u'],s = \"unique\") == 4\n    assert candidate(words = ['aaa', 'aa', 'a', 'aaaa'],s = \"aaa\") == 3\n    assert candidate(words = ['abcd', 'bcde', 'cdef', 'defg'],s = \"abcd\") == 1\n    assert candidate(words = ['not', 'no', 'n'],s = \"note\") == 3\n    assert candidate(words = ['same', 'same', 'same', 'same'],s = \"same\") == 4\n    assert candidate(words = ['test', 'testing', 'tea', 'te'],s = \"testing\") == 3\n    assert candidate(words = ['begin', 'beg', 'be', 'b'],s = \"beginning\") == 4\n    assert candidate(words = ['overlap', 'over', 'o'],s = \"overlap\") == 3\n    assert candidate(words = ['test', 'testing', 'tes', 't'],s = \"testing\") == 4\n    assert candidate(words = ['xy', 'xyz', 'xyzz'],s = \"xy\") == 1\n    assert candidate(words = ['one', 'two', 'three', 'four', 'five'],s = \"fives\") == 1\n    assert candidate(words = ['longword', 'long', 'lo', 'l'],s = \"longword\") == 4\n    assert candidate(words = ['example', 'ex', 'exa', 'exam', 'examp'],s = \"example\") == 5\n    assert candidate(words = ['abc', 'abcd', 'abcde'],s = \"abcdef\") == 3\n    assert candidate(words = ['multiple', 'multi', 'mul', 'mu'],s = \"multiples\") == 4\n    assert candidate(words = ['word', 'wor', 'wo', 'w'],s = \"word\") == 4\n    assert candidate(words = ['banana', 'ban', 'ba', 'b'],s = \"bananarama\") == 4\n    assert candidate(words = ['abcd', 'abc', 'ab', 'a'],s = \"abcd\") == 4\n    assert candidate(words = ['a', 'aa', 'aaa', 'aaaa'],s = \"aaaa\") == 4\n    assert candidate(words = ['prefix', 'pre', 'prefixx', 'prefixxx', 'prefixxxx'],s = \"prefixx\") == 3\n    assert candidate(words = ['test', 'testing', 'tested'],s = \"testing\") == 2\n    assert candidate(words = ['part', 'partial', 'partially'],s = \"partially\") == 3\n    assert candidate(words = ['aaa', 'aa', 'a', 'aaaa'],s = \"aaaa\") == 4\n    assert candidate(words = ['one', 'two', 'three', 'four'],s = \"one\") == 1\n    assert candidate(words = ['prefix', 'pre', 'prex', 'abc'],s = \"prefix\") == 2\n    assert candidate(words = ['abc', 'abcd', 'abcde'],s = \"abcdefg\") == 3\n    assert candidate(words = ['repeat', 'repe', 'rep', 're', 'r'],s = \"repeat\") == 5\n    assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde'],s = \"a\") == 1\n    assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa'],s = \"aaaaaa\") == 5\n    assert candidate(words = ['complex', 'comp', 'com', 'co', 'c'],s = \"complexity\") == 5\n    assert candidate(words = ['python', 'pyth', 'py'],s = \"python\") == 3\n    assert candidate(words = ['xyz', 'xy', 'x'],s = \"xy\") == 2\n    assert candidate(words = ['complex', 'com', 'co', 'c'],s = \"complex\") == 4\n    assert candidate(words = ['prefix', 'prefixx', 'prefixxx', 'prefixxxx'],s = \"prefix\") == 1\n    assert candidate(words = ['abc', 'abcd', 'abcde'],s = \"abcdefg\") == 3\n    assert candidate(words = ['abc', 'def', 'ghi', 'abc'],s = \"abcdefghi\") == 2\n    assert candidate(words = ['cat', 'cattle', 'cattleman'],s = \"cattleman\") == 3\n    assert candidate(words = ['xyz', 'xy', 'x'],s = \"xyz\") == 3\n    assert candidate(words = ['same', 'same', 'same'],s = \"same\") == 3\n    assert candidate(words = ['prefix', 'pre', 'pref'],s = \"prefix\") == 3\n    assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef'],s = \"fghijkl\") == 0\n    assert candidate(words = ['small', 'smaller', 'smallest', 'smallerest'],s = \"smallerest\") == 3\n    assert candidate(words = ['abc', 'abcd', 'abcde', 'abcdef'],s = \"abcdefg\") == 4\n    assert candidate(words = ['test', 'testing', 'testi'],s = \"test\") == 1\n    assert candidate(words = ['zz', 'zzz', 'zzzz'],s = \"zzzz\") == 3\n    assert candidate(words = ['hello', 'he', 'hell'],s = \"hello\") == 3\n    assert candidate(words = ['prefix', 'pre', 'pref', 'prex'],s = \"prefix\") == 3\n    assert candidate(words = ['z', 'zz', 'zzz', 'zzzz'],s = \"zzzzzz\") == 4\n    assert candidate(words = ['unique', 'uniq', 'uni', 'un', 'u'],s = \"unique\") == 5\n    assert candidate(words = ['cat', 'dog', 'car', 'catch', 'cart'],s = \"catch\") == 2\n    assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],s = \"abcdefghij\") == 1\n    assert candidate(words = ['unique', 'uniq', 'uni', 'un'],s = \"uniques\") == 4\n    assert candidate(words = ['hello', 'world', 'hel', 'wo', 'wor'],s = \"helloworld\") == 2\n    assert candidate(words = ['overlap', 'over', 'ov', 'overlaplap'],s = \"overlap\") == 3\n    assert candidate(words = ['matching', 'match', 'mat', 'ma', 'm'],s = \"matching\") == 5\n    assert candidate(words = ['hello', 'hell', 'he', 'h', 'hellohello'],s = \"hellohello\") == 5\n    assert candidate(words = ['a', 'aa', 'aaa', 'aaaa'],s = \"aaaaaaaaa\") == 4\n    assert candidate(words = ['match', 'mat', 'ma', 'm'],s = \"match\") == 4\n    assert candidate(words = ['example', 'exa', 'ex', 'e'],s = \"example\") == 4\n    assert candidate(words = ['hello', 'hell', 'he', 'h'],s = \"hello\") == 4\n    assert candidate(words = ['word', 'wording', 'wordings'],s = \"word\") == 1\n    assert candidate(words = ['a', 'ab', 'abc', 'abcd'],s = \"abcde\") == 4\n    assert candidate(words = ['unique', 'uniqueness', 'uni', 'un'],s = \"uniqueness\") == 4\n    assert candidate(words = ['one', 'on', 'o', 'ones'],s = \"one\") == 3\n    assert candidate(words = ['word', 'wo', 'w'],s = \"word\") == 3\n    assert candidate(words = ['prefix', 'pre', 'pr', 'p'],s = \"prefix\") == 4\n    assert candidate(words = ['example', 'exam', 'ex', 'e'],s = \"examples\") == 4\n    assert candidate(words = ['common', 'commo', 'comm', 'com', 'co', 'c'],s = \"common\") == 6\n", "comparison": "exact"}, "public_tests": ["[\"a\",\"b\",\"c\",\"ab\",\"bc\",\"abc\"]\n\"abc\"", "[\"a\",\"a\"]\n\"aa\""], "hints": ["For each string in words, check if it is a prefix of s. If true, increment the answer by 1."], "metadata": {"canonical_parameter_names": ["words", "s"], "leetcode_dataset_entry_point": "Solution().countPrefixes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:28+00:00", "tests_total": 146, "tests_dropped": 15, "flags": [], "topic_tags": ["array", "string"]}, "language": "python", "interface": {"raw_signature": "def countPrefixes(self, words: list[str], s: str) -> int:", "container": "Solution", "callable": "countPrefixes", "parameters": [{"name": "words", "type": "list[str]"}, {"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2256, "task_id": "minimum-average-difference", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums of length n.\n\nThe average difference of the index i is the absolute difference between the average of the first i + 1 elements of nums and the average of the last n - i - 1 elements. Both averages should be rounded down to the nearest integer.\n\nReturn the index with the minimum average difference. If there are multiple such indices, return the smallest one.\n\nNote:\n\n- The absolute difference of two numbers is the absolute value of their difference.\n- The average of n elements is the sum of the n elements divided (integer division) by n.\n- The average of 0 elements is considered to be 0.\n\nExample 1:\n\nInput: nums = [2,5,3,9,5,3]\nOutput: 3\nExplanation:\n- The average difference of index 0 is: |2 / 1 - (5 + 3 + 9 + 5 + 3) / 5| = |2 / 1 - 25 / 5| = |2 - 5| = 3.\n- The average difference of index 1 is: |(2 + 5) / 2 - (3 + 9 + 5 + 3) / 4| = |7 / 2 - 20 / 4| = |3 - 5| = 2.\n- The average difference of index 2 is: |(2 + 5 + 3) / 3 - (9 + 5 + 3) / 3| = |10 / 3 - 17 / 3| = |3 - 5| = 2.\n- The average difference of index 3 is: |(2 + 5 + 3 + 9) / 4 - (5 + 3) / 2| = |19 / 4 - 8 / 2| = |4 - 4| = 0.\n- The average difference of index 4 is: |(2 + 5 + 3 + 9 + 5) / 5 - 3 / 1| = |24 / 5 - 3 / 1| = |4 - 3| = 1.\n- The average difference of index 5 is: |(2 + 5 + 3 + 9 + 5 + 3) / 6 - 0| = |27 / 6 - 0| = |4 - 0| = 4.\nThe average difference of index 3 is the minimum average difference so return 3.\n\nExample 2:\n\nInput: nums = [0]\nOutput: 0\nExplanation:\nThe only index is 0 so return 0.\nThe average difference of index 0 is: |0 / 1 - 0| = |0 - 0| = 0.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 0, 1, 0, 1]) == 1\n    assert candidate(nums = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0]) == 1\n    assert candidate(nums = [100000, 0, 0, 0, 0, 0]) == 5\n    assert candidate(nums = [0, 1, 0, 1, 0]) == 0\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n    assert candidate(nums = [1]) == 0\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n    assert candidate(nums = [10, 20, 30, 40, 50]) == 0\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n    assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [0]) == 0\n    assert candidate(nums = [100, 200, 300, 400, 500]) == 0\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 9\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000]) == 0\n    assert candidate(nums = [1, 0, 0, 0, 0]) == 1\n    assert candidate(nums = [5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [2, 5, 3, 9, 5, 3]) == 3\n    assert candidate(nums = [1, 2, 3]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 0\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n    assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16]) == 1\n    assert candidate(nums = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0]) == 1\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 0\n    assert candidate(nums = [100000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 14\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 90000, 9000, 900, 90]) == 5\n    assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 0\n    assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 1\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0]) == 11\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 4\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n    assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114]) == 0\n    assert candidate(nums = [100000, 0, 50000, 50000, 25000, 25000, 75000, 25000, 0, 100000]) == 4\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 0]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100000]) == 20\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n    assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 0\n    assert candidate(nums = [5, 3, 8, 1, 4, 2, 7, 6, 9, 0]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 0\n    assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]) == 3\n    assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 9\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000]) == 1\n    assert candidate(nums = [5, 2, 9, 1, 5, 6]) == 0\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 9\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 9\n    assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n    assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 0, 4, 5, 0, 6, 3, 7, 2, 8, 1, 9]) == 9\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\n    assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 0, 0, 0, 0, 0]) == 9\n    assert candidate(nums = [7, 3, 8, 5, 2, 6, 4, 9, 1, 10]) == 1\n    assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\n    assert candidate(nums = [100000, 0, 100000, 0, 100000, 0]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100000]) == 14\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n    assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n", "comparison": "exact"}, "public_tests": ["[2,5,3,9,5,3]", "[0]"], "hints": ["How can we use precalculation to efficiently calculate the average difference at an index?", "Create a prefix and/or suffix sum array."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumAverageDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:30+00:00", "tests_total": 94, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minimumAverageDifference(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minimumAverageDifference", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2257, "task_id": "count-unguarded-cells-in-the-grid", "difficulty": "Medium", "problem_description": "You are given two integers m and n representing a 0-indexed m x n grid. You are also given two 2D integer arrays guards and walls where guards[i] = [row_i, col_i] and walls[j] = [row_j, col_j] represent the positions of the i^th guard and j^th wall respectively.\n\nA guard can see every cell in the four cardinal directions (north, east, south, or west) starting from their position unless obstructed by a wall or another guard. A cell is guarded if there is at least one guard that can see it.\n\nReturn the number of unoccupied cells that are not guarded.\n\nExample 1:\n\nInput: m = 4, n = 6, guards = [[0,0],[1,1],[2,3]], walls = [[0,1],[2,2],[1,4]]\nOutput: 7\nExplanation: The guarded and unguarded cells are shown in red and green respectively in the above diagram.\nThere are a total of 7 unguarded cells, so we return 7.\n\nExample 2:\n\nInput: m = 3, n = 3, guards = [[1,1]], walls = [[0,1],[1,0],[2,1],[1,2]]\nOutput: 4\nExplanation: The unguarded cells are shown in green in the above diagram.\nThere are a total of 4 unguarded cells, so we return 4.\n\nConstraints:\n\n- 1 <= m, n <= 10^5\n- 2 <= m * n <= 10^5\n- 1 <= guards.length, walls.length <= 5 * 10^4\n- 2 <= guards.length + walls.length <= m * n\n- guards[i].length == walls[j].length == 2\n- 0 <= row_i, row_j < m\n- 0 <= col_i, col_j < n\n- All the positions in guards and walls are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(m = 4,n = 6,guards = [[0, 0], [1, 1], [2, 3]],walls = [[0, 1], [2, 2], [1, 4]]) == 7\n    assert candidate(m = 3,n = 3,guards = [[1, 1]],walls = [[0, 1], [1, 0], [2, 1], [1, 2]]) == 4\n    assert candidate(m = 5,n = 5,guards = [[2, 2]],walls = [[0, 0], [4, 4]]) == 14\n    assert candidate(m = 10,n = 10,guards = [[3, 3], [6, 6]],walls = [[1, 1], [8, 8]]) == 62\n    assert candidate(m = 6,n = 6,guards = [[1, 1], [4, 4]],walls = [[2, 2], [3, 3]]) == 14\n    assert candidate(m = 12,n = 12,guards = [[1, 1], [5, 5], [9, 9]],walls = [[2, 2], [6, 6], [10, 10], [3, 3], [7, 7], [11, 11]]) == 75\n    assert candidate(m = 10,n = 10,guards = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 2], [2, 0], [2, 1], [2, 2]],walls = [[1, 1]]) == 49\n    assert candidate(m = 10,n = 5,guards = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2]],walls = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [6, 4], [7, 4], [8, 4], [9, 4]]) == 1\n    assert candidate(m = 20,n = 10,guards = [[5, 2], [10, 7], [15, 3], [18, 8]],walls = [[0, 5], [4, 9], [9, 4], [14, 8], [19, 3], [7, 0]]) == 104\n    assert candidate(m = 15,n = 20,guards = [[2, 5], [4, 8], [10, 15]],walls = [[3, 3], [6, 7], [9, 12], [11, 14]]) == 200\n    assert candidate(m = 20,n = 20,guards = [[0, 0], [19, 19], [0, 19], [19, 0]],walls = [[5, 5], [15, 15], [10, 10], [14, 14], [9, 9], [11, 11]]) == 318\n    assert candidate(m = 10,n = 10,guards = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],walls = [[0, 0], [6, 6], [7, 7], [8, 8], [9, 9]]) == 20\n    assert candidate(m = 15,n = 20,guards = [[2, 2], [5, 5], [8, 8]],walls = [[3, 3], [7, 7], [11, 11], [13, 13]]) == 200\n    assert candidate(m = 45,n = 45,guards = [[10, 10], [20, 20], [30, 30], [40, 40]],walls = [[12, 12], [18, 18], [22, 22], [28, 28], [32, 32], [38, 38]]) == 1675\n    assert candidate(m = 18,n = 18,guards = [[9, 9], [10, 10], [11, 11], [12, 12], [13, 13]],walls = [[0, 0], [17, 17], [1, 1], [16, 16], [8, 8], [9, 9]]) == 164\n    assert candidate(m = 20,n = 20,guards = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],walls = [[6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 220\n    assert candidate(m = 15,n = 15,guards = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14]],walls = [[0, 7], [7, 0], [7, 7], [7, 14], [14, 7]]) == 3\n    assert candidate(m = 6,n = 9,guards = [[1, 1], [1, 8], [4, 4], [5, 5]],walls = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 6], [5, 7], [5, 8], [4, 8], [3, 8], [2, 8], [1, 8], [0, 8]]) == 8\n    assert candidate(m = 12,n = 12,guards = [[2, 2], [2, 9], [9, 2], [9, 9], [5, 5]],walls = [[3, 3], [3, 8], [8, 3], [8, 8], [6, 6]]) == 76\n    assert candidate(m = 12,n = 8,guards = [[2, 1], [5, 3], [8, 5]],walls = [[1, 2], [4, 4], [7, 6], [10, 7]]) == 41\n    assert candidate(m = 9,n = 9,guards = [[1, 1], [1, 7], [7, 1], [7, 7]],walls = [[2, 2], [2, 6], [6, 2], [6, 6], [3, 3], [3, 5], [5, 3], [5, 5]]) == 41\n    assert candidate(m = 100,n = 100,guards = [[25, 25], [50, 50], [75, 75]],walls = [[10, 10], [20, 20], [30, 30], [40, 40], [55, 55], [60, 60], [65, 65], [70, 70], [80, 80], [90, 90]]) == 9399\n    assert candidate(m = 25,n = 25,guards = [[12, 12], [13, 13], [14, 14]],walls = [[0, 0], [24, 24], [5, 5], [20, 20], [10, 10], [15, 15]]) == 478\n    assert candidate(m = 11,n = 7,guards = [[3, 1], [6, 4], [8, 6]],walls = [[1, 0], [2, 3], [4, 5], [5, 6], [7, 2]]) == 32\n    assert candidate(m = 10,n = 10,guards = [[3, 3], [3, 6], [6, 3], [6, 6]],walls = [[2, 2], [2, 7], [7, 2], [7, 7], [4, 4], [4, 5], [5, 4], [5, 5]]) == 56\n    assert candidate(m = 8,n = 12,guards = [[1, 5], [4, 7], [6, 3]],walls = [[0, 3], [3, 5], [5, 8], [7, 10]]) == 45\n    assert candidate(m = 8,n = 8,guards = [[2, 2], [3, 3], [4, 4]],walls = [[1, 1], [5, 5], [6, 6], [7, 7], [0, 0], [1, 6], [6, 1], [5, 7], [7, 5]]) == 16\n    assert candidate(m = 16,n = 16,guards = [[8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]],walls = [[0, 0], [1, 1], [15, 15], [14, 14], [7, 7], [6, 6]]) == 94\n    assert candidate(m = 8,n = 8,guards = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],walls = [[0, 0], [7, 7], [3, 3], [5, 5], [2, 2]]) == 0\n    assert candidate(m = 20,n = 20,guards = [[5, 5], [10, 10], [15, 15]],walls = [[0, 0], [19, 19], [9, 9], [14, 14], [15, 5], [5, 15], [10, 0], [10, 19]]) == 303\n    assert candidate(m = 8,n = 8,guards = [[1, 1], [1, 6], [6, 1], [6, 6]],walls = [[2, 3], [2, 5], [5, 2], [5, 5]]) == 32\n    assert candidate(m = 7,n = 7,guards = [[1, 1], [1, 5], [5, 1], [5, 5]],walls = [[0, 3], [3, 0], [3, 6], [6, 3]]) == 21\n    assert candidate(m = 10,n = 5,guards = [[0, 0], [0, 4], [5, 0], [5, 4]],walls = [[1, 2], [2, 2], [3, 2], [4, 2], [6, 2], [7, 2], [8, 2], [9, 2]]) == 16\n    assert candidate(m = 70,n = 70,guards = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60]],walls = [[15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65]]) == 4090\n    assert candidate(m = 10,n = 10,guards = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],walls = [[1, 1], [1, 9], [9, 1], [9, 9], [0, 0], [0, 9], [9, 0], [5, 1], [5, 9]]) == 3\n    assert candidate(m = 5,n = 10,guards = [[0, 0], [0, 9], [4, 0], [4, 9]],walls = [[2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8]]) == 16\n    assert candidate(m = 10,n = 10,guards = [[0, 0], [0, 9], [9, 0], [9, 9]],walls = [[2, 2], [2, 7], [7, 2], [7, 7]]) == 60\n    assert candidate(m = 7,n = 7,guards = [[1, 1], [1, 5], [5, 1], [5, 5]],walls = [[2, 2], [2, 5], [5, 2], [5, 5], [3, 3]]) == 23\n    assert candidate(m = 8,n = 8,guards = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],walls = [[0, 0], [7, 7], [0, 7], [7, 0]]) == 5\n    assert candidate(m = 10,n = 10,guards = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],walls = [[1, 1], [8, 8], [9, 9], [0, 0]]) == 12\n    assert candidate(m = 7,n = 7,guards = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],walls = [[0, 0], [1, 2], [2, 4], [3, 5], [4, 6], [5, 0], [6, 1], [6, 6]]) == 11\n    assert candidate(m = 20,n = 20,guards = [[5, 5], [10, 10], [15, 15]],walls = [[2, 2], [7, 7], [12, 12], [17, 17]]) == 285\n    assert candidate(m = 100,n = 100,guards = [[10, 10], [40, 50], [70, 80]],walls = [[15, 15], [30, 30], [60, 60], [85, 85]]) == 9405\n    assert candidate(m = 20,n = 20,guards = [[5, 5], [10, 10], [15, 15]],walls = [[0, 0], [19, 19], [5, 10], [10, 15], [15, 5], [5, 15], [10, 5]]) == 331\n    assert candidate(m = 15,n = 15,guards = [[2, 2], [7, 7], [12, 12]],walls = [[3, 3], [4, 4], [5, 5], [6, 6], [8, 8], [9, 9], [10, 10], [11, 11], [13, 13], [14, 14]]) == 134\n    assert candidate(m = 18,n = 10,guards = [[3, 3], [7, 3], [11, 3], [3, 7], [7, 7], [11, 7]],walls = [[2, 2], [2, 8], [8, 2], [8, 8], [5, 5]]) == 115\n    assert candidate(m = 10,n = 5,guards = [[2, 1], [7, 3]],walls = [[1, 1], [1, 3], [3, 1], [3, 3], [5, 1], [5, 3], [8, 1], [8, 3]]) == 31\n    assert candidate(m = 15,n = 15,guards = [[2, 2], [5, 5], [8, 8]],walls = [[3, 3], [6, 6], [9, 9], [4, 4], [7, 7], [10, 10]]) == 138\n    assert candidate(m = 20,n = 20,guards = [[5, 5], [10, 10], [15, 15]],walls = [[2, 2], [4, 4], [6, 6], [8, 8], [12, 12], [14, 14], [16, 16], [18, 18]]) == 281\n    assert candidate(m = 7,n = 7,guards = [[0, 0], [0, 6], [6, 0], [6, 6], [3, 3]],walls = [[1, 1], [1, 5], [5, 1], [5, 5], [2, 2], [2, 4], [4, 2], [4, 4]]) == 8\n    assert candidate(m = 8,n = 8,guards = [[1, 1], [1, 7], [7, 1], [7, 7], [3, 3], [3, 4], [4, 3], [4, 4]],walls = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7]]) == 12\n    assert candidate(m = 7,n = 7,guards = [[1, 3], [2, 4], [3, 5], [4, 1], [5, 2], [6, 3]],walls = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [5, 6], [4, 6], [3, 6], [2, 6], [1, 6]]) == 0\n    assert candidate(m = 12,n = 10,guards = [[2, 2], [2, 3], [3, 2], [3, 3], [5, 5], [6, 6], [7, 7], [8, 8]],walls = [[1, 1], [1, 2], [1, 3], [1, 4], [4, 4], [5, 4], [6, 4], [7, 4], [8, 4], [9, 9]]) == 30\n    assert candidate(m = 12,n = 12,guards = [[3, 3], [6, 6], [9, 9]],walls = [[2, 2], [4, 4], [5, 5], [7, 7], [8, 8], [10, 10], [11, 11], [0, 0], [1, 1]]) == 72\n    assert candidate(m = 14,n = 14,guards = [[2, 2], [2, 11], [11, 2], [11, 11]],walls = [[3, 3], [3, 10], [10, 3], [10, 10], [5, 5], [5, 8], [8, 5], [8, 8]]) == 136\n    assert candidate(m = 12,n = 12,guards = [[6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],walls = [[0, 0], [11, 11], [10, 10], [9, 9], [8, 8]]) == 31\n    assert candidate(m = 10,n = 10,guards = [[1, 1], [1, 8], [8, 1], [8, 8], [4, 4]],walls = [[0, 0], [0, 9], [9, 0], [9, 9], [2, 2], [2, 7], [7, 2], [7, 7]]) == 41\n    assert candidate(m = 9,n = 9,guards = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],walls = [[4, 3], [4, 5], [5, 4], [3, 4]]) == 14\n    assert candidate(m = 15,n = 15,guards = [[2, 3], [4, 5], [6, 7]],walls = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 139\n    assert candidate(m = 80,n = 80,guards = [[10, 10], [30, 30], [50, 50], [70, 70]],walls = [[15, 15], [35, 35], [55, 55], [75, 75]]) == 5772\n    assert candidate(m = 6,n = 6,guards = [[1, 1], [1, 4], [4, 1], [4, 4]],walls = [[0, 0], [0, 5], [5, 0], [5, 5], [2, 2], [3, 3]]) == 10\n    assert candidate(m = 8,n = 8,guards = [[1, 1], [2, 2], [3, 3], [4, 4]],walls = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]]) == 30\n    assert candidate(m = 25,n = 15,guards = [[3, 4], [8, 9], [13, 14], [18, 1], [23, 6]],walls = [[2, 5], [7, 10], [12, 13], [17, 2], [22, 7]]) == 195\n    assert candidate(m = 15,n = 20,guards = [[5, 5], [7, 7], [10, 10]],walls = [[3, 3], [12, 12], [8, 8], [6, 6]]) == 200\n    assert candidate(m = 20,n = 20,guards = [[5, 5], [10, 10], [15, 15]],walls = [[2, 2], [3, 3], [4, 4], [6, 6], [7, 7], [8, 8], [9, 9], [11, 11], [12, 12], [13, 13], [14, 14], [16, 16], [17, 17], [18, 18], [19, 19]]) == 274\n    assert candidate(m = 50,n = 50,guards = [[10, 10], [20, 20], [30, 30], [40, 40]],walls = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45]]) == 2111\n    assert candidate(m = 8,n = 5,guards = [[1, 1], [1, 3], [3, 1], [3, 3]],walls = [[0, 0], [0, 4], [4, 0], [4, 4], [2, 2]]) == 13\n    assert candidate(m = 50,n = 50,guards = [[25, 25], [25, 26], [24, 25]],walls = [[24, 24], [24, 26], [26, 25], [26, 26]]) == 2421\n    assert candidate(m = 15,n = 20,guards = [[2, 2], [5, 5], [7, 7], [10, 10]],walls = [[1, 1], [3, 3], [8, 8], [12, 12], [14, 19]]) == 171\n    assert candidate(m = 5,n = 10,guards = [[1, 2], [3, 7]],walls = [[1, 1], [1, 3], [2, 1], [2, 3], [3, 1], [3, 3], [4, 1], [4, 3], [1, 8], [1, 9], [2, 8], [2, 9], [3, 8], [3, 9], [4, 8], [4, 9]]) == 21\n    assert candidate(m = 7,n = 7,guards = [[1, 1], [5, 5]],walls = [[2, 2], [2, 3], [2, 4], [3, 2], [3, 4], [4, 2], [4, 3], [4, 4]]) == 17\n    assert candidate(m = 30,n = 30,guards = [[1, 1], [2, 2], [3, 3], [4, 4]],walls = [[5, 5], [6, 6], [7, 7], [8, 8]]) == 672\n    assert candidate(m = 15,n = 15,guards = [[3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13]],walls = [[1, 1], [2, 2], [4, 4], [6, 6], [8, 8], [10, 10], [12, 12], [14, 14]]) == 73\n    assert candidate(m = 10,n = 10,guards = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],walls = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 28\n    assert candidate(m = 12,n = 12,guards = [[3, 3], [4, 4], [5, 5], [6, 6]],walls = [[1, 1], [2, 2], [7, 7], [8, 8], [9, 9], [10, 10]]) == 58\n    assert candidate(m = 6,n = 6,guards = [[0, 0], [5, 5]],walls = [[1, 1], [1, 4], [2, 2], [2, 3], [3, 2], [3, 3], [4, 1], [4, 4]]) == 8\n    assert candidate(m = 9,n = 9,guards = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],walls = [[0, 0], [8, 8], [1, 1], [7, 7], [2, 2], [3, 3]]) == 12\n    assert candidate(m = 15,n = 15,guards = [[2, 2], [7, 7], [12, 12]],walls = [[0, 0], [5, 5], [10, 10], [14, 14]]) == 140\n    assert candidate(m = 15,n = 15,guards = [[2, 2], [5, 5], [8, 8], [11, 11]],walls = [[3, 3], [6, 6], [9, 9], [12, 12], [0, 0], [14, 14]]) == 115\n    assert candidate(m = 15,n = 10,guards = [[5, 5], [10, 5], [14, 5]],walls = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [11, 5], [12, 5], [13, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 99\n    assert candidate(m = 7,n = 11,guards = [[1, 3], [4, 6], [6, 8]],walls = [[0, 1], [2, 4], [3, 5], [5, 7], [6, 9]]) == 29\n    assert candidate(m = 10,n = 10,guards = [[1, 2], [2, 1], [3, 3], [6, 6], [8, 8]],walls = [[0, 0], [4, 4], [5, 5], [9, 9]]) == 21\n    assert candidate(m = 20,n = 20,guards = [[5, 5], [10, 10], [15, 15]],walls = [[3, 3], [4, 4], [6, 6], [7, 7], [9, 9], [11, 11], [13, 13], [14, 14], [16, 16], [17, 17], [19, 19]]) == 278\n", "comparison": "exact"}, "public_tests": ["4\n6\n[[0,0],[1,1],[2,3]]\n[[0,1],[2,2],[1,4]]", "3\n3\n[[1,1]]\n[[0,1],[1,0],[2,1],[1,2]]"], "hints": ["Create a 2D array to represent the grid. Can you mark the tiles that can be seen by a guard?", "Iterate over the guards, and for each of the 4 directions, advance the current tile and mark the tile. When should you stop advancing?"], "metadata": {"canonical_parameter_names": ["m", "n", "guards", "walls"], "leetcode_dataset_entry_point": "Solution().countUnguarded", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:33+00:00", "tests_total": 83, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "matrix", "simulation"]}, "language": "python", "interface": {"raw_signature": "def countUnguarded(self, m: int, n: int, guards: list[list[int]], walls: list[list[int]]) -> int:", "container": "Solution", "callable": "countUnguarded", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "guards", "type": "list[list[int]]"}, {"name": "walls", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2258, "task_id": "escape-the-spreading-fire", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array grid of size m x n which represents a field. Each cell has one of three values:\n\n- 0 represents grass,\n- 1 represents fire,\n- 2 represents a wall that you and fire cannot pass through.\n\nYou are situated in the top-left cell, (0, 0), and you want to travel to the safehouse at the bottom-right cell, (m - 1, n - 1). Every minute, you may move to an adjacent grass cell. After your move, every fire cell will spread to all adjacent cells that are not walls.\n\nReturn the maximum number of minutes that you can stay in your initial position before moving while still safely reaching the safehouse. If this is impossible, return -1. If you can always reach the safehouse regardless of the minutes stayed, return 10^9.\n\nNote that even if the fire spreads to the safehouse immediately after you have reached it, it will be counted as safely reaching the safehouse.\n\nA cell is adjacent to another cell if the former is directly north, east, south, or west of the latter (i.e., their sides are touching).\n\nExample 1:\n\nInput: grid = [[0,2,0,0,0,0,0],[0,0,0,2,2,1,0],[0,2,0,0,1,2,0],[0,0,2,2,2,0,2],[0,0,0,0,0,0,0]]\nOutput: 3\nExplanation: The figure above shows the scenario where you stay in the initial position for 3 minutes.\nYou will still be able to safely reach the safehouse.\nStaying for more than 3 minutes will not allow you to safely reach the safehouse.\n\nExample 2:\n\nInput: grid = [[0,0,0,0],[0,1,2,0],[0,2,0,0]]\nOutput: -1\nExplanation: The figure above shows the scenario where you immediately move towards the safehouse.\nFire will spread to any cell you move towards and it is impossible to safely reach the safehouse.\nThus, -1 is returned.\n\nExample 3:\n\nInput: grid = [[0,0,0],[2,2,0],[1,2,0]]\nOutput: 1000000000\nExplanation: The figure above shows the initial grid.\nNotice that the fire is contained by walls and you will always be able to safely reach the safehouse.\nThus, 10^9 is returned.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 2 <= m, n <= 300\n- 4 <= m * n <= 2 * 10^4\n- grid[i][j] is either 0, 1, or 2.\n- grid[0][0] == grid[m - 1][n - 1] == 0\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[0, 0, 0, 0], [0, 1, 2, 0], [0, 2, 0, 0]]) == -1\n    assert candidate(grid = [[0, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 1, 0, 0, 0], [0, 0, 0, 2, 0], [0, 2, 0, 0, 0], [0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 2, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 2, 0, 0]]) == -1\n    assert candidate(grid = [[0, 1, 0, 0, 0], [0, 2, 0, 2, 0], [0, 0, 0, 2, 0], [0, 1, 0, 0, 0], [0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 2, 1, 0], [0, 2, 0, 0, 0, 0], [0, 0, 2, 2, 0, 0], [0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 1], [0, 2, 2, 0], [0, 2, 2, 0], [0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 1], [0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 1000000000\n    assert candidate(grid = [[0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 2, 2, 1, 0], [0, 2, 0, 0, 1, 2, 0], [0, 0, 2, 2, 2, 0, 2], [0, 0, 0, 0, 0, 0, 0]]) == 3\n    assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 2, 2, 1, 0], [0, 2, 0, 0, 0, 2, 0], [0, 0, 2, 2, 2, 0, 2], [0, 0, 0, 0, 0, 0, 0]]) == 0\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 2, 2, 2, 0], [0, 2, 0, 2, 0], [0, 2, 2, 2, 0], [0, 0, 0, 0, 0]]) == 1000000000\n    assert candidate(grid = [[0, 0, 0], [2, 2, 0], [1, 2, 0]]) == 1000000000\n    assert candidate(grid = [[0, 0, 2, 0, 0, 0, 0], [0, 1, 1, 1, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0], [0, 1, 1, 1, 0, 2, 0], [0, 0, 2, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0], [0, 1, 0, 2, 1, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 2, 0, 0], [0, 0, 0, 1, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 1, 2, 0, 1, 2, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 1, 0, 2, 0, 2, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [2, 1, 2, 0, 1, 2, 1, 0, 1, 2], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 2, 1, 2, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n    assert candidate(grid = [[0, 0, 0, 0, 0, 2, 0, 0], [0, 1, 0, 1, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 2, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 2, 0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 2, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 2], [0, 0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 0, 1, 2, 1, 2, 0, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 1, 0], [2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 2, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 1, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 0, 1, 2, 1, 2, 1, 0, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 2, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 2, 2, 1, 0], [0, 2, 0, 0, 1, 2, 0], [0, 0, 2, 2, 2, 0, 2], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 1, 0, 1, 0, 2, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 2, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 0, 2, 0, 2, 1, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 1, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 2, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0], [0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 2, 2, 0, 0], [0, 0, 2, 2, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 2, 0, 0], [0, 1, 0, 2, 0, 2, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 1, 2, 0, 0, 2, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 2, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 2, 0, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 2, 2, 0, 0], [0, 0, 0, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 2, 2, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 2], [0, 1, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 2, 0, 1, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 2, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 2, 0, 0], [0, 0, 1, 2, 0, 2, 1, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 2, 0, 0], [0, 0, 1, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 2, 2, 2, 0, 0, 0], [0, 1, 1, 1, 2, 0, 2, 1, 1, 0], [0, 0, 0, 0, 2, 2, 2, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 2, 0, 0], [0, 1, 2, 2, 2, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 2, 0, 0], [0, 1, 0, 2, 0, 0, 0, 0], [0, 0, 0, 2, 2, 0, 1, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 2, 2, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 1, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 1, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 2, 1, 2, 0], [0, 0, 1, 0, 0, 0], [0, 2, 0, 2, 1, 0], [0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 2, 2, 2, 2, 1, 0], [0, 1, 2, 0, 0, 0, 2, 1, 0], [0, 1, 2, 0, 1, 0, 2, 1, 0], [0, 1, 2, 0, 0, 0, 2, 1, 0], [0, 1, 2, 2, 2, 2, 2, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 1, 0], [0, 0, 0, 0, 2, 2, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 1, 0, 0, 0, 1, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 1, 2, 0], [0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 2, 1, 0, 2, 1, 0, 2, 0], [0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 1, 2, 0], [0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 2, 1, 0, 2, 1, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 0, 2, 0], [0, 0, 0, 0, 1, 0, 0], [0, 2, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 2, 1, 0, 0, 2, 0], [0, 0, 0, 0, 2, 0, 0], [0, 2, 0, 0, 0, 2, 0], [0, 0, 0, 2, 0, 0, 0], [0, 2, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 2, 2, 2, 2, 1, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 2, 2, 0, 2, 1, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 1, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 2, 2, 0, 0, 1, 0], [0, 2, 0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 2, 0, 2, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 2, 2, 2, 2, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 2, 2, 2, 2, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 2, 2, 2, 2, 2, 2, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 2, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 0, 1, 2, 1, 0, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 2, 0], [0, 2, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 2, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 2, 2, 2, 2, 2, 2, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 1, 2, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0, 2, 0], [0, 2, 1, 0, 2, 1, 0, 2, 0, 2], [0, 0, 0, 2, 0, 0, 0, 0, 2, 0], [0, 1, 0, 0, 1, 0, 1, 2, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0, 2, 0], [0, 2, 1, 0, 2, 1, 0, 2, 0, 2], [0, 0, 0, 2, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 0, 1, 2, 0, 2, 1, 0], [0, 1, 2, 0, 0, 0, 0, 2, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 2, 0, 2, 1, 2], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0], [0, 0, 1, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n    assert candidate(grid = [[0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1000000000\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n", "comparison": "exact"}, "public_tests": ["[[0,2,0,0,0,0,0],[0,0,0,2,2,1,0],[0,2,0,0,1,2,0],[0,0,2,2,2,0,2],[0,0,0,0,0,0,0]]", "[[0,0,0,0],[0,1,2,0],[0,2,0,0]]", "[[0,0,0],[2,2,0],[1,2,0]]"], "hints": ["For some tile (x, y), how can we determine when, if ever, the fire will reach it?", "We can use multi-source BFS to find the earliest time the fire will reach each cell.", "Then, starting with a given t minutes of staying in the initial position, we can check if there is a safe path to the safehouse using the obtained information about the fire.", "We can use binary search to efficiently find the maximum t that allows us to reach the safehouse."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maximumMinutes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:35+00:00", "tests_total": 85, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "binary-search", "breadth-first-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def maximumMinutes(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "maximumMinutes", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2259, "task_id": "remove-digit-from-number-to-maximize-result", "difficulty": "Easy", "problem_description": "You are given a string number representing a positive integer and a character digit.\n\nReturn the resulting string after removing exactly one occurrence of digit from number such that the value of the resulting string in decimal form is maximized. The test cases are generated such that digit occurs at least once in number.\n\nExample 1:\n\nInput: number = \"123\", digit = \"3\"\nOutput: \"12\"\nExplanation: There is only one '3' in \"123\". After removing '3', the result is \"12\".\n\nExample 2:\n\nInput: number = \"1231\", digit = \"1\"\nOutput: \"231\"\nExplanation: We can remove the first '1' to get \"231\" or remove the second '1' to get \"123\".\nSince 231 > 123, we return \"231\".\n\nExample 3:\n\nInput: number = \"551\", digit = \"5\"\nOutput: \"51\"\nExplanation: We can remove either the first or second '5' from \"551\".\nBoth result in the string \"51\".\n\nConstraints:\n\n- 2 <= number.length <= 100\n- number consists of digits from '1' to '9'.\n- digit is a digit from '1' to '9'.\n- digit occurs at least once in number.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(number = \"222333\",digit = \"2\") == \"22333\"\n    assert candidate(number = \"99999\",digit = \"9\") == \"9999\"\n    assert candidate(number = \"999\",digit = \"9\") == \"99\"\n    assert candidate(number = \"551\",digit = \"5\") == \"51\"\n    assert candidate(number = \"987654321\",digit = \"9\") == \"87654321\"\n    assert candidate(number = \"123456789\",digit = \"5\") == \"12346789\"\n    assert candidate(number = \"11111\",digit = \"1\") == \"1111\"\n    assert candidate(number = \"123456789123456789\",digit = \"4\") == \"12356789123456789\"\n    assert candidate(number = \"11211\",digit = \"1\") == \"1211\"\n    assert candidate(number = \"123\",digit = \"3\") == \"12\"\n    assert candidate(number = \"111111111\",digit = \"1\") == \"11111111\"\n    assert candidate(number = \"1112\",digit = \"1\") == \"112\"\n    assert candidate(number = \"999999999\",digit = \"9\") == \"99999999\"\n    assert candidate(number = \"1231\",digit = \"1\") == \"231\"\n    assert candidate(number = \"1221\",digit = \"1\") == \"221\"\n    assert candidate(number = \"87654321\",digit = \"8\") == \"7654321\"\n    assert candidate(number = \"3141592653589793\",digit = \"1\") == \"341592653589793\"\n    assert candidate(number = \"123456789\",digit = \"8\") == \"12345679\"\n    assert candidate(number = \"987654321\",digit = \"2\") == \"98765431\"\n    assert candidate(number = \"1221\",digit = \"2\") == \"121\"\n    assert candidate(number = \"2222222\",digit = \"2\") == \"222222\"\n    assert candidate(number = \"1111\",digit = \"1\") == \"111\"\n    assert candidate(number = \"123456789\",digit = \"9\") == \"12345678\"\n    assert candidate(number = \"5656565656\",digit = \"6\") == \"565656565\"\n    assert candidate(number = \"987654321123456789\",digit = \"4\") == \"98765432112356789\"\n    assert candidate(number = \"123123123123\",digit = \"2\") == \"13123123123\"\n    assert candidate(number = \"9898989898\",digit = \"8\") == \"998989898\"\n    assert candidate(number = \"1122334455\",digit = \"1\") == \"122334455\"\n    assert candidate(number = \"333333333\",digit = \"3\") == \"33333333\"\n    assert candidate(number = \"12345654321\",digit = \"3\") == \"1245654321\"\n    assert candidate(number = \"112233445566778899\",digit = \"5\") == \"11223344566778899\"\n    assert candidate(number = \"987987987\",digit = \"7\") == \"98987987\"\n    assert candidate(number = \"5959595959\",digit = \"9\") == \"595959595\"\n    assert candidate(number = \"987654321123456789987654321\",digit = \"3\") == \"98765432112456789987654321\"\n    assert candidate(number = \"122122122\",digit = \"2\") == \"12212212\"\n    assert candidate(number = \"11111111111111111111111111111111111111111111111111\",digit = \"1\") == \"1111111111111111111111111111111111111111111111111\"\n    assert candidate(number = \"1919191919191919\",digit = \"9\") == \"191919191919191\"\n    assert candidate(number = \"543219876\",digit = \"9\") == \"54321876\"\n    assert candidate(number = \"987654321987654321987654321987654321\",digit = \"8\") == \"98765432198765432198765432197654321\"\n    assert candidate(number = \"123412341234\",digit = \"2\") == \"13412341234\"\n    assert candidate(number = \"1919191919\",digit = \"9\") == \"191919191\"\n    assert candidate(number = \"1919191919191919191919191919191919191919191919191\",digit = \"9\") == \"191919191919191919191919191919191919191919191911\"\n    assert candidate(number = \"9999999999\",digit = \"9\") == \"999999999\"\n    assert candidate(number = \"543219876987654321\",digit = \"9\") == \"54321987687654321\"\n    assert candidate(number = \"987654321123456789\",digit = \"1\") == \"98765432123456789\"\n    assert candidate(number = \"3131313131\",digit = \"1\") == \"331313131\"\n    assert candidate(number = \"555555555555555555555\",digit = \"5\") == \"55555555555555555555\"\n    assert candidate(number = \"9999999999999999999\",digit = \"9\") == \"999999999999999999\"\n    assert candidate(number = \"1212121212\",digit = \"2\") == \"121212121\"\n    assert candidate(number = \"12345123451234512345\",digit = \"4\") == \"1235123451234512345\"\n    assert candidate(number = \"91827364591827364591\",digit = \"1\") == \"9827364591827364591\"\n    assert candidate(number = \"567567567\",digit = \"7\") == \"56756756\"\n    assert candidate(number = \"999888777666555444333222111\",digit = \"9\") == \"99888777666555444333222111\"\n    assert candidate(number = \"5645645645645645645645645645645645645645645645645\",digit = \"5\") == \"645645645645645645645645645645645645645645645645\"\n    assert candidate(number = \"1234321\",digit = \"3\") == \"124321\"\n    assert candidate(number = \"123456789123456789123456789\",digit = \"8\") == \"12345679123456789123456789\"\n    assert candidate(number = \"123123123123123\",digit = \"1\") == \"23123123123123\"\n    assert candidate(number = \"5656565656\",digit = \"5\") == \"656565656\"\n    assert candidate(number = \"918273645\",digit = \"9\") == \"18273645\"\n    assert candidate(number = \"12233445566778899\",digit = \"9\") == \"1223344556677889\"\n    assert candidate(number = \"5555555555555555555\",digit = \"5\") == \"555555555555555555\"\n    assert candidate(number = \"999999999999999999999\",digit = \"9\") == \"99999999999999999999\"\n    assert candidate(number = \"33333333333333333333333333333333333333333333333333\",digit = \"3\") == \"3333333333333333333333333333333333333333333333333\"\n    assert candidate(number = \"3232323232323232\",digit = \"3\") == \"323232323232322\"\n    assert candidate(number = \"123456789\",digit = \"2\") == \"13456789\"\n    assert candidate(number = \"19191919191919191919\",digit = \"9\") == \"1919191919191919191\"\n    assert candidate(number = \"123123123\",digit = \"1\") == \"23123123\"\n    assert candidate(number = \"5645645645645645645645645645645645645645645645645\",digit = \"6\") == \"564564564564564564564564564564564564564564564545\"\n    assert candidate(number = \"123987654321987654321987654321\",digit = \"9\") == \"12398765432198765432187654321\"\n    assert candidate(number = \"1212121212121212121\",digit = \"2\") == \"121212121212121211\"\n    assert candidate(number = \"123123123123123123123\",digit = \"3\") == \"12312312312312312312\"\n    assert candidate(number = \"11111111111111111111\",digit = \"1\") == \"1111111111111111111\"\n    assert candidate(number = \"112233445566778899\",digit = \"1\") == \"12233445566778899\"\n    assert candidate(number = \"2222222222222222222222222222222\",digit = \"2\") == \"222222222222222222222222222222\"\n    assert candidate(number = \"123987654321987654321987654321\",digit = \"1\") == \"23987654321987654321987654321\"\n    assert candidate(number = \"987654321987654321\",digit = \"9\") == \"98765432187654321\"\n    assert candidate(number = \"11111111111111111111111111111111111111111111\",digit = \"1\") == \"1111111111111111111111111111111111111111111\"\n    assert candidate(number = \"9999999999999999999999999999999999999999999999999\",digit = \"9\") == \"999999999999999999999999999999999999999999999999\"\n    assert candidate(number = \"111222333444555666777888999\",digit = \"3\") == \"11122233444555666777888999\"\n    assert candidate(number = \"23333332\",digit = \"3\") == \"2333332\"\n    assert candidate(number = \"22222222222222222222222222222222222222222222\",digit = \"2\") == \"2222222222222222222222222222222222222222222\"\n    assert candidate(number = \"99999999991\",digit = \"9\") == \"9999999991\"\n    assert candidate(number = \"333333\",digit = \"3\") == \"33333\"\n    assert candidate(number = \"123456789123456789123456789\",digit = \"9\") == \"12345678912345678912345678\"\n    assert candidate(number = \"123412341234\",digit = \"1\") == \"23412341234\"\n    assert candidate(number = \"987654321123456789\",digit = \"9\") == \"98765432112345678\"\n    assert candidate(number = \"543212345\",digit = \"2\") == \"54321345\"\n    assert candidate(number = \"1111111111\",digit = \"1\") == \"111111111\"\n    assert candidate(number = \"432143214321\",digit = \"2\") == \"43214321431\"\n    assert candidate(number = \"12233445566778899\",digit = \"1\") == \"2233445566778899\"\n    assert candidate(number = \"5555555555555555555555555555555555555555555555555\",digit = \"5\") == \"555555555555555555555555555555555555555555555555\"\n    assert candidate(number = \"11112222\",digit = \"2\") == \"1111222\"\n    assert candidate(number = \"31415926535\",digit = \"1\") == \"3415926535\"\n    assert candidate(number = \"98877665544332211\",digit = \"8\") == \"9877665544332211\"\n    assert candidate(number = \"2468135791113151719\",digit = \"1\") == \"246835791113151719\"\n    assert candidate(number = \"12345678987654321\",digit = \"7\") == \"1234568987654321\"\n", "comparison": "exact"}, "public_tests": ["\"123\"\n\"3\"", "\"1231\"\n\"1\"", "\"551\"\n\"5\""], "hints": ["The maximum length of number is really small.", "Iterate through the digits of number and every time we see digit, try removing it.", "To remove a character at index i, concatenate the substring from index 0 to i - 1 and the substring from index i + 1 to number.length - 1."], "metadata": {"canonical_parameter_names": ["number", "digit"], "leetcode_dataset_entry_point": "Solution().removeDigit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:37+00:00", "tests_total": 126, "tests_dropped": 30, "flags": [], "topic_tags": ["string", "greedy", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def removeDigit(self, number: str, digit: str) -> str:", "container": "Solution", "callable": "removeDigit", "parameters": [{"name": "number", "type": "str"}, {"name": "digit", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2260, "task_id": "minimum-consecutive-cards-to-pick-up", "difficulty": "Medium", "problem_description": "You are given an integer array cards where cards[i] represents the value of the i^th card. A pair of cards are matching if the cards have the same value.\n\nReturn the minimum number of consecutive cards you have to pick up to have a pair of matching cards among the picked cards. If it is impossible to have matching cards, return -1.\n\nExample 1:\n\nInput: cards = [3,4,2,3,4,7]\nOutput: 4\nExplanation: We can pick up the cards [3,4,2,3] which contain a matching pair of cards with value 3. Note that picking up the cards [4,2,3,4] is also optimal.\n\nExample 2:\n\nInput: cards = [1,0,5,3]\nOutput: -1\nExplanation: There is no way to pick up a set of consecutive cards that contain a pair of matching cards.\n\nConstraints:\n\n- 1 <= cards.length <= 10^5\n- 0 <= cards[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(cards = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 11\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 21\n    assert candidate(cards = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 10\n    assert candidate(cards = [3, 4, 2, 3, 4, 7]) == 4\n    assert candidate(cards = [0, 0]) == 2\n    assert candidate(cards = [1, 1]) == 2\n    assert candidate(cards = [0, 0, 0, 0, 0]) == 2\n    assert candidate(cards = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1]) == -1\n    assert candidate(cards = [5]) == -1\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n    assert candidate(cards = [1000000, 999999, 1000000]) == 3\n    assert candidate(cards = [1, 1, 1, 1, 1]) == 2\n    assert candidate(cards = [1, 0, 5, 3]) == -1\n    assert candidate(cards = [1000000, 0, 1000000]) == 3\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1]) == 51\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1]) == 12\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1]) == 51\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n    assert candidate(cards = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 2\n    assert candidate(cards = [5, 3, 8, 10, 5, 3, 8, 10, 5, 3, 8, 10, 5, 3, 8, 10, 5, 3, 8, 10]) == 5\n    assert candidate(cards = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5]) == 7\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 31\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 11\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n    assert candidate(cards = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 5, 15, 25, 35, 45, 55, 65, 75, 85]) == 12\n    assert candidate(cards = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10]) == 21\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1]) == 31\n    assert candidate(cards = [1000000, 999999, 999998, 999997, 999996, 999995, 1000000]) == 7\n    assert candidate(cards = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5]) == 6\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 11\n    assert candidate(cards = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 6\n    assert candidate(cards = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 2\n    assert candidate(cards = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n    assert candidate(cards = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n    assert candidate(cards = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0]) == 32\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1]) == 31\n    assert candidate(cards = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n    assert candidate(cards = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981, 999980, 999999]) == 21\n    assert candidate(cards = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10]) == 11\n    assert candidate(cards = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 500, 300]) == 8\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 2\n    assert candidate(cards = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 1000]) == 11\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1]) == 51\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1]) == 31\n    assert candidate(cards = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n    assert candidate(cards = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 6\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 21\n    assert candidate(cards = [9, 3, 1, 3, 2, 5, 9, 8, 3, 9]) == 3\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 31\n    assert candidate(cards = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 1000000]) == 11\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1, 1]) == 2\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 100]) == 2\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 11\n    assert candidate(cards = [1000000, 999999, 999998, 1000000, 999997, 999996, 999995, 999994, 999993, 1000000]) == 4\n    assert candidate(cards = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 11\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 21\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == 11\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 3\n    assert candidate(cards = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 2\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n    assert candidate(cards = [1000000, 999999, 999998, 999997, 1000000, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981, 999980]) == 5\n    assert candidate(cards = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 1]) == 26\n    assert candidate(cards = [42, 17, 23, 34, 42, 17, 23, 34, 42, 17, 23, 34, 42]) == 5\n    assert candidate(cards = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 26\n    assert candidate(cards = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 11\n    assert candidate(cards = [1, 0, 5, 3, 2, 4, 6, 7, 8, 9, 1, 0, 5, 3, 2, 4, 6, 7, 8, 9]) == 11\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 21\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 1]) == 2\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 21\n    assert candidate(cards = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n    assert candidate(cards = [1000000, 999999, 999998, 999997, 999996, 1000000]) == 6\n    assert candidate(cards = [1000000, 999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111, 1000000]) == 11\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 11\n    assert candidate(cards = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 17\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1]) == 26\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n    assert candidate(cards = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 11\n    assert candidate(cards = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000, 100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 11\n    assert candidate(cards = [1, 0, 5, 3, 2, 2, 5, 1, 0, 3, 2, 1]) == 2\n    assert candidate(cards = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 2\n    assert candidate(cards = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11\n    assert candidate(cards = [100000, 200000, 300000, 100000, 400000, 500000, 600000, 700000, 800000, 900000, 100000]) == 4\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 31\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 1]) == 101\n    assert candidate(cards = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 1]) == 2\n    assert candidate(cards = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 3\n    assert candidate(cards = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 1]) == 21\n    assert candidate(cards = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 11\n    assert candidate(cards = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 2\n    assert candidate(cards = [1, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n    assert candidate(cards = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 1000000]) == 11\n    assert candidate(cards = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 21\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 21\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == 11\n    assert candidate(cards = [1000000, 1000000, 1000000, 1000000, 1000000]) == 2\n    assert candidate(cards = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10]) == 11\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == 11\n    assert candidate(cards = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 3\n    assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 12\n    assert candidate(cards = [100000, 200000, 300000, 400000, 500000, 100000, 200000, 300000, 400000, 500000]) == 6\n", "comparison": "exact"}, "public_tests": ["[3,4,2,3,4,7]", "[1,0,5,3]"], "hints": ["Iterate through the cards and store the location of the last occurrence of each number.", "What data structure could you use to get the last occurrence of a number in O(1) or O(log n)?"], "metadata": {"canonical_parameter_names": ["cards"], "leetcode_dataset_entry_point": "Solution().minimumCardPickup", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:39+00:00", "tests_total": 109, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def minimumCardPickup(self, cards: list[int]) -> int:", "container": "Solution", "callable": "minimumCardPickup", "parameters": [{"name": "cards", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2261, "task_id": "k-divisible-elements-subarrays", "difficulty": "Medium", "problem_description": "Given an integer array nums and two integers k and p, return the number of distinct subarrays, which have at most k elements that are divisible by p.\n\nTwo arrays nums1 and nums2 are said to be distinct if:\n\n- They are of different lengths, or\n- There exists at least one index i where nums1[i] != nums2[i].\n\nA subarray is defined as a non-empty contiguous sequence of elements in an array.\n\nExample 1:\n\nInput: nums = [2,3,3,2,2], k = 2, p = 2\nOutput: 11\nExplanation:\nThe elements at indices 0, 3, and 4 are divisible by p = 2.\nThe 11 distinct subarrays which have at most k = 2 elements divisible by 2 are:\n[2], [2,3], [2,3,3], [2,3,3,2], [3], [3,3], [3,3,2], [3,3,2,2], [3,2], [3,2,2], and [2,2].\nNote that the subarrays [2] and [3] occur more than once in nums, but they should each be counted only once.\nThe subarray [2,3,3,2,2] should not be counted because it has 3 elements that are divisible by 2.\n\nExample 2:\n\nInput: nums = [1,2,3,4], k = 4, p = 1\nOutput: 10\nExplanation:\nAll element of nums are divisible by p = 1.\nAlso, every subarray of nums will have at most 4 elements that are divisible by 1.\nSince all subarrays are distinct, the total number of subarrays satisfying all the constraints is 10.\n\nConstraints:\n\n- 1 <= nums.length <= 200\n- 1 <= nums[i], p <= 200\n- 1 <= k <= nums.length\n\nFollow up:\n\nCan you solve this problem in O(n^2) time complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 2, 1, 2, 1],k = 1,p = 2) == 5\n    assert candidate(nums = [19, 23, 29, 31, 37],k = 3,p = 5) == 15\n    assert candidate(nums = [1, 2, 1, 2],k = 1,p = 2) == 5\n    assert candidate(nums = [13, 26, 39, 52, 65],k = 2,p = 13) == 9\n    assert candidate(nums = [5, 5, 5, 5],k = 2,p = 5) == 2\n    assert candidate(nums = [5, 10, 15, 20],k = 2,p = 5) == 7\n    assert candidate(nums = [5, 10, 15, 20, 25],k = 3,p = 5) == 12\n    assert candidate(nums = [7, 11, 13, 17],k = 1,p = 2) == 10\n    assert candidate(nums = [6, 3, 2, 8, 7, 1],k = 3,p = 3) == 21\n    assert candidate(nums = [5, 5, 5, 5],k = 1,p = 5) == 1\n    assert candidate(nums = [3, 9, 12, 15, 18],k = 2,p = 3) == 9\n    assert candidate(nums = [11, 22, 33, 44, 55],k = 3,p = 11) == 12\n    assert candidate(nums = [19, 19, 19, 19, 19],k = 3,p = 19) == 3\n    assert candidate(nums = [7, 14, 21, 28, 35],k = 2,p = 7) == 9\n    assert candidate(nums = [2, 4, 6, 8, 10],k = 1,p = 2) == 5\n    assert candidate(nums = [3, 6, 9, 12, 15],k = 1,p = 3) == 5\n    assert candidate(nums = [5, 10, 15, 20, 25, 30],k = 3,p = 5) == 15\n    assert candidate(nums = [7, 14, 21, 28, 35],k = 1,p = 7) == 5\n    assert candidate(nums = [3, 6, 9, 12, 15],k = 2,p = 3) == 9\n    assert candidate(nums = [200, 100, 50, 25, 12],k = 1,p = 25) == 6\n    assert candidate(nums = [1, 1, 1, 1, 1],k = 2,p = 1) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 2,p = 10) == 9\n    assert candidate(nums = [1, 1, 1, 1],k = 1,p = 1) == 1\n    assert candidate(nums = [10, 5, 15, 20, 25],k = 3,p = 5) == 12\n    assert candidate(nums = [6, 3, 9, 12, 15],k = 2,p = 3) == 9\n    assert candidate(nums = [2, 3, 3, 2, 2],k = 2,p = 2) == 11\n    assert candidate(nums = [11, 13, 17, 19, 23],k = 5,p = 2) == 15\n    assert candidate(nums = [6, 12, 18, 24, 30],k = 3,p = 3) == 12\n    assert candidate(nums = [11, 22, 33, 44, 55],k = 5,p = 10) == 15\n    assert candidate(nums = [8, 16, 24, 32, 40],k = 2,p = 8) == 9\n    assert candidate(nums = [1, 2, 3, 4],k = 4,p = 1) == 10\n    assert candidate(nums = [1, 6, 3, 2, 7, 4],k = 3,p = 3) == 21\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 15,p = 3) == 195\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 8,p = 1) == 132\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 5,p = 5) == 50\n    assert candidate(nums = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200],k = 1,p = 20) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10,p = 1) == 55\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 2,p = 11) == 19\n    assert candidate(nums = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 15,p = 7) == 231\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 25,p = 2) == 325\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,p = 1) == 5\n    assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40],k = 4,p = 4) == 34\n    assert candidate(nums = [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181],k = 15,p = 200) == 210\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7,p = 3) == 120\n    assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3],k = 2,p = 2) == 9\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 5,p = 2) == 65\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 200],k = 5,p = 5) == 210\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165],k = 6,p = 11) == 75\n    assert candidate(nums = [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181],k = 15,p = 19) == 210\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10,p = 10) == 55\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,p = 3) == 210\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 2,p = 2) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5,p = 10) == 40\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],k = 7,p = 7) == 77\n    assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200],k = 4,p = 100) == 8\n    assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],k = 3,p = 15) == 27\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],k = 7,p = 5) == 91\n    assert candidate(nums = [12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126],k = 12,p = 6) == 174\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5,p = 2) == 147\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 3,p = 4) == 47\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 2,p = 13) == 19\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5,p = 4) == 55\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 3,p = 2) == 41\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5,p = 3) == 201\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 15,p = 2) == 210\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],k = 10,p = 7) == 155\n    assert candidate(nums = [15, 18, 21, 24, 27, 30, 33, 36, 39, 42],k = 5,p = 3) == 40\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],k = 15,p = 2) == 345\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10,p = 5) == 10\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 4,p = 7) == 34\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3,p = 1) == 3\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 3,p = 11) == 27\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2,p = 2) == 55\n    assert candidate(nums = [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181],k = 10,p = 2) == 210\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5,p = 2) == 160\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5,p = 5) == 5\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 10,p = 5) == 155\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 10,p = 3) == 10\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,p = 2) == 20\n    assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3],k = 5,p = 2) == 19\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33],k = 5,p = 3) == 45\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 4,p = 7) == 34\n    assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40],k = 5,p = 4) == 40\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 50,p = 1) == 50\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 10,p = 3) == 155\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5,p = 1) == 90\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42],k = 5,p = 3) == 60\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,p = 2) == 10\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 4,p = 3) == 34\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 7,p = 3) == 119\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2,p = 10) == 19\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,p = 1) == 10\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 6,p = 2) == 75\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91],k = 7,p = 7) == 70\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4,p = 10) == 34\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 10,p = 2) == 210\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125],k = 15,p = 5) == 270\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 10,p = 5) == 155\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 6,p = 2) == 75\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,p = 1) == 5\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 20,p = 2) == 210\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3,p = 1) == 3\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 10,p = 2) == 105\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 3,p = 7) == 27\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91],k = 6,p = 7) == 63\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 20,p = 2) == 20\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5,p = 2) == 40\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 7,p = 5) == 84\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],k = 3,p = 10) == 30\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113],k = 15,p = 2) == 465\n    assert candidate(nums = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10],k = 3,p = 5) == 6\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5,p = 10) == 40\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5,p = 2) == 40\n    assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200],k = 4,p = 25) == 26\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 20,p = 3) == 210\n    assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111],k = 6,p = 101) == 66\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 5,p = 3) == 65\n", "comparison": "exact"}, "public_tests": ["[2,3,3,2,2]\n2\n2", "[1,2,3,4]\n4\n1"], "hints": ["Enumerate all subarrays and find the ones that satisfy all the conditions.", "Use any suitable method to hash the subarrays to avoid duplicates."], "metadata": {"canonical_parameter_names": ["nums", "k", "p"], "leetcode_dataset_entry_point": "Solution().countDistinct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:41+00:00", "tests_total": 135, "tests_dropped": 18, "flags": [], "topic_tags": ["array", "hash-table", "trie", "rolling-hash", "hash-function", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def countDistinct(self, nums: list[int], k: int, p: int) -> int:", "container": "Solution", "callable": "countDistinct", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}, {"name": "p", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2262, "task_id": "total-appeal-of-a-string", "difficulty": "Hard", "problem_description": "The appeal of a string is the number of distinct characters found in the string.\n\n- For example, the appeal of \"abbca\" is 3 because it has 3 distinct characters: 'a', 'b', and 'c'.\n\nGiven a string s, return the total appeal of all of its substrings.\n\nA substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: s = \"abbca\"\nOutput: 28\nExplanation: The following are the substrings of \"abbca\":\n- Substrings of length 1: \"a\", \"b\", \"b\", \"c\", \"a\" have an appeal of 1, 1, 1, 1, and 1 respectively. The sum is 5.\n- Substrings of length 2: \"ab\", \"bb\", \"bc\", \"ca\" have an appeal of 2, 1, 2, and 2 respectively. The sum is 7.\n- Substrings of length 3: \"abb\", \"bbc\", \"bca\" have an appeal of 2, 2, and 3 respectively. The sum is 7.\n- Substrings of length 4: \"abbc\", \"bbca\" have an appeal of 3 and 3 respectively. The sum is 6.\n- Substrings of length 5: \"abbca\" has an appeal of 3. The sum is 3.\nThe total sum is 5 + 7 + 7 + 6 + 3 = 28.\n\nExample 2:\n\nInput: s = \"code\"\nOutput: 20\nExplanation: The following are the substrings of \"code\":\n- Substrings of length 1: \"c\", \"o\", \"d\", \"e\" have an appeal of 1, 1, 1, and 1 respectively. The sum is 4.\n- Substrings of length 2: \"co\", \"od\", \"de\" have an appeal of 2, 2, and 2 respectively. The sum is 6.\n- Substrings of length 3: \"cod\", \"ode\" have an appeal of 3 and 3 respectively. The sum is 6.\n- Substrings of length 4: \"code\" has an appeal of 4. The sum is 4.\nThe total sum is 4 + 6 + 6 + 4 = 20.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 3276\n    assert candidate(s = \"zzzaaa\") == 30\n    assert candidate(s = \"a\") == 1\n    assert candidate(s = \"abacabadabacaba\") == 357\n    assert candidate(s = \"abcabcabc\") == 109\n    assert candidate(s = \"abbca\") == 28\n    assert candidate(s = \"ababababab\") == 100\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 210\n    assert candidate(s = \"aaa\") == 6\n    assert candidate(s = \"python\") == 56\n    assert candidate(s = \"abcabc\") == 46\n    assert candidate(s = \"world\") == 35\n    assert candidate(s = \"zzzzzzzzzz\") == 55\n    assert candidate(s = \"abcdabcdabcd\") == 244\n    assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 1306\n    assert candidate(s = \"abc\") == 10\n    assert candidate(s = \"abcd\") == 20\n    assert candidate(s = \"aaaa\") == 10\n    assert candidate(s = \"hello\") == 29\n    assert candidate(s = \"mississippi\") == 148\n    assert candidate(s = \"zzzzz\") == 15\n    assert candidate(s = \"z\") == 1\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 13078\n    assert candidate(s = \"longstringwithvariouscharacters\") == 3921\n    assert candidate(s = \"code\") == 20\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 3276\n    assert candidate(s = \"xyzzxyzzxyzz\") == 191\n    assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeefffffffffgggggggggghhhhhhhhhh\") == 11380\n    assert candidate(s = \"abcdefg\") == 84\n    assert candidate(s = \"aabbccaaabbbccc\") == 274\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 18730\n    assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 6520\n    assert candidate(s = \"bbaaccddeeffgg\") == 329\n    assert candidate(s = \"aabbaabbaabbccddeeefffggghhhiiijjjkkklllmnnnooopppqqqrrrsssttuuuuuuuuvvwxyz\") == 26940\n    assert candidate(s = \"abracadabra\") == 210\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 1306\n    assert candidate(s = \"uniquecharacters\") == 677\n    assert candidate(s = \"aabbc\") == 25\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzz\") == 23011\n    assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabb\") == 1008\n    assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\") == 865\n    assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 1838\n    assert candidate(s = \"ababababababababababababababa\") == 841\n    assert candidate(s = \"ninetyninebottlesofbeer\") == 1564\n    assert candidate(s = \"abcdabcdbcadbacdbac\") == 646\n    assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 1820\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == 46306\n    assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 5345\n    assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 3276\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabc\") == 1054\n    assert candidate(s = \"abababababababab\") == 256\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 21528\n    assert candidate(s = \"xyxzyzyzyxzyxzyzyxzyxzyzyxzyxzyzyxzyxzyzyxzyxzyzyxzyxzyzyxz\") == 5105\n    assert candidate(s = \"hellohellohello\") == 377\n    assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 46120\n    assert candidate(s = \"banana\") == 40\n    assert candidate(s = \"hellohellobyebye\") == 513\n    assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == 8230\n    assert candidate(s = \"abacabadaba\") == 177\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1378\n    assert candidate(s = \"thisisareallylongteststringwithmanydistinctcharactersandrepeatedones\") == 25027\n    assert candidate(s = \"thisisaverylongstringwithmanycopiesofthissubstringthissubstringthissubstring\") == 35609\n    assert candidate(s = \"xyxzyxyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyz\") == 2363\n    assert candidate(s = \"aaaaabbbbbccccc\") == 220\n    assert candidate(s = \"xyzzzyxzyzyzyxzyzyxzyzyzyzyxzyzyzyzyzyzyzyzyzyzyzyzyzyz\") == 4088\n    assert candidate(s = \"amazingappeal\") == 374\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1275\n    assert candidate(s = \"aabbccaaaabbbccc\") == 309\n    assert candidate(s = \"abacabadabacabaabacabadabacaba\") == 1555\n", "comparison": "exact"}, "public_tests": ["\"abbca\"", "\"code\""], "hints": ["Consider the set of substrings that end at a certain index i. Then, consider a specific alphabetic character. How do you count the number of substrings ending at index i that contain that character?", "The number of substrings that contain the alphabetic character is equivalent to 1 plus the index of the last occurrence of the character before index i + 1.", "The total appeal of all substrings ending at index i is the total sum of the number of substrings that contain each alphabetic character.", "To find the total appeal of all substrings, we simply sum up the total appeal for each index."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().appealSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:44+00:00", "tests_total": 69, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def appealSum(self, s: str) -> int:", "container": "Solution", "callable": "appealSum", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2264, "task_id": "largest-3-same-digit-number-in-string", "difficulty": "Easy", "problem_description": "You are given a string num representing a large integer. An integer is good if it meets the following conditions:\n\n- It is a substring of num with length 3.\n- It consists of only one unique digit.\n\nReturn the maximum good integer as a string or an empty string \"\" if no such integer exists.\n\nNote:\n\n- A substring is a contiguous sequence of characters within a string.\n- There may be leading zeroes in num or a good integer.\n\nExample 1:\n\nInput: num = \"6777133339\"\nOutput: \"777\"\nExplanation: There are two distinct good integers: \"777\" and \"333\".\n\"777\" is the largest, so we return \"777\".\n\nExample 2:\n\nInput: num = \"2300019\"\nOutput: \"000\"\nExplanation: \"000\" is the only good integer.\n\nExample 3:\n\nInput: num = \"42352338\"\nOutput: \"\"\nExplanation: No substring of length 3 consists of only one unique digit. Therefore, there are no good integers.\n\nConstraints:\n\n- 3 <= num.length <= 1000\n- num only consists of digits.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num = \"999888777666555444333222111000\") == \"999\"\n    assert candidate(num = \"000\") == \"000\"\n    assert candidate(num = \"42352338\") == \"\"\n    assert candidate(num = \"9876543210\") == \"\"\n    assert candidate(num = \"555444555\") == \"555\"\n    assert candidate(num = \"112233445566778899\") == \"\"\n    assert candidate(num = \"888777666555444333222111000\") == \"888\"\n    assert candidate(num = \"2300019\") == \"000\"\n    assert candidate(num = \"10000001\") == \"000\"\n    assert candidate(num = \"123\") == \"\"\n    assert candidate(num = \"6777133339\") == \"777\"\n    assert candidate(num = \"1222333444555666777888999000\") == \"999\"\n    assert candidate(num = \"888777666555444333222111\") == \"888\"\n    assert candidate(num = \"333333333\") == \"333\"\n    assert candidate(num = \"999999999\") == \"999\"\n    assert candidate(num = \"999999\") == \"999\"\n    assert candidate(num = \"11223344556677889900\") == \"\"\n    assert candidate(num = \"9999999\") == \"999\"\n    assert candidate(num = \"1234567890\") == \"\"\n    assert candidate(num = \"000111222333444555666777888999\") == \"999\"\n    assert candidate(num = \"111222333\") == \"333\"\n    assert candidate(num = \"888888888888888888888\") == \"888\"\n    assert candidate(num = \"100100100\") == \"\"\n    assert candidate(num = \"000000000\") == \"000\"\n    assert candidate(num = \"111111111\") == \"111\"\n    assert candidate(num = \"111\") == \"111\"\n    assert candidate(num = \"123123123123123123123123123123123123\") == \"\"\n    assert candidate(num = \"1234444321111234444321\") == \"444\"\n    assert candidate(num = \"12345678987654321000000123456789\") == \"000\"\n    assert candidate(num = \"555444333222111000000000000111222333444\") == \"555\"\n    assert candidate(num = \"123456789123456789123456789123456789123456789\") == \"\"\n    assert candidate(num = \"1233344445555566666777777\") == \"777\"\n    assert candidate(num = \"555444333222111000000111222333444555\") == \"555\"\n    assert candidate(num = \"1222222222222222222222222222221\") == \"222\"\n    assert candidate(num = \"555444333222111000999888777666555\") == \"999\"\n    assert candidate(num = \"10000001000000100000010000001000000\") == \"000\"\n    assert candidate(num = \"987654321111111111111111111111987654321000000000\") == \"111\"\n    assert candidate(num = \"88888888888888888888888888888888888888888888\") == \"888\"\n    assert candidate(num = \"1234567890123456789012345678901234567890\") == \"\"\n    assert candidate(num = \"12345678987654321012345678987654321\") == \"\"\n    assert candidate(num = \"999000111222333444555666777888999\") == \"999\"\n    assert candidate(num = \"000123456789\") == \"000\"\n    assert candidate(num = \"111111222222333333444444555555666666777777888888999999\") == \"999\"\n    assert candidate(num = \"1111111111111111111111111111111111111111111111111\") == \"111\"\n    assert candidate(num = \"123123123123123123123123\") == \"\"\n    assert candidate(num = \"123123123123123123123123123123\") == \"\"\n    assert candidate(num = \"1000000000000000000000000000000000000000000000000\") == \"000\"\n    assert candidate(num = \"01234567890123456789012345678901234567890\") == \"\"\n    assert candidate(num = \"999999999999999999999999999999\") == \"999\"\n    assert candidate(num = \"987654321111111111111111111111987654321\") == \"111\"\n    assert candidate(num = \"111222333444555666777888999000111222333444555666777888999\") == \"999\"\n    assert candidate(num = \"1221221221221221221221221\") == \"\"\n    assert candidate(num = \"000000000000000000000000000\") == \"000\"\n    assert candidate(num = \"123123123123123123123123123\") == \"\"\n    assert candidate(num = \"55555555555555555555555555555555555555555555555555555555\") == \"555\"\n    assert candidate(num = \"123333456789000123456789\") == \"333\"\n    assert candidate(num = \"00000000000000000000000000000000000000000000\") == \"000\"\n    assert candidate(num = \"99999999999999999999999999999999999999999999\") == \"999\"\n    assert candidate(num = \"333333333333333333333333333333\") == \"333\"\n    assert candidate(num = \"9990000000000000000000000000000000000000000000000000000000\") == \"999\"\n    assert candidate(num = \"1122334455667788990011223344556677889900\") == \"\"\n    assert candidate(num = \"33333333333333333333333333333333333333333333\") == \"333\"\n    assert candidate(num = \"987654321000000000987654321\") == \"000\"\n    assert candidate(num = \"122333444555666777888999\") == \"999\"\n    assert candidate(num = \"888999777666555444333222111000\") == \"999\"\n    assert candidate(num = \"111222333444555666777888999000\") == \"999\"\n    assert candidate(num = \"123332111112222233333\") == \"333\"\n    assert candidate(num = \"98765432109876543210987654321\") == \"\"\n    assert candidate(num = \"000000000000000000000000000000\") == \"000\"\n    assert candidate(num = \"11111111111111111111111111111111111111111111\") == \"111\"\n    assert candidate(num = \"98765432111111111111111111111111111111111111\") == \"111\"\n    assert candidate(num = \"999111222333444555666777888\") == \"999\"\n    assert candidate(num = \"123332111222222111111\") == \"333\"\n    assert candidate(num = \"111222333444555666777888999111222333444555\") == \"999\"\n    assert candidate(num = \"10101010101010101010101010101010101010101010\") == \"\"\n    assert candidate(num = \"12345678987654321111100000000222222333333\") == \"333\"\n    assert candidate(num = \"1000000000000000000000000000000\") == \"000\"\n    assert candidate(num = \"111222333444555666777888999000111222\") == \"999\"\n    assert candidate(num = \"98765432111123456789000000\") == \"111\"\n    assert candidate(num = \"999000999000999\") == \"999\"\n    assert candidate(num = \"0000000000000000000000000000000000000000000000000\") == \"000\"\n    assert candidate(num = \"000000111111222222333333444444555555666666777777888888999999\") == \"999\"\n    assert candidate(num = \"111222333444555666777888999111\") == \"999\"\n    assert candidate(num = \"987654321098765432109876543210\") == \"\"\n    assert candidate(num = \"888999888999888999888999888999\") == \"999\"\n    assert candidate(num = \"111000111000111000111000\") == \"111\"\n    assert candidate(num = \"1234555554321\") == \"555\"\n    assert candidate(num = \"123456789123456789123456789\") == \"\"\n    assert candidate(num = \"111000111000111000111000111000\") == \"111\"\n    assert candidate(num = \"111000222333444555666777888999\") == \"999\"\n    assert candidate(num = \"333222111333222111333222111\") == \"333\"\n    assert candidate(num = \"101010101010101010101010101\") == \"\"\n    assert candidate(num = \"1111111111111111111111111111111\") == \"111\"\n    assert candidate(num = \"12345678999987654321\") == \"999\"\n    assert candidate(num = \"111122223333444455556666777788889999\") == \"999\"\n    assert candidate(num = \"123456789000000987654321\") == \"000\"\n    assert candidate(num = \"999888777666555444333222111\") == \"999\"\n    assert candidate(num = \"555555555555555555555555555555555555555555555555\") == \"555\"\n    assert candidate(num = \"111222333444555666777888999\") == \"999\"\n    assert candidate(num = \"999888777666555444333222111000999888777\") == \"999\"\n    assert candidate(num = \"111000111222333\") == \"333\"\n    assert candidate(num = \"123456789876543211222333444555666777888999\") == \"999\"\n    assert candidate(num = \"123456789876543211111111111111\") == \"111\"\n    assert candidate(num = \"9999999999999999999999999999999999999999999999999\") == \"999\"\n    assert candidate(num = \"123456789000000000000000000\") == \"000\"\n    assert candidate(num = \"987654321000000123456789\") == \"000\"\n    assert candidate(num = \"111999888777666555444333222111\") == \"999\"\n    assert candidate(num = \"5555555555555555555555555555555\") == \"555\"\n    assert candidate(num = \"333222111000999888777666555444333222111000\") == \"999\"\n    assert candidate(num = \"1233321111222223333\") == \"333\"\n    assert candidate(num = \"0011223344556677889900112233445566\") == \"\"\n    assert candidate(num = \"123456789012345678901234567890\") == \"\"\n    assert candidate(num = \"000111222333444555666777888999000111222333\") == \"999\"\n    assert candidate(num = \"1111122223333444455556666777788889999\") == \"999\"\n    assert candidate(num = \"5555555555555555555555555\") == \"555\"\n    assert candidate(num = \"111222333444555666777888999000111\") == \"999\"\n    assert candidate(num = \"999000999000999000999000999000999000\") == \"999\"\n    assert candidate(num = \"1234567890000000000000000000000000000000\") == \"000\"\n    assert candidate(num = \"123456789123456789123456789123456789\") == \"\"\n    assert candidate(num = \"11111111111111111111111111111100000000000000000\") == \"111\"\n    assert candidate(num = \"555555444444333333222222111111\") == \"555\"\n    assert candidate(num = \"333222111000777888999\") == \"999\"\n    assert candidate(num = \"555555555555555555555555555555\") == \"555\"\n    assert candidate(num = \"1222233333444444555555566666667\") == \"666\"\n    assert candidate(num = \"123123123123123123123123123123123123123123123123123123123123\") == \"\"\n    assert candidate(num = \"123456789999987654321\") == \"999\"\n    assert candidate(num = \"990990990990990990\") == \"\"\n    assert candidate(num = \"123455567890123456789012345678\") == \"555\"\n    assert candidate(num = \"111111111111111111111111111111\") == \"111\"\n    assert candidate(num = \"12345556789000987654321000000\") == \"555\"\n    assert candidate(num = \"22222222222222222222222222222222222222222222\") == \"222\"\n    assert candidate(num = \"10000000000000000000000000000001\") == \"000\"\n    assert candidate(num = \"000111000111000111000111000111\") == \"111\"\n", "comparison": "exact"}, "public_tests": ["\"6777133339\"", "\"2300019\"", "\"42352338\""], "hints": ["We can sequentially check if “999”, “888”, “777”, … , “000” exists in num in that order. The first to be found is the maximum good integer.", "If we cannot find any of the above integers, we return an empty string “”."], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().largestGoodInteger", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:48+00:00", "tests_total": 133, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def largestGoodInteger(self, num: str) -> str:", "container": "Solution", "callable": "largestGoodInteger", "parameters": [{"name": "num", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2266, "task_id": "count-number-of-texts", "difficulty": "Medium", "problem_description": "Alice is texting Bob using her phone. The mapping of digits to letters is shown in the figure below.\n\nIn order to add a letter, Alice has to press the key of the corresponding digit i times, where i is the position of the letter in the key.\n\n- For example, to add the letter 's', Alice has to press '7' four times. Similarly, to add the letter 'k', Alice has to press '5' twice.\n- Note that the digits '0' and '1' do not map to any letters, so Alice does not use them.\n\nHowever, due to an error in transmission, Bob did not receive Alice's text message but received a string of pressed keys instead.\n\n- For example, when Alice sent the message \"bob\", Bob received the string \"2266622\".\n\nGiven a string pressedKeys representing the string received by Bob, return the total number of possible text messages Alice could have sent.\n\nSince the answer may be very large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: pressedKeys = \"22233\"\nOutput: 8\nExplanation:\nThe possible text messages Alice could have sent are:\n\"aaadd\", \"abdd\", \"badd\", \"cdd\", \"aaae\", \"abe\", \"bae\", and \"ce\".\nSince there are 8 possible messages, we return 8.\n\nExample 2:\n\nInput: pressedKeys = \"222222222222222222222222222222222222\"\nOutput: 82876089\nExplanation:\nThere are 2082876103 possible text messages Alice could have sent.\nSince we need to return the answer modulo 10^9 + 7, we return 2082876103 % (10^9 + 7) = 82876089.\n\nConstraints:\n\n- 1 <= pressedKeys.length <= 10^5\n- pressedKeys only consists of digits from '2' - '9'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(pressedKeys = \"99999999\") == 108\n    assert candidate(pressedKeys = \"3333\") == 7\n    assert candidate(pressedKeys = \"33\") == 2\n    assert candidate(pressedKeys = \"4444\") == 7\n    assert candidate(pressedKeys = \"555555\") == 24\n    assert candidate(pressedKeys = \"9999999\") == 56\n    assert candidate(pressedKeys = \"888888888\") == 149\n    assert candidate(pressedKeys = \"888888\") == 24\n    assert candidate(pressedKeys = \"7777777\") == 56\n    assert candidate(pressedKeys = \"66\") == 2\n    assert candidate(pressedKeys = \"55555\") == 13\n    assert candidate(pressedKeys = \"888\") == 4\n    assert candidate(pressedKeys = \"33344455566677778889999\") == 65536\n    assert candidate(pressedKeys = \"2222\") == 7\n    assert candidate(pressedKeys = \"7777\") == 8\n    assert candidate(pressedKeys = \"77777777\") == 108\n    assert candidate(pressedKeys = \"8888\") == 7\n    assert candidate(pressedKeys = \"6666666\") == 44\n    assert candidate(pressedKeys = \"23456789\") == 1\n    assert candidate(pressedKeys = \"666\") == 4\n    assert candidate(pressedKeys = \"22233\") == 8\n    assert candidate(pressedKeys = \"555\") == 4\n    assert candidate(pressedKeys = \"9999999999\") == 401\n    assert candidate(pressedKeys = \"44444\") == 13\n    assert candidate(pressedKeys = \"333333\") == 24\n    assert candidate(pressedKeys = \"99999\") == 15\n    assert candidate(pressedKeys = \"88888\") == 13\n    assert candidate(pressedKeys = \"222222222222222222222222222222222222\") == 82876089\n    assert candidate(pressedKeys = \"777777777777777777777777777777777777\") == 312882411\n    assert candidate(pressedKeys = \"2222222222222222222222222222222222227777777777777777777777777777777\") == 168766023\n    assert candidate(pressedKeys = \"2223333333333333333333333333333333334444444444444444444444444444444\") == 151530826\n    assert candidate(pressedKeys = \"234567898765432345678987654323456789876543234567898765432\") == 1\n    assert candidate(pressedKeys = \"7773333322225555555555444446666688888\") == 219119992\n    assert candidate(pressedKeys = \"222222222222222222222222222222222222444444444444444444444444444\") == 964547839\n    assert candidate(pressedKeys = \"9999999999999999999999999999999999999999999999999999999999999999999\") == 831813694\n    assert candidate(pressedKeys = \"55555555555555555555555555555555555577777777777777777777777777777778888888888888888888888888888888\") == 60492310\n    assert candidate(pressedKeys = \"333322225555444466668888\") == 117649\n", "comparison": "exact"}, "public_tests": ["\"22233\"", "\"222222222222222222222222222222222222\""], "hints": ["For a substring consisting of the same digit, how can we count the number of texts it could have originally represented?", "How can dynamic programming help us calculate the required answer?"], "metadata": {"canonical_parameter_names": ["pressedKeys"], "leetcode_dataset_entry_point": "Solution().countTexts", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:52+00:00", "tests_total": 38, "tests_dropped": 1, "flags": ["figure_reference", "has_images"], "topic_tags": ["hash-table", "math", "string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def countTexts(self, pressedKeys: str) -> int:", "container": "Solution", "callable": "countTexts", "parameters": [{"name": "pressedKeys", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2267, "task_id": "check-if-there-is-a-valid-parentheses-string-path", "difficulty": "Hard", "problem_description": "A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true:\n\n- It is ().\n- It can be written as AB (A concatenated with B), where A and B are valid parentheses strings.\n- It can be written as (A), where A is a valid parentheses string.\n\nYou are given an m x n matrix of parentheses grid. A valid parentheses string path in the grid is a path satisfying all of the following conditions:\n\n- The path starts from the upper left cell (0, 0).\n- The path ends at the bottom-right cell (m - 1, n - 1).\n- The path only ever moves down or right.\n- The resulting parentheses string formed by the path is valid.\n\nReturn true if there exists a valid parentheses string path in the grid. Otherwise, return false.\n\nExample 1:\n\nInput: grid = [[\"(\",\"(\",\"(\"],[\")\",\"(\",\")\"],[\"(\",\"(\",\")\"],[\"(\",\"(\",\")\"]]\nOutput: true\nExplanation: The above diagram shows two possible paths that form valid parentheses strings.\nThe first path shown results in the valid parentheses string \"()(())\".\nThe second path shown results in the valid parentheses string \"((()))\".\nNote that there may be other valid parentheses string paths.\n\nExample 2:\n\nInput: grid = [[\")\",\")\"],[\"(\",\"(\"]]\nOutput: false\nExplanation: The two possible paths form the parentheses strings \"))(\" and \")((\". Since neither of them are valid parentheses strings, we return false.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 100\n- grid[i][j] is either '(' or ')'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [['(', '(', '('], [')', '(', ')'], ['(', '(', ')'], ['(', '(', ')']]) == True\n    assert candidate(grid = [[')', ')'], ['(', '(']]) == False\n    assert candidate(grid = [[')', '('], ['(', '(']]) == False\n    assert candidate(grid = [['(', ')', '(', ')'], [')', '(', ')', '(']]) == False\n    assert candidate(grid = [['(', ')', '(', ')'], ['(', '(', ')', '(']]) == False\n    assert candidate(grid = [['(', '(', '(', ')', '('], [')', '(', ')', '(', ')'], ['(', ')', '(', ')', '('], [')', '(', ')', '(', ')'], [')', '(', ')', '(', ')']]) == False\n    assert candidate(grid = [['(', '(', '(', ')', '('], [')', '(', ')', '(', ')'], [')', '(', '(', ')', '('], [')', '(', ')', '(', ')'], [')', '(', '(', ')', '(']]) == False\n    assert candidate(grid = [['(', '(', '(', ')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(', ')']]) == True\n    assert candidate(grid = [['(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(']]) == False\n    assert candidate(grid = [['(', '(', '(', '(', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')']]) == False\n    assert candidate(grid = [['(', '(', ')', '(', '(', '(', ')', '(', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(']]) == False\n    assert candidate(grid = [['(', '(', ')', '(', '(', '(', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == True\n    assert candidate(grid = [[')', '(', '(', '(', '('], ['(', ')', '(', ')', '('], [')', '(', ')', '(', ')'], ['(', ')', '(', ')', '('], [')', '(', ')', '(', ')']]) == False\n    assert candidate(grid = [['(', '(', '(', ')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')']]) == False\n    assert candidate(grid = [['(', '(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')', '(']]) == False\n    assert candidate(grid = [['(', '(', '(', '('], [')', '(', '(', ')'], [')', ')', '(', ')'], [')', '(', ')', ')']]) == False\n    assert candidate(grid = [['(', '(', '(', '(', '(', '('], [')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(']]) == False\n    assert candidate(grid = [['(', '(', '(', '(', ')'], ['(', ')', '(', ')', '(']]) == False\n    assert candidate(grid = [['(', '(', ')', '(', ')'], [')', '(', '(', ')', '('], [')', '(', ')', '(', ')'], [')', '(', '(', ')', '('], [')', '(', ')', '(', ')']]) == False\n    assert candidate(grid = [['(', '(', ')', '(', '(', '(', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == False\n    assert candidate(grid = [['(', '(', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '('], [')', '(', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '('], [')', '(', '(', ')', '(', ')']]) == True\n    assert candidate(grid = [['(', '(', ')', '('], [')', '(', '(', ')'], ['(', ')', ')', '(']]) == False\n    assert candidate(grid = [['(', '(', ')', '(', '(', '(', ')'], [')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')']]) == True\n    assert candidate(grid = [['(', '(', '(', '(', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')']]) == True\n    assert candidate(grid = [['(', '(', ')', '(', '(', '(', ')'], [')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')']]) == False\n    assert candidate(grid = [['(', '(', '(', ')'], ['(', '(', ')', ')'], [')', ')', ')', '(']]) == False\n    assert candidate(grid = [['(', '(', '(', '(', '('], [')', '(', ')', '(', ')'], ['(', '(', ')', '(', ')'], [')', '(', ')', '(', ')'], [')', '(', ')', '(', ')']]) == False\n    assert candidate(grid = [['(', '(', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')', '(']]) == False\n    assert candidate(grid = [['(', '(', '(', '('], [')', '(', ')', '('], ['(', ')', '(', ')'], [')', '(', ')', '(']]) == False\n    assert candidate(grid = [['(', ')', '(', ')', '('], [')', '(', ')', '(', ')'], ['(', ')', '(', ')', '(']]) == False\n    assert candidate(grid = [['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], ['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], ['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], ['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == False\n    assert candidate(grid = [['(', '(', ')', '('], [')', '(', ')', '('], ['(', ')', ')', '('], [')', '(', '(', ')']]) == False\n    assert candidate(grid = [['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], ['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], ['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], ['(', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')'], [')', '(', ')', '(', ')', '(', ')', '(', ')', '(', ')']]) == True\n    assert candidate(grid = [['(', '(', '(', ')', '('], ['(', '(', ')', ')', '(']]) == False\n    assert candidate(grid = [['(', '(', ')', '(', ')'], [')', '(', '(', ')', '(']]) == False\n    assert candidate(grid = [['(', '(', '(', '(', '(', ')'], [')', '(', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')']]) == True\n    assert candidate(grid = [['(', '(', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')'], [')', '(', '(', ')', '(', ')', '('], [')', '(', ')', '(', ')', '(', ')']]) == True\n    assert candidate(grid = [['(', '(', ')', '('], [')', '(', ')', '('], ['(', '(', ')', '('], [')', '(', ')', '(']]) == False\n    assert candidate(grid = [['(', '(', '(', ')'], [')', '(', ')', '('], ['(', ')', ')', '(']]) == False\n", "comparison": "exact"}, "public_tests": ["[[\"(\",\"(\",\"(\"],[\")\",\"(\",\")\"],[\"(\",\"(\",\")\"],[\"(\",\"(\",\")\"]]", "[[\")\",\")\"],[\"(\",\"(\"]]"], "hints": ["What observations can you make about the number of open brackets and close brackets for any prefix of a valid bracket sequence?", "The number of open brackets must always be greater than or equal to the number of close brackets.", "Could you use dynamic programming?"], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().hasValidPath", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:55+00:00", "tests_total": 54, "tests_dropped": 15, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "matrix", "bracket-sequences"]}, "language": "python", "interface": {"raw_signature": "def hasValidPath(self, grid: list[list[str]]) -> bool:", "container": "Solution", "callable": "hasValidPath", "parameters": [{"name": "grid", "type": "list[list[str]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2269, "task_id": "find-the-k-beauty-of-a-number", "difficulty": "Easy", "problem_description": "The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions:\n\n- It has a length of k.\n- It is a divisor of num.\n\nGiven integers num and k, return the k-beauty of num.\n\nNote:\n\n- Leading zeros are allowed.\n- 0 is not a divisor of any value.\n\nA substring is a contiguous sequence of characters in a string.\n\nExample 1:\n\nInput: num = 240, k = 2\nOutput: 2\nExplanation: The following are the substrings of num of length k:\n- \"24\" from \"240\": 24 is a divisor of 240.\n- \"40\" from \"240\": 40 is a divisor of 240.\nTherefore, the k-beauty is 2.\n\nExample 2:\n\nInput: num = 430043, k = 2\nOutput: 2\nExplanation: The following are the substrings of num of length k:\n- \"43\" from \"430043\": 43 is a divisor of 430043.\n- \"30\" from \"430043\": 30 is not a divisor of 430043.\n- \"00\" from \"430043\": 0 is not a divisor of 430043.\n- \"04\" from \"430043\": 4 is not a divisor of 430043.\n- \"43\" from \"430043\": 43 is a divisor of 430043.\nTherefore, the k-beauty is 2.\n\nConstraints:\n\n- 1 <= num <= 10^9\n- 1 <= k <= num.length (taking num as a string)\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num = 100000,k = 2) == 1\n    assert candidate(num = 240,k = 2) == 2\n    assert candidate(num = 1111,k = 2) == 3\n    assert candidate(num = 430043,k = 2) == 2\n    assert candidate(num = 99999,k = 5) == 1\n    assert candidate(num = 123456,k = 3) == 0\n    assert candidate(num = 987654,k = 1) == 1\n    assert candidate(num = 1111,k = 1) == 4\n    assert candidate(num = 987654321,k = 4) == 0\n    assert candidate(num = 999999999,k = 9) == 1\n    assert candidate(num = 111222333,k = 5) == 0\n    assert candidate(num = 100100100,k = 4) == 4\n    assert candidate(num = 111111111,k = 1) == 9\n    assert candidate(num = 7777777,k = 7) == 1\n    assert candidate(num = 12301230,k = 4) == 3\n    assert candidate(num = 1000000000,k = 9) == 1\n    assert candidate(num = 333333333,k = 4) == 0\n    assert candidate(num = 999999999,k = 2) == 0\n    assert candidate(num = 567890123,k = 6) == 0\n    assert candidate(num = 555555555,k = 6) == 0\n    assert candidate(num = 100100100,k = 3) == 7\n    assert candidate(num = 86420,k = 2) == 1\n    assert candidate(num = 987654321,k = 9) == 1\n    assert candidate(num = 222222222,k = 2) == 0\n    assert candidate(num = 999999999,k = 1) == 9\n    assert candidate(num = 864208642,k = 3) == 0\n    assert candidate(num = 101010101,k = 3) == 0\n    assert candidate(num = 987654321,k = 3) == 0\n    assert candidate(num = 222222222,k = 3) == 7\n    assert candidate(num = 123123123,k = 2) == 0\n    assert candidate(num = 1000000,k = 4) == 1\n    assert candidate(num = 777000777,k = 4) == 2\n    assert candidate(num = 101010101,k = 5) == 0\n    assert candidate(num = 123123123,k = 4) == 0\n    assert candidate(num = 1000000000,k = 5) == 1\n    assert candidate(num = 222222222,k = 1) == 9\n    assert candidate(num = 101010101,k = 2) == 4\n    assert candidate(num = 567890123,k = 3) == 0\n    assert candidate(num = 222222222,k = 5) == 0\n    assert candidate(num = 999999999,k = 7) == 0\n    assert candidate(num = 999999999,k = 3) == 7\n    assert candidate(num = 864197532,k = 4) == 0\n    assert candidate(num = 1000000000,k = 4) == 1\n    assert candidate(num = 444444444,k = 5) == 0\n    assert candidate(num = 555555555,k = 5) == 0\n    assert candidate(num = 7777777,k = 2) == 0\n", "comparison": "exact"}, "public_tests": ["240\n2", "430043\n2"], "hints": ["We should check all the substrings of num with a length of k and see if it is a divisor of num.", "We can more easily obtain the substrings by converting num into a string and converting back to an integer to check for divisibility."], "metadata": {"canonical_parameter_names": ["num", "k"], "leetcode_dataset_entry_point": "Solution().divisorSubstrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:46:59+00:00", "tests_total": 90, "tests_dropped": 44, "flags": [], "topic_tags": ["math", "string", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def divisorSubstrings(self, num: int, k: int) -> int:", "container": "Solution", "callable": "divisorSubstrings", "parameters": [{"name": "num", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2270, "task_id": "number-of-ways-to-split-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums of length n.\n\nnums contains a valid split at index i if the following are true:\n\n- The sum of the first i + 1 elements is greater than or equal to the sum of the last n - i - 1 elements.\n- There is at least one element to the right of i. That is, 0 <= i < n - 1.\n\nReturn the number of valid splits in nums.\n\nExample 1:\n\nInput: nums = [10,4,-8,7]\nOutput: 2\nExplanation:\nThere are three ways of splitting nums into two non-empty parts:\n- Split nums at index 0. Then, the first part is [10], and its sum is 10. The second part is [4,-8,7], and its sum is 3. Since 10 >= 3, i = 0 is a valid split.\n- Split nums at index 1. Then, the first part is [10,4], and its sum is 14. The second part is [-8,7], and its sum is -1. Since 14 >= -1, i = 1 is a valid split.\n- Split nums at index 2. Then, the first part is [10,4,-8], and its sum is 6. The second part is [7], and its sum is 7. Since 6 < 7, i = 2 is not a valid split.\nThus, the number of valid splits in nums is 2.\n\nExample 2:\n\nInput: nums = [2,3,1,0]\nOutput: 2\nExplanation:\nThere are two valid splits in nums:\n- Split nums at index 1. Then, the first part is [2,3], and its sum is 5. The second part is [1,0], and its sum is 1. Since 5 >= 1, i = 1 is a valid split.\n- Split nums at index 2. Then, the first part is [2,3,1], and its sum is 6. The second part is [0], and its sum is 0. Since 6 >= 0, i = 2 is a valid split.\n\nConstraints:\n\n- 2 <= nums.length <= 10^5\n- -10^5 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [-100000, -100000, -100000, -100000, -100000]) == 2\n    assert candidate(nums = [1, -1, 1, -1, 1]) == 2\n    assert candidate(nums = [100, -50, 50, -25, 25]) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n    assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 5\n    assert candidate(nums = [100000, -100000, 100000, -100000, 100000]) == 2\n    assert candidate(nums = [100000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 19\n    assert candidate(nums = [-1, -2, -3, -4, -5]) == 3\n    assert candidate(nums = [5, 5, 5, 5, 5]) == 2\n    assert candidate(nums = [-1, 1, -1, 1, -1]) == 2\n    assert candidate(nums = [0, 0, 0, 0, 0]) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n    assert candidate(nums = [100000, -50000, 50000, -50000, 50000]) == 4\n    assert candidate(nums = [-100000, 100000, -100000, 100000, -100000]) == 2\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100000]) == 0\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000]) == 2\n    assert candidate(nums = [5, 4, 3, 2, 1]) == 3\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 6\n    assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 7\n    assert candidate(nums = [10, 4, -8, 7]) == 2\n    assert candidate(nums = [2, 3, 1, 0]) == 2\n    assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40, 45, -45, 50, -50]) == 19\n    assert candidate(nums = [-1, -1, -1, -1, -1, 5, -1, -1, -1, -1, -1]) == 5\n    assert candidate(nums = [100000, 0, -50000, 50000, -100000, 0, 50000, -50000, 100000, 0]) == 6\n    assert candidate(nums = [10000, 20000, 30000, -10000, -20000, -30000, 40000]) == 4\n    assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100]) == 19\n    assert candidate(nums = [100000, -50000, 25000, -12500, 6250, -3125, 1562]) == 6\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 6\n    assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000]) == 7\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == 10\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 19\n    assert candidate(nums = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5]) == 4\n    assert candidate(nums = [50, 25, 12, 6, 3, 1, 0, -1, -3, -6, -12, -25, -50, 100, 200]) == 0\n    assert candidate(nums = [-100, 200, -300, 400, -500, 600, -700, 800, -900, 1000, -1100, 1200, -1300, 1400, -1500, 1600, -1700, 1800, -1900, 2000]) == 5\n    assert candidate(nums = [100, 200, 300, 400, 500, -600, -700, -800, -900, -1000]) == 8\n    assert candidate(nums = [10000, 20000, 30000, -60000, 40000, 50000, -100000, 60000, 70000, 80000]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 19\n    assert candidate(nums = [-5, -1, -4, -2, -3, -6, -7, -8, -9, -10]) == 6\n    assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500]) == 9\n    assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50, 60, 70, 80, 90, 100]) == 2\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 20\n    assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 5500]) == 0\n    assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 15\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 9\n    assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 2\n    assert candidate(nums = [5, 2, -3, 1, 4, 6, -2, 8, -5, 3]) == 4\n    assert candidate(nums = [-150, -140, -130, -120, -110, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 4\n    assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 19\n    assert candidate(nums = [100000, 0, -100000, 0, 100000, 0, -100000, 0, 100000]) == 4\n    assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 15\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n    assert candidate(nums = [5, 2, 3, 7, 4, 1, 6, 8]) == 3\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -10]) == 10\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -550]) == 10\n    assert candidate(nums = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10]) == 3\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == 0\n    assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 9\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n    assert candidate(nums = [10, -5, 20, -10, 30, -15, 40, -20, 50, -25, 60, -30]) == 4\n    assert candidate(nums = [100, 200, 300, -600, 100, 200, 300]) == 3\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 19\n    assert candidate(nums = [50000, 40000, 30000, 20000, 10000, -10000, -20000, -30000, -40000, -50000]) == 9\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 3\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]) == 15\n    assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 7\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n    assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 55]) == 0\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 6\n    assert candidate(nums = [100000, 50000, -25000, -25000, 10000, -10000, 1000, -1000, 100, -100, 10, -10, 1, -1]) == 13\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1]) == 21\n    assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 7\n    assert candidate(nums = [100000, -50000, 50000, -50000, 50000, -50000, 50000, -50000, 50000, -50000]) == 9\n    assert candidate(nums = [100000, -50000, -30000, -20000, 10000, 5000, 2500, 1250, 625, 313]) == 8\n    assert candidate(nums = [50000, 50000, -100000, 25000, 25000, 25000, 25000]) == 4\n    assert candidate(nums = [1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0]) == 19\n    assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 2\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == 10\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 6\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 0\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 20\n    assert candidate(nums = [99999, -99999, 99998, -99998, 99997, -99997, 99996, -99996, 99995, -99995]) == 9\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 9\n    assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80]) == 15\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n    assert candidate(nums = [1, 1, 1, 1, 1, -5, 1, 1, 1, 1, 1]) == 5\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 7\n    assert candidate(nums = [-100, -200, -300, -400, -500, 600, 700, 800, 900, 1000]) == 1\n    assert candidate(nums = [-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000]) == 4\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60]) == 11\n    assert candidate(nums = [-5, -2, -3, -7, -4, -1, -6, -8]) == 4\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 4\n    assert candidate(nums = [5, 3, -5, 2, -3, 3, 9, -10, 4]) == 6\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55]) == 10\n", "comparison": "exact"}, "public_tests": ["[10,4,-8,7]", "[2,3,1,0]"], "hints": ["For any index i, how can we find the sum of the first (i+1) elements from the sum of the first i elements?", "If the total sum of the array is known, how can we check if the sum of the first (i+1) elements greater than or equal to the remaining elements?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().waysToSplitArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:02+00:00", "tests_total": 105, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def waysToSplitArray(self, nums: list[int]) -> int:", "container": "Solution", "callable": "waysToSplitArray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2271, "task_id": "maximum-white-tiles-covered-by-a-carpet", "difficulty": "Medium", "problem_description": "You are given a 2D integer array tiles where tiles[i] = [l_i, r_i] represents that every tile j in the range l_i <= j <= r_i is colored white.\n\nYou are also given an integer carpetLen, the length of a single carpet that can be placed anywhere.\n\nReturn the maximum number of white tiles that can be covered by the carpet.\n\nExample 1:\n\nInput: tiles = [[1,5],[10,11],[12,18],[20,25],[30,32]], carpetLen = 10\nOutput: 9\nExplanation: Place the carpet starting on tile 10.\nIt covers 9 white tiles, so we return 9.\nNote that there may be other places where the carpet covers 9 white tiles.\nIt can be shown that the carpet cannot cover more than 9 white tiles.\n\nExample 2:\n\nInput: tiles = [[10,11],[1,1]], carpetLen = 2\nOutput: 2\nExplanation: Place the carpet starting on tile 10.\nIt covers 2 white tiles, so we return 2.\n\nConstraints:\n\n- 1 <= tiles.length <= 5 * 10^4\n- tiles[i].length == 2\n- 1 <= l_i <= r_i <= 10^9\n- 1 <= carpetLen <= 10^9\n- The tiles are non-overlapping.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(tiles = [[1, 1000000000]],carpetLen = 1000000000) == 1000000000\n    assert candidate(tiles = [[1, 10], [11, 20], [21, 30]],carpetLen = 15) == 15\n    assert candidate(tiles = [[1, 2], [4, 5], [7, 8], [10, 11]],carpetLen = 3) == 2\n    assert candidate(tiles = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],carpetLen = 3) == 3\n    assert candidate(tiles = [[1, 100]],carpetLen = 50) == 50\n    assert candidate(tiles = [[1, 3], [5, 7], [9, 11]],carpetLen = 10) == 8\n    assert candidate(tiles = [[3, 6], [8, 10], [12, 15], [18, 20]],carpetLen = 8) == 7\n    assert candidate(tiles = [[3, 7], [10, 15], [18, 20]],carpetLen = 8) == 6\n    assert candidate(tiles = [[1, 10], [20, 30], [40, 50]],carpetLen = 15) == 11\n    assert candidate(tiles = [[3, 6], [8, 10], [12, 15]],carpetLen = 5) == 4\n    assert candidate(tiles = [[1, 3], [6, 8], [9, 12]],carpetLen = 5) == 5\n    assert candidate(tiles = [[1, 3], [6, 10], [12, 14], [16, 18]],carpetLen = 5) == 5\n    assert candidate(tiles = [[1, 5], [10, 11], [12, 18], [20, 25], [30, 32]],carpetLen = 10) == 9\n    assert candidate(tiles = [[10, 11], [1, 1]],carpetLen = 2) == 2\n    assert candidate(tiles = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],carpetLen = 10) == 10\n    assert candidate(tiles = [[2, 5], [8, 10], [12, 15], [18, 25], [30, 35], [40, 50]],carpetLen = 12) == 11\n    assert candidate(tiles = [[1, 2], [4, 8], [10, 14], [16, 20], [22, 26], [28, 32], [34, 38], [40, 44], [46, 50]],carpetLen = 10) == 9\n    assert candidate(tiles = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23], [25, 27], [29, 31]],carpetLen = 4) == 3\n    assert candidate(tiles = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70]],carpetLen = 25) == 17\n    assert candidate(tiles = [[1, 5], [7, 10], [15, 20], [25, 30], [35, 40]],carpetLen = 12) == 9\n    assert candidate(tiles = [[1, 2], [4, 6], [8, 10], [12, 14], [16, 18], [20, 22], [24, 26], [28, 30], [32, 34], [36, 38], [40, 42]],carpetLen = 10) == 8\n    assert candidate(tiles = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14]],carpetLen = 4) == 3\n    assert candidate(tiles = [[1, 5], [10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65], [70, 75]],carpetLen = 12) == 8\n    assert candidate(tiles = [[1, 100], [200, 300], [400, 500], [600, 700], [800, 900]],carpetLen = 150) == 101\n    assert candidate(tiles = [[1, 1000000000]],carpetLen = 500000000) == 500000000\n    assert candidate(tiles = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65], [70, 75], [80, 85], [90, 95]],carpetLen = 30) == 18\n    assert candidate(tiles = [[1, 100], [200, 300], [400, 500], [600, 700], [800, 900]],carpetLen = 200) == 101\n    assert candidate(tiles = [[1, 5], [10, 14], [20, 24], [30, 34], [40, 44], [50, 54]],carpetLen = 10) == 6\n    assert candidate(tiles = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30], [31, 35]],carpetLen = 10) == 10\n    assert candidate(tiles = [[1, 3], [6, 8], [11, 13], [16, 18], [21, 23], [26, 28], [31, 33], [36, 38], [41, 43], [46, 48]],carpetLen = 5) == 3\n    assert candidate(tiles = [[5, 9], [15, 29], [35, 49], [55, 69], [75, 89], [95, 109]],carpetLen = 20) == 15\n    assert candidate(tiles = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]],carpetLen = 15) == 11\n    assert candidate(tiles = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65], [70, 75], [80, 85]],carpetLen = 20) == 12\n    assert candidate(tiles = [[1, 10], [20, 30], [40, 50], [60, 70], [80, 90]],carpetLen = 15) == 11\n    assert candidate(tiles = [[1, 20], [25, 40], [45, 60], [65, 80], [85, 100]],carpetLen = 20) == 20\n    assert candidate(tiles = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23], [25, 27], [29, 31], [33, 35], [37, 39]],carpetLen = 7) == 6\n    assert candidate(tiles = [[1, 10], [21, 30], [41, 50], [61, 70], [81, 90], [101, 110]],carpetLen = 20) == 10\n    assert candidate(tiles = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [110, 120], [130, 140], [150, 160]],carpetLen = 25) == 16\n    assert candidate(tiles = [[1, 200], [400, 600], [800, 1000], [1200, 1400], [1600, 1800]],carpetLen = 350) == 201\n    assert candidate(tiles = [[1, 2], [4, 6], [8, 10], [12, 14], [16, 18], [20, 22], [24, 26], [28, 30]],carpetLen = 5) == 4\n    assert candidate(tiles = [[2, 6], [9, 14], [17, 22], [25, 30], [33, 38], [41, 46]],carpetLen = 20) == 16\n    assert candidate(tiles = [[5, 10], [20, 25], [35, 40], [55, 60], [65, 70]],carpetLen = 15) == 11\n    assert candidate(tiles = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23], [25, 27]],carpetLen = 5) == 4\n    assert candidate(tiles = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]],carpetLen = 35) == 22\n    assert candidate(tiles = [[1, 5], [8, 12], [15, 20], [25, 30], [35, 40]],carpetLen = 15) == 11\n    assert candidate(tiles = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14], [16, 17], [19, 20]],carpetLen = 3) == 2\n    assert candidate(tiles = [[2, 5], [8, 15], [18, 25], [30, 35], [40, 50], [55, 60]],carpetLen = 15) == 13\n    assert candidate(tiles = [[1, 2], [4, 6], [8, 10], [12, 14], [16, 18], [20, 22], [24, 26], [28, 30]],carpetLen = 7) == 6\n    assert candidate(tiles = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14], [16, 17]],carpetLen = 3) == 2\n    assert candidate(tiles = [[1, 5], [10, 14], [20, 24], [30, 34], [40, 44], [50, 54], [60, 64], [70, 74], [80, 84], [90, 94]],carpetLen = 10) == 6\n    assert candidate(tiles = [[1, 20], [25, 40], [45, 60], [65, 80], [85, 100]],carpetLen = 30) == 26\n    assert candidate(tiles = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],carpetLen = 4) == 7\n    assert candidate(tiles = [[1, 3], [6, 8], [11, 13], [16, 18], [21, 23], [26, 28]],carpetLen = 5) == 3\n    assert candidate(tiles = [[5, 10], [20, 25], [35, 40], [50, 55], [60, 65], [70, 75], [80, 85]],carpetLen = 20) == 12\n    assert candidate(tiles = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23]],carpetLen = 12) == 9\n    assert candidate(tiles = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],carpetLen = 5) == 9\n    assert candidate(tiles = [[1, 5], [7, 15], [20, 30], [35, 45], [50, 60], [65, 75]],carpetLen = 12) == 11\n    assert candidate(tiles = [[1, 5], [10, 15], [20, 25], [30, 35], [40, 45]],carpetLen = 12) == 8\n    assert candidate(tiles = [[1, 3], [10, 12], [20, 22], [30, 32], [40, 42], [50, 52], [60, 62]],carpetLen = 5) == 3\n    assert candidate(tiles = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60]],carpetLen = 15) == 11\n    assert candidate(tiles = [[1, 3], [10, 12], [20, 22], [30, 32], [40, 42]],carpetLen = 4) == 3\n    assert candidate(tiles = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15], [16, 18], [19, 21], [22, 24]],carpetLen = 10) == 10\n    assert candidate(tiles = [[1, 3], [5, 8], [10, 14], [18, 22], [26, 30], [34, 38]],carpetLen = 6) == 5\n    assert candidate(tiles = [[1, 5], [10, 14], [19, 23], [28, 32], [37, 41], [46, 50]],carpetLen = 10) == 6\n    assert candidate(tiles = [[1, 500000000], [500000001, 1000000000]],carpetLen = 600000000) == 600000000\n    assert candidate(tiles = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14], [16, 17], [19, 20]],carpetLen = 4) == 3\n    assert candidate(tiles = [[2, 5], [8, 11], [15, 18], [22, 25], [29, 32]],carpetLen = 10) == 8\n    assert candidate(tiles = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30]],carpetLen = 12) == 12\n    assert candidate(tiles = [[1, 2], [5, 6], [9, 10], [13, 14], [17, 18], [21, 22], [25, 26], [29, 30]],carpetLen = 3) == 2\n    assert candidate(tiles = [[1, 50], [100, 150], [200, 250], [300, 350], [400, 450], [500, 550]],carpetLen = 75) == 51\n    assert candidate(tiles = [[1, 3], [6, 8], [11, 13], [16, 18], [21, 23], [26, 28], [31, 33]],carpetLen = 6) == 4\n    assert candidate(tiles = [[2, 4], [8, 12], [16, 20], [24, 28], [32, 36]],carpetLen = 8) == 5\n    assert candidate(tiles = [[1, 3], [6, 9], [12, 15], [18, 21], [24, 27], [30, 33]],carpetLen = 10) == 8\n    assert candidate(tiles = [[5, 7], [10, 12], [15, 17], [20, 22], [25, 27], [30, 32], [35, 37]],carpetLen = 7) == 5\n    assert candidate(tiles = [[1, 5], [7, 11], [13, 17], [19, 23], [25, 29], [31, 35]],carpetLen = 15) == 13\n    assert candidate(tiles = [[1, 1000000], [2000000, 3000000], [4000000, 5000000], [6000000, 7000000]],carpetLen = 1500000) == 1000001\n    assert candidate(tiles = [[5, 10], [20, 25], [35, 40], [55, 60], [75, 80], [95, 100]],carpetLen = 30) == 12\n    assert candidate(tiles = [[1, 10], [20, 30], [40, 50], [60, 70], [80, 90]],carpetLen = 25) == 16\n    assert candidate(tiles = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000]],carpetLen = 150) == 101\n    assert candidate(tiles = [[1, 50], [100, 150], [200, 250], [300, 350], [400, 450]],carpetLen = 100) == 51\n    assert candidate(tiles = [[1, 5], [10, 14], [18, 22], [26, 30]],carpetLen = 7) == 5\n    assert candidate(tiles = [[1, 10], [20, 30], [40, 50], [60, 70], [80, 90], [100, 110]],carpetLen = 25) == 16\n    assert candidate(tiles = [[1, 3], [6, 8], [11, 13], [16, 18], [21, 23]],carpetLen = 7) == 5\n    assert candidate(tiles = [[1, 2], [4, 8], [10, 14], [16, 20], [22, 26], [28, 32]],carpetLen = 8) == 7\n    assert candidate(tiles = [[1, 2], [4, 6], [8, 10], [12, 14], [16, 18], [20, 22], [24, 26], [28, 30], [32, 34]],carpetLen = 10) == 8\n    assert candidate(tiles = [[1, 1000000000]],carpetLen = 999999999) == 999999999\n    assert candidate(tiles = [[1, 100], [200, 300], [400, 500], [600, 700], [800, 900]],carpetLen = 100) == 100\n    assert candidate(tiles = [[1, 100], [200, 300], [400, 500], [600, 700], [800, 900]],carpetLen = 50) == 50\n    assert candidate(tiles = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000]],carpetLen = 500) == 302\n    assert candidate(tiles = [[1, 10], [15, 20], [25, 30], [35, 40], [45, 50]],carpetLen = 15) == 11\n    assert candidate(tiles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],carpetLen = 5) == 5\n    assert candidate(tiles = [[1, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70]],carpetLen = 18) == 14\n    assert candidate(tiles = [[1, 10], [15, 20], [25, 30], [35, 40], [45, 50]],carpetLen = 12) == 10\n    assert candidate(tiles = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],carpetLen = 15) == 15\n    assert candidate(tiles = [[1, 50], [100, 150], [200, 250], [300, 350], [400, 450]],carpetLen = 150) == 101\n    assert candidate(tiles = [[1, 20], [40, 60], [80, 100], [120, 140], [160, 180]],carpetLen = 35) == 21\n    assert candidate(tiles = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],carpetLen = 5) == 5\n    assert candidate(tiles = [[1, 5], [10, 20], [25, 30], [35, 40], [45, 50], [55, 60]],carpetLen = 10) == 10\n    assert candidate(tiles = [[100, 150], [200, 250], [300, 350], [400, 450], [500, 550], [600, 650], [700, 750]],carpetLen = 100) == 51\n    assert candidate(tiles = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23]],carpetLen = 5) == 4\n    assert candidate(tiles = [[2, 5], [8, 15], [20, 25], [30, 40], [45, 55]],carpetLen = 12) == 11\n    assert candidate(tiles = [[5, 9], [15, 19], [25, 29], [35, 39], [45, 49]],carpetLen = 10) == 5\n    assert candidate(tiles = [[10, 14], [15, 19], [20, 24], [25, 29], [30, 34], [35, 39]],carpetLen = 15) == 15\n    assert candidate(tiles = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19]],carpetLen = 6) == 5\n    assert candidate(tiles = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14], [16, 17], [19, 20]],carpetLen = 5) == 4\n    assert candidate(tiles = [[1, 10], [20, 30], [40, 50], [60, 70], [80, 90], [100, 110]],carpetLen = 15) == 11\n    assert candidate(tiles = [[1, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60]],carpetLen = 12) == 10\n    assert candidate(tiles = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000]],carpetLen = 250) == 151\n    assert candidate(tiles = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [110, 120], [130, 140]],carpetLen = 25) == 16\n    assert candidate(tiles = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50]],carpetLen = 15) == 11\n    assert candidate(tiles = [[1, 2], [10, 11], [20, 21], [30, 31], [40, 41], [50, 51], [60, 61], [70, 71], [80, 81], [90, 91]],carpetLen = 2) == 2\n", "comparison": "exact"}, "public_tests": ["[[1,5],[10,11],[12,18],[20,25],[30,32]]\n10", "[[10,11],[1,1]]\n2"], "hints": ["Think about the potential placements of the carpet in an optimal solution.", "Can we use Prefix Sum and Binary Search to determine how many tiles are covered for a given placement?"], "metadata": {"canonical_parameter_names": ["tiles", "carpetLen"], "leetcode_dataset_entry_point": "Solution().maximumWhiteTiles", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:04+00:00", "tests_total": 111, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "greedy", "sliding-window", "sorting", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maximumWhiteTiles(self, tiles: list[list[int]], carpetLen: int) -> int:", "container": "Solution", "callable": "maximumWhiteTiles", "parameters": [{"name": "tiles", "type": "list[list[int]]"}, {"name": "carpetLen", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2272, "task_id": "substring-with-largest-variance", "difficulty": "Hard", "problem_description": "The variance of a string is defined as the largest difference between the number of occurrences of any 2 characters present in the string. Note the two characters may or may not be the same.\n\nGiven a string s consisting of lowercase English letters only, return the largest variance possible among all substrings of s.\n\nA substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: s = \"aababbb\"\nOutput: 3\nExplanation:\nAll possible variances along with their respective substrings are listed below:\n- Variance 0 for substrings \"a\", \"aa\", \"ab\", \"abab\", \"aababb\", \"ba\", \"b\", \"bb\", and \"bbb\".\n- Variance 1 for substrings \"aab\", \"aba\", \"abb\", \"aabab\", \"ababb\", \"aababbb\", and \"bab\".\n- Variance 2 for substrings \"aaba\", \"ababbb\", \"abbb\", and \"babb\".\n- Variance 3 for substring \"babbb\".\nSince the largest possible variance is 3, we return it.\n\nExample 2:\n\nInput: s = \"abcde\"\nOutput: 0\nExplanation:\nNo letter occurs more than once in s, so the variance of every substring is 0.\n\nConstraints:\n\n- 1 <= s.length <= 10^4\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"zzzzzzy\") == 5\n    assert candidate(s = \"zyzzyzyzy\") == 2\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 0\n    assert candidate(s = \"abbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n    assert candidate(s = \"abbaabbaabba\") == 2\n    assert candidate(s = \"abababab\") == 1\n    assert candidate(s = \"aaaaa\") == 0\n    assert candidate(s = \"a\") == 0\n    assert candidate(s = \"abcabcabc\") == 1\n    assert candidate(s = \"zzyzxzyzyzxzyzxzyzxzyzxzyzxzyzxzyz\") == 11\n    assert candidate(s = \"abcabcabcabc\") == 1\n    assert candidate(s = \"abcde\") == 0\n    assert candidate(s = \"leetcode\") == 2\n    assert candidate(s = \"xyzxyzxyz\") == 1\n    assert candidate(s = \"abccccccc\") == 6\n    assert candidate(s = \"zzzzzzzzzz\") == 0\n    assert candidate(s = \"aabbcc\") == 1\n    assert candidate(s = \"mississippi\") == 3\n    assert candidate(s = \"abcdefghij\") == 0\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n    assert candidate(s = \"aabbccddeeffgghhiijj\") == 1\n    assert candidate(s = \"aabbaaabb\") == 3\n    assert candidate(s = \"abacaba\") == 3\n    assert candidate(s = \"aababbb\") == 3\n", "comparison": "exact"}, "public_tests": ["\"aababbb\"", "\"abcde\""], "hints": ["Think about how to solve the problem if the string had only two distinct characters.", "If we replace all occurrences of the first character by +1 and those of the second character by -1, can we efficiently calculate the largest possible variance of a string with only two distinct characters?", "Now, try finding the optimal answer by taking all possible pairs of characters into consideration."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().largestVariance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:07+00:00", "tests_total": 25, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string", "dynamic-programming", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def largestVariance(self, s: str) -> int:", "container": "Solution", "callable": "largestVariance", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2273, "task_id": "find-resultant-array-after-removing-anagrams", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string array words, where words[i] consists of lowercase English letters.\n\nIn one operation, select any index i such that 0 < i < words.length and words[i - 1] and words[i] are anagrams, and delete words[i] from words. Keep performing this operation as long as you can select an index that satisfies the conditions.\n\nReturn words after performing all operations. It can be shown that selecting the indices for each operation in any arbitrary order will lead to the same result.\n\nAn Anagram is a word or phrase formed by rearranging the letters of a different word or phrase using all the original letters exactly once. For example, \"dacb\" is an anagram of \"abdc\".\n\nExample 1:\n\nInput: words = [\"abba\",\"baba\",\"bbaa\",\"cd\",\"cd\"]\nOutput: [\"abba\",\"cd\"]\nExplanation:\nOne of the ways we can obtain the resultant array is by using the following operations:\n- Since words[2] = \"bbaa\" and words[1] = \"baba\" are anagrams, we choose index 2 and delete words[2].\n  Now words = [\"abba\",\"baba\",\"cd\",\"cd\"].\n- Since words[1] = \"baba\" and words[0] = \"abba\" are anagrams, we choose index 1 and delete words[1].\n  Now words = [\"abba\",\"cd\",\"cd\"].\n- Since words[2] = \"cd\" and words[1] = \"cd\" are anagrams, we choose index 2 and delete words[2].\n  Now words = [\"abba\",\"cd\"].\nWe can no longer perform any operations, so [\"abba\",\"cd\"] is the final answer.\n\nExample 2:\n\nInput: words = [\"a\",\"b\",\"c\",\"d\",\"e\"]\nOutput: [\"a\",\"b\",\"c\",\"d\",\"e\"]\nExplanation:\nNo two adjacent strings in words are anagrams of each other, so no operations are performed.\n\nConstraints:\n\n- 1 <= words.length <= 100\n- 1 <= words[i].length <= 10\n- words[i] consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(words = ['abc', 'cab', 'bca', 'xyz', 'zyx', 'yxz']) == ['abc', 'xyz']\n    assert candidate(words = ['abc', 'cba', 'bca', 'xyz', 'zyx']) == ['abc', 'xyz']\n    assert candidate(words = ['unique', 'words', 'here', 'now']) == ['unique', 'words', 'here', 'now']\n    assert candidate(words = ['test', 'sett', 'tset', 'ttew']) == ['test', 'ttew']\n    assert candidate(words = ['same', 'same', 'same', 'same', 'same']) == ['same']\n    assert candidate(words = ['a', 'b', 'c', 'd', 'e']) == ['a', 'b', 'c', 'd', 'e']\n    assert candidate(words = ['aabbcc', 'abcabc', 'bcaacb', 'bacbac', 'cababc']) == ['aabbcc']\n    assert candidate(words = ['test', 'sett', 'tset', 'stet', 'ttes']) == ['test']\n    assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']) == ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']\n    assert candidate(words = ['hello', 'billion', 'oellh', 'llheo', 'note', 'tone']) == ['hello', 'billion', 'oellh', 'note']\n    assert candidate(words = ['abc', 'cab', 'bac', 'bca', 'xyz']) == ['abc', 'xyz']\n    assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd']) == ['abcd']\n    assert candidate(words = ['hello', 'olleh', 'world', 'dlrow', 'python', 'nohtyp']) == ['hello', 'world', 'python']\n    assert candidate(words = ['abba', 'baba', 'bbaa', 'cd', 'cd']) == ['abba', 'cd']\n    assert candidate(words = ['deed', 'deep', 'peed', 'depe', 'dpee']) == ['deed', 'deep']\n    assert candidate(words = ['hello', 'world', 'dlrow', 'owrld', 'worlc']) == ['hello', 'world', 'worlc']\n    assert candidate(words = ['same', 'same', 'same', 'same']) == ['same']\n    assert candidate(words = ['abc', 'cba', 'bac', 'bca', 'cab', 'acb']) == ['abc']\n    assert candidate(words = ['aaa', 'aa', 'a', 'aaaa', 'aaa']) == ['aaa', 'aa', 'a', 'aaaa', 'aaa']\n    assert candidate(words = ['aabbcc', 'baccab', 'abcabc', 'xyz', 'zyx', 'yxz']) == ['aabbcc', 'xyz']\n    assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl']) == ['listen', 'google']\n    assert candidate(words = ['abc', 'cab', 'bac', 'bca', 'acb', 'cba']) == ['abc']\n    assert candidate(words = ['aaa', 'aa', 'a']) == ['aaa', 'aa', 'a']\n    assert candidate(words = ['deed', 'deed', 'deed', 'deed', 'deed']) == ['deed']\n    assert candidate(words = ['hello', 'world', 'dlrow', 'owrld', 'werld', 'hello', 'olleh', 'dlrow', 'world', 'rowld', 'dlrow', 'hello', 'hello', 'world', 'world', 'world', 'dlrow', 'dlrow', 'dlrow', 'dlrow']) == ['hello', 'world', 'werld', 'hello', 'dlrow', 'hello', 'world']\n    assert candidate(words = ['triangle', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral']) == ['triangle']\n    assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e']) == ['a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e']\n    assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'abc', 'cab', 'bac', 'xyz', 'zyx', 'yxz']) == ['listen', 'google', 'abc', 'xyz']\n    assert candidate(words = ['rat', 'car', 'tar', 'arc', 'art', 'cat', 'tac', 'act', 'rat', 'car']) == ['rat', 'car', 'tar', 'arc', 'art', 'cat', 'rat', 'car']\n    assert candidate(words = ['racecar', 'carrace', 'acecar', 'enlist', 'inlets', 'silent', 'google', 'gooegl', 'abc', 'bac', 'cba', 'xyz', 'zyx', 'yxz', 'zyx', 'xyz', 'listen', 'silent', 'enlist']) == ['racecar', 'acecar', 'enlist', 'google', 'abc', 'xyz', 'listen']\n    assert candidate(words = ['aabbcc', 'aabbc', 'aabc', 'abc', 'ab', 'a', 'abcd', 'dcba', 'bacd', 'cadb', 'abdc', 'cabd', 'mnop', 'ponm', 'omnp', 'nmop', 'mpno', 'pmno']) == ['aabbcc', 'aabbc', 'aabc', 'abc', 'ab', 'a', 'abcd', 'mnop']\n    assert candidate(words = ['ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba', 'ab', 'ba']) == ['ab']\n    assert candidate(words = ['hello', 'olleh', 'loleh', 'ohell', 'ehlol', 'world', 'dlrow', 'rowld', 'owlrd', 'wrold', 'hello', 'olleh', 'loleh', 'ohell', 'ehlol']) == ['hello', 'world', 'hello']\n    assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'abc', 'cab', 'bac', 'xyz', 'zyx', 'zyxw', 'wxyz']) == ['listen', 'google', 'abc', 'xyz', 'zyxw']\n    assert candidate(words = ['abcd', 'dcba', 'bacd', 'cadb', 'abdc', 'cabd', 'abcd', 'dcba', 'bacd', 'cadb', 'abdc', 'cabd', 'mnop', 'ponm', 'omnp', 'nmop', 'mpno', 'pmno']) == ['abcd', 'mnop']\n    assert candidate(words = ['aabbcc', 'baccab', 'abcabc', 'xyz', 'zyx', 'yxz', 'test', 'sett', 'tset', 'stet', 'ttes']) == ['aabbcc', 'xyz', 'test']\n    assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'abc', 'cab', 'bac', 'bca', 'acb', 'cba', 'xyz', 'zyx', 'yxz']) == ['listen', 'google', 'abc', 'xyz']\n    assert candidate(words = ['rat', 'tar', 'art', 'star', 'rats', 'tars', 'arts', 'tsar', 'chart', 'arch', 'cart', 'ract', 'track', 'krat', 'tract', 'crat', 'carr', 'rack', 'crab', 'back', 'bark', 'park', 'parking', 'arking', 'king', 'gnik', 'pink', 'kimp', 'pink', 'knip', 'kpin']) == ['rat', 'star', 'chart', 'arch', 'cart', 'track', 'krat', 'tract', 'crat', 'carr', 'rack', 'crab', 'back', 'bark', 'park', 'parking', 'arking', 'king', 'pink', 'kimp', 'pink']\n    assert candidate(words = ['rat', 'tar', 'art', 'car', 'arc', 'par', 'arp', 'arc', 'rac', 'cat', 'tac', 'act', 'cta', 'atc', 'tca', 'pqr', 'qrp', 'rpq', 'prq', 'rqp', 'qpr', 'aabb', 'bbaa', 'abab', 'abba', 'aaaa', 'bbba', 'baab', 'aabb', 'baba', 'bbaa', 'cd', 'cd', 'efg', 'feg', 'gfe', 'geg', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj', 'kkk', 'lll', 'mmm', 'nnn', 'ooo', 'ppp', 'qqq', 'rrr', 'sss', 'ttt', 'uuu', 'vvv', 'www', 'xxx', 'yyy', 'zzz']) == ['rat', 'car', 'par', 'arc', 'cat', 'pqr', 'aabb', 'aaaa', 'bbba', 'baab', 'cd', 'efg', 'geg', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj', 'kkk', 'lll', 'mmm', 'nnn', 'ooo', 'ppp', 'qqq', 'rrr', 'sss', 'ttt', 'uuu', 'vvv', 'www', 'xxx', 'yyy', 'zzz']\n    assert candidate(words = ['race', 'care', 'acre', 'racecar', 'carrace', 'racecar', 'carrace', 'abc', 'bca', 'cab', 'xyz', 'zyx', 'yxz', 'zyxzyx', 'xzyzyz', 'yzyzyx']) == ['race', 'racecar', 'abc', 'xyz', 'zyxzyx', 'xzyzyz', 'yzyzyx']\n    assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == ['abcd']\n    assert candidate(words = ['aaaa', 'aaab', 'aabb', 'abbb', 'bbbb', 'bbb', 'bb', 'b', 'a', 'abc', 'bac', 'cba', 'bca', 'cab', 'acb', 'xyz', 'zyx', 'yxz']) == ['aaaa', 'aaab', 'aabb', 'abbb', 'bbbb', 'bbb', 'bb', 'b', 'a', 'abc', 'xyz']\n    assert candidate(words = ['rat', 'tar', 'art', 'dog', 'god', 'cat', 'act', 'tac', 'tack', 'rack', 'track', 'chart', 'cart']) == ['rat', 'dog', 'cat', 'tack', 'rack', 'track', 'chart', 'cart']\n    assert candidate(words = ['abcde', 'edcba', 'decba', 'acdeb', 'badce', 'abcde', 'edcba', 'decba', 'acdeb', 'badce', 'abcde', 'edcba', 'decba', 'acdeb', 'badce', 'abcde', 'edcba', 'decba', 'acdeb', 'badce']) == ['abcde']\n    assert candidate(words = ['anagram', 'nagaram', 'margana', 'anagram', 'margana', 'anagram', 'nagaram', 'margana', 'anagram', 'nagaram', 'margana', 'anagram', 'nagaram', 'margana', 'anagram', 'nagaram', 'margana', 'anagram', 'nagaram', 'margana']) == ['anagram']\n    assert candidate(words = ['python', 'typhon', 'hypton', 'ypthon', 'phonto', 'opynth', 'ypthon', 'phonto', 'opynth', 'ypthon', 'phonto', 'opynth', 'ypthon', 'phonto', 'opynth']) == ['python', 'phonto', 'opynth', 'phonto', 'opynth', 'phonto', 'opynth', 'phonto', 'opynth']\n    assert candidate(words = ['dormitory', 'dirtyroom', 'dirtyroom', 'dormitory', 'dirtyroom', 'dirtyroom', 'dormitory']) == ['dormitory']\n    assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == ['abcd']\n    assert candidate(words = ['aaaaa', 'aaabb', 'aabba', 'abbaa', 'baaab', 'baaba', 'bbaaa', 'abcde', 'edcba', 'decba', 'cbade', 'badec']) == ['aaaaa', 'aaabb', 'abcde']\n    assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'abc', 'bca', 'cab', 'xyz', 'zyx', 'yxz']) == ['listen', 'google', 'abc', 'xyz']\n    assert candidate(words = ['race', 'care', 'acre', 'barc', 'racecar', 'carrace', 'racecar', 'carecar', 'abcde', 'edcba', 'bcdea', 'deabc', 'acdeb', 'decab']) == ['race', 'barc', 'racecar', 'abcde']\n    assert candidate(words = ['triangle', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral', 'integral']) == ['triangle']\n    assert candidate(words = ['aabbcc', 'abcabc', 'baccab', 'abccba', 'bacabc', 'aabbcc', 'abcd', 'dcba', 'cdab', 'bcda', 'badc', 'cabd']) == ['aabbcc', 'abcd']\n    assert candidate(words = ['abcd', 'dcba', 'abcd', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == ['abcd']\n    assert candidate(words = ['rat', 'tar', 'art', 'dog', 'god', 'cat', 'act', 'tac', 'abc', 'bca', 'cab', 'xyz', 'zyx', 'yxz']) == ['rat', 'dog', 'cat', 'abc', 'xyz']\n    assert candidate(words = ['hello', 'olleh', 'world', 'dlrow', 'python', 'nothpy', 'java', 'avaj', 'abcd', 'dcba', 'bacd', 'cadb', 'abdc', 'cabd']) == ['hello', 'world', 'python', 'java', 'abcd']\n    assert candidate(words = ['anagram', 'nagaram', 'margana', 'ramnaga', 'gnamar', 'gnamar', 'gnamra', 'gnamra', 'gnamra', 'gnamra', 'gnamra', 'gnamra', 'gnamra']) == ['anagram', 'gnamar']\n    assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'abc', 'bca', 'cab', 'xyz', 'zyx', 'zyx', 'xyz']) == ['listen', 'google', 'abc', 'xyz']\n    assert candidate(words = ['aabbcc', 'baccab', 'cbaabc', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'xyz', 'zyx', 'yxz', 'zyx', 'xyz']) == ['aabbcc', 'abc', 'xyz']\n    assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'abc', 'cab', 'bac', 'xyz', 'zyx', 'yxz', 'uvw', 'vuw', 'wuv']) == ['listen', 'google', 'abc', 'xyz', 'uvw']\n    assert candidate(words = ['abcd', 'dcba', 'bacd', 'cadb', 'abdc', 'cabd', 'abcd', 'dcba', 'bacd', 'cadb', 'abdc', 'cabd']) == ['abcd']\n    assert candidate(words = ['python', 'typhon', 'nohtyp', 'ypthon', 'hypnot', 'python', 'typhon', 'nohtyp', 'ypthon', 'hypnot', 'python', 'typhon', 'nohtyp', 'ypthon', 'hypnot', 'python', 'typhon', 'nohtyp', 'ypthon', 'hypnot']) == ['python']\n    assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'inlets']) == ['listen', 'google', 'inlets']\n    assert candidate(words = ['aabbcc', 'abcabc', 'baccab', 'cabcab', 'abacbc', 'bbacac', 'acbbca', 'aabbbc', 'aabbbc', 'aabbbc']) == ['aabbcc', 'aabbbc']\n    assert candidate(words = ['abcd', 'dcba', 'cdab', 'bacd', 'cadb', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == ['abcd']\n    assert candidate(words = ['aabbcc', 'abcabc', 'baccab', 'xyz', 'zyx', 'yxz', 'mnop', 'ponm', 'omnp', 'nmop', 'mpno', 'pmno']) == ['aabbcc', 'xyz', 'mnop']\n    assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba', 'zzzz', 'zzz', 'zz', 'z']) == ['abc', 'abcd', 'zzzz', 'zzz', 'zz', 'z']\n    assert candidate(words = ['ab', 'ba', 'aabb', 'bbaa', 'abab', 'baba', 'abba', 'baab', 'ab', 'ba']) == ['ab', 'aabb', 'ab']\n    assert candidate(words = ['aabbcc', 'baccab', 'abcabc', 'abc', 'bac', 'cab', 'bac', 'abc', 'bac', 'cab', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc', 'bac', 'abc']) == ['aabbcc', 'abc']\n    assert candidate(words = ['abcd', 'dcba', 'abdc', 'cbad', 'bcad', 'adbc', 'dabc', 'cdab', 'dacb', 'cadb', 'acbd', 'bdac', 'bdca', 'abcd', 'dcba', 'abdc', 'cbad', 'bcad', 'adbc', 'dabc', 'cdab', 'dacb', 'cadb', 'acbd', 'bdac', 'bdca', 'abcd', 'dcba', 'abdc', 'cbad', 'bcad', 'adbc', 'dabc', 'cdab', 'dacb', 'cadb', 'acbd', 'bdac', 'bdca', 'abcd', 'dcba', 'abdc', 'cbad', 'bcad', 'adbc', 'dabc', 'cdab', 'dacb', 'cadb', 'acbd', 'bdac', 'bdca']) == ['abcd']\n    assert candidate(words = ['aabbcc', 'abcabc', 'baccab', 'ccabba', 'cabacb', 'abcabc', 'aabbcc', 'xyzxyz', 'zyxzyx', 'yxzyxz', 'zyxzyx']) == ['aabbcc', 'xyzxyz']\n    assert candidate(words = ['anagram', 'nagaram', 'margana', 'gnarama', 'granama', 'aaagmnr', 'ab', 'ba', 'abc', 'cba', 'abcd', 'dcba', 'xyz', 'zyx', 'yxz', 'test', 'sett', 'tset', 'stet', 'ttes', 'deed', 'deep', 'peed', 'depe', 'dpee', 'aabbcc', 'baccab', 'abcabc', 'rat', 'tar', 'art', 'dog', 'god', 'cat', 'act', 'tac', 'abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba', 'zzzz', 'zzz', 'zz', 'z']) == ['anagram', 'ab', 'abc', 'abcd', 'xyz', 'test', 'deed', 'deep', 'aabbcc', 'rat', 'dog', 'cat', 'abcd', 'zzzz', 'zzz', 'zz', 'z']\n    assert candidate(words = ['word', 'drow', 'dwor', 'owrd', 'abcd', 'dcba', 'cadb', 'bdac', 'abcd', 'dcba', 'cabd', 'bdac']) == ['word', 'abcd']\n    assert candidate(words = ['abcd', 'dcba', 'abcd', 'abdc', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd']) == ['abcd']\n    assert candidate(words = ['anagram', 'nagaram', 'margana', 'anagram', 'nagaram', 'margana', 'anagram', 'nagaram']) == ['anagram']\n    assert candidate(words = ['abcd', 'dcba', 'cdab', 'bacd', 'adcb', 'cbad', 'bcda', 'abcd', 'dcba', 'cdab', 'bacd', 'adcb', 'cbad', 'bcda']) == ['abcd']\n    assert candidate(words = ['rat', 'tar', 'art', 'car', 'arc', 'arc', 'rca', 'arc', 'cat', 'tac', 'act', 'dog', 'god', 'god', 'ogd']) == ['rat', 'car', 'cat', 'dog']\n    assert candidate(words = ['hello', 'billion', 'nillion', 'illonbi', 'onbilin', 'nnoblli', 'olnibin', 'lobinin', 'ollinbi', 'bloninl', 'bnoloni', 'noblinl', 'llinbon', 'lobinln', 'nilonbl', 'nonlibl', 'oblinln', 'nlonbil', 'oninlb', 'nobinll', 'binlonl', 'onlibnl', 'nbinlol', 'inlboon', 'libnoln', 'onilnbl', 'inlobnl', 'lnoibnl', 'nobllin', 'oinlnbl', 'onilb', 'nlibl', 'inlbn', 'lnbol', 'onbil', 'ilnob', 'lnoib', 'nlobi', 'olnib', 'blnio', 'bnlio', 'nliob', 'libon', 'inlob', 'onilb', 'nobil', 'inobl', 'onlbi', 'nobil', 'lobin', 'linbo', 'inolb', 'nolbi', 'libno', 'inlob', 'onilb', 'nobli', 'inobl', 'onlbi', 'nobil', 'lobin', 'linbo', 'inolb', 'nolbi', 'libno']) == ['hello', 'billion', 'nillion', 'illonbi', 'onbilin', 'nnoblli', 'olnibin', 'ollinbi', 'bloninl', 'bnoloni', 'noblinl', 'oninlb', 'nobinll', 'inlboon', 'libnoln', 'onilb', 'nlibl', 'inlbn', 'lnbol', 'onbil']\n    assert candidate(words = ['aabb', 'abab', 'bbaa', 'abcd', 'dcba', 'cdab', 'bcda', 'mnop', 'ponm', 'opnm', 'nmop', 'qrst', 'srqt', 'qstr', 'tqrs', 'stqr', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd']) == ['aabb', 'abcd', 'mnop', 'qrst', 'abcd']\n    assert candidate(words = ['triangle', 'integral', 'integral', 'integral', 'triangle', 'integral']) == ['triangle']\n    assert candidate(words = ['listen', 'silent', 'enlist', 'google', 'gooegl', 'abc', 'cab', 'bac', 'xyz', 'zyx', 'yxz', 'test', 'sett', 'tset', 'stet', 'ttes', 'deed', 'deep', 'peed', 'depe', 'dpee']) == ['listen', 'google', 'abc', 'xyz', 'test', 'deed', 'deep']\n    assert candidate(words = ['deed', 'deep', 'peed', 'depe', 'dpee', 'abcd', 'dcba', 'cbad', 'adcb', 'bacd', 'cabd', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == ['deed', 'deep', 'abcd']\n    assert candidate(words = ['aabbcc', 'bbaacc', 'abcabc', 'cccccc', 'bbbaaa', 'aabbcc', 'ccbbdd']) == ['aabbcc', 'cccccc', 'bbbaaa', 'aabbcc', 'ccbbdd']\n    assert candidate(words = ['anagram', 'nagaram', 'margana', 'gnarham', 'ramnaga', 'gramana', 'amnagar', 'mangara', 'gnarama', 'ramagna', 'amnagra', 'agranam', 'mangnra', 'gnanram', 'rangnam', 'anagram', 'nagaram', 'margana', 'gnarham', 'ramnaga', 'gramana', 'amnagar', 'mangara', 'gnarama', 'ramagna', 'amnagra', 'agranam', 'mangnra', 'gnanram', 'rangnam']) == ['anagram', 'gnarham', 'ramnaga', 'mangnra', 'anagram', 'gnarham', 'ramnaga', 'mangnra']\n", "comparison": "exact"}, "public_tests": ["[\"abba\",\"baba\",\"bbaa\",\"cd\",\"cd\"]", "[\"a\",\"b\",\"c\",\"d\",\"e\"]"], "hints": ["Instead of removing each repeating anagram, try to find all the strings in words which will not be present in the final answer.", "For every index i, find the largest index j < i such that words[j] will be present in the final answer.", "Check if words[i] and words[j] are anagrams. If they are, then it can be confirmed that words[i] will not be present in the final answer."], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().removeAnagrams", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:09+00:00", "tests_total": 86, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "hash-table", "string", "sorting"]}, "language": "python", "interface": {"raw_signature": "def removeAnagrams(self, words: list[str]) -> list[str]:", "container": "Solution", "callable": "removeAnagrams", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2274, "task_id": "maximum-consecutive-floors-without-special-floors", "difficulty": "Medium", "problem_description": "Alice manages a company and has rented some floors of a building as office space. Alice has decided some of these floors should be special floors, used for relaxation only.\n\nYou are given two integers bottom and top, which denote that Alice has rented all the floors from bottom to top (inclusive). You are also given the integer array special, where special[i] denotes a special floor that Alice has designated for relaxation.\n\nReturn the maximum number of consecutive floors without a special floor.\n\nExample 1:\n\nInput: bottom = 2, top = 9, special = [4,6]\nOutput: 3\nExplanation: The following are the ranges (inclusive) of consecutive floors without a special floor:\n- (2, 3) with a total amount of 2 floors.\n- (5, 5) with a total amount of 1 floor.\n- (7, 9) with a total amount of 3 floors.\nTherefore, we return the maximum number which is 3 floors.\n\nExample 2:\n\nInput: bottom = 6, top = 8, special = [7,6,8]\nOutput: 0\nExplanation: Every floor rented is a special floor, so we return 0.\n\nConstraints:\n\n- 1 <= special.length <= 10^5\n- 1 <= bottom <= special[i] <= top <= 10^9\n- All the values of special are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(bottom = 3,top = 7,special = [3, 4, 5, 6, 7]) == 0\n    assert candidate(bottom = 1,top = 1,special = [1]) == 0\n    assert candidate(bottom = 1,top = 10,special = [3, 5, 7, 9]) == 2\n    assert candidate(bottom = 6,top = 8,special = [7, 6, 8]) == 0\n    assert candidate(bottom = 5,top = 15,special = [10]) == 5\n    assert candidate(bottom = 3,top = 15,special = [3, 5, 7, 9, 11, 15]) == 3\n    assert candidate(bottom = 1,top = 10,special = [2, 5, 8]) == 2\n    assert candidate(bottom = 10,top = 20,special = [12, 14, 16, 18]) == 2\n    assert candidate(bottom = 6,top = 8,special = [7, 6, 8]) == 0\n    assert candidate(bottom = 2,top = 9,special = [4, 6]) == 3\n    assert candidate(bottom = 10,top = 20,special = [12, 15, 18]) == 2\n    assert candidate(bottom = 1,top = 10,special = [5]) == 5\n    assert candidate(bottom = 10,top = 10,special = [10]) == 0\n    assert candidate(bottom = 1,top = 1000000000,special = [500000000]) == 500000000\n    assert candidate(bottom = 3,top = 7,special = [3, 4, 5, 6, 7]) == 0\n    assert candidate(bottom = 1,top = 10,special = [3, 5, 7]) == 3\n    assert candidate(bottom = 2,top = 9,special = [4, 6]) == 3\n    assert candidate(bottom = 1,top = 100,special = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 9\n    assert candidate(bottom = 1,top = 1000000,special = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000]) == 100000\n    assert candidate(bottom = 2,top = 100,special = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 10\n    assert candidate(bottom = 50,top = 200,special = [60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 10\n    assert candidate(bottom = 1,top = 1000,special = [1, 500, 1000]) == 499\n    assert candidate(bottom = 10,top = 20,special = [11, 13, 15, 17]) == 3\n    assert candidate(bottom = 50,top = 200,special = [100, 150, 125]) == 50\n    assert candidate(bottom = 5,top = 50,special = [10, 20, 30, 40]) == 10\n    assert candidate(bottom = 1,top = 1000000000,special = [1000000000]) == 999999999\n    assert candidate(bottom = 1,top = 1000000000,special = [1, 1000000000]) == 999999998\n    assert candidate(bottom = 5,top = 25,special = [7, 13, 19]) == 6\n    assert candidate(bottom = 1,top = 500,special = [250]) == 250\n    assert candidate(bottom = 5,top = 20,special = [6, 8, 10, 12, 14, 16, 18]) == 2\n    assert candidate(bottom = 1,top = 1000,special = [500, 750]) == 499\n    assert candidate(bottom = 1,top = 1000,special = [500]) == 500\n    assert candidate(bottom = 1,top = 50,special = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48]) == 2\n    assert candidate(bottom = 5,top = 15,special = [6, 11]) == 4\n    assert candidate(bottom = 5,top = 15,special = [7, 10, 13]) == 2\n    assert candidate(bottom = 10,top = 50,special = [15, 25, 35, 45]) == 9\n    assert candidate(bottom = 10,top = 50,special = [15, 25, 35]) == 15\n    assert candidate(bottom = 1,top = 50,special = [50]) == 49\n    assert candidate(bottom = 1,top = 100,special = [2, 98]) == 95\n    assert candidate(bottom = 5,top = 25,special = [10, 20]) == 9\n    assert candidate(bottom = 1,top = 100,special = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100]) == 3\n    assert candidate(bottom = 1,top = 100,special = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 81\n    assert candidate(bottom = 1,top = 100,special = [50]) == 50\n    assert candidate(bottom = 1,top = 1000,special = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 901\n    assert candidate(bottom = 1,top = 100,special = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 100]) == 1\n    assert candidate(bottom = 10,top = 20,special = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n    assert candidate(bottom = 1,top = 1000000000,special = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000]) == 100000000\n    assert candidate(bottom = 1,top = 1000,special = [10, 200, 300, 400, 500, 600, 700, 800, 900]) == 189\n    assert candidate(bottom = 1,top = 50,special = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47]) == 3\n    assert candidate(bottom = 100,top = 200,special = [120, 130, 140, 150, 160, 170, 180, 190]) == 20\n    assert candidate(bottom = 1,top = 1000,special = [1, 1000]) == 998\n    assert candidate(bottom = 1,top = 1000000000,special = [1, 500000000, 1000000000]) == 499999999\n    assert candidate(bottom = 10,top = 20,special = [10, 12, 14, 16, 18, 20]) == 1\n    assert candidate(bottom = 1,top = 1000,special = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 100\n    assert candidate(bottom = 1,top = 1000000,special = [500000]) == 500000\n    assert candidate(bottom = 5,top = 50,special = [15, 25, 35, 45]) == 10\n    assert candidate(bottom = 50,top = 150,special = [51, 52, 53, 54, 55, 56, 57, 58, 59, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149]) == 40\n    assert candidate(bottom = 1,top = 50,special = [25]) == 25\n    assert candidate(bottom = 10,top = 100,special = [15, 35, 60, 85]) == 24\n    assert candidate(bottom = 1,top = 100,special = [1, 2, 3, 4, 5, 96, 97, 98, 99, 100]) == 90\n    assert candidate(bottom = 10,top = 1000,special = [150, 250, 350, 450, 550, 650, 750, 850, 950]) == 140\n    assert candidate(bottom = 5,top = 50,special = [10, 15, 20, 25, 30, 35, 40, 45]) == 5\n    assert candidate(bottom = 10,top = 20,special = [12, 15, 18]) == 2\n    assert candidate(bottom = 1,top = 100,special = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]) == 1\n    assert candidate(bottom = 1,top = 100,special = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 10\n    assert candidate(bottom = 10,top = 50,special = [12, 15, 20, 25, 30, 35, 40, 45]) == 5\n    assert candidate(bottom = 10,top = 10000,special = [500, 2500, 4500, 6500, 8500]) == 1999\n    assert candidate(bottom = 1,top = 100,special = [99]) == 98\n    assert candidate(bottom = 1,top = 100,special = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 61\n    assert candidate(bottom = 1,top = 100,special = [1, 100]) == 98\n    assert candidate(bottom = 10,top = 100,special = [20, 40, 60, 80]) == 20\n    assert candidate(bottom = 1,top = 1000000,special = [1, 2, 3, 4, 5, 999995, 999996, 999997, 999998, 999999]) == 999989\n    assert candidate(bottom = 1,top = 20,special = [2, 4, 6, 8, 10, 12, 14, 16, 18]) == 2\n    assert candidate(bottom = 1,top = 20,special = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n    assert candidate(bottom = 1,top = 10,special = [2, 4, 6, 8]) == 2\n    assert candidate(bottom = 100,top = 200,special = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200]) == 1\n    assert candidate(bottom = 100,top = 500,special = [200, 300, 400]) == 100\n    assert candidate(bottom = 1,top = 100,special = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 9\n    assert candidate(bottom = 1,top = 20,special = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 1\n    assert candidate(bottom = 10,top = 1000,special = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 100\n    assert candidate(bottom = 1,top = 100,special = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 1\n    assert candidate(bottom = 1,top = 50,special = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 29\n    assert candidate(bottom = 20,top = 200,special = [30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 10\n    assert candidate(bottom = 5,top = 50,special = [15, 25, 35, 45, 5, 40]) == 9\n    assert candidate(bottom = 1,top = 100,special = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]) == 5\n    assert candidate(bottom = 10,top = 50,special = [20, 30, 40]) == 10\n    assert candidate(bottom = 1,top = 100,special = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 7\n    assert candidate(bottom = 1,top = 10,special = [1, 3, 5, 7, 9]) == 1\n    assert candidate(bottom = 1,top = 100,special = [5, 25, 45, 65, 85, 95]) == 19\n    assert candidate(bottom = 10,top = 100,special = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 75\n    assert candidate(bottom = 1,top = 100,special = [2, 25, 50, 75, 100]) == 24\n    assert candidate(bottom = 1,top = 10,special = [2, 4, 6, 8, 10]) == 1\n", "comparison": "exact"}, "public_tests": ["2\n9\n[4,6]", "6\n8\n[7,6,8]"], "hints": ["Say we have a pair of special floors (x, y) with no other special floors in between. There are x - y - 1 consecutive floors in between them without a special floor.", "Say there are n special floors. After sorting special, we have answer = max(answer, special[i] – special[i – 1] – 1) for all 0 < i < n.", "However, there are two special cases left to consider: the floors before special[0] and after special[n-1].", "To consider these cases, we have answer = max(answer, special[0] – bottom, top – special[n-1])."], "metadata": {"canonical_parameter_names": ["bottom", "top", "special"], "leetcode_dataset_entry_point": "Solution().maxConsecutive", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:12+00:00", "tests_total": 93, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxConsecutive(self, bottom: int, top: int, special: list[int]) -> int:", "container": "Solution", "callable": "maxConsecutive", "parameters": [{"name": "bottom", "type": "int"}, {"name": "top", "type": "int"}, {"name": "special", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2275, "task_id": "largest-combination-with-bitwise-and-greater-than-zero", "difficulty": "Medium", "problem_description": "The bitwise AND of an array nums is the bitwise AND of all integers in nums.\n\n- For example, for nums = [1, 5, 3], the bitwise AND is equal to 1 & 5 & 3 = 1.\n- Also, for nums = [7], the bitwise AND is 7.\n\nYou are given an array of positive integers candidates. Compute the bitwise AND for all possible combinations of elements in the candidates array.\n\nReturn the size of the largest combination of candidates with a bitwise AND greater than 0.\n\nExample 1:\n\nInput: candidates = [16,17,71,62,12,24,14]\nOutput: 4\nExplanation: The combination [16,17,62,24] has a bitwise AND of 16 & 17 & 62 & 24 = 16 > 0.\nThe size of the combination is 4.\nIt can be shown that no combination with a size greater than 4 has a bitwise AND greater than 0.\nNote that more than one combination may have the largest size.\nFor example, the combination [62,12,24,14] has a bitwise AND of 62 & 12 & 24 & 14 = 8 > 0.\n\nExample 2:\n\nInput: candidates = [8,8]\nOutput: 2\nExplanation: The largest combination [8,8] has a bitwise AND of 8 & 8 = 8 > 0.\nThe size of the combination is 2, so we return 2.\n\nConstraints:\n\n- 1 <= candidates.length <= 10^5\n- 1 <= candidates[i] <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(candidates = [16, 17, 71, 62, 12, 24, 14]) == 4\n    assert candidate(candidates = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 16\n    assert candidate(candidates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n    assert candidate(candidates = [1, 10000000, 2, 9999999, 3, 9999998, 4, 9999997, 5, 9999996, 6, 9999995, 7, 9999994, 8, 9999993, 9, 9999992, 10, 9999991]) == 11\n    assert candidate(candidates = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31]) == 10\n    assert candidate(candidates = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 1\n    assert candidate(candidates = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991]) == 10\n    assert candidate(candidates = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1\n    assert candidate(candidates = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 1\n    assert candidate(candidates = [8, 8]) == 2\n    assert candidate(candidates = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 10\n    assert candidate(candidates = [1048575, 1048574, 1048573, 1048572, 1048571]) == 5\n    assert candidate(candidates = [10000000, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144]) == 2\n    assert candidate(candidates = [31, 31, 31, 31, 31]) == 5\n    assert candidate(candidates = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000]) == 10\n    assert candidate(candidates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 25\n    assert candidate(candidates = [1048575, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 14\n    assert candidate(candidates = [9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990, 9999989, 9999988, 9999987, 9999986, 9999985, 9999984, 9999983, 9999982, 9999981, 9999980]) == 20\n    assert candidate(candidates = [1000000, 1000001, 1000002, 1000003, 1000004, 1000005, 1000006, 1000007, 1000008, 1000009, 1000010, 1000011, 1000012, 1000013, 1000014, 1000015, 1000016, 1000017, 1000018, 1000019]) == 20\n    assert candidate(candidates = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 1\n    assert candidate(candidates = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109, 113, 117]) == 30\n    assert candidate(candidates = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180]) == 11\n    assert candidate(candidates = [524288, 524290, 524292, 524294, 524296, 524298, 524300, 524302, 524304, 524306, 524308, 524310, 524312, 524314, 524316, 524318, 524320, 524322, 524324, 524326]) == 20\n    assert candidate(candidates = [5000000, 5000001, 5000002, 5000003, 5000004, 5000005, 5000006, 5000007, 5000008, 5000009, 5000010, 5000011, 5000012, 5000013, 5000014, 5000015, 5000016, 5000017, 5000018, 5000019, 5000020, 5000021, 5000022, 5000023, 5000024, 5000025, 5000026, 5000027, 5000028, 5000029, 5000030]) == 31\n    assert candidate(candidates = [5000000, 4000000, 3000000, 2000000, 1000000, 500000, 400000, 300000, 200000, 100000, 50000, 40000, 30000, 20000, 10000, 5000, 4000, 3000, 2000, 1000, 500, 400, 300, 200, 100, 50, 40, 30, 20, 10, 5]) == 16\n    assert candidate(candidates = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109]) == 29\n    assert candidate(candidates = [8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 1\n    assert candidate(candidates = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015, 1014, 1013, 1012, 1011, 1010, 1009, 1008, 1007, 1006, 1005, 1004]) == 20\n    assert candidate(candidates = [983040, 983041, 983042, 983043, 983044, 983045, 983046, 983047, 983048, 983049]) == 10\n    assert candidate(candidates = [9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990, 9999989, 9999988, 9999987, 9999986, 9999985, 9999984, 9999983, 9999982, 9999981, 9999980]) == 20\n    assert candidate(candidates = [5000000, 5000001, 5000002, 5000003, 5000004, 5000005, 5000006, 5000007, 5000008, 5000009]) == 10\n    assert candidate(candidates = [8388607, 8388606, 8388605, 8388604, 8388603, 8388602, 8388601, 8388600, 8388599, 8388598, 8388597, 8388596, 8388595, 8388594, 8388593, 8388592, 8388591, 8388590, 8388589, 8388588]) == 20\n    assert candidate(candidates = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == 16\n    assert candidate(candidates = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 9\n    assert candidate(candidates = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2\n    assert candidate(candidates = [15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607]) == 20\n    assert candidate(candidates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n    assert candidate(candidates = [1048575, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2\n    assert candidate(candidates = [3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151]) == 20\n    assert candidate(candidates = [1023, 2047, 4095, 8191, 16383, 32767, 65535]) == 7\n    assert candidate(candidates = [262143, 262142, 262141, 262140, 262139, 262138, 262137, 262136, 262135, 262134, 262133, 262132, 262131, 262130, 262129, 262128, 262127, 262126, 262125, 262124, 262123, 262122, 262121, 262120, 262119, 262118, 262117, 262116, 262115, 262114, 262113]) == 31\n    assert candidate(candidates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64]) == 32\n    assert candidate(candidates = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 10\n    assert candidate(candidates = [5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000]) == 15\n    assert candidate(candidates = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 20\n    assert candidate(candidates = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 20\n    assert candidate(candidates = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109]) == 29\n    assert candidate(candidates = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n    assert candidate(candidates = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127]) == 30\n    assert candidate(candidates = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062, 19531, 9765, 4882, 2441, 1220, 610, 305, 152, 76, 38, 19]) == 8\n    assert candidate(candidates = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 62\n    assert candidate(candidates = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 16\n    assert candidate(candidates = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287]) == 10\n    assert candidate(candidates = [65535, 65534, 65533, 65532, 65531, 65530, 65529, 65528, 65527, 65526, 65525, 65524, 65523, 65522, 65521, 65520, 65519, 65518, 65517, 65516, 65515, 65514, 65513, 65512, 65511, 65510, 65509, 65508, 65507, 65506, 65505]) == 31\n    assert candidate(candidates = [1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576]) == 10\n    assert candidate(candidates = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1\n    assert candidate(candidates = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 50\n    assert candidate(candidates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 16\n    assert candidate(candidates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 25\n    assert candidate(candidates = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 10\n    assert candidate(candidates = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1\n    assert candidate(candidates = [15, 27, 51, 85, 129, 173, 217, 261, 305, 349, 393, 437, 481, 525, 569, 613, 657, 701, 745, 789, 833, 877, 921, 965, 1009, 1053, 1097, 1141, 1185, 1229]) == 30\n    assert candidate(candidates = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990, 9999989, 9999988, 9999987, 9999986, 9999985, 9999984, 9999983, 9999982, 9999981]) == 20\n", "comparison": "exact"}, "public_tests": ["[16,17,71,62,12,24,14]", "[8,8]"], "hints": ["For the bitwise AND to be greater than zero, at least one bit should be 1 for every number in the combination.", "The candidates are 24 bits long, so for every bit position, we can calculate the size of the largest combination such that the bitwise AND will have a 1 at that bit position."], "metadata": {"canonical_parameter_names": ["candidates"], "leetcode_dataset_entry_point": "Solution().largestCombination", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:14+00:00", "tests_total": 92, "tests_dropped": 29, "flags": [], "topic_tags": ["array", "hash-table", "bit-manipulation", "counting"]}, "language": "python", "interface": {"raw_signature": "def largestCombination(self, candidates: list[int]) -> int:", "container": "Solution", "callable": "largestCombination", "parameters": [{"name": "candidates", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2278, "task_id": "percentage-of-letter-in-string", "difficulty": "Easy", "problem_description": "Given a string s and a character letter, return the percentage of characters in s that equal letter rounded down to the nearest whole percent.\n\nExample 1:\n\nInput: s = \"foobar\", letter = \"o\"\nOutput: 33\nExplanation:\nThe percentage of characters in s that equal the letter 'o' is 2 / 6 * 100% = 33% when rounded down, so we return 33.\n\nExample 2:\n\nInput: s = \"jjjj\", letter = \"k\"\nOutput: 0\nExplanation:\nThe percentage of characters in s that equal the letter 'k' is 0%, so we return 0.\n\nConstraints:\n\n- 1 <= s.length <= 100\n- s consists of lowercase English letters.\n- letter is a lowercase English letter.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"jjjj\",letter = \"k\") == 0\n    assert candidate(s = \"foobar\",letter = \"o\") == 33\n    assert candidate(s = \"mississippi\",letter = \"i\") == 36\n    assert candidate(s = \"python\",letter = \"y\") == 16\n    assert candidate(s = \"abcabcabc\",letter = \"a\") == 33\n    assert candidate(s = \"hello\",letter = \"l\") == 40\n    assert candidate(s = \"world\",letter = \"d\") == 20\n    assert candidate(s = \"zzzz\",letter = \"z\") == 100\n    assert candidate(s = \"b\",letter = \"a\") == 0\n    assert candidate(s = \"solution\",letter = \"o\") == 25\n    assert candidate(s = \"aaaaabbbbb\",letter = \"b\") == 50\n    assert candidate(s = \"a\",letter = \"a\") == 100\n    assert candidate(s = \"abcdefg\",letter = \"h\") == 0\n    assert candidate(s = \"zzzzzz\",letter = \"z\") == 100\n    assert candidate(s = \"aabbcc\",letter = \"b\") == 33\n    assert candidate(s = \"aabbccddeeff\",letter = \"c\") == 16\n    assert candidate(s = \"abcdefg\",letter = \"a\") == 14\n    assert candidate(s = \"zzzzzzzzz\",letter = \"z\") == 100\n    assert candidate(s = \"abcdefg\",letter = \"x\") == 0\n    assert candidate(s = \"characterization\",letter = \"c\") == 12\n    assert candidate(s = \"examplewithrepeatedletterzzzz\",letter = \"z\") == 13\n    assert candidate(s = \"qwertypoiuytrewqasdfghjklzxcvbnmasdfghjklzxcvbnm\",letter = \"q\") == 4\n    assert candidate(s = \"oneletterone\",letter = \"n\") == 16\n    assert candidate(s = \"parameter\",letter = \"r\") == 22\n    assert candidate(s = \"alphabet\",letter = \"p\") == 12\n    assert candidate(s = \"determinethepercentage\",letter = \"e\") == 31\n    assert candidate(s = \"programming\",letter = \"m\") == 18\n    assert candidate(s = \"supercalifragilisticexpialidocious\",letter = \"i\") == 20\n    assert candidate(s = \"abracadabra\",letter = \"a\") == 45\n    assert candidate(s = \"development\",letter = \"e\") == 27\n    assert candidate(s = \"abcdefghij\",letter = \"a\") == 10\n    assert candidate(s = \"abcdefghijk\",letter = \"a\") == 9\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\",letter = \"z\") == 100\n    assert candidate(s = \"abcdefghij\",letter = \"j\") == 10\n    assert candidate(s = \"visualization\",letter = \"i\") == 23\n    assert candidate(s = \"programming\",letter = \"g\") == 18\n    assert candidate(s = \"development\",letter = \"d\") == 9\n    assert candidate(s = \"charactercounting\",letter = \"c\") == 17\n    assert candidate(s = \"percentage\",letter = \"e\") == 30\n    assert candidate(s = \"classification\",letter = \"f\") == 7\n    assert candidate(s = \"environment\",letter = \"n\") == 27\n    assert candidate(s = \"xyz\",letter = \"z\") == 33\n    assert candidate(s = \"charactercountexample\",letter = \"e\") == 14\n    assert candidate(s = \"testtesttesttest\",letter = \"t\") == 50\n    assert candidate(s = \"computation\",letter = \"i\") == 9\n    assert candidate(s = \"performance\",letter = \"n\") == 9\n    assert candidate(s = \"understanding\",letter = \"d\") == 15\n    assert candidate(s = \"consistencyiskey\",letter = \"i\") == 12\n    assert candidate(s = \"xyxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyzxzyzyz\",letter = \"y\") == 33\n    assert candidate(s = \"algorithm\",letter = \"g\") == 11\n    assert candidate(s = \"representation\",letter = \"r\") == 14\n    assert candidate(s = \"communication\",letter = \"m\") == 15\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",letter = \"z\") == 3\n    assert candidate(s = \"mississippi\",letter = \"s\") == 36\n    assert candidate(s = \"thisisaverylongstringwithrandomcharacters\",letter = \"t\") == 9\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",letter = \"z\") == 100\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",letter = \"z\") == 100\n    assert candidate(s = \"variable\",letter = \"b\") == 12\n    assert candidate(s = \"pythonprogramming\",letter = \"p\") == 11\n    assert candidate(s = \"xyzzxyzz\",letter = \"z\") == 50\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",letter = \"a\") == 3\n    assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",letter = \"m\") == 3\n    assert candidate(s = \"xylophone\",letter = \"p\") == 11\n    assert candidate(s = \"characterization\",letter = \"t\") == 12\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",letter = \"z\") == 100\n    assert candidate(s = \"synchronous\",letter = \"s\") == 18\n    assert candidate(s = \"congratulations\",letter = \"t\") == 13\n    assert candidate(s = \"mississippi\",letter = \"x\") == 0\n    assert candidate(s = \"example\",letter = \"a\") == 14\n    assert candidate(s = \"development\",letter = \"l\") == 9\n    assert candidate(s = \"averylongstringwithvariouscharacters\",letter = \"a\") == 11\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",letter = \"z\") == 3\n    assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",letter = \"e\") == 8\n    assert candidate(s = \"uniquecharacters\",letter = \"u\") == 12\n    assert candidate(s = \"hellotheregeneralkenobi\",letter = \"l\") == 13\n    assert candidate(s = \"asynchronous\",letter = \"y\") == 8\n    assert candidate(s = \"helloalibabacloud\",letter = \"a\") == 17\n    assert candidate(s = \"mathematics\",letter = \"a\") == 18\n    assert candidate(s = \"function\",letter = \"u\") == 12\n    assert candidate(s = \"expression\",letter = \"s\") == 20\n    assert candidate(s = \"thisisaverylongstringthatshouldtestthemaximumlengthoftheinputwhichisonehundredcharacters\",letter = \"s\") == 7\n    assert candidate(s = \"lkjashdflkjhaskldjfhlasjdhflkajshdfjklsahjfdlkjahs\",letter = \"l\") == 14\n    assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxy\",letter = \"x\") == 50\n    assert candidate(s = \"programminglanguage\",letter = \"g\") == 21\n    assert candidate(s = \"abcdefghij\",letter = \"m\") == 0\n    assert candidate(s = \"percentageletter\",letter = \"t\") == 18\n    assert candidate(s = \"encyclopedia\",letter = \"o\") == 8\n    assert candidate(s = \"thisisaverylongstringindeedtoseeifitworks\",letter = \"s\") == 12\n    assert candidate(s = \"alphabet\",letter = \"z\") == 0\n    assert candidate(s = \"programminglanguage\",letter = \"a\") == 15\n    assert candidate(s = \"statistics\",letter = \"s\") == 30\n    assert candidate(s = \"xylophone\",letter = \"x\") == 11\n    assert candidate(s = \"encyclopedia\",letter = \"e\") == 16\n    assert candidate(s = \"nolettersmatch\",letter = \"z\") == 0\n    assert candidate(s = \"elephant\",letter = \"l\") == 12\n    assert candidate(s = \"character\",letter = \"c\") == 22\n    assert candidate(s = \"banana\",letter = \"a\") == 50\n    assert candidate(s = \"congratulations\",letter = \"o\") == 13\n    assert candidate(s = \"longstringwithvariouscharacters\",letter = \"v\") == 3\n    assert candidate(s = \"algorithm\",letter = \"l\") == 11\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",letter = \"b\") == 33\n    assert candidate(s = \"alabama\",letter = \"b\") == 14\n    assert candidate(s = \"zzzzzzzzzz\",letter = \"z\") == 100\n    assert candidate(s = \"sequence\",letter = \"q\") == 12\n    assert candidate(s = \"banana\",letter = \"n\") == 33\n", "comparison": "exact"}, "public_tests": ["\"foobar\"\n\"o\"", "\"jjjj\"\n\"k\""], "hints": ["Can we count the number of occurrences of letter in s?", "Recall that the percentage is calculated as (occurrences / total) * 100."], "metadata": {"canonical_parameter_names": ["s", "letter"], "leetcode_dataset_entry_point": "Solution().percentageLetter", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:19+00:00", "tests_total": 107, "tests_dropped": 2, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def percentageLetter(self, s: str, letter: str) -> int:", "container": "Solution", "callable": "percentageLetter", "parameters": [{"name": "s", "type": "str"}, {"name": "letter", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2279, "task_id": "maximum-bags-with-full-capacity-of-rocks", "difficulty": "Medium", "problem_description": "You have n bags numbered from 0 to n - 1. You are given two 0-indexed integer arrays capacity and rocks. The i^th bag can hold a maximum of capacity[i] rocks and currently contains rocks[i] rocks. You are also given an integer additionalRocks, the number of additional rocks you can place in any of the bags.\n\nReturn the maximum number of bags that could have full capacity after placing the additional rocks in some bags.\n\nExample 1:\n\nInput: capacity = [2,3,4,5], rocks = [1,2,4,4], additionalRocks = 2\nOutput: 3\nExplanation:\nPlace 1 rock in bag 0 and 1 rock in bag 1.\nThe number of rocks in each bag are now [2,3,4,4].\nBags 0, 1, and 2 have full capacity.\nThere are 3 bags at full capacity, so we return 3.\nIt can be shown that it is not possible to have more than 3 bags at full capacity.\nNote that there may be other ways of placing the rocks that result in an answer of 3.\n\nExample 2:\n\nInput: capacity = [10,2,2], rocks = [2,2,0], additionalRocks = 100\nOutput: 3\nExplanation:\nPlace 8 rocks in bag 0 and 2 rocks in bag 2.\nThe number of rocks in each bag are now [10,2,2].\nBags 0, 1, and 2 have full capacity.\nThere are 3 bags at full capacity, so we return 3.\nIt can be shown that it is not possible to have more than 3 bags at full capacity.\nNote that we did not use all of the additional rocks.\n\nConstraints:\n\n- n == capacity.length == rocks.length\n- 1 <= n <= 5 * 10^4\n- 1 <= capacity[i] <= 10^9\n- 0 <= rocks[i] <= capacity[i]\n- 1 <= additionalRocks <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(capacity = [2, 3, 4, 5],rocks = [1, 2, 4, 4],additionalRocks = 2) == 3\n    assert candidate(capacity = [1, 2, 3],rocks = [0, 0, 0],additionalRocks = 5) == 2\n    assert candidate(capacity = [3, 2, 1],rocks = [0, 0, 0],additionalRocks = 5) == 2\n    assert candidate(capacity = [1, 1, 1],rocks = [0, 0, 0],additionalRocks = 3) == 3\n    assert candidate(capacity = [3, 9, 8],rocks = [0, 2, 5],additionalRocks = 6) == 2\n    assert candidate(capacity = [5, 5, 5, 5],rocks = [0, 0, 0, 0],additionalRocks = 10) == 2\n    assert candidate(capacity = [1, 1, 1, 1],rocks = [1, 1, 1, 1],additionalRocks = 1) == 4\n    assert candidate(capacity = [3, 3, 3],rocks = [3, 0, 0],additionalRocks = 3) == 2\n    assert candidate(capacity = [10, 2, 2],rocks = [2, 2, 0],additionalRocks = 100) == 3\n    assert candidate(capacity = [5, 5, 5],rocks = [0, 0, 0],additionalRocks = 10) == 2\n    assert candidate(capacity = [1, 1, 1, 1],rocks = [1, 1, 1, 1],additionalRocks = 4) == 4\n    assert candidate(capacity = [5, 5, 5],rocks = [0, 0, 0],additionalRocks = 15) == 3\n    assert candidate(capacity = [3, 3, 3],rocks = [1, 2, 3],additionalRocks = 2) == 2\n    assert candidate(capacity = [1, 3, 5, 7, 9],rocks = [0, 1, 2, 3, 4],additionalRocks = 10) == 4\n    assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [0, 0, 0, 0, 0],additionalRocks = 1500) == 5\n    assert candidate(capacity = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 2500) == 9\n    assert candidate(capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 5) == 5\n    assert candidate(capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 5) == 5\n    assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [0, 0, 0, 0, 0],additionalRocks = 45) == 4\n    assert candidate(capacity = [5, 8, 10, 15, 20],rocks = [0, 4, 7, 10, 15],additionalRocks = 20) == 4\n    assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 55) == 10\n    assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [50, 150, 250, 350, 450],additionalRocks = 500) == 5\n    assert candidate(capacity = [1, 2, 3, 4, 5, 6],rocks = [0, 0, 0, 0, 0, 0],additionalRocks = 20) == 5\n    assert candidate(capacity = [500000000, 500000000, 500000000],rocks = [0, 0, 0],additionalRocks = 1000000000) == 2\n    assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [10, 20, 30, 40, 0],additionalRocks = 50) == 5\n    assert candidate(capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],rocks = [0, 1, 2, 3, 4, 0, 1, 2, 3, 4],additionalRocks = 15) == 6\n    assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [1, 2, 3, 4, 5],additionalRocks = 90) == 4\n    assert candidate(capacity = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],rocks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],additionalRocks = 5) == 5\n    assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [0, 0, 0, 0, 0],additionalRocks = 30) == 3\n    assert candidate(capacity = [5, 5, 5, 5, 5],rocks = [1, 2, 3, 4, 5],additionalRocks = 10) == 5\n    assert candidate(capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 5) == 5\n    assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [90, 180, 270, 360, 450],additionalRocks = 100) == 4\n    assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [5, 5, 5, 5, 5],additionalRocks = 25) == 5\n    assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],additionalRocks = 10) == 10\n    assert candidate(capacity = [2, 4, 6, 8, 10],rocks = [0, 1, 2, 3, 4],additionalRocks = 10) == 3\n    assert candidate(capacity = [50, 50, 50, 50, 50],rocks = [0, 0, 0, 0, 0],additionalRocks = 100) == 2\n    assert candidate(capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 10) == 10\n    assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [0, 0, 0, 0, 0],additionalRocks = 150) == 5\n    assert candidate(capacity = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 10) == 4\n    assert candidate(capacity = [999999999, 1],rocks = [0, 0],additionalRocks = 1000000000) == 2\n    assert candidate(capacity = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 550) == 10\n    assert candidate(capacity = [100, 100, 100, 100],rocks = [100, 100, 100, 100],additionalRocks = 100) == 4\n    assert candidate(capacity = [2, 4, 6, 8, 10],rocks = [1, 1, 1, 1, 1],additionalRocks = 15) == 3\n    assert candidate(capacity = [50, 50, 50, 50, 50],rocks = [10, 20, 30, 40, 50],additionalRocks = 100) == 5\n    assert candidate(capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 10) == 10\n    assert candidate(capacity = [5, 15, 25, 35, 45],rocks = [2, 8, 14, 20, 26],additionalRocks = 120) == 5\n    assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [0, 100, 200, 300, 400],additionalRocks = 500) == 5\n    assert candidate(capacity = [5, 10, 15, 20, 25, 30, 35],rocks = [0, 0, 0, 0, 0, 0, 0],additionalRocks = 105) == 6\n    assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],additionalRocks = 45) == 10\n    assert candidate(capacity = [1, 3, 5, 7, 9],rocks = [0, 0, 0, 0, 0],additionalRocks = 25) == 5\n    assert candidate(capacity = [1, 2, 4, 8, 16, 32, 64, 128],rocks = [0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 255) == 8\n    assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [0, 0, 0, 0, 0],additionalRocks = 100) == 4\n    assert candidate(capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],rocks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],additionalRocks = 1) == 10\n    assert candidate(capacity = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25],rocks = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20],additionalRocks = 50) == 10\n    assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],additionalRocks = 15) == 10\n    assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [50, 100, 150, 200, 250],additionalRocks = 500) == 4\n    assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [5, 5, 5, 5, 5],additionalRocks = 15) == 3\n    assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [50, 100, 150, 200, 250],additionalRocks = 1000) == 5\n    assert candidate(capacity = [1, 2, 4, 8, 16, 32],rocks = [0, 1, 3, 7, 15, 31],additionalRocks = 63) == 6\n    assert candidate(capacity = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 50) == 5\n    assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [9, 8, 7, 6, 5],additionalRocks = 5) == 2\n    assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [0, 2, 4, 6, 8],additionalRocks = 15) == 3\n    assert candidate(capacity = [1000, 2000, 3000, 4000, 5000],rocks = [500, 1000, 1500, 2000, 2500],additionalRocks = 5000) == 4\n    assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [50, 100, 150, 200, 250],additionalRocks = 100) == 1\n    assert candidate(capacity = [100, 200, 300],rocks = [50, 100, 150],additionalRocks = 200) == 2\n    assert candidate(capacity = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],rocks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],additionalRocks = 100) == 19\n    assert candidate(capacity = [3, 6, 9, 12, 15],rocks = [0, 3, 6, 9, 12],additionalRocks = 20) == 5\n    assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [1, 2, 3, 4, 5],additionalRocks = 80) == 3\n    assert candidate(capacity = [10, 15, 20, 25, 30],rocks = [0, 5, 10, 20, 25],additionalRocks = 50) == 5\n    assert candidate(capacity = [1000000, 2000000, 3000000, 4000000, 5000000],rocks = [100000, 200000, 300000, 400000, 500000],additionalRocks = 5000000) == 2\n    assert candidate(capacity = [100, 100, 100, 100],rocks = [99, 98, 97, 96],additionalRocks = 4) == 2\n    assert candidate(capacity = [1, 2, 3, 4, 5],rocks = [0, 1, 2, 3, 4],additionalRocks = 10) == 5\n    assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [10, 20, 30, 40, 50],additionalRocks = 100) == 5\n    assert candidate(capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],rocks = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],additionalRocks = 5) == 5\n    assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [90, 190, 290, 390, 490],additionalRocks = 50) == 5\n    assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [0, 0, 0, 0, 0],additionalRocks = 25) == 2\n    assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 5) == 2\n    assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 55) == 10\n    assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [9, 19, 29, 39, 49],additionalRocks = 5) == 5\n    assert candidate(capacity = [7, 7, 7, 7, 7, 7, 7],rocks = [1, 2, 3, 4, 5, 6, 0],additionalRocks = 14) == 4\n    assert candidate(capacity = [5, 5, 5, 5, 5],rocks = [0, 1, 2, 3, 4],additionalRocks = 10) == 4\n    assert candidate(capacity = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 55) == 10\n    assert candidate(capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],rocks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],additionalRocks = 5) == 1\n    assert candidate(capacity = [10, 10, 10, 10, 10],rocks = [1, 2, 3, 4, 5],additionalRocks = 15) == 2\n    assert candidate(capacity = [100, 200, 300, 400, 500],rocks = [10, 20, 30, 40, 50],additionalRocks = 1000) == 4\n    assert candidate(capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],rocks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],additionalRocks = 55) == 10\n    assert candidate(capacity = [10, 20, 30, 40, 50],rocks = [0, 5, 10, 15, 20],additionalRocks = 100) == 5\n    assert candidate(capacity = [100000000, 100000000, 100000000],rocks = [50000000, 50000000, 50000000],additionalRocks = 100000000) == 2\n    assert candidate(capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],rocks = [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4],additionalRocks = 25) == 12\n    assert candidate(capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],rocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],additionalRocks = 10) == 10\n", "comparison": "exact"}, "public_tests": ["[2,3,4,5]\n[1,2,4,4]\n2", "[10,2,2]\n[2,2,0]\n100"], "hints": ["Which bag should you fill completely first?", "Can you think of a greedy solution?"], "metadata": {"canonical_parameter_names": ["capacity", "rocks", "additionalRocks"], "leetcode_dataset_entry_point": "Solution().maximumBags", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:21+00:00", "tests_total": 103, "tests_dropped": 13, "flags": [], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maximumBags(self, capacity: list[int], rocks: list[int], additionalRocks: int) -> int:", "container": "Solution", "callable": "maximumBags", "parameters": [{"name": "capacity", "type": "list[int]"}, {"name": "rocks", "type": "list[int]"}, {"name": "additionalRocks", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2280, "task_id": "minimum-lines-to-represent-a-line-chart", "difficulty": "Medium", "problem_description": "You are given a 2D integer array stockPrices where stockPrices[i] = [day_i, price_i] indicates the price of the stock on day day_i is price_i. A line chart is created from the array by plotting the points on an XY plane with the X-axis representing the day and the Y-axis representing the price and connecting adjacent points. One such example is shown below:\n\nReturn the minimum number of lines needed to represent the line chart.\n\nExample 1:\n\nInput: stockPrices = [[1,7],[2,6],[3,5],[4,4],[5,4],[6,3],[7,2],[8,1]]\nOutput: 3\nExplanation:\nThe diagram above represents the input, with the X-axis representing the day and Y-axis representing the price.\nThe following 3 lines can be drawn to represent the line chart:\n- Line 1 (in red) from (1,7) to (4,4) passing through (1,7), (2,6), (3,5), and (4,4).\n- Line 2 (in blue) from (4,4) to (5,4).\n- Line 3 (in green) from (5,4) to (8,1) passing through (5,4), (6,3), (7,2), and (8,1).\nIt can be shown that it is not possible to represent the line chart using less than 3 lines.\n\nExample 2:\n\nInput: stockPrices = [[3,4],[1,2],[7,8],[2,3]]\nOutput: 1\nExplanation:\nAs shown in the diagram above, the line chart can be represented with a single line.\n\nConstraints:\n\n- 1 <= stockPrices.length <= 10^5\n- stockPrices[i].length == 2\n- 1 <= day_i, price_i <= 10^9\n- All day_i are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(stockPrices = [[3, 4], [1, 2], [7, 8], [2, 3]]) == 1\n    assert candidate(stockPrices = [[1, 7], [2, 6], [3, 5], [4, 4], [5, 4], [6, 3], [7, 2], [8, 1]]) == 3\n    assert candidate(stockPrices = [[1, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]]) == 2\n    assert candidate(stockPrices = [[1, 1], [2, 10], [3, 3], [4, 14], [5, 5], [6, 18], [7, 7], [8, 22], [9, 9], [10, 26]]) == 9\n    assert candidate(stockPrices = [[1, 1], [10, 10], [100, 100], [1000, 1000], [10000, 10000], [100000, 100000], [1000000, 1000000], [10000000, 10000000], [100000000, 100000000]]) == 1\n    assert candidate(stockPrices = [[1, 2], [2, 4], [3, 6], [5, 8], [10, 14], [20, 22], [30, 30], [40, 40]]) == 5\n    assert candidate(stockPrices = [[1, 1], [2, 3], [4, 5], [8, 7], [16, 9], [32, 11], [64, 13], [128, 15]]) == 7\n    assert candidate(stockPrices = [[1, 1], [2, 3], [3, 6], [4, 10], [5, 15], [6, 21], [7, 28], [8, 36], [9, 45], [10, 55]]) == 9\n    assert candidate(stockPrices = [[1, 2], [2, 3], [4, 5], [5, 7], [6, 11], [7, 13], [8, 17], [9, 19]]) == 6\n    assert candidate(stockPrices = [[1, 2], [2, 2], [3, 3], [4, 3], [5, 4], [6, 5], [7, 6], [8, 6], [9, 7]]) == 6\n    assert candidate(stockPrices = [[1, 1], [3, 3], [6, 6], [10, 10], [15, 15], [21, 21], [28, 28]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 3], [4, 5], [8, 9], [16, 17], [32, 33], [64, 65], [128, 129]]) == 2\n    assert candidate(stockPrices = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 11], [6, 13], [7, 17]]) == 4\n    assert candidate(stockPrices = [[1, 1], [3, 5], [6, 10], [10, 17], [15, 26], [21, 37], [28, 50], [36, 65], [45, 82]]) == 8\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [5, 5], [6, 6], [8, 8], [9, 9], [11, 11], [12, 12]]) == 1\n    assert candidate(stockPrices = [[1, 5], [2, 5], [3, 5], [4, 6], [5, 6], [6, 6], [7, 7], [8, 7], [9, 7], [10, 8]]) == 6\n    assert candidate(stockPrices = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19], [21, 21], [23, 23]]) == 1\n    assert candidate(stockPrices = [[1, 10], [2, 20], [3, 30], [4, 25], [5, 20], [6, 15], [7, 10]]) == 2\n    assert candidate(stockPrices = [[1, 1], [2, 5], [3, 10], [4, 17], [5, 26], [6, 37], [7, 50], [8, 65], [9, 82], [10, 101]]) == 9\n    assert candidate(stockPrices = [[1, 2], [2, 3], [3, 2], [4, 3], [5, 2], [6, 3], [7, 2], [8, 3]]) == 7\n    assert candidate(stockPrices = [[1, 5], [2, 7], [3, 9], [4, 11], [5, 13], [6, 15], [7, 17], [8, 19], [9, 21], [10, 23]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64]]) == 7\n    assert candidate(stockPrices = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8], [17, 9], [19, 10]]) == 1\n    assert candidate(stockPrices = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 2], [7, 3], [8, 4], [9, 5], [10, 6]]) == 2\n    assert candidate(stockPrices = [[1, 2], [2, 3], [4, 5], [7, 8], [11, 12], [16, 14], [22, 15], [29, 16], [37, 17]]) == 5\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 5], [5, 8], [6, 12], [7, 17], [8, 23], [9, 30], [10, 38]]) == 8\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 4], [4, 6], [5, 8], [6, 10], [7, 12], [8, 14], [9, 16], [10, 18]]) == 2\n    assert candidate(stockPrices = [[1, 1], [2, 3], [3, 6], [4, 10], [5, 15], [6, 21], [7, 28]]) == 6\n    assert candidate(stockPrices = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 10], [3, 20], [4, 30], [5, 40], [6, 50], [7, 60], [8, 70], [9, 80], [10, 90]]) == 2\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 1\n    assert candidate(stockPrices = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 2\n    assert candidate(stockPrices = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19], [11, 20], [12, 21], [13, 22], [14, 23], [15, 24]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 3], [4, 7], [7, 15], [11, 26], [16, 40], [22, 58], [29, 79]]) == 5\n    assert candidate(stockPrices = [[1, 1], [2, 5], [4, 9], [8, 13], [16, 17], [32, 21], [64, 25], [128, 29]]) == 7\n    assert candidate(stockPrices = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7]]) == 6\n    assert candidate(stockPrices = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 5], [3, 14], [4, 30], [5, 50], [6, 75], [7, 105], [8, 140], [9, 182], [10, 230]]) == 9\n    assert candidate(stockPrices = [[1, 2], [2, 1], [3, 2], [4, 1], [5, 2], [6, 1], [7, 2], [8, 1], [9, 2], [10, 1]]) == 9\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [5, 5], [8, 8], [13, 13], [21, 21], [34, 34], [55, 55]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81], [10, 100]]) == 9\n    assert candidate(stockPrices = [[1, 1], [2, 1], [3, 1], [4, 2], [5, 3], [6, 4], [7, 4], [8, 4], [9, 5], [10, 6]]) == 4\n    assert candidate(stockPrices = [[1, 5], [2, 10], [3, 15], [5, 20], [10, 25], [20, 30], [40, 35], [80, 40]]) == 6\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 2], [4, 3], [5, 3], [6, 4], [7, 4], [8, 5]]) == 7\n    assert candidate(stockPrices = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 1\n    assert candidate(stockPrices = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11], [6, 13], [7, 15], [8, 17], [9, 19], [10, 21], [11, 23], [12, 25]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [10, 11]]) == 9\n    assert candidate(stockPrices = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 2], [7, 3], [8, 2], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]]) == 4\n    assert candidate(stockPrices = [[1, 1], [2, 4], [4, 9], [7, 16], [11, 25], [16, 36], [22, 49], [29, 64]]) == 7\n    assert candidate(stockPrices = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700]]) == 1\n    assert candidate(stockPrices = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 1\n    assert candidate(stockPrices = [[1, 1], [3, 3], [6, 6], [9, 9], [12, 12], [15, 15], [18, 18], [21, 21]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == 1\n    assert candidate(stockPrices = [[1, 1], [3, 2], [6, 3], [10, 4], [15, 5], [21, 6], [28, 7], [36, 8], [45, 9]]) == 8\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81]]) == 8\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 3], [5, 3], [6, 3], [7, 4], [8, 5], [9, 6], [10, 7]]) == 3\n    assert candidate(stockPrices = [[1, 2], [2, 3], [3, 5], [5, 8], [8, 13], [13, 21], [21, 34], [34, 55], [55, 89], [89, 144]]) == 9\n    assert candidate(stockPrices = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19], [11, 21], [12, 23], [13, 25]]) == 1\n    assert candidate(stockPrices = [[1, 2], [2, 2], [3, 2], [4, 3], [5, 4], [6, 5], [7, 5], [8, 5], [9, 6], [10, 7]]) == 4\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 1\n    assert candidate(stockPrices = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]]) == 1\n    assert candidate(stockPrices = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 1], [4, 2], [5, 1], [6, 2], [7, 1], [8, 2], [9, 1], [10, 2]]) == 9\n    assert candidate(stockPrices = [[1, 1], [3, 5], [6, 10], [10, 15], [15, 20], [21, 25], [28, 30]]) == 6\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 5], [5, 7], [6, 9], [7, 11]]) == 2\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 4], [4, 8], [5, 16], [6, 32], [7, 64], [8, 128], [9, 256], [10, 512]]) == 9\n    assert candidate(stockPrices = [[1, 1], [2, 3], [4, 9], [8, 27], [16, 81], [32, 243], [64, 729], [128, 2187]]) == 7\n    assert candidate(stockPrices = [[1, 1], [2, 1], [3, 2], [4, 2], [5, 3], [6, 3], [7, 4], [8, 4], [9, 5], [10, 5]]) == 9\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 5], [5, 7], [6, 10], [7, 15], [8, 21], [9, 28], [10, 36]]) == 7\n    assert candidate(stockPrices = [[10, 20], [20, 10], [30, 30], [40, 40], [50, 50], [60, 60]]) == 3\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 4], [5, 8], [9, 16], [17, 32], [33, 64], [65, 128], [129, 256]]) == 2\n    assert candidate(stockPrices = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 8], [7, 6], [8, 4], [9, 2]]) == 2\n    assert candidate(stockPrices = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3]]) == 1\n    assert candidate(stockPrices = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 1\n    assert candidate(stockPrices = [[1, 2], [2, 2], [3, 3], [4, 3], [5, 4], [6, 4], [7, 5], [8, 5]]) == 7\n    assert candidate(stockPrices = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 3], [6, 4], [7, 5], [8, 6], [9, 7], [10, 8]]) == 2\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 11]]) == 2\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 2], [4, 2], [5, 3], [6, 3], [7, 4], [8, 4], [9, 5]]) == 7\n    assert candidate(stockPrices = [[1, 1], [2, 1], [3, 3], [4, 4], [5, 5], [6, 6], [7, 8], [8, 8], [9, 9], [10, 10]]) == 6\n    assert candidate(stockPrices = [[1, 1], [2, 2], [4, 4], [5, 5], [7, 7], [8, 8], [10, 10], [11, 11]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [4, 5], [5, 8], [6, 13], [7, 21], [8, 31], [9, 43], [10, 57]]) == 8\n    assert candidate(stockPrices = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 2]]) == 2\n    assert candidate(stockPrices = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1]]) == 1\n    assert candidate(stockPrices = [[1, 10], [2, 15], [3, 25], [4, 40], [5, 60], [6, 85], [7, 115], [8, 150], [9, 190], [10, 235]]) == 9\n    assert candidate(stockPrices = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 6], [6, 6], [7, 6], [8, 6], [9, 7], [10, 7]]) == 5\n    assert candidate(stockPrices = [[1, 1], [2, 5], [3, 9], [4, 14], [5, 19], [6, 25], [7, 31], [8, 38], [9, 45], [10, 53]]) == 5\n    assert candidate(stockPrices = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 5], [6, 3], [7, 1], [8, 3], [9, 5], [10, 7]]) == 3\n    assert candidate(stockPrices = [[1, 1], [3, 4], [6, 7], [8, 10], [9, 11], [11, 13], [13, 15], [14, 16]]) == 4\n    assert candidate(stockPrices = [[5, 3], [10, 6], [15, 9], [20, 12], [25, 15], [30, 18], [35, 21], [40, 24]]) == 1\n    assert candidate(stockPrices = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5], [11, 5], [12, 5], [13, 5], [14, 5], [15, 5], [16, 5], [17, 5], [18, 5], [19, 5], [20, 5]]) == 1\n    assert candidate(stockPrices = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996], [6, 999999995], [7, 999999994], [8, 999999993], [9, 999999992], [10, 999999991]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 2], [6, 2], [7, 2], [8, 2], [9, 3], [10, 3]]) == 5\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 3], [5, 5], [6, 6], [8, 8], [9, 9], [10, 10]]) == 1\n    assert candidate(stockPrices = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17]]) == 1\n    assert candidate(stockPrices = [[1, 1], [2, 2], [3, 5], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]]) == 4\n    assert candidate(stockPrices = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 40], [7, 30], [8, 20], [9, 10]]) == 2\n", "comparison": "exact"}, "public_tests": ["[[1,7],[2,6],[3,5],[4,4],[5,4],[6,3],[7,2],[8,1]]", "[[3,4],[1,2],[7,8],[2,3]]"], "hints": ["When will three adjacent points lie on the same line? How can we generalize this for all points?", "Will calculating the slope of lines connecting adjacent points help us find the answer?"], "metadata": {"canonical_parameter_names": ["stockPrices"], "leetcode_dataset_entry_point": "Solution().minimumLines", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:23+00:00", "tests_total": 107, "tests_dropped": 7, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "math", "geometry", "sorting", "number-theory"]}, "language": "python", "interface": {"raw_signature": "def minimumLines(self, stockPrices: list[list[int]]) -> int:", "container": "Solution", "callable": "minimumLines", "parameters": [{"name": "stockPrices", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2281, "task_id": "sum-of-total-strength-of-wizards", "difficulty": "Hard", "problem_description": "As the ruler of a kingdom, you have an army of wizards at your command.\n\nYou are given a 0-indexed integer array strength, where strength[i] denotes the strength of the i^th wizard. For a contiguous group of wizards (i.e. the wizards' strengths form a subarray of strength), the total strength is defined as the product of the following two values:\n\n- The strength of the weakest wizard in the group.\n- The total of all the individual strengths of the wizards in the group.\n\nReturn the sum of the total strengths of all contiguous groups of wizards. Since the answer may be very large, return it modulo 10^9 + 7.\n\nA subarray is a contiguous non-empty sequence of elements within an array.\n\nExample 1:\n\nInput: strength = [1,3,1,2]\nOutput: 44\nExplanation: The following are all the contiguous groups of wizards:\n- [1] from [1,3,1,2] has a total strength of min([1]) * sum([1]) = 1 * 1 = 1\n- [3] from [1,3,1,2] has a total strength of min([3]) * sum([3]) = 3 * 3 = 9\n- [1] from [1,3,1,2] has a total strength of min([1]) * sum([1]) = 1 * 1 = 1\n- [2] from [1,3,1,2] has a total strength of min([2]) * sum([2]) = 2 * 2 = 4\n- [1,3] from [1,3,1,2] has a total strength of min([1,3]) * sum([1,3]) = 1 * 4 = 4\n- [3,1] from [1,3,1,2] has a total strength of min([3,1]) * sum([3,1]) = 1 * 4 = 4\n- [1,2] from [1,3,1,2] has a total strength of min([1,2]) * sum([1,2]) = 1 * 3 = 3\n- [1,3,1] from [1,3,1,2] has a total strength of min([1,3,1]) * sum([1,3,1]) = 1 * 5 = 5\n- [3,1,2] from [1,3,1,2] has a total strength of min([3,1,2]) * sum([3,1,2]) = 1 * 6 = 6\n- [1,3,1,2] from [1,3,1,2] has a total strength of min([1,3,1,2]) * sum([1,3,1,2]) = 1 * 7 = 7\nThe sum of all the total strengths is 1 + 9 + 1 + 4 + 4 + 4 + 3 + 5 + 6 + 7 = 44.\n\nExample 2:\n\nInput: strength = [5,4,6]\nOutput: 213\nExplanation: The following are all the contiguous groups of wizards:\n- [5] from [5,4,6] has a total strength of min([5]) * sum([5]) = 5 * 5 = 25\n- [4] from [5,4,6] has a total strength of min([4]) * sum([4]) = 4 * 4 = 16\n- [6] from [5,4,6] has a total strength of min([6]) * sum([6]) = 6 * 6 = 36\n- [5,4] from [5,4,6] has a total strength of min([5,4]) * sum([5,4]) = 4 * 9 = 36\n- [4,6] from [5,4,6] has a total strength of min([4,6]) * sum([4,6]) = 4 * 10 = 40\n- [5,4,6] from [5,4,6] has a total strength of min([5,4,6]) * sum([5,4,6]) = 4 * 15 = 60\nThe sum of all the total strengths is 25 + 16 + 36 + 36 + 40 + 60 = 213.\n\nConstraints:\n\n- 1 <= strength.length <= 10^5\n- 1 <= strength[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(strength = [1]) == 1\n    assert candidate(strength = [1, 1, 1, 1, 1]) == 35\n    assert candidate(strength = [10, 9, 8, 7, 6]) == 1988\n    assert candidate(strength = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4576\n    assert candidate(strength = [5]) == 25\n    assert candidate(strength = [1000000000, 1000000000, 1000000000]) == 490\n    assert candidate(strength = [5, 3, 1, 2, 4]) == 156\n    assert candidate(strength = [1, 2, 3, 4, 5]) == 238\n    assert candidate(strength = [5, 6, 7, 8, 9, 10]) == 2688\n    assert candidate(strength = [5, 4, 6]) == 213\n    assert candidate(strength = [1, 10, 1, 10, 1, 10]) == 578\n    assert candidate(strength = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 731\n    assert candidate(strength = [10, 9, 8, 7, 6, 5]) == 2688\n    assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4576\n    assert candidate(strength = [1, 3, 1, 2]) == 44\n    assert candidate(strength = [1000000000, 1000000000]) == 196\n    assert candidate(strength = [1, 3, 5, 7, 9, 7, 5, 3, 1]) == 2577\n    assert candidate(strength = [100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100]) == 2600000\n    assert candidate(strength = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 21824\n    assert candidate(strength = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2330\n    assert candidate(strength = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 4144\n    assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 315315\n    assert candidate(strength = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 22000\n    assert candidate(strength = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 108290\n    assert candidate(strength = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 760\n    assert candidate(strength = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1540\n    assert candidate(strength = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 4820\n    assert candidate(strength = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 8712\n    assert candidate(strength = [1, 5, 2, 5, 3, 5, 4, 5, 5, 5]) == 2232\n    assert candidate(strength = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 13042\n    assert candidate(strength = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 457600\n    assert candidate(strength = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == 370373883\n    assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 109802\n    assert candidate(strength = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 98736\n    assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2871\n    assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2871\n    assert candidate(strength = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 1660\n    assert candidate(strength = [10, 20, 30, 40, 50]) == 23800\n    assert candidate(strength = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 38768\n    assert candidate(strength = [1000000000, 1000000000, 1000000000, 1000000000]) == 980\n    assert candidate(strength = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4576\n    assert candidate(strength = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == 370373883\n    assert candidate(strength = [5, 3, 8, 6, 2, 7, 4, 9, 1]) == 1914\n    assert candidate(strength = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 14312\n    assert candidate(strength = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 2684\n    assert candidate(strength = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 2439\n    assert candidate(strength = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]) == 4200\n    assert candidate(strength = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 109802\n    assert candidate(strength = [2, 1, 3, 4, 2, 1, 3, 4, 2, 1]) == 638\n    assert candidate(strength = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 165\n    assert candidate(strength = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 268328687\n    assert candidate(strength = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 457600\n    assert candidate(strength = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 13552\n    assert candidate(strength = [2, 1, 3, 4, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 4, 1, 2]) == 3672\n    assert candidate(strength = [3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 3193\n    assert candidate(strength = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == 1590\n    assert candidate(strength = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 2767600\n    assert candidate(strength = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == 619372\n    assert candidate(strength = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 30778\n    assert candidate(strength = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10]) == 3448\n    assert candidate(strength = [2, 1, 2, 1, 2, 1, 2, 1, 2]) == 260\n    assert candidate(strength = [35, 30, 25, 20, 15, 10, 5, 10, 15, 20, 25, 30, 35]) == 72275\n    assert candidate(strength = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 3178\n    assert candidate(strength = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 268328687\n    assert candidate(strength = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1715\n    assert candidate(strength = [1000000000, 1000000000, 1000000000, 1000000000]) == 980\n    assert candidate(strength = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 1414\n    assert candidate(strength = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 2767600\n    assert candidate(strength = [10, 15, 10, 20, 15, 25, 20, 30, 25, 35]) == 61475\n    assert candidate(strength = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400]) == 301120400\n    assert candidate(strength = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 457600\n    assert candidate(strength = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 1013\n    assert candidate(strength = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1540\n    assert candidate(strength = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 3150\n    assert candidate(strength = [10, 20, 30, 20, 10, 10, 20, 30, 20, 10]) == 46200\n    assert candidate(strength = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2871\n    assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4576\n    assert candidate(strength = [3, 1, 2, 5, 4]) == 186\n    assert candidate(strength = [5, 1, 3, 2, 4, 6, 8, 7, 9]) == 2155\n    assert candidate(strength = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 220\n    assert candidate(strength = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 10780\n    assert candidate(strength = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2876356\n    assert candidate(strength = [1, 1000000000, 1, 1000000000, 1, 1000000000]) == 0\n    assert candidate(strength = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 3676\n    assert candidate(strength = [100, 1, 200, 2, 300, 3, 400, 4, 500]) == 596592\n    assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 109802\n    assert candidate(strength = [50, 20, 30, 10, 40, 60, 70, 5, 80, 90]) == 115850\n    assert candidate(strength = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 220\n    assert candidate(strength = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 30778\n    assert candidate(strength = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 28764\n    assert candidate(strength = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 926\n    assert candidate(strength = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 28764\n    assert candidate(strength = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 826\n    assert candidate(strength = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == 369\n    assert candidate(strength = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 340\n    assert candidate(strength = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 6, 7, 8, 9, 10]) == 3083588\n    assert candidate(strength = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2871\n    assert candidate(strength = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5500\n    assert candidate(strength = [1, 3, 2, 4, 1, 5, 2, 6, 1, 7, 2, 8, 1, 9, 2, 10]) == 3648\n    assert candidate(strength = [3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == 1864\n    assert candidate(strength = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 639\n    assert candidate(strength = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 165\n    assert candidate(strength = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1980\n", "comparison": "exact"}, "public_tests": ["[1,3,1,2]", "[5,4,6]"], "hints": ["Consider the contribution of each wizard to the answer.", "Can you efficiently calculate the total contribution to the answer for all subarrays that end at each index?", "Denote the total contribution of all subarrays ending at index i as solve[i]. Can you express solve[i] in terms of solve[m] for some m < i?"], "metadata": {"canonical_parameter_names": ["strength"], "leetcode_dataset_entry_point": "Solution().totalStrength", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:26+00:00", "tests_total": 104, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "stack", "monotonic-stack", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def totalStrength(self, strength: list[int]) -> int:", "container": "Solution", "callable": "totalStrength", "parameters": [{"name": "strength", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2283, "task_id": "check-if-number-has-equal-digit-count-and-digit-value", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string num of length n consisting of digits.\n\nReturn true if for every index i in the range 0 <= i < n, the digit i occurs num[i] times in num, otherwise return false.\n\nExample 1:\n\nInput: num = \"1210\"\nOutput: true\nExplanation:\nnum[0] = '1'. The digit 0 occurs once in num.\nnum[1] = '2'. The digit 1 occurs twice in num.\nnum[2] = '1'. The digit 2 occurs once in num.\nnum[3] = '0'. The digit 3 occurs zero times in num.\nThe condition holds true for every index in \"1210\", so return true.\n\nExample 2:\n\nInput: num = \"030\"\nOutput: false\nExplanation:\nnum[0] = '0'. The digit 0 should occur zero times, but actually occurs twice in num.\nnum[1] = '3'. The digit 1 should occur three times, but actually occurs zero times in num.\nnum[2] = '0'. The digit 2 occurs zero times in num.\nThe indices 0 and 1 both violate the condition, so return false.\n\nConstraints:\n\n- n == num.length\n- 1 <= n <= 10\n- num consists of digits.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num = \"1111\") == False\n    assert candidate(num = \"00000\") == False\n    assert candidate(num = \"10\") == False\n    assert candidate(num = \"1111111111\") == False\n    assert candidate(num = \"000\") == False\n    assert candidate(num = \"6200000000\") == False\n    assert candidate(num = \"0100100010\") == False\n    assert candidate(num = \"6210001000\") == True\n    assert candidate(num = \"030\") == False\n    assert candidate(num = \"9876543210\") == False\n    assert candidate(num = \"2020202020\") == False\n    assert candidate(num = \"0\") == False\n    assert candidate(num = \"5000000000\") == False\n    assert candidate(num = \"21200\") == True\n    assert candidate(num = \"0987654321\") == False\n    assert candidate(num = \"2020\") == True\n    assert candidate(num = \"11200\") == False\n    assert candidate(num = \"1010101010\") == False\n    assert candidate(num = \"1210\") == True\n    assert candidate(num = \"6543210\") == False\n    assert candidate(num = \"50000\") == False\n    assert candidate(num = \"5000001000\") == False\n    assert candidate(num = \"1234567890\") == False\n    assert candidate(num = \"1221111111\") == False\n    assert candidate(num = \"1001\") == False\n    assert candidate(num = \"0000\") == False\n    assert candidate(num = \"2120000000\") == False\n    assert candidate(num = \"4000400040\") == False\n    assert candidate(num = \"101010101\") == False\n    assert candidate(num = \"0000100000\") == False\n    assert candidate(num = \"1112212100\") == False\n    assert candidate(num = \"0000000000\") == False\n    assert candidate(num = \"0000000100\") == False\n    assert candidate(num = \"0101010101\") == False\n    assert candidate(num = \"9000000000\") == False\n    assert candidate(num = \"3110001000\") == False\n    assert candidate(num = \"0100101010\") == False\n    assert candidate(num = \"100010000\") == False\n    assert candidate(num = \"000020000\") == False\n    assert candidate(num = \"100201000\") == False\n    assert candidate(num = \"30003\") == False\n    assert candidate(num = \"1221\") == False\n    assert candidate(num = \"12101000\") == False\n    assert candidate(num = \"000010001\") == False\n    assert candidate(num = \"3000000000\") == False\n    assert candidate(num = \"0010000000\") == False\n    assert candidate(num = \"0000101000\") == False\n    assert candidate(num = \"3100000\") == False\n    assert candidate(num = \"3000000010\") == False\n    assert candidate(num = \"0100000001\") == False\n    assert candidate(num = \"121010000\") == False\n    assert candidate(num = \"0123400000\") == False\n    assert candidate(num = \"2010000000\") == False\n    assert candidate(num = \"0010000010\") == False\n    assert candidate(num = \"102020100\") == False\n    assert candidate(num = \"000300003\") == False\n    assert candidate(num = \"500000000\") == False\n    assert candidate(num = \"40000000\") == False\n    assert candidate(num = \"5000011000\") == False\n    assert candidate(num = \"1001001001\") == False\n    assert candidate(num = \"1221100000\") == False\n    assert candidate(num = \"1212121212\") == False\n    assert candidate(num = \"0001000100\") == False\n    assert candidate(num = \"0000000010\") == False\n    assert candidate(num = \"3000100002\") == False\n    assert candidate(num = \"100002000\") == False\n    assert candidate(num = \"200000010\") == False\n    assert candidate(num = \"0012002001\") == False\n    assert candidate(num = \"13010003\") == False\n    assert candidate(num = \"42101000\") == True\n    assert candidate(num = \"7000000000\") == False\n    assert candidate(num = \"6543210000\") == False\n    assert candidate(num = \"5000001400\") == False\n    assert candidate(num = \"210010010\") == False\n    assert candidate(num = \"012020200\") == False\n    assert candidate(num = \"0000000004\") == False\n    assert candidate(num = \"000030000\") == False\n    assert candidate(num = \"12101\") == False\n    assert candidate(num = \"4000010000\") == False\n    assert candidate(num = \"2220000000\") == False\n    assert candidate(num = \"1210101010\") == False\n    assert candidate(num = \"000000003\") == False\n    assert candidate(num = \"0210000110\") == False\n    assert candidate(num = \"1000100010\") == False\n    assert candidate(num = \"100000002\") == False\n    assert candidate(num = \"3000300000\") == False\n    assert candidate(num = \"400001000\") == False\n    assert candidate(num = \"0123456789\") == False\n    assert candidate(num = \"0000001001\") == False\n    assert candidate(num = \"2100100000\") == False\n    assert candidate(num = \"3110000\") == False\n    assert candidate(num = \"0000000020\") == False\n    assert candidate(num = \"200100100\") == False\n    assert candidate(num = \"1210100\") == False\n    assert candidate(num = \"1020304050\") == False\n    assert candidate(num = \"6000000000\") == False\n    assert candidate(num = \"001010101\") == False\n    assert candidate(num = \"0000000002\") == False\n    assert candidate(num = \"000001011\") == False\n    assert candidate(num = \"20200\") == False\n    assert candidate(num = \"1111111110\") == False\n    assert candidate(num = \"1300102000\") == False\n    assert candidate(num = \"2020200\") == False\n    assert candidate(num = \"41210000\") == False\n    assert candidate(num = \"0000000009\") == False\n    assert candidate(num = \"0020200\") == False\n    assert candidate(num = \"200001\") == False\n    assert candidate(num = \"100000101\") == False\n    assert candidate(num = \"010200200\") == False\n    assert candidate(num = \"1000000001\") == False\n    assert candidate(num = \"0123210\") == False\n    assert candidate(num = \"3000100000\") == False\n    assert candidate(num = \"200000000\") == False\n    assert candidate(num = \"021001001\") == False\n    assert candidate(num = \"30000003\") == False\n    assert candidate(num = \"300020000\") == False\n    assert candidate(num = \"0000000001\") == False\n    assert candidate(num = \"300000000\") == False\n    assert candidate(num = \"0000000110\") == False\n    assert candidate(num = \"5000000005\") == False\n    assert candidate(num = \"4000000000\") == False\n    assert candidate(num = \"2010011000\") == False\n    assert candidate(num = \"201010101\") == False\n    assert candidate(num = \"001100110\") == False\n    assert candidate(num = \"1000000010\") == False\n    assert candidate(num = \"0112233445\") == False\n    assert candidate(num = \"5000000100\") == False\n    assert candidate(num = \"0110001000\") == False\n    assert candidate(num = \"3110000000\") == False\n    assert candidate(num = \"100010001\") == False\n    assert candidate(num = \"0000010010\") == False\n    assert candidate(num = \"8000000000\") == False\n    assert candidate(num = \"00001111\") == False\n    assert candidate(num = \"1200100000\") == False\n    assert candidate(num = \"3330000000\") == False\n    assert candidate(num = \"011110000\") == False\n    assert candidate(num = \"2120001000\") == False\n", "comparison": "exact"}, "public_tests": ["\"1210\"", "\"030\""], "hints": ["Count the frequency of each digit in num."], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().digitCount", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:30+00:00", "tests_total": 150, "tests_dropped": 13, "flags": [], "topic_tags": ["hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def digitCount(self, num: str) -> bool:", "container": "Solution", "callable": "digitCount", "parameters": [{"name": "num", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2284, "task_id": "sender-with-largest-word-count", "difficulty": "Medium", "problem_description": "You have a chat log of n messages. You are given two string arrays messages and senders where messages[i] is a message sent by senders[i].\n\nA message is list of words that are separated by a single space with no leading or trailing spaces. The word count of a sender is the total number of words sent by the sender. Note that a sender may send more than one message.\n\nReturn the sender with the largest word count. If there is more than one sender with the largest word count, return the one with the lexicographically largest name.\n\nNote:\n\n- Uppercase letters come before lowercase letters in lexicographical order.\n- \"Alice\" and \"alice\" are distinct.\n\nExample 1:\n\nInput: messages = [\"Hello userTwooo\",\"Hi userThree\",\"Wonderful day Alice\",\"Nice day userThree\"], senders = [\"Alice\",\"userTwo\",\"userThree\",\"Alice\"]\nOutput: \"Alice\"\nExplanation: Alice sends a total of 2 + 3 = 5 words.\nuserTwo sends a total of 2 words.\nuserThree sends a total of 3 words.\nSince Alice has the largest word count, we return \"Alice\".\n\nExample 2:\n\nInput: messages = [\"How is leetcode for everyone\",\"Leetcode is useful for practice\"], senders = [\"Bob\",\"Charlie\"]\nOutput: \"Charlie\"\nExplanation: Bob sends a total of 5 words.\nCharlie sends a total of 5 words.\nSince there is a tie for the largest word count, we return the sender with the lexicographically larger name, Charlie.\n\nConstraints:\n\n- n == messages.length == senders.length\n- 1 <= n <= 10^4\n- 1 <= messages[i].length <= 100\n- 1 <= senders[i].length <= 10\n- messages[i] consists of uppercase and lowercase English letters and ' '.\n- All the words in messages[i] are separated by a single space.\n- messages[i] does not have leading or trailing spaces.\n- senders[i] consists of uppercase and lowercase English letters only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(messages = ['This is a test', 'Another test', 'Final test'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['Hi'],senders = ['Bob']) == \"Bob\"\n    assert candidate(messages = ['Short', 'Longer message indeed'],senders = ['Alice', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['How is leetcode for everyone', 'Leetcode is useful for practice'],senders = ['Bob', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['Hi', 'Hello', 'Hey'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['Hello userTwooo', 'Hi userThree', 'Wonderful day Alice', 'Nice day userThree'],senders = ['Alice', 'userTwo', 'userThree', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['Short', 'Longer message indeed'],senders = ['Bob', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['This is a test', 'Another test', 'Final test'],senders = ['Alice', 'Alice', 'Bob']) == \"Alice\"\n    assert candidate(messages = ['Short', 'Longer message indeed'],senders = ['Charlie', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['Short', 'Longer message here', 'Even longer message here'],senders = ['Zoe', 'Zoe', 'Zoe']) == \"Zoe\"\n    assert candidate(messages = ['a', 'b', 'c', 'd'],senders = ['Anna', 'Bob', 'Charlie', 'David']) == \"David\"\n    assert candidate(messages = ['Hello', 'Hi'],senders = ['Alice', 'Bob']) == \"Bob\"\n    assert candidate(messages = ['Hello World', 'Foo Bar'],senders = ['Alice', 'Bob']) == \"Bob\"\n    assert candidate(messages = ['Hi', 'Hello'],senders = ['Alice', 'Bob']) == \"Bob\"\n    assert candidate(messages = ['Equal length messages here', 'Equal length messages here', 'Equal length messages here'],senders = ['Alice', 'Bob', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['a a a a a a a a a a', 'b b b b b b b b b', 'c c c c c c c c', 'd d d d d d d'],senders = ['Alice', 'Bob', 'Alice', 'Bob']) == \"Alice\"\n    assert candidate(messages = ['Hello Alice', 'Hello Bob', 'Hello Charlie', 'Hello Dave', 'Hello Eve'],senders = ['Alice', 'Bob', 'Charlie', 'Dave', 'Eve']) == \"Eve\"\n    assert candidate(messages = ['Short', 'Longer message with multiple words', 'Another long message that is quite lengthy'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['abc def ghi', 'jkl mno pqr', 'stu vwx yz'],senders = ['Alice', 'Alice', 'Bob']) == \"Alice\"\n    assert candidate(messages = ['Word', 'Word Word', 'Word Word Word', 'Word Word Word Word', 'Word Word Word Word Word'],senders = ['Yankee', 'yankee', 'YANKEE', 'Yankee', 'yankee']) == \"yankee\"\n    assert candidate(messages = ['a', 'b c', 'd e f', 'g h i j'],senders = ['Z', 'Y', 'X', 'W']) == \"W\"\n    assert candidate(messages = ['First message', 'Second message', 'Third message', 'Fourth message'],senders = ['Dave', 'Dave', 'Eve', 'Dave']) == \"Dave\"\n    assert candidate(messages = ['This is a longer message with multiple words', 'Short message', 'Another long message with several words in it'],senders = ['Charlie', 'Alice', 'Bob']) == \"Charlie\"\n    assert candidate(messages = ['a', 'b', 'c', 'd', 'e', 'f'],senders = ['Z', 'Y', 'X', 'W', 'V', 'U']) == \"Z\"\n    assert candidate(messages = ['Hi', 'Hello', 'Hey', 'Goodbye', 'See you later'],senders = ['Alice', 'Bob', 'Alice', 'Bob', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['Hello world', 'How are you doing', 'I am fine thank you', 'And you'],senders = ['Bob', 'Charlie', 'Alice', 'Bob']) == \"Alice\"\n    assert candidate(messages = ['Many many words in this message to test the function', 'Few words'],senders = ['Alice', 'Bob']) == \"Alice\"\n    assert candidate(messages = ['a b c d e f g h i j k l m n o p q r s t u v w x y z', 'a b c d e f g h i j k l m n o p q r s t u v w x y', 'a b c d e f g h i j k l m n o p q r s t u v w x'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['Short message', 'Another short one'],senders = ['charlie', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['One two three four five', 'Six seven eight nine ten', 'Eleven twelve'],senders = ['George', 'Hannah', 'George']) == \"George\"\n    assert candidate(messages = ['Hello userTwooo', 'Hi userThree', 'Wonderful day Alice', 'Nice day userThree', 'Great to see you Alice'],senders = ['Alice', 'userTwo', 'userThree', 'Alice', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],senders = ['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A']) == \"A\"\n    assert candidate(messages = ['Short msg', 'Medium length message indeed', 'A very long message with lots of words to count accurately'],senders = ['Carol', 'Carol', 'Carol']) == \"Carol\"\n    assert candidate(messages = ['Hello world', 'Python programming is fun', 'Hello again', 'Data structures and algorithms'],senders = ['Alice', 'Bob', 'Alice', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['Long message to test', 'Another long message to test', 'Short'],senders = ['Charlie', 'Alice', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['One', 'Two', 'Three', 'Four', 'Five'],senders = ['Zebra', 'Zebra', 'Zebra', 'Zebra', 'Zebra']) == \"Zebra\"\n    assert candidate(messages = ['One', 'Two words here', 'Three words in this message', 'Four words make a sentence'],senders = ['Anna', 'Anna', 'Anna', 'Anna']) == \"Anna\"\n    assert candidate(messages = ['Quick brown fox jumps over lazy dog', 'Hello', 'Goodbye'],senders = ['Alice', 'Alice', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['Quick brown fox', 'Lazy dog', 'Uppercase LOWERCASE', 'Mixed CASE Words'],senders = ['Alex', 'Bob', 'Charlie', 'David']) == \"David\"\n    assert candidate(messages = ['One', 'Two words here', 'Three words in this one', 'Four words make this message'],senders = ['Eve', 'eve', 'EVE', 'Eve']) == \"Eve\"\n    assert candidate(messages = ['This is a longer message', 'Even longer message here', 'Short'],senders = ['Charlie', 'Charlie', 'Alice']) == \"Charlie\"\n    assert candidate(messages = ['Short', 'Longer message to test', 'Even longer message to check the word count', 'Short again'],senders = ['Bob', 'Charlie', 'Alice', 'Charlie']) == \"Alice\"\n    assert candidate(messages = ['This is a test message', 'Another test', 'Yet another message here'],senders = ['Charlie', 'Alice', 'Bob']) == \"Charlie\"\n    assert candidate(messages = ['A quick brown fox jumps over the lazy dog', 'Foo bar baz'],senders = ['Dave', 'Eve']) == \"Dave\"\n    assert candidate(messages = ['Equal words here', 'Equal words here'],senders = ['Alice', 'Bob']) == \"Bob\"\n    assert candidate(messages = ['Many words in this message to test the word count functionality', 'Another message to ensure the solution works correctly'],senders = ['Anna', 'Anna']) == \"Anna\"\n    assert candidate(messages = ['Multiple words', 'Multiple words', 'Multiple words', 'Multiple words'],senders = ['Alice', 'Bob', 'Charlie', 'David']) == \"David\"\n    assert candidate(messages = ['Equal words', 'Equal words'],senders = ['Anna', 'Bob']) == \"Bob\"\n    assert candidate(messages = ['Equal length message', 'Another equal length message'],senders = ['Dave', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['Word', 'Word word', 'Word word word', 'Word word word word', 'Word word word word word'],senders = ['Alex', 'Alex', 'Alex', 'Brian', 'Brian']) == \"Brian\"\n    assert candidate(messages = ['One', 'Two words', 'Three words here', 'Four words in this message'],senders = ['Bob', 'Charlie', 'Bob', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['Multiple words in this message', 'Single', 'Two words'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['Equal length', 'Equal length'],senders = ['Tom', 'Jerry']) == \"Tom\"\n    assert candidate(messages = ['Message one', 'Message two', 'Message three', 'Message four'],senders = ['Zebra', 'Zebra', 'Zebra', 'Zebra']) == \"Zebra\"\n    assert candidate(messages = ['Unique message each time', 'Another unique one'],senders = ['Alice', 'Bob']) == \"Alice\"\n    assert candidate(messages = ['Same sender many times', 'Same sender many times', 'Same sender many times'],senders = ['Alice', 'Alice', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['Message one', 'Another message', 'Yet another message to test', 'Final message'],senders = ['Zara', 'Alice', 'Bob', 'Charlie']) == \"Bob\"\n    assert candidate(messages = ['A B C D E', 'F G H I J K L M N O P', 'Q R S T U V W X Y Z'],senders = ['Alice', 'Bob', 'Charlie']) == \"Bob\"\n    assert candidate(messages = ['Hello world', 'Foo bar baz', 'This is a test message'],senders = ['alice', 'Bob', 'alice']) == \"alice\"\n    assert candidate(messages = ['Message one', 'Message two', 'Message three'],senders = ['Zach', 'Yvonne', 'Xander']) == \"Zach\"\n    assert candidate(messages = ['Different sender', 'Different sender', 'Different sender', 'Different sender'],senders = ['Mike', 'Mike', 'Mike', 'Mike']) == \"Mike\"\n    assert candidate(messages = ['Short', 'Medium length message', 'A very very very long message that spans several words indeed'],senders = ['Alice', 'Alice', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['This is a longer message', 'Short', 'Another long message here'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'],senders = ['Alice']) == \"Alice\"\n    assert candidate(messages = ['a', 'b', 'c', 'd', 'e'],senders = ['Eve', 'Eve', 'Eve', 'Eve', 'Eve']) == \"Eve\"\n    assert candidate(messages = ['Equal words', 'Equal words'],senders = ['Frank', 'frank']) == \"frank\"\n    assert candidate(messages = ['This is a test message', 'Another test', 'Short one'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['A quick brown fox jumps over the lazy dog', 'Lorem ipsum dolor sit amet', 'Consectetur adipiscing elit', 'Sed do eiusmod tempor incididunt'],senders = ['Sam', 'Sam', 'Sam', 'Sam']) == \"Sam\"\n    assert candidate(messages = ['Equal', 'Equal Equal', 'Equal Equal Equal'],senders = ['Mickey', 'mickey', 'MICKEY']) == \"MICKEY\"\n    assert candidate(messages = ['Hi Alice', 'Hello Bob', 'How are you Charlie'],senders = ['Bob', 'Alice', 'Bob']) == \"Bob\"\n    assert candidate(messages = ['Hello world', 'Good morning', 'How are you doing'],senders = ['Charlie', 'Bob', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['Hello world', 'How are you today', 'Hope you are well'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['abc def ghi', 'jkl mno pqr', 'stu vwx yz', 'abc def', 'ghi jkl'],senders = ['Charlie', 'Bob', 'Alice', 'Charlie', 'Alice']) == \"Charlie\"\n    assert candidate(messages = ['Word', 'Word Word', 'Word Word Word', 'Word Word Word Word'],senders = ['Zeta', 'Zeta', 'zeta', 'ZETA']) == \"ZETA\"\n    assert candidate(messages = ['This is a very long message to test the word count functionality', 'Short msg'],senders = ['Delta', 'delta']) == \"Delta\"\n    assert candidate(messages = ['Hi there', 'Hello there', 'Hi there', 'Hello there'],senders = ['Alice', 'Bob', 'Alice', 'Bob']) == \"Bob\"\n    assert candidate(messages = ['A', 'B', 'C', 'D'],senders = ['Anna', 'Bob', 'Charlie', 'David']) == \"David\"\n    assert candidate(messages = ['One', 'Two words', 'Three words here', 'Four words message test'],senders = ['David', 'David', 'Eve', 'Eve']) == \"Eve\"\n    assert candidate(messages = ['Same length', 'Same length', 'Same length', 'Same length'],senders = ['Alice', 'Bob', 'Charlie', 'David']) == \"David\"\n    assert candidate(messages = ['Quick brown fox jumps over the lazy dog', 'Lazy dog sleeps', 'Quick fox runs away'],senders = ['Dog', 'Dog', 'Fox']) == \"Dog\"\n    assert candidate(messages = ['Equal words here', 'Equal words here', 'Equal words here'],senders = ['Anna', 'Bob', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['Multiple messages here', 'Even more messages', 'And yet another message'],senders = ['Kate', 'Kate', 'Laura']) == \"Kate\"\n    assert candidate(messages = ['Multiple words in this message', 'Another message with several words', 'Just a few words'],senders = ['SenderX', 'SenderX', 'SenderY']) == \"SenderX\"\n    assert candidate(messages = ['Message from Alice', 'Another message from Alice', 'Yet another message from Alice', 'Final message from Alice'],senders = ['Alice', 'Alice', 'Alice', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['Message one', 'Message two', 'Message three', 'Message four', 'Message five'],senders = ['Neil', 'Neil', 'Neil', 'Neil', 'Neil']) == \"Neil\"\n    assert candidate(messages = ['a b c d e f g h i j k l m n o p q r s t u v w x y z', 'a b c d e f g h i j k l m n o p q r s t u v w x y z'],senders = ['Alice', 'Bob']) == \"Bob\"\n    assert candidate(messages = ['Multiple words in this message', 'Few words', 'One'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n    assert candidate(messages = ['Equal length message', 'Equal length message'],senders = ['Alice', 'Bob']) == \"Bob\"\n    assert candidate(messages = ['word'],senders = ['Z']) == \"Z\"\n    assert candidate(messages = ['Single', 'Double words', 'Triple words here'],senders = ['Eve', 'Eve', 'Frank']) == \"Frank\"\n    assert candidate(messages = ['Many words in this message to test the word count', 'Few words'],senders = ['Charlie', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['Same sender multiple times', 'Same sender multiple times', 'Same sender multiple times'],senders = ['Zoe', 'Zoe', 'Zoe']) == \"Zoe\"\n    assert candidate(messages = ['A B C D E', 'F G H', 'I J K L M N O'],senders = ['Dave', 'Eve', 'Frank']) == \"Frank\"\n    assert candidate(messages = ['Long message with multiple words indeed', 'Another long message with multiple words indeed'],senders = ['Anna', 'Anna']) == \"Anna\"\n    assert candidate(messages = ['A quick brown fox jumps over the lazy dog', 'Lorem ipsum dolor sit amet', 'Python programming'],senders = ['Alice', 'Bob', 'Charlie']) == \"Alice\"\n    assert candidate(messages = ['a b c d e f g h i j k l m n o p q r s t u v w x y z'],senders = ['Zachary']) == \"Zachary\"\n    assert candidate(messages = ['This is a test message', 'Another message here', 'Short one'],senders = ['Alice', 'Bob', 'Charlie']) == \"Alice\"\n    assert candidate(messages = ['A quick brown fox jumps over the lazy dog', 'The quick brown fox jumps over the lazy dog'],senders = ['Grace', 'grace']) == \"grace\"\n    assert candidate(messages = ['Single', 'Double double', 'Triple triple triple'],senders = ['Alice', 'Bob', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['Short message', 'Longer message here', 'Even longer message to check', 'Short again'],senders = ['Bob', 'Charlie', 'Alice', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['Short one', 'Another short one'],senders = ['Alice', 'Bob']) == \"Bob\"\n    assert candidate(messages = ['One', 'Two words', 'Three words here'],senders = ['Zara', 'Zara', 'Zara']) == \"Zara\"\n    assert candidate(messages = ['Unique words in each message', 'Unique words here too', 'More unique words'],senders = ['Zoe', 'Yasmin', 'Xander']) == \"Zoe\"\n    assert candidate(messages = ['One', 'Two words', 'Three words here', 'Four words in a sentence'],senders = ['Charlie', 'Alice', 'Bob', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['Hello world', 'This is a longer message', 'Another message'],senders = ['Charlie', 'Bob', 'Charlie']) == \"Bob\"\n    assert candidate(messages = ['Test message', 'Test message', 'Test message', 'Test message'],senders = ['Jack', 'Jack', 'Jack', 'Jack']) == \"Jack\"\n    assert candidate(messages = ['One more message', 'Yet another message', 'Final message'],senders = ['Charlie', 'Charlie', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['Hello world', 'How are you doing today', 'Fine thank you'],senders = ['Charlie', 'Alice', 'Bob']) == \"Alice\"\n    assert candidate(messages = ['Hello world', 'This is a test', 'Python programming'],senders = ['Alice', 'Bob', 'Charlie']) == \"Bob\"\n    assert candidate(messages = ['Single', 'Two words', 'Three word phrase', 'Four word sentence structure'],senders = ['Zebra', 'Zebra', 'Zebra', 'Zebra']) == \"Zebra\"\n    assert candidate(messages = ['Hello world', 'Hello Alice', 'Hello Bob'],senders = ['Bob', 'Alice', 'Bob']) == \"Bob\"\n    assert candidate(messages = ['A B C D E F G', 'H I J K L M N', 'O P Q R S T U V W X Y Z'],senders = ['SenderA', 'SenderB', 'SenderC']) == \"SenderC\"\n    assert candidate(messages = ['Unique message', 'Unique message', 'Unique message'],senders = ['Ian', 'Ian', 'Ian']) == \"Ian\"\n    assert candidate(messages = ['Message one', 'Message two', 'Message three', 'Message four'],senders = ['Anna', 'Bob', 'Charlie', 'Bob']) == \"Bob\"\n    assert candidate(messages = ['Long message to increase word count significantly', 'Short'],senders = ['Charlie', 'Charlie']) == \"Charlie\"\n    assert candidate(messages = ['A quick brown fox jumps over the lazy dog', 'The quick brown fox jumps over the lazy dog', 'Lazy dog'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n", "comparison": "exact"}, "public_tests": ["[\"Hello userTwooo\",\"Hi userThree\",\"Wonderful day Alice\",\"Nice day userThree\"]\n[\"Alice\",\"userTwo\",\"userThree\",\"Alice\"]", "[\"How is leetcode for everyone\",\"Leetcode is useful for practice\"]\n[\"Bob\",\"Charlie\"]"], "hints": ["The number of words in a message is equal to the number of spaces + 1.", "Use a hash map to count the total number of words from each sender."], "metadata": {"canonical_parameter_names": ["messages", "senders"], "leetcode_dataset_entry_point": "Solution().largestWordCount", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:33+00:00", "tests_total": 117, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def largestWordCount(self, messages: list[str], senders: list[str]) -> str:", "container": "Solution", "callable": "largestWordCount", "parameters": [{"name": "messages", "type": "list[str]"}, {"name": "senders", "type": "list[str]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2285, "task_id": "maximum-total-importance-of-roads", "difficulty": "Medium", "problem_description": "You are given an integer n denoting the number of cities in a country. The cities are numbered from 0 to n - 1.\n\nYou are also given a 2D integer array roads where roads[i] = [a_i, b_i] denotes that there exists a bidirectional road connecting cities a_i and b_i.\n\nYou need to assign each city with an integer value from 1 to n, where each value can only be used once. The importance of a road is then defined as the sum of the values of the two cities it connects.\n\nReturn the maximum total importance of all roads possible after assigning the values optimally.\n\nExample 1:\n\nInput: n = 5, roads = [[0,1],[1,2],[2,3],[0,2],[1,3],[2,4]]\nOutput: 43\nExplanation: The figure above shows the country and the assigned values of [2,4,5,3,1].\n- The road (0,1) has an importance of 2 + 4 = 6.\n- The road (1,2) has an importance of 4 + 5 = 9.\n- The road (2,3) has an importance of 5 + 3 = 8.\n- The road (0,2) has an importance of 2 + 5 = 7.\n- The road (1,3) has an importance of 4 + 3 = 7.\n- The road (2,4) has an importance of 5 + 1 = 6.\nThe total importance of all roads is 6 + 9 + 8 + 7 + 7 + 6 = 43.\nIt can be shown that we cannot obtain a greater total importance than 43.\n\nExample 2:\n\nInput: n = 5, roads = [[0,3],[2,4],[1,3]]\nOutput: 20\nExplanation: The figure above shows the country and the assigned values of [4,3,2,5,1].\n- The road (0,3) has an importance of 4 + 5 = 9.\n- The road (2,4) has an importance of 2 + 1 = 3.\n- The road (1,3) has an importance of 3 + 5 = 8.\nThe total importance of all roads is 9 + 3 + 8 = 20.\nIt can be shown that we cannot obtain a greater total importance than 20.\n\nConstraints:\n\n- 2 <= n <= 5 * 10^4\n- 1 <= roads.length <= 5 * 10^4\n- roads[i].length == 2\n- 0 <= a_i, b_i <= n - 1\n- a_i != b_i\n- There are no duplicate roads.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 5,roads = [[0, 1], [1, 2], [2, 3], [0, 2], [1, 3], [2, 4]]) == 43\n    assert candidate(n = 6,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == 45\n    assert candidate(n = 3,roads = [[0, 1], [1, 2]]) == 9\n    assert candidate(n = 4,roads = [[0, 1], [0, 3], [1, 2], [2, 3]]) == 20\n    assert candidate(n = 4,roads = [[0, 1], [1, 2], [2, 3]]) == 17\n    assert candidate(n = 6,roads = [[0, 1], [0, 2], [1, 2], [1, 3], [1, 4], [2, 5]]) == 53\n    assert candidate(n = 5,roads = [[0, 3], [2, 4], [1, 3]]) == 20\n    assert candidate(n = 20,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 947\n    assert candidate(n = 7,roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 59\n    assert candidate(n = 9,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 0], [6, 1], [7, 2], [8, 3]]) == 180\n    assert candidate(n = 8,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]]) == 72\n    assert candidate(n = 10,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 165\n    assert candidate(n = 12,roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11]]) == 188\n    assert candidate(n = 16,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [0, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 13], [6, 14], [7, 15], [0, 4], [1, 5], [2, 6], [3, 7], [8, 12], [9, 13], [10, 14], [11, 15]]) == 541\n    assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]]) == 123\n    assert candidate(n = 10,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 8], [1, 7], [2, 6], [3, 5], [4, 0], [5, 1], [6, 2], [7, 3], [8, 4]]) == 218\n    assert candidate(n = 14,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 6], [1, 7], [2, 8], [2, 9], [3, 10], [3, 11], [4, 12], [4, 13], [5, 6], [5, 7], [6, 8], [6, 9], [7, 10], [7, 11], [8, 12], [8, 13], [9, 10], [9, 11], [10, 12], [10, 13], [11, 12], [11, 13]]) == 444\n    assert candidate(n = 14,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 0], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 1], [9, 2], [10, 3], [11, 4], [12, 5], [13, 6]]) == 433\n    assert candidate(n = 9,roads = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 4], [3, 4], [3, 5], [4, 6], [5, 6], [5, 7], [6, 8], [7, 8]]) == 129\n    assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 6], [6, 7], [7, 8], [8, 9]]) == 164\n    assert candidate(n = 20,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 1]]) == 950\n    assert candidate(n = 12,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]]) == 234\n    assert candidate(n = 8,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 4], [1, 5], [2, 6], [3, 7]]) == 108\n    assert candidate(n = 8,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 4], [3, 5], [4, 6], [5, 7]]) == 105\n    assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 1]]) == 525\n    assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]) == 160\n    assert candidate(n = 9,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [4, 5], [6, 7], [7, 8]]) == 120\n    assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14]]) == 315\n    assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 135\n    assert candidate(n = 12,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 10], [6, 11], [7, 11], [8, 11], [9, 11]]) == 218\n    assert candidate(n = 10,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == 110\n    assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [5, 13], [6, 13], [7, 14], [8, 14], [9, 14], [10, 14], [11, 14], [12, 14], [13, 14]]) == 425\n    assert candidate(n = 7,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 4], [3, 5], [4, 6], [5, 6]]) == 83\n    assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 222\n    assert candidate(n = 15,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0], [0, 7], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14], [8, 1], [9, 2], [10, 3], [11, 4], [12, 5], [13, 6], [14, 0]]) == 480\n    assert candidate(n = 8,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 0], [6, 1], [7, 2]]) == 144\n    assert candidate(n = 20,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0]]) == 420\n    assert candidate(n = 7,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == 105\n    assert candidate(n = 12,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 10], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11]]) == 237\n    assert candidate(n = 15,roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == 279\n    assert candidate(n = 20,roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 19]]) == 516\n    assert candidate(n = 9,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 7], [7, 8]]) == 107\n    assert candidate(n = 6,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == 105\n    assert candidate(n = 12,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 11]]) == 156\n    assert candidate(n = 8,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 2], [2, 4], [4, 6], [6, 0]]) == 124\n    assert candidate(n = 20,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19]]) == 1542\n    assert candidate(n = 6,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [0, 4], [1, 4], [2, 4], [3, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == 105\n    assert candidate(n = 15,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [0, 14]]) == 240\n    assert candidate(n = 7,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 6], [4, 5], [5, 6]]) == 78\n    assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 428\n    assert candidate(n = 8,roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]]) == 101\n    assert candidate(n = 15,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9]]) == 345\n    assert candidate(n = 8,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 0], [7, 1]]) == 144\n    assert candidate(n = 9,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 8], [1, 7], [2, 5], [3, 6], [4, 0]]) == 134\n    assert candidate(n = 13,roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 11], [6, 12], [7, 8], [8, 9], [9, 10]]) == 258\n    assert candidate(n = 7,roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 4], [4, 5], [5, 6]]) == 78\n    assert candidate(n = 20,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 0], [19, 1]]) == 840\n    assert candidate(n = 8,roads = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7]]) == 69\n    assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14]]) == 822\n    assert candidate(n = 12,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 2], [7, 3], [8, 4], [9, 5], [10, 1], [11, 0]]) == 312\n    assert candidate(n = 11,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 197\n    assert candidate(n = 12,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 231\n    assert candidate(n = 9,roads = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 6], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8]]) == 159\n    assert candidate(n = 50000,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0]]) == 1999620\n    assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [6, 14]]) == 284\n", "comparison": "exact"}, "public_tests": ["5\n[[0,1],[1,2],[2,3],[0,2],[1,3],[2,4]]", "5\n[[0,3],[2,4],[1,3]]"], "hints": ["Consider what each city contributes to the total importance of all roads.", "Based on that, how can you sort the cities such that assigning them values in that order will yield the maximum total importance?"], "metadata": {"canonical_parameter_names": ["n", "roads"], "leetcode_dataset_entry_point": "Solution().maximumImportance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:35+00:00", "tests_total": 65, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["greedy", "graph", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def maximumImportance(self, n: int, roads: list[list[int]]) -> int:", "container": "Solution", "callable": "maximumImportance", "parameters": [{"name": "n", "type": "int"}, {"name": "roads", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2287, "task_id": "rearrange-characters-to-make-target-string", "difficulty": "Easy", "problem_description": "You are given two 0-indexed strings s and target. You can take some letters from s and rearrange them to form new strings.\n\nReturn the maximum number of copies of target that can be formed by taking letters from s and rearranging them.\n\nExample 1:\n\nInput: s = \"ilovecodingonleetcode\", target = \"code\"\nOutput: 2\nExplanation:\nFor the first copy of \"code\", take the letters at indices 4, 5, 6, and 7.\nFor the second copy of \"code\", take the letters at indices 17, 18, 19, and 20.\nThe strings that are formed are \"ecod\" and \"code\" which can both be rearranged into \"code\".\nWe can make at most two copies of \"code\", so we return 2.\n\nExample 2:\n\nInput: s = \"abcba\", target = \"abc\"\nOutput: 1\nExplanation:\nWe can make one copy of \"abc\" by taking the letters at indices 0, 1, and 2.\nWe can make at most one copy of \"abc\", so we return 1.\nNote that while there is an extra 'a' and 'b' at indices 3 and 4, we cannot reuse the letter 'c' at index 2, so we cannot make a second copy of \"abc\".\n\nExample 3:\n\nInput: s = \"abbaccaddaeea\", target = \"aaaaa\"\nOutput: 1\nExplanation:\nWe can make one copy of \"aaaaa\" by taking the letters at indices 0, 3, 6, 9, and 12.\nWe can make at most one copy of \"aaaaa\", so we return 1.\n\nConstraints:\n\n- 1 <= s.length <= 100\n- 1 <= target.length <= 10\n- s and target consist of lowercase English letters.\n\nNote: This question is the same as  1189: Maximum Number of Balloons.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"aabbc\",target = \"abc\") == 1\n    assert candidate(s = \"aabbbccc\",target = \"abc\") == 2\n    assert candidate(s = \"zzzz\",target = \"zz\") == 2\n    assert candidate(s = \"abcabcabc\",target = \"abc\") == 3\n    assert candidate(s = \"abcd\",target = \"abce\") == 0\n    assert candidate(s = \"abbaccaddaeea\",target = \"aaaaa\") == 1\n    assert candidate(s = \"aabbbcc\",target = \"abc\") == 2\n    assert candidate(s = \"ilovecodingonleetcode\",target = \"code\") == 2\n    assert candidate(s = \"aabbccddeeffgghh\",target = \"abcdefgh\") == 2\n    assert candidate(s = \"aabbcc\",target = \"abc\") == 2\n    assert candidate(s = \"zzzz\",target = \"zzz\") == 1\n    assert candidate(s = \"a\",target = \"a\") == 1\n    assert candidate(s = \"abcccccc\",target = \"cat\") == 0\n    assert candidate(s = \"aaabbbccc\",target = \"abc\") == 3\n    assert candidate(s = \"abcd\",target = \"e\") == 0\n    assert candidate(s = \"abcd\",target = \"abcd\") == 1\n    assert candidate(s = \"aaaaa\",target = \"a\") == 5\n    assert candidate(s = \"abababab\",target = \"abab\") == 2\n    assert candidate(s = \"aaa\",target = \"a\") == 3\n    assert candidate(s = \"aaaaaaaaaa\",target = \"aa\") == 5\n    assert candidate(s = \"pqr\",target = \"ppp\") == 0\n    assert candidate(s = \"aaaabbbbcccc\",target = \"abc\") == 4\n    assert candidate(s = \"leetcode\",target = \"leet\") == 1\n    assert candidate(s = \"abcba\",target = \"abc\") == 1\n    assert candidate(s = \"xyz\",target = \"xyzy\") == 0\n    assert candidate(s = \"xyz\",target = \"zyx\") == 1\n    assert candidate(s = \"programming\",target = \"gram\") == 1\n    assert candidate(s = \"ababababababababababab\",target = \"baba\") == 5\n    assert candidate(s = \"bbbaaaccdddeefff\",target = \"abcde\") == 2\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",target = \"zzzz\") == 10\n    assert candidate(s = \"elevenletters\",target = \"eleven\") == 1\n    assert candidate(s = \"ppppppppppppppp\",target = \"pppp\") == 3\n    assert candidate(s = \"programmingproblems\",target = \"problem\") == 1\n    assert candidate(s = \"characterscharacters\",target = \"characters\") == 2\n    assert candidate(s = \"hellokitty\",target = \"hello\") == 1\n    assert candidate(s = \"repeatedcharacters\",target = \"repeat\") == 1\n    assert candidate(s = \"abcdabcdabcdabcdabcd\",target = \"abcdabcd\") == 2\n    assert candidate(s = \"ppppqqqqrrrsssss\",target = \"pqrs\") == 3\n    assert candidate(s = \"xyzxyzxyz\",target = \"xyz\") == 3\n    assert candidate(s = \"thisisjustaword\",target = \"word\") == 1\n    assert candidate(s = \"bananaananan\",target = \"ana\") == 3\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",target = \"zzzz\") == 8\n    assert candidate(s = \"xxxxxyyyyyzzzzzwwwwwvvvvv\",target = \"xyzzwv\") == 2\n    assert candidate(s = \"ppqpqqppqppqqqqqqq\",target = \"ppqq\") == 3\n    assert candidate(s = \"aabcccccaaa\",target = \"abc\") == 1\n    assert candidate(s = \"xyzzyxzyzyzxzyxzy\",target = \"zyx\") == 4\n    assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppppppppppp\",target = \"p\") == 52\n    assert candidate(s = \"quickbrownfox\",target = \"quick\") == 1\n    assert candidate(s = \"abracadabra\",target = \"abrac\") == 1\n    assert candidate(s = \"aaabbbcccddd\",target = \"abcd\") == 3\n    assert candidate(s = \"jumpoverthelazydog\",target = \"dogjump\") == 1\n    assert candidate(s = \"xyxxyxyxyxyx\",target = \"xyx\") == 3\n    assert candidate(s = \"bananana\",target = \"banana\") == 1\n    assert candidate(s = \"supercalifragilisticexpialidocious\",target = \"super\") == 2\n    assert candidate(s = \"programmingisfun\",target = \"fun\") == 1\n    assert candidate(s = \"rearrangerearrangerearrange\",target = \"range\") == 3\n    assert candidate(s = \"aaabbbccc\",target = \"abcabc\") == 1\n    assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",target = \"a\") == 91\n    assert candidate(s = \"aabbbcccdddeeefff\",target = \"abcdef\") == 2\n    assert candidate(s = \"abacabadabacaba\",target = \"abc\") == 2\n    assert candidate(s = \"mississippi\",target = \"issi\") == 2\n    assert candidate(s = \"babbbababbaba\",target = \"bab\") == 4\n    assert candidate(s = \"abacabadabacaba\",target = \"abac\") == 2\n    assert candidate(s = \"aabbaabbaabb\",target = \"aabb\") == 3\n    assert candidate(s = \"nfaivnfainfainfainfainfafinainfnainfaianfaianfaianfaianfaianfaianfaianfaianfaianfaianfai\",target = \"nfa\") == 19\n    assert candidate(s = \"abcdefgabcdefgabcdefg\",target = \"abcdefg\") == 3\n    assert candidate(s = \"qpwoeirutyalskdjfhgmznxbcv\",target = \"qwerty\") == 1\n    assert candidate(s = \"everygoodboydoesfine\",target = \"every\") == 1\n    assert candidate(s = \"aabbcc\",target = \"abcabc\") == 1\n    assert candidate(s = \"aabbbccddeeefff\",target = \"abcdef\") == 2\n    assert candidate(s = \"xyxxyxyxyx\",target = \"xyx\") == 3\n    assert candidate(s = \"aabbcc\",target = \"aab\") == 1\n    assert candidate(s = \"xzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzy\",target = \"zyx\") == 23\n    assert candidate(s = \"aabbcdeffgghhiijk\",target = \"abcdefghij\") == 1\n    assert candidate(s = \"wassupwassupwassup\",target = \"wassup\") == 3\n    assert candidate(s = \"abracadabra\",target = \"abra\") == 2\n    assert candidate(s = \"xyzxyzxyzxyzxyz\",target = \"xyzxyz\") == 2\n    assert candidate(s = \"testtesttesttest\",target = \"test\") == 4\n    assert candidate(s = \"rearrangerearrange\",target = \"rearrange\") == 2\n    assert candidate(s = \"optimization\",target = \"on\") == 1\n    assert candidate(s = \"aaaaaaaaaaa\",target = \"aaaaa\") == 2\n    assert candidate(s = \"qqwweerrttyyuuiiooppllaa\",target = \"typewriter\") == 1\n    assert candidate(s = \"balloonballoonballoon\",target = \"balloon\") == 3\n    assert candidate(s = \"nnnoooiii\",target = \"noon\") == 1\n    assert candidate(s = \"abracadabra\",target = \"cab\") == 1\n    assert candidate(s = \"xyzxyzxyzxyzxyzxyz\",target = \"xyz\") == 6\n    assert candidate(s = \"xylophonephonexylo\",target = \"xylo\") == 2\n    assert candidate(s = \"abcabcabcabcabc\",target = \"abcabc\") == 2\n    assert candidate(s = \"babababababababab\",target = \"abba\") == 4\n    assert candidate(s = \"abcabcabcabcabc\",target = \"ab\") == 5\n    assert candidate(s = \"aaaabbbbccccdddd\",target = \"abcd\") == 4\n    assert candidate(s = \"rearrangecharacters\",target = \"char\") == 1\n    assert candidate(s = \"elephantelephant\",target = \"elephant\") == 2\n    assert candidate(s = \"fifteenlettersfifteenletters\",target = \"fifteen\") == 2\n    assert candidate(s = \"thisthisthisthisthisthisisthisthisthisthisthis\",target = \"this\") == 11\n    assert candidate(s = \"supercalifragilisticexpialidocious\",target = \"supercali\") == 2\n    assert candidate(s = \"mississippi\",target = \"issip\") == 2\n    assert candidate(s = \"aabbccddeeff\",target = \"abcdef\") == 2\n    assert candidate(s = \"babababa\",target = \"ba\") == 4\n    assert candidate(s = \"abcdabcdabcdabcdabcd\",target = \"abcd\") == 5\n    assert candidate(s = \"xylophone\",target = \"xyl\") == 1\n    assert candidate(s = \"abcdabcdabcd\",target = \"abcd\") == 3\n    assert candidate(s = \"thisisaverylongstringwithmanylettersinittomakeitmorechallengingtotest\",target = \"thisis\") == 2\n    assert candidate(s = \"balloonballoon\",target = \"balloon\") == 2\n    assert candidate(s = \"packmyboxwithfivedozenliquorjugs\",target = \"boxwith\") == 1\n    assert candidate(s = \"bananaapple\",target = \"ana\") == 2\n    assert candidate(s = \"qwerqwerqwerqwer\",target = \"qwerqwer\") == 2\n    assert candidate(s = \"thefiveboxingwizardsjumpquickly\",target = \"jump\") == 1\n    assert candidate(s = \"algorithmsarecool\",target = \"cool\") == 1\n    assert candidate(s = \"exampleexampleexampleexampleexampleexample\",target = \"example\") == 6\n    assert candidate(s = \"xylophone\",target = \"phonex\") == 1\n    assert candidate(s = \"thisisaverylongstringthatyoumightfindchallengingtorearrange\",target = \"string\") == 3\n    assert candidate(s = \"bananaananabanananana\",target = \"nana\") == 4\n    assert candidate(s = \"hellohellohellohello\",target = \"hello\") == 4\n    assert candidate(s = \"abracadabra\",target = \"abraca\") == 1\n    assert candidate(s = \"hellohellohello\",target = \"hello\") == 3\n", "comparison": "exact"}, "public_tests": ["\"ilovecodingonleetcode\"\n\"code\"", "\"abcba\"\n\"abc\"", "\"abbaccaddaeea\"\n\"aaaaa\""], "hints": ["Count the frequency of each character in s and target.", "Consider each letter one at a time. If there are x occurrences of a letter in s and y occurrences of the same letter in target, how many copies of this letter can we make?", "We can make floor(x / y) copies of the letter."], "metadata": {"canonical_parameter_names": ["s", "target"], "leetcode_dataset_entry_point": "Solution().rearrangeCharacters", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:37+00:00", "tests_total": 129, "tests_dropped": 13, "flags": [], "topic_tags": ["hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def rearrangeCharacters(self, s: str, target: str) -> int:", "container": "Solution", "callable": "rearrangeCharacters", "parameters": [{"name": "s", "type": "str"}, {"name": "target", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2288, "task_id": "apply-discount-to-prices", "difficulty": "Medium", "problem_description": "A sentence is a string of single-space separated words where each word can contain digits, lowercase letters, and the dollar sign '$'. A word represents a price if it is a sequence of digits preceded by a dollar sign.\n\n- For example, \"$100\", \"$23\", and \"$6\" represent prices while \"100\", \"$\", and \"$1e5\" do not.\n\nYou are given a string sentence representing a sentence and an integer discount. For each word representing a price, apply a discount of discount% on the price and update the word in the sentence. All updated prices should be represented with exactly two decimal places.\n\nReturn a string representing the modified sentence.\n\nNote that all prices will contain at most 10 digits.\n\nExample 1:\n\nInput: sentence = \"there are $1 $2 and 5$ candies in the shop\", discount = 50\nOutput: \"there are $0.50 $1.00 and 5$ candies in the shop\"\nExplanation:\nThe words which represent prices are \"$1\" and \"$2\".\n- A 50% discount on \"$1\" yields \"$0.50\", so \"$1\" is replaced by \"$0.50\".\n- A 50% discount on \"$2\" yields \"$1\". Since we need to have exactly 2 decimal places after a price, we replace \"$2\" with \"$1.00\".\n\nExample 2:\n\nInput: sentence = \"1 2 $3 4 $5 $6 7 8$ $9 $10$\", discount = 100\nOutput: \"1 2 $0.00 4 $0.00 $0.00 7 8$ $0.00 $10$\"\nExplanation:\nApplying a 100% discount on any price will result in 0.\nThe words representing prices are \"$3\", \"$5\", \"$6\", and \"$9\".\nEach of them is replaced by \"$0.00\".\n\nConstraints:\n\n- 1 <= sentence.length <= 10^5\n- sentence consists of lowercase English letters, digits, ' ', and '$'.\n- sentence does not have leading or trailing spaces.\n- All words in sentence are separated by a single space.\n- All prices will be positive numbers without leading zeros.\n- All prices will have at most 10 digits.\n- 0 <= discount <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(sentence = \"$10 $20 $30 $40 $50\",discount = 0) == \"$10.00 $20.00 $30.00 $40.00 $50.00\"\n    assert candidate(sentence = \"$100 $200 $300\",discount = 25) == \"$75.00 $150.00 $225.00\"\n    assert candidate(sentence = \"no prices here\",discount = 20) == \"no prices here\"\n    assert candidate(sentence = \"1 2 $3 4 $5 $6 7 8$ $9 $10$\",discount = 100) == \"1 2 $0.00 4 $0.00 $0.00 7 8$ $0.00 $10$\"\n    assert candidate(sentence = \"there are $1 $2 and 5$ candies in the shop\",discount = 50) == \"there are $0.50 $1.00 and 5$ candies in the shop\"\n    assert candidate(sentence = \"no prices here\",discount = 10) == \"no prices here\"\n    assert candidate(sentence = \"$9999999999 $1\",discount = 99) == \"$99999999.99 $0.01\"\n    assert candidate(sentence = \"$9999999999 $10000000000 $11111111111\",discount = 10) == \"$8999999999.10 $9000000000.00 $9999999999.90\"\n    assert candidate(sentence = \"$999 $888 $777 $666 $555 $444 $333 $222 $111 $000\",discount = 90) == \"$99.90 $88.80 $77.70 $66.60 $55.50 $44.40 $33.30 $22.20 $11.10 $0.00\"\n    assert candidate(sentence = \"$100 $200 $300 $400 $500 $600 $700 $800 $900 $1000\",discount = 15) == \"$85.00 $170.00 $255.00 $340.00 $425.00 $510.00 $595.00 $680.00 $765.00 $850.00\"\n    assert candidate(sentence = \"$0 $00 $000 $0000 $00000\",discount = 100) == \"$0.00 $0.00 $0.00 $0.00 $0.00\"\n    assert candidate(sentence = \"$1000000000 $999999999 $1111111111 $2222222222 $3333333333\",discount = 75) == \"$250000000.00 $249999999.75 $277777777.75 $555555555.50 $833333333.25\"\n    assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $0\",discount = 75) == \"$0.25 $0.50 $0.75 $1.00 $1.25 $1.50 $1.75 $2.00 $2.25 $0.00\"\n    assert candidate(sentence = \"$123456 $654321 $111111 $222222\",discount = 75) == \"$30864.00 $163580.25 $27777.75 $55555.50\"\n    assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10\",discount = 20) == \"$0.80 $1.60 $2.40 $3.20 $4.00 $4.80 $5.60 $6.40 $7.20 $8.00\"\n    assert candidate(sentence = \"$0 $1 $2 $3 $4 $5 $6 $7 $8 $9\",discount = 10) == \"$0.00 $0.90 $1.80 $2.70 $3.60 $4.50 $5.40 $6.30 $7.20 $8.10\"\n    assert candidate(sentence = \"$100 $200 $300 $400 $500 $600 $700 $800 $900 $1000 $1100 $1200 $1300 $1400 $1500\",discount = 10) == \"$90.00 $180.00 $270.00 $360.00 $450.00 $540.00 $630.00 $720.00 $810.00 $900.00 $990.00 $1080.00 $1170.00 $1260.00 $1350.00\"\n    assert candidate(sentence = \"$10 $20 $30 $40 $50 $60 $70 $80 $90 $100\",discount = 100) == \"$0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00\"\n    assert candidate(sentence = \"$999999999 $111111111 $222222222 $333333333 $444444444\",discount = 90) == \"$99999999.90 $11111111.10 $22222222.20 $33333333.30 $44444444.40\"\n    assert candidate(sentence = \"$1000000000 $999999999 $888888888 $777777777 $666666666 $555555555 $444444444 $333333333 $222222222 $111111111\",discount = 1) == \"$990000000.00 $989999999.01 $879999999.12 $769999999.23 $659999999.34 $549999999.45 $439999999.56 $329999999.67 $219999999.78 $109999999.89\"\n    assert candidate(sentence = \"$12345678901234567890 $98765432109876543210 $10000000001000000000\",discount = 50) == \"$6172839450617283584.00 $49382716054938271744.00 $5000000000499999744.00\"\n    assert candidate(sentence = \"$100 $200 $300 $400 $500 $600 $700 $800 $900 $1000\",discount = 99) == \"$1.00 $2.00 $3.00 $4.00 $5.00 $6.00 $7.00 $8.00 $9.00 $10.00\"\n    assert candidate(sentence = \"$9999999999 this is a very long sentence with many $100 prices $500 and $1000\",discount = 20) == \"$7999999999.20 this is a very long sentence with many $80.00 prices $400.00 and $800.00\"\n    assert candidate(sentence = \"$1million $1billion $1trillion\",discount = 50) == \"$1million $1billion $1trillion\"\n    assert candidate(sentence = \"$1000000 $2000000 $3000000 $4000000\",discount = 30) == \"$700000.00 $1400000.00 $2100000.00 $2800000.00\"\n    assert candidate(sentence = \"$500 $1000 $1500 $2000\",discount = 20) == \"$400.00 $800.00 $1200.00 $1600.00\"\n    assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20\",discount = 10) == \"$0.90 $1.80 $2.70 $3.60 $4.50 $5.40 $6.30 $7.20 $8.10 $9.00 $9.90 $10.80 $11.70 $12.60 $13.50 $14.40 $15.30 $16.20 $17.10 $18.00\"\n    assert candidate(sentence = \"$9999999999 $1000000000 $123456789\",discount = 5) == \"$9499999999.05 $950000000.00 $117283949.55\"\n    assert candidate(sentence = \"$999999999 $888888888 $777777777 $666666666 $555555555\",discount = 20) == \"$799999999.20 $711111110.40 $622222221.60 $533333332.80 $444444444.00\"\n    assert candidate(sentence = \"$1234567890 $123456789 $12345678 $1234567 $123456 $12345 $1234 $123 $12 $1\",discount = 10) == \"$1111111101.00 $111111110.10 $11111110.20 $1111110.30 $111110.40 $11110.50 $1110.60 $110.70 $10.80 $0.90\"\n    assert candidate(sentence = \"$1 $10 $100 $1000 $10000 $100000 $1000000 $10000000 $100000000 $1000000000\",discount = 99) == \"$0.01 $0.10 $1.00 $10.00 $100.00 $1000.00 $10000.00 $100000.00 $1000000.00 $10000000.00\"\n    assert candidate(sentence = \"$12345 $67890 $54321 $98760 $13579 $24680\",discount = 30) == \"$8641.50 $47523.00 $38024.70 $69132.00 $9505.30 $17276.00\"\n    assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20\",discount = 95) == \"$0.05 $0.10 $0.15 $0.20 $0.25 $0.30 $0.35 $0.40 $0.45 $0.50 $0.55 $0.60 $0.65 $0.70 $0.75 $0.80 $0.85 $0.90 $0.95 $1.00\"\n    assert candidate(sentence = \"$10 $20 $30 $40 $50 $60 $70 $80 $90 $100\",discount = 5) == \"$9.50 $19.00 $28.50 $38.00 $47.50 $57.00 $66.50 $76.00 $85.50 $95.00\"\n    assert candidate(sentence = \"$10 $20 $30 $40 $50 $60 $70 $80 $90 $100\",discount = 20) == \"$8.00 $16.00 $24.00 $32.00 $40.00 $48.00 $56.00 $64.00 $72.00 $80.00\"\n    assert candidate(sentence = \"$9999999999\",discount = 1) == \"$9899999999.01\"\n    assert candidate(sentence = \"$100abc $abc100 $100$ $100 $200\",discount = 10) == \"$100abc $abc100 $100$ $90.00 $180.00\"\n    assert candidate(sentence = \"$9999999999 is the max price and $1 is the min price in this sentence\",discount = 5) == \"$9499999999.05 is the max price and $0.95 is the min price in this sentence\"\n    assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $0\",discount = 50) == \"$0.50 $1.00 $1.50 $2.00 $2.50 $3.00 $3.50 $4.00 $4.50 $0.00 $0.50 $1.00 $1.50 $2.00 $2.50 $3.00 $3.50 $4.00 $4.50 $0.00\"\n    assert candidate(sentence = \"$10000000000 $20000000000 $30000000000\",discount = 50) == \"$5000000000.00 $10000000000.00 $15000000000.00\"\n    assert candidate(sentence = \"$100 $200 $300 $400 $500 $600 $700 $800 $900 $1000 $1100 $1200 $1300 $1400 $1500 $1600 $1700 $1800 $1900 $2000\",discount = 75) == \"$25.00 $50.00 $75.00 $100.00 $125.00 $150.00 $175.00 $200.00 $225.00 $250.00 $275.00 $300.00 $325.00 $350.00 $375.00 $400.00 $425.00 $450.00 $475.00 $500.00\"\n    assert candidate(sentence = \"$12345 $67890 $54321 $98765 $13579 $24680\",discount = 30) == \"$8641.50 $47523.00 $38024.70 $69135.50 $9505.30 $17276.00\"\n    assert candidate(sentence = \"$0\",discount = 100) == \"$0.00\"\n    assert candidate(sentence = \"$1234567890 $987654321 $1000000000\",discount = 10) == \"$1111111101.00 $888888888.90 $900000000.00\"\n    assert candidate(sentence = \"$9 $99 $999 $9999 $99999 $999999 $9999999 $99999999 $999999999 $9999999999\",discount = 90) == \"$0.90 $9.90 $99.90 $999.90 $9999.90 $99999.90 $999999.90 $9999999.90 $99999999.90 $999999999.90\"\n    assert candidate(sentence = \"$1234567890 $9876543210 $1111111111 $2222222222 $3333333333 $4444444444 $5555555555 $6666666666 $7777777777 $8888888888\",discount = 10) == \"$1111111101.00 $8888888889.00 $999999999.90 $1999999999.80 $2999999999.70 $3999999999.60 $4999999999.50 $5999999999.40 $6999999999.30 $7999999999.20\"\n    assert candidate(sentence = \"$9999999999 $1000000000 $123456789\",discount = 10) == \"$8999999999.10 $900000000.00 $111111110.10\"\n    assert candidate(sentence = \"$1000000 $2000000 $3000000 $4000000 $5000000\",discount = 0) == \"$1000000.00 $2000000.00 $3000000.00 $4000000.00 $5000000.00\"\n    assert candidate(sentence = \"$10 $20 $30 $40 $50 $60 $70 $80 $90 $100\",discount = 0) == \"$10.00 $20.00 $30.00 $40.00 $50.00 $60.00 $70.00 $80.00 $90.00 $100.00\"\n    assert candidate(sentence = \"$10 $20 $30 $40 $50 $60 $70 $80 $90 $100 $110 $120 $130 $140 $150\",discount = 30) == \"$7.00 $14.00 $21.00 $28.00 $35.00 $42.00 $49.00 $56.00 $63.00 $70.00 $77.00 $84.00 $91.00 $98.00 $105.00\"\n    assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20\",discount = 99) == \"$0.01 $0.02 $0.03 $0.04 $0.05 $0.06 $0.07 $0.08 $0.09 $0.10 $0.11 $0.12 $0.13 $0.14 $0.15 $0.16 $0.17 $0.18 $0.19 $0.20\"\n    assert candidate(sentence = \"$1000 $2000 $3000\",discount = 95) == \"$50.00 $100.00 $150.00\"\n    assert candidate(sentence = \"$9999999999 $8888888888 $7777777777 $6666666666 $5555555555\",discount = 0) == \"$9999999999.00 $8888888888.00 $7777777777.00 $6666666666.00 $5555555555.00\"\n    assert candidate(sentence = \"$100 $200 $300 $400 $500 $600 $700 $800 $900 $1000\",discount = 0) == \"$100.00 $200.00 $300.00 $400.00 $500.00 $600.00 $700.00 $800.00 $900.00 $1000.00\"\n    assert candidate(sentence = \"$1000000000 $999999999 $888888888 $777777777 $666666666 $555555555 $444444444 $333333333 $222222222 $111111111\",discount = 15) == \"$850000000.00 $849999999.15 $755555554.80 $661111110.45 $566666666.10 $472222221.75 $377777777.40 $283333333.05 $188888888.70 $94444444.35\"\n    assert candidate(sentence = \"$100000 $200000 $300000 $400000 $500000\",discount = 20) == \"$80000.00 $160000.00 $240000.00 $320000.00 $400000.00\"\n    assert candidate(sentence = \"$123abc $456def $789ghi $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20\",discount = 15) == \"$123abc $456def $789ghi $0.00 $0.85 $1.70 $2.55 $3.40 $4.25 $5.10 $5.95 $6.80 $7.65 $8.50 $9.35 $10.20 $11.05 $11.90 $12.75 $13.60 $14.45 $15.30 $16.15 $17.00\"\n    assert candidate(sentence = \"$9999999999 $1000000000 $100000000 $10000000 $1000000 $100000 $10000 $1000 $100 $10 $1\",discount = 5) == \"$9499999999.05 $950000000.00 $95000000.00 $9500000.00 $950000.00 $95000.00 $9500.00 $950.00 $95.00 $9.50 $0.95\"\n    assert candidate(sentence = \"$123 $456 $789 $012 $345 $678 $901 $234 $567 $890 $123456789 $987654321 $111111111 $222222222 $333333333 $444444444 $555555555 $666666666 $777777777 $888888888 $999999999 $1000000000 $2000000000 $3000000000\",discount = 30) == \"$86.10 $319.20 $552.30 $8.40 $241.50 $474.60 $630.70 $163.80 $396.90 $623.00 $86419752.30 $691358024.70 $77777777.70 $155555555.40 $233333333.10 $311111110.80 $388888888.50 $466666666.20 $544444443.90 $622222221.60 $699999999.30 $700000000.00 $1400000000.00 $2100000000.00\"\n    assert candidate(sentence = \"$5 $15 $25 $35 $45 $55 $65 $75 $85 $95\",discount = 75) == \"$1.25 $3.75 $6.25 $8.75 $11.25 $13.75 $16.25 $18.75 $21.25 $23.75\"\n    assert candidate(sentence = \"$50 apples $20 oranges $30 bananas $10 grapes\",discount = 30) == \"$35.00 apples $14.00 oranges $21.00 bananas $7.00 grapes\"\n    assert candidate(sentence = \"$9999999999 $123456789 $9876543210 $1000000000 $500000000\",discount = 15) == \"$8499999999.15 $104938270.65 $8395061728.50 $850000000.00 $425000000.00\"\n    assert candidate(sentence = \"$0 $00 $000 $0000 $00000\",discount = 20) == \"$0.00 $0.00 $0.00 $0.00 $0.00\"\n    assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15\",discount = 0) == \"$1.00 $2.00 $3.00 $4.00 $5.00 $6.00 $7.00 $8.00 $9.00 $10.00 $11.00 $12.00 $13.00 $14.00 $15.00\"\n    assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10\",discount = 5) == \"$0.95 $1.90 $2.85 $3.80 $4.75 $5.70 $6.65 $7.60 $8.55 $9.50\"\n    assert candidate(sentence = \"$1234567890 $9876543210 $1000000000\",discount = 5) == \"$1172839495.50 $9382716049.50 $950000000.00\"\n    assert candidate(sentence = \"$1000000000 $999999999 $888888888 $777777777\",discount = 50) == \"$500000000.00 $499999999.50 $444444444.00 $388888888.50\"\n    assert candidate(sentence = \"$1234567890 $9876543210 $1000000000\",discount = 15) == \"$1049382706.50 $8395061728.50 $850000000.00\"\n    assert candidate(sentence = \"$9999999999 $8888888888 $7777777777 $6666666666 $5555555555 $4444444444 $3333333333 $2222222222 $1111111111 $1\",discount = 99) == \"$99999999.99 $88888888.88 $77777777.77 $66666666.66 $55555555.55 $44444444.44 $33333333.33 $22222222.22 $11111111.11 $0.01\"\n    assert candidate(sentence = \"$123 $456 $789 $101112 $131415 $161718 $192021 $222324 $252627 $282930\",discount = 25) == \"$92.25 $342.00 $591.75 $75834.00 $98561.25 $121288.50 $144015.75 $166743.00 $189470.25 $212197.50\"\n    assert candidate(sentence = \"$1000 $2000 $3000 $4000 $5000 $6000 $7000 $8000 $9000 $10000\",discount = 75) == \"$250.00 $500.00 $750.00 $1000.00 $1250.00 $1500.00 $1750.00 $2000.00 $2250.00 $2500.00\"\n    assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20\",discount = 50) == \"$0.50 $1.00 $1.50 $2.00 $2.50 $3.00 $3.50 $4.00 $4.50 $5.00 $5.50 $6.00 $6.50 $7.00 $7.50 $8.00 $8.50 $9.00 $9.50 $10.00\"\n    assert candidate(sentence = \"$100 $200 $300 $400 $500 $600 $700 $800 $900 $1000\",discount = 20) == \"$80.00 $160.00 $240.00 $320.00 $400.00 $480.00 $560.00 $640.00 $720.00 $800.00\"\n    assert candidate(sentence = \"$999999999 $888888888 $777777777 $666666666 $555555555\",discount = 30) == \"$699999999.30 $622222221.60 $544444443.90 $466666666.20 $388888888.50\"\n    assert candidate(sentence = \"$9999999999 $8888888888 $7777777777\",discount = 5) == \"$9499999999.05 $8444444443.60 $7388888888.15\"\n    assert candidate(sentence = \"$1000000000 $100000000 $10000000 $1000000 $100000 $10000 $1000 $100 $10 $1\",discount = 5) == \"$950000000.00 $95000000.00 $9500000.00 $950000.00 $95000.00 $9500.00 $950.00 $95.00 $9.50 $0.95\"\n    assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20\",discount = 15) == \"$0.85 $1.70 $2.55 $3.40 $4.25 $5.10 $5.95 $6.80 $7.65 $8.50 $9.35 $10.20 $11.05 $11.90 $12.75 $13.60 $14.45 $15.30 $16.15 $17.00\"\n    assert candidate(sentence = \"$9999999999 $8888888888 $7777777777 $6666666666 $5555555555 $4444444444 $3333333333 $2222222222 $1111111111 $1000000000 $999999999 $888888888 $777777777 $666666666 $555555555 $444444444 $333333333 $222222222 $111111111 $100000000 $99999999 $88888888 $77777777 $66666666 $55555555 $44444444 $33333333 $22222222 $11111111 $10000000 $9999999 $8888888 $7777777 $6666666 $5555555 $4444444 $3333333 $2222222 $1111111 $1000000 $999999 $888888 $777777 $666666 $555555 $444444 $333333 $222222 $111111 $100000 $99999 $88888 $77777 $66666 $55555 $44444 $33333 $22222 $11111 $10000 $9999 $8888 $7777 $6666 $5555 $4444 $3333 $2222 $1111 $1000 $999 $888 $777 $666 $555 $444 $333 $222 $111 $100 $99 $88 $77 $66 $55 $44 $33 $22 $11 $1\",discount = 10) == \"$8999999999.10 $7999999999.20 $6999999999.30 $5999999999.40 $4999999999.50 $3999999999.60 $2999999999.70 $1999999999.80 $999999999.90 $900000000.00 $899999999.10 $799999999.20 $699999999.30 $599999999.40 $499999999.50 $399999999.60 $299999999.70 $199999999.80 $99999999.90 $90000000.00 $89999999.10 $79999999.20 $69999999.30 $59999999.40 $49999999.50 $39999999.60 $29999999.70 $19999999.80 $9999999.90 $9000000.00 $8999999.10 $7999999.20 $6999999.30 $5999999.40 $4999999.50 $3999999.60 $2999999.70 $1999999.80 $999999.90 $900000.00 $899999.10 $799999.20 $699999.30 $599999.40 $499999.50 $399999.60 $299999.70 $199999.80 $99999.90 $90000.00 $89999.10 $79999.20 $69999.30 $59999.40 $49999.50 $39999.60 $29999.70 $19999.80 $9999.90 $9000.00 $8999.10 $7999.20 $6999.30 $5999.40 $4999.50 $3999.60 $2999.70 $1999.80 $999.90 $900.00 $899.10 $799.20 $699.30 $599.40 $499.50 $399.60 $299.70 $199.80 $99.90 $90.00 $89.10 $79.20 $69.30 $59.40 $49.50 $39.60 $29.70 $19.80 $9.90 $0.90\"\n    assert candidate(sentence = \"$100 abc $200 def $300 ghi $400 jkl $500 mno\",discount = 75) == \"$25.00 abc $50.00 def $75.00 ghi $100.00 jkl $125.00 mno\"\n    assert candidate(sentence = \"$1234 $5678 $91011 $121314 $151617 $181920 $212223 $242526 $272829 $303132\",discount = 20) == \"$987.20 $4542.40 $72808.80 $97051.20 $121293.60 $145536.00 $169778.40 $194020.80 $218263.20 $242505.60\"\n    assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20 $21 $22 $23 $24 $25 $26 $27 $28 $29 $30\",discount = 100) == \"$0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00\"\n    assert candidate(sentence = \"$1234567890 $987654321 $1000000000 $500000000 $250000000 $125000000 $62500000 $31250000 $15625000 $7812500 $3906250 $1953125 $976562 $488281 $244140 $122070 $61035 $30517 $15258 $7629 $3814 $1907 $953 $476 $238 $119 $59 $29 $14 $7 $3 $1\",discount = 10) == \"$1111111101.00 $888888888.90 $900000000.00 $450000000.00 $225000000.00 $112500000.00 $56250000.00 $28125000.00 $14062500.00 $7031250.00 $3515625.00 $1757812.50 $878905.80 $439452.90 $219726.00 $109863.00 $54931.50 $27465.30 $13732.20 $6866.10 $3432.60 $1716.30 $857.70 $428.40 $214.20 $107.10 $53.10 $26.10 $12.60 $6.30 $2.70 $0.90\"\n    assert candidate(sentence = \"$123 $456 $789 $1011 $1213 $1415 $1617 $1819 $2021 $2223 $2425 $2627 $2829 $3031 $3233\",discount = 25) == \"$92.25 $342.00 $591.75 $758.25 $909.75 $1061.25 $1212.75 $1364.25 $1515.75 $1667.25 $1818.75 $1970.25 $2121.75 $2273.25 $2424.75\"\n    assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10\",discount = 90) == \"$0.10 $0.20 $0.30 $0.40 $0.50 $0.60 $0.70 $0.80 $0.90 $1.00\"\n    assert candidate(sentence = \"$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15\",discount = 5) == \"$0.95 $1.90 $2.85 $3.80 $4.75 $5.70 $6.65 $7.60 $8.55 $9.50 $10.45 $11.40 $12.35 $13.30 $14.25\"\n    assert candidate(sentence = \"$9 $8 $7 $6 $5 $4 $3 $2 $1 $0\",discount = 100) == \"$0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00\"\n    assert candidate(sentence = \"$123 $456 $789 $101112 $131415 $161718\",discount = 75) == \"$30.75 $114.00 $197.25 $25278.00 $32853.75 $40429.50\"\n    assert candidate(sentence = \"$1 $10 $100 $1000 $10000 $100000 $1000000 $10000000 $100000000 $1000000000\",discount = 50) == \"$0.50 $5.00 $50.00 $500.00 $5000.00 $50000.00 $500000.00 $5000000.00 $50000000.00 $500000000.00\"\n    assert candidate(sentence = \"$10 $20 $30 $40 $50 $60 $70 $80 $90 $100 $110 $120 $130 $140 $150\",discount = 75) == \"$2.50 $5.00 $7.50 $10.00 $12.50 $15.00 $17.50 $20.00 $22.50 $25.00 $27.50 $30.00 $32.50 $35.00 $37.50\"\n    assert candidate(sentence = \"$1000000000 this is a test with one big $9999999999 price and a small $1\",discount = 1) == \"$990000000.00 this is a test with one big $9899999999.01 price and a small $0.99\"\n    assert candidate(sentence = \"$0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10\",discount = 50) == \"$0.00 $0.50 $1.00 $1.50 $2.00 $2.50 $3.00 $3.50 $4.00 $4.50 $5.00\"\n    assert candidate(sentence = \"$9999999999 $8888888888 $7777777777 $6666666666 $5555555555\",discount = 1) == \"$9899999999.01 $8799999999.12 $7699999999.23 $6599999999.34 $5499999999.45\"\n    assert candidate(sentence = \"$1 $10 $100 $1000 $10000 $100000 $1000000 $10000000 $100000000 $1000000000 $10000000000\",discount = 5) == \"$0.95 $9.50 $95.00 $950.00 $9500.00 $95000.00 $950000.00 $9500000.00 $95000000.00 $950000000.00 $9500000000.00\"\n    assert candidate(sentence = \"$9999999999 $8888888888 $7777777777 $6666666666 $5555555555 $4444444444 $3333333333 $2222222222 $1111111111 $1000000000\",discount = 50) == \"$4999999999.50 $4444444444.00 $3888888888.50 $3333333333.00 $2777777777.50 $2222222222.00 $1666666666.50 $1111111111.00 $555555555.50 $500000000.00\"\n    assert candidate(sentence = \"$9999999999 $999999999 $99999999 $9999999 $999999 $99999 $9999 $999 $99 $9\",discount = 0) == \"$9999999999.00 $999999999.00 $99999999.00 $9999999.00 $999999.00 $99999.00 $9999.00 $999.00 $99.00 $9.00\"\n    assert candidate(sentence = \"$999999999 $888888888 $777777777 $666666666 $555555555 $444444444 $333333333 $222222222 $111111111 $1\",discount = 50) == \"$499999999.50 $444444444.00 $388888888.50 $333333333.00 $277777777.50 $222222222.00 $166666666.50 $111111111.00 $55555555.50 $0.50\"\n    assert candidate(sentence = \"$0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20\",discount = 10) == \"$0.00 $0.90 $1.80 $2.70 $3.60 $4.50 $5.40 $6.30 $7.20 $8.10 $9.00 $9.90 $10.80 $11.70 $12.60 $13.50 $14.40 $15.30 $16.20 $17.10 $18.00\"\n    assert candidate(sentence = \"$999 $888 $777 $666 $555 $444 $333 $222 $111 $10\",discount = 99) == \"$9.99 $8.88 $7.77 $6.66 $5.55 $4.44 $3.33 $2.22 $1.11 $0.10\"\n", "comparison": "exact"}, "public_tests": ["\"there are $1 $2 and 5$ candies in the shop\"\n50", "\"1 2 $3 4 $5 $6 7 8$ $9 $10$\"\n100"], "hints": ["Extract each word from the sentence and check if it represents a price.", "For each price, apply the given discount to it and update it."], "metadata": {"canonical_parameter_names": ["sentence", "discount"], "leetcode_dataset_entry_point": "Solution().discountPrices", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:40+00:00", "tests_total": 108, "tests_dropped": 10, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def discountPrices(self, sentence: str, discount: int) -> str:", "container": "Solution", "callable": "discountPrices", "parameters": [{"name": "sentence", "type": "str"}, {"name": "discount", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2289, "task_id": "steps-to-make-array-non-decreasing", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. In one step, remove all elements nums[i] where nums[i - 1] > nums[i] for all 0 < i < nums.length.\n\nReturn the number of steps performed until nums becomes a non-decreasing array.\n\nExample 1:\n\nInput: nums = [5,3,4,4,7,3,6,11,8,5,11]\nOutput: 3\nExplanation: The following are the steps performed:\n- Step 1: [5,3,4,4,7,3,6,11,8,5,11] becomes [5,4,4,7,6,11,11]\n- Step 2: [5,4,4,7,6,11,11] becomes [5,4,7,11,11]\n- Step 3: [5,4,7,11,11] becomes [5,7,11,11]\n[5,7,11,11] is a non-decreasing array. Therefore, we return 3.\n\nExample 2:\n\nInput: nums = [4,5,7,7,13]\nOutput: 0\nExplanation: nums is already a non-decreasing array. Therefore, we return 0.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 1\n    assert candidate(nums = [3, 2, 1, 2, 1, 2, 3, 2, 1]) == 3\n    assert candidate(nums = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 5\n    assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1]) == 1\n    assert candidate(nums = [2, 1]) == 1\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n    assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 5, 4, 6]) == 1\n    assert candidate(nums = [3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 2\n    assert candidate(nums = [1]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9]) == 4\n    assert candidate(nums = [4, 5, 7, 7, 13]) == 0\n    assert candidate(nums = [1, 3, 2]) == 1\n    assert candidate(nums = [5, 3, 4, 4, 7, 3, 6, 11, 8, 5, 11]) == 3\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [7, 14, 4, 14, 13, 2, 6, 13, 10, 16]) == 3\n    assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 1\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 2\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == 0\n    assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 1\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 1\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 0\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n    assert candidate(nums = [1, 2]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [2, 1, 3, 2, 1, 4, 3, 2, 1, 5]) == 1\n    assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10]) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 1\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3]) == 6\n    assert candidate(nums = [2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15]) == 1\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995]) == 1\n    assert candidate(nums = [100, 10, 90, 20, 80, 30, 70, 40, 60, 50, 5, 4, 3, 2, 1]) == 2\n    assert candidate(nums = [10, 20, 30, 25, 40, 50, 45, 60, 70, 55, 80, 90, 85, 100, 95, 110, 120, 115]) == 1\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1\n    assert candidate(nums = [10, 20, 15, 25, 30, 5, 35, 40, 45, 10, 50]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [10, 20, 30, 25, 20, 15, 10, 5, 15, 25, 35, 45, 55, 50, 45, 40, 35, 30, 25, 20]) == 3\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 1\n    assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10]) == 2\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 9\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 5, 9, 6, 10, 5, 11, 5, 12]) == 1\n    assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21]) == 1\n    assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 1\n    assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90, 110]) == 1\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 2\n    assert candidate(nums = [10, 20, 30, 25, 35, 40, 38, 45, 50, 48]) == 1\n    assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6]) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == 5\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 3\n    assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 1\n    assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6, 70, 7, 80, 8, 90, 9, 100, 10]) == 1\n    assert candidate(nums = [5, 3, 4, 4, 7, 3, 6, 11, 8, 5, 11, 20, 15, 25, 22, 30, 27, 35, 32, 40, 37, 45, 42, 50]) == 3\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 1\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 5, 9, 6]) == 1\n    assert candidate(nums = [3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 6, 5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9, 10]) == 3\n    assert candidate(nums = [100, 200, 150, 250, 200, 300, 250, 350, 300, 400]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16]) == 1\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == 2\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 1\n    assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n    assert candidate(nums = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9, 1000, 10]) == 1\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n    assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 4\n    assert candidate(nums = [3, 2, 1, 4, 6, 5, 7, 9, 8, 10]) == 1\n    assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10]) == 2\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [3, 2, 1, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 1\n    assert candidate(nums = [5, 3, 8, 6, 7, 2, 4, 9, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n    assert candidate(nums = [2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1, 19, 1, 20, 1]) == 1\n    assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91, 11, 90, 12, 89]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n    assert candidate(nums = [5, 3, 4, 4, 7, 3, 6, 11, 8, 5, 11, 10, 9, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 2\n    assert candidate(nums = [100, 200, 100, 300, 200, 400, 300, 500, 400, 600]) == 1\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 2\n    assert candidate(nums = [5, 3, 4, 4, 7, 3, 6, 11, 8, 5, 11, 3, 2, 1, 9, 8, 7, 6, 5, 4]) == 3\n    assert candidate(nums = [8, 3, 2, 1, 4, 5, 6, 7, 9, 10]) == 5\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 10\n    assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n    assert candidate(nums = [3, 2, 1, 6, 5, 4, 9, 8, 7, 10]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 10\n    assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10, 12, 11, 13, 15, 14, 16, 18, 17, 19, 20]) == 1\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 2\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 5\n    assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n    assert candidate(nums = [100, 50, 25, 12, 6, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 7\n    assert candidate(nums = [10, 9, 8, 10, 9, 8, 10, 9, 8, 10, 9, 8, 10, 9, 8]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 1\n    assert candidate(nums = [5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 4\n    assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 4\n", "comparison": "exact"}, "public_tests": ["[5,3,4,4,7,3,6,11,8,5,11]", "[4,5,7,7,13]"], "hints": ["Notice that an element will be removed if and only if there exists a strictly greater element to the left of it in the array.", "For each element, we need to find the number of rounds it will take for it to be removed. The answer is the maximum number of rounds for all elements. Build an array dp to hold this information where the answer is the maximum value of dp.", "Use a stack of the indices. While processing element nums[i], remove from the stack all the indices of elements that are smaller than nums[i]. dp[i] should be set to the maximum of dp[i] + 1 and dp[removed index]."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().totalSteps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:42+00:00", "tests_total": 129, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "linked-list", "dynamic-programming", "stack", "monotonic-stack", "simulation"]}, "language": "python", "interface": {"raw_signature": "def totalSteps(self, nums: list[int]) -> int:", "container": "Solution", "callable": "totalSteps", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2290, "task_id": "minimum-obstacle-removal-to-reach-corner", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array grid of size m x n. Each cell has one of two values:\n\n- 0 represents an empty cell,\n- 1 represents an obstacle that may be removed.\n\nYou can move up, down, left, or right from and to an empty cell.\n\nReturn the minimum number of obstacles to remove so you can move from the upper left corner (0, 0) to the lower right corner (m - 1, n - 1).\n\nExample 1:\n\nInput: grid = [[0,1,1],[1,1,0],[1,1,0]]\nOutput: 2\nExplanation: We can remove the obstacles at (0, 1) and (0, 2) to create a path from (0, 0) to (2, 2).\nIt can be shown that we need to remove at least 2 obstacles, so we return 2.\nNote that there may be other ways to remove 2 obstacles to create a path.\n\nExample 2:\n\nInput: grid = [[0,1,0,0,0],[0,1,0,1,0],[0,0,0,1,0]]\nOutput: 0\nExplanation: We can move from (0, 0) to (2, 4) without removing any obstacles, so we return 0.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 10^5\n- 2 <= m * n <= 10^5\n- grid[i][j] is either 0 or 1.\n- grid[0][0] == grid[m - 1][n - 1] == 0\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[0, 1], [1, 0]]) == 1\n    assert candidate(grid = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 0\n    assert candidate(grid = [[0, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 0]]) == 4\n    assert candidate(grid = [[0, 1, 1, 0], [1, 1, 1, 0], [1, 1, 1, 0], [0, 0, 0, 0]]) == 2\n    assert candidate(grid = [[0, 1, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 1, 0]]) == 0\n    assert candidate(grid = [[0, 1, 1], [1, 1, 0], [1, 1, 0]]) == 2\n    assert candidate(grid = [[0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 1, 0]]) == 1\n    assert candidate(grid = [[0, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0]]) == 3\n    assert candidate(grid = [[0, 1, 1, 0, 1, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1, 0, 0, 1, 0], [1, 1, 0, 1, 1, 1, 1, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 0, 0, 0]]) == 2\n    assert candidate(grid = [[0, 1, 0, 1, 1, 0, 1, 0], [1, 1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n    assert candidate(grid = [[0, 1, 1, 1, 1, 0], [1, 1, 0, 1, 1, 0], [0, 1, 0, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 1\n    assert candidate(grid = [[0, 1, 1, 1, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n    assert candidate(grid = [[0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n    assert candidate(grid = [[0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 0], [0, 0, 0, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 2\n    assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0]]) == 2\n    assert candidate(grid = [[0, 1, 1, 1, 1, 1, 0], [1, 0, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 1, 0, 1], [0, 1, 1, 1, 1, 0, 0]]) == 2\n    assert candidate(grid = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0]]) == 4\n    assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 0]]) == 6\n    assert candidate(grid = [[0, 1, 1, 1, 1, 0], [1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1], [0, 1, 1, 1, 0, 0]]) == 3\n    assert candidate(grid = [[0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 3\n    assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0]]) == 2\n    assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 1\n    assert candidate(grid = [[0, 0, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 2\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0, 1, 0], [1, 1, 1, 1, 0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == 0\n    assert candidate(grid = [[0, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n    assert candidate(grid = [[0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 0, 1, 1, 1], [1, 0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 0, 1, 1], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0]]) == 4\n    assert candidate(grid = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0]]) == 2\n    assert candidate(grid = [[0, 1, 1, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 0, 0], [1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0]]) == 0\n    assert candidate(grid = [[0, 1, 1, 1, 0], [1, 0, 1, 0, 1], [1, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 0, 1, 1, 0]]) == 3\n    assert candidate(grid = [[0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 0\n    assert candidate(grid = [[0, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 0]]) == 2\n    assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0]]) == 3\n    assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 1, 0, 0], [1, 1, 0, 1, 0, 1, 1], [0, 0, 0, 1, 0, 0, 0]]) == 1\n    assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0, 1, 0], [1, 1, 1, 1, 0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == 0\n    assert candidate(grid = [[0, 1, 1, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [1, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 1, 0, 0]]) == 1\n    assert candidate(grid = [[0, 1, 1, 1, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 0, 0, 0, 1, 0]]) == 1\n    assert candidate(grid = [[0, 1, 1, 0, 1, 0, 0, 1], [1, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 1, 1, 0, 1], [0, 1, 1, 0, 0, 1, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0]]) == 2\n    assert candidate(grid = [[0, 0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 0], [1, 1, 0, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0], [1, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 1\n    assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 5\n    assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 7\n    assert candidate(grid = [[0, 1, 1, 0, 0, 1, 0], [1, 1, 1, 1, 1, 0, 1], [0, 0, 1, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 1, 1, 0]]) == 3\n    assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0, 0, 1], [0, 1, 1, 1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n    assert candidate(grid = [[0, 1, 0, 0, 0, 0, 1, 0], [1, 0, 1, 1, 1, 1, 0, 1], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1, 0]]) == 3\n    assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 1, 1, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 1, 0, 1], [0, 1, 1, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0]]) == 4\n    assert candidate(grid = [[0, 1, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 2\n    assert candidate(grid = [[0, 1, 1, 1, 0, 0, 0], [1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0]]) == 2\n    assert candidate(grid = [[0, 1, 1, 1, 0], [1, 1, 0, 1, 0], [0, 1, 1, 1, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0]]) == 1\n    assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0]]) == 0\n    assert candidate(grid = [[0, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 0, 1, 1], [1, 1, 1, 0, 1], [0, 0, 0, 0, 0]]) == 3\n    assert candidate(grid = [[0, 1, 1, 1, 1, 1, 0], [1, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 1, 1], [0, 1, 1, 1, 1, 1, 0]]) == 4\n    assert candidate(grid = [[0, 1, 1, 1, 0, 1, 1, 0, 1, 1], [1, 0, 0, 1, 0, 1, 1, 1, 0, 1], [1, 1, 0, 1, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 1, 0, 0, 0, 0]]) == 3\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n    assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n    assert candidate(grid = [[0, 1, 1, 1, 1, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 1, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n    assert candidate(grid = [[0, 1, 0, 1, 0, 0, 0], [1, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0]]) == 1\n    assert candidate(grid = [[0, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1], [1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 0, 1], [1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == 4\n    assert candidate(grid = [[0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0], [0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 0\n", "comparison": "exact"}, "public_tests": ["[[0,1,1],[1,1,0],[1,1,0]]", "[[0,1,0,0,0],[0,1,0,1,0],[0,0,0,1,0]]"], "hints": ["Model the grid as a graph where cells are nodes and edges are between adjacent cells. Edges to cells with obstacles have a cost of 1 and all other edges have a cost of 0.", "Could you use 0-1 Breadth-First Search or Dijkstra’s algorithm?"], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minimumObstacles", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:45+00:00", "tests_total": 59, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["array", "breadth-first-search", "graph", "heap-priority-queue", "matrix", "shortest-path", "0-1-bfs", "dijkstra"]}, "language": "python", "interface": {"raw_signature": "def minimumObstacles(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "minimumObstacles", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2293, "task_id": "min-max-game", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums whose length is a power of 2.\n\nApply the following algorithm on nums:\n\n1. Let n be the length of nums. If n == 1, end the process. Otherwise, create a new 0-indexed integer array newNums of length n / 2.\n2. For every even index i where 0 <= i < n / 2, assign the value of newNums[i] as min(nums[2 * i], nums[2 * i + 1]).\n3. For every odd index i where 0 <= i < n / 2, assign the value of newNums[i] as max(nums[2 * i], nums[2 * i + 1]).\n4. Replace the array nums with newNums.\n5. Repeat the entire process starting from step 1.\n\nReturn the last number that remains in nums after applying the algorithm.\n\nExample 1:\n\nInput: nums = [1,3,5,2,4,8,2,2]\nOutput: 1\nExplanation: The following arrays are the results of applying the algorithm repeatedly.\nFirst: nums = [1,5,4,2]\nSecond: nums = [1,4]\nThird: nums = [1]\n1 is the last remaining number, so we return 1.\n\nExample 2:\n\nInput: nums = [3]\nOutput: 3\nExplanation: 3 is already the last remaining number, so we return 3.\n\nConstraints:\n\n- 1 <= nums.length <= 1024\n- 1 <= nums[i] <= 10^9\n- nums.length is a power of 2.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 3, 5, 2, 4, 8, 2, 2]) == 1\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1000000000\n    assert candidate(nums = [5, 1, 4, 2, 7, 6, 3, 8]) == 1\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993]) == 999999995\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 1\n    assert candidate(nums = [2, 7, 4, 1, 8, 1, 5, 6]) == 2\n    assert candidate(nums = [7, 5, 3, 1, 9, 11, 13, 15]) == 3\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 10\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [9, 11, 8, 7, 6, 5, 4, 3]) == 5\n    assert candidate(nums = [3]) == 3\n    assert candidate(nums = [7, 3, 2, 4, 9, 8, 5, 1]) == 3\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80]) == 10\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == 1\n    assert candidate(nums = [1024]) == 1024\n    assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996, 6, 999999995, 7, 999999994, 8, 999999993]) == 1\n    assert candidate(nums = [23, 45, 12, 67, 34, 89, 10, 20, 33, 56, 78, 90, 11, 22, 35, 46]) == 23\n    assert candidate(nums = [128, 256, 512, 1024, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 8\n    assert candidate(nums = [16, 8, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55]) == 4\n    assert candidate(nums = [5, 3, 8, 1, 6, 7, 2, 4, 9, 11, 10, 13, 15, 12, 14, 16]) == 3\n    assert candidate(nums = [9, 1, 7, 5, 3, 6, 4, 8, 2, 10, 11, 13, 12, 14, 15, 16]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 1\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55]) == 50\n    assert candidate(nums = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n    assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 3, 5, 7, 9, 11]) == 11\n    assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672]) == 42\n    assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 3, 5, 7, 9, 11]) == 11\n    assert candidate(nums = [13, 21, 7, 15, 2, 18, 10, 20, 23, 5, 3, 9, 22, 4, 8, 16, 19, 1, 17, 14, 12, 6, 11, 24, 111]) == 13\n    assert candidate(nums = [9, 3, 5, 7, 2, 8, 6, 4, 1, 10, 11, 12, 13, 14, 15, 16]) == 3\n    assert candidate(nums = [1000000000, 1, 1000000000, 2, 1000000000, 3, 1000000000, 4]) == 1\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64]) == 2\n    assert candidate(nums = [100, 200, 150, 50, 250, 125, 300, 75, 275, 62, 175, 87, 325, 43, 187, 91]) == 100\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3]) == 1\n    assert candidate(nums = [5, 15, 10, 20, 25, 35, 30, 40, 45, 55, 50, 60, 65, 75, 70, 80]) == 5\n    assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 11\n    assert candidate(nums = [987654321, 123456789, 198765432, 212345678, 398765432, 312345678, 498765432, 412345678]) == 123456789\n    assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 10, 15, 20, 25, 30, 35, 40]) == 1\n    assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29, 32, 31]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131]) == 2\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 5\n    assert candidate(nums = [1000000000, 999999999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 2\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 100\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640]) == 10\n    assert candidate(nums = [8, 3, 9, 2, 10, 7, 6, 5, 12, 11, 14, 13, 16, 15, 18, 17]) == 3\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == 2\n    assert candidate(nums = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431]) == 1023\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n    assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320]) == 10\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 1\n    assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 17, 18, 19, 20, 21]) == 21\n    assert candidate(nums = [9, 7, 5, 11, 13, 2, 8, 6, 4, 10, 12, 3, 1, 14, 15, 16]) == 7\n    assert candidate(nums = [33, 11, 44, 22, 55, 33, 66, 44, 77, 55, 88, 66, 99, 77, 110, 88]) == 11\n    assert candidate(nums = [32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11\n    assert candidate(nums = [2, 1, 3, 4, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15]) == 1\n    assert candidate(nums = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == 2\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985]) == 999999990\n    assert candidate(nums = [23, 45, 12, 67, 34, 89, 21, 56, 78, 90, 34, 23, 67, 89, 45, 12]) == 23\n    assert candidate(nums = [5, 8, 3, 9, 1, 7, 4, 2, 6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 4\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16]) == 4\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 90\n    assert candidate(nums = [1, 3, 2, 4, 7, 5, 9, 6, 11, 8, 10, 12, 15, 13, 14, 16, 19, 17, 18, 20, 23, 21, 22, 24, 27, 25, 26, 28, 31, 29, 30, 32]) == 1\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985]) == 990\n    assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1]) == 1\n    assert candidate(nums = [100, 200, 150, 50, 300, 250, 400, 10, 600, 550, 700, 20, 800, 750, 900, 30]) == 100\n    assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == 5\n    assert candidate(nums = [17, 23, 15, 29, 11, 31, 13, 37, 19, 41, 21, 43, 25, 47, 27, 49]) == 17\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 8\n    assert candidate(nums = [5, 2, 9, 1, 7, 3, 8, 4, 6, 10, 12, 11, 14, 13, 16, 15]) == 2\n    assert candidate(nums = [2, 1, 3, 4, 5, 6, 8, 7, 9, 10, 12, 11, 14, 13, 15, 16]) == 1\n    assert candidate(nums = [100, 50, 25, 75, 60, 30, 90, 40, 80, 10, 110, 120, 130, 140, 150, 160]) == 50\n    assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930, 313233, 343536, 373839, 404142, 434445, 464748]) == 123\n    assert candidate(nums = [9, 7, 5, 3, 2, 8, 6, 4, 1, 10, 12, 14, 16, 18, 20, 19]) == 5\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 21\n    assert candidate(nums = [17, 13, 21, 7, 11, 19, 23, 5, 15, 9, 25, 3, 27, 1, 29, 12]) == 13\n    assert candidate(nums = [100, 200, 150, 300, 50, 250, 20, 400, 10, 15, 30, 25, 60, 70, 80, 90]) == 90\n    assert candidate(nums = [64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32]) == 43\n    assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1]) == 1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64]) == 2\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 17, 18, 19, 20, 21, 22, 23]) == 4\n    assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == 5\n", "comparison": "exact"}, "public_tests": ["[1,3,5,2,4,8,2,2]", "[3]"], "hints": ["Simply simulate the algorithm.", "Note that the size of the array decreases exponentially, so the process will terminate after just O(log n) steps."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minMaxGame", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:49+00:00", "tests_total": 93, "tests_dropped": 4, "flags": ["has_images"], "topic_tags": ["array", "simulation"]}, "language": "python", "interface": {"raw_signature": "def minMaxGame(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minMaxGame", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2294, "task_id": "partition-array-such-that-maximum-difference-is-k", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer k. You may partition nums into one or more subsequences such that each element in nums appears in exactly one of the subsequences.\n\nReturn the minimum number of subsequences needed such that the difference between the maximum and minimum values in each subsequence is at most k.\n\nA subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.\n\nExample 1:\n\nInput: nums = [3,6,1,2,5], k = 2\nOutput: 2\nExplanation:\nWe can partition nums into the two subsequences [3,1,2] and [6,5].\nThe difference between the maximum and minimum value in the first subsequence is 3 - 1 = 2.\nThe difference between the maximum and minimum value in the second subsequence is 6 - 5 = 1.\nSince two subsequences were created, we return 2. It can be shown that 2 is the minimum number of subsequences needed.\n\nExample 2:\n\nInput: nums = [1,2,3], k = 1\nOutput: 2\nExplanation:\nWe can partition nums into the two subsequences [1,2] and [3].\nThe difference between the maximum and minimum value in the first subsequence is 2 - 1 = 1.\nThe difference between the maximum and minimum value in the second subsequence is 3 - 3 = 0.\nSince two subsequences were created, we return 2. Note that another optimal solution is to partition nums into the two subsequences [1] and [2,3].\n\nExample 3:\n\nInput: nums = [2,2,4,5], k = 0\nOutput: 3\nExplanation:\nWe can partition nums into the three subsequences [2,2], [4], and [5].\nThe difference between the maximum and minimum value in the first subsequences is 2 - 2 = 0.\nThe difference between the maximum and minimum value in the second subsequences is 4 - 4 = 0.\nThe difference between the maximum and minimum value in the third subsequences is 5 - 5 = 0.\nSince three subsequences were created, we return 3. It can be shown that 3 is the minimum number of subsequences needed.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= nums[i] <= 10^5\n- 0 <= k <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 100000],k = 99999) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 4\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 3\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 4\n    assert candidate(nums = [5, 5, 5, 5, 5],k = 0) == 1\n    assert candidate(nums = [1, 2, 3],k = 1) == 2\n    assert candidate(nums = [1, 3, 5, 7, 9],k = 1) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 5\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 5\n    assert candidate(nums = [3, 6, 1, 2, 5],k = 2) == 2\n    assert candidate(nums = [5, 5, 5, 5, 5],k = 1) == 1\n    assert candidate(nums = [2, 2, 4, 5],k = 0) == 3\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 4) == 1\n    assert candidate(nums = [5, 4, 3, 2, 1],k = 3) == 2\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 5\n    assert candidate(nums = [1, 100, 101, 200, 201, 300, 301],k = 1) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 2) == 9\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61],k = 4) == 8\n    assert candidate(nums = [5, 5, 5, 10, 10, 10, 15, 15, 15, 20, 20, 20, 25, 25, 25, 30, 30, 30, 35, 35, 35, 40, 40, 40, 45, 45, 45],k = 5) == 5\n    assert candidate(nums = [1, 101, 201, 301, 401, 501, 601, 701, 801, 901],k = 100) == 5\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 20) == 4\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 150) == 6\n    assert candidate(nums = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 11\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 10) == 7\n    assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009],k = 1) == 5\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 5\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 99) == 10\n    assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6],k = 1) == 5\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 15) == 5\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1000) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 2) == 9\n    assert candidate(nums = [3, 1, 2, 6, 5, 4, 9, 7, 8, 12, 10, 11, 15, 13, 14, 18, 16, 17, 21, 19, 20],k = 3) == 6\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 1) == 5\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 1) == 20\n    assert candidate(nums = [1, 100000, 2, 99999, 3, 99998],k = 99998) == 2\n    assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 6\n    assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100],k = 10) == 5\n    assert candidate(nums = [8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84],k = 4) == 10\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],k = 1) == 5\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 2) == 10\n    assert candidate(nums = [100, 105, 110, 115, 120, 125, 130, 135, 140, 145],k = 10) == 4\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 5\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 20) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 24) == 1\n    assert candidate(nums = [5, 8, 12, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 6\n    assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6],k = 1) == 3\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 10\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 200) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 4) == 4\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 1\n    assert candidate(nums = [1, 3, 6, 8, 10, 15, 18, 20, 22, 25],k = 4) == 5\n    assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 120, 131, 142, 153, 164],k = 11) == 8\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 1) == 5\n    assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],k = 3) == 5\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 4) == 6\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 2) == 10\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 2) == 8\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101],k = 4) == 13\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 4\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 1) == 3\n    assert candidate(nums = [1, 2, 3, 4, 5, 11, 12, 13, 14, 15, 21, 22, 23, 24, 25],k = 10) == 3\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 150) == 5\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 2) == 6\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 0) == 25\n    assert candidate(nums = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 3) == 6\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 1) == 5\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 2) == 8\n    assert candidate(nums = [1, 5, 9, 14, 18, 22, 26, 30],k = 4) == 5\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 10) == 10\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 0) == 1\n    assert candidate(nums = [1, 3, 6, 8, 10, 15, 18, 20, 25, 28],k = 3) == 6\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 25) == 5\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 50) == 10\n    assert candidate(nums = [5, 8, 3, 9, 1, 4, 7, 6, 2, 10],k = 3) == 3\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],k = 5) == 4\n    assert candidate(nums = [5, 1, 9, 3, 7, 11, 6, 4, 8, 2, 10, 12],k = 3) == 3\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 5\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],k = 4) == 10\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 10\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 15) == 8\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 2) == 7\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 3) == 7\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994],k = 3) == 2\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 169, 173, 177, 181, 185, 189, 193, 197],k = 4) == 25\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],k = 2) == 13\n    assert candidate(nums = [1, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 3) == 8\n    assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 10000) == 5\n    assert candidate(nums = [4, 8, 15, 16, 23, 42, 50, 55, 60, 65],k = 10) == 4\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 3) == 10\n    assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 11\n    assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10, 10, 10, 10, 10],k = 1) == 5\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],k = 5) == 9\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6],k = 1) == 3\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 7) == 5\n    assert candidate(nums = [5, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48],k = 5) == 6\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 0) == 10\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 10\n    assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120],k = 15) == 6\n    assert candidate(nums = [30, 40, 20, 50, 60, 10, 70, 80, 90, 100],k = 10) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 5\n    assert candidate(nums = [5, 2, 9, 1, 5, 6],k = 4) == 2\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 10) == 7\n    assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100],k = 9) == 6\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 1) == 20\n    assert candidate(nums = [15, 8, 20, 12, 18, 25, 5, 10, 30, 22],k = 5) == 4\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 4) == 7\n    assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 10) == 8\n", "comparison": "exact"}, "public_tests": ["[3,6,1,2,5]\n2", "[1,2,3]\n1", "[2,2,4,5]\n0"], "hints": ["Which values in each subsequence matter? The only values that matter are the maximum and minimum values.", "Let the maximum and minimum values of a subsequence be Max and Min. It is optimal to place all values in between Max and Min in the original array in the same subsequence as Max and Min.", "Sort the array."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().partitionArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:52+00:00", "tests_total": 112, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def partitionArray(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "partitionArray", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2295, "task_id": "replace-elements-in-an-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums that consists of n distinct positive integers. Apply m operations to this array, where in the i^th operation you replace the number operations[i][0] with operations[i][1].\n\nIt is guaranteed that in the i^th operation:\n\n- operations[i][0] exists in nums.\n- operations[i][1] does not exist in nums.\n\nReturn the array obtained after applying all the operations.\n\nExample 1:\n\nInput: nums = [1,2,4,6], operations = [[1,3],[4,7],[6,1]]\nOutput: [3,2,7,1]\nExplanation: We perform the following operations on nums:\n- Replace the number 1 with 3. nums becomes [3,2,4,6].\n- Replace the number 4 with 7. nums becomes [3,2,7,6].\n- Replace the number 6 with 1. nums becomes [3,2,7,1].\nWe return the final array [3,2,7,1].\n\nExample 2:\n\nInput: nums = [1,2], operations = [[1,3],[2,1],[3,2]]\nOutput: [2,1]\nExplanation: We perform the following operations to nums:\n- Replace the number 1 with 3. nums becomes [3,2].\n- Replace the number 2 with 1. nums becomes [3,1].\n- Replace the number 3 with 2. nums becomes [2,1].\nWe return the array [2,1].\n\nConstraints:\n\n- n == nums.length\n- m == operations.length\n- 1 <= n, m <= 10^5\n- All the values of nums are distinct.\n- operations[i].length == 2\n- 1 <= nums[i], operations[i][0], operations[i][1] <= 10^6\n- operations[i][0] will exist in nums when applying the i^th operation.\n- operations[i][1] will not exist in nums when applying the i^th operation.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 2],operations = [[1, 3], [2, 1], [3, 2]]) == [2, 1]\n    assert candidate(nums = [5, 3, 7, 8],operations = [[5, 10], [3, 15], [7, 20], [8, 25]]) == [10, 15, 20, 25]\n    assert candidate(nums = [1, 2, 3, 4, 5],operations = [[1, 5], [2, 4], [3, 3]]) == [5, 4, 3, 4, 5]\n    assert candidate(nums = [1, 2, 4, 6],operations = [[1, 3], [4, 7], [6, 1]]) == [3, 2, 7, 1]\n    assert candidate(nums = [100, 200, 300],operations = [[100, 150], [200, 250], [300, 350]]) == [150, 250, 350]\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65],operations = [[5, 1], [15, 2], [25, 3], [35, 4], [45, 5], [55, 6], [65, 7]]) == [1, 2, 3, 4, 5, 6, 7]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],operations = [[10, 110], [20, 220], [30, 330], [40, 440], [50, 550], [60, 660], [70, 770], [80, 880], [90, 990], [100, 1010]]) == [110, 220, 330, 440, 550, 660, 770, 880, 990, 1010]\n    assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120],operations = [[8, 1], [16, 2], [24, 3], [32, 4], [40, 5], [48, 6], [56, 7], [64, 8], [72, 9], [80, 10], [88, 11], [96, 12], [104, 13], [112, 14], [120, 15]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],operations = [[1, 15], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [11, 10], [12, 11], [13, 12], [14, 13]]) == [15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15]\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65],operations = [[5, 1], [15, 2], [25, 3], [35, 4], [45, 5], [55, 6], [65, 7]]) == [1, 2, 3, 4, 5, 6, 7]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],operations = [[10, 5], [20, 15], [30, 25], [40, 35], [50, 45], [60, 55], [70, 65], [80, 75], [90, 85], [100, 95]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]\n    assert candidate(nums = [1, 3, 5, 7, 9],operations = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [2, 4, 6, 8, 10]\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],operations = [[7, 1], [14, 2], [21, 3], [28, 4], [35, 5], [42, 6], [49, 7], [56, 8], [63, 9], [70, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000],operations = [[1000, 500], [2000, 1500], [3000, 2500], [4000, 3500], [5000, 4500]]) == [500, 1500, 2500, 3500, 4500]\n    assert candidate(nums = [1234, 5678, 91011, 121314, 151617],operations = [[1234, 1], [5678, 2], [91011, 3], [121314, 4], [151617, 5]]) == [1, 2, 3, 4, 5]\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],operations = [[7, 1], [14, 2], [21, 3], [28, 4], [35, 5], [42, 6], [49, 7], [56, 8], [63, 9], [70, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [7, 14, 21, 28, 35, 42],operations = [[7, 1], [14, 2], [21, 3], [28, 4], [35, 5], [42, 6]]) == [1, 2, 3, 4, 5, 6]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],operations = [[1, 16], [2, 17], [3, 18], [4, 19], [5, 20], [6, 21], [7, 22], [8, 23], [9, 24], [10, 25], [11, 26], [12, 27], [13, 28], [14, 29], [15, 30]]) == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n    assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],operations = [[100000, 1], [50000, 2], [25000, 3], [12500, 4], [6250, 5], [3125, 6], [1562, 7], [781, 8], [390, 9], [195, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],operations = [[1000000, 1], [999999, 2], [999998, 3], [999997, 4], [999996, 5]]) == [1, 2, 3, 4, 5]\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000],operations = [[1000, 1001], [2000, 2002], [3000, 3003], [4000, 4004], [5000, 5005]]) == [1001, 2002, 3003, 4004, 5005]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],operations = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19], [22, 21], [24, 23], [26, 25], [28, 27], [30, 29]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]\n    assert candidate(nums = [999, 998, 997, 996, 995],operations = [[999, 994], [998, 993], [997, 992], [996, 991], [995, 990]]) == [994, 993, 992, 991, 990]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],operations = [[1, 21], [2, 22], [3, 23], [4, 24], [5, 25], [6, 26], [7, 27], [8, 28], [9, 29], [10, 30], [11, 31], [12, 32], [13, 33], [14, 34], [15, 35], [16, 36], [17, 37], [18, 38], [19, 39], [20, 40]]) == [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n    assert candidate(nums = [5, 10, 15, 20, 25],operations = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5]]) == [1, 2, 3, 4, 5]\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000],operations = [[1000, 1001], [2000, 2001], [3000, 3001], [4000, 4001], [5000, 5001], [6000, 6001]]) == [1001, 2001, 3001, 4001, 5001, 6001]\n    assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],operations = [[1000000, 999999], [500000, 499999], [250000, 249999], [125000, 124999], [62500, 62499], [31250, 31249], [15625, 15624], [7812, 7811], [3906, 3905], [1953, 1952]]) == [999999, 499999, 249999, 124999, 62499, 31249, 15624, 7811, 3905, 1952]\n    assert candidate(nums = [1, 3, 5, 7, 9],operations = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [2, 4, 6, 8, 10]\n    assert candidate(nums = [5, 3, 8, 9, 10],operations = [[5, 6], [3, 4], [8, 5], [9, 8], [10, 9]]) == [6, 4, 5, 8, 9]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],operations = [[10, 11], [20, 21], [30, 31], [40, 41], [50, 51], [60, 61], [70, 71], [80, 81], [90, 91], [100, 101]]) == [11, 21, 31, 41, 51, 61, 71, 81, 91, 101]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],operations = [[1, 21], [2, 22], [3, 23], [4, 24], [5, 25], [6, 26], [7, 27], [8, 28], [9, 29], [10, 30], [11, 31], [12, 32], [13, 33], [14, 34], [15, 35], [16, 36], [17, 37], [18, 38], [19, 39], [20, 40]]) == [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],operations = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 11]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 11]\n    assert candidate(nums = [9999, 8888, 7777, 6666, 5555],operations = [[9999, 10000], [8888, 11111], [7777, 12222], [6666, 13333], [5555, 14444]]) == [10000, 11111, 12222, 13333, 14444]\n    assert candidate(nums = [500000, 1, 500001, 2, 500002],operations = [[500000, 3], [1, 4], [500001, 5], [2, 6], [500002, 7]]) == [3, 4, 5, 6, 7]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60],operations = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65]]) == [15, 25, 35, 45, 55, 65]\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121],operations = [[11, 12], [22, 14], [33, 16], [44, 18], [55, 20], [66, 22], [77, 24], [88, 26], [99, 28], [110, 30], [121, 32]]) == [12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]\n    assert candidate(nums = [7, 14, 21, 28, 35, 42],operations = [[7, 1], [14, 2], [21, 3], [28, 4], [35, 5], [42, 6]]) == [1, 2, 3, 4, 5, 6]\n    assert candidate(nums = [12, 34, 56, 78, 90, 123, 456],operations = [[12, 11], [34, 33], [56, 55], [78, 77], [90, 89], [123, 122], [456, 455]]) == [11, 33, 55, 77, 89, 122, 455]\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56],operations = [[7, 15], [14, 7], [21, 14], [28, 21], [35, 28], [42, 35], [49, 42], [56, 49]]) == [15, 7, 14, 21, 28, 35, 42, 49]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],operations = [[10, 5], [20, 15], [30, 25], [40, 35], [50, 45], [60, 55], [70, 65], [80, 75], [90, 85], [100, 95]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],operations = [[9, 18], [8, 16], [7, 14], [6, 12], [5, 10], [4, 8], [3, 6], [2, 4], [1, 2]]) == [18, 16, 14, 12, 10, 8, 6, 4, 2]\n    assert candidate(nums = [5, 3, 8, 9, 2],operations = [[5, 15], [3, 10], [8, 18], [9, 19], [2, 12]]) == [15, 10, 18, 19, 12]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],operations = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n    assert candidate(nums = [5, 3, 8, 9, 2, 6],operations = [[5, 10], [3, 5], [8, 3], [9, 8], [2, 9], [6, 2]]) == [10, 5, 3, 8, 9, 2]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],operations = [[100, 110], [200, 120], [300, 130], [400, 140], [500, 150], [600, 160], [700, 170], [800, 180], [900, 190], [1000, 200], [1100, 210], [1200, 220], [1300, 230], [1400, 240], [1500, 250]]) == [110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]\n    assert candidate(nums = [1, 100000],operations = [[1, 50000], [100000, 99999]]) == [50000, 99999]\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000],operations = [[1000, 1100], [2000, 2200], [3000, 3300], [4000, 4400], [5000, 5500]]) == [1100, 2200, 3300, 4400, 5500]\n    assert candidate(nums = [5, 15, 25, 35, 45, 55],operations = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60]]) == [10, 20, 30, 40, 50, 60]\n    assert candidate(nums = [10, 20, 30, 40, 50],operations = [[10, 5], [20, 15], [30, 25], [40, 35], [50, 45]]) == [5, 15, 25, 35, 45]\n    assert candidate(nums = [1, 1000000],operations = [[1, 2], [1000000, 1]]) == [2, 1]\n    assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],operations = [[100000, 200000], [50000, 100000], [25000, 50000], [12500, 25000], [6250, 12500], [3125, 6250], [1562, 3125], [781, 1562], [390, 781], [195, 390]]) == [200000, 100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],operations = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30],operations = [[5, 4], [10, 9], [15, 8], [20, 7], [25, 6], [30, 5]]) == [4, 9, 8, 7, 6, 5]\n    assert candidate(nums = [7, 11, 13, 17, 19],operations = [[7, 10], [11, 12], [13, 14], [17, 15], [19, 16]]) == [10, 12, 14, 15, 16]\n    assert candidate(nums = [10, 20, 30, 40, 50],operations = [[10, 15], [30, 35], [50, 55], [20, 25], [40, 45]]) == [15, 25, 35, 45, 55]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],operations = [[1, 20], [3, 21], [5, 22], [7, 23], [9, 24], [11, 25], [13, 26], [15, 27], [17, 28], [19, 29]]) == [20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\n    assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],operations = [[1000000, 1], [999999, 2], [999998, 3], [999997, 4], [999996, 5]]) == [1, 2, 3, 4, 5]\n    assert candidate(nums = [10, 20, 30, 40, 50],operations = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55]]) == [15, 25, 35, 45, 55]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],operations = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n    assert candidate(nums = [5, 3, 9, 11, 13],operations = [[3, 4], [9, 10], [11, 12], [13, 14], [5, 6]]) == [6, 4, 10, 12, 14]\n    assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],operations = [[99, 100], [98, 101], [97, 102], [96, 103], [95, 104], [94, 105], [93, 106], [92, 107], [91, 108], [90, 109]]) == [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 111, 222, 333, 444, 555, 666, 777, 888, 999],operations = [[11, 1], [22, 2], [33, 3], [44, 4], [55, 5], [66, 6], [77, 7], [88, 8], [99, 9], [111, 10], [222, 11], [333, 12], [444, 13], [555, 14], [666, 15], [777, 16], [888, 17], [999, 18]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]\n    assert candidate(nums = [7, 17, 27, 37, 47, 57],operations = [[7, 8], [17, 18], [27, 28], [37, 38], [47, 48], [57, 58]]) == [8, 18, 28, 38, 48, 58]\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000],operations = [[1000, 1001], [2000, 2002], [3000, 3003], [4000, 4004], [5000, 5005], [6000, 6006]]) == [1001, 2002, 3003, 4004, 5005, 6006]\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000],operations = [[1000, 500], [2000, 1000], [3000, 1500], [4000, 2000], [5000, 2500], [6000, 3000], [7000, 3500], [8000, 4000], [9000, 4500]]) == [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],operations = [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21]]) == [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]\n    assert candidate(nums = [29, 13, 11, 14, 23, 25, 9, 22, 19, 30, 28, 21, 17, 26, 18, 24, 27, 16, 12, 31, 10, 15, 8, 20, 7, 6, 5, 4, 3, 2, 1],operations = [[29, 32], [13, 33], [11, 34], [14, 35], [23, 36], [25, 37], [9, 38], [22, 39], [19, 40], [30, 41], [28, 42], [21, 43], [17, 44], [26, 45], [18, 46], [24, 47], [27, 48], [16, 49], [12, 50], [31, 51], [10, 52], [15, 53], [8, 54], [20, 55], [7, 56], [6, 57], [5, 58], [4, 59], [3, 60], [2, 61], [1, 62]]) == [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62]\n    assert candidate(nums = [99, 199, 299, 399, 499, 599],operations = [[99, 100], [199, 200], [299, 300], [399, 400], [499, 500], [599, 600]]) == [100, 200, 300, 400, 500, 600]\n    assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],operations = [[5, 10], [3, 11], [8, 12], [6, 13], [2, 14], [7, 15], [4, 16], [1, 17]]) == [10, 11, 12, 13, 14, 15, 16, 17]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],operations = [[1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20]]) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n    assert candidate(nums = [1000000, 500000, 250000, 125000, 62500],operations = [[1000000, 999999], [500000, 1000000], [250000, 500000], [125000, 250000], [62500, 125000]]) == [999999, 1000000, 500000, 250000, 125000]\n    assert candidate(nums = [9, 7, 5, 3, 1],operations = [[9, 10], [7, 8], [5, 6], [3, 4], [1, 2]]) == [10, 8, 6, 4, 2]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60],operations = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65]]) == [15, 25, 35, 45, 55, 65]\n    assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],operations = [[999999, 999989], [999998, 999988], [999997, 999987], [999996, 999986], [999995, 999985], [999994, 999984], [999993, 999983], [999992, 999982], [999991, 999981], [999990, 999980]]) == [999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981, 999980]\n    assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],operations = [[10000, 5000], [20000, 10000], [30000, 15000], [40000, 20000], [50000, 25000], [60000, 30000], [70000, 35000], [80000, 40000], [90000, 45000], [100000, 50000]]) == [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000]\n", "comparison": "exact"}, "public_tests": ["[1,2,4,6]\n[[1,3],[4,7],[6,1]]", "[1,2]\n[[1,3],[2,1],[3,2]]"], "hints": ["Can you think of a data structure that will allow you to store the position of each number?", "Use that data structure to instantly replace a number with its new value."], "metadata": {"canonical_parameter_names": ["nums", "operations"], "leetcode_dataset_entry_point": "Solution().arrayChange", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:47:54+00:00", "tests_total": 76, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "simulation"]}, "language": "python", "interface": {"raw_signature": "def arrayChange(self, nums: list[int], operations: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "arrayChange", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "operations", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2300, "task_id": "successful-pairs-of-spells-and-potions", "difficulty": "Medium", "problem_description": "You are given two positive integer arrays spells and potions, of length n and m respectively, where spells[i] represents the strength of the i^th spell and potions[j] represents the strength of the j^th potion.\n\nYou are also given an integer success. A spell and potion pair is considered successful if the product of their strengths is at least success.\n\nReturn an integer array pairs of length n where pairs[i] is the number of potions that will form a successful pair with the i^th spell.\n\nExample 1:\n\nInput: spells = [5,1,3], potions = [1,2,3,4,5], success = 7\nOutput: [4,0,3]\nExplanation:\n- 0^th spell: 5 * [1,2,3,4,5] = [5,10,15,20,25]. 4 pairs are successful.\n- 1^st spell: 1 * [1,2,3,4,5] = [1,2,3,4,5]. 0 pairs are successful.\n- 2^nd spell: 3 * [1,2,3,4,5] = [3,6,9,12,15]. 3 pairs are successful.\nThus, [4,0,3] is returned.\n\nExample 2:\n\nInput: spells = [3,1,2], potions = [8,5,8], success = 16\nOutput: [2,0,2]\nExplanation:\n- 0^th spell: 3 * [8,5,8] = [24,15,24]. 2 pairs are successful.\n- 1^st spell: 1 * [8,5,8] = [8,5,8]. 0 pairs are successful.\n- 2^nd spell: 2 * [8,5,8] = [16,10,16]. 2 pairs are successful.\nThus, [2,0,2] is returned.\n\nConstraints:\n\n- n == spells.length\n- m == potions.length\n- 1 <= n, m <= 10^5\n- 1 <= spells[i], potions[i] <= 10^5\n- 1 <= success <= 10^10\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(spells = [3, 1, 2],potions = [8, 5, 8],success = 16) == [2, 0, 2]\n    assert candidate(spells = [1, 1, 1],potions = [1, 1, 1],success = 2) == [0, 0, 0]\n    assert candidate(spells = [5, 1, 3],potions = [1, 2, 3, 4, 5],success = 7) == [4, 0, 3]\n    assert candidate(spells = [1, 2, 3, 4, 5],potions = [5, 4, 3, 2, 1],success = 10) == [0, 1, 2, 3, 4]\n    assert candidate(spells = [10, 20, 30],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 50) == [6, 8, 9]\n    assert candidate(spells = [100000, 100000, 100000],potions = [100000, 100000, 100000],success = 10000000000) == [3, 3, 3]\n    assert candidate(spells = [10, 20, 30],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 100) == [1, 6, 7]\n    assert candidate(spells = [1, 1, 1],potions = [1, 1, 1, 1],success = 1) == [4, 4, 4]\n    assert candidate(spells = [10, 10, 10],potions = [1, 1, 1, 1, 1],success = 100) == [0, 0, 0]\n    assert candidate(spells = [1, 1, 1, 1],potions = [1, 1, 1, 1],success = 1) == [4, 4, 4, 4]\n    assert candidate(spells = [1, 2, 3, 4, 5],potions = [5, 4, 3, 2, 1],success = 6) == [0, 3, 4, 4, 4]\n    assert candidate(spells = [10, 20, 30],potions = [5, 10, 15, 20],success = 100) == [3, 4, 4]\n    assert candidate(spells = [100000],potions = [100000],success = 10000000000) == [1]\n    assert candidate(spells = [100, 200, 300, 400, 500],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],success = 500) == [11, 13, 14, 14, 15]\n    assert candidate(spells = [99999, 99998, 99997, 99996, 99995],potions = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991],success = 4999750005) == [2, 2, 1, 1, 0]\n    assert candidate(spells = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],potions = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],success = 100000) == [1, 6, 7, 8, 9, 9, 9, 9, 9, 10]\n    assert candidate(spells = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 10000000000) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(spells = [99999, 99998, 99997, 99996, 99995],potions = [100000, 99999, 99998, 99997, 99996, 99995],success = 9999900000) == [1, 0, 0, 0, 0]\n    assert candidate(spells = [1, 1, 1, 1, 1],potions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],success = 2) == [0, 0, 0, 0, 0]\n    assert candidate(spells = [1, 1, 1, 1, 1],potions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],success = 1) == [10, 10, 10, 10, 10]\n    assert candidate(spells = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],potions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],success = 50) == [6, 8, 9, 9, 10, 10, 10, 10, 10, 10]\n    assert candidate(spells = [1, 10, 100, 1000, 10000],potions = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000],success = 10000) == [0, 1, 4, 7, 10]\n    assert candidate(spells = [1, 3, 5, 7, 9],potions = [11, 13, 15, 17, 19, 21, 23, 25, 27, 29],success = 50) == [0, 7, 10, 10, 10]\n    assert candidate(spells = [2, 4, 6, 8, 10],potions = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],success = 100) == [1, 6, 7, 8, 9]\n    assert candidate(spells = [100, 200, 300, 400, 500],potions = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],success = 5000) == [10, 16, 19, 20, 21]\n    assert candidate(spells = [5, 10, 15, 20, 25],potions = [20, 25, 30, 35, 40, 45, 50, 55, 60],success = 500) == [0, 3, 6, 8, 9]\n    assert candidate(spells = [1000, 2000, 3000, 4000, 5000],potions = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],success = 10000) == [9, 10, 10, 10, 10]\n    assert candidate(spells = [5, 10, 15, 20, 25],potions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],success = 50) == [5, 8, 8, 9, 9]\n    assert candidate(spells = [1, 2, 3, 4, 5],potions = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],success = 100000) == [0, 10, 10, 10, 10]\n    assert candidate(spells = [9, 8, 7, 6, 5],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9],success = 20) == [7, 7, 7, 6, 6]\n    assert candidate(spells = [100, 200, 300, 400, 500],potions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],success = 100) == [10, 10, 10, 10, 10]\n    assert candidate(spells = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],potions = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],success = 250) == [1, 6, 7, 8, 9, 9, 9, 9, 9, 10]\n    assert candidate(spells = [50000, 50000, 50000, 50000],potions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],success = 100000) == [10, 10, 10, 10]\n    assert candidate(spells = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],potions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],success = 2500) == [0, 0, 2, 4, 6, 6, 7, 7, 8, 8]\n    assert candidate(spells = [50000, 25000, 12500],potions = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],success = 625000000) == [9, 8, 6]\n    assert candidate(spells = [1, 2, 3, 4, 5],potions = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],success = 25) == [6, 8, 9, 9, 10]\n    assert candidate(spells = [100000, 90000, 80000],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 500000) == [6, 5, 4]\n    assert candidate(spells = [1, 1, 1, 1, 1],potions = [100000, 100000, 100000, 100000, 100000],success = 100000) == [5, 5, 5, 5, 5]\n    assert candidate(spells = [10000, 20000, 30000, 40000, 50000],potions = [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000],success = 200000000) == [7, 9, 9, 10, 10]\n    assert candidate(spells = [10000, 5000, 2500],potions = [5000, 10000, 15000, 20000, 25000],success = 100000000) == [4, 2, 0]\n    assert candidate(spells = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],potions = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],success = 1000000) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n    assert candidate(spells = [5, 15, 25, 35, 45],potions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],success = 100) == [1, 7, 9, 9, 9]\n    assert candidate(spells = [100000, 100000, 100000, 100000],potions = [100000, 100000, 100000, 100000, 100000],success = 10000000000) == [5, 5, 5, 5]\n    assert candidate(spells = [5, 5, 5, 5, 5],potions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],success = 6) == [0, 0, 0, 0, 0]\n    assert candidate(spells = [1, 3, 5, 7, 9],potions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],success = 18) == [2, 8, 9, 9, 10]\n    assert candidate(spells = [1, 1, 1, 1, 1],potions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],success = 1) == [21, 21, 21, 21, 21]\n    assert candidate(spells = [3, 3, 3, 3, 3],potions = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],success = 10) == [0, 0, 0, 0, 0]\n    assert candidate(spells = [1, 3, 5, 7, 9],potions = [9, 7, 5, 3, 1],success = 15) == [0, 3, 4, 4, 4]\n    assert candidate(spells = [9, 7, 5, 3, 1],potions = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2],success = 50) == [8, 7, 6, 2, 0]\n    assert candidate(spells = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],potions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],success = 20) == [1, 7, 9, 9, 9, 10, 10, 10, 10, 10]\n    assert candidate(spells = [99999, 99998, 99997, 99996, 99995],potions = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],success = 9999500000) == [0, 0, 0, 0, 0]\n    assert candidate(spells = [50, 25, 10, 2],potions = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],success = 5000) == [4, 3, 2, 0]\n    assert candidate(spells = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],potions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],success = 10) == [1, 6, 7, 8, 9, 9, 9, 9, 9, 10]\n    assert candidate(spells = [1000, 2000, 3000, 4000, 5000],potions = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],success = 5000000) == [0, 0, 0, 0, 10]\n    assert candidate(spells = [99999, 99998, 99997, 99996, 99995],potions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],success = 9999500000) == [0, 0, 0, 0, 0]\n    assert candidate(spells = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],potions = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],success = 100000) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n    assert candidate(spells = [5, 5, 5, 5, 5],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 25) == [6, 6, 6, 6, 6]\n    assert candidate(spells = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],potions = [100, 200, 300, 400, 500],success = 5000) == [0, 0, 0, 0, 1, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n    assert candidate(spells = [100, 200, 300, 400, 500],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],success = 1000) == [11, 16, 17, 18, 19]\n    assert candidate(spells = [100000, 90000, 80000],potions = [100000, 90000, 80000, 70000, 60000],success = 8100000000) == [2, 2, 0]\n    assert candidate(spells = [1, 1, 1, 1, 1],potions = [100000, 100000, 100000, 100000, 100000],success = 50000) == [5, 5, 5, 5, 5]\n    assert candidate(spells = [1, 3, 5, 7, 9],potions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],success = 15) == [3, 8, 9, 9, 10]\n    assert candidate(spells = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],potions = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],success = 1000000) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n    assert candidate(spells = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],success = 1000) == [1, 11, 14, 16, 17, 17, 18, 18, 18, 19]\n    assert candidate(spells = [100000, 1, 50000, 10000],potions = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],success = 10000000000) == [1, 0, 0, 0]\n    assert candidate(spells = [1, 1, 1, 1, 1],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 10) == [1, 1, 1, 1, 1]\n    assert candidate(spells = [99999, 99998, 99997, 99996, 99995],potions = [1, 10, 100, 1000, 10000, 100000],success = 9999500000) == [1, 1, 1, 1, 1]\n    assert candidate(spells = [9, 8, 7, 6, 5, 4, 3, 2, 1],potions = [9, 8, 7, 6, 5, 4, 3, 2, 1],success = 36) == [6, 5, 4, 4, 2, 1, 0, 0, 0]\n    assert candidate(spells = [99999, 99998, 99997, 99996, 99995],potions = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],success = 9999800001) == [1, 0, 0, 0, 0]\n    assert candidate(spells = [50, 25, 100, 1],potions = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],success = 1000) == [6, 5, 7, 1]\n    assert candidate(spells = [10, 20, 30, 40, 50],potions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],success = 150) == [3, 7, 8, 9, 9]\n    assert candidate(spells = [100000, 90000, 80000, 70000, 60000],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 54000000) == [0, 0, 0, 0, 0]\n    assert candidate(spells = [100000, 1, 99999],potions = [1, 100000, 99999, 50000, 25000],success = 9999999999) == [1, 0, 0]\n    assert candidate(spells = [100000, 100000, 100000],potions = [100000, 100000, 100000, 100000, 100000],success = 10000000000) == [5, 5, 5]\n    assert candidate(spells = [5, 10, 15, 20, 25],potions = [20, 25, 30, 35, 40, 45, 50, 55, 60, 65],success = 800) == [0, 0, 3, 6, 7]\n    assert candidate(spells = [50, 40, 30, 20, 10],potions = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],success = 200) == [10, 10, 9, 9, 7]\n    assert candidate(spells = [100000, 50000, 25000],potions = [1, 10, 100, 1000, 10000, 100000],success = 10000000000) == [1, 0, 0]\n    assert candidate(spells = [100, 200, 300, 400, 500],potions = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],success = 1500) == [3, 7, 8, 9, 9]\n    assert candidate(spells = [50, 50, 50, 50, 50],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],success = 250) == [16, 16, 16, 16, 16]\n    assert candidate(spells = [99999, 99998, 99997],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 9999800000) == [0, 0, 0]\n    assert candidate(spells = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],potions = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],success = 1024) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(spells = [100000, 50000, 25000, 12500],potions = [1, 10, 100, 1000, 10000, 100000],success = 10000000000) == [1, 0, 0, 0]\n    assert candidate(spells = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 50) == [0, 0, 0, 0, 1, 2, 3, 4, 5, 6]\n    assert candidate(spells = [10, 20, 30, 40, 50],potions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],success = 50) == [6, 8, 9, 9, 10]\n", "comparison": "exact"}, "public_tests": ["[5,1,3]\n[1,2,3,4,5]\n7", "[3,1,2]\n[8,5,8]\n16"], "hints": ["Notice that if a spell and potion pair is successful, then the spell and all stronger potions will be successful too.", "Thus, for each spell, we need to find the potion with the least strength that will form a successful pair.", "We can efficiently do this by sorting the potions based on strength and using binary search."], "metadata": {"canonical_parameter_names": ["spells", "potions", "success"], "leetcode_dataset_entry_point": "Solution().successfulPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:01+00:00", "tests_total": 96, "tests_dropped": 12, "flags": [], "topic_tags": ["array", "two-pointers", "binary-search", "sorting"]}, "language": "python", "interface": {"raw_signature": "def successfulPairs(self, spells: list[int], potions: list[int], success: int) -> list[int]:", "container": "Solution", "callable": "successfulPairs", "parameters": [{"name": "spells", "type": "list[int]"}, {"name": "potions", "type": "list[int]"}, {"name": "success", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2301, "task_id": "match-substring-after-replacement", "difficulty": "Hard", "problem_description": "You are given two strings s and sub. You are also given a 2D character array mappings where mappings[i] = [old_i, new_i] indicates that you may perform the following operation any number of times:\n\n- Replace a character old_i of sub with new_i.\n\nEach character in sub cannot be replaced more than once.\n\nReturn true if it is possible to make sub a substring of s by replacing zero or more characters according to mappings. Otherwise, return false.\n\nA substring is a contiguous non-empty sequence of characters within a string.\n\nExample 1:\n\nInput: s = \"fool3e7bar\", sub = \"leet\", mappings = [[\"e\",\"3\"],[\"t\",\"7\"],[\"t\",\"8\"]]\nOutput: true\nExplanation: Replace the first 'e' in sub with '3' and 't' in sub with '7'.\nNow sub = \"l3e7\" is a substring of s, so we return true.\n\nExample 2:\n\nInput: s = \"fooleetbar\", sub = \"f00l\", mappings = [[\"o\",\"0\"]]\nOutput: false\nExplanation: The string \"f00l\" is not a substring of s and no replacements can be made.\nNote that we cannot replace '0' with 'o'.\n\nExample 3:\n\nInput: s = \"Fool33tbaR\", sub = \"leetd\", mappings = [[\"e\",\"3\"],[\"t\",\"7\"],[\"t\",\"8\"],[\"d\",\"b\"],[\"p\",\"b\"]]\nOutput: true\nExplanation: Replace the first and second 'e' in sub with '3' and 'd' in sub with 'b'.\nNow sub = \"l33tb\" is a substring of s, so we return true.\n\nConstraints:\n\n- 1 <= sub.length <= s.length <= 5000\n- 0 <= mappings.length <= 1000\n- mappings[i].length == 2\n- old_i != new_i\n- s and sub consist of uppercase and lowercase English letters and digits.\n- old_i and new_i are either uppercase or lowercase English letters or digits.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"fooleetbar\",sub = \"f00l\",mappings = [['o', '0']]) == False\n    assert candidate(s = \"fool3e7bar\",sub = \"leet\",mappings = [['e', '3'], ['t', '7'], ['t', '8']]) == True\n    assert candidate(s = \"Fool33tbaR\",sub = \"leetd\",mappings = [['e', '3'], ['t', '7'], ['t', '8'], ['d', 'b'], ['p', 'b']]) == True\n    assert candidate(s = \"1234567890\",sub = \"120\",mappings = [['3', '4'], ['5', '6'], ['7', '8'], ['9', '0']]) == False\n    assert candidate(s = \"thisisaverylongstringwithmanycharacters\",sub = \"thisisaverylongstringwithmanychar1\",mappings = [['a', '1']]) == False\n    assert candidate(s = \"abcABC123\",sub = \"aBc12\",mappings = [['a', 'A'], ['b', 'B'], ['c', 'C'], ['1', '2'], ['2', '3']]) == True\n    assert candidate(s = \"A1B2C3D4E5F6G7H8I9J0\",sub = \"abcdefghij\",mappings = [['1', 'a'], ['2', 'b'], ['3', 'c'], ['4', 'd'], ['5', 'e'], ['6', 'f'], ['7', 'g'], ['8', 'h'], ['9', 'i'], ['0', 'j']]) == False\n    assert candidate(s = \"AaBbCc\",sub = \"abc\",mappings = [['A', 'a'], ['B', 'b'], ['C', 'c']]) == False\n    assert candidate(s = \"UPPERlower\",sub = \"lower\",mappings = [['U', 'l'], ['P', 'o'], ['E', 'w'], ['R', 'r']]) == True\n    assert candidate(s = \"12345678901234567890\",sub = \"13579\",mappings = [['1', '2'], ['3', '4'], ['5', '6'], ['7', '8'], ['9', '0']]) == False\n    assert candidate(s = \"xyzuvw\",sub = \"xyzz\",mappings = [['z', 'w'], ['z', 'u']]) == True\n    assert candidate(s = \"aaaaaaa\",sub = \"aaab\",mappings = [['a', 'b']]) == False\n    assert candidate(s = \"aaaaabbbbcccc\",sub = \"abc\",mappings = [['a', 'b'], ['b', 'c'], ['c', 'a']]) == True\n    assert candidate(s = \"1234567890qwertyuiopasdfghjklzxcvbnm\",sub = \"QWERTYUIOPASDFGHJKLZXCVBNM\",mappings = [['q', 'Q'], ['w', 'W'], ['e', 'E'], ['r', 'R'], ['t', 'T'], ['y', 'Y'], ['u', 'U'], ['i', 'I'], ['o', 'O'], ['p', 'P'], ['a', 'A'], ['s', 'S'], ['d', 'D'], ['f', 'F'], ['g', 'G'], ['h', 'H'], ['j', 'J'], ['k', 'K'], ['l', 'L'], ['z', 'Z'], ['x', 'X'], ['c', 'C'], ['v', 'V'], ['b', 'B'], ['n', 'N'], ['m', 'M']]) == False\n    assert candidate(s = \"1234567890abcdefghijklmnopqrstuvwxyz\",sub = \"123abc\",mappings = [['1', 'a'], ['2', 'b'], ['3', 'c'], ['a', '1'], ['b', '2'], ['c', '3']]) == False\n    assert candidate(s = \"mississippi\",sub = \"misp\",mappings = [['i', 's'], ['s', 'i']]) == False\n    assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789\",sub = \"abcdef\",mappings = [['a', 'A'], ['b', 'B'], ['c', 'C'], ['d', 'D'], ['e', 'E'], ['f', 'F'], ['0', 'a'], ['1', 'b']]) == False\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",sub = \"zzzzzzzzzzzzzzzz\",mappings = []) == True\n    assert candidate(s = \"PythonProgrammingIsFun\",sub = \"PythnPrgrammngIsFn\",mappings = [['o', '0'], ['r', '4'], ['g', '9'], ['m', 'n'], ['n', 'm'], ['u', '1']]) == False\n    assert candidate(s = \"abcXYZabcXYZabc\",sub = \"XYZ\",mappings = [['X', 'a'], ['Y', 'b'], ['Z', 'c']]) == True\n    assert candidate(s = \"abcXYZ123defGHI456\",sub = \"xyz\",mappings = [['x', 'X'], ['y', 'Y'], ['z', 'Z']]) == True\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",sub = \"mnoPQR\",mappings = [['m', 'M'], ['n', 'N'], ['o', 'O'], ['p', 'P'], ['q', 'Q'], ['r', 'R'], ['s', 'S'], ['t', 'T']]) == False\n    assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\",sub = \"qwertyuiopasdfghjklzxcvbnm\",mappings = [['Q', 'q'], ['W', 'w'], ['E', 'e'], ['R', 'r'], ['T', 't'], ['Y', 'y'], ['U', 'u'], ['I', 'i'], ['O', 'o'], ['P', 'p'], ['A', 'a'], ['S', 's'], ['D', 'd'], ['F', 'f'], ['G', 'g'], ['H', 'h'], ['J', 'j'], ['K', 'k'], ['L', 'l'], ['Z', 'z'], ['X', 'x'], ['C', 'c'], ['V', 'v'], ['B', 'b'], ['N', 'n'], ['M', 'm']]) == False\n    assert candidate(s = \"xyzabcxyz\",sub = \"zyx\",mappings = [['x', 'y'], ['y', 'z'], ['z', 'x']]) == False\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz0123456789\",sub = \"zyxwvutsrqp\",mappings = [['z', '9'], ['y', '8'], ['x', '7'], ['w', '6'], ['v', '5'], ['u', '4'], ['t', '3'], ['s', '2'], ['r', '1'], ['q', '0']]) == False\n    assert candidate(s = \"aabbccddeeff\",sub = \"abc\",mappings = [['a', 'b'], ['b', 'c'], ['c', 'd']]) == True\n    assert candidate(s = \"9876543210\",sub = \"123\",mappings = [['1', '9'], ['2', '8'], ['3', '7']]) == True\n    assert candidate(s = \"mississippi\",sub = \"miss\",mappings = [['m', 'i'], ['i', 's'], ['s', 'p']]) == True\n    assert candidate(s = \"mississippi\",sub = \"MISS\",mappings = [['m', 'M'], ['i', 'I'], ['s', 'S']]) == False\n    assert candidate(s = \"ababababababab\",sub = \"AB\",mappings = [['a', 'A'], ['b', 'B']]) == False\n    assert candidate(s = \"nestedparentheses\",sub = \"nest1dpar3ntheses\",mappings = [['e', '1'], ['o', '3']]) == False\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",sub = \"aaaaaaaaaa\",mappings = [['z', 'a']]) == False\n    assert candidate(s = \"abcabcabcabcabcabc\",sub = \"abababa\",mappings = [['a', 'b'], ['b', 'a']]) == False\n    assert candidate(s = \"MULTIPLEMAPPINGS\",sub = \"MAPPING\",mappings = [['M', 'N'], ['A', 'B'], ['P', 'Q'], ['I', 'J'], ['G', 'H']]) == True\n    assert candidate(s = \"12345678901234567890\",sub = \"111111\",mappings = [['1', '2'], ['2', '3'], ['3', '4'], ['4', '5'], ['5', '6'], ['6', '7']]) == False\n    assert candidate(s = \"abracadabra123\",sub = \"acad\",mappings = [['a', '1'], ['d', '3'], ['a', 'b']]) == True\n    assert candidate(s = \"TheQuickBrownFox\",sub = \"TheQucikBrwnFks\",mappings = [['u', 'i'], ['i', 'k'], ['B', 'r'], ['r', 'n'], ['F', 'k'], ['o', 'u']]) == False\n    assert candidate(s = \"MAPPINGmappings\",sub = \"mapping\",mappings = [['M', 'm'], ['A', 'a'], ['P', 'p'], ['P', 'p'], ['I', 'i'], ['N', 'n'], ['G', 'g']]) == True\n    assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",sub = \"fedcba\",mappings = [['f', 'Z'], ['e', 'Y'], ['d', 'X'], ['c', 'W'], ['b', 'V'], ['a', 'U']]) == False\n    assert candidate(s = \"mississippi\",sub = \"missi5\",mappings = [['i', '5']]) == False\n    assert candidate(s = \"ababababab\",sub = \"abab\",mappings = [['a', 'b'], ['b', 'a']]) == True\n    assert candidate(s = \"xyz123xyz123xyz123\",sub = \"abc\",mappings = [['a', 'x'], ['b', 'y'], ['c', 'z'], ['1', 'a'], ['2', 'b'], ['3', 'c']]) == True\n    assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",sub = \"ABCD123\",mappings = [['E', '1'], ['F', '2'], ['G', '3']]) == False\n    assert candidate(s = \"00000000000000000000\",sub = \"1111111111\",mappings = [['0', '1']]) == False\n    assert candidate(s = \"abcabcabcabcabcabc\",sub = \"aBc\",mappings = [['a', 'A'], ['b', 'B'], ['c', 'C']]) == False\n    assert candidate(s = \"HELLOworld\",sub = \"H3LL0\",mappings = [['E', '3'], ['O', '0']]) == False\n    assert candidate(s = \"1234567890\",sub = \"123\",mappings = [['1', '9'], ['2', '8'], ['3', '7']]) == True\n    assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0\",sub = \"abcdefghij\",mappings = [['a', '1'], ['b', '2'], ['c', '3'], ['d', '4'], ['e', '5'], ['f', '6'], ['g', '7'], ['h', '8'], ['i', '9'], ['j', '0']]) == False\n    assert candidate(s = \"abcXYZdefUVW\",sub = \"xyzuvw\",mappings = [['a', 'x'], ['b', 'y'], ['c', 'z'], ['d', 'u'], ['e', 'v'], ['f', 'w']]) == False\n    assert candidate(s = \"xyxyxyxyxy\",sub = \"xyz\",mappings = [['x', 'y'], ['y', 'x']]) == False\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",sub = \"xyz\",mappings = [['x', 'v'], ['y', 'w'], ['z', 'x']]) == True\n    assert candidate(s = \"A1B2C3D4E5F6G7H8I9J0\",sub = \"abcd\",mappings = [['a', 'A'], ['b', 'B'], ['c', 'C'], ['d', 'D']]) == False\n    assert candidate(s = \"1234567890\",sub = \"abcdefghij\",mappings = [['1', 'a'], ['2', 'b'], ['3', 'c'], ['4', 'd'], ['5', 'e'], ['6', 'f'], ['7', 'g'], ['8', 'h'], ['9', 'i']]) == False\n    assert candidate(s = \"abcdefabcdefabcdef\",sub = \"xyz\",mappings = [['a', 'x'], ['b', 'y'], ['c', 'z']]) == False\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",sub = \"zzzz\",mappings = [['z', 'Z'], ['Z', 'z']]) == True\n    assert candidate(s = \"aaaaaa\",sub = \"bbbbb\",mappings = [['a', 'b']]) == False\n    assert candidate(s = \"abcabcabcabc\",sub = \"abca\",mappings = [['a', 'b'], ['b', 'c'], ['c', 'a']]) == True\n    assert candidate(s = \"111222333444555666777888999\",sub = \"123456789\",mappings = [['1', '2'], ['2', '3'], ['3', '4'], ['4', '5'], ['5', '6'], ['6', '7'], ['7', '8'], ['8', '9']]) == False\n    assert candidate(s = \"1234567890\",sub = \"123abc\",mappings = [['4', 'a'], ['5', 'b'], ['6', 'c']]) == False\n    assert candidate(s = \"abcabcabcabcabc\",sub = \"abdc\",mappings = [['a', 'd'], ['b', 'c']]) == False\n    assert candidate(s = \"AAABBBCCCDDD\",sub = \"abc\",mappings = [['A', 'a'], ['B', 'b'], ['C', 'c']]) == False\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",sub = \"zyxwvutsrqponmlkjihgfedcba\",mappings = [['a', 'z'], ['b', 'y'], ['c', 'x'], ['d', 'w'], ['e', 'v'], ['f', 'u'], ['g', 't'], ['h', 's'], ['i', 'r'], ['j', 'q'], ['k', 'p'], ['l', 'o'], ['m', 'n']]) == False\n    assert candidate(s = \"abcdefghij\",sub = \"abcd12\",mappings = [['e', '1'], ['f', '2'], ['g', '3']]) == False\n    assert candidate(s = \"HelloWorld123\",sub = \"hello123\",mappings = [['H', 'h'], ['W', 'w'], ['o', '0'], ['r', '4'], ['l', '1']]) == False\n    assert candidate(s = \"aabbccddeeffgg\",sub = \"abc\",mappings = [['a', 'b'], ['b', 'c'], ['c', 'd']]) == True\n    assert candidate(s = \"abcdeABCDEabcdeABCDE\",sub = \"abcde\",mappings = [['a', 'A'], ['b', 'B'], ['c', 'C'], ['d', 'D'], ['e', 'E']]) == True\n    assert candidate(s = \"patternmatching\",sub = \"patt3rn\",mappings = [['a', '3']]) == False\n    assert candidate(s = \"abcdefgABCDEFG\",sub = \"aBcDeFg\",mappings = [['a', 'A'], ['b', 'B'], ['c', 'C'], ['d', 'D'], ['e', 'E'], ['f', 'F'], ['g', 'G']]) == True\n    assert candidate(s = \"abcdefghijk\",sub = \"abc123\",mappings = [['d', '1'], ['e', '2'], ['f', '3']]) == False\n    assert candidate(s = \"zzzzzzzzzz\",sub = \"aaa\",mappings = [['z', 'a']]) == False\n    assert candidate(s = \"hello123world456\",sub = \"hell12\",mappings = [['l', '1'], ['o', '2']]) == False\n    assert candidate(s = \"helloWorld123\",sub = \"he1oW3ld\",mappings = [['l', '1'], ['o', '0'], ['W', '3'], ['r', '2']]) == False\n    assert candidate(s = \"12345678901234567890\",sub = \"12345\",mappings = [['1', '2'], ['2', '3'], ['3', '4'], ['4', '5'], ['5', '6']]) == True\n", "comparison": "exact"}, "public_tests": ["\"fool3e7bar\"\n\"leet\"\n[[\"e\",\"3\"],[\"t\",\"7\"],[\"t\",\"8\"]]", "\"fooleetbar\"\n\"f00l\"\n[[\"o\",\"0\"]]", "\"Fool33tbaR\"\n\"leetd\"\n[[\"e\",\"3\"],[\"t\",\"7\"],[\"t\",\"8\"],[\"d\",\"b\"],[\"p\",\"b\"]]"], "hints": ["Enumerate all substrings of s with the same length as sub, and compare each substring to sub for equality.", "How can you quickly tell if a character of s can result from replacing the corresponding character in sub?"], "metadata": {"canonical_parameter_names": ["s", "sub", "mappings"], "leetcode_dataset_entry_point": "Solution().matchReplacement", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:03+00:00", "tests_total": 79, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "hash-table", "string", "string-matching"]}, "language": "python", "interface": {"raw_signature": "def matchReplacement(self, s: str, sub: str, mappings: list[list[str]]) -> bool:", "container": "Solution", "callable": "matchReplacement", "parameters": [{"name": "s", "type": "str"}, {"name": "sub", "type": "str"}, {"name": "mappings", "type": "list[list[str]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2302, "task_id": "count-subarrays-with-score-less-than-k", "difficulty": "Hard", "problem_description": "The score of an array is defined as the product of its sum and its length.\n\n- For example, the score of [1, 2, 3, 4, 5] is (1 + 2 + 3 + 4 + 5) * 5 = 75.\n\nGiven a positive integer array nums and an integer k, return the number of non-empty subarrays of nums whose score is strictly less than k.\n\nA subarray is a contiguous sequence of elements within an array.\n\nExample 1:\n\nInput: nums = [2,1,4,3,5], k = 10\nOutput: 6\nExplanation:\nThe 6 subarrays having scores less than 10 are:\n- [2] with score 2 * 1 = 2.\n- [1] with score 1 * 1 = 1.\n- [4] with score 4 * 1 = 4.\n- [3] with score 3 * 1 = 3.\n- [5] with score 5 * 1 = 5.\n- [2,1] with score (2 + 1) * 2 = 6.\nNote that subarrays such as [1,4] and [4,3,5] are not considered because their scores are 10 and 36 respectively, while we need scores strictly less than 10.\n\nExample 2:\n\nInput: nums = [1,1,1], k = 5\nOutput: 5\nExplanation:\nEvery subarray except [1,1,1] has a score less than 5.\n[1,1,1] has a score (1 + 1 + 1) * 3 = 9, which is greater than 5.\nThus, there are 5 subarrays having scores less than 5.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^5\n- 1 <= k <= 10^15\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 100) == 15\n    assert candidate(nums = [10, 10, 10],k = 100) == 6\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 24\n    assert candidate(nums = [1, 1, 1],k = 5) == 5\n    assert candidate(nums = [1],k = 2) == 1\n    assert candidate(nums = [5, 5, 5, 5],k = 20) == 4\n    assert candidate(nums = [10, 20, 30],k = 100) == 4\n    assert candidate(nums = [5, 5, 5, 5],k = 25) == 7\n    assert candidate(nums = [2, 1, 4, 3, 5],k = 10) == 6\n    assert candidate(nums = [10, 5, 2, 6],k = 100) == 10\n    assert candidate(nums = [5, 5, 5, 5, 5],k = 25) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 75) == 14\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 200) == 10\n    assert candidate(nums = [5, 5, 5, 5],k = 15) == 4\n    assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 10) == 19\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1000) == 32\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 50) == 19\n    assert candidate(nums = [3, 5, 2, 8, 6, 1],k = 25) == 10\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 30) == 24\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 30) == 19\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 50) == 74\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 74\n    assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],k = 20) == 23\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 100) == 26\n    assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 100) == 34\n    assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 10000) == 54\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 200) == 32\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 100) == 29\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == 34\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 30) == 18\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 100) == 23\n    assert candidate(nums = [100, 200, 300, 400, 500],k = 100000) == 15\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000],k = 500000000000) == 15\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 24\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 500000) == 55\n    assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 400) == 37\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995],k = 100000000000) == 21\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9],k = 50) == 13\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 200) == 101\n    assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],k = 500) == 37\n    assert candidate(nums = [3, 5, 7, 2, 8, 10],k = 100) == 17\n    assert candidate(nums = [100, 200, 300, 400, 500],k = 10000) == 15\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100000) == 55\n    assert candidate(nums = [5, 1, 3, 2, 5, 1, 2],k = 20) == 14\n    assert candidate(nums = [9, 7, 5, 3, 1, 9, 7, 5, 3, 1],k = 100) == 34\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 300) == 32\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10000) == 55\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2],k = 30) == 57\n    assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],k = 999990000000) == 55\n    assert candidate(nums = [7, 3, 2, 8, 1, 2, 4],k = 20) == 11\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 20) == 20\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 81) == 19\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 57\n    assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 25) == 22\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 50) == 54\n    assert candidate(nums = [3, 2, 1, 4, 5],k = 20) == 10\n    assert candidate(nums = [5, 4, 3, 2, 1],k = 15) == 8\n    assert candidate(nums = [10, 1, 2, 3, 10, 2, 3, 10, 2, 3],k = 50) == 27\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 150) == 30\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 50000) == 54\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 150) == 38\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 100) == 27\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 11) == 27\n    assert candidate(nums = [50, 40, 30, 20, 10],k = 1000) == 15\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 50) == 22\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 100) == 203\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 150) == 29\n    assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5],k = 50) == 34\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5000) == 55\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 27\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 500) == 40\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 150) == 53\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 54\n    assert candidate(nums = [10, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 150) == 37\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 100) == 32\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5000) == 54\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 200) == 61\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 100) == 44\n", "comparison": "exact"}, "public_tests": ["[2,1,4,3,5]\n10", "[1,1,1]\n5"], "hints": ["If we add an element to a list of elements, how will the score change?", "How can we use this to determine the number of subarrays with score less than k in a given range?", "How can we use “Two Pointers” to generalize the solution, and thus count all possible subarrays?"], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countSubarrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:06+00:00", "tests_total": 79, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "binary-search", "sliding-window", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def countSubarrays(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "countSubarrays", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2303, "task_id": "calculate-amount-paid-in-taxes", "difficulty": "Easy", "problem_description": "You are given a 0-indexed 2D integer array brackets where brackets[i] = [upper_i, percent_i] means that the i^th tax bracket has an upper bound of upper_i and is taxed at a rate of percent_i. The brackets are sorted by upper bound (i.e. upper_{i-1} < upper_i for 0 < i < brackets.length).\n\nTax is calculated as follows:\n\n- The first upper_0 dollars earned are taxed at a rate of percent_0.\n- The next upper_1 - upper_0 dollars earned are taxed at a rate of percent_1.\n- The next upper_2 - upper_1 dollars earned are taxed at a rate of percent_2.\n- And so on.\n\nYou are given an integer income representing the amount of money you earned. Return the amount of money that you have to pay in taxes. Answers within 10^-5 of the actual answer will be accepted.\n\nExample 1:\n\nInput: brackets = [[3,50],[7,10],[12,25]], income = 10\nOutput: 2.65000\nExplanation:\nBased on your income, you have 3 dollars in the 1^st tax bracket, 4 dollars in the 2^nd tax bracket, and 3 dollars in the 3^rd tax bracket.\nThe tax rate for the three tax brackets is 50%, 10%, and 25%, respectively.\nIn total, you pay $3 * 50% + $4 * 10% + $3 * 25% = $2.65 in taxes.\n\nExample 2:\n\nInput: brackets = [[1,0],[4,25],[5,50]], income = 2\nOutput: 0.25000\nExplanation:\nBased on your income, you have 1 dollar in the 1^st tax bracket and 1 dollar in the 2^nd tax bracket.\nThe tax rate for the two tax brackets is 0% and 25%, respectively.\nIn total, you pay $1 * 0% + $1 * 25% = $0.25 in taxes.\n\nExample 3:\n\nInput: brackets = [[2,50]], income = 0\nOutput: 0.00000\nExplanation:\nYou have no income to tax, so you have to pay a total of $0 in taxes.\n\nConstraints:\n\n- 1 <= brackets.length <= 100\n- 1 <= upper_i <= 1000\n- 0 <= percent_i <= 100\n- 0 <= income <= 1000\n- upper_i is sorted in ascending order.\n- All the values of upper_i are unique.\n- The upper bound of the last tax bracket is greater than or equal to income.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n    \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n    import math\n    if isinstance(result, list) and isinstance(expected, list):\n        return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n    numbers = (int, float)\n    if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n        return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n    return result == expected\n\n\ndef check(candidate):\n    assert answers_match(candidate(brackets=[[3, 50], [7, 10], [12, 25]], income=10), 2.65)\n    assert answers_match(candidate(brackets=[[5, 10], [10, 20], [15, 30], [20, 40]], income=25), 5.0)\n    assert answers_match(candidate(brackets=[[100, 20]], income=50), 10.0)\n    assert answers_match(candidate(brackets=[[50, 0], [100, 20], [150, 25]], income=175), 22.5)\n    assert answers_match(candidate(brackets=[[1, 100], [2, 50]], income=1), 1.0)\n    assert answers_match(candidate(brackets=[[5, 5], [10, 15], [15, 25]], income=15), 2.25)\n    assert answers_match(candidate(brackets=[[1, 100]], income=1), 1.0)\n    assert answers_match(candidate(brackets=[[2, 50]], income=0), 0.0)\n    assert answers_match(candidate(brackets=[[1, 100], [2, 0], [3, 50]], income=1), 1.0)\n    assert answers_match(candidate(brackets=[[1, 0], [4, 25], [5, 50]], income=2), 0.25)\n    assert answers_match(candidate(brackets=[[10, 10], [20, 20], [30, 30], [40, 40]], income=35), 8.0)\n    assert answers_match(candidate(brackets=[[1, 1], [2, 2], [3, 3]], income=3), 0.06)\n    assert answers_match(candidate(brackets=[[1, 100], [2, 50], [3, 25]], income=1), 1.0)\n    assert answers_match(candidate(brackets=[[10, 20], [20, 30], [30, 40]], income=15), 3.5)\n    assert answers_match(candidate(brackets=[[5, 50], [10, 30], [15, 20]], income=12), 4.4)\n    assert answers_match(candidate(brackets=[[500, 10], [1000, 20]], income=750), 100.0)\n    assert answers_match(candidate(brackets=[[10, 50]], income=10), 5.0)\n    assert answers_match(candidate(brackets=[[50, 10], [100, 20], [150, 30]], income=75), 10.0)\n    assert answers_match(candidate(brackets=[[10, 20], [20, 30], [30, 25]], income=25), 6.25)\n    assert answers_match(candidate(brackets=[[100, 5]], income=100), 5.0)\n    assert answers_match(candidate(brackets=[[100, 10]], income=100), 10.0)\n    assert answers_match(candidate(brackets=[[10, 10], [20, 20], [30, 30]], income=15), 2.0)\n    assert answers_match(candidate(brackets=[[1, 1], [2, 2], [3, 3], [4, 4]], income=4), 0.1)\n    assert answers_match(candidate(brackets=[[100, 10]], income=50), 5.0)\n    assert answers_match(candidate(brackets=[[500, 10], [750, 20], [1000, 30]], income=1000), 175.0)\n    assert answers_match(candidate(brackets=[[5, 100]], income=5), 5.0)\n    assert answers_match(candidate(brackets=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]], income=5), 0.15)\n    assert answers_match(candidate(brackets=[[10, 10], [20, 20], [30, 30]], income=25), 4.5)\n    assert answers_match(candidate(brackets=[[3, 0], [6, 10], [9, 20]], income=9), 0.9)\n    assert answers_match(candidate(brackets=[[1, 100], [2, 100], [3, 100]], income=3), 3.0)\n    assert answers_match(candidate(brackets=[[50, 10], [100, 20], [200, 30], [500, 40]], income=400), 125.0)\n    assert answers_match(candidate(brackets=[[100, 10], [200, 20], [300, 30], [400, 40]], income=350), 80.0)\n    assert answers_match(candidate(brackets=[[10, 0], [20, 10], [30, 20], [40, 30], [50, 40], [60, 50]], income=60), 15.0)\n    assert answers_match(candidate(brackets=[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]], income=45), 12.5)\n    assert answers_match(candidate(brackets=[[500, 25], [1000, 30]], income=800), 215.0)\n    assert answers_match(candidate(brackets=[[5, 0], [10, 5], [15, 10], [20, 15], [25, 20]], income=18), 1.2)\n    assert answers_match(candidate(brackets=[[10, 5], [20, 10], [30, 15], [40, 20]], income=25), 2.25)\n    assert answers_match(candidate(brackets=[[50, 1], [100, 2], [150, 3], [200, 4], [250, 5]], income=100), 1.5)\n    assert answers_match(candidate(brackets=[[5, 25], [15, 50], [25, 75], [35, 100]], income=35), 23.75)\n    assert answers_match(candidate(brackets=[[100, 25], [200, 30], [300, 35]], income=250), 72.5)\n    assert answers_match(candidate(brackets=[[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]], income=10), 5.5)\n    assert answers_match(candidate(brackets=[[10, 0], [20, 5], [30, 10], [40, 15], [50, 20], [60, 25]], income=55), 6.25)\n    assert answers_match(candidate(brackets=[[100, 5], [200, 10], [300, 15], [400, 20], [500, 25]], income=500), 75.0)\n    assert answers_match(candidate(brackets=[[10, 10], [20, 20], [30, 30], [40, 40]], income=25), 4.5)\n    assert answers_match(candidate(brackets=[[100, 10], [200, 20], [300, 30], [400, 40], [500, 50], [600, 60], [700, 70], [800, 80], [900, 90], [1000, 100]], income=1000), 550.0)\n    assert answers_match(candidate(brackets=[[150, 5], [250, 10], [350, 15], [450, 20], [550, 25]], income=600), 77.5)\n    assert answers_match(candidate(brackets=[[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]], income=45), 1.25)\n    assert answers_match(candidate(brackets=[[100, 5], [150, 10], [200, 15], [250, 20], [300, 25], [350, 30], [400, 35], [450, 40], [500, 45]], income=499), 114.55)\n    assert answers_match(candidate(brackets=[[100, 15], [200, 25], [300, 35], [400, 45]], income=350), 97.5)\n    assert answers_match(candidate(brackets=[[500, 1], [1000, 2]], income=750), 10.0)\n    assert answers_match(candidate(brackets=[[50, 5], [150, 15], [300, 25]], income=200), 30.0)\n    assert answers_match(candidate(brackets=[[50, 15], [100, 20], [150, 25], [200, 30]], income=175), 37.5)\n    assert answers_match(candidate(brackets=[[10, 50], [20, 75], [30, 100]], income=10), 5.0)\n    assert answers_match(candidate(brackets=[[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35]], income=65), 12.25)\n    assert answers_match(candidate(brackets=[[1, 100]], income=1000), 1.0)\n    assert answers_match(candidate(brackets=[[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70], [75, 80], [85, 90], [95, 100]], income=100), 54.5)\n    assert answers_match(candidate(brackets=[[200, 10], [400, 20], [600, 30], [800, 40], [1000, 50]], income=750), 180.0)\n    assert answers_match(candidate(brackets=[[100, 0], [200, 5], [300, 10], [400, 15], [500, 20]], income=0), 0.0)\n    assert answers_match(candidate(brackets=[[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]], income=30), 3.0)\n    assert answers_match(candidate(brackets=[[100, 10], [200, 20], [300, 30], [400, 40], [500, 50]], income=450), 125.0)\n    assert answers_match(candidate(brackets=[[100, 5], [200, 10], [300, 15], [400, 20], [500, 25], [600, 30], [700, 35], [800, 40], [900, 45], [1000, 50]], income=800), 180.0)\n    assert answers_match(candidate(brackets=[[10, 25], [20, 25], [30, 25], [40, 25], [50, 25]], income=40), 10.0)\n    assert answers_match(candidate(brackets=[[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]], income=25), 0.45)\n    assert answers_match(candidate(brackets=[[10, 100], [20, 100], [30, 100], [40, 100], [50, 100]], income=45), 45.0)\n    assert answers_match(candidate(brackets=[[50, 0], [100, 10], [150, 20], [200, 30], [250, 40]], income=250), 50.0)\n    assert answers_match(candidate(brackets=[[1, 2], [2, 4], [3, 6], [4, 8], [5, 10]], income=5), 0.3)\n    assert answers_match(candidate(brackets=[[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]], income=400), 10.0)\n    assert answers_match(candidate(brackets=[[10, 10], [50, 20], [100, 30], [200, 40], [500, 50]], income=600), 214.0)\n    assert answers_match(candidate(brackets=[[50, 1], [100, 2], [150, 3], [200, 4], [250, 5], [300, 6]], income=175), 4.0)\n    assert answers_match(candidate(brackets=[[15, 0], [30, 10], [45, 20], [60, 30], [75, 40]], income=70), 13.0)\n    assert answers_match(candidate(brackets=[[10, 50], [20, 40], [30, 30], [40, 20], [50, 10]], income=50), 15.0)\n    assert answers_match(candidate(brackets=[[10, 50], [20, 40], [30, 30], [40, 20], [50, 10]], income=45), 14.5)\n    assert answers_match(candidate(brackets=[[50, 0], [100, 5], [150, 10], [200, 15], [250, 20], [300, 25]], income=120), 4.5)\n    assert answers_match(candidate(brackets=[[10, 25], [20, 25], [30, 25], [40, 25], [50, 25], [60, 25], [70, 25], [80, 25], [90, 25], [100, 25]], income=95), 23.75)\n    assert answers_match(candidate(brackets=[[10, 50], [20, 50], [30, 50], [40, 50], [50, 50], [60, 50], [70, 50], [80, 50], [90, 50], [100, 50]], income=55), 27.5)\n    assert answers_match(candidate(brackets=[[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]], income=100), 5.5)\n    assert answers_match(candidate(brackets=[[1000, 100]], income=1000), 1000.0)\n    assert answers_match(candidate(brackets=[[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]], income=85), 20.25)\n    assert answers_match(candidate(brackets=[[10, 0], [20, 0], [30, 0], [40, 0], [50, 0]], income=50), 0.0)\n    assert answers_match(candidate(brackets=[[5, 10], [15, 15], [25, 20], [35, 25], [45, 30]], income=30), 5.25)\n    assert answers_match(candidate(brackets=[[10, 5], [20, 10], [30, 15]], income=5), 0.25)\n    assert answers_match(candidate(brackets=[[50, 10], [100, 20], [150, 30], [200, 40], [250, 50]], income=300), 75.0)\n    assert answers_match(candidate(brackets=[[50, 10], [100, 20], [150, 30], [200, 40], [250, 50]], income=220), 60.0)\n    assert answers_match(candidate(brackets=[[2, 5], [5, 10], [10, 20], [20, 30], [50, 40]], income=30), 8.4)\n    assert answers_match(candidate(brackets=[[10, 0], [20, 10], [30, 20], [40, 30], [50, 40], [60, 50], [70, 60], [80, 70], [90, 80], [100, 90]], income=95), 40.5)\n    assert answers_match(candidate(brackets=[[300, 5], [600, 10], [900, 15]], income=900), 90.0)\n    assert answers_match(candidate(brackets=[[100, 10], [200, 20], [300, 30], [400, 40], [500, 50], [600, 60]], income=650), 210.0)\n    assert answers_match(candidate(brackets=[[5, 0], [10, 10], [15, 20], [20, 30], [25, 40]], income=25), 5.0)\n    assert answers_match(candidate(brackets=[[100, 15], [200, 25], [300, 35], [400, 45], [500, 55]], income=600), 175.0)\n    assert answers_match(candidate(brackets=[[10, 100], [20, 90], [30, 80], [40, 70], [50, 60]], income=15), 14.5)\n    assert answers_match(candidate(brackets=[[200, 15], [400, 25], [600, 30]], income=550), 125.0)\n    assert answers_match(candidate(brackets=[[10, 25], [20, 35], [30, 45], [40, 55], [50, 65]], income=35), 13.25)\n    assert answers_match(candidate(brackets=[[10, 15], [20, 25], [30, 35], [40, 45], [50, 55]], income=50), 17.5)\n    assert answers_match(candidate(brackets=[[1, 100], [2, 90], [3, 80], [4, 70], [5, 60]], income=5), 4.0)\n    assert answers_match(candidate(brackets=[[10, 0], [20, 5], [30, 10], [40, 15], [50, 20], [60, 25], [70, 30], [80, 35], [90, 40], [100, 45]], income=50), 5.0)\n    assert answers_match(candidate(brackets=[[30, 5], [60, 10], [90, 15], [120, 20], [150, 25]], income=150), 22.5)\n    assert answers_match(candidate(brackets=[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]], income=100), 55.0)\n    assert answers_match(candidate(brackets=[[10, 0], [20, 5], [30, 10], [40, 15], [50, 20]], income=40), 3.0)\n    assert answers_match(candidate(brackets=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]], income=10), 0.55)\n    assert answers_match(candidate(brackets=[[50, 5], [150, 10], [250, 15], [350, 20], [450, 25], [550, 30]], income=300), 37.5)\n    assert answers_match(candidate(brackets=[[10, 100], [20, 0], [30, 100], [40, 0]], income=35), 20.0)\n    assert answers_match(candidate(brackets=[[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60]], income=55), 20.5)\n    assert answers_match(candidate(brackets=[[100, 10], [200, 20], [300, 30], [400, 40], [500, 50]], income=500), 150.0)\n    assert answers_match(candidate(brackets=[[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]], income=100), 27.5)\n    assert answers_match(candidate(brackets=[[50, 5], [150, 15], [250, 25], [350, 35], [450, 45]], income=450), 122.5)\n    assert answers_match(candidate(brackets=[[200, 10], [500, 20], [800, 30], [1000, 40]], income=750), 155.0)\n    assert answers_match(candidate(brackets=[[100, 0], [200, 0], [300, 0], [400, 0], [500, 0]], income=500), 0.0)\n    assert answers_match(candidate(brackets=[[100, 5], [200, 10], [300, 15], [400, 20], [500, 25], [600, 30]], income=600), 105.0)\n    assert answers_match(candidate(brackets=[[100, 0], [200, 5], [300, 10], [400, 15], [500, 20], [600, 25]], income=150), 2.5)\n    assert answers_match(candidate(brackets=[[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60]], income=6), 2.1)\n    assert answers_match(candidate(brackets=[[10, 5], [20, 10], [30, 15], [40, 20], [50, 25]], income=45), 6.25)\n    assert answers_match(candidate(brackets=[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]], income=35), 8.0)\n    assert answers_match(candidate(brackets=[[1, 100], [10, 90], [100, 80], [1000, 70]], income=500), 361.1)\n    assert answers_match(candidate(brackets=[[100, 5], [200, 10], [300, 15], [400, 20], [500, 25], [600, 30], [700, 35], [800, 40], [900, 45], [1000, 50]], income=950), 250.0)\n    assert answers_match(candidate(brackets=[[50, 5], [100, 15], [200, 25], [300, 35]], income=250), 52.5)\n    assert answers_match(candidate(brackets=[[100, 5], [200, 10], [300, 15], [400, 20], [500, 25], [600, 30], [700, 35], [800, 40], [900, 45], [1000, 50]], income=999), 274.5)\n    assert answers_match(candidate(brackets=[[5, 10], [10, 20], [15, 30], [20, 40], [25, 50]], income=18), 4.2)\n", "comparison": "float"}, "public_tests": ["[[3,50],[7,10],[12,25]]\n10", "[[1,0],[4,25],[5,50]]\n2", "[[2,50]]\n0"], "hints": ["As you iterate through the tax brackets, keep track of the previous tax bracket’s upper bound in a variable called prev. If there is no previous tax bracket, use 0 instead.", "The amount of money in the ith tax bracket is min(income, upperi) - prev."], "metadata": {"canonical_parameter_names": ["brackets", "income"], "leetcode_dataset_entry_point": "Solution().calculateTax", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:08+00:00", "tests_total": 122, "tests_dropped": 5, "flags": ["decimal_answer"], "topic_tags": ["array", "simulation"]}, "language": "python", "interface": {"raw_signature": "def calculateTax(self, brackets: list[list[int]], income: int) -> float:", "container": "Solution", "callable": "calculateTax", "parameters": [{"name": "brackets", "type": "list[list[int]]"}, {"name": "income", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2304, "task_id": "minimum-path-cost-in-a-grid", "difficulty": "Medium", "problem_description": "You are given a 0-indexed m x n integer matrix grid consisting of distinct integers from 0 to m * n - 1. You can move in this matrix from a cell to any other cell in the next row. That is, if you are in cell (x, y) such that x < m - 1, you can move to any of the cells (x + 1, 0), (x + 1, 1), ..., (x + 1, n - 1). Note that it is not possible to move from cells in the last row.\n\nEach possible move has a cost given by a 0-indexed 2D array moveCost of size (m * n) x n, where moveCost[i][j] is the cost of moving from a cell with value i to a cell in column j of the next row. The cost of moving from cells in the last row of grid can be ignored.\n\nThe cost of a path in grid is the sum of all values of cells visited plus the sum of costs of all the moves made. Return the minimum cost of a path that starts from any cell in the first row and ends at any cell in the last row.\n\nExample 1:\n\nInput: grid = [[5,3],[4,0],[2,1]], moveCost = [[9,8],[1,5],[10,12],[18,6],[2,4],[14,3]]\nOutput: 17\nExplanation: The path with the minimum possible cost is the path 5 -> 0 -> 1.\n- The sum of the values of cells visited is 5 + 0 + 1 = 6.\n- The cost of moving from 5 to 0 is 3.\n- The cost of moving from 0 to 1 is 8.\nSo the total cost of the path is 6 + 3 + 8 = 17.\n\nExample 2:\n\nInput: grid = [[5,1,2],[4,0,3]], moveCost = [[12,10,15],[20,23,8],[21,7,1],[8,1,13],[9,10,25],[5,3,2]]\nOutput: 6\nExplanation: The path with the minimum possible cost is the path 2 -> 3.\n- The sum of the values of cells visited is 2 + 3 = 5.\n- The cost of moving from 2 to 3 is 1.\nSo the total cost of this path is 5 + 1 = 6.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 2 <= m, n <= 50\n- grid consists of distinct integers from 0 to m * n - 1.\n- moveCost.length == m * n\n- moveCost[i].length == n\n- 1 <= moveCost[i][j] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],moveCost = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27]]) == 29\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6]],moveCost = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]]) == 9\n    assert candidate(grid = [[0, 1], [2, 3]],moveCost = [[9, 8], [1, 5], [10, 12], [18, 6]]) == 4\n    assert candidate(grid = [[5, 3], [4, 0], [2, 1]],moveCost = [[9, 8], [1, 5], [10, 12], [18, 6], [2, 4], [14, 3]]) == 17\n    assert candidate(grid = [[5, 1, 2], [4, 0, 3]],moveCost = [[12, 10, 15], [20, 23, 8], [21, 7, 1], [8, 1, 13], [9, 10, 25], [5, 3, 2]]) == 6\n    assert candidate(grid = [[1, 3, 5], [2, 8, 4], [6, 7, 9], [10, 12, 11]],moveCost = [[2, 3, 4], [1, 6, 5], [8, 9, 7], [3, 2, 1], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27]]) == 38\n    assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],moveCost = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40], [41, 42, 43, 44, 45], [46, 47, 48, 49, 50], [51, 52, 53, 54, 55], [56, 57, 58, 59, 60], [61, 62, 63, 64, 65], [66, 67, 68, 69, 70], [71, 72, 73, 74, 75]]) == 55\n    assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],moveCost = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 20\n    assert candidate(grid = [[1, 10, 3, 4], [2, 5, 6, 7], [8, 9, 2, 11], [12, 13, 14, 15]],moveCost = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24], [25, 26, 27, 28], [29, 30, 31, 32], [33, 34, 35, 36], [37, 38, 39, 40], [41, 42, 43, 44], [45, 46, 47, 48], [49, 50, 51, 52], [53, 54, 55, 56], [57, 58, 59, 60], [61, 62, 63, 64]]) == 42\n    assert candidate(grid = [[1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20]],moveCost = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40], [41, 42, 43, 44, 45], [46, 47, 48, 49, 50], [51, 52, 53, 54, 55], [56, 57, 58, 59, 60], [61, 62, 63, 64, 65], [66, 67, 68, 69, 70], [71, 72, 73, 74, 75], [76, 77, 78, 79, 80], [81, 82, 83, 84, 85], [86, 87, 88, 89, 90], [91, 92, 93, 94, 95], [96, 97, 98, 99, 100]]) == 43\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],moveCost = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27], [28, 29, 30], [31, 32, 33], [34, 35, 36]]) == 61\n    assert candidate(grid = [[1, 3, 2, 4], [2, 4, 3, 1], [3, 1, 4, 2], [4, 2, 1, 3]],moveCost = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24], [25, 26, 27, 28], [29, 30, 31, 32], [33, 34, 35, 36], [37, 38, 39, 40], [41, 42, 43, 44], [45, 46, 47, 48], [49, 50, 51, 52], [53, 54, 55, 56], [57, 58, 59, 60], [61, 62, 63, 64]]) == 25\n    assert candidate(grid = [[1, 3, 5], [2, 4, 6], [7, 8, 9]],moveCost = [[3, 5, 2], [1, 3, 4], [6, 2, 5], [4, 1, 3], [2, 5, 1], [7, 2, 4], [3, 6, 2], [5, 1, 4], [2, 3, 1]]) == 14\n", "comparison": "exact"}, "public_tests": ["[[5,3],[4,0],[2,1]]\n[[9,8],[1,5],[10,12],[18,6],[2,4],[14,3]]", "[[5,1,2],[4,0,3]]\n[[12,10,15],[20,23,8],[21,7,1],[8,1,13],[9,10,25],[5,3,2]]"], "hints": ["What is the optimal cost to get to each of the cells in the second row? What about the third row?", "Use dynamic programming to compute the optimal cost to get to each cell."], "metadata": {"canonical_parameter_names": ["grid", "moveCost"], "leetcode_dataset_entry_point": "Solution().minPathCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:10+00:00", "tests_total": 28, "tests_dropped": 15, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "matrix"]}, "language": "python", "interface": {"raw_signature": "def minPathCost(self, grid: list[list[int]], moveCost: list[list[int]]) -> int:", "container": "Solution", "callable": "minPathCost", "parameters": [{"name": "grid", "type": "list[list[int]]"}, {"name": "moveCost", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2305, "task_id": "fair-distribution-of-cookies", "difficulty": "Medium", "problem_description": "You are given an integer array cookies, where cookies[i] denotes the number of cookies in the i^th bag. You are also given an integer k that denotes the number of children to distribute all the bags of cookies to. All the cookies in the same bag must go to the same child and cannot be split up.\n\nThe unfairness of a distribution is defined as the maximum total cookies obtained by a single child in the distribution.\n\nReturn the minimum unfairness of all distributions.\n\nExample 1:\n\nInput: cookies = [8,15,10,20,8], k = 2\nOutput: 31\nExplanation: One optimal distribution is [8,15,8] and [10,20]\n- The 1^st child receives [8,15,8] which has a total of 8 + 15 + 8 = 31 cookies.\n- The 2^nd child receives [10,20] which has a total of 10 + 20 = 30 cookies.\nThe unfairness of the distribution is max(31,30) = 31.\nIt can be shown that there is no distribution with an unfairness less than 31.\n\nExample 2:\n\nInput: cookies = [6,1,3,2,2,4,1,2], k = 3\nOutput: 7\nExplanation: One optimal distribution is [6,1], [3,2,2], and [4,1,2]\n- The 1^st child receives [6,1] which has a total of 6 + 1 = 7 cookies.\n- The 2^nd child receives [3,2,2] which has a total of 3 + 2 + 2 = 7 cookies.\n- The 3^rd child receives [4,1,2] which has a total of 4 + 1 + 2 = 7 cookies.\nThe unfairness of the distribution is max(7,7,7) = 7.\nIt can be shown that there is no distribution with an unfairness less than 7.\n\nConstraints:\n\n- 2 <= cookies.length <= 8\n- 1 <= cookies[i] <= 10^5\n- 2 <= k <= cookies.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(cookies = [1, 1, 1, 1, 1, 1, 1, 100000],k = 7) == 100000\n    assert candidate(cookies = [8, 15, 10, 20, 8],k = 2) == 31\n    assert candidate(cookies = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 8) == 100000\n    assert candidate(cookies = [1, 100000, 1, 1, 1, 1, 1, 1],k = 3) == 100000\n    assert candidate(cookies = [10, 20, 30, 40, 50, 60, 70, 80],k = 2) == 180\n    assert candidate(cookies = [10, 20, 30, 40, 50, 60, 70, 80],k = 8) == 80\n    assert candidate(cookies = [1, 3, 2, 4, 5, 6, 7, 8],k = 2) == 18\n    assert candidate(cookies = [100000, 1, 1, 1, 1, 1, 1, 1],k = 2) == 100000\n    assert candidate(cookies = [5, 5, 5, 5, 5, 5, 5, 5],k = 8) == 5\n    assert candidate(cookies = [2, 2, 2, 2, 2, 2, 2, 2],k = 2) == 8\n    assert candidate(cookies = [6, 1, 3, 2, 2, 4, 1, 2],k = 3) == 7\n    assert candidate(cookies = [8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 9\n    assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8],k = 4) == 9\n    assert candidate(cookies = [100000, 1, 1, 1, 1, 1, 1, 1],k = 7) == 100000\n    assert candidate(cookies = [5, 5, 5, 5, 5, 5, 5, 5],k = 2) == 20\n    assert candidate(cookies = [8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 18\n    assert candidate(cookies = [15, 20, 25, 30, 35, 40, 45, 50],k = 7) == 50\n    assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8],k = 7) == 8\n    assert candidate(cookies = [9, 8, 7, 6, 5, 4, 3, 2],k = 5) == 9\n    assert candidate(cookies = [100, 200, 300, 400, 500, 600, 700, 800],k = 5) == 800\n    assert candidate(cookies = [1, 1, 2, 2, 3, 3, 4, 4],k = 5) == 4\n    assert candidate(cookies = [7, 14, 21, 28, 35, 42, 49, 56],k = 2) == 126\n    assert candidate(cookies = [80, 70, 60, 50, 40, 30, 20, 10],k = 4) == 90\n    assert candidate(cookies = [1, 1, 2, 2, 3, 3, 4, 4],k = 2) == 10\n    assert candidate(cookies = [10, 20, 30, 40, 50, 60, 70, 80],k = 4) == 90\n    assert candidate(cookies = [12, 11, 10, 9, 8, 7, 6, 5],k = 3) == 23\n    assert candidate(cookies = [100, 200, 300, 150, 50, 25, 25, 50],k = 4) == 300\n    assert candidate(cookies = [30, 20, 10, 40, 60, 50, 70, 80],k = 5) == 80\n    assert candidate(cookies = [30, 20, 10, 20, 30, 20, 10, 20],k = 5) == 40\n    assert candidate(cookies = [10, 20, 30, 40, 50, 60, 70, 80],k = 5) == 80\n    assert candidate(cookies = [100000, 1, 2, 3, 4, 5, 6, 7],k = 2) == 100000\n    assert candidate(cookies = [1, 10, 100, 1000, 10000, 100000, 5, 50],k = 5) == 100000\n    assert candidate(cookies = [9, 6, 12, 4, 7, 11, 5, 3],k = 4) == 15\n    assert candidate(cookies = [1, 1, 1, 1, 1, 1, 1, 1],k = 4) == 2\n    assert candidate(cookies = [9, 9, 9, 9, 9, 9, 9, 9],k = 4) == 18\n    assert candidate(cookies = [1, 2, 4, 8, 16, 32, 64, 128],k = 5) == 128\n    assert candidate(cookies = [10, 10, 10, 10, 10, 10, 10, 10],k = 7) == 20\n    assert candidate(cookies = [18, 23, 45, 12, 34, 56, 78, 90],k = 3) == 123\n    assert candidate(cookies = [100, 200, 300, 400, 500, 600, 700, 800],k = 6) == 800\n    assert candidate(cookies = [100, 200, 300, 400, 500, 600, 700, 800],k = 4) == 900\n    assert candidate(cookies = [8, 1, 5, 7, 3, 6, 4, 2],k = 3) == 12\n    assert candidate(cookies = [9, 8, 7, 6, 5, 4, 3, 2],k = 6) == 9\n    assert candidate(cookies = [16, 14, 12, 10, 8, 6, 4, 2],k = 4) == 18\n    assert candidate(cookies = [5, 10, 15, 20, 25, 30, 35, 40],k = 5) == 40\n    assert candidate(cookies = [5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 15\n    assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8],k = 7) == 8\n    assert candidate(cookies = [9, 18, 27, 36, 45, 54, 63, 72],k = 4) == 81\n    assert candidate(cookies = [1, 1, 1, 1, 1, 1, 1, 1],k = 8) == 1\n    assert candidate(cookies = [15, 14, 13, 12, 11, 10, 9, 8],k = 4) == 23\n    assert candidate(cookies = [15, 25, 35, 45, 55, 65, 75, 85],k = 5) == 85\n    assert candidate(cookies = [12, 11, 10, 9, 8, 7, 6, 5],k = 2) == 34\n    assert candidate(cookies = [1, 1, 1, 1, 1, 1, 1, 1],k = 3) == 3\n    assert candidate(cookies = [30, 20, 10, 10, 20, 30, 40, 50],k = 5) == 50\n    assert candidate(cookies = [10, 20, 30, 40, 50, 60, 70, 80],k = 3) == 120\n    assert candidate(cookies = [15, 15, 15, 15, 15, 15, 15, 15],k = 7) == 30\n    assert candidate(cookies = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000],k = 8) == 8000\n    assert candidate(cookies = [1, 1, 1, 1, 1, 1, 1, 1],k = 8) == 1\n    assert candidate(cookies = [8, 16, 32, 64, 128, 256, 512, 1024],k = 2) == 1024\n    assert candidate(cookies = [30, 20, 10, 60, 50, 40, 70, 80],k = 5) == 80\n    assert candidate(cookies = [5, 10, 15, 20, 25, 30, 35, 40],k = 6) == 40\n    assert candidate(cookies = [9, 3, 10, 12, 8, 15, 5, 7],k = 3) == 24\n    assert candidate(cookies = [3, 1, 2, 4, 5, 6, 7, 8],k = 4) == 9\n    assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8],k = 4) == 9\n    assert candidate(cookies = [12, 17, 22, 14, 29, 18, 15, 20],k = 4) == 41\n    assert candidate(cookies = [1, 2, 4, 8, 16, 32, 64, 128],k = 3) == 128\n    assert candidate(cookies = [100, 100, 100, 100, 100, 100, 100, 100],k = 5) == 200\n    assert candidate(cookies = [12, 23, 34, 45, 56, 67, 78, 89],k = 3) == 135\n    assert candidate(cookies = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 4) == 200000\n    assert candidate(cookies = [10, 20, 30, 40, 50, 60, 70, 80],k = 6) == 80\n    assert candidate(cookies = [7, 8, 9, 10, 11, 12, 13, 14],k = 6) == 17\n    assert candidate(cookies = [100, 200, 300, 400, 500, 600, 700, 800],k = 3) == 1200\n    assert candidate(cookies = [8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 8\n    assert candidate(cookies = [8, 15, 10, 20, 8, 5, 3, 7],k = 3) == 26\n    assert candidate(cookies = [5, 15, 25, 35, 45, 55, 65, 75],k = 3) == 110\n    assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8],k = 8) == 8\n    assert candidate(cookies = [100, 200, 300, 400, 500, 600, 700, 800],k = 4) == 900\n    assert candidate(cookies = [15, 15, 15, 15, 15, 15, 15, 15],k = 6) == 30\n    assert candidate(cookies = [100, 200, 300, 400, 500, 600, 700, 800],k = 5) == 800\n    assert candidate(cookies = [2, 4, 6, 8, 10, 12, 14, 16],k = 3) == 24\n    assert candidate(cookies = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000],k = 2) == 18000\n    assert candidate(cookies = [50, 40, 30, 20, 10, 5, 3, 1],k = 4) == 50\n    assert candidate(cookies = [5, 5, 15, 15, 25, 25, 35, 35],k = 4) == 40\n    assert candidate(cookies = [15, 15, 15, 15, 15, 15, 15, 15],k = 2) == 60\n    assert candidate(cookies = [2, 2, 2, 2, 2, 2, 2, 2],k = 7) == 4\n    assert candidate(cookies = [25, 25, 25, 25, 25, 25, 25, 25],k = 8) == 25\n    assert candidate(cookies = [8, 15, 10, 20, 8, 12, 15, 10],k = 3) == 33\n    assert candidate(cookies = [8, 1, 2, 3, 4, 5, 6, 7],k = 2) == 18\n    assert candidate(cookies = [10, 20, 10, 20, 10, 20, 10, 20],k = 4) == 30\n    assert candidate(cookies = [50, 40, 30, 20, 10, 1, 2, 3],k = 3) == 53\n    assert candidate(cookies = [1, 1, 2, 2, 3, 3, 4, 4],k = 4) == 5\n    assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8],k = 8) == 8\n    assert candidate(cookies = [1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 4\n    assert candidate(cookies = [1, 2, 3, 4, 5, 6, 7, 8],k = 3) == 12\n    assert candidate(cookies = [10, 10, 20, 20, 30, 30, 40, 40],k = 4) == 50\n    assert candidate(cookies = [9, 18, 27, 36, 45, 54, 63, 72],k = 4) == 81\n    assert candidate(cookies = [8, 1, 2, 3, 4, 5, 6, 7],k = 8) == 8\n    assert candidate(cookies = [100, 200, 300, 400, 500, 600, 700, 800],k = 7) == 800\n", "comparison": "exact"}, "public_tests": ["[8,15,10,20,8]\n2", "[6,1,3,2,2,4,1,2]\n3"], "hints": ["We have to give each bag to one of the children. How can we enumerate all of the possibilities?", "Use recursion and keep track of the current number of cookies each child has. Once all the bags have been distributed, find the child with the most cookies."], "metadata": {"canonical_parameter_names": ["cookies", "k"], "leetcode_dataset_entry_point": "Solution().distributeCookies", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:13+00:00", "tests_total": 104, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "dynamic-programming", "backtracking", "bit-manipulation", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def distributeCookies(self, cookies: list[int], k: int) -> int:", "container": "Solution", "callable": "distributeCookies", "parameters": [{"name": "cookies", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2306, "task_id": "naming-a-company", "difficulty": "Hard", "problem_description": "You are given an array of strings ideas that represents a list of names to be used in the process of naming a company. The process of naming a company is as follows:\n\n1. Choose 2 distinct names from ideas, call them idea_A and idea_B.\n2. Swap the first letters of idea_A and idea_B with each other.\n3. If both of the new names are not found in the original ideas, then the name idea_A idea_B (the concatenation of idea_A and idea_B, separated by a space) is a valid company name.\n4. Otherwise, it is not a valid name.\n\nReturn the number of distinct valid names for the company.\n\nExample 1:\n\nInput: ideas = [\"coffee\",\"donuts\",\"time\",\"toffee\"]\nOutput: 6\nExplanation: The following selections are valid:\n- (\"coffee\", \"donuts\"): The company name created is \"doffee conuts\".\n- (\"donuts\", \"coffee\"): The company name created is \"conuts doffee\".\n- (\"donuts\", \"time\"): The company name created is \"tonuts dime\".\n- (\"donuts\", \"toffee\"): The company name created is \"tonuts doffee\".\n- (\"time\", \"donuts\"): The company name created is \"dime tonuts\".\n- (\"toffee\", \"donuts\"): The company name created is \"doffee tonuts\".\nTherefore, there are a total of 6 distinct company names.\n\nThe following are some examples of invalid selections:\n- (\"coffee\", \"time\"): The name \"toffee\" formed after swapping already exists in the original array.\n- (\"time\", \"toffee\"): Both names are still the same after swapping and exist in the original array.\n- (\"coffee\", \"toffee\"): Both names formed after swapping already exist in the original array.\n\nExample 2:\n\nInput: ideas = [\"lack\",\"back\"]\nOutput: 0\nExplanation: There are no valid selections. Therefore, 0 is returned.\n\nConstraints:\n\n- 2 <= ideas.length <= 5 * 10^4\n- 1 <= ideas[i].length <= 10\n- ideas[i] consists of lowercase English letters.\n- All the strings in ideas are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(ideas = ['coffee', 'donuts', 'time', 'toffee']) == 6\n    assert candidate(ideas = ['aaa', 'bbb', 'ccc']) == 6\n    assert candidate(ideas = ['abc', 'bcd', 'cde', 'dec']) == 12\n    assert candidate(ideas = ['abcd', 'dcba', 'ddda', 'dccd']) == 6\n    assert candidate(ideas = ['aaa', 'aab', 'aac', 'aba', 'abb', 'abc', 'aca', 'acb', 'acc', 'baa', 'bab', 'bac', 'bba', 'bbb', 'bbc', 'bca', 'bcb', 'bcc', 'caa', 'cab', 'cac', 'cba', 'cbb', 'cbc', 'cca', 'ccb', 'ccc']) == 0\n    assert candidate(ideas = ['aaa', 'bbb', 'ccc', 'ddd']) == 12\n    assert candidate(ideas = ['lack', 'back']) == 0\n    assert candidate(ideas = ['aaa', 'bbb', 'ccc', 'aab', 'abb', 'abc']) == 10\n    assert candidate(ideas = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']) == 0\n    assert candidate(ideas = ['ana', 'anna', 'nana', 'ann', 'nan']) == 12\n    assert candidate(ideas = ['aaa', 'baa', 'caa']) == 0\n    assert candidate(ideas = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 0\n    assert candidate(ideas = ['aaa', 'aab', 'aac', 'aba', 'abb', 'abc', 'aca', 'acb', 'acc']) == 0\n    assert candidate(ideas = ['aa', 'bb', 'cc', 'ac', 'ba', 'ab', 'ad', 'da', 'bd', 'db']) == 10\n    assert candidate(ideas = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj', 'kkk', 'lll', 'mmm', 'nnn', 'ooo', 'ppp', 'qqq', 'rrr', 'sss', 'ttt', 'uuu', 'vvv', 'www', 'xxx', 'yyy', 'zzz']) == 5552\n    assert candidate(ideas = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz', 'aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj', 'kkk', 'lll', 'mmm', 'nnn', 'ooo', 'ppp', 'qqq', 'rrr', 'sss', 'ttt', 'uuu', 'vvv', 'www', 'xxx', 'yyy', 'zzz', 'aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh', 'iiii', 'jjjj', 'kkkk', 'llll', 'mmmm', 'nnnn', 'oooo', 'pppp', 'qqqq', 'rrrr', 'ssss', 'tttt', 'uuuu', 'vvvv', 'wwww', 'xxxx', 'yyyy', 'zzzz', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == 10002\n    assert candidate(ideas = ['axx', 'bxx', 'cxx', 'dxx', 'exx', 'fxx', 'gxx', 'hxx', 'ixx', 'jxx', 'kxx', 'lxx', 'mxx', 'nxx', 'oxx', 'pxx', 'qxx', 'rxx', 'sxx', 'txx', 'uxx', 'vxx', 'wxx', 'xxx', 'yxx', 'zxx']) == 0\n    assert candidate(ideas = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'axa', 'bxb', 'cxc', 'dxd', 'eye', 'fzf', 'gag', 'hah', 'ibi', 'jij', 'kjk', 'lll', 'mmm', 'nnn', 'ooo', 'ppp', 'qqq', 'rrr', 'sss', 'ttt', 'uuu', 'vvv', 'www', 'xxx', 'yyy', 'zzz']) == 2390\n    assert candidate(ideas = ['aabb', 'abbb', 'acbb', 'adbb', 'aebb', 'afbb', 'agbb', 'ahbb', 'aibb', 'ajbb', 'akbb', 'albb', 'ambb', 'anbb', 'aobb', 'apbb', 'aqbb', 'arbb', 'asbb', 'atbb', 'aubb', 'avbb', 'awbb', 'axbb', 'aybb', 'azbb', 'baab', 'bbab', 'bcab', 'bdab', 'beab', 'bfab', 'bgab', 'bhab', 'biab', 'bjab', 'bkab', 'blab', 'bmba', 'bnab', 'boab', 'bpab', 'bqab', 'brab', 'bsab', 'btab', 'buab', 'bvab', 'bwab', 'bxab', 'byab', 'bzab', 'caab', 'cbab', 'ccab', 'cdba', 'ceab', 'cfab', 'cgab', 'chab', 'ciab', 'cjab', 'ckab', 'clab', 'cmba', 'cnab', 'coab', 'cpab', 'cqab', 'crab', 'csab', 'ctab', 'cuab', 'cvab', 'cwab', 'cxab', 'cyab', 'czab', 'daab', 'dbab', 'dcab', 'ddab', 'deab', 'dfab', 'dgab', 'dhab', 'diab', 'djab', 'dkab', 'dlab', 'dmab', 'dnab', 'doab', 'dpab', 'dqab', 'drab', 'dsab', 'dtab', 'duab', 'dvab', 'dwab', 'dxab', 'dyab', 'dzab', 'eaab', 'ebab', 'ecab', 'edab', 'eeab', 'efab', 'egab', 'ehab', 'eiab', 'ejab', 'ekab', 'elab', 'emab', 'enab', 'eoab', 'epab', 'eqab', 'erab', 'esab', 'etab', 'euab', 'evab', 'ewab', 'exab', 'eyab', 'ezab', 'faab', 'fbab', 'fcab', 'fdab', 'feab', 'ffab', 'fgab', 'fhab', 'fiab', 'fjab', 'fkab', 'flab', 'fmab', 'fnab', 'foab', 'fpab', 'fqab', 'frab', 'fsab', 'ftab', 'fuab', 'fvab', 'fwab', 'fxab', 'fyab', 'fzab']) == 6792\n    assert candidate(ideas = ['aabb', 'abba', 'bbaa', 'baab', 'abab', 'baba', 'abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba', 'aaaa', 'bbbb', 'cccc', 'dddd', 'aabbcc', 'bbccaa', 'ccaabb', 'aabbaa', 'bbccbb', 'ccaaca']) == 1182\n    assert candidate(ideas = ['aaa', 'aab', 'aac', 'aba', 'abb', 'abc', 'aca', 'acb', 'acc', 'baa', 'bab', 'bac', 'bba', 'bbb', 'bbc', 'bca', 'bcb', 'bcc', 'caa', 'cab', 'cac', 'cba', 'cbb', 'cbc', 'cca', 'ccb', 'ccc', 'ddd', 'dee', 'def', 'deg', 'dih', 'dii', 'dij', 'dka', 'dkb', 'dkc', 'dla', 'dlb', 'dlc', 'dma', 'dmb', 'dmc', 'dna', 'dnb', 'dnc', 'doa', 'dob', 'doc', 'doea', 'doeb', 'doec', 'dofa', 'dobf', 'docf']) == 1512\n    assert candidate(ideas = ['aabc', 'abac', 'abbc', 'acbc', 'adbc', 'aebc', 'afbc', 'agbc', 'ahbc', 'aibc', 'ajbc', 'akbc', 'albc', 'ambc', 'anbc', 'aobc', 'apbc', 'aqbc', 'arbc', 'asbc', 'atbc', 'aubc', 'avbc', 'awbc', 'axbc', 'aybc', 'azbc', 'baaa', 'baab', 'baac', 'baad', 'baae', 'baaf', 'baag', 'baah', 'baai', 'baaj', 'baak', 'baal', 'baam', 'baan', 'baao', 'baap', 'baaq', 'baar', 'baas', 'baat', 'baau', 'baav', 'baaw', 'baax', 'baay', 'baaz']) == 1404\n    assert candidate(ideas = ['apple', 'apricot', 'banana', 'blueberry', 'cherry', 'cranberry', 'grape', 'guava', 'kiwi', 'lemon', 'lime', 'mango', 'melon', 'orange', 'papaya', 'peach', 'pear', 'plum', 'raspberry', 'strawberry', 'tangerine', 'watermelon']) == 438\n    assert candidate(ideas = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz', 'aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj', 'kkk', 'lll', 'mmm', 'nnn', 'ooo', 'ppp', 'qqq', 'rrr', 'sss', 'ttt', 'uuu', 'vvv', 'www', 'xxx', 'yyy', 'zzz', 'aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh', 'iiii', 'jjjj', 'kkkk', 'llll', 'mmmm', 'nnnn', 'oooo', 'pppp', 'qqqq', 'rrrr', 'ssss', 'tttt', 'uuuu', 'vvvv', 'wwww', 'xxxx', 'yyyy', 'zzzz', 'aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'fffff', 'ggggg', 'hhhhh', 'iiiii', 'jjjjj', 'kkkkk', 'lllll', 'mmmmm', 'nnnnn', 'ooooo', 'ppppp', 'qqqqq', 'rrrrr', 'sssss', 'ttttt', 'uuuuu', 'vvvvv', 'wwwww', 'xxxxx', 'yyyyy', 'zzzzz']) == 10400\n", "comparison": "exact"}, "public_tests": ["[\"coffee\",\"donuts\",\"time\",\"toffee\"]", "[\"lack\",\"back\"]"], "hints": ["How can we divide the ideas into groups to make it easier to find valid pairs?", "Group ideas that share the same suffix (all characters except the first) together and notice that a pair of ideas from the same group is invalid. What about pairs of ideas from different groups?", "The first letter of the idea in the first group must not be the first letter of an idea in the second group and vice versa.", "We can efficiently count the valid pairings for an idea if we already know how many ideas starting with a letter x are within a group that does not contain any ideas with starting letter y for all letters x and y."], "metadata": {"canonical_parameter_names": ["ideas"], "leetcode_dataset_entry_point": "Solution().distinctNames", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:15+00:00", "tests_total": 45, "tests_dropped": 21, "flags": [], "topic_tags": ["array", "hash-table", "string", "bit-manipulation", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def distinctNames(self, ideas: list[str]) -> int:", "container": "Solution", "callable": "distinctNames", "parameters": [{"name": "ideas", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2309, "task_id": "greatest-english-letter-in-upper-and-lower-case", "difficulty": "Easy", "problem_description": "Given a string of English letters s, return the greatest English letter which occurs as both a lowercase and uppercase letter in s. The returned letter should be in uppercase. If no such letter exists, return an empty string.\n\nAn English letter b is greater than another letter a if b appears after a in the English alphabet.\n\nExample 1:\n\nInput: s = \"lEeTcOdE\"\nOutput: \"E\"\nExplanation:\nThe letter 'E' is the only letter to appear in both lower and upper case.\n\nExample 2:\n\nInput: s = \"arRAzFif\"\nOutput: \"R\"\nExplanation:\nThe letter 'R' is the greatest letter to appear in both lower and upper case.\nNote that 'A' and 'F' also appear in both lower and upper case, but 'R' is greater than 'F' or 'A'.\n\nExample 3:\n\nInput: s = \"AbCdEfGhIjK\"\nOutput: \"\"\nExplanation:\nThere is no letter that appears in both lower and upper case.\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- s consists of lowercase and uppercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n    assert candidate(s = \"mMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n    assert candidate(s = \"zZyYxXwWeE\") == \"Z\"\n    assert candidate(s = \"zZyYxXwWvVuUtTrRsSqQpPoOnNmMlLkKiIjJhHgGfFeEdDcCbBaA\") == \"Z\"\n    assert candidate(s = \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY\") == \"Y\"\n    assert candidate(s = \"alluppercase\") == \"\"\n    assert candidate(s = \"ALLLOWERCASE\") == \"\"\n    assert candidate(s = \"aBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"Z\"\n    assert candidate(s = \"AbCdEfGhIjK\") == \"\"\n    assert candidate(s = \"a\") == \"\"\n    assert candidate(s = \"NoUpperCaseHere\") == \"\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"Z\"\n    assert candidate(s = \"bA\") == \"\"\n    assert candidate(s = \"AbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n    assert candidate(s = \"NnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"Z\"\n    assert candidate(s = \"lEeTcOdE\") == \"E\"\n    assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n    assert candidate(s = \"arRAzFif\") == \"R\"\n    assert candidate(s = \"abcdefgHIJKLMnoPQRSTuVwxyz\") == \"\"\n    assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\") == \"\"\n    assert candidate(s = \"aA\") == \"A\"\n    assert candidate(s = \"A\") == \"\"\n    assert candidate(s = \"AaBbCc\") == \"C\"\n    assert candidate(s = \"zZ\") == \"Z\"\n    assert candidate(s = \"MmQqEe\") == \"Q\"\n    assert candidate(s = \"aB\") == \"\"\n    assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == \"\"\n    assert candidate(s = \"qUICkBrOwNBROWNfOX\") == \"W\"\n    assert candidate(s = \"pUrPLe\") == \"P\"\n    assert candidate(s = \"ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJjIiHhGgFfEeDdCcBbAa\") == \"Z\"\n    assert candidate(s = \"aBcD\") == \"\"\n    assert candidate(s = \"bLuE\") == \"\"\n    assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"\"\n    assert candidate(s = \"xYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwW\") == \"Z\"\n    assert candidate(s = \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n    assert candidate(s = \"bAcBdCeCdFdEgFhG\") == \"G\"\n    assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"Z\"\n    assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZzZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaAaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n    assert candidate(s = \"hYsS\") == \"S\"\n    assert candidate(s = \"thisIsAtEsTString\") == \"T\"\n    assert candidate(s = \"xyzXYZuvwUVWtTqsSRpqPRonmNMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"Z\"\n    assert candidate(s = \"AaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa\") == \"A\"\n    assert candidate(s = \"aAaaAAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"A\"\n    assert candidate(s = \"noUpperLower\") == \"\"\n    assert candidate(s = \"UnIqUe\") == \"\"\n    assert candidate(s = \"mAgEnTa\") == \"A\"\n    assert candidate(s = \"aAaAaAaAaAaA\") == \"A\"\n    assert candidate(s = \"AaaaBBbbbCCCCDDDdeeeFFGHHHIIIJJJ\") == \"D\"\n    assert candidate(s = \"xyzABCxyzABC\") == \"\"\n    assert candidate(s = \"aNdSoMeSpEcIaLChArAcTeRs\") == \"S\"\n    assert candidate(s = \"withSomeDuPpLicaTeS\") == \"T\"\n    assert candidate(s = \"bBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBb\") == \"B\"\n    assert candidate(s = \"mNnOoPpQqRrSsTtUuVvWwXxYyZzLlKkJjIiHhGgFfEeDdCcBbAa\") == \"Z\"\n    assert candidate(s = \"abcdefghiJklmnopqrStuvWxyzZ\") == \"Z\"\n    assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n    assert candidate(s = \"abcdefGHIJKLmnopQRStuvWXYZ\") == \"\"\n    assert candidate(s = \"mMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlL\") == \"Z\"\n    assert candidate(s = \"aBcDdEfGgHiJjKlMmNoPpQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n    assert candidate(s = \"gRaY\") == \"\"\n    assert candidate(s = \"butNoVaLiDgReaTtEsT\") == \"T\"\n    assert candidate(s = \"mIXeDuPpLeTeXt\") == \"T\"\n    assert candidate(s = \"nNoOlLkKiIjJhHgGfFeEdDcCbBaA\") == \"O\"\n    assert candidate(s = \"cYaN\") == \"\"\n    assert candidate(s = \"sUpErCoMpLeXtExT\") == \"X\"\n    assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzZ\") == \"Z\"\n    assert candidate(s = \"mIxEdCaSeStRiNg\") == \"I\"\n    assert candidate(s = \"MmLlKkJjIiHhGgFfEeDdCcBbAa\") == \"M\"\n    assert candidate(s = \"abcdefgHIJKLmnopqRSTUVWxyz\") == \"\"\n    assert candidate(s = \"mM\") == \"M\"\n    assert candidate(s = \"AbcDefGhIjKlMnopQRStuvWXYZ\") == \"\"\n    assert candidate(s = \"ZZZaaaBBBcccDDDeeeFFFgggHHHiiiJJJkkkLLLmmmNNNoooPPPqqqRRRsssTTTuuuVVVwwwXXXyyyzzz\") == \"Z\"\n    assert candidate(s = \"tEsTiNgUpPeRaNdLoWeRcAsE\") == \"T\"\n    assert candidate(s = \"sUnShInESoNnY\") == \"S\"\n    assert candidate(s = \"xYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxYxY\") == \"\"\n    assert candidate(s = \"mNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"Z\"\n    assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"Z\"\n    assert candidate(s = \"zZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY\") == \"Z\"\n    assert candidate(s = \"aNkLmNpQrStUvWxYzZ\") == \"Z\"\n    assert candidate(s = \"sTrInGtEsTcAsE\") == \"T\"\n    assert candidate(s = \"aAaAaAbBbBcCcCdDdDeEeEfFfFgGgGhHhHiIiIjJjJkKkKlLlLmMmMnNnNoOpPqQrRsStTuUvVwWxXyYzZzZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"Z\"\n    assert candidate(s = \"gReEn\") == \"E\"\n    assert candidate(s = \"mnopQRstUVwXYZ\") == \"\"\n    assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n    assert candidate(s = \"mnopqrStuvWxyzZ\") == \"Z\"\n    assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n    assert candidate(s = \"zZyYxXwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"Z\"\n    assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"A\"\n    assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaA\") == \"A\"\n    assert candidate(s = \"abcdefghijkLmnopqrstUvwxyz\") == \"\"\n    assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"Z\"\n    assert candidate(s = \"aNnBmMlLkKiIjJhHgGfFeEdDcCbBaA\") == \"N\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmooppqqrrssttuuvvwwxxyyzz\") == \"\"\n    assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"Z\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"\"\n    assert candidate(s = \"aBcDxyzXYZaBcD\") == \"Z\"\n    assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"Z\"\n    assert candidate(s = \"fUnNyCaSe\") == \"N\"\n    assert candidate(s = \"oRaNgE\") == \"\"\n    assert candidate(s = \"aBcDfEgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n    assert candidate(s = \"xyZzXyZzXyZzXyZzXyZzXyZzXyZzXyZzXyZz\") == \"Z\"\n    assert candidate(s = \"bAcAdAeAfAgAhAiAjAkAlAmAnAoApAqArAsAtAuAvAwAxAyAz\") == \"\"\n    assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"A\"\n    assert candidate(s = \"qQwWeErRtTyYuUiIoOpPlLkKjJhHgGfFdDsSaAzZ\") == \"Z\"\n    assert candidate(s = \"xyzXYZabcABCdefDEFghiGHIjklJKLmnopMNOpqrQRstSTuvwUVWxyzXYZ\") == \"Z\"\n    assert candidate(s = \"MiXeDcAsEnOnCaSeTeStStRiNg\") == \"T\"\n    assert candidate(s = \"jUmBlEdTeXt\") == \"T\"\n    assert candidate(s = \"aBcDefGHiJkLmNoPqRsTuVwXyZZzz\") == \"Z\"\n    assert candidate(s = \"aAeEiIoOuUaAeEiIoOuUaAeEiIoOuU\") == \"U\"\n    assert candidate(s = \"abCDxyzXYZ\") == \"Z\"\n    assert candidate(s = \"oNeTwOThReEfOuRfIvEsIxTEnElEvEnTiGoNeVeNtWeNtYtHrEe\") == \"W\"\n    assert candidate(s = \"mAgIc\") == \"\"\n    assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"Z\"\n    assert candidate(s = \"ABCDEFGhijklmNopqrStuvWxyz\") == \"\"\n    assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"\"\n", "comparison": "exact"}, "public_tests": ["\"lEeTcOdE\"", "\"arRAzFif\"", "\"AbCdEfGhIjK\""], "hints": ["Consider iterating through the string and storing each unique character that occurs in a set.", "From Z to A, check whether both the uppercase and lowercase version occur in the set."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().greatestLetter", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:20+00:00", "tests_total": 117, "tests_dropped": 2, "flags": [], "topic_tags": ["hash-table", "string", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def greatestLetter(self, s: str) -> str:", "container": "Solution", "callable": "greatestLetter", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2310, "task_id": "sum-of-numbers-with-units-digit-k", "difficulty": "Medium", "problem_description": "Given two integers num and k, consider a set of positive integers with the following properties:\n\n- The units digit of each integer is k.\n- The sum of the integers is num.\n\nReturn the minimum possible size of such a set, or -1 if no such set exists.\n\nNote:\n\n- The set can contain multiple instances of the same integer, and the sum of an empty set is considered 0.\n- The units digit of a number is the rightmost digit of the number.\n\nExample 1:\n\nInput: num = 58, k = 9\nOutput: 2\nExplanation:\nOne valid set is [9,49], as the sum is 58 and each integer has a units digit of 9.\nAnother valid set is [19,39].\nIt can be shown that 2 is the minimum possible size of a valid set.\n\nExample 2:\n\nInput: num = 37, k = 2\nOutput: -1\nExplanation: It is not possible to obtain a sum of 37 using only integers that have a units digit of 2.\n\nExample 3:\n\nInput: num = 0, k = 7\nOutput: 0\nExplanation: The sum of an empty set is considered 0.\n\nConstraints:\n\n- 0 <= num <= 3000\n- 0 <= k <= 9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num = 25,k = 5) == 1\n    assert candidate(num = 2023,k = 3) == 1\n    assert candidate(num = 37,k = 2) == -1\n    assert candidate(num = 100,k = 0) == 1\n    assert candidate(num = 58,k = 9) == 2\n    assert candidate(num = 99,k = 9) == 1\n    assert candidate(num = 15,k = 3) == 5\n    assert candidate(num = 27,k = 9) == 3\n    assert candidate(num = 888,k = 8) == 1\n    assert candidate(num = 0,k = 7) == 0\n    assert candidate(num = 100,k = 1) == 10\n    assert candidate(num = 88,k = 8) == 1\n    assert candidate(num = 20,k = 5) == 2\n    assert candidate(num = 45,k = 5) == 1\n    assert candidate(num = 1,k = 1) == 1\n    assert candidate(num = 999,k = 9) == 1\n    assert candidate(num = 100,k = 3) == 10\n    assert candidate(num = 9,k = 9) == 1\n    assert candidate(num = 10,k = 0) == 1\n    assert candidate(num = 100,k = 9) == 10\n    assert candidate(num = 666,k = 6) == 1\n    assert candidate(num = 345,k = 4) == -1\n    assert candidate(num = 1000,k = 5) == 2\n    assert candidate(num = 123,k = 3) == 1\n    assert candidate(num = 2997,k = 7) == 1\n    assert candidate(num = 2999,k = 9) == 1\n    assert candidate(num = 275,k = 5) == 1\n    assert candidate(num = 3000,k = 1) == 10\n    assert candidate(num = 222,k = 2) == 1\n    assert candidate(num = 210,k = 1) == 10\n    assert candidate(num = 256,k = 7) == 8\n    assert candidate(num = 1995,k = 5) == 1\n    assert candidate(num = 900,k = 0) == 1\n    assert candidate(num = 456,k = 4) == 4\n    assert candidate(num = 256,k = 8) == 2\n    assert candidate(num = 789,k = 9) == 1\n    assert candidate(num = 21,k = 1) == 1\n    assert candidate(num = 202,k = 2) == 1\n    assert candidate(num = 333,k = 3) == 1\n    assert candidate(num = 150,k = 5) == 2\n    assert candidate(num = 123,k = 8) == -1\n    assert candidate(num = 2500,k = 5) == 2\n    assert candidate(num = 400,k = 6) == 5\n    assert candidate(num = 1234,k = 8) == 3\n    assert candidate(num = 777,k = 1) == 7\n    assert candidate(num = 234,k = 5) == -1\n    assert candidate(num = 3000,k = 9) == 10\n    assert candidate(num = 2345,k = 4) == -1\n    assert candidate(num = 678,k = 8) == 1\n    assert candidate(num = 999,k = 3) == 3\n    assert candidate(num = 145,k = 6) == -1\n    assert candidate(num = 56,k = 0) == -1\n    assert candidate(num = 777,k = 7) == 1\n    assert candidate(num = 2999,k = 3) == 3\n    assert candidate(num = 1200,k = 0) == 1\n    assert candidate(num = 567,k = 2) == -1\n    assert candidate(num = 444,k = 4) == 1\n    assert candidate(num = 50,k = 5) == 2\n    assert candidate(num = 999,k = 1) == 9\n    assert candidate(num = 256,k = 6) == 1\n    assert candidate(num = 189,k = 9) == 1\n    assert candidate(num = 555,k = 5) == 1\n    assert candidate(num = 111,k = 1) == 1\n    assert candidate(num = 450,k = 5) == 2\n    assert candidate(num = 0,k = 0) == 0\n    assert candidate(num = 299,k = 9) == 1\n    assert candidate(num = 250,k = 7) == 10\n    assert candidate(num = 768,k = 4) == 2\n    assert candidate(num = 1985,k = 5) == 1\n    assert candidate(num = 1500,k = 0) == 1\n    assert candidate(num = 3000,k = 5) == 2\n    assert candidate(num = 2875,k = 7) == 5\n    assert candidate(num = 158,k = 8) == 1\n    assert candidate(num = 99,k = 2) == -1\n    assert candidate(num = 1234,k = 4) == 1\n    assert candidate(num = 234,k = 4) == 1\n    assert candidate(num = 111,k = 2) == -1\n    assert candidate(num = 101,k = 1) == 1\n    assert candidate(num = 3000,k = 0) == 1\n    assert candidate(num = 143,k = 3) == 1\n    assert candidate(num = 800,k = 2) == 5\n    assert candidate(num = 1024,k = 3) == 8\n    assert candidate(num = 303,k = 3) == 1\n    assert candidate(num = 888,k = 2) == 4\n    assert candidate(num = 500,k = 5) == 2\n    assert candidate(num = 123,k = 4) == -1\n    assert candidate(num = 1234,k = 7) == 2\n    assert candidate(num = 1000,k = 1) == 10\n    assert candidate(num = 75,k = 5) == 1\n    assert candidate(num = 1999,k = 9) == 1\n    assert candidate(num = 243,k = 7) == 9\n    assert candidate(num = 1998,k = 8) == 1\n    assert candidate(num = 246,k = 7) == 8\n    assert candidate(num = 135,k = 5) == 1\n    assert candidate(num = 676,k = 6) == 1\n    assert candidate(num = 123,k = 1) == 3\n    assert candidate(num = 150,k = 1) == 10\n    assert candidate(num = 2500,k = 0) == 1\n    assert candidate(num = 2345,k = 9) == 5\n    assert candidate(num = 5,k = 0) == -1\n    assert candidate(num = 999,k = 5) == -1\n    assert candidate(num = 250,k = 5) == 2\n    assert candidate(num = 147,k = 6) == -1\n    assert candidate(num = 199,k = 9) == 1\n    assert candidate(num = 1000,k = 0) == 1\n    assert candidate(num = 2468,k = 8) == 1\n    assert candidate(num = 2024,k = 4) == 1\n    assert candidate(num = 234,k = 3) == 8\n    assert candidate(num = 1111,k = 1) == 1\n", "comparison": "exact"}, "public_tests": ["58\n9", "37\n2", "0\n7"], "hints": ["Try solving this recursively.", "Create a method that takes an integer x as a parameter. This method returns the minimum possible size of a set where each number has units digit k and the sum of the numbers in the set is x."], "metadata": {"canonical_parameter_names": ["num", "k"], "leetcode_dataset_entry_point": "Solution().minimumNumbers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:22+00:00", "tests_total": 114, "tests_dropped": 5, "flags": [], "topic_tags": ["math", "dynamic-programming", "greedy", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def minimumNumbers(self, num: int, k: int) -> int:", "container": "Solution", "callable": "minimumNumbers", "parameters": [{"name": "num", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2311, "task_id": "longest-binary-subsequence-less-than-or-equal-to-k", "difficulty": "Medium", "problem_description": "You are given a binary string s and a positive integer k.\n\nReturn the length of the longest subsequence of s that makes up a binary number less than or equal to k.\n\nNote:\n\n- The subsequence can contain leading zeroes.\n- The empty string is considered to be equal to 0.\n- A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n\nExample 1:\n\nInput: s = \"1001010\", k = 5\nOutput: 5\nExplanation: The longest subsequence of s that makes up a binary number less than or equal to 5 is \"00010\", as this number is equal to 2 in decimal.\nNote that \"00100\" and \"00101\" are also possible, which are equal to 4 and 5 in decimal, respectively.\nThe length of this subsequence is 5, so 5 is returned.\n\nExample 2:\n\nInput: s = \"00101001\", k = 1\nOutput: 6\nExplanation: \"000001\" is the longest subsequence of s that makes up a binary number less than or equal to 1, as this number is equal to 1 in decimal.\nThe length of this subsequence is 6, so 6 is returned.\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- s[i] is either '0' or '1'.\n- 1 <= k <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"111000111\",k = 127) == 7\n    assert candidate(s = \"1111111\",k = 127) == 7\n    assert candidate(s = \"1111000011\",k = 255) == 8\n    assert candidate(s = \"1100110011\",k = 10) == 6\n    assert candidate(s = \"1010101010\",k = 512) == 9\n    assert candidate(s = \"10101010\",k = 10) == 6\n    assert candidate(s = \"111000111\",k = 50) == 6\n    assert candidate(s = \"1101001\",k = 4) == 4\n    assert candidate(s = \"11111111\",k = 15) == 4\n    assert candidate(s = \"0101010101\",k = 512) == 10\n    assert candidate(s = \"1101101\",k = 7) == 4\n    assert candidate(s = \"1100110011\",k = 500) == 9\n    assert candidate(s = \"0000000\",k = 10) == 7\n    assert candidate(s = \"1001010\",k = 5) == 5\n    assert candidate(s = \"00000\",k = 1000) == 5\n    assert candidate(s = \"0101010101\",k = 255) == 9\n    assert candidate(s = \"1\",k = 1) == 1\n    assert candidate(s = \"11111111\",k = 255) == 8\n    assert candidate(s = \"0000111100\",k = 31) == 9\n    assert candidate(s = \"101010\",k = 3) == 4\n    assert candidate(s = \"1111000011110000\",k = 100000) == 16\n    assert candidate(s = \"1100110011\",k = 100) == 8\n    assert candidate(s = \"1010101010\",k = 10) == 7\n    assert candidate(s = \"100110011001100110\",k = 1000) == 14\n    assert candidate(s = \"11001100\",k = 20) == 6\n    assert candidate(s = \"00000000\",k = 8) == 8\n    assert candidate(s = \"00101001\",k = 1) == 6\n    assert candidate(s = \"010101010101010101\",k = 10000) == 16\n    assert candidate(s = \"100101010010101010101010\",k = 1024) == 18\n    assert candidate(s = \"1010101010101010101010101\",k = 1048575) == 22\n    assert candidate(s = \"11001100110011001100110011001100110011001100110011001100\",k = 1000000) == 38\n    assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101010\",k = 10) == 36\n    assert candidate(s = \"10101010101010101010101010101010101010101010101010101010\",k = 1023) == 33\n    assert candidate(s = \"110011001100110011001100110011001100110011001100\",k = 65535) == 32\n    assert candidate(s = \"001100110011001100110011001100110011001100110011001100110011\",k = 4096) == 36\n    assert candidate(s = \"1101101101101101101101101\",k = 1000) == 15\n    assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111111111\",k = 2047) == 11\n    assert candidate(s = \"00000000000000000000000000000000000000000000000000000000\",k = 1000) == 56\n    assert candidate(s = \"0101010101010101010101010101010101010101\",k = 1023) == 25\n    assert candidate(s = \"00001111000011110000111100001111000011110000111100001111\",k = 32767) == 36\n    assert candidate(s = \"1001001001001001001001001001001001001001\",k = 10000) == 31\n    assert candidate(s = \"11010110101101011010110101101011010110101101011010110101\",k = 1048575) == 34\n    assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001\",k = 5000) == 43\n    assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011001100110011001100110011001100\",k = 128) == 47\n    assert candidate(s = \"10010101010101010101\",k = 30000) == 18\n    assert candidate(s = \"111000111000111000111000111000111000111000111000111000111000111000111000\",k = 50000) == 43\n    assert candidate(s = \"11010101010101010101\",k = 16383) == 16\n    assert candidate(s = \"1101001101001101001101001101001\",k = 1024) == 20\n    assert candidate(s = \"1111111111111111111111111111111111111111\",k = 1024) == 10\n    assert candidate(s = \"0101010101010101010101010101010101010101\",k = 10) == 22\n    assert candidate(s = \"1001100110011001100110011001100110011001\",k = 2000) == 25\n    assert candidate(s = \"1100110011001100\",k = 1000) == 12\n    assert candidate(s = \"10101010101010101010101010101010101010101010\",k = 1000000) == 32\n    assert candidate(s = \"01010101010101010101010101010101010101010101010101010101010101010101\",k = 1000) == 39\n    assert candidate(s = \"11111111111111111111111111111111111111111111\",k = 1048575) == 20\n    assert candidate(s = \"1111111111111111111111111\",k = 1048575) == 20\n    assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 500) == 48\n    assert candidate(s = \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",k = 1000000000) == 29\n    assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000\",k = 1) == 65\n    assert candidate(s = \"0011001100110011001100110011001100110011\",k = 5000) == 27\n    assert candidate(s = \"111111111100000000111111111000000011111111100000001111111110000000111111111000000011111111\",k = 10000000) == 52\n    assert candidate(s = \"1101101101101101101101101101101101101101\",k = 500) == 19\n    assert candidate(s = \"100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000\",k = 500000000) == 115\n    assert candidate(s = \"11110000111100001111000011110000111100001111000011110000\",k = 65535) == 36\n    assert candidate(s = \"100000000000000000000000000000000000000000000000\",k = 1000000000) == 47\n    assert candidate(s = \"11001100110011001100110011001100\",k = 2048) == 21\n    assert candidate(s = \"101010101010101010101010101010101010101010101010101010101\",k = 2048) == 34\n    assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 100) == 48\n    assert candidate(s = \"111000111000111000111000111000111000111000111000111000111000111000111\",k = 500) == 39\n    assert candidate(s = \"01010101010101010101010101010101010101010101010101010101\",k = 511) == 33\n    assert candidate(s = \"01110111011101110111011101110111011101110111011101110111\",k = 524287) == 29\n    assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 1048575) == 53\n    assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010\",k = 65535) == 44\n    assert candidate(s = \"1111000011110000111100001111000011110000\",k = 10000) == 25\n    assert candidate(s = \"0000000000000000000000000\",k = 1) == 25\n    assert candidate(s = \"000111000111000111000111000111000111000111000111000111000111000111000111\",k = 25000) == 44\n    assert candidate(s = \"1110000011100000111000001110000011100000111000001110000011100000111000001110000011100000\",k = 255) == 58\n    assert candidate(s = \"010101010101010101010101010101010101010101010101\",k = 524287) == 34\n    assert candidate(s = \"1110001110001110001110001\",k = 2048) == 17\n    assert candidate(s = \"1111000011110000111100001111000011110000111100001111000011110000\",k = 10000) == 37\n    assert candidate(s = \"11111111111111111111111111111111111111111111111111111111\",k = 1000000000) == 29\n    assert candidate(s = \"000100010001000100010001000100010001000100010001000100010001000100010\",k = 1023) == 55\n    assert candidate(s = \"0000111111111111111111111\",k = 1048575) == 24\n    assert candidate(s = \"0011001100110011001100110011001100110011001100110011001100110011001100110011001100110011\",k = 50) == 47\n    assert candidate(s = \"10000000000000000000000000000000000000000000000000000000000000000000\",k = 1) == 67\n    assert candidate(s = \"1010101010101010101010101010101010101010\",k = 1023) == 25\n    assert candidate(s = \"110010011001001100100110010011001001100100110011001001\",k = 1023) == 34\n    assert candidate(s = \"00000000000000000000\",k = 1000) == 20\n    assert candidate(s = \"11111111111111111111111111111111111111111111111111111111\",k = 2047) == 11\n    assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111\",k = 1000000000) == 29\n    assert candidate(s = \"001010101010101010101010101010101010101010101010\",k = 1024) == 30\n    assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\",k = 999999999) == 94\n", "comparison": "exact"}, "public_tests": ["\"1001010\"\n5", "\"00101001\"\n1"], "hints": ["Choosing a subsequence from the string is equivalent to deleting all the other digits.", "If you were to remove a digit, which one should you remove to reduce the value of the string?"], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().longestSubsequence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:24+00:00", "tests_total": 101, "tests_dropped": 9, "flags": [], "topic_tags": ["string", "dynamic-programming", "greedy", "memoization"]}, "language": "python", "interface": {"raw_signature": "def longestSubsequence(self, s: str, k: int) -> int:", "container": "Solution", "callable": "longestSubsequence", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2312, "task_id": "selling-pieces-of-wood", "difficulty": "Hard", "problem_description": "You are given two integers m and n that represent the height and width of a rectangular piece of wood. You are also given a 2D integer array prices, where prices[i] = [h_i, w_i, price_i] indicates you can sell a rectangular piece of wood of height h_i and width w_i for price_i dollars.\n\nTo cut a piece of wood, you must make a vertical or horizontal cut across the entire height or width of the piece to split it into two smaller pieces. After cutting a piece of wood into some number of smaller pieces, you can sell pieces according to prices. You may sell multiple pieces of the same shape, and you do not have to sell all the shapes. The grain of the wood makes a difference, so you cannot rotate a piece to swap its height and width.\n\nReturn the maximum money you can earn after cutting an m x n piece of wood.\n\nNote that you can cut the piece of wood as many times as you want.\n\nExample 1:\n\nInput: m = 3, n = 5, prices = [[1,4,2],[2,2,7],[2,1,3]]\nOutput: 19\nExplanation: The diagram above shows a possible scenario. It consists of:\n- 2 pieces of wood shaped 2 x 2, selling for a price of 2 * 7 = 14.\n- 1 piece of wood shaped 2 x 1, selling for a price of 1 * 3 = 3.\n- 1 piece of wood shaped 1 x 4, selling for a price of 1 * 2 = 2.\nThis obtains a total of 14 + 3 + 2 = 19 money earned.\nIt can be shown that 19 is the maximum amount of money that can be earned.\n\nExample 2:\n\nInput: m = 4, n = 6, prices = [[3,2,10],[1,4,2],[4,1,3]]\nOutput: 32\nExplanation: The diagram above shows a possible scenario. It consists of:\n- 3 pieces of wood shaped 3 x 2, selling for a price of 3 * 10 = 30.\n- 1 piece of wood shaped 1 x 4, selling for a price of 1 * 2 = 2.\nThis obtains a total of 30 + 2 = 32 money earned.\nIt can be shown that 32 is the maximum amount of money that can be earned.\nNotice that we cannot rotate the 1 x 4 piece of wood to obtain a 4 x 1 piece of wood.\n\nConstraints:\n\n- 1 <= m, n <= 200\n- 1 <= prices.length <= 2 * 10^4\n- prices[i].length == 3\n- 1 <= h_i <= m\n- 1 <= w_i <= n\n- 1 <= price_i <= 10^6\n- All the shapes of wood (h_i, w_i) are pairwise distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(m = 4,n = 6,prices = [[3, 2, 10], [1, 4, 2], [4, 1, 3]]) == 32\n    assert candidate(m = 2,n = 2,prices = [[1, 1, 1], [2, 2, 5]]) == 5\n    assert candidate(m = 3,n = 5,prices = [[1, 4, 2], [2, 2, 7], [2, 1, 3]]) == 19\n    assert candidate(m = 200,n = 200,prices = [[1, 1, 1], [2, 2, 2], [3, 3, 3]]) == 40000\n    assert candidate(m = 2,n = 2,prices = [[2, 2, 5]]) == 5\n    assert candidate(m = 1,n = 1,prices = [[1, 1, 100]]) == 100\n    assert candidate(m = 5,n = 5,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20]]) == 29\n    assert candidate(m = 5,n = 5,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 20], [5, 5, 50]]) == 50\n    assert candidate(m = 10,n = 10,prices = [[1, 1, 1], [1, 2, 3], [2, 1, 3], [2, 2, 5], [3, 3, 10], [5, 5, 20]]) == 150\n    assert candidate(m = 15,n = 15,prices = [[1, 1, 1], [2, 2, 4], [3, 3, 9], [4, 4, 16], [5, 5, 25], [6, 6, 36], [7, 7, 49], [8, 8, 64], [9, 9, 81], [10, 10, 100], [11, 11, 121], [12, 12, 144], [13, 13, 169], [14, 14, 196], [15, 15, 225]]) == 225\n    assert candidate(m = 90,n = 60,prices = [[5, 5, 25], [10, 10, 100], [15, 15, 225], [20, 20, 400], [25, 25, 625]]) == 5400\n    assert candidate(m = 10,n = 5,prices = [[1, 1, 2], [1, 2, 4], [1, 3, 6], [1, 4, 8], [1, 5, 10], [2, 1, 4], [2, 2, 8], [2, 3, 12], [2, 4, 16], [2, 5, 20], [3, 1, 6], [3, 2, 12], [3, 3, 18], [3, 4, 24], [3, 5, 30], [4, 1, 8], [4, 2, 16], [4, 3, 24], [4, 4, 32], [4, 5, 40], [5, 1, 10], [5, 2, 20], [5, 3, 30], [5, 4, 40], [5, 5, 50]]) == 100\n    assert candidate(m = 100,n = 100,prices = [[50, 50, 2500], [25, 25, 625], [75, 75, 4500], [10, 10, 25], [1, 1, 1]]) == 10000\n    assert candidate(m = 50,n = 50,prices = [[5, 5, 25], [10, 10, 100], [25, 25, 625], [45, 45, 2025], [1, 1, 1]]) == 2500\n    assert candidate(m = 150,n = 100,prices = [[10, 20, 100], [15, 10, 200], [20, 15, 250], [50, 50, 1500], [75, 75, 5000]]) == 20000\n    assert candidate(m = 5,n = 5,prices = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40], [5, 5, 50]]) == 250\n    assert candidate(m = 150,n = 100,prices = [[1, 1, 1], [5, 5, 10], [10, 10, 20], [15, 15, 30], [25, 25, 40], [50, 50, 100]]) == 15000\n    assert candidate(m = 180,n = 90,prices = [[1, 1, 2], [2, 2, 8], [3, 3, 18], [4, 4, 32], [5, 5, 50], [6, 6, 72], [7, 7, 98], [8, 8, 128], [9, 9, 162], [10, 10, 200], [15, 15, 750], [30, 30, 3000], [45, 45, 6750], [90, 90, 20250]]) == 54000\n    assert candidate(m = 50,n = 50,prices = [[1, 1, 2], [2, 2, 6], [3, 3, 18], [4, 4, 40], [5, 5, 75], [10, 10, 300], [15, 15, 800], [25, 25, 1200]]) == 8625\n    assert candidate(m = 160,n = 140,prices = [[1, 2, 1], [2, 1, 2], [3, 4, 3], [4, 3, 4], [5, 6, 5], [6, 5, 6], [7, 8, 7], [8, 7, 8], [9, 10, 9], [10, 9, 10]]) == 22400\n    assert candidate(m = 150,n = 120,prices = [[50, 40, 2000], [75, 60, 3600], [25, 30, 600], [10, 15, 150], [1, 1, 1]]) == 18000\n    assert candidate(m = 100,n = 100,prices = [[10, 10, 50], [20, 20, 100], [30, 30, 150], [50, 50, 300]]) == 5000\n    assert candidate(m = 20,n = 30,prices = [[1, 1, 1], [2, 2, 4], [3, 3, 9], [4, 4, 16], [5, 5, 25], [10, 10, 100], [15, 15, 225]]) == 600\n    assert candidate(m = 120,n = 80,prices = [[20, 10, 200], [10, 20, 150], [30, 30, 900], [60, 40, 2400], [40, 60, 3000]]) == 11400\n    assert candidate(m = 80,n = 60,prices = [[20, 15, 300], [10, 10, 100], [40, 30, 1200], [60, 40, 2400], [50, 50, 3000], [1, 1, 1]]) == 5300\n    assert candidate(m = 110,n = 90,prices = [[30, 20, 600], [60, 40, 2400], [15, 10, 150], [50, 30, 1500], [1, 1, 1]]) == 9900\n    assert candidate(m = 100,n = 100,prices = [[10, 10, 50], [20, 20, 200], [30, 30, 500], [40, 40, 1000], [50, 50, 2000]]) == 8000\n    assert candidate(m = 180,n = 160,prices = [[10, 10, 50], [20, 20, 200], [30, 30, 500], [40, 40, 1000], [50, 50, 2000], [60, 60, 3000]]) == 22650\n    assert candidate(m = 50,n = 50,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [5, 5, 50], [10, 10, 100], [25, 25, 5000], [50, 50, 100000]]) == 100000\n    assert candidate(m = 200,n = 100,prices = [[1, 1, 1], [1, 2, 2], [2, 1, 3], [2, 2, 5], [10, 10, 100], [20, 20, 500], [30, 30, 1200], [50, 50, 2500], [100, 100, 10000]]) == 30000\n    assert candidate(m = 80,n = 120,prices = [[1, 2, 2], [2, 1, 3], [2, 3, 5], [3, 2, 6], [4, 6, 12], [6, 4, 15], [8, 12, 24], [12, 8, 30]]) == 14400\n    assert candidate(m = 150,n = 100,prices = [[10, 10, 100], [20, 20, 500], [30, 30, 1200], [15, 15, 300]]) == 19500\n    assert candidate(m = 200,n = 100,prices = [[1, 1, 1], [2, 2, 2], [4, 4, 4], [8, 8, 8], [16, 16, 16], [32, 32, 32]]) == 20000\n    assert candidate(m = 10,n = 20,prices = [[1, 1, 1], [2, 2, 4], [3, 3, 9], [4, 4, 16], [5, 5, 25], [6, 6, 36], [7, 7, 49], [8, 8, 64], [9, 9, 81], [10, 10, 100]]) == 200\n    assert candidate(m = 200,n = 200,prices = [[10, 20, 100], [20, 30, 250], [30, 40, 500], [40, 50, 750], [50, 60, 1000]]) == 20000\n    assert candidate(m = 190,n = 190,prices = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [2, 1, 2], [2, 2, 5], [2, 3, 6], [3, 1, 3], [3, 2, 6], [3, 3, 10]]) == 45125\n    assert candidate(m = 100,n = 100,prices = [[10, 10, 100], [20, 20, 300], [30, 30, 600], [40, 40, 1000], [50, 50, 1500]]) == 10000\n    assert candidate(m = 120,n = 80,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25], [7, 7, 35], [8, 8, 45], [9, 9, 55], [10, 10, 65], [11, 11, 75], [12, 12, 85], [13, 13, 95], [14, 14, 105], [15, 15, 115], [16, 16, 125], [17, 17, 135], [18, 18, 145], [19, 19, 155], [20, 20, 165], [21, 21, 175], [22, 22, 185], [23, 23, 195], [24, 24, 205], [25, 25, 215], [26, 26, 225], [27, 27, 235], [28, 28, 245], [29, 29, 255], [30, 30, 265], [31, 31, 275], [32, 32, 285], [33, 33, 295], [34, 34, 305], [35, 35, 315], [36, 36, 325], [37, 37, 335], [38, 38, 345], [39, 39, 355], [40, 40, 365], [41, 41, 375], [42, 42, 385], [43, 43, 395], [44, 44, 405], [45, 45, 415], [46, 46, 425], [47, 47, 435], [48, 48, 445], [49, 49, 455], [50, 50, 465], [51, 51, 475], [52, 52, 485], [53, 53, 495], [54, 54, 505], [55, 55, 515], [56, 56, 525], [57, 57, 535], [58, 58, 545], [59, 59, 555], [60, 60, 565], [61, 61, 575], [62, 62, 585], [63, 63, 595], [64, 64, 605], [65, 65, 615], [66, 66, 625], [67, 67, 635], [68, 68, 645], [69, 69, 655], [70, 70, 665], [71, 71, 675], [72, 72, 685], [73, 73, 695], [74, 74, 705], [75, 75, 715], [76, 76, 725], [77, 77, 735], [78, 78, 745], [79, 79, 755], [80, 80, 765]]) == 12000\n    assert candidate(m = 80,n = 60,prices = [[10, 20, 500], [20, 30, 1500], [30, 40, 2700], [40, 50, 4000]]) == 12000\n    assert candidate(m = 120,n = 80,prices = [[1, 1, 1], [2, 2, 5], [4, 4, 20], [8, 8, 100], [16, 16, 500], [32, 32, 2000], [64, 64, 5000], [120, 80, 10000]]) == 18500\n    assert candidate(m = 200,n = 200,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25], [7, 7, 35], [8, 8, 45], [9, 9, 55], [10, 10, 65], [11, 11, 75], [12, 12, 85], [13, 13, 95], [14, 14, 105], [15, 15, 115], [16, 16, 125], [17, 17, 135], [18, 18, 145], [19, 19, 155], [20, 20, 165], [21, 21, 175], [22, 22, 185], [23, 23, 195], [24, 24, 205], [25, 25, 215], [26, 26, 225], [27, 27, 235], [28, 28, 245], [29, 29, 255], [30, 30, 265]]) == 50000\n    assert candidate(m = 200,n = 100,prices = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [5, 5, 5], [10, 10, 10], [20, 20, 20], [50, 50, 50], [100, 100, 100]]) == 20000\n    assert candidate(m = 15,n = 12,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25]]) == 222\n    assert candidate(m = 200,n = 150,prices = [[50, 50, 1000], [75, 75, 3000], [100, 100, 5000], [150, 150, 8000]]) == 15000\n    assert candidate(m = 180,n = 180,prices = [[1, 1, 3], [2, 2, 6], [3, 3, 9], [4, 4, 12], [5, 5, 15], [6, 6, 18], [7, 7, 21], [8, 8, 24], [9, 9, 27]]) == 97200\n    assert candidate(m = 175,n = 110,prices = [[10, 5, 50], [5, 10, 75], [20, 10, 150], [10, 20, 200], [15, 15, 300], [25, 25, 500], [50, 50, 1000]]) == 28875\n    assert candidate(m = 120,n = 80,prices = [[1, 1, 1], [2, 2, 5], [4, 4, 15], [8, 8, 30], [16, 16, 60], [32, 32, 120], [64, 64, 240]]) == 12000\n    assert candidate(m = 180,n = 120,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 20], [5, 5, 50], [6, 6, 100], [10, 10, 500], [20, 20, 2000], [30, 30, 5000], [40, 40, 10000], [50, 50, 20000], [60, 60, 50000], [120, 120, 100000], [180, 120, 150000]]) == 300000\n    assert candidate(m = 120,n = 120,prices = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]]) == 14400\n    assert candidate(m = 6,n = 4,prices = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [2, 1, 2], [2, 2, 5], [2, 3, 6], [2, 4, 8], [3, 1, 3], [3, 2, 6], [3, 3, 9], [3, 4, 12], [4, 1, 4], [4, 2, 8], [4, 3, 12], [4, 4, 16], [5, 1, 5], [5, 2, 10], [5, 3, 15], [5, 4, 20], [6, 1, 6], [6, 2, 12], [6, 3, 18], [6, 4, 24]]) == 30\n    assert candidate(m = 190,n = 190,prices = [[1, 1, 1], [10, 10, 50], [20, 20, 200], [30, 30, 500], [40, 40, 1000], [50, 50, 2000], [60, 60, 3000], [70, 70, 4000], [80, 80, 5000], [90, 90, 6000], [100, 100, 7000], [110, 110, 8000], [120, 120, 9000], [130, 130, 10000], [140, 140, 11000], [150, 150, 12000], [160, 160, 13000], [170, 170, 14000], [180, 180, 15000], [190, 190, 16000]]) == 36100\n    assert candidate(m = 80,n = 60,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 20], [5, 5, 50], [10, 10, 100], [20, 20, 500], [30, 30, 1500], [40, 40, 5000], [50, 50, 10000], [60, 60, 20000], [80, 60, 30000]]) == 30000\n    assert candidate(m = 150,n = 150,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [150, 150, 100000], [75, 75, 25000]]) == 100000\n    assert candidate(m = 150,n = 150,prices = [[1, 1, 5], [2, 2, 10], [3, 3, 15], [5, 5, 25], [10, 10, 50], [15, 15, 75]]) == 112500\n    assert candidate(m = 100,n = 100,prices = [[1, 1, 10], [10, 10, 500], [50, 50, 20000], [25, 25, 5000], [100, 100, 50000]]) == 100000\n    assert candidate(m = 120,n = 150,prices = [[1, 1, 5], [2, 2, 15], [3, 3, 45], [4, 4, 100], [5, 5, 175], [6, 6, 270], [7, 7, 392], [8, 8, 540], [9, 9, 717], [10, 10, 920], [11, 11, 1155], [12, 12, 1420], [13, 13, 1725], [14, 14, 2070], [15, 15, 2450], [16, 16, 2870], [17, 17, 3332], [18, 18, 3837], [19, 19, 4385], [20, 20, 4980]]) == 220200\n    assert candidate(m = 7,n = 3,prices = [[1, 1, 3], [1, 2, 5], [1, 3, 7], [2, 1, 6], [2, 2, 12], [2, 3, 15], [3, 1, 9], [3, 2, 18], [3, 3, 20]]) == 63\n    assert candidate(m = 100,n = 150,prices = [[5, 5, 25], [10, 10, 100], [15, 15, 250], [20, 20, 500], [25, 25, 750]]) == 18500\n    assert candidate(m = 100,n = 200,prices = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [5, 5, 5], [10, 10, 10], [20, 20, 20], [50, 50, 50], [100, 100, 100]]) == 20000\n    assert candidate(m = 100,n = 50,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25], [7, 7, 35], [8, 8, 45], [9, 9, 55], [10, 10, 65], [11, 11, 75], [12, 12, 85], [13, 13, 95], [14, 14, 105], [15, 15, 115], [16, 16, 125], [17, 17, 135], [18, 18, 145], [19, 19, 155], [20, 20, 165], [21, 21, 175], [22, 22, 185], [23, 23, 195], [24, 24, 205], [25, 25, 215], [26, 26, 225], [27, 27, 235], [28, 28, 245], [29, 29, 255], [30, 30, 265], [31, 31, 275], [32, 32, 285], [33, 33, 295], [34, 34, 305], [35, 35, 315], [36, 36, 325], [37, 37, 335], [38, 38, 345], [39, 39, 355], [40, 40, 365], [41, 41, 375], [42, 42, 385], [43, 43, 395], [44, 44, 405], [45, 45, 415], [46, 46, 425], [47, 47, 435], [48, 48, 445], [49, 49, 455], [50, 50, 465]]) == 6250\n    assert candidate(m = 100,n = 100,prices = [[1, 1, 10], [5, 5, 100], [10, 10, 500], [20, 20, 2000], [50, 50, 10000]]) == 100000\n    assert candidate(m = 120,n = 120,prices = [[1, 1, 1], [2, 2, 4], [3, 3, 9], [4, 4, 16], [5, 5, 25], [6, 6, 36], [7, 7, 49], [8, 8, 64], [9, 9, 81], [10, 10, 100], [11, 11, 121], [12, 12, 144], [13, 13, 169], [14, 14, 196], [15, 15, 225]]) == 14400\n    assert candidate(m = 120,n = 80,prices = [[1, 1, 1], [2, 2, 5], [4, 4, 20], [8, 8, 100], [16, 16, 500]]) == 18500\n    assert candidate(m = 180,n = 120,prices = [[1, 2, 1], [2, 3, 4], [3, 4, 7], [4, 5, 11], [5, 6, 16]]) == 14400\n    assert candidate(m = 180,n = 160,prices = [[90, 80, 14400], [60, 70, 8400], [30, 40, 1200], [20, 30, 600], [10, 20, 200], [1, 1, 1]]) == 57600\n    assert candidate(m = 75,n = 75,prices = [[1, 1, 2], [3, 3, 10], [5, 5, 30], [7, 7, 60], [10, 10, 120], [15, 15, 300], [20, 20, 500], [25, 25, 800], [30, 30, 1200], [35, 35, 1600], [40, 40, 2000], [45, 45, 2400], [50, 50, 2800], [55, 55, 3200], [60, 60, 3600], [65, 65, 4000], [70, 70, 4400], [75, 75, 4800]]) == 11250\n    assert candidate(m = 160,n = 100,prices = [[10, 10, 100], [20, 20, 400], [30, 30, 900], [40, 40, 1600], [50, 50, 2500]]) == 16000\n    assert candidate(m = 120,n = 80,prices = [[10, 5, 10], [5, 10, 20], [15, 5, 30], [5, 15, 40], [20, 10, 50], [10, 20, 60], [25, 5, 70], [5, 25, 80], [30, 10, 90], [10, 30, 100]]) == 6070\n    assert candidate(m = 160,n = 160,prices = [[1, 1, 1], [2, 2, 5], [4, 4, 15], [8, 8, 30], [16, 16, 60], [32, 32, 120], [64, 64, 240], [128, 128, 480]]) == 32000\n    assert candidate(m = 8,n = 6,prices = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [2, 1, 2], [2, 2, 5], [2, 3, 6], [2, 4, 8], [2, 5, 10], [2, 6, 12], [3, 1, 3], [3, 2, 6], [3, 3, 9], [3, 4, 12], [3, 5, 15], [3, 6, 18], [4, 1, 4], [4, 2, 8], [4, 3, 12], [4, 4, 16], [4, 5, 20], [4, 6, 24], [5, 1, 5], [5, 2, 10], [5, 3, 15], [5, 4, 20], [5, 5, 25], [5, 6, 30], [6, 1, 6], [6, 2, 12], [6, 3, 18], [6, 4, 24], [6, 5, 30], [6, 6, 36], [7, 1, 7], [7, 2, 14], [7, 3, 21], [7, 4, 28], [7, 5, 35], [7, 6, 42], [8, 1, 8], [8, 2, 16], [8, 3, 24], [8, 4, 32], [8, 5, 40], [8, 6, 48]]) == 60\n    assert candidate(m = 190,n = 140,prices = [[10, 10, 100], [20, 20, 400], [30, 30, 900], [40, 40, 1600], [50, 50, 2500]]) == 26600\n    assert candidate(m = 150,n = 100,prices = [[1, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25], [7, 7, 35], [8, 8, 45], [9, 9, 55], [10, 10, 65], [11, 11, 75], [12, 12, 85], [13, 13, 95], [14, 14, 105], [15, 15, 115], [16, 16, 125], [17, 17, 135], [18, 18, 145], [19, 19, 155], [20, 20, 165], [21, 21, 175], [22, 22, 185], [23, 23, 195], [24, 24, 205], [25, 25, 215], [26, 26, 225], [27, 27, 235], [28, 28, 245], [29, 29, 255], [30, 30, 265], [31, 31, 275], [32, 32, 285], [33, 33, 295], [34, 34, 305], [35, 35, 315], [36, 36, 325], [37, 37, 335], [38, 38, 345], [39, 39, 355], [40, 40, 365], [41, 41, 375], [42, 42, 385], [43, 43, 395], [44, 44, 405], [45, 45, 415], [46, 46, 425], [47, 47, 435], [48, 48, 445], [49, 49, 455], [50, 50, 465], [51, 51, 475], [52, 52, 485], [53, 53, 495], [54, 54, 505], [55, 55, 515], [56, 56, 525], [57, 57, 535], [58, 58, 545], [59, 59, 555], [60, 60, 565], [61, 61, 575], [62, 62, 585], [63, 63, 595], [64, 64, 605], [65, 65, 615], [66, 66, 625], [67, 67, 635], [68, 68, 645], [69, 69, 655], [70, 70, 665], [71, 71, 675], [72, 72, 685], [73, 73, 695], [74, 74, 705], [75, 75, 715]]) == 18750\n    assert candidate(m = 100,n = 100,prices = [[1, 1, 1], [2, 2, 4], [3, 3, 9], [4, 4, 16], [5, 5, 25], [6, 6, 36], [7, 7, 49], [8, 8, 64], [9, 9, 81], [10, 10, 100], [20, 20, 400], [30, 30, 900], [40, 40, 1600], [50, 50, 2500], [60, 60, 3600], [70, 70, 4900], [80, 80, 6400], [90, 90, 8100], [100, 100, 10000]]) == 10000\n    assert candidate(m = 180,n = 120,prices = [[10, 20, 50], [20, 10, 40], [30, 40, 120], [40, 30, 100], [60, 60, 200]]) == 5400\n    assert candidate(m = 200,n = 100,prices = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [2, 2, 5], [2, 3, 6], [2, 4, 7], [2, 5, 8], [3, 3, 9], [3, 4, 10], [3, 5, 11], [4, 4, 13], [4, 5, 14], [5, 5, 16]]) == 25000\n    assert candidate(m = 18,n = 18,prices = [[1, 1, 1], [1, 2, 3], [2, 1, 3], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25], [7, 7, 35], [8, 8, 45], [9, 9, 55], [10, 10, 65], [11, 11, 75], [12, 12, 85], [13, 13, 95], [14, 14, 105], [15, 15, 115], [16, 16, 125], [17, 17, 135], [18, 18, 145]]) == 486\n    assert candidate(m = 150,n = 100,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 20], [5, 5, 50], [6, 6, 100], [7, 7, 200], [8, 8, 500]]) == 110350\n    assert candidate(m = 150,n = 100,prices = [[10, 10, 100], [20, 20, 500], [30, 30, 1200], [5, 5, 20], [15, 15, 300]]) == 19500\n    assert candidate(m = 190,n = 130,prices = [[1, 1, 1], [2, 2, 4], [3, 3, 9], [4, 4, 16], [5, 5, 25], [10, 10, 100], [15, 15, 225], [20, 20, 400], [25, 25, 625]]) == 24700\n    assert candidate(m = 10,n = 10,prices = [[1, 1, 5], [2, 2, 10], [3, 3, 15], [4, 4, 20], [5, 5, 25], [6, 6, 30], [7, 7, 35], [8, 8, 40], [9, 9, 45], [10, 10, 50]]) == 500\n    assert candidate(m = 50,n = 50,prices = [[5, 5, 100], [10, 10, 500], [15, 15, 1200], [20, 20, 2000], [25, 25, 3000], [30, 30, 4000], [35, 35, 5000], [40, 40, 6000], [45, 45, 7000], [50, 50, 8000]]) == 12800\n    assert candidate(m = 100,n = 100,prices = [[50, 50, 10000], [25, 25, 2500], [75, 75, 15000], [10, 10, 100], [1, 1, 1]]) == 40000\n    assert candidate(m = 10,n = 10,prices = [[1, 1, 1], [2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25], [7, 7, 30], [8, 8, 35], [9, 9, 40], [10, 10, 50]]) == 125\n    assert candidate(m = 150,n = 100,prices = [[1, 1, 1], [2, 2, 5], [5, 5, 10], [10, 10, 20], [15, 15, 30]]) == 18750\n", "comparison": "exact"}, "public_tests": ["3\n5\n[[1,4,2],[2,2,7],[2,1,3]]", "4\n6\n[[3,2,10],[1,4,2],[4,1,3]]"], "hints": ["Note down the different actions that can be done on a piece of wood with dimensions m x n. What do you notice?", "If possible, we could sell the m x n piece. We could also cut the piece vertically creating two pieces of size m x n1 and m x n2 where n1 + n2 = n, or horizontally creating two pieces of size m1 x n and m2 x n where m1 + m2 = m.", "Notice that cutting a piece breaks the problem down into smaller subproblems, and selling the piece when available is also a case that terminates the process. Thus, we can use DP to efficiently solve this."], "metadata": {"canonical_parameter_names": ["m", "n", "prices"], "leetcode_dataset_entry_point": "Solution().sellingWood", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:27+00:00", "tests_total": 88, "tests_dropped": 4, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "dynamic-programming", "memoization"]}, "language": "python", "interface": {"raw_signature": "def sellingWood(self, m: int, n: int, prices: list[list[int]]) -> int:", "container": "Solution", "callable": "sellingWood", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "prices", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2315, "task_id": "count-asterisks", "difficulty": "Easy", "problem_description": "You are given a string s, where every two consecutive vertical bars '|' are grouped into a pair. In other words, the 1^st and 2^nd '|' make a pair, the 3^rd and 4^th '|' make a pair, and so forth.\n\nReturn the number of '*' in s, excluding the '*' between each pair of '|'.\n\nNote that each '|' will belong to exactly one pair.\n\nExample 1:\n\nInput: s = \"l|*e*et|c**o|*de|\"\nOutput: 2\nExplanation: The considered characters are underlined: \"l|*e*et|c**o|*de|\".\nThe characters between the first and second '|' are excluded from the answer.\nAlso, the characters between the third and fourth '|' are excluded from the answer.\nThere are 2 asterisks considered. Therefore, we return 2.\n\nExample 2:\n\nInput: s = \"iamprogrammer\"\nOutput: 0\nExplanation: In this example, there are no asterisks in s. Therefore, we return 0.\n\nExample 3:\n\nInput: s = \"yo|uar|e**|b|e***au|tifu|l\"\nOutput: 5\nExplanation: The considered characters are underlined: \"yo|uar|e**|b|e***au|tifu|l\". There are 5 asterisks considered. Therefore, we return 5.\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- s consists of lowercase English letters, vertical bars '|', and asterisks '*'.\n- s contains an even number of vertical bars '|'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"iamprogrammer\") == 0\n    assert candidate(s = \"|*|*|*|*|\") == 2\n    assert candidate(s = \"||||||||||\") == 0\n    assert candidate(s = \"yo|uar|e**|b|e***au|tifu|l\") == 5\n    assert candidate(s = \"l|*e*et|c**o|*de|\") == 2\n    assert candidate(s = \"abc|def|ghi|jkl|\") == 0\n    assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l|m*n*o*p*q*r*s*t*u*v*w*x*y*z|\") == 11\n    assert candidate(s = \"*|*|*|*|*|*|\") == 3\n    assert candidate(s = \"no|asterisks|here|\") == 0\n    assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|\") == 5\n    assert candidate(s = \"|*a|b*|*c|d*|e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*|\") == 2\n    assert candidate(s = \"|*a*|b*|*c*|d*|*e*|f*|*g*|h*|*i*|j*|*k*|l*|*m*|n*|*o*|p*|*q*|r*|*s*|t*|*u*|v*|*w*|x*|*y*|z*|\") == 13\n    assert candidate(s = \"*a|*b|*c|*d|*e|*f|*g|*h|*i|*j|*k|*l|*m|*n|*o|*p|*q|*r|*s|*t|*u|*v|*w|*x|*y|*z|\") == 13\n    assert candidate(s = \"*a*|b*c|d*e*f|g*h*i*j*k|l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*|*\") == 19\n    assert candidate(s = \"this|is|a|test|string|with|multiple|pipes|and|asterisks|*|*|*|*|*|*|*|*|*|*|*|\") == 6\n    assert candidate(s = \"|*a|b*c|d*e*f|g*h*i*j*k|l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*|*a*|b|*c*|d*|*e*|f*|*g*|*h*|*i*|*j*|*k*|*l*|*m*|*n*|*o*|*p*|*q*|*r*|*s*|*t*|*u*|*v*|*w*|*x*|*y*|*z*|\") == 31\n    assert candidate(s = \"multiple|pairs|of|bars|and*no*asterisks*between|them|\") == 3\n    assert candidate(s = \"*a*|b*c|d*e*f|g*h*i*j|\") == 4\n    assert candidate(s = \"abc*def|ghi*jkl|*mnop|qrstu|vwxyz*\") == 3\n    assert candidate(s = \"|*a*|b|c*|d*e*|f*g*h|*i*j*k*|l*m*n*o*|\") == 6\n    assert candidate(s = \"this|is|a|test|string|with|multiple|pipes|and|asterisks|*|*|*|\") == 2\n    assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*|*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z|\") == 26\n    assert candidate(s = \"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\") == 0\n    assert candidate(s = \"|*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*|\") == 0\n    assert candidate(s = \"interleaved*characters|with|pipes*and*asterisks|and|more|pipes*and*asterisks*at|the*end*of*the|string*\") == 6\n    assert candidate(s = \"|*||||*||||*||||*||||*|\") == 0\n    assert candidate(s = \"|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|\") == 0\n    assert candidate(s = \"|*a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z*|\") == 1\n    assert candidate(s = \"*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*|\") == 27\n    assert candidate(s = \"nested||pipes|should|not|affect|the|count|of|*|in|between|pipes|\") == 0\n    assert candidate(s = \"*a|*b|*c|*d|*e|*f|*g|*h|*i|*j|*k|*l|*m|*n|*o|*p|*q|*r|*s|*t|*u|*v|*w|*x|*y|*z*|\") == 13\n    assert candidate(s = \"*a*|*b*|*c*|*d*|*e*|*f*|*g*|*h*|*i*|*j*|*k*|*l*|*m*|*n*|*o*|*p*|*q*|*r*|*s*|*t*|*u*|*v*|*w*|*x*|*y*|*z*|\") == 26\n    assert candidate(s = \"long|*sequence*|of|*characters*|to|test|the|*algorithm*|efficiency|\") == 0\n    assert candidate(s = \"*a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z*|*\") == 2\n    assert candidate(s = \"|*a*|b*|c*|d*|e*|f*|g*|h*|i*|j*|k*|l*|m*|n*|o*|p*|q*|r*|s*|t*|u*|v*|w*|x*|y*|z*|\") == 13\n    assert candidate(s = \"a*|b*|c*|d*|e*|f*|g*|h*|i*|j*|k*|l*|m*|n*|o*|p*|q*|r*|s*|t*|u*|v*|w*|x*|y*|z*|\") == 13\n    assert candidate(s = \"nested|*pipes*|and|*asterisks*|inside|*and*|outside|*pipes*|\") == 0\n    assert candidate(s = \"|a*b*c|d*e*f*g|h*i*j*k*l*m*n|o*p*q*r*s*t*u|v*w*x*y*z|\") == 9\n    assert candidate(s = \"multiple*asterisks*here|and*here*too|and*here|\") == 3\n    assert candidate(s = \"this|is*a*test|to*see*if*the*function*works*correctly*with*many*bars|and*asterisks*in*various*places*|\") == 9\n    assert candidate(s = \"*|*a*b*c*|d*e*f*g*|h*i*j*k*l*m*n*|o*p*q*r*s*t*u*|v*w*x*y*z*|\") == 12\n    assert candidate(s = \"*at|the|start*|and|at|the|end*|pipes|should|not|affect|the|count*|\") == 4\n    assert candidate(s = \"|a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*|\") == 0\n    assert candidate(s = \"|pipes|without|*asterisks*|in|between|pipes|should|return|zero|\") == 0\n    assert candidate(s = \"*only*|*pipes*|*and*|*asterisks*|*in*|*the*|*string*|\") == 8\n    assert candidate(s = \"no*bars*in*string\") == 3\n    assert candidate(s = \"no|pipes|here|just|plain|text|and|some|asterisks*at*the*end\") == 3\n    assert candidate(s = \"|a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w|x*y*z*|a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w|x*y*z*|\") == 6\n    assert candidate(s = \"nested*bars*are|not|possible|but|this|is*a*test*case*with*many*bars|and*some*stars*in*the*end*|\") == 8\n    assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 20\n    assert candidate(s = \"*at*the*start*and*no*pipes*in*the*middle*or*end\") == 11\n    assert candidate(s = \"|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 19\n    assert candidate(s = \"noasterisks|here|but|many|pipes|to|confuse|you|\") == 0\n    assert candidate(s = \"*a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z*\") == 1\n    assert candidate(s = \"|a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z|*\") == 1\n    assert candidate(s = \"*|a*|b*|c*|d*|e*|f*|g*|h*|i*|j*|k*|l*|m*|n*|o*|p*|q*|r*|s*|t*|u*|v*|w*|x*|y*|z*|\") == 14\n    assert candidate(s = \"hello*world|this|is*a*test|string|with*many*asterisks|\") == 5\n    assert candidate(s = \"*|a|*b|*c|*d|*e|*f|*g|*h|*i|*j|*k|*l|*m|*n|*o|*p|*q|*r|*s|*t|*u|*v|*w|*x|*y|*z|*|\") == 14\n    assert candidate(s = \"*a|b*c|d*e*f|g|h*i*j|k*l*m|n*o*p*q*r*s*t*u*v*w*x*y*z|\") == 17\n    assert candidate(s = \"*a|b|*c|d|*e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z*|\") == 3\n    assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 18\n    assert candidate(s = \"||||||||**||||||||\") == 2\n    assert candidate(s = \"*single*|*pair*|of|*pipes*|with|*multiple*|asterisks*|inside*|\") == 3\n    assert candidate(s = \"no|pipes|here|just|asterisks|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 11\n    assert candidate(s = \"a*|b*c|d*e*f|g*h|i*j*k|l*m*n|\") == 5\n    assert candidate(s = \"*a*|b*c|d*e*f|g*h*i*j*k|l*m*n*o*p*q*r*s*t*u*v*w*x*y*z|\") == 18\n    assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 8\n    assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z\") == 25\n    assert candidate(s = \"this|is*a*test|with*many*asterisks|and*no*exclusions*at*the*end*\") == 2\n    assert candidate(s = \"multiple||pipes||in||a||row||with||asterisks*in||between\") == 1\n    assert candidate(s = \"a|*b*|*c*|*d*|*e*|*f*|*g*|*h*|*i*|*j*|*k*|*l*|*m*|*n*|*o*|*p*|*q*|*r*|*s*|*t*|*u*|*v*|*w*|*x*|*y*|*z*|\") == 24\n    assert candidate(s = \"*a|*b*c|*d*e*f|*g*h*i|*j*k*l|m*n*o|*p*q*r|*s*t*u|*v*w*x|*y*z*|\") == 13\n    assert candidate(s = \"*a|b|*c|d|e|*f|g|h|*i|j|k|l|m|*n|o|p|q|r|*s|t|u|v|w|x|*y|z*|\") == 5\n    assert candidate(s = \"*a*|b*c|d*e*f|g*h*i*j*k|l*m*n*o*p*q*r*s*t*u*v*w*x*y*z|*\") == 18\n    assert candidate(s = \"hello|world|*python*|programming|*|code*|\") == 3\n    assert candidate(s = \"hello|world*is*great|but*this*is*not|\") == 3\n    assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 20\n    assert candidate(s = \"*|**|***|****|*****|******|*******|********|*********|**********|\") == 25\n    assert candidate(s = \"no|*pipes|or|*asterisks*|here|\") == 0\n    assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z|*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z|\") == 25\n    assert candidate(s = \"|a|*b|*c|*d|*e|*f|*g|*h|*i|*j|*k|*l|*m|*n|*o|*p|*q|*r|*s|*t|*u|*v|*w|*x|*y|*z|\") == 13\n    assert candidate(s = \"*middle*|pipes|*middle*|pipes|*middle*|pipes|*middle*|pipes|*middle*|pipes|\") == 10\n    assert candidate(s = \"*a|b*c|d*e*f|g*h*i*j*k|l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*|\") == 18\n    assert candidate(s = \"*a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z*|\") == 1\n    assert candidate(s = \"*|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|*\") == 1\n    assert candidate(s = \"nested|pipes|are|not|possible||but|this|is|how|it|could|look|if|they|were|*|*|*|*|*|*|\") == 3\n    assert candidate(s = \"*a|b|*c|d|*e|f|*g|h|*i|j|*k|l|*m|n|*o|p|*q|r|*s|t|*u|*v|*w|*x|*y|*z*|\") == 13\n    assert candidate(s = \"*|*a*|*b*|*c*|*d*|*e*|*f*|*g*|*h*|*i*|*j*|*k*|*l*|*m*|*n*|*o*|*p*|*q*|*r*|*s*|*t*|*u*|*v*|*w*|*x*|*y*|*z*|*|\") == 27\n    assert candidate(s = \"a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z\") == 25\n    assert candidate(s = \"|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 21\n    assert candidate(s = \"longer|string|with|many|characters|and|some|pipes|and|asterisks*in*various*places|and*more|pipes|and|asterisks*at*the*end*\") == 1\n    assert candidate(s = \"complex|test*case*with*mixed*characters*and*bars*and*asterisks|throughout*the*string|\") == 2\n    assert candidate(s = \"single*asterisk*outside*pipes|double**asterisks*inside*pipes|triple***asterisks*outside*pipes\") == 8\n    assert candidate(s = \"|a*b*c|d*e*f|g*h*i|j*k*l|m*n*o|p*q*r|s*t*u|v*w*x|y*z|\") == 8\n    assert candidate(s = \"multiple|*pipes*|in|*one*|segment|*of*|the|*string*|should|be|handled|correctly|\") == 0\n    assert candidate(s = \"|a|*b*|c|d|e|*f*|g|h|i|j|k|l|m|*n*|o|p|q|r|s|t|u|v|w|x|y|z|\") == 6\n    assert candidate(s = \"|a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z||\") == 0\n    assert candidate(s = \"|a*|b*|c*|d*|e*|f*|g*|h*|i*|j*|k*|l*|m*|n*|o*|p*|q*|r*|s*|t*|u*|v*|w*|x*|y*|z|\") == 12\n    assert candidate(s = \"a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|*|*|*|*|\") == 2\n    assert candidate(s = \"|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 16\n    assert candidate(s = \"|a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z|\") == 0\n    assert candidate(s = \"|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|\") == 20\n    assert candidate(s = \"||||||||||||||||||||||||||||||||||||||||||||||||||||\") == 0\n    assert candidate(s = \"nested|*p*|ai|*n*|e*d|*|t*e*s*t|case|\") == 4\n", "comparison": "exact"}, "public_tests": ["\"l|*e*et|c**o|*de|\"", "\"iamprogrammer\"", "\"yo|uar|e**|b|e***au|tifu|l\""], "hints": ["Iterate through each character, while maintaining whether we are currently between a pair of ‘|’ or not.", "If we are not in between a pair of ‘|’ and there is a ‘*’, increment the answer by 1."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().countAsterisks", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:29+00:00", "tests_total": 106, "tests_dropped": 2, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def countAsterisks(self, s: str) -> int:", "container": "Solution", "callable": "countAsterisks", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2316, "task_id": "count-unreachable-pairs-of-nodes-in-an-undirected-graph", "difficulty": "Medium", "problem_description": "You are given an integer n. There is an undirected graph with n nodes, numbered from 0 to n - 1. You are given a 2D integer array edges where edges[i] = [a_i, b_i] denotes that there exists an undirected edge connecting nodes a_i and b_i.\n\nReturn the number of pairs of different nodes that are unreachable from each other.\n\nExample 1:\n\nInput: n = 3, edges = [[0,1],[0,2],[1,2]]\nOutput: 0\nExplanation: There are no pairs of nodes that are unreachable from each other. Therefore, we return 0.\n\nExample 2:\n\nInput: n = 7, edges = [[0,2],[0,5],[2,4],[1,6],[5,4]]\nOutput: 14\nExplanation: There are 14 pairs of nodes that are unreachable from each other:\n[[0,1],[0,3],[0,6],[1,2],[1,3],[1,4],[1,5],[2,3],[2,6],[3,4],[3,5],[3,6],[4,6],[5,6]].\nTherefore, we return 14.\n\nConstraints:\n\n- 1 <= n <= 10^5\n- 0 <= edges.length <= 2 * 10^5\n- edges[i].length == 2\n- 0 <= a_i, b_i < n\n- a_i != b_i\n- There are no repeated edges.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 6,edges = [[0, 1], [1, 2], [3, 4]]) == 11\n    assert candidate(n = 6,edges = []) == 15\n    assert candidate(n = 3,edges = [[0, 1], [0, 2], [1, 2]]) == 0\n    assert candidate(n = 5,edges = [[0, 1], [2, 3]]) == 8\n    assert candidate(n = 10,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 40\n    assert candidate(n = 5,edges = [[0, 1], [1, 2], [3, 4]]) == 6\n    assert candidate(n = 4,edges = []) == 6\n    assert candidate(n = 1,edges = []) == 0\n    assert candidate(n = 10,edges = []) == 45\n    assert candidate(n = 7,edges = [[0, 2], [0, 5], [2, 4], [1, 6], [5, 4]]) == 14\n    assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n    assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9]]) == 25\n    assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 6], [15, 16], [16, 17], [17, 18], [18, 19], [19, 15]]) == 129\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [6, 7], [7, 8], [8, 9]]) == 33\n    assert candidate(n = 16,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 0]]) == 0\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]]) == 96\n    assert candidate(n = 25,edges = [[0, 1], [1, 2], [3, 4], [4, 5], [6, 7], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24]]) == 283\n    assert candidate(n = 10,edges = [[0, 1], [2, 3], [3, 4], [4, 5], [6, 7], [7, 8], [8, 9]]) == 32\n    assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 9], [12, 13], [13, 14], [14, 12]]) == 83\n    assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9], [10, 11], [11, 12], [12, 13], [13, 14]]) == 75\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [8, 9], [9, 10], [11, 12], [13, 14]]) == 93\n    assert candidate(n = 20,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]]) == 180\n    assert candidate(n = 15,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 0]]) == 96\n    assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5], [10, 11], [11, 12], [12, 13], [13, 14], [14, 10], [15, 16], [16, 17], [17, 18], [18, 19], [19, 15], [20, 21], [21, 22], [22, 23], [23, 24], [24, 20]]) == 250\n    assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 0\n    assert candidate(n = 50,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21], [22, 23], [24, 25], [26, 27], [28, 29], [30, 31], [32, 33], [34, 35], [36, 37], [38, 39], [40, 41], [42, 43], [44, 45], [46, 47], [48, 49]]) == 1200\n    assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [8, 9], [9, 10], [11, 12], [13, 14]]) == 87\n    assert candidate(n = 100,edges = []) == 4950\n    assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [8, 9]]) == 31\n    assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [4, 5], [5, 6], [7, 4]]) == 16\n    assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 100\n    assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 12], [12, 9], [13, 14], [14, 15], [15, 16], [16, 13], [17, 18], [18, 19], [19, 20], [20, 17], [21, 22], [22, 23], [23, 24], [24, 21]]) == 260\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [3, 6], [7, 8], [7, 9]]) == 33\n    assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 0\n    assert candidate(n = 30,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21], [22, 23], [24, 25], [26, 27], [28, 29]]) == 420\n    assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 2], [3, 4]]) == 6\n    assert candidate(n = 50,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 1035\n    assert candidate(n = 100,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50], [50, 51], [51, 52], [52, 53], [53, 54], [54, 55], [55, 56], [56, 57], [57, 58], [58, 59], [59, 60], [60, 61], [61, 62], [62, 63], [63, 64], [64, 65], [65, 66], [66, 67], [67, 68], [68, 69], [69, 70], [70, 71], [71, 72], [72, 73], [73, 74], [74, 75], [75, 76], [76, 77], [77, 78], [78, 79], [79, 80], [80, 81], [81, 82], [82, 83], [83, 84], [84, 85], [85, 86], [86, 87], [87, 88], [88, 89], [89, 90], [90, 91], [91, 92], [92, 93], [93, 94], [94, 95], [95, 96], [96, 97], [97, 98], [98, 99]]) == 0\n    assert candidate(n = 15,edges = [[0, 1], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8], [8, 9], [9, 10], [11, 12], [12, 13], [13, 14], [14, 7]]) == 68\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [4, 5], [6, 7], [6, 8], [6, 9]]) == 32\n    assert candidate(n = 10,edges = [[0, 1], [1, 2], [3, 4], [4, 5], [6, 7], [8, 9]]) == 37\n    assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [11, 12], [12, 13], [13, 14]]) == 74\n    assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [7, 8], [8, 9], [9, 10], [10, 11], [11, 7]]) == 35\n    assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24]]) == 0\n    assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 12], [12, 9], [13, 14], [14, 15], [15, 16], [16, 13], [17, 18], [18, 19], [19, 17]]) == 159\n    assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 36\n    assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [4, 5], [5, 6], [7, 8]]) == 35\n    assert candidate(n = 15,edges = [[0, 1], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8], [8, 9], [10, 11], [12, 13], [13, 14]]) == 89\n    assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [5, 6], [5, 7], [6, 8], [7, 9], [10, 11], [11, 12], [12, 13], [13, 14], [15, 16], [16, 17], [17, 18], [18, 19]]) == 150\n    assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == 0\n    assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24]]) == 150\n    assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [4, 5], [5, 6], [7, 8], [8, 9]]) == 33\n    assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [7, 8], [8, 9]]) == 31\n", "comparison": "exact"}, "public_tests": ["3\n[[0,1],[0,2],[1,2]]", "7\n[[0,2],[0,5],[2,4],[1,6],[5,4]]"], "hints": ["Find the connected components of the graph. To find connected components, you can use Union Find (Disjoint Sets), BFS, or DFS.", "For a node u, the number of nodes that are unreachable from u is the number of nodes that are not in the same connected component as u.", "The number of unreachable nodes from node u will be the same for the number of nodes that are unreachable from node v if nodes u and v belong to the same connected component."], "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:31+00:00", "tests_total": 55, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["depth-first-search", "breadth-first-search", "union-find", "graph"]}, "language": "python", "interface": {"raw_signature": "def countPairs(self, n: int, edges: list[list[int]]) -> int:", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2317, "task_id": "maximum-xor-after-operations", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. In one operation, select any non-negative integer x and an index i, then update nums[i] to be equal to nums[i] AND (nums[i] XOR x).\n\nNote that AND is the bitwise AND operation and XOR is the bitwise XOR operation.\n\nReturn the maximum possible bitwise XOR of all elements of nums after applying the operation any number of times.\n\nExample 1:\n\nInput: nums = [3,2,4,6]\nOutput: 7\nExplanation: Apply the operation with x = 4 and i = 3, num[3] = 6 AND (6 XOR 4) = 6 AND 2 = 2.\nNow, nums = [3, 2, 4, 2] and the bitwise XOR of all the elements = 3 XOR 2 XOR 4 XOR 2 = 7.\nIt can be shown that 7 is the maximum possible bitwise XOR.\nNote that other operations may be used to achieve a bitwise XOR of 7.\n\nExample 2:\n\nInput: nums = [1,2,3,9,2]\nOutput: 11\nExplanation: Apply the operation zero times.\nThe bitwise XOR of all the elements = 1 XOR 2 XOR 3 XOR 9 XOR 2 = 11.\nIt can be shown that 11 is the maximum possible bitwise XOR.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= nums[i] <= 10^8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [8, 1, 4, 2, 15]) == 15\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 15\n    assert candidate(nums = [1, 0, 3, 2]) == 3\n    assert candidate(nums = [1, 0, 1, 0, 1]) == 1\n    assert candidate(nums = [1, 1, 1, 1]) == 1\n    assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 8184\n    assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1]) == 255\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 7\n    assert candidate(nums = [3, 2, 4, 6]) == 7\n    assert candidate(nums = [100000000, 50000000, 25000000, 12500000, 6250000]) == 134217712\n    assert candidate(nums = [1, 2, 3, 9, 2]) == 11\n    assert candidate(nums = [100000000, 50000000, 25000000, 12500000, 6250000, 3125000, 1562500, 781250, 390625, 195312, 97656, 48828, 24414, 12207, 6103, 3051, 1525, 762, 381, 190, 95, 47, 23, 11, 5, 2, 1]) == 134217727\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 31\n    assert candidate(nums = [7, 7, 7, 7, 7]) == 7\n    assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024]) == 2040\n    assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == 15\n    assert candidate(nums = [100000000, 50000000, 25000000, 12500000, 6250000, 3125000, 1562500, 781250, 390625, 195312, 97656, 48828, 24414, 12207, 6103, 3051, 1525, 762, 381, 190, 95, 47, 23, 11, 5, 2, 1]) == 134217727\n    assert candidate(nums = [2, 4, 8, 16, 32]) == 62\n    assert candidate(nums = [0, 0, 0, 0]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25]) == 31\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2047\n    assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1]) == 255\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\n    assert candidate(nums = [10, 20, 30, 40]) == 62\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047]) == 2047\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 127\n    assert candidate(nums = [1919810, 909405, 454702, 227351, 113675, 56837, 28418, 14209, 7104, 3552, 1776, 888, 444, 222, 111, 55, 27, 13, 6, 3, 1]) == 2097151\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 2097151\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1020\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1048575\n    assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2097151\n    assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 255, 127, 63, 31, 15, 7, 3]) == 255\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 1048575\n    assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 63\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 63\n    assert candidate(nums = [100000000, 50000000, 25000000, 12500000, 6250000, 3125000, 1562500, 781250, 390625, 195312, 97656, 48828, 24414, 12207, 6103, 3051, 1525, 762, 381, 190, 95]) == 134217727\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048575]) == 1048575\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29, 31, 31, 37, 37, 41, 41, 43, 43]) == 63\n    assert candidate(nums = [23456789, 87654321, 12345678, 45678901, 56789012, 67890123, 78901234, 34567890, 43210987, 76543210, 98765432, 21098765, 32109876, 65432109, 54321098, 43210987, 32109876, 21098765, 10987654, 98765432, 87654321, 76543210, 65432109, 54321098, 43210987, 32109876, 21098765, 10987654, 9876543, 8765432]) == 134217727\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84]) == 127\n    assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 2047\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 65535\n    assert candidate(nums = [131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 262143\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 2044\n    assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 65535\n    assert candidate(nums = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240]) == 255\n    assert candidate(nums = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 31\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 15\n    assert candidate(nums = [16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767]) == 16777215\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]) == 100661247\n    assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1048575\n    assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == 1023\n    assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1023\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63]) == 63\n    assert candidate(nums = [100000000, 99999999, 99999998, 99999997, 99999996, 99999995, 99999994, 99999993, 99999992, 99999991]) == 100000255\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1048575, 1048574, 1048573, 1048572, 1048571, 1048570]) == 1048575\n    assert candidate(nums = [99999999, 88888888, 77777777, 66666666, 55555555, 44444444, 33333333, 22222222, 11111111, 100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000, 5000000, 1000000, 500000, 100000, 50000, 10000, 5000, 1000, 500, 100, 50, 10]) == 134217727\n    assert candidate(nums = [100000000, 50000000, 25000000, 12500000, 6250000, 3125000, 1562500, 781250, 390625, 195312]) == 134217727\n    assert candidate(nums = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]) == 13\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 31\n    assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1023\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 8\n    assert candidate(nums = [100000000, 90000000, 80000000, 70000000, 60000000]) == 134217600\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113]) == 127\n    assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2097151\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 31\n    assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1023\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255]) == 255\n    assert candidate(nums = [1048575, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 1048575\n    assert candidate(nums = [8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0]) == 8388607\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]) == 65535\n    assert candidate(nums = [100000000, 99999999, 99999998, 99999997, 99999996]) == 100000255\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2047\n    assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 9000, 8000]) == 1048575\n    assert candidate(nums = [8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0]) == 16777215\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [23, 45, 67, 89, 111, 133, 155, 177]) == 255\n    assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1048575\n    assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 15\n", "comparison": "exact"}, "public_tests": ["[3,2,4,6]", "[1,2,3,9,2]"], "hints": ["Consider what it means to be able to choose any x for the operation and which integers could be obtained from a given nums[i].", "The given operation can unset any bit in nums[i].", "The nth bit of the XOR of all the elements is 1 if the nth bit is 1 for an odd number of elements. When can we ensure it is odd?", "Try to set every bit of the result to 1 if possible."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumXOR", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:34+00:00", "tests_total": 117, "tests_dropped": 34, "flags": [], "topic_tags": ["array", "math", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def maximumXOR(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maximumXOR", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2318, "task_id": "number-of-distinct-roll-sequences", "difficulty": "Hard", "problem_description": "You are given an integer n. You roll a fair 6-sided dice n times. Determine the total number of distinct sequences of rolls possible such that the following conditions are satisfied:\n\n1. The greatest common divisor of any adjacent values in the sequence is equal to 1.\n2. There is at least a gap of 2 rolls between equal valued rolls. More formally, if the value of the i^th roll is equal to the value of the j^th roll, then abs(i - j) > 2.\n\nReturn the total number of distinct sequences possible. Since the answer may be very large, return it modulo 10^9 + 7.\n\nTwo sequences are considered distinct if at least one element is different.\n\nExample 1:\n\nInput: n = 4\nOutput: 184\nExplanation: Some of the possible sequences are (1, 2, 3, 4), (6, 1, 2, 3), (1, 2, 3, 1), etc.\nSome invalid sequences are (1, 2, 1, 3), (1, 2, 3, 6).\n(1, 2, 1, 3) is invalid since the first and third roll have an equal value and abs(1 - 3) = 2 (i and j are 1-indexed).\n(1, 2, 3, 6) is invalid since the greatest common divisor of 3 and 6 = 3.\nThere are a total of 184 distinct sequences possible, so we return 184.\n\nExample 2:\n\nInput: n = 2\nOutput: 22\nExplanation: Some of the possible sequences are (1, 2), (2, 1), (3, 2).\nSome invalid sequences are (3, 6), (2, 4) since the greatest common divisor is not equal to 1.\nThere are a total of 22 distinct sequences possible, so we return 22.\n\nConstraints:\n\n- 1 <= n <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 3) == 66\n    assert candidate(n = 100) == 534856607\n    assert candidate(n = 4) == 184\n    assert candidate(n = 10000) == 874574246\n    assert candidate(n = 2) == 22\n    assert candidate(n = 1) == 6\n    assert candidate(n = 1000) == 497171723\n    assert candidate(n = 10) == 93120\n    assert candidate(n = 2000) == 784558903\n    assert candidate(n = 104) == 920649565\n    assert candidate(n = 5) == 516\n    assert candidate(n = 8000) == 366597434\n    assert candidate(n = 5000) == 798977852\n    assert candidate(n = 9999) == 455330915\n    assert candidate(n = 20) == 996985946\n    assert candidate(n = 15) == 16706688\n    assert candidate(n = 6) == 1472\n    assert candidate(n = 750) == 498714087\n    assert candidate(n = 500) == 353640467\n    assert candidate(n = 7) == 4136\n", "comparison": "exact"}, "public_tests": ["4", "2"], "hints": ["Can you think of a DP solution?", "Consider a state that remembers the last 1 or 2 rolls.", "Do you need to consider the last 3 rolls?"], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().distinctSequences", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:36+00:00", "tests_total": 21, "tests_dropped": 1, "flags": [], "topic_tags": ["dynamic-programming", "memoization"]}, "language": "python", "interface": {"raw_signature": "def distinctSequences(self, n: int) -> int:", "container": "Solution", "callable": "distinctSequences", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2319, "task_id": "check-if-matrix-is-x-matrix", "difficulty": "Easy", "problem_description": "A square matrix is said to be an X-Matrix if both of the following conditions hold:\n\n1. All the elements in the diagonals of the matrix are non-zero.\n2. All other elements are 0.\n\nGiven a 2D integer array grid of size n x n representing a square matrix, return true if grid is an X-Matrix. Otherwise, return false.\n\nExample 1:\n\nInput: grid = [[2,0,0,1],[0,3,1,0],[0,5,2,0],[4,0,0,2]]\nOutput: true\nExplanation: Refer to the diagram above.\nAn X-Matrix should have the green elements (diagonals) be non-zero and the red elements be 0.\nThus, grid is an X-Matrix.\n\nExample 2:\n\nInput: grid = [[5,7,0],[0,3,1],[0,5,0]]\nOutput: false\nExplanation: Refer to the diagram above.\nAn X-Matrix should have the green elements (diagonals) be non-zero and the red elements be 0.\nThus, grid is not an X-Matrix.\n\nConstraints:\n\n- n == grid.length == grid[i].length\n- 3 <= n <= 100\n- 0 <= grid[i][j] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[1, 2, 0, 0], [0, 0, 0, 3], [0, 0, 4, 0], [0, 5, 0, 0]]) == False\n    assert candidate(grid = [[1, 2, 0, 0], [0, 3, 1, 0], [0, 5, 2, 0], [0, 0, 0, 4]]) == False\n    assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0], [0, 2, 0, 0, 0], [0, 0, 3, 0, 0], [0, 0, 0, 4, 0], [0, 0, 0, 0, 5]]) == False\n    assert candidate(grid = [[1, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 1]]) == False\n    assert candidate(grid = [[5, 7, 0], [0, 3, 1], [0, 5, 0]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 1], [0, 2, 0, 2, 0], [0, 0, 3, 0, 0], [0, 2, 0, 2, 0], [1, 0, 0, 0, 1]]) == True\n    assert candidate(grid = [[2, 0, 0, 1], [0, 3, 1, 0], [0, 5, 2, 0], [4, 0, 0, 2]]) == True\n    assert candidate(grid = [[6, 0, 0, 0, 6], [0, 7, 0, 7, 0], [0, 0, 8, 0, 0], [0, 7, 0, 7, 0], [6, 0, 0, 0, 6]]) == True\n    assert candidate(grid = [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]) == False\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == False\n    assert candidate(grid = [[0, 1, 0], [1, 2, 1], [0, 1, 0]]) == False\n    assert candidate(grid = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == False\n    assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == True\n    assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == True\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 2, 0, 0, 0, 0, 0, 0, 2, 0], [0, 0, 3, 0, 0, 0, 0, 3, 0, 0], [0, 0, 0, 4, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 5, 0, 0, 0, 0], [0, 0, 0, 0, 5, 5, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 4, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 3, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 2, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == True\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 2], [0, 3, 0, 0, 0, 0, 5, 0], [0, 0, 6, 0, 0, 8, 0, 0], [0, 0, 0, 9, 10, 0, 0, 0], [0, 0, 0, 11, 12, 0, 0, 0], [0, 0, 13, 0, 0, 14, 0, 0], [0, 15, 0, 0, 0, 0, 16, 0], [17, 0, 0, 0, 0, 0, 0, 18]]) == True\n    assert candidate(grid = [[5, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 5]]) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 3, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 5, 0, 0, 0, 0], [0, 6, 0, 0, 0, 0, 0], [7, 0, 0, 0, 0, 0, 0]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 1, 0], [0, 2, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 6]]) == False\n    assert candidate(grid = [[1, 2, 3, 4, 5], [0, 6, 0, 7, 0], [0, 0, 8, 0, 0], [0, 9, 0, 10, 0], [11, 0, 0, 0, 12]]) == False\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [0, 8, 0, 0, 0, 9, 0], [0, 0, 10, 0, 11, 0, 0], [0, 0, 0, 12, 0, 0, 0], [0, 0, 13, 0, 14, 0, 0], [0, 15, 0, 0, 0, 16, 0], [17, 0, 0, 0, 0, 0, 18]]) == False\n    assert candidate(grid = [[2, 0, 0, 0, 3], [0, 5, 0, 6, 0], [0, 0, 7, 0, 0], [0, 8, 0, 9, 0], [4, 0, 0, 0, 1]]) == True\n    assert candidate(grid = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 3], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [6, 0, 0, 0, 0, 2]]) == False\n    assert candidate(grid = [[7, 0, 0, 0, 0, 1], [0, 4, 0, 0, 4, 0], [0, 0, 9, 0, 0, 0], [0, 0, 0, 6, 0, 0], [0, 8, 0, 0, 7, 0], [2, 0, 0, 0, 0, 9]]) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [0, 2, 0, 0, 0, 2, 0], [0, 0, 3, 0, 3, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 5, 0, 5, 0, 0], [0, 6, 0, 0, 0, 6, 0], [7, 0, 0, 0, 0, 0, 7]]) == True\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 1], [0, 0, 3, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 5, 0], [1, 0, 0, 0, 0, 1]]) == False\n    assert candidate(grid = [[7, 0, 0, 0, 0, 0], [0, 6, 0, 0, 0, 0], [0, 0, 5, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 3, 0], [0, 0, 0, 0, 0, 2]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 2, 0, 0, 0, 0, 0, 2, 0], [0, 0, 3, 0, 0, 0, 3, 0, 0], [0, 0, 0, 4, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 4, 0, 4, 0, 0, 0], [0, 0, 3, 0, 0, 0, 3, 0, 0], [0, 2, 0, 0, 0, 0, 0, 2, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == True\n    assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 1], [0, 1, 0, 1, 0]]) == False\n    assert candidate(grid = [[6, 0, 0, 0, 0], [0, 7, 0, 0, 0], [0, 0, 8, 0, 0], [0, 0, 0, 9, 0], [0, 0, 0, 0, 10]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 7], [0, 2, 0, 0, 0, 8, 0], [0, 0, 3, 0, 9, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 10, 0, 5, 0, 0], [0, 11, 0, 0, 0, 6, 0], [12, 0, 0, 0, 0, 0, 13]]) == True\n    assert candidate(grid = [[6, 0, 0, 0, 1], [0, 7, 0, 3, 0], [0, 0, 8, 0, 0], [0, 9, 0, 5, 0], [2, 0, 0, 0, 4]]) == True\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 1]]) == False\n    assert candidate(grid = [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 6]]) == False\n    assert candidate(grid = [[9, 0, 0, 0, 0, 0, 0, 0], [0, 8, 0, 0, 0, 0, 0, 0], [0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 0, 0, 3, 0], [0, 0, 0, 0, 0, 0, 0, 2]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]) == False\n    assert candidate(grid = [[1, 2, 0, 0, 4], [3, 0, 5, 0, 6], [0, 7, 0, 8, 0], [9, 0, 10, 0, 11], [12, 0, 0, 13, 14]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 2], [0, 3, 0, 5, 0], [0, 0, 4, 0, 0], [0, 6, 0, 7, 0], [8, 0, 0, 0, 9]]) == True\n    assert candidate(grid = [[10, 0, 0, 0, 0, 0, 0, 0, 0], [0, 9, 0, 0, 0, 0, 0, 0, 0], [0, 0, 8, 0, 0, 0, 0, 0, 0], [0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 0, 0, 0, 3, 0], [0, 0, 0, 0, 0, 0, 0, 0, 2]]) == False\n    assert candidate(grid = [[5, 0, 0, 0, 0, 0], [0, 4, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 2, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 9]]) == False\n    assert candidate(grid = [[5, 0, 0, 0, 0], [0, 6, 0, 0, 0], [0, 0, 7, 0, 0], [0, 0, 0, 8, 0], [0, 0, 0, 0, 9]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0], [0, 2, 0, 0, 1], [0, 0, 3, 0, 0], [0, 0, 0, 2, 0], [1, 0, 0, 0, 1]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 9, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 7, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 6, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 3, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 2], [0, 2, 0, 3, 0], [0, 0, 4, 0, 0], [0, 5, 0, 6, 0], [7, 0, 0, 0, 8]]) == True\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 14], [0, 2, 0, 0, 0, 0, 15, 0], [0, 0, 3, 0, 0, 16, 0, 0], [0, 0, 0, 4, 17, 0, 0, 0], [0, 0, 0, 18, 5, 0, 0, 0], [0, 0, 19, 0, 0, 6, 0, 0], [0, 20, 0, 0, 0, 0, 7, 0], [21, 0, 0, 0, 0, 0, 0, 8]]) == True\n    assert candidate(grid = [[1, 0, 0, 0, 0, 5], [0, 2, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 5, 0], [6, 0, 0, 0, 0, 7]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 2], [0, 2, 0, 0, 0, 0, 3, 0], [0, 0, 3, 0, 0, 4, 0, 0], [0, 0, 0, 4, 5, 0, 0, 0], [0, 0, 0, 5, 4, 0, 0, 0], [0, 0, 4, 0, 0, 3, 0, 0], [0, 3, 0, 0, 0, 0, 2, 0], [2, 0, 0, 0, 0, 0, 0, 1]]) == True\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 1], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 6, 0], [1, 0, 0, 0, 0, 0, 1]]) == False\n    assert candidate(grid = [[12, 0, 0, 0, 0, 0], [0, 13, 0, 0, 0, 0], [0, 0, 14, 0, 0, 0], [0, 0, 0, 15, 0, 0], [0, 0, 0, 0, 16, 0], [0, 0, 0, 0, 0, 17]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 9], [0, 2, 0, 0, 0, 0, 8, 0], [0, 0, 3, 0, 0, 7, 0, 0], [0, 0, 0, 4, 6, 0, 0, 0], [0, 0, 0, 6, 4, 0, 0, 0], [0, 0, 7, 0, 0, 3, 0, 0], [0, 8, 0, 0, 0, 0, 2, 0], [9, 0, 0, 0, 0, 0, 0, 1]]) == True\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8]]) == False\n    assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == False\n    assert candidate(grid = [[5, 0, 0, 0, 0, 0, 7], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 8, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [9, 0, 0, 0, 0, 0, 10]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0], [0, 2, 0, 0, 1], [0, 0, 3, 0, 0], [0, 0, 0, 4, 0], [0, 1, 0, 0, 5]]) == False\n    assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [1, 0, 2, 0, 0, 0, 0], [0, 2, 0, 3, 0, 0, 0], [0, 0, 3, 0, 4, 0, 0], [0, 0, 0, 4, 0, 5, 0], [0, 0, 0, 0, 5, 0, 6], [0, 0, 0, 0, 0, 6, 0]]) == False\n    assert candidate(grid = [[5, 0, 0, 0, 0, 0, 0, 0, 0, 2], [0, 4, 0, 0, 0, 0, 0, 0, 3, 0], [0, 0, 3, 0, 0, 0, 0, 4, 0, 0], [0, 0, 0, 2, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 5, 0, 0, 2, 0, 0, 0], [0, 0, 4, 0, 0, 0, 0, 3, 0, 0], [0, 3, 0, 0, 0, 0, 0, 0, 4, 0], [2, 0, 0, 0, 0, 0, 0, 0, 0, 5]]) == False\n    assert candidate(grid = [[7, 0, 0, 0, 0], [0, 8, 0, 0, 0], [0, 0, 9, 0, 0], [0, 0, 0, 10, 0], [0, 0, 0, 0, 11]]) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 2, 0], [0, 0, 0, 3, 0, 0], [0, 0, 4, 0, 0, 0], [0, 5, 0, 0, 0, 0], [6, 0, 0, 0, 0, 0]]) == False\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 1, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 7]]) == False\n    assert candidate(grid = [[0, 0, 0, 0, 1], [0, 0, 0, 2, 0], [0, 0, 3, 0, 0], [0, 4, 0, 0, 0], [5, 0, 0, 0, 0]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == True\n    assert candidate(grid = [[1, 0, 0, 0, 5], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [6, 0, 0, 0, 1]]) == False\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 7]]) == False\n", "comparison": "exact"}, "public_tests": ["[[2,0,0,1],[0,3,1,0],[0,5,2,0],[4,0,0,2]]", "[[5,7,0],[0,3,1],[0,5,0]]"], "hints": ["Assuming a 0-indexed matrix, for a given cell on row i and column j, it is in a diagonal if and only if i == j or i == n - 1 - j.", "We can then iterate through the elements in the matrix to check if all the elements in the diagonals are non-zero and all other elements are zero."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().checkXMatrix", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:38+00:00", "tests_total": 70, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "matrix"]}, "language": "python", "interface": {"raw_signature": "def checkXMatrix(self, grid: list[list[int]]) -> bool:", "container": "Solution", "callable": "checkXMatrix", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2320, "task_id": "count-number-of-ways-to-place-houses", "difficulty": "Medium", "problem_description": "There is a street with n * 2 plots, where there are n plots on each side of the street. The plots on each side are numbered from 1 to n. On each plot, a house can be placed.\n\nReturn the number of ways houses can be placed such that no two houses are adjacent to each other on the same side of the street. Since the answer may be very large, return it modulo 10^9 + 7.\n\nNote that if a house is placed on the i^th plot on one side of the street, a house can also be placed on the i^th plot on the other side of the street.\n\nExample 1:\n\nInput: n = 1\nOutput: 4\nExplanation:\nPossible arrangements:\n1. All plots are empty.\n2. A house is placed on one side of the street.\n3. A house is placed on the other side of the street.\n4. Two houses are placed, one on each side of the street.\n\nExample 2:\n\nInput: n = 2\nOutput: 9\nExplanation: The 9 possible arrangements are shown in the diagram above.\n\nConstraints:\n\n- 1 <= n <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 3) == 25\n    assert candidate(n = 100) == 20522904\n    assert candidate(n = 10000) == 402613600\n    assert candidate(n = 2) == 9\n    assert candidate(n = 1) == 4\n    assert candidate(n = 1000) == 500478595\n    assert candidate(n = 10) == 20736\n    assert candidate(n = 4000) == 984988507\n    assert candidate(n = 7000) == 750848153\n    assert candidate(n = 2000) == 329423452\n    assert candidate(n = 7500) == 39764836\n    assert candidate(n = 50) == 245481867\n    assert candidate(n = 5) == 169\n    assert candidate(n = 3000) == 511358621\n    assert candidate(n = 30) == 30066266\n    assert candidate(n = 4) == 64\n    assert candidate(n = 1001) == 307206160\n    assert candidate(n = 8) == 3025\n    assert candidate(n = 250) == 172820552\n    assert candidate(n = 8000) == 823868594\n    assert candidate(n = 5000) == 851109891\n    assert candidate(n = 9999) == 459963766\n    assert candidate(n = 20) == 313679521\n    assert candidate(n = 15) == 2550409\n    assert candidate(n = 2500) == 968650195\n    assert candidate(n = 9000) == 641644802\n    assert candidate(n = 200) == 450435314\n    assert candidate(n = 9) == 7921\n    assert candidate(n = 6) == 441\n    assert candidate(n = 6000) == 337759600\n    assert candidate(n = 500) == 164765197\n    assert candidate(n = 7) == 1156\n    assert candidate(n = 25) == 580030458\n", "comparison": "exact"}, "public_tests": ["1", "2"], "hints": ["Try coming up with a DP solution for one side of the street.", "The DP for one side of the street will bear resemblance to the Fibonacci sequence.", "The number of different arrangements on both side of the street is the same."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countHousePlacements", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:41+00:00", "tests_total": 33, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def countHousePlacements(self, n: int) -> int:", "container": "Solution", "callable": "countHousePlacements", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2321, "task_id": "maximum-score-of-spliced-array", "difficulty": "Hard", "problem_description": "You are given two 0-indexed integer arrays nums1 and nums2, both of length n.\n\nYou can choose two integers left and right where 0 <= left <= right < n and swap the subarray nums1[left...right] with the subarray nums2[left...right].\n\n- For example, if nums1 = [1,2,3,4,5] and nums2 = [11,12,13,14,15] and you choose left = 1 and right = 2, nums1 becomes [1,12,13,4,5] and nums2 becomes [11,2,3,14,15].\n\nYou may choose to apply the mentioned operation once or not do anything.\n\nThe score of the arrays is the maximum of sum(nums1) and sum(nums2), where sum(arr) is the sum of all the elements in the array arr.\n\nReturn the maximum possible score.\n\nA subarray is a contiguous sequence of elements within an array. arr[left...right] denotes the subarray that contains the elements of nums between indices left and right (inclusive).\n\nExample 1:\n\nInput: nums1 = [60,60,60], nums2 = [10,90,10]\nOutput: 210\nExplanation: Choosing left = 1 and right = 1, we have nums1 = [60,90,60] and nums2 = [10,60,10].\nThe score is max(sum(nums1), sum(nums2)) = max(210, 80) = 210.\n\nExample 2:\n\nInput: nums1 = [20,40,20,70,30], nums2 = [50,20,50,40,20]\nOutput: 220\nExplanation: Choosing left = 3, right = 4, we have nums1 = [20,40,20,40,20] and nums2 = [50,20,50,70,30].\nThe score is max(sum(nums1), sum(nums2)) = max(140, 220) = 220.\n\nExample 3:\n\nInput: nums1 = [7,11,13], nums2 = [1,1,1]\nOutput: 31\nExplanation: We choose not to swap any subarray.\nThe score is max(sum(nums1), sum(nums2)) = max(31, 3) = 31.\n\nConstraints:\n\n- n == nums1.length == nums2.length\n- 1 <= n <= 10^5\n- 1 <= nums1[i], nums2[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums1 = [20, 40, 20, 70, 30],nums2 = [50, 20, 50, 40, 20]) == 220\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 150\n    assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [10000, 10000, 10000, 10000, 10000]) == 50000\n    assert candidate(nums1 = [100, 200, 300],nums2 = [300, 200, 100]) == 800\n    assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 15\n    assert candidate(nums1 = [5000, 5000, 5000],nums2 = [5000, 5000, 5000]) == 15000\n    assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1]) == 8\n    assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 30\n    assert candidate(nums1 = [5000, 5000, 5000, 5000, 5000],nums2 = [6000, 6000, 6000, 6000, 6000]) == 30000\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 21\n    assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5]) == 25\n    assert candidate(nums1 = [10000, 10000, 10000],nums2 = [1, 1, 1]) == 30000\n    assert candidate(nums1 = [60, 60, 60],nums2 = [10, 90, 10]) == 210\n    assert candidate(nums1 = [1, 1, 1],nums2 = [10000, 10000, 10000]) == 30000\n    assert candidate(nums1 = [7, 11, 13],nums2 = [1, 1, 1]) == 31\n    assert candidate(nums1 = [9, 8, 7],nums2 = [1, 2, 3]) == 24\n    assert candidate(nums1 = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 120\n    assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5]) == 25\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 310\n    assert candidate(nums1 = [10000, 10000, 10000, 10000, 10000],nums2 = [5000, 5000, 5000, 5000, 5000]) == 50000\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 2, 30, 4, 50, 6, 70, 8, 90, 10]) == 280\n    assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 5500\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5]) == 15\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n    assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 800\n    assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 55000\n    assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 30\n    assert candidate(nums1 = [10000, 1, 10000, 1, 10000],nums2 = [1, 10000, 1, 10000, 1]) == 40001\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 200000\n    assert candidate(nums1 = [5, 1, 3, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 104\n    assert candidate(nums1 = [5000, 3000, 1000, 500, 250],nums2 = [250, 500, 1000, 3000, 5000]) == 17000\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 176\n    assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [1, 6, 11, 16, 21]) == 75\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 42\n    assert candidate(nums1 = [10000, 10000, 10000, 10000, 10000],nums2 = [9999, 9999, 9999, 9999, 9999]) == 50000\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 45\n    assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],nums2 = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 3100\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999]) == 99990\n    assert candidate(nums1 = [5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5]) == 41\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 150000\n    assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 58\n    assert candidate(nums1 = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1],nums2 = [1, 10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000]) == 60004\n    assert candidate(nums1 = [10000, 9000, 8000, 7000, 6000],nums2 = [100, 200, 300, 400, 500]) == 40000\n    assert candidate(nums1 = [5000, 2000, 3000, 4000, 1000],nums2 = [1000, 4000, 3000, 2000, 5000]) == 19000\n    assert candidate(nums1 = [9999, 9998, 9997, 9996, 9995],nums2 = [1, 2, 3, 4, 5]) == 49985\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 36\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 80\n    assert candidate(nums1 = [5000, 5000, 5000, 5000, 5000],nums2 = [10000, 10000, 10000, 10000, 10000]) == 50000\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n    assert candidate(nums1 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n    assert candidate(nums1 = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],nums2 = [9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000]) == 100000\n    assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 400\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 100000\n    assert candidate(nums1 = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50000\n    assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 550\n    assert candidate(nums1 = [100, 100, 100, 100, 100],nums2 = [200, 200, 200, 200, 200]) == 1000\n    assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [5000, 4000, 3000, 2000, 1000]) == 21000\n    assert candidate(nums1 = [5000, 5000, 5000, 5000, 5000],nums2 = [5000, 5000, 5000, 5000, 5000]) == 25000\n    assert candidate(nums1 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 40\n    assert candidate(nums1 = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],nums2 = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 604\n    assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 100\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100, 5, 4, 3, 2, 1]) == 3000\n    assert candidate(nums1 = [1, 10, 100, 1000, 10000],nums2 = [10000, 1000, 100, 10, 1]) == 22100\n    assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5500\n    assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 50\n    assert candidate(nums1 = [100, 50, 30, 20, 10],nums2 = [10, 20, 30, 50, 100]) == 330\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [100, 90, 80, 70, 60]) == 400\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n    assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 8000\n    assert candidate(nums1 = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],nums2 = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 80000\n    assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [10, 8, 6, 4, 2]) == 40\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 60\n    assert candidate(nums1 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5]) == 120\n    assert candidate(nums1 = [10000, 1, 1, 1, 10000],nums2 = [1, 10000, 10000, 1, 1]) == 40001\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100]) == 2100\n    assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],nums2 = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1760\n    assert candidate(nums1 = [10000, 10000, 10000, 10000, 10000],nums2 = [1, 1, 1, 1, 1]) == 50000\n    assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [1, 2, 3, 4, 5]) == 15000\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 10000],nums2 = [10000, 1, 1, 1, 1, 1]) == 20004\n", "comparison": "exact"}, "public_tests": ["[60,60,60]\n[10,90,10]", "[20,40,20,70,30]\n[50,20,50,40,20]", "[7,11,13]\n[1,1,1]"], "hints": ["Think on Dynamic Programming.", "First assume you will be taking the array a and choose some subarray from b", "Suppose the DP is DP(pos, state). pos is the current position you are in. state is one of {0,1,2}, where 0 means taking the array a, 1 means we are taking the subarray b, and 2 means we are again taking the array a. We need to handle the transitions carefully."], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maximumsSplicedArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:43+00:00", "tests_total": 87, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def maximumsSplicedArray(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "maximumsSplicedArray", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2322, "task_id": "minimum-score-after-removals-on-a-tree", "difficulty": "Hard", "problem_description": "There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.\n\nYou are given a 0-indexed integer array nums of length n where nums[i] represents the value of the i^th node. You are also given a 2D integer array edges of length n - 1 where edges[i] = [a_i, b_i] indicates that there is an edge between nodes a_i and b_i in the tree.\n\nRemove two distinct edges of the tree to form three connected components. For a pair of removed edges, the following steps are defined:\n\n1. Get the XOR of all the values of the nodes for each of the three components respectively.\n2. The difference between the largest XOR value and the smallest XOR value is the score of the pair.\n\n- For example, say the three components have the node values: [4,5,7], [1,9], and [3,3,3]. The three XOR values are 4 ^ 5 ^ 7 = 6, 1 ^ 9 = 8, and 3 ^ 3 ^ 3 = 3. The largest XOR value is 8 and the smallest XOR value is 3. The score is then 8 - 3 = 5.\n\nReturn the minimum score of any possible pair of edge removals on the given tree.\n\nExample 1:\n\nInput: nums = [1,5,5,4,11], edges = [[0,1],[1,2],[1,3],[3,4]]\nOutput: 9\nExplanation: The diagram above shows a way to make a pair of removals.\n- The 1^st component has nodes [1,3,4] with values [5,4,11]. Its XOR value is 5 ^ 4 ^ 11 = 10.\n- The 2^nd component has node [0] with value [1]. Its XOR value is 1 = 1.\n- The 3^rd component has node [2] with value [5]. Its XOR value is 5 = 5.\nThe score is the difference between the largest and smallest XOR value which is 10 - 1 = 9.\nIt can be shown that no other pair of removals will obtain a smaller score than 9.\n\nExample 2:\n\nInput: nums = [5,5,2,4,4,2], edges = [[0,1],[1,2],[5,2],[4,3],[1,3]]\nOutput: 0\nExplanation: The diagram above shows a way to make a pair of removals.\n- The 1^st component has nodes [3,4] with values [4,4]. Its XOR value is 4 ^ 4 = 0.\n- The 2^nd component has nodes [1,0] with values [5,5]. Its XOR value is 5 ^ 5 = 0.\n- The 3^rd component has nodes [2,5] with values [2,2]. Its XOR value is 2 ^ 2 = 0.\nThe score is the difference between the largest and smallest XOR value which is 0 - 0 = 0.\nWe cannot obtain a smaller score than 0.\n\nConstraints:\n\n- n == nums.length\n- 3 <= n <= 1000\n- 1 <= nums[i] <= 10^8\n- edges.length == n - 1\n- edges[i].length == 2\n- 0 <= a_i, b_i < n\n- a_i != b_i\n- edges represents a valid tree.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 5, 5, 4, 11],edges = [[0, 1], [1, 2], [1, 3], [3, 4]]) == 9\n    assert candidate(nums = [10, 20, 30, 40, 50],edges = [[0, 1], [0, 2], [0, 3], [3, 4]]) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 1\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n    assert candidate(nums = [5, 5, 2, 4, 4, 2],edges = [[0, 1], [1, 2], [5, 2], [4, 3], [1, 3]]) == 0\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [3, 6]]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 4\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 1\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]]) == 336\n    assert candidate(nums = [100000000, 50000000, 25000000, 12500000, 6250000, 3125000, 1562500, 781250, 390625, 195312, 97656, 48828, 24414, 12207],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13]]) == 67079550\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 36\n    assert candidate(nums = [100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 1\n    assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10]]) == 3\n    assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]]) == 11\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == 2\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9]]) == 1\n    assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 36\n    assert candidate(nums = [9, 3, 5, 2, 7, 1, 8, 6, 4],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8]]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == 4\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 3\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8]]) == 16\n    assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]]) == 75\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == 0\n    assert candidate(nums = [1, 3, 2, 5, 4, 6, 7, 9, 8, 10, 12, 11, 13, 15, 14, 17, 16, 19, 18, 20],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [2, 6], [6, 7], [4, 8], [8, 9], [8, 10], [5, 11], [11, 12], [11, 13], [10, 14], [14, 15], [14, 16], [7, 17], [17, 18], [18, 19]]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11]]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]]) == 20\n    assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]]) == 11\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == 2\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == 3\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 36\n    assert candidate(nums = [100000000, 99999999, 88888888, 77777777, 66666666, 55555555, 44444444, 33333333, 22222222, 11111111],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 9915534\n    assert candidate(nums = [1, 5, 3, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23]]) == 0\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10]]) == 552\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]]) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 4\n", "comparison": "exact"}, "public_tests": ["[1,5,5,4,11]\n[[0,1],[1,2],[1,3],[3,4]]", "[5,5,2,4,4,2]\n[[0,1],[1,2],[5,2],[4,3],[1,3]]"], "hints": ["Consider iterating over the first edge to remove, and then doing some precalculations on the 2 resulting connected components.", "Will calculating the XOR of each subtree help?"], "metadata": {"canonical_parameter_names": ["nums", "edges"], "leetcode_dataset_entry_point": "Solution().minimumScore", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:45+00:00", "tests_total": 55, "tests_dropped": 1, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "bit-manipulation", "tree", "depth-first-search"]}, "language": "python", "interface": {"raw_signature": "def minimumScore(self, nums: list[int], edges: list[list[int]]) -> int:", "container": "Solution", "callable": "minimumScore", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2325, "task_id": "decode-the-message", "difficulty": "Easy", "problem_description": "You are given the strings key and message, which represent a cipher key and a secret message, respectively. The steps to decode message are as follows:\n\n1. Use the first appearance of all 26 lowercase English letters in key as the order of the substitution table.\n2. Align the substitution table with the regular English alphabet.\n3. Each letter in message is then substituted using the table.\n4. Spaces ' ' are transformed to themselves.\n\n- For example, given key = \"happy boy\" (actual key would have at least one instance of each letter in the alphabet), we have the partial substitution table of ('h' -> 'a', 'a' -> 'b', 'p' -> 'c', 'y' -> 'd', 'b' -> 'e', 'o' -> 'f').\n\nReturn the decoded message.\n\nExample 1:\n\nInput: key = \"the quick brown fox jumps over the lazy dog\", message = \"vkbs bs t suepuv\"\nOutput: \"this is a secret\"\nExplanation: The diagram above shows the substitution table.\nIt is obtained by taking the first appearance of each letter in \"the quick brown fox jumps over the lazy dog\".\n\nExample 2:\n\nInput: key = \"eljuxhpwnyrdgtqkviszcfmabo\", message = \"zwx hnfx lqantp mnoeius ycgk vcnjrdb\"\nOutput: \"the five boxing wizards jump quickly\"\nExplanation: The diagram above shows the substitution table.\nIt is obtained by taking the first appearance of each letter in \"eljuxhpwnyrdgtqkviszcfmabo\".\n\nConstraints:\n\n- 26 <= key.length <= 2000\n- key consists of lowercase English letters and ' '.\n- key contains every letter in the English alphabet ('a' to 'z') at least once.\n- 1 <= message.length <= 2000\n- message consists of lowercase English letters and ' '.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"cba zyx\") == \"xyz abc\"\n    assert candidate(key = \"a quick movement of the enemy will jeopardize five gunboats\",message = \"yfcj myj pyjl ufcj myj pyjl ufcj myj pyjl\") == \"omer gor sorq cmer gor sorq cmer gor sorq\"\n    assert candidate(key = \"the five boxing wizards jump quickly on this yellow pig\",message = \"jhxuh lqdj efxgh lpuaz fxdyjzjw\") == \"rbisb yvpr cdikb yusnm dipzrmrl\"\n    assert candidate(key = \"dvhfujngcpqxlwokzriebastmy\",message = \"mwtiaz azr\") == \"ynxsvq vqr\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"xyz abc\") == \"xyz abc\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"vkbs bs t suepuv\") == \"this is a secret\"\n    assert candidate(key = \"byvzkgxfnqmpalwodjtrshceui\",message = \"xsm wv zmz\") == \"guk oc dkd\"\n    assert candidate(key = \"wmtresuavhigdcbfykjqploxzn\",message = \"lfnlccyvmdg\") == \"vpzvnnqibml\"\n    assert candidate(key = \"zabcdefghijklmnopqrstuvwxy\",message = \"sl rfc zdf\") == \"tm sgd aeg\"\n    assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"mlkjhgfedcbazyxwvutsrqpon\") == \"nopqstuvwxyzabcdefghijklm\"\n    assert candidate(key = \"eljuxhpwnyrdgtqkviszcfmabo\",message = \"zwx hnfx lqantp mnoeius ycgk vcnjrdb\") == \"the five boxing wizards jump quickly\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"z x c v\") == \"z x c v\"\n    assert candidate(key = \"gysrnhxvaofcedwmltukipjbqz\",message = \"gigv symykgl igxvxjxg\") == \"auah cbpbtaq uaghgwga\"\n    assert candidate(key = \"phinxajsgkrzcwvltqbdemoufy\",message = \"xvo wv pmj\") == \"eow no avg\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"zaoymnbxcqrljtheifkgdvspwu\") == \"zaoymnbxcqrljtheifkgdvspwu\"\n    assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"gsv jfrxp yildm ulc\") == \"olw qnduj fhsmz gsv\"\n    assert candidate(key = \"the five boxing wizards jump quickly on this june day\",message = \"ymj lvfx sflhzymhs vxlw wjymjlvfx sflhzymhs\") == \"ztr yfdi qdybmztbq fiyl lrztryfdi qdybmztbq\"\n    assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt\") == \"thequ ickbr ownfo xjump sover thela zydog\"\n    assert candidate(key = \"dfghjklwcvxziomnpqrustyabe\",message = \"kckd ykky\") == \"fifa wffw\"\n    assert candidate(key = \"mnychdpbxofl wgviakjuzterqs\",message = \"irhvmvccsjb\") == \"pxeoaoddzsh\"\n    assert candidate(key = \"pack my box with five dozen liquor jugs\",message = \"xujf qv zgy jxpx qne nfgqj sraju\") == \"ivxn uo ryf xiai usp snyux zwbxv\"\n    assert candidate(key = \"mwp dhxjzvcqrkbyanflstguoei\",message = \"di vccvmr wv czebwqha wv iv lvyrj\") == \"dz ijjial bi jhynbkep bi zi siolg\"\n    assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"a b c d\") == \"z y x w\"\n    assert candidate(key = \"the five boxing wizards jump quickly\",message = \"fmwp vifd ttp xosmead\") == \"dtlu fedp aau ihqtcnp\"\n    assert candidate(key = \"vuqangfkswjpryxtdmzobhcile\",message = \"wfn yv yfcv\") == \"jge na ngwa\"\n    assert candidate(key = \"abcdefghijk lmnopqrstuvwxyz\",message = \"eiqhw fjq hwdq\") == \"eiqhw fjq hwdq\"\n    assert candidate(key = \"a quick movement of the enemy will jeopardize five gunboats\",message = \"zruog glhvg frp fvdw zl glcgv\") == \"vtchw wqniw mts miup vq wqewi\"\n    assert candidate(key = \"thejumpsquickbrownfoxoverlazydog\",message = \"svhjyjsiqphsjudprvcbgijz\") == \"htbdxdhjigbhdeygntkmzjdw\"\n    assert candidate(key = \"ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az\",message = \"qz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz\") == \"qz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz vz\"\n    assert candidate(key = \"swzybfrxlnaoumdgtqivhjkpce\",message = \"flgxswdliefyirukyoaqmpjc\") == \"fiphaboiszfdsgmwdlkrnxvy\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"qruqz efn nhr htyq\") == \"djedw cnm mbj baxd\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"xibohu uvp xibohu\") == \"ofikbe etr ofikbe\"\n    assert candidate(key = \"abcd efgh ijkl mnop qrst uvwx yz\",message = \"vuwx yz abcd ef\") == \"vuwx yz abcd ef\"\n    assert candidate(key = \"gymnopqrstuvwxzabcdefhiljk\",message = \"xqmgq zm zmjy\") == \"ngcag oc ocyb\"\n    assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"yxe xe xe\") == \"bcv cv cv\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",message = \"abc def abc\") == \"abc def abc\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"vxp qpy o\") == \"vxp qpy o\"\n    assert candidate(key = \"jumps over the lazy dog quick brown fox\",message = \"pvuzr cgviy ojizv bxz cfiwz nqzsx vgrb\") == \"dgbni tqgso fasng vzn tyswn xrnez gqiv\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"xqf\") == \"odn\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"gfn\") == \"znm\"\n    assert candidate(key = \"pzucfelxwyabqomtjirdnsvhgk\",message = \"kwj kwi kwv wkv\") == \"ziq zir ziw izw\"\n    assert candidate(key = \"fmwtkujhpnobxigcsqrzydalve\",message = \"fyh fyt fyv yfj\") == \"auh aud auy uag\"\n    assert candidate(key = \"abcdefghij klmnopqrstuvwxyz\",message = \"qzcfj nx ud qzcfj\") == \"qzcfj nx ud qzcfj\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"yjx x\") == \"xpo o\"\n    assert candidate(key = \"jumps over lazy dogs quick brown fox the this\",message = \"yjiwxtw vqzj spwq ovbxc yoz qjxv\") == \"maquxyu gpla edup fgtxr mfl paxg\"\n    assert candidate(key = \"jklmnopqrstuvwxyzabcdefghi\",message = \"frg fmh gfn\") == \"wix wdy xwe\"\n    assert candidate(key = \"zabcdefghijklmnopqrstuvwxy\",message = \"qxy xyx yxq\") == \"ryz yzy zyr\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dog and the quick brown fox jumps over the lazy dog\",message = \"vkbs bs t suepuv\") == \"this is a secret\"\n    assert candidate(key = \"ekmflgdqvzntowyhxuspaibrcj\",message = \"jbs xut hig\") == \"zws qrl pvf\"\n    assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"iyh uhy l\") == \"rbs fsb o\"\n    assert candidate(key = \"vwxymnbcdfghjklqropstuzaike\",message = \"vcp o cv vcp\") == \"ahs r ha ahs\"\n    assert candidate(key = \"ajfzldkgotmhrvwsypnqicxebu\",message = \"oxt oxi oxd xot\") == \"iwj iwu iwf wij\"\n    assert candidate(key = \"jklmnopqrstuvwxyzabcdefghi\",message = \"wfn yv yfcv\") == \"nwe pm pwtm\"\n    assert candidate(key = \"tevosjhbnyxrgqkfaumzilwpcd\",message = \"npu gpm gpy lgg\") == \"ixr mxs mxj vmm\"\n    assert candidate(key = \"mnbvcxzlkjhgfdsapoiuytrewq\",message = \"hfu q jhu\") == \"kmt z jkt\"\n    assert candidate(key = \"asdfghjklqwertyuiopzxcvbnm\",message = \"yqz dpy o\") == \"ojt cso r\"\n    assert candidate(key = \"qbnvgjlftscxkouwamdphzreiy\",message = \"umr urv urm pyz\") == \"orw owd owr tzv\"\n    assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"zqj dpy o\") == \"taq mjf i\"\n    assert candidate(key = \"five boxing wizards jump quickly on this lazy dog\",message = \"qzyc yvzctv yxqjvzq yjiwxtw on qjxv yoj\") == \"tkxu xckuyc xgtpckt xpbjgyj fh tpgc xfp\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"c e\") == \"g c\"\n    assert candidate(key = \"abcdefghizjklmnopqrstuvwxy\",message = \"lii eil eil\") == \"mii eim eim\"\n    assert candidate(key = \"vxznpqjwoefkytlimrdhaguscb\",message = \"tyf iy tf\") == \"nmk pm nk\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"sw uqz\") == \"sl edw\"\n    assert candidate(key = \"jxwtrklivnpmhudsfgcayzbeoq\",message = \"kcfizgv zr ocfv\") == \"fsqhvri ve ysqi\"\n    assert candidate(key = \"lazy dogs quick brown fox jumps over the this\",message = \"vqzj spwq ovbxc yjiwxtw vqzj qjxv\") == \"wict hvpi fwnsl dtkpsyp wict itsw\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"yjx z\") == \"xpo w\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"mlml qmf lml gmgg\") == \"mlml qmf lml gmgg\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"vz\") == \"tw\"\n    assert candidate(key = \"dbrujxfgzvcotwiympnslakqhe\",message = \"kmqs ks u kqsebs\") == \"wqxt wt d wxtzbt\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"wqiv xi sqin sqin\") == \"ldft of sdfm sdfm\"\n    assert candidate(key = \"dtjgsvyzxpkbfqwulcmohraeni\",message = \"obr obn oti atn\") == \"tlv tly tbz wby\"\n    assert candidate(key = \"abcdefghijk lmnopqrstuvwxyz\",message = \"svil km ybgu bg ujr krkhi yjr cvvux\") == \"svil km ybgu bg ujr krkhi yjr cvvux\"\n    assert candidate(key = \"the quick brown fox jumps over lazy dogs\",message = \"mht zrs xqf ovkqvoq ngyu kgxqj bpxc\") == \"qba wjs odn kthdtkd mzxe hzodp irog\"\n    assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"jyq zq o\") == \"qfa ta i\"\n    assert candidate(key = \"gibrfqotdhewakjyzlxmvncpus\",message = \"yxh lo loxhy\") == \"psj rg rgsjp\"\n    assert candidate(key = \"mnopqrstuvwxyzabcdefghijkl\",message = \"aov eovm eovm\") == \"ocj scja scja\"\n    assert candidate(key = \"gfedcbauioplkjhzyxwvtsrqmn\",message = \"ixv yxv oxv\") == \"irt qrt jrt\"\n    assert candidate(key = \"xyzabcdefghijklmnopqrstuvw\",message = \"wvf v fv\") == \"zyi y iy\"\n    assert candidate(key = \"abc def ghijk lmnop qrst uvwxyz\",message = \"nvmjy nbsytw\") == \"nvmjy nbsytw\"\n    assert candidate(key = \"eljuxhpwnyrdgtqkviszcfmabo\",message = \"ihd hsih xihw gh hsi\") == \"rfl fsrf erfh mf fsr\"\n    assert candidate(key = \"nopqrstuvwxyzabcdefghijklm\",message = \"zqv qv q\") == \"mdi di d\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"qytz nwt zwt\") == \"dxaw mla wla\"\n    assert candidate(key = \"quick brown fox jumps over the lazy dog and the quick brown fox jumps\",message = \"vxw aov g pufa ohq\") == \"qli vhq z obkv hta\"\n    assert candidate(key = \"vbnmxczasdfghjklpoiuytrewq\",message = \"vkbs bs t suepuv\") == \"aobi bi v itxqta\"\n    assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"yvc zc yz\") == \"bex ax ba\"\n    assert candidate(key = \"azbycxdwevfugthrskjqplomni\",message = \"tqppf ptd je\") == \"ntuuk ung si\"\n    assert candidate(key = \"xylophone qwertyuiop asdfghjklz cvbnm\",message = \"cvmu cvxqv\") == \"wxzm wxaix\"\n    assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"lqtfw xtg twkxq\") == \"saenb ueo ebrua\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"yjx v\") == \"xpo t\"\n    assert candidate(key = \"nmqpviwedklxzfgrctuhyjasob\",message = \"ohc oha ohu voh\") == \"ytq ytw yts eyt\"\n    assert candidate(key = \"nopqrstuvwxyzabcdefghijklm\",message = \"izk zkh bva jnfrdq\") == \"vmx mxu oin waseqd\"\n    assert candidate(key = \"quick brown fox jumps over the lazy dog\",message = \"rwjsi exmti gsrhri zv wimtix egzewy\") == \"gimpc rlnsc zpgtgc wq icnscl rzwrix\"\n    assert candidate(key = \"lazy dogs jumps over the quick brown fox the\",message = \"vqzj yjiwxtw spwq yoj spwq ovbxc yoz\") == \"mrci diswzpw hlwr dfi hlwr fmvzt dfc\"\n    assert candidate(key = \"mnopqrstuvwxyzabcdefghijkl\",message = \"mud gct gct\") == \"air uqh uqh\"\n    assert candidate(key = \"lazy dogs jumps quickly over the brown fox and\",message = \"vqzj yjiwxtw spwq yoj ovbxc yoz\") == \"qmci dinwztw hlwm dfi fqvzo dfc\"\n    assert candidate(key = \"vzhofucmlnjqbdspartexwiykg\",message = \"dpy ld o yv\") == \"npx in d xa\"\n    assert candidate(key = \"mnbvcxzlkjhgfdsapoiuytrewq\",message = \"cv lpcv\") == \"ed hqed\"\n    assert candidate(key = \"the lazy dog jumps over the quick brown fox\",message = \"qjxv yoj vqzj spwq yjiwxtw ovbxc yvoqzgkxq\") == \"rkzp gik prfk onwr gkswzaw ipvzt gpirfjuzr\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"yjx yjx\") == \"xpo xpo\"\n    assert candidate(key = \"cvzkgbxquihmpnytjrsdawolef\",message = \"cfr cfd cfl mfl\") == \"azr azt azx lzx\"\n    assert candidate(key = \"lazy dogs jumps quickly over the brown fox the\",message = \"vqzj yjiwxtw spwq yoj ovbxc yoj\") == \"qmci dinwztw hlwm dfi fqvzo dfi\"\n    assert candidate(key = \"thezyxwvutsrqponmlkjihgfedcba\",message = \"zqv eovm ztqkofv ztqkofv\") == \"dlh cnhp dalrnvh dalrnvh\"\n    assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"evh vhe yhe\") == \"ves esv bsv\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"zqf ykq fqu fqo ykt nqtk\") == \"wdn xhd nde ndk xha mdah\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"hqv v yhqf\") == \"hqv v yhqf\"\n    assert candidate(key = \"ponmlkjihgfedcbazyxwvutsrq\",message = \"jxqy xtgy efn nhr\") == \"gszr swjr lkc ciy\"\n    assert candidate(key = \"gymbztfkwjxehalnqosrudvpci\",message = \"nqzv nq p azdvmn\") == \"pqew pq x nevwcp\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"zcf bvg jnfrdq\") == \"zcf bvg jnfrdq\"\n    assert candidate(key = \"brown fox the quick jumps over lazy dogs and\",message = \"ovbxc yoz spwq yvoqzgkxq vqzj qjxv ovgx\") == \"ctagn xcw srdk xtckwzogk tkwp kpgt ctzg\"\n    assert candidate(key = \"qpwoeirutyalskdjfhgczxmvbn\",message = \"vcp o cv ocv\") == \"xtb d tx dtx\"\n    assert candidate(key = \"ijklmnopqrstuvwxyzabcdefgh\",message = \"wqv qv q\") == \"oin in i\"\n    assert candidate(key = \"cijqxfyvolnmtzgdwsaehrkpbu\",message = \"fnw uvf uft nwg\") == \"fkq zhf zfm kqo\"\n    assert candidate(key = \"lazy dogs jump quickly over the brown fox\",message = \"jxqy xtgy efn nhr\") == \"izmd ztgd ryx xus\"\n    assert candidate(key = \"phinxqbcdgjkamlstvrewyzouf\",message = \"thx thg lv xkqhs\") == \"qbe qbj or elfbp\"\n    assert candidate(key = \"jklmnopqrstuvwxyzabcdefghi\",message = \"dru gct gct\") == \"uil xtk xtk\"\n    assert candidate(key = \"jxqtvknpsmuhbdrgzlcewfoaiy\",message = \"dgy gch dgy\") == \"npz psl npz\"\n    assert candidate(key = \"abcdefghijklnmopqrstuvwxyz\",message = \"opq qpo qpo\") == \"opq qpo qpo\"\n    assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"gsv htk gdv jgd\") == \"olw per omw qom\"\n    assert candidate(key = \"wsgczxfltkbqpndohjuaevrmiy\",message = \"vmx gpm mvg maq\") == \"vxf cmx xvc xtl\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"xol mlu w yjx\") == \"xol mlu w yjx\"\n    assert candidate(key = \"dogs quick brown fox jumps over lazy the this\",message = \"vqzj spwq ovbxc yjiwxtw vqzj qjxv\") == \"sewp drle bsjoh xpgloyl sewp epos\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"yjx y\") == \"xpo x\"\n    assert candidate(key = \"lmnopqrstuvwxyzabcdefghijk\",message = \"vqj qjv z\") == \"kfy fyk o\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"qiy oiq z\") == \"qiy oiq z\"\n    assert candidate(key = \"and the quick brown fox jumps over lazy dogs\",message = \"ovgx yoj spwq yvoqzgkxq ovbxc yjiwxtw vqzj\") == \"nvzq ynr utog yvngxzkqg nvlqj yrioqdo vgxr\"\n    assert candidate(key = \"qwertyuioplkjhgfdsazxcvbnm\",message = \"gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt\") == \"orwmp dujfh kqzgk vapyl nkcwh orwit sxbke\"\n    assert candidate(key = \"nopqrstuvwxyzabcdefghijklm\",message = \"zqv qv z\") == \"mdi di m\"\n    assert candidate(key = \"quick brown fox jumps over lazy dogs the this\",message = \"yvoqzgkxq ovbxc yjiwxtw vqzj qjxv spwq qjxv\") == \"vqhauxela hqfld vmcilyi qaum amlq poia amlq\"\n    assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"oxj o j\") == \"iuq i q\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"sw yjx\") == \"sl xpo\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"v zifw ilxqfs\") == \"t wfnl fuodns\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"qzcf bfgs jgcd yqcf\") == \"qzcf bfgs jgcd yqcf\"\n    assert candidate(key = \"abcdefghizjklmnopqrstuvwxy\",message = \"ulc cul cul\") == \"vmc cvm cvm\"\n    assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"tsr rst rst\") == \"ghi ihg ihg\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"qz cf\") == \"dw gn\"\n    assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"mfir kkfr ifxk\") == \"znhd rrnd hnur\"\n    assert candidate(key = \"fnex wpviqkdmtlugybhcarzsoj\",message = \"hcv uxl\") == \"stg odn\"\n    assert candidate(key = \"zebra quick brown fox jumps over the lazy dog\",message = \"gqjty efn nhr htyq\") == \"zfpux bnm mvd vuxf\"\n    assert candidate(key = \"nopqrstuvwxyzabcdefghijklm\",message = \"vqz zqv z\") == \"idm mdi m\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"vgj ov sa jhygjmt oh rjw\") == \"tzp kt sv pbxzpqa kb jpl\"\n    assert candidate(key = \"bcadefghijklmnopqrstuvwxzy\",message = \"bdc bva jnfrdq\") == \"adb avc jnfrdq\"\n    assert candidate(key = \"asdfghjklqwertyuiopzxcvbnm\",message = \"wqv qv q\") == \"kjw jw j\"\n    assert candidate(key = \"zebra tiger quick brown fox jumps over the lazy dog\",message = \"uybvf ojizv cfiwz nqzsx vgrb cgviy ojizv bxz\") == \"jycvp mrgav kpgna oiauq vhdc khvgy mrgav cqa\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"dkv v yvk\") == \"yht t xth\"\n    assert candidate(key = \"nopqrstuvwxyzabcdefghijklm\",message = \"zqv qv zc\") == \"mdi di mp\"\n    assert candidate(key = \"the brown fox jumps quickly over a lazy dog\",message = \"pjoj qvw xqt jqtqi yjiwxtw spwq jx gsvk yoj\") == \"nkfk pvg jpa kpapq ukqgjag ongp kj zovs ufk\"\n    assert candidate(key = \"this quick brown fox jumps over lazy dogs\",message = \"qjxv yvoqzgkxq ovbxc yjiwxtw spwq yoj vqzj\") == \"epos xskewzhoe ksiog xpcloal drle xkp sewp\"\n    assert candidate(key = \"jklmnopqrstuvwxyzabcdefghi\",message = \"sgtw xjxw xjxw\") == \"jxkn oaon oaon\"\n    assert candidate(key = \"a bc df egh ijkl mno pq rs tuvwxyz\",message = \"v lqyq w lwv yjx\") == \"v lqyq w lwv yjx\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"qzcfb qmgox ypgmt gsv fiu\") == \"qzcfb qmgox ypgmt gsv fiu\"\n    assert candidate(key = \"pqrkxlcdemosvahzwfygtnujib\",message = \"izv zfc yfcv\") == \"ypm prg srgm\"\n    assert candidate(key = \"lazy dogs jump over quick brown fox the\",message = \"bxz bpxc wxqgc ebcjg fcivw zqzsx ojizv\") == \"txc tlxr uxpgr ntrig wrqmu cpchx fiqcm\"\n    assert candidate(key = \"okyftdazhsxngijwumrcvqlpeb\",message = \"kqv mhg a lv vjx\") == \"bvu rim g wu uok\"\n    assert candidate(key = \"the brown fox jumps quickly over a lazy dog\",message = \"mht zrs xqf ovkqvoq ngyu a qzfe nax\") == \"mba xeo jpi fvspvfp hzul w pxic hwj\"\n    assert candidate(key = \"over lazy dogs quick brown fox jumps the this\",message = \"spwq vqzj spwq ovbxc yjiwxtw qjxv qjxv\") == \"kxrl blgv kxrl abquo hvnruyr lvub lvub\"\n    assert candidate(key = \"the brown quick fox jumps over lazy dogs\",message = \"zqft gqf vxt xec ohq oizd\") == \"wina zin toa ocl fbi fkwy\"\n    assert candidate(key = \"jumped over the lazy brown fox quick\",message = \"ujxqyc efn nhr htyq\") == \"batuow esr rki kjou\"\n    assert candidate(key = \"fghijklmnopqrstuvwxyzabcde\",message = \"vrc vja vrc vja\") == \"qmx qev qmx qev\"\n    assert candidate(key = \"the quick brown fox jumps over lazy dogs and\",message = \"spwq yvoqzgkxq ovbxc yjiwxtw vqzj ovgx\") == \"srld xtkdwzhod ktiog xpfloal tdwp ktzo\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"qjvux xfgf q px\") == \"dpteo onzn d ro\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dog\",message = \"dkv v ydv\") == \"yht t xyt\"\n    assert candidate(key = \"xlsnmveizhptfjugobcdkqrway\",message = \"wcr vcv wcv xwv\") == \"xsw fsf xsf axf\"\n    assert candidate(key = \"quick brown fox jumps over lazy dog the\",message = \"fxfsr jxqfk wtf pvuzr bcgy jxqfk dvo\") == \"klkpg mlake iyk oqbug fdxv mlake wqh\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"yjx w\") == \"xpo l\"\n    assert candidate(key = \"bdfhjlnprtvxzcgikmoqsuwyae\",message = \"hc vjg cji cgy\") == \"dn keo nep nox\"\n    assert candidate(key = \"onmlkjihgfedcbazyxwvutsrqp\",message = \"ixkz znxoz kx yq\") == \"grep pbrap er qy\"\n    assert candidate(key = \"phqgiumeaylnofdxjkrcvstzwb\",message = \"ixw ikg ikg ikg\") == \"epy erd erd erd\"\n    assert candidate(key = \"five boxing wizards jump quickly on this lazy dog\",message = \"wfkq xqfnk uveogvj pvuzr cfiwz rjgt jxqfk bxz\") == \"javt gtahv qcdficp scqkm uabjk mpiy pgtav egk\"\n    assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"vqj qjv cv\") == \"waq aqw vw\"\n    assert candidate(key = \"abcdefghjklmnopqrstuvwxyzti\",message = \"ghw gct gct\") == \"ghv gcs gcs\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"fnbv wvxm\") == \"nmit ltoq\"\n    assert candidate(key = \"the quick brown fox jumps over the lazy dogs\",message = \"yjx\") == \"xpo\"\n    assert candidate(key = \"mnbvcxzlkjhgfdsapoiuytrewq\",message = \"qnb wql fhw fql\") == \"zbc yzh mky mzh\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz\",message = \"anxanq azoz anu\") == \"anxanq azoz anu\"\n    assert candidate(key = \"thequickbrownfoxjumpsoverthelazydogs\",message = \"qjvux xfgf q px\") == \"dpteo onzn d ro\"\n    assert candidate(key = \"abcdefghjklmnopqrstuvwxyzti\",message = \"jkq xjxw xjxw\") == \"ijp wiwv wiwv\"\n    assert candidate(key = \"bujgtfayrxohqzplmwdinckevs\",message = \"yzq d pyq o\") == \"hnm s ohm k\"\n    assert candidate(key = \"rjkylmfdqogavwunhixpctzesb\",message = \"tzm tmz tmh tmi\") == \"vwf vfw vfq vfr\"\n    assert candidate(key = \"the quick brown fox jumps over lazy dogs this\",message = \"spwq yvoqzgkxq ovbxc yjiwxtw vqzj qjxv\") == \"srld xtkdwzhod ktiog xpfloal tdwp dpot\"\n    assert candidate(key = \"brown fox jumps over lazy dogs the quick this\",message = \"ovbxc yjiwxtw vqzj qjxv spwq yvoqzgkxq\") == \"cmagy rhxdgud mwqh whgm lkdw rmcwqtzgw\"\n    assert candidate(key = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",message = \"z k u o c g t w\") == \"z k u o c g t w\"\n    assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"gtgt nvo gtg mpgg\") == \"tgtg mel tgt nktt\"\n    assert candidate(key = \"ijklmnopqrstuvwxyzabcdefgh\",message = \"wqv qv qv\") == \"oin in in\"\n    assert candidate(key = \"mjw qzlnf hw uo kcf jehrv dpo osxgt cyqak\",message = \"jnjfdh frl df\") == \"bgbhqi hof qh\"\n    assert candidate(key = \"abcdefghizjklmnopqrstuvwxy\",message = \"vuvw xw yx za\") == \"wvwx yx zy ja\"\n    assert candidate(key = \"abcdefghijklnmopqrstuvwxyz\",message = \"ehu zcv i\") == \"ehu zcv i\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"ehu zcv i\") == \"ehu zcv i\"\n    assert candidate(key = \"wvutsrqponmlkjihgfedcba zyx\",message = \"zyxwvutsrqpnmolkjihgfedcba\") == \"xyzabcdefghjkilmnopqrstuvw\"\n    assert candidate(key = \"mnbvcxzlkjhgfdsapoiuytrewq\",message = \"vcp o cv v\") == \"deq r ed d\"\n    assert candidate(key = \"qwertyuiopasdfghjklzxcvbnm\",message = \"jyq zq j\") == \"qfa ta q\"\n    assert candidate(key = \"the brown fox jumps over the lazy dog quickly\",message = \"tqpp d dswcp gygij\") == \"awnn u uogyn vtvxk\"\n    assert candidate(key = \"zyxwvutsrqponmlkjihgfedcba\",message = \"ixq kivk eiqb\") == \"rcj prep vrjy\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"wklv lv dq xvh hqw phvvdjh\") == \"wklv lv dq xvh hqw phvvdjh\"\n    assert candidate(key = \"nopqrstuvwxyzabcdefghijklm\",message = \"zcf jopcnboe wj jop\") == \"mps wbcpaobr jw wbc\"\n    assert candidate(key = \"xyzabcdefghijklmnopqrstuvw\",message = \"xpu xh z\") == \"asx ak c\"\n    assert candidate(key = \"quick brown fox jumps over the lazy dog\",message = \"kxvzn hqomj jxq zpsvx wbvs hq tkgx\") == \"elqwj tahnm mla wopql ifqp ta sezl\"\n    assert candidate(key = \"abcdefghijklmnopqrstuvwxyz\",message = \"ehu zcv z\") == \"ehu zcv z\"\n    assert candidate(key = \"this quick brown fox jumps over lazy dogs and\",message = \"qjxv spwq yvoqzgkxq ovbxc yjiwxtw vqzj ovgx\") == \"epos drle xskewzhoe ksiog xpcloal sewp kszo\"\n    assert candidate(key = \"abcdef ghijklmnopqrstuvwxyz\",message = \"zcf bvg jnfrdq\") == \"zcf bvg jnfrdq\"\n    assert candidate(key = \"abcdefghijklnmopqrstuvwxyz\",message = \"qzdv lqaf qv yzxq\") == \"qzdv lqaf qv yzxq\"\n    assert candidate(key = \"abcdefghikjlmnopqrstuvwxyz\",message = \"hij iji iij\") == \"hik iki iik\"\n", "comparison": "exact"}, "public_tests": ["\"the quick brown fox jumps over the lazy dog\"\n\"vkbs bs t suepuv\"", "\"eljuxhpwnyrdgtqkviszcfmabo\"\n\"zwx hnfx lqantp mnoeius ycgk vcnjrdb\""], "hints": ["Iterate through the characters in the key to construct a mapping to the English alphabet.", "Make sure to check that the current character is not already in the mapping (only the first appearance is considered).", "Map the characters in the message according to the constructed mapping."], "metadata": {"canonical_parameter_names": ["key", "message"], "leetcode_dataset_entry_point": "Solution().decodeMessage", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:50+00:00", "tests_total": 204, "tests_dropped": 3, "flags": ["figure_reference", "has_images"], "topic_tags": ["hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def decodeMessage(self, key: str, message: str) -> str:", "container": "Solution", "callable": "decodeMessage", "parameters": [{"name": "key", "type": "str"}, {"name": "message", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2327, "task_id": "number-of-people-aware-of-a-secret", "difficulty": "Medium", "problem_description": "On day 1, one person discovers a secret.\n\nYou are given an integer delay, which means that each person will share the secret with a new person every day, starting from delay days after discovering the secret. You are also given an integer forget, which means that each person will forget the secret forget days after discovering it. A person cannot share the secret on the same day they forgot it, or on any day afterwards.\n\nGiven an integer n, return the number of people who know the secret at the end of day n. Since the answer may be very large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 6, delay = 2, forget = 4\nOutput: 5\nExplanation:\nDay 1: Suppose the first person is named A. (1 person)\nDay 2: A is the only person who knows the secret. (1 person)\nDay 3: A shares the secret with a new person, B. (2 people)\nDay 4: A shares the secret with a new person, C. (3 people)\nDay 5: A forgets the secret, and B shares the secret with a new person, D. (3 people)\nDay 6: B shares the secret with E, and C shares the secret with F. (5 people)\n\nExample 2:\n\nInput: n = 4, delay = 1, forget = 3\nOutput: 6\nExplanation:\nDay 1: The first person is named A. (1 person)\nDay 2: A shares the secret with B. (2 people)\nDay 3: A and B share the secret with 2 new people, C and D. (4 people)\nDay 4: A forgets the secret. B, C, and D share the secret with 3 new people. (6 people)\n\nConstraints:\n\n- 2 <= n <= 1000\n- 1 <= delay < forget <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 8,delay = 3,forget = 6) == 6\n    assert candidate(n = 500,delay = 100,forget = 400) == 5820125\n    assert candidate(n = 4,delay = 1,forget = 3) == 6\n    assert candidate(n = 1000,delay = 5,forget = 10) == 743819361\n    assert candidate(n = 1000,delay = 1,forget = 999) == 344211603\n    assert candidate(n = 10,delay = 2,forget = 5) == 30\n    assert candidate(n = 10,delay = 3,forget = 5) == 5\n    assert candidate(n = 15,delay = 4,forget = 7) == 19\n    assert candidate(n = 6,delay = 2,forget = 4) == 5\n    assert candidate(n = 5,delay = 1,forget = 4) == 14\n    assert candidate(n = 7,delay = 2,forget = 3) == 2\n    assert candidate(n = 100,delay = 10,forget = 50) == 22517820\n    assert candidate(n = 200,delay = 50,forget = 150) == 27250\n    assert candidate(n = 900,delay = 300,forget = 650) == 45500\n    assert candidate(n = 550,delay = 150,forget = 450) == 203375\n    assert candidate(n = 950,delay = 400,forget = 700) == 11625\n    assert candidate(n = 800,delay = 150,forget = 600) == 79177860\n    assert candidate(n = 900,delay = 150,forget = 300) == 935294905\n    assert candidate(n = 1000,delay = 1,forget = 10) == 694661098\n    assert candidate(n = 700,delay = 110,forget = 550) == 887595495\n    assert candidate(n = 600,delay = 250,forget = 550) == 5350\n    assert candidate(n = 500,delay = 100,forget = 200) == 5264525\n    assert candidate(n = 200,delay = 2,forget = 199) == 349361643\n    assert candidate(n = 1000,delay = 1,forget = 500) == 28219034\n    assert candidate(n = 1000,delay = 1,forget = 2) == 2\n    assert candidate(n = 750,delay = 250,forget = 500) == 31625\n    assert candidate(n = 999,delay = 50,forget = 400) == 112339611\n    assert candidate(n = 950,delay = 300,forget = 600) == 81225\n    assert candidate(n = 750,delay = 200,forget = 600) == 635625\n    assert candidate(n = 900,delay = 200,forget = 500) == 9051525\n    assert candidate(n = 600,delay = 125,forget = 500) == 6406900\n    assert candidate(n = 800,delay = 200,forget = 300) == 843250\n    assert candidate(n = 550,delay = 110,forget = 440) == 8292625\n    assert candidate(n = 700,delay = 150,forget = 450) == 7127075\n    assert candidate(n = 500,delay = 5,forget = 100) == 121345145\n    assert candidate(n = 750,delay = 120,forget = 450) == 913950185\n    assert candidate(n = 300,delay = 60,forget = 280) == 907415\n    assert candidate(n = 500,delay = 150,forget = 400) == 42450\n    assert candidate(n = 600,delay = 50,forget = 550) == 979826832\n    assert candidate(n = 750,delay = 125,forget = 550) == 450909175\n    assert candidate(n = 550,delay = 70,forget = 400) == 326052608\n    assert candidate(n = 800,delay = 400,forget = 750) == 350\n    assert candidate(n = 120,delay = 20,forget = 100) == 207054\n    assert candidate(n = 400,delay = 30,forget = 150) == 689207212\n    assert candidate(n = 800,delay = 100,forget = 600) == 153808266\n    assert candidate(n = 600,delay = 200,forget = 300) == 10000\n    assert candidate(n = 900,delay = 300,forget = 600) == 45450\n    assert candidate(n = 950,delay = 150,forget = 850) == 488545869\n    assert candidate(n = 600,delay = 250,forget = 400) == 5200\n    assert candidate(n = 650,delay = 130,forget = 520) == 15497300\n    assert candidate(n = 700,delay = 350,forget = 560) == 210\n    assert candidate(n = 950,delay = 140,forget = 650) == 285835661\n    assert candidate(n = 850,delay = 300,forget = 500) == 28975\n    assert candidate(n = 650,delay = 90,forget = 500) == 926898505\n    assert candidate(n = 550,delay = 250,forget = 450) == 1475\n    assert candidate(n = 800,delay = 200,forget = 500) == 1423700\n    assert candidate(n = 750,delay = 250,forget = 550) == 31675\n    assert candidate(n = 550,delay = 80,forget = 450) == 2109288\n    assert candidate(n = 500,delay = 200,forget = 400) == 5250\n    assert candidate(n = 1000,delay = 50,forget = 900) == 770071855\n    assert candidate(n = 750,delay = 120,forget = 500) == 914080410\n    assert candidate(n = 600,delay = 150,forget = 450) == 619250\n    assert candidate(n = 999,delay = 300,forget = 750) == 246900\n    assert candidate(n = 1000,delay = 50,forget = 950) == 770074505\n    assert candidate(n = 950,delay = 190,forget = 760) == 65412725\n    assert candidate(n = 1000,delay = 10,forget = 500) == 104566774\n    assert candidate(n = 600,delay = 120,forget = 480) == 11476850\n    assert candidate(n = 1000,delay = 400,forget = 700) == 20400\n    assert candidate(n = 900,delay = 100,forget = 800) == 892948851\n    assert candidate(n = 500,delay = 50,forget = 450) == 344465040\n    assert candidate(n = 200,delay = 40,forget = 150) == 219220\n    assert candidate(n = 300,delay = 50,forget = 250) == 8177885\n    assert candidate(n = 1000,delay = 500,forget = 900) == 400\n    assert candidate(n = 600,delay = 100,forget = 500) == 165273270\n    assert candidate(n = 750,delay = 200,forget = 500) == 632925\n    assert candidate(n = 850,delay = 130,forget = 550) == 523316449\n    assert candidate(n = 450,delay = 90,forget = 360) == 3944850\n    assert candidate(n = 1000,delay = 150,forget = 700) == 188312873\n    assert candidate(n = 1000,delay = 999,forget = 1000) == 2\n    assert candidate(n = 400,delay = 10,forget = 350) == 610381426\n    assert candidate(n = 800,delay = 150,forget = 350) == 77362035\n    assert candidate(n = 700,delay = 190,forget = 560) == 426390\n    assert candidate(n = 550,delay = 220,forget = 330) == 6215\n    assert candidate(n = 900,delay = 250,forget = 600) == 651750\n    assert candidate(n = 700,delay = 70,forget = 630) == 66046770\n    assert candidate(n = 950,delay = 400,forget = 850) == 11775\n    assert candidate(n = 750,delay = 150,forget = 600) == 26594875\n    assert candidate(n = 400,delay = 100,forget = 350) == 192050\n    assert candidate(n = 300,delay = 10,forget = 299) == 236977941\n    assert candidate(n = 800,delay = 200,forget = 600) == 1434000\n    assert candidate(n = 900,delay = 200,forget = 700) == 9092125\n    assert candidate(n = 700,delay = 100,forget = 500) == 766847687\n    assert candidate(n = 650,delay = 175,forget = 525) == 378875\n    assert candidate(n = 600,delay = 80,forget = 400) == 816019201\n    assert candidate(n = 1000,delay = 500,forget = 999) == 499\n    assert candidate(n = 300,delay = 100,forget = 200) == 5150\n", "comparison": "exact"}, "public_tests": ["6\n2\n4", "4\n1\n3"], "hints": ["Let dp[i][j] be the number of people who have known the secret for exactly j + 1 days, at day i.", "If j > 0, dp[i][j] = dp[i – 1][j – 1].", "dp[i][0] = sum(dp[i – 1][j]) for j in [delay – 1, forget – 2]."], "metadata": {"canonical_parameter_names": ["n", "delay", "forget"], "leetcode_dataset_entry_point": "Solution().peopleAwareOfSecret", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:55+00:00", "tests_total": 96, "tests_dropped": 0, "flags": [], "topic_tags": ["dynamic-programming", "queue", "simulation"]}, "language": "python", "interface": {"raw_signature": "def peopleAwareOfSecret(self, n: int, delay: int, forget: int) -> int:", "container": "Solution", "callable": "peopleAwareOfSecret", "parameters": [{"name": "n", "type": "int"}, {"name": "delay", "type": "int"}, {"name": "forget", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2328, "task_id": "number-of-increasing-paths-in-a-grid", "difficulty": "Hard", "problem_description": "You are given an m x n integer matrix grid, where you can move from a cell to any adjacent cell in all 4 directions.\n\nReturn the number of strictly increasing paths in the grid such that you can start from any cell and end at any cell. Since the answer may be very large, return it modulo 10^9 + 7.\n\nTwo paths are considered different if they do not have exactly the same sequence of visited cells.\n\nExample 1:\n\nInput: grid = [[1,1],[3,4]]\nOutput: 8\nExplanation: The strictly increasing paths are:\n- Paths with length 1: [1], [1], [3], [4].\n- Paths with length 2: [1 -> 3], [1 -> 4], [3 -> 4].\n- Paths with length 3: [1 -> 3 -> 4].\nThe total number of paths is 4 + 3 + 1 = 8.\n\nExample 2:\n\nInput: grid = [[1],[2]]\nOutput: 3\nExplanation: The strictly increasing paths are:\n- Paths with length 1: [1], [2].\n- Paths with length 2: [1 -> 2].\nThe total number of paths is 2 + 1 = 3.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 1000\n- 1 <= m * n <= 10^5\n- 1 <= grid[i][j] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 9\n    assert candidate(grid = [[4, 3, 2, 1], [3, 2, 1, 4], [2, 1, 4, 3], [1, 4, 3, 2]]) == 64\n    assert candidate(grid = [[4, 3, 2, 1], [5, 6, 7, 8]]) == 50\n    assert candidate(grid = [[1]]) == 1\n    assert candidate(grid = [[1], [2]]) == 3\n    assert candidate(grid = [[9, 9, 4], [6, 6, 8], [2, 1, 1]]) == 23\n    assert candidate(grid = [[9, 9, 9], [9, 9, 9], [9, 9, 9]]) == 9\n    assert candidate(grid = [[10]]) == 1\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 53\n    assert candidate(grid = [[10, 20, 30], [15, 25, 35], [12, 22, 32]]) == 38\n    assert candidate(grid = [[1, 1], [3, 4]]) == 8\n    assert candidate(grid = [[3, 1, 4, 2], [1, 6, 5, 3], [2, 7, 4, 8]]) == 49\n    assert candidate(grid = [[10, 10, 10, 10], [10, 1, 2, 10], [10, 3, 4, 10], [10, 10, 10, 10]]) == 42\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 185\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 4312\n    assert candidate(grid = [[1, 3, 1], [1, 5, 1], [4, 2, 4]]) == 21\n    assert candidate(grid = [[1, 1, 1], [1, 2, 1], [1, 1, 1]]) == 13\n    assert candidate(grid = [[1, 2, 3], [6, 5, 4], [7, 8, 9]]) == 77\n    assert candidate(grid = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 192\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 5, 4, 3, 1], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 363\n    assert candidate(grid = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [10, 11, 12]]) == 172\n    assert candidate(grid = [[3, 1, 4, 1, 5], [9, 2, 6, 5, 3], [5, 8, 9, 7, 9], [3, 2, 3, 8, 6], [3, 7, 4, 9, 8]]) == 117\n    assert candidate(grid = [[10, 9, 8, 7, 6], [9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2]]) == 887\n    assert candidate(grid = [[10, 9, 8, 7, 6], [9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2], [5, 4, 3, 2, 1]]) == 1673\n    assert candidate(grid = [[1, 10, 9, 14, 13], [2, 3, 8, 12, 15], [5, 6, 7, 11, 16], [17, 18, 19, 20, 21]]) == 328\n    assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 65\n    assert candidate(grid = [[50, 50, 50, 50, 50], [50, 50, 50, 50, 50], [50, 50, 50, 50, 50], [50, 50, 50, 50, 50], [50, 50, 50, 50, 50]]) == 25\n    assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 431\n    assert candidate(grid = [[10, 9, 8, 7, 6], [11, 10, 9, 8, 7], [12, 11, 10, 9, 8], [13, 12, 11, 10, 9], [14, 13, 12, 11, 10]]) == 887\n    assert candidate(grid = [[10, 1, 10, 1, 10], [1, 10, 1, 10, 1], [10, 1, 10, 1, 10], [1, 10, 1, 10, 1], [10, 1, 10, 1, 10]]) == 65\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 12309\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 880\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == 105\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 1540\n    assert candidate(grid = [[1, 2, 3, 2, 1], [2, 3, 4, 3, 2], [3, 4, 5, 4, 3], [2, 3, 4, 3, 2], [1, 2, 3, 2, 1]]) == 189\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 550\n    assert candidate(grid = [[1, 10, 100], [10, 100, 1000], [100, 1000, 10000]]) == 53\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == 45\n    assert candidate(grid = [[5, 3, 2], [1, 4, 6], [7, 8, 9]]) == 41\n    assert candidate(grid = [[3, 1, 4, 1, 5], [9, 2, 6, 5, 3], [5, 8, 9, 7, 9], [3, 2, 3, 8, 4], [2, 7, 1, 8, 2]]) == 112\n    assert candidate(grid = [[1, 10, 1], [2, 11, 2], [3, 12, 3], [4, 13, 4], [5, 14, 5], [6, 15, 6], [7, 16, 7], [8, 17, 8], [9, 18, 9]]) == 465\n    assert candidate(grid = [[10, 10, 10, 10], [10, 1, 1, 10], [10, 1, 1, 10], [10, 10, 10, 10]]) == 24\n    assert candidate(grid = [[5, 5, 5, 5, 5], [5, 1, 2, 1, 5], [5, 3, 4, 3, 5], [5, 5, 5, 5, 5]]) == 54\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 55\n    assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 887\n    assert candidate(grid = [[1, 3, 2, 1], [1, 3, 2, 1], [1, 3, 2, 1]]) == 24\n    assert candidate(grid = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [12, 11, 10], [13, 14, 15]]) == 476\n    assert candidate(grid = [[25, 24, 23, 22, 21], [20, 19, 18, 17, 16], [15, 14, 13, 12, 11], [10, 9, 8, 7, 6], [5, 4, 3, 2, 1]]) == 887\n    assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16]]) == 1276\n    assert candidate(grid = [[5, 5, 5, 5], [5, 1, 2, 5], [5, 4, 3, 5], [5, 5, 5, 5]]) == 45\n    assert candidate(grid = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [4, 5, 6]]) == 93\n    assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]) == 887\n    assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == 226\n    assert candidate(grid = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 330\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 25\n    assert candidate(grid = [[1, 2], [4, 3], [2, 1], [3, 4]]) == 26\n    assert candidate(grid = [[1, 3, 1, 3, 1], [3, 1, 3, 1, 3], [1, 3, 1, 3, 1], [3, 1, 3, 1, 3], [1, 3, 1, 3, 1]]) == 65\n    assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, 5], [3, 2, 1, 5, 4], [2, 1, 5, 4, 3], [1, 5, 4, 3, 2]]) == 149\n    assert candidate(grid = [[10, 9, 8, 7], [9, 8, 7, 6], [8, 7, 6, 5], [7, 6, 5, 4]]) == 226\n    assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 8, 12, 16, 20], [5, 10, 15, 20, 25]]) == 887\n    assert candidate(grid = [[9, 8, 7, 6], [8, 7, 6, 5], [7, 6, 5, 4], [6, 5, 4, 3], [5, 4, 3, 2], [4, 3, 2, 1]]) == 756\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 385\n    assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [2, 4, 6, 8, 10]]) == 133\n    assert candidate(grid = [[1, 10, 100, 1000, 10000], [1, 10, 100, 1000, 10000], [1, 10, 100, 1000, 10000], [1, 10, 100, 1000, 10000]]) == 60\n    assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]]) == 887\n    assert candidate(grid = [[1, 1000, 1, 1000, 1], [1000, 1, 1000, 1, 1000], [1, 1000, 1, 1000, 1], [1000, 1, 1000, 1, 1000], [1, 1000, 1, 1000, 1]]) == 65\n    assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 50\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]]) == 12309\n    assert candidate(grid = [[10, 11, 16, 15, 4, 1, 5], [7, 6, 3, 16, 15, 10, 11], [14, 13, 12, 5, 18, 19, 20], [1, 2, 3, 4, 21, 22, 23], [24, 25, 26, 27, 28, 29, 30]]) == 508\n    assert candidate(grid = [[1, 2, 3, 4], [4, 3, 2, 1], [5, 6, 7, 8], [8, 7, 6, 5]]) == 139\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 24\n    assert candidate(grid = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41]]) == 481\n    assert candidate(grid = [[5, 1, 4], [1, 5, 5], [4, 5, 5]]) == 19\n    assert candidate(grid = [[1, 3, 1], [1, 5, 1], [1, 3, 1]]) == 21\n    assert candidate(grid = [[1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]]) == 135\n    assert candidate(grid = [[10], [9], [8], [7], [6], [5], [4], [3], [2], [1]]) == 55\n    assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [1, 2, 3, 4, 5]]) == 133\n    assert candidate(grid = [[10, 9, 8, 7, 6], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == 283\n    assert candidate(grid = [[3, 2, 1], [6, 5, 4], [9, 8, 7]]) == 53\n    assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]]) == 4560\n    assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 495\n", "comparison": "exact"}, "public_tests": ["[[1,1],[3,4]]", "[[1],[2]]"], "hints": ["How can you calculate the number of increasing paths that start from a cell (i, j)? Think about dynamic programming.", "Define f(i, j) as the number of increasing paths starting from cell (i, j). Try to find how f(i, j) is related to each of f(i, j+1), f(i, j-1), f(i+1, j) and f(i-1, j)."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().countPaths", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:48:57+00:00", "tests_total": 88, "tests_dropped": 7, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "depth-first-search", "breadth-first-search", "graph", "topological-sort", "memoization", "matrix"]}, "language": "python", "interface": {"raw_signature": "def countPaths(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "countPaths", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2332, "task_id": "the-latest-time-to-catch-a-bus", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array buses of length n, where buses[i] represents the departure time of the i^th bus. You are also given a 0-indexed integer array passengers of length m, where passengers[j] represents the arrival time of the j^th passenger. All bus departure times are unique. All passenger arrival times are unique.\n\nYou are given an integer capacity, which represents the maximum number of passengers that can get on each bus.\n\nWhen a passenger arrives, they will wait in line for the next available bus. You can get on a bus that departs at x minutes if you arrive at y minutes where y <= x, and the bus is not full. Passengers with the earliest arrival times get on the bus first.\n\nMore formally when a bus arrives, either:\n\n- If capacity or fewer passengers are waiting for a bus, they will all get on the bus, or\n- The capacity passengers with the earliest arrival times will get on the bus.\n\nReturn the latest time you may arrive at the bus station to catch a bus. You cannot arrive at the same time as another passenger.\n\nNote: The arrays buses and passengers are not necessarily sorted.\n\nExample 1:\n\nInput: buses = [10,20], passengers = [2,17,18,19], capacity = 2\nOutput: 16\nExplanation: Suppose you arrive at time 16.\nAt time 10, the first bus departs with the 0^th passenger.\nAt time 20, the second bus departs with you and the 1^st passenger.\nNote that you may not arrive at the same time as another passenger, which is why you must arrive before the 1^st passenger to catch the bus.\n\nExample 2:\n\nInput: buses = [20,30,10], passengers = [19,13,26,4,25,11,21], capacity = 2\nOutput: 20\nExplanation: Suppose you arrive at time 20.\nAt time 10, the first bus departs with the 3^rd passenger.\nAt time 20, the second bus departs with the 5^th and 1^st passengers.\nAt time 30, the third bus departs with the 0^th passenger and you.\nNotice if you had arrived any later, then the 6^th passenger would have taken your seat on the third bus.\n\nConstraints:\n\n- n == buses.length\n- m == passengers.length\n- 1 <= n, m, capacity <= 10^5\n- 2 <= buses[i], passengers[i] <= 10^9\n- Each element in buses is unique.\n- Each element in passengers is unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(buses = [50, 60, 70],passengers = [5, 10, 20, 30, 40],capacity = 5) == 70\n    assert candidate(buses = [3, 5, 7],passengers = [2, 4, 6, 8],capacity = 1) == 5\n    assert candidate(buses = [10, 20],passengers = [2, 17, 18, 19],capacity = 2) == 16\n    assert candidate(buses = [10, 20, 30, 40],passengers = [5, 10, 15, 20, 25, 30, 35, 40],capacity = 1) == 19\n    assert candidate(buses = [100, 200],passengers = [99, 101, 102, 103],capacity = 2) == 100\n    assert candidate(buses = [100],passengers = [99],capacity = 1) == 98\n    assert candidate(buses = [30],passengers = [19, 13, 26, 4, 25, 11, 21],capacity = 3) == 12\n    assert candidate(buses = [100],passengers = [10],capacity = 1) == 9\n    assert candidate(buses = [20, 30, 10],passengers = [19, 13, 26, 4, 25, 11, 21],capacity = 2) == 20\n    assert candidate(buses = [10, 20, 30, 40, 50],passengers = [10, 20, 30, 40, 50],capacity = 1) == 49\n    assert candidate(buses = [100, 200, 300, 400, 500],passengers = [50, 150, 250, 350, 450, 50, 150, 250, 350, 450, 50, 150, 250, 350, 450, 50, 150, 250, 350, 450, 50, 150, 250, 350, 450, 50, 150, 250, 350, 450, 50, 150, 250, 350, 450],capacity = 5) == 349\n    assert candidate(buses = [5, 15, 25, 35, 45],passengers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44],capacity = 4) == 35\n    assert candidate(buses = [10, 20, 30, 40, 50],passengers = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],capacity = 2) == 50\n    assert candidate(buses = [15, 25, 35, 45, 55],passengers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],capacity = 5) == 55\n    assert candidate(buses = [5, 12, 19, 26, 33],passengers = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],capacity = 2) == 26\n    assert candidate(buses = [10, 20, 30, 40, 50],passengers = [9, 19, 29, 39, 49],capacity = 1) == 48\n    assert candidate(buses = [100, 200, 300, 400, 500],passengers = [50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500],capacity = 3) == 399\n    assert candidate(buses = [15, 30, 45, 60, 75],passengers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],capacity = 3) == 75\n    assert candidate(buses = [5, 10, 20, 30, 40],passengers = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],capacity = 2) == 26\n    assert candidate(buses = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],passengers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100],capacity = 1) == 19\n    assert candidate(buses = [5, 15, 25, 35, 45],passengers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44],capacity = 5) == 43\n    assert candidate(buses = [100, 200, 300],passengers = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],capacity = 5) == 189\n    assert candidate(buses = [100, 200, 300],passengers = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],capacity = 2) == 299\n    assert candidate(buses = [12, 24, 36, 48, 60],passengers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],capacity = 5) == 49\n    assert candidate(buses = [30, 60, 90, 120, 150],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],capacity = 4) == 99\n    assert candidate(buses = [100, 200, 300, 400, 500],passengers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],capacity = 10) == 500\n    assert candidate(buses = [20, 30, 40, 50, 60],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],capacity = 2) == 49\n    assert candidate(buses = [15, 30, 45, 60, 75],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125],capacity = 5) == 74\n    assert candidate(buses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125],capacity = 1) == 49\n    assert candidate(buses = [5, 15, 25, 35, 45, 55],passengers = [4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54],capacity = 1) == 28\n    assert candidate(buses = [100, 200, 300],passengers = [50, 99, 101, 149, 151, 299, 301],capacity = 2) == 298\n    assert candidate(buses = [20, 50, 70, 100],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],capacity = 5) == 94\n    assert candidate(buses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],passengers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104],capacity = 3) == 63\n    assert candidate(buses = [10, 20, 30, 40, 50],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],capacity = 2) == 49\n    assert candidate(buses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],passengers = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99],capacity = 1) == 98\n    assert candidate(buses = [5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],passengers = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, 150],capacity = 3) == 134\n    assert candidate(buses = [100, 200, 300, 400, 500],passengers = [50, 150, 250, 350, 450],capacity = 1) == 449\n    assert candidate(buses = [100, 200, 300, 400, 500],passengers = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310],capacity = 10) == 500\n    assert candidate(buses = [100, 120, 140, 160, 180],passengers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],capacity = 10) == 179\n    assert candidate(buses = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],passengers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100],capacity = 3) == 99\n    assert candidate(buses = [5, 10, 20, 25],passengers = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],capacity = 3) == 1\n    assert candidate(buses = [100, 200, 300],passengers = [50, 150, 250, 350],capacity = 3) == 300\n    assert candidate(buses = [5, 15, 25, 35, 45],passengers = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60],capacity = 2) == 35\n    assert candidate(buses = [20, 30, 40, 50, 60],passengers = [5, 15, 25, 35, 45, 55, 65],capacity = 2) == 60\n    assert candidate(buses = [15, 30, 45, 60],passengers = [3, 4, 6, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 47, 49, 51, 53, 57, 59],capacity = 5) == 38\n    assert candidate(buses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],capacity = 2) == 99\n    assert candidate(buses = [5, 15, 25, 35, 45],passengers = [2, 5, 7, 10, 15, 18, 20, 22, 25, 30, 32, 35, 40, 42, 45],capacity = 3) == 41\n    assert candidate(buses = [10, 20, 30, 40, 50],passengers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],capacity = 3) == 29\n    assert candidate(buses = [10, 20, 30, 40, 50],passengers = [5, 15, 25, 35, 45, 55],capacity = 1) == 44\n    assert candidate(buses = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],passengers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],capacity = 1) == 21\n    assert candidate(buses = [10, 20, 30, 40, 50],passengers = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99],capacity = 1) == 44\n    assert candidate(buses = [1000, 2000, 3000],passengers = [500, 1500, 2500, 3500, 4500],capacity = 2) == 3000\n    assert candidate(buses = [10, 20, 30, 40, 50],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacity = 2) == 49\n    assert candidate(buses = [10, 20, 30, 40, 50],passengers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacity = 1) == 24\n", "comparison": "exact"}, "public_tests": ["[10,20]\n[2,17,18,19]\n2", "[20,30,10]\n[19,13,26,4,25,11,21]\n2"], "hints": ["Sort the buses and passengers arrays.", "Use 2 pointers to traverse buses and passengers with a simulation of passengers getting on a particular bus."], "metadata": {"canonical_parameter_names": ["buses", "passengers", "capacity"], "leetcode_dataset_entry_point": "Solution().latestTimeCatchTheBus", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:04+00:00", "tests_total": 93, "tests_dropped": 39, "flags": [], "topic_tags": ["array", "two-pointers", "binary-search", "sorting"]}, "language": "python", "interface": {"raw_signature": "def latestTimeCatchTheBus(self, buses: list[int], passengers: list[int], capacity: int) -> int:", "container": "Solution", "callable": "latestTimeCatchTheBus", "parameters": [{"name": "buses", "type": "list[int]"}, {"name": "passengers", "type": "list[int]"}, {"name": "capacity", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2333, "task_id": "minimum-sum-of-squared-difference", "difficulty": "Medium", "problem_description": "You are given two positive 0-indexed integer arrays nums1 and nums2, both of length n.\n\nThe sum of squared difference of arrays nums1 and nums2 is defined as the sum of (nums1[i] - nums2[i])^2 for each 0 <= i < n.\n\nYou are also given two positive integers k1 and k2. You can modify any of the elements of nums1 by +1 or -1 at most k1 times. Similarly, you can modify any of the elements of nums2 by +1 or -1 at most k2 times.\n\nReturn the minimum sum of squared difference after modifying array nums1 at most k1 times and modifying array nums2 at most k2 times.\n\nNote: You are allowed to modify the array elements to become negative integers.\n\nExample 1:\n\nInput: nums1 = [1,2,3,4], nums2 = [2,10,20,19], k1 = 0, k2 = 0\nOutput: 579\nExplanation: The elements in nums1 and nums2 cannot be modified because k1 = 0 and k2 = 0.\nThe sum of square difference will be: (1 - 2)^2+ (2 - 10)^2+ (3 - 20)^2+ (4 - 19)^2 = 579.\n\nExample 2:\n\nInput: nums1 = [1,4,10,12], nums2 = [5,8,6,9], k1 = 1, k2 = 1\nOutput: 43\nExplanation: One way to obtain the minimum sum of square difference is:\n- Increase nums1[0] once.\n- Increase nums2[2] once.\nThe minimum of the sum of square difference will be:\n(2 - 5)^2+ (4 - 8)^2+ (10 - 7)^2+ (12 - 9)^2 = 43.\nNote that, there are other ways to obtain the minimum of the sum of square difference, but there is no way to obtain a sum smaller than 43.\n\nConstraints:\n\n- n == nums1.length == nums2.length\n- 1 <= n <= 10^5\n- 0 <= nums1[i], nums2[i] <= 10^5\n- 0 <= k1, k2 <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums1 = [5, 5, 5, 5],nums2 = [5, 5, 5, 5],k1 = 100,k2 = 100) == 0\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45],k1 = 50,k2 = 50) == 0\n    assert candidate(nums1 = [100000, 100000],nums2 = [0, 0],k1 = 100000,k2 = 100000) == 0\n    assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],k1 = 1,k2 = 1) == 3\n    assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1],k1 = 3,k2 = 3) == 0\n    assert candidate(nums1 = [0, 0, 0, 0],nums2 = [100, 100, 100, 100],k1 = 200,k2 = 200) == 0\n    assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1],k1 = 10,k2 = 10) == 0\n    assert candidate(nums1 = [1, 2, 3, 4],nums2 = [2, 10, 20, 19],k1 = 0,k2 = 0) == 579\n    assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1],k1 = 2,k2 = 2) == 0\n    assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1],k1 = 4,k2 = 4) == 16\n    assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [5, 5, 5, 5, 5],k1 = 5,k2 = 5) == 20\n    assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0],k1 = 5,k2 = 5) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],k1 = 5,k2 = 5) == 2\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k1 = 50,k2 = 50) == 0\n    assert candidate(nums1 = [0, 0, 0, 0],nums2 = [10, 10, 10, 10],k1 = 20,k2 = 20) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],k1 = 3,k2 = 3) == 10\n    assert candidate(nums1 = [0, 0, 0],nums2 = [100, 100, 100],k1 = 150,k2 = 150) == 0\n    assert candidate(nums1 = [10, 20, 30],nums2 = [1, 2, 3],k1 = 25,k2 = 25) == 6\n    assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1],k1 = 5,k2 = 5) == 0\n    assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 1, 1, 1],k1 = 2,k2 = 2) == 0\n    assert candidate(nums1 = [1, 1, 1, 1],nums2 = [10, 10, 10, 10],k1 = 10,k2 = 10) == 64\n    assert candidate(nums1 = [3, 5, 7, 9],nums2 = [4, 6, 8, 10],k1 = 3,k2 = 3) == 0\n    assert candidate(nums1 = [100000, 100000, 100000],nums2 = [0, 0, 0],k1 = 300000,k2 = 300000) == 0\n    assert candidate(nums1 = [1, 4, 10, 12],nums2 = [5, 8, 6, 9],k1 = 1,k2 = 1) == 43\n    assert candidate(nums1 = [100000, 100000, 100000],nums2 = [0, 0, 0],k1 = 100000,k2 = 100000) == 3333333334\n    assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1],k1 = 10,k2 = 10) == 0\n    assert candidate(nums1 = [100000, 100000, 100000],nums2 = [0, 0, 0],k1 = 100000,k2 = 100000) == 3333333334\n    assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [5000, 4000, 3000, 2000, 1000],k1 = 2000,k2 = 2000) == 16000000\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55],k1 = 100,k2 = 100) == 0\n    assert candidate(nums1 = [100000, 90000, 80000, 70000],nums2 = [60000, 50000, 40000, 30000],k1 = 500000,k2 = 500000) == 0\n    assert candidate(nums1 = [100000, 50000, 25000, 10000],nums2 = [90000, 60000, 35000, 15000],k1 = 50000,k2 = 50000) == 0\n    assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],k1 = 1000000,k2 = 1000000) == 0\n    assert candidate(nums1 = [100000, 50000, 25000],nums2 = [0, 0, 0],k1 = 500000,k2 = 500000) == 0\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5],k1 = 50,k2 = 50) == 245\n    assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k1 = 1000,k2 = 1000) == 1298535\n    assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [100, 100, 100, 100, 100],k1 = 300,k2 = 300) == 0\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k1 = 100,k2 = 100) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],k1 = 1000000000,k2 = 1000000000) == 0\n    assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9],k1 = 10,k2 = 10) == 52\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k1 = 50,k2 = 50) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k1 = 0,k2 = 0) == 0\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5],k1 = 100,k2 = 100) == 0\n    assert candidate(nums1 = [50000, 50000, 50000],nums2 = [0, 0, 0],k1 = 150000,k2 = 150000) == 0\n    assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [500, 1000, 1500, 2000, 2500],k1 = 1000,k2 = 1000) == 6583334\n    assert candidate(nums1 = [100, 200, 300],nums2 = [300, 200, 100],k1 = 150,k2 = 150) == 5000\n    assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [500, 1500, 2500, 3500, 4500],k1 = 100000,k2 = 100000) == 0\n    assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k1 = 150,k2 = 150) == 4252\n    assert candidate(nums1 = [5, 10, 15, 20, 25, 30],nums2 = [3, 6, 9, 12, 15, 18],k1 = 20,k2 = 25) == 0\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k1 = 100,k2 = 100) == 0\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45],k1 = 10,k2 = 10) == 5\n    assert candidate(nums1 = [100, 200, 300, 400],nums2 = [150, 250, 350, 450],k1 = 100,k2 = 100) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],k1 = 10,k2 = 10) == 0\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k1 = 50,k2 = 50) == 0\n    assert candidate(nums1 = [100, 200, 300, 400],nums2 = [105, 205, 305, 405],k1 = 10,k2 = 10) == 0\n    assert candidate(nums1 = [50, 50, 50, 50, 50],nums2 = [1, 2, 3, 4, 5],k1 = 200,k2 = 200) == 0\n    assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k1 = 5,k2 = 5) == 810\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k1 = 100,k2 = 100) == 0\n    assert candidate(nums1 = [100000, 0, 50000],nums2 = [0, 100000, 50000],k1 = 100000,k2 = 100000) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k1 = 100,k2 = 100) == 12728\n    assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5],k1 = 20,k2 = 20) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k1 = 0,k2 = 0) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k1 = 0,k2 = 0) == 330\n    assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k1 = 500,k2 = 500) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],k1 = 10,k2 = 10) == 0\n    assert candidate(nums1 = [50, 50, 50, 50, 50],nums2 = [0, 0, 0, 0, 0],k1 = 50,k2 = 50) == 4500\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k1 = 100,k2 = 100) == 0\n    assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k1 = 20,k2 = 20) == 10\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k1 = 100,k2 = 100) == 0\n    assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k1 = 1000,k2 = 1000) == 0\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [100, 100, 100, 100, 100],k1 = 100,k2 = 100) == 175000\n    assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000],nums2 = [50000, 40000, 30000, 20000, 10000],k1 = 1000000,k2 = 1000000) == 0\n    assert candidate(nums1 = [100, 100, 100, 100, 100, 100],nums2 = [1, 1, 1, 1, 1, 1],k1 = 300,k2 = 300) == 0\n    assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [500, 1500, 2500, 3500, 4500],k1 = 2000,k2 = 2000) == 0\n    assert candidate(nums1 = [10, 20, 30],nums2 = [30, 20, 10],k1 = 20,k2 = 20) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k1 = 50,k2 = 50) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k1 = 50,k2 = 50) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 1, 1, 1, 1],k1 = 10,k2 = 10) == 0\n    assert candidate(nums1 = [50000, 40000, 30000, 20000, 10000],nums2 = [50000, 40000, 30000, 20000, 10000],k1 = 0,k2 = 0) == 0\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 2, 3, 4, 5],k1 = 1000,k2 = 1000) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [100000, 100000, 100000, 100000, 100000],k1 = 50000,k2 = 50000) == 31999200005\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55],k1 = 15,k2 = 20) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k1 = 100,k2 = 100) == 0\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [10, 20, 30, 40, 50],k1 = 10000,k2 = 10000) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k1 = 10,k2 = 10) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k1 = 0,k2 = 0) == 330\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k1 = 500,k2 = 500) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k1 = 20,k2 = 20) == 10\n    assert candidate(nums1 = [50, 50, 50, 50, 50],nums2 = [100, 100, 100, 100, 100],k1 = 150,k2 = 150) == 0\n    assert candidate(nums1 = [100000, 90000, 80000, 70000],nums2 = [60000, 50000, 40000, 30000],k1 = 1000000,k2 = 1000000) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k1 = 100,k2 = 100) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k1 = 1000,k2 = 1000) == 0\n    assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k1 = 5,k2 = 5) == 160\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [90, 190, 290, 390, 490],k1 = 5,k2 = 5) == 320\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k1 = 500,k2 = 500) == 0\n    assert candidate(nums1 = [100000, 90000, 80000, 70000, 60000],nums2 = [1, 2, 3, 4, 5],k1 = 1000000,k2 = 1000000) == 0\n    assert candidate(nums1 = [100000, 90000, 80000, 70000, 60000],nums2 = [50000, 40000, 30000, 20000, 10000],k1 = 1000000,k2 = 1000000) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k1 = 20,k2 = 20) == 10\n    assert candidate(nums1 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k1 = 100,k2 = 100) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k1 = 100,k2 = 100) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k1 = 50,k2 = 50) == 0\n    assert candidate(nums1 = [100, 200, 300],nums2 = [1, 1, 1],k1 = 500,k2 = 500) == 0\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [50, 150, 250, 350, 450],k1 = 1000,k2 = 1000) == 0\n    assert candidate(nums1 = [100000, 100000, 100000],nums2 = [0, 0, 0],k1 = 150000,k2 = 150000) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k1 = 50,k2 = 50) == 0\n    assert candidate(nums1 = [100000, 100000, 100000, 100000, 100000],nums2 = [0, 0, 0, 0, 0],k1 = 1000000,k2 = 1000000) == 0\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45],k1 = 25,k2 = 25) == 0\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [100, 90, 80, 70, 60],k1 = 500,k2 = 500) == 0\n    assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k1 = 500,k2 = 500) == 0\n    assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5],k1 = 100,k2 = 100) == 0\n    assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [3, 8, 13, 18, 23],k1 = 25,k2 = 25) == 0\n    assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000],nums2 = [1, 2, 3, 4, 5],k1 = 1000000,k2 = 1000000) == 0\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100],k1 = 1000,k2 = 1000) == 0\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 2, 3, 4, 5],k1 = 1000,k2 = 1000) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k1 = 1500000,k2 = 1500000) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [10, 20, 30, 40, 50],k1 = 250,k2 = 250) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k1 = 1000,k2 = 1000) == 0\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]\n[2,10,20,19]\n0\n0", "[1,4,10,12]\n[5,8,6,9]\n1\n1"], "hints": ["There is no difference between the purpose of k1 and k2. Adding +1 to one element in nums1 is same as performing -1 to one element in nums2, and vice versa.", "Reduce the sum of squared difference greedily. One operation of k should use the index that has the current maximum difference.", "Binary search the maximum difference for the final result."], "metadata": {"canonical_parameter_names": ["nums1", "nums2", "k1", "k2"], "leetcode_dataset_entry_point": "Solution().minSumSquareDiff", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:07+00:00", "tests_total": 116, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "binary-search", "greedy", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def minSumSquareDiff(self, nums1: list[int], nums2: list[int], k1: int, k2: int) -> int:", "container": "Solution", "callable": "minSumSquareDiff", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}, {"name": "k1", "type": "int"}, {"name": "k2", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2334, "task_id": "subarray-with-elements-greater-than-varying-threshold", "difficulty": "Hard", "problem_description": "You are given an integer array nums and an integer threshold.\n\nFind any subarray of nums of length k such that every element in the subarray is greater than threshold / k.\n\nReturn the size of any such subarray. If there is no such subarray, return -1.\n\nA subarray is a contiguous non-empty sequence of elements within an array.\n\nExample 1:\n\nInput: nums = [1,3,4,3,1], threshold = 6\nOutput: 3\nExplanation: The subarray [3,4,3] has a size of 3, and every element is greater than 6 / 3 = 2.\nNote that this is the only valid subarray.\n\nExample 2:\n\nInput: nums = [6,5,6,5,8], threshold = 7\nOutput: 1\nExplanation: The subarray [8] has a size of 1, and 8 > 7 / 1 = 7. So 1 is returned.\nNote that the subarray [6,5] has a size of 2, and every element is greater than 7 / 2 = 3.5.\nSimilarly, the subarrays [6,5,6], [6,5,6,5], [6,5,6,5,8] also satisfy the given conditions.\nTherefore, 2, 3, 4, or 5 may also be returned.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i], threshold <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [10, 20, 30, 40, 50],threshold = 15) == 1\n    assert candidate(nums = [10, 10, 10, 10, 10],threshold = 1) == 1\n    assert candidate(nums = [5, 5, 5, 5, 5],threshold = 25) == -1\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 55) == -1\n    assert candidate(nums = [10, 20, 30, 40, 50],threshold = 100) == -1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],threshold = 5) == 2\n    assert candidate(nums = [2, 2, 2, 2, 2],threshold = 10) == -1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],threshold = 1) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5],threshold = 15) == -1\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 45) == -1\n    assert candidate(nums = [5, 4, 3, 2, 1],threshold = 10) == -1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 50) == -1\n    assert candidate(nums = [6, 5, 6, 5, 8],threshold = 7) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 30) == -1\n    assert candidate(nums = [1, 3, 4, 3, 1],threshold = 6) == 3\n    assert candidate(nums = [100, 200, 300, 400, 500],threshold = 1000) == -1\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],threshold = 20) == 21\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],threshold = 10) == 3\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],threshold = 10) == 11\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],threshold = 500) == -1\n    assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],threshold = 50) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 5) == 1\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],threshold = 225) == -1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],threshold = 45) == 1\n    assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9],threshold = 8) == 1\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10],threshold = 45) == -1\n    assert candidate(nums = [5, 10, 15, 20, 25],threshold = 100) == -1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],threshold = 1000) == -1\n    assert candidate(nums = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],threshold = 1285) == -1\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],threshold = 100) == -1\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 95) == -1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],threshold = 1000) == -1\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],threshold = 5) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],threshold = 1) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 1) == 1\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 20) == 3\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],threshold = 1000000000) == 2\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],threshold = 100) == -1\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],threshold = 15) == 4\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],threshold = 1) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 55) == -1\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 50) == -1\n    assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],threshold = 20) == -1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],threshold = 20) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],threshold = 120) == -1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],threshold = 1000) == -1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],threshold = 450) == -1\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 25) == -1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],threshold = 190) == -1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 25) == 4\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],threshold = 1) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],threshold = 1) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],threshold = 1950) == -1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],threshold = 1000000000) == -1\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 200) == -1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],threshold = 100) == -1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 45) == -1\n    assert candidate(nums = [1, 1000000000, 1, 1, 1, 1, 1, 1, 1, 1],threshold = 1000000000) == -1\n    assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1],threshold = 400) == -1\n    assert candidate(nums = [100, 200, 300, 400, 500],threshold = 1000) == -1\n    assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10],threshold = 18) == -1\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],threshold = 20) == 5\n    assert candidate(nums = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100],threshold = 250) == 4\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],threshold = 1000000000) == 2\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],threshold = 20) == 7\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],threshold = 10) == 4\n    assert candidate(nums = [5, 8, 7, 3, 9, 10, 2, 1, 6],threshold = 20) == -1\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],threshold = 500000000) == 1\n    assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],threshold = 50) == -1\n    assert candidate(nums = [5, 1, 4, 3, 9, 8, 10],threshold = 30) == -1\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 100) == -1\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 20) == 3\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 20) == 3\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],threshold = 450) == -1\n    assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],threshold = 25) == -1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 45) == -1\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6],threshold = 50) == -1\n    assert candidate(nums = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2],threshold = 100) == -1\n    assert candidate(nums = [1, 3, 2, 6, 5, 4, 7, 9, 8, 10],threshold = 15) == 3\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 25) == 4\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],threshold = 100) == -1\n    assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1],threshold = 10) == -1\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17, 16, 18, 17, 19, 18, 20],threshold = 210) == -1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],threshold = 20) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],threshold = 900) == -1\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],threshold = 5000) == -1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],threshold = 90) == 7\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],threshold = 100) == -1\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90],threshold = 500) == 6\n    assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],threshold = 10) == -1\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 20) == 3\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],threshold = 495) == -1\n    assert candidate(nums = [1, 3, 2, 4, 5, 3, 2, 1, 3, 4],threshold = 10) == 6\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],threshold = 10) == 11\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],threshold = 200) == -1\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],threshold = 100) == -1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],threshold = 50) == 4\n    assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7],threshold = 49) == -1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],threshold = 1285) == -1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],threshold = 550) == -1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],threshold = 240) == -1\n    assert candidate(nums = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],threshold = 900) == -1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],threshold = 5) == 2\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 90) == 7\n    assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1],threshold = 9) == 1\n    assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],threshold = 45) == -1\n    assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],threshold = 15) == -1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],threshold = 100) == -1\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],threshold = 550) == -1\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],threshold = 1000000000) == 2\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],threshold = 275) == -1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],threshold = 25) == 6\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 45) == -1\n", "comparison": "exact"}, "public_tests": ["[1,3,4,3,1]\n6", "[6,5,6,5,8]\n7"], "hints": ["For all elements to be greater than the threshold/length, the minimum element in the subarray must be greater than the threshold/length.", "For a given index, could you find the largest subarray such that the given index is the minimum element?", "Could you use a monotonic stack to get the next and previous smallest element for every index?"], "metadata": {"canonical_parameter_names": ["nums", "threshold"], "leetcode_dataset_entry_point": "Solution().validSubarraySize", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:10+00:00", "tests_total": 116, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "stack", "union-find", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def validSubarraySize(self, nums: list[int], threshold: int) -> int:", "container": "Solution", "callable": "validSubarraySize", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "threshold", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2335, "task_id": "minimum-amount-of-time-to-fill-cups", "difficulty": "Easy", "problem_description": "You have a water dispenser that can dispense cold, warm, and hot water. Every second, you can either fill up 2 cups with different types of water, or 1 cup of any type of water.\n\nYou are given a 0-indexed integer array amount of length 3 where amount[0], amount[1], and amount[2] denote the number of cold, warm, and hot water cups you need to fill respectively. Return the minimum number of seconds needed to fill up all the cups.\n\nExample 1:\n\nInput: amount = [1,4,2]\nOutput: 4\nExplanation: One way to fill up the cups is:\nSecond 1: Fill up a cold cup and a warm cup.\nSecond 2: Fill up a warm cup and a hot cup.\nSecond 3: Fill up a warm cup and a hot cup.\nSecond 4: Fill up a warm cup.\nIt can be proven that 4 is the minimum number of seconds needed.\n\nExample 2:\n\nInput: amount = [5,4,4]\nOutput: 7\nExplanation: One way to fill up the cups is:\nSecond 1: Fill up a cold cup, and a hot cup.\nSecond 2: Fill up a cold cup, and a warm cup.\nSecond 3: Fill up a cold cup, and a warm cup.\nSecond 4: Fill up a warm cup, and a hot cup.\nSecond 5: Fill up a cold cup, and a hot cup.\nSecond 6: Fill up a cold cup, and a warm cup.\nSecond 7: Fill up a hot cup.\n\nExample 3:\n\nInput: amount = [5,0,0]\nOutput: 5\nExplanation: Every second, we fill up a cold cup.\n\nConstraints:\n\n- amount.length == 3\n- 0 <= amount[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(amount = [33, 33, 34]) == 50\n    assert candidate(amount = [0, 0, 0]) == 0\n    assert candidate(amount = [99, 1, 1]) == 99\n    assert candidate(amount = [7, 7, 7]) == 11\n    assert candidate(amount = [10, 10, 10]) == 15\n    assert candidate(amount = [1, 2, 3]) == 3\n    assert candidate(amount = [100, 0, 0]) == 100\n    assert candidate(amount = [100, 100, 100]) == 150\n    assert candidate(amount = [0, 1, 2]) == 2\n    assert candidate(amount = [1, 4, 2]) == 4\n    assert candidate(amount = [5, 0, 0]) == 5\n    assert candidate(amount = [99, 99, 1]) == 100\n    assert candidate(amount = [0, 50, 50]) == 50\n    assert candidate(amount = [5, 4, 4]) == 7\n    assert candidate(amount = [98, 1, 1]) == 98\n    assert candidate(amount = [25, 0, 75]) == 75\n    assert candidate(amount = [42, 42, 41]) == 63\n    assert candidate(amount = [60, 20, 20]) == 60\n    assert candidate(amount = [10, 50, 25]) == 50\n    assert candidate(amount = [49, 49, 49]) == 74\n    assert candidate(amount = [1, 1, 0]) == 1\n    assert candidate(amount = [80, 10, 10]) == 80\n    assert candidate(amount = [1, 10, 10]) == 11\n    assert candidate(amount = [1, 1, 100]) == 100\n    assert candidate(amount = [10, 90, 0]) == 90\n    assert candidate(amount = [10, 80, 10]) == 80\n    assert candidate(amount = [0, 0, 100]) == 100\n    assert candidate(amount = [80, 10, 10]) == 80\n    assert candidate(amount = [33, 33, 34]) == 50\n    assert candidate(amount = [70, 70, 60]) == 100\n    assert candidate(amount = [50, 25, 25]) == 50\n    assert candidate(amount = [29, 29, 42]) == 50\n    assert candidate(amount = [50, 50, 49]) == 75\n    assert candidate(amount = [99, 2, 99]) == 100\n    assert candidate(amount = [50, 49, 51]) == 75\n    assert candidate(amount = [100, 1, 1]) == 100\n    assert candidate(amount = [80, 70, 60]) == 105\n    assert candidate(amount = [100, 50, 25]) == 100\n    assert candidate(amount = [1, 0, 1]) == 1\n    assert candidate(amount = [40, 30, 20]) == 45\n    assert candidate(amount = [1, 2, 97]) == 97\n    assert candidate(amount = [1, 1, 1]) == 2\n    assert candidate(amount = [49, 50, 1]) == 50\n    assert candidate(amount = [30, 20, 10]) == 30\n    assert candidate(amount = [100, 10, 10]) == 100\n    assert candidate(amount = [2, 99, 99]) == 100\n    assert candidate(amount = [1, 98, 1]) == 98\n    assert candidate(amount = [1, 0, 99]) == 99\n    assert candidate(amount = [80, 15, 5]) == 80\n    assert candidate(amount = [45, 55, 0]) == 55\n    assert candidate(amount = [100, 1, 1]) == 100\n    assert candidate(amount = [50, 50, 1]) == 51\n    assert candidate(amount = [25, 25, 25]) == 38\n    assert candidate(amount = [42, 29, 29]) == 50\n    assert candidate(amount = [100, 50, 1]) == 100\n    assert candidate(amount = [1, 90, 10]) == 90\n    assert candidate(amount = [1, 1, 1]) == 2\n    assert candidate(amount = [0, 75, 25]) == 75\n    assert candidate(amount = [55, 45, 5]) == 55\n    assert candidate(amount = [10, 1, 90]) == 90\n    assert candidate(amount = [100, 10, 0]) == 100\n    assert candidate(amount = [80, 10, 1]) == 80\n    assert candidate(amount = [48, 48, 48]) == 72\n    assert candidate(amount = [80, 50, 30]) == 80\n    assert candidate(amount = [90, 90, 1]) == 91\n    assert candidate(amount = [1, 50, 50]) == 51\n    assert candidate(amount = [55, 0, 45]) == 55\n    assert candidate(amount = [49, 2, 49]) == 50\n    assert candidate(amount = [45, 67, 23]) == 68\n    assert candidate(amount = [20, 20, 60]) == 60\n    assert candidate(amount = [100, 100, 99]) == 150\n    assert candidate(amount = [10, 10, 100]) == 100\n    assert candidate(amount = [50, 100, 50]) == 100\n    assert candidate(amount = [10, 15, 20]) == 23\n    assert candidate(amount = [0, 100, 100]) == 100\n    assert candidate(amount = [60, 40, 20]) == 60\n    assert candidate(amount = [0, 100, 0]) == 100\n    assert candidate(amount = [50, 51, 50]) == 76\n    assert candidate(amount = [33, 33, 33]) == 50\n    assert candidate(amount = [23, 47, 29]) == 50\n    assert candidate(amount = [51, 51, 51]) == 77\n    assert candidate(amount = [50, 1, 50]) == 51\n    assert candidate(amount = [25, 10, 50]) == 50\n    assert candidate(amount = [55, 55, 45]) == 78\n    assert candidate(amount = [0, 100, 10]) == 100\n    assert candidate(amount = [90, 10, 1]) == 90\n    assert candidate(amount = [33, 66, 0]) == 66\n    assert candidate(amount = [99, 1, 0]) == 99\n    assert candidate(amount = [50, 25, 10]) == 50\n    assert candidate(amount = [49, 50, 51]) == 75\n    assert candidate(amount = [60, 60, 61]) == 91\n    assert candidate(amount = [29, 42, 29]) == 50\n    assert candidate(amount = [50, 50, 50]) == 75\n    assert candidate(amount = [25, 25, 26]) == 38\n    assert candidate(amount = [34, 33, 34]) == 51\n    assert candidate(amount = [2, 49, 49]) == 50\n    assert candidate(amount = [25, 25, 25]) == 38\n    assert candidate(amount = [1, 1, 2]) == 2\n    assert candidate(amount = [1, 1, 99]) == 99\n    assert candidate(amount = [60, 40, 20]) == 60\n    assert candidate(amount = [60, 60, 60]) == 90\n    assert candidate(amount = [33, 33, 67]) == 67\n    assert candidate(amount = [10, 100, 10]) == 100\n    assert candidate(amount = [5, 0, 5]) == 5\n    assert candidate(amount = [1, 100, 1]) == 100\n    assert candidate(amount = [80, 15, 5]) == 80\n    assert candidate(amount = [99, 99, 99]) == 149\n    assert candidate(amount = [66, 33, 0]) == 66\n    assert candidate(amount = [2, 3, 4]) == 5\n    assert candidate(amount = [5, 15, 80]) == 80\n    assert candidate(amount = [30, 0, 20]) == 30\n    assert candidate(amount = [50, 25, 25]) == 50\n    assert candidate(amount = [47, 23, 29]) == 50\n    assert candidate(amount = [100, 99, 98]) == 149\n    assert candidate(amount = [90, 85, 80]) == 128\n    assert candidate(amount = [67, 33, 33]) == 67\n    assert candidate(amount = [98, 99, 1]) == 99\n    assert candidate(amount = [15, 80, 5]) == 80\n    assert candidate(amount = [10, 10, 80]) == 80\n    assert candidate(amount = [3, 2, 1]) == 3\n    assert candidate(amount = [23, 45, 67]) == 68\n    assert candidate(amount = [50, 50, 100]) == 100\n    assert candidate(amount = [90, 10, 90]) == 95\n    assert candidate(amount = [99, 98, 97]) == 147\n    assert candidate(amount = [1, 99, 1]) == 99\n    assert candidate(amount = [45, 55, 55]) == 78\n    assert candidate(amount = [75, 25, 0]) == 75\n    assert candidate(amount = [0, 0, 100]) == 100\n    assert candidate(amount = [1, 100, 1]) == 100\n    assert candidate(amount = [1, 2, 1]) == 2\n    assert candidate(amount = [70, 20, 10]) == 70\n    assert candidate(amount = [2, 2, 1]) == 3\n    assert candidate(amount = [95, 3, 2]) == 95\n    assert candidate(amount = [1, 2, 3]) == 3\n    assert candidate(amount = [0, 99, 0]) == 99\n    assert candidate(amount = [60, 40, 0]) == 60\n    assert candidate(amount = [10, 10, 10]) == 15\n    assert candidate(amount = [33, 34, 33]) == 50\n    assert candidate(amount = [50, 50, 5]) == 53\n    assert candidate(amount = [2, 1, 1]) == 2\n    assert candidate(amount = [2, 1, 2]) == 3\n    assert candidate(amount = [10, 90, 0]) == 90\n    assert candidate(amount = [66, 33, 3]) == 66\n    assert candidate(amount = [49, 49, 2]) == 50\n    assert candidate(amount = [67, 23, 45]) == 68\n    assert candidate(amount = [50, 49, 48]) == 74\n    assert candidate(amount = [55, 45, 55]) == 78\n    assert candidate(amount = [0, 55, 45]) == 55\n    assert candidate(amount = [100, 0, 0]) == 100\n    assert candidate(amount = [0, 1, 1]) == 1\n    assert candidate(amount = [1, 1, 100]) == 100\n    assert candidate(amount = [1, 2, 2]) == 3\n    assert candidate(amount = [50, 50, 0]) == 50\n    assert candidate(amount = [34, 33, 33]) == 50\n    assert candidate(amount = [0, 100, 0]) == 100\n    assert candidate(amount = [42, 41, 42]) == 63\n    assert candidate(amount = [100, 50, 50]) == 100\n    assert candidate(amount = [100, 50, 50]) == 100\n    assert candidate(amount = [10, 0, 100]) == 100\n    assert candidate(amount = [0, 99, 1]) == 99\n    assert candidate(amount = [99, 99, 2]) == 100\n    assert candidate(amount = [50, 0, 50]) == 50\n    assert candidate(amount = [41, 42, 42]) == 63\n    assert candidate(amount = [0, 5, 5]) == 5\n    assert candidate(amount = [1, 99, 98]) == 99\n    assert candidate(amount = [2, 2, 98]) == 98\n    assert candidate(amount = [1, 1, 98]) == 98\n    assert candidate(amount = [10, 10, 1]) == 11\n    assert candidate(amount = [1, 99, 99]) == 100\n    assert candidate(amount = [29, 47, 23]) == 50\n    assert candidate(amount = [33, 67, 33]) == 67\n    assert candidate(amount = [99, 98, 97]) == 147\n    assert candidate(amount = [10, 20, 30]) == 30\n    assert candidate(amount = [0, 50, 50]) == 50\n    assert candidate(amount = [99, 1, 0]) == 99\n    assert candidate(amount = [99, 1, 99]) == 100\n    assert candidate(amount = [10, 90, 10]) == 90\n", "comparison": "exact"}, "public_tests": ["[1,4,2]", "[5,4,4]", "[5,0,0]"], "hints": ["To minimize the amount of time needed, you want to fill up as many cups as possible in each second. This means that you want to maximize the number of seconds where you are filling up two cups.", "You always want to fill up the two types of water with the most unfilled cups."], "metadata": {"canonical_parameter_names": ["amount"], "leetcode_dataset_entry_point": "Solution().fillCups", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:12+00:00", "tests_total": 178, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "greedy", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def fillCups(self, amount: list[int]) -> int:", "container": "Solution", "callable": "fillCups", "parameters": [{"name": "amount", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2337, "task_id": "move-pieces-to-obtain-a-string", "difficulty": "Medium", "problem_description": "You are given two strings start and target, both of length n. Each string consists only of the characters 'L', 'R', and '_' where:\n\n- The characters 'L' and 'R' represent pieces, where a piece 'L' can move to the left only if there is a blank space directly to its left, and a piece 'R' can move to the right only if there is a blank space directly to its right.\n- The character '_' represents a blank space that can be occupied by any of the 'L' or 'R' pieces.\n\nReturn true if it is possible to obtain the string target by moving the pieces of the string start any number of times. Otherwise, return false.\n\nExample 1:\n\nInput: start = \"_L__R__R_\", target = \"L______RR\"\nOutput: true\nExplanation: We can obtain the string target from start by doing the following moves:\n- Move the first piece one step to the left, start becomes equal to \"L___R__R_\".\n- Move the last piece one step to the right, start becomes equal to \"L___R___R\".\n- Move the second piece three steps to the right, start becomes equal to \"L______RR\".\nSince it is possible to get the string target from start, we return true.\n\nExample 2:\n\nInput: start = \"R_L_\", target = \"__LR\"\nOutput: false\nExplanation: The 'R' piece in the string start can move one step to the right to obtain \"_RL_\".\nAfter that, no pieces can move anymore, so it is impossible to obtain the string target from start.\n\nExample 3:\n\nInput: start = \"_R\", target = \"R_\"\nOutput: false\nExplanation: The piece in the string start can move only to the right, so it is impossible to obtain the string target from start.\n\nConstraints:\n\n- n == start.length == target.length\n- 1 <= n <= 10^5\n- start and target consist of the characters 'L', 'R', and '_'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(start = \"_R\",target = \"R_\") == False\n    assert candidate(start = \"___\",target = \"___\") == True\n    assert candidate(start = \"LR\",target = \"LR\") == True\n    assert candidate(start = \"_LL_R\",target = \"LL__R\") == True\n    assert candidate(start = \"____\",target = \"____\") == True\n    assert candidate(start = \"L_R\",target = \"_LR\") == False\n    assert candidate(start = \"R__L\",target = \"L__R\") == False\n    assert candidate(start = \"L_L_R\",target = \"LL_R_\") == False\n    assert candidate(start = \"R_R\",target = \"_RR\") == True\n    assert candidate(start = \"_L__R__R_\",target = \"L______RR\") == True\n    assert candidate(start = \"L___R\",target = \"_L__R\") == False\n    assert candidate(start = \"LL_R\",target = \"R_L_\") == False\n    assert candidate(start = \"__L___\",target = \"L_____\") == True\n    assert candidate(start = \"LRRL\",target = \"LRRL\") == True\n    assert candidate(start = \"RL\",target = \"LR\") == False\n    assert candidate(start = \"R__L\",target = \"__LR\") == False\n    assert candidate(start = \"LRLR\",target = \"LRLR\") == True\n    assert candidate(start = \"LL_RR\",target = \"L_RLR\") == False\n    assert candidate(start = \"L_L\",target = \"LL_\") == True\n    assert candidate(start = \"RLRL\",target = \"LRLR\") == False\n    assert candidate(start = \"L___R\",target = \"L___R\") == True\n    assert candidate(start = \"R___L\",target = \"L___R\") == False\n    assert candidate(start = \"R_L_\",target = \"__LR\") == False\n    assert candidate(start = \"R_LRL\",target = \"RLR_L\") == False\n    assert candidate(start = \"RRLL____\",target = \"____RRLL\") == False\n    assert candidate(start = \"R__L__R\",target = \"__LR___\") == False\n    assert candidate(start = \"LR___LR___LR____\",target = \"_L__L___R___R___\") == False\n    assert candidate(start = \"L___R_L__\",target = \"L______LR\") == False\n    assert candidate(start = \"R____L_____\",target = \"_____R____L\") == False\n    assert candidate(start = \"R______L\",target = \"_____LR_\") == False\n    assert candidate(start = \"R___L__R_L\",target = \"_____LR__L\") == False\n    assert candidate(start = \"L______R______L\",target = \"_______LR______\") == False\n    assert candidate(start = \"R__L___L_\",target = \"___LR___L\") == False\n    assert candidate(start = \"L____R____L___\",target = \"________LR____\") == False\n    assert candidate(start = \"L_R____R\",target = \"_LR_____\") == False\n    assert candidate(start = \"R_R_R_R_\",target = \"____RRRR\") == True\n    assert candidate(start = \"R_L_R_L_R\",target = \"_L__L__RR\") == False\n    assert candidate(start = \"R__LR_R__\",target = \"__LR___R_\") == False\n    assert candidate(start = \"LR_L_R_L_R\",target = \"L_R_L_R_L_\") == False\n    assert candidate(start = \"L_R_L_R\",target = \"_L__L_R\") == False\n    assert candidate(start = \"R__L___R_L\",target = \"____LR__RL\") == False\n    assert candidate(start = \"__LR__R\",target = \"____LRR\") == False\n    assert candidate(start = \"L___R___L\",target = \"____L__LR\") == False\n    assert candidate(start = \"_L_R__L_R\",target = \"L______LR\") == False\n    assert candidate(start = \"L_L_L_L_L\",target = \"_____LLLL\") == False\n    assert candidate(start = \"R_L_R_L_R_L\",target = \"_LR_L_L_R_L\") == False\n    assert candidate(start = \"R_L_R_L_R\",target = \"___R_L_RL\") == False\n    assert candidate(start = \"R_L_R_L_R\",target = \"_LR_L__RR\") == False\n    assert candidate(start = \"R___L___R___L\",target = \"_____R___L___\") == False\n    assert candidate(start = \"LR_LRL__\",target = \"LRL_L___\") == False\n    assert candidate(start = \"L___R____L\",target = \"______LR_L\") == False\n    assert candidate(start = \"L____R____\",target = \"____LR____\") == False\n    assert candidate(start = \"RRR___LLL\",target = \"___LLLRRR\") == False\n    assert candidate(start = \"L_R_L___R\",target = \"L___L_R__\") == False\n    assert candidate(start = \"L_R_L_R_L_R\",target = \"LL______RRR\") == False\n    assert candidate(start = \"_L__R_L_R\",target = \"L_____RLR\") == False\n    assert candidate(start = \"R_L_R_L_R_L_R___\",target = \"_L_R_L_R_L_R____\") == False\n    assert candidate(start = \"R___L___R\",target = \"__LR___R_\") == False\n    assert candidate(start = \"______L_R\",target = \"L______R_\") == False\n    assert candidate(start = \"R__L_L___R\",target = \"___LR____R\") == False\n    assert candidate(start = \"_L_L_L_L\",target = \"LLLL____\") == True\n    assert candidate(start = \"_L_R_L_R_\",target = \"L_____R_R\") == False\n    assert candidate(start = \"L_R_L_R_L_R\",target = \"_LR_L_R_L_R\") == False\n    assert candidate(start = \"L_R_L_R_L_R\",target = \"_L_L_L_RLR_\") == False\n    assert candidate(start = \"L_____R_L____\",target = \"________L_R__\") == False\n    assert candidate(start = \"R_L_R___L_R___\",target = \"_L_R_L___R____\") == False\n    assert candidate(start = \"_L_R__L__R\",target = \"____L___LR\") == False\n    assert candidate(start = \"R_L_R___L\",target = \"_LR______\") == False\n    assert candidate(start = \"L_R_L___R\",target = \"L___LR___\") == False\n    assert candidate(start = \"R_L_R_L_R\",target = \"_LR_L_R_L\") == False\n    assert candidate(start = \"LRLR_LRL\",target = \"LRLR_LRL\") == True\n    assert candidate(start = \"R_____L__\",target = \"_____LR__\") == False\n    assert candidate(start = \"R_L_R_L\",target = \"__LR__L\") == False\n    assert candidate(start = \"R_L_R_L_R_L\",target = \"LR_L_R_L_R_\") == False\n    assert candidate(start = \"L_____R___L\",target = \"________LRL\") == False\n    assert candidate(start = \"_L____R_____\",target = \"L_____R_____\") == True\n    assert candidate(start = \"___LR___R\",target = \"L_____RR_\") == False\n    assert candidate(start = \"_L___R_L_R\",target = \"L_____RR__\") == False\n    assert candidate(start = \"L___R__L_R\",target = \"LL______RR\") == False\n    assert candidate(start = \"______\",target = \"______\") == True\n    assert candidate(start = \"R_L_R___L_R\",target = \"_L_R_L___RR\") == False\n    assert candidate(start = \"R________L\",target = \"________LR\") == False\n    assert candidate(start = \"R_L___L_R\",target = \"__LR__L_R\") == False\n    assert candidate(start = \"L___R___L\",target = \"__L___R_L\") == False\n    assert candidate(start = \"_______L_L_R_R\",target = \"L______L___R_R\") == True\n    assert candidate(start = \"RRRLLL___\",target = \"___RRRLLL\") == False\n    assert candidate(start = \"L__R__L___R____\",target = \"L___L__R__R____\") == False\n    assert candidate(start = \"L___R__L___\",target = \"_L_____RL__\") == False\n    assert candidate(start = \"L___R___L___R\",target = \"L___L___R___R\") == False\n    assert candidate(start = \"____L___R__\",target = \"L_____R____\") == False\n    assert candidate(start = \"L_R__L_R\",target = \"_LR__LR_\") == False\n    assert candidate(start = \"R_L___LR__L____\",target = \"__LR__LR__L____\") == False\n    assert candidate(start = \"L___R___R\",target = \"___L____R\") == False\n    assert candidate(start = \"L___R___L_R\",target = \"L_____RL___\") == False\n    assert candidate(start = \"__L_R__R_L\",target = \"L_____R__L\") == False\n    assert candidate(start = \"_L___R__L\",target = \"L_____R__\") == False\n    assert candidate(start = \"_L_R_L_R_R\",target = \"L______RRR\") == False\n    assert candidate(start = \"_R_L_R_L____\",target = \"____LR____LR\") == False\n    assert candidate(start = \"R_L__R\",target = \"__LR__\") == False\n", "comparison": "exact"}, "public_tests": ["\"_L__R__R_\"\n\"L______RR\"", "\"R_L_\"\n\"__LR\"", "\"_R\"\n\"R_\""], "hints": ["After some sequence of moves, can the order of the pieces change?", "Try to match each piece in s with a piece in e."], "metadata": {"canonical_parameter_names": ["start", "target"], "leetcode_dataset_entry_point": "Solution().canChange", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:14+00:00", "tests_total": 136, "tests_dropped": 37, "flags": [], "topic_tags": ["two-pointers", "string"]}, "language": "python", "interface": {"raw_signature": "def canChange(self, start: str, target: str) -> bool:", "container": "Solution", "callable": "canChange", "parameters": [{"name": "start", "type": "str"}, {"name": "target", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2338, "task_id": "count-the-number-of-ideal-arrays", "difficulty": "Hard", "problem_description": "You are given two integers n and maxValue, which are used to describe an ideal array.\n\nA 0-indexed integer array arr of length n is considered ideal if the following conditions hold:\n\n- Every arr[i] is a value from 1 to maxValue, for 0 <= i < n.\n- Every arr[i] is divisible by arr[i - 1], for 0 < i < n.\n\nReturn the number of distinct ideal arrays of length n. Since the answer may be very large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 2, maxValue = 5\nOutput: 10\nExplanation: The following are the possible ideal arrays:\n- Arrays starting with the value 1 (5 arrays): [1,1], [1,2], [1,3], [1,4], [1,5]\n- Arrays starting with the value 2 (2 arrays): [2,2], [2,4]\n- Arrays starting with the value 3 (1 array): [3,3]\n- Arrays starting with the value 4 (1 array): [4,4]\n- Arrays starting with the value 5 (1 array): [5,5]\nThere are a total of 5 + 2 + 1 + 1 + 1 = 10 distinct ideal arrays.\n\nExample 2:\n\nInput: n = 5, maxValue = 3\nOutput: 11\nExplanation: The following are the possible ideal arrays:\n- Arrays starting with the value 1 (9 arrays):\n   - With no other distinct values (1 array): [1,1,1,1,1]\n   - With 2^nd distinct value 2 (4 arrays): [1,1,1,1,2], [1,1,1,2,2], [1,1,2,2,2], [1,2,2,2,2]\n   - With 2^nd distinct value 3 (4 arrays): [1,1,1,1,3], [1,1,1,3,3], [1,1,3,3,3], [1,3,3,3,3]\n- Arrays starting with the value 2 (1 array): [2,2,2,2,2]\n- Arrays starting with the value 3 (1 array): [3,3,3,3,3]\nThere are a total of 9 + 1 + 1 = 11 distinct ideal arrays.\n\nConstraints:\n\n- 2 <= n <= 10^4\n- 1 <= maxValue <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 7,maxValue = 7) == 106\n    assert candidate(n = 2,maxValue = 5) == 10\n    assert candidate(n = 3,maxValue = 7) == 28\n    assert candidate(n = 3,maxValue = 6) == 25\n    assert candidate(n = 6,maxValue = 12) == 327\n    assert candidate(n = 10,maxValue = 5) == 86\n    assert candidate(n = 4,maxValue = 4) == 19\n    assert candidate(n = 10,maxValue = 10) == 571\n    assert candidate(n = 4,maxValue = 7) == 43\n    assert candidate(n = 3,maxValue = 2) == 4\n    assert candidate(n = 10000,maxValue = 10000) == 22940607\n    assert candidate(n = 4,maxValue = 10) == 89\n    assert candidate(n = 5,maxValue = 3) == 11\n    assert candidate(n = 2000,maxValue = 10) == 347343994\n    assert candidate(n = 15,maxValue = 10) == 1431\n    assert candidate(n = 7,maxValue = 20) == 1191\n    assert candidate(n = 8000,maxValue = 8000) == 106406983\n    assert candidate(n = 8,maxValue = 16) == 1115\n    assert candidate(n = 6000,maxValue = 6000) == 883250062\n    assert candidate(n = 2000,maxValue = 5000) == 716352377\n    assert candidate(n = 10000,maxValue = 1) == 1\n    assert candidate(n = 100,maxValue = 50) == 604383896\n    assert candidate(n = 1000,maxValue = 4) == 502501\n    assert candidate(n = 9,maxValue = 5) == 73\n    assert candidate(n = 7,maxValue = 15) == 575\n    assert candidate(n = 10,maxValue = 20) == 3176\n    assert candidate(n = 2000,maxValue = 1000) == 534638579\n    assert candidate(n = 10,maxValue = 15) == 1341\n    assert candidate(n = 50,maxValue = 20) == 519126\n    assert candidate(n = 8,maxValue = 3) == 17\n    assert candidate(n = 20,maxValue = 2) == 21\n    assert candidate(n = 6,maxValue = 3) == 13\n    assert candidate(n = 100,maxValue = 3) == 201\n    assert candidate(n = 10000,maxValue = 5000) == 22892639\n    assert candidate(n = 9999,maxValue = 10000) == 667133522\n    assert candidate(n = 6000,maxValue = 3000) == 80648523\n    assert candidate(n = 3000,maxValue = 3000) == 806624302\n    assert candidate(n = 2000,maxValue = 2000) == 585712681\n    assert candidate(n = 3,maxValue = 1) == 1\n    assert candidate(n = 5000,maxValue = 5) == 12517501\n    assert candidate(n = 5000,maxValue = 2000) == 802769368\n    assert candidate(n = 1000,maxValue = 2000) == 228299266\n    assert candidate(n = 8,maxValue = 20) == 1707\n    assert candidate(n = 50,maxValue = 25) == 1630451\n    assert candidate(n = 100,maxValue = 2) == 101\n    assert candidate(n = 5,maxValue = 1) == 1\n    assert candidate(n = 6,maxValue = 8) == 138\n    assert candidate(n = 5,maxValue = 9999) == 6309016\n    assert candidate(n = 100,maxValue = 5) == 5351\n    assert candidate(n = 500,maxValue = 3) == 1001\n    assert candidate(n = 2000,maxValue = 50) == 74895101\n    assert candidate(n = 100,maxValue = 100) == 959337187\n    assert candidate(n = 5,maxValue = 100) == 7537\n    assert candidate(n = 100,maxValue = 10) == 202201\n    assert candidate(n = 9,maxValue = 9) == 373\n    assert candidate(n = 5000,maxValue = 20) == 436322284\n    assert candidate(n = 2000,maxValue = 10000) == 239341549\n    assert candidate(n = 20,maxValue = 50) == 388980\n    assert candidate(n = 10000,maxValue = 500) == 397370814\n    assert candidate(n = 1000,maxValue = 1000) == 91997497\n    assert candidate(n = 7500,maxValue = 7500) == 143340271\n    assert candidate(n = 25,maxValue = 30) == 153176\n    assert candidate(n = 500,maxValue = 500) == 652553975\n    assert candidate(n = 5000,maxValue = 100) == 853200627\n    assert candidate(n = 5000,maxValue = 5000) == 144035088\n    assert candidate(n = 1000,maxValue = 100) == 607180637\n    assert candidate(n = 50,maxValue = 100) == 268368886\n    assert candidate(n = 10000,maxValue = 100) == 200548806\n    assert candidate(n = 10,maxValue = 100) == 105568\n    assert candidate(n = 2,maxValue = 10000) == 93668\n    assert candidate(n = 10,maxValue = 10000) == 466423769\n    assert candidate(n = 1000,maxValue = 10000) == 888200964\n    assert candidate(n = 15,maxValue = 15) == 3711\n    assert candidate(n = 3000,maxValue = 6000) == 321990518\n    assert candidate(n = 8,maxValue = 2) == 9\n    assert candidate(n = 30,maxValue = 30) == 290436\n    assert candidate(n = 1000,maxValue = 10) == 170172001\n    assert candidate(n = 7500,maxValue = 10000) == 430119293\n    assert candidate(n = 8000,maxValue = 9000) == 358648747\n    assert candidate(n = 7500,maxValue = 5000) == 777616479\n", "comparison": "exact"}, "public_tests": ["2\n5", "5\n3"], "hints": ["Notice that an ideal array is non-decreasing.", "Consider an alternative problem: where an ideal array must also be strictly increasing. Can you use DP to solve it?", "Will combinatorics help to get an answer from the alternative problem to the actual problem?"], "metadata": {"canonical_parameter_names": ["n", "maxValue"], "leetcode_dataset_entry_point": "Solution().idealArrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:17+00:00", "tests_total": 80, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "dynamic-programming", "combinatorics", "number-theory", "prime-factorization", "fermats-little-theorem"]}, "language": "python", "interface": {"raw_signature": "def idealArrays(self, n: int, maxValue: int) -> int:", "container": "Solution", "callable": "idealArrays", "parameters": [{"name": "n", "type": "int"}, {"name": "maxValue", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2341, "task_id": "maximum-number-of-pairs-in-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums. In one operation, you may do the following:\n\n- Choose two integers in nums that are equal.\n- Remove both integers from nums, forming a pair.\n\nThe operation is done on nums as many times as possible.\n\nReturn a 0-indexed integer array answer of size 2 where answer[0] is the number of pairs that are formed and answer[1] is the number of leftover integers in nums after doing the operation as many times as possible.\n\nExample 1:\n\nInput: nums = [1,3,2,1,3,2,2]\nOutput: [3,1]\nExplanation:\nForm a pair with nums[0] and nums[3] and remove them from nums. Now, nums = [3,2,3,2,2].\nForm a pair with nums[0] and nums[2] and remove them from nums. Now, nums = [2,2,2].\nForm a pair with nums[0] and nums[1] and remove them from nums. Now, nums = [2].\nNo more pairs can be formed. A total of 3 pairs have been formed, and there is 1 number leftover in nums.\n\nExample 2:\n\nInput: nums = [1,1]\nOutput: [1,0]\nExplanation: Form a pair with nums[0] and nums[1] and remove them from nums. Now, nums = [].\nNo more pairs can be formed. A total of 1 pair has been formed, and there are 0 numbers leftover in nums.\n\nExample 3:\n\nInput: nums = [0]\nOutput: [0,1]\nExplanation: No pairs can be formed, and there is 1 number leftover in nums.\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 0 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [5, 0]\n    assert candidate(nums = [100, 0, 50, 50, 0, 100]) == [3, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 10]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [5, 1]\n    assert candidate(nums = [42]) == [0, 1]\n    assert candidate(nums = [1]) == [0, 1]\n    assert candidate(nums = [1, 3, 2, 1, 3, 2, 2]) == [3, 1]\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1]) == [4, 1]\n    assert candidate(nums = [6, 6, 6, 7, 7, 7, 8, 8, 8, 8]) == [4, 2]\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [5, 0]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [5, 0]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [10, 0]\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [6, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5]) == [0, 5]\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == [3, 3]\n    assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [5, 0]\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [5, 1]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [5, 0]\n    assert candidate(nums = [0]) == [0, 1]\n    assert candidate(nums = [100, 100, 100, 99, 99, 98]) == [2, 2]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5]) == [3, 0]\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [4, 2]\n    assert candidate(nums = [100, 100, 99, 99, 98, 98, 97, 97, 96, 96]) == [5, 0]\n    assert candidate(nums = [1, 1]) == [1, 0]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 0]\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2]) == [3, 1]\n    assert candidate(nums = [100, 100, 100]) == [1, 1]\n    assert candidate(nums = [30, 30, 30, 31, 31, 31, 31, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34]) == [8, 3]\n    assert candidate(nums = [1, 2, 1, 2, 3, 4, 3, 4, 5, 5, 5, 6, 6, 6, 6]) == [7, 1]\n    assert candidate(nums = [10, 10, 10, 10, 10, 20, 20, 20, 20, 30, 30, 30, 40, 40, 40, 40, 40]) == [7, 3]\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [14, 1]\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [15, 0]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == [10, 0]\n    assert candidate(nums = [65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 67, 67, 68, 68, 68, 68]) == [11, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [18, 0]\n    assert candidate(nums = [34, 34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 36, 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38]) == [13, 2]\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [11, 0]\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == [8, 4]\n    assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [12, 1]\n    assert candidate(nums = [7, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12]) == [9, 3]\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == [16, 5]\n    assert candidate(nums = [30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33]) == [12, 3]\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [10, 0]\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [15, 0]\n    assert candidate(nums = [13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == [13, 1]\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5]) == [14, 2]\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [3, 23]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [15, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [10, 5]\n    assert candidate(nums = [35, 35, 35, 35, 36, 36, 36, 36, 36, 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38]) == [10, 1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [0, 30]\n    assert candidate(nums = [10, 20, 10, 20, 30, 30, 30, 40, 40, 40, 40]) == [5, 1]\n    assert candidate(nums = [21, 22, 22, 21, 23, 24, 24, 23, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29]) == [9, 0]\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == [12, 3]\n    assert candidate(nums = [1, 3, 2, 1, 3, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6]) == [15, 0]\n    assert candidate(nums = [6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8]) == [8, 1]\n    assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]) == [11, 2]\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == [9, 2]\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == [6, 2]\n    assert candidate(nums = [10, 10, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40]) == [6, 1]\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4]) == [7, 1]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [12, 1]\n    assert candidate(nums = [21, 21, 21, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25]) == [9, 2]\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [13, 3]\n    assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [15, 0]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [10, 0]\n    assert candidate(nums = [45, 45, 45, 45, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 48, 48, 48, 48, 48, 48, 48, 49, 49, 49, 49, 49, 49, 49, 49]) == [14, 2]\n    assert candidate(nums = [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [8, 4]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == [7, 1]\n    assert candidate(nums = [16, 17, 18, 19, 20, 16, 17, 18, 19, 20, 16, 17, 18, 19, 20, 16, 17, 18, 19, 20, 16, 17, 18, 19, 20]) == [10, 5]\n    assert candidate(nums = [10, 10, 10, 20, 20, 30, 30, 40, 40, 40, 50, 50, 50, 50]) == [6, 2]\n    assert candidate(nums = [10, 20, 10, 30, 20, 30, 40, 40, 40, 50, 50, 50, 50, 60, 60, 60, 60, 60]) == [8, 2]\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [18, 1]\n    assert candidate(nums = [10, 20, 10, 30, 20, 30, 40, 50, 60, 40, 50, 60, 70, 80, 90, 100, 70, 80, 90, 100]) == [10, 0]\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [20, 0]\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == [10, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10]) == [10, 1]\n    assert candidate(nums = [39, 39, 40, 40, 40, 41, 41, 41, 41, 42, 42, 42, 42, 42, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 44]) == [12, 3]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 20]\n    assert candidate(nums = [1, 3, 2, 1, 3, 2, 2, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == [11, 2]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10]\n    assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == [8, 4]\n    assert candidate(nums = [99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91, 90, 90]) == [10, 0]\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [6, 3]\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 10, 10]) == [14, 5]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == [14, 0]\n    assert candidate(nums = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99]) == [10, 0]\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [15, 0]\n    assert candidate(nums = [1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [9, 5]\n    assert candidate(nums = [7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10]) == [9, 2]\n    assert candidate(nums = [10, 10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40]) == [6, 2]\n    assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == [0, 20]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [0, 25]\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [15, 0]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == [20, 0]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10]) == [5, 5]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 20]\n    assert candidate(nums = [7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10]) == [13, 1]\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == [6, 2]\n    assert candidate(nums = [11, 12, 11, 12, 13, 14, 15, 14, 13, 15, 15, 14, 13, 12, 11]) == [5, 5]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == [5, 15]\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [10, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [26, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [10, 2]\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51]) == [16, 0]\n    assert candidate(nums = [16, 16, 17, 17, 17, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 20]) == [7, 2]\n    assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == [15, 2]\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10]) == [16, 0]\n    assert candidate(nums = [52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52]) == [19, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 6, 7, 8, 9, 10]) == [10, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4]) == [12, 2]\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [4, 2]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8]) == [15, 1]\n    assert candidate(nums = [60, 60, 61, 61, 61, 62, 62, 62, 62, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64]) == [9, 2]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 3, 4, 6, 7, 8, 9, 10]) == [6, 9]\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12]) == [12, 12]\n    assert candidate(nums = [26, 26, 26, 26, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29]) == [11, 2]\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [12, 2]\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [14, 1]\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [12, 2]\n    assert candidate(nums = [7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9]) == [8, 1]\n    assert candidate(nums = [0, 1, 1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6]) == [12, 5]\n    assert candidate(nums = [2, 3, 3, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6]) == [7, 4]\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == [11, 3]\n    assert candidate(nums = [7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]) == [7, 1]\n    assert candidate(nums = [39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]) == [0, 21]\n", "comparison": "exact"}, "public_tests": ["[1,3,2,1,3,2,2]", "[1,1]", "[0]"], "hints": ["What do we need to know to find how many pairs we can make? We need to know the frequency of each integer.", "When will there be a leftover number? When the frequency of an integer is an odd number."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numberOfPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:21+00:00", "tests_total": 126, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "counting"]}, "language": "python", "interface": {"raw_signature": "def numberOfPairs(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "numberOfPairs", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2342, "task_id": "max-sum-of-a-pair-with-equal-sum-of-digits", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums consisting of positive integers. You can choose two indices i and j, such that i != j, and the sum of digits of the number nums[i] is equal to that of nums[j].\n\nReturn the maximum value of nums[i] + nums[j] that you can obtain over all possible indices i and j that satisfy the conditions. If no such pair of indices exists, return -1.\n\nExample 1:\n\nInput: nums = [18,43,36,13,7]\nOutput: 54\nExplanation: The pairs (i, j) that satisfy the conditions are:\n- (0, 2), both numbers have a sum of digits equal to 9, and their sum is 18 + 36 = 54.\n- (1, 4), both numbers have a sum of digits equal to 7, and their sum is 43 + 7 = 50.\nSo the maximum sum that we can obtain is 54.\n\nExample 2:\n\nInput: nums = [10,12,19,14]\nOutput: -1\nExplanation: There are no two numbers that satisfy the conditions, so we return -1.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [99, 18, 81, 27]) == 108\n    assert candidate(nums = [55, 23, 45, 55, 23]) == 110\n    assert candidate(nums = [55, 23, 45, 55]) == 110\n    assert candidate(nums = [111, 222, 333, 444]) == -1\n    assert candidate(nums = [1000000000]) == -1\n    assert candidate(nums = [5, 5, 5, 5, 5]) == 10\n    assert candidate(nums = [999999999, 999999999]) == 1999999998\n    assert candidate(nums = [1, 2, 3, 4, 5]) == -1\n    assert candidate(nums = [999999999, 111111111, 222222222]) == -1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == -1\n    assert candidate(nums = [99, 18, 81, 27, 72]) == 153\n    assert candidate(nums = [9, 99, 999, 9999]) == -1\n    assert candidate(nums = [100, 200, 300, 400, 500]) == -1\n    assert candidate(nums = [1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 1100000000\n    assert candidate(nums = [89, 98, 76, 67, 54, 45, 32, 23, 10, 1]) == 187\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n    assert candidate(nums = [55, 23, 32, 44, 55]) == 110\n    assert candidate(nums = [55, 23, 45, 67, 89, 90, 11]) == 135\n    assert candidate(nums = [123, 321, 213, 132, 231, 312]) == 633\n    assert candidate(nums = [10, 12, 19, 14]) == -1\n    assert candidate(nums = [18, 43, 36, 13, 7]) == 54\n    assert candidate(nums = [123, 321, 213]) == 534\n    assert candidate(nums = [55, 23, 45, 67, 89, 90]) == 135\n    assert candidate(nums = [123, 321, 213, 132, 312, 231]) == 633\n    assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == -1\n    assert candidate(nums = [123456789, 987654321, 234567891, 123456789, 987654321]) == 1975308642\n    assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888]) == 1543209876\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n    assert candidate(nums = [55555, 44444, 33333, 22222, 11111, 66666, 77777, 88888, 99999]) == -1\n    assert candidate(nums = [12345, 54321, 13452, 21435, 23541, 32145, 42315, 52314, 34512, 54123]) == 108444\n    assert candidate(nums = [12345, 54321, 23451, 45123, 34512, 123456, 654321, 234516, 165432, 321654, 654123, 412365, 564321, 123654, 654312]) == 1308633\n    assert candidate(nums = [123, 321, 231, 312, 132, 213, 456, 654, 564, 546, 465, 645, 789, 987, 897, 879, 798, 978]) == 1965\n    assert candidate(nums = [1001, 1100, 1010, 1001, 2002, 2020, 2200, 3003, 3030, 3300]) == 6330\n    assert candidate(nums = [123456789, 987654321, 234567891, 345678912, 456789123, 567891234, 678912345, 789123456, 891234567]) == 1878888888\n    assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 10000]) == -1\n    assert candidate(nums = [123, 132, 213, 231, 312, 321, 456, 465, 546, 564, 645, 654, 789, 798, 879, 897, 978, 987, 101, 110, 1001, 1010, 1100]) == 2110\n    assert candidate(nums = [555555555, 222222222, 333333333, 444444444, 55555555, 22222222, 33333333, 44444444, 5555555, 2222222, 3333333, 4444444]) == -1\n    assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == -1\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]) == 1100000000\n    assert candidate(nums = [123, 321, 213, 132, 312, 231, 111, 222, 333]) == 633\n    assert candidate(nums = [999, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 1998\n    assert candidate(nums = [1001, 1100, 1010, 10001, 9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111]) == 11101\n    assert candidate(nums = [99, 999, 9999, 99999, 999999]) == -1\n    assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999, 123456789, 987654321]) == 1543209876\n    assert candidate(nums = [1234, 4321, 2341, 1432, 1243, 2413, 3412, 4123, 1342, 3241]) == 8444\n    assert candidate(nums = [999999999, 111111111, 222222222, 333333333, 444444444]) == -1\n    assert candidate(nums = [987654321, 123456789, 98765432, 12345678, 9876543, 1234567]) == 1111111110\n    assert candidate(nums = [1001, 1010, 1100, 2002, 2020, 2200, 3003, 3030, 3300]) == 6330\n    assert candidate(nums = [11112, 22223, 33334, 44445, 55556, 66667, 77778, 88889, 99990]) == 177768\n    assert candidate(nums = [123, 321, 111, 456, 654, 789, 987]) == 1776\n    assert candidate(nums = [987654321, 123456789, 111222333, 333222111, 444444444, 555555555]) == 1543209876\n    assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == 1233\n    assert candidate(nums = [876, 768, 687, 867, 678, 786, 543, 456, 345, 435, 543, 534]) == 1743\n    assert candidate(nums = [12345, 54321, 11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999]) == 87654\n    assert candidate(nums = [54321, 21345, 32145, 45321, 14523, 51423, 23451, 34512, 45123, 12354]) == 105744\n    assert candidate(nums = [123, 321, 456, 654, 789, 987, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 1875\n    assert candidate(nums = [500000000, 499999999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 999999999]) == 500000005\n    assert candidate(nums = [12, 21, 30, 13, 31, 40, 24, 42, 33, 50]) == 75\n    assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == -1\n    assert candidate(nums = [123, 321, 213, 111, 222, 333]) == 543\n    assert candidate(nums = [999, 111, 222, 333, 444, 555, 666, 777, 888]) == -1\n    assert candidate(nums = [9, 90, 900, 9000, 90000, 900000, 9000000, 90000000, 900000000]) == 990000000\n    assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888]) == 1543209876\n    assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]) == -1\n    assert candidate(nums = [199, 288, 377, 466, 555, 644, 733, 822, 911, 1000]) == -1\n    assert candidate(nums = [123, 321, 213, 132, 312, 231]) == 633\n    assert candidate(nums = [12345, 54321, 23451, 15432, 67890, 98760, 89076, 76980, 32145, 54312]) == 187836\n    assert candidate(nums = [999999999, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888]) == -1\n    assert candidate(nums = [123456789, 12345678, 1234567, 123456, 12345, 1234, 123, 12, 1]) == -1\n    assert candidate(nums = [123, 321, 213, 132, 231, 312, 456, 654, 546, 465, 564, 645, 789, 987, 897, 798, 879, 978]) == 1965\n    assert candidate(nums = [987654321, 123456789, 234567891, 345678912, 456789123]) == 1444443444\n    assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 18, 81, 123, 321, 132, 213, 231, 312]) == 633\n    assert candidate(nums = [123456789, 987654321, 123456789, 987654321]) == 1975308642\n    assert candidate(nums = [100, 101, 110, 111, 200, 201, 210, 211, 300, 301, 310, 311]) == 611\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 1100000000\n    assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 171\n    assert candidate(nums = [123, 321, 213, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 543\n    assert candidate(nums = [99999999, 9999999, 999999, 99999, 9999, 999, 99, 9, 88888888, 8888888, 888888, 88888, 8888, 888, 88, 8]) == -1\n    assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 9675\n    assert candidate(nums = [12, 21, 13, 31, 14, 41, 15, 51, 16, 61, 17, 71, 18, 81, 19, 91]) == 110\n    assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999]) == -1\n    assert candidate(nums = [1001, 110, 1110, 1011, 11100, 11110, 10111]) == 21221\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 31\n    assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901, 102]) == -1\n    assert candidate(nums = [100000000, 100000001, 100000002, 100000003, 100000004, 100000005]) == -1\n    assert candidate(nums = [1001, 1010, 1100, 2002, 2020, 2200, 3003, 3030, 3300]) == 6330\n    assert candidate(nums = [123456789, 987654321, 111222333, 444555666, 777888999]) == 1432209987\n    assert candidate(nums = [123456789, 987654321, 234567891, 123456782, 111111111]) == 1222222212\n    assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == -1\n    assert candidate(nums = [123, 321, 456, 654, 789, 987, 234, 432, 567, 765, 890, 980]) == 1870\n    assert candidate(nums = [100000000, 200000000, 300000000, 111111111, 222222222, 333333333]) == -1\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 1100000000\n    assert candidate(nums = [98765, 56789, 12345, 54321, 67890, 9876, 6789, 1234, 5678, 2345]) == 155554\n    assert candidate(nums = [56, 65, 74, 47, 83, 38, 92, 29, 101, 110]) == 211\n    assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == -1\n    assert candidate(nums = [1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 1100000000\n    assert candidate(nums = [876543210, 123456789, 111222333, 444555666, 777888999, 555555555, 666666666]) == 1000111221\n    assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 100000000]) == -1\n    assert candidate(nums = [999999999, 111111111, 222222222, 333333333, 444444444, 555555555]) == -1\n    assert candidate(nums = [123, 1230, 1203, 1023, 10023, 100023, 1000023, 10000023, 100000023]) == 110000046\n    assert candidate(nums = [112, 121, 211, 221, 212, 122, 333, 444, 555, 666, 777, 888, 999, 1001, 1010, 1100]) == 2110\n    assert candidate(nums = [123, 321, 213, 132, 231, 312, 111, 222, 333, 444]) == 633\n    assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == -1\n    assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009, 1101, 2202, 3303, 4404, 5505]) == 10410\n    assert candidate(nums = [101, 110, 202, 220, 303, 330, 404, 440, 505, 550]) == 1055\n    assert candidate(nums = [1234, 4321, 2134, 1324, 2341, 3412, 3421, 4231, 4123, 2431]) == 8552\n    assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909]) == -1\n    assert candidate(nums = [123, 321, 213, 132, 231, 312, 12, 21, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 633\n    assert candidate(nums = [11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999]) == -1\n    assert candidate(nums = [987654321, 98765432, 9876543, 987654, 98765, 9876, 987, 98, 9]) == -1\n    assert candidate(nums = [123, 321, 213, 456, 654, 564, 999, 888, 777, 111]) == 1218\n    assert candidate(nums = [987, 654, 321, 432, 789, 123]) == 1776\n    assert candidate(nums = [88, 88, 88, 88, 88, 88, 88, 88, 88, 88]) == 176\n    assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 1100000000\n", "comparison": "exact"}, "public_tests": ["[18,43,36,13,7]", "[10,12,19,14]"], "hints": ["What is the largest possible sum of digits a number can have?", "Group the array elements by the sum of their digits, and find the largest two elements of each group."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:24+00:00", "tests_total": 121, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "hash-table", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def maximumSum(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maximumSum", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2343, "task_id": "query-kth-smallest-trimmed-number", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of strings nums, where each string is of equal length and consists of only digits.\n\nYou are also given a 0-indexed 2D integer array queries where queries[i] = [k_i, trim_i]. For each queries[i], you need to:\n\n- Trim each number in nums to its rightmost trim_i digits.\n- Determine the index of the k_i^th smallest trimmed number in nums. If two trimmed numbers are equal, the number with the lower index is considered to be smaller.\n- Reset each number in nums to its original length.\n\nReturn an array answer of the same length as queries, where answer[i] is the answer to the i^th query.\n\nNote:\n\n- To trim to the rightmost x digits means to keep removing the leftmost digit, until only x digits remain.\n- Strings in nums may contain leading zeros.\n\nExample 1:\n\nInput: nums = [\"102\",\"473\",\"251\",\"814\"], queries = [[1,1],[2,3],[4,2],[1,2]]\nOutput: [2,2,1,0]\nExplanation:\n1. After trimming to the last digit, nums = [\"2\",\"3\",\"1\",\"4\"]. The smallest number is 1 at index 2.\n2. Trimmed to the last 3 digits, nums is unchanged. The 2^nd smallest number is 251 at index 2.\n3. Trimmed to the last 2 digits, nums = [\"02\",\"73\",\"51\",\"14\"]. The 4^th smallest number is 73.\n4. Trimmed to the last 2 digits, the smallest number is 2 at index 0.\n   Note that the trimmed number \"02\" is evaluated as 2.\n\nExample 2:\n\nInput: nums = [\"24\",\"37\",\"96\",\"04\"], queries = [[2,1],[2,2]]\nOutput: [3,0]\nExplanation:\n1. Trimmed to the last digit, nums = [\"4\",\"7\",\"6\",\"4\"]. The 2^nd smallest number is 4 at index 3.\n   There are two occurrences of 4, but the one at index 0 is considered smaller than the one at index 3.\n2. Trimmed to the last 2 digits, nums is unchanged. The 2^nd smallest number is 24.\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 1 <= nums[i].length <= 100\n- nums[i] consists of only digits.\n- All nums[i].length are equal.\n- 1 <= queries.length <= 100\n- queries[i].length == 2\n- 1 <= k_i <= nums.length\n- 1 <= trim_i <= nums[i].length\n\nFollow up: Could you use the Radix Sort Algorithm to solve this problem? What will be the complexity of that solution?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = ['111', '222', '333', '444'],queries = [[1, 1], [2, 2], [3, 3], [4, 3]]) == [0, 1, 2, 3]\n    assert candidate(nums = ['123', '456', '789', '012'],queries = [[1, 2], [3, 3], [2, 1]]) == [3, 1, 0]\n    assert candidate(nums = ['001', '002', '003'],queries = [[1, 1], [2, 1], [3, 1]]) == [0, 1, 2]\n    assert candidate(nums = ['001', '012', '123', '234'],queries = [[1, 2], [2, 3], [3, 1]]) == [0, 1, 2]\n    assert candidate(nums = ['001', '002', '003', '004'],queries = [[1, 3], [4, 1], [2, 2]]) == [0, 3, 1]\n    assert candidate(nums = ['24', '37', '96', '04'],queries = [[2, 1], [2, 2]]) == [3, 0]\n    assert candidate(nums = ['111', '222', '333', '444'],queries = [[1, 1], [2, 2], [3, 3], [4, 4]]) == [0, 1, 2, 3]\n    assert candidate(nums = ['56', '78', '90'],queries = [[1, 1], [2, 2]]) == [2, 1]\n    assert candidate(nums = ['12', '12', '12'],queries = [[1, 1], [2, 1], [3, 1]]) == [0, 1, 2]\n    assert candidate(nums = ['567', '890', '123'],queries = [[1, 3], [2, 2], [3, 1]]) == [2, 0, 0]\n    assert candidate(nums = ['123', '456', '789'],queries = [[1, 2], [3, 3], [2, 1]]) == [0, 2, 1]\n    assert candidate(nums = ['123', '456', '789'],queries = [[1, 2], [3, 1], [2, 3]]) == [0, 2, 1]\n    assert candidate(nums = ['102', '473', '251', '814'],queries = [[1, 1], [2, 3], [4, 2], [1, 2]]) == [2, 2, 1, 0]\n    assert candidate(nums = ['001', '010', '100'],queries = [[1, 1], [2, 2], [3, 3]]) == [1, 0, 2]\n    assert candidate(nums = ['987', '654', '321'],queries = [[1, 3], [2, 2], [3, 1]]) == [2, 1, 0]\n    assert candidate(nums = ['00123', '01234', '12345', '23456', '34567'],queries = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3]]) == [0, 1, 2, 3, 4]\n    assert candidate(nums = ['1234567890', '9876543210', '0000000000', '1111111111', '2222222222'],queries = [[1, 5], [3, 10], [2, 3], [5, 2]]) == [2, 0, 3, 0]\n    assert candidate(nums = ['9999', '8888', '7777', '6666'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [1, 4]]) == [3, 2, 1, 0, 3]\n    assert candidate(nums = ['111111111', '222222222', '333333333', '444444444', '555555555', '666666666', '777777777', '888888888', '999999999'],queries = [[9, 1], [1, 9], [5, 5], [3, 7], [7, 3], [2, 8], [8, 2], [4, 6], [6, 4]]) == [8, 0, 4, 2, 6, 1, 7, 3, 5]\n    assert candidate(nums = ['1001', '10001', '100001', '1000001', '10000001'],queries = [[1, 4], [2, 6], [3, 3], [4, 5], [5, 1]]) == [1, 4, 2, 1, 4]\n    assert candidate(nums = ['123456', '654321', '135799', '975311', '246800'],queries = [[1, 6], [2, 5], [3, 4], [4, 3], [5, 2]]) == [0, 2, 3, 2, 2]\n    assert candidate(nums = ['12345', '67890', '54321', '09876', '43210'],queries = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == [3, 4, 0, 3, 3]\n    assert candidate(nums = ['123456789', '987654321', '135792468', '246801357', '579135791'],queries = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [1, 4], [2, 3], [3, 2], [4, 1]]) == [0, 2, 3, 2, 2, 3, 3, 2, 2]\n    assert candidate(nums = ['10001', '01001', '00101', '00011', '11001'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [2, 3]]) == [0, 1, 4, 1, 4, 1]\n    assert candidate(nums = ['00001', '00002', '00003', '00004', '00005', '00006', '00007', '00008', '00009'],queries = [[1, 1], [9, 1], [2, 1], [3, 1], [8, 1], [4, 1], [7, 1], [5, 1], [6, 1]]) == [0, 8, 1, 2, 7, 3, 6, 4, 5]\n    assert candidate(nums = ['1234', '2345', '3456', '4567', '5678', '6789', '7890'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == [6, 1, 2, 3, 4, 5, 6]\n    assert candidate(nums = ['00000', '00001', '00002', '00003', '00004'],queries = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 5]]) == [0, 1, 2, 3, 4, 0]\n    assert candidate(nums = ['00001', '00010', '00100', '01000', '10000'],queries = [[1, 1], [5, 5], [3, 3], [2, 2], [4, 4]]) == [1, 4, 0, 3, 2]\n    assert candidate(nums = ['987', '876', '765', '654', '543', '432', '321', '210', '109'],queries = [[1, 1], [2, 1], [3, 2], [4, 2], [5, 3], [6, 3], [7, 2], [8, 3], [9, 1]]) == [7, 6, 6, 5, 4, 3, 2, 1, 8]\n    assert candidate(nums = ['1010', '0101', '0011', '1100'],queries = [[1, 2], [2, 1], [3, 4], [4, 3]]) == [3, 3, 0, 1]\n    assert candidate(nums = ['1111', '2222', '3333', '4444', '5555'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 5]]) == [0, 1, 2, 3, 4, 0]\n    assert candidate(nums = ['000001', '000010', '000100', '001000', '010000', '100000'],queries = [[1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6]]) == [0, 1, 2, 3, 4, 5]\n    assert candidate(nums = ['11111', '11112', '11122', '11222', '12222'],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == [0, 1, 2, 3, 4]\n    assert candidate(nums = ['100100', '100010', '101000', '010100', '001100', '001010', '010010', '000101', '000011', '110000'],queries = [[1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 6], [8, 5], [9, 4], [10, 3]]) == [8, 8, 6, 5, 9, 5, 1, 9, 5, 7]\n    assert candidate(nums = ['11111', '22222', '33333', '44444', '55555'],queries = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1]]) == [0, 1, 2, 3, 4]\n    assert candidate(nums = ['999', '888', '777', '666', '555'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 3]]) == [4, 3, 2, 1, 0]\n    assert candidate(nums = ['00123', '00234', '00345', '00456'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [2, 3]]) == [0, 1, 2, 3, 1]\n    assert candidate(nums = ['123', '234', '345', '456', '567', '678', '789', '890', '901', '012'],queries = [[1, 1], [10, 3], [5, 2], [3, 3], [8, 1], [2, 2], [7, 3], [4, 3], [6, 3], [9, 1]]) == [7, 8, 2, 1, 4, 9, 5, 2, 4, 5]\n    assert candidate(nums = ['00000', '11111', '22222', '33333', '44444', '55555'],queries = [[1, 1], [6, 5], [3, 3], [4, 2], [2, 4], [5, 5]]) == [0, 5, 2, 3, 1, 4]\n    assert candidate(nums = ['123', '456', '789', '101', '111'],queries = [[1, 1], [2, 2], [3, 3], [4, 1], [5, 2]]) == [3, 4, 0, 1, 2]\n    assert candidate(nums = ['123456', '654321', '111111', '222222', '333333'],queries = [[1, 6], [2, 5], [3, 4], [4, 3], [5, 2]]) == [2, 3, 4, 4, 0]\n    assert candidate(nums = ['999', '111', '222', '888', '333', '444', '555', '666', '777', '000'],queries = [[1, 1], [10, 3], [5, 2], [3, 3], [8, 1], [2, 2], [4, 4], [7, 5], [6, 6], [9, 9]]) == [9, 0, 5, 2, 8, 1, 4, 7, 6, 3]\n    assert candidate(nums = ['09876', '54321', '01234', '98765', '43210'],queries = [[1, 3], [2, 2], [3, 1], [4, 5], [5, 4]]) == [4, 1, 2, 1, 0]\n    assert candidate(nums = ['0000', '1111', '2222', '3333', '4444', '5555', '6666', '7777', '8888', '9999'],queries = [[1, 1], [5, 4], [10, 1], [3, 2], [7, 3]]) == [0, 4, 9, 2, 6]\n    assert candidate(nums = ['00011', '00101', '01001', '10001', '00110', '01100', '11000', '10100', '01010', '10010'],queries = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3]]) == [6, 2, 3, 8, 9, 0, 5, 7, 1, 4]\n    assert candidate(nums = ['123', '456', '789', '123', '456'],queries = [[1, 3], [2, 3], [3, 3], [4, 2], [5, 1]]) == [0, 3, 1, 4, 2]\n    assert candidate(nums = ['00001', '00002', '00003', '00004', '00005', '00006', '00007', '00008', '00009', '00010'],queries = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [9, 0, 1, 2, 3, 4, 5, 6, 7, 8]\n    assert candidate(nums = ['112233', '223344', '334455', '445566', '556677'],queries = [[1, 3], [2, 6], [3, 2], [4, 4], [5, 5]]) == [0, 1, 2, 3, 4]\n    assert candidate(nums = ['123456789', '234567890', '345678901', '456789012', '567890123'],queries = [[1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [1, 1]]) == [0, 1, 2, 3, 4, 1]\n    assert candidate(nums = ['11111', '22222', '33333', '44444', '55555'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 1, 2, 3, 4]\n    assert candidate(nums = ['98765', '87654', '76543', '65432', '54321'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [4, 3, 2, 1, 0]\n    assert candidate(nums = ['11111', '21111', '31111', '41111', '51111'],queries = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == [0, 1, 2, 3, 4]\n    assert candidate(nums = ['9999999999', '1234567890', '1111111111', '2222222222', '3333333333'],queries = [[1, 10], [2, 5], [3, 7], [4, 2], [5, 9]]) == [2, 3, 4, 1, 0]\n    assert candidate(nums = ['0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111'],queries = [[1, 1], [2, 1], [3, 2], [4, 2], [5, 3], [6, 3], [7, 4], [8, 4], [9, 5], [10, 5], [11, 6], [12, 6], [13, 7], [14, 7], [15, 8], [16, 8]]) == [0, 2, 8, 12, 2, 10, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n    assert candidate(nums = ['111111111', '222222222', '333333333', '444444444', '555555555'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [3, 9], [5, 9]]) == [0, 1, 2, 3, 4, 2, 4]\n    assert candidate(nums = ['0000', '0001', '0010', '0100', '1000'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 3, 1, 3, 4]\n    assert candidate(nums = ['00011', '00101', '01001', '10001', '00110', '01100', '11000', '10100', '10010', '01010'],queries = [[1, 2], [3, 3], [5, 1], [7, 4], [9, 5], [2, 5], [4, 2], [6, 3], [8, 1], [10, 2]]) == [5, 3, 8, 6, 7, 1, 1, 0, 1, 0]\n    assert candidate(nums = ['99999', '88888', '77777', '66666', '55555', '44444', '33333'],queries = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [3, 5], [4, 4]]) == [6, 5, 4, 3, 2, 4, 3]\n    assert candidate(nums = ['0011', '0101', '1001', '1100'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [1, 2]]) == [3, 1, 3, 3, 3]\n    assert candidate(nums = ['0123456789', '1234567890', '2345678901', '3456789012', '4567890123'],queries = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [0, 1, 2, 3, 4]\n    assert candidate(nums = ['00001', '00011', '00111', '01111', '11111', '22222', '33333', '44444', '55555'],queries = [[1, 1], [5, 2], [9, 3], [4, 4], [3, 5], [8, 1], [2, 2]]) == [0, 4, 8, 3, 2, 7, 1]\n    assert candidate(nums = ['12', '21', '11', '22', '12', '21'],queries = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [1, 2]]) == [1, 2, 5, 0, 3, 4, 2]\n    assert candidate(nums = ['9990', '9909', '9099', '0999', '9999'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 1], [5, 2], [5, 3]]) == [0, 0, 0, 0, 4, 4, 4]\n    assert candidate(nums = ['001100', '010101', '100100', '110011'],queries = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 3], [2, 4], [3, 5], [4, 6]]) == [0, 0, 1, 1, 3, 2, 3, 3]\n    assert candidate(nums = ['00111', '01010', '10001', '11100', '10110'],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == [0, 1, 2, 4, 3]\n    assert candidate(nums = ['00123', '01234', '12345', '23456', '34567'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [2, 3], [3, 2]]) == [0, 1, 2, 3, 4, 1, 2]\n    assert candidate(nums = ['12345', '23456', '34567', '45678', '56789'],queries = [[1, 1], [3, 2], [5, 3], [2, 4], [4, 5]]) == [0, 2, 4, 1, 3]\n    assert candidate(nums = ['12345', '67890', '13579', '24680', '97531'],queries = [[1, 2], [3, 4], [5, 1], [2, 5], [4, 3]]) == [4, 3, 2, 2, 3]\n    assert candidate(nums = ['1111111111', '2222222222', '3333333333', '4444444444', '5555555555', '6666666666', '7777777777', '8888888888', '9999999999'],queries = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n    assert candidate(nums = ['50000', '05000', '00500', '00050'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [3, 5], [4, 5]]) == [0, 1, 3, 1, 1, 0]\n    assert candidate(nums = ['9876543210', '0123456789', '1029384756', '2918074653', '3827165430'],queries = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [1, 1, 4, 3, 0]\n    assert candidate(nums = ['123', '234', '345', '456', '567', '678', '789'],queries = [[1, 1], [2, 3], [4, 2], [5, 3], [7, 1]]) == [0, 1, 3, 4, 6]\n    assert candidate(nums = ['999999', '888888', '777777', '666666', '555555'],queries = [[1, 6], [2, 5], [3, 4], [4, 3], [5, 2]]) == [4, 3, 2, 1, 0]\n    assert candidate(nums = ['12345', '23456', '34567', '45678', '56789'],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [1, 1]]) == [0, 1, 2, 3, 4, 0]\n    assert candidate(nums = ['00001', '00010', '00100', '01000', '10000'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [1, 3, 0, 2, 4]\n    assert candidate(nums = ['0000000000', '0000000001', '0000000010', '0000000100', '0000001000', '0000010000', '0000100000', '0001000000', '0010000000', '0100000000'],queries = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = ['110011001', '101010101', '010101010', '001100110', '100110011'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 3], [2, 3], [3, 5], [4, 5], [5, 1]]) == [2, 1, 4, 0, 0, 0, 2, 4, 1, 4]\n    assert candidate(nums = ['98765', '87654', '76543', '65432'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [1, 2], [2, 3]]) == [3, 2, 1, 0, 3, 2]\n    assert candidate(nums = ['0001', '0010', '0100', '1000'],queries = [[1, 1], [2, 2], [3, 3], [4, 4]]) == [1, 3, 1, 3]\n    assert candidate(nums = ['99999', '99998', '99997', '99996', '99995'],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == [4, 3, 2, 1, 0]\n    assert candidate(nums = ['1234', '5678', '9012', '3456'],queries = [[1, 1], [2, 4], [3, 3], [4, 2]]) == [2, 3, 3, 1]\n    assert candidate(nums = ['001', '010', '100', '011', '101', '110'],queries = [[1, 1], [2, 1], [3, 2], [4, 2], [5, 3], [6, 3]]) == [1, 2, 4, 1, 4, 5]\n    assert candidate(nums = ['11111', '22222', '33333', '44444'],queries = [[4, 5], [3, 4], [2, 3], [1, 2]]) == [3, 2, 1, 0]\n    assert candidate(nums = ['9876543210', '8765432109', '7654321098', '6543210987', '5432109876'],queries = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == [4, 2, 0, 3, 1]\n    assert candidate(nums = ['12345', '23456', '34567', '45678', '56789'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 1, 2, 3, 4]\n    assert candidate(nums = ['9876543210', '0123456789', '1098765432', '2987654321', '3876543210'],queries = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == [1, 2, 3, 4, 0]\n    assert candidate(nums = ['0011', '0101', '0110', '1001', '1010', '1100'],queries = [[1, 1], [3, 2], [2, 2], [4, 3], [5, 1], [6, 3]]) == [2, 3, 1, 5, 1, 2]\n    assert candidate(nums = ['00100', '01010', '10001', '01110', '11001'],queries = [[1, 5], [2, 3], [3, 2], [4, 4], [5, 1]]) == [0, 4, 4, 1, 4]\n    assert candidate(nums = ['987654321', '876543219', '765432198', '654321987', '543219876'],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [3, 9]]) == [0, 0, 0, 0, 0, 2]\n    assert candidate(nums = ['11111', '22222', '33333', '44444', '55555'],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == [0, 1, 2, 3, 4]\n    assert candidate(nums = ['00111', '01110', '11100', '11001', '10011'],queries = [[1, 3], [2, 2], [3, 1], [4, 4], [5, 5]]) == [3, 3, 0, 2, 2]\n    assert candidate(nums = ['0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001'],queries = [[1, 4], [2, 3], [3, 2], [4, 1], [5, 4], [6, 3], [7, 2], [8, 1], [9, 4], [10, 3]]) == [0, 8, 8, 6, 4, 3, 2, 5, 8, 7]\n    assert candidate(nums = ['00001', '00010', '00100', '01000', '10000'],queries = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == [0, 0, 0, 0, 0]\n    assert candidate(nums = ['00001', '00002', '00003', '00004', '00005'],queries = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2]]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n", "comparison": "exact"}, "public_tests": ["[\"102\",\"473\",\"251\",\"814\"]\n[[1,1],[2,3],[4,2],[1,2]]", "[\"24\",\"37\",\"96\",\"04\"]\n[[2,1],[2,2]]"], "hints": ["Run a simulation to follow the requirement of each query."], "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().smallestTrimmedNumbers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:26+00:00", "tests_total": 94, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "string", "divide-and-conquer", "sorting", "heap-priority-queue", "radix-sort", "quickselect"]}, "language": "python", "interface": {"raw_signature": "def smallestTrimmedNumbers(self, nums: list[str], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "smallestTrimmedNumbers", "parameters": [{"name": "nums", "type": "list[str]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2344, "task_id": "minimum-deletions-to-make-array-divisible", "difficulty": "Hard", "problem_description": "You are given two positive integer arrays nums and numsDivide. You can delete any number of elements from nums.\n\nReturn the minimum number of deletions such that the smallest element in nums divides all the elements of numsDivide. If this is not possible, return -1.\n\nNote that an integer x divides y if y % x == 0.\n\nExample 1:\n\nInput: nums = [2,3,2,4,3], numsDivide = [9,6,9,3,15]\nOutput: 2\nExplanation:\nThe smallest element in [2,3,2,4,3] is 2, which does not divide all the elements of numsDivide.\nWe use 2 deletions to delete the elements in nums that are equal to 2 which makes nums = [3,4,3].\nThe smallest element in [3,4,3] is 3, which divides all the elements of numsDivide.\nIt can be shown that 2 is the minimum number of deletions needed.\n\nExample 2:\n\nInput: nums = [4,3,6], numsDivide = [8,2,6,10]\nOutput: -1\nExplanation:\nWe want the smallest element in nums to divide all the elements of numsDivide.\nThere is no way to delete elements from nums to allow this.\n\nConstraints:\n\n- 1 <= nums.length, numsDivide.length <= 10^5\n- 1 <= nums[i], numsDivide[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 2, 3, 4, 5],numsDivide = [10, 20, 30, 40, 50]) == 0\n    assert candidate(nums = [5, 10, 15, 20],numsDivide = [5, 15, 25, 35]) == 0\n    assert candidate(nums = [1, 3, 5, 7],numsDivide = [2, 4, 6, 8]) == 0\n    assert candidate(nums = [10, 20, 30],numsDivide = [5, 10, 15]) == -1\n    assert candidate(nums = [5, 5, 5, 5],numsDivide = [5, 5, 5, 5]) == 0\n    assert candidate(nums = [3, 5, 7, 9],numsDivide = [15, 30, 45, 60]) == 0\n    assert candidate(nums = [2, 4, 6, 8],numsDivide = [2, 4, 6, 8]) == 0\n    assert candidate(nums = [5, 10, 15, 20],numsDivide = [10, 20, 30, 40]) == 0\n    assert candidate(nums = [5, 7, 10],numsDivide = [14, 35, 70]) == 1\n    assert candidate(nums = [2, 4, 8, 16],numsDivide = [1, 2, 3, 4]) == -1\n    assert candidate(nums = [3, 5, 6, 8, 9],numsDivide = [30, 45, 60]) == 0\n    assert candidate(nums = [1, 2, 3, 4],numsDivide = [2, 4, 6, 8]) == 0\n    assert candidate(nums = [4, 3, 6],numsDivide = [8, 2, 6, 10]) == -1\n    assert candidate(nums = [3, 9, 7, 3],numsDivide = [9, 18, 90, 72]) == 0\n    assert candidate(nums = [2, 3, 2, 4, 3],numsDivide = [9, 6, 9, 3, 15]) == 2\n    assert candidate(nums = [1],numsDivide = [1]) == 0\n    assert candidate(nums = [3, 6, 9, 12],numsDivide = [3, 6, 9, 12]) == 0\n    assert candidate(nums = [3, 6, 9, 12, 15],numsDivide = [27, 54, 81, 108]) == 0\n    assert candidate(nums = [2, 4, 6, 8, 10],numsDivide = [20, 40, 60, 80, 100]) == 0\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81],numsDivide = [162, 324, 486, 648]) == 0\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],numsDivide = [84, 168, 252]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25],numsDivide = [100, 200, 300]) == 0\n    assert candidate(nums = [17, 34, 51, 68],numsDivide = [34, 68, 102, 136, 170]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],numsDivide = [15, 30, 45, 60, 75]) == 0\n    assert candidate(nums = [8, 16, 32, 64, 128],numsDivide = [256, 512, 1024, 2048]) == 0\n    assert candidate(nums = [7, 14, 21, 28, 35],numsDivide = [49, 98, 147, 196]) == 0\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19],numsDivide = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == -1\n    assert candidate(nums = [4, 8, 12, 16, 20],numsDivide = [8, 16, 24, 32, 40, 48, 56]) == 0\n    assert candidate(nums = [9, 18, 27, 36, 45],numsDivide = [18, 36, 54, 72]) == 0\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],numsDivide = [18, 36, 54, 72, 90]) == 0\n    assert candidate(nums = [21, 42, 63, 84],numsDivide = [42, 84, 126, 168, 210]) == 0\n    assert candidate(nums = [2, 4, 8, 16, 32, 64, 128],numsDivide = [256, 512, 1024, 2048]) == 0\n    assert candidate(nums = [3, 9, 27, 81, 243],numsDivide = [81, 243, 729, 2187]) == 0\n    assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40],numsDivide = [4, 8, 12, 16, 20]) == 0\n    assert candidate(nums = [2, 4, 6, 8, 10, 12],numsDivide = [24, 48, 72, 96]) == 0\n    assert candidate(nums = [3, 6, 9, 12],numsDivide = [18, 24, 30, 36, 42]) == 0\n    assert candidate(nums = [13, 26, 39, 52],numsDivide = [260, 390, 520]) == 0\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],numsDivide = [30, 45, 60, 75]) == -1\n    assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64],numsDivide = [192, 384, 576, 768]) == 0\n    assert candidate(nums = [12, 15, 18, 21],numsDivide = [36, 54, 72, 90]) == 2\n    assert candidate(nums = [7, 11, 13, 17],numsDivide = [14, 22, 26, 34]) == -1\n    assert candidate(nums = [1, 2, 3, 5, 7, 11, 13],numsDivide = [2, 3, 5, 7, 11, 13]) == 0\n    assert candidate(nums = [13, 26, 39, 52, 65],numsDivide = [260, 390, 520, 650]) == 0\n    assert candidate(nums = [31, 37, 41, 43, 47],numsDivide = [93, 121, 143, 187]) == -1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],numsDivide = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n    assert candidate(nums = [7, 14, 21, 28, 35],numsDivide = [14, 28, 42, 56]) == 0\n    assert candidate(nums = [11, 22, 33, 44, 55],numsDivide = [66, 132, 198, 264]) == 0\n    assert candidate(nums = [2, 5, 7, 10, 14],numsDivide = [4, 10, 14, 20]) == 0\n    assert candidate(nums = [13, 26, 39, 52, 65],numsDivide = [78, 156, 234, 312]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25],numsDivide = [100, 50, 25, 20]) == 0\n    assert candidate(nums = [31, 62, 93, 124, 155],numsDivide = [186, 372, 558, 744]) == 0\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],numsDivide = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == -1\n    assert candidate(nums = [101, 202, 303, 404],numsDivide = [202, 404, 606, 808, 1010]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25],numsDivide = [100, 200, 300, 400]) == 0\n    assert candidate(nums = [11, 22, 33, 44, 55],numsDivide = [220, 330, 440, 550]) == 0\n    assert candidate(nums = [47, 94, 141, 188, 235],numsDivide = [282, 564, 846, 1128]) == 0\n    assert candidate(nums = [29, 58, 87, 116, 145],numsDivide = [174, 348, 522, 696]) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],numsDivide = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 0\n    assert candidate(nums = [9, 18, 27, 36],numsDivide = [27, 54, 81, 108, 135]) == 0\n    assert candidate(nums = [3, 6, 9, 12, 15],numsDivide = [27, 54, 81, 108]) == 0\n    assert candidate(nums = [11, 22, 33, 44, 55],numsDivide = [22, 44, 66, 88]) == 0\n    assert candidate(nums = [13, 26, 39, 52, 65],numsDivide = [78, 156, 234, 312]) == 0\n    assert candidate(nums = [3, 5, 7, 11, 13],numsDivide = [15, 21, 35, 77]) == -1\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],numsDivide = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n    assert candidate(nums = [18, 27, 36, 45, 54],numsDivide = [54, 108, 162, 216]) == 0\n    assert candidate(nums = [3, 6, 9, 12, 15],numsDivide = [18, 36, 54, 72]) == 0\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],numsDivide = [60, 105, 140, 231]) == -1\n    assert candidate(nums = [100, 200, 300, 400, 500],numsDivide = [1000, 2000, 3000, 4000]) == 0\n    assert candidate(nums = [7, 14, 28, 35],numsDivide = [28, 56, 84, 112]) == 0\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000],numsDivide = [1000000000, 500000000, 250000000, 125000000]) == 0\n    assert candidate(nums = [2, 4, 6, 8, 10],numsDivide = [12, 18, 24, 30, 36]) == 0\n    assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909],numsDivide = [1010, 2020, 3030]) == 0\n    assert candidate(nums = [17, 34, 51, 68, 85],numsDivide = [102, 204, 306, 408]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25],numsDivide = [50, 75, 100]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numsDivide = [100, 200, 300, 400, 500]) == 0\n    assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],numsDivide = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == -1\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104],numsDivide = [104, 208, 312]) == 0\n    assert candidate(nums = [2, 4, 6, 8, 10],numsDivide = [12, 18, 24, 30]) == 0\n    assert candidate(nums = [2, 3, 5, 7, 11],numsDivide = [2310, 4620, 6930, 9240]) == 0\n    assert candidate(nums = [7, 14, 21, 28],numsDivide = [42, 56, 70, 84]) == 0\n    assert candidate(nums = [30, 40, 50, 60, 70],numsDivide = [300, 600, 900, 1200]) == 0\n    assert candidate(nums = [18, 27, 36, 45],numsDivide = [162, 243, 324]) == 1\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],numsDivide = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n    assert candidate(nums = [11, 22, 33, 44, 55, 66],numsDivide = [132, 264, 396]) == 0\n    assert candidate(nums = [10, 15, 20, 25, 30],numsDivide = [100, 150, 200]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],numsDivide = [50, 100, 150, 200]) == 0\n    assert candidate(nums = [12, 15, 20, 25, 30],numsDivide = [60, 90, 120, 150]) == 1\n    assert candidate(nums = [7, 14, 21, 28, 35, 42],numsDivide = [420, 840, 1260, 1680]) == 0\n    assert candidate(nums = [7, 14, 28, 35, 42],numsDivide = [84, 168, 252, 336]) == 0\n    assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31],numsDivide = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == -1\n    assert candidate(nums = [23, 46, 69, 92, 115],numsDivide = [138, 207, 276, 345, 414]) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50],numsDivide = [25, 50, 75, 100]) == -1\n    assert candidate(nums = [2, 3, 5, 7, 11, 13],numsDivide = [30030, 60060, 90090, 120120]) == 0\n    assert candidate(nums = [12, 24, 36, 48],numsDivide = [60, 120, 180]) == 0\n    assert candidate(nums = [43, 86, 129, 172, 215],numsDivide = [258, 387, 516, 645, 774]) == 0\n    assert candidate(nums = [7, 14, 21, 28, 35],numsDivide = [42, 56, 70, 84]) == 0\n    assert candidate(nums = [11, 22, 33, 44, 55],numsDivide = [220, 330, 440, 550, 660]) == 0\n    assert candidate(nums = [2, 4, 6, 8, 10],numsDivide = [3, 5, 7, 9, 11]) == -1\n    assert candidate(nums = [2, 2, 2, 2, 2],numsDivide = [4, 6, 8, 10]) == 0\n    assert candidate(nums = [8, 16, 24, 32, 40],numsDivide = [40, 80, 120, 160]) == 0\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65],numsDivide = [165, 330, 495]) == 0\n    assert candidate(nums = [43, 86, 129, 172, 215],numsDivide = [258, 516, 774, 1032]) == 0\n    assert candidate(nums = [10, 15, 20, 25, 30],numsDivide = [150, 300, 450, 600, 750]) == 0\n    assert candidate(nums = [3, 6, 9, 12, 15, 18],numsDivide = [180, 360, 540, 720, 900]) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50],numsDivide = [100, 200, 300, 400, 500]) == 0\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19],numsDivide = [13, 17, 19, 29, 31]) == -1\n    assert candidate(nums = [1001, 2002, 3003, 4004],numsDivide = [2002, 4004, 6006, 8008, 10010]) == 0\n    assert candidate(nums = [9, 18, 27, 36, 45],numsDivide = [108, 162, 216, 270, 324]) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],numsDivide = [20, 40, 60, 80, 100]) == 0\n    assert candidate(nums = [13, 26, 39, 52, 65],numsDivide = [78, 130, 195, 260, 325]) == 0\n    assert candidate(nums = [3, 6, 9, 12],numsDivide = [36, 72, 108]) == 0\n    assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23],numsDivide = [2310, 4620, 6930, 9240]) == 0\n    assert candidate(nums = [3, 9, 12, 18],numsDivide = [27, 54, 81, 108]) == 0\n    assert candidate(nums = [5, 15, 25, 35, 45],numsDivide = [75, 150, 225, 300]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25],numsDivide = [50, 100, 150, 200]) == 0\n    assert candidate(nums = [11, 22, 33, 44, 55],numsDivide = [110, 220, 330, 440, 550]) == 0\n    assert candidate(nums = [37, 74, 111, 148, 185],numsDivide = [238, 357, 476, 595, 714]) == -1\n    assert candidate(nums = [31, 62, 93, 124, 155],numsDivide = [186, 279, 372, 465, 558]) == 0\n    assert candidate(nums = [41, 82, 123, 164, 205],numsDivide = [246, 369, 492, 615, 738]) == 0\n    assert candidate(nums = [13, 26, 39, 52, 65, 78],numsDivide = [156, 195, 260, 390]) == 0\n    assert candidate(nums = [7, 14, 21, 28, 35],numsDivide = [49, 98, 147, 196]) == 0\n    assert candidate(nums = [7, 14, 21, 28],numsDivide = [42, 56, 70]) == 0\n    assert candidate(nums = [30, 60, 90, 120, 150, 180],numsDivide = [300, 600, 900, 1200]) == 0\n    assert candidate(nums = [5, 15, 25, 35],numsDivide = [25, 50, 75, 100, 125]) == 0\n    assert candidate(nums = [100, 200, 300, 400, 500],numsDivide = [150, 300, 450, 600]) == -1\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],numsDivide = [14, 28, 42, 56, 70]) == 0\n    assert candidate(nums = [13, 26, 39, 52],numsDivide = [26, 52, 78, 104, 130]) == 0\n    assert candidate(nums = [17, 34, 51, 68, 85],numsDivide = [340, 680, 1020, 1360]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25],numsDivide = [50, 100, 150, 200]) == 0\n    assert candidate(nums = [7, 14, 21, 28, 35, 42],numsDivide = [14, 28, 42, 56, 70]) == 0\n    assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999],numsDivide = [1110, 2220, 3330]) == 0\n    assert candidate(nums = [1, 2, 3, 5, 7, 11],numsDivide = [105, 165, 231]) == 0\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63],numsDivide = [108, 162, 216, 270]) == 0\n    assert candidate(nums = [13, 26, 39, 52, 65],numsDivide = [26, 52, 78, 104]) == 0\n    assert candidate(nums = [11, 22, 33, 44, 55],numsDivide = [66, 77, 88, 99]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25, 30],numsDivide = [60, 120, 180, 240]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25],numsDivide = [50, 100, 150, 200, 250]) == 0\n    assert candidate(nums = [100, 200, 300, 400],numsDivide = [500, 1000, 1500]) == 0\n    assert candidate(nums = [37, 74, 111, 148, 185],numsDivide = [222, 444, 666, 888]) == 0\n    assert candidate(nums = [29, 58, 87, 116, 145],numsDivide = [174, 261, 348, 435, 522]) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50],numsDivide = [10, 20, 30, 40, 50]) == 0\n    assert candidate(nums = [8, 16, 24, 32, 40],numsDivide = [100, 200, 300, 400]) == -1\n    assert candidate(nums = [23, 46, 69, 92, 115],numsDivide = [138, 276, 414, 552]) == 0\n    assert candidate(nums = [19, 38, 57, 76, 95],numsDivide = [114, 190, 285, 380, 475]) == 0\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],numsDivide = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == -1\n    assert candidate(nums = [19, 38, 57, 76, 95],numsDivide = [114, 228, 342, 456]) == 0\n    assert candidate(nums = [10, 15, 20, 25],numsDivide = [100, 200, 300]) == 0\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],numsDivide = [12, 24, 36, 48, 60]) == 0\n    assert candidate(nums = [11, 22, 33, 44],numsDivide = [22, 44, 66, 88, 110]) == 0\n    assert candidate(nums = [2, 4, 6, 8, 10],numsDivide = [24, 36, 48, 60]) == 0\n    assert candidate(nums = [17, 23, 31, 37, 41, 43],numsDivide = [51, 68, 85]) == 0\n    assert candidate(nums = [8, 16, 24, 32, 40],numsDivide = [16, 32, 48, 64, 80, 96]) == 0\n    assert candidate(nums = [19, 38, 57, 76],numsDivide = [38, 76, 114, 152, 190]) == 0\n    assert candidate(nums = [41, 82, 123, 164, 205],numsDivide = [246, 492, 738, 984]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1],numsDivide = [1]) == 0\n    assert candidate(nums = [7, 14, 21, 28, 35],numsDivide = [42, 56, 84, 98, 140]) == 0\n    assert candidate(nums = [6, 12, 18, 24, 30],numsDivide = [12, 24, 36, 48, 60, 72]) == 0\n", "comparison": "exact"}, "public_tests": ["[2,3,2,4,3]\n[9,6,9,3,15]", "[4,3,6]\n[8,2,6,10]"], "hints": ["How can we find an integer x that divides all the elements of numsDivide?", "Will finding GCD (Greatest Common Divisor) help here?"], "metadata": {"canonical_parameter_names": ["nums", "numsDivide"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:29+00:00", "tests_total": 158, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "math", "sorting", "heap-priority-queue", "number-theory", "euclidean-algorithm", "greatest-common-divisor"]}, "language": "python", "interface": {"raw_signature": "def minOperations(self, nums: list[int], numsDivide: list[int]) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "numsDivide", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2347, "task_id": "best-poker-hand", "difficulty": "Easy", "problem_description": "You are given an integer array ranks and a character array suits. You have 5 cards where the i^th card has a rank of ranks[i] and a suit of suits[i].\n\nThe following are the types of poker hands you can make from best to worst:\n\n1. \"Flush\": Five cards of the same suit.\n2. \"Three of a Kind\": Three cards of the same rank.\n3. \"Pair\": Two cards of the same rank.\n4. \"High Card\": Any single card.\n\nReturn a string representing the best type of poker hand you can make with the given cards.\n\nNote that the return values are case-sensitive.\n\nExample 1:\n\nInput: ranks = [13,2,3,1,9], suits = [\"a\",\"a\",\"a\",\"a\",\"a\"]\nOutput: \"Flush\"\nExplanation: The hand with all the cards consists of 5 cards with the same suit, so we have a \"Flush\".\n\nExample 2:\n\nInput: ranks = [4,4,2,4,4], suits = [\"d\",\"a\",\"a\",\"b\",\"c\"]\nOutput: \"Three of a Kind\"\nExplanation: The hand with the first, second, and fourth card consists of 3 cards with the same rank, so we have a \"Three of a Kind\".\nNote that we could also make a \"Pair\" hand but \"Three of a Kind\" is a better hand.\nAlso note that other cards could be used to make the \"Three of a Kind\" hand.\n\nExample 3:\n\nInput: ranks = [10,10,2,12,9], suits = [\"a\",\"b\",\"c\",\"a\",\"d\"]\nOutput: \"Pair\"\nExplanation: The hand with the first and second card consists of 2 cards with the same rank, so we have a \"Pair\".\nNote that we cannot make a \"Flush\" or a \"Three of a Kind\".\n\nConstraints:\n\n- ranks.length == suits.length == 5\n- 1 <= ranks[i] <= 13\n- 'a' <= suits[i] <= 'd'\n- No two cards have the same rank and suit.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(ranks = [7, 7, 7, 8, 9],suits = ['a', 'b', 'c', 'a', 'd']) == \"Three of a Kind\"\n    assert candidate(ranks = [10, 10, 2, 12, 9],suits = ['a', 'b', 'c', 'a', 'd']) == \"Pair\"\n    assert candidate(ranks = [7, 7, 7, 7, 7],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [1, 2, 3, 4, 5],suits = ['a', 'b', 'c', 'd', 'a']) == \"High Card\"\n    assert candidate(ranks = [13, 2, 3, 1, 9],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n    assert candidate(ranks = [2, 3, 4, 5, 6],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n    assert candidate(ranks = [11, 11, 12, 12, 13],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n    assert candidate(ranks = [4, 4, 2, 4, 4],suits = ['d', 'a', 'a', 'b', 'c']) == \"Three of a Kind\"\n    assert candidate(ranks = [10, 10, 11, 11, 12],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n    assert candidate(ranks = [6, 6, 6, 7, 7],suits = ['d', 'd', 'd', 'c', 'c']) == \"Three of a Kind\"\n    assert candidate(ranks = [8, 8, 8, 9, 10],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [5, 6, 7, 8, 9],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n    assert candidate(ranks = [5, 5, 6, 6, 7],suits = ['a', 'b', 'a', 'b', 'a']) == \"Pair\"\n    assert candidate(ranks = [6, 6, 7, 7, 8],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n    assert candidate(ranks = [1, 2, 3, 3, 3],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [4, 4, 5, 5, 6],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n    assert candidate(ranks = [9, 9, 9, 9, 9],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n    assert candidate(ranks = [1, 2, 3, 4, 4],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n    assert candidate(ranks = [8, 8, 9, 9, 10],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n    assert candidate(ranks = [10, 11, 12, 13, 13],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n    assert candidate(ranks = [6, 6, 6, 7, 8],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [10, 10, 10, 12, 13],suits = ['a', 'b', 'c', 'a', 'b']) == \"Three of a Kind\"\n    assert candidate(ranks = [8, 8, 9, 9, 10],suits = ['a', 'a', 'b', 'b', 'c']) == \"Pair\"\n    assert candidate(ranks = [3, 3, 3, 8, 8],suits = ['a', 'b', 'c', 'a', 'b']) == \"Three of a Kind\"\n    assert candidate(ranks = [13, 13, 13, 13, 1],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [6, 6, 6, 7, 8],suits = ['a', 'a', 'a', 'b', 'c']) == \"Three of a Kind\"\n    assert candidate(ranks = [1, 1, 2, 3, 4],suits = ['a', 'a', 'b', 'c', 'd']) == \"Pair\"\n    assert candidate(ranks = [13, 13, 13, 13, 13],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [9, 9, 10, 11, 12],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n    assert candidate(ranks = [8, 8, 10, 10, 10],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [3, 3, 3, 4, 4],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [6, 6, 6, 6, 6],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n    assert candidate(ranks = [8, 8, 8, 9, 9],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [1, 2, 3, 4, 5],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n    assert candidate(ranks = [5, 5, 5, 5, 10],suits = ['a', 'a', 'a', 'a', 'b']) == \"Three of a Kind\"\n    assert candidate(ranks = [7, 8, 9, 10, 11],suits = ['a', 'b', 'c', 'd', 'a']) == \"High Card\"\n    assert candidate(ranks = [13, 12, 11, 10, 9],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n    assert candidate(ranks = [5, 5, 5, 6, 7],suits = ['a', 'b', 'c', 'a', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [6, 6, 6, 7, 8],suits = ['b', 'b', 'b', 'c', 'd']) == \"Three of a Kind\"\n    assert candidate(ranks = [1, 2, 3, 4, 5],suits = ['a', 'a', 'b', 'b', 'c']) == \"High Card\"\n    assert candidate(ranks = [6, 6, 7, 7, 8],suits = ['a', 'a', 'b', 'b', 'c']) == \"Pair\"\n    assert candidate(ranks = [2, 2, 2, 2, 2],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [13, 13, 2, 3, 4],suits = ['a', 'b', 'a', 'b', 'a']) == \"Pair\"\n    assert candidate(ranks = [6, 6, 6, 6, 7],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [11, 11, 12, 12, 13],suits = ['a', 'a', 'b', 'b', 'c']) == \"Pair\"\n    assert candidate(ranks = [10, 10, 11, 11, 12],suits = ['a', 'b', 'a', 'b', 'a']) == \"Pair\"\n    assert candidate(ranks = [5, 6, 7, 8, 9],suits = ['a', 'b', 'c', 'd', 'a']) == \"High Card\"\n    assert candidate(ranks = [8, 8, 8, 8, 2],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n    assert candidate(ranks = [1, 2, 3, 4, 5],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n    assert candidate(ranks = [1, 1, 2, 3, 4],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n    assert candidate(ranks = [2, 3, 4, 5, 6],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n    assert candidate(ranks = [5, 5, 5, 6, 7],suits = ['a', 'a', 'a', 'b', 'c']) == \"Three of a Kind\"\n    assert candidate(ranks = [2, 2, 3, 4, 5],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n    assert candidate(ranks = [7, 8, 9, 10, 11],suits = ['a', 'b', 'c', 'd', 'a']) == \"High Card\"\n    assert candidate(ranks = [1, 2, 3, 4, 5],suits = ['a', 'b', 'c', 'd', 'a']) == \"High Card\"\n    assert candidate(ranks = [9, 9, 10, 10, 11],suits = ['a', 'b', 'a', 'b', 'c']) == \"Pair\"\n    assert candidate(ranks = [3, 3, 4, 4, 5],suits = ['a', 'a', 'b', 'b', 'c']) == \"Pair\"\n    assert candidate(ranks = [9, 9, 9, 9, 10],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [7, 8, 9, 10, 11],suits = ['a', 'a', 'a', 'a', 'a']) == \"Flush\"\n    assert candidate(ranks = [1, 1, 2, 2, 3],suits = ['a', 'b', 'c', 'd', 'a']) == \"Pair\"\n    assert candidate(ranks = [9, 9, 9, 9, 9],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [2, 2, 2, 2, 3],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [13, 13, 13, 1, 1],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [5, 5, 10, 10, 10],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [3, 3, 5, 5, 7],suits = ['a', 'b', 'a', 'b', 'a']) == \"Pair\"\n    assert candidate(ranks = [12, 12, 13, 13, 13],suits = ['a', 'b', 'c', 'd', 'a']) == \"Three of a Kind\"\n    assert candidate(ranks = [1, 2, 3, 4, 5],suits = ['a', 'a', 'a', 'a', 'd']) == \"High Card\"\n", "comparison": "exact"}, "public_tests": ["[13,2,3,1,9]\n[\"a\",\"a\",\"a\",\"a\",\"a\"]", "[4,4,2,4,4]\n[\"d\",\"a\",\"a\",\"b\",\"c\"]", "[10,10,2,12,9]\n[\"a\",\"b\",\"c\",\"a\",\"d\"]"], "hints": ["Sequentially check the conditions 1 through 4, and return the outcome corresponding to the first met condition."], "metadata": {"canonical_parameter_names": ["ranks", "suits"], "leetcode_dataset_entry_point": "Solution().bestHand", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:33+00:00", "tests_total": 100, "tests_dropped": 33, "flags": [], "topic_tags": ["array", "hash-table", "counting"]}, "language": "python", "interface": {"raw_signature": "def bestHand(self, ranks: list[int], suits: list[str]) -> str:", "container": "Solution", "callable": "bestHand", "parameters": [{"name": "ranks", "type": "list[int]"}, {"name": "suits", "type": "list[str]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2348, "task_id": "number-of-zero-filled-subarrays", "difficulty": "Medium", "problem_description": "Given an integer array nums, return the number of subarrays filled with 0.\n\nA subarray is a contiguous non-empty sequence of elements within an array.\n\nExample 1:\n\nInput: nums = [1,3,0,0,2,0,0,4]\nOutput: 6\nExplanation:\nThere are 4 occurrences of [0] as a subarray.\nThere are 2 occurrences of [0,0] as a subarray.\nThere is no occurrence of a subarray with a size more than 2 filled with 0. Therefore, we return 6.\n\nExample 2:\n\nInput: nums = [0,0,0,2,0,0]\nOutput: 9\nExplanation:\nThere are 5 occurrences of [0] as a subarray.\nThere are 3 occurrences of [0,0] as a subarray.\nThere is 1 occurrence of [0,0,0] as a subarray.\nThere is no occurrence of a subarray with a size more than 3 filled with 0. Therefore, we return 9.\n\nExample 3:\n\nInput: nums = [2,10,2019]\nOutput: 0\nExplanation: There is no subarray filled with 0. Therefore, we return 0.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- -10^9 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 45\n    assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 1\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 55\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 2\n    assert candidate(nums = [1, 0, 1, 0, 1]) == 2\n    assert candidate(nums = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]) == 30\n    assert candidate(nums = [1, 3, 0, 0, 2, 0, 0, 4]) == 6\n    assert candidate(nums = [1]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 1\n    assert candidate(nums = [5, 0, 0, 0, 0, 0, 0, 5]) == 21\n    assert candidate(nums = [5, 6, 7, 8, 9]) == 0\n    assert candidate(nums = [0, 0, 0, 2, 0, 0]) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n    assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 45\n    assert candidate(nums = [2, 10, 2019]) == 0\n    assert candidate(nums = [0]) == 1\n    assert candidate(nums = [1, 0, 1, 0, 1, 0]) == 3\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0]) == 4\n    assert candidate(nums = [0, 0, 0, 0]) == 10\n    assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0]) == 9\n    assert candidate(nums = [5, 4, 3, 2, 1, 0]) == 1\n    assert candidate(nums = [0, 1, 0, 2, 0, 3, 0]) == 4\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1]) == 3\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 0, 0]) == 8\n    assert candidate(nums = [10, 20, 30, 0, 0, 0, 40, 50, 60, 0, 0, 70]) == 9\n    assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 18\n    assert candidate(nums = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 7]) == 52\n    assert candidate(nums = [1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0]) == 37\n    assert candidate(nums = [999999999, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 190\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 300\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 7\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 210\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0]) == 63\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 175\n    assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == 30\n    assert candidate(nums = [1000000000, 0, 0, 0, -1000000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 502\n    assert candidate(nums = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0]) == 45\n    assert candidate(nums = [0, 0, 0, 1, 1, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0]) == 37\n    assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 0, 0, 0]) == 19\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14]) == 45\n    assert candidate(nums = [100, 0, 0, 0, 0, 0, 200, 0, 0, 0, 300, 0, 0, 0, 400, 0, 0, 0, 500]) == 33\n    assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 39\n    assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0]) == 50\n    assert candidate(nums = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]) == 45\n    assert candidate(nums = [10, 0, 0, 10, 0, 10, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0]) == 38\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 2850\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 8\n    assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == 6\n    assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == 54\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1596\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == 5\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1891\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 22\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 780\n    assert candidate(nums = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 0, 0, 0, 0]) == 76\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 990\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000000000]) == 325\n    assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10]) == 10\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1275\n    assert candidate(nums = [9, 0, 0, 8, 0, 0, 7, 0, 0, 6, 0, 0, 5, 0, 0, 4, 0, 0, 3, 0, 0, 2, 0, 0, 1, 0]) == 25\n    assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5]) == 5\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 13\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 171\n    assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == 12\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 4753\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 0, 4, 0, 0, 0, 5]) == 11\n    assert candidate(nums = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 34\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 5\n    assert candidate(nums = [999999999, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -999999999]) == 190\n    assert candidate(nums = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 10]) == 42\n    assert candidate(nums = [1, 2, 3, 0, 0, 0, 4, 5, 0, 0, 6, 7, 0, 0, 0, 0, 8]) == 19\n    assert candidate(nums = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5]) == 25\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 10\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 15\n    assert candidate(nums = [1000000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 300\n    assert candidate(nums = [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0, 8, 0, 0, 0, 9, 0, 0, 0]) == 54\n    assert candidate(nums = [0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0]) == 22\n    assert candidate(nums = [0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0]) == 15\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 55\n    assert candidate(nums = [1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 5]) == 60\n    assert candidate(nums = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 210\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0]) == 84\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 325\n    assert candidate(nums = [9, 0, 0, 0, 0, 8, 0, 0, 7, 0, 0, 0, 6, 0, 5, 0, 0, 4, 0, 0, 0, 3, 0, 0, 2, 0, 0, 1, 0]) == 36\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 106\n    assert candidate(nums = [0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0]) == 12\n    assert candidate(nums = [5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == 21\n    assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]) == 34\n    assert candidate(nums = [1, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0]) == 34\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0]) == 9\n    assert candidate(nums = [0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]) == 62\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 496\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000000000, 1000000000, 1000000000]) == 153\n    assert candidate(nums = [1, 0, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 0, 5, 0, 0, 6, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 9]) == 67\n    assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 0, 0, 0, 0]) == 38\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 595\n    assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 9\n    assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 2, 2, 2, 0, 0, 0, 3, 3, 3, 0, 0, 0]) == 24\n", "comparison": "exact"}, "public_tests": ["[1,3,0,0,2,0,0,4]", "[0,0,0,2,0,0]", "[2,10,2019]"], "hints": ["For each zero, you can calculate the number of zero-filled subarrays that end on that index, which is the number of consecutive zeros behind the current element + 1.", "Maintain the number of consecutive zeros behind the current element, count the number of zero-filled subarrays that end on each index, sum it up to get the answer."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().zeroFilledSubarray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:36+00:00", "tests_total": 99, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "math"]}, "language": "python", "interface": {"raw_signature": "def zeroFilledSubarray(self, nums: list[int]) -> int:", "container": "Solution", "callable": "zeroFilledSubarray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2350, "task_id": "shortest-impossible-sequence-of-rolls", "difficulty": "Hard", "problem_description": "You are given an integer array rolls of length n and an integer k. You roll a k sided dice numbered from 1 to k, n times, where the result of the i^th roll is rolls[i].\n\nReturn the length of the shortest sequence of rolls so that there's no such subsequence in rolls.\n\nA sequence of rolls of length len is the result of rolling a k sided dice len times.\n\nExample 1:\n\nInput: rolls = [4,2,1,2,3,3,2,4,1], k = 4\nOutput: 3\nExplanation: Every sequence of rolls of length 1, [1], [2], [3], [4], can be taken from rolls.\nEvery sequence of rolls of length 2, [1, 1], [1, 2], ..., [4, 4], can be taken from rolls.\nThe sequence [1, 4, 2] cannot be taken from rolls, so we return 3.\nNote that there are other sequences that cannot be taken from rolls.\n\nExample 2:\n\nInput: rolls = [1,1,2,2], k = 2\nOutput: 2\nExplanation: Every sequence of rolls of length 1, [1], [2], can be taken from rolls.\nThe sequence [2, 1] cannot be taken from rolls, so we return 2.\nNote that there are other sequences that cannot be taken from rolls but [2, 1] is the shortest.\n\nExample 3:\n\nInput: rolls = [1,1,3,2,2,2,3,3], k = 4\nOutput: 1\nExplanation: The sequence [4] cannot be taken from rolls, so we return 1.\nNote that there are other sequences that cannot be taken from rolls but [4] is the shortest.\n\nConstraints:\n\n- n == rolls.length\n- 1 <= n <= 10^5\n- 1 <= rolls[i] <= k <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 2\n    assert candidate(rolls = [1, 1, 1, 1, 1],k = 1) == 6\n    assert candidate(rolls = [1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 4\n    assert candidate(rolls = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1],k = 6) == 3\n    assert candidate(rolls = [1, 1, 3, 2, 2, 2, 3, 3],k = 4) == 1\n    assert candidate(rolls = [1, 1, 2, 2],k = 2) == 2\n    assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 11\n    assert candidate(rolls = [1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 3\n    assert candidate(rolls = [4, 2, 1, 2, 3, 3, 2, 4, 1],k = 4) == 3\n    assert candidate(rolls = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 4\n    assert candidate(rolls = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10) == 1\n    assert candidate(rolls = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 1\n    assert candidate(rolls = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 3\n    assert candidate(rolls = [1],k = 1) == 2\n    assert candidate(rolls = [5, 5, 5, 5, 5],k = 5) == 1\n    assert candidate(rolls = [5, 4, 3, 2, 1],k = 5) == 2\n    assert candidate(rolls = [1, 2, 3, 4, 5],k = 5) == 2\n    assert candidate(rolls = [1, 3, 2, 3, 2, 1],k = 3) == 3\n    assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 9\n    assert candidate(rolls = [5, 1, 3, 4, 2, 5, 1, 3, 4, 2, 5, 1, 3, 4, 2],k = 5) == 4\n    assert candidate(rolls = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 2, 2, 3, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 9\n    assert candidate(rolls = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 5\n    assert candidate(rolls = [1, 2, 3, 4, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],k = 6) == 3\n    assert candidate(rolls = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 18\n    assert candidate(rolls = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 100000) == 1\n    assert candidate(rolls = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 2\n    assert candidate(rolls = [1, 2, 3, 4, 4, 3, 2, 1, 1, 2, 3, 4, 4, 3, 2, 1],k = 4) == 5\n    assert candidate(rolls = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 8\n    assert candidate(rolls = [1, 2, 1, 3, 2, 1, 4, 2, 1, 3, 4, 2, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 1, 4, 2, 1, 3, 4, 2, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 1, 4, 2, 1, 3, 4, 2, 1, 3, 2, 4],k = 4) == 12\n    assert candidate(rolls = [3, 1, 2, 1, 3, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 10\n    assert candidate(rolls = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],k = 5) == 5\n    assert candidate(rolls = [5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 10\n    assert candidate(rolls = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 3\n    assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 6\n    assert candidate(rolls = [1, 2, 2, 1, 3, 1, 2, 3, 4, 2, 1, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],k = 6) == 3\n    assert candidate(rolls = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 4) == 2\n    assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 5\n    assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],k = 10) == 3\n    assert candidate(rolls = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 2\n    assert candidate(rolls = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 10) == 2\n    assert candidate(rolls = [5, 5, 5, 5, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 5\n    assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 3\n    assert candidate(rolls = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 12\n    assert candidate(rolls = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 5) == 2\n    assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 8\n    assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 30) == 3\n    assert candidate(rolls = [5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2],k = 5) == 4\n    assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 35\n    assert candidate(rolls = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 5) == 5\n    assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1],k = 15) == 3\n    assert candidate(rolls = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 4\n    assert candidate(rolls = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7],k = 7) == 2\n    assert candidate(rolls = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 6\n    assert candidate(rolls = [1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 4],k = 4) == 6\n    assert candidate(rolls = [1],k = 100000) == 1\n    assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 4\n    assert candidate(rolls = [2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4],k = 4) == 11\n    assert candidate(rolls = [5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4],k = 5) == 4\n    assert candidate(rolls = [1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 3\n    assert candidate(rolls = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 13\n    assert candidate(rolls = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 16\n    assert candidate(rolls = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 4\n    assert candidate(rolls = [1, 3, 2, 4, 2, 1, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 6\n    assert candidate(rolls = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 2) == 11\n    assert candidate(rolls = [7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1],k = 7) == 6\n    assert candidate(rolls = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 5) == 7\n    assert candidate(rolls = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 15) == 2\n    assert candidate(rolls = [1, 3, 3, 1, 2, 4, 4, 2, 3, 1, 4, 2, 3, 1, 2, 4, 4, 2, 3, 1, 4, 2, 3, 1, 2, 4, 4, 2, 3, 1, 4, 2, 3, 1, 2, 4, 4, 2, 3, 1, 4, 2, 3, 1, 2, 4],k = 4) == 10\n    assert candidate(rolls = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 1, 1, 2, 2, 3, 3],k = 6) == 2\n    assert candidate(rolls = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 5) == 5\n    assert candidate(rolls = [1, 2, 2, 1, 3, 3, 1, 2, 3, 4, 4, 1, 2, 3, 4, 5, 5, 1, 2, 3, 4, 5, 6, 6, 1, 2, 3, 4, 5, 6, 7, 7],k = 7) == 2\n    assert candidate(rolls = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 3\n    assert candidate(rolls = [3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4],k = 4) == 6\n    assert candidate(rolls = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 5) == 2\n    assert candidate(rolls = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6],k = 6) == 2\n    assert candidate(rolls = [1, 2, 3, 4, 5, 1, 2, 3, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2],k = 5) == 4\n    assert candidate(rolls = [7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7],k = 7) == 5\n    assert candidate(rolls = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 4\n    assert candidate(rolls = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 9\n    assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 3\n    assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 4) == 2\n    assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 16\n    assert candidate(rolls = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 5) == 12\n    assert candidate(rolls = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],k = 6) == 3\n    assert candidate(rolls = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 5) == 4\n    assert candidate(rolls = [1, 2, 2, 1, 3, 3, 3, 1, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 6\n    assert candidate(rolls = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 5) == 4\n    assert candidate(rolls = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],k = 3) == 16\n    assert candidate(rolls = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 9\n    assert candidate(rolls = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 12\n    assert candidate(rolls = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 11\n    assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 4\n    assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 4) == 2\n    assert candidate(rolls = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 10\n    assert candidate(rolls = [5, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4],k = 5) == 5\n    assert candidate(rolls = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 4\n    assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10],k = 20) == 2\n", "comparison": "exact"}, "public_tests": ["[4,2,1,2,3,3,2,4,1]\n4", "[1,1,2,2]\n2", "[1,1,3,2,2,2,3,3]\n4"], "hints": ["How can you find the minimum index such that all sequences of length 1 can be formed from the start until that index?", "Starting from the previous minimum index, what is the next index such that all sequences of length 2 can be formed?", "Can you extend the idea to sequences of length 3 and more?"], "metadata": {"canonical_parameter_names": ["rolls", "k"], "leetcode_dataset_entry_point": "Solution().shortestSequence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:38+00:00", "tests_total": 97, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "greedy"]}, "language": "python", "interface": {"raw_signature": "def shortestSequence(self, rolls: list[int], k: int) -> int:", "container": "Solution", "callable": "shortestSequence", "parameters": [{"name": "rolls", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2351, "task_id": "first-letter-to-appear-twice", "difficulty": "Easy", "problem_description": "Given a string s consisting of lowercase English letters, return the first letter to appear twice.\n\nNote:\n\n- A letter a appears twice before another letter b if the second occurrence of a is before the second occurrence of b.\n- s will contain at least one letter that appears twice.\n\nExample 1:\n\nInput: s = \"abccbaacz\"\nOutput: \"c\"\nExplanation:\nThe letter 'a' appears on the indexes 0, 5 and 6.\nThe letter 'b' appears on the indexes 1 and 4.\nThe letter 'c' appears on the indexes 2, 3 and 7.\nThe letter 'z' appears on the index 8.\nThe letter 'c' is the first letter to appear twice, because out of all the letters the index of its second occurrence is the smallest.\n\nExample 2:\n\nInput: s = \"abcdd\"\nOutput: \"d\"\nExplanation:\nThe only letter that appears twice is 'd' so we return 'd'.\n\nConstraints:\n\n- 2 <= s.length <= 100\n- s consists of lowercase English letters.\n- s has at least one repeated letter.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"alphabet\") == \"a\"\n    assert candidate(s = \"finding\") == \"i\"\n    assert candidate(s = \"xyzxyz\") == \"x\"\n    assert candidate(s = \"zabcdefghijkkl\") == \"k\"\n    assert candidate(s = \"first\") == None\n    assert candidate(s = \"second\") == None\n    assert candidate(s = \"abcdefghijkk\") == \"k\"\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaa\") == \"a\"\n    assert candidate(s = \"abcdefggh\") == \"g\"\n    assert candidate(s = \"mnopqrsstuvwxzyz\") == \"s\"\n    assert candidate(s = \"abccbaacz\") == \"c\"\n    assert candidate(s = \"interview\") == \"i\"\n    assert candidate(s = \"abcdefgah\") == \"a\"\n    assert candidate(s = \"abcdd\") == \"d\"\n    assert candidate(s = \"aabb\") == \"a\"\n    assert candidate(s = \"xyzabczy\") == \"z\"\n    assert candidate(s = \"xyzxyzxyz\") == \"x\"\n    assert candidate(s = \"example\") == \"e\"\n    assert candidate(s = \"repeated\") == \"e\"\n    assert candidate(s = \"occurrence\") == \"c\"\n    assert candidate(s = \"aabbccddeeff\") == \"a\"\n    assert candidate(s = \"aab\") == \"a\"\n    assert candidate(s = \"hello\") == \"l\"\n    assert candidate(s = \"aabbcc\") == \"a\"\n    assert candidate(s = \"abcdabc\") == \"a\"\n    assert candidate(s = \"characters\") == \"a\"\n    assert candidate(s = \"programming\") == \"r\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabc\") == \"a\"\n    assert candidate(s = \"abcdefghia\") == \"a\"\n    assert candidate(s = \"abcdefghijkklmno\") == \"k\"\n    assert candidate(s = \"onetimeonetimethisisaverylongstringwithsomerepeatedcharacters\") == \"e\"\n    assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmq\") == \"q\"\n    assert candidate(s = \"abcdefghijkabcdefghijklmnopqrstuvwxyz\") == \"a\"\n    assert candidate(s = \"findingthebestsolution\") == \"i\"\n    assert candidate(s = \"hellothereitisme\") == \"l\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"a\"\n    assert candidate(s = \"thisisareallylongstringtofindtherepeatedcharacter\") == \"i\"\n    assert candidate(s = \"abracadabra\") == \"a\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzz\") == \"z\"\n    assert candidate(s = \"ababababababababababababababababab\") == \"a\"\n    assert candidate(s = \"fasterthanlighttravels\") == \"t\"\n    assert candidate(s = \"abcdefghijabcdefghijabcdefghij\") == \"a\"\n    assert candidate(s = \"zzzzzzzzzz\") == \"z\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwxyzz\") == \"a\"\n    assert candidate(s = \"xyzzzyxzyxzyzyxzyxzyzyxzyxzyzyxzyxzyzyxzyxzyzyxzyxzyzyxzyxzyzyxz\") == \"z\"\n    assert candidate(s = \"characterscharacterscharacterszzzzzzz\") == \"a\"\n    assert candidate(s = \"abababababababababababababababab\") == \"a\"\n    assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == \"a\"\n    assert candidate(s = \"thisisareallylongstringwithsomerepeatedcharacters\") == \"i\"\n    assert candidate(s = \"thequickbrownfoxjumpsoverthelazydoggg\") == \"o\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab\") == \"a\"\n    assert candidate(s = \"repeatedcharacters\") == \"e\"\n    assert candidate(s = \"aquickbrownfoxjumpsoverthelazydogzzzzzzzzzzzzz\") == \"o\"\n    assert candidate(s = \"abcdefghijklmnopqrstuuvwxyzz\") == \"u\"\n    assert candidate(s = \"everyletterappearsatleasttwicemanytimes\") == \"e\"\n    assert candidate(s = \"abcabcabcabcabcabcabc\") == \"a\"\n    assert candidate(s = \"abcdefghijzabcdefghijzabcdefghijzabcdefghijzabcdefghijzabcdefghijz\") == \"a\"\n    assert candidate(s = \"uniqueabcunique\") == \"u\"\n    assert candidate(s = \"abcdefghijkmnopqrstuvwxyzabcde\") == \"a\"\n    assert candidate(s = \"mnopqrstuzyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == \"u\"\n    assert candidate(s = \"almostuniqueexceptfortheendzz\") == \"u\"\n    assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == \"a\"\n    assert candidate(s = \"alohafromhawaii\") == \"a\"\n    assert candidate(s = \"supercalifragilisticexpialidociouszzzz\") == \"r\"\n    assert candidate(s = \"vovelsaeiouaeiouaeiou\") == \"v\"\n    assert candidate(s = \"abcdefghijkabcdefghijk\") == \"a\"\n    assert candidate(s = \"manymanycharactersandcharacters\") == \"m\"\n    assert candidate(s = \"thisisthesentencewithrepeatedwords\") == \"i\"\n    assert candidate(s = \"charactersrepeatedoften\") == \"a\"\n    assert candidate(s = \"sometextwithrepeatedlettersss\") == \"e\"\n    assert candidate(s = \"abcdefghijklmnoab\") == \"a\"\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\") == \"a\"\n    assert candidate(s = \"abcdefghijkabcdefghijkabcdefghijk\") == \"a\"\n    assert candidate(s = \"encyclopedia\") == \"c\"\n    assert candidate(s = \"abcdefghijkllmnopqrstuvwxyz\") == \"l\"\n    assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzz\") == \"z\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n    assert candidate(s = \"mnopqrstuvwxyzabcdefghijklmno\") == \"m\"\n    assert candidate(s = \"repeatedcharacterintheendzz\") == \"e\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n    assert candidate(s = \"thelongestsubstringwithoutrepeatingcharactersxx\") == \"e\"\n    assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcde\") == \"a\"\n    assert candidate(s = \"abababababababababab\") == \"a\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n    assert candidate(s = \"abcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyza\") == \"a\"\n    assert candidate(s = \"mnopqrswxyzaabcdefgijkhl\") == \"a\"\n    assert candidate(s = \"mnopqrstuvwxyzaabcdefghijklmnopqrstuvwxyz\") == \"a\"\n    assert candidate(s = \"abacabadabacaba\") == \"a\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"a\"\n    assert candidate(s = \"overlappingcharactersababababababababa\") == \"p\"\n    assert candidate(s = \"abcdexyzzyxwvutsrqponmlkjihgfe\") == \"z\"\n    assert candidate(s = \"abcdefghijklaaabbbccc\") == \"a\"\n    assert candidate(s = \"testingtestingtesting\") == \"t\"\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaz\") == \"z\"\n    assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\") == \"q\"\n    assert candidate(s = \"abcdefghijkllmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"l\"\n    assert candidate(s = \"nestedcharactersandcharacters\") == \"e\"\n    assert candidate(s = \"elevenletters\") == \"e\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"a\"\n    assert candidate(s = \"tenletterstensletters\") == \"e\"\n    assert candidate(s = \"uniquecharacterherea\") == \"u\"\n    assert candidate(s = \"aquickbrownfoxjumpsoverthelazydogz\") == \"o\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n    assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\") == \"o\"\n    assert candidate(s = \"aaaabbbbccccdddd\") == \"a\"\n    assert candidate(s = \"abcdexyzabc\") == \"a\"\n    assert candidate(s = \"abcdefghef\") == \"e\"\n    assert candidate(s = \"abcdefghijjklmnopqrstuvwxyz\") == \"j\"\n    assert candidate(s = \"thisisaverylongstringwithseveralrepeatedcharacters\") == \"i\"\n    assert candidate(s = \"singleletterrepeatedmanytimesaaaaaaaaaaa\") == \"l\"\n    assert candidate(s = \"abcdefghijkla\") == \"a\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzba\") == \"b\"\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyx\") == \"z\"\n    assert candidate(s = \"aabccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"a\"\n    assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\") == \"o\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"a\"\n    assert candidate(s = \"verylongstringwithrepeatedcharactersqrs\") == \"r\"\n    assert candidate(s = \"repeatedcharacharactercharacter\") == \"e\"\n    assert candidate(s = \"programmingproblemsarefun\") == \"r\"\n    assert candidate(s = \"charactersrepeatedinrandomorderzzzzzzzzzz\") == \"a\"\n    assert candidate(s = \"thisproblemhasmanylettersrepeated\") == \"h\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzabcdefghijklmnopqrstuvwxyz\") == \"z\"\n    assert candidate(s = \"characterscharacterscharacterscharacters\") == \"a\"\n    assert candidate(s = \"mississippi\") == \"s\"\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbac\") == \"c\"\n    assert candidate(s = \"aaaaaaaaaaabbbbbbbbbbbccccccccccdddddddddd\") == \"a\"\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == \"z\"\n    assert candidate(s = \"aaaaabbbbbccccc\") == \"a\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n", "comparison": "exact"}, "public_tests": ["\"abccbaacz\"", "\"abcdd\""], "hints": ["Iterate through the string from left to right. Keep track of the elements you have already seen in a set.", "If the current element is already in the set, return that element."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().repeatedCharacter", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:40+00:00", "tests_total": 132, "tests_dropped": 3, "flags": [], "topic_tags": ["hash-table", "string", "bit-manipulation", "counting"]}, "language": "python", "interface": {"raw_signature": "def repeatedCharacter(self, s: str) -> str:", "container": "Solution", "callable": "repeatedCharacter", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2352, "task_id": "equal-row-and-column-pairs", "difficulty": "Medium", "problem_description": "Given a 0-indexed n x n integer matrix grid, return the number of pairs (r_i, c_j) such that row r_i and column c_j are equal.\n\nA row and column pair is considered equal if they contain the same elements in the same order (i.e., an equal array).\n\nExample 1:\n\nInput: grid = [[3,2,1],[1,7,6],[2,7,7]]\nOutput: 1\nExplanation: There is 1 equal row and column pair:\n- (Row 2, Column 1): [2,7,7]\n\nExample 2:\n\nInput: grid = [[3,1,2,2],[1,4,4,5],[2,4,2,2],[2,4,2,2]]\nOutput: 3\nExplanation: There are 3 equal row and column pairs:\n- (Row 0, Column 0): [3,1,2,2]\n- (Row 2, Column 2): [2,4,2,2]\n- (Row 3, Column 2): [2,4,2,2]\n\nConstraints:\n\n- n == grid.length == grid[i].length\n- 1 <= n <= 200\n- 1 <= grid[i][j] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 9\n    assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 9\n    assert candidate(grid = [[5]]) == 1\n    assert candidate(grid = [[3, 2, 1], [1, 7, 6], [2, 7, 7]]) == 1\n    assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == 16\n    assert candidate(grid = [[1, 2, 3], [3, 2, 1], [2, 1, 3]]) == 0\n    assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 16\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 0\n    assert candidate(grid = [[3, 1, 2, 2], [1, 4, 4, 5], [2, 4, 2, 2], [2, 4, 2, 2]]) == 3\n    assert candidate(grid = [[10, 20, 30], [30, 20, 10], [20, 10, 30]]) == 0\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1], [2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2], [2, 2, 2, 2, 2, 2]]) == 0\n    assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]]) == 36\n    assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5]]) == 49\n    assert candidate(grid = [[10, 20, 30, 40], [40, 30, 20, 10], [10, 30, 50, 70], [70, 50, 30, 10]]) == 0\n    assert candidate(grid = [[9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2], [5, 4, 3, 2, 1]]) == 5\n    assert candidate(grid = [[100000, 1, 2, 3], [1, 100000, 2, 3], [2, 1, 100000, 3], [3, 2, 1, 100000]]) == 1\n    assert candidate(grid = [[7, 8, 9, 10], [10, 9, 8, 7], [7, 7, 7, 7], [1, 2, 3, 4]]) == 0\n    assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]) == 5\n    assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == 4\n    assert candidate(grid = [[5, 1, 9, 1, 5], [1, 5, 1, 5, 1], [9, 1, 5, 1, 9], [1, 5, 1, 5, 1], [5, 1, 9, 1, 5]]) == 9\n    assert candidate(grid = [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]]) == 4\n    assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]]) == 4\n    assert candidate(grid = [[5, 6, 7, 8, 9], [9, 8, 7, 6, 5], [5, 5, 5, 5, 5], [1, 2, 3, 4, 5], [9, 7, 5, 3, 1]]) == 0\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 25\n    assert candidate(grid = [[7, 8, 9, 10], [8, 9, 10, 7], [9, 10, 7, 8], [10, 7, 8, 9]]) == 4\n    assert candidate(grid = [[100, 101, 102, 103, 104, 105], [105, 104, 103, 102, 101, 100], [100, 102, 104, 106, 108, 110], [110, 108, 106, 104, 102, 100], [101, 103, 105, 107, 109, 111], [111, 109, 107, 105, 103, 101]]) == 0\n    assert candidate(grid = [[1, 2, 1], [2, 1, 2], [1, 2, 1]]) == 5\n    assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 1, 1, 1, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2]]) == 0\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17], [17, 15, 13, 11, 9, 7, 5, 3, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 0\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]]) == 0\n    assert candidate(grid = [[7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7]]) == 36\n    assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]) == 5\n    assert candidate(grid = [[7, 8, 9], [9, 7, 8], [8, 9, 7]]) == 0\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [12, 11, 10, 9, 8, 7, 6, 5, 4, 3], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [13, 12, 11, 10, 9, 8, 7, 6, 5, 4], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 0\n    assert candidate(grid = [[1, 5, 9, 13], [2, 6, 10, 14], [3, 7, 11, 15], [4, 8, 12, 16]]) == 0\n    assert candidate(grid = [[1, 1, 2, 2], [2, 2, 1, 1], [1, 2, 1, 2], [2, 1, 2, 1]]) == 2\n    assert candidate(grid = [[1, 2, 1, 2], [2, 1, 2, 1], [1, 2, 1, 2], [2, 1, 2, 1]]) == 8\n    assert candidate(grid = [[12345, 67890, 54321], [67890, 54321, 12345], [54321, 12345, 67890]]) == 3\n    assert candidate(grid = [[11, 12, 13, 14], [15, 16, 17, 18], [19, 20, 21, 22], [14, 18, 22, 26]]) == 1\n    assert candidate(grid = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 10], [30, 40, 50, 10, 20], [40, 50, 10, 20, 30], [50, 10, 20, 30, 40]]) == 5\n    assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [2, 4, 6, 8, 10]]) == 0\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 1, 2, 1], [1, 3, 1, 3, 1], [1, 4, 1, 4, 1], [1, 5, 1, 5, 1]]) == 3\n    assert candidate(grid = [[100, 200, 300, 400], [200, 300, 400, 500], [300, 400, 500, 600], [400, 500, 600, 700]]) == 4\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 100\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 36\n    assert candidate(grid = [[9, 8, 7, 6], [8, 7, 6, 5], [7, 6, 5, 4], [6, 5, 4, 3]]) == 4\n    assert candidate(grid = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]) == 0\n    assert candidate(grid = [[11, 22, 33, 44, 55, 66], [66, 55, 44, 33, 22, 11], [11, 11, 11, 11, 11, 11], [22, 33, 44, 55, 66, 77], [77, 66, 55, 44, 33, 22], [22, 22, 22, 22, 22, 22]]) == 0\n    assert candidate(grid = [[5, 6, 7, 8, 9], [6, 7, 8, 9, 5], [7, 8, 9, 5, 6], [8, 9, 5, 6, 7], [9, 5, 6, 7, 8]]) == 5\n    assert candidate(grid = [[11, 22, 33, 44, 55], [55, 44, 33, 22, 11], [11, 33, 55, 77, 99], [99, 77, 55, 33, 11], [22, 44, 66, 88, 100]]) == 0\n    assert candidate(grid = [[4, 3, 2, 1], [1, 4, 3, 2], [2, 1, 4, 3], [3, 2, 1, 4]]) == 0\n    assert candidate(grid = [[100, 200, 300, 400, 500], [500, 400, 300, 200, 100], [100, 300, 500, 700, 900], [900, 700, 500, 300, 100], [100, 100, 100, 100, 100]]) == 0\n    assert candidate(grid = [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 2, 1], [1, 1, 1, 1]]) == 8\n    assert candidate(grid = [[1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1], [1, 1, 1, 2]]) == 4\n    assert candidate(grid = [[100000, 100000, 100000], [100000, 100000, 100000], [100000, 100000, 100000]]) == 9\n    assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [1, 1, 1, 1, 1]]) == 0\n    assert candidate(grid = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 3, 4, 1], [3, 4, 1, 2]]) == 0\n", "comparison": "exact"}, "public_tests": ["[[3,2,1],[1,7,6],[2,7,7]]", "[[3,1,2,2],[1,4,4,5],[2,4,2,2],[2,4,2,2]]"], "hints": ["We can use nested loops to compare every row against every column.", "Another loop is necessary to compare the row and column element by element.", "It is also possible to hash the arrays and compare the hashed values instead."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().equalPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:43+00:00", "tests_total": 64, "tests_dropped": 7, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "matrix", "simulation"]}, "language": "python", "interface": {"raw_signature": "def equalPairs(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "equalPairs", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2354, "task_id": "number-of-excellent-pairs", "difficulty": "Hard", "problem_description": "You are given a 0-indexed positive integer array nums and a positive integer k.\n\nA pair of numbers (num1, num2) is called excellent if the following conditions are satisfied:\n\n- Both the numbers num1 and num2 exist in the array nums.\n- The sum of the number of set bits in num1 OR num2 and num1 AND num2 is greater than or equal to k, where OR is the bitwise OR operation and AND is the bitwise AND operation.\n\nReturn the number of distinct excellent pairs.\n\nTwo pairs (a, b) and (c, d) are considered distinct if either a != c or b != d. For example, (1, 2) and (2, 1) are distinct.\n\nNote that a pair (num1, num2) such that num1 == num2 can also be excellent if you have at least one occurrence of num1 in the array.\n\nExample 1:\n\nInput: nums = [1,2,3,1], k = 3\nOutput: 5\nExplanation: The excellent pairs are the following:\n- (3, 3). (3 AND 3) and (3 OR 3) are both equal to (11) in binary. The total number of set bits is 2 + 2 = 4, which is greater than or equal to k = 3.\n- (2, 3) and (3, 2). (2 AND 3) is equal to (10) in binary, and (2 OR 3) is equal to (11) in binary. The total number of set bits is 1 + 2 = 3.\n- (1, 3) and (3, 1). (1 AND 3) is equal to (01) in binary, and (1 OR 3) is equal to (11) in binary. The total number of set bits is 1 + 2 = 3.\nSo the number of excellent pairs is 5.\n\nExample 2:\n\nInput: nums = [5,1,1], k = 10\nOutput: 0\nExplanation: There are no excellent pairs for this array.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^9\n- 1 <= k <= 60\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 1, 1, 1],k = 1) == 1\n    assert candidate(nums = [2, 4, 8, 16],k = 3) == 0\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 4) == 93\n    assert candidate(nums = [1, 2, 4, 8, 16, 32],k = 3) == 0\n    assert candidate(nums = [9, 10, 11, 12, 13, 14, 15],k = 7) == 7\n    assert candidate(nums = [1, 1, 2, 3, 4],k = 2) == 16\n    assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 9) == 72\n    assert candidate(nums = [5, 1, 1],k = 10) == 0\n    assert candidate(nums = [31, 14, 7, 3],k = 6) == 11\n    assert candidate(nums = [1, 3, 5, 7],k = 4) == 11\n    assert candidate(nums = [3, 1, 2, 5, 3, 4],k = 4) == 4\n    assert candidate(nums = [7, 8, 9],k = 5) == 3\n    assert candidate(nums = [1, 1, 1, 1],k = 1) == 1\n    assert candidate(nums = [31, 14, 7, 1],k = 8) == 5\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 5) == 0\n    assert candidate(nums = [1, 2, 3, 1],k = 3) == 5\n    assert candidate(nums = [6, 5, 3, 1, 8, 7, 2, 4],k = 6) == 1\n    assert candidate(nums = [7, 7, 7, 7],k = 5) == 1\n    assert candidate(nums = [1023, 511, 255, 127],k = 10) == 16\n    assert candidate(nums = [8, 8, 8, 8],k = 4) == 0\n    assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 3) == 0\n    assert candidate(nums = [7, 10, 4, 3, 15],k = 5) == 14\n    assert candidate(nums = [31, 15, 7, 3, 1],k = 8) == 6\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 6) == 76\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 10) == 64\n    assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 15) == 21\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5) == 348\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000],k = 10) == 25\n    assert candidate(nums = [15, 8, 7, 3, 1, 1, 2, 2],k = 4) == 21\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],k = 10) == 0\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],k = 4) == 22\n    assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 1) == 100\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 3) == 209\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 200\n    assert candidate(nums = [123456789, 987654321, 234567891, 198765432, 345678912, 456789123, 567891234, 678912345, 789123456, 891234567],k = 25) == 88\n    assert candidate(nums = [1023, 2047, 4095, 8191, 16383],k = 15) == 25\n    assert candidate(nums = [1, 5, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289, 1048577, 2097153],k = 18) == 0\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 9) == 72\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 25) == 0\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907],k = 25) == 140\n    assert candidate(nums = [5, 13, 15, 31, 7, 63],k = 8) == 19\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000],k = 10) == 36\n    assert candidate(nums = [128, 256, 512, 1024, 2048, 4096],k = 7) == 0\n    assert candidate(nums = [31, 14, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128],k = 7) == 7\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 20) == 100\n    assert candidate(nums = [1023, 511, 255, 127, 63, 31],k = 10) == 36\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n    assert candidate(nums = [29, 15, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 12\n    assert candidate(nums = [5, 7, 15, 31, 63, 127, 255, 511, 1023, 2047],k = 15) == 36\n    assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31],k = 6) == 55\n    assert candidate(nums = [100, 200, 300, 400, 500],k = 8) == 10\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 7) == 0\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 15) == 0\n    assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 20) == 229\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 6) == 0\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 10) == 0\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 4) == 44\n    assert candidate(nums = [3, 7, 15, 31, 63],k = 5) == 24\n    assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 9) == 72\n    assert candidate(nums = [5, 7, 13, 17, 23, 29, 31, 37, 41, 43, 47, 53, 59],k = 8) == 73\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535],k = 18) == 120\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 10) == 67\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 3) == 48\n    assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 10) == 64\n    assert candidate(nums = [3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047],k = 12) == 64\n    assert candidate(nums = [7, 11, 13, 14, 15],k = 5) == 25\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191],k = 14) == 91\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],k = 8) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 5) == 219\n    assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 1],k = 10) == 28\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 5) == 16\n    assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 5) == 209\n    assert candidate(nums = [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29],k = 5) == 1\n    assert candidate(nums = [999999937, 999999938, 999999939, 999999940, 999999941, 999999942, 999999943, 999999944, 999999945, 999999946],k = 40) == 0\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 14) == 0\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64],k = 7) == 0\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517],k = 20) == 256\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64],k = 10) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 44\n    assert candidate(nums = [2, 4, 8, 16, 32],k = 5) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 4) == 285\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575],k = 12) == 345\n    assert candidate(nums = [29, 17, 23, 30, 14, 11, 13, 19, 21, 22],k = 6) == 87\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 10) == 0\n    assert candidate(nums = [3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 25, 27, 30, 33, 34, 36, 40, 41, 42, 45, 48, 50, 51, 54, 57, 60, 62, 65, 66, 68, 72, 73, 74, 77, 80, 81, 82, 85, 88, 90, 93, 96, 98, 101, 102, 104, 105, 106, 108, 112, 113, 114, 117, 120, 122, 125, 126, 129, 130, 132, 135, 136, 138, 140, 141, 142, 144, 145, 146, 148, 150, 153, 154, 156, 159, 160, 162, 165, 168, 170, 171, 172, 174, 177, 180, 182, 185, 186, 188, 190, 192, 193, 194, 195, 196, 198, 200, 201, 204, 205, 208, 210, 213, 216, 218, 219, 220, 222, 224, 225, 226, 228, 230, 231, 232, 234, 237, 240, 242, 243, 244, 246, 248, 249, 250, 252, 255],k = 6) == 13945\n    assert candidate(nums = [3, 5, 9, 17, 33, 65, 129, 257, 513],k = 7) == 0\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 7) == 0\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12],k = 5) == 24\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 12) == 0\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3],k = 1) == 1\n    assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],k = 15) == 1\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 2) == 100\n    assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 12) == 45\n    assert candidate(nums = [3, 3, 3, 5, 5, 5, 7, 7, 7],k = 4) == 9\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 25) == 100\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],k = 12) == 170\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],k = 5) == 636\n    assert candidate(nums = [5, 3, 9, 7, 11],k = 4) == 25\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 3) == 16\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 22) == 0\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255],k = 10) == 28\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 4) == 247\n    assert candidate(nums = [98304, 49152, 24576, 12288, 6144, 3072, 1536, 768, 384, 192, 96, 48, 24, 12, 6, 3, 1, 1, 1, 1],k = 12) == 0\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 12) == 100\n    assert candidate(nums = [134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 15) == 0\n    assert candidate(nums = [8, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180],k = 4) == 239\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 8) == 0\n", "comparison": "exact"}, "public_tests": ["[1,2,3,1]\n3", "[5,1,1]\n10"], "hints": ["Can you find a different way to describe the second condition?", "The sum of the number of set bits in (num1 OR num2) and (num1 AND num2) is equal to the sum of the number of set bits in num1 and num2."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countExcellentPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:45+00:00", "tests_total": 111, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "hash-table", "binary-search", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def countExcellentPairs(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "countExcellentPairs", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2357, "task_id": "make-array-zero-by-subtracting-equal-amounts", "difficulty": "Easy", "problem_description": "You are given a non-negative integer array nums. In one operation, you must:\n\n- Choose a positive integer x such that x is less than or equal to the smallest non-zero element in nums.\n- Subtract x from every positive element in nums.\n\nReturn the minimum number of operations to make every element in nums equal to 0.\n\nExample 1:\n\nInput: nums = [1,5,0,3,5]\nOutput: 3\nExplanation:\nIn the first operation, choose x = 1. Now, nums = [0,4,0,2,4].\nIn the second operation, choose x = 2. Now, nums = [0,2,0,0,2].\nIn the third operation, choose x = 2. Now, nums = [0,0,0,0,0].\n\nExample 2:\n\nInput: nums = [0]\nOutput: 0\nExplanation: Each element in nums is already 0 so no operations are needed.\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 0 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 5\n    assert candidate(nums = [1, 0, 1, 0, 1]) == 1\n    assert candidate(nums = [1, 5, 0, 3, 5]) == 3\n    assert candidate(nums = [0, 1, 0, 1, 0]) == 1\n    assert candidate(nums = [1]) == 1\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 4]) == 4\n    assert candidate(nums = [100, 0, 50, 50]) == 2\n    assert candidate(nums = [100, 0, 50, 50, 0]) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50]) == 5\n    assert candidate(nums = [5, 5, 5, 5, 5]) == 1\n    assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n    assert candidate(nums = [99, 99, 99, 99, 99]) == 1\n    assert candidate(nums = [0]) == 0\n    assert candidate(nums = [1, 0, 1, 0, 1, 0]) == 1\n    assert candidate(nums = [100, 100, 100, 100, 100]) == 1\n    assert candidate(nums = [100, 0, 50, 25, 75]) == 4\n    assert candidate(nums = [0, 0, 0, 0]) == 0\n    assert candidate(nums = [2, 2, 2, 2]) == 1\n    assert candidate(nums = [5, 5, 5, 0, 0, 5, 0]) == 1\n    assert candidate(nums = [2, 2, 2, 2, 2]) == 1\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0]) == 14\n    assert candidate(nums = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0]) == 5\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 10\n    assert candidate(nums = [50, 25, 12, 6, 3, 1, 0, 0, 0, 0]) == 6\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n    assert candidate(nums = [7, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 7\n    assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 10\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0]) == 10\n    assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == 10\n    assert candidate(nums = [5, 0, 3, 3, 5, 0, 2]) == 3\n    assert candidate(nums = [10, 20, 30, 40, 50, 0, 10, 20, 30, 40, 50, 0]) == 5\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 20\n    assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 25\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 4\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 10\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 9\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n    assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n    assert candidate(nums = [5, 10, 15, 20, 25]) == 5\n    assert candidate(nums = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5]) == 10\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n    assert candidate(nums = [10, 20, 30, 40, 50, 0, 0, 0, 0, 0]) == 5\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n    assert candidate(nums = [5, 3, 8, 6, 2, 0, 7]) == 6\n    assert candidate(nums = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n    assert candidate(nums = [5, 3, 2, 1, 4, 0, 2, 3]) == 5\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 0]) == 10\n    assert candidate(nums = [42, 0, 42, 0, 42, 0, 42, 0, 42, 0, 42, 0, 42, 0, 42, 0, 42, 0, 42, 0]) == 1\n    assert candidate(nums = [50, 40, 30, 20, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 5\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n    assert candidate(nums = [99, 98, 97, 96, 95, 94, 93]) == 7\n    assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 5\n    assert candidate(nums = [5, 3, 2, 1, 4, 3, 5, 0, 1, 2, 3, 4, 5]) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5]) == 5\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == 5\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n    assert candidate(nums = [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 1\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 3\n    assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == 10\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == 5\n    assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5]) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 25\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n    assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 15\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 1\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 20\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 20\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 10\n    assert candidate(nums = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 0, 10, 20, 30, 40, 50, 60, 70, 80]) == 10\n    assert candidate(nums = [50, 25, 75, 50, 25, 75, 50, 25, 75, 50, 25, 75, 50, 25, 75]) == 3\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n    assert candidate(nums = [0, 2, 3, 2, 1, 3, 4, 3, 2, 1]) == 4\n    assert candidate(nums = [5, 1, 4, 2, 3, 1, 0, 2, 4, 3]) == 5\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0]) == 9\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [7, 14, 21, 28, 35, 42]) == 6\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 0, 10, 20, 30]) == 5\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 4\n    assert candidate(nums = [10, 20, 30, 40, 50, 0, 0, 0]) == 5\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 0, 0, 0, 0, 0]) == 5\n    assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 3\n    assert candidate(nums = [50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n    assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 20\n    assert candidate(nums = [10, 20, 30, 40, 50, 0, 10, 20, 30, 40]) == 5\n", "comparison": "exact"}, "public_tests": ["[1,5,0,3,5]", "[0]"], "hints": ["It is always best to set x as the smallest non-zero element in nums.", "Elements with the same value will always take the same number of operations to become 0. Contrarily, elements with different values will always take a different number of operations to become 0.", "The answer is the number of unique non-zero numbers in nums."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:50+00:00", "tests_total": 116, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "sorting", "heap-priority-queue", "simulation"]}, "language": "python", "interface": {"raw_signature": "def minimumOperations(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minimumOperations", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2358, "task_id": "maximum-number-of-groups-entering-a-competition", "difficulty": "Medium", "problem_description": "You are given a positive integer array grades which represents the grades of students in a university. You would like to enter all these students into a competition in ordered non-empty groups, such that the ordering meets the following conditions:\n\n- The sum of the grades of students in the i^th group is less than the sum of the grades of students in the (i + 1)^th group, for all groups (except the last).\n- The total number of students in the i^th group is less than the total number of students in the (i + 1)^th group, for all groups (except the last).\n\nReturn the maximum number of groups that can be formed.\n\nExample 1:\n\nInput: grades = [10,6,12,7,3,5]\nOutput: 3\nExplanation: The following is a possible way to form 3 groups of students:\n- 1^st group has the students with grades = [12]. Sum of grades: 12. Student count: 1\n- 2^nd group has the students with grades = [6,7]. Sum of grades: 6 + 7 = 13. Student count: 2\n- 3^rd group has the students with grades = [10,3,5]. Sum of grades: 10 + 3 + 5 = 18. Student count: 3\nIt can be shown that it is not possible to form more than 3 groups.\n\nExample 2:\n\nInput: grades = [8,8]\nOutput: 1\nExplanation: We can only form 1 group, since forming 2 groups would lead to an equal number of students in both groups.\n\nConstraints:\n\n- 1 <= grades.length <= 10^5\n- 1 <= grades[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grades = [10, 6, 12, 7, 3, 5]) == 3\n    assert candidate(grades = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 4\n    assert candidate(grades = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 4\n    assert candidate(grades = [1]) == 1\n    assert candidate(grades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n    assert candidate(grades = [100, 200, 300, 400, 500]) == 2\n    assert candidate(grades = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 4\n    assert candidate(grades = [1, 2]) == 1\n    assert candidate(grades = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 4\n    assert candidate(grades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 5\n    assert candidate(grades = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n    assert candidate(grades = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 4\n    assert candidate(grades = [8, 8]) == 1\n    assert candidate(grades = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 4\n    assert candidate(grades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 13\n    assert candidate(grades = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 4\n    assert candidate(grades = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 4\n    assert candidate(grades = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 7\n    assert candidate(grades = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 5\n    assert candidate(grades = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 4\n    assert candidate(grades = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 4\n    assert candidate(grades = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 5\n    assert candidate(grades = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 4\n    assert candidate(grades = [9, 5, 1, 3, 7, 4, 2, 8, 6, 10]) == 4\n    assert candidate(grades = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 6\n    assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 13\n    assert candidate(grades = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1]) == 6\n    assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n    assert candidate(grades = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 6\n    assert candidate(grades = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 7\n    assert candidate(grades = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n    assert candidate(grades = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970, 99969, 99968, 99967, 99966, 99965, 99964, 99963, 99962, 99961, 99960, 99959, 99958, 99957, 99956, 99955, 99954, 99953, 99952, 99951, 99950, 99949, 99948, 99947, 99946, 99945, 99944, 99943, 99942, 99941, 99940, 99939, 99938, 99937, 99936, 99935, 99934, 99933, 99932, 99931, 99930, 99929, 99928, 99927, 99926, 99925, 99924, 99923, 99922, 99921, 99920, 99919, 99918, 99917, 99916, 99915, 99914, 99913, 99912, 99911, 99910, 99909, 99908, 99907, 99906, 99905, 99904, 99903, 99902, 99901]) == 13\n    assert candidate(grades = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n    assert candidate(grades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 6\n    assert candidate(grades = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 4\n    assert candidate(grades = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 7\n    assert candidate(grades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 8\n    assert candidate(grades = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200]) == 8\n    assert candidate(grades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 8\n    assert candidate(grades = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 5\n    assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n    assert candidate(grades = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n    assert candidate(grades = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 5\n    assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n    assert candidate(grades = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 7\n    assert candidate(grades = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 5\n    assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 12\n    assert candidate(grades = [5, 1, 4, 3, 2, 6, 7, 8, 9, 10]) == 4\n    assert candidate(grades = [2, 1, 3, 1, 2, 3, 4, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 7\n    assert candidate(grades = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n    assert candidate(grades = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150]) == 9\n    assert candidate(grades = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n    assert candidate(grades = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 8\n    assert candidate(grades = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 7\n    assert candidate(grades = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == 5\n    assert candidate(grades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 6\n    assert candidate(grades = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 6\n    assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n    assert candidate(grades = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == 7\n    assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 7\n    assert candidate(grades = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n    assert candidate(grades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 7\n    assert candidate(grades = [9, 3, 5, 7, 2, 8, 6, 4, 1, 10]) == 4\n    assert candidate(grades = [30, 25, 20, 15, 10, 5, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 5\n    assert candidate(grades = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 13\n    assert candidate(grades = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n    assert candidate(grades = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 5\n    assert candidate(grades = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 6\n    assert candidate(grades = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n    assert candidate(grades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 5\n    assert candidate(grades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 7\n    assert candidate(grades = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 4\n    assert candidate(grades = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215]) == 6\n    assert candidate(grades = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 6\n    assert candidate(grades = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019]) == 5\n    assert candidate(grades = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200]) == 8\n    assert candidate(grades = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 9\n    assert candidate(grades = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981]) == 5\n    assert candidate(grades = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 7\n    assert candidate(grades = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325]) == 6\n    assert candidate(grades = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 5\n    assert candidate(grades = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25]) == 9\n    assert candidate(grades = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16, 21, 30, 22, 29, 23, 28, 24, 27, 25, 26]) == 7\n", "comparison": "exact"}, "public_tests": ["[10,6,12,7,3,5]", "[8,8]"], "hints": ["Would it be easier to place the students into valid groups after sorting them based on their grades in ascending order?", "Notice that, after sorting, we can separate them into groups of sizes 1, 2, 3, and so on.", "If the last group is invalid, we can merge it with the previous group.", "This creates the maximum number of groups because we always greedily form the smallest possible group."], "metadata": {"canonical_parameter_names": ["grades"], "leetcode_dataset_entry_point": "Solution().maximumGroups", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:52+00:00", "tests_total": 84, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "math", "binary-search", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maximumGroups(self, grades: list[int]) -> int:", "container": "Solution", "callable": "maximumGroups", "parameters": [{"name": "grades", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2359, "task_id": "find-closest-node-to-given-two-nodes", "difficulty": "Medium", "problem_description": "You are given a directed graph of n nodes numbered from 0 to n - 1, where each node has at most one outgoing edge.\n\nThe graph is represented with a given 0-indexed array edges of size n, indicating that there is a directed edge from node i to node edges[i]. If there is no outgoing edge from i, then edges[i] == -1.\n\nYou are also given two integers node1 and node2.\n\nReturn the index of the node that can be reached from both node1 and node2, such that the maximum between the distance from node1 to that node, and from node2 to that node is minimized. If there are multiple answers, return the node with the smallest index, and if no possible answer exists, return -1.\n\nNote that edges may contain cycles.\n\nExample 1:\n\nInput: edges = [2,2,3,-1], node1 = 0, node2 = 1\nOutput: 2\nExplanation: The distance from node 0 to node 2 is 1, and the distance from node 1 to node 2 is 1.\nThe maximum of those two distances is 1. It can be proven that we cannot get a node with a smaller maximum distance than 1, so we return node 2.\n\nExample 2:\n\nInput: edges = [1,2,-1], node1 = 0, node2 = 2\nOutput: 2\nExplanation: The distance from node 0 to node 2 is 2, and the distance from node 2 to itself is 0.\nThe maximum of those two distances is 2. It can be proven that we cannot get a node with a smaller maximum distance than 2, so we return node 2.\n\nConstraints:\n\n- n == edges.length\n- 2 <= n <= 10^5\n- -1 <= edges[i] < n\n- edges[i] != i\n- 0 <= node1, node2 < n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(edges = [5, -1, 3, 4, 5, 6, -1, -1, 4, 3],node1 = 0,node2 = 0) == 0\n    assert candidate(edges = [4, 3, 0, 5, 3, -1],node1 = 4,node2 = 0) == 4\n    assert candidate(edges = [1, 2, 0, -1],node1 = 0,node2 = 2) == 0\n    assert candidate(edges = [4, 4, 4, 5, 1, 2, 2],node1 = 1,node2 = 1) == 1\n    assert candidate(edges = [4, 4, 4, 5, 1, 2],node1 = 0,node2 = 1) == 4\n    assert candidate(edges = [4, 4, 8, -1, 9, 8, 4, 4, 1, 1],node1 = 5,node2 = 6) == 1\n    assert candidate(edges = [1, 2, 0, -1],node1 = 1,node2 = 2) == 2\n    assert candidate(edges = [1, 2, 3, 4, -1],node1 = 0,node2 = 4) == 4\n    assert candidate(edges = [2, 2, 3, -1],node1 = 0,node2 = 1) == 2\n    assert candidate(edges = [1, 2, -1],node1 = 0,node2 = 2) == 2\n    assert candidate(edges = [4, 3, 0, 5, 3, 9, 8, 5, 4, 6],node1 = 0,node2 = 8) == 4\n    assert candidate(edges = [4, 4, 8, 5, 9, 8, 4, 4, 1, 1],node1 = 5,node2 = 6) == 1\n    assert candidate(edges = [3, 0, 5, 5, 5, 3, 2, 0],node1 = 1,node2 = 7) == 0\n    assert candidate(edges = [9, 8, 7, 6, 5, 4, 3, 2, 1, -1],node1 = 0,node2 = 8) == -1\n    assert candidate(edges = [1, 2, 0, -1, -1, -1],node1 = 2,node2 = 3) == -1\n    assert candidate(edges = [1, 0, -1, -1, -1, -1, -1, -1, -1, -1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],node1 = 0,node2 = 10) == -1\n    assert candidate(edges = [5, 3, 1, 5, 2, 3],node1 = 1,node2 = 0) == 3\n    assert candidate(edges = [5, 5, 5, 5, 5, -1, -1, -1, -1, -1],node1 = 0,node2 = 5) == 5\n    assert candidate(edges = [2, 2, 3, 4, 2, -1, -1, 1],node1 = 0,node2 = 6) == -1\n    assert candidate(edges = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],node1 = 0,node2 = 9) == 0\n    assert candidate(edges = [2, 0, 0, 2, 5, 4, 4],node1 = 3,node2 = 4) == -1\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],node1 = 0,node2 = 5) == 0\n    assert candidate(edges = [4, 3, 0, 5, 3, -1],node1 = 0,node2 = 4) == 4\n    assert candidate(edges = [3, 3, 3, 4, 3, -1, -1, -1, -1, -1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],node1 = 0,node2 = 40) == -1\n    assert candidate(edges = [9, 8, 7, 6, 5, 4, 3, 2, 1, -1, 0],node1 = 5,node2 = 0) == -1\n    assert candidate(edges = [4, 4, 8, -1, 9, 8, 4, 4, 1, 11, 4, 4, 4, 8, 11, 2, 10, 4, 10, 1],node1 = 0,node2 = 13) == 4\n    assert candidate(edges = [6, 3, 4, 5, 5, 6, 7, 1, 0, -1],node1 = 0,node2 = 5) == 6\n    assert candidate(edges = [1, 2, 0, 1, 3, 4, 2],node1 = 2,node2 = 5) == 1\n    assert candidate(edges = [2, 0, 0, 2, 1, 4],node1 = 3,node2 = 5) == 0\n    assert candidate(edges = [1, 2, 3, 4, 0, -1],node1 = 0,node2 = 5) == -1\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1],node1 = 18,node2 = 19) == -1\n    assert candidate(edges = [4, 4, 8, 5, 9, 8, 4, 4, 1, 4],node1 = 0,node2 = 7) == 4\n    assert candidate(edges = [1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0],node1 = 0,node2 = 5) == 0\n    assert candidate(edges = [3, 3, 0, -1, -1, 0],node1 = 1,node2 = 5) == 3\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10],node1 = 0,node2 = 19) == -1\n    assert candidate(edges = [1, 2, 0, 5, 2, 1, 3, 4, 6, 7, -1],node1 = 8,node2 = 9) == 1\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, -1],node1 = 19,node2 = 20) == -1\n    assert candidate(edges = [4, 4, 4, 5, 1, 2, 2],node1 = 1,node2 = 0) == 4\n    assert candidate(edges = [3, 4, 4, 5, 1, 6, 5, 5, 6, 8, 8, 1, 7, 9, 8, 8, 8, 8, 8, 8],node1 = 0,node2 = 10) == 5\n    assert candidate(edges = [1, 2, 3, 4, 0],node1 = 1,node2 = 4) == 1\n    assert candidate(edges = [3, 0, 5, 1, 3, 2, 4, 2, 2, -1],node1 = 1,node2 = 8) == -1\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0],node1 = 0,node2 = 19) == 0\n    assert candidate(edges = [2, -1, 3, 5, -1, 2],node1 = 0,node2 = 5) == 2\n    assert candidate(edges = [4, 4, 4, 5, 1, 2],node1 = 0,node2 = 3) == 4\n    assert candidate(edges = [2, 2, 0, 4, 1, 0, -1, -1, 0, 3],node1 = 6,node2 = 7) == -1\n    assert candidate(edges = [4, 4, 4, 5, 1, 2, 2],node1 = 0,node2 = 3) == 4\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0],node1 = 0,node2 = 19) == 0\n    assert candidate(edges = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],node1 = 0,node2 = 18) == -1\n    assert candidate(edges = [1, 2, 3, 4, -1, -1, -1, -1, -1, -1],node1 = 0,node2 = 7) == -1\n    assert candidate(edges = [5, 3, 4, 5, 3, 2, -1],node1 = 1,node2 = 4) == 3\n    assert candidate(edges = [4, 4, 4, 5, 1, 2, 2],node1 = 1,node2 = 5) == 4\n    assert candidate(edges = [1, 0, 0, 4, 1],node1 = 0,node2 = 3) == 1\n    assert candidate(edges = [2, -1, 3, 1],node1 = 0,node2 = 2) == 2\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],node1 = 0,node2 = 9) == 0\n    assert candidate(edges = [10, 15, 11, 14, 13, 12, 5, 15, 9, 12, 15, 9, 10, 11, 13, -1, 12, 14, 15, 8, 5],node1 = 0,node2 = 14) == 10\n    assert candidate(edges = [5, 4, 0, 2, 3, 0, 2, 4, 0, 3, 2, 3, 2, 2, 3, 0, 2, 1, 0, 1],node1 = 0,node2 = 1) == 0\n    assert candidate(edges = [3, 0, 5, 5, 2, 4, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],node1 = 0,node2 = 18) == -1\n    assert candidate(edges = [1, 0, 3, 2, 1, 4, 5, -1, -1, -1, 8, 9, 7, 10, 11, 12, 13, -1],node1 = 1,node2 = 7) == -1\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1],node1 = 0,node2 = 10) == 10\n    assert candidate(edges = [2, 2, 3, 4, 5, -1, 2, 6, 7, -1, -1],node1 = 0,node2 = 1) == 2\n    assert candidate(edges = [2, 3, 3, 2],node1 = 0,node2 = 1) == 2\n    assert candidate(edges = [5, 4, 0, 2, 3, 0, 2, 4, 0, 3, 2, 3, 2, 2, 3, -1, 2],node1 = 0,node2 = 2) == 0\n    assert candidate(edges = [5, 3, 1, 4, 2, 6, 3, 2],node1 = 0,node2 = 5) == 5\n    assert candidate(edges = [5, -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, -1, -1, -1, 13, -1, 14, -1, 15],node1 = 0,node2 = 15) == -1\n    assert candidate(edges = [2, 2, 3, 4, 5, -1, -1, 5, 5, 5],node1 = 0,node2 = 9) == 5\n    assert candidate(edges = [1, 2, 0, 1, 3, -1, -1, -1],node1 = 0,node2 = 1) == 1\n    assert candidate(edges = [3, 3, 0, 5, -1, 2, 0, -1, -1, 3, 1],node1 = 3,node2 = 10) == 3\n", "comparison": "exact"}, "public_tests": ["[2,2,3,-1]\n0\n1", "[1,2,-1]\n0\n2"], "hints": ["How can you find the shortest distance from one node to all nodes in the graph?", "Use BFS to find the shortest distance from both node1 and node2 to all nodes in the graph. Then iterate over all nodes, and find the node with the minimum max distance."], "metadata": {"canonical_parameter_names": ["edges", "node1", "node2"], "leetcode_dataset_entry_point": "Solution().closestMeetingNode", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:55+00:00", "tests_total": 101, "tests_dropped": 34, "flags": ["multiple_answers", "has_images"], "topic_tags": ["depth-first-search", "graph"]}, "language": "python", "interface": {"raw_signature": "def closestMeetingNode(self, edges: list[int], node1: int, node2: int) -> int:", "container": "Solution", "callable": "closestMeetingNode", "parameters": [{"name": "edges", "type": "list[int]"}, {"name": "node1", "type": "int"}, {"name": "node2", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2360, "task_id": "longest-cycle-in-a-graph", "difficulty": "Hard", "problem_description": "You are given a directed graph of n nodes numbered from 0 to n - 1, where each node has at most one outgoing edge.\n\nThe graph is represented with a given 0-indexed array edges of size n, indicating that there is a directed edge from node i to node edges[i]. If there is no outgoing edge from node i, then edges[i] == -1.\n\nReturn the length of the longest cycle in the graph. If no cycle exists, return -1.\n\nA cycle is a path that starts and ends at the same node.\n\nExample 1:\n\nInput: edges = [3,3,4,2,3]\nOutput: 3\nExplanation: The longest cycle in the graph is the cycle: 2 -> 4 -> 3 -> 2.\nThe length of this cycle is 3, so 3 is returned.\n\nExample 2:\n\nInput: edges = [2,-1,3,1]\nOutput: -1\nExplanation: There are no cycles in this graph.\n\nConstraints:\n\n- n == edges.length\n- 2 <= n <= 10^5\n- -1 <= edges[i] < n\n- edges[i] != i\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(edges = [-1, 2, 0, 1, -1]) == -1\n    assert candidate(edges = [1, 2, 0, 4, -1]) == 3\n    assert candidate(edges = [5, 4, 5, 4, 5, 4]) == 2\n    assert candidate(edges = [1, 0, -1, -1]) == 2\n    assert candidate(edges = [1, 0, 0, 0, 1]) == 2\n    assert candidate(edges = [1, 0, -1, -1, -1]) == 2\n    assert candidate(edges = [2, -1, 1, -1, -1, -1, -1, -1, -1, -1]) == -1\n    assert candidate(edges = [5, 4, 3, 2, 1, 0]) == 2\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 10\n    assert candidate(edges = [1, 2, 0, 1, 3, -1]) == 3\n    assert candidate(edges = [1, 2, 0, -1]) == 3\n    assert candidate(edges = [1, 2, 3, 4, 0]) == 5\n    assert candidate(edges = [3, 0, 1, 4, 2]) == 5\n    assert candidate(edges = [-1, -1, -1, -1, -1]) == -1\n    assert candidate(edges = [5, 4, 3, 2, 1, 0, -1, -1, -1, -1]) == 2\n    assert candidate(edges = [3, 3, 4, 2, 3]) == 3\n    assert candidate(edges = [2, -1, 3, 1]) == -1\n    assert candidate(edges = [1, 0, 0, 0, 0]) == 2\n    assert candidate(edges = [1, 2, 3, 4, 5, 0]) == 6\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 15, 16, 17, 18, 19, 10, 11]) == 10\n    assert candidate(edges = [1, 2, 0, 5, 6, 7, 8, 9, 3, 4]) == 7\n    assert candidate(edges = [2, 3, 4, -1, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == -1\n    assert candidate(edges = [5, 4, 0, 2, 0, 1, -1, 3]) == 4\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 10\n    assert candidate(edges = [1, 2, 0, -1, 1, -1, -1, -1, -1, -1]) == 3\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12, 13, 14, 10]) == 10\n    assert candidate(edges = [2, 2, 3, 2, 2]) == 2\n    assert candidate(edges = [1, 0, 3, 2, -1, -1, -1, -1, -1, -1]) == 2\n    assert candidate(edges = [3, 3, 3, 1, 2]) == 2\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 15, 16, 17, 18, 19, 10, 11, 21, 22, 23, 24, 20]) == 10\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]) == -1\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 20\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 0]) == 41\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 30]) == 10\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 0]) == 8\n    assert candidate(edges = [7, 4, 5, 6, 3, 1, 2, 0]) == 6\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0]) == 31\n    assert candidate(edges = [5, 4, 0, 2, 0, 1, 2, -1, -1, 10, 9]) == 4\n    assert candidate(edges = [2, 3, 4, 5, 0, -1, -1, -1, -1, -1]) == 3\n    assert candidate(edges = [3, 3, 4, 2, 3, -1, 5, 5, 6, 7, -1, 8, 9, 10, -1, 11, 12, -1, 13, 14, -1, 15, 16, -1, 17, 18, -1, 19, 20, -1, 21, 22, -1, 23, 24, -1, 25, 26, -1, 27, 28, -1, 29, 30, -1, 31, 32, -1, 33, 34, -1, 35, 36, -1, 37, 38, -1, 39, 40, -1, 41, 42, -1, 43, 44, -1, 45, 46, -1, 47, 48, -1, 49, 50, -1, 51, 52, -1, 53, 54, -1, 55, 56, -1, 57, 58, -1, 59, 60, -1, 61, 62, -1, 63, 64, -1, 65, 66, -1, 67, 68, -1, 69, 70, -1, 71, 72, -1, 73, 74, -1, 75, 76, -1, 77, 78, -1, 79, 80, -1, 81, 82, -1, 83, 84, -1, 85, 86, -1, 87, 88, -1, 89, 90, -1, 91, 92, -1, 93, 94, -1, 95, 96, -1, 97, 98, -1, 99, 100, -1]) == 3\n    assert candidate(edges = [2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n    assert candidate(edges = [1, 2, 0, 4, 3]) == 3\n    assert candidate(edges = [1, 3, 4, 2, 1, -1, -1, -1]) == 4\n    assert candidate(edges = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, 1]) == 6\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0]) == 100\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 0]) == 20\n    assert candidate(edges = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == -1\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == 11\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]) == 16\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4]) == 21\n    assert candidate(edges = [4, 4, 4, 4, 0]) == 2\n    assert candidate(edges = [5, 4, 3, 2, 1, -1, -1, -1, -1, -1]) == 2\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 0]) == 201\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 20\n    assert candidate(edges = [9, 9, 9, 9, 9, 9, 9, 9, 9, 0]) == 2\n    assert candidate(edges = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 2\n    assert candidate(edges = [3, 3, 4, 2, 3, 3, 4, 2, 3, 3]) == 3\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10]) == 10\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0]) == 15\n    assert candidate(edges = [3, 2, 1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 2\n    assert candidate(edges = [5, 5, 5, 5, 5, -1, 5, 5, 5, 5]) == -1\n    assert candidate(edges = [1, 2, 3, 4, 0, 6, 7, 8, 9, 5]) == 5\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0]) == 30\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0]) == 50\n    assert candidate(edges = [1, 2, 3, 4, 0, 6, 7, 8, 9, 5]) == 5\n    assert candidate(edges = [5, 4, 0, 2, 0, 4, 2, 2, 0, 4]) == 3\n    assert candidate(edges = [5, 4, 3, 2, 1, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, -1]) == 2\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 0]) == 40\n    assert candidate(edges = [-1, 3, -1, -1, 5, -1, 7, -1, 9, -1, 11, -1, 13, -1, 15, -1, 17, -1, 19, -1, 21, -1, 23, -1, 25, -1]) == -1\n    assert candidate(edges = [4, 3, 0, 5, 3, -1, 2]) == -1\n", "comparison": "exact"}, "public_tests": ["[3,3,4,2,3]", "[2,-1,3,1]"], "hints": ["How many cycles can each node at most be part of?", "Each node can be part of at most one cycle. Start from each node and find the cycle that it is part of if there is any. Save the already visited nodes to not repeat visiting the same cycle multiple times."], "metadata": {"canonical_parameter_names": ["edges"], "leetcode_dataset_entry_point": "Solution().longestCycle", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:49:58+00:00", "tests_total": 109, "tests_dropped": 39, "flags": ["has_images"], "topic_tags": ["depth-first-search", "breadth-first-search", "graph", "topological-sort", "kosarajus-algorithm", "tarjans-scc-algorithm"]}, "language": "python", "interface": {"raw_signature": "def longestCycle(self, edges: list[int]) -> int:", "container": "Solution", "callable": "longestCycle", "parameters": [{"name": "edges", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2363, "task_id": "merge-similar-items", "difficulty": "Easy", "problem_description": "You are given two 2D integer arrays, items1 and items2, representing two sets of items. Each array items has the following properties:\n\n- items[i] = [value_i, weight_i] where value_i represents the value and weight_i represents the weight of the i^th item.\n- The value of each item in items is unique.\n\nReturn a 2D integer array ret where ret[i] = [value_i, weight_i], with weight_i being the sum of weights of all items with value value_i.\n\nNote: ret should be returned in ascending order by value.\n\nExample 1:\n\nInput: items1 = [[1,1],[4,5],[3,8]], items2 = [[3,1],[1,5]]\nOutput: [[1,6],[3,9],[4,5]]\nExplanation:\nThe item with value = 1 occurs in items1 with weight = 1 and in items2 with weight = 5, total weight = 1 + 5 = 6.\nThe item with value = 3 occurs in items1 with weight = 8 and in items2 with weight = 1, total weight = 8 + 1 = 9.\nThe item with value = 4 occurs in items1 with weight = 5, total weight = 5.\nTherefore, we return [[1,6],[3,9],[4,5]].\n\nExample 2:\n\nInput: items1 = [[1,1],[3,2],[2,3]], items2 = [[2,1],[3,2],[1,3]]\nOutput: [[1,4],[2,4],[3,4]]\nExplanation:\nThe item with value = 1 occurs in items1 with weight = 1 and in items2 with weight = 3, total weight = 1 + 3 = 4.\nThe item with value = 2 occurs in items1 with weight = 3 and in items2 with weight = 1, total weight = 3 + 1 = 4.\nThe item with value = 3 occurs in items1 with weight = 2 and in items2 with weight = 2, total weight = 2 + 2 = 4.\nTherefore, we return [[1,4],[2,4],[3,4]].\n\nExample 3:\n\nInput: items1 = [[1,3],[2,2]], items2 = [[7,1],[2,2],[1,4]]\nOutput: [[1,7],[2,4],[7,1]]\nExplanation:\nThe item with value = 1 occurs in items1 with weight = 3 and in items2 with weight = 4, total weight = 3 + 4 = 7.\nThe item with value = 2 occurs in items1 with weight = 2 and in items2 with weight = 2, total weight = 2 + 2 = 4.\nThe item with value = 7 occurs in items2 with weight = 1, total weight = 1.\nTherefore, we return [[1,7],[2,4],[7,1]].\n\nConstraints:\n\n- 1 <= items1.length, items2.length <= 1000\n- items1[i].length == items2[i].length == 2\n- 1 <= value_i, weight_i <= 1000\n- Each value_i in items1 is unique.\n- Each value_i in items2 is unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(items1 = [[1, 3], [2, 2]],items2 = [[7, 1], [2, 2], [1, 4]]) == [(1, 7), (2, 4), (7, 1)]\n    assert candidate(items1 = [[1, 1000]],items2 = [[2, 1000]]) == [(1, 1000), (2, 1000)]\n    assert candidate(items1 = [[1, 1], [4, 5], [3, 8]],items2 = [[3, 1], [1, 5]]) == [(1, 6), (3, 9), (4, 5)]\n    assert candidate(items1 = [[1000, 1]],items2 = [[999, 1000]]) == [(999, 1000), (1000, 1)]\n    assert candidate(items1 = [[100, 100], [200, 200]],items2 = [[150, 150], [250, 250]]) == [(100, 100), (150, 150), (200, 200), (250, 250)]\n    assert candidate(items1 = [[10, 10]],items2 = [[20, 20]]) == [(10, 10), (20, 20)]\n    assert candidate(items1 = [[5, 5], [10, 10]],items2 = [[5, 5], [15, 15]]) == [(5, 10), (10, 10), (15, 15)]\n    assert candidate(items1 = [[5, 5]],items2 = [[5, 5]]) == [(5, 10)]\n    assert candidate(items1 = [[1, 1], [2, 2], [3, 3]],items2 = [[4, 4], [5, 5], [6, 6]]) == [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]\n    assert candidate(items1 = [[1, 1], [3, 2], [2, 3]],items2 = [[2, 1], [3, 2], [1, 3]]) == [(1, 4), (2, 4), (3, 4)]\n    assert candidate(items1 = [[1, 100], [2, 200], [3, 300]],items2 = [[1, 100], [2, 200], [3, 300]]) == [(1, 200), (2, 400), (3, 600)]\n    assert candidate(items1 = [[1, 500], [2, 400], [3, 300], [4, 200], [5, 100]],items2 = [[6, 100], [7, 200], [8, 300], [9, 400], [10, 500]]) == [(1, 500), (2, 400), (3, 300), (4, 200), (5, 100), (6, 100), (7, 200), (8, 300), (9, 400), (10, 500)]\n    assert candidate(items1 = [[500, 500], [1, 1], [100, 100]],items2 = [[500, 500], [1, 1], [100, 100], [200, 200], [300, 300], [400, 400]]) == [(1, 2), (100, 200), (200, 200), (300, 300), (400, 400), (500, 1000)]\n    assert candidate(items1 = [[1, 999], [2, 998], [3, 997], [4, 996], [5, 995]],items2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [(1, 1000), (2, 1000), (3, 1000), (4, 1000), (5, 1000)]\n    assert candidate(items1 = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],items2 = [[50, 5], [150, 4], [250, 3], [350, 2], [450, 1]]) == [(50, 5), (100, 1), (150, 4), (200, 2), (250, 3), (300, 3), (350, 2), (400, 4), (450, 1), (500, 5)]\n    assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4]],items2 = [[2, 4], [3, 6], [5, 8], [6, 10]]) == [(1, 1), (2, 6), (3, 9), (4, 4), (5, 8), (6, 10)]\n    assert candidate(items1 = [[999, 1], [998, 2], [997, 3]],items2 = [[996, 4], [995, 5], [994, 6], [993, 7], [992, 8], [991, 9], [990, 10]]) == [(990, 10), (991, 9), (992, 8), (993, 7), (994, 6), (995, 5), (996, 4), (997, 3), (998, 2), (999, 1)]\n    assert candidate(items1 = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1]],items2 = [[10, 99], [20, 98], [30, 97], [40, 96], [50, 95]]) == [(10, 100), (20, 99), (30, 98), (40, 97), (50, 96)]\n    assert candidate(items1 = [[1, 10], [2, 20], [5, 50], [10, 100]],items2 = [[1, 5], [3, 30], [4, 40], [6, 60], [7, 70]]) == [(1, 15), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60), (7, 70), (10, 100)]\n    assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4]],items2 = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [(1, 1), (2, 4), (3, 6), (4, 8), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10)]\n    assert candidate(items1 = [[1, 1], [10, 10], [100, 100]],items2 = [[1, 99], [10, 90], [100, 900], [1000, 1000]]) == [(1, 100), (10, 100), (100, 1000), (1000, 1000)]\n    assert candidate(items1 = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],items2 = [[3, 30], [4, 40], [5, 50], [6, 60], [7, 70]]) == [(1, 10), (2, 20), (3, 60), (4, 80), (5, 100), (6, 60), (7, 70)]\n    assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],items2 = [[10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]]) == [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10), (11, 11), (12, 12), (13, 13), (14, 14), (15, 15), (16, 16), (17, 17), (18, 18), (19, 19)]\n    assert candidate(items1 = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45]],items2 = [[5, 45], [15, 35], [25, 25], [35, 15], [45, 5]]) == [(5, 50), (15, 50), (25, 50), (35, 50), (45, 50)]\n    assert candidate(items1 = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],items2 = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55]]) == [(5, 5), (10, 1), (15, 15), (20, 2), (25, 25), (30, 3), (35, 35), (40, 4), (45, 45), (50, 5), (55, 55)]\n    assert candidate(items1 = [[500, 100], [300, 200]],items2 = [[200, 300], [100, 400], [500, 600]]) == [(100, 400), (200, 300), (300, 200), (500, 700)]\n    assert candidate(items1 = [[5, 1], [15, 2], [25, 3], [35, 4], [45, 5]],items2 = [[5, 5], [15, 4], [25, 3], [35, 2], [45, 1]]) == [(5, 6), (15, 6), (25, 6), (35, 6), (45, 6)]\n    assert candidate(items1 = [[1, 10], [2, 20], [3, 30]],items2 = [[4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90]]) == [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60), (7, 70), (8, 80), (9, 90)]\n    assert candidate(items1 = [[100, 100], [200, 200], [300, 300]],items2 = [[150, 150], [250, 250], [350, 350], [450, 450]]) == [(100, 100), (150, 150), (200, 200), (250, 250), (300, 300), (350, 350), (450, 450)]\n    assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],items2 = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == [(1, 2), (2, 4), (3, 6), (4, 8), (5, 10)]\n    assert candidate(items1 = [[1, 1000], [2, 1000], [3, 1000]],items2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [(1, 1001), (2, 1002), (3, 1003), (4, 4), (5, 5)]\n    assert candidate(items1 = [[1, 1000], [2, 999], [3, 998], [4, 997]],items2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [(1, 1001), (2, 1001), (3, 1001), (4, 1001), (5, 5)]\n    assert candidate(items1 = [[5, 5], [10, 10], [15, 15], [20, 20]],items2 = [[5, 5], [10, 10], [25, 25], [30, 30]]) == [(5, 10), (10, 20), (15, 15), (20, 20), (25, 25), (30, 30)]\n    assert candidate(items1 = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],items2 = [[6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60), (7, 70), (8, 80), (9, 90), (10, 100)]\n    assert candidate(items1 = [[500, 5000], [1000, 10000]],items2 = [[250, 2500], [750, 7500]]) == [(250, 2500), (500, 5000), (750, 7500), (1000, 10000)]\n    assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],items2 = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == [(1, 11), (2, 22), (3, 33), (4, 44), (5, 55), (6, 66), (7, 77), (8, 88), (9, 99), (10, 110)]\n    assert candidate(items1 = [[100, 1], [200, 2], [300, 3], [400, 4]],items2 = [[50, 5], [150, 15], [250, 25], [350, 35], [450, 45]]) == [(50, 5), (100, 1), (150, 15), (200, 2), (250, 25), (300, 3), (350, 35), (400, 4), (450, 45)]\n    assert candidate(items1 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],items2 = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]]) == [(10, 11), (20, 22), (30, 33), (40, 44), (50, 55), (60, 66), (70, 77), (80, 88), (90, 99), (100, 110)]\n    assert candidate(items1 = [[10, 15], [20, 25], [30, 35], [40, 45]],items2 = [[10, 5], [20, 15], [50, 55]]) == [(10, 20), (20, 40), (30, 35), (40, 45), (50, 55)]\n    assert candidate(items1 = [[1, 10], [2, 20], [3, 30]],items2 = [[4, 40], [5, 50], [6, 60], [7, 70], [8, 80]]) == [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60), (7, 70), (8, 80)]\n    assert candidate(items1 = [[5, 10], [15, 20], [25, 30], [35, 40]],items2 = [[10, 5], [15, 15], [25, 25], [40, 45]]) == [(5, 10), (10, 5), (15, 35), (25, 55), (35, 40), (40, 45)]\n    assert candidate(items1 = [[1000, 1]],items2 = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992]]) == [(1, 1000), (2, 999), (3, 998), (4, 997), (5, 996), (6, 995), (7, 994), (8, 993), (9, 992), (1000, 1)]\n    assert candidate(items1 = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],items2 = [[100, 5], [200, 4], [300, 3], [400, 2], [500, 1]]) == [(100, 6), (200, 6), (300, 6), (400, 6), (500, 6)]\n    assert candidate(items1 = [[999, 1], [998, 2], [997, 3], [996, 4], [995, 5]],items2 = [[994, 6], [993, 7], [992, 8], [991, 9], [990, 10]]) == [(990, 10), (991, 9), (992, 8), (993, 7), (994, 6), (995, 5), (996, 4), (997, 3), (998, 2), (999, 1)]\n    assert candidate(items1 = [[999, 1], [998, 2], [997, 3]],items2 = [[996, 4], [995, 5], [994, 6], [993, 7], [992, 8]]) == [(992, 8), (993, 7), (994, 6), (995, 5), (996, 4), (997, 3), (998, 2), (999, 1)]\n    assert candidate(items1 = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]],items2 = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5]]) == [(5, 6), (10, 12), (15, 18), (20, 24), (25, 30)]\n    assert candidate(items1 = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],items2 = [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]]) == [(10, 6), (20, 6), (30, 6), (40, 6), (50, 6)]\n    assert candidate(items1 = [[100, 1000], [200, 2000]],items2 = [[101, 1001], [201, 2001], [100, 1000]]) == [(100, 2000), (101, 1001), (200, 2000), (201, 2001)]\n    assert candidate(items1 = [[1, 1000], [2, 999], [3, 998]],items2 = [[2, 1], [3, 2], [4, 3], [5, 4], [6, 5]]) == [(1, 1000), (2, 1000), (3, 1000), (4, 3), (5, 4), (6, 5)]\n    assert candidate(items1 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60]],items2 = [[15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65]]) == [(10, 10), (15, 15), (20, 20), (25, 25), (30, 30), (35, 35), (40, 40), (45, 45), (50, 50), (55, 55), (60, 60), (65, 65)]\n    assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],items2 = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == [(1, 2), (2, 4), (3, 6), (4, 8), (5, 10)]\n    assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],items2 = [[1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1]]) == [(1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7)]\n    assert candidate(items1 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],items2 = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95]]) == [(5, 5), (10, 10), (15, 15), (20, 20), (25, 25), (30, 30), (35, 35), (40, 40), (45, 45), (50, 50), (55, 55), (60, 60), (65, 65), (70, 70), (75, 75), (80, 80), (85, 85), (90, 90), (95, 95), (100, 100)]\n    assert candidate(items1 = [[10, 50], [20, 100], [30, 150], [40, 200]],items2 = [[10, 50], [20, 50], [30, 50], [50, 250]]) == [(10, 100), (20, 150), (30, 200), (40, 200), (50, 250)]\n    assert candidate(items1 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],items2 = [[15, 15], [25, 25], [35, 35], [45, 45], [55, 55]]) == [(10, 10), (15, 15), (20, 20), (25, 25), (30, 30), (35, 35), (40, 40), (45, 45), (50, 50), (55, 55)]\n    assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],items2 = [[6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10)]\n    assert candidate(items1 = [[2, 200], [4, 400], [6, 600], [8, 800]],items2 = [[1, 100], [3, 300], [5, 500], [7, 700], [9, 900]]) == [(1, 100), (2, 200), (3, 300), (4, 400), (5, 500), (6, 600), (7, 700), (8, 800), (9, 900)]\n    assert candidate(items1 = [[1, 1000], [3, 1000], [5, 1000], [7, 1000], [9, 1000]],items2 = [[2, 1000], [4, 1000], [6, 1000], [8, 1000], [10, 1000]]) == [(1, 1000), (2, 1000), (3, 1000), (4, 1000), (5, 1000), (6, 1000), (7, 1000), (8, 1000), (9, 1000), (10, 1000)]\n    assert candidate(items1 = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9]],items2 = [[2, 2], [4, 4], [6, 6], [8, 8], [10, 10]]) == [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10)]\n    assert candidate(items1 = [[1, 999]],items2 = [[1, 1]]) == [(1, 1000)]\n    assert candidate(items1 = [[100, 1000], [200, 2000], [300, 3000]],items2 = [[50, 500], [150, 1500], [250, 2500], [350, 3500]]) == [(50, 500), (100, 1000), (150, 1500), (200, 2000), (250, 2500), (300, 3000), (350, 3500)]\n    assert candidate(items1 = [[10, 5], [20, 15], [30, 25]],items2 = [[5, 5], [15, 10], [25, 15], [35, 20]]) == [(5, 5), (10, 5), (15, 10), (20, 15), (25, 15), (30, 25), (35, 20)]\n    assert candidate(items1 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70]],items2 = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75]]) == [(5, 5), (10, 10), (15, 15), (20, 20), (25, 25), (30, 30), (35, 35), (40, 40), (45, 45), (50, 50), (55, 55), (60, 60), (65, 65), (70, 70), (75, 75)]\n    assert candidate(items1 = [[100, 100], [200, 200], [300, 300]],items2 = [[100, 50], [200, 150], [300, 250], [400, 350], [500, 450]]) == [(100, 150), (200, 350), (300, 550), (400, 350), (500, 450)]\n    assert candidate(items1 = [[1, 100], [2, 200], [3, 300], [4, 400]],items2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [(1, 101), (2, 202), (3, 303), (4, 404), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10)]\n    assert candidate(items1 = [[1, 1000], [500, 1], [1000, 1000]],items2 = [[1, 1], [500, 1000], [1000, 1]]) == [(1, 1001), (500, 1001), (1000, 1001)]\n    assert candidate(items1 = [[10, 50], [20, 100], [30, 150]],items2 = [[5, 25], [10, 75], [40, 200]]) == [(5, 25), (10, 125), (20, 100), (30, 150), (40, 200)]\n    assert candidate(items1 = [[10, 10], [20, 20], [30, 30]],items2 = [[11, 11], [21, 21], [31, 31], [10, 9], [20, 18], [30, 27]]) == [(10, 19), (11, 11), (20, 38), (21, 21), (30, 57), (31, 31)]\n    assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],items2 = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == [(1, 11), (2, 22), (3, 33), (4, 44), (5, 55), (6, 66), (7, 77), (8, 88), (9, 99), (10, 110)]\n    assert candidate(items1 = [[10, 100], [20, 200], [30, 300], [40, 400]],items2 = [[5, 50], [10, 150], [25, 250], [30, 350]]) == [(5, 50), (10, 250), (20, 200), (25, 250), (30, 650), (40, 400)]\n    assert candidate(items1 = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50]],items2 = [[50, 5], [150, 15], [250, 25], [350, 35], [450, 45], [550, 55]]) == [(50, 5), (100, 10), (150, 15), (200, 20), (250, 25), (300, 30), (350, 35), (400, 40), (450, 45), (500, 50), (550, 55)]\n    assert candidate(items1 = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900]],items2 = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9]]) == [(100, 101), (200, 202), (300, 303), (400, 404), (500, 505), (600, 606), (700, 707), (800, 808), (900, 909)]\n    assert candidate(items1 = [[10, 100], [20, 200], [30, 300]],items2 = [[15, 150], [25, 250], [35, 350], [45, 450], [55, 550]]) == [(10, 100), (15, 150), (20, 200), (25, 250), (30, 300), (35, 350), (45, 450), (55, 550)]\n    assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],items2 = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == [(1, 6), (2, 6), (3, 6), (4, 6), (5, 6)]\n    assert candidate(items1 = [[1, 100], [10, 100], [100, 100], [1000, 100]],items2 = [[2, 200], [20, 200], [200, 200], [2000, 200]]) == [(1, 100), (2, 200), (10, 100), (20, 200), (100, 100), (200, 200), (1000, 100), (2000, 200)]\n    assert candidate(items1 = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],items2 = [[1, 5], [2, 10], [3, 15], [4, 20], [5, 25]]) == [(1, 15), (2, 30), (3, 45), (4, 60), (5, 75)]\n    assert candidate(items1 = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9]],items2 = [[2, 2], [4, 4], [6, 6], [8, 8], [10, 10]]) == [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10)]\n    assert candidate(items1 = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],items2 = [[1, 5], [2, 10], [3, 15], [4, 20], [5, 25]]) == [(1, 15), (2, 30), (3, 45), (4, 60), (5, 75)]\n    assert candidate(items1 = [[1, 1000], [2, 999], [3, 998], [4, 997]],items2 = [[5, 996], [6, 995], [7, 994], [8, 993]]) == [(1, 1000), (2, 999), (3, 998), (4, 997), (5, 996), (6, 995), (7, 994), (8, 993)]\n    assert candidate(items1 = [[999, 1], [998, 2], [997, 3]],items2 = [[996, 4], [995, 5], [997, 6]]) == [(995, 5), (996, 4), (997, 9), (998, 2), (999, 1)]\n    assert candidate(items1 = [[10, 10], [20, 20], [30, 30]],items2 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == [(10, 20), (20, 40), (30, 60), (40, 40), (50, 50)]\n    assert candidate(items1 = [[100, 1], [200, 2], [300, 3], [400, 4]],items2 = [[50, 5], [150, 6], [250, 7], [350, 8], [450, 9]]) == [(50, 5), (100, 1), (150, 6), (200, 2), (250, 7), (300, 3), (350, 8), (400, 4), (450, 9)]\n    assert candidate(items1 = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],items2 = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45]]) == [(5, 5), (10, 10), (15, 15), (20, 20), (25, 25), (30, 30), (35, 35), (40, 40), (45, 45), (50, 50)]\n    assert candidate(items1 = [[100, 1], [200, 1], [300, 1], [400, 1], [500, 1]],items2 = [[100, 1000], [200, 2000], [300, 3000], [400, 4000], [500, 5000]]) == [(100, 1001), (200, 2001), (300, 3001), (400, 4001), (500, 5001)]\n    assert candidate(items1 = [[5, 50], [15, 150], [25, 250], [35, 350], [45, 450]],items2 = [[5, 50], [15, 150], [25, 250], [35, 350], [45, 450]]) == [(5, 100), (15, 300), (25, 500), (35, 700), (45, 900)]\n    assert candidate(items1 = [[10, 1], [20, 2], [30, 3]],items2 = [[10, 9], [20, 8], [30, 7]]) == [(10, 10), (20, 10), (30, 10)]\n    assert candidate(items1 = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5]],items2 = [[5, 5], [10, 4], [15, 3], [20, 2], [25, 1]]) == [(5, 6), (10, 6), (15, 6), (20, 6), (25, 6)]\n    assert candidate(items1 = [[500, 50], [1000, 100]],items2 = [[250, 25], [750, 75], [1000, 50]]) == [(250, 25), (500, 50), (750, 75), (1000, 150)]\n    assert candidate(items1 = [[1, 1], [10, 10], [100, 100], [1000, 1000]],items2 = [[1, 1000], [10, 100], [100, 10], [1000, 1]]) == [(1, 1001), (10, 110), (100, 110), (1000, 1001)]\n    assert candidate(items1 = [[500, 1], [501, 2], [502, 3], [503, 4], [504, 5]],items2 = [[500, 5], [501, 4], [502, 3], [503, 2], [504, 1]]) == [(500, 6), (501, 6), (502, 6), (503, 6), (504, 6)]\n    assert candidate(items1 = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500]],items2 = [[5, 50], [15, 150], [25, 250], [35, 350], [45, 450], [55, 550]]) == [(5, 50), (10, 100), (15, 150), (20, 200), (25, 250), (30, 300), (35, 350), (40, 400), (45, 450), (50, 500), (55, 550)]\n    assert candidate(items1 = [[1, 100], [3, 300], [5, 500], [7, 700]],items2 = [[2, 200], [4, 400], [6, 600], [8, 800]]) == [(1, 100), (2, 200), (3, 300), (4, 400), (5, 500), (6, 600), (7, 700), (8, 800)]\n    assert candidate(items1 = [[999, 1], [998, 2], [997, 3]],items2 = [[999, 4], [998, 5], [997, 6], [996, 7]]) == [(996, 7), (997, 9), (998, 7), (999, 5)]\n    assert candidate(items1 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],items2 = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [(1, 10), (2, 10), (3, 10), (4, 10), (5, 10), (6, 10), (7, 10), (8, 10), (9, 10)]\n    assert candidate(items1 = [[10, 5], [20, 10], [30, 15], [40, 20]],items2 = [[10, 15], [20, 20], [50, 25], [60, 30]]) == [(10, 20), (20, 30), (30, 15), (40, 20), (50, 25), (60, 30)]\n    assert candidate(items1 = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40]],items2 = [[3, 3], [6, 6], [9, 9], [12, 12], [18, 18], [21, 21], [24, 24], [27, 27], [33, 33], [36, 36], [39, 39], [42, 42]]) == [(3, 3), (5, 5), (6, 6), (9, 9), (10, 10), (12, 12), (15, 15), (18, 18), (20, 20), (21, 21), (24, 24), (25, 25), (27, 27), (30, 30), (33, 33), (35, 35), (36, 36), (39, 39), (40, 40), (42, 42)]\n    assert candidate(items1 = [[5, 100], [15, 200], [25, 300], [35, 400]],items2 = [[5, 150], [25, 250], [35, 350], [45, 450]]) == [(5, 250), (15, 200), (25, 550), (35, 750), (45, 450)]\n    assert candidate(items1 = [[1, 1000], [500, 500], [1000, 1]],items2 = [[1, 1000], [500, 500], [1000, 1]]) == [(1, 2000), (500, 1000), (1000, 2)]\n    assert candidate(items1 = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],items2 = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [(1, 101), (2, 202), (3, 303), (4, 404), (5, 505), (6, 606), (7, 707), (8, 808), (9, 909), (10, 1010)]\n    assert candidate(items1 = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5]],items2 = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]]) == [(5, 6), (10, 12), (15, 18), (20, 24), (25, 30)]\n", "comparison": "exact"}, "public_tests": ["[[1,1],[4,5],[3,8]]\n[[3,1],[1,5]]", "[[1,1],[3,2],[2,3]]\n[[2,1],[3,2],[1,3]]", "[[1,3],[2,2]]\n[[7,1],[2,2],[1,4]]"], "hints": ["Map the weights using the corresponding values as keys.", "Make sure your output is sorted in ascending order by value."], "metadata": {"canonical_parameter_names": ["items1", "items2"], "leetcode_dataset_entry_point": "Solution().mergeSimilarItems", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:03+00:00", "tests_total": 100, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "sorting", "ordered-set"]}, "language": "python", "interface": {"raw_signature": "def mergeSimilarItems(self, items1: list[list[int]], items2: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "mergeSimilarItems", "parameters": [{"name": "items1", "type": "list[list[int]]"}, {"name": "items2", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2364, "task_id": "count-number-of-bad-pairs", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. A pair of indices (i, j) is a bad pair if i < j and j - i != nums[j] - nums[i].\n\nReturn the total number of bad pairs in nums.\n\nExample 1:\n\nInput: nums = [4,1,3,3]\nOutput: 5\nExplanation: The pair (0, 1) is a bad pair since 1 - 0 != 1 - 4.\nThe pair (0, 2) is a bad pair since 2 - 0 != 3 - 4, 2 != -1.\nThe pair (0, 3) is a bad pair since 3 - 0 != 3 - 4, 3 != -1.\nThe pair (1, 2) is a bad pair since 2 - 1 != 3 - 1, 1 != 2.\nThe pair (2, 3) is a bad pair since 3 - 2 != 3 - 3, 1 != 0.\nThere are a total of 5 bad pairs, so we return 5.\n\nExample 2:\n\nInput: nums = [1,2,3,4,5]\nOutput: 0\nExplanation: There are no bad pairs.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 3, 2, 4, 5]) == 7\n    assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 15\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 10\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 25\n    assert candidate(nums = [9, 7, 5, 3, 1]) == 10\n    assert candidate(nums = [1, 1, 1, 1]) == 6\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n    assert candidate(nums = [1, 3, 5, 7, 9]) == 10\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 41\n    assert candidate(nums = [10, 20, 30, 40, 50]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n    assert candidate(nums = [1, 2, 2, 3, 3, 3]) == 13\n    assert candidate(nums = [4, 1, 3, 3]) == 5\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 5]) == 16\n    assert candidate(nums = [1, 1, 1, 1, 1]) == 10\n    assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == 42\n    assert candidate(nums = [5, 4, 3, 2, 1]) == 10\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5]) == 21\n    assert candidate(nums = [5, 3, 1, 4, 2]) == 10\n    assert candidate(nums = [50, 40, 30, 20, 10]) == 10\n    assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 25\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 190\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 120\n    assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 25\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 44\n    assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996, 6, 999999995, 7, 999999994, 8, 999999993, 9, 999999992, 10, 999999991]) == 190\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 189\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 190\n    assert candidate(nums = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56, 67, 79, 92, 106]) == 104\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 190\n    assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9]) == 982\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 105\n    assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496]) == 465\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 10\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == 45\n    assert candidate(nums = [10, 20, 30, 20, 10, 20, 30, 20, 10, 20]) == 45\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 186\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 105\n    assert candidate(nums = [4, 7, 10, 13, 16, 19, 22, 25]) == 28\n    assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225]) == 105\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n    assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 9, 8, 10, 11, 13, 12, 14, 15, 17, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 272\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 435\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 190\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n    assert candidate(nums = [3, 8, 3, 8, 3, 8, 3, 8, 3, 8]) == 42\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 44\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 241\n    assert candidate(nums = [1, 2, 3, 4, 3, 4, 5, 6, 5, 6]) == 32\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 300\n    assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == 210\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n    assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 185\n    assert candidate(nums = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46]) == 44\n    assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]) == 63\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 496\n    assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1]) == 42\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 50\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 99\n    assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16, 17, 19, 18, 20, 21, 23, 22, 24, 25, 27, 26, 28, 29, 31, 30, 32, 33, 35, 34, 36, 37, 39, 38, 40]) == 500\n    assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 45\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 175\n    assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 35\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 45\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 245\n    assert candidate(nums = [10, 11, 13, 16, 20, 25, 31, 38, 46, 55, 65, 76, 88, 101, 115, 130, 146, 163, 181, 200, 220, 241, 263, 286, 310, 335, 361, 388, 416, 445]) == 434\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216]) == 299\n    assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 44\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 189\n    assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 17\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 435\n    assert candidate(nums = [100, 200, 150, 300, 250, 400, 350, 500, 450, 600]) == 45\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 45\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 200\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 45\n    assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 9, 8, 10, 11, 13, 12, 14, 15, 17, 16, 18, 19, 20]) == 112\n    assert candidate(nums = [1, 3, 2, 4, 5, 3, 2, 1]) == 25\n    assert candidate(nums = [1, 5, 14, 30, 55, 91, 140, 204, 285, 385, 506, 650, 819, 1015, 1240, 1496, 1785, 2109, 2470, 2870, 3311, 3795, 4324, 4890, 5495, 6131, 6798, 7490, 8210, 8951]) == 435\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 66\n    assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 45\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 45\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 65\n    assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 190\n    assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 190\n    assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 37\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 190\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517]) == 120\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 119\n    assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == 100\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 426\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 43\n    assert candidate(nums = [7, 7, 7, 10, 10, 10, 13, 13, 13, 16, 16, 16]) == 48\n    assert candidate(nums = [5, 1, 9, 3, 7, 11, 15, 2, 6, 10, 14, 18, 22, 26, 30]) == 103\n    assert candidate(nums = [1, 6, 3, 8, 5, 10, 7, 12, 9, 14, 11, 16, 13, 18, 15]) == 56\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 105\n    assert candidate(nums = [1, 2, 5, 10, 17, 26, 37, 50, 65, 82, 101, 122, 145, 170, 197, 226, 257, 290, 325, 362, 401, 442, 485, 530, 577, 626, 677, 730, 785, 842]) == 434\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n    assert candidate(nums = [100, 101, 102, 99, 98, 97, 96, 95, 94, 93]) == 42\n    assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]) == 102\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995]) == 15\n    assert candidate(nums = [5, 3, 1, 4, 2, 6, 8, 7, 10, 9]) == 40\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 45\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30]) == 1741\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 190\n    assert candidate(nums = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56]) == 54\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 385\n    assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n    assert candidate(nums = [1, 2, 3, 6, 11, 20, 37, 68, 129, 246, 473, 910]) == 63\n    assert candidate(nums = [1, 6, 15, 28, 45, 66, 91, 120, 153, 190, 231, 276, 325, 378, 435]) == 105\n    assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 180\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 105\n    assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 269\n    assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29, 32, 31, 34, 33, 36, 35, 38, 37, 40, 39, 42, 41, 44, 43, 46, 45, 48, 47, 50, 49, 52, 51, 54, 53, 56, 55]) == 784\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 190\n    assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100]) == 66\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 105\n", "comparison": "exact"}, "public_tests": ["[4,1,3,3]", "[1,2,3,4,5]"], "hints": ["Would it be easier to count the number of pairs that are not bad pairs?", "Notice that (j - i != nums[j] - nums[i]) is the same as (nums[i] - i != nums[j] - j).", "Keep a counter of nums[i] - i. To be efficient, use a HashMap."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countBadPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:05+00:00", "tests_total": 132, "tests_dropped": 9, "flags": [], "topic_tags": ["array", "hash-table", "math", "counting"]}, "language": "python", "interface": {"raw_signature": "def countBadPairs(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countBadPairs", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2365, "task_id": "task-scheduler-ii", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of positive integers tasks, representing tasks that need to be completed in order, where tasks[i] represents the type of the i^th task.\n\nYou are also given a positive integer space, which represents the minimum number of days that must pass after the completion of a task before another task of the same type can be performed.\n\nEach day, until all tasks have been completed, you must either:\n\n- Complete the next task from tasks, or\n- Take a break.\n\nReturn the minimum number of days needed to complete all tasks.\n\nExample 1:\n\nInput: tasks = [1,2,1,2,3,1], space = 3\nOutput: 9\nExplanation:\nOne way to complete all tasks in 9 days is as follows:\nDay 1: Complete the 0th task.\nDay 2: Complete the 1st task.\nDay 3: Take a break.\nDay 4: Take a break.\nDay 5: Complete the 2nd task.\nDay 6: Complete the 3rd task.\nDay 7: Take a break.\nDay 8: Complete the 4th task.\nDay 9: Complete the 5th task.\nIt can be shown that the tasks cannot be completed in less than 9 days.\n\nExample 2:\n\nInput: tasks = [5,8,8,5], space = 2\nOutput: 6\nExplanation:\nOne way to complete all tasks in 6 days is as follows:\nDay 1: Complete the 0th task.\nDay 2: Complete the 1st task.\nDay 3: Take a break.\nDay 4: Take a break.\nDay 5: Complete the 2nd task.\nDay 6: Complete the 3rd task.\nIt can be shown that the tasks cannot be completed in less than 6 days.\n\nConstraints:\n\n- 1 <= tasks.length <= 10^5\n- 1 <= tasks[i] <= 10^9\n- 1 <= space <= tasks.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 10) == 10\n    assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],space = 1) == 10\n    assert candidate(tasks = [1, 2, 3, 4, 5],space = 5) == 5\n    assert candidate(tasks = [1, 1, 1, 1, 1],space = 1) == 9\n    assert candidate(tasks = [1, 1, 1, 1],space = 2) == 10\n    assert candidate(tasks = [1, 1, 1, 1, 1],space = 5) == 25\n    assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],space = 5) == 10\n    assert candidate(tasks = [1, 2, 3, 4, 5],space = 1) == 5\n    assert candidate(tasks = [1, 1, 1, 1],space = 1) == 7\n    assert candidate(tasks = [1, 2, 1, 2, 3, 1],space = 3) == 9\n    assert candidate(tasks = [5, 8, 8, 5],space = 2) == 6\n    assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],space = 10) == 10\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 1) == 10\n    assert candidate(tasks = [1000000000, 999999999, 1000000000, 999999999, 1000000000],space = 3) == 9\n    assert candidate(tasks = [1, 3, 2, 3, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],space = 4) == 34\n    assert candidate(tasks = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],space = 1) == 36\n    assert candidate(tasks = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],space = 2) == 12\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 10) == 21\n    assert candidate(tasks = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10],space = 3) == 34\n    assert candidate(tasks = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],space = 20) == 191\n    assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],space = 1) == 39\n    assert candidate(tasks = [1, 2, 2, 1, 3, 4, 3, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9, 10, 9, 10],space = 5) == 41\n    assert candidate(tasks = [1000000000, 1, 2, 1000000000, 3, 4, 1000000000, 5],space = 2) == 8\n    assert candidate(tasks = [5, 1, 2, 5, 1, 2, 5, 1, 2],space = 3) == 11\n    assert candidate(tasks = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],space = 3) == 38\n    assert candidate(tasks = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],space = 5) == 29\n    assert candidate(tasks = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2],space = 2) == 64\n    assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],space = 1) == 19\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 15) == 20\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 4) == 20\n    assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],space = 9) == 91\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 15) == 30\n    assert candidate(tasks = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],space = 1) == 20\n    assert candidate(tasks = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6],space = 3) == 66\n    assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],space = 10) == 188\n    assert candidate(tasks = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],space = 5) == 17\n    assert candidate(tasks = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],space = 2) == 10\n    assert candidate(tasks = [5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],space = 5) == 25\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5],space = 4) == 25\n    assert candidate(tasks = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],space = 1) == 20\n    assert candidate(tasks = [1000000000, 999999999, 1000000000, 999999999, 1000000000],space = 2) == 7\n    assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 10) == 100\n    assert candidate(tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],space = 2) == 20\n    assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 10) == 210\n    assert candidate(tasks = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 1000000000],space = 5) == 11\n    assert candidate(tasks = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],space = 1) == 20\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 20) == 52\n    assert candidate(tasks = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985],space = 10) == 15\n    assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],space = 5) == 70\n    assert candidate(tasks = [1, 2, 3, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1],space = 2) == 20\n    assert candidate(tasks = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],space = 3) == 18\n    assert candidate(tasks = [1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3],space = 3) == 38\n    assert candidate(tasks = [1, 3, 5, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9],space = 5) == 20\n    assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],space = 3) == 77\n    assert candidate(tasks = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],space = 10) == 113\n    assert candidate(tasks = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50],space = 15) == 53\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 10) == 32\n    assert candidate(tasks = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],space = 1) == 12\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 19) == 20\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 5) == 20\n    assert candidate(tasks = [1, 2, 2, 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],space = 2) == 34\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 5) == 20\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 2) == 20\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 5) == 20\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],space = 3) == 18\n    assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],space = 5) == 140\n    assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],space = 9) == 91\n    assert candidate(tasks = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1],space = 3) == 31\n    assert candidate(tasks = [1000000000, 999999999, 1000000000, 999999999, 1000000000, 999999999],space = 5) == 14\n    assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],space = 2) == 40\n    assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],space = 3) == 75\n    assert candidate(tasks = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],space = 3) == 35\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 3) == 20\n    assert candidate(tasks = [1, 2, 3, 2, 1, 2, 1, 2, 1],space = 2) == 12\n    assert candidate(tasks = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5],space = 4) == 105\n    assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],space = 2) == 40\n    assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],space = 3) == 74\n    assert candidate(tasks = [1, 3, 2, 3, 1, 4, 2, 3, 1, 2, 4, 3, 1, 2, 3, 4, 1, 2, 3, 4],space = 4) == 28\n    assert candidate(tasks = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],space = 4) == 15\n    assert candidate(tasks = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8],space = 2) == 20\n    assert candidate(tasks = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1],space = 3) == 18\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 1) == 20\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5],space = 4) == 14\n    assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 5) == 265\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 10) == 30\n    assert candidate(tasks = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],space = 1) == 21\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],space = 4) == 18\n    assert candidate(tasks = [1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3],space = 2) == 36\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 1) == 20\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 20) == 20\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 1) == 30\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 15) == 46\n    assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 1) == 20\n    assert candidate(tasks = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],space = 4) == 47\n", "comparison": "exact"}, "public_tests": ["[1,2,1,2,3,1]\n3", "[5,8,8,5]\n2"], "hints": ["Try taking breaks as late as possible, such that tasks are still spaced appropriately.", "Whenever considering whether to complete the next task, if it is not the first task of its type, check how many days ago the previous task was completed and add an appropriate number of breaks."], "metadata": {"canonical_parameter_names": ["tasks", "space"], "leetcode_dataset_entry_point": "Solution().taskSchedulerII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:07+00:00", "tests_total": 102, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "hash-table", "simulation"]}, "language": "python", "interface": {"raw_signature": "def taskSchedulerII(self, tasks: list[int], space: int) -> int:", "container": "Solution", "callable": "taskSchedulerII", "parameters": [{"name": "tasks", "type": "list[int]"}, {"name": "space", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2366, "task_id": "minimum-replacements-to-sort-the-array", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums. In one operation you can replace any element of the array with any two elements that sum to it.\n\n- For example, consider nums = [5,6,7]. In one operation, we can replace nums[1] with 2 and 4 and convert nums to [5,2,4,7].\n\nReturn the minimum number of operations to make an array that is sorted in non-decreasing order.\n\nExample 1:\n\nInput: nums = [3,9,3]\nOutput: 2\nExplanation: Here are the steps to sort the array in non-decreasing order:\n- From [3,9,3], replace the 9 with 3 and 6 so the array becomes [3,3,6,3]\n- From [3,3,6,3], replace the 6 with 3 and 3 so the array becomes [3,3,3,3,3]\nThere are 2 steps to sort the array in non-decreasing order. Therefore, we return 2.\n\nExample 2:\n\nInput: nums = [1,2,3,4,5]\nOutput: 0\nExplanation: The array is already in non-decreasing order. Therefore, we return 0.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 1000000000]) == 0\n    assert candidate(nums = [9, 7, 5, 3, 1]) == 20\n    assert candidate(nums = [10, 5, 3]) == 5\n    assert candidate(nums = [100, 75, 50]) == 3\n    assert candidate(nums = [1, 3, 5, 7, 9]) == 0\n    assert candidate(nums = [1]) == 0\n    assert candidate(nums = [1000000000, 1000000000]) == 0\n    assert candidate(nums = [1000000000, 1000000000, 1000000000]) == 0\n    assert candidate(nums = [3, 9, 3]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9, 11]) == 0\n    assert candidate(nums = [9, 4, 2, 1]) == 12\n    assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [7, 8, 9, 10]) == 0\n    assert candidate(nums = [5, 4, 3, 2, 1]) == 10\n    assert candidate(nums = [5, 3, 2, 4, 1]) == 10\n    assert candidate(nums = [10, 3, 3, 3, 3]) == 3\n    assert candidate(nums = [1, 2, 5, 5, 5]) == 0\n    assert candidate(nums = [10, 5, 2]) == 11\n    assert candidate(nums = [100, 75, 50, 25]) == 6\n    assert candidate(nums = [10, 10, 10, 10, 10]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 190\n    assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000]) == 1999999998\n    assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100]) == 297\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 56\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99]) == 0\n    assert candidate(nums = [999999999, 100000000, 10000000, 1000000, 100000]) == 11106\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 1]) == 4950\n    assert candidate(nums = [99, 90, 81, 72, 63, 54, 45, 36, 27, 18, 9]) == 55\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 0\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 0\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 105\n    assert candidate(nums = [100, 50, 25, 12, 6, 3, 1, 1, 1, 1]) == 190\n    assert candidate(nums = [8, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n    assert candidate(nums = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000]) == 45\n    assert candidate(nums = [1000, 999, 998, 997, 996]) == 10\n    assert candidate(nums = [1, 3, 2, 6, 5, 4, 7, 8, 9, 10]) == 4\n    assert candidate(nums = [8, 22, 9, 11, 2]) == 41\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1]) == 3999999996\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1]) == 36\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 81\n    assert candidate(nums = [10, 15, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == 125\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 0\n    assert candidate(nums = [1, 10, 100, 1000, 10000]) == 0\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000]) == 57\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 45\n    assert candidate(nums = [7, 14, 7, 28, 14, 35, 21, 49, 28, 56]) == 4\n    assert candidate(nums = [20, 10, 20, 10, 20, 10, 20]) == 3\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000]) == 26\n    assert candidate(nums = [2, 6, 5, 4, 3, 2, 1]) == 16\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 45\n    assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 20\n    assert candidate(nums = [10, 5, 25, 15, 20, 50, 30, 100, 40, 60]) == 5\n    assert candidate(nums = [10, 20, 30, 25, 20, 15, 10]) == 16\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 1013\n    assert candidate(nums = [5, 20, 15, 10, 25, 30, 5, 40, 35, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 16\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 0\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n    assert candidate(nums = [3, 12, 15, 9, 6, 3]) == 10\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 45\n    assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 45\n    assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 9\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n    assert candidate(nums = [3, 10, 5, 15, 20, 25, 30, 5]) == 15\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n    assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625]) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n    assert candidate(nums = [50, 40, 30, 20, 10, 5, 3, 1]) == 151\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n    assert candidate(nums = [8, 12, 9, 6, 3, 1]) == 33\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 0\n    assert candidate(nums = [34, 34, 21, 21, 13, 13, 8, 8, 5, 5, 3, 3, 2, 2]) == 155\n    assert candidate(nums = [45, 36, 30, 24, 18, 15, 10, 5]) == 43\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 50]) == 9\n    assert candidate(nums = [8, 12, 8, 16, 8]) == 3\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5]) == 100\n    assert candidate(nums = [9, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 52\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 10\n    assert candidate(nums = [3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9]) == 44\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 81\n    assert candidate(nums = [10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35]) == 0\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 0\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1]) == 120\n    assert candidate(nums = [15, 10, 5, 10, 15, 20, 25, 30, 35, 40]) == 3\n    assert candidate(nums = [1000000000, 999999999, 999999998]) == 3\n    assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 10]) == 168\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4950\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 0\n    assert candidate(nums = [2, 2, 3, 3, 5, 5, 8, 8, 13, 13, 21, 21, 34, 34, 55, 55]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1]) == 9\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n    assert candidate(nums = [50, 40, 30, 20, 10, 5, 1, 1, 1, 1]) == 149\n    assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 0\n    assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2036\n    assert candidate(nums = [1, 10, 100, 1000, 10000]) == 0\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000]) == 57\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 0\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n", "comparison": "exact"}, "public_tests": ["[3,9,3]", "[1,2,3,4,5]"], "hints": ["It is optimal to never make an operation to the last element of the array.", "You can iterate from the second last element to the first. If the current value is greater than the previous bound, we want to break it into pieces so that the smaller one is as large as possible but not larger than the previous one."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumReplacement", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:10+00:00", "tests_total": 107, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "math", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minimumReplacement(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minimumReplacement", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2367, "task_id": "number-of-arithmetic-triplets", "difficulty": "Easy", "problem_description": "You are given a 0-indexed, strictly increasing integer array nums and a positive integer diff. A triplet (i, j, k) is an arithmetic triplet if the following conditions are met:\n\n- i < j < k,\n- nums[j] - nums[i] == diff, and\n- nums[k] - nums[j] == diff.\n\nReturn the number of unique arithmetic triplets.\n\nExample 1:\n\nInput: nums = [0,1,4,6,7,10], diff = 3\nOutput: 2\nExplanation:\n(1, 2, 4) is an arithmetic triplet because both 7 - 4 == 3 and 4 - 1 == 3.\n(2, 4, 5) is an arithmetic triplet because both 10 - 7 == 3 and 7 - 4 == 3.\n\nExample 2:\n\nInput: nums = [4,5,6,7,8,9], diff = 2\nOutput: 2\nExplanation:\n(0, 2, 4) is an arithmetic triplet because both 8 - 6 == 2 and 6 - 4 == 2.\n(1, 3, 5) is an arithmetic triplet because both 9 - 7 == 2 and 7 - 5 == 2.\n\nConstraints:\n\n- 3 <= nums.length <= 200\n- 0 <= nums[i] <= 200\n- 1 <= diff <= 50\n- nums is strictly increasing.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],diff = 2) == 5\n    assert candidate(nums = [5, 10, 15, 20, 25, 30],diff = 5) == 4\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],diff = 4) == 6\n    assert candidate(nums = [4, 5, 6, 7, 8, 9],diff = 2) == 2\n    assert candidate(nums = [1, 3, 5, 7, 9],diff = 2) == 3\n    assert candidate(nums = [0, 3, 6, 9, 12],diff = 3) == 3\n    assert candidate(nums = [0, 1, 4, 6, 7, 10],diff = 3) == 2\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41],diff = 4) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = 1) == 8\n    assert candidate(nums = [0, 2, 4, 6, 8, 10],diff = 2) == 4\n    assert candidate(nums = [10, 20, 30, 40, 50],diff = 10) == 3\n    assert candidate(nums = [2, 5, 8, 11, 14, 17, 20],diff = 3) == 5\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],diff = 3) == 8\n    assert candidate(nums = [10, 15, 20, 25, 30, 35],diff = 5) == 4\n    assert candidate(nums = [5, 10, 15, 20, 25],diff = 5) == 3\n    assert candidate(nums = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42],diff = 3) == 13\n    assert candidate(nums = [10, 18, 26, 34, 42, 50, 58, 66, 74, 82, 90, 98, 106, 114, 122],diff = 8) == 13\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],diff = 4) == 23\n    assert candidate(nums = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109],diff = 6) == 17\n    assert candidate(nums = [2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 74, 80, 86, 92, 98, 104, 110, 116, 122],diff = 6) == 19\n    assert candidate(nums = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85],diff = 6) == 13\n    assert candidate(nums = [3, 12, 21, 30, 39, 48, 57, 66, 75, 84, 93],diff = 9) == 9\n    assert candidate(nums = [0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72],diff = 6) == 11\n    assert candidate(nums = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50],diff = 5) == 9\n    assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160],diff = 8) == 18\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],diff = 5) == 18\n    assert candidate(nums = [5, 12, 19, 26, 33, 40, 47, 54, 61, 68],diff = 7) == 8\n    assert candidate(nums = [2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68],diff = 6) == 10\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133],diff = 7) == 17\n    assert candidate(nums = [1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92, 99, 106, 113, 120, 127, 134, 141, 148, 155, 162, 169, 176, 183, 190, 197],diff = 7) == 27\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],diff = 10) == 14\n    assert candidate(nums = [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80],diff = 4) == 19\n    assert candidate(nums = [1, 5, 9, 14, 19, 24, 29, 34, 39, 44, 49],diff = 4) == 1\n    assert candidate(nums = [2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 72],diff = 7) == 9\n    assert candidate(nums = [0, 2, 6, 8, 10, 14, 18, 20, 24, 28, 32, 34, 38, 40],diff = 2) == 1\n    assert candidate(nums = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191],diff = 10) == 18\n    assert candidate(nums = [3, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115],diff = 4) == 0\n    assert candidate(nums = [1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92, 99],diff = 7) == 13\n    assert candidate(nums = [1, 6, 9, 11, 15, 18, 21, 24, 27, 30],diff = 3) == 4\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198],diff = 11) == 16\n    assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117, 123, 129, 135, 141, 147, 153, 159, 165, 171, 177, 183, 189, 195],diff = 6) == 31\n    assert candidate(nums = [2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 72, 79, 86, 93],diff = 7) == 12\n    assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38],diff = 4) == 8\n    assert candidate(nums = [3, 11, 19, 27, 35, 43, 51, 59, 67, 75, 83, 91, 99, 107, 115, 123, 131, 139, 147, 155, 163, 171, 179],diff = 8) == 21\n    assert candidate(nums = [2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62],diff = 5) == 11\n    assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117, 123],diff = 6) == 19\n    assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96, 101, 106, 111],diff = 5) == 21\n    assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40],diff = 3) == 12\n    assert candidate(nums = [0, 5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 107, 113, 119, 125, 131, 137, 143, 149, 155, 161, 167, 173, 179, 185, 191, 197],diff = 7) == 0\n    assert candidate(nums = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45],diff = 5) == 8\n    assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51],diff = 5) == 9\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39],diff = 3) == 11\n    assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],diff = 3) == 8\n    assert candidate(nums = [2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77, 82, 87, 92, 97, 102],diff = 5) == 19\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],diff = 1) == 18\n    assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36, 41],diff = 5) == 7\n    assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71],diff = 6) == 10\n    assert candidate(nums = [7, 17, 27, 37, 47, 57, 67, 77, 87, 97],diff = 10) == 8\n    assert candidate(nums = [2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77, 82, 87, 92, 97],diff = 5) == 18\n    assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98],diff = 4) == 23\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],diff = 10) == 8\n    assert candidate(nums = [2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 74, 80, 86, 92, 98],diff = 6) == 15\n    assert candidate(nums = [0, 5, 11, 16, 22, 27, 33, 38, 44, 49],diff = 7) == 0\n    assert candidate(nums = [0, 3, 7, 12, 15, 19, 24, 27, 31, 36, 39, 43, 48, 51, 55, 60, 63, 67, 72],diff = 3) == 0\n    assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59],diff = 6) == 8\n    assert candidate(nums = [5, 12, 19, 26, 33, 40, 47, 54, 61, 68, 75, 82, 89],diff = 7) == 11\n    assert candidate(nums = [3, 8, 13, 18, 23, 28, 33, 38, 43, 48],diff = 5) == 8\n    assert candidate(nums = [5, 20, 35, 50, 65, 80, 95, 110, 125, 140, 155, 170, 185],diff = 15) == 11\n    assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34],diff = 3) == 10\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],diff = 10) == 18\n    assert candidate(nums = [3, 12, 21, 30, 39, 48, 57, 66, 75, 84, 93, 102, 111, 120, 129, 138, 147, 156, 165, 174],diff = 9) == 18\n    assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25],diff = 3) == 7\n    assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81],diff = 5) == 15\n    assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95],diff = 6) == 14\n    assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99],diff = 6) == 15\n    assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],diff = 2) == 9\n    assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20],diff = 1) == 0\n    assert candidate(nums = [1, 5, 8, 11, 14, 17, 20, 23, 26],diff = 3) == 6\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],diff = 1) == 19\n    assert candidate(nums = [0, 5, 10, 15, 20, 25, 30, 35, 40],diff = 5) == 7\n    assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43],diff = 4) == 9\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],diff = 10) == 18\n    assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61],diff = 3) == 19\n    assert candidate(nums = [1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 17, 18, 20, 21, 23, 24, 26, 27, 29, 30, 32, 33, 35, 36, 38, 39, 41, 42, 44, 45, 47, 48, 50, 51, 53, 54, 56, 57, 59, 60, 62, 63, 65, 66, 68, 69, 71, 72, 74, 75, 77, 78, 80, 81, 83, 84, 86, 87, 89, 90, 92, 93, 95, 96, 98, 99, 101, 102, 104, 105, 107, 108, 110, 111, 113, 114, 116, 117, 119, 120, 122, 123, 125, 126, 128, 129, 131, 132, 134, 135, 137, 138, 140, 141, 143, 144, 146, 147, 149, 150, 152, 153, 155, 156, 158, 159, 161, 162, 164, 165, 167, 168, 170, 171, 173, 174, 176, 177, 179, 180, 182, 183, 185, 186, 188, 189, 191, 192, 194, 195, 197, 198],diff = 2) == 1\n    assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22],diff = 3) == 6\n    assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96, 101, 106, 111, 116, 121, 126, 131, 136, 141, 146, 151, 156, 161, 166, 171, 176, 181, 186, 191, 196, 200],diff = 5) == 38\n    assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61],diff = 5) == 11\n    assert candidate(nums = [2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 72, 79, 86, 93, 100],diff = 7) == 13\n    assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],diff = 2) == 2\n    assert candidate(nums = [3, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],diff = 3) == 8\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101],diff = 4) == 24\n    assert candidate(nums = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97],diff = 6) == 15\n    assert candidate(nums = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100],diff = 15) == 0\n    assert candidate(nums = [7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67],diff = 5) == 11\n    assert candidate(nums = [3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73, 78, 83, 88, 93, 98],diff = 5) == 18\n    assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100, 109, 118, 127],diff = 9) == 13\n    assert candidate(nums = [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44],diff = 4) == 10\n    assert candidate(nums = [2, 10, 18, 26, 34, 42, 50, 58, 66, 74, 82, 90, 98, 106, 114],diff = 8) == 13\n    assert candidate(nums = [7, 17, 27, 37, 47, 57, 67, 77, 87, 97, 107, 117, 127, 137, 147, 157, 167, 177, 187, 197],diff = 10) == 18\n    assert candidate(nums = [3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53],diff = 5) == 9\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49],diff = 4) == 11\n    assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99],diff = 6) == 15\n    assert candidate(nums = [0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99],diff = 9) == 10\n    assert candidate(nums = [3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73],diff = 5) == 13\n", "comparison": "exact"}, "public_tests": ["[0,1,4,6,7,10]\n3", "[4,5,6,7,8,9]\n2"], "hints": ["Are the constraints small enough for brute force?", "We can use three loops, each iterating through the array to go through every possible triplet. Be sure to not count duplicates."], "metadata": {"canonical_parameter_names": ["nums", "diff"], "leetcode_dataset_entry_point": "Solution().arithmeticTriplets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:12+00:00", "tests_total": 104, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "two-pointers", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def arithmeticTriplets(self, nums: list[int], diff: int) -> int:", "container": "Solution", "callable": "arithmeticTriplets", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "diff", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2368, "task_id": "reachable-nodes-with-restrictions", "difficulty": "Medium", "problem_description": "There is an undirected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.\n\nYou are given a 2D integer array edges of length n - 1 where edges[i] = [a_i, b_i] indicates that there is an edge between nodes a_i and b_i in the tree. You are also given an integer array restricted which represents restricted nodes.\n\nReturn the maximum number of nodes you can reach from node 0 without visiting a restricted node.\n\nNote that node 0 will not be a restricted node.\n\nExample 1:\n\nInput: n = 7, edges = [[0,1],[1,2],[3,1],[4,0],[0,5],[5,6]], restricted = [4,5]\nOutput: 4\nExplanation: The diagram above shows the tree.\nWe have that [0,1,2,3] are the only nodes that can be reached from node 0 without visiting a restricted node.\n\nExample 2:\n\nInput: n = 7, edges = [[0,1],[0,2],[0,5],[0,4],[3,2],[6,5]], restricted = [4,2,1]\nOutput: 3\nExplanation: The diagram above shows the tree.\nWe have that [0,5,6] are the only nodes that can be reached from node 0 without visiting a restricted node.\n\nConstraints:\n\n- 2 <= n <= 10^5\n- edges.length == n - 1\n- edges[i].length == 2\n- 0 <= a_i, b_i < n\n- a_i != b_i\n- edges represents a valid tree.\n- 1 <= restricted.length < n\n- 1 <= restricted[i] < n\n- All the values of restricted are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 6,edges = [[0, 1], [0, 2], [2, 3], [2, 4], [4, 5]],restricted = [1, 4]) == 3\n    assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]],restricted = [5, 7]) == 6\n    assert candidate(n = 8,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 7]],restricted = [2, 4]) == 5\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],restricted = [7, 8]) == 8\n    assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [6, 7]],restricted = [3, 5]) == 6\n    assert candidate(n = 7,edges = [[0, 1], [1, 2], [3, 1], [4, 0], [0, 5], [5, 6]],restricted = [4, 5]) == 4\n    assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],restricted = [1, 2]) == 1\n    assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],restricted = [1, 5]) == 2\n    assert candidate(n = 7,edges = [[0, 1], [0, 2], [0, 5], [0, 4], [3, 2], [6, 5]],restricted = [4, 2, 1]) == 3\n    assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4]],restricted = [2, 3]) == 3\n    assert candidate(n = 5,edges = [[0, 1], [0, 2], [2, 3], [2, 4]],restricted = [3]) == 4\n    assert candidate(n = 30,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29]],restricted = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 4\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],restricted = [1, 5, 9]) == 5\n    assert candidate(n = 30,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29]],restricted = [12, 14, 16, 18, 20, 22, 24, 26, 28]) == 19\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],restricted = [2, 5, 8, 10]) == 6\n    assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]],restricted = [3, 7, 12, 16]) == 11\n    assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11]],restricted = [9, 10, 11]) == 9\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],restricted = [3, 5, 7, 9, 11]) == 8\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],restricted = [1, 5]) == 3\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],restricted = [2, 4]) == 5\n    assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24]],restricted = [3, 5, 8, 12, 15]) == 9\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],restricted = [1, 4, 6]) == 4\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],restricted = [8, 9, 10, 11]) == 11\n    assert candidate(n = 21,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 20]],restricted = [2, 6, 10, 15, 18, 20]) == 10\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],restricted = [2, 3, 5, 7, 9]) == 3\n    assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]],restricted = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == 4\n    assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24]],restricted = [5, 11, 17, 23]) == 19\n    assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]],restricted = [1, 2, 3, 5, 6, 7, 10]) == 1\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14]],restricted = [3, 5, 8]) == 8\n    assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19]],restricted = [2, 4, 7, 12]) == 6\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],restricted = [1, 3, 5]) == 3\n    assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]],restricted = [1, 3, 5, 7]) == 3\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],restricted = [1, 4, 7]) == 4\n    assert candidate(n = 16,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15]],restricted = [1, 4, 6, 7, 11]) == 4\n    assert candidate(n = 18,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [9, 17]],restricted = [1, 5, 8, 12, 15]) == 5\n    assert candidate(n = 12,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11]],restricted = [1, 2, 3, 4]) == 1\n    assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [7, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [10, 26], [10, 27], [11, 28], [11, 29]],restricted = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 1\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]],restricted = [2, 4, 6, 8]) == 5\n    assert candidate(n = 18,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17]],restricted = [1, 3, 5, 8, 11, 15]) == 5\n    assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24]],restricted = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 5\n    assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24]],restricted = [1, 5, 9, 13, 17, 21]) == 4\n    assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],restricted = [2, 6, 10]) == 7\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],restricted = [3, 5, 7]) == 6\n    assert candidate(n = 30,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29]],restricted = [2, 6, 10, 14, 18, 22, 26]) == 12\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14]],restricted = [2, 4, 6, 8]) == 6\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],restricted = [3, 5, 7, 10]) == 8\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],restricted = [2, 4, 7]) == 4\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],restricted = [1, 5, 10]) == 5\n    assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24]],restricted = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n    assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14]],restricted = [1, 4, 6, 9]) == 5\n    assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24]],restricted = [1, 3, 5, 8, 11, 15, 21]) == 5\n    assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19]],restricted = [1, 3, 5, 7, 9]) == 5\n    assert candidate(n = 30,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29]],restricted = [2, 4, 7, 12, 15, 20]) == 6\n    assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],restricted = [1, 4, 6, 9, 11]) == 3\n    assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]],restricted = [1, 3, 5, 8, 11]) == 5\n    assert candidate(n = 25,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [7, 20], [8, 21], [8, 22], [9, 23], [9, 24]],restricted = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 6\n    assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]],restricted = [2, 7, 9]) == 5\n    assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]],restricted = [3, 6, 9, 12, 15]) == 7\n    assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]],restricted = [3, 6, 8]) == 6\n    assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]],restricted = [3, 10, 15, 19]) == 13\n", "comparison": "exact"}, "public_tests": ["7\n[[0,1],[1,2],[3,1],[4,0],[0,5],[5,6]]\n[4,5]", "7\n[[0,1],[0,2],[0,5],[0,4],[3,2],[6,5]]\n[4,2,1]"], "hints": ["Can we find all the reachable nodes in a single traversal?", "Traverse the graph from node 0 while avoiding the nodes in restricted and do not revisit nodes that have been visited.", "Keep count of how many nodes are visited in total."], "metadata": {"canonical_parameter_names": ["n", "edges", "restricted"], "leetcode_dataset_entry_point": "Solution().reachableNodes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:15+00:00", "tests_total": 71, "tests_dropped": 11, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "hash-table", "tree", "depth-first-search", "breadth-first-search", "union-find", "graph"]}, "language": "python", "interface": {"raw_signature": "def reachableNodes(self, n: int, edges: list[list[int]], restricted: list[int]) -> int:", "container": "Solution", "callable": "reachableNodes", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "restricted", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2369, "task_id": "check-if-there-is-a-valid-partition-for-the-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. You have to partition the array into one or more contiguous subarrays.\n\nWe call a partition of the array valid if each of the obtained subarrays satisfies one of the following conditions:\n\n1. The subarray consists of exactly 2, equal elements. For example, the subarray [2,2] is good.\n2. The subarray consists of exactly 3, equal elements. For example, the subarray [4,4,4] is good.\n3. The subarray consists of exactly 3 consecutive increasing elements, that is, the difference between adjacent elements is 1. For example, the subarray [3,4,5] is good, but the subarray [1,3,5] is not.\n\nReturn true if the array has at least one valid partition. Otherwise, return false.\n\nExample 1:\n\nInput: nums = [4,4,4,5,6]\nOutput: true\nExplanation: The array can be partitioned into the subarrays [4,4] and [4,5,6].\nThis partition is valid, so we return true.\n\nExample 2:\n\nInput: nums = [1,1,1,2]\nOutput: false\nExplanation: There is no valid partition for this array.\n\nConstraints:\n\n- 2 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 2, 3, 4, 4, 5]) == False\n    assert candidate(nums = [2, 2, 2, 3, 3, 4, 4, 4]) == True\n    assert candidate(nums = [2, 2, 3, 3, 4, 4]) == True\n    assert candidate(nums = [1, 2, 3, 3, 3, 4, 5, 5]) == False\n    assert candidate(nums = [1, 1, 2, 3, 4, 4, 5, 6]) == True\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == True\n    assert candidate(nums = [1, 1, 1, 1]) == True\n    assert candidate(nums = [1, 2, 3, 3, 3, 3]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n    assert candidate(nums = [1, 3, 5, 7, 9]) == False\n    assert candidate(nums = [1, 1, 2, 2, 3, 3]) == True\n    assert candidate(nums = [1000000, 1000000]) == True\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == True\n    assert candidate(nums = [1, 1, 1, 2]) == False\n    assert candidate(nums = [1, 1, 2, 3, 4, 5, 5, 5]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5]) == False\n    assert candidate(nums = [4, 4, 4, 5, 6]) == True\n    assert candidate(nums = [1, 2, 2, 3, 3, 3]) == False\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6]) == True\n    assert candidate(nums = [1, 2, 3, 2, 2, 3, 4, 5]) == True\n    assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3]) == True\n    assert candidate(nums = [1, 2, 3]) == True\n    assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5]) == True\n    assert candidate(nums = [1, 1, 1, 1, 1, 1]) == True\n    assert candidate(nums = [2, 2, 3, 4, 5, 5, 5]) == True\n    assert candidate(nums = [2, 2]) == True\n    assert candidate(nums = [4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == True\n    assert candidate(nums = [1, 1, 1, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19]) == True\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 5, 6, 7, 8, 9, 10]) == False\n    assert candidate(nums = [1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10]) == False\n    assert candidate(nums = [1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == False\n    assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10, 11, 12, 13, 14, 15, 15, 15, 16, 17, 18, 19, 20, 20, 20, 21, 22, 23]) == False\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == True\n    assert candidate(nums = [5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 12, 13, 13, 14, 14, 14, 15, 15]) == True\n    assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9]) == True\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == False\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n    assert candidate(nums = [3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == True\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == True\n    assert candidate(nums = [5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == True\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7]) == True\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n    assert candidate(nums = [9, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == True\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 8, 8, 8, 9, 9, 10, 10]) == True\n    assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 11, 12, 13, 14, 15, 15, 15]) == True\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == True\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == True\n    assert candidate(nums = [2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 9, 10, 10, 11, 11, 11, 12, 12, 13, 13]) == True\n    assert candidate(nums = [9, 9, 10, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == False\n    assert candidate(nums = [3, 3, 3, 4, 5, 6, 7, 7, 8, 9, 10, 10, 10]) == True\n    assert candidate(nums = [10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 15, 16, 17, 18, 19, 19, 20]) == False\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n    assert candidate(nums = [5, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 13]) == True\n    assert candidate(nums = [5, 6, 7, 8, 8, 9, 10, 10, 11, 11]) == False\n    assert candidate(nums = [10, 10, 10, 11, 12, 12, 12, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 17, 17]) == True\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 4, 5, 6, 6, 6, 7, 8, 9, 10, 10, 10, 11, 12, 13, 14, 15, 15, 15, 16, 17, 18, 19, 20, 20, 20, 21, 22, 23]) == False\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11]) == True\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == True\n    assert candidate(nums = [1, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == True\n    assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == True\n    assert candidate(nums = [5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == True\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n    assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 24, 25, 26]) == False\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == True\n    assert candidate(nums = [1, 2, 3, 2, 2, 3, 4, 5, 6, 6, 6]) == True\n    assert candidate(nums = [1, 1, 2, 3, 4, 4, 4, 5, 6, 7, 8, 9, 10, 10, 10]) == True\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == True\n    assert candidate(nums = [5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 11, 11, 12, 12]) == True\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == True\n    assert candidate(nums = [5, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == False\n    assert candidate(nums = [1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == False\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == False\n    assert candidate(nums = [4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == False\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10]) == True\n    assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 6, 6, 7, 8, 9, 10, 11, 12, 12, 12]) == True\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == False\n    assert candidate(nums = [3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == True\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 21, 22, 22]) == False\n    assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == True\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12]) == True\n    assert candidate(nums = [3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 15, 16, 17, 18, 18, 19, 20]) == True\n    assert candidate(nums = [1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 10, 10, 10, 11, 12, 13, 14, 15, 15, 15, 16, 16, 16]) == True\n    assert candidate(nums = [2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == True\n    assert candidate(nums = [3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8]) == True\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 4, 5, 6, 6, 7, 8, 8, 8]) == False\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == True\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == True\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n    assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == True\n    assert candidate(nums = [1, 1, 1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10, 11, 12]) == False\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 11, 12, 13, 13, 13, 14, 14]) == True\n    assert candidate(nums = [1, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 15, 15, 16, 17, 18, 19]) == False\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8]) == True\n    assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == True\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8]) == False\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 25, 25, 26, 27, 28, 29, 30, 30, 30]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 14, 15, 16, 17, 18, 19, 20, 20, 21, 22, 23]) == False\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 12, 13, 13]) == False\n    assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18]) == False\n    assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == True\n    assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17]) == True\n    assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == False\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n    assert candidate(nums = [1, 2, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8]) == True\n    assert candidate(nums = [1, 2, 3, 3, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10, 10, 10, 11, 12, 13, 14, 15, 15, 15, 16, 17, 18, 19, 20, 20, 20, 21, 22, 23, 24, 25]) == False\n    assert candidate(nums = [9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13]) == True\n    assert candidate(nums = [1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10]) == False\n    assert candidate(nums = [9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23]) == True\n    assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == True\n    assert candidate(nums = [10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == True\n    assert candidate(nums = [2, 2, 3, 4, 5, 5, 5, 6, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == False\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15]) == True\n    assert candidate(nums = [10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22]) == True\n    assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 6, 6, 7, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17]) == False\n    assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8]) == True\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == False\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10]) == True\n    assert candidate(nums = [1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 8, 8, 9, 9]) == False\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n    assert candidate(nums = [2, 2, 3, 3, 4, 5, 5, 6, 6, 7]) == False\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == False\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == True\n", "comparison": "exact"}, "public_tests": ["[4,4,4,5,6]", "[1,1,1,2]"], "hints": ["How can you reduce the problem to checking if there is a valid partition for a smaller array?", "Use dynamic programming to reduce the problem until you have an empty array."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().validPartition", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:18+00:00", "tests_total": 134, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def validPartition(self, nums: list[int]) -> bool:", "container": "Solution", "callable": "validPartition", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2370, "task_id": "longest-ideal-subsequence", "difficulty": "Medium", "problem_description": "You are given a string s consisting of lowercase letters and an integer k. We call a string t ideal if the following conditions are satisfied:\n\n- t is a subsequence of the string s.\n- The absolute difference in the alphabet order of every two adjacent letters in t is less than or equal to k.\n\nReturn the length of the longest ideal string.\n\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n\nNote that the alphabet order is not cyclic. For example, the absolute difference in the alphabet order of 'a' and 'z' is 25, not 1.\n\nExample 1:\n\nInput: s = \"acfgbd\", k = 2\nOutput: 4\nExplanation: The longest ideal string is \"acbd\". The length of this string is 4, so 4 is returned.\nNote that \"acfgbd\" is not ideal because 'c' and 'f' have a difference of 3 in alphabet order.\n\nExample 2:\n\nInput: s = \"abcd\", k = 3\nOutput: 4\nExplanation: The longest ideal string is \"abcd\". The length of this string is 4, so 4 is returned.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- 0 <= k <= 25\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 25) == 20\n    assert candidate(s = \"a\",k = 0) == 1\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 0) == 1\n    assert candidate(s = \"abcd\",k = 3) == 4\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 1) == 26\n    assert candidate(s = \"a\",k = 5) == 1\n    assert candidate(s = \"abacabadabacaba\",k = 1) == 12\n    assert candidate(s = \"pqrspqrstuv\",k = 2) == 10\n    assert candidate(s = \"abcabcabcabc\",k = 2) == 12\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\",k = 25) == 27\n    assert candidate(s = \"acfgbd\",k = 2) == 4\n    assert candidate(s = \"aaaabbbbcccc\",k = 25) == 12\n    assert candidate(s = \"zzzzzzzzz\",k = 25) == 9\n    assert candidate(s = \"leetcode\",k = 2) == 5\n    assert candidate(s = \"abcabcabc\",k = 2) == 9\n    assert candidate(s = \"zyzyzyzyzyzyzyzyzyzy\",k = 1) == 20\n    assert candidate(s = \"triplebyte\",k = 2) == 3\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\",k = 1) == 52\n    assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabb\",k = 1) == 32\n    assert candidate(s = \"aaaabbbbccccddddeeeeffffgggg\",k = 2) == 28\n    assert candidate(s = \"aabcdefghijklmnopqrstuvwxyz\",k = 24) == 27\n    assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",k = 2) == 16\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == 26\n    assert candidate(s = \"abacabadabacaba\",k = 0) == 8\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 0) == 50\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 25) == 26\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 5) == 26\n    assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhh\",k = 3) == 32\n    assert candidate(s = \"aabcdefghijklmnopqrstuvwxyz\",k = 1) == 27\n    assert candidate(s = \"abababababababababababababababab\",k = 0) == 16\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\",k = 3) == 32\n    assert candidate(s = \"ababababababababababababababababab\",k = 0) == 17\n    assert candidate(s = \"abcdxyzabcdxyzabcdxyz\",k = 4) == 12\n    assert candidate(s = \"z\",k = 25) == 1\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 0) == 1\n    assert candidate(s = \"mississippiissipi\",k = 4) == 9\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 0) == 60\n    assert candidate(s = \"thisisaverylongstringthatneedstobechecked\",k = 3) == 17\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",k = 25) == 51\n    assert candidate(s = \"zzzzyyyyxxxwwvvuttsrrqqppoonnmmllkkjjiihhggffeeddccbbbaaa\",k = 3) == 57\n    assert candidate(s = \"qpwoeirutyalskdjfhgzmxncbv\",k = 4) == 11\n    assert candidate(s = \"aaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaab\",k = 0) == 40\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcd\",k = 3) == 28\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 2) == 29\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcd\",k = 3) == 24\n    assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\",k = 5) == 21\n    assert candidate(s = \"abacabacabacaba\",k = 1) == 12\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 25) == 52\n    assert candidate(s = \"zzzyyyxxxwwwwvvvuutttsssrqqppoonnmlkkjjiihhggffeeddccbbaaa\",k = 2) == 58\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 1) == 52\n    assert candidate(s = \"zabcdefghijklmnopqrstuvwxyz\",k = 24) == 26\n    assert candidate(s = \"bdfhjlnprtvxz\",k = 2) == 13\n    assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrs\",k = 2) == 16\n    assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 0) == 120\n    assert candidate(s = \"qwertypoiuytrewqazxcvbnmnbvcxz\",k = 5) == 15\n    assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",k = 5) == 22\n    assert candidate(s = \"qpqprqqpqrqpqrqpqrqpq\",k = 1) == 20\n    assert candidate(s = \"abcdxyzabcdxyzabcdxyz\",k = 3) == 12\n    assert candidate(s = \"mnopqrstuvwxyzabcdefghijkl\",k = 10) == 14\n    assert candidate(s = \"mmppqqrrssttuuvvwwxxyyzz\",k = 1) == 22\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 0) == 20\n    assert candidate(s = \"abababababababababababababababab\",k = 1) == 32\n    assert candidate(s = \"abcdefgabcdefgabcdefg\",k = 5) == 19\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 24) == 26\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 0) == 2\n    assert candidate(s = \"abacabadabacabadabacabad\",k = 1) == 18\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 2) == 26\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 3) == 30\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\",k = 12) == 52\n    assert candidate(s = \"aeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",k = 0) == 63\n    assert candidate(s = \"qpwoeirutyalskdjfhgxcvbnm\",k = 5) == 11\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 2) == 97\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 10) == 37\n    assert candidate(s = \"abcdefghijkalmnopqrstuvwxyz\",k = 2) == 26\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 25) == 84\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 2) == 52\n    assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\",k = 1) == 128\n    assert candidate(s = \"abcdabcdabcdabcd\",k = 3) == 16\n    assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\",k = 5) == 17\n    assert candidate(s = \"a\",k = 25) == 1\n    assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\",k = 5) == 14\n    assert candidate(s = \"mjmnjmmnjmnmjmmnj\",k = 0) == 8\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 24) == 26\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 24) == 52\n", "comparison": "exact"}, "public_tests": ["\"acfgbd\"\n2", "\"abcd\"\n3"], "hints": ["How can you calculate the longest ideal subsequence that ends at a specific index i?", "Can you calculate it for all positions i? How can you use previously calculated answers to calculate the answer for the next position?"], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().longestIdealString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:20+00:00", "tests_total": 85, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def longestIdealString(self, s: str, k: int) -> int:", "container": "Solution", "callable": "longestIdealString", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2373, "task_id": "largest-local-values-in-a-matrix", "difficulty": "Easy", "problem_description": "You are given an n x n integer matrix grid.\n\nGenerate an integer matrix maxLocal of size (n - 2) x (n - 2) such that:\n\n- maxLocal[i][j] is equal to the largest value of the 3 x 3 matrix in grid centered around row i + 1 and column j + 1.\n\nIn other words, we want to find the largest value in every contiguous 3 x 3 matrix in grid.\n\nReturn the generated matrix.\n\nExample 1:\n\nInput: grid = [[9,9,8,1],[5,6,2,6],[8,2,6,4],[6,2,2,2]]\nOutput: [[9,9],[8,6]]\nExplanation: The diagram above shows the original matrix and the generated matrix.\nNotice that each value in the generated matrix corresponds to the largest value of a contiguous 3 x 3 matrix in grid.\n\nExample 2:\n\nInput: grid = [[1,1,1,1,1],[1,1,1,1,1],[1,1,2,1,1],[1,1,1,1,1],[1,1,1,1,1]]\nOutput: [[2,2,2],[2,2,2],[2,2,2]]\nExplanation: Notice that the 2 is contained within every contiguous 3 x 3 matrix in grid.\n\nConstraints:\n\n- n == grid.length == grid[i].length\n- 3 <= n <= 100\n- 1 <= grid[i][j] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[5, 8, 4, 3], [3, 5, 9, 5], [7, 6, 7, 9], [4, 8, 5, 3]]) == [[9, 9], [9, 9]]\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 2, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == [[2, 2, 2], [2, 2, 2], [2, 2, 2]]\n    assert candidate(grid = [[100, 100, 100], [100, 100, 100], [100, 100, 100]]) == [[100]]\n    assert candidate(grid = [[9, 9, 8, 1], [5, 6, 2, 6], [8, 2, 6, 4], [6, 2, 2, 2]]) == [[9, 9], [8, 6]]\n    assert candidate(grid = [[1, 9, 2, 8, 3, 7, 4, 6, 5, 10], [11, 19, 12, 18, 13, 17, 14, 16, 15, 20], [21, 29, 22, 28, 23, 27, 24, 26, 25, 30], [31, 39, 32, 38, 33, 37, 34, 36, 35, 40], [41, 49, 42, 48, 43, 47, 44, 46, 45, 50], [51, 59, 52, 58, 53, 57, 54, 56, 55, 60], [61, 69, 62, 68, 63, 67, 64, 66, 65, 70], [71, 79, 72, 78, 73, 77, 74, 76, 75, 80], [81, 89, 82, 88, 83, 87, 84, 86, 85, 90], [91, 99, 92, 98, 93, 97, 94, 96, 95, 100]]) == [[29, 29, 28, 28, 27, 27, 26, 30], [39, 39, 38, 38, 37, 37, 36, 40], [49, 49, 48, 48, 47, 47, 46, 50], [59, 59, 58, 58, 57, 57, 56, 60], [69, 69, 68, 68, 67, 67, 66, 70], [79, 79, 78, 78, 77, 77, 76, 80], [89, 89, 88, 88, 87, 87, 86, 90], [99, 99, 98, 98, 97, 97, 96, 100]]\n    assert candidate(grid = [[9, 9, 9, 9], [9, 9, 9, 9], [9, 9, 9, 9], [9, 9, 9, 9]]) == [[9, 9], [9, 9]]\n    assert candidate(grid = [[100, 99, 98, 97, 96], [95, 94, 93, 92, 91], [90, 89, 88, 87, 86], [85, 84, 83, 82, 81], [80, 79, 78, 77, 76]]) == [[100, 99, 98], [95, 94, 93], [90, 89, 88]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]]) == [[15, 16, 17, 18], [21, 22, 23, 24], [27, 28, 29, 30], [33, 34, 35, 36]]\n    assert candidate(grid = [[100, 1, 100, 1, 100, 1], [1, 100, 1, 100, 1, 100], [100, 1, 100, 1, 100, 1], [1, 100, 1, 100, 1, 100], [100, 1, 100, 1, 100, 1], [1, 100, 1, 100, 1, 100]]) == [[100, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 100]]\n    assert candidate(grid = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70], [40, 50, 60, 70, 80], [50, 60, 70, 80, 90]]) == [[50, 60, 70], [60, 70, 80], [70, 80, 90]]\n    assert candidate(grid = [[50, 20, 30, 10, 60, 70, 80], [40, 10, 50, 30, 20, 60, 90], [60, 50, 40, 30, 20, 10, 70], [30, 40, 50, 60, 70, 80, 90], [20, 30, 40, 50, 60, 70, 80], [10, 20, 30, 40, 50, 60, 70], [5, 15, 25, 35, 45, 55, 65]]) == [[60, 50, 60, 70, 90], [60, 60, 70, 80, 90], [60, 60, 70, 80, 90], [50, 60, 70, 80, 90], [40, 50, 60, 70, 80]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 8, 6, 4, 2], [3, 6, 9, 12, 15, 12, 9, 6, 3], [4, 8, 12, 16, 20, 16, 12, 8, 4], [5, 10, 15, 20, 25, 20, 15, 10, 5], [6, 12, 18, 24, 30, 24, 18, 12, 6], [7, 14, 21, 28, 35, 28, 21, 14, 7]]) == [[9, 8, 9, 9, 9, 8, 9], [9, 8, 10, 10, 10, 8, 6], [9, 12, 15, 15, 15, 12, 9], [12, 16, 20, 20, 20, 16, 12], [15, 20, 25, 25, 25, 20, 15], [18, 24, 30, 30, 30, 24, 18], [21, 28, 35, 35, 35, 28, 21]]\n    assert candidate(grid = [[70, 23, 16, 35, 40, 97, 89], [22, 28, 48, 39, 78, 49, 21], [72, 84, 43, 26, 14, 62, 54], [92, 25, 15, 61, 32, 86, 19], [11, 98, 85, 29, 53, 77, 94], [59, 34, 82, 76, 83, 36, 93], [50, 60, 51, 44, 46, 63, 79]]) == [[84, 84, 78, 97, 97], [92, 84, 78, 86, 86], [98, 98, 85, 86, 94], [98, 98, 85, 86, 94], [98, 98, 85, 83, 94]]\n    assert candidate(grid = [[100, 1, 1, 1, 1, 1, 100], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [100, 1, 1, 1, 1, 1, 100]]) == [[100, 1, 1, 1, 100], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [100, 1, 1, 1, 100]]\n    assert candidate(grid = [[50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63], [64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77], [78, 79, 80, 81, 82, 83, 84], [85, 86, 87, 88, 89, 90, 91], [92, 93, 94, 95, 96, 97, 98]]) == [[66, 67, 68, 69, 70], [73, 74, 75, 76, 77], [80, 81, 82, 83, 84], [87, 88, 89, 90, 91], [94, 95, 96, 97, 98]]\n    assert candidate(grid = [[100, 99, 98, 97], [96, 95, 94, 93], [92, 91, 90, 89], [88, 87, 86, 85]]) == [[100, 99], [96, 95]]\n    assert candidate(grid = [[50, 50, 50, 50, 50, 50], [50, 1, 2, 3, 4, 50], [50, 6, 7, 8, 9, 50], [50, 10, 11, 12, 13, 50], [50, 14, 15, 16, 17, 50], [50, 50, 50, 50, 50, 50]]) == [[50, 50, 50, 50], [50, 12, 13, 50], [50, 16, 17, 50], [50, 50, 50, 50]]\n    assert candidate(grid = [[1, 10, 15, 20, 25, 30], [5, 6, 7, 8, 9, 10], [15, 20, 25, 30, 35, 40], [25, 30, 35, 40, 45, 50], [35, 40, 45, 50, 55, 60], [45, 50, 55, 60, 65, 70]]) == [[25, 30, 35, 40], [35, 40, 45, 50], [45, 50, 55, 60], [55, 60, 65, 70]]\n    assert candidate(grid = [[100, 1, 2, 3, 4], [1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8]]) == [[100, 5, 6], [5, 6, 7], [6, 7, 8]]\n    assert candidate(grid = [[99, 1, 2, 3, 4, 5, 6, 7, 8], [8, 99, 1, 2, 3, 4, 5, 6, 7], [7, 8, 99, 1, 2, 3, 4, 5, 6], [6, 7, 8, 99, 1, 2, 3, 4, 5], [5, 6, 7, 8, 99, 1, 2, 3, 4], [4, 5, 6, 7, 8, 99, 1, 2, 3], [3, 4, 5, 6, 7, 8, 99, 1, 2], [2, 3, 4, 5, 6, 7, 8, 99, 1], [1, 2, 3, 4, 5, 6, 7, 8, 99]]) == [[99, 99, 99, 5, 6, 7, 8], [99, 99, 99, 99, 5, 6, 7], [99, 99, 99, 99, 99, 5, 6], [8, 99, 99, 99, 99, 99, 5], [7, 8, 99, 99, 99, 99, 99], [6, 7, 8, 99, 99, 99, 99], [5, 6, 7, 8, 99, 99, 99]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [7, 8, 9, 10, 11, 12], [12, 11, 10, 9, 8, 7], [13, 14, 15, 16, 17, 18], [18, 17, 16, 15, 14, 13]]) == [[9, 10, 11, 12], [12, 11, 11, 12], [15, 16, 17, 18], [18, 17, 17, 18]]\n    assert candidate(grid = [[1, 3, 2, 1, 5], [4, 1, 5, 3, 2], [2, 5, 3, 4, 1], [3, 2, 4, 5, 3], [5, 4, 1, 2, 3]]) == [[5, 5, 5], [5, 5, 5], [5, 5, 5]]\n    assert candidate(grid = [[90, 91, 92, 93, 94, 95], [89, 88, 87, 86, 85, 84], [83, 82, 81, 80, 79, 78], [77, 76, 75, 74, 73, 72], [71, 70, 69, 68, 67, 66], [65, 64, 63, 62, 61, 60]]) == [[92, 93, 94, 95], [89, 88, 87, 86], [83, 82, 81, 80], [77, 76, 75, 74]]\n    assert candidate(grid = [[9, 1, 3, 5, 7, 9], [5, 3, 1, 7, 9, 5], [3, 5, 7, 1, 3, 7], [7, 9, 5, 3, 1, 9], [9, 7, 3, 5, 7, 1], [1, 9, 7, 5, 3, 5]]) == [[9, 7, 9, 9], [9, 9, 9, 9], [9, 9, 7, 9], [9, 9, 7, 9]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 8, 6, 4, 2], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 8, 6, 4, 2], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == [[9, 8, 9, 9, 9, 8, 9], [9, 8, 10, 10, 10, 8, 6], [6, 8, 10, 10, 10, 8, 9], [9, 8, 10, 10, 10, 8, 9], [9, 8, 9, 9, 9, 8, 9], [9, 8, 10, 10, 10, 8, 6], [6, 8, 10, 10, 10, 8, 9]]\n    assert candidate(grid = [[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10], [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30], [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50], [70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70], [90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100], [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [[32, 33, 34, 35, 36, 37, 38, 39, 40], [40, 39, 38, 37, 36, 37, 38, 39, 40], [52, 53, 54, 55, 56, 57, 58, 59, 60], [60, 59, 58, 57, 56, 57, 58, 59, 60], [72, 73, 74, 75, 76, 77, 78, 79, 80], [80, 79, 78, 77, 76, 77, 78, 79, 80], [92, 93, 94, 95, 96, 97, 98, 99, 100], [100, 99, 98, 97, 96, 97, 98, 99, 100], [100, 99, 98, 97, 96, 97, 98, 99, 100]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]]) == [[17, 18, 19, 20, 21], [24, 25, 26, 27, 28], [31, 32, 33, 34, 35], [38, 39, 40, 41, 42], [45, 46, 47, 48, 49]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3]]) == [[6, 5, 6, 7], [7, 6, 6, 7], [7, 6, 7, 8], [8, 7, 7, 8]]\n    assert candidate(grid = [[5, 3, 1, 2, 7, 8, 4, 9, 6], [4, 5, 6, 7, 8, 9, 1, 2, 3], [7, 8, 9, 1, 2, 3, 4, 5, 6], [2, 1, 3, 4, 5, 6, 7, 8, 9], [8, 9, 1, 2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8, 9, 1, 2], [6, 7, 8, 9, 1, 2, 3, 4, 5], [9, 1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == [[9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 6, 7, 8, 9], [9, 9, 7, 8, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 7, 8, 9]]\n    assert candidate(grid = [[1, 100, 2, 99, 3, 98], [100, 99, 2, 1, 3, 98], [99, 98, 1, 2, 100, 3], [3, 2, 100, 1, 99, 2], [2, 1, 99, 3, 100, 98], [100, 98, 3, 99, 2, 1]]) == [[100, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 100]]\n    assert candidate(grid = [[48, 12, 24, 87, 55, 96], [17, 94, 31, 76, 67, 33], [58, 28, 72, 57, 86, 52], [27, 74, 95, 65, 89, 60], [41, 62, 84, 43, 88, 9], [13, 77, 42, 82, 36, 70]]) == [[94, 94, 87, 96], [95, 95, 95, 89], [95, 95, 95, 89], [95, 95, 95, 89]]\n    assert candidate(grid = [[1, 1, 1, 100, 1, 1, 1, 1, 1], [1, 1, 1, 1, 100, 1, 1, 1, 1], [1, 1, 1, 1, 1, 100, 1, 1, 1], [1, 1, 1, 1, 1, 1, 100, 1, 1], [1, 1, 1, 1, 1, 1, 1, 100, 1], [1, 1, 1, 1, 1, 1, 1, 1, 100], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [[1, 100, 100, 100, 100, 100, 1], [1, 1, 100, 100, 100, 100, 100], [1, 1, 1, 100, 100, 100, 100], [1, 1, 1, 1, 100, 100, 100], [1, 1, 1, 1, 1, 100, 100], [1, 1, 1, 1, 1, 1, 100], [1, 1, 1, 1, 1, 1, 1]]\n    assert candidate(grid = [[83, 11, 52, 93, 48, 37, 29, 71, 88], [6, 13, 39, 96, 54, 15, 79, 38, 40], [87, 75, 99, 64, 49, 91, 27, 67, 56], [95, 70, 43, 25, 12, 81, 41, 69, 82], [9, 58, 66, 20, 33, 47, 80, 90, 65], [31, 55, 86, 46, 68, 74, 3, 16, 57], [4, 51, 73, 60, 85, 100, 5, 78, 18], [26, 32, 59, 45, 97, 7, 62, 53, 24], [63, 14, 98, 44, 35, 72, 8, 42, 17]]) == [[99, 99, 99, 96, 91, 91, 88], [99, 99, 99, 96, 91, 91, 82], [99, 99, 99, 91, 91, 91, 90], [95, 86, 86, 81, 81, 90, 90], [86, 86, 86, 100, 100, 100, 90], [86, 86, 97, 100, 100, 100, 78], [98, 98, 98, 100, 100, 100, 78]]\n    assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 7, 5, 3, 1, 2, 4, 6, 8], [8, 6, 4, 2, 1, 3, 5, 7, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 7, 5, 3, 1, 2, 4, 6, 8], [8, 6, 4, 2, 1, 3, 5, 7, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [[9, 8, 7, 6, 7, 8, 9], [9, 7, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 7, 9], [9, 8, 7, 6, 7, 8, 9], [9, 8, 7, 6, 7, 8, 9], [9, 7, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 7, 9]]\n    assert candidate(grid = [[10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 9, 9, 9, 9, 9, 9, 9, 10], [10, 9, 8, 8, 8, 8, 8, 9, 10], [10, 9, 8, 7, 7, 7, 8, 9, 10], [10, 9, 8, 7, 6, 7, 8, 9, 10], [10, 9, 8, 7, 7, 7, 8, 9, 10], [10, 9, 8, 8, 8, 8, 8, 9, 10], [10, 9, 9, 9, 9, 9, 9, 9, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10]]) == [[10, 10, 10, 10, 10, 10, 10], [10, 9, 9, 9, 9, 9, 10], [10, 9, 8, 8, 8, 9, 10], [10, 9, 8, 7, 8, 9, 10], [10, 9, 8, 8, 8, 9, 10], [10, 9, 9, 9, 9, 9, 10], [10, 10, 10, 10, 10, 10, 10]]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 9, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [[1, 1, 1, 1, 1, 1, 1], [1, 1, 9, 9, 9, 1, 1], [1, 1, 9, 9, 9, 1, 1], [1, 1, 9, 9, 9, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 2, 4, 6, 8], [8, 6, 4, 2, 1, 9, 7, 5, 3], [5, 1, 9, 7, 3, 6, 2, 8, 4], [2, 8, 6, 4, 7, 1, 3, 9, 5], [4, 9, 1, 3, 2, 8, 5, 7, 6], [3, 5, 2, 8, 4, 7, 6, 9, 1], [6, 7, 8, 9, 1, 2, 3, 4, 5]]) == [[9, 8, 9, 9, 9, 8, 9], [9, 8, 9, 9, 9, 9, 8], [9, 9, 9, 9, 9, 9, 8], [9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 8, 8, 9, 9], [9, 9, 8, 8, 8, 9, 9], [9, 9, 9, 9, 8, 9, 9]]\n    assert candidate(grid = [[32, 33, 34, 35, 36, 37, 38], [39, 40, 41, 42, 43, 44, 45], [46, 47, 48, 49, 50, 51, 52], [53, 54, 55, 56, 57, 58, 59], [60, 61, 62, 63, 64, 65, 66], [67, 68, 69, 70, 71, 72, 73], [74, 75, 76, 77, 78, 79, 80]]) == [[48, 49, 50, 51, 52], [55, 56, 57, 58, 59], [62, 63, 64, 65, 66], [69, 70, 71, 72, 73], [76, 77, 78, 79, 80]]\n    assert candidate(grid = [[1, 15, 3, 17, 7], [16, 18, 5, 14, 6], [12, 19, 9, 13, 11], [4, 8, 20, 1, 10], [15, 2, 16, 3, 18]]) == [[19, 19, 17], [20, 20, 20], [20, 20, 20]]\n    assert candidate(grid = [[100, 99, 98, 97, 96, 95], [94, 93, 92, 91, 90, 89], [88, 87, 86, 85, 84, 83], [82, 81, 80, 79, 78, 77], [76, 75, 74, 73, 72, 71], [70, 69, 68, 67, 66, 65]]) == [[100, 99, 98, 97], [94, 93, 92, 91], [88, 87, 86, 85], [82, 81, 80, 79]]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17], [2, 4, 6, 8, 10, 12, 14, 16, 18], [18, 16, 14, 12, 10, 8, 6, 4, 2], [17, 15, 13, 11, 9, 7, 5, 3, 1], [9, 7, 5, 3, 1, 2, 4, 6, 8], [8, 6, 4, 2, 1, 3, 5, 7, 9], [7, 8, 9, 1, 2, 3, 4, 5, 6]]) == [[9, 8, 9, 11, 13, 15, 17], [9, 8, 10, 12, 14, 16, 18], [18, 16, 14, 12, 14, 16, 18], [18, 16, 14, 12, 14, 16, 18], [18, 16, 14, 12, 10, 8, 8], [17, 15, 13, 11, 9, 7, 9], [9, 9, 9, 3, 5, 7, 9]]\n    assert candidate(grid = [[50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50]]) == [[50, 50, 50, 50, 50], [50, 50, 50, 50, 50], [50, 50, 50, 50, 50], [50, 50, 50, 50, 50], [50, 50, 50, 50, 50]]\n    assert candidate(grid = [[30, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 8], [3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10, 11], [6, 7, 8, 9, 10, 11, 12]]) == [[30, 5, 6, 7, 8], [5, 6, 7, 8, 9], [6, 7, 8, 9, 10], [7, 8, 9, 10, 11], [8, 9, 10, 11, 12]]\n    assert candidate(grid = [[10, 9, 8, 7, 6], [7, 6, 5, 4, 3], [8, 7, 6, 5, 4], [9, 8, 7, 6, 5], [10, 9, 8, 7, 6]]) == [[10, 9, 8], [9, 8, 7], [10, 9, 8]]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 3, 2, 1, 1], [1, 3, 5, 3, 1, 1], [1, 2, 3, 2, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == [[5, 5, 5, 3], [5, 5, 5, 3], [5, 5, 5, 3], [3, 3, 3, 2]]\n    assert candidate(grid = [[81, 82, 83, 84, 85, 86, 87], [88, 89, 90, 91, 92, 93, 94], [95, 96, 97, 98, 99, 100, 95], [94, 93, 92, 91, 90, 89, 88], [87, 86, 85, 84, 83, 82, 81], [82, 83, 84, 85, 86, 87, 88], [89, 90, 91, 92, 93, 94, 95]]) == [[97, 98, 99, 100, 100], [97, 98, 99, 100, 100], [97, 98, 99, 100, 100], [94, 93, 92, 91, 90], [91, 92, 93, 94, 95]]\n    assert candidate(grid = [[3, 3, 3, 3, 3, 3, 3], [3, 1, 2, 3, 4, 5, 3], [3, 4, 5, 6, 7, 8, 3], [3, 5, 6, 7, 8, 9, 3], [3, 6, 7, 8, 9, 8, 3], [3, 5, 6, 7, 8, 7, 3], [3, 3, 3, 3, 3, 3, 3]]) == [[5, 6, 7, 8, 8], [6, 7, 8, 9, 9], [7, 8, 9, 9, 9], [7, 8, 9, 9, 9], [7, 8, 9, 9, 9]]\n    assert candidate(grid = [[5, 1, 5, 1, 5], [1, 5, 1, 5, 1], [5, 1, 5, 1, 5], [1, 5, 1, 5, 1], [5, 1, 5, 1, 5]]) == [[5, 5, 5], [5, 5, 5], [5, 5, 5]]\n    assert candidate(grid = [[1, 50, 2, 51, 3, 52, 4, 53, 5], [5, 54, 6, 55, 7, 56, 8, 57, 9], [10, 59, 11, 60, 12, 61, 13, 62, 14], [15, 63, 16, 64, 17, 65, 18, 66, 19], [20, 67, 21, 68, 22, 69, 23, 70, 24], [25, 71, 26, 72, 27, 73, 28, 74, 29], [30, 75, 31, 76, 32, 77, 33, 78, 34], [35, 79, 36, 80, 37, 81, 38, 82, 39], [40, 83, 41, 84, 42, 85, 43, 86, 44]]) == [[59, 60, 60, 61, 61, 62, 62], [63, 64, 64, 65, 65, 66, 66], [67, 68, 68, 69, 69, 70, 70], [71, 72, 72, 73, 73, 74, 74], [75, 76, 76, 77, 77, 78, 78], [79, 80, 80, 81, 81, 82, 82], [83, 84, 84, 85, 85, 86, 86]]\n    assert candidate(grid = [[5, 1, 9, 3, 5, 7, 8, 2, 9, 10], [6, 2, 8, 4, 7, 5, 3, 8, 10, 7], [9, 3, 5, 8, 2, 10, 4, 7, 6, 5], [1, 4, 7, 9, 8, 6, 2, 10, 3, 9], [8, 6, 2, 7, 5, 9, 10, 4, 8, 6], [4, 7, 8, 6, 10, 2, 9, 5, 7, 4], [7, 5, 3, 9, 4, 8, 6, 10, 2, 8], [2, 8, 10, 5, 7, 3, 9, 6, 4, 7], [9, 6, 4, 7, 8, 10, 5, 2, 3, 1], [10, 7, 6, 5, 9, 4, 8, 7, 6, 5]]) == [[9, 9, 9, 10, 10, 10, 10, 10], [9, 9, 9, 10, 10, 10, 10, 10], [9, 9, 9, 10, 10, 10, 10, 10], [8, 9, 10, 10, 10, 10, 10, 10], [8, 9, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 9, 7]]\n", "comparison": "exact"}, "public_tests": ["[[9,9,8,1],[5,6,2,6],[8,2,6,4],[6,2,2,2]]", "[[1,1,1,1,1],[1,1,1,1,1],[1,1,2,1,1],[1,1,1,1,1],[1,1,1,1,1]]"], "hints": ["Use nested loops to run through all possible 3 x 3 windows in the matrix.", "For each 3 x 3 window, iterate through the values to get the maximum value within the window."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().largestLocal", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:25+00:00", "tests_total": 56, "tests_dropped": 6, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "matrix"]}, "language": "python", "interface": {"raw_signature": "def largestLocal(self, grid: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "largestLocal", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2374, "task_id": "node-with-highest-edge-score", "difficulty": "Medium", "problem_description": "You are given a directed graph with n nodes labeled from 0 to n - 1, where each node has exactly one outgoing edge.\n\nThe graph is represented by a given 0-indexed integer array edges of length n, where edges[i] indicates that there is a directed edge from node i to node edges[i].\n\nThe edge score of a node i is defined as the sum of the labels of all the nodes that have an edge pointing to i.\n\nReturn the node with the highest edge score. If multiple nodes have the same edge score, return the node with the smallest index.\n\nExample 1:\n\nInput: edges = [1,0,0,0,0,7,7,5]\nOutput: 7\nExplanation:\n- The nodes 1, 2, 3 and 4 have an edge pointing to node 0. The edge score of node 0 is 1 + 2 + 3 + 4 = 10.\n- The node 0 has an edge pointing to node 1. The edge score of node 1 is 0.\n- The node 7 has an edge pointing to node 5. The edge score of node 5 is 7.\n- The nodes 5 and 6 have an edge pointing to node 7. The edge score of node 7 is 5 + 6 = 11.\nNode 7 has the highest edge score so return 7.\n\nExample 2:\n\nInput: edges = [2,0,0,2]\nOutput: 0\nExplanation:\n- The nodes 1 and 2 have an edge pointing to node 0. The edge score of node 0 is 1 + 2 = 3.\n- The nodes 0 and 3 have an edge pointing to node 2. The edge score of node 2 is 0 + 3 = 3.\nNodes 0 and 2 both have an edge score of 3. Since node 0 has a smaller index, we return 0.\n\nConstraints:\n\n- n == edges.length\n- 2 <= n <= 10^5\n- 0 <= edges[i] < n\n- edges[i] != i\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(edges = [2, 0, 0, 2]) == 0\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 0\n    assert candidate(edges = [1, 0, 0, 0, 0, 7, 7, 5]) == 7\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 0]) == 0\n    assert candidate(edges = [5, 3, 0, 5, 1, 6, 2]) == 2\n    assert candidate(edges = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == 6\n    assert candidate(edges = [1, 2, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 0\n    assert candidate(edges = [1, 2, 0, 0, 3, 4, 5, 6, 7, 8, 9, 0]) == 0\n    assert candidate(edges = [8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7]) == 7\n    assert candidate(edges = [1, 2, 3, 4, 5, 6, 7, 0, 1, 2]) == 2\n    assert candidate(edges = [2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == 0\n", "comparison": "exact"}, "public_tests": ["[1,0,0,0,0,7,7,5]", "[2,0,0,2]"], "hints": ["Create an array arr where arr[i] is the edge score for node i.", "How does the edge score for node edges[i] change? It increases by i.", "The edge score may not fit within a standard 32-bit integer."], "metadata": {"canonical_parameter_names": ["edges"], "leetcode_dataset_entry_point": "Solution().edgeScore", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:27+00:00", "tests_total": 26, "tests_dropped": 15, "flags": ["has_images"], "topic_tags": ["hash-table", "graph"]}, "language": "python", "interface": {"raw_signature": "def edgeScore(self, edges: list[int]) -> int:", "container": "Solution", "callable": "edgeScore", "parameters": [{"name": "edges", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2375, "task_id": "construct-smallest-number-from-di-string", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string pattern of length n consisting of the characters 'I' meaning increasing and 'D' meaning decreasing.\n\nA 0-indexed string num of length n + 1 is created using the following conditions:\n\n- num consists of the digits '1' to '9', where each digit is used at most once.\n- If pattern[i] == 'I', then num[i] < num[i + 1].\n- If pattern[i] == 'D', then num[i] > num[i + 1].\n\nReturn the lexicographically smallest possible string num that meets the conditions.\n\nExample 1:\n\nInput: pattern = \"IIIDIDDD\"\nOutput: \"123549876\"\nExplanation:\nAt indices 0, 1, 2, and 4 we must have that num[i] < num[i+1].\nAt indices 3, 5, 6, and 7 we must have that num[i] > num[i+1].\nSome possible values of num are \"245639871\", \"135749862\", and \"123849765\".\nIt can be proven that \"123549876\" is the smallest possible num that meets the conditions.\nNote that \"123414321\" is not possible because the digit '1' is used more than once.\n\nExample 2:\n\nInput: pattern = \"DDD\"\nOutput: \"4321\"\nExplanation:\nSome possible values of num are \"9876\", \"7321\", and \"8742\".\nIt can be proven that \"4321\" is the smallest possible num that meets the conditions.\n\nConstraints:\n\n- 1 <= pattern.length <= 8\n- pattern consists of only the letters 'I' and 'D'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(pattern = \"DDD\") == \"4321\"\n    assert candidate(pattern = \"IIIDIDDD\") == \"123549876\"\n    assert candidate(pattern = \"ID\") == \"132\"\n    assert candidate(pattern = \"IIDDD\") == \"126543\"\n    assert candidate(pattern = \"DDIII\") == \"321456\"\n    assert candidate(pattern = \"IDID\") == \"13254\"\n    assert candidate(pattern = \"IIII\") == \"12345\"\n    assert candidate(pattern = \"DI\") == \"213\"\n    assert candidate(pattern = \"IID\") == \"1243\"\n    assert candidate(pattern = \"DDIDDIID\") == \"321654798\"\n    assert candidate(pattern = \"IDIDIDID\") == \"132547698\"\n    assert candidate(pattern = \"I\") == \"12\"\n    assert candidate(pattern = \"DID\") == \"2143\"\n    assert candidate(pattern = \"IIIII\") == \"123456\"\n    assert candidate(pattern = \"DDDDD\") == \"654321\"\n    assert candidate(pattern = \"D\") == \"21\"\n    assert candidate(pattern = \"DDDD\") == \"54321\"\n    assert candidate(pattern = \"DDDIDIII\") == \"432165789\"\n    assert candidate(pattern = \"DDDIIIII\") == \"432156789\"\n    assert candidate(pattern = \"IDDDDDID\") == \"176543298\"\n    assert candidate(pattern = \"IIDID\") == \"124365\"\n    assert candidate(pattern = \"DIIIDDDI\") == \"213487659\"\n    assert candidate(pattern = \"DDDDDDD\") == \"87654321\"\n    assert candidate(pattern = \"DIDIDIDI\") == \"214365879\"\n    assert candidate(pattern = \"DDDDDDDD\") == \"987654321\"\n    assert candidate(pattern = \"DDDDIIII\") == \"543216789\"\n    assert candidate(pattern = \"IIIDIDID\") == \"123547698\"\n    assert candidate(pattern = \"IDDDIIDI\") == \"154326879\"\n    assert candidate(pattern = \"IIDIDDDI\") == \"124387659\"\n    assert candidate(pattern = \"DIDIDID\") == \"21436587\"\n    assert candidate(pattern = \"DDDDIII\") == \"54321678\"\n    assert candidate(pattern = \"IDIDID\") == \"1325476\"\n    assert candidate(pattern = \"IIDIDIDI\") == \"124365879\"\n    assert candidate(pattern = \"DDDDDDI\") == \"76543218\"\n    assert candidate(pattern = \"DDIDDDID\") == \"321765498\"\n    assert candidate(pattern = \"DIIIIIII\") == \"213456789\"\n    assert candidate(pattern = \"IDDDIDII\") == \"154327689\"\n    assert candidate(pattern = \"DDIDIDID\") == \"321547698\"\n    assert candidate(pattern = \"IIIDDDDD\") == \"123987654\"\n    assert candidate(pattern = \"IIIIIID\") == \"12345687\"\n    assert candidate(pattern = \"IDIDDDID\") == \"132765498\"\n    assert candidate(pattern = \"IIIIIII\") == \"12345678\"\n    assert candidate(pattern = \"DDIIDDDD\") == \"321498765\"\n    assert candidate(pattern = \"IIIIIIID\") == \"123456798\"\n    assert candidate(pattern = \"DIIDIDID\") == \"213547698\"\n    assert candidate(pattern = \"DDIIDIDI\") == \"321465879\"\n    assert candidate(pattern = \"IIDDDIID\") == \"126543798\"\n    assert candidate(pattern = \"IIDDDIII\") == \"126543789\"\n    assert candidate(pattern = \"DIDID\") == \"214365\"\n    assert candidate(pattern = \"DDDDDIII\") == \"654321789\"\n    assert candidate(pattern = \"DDII\") == \"32145\"\n    assert candidate(pattern = \"DDDIDDDD\") == \"432198765\"\n    assert candidate(pattern = \"IDDDDDD\") == \"18765432\"\n    assert candidate(pattern = \"IDII\") == \"13245\"\n    assert candidate(pattern = \"DDDDDDII\") == \"765432189\"\n    assert candidate(pattern = \"IIIDDDDI\") == \"123876549\"\n    assert candidate(pattern = \"IDDDIDID\") == \"154327698\"\n    assert candidate(pattern = \"IIIIIDDI\") == \"123458769\"\n    assert candidate(pattern = \"DDDDDD\") == \"7654321\"\n    assert candidate(pattern = \"IIIIIDDD\") == \"123459876\"\n    assert candidate(pattern = \"DDDDIID\") == \"54321687\"\n    assert candidate(pattern = \"DDIIDDID\") == \"321476598\"\n    assert candidate(pattern = \"IIDDDDDD\") == \"129876543\"\n    assert candidate(pattern = \"IIDDDII\") == \"12654378\"\n    assert candidate(pattern = \"DDIIDIDD\") == \"321465987\"\n    assert candidate(pattern = \"IIDDIIDD\") == \"125436987\"\n    assert candidate(pattern = \"IIIIIIII\") == \"123456789\"\n    assert candidate(pattern = \"IIIDDDD\") == \"12387654\"\n    assert candidate(pattern = \"DDIID\") == \"321465\"\n", "comparison": "exact"}, "public_tests": ["\"IIIDIDDD\"", "\"DDD\""], "hints": ["With the constraints, could we generate every possible string?", "Yes we can. Now we just need to check if the string meets all the conditions."], "metadata": {"canonical_parameter_names": ["pattern"], "leetcode_dataset_entry_point": "Solution().smallestNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:30+00:00", "tests_total": 116, "tests_dropped": 47, "flags": [], "topic_tags": ["string", "backtracking", "stack", "greedy"]}, "language": "python", "interface": {"raw_signature": "def smallestNumber(self, pattern: str) -> str:", "container": "Solution", "callable": "smallestNumber", "parameters": [{"name": "pattern", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2376, "task_id": "count-special-integers", "difficulty": "Hard", "problem_description": "We call a positive integer special if all of its digits are distinct.\n\nGiven a positive integer n, return the number of special integers that belong to the interval [1, n].\n\nExample 1:\n\nInput: n = 20\nOutput: 19\nExplanation: All the integers from 1 to 20, except 11, are special. Thus, there are 19 special integers.\n\nExample 2:\n\nInput: n = 5\nOutput: 5\nExplanation: All the integers from 1 to 5 are special.\n\nExample 3:\n\nInput: n = 135\nOutput: 110\nExplanation: There are 110 integers from 1 to 135 that are special.\nSome of the integers that are not special are: 22, 114, and 131.\n\nConstraints:\n\n- 1 <= n <= 2 * 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 135) == 110\n    assert candidate(n = 999) == 738\n    assert candidate(n = 200) == 162\n    assert candidate(n = 10000) == 5274\n    assert candidate(n = 1234) == 803\n    assert candidate(n = 2000) == 1242\n    assert candidate(n = 9876) == 5274\n    assert candidate(n = 123456789) == 2392084\n    assert candidate(n = 20) == 19\n    assert candidate(n = 2000000) == 229050\n    assert candidate(n = 2000000000) == 5974650\n    assert candidate(n = 300) == 234\n    assert candidate(n = 100) == 90\n    assert candidate(n = 1999999999) == 5974650\n    assert candidate(n = 1000) == 738\n    assert candidate(n = 1) == 1\n    assert candidate(n = 5) == 5\n    assert candidate(n = 222222222) == 2789370\n    assert candidate(n = 210) == 171\n    assert candidate(n = 999999999) == 5611770\n    assert candidate(n = 12345) == 5660\n    assert candidate(n = 9999999) == 712890\n    assert candidate(n = 111111) == 34170\n    assert candidate(n = 111222333) == 2386170\n    assert candidate(n = 111) == 98\n    assert candidate(n = 213456789) == 2754964\n    assert candidate(n = 987654) == 168570\n    assert candidate(n = 876543210) == 5202657\n    assert candidate(n = 200000) == 47610\n    assert candidate(n = 101010101) == 2345850\n    assert candidate(n = 200000000) == 2708730\n    assert candidate(n = 12344321) == 735990\n    assert candidate(n = 543210987) == 3975354\n    assert candidate(n = 1122334455) == 5652090\n    assert candidate(n = 9999) == 5274\n    assert candidate(n = 555555555) == 3998970\n    assert candidate(n = 1111111) == 175290\n    assert candidate(n = 1000000000) == 5611770\n    assert candidate(n = 88888) == 29130\n    assert candidate(n = 1000000001) == 5611770\n    assert candidate(n = 111111111) == 2386170\n    assert candidate(n = 987654321) == 5611770\n    assert candidate(n = 888888888) == 5208570\n    assert candidate(n = 1234567890) == 5658004\n    assert candidate(n = 567890123) == 4028371\n    assert candidate(n = 101010) == 32490\n    assert candidate(n = 987654320) == 5611769\n    assert candidate(n = 98765) == 32490\n    assert candidate(n = 1000000) == 168570\n    assert candidate(n = 999999) == 168570\n    assert candidate(n = 123456) == 34417\n    assert candidate(n = 87654321) == 2141294\n    assert candidate(n = 1111111111) == 5652090\n", "comparison": "exact"}, "public_tests": ["20", "5", "135"], "hints": ["Try to think of dynamic programming.", "Use the idea of digit dynamic programming to build the numbers, in addition to a bitmask that will tell which digits you have used so far on the number that you are building."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countSpecialNumbers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:32+00:00", "tests_total": 57, "tests_dropped": 4, "flags": [], "topic_tags": ["math", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def countSpecialNumbers(self, n: int) -> int:", "container": "Solution", "callable": "countSpecialNumbers", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2379, "task_id": "minimum-recolors-to-get-k-consecutive-black-blocks", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string blocks of length n, where blocks[i] is either 'W' or 'B', representing the color of the i^th block. The characters 'W' and 'B' denote the colors white and black, respectively.\n\nYou are also given an integer k, which is the desired number of consecutive black blocks.\n\nIn one operation, you can recolor a white block such that it becomes a black block.\n\nReturn the minimum number of operations needed such that there is at least one occurrence of k consecutive black blocks.\n\nExample 1:\n\nInput: blocks = \"WBBWWBBWBW\", k = 7\nOutput: 3\nExplanation:\nOne way to achieve 7 consecutive black blocks is to recolor the 0th, 3rd, and 4th blocks\nso that blocks = \"BBBBBBBWBW\".\nIt can be shown that there is no way to achieve 7 consecutive black blocks in less than 3 operations.\nTherefore, we return 3.\n\nExample 2:\n\nInput: blocks = \"WBWBBBW\", k = 2\nOutput: 0\nExplanation:\nNo changes need to be made, since 2 consecutive black blocks already exist.\nTherefore, we return 0.\n\nConstraints:\n\n- n == blocks.length\n- 1 <= n <= 100\n- blocks[i] is either 'W' or 'B'.\n- 1 <= k <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(blocks = \"WWWW\",k = 2) == 2\n    assert candidate(blocks = \"WBBBWWBBBW\",k = 3) == 0\n    assert candidate(blocks = \"WBBWWBBWBW\",k = 7) == 3\n    assert candidate(blocks = \"BBBBB\",k = 3) == 0\n    assert candidate(blocks = \"BWBWBWBWBW\",k = 6) == 3\n    assert candidate(blocks = \"WWWWWW\",k = 4) == 4\n    assert candidate(blocks = \"WWWWWW\",k = 3) == 3\n    assert candidate(blocks = \"BBBB\",k = 4) == 0\n    assert candidate(blocks = \"BBBBBB\",k = 4) == 0\n    assert candidate(blocks = \"WBWBBBW\",k = 2) == 0\n    assert candidate(blocks = \"WBWBWBWBWB\",k = 5) == 2\n    assert candidate(blocks = \"BBBBBB\",k = 3) == 0\n    assert candidate(blocks = \"BBBBBBBBBBBBBBBBBBBB\",k = 20) == 0\n    assert candidate(blocks = \"BBWBBWBBWBBWBBWBBWBBWBBWBBWBBWBBW\",k = 14) == 4\n    assert candidate(blocks = \"WBBBWWWWWWBBBWWBB\",k = 7) == 2\n    assert candidate(blocks = \"WBWBWBWBWBWBWBWBWB\",k = 10) == 5\n    assert candidate(blocks = \"WBBWWBBWWBBWWBBWWBBW\",k = 8) == 4\n    assert candidate(blocks = \"WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWB\",k = 10) == 5\n    assert candidate(blocks = \"WBWBWBWBWBWBWB\",k = 5) == 2\n    assert candidate(blocks = \"WWBBWWBBWWBBWWBBWWBB\",k = 6) == 2\n    assert candidate(blocks = \"BWBWBWBWBWBWBWBWBWBWBWBWBW\",k = 7) == 3\n    assert candidate(blocks = \"BBWWBBWWBBW\",k = 5) == 2\n    assert candidate(blocks = \"BWBWBWBWBWBWBW\",k = 7) == 3\n    assert candidate(blocks = \"WBBBWWBBBWBBBWWBBB\",k = 7) == 1\n    assert candidate(blocks = \"BBBBBBBBBBBBBBBB\",k = 16) == 0\n    assert candidate(blocks = \"BBBBBBWWBBWWBBWWBBWW\",k = 6) == 0\n    assert candidate(blocks = \"WWBWWBBWWB\",k = 6) == 3\n    assert candidate(blocks = \"WWWWBBWWWBBWWBBWWB\",k = 5) == 2\n    assert candidate(blocks = \"WBBWWWWBBBWBWWBBB\",k = 8) == 3\n    assert candidate(blocks = \"BBWWBBWWBBWWBBWW\",k = 4) == 2\n    assert candidate(blocks = \"BWWBWWBWWBWWBWWBWWBW\",k = 7) == 4\n    assert candidate(blocks = \"BWBWBWBWBWBWBWBWBWBW\",k = 15) == 7\n    assert candidate(blocks = \"WWWWWWWWWW\",k = 10) == 10\n    assert candidate(blocks = \"WWBWWBWWBWWBWWBWWBWWBWWBWWB\",k = 3) == 2\n    assert candidate(blocks = \"WBBBBBBWBBBBBBW\",k = 10) == 1\n    assert candidate(blocks = \"BBBWBBWWWWBBBWWBBB\",k = 6) == 1\n    assert candidate(blocks = \"BBBBBBBWWWWWWWBBBBBB\",k = 8) == 1\n    assert candidate(blocks = \"WWWWBWWWWBWWWWBWWWWB\",k = 4) == 3\n    assert candidate(blocks = \"WBBWBBWBBWBBWBBW\",k = 7) == 2\n    assert candidate(blocks = \"BWBWBWBWBWBWBWBWBW\",k = 10) == 5\n    assert candidate(blocks = \"BWBWBWBWBW\",k = 4) == 2\n    assert candidate(blocks = \"WBBBWWBBBWWBBB\",k = 6) == 2\n    assert candidate(blocks = \"WWWWWBBBWBBBWWWW\",k = 7) == 1\n    assert candidate(blocks = \"BBBWWWBBBWWWBBB\",k = 9) == 3\n    assert candidate(blocks = \"WBBWBWBWBWBWBWBWBW\",k = 8) == 3\n    assert candidate(blocks = \"WWWWWWWW\",k = 4) == 4\n    assert candidate(blocks = \"BBWWBBWWBBWW\",k = 4) == 2\n    assert candidate(blocks = \"WWBBBWWBBBWWBBBWW\",k = 5) == 2\n    assert candidate(blocks = \"WWWWWWWWWW\",k = 5) == 5\n    assert candidate(blocks = \"WWWWWWWWWWWWWWWWWWWW\",k = 15) == 15\n    assert candidate(blocks = \"BBBBBBBBBWWWWWWWWW\",k = 9) == 0\n    assert candidate(blocks = \"BBBBBB\",k = 6) == 0\n    assert candidate(blocks = \"BWBWBWBWBWBWBWBWBWBW\",k = 9) == 4\n    assert candidate(blocks = \"BWBWBWBWBWBWBWBWBWBWBW\",k = 11) == 5\n    assert candidate(blocks = \"BBBBBBBBBB\",k = 5) == 0\n    assert candidate(blocks = \"BBBBWWBBBWBWB\",k = 6) == 2\n    assert candidate(blocks = \"BBBBWBWBWBWBWBWBWB\",k = 11) == 4\n    assert candidate(blocks = \"WBBBBBBBBBBBBBBBBBBBBBBBBBBW\",k = 25) == 0\n    assert candidate(blocks = \"BBBBBBWWWWWW\",k = 4) == 0\n    assert candidate(blocks = \"BBBWWBWBWBWBWBW\",k = 6) == 2\n    assert candidate(blocks = \"BWBWBWBWBWBWBWBW\",k = 8) == 4\n    assert candidate(blocks = \"WBBWWBBWBWWBBWBBWBWBWBWB\",k = 12) == 5\n    assert candidate(blocks = \"BBBWWWBBBWWWBBBWWWBB\",k = 5) == 2\n    assert candidate(blocks = \"WWBBWWBBWWBBWWBBWW\",k = 5) == 2\n    assert candidate(blocks = \"BBBBBBBWBBB\",k = 8) == 1\n    assert candidate(blocks = \"WBBBWWBBBWWBBB\",k = 8) == 2\n    assert candidate(blocks = \"BBBWBBBWWBBBWWBBBWWB\",k = 7) == 1\n    assert candidate(blocks = \"BBWWWWWWWWWW\",k = 3) == 1\n    assert candidate(blocks = \"BWBWBWBWBW\",k = 8) == 4\n    assert candidate(blocks = \"WBBBWBWBWBWBBB\",k = 5) == 1\n    assert candidate(blocks = \"WWBWBWBWBW\",k = 5) == 2\n    assert candidate(blocks = \"WBBWWBBWBBWWBBWBBWBBWWBBWB\",k = 8) == 2\n    assert candidate(blocks = \"BBWWBBWWBBWWBBWWBBWWBBWW\",k = 5) == 2\n    assert candidate(blocks = \"WBBBWWBBBWBBBWWBBB\",k = 6) == 1\n    assert candidate(blocks = \"WBWBWBWBWBWBWBWBWBWB\",k = 10) == 5\n    assert candidate(blocks = \"BWBWBWBWBWBWBWBW\",k = 6) == 3\n    assert candidate(blocks = \"WBBWBBWWBBWWBBWBBWBBW\",k = 8) == 2\n    assert candidate(blocks = \"WBBWWBBWBWWBBWBBW\",k = 10) == 4\n    assert candidate(blocks = \"BWWWWBBWWWWBBWWWW\",k = 7) == 4\n    assert candidate(blocks = \"BBBWBWBBBBBBBWB\",k = 9) == 1\n    assert candidate(blocks = \"WWWWWWWWWWWW\",k = 5) == 5\n    assert candidate(blocks = \"WBBWWWWBWBWWB\",k = 6) == 3\n    assert candidate(blocks = \"WWBBWWBBWWBBWWBBWWBB\",k = 4) == 2\n    assert candidate(blocks = \"WBBWBBWBBWBBWBBWBBWB\",k = 10) == 3\n    assert candidate(blocks = \"BBWWBBWWBBWWBBWWBB\",k = 4) == 2\n    assert candidate(blocks = \"BWWBWWBWWBWWBWWBWW\",k = 6) == 4\n    assert candidate(blocks = \"WWWBWWWWBWBWWB\",k = 4) == 2\n    assert candidate(blocks = \"WBWBWBWBWBWBWBWBWBWB\",k = 5) == 2\n    assert candidate(blocks = \"WBBWBBWBBWBBWBBWBBWB\",k = 9) == 3\n    assert candidate(blocks = \"BBBBBBBWWWWWWWWWW\",k = 7) == 0\n    assert candidate(blocks = \"WWWWWWWWWWWWWWWWWWWW\",k = 1) == 1\n    assert candidate(blocks = \"WBBWWBBWWBBWWBBWWBBWWBBW\",k = 7) == 3\n    assert candidate(blocks = \"WWWWBBWWWWBBWWWWBBWWWWBB\",k = 4) == 2\n    assert candidate(blocks = \"WWBBWWBBWWBBWW\",k = 5) == 2\n    assert candidate(blocks = \"WWWWBWWWWBWWWWB\",k = 4) == 3\n    assert candidate(blocks = \"BBBBBBBBBB\",k = 10) == 0\n    assert candidate(blocks = \"BBBBBBBBBBBBBBBBBBBB\",k = 10) == 0\n    assert candidate(blocks = \"WWWWWWWWWWWWWW\",k = 5) == 5\n    assert candidate(blocks = \"WWBBWWBBWWBBWW\",k = 6) == 2\n    assert candidate(blocks = \"BBBBBWWBBBWWBBBWWBBBWWBBB\",k = 5) == 0\n    assert candidate(blocks = \"BWBWBWBWBWBWBWBWBWBWBWBWBWBWBW\",k = 15) == 7\n", "comparison": "exact"}, "public_tests": ["\"WBBWWBBWBW\"\n7", "\"WBWBBBW\"\n2"], "hints": ["Iterate through all possible consecutive substrings of k characters.", "Find the number of changes for each substring to make all blocks black, and return the minimum of these."], "metadata": {"canonical_parameter_names": ["blocks", "k"], "leetcode_dataset_entry_point": "Solution().minimumRecolors", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:37+00:00", "tests_total": 101, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def minimumRecolors(self, blocks: str, k: int) -> int:", "container": "Solution", "callable": "minimumRecolors", "parameters": [{"name": "blocks", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2380, "task_id": "time-needed-to-rearrange-a-binary-string", "difficulty": "Medium", "problem_description": "You are given a binary string s. In one second, all occurrences of \"01\" are simultaneously replaced with \"10\". This process repeats until no occurrences of \"01\" exist.\n\nReturn the number of seconds needed to complete this process.\n\nExample 1:\n\nInput: s = \"0110101\"\nOutput: 4\nExplanation:\nAfter one second, s becomes \"1011010\".\nAfter another second, s becomes \"1101100\".\nAfter the third second, s becomes \"1110100\".\nAfter the fourth second, s becomes \"1111000\".\nNo occurrence of \"01\" exists any longer, and the process needed 4 seconds to complete,\nso we return 4.\n\nExample 2:\n\nInput: s = \"11100\"\nOutput: 0\nExplanation:\nNo occurrence of \"01\" exists in s, and the processes needed 0 seconds to complete,\nso we return 0.\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- s[i] is either '0' or '1'.\n\nFollow up:\n\nCan you solve this problem in O(n) time complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"1111\") == 0\n    assert candidate(s = \"00110011\") == 5\n    assert candidate(s = \"0000\") == 0\n    assert candidate(s = \"111000\") == 0\n    assert candidate(s = \"0010110\") == 4\n    assert candidate(s = \"1001001\") == 4\n    assert candidate(s = \"000011110000\") == 7\n    assert candidate(s = \"000111\") == 5\n    assert candidate(s = \"1001001001\") == 6\n    assert candidate(s = \"11111\") == 0\n    assert candidate(s = \"01010101\") == 4\n    assert candidate(s = \"10101010\") == 3\n    assert candidate(s = \"110100110\") == 4\n    assert candidate(s = \"1010101010\") == 4\n    assert candidate(s = \"101010\") == 2\n    assert candidate(s = \"1000000\") == 0\n    assert candidate(s = \"11001100\") == 3\n    assert candidate(s = \"11100\") == 0\n    assert candidate(s = \"0101010101\") == 5\n    assert candidate(s = \"0110101\") == 4\n    assert candidate(s = \"0110011001\") == 5\n    assert candidate(s = \"00000\") == 0\n    assert candidate(s = \"0010010010\") == 6\n    assert candidate(s = \"101010101010101010\") == 8\n    assert candidate(s = \"011010101010101010100110\") == 12\n    assert candidate(s = \"0010101010101010\") == 8\n    assert candidate(s = \"000000000000000000000000000111111111111111111111111111111111111111111111111\") == 74\n    assert candidate(s = \"01001010100101010010\") == 11\n    assert candidate(s = \"11101110111011101110111011101110111011101110\") == 30\n    assert candidate(s = \"00000000111111111111\") == 19\n    assert candidate(s = \"1100110011001100\") == 7\n    assert candidate(s = \"111011101110111011101110111011101110111011101110\") == 33\n    assert candidate(s = \"000111000111000111000111000111000111\") == 20\n    assert candidate(s = \"10101010101010101010101010\") == 12\n    assert candidate(s = \"00000000000000001111111111111111\") == 31\n    assert candidate(s = \"111000111000111\") == 8\n    assert candidate(s = \"10110011001100110011\") == 10\n    assert candidate(s = \"010101010101010101\") == 9\n    assert candidate(s = \"0000000000000000000011111111111111111111\") == 39\n    assert candidate(s = \"1100110011001100110011001100110011001100\") == 19\n    assert candidate(s = \"1010101010101010\") == 7\n    assert candidate(s = \"111111000000111111000000\") == 11\n    assert candidate(s = \"11110000011110000111\") == 11\n    assert candidate(s = \"111100001111000011110000\") == 11\n    assert candidate(s = \"111111111111111111110000000000000000\") == 0\n    assert candidate(s = \"0011001100110011\") == 9\n    assert candidate(s = \"00000111111111\") == 13\n    assert candidate(s = \"11111000001111100000\") == 9\n    assert candidate(s = \"111111100000000\") == 0\n    assert candidate(s = \"0000111100001111000011110000\") == 15\n    assert candidate(s = \"01001000100001000001\") == 15\n    assert candidate(s = \"00000101010111111\") == 13\n    assert candidate(s = \"0110110110110110\") == 10\n    assert candidate(s = \"01010101010101010101010101\") == 13\n    assert candidate(s = \"11110000111100001111\") == 11\n    assert candidate(s = \"01101101101101\") == 9\n    assert candidate(s = \"000000001111111100000000\") == 15\n    assert candidate(s = \"101010101010\") == 5\n    assert candidate(s = \"000000011111111\") == 14\n    assert candidate(s = \"110000000000001111\") == 15\n    assert candidate(s = \"01001000100000001001\") == 15\n    assert candidate(s = \"01010101010101010101010101010101010101010101010101\") == 25\n    assert candidate(s = \"001001001001001001001001\") == 16\n    assert candidate(s = \"000101010101\") == 7\n    assert candidate(s = \"10010010010010\") == 8\n    assert candidate(s = \"0000001111111111\") == 15\n    assert candidate(s = \"00000000001111111111\") == 19\n    assert candidate(s = \"000000001111111111111111\") == 23\n    assert candidate(s = \"00000111110000011111\") == 14\n    assert candidate(s = \"01010010101101\") == 8\n    assert candidate(s = \"11101110000111000011\") == 10\n    assert candidate(s = \"1001001001001001\") == 10\n    assert candidate(s = \"11001100110011001100\") == 9\n    assert candidate(s = \"00111100001111000011\") == 11\n    assert candidate(s = \"01010101010101010101010101010101\") == 16\n    assert candidate(s = \"10010010010010010010\") == 12\n    assert candidate(s = \"1010101010101010101010101010\") == 13\n    assert candidate(s = \"01001100110011001100\") == 10\n    assert candidate(s = \"1000000000000000000000000000000000000000\") == 0\n    assert candidate(s = \"111000111000\") == 5\n    assert candidate(s = \"11000011110000\") == 7\n    assert candidate(s = \"11111000000000\") == 0\n    assert candidate(s = \"10101101010010\") == 6\n    assert candidate(s = \"000000001111111111\") == 17\n    assert candidate(s = \"10010101010101010101\") == 10\n    assert candidate(s = \"0101010101010101\") == 8\n    assert candidate(s = \"11111111111111111110\") == 0\n    assert candidate(s = \"0000000000000000001\") == 18\n    assert candidate(s = \"111111110000000011111111\") == 15\n    assert candidate(s = \"00000111111111111111100000\") == 20\n    assert candidate(s = \"0101010101010101010101010101\") == 14\n    assert candidate(s = \"00010001000100010001\") == 15\n    assert candidate(s = \"1111111111111111111111111111111111111111\") == 0\n    assert candidate(s = \"11111100000011111100\") == 11\n    assert candidate(s = \"00110011001100110011\") == 11\n    assert candidate(s = \"11111111000000000000\") == 0\n    assert candidate(s = \"00010010010010010010010010010010010010010010\") == 29\n    assert candidate(s = \"00000111100001111000\") == 12\n    assert candidate(s = \"1001001001001001001001001\") == 16\n    assert candidate(s = \"01010101010101010101010101010101010101010101010101010101\") == 28\n    assert candidate(s = \"00100100100100100100100100100100100100100100\") == 28\n    assert candidate(s = \"01010101010101\") == 7\n    assert candidate(s = \"10101010100101010101\") == 10\n    assert candidate(s = \"00101010101010101010101010\") == 13\n    assert candidate(s = \"000001000001000001000001000001000001\") == 30\n    assert candidate(s = \"1010101010101010101010101010101010101010\") == 19\n    assert candidate(s = \"1001001001001001001001001001001001001001001001001\") == 32\n    assert candidate(s = \"1111000011110000111100001111\") == 15\n    assert candidate(s = \"111110000011111\") == 9\n    assert candidate(s = \"11111010101000000\") == 3\n    assert candidate(s = \"01010101010101010101010101010101010101010101\") == 22\n    assert candidate(s = \"01010101010101010101\") == 10\n    assert candidate(s = \"111111110000000011111111000000001111\") == 19\n    assert candidate(s = \"00011111100000111110\") == 13\n    assert candidate(s = \"0000000000000000000000000000000000000001\") == 39\n    assert candidate(s = \"11000011110000111100\") == 11\n    assert candidate(s = \"01101101101101101101\") == 13\n    assert candidate(s = \"10101010101010101010\") == 9\n    assert candidate(s = \"11111111111111110000000000000000\") == 0\n    assert candidate(s = \"100110011001100110011001\") == 12\n    assert candidate(s = \"110110110110110110\") == 10\n    assert candidate(s = \"00101010101000\") == 6\n    assert candidate(s = \"11111111111111110000000000\") == 0\n    assert candidate(s = \"000111000111000\") == 8\n    assert candidate(s = \"001001001001001001\") == 12\n    assert candidate(s = \"1000000000000001\") == 14\n    assert candidate(s = \"0000111100001111\") == 11\n", "comparison": "exact"}, "public_tests": ["\"0110101\"", "\"11100\""], "hints": ["Try replicating the steps from the problem statement.", "Perform the replacements simultaneously, and return the number of times the process repeats."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().secondsToRemoveOccurrences", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:39+00:00", "tests_total": 127, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming", "simulation"]}, "language": "python", "interface": {"raw_signature": "def secondsToRemoveOccurrences(self, s: str) -> int:", "container": "Solution", "callable": "secondsToRemoveOccurrences", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2381, "task_id": "shifting-letters-ii", "difficulty": "Medium", "problem_description": "You are given a string s of lowercase English letters and a 2D integer array shifts where shifts[i] = [start_i, end_i, direction_i]. For every i, shift the characters in s from the index start_i to the index end_i (inclusive) forward if direction_i = 1, or shift the characters backward if direction_i = 0.\n\nShifting a character forward means replacing it with the next letter in the alphabet (wrapping around so that 'z' becomes 'a'). Similarly, shifting a character backward means replacing it with the previous letter in the alphabet (wrapping around so that 'a' becomes 'z').\n\nReturn the final string after all such shifts to s are applied.\n\nExample 1:\n\nInput: s = \"abc\", shifts = [[0,1,0],[1,2,1],[0,2,1]]\nOutput: \"ace\"\nExplanation: Firstly, shift the characters from index 0 to index 1 backward. Now s = \"zac\".\nSecondly, shift the characters from index 1 to index 2 forward. Now s = \"zbd\".\nFinally, shift the characters from index 0 to index 2 forward. Now s = \"ace\".\n\nExample 2:\n\nInput: s = \"dztz\", shifts = [[0,0,0],[1,1,1]]\nOutput: \"catz\"\nExplanation: Firstly, shift the characters from index 0 to index 0 backward. Now s = \"cztz\".\nFinally, shift the characters from index 1 to index 1 forward. Now s = \"catz\".\n\nConstraints:\n\n- 1 <= s.length, shifts.length <= 5 * 10^4\n- shifts[i].length == 3\n- 0 <= start_i <= end_i < s.length\n- 0 <= direction_i <= 1\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"world\",shifts = [[0, 4, 0], [0, 4, 0], [0, 4, 0], [0, 4, 0]]) == \"sknhz\"\n    assert candidate(s = \"abc\",shifts = [[0, 1, 0], [1, 2, 1], [0, 2, 1]]) == \"ace\"\n    assert candidate(s = \"xyz\",shifts = [[0, 2, 0]]) == \"wxy\"\n    assert candidate(s = \"abcdef\",shifts = [[1, 4, 1], [2, 3, 0]]) == \"accdff\"\n    assert candidate(s = \"aaa\",shifts = [[0, 2, 1], [0, 2, 1], [0, 2, 1]]) == \"ddd\"\n    assert candidate(s = \"hello\",shifts = [[0, 4, 1], [1, 3, 0]]) == \"iellp\"\n    assert candidate(s = \"hello\",shifts = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1]]) == \"ignnp\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1]]) == \"bcdefghijklmnopqrstuvwxyza\"\n    assert candidate(s = \"dztz\",shifts = [[0, 0, 0], [1, 1, 1]]) == \"catz\"\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",shifts = [[0, 25, 0]]) == \"yxwvutsrqponmlkjihgfedcbaz\"\n    assert candidate(s = \"a\",shifts = [[0, 0, 1], [0, 0, 0]]) == \"a\"\n    assert candidate(s = \"abcd\",shifts = [[0, 3, 1], [1, 2, 0], [2, 3, 1]]) == \"bbdf\"\n    assert candidate(s = \"zzz\",shifts = [[0, 2, 0], [0, 2, 0], [0, 2, 0]]) == \"www\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 0]]) == \"zabcdefghijklmnopqrstuvwxy\"\n    assert candidate(s = \"hello\",shifts = [[0, 4, 1]]) == \"ifmmp\"\n    assert candidate(s = \"zzzzzzzzzz\",shifts = [[0, 4, 0], [5, 9, 1], [0, 9, 1], [3, 6, 0]]) == \"zzzyyaabbb\"\n    assert candidate(s = \"alphabet\",shifts = [[0, 0, 1], [1, 1, 0], [2, 2, 1], [3, 3, 0], [4, 4, 1], [5, 5, 0], [5, 5, 1]]) == \"bkqgbbet\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1], [5, 10, 0], [15, 20, 1]]) == \"bcdeffghijkmnoprstuvwwxyza\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",shifts = [[0, 51, 1], [10, 40, 0], [20, 30, 1], [30, 40, 0]]) == \"bbccddeeffffgghhiijjllmmnnoopppoppqqrrsstvwwxxyyzzaa\"\n    assert candidate(s = \"abacax\",shifts = [[0, 5, 1], [1, 4, 0], [2, 3, 1], [0, 5, 0]]) == \"aaaczx\"\n    assert candidate(s = \"programming\",shifts = [[0, 9, 1], [1, 8, 0], [2, 7, 1], [3, 6, 0], [4, 5, 1], [5, 5, 0], [6, 6, 1], [7, 7, 0], [8, 8, 1], [9, 9, 0]]) == \"qrpgsanmjng\"\n    assert candidate(s = \"abcdefghij\",shifts = [[0, 9, 0], [1, 8, 1], [2, 7, 0], [3, 6, 1], [4, 5, 0]]) == \"zbbddeggii\"\n    assert candidate(s = \"mnopqrstuvwxyzabcdefghijkl\",shifts = [[0, 25, 1], [5, 15, 0], [10, 20, 1], [15, 25, 0]]) == \"nopqrrstuvxyzabbdefghhijkl\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1], [0, 25, 1], [0, 25, 1], [0, 25, 0]]) == \"cdefghijklmnopqrstuvwxyzab\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1], [0, 25, 0], [0, 25, 1], [0, 25, 0]]) == \"abcdefghijklmnopqrstuvwxyz\"\n    assert candidate(s = \"abababab\",shifts = [[0, 7, 1], [1, 6, 0], [2, 5, 1], [3, 4, 0]]) == \"bbbbacac\"\n    assert candidate(s = \"zzzzzzzzzz\",shifts = [[0, 9, 1], [2, 8, 0], [4, 6, 1]]) == \"aazzaaazza\"\n    assert candidate(s = \"algorithm\",shifts = [[0, 2, 1], [3, 5, 0], [6, 8, 1], [1, 4, 0], [2, 3, 1], [5, 7, 0], [7, 8, 1]]) == \"blhnpgtio\"\n    assert candidate(s = \"abcdefghij\",shifts = [[0, 9, 1], [0, 9, 0], [0, 9, 1], [0, 9, 0], [0, 9, 1], [0, 9, 0], [0, 9, 1], [0, 9, 0], [0, 9, 1], [0, 9, 0]]) == \"abcdefghij\"\n    assert candidate(s = \"codingame\",shifts = [[0, 1, 1], [2, 3, 0], [4, 5, 1], [6, 7, 0], [8, 8, 1], [0, 8, 0], [0, 8, 1], [0, 8, 0], [0, 8, 1]]) == \"dpchohzlf\"\n    assert candidate(s = \"abacabadabacaba\",shifts = [[0, 14, 1], [1, 13, 0], [2, 12, 1], [3, 11, 0], [4, 10, 1], [5, 9, 0]]) == \"bbbcbbadabbcbbb\"\n    assert candidate(s = \"abcdefghij\",shifts = [[0, 4, 1], [5, 9, 0], [0, 4, 0], [5, 9, 1], [0, 9, 1]]) == \"bcdefghijk\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1], [1, 24, 0], [2, 23, 1], [3, 22, 0], [4, 21, 1]]) == \"bbddfghijklmnopqrstuvwwyya\"\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",shifts = [[0, 25, 0], [5, 10, 1], [15, 20, 0]]) == \"yxwvuutsrqpnmlkihgfeddcbaz\"\n    assert candidate(s = \"zzzzz\",shifts = [[0, 4, 0], [0, 4, 0], [0, 4, 0], [0, 4, 0], [0, 4, 1]]) == \"wwwww\"\n    assert candidate(s = \"abcdefghij\",shifts = [[0, 9, 1], [1, 8, 0], [2, 7, 1], [3, 6, 0], [4, 5, 1]]) == \"bbddfggiik\"\n    assert candidate(s = \"abcdefghij\",shifts = [[0, 9, 1], [0, 9, 0], [0, 9, 1], [0, 9, 0], [0, 9, 1]]) == \"bcdefghijk\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",shifts = [[0, 25, 1], [5, 15, 0], [10, 20, 1]]) == \"aaaaazzzzzaaaaaabbbbbaaaaa\"\n    assert candidate(s = \"abcdefghijklmnop\",shifts = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [13, 13, 1], [14, 14, 1], [15, 15, 1]]) == \"bcdefghijklmnopq\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 12, 1], [13, 25, 0], [0, 25, 1], [0, 25, 0], [0, 25, 1]]) == \"cdefghijklmnonopqrstuvwxyz\"\n    assert candidate(s = \"alibabacloud\",shifts = [[0, 9, 1], [2, 4, 0], [5, 7, 1], [8, 11, 0], [0, 3, 1], [6, 9, 0], [1, 8, 1], [2, 7, 0]]) == \"cojcadbdlntc\"\n    assert candidate(s = \"xyz\",shifts = [[0, 2, 1], [0, 2, 1], [0, 2, 0], [0, 2, 0]]) == \"xyz\"\n    assert candidate(s = \"abcdefg\",shifts = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1]]) == \"bdefghh\"\n    assert candidate(s = \"abacabadabacaba\",shifts = [[0, 4, 1], [5, 9, 0], [10, 14, 1], [0, 14, 0], [0, 14, 1]]) == \"bcbdbazczabdbcb\"\n    assert candidate(s = \"example\",shifts = [[0, 6, 1], [1, 5, 0], [2, 4, 1], [3, 6, 0]]) == \"fxbmpke\"\n    assert candidate(s = \"abcdefg\",shifts = [[0, 6, 1], [1, 5, 0], [2, 4, 1], [3, 3, 0]]) == \"bbddffh\"\n    assert candidate(s = \"hellozworld\",shifts = [[0, 4, 1], [5, 9, 0], [6, 10, 1], [7, 8, 0], [9, 10, 1], [10, 10, 0]]) == \"ifmmpywnqme\"\n    assert candidate(s = \"abcde\",shifts = [[0, 2, 1], [3, 4, 0], [1, 3, 1], [0, 1, 0], [4, 4, 1], [2, 2, 0]]) == \"acdde\"\n    assert candidate(s = \"xylophone\",shifts = [[0, 8, 1], [1, 7, 0], [2, 6, 1], [3, 5, 0], [4, 4, 1]]) == \"yymoqhpnf\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1], [0, 25, 0], [0, 25, 1], [0, 25, 0], [0, 25, 1]]) == \"bcdefghijklmnopqrstuvwxyza\"\n    assert candidate(s = \"programming\",shifts = [[0, 9, 1], [4, 8, 0], [2, 6, 1], [1, 7, 0], [0, 8, 1]]) == \"rsqisbnmjog\"\n    assert candidate(s = \"shiftmeplease\",shifts = [[0, 1, 1], [2, 3, 0], [4, 5, 1], [6, 7, 0], [8, 9, 1], [10, 11, 0], [12, 12, 1]]) == \"tiheundomfzrf\"\n    assert candidate(s = \"quickbrownfox\",shifts = [[0, 12, 1], [1, 11, 0], [2, 10, 1], [3, 9, 0], [4, 8, 1], [5, 7, 0]]) == \"rujclbroxngoy\"\n    assert candidate(s = \"mnopqr\",shifts = [[0, 2, 1], [3, 5, 0], [0, 5, 1], [1, 4, 0]]) == \"oopopr\"\n    assert candidate(s = \"abcdefghijklmnop\",shifts = [[0, 15, 1], [1, 14, 0], [2, 13, 1], [3, 12, 0], [4, 11, 1], [5, 10, 0], [6, 9, 1], [7, 8, 0]]) == \"bbddffhhikkmmooq\"\n    assert candidate(s = \"zzzzzzzzzz\",shifts = [[0, 9, 1], [1, 8, 0], [2, 7, 1], [3, 6, 0], [4, 5, 1]]) == \"azazaazaza\"\n    assert candidate(s = \"mississippi\",shifts = [[0, 4, 0], [1, 3, 1], [2, 2, 0], [3, 5, 1], [6, 8, 0], [7, 7, 1], [8, 10, 0], [9, 9, 1], [10, 10, 0]]) == \"lirtitrinpg\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 0, 0], [1, 1, 0], [2, 2, 0], [3, 3, 0], [4, 4, 0], [5, 5, 0], [6, 6, 0], [7, 7, 0], [8, 8, 0], [9, 9, 0], [10, 10, 0], [11, 11, 0], [12, 12, 0], [13, 13, 0], [14, 14, 0], [15, 15, 0], [16, 16, 0], [17, 17, 0], [18, 18, 0], [19, 19, 0], [20, 20, 0], [21, 21, 0], [22, 22, 0], [23, 23, 0], [24, 24, 1], [25, 25, 1]]) == \"zabcdefghijklmnopqrstuvwza\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1], [5, 15, 0], [10, 20, 1]]) == \"bcdeffghijlmnopqstuvwwxyza\"\n    assert candidate(s = \"programming\",shifts = [[0, 8, 1], [3, 7, 0], [2, 5, 1], [4, 10, 0], [1, 9, 1]]) == \"qtrisbmmjnf\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [13, 13, 1], [14, 14, 1], [15, 15, 1], [16, 16, 1], [17, 17, 1], [18, 18, 1], [19, 19, 1], [20, 20, 1], [21, 21, 1], [22, 22, 1], [23, 23, 1], [24, 24, 1], [25, 25, 1]]) == \"bcdefghijklmnopqrstuvwxyza\"\n    assert candidate(s = \"abcdefgh\",shifts = [[0, 0, 0], [7, 7, 1], [2, 2, 1], [5, 5, 0], [3, 3, 1]]) == \"zbdeeegi\"\n    assert candidate(s = \"a\",shifts = [[0, 0, 1], [0, 0, 0], [0, 0, 1], [0, 0, 0]]) == \"a\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 25, 1], [0, 25, 1], [0, 25, 1], [0, 25, 1], [0, 25, 1]]) == \"fghijklmnopqrstuvwxyzabcde\"\n    assert candidate(s = \"abcdefg\",shifts = [[0, 1, 0], [1, 2, 0], [2, 3, 0], [3, 4, 0], [4, 5, 0], [5, 6, 0]]) == \"zzabcdf\"\n    assert candidate(s = \"mnopqr\",shifts = [[0, 0, 1], [1, 1, 0], [2, 2, 1], [3, 3, 0], [4, 4, 1], [5, 5, 0]]) == \"nmporq\"\n    assert candidate(s = \"abcdefghij\",shifts = [[0, 4, 0], [5, 9, 1], [0, 9, 1], [1, 8, 0], [2, 7, 1], [3, 6, 0], [4, 5, 1]]) == \"aaccehhjjl\"\n    assert candidate(s = \"abcdefghij\",shifts = [[0, 1, 1], [2, 3, 0], [4, 5, 1], [6, 7, 0], [8, 9, 1]]) == \"bcbcfgfgjk\"\n    assert candidate(s = \"mississippi\",shifts = [[0, 2, 1], [2, 4, 0], [4, 6, 1], [6, 8, 0], [8, 10, 1]]) == \"njsritshpqj\"\n    assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",shifts = [[0, 9, 1], [10, 19, 0], [20, 25, 1], [0, 19, 0], [10, 25, 1], [0, 25, 0], [0, 25, 1]]) == \"qwertyuiopzrcefgijkyzexdpo\"\n    assert candidate(s = \"aaaabbbbcccc\",shifts = [[0, 3, 1], [4, 7, 0], [8, 11, 1], [0, 11, 1]]) == \"ccccbbbbeeee\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",shifts = [[0, 51, 1], [0, 51, 0], [0, 51, 1], [0, 51, 0], [0, 51, 1]]) == \"bbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaa\"\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",shifts = [[0, 13, 0], [13, 25, 1], [0, 25, 0], [0, 25, 1]]) == \"yxwvutsrqponmmmlkjihgfedcb\"\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",shifts = [[0, 25, 0], [0, 25, 0], [0, 25, 0], [0, 25, 0], [0, 25, 0]]) == \"utsrqponmlkjihgfedcbazyxwv\"\n    assert candidate(s = \"shiftthis\",shifts = [[0, 0, 1], [1, 1, 0], [2, 2, 1], [3, 3, 0], [4, 4, 1], [5, 5, 0], [6, 6, 1], [7, 7, 0], [8, 8, 1]]) == \"tgjeusiht\"\n    assert candidate(s = \"abcd\",shifts = [[0, 3, 1], [0, 2, 0], [1, 3, 1], [1, 2, 0], [2, 3, 1]]) == \"abdg\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\",shifts = [[0, 25, 1], [1, 24, 0], [2, 23, 1], [3, 22, 0]]) == \"bbddefghijklmnopqrstuvwyyaa\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [13, 13, 1], [14, 14, 1], [15, 15, 1], [16, 16, 1], [17, 17, 1], [18, 18, 1], [19, 19, 1], [20, 20, 1], [21, 21, 1], [22, 22, 1], [23, 23, 1], [24, 24, 0], [25, 25, 0]]) == \"bcdefghijklmnopqrstuvwxyxy\"\n    assert candidate(s = \"python\",shifts = [[0, 5, 1], [1, 4, 0], [2, 3, 1], [0, 5, 0], [1, 4, 1]]) == \"pyuion\"\n    assert candidate(s = \"abcdefghij\",shifts = [[0, 0, 1], [1, 1, 0], [2, 2, 1], [3, 3, 0], [4, 4, 1], [5, 5, 0], [6, 6, 1], [7, 7, 0], [8, 8, 1], [9, 9, 0]]) == \"badcfehgji\"\n    assert candidate(s = \"zzzzzzzzzz\",shifts = [[0, 9, 1], [0, 9, 1], [0, 9, 1], [0, 9, 1], [0, 9, 1], [0, 9, 1], [0, 9, 1], [0, 9, 1], [0, 9, 1], [0, 9, 1]]) == \"jjjjjjjjjj\"\n    assert candidate(s = \"xyzxyzxyz\",shifts = [[0, 2, 1], [3, 5, 0], [6, 8, 1], [0, 5, 1], [3, 8, 0], [0, 8, 1]]) == \"abcxyzyza\"\n    assert candidate(s = \"aaaabbbb\",shifts = [[0, 3, 1], [4, 7, 0], [2, 5, 1], [1, 6, 0]]) == \"babbaaza\"\n    assert candidate(s = \"zzzzzzzz\",shifts = [[0, 7, 1], [1, 6, 0], [2, 5, 1], [3, 4, 0]]) == \"azazzaza\"\n    assert candidate(s = \"abcdefghij\",shifts = [[0, 4, 1], [1, 8, 0], [2, 7, 1], [3, 6, 0], [4, 5, 1]]) == \"bbddfffhhj\"\n    assert candidate(s = \"abcdabcdabcd\",shifts = [[0, 3, 1], [4, 7, 0], [8, 11, 1], [0, 11, 0], [0, 11, 1]]) == \"bcdezabcbcde\"\n    assert candidate(s = \"zzzzzzzzzz\",shifts = [[0, 9, 1], [0, 9, 0], [1, 8, 1], [1, 8, 0], [2, 7, 1], [2, 7, 0], [3, 6, 1], [3, 6, 0], [4, 5, 1], [4, 5, 0]]) == \"zzzzzzzzzz\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [[0, 0, 1], [1, 1, 0], [2, 2, 1], [3, 3, 0], [4, 4, 1], [5, 5, 0], [6, 6, 1], [7, 7, 0], [8, 8, 1], [9, 9, 0], [10, 10, 1], [11, 11, 0], [12, 12, 1], [13, 13, 0], [14, 14, 1], [15, 15, 0], [16, 16, 1], [17, 17, 0], [18, 18, 1], [19, 19, 0], [20, 20, 1], [21, 21, 0], [22, 22, 1], [23, 23, 0], [24, 24, 1], [25, 25, 0]]) == \"badcfehgjilknmporqtsvuxwzy\"\n    assert candidate(s = \"xyzabc\",shifts = [[0, 2, 1], [3, 5, 0], [1, 4, 1], [2, 5, 0], [0, 5, 1]]) == \"zbbabb\"\n    assert candidate(s = \"programming\",shifts = [[0, 3, 1], [4, 8, 0], [6, 10, 1], [7, 9, 0], [1, 5, 1]]) == \"qtqiramlhnh\"\n", "comparison": "exact"}, "public_tests": ["\"abc\"\n[[0,1,0],[1,2,1],[0,2,1]]", "\"dztz\"\n[[0,0,0],[1,1,1]]"], "hints": ["Instead of shifting every character in each shift, could you keep track of which characters are shifted and by how much across all shifts?", "Try marking the start and ends of each shift, then perform a prefix sum of the shifts."], "metadata": {"canonical_parameter_names": ["s", "shifts"], "leetcode_dataset_entry_point": "Solution().shiftingLetters", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:41+00:00", "tests_total": 94, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "string", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def shiftingLetters(self, s: str, shifts: list[list[int]]) -> str:", "container": "Solution", "callable": "shiftingLetters", "parameters": [{"name": "s", "type": "str"}, {"name": "shifts", "type": "list[list[int]]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2382, "task_id": "maximum-segment-sum-after-removals", "difficulty": "Hard", "problem_description": "You are given two 0-indexed integer arrays nums and removeQueries, both of length n. For the i^th query, the element in nums at the index removeQueries[i] is removed, splitting nums into different segments.\n\nA segment is a contiguous sequence of positive integers in nums. A segment sum is the sum of every element in a segment.\n\nReturn an integer array answer, of length n, where answer[i] is the maximum segment sum after applying the i^th removal.\n\nNote: The same index will not be removed more than once.\n\nExample 1:\n\nInput: nums = [1,2,5,6,1], removeQueries = [0,3,2,4,1]\nOutput: [14,7,2,2,0]\nExplanation: Using 0 to indicate a removed element, the answer is as follows:\nQuery 1: Remove the 0th element, nums becomes [0,2,5,6,1] and the maximum segment sum is 14 for segment [2,5,6,1].\nQuery 2: Remove the 3rd element, nums becomes [0,2,5,0,1] and the maximum segment sum is 7 for segment [2,5].\nQuery 3: Remove the 2nd element, nums becomes [0,2,0,0,1] and the maximum segment sum is 2 for segment [2].\nQuery 4: Remove the 4th element, nums becomes [0,2,0,0,0] and the maximum segment sum is 2 for segment [2].\nQuery 5: Remove the 1st element, nums becomes [0,0,0,0,0] and the maximum segment sum is 0, since there are no segments.\nFinally, we return [14,7,2,2,0].\n\nExample 2:\n\nInput: nums = [3,2,11,1], removeQueries = [3,2,1,0]\nOutput: [16,5,3,0]\nExplanation: Using 0 to indicate a removed element, the answer is as follows:\nQuery 1: Remove the 3rd element, nums becomes [3,2,11,0] and the maximum segment sum is 16 for segment [3,2,11].\nQuery 2: Remove the 2nd element, nums becomes [3,2,0,0] and the maximum segment sum is 5 for segment [3,2].\nQuery 3: Remove the 1st element, nums becomes [3,0,0,0] and the maximum segment sum is 3 for segment [3].\nQuery 4: Remove the 0th element, nums becomes [0,0,0,0] and the maximum segment sum is 0, since there are no segments.\nFinally, we return [16,5,3,0].\n\nConstraints:\n\n- n == nums.length == removeQueries.length\n- 1 <= n <= 10^5\n- 1 <= nums[i] <= 10^9\n- 0 <= removeQueries[i] < n\n- All the values of removeQueries are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 2, 5, 6, 1],removeQueries = [0, 3, 2, 4, 1]) == [14, 7, 2, 2, 0]\n    assert candidate(nums = [5, 1, 4, 3, 2],removeQueries = [2, 0, 4, 1, 3]) == [6, 5, 3, 3, 0]\n    assert candidate(nums = [1000000000, 1000000000, 1000000000],removeQueries = [0, 1, 2]) == [2000000000, 1000000000, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50],removeQueries = [4, 3, 2, 1, 0]) == [100, 60, 30, 10, 0]\n    assert candidate(nums = [5, 1, 4, 3],removeQueries = [1, 2, 0, 3]) == [7, 5, 3, 0]\n    assert candidate(nums = [3, 2, 11, 1],removeQueries = [3, 2, 1, 0]) == [16, 5, 3, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50],removeQueries = [0, 1, 2, 3, 4]) == [140, 120, 90, 50, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50],removeQueries = [2, 4, 0, 1, 3]) == [90, 40, 40, 40, 0]\n    assert candidate(nums = [5, 2, 3, 1, 4],removeQueries = [2, 0, 4, 3, 1]) == [7, 5, 2, 2, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1],removeQueries = [0, 1, 2, 3, 4]) == [4, 3, 2, 1, 0]\n    assert candidate(nums = [1000000000, 1000000000, 1000000000],removeQueries = [0, 1, 2]) == [2000000000, 1000000000, 0]\n    assert candidate(nums = [5, 1, 3, 2, 4],removeQueries = [2, 0, 1, 3, 4]) == [6, 6, 6, 4, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],removeQueries = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n    assert candidate(nums = [5, 2, 3, 1, 4],removeQueries = [2, 0, 3, 4, 1]) == [7, 5, 4, 2, 0]\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9000000000, 8000000000, 7000000000, 6000000000, 5000000000, 4000000000, 3000000000, 2000000000, 1000000000, 0]\n    assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000],removeQueries = [5, 4, 3, 2, 1, 0]) == [111110, 11110, 1110, 110, 10, 0]\n    assert candidate(nums = [9, 1, 5, 3, 2, 4, 8, 6, 7, 10],removeQueries = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == [46, 36, 35, 28, 23, 17, 14, 6, 4, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],removeQueries = [0, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [324, 299, 275, 252, 230, 209, 189, 170, 152, 135, 119, 104, 90, 77, 65, 54, 44, 35, 27, 20, 14, 9, 5, 2, 0]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],removeQueries = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == [5400, 4900, 4000, 2700, 1000, 1000, 1000, 1000, 1000, 0]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40],removeQueries = [3, 6, 0, 5, 1, 7, 2, 4]) == [130, 55, 55, 40, 40, 25, 25, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],removeQueries = [14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == [105, 104, 102, 99, 95, 90, 84, 77, 69, 60, 50, 39, 27, 14, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [4, 2, 6, 8, 0, 1, 3, 5, 7, 9]) == [400, 400, 270, 100, 100, 100, 100, 100, 100, 0]\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],removeQueries = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [380, 342, 306, 272, 240, 210, 182, 156, 132, 110, 90, 72, 56, 42, 30, 20, 12, 6, 2, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],removeQueries = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [190, 171, 153, 136, 120, 105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],removeQueries = [14, 0, 7, 2, 9, 4, 12, 6, 11, 3, 8, 13, 5, 10, 1]) == [196, 195, 132, 132, 96, 96, 44, 44, 27, 27, 27, 21, 21, 3, 0]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],removeQueries = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 3, 4, 0, 1]) == [65, 61, 58, 56, 55, 54, 52, 49, 45, 40, 40, 40, 40, 40, 40, 19, 19, 19, 9, 0]\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],removeQueries = [2, 0, 1, 3]) == [2000000000, 1000000000, 1000000000, 0]\n    assert candidate(nums = [100, 200, 300, 400, 500],removeQueries = [4, 3, 2, 1, 0]) == [1000, 600, 300, 100, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [5, 2, 8, 0, 4, 7, 1, 9, 6, 3]) == [340, 340, 150, 150, 150, 100, 100, 70, 40, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [5, 2, 8, 1, 7, 4, 3, 9, 6, 0]) == [340, 340, 150, 150, 100, 100, 100, 70, 10, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],removeQueries = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [190, 153, 120, 91, 66, 45, 28, 19, 19, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 0]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],removeQueries = [14, 1, 2, 12, 0, 3, 4, 13, 5, 6, 11, 7, 8, 9, 10]) == [10500, 10200, 9900, 7200, 7200, 6800, 6300, 6300, 5700, 5000, 3800, 3000, 2100, 1100, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],removeQueries = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],removeQueries = [19, 9, 18, 8, 17, 7, 16, 6, 15, 5, 14, 4, 13, 3, 12, 2, 11, 1, 10, 0]) == [1900, 1350, 1160, 1160, 980, 980, 810, 810, 650, 650, 500, 500, 360, 360, 230, 230, 110, 110, 10, 0]\n    assert candidate(nums = [31, 41, 59, 26, 53, 58, 97, 93, 23, 84, 62, 64, 33, 83, 27, 95, 28, 84, 19, 71],removeQueries = [10, 18, 8, 12, 17, 19, 16, 7, 5, 0, 14, 2, 15, 9, 6, 13, 3, 4, 11, 1]) == [565, 565, 458, 458, 458, 458, 458, 365, 210, 205, 179, 97, 97, 97, 83, 79, 64, 64, 41, 0]\n    assert candidate(nums = [2, 1, 3, 4, 2, 3, 4, 1, 5, 6, 7, 8, 9, 10],removeQueries = [1, 3, 5, 7, 9, 11, 13, 0, 2, 4, 6, 8, 10, 12]) == [62, 55, 50, 45, 34, 19, 9, 9, 9, 9, 9, 9, 9, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == [540, 490, 400, 270, 100, 100, 100, 100, 100, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],removeQueries = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == [190, 153, 120, 91, 66, 45, 28, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [5, 3, 7, 1, 9, 4, 0, 6, 8, 2]) == [340, 340, 190, 190, 90, 90, 90, 90, 30, 0]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],removeQueries = [4, 2, 6, 8, 0, 3, 5, 7, 9, 1]) == [4000, 4000, 2700, 1000, 1000, 1000, 1000, 1000, 200, 0]\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],removeQueries = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [89, 85, 77, 74, 72, 69, 60, 53, 44, 39, 36, 31, 25, 23, 14, 9, 8, 4, 3, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],removeQueries = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]) == [190, 153, 120, 91, 66, 45, 28, 19, 19, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 0]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],removeQueries = [2, 4, 6, 8, 10, 12, 14, 0, 1, 3, 5, 7, 9, 11, 13]) == [11400, 10500, 9200, 7500, 5400, 2900, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 0]\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],removeQueries = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [1996093750, 1992187500, 1984375000, 1968750000, 1937500000, 1875000000, 1750000000, 1500000000, 1000000000, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],removeQueries = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n    assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [46, 39, 34, 31, 30, 28, 24, 18, 10, 0]\n    assert candidate(nums = [5, 1, 4, 3, 9, 8, 7, 2, 6],removeQueries = [2, 5, 0, 3, 4, 8, 6, 7, 1]) == [35, 15, 15, 15, 15, 9, 2, 1, 0]\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [190, 171, 153, 136, 120, 105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],removeQueries = [4, 8, 3, 7, 2, 6, 1, 5, 0]) == [30, 30, 24, 24, 17, 17, 9, 9, 0]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],removeQueries = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],removeQueries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 132, 119, 105, 90, 74, 57, 39, 20, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [5, 7, 3, 1, 9, 0, 8, 6, 2, 4]) == [340, 190, 190, 190, 90, 90, 70, 50, 50, 0]\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],removeQueries = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9000000000, 8000000000, 7000000000, 6000000000, 5000000000, 4000000000, 3000000000, 2000000000, 1000000000, 0]\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],removeQueries = [5, 0, 4, 9, 2, 8, 6, 3, 7, 1]) == [25, 24, 22, 21, 16, 11, 10, 10, 10, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],removeQueries = [14, 1, 2, 12, 0, 3, 4, 13, 5, 6, 11, 7, 8, 9, 10]) == [105, 102, 99, 72, 72, 68, 63, 63, 57, 50, 38, 30, 21, 11, 0]\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],removeQueries = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9000000000, 8000000000, 7000000000, 6000000000, 5000000000, 4000000000, 3000000000, 2000000000, 1000000000, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],removeQueries = [7, 14, 0, 13, 1, 12, 2, 11, 3, 10, 4, 9, 5, 8, 6]) == [840, 690, 690, 550, 550, 420, 420, 300, 300, 190, 190, 130, 90, 70, 0]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],removeQueries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == [90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907],removeQueries = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [1999996181, 1999992367, 1999984738, 1999969480, 1999938963, 1999877928, 1999755858, 1999511718, 1999023437, 1998046875, 1996093750, 1992187500, 1984375000, 1968750000, 1937500000, 1875000000, 1750000000, 1500000000, 1000000000, 0]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],removeQueries = [11, 5, 3, 7, 9, 1, 8, 10, 4, 2, 6, 0]) == [6600, 4500, 4500, 3000, 1100, 1100, 1100, 700, 700, 700, 100, 0]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8]) == [36, 28, 21, 15, 10, 6, 3, 1, 0]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],removeQueries = [0, 8, 1, 7, 2, 6, 3, 5, 4]) == [36, 35, 27, 25, 18, 15, 9, 5, 0]\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],removeQueries = [0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13]) == [54, 50, 44, 37, 29, 20, 10, 5, 5, 5, 5, 5, 5, 5, 0]\n    assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115],removeQueries = [7, 15, 3, 11, 13, 5, 9, 1, 12, 14, 8, 10, 6, 2, 4, 0]) == [892, 777, 777, 339, 327, 327, 303, 114, 114, 110, 110, 106, 104, 104, 100, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],removeQueries = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n    assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],removeQueries = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 0]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],removeQueries = [0, 8, 1, 7, 2, 6, 3, 5, 4]) == [36, 35, 27, 25, 18, 15, 9, 5, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],removeQueries = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [190, 171, 153, 136, 120, 105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n    assert candidate(nums = [1, 3, 2, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],removeQueries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [209, 206, 204, 199, 195, 189, 182, 174, 165, 155, 144, 132, 119, 105, 90, 74, 57, 39, 20, 0]\n    assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],removeQueries = [15, 10, 5, 0, 19, 14, 9, 4, 18, 13, 8, 3, 17, 12, 7, 2, 16, 11, 6, 1]) == [120, 74, 74, 74, 54, 54, 54, 54, 39, 35, 35, 35, 25, 17, 17, 17, 12, 7, 4, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],removeQueries = [10, 5, 15, 2, 18, 8, 0, 17, 3, 14, 9, 11, 7, 1, 12, 6, 13, 4, 16, 19]) == [10, 9, 5, 4, 4, 4, 4, 4, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1, 1, 0]\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6],removeQueries = [10, 2, 16, 14, 18, 6, 8, 12, 4, 1, 13, 7, 15, 3, 9, 19, 11, 5, 17, 0]) == [47, 47, 31, 31, 31, 17, 17, 15, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 3, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [5, 7, 9, 1, 3, 8, 2, 6, 4, 0]) == [340, 190, 150, 120, 90, 70, 70, 50, 10, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],removeQueries = [29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [435, 406, 378, 351, 325, 300, 276, 253, 231, 210, 190, 171, 153, 136, 120, 105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],removeQueries = [7, 3, 9, 13, 5, 11, 1, 6, 2, 14, 8, 0, 12, 10, 4]) == [840, 840, 650, 360, 360, 150, 150, 150, 150, 130, 130, 130, 110, 50, 0]\n    assert candidate(nums = [5, 2, 3, 1, 4, 6, 8, 7, 9, 10],removeQueries = [4, 0, 3, 2, 5, 1, 8, 9, 7, 6]) == [40, 40, 40, 40, 34, 34, 15, 15, 8, 0]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],removeQueries = [0, 2, 4, 6, 8, 1, 3, 5, 7]) == [36, 21, 10, 8, 8, 6, 4, 2, 0]\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],removeQueries = [0, 1, 2, 3, 4]) == [4000000000, 3000000000, 2000000000, 1000000000, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],removeQueries = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [1225, 1176, 1128, 1081, 1035, 990, 946, 903, 861, 820, 780, 741, 703, 666, 630, 595, 561, 528, 496, 465, 435, 406, 378, 351, 325, 300, 276, 253, 231, 210, 190, 171, 153, 136, 120, 105, 91, 78, 66, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1, 0]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],removeQueries = [4, 2, 7, 5, 8, 1, 0, 9, 3, 6]) == [400, 400, 190, 190, 100, 100, 100, 70, 70, 0]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],removeQueries = [5, 7, 3, 9, 1, 6, 0, 8, 2, 4]) == [64, 36, 36, 17, 17, 17, 17, 9, 9, 0]\n", "comparison": "exact"}, "public_tests": ["[1,2,5,6,1]\n[0,3,2,4,1]", "[3,2,11,1]\n[3,2,1,0]"], "hints": ["Use a sorted data structure to collect removal points and store the segments.", "Use a heap or priority queue to store segment sums and their corresponding boundaries.", "Make sure to remove invalid segments from the heap."], "metadata": {"canonical_parameter_names": ["nums", "removeQueries"], "leetcode_dataset_entry_point": "Solution().maximumSegmentSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:44+00:00", "tests_total": 90, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "union-find", "prefix-sum", "ordered-set"]}, "language": "python", "interface": {"raw_signature": "def maximumSegmentSum(self, nums: list[int], removeQueries: list[int]) -> list[int]:", "container": "Solution", "callable": "maximumSegmentSum", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "removeQueries", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2383, "task_id": "minimum-hours-of-training-to-win-a-competition", "difficulty": "Easy", "problem_description": "You are entering a competition, and are given two positive integers initialEnergy and initialExperience denoting your initial energy and initial experience respectively.\n\nYou are also given two 0-indexed integer arrays energy and experience, both of length n.\n\nYou will face n opponents in order. The energy and experience of the i^th opponent is denoted by energy[i] and experience[i] respectively. When you face an opponent, you need to have both strictly greater experience and energy to defeat them and move to the next opponent if available.\n\nDefeating the i^th opponent increases your experience by experience[i], but decreases your energy by energy[i].\n\nBefore starting the competition, you can train for some number of hours. After each hour of training, you can either choose to increase your initial experience by one, or increase your initial energy by one.\n\nReturn the minimum number of training hours required to defeat all n opponents.\n\nExample 1:\n\nInput: initialEnergy = 5, initialExperience = 3, energy = [1,4,3,2], experience = [2,6,3,1]\nOutput: 8\nExplanation: You can increase your energy to 11 after 6 hours of training, and your experience to 5 after 2 hours of training.\nYou face the opponents in the following order:\n- You have more energy and experience than the 0^th opponent so you win.\n  Your energy becomes 11 - 1 = 10, and your experience becomes 5 + 2 = 7.\n- You have more energy and experience than the 1^st opponent so you win.\n  Your energy becomes 10 - 4 = 6, and your experience becomes 7 + 6 = 13.\n- You have more energy and experience than the 2^nd opponent so you win.\n  Your energy becomes 6 - 3 = 3, and your experience becomes 13 + 3 = 16.\n- You have more energy and experience than the 3^rd opponent so you win.\n  Your energy becomes 3 - 2 = 1, and your experience becomes 16 + 1 = 17.\nYou did a total of 6 + 2 = 8 hours of training before the competition, so we return 8.\nIt can be proven that no smaller answer exists.\n\nExample 2:\n\nInput: initialEnergy = 2, initialExperience = 4, energy = [1], experience = [3]\nOutput: 0\nExplanation: You do not need any additional energy or experience to win the competition, so we return 0.\n\nConstraints:\n\n- n == energy.length == experience.length\n- 1 <= n <= 100\n- 1 <= initialEnergy, initialExperience, energy[i], experience[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [50, 50],experience = [50, 50]) == 52\n    assert candidate(initialEnergy = 5,initialExperience = 3,energy = [1, 4, 3, 2],experience = [2, 6, 3, 1]) == 8\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [100],experience = [100]) == 200\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 25, 25],experience = [50, 25, 25]) == 1\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30],experience = [10, 20, 30]) == 11\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [100],experience = [100]) == 2\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 50],experience = [50, 50]) == 1\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [1, 1, 1, 1],experience = [1, 1, 1, 1]) == 0\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],experience = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(initialEnergy = 2,initialExperience = 4,energy = [1],experience = [3]) == 0\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 1, 1, 1],experience = [1, 1, 1, 1]) == 5\n    assert candidate(initialEnergy = 99,initialExperience = 99,energy = [100],experience = [100]) == 4\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],experience = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 71\n    assert candidate(initialEnergy = 50,initialExperience = 25,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n    assert candidate(initialEnergy = 30,initialExperience = 25,energy = [10, 15, 20, 5, 10],experience = [20, 15, 10, 25, 15]) == 31\n    assert candidate(initialEnergy = 40,initialExperience = 40,energy = [20, 20, 20, 20],experience = [20, 20, 20, 20]) == 41\n    assert candidate(initialEnergy = 30,initialExperience = 20,energy = [10, 20, 30, 40, 50],experience = [1, 2, 3, 4, 5]) == 121\n    assert candidate(initialEnergy = 15,initialExperience = 8,energy = [7, 7, 7, 7, 7, 7],experience = [6, 6, 6, 6, 6, 6]) == 28\n    assert candidate(initialEnergy = 70,initialExperience = 40,energy = [5, 15, 25, 35, 45],experience = [45, 35, 25, 15, 5]) == 62\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],experience = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 135\n    assert candidate(initialEnergy = 2,initialExperience = 2,energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],experience = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n    assert candidate(initialEnergy = 20,initialExperience = 25,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n    assert candidate(initialEnergy = 10,initialExperience = 5,energy = [5, 6, 7, 8],experience = [1, 2, 3, 4]) == 17\n    assert candidate(initialEnergy = 20,initialExperience = 5,energy = [10, 15, 5, 20],experience = [3, 7, 10, 2]) == 31\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30, 40],experience = [5, 15, 25, 35]) == 51\n    assert candidate(initialEnergy = 40,initialExperience = 25,energy = [10, 15, 10, 20, 15, 25],experience = [25, 20, 15, 10, 25, 20]) == 57\n    assert candidate(initialEnergy = 30,initialExperience = 30,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],experience = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 181\n    assert candidate(initialEnergy = 10,initialExperience = 20,energy = [1, 3, 5, 7, 9],experience = [9, 7, 5, 3, 1]) == 16\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],experience = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 51\n    assert candidate(initialEnergy = 50,initialExperience = 30,energy = [40, 35, 20, 10, 5],experience = [25, 20, 15, 10, 5]) == 61\n    assert candidate(initialEnergy = 70,initialExperience = 30,energy = [20, 10, 30, 5, 20],experience = [15, 25, 10, 20, 5]) == 16\n    assert candidate(initialEnergy = 20,initialExperience = 15,energy = [10, 20, 30],experience = [5, 15, 25]) == 41\n    assert candidate(initialEnergy = 1,initialExperience = 10,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9],experience = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n    assert candidate(initialEnergy = 20,initialExperience = 15,energy = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],experience = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5]) == 76\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [25, 25, 25, 25],experience = [20, 20, 20, 20]) == 51\n    assert candidate(initialEnergy = 15,initialExperience = 10,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 42\n    assert candidate(initialEnergy = 25,initialExperience = 15,energy = [8, 7, 6, 5, 4, 3, 2, 1],experience = [1, 2, 3, 4, 5, 6, 7, 8]) == 12\n    assert candidate(initialEnergy = 5,initialExperience = 5,energy = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],experience = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 26\n    assert candidate(initialEnergy = 10,initialExperience = 15,energy = [3, 2, 6, 1],experience = [8, 4, 2, 7]) == 3\n    assert candidate(initialEnergy = 20,initialExperience = 25,energy = [10, 10, 10, 10],experience = [25, 26, 27, 28]) == 22\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [5, 15, 25, 35],experience = [30, 20, 10, 5]) == 92\n    assert candidate(initialEnergy = 30,initialExperience = 30,energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],experience = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 47\n    assert candidate(initialEnergy = 30,initialExperience = 50,energy = [10, 20, 30],experience = [25, 20, 15]) == 31\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],experience = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 91\n    assert candidate(initialEnergy = 15,initialExperience = 20,energy = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],experience = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2]) == 46\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [20, 30, 40, 50, 60, 70, 80, 90, 100],experience = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 441\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [10, 20, 30, 40, 50],experience = [1, 2, 3, 4, 5]) == 141\n    assert candidate(initialEnergy = 25,initialExperience = 25,energy = [20, 15, 10, 5],experience = [5, 10, 15, 20]) == 26\n    assert candidate(initialEnergy = 30,initialExperience = 20,energy = [15, 25, 10],experience = [10, 15, 25]) == 21\n    assert candidate(initialEnergy = 50,initialExperience = 30,energy = [10, 20, 15, 25],experience = [5, 25, 20, 30]) == 21\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [99, 98, 97, 96, 95],experience = [95, 96, 97, 98, 99]) == 580\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [10, 20, 30, 40],experience = [40, 30, 20, 10]) == 140\n    assert candidate(initialEnergy = 10,initialExperience = 5,energy = [3, 2, 6, 1],experience = [5, 4, 3, 2]) == 4\n    assert candidate(initialEnergy = 5,initialExperience = 5,energy = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],experience = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 26\n    assert candidate(initialEnergy = 5,initialExperience = 5,energy = [1, 2, 3, 4, 5],experience = [5, 4, 3, 2, 1]) == 12\n    assert candidate(initialEnergy = 60,initialExperience = 30,energy = [20, 20, 20, 20, 20],experience = [20, 20, 20, 20, 20]) == 41\n    assert candidate(initialEnergy = 75,initialExperience = 40,energy = [40, 30, 20, 10, 5],experience = [50, 40, 30, 20, 10]) == 42\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [25, 10, 10, 5],experience = [20, 25, 30, 10]) == 1\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41],experience = [51, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == 408\n    assert candidate(initialEnergy = 10,initialExperience = 5,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 52\n    assert candidate(initialEnergy = 20,initialExperience = 10,energy = [25, 15, 5, 10, 20],experience = [30, 20, 10, 5, 15]) == 77\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],experience = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 947\n    assert candidate(initialEnergy = 30,initialExperience = 30,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 26\n    assert candidate(initialEnergy = 5,initialExperience = 3,energy = [1, 2, 3, 4, 5],experience = [5, 4, 3, 2, 1]) == 14\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [5, 6, 7, 8],experience = [15, 14, 13, 12]) == 23\n    assert candidate(initialEnergy = 80,initialExperience = 60,energy = [15, 20, 25, 30, 35],experience = [65, 70, 75, 80, 85]) == 52\n    assert candidate(initialEnergy = 40,initialExperience = 30,energy = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],experience = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 61\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 30, 20],experience = [20, 30, 50]) == 1\n    assert candidate(initialEnergy = 25,initialExperience = 25,energy = [13, 14, 15, 16, 17],experience = [17, 16, 15, 14, 13]) == 51\n    assert candidate(initialEnergy = 30,initialExperience = 30,energy = [29, 28, 27, 26, 25],experience = [25, 26, 27, 28, 29]) == 106\n    assert candidate(initialEnergy = 20,initialExperience = 20,energy = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],experience = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 31\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 25, 12, 6, 3, 1],experience = [1, 3, 6, 12, 25, 50]) == 0\n    assert candidate(initialEnergy = 80,initialExperience = 70,energy = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],experience = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 471\n    assert candidate(initialEnergy = 100,initialExperience = 1,energy = [99, 99, 99],experience = [98, 97, 96]) == 296\n    assert candidate(initialEnergy = 10,initialExperience = 15,energy = [3, 4, 5, 6, 7],experience = [5, 6, 7, 8, 9]) == 16\n    assert candidate(initialEnergy = 20,initialExperience = 10,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 37\n    assert candidate(initialEnergy = 50,initialExperience = 20,energy = [25, 25, 25, 25],experience = [15, 15, 15, 15]) == 51\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30, 40],experience = [40, 30, 20, 10]) == 51\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],experience = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 212\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 40, 30, 20, 10],experience = [10, 20, 30, 40, 50]) == 51\n    assert candidate(initialEnergy = 60,initialExperience = 25,energy = [20, 20, 20, 20],experience = [15, 25, 35, 45]) == 21\n    assert candidate(initialEnergy = 60,initialExperience = 40,energy = [10, 20, 30, 40],experience = [40, 30, 20, 10]) == 42\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],experience = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30, 40],experience = [45, 35, 25, 15]) == 51\n    assert candidate(initialEnergy = 3,initialExperience = 4,energy = [2, 5, 7, 8],experience = [5, 3, 6, 10]) == 22\n    assert candidate(initialEnergy = 50,initialExperience = 10,energy = [30, 20, 10, 5, 25],experience = [15, 25, 5, 10, 30]) == 47\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [99, 1, 1],experience = [1, 99, 1]) == 199\n    assert candidate(initialEnergy = 20,initialExperience = 20,energy = [10, 20, 30, 40],experience = [15, 15, 15, 15]) == 81\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [99, 99, 99, 99],experience = [99, 99, 99, 99]) == 297\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [90, 80, 70, 60, 50, 40, 30, 20, 10],experience = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 459\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [25, 25, 25, 25],experience = [20, 30, 20, 30]) == 51\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [10, 10, 10, 10],experience = [11, 12, 13, 14]) == 33\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [10, 20, 30, 40, 50],experience = [50, 40, 30, 20, 10]) == 200\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 3, 2, 4, 5, 3, 2, 1],experience = [2, 1, 3, 2, 1, 4, 3, 2]) == 23\n    assert candidate(initialEnergy = 30,initialExperience = 25,energy = [5, 15, 25, 35, 45],experience = [40, 35, 30, 25, 20]) == 112\n    assert candidate(initialEnergy = 20,initialExperience = 10,energy = [5, 10, 15, 20],experience = [8, 6, 4, 2]) == 31\n    assert candidate(initialEnergy = 50,initialExperience = 30,energy = [10, 20, 30, 40],experience = [20, 30, 40, 50]) == 51\n    assert candidate(initialEnergy = 15,initialExperience = 20,energy = [3, 3, 3, 3, 3],experience = [1, 2, 3, 4, 5]) == 1\n    assert candidate(initialEnergy = 10,initialExperience = 50,energy = [25, 25, 25, 25],experience = [51, 52, 53, 54]) == 93\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [10, 20, 30],experience = [30, 20, 10]) == 90\n    assert candidate(initialEnergy = 50,initialExperience = 100,energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],experience = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 2, 3, 4, 5],experience = [1, 2, 3, 4, 5]) == 16\n    assert candidate(initialEnergy = 30,initialExperience = 15,energy = [5, 10, 15, 20, 25],experience = [10, 15, 20, 25, 30]) == 46\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [25, 25, 25, 25],experience = [25, 25, 25, 25]) == 51\n    assert candidate(initialEnergy = 60,initialExperience = 60,energy = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],experience = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 532\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [5, 5, 5, 5],experience = [5, 5, 5, 5]) == 11\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],experience = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 56\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30],experience = [15, 25, 35]) == 11\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [5, 5, 5, 5, 5],experience = [1, 2, 3, 4, 5]) == 16\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 1, 1],experience = [1, 1, 1]) == 4\n    assert candidate(initialEnergy = 1,initialExperience = 100,energy = [1, 1, 1],experience = [1, 1, 1]) == 3\n    assert candidate(initialEnergy = 1,initialExperience = 50,energy = [50, 50, 50, 50],experience = [1, 1, 1, 1]) == 200\n    assert candidate(initialEnergy = 100,initialExperience = 1,energy = [100],experience = [1]) == 2\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 25, 25],experience = [50, 25, 25]) == 1\n    assert candidate(initialEnergy = 5,initialExperience = 5,energy = [2, 3, 4],experience = [4, 3, 2]) == 5\n    assert candidate(initialEnergy = 30,initialExperience = 30,energy = [10, 20, 10],experience = [5, 15, 10]) == 11\n    assert candidate(initialEnergy = 15,initialExperience = 15,energy = [5, 5, 5],experience = [5, 5, 5]) == 1\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30, 40],experience = [10, 20, 30, 40]) == 51\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [50, 50],experience = [50, 50]) == 52\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 1, 1, 1],experience = [1, 1, 1, 1]) == 5\n    assert candidate(initialEnergy = 20,initialExperience = 20,energy = [5, 5, 5, 5, 5],experience = [5, 5, 5, 5, 5]) == 6\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [50, 40, 30],experience = [30, 40, 50]) == 71\n    assert candidate(initialEnergy = 50,initialExperience = 1,energy = [25, 25, 25],experience = [25, 25, 25]) == 51\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [5, 4, 3, 2, 1],experience = [1, 2, 3, 4, 5]) == 16\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [10, 10, 10],experience = [10, 10, 10]) == 22\n    assert candidate(initialEnergy = 50,initialExperience = 1,energy = [1, 1, 1, 1],experience = [50, 50, 50, 50]) == 50\n    assert candidate(initialEnergy = 1,initialExperience = 100,energy = [1],experience = [100]) == 2\n    assert candidate(initialEnergy = 20,initialExperience = 20,energy = [10, 10, 10],experience = [10, 10, 10]) == 11\n    assert candidate(initialEnergy = 100,initialExperience = 1,energy = [99, 98, 97],experience = [97, 98, 99]) == 292\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 10, 10, 10, 10],experience = [10, 10, 10, 10, 10]) == 1\n    assert candidate(initialEnergy = 1,initialExperience = 100,energy = [1, 1, 1, 1],experience = [1, 1, 1, 1]) == 4\n    assert candidate(initialEnergy = 5,initialExperience = 5,energy = [3, 2, 1],experience = [1, 2, 3]) == 2\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],experience = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(initialEnergy = 5,initialExperience = 5,energy = [10, 10, 10],experience = [10, 10, 10]) == 32\n    assert candidate(initialEnergy = 30,initialExperience = 10,energy = [10, 10, 10],experience = [5, 5, 5]) == 1\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],experience = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [1, 2, 3, 4, 5],experience = [5, 4, 3, 2, 1]) == 6\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [25, 25, 25, 25],experience = [25, 25, 25, 25]) == 51\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [1, 2, 3, 4, 5],experience = [5, 4, 3, 2, 1]) == 6\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],experience = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30],experience = [15, 25, 35]) == 11\n    assert candidate(initialEnergy = 10,initialExperience = 1,energy = [2, 3, 4, 5],experience = [3, 4, 5, 6]) == 8\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [10, 20, 30],experience = [30, 20, 10]) == 0\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 30],experience = [40, 60]) == 0\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [5, 5, 5, 5],experience = [5, 5, 5, 5]) == 11\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 2, 3],experience = [1, 2, 3]) == 7\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [1, 1, 1, 1],experience = [1, 1, 1, 1]) == 0\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [10, 9, 8, 7],experience = [7, 8, 9, 10]) == 25\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [50, 25, 25],experience = [50, 25, 25]) == 52\n    assert candidate(initialEnergy = 3,initialExperience = 3,energy = [1, 1, 1, 1],experience = [1, 1, 1, 1]) == 2\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [50, 50, 50],experience = [50, 50, 50]) == 102\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 50, 50],experience = [30, 30, 30]) == 51\n    assert candidate(initialEnergy = 20,initialExperience = 20,energy = [10, 10],experience = [10, 10]) == 1\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [10, 10, 10],experience = [10, 10, 10]) == 22\n    assert candidate(initialEnergy = 10,initialExperience = 1,energy = [10, 10, 10],experience = [1, 1, 1]) == 22\n    assert candidate(initialEnergy = 30,initialExperience = 10,energy = [15, 15, 15],experience = [5, 5, 5]) == 16\n    assert candidate(initialEnergy = 60,initialExperience = 50,energy = [30, 20, 10],experience = [10, 20, 30]) == 1\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30],experience = [5, 15, 25]) == 11\n    assert candidate(initialEnergy = 1,initialExperience = 1,energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],experience = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n    assert candidate(initialEnergy = 100,initialExperience = 100,energy = [50, 40, 30],experience = [10, 20, 30]) == 21\n    assert candidate(initialEnergy = 3,initialExperience = 3,energy = [1, 1, 3, 3],experience = [3, 3, 1, 1]) == 7\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [10, 20, 30],experience = [5, 15, 25]) == 11\n    assert candidate(initialEnergy = 1,initialExperience = 50,energy = [25, 25, 25],experience = [25, 25, 25]) == 75\n    assert candidate(initialEnergy = 100,initialExperience = 1,energy = [1, 1, 1],experience = [1, 1, 1]) == 1\n    assert candidate(initialEnergy = 50,initialExperience = 50,energy = [50],experience = [50]) == 2\n    assert candidate(initialEnergy = 10,initialExperience = 10,energy = [5, 5, 5],experience = [5, 5, 5]) == 6\n", "comparison": "exact"}, "public_tests": ["5\n3\n[1,4,3,2]\n[2,6,3,1]", "2\n4\n[1]\n[3]"], "hints": ["Find the minimum number of training hours needed for the energy and experience separately, and sum the results.", "Try to increase the energy and experience until you find how much is enough to win the competition."], "metadata": {"canonical_parameter_names": ["initialEnergy", "initialExperience", "energy", "experience"], "leetcode_dataset_entry_point": "Solution().minNumberOfHours", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:46+00:00", "tests_total": 169, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minNumberOfHours(self, initialEnergy: int, initialExperience: int, energy: list[int], experience: list[int]) -> int:", "container": "Solution", "callable": "minNumberOfHours", "parameters": [{"name": "initialEnergy", "type": "int"}, {"name": "initialExperience", "type": "int"}, {"name": "energy", "type": "list[int]"}, {"name": "experience", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2384, "task_id": "largest-palindromic-number", "difficulty": "Medium", "problem_description": "You are given a string num consisting of digits only.\n\nReturn the largest palindromic integer (in the form of a string) that can be formed using digits taken from num. It should not contain leading zeroes.\n\nNotes:\n\n- You do not need to use all the digits of num, but you must use at least one digit.\n- The digits can be reordered.\n\nExample 1:\n\nInput: num = \"444947137\"\nOutput: \"7449447\"\nExplanation:\nUse the digits \"4449477\" from \"444947137\" to form the palindromic integer \"7449447\".\nIt can be shown that \"7449447\" is the largest palindromic integer that can be formed.\n\nExample 2:\n\nInput: num = \"00009\"\nOutput: \"9\"\nExplanation:\nIt can be shown that \"9\" is the largest palindromic integer that can be formed.\nNote that the integer returned should not contain leading zeroes.\n\nConstraints:\n\n- 1 <= num.length <= 10^5\n- num consists of digits.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num = \"1111\") == \"1111\"\n    assert candidate(num = \"00000\") == \"0\"\n    assert candidate(num = \"10\") == \"1\"\n    assert candidate(num = \"9\") == \"9\"\n    assert candidate(num = \"1111111111\") == \"1111111111\"\n    assert candidate(num = \"00009\") == \"9\"\n    assert candidate(num = \"000\") == \"0\"\n    assert candidate(num = \"220022\") == \"220022\"\n    assert candidate(num = \"1\") == \"1\"\n    assert candidate(num = \"55555\") == \"55555\"\n    assert candidate(num = \"12345678987654321\") == \"87654321912345678\"\n    assert candidate(num = \"9876543210\") == \"9\"\n    assert candidate(num = \"0\") == \"0\"\n    assert candidate(num = \"444947137\") == \"7449447\"\n    assert candidate(num = \"22\") == \"22\"\n    assert candidate(num = \"123321\") == \"321123\"\n    assert candidate(num = \"1234567890\") == \"9\"\n    assert candidate(num = \"9876543210000000000\") == \"9\"\n    assert candidate(num = \"1001\") == \"1001\"\n    assert candidate(num = \"987654321111111111111111111111111111111111111111111987654321\") == \"987654321111111111111111111111111111111111111111111123456789\"\n    assert candidate(num = \"1001001001001001\") == \"1110000000000111\"\n    assert candidate(num = \"123456789987654321123456789987654321\") == \"998877665544332211112233445566778899\"\n    assert candidate(num = \"12345543211234554321\") == \"55443322111122334455\"\n    assert candidate(num = \"98765432109876543210\") == \"98765432100123456789\"\n    assert candidate(num = \"1000000000000000000000001\") == \"1000000000000000000000001\"\n    assert candidate(num = \"900000000000000000000000000000009\") == \"900000000000000000000000000000009\"\n    assert candidate(num = \"33330000000000000000000\") == \"33000000000000000000033\"\n    assert candidate(num = \"0987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210\") == \"99998888777766665555444433332222111100000900000111122223333444455556666777788889999\"\n    assert candidate(num = \"5555555555555555555\") == \"5555555555555555555\"\n    assert candidate(num = \"101010101010101010101010101010101010101010101010101010101010101010101010101010101\") == \"111111111111111111110000000000000000000010000000000000000000011111111111111111111\"\n    assert candidate(num = \"1111100000111110000011111\") == \"1111111000001000001111111\"\n    assert candidate(num = \"11000011\") == \"11000011\"\n    assert candidate(num = \"123455432109876567890\") == \"987654321050123456789\"\n    assert candidate(num = \"999999999999999999999999999\") == \"999999999999999999999999999\"\n    assert candidate(num = \"10000000000000000000000000000000000000000000000000000000000000000000000000001\") == \"10000000000000000000000000000000000000000000000000000000000000000000000000001\"\n    assert candidate(num = \"090090090\") == \"900090009\"\n    assert candidate(num = \"111122223333444455556666777788889999\") == \"998877665544332211112233445566778899\"\n    assert candidate(num = \"1234567898765432100000000000000000000000000000000000000000000000000000000000000000\") == \"876543210000000000000000000000000000000090000000000000000000000000000000012345678\"\n    assert candidate(num = \"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009\") == \"9\"\n    assert candidate(num = \"123321456654123321\") == \"654332211112233456\"\n    assert candidate(num = \"543210987654321098765432109876543210\") == \"987655443322110090011223344556789\"\n    assert candidate(num = \"00000000000000000000000000000000000000000000000000000000000000000000000000009\") == \"9\"\n    assert candidate(num = \"101010101010101010101010101010101\") == \"111111110000000010000000011111111\"\n    assert candidate(num = \"1234567890987654321\") == \"9876543210123456789\"\n    assert candidate(num = \"0000000001000000000\") == \"1\"\n    assert candidate(num = \"111222333444555666777888999\") == \"9876543219123456789\"\n    assert candidate(num = \"987654321234567890000000\") == \"98765432000100023456789\"\n    assert candidate(num = \"987654321234567890\") == \"98765432123456789\"\n    assert candidate(num = \"122111221\") == \"221111122\"\n    assert candidate(num = \"908070605040302010\") == \"9\"\n", "comparison": "exact"}, "public_tests": ["\"444947137\"", "\"00009\""], "hints": ["In order to form a valid palindrome, other than the middle digit in an odd-length palindrome, every digit needs to exist on both sides.", "A longer palindrome implies a larger valued palindrome. For palindromes of the same length, the larger digits should occur first.", "We can count the occurrences of each digit and build the palindrome starting from the ends. Starting from the larger digits, if there are still at least 2 occurrences of a digit, we can place these digits on each side.", "Make sure to consider the special case for the center digit (if any) and zeroes. There should not be leading zeroes."], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().largestPalindromic", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:48+00:00", "tests_total": 50, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "greedy", "counting"]}, "language": "python", "interface": {"raw_signature": "def largestPalindromic(self, num: str) -> str:", "container": "Solution", "callable": "largestPalindromic", "parameters": [{"name": "num", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2386, "task_id": "find-the-k-sum-of-an-array", "difficulty": "Hard", "problem_description": "You are given an integer array nums and a positive integer k. You can choose any subsequence of the array and sum all of its elements together.\n\nWe define the K-Sum of the array as the k^th largest subsequence sum that can be obtained (not necessarily distinct).\n\nReturn the K-Sum of the array.\n\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n\nNote that the empty subsequence is considered to have a sum of 0.\n\nExample 1:\n\nInput: nums = [2,4,-2], k = 5\nOutput: 2\nExplanation: All the possible subsequence sums that we can obtain are the following sorted in decreasing order:\n6, 4, 4, 2, 2, 0, 0, -2.\nThe 5-Sum of the array is 2.\n\nExample 2:\n\nInput: nums = [1,-2,3,4,-10,12], k = 16\nOutput: 10\nExplanation: The 16-Sum of the array is 10.\n\nConstraints:\n\n- n == nums.length\n- 1 <= n <= 10^5\n- -10^9 <= nums[i] <= 10^9\n- 1 <= k <= min(2000, 2^n)\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 100\n    assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000],k = 7) == 0\n    assert candidate(nums = [1000000000, -1000000000, 1000000000],k = 3) == 1000000000\n    assert candidate(nums = [1, 2, 3],k = 1) == 6\n    assert candidate(nums = [5, 8, 3, 1],k = 8) == 9\n    assert candidate(nums = [0, 0, 0, 0],k = 10) == 0\n    assert candidate(nums = [0, 0, 0, 0],k = 1) == 0\n    assert candidate(nums = [-1, -2, -3],k = 4) == -3\n    assert candidate(nums = [-1, -2, -3, -4],k = 4) == -3\n    assert candidate(nums = [5, 10, -3, 7, 2, -8],k = 3) == 21\n    assert candidate(nums = [1, 2, 3],k = 2) == 5\n    assert candidate(nums = [2, 4, -2],k = 5) == 2\n    assert candidate(nums = [1, -2, 3, 4, -10, 12],k = 16) == 10\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1000) == 80\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1000) == 27\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 512) == 27\n    assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 500) == 0\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 100) == -14\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1000) == 17\n    assert candidate(nums = [5, 7, -3, 9, -6, 2, 8, -4],k = 20) == 21\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 20) == 8000000000\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1024) == 0\n    assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8],k = 20) == 12\n    assert candidate(nums = [100, 200, 300, -100, -200, -300, 400, 500, -400, -500],k = 50) == 900\n    assert candidate(nums = [100, 200, -150, 250, -300, 400, -50, -500, 600, 700, -1000, 800, 900],k = 1000) == 2150\n    assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6],k = 25) == 17\n    assert candidate(nums = [5, -3, 7, 1, -2, 4],k = 15) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 200) == 193\n    assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20],k = 750) == 76\n    assert candidate(nums = [5, -5, 15, -15, 25, -25, 35, -35, 45, -45],k = 100) == 60\n    assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 100) == 70\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 100) == 7\n    assert candidate(nums = [1, 3, -2, 5, -4, 2, 6],k = 10) == 13\n    assert candidate(nums = [5, -3, 7, 9, -2, 10],k = 15) == 19\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 1000) == 2000000000\n    assert candidate(nums = [1000000000, -999999999, 999999998, -999999997, 999999996, -999999995, 999999994, -999999993, 999999992, -999999991],k = 200) == 1000000004\n    assert candidate(nums = [5, -3, 2, 1, -2, 4, -1, 3, -5, 6],k = 150) == 11\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 50) == 1902343750\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 500) == 280\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 500) == 5\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50, -55, -60, -65, -70, -75, -80, -85, -90, -95, -100],k = 1500) == 975\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 512) == 280\n    assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120, -130, 140, -150, 160, -170, 180, -190, 200],k = 1000) == 840\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1000) == 93\n    assert candidate(nums = [-1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000],k = 1000) == -8000000000\n    assert candidate(nums = [10, 20, 30, -10, -20, -30, 40, 50, 60, -40, -50, -60],k = 150) == 120\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 2000) == 31\n    assert candidate(nums = [100, 200, 300, -100, -200, -300, 400, 500, 600, -400, -500, -600, 700, 800, 900],k = 500) == 3300\n    assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 256) == -210\n    assert candidate(nums = [5, 3, -1, 4, -6, 2, -2, 3],k = 10) == 13\n    assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000],k = 2000) == 3800\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 30) == 1000000000\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1024) == 17\n    assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2000) == 6\n    assert candidate(nums = [1000000, -500000, 2000000, -1000000, 3000000, -1500000],k = 20) == 2500000\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 100) == 40\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 500) == 172\n    assert candidate(nums = [5, -1, 3, -4, 2, -6, 7, -8, 9, -10],k = 128) == 10\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 50) == -11\n    assert candidate(nums = [5, 4, 3, 2, 1],k = 20) == 6\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 500) == 188\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 500) == 17\n    assert candidate(nums = [10, -5, 3, -2, 1, -1, 0],k = 15) == 11\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500],k = 300) == 4400\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == -3\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1500) == 181\n    assert candidate(nums = [-1, -2, -3, -4, -5],k = 20) == -9\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 100) == 400\n    assert candidate(nums = [-1, -2, -3, -4, -5],k = 7) == -4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1024) == 0\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9],k = 1000) == 33\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 2000) == 343\n    assert candidate(nums = [999999999, -999999999, 999999998, -999999998, 999999997, -999999997, 999999996, -999999996, 999999995, -999999995],k = 500) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 2000) == 179\n    assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 1000) == 33\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 1024) == 351\n    assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 200) == 8\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],k = 1000) == 4100\n    assert candidate(nums = [5, -3, 2, 7, -8, 10, -2, 3, 4, -1],k = 15) == 26\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2000) == 16\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 1024) == -55\n    assert candidate(nums = [500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907, 953, 476, 238, 119, 59, 29, 14, 7, 3, 1],k = 1000) == 999998131\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1000) == 17\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 15) == -7\n    assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20],k = 500) == 88\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1024) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1000) == 184\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],k = 1500) == 3900\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 750) == 420\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 1500) == 32\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 500) == 43\n    assert candidate(nums = [100, 200, 300, -100, -200, -300, 400, 500, -400, -500, 600, 700, -600, -700, 800, 900, -800, -900, 1000, -1000],k = 1000) == 4100\n    assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 15) == 7\n    assert candidate(nums = [-10, -20, -30, -40, -50],k = 5) == -30\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 28\n    assert candidate(nums = [1000000000, -500000000, 500000000, -250000000, 250000000, -125000000, 125000000],k = 100) == 0\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 1200) == 167\n", "comparison": "exact"}, "public_tests": ["[2,4,-2]\n5", "[1,-2,3,4,-10,12]\n16"], "hints": ["Start from the largest sum possible, and keep finding the next largest sum until you reach the kth sum.", "Starting from a sum, what are the two next largest sums that you can obtain from it?"], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().kSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:53+00:00", "tests_total": 105, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def kSum(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "kSum", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2389, "task_id": "longest-subsequence-with-limited-sum", "difficulty": "Easy", "problem_description": "You are given an integer array nums of length n, and an integer array queries of length m.\n\nReturn an array answer of length m where answer[i] is the maximum size of a subsequence that you can take from nums such that the sum of its elements is less than or equal to queries[i].\n\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n\nExample 1:\n\nInput: nums = [4,5,2,1], queries = [3,10,21]\nOutput: [2,3,4]\nExplanation: We answer the queries as follows:\n- The subsequence [2,1] has a sum less than or equal to 3. It can be proven that 2 is the maximum size of such a subsequence, so answer[0] = 2.\n- The subsequence [4,5,1] has a sum less than or equal to 10. It can be proven that 3 is the maximum size of such a subsequence, so answer[1] = 3.\n- The subsequence [4,5,2,1] has a sum less than or equal to 21. It can be proven that 4 is the maximum size of such a subsequence, so answer[2] = 4.\n\nExample 2:\n\nInput: nums = [2,3,4,5], queries = [1]\nOutput: [0]\nExplanation: The empty subsequence is the only subsequence that has a sum less than or equal to 1, so answer[0] = 0.\n\nConstraints:\n\n- n == nums.length\n- m == queries.length\n- 1 <= n, m <= 1000\n- 1 <= nums[i], queries[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 2, 3, 4, 5],queries = [1, 2, 3, 4, 5]) == [1, 1, 2, 2, 2]\n    assert candidate(nums = [10, 20, 30],queries = [10, 25, 50, 70]) == [1, 1, 2, 3]\n    assert candidate(nums = [10, 20, 30],queries = [5, 15, 25, 35]) == [0, 1, 1, 2]\n    assert candidate(nums = [10, 20, 30],queries = [10, 25, 50, 60]) == [1, 1, 2, 3]\n    assert candidate(nums = [5, 4, 3, 2, 1],queries = [1, 2, 3, 4, 5]) == [1, 1, 2, 2, 2]\n    assert candidate(nums = [4, 5, 2, 1],queries = [3, 10, 21]) == [2, 3, 4]\n    assert candidate(nums = [10, 20, 30, 40, 50],queries = [100, 200, 300, 400, 500]) == [4, 5, 5, 5, 5]\n    assert candidate(nums = [5, 5, 5, 5, 5],queries = [1, 5, 10, 15, 25]) == [0, 1, 2, 3, 5]\n    assert candidate(nums = [2, 3, 4, 5],queries = [1]) == [0]\n    assert candidate(nums = [1, 1, 1, 1, 1],queries = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n    assert candidate(nums = [10, 20, 30],queries = [5, 15, 25, 35, 45]) == [0, 1, 1, 2, 2]\n    assert candidate(nums = [10, 20, 30],queries = [15, 25, 35, 45]) == [1, 1, 2, 2]\n    assert candidate(nums = [1, 2, 3, 4, 5],queries = [15, 10, 5]) == [5, 4, 2]\n    assert candidate(nums = [1, 2, 3, 4, 5],queries = [15, 10, 5, 3, 1]) == [5, 4, 2, 2, 1]\n    assert candidate(nums = [1, 2, 3, 4, 5],queries = [15, 10, 5, 3]) == [5, 4, 2, 2]\n    assert candidate(nums = [5, 4, 3, 2, 1],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [55]) == [10]\n    assert candidate(nums = [1000000],queries = [1000000]) == [1]\n    assert candidate(nums = [5, 5, 5, 5, 5],queries = [5, 10, 15, 20, 25]) == [1, 2, 3, 4, 5]\n    assert candidate(nums = [1, 1000000],queries = [1000000]) == [1]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [5, 10, 15, 20, 25, 30]) == [5, 10, 15, 20, 20, 20]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6]\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == [0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],queries = [55, 165, 275, 385, 495, 605, 715, 825, 935, 1045, 1155, 1265, 1375, 1485, 1595]) == [2, 5, 6, 8, 9, 10, 11, 12, 13, 13, 14, 15, 15, 15, 15]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [3, 4, 5, 6, 7, 7, 8, 8, 9, 10]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210]) == [4, 5, 7, 8, 9, 10, 11, 12, 12, 13, 14, 15, 15, 16, 16, 17, 17, 18, 19, 19, 20]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [2, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [1, 5, 15, 30, 50, 75, 105, 140, 180, 225, 275, 330, 385, 440, 500]) == [1, 2, 5, 7, 9, 11, 14, 15, 15, 15, 15, 15, 15, 15, 15]\n    assert candidate(nums = [100, 10, 1, 50, 20, 60],queries = [50, 150, 200, 300, 400]) == [3, 5, 5, 6, 6]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],queries = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == [1, 2, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 12, 13, 13, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [10, 30, 60, 100, 150, 210, 280, 360, 450, 550]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6]\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],queries = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [500, 1500, 2500, 3500, 4500, 5500, 6500, 7500, 8500, 9500]) == [2, 5, 6, 7, 9, 10, 10, 10, 10, 10]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [4, 5, 7, 8, 9, 10, 11, 12, 12, 13]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],queries = [10, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350, 1400, 1450, 1500]) == [1, 2, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 12, 13, 13, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],queries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [5, 8, 10, 12, 13, 15, 16, 17, 18, 19]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]\n    assert candidate(nums = [7, 3, 10, 1, 5, 2, 8, 6, 4, 9],queries = [15, 25, 30, 35, 40, 45, 50]) == [5, 6, 7, 7, 8, 9, 9]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [9, 7, 5, 3, 1],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [3, 4, 5, 5, 5, 5, 5, 5, 5, 5]\n    assert candidate(nums = [5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 4, 3, 2, 1, 3, 2, 1, 2, 1, 1],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26]\n    assert candidate(nums = [7, 3, 4, 9, 1],queries = [10, 15, 20, 25, 30, 35, 40]) == [3, 4, 4, 5, 5, 5, 5]\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],queries = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n    assert candidate(nums = [100, 200, 300, 400, 500],queries = [150, 300, 450, 600, 750, 900, 1050]) == [1, 2, 2, 3, 3, 3, 4]\n    assert candidate(nums = [7, 1, 3, 2, 8, 5, 6, 4],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == [10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n    assert candidate(nums = [300, 200, 100, 400, 500],queries = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == [0, 1, 1, 2, 2, 2, 3, 3, 3, 3]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130]) == [2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60]) == [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7]\n    assert candidate(nums = [50, 40, 30, 20, 10],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4]\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7]\n    assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991],queries = [500, 1500, 2500, 3500, 4500, 5500, 6500, 7500, 8500, 9500]) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [2, 4, 5, 5, 6, 7, 7, 8, 9, 9]\n    assert candidate(nums = [999999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1000000, 500000, 100000, 50000]) == [19, 19, 19, 19]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == [2, 5, 6, 7, 9, 10, 10, 11, 12, 13, 14, 14, 15, 15, 16, 17, 17, 18, 18, 19]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],queries = [10, 30, 60, 100, 150, 210, 280, 360, 450, 550, 660, 780, 910, 1050, 1200, 1360, 1530, 1710, 1900, 2100]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 9]\n    assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],queries = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [1, 2, 3, 4, 5, 6, 7, 7, 7, 7]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == [0, 1, 1, 2, 2, 2, 3, 3, 3, 3]\n    assert candidate(nums = [1000000, 500000, 250000, 125000, 62500],queries = [100000, 250000, 500000, 750000, 1000000]) == [1, 2, 3, 3, 4]\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [1, 2, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],queries = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 2, 3, 3, 4, 4, 4, 5, 5]\n    assert candidate(nums = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711],queries = [10, 100, 1000, 10000, 100000, 1000000]) == [3, 7, 12, 16, 20, 20]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [90, 180, 270, 360, 450, 540, 630, 720, 810, 900, 990]) == [3, 5, 6, 8, 9, 9, 10, 10, 10, 10, 10]\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14]\n    assert candidate(nums = [9, 7, 5, 3, 1],queries = [5, 10, 15, 20, 25, 30]) == [2, 3, 3, 4, 5, 5]\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9]\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == [1, 50, 100, 145, 145, 145, 145, 145, 145, 145, 145]\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],queries = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500]) == [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [0, 1, 1, 2, 2, 3, 3, 4, 4, 5]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250]) == [0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1, 5, 10, 20, 50, 100, 200, 500, 1000]) == [1, 5, 10, 20, 50, 91, 91, 91, 91]\n    assert candidate(nums = [33, 21, 47, 55, 17, 82, 38, 67, 25, 12, 99, 78, 63, 44, 5, 85, 93, 4, 52, 36, 73, 29, 31, 88, 57, 90, 19, 15, 81, 77, 7, 48, 53, 18, 11, 34, 86, 59, 97, 40, 30, 92, 68, 49, 61, 50, 54, 91, 74, 75, 70, 60, 83, 64, 41, 87, 62, 24, 22, 27, 66, 35, 23, 58, 79, 98, 94, 39, 28, 20, 65, 43, 51, 46, 6, 95, 71, 1, 96, 3, 8, 9, 10, 13, 14, 16, 26, 32, 37, 42, 45, 56, 72, 80, 84, 89, 91],queries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == [12, 18, 23, 26, 30, 33, 35, 38, 40, 43, 45, 47, 49, 51, 53]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [10, 30, 60, 100, 150, 210, 280, 360, 450, 550]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550]) == [0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5]\n    assert candidate(nums = [500, 400, 300, 200, 100],queries = [150, 250, 350, 450, 550, 650, 750, 850, 950]) == [1, 1, 2, 2, 2, 3, 3, 3, 3]\n    assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200],queries = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 11, 12, 12]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == [5, 6, 7, 9, 10, 10, 10, 10, 10, 10]\n", "comparison": "exact"}, "public_tests": ["[4,5,2,1]\n[3,10,21]", "[2,3,4,5]\n[1]"], "hints": ["Solve each query independently.", "When solving a query, which elements of nums should you choose to make the subsequence as long as possible?", "Choose the smallest elements in nums that add up to a sum less than the query."], "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().answerQueries", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:50:58+00:00", "tests_total": 108, "tests_dropped": 10, "flags": [], "topic_tags": ["array", "binary-search", "greedy", "sorting", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def answerQueries(self, nums: list[int], queries: list[int]) -> list[int]:", "container": "Solution", "callable": "answerQueries", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "queries", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2390, "task_id": "removing-stars-from-a-string", "difficulty": "Medium", "problem_description": "You are given a string s, which contains stars *.\n\nIn one operation, you can:\n\n- Choose a star in s.\n- Remove the closest non-star character to its left, as well as remove the star itself.\n\nReturn the string after all stars have been removed.\n\nNote:\n\n- The input will be generated such that the operation is always possible.\n- It can be shown that the resulting string will always be unique.\n\nExample 1:\n\nInput: s = \"leet**cod*e\"\nOutput: \"lecoe\"\nExplanation: Performing the removals from left to right:\n- The closest character to the 1^st star is 't' in \"leet**cod*e\". s becomes \"lee*cod*e\".\n- The closest character to the 2^nd star is 'e' in \"lee*cod*e\". s becomes \"lecod*e\".\n- The closest character to the 3^rd star is 'd' in \"lecod*e\". s becomes \"lecoe\".\nThere are no more stars, so we return \"lecoe\".\n\nExample 2:\n\nInput: s = \"erase*****\"\nOutput: \"\"\nExplanation: The entire string is removed, so we return an empty string.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of lowercase English letters and stars *.\n- The operation above can be performed on s.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"abc*def*ghi*jkl*mno*pqr*stu*vwx*y*z\") == \"abdeghjkmnpqstvwz\"\n    assert candidate(s = \"leet**cod*e\") == \"lecoe\"\n    assert candidate(s = \"a*b*c*d*e*\") == \"\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n    assert candidate(s = \"ab*cd*ef*gh*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*\") == \"aceg\"\n    assert candidate(s = \"a*ab*abc*abcd*abcde*abcdef*abcdefg*abcdefgh*abcdefghi*abcdefghij*abcdefghijk*abcdefghijkl*abcdefghijklm*abcdefghijklmn*abcdefghijklmno*abcdefghijklmnop*abcdefghijklmnopq*abcdefghijklmnopqr*abcdefghijklmnopqrs*abcdefghijklmnopqrst*abcdefghijklmnopqrstu*abcdefghijklmnopqrstuv*abcdefghijklmnopqrstuvw*abcdefghijklmnopqrstuvwx*abcdefghijklmnopqrstuvwxy*abcdefghijklmnopqrstuvwxyza\") == \"aababcabcdabcdeabcdefabcdefgabcdefghabcdefghiabcdefghijabcdefghijkabcdefghijklabcdefghijklmabcdefghijklmnabcdefghijklmnoabcdefghijklmnopabcdefghijklmnopqabcdefghijklmnopqrabcdefghijklmnopqrsabcdefghijklmnopqrstabcdefghijklmnopqrstuabcdefghijklmnopqrstuvabcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxyza\"\n    assert candidate(s = \"abcdef\") == \"abcdef\"\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n    assert candidate(s = \"a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a\") == \"a\"\n    assert candidate(s = \"ab*cd*ef*gh*ij*kl*mn*op*qr*st*uv*wx*yz\") == \"acegikmoqsuwyz\"\n    assert candidate(s = \"abcde\") == \"abcde\"\n    assert candidate(s = \"abc***\") == \"\"\n    assert candidate(s = \"ab*cd*ef*g*hi*j*\") == \"aceh\"\n    assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z\") == \"z\"\n    assert candidate(s = \"erase*****\") == \"\"\n    assert candidate(s = \"abcd**efgh**ijkl**mnop**qrst**uvw**x**y**z\") == \"abefijmnqz\"\n    assert candidate(s = \"aaabbbcccddd***eee***fffgggggghhhhiiiiijkkkkkllllmmmmnnnnoooo***pppppqqqqrrrrsssss\") == \"aaabbbcccfffgggggghhhhiiiiijkkkkkllllmmmmnnnnopppppqqqqrrrrsssss\"\n    assert candidate(s = \"abcde**fghij**klmno**pqrst**uvwxy**z\") == \"abcfghklmpqruvwz\"\n    assert candidate(s = \"abcdefghijklmnopqrstuv*xyzwvutsrponmlkjihgfedcba*\") == \"abcdefghijklmnopqrstuxyzwvutsrponmlkjihgfedcb\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz*zyxwvutsrqponmlkjihgfedcba*\") == \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcb\"\n    assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z\") == \"z\"\n    assert candidate(s = \"aaaaaa*bbbbbb*cccccc*dddddd*eeeeee*ffffff*gggggg*hhhhhh*iiiiii*jjjjjj*kkkkkk*llllll*mmmmmm*nnnnnn*oooooo*pppppp*qqqqqq*rrrrrr*ssssss*tttttt*uuuuuu*vvvvvv*wwwwww*xxxxxx*yyyyyy*zzzzzz*\") == \"aaaaabbbbbcccccdddddeeeeefffffggggghhhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooopppppqqqqqrrrrrssssstttttuuuuuvvvvvwwwwwxxxxxyyyyyzzzzz\"\n    assert candidate(s = \"abcde*fghij*klmno*pqrst*uvwxy*z*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z\") == \"abcdfghiklmnpqrsuvwxz\"\n    assert candidate(s = \"abc*def*ghi*jkl*mno*pqr*stu*vwx*yz*\") == \"abdeghjkmnpqstvwy\"\n    assert candidate(s = \"aaa*bbb*ccc*ddd*eee*fff*ggg*hhh*iii*jjj*kkk*lll*mmm*nnn*ooo*ppp*qqq*rrr*sss*ttt*uuu*vvv*www*xxx*yyy*zzz*\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z\") == \"abcdefghijklmnopqrstuvwxyz\"\n    assert candidate(s = \"abcde*fg*hi*jkl*mno*pqr*stu*vwx*y*z*\") == \"abcdfhjkmnpqstvw\"\n    assert candidate(s = \"aabbccddeeefffggg***hhiijjkkllmmnn***oo***ppqqrrssttttuuuuuuuuuuvvvvvvvvwxyz\") == \"aabbccddeeefffhhiijjkkllppqqrrssttttuuuuuuuuuuvvvvvvvvwxyz\"\n    assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz*****\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwx\"\n    assert candidate(s = \"z*yz*zyxw*vyxwv*u*vwxy*ts*rq*ponm*ln*kj*i*hg*fed*cb*a*\") == \"yzyxvyxwvwxtrponlkhfec\"\n    assert candidate(s = \"abc***def**ghij***klmno**pqrstuv***wxyz\") == \"dgklmpqrswxyz\"\n    assert candidate(s = \"abcdefghij*klmnopqrst*uvwxyz*zyxwvutsr*qp*on*m*l*k*j*i*h*g*f*e*d*c*b*a\") == \"abcdefghiklmnopqrsuvwxyzyxwvutsqoa\"\n    assert candidate(s = \"a*ab*abc*abcd*abcde*abcdef*abcdefg*abcdefgh*abcdefghi*abcdefghij*abcdefghijk*abcdefghijkl*abcdefghijklm*abcdefghijklmn*abcdefghijklmno*abcdefghijklmnop*abcdefghijklmnopq*abcdefghijklmnopqr*abcdefghijklmnopqrs*abcdefghijklmnopqrst*abcdefghijklmnopqrstu*abcdefghijklmnopqrstuv*abcdefghijklmnopqrstuvw*abcdefghijklmnopqrstuvwx*abcdefghijklmnopqrstuvwxy*abcdefghijklmnopqrstuvwxyz*\") == \"aababcabcdabcdeabcdefabcdefgabcdefghabcdefghiabcdefghijabcdefghijkabcdefghijklabcdefghijklmabcdefghijklmnabcdefghijklmnoabcdefghijklmnopabcdefghijklmnopqabcdefghijklmnopqrabcdefghijklmnopqrsabcdefghijklmnopqrstabcdefghijklmnopqrstuabcdefghijklmnopqrstuvabcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxy\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz****\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxx\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxy**z\") == \"abcdefghijklmnopqrstuvwz\"\n    assert candidate(s = \"xyz***xyz***xyz***xyz***xyz***xyz***xyz***xyz***xyz***xyz***xyz***xyz***xyz\") == \"xyz\"\n    assert candidate(s = \"abcde*****fghij*****klmno*****pqrst*****uvwxy*****z\") == \"z\"\n    assert candidate(s = \"abcdefghij***klmnopqrst***uvwxyz***abcd***efghij***klmno***pqrst***uvwxy***z\") == \"abcdefgklmnopquvwaefgklpquvz\"\n    assert candidate(s = \"abcdefghijk***lmnopqrstuvwxyz**aaaaaaaaaabbbbbbbbbbccccccccccddddeeeeee****\") == \"abcdefghlmnopqrstuvwxaaaaaaaaaabbbbbbbbbbccccccccccddddee\"\n    assert candidate(s = \"abcd*efgh*ijkl*mnop*qrst*uvw*x*y*z*\") == \"abcefgijkmnoqrsuv\"\n    assert candidate(s = \"nested*stars*****in*string*example***\") == \"nesteistrinexam\"\n    assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z\") == \"z\"\n    assert candidate(s = \"a*bb*ccc*dddd*eeeee*ffffff*gggggg*hhhhhhh*iiiiiiii*jjjjjjjjj*kkkkkkkkk*llllllllll*mmmmmmmmmm*nnnnnnnnnnn*ooooooooooo*pppppppppppp*qqqqqqqqqqqqq*rrrrrrrrrrrrrr*sssssssssssssss*ttttttttttttttttt*uuuuuuuuuuuuuuuuuu*vvvvvvvvvvvvvvvvvvv*wwwwwwwwwwwwwwwwwwww*xxyyz**\") == \"bccdddeeeefffffggggghhhhhhiiiiiiijjjjjjjjkkkkkkkklllllllllmmmmmmmmmnnnnnnnnnnoooooooooopppppppppppqqqqqqqqqqqqrrrrrrrrrrrrrssssssssssssssttttttttttttttttuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwxxy\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz*abcdefghijklmnopqrstuvwxyz*\") == \"abcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxy\"\n    assert candidate(s = \"abcde*fg*hij*k*lmnop*qrs*tuvw*x*y*z*\") == \"abcdfhilmnoqrtuv\"\n    assert candidate(s = \"abcdefghi*jk*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z**\") == \"abcdefgh\"\n    assert candidate(s = \"x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x\") == \"x\"\n    assert candidate(s = \"aabbaa*bbcc*ddcc*eeff*ffgg*hhiijj*kkll*mmnn*oopp*qqrr*sttuu*vwwxxyyzz*****\") == \"aabbabbcddceefffghhiijkklmmnoopqqrsttuvwwx\"\n    assert candidate(s = \"abc**def**ghi**jkl**mno**pqr**stu**vwx**yz**\") == \"adgjmpsv\"\n    assert candidate(s = \"mississippi***ipp*ss*m*i**\") == \"mississiip\"\n    assert candidate(s = \"a*bc*def*ghij*klmno*pqrst*uvwxy*z\") == \"bdeghiklmnpqrsuvwxz\"\n    assert candidate(s = \"mnopqrstu*****vwxyz*****abcdefghi*****jklmno*****pqrst*****uvw*****xy*****z\") == \"mnopz\"\n    assert candidate(s = \"abcde*fgh*i*jklmno*pqrstu*v*wxyz*\") == \"abcdfgjklmnpqrstwxy\"\n    assert candidate(s = \"abc*def*ghi*jkl*mno*pqr*stu*vwx*y*z**\") == \"abdeghjkmnpqstv\"\n    assert candidate(s = \"a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*\") == \"\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxy**z*\") == \"abcdefghijklmnopqrstuvw\"\n    assert candidate(s = \"xy*z*ab*cd*ef*gh*ij*kl*mn*op*qr*st*uv*wx*yz*\") == \"xacegikmoqsuwy\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz*\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyz\"\n    assert candidate(s = \"python*is*awesome***so**is**java**\") == \"pythoiawesja\"\n    assert candidate(s = \"longstringwith*various*characters*and*stars*through*out***\") == \"longstringwitvarioucharacteranstarthroug\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz*a**b**c**d**e**f**g**h**i**j**k**l**m**n**o**p**q**r**s**t**u**v**w**x**y**z\") == \"z\"\n    assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z\") == \"z\"\n    assert candidate(s = \"a*ab*abc*abcd*abcde*abcdef*abcdefg*abcdefgh*abcdefghi*abcdefghij*abcdefghijk\") == \"aababcabcdabcdeabcdefabcdefgabcdefghabcdefghiabcdefghijk\"\n    assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*abcdefghijklmnopqrstuvwxyz*zyxwvutsrqponmlkjihgfedcba*\") == \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcb\"\n", "comparison": "exact"}, "public_tests": ["\"leet**cod*e\"", "\"erase*****\""], "hints": ["What data structure could we use to efficiently perform these removals?", "Use a stack to store the characters. Pop one character off the stack at each star. Otherwise, we push the character onto the stack."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().removeStars", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:01+00:00", "tests_total": 65, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "stack", "simulation"]}, "language": "python", "interface": {"raw_signature": "def removeStars(self, s: str) -> str:", "container": "Solution", "callable": "removeStars", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2391, "task_id": "minimum-amount-of-time-to-collect-garbage", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of strings garbage where garbage[i] represents the assortment of garbage at the i^th house. garbage[i] consists only of the characters 'M', 'P' and 'G' representing one unit of metal, paper and glass garbage respectively. Picking up one unit of any type of garbage takes 1 minute.\n\nYou are also given a 0-indexed integer array travel where travel[i] is the number of minutes needed to go from house i to house i + 1.\n\nThere are three garbage trucks in the city, each responsible for picking up one type of garbage. Each garbage truck starts at house 0 and must visit each house in order; however, they do not need to visit every house.\n\nOnly one garbage truck may be used at any given moment. While one truck is driving or picking up garbage, the other two trucks cannot do anything.\n\nReturn the minimum number of minutes needed to pick up all the garbage.\n\nExample 1:\n\nInput: garbage = [\"G\",\"P\",\"GP\",\"GG\"], travel = [2,4,3]\nOutput: 21\nExplanation:\nThe paper garbage truck:\n1. Travels from house 0 to house 1\n2. Collects the paper garbage at house 1\n3. Travels from house 1 to house 2\n4. Collects the paper garbage at house 2\nAltogether, it takes 8 minutes to pick up all the paper garbage.\nThe glass garbage truck:\n1. Collects the glass garbage at house 0\n2. Travels from house 0 to house 1\n3. Travels from house 1 to house 2\n4. Collects the glass garbage at house 2\n5. Travels from house 2 to house 3\n6. Collects the glass garbage at house 3\nAltogether, it takes 13 minutes to pick up all the glass garbage.\nSince there is no metal garbage, we do not need to consider the metal garbage truck.\nTherefore, it takes a total of 8 + 13 = 21 minutes to collect all the garbage.\n\nExample 2:\n\nInput: garbage = [\"MMM\",\"PGM\",\"GP\"], travel = [3,10]\nOutput: 37\nExplanation:\nThe metal garbage truck takes 7 minutes to pick up all the metal garbage.\nThe paper garbage truck takes 15 minutes to pick up all the paper garbage.\nThe glass garbage truck takes 15 minutes to pick up all the glass garbage.\nIt takes a total of 7 + 15 + 15 = 37 minutes to collect all the garbage.\n\nConstraints:\n\n- 2 <= garbage.length <= 10^5\n- garbage[i] consists of only the letters 'M', 'P', and 'G'.\n- 1 <= garbage[i].length <= 10\n- travel.length == garbage.length - 1\n- 1 <= travel[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(garbage = ['M', 'P', 'G', 'M', 'P', 'G'],travel = [1, 2, 3, 4, 5]) == 37\n    assert candidate(garbage = ['P', 'G', 'M', 'P'],travel = [1, 1, 1]) == 10\n    assert candidate(garbage = ['GGG', 'PPP', 'MMM', 'GGG', 'PPP', 'MMM'],travel = [10, 10, 10, 10, 10]) == 138\n    assert candidate(garbage = ['G', 'P', 'M'],travel = [1, 1]) == 6\n    assert candidate(garbage = ['M', 'P', 'G'],travel = [1, 1]) == 6\n    assert candidate(garbage = ['GGGG', 'MM', 'PP', 'GG'],travel = [5, 5, 5]) == 40\n    assert candidate(garbage = ['GGP', 'GGP', 'GGP', 'GGP'],travel = [2, 2, 2]) == 24\n    assert candidate(garbage = ['M', 'M', 'M', 'M', 'M'],travel = [1, 1, 1, 1]) == 9\n    assert candidate(garbage = ['G', 'P', 'GP', 'GG'],travel = [2, 4, 3]) == 21\n    assert candidate(garbage = ['MMM', 'PGM', 'GP'],travel = [3, 10]) == 37\n    assert candidate(garbage = ['GMP', 'GMP', 'GMP'],travel = [10, 10]) == 69\n    assert candidate(garbage = ['MG', 'GP', 'PM', 'MG'],travel = [3, 4, 2]) == 33\n    assert candidate(garbage = ['MG', 'GP', 'MM', 'PG', 'GG'],travel = [2, 3, 1, 5]) == 32\n    assert candidate(garbage = ['MGP', 'MGP', 'MGP', 'MGP'],travel = [5, 5, 5]) == 57\n    assert candidate(garbage = ['GGG', 'MMM', 'PPP'],travel = [5, 5]) == 24\n    assert candidate(garbage = ['GP', 'GP', 'GP', 'GP'],travel = [1, 1, 1]) == 14\n    assert candidate(garbage = ['GP', 'MM', 'GG', 'PP', 'GG'],travel = [5, 2, 4, 3]) == 40\n    assert candidate(garbage = ['P', 'G', 'M'],travel = [1, 2]) == 7\n    assert candidate(garbage = ['G', 'P', 'M', 'GP', 'MG', 'PG', 'GMP', 'MGP', 'PMG', 'G'],travel = [2, 3, 1, 5, 4, 2, 3, 1, 4]) == 86\n    assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [2, 2, 2, 2, 2, 2, 2, 2]) == 51\n    assert candidate(garbage = ['G', 'P', 'M', 'GP', 'GM', 'MP', 'PGM', 'MGP', 'GMP', 'PGMG', 'GMPG', 'MPGM'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 228\n    assert candidate(garbage = ['MPG', 'G', 'M', 'P', 'G', 'M', 'P', 'G'],travel = [10, 20, 30, 40, 50, 60, 70]) == 650\n    assert candidate(garbage = ['GGG', 'PPP', 'MMM', 'GPM', 'GPM', 'GPM', 'GPM'],travel = [2, 2, 2, 2, 2, 2]) == 57\n    assert candidate(garbage = ['GGP', 'PGM', 'MG', 'PG', 'GM', 'MP', 'GG', 'PP', 'MM'],travel = [3, 3, 3, 3, 3, 3, 3, 3]) == 83\n    assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [1, 2, 1, 2, 1, 2, 1, 2]) == 40\n    assert candidate(garbage = ['GGGPPPMMM', 'GGGPPPMMM', 'GGGPPPMMM', 'GGGPPPMMM'],travel = [10, 10, 10]) == 126\n    assert candidate(garbage = ['M', 'G', 'P', 'MG', 'PG', 'GM', 'GMP', 'P', 'M'],travel = [2, 3, 1, 4, 2, 3, 1, 2]) == 63\n    assert candidate(garbage = ['G', 'M', 'P', 'G', 'M', 'P', 'G', 'M', 'P', 'G', 'M', 'P', 'G', 'M', 'P'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 289\n    assert candidate(garbage = ['M', 'P', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 146\n    assert candidate(garbage = ['GGG', 'PPP', 'MMM', 'GGG', 'PPP', 'MMM', 'GGG', 'PPP', 'MMM'],travel = [10, 20, 30, 10, 20, 30, 10, 20]) == 427\n    assert candidate(garbage = ['MP', 'GP', 'MG', 'PG', 'GM', 'PM', 'MG', 'PG', 'GM', 'PM'],travel = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 150\n    assert candidate(garbage = ['MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP'],travel = [2, 2, 2, 2, 2, 2, 2]) == 66\n    assert candidate(garbage = ['MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 39\n    assert candidate(garbage = ['GMPGMP', 'PMPMPM', 'MGMGMG', 'PGPGPG', 'GMPGMP', 'PMPMPM', 'MGMGMG', 'PGPGPG'],travel = [15, 15, 15, 15, 15, 15, 15]) == 348\n    assert candidate(garbage = ['G', 'M', 'P', 'G', 'M', 'P', 'G', 'M', 'P'],travel = [1, 2, 3, 4, 5, 6, 7, 8]) == 94\n    assert candidate(garbage = ['PG', 'G', 'P', 'G', 'P', 'G', 'P', 'G', 'P', 'G', 'P'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 112\n    assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 66\n    assert candidate(garbage = ['GMM', 'GGP', 'PPP', 'MMM', 'GGG', 'PPP', 'MMM'],travel = [7, 8, 9, 10, 11, 12]) == 157\n    assert candidate(garbage = ['GMM', 'GGP', 'PPP', 'MMM', 'GGG', 'PPP', 'MMM', 'GPP', 'MG', 'PGM', 'PG', 'GM', 'MP', 'PGM', 'GMP'],travel = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 608\n    assert candidate(garbage = ['GGGG', 'PPPP', 'MMMM', 'PPPP', 'GGGG', 'MMMM'],travel = [3, 4, 5, 6, 7]) == 79\n    assert candidate(garbage = ['G', 'P', 'M', 'GP', 'MG', 'PG', 'GMP', 'MGP', 'PMG', 'G', 'P', 'M', 'GP', 'MG', 'PG', 'GMP', 'MGP', 'PMG', 'G'],travel = [2, 3, 1, 5, 4, 2, 3, 1, 4, 2, 3, 1, 5, 4, 2, 3, 1, 4]) == 179\n    assert candidate(garbage = ['GP', 'MG', 'PM', 'MG', 'PM', 'MG', 'PM', 'MG', 'PM', 'MG'],travel = [5, 10, 5, 10, 5, 10, 5, 10, 5]) == 210\n    assert candidate(garbage = ['P', 'M', 'G', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 130\n    assert candidate(garbage = ['GMP', 'P', 'G', 'M', 'P', 'G', 'M', 'P', 'G', 'M'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 121\n    assert candidate(garbage = ['MPG', 'PGM', 'GMP', 'MGP', 'GPM', 'PGM', 'GMP', 'MGP', 'GPM', 'PGM'],travel = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 705\n    assert candidate(garbage = ['G', 'M', 'P', 'G', 'M', 'P', 'G', 'M', 'P', 'G'],travel = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 130\n    assert candidate(garbage = ['MGP', 'G', 'P', 'M', 'GP', 'MG', 'PG', 'GM', 'PM'],travel = [10, 5, 7, 6, 8, 9, 2, 3]) == 163\n    assert candidate(garbage = ['MMM', 'GGG', 'PPP', 'MMM', 'GGG', 'PPP', 'MMM'],travel = [5, 5, 5, 5, 5, 5]) == 96\n    assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 42\n    assert candidate(garbage = ['GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 513\n    assert candidate(garbage = ['MMG', 'PG', 'MM', 'GGG', 'PP', 'G'],travel = [3, 5, 2, 6, 4]) == 57\n    assert candidate(garbage = ['GGGG', 'PPPP', 'MMMM', 'GGGG', 'PPPP', 'MMMM'],travel = [1, 2, 3, 4, 5]) == 55\n    assert candidate(garbage = ['G', 'M', 'P', 'GM', 'PG', 'MG', 'GPM', 'PMG', 'MPG', 'GMP'],travel = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 183\n    assert candidate(garbage = ['MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 165\n    assert candidate(garbage = ['MGP', 'GP', 'MGG', 'PGG', 'MMM', 'GGP', 'PGM'],travel = [3, 5, 2, 4, 6, 7]) == 101\n    assert candidate(garbage = ['MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP'],travel = [10, 10, 10, 10, 10, 10, 10, 10, 10]) == 300\n    assert candidate(garbage = ['MMMGGGPPP', 'MMMGGGPPP', 'MMMGGGPPP', 'MMMGGGPPP'],travel = [15, 15, 15]) == 171\n    assert candidate(garbage = ['MGPG', 'GPMP', 'PGMG', 'P', 'M', 'G', 'MGP', 'P', 'G', 'MP'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 148\n    assert candidate(garbage = ['MPG', 'G', 'P', 'M', 'PG', 'GM', 'PGM'],travel = [7, 3, 8, 2, 5, 6]) == 106\n    assert candidate(garbage = ['MMM', 'MMM', 'MMM', 'MMM', 'MMM'],travel = [10, 10, 10, 10]) == 55\n    assert candidate(garbage = ['G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 21\n    assert candidate(garbage = ['GMP', 'P', 'M', 'G', 'MPG', 'MG', 'PG', 'GMP', 'GMP', 'P'],travel = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 145\n    assert candidate(garbage = ['GP', 'GP', 'GP', 'GP', 'GP', 'GP', 'GP'],travel = [1, 1, 1, 1, 1, 1]) == 26\n    assert candidate(garbage = ['MMM', 'PPP', 'GGG', 'MMM', 'PPP', 'GGG', 'MMM', 'PPP', 'GGG'],travel = [10, 10, 10, 10, 10, 10, 10, 10]) == 237\n    assert candidate(garbage = ['MG', 'PGP', 'GGM', 'PPG', 'MMG'],travel = [3, 5, 2, 7]) == 58\n    assert candidate(garbage = ['MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM', 'MMM'],travel = [10, 10, 10, 10, 10, 10, 10, 10]) == 107\n    assert candidate(garbage = ['GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP', 'GMP'],travel = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 165\n    assert candidate(garbage = ['G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n    assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [1, 2, 3, 4, 5, 6, 7, 8]) == 94\n    assert candidate(garbage = ['MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG'],travel = [5, 5, 5, 5, 5, 5, 5]) == 129\n    assert candidate(garbage = ['MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG', 'MPG'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 57\n    assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 427\n    assert candidate(garbage = ['MMMM', 'PPPP', 'GGGG', 'MMMM', 'PPPP', 'GGGG'],travel = [10, 10, 10, 10, 10]) == 144\n    assert candidate(garbage = ['MMM', 'PPP', 'GGG', 'MMM', 'PPP', 'GGG', 'MMM'],travel = [10, 10, 10, 10, 10, 10]) == 171\n    assert candidate(garbage = ['MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP', 'MGP'],travel = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 69\n    assert candidate(garbage = ['MMM', 'GGG', 'PPP', 'MGP', 'GMP', 'PMM', 'GGP', 'PPG', 'MPM', 'MGP'],travel = [10, 20, 15, 10, 5, 12, 8, 18, 7]) == 345\n    assert candidate(garbage = ['M', 'P', 'G', 'MPG', 'GMP', 'PGM'],travel = [1, 3, 2, 4, 5]) == 57\n    assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 115\n    assert candidate(garbage = ['MGP', 'MG', 'P', 'G', 'MP', 'GM', 'PG', 'MG', 'PGM'],travel = [5, 5, 5, 5, 5, 5, 5, 5]) == 138\n    assert candidate(garbage = ['G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M', 'G', 'P', 'M'],travel = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 289\n    assert candidate(garbage = ['G', 'P', 'M', 'PG', 'GM', 'MP', 'PGM'],travel = [1, 2, 3, 4, 5, 6]) == 75\n", "comparison": "exact"}, "public_tests": ["[\"G\",\"P\",\"GP\",\"GG\"]\n[2,4,3]", "[\"MMM\",\"PGM\",\"GP\"]\n[3,10]"], "hints": ["Where can we save time? By not visiting all the houses.", "For each type of garbage, find the house with the highest index that has at least 1 unit of this type of garbage."], "metadata": {"canonical_parameter_names": ["garbage", "travel"], "leetcode_dataset_entry_point": "Solution().garbageCollection", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:03+00:00", "tests_total": 107, "tests_dropped": 26, "flags": [], "topic_tags": ["array", "string", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def garbageCollection(self, garbage: list[str], travel: list[int]) -> int:", "container": "Solution", "callable": "garbageCollection", "parameters": [{"name": "garbage", "type": "list[str]"}, {"name": "travel", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2392, "task_id": "build-a-matrix-with-conditions", "difficulty": "Hard", "problem_description": "You are given a positive integer k. You are also given:\n\n- a 2D integer array rowConditions of size n where rowConditions[i] = [above_i, below_i], and\n- a 2D integer array colConditions of size m where colConditions[i] = [left_i, right_i].\n\nThe two arrays contain integers from 1 to k.\n\nYou have to build a k x k matrix that contains each of the numbers from 1 to k exactly once. The remaining cells should have the value 0.\n\nThe matrix should also satisfy the following conditions:\n\n- The number above_i should appear in a row that is strictly above the row at which the number below_i appears for all i from 0 to n - 1.\n- The number left_i should appear in a column that is strictly left of the column at which the number right_i appears for all i from 0 to m - 1.\n\nReturn any matrix that satisfies the conditions. If no answer exists, return an empty matrix.\n\nExample 1:\n\nInput: k = 3, rowConditions = [[1,2],[3,2]], colConditions = [[2,1],[3,2]]\nOutput: [[3,0,0],[0,0,1],[0,2,0]]\nExplanation: The diagram above shows a valid example of a matrix that satisfies all the conditions.\nThe row conditions are the following:\n- Number 1 is in row 1, and number 2 is in row 2, so 1 is above 2 in the matrix.\n- Number 3 is in row 0, and number 2 is in row 2, so 3 is above 2 in the matrix.\nThe column conditions are the following:\n- Number 2 is in column 1, and number 1 is in column 2, so 2 is left of 1 in the matrix.\n- Number 3 is in column 0, and number 2 is in column 1, so 3 is left of 2 in the matrix.\nNote that there may be multiple correct answers.\n\nExample 2:\n\nInput: k = 3, rowConditions = [[1,2],[2,3],[3,1],[2,3]], colConditions = [[2,1]]\nOutput: []\nExplanation: From the first two conditions, 3 has to be below 1 but the third conditions needs 3 to be above 1 to be satisfied.\nNo matrix can satisfy all the conditions, so we return the empty matrix.\n\nConstraints:\n\n- 2 <= k <= 400\n- 1 <= rowConditions.length, colConditions.length <= 10^4\n- rowConditions[i].length == colConditions[i].length == 2\n- 1 <= above_i, below_i, left_i, right_i <= k\n- above_i != below_i\n- left_i != right_i\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(k = 5,rowConditions = [[1, 5], [2, 5], [3, 5], [4, 5]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5]]) == [[1, 0, 0, 0, 0], [0, 2, 0, 0, 0], [0, 0, 3, 0, 0], [0, 0, 0, 4, 0], [0, 0, 0, 0, 5]]\n    assert candidate(k = 3,rowConditions = [[1, 2], [3, 2]],colConditions = [[2, 1], [3, 2]]) == [[0, 0, 1], [3, 0, 0], [0, 2, 0]]\n    assert candidate(k = 4,rowConditions = [[4, 3], [3, 2], [2, 1]],colConditions = [[4, 3], [3, 2], [2, 1]]) == [[4, 0, 0, 0], [0, 3, 0, 0], [0, 0, 2, 0], [0, 0, 0, 1]]\n    assert candidate(k = 4,rowConditions = [[1, 2], [2, 3], [3, 4]],colConditions = [[1, 2], [2, 3], [3, 4]]) == [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]\n    assert candidate(k = 6,rowConditions = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6]],colConditions = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6]]) == [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 6]]\n    assert candidate(k = 4,rowConditions = [[1, 2], [3, 4]],colConditions = [[1, 3], [2, 4]]) == [[1, 0, 0, 0], [0, 0, 3, 0], [0, 2, 0, 0], [0, 0, 0, 4]]\n    assert candidate(k = 3,rowConditions = [[1, 2], [2, 3], [3, 1], [2, 3]],colConditions = [[2, 1]]) == []\n    assert candidate(k = 6,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == []\n    assert candidate(k = 15,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [1, 15]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [1, 15]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]]\n    assert candidate(k = 7,rowConditions = [[7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == [[0, 0, 0, 0, 0, 0, 7], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0]]\n    assert candidate(k = 15,rowConditions = [[1, 15], [2, 14], [3, 13], [4, 12], [5, 11], [6, 10], [7, 9]],colConditions = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9]]\n    assert candidate(k = 8,rowConditions = [[8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [[0, 0, 0, 0, 0, 0, 0, 8], [0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0]]\n    assert candidate(k = 15,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],colConditions = [[1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14], [8, 15]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]]\n    assert candidate(k = 15,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [1, 15]],colConditions = [[1, 15], [2, 15], [3, 15], [4, 15], [5, 15], [6, 15], [7, 15], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15], [1, 15]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]]\n    assert candidate(k = 10,rowConditions = [[1, 5], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10]],colConditions = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 9], [0, 0, 10, 0, 0, 0, 0, 0, 0, 0]]\n    assert candidate(k = 9,rowConditions = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 6]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0]]\n    assert candidate(k = 6,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6], [2, 5], [3, 6], [4, 6]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6], [2, 5], [3, 6], [4, 6]]) == [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 6]]\n    assert candidate(k = 7,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],colConditions = [[1, 7], [2, 6], [3, 5], [4, 5], [5, 6], [6, 7]]) == [[1, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 7]]\n    assert candidate(k = 8,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],colConditions = [[1, 8], [2, 7], [3, 6], [4, 5]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 5], [0, 0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 8, 0, 0, 0]]\n    assert candidate(k = 10,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],colConditions = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 6], [0, 0, 0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 10, 0, 0, 0, 0]]\n    assert candidate(k = 7,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],colConditions = [[1, 4], [4, 7], [2, 5], [5, 7], [3, 6], [6, 7]]) == [[1, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 7]]\n    assert candidate(k = 8,rowConditions = [[1, 8], [2, 7], [3, 6], [4, 5], [5, 6], [6, 7], [7, 8]],colConditions = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8]]\n    assert candidate(k = 9,rowConditions = [[1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],colConditions = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9]]\n    assert candidate(k = 10,rowConditions = [[1, 3], [2, 4], [5, 8], [6, 9], [3, 7], [4, 10]],colConditions = [[1, 5], [2, 6], [3, 9], [4, 10], [7, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 8], [0, 0, 0, 0, 0, 0, 0, 9, 0, 0], [0, 0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 10, 0]]\n    assert candidate(k = 6,rowConditions = [[1, 3], [2, 3], [4, 5], [4, 6], [5, 6]],colConditions = [[1, 4], [2, 5], [3, 6]]) == [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 6]]\n    assert candidate(k = 12,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],colConditions = [[1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12]]\n    assert candidate(k = 13,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]],colConditions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 1]]) == [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2], [3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0], [0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0], [0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0], [0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0], [0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0]]\n    assert candidate(k = 12,rowConditions = [[1, 6], [6, 11], [2, 7], [7, 12], [3, 8], [4, 9], [5, 10]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12]]\n    assert candidate(k = 8,rowConditions = [[1, 3], [3, 5], [5, 7], [2, 4], [4, 6], [6, 8]],colConditions = [[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0], [0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 4, 0, 0], [0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 7, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8]]\n    assert candidate(k = 6,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 6]]\n    assert candidate(k = 12,rowConditions = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11]],colConditions = [[1, 4], [4, 8], [2, 5], [5, 9], [3, 6], [6, 10], [7, 11], [8, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0], [0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0], [0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0]]\n    assert candidate(k = 11,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11]]\n    assert candidate(k = 10,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],colConditions = [[1, 3], [3, 5], [5, 7], [7, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 3, 0, 0, 0], [0, 0, 4, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 8, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 9], [0, 0, 0, 0, 0, 10, 0, 0, 0, 0]]\n    assert candidate(k = 7,rowConditions = [[1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7]],colConditions = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7]]) == [[1, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 7]]\n    assert candidate(k = 9,rowConditions = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]],colConditions = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9]]\n    assert candidate(k = 12,rowConditions = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12]],colConditions = [[1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12]]\n    assert candidate(k = 10,rowConditions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],colConditions = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]\n    assert candidate(k = 8,rowConditions = [[1, 4], [4, 7], [7, 8], [2, 5], [5, 8], [3, 6], [6, 8]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8]]\n    assert candidate(k = 6,rowConditions = [[1, 4], [2, 4], [3, 4], [5, 6]],colConditions = [[1, 3], [2, 3], [5, 6]]) == [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 3, 0], [0, 0, 0, 5, 0, 0], [0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 0, 6]]\n    assert candidate(k = 9,rowConditions = [[1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 0, 8], [0, 9, 0, 0, 0, 0, 0, 0, 0]]\n    assert candidate(k = 7,rowConditions = [[1, 7], [2, 6], [3, 5], [4, 5], [5, 6], [6, 7]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == [[1, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 7]]\n    assert candidate(k = 15,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]]\n    assert candidate(k = 11,rowConditions = [[1, 11], [2, 10], [3, 9], [4, 8], [5, 7]],colConditions = [[1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0]]\n    assert candidate(k = 6,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]],colConditions = [[1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1]]) == []\n    assert candidate(k = 6,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6]]) == [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 6]]\n    assert candidate(k = 9,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [1, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9]]\n    assert candidate(k = 8,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],colConditions = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8]]\n    assert candidate(k = 10,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],colConditions = [[1, 3], [3, 5], [5, 7], [7, 9], [2, 4], [4, 6], [6, 8], [8, 10]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]\n    assert candidate(k = 20,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],colConditions = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19], [11, 20]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20]]\n    assert candidate(k = 7,rowConditions = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 6], [3, 7], [4, 7], [5, 7]],colConditions = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 6], [3, 7], [4, 7], [5, 7]]) == [[1, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 7]]\n    assert candidate(k = 10,rowConditions = [[1, 3], [3, 5], [5, 7], [7, 9], [2, 4], [4, 6], [6, 8], [8, 10]],colConditions = [[1, 4], [4, 7], [7, 10], [2, 5], [5, 8], [3, 6], [6, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]\n    assert candidate(k = 7,rowConditions = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == [[1, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 7]]\n    assert candidate(k = 12,rowConditions = [[1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 12], [7, 12], [8, 12], [9, 12], [10, 12], [11, 12]],colConditions = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0], [0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11], [0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0]]\n    assert candidate(k = 7,rowConditions = [[1, 2], [2, 3], [4, 5], [5, 6], [6, 7]],colConditions = [[1, 2], [3, 4], [5, 6], [6, 7]]) == [[1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0], [0, 0, 0, 2, 0, 0, 0], [0, 0, 5, 0, 0, 0, 0], [0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 7]]\n    assert candidate(k = 8,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],colConditions = [[1, 3], [3, 5], [5, 7], [2, 4], [4, 6], [6, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8]]\n    assert candidate(k = 12,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12]]\n    assert candidate(k = 5,rowConditions = [[1, 5], [2, 5], [3, 5], [4, 5]],colConditions = [[1, 3], [2, 3], [3, 4], [4, 5]]) == [[1, 0, 0, 0, 0], [0, 2, 0, 0, 0], [0, 0, 3, 0, 0], [0, 0, 0, 4, 0], [0, 0, 0, 0, 5]]\n    assert candidate(k = 6,rowConditions = [[1, 4], [2, 5], [3, 6], [4, 6]],colConditions = [[1, 3], [2, 4], [3, 5], [4, 6]]) == [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 6]]\n    assert candidate(k = 9,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9]]\n    assert candidate(k = 8,rowConditions = [[1, 8], [2, 7], [3, 6], [4, 5]],colConditions = [[1, 8], [2, 7], [3, 6], [4, 5]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 8, 0, 0, 0], [0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 0, 5]]\n    assert candidate(k = 7,rowConditions = [[1, 3], [2, 5], [3, 6], [4, 7], [5, 7], [6, 7]],colConditions = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 7], [6, 7]]) == [[1, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 7]]\n    assert candidate(k = 12,rowConditions = [[1, 6], [6, 11], [11, 3], [3, 9], [9, 5], [5, 2], [2, 8], [8, 4], [4, 12], [12, 7], [7, 10]],colConditions = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0], [0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0], [0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12], [0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0]]\n    assert candidate(k = 15,rowConditions = [[1, 5], [2, 5], [3, 5], [4, 5], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],colConditions = [[1, 3], [2, 4], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]]\n    assert candidate(k = 6,rowConditions = [[1, 6], [2, 5], [3, 4], [4, 6], [5, 6]],colConditions = [[1, 5], [2, 6], [3, 5], [4, 6]]) == [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 0, 6]]\n    assert candidate(k = 12,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],colConditions = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12]]\n    assert candidate(k = 8,rowConditions = [[1, 3], [3, 5], [2, 4], [4, 6], [5, 7], [6, 8]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8]]\n    assert candidate(k = 20,rowConditions = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],colConditions = [[1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0]]\n    assert candidate(k = 8,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],colConditions = [[8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1]]) == [[0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 3, 0, 0], [0, 0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 6, 0, 0, 0, 0, 0], [0, 7, 0, 0, 0, 0, 0, 0], [8, 0, 0, 0, 0, 0, 0, 0]]\n    assert candidate(k = 15,rowConditions = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]]\n    assert candidate(k = 10,rowConditions = [[1, 3], [2, 3], [3, 5], [3, 6], [4, 7], [7, 8], [9, 10]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0]]\n    assert candidate(k = 20,rowConditions = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],colConditions = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [11, 19], [12, 18], [13, 17], [14, 16], [15, 20]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]\n    assert candidate(k = 10,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]\n    assert candidate(k = 10,rowConditions = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],colConditions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 3, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 0, 0, 0], [0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 6, 0, 0], [0, 0, 0, 7, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 9, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]\n    assert candidate(k = 12,rowConditions = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12]]\n    assert candidate(k = 9,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],colConditions = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 7], [6, 8], [7, 9], [8, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9]]\n    assert candidate(k = 6,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],colConditions = [[1, 3], [3, 5], [5, 6]]) == [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 0, 3, 0, 0], [0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 6]]\n    assert candidate(k = 10,rowConditions = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],colConditions = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 10, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 9, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 6]]\n    assert candidate(k = 8,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],colConditions = [[1, 3], [3, 5], [5, 7]]) == [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 3, 0, 0], [0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 5, 0], [0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 7], [0, 0, 0, 0, 8, 0, 0, 0]]\n    assert candidate(k = 9,rowConditions = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 9], [6, 9], [7, 9], [8, 9]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9]]\n    assert candidate(k = 12,rowConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],colConditions = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0], [0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0], [0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11], [0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0]]\n    assert candidate(k = 6,rowConditions = [[1, 3], [2, 3], [1, 4], [2, 4], [1, 5], [3, 5], [1, 6], [2, 6]],colConditions = [[1, 2], [1, 3], [2, 4], [3, 4], [1, 5], [3, 5]]) == [[1, 0, 0, 0, 0, 0], [0, 0, 2, 0, 0, 0], [0, 0, 0, 3, 0, 0], [0, 0, 0, 0, 4, 0], [0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5]]\n    assert candidate(k = 15,rowConditions = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14]],colConditions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15]]\n    assert candidate(k = 10,rowConditions = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],colConditions = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]]\n", "comparison": "exact"}, "public_tests": ["3\n[[1,2],[3,2]]\n[[2,1],[3,2]]", "3\n[[1,2],[2,3],[3,1],[2,3]]\n[[2,1]]"], "hints": ["Can you think of the problem in terms of graphs?", "What algorithm allows you to find the order of nodes in a graph?"], "metadata": {"canonical_parameter_names": ["k", "rowConditions", "colConditions"], "leetcode_dataset_entry_point": "Solution().buildMatrix", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:06+00:00", "tests_total": 85, "tests_dropped": 2, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "graph", "topological-sort", "matrix", "directed-acyclic-graph"]}, "language": "python", "interface": {"raw_signature": "def buildMatrix(self, k: int, rowConditions: list[list[int]], colConditions: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "buildMatrix", "parameters": [{"name": "k", "type": "int"}, {"name": "rowConditions", "type": "list[list[int]]"}, {"name": "colConditions", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2395, "task_id": "find-subarrays-with-equal-sum", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums, determine whether there exist two subarrays of length 2 with equal sum. Note that the two subarrays must begin at different indices.\n\nReturn true if these subarrays exist, and false otherwise.\n\nA subarray is a contiguous non-empty sequence of elements within an array.\n\nExample 1:\n\nInput: nums = [4,2,4]\nOutput: true\nExplanation: The subarrays with elements [4,2] and [2,4] have the same sum of 6.\n\nExample 2:\n\nInput: nums = [1,2,3,4,5]\nOutput: false\nExplanation: No two subarrays of size 2 have the same sum.\n\nExample 3:\n\nInput: nums = [0,0,0]\nOutput: true\nExplanation: The subarrays [nums[0],nums[1]] and [nums[1],nums[2]] have the same sum of 0.\nNote that even though the subarrays have the same content, the two subarrays are considered different because they are in different positions in the original array.\n\nConstraints:\n\n- 2 <= nums.length <= 1000\n- -10^9 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [-1, 0, 1, -1, 0]) == True\n    assert candidate(nums = [1, 1, 1, 1]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n    assert candidate(nums = [5, -1, 5, -1]) == True\n    assert candidate(nums = [1, 2, 3, 3, 2, 1]) == True\n    assert candidate(nums = [-1, 0, 1, 0, -1]) == True\n    assert candidate(nums = [1000000000, 1000000000]) == False\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == True\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == False\n    assert candidate(nums = [-1, -2, -3, -4, -5]) == False\n    assert candidate(nums = [1, 2, 3, 4, 5]) == False\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == True\n    assert candidate(nums = [0, 0, 0]) == True\n    assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == True\n    assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n    assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1]) == True\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == False\n    assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == True\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n    assert candidate(nums = [1, 2, 1, 2]) == True\n    assert candidate(nums = [1, 1, 2, 3, 3, 4]) == False\n    assert candidate(nums = [-1, 0, 1, -1, 0, 1]) == True\n    assert candidate(nums = [-1000000000, 1000000000, -1000000000, 1000000000]) == True\n    assert candidate(nums = [4, 2, 4]) == True\n    assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == True\n    assert candidate(nums = [-1, -2, -3, -1, -2, -3, -1, -2, -3]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == True\n    assert candidate(nums = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30]) == True\n    assert candidate(nums = [7, 3, 5, 7, 9, 5, 3, 1, 5, 7, 9, 3, 5, 7, 1]) == True\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200]) == True\n    assert candidate(nums = [-1, -2, -3, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == True\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == True\n    assert candidate(nums = [500000000, -500000000, 500000000, -500000000, 500000000, -500000000]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == True\n    assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000, -250000000, 125000000, -125000000]) == True\n    assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90, 110]) == True\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == False\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == False\n    assert candidate(nums = [999999999, -999999999, 999999999, -999999999, 999999999, -999999999, 999999999, -999999999]) == True\n    assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == True\n    assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == True\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == True\n    assert candidate(nums = [5, 5, 10, 15, 5, 5]) == True\n    assert candidate(nums = [-1, -2, -3, -4, -5, -1, -2, -3, -4, -5]) == True\n    assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 10, 11]) == True\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9]) == True\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == False\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, 4, 3, 2, 1, 0]) == True\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == False\n    assert candidate(nums = [5, -5, 5, -5, 5, -5]) == True\n    assert candidate(nums = [5, 3, 5, 3, 5, 3]) == True\n    assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == True\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == False\n    assert candidate(nums = [0, 1, 2, 3, 4, 3, 2, 1, 0]) == True\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == True\n    assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1]) == True\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == True\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == False\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3]) == True\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == True\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n    assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n    assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -10]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == False\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == True\n    assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1]) == True\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == True\n    assert candidate(nums = [999999999, 999999999, -999999999, -999999999, 1, -1, 1, -1]) == True\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == True\n    assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == False\n    assert candidate(nums = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5]) == True\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3]) == True\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == True\n    assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90, 110, 100, 120, 110, 130, 120, 140, 130, 150, 140, 160]) == True\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -1, -2, -3, -4, -5]) == True\n    assert candidate(nums = [5, -5, 5, -5, 5]) == True\n    assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == True\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5]) == True\n    assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == False\n    assert candidate(nums = [-1, 2, -1, 2, -1]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == False\n    assert candidate(nums = [5, 15, -10, 5, 10, 0, -5, 15, 5]) == True\n    assert candidate(nums = [100, -100, 100, -100, 100, -100]) == True\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -1, -2]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == True\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == False\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n    assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 600]) == True\n    assert candidate(nums = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == True\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == True\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == True\n    assert candidate(nums = [1, 3, 2, 3, 4, 5, 6, 7, 8, 9, 1, 3, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == True\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n    assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == True\n    assert candidate(nums = [100, 200, 300, 100, 200, 300, 100, 200, 300]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n    assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == True\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3]) == True\n    assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100]) == True\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == True\n", "comparison": "exact"}, "public_tests": ["[4,2,4]", "[1,2,3,4,5]", "[0,0,0]"], "hints": ["Use a counter to keep track of the subarray sums.", "Use a hashset to check if any two sums are equal."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findSubarrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:10+00:00", "tests_total": 119, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table"]}, "language": "python", "interface": {"raw_signature": "def findSubarrays(self, nums: list[int]) -> bool:", "container": "Solution", "callable": "findSubarrays", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2396, "task_id": "strictly-palindromic-number", "difficulty": "Medium", "problem_description": "An integer n is strictly palindromic if, for every base b between 2 and n - 2 (inclusive), the string representation of the integer n in base b is palindromic.\n\nGiven an integer n, return true if n is strictly palindromic and false otherwise.\n\nA string is palindromic if it reads the same forward and backward.\n\nExample 1:\n\nInput: n = 9\nOutput: false\nExplanation: In base 2: 9 = 1001 (base 2), which is palindromic.\nIn base 3: 9 = 100 (base 3), which is not palindromic.\nTherefore, 9 is not strictly palindromic so we return false.\nNote that in bases 4, 5, 6, and 7, n = 9 is also not palindromic.\n\nExample 2:\n\nInput: n = 4\nOutput: false\nExplanation: We only consider base 2: 4 = 100 (base 2), which is not palindromic.\nTherefore, we return false.\n\nConstraints:\n\n- 4 <= n <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 15) == False\n    assert candidate(n = 4) == False\n    assert candidate(n = 9) == False\n    assert candidate(n = 6) == False\n    assert candidate(n = 20) == False\n    assert candidate(n = 100) == False\n    assert candidate(n = 10) == False\n    assert candidate(n = 5) == False\n    assert candidate(n = 99999) == False\n    assert candidate(n = 4096) == False\n    assert candidate(n = 21) == False\n    assert candidate(n = 50000) == False\n    assert candidate(n = 1000) == False\n    assert candidate(n = 50) == False\n    assert candidate(n = 10001) == False\n    assert candidate(n = 300) == False\n    assert candidate(n = 30) == False\n    assert candidate(n = 99) == False\n    assert candidate(n = 16) == False\n    assert candidate(n = 33) == False\n    assert candidate(n = 10000) == False\n    assert candidate(n = 17) == False\n    assert candidate(n = 1001) == False\n    assert candidate(n = 23) == False\n    assert candidate(n = 42) == False\n    assert candidate(n = 360) == False\n    assert candidate(n = 1024) == False\n    assert candidate(n = 101) == False\n    assert candidate(n = 100000) == False\n    assert candidate(n = 2048) == False\n    assert candidate(n = 255) == False\n    assert candidate(n = 999) == False\n    assert candidate(n = 75) == False\n    assert candidate(n = 256) == False\n    assert candidate(n = 32) == False\n    assert candidate(n = 5000) == False\n    assert candidate(n = 18) == False\n    assert candidate(n = 75000) == False\n    assert candidate(n = 9999) == False\n    assert candidate(n = 65535) == False\n    assert candidate(n = 88888) == False\n    assert candidate(n = 81) == False\n    assert candidate(n = 4321) == False\n    assert candidate(n = 150) == False\n    assert candidate(n = 200) == False\n    assert candidate(n = 400) == False\n    assert candidate(n = 31) == False\n    assert candidate(n = 1234) == False\n    assert candidate(n = 750) == False\n    assert candidate(n = 121) == False\n    assert candidate(n = 199) == False\n    assert candidate(n = 700) == False\n    assert candidate(n = 500) == False\n    assert candidate(n = 54321) == False\n    assert candidate(n = 25) == False\n    assert candidate(n = 25000) == False\n", "comparison": "exact"}, "public_tests": ["9", "4"], "hints": ["Consider the representation of the given number in the base n - 2.", "The number n in base (n - 2) is always 12, which is not palindromic."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().isStrictlyPalindromic", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:13+00:00", "tests_total": 57, "tests_dropped": 1, "flags": [], "topic_tags": ["math", "two-pointers", "brainteaser"]}, "language": "python", "interface": {"raw_signature": "def isStrictlyPalindromic(self, n: int) -> bool:", "container": "Solution", "callable": "isStrictlyPalindromic", "parameters": [{"name": "n", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2397, "task_id": "maximum-rows-covered-by-columns", "difficulty": "Medium", "problem_description": "You are given an m x n binary matrix matrix and an integer numSelect.\n\nYour goal is to select exactly numSelect distinct columns from matrix such that you cover as many rows as possible.\n\nA row is considered covered if all the 1's in that row are also part of a column that you have selected. If a row does not have any 1s, it is also considered covered.\n\nMore formally, let us consider selected = {c_1, c_2, ...., c_numSelect} as the set of columns selected by you. A row i is covered by selected if:\n\n- For each cell where matrix[i][j] == 1, the column j is in selected.\n- Or, no cell in row i has a value of 1.\n\nReturn the maximum number of rows that can be covered by a set of numSelect columns.\n\nExample 1:\n\nInput: matrix = [[0,0,0],[1,0,1],[0,1,1],[0,0,1]], numSelect = 2\nOutput: 3\nExplanation:\nOne possible way to cover 3 rows is shown in the diagram above.\nWe choose s = {0, 2}.\n- Row 0 is covered because it has no occurrences of 1.\n- Row 1 is covered because the columns with value 1, i.e. 0 and 2 are present in s.\n- Row 2 is not covered because matrix[2][1] == 1 but 1 is not present in s.\n- Row 3 is covered because matrix[2][2] == 1 and 2 is present in s.\nThus, we can cover three rows.\nNote that s = {1, 2} will also cover 3 rows, but it can be shown that no more than three rows can be covered.\n\nExample 2:\n\nInput: matrix = [[1],[0]], numSelect = 1\nOutput: 2\nExplanation:\nSelecting the only column will result in both rows being covered since the entire matrix is selected.\n\nConstraints:\n\n- m == matrix.length\n- n == matrix[i].length\n- 1 <= m, n <= 12\n- matrix[i][j] is either 0 or 1.\n- 1 <= numSelect <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(matrix = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],numSelect = 4) == 3\n    assert candidate(matrix = [[1, 1], [0, 0], [1, 0], [0, 1]],numSelect = 1) == 2\n    assert candidate(matrix = [[1, 1, 1], [0, 1, 1], [1, 0, 1]],numSelect = 1) == 0\n    assert candidate(matrix = [[0, 0], [0, 0]],numSelect = 1) == 2\n    assert candidate(matrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],numSelect = 4) == 4\n    assert candidate(matrix = [[0, 1, 0], [1, 0, 1], [0, 1, 0]],numSelect = 1) == 2\n    assert candidate(matrix = [[0, 0, 1, 1], [1, 0, 1, 0], [1, 1, 0, 0]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],numSelect = 1) == 0\n    assert candidate(matrix = [[1], [0]],numSelect = 1) == 2\n    assert candidate(matrix = [[1, 1, 0, 0], [0, 1, 1, 0], [1, 0, 1, 1], [0, 0, 0, 1]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]],numSelect = 2) == 2\n    assert candidate(matrix = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],numSelect = 4) == 4\n    assert candidate(matrix = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1]],numSelect = 2) == 1\n    assert candidate(matrix = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 0, 0, 0]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 1, 1], [1, 0, 1], [0, 0, 0], [1, 1, 1]],numSelect = 2) == 2\n    assert candidate(matrix = [[0, 0], [0, 0], [1, 1]],numSelect = 2) == 3\n    assert candidate(matrix = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [0, 1, 0, 1]],numSelect = 2) == 1\n    assert candidate(matrix = [[0, 0, 0], [1, 0, 1], [0, 1, 1], [0, 0, 1]],numSelect = 2) == 3\n    assert candidate(matrix = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1]],numSelect = 3) == 1\n    assert candidate(matrix = [[0, 1, 1, 0], [0, 1, 1, 0], [0, 1, 0, 1], [1, 0, 0, 0]],numSelect = 3) == 3\n    assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],numSelect = 1) == 3\n    assert candidate(matrix = [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 1, 1], [0, 0, 1, 0]],numSelect = 2) == 2\n    assert candidate(matrix = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 0, 1, 0], [0, 1, 0, 1]],numSelect = 2) == 1\n    assert candidate(matrix = [[1, 0, 0, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [0, 1, 0, 0, 1]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],numSelect = 2) == 0\n    assert candidate(matrix = [[1, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1]],numSelect = 4) == 2\n    assert candidate(matrix = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0]],numSelect = 8) == 7\n    assert candidate(matrix = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]],numSelect = 2) == 0\n    assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]],numSelect = 5) == 2\n    assert candidate(matrix = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1]],numSelect = 4) == 3\n    assert candidate(matrix = [[1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]],numSelect = 4) == 1\n    assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],numSelect = 5) == 2\n    assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [0, 0, 1, 1, 0], [1, 0, 0, 0, 1]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],numSelect = 5) == 2\n    assert candidate(matrix = [[1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0]],numSelect = 7) == 2\n    assert candidate(matrix = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]],numSelect = 5) == 3\n    assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]],numSelect = 4) == 3\n    assert candidate(matrix = [[1, 1, 0, 0, 1], [1, 0, 1, 0, 0], [1, 1, 0, 1, 0], [0, 0, 0, 0, 1], [1, 0, 1, 1, 1]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0]],numSelect = 4) == 4\n    assert candidate(matrix = [[0, 1, 1, 1, 0], [1, 1, 1, 0, 1], [1, 0, 1, 1, 0], [0, 0, 0, 0, 0], [1, 1, 0, 0, 1]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],numSelect = 5) == 3\n    assert candidate(matrix = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1]],numSelect = 4) == 4\n    assert candidate(matrix = [[1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 1]],numSelect = 5) == 2\n    assert candidate(matrix = [[1, 1, 0, 0, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 1], [1, 1, 0, 0, 1, 0]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 0, 1, 1, 1, 1, 0, 1], [0, 1, 0, 1, 0, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]],numSelect = 6) == 2\n    assert candidate(matrix = [[1, 1, 0, 0, 1], [1, 0, 1, 1, 0], [0, 1, 1, 0, 1], [1, 0, 1, 1, 0], [0, 0, 0, 1, 1]],numSelect = 3) == 2\n    assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 1, 1, 1]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1]],numSelect = 4) == 2\n    assert candidate(matrix = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]],numSelect = 4) == 2\n    assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 0, 0, 0, 0, 1, 1]],numSelect = 6) == 2\n    assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],numSelect = 6) == 2\n    assert candidate(matrix = [[1, 1, 0, 0, 1], [1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 0, 0, 0, 1]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1]],numSelect = 5) == 2\n    assert candidate(matrix = [[1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 0, 1, 0]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]],numSelect = 2) == 2\n    assert candidate(matrix = [[0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1]],numSelect = 4) == 2\n    assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 0], [1, 0, 0, 1, 1, 0, 0], [0, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0]],numSelect = 2) == 0\n    assert candidate(matrix = [[1, 1, 0, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]],numSelect = 3) == 1\n    assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],numSelect = 4) == 2\n    assert candidate(matrix = [[1, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1], [1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]],numSelect = 5) == 3\n    assert candidate(matrix = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]],numSelect = 6) == 6\n    assert candidate(matrix = [[1, 0, 0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 0, 0, 0, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0, 0, 1]],numSelect = 5) == 1\n    assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]],numSelect = 3) == 1\n    assert candidate(matrix = [[1, 0, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0], [1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0]],numSelect = 4) == 2\n    assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 1], [1, 1, 0, 0, 1]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]],numSelect = 5) == 3\n    assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]],numSelect = 3) == 1\n    assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [0, 1, 0, 1, 0, 1]],numSelect = 4) == 2\n    assert candidate(matrix = [[0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]],numSelect = 8) == 3\n    assert candidate(matrix = [[0, 1, 0, 0, 1, 0], [1, 0, 1, 1, 0, 1], [0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0], [0, 0, 1, 0, 1, 1]],numSelect = 4) == 2\n    assert candidate(matrix = [[1, 0, 0, 1, 0, 0, 1], [0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0], [1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0]],numSelect = 5) == 3\n    assert candidate(matrix = [[1, 1, 0, 1, 1, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 1, 0, 0]],numSelect = 4) == 1\n    assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0]],numSelect = 4) == 3\n    assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]],numSelect = 6) == 2\n    assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [0, 1, 0, 1, 1, 0], [0, 0, 1, 0, 1, 1], [1, 1, 0, 1, 0, 0]],numSelect = 4) == 2\n    assert candidate(matrix = [[0, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0], [0, 1, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 1], [0, 0, 1, 0, 0, 1, 0]],numSelect = 5) == 2\n    assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]],numSelect = 5) == 1\n    assert candidate(matrix = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]],numSelect = 2) == 2\n    assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],numSelect = 5) == 3\n    assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0]],numSelect = 4) == 4\n    assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],numSelect = 6) == 2\n    assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 0]],numSelect = 4) == 2\n    assert candidate(matrix = [[1, 1, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [1, 0, 1, 1, 0, 0]],numSelect = 2) == 0\n    assert candidate(matrix = [[1, 1, 1, 0, 1], [1, 0, 1, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 1, 0, 0, 0], [1, 1, 0, 1, 0], [0, 0, 1, 0, 1], [1, 0, 0, 1, 1], [0, 0, 0, 1, 1], [1, 1, 0, 0, 1]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],numSelect = 7) == 3\n    assert candidate(matrix = [[0, 1, 0, 1, 1], [1, 1, 0, 1, 0], [0, 0, 1, 1, 1], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1]],numSelect = 3) == 2\n    assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]],numSelect = 5) == 3\n    assert candidate(matrix = [[1, 1, 0, 0, 1], [1, 0, 1, 1, 0], [0, 0, 0, 1, 1], [1, 1, 1, 0, 1]],numSelect = 3) == 1\n    assert candidate(matrix = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]],numSelect = 5) == 2\n    assert candidate(matrix = [[1, 1, 0, 1, 1, 0, 1, 1], [0, 0, 1, 0, 0, 1, 0, 0], [1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0]],numSelect = 4) == 2\n    assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 0, 1, 1, 1, 0, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0]],numSelect = 5) == 2\n    assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],numSelect = 6) == 3\n    assert candidate(matrix = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],numSelect = 2) == 0\n    assert candidate(matrix = [[0, 1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1, 0, 1, 0]],numSelect = 5) == 3\n    assert candidate(matrix = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0]],numSelect = 2) == 2\n    assert candidate(matrix = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 0]],numSelect = 4) == 2\n    assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 0], [1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1]],numSelect = 4) == 1\n", "comparison": "exact"}, "public_tests": ["[[0,0,0],[1,0,1],[0,1,1],[0,0,1]]\n2", "[[1],[0]]\n1"], "hints": ["Try a brute-force approach.", "Iterate through all possible sets of exactly cols columns.", "For each valid set, check how many rows are covered, and return the maximum."], "metadata": {"canonical_parameter_names": ["matrix", "numSelect"], "leetcode_dataset_entry_point": "Solution().maximumRows", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:15+00:00", "tests_total": 99, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "backtracking", "bit-manipulation", "matrix", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def maximumRows(self, matrix: list[list[int]], numSelect: int) -> int:", "container": "Solution", "callable": "maximumRows", "parameters": [{"name": "matrix", "type": "list[list[int]]"}, {"name": "numSelect", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2398, "task_id": "maximum-number-of-robots-within-budget", "difficulty": "Hard", "problem_description": "You have n robots. You are given two 0-indexed integer arrays, chargeTimes and runningCosts, both of length n. The i^th robot costs chargeTimes[i] units to charge and costs runningCosts[i] units to run. You are also given an integer budget.\n\nThe total cost of running k chosen robots is equal to max(chargeTimes) + k * sum(runningCosts), where max(chargeTimes) is the largest charge cost among the k robots and sum(runningCosts) is the sum of running costs among the k robots.\n\nReturn the maximum number of consecutive robots you can run such that the total cost does not exceed budget.\n\nExample 1:\n\nInput: chargeTimes = [3,6,1,3,4], runningCosts = [2,1,3,4,5], budget = 25\nOutput: 3\nExplanation:\nIt is possible to run all individual and consecutive pairs of robots within budget.\nTo obtain answer 3, consider the first 3 robots. The total cost will be max(3,6,1) + 3 * sum(2,1,3) = 6 + 3 * 6 = 24 which is less than 25.\nIt can be shown that it is not possible to run more than 3 consecutive robots within budget, so we return 3.\n\nExample 2:\n\nInput: chargeTimes = [11,12,19], runningCosts = [10,8,7], budget = 19\nOutput: 0\nExplanation: No robot can be run that does not exceed the budget, so we return 0.\n\nConstraints:\n\n- chargeTimes.length == runningCosts.length == n\n- 1 <= n <= 5 * 10^4\n- 1 <= chargeTimes[i], runningCosts[i] <= 10^5\n- 1 <= budget <= 10^15\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(chargeTimes = [1, 1, 1, 1, 1],runningCosts = [100000, 100000, 100000, 100000, 100000],budget = 500000) == 2\n    assert candidate(chargeTimes = [7, 7, 7, 7],runningCosts = [1, 1, 1, 1],budget = 20) == 3\n    assert candidate(chargeTimes = [100000, 100000, 100000, 100000, 100000],runningCosts = [100000, 100000, 100000, 100000, 100000],budget = 1000000000000) == 5\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5],runningCosts = [1, 2, 3, 4, 5],budget = 20) == 2\n    assert candidate(chargeTimes = [100000, 100000, 100000],runningCosts = [1, 1, 1],budget = 300001) == 3\n    assert candidate(chargeTimes = [5, 11, 2, 7],runningCosts = [3, 9, 1, 10],budget = 30) == 2\n    assert candidate(chargeTimes = [11, 12, 19],runningCosts = [10, 8, 7],budget = 19) == 0\n    assert candidate(chargeTimes = [1, 2, 3],runningCosts = [10, 20, 30],budget = 100) == 2\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5],runningCosts = [5, 4, 3, 2, 1],budget = 20) == 2\n    assert candidate(chargeTimes = [5, 5, 5, 5, 5],runningCosts = [1, 1, 1, 1, 1],budget = 15) == 3\n    assert candidate(chargeTimes = [3, 6, 1, 3, 4],runningCosts = [2, 1, 3, 4, 5],budget = 25) == 3\n    assert candidate(chargeTimes = [100000, 100000, 100000],runningCosts = [100000, 100000, 100000],budget = 100000000000) == 3\n    assert candidate(chargeTimes = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],budget = 500) == 4\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 50) == 4\n    assert candidate(chargeTimes = [1, 3, 2, 4, 5, 3, 2, 1, 4, 5],runningCosts = [5, 1, 4, 2, 3, 5, 1, 4, 2, 3],budget = 25) == 3\n    assert candidate(chargeTimes = [9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 20) == 4\n    assert candidate(chargeTimes = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 30) == 4\n    assert candidate(chargeTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],runningCosts = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],budget = 100) == 4\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 10) == 2\n    assert candidate(chargeTimes = [20, 10, 15, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],budget = 300) == 7\n    assert candidate(chargeTimes = [3, 6, 1, 3, 4, 5, 7, 8, 9, 10, 2, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],runningCosts = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],budget = 100) == 5\n    assert candidate(chargeTimes = [9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9],budget = 40) == 3\n    assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 20) == 4\n    assert candidate(chargeTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 300) == 10\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],budget = 1000) == 10\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],runningCosts = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 500) == 9\n    assert candidate(chargeTimes = [3, 7, 9, 8, 5, 6, 2, 4],runningCosts = [10, 8, 5, 3, 9, 6, 7, 2],budget = 50) == 2\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],budget = 100) == 5\n    assert candidate(chargeTimes = [10, 20, 30, 40, 50],runningCosts = [5, 15, 25, 35, 45],budget = 500) == 4\n    assert candidate(chargeTimes = [10, 15, 20, 25, 30],runningCosts = [1, 2, 3, 4, 5],budget = 50) == 3\n    assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],budget = 500005) == 2\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],runningCosts = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 500) == 9\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 50) == 4\n    assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60],budget = 250) == 3\n    assert candidate(chargeTimes = [100, 200, 300, 400, 500],runningCosts = [5, 5, 5, 5, 5],budget = 1500) == 5\n    assert candidate(chargeTimes = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 30) == 5\n    assert candidate(chargeTimes = [3, 6, 1, 3, 4, 9, 12, 8, 10, 5],runningCosts = [2, 1, 3, 4, 5, 1, 2, 3, 4, 5],budget = 100) == 5\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5],runningCosts = [10000, 10000, 10000, 10000, 10000],budget = 50000) == 2\n    assert candidate(chargeTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],budget = 500) == 9\n    assert candidate(chargeTimes = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],runningCosts = [5, 9, 2, 6, 5, 3, 5, 9, 1, 4, 1],budget = 150) == 6\n    assert candidate(chargeTimes = [10000, 20000, 30000, 40000, 50000],runningCosts = [1000, 2000, 3000, 4000, 5000],budget = 100000) == 4\n    assert candidate(chargeTimes = [100000, 100000, 100000, 100000, 100000],runningCosts = [1, 1, 1, 1, 1],budget = 500005) == 5\n    assert candidate(chargeTimes = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],runningCosts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],budget = 1000) == 6\n    assert candidate(chargeTimes = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],runningCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],budget = 10000) == 10\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 100) == 5\n    assert candidate(chargeTimes = [1, 10, 100, 1000, 10000],runningCosts = [1, 10, 100, 1000, 10000],budget = 111111) == 5\n    assert candidate(chargeTimes = [9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9],budget = 50) == 4\n    assert candidate(chargeTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],runningCosts = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],budget = 1000) == 9\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 55) == 4\n    assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 5) == 2\n    assert candidate(chargeTimes = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],runningCosts = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],budget = 100) == 3\n    assert candidate(chargeTimes = [100, 200, 300, 400, 500],runningCosts = [5, 10, 15, 20, 25],budget = 1000) == 5\n    assert candidate(chargeTimes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 25) == 4\n    assert candidate(chargeTimes = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],budget = 45) == 3\n    assert candidate(chargeTimes = [50, 25, 75, 100, 125, 200, 150, 225, 300, 350],runningCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],budget = 1000) == 5\n    assert candidate(chargeTimes = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 10) == 2\n    assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 5) == 2\n    assert candidate(chargeTimes = [1, 5, 1, 5, 1, 5],runningCosts = [1, 1, 1, 1, 1, 1],budget = 12) == 2\n    assert candidate(chargeTimes = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 1000000) == 10\n    assert candidate(chargeTimes = [5, 15, 10, 20, 25, 30, 35, 40, 45, 50],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],budget = 100) == 5\n    assert candidate(chargeTimes = [50, 40, 30, 20, 10],runningCosts = [1, 2, 3, 4, 5],budget = 100) == 4\n    assert candidate(chargeTimes = [9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9],budget = 45) == 3\n    assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 10) == 3\n    assert candidate(chargeTimes = [50, 40, 30, 20, 10],runningCosts = [1, 2, 3, 4, 5],budget = 200) == 5\n    assert candidate(chargeTimes = [100000, 100000, 100000, 100000, 100000],runningCosts = [100000, 100000, 100000, 100000, 100000],budget = 500000) == 2\n    assert candidate(chargeTimes = [100, 200, 300, 400, 500],runningCosts = [50, 40, 30, 20, 10],budget = 1000) == 4\n    assert candidate(chargeTimes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],budget = 100) == 5\n    assert candidate(chargeTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],runningCosts = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],budget = 500) == 4\n    assert candidate(chargeTimes = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 5000010) == 10\n    assert candidate(chargeTimes = [10, 20, 30, 40, 50],runningCosts = [1, 2, 3, 4, 5],budget = 100) == 4\n    assert candidate(chargeTimes = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],runningCosts = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6],budget = 300) == 2\n    assert candidate(chargeTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],runningCosts = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],budget = 50) == 3\n    assert candidate(chargeTimes = [100, 200, 300, 400, 500, 600],runningCosts = [1, 2, 3, 4, 5, 6],budget = 1500) == 6\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 100) == 5\n    assert candidate(chargeTimes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],budget = 100) == 5\n    assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 15) == 3\n    assert candidate(chargeTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],runningCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],budget = 500) == 4\n    assert candidate(chargeTimes = [9, 7, 5, 11, 13, 2, 8],runningCosts = [4, 8, 12, 16, 20, 24, 28],budget = 100) == 3\n    assert candidate(chargeTimes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],budget = 1500) == 13\n    assert candidate(chargeTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],runningCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 50) == 3\n    assert candidate(chargeTimes = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],budget = 50) == 4\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],runningCosts = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 100) == 5\n    assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 10) == 3\n    assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 20) == 4\n    assert candidate(chargeTimes = [1, 3, 2, 5, 4],runningCosts = [5, 3, 6, 2, 4],budget = 20) == 2\n    assert candidate(chargeTimes = [9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9],budget = 100) == 5\n    assert candidate(chargeTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],budget = 200) == 6\n    assert candidate(chargeTimes = [10, 20, 30, 40, 50, 60, 70],runningCosts = [1, 2, 3, 4, 5, 6, 7],budget = 200) == 6\n    assert candidate(chargeTimes = [50, 40, 30, 20, 10],runningCosts = [1, 2, 3, 4, 5],budget = 300) == 5\n    assert candidate(chargeTimes = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],runningCosts = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],budget = 150) == 6\n    assert candidate(chargeTimes = [9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9],budget = 30) == 3\n    assert candidate(chargeTimes = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],runningCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],budget = 1000000) == 10\n    assert candidate(chargeTimes = [100000, 90000, 80000, 70000, 60000],runningCosts = [10000, 9000, 8000, 7000, 6000],budget = 10000000) == 5\n    assert candidate(chargeTimes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],runningCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],budget = 250) == 3\n    assert candidate(chargeTimes = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 200) == 10\n    assert candidate(chargeTimes = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],runningCosts = [25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3],budget = 200) == 5\n    assert candidate(chargeTimes = [20, 18, 15, 12, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],runningCosts = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],budget = 100) == 4\n    assert candidate(chargeTimes = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 100) == 7\n    assert candidate(chargeTimes = [100000, 100000, 100000, 100000, 100000],runningCosts = [1, 1, 1, 1, 1],budget = 500000) == 5\n    assert candidate(chargeTimes = [1000, 2000, 3000, 4000, 5000],runningCosts = [5, 5, 5, 5, 5],budget = 10000) == 5\n    assert candidate(chargeTimes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 300) == 16\n    assert candidate(chargeTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],runningCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],budget = 500) == 10\n    assert candidate(chargeTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],runningCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],budget = 500) == 4\n    assert candidate(chargeTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],budget = 150) == 5\n    assert candidate(chargeTimes = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],runningCosts = [9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3],budget = 200) == 6\n    assert candidate(chargeTimes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],budget = 250) == 7\n    assert candidate(chargeTimes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],runningCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],budget = 50) == 4\n", "comparison": "exact"}, "public_tests": ["[3,6,1,3,4]\n[2,1,3,4,5]\n25", "[11,12,19]\n[10,8,7]\n19"], "hints": ["Use binary search to convert the problem into checking if we can find a specific number of consecutive robots within the budget.", "Maintain a sliding window of the consecutive robots being considered.", "Use either a map, deque, or heap to find the maximum charge times in the window efficiently."], "metadata": {"canonical_parameter_names": ["chargeTimes", "runningCosts", "budget"], "leetcode_dataset_entry_point": "Solution().maximumRobots", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:17+00:00", "tests_total": 108, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "binary-search", "queue", "sliding-window", "heap-priority-queue", "prefix-sum", "monotonic-queue"]}, "language": "python", "interface": {"raw_signature": "def maximumRobots(self, chargeTimes: list[int], runningCosts: list[int], budget: int) -> int:", "container": "Solution", "callable": "maximumRobots", "parameters": [{"name": "chargeTimes", "type": "list[int]"}, {"name": "runningCosts", "type": "list[int]"}, {"name": "budget", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2399, "task_id": "check-distances-between-same-letters", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string s consisting of only lowercase English letters, where each letter in s appears exactly twice. You are also given a 0-indexed integer array distance of length 26.\n\nEach letter in the alphabet is numbered from 0 to 25 (i.e. 'a' -> 0, 'b' -> 1, 'c' -> 2, ... , 'z' -> 25).\n\nIn a well-spaced string, the number of letters between the two occurrences of the i^th letter is distance[i]. If the i^th letter does not appear in s, then distance[i] can be ignored.\n\nReturn true if s is a well-spaced string, otherwise return false.\n\nExample 1:\n\nInput: s = \"abaccb\", distance = [1,3,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\nOutput: true\nExplanation:\n- 'a' appears at indices 0 and 2 so it satisfies distance[0] = 1.\n- 'b' appears at indices 1 and 5 so it satisfies distance[1] = 3.\n- 'c' appears at indices 3 and 4 so it satisfies distance[2] = 0.\nNote that distance[3] = 5, but since 'd' does not appear in s, it can be ignored.\nReturn true because s is a well-spaced string.\n\nExample 2:\n\nInput: s = \"aa\", distance = [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\nOutput: false\nExplanation:\n- 'a' appears at indices 0 and 1 so there are zero letters between them.\nBecause distance[0] = 1, s is not a well-spaced string.\n\nConstraints:\n\n- 2 <= s.length <= 52\n- s consists only of lowercase English letters.\n- Each letter appears in s exactly twice.\n- distance.length == 26\n- 0 <= distance[i] <= 50\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"abcdefghijklmnopqrztuvwxyz\",distance = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n    assert candidate(s = \"zz\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50]) == False\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\",distance = [50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]) == False\n    assert candidate(s = \"abcdcba\",distance = [3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"bbcaac\",distance = [3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\",distance = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 0]) == False\n    assert candidate(s = \"abcabc\",distance = [2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abba\",distance = [2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",distance = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n    assert candidate(s = \"aa\",distance = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abaccb\",distance = [1, 3, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",distance = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",distance = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcde\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"zazbzczdzdzczbza\",distance = [2, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abcdefghijkllkjihgfedcba\",distance = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"zxyxzyxzyx\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9]) == False\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\",distance = [50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"aabbaa\",distance = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"zyxzyxzyxzyx\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]) == False\n    assert candidate(s = \"acbacbacbacbacbacb\",distance = [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abcdefghijabcdefghij\",distance = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"zamnzamn\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]) == False\n    assert candidate(s = \"abcdefghijzyxwvutsrqponmlk\",distance = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"mnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",distance = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == False\n    assert candidate(s = \"abcdefggfedcba\",distance = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abcdefgabcdefg\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"lkjihglkjh\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 1, 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\",distance = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abababababababab\",distance = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"abababababababababababab\",distance = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"pqrstuvwxyzzzyxwvutsrqp\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n    assert candidate(s = \"abacabadabacabad\",distance = [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abcdefghijklmabcdefghijklm\",distance = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"qponmlkjihgfedcbazyxwvutsr\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"zzzyyxxwwvvuuttssrrqqppoonnmmlkkjjiihhggffeeddccbaa\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50]) == False\n    assert candidate(s = \"acbacbacbacb\",distance = [2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzz\",distance = [25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"zyxzyxzyxzyxzyxzyx\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]) == False\n    assert candidate(s = \"qrstuvwxzyabcdefghijklmnop\",distance = [23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0]) == True\n    assert candidate(s = \"mnopqrstuvwxzzyxwvutsrqponmlkjihgfedcba\",distance = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\",distance = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25]) == False\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxw\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 7, 6, 5]) == False\n    assert candidate(s = \"abcdabcd\",distance = [3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"abcdefgihgfedcba\",distance = [0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abcdefgabcdefg\",distance = [5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"qrstuvqr\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"mnopqrsmnopqr\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"mnopmnop\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",distance = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25]) == False\n    assert candidate(s = \"qrstuvqrstuv\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abcdefgabcdefg\",distance = [1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"zebrazebra\",distance = [23, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abcdefghijhgfedcba\",distance = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"ababababababababababababababababababababab\",distance = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"lmnopqrstuvw\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"abcdefgihgfedcba\",distance = [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"mnopqrstuvwxyzz\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == False\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",distance = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == False\n    assert candidate(s = \"pqrsrqpq\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"zabyxwvutsrqponmlkjihgfedcba\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcd\",distance = [3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"qrstuvrstu\",distance = [0, 0, 0, 0, 0, 0, 0, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"acbacbacbacbacbacb\",distance = [1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"lkjhlkjhlkjh\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"mnopqrsmnopqr\",distance = [0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abcdeffedcba\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0]) == False\n    assert candidate(s = \"zabzyabzyabzyabz\",distance = [0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]) == False\n    assert candidate(s = \"abcdefghigfedcba\",distance = [7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"aabbaaccddaaff\",distance = [2, 2, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",distance = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == False\n    assert candidate(s = \"abcdabcdeff\",distance = [1, 1, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"mnopqrstuvtwxzyabcdeffedcba\",distance = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",distance = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == True\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzza\",distance = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == False\n    assert candidate(s = \"mnopqrstuv\",distance = [0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"mnopqrmpqr\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 3, 2, 1, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"lmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\",distance = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == False\n    assert candidate(s = \"mnopmnop\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"acbacbacba\",distance = [0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"mnopqrsmnopqrsmnopqrs\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n    assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdef\",distance = [5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxzy\",distance = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 0]) == True\n    assert candidate(s = \"qrstuvqponmlkjihgfedcbazyxw\",distance = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 8, 7, 6]) == False\n    assert candidate(s = \"abcdabcdabcd\",distance = [3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n", "comparison": "exact"}, "public_tests": ["\"abaccb\"\n[1,3,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]", "\"aa\"\n[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]"], "hints": ["Create an integer array of size 26 to keep track of the first occurrence of each letter.", "The number of letters between indices i and j is j - i - 1."], "metadata": {"canonical_parameter_names": ["s", "distance"], "leetcode_dataset_entry_point": "Solution().checkDistances", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:19+00:00", "tests_total": 93, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def checkDistances(self, s: str, distance: list[int]) -> bool:", "container": "Solution", "callable": "checkDistances", "parameters": [{"name": "s", "type": "str"}, {"name": "distance", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2400, "task_id": "number-of-ways-to-reach-a-position-after-exactly-k-steps", "difficulty": "Medium", "problem_description": "You are given two positive integers startPos and endPos. Initially, you are standing at position startPos on an infinite number line. With one step, you can move either one position to the left, or one position to the right.\n\nGiven a positive integer k, return the number of different ways to reach the position endPos starting from startPos, such that you perform exactly k steps. Since the answer may be very large, return it modulo 10^9 + 7.\n\nTwo ways are considered different if the order of the steps made is not exactly the same.\n\nNote that the number line includes negative integers.\n\nExample 1:\n\nInput: startPos = 1, endPos = 2, k = 3\nOutput: 3\nExplanation: We can reach position 2 from 1 in exactly 3 steps in three ways:\n- 1 -> 2 -> 3 -> 2.\n- 1 -> 2 -> 1 -> 2.\n- 1 -> 0 -> 1 -> 2.\nIt can be proven that no other way is possible, so we return 3.\n\nExample 2:\n\nInput: startPos = 2, endPos = 5, k = 10\nOutput: 0\nExplanation: It is impossible to reach position 5 from position 2 in exactly 10 steps.\n\nConstraints:\n\n- 1 <= startPos, endPos, k <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(startPos = 1,endPos = 2,k = 3) == 3\n    assert candidate(startPos = 10,endPos = 1,k = 15) == 455\n    assert candidate(startPos = 5,endPos = 5,k = 10) == 252\n    assert candidate(startPos = 10,endPos = 1,k = 9) == 1\n    assert candidate(startPos = 2,endPos = 5,k = 10) == 0\n    assert candidate(startPos = 1,endPos = 2,k = 100) == 0\n    assert candidate(startPos = 100,endPos = 50,k = 150) == 713790273\n    assert candidate(startPos = 500,endPos = 450,k = 100) == 244856590\n    assert candidate(startPos = 2,endPos = 1,k = 4) == 0\n    assert candidate(startPos = 500,endPos = 400,k = 100) == 1\n    assert candidate(startPos = 5,endPos = 5,k = 1) == 0\n    assert candidate(startPos = 1000,endPos = 990,k = 20) == 15504\n    assert candidate(startPos = 100,endPos = 50,k = 200) == 489348363\n    assert candidate(startPos = 5,endPos = 15,k = 12) == 12\n    assert candidate(startPos = 1,endPos = 2,k = 5) == 10\n    assert candidate(startPos = 100,endPos = 100,k = 200) == 407336795\n    assert candidate(startPos = 500,endPos = 400,k = 199) == 0\n    assert candidate(startPos = 3,endPos = 3,k = 6) == 20\n    assert candidate(startPos = 100,endPos = 100,k = 1) == 0\n    assert candidate(startPos = 50,endPos = 50,k = 50) == 605552882\n    assert candidate(startPos = 100,endPos = 200,k = 150) == 297103639\n", "comparison": "exact"}, "public_tests": ["1\n2\n3", "2\n5\n10"], "hints": ["How many steps to the left and to the right do you need to make exactly?", "Does the order of the steps matter?", "Use combinatorics to find the number of ways to order the steps."], "metadata": {"canonical_parameter_names": ["startPos", "endPos", "k"], "leetcode_dataset_entry_point": "Solution().numberOfWays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:21+00:00", "tests_total": 39, "tests_dropped": 18, "flags": [], "topic_tags": ["math", "dynamic-programming", "combinatorics"]}, "language": "python", "interface": {"raw_signature": "def numberOfWays(self, startPos: int, endPos: int, k: int) -> int:", "container": "Solution", "callable": "numberOfWays", "parameters": [{"name": "startPos", "type": "int"}, {"name": "endPos", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2401, "task_id": "longest-nice-subarray", "difficulty": "Medium", "problem_description": "You are given an array nums consisting of positive integers.\n\nWe call a subarray of nums nice if the bitwise AND of every pair of elements that are in different positions in the subarray is equal to 0.\n\nReturn the length of the longest nice subarray.\n\nA subarray is a contiguous part of an array.\n\nNote that subarrays of length 1 are always considered nice.\n\nExample 1:\n\nInput: nums = [1,3,8,48,10]\nOutput: 3\nExplanation: The longest nice subarray is [3,8,48]. This subarray satisfies the conditions:\n- 3 AND 8 = 0.\n- 3 AND 48 = 0.\n- 8 AND 48 = 0.\nIt can be proven that no longer nice subarray can be obtained, so we return 3.\n\nExample 2:\n\nInput: nums = [3,1,5,11,13]\nOutput: 1\nExplanation: The length of the longest nice subarray is 1. Any subarray of length 1 can be chosen.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [3, 1, 5, 11, 13]) == 1\n    assert candidate(nums = [31, 1, 4, 32, 16]) == 4\n    assert candidate(nums = [7, 11, 13, 14, 2, 5, 3]) == 2\n    assert candidate(nums = [1, 2, 4, 8, 16]) == 5\n    assert candidate(nums = [16, 17, 71, 62, 12, 24, 14]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n    assert candidate(nums = [7, 14, 28, 56, 112]) == 1\n    assert candidate(nums = [1]) == 1\n    assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 2\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [2, 1, 5, 6, 7, 4, 10]) == 2\n    assert candidate(nums = [30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n    assert candidate(nums = [31, 15, 7, 3, 1]) == 1\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 20\n    assert candidate(nums = [1, 3, 8, 48, 10]) == 3\n    assert candidate(nums = [7, 11, 14, 18, 21, 23, 26, 28, 31, 33, 34, 38, 39, 42, 43, 46, 47, 50, 51, 54]) == 1\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 21\n    assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63]) == 1\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 102, 106, 110, 114, 118, 122, 126, 130, 134, 138, 142, 146, 150, 154, 158, 162, 166, 170]) == 1\n    assert candidate(nums = [1, 2, 3, 5, 6, 10, 12, 15, 17, 20, 24, 28, 30, 31, 35, 40, 42, 48, 56, 60]) == 2\n    assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 20\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 1\n    assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1023, 511, 255, 127, 63, 31, 15, 7, 3]) == 11\n    assert candidate(nums = [2, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432]) == 1\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431]) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 1\n    assert candidate(nums = [128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864]) == 20\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 2\n    assert candidate(nums = [255, 256, 257, 258, 259, 260, 261, 262, 263, 264]) == 2\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152]) == 22\n    assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048]) == 21\n    assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432, 1572864, 3145728, 6291456, 12582912, 25165824, 50331648]) == 1\n    assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 20\n    assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048]) == 11\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == 2\n    assert candidate(nums = [1, 2, 3, 5, 6, 10, 12, 15, 20, 21, 30, 60, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608]) == 23\n    assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1\n    assert candidate(nums = [2, 3, 6, 7, 14, 21, 23, 26, 31, 35, 38, 39, 42, 43, 46, 47, 51, 53, 54, 55, 58, 59, 62, 63, 66, 67, 70, 71, 75, 77, 78, 79, 82, 83, 86, 87, 91, 93, 94, 95, 98, 99, 102, 103, 106, 107, 111, 113, 114, 115, 118, 119, 122, 123, 127]) == 1\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216]) == 25\n    assert candidate(nums = [1, 2, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289]) == 2\n    assert candidate(nums = [31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383]) == 1\n    assert candidate(nums = [31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 16\n    assert candidate(nums = [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480, 40960, 81920, 163840, 327680, 655360, 1310720, 2621440, 5242880, 10485760, 20971520, 41943040, 83886080]) == 2\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n    assert candidate(nums = [1048575, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048]) == 9\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912]) == 30\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200]) == 2\n    assert candidate(nums = [1, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432, 1572864]) == 2\n    assert candidate(nums = [1, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432, 1572864]) == 2\n    assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 21\n    assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480, 40960, 81920, 163840, 327680, 655360, 1310720, 2621440, 5242880, 10485760, 20971520, 41943040, 83886080, 167772160]) == 2\n    assert candidate(nums = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911]) == 1\n    assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1\n    assert candidate(nums = [3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 25, 30, 33, 34, 40, 41, 48, 50, 60, 64]) == 2\n    assert candidate(nums = [1023, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 2\n    assert candidate(nums = [1, 5, 3, 9, 7, 11, 13, 17, 15, 23, 21, 29, 27, 33, 31, 37, 35, 41, 39, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63]) == 1\n    assert candidate(nums = [1, 6, 10, 18, 33, 66, 132, 264, 528, 1056, 2112, 4224, 8448, 16896, 33792, 67584, 135168, 270336, 540672, 1081344]) == 5\n    assert candidate(nums = [8388607, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384]) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n    assert candidate(nums = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n    assert candidate(nums = [1, 2, 3, 5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480, 40960, 81920, 163840, 327680]) == 2\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907, 953, 476, 238, 119, 59, 29, 14, 7, 3, 1]) == 1\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 2\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 1\n    assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336, 28672, 57344, 114688, 229376, 458752, 917504, 1835008, 3670016]) == 1\n    assert candidate(nums = [3, 5, 1, 2, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 19\n    assert candidate(nums = [31, 62, 124, 248, 496, 992, 1984, 3968, 7936, 15872, 31744, 63488, 126976, 253952, 507904, 1015808, 2031616, 4063232, 8126464, 16252928]) == 1\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1\n    assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1\n    assert candidate(nums = [511, 255, 127, 63, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 12\n    assert candidate(nums = [536870912, 268435456, 134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 30\n    assert candidate(nums = [999999999, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023]) == 1\n", "comparison": "exact"}, "public_tests": ["[1,3,8,48,10]", "[3,1,5,11,13]"], "hints": ["What is the maximum possible length of a nice subarray?", "If two numbers have bitwise AND equal to zero, they do not have any common set bit. A number x <= 10^9 only has 30 bits, hence the length of the longest nice subarray cannot exceed 30."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().longestNiceSubarray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:24+00:00", "tests_total": 115, "tests_dropped": 32, "flags": [], "topic_tags": ["array", "bit-manipulation", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def longestNiceSubarray(self, nums: list[int]) -> int:", "container": "Solution", "callable": "longestNiceSubarray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2402, "task_id": "meeting-rooms-iii", "difficulty": "Hard", "problem_description": "You are given an integer n. There are n rooms numbered from 0 to n - 1.\n\nYou are given a 2D integer array meetings where meetings[i] = [start_i, end_i] means that a meeting will be held during the half-closed time interval [start_i, end_i). All the values of start_i are unique.\n\nMeetings are allocated to rooms in the following manner:\n\n1. Each meeting will take place in the unused room with the lowest number.\n2. If there are no available rooms, the meeting will be delayed until a room becomes free. The delayed meeting should have the same duration as the original meeting.\n3. When a room becomes unused, meetings that have an earlier original start time should be given the room.\n\nReturn the number of the room that held the most meetings. If there are multiple rooms, return the room with the lowest number.\n\nA half-closed interval [a, b) is the interval between a and b including a and not including b.\n\nExample 1:\n\nInput: n = 2, meetings = [[0,10],[1,5],[2,7],[3,4]]\nOutput: 0\nExplanation:\n- At time 0, both rooms are not being used. The first meeting starts in room 0.\n- At time 1, only room 1 is not being used. The second meeting starts in room 1.\n- At time 2, both rooms are being used. The third meeting is delayed.\n- At time 3, both rooms are being used. The fourth meeting is delayed.\n- At time 5, the meeting in room 1 finishes. The third meeting starts in room 1 for the time period [5,10).\n- At time 10, the meetings in both rooms finish. The fourth meeting starts in room 0 for the time period [10,11).\nBoth rooms 0 and 1 held 2 meetings, so we return 0.\n\nExample 2:\n\nInput: n = 3, meetings = [[1,20],[2,10],[3,5],[4,9],[6,8]]\nOutput: 1\nExplanation:\n- At time 1, all three rooms are not being used. The first meeting starts in room 0.\n- At time 2, rooms 1 and 2 are not being used. The second meeting starts in room 1.\n- At time 3, only room 2 is not being used. The third meeting starts in room 2.\n- At time 4, all three rooms are being used. The fourth meeting is delayed.\n- At time 5, the meeting in room 2 finishes. The fourth meeting starts in room 2 for the time period [5,10).\n- At time 6, all three rooms are being used. The fifth meeting is delayed.\n- At time 10, the meetings in rooms 1 and 2 finish. The fifth meeting starts in room 1 for the time period [10,12).\nRoom 0 held 1 meeting while rooms 1 and 2 each held 2 meetings, so we return 1.\n\nConstraints:\n\n- 1 <= n <= 100\n- 1 <= meetings.length <= 10^5\n- meetings[i].length == 2\n- 0 <= start_i < end_i <= 5 * 10^5\n- All the values of start_i are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 5,meetings = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 0\n    assert candidate(n = 5,meetings = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6]]) == 0\n    assert candidate(n = 10,meetings = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]]) == 0\n    assert candidate(n = 5,meetings = [[0, 30], [5, 10], [15, 20], [5, 10]]) == 1\n    assert candidate(n = 2,meetings = [[0, 10], [1, 5], [2, 7], [3, 4]]) == 0\n    assert candidate(n = 4,meetings = [[0, 2], [0, 3], [1, 2], [2, 4], [3, 5]]) == 0\n    assert candidate(n = 1,meetings = [[1, 2], [3, 4], [5, 6]]) == 0\n    assert candidate(n = 5,meetings = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n    assert candidate(n = 1,meetings = [[0, 1], [2, 3], [4, 5]]) == 0\n    assert candidate(n = 10,meetings = [[0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]) == 0\n    assert candidate(n = 4,meetings = [[0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30]]) == 0\n    assert candidate(n = 2,meetings = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n    assert candidate(n = 3,meetings = [[1, 20], [2, 10], [3, 5], [4, 9], [6, 8]]) == 1\n    assert candidate(n = 3,meetings = [[0, 100], [101, 200], [201, 300], [301, 400]]) == 0\n    assert candidate(n = 1,meetings = [[0, 100], [100, 200], [200, 300]]) == 0\n    assert candidate(n = 4,meetings = [[1, 10], [2, 15], [3, 20], [4, 25], [5, 30]]) == 0\n    assert candidate(n = 10,meetings = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == 0\n    assert candidate(n = 7,meetings = [[1, 5], [1, 10], [1, 15], [1, 20], [2, 6], [2, 11], [2, 16], [2, 21], [3, 7], [3, 12], [3, 17], [3, 22], [4, 8], [4, 13], [4, 18], [4, 23], [5, 9], [5, 14], [5, 19], [5, 24]]) == 4\n    assert candidate(n = 6,meetings = [[0, 100], [1, 99], [2, 98], [3, 97], [4, 96], [5, 95], [6, 94], [7, 93], [8, 92], [9, 91], [10, 90], [11, 89], [12, 88], [13, 87], [14, 86], [15, 85], [16, 84], [17, 83], [18, 82], [19, 81], [20, 80], [21, 79], [22, 78], [23, 77], [24, 76], [25, 75], [26, 74], [27, 73], [28, 72], [29, 71], [30, 70], [31, 69], [32, 68], [33, 67], [34, 66], [35, 65], [36, 64], [37, 63], [38, 62], [39, 61], [40, 60], [41, 59], [42, 58], [43, 57], [44, 56], [45, 55], [46, 54], [47, 53], [48, 52], [49, 51]]) == 0\n    assert candidate(n = 10,meetings = [[1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20], [11, 21], [12, 22], [13, 23], [14, 24], [15, 25], [16, 26], [17, 27], [18, 28], [19, 29], [20, 30]]) == 0\n    assert candidate(n = 6,meetings = [[1, 3], [2, 5], [4, 7], [6, 9], [8, 11], [10, 13], [12, 15], [14, 17], [16, 19], [18, 21]]) == 0\n    assert candidate(n = 4,meetings = [[1, 10], [2, 8], [3, 6], [4, 5], [5, 15], [6, 12], [7, 10], [8, 20], [9, 11], [10, 13]]) == 1\n    assert candidate(n = 5,meetings = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 0\n    assert candidate(n = 7,meetings = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20]]) == 0\n    assert candidate(n = 8,meetings = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19], [11, 20], [12, 21], [13, 22], [14, 23], [15, 24], [16, 25], [17, 26], [18, 27], [19, 28], [20, 29], [21, 30]]) == 0\n    assert candidate(n = 3,meetings = [[10, 15], [20, 25], [30, 35], [5, 10], [15, 20], [25, 30], [35, 40], [5, 15], [10, 20], [20, 30]]) == 0\n    assert candidate(n = 10,meetings = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 0\n    assert candidate(n = 3,meetings = [[0, 10], [1, 5], [2, 7], [3, 4], [4, 6], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12]]) == 1\n    assert candidate(n = 10,meetings = [[0, 1000], [500, 1500], [1000, 2000], [1500, 2500], [2000, 3000], [2500, 3500], [3000, 4000], [3500, 4500], [4000, 5000], [4500, 5500]]) == 0\n    assert candidate(n = 2,meetings = [[0, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500], [450, 550]]) == 0\n    assert candidate(n = 2,meetings = [[0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 65], [65, 70], [70, 75], [75, 80], [80, 85], [85, 90], [90, 95], [95, 100]]) == 0\n    assert candidate(n = 5,meetings = [[0, 2], [0, 4], [0, 6], [0, 8], [0, 10], [1, 3], [1, 5], [1, 7], [1, 9], [2, 4], [2, 6], [2, 8], [3, 5], [3, 7], [4, 6], [4, 8], [5, 7], [6, 8], [7, 9], [8, 10]]) == 0\n    assert candidate(n = 7,meetings = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 0\n    assert candidate(n = 3,meetings = [[0, 3], [1, 2], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13]]) == 0\n    assert candidate(n = 4,meetings = [[0, 10], [1, 5], [2, 7], [3, 4], [8, 12], [10, 15], [13, 18]]) == 1\n    assert candidate(n = 6,meetings = [[0, 3], [3, 6], [6, 9], [9, 12], [12, 15], [15, 18], [18, 21], [21, 24], [24, 27], [27, 30], [30, 33], [33, 36], [36, 39], [39, 42], [42, 45]]) == 0\n    assert candidate(n = 2,meetings = [[100, 105], [101, 106], [102, 107], [103, 108], [104, 109], [105, 110], [106, 111], [107, 112], [108, 113], [109, 114]]) == 0\n    assert candidate(n = 5,meetings = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17]]) == 0\n    assert candidate(n = 3,meetings = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]]) == 0\n    assert candidate(n = 4,meetings = [[0, 50], [10, 60], [20, 70], [30, 80], [40, 90], [50, 100], [60, 110], [70, 120], [80, 130], [90, 140]]) == 0\n    assert candidate(n = 6,meetings = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19]]) == 0\n    assert candidate(n = 2,meetings = [[0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [0, 15], [15, 25], [25, 35], [35, 45], [45, 55]]) == 0\n    assert candidate(n = 7,meetings = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [4, 5], [4, 6], [4, 7], [4, 8], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8]]) == 1\n    assert candidate(n = 7,meetings = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 11], [1, 12], [2, 13], [3, 14], [4, 15]]) == 0\n    assert candidate(n = 5,meetings = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 0\n    assert candidate(n = 10,meetings = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]]) == 0\n    assert candidate(n = 4,meetings = [[0, 30], [5, 10], [15, 20], [25, 35], [10, 25], [20, 30], [30, 40]]) == 1\n    assert candidate(n = 7,meetings = [[1, 5], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 19], [14, 20], [15, 21], [16, 22], [17, 23], [18, 24], [19, 25], [20, 26], [21, 27], [22, 28], [23, 29], [24, 30], [25, 31], [26, 32], [27, 33], [28, 34], [29, 35], [30, 36], [31, 37], [32, 38], [33, 39], [34, 40], [35, 41], [36, 42], [37, 43], [38, 44], [39, 45], [40, 46], [41, 47], [42, 48], [43, 49], [44, 50], [45, 51], [46, 52], [47, 53], [48, 54], [49, 55]]) == 0\n    assert candidate(n = 6,meetings = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 0\n    assert candidate(n = 7,meetings = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7]]) == 0\n    assert candidate(n = 3,meetings = [[0, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350], [300, 400]]) == 0\n    assert candidate(n = 4,meetings = [[0, 3], [1, 5], [2, 6], [3, 9], [4, 10], [5, 12], [6, 13], [7, 15], [8, 17], [9, 18]]) == 0\n    assert candidate(n = 8,meetings = [[0, 15], [15, 30], [30, 45], [45, 60], [60, 75], [75, 90], [90, 105], [105, 120], [120, 135], [135, 150], [150, 165], [165, 180], [180, 195], [195, 210], [210, 225]]) == 0\n    assert candidate(n = 3,meetings = [[0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [0, 30], [10, 40], [20, 50]]) == 0\n    assert candidate(n = 8,meetings = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 0\n    assert candidate(n = 5,meetings = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [15, 25], [25, 35], [35, 45], [45, 55], [55, 65]]) == 0\n    assert candidate(n = 5,meetings = [[0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [12, 14], [14, 16], [16, 18], [18, 20]]) == 0\n    assert candidate(n = 5,meetings = [[0, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20], [11, 21], [12, 22], [13, 23], [14, 24], [15, 25], [16, 26], [17, 27], [18, 28], [19, 29]]) == 0\n    assert candidate(n = 3,meetings = [[1, 100], [101, 200], [201, 300], [10, 110], [110, 210], [210, 310], [20, 120], [120, 220], [220, 320], [30, 130], [130, 230], [230, 330]]) == 0\n    assert candidate(n = 6,meetings = [[0, 2], [1, 4], [2, 6], [3, 8], [4, 10], [5, 12], [6, 14], [7, 16], [8, 18], [9, 20], [10, 22], [11, 24], [12, 26], [13, 28], [14, 30], [15, 32], [16, 34], [17, 36], [18, 38], [19, 40]]) == 0\n    assert candidate(n = 2,meetings = [[0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 65], [65, 70], [70, 75], [75, 80], [80, 85], [85, 90], [90, 95], [95, 100]]) == 0\n    assert candidate(n = 4,meetings = [[1, 15], [2, 3], [5, 12], [8, 10], [6, 14], [16, 20], [17, 19], [21, 25], [22, 24], [23, 26]]) == 1\n    assert candidate(n = 6,meetings = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20], [16, 21], [17, 22], [18, 23], [19, 24], [20, 25], [21, 26], [22, 27], [23, 28], [24, 29], [25, 30]]) == 0\n    assert candidate(n = 5,meetings = [[0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [1, 11], [11, 21], [21, 31], [31, 41], [41, 51]]) == 0\n    assert candidate(n = 6,meetings = [[1, 1000], [2, 2000], [3, 3000], [4, 4000], [5, 5000], [6, 6000], [7, 7000], [8, 8000], [9, 9000], [10, 10000]]) == 0\n    assert candidate(n = 3,meetings = [[0, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500], [450, 550], [500, 600], [550, 650], [600, 700], [650, 750], [700, 800]]) == 0\n    assert candidate(n = 3,meetings = [[0, 2], [0, 5], [0, 10], [5, 10], [10, 15], [5, 15], [10, 20], [15, 25], [20, 30], [25, 35]]) == 0\n    assert candidate(n = 7,meetings = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11], [6, 13], [7, 15], [8, 17], [9, 19], [10, 21], [11, 23], [12, 25], [13, 27], [14, 29], [15, 31], [16, 33], [17, 35], [18, 37], [19, 39]]) == 0\n    assert candidate(n = 4,meetings = [[1, 10], [2, 15], [3, 12], [4, 11], [5, 14], [6, 13], [7, 16], [8, 17], [9, 18], [10, 19]]) == 0\n    assert candidate(n = 3,meetings = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]]) == 0\n    assert candidate(n = 5,meetings = [[0, 2], [1, 4], [2, 6], [3, 8], [4, 10], [5, 12], [6, 14], [7, 16], [8, 18], [9, 20], [10, 22], [11, 24], [12, 26], [13, 28], [14, 30]]) == 0\n    assert candidate(n = 5,meetings = [[0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [5, 15], [15, 25], [25, 35], [35, 45], [45, 55]]) == 0\n    assert candidate(n = 3,meetings = [[0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110], [110, 120], [120, 130], [130, 140], [140, 150]]) == 0\n    assert candidate(n = 2,meetings = [[0, 100], [50, 60], [20, 30], [10, 20], [30, 40], [70, 80], [110, 120], [90, 100], [130, 140], [150, 160]]) == 1\n    assert candidate(n = 4,meetings = [[1, 18], [2, 15], [3, 12], [4, 9], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18]]) == 3\n    assert candidate(n = 10,meetings = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21]]) == 0\n    assert candidate(n = 7,meetings = [[0, 100], [100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [100, 500], [200, 600], [300, 700], [400, 800], [500, 900], [600, 1000]]) == 0\n    assert candidate(n = 4,meetings = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50]]) == 0\n    assert candidate(n = 8,meetings = [[0, 2], [0, 4], [0, 6], [0, 8], [0, 10], [0, 12], [0, 14], [0, 16], [0, 18], [0, 20], [1, 3], [1, 5], [1, 7], [1, 9], [1, 11], [1, 13], [1, 15], [1, 17], [1, 19], [1, 21]]) == 2\n    assert candidate(n = 4,meetings = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21]]) == 0\n    assert candidate(n = 5,meetings = [[0, 50], [10, 60], [20, 70], [30, 80], [40, 90], [50, 100], [60, 110], [70, 120], [80, 130], [90, 140]]) == 0\n    assert candidate(n = 5,meetings = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21]]) == 0\n    assert candidate(n = 4,meetings = [[1, 10], [10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [35, 45], [40, 50], [45, 55], [50, 60], [55, 65], [60, 70]]) == 0\n    assert candidate(n = 3,meetings = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 5], [2, 6], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12]]) == 0\n    assert candidate(n = 7,meetings = [[0, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500], [450, 550], [500, 600], [550, 650], [600, 700], [650, 750], [700, 800]]) == 0\n    assert candidate(n = 6,meetings = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 0\n    assert candidate(n = 1,meetings = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100], [10, 110], [11, 120], [12, 130], [13, 140], [14, 150], [15, 160], [16, 170], [17, 180], [18, 190], [19, 200], [20, 210], [21, 220], [22, 230], [23, 240], [24, 250], [25, 260], [26, 270], [27, 280], [28, 290], [29, 300]]) == 0\n    assert candidate(n = 6,meetings = [[1, 6], [2, 5], [3, 4], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20]]) == 0\n    assert candidate(n = 10,meetings = [[0, 10], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]) == 0\n    assert candidate(n = 4,meetings = [[0, 15], [5, 20], [10, 25], [15, 30], [20, 35], [25, 40]]) == 0\n", "comparison": "exact"}, "public_tests": ["2\n[[0,10],[1,5],[2,7],[3,4]]", "3\n[[1,20],[2,10],[3,5],[4,9],[6,8]]"], "hints": ["Sort meetings based on start times.", "Use two min heaps, the first one keeps track of the numbers of all the rooms that are free. The second heap keeps track of the end times of all the meetings that are happening and the room that they are in.", "Keep track of the number of times each room is used in an array.", "With each meeting, check if there are any free rooms. If there are, then use the room with the smallest number. Otherwise, assign the meeting to the room whose meeting will end the soonest."], "metadata": {"canonical_parameter_names": ["n", "meetings"], "leetcode_dataset_entry_point": "Solution().mostBooked", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:27+00:00", "tests_total": 92, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "hash-table", "sorting", "heap-priority-queue", "simulation"]}, "language": "python", "interface": {"raw_signature": "def mostBooked(self, n: int, meetings: list[list[int]]) -> int:", "container": "Solution", "callable": "mostBooked", "parameters": [{"name": "n", "type": "int"}, {"name": "meetings", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2404, "task_id": "most-frequent-even-element", "difficulty": "Easy", "problem_description": "Given an integer array nums, return the most frequent even element.\n\nIf there is a tie, return the smallest one. If there is no such element, return -1.\n\nExample 1:\n\nInput: nums = [0,1,2,2,4,4,1]\nOutput: 2\nExplanation:\nThe even elements are 0, 2, and 4. Of these, 2 and 4 appear the most.\nWe return the smallest one, which is 2.\n\nExample 2:\n\nInput: nums = [4,4,4,9,2,4]\nOutput: 4\nExplanation: 4 is the even element appears the most.\n\nExample 3:\n\nInput: nums = [29,47,21,41,13,37,25,7]\nOutput: -1\nExplanation: There is no even element.\n\nConstraints:\n\n- 1 <= nums.length <= 2000\n- 0 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [29, 47, 21, 41, 13, 37, 25, 7]) == -1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == -1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4]) == 4\n    assert candidate(nums = [8, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6]) == 8\n    assert candidate(nums = [10, 20, 20, 10, 10, 20, 20, 10]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n    assert candidate(nums = [1, 3, 5, 7, 9]) == -1\n    assert candidate(nums = [10, 20, 20, 10, 30, 30, 30, 20, 20]) == 20\n    assert candidate(nums = [10, 20, 20, 10, 10, 20, 20]) == 20\n    assert candidate(nums = [6, 6, 6, 6, 8, 8, 8, 8, 10, 10]) == 6\n    assert candidate(nums = [6, 6, 6, 8, 8, 8, 10, 10, 10]) == 6\n    assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4]) == 2\n    assert candidate(nums = [0, 1, 2, 2, 4, 4, 1]) == 2\n    assert candidate(nums = [2]) == 2\n    assert candidate(nums = [6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8]) == 8\n    assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9, 11]) == -1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13]) == -1\n    assert candidate(nums = [6, 6, 6, 8, 8, 8, 10, 10]) == 6\n    assert candidate(nums = [6, 6, 8, 8, 8, 10, 10, 10, 10]) == 10\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n    assert candidate(nums = [0]) == 0\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8]) == 8\n    assert candidate(nums = [100000, 100000, 99998, 99998, 99996]) == 99998\n    assert candidate(nums = [10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30]) == 10\n    assert candidate(nums = [4, 4, 4, 9, 2, 4]) == 4\n    assert candidate(nums = [100000, 100000, 99998, 99998, 99998]) == 99998\n    assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2]) == 0\n    assert candidate(nums = [2, 2, 2, 2, 2]) == 2\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 24, 26, 28, 30]) == 2\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 10\n    assert candidate(nums = [99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131]) == -1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 2\n    assert candidate(nums = [0, 0, 0, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8]) == 8\n    assert candidate(nums = [6, 6, 8, 8, 8, 10, 10, 10, 10, 12, 12, 12, 12, 12]) == 12\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 10000, 10000, 10000]) == 10000\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 2\n    assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 200, 300, 300, 300, 300]) == 300\n    assert candidate(nums = [0, 0, 0, 2, 2, 2, 4, 4, 4, 6, 6, 8, 8, 8, 8]) == 8\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [100000, 100000, 100000, 99998, 99998, 99996, 99996, 99996, 99994, 99994]) == 99996\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == 6\n    assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n    assert candidate(nums = [1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500]) == 1500\n    assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 4\n    assert candidate(nums = [99998, 99998, 99998, 99996, 99996, 99994, 99994, 99994, 99992, 99992, 99992, 99992]) == 99992\n    assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 50000\n    assert candidate(nums = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 12\n    assert candidate(nums = [5, 3, 1, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == -1\n    assert candidate(nums = [8, 8, 8, 8, 10, 10, 10, 12, 12, 14, 14, 14, 16, 16, 16, 16]) == 8\n    assert candidate(nums = [100000, 99998, 99998, 99996, 99996, 99996, 99994, 99994]) == 99996\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100, 100]) == 100\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 4, 6, 8, 10]) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n    assert candidate(nums = [0, 0, 2, 2, 2, 4, 4, 4, 4, 6, 6]) == 4\n    assert candidate(nums = [2, 2, 4, 4, 4, 6, 6, 6, 6, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10]) == 10\n    assert candidate(nums = [100000, 100000, 100000, 99998, 99998, 99998, 99996, 99996, 99994]) == 99998\n    assert candidate(nums = [18, 18, 18, 18, 20, 20, 20, 20, 22, 22, 22, 22, 24, 24, 24, 24]) == 18\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 2, 4, 6, 8, 10]) == 2\n    assert candidate(nums = [2, 2, 2, 4, 4, 4, 6, 6, 6, 8, 8, 8, 10, 10, 10, 12, 12, 12, 14, 14, 14, 16, 16, 16, 18, 18, 18, 20, 20, 20, 22, 22, 22, 24, 24, 24, 26, 26, 26, 28, 28, 28, 30, 30, 30, 32, 32, 32, 34, 34, 34, 36, 36, 36, 38, 38, 38, 40, 40, 40, 42, 42, 42, 44, 44, 44, 46, 46, 46, 48, 48, 48, 50, 50, 50, 52, 52, 52, 54, 54, 54, 56, 56, 56, 58, 58, 58, 60, 60, 60, 62, 62, 62, 64, 64, 64, 66, 66, 66, 68, 68, 68, 70, 70, 70, 72, 72, 72, 74, 74, 74, 76, 76, 76, 78, 78, 78, 80, 80, 80, 82, 82, 82, 84, 84, 84, 86, 86, 86, 88, 88, 88, 90, 90, 90, 92, 92, 92, 94, 94, 94, 96, 96, 96, 98, 98, 98]) == 2\n    assert candidate(nums = [6, 8, 10, 8, 6, 6, 8, 10, 10, 10, 10, 8]) == 10\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 2\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n    assert candidate(nums = [1, 1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17, 17, 19, 19]) == -1\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 4\n    assert candidate(nums = [10, 10, 10, 20, 20, 30, 30, 40, 40, 40, 50, 50, 50, 50]) == 50\n    assert candidate(nums = [100000, 100000, 99998, 99998, 99998, 99996, 99996, 99996, 99996]) == 99996\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 2\n    assert candidate(nums = [100000, 50000, 100000, 50000, 20000, 20000, 20000, 20000]) == 20000\n    assert candidate(nums = [2, 4, 6, 8, 10, 2, 4, 6, 8, 10, 2, 4, 6, 8, 10, 2, 4, 6, 8, 10, 2, 4, 6, 8, 10]) == 2\n    assert candidate(nums = [8, 6, 8, 8, 6, 6, 8, 8, 6, 6, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6]) == 6\n    assert candidate(nums = [10, 20, 10, 30, 20, 20, 40, 40, 40, 40, 60, 60]) == 40\n    assert candidate(nums = [18, 18, 18, 20, 20, 20, 22, 22, 22, 24, 24, 24, 26, 26, 26, 28, 28, 28, 30, 30, 30]) == 18\n    assert candidate(nums = [8, 3, 8, 6, 8, 5, 6, 6, 2, 2, 2, 10, 10, 10, 10]) == 10\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60]) == 2\n    assert candidate(nums = [0, 2, 2, 4, 4, 4, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8]) == 8\n    assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200]) == 4\n    assert candidate(nums = [10, 10, 10, 12, 12, 14, 14, 14, 16, 16, 16, 16, 18, 18, 18, 18, 18, 20, 20, 20, 20, 20]) == 18\n    assert candidate(nums = [20000, 20000, 19998, 19998, 19996, 19996, 19994, 19994, 19992, 19992]) == 19992\n    assert candidate(nums = [2, 2, 4, 4, 4, 6, 6, 6, 8, 8, 8, 8, 10, 10, 10, 10, 10]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 12, 12, 14, 16, 18, 20]) == 10\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 2, 4, 6, 8, 10]) == 2\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40]) == 40\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18]) == 8\n    assert candidate(nums = [20000, 19998, 19998, 19996, 19996, 19996, 19994, 19994, 19992, 19992, 19992, 19992]) == 19992\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]) == 2\n    assert candidate(nums = [2, 2, 2, 2, 2, 4, 4, 4, 4, 6, 6, 6, 8, 8, 10, 10, 10, 10, 10, 10]) == 10\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 10, 10, 10, 10]) == 10\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n    assert candidate(nums = [2, 4, 4, 6, 6, 6, 8, 8, 8, 8, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12]) == 12\n    assert candidate(nums = [100000, 100000, 99998, 99998, 99998, 99996, 99996, 99996, 99994, 99994, 99994, 99994]) == 99994\n    assert candidate(nums = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30, 32, 32, 34, 34, 36, 36, 38, 38, 40, 40, 42, 42, 44, 44, 46, 46, 48, 48, 50, 50, 52, 52, 54, 54, 56, 56, 58, 58, 60, 60, 62, 62, 64, 64, 66, 66, 68, 68, 70, 70, 72, 72, 74, 74, 76, 76, 78, 78, 80, 80, 82, 82, 84, 84, 86, 86, 88, 88, 90, 90, 92, 92, 94, 94, 96, 96, 98, 98, 100, 100]) == 2\n    assert candidate(nums = [1000, 2000, 1000, 3000, 4000, 4000, 5000, 5000, 5000, 5000, 6000, 6000, 6000, 6000, 6000]) == 6000\n    assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 4, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 6]) == 0\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]) == 2\n    assert candidate(nums = [100000, 100000, 100000, 50000, 50000, 50000, 50000, 25000, 25000]) == 50000\n    assert candidate(nums = [42, 42, 42, 42, 44, 44, 44, 44, 46, 46, 46, 46]) == 42\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 8\n    assert candidate(nums = [8, 8, 8, 6, 6, 6, 4, 4, 4, 4]) == 4\n    assert candidate(nums = [5000, 4000, 3000, 2000, 1000, 1000, 2000, 3000, 4000, 5000, 5000, 4000, 3000, 2000, 1000]) == 1000\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 200, 200, 300, 300, 300, 400, 400, 400, 400, 500, 500, 500, 500, 500, 600, 600, 600, 600, 600, 600, 700, 700, 700, 700, 700, 700, 700, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 1000\n", "comparison": "exact"}, "public_tests": ["[0,1,2,2,4,4,1]", "[4,4,4,9,2,4]", "[29,47,21,41,13,37,25,7]"], "hints": ["Could you count the frequency of each even element in the array?", "Would a hashmap help?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().mostFrequentEven", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:31+00:00", "tests_total": 110, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "hash-table", "counting"]}, "language": "python", "interface": {"raw_signature": "def mostFrequentEven(self, nums: list[int]) -> int:", "container": "Solution", "callable": "mostFrequentEven", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2405, "task_id": "optimal-partition-of-string", "difficulty": "Medium", "problem_description": "Given a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears in a single substring more than once.\n\nReturn the minimum number of substrings in such a partition.\n\nNote that each character should belong to exactly one substring in a partition.\n\nExample 1:\n\nInput: s = \"abacaba\"\nOutput: 4\nExplanation:\nTwo possible partitions are (\"a\",\"ba\",\"cab\",\"a\") and (\"ab\",\"a\",\"ca\",\"ba\").\nIt can be shown that 4 is the minimum number of substrings needed.\n\nExample 2:\n\nInput: s = \"ssssss\"\nOutput: 6\nExplanation:\nThe only valid partition is (\"s\",\"s\",\"s\",\"s\",\"s\",\"s\").\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of only English lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"abcdefg\") == 1\n    assert candidate(s = \"abac\") == 2\n    assert candidate(s = \"abcdabcdeabcdefabcdefg\") == 4\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 44\n    assert candidate(s = \"abababab\") == 4\n    assert candidate(s = \"aaaaa\") == 5\n    assert candidate(s = \"a\") == 1\n    assert candidate(s = \"optimal\") == 1\n    assert candidate(s = \"abcabcabc\") == 3\n    assert candidate(s = \"ssssss\") == 6\n    assert candidate(s = \"abcabcabcabc\") == 4\n    assert candidate(s = \"ab\") == 1\n    assert candidate(s = \"partition\") == 2\n    assert candidate(s = \"racecar\") == 2\n    assert candidate(s = \"xyzxyzxyz\") == 3\n    assert candidate(s = \"abcadef\") == 2\n    assert candidate(s = \"banana\") == 3\n    assert candidate(s = \"abc\") == 1\n    assert candidate(s = \"pqrspqrspqrs\") == 3\n    assert candidate(s = \"aabbccddeeff\") == 7\n    assert candidate(s = \"abcdeabcde\") == 2\n    assert candidate(s = \"aabbcc\") == 4\n    assert candidate(s = \"unique\") == 2\n    assert candidate(s = \"characters\") == 2\n    assert candidate(s = \"aaaaaaaaa\") == 9\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 27\n    assert candidate(s = \"abacaba\") == 4\n    assert candidate(s = \"abca\") == 2\n    assert candidate(s = \"zxyxzyxz\") == 3\n    assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzxy\") == 40\n    assert candidate(s = \"abcdeabcdeabcdeabcdeabcde\") == 5\n    assert candidate(s = \"xyxxyxyxyxxyxyxyxyxyx\") == 12\n    assert candidate(s = \"repeatrepeatrepeatrepeatrepeat\") == 10\n    assert candidate(s = \"uniquecharacterswithoutrepeating\") == 6\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 23\n    assert candidate(s = \"abacabadabacabaeabacabafabacabadabacabaeabacabaf\") == 24\n    assert candidate(s = \"abacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabaf\") == 72\n    assert candidate(s = \"abacabadabacabad\") == 8\n    assert candidate(s = \"aaaaabbbbbccccdddd\") == 15\n    assert candidate(s = \"abcdabcdeabcdabcdef\") == 4\n    assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiijjjjjjkkkkkkklllllllmmmmmmmnnnnnnnooooooooppppppppqqqqqqqqrrrrrrrrssssssssttttttttuuuuuuuuvvvvvvvvwwwwwwwwxxxxxxxxxyyyyyyyyzzzzzzzz\") == 145\n    assert candidate(s = \"longerstringwithoutrepeats\") == 5\n    assert candidate(s = \"abcba\") == 2\n    assert candidate(s = \"mississippimississippimississippi\") == 15\n    assert candidate(s = \"aaaaabbbbbcccccdddddeeeeeeaaaaabbbbbcccccdddddeeeeeeaaaaabbbbbcccccdddddeeeeeeaaaaabbbbbcccccdddddeeeeee\") == 85\n    assert candidate(s = \"aaaaabbbbbcccccdddddeeeee\") == 21\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 30\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 16\n    assert candidate(s = \"abracadabraabracadabraabracadabra\") == 15\n    assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeffffffffgggggggghhhhhhhh\") == 59\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == 29\n    assert candidate(s = \"noon\") == 2\n    assert candidate(s = \"abcabcabcabcabcabc\") == 6\n    assert candidate(s = \"thisisaverylongstringthatwilltestthealgorithm\") == 9\n    assert candidate(s = \"hellohellohellohellohellohello\") == 12\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzz\") == 24\n    assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 4\n    assert candidate(s = \"abcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcba\") == 20\n    assert candidate(s = \"abacdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 3\n    assert candidate(s = \"abacaxbabax\") == 5\n    assert candidate(s = \"aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee\") == 36\n    assert candidate(s = \"nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn\") == 40\n    assert candidate(s = \"abababababababababab\") == 10\n    assert candidate(s = \"abacabadabacaba\") == 8\n    assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 36\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 3\n    assert candidate(s = \"thecuriouscaseofjeffersonraisethetrapdoor\") == 8\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == 28\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 70\n    assert candidate(s = \"aaaaabbbbbccccddddeeeeffffgggg\") == 24\n    assert candidate(s = \"xyzzysabcabcabcabcabcabcabcabc\") == 9\n    assert candidate(s = \"abcdefghijklaaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 38\n    assert candidate(s = \"abracadabraabracadabra\") == 10\n    assert candidate(s = \"ababcbabcab\") == 5\n    assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 28\n    assert candidate(s = \"mnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 61\n    assert candidate(s = \"abacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabaf\") == 36\n    assert candidate(s = \"aabbccddeeffaabbccddeeff\") == 13\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 40\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 1\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 9\n    assert candidate(s = \"thisisanexamplestringthatneedstobepartitionedproperly\") == 9\n    assert candidate(s = \"abacabadabacabaeabacabaf\") == 12\n    assert candidate(s = \"abacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabaf\") == 60\n    assert candidate(s = \"aabcbcbcbaabcabcbcbcba\") == 10\n    assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrs\") == 4\n    assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 2\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\") == 8\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 5\n    assert candidate(s = \"aaaaaabbcccddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooo\") == 43\n    assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 8\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 2\n    assert candidate(s = \"abcdabcdaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 29\n    assert candidate(s = \"abacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabafabacabadabacabaeabacabaf\") == 48\n    assert candidate(s = \"ppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxxyyyyzzzz\") == 35\n    assert candidate(s = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 29\n    assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzz\") == 12\n    assert candidate(s = \"mississippi\") == 5\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzz\") == 43\n    assert candidate(s = \"abcabcabcabcabc\") == 5\n    assert candidate(s = \"aaaaabbbbbbbaaaabbbbbbbaaaabbbbbbbaaaabbbbb\") == 36\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 50\n", "comparison": "exact"}, "public_tests": ["\"abacaba\"", "\"ssssss\""], "hints": ["Try to come up with a greedy approach.", "From left to right, extend every substring in the partition as much as possible."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().partitionString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:34+00:00", "tests_total": 103, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def partitionString(self, s: str) -> int:", "container": "Solution", "callable": "partitionString", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2406, "task_id": "divide-intervals-into-minimum-number-of-groups", "difficulty": "Medium", "problem_description": "You are given a 2D integer array intervals where intervals[i] = [left_i, right_i] represents the inclusive interval [left_i, right_i].\n\nYou have to divide the intervals into one or more groups such that each interval is in exactly one group, and no two intervals that are in the same group intersect each other.\n\nReturn the minimum number of groups you need to make.\n\nTwo intervals intersect if there is at least one common number between them. For example, the intervals [1, 5] and [5, 8] intersect.\n\nExample 1:\n\nInput: intervals = [[5,10],[6,8],[1,5],[2,3],[1,10]]\nOutput: 3\nExplanation: We can divide the intervals into the following groups:\n- Group 1: [1, 5], [6, 8].\n- Group 2: [2, 3], [5, 10].\n- Group 3: [1, 10].\nIt can be proven that it is not possible to divide the intervals into fewer than 3 groups.\n\nExample 2:\n\nInput: intervals = [[1,3],[5,6],[8,10],[11,13]]\nOutput: 1\nExplanation: None of the intervals overlap, so we can put all of them in one group.\n\nConstraints:\n\n- 1 <= intervals.length <= 10^5\n- intervals[i].length == 2\n- 1 <= left_i <= right_i <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8]]) == 1\n    assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 2\n    assert candidate(intervals = [[1, 1000000]]) == 1\n    assert candidate(intervals = [[5, 10], [6, 8], [1, 5], [2, 3], [1, 10]]) == 3\n    assert candidate(intervals = [[1, 3], [5, 6], [8, 10], [11, 13]]) == 1\n    assert candidate(intervals = [[1, 100], [50, 60], [60, 90]]) == 3\n    assert candidate(intervals = [[1, 10], [10, 20], [20, 30]]) == 2\n    assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 1\n    assert candidate(intervals = [[1, 2], [1, 3], [1, 4], [1, 5]]) == 4\n    assert candidate(intervals = [[1, 5], [2, 9], [3, 7], [4, 10]]) == 4\n    assert candidate(intervals = [[1, 100], [2, 99], [3, 98], [4, 97]]) == 4\n    assert candidate(intervals = [[5, 10], [11, 15], [16, 20], [21, 25], [1, 5], [6, 10], [11, 15], [16, 20], [21, 25]]) == 2\n    assert candidate(intervals = [[5, 15], [10, 20], [25, 30], [5, 10], [15, 25], [20, 25]]) == 3\n    assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8]]) == 3\n    assert candidate(intervals = [[1, 10], [2, 5], [3, 8], [4, 9], [5, 10], [6, 11]]) == 5\n    assert candidate(intervals = [[1, 10], [10, 20], [20, 30], [5, 15], [15, 25]]) == 3\n    assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 2\n    assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 3\n    assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 2\n    assert candidate(intervals = [[1000, 2000], [1500, 2500], [2000, 3000], [2500, 3500], [3000, 4000], [3500, 4500]]) == 3\n    assert candidate(intervals = [[1, 50], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44], [8, 43], [9, 42], [10, 41], [11, 40], [12, 39], [13, 38], [14, 37], [15, 36], [16, 35], [17, 34], [18, 33], [19, 32], [20, 31], [21, 30], [22, 29], [23, 28], [24, 27], [25, 26]]) == 25\n    assert candidate(intervals = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == 5\n    assert candidate(intervals = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]]) == 5\n    assert candidate(intervals = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]]) == 10\n    assert candidate(intervals = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11], [6, 13], [7, 15]]) == 5\n    assert candidate(intervals = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [35, 45], [40, 50]]) == 3\n    assert candidate(intervals = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 5\n    assert candidate(intervals = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [35, 45], [40, 50], [45, 55], [50, 60], [55, 65]]) == 3\n    assert candidate(intervals = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [1, 50], [51, 100]]) == 11\n    assert candidate(intervals = [[1, 500000], [500001, 1000000], [2, 499999], [500002, 999998], [3, 499998], [500003, 999997]]) == 3\n    assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 5\n    assert candidate(intervals = [[1, 500000], [500001, 1000000], [1, 500000], [500001, 1000000]]) == 2\n    assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 1\n    assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == 3\n    assert candidate(intervals = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == 10\n    assert candidate(intervals = [[1, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50]]) == 2\n    assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]]) == 5\n    assert candidate(intervals = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 10\n    assert candidate(intervals = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991]]) == 10\n    assert candidate(intervals = [[5, 10], [15, 20], [25, 30], [10, 15], [20, 25], [30, 35], [15, 20], [25, 30], [35, 40], [20, 25]]) == 4\n    assert candidate(intervals = [[1, 10], [11, 20], [1, 10], [11, 20], [1, 10], [11, 20]]) == 3\n    assert candidate(intervals = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15]]) == 4\n    assert candidate(intervals = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 9\n    assert candidate(intervals = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30], [1, 10], [6, 15], [11, 20], [16, 25]]) == 3\n    assert candidate(intervals = [[1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10]]) == 10\n    assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 2\n    assert candidate(intervals = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19]]) == 2\n    assert candidate(intervals = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997]]) == 4\n    assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 5\n    assert candidate(intervals = [[1, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30]]) == 2\n    assert candidate(intervals = [[5, 10], [15, 20], [25, 30], [5, 20], [10, 25], [15, 30], [5, 30]]) == 5\n    assert candidate(intervals = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19]]) == 10\n    assert candidate(intervals = [[1, 100000], [100000, 200000], [200000, 300000], [300000, 400000], [400000, 500000]]) == 2\n    assert candidate(intervals = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]) == 2\n    assert candidate(intervals = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7]]) == 6\n    assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350], [300, 400]]) == 3\n    assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [1, 5], [5, 9], [9, 13]]) == 3\n    assert candidate(intervals = [[1, 3], [2, 5], [4, 7], [6, 9], [8, 11], [10, 13], [12, 15]]) == 2\n    assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350]]) == 3\n    assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 3\n    assert candidate(intervals = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]]) == 9\n    assert candidate(intervals = [[1, 10], [1, 20], [1, 30], [1, 40], [1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [1, 100]]) == 10\n    assert candidate(intervals = [[1, 10], [11, 20], [1, 10], [11, 20], [1, 10], [11, 20], [1, 10], [11, 20]]) == 4\n    assert candidate(intervals = [[1, 2], [2, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30]]) == 2\n    assert candidate(intervals = [[1, 5], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 3\n    assert candidate(intervals = [[1, 1000000], [1, 1000000], [1, 1000000]]) == 3\n    assert candidate(intervals = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]]) == 6\n    assert candidate(intervals = [[1, 3], [1, 3], [1, 3], [2, 4], [2, 4], [2, 4], [3, 5], [3, 5], [3, 5], [4, 6], [4, 6], [4, 6], [5, 7], [5, 7], [5, 7]]) == 9\n    assert candidate(intervals = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997], [5, 999996]]) == 5\n    assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]]) == 3\n    assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == 2\n    assert candidate(intervals = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50]]) == 2\n    assert candidate(intervals = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996]]) == 5\n    assert candidate(intervals = [[1, 1000], [500, 1500], [1000, 2000], [1500, 2500], [2000, 3000], [2500, 3500], [3000, 4000]]) == 3\n    assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 6\n    assert candidate(intervals = [[1, 3], [2, 6], [8, 10], [15, 18], [3, 5], [6, 9], [12, 14]]) == 3\n    assert candidate(intervals = [[1, 10], [11, 20], [21, 30], [31, 40], [1, 10], [11, 20], [21, 30], [31, 40], [1, 10]]) == 3\n    assert candidate(intervals = [[10, 20], [20, 30], [30, 40], [10, 20], [20, 30], [30, 40], [10, 30], [20, 40], [30, 50]]) == 7\n    assert candidate(intervals = [[1, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35]]) == 2\n    assert candidate(intervals = [[1, 10], [1, 10], [1, 10], [10, 20], [10, 20], [10, 20]]) == 6\n    assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 6\n    assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7]]) == 3\n    assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]]) == 5\n    assert candidate(intervals = [[1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3]]) == 10\n    assert candidate(intervals = [[1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15]]) == 6\n    assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [200, 300]]) == 3\n    assert candidate(intervals = [[5, 10], [15, 20], [25, 30], [35, 40], [10, 15], [20, 25], [30, 35]]) == 2\n    assert candidate(intervals = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [1, 50]]) == 3\n    assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300]]) == 3\n    assert candidate(intervals = [[1, 20], [5, 15], [10, 25], [15, 30], [20, 35]]) == 4\n    assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]]) == 1\n    assert candidate(intervals = [[1, 3], [4, 7], [8, 10], [2, 5], [6, 9], [11, 13], [1, 4], [5, 8], [9, 12]]) == 3\n    assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == 2\n    assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10], [2, 9]]) == 3\n", "comparison": "exact"}, "public_tests": ["[[5,10],[6,8],[1,5],[2,3],[1,10]]", "[[1,3],[5,6],[8,10],[11,13]]"], "hints": ["Can you find a different way to describe the question?", "The minimum number of groups we need is equivalent to the maximum number of intervals that overlap at some point. How can you find that?"], "metadata": {"canonical_parameter_names": ["intervals"], "leetcode_dataset_entry_point": "Solution().minGroups", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:36+00:00", "tests_total": 97, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "two-pointers", "greedy", "sorting", "heap-priority-queue", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minGroups(self, intervals: list[list[int]]) -> int:", "container": "Solution", "callable": "minGroups", "parameters": [{"name": "intervals", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2407, "task_id": "longest-increasing-subsequence-ii", "difficulty": "Hard", "problem_description": "You are given an integer array nums and an integer k.\n\nFind the longest subsequence of nums that meets the following requirements:\n\n- The subsequence is strictly increasing and\n- The difference between adjacent elements in the subsequence is at most k.\n\nReturn the length of the longest subsequence that meets the requirements.\n\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n\nExample 1:\n\nInput: nums = [4,2,1,4,3,4,5,8,15], k = 3\nOutput: 5\nExplanation:\nThe longest subsequence that meets the requirements is [1,3,4,5,8].\nThe subsequence has a length of 5, so we return 5.\nNote that the subsequence [1,3,4,5,8,15] does not meet the requirements because 15 - 8 = 7 is larger than 3.\n\nExample 2:\n\nInput: nums = [7,4,5,1,8,12,4,7], k = 5\nOutput: 4\nExplanation:\nThe longest subsequence that meets the requirements is [4,5,8,12].\nThe subsequence has a length of 4, so we return 4.\n\nExample 3:\n\nInput: nums = [1,5], k = 1\nOutput: 1\nExplanation:\nThe longest subsequence that meets the requirements is [1].\nThe subsequence has a length of 1, so we return 1.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i], k <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18],k = 10) == 3\n    assert candidate(nums = [5, 4, 3, 2, 1],k = 2) == 1\n    assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18],k = 5) == 3\n    assert candidate(nums = [7, 4, 5, 1, 8, 12, 4, 7],k = 5) == 4\n    assert candidate(nums = [5, 4, 3, 2, 1],k = 1) == 1\n    assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18],k = 2) == 2\n    assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18],k = 4) == 3\n    assert candidate(nums = [9, 7, 5, 3, 1],k = 2) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9],k = 2) == 5\n    assert candidate(nums = [4, 2, 1, 4, 3, 4, 5, 8, 15],k = 3) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 5\n    assert candidate(nums = [1, 5],k = 1) == 1\n    assert candidate(nums = [5, 8, 7, 1, 9, 1, 5, 10, 4, 3, 2, 1],k = 2) == 4\n    assert candidate(nums = [3, 1, 2, 4, 6, 5, 9, 7, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20],k = 3) == 12\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 4) == 15\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == 20\n    assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 9) == 2\n    assert candidate(nums = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 19\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 10\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == 1\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 11\n    assert candidate(nums = [100, 200, 300, 400, 500, 401, 402, 403, 501, 502, 503, 504],k = 10) == 5\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 1) == 2\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 15) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 1) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 10\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == 10\n    assert candidate(nums = [5, 8, 7, 1, 9, 12, 10, 13, 14, 15],k = 4) == 7\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 2) == 20\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4],k = 4) == 6\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 10\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 10\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 10\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9],k = 2) == 8\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 10\n    assert candidate(nums = [1, 4, 3, 5, 6, 2, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19],k = 4) == 11\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 20\n    assert candidate(nums = [9, 1, 4, 7, 3, 2, 5, 8, 6],k = 3) == 4\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 1\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2],k = 1) == 3\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9) == 1\n    assert candidate(nums = [20, 10, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 10\n    assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 3) == 30\n    assert candidate(nums = [1, 6, 7, 8, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 11, 12],k = 3) == 10\n    assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8],k = 2) == 8\n    assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996],k = 99999) == 6\n    assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4],k = 1) == 3\n    assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 9) == 2\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 2) == 15\n    assert candidate(nums = [2, 3, 1, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 3) == 13\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 20\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 5) == 30\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 14) == 15\n    assert candidate(nums = [3, 1, 5, 2, 6, 4, 7],k = 3) == 4\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == 16\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 1\n    assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6],k = 3) == 6\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 10) == 1\n    assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 4) == 2\n    assert candidate(nums = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 10\n    assert candidate(nums = [3, 1, 2, 5, 4, 8, 7, 6, 10, 9],k = 3) == 5\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 10) == 1\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 1) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == 20\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 100) == 10\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 1\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],k = 10) == 1\n    assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985],k = 5) == 1\n    assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100, 92, 83, 74, 65, 56, 47, 38, 29],k = 9) == 12\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 10\n    assert candidate(nums = [3, 1, 5, 4, 7, 6, 9, 8, 11, 10],k = 2) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 15\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 2) == 20\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 1) == 2\n    assert candidate(nums = [3, 10, 2, 1, 20, 15, 25, 28, 30, 100],k = 10) == 6\n    assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5],k = 10) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 10\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10],k = 5) == 1\n    assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 4) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 2) == 40\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 20\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 10\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 90) == 10\n    assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 16\n    assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93],k = 90) == 9\n    assert candidate(nums = [5, 3, 4, 8, 9, 10, 20, 30, 15, 25, 35, 45, 55, 65, 75],k = 20) == 12\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 10\n    assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6],k = 2) == 6\n    assert candidate(nums = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10],k = 3) == 10\n    assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58],k = 2) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 2) == 20\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],k = 3) == 1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 10\n    assert candidate(nums = [4, 3, 5, 4, 7, 6, 8, 9, 10, 11, 12],k = 3) == 8\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1) == 1\n    assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 100) == 1\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 1\n    assert candidate(nums = [4, 3, 2, 1, 100, 101, 102, 103, 104],k = 3) == 5\n    assert candidate(nums = [3, 10, 2, 1, 20, 1, 15, 5, 17, 6, 8, 9, 11, 13, 14],k = 4) == 8\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5],k = 5) == 20\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],k = 3) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 50) == 15\n", "comparison": "exact"}, "public_tests": ["[4,2,1,4,3,4,5,8,15]\n3", "[7,4,5,1,8,12,4,7]\n5", "[1,5]\n1"], "hints": ["We can use dynamic programming. Let dp[i][val] be the answer using only the first i + 1 elements, and the last element in the subsequence is equal to val.", "The only value that might change between dp[i - 1] and dp[i] are dp[i - 1][val] and dp[i][val].", "Try using dp[i - 1] and the fact that the second last element in the subsequence has to fall within a range to calculate dp[i][val].", "We can use a segment tree to find the maximum value in dp[i - 1] within a certain range."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().lengthOfLIS", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:38+00:00", "tests_total": 110, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "divide-and-conquer", "dynamic-programming", "binary-indexed-tree", "segment-tree", "queue", "monotonic-queue"]}, "language": "python", "interface": {"raw_signature": "def lengthOfLIS(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "lengthOfLIS", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2409, "task_id": "count-days-spent-together", "difficulty": "Easy", "problem_description": "Alice and Bob are traveling to Rome for separate business meetings.\n\nYou are given 4 strings arriveAlice, leaveAlice, arriveBob, and leaveBob. Alice will be in the city from the dates arriveAlice to leaveAlice (inclusive), while Bob will be in the city from the dates arriveBob to leaveBob (inclusive). Each will be a 5-character string in the format \"MM-DD\", corresponding to the month and day of the date.\n\nReturn the total number of days that Alice and Bob are in Rome together.\n\nYou can assume that all dates occur in the same calendar year, which is not a leap year. Note that the number of days per month can be represented as: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31].\n\nExample 1:\n\nInput: arriveAlice = \"08-15\", leaveAlice = \"08-18\", arriveBob = \"08-16\", leaveBob = \"08-19\"\nOutput: 3\nExplanation: Alice will be in Rome from August 15 to August 18. Bob will be in Rome from August 16 to August 19. They are both in Rome together on August 16th, 17th, and 18th, so the answer is 3.\n\nExample 2:\n\nInput: arriveAlice = \"10-01\", leaveAlice = \"10-31\", arriveBob = \"11-01\", leaveBob = \"12-31\"\nOutput: 0\nExplanation: There is no day when Alice and Bob are in Rome together, so we return 0.\n\nConstraints:\n\n- All dates are provided in the format \"MM-DD\".\n- Alice and Bob's arrival dates are earlier than or equal to their leaving dates.\n- The given dates are valid dates of a non-leap year.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(arriveAlice = \"03-10\",leaveAlice = \"05-20\",arriveBob = \"04-01\",leaveBob = \"04-30\") == 30\n    assert candidate(arriveAlice = \"06-15\",leaveAlice = \"06-20\",arriveBob = \"06-18\",leaveBob = \"06-25\") == 3\n    assert candidate(arriveAlice = \"10-01\",leaveAlice = \"10-31\",arriveBob = \"11-01\",leaveBob = \"12-31\") == 0\n    assert candidate(arriveAlice = \"01-01\",leaveAlice = \"12-31\",arriveBob = \"01-01\",leaveBob = \"12-31\") == 365\n    assert candidate(arriveAlice = \"08-15\",leaveAlice = \"08-18\",arriveBob = \"08-16\",leaveBob = \"08-19\") == 3\n    assert candidate(arriveAlice = \"12-20\",leaveAlice = \"12-31\",arriveBob = \"12-25\",leaveBob = \"12-30\") == 6\n    assert candidate(arriveAlice = \"05-24\",leaveAlice = \"07-24\",arriveBob = \"07-25\",leaveBob = \"08-25\") == 0\n    assert candidate(arriveAlice = \"07-20\",leaveAlice = \"08-15\",arriveBob = \"07-25\",leaveBob = \"08-10\") == 17\n    assert candidate(arriveAlice = \"07-01\",leaveAlice = \"08-01\",arriveBob = \"07-15\",leaveBob = \"07-30\") == 16\n    assert candidate(arriveAlice = \"07-10\",leaveAlice = \"07-20\",arriveBob = \"07-15\",leaveBob = \"07-25\") == 6\n    assert candidate(arriveAlice = \"01-01\",leaveAlice = \"01-31\",arriveBob = \"01-01\",leaveBob = \"01-31\") == 31\n    assert candidate(arriveAlice = \"03-10\",leaveAlice = \"03-10\",arriveBob = \"03-10\",leaveBob = \"03-10\") == 1\n    assert candidate(arriveAlice = \"06-15\",leaveAlice = \"06-15\",arriveBob = \"06-15\",leaveBob = \"06-15\") == 1\n    assert candidate(arriveAlice = \"01-01\",leaveAlice = \"01-31\",arriveBob = \"01-15\",leaveBob = \"01-20\") == 6\n    assert candidate(arriveAlice = \"03-14\",leaveAlice = \"03-14\",arriveBob = \"03-14\",leaveBob = \"03-14\") == 1\n    assert candidate(arriveAlice = \"06-01\",leaveAlice = \"06-30\",arriveBob = \"05-25\",leaveBob = \"06-10\") == 10\n    assert candidate(arriveAlice = \"10-01\",leaveAlice = \"10-20\",arriveBob = \"09-25\",leaveBob = \"10-25\") == 20\n    assert candidate(arriveAlice = \"11-15\",leaveAlice = \"12-31\",arriveBob = \"12-01\",leaveBob = \"12-31\") == 31\n    assert candidate(arriveAlice = \"04-10\",leaveAlice = \"06-10\",arriveBob = \"05-01\",leaveBob = \"06-30\") == 41\n    assert candidate(arriveAlice = \"01-10\",leaveAlice = \"02-20\",arriveBob = \"02-15\",leaveBob = \"03-25\") == 6\n    assert candidate(arriveAlice = \"09-15\",leaveAlice = \"09-15\",arriveBob = \"09-15\",leaveBob = \"09-15\") == 1\n    assert candidate(arriveAlice = \"12-20\",leaveAlice = \"12-31\",arriveBob = \"12-15\",leaveBob = \"01-10\") == 0\n    assert candidate(arriveAlice = \"05-05\",leaveAlice = \"07-05\",arriveBob = \"05-05\",leaveBob = \"05-05\") == 1\n    assert candidate(arriveAlice = \"02-28\",leaveAlice = \"03-15\",arriveBob = \"03-01\",leaveBob = \"03-31\") == 15\n    assert candidate(arriveAlice = \"08-15\",leaveAlice = \"09-15\",arriveBob = \"09-15\",leaveBob = \"10-15\") == 1\n    assert candidate(arriveAlice = \"03-05\",leaveAlice = \"03-20\",arriveBob = \"03-15\",leaveBob = \"03-25\") == 6\n    assert candidate(arriveAlice = \"03-15\",leaveAlice = \"03-20\",arriveBob = \"03-10\",leaveBob = \"03-14\") == 0\n    assert candidate(arriveAlice = \"06-01\",leaveAlice = \"06-30\",arriveBob = \"06-15\",leaveBob = \"06-25\") == 11\n    assert candidate(arriveAlice = \"02-28\",leaveAlice = \"03-10\",arriveBob = \"03-01\",leaveBob = \"03-15\") == 10\n    assert candidate(arriveAlice = \"01-15\",leaveAlice = \"01-15\",arriveBob = \"01-15\",leaveBob = \"01-15\") == 1\n    assert candidate(arriveAlice = \"01-01\",leaveAlice = \"01-31\",arriveBob = \"01-15\",leaveBob = \"02-14\") == 17\n    assert candidate(arriveAlice = \"12-15\",leaveAlice = \"12-15\",arriveBob = \"12-16\",leaveBob = \"12-16\") == 0\n    assert candidate(arriveAlice = \"11-11\",leaveAlice = \"11-11\",arriveBob = \"11-11\",leaveBob = \"11-11\") == 1\n    assert candidate(arriveAlice = \"11-20\",leaveAlice = \"12-15\",arriveBob = \"11-25\",leaveBob = \"12-25\") == 21\n    assert candidate(arriveAlice = \"11-11\",leaveAlice = \"11-25\",arriveBob = \"11-20\",leaveBob = \"12-10\") == 6\n    assert candidate(arriveAlice = \"04-30\",leaveAlice = \"05-30\",arriveBob = \"04-15\",leaveBob = \"05-15\") == 16\n    assert candidate(arriveAlice = \"07-20\",leaveAlice = \"08-10\",arriveBob = \"07-25\",leaveBob = \"08-05\") == 12\n    assert candidate(arriveAlice = \"08-05\",leaveAlice = \"10-10\",arriveBob = \"09-01\",leaveBob = \"10-05\") == 35\n    assert candidate(arriveAlice = \"08-15\",leaveAlice = \"09-20\",arriveBob = \"09-05\",leaveBob = \"10-05\") == 16\n    assert candidate(arriveAlice = \"01-15\",leaveAlice = \"03-20\",arriveBob = \"02-10\",leaveBob = \"04-15\") == 39\n    assert candidate(arriveAlice = \"10-20\",leaveAlice = \"11-10\",arriveBob = \"11-05\",leaveBob = \"12-15\") == 6\n    assert candidate(arriveAlice = \"06-30\",leaveAlice = \"07-01\",arriveBob = \"06-29\",leaveBob = \"07-02\") == 2\n    assert candidate(arriveAlice = \"02-28\",leaveAlice = \"03-01\",arriveBob = \"03-01\",leaveBob = \"03-02\") == 1\n    assert candidate(arriveAlice = \"04-01\",leaveAlice = \"04-30\",arriveBob = \"03-20\",leaveBob = \"04-25\") == 25\n    assert candidate(arriveAlice = \"09-10\",leaveAlice = \"10-10\",arriveBob = \"09-15\",leaveBob = \"09-20\") == 6\n    assert candidate(arriveAlice = \"05-10\",leaveAlice = \"05-10\",arriveBob = \"05-10\",leaveBob = \"05-10\") == 1\n    assert candidate(arriveAlice = \"07-20\",leaveAlice = \"07-25\",arriveBob = \"07-20\",leaveBob = \"07-25\") == 6\n    assert candidate(arriveAlice = \"08-01\",leaveAlice = \"08-31\",arriveBob = \"07-20\",leaveBob = \"08-10\") == 10\n    assert candidate(arriveAlice = \"06-15\",leaveAlice = \"06-20\",arriveBob = \"06-21\",leaveBob = \"06-25\") == 0\n    assert candidate(arriveAlice = \"12-15\",leaveAlice = \"12-20\",arriveBob = \"12-15\",leaveBob = \"12-20\") == 6\n    assert candidate(arriveAlice = \"11-01\",leaveAlice = \"11-30\",arriveBob = \"10-25\",leaveBob = \"11-25\") == 25\n    assert candidate(arriveAlice = \"07-31\",leaveAlice = \"07-31\",arriveBob = \"08-01\",leaveBob = \"08-01\") == 0\n    assert candidate(arriveAlice = \"08-01\",leaveAlice = \"08-31\",arriveBob = \"07-25\",leaveBob = \"08-15\") == 15\n    assert candidate(arriveAlice = \"02-14\",leaveAlice = \"03-14\",arriveBob = \"03-01\",leaveBob = \"04-01\") == 14\n    assert candidate(arriveAlice = \"08-10\",leaveAlice = \"09-10\",arriveBob = \"09-05\",leaveBob = \"09-20\") == 6\n    assert candidate(arriveAlice = \"01-01\",leaveAlice = \"01-31\",arriveBob = \"02-01\",leaveBob = \"02-28\") == 0\n    assert candidate(arriveAlice = \"03-15\",leaveAlice = \"03-31\",arriveBob = \"04-01\",leaveBob = \"04-10\") == 0\n    assert candidate(arriveAlice = \"01-01\",leaveAlice = \"12-31\",arriveBob = \"06-15\",leaveBob = \"06-15\") == 1\n    assert candidate(arriveAlice = \"11-15\",leaveAlice = \"11-30\",arriveBob = \"12-01\",leaveBob = \"12-31\") == 0\n    assert candidate(arriveAlice = \"09-01\",leaveAlice = \"11-15\",arriveBob = \"10-01\",leaveBob = \"10-31\") == 31\n    assert candidate(arriveAlice = \"04-15\",leaveAlice = \"06-20\",arriveBob = \"05-01\",leaveBob = \"07-15\") == 51\n    assert candidate(arriveAlice = \"08-20\",leaveAlice = \"09-20\",arriveBob = \"09-10\",leaveBob = \"10-10\") == 11\n    assert candidate(arriveAlice = \"07-10\",leaveAlice = \"08-10\",arriveBob = \"07-20\",leaveBob = \"08-20\") == 22\n    assert candidate(arriveAlice = \"05-10\",leaveAlice = \"06-10\",arriveBob = \"05-20\",leaveBob = \"06-20\") == 22\n    assert candidate(arriveAlice = \"06-01\",leaveAlice = \"06-10\",arriveBob = \"06-05\",leaveBob = \"06-05\") == 1\n    assert candidate(arriveAlice = \"11-10\",leaveAlice = \"11-10\",arriveBob = \"11-11\",leaveBob = \"11-11\") == 0\n    assert candidate(arriveAlice = \"09-01\",leaveAlice = \"10-31\",arriveBob = \"08-01\",leaveBob = \"09-15\") == 15\n    assert candidate(arriveAlice = \"12-15\",leaveAlice = \"12-31\",arriveBob = \"12-10\",leaveBob = \"12-15\") == 1\n    assert candidate(arriveAlice = \"07-01\",leaveAlice = \"07-31\",arriveBob = \"06-25\",leaveBob = \"07-25\") == 25\n    assert candidate(arriveAlice = \"03-10\",leaveAlice = \"04-10\",arriveBob = \"04-05\",leaveBob = \"05-10\") == 6\n    assert candidate(arriveAlice = \"03-31\",leaveAlice = \"03-31\",arriveBob = \"04-01\",leaveBob = \"04-01\") == 0\n    assert candidate(arriveAlice = \"09-10\",leaveAlice = \"10-10\",arriveBob = \"09-15\",leaveBob = \"10-15\") == 26\n    assert candidate(arriveAlice = \"05-25\",leaveAlice = \"06-05\",arriveBob = \"05-26\",leaveBob = \"06-04\") == 10\n    assert candidate(arriveAlice = \"10-15\",leaveAlice = \"10-20\",arriveBob = \"09-25\",leaveBob = \"10-16\") == 2\n    assert candidate(arriveAlice = \"09-01\",leaveAlice = \"10-31\",arriveBob = \"08-15\",leaveBob = \"09-15\") == 15\n    assert candidate(arriveAlice = \"03-01\",leaveAlice = \"03-31\",arriveBob = \"02-28\",leaveBob = \"03-10\") == 10\n    assert candidate(arriveAlice = \"06-01\",leaveAlice = \"08-31\",arriveBob = \"07-01\",leaveBob = \"07-31\") == 31\n    assert candidate(arriveAlice = \"07-25\",leaveAlice = \"08-25\",arriveBob = \"07-26\",leaveBob = \"07-27\") == 2\n    assert candidate(arriveAlice = \"06-01\",leaveAlice = \"08-31\",arriveBob = \"07-01\",leaveBob = \"09-30\") == 62\n    assert candidate(arriveAlice = \"02-15\",leaveAlice = \"03-15\",arriveBob = \"03-10\",leaveBob = \"04-10\") == 6\n    assert candidate(arriveAlice = \"04-30\",leaveAlice = \"05-01\",arriveBob = \"04-29\",leaveBob = \"05-02\") == 2\n    assert candidate(arriveAlice = \"09-01\",leaveAlice = \"09-15\",arriveBob = \"08-20\",leaveBob = \"09-10\") == 10\n    assert candidate(arriveAlice = \"03-15\",leaveAlice = \"03-15\",arriveBob = \"03-15\",leaveBob = \"03-15\") == 1\n    assert candidate(arriveAlice = \"05-05\",leaveAlice = \"05-05\",arriveBob = \"05-04\",leaveBob = \"05-06\") == 1\n    assert candidate(arriveAlice = \"08-25\",leaveAlice = \"09-05\",arriveBob = \"09-01\",leaveBob = \"09-10\") == 5\n    assert candidate(arriveAlice = \"07-05\",leaveAlice = \"08-10\",arriveBob = \"08-05\",leaveBob = \"09-15\") == 6\n    assert candidate(arriveAlice = \"09-10\",leaveAlice = \"11-20\",arriveBob = \"10-01\",leaveBob = \"10-31\") == 31\n    assert candidate(arriveAlice = \"09-15\",leaveAlice = \"10-15\",arriveBob = \"10-01\",leaveBob = \"11-01\") == 15\n    assert candidate(arriveAlice = \"12-15\",leaveAlice = \"12-31\",arriveBob = \"12-20\",leaveBob = \"01-15\") == 0\n    assert candidate(arriveAlice = \"05-05\",leaveAlice = \"07-10\",arriveBob = \"06-01\",leaveBob = \"06-30\") == 30\n    assert candidate(arriveAlice = \"03-15\",leaveAlice = \"05-15\",arriveBob = \"04-01\",leaveBob = \"04-30\") == 30\n    assert candidate(arriveAlice = \"11-10\",leaveAlice = \"11-20\",arriveBob = \"11-21\",leaveBob = \"11-30\") == 0\n    assert candidate(arriveAlice = \"02-20\",leaveAlice = \"03-10\",arriveBob = \"03-05\",leaveBob = \"04-01\") == 6\n    assert candidate(arriveAlice = \"01-05\",leaveAlice = \"01-10\",arriveBob = \"01-08\",leaveBob = \"01-15\") == 3\n    assert candidate(arriveAlice = \"01-29\",leaveAlice = \"02-02\",arriveBob = \"02-01\",leaveBob = \"02-28\") == 2\n    assert candidate(arriveAlice = \"10-10\",leaveAlice = \"10-20\",arriveBob = \"09-30\",leaveBob = \"10-10\") == 1\n    assert candidate(arriveAlice = \"04-01\",leaveAlice = \"04-30\",arriveBob = \"04-10\",leaveBob = \"04-20\") == 11\n    assert candidate(arriveAlice = \"05-15\",leaveAlice = \"06-15\",arriveBob = \"06-10\",leaveBob = \"07-10\") == 6\n    assert candidate(arriveAlice = \"02-28\",leaveAlice = \"03-01\",arriveBob = \"02-28\",leaveBob = \"03-01\") == 2\n    assert candidate(arriveAlice = \"01-10\",leaveAlice = \"02-10\",arriveBob = \"02-01\",leaveBob = \"03-10\") == 10\n    assert candidate(arriveAlice = \"11-01\",leaveAlice = \"11-30\",arriveBob = \"11-15\",leaveBob = \"12-15\") == 16\n    assert candidate(arriveAlice = \"05-01\",leaveAlice = \"05-31\",arriveBob = \"04-30\",leaveBob = \"05-10\") == 10\n    assert candidate(arriveAlice = \"12-10\",leaveAlice = \"12-31\",arriveBob = \"12-20\",leaveBob = \"01-10\") == 0\n    assert candidate(arriveAlice = \"07-20\",leaveAlice = \"08-20\",arriveBob = \"08-01\",leaveBob = \"08-19\") == 19\n    assert candidate(arriveAlice = \"01-10\",leaveAlice = \"02-10\",arriveBob = \"01-15\",leaveBob = \"03-15\") == 27\n    assert candidate(arriveAlice = \"05-10\",leaveAlice = \"05-15\",arriveBob = \"05-12\",leaveBob = \"05-20\") == 4\n    assert candidate(arriveAlice = \"02-28\",leaveAlice = \"03-05\",arriveBob = \"03-01\",leaveBob = \"03-10\") == 5\n    assert candidate(arriveAlice = \"02-28\",leaveAlice = \"03-01\",arriveBob = \"02-29\",leaveBob = \"03-02\") == 1\n    assert candidate(arriveAlice = \"11-25\",leaveAlice = \"12-10\",arriveBob = \"12-01\",leaveBob = \"12-15\") == 10\n    assert candidate(arriveAlice = \"04-10\",leaveAlice = \"04-30\",arriveBob = \"04-15\",leaveBob = \"05-15\") == 16\n    assert candidate(arriveAlice = \"07-10\",leaveAlice = \"07-20\",arriveBob = \"07-20\",leaveBob = \"07-30\") == 1\n    assert candidate(arriveAlice = \"11-11\",leaveAlice = \"11-30\",arriveBob = \"11-15\",leaveBob = \"11-25\") == 11\n    assert candidate(arriveAlice = \"03-20\",leaveAlice = \"03-31\",arriveBob = \"04-01\",leaveBob = \"04-10\") == 0\n    assert candidate(arriveAlice = \"09-15\",leaveAlice = \"10-15\",arriveBob = \"10-10\",leaveBob = \"11-10\") == 6\n    assert candidate(arriveAlice = \"11-01\",leaveAlice = \"11-15\",arriveBob = \"10-25\",leaveBob = \"11-10\") == 10\n    assert candidate(arriveAlice = \"07-20\",leaveAlice = \"08-20\",arriveBob = \"07-15\",leaveBob = \"07-25\") == 6\n", "comparison": "exact"}, "public_tests": ["\"08-15\"\n\"08-18\"\n\"08-16\"\n\"08-19\"", "\"10-01\"\n\"10-31\"\n\"11-01\"\n\"12-31\""], "hints": ["For a given day, determine if Alice or Bob or both are in Rome.", "Brute force all 365 days for both Alice and Bob."], "metadata": {"canonical_parameter_names": ["arriveAlice", "leaveAlice", "arriveBob", "leaveBob"], "leetcode_dataset_entry_point": "Solution().countDaysTogether", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:40+00:00", "tests_total": 116, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "string"]}, "language": "python", "interface": {"raw_signature": "def countDaysTogether(self, arriveAlice: str, leaveAlice: str, arriveBob: str, leaveBob: str) -> int:", "container": "Solution", "callable": "countDaysTogether", "parameters": [{"name": "arriveAlice", "type": "str"}, {"name": "leaveAlice", "type": "str"}, {"name": "arriveBob", "type": "str"}, {"name": "leaveBob", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2410, "task_id": "maximum-matching-of-players-with-trainers", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array players, where players[i] represents the ability of the i^th player. You are also given a 0-indexed integer array trainers, where trainers[j] represents the training capacity of the j^th trainer.\n\nThe i^th player can match with the j^th trainer if the player's ability is less than or equal to the trainer's training capacity. Additionally, the i^th player can be matched with at most one trainer, and the j^th trainer can be matched with at most one player.\n\nReturn the maximum number of matchings between players and trainers that satisfy these conditions.\n\nExample 1:\n\nInput: players = [4,7,9], trainers = [8,2,5,8]\nOutput: 2\nExplanation:\nOne of the ways we can form two matchings is as follows:\n- players[0] can be matched with trainers[0] since 4 <= 8.\n- players[1] can be matched with trainers[3] since 7 <= 8.\nIt can be proven that 2 is the maximum number of matchings that can be formed.\n\nExample 2:\n\nInput: players = [1,1,1], trainers = [10]\nOutput: 1\nExplanation:\nThe trainer can be matched with any of the 3 players.\nEach player can only be matched with one trainer, so the maximum answer is 1.\n\nConstraints:\n\n- 1 <= players.length, trainers.length <= 10^5\n- 1 <= players[i], trainers[j] <= 10^9\n\nNote: This question is the same as  445: Assign Cookies.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(players = [1, 2, 3],trainers = [10, 11, 12]) == 3\n    assert candidate(players = [10, 20, 30],trainers = [1, 2, 3]) == 0\n    assert candidate(players = [1, 2, 3, 4, 5],trainers = [5, 4, 3, 2, 1]) == 5\n    assert candidate(players = [1000000000],trainers = [1000000000]) == 1\n    assert candidate(players = [1, 2, 3],trainers = [4, 5, 6, 7, 8]) == 3\n    assert candidate(players = [1, 1, 1, 1, 1],trainers = [1, 1, 1, 1, 1, 1]) == 5\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [10]) == 1\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n    assert candidate(players = [1],trainers = [1]) == 1\n    assert candidate(players = [1, 10, 100],trainers = [10, 100, 1000]) == 3\n    assert candidate(players = [5, 6, 7],trainers = [8, 9, 10]) == 3\n    assert candidate(players = [1, 3, 5, 7, 9],trainers = [2, 4, 6, 8, 10]) == 5\n    assert candidate(players = [5, 5, 5],trainers = [5, 5, 5]) == 3\n    assert candidate(players = [9, 7, 5, 3, 1],trainers = [10, 8, 6, 4, 2]) == 5\n    assert candidate(players = [1, 2, 3],trainers = [10, 20, 30]) == 3\n    assert candidate(players = [10, 20, 30, 40],trainers = [5, 15, 25, 35, 45]) == 4\n    assert candidate(players = [10, 20, 30],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n    assert candidate(players = [1, 1000000000],trainers = [1000000000, 1]) == 2\n    assert candidate(players = [5, 5, 5, 5],trainers = [5, 5, 5, 5]) == 4\n    assert candidate(players = [1, 3, 5, 7],trainers = [2, 4, 6, 8]) == 4\n    assert candidate(players = [1, 1, 1],trainers = [10]) == 1\n    assert candidate(players = [4, 7, 9],trainers = [8, 2, 5, 8]) == 2\n    assert candidate(players = [100, 200, 300],trainers = [150, 250, 350]) == 3\n    assert candidate(players = [3, 7, 11, 15, 19],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n    assert candidate(players = [4, 7, 9, 11, 13, 15],trainers = [10, 8, 12, 6, 14, 16]) == 6\n    assert candidate(players = [100, 200, 300, 400, 500],trainers = [50, 150, 250, 350, 450, 550]) == 5\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n    assert candidate(players = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n    assert candidate(players = [1, 2, 3, 4, 5],trainers = [5, 5, 5, 5, 5]) == 5\n    assert candidate(players = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],trainers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n    assert candidate(players = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],trainers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n    assert candidate(players = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],trainers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n    assert candidate(players = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n    assert candidate(players = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],trainers = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 10\n    assert candidate(players = [3, 3, 3, 4, 4, 4, 5, 5, 5],trainers = [3, 4, 5]) == 3\n    assert candidate(players = [1, 5, 8, 9, 11, 13, 15, 17, 19],trainers = [2, 3, 6, 7, 10, 12, 14, 16, 18, 20]) == 8\n    assert candidate(players = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],trainers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 4\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n    assert candidate(players = [50, 40, 30, 20, 10],trainers = [15, 25, 35, 45, 55]) == 5\n    assert candidate(players = [1, 1, 1, 1, 1],trainers = [1, 2, 3, 4, 5]) == 5\n    assert candidate(players = [1, 3, 6, 7, 8],trainers = [2, 4, 5, 8, 9]) == 4\n    assert candidate(players = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n    assert candidate(players = [1, 100, 1000, 10000, 100000],trainers = [1, 100, 1000, 10000, 100000]) == 5\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 10\n    assert candidate(players = [5, 10, 15, 20, 25, 30],trainers = [25, 10, 5, 30, 20, 15]) == 6\n    assert candidate(players = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],trainers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n    assert candidate(players = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],trainers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n    assert candidate(players = [1, 1, 2, 2, 3, 3, 4, 4],trainers = [1, 2, 2, 3, 3, 4, 4, 5]) == 8\n    assert candidate(players = [10, 20, 30, 40, 50],trainers = [15, 25, 35, 45, 55]) == 5\n    assert candidate(players = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],trainers = [500, 600, 700, 800, 900, 1000, 100, 200, 300, 400]) == 10\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],trainers = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 25\n    assert candidate(players = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],trainers = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == 10\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],trainers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]) == 25\n    assert candidate(players = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],trainers = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 5\n    assert candidate(players = [1, 5, 9, 13, 17],trainers = [3, 7, 11, 15, 19]) == 5\n    assert candidate(players = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],trainers = [5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]) == 15\n    assert candidate(players = [3, 6, 7, 8, 10, 11, 15],trainers = [4, 5, 8, 9, 12, 16, 20]) == 6\n    assert candidate(players = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],trainers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 10\n    assert candidate(players = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],trainers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],trainers = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n    assert candidate(players = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],trainers = [1, 1, 1, 1, 1]) == 5\n    assert candidate(players = [5, 10, 15, 20, 25, 30],trainers = [3, 6, 9, 12, 18, 21, 24, 27]) == 5\n    assert candidate(players = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500],trainers = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 10\n    assert candidate(players = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],trainers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 15\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n    assert candidate(players = [10, 20, 30, 40, 50],trainers = [1, 2, 3, 4, 5]) == 0\n    assert candidate(players = [1, 1, 1, 1, 1],trainers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],trainers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 20\n    assert candidate(players = [1, 10, 100, 1000, 10000, 100000],trainers = [100000, 10000, 1000, 100, 10, 1]) == 6\n    assert candidate(players = [100, 200, 300, 400, 500],trainers = [250, 350, 150, 450, 550]) == 5\n    assert candidate(players = [10, 10, 10, 10, 10],trainers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(players = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n    assert candidate(players = [100, 200, 300, 400, 500],trainers = [150, 250, 350, 450, 550]) == 5\n    assert candidate(players = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],trainers = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 9\n    assert candidate(players = [1000000000, 1000000000, 1000000000],trainers = [1000000000, 1000000000]) == 2\n    assert candidate(players = [1, 100, 200, 300, 400, 500],trainers = [500, 400, 300, 200, 100, 1]) == 6\n    assert candidate(players = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],trainers = [99, 199, 299, 399, 499, 599, 699, 799, 899, 999, 1099, 1199, 1299, 1399, 1499]) == 14\n    assert candidate(players = [1000000000, 999999999, 999999998, 999999997, 999999996],trainers = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 5\n    assert candidate(players = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],trainers = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10]) == 10\n    assert candidate(players = [10, 20, 30, 40, 50],trainers = [5, 15, 25, 35, 45, 55]) == 5\n    assert candidate(players = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],trainers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n    assert candidate(players = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],trainers = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 15\n    assert candidate(players = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],trainers = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 9\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n    assert candidate(players = [1, 1, 1, 1, 1],trainers = [1]) == 1\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n    assert candidate(players = [5, 5, 5, 5, 5],trainers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n    assert candidate(players = [1, 2, 3, 4, 5],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n    assert candidate(players = [5, 5, 5, 5, 5],trainers = [5, 5, 5, 5, 5]) == 5\n    assert candidate(players = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],trainers = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == 10\n    assert candidate(players = [2, 5, 8, 12, 15],trainers = [3, 5, 7, 9, 11, 15]) == 4\n    assert candidate(players = [1, 2, 3, 4, 5],trainers = [1, 1, 1, 1, 1]) == 1\n    assert candidate(players = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],trainers = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 9\n    assert candidate(players = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],trainers = [49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 25\n    assert candidate(players = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],trainers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n    assert candidate(players = [10, 20, 30, 40, 50],trainers = [15, 25, 35, 45, 55]) == 5\n    assert candidate(players = [3, 6, 9, 12, 15, 18, 21],trainers = [10, 12, 14, 16, 18, 20, 22]) == 7\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n    assert candidate(players = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],trainers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n    assert candidate(players = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],trainers = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 10\n    assert candidate(players = [5, 5, 5, 5, 5],trainers = [1, 2, 3, 4, 5]) == 1\n    assert candidate(players = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],trainers = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == 10\n    assert candidate(players = [5, 10, 15, 20, 25],trainers = [1, 5, 10, 15, 20, 25, 30]) == 5\n    assert candidate(players = [100, 100, 100, 100, 100],trainers = [100, 100, 100, 100, 100, 100]) == 5\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],trainers = [3, 6, 9, 12, 15]) == 5\n    assert candidate(players = [5, 5, 5, 5, 5],trainers = [1, 2, 3, 4, 5]) == 1\n    assert candidate(players = [100, 200, 300],trainers = [150, 100, 250, 300]) == 3\n    assert candidate(players = [50, 40, 30, 20, 10],trainers = [10, 20, 30, 40, 50]) == 5\n    assert candidate(players = [10, 20, 30, 40, 50],trainers = [9, 19, 29, 39, 49]) == 4\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],trainers = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n    assert candidate(players = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],trainers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n    assert candidate(players = [90, 80, 70, 60, 50, 40, 30, 20, 10],trainers = [85, 95, 90, 75, 65, 55, 45, 35, 25, 15]) == 9\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n    assert candidate(players = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],trainers = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 10\n    assert candidate(players = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],trainers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n    assert candidate(players = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],trainers = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 10\n", "comparison": "exact"}, "public_tests": ["[4,7,9]\n[8,2,5,8]", "[1,1,1]\n[10]"], "hints": ["Sort both the arrays.", "Construct the matching greedily."], "metadata": {"canonical_parameter_names": ["players", "trainers"], "leetcode_dataset_entry_point": "Solution().matchPlayersAndTrainers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:43+00:00", "tests_total": 120, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "two-pointers", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def matchPlayersAndTrainers(self, players: list[int], trainers: list[int]) -> int:", "container": "Solution", "callable": "matchPlayersAndTrainers", "parameters": [{"name": "players", "type": "list[int]"}, {"name": "trainers", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2411, "task_id": "smallest-subarrays-with-maximum-bitwise-or", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums of length n, consisting of non-negative integers. For each index i from 0 to n - 1, you must determine the size of the minimum sized non-empty subarray of nums starting at i (inclusive) that has the maximum possible bitwise OR.\n\n- In other words, let B_ij be the bitwise OR of the subarray nums[i...j]. You need to find the smallest subarray starting at i, such that bitwise OR of this subarray is equal to max(B_ik) where i <= k <= n - 1.\n\nThe bitwise OR of an array is the bitwise OR of all the numbers in it.\n\nReturn an integer array answer of size n where answer[i] is the length of the minimum sized subarray starting at i with maximum bitwise OR.\n\nA subarray is a contiguous non-empty sequence of elements within an array.\n\nExample 1:\n\nInput: nums = [1,0,2,1,3]\nOutput: [3,3,2,2,1]\nExplanation:\nThe maximum possible bitwise OR starting at any index is 3.\n- Starting at index 0, the shortest subarray that yields it is [1,0,2].\n- Starting at index 1, the shortest subarray that yields the maximum bitwise OR is [0,2,1].\n- Starting at index 2, the shortest subarray that yields the maximum bitwise OR is [2,1].\n- Starting at index 3, the shortest subarray that yields the maximum bitwise OR is [1,3].\n- Starting at index 4, the shortest subarray that yields the maximum bitwise OR is [3].\nTherefore, we return [3,3,2,2,1].\n\nExample 2:\n\nInput: nums = [1,2]\nOutput: [2,1]\nExplanation:\nStarting at index 0, the shortest subarray that yields the maximum bitwise OR is of length 2.\nStarting at index 1, the shortest subarray that yields the maximum bitwise OR is of length 1.\nTherefore, we return [2,1].\n\nConstraints:\n\n- n == nums.length\n- 1 <= n <= 10^5\n- 0 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907, 953, 476, 238, 119, 59, 29, 14, 7, 3, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1]\n    assert candidate(nums = [8, 16, 32, 64, 128]) == [5, 4, 3, 2, 1]\n    assert candidate(nums = [1, 0, 1, 0, 1]) == [1, 2, 1, 2, 1]\n    assert candidate(nums = [3, 1, 5, 7, 9]) == [5, 4, 3, 2, 1]\n    assert candidate(nums = [8, 4, 2, 1]) == [4, 3, 2, 1]\n    assert candidate(nums = [1, 3, 5, 7, 9]) == [5, 4, 3, 2, 1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [8, 7, 6, 5, 4, 3, 2, 3, 2, 1]\n    assert candidate(nums = [7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 2, 1, 2, 1]\n    assert candidate(nums = [1, 0, 2, 1, 3]) == [3, 3, 2, 2, 1]\n    assert candidate(nums = [8, 4, 2, 1, 0]) == [4, 3, 2, 1, 1]\n    assert candidate(nums = [5, 5, 5, 5, 5]) == [1, 1, 1, 1, 1]\n    assert candidate(nums = [0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1]\n    assert candidate(nums = [1, 3, 2, 1, 4, 7, 8, 5, 6, 9]) == [7, 6, 5, 4, 3, 2, 3, 3, 2, 1]\n    assert candidate(nums = [1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1]\n    assert candidate(nums = [0, 0, 0, 0]) == [1, 1, 1, 1]\n    assert candidate(nums = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1023]) == [10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [31, 15, 7, 3, 1]) == [1, 1, 1, 1, 1]\n    assert candidate(nums = [1, 2]) == [2, 1]\n    assert candidate(nums = [3, 3, 3, 3, 3]) == [1, 1, 1, 1, 1]\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [1, 1, 1, 1, 1]\n    assert candidate(nums = [8, 4, 2, 1, 16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1, 64, 32, 16, 8, 4, 2, 1]) == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 7, 7, 7, 7, 7, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [33554431, 16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015, 1014, 1013, 1012, 1011, 1010, 1009, 1008, 1007, 1006, 1005, 1004]) == [1, 2, 3, 2, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 1, 1]\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1]) == [1, 1, 1, 4, 3, 2, 1, 1, 1, 4, 3, 2, 1, 1, 1, 4, 3, 2, 1, 1]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 255, 127, 63, 31, 15, 7, 3, 1, 511, 255, 127, 63]) == [17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 5, 4, 3, 2, 3, 2, 1]\n    assert candidate(nums = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015, 1014]) == [1, 2, 3, 2, 5, 4, 3, 2, 1, 1]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [7, 6, 5, 4, 3, 2, 4, 3, 2, 1]\n    assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [8, 7, 6, 5, 4, 3, 2, 5, 4, 3, 2, 3, 2, 2, 1]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 5, 4, 3, 2, 3, 2, 1, 1]\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [8, 6, 2, 3, 7, 5, 1, 4, 9, 10]) == [4, 8, 7, 6, 5, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8]) == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1]\n    assert candidate(nums = [8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [1023, 0, 2047, 0, 4095, 0, 8191, 0, 16383, 0]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 1]\n    assert candidate(nums = [8, 15, 3, 12, 7, 9, 1, 5, 11, 6, 4, 10, 2, 14, 0, 13]) == [2, 1, 2, 2, 2, 4, 3, 2, 2, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [2, 3, 1, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 0]) == [4, 5, 4, 4, 4, 3, 3, 2, 1, 1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 5, 4, 3, 2, 3, 2, 2, 1]\n    assert candidate(nums = [31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 1, 1, 3, 7, 15, 31, 1, 1, 3, 7, 15, 31, 1, 1, 3, 7, 15, 31]) == [1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == [32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [16, 8, 4, 2, 1, 32, 64, 128, 256, 512]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == [1, 8, 7, 6, 5, 4, 3, 2, 1, 1]\n    assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [2, 3, 2, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 2, 5, 4, 3, 2, 1, 2, 3, 2, 1, 2, 1, 1]\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 3, 2, 2, 1]\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035]) == [10, 9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 2, 1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 5, 4, 3, 2, 1]\n    assert candidate(nums = [3, 1, 2, 7, 4, 6, 5, 0, 8, 9]) == [9, 8, 7, 6, 5, 4, 3, 3, 2, 1]\n    assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [31, 15, 7, 3, 1, 1, 3, 7, 15, 31]) == [1, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [9, 3, 1, 7, 5, 11, 13, 15, 8, 12, 14, 6, 10, 2, 4, 0]) == [4, 5, 4, 3, 2, 2, 2, 1, 3, 2, 1, 2, 3, 2, 1, 1]\n    assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == [8, 7, 6, 5, 4, 3, 2, 3, 2, 1]\n    assert candidate(nums = [15, 7, 3, 1, 14, 6, 2, 0, 13, 5, 1, 0, 9, 3, 1, 0, 8, 2, 0, 7]) == [1, 4, 3, 2, 5, 4, 3, 7, 6, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1]\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 1]\n    assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [3, 2, 9, 8, 7, 6, 7, 6, 5, 4, 3, 2, 1, 2, 3, 2, 1, 2, 1, 1]\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 3, 3, 2, 1]\n    assert candidate(nums = [268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303, 2097151, 1048575, 524287]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [5, 3, 1, 7, 9, 11, 13, 15, 17, 19]) == [9, 8, 7, 6, 5, 4, 3, 2, 2, 1]\n    assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 128, 64, 32, 16, 8, 4, 2, 1, 256, 512, 1024, 2048, 4096]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [31, 14, 7, 3, 1, 0, 1, 3, 7, 14, 31, 0, 1, 3, 7, 14, 31, 0, 1, 3, 7, 14, 31]) == [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0]) == [1, 1, 1, 4, 3, 2, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1, 0, 2, 1, 3, 1, 0, 2, 1, 3, 1, 0, 2, 1, 3, 1, 0, 2, 1, 3]) == [3, 3, 2, 2, 1, 3, 3, 2, 2, 1, 3, 3, 2, 2, 1, 3, 3, 2, 2, 1]\n    assert candidate(nums = [5, 8, 14, 23, 42, 67, 98, 132, 175, 220, 270, 325, 385, 450, 520]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 255, 128, 64, 32, 16, 8, 4, 2, 1, 255, 128, 64, 32, 16, 8, 4, 2, 1]) == [1, 8, 8, 7, 6, 5, 4, 3, 2, 1, 8, 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907, 953, 476, 238, 119, 59, 29, 14, 7, 3, 1, 0]) == [10, 9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1]\n    assert candidate(nums = [1, 0, 3, 2, 1, 2, 3, 0, 1, 2]) == [3, 2, 1, 2, 2, 2, 1, 3, 2, 1]\n    assert candidate(nums = [524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [31, 15, 7, 3, 1, 63, 31, 15, 7, 3, 1, 127, 63, 31, 15, 7, 3, 1, 255, 127, 63, 31, 15, 7, 3, 1]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(nums = [987654321, 987654320, 987654319, 987654318, 987654317, 987654316, 987654315, 987654314, 987654313, 987654312]) == [3, 2, 1, 2, 3, 2, 1, 2, 1, 1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1, 0, 3, 2, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]) == [3, 2, 1, 2, 2, 2, 1, 3, 2, 2, 1, 3, 2, 2, 1, 3, 2, 2, 1, 1]\n    assert candidate(nums = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015, 1014, 1013, 1012, 1011, 1010, 1009, 1008, 1007, 1006, 1005, 1004]) == [1, 2, 3, 2, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 1, 1]\n    assert candidate(nums = [31, 15, 7, 3, 1, 0, 1, 3, 5, 7, 9]) == [1, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n", "comparison": "exact"}, "public_tests": ["[1,0,2,1,3]", "[1,2]"], "hints": ["Consider trying to solve the problem for each bit position separately.", "For each bit position, find the position of the next number that has a 1 in that position, if any.", "Take the maximum distance to such a number, including the current number.", "Iterate backwards to achieve a linear complexity."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().smallestSubarrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:45+00:00", "tests_total": 102, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "binary-search", "bit-manipulation", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def smallestSubarrays(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "smallestSubarrays", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2412, "task_id": "minimum-money-required-before-transactions", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array transactions, where transactions[i] = [cost_i, cashback_i].\n\nThe array describes transactions, where each transaction must be completed exactly once in some order. At any given moment, you have a certain amount of money. In order to complete transaction i, money >= cost_i must hold true. After performing a transaction, money becomes money - cost_i + cashback_i.\n\nReturn the minimum amount of money required before any transaction so that all of the transactions can be completed regardless of the order of the transactions.\n\nExample 1:\n\nInput: transactions = [[2,1],[5,0],[4,2]]\nOutput: 10\nExplanation:\nStarting with money = 10, the transactions can be performed in any order.\nIt can be shown that starting with money < 10 will fail to complete all transactions in some order.\n\nExample 2:\n\nInput: transactions = [[3,0],[0,3]]\nOutput: 3\nExplanation:\n- If transactions are in the order [[3,0],[0,3]], the minimum money required to complete the transactions is 3.\n- If transactions are in the order [[0,3],[3,0]], the minimum money required to complete the transactions is 0.\nThus, starting with money = 3, the transactions can be performed in any order.\n\nConstraints:\n\n- 1 <= transactions.length <= 10^5\n- transactions[i].length == 2\n- 0 <= cost_i, cashback_i <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(transactions = [[1, 2], [3, 4], [5, 6]]) == 5\n    assert candidate(transactions = [[1, 0], [2, 0], [3, 0]]) == 6\n    assert candidate(transactions = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 4\n    assert candidate(transactions = [[0, 0], [0, 0], [0, 0]]) == 0\n    assert candidate(transactions = [[7, 3], [2, 1], [4, 4]]) == 9\n    assert candidate(transactions = [[2, 1], [5, 0], [4, 2]]) == 10\n    assert candidate(transactions = [[0, 0], [1, 1], [2, 2]]) == 2\n    assert candidate(transactions = [[10, 5], [2, 2], [8, 3]]) == 15\n    assert candidate(transactions = [[1000000000, 0], [0, 1000000000]]) == 1000000000\n    assert candidate(transactions = [[10, 5], [5, 10], [20, 10]]) == 25\n    assert candidate(transactions = [[100, 0], [0, 100], [50, 50]]) == 150\n    assert candidate(transactions = [[10, 5], [2, 2], [1, 1]]) == 10\n    assert candidate(transactions = [[3, 0], [0, 3]]) == 3\n    assert candidate(transactions = [[1000000000, 500000000], [500000000, 250000000]]) == 1250000000\n    assert candidate(transactions = [[1000000000, 0], [0, 1000000000], [500000000, 500000000]]) == 1500000000\n    assert candidate(transactions = [[5, 5], [5, 5], [5, 5]]) == 5\n    assert candidate(transactions = [[100, 50], [50, 100], [25, 25]]) == 100\n    assert candidate(transactions = [[0, 1], [0, 2], [0, 3]]) == 0\n    assert candidate(transactions = [[10, 0], [0, 10], [5, 5]]) == 15\n    assert candidate(transactions = [[5, 10], [3, 6], [7, 8]]) == 7\n    assert candidate(transactions = [[100, 99], [99, 98], [98, 97], [97, 96], [96, 95], [95, 94], [94, 93], [93, 92], [92, 91], [91, 90]]) == 109\n    assert candidate(transactions = [[100, 50], [50, 100], [25, 75], [75, 25]]) == 150\n    assert candidate(transactions = [[1, 100], [1, 99], [1, 98], [1, 97], [1, 96]]) == 1\n    assert candidate(transactions = [[1000000000, 500000000], [500000000, 1000000000], [250000000, 750000000], [750000000, 250000000]]) == 1500000000\n    assert candidate(transactions = [[1000000000, 0], [0, 1000000000], [500000000, 500000000], [250000000, 250000000], [750000000, 750000000]]) == 1750000000\n    assert candidate(transactions = [[1, 999999999], [2, 999999998], [3, 999999997], [4, 999999996], [5, 999999995]]) == 5\n    assert candidate(transactions = [[5, 10], [10, 5], [3, 15], [15, 3], [8, 8]]) == 25\n    assert candidate(transactions = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == 46\n    assert candidate(transactions = [[1000000000, 500000000], [500000000, 250000000], [250000000, 125000000], [125000000, 62500000], [62500000, 31250000]]) == 1468750000\n    assert candidate(transactions = [[5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0], [4, 5], [3, 5], [2, 5], [1, 5]]) == 20\n    assert candidate(transactions = [[1, 1000000000], [2, 1000000000], [3, 1000000000], [4, 1000000000], [5, 1000000000], [6, 1000000000], [7, 1000000000], [8, 1000000000], [9, 1000000000], [10, 1000000000]]) == 10\n    assert candidate(transactions = [[1000000000, 500000000], [500000000, 250000000], [250000000, 125000000], [125000000, 62500000], [62500000, 31250000], [31250000, 15625000], [15625000, 7812500], [7812500, 3906250], [3906250, 1953125], [1953125, 976562], [976562, 488281], [488281, 244140], [244140, 122070], [122070, 61035], [61035, 30517], [30517, 15258], [15258, 7629], [7629, 3814], [3814, 1907], [1907, 953], [953, 476], [476, 238], [238, 119], [119, 59], [59, 29], [29, 14], [14, 7], [7, 3], [3, 1]]) == 1499999999\n    assert candidate(transactions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30]]) == 135\n    assert candidate(transactions = [[1, 1], [1, 2], [2, 1], [2, 2], [1, 3], [3, 1], [3, 3]]) == 6\n    assert candidate(transactions = [[1000000000, 0], [0, 1000000000], [500000000, 500000000], [500000001, 499999999]]) == 1500000002\n    assert candidate(transactions = [[10, 5], [9, 4], [8, 3], [7, 2], [6, 1], [5, 0], [4, 6], [3, 7], [2, 8], [1, 9]]) == 35\n    assert candidate(transactions = [[100, 50], [200, 150], [300, 100], [400, 50], [500, 0]]) == 1300\n    assert candidate(transactions = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]]) == 460\n    assert candidate(transactions = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]]) == 45\n    assert candidate(transactions = [[5, 0], [0, 5], [5, 5], [0, 0], [10, 10]]) == 15\n    assert candidate(transactions = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]]) == 55\n    assert candidate(transactions = [[10, 5], [20, 15], [30, 25], [40, 35], [50, 45]]) == 70\n    assert candidate(transactions = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]]) == 14\n    assert candidate(transactions = [[100, 90], [90, 80], [80, 70], [70, 60], [60, 50]]) == 140\n    assert candidate(transactions = [[9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == 17\n    assert candidate(transactions = [[1000, 500], [1500, 1000], [2000, 1500], [2500, 2000], [3000, 2500]]) == 5000\n    assert candidate(transactions = [[1000000000, 900000000], [500000000, 400000000], [300000000, 200000000], [100000000, 90000000]]) == 1210000000\n    assert candidate(transactions = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]]) == 55\n    assert candidate(transactions = [[500, 500], [500, 500], [500, 500], [500, 500], [500, 500]]) == 500\n    assert candidate(transactions = [[10, 1], [5, 5], [15, 10], [20, 15], [25, 20], [30, 25], [35, 30], [40, 35], [45, 40]]) == 84\n    assert candidate(transactions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 9\n    assert candidate(transactions = [[10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]]) == 50\n    assert candidate(transactions = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 1], [1, 2]]) == 4\n    assert candidate(transactions = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]]) == 505\n    assert candidate(transactions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 5\n    assert candidate(transactions = [[5, 2], [10, 3], [15, 5], [20, 10]]) == 40\n    assert candidate(transactions = [[100, 0], [0, 100], [50, 50], [25, 25], [75, 75]]) == 175\n    assert candidate(transactions = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 10\n    assert candidate(transactions = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 30\n    assert candidate(transactions = [[10, 0], [20, 10], [30, 20], [40, 30], [50, 40], [60, 50], [70, 60], [80, 70], [90, 80]]) == 170\n    assert candidate(transactions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 19\n    assert candidate(transactions = [[100, 1], [101, 1], [102, 1], [103, 1], [104, 1]]) == 506\n    assert candidate(transactions = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 6\n    assert candidate(transactions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 10\n    assert candidate(transactions = [[9, 8], [7, 6], [5, 4], [3, 2], [1, 0]]) == 13\n    assert candidate(transactions = [[10, 15], [20, 10], [30, 5], [40, 0], [50, 25], [60, 30], [70, 20]]) == 210\n    assert candidate(transactions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 8\n    assert candidate(transactions = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]]) == 25\n    assert candidate(transactions = [[100, 50], [200, 150], [50, 100], [300, 200]]) == 400\n    assert candidate(transactions = [[100, 50], [200, 100], [300, 150], [50, 25]]) == 475\n    assert candidate(transactions = [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]) == 0\n    assert candidate(transactions = [[50, 0], [25, 0], [0, 50], [0, 25], [75, 0], [0, 75]]) == 150\n    assert candidate(transactions = [[20, 10], [25, 15], [30, 20], [35, 25], [40, 30], [45, 35], [50, 40], [55, 45], [60, 50], [65, 55]]) == 155\n    assert candidate(transactions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == 6\n    assert candidate(transactions = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96]]) == 5\n    assert candidate(transactions = [[9, 8], [7, 6], [5, 4], [3, 2], [1, 0]]) == 13\n    assert candidate(transactions = [[100, 10], [90, 20], [80, 30], [70, 40], [60, 50], [50, 60], [40, 70], [30, 80], [20, 90], [10, 100]]) == 300\n    assert candidate(transactions = [[500, 250], [250, 125], [125, 62], [62, 31], [31, 15], [15, 7], [7, 3], [3, 1], [1, 0]]) == 750\n    assert candidate(transactions = [[10, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10]]) == 300\n    assert candidate(transactions = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 100\n    assert candidate(transactions = [[5, 0], [5, 5], [5, 10], [5, 15], [5, 20], [5, 25], [5, 30], [5, 35], [5, 40], [5, 45]]) == 10\n    assert candidate(transactions = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 4\n    assert candidate(transactions = [[100, 50], [50, 100], [200, 150], [150, 200]]) == 250\n    assert candidate(transactions = [[10, 5], [5, 10], [15, 20], [20, 15], [25, 30], [30, 25]]) == 40\n    assert candidate(transactions = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 5]]) == 7\n    assert candidate(transactions = [[1000000000, 0], [0, 1000000000], [500000000, 500000000]]) == 1500000000\n    assert candidate(transactions = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0]]) == 15\n    assert candidate(transactions = [[100, 0], [50, 100], [25, 50], [10, 25], [5, 10], [1, 5]]) == 150\n    assert candidate(transactions = [[10, 9], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == 19\n    assert candidate(transactions = [[5, 10], [15, 5], [25, 20], [35, 30], [45, 40], [55, 50], [65, 60], [75, 70], [85, 80]]) == 125\n    assert candidate(transactions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25]]) == 100\n    assert candidate(transactions = [[5, 10], [10, 5], [0, 0], [7, 7], [3, 3]]) == 12\n    assert candidate(transactions = [[1000, 1000], [2000, 1000], [3000, 1000], [4000, 1000], [5000, 1000], [6000, 1000], [7000, 1000], [8000, 1000], [9000, 1000], [10000, 1000]]) == 46000\n    assert candidate(transactions = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120], [130, 130], [140, 140], [150, 150]]) == 150\n    assert candidate(transactions = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]]) == 505\n    assert candidate(transactions = [[1, 0], [0, 1], [1, 1], [0, 0], [1, 0], [0, 1]]) == 3\n    assert candidate(transactions = [[1000000000, 0], [0, 1000000000]]) == 1000000000\n    assert candidate(transactions = [[100000, 50000], [50000, 25000], [25000, 12500], [12500, 6250], [6250, 3125], [3125, 1562], [1562, 781], [781, 390], [390, 195]]) == 149805\n    assert candidate(transactions = [[100, 0], [90, 10], [80, 20], [70, 30], [60, 40], [50, 50], [40, 60], [30, 70], [20, 80], [10, 90]]) == 350\n    assert candidate(transactions = [[500, 400], [400, 300], [300, 200], [200, 100]]) == 800\n    assert candidate(transactions = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]]) == 0\n    assert candidate(transactions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 7\n    assert candidate(transactions = [[0, 100], [100, 200], [200, 300], [300, 400], [400, 500]]) == 400\n    assert candidate(transactions = [[10, 0], [0, 10], [5, 5], [5, 0], [0, 5], [7, 7], [3, 3], [2, 2], [1, 1]]) == 22\n    assert candidate(transactions = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 10\n    assert candidate(transactions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 8\n    assert candidate(transactions = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 65\n    assert candidate(transactions = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9]]) == 54\n    assert candidate(transactions = [[10, 5], [15, 10], [20, 15], [25, 20], [30, 25], [35, 30], [40, 35], [45, 40], [50, 45], [55, 50]]) == 100\n", "comparison": "exact"}, "public_tests": ["[[2,1],[5,0],[4,2]]", "[[3,0],[0,3]]"], "hints": ["Split transactions that have cashback greater or equal to cost apart from transactions that have cashback less than cost. You will always earn money in the first scenario.", "For transactions that have cashback greater or equal to cost, sort them by cost in descending order.", "For transactions that have cashback less than cost, sort them by cashback in ascending order."], "metadata": {"canonical_parameter_names": ["transactions"], "leetcode_dataset_entry_point": "Solution().minimumMoney", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:48+00:00", "tests_total": 109, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minimumMoney(self, transactions: list[list[int]]) -> int:", "container": "Solution", "callable": "minimumMoney", "parameters": [{"name": "transactions", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2413, "task_id": "smallest-even-multiple", "difficulty": "Easy", "problem_description": "Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n.\n\nExample 1:\n\nInput: n = 5\nOutput: 10\nExplanation: The smallest multiple of both 5 and 2 is 10.\n\nExample 2:\n\nInput: n = 6\nOutput: 6\nExplanation: The smallest multiple of both 6 and 2 is 6. Note that a number is a multiple of itself.\n\nConstraints:\n\n- 1 <= n <= 150\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 3) == 6\n    assert candidate(n = 100) == 100\n    assert candidate(n = 33) == 66\n    assert candidate(n = 75) == 150\n    assert candidate(n = 6) == 6\n    assert candidate(n = 2) == 2\n    assert candidate(n = 1) == 2\n    assert candidate(n = 7) == 14\n    assert candidate(n = 5) == 10\n    assert candidate(n = 150) == 150\n    assert candidate(n = 45) == 90\n    assert candidate(n = 119) == 238\n    assert candidate(n = 53) == 106\n    assert candidate(n = 43) == 86\n    assert candidate(n = 103) == 206\n    assert candidate(n = 145) == 290\n    assert candidate(n = 37) == 74\n    assert candidate(n = 23) == 46\n    assert candidate(n = 73) == 146\n    assert candidate(n = 133) == 266\n    assert candidate(n = 8) == 8\n    assert candidate(n = 147) == 294\n    assert candidate(n = 131) == 262\n    assert candidate(n = 27) == 54\n    assert candidate(n = 35) == 70\n    assert candidate(n = 77) == 154\n    assert candidate(n = 11) == 22\n    assert candidate(n = 142) == 142\n    assert candidate(n = 55) == 110\n    assert candidate(n = 65) == 130\n    assert candidate(n = 97) == 194\n    assert candidate(n = 88) == 88\n    assert candidate(n = 29) == 58\n    assert candidate(n = 135) == 270\n    assert candidate(n = 144) == 144\n    assert candidate(n = 107) == 214\n    assert candidate(n = 21) == 42\n    assert candidate(n = 115) == 230\n    assert candidate(n = 87) == 174\n    assert candidate(n = 137) == 274\n    assert candidate(n = 17) == 34\n    assert candidate(n = 42) == 42\n    assert candidate(n = 101) == 202\n    assert candidate(n = 89) == 178\n    assert candidate(n = 112) == 112\n    assert candidate(n = 71) == 142\n    assert candidate(n = 81) == 162\n    assert candidate(n = 41) == 82\n    assert candidate(n = 9) == 18\n    assert candidate(n = 83) == 166\n    assert candidate(n = 121) == 242\n    assert candidate(n = 105) == 210\n    assert candidate(n = 79) == 158\n    assert candidate(n = 84) == 84\n    assert candidate(n = 63) == 126\n    assert candidate(n = 61) == 122\n    assert candidate(n = 130) == 130\n    assert candidate(n = 49) == 98\n    assert candidate(n = 47) == 94\n    assert candidate(n = 113) == 226\n    assert candidate(n = 93) == 186\n    assert candidate(n = 57) == 114\n    assert candidate(n = 111) == 222\n    assert candidate(n = 123) == 246\n    assert candidate(n = 95) == 190\n    assert candidate(n = 141) == 282\n    assert candidate(n = 51) == 102\n    assert candidate(n = 127) == 254\n    assert candidate(n = 15) == 30\n    assert candidate(n = 13) == 26\n    assert candidate(n = 69) == 138\n    assert candidate(n = 125) == 250\n    assert candidate(n = 12) == 12\n    assert candidate(n = 117) == 234\n    assert candidate(n = 59) == 118\n    assert candidate(n = 67) == 134\n    assert candidate(n = 99) == 198\n    assert candidate(n = 64) == 64\n    assert candidate(n = 143) == 286\n    assert candidate(n = 128) == 128\n    assert candidate(n = 129) == 258\n    assert candidate(n = 140) == 140\n    assert candidate(n = 149) == 298\n    assert candidate(n = 19) == 38\n    assert candidate(n = 39) == 78\n    assert candidate(n = 91) == 182\n    assert candidate(n = 139) == 278\n    assert candidate(n = 85) == 170\n    assert candidate(n = 109) == 218\n    assert candidate(n = 31) == 62\n    assert candidate(n = 25) == 50\n", "comparison": "exact"}, "public_tests": ["5", "6"], "hints": ["A guaranteed way to find a multiple of 2 and n is to multiply them together. When is this the answer, and when is there a smaller answer?", "There is a smaller answer when n is even."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().smallestEvenMultiple", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:50+00:00", "tests_total": 91, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "number-theory"]}, "language": "python", "interface": {"raw_signature": "def smallestEvenMultiple(self, n: int) -> int:", "container": "Solution", "callable": "smallestEvenMultiple", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2414, "task_id": "length-of-the-longest-alphabetical-continuous-substring", "difficulty": "Medium", "problem_description": "An alphabetical continuous string is a string consisting of consecutive letters in the alphabet. In other words, it is any substring of the string \"abcdefghijklmnopqrstuvwxyz\".\n\n- For example, \"abc\" is an alphabetical continuous string, while \"acb\" and \"za\" are not.\n\nGiven a string s consisting of lowercase letters only, return the length of the longest alphabetical continuous substring.\n\nExample 1:\n\nInput: s = \"abacaba\"\nOutput: 2\nExplanation: There are 4 distinct continuous substrings: \"a\", \"b\", \"c\" and \"ab\".\n\"ab\" is the longest continuous substring.\n\nExample 2:\n\nInput: s = \"abcde\"\nOutput: 5\nExplanation: \"abcde\" is the longest continuous substring.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of only English lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"zzzzzzzzz\") == 1\n    assert candidate(s = \"abxyz\") == 3\n    assert candidate(s = \"qrstuvwpqrstu\") == 7\n    assert candidate(s = \"mnopqrstuvwxyzz\") == 14\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 26\n    assert candidate(s = \"mnopqrstuvwxyza\") == 14\n    assert candidate(s = \"abababab\") == 2\n    assert candidate(s = \"qrstuvwxyza\") == 10\n    assert candidate(s = \"bcdfghij\") == 5\n    assert candidate(s = \"a\") == 1\n    assert candidate(s = \"abcdabcde\") == 5\n    assert candidate(s = \"pqrstuvwxyzabc\") == 11\n    assert candidate(s = \"ababababab\") == 2\n    assert candidate(s = \"mnopqr\") == 6\n    assert candidate(s = \"abcde\") == 5\n    assert candidate(s = \"xyz\") == 3\n    assert candidate(s = \"mnopqrstu\") == 9\n    assert candidate(s = \"qrstuvwpqr\") == 7\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n    assert candidate(s = \"abccba\") == 3\n    assert candidate(s = \"acdfg\") == 2\n    assert candidate(s = \"defghijklmno\") == 12\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 2\n    assert candidate(s = \"zab\") == 2\n    assert candidate(s = \"abxyzab\") == 3\n    assert candidate(s = \"bcdfghjkl\") == 3\n    assert candidate(s = \"abacaba\") == 2\n    assert candidate(s = \"xyzabc\") == 3\n    assert candidate(s = \"abcabcvwxyz\") == 5\n    assert candidate(s = \"abcdefgxyzabcdefghijlmnopqrstuvwxyz\") == 15\n    assert candidate(s = \"abcdefghijlmnopqrstuvwxyzmnopqrstuvwxy\") == 15\n    assert candidate(s = \"mnopqrstuabcdefghijklmnopqrstuvwxyzaabcdeefghijklmnopqrstuvwxyz\") == 26\n    assert candidate(s = \"defghijklmnopqrstuvwxyz\") == 23\n    assert candidate(s = \"mnopqrstuvmnopqrstu\") == 10\n    assert candidate(s = \"mnopqrstuuvwxyzaaaa\") == 9\n    assert candidate(s = \"abcabcdabcdeabcdeabcd\") == 5\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzab\") == 26\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzz\") == 26\n    assert candidate(s = \"pqrsabcdewxyz\") == 5\n    assert candidate(s = \"xyzabcd\") == 4\n    assert candidate(s = \"aaaabbbbcccc\") == 2\n    assert candidate(s = \"zzzzzzzzzz\") == 1\n    assert candidate(s = \"abxyzabxyz\") == 3\n    assert candidate(s = \"abdefgxyz\") == 4\n    assert candidate(s = \"defghijklmnopqrstuvw\") == 20\n    assert candidate(s = \"mnopqrstuvxyzab\") == 10\n    assert candidate(s = \"pqrstuvwxyzaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 11\n    assert candidate(s = \"mnopqrstuabcde\") == 9\n    assert candidate(s = \"abcxyzab\") == 3\n    assert candidate(s = \"abcdefgxyzabcde\") == 7\n    assert candidate(s = \"abcabcabcabcabcabcabc\") == 3\n    assert candidate(s = \"pqrstuvwxyza\") == 11\n    assert candidate(s = \"mnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 14\n    assert candidate(s = \"mnopqrstuvwxyzmnopqrstuvwxyzmnopqrstuvwxyzmnopqrstuvwxyzmnopqrstuvwxyz\") == 14\n    assert candidate(s = \"lmnopqrstuvwxyzabc\") == 15\n    assert candidate(s = \"mnopqrstuvwxyzabcdefghijkl\") == 14\n    assert candidate(s = \"qrsabcdabcdxyz\") == 4\n    assert candidate(s = \"defghijklmnopqrstuvwxyza\") == 23\n    assert candidate(s = \"mnopqrstuvwxyzmnopqrstuvwxyza\") == 14\n    assert candidate(s = \"abcdeabfghicdef\") == 5\n    assert candidate(s = \"xyzabxyzuvwxyza\") == 6\n    assert candidate(s = \"abxyzabcxyz\") == 3\n    assert candidate(s = \"qrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 10\n    assert candidate(s = \"abcdefabcdeabcde\") == 6\n    assert candidate(s = \"pqrsabcd\") == 4\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 26\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzmnopqrstuvwxyz\") == 26\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\") == 26\n    assert candidate(s = \"klmnopqrstuvxyz\") == 12\n    assert candidate(s = \"abababababab\") == 2\n    assert candidate(s = \"mnopqrstuabcdefghijklmnopqrstuvwxyzaabcde\") == 26\n    assert candidate(s = \"mnopqrstuvwxyzabcde\") == 14\n    assert candidate(s = \"xyzabcde\") == 5\n    assert candidate(s = \"mnopqrstuzyxwvutsrqponmlkjihgfedcba\") == 9\n    assert candidate(s = \"qrsabcdabcdabcd\") == 4\n    assert candidate(s = \"mnopqrstuvwxyzabcdefghijklmno\") == 15\n    assert candidate(s = \"abcdeabcdabcdabcdabcde\") == 5\n    assert candidate(s = \"mnopqrstuabcdefghijklmnopqrstuvwxyza\") == 26\n    assert candidate(s = \"aaaaa\") == 1\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 26\n    assert candidate(s = \"zabcdefghijklmnopqrstuvwxyz\") == 26\n    assert candidate(s = \"xyzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxz\") == 3\n    assert candidate(s = \"mnopqrstuuvwxyza\") == 9\n    assert candidate(s = \"abcdefgabcdefgabcdefgabcdefg\") == 7\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n    assert candidate(s = \"qrstuvwxyzabcdefghijklmnop\") == 16\n    assert candidate(s = \"abcdxyzuvwxyza\") == 6\n    assert candidate(s = \"mnopqrstuvwxyzmnopqrstu\") == 14\n    assert candidate(s = \"xyzzyxwvutsrqponmlkjihgfedcba\") == 3\n    assert candidate(s = \"zabcdefghijklmnopqrstuvwxy\") == 25\n    assert candidate(s = \"zabcvwxyz\") == 5\n    assert candidate(s = \"abxyzabcd\") == 4\n    assert candidate(s = \"mnopqrlmnopqr\") == 7\n    assert candidate(s = \"aabcdefghijklmnopqrstuvwxyz\") == 26\n    assert candidate(s = \"abxyzabc\") == 3\n    assert candidate(s = \"qrstuvwpqrstuzyxwvutsrqponmlkjihgfedcba\") == 7\n    assert candidate(s = \"zabcdefghijklmnopqrstuvwxyza\") == 26\n    assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 3\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaabbcc\") == 2\n    assert candidate(s = \"abcdefghijlmnopqrstuvwxyz\") == 15\n    assert candidate(s = \"abcddefghijklmnopqrstuvwxyz\") == 23\n    assert candidate(s = \"abcdeabcdeabcde\") == 5\n    assert candidate(s = \"qrstuvwxyz\") == 10\n    assert candidate(s = \"abcdefghijkabcde\") == 11\n    assert candidate(s = \"abcdefgabcdefgabcdefg\") == 7\n    assert candidate(s = \"abcdefghijlkjihgfedcba\") == 10\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 26\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaedcba\") == 1\n    assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 3\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaabcdefghijklmnopqrstuvwxyza\") == 26\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n    assert candidate(s = \"xyzzyxwvutsrqpomnlkjihgfedcba\") == 3\n    assert candidate(s = \"pqrstuvwxyzabcde\") == 11\n    assert candidate(s = \"lmnopqrsabcd\") == 8\n", "comparison": "exact"}, "public_tests": ["\"abacaba\"", "\"abcde\""], "hints": ["What is the longest possible continuous substring?", "The size of the longest possible continuous substring is at most 26, so we can just brute force the answer."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().longestContinuousSubstring", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:53+00:00", "tests_total": 115, "tests_dropped": 1, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def longestContinuousSubstring(self, s: str) -> int:", "container": "Solution", "callable": "longestContinuousSubstring", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2416, "task_id": "sum-of-prefix-scores-of-strings", "difficulty": "Hard", "problem_description": "You are given an array words of size n consisting of non-empty strings.\n\nWe define the score of a string term as the number of strings words[i] such that term is a prefix of words[i].\n\n- For example, if words = [\"a\", \"ab\", \"abc\", \"cab\"], then the score of \"ab\" is 2, since \"ab\" is a prefix of both \"ab\" and \"abc\".\n\nReturn an array answer of size n where answer[i] is the sum of scores of every non-empty prefix of words[i].\n\nNote that a string is considered as a prefix of itself.\n\nExample 1:\n\nInput: words = [\"abc\",\"ab\",\"bc\",\"b\"]\nOutput: [5,4,3,2]\nExplanation: The answer for each string is the following:\n- \"abc\" has 3 prefixes: \"a\", \"ab\", and \"abc\".\n- There are 2 strings with the prefix \"a\", 2 strings with the prefix \"ab\", and 1 string with the prefix \"abc\".\nThe total is answer[0] = 2 + 2 + 1 = 5.\n- \"ab\" has 2 prefixes: \"a\" and \"ab\".\n- There are 2 strings with the prefix \"a\", and 2 strings with the prefix \"ab\".\nThe total is answer[1] = 2 + 2 = 4.\n- \"bc\" has 2 prefixes: \"b\" and \"bc\".\n- There are 2 strings with the prefix \"b\", and 1 string with the prefix \"bc\".\nThe total is answer[2] = 2 + 1 = 3.\n- \"b\" has 1 prefix: \"b\".\n- There are 2 strings with the prefix \"b\".\nThe total is answer[3] = 2.\n\nExample 2:\n\nInput: words = [\"abcd\"]\nOutput: [4]\nExplanation:\n\"abcd\" has 4 prefixes: \"a\", \"ab\", \"abc\", and \"abcd\".\nEach prefix has a score of one, so the total is answer[0] = 1 + 1 + 1 + 1 = 4.\n\nConstraints:\n\n- 1 <= words.length <= 1000\n- 1 <= words[i].length <= 1000\n- words[i] consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(words = ['hello', 'hell', 'he', 'h']) == [12, 11, 7, 4]\n    assert candidate(words = ['abc', 'ab', 'bc', 'b']) == [5, 4, 3, 2]\n    assert candidate(words = ['a', 'b', 'c', 'd']) == [1, 1, 1, 1]\n    assert candidate(words = ['aa', 'aaa', 'aaaa', 'aaaaa']) == [8, 11, 13, 14]\n    assert candidate(words = ['a', 'ab', 'abc', 'abcd']) == [4, 7, 9, 10]\n    assert candidate(words = ['abcde', 'abcd', 'abc', 'ab', 'a']) == [15, 14, 12, 9, 5]\n    assert candidate(words = ['b', 'bb', 'bbb', 'bbbb']) == [4, 7, 9, 10]\n    assert candidate(words = ['xyz', 'xy', 'x']) == [6, 5, 3]\n    assert candidate(words = ['abcd']) == [4]\n    assert candidate(words = ['xyz', 'xy', 'x', 'xyzabc']) == [9, 7, 4, 12]\n    assert candidate(words = ['aa', 'ab', 'ac', 'ba', 'bb', 'bc', 'ca', 'cb', 'cc']) == [4, 4, 4, 4, 4, 4, 4, 4, 4]\n    assert candidate(words = ['aaaa', 'aa', 'a']) == [7, 5, 3]\n    assert candidate(words = ['dynamic', 'dyn', 'dynam', 'dynamicp', 'dynamicpr', 'dynamicpro', 'dynamicprogra', 'dynamicprogram', 'dynamicprogramming']) == [57, 27, 43, 63, 68, 72, 81, 83, 87]\n    assert candidate(words = ['optimization', 'optimize', 'opt', 'opti', 'optim', 'optimi']) == [37, 33, 18, 23, 27, 30]\n    assert candidate(words = ['xylophone', 'xylo', 'xylophon', 'xy', 'xyl', 'xylophonist', 'xylophoneplayer', 'xylophoneplayerperformance']) == [52, 29, 49, 16, 23, 52, 64, 75]\n    assert candidate(words = ['xylophone', 'xylography', 'xylo', 'xylophoneography', 'xyl', 'xylonate']) == [33, 29, 23, 40, 18, 27]\n    assert candidate(words = ['aabbcc', 'aabbc', 'aabb', 'aa', 'a', 'aabbbccc', 'aabbbbcccc', 'aabbbbccccd']) == [30, 29, 27, 15, 8, 33, 40, 41]\n    assert candidate(words = ['aaaa', 'aaab', 'aaac', 'aabb', 'aabc', 'abaa', 'abab', 'abac', 'abba', 'abbb', 'abbc', 'abca', 'abcb', 'abcc', 'acaa', 'acab', 'acac', 'acba', 'acbb', 'acbc', 'acca', 'accc']) == [31, 31, 31, 30, 30, 35, 35, 35, 35, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34, 34, 33, 33]\n    assert candidate(words = ['abacax', 'abaca', 'bacax', 'abac', 'ab']) == [17, 16, 5, 14, 8]\n    assert candidate(words = ['apple', 'app', 'application', 'applesauce', 'appetizer']) == [20, 15, 25, 25, 21]\n    assert candidate(words = ['pneumonoultramicroscopicsilicovolcanoconiosis', 'pneumo', 'pneumonoultra', 'pneumonoultramicro', 'pneumonoultramicroscopicsilico', 'pneumonoultramicroscopicsilicovolcano', 'pneumo']) == [155, 42, 77, 97, 133, 147, 42]\n    assert candidate(words = ['programming', 'program', 'pro', 'prog', 'progr']) == [30, 26, 15, 19, 22]\n    assert candidate(words = ['algorithm', 'algo', 'al', 'alex', 'ale', 'all']) == [21, 16, 12, 15, 14, 13]\n    assert candidate(words = ['abcdabcd', 'abcabc', 'ababab', 'aaaaaa', 'bbbbbb', 'cccccc', 'dddddd']) == [14, 12, 11, 9, 6, 6, 6]\n    assert candidate(words = ['algorithm', 'algo', 'alg', 'algor', 'algorith', 'algori']) == [35, 23, 18, 27, 34, 30]\n    assert candidate(words = ['aabbcc', 'aabbc', 'aabb', 'aab', 'aa', 'a', 'aabbbcc', 'aabbb', 'aabbbb']) == [33, 32, 30, 24, 17, 9, 35, 33, 34]\n    assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa']) == [9, 17, 24, 30, 35, 39, 42, 44, 45]\n    assert candidate(words = ['prefix', 'pre', 'prefer', 'preference', 'presentation', 'president', 'presidency']) == [26, 21, 28, 32, 32, 33, 34]\n    assert candidate(words = ['hello', 'hell', 'he', 'h', 'hero', 'helium', 'helper']) == [20, 19, 13, 7, 15, 20, 20]\n    assert candidate(words = ['unique', 'un', 'uni', 'unic', 'uniqu', 'uniquee', 'uniqueee', 'uniqueeee']) == [37, 16, 23, 24, 33, 40, 42, 43]\n    assert candidate(words = ['prefix', 'pre', 'pref', 'prefi', 'prefin', 'prefixation', 'prefixes', 'prefixing', 'prefixes', 'preference', 'prefer']) == [55, 33, 43, 50, 51, 60, 59, 58, 59, 51, 47]\n    assert candidate(words = ['apple', 'app', 'ap', 'application', 'appetite']) == [17, 14, 10, 23, 19]\n    assert candidate(words = ['aabbcc', 'aab', 'abc', 'aac', 'acc', 'aaa', 'bbb', 'ccc', 'aabbc', 'aabbbc', 'aabbbcc', 'aabbbccc']) == [32, 24, 12, 19, 12, 19, 3, 3, 31, 35, 37, 38]\n    assert candidate(words = ['complex', 'com', 'compl', 'complexity', 'composite']) == [26, 15, 22, 29, 24]\n    assert candidate(words = ['cat', 'cater', 'caterpillar', 'catering', 'caterer', 'caterers', 'catered', 'catering']) == [24, 38, 44, 44, 43, 44, 42, 44]\n    assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa', 'aaaaaaaaaa']) == [10, 19, 27, 34, 40, 45, 49, 52, 54, 55]\n    assert candidate(words = ['optimization', 'opt', 'opti', 'optim', 'optimiz', 'optimise', 'optimized']) == [44, 21, 27, 32, 39, 38, 41]\n    assert candidate(words = ['data', 'dat', 'database', 'datascience', 'datastructure']) == [19, 15, 23, 27, 29]\n    assert candidate(words = ['car', 'cat', 'catch', 'cart', 'card', 'carpet']) == [16, 14, 16, 17, 17, 19]\n    assert candidate(words = ['banana', 'band', 'ball', 'bat', 'basketball']) == [15, 13, 12, 11, 18]\n    assert candidate(words = ['programming', 'program', 'pro', 'pr', 'p', 'prefix', 'pre', 'preprocessing']) == [30, 26, 18, 15, 8, 21, 18, 28]\n    assert candidate(words = ['longword', 'longworder', 'longworderer', 'longwordererest', 'longwordereresterest']) == [40, 48, 54, 60, 65]\n    assert candidate(words = ['algorithm', 'algo', 'al', 'alex', 'algorithmic', 'algorithms']) == [35, 20, 12, 14, 37, 36]\n    assert candidate(words = ['aaa', 'aab', 'aac', 'aba', 'abb', 'abc', 'aca', 'acb', 'acc', 'baa', 'bab', 'bac', 'bba', 'bbb', 'bbc', 'bca', 'bcb', 'bcc', 'caa', 'cab', 'cac', 'cba', 'cbb', 'cbc', 'cca', 'ccb', 'ccc']) == [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]\n    assert candidate(words = ['backtracking', 'back', 'backt', 'backtr', 'backtra', 'backtrac', 'backtrack', 'backtracki', 'backtrackin', 'backtrackin', 'backtrackinga', 'backtrackingal', 'backtrackingalg', 'backtrackingalgo']) == [131, 56, 69, 81, 92, 102, 111, 119, 126, 126, 135, 138, 140, 141]\n    assert candidate(words = ['prefix', 'pre', 'pres', 'presum', 'pressure']) == [18, 15, 18, 20, 22]\n    assert candidate(words = ['interview', 'inter', 'inte', 'interw', 'interv', 'intervi', 'interviewe']) == [45, 34, 28, 35, 38, 41, 46]\n    assert candidate(words = ['zebra', 'zoo', 'zookeeper', 'zoozoo', 'ze', 'zee', 'z']) == [13, 13, 19, 16, 10, 11, 7]\n    assert candidate(words = ['repeated', 'repeat', 'rep', 're', 'r', 'peated', 'eat', 'e', 't', 'ted', 'tedious', 'tediousness']) == [20, 18, 12, 9, 5, 6, 4, 2, 4, 10, 18, 22]\n    assert candidate(words = ['banana', 'ban', 'bananas', 'band', 'bandana', 'bandwidth']) == [24, 18, 25, 21, 24, 26]\n    assert candidate(words = ['repeated', 'repeats', 'repeat', 'repeating', 'repeatedly', 'repeatability']) == [40, 37, 36, 39, 42, 43]\n    assert candidate(words = ['algorithm', 'al', 'algo', 'all', 'algorithms', 'application', 'app']) == [28, 12, 18, 13, 29, 19, 11]\n    assert candidate(words = ['flower', 'flow', 'flight', 'flour', 'flourish', 'flourishingly']) == [21, 19, 16, 23, 29, 34]\n    assert candidate(words = ['banana', 'ban', 'band', 'bandana', 'bandanna', 'banda']) == [21, 18, 22, 28, 29, 25]\n    assert candidate(words = ['hello', 'hell', 'he', 'h', 'helicopter', 'helium', 'help', 'hero', 'her', 'hemoglobin']) == [27, 26, 19, 10, 32, 28, 25, 22, 21, 27]\n    assert candidate(words = ['unique', 'uniques', 'unicorn', 'unicycle', 'universality']) == [21, 22, 20, 21, 24]\n    assert candidate(words = ['optimization', 'optimizer', 'optimize', 'optimal', 'optimism', 'optimist', 'optimistic', 'optimum', 'opt', 'optional']) == [61, 59, 58, 49, 57, 58, 60, 49, 30, 43]\n    assert candidate(words = ['complex', 'complicated', 'complicate', 'complexity', 'complexion', 'complexing', 'complexified', 'complexify', 'complexifies', 'complexing']) == [66, 61, 60, 75, 75, 77, 81, 77, 81, 77]\n    assert candidate(words = ['abracadabra', 'abra', 'bracadabra', 'bracada', 'braca', 'bracad', 'bracadab', 'bracadabr', 'bracadabra', 'bracadabram', 'bracadabramm']) == [15, 8, 75, 60, 45, 53, 66, 71, 75, 77, 78]\n    assert candidate(words = ['hello', 'hell', 'help', 'hero', 'her', 'hers', 'he', 'hem', 'hemoglobin']) == [24, 23, 22, 22, 21, 22, 18, 20, 27]\n    assert candidate(words = ['trie', 'tr', 'tree', 'tries', 'trigger', 'trig']) == [18, 12, 14, 19, 21, 18]\n    assert candidate(words = ['aabbcc', 'aabbc', 'aabb', 'aab', 'aa', 'a']) == [21, 20, 18, 15, 11, 6]\n    assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcde', 'abcdef', 'abcdefghij', 'a']) == [48, 21, 24, 32, 5]\n    assert candidate(words = ['algorithm', 'algo', 'algor', 'algorit', 'algorith', 'algorithme', 'algori', 'algorithmically']) == [57, 32, 39, 50, 54, 58, 45, 63]\n    assert candidate(words = ['banana', 'ban', 'band', 'bandana', 'bandwidth']) == [18, 15, 18, 21, 23]\n    assert candidate(words = ['algorithm', 'algebra', 'alien', 'alliance', 'alibi', 'allocate', 'allot', 'allow', 'allude', 'allure', 'alloy', 'ally']) == [32, 30, 28, 37, 28, 40, 37, 37, 36, 36, 37, 33]\n    assert candidate(words = ['prefix', 'pre', 'pref', 'prefer', 'preference', 'preferred', 'preferring']) == [29, 21, 27, 35, 39, 39, 40]\n    assert candidate(words = ['data', 'database', 'datastructure', 'datamining', 'dataviz', 'datascience', 'datamodel']) == [28, 32, 38, 35, 31, 36, 34]\n    assert candidate(words = ['programming', 'program', 'pro', 'progress', 'profound', 'process', 'progressive']) == [37, 33, 21, 35, 26, 25, 38]\n    assert candidate(words = ['programming', 'program', 'pro', 'programminglanguage', 'prolog', 'protocol']) == [38, 30, 18, 46, 21, 23]\n    assert candidate(words = ['abacaxi', 'abacax', 'abac', 'aba', 'ab', 'a', 'abc', 'abcd', 'abcde']) == [29, 28, 24, 21, 17, 9, 20, 22, 23]\n    assert candidate(words = ['zebra', 'ze', 'zoo', 'zookeeper', 'zest', 'zippy', 'zeta', 'zone']) == [15, 12, 13, 19, 14, 12, 14, 13]\n    assert candidate(words = ['complexity', 'comp', 'compl', 'comple', 'complex', 'complexe', 'complexit']) == [48, 28, 34, 39, 43, 44, 47]\n    assert candidate(words = ['algorithm', 'algebra', 'al', 'algorithmically', 'algo']) == [27, 18, 10, 33, 17]\n    assert candidate(words = ['unique', 'un', 'uni', 'unic', 'uniqu', 'uniqueness', 'uniquely', 'uniques']) == [37, 16, 23, 24, 33, 41, 39, 38]\n    assert candidate(words = ['datastructure', 'data', 'datas', 'datast', 'datastr', 'datastru', 'datastruc']) == [52, 28, 34, 39, 43, 46, 48]\n    assert candidate(words = ['prefix', 'prefixes', 'pref', 'prefer', 'prefixing']) == [26, 28, 20, 22, 29]\n    assert candidate(words = ['apple', 'app', 'ap', 'a', 'application']) == [15, 12, 9, 5, 21]\n    assert candidate(words = ['banana', 'bandana', 'band', 'bandwidth', 'bandage']) == [18, 23, 19, 24, 23]\n    assert candidate(words = ['abacaxi', 'abac', 'aba', 'ab', 'a', 'abacax', 'abacaxs', 'abacaxus']) == [35, 26, 21, 15, 8, 34, 35, 36]\n    assert candidate(words = ['interview', 'inter', 'interac', 'interactive', 'interact', 'interactivity']) == [34, 30, 38, 46, 41, 48]\n    assert candidate(words = ['prefix', 'prefixing', 'prefixation', 'prefixer', 'pref', 'pre', 'p']) == [32, 35, 37, 34, 24, 19, 7]\n    assert candidate(words = ['zebra', 'zebr', 'zeb', 'ze', 'z', 'zebraa', 'zebrab', 'zebrac', 'zebrad']) == [35, 30, 24, 17, 9, 36, 36, 36, 36]\n    assert candidate(words = ['cat', 'cater', 'category', 'categories', 'caterpillar', 'catering', 'catered', 'caterer', 'caterers', 'catering']) == [30, 46, 46, 48, 52, 52, 50, 51, 52, 52]\n    assert candidate(words = ['abacaxi', 'abacax', 'abac', 'aba', 'ab', 'a', 'bacaxi', 'bacax', 'bac', 'ba', 'b']) == [23, 22, 18, 15, 11, 6, 17, 16, 12, 9, 5]\n    assert candidate(words = ['abacax', 'abaca', 'ab', 'abc', 'abcd', 'abcde', 'abcdef']) == [21, 20, 14, 18, 21, 23, 24]\n    assert candidate(words = ['xylophone', 'xylo', 'xylophon', 'xylophone', 'xylophones', 'xylophonist', 'xylophonists', 'xylophonistic', 'xylophonistically', 'xylophonists', 'xylophonist']) == [87, 44, 84, 87, 88, 102, 104, 106, 110, 104, 102]\n    assert candidate(words = ['algorithm', 'algo', 'al', 'alex', 'alert']) == [19, 14, 10, 13, 14]\n    assert candidate(words = ['banana', 'ban', 'band', 'bandana', 'bandwidth', 'bandage']) == [21, 18, 22, 26, 27, 26]\n    assert candidate(words = ['test', 'testing', 'tested', 'testify', 'testimony', 'testimonial', 'testament', 'testamentary', 'testator', 'testatrix']) == [40, 46, 42, 46, 51, 53, 52, 55, 48, 49]\n    assert candidate(words = ['banana', 'band', 'bandana', 'bandanna', 'bandage', 'bandaid']) == [21, 23, 30, 31, 29, 29]\n    assert candidate(words = ['abcd', 'abc', 'ab', 'a', 'zyx', 'zy', 'z', 'mnop', 'mno', 'mn', 'm']) == [10, 9, 7, 4, 6, 5, 3, 10, 9, 7, 4]\n    assert candidate(words = ['optimization', 'optimizer', 'optimize', 'optimal', 'optimism', 'optimist', 'optimum', 'option', 'optional', 'opt', 'optic', 'optics']) == [67, 65, 64, 56, 62, 62, 56, 51, 53, 36, 49, 50]\n    assert candidate(words = ['banana', 'ban', 'band', 'bandana', 'bandanna', 'banda', 'bandanaaa']) == [24, 21, 26, 35, 35, 30, 37]\n    assert candidate(words = ['supercalifragilisticexpialidocious', 'super', 'supercal', 'supercalifrag', 'supercalifragilistic', 'supercalifragilisticex', 'supercalifragilisticexp', 'supercalifragilisticexpia', 'supercalifragilisticexpiali', 'supercalifragilisticexpialidoc', 'supercalifragilisticexpialidociou', 'supercalifragilisticexpialidociousness']) == [274, 60, 93, 143, 206, 222, 229, 241, 251, 263, 272, 278]\n    assert candidate(words = ['interspecies', 'inter', 'interstellar', 'interact', 'interaction', 'interference', 'internet', 'interim']) == [48, 40, 48, 46, 49, 47, 43, 42]\n", "comparison": "exact"}, "public_tests": ["[\"abc\",\"ab\",\"bc\",\"b\"]", "[\"abcd\"]"], "hints": ["What data structure will allow you to efficiently keep track of the score of each prefix?", "Use a Trie. Insert all the words into it, and keep a counter at each node that will tell you how many times we have visited each prefix."], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().sumPrefixScores", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:51:57+00:00", "tests_total": 96, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "string", "trie", "counting"]}, "language": "python", "interface": {"raw_signature": "def sumPrefixScores(self, words: list[str]) -> list[int]:", "container": "Solution", "callable": "sumPrefixScores", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2418, "task_id": "sort-the-people", "difficulty": "Easy", "problem_description": "You are given an array of strings names, and an array heights that consists of distinct positive integers. Both arrays are of length n.\n\nFor each index i, names[i] and heights[i] denote the name and height of the i^th person.\n\nReturn names sorted in descending order by the people's heights.\n\nExample 1:\n\nInput: names = [\"Mary\",\"John\",\"Emma\"], heights = [180,165,170]\nOutput: [\"Mary\",\"Emma\",\"John\"]\nExplanation: Mary is the tallest, followed by Emma and John.\n\nExample 2:\n\nInput: names = [\"Alice\",\"Bob\",\"Bob\"], heights = [155,185,150]\nOutput: [\"Bob\",\"Alice\",\"Bob\"]\nExplanation: The first Bob is the tallest, followed by Alice and the second Bob.\n\nConstraints:\n\n- n == names.length == heights.length\n- 1 <= n <= 10^3\n- 1 <= names[i].length <= 20\n- 1 <= heights[i] <= 10^5\n- names[i] consists of lower and upper case English letters.\n- All the values of heights are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(names = ['Zoe', 'Lily', 'Rose'],heights = [150, 145, 155]) == ['Rose', 'Zoe', 'Lily']\n    assert candidate(names = ['Qwen', 'Alibaba', 'Cloud'],heights = [200, 190, 180]) == ['Qwen', 'Alibaba', 'Cloud']\n    assert candidate(names = ['Ava', 'Sophia', 'Isabella'],heights = [160, 165, 170]) == ['Isabella', 'Sophia', 'Ava']\n    assert candidate(names = ['Mary', 'John', 'Emma'],heights = [180, 165, 170]) == ['Mary', 'Emma', 'John']\n    assert candidate(names = ['A', 'B', 'C', 'D'],heights = [150, 160, 170, 180]) == ['D', 'C', 'B', 'A']\n    assert candidate(names = ['Ava', 'Ella', 'Olivia'],heights = [168, 162, 170]) == ['Olivia', 'Ava', 'Ella']\n    assert candidate(names = ['Alice', 'Bob', 'Bob'],heights = [155, 185, 150]) == ['Bob', 'Alice', 'Bob']\n    assert candidate(names = ['Zoe', 'Liam', 'Noah'],heights = [165, 175, 185]) == ['Noah', 'Liam', 'Zoe']\n    assert candidate(names = ['Noah', 'Liam', 'Mason'],heights = [185, 180, 175]) == ['Noah', 'Liam', 'Mason']\n    assert candidate(names = ['Mia', 'Ella', 'Olivia'],heights = [168, 162, 170]) == ['Olivia', 'Mia', 'Ella']\n    assert candidate(names = ['Tom', 'Jerry', 'Spike'],heights = [190, 160, 175]) == ['Tom', 'Spike', 'Jerry']\n    assert candidate(names = ['Zoe', 'Liam', 'Noah'],heights = [175, 180, 165]) == ['Liam', 'Zoe', 'Noah']\n    assert candidate(names = ['Z', 'Y', 'X'],heights = [165, 175, 185]) == ['X', 'Y', 'Z']\n    assert candidate(names = ['Anna', 'Elsa', 'Olaf'],heights = [170, 180, 160]) == ['Elsa', 'Anna', 'Olaf']\n    assert candidate(names = ['Liam', 'Noah', 'Oliver', 'Elijah', 'James', 'William', 'Benjamin'],heights = [179, 178, 177, 176, 175, 174, 173]) == ['Liam', 'Noah', 'Oliver', 'Elijah', 'James', 'William', 'Benjamin']\n    assert candidate(names = ['William', 'James', 'Benjamin', 'Henry'],heights = [190, 170, 180, 160]) == ['William', 'Benjamin', 'James', 'Henry']\n    assert candidate(names = ['Jackson', 'Aiden', 'Mason', 'Lucas'],heights = [182, 188, 178, 180]) == ['Aiden', 'Jackson', 'Lucas', 'Mason']\n    assert candidate(names = ['Dominic', 'Penelope', 'Victor', 'Emilia', 'Mason'],heights = [178, 173, 189, 169, 174]) == ['Victor', 'Dominic', 'Mason', 'Penelope', 'Emilia']\n    assert candidate(names = ['Ezra', 'Isabella', 'Oliver', 'Sophia', 'Noah', 'Emma', 'James', 'Amelia', 'Benjamin', 'Ava', 'Elijah', 'Liam'],heights = [177, 165, 183, 170, 185, 171, 179, 172, 180, 167, 182, 184]) == ['Noah', 'Liam', 'Oliver', 'Elijah', 'Benjamin', 'James', 'Ezra', 'Amelia', 'Emma', 'Sophia', 'Ava', 'Isabella']\n    assert candidate(names = ['Daniel', 'Matthew', 'Ethan', 'Logan', 'Jackson'],heights = [175, 170, 165, 160, 155]) == ['Daniel', 'Matthew', 'Ethan', 'Logan', 'Jackson']\n    assert candidate(names = ['William', 'James', 'George', 'Charles'],heights = [188, 192, 178, 180]) == ['James', 'William', 'Charles', 'George']\n    assert candidate(names = ['Liam', 'Noah', 'Oliver', 'Elijah', 'William'],heights = [180, 178, 175, 173, 170]) == ['Liam', 'Noah', 'Oliver', 'Elijah', 'William']\n    assert candidate(names = ['Sophia', 'Jackson', 'Mia', 'Logan'],heights = [160, 200, 180, 170]) == ['Jackson', 'Mia', 'Logan', 'Sophia']\n    assert candidate(names = ['Amelia', 'Olivia', 'Emma', 'Sophia'],heights = [155, 165, 175, 185]) == ['Sophia', 'Emma', 'Olivia', 'Amelia']\n    assert candidate(names = ['Emma', 'Noah', 'Olivia', 'Elijah', 'Ava', 'Sophia'],heights = [173, 186, 168, 183, 170, 165]) == ['Noah', 'Elijah', 'Emma', 'Ava', 'Olivia', 'Sophia']\n    assert candidate(names = ['Levi', 'Carter', 'Aria', 'Sebastian', 'Avery'],heights = [175, 184, 168, 189, 176]) == ['Sebastian', 'Carter', 'Avery', 'Levi', 'Aria']\n    assert candidate(names = ['Sophia', 'Olivia', 'Isabella', 'Ava', 'Emma'],heights = [162, 178, 168, 173, 175]) == ['Olivia', 'Emma', 'Ava', 'Isabella', 'Sophia']\n    assert candidate(names = ['William', 'James', 'Oliver', 'Noah', 'Elijah', 'Lucas'],heights = [195, 194, 193, 192, 191, 190]) == ['William', 'James', 'Oliver', 'Noah', 'Elijah', 'Lucas']\n    assert candidate(names = ['Zachary', 'Christopher', 'Jonathan', 'Matthew'],heights = [195, 190, 180, 185]) == ['Zachary', 'Christopher', 'Matthew', 'Jonathan']\n    assert candidate(names = ['Charlie', 'Delta', 'Echo', 'Foxtrot', 'Golf'],heights = [160, 165, 170, 175, 180]) == ['Golf', 'Foxtrot', 'Echo', 'Delta', 'Charlie']\n    assert candidate(names = ['Ava', 'Isabella', 'Sophia', 'Emma', 'Olivia', 'Mia'],heights = [155, 157, 158, 160, 159, 156]) == ['Emma', 'Olivia', 'Sophia', 'Isabella', 'Mia', 'Ava']\n    assert candidate(names = ['Grace', 'Heidi', 'Ivy', 'Judy', 'Kara'],heights = [158, 168, 178, 188, 198]) == ['Kara', 'Judy', 'Ivy', 'Heidi', 'Grace']\n    assert candidate(names = ['Mila', 'Aaron', 'Jasper', 'Sophie'],heights = [170, 160, 200, 180]) == ['Jasper', 'Sophie', 'Mila', 'Aaron']\n    assert candidate(names = ['Finn', 'Jake', 'BMO', 'Marceline', 'LSP'],heights = [160, 170, 155, 180, 150]) == ['Marceline', 'Jake', 'Finn', 'BMO', 'LSP']\n    assert candidate(names = ['Zoe', 'Chris', 'Ava', 'Ian'],heights = [165, 190, 175, 180]) == ['Chris', 'Ian', 'Ava', 'Zoe']\n    assert candidate(names = ['Grace', 'Katherine', 'Ava', 'Sophie', 'Liam'],heights = [165, 172, 160, 170, 180]) == ['Liam', 'Katherine', 'Sophie', 'Grace', 'Ava']\n    assert candidate(names = ['Olivia', 'Emma', 'Ava', 'Sophia'],heights = [158, 159, 160, 157]) == ['Ava', 'Emma', 'Olivia', 'Sophia']\n    assert candidate(names = ['Evelyn', 'Arthur', 'Sophie', 'Miles'],heights = [160, 190, 180, 175]) == ['Arthur', 'Sophie', 'Miles', 'Evelyn']\n    assert candidate(names = ['Ethan', 'Abigail', 'Daniel', 'Ella'],heights = [185, 168, 195, 175]) == ['Daniel', 'Ethan', 'Ella', 'Abigail']\n    assert candidate(names = ['Ava', 'Ella', 'Scarlett', 'Grace'],heights = [185, 175, 165, 155]) == ['Ava', 'Ella', 'Scarlett', 'Grace']\n    assert candidate(names = ['Amelia', 'Olivia', 'Ava', 'Isla'],heights = [168, 169, 170, 171]) == ['Isla', 'Ava', 'Olivia', 'Amelia']\n    assert candidate(names = ['Noah', 'Sophia', 'Mia', 'Ethan'],heights = [195, 180, 175, 170]) == ['Noah', 'Sophia', 'Mia', 'Ethan']\n    assert candidate(names = ['Alex', 'Brian', 'Carter', 'David', 'Ethan'],heights = [155, 165, 175, 185, 195]) == ['Ethan', 'David', 'Carter', 'Brian', 'Alex']\n    assert candidate(names = ['Jonathan', 'Katherine', 'Lucas', 'Mia', 'Nina'],heights = [175, 165, 180, 170, 160]) == ['Lucas', 'Jonathan', 'Mia', 'Katherine', 'Nina']\n    assert candidate(names = ['Lucas', 'Hannah', 'Olivia', 'Avery'],heights = [185, 168, 190, 175]) == ['Olivia', 'Lucas', 'Avery', 'Hannah']\n    assert candidate(names = ['Nina', 'Nora', 'Nina', 'Nora'],heights = [160, 162, 158, 159]) == ['Nora', 'Nina', 'Nora', 'Nina']\n    assert candidate(names = ['Daniel', 'Matilda', 'Samuel', 'Lucas', 'Mia', 'Emily', 'Oliver', 'Ava'],heights = [182, 165, 178, 184, 170, 167, 190, 173]) == ['Oliver', 'Lucas', 'Daniel', 'Samuel', 'Ava', 'Mia', 'Emily', 'Matilda']\n    assert candidate(names = ['Sophia', 'Olivia', 'Ava', 'Isabella', 'Mia'],heights = [160, 165, 170, 175, 180]) == ['Mia', 'Isabella', 'Ava', 'Olivia', 'Sophia']\n    assert candidate(names = ['Sophia', 'Oliver', 'Isabella', 'Noah'],heights = [172, 180, 168, 182]) == ['Noah', 'Oliver', 'Sophia', 'Isabella']\n    assert candidate(names = ['Zoe', 'Sophia', 'Ava', 'Isabella'],heights = [163, 164, 165, 162]) == ['Ava', 'Sophia', 'Zoe', 'Isabella']\n    assert candidate(names = ['Oliver', 'Amelia', 'Evelyn', 'Jasper'],heights = [185, 170, 180, 190]) == ['Jasper', 'Oliver', 'Evelyn', 'Amelia']\n    assert candidate(names = ['Emily', 'Emma', 'Mia', 'Sophia', 'Isabella', 'Ava', 'Olivia'],heights = [163, 164, 162, 165, 166, 161, 160]) == ['Isabella', 'Sophia', 'Emma', 'Emily', 'Mia', 'Ava', 'Olivia']\n    assert candidate(names = ['Isabella', 'Sophia', 'Olivia', 'Ava', 'Emma'],heights = [162, 172, 182, 192, 202]) == ['Emma', 'Ava', 'Olivia', 'Sophia', 'Isabella']\n    assert candidate(names = ['Liam', 'Noah', 'Oliver', 'Lucas', 'Ethan'],heights = [200, 199, 198, 197, 196]) == ['Liam', 'Noah', 'Oliver', 'Lucas', 'Ethan']\n    assert candidate(names = ['Scarlett', 'Ava', 'Emma', 'Olivia', 'Sophia'],heights = [175, 180, 170, 165, 185]) == ['Sophia', 'Ava', 'Scarlett', 'Emma', 'Olivia']\n    assert candidate(names = ['Sophia', 'Emma', 'Ava', 'Olivia', 'Isabella', 'Mia'],heights = [169, 168, 167, 166, 165, 164]) == ['Sophia', 'Emma', 'Ava', 'Olivia', 'Isabella', 'Mia']\n    assert candidate(names = ['Benjamin', 'Logan', 'Jackson', 'David', 'Aiden'],heights = [150, 160, 170, 180, 190]) == ['Aiden', 'David', 'Jackson', 'Logan', 'Benjamin']\n    assert candidate(names = ['Mia', 'Evelyn', 'Abigail', 'Scarlett', 'Amelia'],heights = [180, 175, 170, 165, 160]) == ['Mia', 'Evelyn', 'Abigail', 'Scarlett', 'Amelia']\n    assert candidate(names = ['Camila', 'Lincoln', 'Madison', 'Isaac', 'Scarlett'],heights = [167, 187, 170, 182, 163]) == ['Lincoln', 'Isaac', 'Madison', 'Camila', 'Scarlett']\n    assert candidate(names = ['Sophia', 'Isabella', 'Olivia', 'Ava', 'Mia'],heights = [162, 171, 168, 165, 169]) == ['Isabella', 'Mia', 'Olivia', 'Ava', 'Sophia']\n    assert candidate(names = ['Theodore', 'George', 'Thomas', 'James'],heights = [175, 185, 180, 170]) == ['George', 'Thomas', 'Theodore', 'James']\n    assert candidate(names = ['Sam', 'Max', 'Leo', 'Sam'],heights = [185, 182, 179, 184]) == ['Sam', 'Sam', 'Max', 'Leo']\n    assert candidate(names = ['Charlotte', 'Sophia', 'Ava', 'Isabella'],heights = [165, 170, 175, 180]) == ['Isabella', 'Ava', 'Sophia', 'Charlotte']\n    assert candidate(names = ['Charlotte', 'Amelia', 'Evelyn', 'Abigail', 'Sofia'],heights = [150, 155, 160, 165, 170]) == ['Sofia', 'Abigail', 'Evelyn', 'Amelia', 'Charlotte']\n    assert candidate(names = ['Lily', 'Aaron', 'Emma', 'Nolan'],heights = [165, 185, 175, 195]) == ['Nolan', 'Aaron', 'Emma', 'Lily']\n    assert candidate(names = ['Sophia', 'Isabella', 'Olivia', 'Ava'],heights = [165, 172, 168, 170]) == ['Isabella', 'Ava', 'Olivia', 'Sophia']\n    assert candidate(names = ['Ethan', 'Noah', 'Liam', 'Mason'],heights = [180, 185, 170, 175]) == ['Noah', 'Ethan', 'Mason', 'Liam']\n    assert candidate(names = ['Alexander', 'Sophia', 'Benjamin', 'Charlotte', 'Elijah', 'Mia', 'James', 'Amelia'],heights = [180, 166, 175, 168, 183, 172, 178, 171]) == ['Elijah', 'Alexander', 'James', 'Benjamin', 'Mia', 'Amelia', 'Charlotte', 'Sophia']\n    assert candidate(names = ['William', 'James', 'Oliver', 'Benjamin', 'Elijah', 'Lucas'],heights = [187, 186, 185, 184, 183, 182]) == ['William', 'James', 'Oliver', 'Benjamin', 'Elijah', 'Lucas']\n    assert candidate(names = ['Eva', 'Nathan', 'Ella', 'Samuel', 'Sophia'],heights = [169, 179, 171, 186, 174]) == ['Samuel', 'Nathan', 'Sophia', 'Ella', 'Eva']\n    assert candidate(names = ['Zoe', 'Addison', 'Mia', 'Hannah', 'Abigail'],heights = [168, 167, 166, 165, 164]) == ['Zoe', 'Addison', 'Mia', 'Hannah', 'Abigail']\n    assert candidate(names = ['Benjamin', 'Olivia', 'Daniel', 'Zachary'],heights = [170, 180, 160, 190]) == ['Zachary', 'Olivia', 'Benjamin', 'Daniel']\n    assert candidate(names = ['Carter', 'Jackson', 'Lucas', 'Logan', 'Benjamin'],heights = [190, 185, 180, 175, 170]) == ['Carter', 'Jackson', 'Lucas', 'Logan', 'Benjamin']\n    assert candidate(names = ['Amelia', 'Oliver', 'Ava', 'Noah', 'Sophia', 'Ethan', 'Isabella', 'Elijah'],heights = [172, 188, 169, 185, 171, 182, 168, 184]) == ['Oliver', 'Noah', 'Elijah', 'Ethan', 'Amelia', 'Sophia', 'Ava', 'Isabella']\n    assert candidate(names = ['Michael', 'Christopher', 'Jessica', 'Matthew', 'Ashley'],heights = [182, 178, 165, 180, 170]) == ['Michael', 'Matthew', 'Christopher', 'Ashley', 'Jessica']\n    assert candidate(names = ['Amelia', 'Sophia', 'Isabella', 'Olivia', 'Ava', 'Emma'],heights = [150, 151, 152, 153, 154, 155]) == ['Emma', 'Ava', 'Olivia', 'Isabella', 'Sophia', 'Amelia']\n    assert candidate(names = ['Catherine', 'Margaret', 'Joan', 'Eleanor'],heights = [167, 173, 170, 169]) == ['Margaret', 'Joan', 'Eleanor', 'Catherine']\n    assert candidate(names = ['Mason', 'Jacob', 'William', 'Ethan', 'Alexander'],heights = [155, 165, 175, 185, 195]) == ['Alexander', 'Ethan', 'William', 'Jacob', 'Mason']\n    assert candidate(names = ['Sophia', 'Ava', 'Emma', 'Isabella', 'Olivia', 'Mia', 'Charlotte'],heights = [169, 168, 167, 166, 165, 164, 163]) == ['Sophia', 'Ava', 'Emma', 'Isabella', 'Olivia', 'Mia', 'Charlotte']\n    assert candidate(names = ['Scarlett', 'Avery', 'James', 'Michael', 'Evelyn'],heights = [162, 177, 181, 180, 166]) == ['James', 'Michael', 'Avery', 'Evelyn', 'Scarlett']\n    assert candidate(names = ['Sophia', 'Jackson', 'Ava', 'Lucas', 'Mia', 'Ethan'],heights = [160, 195, 168, 180, 170, 185]) == ['Jackson', 'Ethan', 'Lucas', 'Mia', 'Ava', 'Sophia']\n    assert candidate(names = ['Sophia', 'Isabella', 'Olivia', 'Ava', 'Emma'],heights = [160, 165, 170, 175, 180]) == ['Emma', 'Ava', 'Olivia', 'Isabella', 'Sophia']\n    assert candidate(names = ['Alexander', 'Michael', 'Benjamin', 'Daniel'],heights = [190, 188, 185, 187]) == ['Alexander', 'Michael', 'Daniel', 'Benjamin']\n    assert candidate(names = ['Mia', 'Ethan', 'Amelia', 'Liam', 'Olivia'],heights = [168, 180, 169, 182, 165]) == ['Liam', 'Ethan', 'Amelia', 'Mia', 'Olivia']\n    assert candidate(names = ['Sophia', 'Olivia', 'Ava', 'Isabella'],heights = [165, 170, 175, 180]) == ['Isabella', 'Ava', 'Olivia', 'Sophia']\n    assert candidate(names = ['Alexander', 'Michael', 'William', 'James', 'Benjamin'],heights = [155, 190, 165, 185, 170]) == ['Michael', 'James', 'Benjamin', 'William', 'Alexander']\n    assert candidate(names = ['Emily', 'Emma', 'Sophia', 'Olivia', 'Isabella', 'Ava'],heights = [161, 160, 159, 158, 157, 156]) == ['Emily', 'Emma', 'Sophia', 'Olivia', 'Isabella', 'Ava']\n    assert candidate(names = ['Zoe', 'Lily', 'Rosie', 'Lena'],heights = [160, 162, 158, 159]) == ['Lily', 'Zoe', 'Lena', 'Rosie']\n    assert candidate(names = ['Zoe', 'Abigail', 'Daniel', 'Jackson', 'Harper'],heights = [165, 172, 179, 183, 170]) == ['Jackson', 'Daniel', 'Abigail', 'Harper', 'Zoe']\n    assert candidate(names = ['Jackson', 'Aiden', 'Lucas', 'Caleb', 'Noah'],heights = [151, 161, 171, 181, 191]) == ['Noah', 'Caleb', 'Lucas', 'Aiden', 'Jackson']\n    assert candidate(names = ['Alexander', 'Noah', 'Daniel', 'Matthew', 'Logan'],heights = [182, 181, 183, 180, 179]) == ['Daniel', 'Alexander', 'Noah', 'Matthew', 'Logan']\n    assert candidate(names = ['Liam', 'Noah', 'Oliver', 'Elijah', 'James'],heights = [170, 180, 190, 200, 210]) == ['James', 'Elijah', 'Oliver', 'Noah', 'Liam']\n    assert candidate(names = ['Lucas', 'Mason', 'Logan', 'Ethan'],heights = [178, 177, 179, 176]) == ['Logan', 'Lucas', 'Mason', 'Ethan']\n    assert candidate(names = ['Peter', 'Paul', 'Mary', 'John', 'Jane'],heights = [175, 180, 165, 170, 160]) == ['Paul', 'Peter', 'John', 'Mary', 'Jane']\n    assert candidate(names = ['William', 'James', 'Benjamin', 'Henry', 'Noah', 'Liam'],heights = [185, 180, 175, 170, 190, 195]) == ['Liam', 'Noah', 'William', 'James', 'Benjamin', 'Henry']\n    assert candidate(names = ['Zoe', 'Lily', 'Ella', 'Amelia'],heights = [160, 165, 170, 175]) == ['Amelia', 'Ella', 'Lily', 'Zoe']\n    assert candidate(names = ['Amelia', 'Connor', 'Sophia', 'Ethan'],heights = [175, 195, 180, 185]) == ['Connor', 'Ethan', 'Sophia', 'Amelia']\n    assert candidate(names = ['William', 'James', 'Oliver', 'Benjamin', 'Elijah'],heights = [190, 185, 180, 175, 170]) == ['William', 'James', 'Oliver', 'Benjamin', 'Elijah']\n    assert candidate(names = ['Emily', 'Ava', 'Sophia', 'Charlotte', 'Isabella'],heights = [160, 170, 165, 155, 175]) == ['Isabella', 'Ava', 'Sophia', 'Emily', 'Charlotte']\n    assert candidate(names = ['Liam', 'Noah', 'Oliver', 'Elijah', 'William', 'James'],heights = [179, 178, 177, 176, 175, 174]) == ['Liam', 'Noah', 'Oliver', 'Elijah', 'William', 'James']\n    assert candidate(names = ['Jonathan', 'Jordan', 'Jack', 'Jared', 'James', 'Jackson'],heights = [198, 197, 196, 195, 194, 193]) == ['Jonathan', 'Jordan', 'Jack', 'Jared', 'James', 'Jackson']\n    assert candidate(names = ['Zoe', 'Yasmin', 'Xander', 'Will', 'Vera'],heights = [150, 160, 170, 180, 190]) == ['Vera', 'Will', 'Xander', 'Yasmin', 'Zoe']\n    assert candidate(names = ['Ava', 'Isabella', 'Sophia', 'Mia'],heights = [165, 175, 185, 155]) == ['Sophia', 'Isabella', 'Ava', 'Mia']\n    assert candidate(names = ['Zara', 'Oliver', 'Isabella', 'Charlie'],heights = [175, 190, 165, 180]) == ['Oliver', 'Charlie', 'Zara', 'Isabella']\n    assert candidate(names = ['Alex', 'Brian', 'Craig', 'David', 'Evan'],heights = [173, 171, 175, 169, 172]) == ['Craig', 'Alex', 'Evan', 'Brian', 'David']\n    assert candidate(names = ['Alexander', 'Michael', 'James', 'John', 'Daniel', 'David'],heights = [172, 171, 173, 174, 175, 176]) == ['David', 'Daniel', 'John', 'James', 'Alexander', 'Michael']\n    assert candidate(names = ['Scarlett', 'William', 'Lily', 'James', 'Ava', 'Thomas', 'Ella', 'Noah', 'Ethan', 'Mia', 'Olivia'],heights = [174, 185, 167, 180, 168, 182, 170, 183, 181, 169, 165]) == ['William', 'Noah', 'Thomas', 'Ethan', 'James', 'Scarlett', 'Ella', 'Mia', 'Ava', 'Lily', 'Olivia']\n    assert candidate(names = ['Emma', 'Charlotte', 'Ava', 'Logan', 'Benjamin'],heights = [163, 170, 167, 178, 185]) == ['Benjamin', 'Logan', 'Charlotte', 'Ava', 'Emma']\n    assert candidate(names = ['Sophie', 'Grayson', 'Hannah', 'Isaac', 'Layla'],heights = [170, 185, 165, 188, 172]) == ['Isaac', 'Grayson', 'Layla', 'Sophie', 'Hannah']\n    assert candidate(names = ['Evelyn', 'Sophie', 'Isabella', 'Mia', 'Emma'],heights = [168, 170, 166, 165, 172]) == ['Emma', 'Sophie', 'Evelyn', 'Isabella', 'Mia']\n    assert candidate(names = ['Zara', 'Xander', 'Yasmin', 'Will'],heights = [160, 175, 170, 165]) == ['Xander', 'Yasmin', 'Will', 'Zara']\n    assert candidate(names = ['Liam', 'Hannah', 'Sophie', 'Lucas'],heights = [195, 170, 180, 175]) == ['Liam', 'Sophie', 'Lucas', 'Hannah']\n    assert candidate(names = ['Liam', 'Olivia', 'Noah', 'Emma', 'Oliver', 'Ava', 'Sophia', 'Elijah', 'Amelia'],heights = [181, 168, 185, 171, 183, 167, 170, 182, 173]) == ['Noah', 'Oliver', 'Elijah', 'Liam', 'Amelia', 'Emma', 'Sophia', 'Olivia', 'Ava']\n    assert candidate(names = ['Sophia', 'Ava', 'Isabella', 'Mia'],heights = [160, 170, 175, 180]) == ['Mia', 'Isabella', 'Ava', 'Sophia']\n    assert candidate(names = ['Avery', 'Grayson', 'Evan', 'Nathan'],heights = [172, 182, 175, 180]) == ['Grayson', 'Nathan', 'Evan', 'Avery']\n    assert candidate(names = ['Willow', 'Tara', 'Xander', 'Alyson', 'Reese'],heights = [175, 160, 170, 165, 180]) == ['Reese', 'Willow', 'Xander', 'Alyson', 'Tara']\n    assert candidate(names = ['Eli', 'Ella', 'Ezra', 'Emilia', 'Evan'],heights = [170, 175, 160, 180, 165]) == ['Emilia', 'Ella', 'Eli', 'Evan', 'Ezra']\n    assert candidate(names = ['James', 'Benjamin', 'Mason', 'Noah', 'Lucas'],heights = [170, 175, 180, 185, 190]) == ['Lucas', 'Noah', 'Mason', 'Benjamin', 'James']\n    assert candidate(names = ['Jack', 'Rose', 'Cal', 'Fabian', 'Molly'],heights = [170, 175, 165, 180, 160]) == ['Fabian', 'Rose', 'Jack', 'Cal', 'Molly']\n", "comparison": "exact"}, "public_tests": ["[\"Mary\",\"John\",\"Emma\"]\n[180,165,170]", "[\"Alice\",\"Bob\",\"Bob\"]\n[155,185,150]"], "hints": ["Find the tallest person and swap with the first person, then find the second tallest person and swap with the second person, etc. Repeat until you fix all n people."], "metadata": {"canonical_parameter_names": ["names", "heights"], "leetcode_dataset_entry_point": "Solution().sortPeople", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:02+00:00", "tests_total": 120, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "string", "sorting"]}, "language": "python", "interface": {"raw_signature": "def sortPeople(self, names: list[str], heights: list[int]) -> list[str]:", "container": "Solution", "callable": "sortPeople", "parameters": [{"name": "names", "type": "list[str]"}, {"name": "heights", "type": "list[int]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2419, "task_id": "longest-subarray-with-maximum-bitwise-and", "difficulty": "Medium", "problem_description": "You are given an integer array nums of size n.\n\nConsider a non-empty subarray from nums that has the maximum possible bitwise AND.\n\n- In other words, let k be the maximum value of the bitwise AND of any subarray of nums. Then, only subarrays with a bitwise AND equal to k should be considered.\n\nReturn the length of the longest such subarray.\n\nThe bitwise AND of an array is the bitwise AND of all the numbers in it.\n\nA subarray is a contiguous sequence of elements within an array.\n\nExample 1:\n\nInput: nums = [1,2,3,3,2,2]\nOutput: 2\nExplanation:\nThe maximum possible bitwise AND of a subarray is 3.\nThe longest subarray with that value is [3,3], so we return 2.\n\nExample 2:\n\nInput: nums = [1,2,3,4]\nOutput: 1\nExplanation:\nThe maximum possible bitwise AND of a subarray is 4.\nThe longest subarray with that value is [4], so we return 1.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [8, 9, 10, 11, 12, 13, 14, 15, 16]) == 1\n    assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == 1\n    assert candidate(nums = [8, 9, 10, 10, 10, 8]) == 3\n    assert candidate(nums = [2, 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 1\n    assert candidate(nums = [8, 1, 2, 3, 7, 8, 8]) == 2\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 20\n    assert candidate(nums = [8, 9, 7, 6, 8, 9, 9, 8]) == 2\n    assert candidate(nums = [1]) == 1\n    assert candidate(nums = [1, 2, 3, 4]) == 1\n    assert candidate(nums = [5, 5, 5, 5, 5]) == 5\n    assert candidate(nums = [1000000, 1, 2, 3, 1000000, 1000000]) == 2\n    assert candidate(nums = [3, 1, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 10\n    assert candidate(nums = [1, 2, 3, 3, 2, 2]) == 2\n    assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995]) == 1\n    assert candidate(nums = [2, 2, 2, 3, 3, 3, 2, 2, 2, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2]) == 6\n    assert candidate(nums = [32, 32, 32, 32, 31, 30, 29, 28, 27, 26]) == 4\n    assert candidate(nums = [2, 3, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8]) == 1\n    assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 6\n    assert candidate(nums = [1, 10, 10, 2, 10, 10, 10, 5, 5, 5, 5, 10, 10, 10, 10, 1, 1, 1, 1]) == 4\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 30\n    assert candidate(nums = [17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 19, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]) == 10\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1\n    assert candidate(nums = [13, 13, 13, 14, 14, 14, 14, 13, 13, 14, 14, 14, 14, 14, 13, 13, 13, 14, 14, 14]) == 5\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 55\n    assert candidate(nums = [32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]) == 30\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 16\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 22\n    assert candidate(nums = [1000000, 1000000, 500000, 500000, 250000, 250000, 125000, 125000, 62500, 62500, 31250, 31250, 15625, 15625, 7812, 7812, 3906, 3906, 1953, 1953]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 10\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1000000, 1000000, 1000000, 1000000]) == 4\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 49\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 51\n    assert candidate(nums = [128, 255, 255, 128, 255, 255, 255, 128, 128, 255, 255, 255, 255, 255, 128]) == 5\n    assert candidate(nums = [5, 5, 6, 6, 6, 5, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 5, 5, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6]) == 8\n    assert candidate(nums = [999999, 999998, 999999, 999997, 999999, 999999, 999996, 999999, 999999, 999999]) == 3\n", "comparison": "exact"}, "public_tests": ["[1,2,3,3,2,2]", "[1,2,3,4]"], "hints": ["Notice that the bitwise AND of two different numbers will always be strictly less than the maximum of those two numbers.", "What does that tell us about the nature of the subarray that we should choose?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().longestSubarray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:04+00:00", "tests_total": 42, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "bit-manipulation", "brainteaser"]}, "language": "python", "interface": {"raw_signature": "def longestSubarray(self, nums: list[int]) -> int:", "container": "Solution", "callable": "longestSubarray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2420, "task_id": "find-all-good-indices", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums of size n and a positive integer k.\n\nWe call an index i in the range k <= i < n - k good if the following conditions are satisfied:\n\n- The k elements that are just before the index i are in non-increasing order.\n- The k elements that are just after the index i are in non-decreasing order.\n\nReturn an array of all good indices sorted in increasing order.\n\nExample 1:\n\nInput: nums = [2,1,1,1,3,4,1], k = 2\nOutput: [2,3]\nExplanation: There are two good indices in the array:\n- Index 2. The subarray [2,1] is in non-increasing order, and the subarray [1,3] is in non-decreasing order.\n- Index 3. The subarray [1,1] is in non-increasing order, and the subarray [3,4] is in non-decreasing order.\nNote that the index 4 is not good because [4,1] is not non-decreasing.\n\nExample 2:\n\nInput: nums = [2,1,1,2], k = 2\nOutput: []\nExplanation: There are no good indices in this array.\n\nConstraints:\n\n- n == nums.length\n- 3 <= n <= 10^5\n- 1 <= nums[i] <= 10^6\n- 1 <= k <= n / 2\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5],k = 3) == [7, 8, 9]\n    assert candidate(nums = [1, 2, 3, 4, 3, 2, 1],k = 2) == []\n    assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 4, 3, 2, 1],k = 3) == []\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == []\n    assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992],k = 3) == []\n    assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5],k = 2) == [3, 4, 5]\n    assert candidate(nums = [5, 4, 5, 3, 4, 5, 6, 7, 8],k = 2) == [2, 4]\n    assert candidate(nums = [2, 1, 1, 2],k = 2) == []\n    assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 3) == []\n    assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1],k = 2) == []\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 3) == [7, 8, 9]\n    assert candidate(nums = [5, 4, 3, 4, 5],k = 1) == [1, 2, 3]\n    assert candidate(nums = [2, 1, 1, 1, 3, 4, 1],k = 2) == [2, 3]\n    assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1],k = 3) == [4, 7, 15, 18]\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 3) == [3, 4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 4) == [7, 8, 9]\n    assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],k = 2) == []\n    assert candidate(nums = [100, 99, 98, 97, 96, 97, 98, 99, 100, 101, 102, 103, 104, 103, 102, 101, 100],k = 4) == [4, 5]\n    assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3],k = 2) == [6, 10, 14]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5],k = 5) == [5]\n    assert candidate(nums = [10, 20, 30, 20, 10, 20, 30, 20, 10, 20, 30, 20, 10, 20, 30, 20, 10, 20, 30],k = 4) == []\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == []\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 4) == [7, 8, 9, 10]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == [5, 6, 7]\n    assert candidate(nums = [1, 3, 2, 1, 2, 3, 2, 1, 2, 3],k = 2) == [3, 7]\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 1, 1, 20, 30, 40],k = 3) == [9, 10, 11, 12]\n    assert candidate(nums = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],k = 3) == [4, 5, 6]\n    assert candidate(nums = [10, 9, 8, 7, 7, 6, 5, 4, 4, 3, 2, 1],k = 3) == []\n    assert candidate(nums = [1, 3, 2, 3, 2, 3, 2, 3, 2, 1],k = 2) == [3, 5]\n    assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],k = 2) == [3, 4, 5, 6, 13, 14, 15, 16]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n    assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1],k = 2) == [5, 6, 10, 11, 15, 16]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]\n    assert candidate(nums = [10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11],k = 2) == [3, 5, 7, 9, 11, 13]\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == []\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2],k = 3) == []\n    assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999997, 999998, 999999, 1000000],k = 3) == [3, 4, 5]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3],k = 3) == [7, 8, 9, 10]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == [14]\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [8, 9, 10, 11]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == [3, 4, 5, 6]\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],k = 3) == []\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == []\n    assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1],k = 3) == [6]\n    assert candidate(nums = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == [5, 6]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == []\n    assert candidate(nums = [1, 3, 2, 3, 4, 5, 4, 3, 2, 1],k = 2) == [3]\n    assert candidate(nums = [8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 4) == []\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 3, 4, 5, 6],k = 3) == [8, 9, 10]\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 2) == [3, 5, 7, 9, 11]\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1],k = 4) == []\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1],k = 4) == [5, 6, 7, 11, 12, 13, 14]\n    assert candidate(nums = [5, 3, 2, 1, 1, 1, 2, 3, 4, 5],k = 2) == [2, 3, 4, 5, 6]\n    assert candidate(nums = [1, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2],k = 3) == []\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == [3, 4, 5, 6]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4],k = 3) == [3, 4, 5, 6, 9, 10, 11, 12, 15, 16, 17, 18]\n    assert candidate(nums = [5, 6, 7, 8, 9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 6, 7],k = 3) == [7, 8, 9, 15]\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10],k = 2) == [3, 5, 7, 9, 11, 13, 15]\n    assert candidate(nums = [1, 3, 2, 2, 2, 1, 3, 4, 3, 2, 1, 2, 3, 4, 5],k = 2) == [4, 5, 9, 10, 11]\n    assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 3, 3, 2, 2, 1, 1],k = 2) == [3, 4, 5, 10]\n    assert candidate(nums = [5, 4, 3, 2, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],k = 4) == [4, 5, 6, 7, 8, 9]\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 11, 12, 13, 14, 15],k = 5) == [8, 9]\n    assert candidate(nums = [9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == [3, 4, 5]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4],k = 3) == [15, 16]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == []\n    assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 4) == []\n    assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1],k = 3) == []\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == [4, 5, 6, 7]\n    assert candidate(nums = [5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5],k = 2) == [5, 6, 7]\n    assert candidate(nums = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == [9, 10, 11]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],k = 5) == [7, 8, 9]\n    assert candidate(nums = [5, 4, 4, 3, 2, 2, 3, 4, 5],k = 2) == [3, 4, 5, 6]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1],k = 3) == []\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == [7, 8, 9]\n    assert candidate(nums = [5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],k = 3) == [5, 6, 7]\n    assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],k = 3) == []\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],k = 3) == []\n    assert candidate(nums = [1, 3, 2, 4, 3, 2, 1, 3, 2, 4, 3, 2, 1, 3, 2, 4, 3, 2, 1],k = 2) == [5, 7, 11, 13]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 3) == [7, 8, 9, 10]\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],k = 5) == []\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],k = 5) == [10]\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3],k = 2) == [4, 8, 12]\n    assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2],k = 2) == [3, 4, 7, 8]\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [8, 9, 10]\n    assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5) == [6, 7, 8, 9, 10, 11, 12, 13, 14]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == []\n    assert candidate(nums = [3, 2, 1, 1, 1, 2, 3, 4, 5, 6],k = 2) == [2, 3, 4, 5]\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == []\n    assert candidate(nums = [1, 2, 3, 4, 3, 3, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1],k = 3) == [6, 7]\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],k = 2) == [4, 8, 12, 16]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == []\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 5, 6, 7, 8, 9],k = 3) == [4, 5, 6]\n    assert candidate(nums = [1, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5],k = 3) == [9, 10]\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == []\n    assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5],k = 2) == [2, 4, 6, 8, 10, 12, 14, 16]\n    assert candidate(nums = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],k = 5) == [5]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],k = 4) == [8, 9, 10]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 2) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n", "comparison": "exact"}, "public_tests": ["[2,1,1,1,3,4,1]\n2", "[2,1,1,2]\n2"], "hints": ["Iterate over all indices i. How do you quickly check the two conditions?", "Precompute for each index whether the conditions are satisfied on the left and the right of the index. You can do that with two iterations, from left to right and right to left."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().goodIndices", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:07+00:00", "tests_total": 101, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def goodIndices(self, nums: list[int], k: int) -> list[int]:", "container": "Solution", "callable": "goodIndices", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2421, "task_id": "number-of-good-paths", "difficulty": "Hard", "problem_description": "There is a tree (i.e. a connected, undirected graph with no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges.\n\nYou are given a 0-indexed integer array vals of length n where vals[i] denotes the value of the i^th node. You are also given a 2D integer array edges where edges[i] = [a_i, b_i] denotes that there exists an undirected edge connecting nodes a_i and b_i.\n\nA good path is a simple path that satisfies the following conditions:\n\n1. The starting node and the ending node have the same value.\n2. All nodes between the starting node and the ending node have values less than or equal to the starting node (i.e. the starting node's value should be the maximum value along the path).\n\nReturn the number of distinct good paths.\n\nNote that a path and its reverse are counted as the same path. For example, 0 -> 1 is considered to be the same as 1 -> 0. A single node is also considered as a valid path.\n\nExample 1:\n\nInput: vals = [1,3,2,1,3], edges = [[0,1],[0,2],[2,3],[2,4]]\nOutput: 6\nExplanation: There are 5 good paths consisting of a single node.\nThere is 1 additional good path: 1 -> 0 -> 2 -> 4.\n(The reverse path 4 -> 2 -> 0 -> 1 is treated as the same as 1 -> 0 -> 2 -> 4.)\nNote that 0 -> 2 -> 3 is not a good path because vals[2] > vals[0].\n\nExample 2:\n\nInput: vals = [1,1,2,2,3], edges = [[0,1],[1,2],[2,3],[2,4]]\nOutput: 7\nExplanation: There are 5 good paths consisting of a single node.\nThere are 2 additional good paths: 0 -> 1 and 2 -> 3.\n\nExample 3:\n\nInput: vals = [1], edges = []\nOutput: 1\nExplanation: The tree consists of only one node, so there is one good path.\n\nConstraints:\n\n- n == vals.length\n- 1 <= n <= 3 * 10^4\n- 0 <= vals[i] <= 10^5\n- edges.length == n - 1\n- edges[i].length == 2\n- 0 <= a_i, b_i < n\n- a_i != b_i\n- edges represents a valid tree.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(vals = [2, 2, 2, 2, 2],edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 15\n    assert candidate(vals = [1],edges = []) == 1\n    assert candidate(vals = [1, 2, 3, 4, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 5\n    assert candidate(vals = [1, 2, 2, 3, 3, 4, 4],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 10\n    assert candidate(vals = [2, 2, 2, 2],edges = [[0, 1], [1, 2], [2, 3]]) == 10\n    assert candidate(vals = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n    assert candidate(vals = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n    assert candidate(vals = [10, 10, 10, 10],edges = [[0, 1], [1, 2], [2, 3]]) == 10\n    assert candidate(vals = [1, 1, 2, 2, 3],edges = [[0, 1], [1, 2], [2, 3], [2, 4]]) == 7\n    assert candidate(vals = [5, 4, 3, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 5\n    assert candidate(vals = [1, 3, 2, 1, 3],edges = [[0, 1], [0, 2], [2, 3], [2, 4]]) == 6\n    assert candidate(vals = [1, 3, 3, 3, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 8\n    assert candidate(vals = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 12\n    assert candidate(vals = [3, 1, 4, 4, 3],edges = [[0, 1], [1, 2], [2, 3], [2, 4]]) == 6\n    assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 55\n    assert candidate(vals = [1, 2, 3, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [2, 4]]) == 5\n    assert candidate(vals = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 56\n    assert candidate(vals = [1, 3, 2, 3, 1, 4, 2, 3, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [4, 7], [6, 8]]) == 13\n    assert candidate(vals = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 24\n    assert candidate(vals = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == 20\n    assert candidate(vals = [1, 2, 2, 3, 3, 3, 4],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 11\n    assert candidate(vals = [2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10]]) == 28\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 15\n    assert candidate(vals = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 15\n    assert candidate(vals = [1, 3, 2, 3, 1, 3, 3, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7]]) == 14\n    assert candidate(vals = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 15\n    assert candidate(vals = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == 120\n    assert candidate(vals = [1, 2, 1, 2, 1, 2, 1, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 15\n    assert candidate(vals = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == 37\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n    assert candidate(vals = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 15\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 20\n    assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18]]) == 19\n    assert candidate(vals = [5, 4, 5, 3, 4, 5, 2, 1, 5, 5, 5],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == 26\n    assert candidate(vals = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == 91\n    assert candidate(vals = [10, 5, 10, 10, 3, 5, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [3, 5], [4, 6]]) == 13\n    assert candidate(vals = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == 66\n    assert candidate(vals = [7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 43\n    assert candidate(vals = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7], [6, 8], [6, 9]]) == 11\n    assert candidate(vals = [4, 2, 5, 3, 1, 6, 1, 2, 4, 5],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [0, 5], [5, 6], [5, 7], [7, 8], [7, 9]]) == 10\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15]]) == 16\n    assert candidate(vals = [1, 2, 3, 4, 5, 4, 3, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [3, 5], [5, 6], [6, 7], [7, 8]]) == 10\n    assert candidate(vals = [3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]]) == 45\n    assert candidate(vals = [1, 3, 2, 3, 1, 3, 1, 3, 1, 3],edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 23\n    assert candidate(vals = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 55\n    assert candidate(vals = [6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == 19\n    assert candidate(vals = [4, 2, 3, 4, 3, 4, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 10\n    assert candidate(vals = [4, 2, 3, 4, 4, 3, 2, 4],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]]) == 15\n    assert candidate(vals = [1, 3, 1, 2, 3, 1, 1, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7]]) == 12\n    assert candidate(vals = [3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 28\n    assert candidate(vals = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10]]) == 32\n    assert candidate(vals = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17]]) == 23\n    assert candidate(vals = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == 33\n    assert candidate(vals = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 16\n    assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 210\n    assert candidate(vals = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == 19\n    assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == 465\n    assert candidate(vals = [3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 36\n    assert candidate(vals = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19]]) == 210\n    assert candidate(vals = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9]]) == 55\n    assert candidate(vals = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 10\n    assert candidate(vals = [5, 3, 5, 3, 3, 5, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 13\n    assert candidate(vals = [1, 2, 2, 1, 3, 3, 1, 1, 2, 2],edges = [[0, 1], [0, 3], [1, 2], [3, 4], [3, 7], [4, 5], [5, 6], [7, 8], [8, 9]]) == 20\n    assert candidate(vals = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == 73\n    assert candidate(vals = [5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 36\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n    assert candidate(vals = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3],edges = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [3, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 31\n    assert candidate(vals = [5, 3, 5, 5, 2, 5, 5, 5, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8]]) == 30\n    assert candidate(vals = [3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8]]) == 45\n    assert candidate(vals = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 16\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 9\n    assert candidate(vals = [3, 1, 2, 3, 1, 3, 2, 1, 3, 2, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]]) == 19\n    assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == 210\n    assert candidate(vals = [2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == 49\n    assert candidate(vals = [3, 1, 2, 3, 3, 2, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 14\n    assert candidate(vals = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7], [7, 8], [7, 9], [9, 10], [9, 11], [11, 12], [11, 13], [13, 14], [13, 15], [15, 16], [15, 17], [17, 18], [17, 19], [19, 20]]) == 21\n    assert candidate(vals = [5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 45\n    assert candidate(vals = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 210\n    assert candidate(vals = [4, 3, 3, 4, 4, 4, 3, 4],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]]) == 19\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 10\n", "comparison": "exact"}, "public_tests": ["[1,3,2,1,3]\n[[0,1],[0,2],[2,3],[2,4]]", "[1,1,2,2,3]\n[[0,1],[1,2],[2,3],[2,4]]", "[1]\n[]"], "hints": ["Can you process nodes from smallest to largest value?", "Try to build the graph from nodes with the smallest value to the largest value.", "May union find help?"], "metadata": {"canonical_parameter_names": ["vals", "edges"], "leetcode_dataset_entry_point": "Solution().numberOfGoodPaths", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:10+00:00", "tests_total": 82, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "tree", "union-find", "graph", "sorting"]}, "language": "python", "interface": {"raw_signature": "def numberOfGoodPaths(self, vals: list[int], edges: list[list[int]]) -> int:", "container": "Solution", "callable": "numberOfGoodPaths", "parameters": [{"name": "vals", "type": "list[int]"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2423, "task_id": "remove-letter-to-equalize-frequency", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string word, consisting of lowercase English letters. You need to select one index and remove the letter at that index from word so that the frequency of every letter present in word is equal.\n\nReturn true if it is possible to remove one letter so that the frequency of all letters in word are equal, and false otherwise.\n\nNote:\n\n- The frequency of a letter x is the number of times it occurs in the string.\n- You must remove exactly one letter and cannot choose to do nothing.\n\nExample 1:\n\nInput: word = \"abcc\"\nOutput: true\nExplanation: Select index 3 and delete it: word becomes \"abc\" and each character has a frequency of 1.\n\nExample 2:\n\nInput: word = \"aazz\"\nOutput: false\nExplanation: We must delete a character, so either the frequency of \"a\" is 1 and the frequency of \"z\" is 2, or vice versa. It is impossible to make all present letters have equal frequency.\n\nConstraints:\n\n- 2 <= word.length <= 100\n- word consists of lowercase English letters only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(word = \"aabbccd\") == True\n    assert candidate(word = \"aaabbbccc\") == False\n    assert candidate(word = \"zazaza\") == False\n    assert candidate(word = \"aaaaabbbbbcccc\") == False\n    assert candidate(word = \"zzzzzzzz\") == True\n    assert candidate(word = \"aabbccddeff\") == True\n    assert candidate(word = \"aabbbbcccc\") == False\n    assert candidate(word = \"aazz\") == False\n    assert candidate(word = \"aabbbccccc\") == False\n    assert candidate(word = \"aaa\") == True\n    assert candidate(word = \"aabbbccddd\") == False\n    assert candidate(word = \"abcdef\") == True\n    assert candidate(word = \"aabbcccddd\") == False\n    assert candidate(word = \"aabbc\") == True\n    assert candidate(word = \"aabbccddeee\") == True\n    assert candidate(word = \"abacabad\") == False\n    assert candidate(word = \"abcdabcd\") == False\n    assert candidate(word = \"aabbbccc\") == False\n    assert candidate(word = \"aabbccdde\") == True\n    assert candidate(word = \"aabbbcccc\") == False\n    assert candidate(word = \"aabbbcccccc\") == False\n    assert candidate(word = \"zzzz\") == True\n    assert candidate(word = \"abcc\") == True\n    assert candidate(word = \"xyyz\") == True\n    assert candidate(word = \"aab\") == True\n    assert candidate(word = \"aabbcc\") == False\n    assert candidate(word = \"abcde\") == True\n    assert candidate(word = \"aaabbbb\") == True\n    assert candidate(word = \"aabbbb\") == False\n    assert candidate(word = \"abcd\") == True\n    assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == False\n    assert candidate(word = \"abbbccddde\") == False\n    assert candidate(word = \"abcabcabc\") == False\n    assert candidate(word = \"qwerty\") == True\n    assert candidate(word = \"aabbbcccd\") == False\n    assert candidate(word = \"aabbccddd\") == True\n    assert candidate(word = \"abc\") == True\n    assert candidate(word = \"abcddd\") == False\n    assert candidate(word = \"abcdefghijklmnopqrstuvwxzy\") == True\n    assert candidate(word = \"aaaabbbb\") == False\n    assert candidate(word = \"aabbccc\") == True\n    assert candidate(word = \"abcdabcdabcd\") == False\n    assert candidate(word = \"abcdefghi\") == True\n    assert candidate(word = \"aabbcccd\") == False\n    assert candidate(word = \"abcdefghijj\") == True\n    assert candidate(word = \"aabbbcccdddde\") == False\n    assert candidate(word = \"aabbcccc\") == False\n    assert candidate(word = \"aabbccddeeefffg\") == False\n    assert candidate(word = \"aabbccddeeeffffgggg\") == False\n    assert candidate(word = \"aabbbccccddddeeeeeffffffggggg\") == False\n    assert candidate(word = \"aabbccddeeffg\") == True\n    assert candidate(word = \"zzzzzzzzzz\") == True\n    assert candidate(word = \"aabbbccccdddde\") == False\n    assert candidate(word = \"aabbccddeeffgg\") == False\n    assert candidate(word = \"abcdefghij\") == True\n    assert candidate(word = \"aabbccddeeffgggh\") == False\n    assert candidate(word = \"aabbccddeeff\") == False\n    assert candidate(word = \"abcabcabcabcabcabcabcabc\") == False\n    assert candidate(word = \"zzzzzyyyyy\") == False\n    assert candidate(word = \"aaaabbbbccccdddd\") == False\n    assert candidate(word = \"aabbbccccdddd\") == False\n    assert candidate(word = \"aabbbcccddd\") == False\n    assert candidate(word = \"abcdefg\") == True\n    assert candidate(word = \"aabbbccccddddeeeeeffffff\") == False\n    assert candidate(word = \"abcdefghijjk\") == True\n    assert candidate(word = \"aabbbcccde\") == False\n    assert candidate(word = \"abbbbcccccdddddeeeeee\") == False\n    assert candidate(word = \"aabbccddeeeffff\") == False\n    assert candidate(word = \"aabbbccccddddeeeee\") == False\n    assert candidate(word = \"aabbccddeeffggghhhh\") == False\n    assert candidate(word = \"abcabcabcabc\") == False\n    assert candidate(word = \"aabbbcccdddd\") == False\n    assert candidate(word = \"aabbcddd\") == False\n", "comparison": "exact"}, "public_tests": ["\"abcc\"", "\"aazz\""], "hints": ["Brute force all letters that could be removed.", "Use a frequency array of size 26."], "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().equalFrequency", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:14+00:00", "tests_total": 74, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def equalFrequency(self, word: str) -> bool:", "container": "Solution", "callable": "equalFrequency", "parameters": [{"name": "word", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2425, "task_id": "bitwise-xor-of-all-pairings", "difficulty": "Medium", "problem_description": "You are given two 0-indexed arrays, nums1 and nums2, consisting of non-negative integers. Let there be another array, nums3, which contains the bitwise XOR of all pairings of integers between nums1 and nums2 (every integer in nums1 is paired with every integer in nums2 exactly once).\n\nReturn the bitwise XOR of all integers in nums3.\n\nExample 1:\n\nInput: nums1 = [2,1,3], nums2 = [10,2,5,0]\nOutput: 13\nExplanation:\nA possible nums3 array is [8,0,7,2,11,3,4,1,9,1,6,3].\nThe bitwise XOR of all these numbers is 13, so we return 13.\n\nExample 2:\n\nInput: nums1 = [1,2], nums2 = [3,4]\nOutput: 0\nExplanation:\nAll possible pairs of bitwise XORs are nums1[0] ^ nums2[0], nums1[0] ^ nums2[1], nums1[1] ^ nums2[0],\nand nums1[1] ^ nums2[1].\nThus, one possible nums3 array is [2,5,1,6].\n2 ^ 5 ^ 1 ^ 6 = 0, so we return 0.\n\nConstraints:\n\n- 1 <= nums1.length, nums2.length <= 10^5\n- 0 <= nums1[i], nums2[j] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums1 = [8, 16, 24, 32],nums2 = [4, 8, 12, 16, 20]) == 32\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1]) == 11\n    assert candidate(nums1 = [2, 1, 3],nums2 = [10, 2, 5, 0]) == 13\n    assert candidate(nums1 = [7, 8, 9],nums2 = [10, 11, 12, 13]) == 0\n    assert candidate(nums1 = [14, 15, 16],nums2 = [17, 18]) == 3\n    assert candidate(nums1 = [5],nums2 = [5]) == 0\n    assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == 0\n    assert candidate(nums1 = [1, 1, 1],nums2 = [1, 1, 1]) == 0\n    assert candidate(nums1 = [1, 3, 5, 7],nums2 = [2, 4, 6, 8]) == 0\n    assert candidate(nums1 = [1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 0\n    assert candidate(nums1 = [1000000000],nums2 = [1000000000]) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1]) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5]) == 0\n    assert candidate(nums1 = [9, 8, 7, 6],nums2 = [5, 4, 3, 2, 1]) == 0\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n    assert candidate(nums1 = [9, 8, 7],nums2 = [6, 5, 4, 3, 2, 1]) == 7\n    assert candidate(nums1 = [1, 2],nums2 = [3, 4]) == 0\n    assert candidate(nums1 = [1],nums2 = [1, 2, 3, 4, 5]) == 0\n    assert candidate(nums1 = [1, 2, 3],nums2 = [6, 5, 4, 3, 2, 1]) == 7\n    assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0]) == 0\n    assert candidate(nums1 = [5],nums2 = [5, 5, 5, 5, 5]) == 0\n    assert candidate(nums1 = [7, 14, 21],nums2 = [3, 6, 9, 12]) == 0\n    assert candidate(nums1 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],nums2 = [20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 0\n    assert candidate(nums1 = [13, 29, 37, 41, 53],nums2 = [67, 71, 73, 79, 83, 89, 97, 101]) == 12\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums1 = [7, 11, 13, 14],nums2 = [18, 19, 20, 21, 22]) == 15\n    assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5]) == 0\n    assert candidate(nums1 = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],nums2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 682\n    assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == 0\n    assert candidate(nums1 = [15, 30, 45, 60, 75],nums2 = [1, 3, 5, 7, 9, 11, 13]) == 68\n    assert candidate(nums1 = [255, 127, 63, 31],nums2 = [1, 2, 4, 8, 16, 32]) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums1 = [7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15]) == 12\n    assert candidate(nums1 = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195],nums2 = [199, 299, 399, 499, 599, 699]) == 380\n    assert candidate(nums1 = [1000000000],nums2 = [1000000000, 1000000000, 1000000000, 1000000000]) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 31\n    assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],nums2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n    assert candidate(nums1 = [7, 8, 9, 10],nums2 = [3, 1, 4, 1, 5, 9]) == 0\n    assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [1, 3, 5, 7, 9]) == 1\n    assert candidate(nums1 = [100, 200, 300],nums2 = [101, 202, 303, 404]) == 20\n    assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5]) == 1\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [2, 4, 6, 8, 10, 12, 14, 16]) == 0\n    assert candidate(nums1 = [1000000000],nums2 = [500000000, 600000000, 700000000, 800000000, 900000000]) == 908472064\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n    assert candidate(nums1 = [100, 200, 300],nums2 = [101, 202, 303, 404, 505]) == 109\n    assert candidate(nums1 = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90],nums2 = [96, 102, 108, 114, 120, 126]) == 30\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 0\n    assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],nums2 = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n    assert candidate(nums1 = [255, 254, 253, 252, 251],nums2 = [127, 63, 31, 15, 7]) == 172\n    assert candidate(nums1 = [0, 255, 511, 1023, 2047],nums2 = [1, 128, 256, 512, 1024]) == 641\n    assert candidate(nums1 = [1, 1000000000],nums2 = [1, 1000000000, 1000000000, 1000000000, 1000000000]) == 1000000001\n    assert candidate(nums1 = [7, 15, 21],nums2 = [9, 3, 12, 8]) == 14\n    assert candidate(nums1 = [255, 128, 64, 32, 16],nums2 = [1, 2, 4, 8, 16, 32]) == 63\n    assert candidate(nums1 = [999999999, 888888888, 777777777],nums2 = [666666666, 555555555, 444444444, 333333333, 222222222]) == 587645496\n    assert candidate(nums1 = [123456789, 987654321, 456789123],nums2 = [321654987, 789123456, 654987321, 123456789]) == 477404263\n    assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1]) == 0\n    assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],nums2 = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2046\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13],nums2 = [2, 4, 6, 8, 10, 12, 14, 16]) == 16\n    assert candidate(nums1 = [13, 17, 19, 23, 29, 31],nums2 = [37, 41, 43, 47, 53, 59, 61, 67, 71]) == 26\n    assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 0\n    assert candidate(nums1 = [1000000000],nums2 = [1000000000, 1000000000]) == 0\n    assert candidate(nums1 = [13, 29, 31, 47, 53, 59, 61, 67, 71, 73],nums2 = [79, 83, 89, 97, 101, 103, 107, 109, 113, 127]) == 0\n    assert candidate(nums1 = [255, 128, 64, 32, 16, 8, 4, 2, 1],nums2 = [1, 3, 7, 15, 31, 63, 127, 255]) == 170\n    assert candidate(nums1 = [255, 511, 765, 1023, 1279],nums2 = [15, 31, 47, 63, 79]) == 1202\n    assert candidate(nums1 = [255, 128, 64, 32, 16, 8, 4, 2, 1],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == 17\n    assert candidate(nums1 = [7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6]) == 0\n    assert candidate(nums1 = [999999999, 888888888, 777777777, 666666666],nums2 = [555555555, 444444444, 333333333, 222222222]) == 0\n    assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 11\n    assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums1 = [666],nums2 = [666, 666, 666, 666, 666, 666]) == 0\n    assert candidate(nums1 = [1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100]) == 0\n    assert candidate(nums1 = [1024, 2048, 4096, 8192, 16384],nums2 = [1, 2, 4, 8, 16]) == 31775\n    assert candidate(nums1 = [7, 11, 13, 17, 19],nums2 = [3, 6, 9, 12, 15]) == 12\n    assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],nums2 = [1024, 2048, 4096, 8192, 16384]) == 1023\n    assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],nums2 = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == 0\n    assert candidate(nums1 = [100, 200, 300, 400],nums2 = [50, 60, 70]) == 16\n    assert candidate(nums1 = [255, 128, 64, 32],nums2 = [16, 8, 4, 2, 1]) == 31\n    assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0]) == 0\n    assert candidate(nums1 = [111, 222, 333, 444, 555, 666, 777, 888, 999],nums2 = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 707\n    assert candidate(nums1 = [123456789, 987654321, 111111111, 222222222],nums2 = [333333333, 444444444, 555555555]) == 908335597\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6],nums2 = [7, 8, 9, 10, 11, 12, 13]) == 1\n    assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2]) == 3\n    assert candidate(nums1 = [1000000, 2000000, 3000000, 4000000],nums2 = [500000, 600000, 700000]) == 67840\n    assert candidate(nums1 = [100, 200, 300],nums2 = [50, 150, 250, 350, 450]) == 322\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [2, 4, 6, 8, 10]) == 2\n    assert candidate(nums1 = [13, 23, 33, 43, 53, 63, 73, 83, 93, 103, 113],nums2 = [11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111]) == 42\n    assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 1, 1, 1, 1]) == 0\n    assert candidate(nums1 = [13, 14, 15, 16, 17, 18, 19, 20],nums2 = [21, 22, 23, 24, 25, 26, 27, 28]) == 0\n    assert candidate(nums1 = [15, 23, 42, 8, 16],nums2 = [32, 19, 10, 7, 11]) == 31\n    assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10, 12, 14]) == 9\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n    assert candidate(nums1 = [1024, 512, 256, 128],nums2 = [64, 32, 16, 8, 4, 2, 1]) == 1920\n", "comparison": "exact"}, "public_tests": ["[2,1,3]\n[10,2,5,0]", "[1,2]\n[3,4]"], "hints": ["Think how the count of each individual integer affects the final answer.", "If the length of nums1 is m and the length of nums2 is n, then each number in nums1 is repeated n times and each number in nums2 is repeated m times."], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().xorAllNums", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:17+00:00", "tests_total": 102, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "bit-manipulation", "brainteaser"]}, "language": "python", "interface": {"raw_signature": "def xorAllNums(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "xorAllNums", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2426, "task_id": "number-of-pairs-satisfying-inequality", "difficulty": "Hard", "problem_description": "You are given two 0-indexed integer arrays nums1 and nums2, each of size n, and an integer diff. Find the number of pairs (i, j) such that:\n\n- 0 <= i < j <= n - 1 and\n- nums1[i] - nums1[j] <= nums2[i] - nums2[j] + diff.\n\nReturn the number of pairs that satisfy the conditions.\n\nExample 1:\n\nInput: nums1 = [3,2,5], nums2 = [2,2,1], diff = 1\nOutput: 3\nExplanation:\nThere are 3 pairs that satisfy the conditions:\n1. i = 0, j = 1: 3 - 2 <= 2 - 2 + 1. Since i < j and 1 <= 1, this pair satisfies the conditions.\n2. i = 0, j = 2: 3 - 5 <= 2 - 1 + 1. Since i < j and -2 <= 2, this pair satisfies the conditions.\n3. i = 1, j = 2: 2 - 5 <= 2 - 1 + 1. Since i < j and -3 <= 2, this pair satisfies the conditions.\nTherefore, we return 3.\n\nExample 2:\n\nInput: nums1 = [3,-1], nums2 = [-2,2], diff = -1\nOutput: 0\nExplanation:\nSince there does not exist any pair that satisfies the conditions, we return 0.\n\nConstraints:\n\n- n == nums1.length == nums2.length\n- 2 <= n <= 10^5\n- -10^4 <= nums1[i], nums2[i] <= 10^4\n- -10^4 <= diff <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums1 = [3, -1],nums2 = [-2, 2],diff = -1) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],diff = 0) == 10\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5],diff = 50) == 10\n    assert candidate(nums1 = [-10, -20, -30, -40, -50],nums2 = [-1, -2, -3, -4, -5],diff = -10) == 0\n    assert candidate(nums1 = [-10, -20, -30],nums2 = [-1, -2, -3],diff = -5) == 0\n    assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0],diff = 10) == 6\n    assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [-5, -4, -3, -2, -1],diff = -10) == 0\n    assert candidate(nums1 = [9, 7, 5, 3, 1],nums2 = [10, 8, 6, 4, 2],diff = -1) == 0\n    assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],diff = 1) == 10\n    assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5],diff = 10) == 10\n    assert candidate(nums1 = [10, 20, 30],nums2 = [1, 2, 3],diff = 5) == 3\n    assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0],diff = 0) == 10\n    assert candidate(nums1 = [3, 2, 5],nums2 = [2, 2, 1],diff = 1) == 3\n    assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0],diff = 10000) == 6\n    assert candidate(nums1 = [10000, -10000, 5000, -5000, 0],nums2 = [-10000, 10000, -5000, 5000, 0],diff = 0) == 4\n    assert candidate(nums1 = [10000, -5000, 3000, -1000, 2000],nums2 = [5000, -2500, 1500, -500, 1000],diff = 2000) == 6\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],diff = -1) == 45\n    assert candidate(nums1 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],diff = 5) == 45\n    assert candidate(nums1 = [10000, 10000, 10000, 10000, 10000],nums2 = [1, 2, 3, 4, 5],diff = 10000) == 10\n    assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],diff = 0) == 10\n    assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],diff = -100) == 45\n    assert candidate(nums1 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = -1) == 0\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [50, 150, 250, 350, 450],diff = 0) == 10\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],diff = 1) == 45\n    assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [0, 0, 0, 0, 0],diff = 0) == 10\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],diff = 10000) == 45\n    assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],diff = 500) == 45\n    assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],diff = 1) == 55\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],nums2 = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],diff = 10) == 190\n    assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = 1000) == 45\n    assert candidate(nums1 = [-500, -1000, -1500, -2000, -2500, -3000],nums2 = [500, 1000, 1500, 2000, 2500, 3000],diff = -1000) == 0\n    assert candidate(nums1 = [-9999, -8888, -7777, -6666, -5555],nums2 = [-10000, -8889, -7778, -6667, -5556],diff = 1) == 10\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],diff = 0) == 45\n    assert candidate(nums1 = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],diff = 10) == 45\n    assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],diff = 100) == 45\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],diff = 20) == 17\n    assert candidate(nums1 = [-1000, -2000, -3000, -4000, -5000, -6000, -7000, -8000, -9000, -10000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = -1000) == 0\n    assert candidate(nums1 = [5000, 5000, 5000, 5000, 5000],nums2 = [-5000, -5000, -5000, -5000, -5000],diff = 10000) == 10\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],diff = 1) == 190\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],diff = -2) == 0\n    assert candidate(nums1 = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],diff = 0) == 20\n    assert candidate(nums1 = [500, 400, 300, 200, 100, 0, -100, -200, -300, -400],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],diff = 500) == 45\n    assert candidate(nums1 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = 0) == 45\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],diff = 0) == 45\n    assert candidate(nums1 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = 100) == 0\n    assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],diff = 500) == 45\n    assert candidate(nums1 = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50],nums2 = [-50, -45, -40, -35, -30, -25, -20, -15, -10, -5],diff = -15) == 0\n    assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = 100) == 45\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],diff = 10) == 45\n    assert candidate(nums1 = [5, 15, 25, 35, 45, 55],nums2 = [0, 10, 20, 30, 40, 50],diff = 5) == 15\n    assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],diff = 100) == 45\n    assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],diff = 0) == 0\n    assert candidate(nums1 = [0, -10, -20, -30, -40],nums2 = [0, 10, 20, 30, 40],diff = 10) == 0\n    assert candidate(nums1 = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],nums2 = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],diff = -1000) == 0\n    assert candidate(nums1 = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],diff = 1) == 30\n    assert candidate(nums1 = [100, -50, 25, -25, 75, -100],nums2 = [0, 10, 20, -10, 30, -20],diff = 50) == 7\n    assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],diff = 0) == 45\n    assert candidate(nums1 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],diff = 1) == 45\n    assert candidate(nums1 = [-5, -10, -15, -20, -25],nums2 = [5, 10, 15, 20, 25],diff = 0) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],diff = 5) == 45\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = 0) == 45\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [10, 20, 30, 40, 50],diff = 50) == 10\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],diff = -4) == 45\n    assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [1, -1, 2, -2, 3],diff = 3) == 8\n    assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],diff = 25) == 45\n    assert candidate(nums1 = [10000, -10000, 10000, -10000, 10000],nums2 = [0, 0, 0, 0, 0],diff = 0) == 7\n    assert candidate(nums1 = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],diff = 0) == 20\n    assert candidate(nums1 = [5000, -5000, 3000, -3000, 1000],nums2 = [1, -1, 2, -2, 3],diff = 10000) == 10\n    assert candidate(nums1 = [-5000, 5000, -2500, 2500, 0],nums2 = [5000, -5000, 2500, -2500, 0],diff = 0) == 6\n    assert candidate(nums1 = [10000, -10000, 10000, -10000, 10000],nums2 = [-10000, 10000, -10000, 10000, -10000],diff = 0) == 7\n    assert candidate(nums1 = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],nums2 = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],diff = -50) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = -2) == 0\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [0, 2, 4, 6, 8, 10, 12, 14],diff = 0) == 28\n    assert candidate(nums1 = [1, -1, 2, -2, 3, -3, 4, -4],nums2 = [0, 0, 0, 0, 0, 0, 0, 0],diff = 0) == 12\n    assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = 999) == 45\n    assert candidate(nums1 = [5000, 4000, 3000, 2000, 1000, 0, -1000, -2000, -3000, -4000, -5000],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],diff = 2000) == 19\n    assert candidate(nums1 = [1, -1, 1, -1, 1],nums2 = [-1, 1, -1, 1, -1],diff = 2) == 7\n    assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 1, 1, 1, 1],diff = 99) == 10\n    assert candidate(nums1 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],diff = 10) == 35\n    assert candidate(nums1 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],nums2 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],diff = 0) == 35\n    assert candidate(nums1 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],diff = 0) == 190\n    assert candidate(nums1 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],nums2 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],diff = -1) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],diff = 1) == 45\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],diff = 0) == 45\n    assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],diff = 1) == 45\n    assert candidate(nums1 = [-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000],nums2 = [10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000],diff = 0) == 35\n    assert candidate(nums1 = [5, 3, 8, 6, 2],nums2 = [1, 4, 3, 2, 5],diff = 1) == 5\n    assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],diff = -5) == 0\n    assert candidate(nums1 = [-10000, -9999, -9998, -9997, -9996, -9995, -9994, -9993, -9992, -9991],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],diff = -10) == 0\n    assert candidate(nums1 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],diff = -5) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],diff = 10) == 105\n", "comparison": "exact"}, "public_tests": ["[3,2,5]\n[2,2,1]\n1", "[3,-1]\n[-2,2]\n-1"], "hints": ["Try rearranging the equation.", "Once the equation is rearranged properly, think how a segment tree or a Fenwick tree can be used to solve the rearranged equation.", "Iterate through the array backwards."], "metadata": {"canonical_parameter_names": ["nums1", "nums2", "diff"], "leetcode_dataset_entry_point": "Solution().numberOfPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:20+00:00", "tests_total": 99, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "binary-search", "divide-and-conquer", "binary-indexed-tree", "segment-tree", "merge-sort", "ordered-set"]}, "language": "python", "interface": {"raw_signature": "def numberOfPairs(self, nums1: list[int], nums2: list[int], diff: int) -> int:", "container": "Solution", "callable": "numberOfPairs", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}, {"name": "diff", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2427, "task_id": "number-of-common-factors", "difficulty": "Easy", "problem_description": "Given two positive integers a and b, return the number of common factors of a and b.\n\nAn integer x is a common factor of a and b if x divides both a and b.\n\nExample 1:\n\nInput: a = 12, b = 6\nOutput: 4\nExplanation: The common factors of 12 and 6 are 1, 2, 3, 6.\n\nExample 2:\n\nInput: a = 25, b = 30\nOutput: 2\nExplanation: The common factors of 25 and 30 are 1, 5.\n\nConstraints:\n\n- 1 <= a, b <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(a = 7,b = 13) == 1\n    assert candidate(a = 500,b = 500) == 12\n    assert candidate(a = 42,b = 56) == 4\n    assert candidate(a = 999,b = 1000) == 1\n    assert candidate(a = 77,b = 14) == 2\n    assert candidate(a = 98,b = 42) == 4\n    assert candidate(a = 77,b = 143) == 2\n    assert candidate(a = 12,b = 6) == 4\n    assert candidate(a = 500,b = 250) == 8\n    assert candidate(a = 25,b = 30) == 2\n    assert candidate(a = 500,b = 200) == 9\n    assert candidate(a = 100,b = 10) == 4\n    assert candidate(a = 1,b = 1) == 1\n    assert candidate(a = 60,b = 120) == 12\n    assert candidate(a = 7,b = 14) == 2\n    assert candidate(a = 49,b = 7) == 2\n    assert candidate(a = 1000,b = 1000) == 16\n    assert candidate(a = 81,b = 27) == 4\n    assert candidate(a = 999,b = 333) == 6\n    assert candidate(a = 2,b = 3) == 1\n    assert candidate(a = 987,b = 651) == 4\n    assert candidate(a = 315,b = 105) == 8\n    assert candidate(a = 600,b = 400) == 12\n    assert candidate(a = 675,b = 900) == 9\n    assert candidate(a = 675,b = 375) == 6\n    assert candidate(a = 777,b = 111) == 4\n    assert candidate(a = 789,b = 321) == 2\n    assert candidate(a = 456,b = 123) == 2\n    assert candidate(a = 360,b = 180) == 18\n    assert candidate(a = 221,b = 143) == 2\n    assert candidate(a = 840,b = 420) == 24\n    assert candidate(a = 495,b = 135) == 6\n    assert candidate(a = 999,b = 111) == 4\n    assert candidate(a = 999,b = 891) == 4\n    assert candidate(a = 543,b = 234) == 2\n    assert candidate(a = 960,b = 720) == 20\n    assert candidate(a = 777,b = 222) == 4\n    assert candidate(a = 500,b = 1000) == 12\n    assert candidate(a = 987,b = 654) == 2\n    assert candidate(a = 450,b = 150) == 12\n    assert candidate(a = 560,b = 315) == 4\n    assert candidate(a = 420,b = 560) == 12\n    assert candidate(a = 432,b = 504) == 12\n    assert candidate(a = 100,b = 150) == 6\n    assert candidate(a = 420,b = 168) == 12\n    assert candidate(a = 729,b = 243) == 6\n    assert candidate(a = 400,b = 500) == 9\n    assert candidate(a = 504,b = 252) == 18\n    assert candidate(a = 500,b = 100) == 9\n    assert candidate(a = 495,b = 363) == 4\n    assert candidate(a = 84,b = 105) == 4\n    assert candidate(a = 315,b = 135) == 6\n    assert candidate(a = 48,b = 180) == 6\n    assert candidate(a = 333,b = 111) == 4\n    assert candidate(a = 121,b = 220) == 2\n    assert candidate(a = 560,b = 240) == 10\n    assert candidate(a = 143,b = 169) == 2\n    assert candidate(a = 440,b = 88) == 8\n    assert candidate(a = 441,b = 147) == 6\n    assert candidate(a = 675,b = 225) == 9\n    assert candidate(a = 560,b = 840) == 16\n    assert candidate(a = 729,b = 81) == 5\n    assert candidate(a = 500,b = 400) == 9\n    assert candidate(a = 210,b = 140) == 8\n    assert candidate(a = 576,b = 288) == 18\n    assert candidate(a = 777,b = 555) == 4\n    assert candidate(a = 220,b = 88) == 6\n    assert candidate(a = 720,b = 540) == 18\n    assert candidate(a = 882,b = 147) == 6\n    assert candidate(a = 210,b = 420) == 16\n    assert candidate(a = 987,b = 329) == 4\n    assert candidate(a = 882,b = 630) == 12\n    assert candidate(a = 890,b = 345) == 2\n    assert candidate(a = 462,b = 231) == 8\n    assert candidate(a = 84,b = 28) == 6\n    assert candidate(a = 450,b = 180) == 12\n    assert candidate(a = 504,b = 168) == 16\n    assert candidate(a = 100,b = 200) == 9\n    assert candidate(a = 400,b = 160) == 10\n    assert candidate(a = 1000,b = 750) == 8\n    assert candidate(a = 840,b = 700) == 12\n    assert candidate(a = 456,b = 342) == 8\n    assert candidate(a = 650,b = 260) == 8\n    assert candidate(a = 101,b = 103) == 1\n    assert candidate(a = 128,b = 256) == 8\n    assert candidate(a = 987,b = 323) == 1\n    assert candidate(a = 729,b = 486) == 6\n    assert candidate(a = 987,b = 567) == 4\n    assert candidate(a = 600,b = 750) == 12\n    assert candidate(a = 987,b = 399) == 4\n    assert candidate(a = 360,b = 720) == 24\n    assert candidate(a = 882,b = 98) == 6\n    assert candidate(a = 612,b = 468) == 9\n    assert candidate(a = 360,b = 240) == 16\n    assert candidate(a = 900,b = 450) == 18\n    assert candidate(a = 960,b = 480) == 24\n    assert candidate(a = 504,b = 756) == 18\n    assert candidate(a = 1000,b = 900) == 9\n    assert candidate(a = 678,b = 456) == 4\n", "comparison": "exact"}, "public_tests": ["12\n6", "25\n30"], "hints": ["For each integer in range [1,1000], check if it’s divisible by both A and B."], "metadata": {"canonical_parameter_names": ["a", "b"], "leetcode_dataset_entry_point": "Solution().commonFactors", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:22+00:00", "tests_total": 107, "tests_dropped": 8, "flags": [], "topic_tags": ["math", "enumeration", "number-theory", "euclidean-algorithm", "greatest-common-divisor"]}, "language": "python", "interface": {"raw_signature": "def commonFactors(self, a: int, b: int) -> int:", "container": "Solution", "callable": "commonFactors", "parameters": [{"name": "a", "type": "int"}, {"name": "b", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2428, "task_id": "maximum-sum-of-an-hourglass", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix grid.\n\nWe define an hourglass as a part of the matrix with the following form:\n\nReturn the maximum sum of the elements of an hourglass.\n\nNote that an hourglass cannot be rotated and must be entirely contained within the matrix.\n\nExample 1:\n\nInput: grid = [[6,2,1,3],[4,2,1,5],[9,2,8,7],[4,1,2,9]]\nOutput: 30\nExplanation: The cells shown above represent the hourglass with the maximum sum: 6 + 2 + 1 + 2 + 9 + 2 + 8 = 30.\n\nExample 2:\n\nInput: grid = [[1,2,3],[4,5,6],[7,8,9]]\nOutput: 35\nExplanation: There is only one hourglass in the matrix, with the sum: 1 + 2 + 3 + 5 + 7 + 8 + 9 = 35.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 3 <= m, n <= 150\n- 0 <= grid[i][j] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 133\n    assert candidate(grid = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 1\n    assert candidate(grid = [[1000000, 1000000, 1000000], [1000000, 1000000, 1000000], [1000000, 1000000, 1000000]]) == 7000000\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 7\n    assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 7\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 35\n    assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n    assert candidate(grid = [[6, 2, 1, 3], [4, 2, 1, 5], [9, 2, 8, 7], [4, 1, 2, 9]]) == 30\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1]]) == 3\n    assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 5\n    assert candidate(grid = [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200], [1300, 1400, 1500]]) == 7700\n    assert candidate(grid = [[9, 8, 7, 6, 5, 4], [3, 2, 1, 0, 1, 2], [4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7]]) == 47\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 3, 4, 3, 1], [1, 2, 3, 3, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]) == 20\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]]) == 203\n    assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5]]) == 35\n    assert candidate(grid = [[1000000, 0, 1000000, 0, 1000000], [0, 0, 0, 0, 0], [1000000, 0, 1000000, 0, 1000000], [0, 0, 0, 0, 0], [1000000, 0, 1000000, 0, 1000000]]) == 4000000\n    assert candidate(grid = [[1000000, 999999, 999998, 999997, 999996], [999995, 999994, 999993, 999992, 999991], [999990, 999989, 999988, 999987, 999986], [999985, 999984, 999983, 999982, 999981], [999980, 999979, 999978, 999977, 999976]]) == 6999958\n    assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5]]) == 35\n    assert candidate(grid = [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]]) == 63\n    assert candidate(grid = [[999999, 999998, 999997], [999996, 999995, 999994], [999993, 999992, 999991], [999990, 999989, 999988], [999987, 999986, 999985], [999984, 999983, 999982]]) == 6999965\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 8, 6, 4, 2], [1, 5, 9, 13, 17, 13, 9, 5, 1], [2, 6, 10, 14, 18, 14, 10, 6, 2]]) == 89\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]]) == 203\n    assert candidate(grid = [[9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9]]) == 63\n    assert candidate(grid = [[9, 8, 7, 6], [6, 5, 4, 3], [3, 2, 1, 0], [0, 1, 2, 3]]) == 35\n    assert candidate(grid = [[1, 0, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34], [35, 36, 37, 38, 39, 40, 41], [42, 43, 44, 45, 46, 47, 48]]) == 280\n    assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 5\n    assert candidate(grid = [[0, 1, 0, 2, 0, 3, 0, 4, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 2, 0, 3, 0, 4, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 2, 0, 3, 0, 4, 0]]) == 15\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6]]) == 35\n    assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30]]) == 168\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]]) == 119\n    assert candidate(grid = [[1, 5, 1, 3, 7], [4, 3, 2, 6, 8], [9, 5, 6, 1, 2], [7, 8, 9, 4, 5], [3, 4, 2, 7, 1]]) == 38\n    assert candidate(grid = [[1, 3, 1, 1, 1, 3, 1], [1, 9, 1, 1, 1, 9, 1], [1, 3, 1, 1, 1, 3, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 3, 1, 1, 1, 3, 1]]) == 19\n    assert candidate(grid = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 5\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 7\n    assert candidate(grid = [[1, 5, 0, 2, 1], [6, 9, 2, 4, 3], [5, 6, 8, 1, 1], [2, 3, 4, 7, 9], [1, 2, 3, 4, 5]]) == 37\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 4, 5, 6, 7, 8, 9, 10], [3, 4, 5, 6, 7, 8, 9, 10, 11], [4, 5, 6, 7, 8, 9, 10, 11, 12], [5, 6, 7, 8, 9, 10, 11, 12, 13], [6, 7, 8, 9, 10, 11, 12, 13, 14], [7, 8, 9, 10, 11, 12, 13, 14, 15], [8, 9, 10, 11, 12, 13, 14, 15, 16], [9, 10, 11, 12, 13, 14, 15, 16, 17]]) == 105\n    assert candidate(grid = [[1000000, 1000000, 1000000, 1000000, 1000000], [1000000, 0, 0, 0, 1000000], [1000000, 0, 1000000, 0, 1000000], [1000000, 0, 0, 0, 1000000], [1000000, 1000000, 1000000, 1000000, 1000000]]) == 5000000\n    assert candidate(grid = [[9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9]]) == 63\n    assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == 35\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 150], [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], [46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75], [76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105], [106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120], [121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135], [136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150]]) == 938\n    assert candidate(grid = [[1, 0, 0, 1, 1], [0, 1, 1, 0, 0], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 1]]) == 4\n    assert candidate(grid = [[1000000, 999999, 999998, 999997, 999996], [999995, 999994, 999993, 999992, 999991], [999990, 999989, 999988, 999987, 999986], [999985, 999984, 999983, 999982, 999981], [999980, 999979, 999978, 999977, 999976]]) == 6999958\n    assert candidate(grid = [[100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000]]) == 700000\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40]]) == 217\n    assert candidate(grid = [[5, 1, 3, 9, 4], [2, 6, 7, 3, 8], [1, 5, 4, 7, 2], [6, 8, 2, 9, 5], [3, 7, 5, 1, 4]]) == 41\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42, 43, 44, 45], [46, 47, 48, 49, 50, 51, 52, 53, 54], [55, 56, 57, 58, 59, 60, 61, 62, 63]]) == 371\n    assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [5, 4, 3, 2, 1], [0, 1, 2, 3, 4], [9, 8, 7, 6, 5]]) == 39\n    assert candidate(grid = [[9, 1, 8, 5, 6], [4, 7, 3, 2, 9], [10, 5, 1, 8, 2], [6, 3, 2, 7, 4], [5, 8, 9, 2, 1]]) == 41\n    assert candidate(grid = [[5, 8, 4, 6], [9, 2, 3, 4], [1, 6, 7, 8], [4, 5, 6, 7], [8, 9, 0, 1], [2, 3, 4, 5]]) == 42\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], [46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75]]) == 413\n    assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43], [44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54]]) == 294\n    assert candidate(grid = [[1, 0, 7, 0, 8, 4], [4, 9, 3, 2, 5, 10], [0, 2, 8, 5, 3, 9], [3, 1, 6, 7, 4, 8], [8, 5, 2, 9, 0, 3], [1, 4, 7, 6, 9, 5]]) == 48\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 7\n    assert candidate(grid = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160], [170, 180, 190, 200]]) == 1050\n    assert candidate(grid = [[1000000, 1000000, 1000000], [1000000, 1000000, 1000000], [1000000, 1000000, 1000000], [1000000, 1000000, 1000000], [1000000, 1000000, 1000000]]) == 7000000\n    assert candidate(grid = [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 0]]) == 49\n    assert candidate(grid = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [110, 120, 130, 140, 150], [160, 170, 180, 190, 200], [210, 220, 230, 240, 250], [260, 270, 280, 290, 300]]) == 1680\n    assert candidate(grid = [[9, 1, 2, 3, 4], [8, 7, 6, 5, 4], [3, 5, 7, 9, 1], [2, 4, 6, 8, 0], [5, 5, 5, 5, 5]]) == 43\n    assert candidate(grid = [[100000, 100000, 100000], [100000, 100000, 100000], [100000, 100000, 100000]]) == 700000\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 7\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 8], [3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10, 11], [6, 7, 8, 9, 10, 11, 12], [7, 8, 9, 10, 11, 12, 13]]) == 77\n    assert candidate(grid = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [0, 10, 20, 30, 40], [9, 19, 29, 39, 49]]) == 248\n    assert candidate(grid = [[1000000, 500000, 300000, 200000], [100000, 50000, 30000, 20000], [10000, 5000, 3000, 2000], [1000, 500, 300, 200]]) == 1868000\n", "comparison": "exact"}, "public_tests": ["[[6,2,1,3],[4,2,1,5],[9,2,8,7],[4,1,2,9]]", "[[1,2,3],[4,5,6],[7,8,9]]"], "hints": ["Each 3x3 submatrix has exactly one hourglass.", "Find the sum of each hourglass in the matrix and return the largest of these values."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maxSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:24+00:00", "tests_total": 65, "tests_dropped": 2, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "matrix", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maxSum(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "maxSum", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2429, "task_id": "minimize-xor", "difficulty": "Medium", "problem_description": "Given two positive integers num1 and num2, find the positive integer x such that:\n\n- x has the same number of set bits as num2, and\n- The value x XOR num1 is minimal.\n\nNote that XOR is the bitwise XOR operation.\n\nReturn the integer x. The test cases are generated such that x is uniquely determined.\n\nThe number of set bits of an integer is the number of 1's in its binary representation.\n\nExample 1:\n\nInput: num1 = 3, num2 = 5\nOutput: 3\nExplanation:\nThe binary representations of num1 and num2 are 0011 and 0101, respectively.\nThe integer 3 has the same number of set bits as num2, and the value 3 XOR 3 = 0 is minimal.\n\nExample 2:\n\nInput: num1 = 1, num2 = 12\nOutput: 3\nExplanation:\nThe binary representations of num1 and num2 are 0001 and 1100, respectively.\nThe integer 3 has the same number of set bits as num2, and the value 3 XOR 1 = 2 is minimal.\n\nConstraints:\n\n- 1 <= num1, num2 <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num1 = 1,num2 = 12) == 3\n    assert candidate(num1 = 8,num2 = 3) == 9\n    assert candidate(num1 = 29,num2 = 15) == 29\n    assert candidate(num1 = 3,num2 = 5) == 3\n    assert candidate(num1 = 7,num2 = 10) == 6\n    assert candidate(num1 = 1000000000,num2 = 1) == 536870912\n    assert candidate(num1 = 987654321,num2 = 1000000000) == 987654144\n    assert candidate(num1 = 8,num2 = 31) == 31\n    assert candidate(num1 = 134217728,num2 = 671088640) == 134217729\n    assert candidate(num1 = 1023,num2 = 511) == 1022\n    assert candidate(num1 = 8388607,num2 = 16777215) == 16777215\n    assert candidate(num1 = 123456789,num2 = 31) == 122683392\n    assert candidate(num1 = 1,num2 = 1023) == 1023\n    assert candidate(num1 = 32768,num2 = 65535) == 65535\n    assert candidate(num1 = 1023,num2 = 1) == 512\n    assert candidate(num1 = 123456789,num2 = 987654321) == 123456791\n    assert candidate(num1 = 1000000000,num2 = 100000000) == 999999488\n    assert candidate(num1 = 123,num2 = 987654321) == 131071\n    assert candidate(num1 = 500000000,num2 = 750000000) == 499999744\n    assert candidate(num1 = 134217728,num2 = 32767) == 134234111\n    assert candidate(num1 = 858993459,num2 = 12) == 805306368\n    assert candidate(num1 = 123456,num2 = 32) == 65536\n    assert candidate(num1 = 512,num2 = 256) == 512\n    assert candidate(num1 = 894567321,num2 = 987654321) == 894567423\n    assert candidate(num1 = 65535,num2 = 8) == 32768\n    assert candidate(num1 = 111111111,num2 = 222222222) == 111111111\n    assert candidate(num1 = 512,num2 = 255) == 639\n    assert candidate(num1 = 834567,num2 = 987654) == 834564\n    assert candidate(num1 = 999999999,num2 = 1) == 536870912\n    assert candidate(num1 = 54321,num2 = 98765) == 54323\n    assert candidate(num1 = 987654321,num2 = 16) == 536870912\n    assert candidate(num1 = 1023,num2 = 10) == 768\n    assert candidate(num1 = 987654,num2 = 24) == 786432\n    assert candidate(num1 = 777777777,num2 = 333333333) == 777777760\n    assert candidate(num1 = 1048575,num2 = 1048575) == 1048575\n    assert candidate(num1 = 987654321,num2 = 123456789) == 987654320\n    assert candidate(num1 = 131071,num2 = 65535) == 131070\n    assert candidate(num1 = 999999999,num2 = 1000000000) == 999999744\n    assert candidate(num1 = 16777215,num2 = 8388607) == 16777214\n    assert candidate(num1 = 8192,num2 = 16384) == 8192\n    assert candidate(num1 = 1023,num2 = 2047) == 2047\n    assert candidate(num1 = 987654321,num2 = 135792468) == 987496448\n    assert candidate(num1 = 134217728,num2 = 25) == 134217731\n    assert candidate(num1 = 1000000000,num2 = 1000000000) == 1000000000\n    assert candidate(num1 = 16,num2 = 3) == 17\n    assert candidate(num1 = 1048575,num2 = 524288) == 524288\n    assert candidate(num1 = 134217728,num2 = 67108864) == 134217728\n    assert candidate(num1 = 888888888,num2 = 888888888) == 888888888\n    assert candidate(num1 = 1000000000,num2 = 500000000) == 1000000000\n    assert candidate(num1 = 67890,num2 = 13579) == 67891\n    assert candidate(num1 = 999999999,num2 = 888888888) == 999999992\n    assert candidate(num1 = 1,num2 = 1048575) == 1048575\n    assert candidate(num1 = 123456789,num2 = 123456789) == 123456789\n    assert candidate(num1 = 8388607,num2 = 4194304) == 4194304\n    assert candidate(num1 = 8388607,num2 = 1048575) == 8388600\n    assert candidate(num1 = 536870911,num2 = 268435456) == 268435456\n    assert candidate(num1 = 135792468,num2 = 246813579) == 135794687\n    assert candidate(num1 = 65535,num2 = 65535) == 65535\n    assert candidate(num1 = 500000000,num2 = 800000000) == 499999744\n    assert candidate(num1 = 1024,num2 = 1023) == 1535\n", "comparison": "exact"}, "public_tests": ["3\n5", "1\n12"], "hints": ["To arrive at a small xor, try to turn off some bits from num1", "If there are still left bits to set, try to set them from the least significant bit"], "metadata": {"canonical_parameter_names": ["num1", "num2"], "leetcode_dataset_entry_point": "Solution().minimizeXor", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:26+00:00", "tests_total": 85, "tests_dropped": 25, "flags": [], "topic_tags": ["greedy", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def minimizeXor(self, num1: int, num2: int) -> int:", "container": "Solution", "callable": "minimizeXor", "parameters": [{"name": "num1", "type": "int"}, {"name": "num2", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2430, "task_id": "maximum-deletions-on-a-string", "difficulty": "Hard", "problem_description": "You are given a string s consisting of only lowercase English letters. In one operation, you can:\n\n- Delete the entire string s, or\n- Delete the first i letters of s if the first i letters of s are equal to the following i letters in s, for any i in the range 1 <= i <= s.length / 2.\n\nFor example, if s = \"ababc\", then in one operation, you could delete the first two letters of s to get \"abc\", since the first two letters of s and the following two letters of s are both equal to \"ab\".\n\nReturn the maximum number of operations needed to delete all of s.\n\nExample 1:\n\nInput: s = \"abcabcdabc\"\nOutput: 2\nExplanation:\n- Delete the first 3 letters (\"abc\") since the next 3 letters are equal. Now, s = \"abcdabc\".\n- Delete all the letters.\nWe used 2 operations so return 2. It can be proven that 2 is the maximum number of operations needed.\nNote that in the second operation we cannot delete \"abc\" again because the next occurrence of \"abc\" does not happen in the next 3 letters.\n\nExample 2:\n\nInput: s = \"aaabaab\"\nOutput: 4\nExplanation:\n- Delete the first letter (\"a\") since the next letter is equal. Now, s = \"aabaab\".\n- Delete the first 3 letters (\"aab\") since the next 3 letters are equal. Now, s = \"aab\".\n- Delete the first letter (\"a\") since the next letter is equal. Now, s = \"ab\".\n- Delete all the letters.\nWe used 4 operations so return 4. It can be proven that 4 is the maximum number of operations needed.\n\nExample 3:\n\nInput: s = \"aaaaa\"\nOutput: 5\nExplanation: In each operation, we can delete the first letter of s.\n\nConstraints:\n\n- 1 <= s.length <= 4000\n- s consists only of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababab\") == 48\n    assert candidate(s = \"aaabaab\") == 4\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 90\n    assert candidate(s = \"abacabadabacaba\") == 1\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 29\n    assert candidate(s = \"abcabcabcabc\") == 4\n    assert candidate(s = \"abcdabcdabcd\") == 3\n    assert candidate(s = \"abcdefghijklmnopqrstuvsuwxyzabcdefghijklmnopqrstuvsuwxyz\") == 2\n    assert candidate(s = \"abcabcdabc\") == 2\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 1\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 2\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 102\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 66\n    assert candidate(s = \"abcdef\") == 1\n    assert candidate(s = \"abababab\") == 4\n    assert candidate(s = \"abcd\") == 1\n    assert candidate(s = \"aaaaa\") == 5\n    assert candidate(s = \"aabbccddeeff\") == 2\n    assert candidate(s = \"abacabadabacabadabacaba\") == 2\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 32\n    assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 26\n    assert candidate(s = \"aabbccddeeffaabbccddeeffaabbccddeeff\") == 4\n    assert candidate(s = \"abcababcababcababcababcababcababcababcababcababcababcab\") == 11\n    assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 13\n    assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 4\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 26\n    assert candidate(s = \"abcdefabcdefabcdefabcdefabcdef\") == 5\n    assert candidate(s = \"abcdefghabcdefghabcdefghabcdefgh\") == 4\n    assert candidate(s = \"aabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeff\") == 9\n    assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\") == 19\n    assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 10\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 24\n    assert candidate(s = \"abababababababababababababababababababababababababababababababab\") == 32\n    assert candidate(s = \"abababababababcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 20\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 27\n    assert candidate(s = \"ababccababccababccababccababcc\") == 6\n    assert candidate(s = \"aaaaabbbbbccccdddd\") == 5\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 28\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcab\") == 9\n    assert candidate(s = \"abcdabcabcdabcabcd\") == 2\n    assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 106\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 20\n    assert candidate(s = \"ababababababababababababababababababababababababababababababababababababab\") == 37\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 18\n    assert candidate(s = \"abababababababababababababababababababc\") == 19\n    assert candidate(s = \"abacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabac\") == 20\n    assert candidate(s = \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\") == 8\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzwwxxyyzzwwxxyyzz\") == 2\n    assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 12\n    assert candidate(s = \"aaaaaaaaaaabaaaaaaaaaabaaaaaaaaaabaaaaaaaaaabaaaaaaaaaabaaaaaaaaaabaaaaaaaaaabaaaaaaaaaabaaaaaaaaaabaaaaaaaaaab\") == 20\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 10\n    assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabb\") == 9\n    assert candidate(s = \"abcdabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 1\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 94\n    assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 10\n    assert candidate(s = \"abracadabraabracadabraabracadabra\") == 3\n    assert candidate(s = \"aaabaaaabaaaaabaaaaaaaabaaaaaaaaabaaaaaaaaaabaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaab\") == 11\n    assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\") == 24\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 110\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 21\n    assert candidate(s = \"abababababababababababababababababababababab\") == 22\n    assert candidate(s = \"ababababababababababababababababababababababababababababababababab\") == 33\n    assert candidate(s = \"ababccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 2\n    assert candidate(s = \"aabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccdd\") == 7\n    assert candidate(s = \"ababababababababababababababababa\") == 16\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 25\n    assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 14\n    assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 11\n    assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 18\n    assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 9\n    assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 16\n    assert candidate(s = \"aabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeff\") == 8\n    assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 27\n    assert candidate(s = \"abacabadabcaba\") == 1\n    assert candidate(s = \"banana\") == 1\n    assert candidate(s = \"abacabacabacabacabacabacabacabac\") == 8\n    assert candidate(s = \"aaabbbcccdddcccbbbcccaaa\") == 3\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 30\n    assert candidate(s = \"aabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeff\") == 6\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 21\n    assert candidate(s = \"abcdabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 1\n    assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 8\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 22\n    assert candidate(s = \"ababcabcabcabcabcabc\") == 7\n    assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 16\n    assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabad\") == 6\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcd\") == 10\n    assert candidate(s = \"abacabadabacabadabacabad\") == 3\n    assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababab\") == 46\n    assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababab\") == 40\n    assert candidate(s = \"ababccababccababccababccababccababccababccababccababccababccababccababccababccababccababcc\") == 16\n    assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 29\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdabcdabcdabcdabcd\") == 2\n    assert candidate(s = \"abababababababababababababababababababababababababababababababababababcabcabc\") == 37\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzwwxxyyzz\") == 2\n    assert candidate(s = \"abacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabac\") == 21\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\") == 11\n    assert candidate(s = \"ababccababccababccababccababccababccababccababccababccababccababccababccababcc\") == 14\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabacabadabacabadabacabadabacabad\") == 2\n    assert candidate(s = \"abacabacabacabacabacabacabacabacabac\") == 9\n    assert candidate(s = \"mississippi\") == 1\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabacabadabacabadabacabadabacabadabacabadabacabad\") == 2\n    assert candidate(s = \"ababababababababababababababababababababababababababababababababababababababababab\") == 41\n", "comparison": "exact"}, "public_tests": ["\"abcabcdabc\"", "\"aaabaab\"", "\"aaaaa\""], "hints": ["We can use dynamic programming to find the answer. Create a 0-indexed dp array where dp[i] represents the maximum number of moves needed to remove the first i + 1 letters from s.", "What should we do if there is an i where it is impossible to remove the first i + 1 letters?", "Use a sentinel value such as -1 to show that it is impossible.", "How can we quickly determine if two substrings of s are equal? We can use hashing."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().deleteString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:28+00:00", "tests_total": 103, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming", "rolling-hash", "string-matching", "hash-function"]}, "language": "python", "interface": {"raw_signature": "def deleteString(self, s: str) -> int:", "container": "Solution", "callable": "deleteString", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2432, "task_id": "the-employee-that-worked-on-the-longest-task", "difficulty": "Easy", "problem_description": "There are n employees, each with a unique id from 0 to n - 1.\n\nYou are given a 2D integer array logs where logs[i] = [id_i, leaveTime_i] where:\n\n- id_i is the id of the employee that worked on the i^th task, and\n- leaveTime_i is the time at which the employee finished the i^th task. All the values leaveTime_i are unique.\n\nNote that the i^th task starts the moment right after the (i - 1)^th task ends, and the 0^th task starts at time 0.\n\nReturn the id of the employee that worked the task with the longest time. If there is a tie between two or more employees, return the smallest id among them.\n\nExample 1:\n\nInput: n = 10, logs = [[0,3],[2,5],[0,9],[1,15]]\nOutput: 1\nExplanation:\nTask 0 started at 0 and ended at 3 with 3 units of times.\nTask 1 started at 3 and ended at 5 with 2 units of times.\nTask 2 started at 5 and ended at 9 with 4 units of times.\nTask 3 started at 9 and ended at 15 with 6 units of times.\nThe task with the longest time is task 3 and the employee with id 1 is the one that worked on it, so we return 1.\n\nExample 2:\n\nInput: n = 26, logs = [[1,1],[3,7],[2,12],[7,17]]\nOutput: 3\nExplanation:\nTask 0 started at 0 and ended at 1 with 1 unit of times.\nTask 1 started at 1 and ended at 7 with 6 units of times.\nTask 2 started at 7 and ended at 12 with 5 units of times.\nTask 3 started at 12 and ended at 17 with 5 units of times.\nThe tasks with the longest time is task 1. The employee that worked on it is 3, so we return 3.\n\nExample 3:\n\nInput: n = 2, logs = [[0,10],[1,20]]\nOutput: 0\nExplanation:\nTask 0 started at 0 and ended at 10 with 10 units of times.\nTask 1 started at 10 and ended at 20 with 10 units of times.\nThe tasks with the longest time are tasks 0 and 1. The employees that worked on them are 0 and 1, so we return the smallest id 0.\n\nConstraints:\n\n- 2 <= n <= 500\n- 1 <= logs.length <= 500\n- logs[i].length == 2\n- 0 <= id_i <= n - 1\n- 1 <= leaveTime_i <= 500\n- id_i != id_{i+1}\n- leaveTime_i are sorted in a strictly increasing order.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 5,logs = [[0, 1], [2, 2], [1, 3], [3, 4]]) == 0\n    assert candidate(n = 2,logs = [[0, 10], [1, 20]]) == 0\n    assert candidate(n = 6,logs = [[0, 2], [1, 6], [2, 10], [3, 14], [4, 18], [5, 22]]) == 1\n    assert candidate(n = 5,logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n    assert candidate(n = 26,logs = [[1, 1], [3, 7], [2, 12], [7, 17]]) == 3\n    assert candidate(n = 4,logs = [[0, 5], [1, 10], [2, 15], [3, 20]]) == 0\n    assert candidate(n = 3,logs = [[0, 10], [1, 20], [2, 30]]) == 0\n    assert candidate(n = 4,logs = [[3, 10], [1, 15], [2, 20], [0, 25]]) == 3\n    assert candidate(n = 3,logs = [[0, 5], [1, 10], [2, 15]]) == 0\n    assert candidate(n = 10,logs = [[0, 3], [2, 5], [0, 9], [1, 15]]) == 1\n    assert candidate(n = 5,logs = [[0, 2], [1, 5], [0, 9]]) == 0\n    assert candidate(n = 5,logs = [[0, 2], [1, 5], [0, 9], [1, 15]]) == 1\n    assert candidate(n = 4,logs = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 0\n    assert candidate(n = 5,logs = [[0, 2], [1, 4], [2, 6], [3, 8], [4, 10]]) == 0\n    assert candidate(n = 10,logs = [[0, 5], [1, 12], [2, 18], [3, 25], [4, 32], [5, 40], [6, 48], [7, 55], [8, 60], [9, 65]]) == 5\n    assert candidate(n = 8,logs = [[6, 2], [4, 5], [3, 9], [5, 14], [1, 18], [7, 23], [2, 29], [0, 34]]) == 2\n    assert candidate(n = 6,logs = [[0, 10], [1, 20], [0, 30], [1, 40], [0, 50], [1, 60]]) == 0\n    assert candidate(n = 20,logs = [[0, 10], [2, 20], [4, 30], [6, 40], [8, 50], [10, 60], [12, 70], [14, 80], [16, 90], [18, 100]]) == 0\n    assert candidate(n = 8,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80]]) == 0\n    assert candidate(n = 10,logs = [[0, 5], [3, 12], [2, 18], [1, 22], [0, 30]]) == 0\n    assert candidate(n = 10,logs = [[0, 1], [2, 4], [4, 7], [6, 10], [8, 13], [1, 16], [3, 19], [5, 22], [7, 25], [9, 28]]) == 1\n    assert candidate(n = 7,logs = [[0, 5], [1, 10], [2, 15], [0, 20], [1, 25], [2, 30], [0, 35]]) == 0\n    assert candidate(n = 20,logs = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50], [10, 55], [11, 60], [12, 65], [13, 70], [14, 75], [15, 80], [16, 85], [17, 90], [18, 95], [19, 100]]) == 0\n    assert candidate(n = 30,logs = [[0, 2], [1, 5], [2, 9], [3, 14], [4, 20], [5, 27], [6, 35], [7, 44], [8, 54], [9, 65], [10, 77], [11, 90], [12, 104], [13, 119], [14, 135], [15, 152], [16, 170], [17, 189], [18, 209], [19, 230], [20, 252], [21, 275], [22, 300], [23, 326], [24, 353], [25, 381], [26, 410], [27, 440], [28, 471], [29, 500]]) == 28\n    assert candidate(n = 3,logs = [[0, 10], [1, 20], [2, 20]]) == 0\n    assert candidate(n = 5,logs = [[0, 5], [1, 10], [2, 10], [3, 15], [4, 20]]) == 0\n    assert candidate(n = 11,logs = [[10, 10], [9, 20], [8, 30], [7, 40], [6, 50], [5, 60], [4, 70], [3, 80], [2, 90], [1, 100], [0, 110]]) == 0\n    assert candidate(n = 10,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100], [0, 110], [1, 120]]) == 0\n    assert candidate(n = 7,logs = [[0, 10], [1, 10], [2, 10], [3, 20], [4, 20], [5, 20], [6, 30]]) == 0\n    assert candidate(n = 6,logs = [[0, 15], [1, 28], [2, 42], [3, 57], [4, 72], [5, 88]]) == 5\n    assert candidate(n = 10,logs = [[0, 1], [1, 3], [2, 6], [3, 10], [4, 15], [5, 21], [6, 28], [7, 36], [8, 45], [9, 55]]) == 9\n    assert candidate(n = 20,logs = [[19, 1], [18, 3], [17, 6], [16, 10], [15, 15], [14, 21], [13, 28], [12, 36], [11, 45], [10, 55], [9, 66], [8, 78], [7, 91], [6, 105], [5, 120], [4, 136], [3, 153], [2, 171], [1, 190], [0, 210]]) == 0\n    assert candidate(n = 25,logs = [[0, 1], [1, 3], [2, 5], [3, 7], [4, 9], [5, 11], [6, 13], [7, 15], [8, 17], [9, 19], [10, 21], [11, 23], [12, 25], [13, 27], [14, 29], [15, 31], [16, 33], [17, 35], [18, 37], [19, 39], [20, 41], [21, 43], [22, 45], [23, 47], [24, 49]]) == 1\n    assert candidate(n = 9,logs = [[0, 2], [1, 5], [2, 10], [3, 17], [4, 26], [5, 37], [6, 50], [7, 65], [8, 82]]) == 8\n    assert candidate(n = 10,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100]]) == 0\n    assert candidate(n = 9,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90]]) == 0\n    assert candidate(n = 15,logs = [[1, 5], [2, 15], [3, 25], [4, 35], [5, 45], [6, 55], [7, 65], [8, 75], [9, 85], [10, 95], [11, 105], [12, 115], [13, 125], [14, 135]]) == 2\n    assert candidate(n = 12,logs = [[0, 2], [1, 4], [2, 7], [3, 11], [4, 16], [5, 22], [6, 29], [7, 37], [8, 46], [9, 56], [10, 67], [11, 78]]) == 10\n    assert candidate(n = 6,logs = [[0, 10], [1, 10], [2, 20], [3, 20], [4, 30], [5, 30]]) == 0\n    assert candidate(n = 7,logs = [[6, 3], [5, 9], [4, 14], [3, 20], [2, 27], [1, 35], [0, 44]]) == 0\n    assert candidate(n = 12,logs = [[11, 2], [10, 5], [9, 9], [8, 14], [7, 20], [6, 27], [5, 35], [4, 44], [3, 54], [2, 65], [1, 77], [0, 90]]) == 0\n    assert candidate(n = 6,logs = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 25], [5, 30]]) == 0\n    assert candidate(n = 10,logs = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50]]) == 0\n    assert candidate(n = 7,logs = [[0, 5], [1, 10], [2, 15], [0, 20], [3, 25], [1, 30], [4, 35]]) == 0\n    assert candidate(n = 15,logs = [[14, 1], [13, 3], [12, 6], [11, 10], [10, 15], [9, 21], [8, 28], [7, 36], [6, 45], [5, 55], [4, 66], [3, 78], [2, 91], [1, 105], [0, 120]]) == 0\n    assert candidate(n = 12,logs = [[11, 10], [10, 20], [9, 30], [8, 40], [7, 50], [6, 60], [5, 70], [4, 80], [3, 90], [2, 100], [1, 110], [0, 120]]) == 0\n    assert candidate(n = 12,logs = [[0, 15], [1, 30], [2, 45], [3, 60], [4, 75], [5, 90], [6, 105], [7, 120], [8, 135], [9, 150], [10, 165], [11, 180]]) == 0\n    assert candidate(n = 10,logs = [[0, 3], [2, 5], [0, 9], [1, 15], [4, 20], [6, 30], [5, 35], [3, 40]]) == 6\n    assert candidate(n = 10,logs = [[0, 10], [1, 15], [2, 20], [3, 25], [4, 30], [5, 35], [6, 40], [7, 45], [8, 50], [9, 55], [0, 60], [1, 65], [2, 70], [3, 75], [4, 80], [5, 85], [6, 90], [7, 95], [8, 100], [9, 105]]) == 0\n    assert candidate(n = 7,logs = [[0, 2], [1, 5], [2, 9], [3, 14], [4, 20], [5, 27], [6, 35]]) == 6\n    assert candidate(n = 8,logs = [[0, 2], [1, 6], [2, 12], [3, 18], [4, 24], [5, 30], [6, 36], [7, 42]]) == 2\n    assert candidate(n = 5,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [0, 60], [1, 70], [2, 80], [3, 90], [4, 100], [0, 110], [1, 120], [2, 130], [3, 140], [4, 150], [0, 160], [1, 170], [2, 180], [3, 190], [4, 200]]) == 0\n    assert candidate(n = 8,logs = [[0, 20], [1, 30], [2, 40], [3, 50], [4, 60], [5, 70], [6, 80], [7, 90]]) == 0\n    assert candidate(n = 7,logs = [[0, 1], [1, 3], [2, 6], [3, 10], [4, 15], [5, 21], [6, 28]]) == 6\n    assert candidate(n = 12,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100], [10, 110], [11, 120], [0, 130], [1, 140], [2, 150], [3, 160], [4, 170], [5, 180], [6, 190], [7, 200], [8, 210], [9, 220], [10, 230], [11, 240]]) == 0\n    assert candidate(n = 15,logs = [[5, 10], [7, 20], [2, 25], [3, 30], [10, 35], [6, 40], [1, 45]]) == 5\n    assert candidate(n = 8,logs = [[0, 3], [1, 7], [2, 14], [3, 22], [4, 31], [5, 41], [6, 53], [7, 66]]) == 7\n    assert candidate(n = 15,logs = [[0, 2], [1, 6], [2, 11], [3, 17], [4, 24], [5, 32], [6, 41], [7, 51], [8, 62], [9, 74], [10, 87], [11, 101], [12, 116], [13, 132], [14, 149]]) == 14\n    assert candidate(n = 11,logs = [[0, 2], [1, 5], [2, 10], [3, 17], [4, 26], [5, 37], [6, 50], [7, 65], [8, 82], [9, 101], [10, 122]]) == 10\n    assert candidate(n = 5,logs = [[0, 10], [1, 15], [2, 20], [3, 25], [4, 30], [0, 35], [1, 40]]) == 0\n    assert candidate(n = 9,logs = [[0, 11], [1, 22], [2, 33], [3, 44], [4, 55], [5, 66], [6, 77], [7, 88], [8, 99]]) == 0\n    assert candidate(n = 5,logs = [[4, 100], [2, 200], [3, 300], [1, 400], [0, 500]]) == 0\n    assert candidate(n = 12,logs = [[0, 5], [1, 12], [2, 22], [3, 35], [4, 50], [5, 67], [6, 86], [7, 107], [8, 130], [9, 155], [10, 182], [11, 211]]) == 11\n    assert candidate(n = 8,logs = [[7, 1], [1, 2], [3, 5], [2, 10], [4, 20], [6, 30], [5, 40], [0, 50]]) == 0\n    assert candidate(n = 20,logs = [[0, 1], [2, 3], [4, 6], [6, 10], [8, 15], [10, 21], [12, 28], [14, 36], [16, 45], [18, 55], [1, 65], [3, 75], [5, 85], [7, 95]]) == 1\n    assert candidate(n = 5,logs = [[0, 1], [1, 10], [2, 11], [3, 12], [4, 13]]) == 1\n    assert candidate(n = 10,logs = [[0, 10], [1, 15], [2, 20], [3, 25], [4, 30], [5, 35], [6, 40], [7, 45], [8, 50], [9, 55]]) == 0\n    assert candidate(n = 10,logs = [[9, 10], [8, 20], [7, 30], [6, 40], [5, 50], [4, 60], [3, 70], [2, 80], [1, 90], [0, 100]]) == 0\n    assert candidate(n = 10,logs = [[0, 5], [1, 15], [2, 25], [3, 35], [4, 45], [5, 55], [6, 65], [7, 75], [8, 85], [9, 95]]) == 1\n    assert candidate(n = 15,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100], [10, 110], [11, 120], [12, 130], [13, 140], [14, 150]]) == 0\n    assert candidate(n = 10,logs = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 30], [5, 40], [6, 50], [7, 60], [8, 70], [9, 80]]) == 4\n    assert candidate(n = 7,logs = [[0, 12], [1, 23], [2, 34], [3, 45], [4, 56], [5, 67], [6, 78]]) == 0\n    assert candidate(n = 25,logs = [[0, 12], [1, 24], [2, 36], [3, 48], [4, 60], [5, 72], [6, 84], [7, 96], [8, 108], [9, 120], [10, 132], [11, 144], [12, 156], [13, 168], [14, 180], [15, 192], [16, 204], [17, 216], [18, 228], [19, 240], [20, 252], [21, 264], [22, 276], [23, 288], [24, 300]]) == 0\n    assert candidate(n = 8,logs = [[7, 15], [3, 25], [5, 40], [6, 50], [2, 60], [1, 70], [4, 80], [0, 90]]) == 5\n    assert candidate(n = 10,logs = [[0, 5], [1, 9], [2, 13], [3, 17], [4, 21], [5, 25], [6, 29], [7, 33], [8, 37], [9, 41]]) == 0\n    assert candidate(n = 6,logs = [[5, 10], [0, 20], [2, 30], [1, 40], [3, 50], [4, 60]]) == 0\n    assert candidate(n = 15,logs = [[0, 2], [1, 5], [2, 9], [3, 14], [4, 20], [5, 27], [6, 35], [7, 44], [8, 54], [9, 65], [10, 77], [11, 90], [12, 104], [13, 119], [14, 135]]) == 14\n    assert candidate(n = 13,logs = [[12, 2], [11, 5], [10, 9], [9, 14], [8, 20], [7, 27], [6, 35], [5, 44], [4, 54], [3, 65], [2, 77], [1, 90], [0, 104]]) == 0\n    assert candidate(n = 10,logs = [[9, 2], [3, 6], [7, 10], [2, 15], [4, 20], [1, 25], [5, 30], [8, 35], [6, 40], [0, 50]]) == 0\n    assert candidate(n = 7,logs = [[0, 5], [1, 10], [0, 15], [1, 20], [0, 25], [1, 30], [0, 35]]) == 0\n    assert candidate(n = 15,logs = [[14, 3], [13, 7], [12, 12], [11, 18], [10, 24], [9, 31], [8, 38], [7, 45], [6, 52], [5, 59], [4, 66], [3, 73], [2, 80], [1, 87], [0, 94]]) == 0\n    assert candidate(n = 30,logs = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50], [10, 55], [11, 60], [12, 65], [13, 70], [14, 75], [15, 80], [16, 85], [17, 90], [18, 95], [19, 100], [20, 105], [21, 110], [22, 115], [23, 120], [24, 125], [25, 130], [26, 135], [27, 140], [28, 145], [29, 150]]) == 0\n    assert candidate(n = 10,logs = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50], [0, 55], [1, 60], [2, 65], [3, 70], [4, 75], [5, 80], [6, 85], [7, 90], [8, 95], [9, 100]]) == 0\n    assert candidate(n = 9,logs = [[8, 1], [7, 3], [6, 6], [5, 10], [4, 15], [3, 21], [2, 28], [1, 36], [0, 45]]) == 0\n    assert candidate(n = 20,logs = [[0, 15], [1, 30], [2, 45], [3, 60], [4, 75], [5, 90], [6, 105], [7, 120], [8, 135], [9, 150], [10, 165], [11, 180], [12, 195], [13, 210], [14, 225], [15, 240], [16, 255], [17, 270], [18, 285], [19, 300]]) == 0\n    assert candidate(n = 15,logs = [[0, 5], [1, 15], [2, 25], [3, 35], [4, 45], [5, 55], [6, 65], [7, 75], [8, 85], [9, 95], [10, 105], [11, 115], [12, 125], [13, 135], [14, 145]]) == 1\n    assert candidate(n = 10,logs = [[0, 5], [1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50], [0, 55], [1, 60], [2, 65], [3, 70], [4, 75], [5, 80], [6, 85], [7, 90], [8, 95], [9, 100], [0, 105], [1, 110], [2, 115], [3, 120], [4, 125], [5, 130], [6, 135], [7, 140], [8, 145], [9, 150]]) == 0\n    assert candidate(n = 5,logs = [[0, 50], [1, 100], [2, 150], [3, 200], [4, 250]]) == 0\n    assert candidate(n = 4,logs = [[0, 10], [1, 20], [2, 30], [3, 40]]) == 0\n    assert candidate(n = 5,logs = [[4, 2], [3, 5], [2, 9], [1, 14], [0, 20]]) == 0\n    assert candidate(n = 7,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [0, 80]]) == 0\n    assert candidate(n = 6,logs = [[0, 5], [1, 15], [2, 25], [3, 35], [4, 45], [5, 55]]) == 1\n    assert candidate(n = 7,logs = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [0, 80], [1, 90], [2, 100], [3, 110], [4, 120], [5, 130], [6, 140], [0, 150], [1, 160], [2, 170], [3, 180], [4, 190], [5, 200], [6, 210]]) == 0\n    assert candidate(n = 8,logs = [[0, 2], [1, 4], [2, 8], [3, 14], [4, 22], [5, 32], [6, 44], [7, 58]]) == 7\n    assert candidate(n = 5,logs = [[0, 50], [1, 100], [2, 150], [3, 200], [4, 250], [0, 300], [1, 350], [2, 400], [3, 450], [4, 500]]) == 0\n    assert candidate(n = 15,logs = [[14, 10], [3, 20], [5, 30], [7, 40], [9, 50], [11, 60], [13, 70]]) == 3\n", "comparison": "exact"}, "public_tests": ["10\n[[0,3],[2,5],[0,9],[1,15]]", "26\n[[1,1],[3,7],[2,12],[7,17]]", "2\n[[0,10],[1,20]]"], "hints": ["Find the time of the longest task", "Store each employee’s longest task time in a hash table", "For employees that have the same longest task time, we only need the employee with the smallest ID"], "metadata": {"canonical_parameter_names": ["n", "logs"], "leetcode_dataset_entry_point": "Solution().hardestWorker", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:33+00:00", "tests_total": 99, "tests_dropped": 3, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def hardestWorker(self, n: int, logs: list[list[int]]) -> int:", "container": "Solution", "callable": "hardestWorker", "parameters": [{"name": "n", "type": "int"}, {"name": "logs", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2433, "task_id": "find-the-original-array-of-prefix-xor", "difficulty": "Medium", "problem_description": "You are given an integer array pref of size n. Find and return the array arr of size n that satisfies:\n\n- pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i].\n\nNote that ^ denotes the bitwise-xor operation.\n\nIt can be proven that the answer is unique.\n\nExample 1:\n\nInput: pref = [5,2,0,3,1]\nOutput: [5,7,2,3,2]\nExplanation: From the array [5,7,2,3,2] we have the following:\n- pref[0] = 5.\n- pref[1] = 5 ^ 7 = 2.\n- pref[2] = 5 ^ 7 ^ 2 = 0.\n- pref[3] = 5 ^ 7 ^ 2 ^ 3 = 3.\n- pref[4] = 5 ^ 7 ^ 2 ^ 3 ^ 2 = 1.\n\nExample 2:\n\nInput: pref = [13]\nOutput: [13]\nExplanation: We have pref[0] = arr[0] = 13.\n\nConstraints:\n\n- 1 <= pref.length <= 10^5\n- 0 <= pref[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(pref = [5, 2, 0, 3, 1]) == [5, 7, 2, 3, 2]\n    assert candidate(pref = [0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n    assert candidate(pref = [0, 1, 2, 3, 4]) == [0, 1, 3, 1, 7]\n    assert candidate(pref = [10, 4, 6, 3, 5]) == [10, 14, 2, 5, 6]\n    assert candidate(pref = [13]) == [13]\n    assert candidate(pref = [1, 1, 1, 1, 1]) == [1, 0, 0, 0, 0]\n    assert candidate(pref = [2, 3, 4, 5, 6]) == [2, 1, 7, 1, 3]\n    assert candidate(pref = [1, 2, 3, 4, 5]) == [1, 3, 1, 7, 1]\n    assert candidate(pref = [1000000, 500000, 250000, 125000, 62500]) == [1000000, 582496, 291248, 145624, 72812]\n    assert candidate(pref = [1, 3, 7, 15, 31]) == [1, 2, 4, 8, 16]\n    assert candidate(pref = [10, 15, 5, 12, 9]) == [10, 5, 10, 9, 5]\n    assert candidate(pref = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [65535, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]\n    assert candidate(pref = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111, 0, 111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999]) == [999999, 184839, 413193, 127515, 153097, 963135, 253449, 422427, 185865, 111111, 111111, 185865, 422427, 253449, 963135, 153097, 127515, 413193, 184839]\n    assert candidate(pref = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [1, 3, 6, 12, 24, 48, 96, 192, 384, 768]\n    assert candidate(pref = [123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234]) == [123456, 161287, 446985, 245275, 938503, 192935, 414177, 106271, 21881]\n    assert candidate(pref = [0, 1, 3, 6, 15, 31, 63, 127, 255, 511]) == [0, 1, 2, 5, 9, 16, 32, 64, 128, 256]\n    assert candidate(pref = [0, 1, 3, 0, 4, 5, 1, 2, 6, 7, 1, 0]) == [0, 1, 2, 3, 4, 1, 4, 3, 4, 1, 6, 1]\n    assert candidate(pref = [0, 1, 3, 6, 10, 15, 21]) == [0, 1, 2, 5, 12, 5, 26]\n    assert candidate(pref = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == [1, 3, 6, 12, 24, 48, 96, 192, 384]\n    assert candidate(pref = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [1024, 1536, 768, 384, 192, 96, 48, 24, 12, 6, 3, 1, 1, 3, 6, 12, 24, 48, 96, 192, 384, 768]\n    assert candidate(pref = [0, 1, 3, 0, 4, 7, 4, 3, 1, 0]) == [0, 1, 2, 3, 4, 3, 3, 7, 2, 1]\n    assert candidate(pref = [123456, 654321, 111111, 222222, 333333, 444444]) == [123456, 530865, 543222, 185865, 422427, 253449]\n    assert candidate(pref = [255, 127, 63, 31, 15, 7, 3, 1, 0]) == [255, 128, 64, 32, 16, 8, 4, 2, 1]\n    assert candidate(pref = [888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == [888888, 413193, 127515, 153097, 963135, 253449, 422427, 185865]\n    assert candidate(pref = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 3, 1, 7, 1, 3, 1, 15, 1, 3, 1, 7, 1, 3, 1]\n    assert candidate(pref = [888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111, 0]) == [888888, 413193, 127515, 153097, 963135, 253449, 422427, 185865, 111111]\n    assert candidate(pref = [256, 272, 258, 274, 259, 275, 260, 276, 261, 277, 262, 278, 263, 279, 264, 280, 265, 281, 266, 282, 267, 283, 268, 284, 269, 285, 270, 286, 271, 287, 272, 288]) == [256, 16, 18, 16, 17, 16, 23, 16, 17, 16, 19, 16, 17, 16, 31, 16, 17, 16, 19, 16, 17, 16, 23, 16, 17, 16, 19, 16, 17, 16, 15, 48]\n    assert candidate(pref = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 3, 1, 7, 1, 3, 1, 15, 1, 3]\n    assert candidate(pref = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 172, 484, 188, 100, 940, 228, 412, 164, 108]\n    assert candidate(pref = [123456, 654321, 111111, 222222, 333333]) == [123456, 530865, 543222, 185865, 422427]\n    assert candidate(pref = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == [100, 172, 484, 188, 100, 940, 228, 412, 164, 108, 1956, 252]\n    assert candidate(pref = [15, 14, 13, 12, 11, 10, 9, 8, 7]) == [15, 1, 3, 1, 7, 1, 3, 1, 15]\n    assert candidate(pref = [17, 23, 14, 31, 5, 9, 12, 7]) == [17, 6, 25, 17, 26, 12, 5, 11]\n    assert candidate(pref = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]\n    assert candidate(pref = [8, 12, 10, 15, 7, 13, 9, 14, 6, 11]) == [8, 4, 6, 5, 8, 10, 4, 7, 8, 13]\n    assert candidate(pref = [13, 13, 26, 26, 52, 52, 104, 104, 208, 208]) == [13, 0, 23, 0, 46, 0, 92, 0, 184, 0]\n    assert candidate(pref = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == [1, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152]\n    assert candidate(pref = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(pref = [256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16]) == [256, 384, 192, 96, 48, 24, 12, 6, 3, 1, 1, 3, 6, 12, 24]\n    assert candidate(pref = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == [1, 0, 3, 1, 6, 13, 5, 24, 55, 21, 110, 201, 121, 400, 795, 441, 1510, 3109, 6733, 2616]\n    assert candidate(pref = [999999, 899999, 799999, 699999, 599999, 499999, 399999, 299999, 199999, 99999]) == [999999, 194976, 102240, 432800, 231904, 951968, 113504, 166304, 499424, 166816]\n    assert candidate(pref = [123456, 654321, 111222, 333444, 555666, 777888]) == [123456, 530865, 543111, 304370, 879638, 238642]\n    assert candidate(pref = [7, 14, 21, 28, 35, 42, 49]) == [7, 9, 27, 9, 63, 9, 27]\n    assert candidate(pref = [42, 21, 42, 21, 42, 21, 42, 21, 42, 21, 42, 21, 42, 21, 42, 21, 42, 21, 42, 21]) == [42, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63]\n    assert candidate(pref = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(pref = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(pref = [1024, 2048, 1024, 2048, 1024, 2048, 1024, 2048, 1024, 2048, 1024, 2048]) == [1024, 3072, 3072, 3072, 3072, 3072, 3072, 3072, 3072, 3072, 3072, 3072]\n    assert candidate(pref = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(pref = [1024, 2048, 4096, 8192, 16384, 32768]) == [1024, 3072, 6144, 12288, 24576, 49152]\n    assert candidate(pref = [255, 0, 255, 0, 255, 0, 255, 0, 255]) == [255, 255, 255, 255, 255, 255, 255, 255, 255]\n    assert candidate(pref = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]) == [0, 1, 2, 5, 12, 5, 26, 9, 56, 9]\n    assert candidate(pref = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930]) == [123, 435, 733, 100845, 232367, 30433, 39331, 100961, 48807, 494561]\n    assert candidate(pref = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(pref = [1365, 1364, 1360, 1344, 1312, 1248, 1120, 896, 512, 0]) == [1365, 1, 4, 16, 96, 448, 128, 2016, 384, 512]\n    assert candidate(pref = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [1, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]\n    assert candidate(pref = [100, 200, 100, 300, 200, 500, 400, 700, 600, 1100, 1000, 1500, 1400, 1900, 1800]) == [100, 172, 172, 328, 484, 316, 100, 812, 228, 1556, 1956, 1588, 164, 532, 100]\n    assert candidate(pref = [16, 28, 40, 52, 64, 76, 88, 100]) == [16, 12, 52, 28, 116, 12, 20, 60]\n    assert candidate(pref = [16, 24, 28, 20, 26, 30, 22, 31, 27, 29, 31, 15, 7, 11, 13, 12]) == [16, 8, 4, 8, 14, 4, 8, 9, 4, 6, 2, 16, 8, 12, 6, 1]\n    assert candidate(pref = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [5, 15, 5, 27, 13, 7, 61, 11, 5, 31, 5, 11]\n    assert candidate(pref = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(pref = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == [1, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576]\n    assert candidate(pref = [3, 1, 2, 3, 1, 0, 1]) == [3, 2, 3, 1, 2, 1, 1]\n    assert candidate(pref = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n    assert candidate(pref = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246]) == [255, 1, 3, 1, 7, 1, 3, 1, 15, 1]\n    assert candidate(pref = [1024, 1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016]) == [1024, 2047, 1, 3, 1, 7, 1, 3, 1]\n    assert candidate(pref = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [15, 1, 3, 1, 7, 1, 3, 1, 15, 1, 3, 1, 7, 1, 3, 1]\n    assert candidate(pref = [987654, 321456, 654321, 789012, 123456, 456789]) == [987654, 783798, 859201, 389605, 911444, 465429]\n    assert candidate(pref = [8, 12, 14, 8, 10, 3, 9, 0, 1, 5, 6, 7, 1]) == [8, 4, 2, 6, 2, 9, 10, 9, 1, 4, 3, 1, 6]\n    assert candidate(pref = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(pref = [255, 254, 252, 248, 240, 224, 192, 128, 64, 0]) == [255, 1, 2, 4, 8, 16, 32, 64, 192, 64]\n    assert candidate(pref = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584]) == [7, 9, 18, 36, 72, 144, 288, 576, 1152, 2304]\n    assert candidate(pref = [8, 12, 10, 14, 13, 11, 15, 9, 13, 11, 15, 9]) == [8, 4, 6, 4, 3, 6, 4, 6, 4, 6, 4, 6]\n    assert candidate(pref = [15, 11, 13, 9, 15, 7]) == [15, 4, 6, 4, 6, 8]\n    assert candidate(pref = [8, 12, 14, 13, 9, 3, 6, 10, 11, 7]) == [8, 4, 2, 3, 4, 10, 5, 12, 1, 12]\n    assert candidate(pref = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10]) == [10, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]\n    assert candidate(pref = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [1, 2, 5, 12, 5, 26, 9, 56, 9, 26]\n    assert candidate(pref = [131313, 131312, 131311, 131310, 131309, 131308, 131307, 131306, 131305, 131304]) == [131313, 1, 31, 1, 3, 1, 7, 1, 3, 1]\n    assert candidate(pref = [15, 30, 60, 120, 240, 480, 960, 1920, 3840, 7680]) == [15, 17, 34, 68, 136, 272, 544, 1088, 2176, 4352]\n", "comparison": "exact"}, "public_tests": ["[5,2,0,3,1]", "[13]"], "hints": ["Consider the following equation: x ^ a = b. How can you find x?", "Notice that arr[i] ^ pref[i-1] = pref[i]. This is the same as the previous equation."], "metadata": {"canonical_parameter_names": ["pref"], "leetcode_dataset_entry_point": "Solution().findArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:35+00:00", "tests_total": 98, "tests_dropped": 20, "flags": [], "topic_tags": ["array", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def findArray(self, pref: list[int]) -> list[int]:", "container": "Solution", "callable": "findArray", "parameters": [{"name": "pref", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2434, "task_id": "using-a-robot-to-print-the-lexicographically-smallest-string", "difficulty": "Medium", "problem_description": "You are given a string s and a robot that currently holds an empty string t. Apply one of the following operations until s and t are both empty:\n\n- Remove the first character of a string s and give it to the robot. The robot will append this character to the string t.\n- Remove the last character of a string t and give it to the robot. The robot will write this character on paper.\n\nReturn the lexicographically smallest string that can be written on the paper.\n\nExample 1:\n\nInput: s = \"zza\"\nOutput: \"azz\"\nExplanation: Let p denote the written string.\nInitially p=\"\", s=\"zza\", t=\"\".\nPerform first operation three times p=\"\", s=\"\", t=\"zza\".\nPerform second operation three times p=\"azz\", s=\"\", t=\"\".\n\nExample 2:\n\nInput: s = \"bac\"\nOutput: \"abc\"\nExplanation: Let p denote the written string.\nPerform first operation twice p=\"\", s=\"c\", t=\"ba\".\nPerform second operation twice p=\"ab\", s=\"c\", t=\"\".\nPerform first operation p=\"ab\", s=\"\", t=\"c\".\nPerform second operation p=\"abc\", s=\"\", t=\"\".\n\nExample 3:\n\nInput: s = \"bdda\"\nOutput: \"addb\"\nExplanation: Let p denote the written string.\nInitially p=\"\", s=\"bdda\", t=\"\".\nPerform first operation four times p=\"\", s=\"\", t=\"bdda\".\nPerform second operation four times p=\"addb\", s=\"\", t=\"\".\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of only English lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"aabbcc\") == \"aabbcc\"\n    assert candidate(s = \"bdda\") == \"addb\"\n    assert candidate(s = \"cba\") == \"abc\"\n    assert candidate(s = \"bac\") == \"abc\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n    assert candidate(s = \"aaa\") == \"aaa\"\n    assert candidate(s = \"abcde\") == \"abcde\"\n    assert candidate(s = \"zza\") == \"azz\"\n    assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyz\"\n    assert candidate(s = \"a\") == \"a\"\n    assert candidate(s = \"edcba\") == \"abcde\"\n    assert candidate(s = \"abacabadabacaba\") == \"aaaaaaaabcbdbcb\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n    assert candidate(s = \"aaaabbbbccccdddd\") == \"aaaabbbbccccdddd\"\n    assert candidate(s = \"fedcb\") == \"bcdef\"\n    assert candidate(s = \"ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\") == \"ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\"\n    assert candidate(s = \"aaabbbccc\") == \"aaabbbccc\"\n    assert candidate(s = \"fedcbafedcbafedcba\") == \"aaabcdefbcdefbcdef\"\n    assert candidate(s = \"fedcbaghijk\") == \"abcdefghijk\"\n    assert candidate(s = \"mjwqeqpdpdwdwwvwqwdqeqpqwwqwwqwwpqwwqwpqwwqppwpqpqppwpqpqpqpqpqpqpqpqpqpqpqpqpqpqppwqqqqqqqppqqqpqpwq\") == \"ddddepppppppppppppppppppppppppppppqqqqqqqqqqqqwwqqqqqqqqqqqqqqwqqwqwwqwqwwqwwqwwqwwqqqwqwvwwwppqeqwjm\"\n    assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjjkkkkllllmmmmnnnnooopppqqqrrrssstttuuuuvvvwwwxxxyyyzzz\") == \"aaabbbcccdddeeefffggghhhiiiijjjjkkkkllllmmmmnnnnooopppqqqrrrssstttuuuuvvvwwwxxxyyyzzz\"\n    assert candidate(s = \"acbcbabcbabcba\") == \"aaaabcbbcbbcbc\"\n    assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"aaaaaaaaaaaaaaaaaaabcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\"\n    assert candidate(s = \"bbbaaa\") == \"aaabbb\"\n    assert candidate(s = \"abcdcba\") == \"aabcdcb\"\n    assert candidate(s = \"zazbzczdz\") == \"abcdzzzzz\"\n    assert candidate(s = \"zzzaaa\") == \"aaazzz\"\n    assert candidate(s = \"amazingleetcodeproblem\") == \"aabelmorpedocteelgnizm\"\n    assert candidate(s = \"abcdefgzyxwvutsrqponmlkjihgfedcba\") == \"aabcdefghijklmnopqrstuvwxyzgfedcb\"\n    assert candidate(s = \"fedcbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbac\") == \"aaaaaaaaaaaaaaaaabcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbccdef\"\n    assert candidate(s = \"abracadabra\") == \"aaaaarbdcrb\"\n    assert candidate(s = \"aabccccaaa\") == \"aaaaaccccb\"\n    assert candidate(s = \"abcdabcda\") == \"aaadcbdcb\"\n    assert candidate(s = \"bacbacbacb\") == \"aaabbccbcb\"\n    assert candidate(s = \"abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde\") == \"aaaaaaaaaabcdedcbedcbedcbedcbedcbedcbedcbedcbedcbe\"\n    assert candidate(s = \"zzzaaaazzzaaaazzzaaaazzzaaaazzzaaaazzzaaaazzzaaaazzzaaaazzzaaaazzzaaaazzzaaaazzzaaaa\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzz\") == \"abcdefghijklmnopqrstuvwxyzz\"\n    assert candidate(s = \"zzzyyyxxxwwwwvvvuuutttsssrqqqpppoonnmmlkkjjiihhggffeedcba\") == \"abcdeeffgghhiijjkklmmnnoopppqqqrssstttuuuvvvwwwwxxxyyyzzz\"\n    assert candidate(s = \"caabdbac\") == \"aaabcdbc\"\n    assert candidate(s = \"aaaabbbbccccddddeeeeffff\") == \"aaaabbbbccccddddeeeeffff\"\n    assert candidate(s = \"fedcba\") == \"abcdef\"\n    assert candidate(s = \"abcdabcabc\") == \"aaabcbcdcb\"\n    assert candidate(s = \"leetcode\") == \"cdeoteel\"\n    assert candidate(s = \"racecar\") == \"aacecrr\"\n    assert candidate(s = \"zzzyyxxwvwuvuttrssrqqponnmlkkjjiihhhggffeeddcbbbaaa\") == \"aaabbbcddeeffgghhhiijjkklmnnopqqrssrttuvuwvwxxyyzzz\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"aabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcb\"\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"aaaabcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcbzyxwvutsrqponmlkjihgfedcbzyxwvutsrqponmlkjihgfedcbz\"\n    assert candidate(s = \"banana\") == \"aaannb\"\n    assert candidate(s = \"abcdeabcde\") == \"aabcdedcbe\"\n    assert candidate(s = \"mississippi\") == \"iiiippssssm\"\n    assert candidate(s = \"acacacacac\") == \"aaaaaccccc\"\n    assert candidate(s = \"abcdabcdbacd\") == \"aaabcdcbdcbd\"\n    assert candidate(s = \"bbaaccdd\") == \"aabbccdd\"\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n    assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n    assert candidate(s = \"abcdabcdabcdabcd\") == \"aaaabcdcbdcbdcbd\"\n    assert candidate(s = \"aaabbbcccddd\") == \"aaabbbcccddd\"\n    assert candidate(s = \"qrsnspndpsnpppdnspndpdpsnsnspdpspndpdpsnpsdpsnpspdpsndpdpsnpdpsnpsdpsnpd\") == \"ddddddddddddddpnspspnsppnsppnsppspnspspnsppnpsppsnsnsppnpsnpppnspnpsnsrq\"\n    assert candidate(s = \"abababababababababababababab\") == \"aaaaaaaaaaaaaabbbbbbbbbbbbbb\"\n    assert candidate(s = \"xyzzyxzyx\") == \"xxxyzyzzy\"\n", "comparison": "exact"}, "public_tests": ["\"zza\"", "\"bac\"", "\"bdda\""], "hints": ["If there are some character “a” ’ s in the string, they can be written on paper before anything else.", "Every character in the string before the last “a” should be written in reversed order.", "After the robot writes every “a” on paper, the same holds for other characters “b”, ”c”, …etc."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().robotWithString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:38+00:00", "tests_total": 61, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "stack", "greedy"]}, "language": "python", "interface": {"raw_signature": "def robotWithString(self, s: str) -> str:", "container": "Solution", "callable": "robotWithString", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2435, "task_id": "paths-in-matrix-whose-sum-is-divisible-by-k", "difficulty": "Hard", "problem_description": "You are given a 0-indexed m x n integer matrix grid and an integer k. You are currently at position (0, 0) and you want to reach position (m - 1, n - 1) moving only down or right.\n\nReturn the number of paths where the sum of the elements on the path is divisible by k. Since the answer may be very large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: grid = [[5,2,4],[3,0,5],[0,7,2]], k = 3\nOutput: 2\nExplanation: There are two paths where the sum of the elements on the path is divisible by k.\nThe first path highlighted in red has a sum of 5 + 2 + 4 + 5 + 2 = 18 which is divisible by 3.\nThe second path highlighted in blue has a sum of 5 + 3 + 0 + 5 + 2 = 15 which is divisible by 3.\n\nExample 2:\n\nInput: grid = [[0,0]], k = 5\nOutput: 1\nExplanation: The path highlighted in red has a sum of 0 + 0 = 0 which is divisible by 5.\n\nExample 3:\n\nInput: grid = [[7,3,4,9],[2,3,6,2],[2,3,7,0]], k = 1\nOutput: 10\nExplanation: Every integer is divisible by 1 so the sum of the elements on every possible path is divisible by k.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 5 * 10^4\n- 1 <= m * n <= 5 * 10^4\n- 0 <= grid[i][j] <= 100\n- 1 <= k <= 50\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[10, 10, 10], [10, 10, 10], [10, 10, 10]],k = 5) == 6\n    assert candidate(grid = [[100, 100], [100, 100]],k = 5) == 2\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6]],k = 2) == 3\n    assert candidate(grid = [[7, 3, 4, 9], [2, 3, 6, 2], [2, 3, 7, 0]],k = 1) == 10\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 2) == 0\n    assert candidate(grid = [[10, 10, 10], [10, 10, 10], [10, 10, 10]],k = 10) == 6\n    assert candidate(grid = [[10, 20, 30], [40, 50, 60]],k = 10) == 3\n    assert candidate(grid = [[5, 2, 4], [3, 0, 5], [0, 7, 2]],k = 3) == 2\n    assert candidate(grid = [[0, 0]],k = 5) == 1\n    assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]],k = 11) == 0\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]],k = 15) == 48\n    assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 7) == 5\n    assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 3) == 13\n    assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 0, 9, 8, 7, 6, 5, 4, 3, 2]],k = 10) == 44\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 3) == 0\n    assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 7, 5, 3, 1, 2, 4, 6, 8]],k = 4) == 5\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == 0\n    assert candidate(grid = [[100, 99, 98, 97, 96], [95, 94, 93, 92, 91], [90, 89, 88, 87, 86], [85, 84, 83, 82, 81], [80, 79, 78, 77, 76]],k = 50) == 7\n    assert candidate(grid = [[50, 49, 48, 47, 46], [45, 44, 43, 42, 41], [40, 39, 38, 37, 36], [35, 34, 33, 32, 31], [30, 29, 28, 27, 26]],k = 7) == 10\n    assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 11) == 7\n    assert candidate(grid = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4], [5, 5, 5, 5, 5]],k = 3) == 22\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]],k = 11) == 65\n    assert candidate(grid = [[50, 49, 48, 47, 46, 45, 44, 43, 42, 41], [40, 39, 38, 37, 36, 35, 34, 33, 32, 31], [30, 29, 28, 27, 26, 25, 24, 23, 22, 21], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],k = 29) == 41\n    assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 10, 12, 14, 16, 18], [18, 16, 14, 12, 10, 8, 6, 4, 2, 0]],k = 19) == 9\n    assert candidate(grid = [[97, 23, 14], [12, 54, 67], [11, 22, 33], [44, 55, 66]],k = 49) == 0\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 10) == 0\n    assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]],k = 10) == 0\n    assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]],k = 13) == 2\n    assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50]],k = 13) == 6\n    assert candidate(grid = [[5, 15, 25, 35, 45], [10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [10, 20, 30, 40, 50]],k = 7) == 5\n    assert candidate(grid = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]],k = 5) == 16\n    assert candidate(grid = [[3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]],k = 5) == 0\n    assert candidate(grid = [[3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8], [9, 8, 7, 6, 5, 4, 3, 2], [1, 3, 5, 7, 9, 11, 13, 15]],k = 7) == 20\n    assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 4) == 35\n    assert candidate(grid = [[99, 98, 97, 96, 95], [94, 93, 92, 91, 90], [89, 88, 87, 86, 85], [84, 83, 82, 81, 80], [79, 78, 77, 76, 75]],k = 50) == 0\n    assert candidate(grid = [[100, 99, 98, 97, 96, 95, 94, 93], [92, 91, 90, 89, 88, 87, 86, 85], [84, 83, 82, 81, 80, 79, 78, 77]],k = 8) == 5\n    assert candidate(grid = [[30, 30, 30, 30, 30, 30, 30, 30, 30, 30], [30, 30, 30, 30, 30, 30, 30, 30, 30, 30], [30, 30, 30, 30, 30, 30, 30, 30, 30, 30]],k = 25) == 0\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],k = 11) == 4500\n    assert candidate(grid = [[42, 24, 64, 18, 81], [30, 37, 30, 26, 44], [30, 37, 30, 26, 44], [30, 37, 30, 26, 44], [30, 37, 30, 26, 44]],k = 17) == 5\n    assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],k = 2) == 35\n    assert candidate(grid = [[3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]],k = 10) == 0\n    assert candidate(grid = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [100, 90, 80, 70, 60, 50, 40, 30, 20, 10], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [100, 90, 80, 70, 60, 50, 40, 30, 20, 10], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]],k = 11) == 119\n    assert candidate(grid = [[25, 24, 23, 22, 21], [20, 19, 18, 17, 16], [15, 14, 13, 12, 11], [10, 9, 8, 7, 6], [5, 4, 3, 2, 1]],k = 17) == 1\n    assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]],k = 3) == 16568\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 10) == 35\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 7) == 55\n    assert candidate(grid = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4], [5, 5, 5, 5, 5]],k = 4) == 16\n    assert candidate(grid = [[42, 35, 18, 57], [61, 36, 35, 90], [61, 28, 47, 66], [84, 84, 53, 71]],k = 17) == 1\n    assert candidate(grid = [[5, 8, 3, 6, 2], [7, 1, 4, 9, 10], [12, 5, 16, 3, 8], [4, 13, 11, 20, 6]],k = 7) == 4\n    assert candidate(grid = [[7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2]],k = 11) == 2\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 7) == 12\n    assert candidate(grid = [[34, 21, 54, 23], [12, 34, 56, 78], [90, 12, 34, 56], [78, 90, 12, 34]],k = 13) == 1\n    assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 0]],k = 5) == 1\n    assert candidate(grid = [[50, 49, 48, 47, 46, 45, 44, 43, 42, 41], [40, 39, 38, 37, 36, 35, 34, 33, 32, 31], [30, 29, 28, 27, 26, 25, 24, 23, 22, 21], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],k = 42) == 50\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 7) == 715\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],k = 3) == 0\n    assert candidate(grid = [[99, 98, 97, 96], [95, 94, 93, 92], [91, 90, 89, 88]],k = 50) == 0\n    assert candidate(grid = [[100, 99, 98, 97, 96, 95, 94, 93, 92, 91], [90, 89, 88, 87, 86, 85, 84, 83, 82, 81], [80, 79, 78, 77, 76, 75, 74, 73, 72, 71], [70, 69, 68, 67, 66, 65, 64, 63, 62, 61], [60, 59, 58, 57, 56, 55, 54, 53, 52, 51]],k = 50) == 0\n    assert candidate(grid = [[3, 1, 4, 1, 5], [9, 2, 6, 5, 3], [5, 8, 9, 7, 9], [3, 2, 3, 8, 4], [0, 2, 1, 3, 8]],k = 13) == 4\n    assert candidate(grid = [[3, 1, 2, 3, 4], [1, 3, 4, 5, 2], [2, 4, 5, 1, 3], [4, 5, 1, 3, 2], [5, 1, 3, 2, 4]],k = 13) == 39\n    assert candidate(grid = [[99, 98, 97, 96, 95], [94, 93, 92, 91, 90], [89, 88, 87, 86, 85], [84, 83, 82, 81, 80]],k = 25) == 2\n    assert candidate(grid = [[99, 98, 97, 96, 95], [94, 93, 92, 91, 90], [89, 88, 87, 86, 85], [84, 83, 82, 81, 80], [79, 78, 77, 76, 75]],k = 49) == 0\n    assert candidate(grid = [[100, 0, 100, 0, 100], [0, 100, 0, 100, 0], [100, 0, 100, 0, 100], [0, 100, 0, 100, 0], [100, 0, 100, 0, 100]],k = 5) == 70\n    assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9]],k = 11) == 5\n    assert candidate(grid = [[37, 37, 37, 37, 37, 37, 37, 37, 37, 37], [37, 37, 37, 37, 37, 37, 37, 37, 37, 37], [37, 37, 37, 37, 37, 37, 37, 37, 37, 37], [37, 37, 37, 37, 37, 37, 37, 37, 37, 37], [37, 37, 37, 37, 37, 37, 37, 37, 37, 37]],k = 47) == 0\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 2) == 70\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]],k = 19) == 3\n    assert candidate(grid = [[0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 10], [10, 8, 6, 4, 2, 0]],k = 4) == 14\n    assert candidate(grid = [[50, 10, 20, 30, 40], [50, 10, 20, 30, 40], [50, 10, 20, 30, 40], [50, 10, 20, 30, 40], [50, 10, 20, 30, 40]],k = 7) == 10\n    assert candidate(grid = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65]],k = 27) == 1\n", "comparison": "exact"}, "public_tests": ["[[5,2,4],[3,0,5],[0,7,2]]\n3", "[[0,0]]\n5", "[[7,3,4,9],[2,3,6,2],[2,3,7,0]]\n1"], "hints": ["The actual numbers in grid do not matter. What matters are the remainders you get when you divide the numbers by k.", "We can use dynamic programming to solve this problem. What can we use as states?", "Let dp[i][j][value] represent the number of paths where the sum of the elements on the path has a remainder of value when divided by k."], "metadata": {"canonical_parameter_names": ["grid", "k"], "leetcode_dataset_entry_point": "Solution().numberOfPaths", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:40+00:00", "tests_total": 74, "tests_dropped": 4, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "matrix"]}, "language": "python", "interface": {"raw_signature": "def numberOfPaths(self, grid: list[list[int]], k: int) -> int:", "container": "Solution", "callable": "numberOfPaths", "parameters": [{"name": "grid", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2437, "task_id": "number-of-valid-clock-times", "difficulty": "Easy", "problem_description": "You are given a string of length 5 called time, representing the current time on a digital clock in the format \"hh:mm\". The earliest possible time is \"00:00\" and the latest possible time is \"23:59\".\n\nIn the string time, the digits represented by the ? symbol are unknown, and must be replaced with a digit from 0 to 9.\n\nReturn an integer answer, the number of valid clock times that can be created by replacing every ? with a digit from 0 to 9.\n\nExample 1:\n\nInput: time = \"?5:00\"\nOutput: 2\nExplanation: We can replace the ? with either a 0 or 1, producing \"05:00\" or \"15:00\". Note that we cannot replace it with a 2, since the time \"25:00\" is invalid. In total, we have two choices.\n\nExample 2:\n\nInput: time = \"0?:0?\"\nOutput: 100\nExplanation: Each ? can be replaced by any digit from 0 to 9, so we have 100 total choices.\n\nExample 3:\n\nInput: time = \"??:??\"\nOutput: 1440\nExplanation: There are 24 possible choices for the hours, and 60 possible choices for the minutes. In total, we have 24 * 60 = 1440 choices.\n\nConstraints:\n\n- time is a valid string of length 5 in the format \"hh:mm\".\n- \"00\" <= hh <= \"23\"\n- \"00\" <= mm <= \"59\"\n- Some of the digits might be replaced with '?' and need to be replaced with digits from 0 to 9.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(time = \"23:?0\") == 6\n    assert candidate(time = \"23:5?\") == 10\n    assert candidate(time = \"09:5?\") == 10\n    assert candidate(time = \"23:?9\") == 6\n    assert candidate(time = \"1?:?0\") == 60\n    assert candidate(time = \"00:??\") == 60\n    assert candidate(time = \"1?:?5\") == 60\n    assert candidate(time = \"0?:0?\") == 100\n    assert candidate(time = \"?3:59\") == 3\n    assert candidate(time = \"1?:2?\") == 100\n    assert candidate(time = \"09:?9\") == 6\n    assert candidate(time = \"??:??\") == 1440\n    assert candidate(time = \"00:00\") == 1\n    assert candidate(time = \"23:59\") == 1\n    assert candidate(time = \"1?:30\") == 10\n    assert candidate(time = \"2?:45\") == 4\n    assert candidate(time = \"1?:5?\") == 100\n    assert candidate(time = \"12:??\") == 60\n    assert candidate(time = \"2?:4?\") == 40\n    assert candidate(time = \"1??:3?\") == 0\n    assert candidate(time = \"?3:21\") == 3\n    assert candidate(time = \"1?:45\") == 10\n    assert candidate(time = \"1?:?1\") == 60\n    assert candidate(time = \"12:?5\") == 6\n    assert candidate(time = \"1?:3?\") == 100\n    assert candidate(time = \"09:??\") == 60\n    assert candidate(time = \"12:?3\") == 6\n    assert candidate(time = \"??:59\") == 24\n    assert candidate(time = \"?5:00\") == 2\n    assert candidate(time = \"2?:3?\") == 40\n    assert candidate(time = \"??:45\") == 24\n    assert candidate(time = \"?4:??\") == 120\n    assert candidate(time = \"19:?5\") == 6\n    assert candidate(time = \"2?:15\") == 4\n    assert candidate(time = \"2?:?3\") == 24\n    assert candidate(time = \"???:30\") == 0\n    assert candidate(time = \"23:?5\") == 6\n    assert candidate(time = \"23:?7\") == 6\n    assert candidate(time = \"??:2?\") == 240\n    assert candidate(time = \"0?:??:\") == 600\n    assert candidate(time = \"??:00\") == 24\n    assert candidate(time = \"19:?7\") == 6\n    assert candidate(time = \"2?:59\") == 4\n    assert candidate(time = \"2?:1?\") == 40\n    assert candidate(time = \"19:?1\") == 6\n    assert candidate(time = \"22:?8\") == 6\n    assert candidate(time = \"?4:3?\") == 20\n    assert candidate(time = \"0?:?9\") == 60\n    assert candidate(time = \"?3:?1\") == 18\n    assert candidate(time = \"1?:??\") == 600\n    assert candidate(time = \"??:3?\") == 240\n    assert candidate(time = \"??:?1\") == 144\n    assert candidate(time = \"12:?7\") == 6\n    assert candidate(time = \"2?:35\") == 4\n    assert candidate(time = \"0??:59\") == 0\n    assert candidate(time = \"2?:?0\") == 24\n    assert candidate(time = \"09:?5\") == 6\n    assert candidate(time = \"???:??\") == 0\n    assert candidate(time = \"?0:5?\") == 30\n    assert candidate(time = \"0?:3?\") == 100\n    assert candidate(time = \"1?:?9\") == 60\n    assert candidate(time = \"12:?9\") == 6\n    assert candidate(time = \"?3:45\") == 3\n    assert candidate(time = \"19:??\") == 60\n    assert candidate(time = \"19:?4\") == 6\n    assert candidate(time = \"23:?4\") == 6\n    assert candidate(time = \"?1:??\") == 180\n    assert candidate(time = \"?3:?0\") == 18\n    assert candidate(time = \"0?:?5\") == 60\n    assert candidate(time = \"0?:4?\") == 100\n    assert candidate(time = \"2?:5?\") == 40\n    assert candidate(time = \"??:10\") == 24\n    assert candidate(time = \"0?:?3\") == 60\n    assert candidate(time = \"19:?0\") == 6\n    assert candidate(time = \"2?:?5\") == 24\n    assert candidate(time = \"2?:40\") == 4\n    assert candidate(time = \"19:?9\") == 6\n    assert candidate(time = \"1?:0?\") == 100\n    assert candidate(time = \"???:00\") == 0\n    assert candidate(time = \"2?:22\") == 4\n    assert candidate(time = \"0?:5?\") == 100\n    assert candidate(time = \"1??:0?\") == 0\n    assert candidate(time = \"0?:30\") == 10\n    assert candidate(time = \"2?:?4\") == 24\n    assert candidate(time = \"21:??\") == 60\n    assert candidate(time = \"20:?7\") == 6\n    assert candidate(time = \"?4:?3\") == 12\n    assert candidate(time = \"2?:00\") == 4\n    assert candidate(time = \"09:4?\") == 10\n    assert candidate(time = \"?9:??\") == 120\n    assert candidate(time = \"1?:?7\") == 60\n    assert candidate(time = \"0?:59\") == 10\n    assert candidate(time = \"0?:??\") == 600\n    assert candidate(time = \"0?:?0\") == 60\n    assert candidate(time = \"?4:5?\") == 20\n    assert candidate(time = \"?2:??\") == 180\n    assert candidate(time = \"1?:59\") == 10\n    assert candidate(time = \"0?:1?\") == 100\n    assert candidate(time = \"2?:??:\") == 240\n    assert candidate(time = \"1??:??\") == 0\n    assert candidate(time = \"?:09\") == 0\n    assert candidate(time = \"?9:0?\") == 20\n    assert candidate(time = \"2?:?2\") == 24\n    assert candidate(time = \"?1:?2\") == 18\n    assert candidate(time = \"2?:?9\") == 24\n    assert candidate(time = \"0?:19\") == 10\n    assert candidate(time = \"??:0?\") == 240\n    assert candidate(time = \"?4:?9\") == 12\n    assert candidate(time = \"20:??\") == 60\n    assert candidate(time = \"??:30\") == 24\n    assert candidate(time = \"1?:??:\") == 600\n    assert candidate(time = \"?4:2?\") == 20\n    assert candidate(time = \"1?:23\") == 10\n    assert candidate(time = \"2?:2?\") == 40\n", "comparison": "exact"}, "public_tests": ["\"?5:00\"", "\"0?:0?\"", "\"??:??\""], "hints": ["Brute force all possible clock times.", "Checking if a clock time is valid can be done with Regex."], "metadata": {"canonical_parameter_names": ["time"], "leetcode_dataset_entry_point": "Solution().countTime", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:44+00:00", "tests_total": 114, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def countTime(self, time: str) -> int:", "container": "Solution", "callable": "countTime", "parameters": [{"name": "time", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2438, "task_id": "range-product-queries-of-powers", "difficulty": "Medium", "problem_description": "Given a positive integer n, there exists a 0-indexed array called powers, composed of the minimum number of powers of 2 that sum to n. The array is sorted in non-decreasing order, and there is only one way to form the array.\n\nYou are also given a 0-indexed 2D integer array queries, where queries[i] = [left_i, right_i]. Each queries[i] represents a query where you have to find the product of all powers[j] with left_i <= j <= right_i.\n\nReturn an array answers, equal in length to queries, where answers[i] is the answer to the i^th query. Since the answer to the i^th query may be too large, each answers[i] should be returned modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 15, queries = [[0,1],[2,2],[0,3]]\nOutput: [2,4,64]\nExplanation:\nFor n = 15, powers = [1,2,4,8]. It can be shown that powers cannot be a smaller size.\nAnswer to 1st query: powers[0] * powers[1] = 1 * 2 = 2.\nAnswer to 2nd query: powers[2] = 4.\nAnswer to 3rd query: powers[0] * powers[1] * powers[2] * powers[3] = 1 * 2 * 4 * 8 = 64.\nEach answer modulo 10^9 + 7 yields the same answer, so [2,4,64] is returned.\n\nExample 2:\n\nInput: n = 2, queries = [[0,0]]\nOutput: [2]\nExplanation:\nFor n = 2, powers = [2].\nThe answer to the only query is powers[0] = 2. The answer modulo 10^9 + 7 is the same, so [2] is returned.\n\nConstraints:\n\n- 1 <= n <= 10^9\n- 1 <= queries.length <= 10^5\n- 0 <= start_i <= end_i < powers.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 10,queries = [[0, 0], [1, 1], [0, 2]]) == [2, 8, 16]\n    assert candidate(n = 1023,queries = [[0, 9], [3, 5]]) == [371842544, 4096]\n    assert candidate(n = 1023,queries = [[0, 9], [4, 5], [2, 8]]) == [371842544, 512, 359738130]\n    assert candidate(n = 100,queries = [[0, 0], [1, 2], [2, 2]]) == [4, 2048, 64]\n    assert candidate(n = 29,queries = [[0, 2], [1, 3]]) == [32, 512]\n    assert candidate(n = 5,queries = [[0, 1], [0, 2], [1, 2]]) == [4, 4, 4]\n    assert candidate(n = 1023,queries = [[0, 9], [3, 5], [6, 8]]) == [371842544, 4096, 2097152]\n    assert candidate(n = 8,queries = [[0, 2], [1, 1], [0, 3]]) == [8, 1, 8]\n    assert candidate(n = 1023,queries = [[0, 9], [2, 6], [0, 8]]) == [371842544, 1048576, 719476260]\n    assert candidate(n = 1023,queries = [[0, 9], [1, 3], [5, 7]]) == [371842544, 64, 262144]\n    assert candidate(n = 255,queries = [[0, 7], [3, 5], [1, 2]]) == [268435456, 4096, 8]\n    assert candidate(n = 5,queries = [[0, 0], [0, 1], [0, 2]]) == [1, 4, 4]\n    assert candidate(n = 1000000000,queries = [[0, 29]]) == [371048337]\n    assert candidate(n = 15,queries = [[0, 1], [2, 2], [0, 3]]) == [2, 4, 64]\n    assert candidate(n = 2,queries = [[0, 0]]) == [2]\n    assert candidate(n = 134217727,queries = [[0, 26], [10, 15], [20, 25]]) == [867243987, 640520040, 792931211]\n    assert candidate(n = 8388607,queries = [[0, 22], [12, 17], [20, 21], [0, 5], [18, 22]]) == [349105660, 570065479, 23240159, 32768, 976371285]\n    assert candidate(n = 1024,queries = [[0, 9], [4, 4], [2, 2], [8, 8], [0, 0]]) == [1024, 1, 1, 1, 1024]\n    assert candidate(n = 1048575,queries = [[0, 19], [5, 10], [15, 18]]) == [953612746, 371842544, 329376018]\n    assert candidate(n = 65535,queries = [[0, 15], [4, 7], [10, 13], [0, 15]]) == [489373567, 4194304, 743685088, 489373567]\n    assert candidate(n = 999999935,queries = [[0, 29], [10, 20], [15, 25], [5, 15], [0, 29]]) == [756589216, 355395742, 948232808, 711461273, 756589216]\n    assert candidate(n = 999999935,queries = [[0, 29], [10, 16], [20, 26]]) == [756589216, 990388602, 1]\n    assert candidate(n = 1048575,queries = [[0, 19], [10, 15], [5, 10], [18, 19]]) == [953612746, 640520040, 371842544, 438952513]\n    assert candidate(n = 1000000000,queries = [[0, 29], [15, 20], [30, 30]]) == [371048337, 1, 1]\n    assert candidate(n = 16777215,queries = [[0, 23], [14, 18], [6, 9], [12, 15], [0, 23]]) == [511821710, 496641140, 73741817, 383381198, 511821710]\n    assert candidate(n = 524287,queries = [[0, 18], [7, 12], [3, 8], [0, 19]]) == [134084614, 67049563, 589934536, 134084614]\n    assert candidate(n = 1234567,queries = [[0, 20], [7, 12], [3, 8]]) == [975523612, 329376018, 658752036]\n    assert candidate(n = 67108863,queries = [[0, 25], [12, 19], [6, 11], [0, 24]]) == [217770278, 829977023, 797922655, 322050759]\n    assert candidate(n = 524287,queries = [[0, 18], [5, 8], [10, 15], [17, 18], [0, 19]]) == [134084614, 67108864, 640520040, 359738130, 134084614]\n    assert candidate(n = 999999935,queries = [[0, 29], [10, 20], [15, 25], [5, 15]]) == [756589216, 355395742, 948232808, 711461273]\n    assert candidate(n = 65535,queries = [[0, 15], [7, 10], [3, 7], [0, 14], [12, 15]]) == [489373567, 179869065, 33554432, 243880903, 383381198]\n    assert candidate(n = 1024,queries = [[0, 0], [0, 9], [1, 8]]) == [1024, 1024, 1]\n    assert candidate(n = 1047552,queries = [[0, 19], [5, 12], [15, 18]]) == [961554387, 892516375, 1]\n    assert candidate(n = 1048575,queries = [[0, 19], [10, 15], [5, 14], [0, 20]]) == [953612746, 640520040, 936761609, 953612746]\n    assert candidate(n = 524287,queries = [[0, 18], [4, 9], [10, 15]]) == [134084614, 755810045, 640520040]\n    assert candidate(n = 131071,queries = [[0, 16], [6, 10], [8, 12], [14, 16]]) == [585862415, 511620083, 898961331, 371842544]\n    assert candidate(n = 536870911,queries = [[0, 28], [3, 8], [12, 17], [0, 28], [8, 13]]) == [733922348, 589934536, 570065479, 733922348, 291172004]\n    assert candidate(n = 5,queries = [[0, 0], [1, 1], [0, 1]]) == [1, 4, 4]\n    assert candidate(n = 4194303,queries = [[0, 21], [4, 9], [12, 16], [3, 8], [0, 21]]) == [686331837, 755810045, 270016253, 589934536, 686331837]\n    assert candidate(n = 1,queries = [[0, 0]]) == [1]\n    assert candidate(n = 65535,queries = [[0, 15], [3, 7], [9, 12], [0, 15], [8, 11]]) == [489373567, 33554432, 46480318, 489373567, 877905026]\n    assert candidate(n = 65535,queries = [[0, 15], [5, 10], [10, 15], [0, 15]]) == [489373567, 371842544, 640520040, 489373567]\n    assert candidate(n = 536870911,queries = [[0, 28], [14, 20], [22, 28]]) == [733922348, 744686787, 145353810]\n    assert candidate(n = 8388607,queries = [[0, 22], [6, 12], [14, 18]]) == [349105660, 291172004, 496641140]\n    assert candidate(n = 511,queries = [[0, 8], [3, 7], [1, 4], [0, 9]]) == [719476260, 33554432, 1024, 719476260]\n    assert candidate(n = 3,queries = [[0, 0], [0, 1], [1, 1]]) == [1, 2, 2]\n    assert candidate(n = 134217727,queries = [[0, 26], [5, 13], [18, 23], [10, 17], [0, 26]]) == [867243987, 993282280, 914988515, 951047217, 867243987]\n    assert candidate(n = 16777215,queries = [[0, 23], [5, 10], [15, 18]]) == [511821710, 371842544, 329376018]\n    assert candidate(n = 524287,queries = [[0, 18], [7, 12], [3, 8]]) == [134084614, 67049563, 589934536]\n    assert candidate(n = 4194303,queries = [[0, 21], [13, 17], [20, 21], [5, 10], [0, 21]]) == [686331837, 640520040, 23240159, 371842544, 686331837]\n    assert candidate(n = 33554431,queries = [[0, 24], [12, 19], [6, 15], [0, 25], [3, 8], [10, 13]]) == [322050759, 829977023, 243880903, 322050759, 589934536, 743685088]\n    assert candidate(n = 2097151,queries = [[0, 20], [8, 12], [16, 20], [10, 15], [0, 20]]) == [431750151, 898961331, 560523804, 640520040, 431750151]\n    assert candidate(n = 33554431,queries = [[0, 24], [16, 20], [8, 11], [2, 5], [0, 24]]) == [322050759, 560523804, 877905026, 16384, 322050759]\n    assert candidate(n = 8388607,queries = [[0, 22], [11, 16], [4, 8], [0, 21]]) == [349105660, 993282280, 73741817, 686331837]\n    assert candidate(n = 4194303,queries = [[0, 21], [10, 15], [18, 20], [5, 8], [0, 21]]) == [686331837, 640520040, 67049563, 67108864, 686331837]\n    assert candidate(n = 536870911,queries = [[0, 28], [12, 18], [20, 25], [0, 29]]) == [733922348, 243880903, 792931211, 733922348]\n    assert candidate(n = 33554431,queries = [[0, 24], [8, 13], [16, 20]]) == [322050759, 291172004, 560523804]\n    assert candidate(n = 1000000000,queries = [[0, 29], [10, 20], [15, 25]]) == [371048337, 946258191, 1]\n    assert candidate(n = 8388607,queries = [[0, 22], [7, 11], [14, 18], [2, 6], [0, 22]]) == [349105660, 371842544, 496641140, 1048576, 349105660]\n    assert candidate(n = 8388607,queries = [[0, 22], [8, 13], [16, 20]]) == [349105660, 291172004, 560523804]\n    assert candidate(n = 1048575,queries = [[0, 19], [10, 15], [5, 18]]) == [953612746, 640520040, 427865320]\n    assert candidate(n = 511,queries = [[0, 8], [3, 6], [1, 7]]) == [719476260, 262144, 268435456]\n    assert candidate(n = 33554431,queries = [[0, 24], [12, 18], [5, 10], [0, 9], [20, 24]]) == [322050759, 243880903, 371842544, 371842544, 804188847]\n    assert candidate(n = 131071,queries = [[0, 16], [8, 12], [0, 0], [15, 16]]) == [585862415, 898961331, 1, 147483634]\n    assert candidate(n = 8388607,queries = [[0, 22], [9, 16], [5, 11], [0, 23], [2, 7]]) == [349105660, 976371285, 533524785, 349105660, 134217728]\n    assert candidate(n = 1048576,queries = [[0, 19], [5, 10], [15, 20]]) == [1048576, 1, 1]\n    assert candidate(n = 255,queries = [[0, 7], [3, 6], [1, 5], [0, 0], [7, 7]]) == [268435456, 262144, 32768, 1, 128]\n    assert candidate(n = 8388607,queries = [[0, 22], [11, 14], [20, 22], [15, 18], [0, 22]]) == [349105660, 898961331, 291172004, 329376018, 349105660]\n    assert candidate(n = 500000000,queries = [[0, 28], [10, 20], [5, 15]]) == [885909558, 993282280, 369201595]\n    assert candidate(n = 134217727,queries = [[0, 26], [10, 16], [18, 24]]) == [867243987, 121047601, 846217527]\n    assert candidate(n = 524287,queries = [[0, 18], [3, 8], [12, 15], [0, 19]]) == [134084614, 589934536, 383381198, 134084614]\n    assert candidate(n = 524287,queries = [[0, 18], [3, 7], [9, 14], [0, 17]]) == [134084614, 33554432, 635008130, 157921350]\n    assert candidate(n = 1048575,queries = [[0, 19], [9, 15], [5, 10], [0, 18], [17, 19]]) == [953612746, 946258191, 371842544, 134084614, 383381198]\n    assert candidate(n = 8388607,queries = [[0, 22], [10, 15], [5, 18]]) == [349105660, 640520040, 427865320]\n    assert candidate(n = 7,queries = [[0, 0], [0, 1], [0, 2], [1, 2], [2, 2]]) == [1, 2, 8, 8, 4]\n    assert candidate(n = 134217727,queries = [[0, 26], [13, 18], [8, 12], [0, 27], [4, 9]]) == [867243987, 484190404, 898961331, 867243987, 755810045]\n    assert candidate(n = 67108863,queries = [[0, 25], [8, 14], [16, 22]]) == [217770278, 562080146, 948232808]\n    assert candidate(n = 1000000000,queries = [[0, 29], [15, 20], [10, 14], [0, 9], [25, 29]]) == [371048337, 1, 946258191, 581415240, 1]\n    assert candidate(n = 999999999,queries = [[0, 29], [10, 15], [20, 25]]) == [421709488, 951047217, 536870912]\n    assert candidate(n = 268435455,queries = [[0, 27], [12, 18], [20, 26]]) == [742004924, 243880903, 427865320]\n", "comparison": "exact"}, "public_tests": ["15\n[[0,1],[2,2],[0,3]]", "2\n[[0,0]]"], "hints": ["The powers array can be created using the binary representation of n.", "Once powers is formed, the products can be taken using brute force."], "metadata": {"canonical_parameter_names": ["n", "queries"], "leetcode_dataset_entry_point": "Solution().productQueries", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:47+00:00", "tests_total": 90, "tests_dropped": 10, "flags": [], "topic_tags": ["array", "bit-manipulation", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def productQueries(self, n: int, queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "productQueries", "parameters": [{"name": "n", "type": "int"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2439, "task_id": "minimize-maximum-of-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums comprising of n non-negative integers.\n\nIn one operation, you must:\n\n- Choose an integer i such that 1 <= i < n and nums[i] > 0.\n- Decrease nums[i] by 1.\n- Increase nums[i - 1] by 1.\n\nReturn the minimum possible value of the maximum integer of nums after performing any number of operations.\n\nExample 1:\n\nInput: nums = [3,7,1,6]\nOutput: 5\nExplanation:\nOne set of optimal operations is as follows:\n1. Choose i = 1, and nums becomes [4,6,1,6].\n2. Choose i = 3, and nums becomes [4,6,2,5].\n3. Choose i = 1, and nums becomes [5,5,2,5].\nThe maximum integer of nums is 5. It can be shown that the maximum number cannot be less than 5.\nTherefore, we return 5.\n\nExample 2:\n\nInput: nums = [10,1]\nOutput: 10\nExplanation:\nIt is optimal to leave nums as is, and since 10 is the maximum value, we return 10.\n\nConstraints:\n\n- n == nums.length\n- 2 <= n <= 10^5\n- 0 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 9, 1, 9, 1]) == 5\n    assert candidate(nums = [1, 1000000000]) == 500000001\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1000000000\n    assert candidate(nums = [9, 7, 5, 3, 1]) == 9\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n    assert candidate(nums = [1000000000, 1000000000]) == 1000000000\n    assert candidate(nums = [5, 5, 5, 5, 5]) == 5\n    assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 3\n    assert candidate(nums = [1, 1000000000, 1, 1000000000, 1]) == 500000001\n    assert candidate(nums = [1, 2, 1000000000, 2, 1]) == 333333335\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1000000000, 0, 0, 0, 0]) == 1000000000\n    assert candidate(nums = [5, 4, 3, 2, 1]) == 5\n    assert candidate(nums = [1, 1000000000, 1, 1, 1]) == 500000001\n    assert candidate(nums = [1, 1000000000, 1]) == 500000001\n    assert candidate(nums = [10, 1]) == 10\n    assert candidate(nums = [3, 7, 1, 6]) == 5\n    assert candidate(nums = [1000000000, 1]) == 1000000000\n    assert candidate(nums = [500, 450, 400, 350, 300, 250, 200, 150, 100, 50]) == 500\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 5\n    assert candidate(nums = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000000000\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 550\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 103\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n    assert candidate(nums = [10, 20, 30, 40, 50]) == 30\n    assert candidate(nums = [1, 999999999, 2, 999999998, 3, 999999997, 4, 999999996, 5]) == 500000000\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000000000]) == 47619048\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n    assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 1000000000\n    assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 25\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 100\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1000000000]) == 100000005\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 10\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 3\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n    assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n    assert candidate(nums = [1000000000, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1000000000\n    assert candidate(nums = [5, 3, 8, 2, 9, 1]) == 6\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 100, 6, 7, 8, 9, 10]) == 20\n    assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 6\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 47619049\n    assert candidate(nums = [0, 0, 0, 0, 0, 1000000000]) == 166666667\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000]) == 1000000000\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 28\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 100000001\n    assert candidate(nums = [999999999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 999999999\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 1000000000\n    assert candidate(nums = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 20\n    assert candidate(nums = [100, 50, 10, 5, 1, 0, 0, 0, 0, 0]) == 100\n    assert candidate(nums = [0, 1000000000, 0, 0, 0, 0, 0, 0, 0, 0]) == 500000000\n    assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 11\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000000000]) == 50000000\n    assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 19\n    assert candidate(nums = [100, 10, 1, 1, 1, 1, 1, 1, 1, 1]) == 100\n    assert candidate(nums = [1000000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1000000000\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 16\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n    assert candidate(nums = [0, 1000000000, 0, 1000000000, 0, 1000000000, 0]) == 500000000\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 20\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 111111112\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n    assert candidate(nums = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000000000\n    assert candidate(nums = [50, 40, 30, 20, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 50\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 13\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 50000001\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n    assert candidate(nums = [5, 4, 3, 2, 1]) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n    assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 1000\n    assert candidate(nums = [1, 999999999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 500000000\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == 6\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 105\n    assert candidate(nums = [10, 20, 30, 40, 50]) == 30\n    assert candidate(nums = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == 275\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 11\n    assert candidate(nums = [1, 2, 100, 4, 5, 6, 7, 8, 9, 10]) == 35\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 11\n    assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == 1000000000\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 100\n    assert candidate(nums = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000]) == 100000000\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n    assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 100\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1000000000]) == 100000000\n    assert candidate(nums = [333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333]) == 333333333\n    assert candidate(nums = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == 168\n    assert candidate(nums = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000000000\n    assert candidate(nums = [999999999, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 999999999\n    assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 1000\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 55\n    assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 30\n    assert candidate(nums = [1000000000, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1000000000\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 31250001\n    assert candidate(nums = [5, 3, 8, 12, 2]) == 7\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n    assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 500\n    assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1000]) == 105\n    assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 6\n", "comparison": "exact"}, "public_tests": ["[3,7,1,6]", "[10,1]"], "hints": ["Try a binary search approach.", "Perform a binary search over the minimum value that can be achieved for the maximum number of the array.", "In each binary search iteration, iterate through the array backwards, greedily decreasing the current element until it is within the limit."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimizeArrayValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:49+00:00", "tests_total": 114, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "binary-search", "dynamic-programming", "greedy", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minimizeArrayValue(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minimizeArrayValue", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2440, "task_id": "create-components-with-same-value", "difficulty": "Hard", "problem_description": "There is an undirected tree with n nodes labeled from 0 to n - 1.\n\nYou are given a 0-indexed integer array nums of length n where nums[i] represents the value of the i^th node. You are also given a 2D integer array edges of length n - 1 where edges[i] = [a_i, b_i] indicates that there is an edge between nodes a_i and b_i in the tree.\n\nYou are allowed to delete some edges, splitting the tree into multiple connected components. Let the value of a component be the sum of all nums[i] for which node i is in the component.\n\nReturn the maximum number of edges you can delete, such that every connected component in the tree has the same value.\n\nExample 1:\n\nInput: nums = [6,2,2,2,6], edges = [[0,1],[1,2],[1,3],[3,4]]\nOutput: 2\nExplanation: The above figure shows how we can delete the edges [0,1] and [3,4]. The created components are nodes [0], [1,2,3] and [4]. The sum of the values in each component equals 6. It can be proven that no better deletion exists, so the answer is 2.\n\nExample 2:\n\nInput: nums = [2], edges = []\nOutput: 0\nExplanation: There are no edges to be deleted.\n\nConstraints:\n\n- 1 <= n <= 2 * 10^4\n- nums.length == n\n- 1 <= nums[i] <= 50\n- edges.length == n - 1\n- edges[i].length == 2\n- 0 <= edges[i][0], edges[i][1] <= n - 1\n- edges represents a valid tree.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [10, 10, 10, 10],edges = [[0, 1], [1, 2], [2, 3]]) == 3\n    assert candidate(nums = [5, 5, 5, 5, 5, 5],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5]]) == 5\n    assert candidate(nums = [1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5]]) == 5\n    assert candidate(nums = [4, 4, 4, 4, 4, 4],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [4, 5]]) == 5\n    assert candidate(nums = [10, 10, 10, 10],edges = [[0, 1], [1, 2], [1, 3]]) == 3\n    assert candidate(nums = [3, 2, 6, 1, 3],edges = [[0, 1], [1, 2], [1, 3], [3, 4]]) == 0\n    assert candidate(nums = [3, 3, 3, 9, 3],edges = [[0, 1], [1, 2], [1, 3], [1, 4]]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]]) == 7\n    assert candidate(nums = [7, 7, 7, 7, 7, 7],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5]]) == 5\n    assert candidate(nums = [4, 4, 4, 4, 4, 4],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 5\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 7\n    assert candidate(nums = [6, 2, 2, 2, 6],edges = [[0, 1], [1, 2], [1, 3], [3, 4]]) == 2\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 7\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 7\n    assert candidate(nums = [2],edges = []) == 0\n    assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]]) == 7\n    assert candidate(nums = [1, 2, 3, 4, 5, 6],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5]]) == 0\n    assert candidate(nums = [1, 2, 3, 6, 2, 2, 2, 6],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [3, 6], [0, 7]]) == 1\n    assert candidate(nums = [15, 10, 5, 5, 10, 10, 10, 5, 10, 10],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9]]) == 2\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 9\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19]]) == 19\n    assert candidate(nums = [1, 2, 2, 1, 1, 1, 2, 2, 1, 2, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [0, 6], [6, 7], [6, 8], [8, 9], [9, 10], [8, 11], [7, 12], [12, 13], [12, 14], [14, 15], [14, 16], [6, 17], [17, 18], [17, 19]]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8], [6, 9]]) == 9\n    assert candidate(nums = [5, 10, 5, 10, 5, 10, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 1\n    assert candidate(nums = [5, 1, 5, 1, 5, 1, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 0\n    assert candidate(nums = [10, 15, 15, 10, 20, 20, 10, 30],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7]]) == 0\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15]]) == 15\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]]) == 19\n    assert candidate(nums = [15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 19\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == 29\n    assert candidate(nums = [10, 10, 5, 5, 5, 5, 10, 5, 5, 5, 5, 10],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [0, 8], [8, 9], [8, 10], [9, 11]]) == 0\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == 19\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 0\n    assert candidate(nums = [10, 5, 5, 2, 2, 2, 10, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]]) == 0\n    assert candidate(nums = [2, 4, 8, 8, 8, 16, 16, 16, 16],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8]]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9]]) == 9\n    assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 11\n    assert candidate(nums = [20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [1, 7], [2, 8], [2, 9], [2, 10], [3, 11], [3, 12], [3, 13], [4, 14], [4, 15], [4, 16], [5, 17], [6, 18], [7, 19]]) == 0\n    assert candidate(nums = [6, 3, 3, 2, 2, 2, 6],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [0, 6]]) == 3\n", "comparison": "exact"}, "public_tests": ["[6,2,2,2,6]\n[[0,1],[1,2],[1,3],[3,4]]", "[2]\n[]"], "hints": ["Consider all divisors of the sum of values."], "metadata": {"canonical_parameter_names": ["nums", "edges"], "leetcode_dataset_entry_point": "Solution().componentValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:51+00:00", "tests_total": 49, "tests_dropped": 5, "flags": ["has_images"], "topic_tags": ["array", "math", "tree", "depth-first-search", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def componentValue(self, nums: list[int], edges: list[list[int]]) -> int:", "container": "Solution", "callable": "componentValue", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2441, "task_id": "largest-positive-integer-that-exists-with-its-negative", "difficulty": "Easy", "problem_description": "Given an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array.\n\nReturn the positive integer k. If there is no such integer, return -1.\n\nExample 1:\n\nInput: nums = [-1,2,-3,3]\nOutput: 3\nExplanation: 3 is the only valid k we can find in the array.\n\nExample 2:\n\nInput: nums = [-1,10,6,7,-7,1]\nOutput: 7\nExplanation: Both 1 and 7 have their corresponding negative values in the array. 7 has a larger value.\n\nExample 3:\n\nInput: nums = [-10,8,6,7,-2,-3]\nOutput: -1\nExplanation: There is no a single valid k, we return -1.\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- -1000 <= nums[i] <= 1000\n- nums[i] != 0\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 2, 3, 4, 5, -4, -3, -2]) == 4\n    assert candidate(nums = [1000, -1000, 500, -500, 250, -250, 125, -125]) == 1000\n    assert candidate(nums = [5, 4, 3, 2, 1, -1]) == 1\n    assert candidate(nums = [5, 4, 3, 2, 1, -5, -4, -3, -2, -1]) == 5\n    assert candidate(nums = [-1]) == -1\n    assert candidate(nums = [1]) == -1\n    assert candidate(nums = [-5, -4, -3, -2, -1]) == -1\n    assert candidate(nums = [1, 2, 3, 4, 5]) == -1\n    assert candidate(nums = [100, 200, -100, -200, 300, 400]) == 200\n    assert candidate(nums = [1000, -1000]) == 1000\n    assert candidate(nums = [-100, -99, -98, 98, 99, 100]) == 100\n    assert candidate(nums = [-10, 8, 6, 7, -2, -3]) == -1\n    assert candidate(nums = [999, -999, 500, -500, 250, -250]) == 999\n    assert candidate(nums = [5, 4, 3, 2, 1]) == -1\n    assert candidate(nums = [1, 1, 1, 1, -1, -1, -1, -1]) == 1\n    assert candidate(nums = [1000, -1000, 500, -500, 250, -250]) == 1000\n    assert candidate(nums = [1, 2, 3, -2, -1]) == 2\n    assert candidate(nums = [1, 2, -2, 3, -3, 4, -4]) == 4\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 5\n    assert candidate(nums = [-1, 10, 6, 7, -7, 1]) == 7\n    assert candidate(nums = [-1, 2, -3, 3]) == 3\n    assert candidate(nums = [-999, 999, -998, 998, -997, 997, -996, 996, -995, 995, -994, 994, -993, 993, -992, 992, -991, 991, -990, 990]) == 999\n    assert candidate(nums = [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 5\n    assert candidate(nums = [1, -1, 1000, -1000, 500, -500, 250, -250, 125, -125, 625, -625, 312, -312, 156, -156, 78, -78, 39, -39]) == 1000\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 9\n    assert candidate(nums = [-100, -99, -98, -97, -96, -95, 95, 96, 97, 98, 99, 100]) == 100\n    assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100]) == 100\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == -1\n    assert candidate(nums = [50, -50, 23, -23, 47, -47, 38, -38, 19, -19, 11, -11, 7, -7, 3, -3, 1, -1]) == 50\n    assert candidate(nums = [999, -999, 998, -998, 997, -997, 996, -996, 995, -995, 994, -994]) == 999\n    assert candidate(nums = [-1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == -1\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50]) == 50\n    assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100, 110, -110, 120, -120, 130, -130, 140, -140, 150, -150, 160, -160, 170, -170, 180, -180, 190, -190, 200, -200]) == 200\n    assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, -6, 7, -7, 8, -8, 9, -9]) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 10\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15]) == 15\n    assert candidate(nums = [999, -999, 500, -500, 250, -250, 125, -125]) == 999\n    assert candidate(nums = [100, -100, 99, -99, 98, -98, 97, -97, 96, -96, 95, -95, 94, -94, 93, -93, 92, -92, 91, -91]) == 100\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 10\n    assert candidate(nums = [-100, 100, 50, -50, 25, -25, 12, -12, 6, -6]) == 100\n    assert candidate(nums = [42, -42, 24, -24, 36, -36, 48, -48, 60, -60, 72, -72, 84, -84, 96, -96, 108, -108, 120, -120]) == 120\n    assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900]) == 900\n    assert candidate(nums = [1, 2, 3, 4, 5, -6, -7, -8, -9, -10]) == -1\n    assert candidate(nums = [7, -7, 14, -14, 21, -21, 28, -28, 35, -35, 42, -42, 49, -49, 56, -56, 63, -63, 70, -70, 77, -77, 84, -84]) == 84\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, -1, -3, -5, -7, -9, -11, -13, -15, -17, -19]) == 19\n    assert candidate(nums = [10, 20, 30, -10, -20, -30, 40, 50, -40, -50, 60, -60, 70]) == 60\n    assert candidate(nums = [-500, 500, 250, -250, 125, -125, 625, -625]) == 625\n    assert candidate(nums = [500, -500, 250, -250, 125, -125, 62, -62, 31, -31, 15, -15, 7, -7, 3, -3, 1, -1]) == 500\n    assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == -1\n    assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10, -6, -7, -8, -9, -10, 11, 12, 13, 14, 15, -11, -12, -13, -14, -15]) == 15\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 20\n    assert candidate(nums = [-1000, 1000, -999, 999, -998, 998, -1, 1]) == 1000\n    assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500, 150, -150, 250, -250, 350, -350]) == 500\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15]) == 15\n    assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == -1\n    assert candidate(nums = [999, 998, 997, 996, 995, -999, -998, -997, -996, -995, 994, 993, 992, 991, -994, -993, -992, -991]) == 999\n    assert candidate(nums = [-500, 500, -499, 499, -498, 498, -1, 1, 2, -2]) == 500\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n    assert candidate(nums = [999, -999, 998, -998, 997, -997, 996, -996, 995, -995, 994, -994, 993, -993]) == 999\n    assert candidate(nums = [-500, 500, -499, 499, -200, 200, 100, -100, 50, -50, 1, -1]) == 500\n    assert candidate(nums = [7, -7, 14, -14, 21, -21, 28, -28, 35, -35, 42, -42, 49, -49, 56, -56]) == 56\n    assert candidate(nums = [2, -2, 4, -4, 6, -6, 8, -8, 10, -10, 12, -12, 14, -14, 16, -16, 18, -18, 20, -20, 22, -22, 24, -24, 26, -26]) == 26\n    assert candidate(nums = [-333, 333, -222, 222, -111, 111, 444, -444, 555, -555, 666, -666, 777, -777, 888, -888, 999]) == 888\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50, 60, 65, 70, 75, -60, -65, -70, -75]) == 75\n    assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500, -600, 600, -700, 700, -800, 800, -900, 900, -1000, 1000]) == 1000\n    assert candidate(nums = [5, -5, 15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75, 85, -85, 95, -95, 105, -105, 115, -115]) == 115\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 15\n    assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10, -6, -7, -8, -9, -10]) == 10\n    assert candidate(nums = [-500, 500, 250, -250, 125, -125, 62, -62]) == 500\n    assert candidate(nums = [100, 200, 300, 400, -100, -200, -300, -400, 500, -500]) == 500\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11]) == 11\n    assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 10\n    assert candidate(nums = [-1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15]) == 15\n    assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100, 110, -110, 120, -120]) == 120\n    assert candidate(nums = [-500, 500, 250, -250, 125, -125, 625, -625, 312, -312]) == 625\n    assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90]) == 90\n    assert candidate(nums = [999, -999, 998, -998, 997, -997, 996, -996, 995, -995]) == 999\n    assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, -109, -108, -107, -106, -105, -104, -103, -102, -101]) == 109\n    assert candidate(nums = [-100, 100, -50, 50, -25, 25, -10, 10]) == 100\n    assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50, 60, -60, 70, -70, 80, -80, 90, -90]) == 90\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 10\n    assert candidate(nums = [-100, 100, -99, 99, -98, 98, -97, 97, -96, 96, -95, 95, -94, 94, -93, 93, -92, 92, -91, 91, -90, 90, -89, 89, -88, 88, -87, 87, -86, 86, -85, 85]) == 100\n    assert candidate(nums = [200, -200, 150, -150, 100, -100, 50, -50, 25, -25, 10, -10, 5, -5, 1, -1]) == 200\n    assert candidate(nums = [-500, 500, -250, 250, -125, 125, -62, 62, -31, 31, -15, 15, -7, 7, -3, 3, -1, 1]) == 500\n    assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 100\n    assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000]) == 1000\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -11, 11, -12, 12, -13, 13, -14, 14, -15, 15]) == 15\n    assert candidate(nums = [-500, 500, 250, -250, 100, -100, 50, -50, 10, -10]) == 500\n    assert candidate(nums = [-500, -400, -300, -200, -100, 100, 200, 300, 400, 500, -1, 1]) == 500\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -15]) == 15\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 11, 12, 13, 14, 15, -11, -12, -13, -14, -15, 16, 17, 18, 19, 20, -16, -17, -18, -19, -20]) == 20\n    assert candidate(nums = [10, 20, 30, 40, -10, -20, -30, 50, 60, -50, -60, 70, 80, -70, -80, 90, -90, 100, -100]) == 100\n    assert candidate(nums = [999, -999, 998, -998, 997, -997, 996, -996, 995, -995, 994, -994, 993, -993, 992, -992, 991, -991, 990, -990]) == 999\n    assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12]) == 12\n    assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30]) == 30\n    assert candidate(nums = [1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 11, -11, 13, -13, 15, -15, 17, -17, 19, -19, 21, -21, 23, -23, 25, -25, 27, -27, 29, -29]) == 29\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n    assert candidate(nums = [-999, 999, -998, 998, -997, 997, -996, 996, -995, 995]) == 999\n    assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30]) == 30\n    assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40]) == 40\n    assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40, 45, -45]) == 45\n    assert candidate(nums = [-500, 500, -499, 499, -498, 498, -497, 497, -496, 496, -495, 495]) == 500\n    assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25]) == 25\n    assert candidate(nums = [-1, -2, -3, -4, -5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == -1\n    assert candidate(nums = [77, -77, 66, -66, 55, -55, 44, -44, 33, -33, 22, -22, 11, -11, 1, -1]) == 77\n    assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n    assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40, 45, -45, 50, -50, 55, -55, 60, -60, 65, -65]) == 65\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, -19, -17, -15, -13, -11, -9, -7, -5, -3, -1]) == 19\n    assert candidate(nums = [-1000, 1000, -999, 999, -998, 998, -997, 997, -996, 996]) == 1000\n    assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500, 600, -600, 700, -700, 800, -800, 900, -900]) == 900\n    assert candidate(nums = [-23, 23, -45, 45, -67, 67, -89, 89, 101, -101, 123, -123, 145, -145, 167, -167, 189, -189]) == 189\n", "comparison": "exact"}, "public_tests": ["[-1,2,-3,3]", "[-1,10,6,7,-7,1]", "[-10,8,6,7,-2,-3]"], "hints": ["What data structure can help you to determine if an element exists?", "Would a hash table help?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findMaxK", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:54+00:00", "tests_total": 116, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "hash-table", "two-pointers", "sorting"]}, "language": "python", "interface": {"raw_signature": "def findMaxK(self, nums: list[int]) -> int:", "container": "Solution", "callable": "findMaxK", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2442, "task_id": "count-number-of-distinct-integers-after-reverse-operations", "difficulty": "Medium", "problem_description": "You are given an array nums consisting of positive integers.\n\nYou have to take each integer in the array, reverse its digits, and add it to the end of the array. You should apply this operation to the original integers in nums.\n\nReturn the number of distinct integers in the final array.\n\nExample 1:\n\nInput: nums = [1,13,10,12,31]\nOutput: 6\nExplanation: After including the reverse of each number, the resulting array is [1,13,10,12,31,1,31,1,21,13].\nThe reversed integers that were added to the end of the array are underlined. Note that for the integer 10, after reversing it, it becomes 01 which is just 1.\nThe number of distinct integers in this array is 6 (The numbers 1, 10, 12, 13, 21, and 31).\n\nExample 2:\n\nInput: nums = [2,2,2]\nOutput: 1\nExplanation: After including the reverse of each number, the resulting array is [2,2,2,2,2,2].\nThe number of distinct integers in this array is 1 (The number 2).\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [2, 2, 2]) == 1\n    assert candidate(nums = [123, 321, 111, 222]) == 4\n    assert candidate(nums = [100, 200, 300, 400]) == 8\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n    assert candidate(nums = [9, 99, 999, 9999]) == 4\n    assert candidate(nums = [987, 654, 321]) == 6\n    assert candidate(nums = [111, 222, 333, 444, 555]) == 5\n    assert candidate(nums = [123, 321, 456, 654]) == 4\n    assert candidate(nums = [100, 200, 300]) == 6\n    assert candidate(nums = [120, 210, 130, 310]) == 8\n    assert candidate(nums = [111, 222, 333, 444]) == 4\n    assert candidate(nums = [1, 13, 10, 12, 31]) == 6\n    assert candidate(nums = [123, 321, 111, 456, 654]) == 5\n    assert candidate(nums = [123456, 654321, 111222, 222111, 101010, 100100, 200200, 300300, 400400]) == 14\n    assert candidate(nums = [123456, 654321, 112233, 332211, 445566, 665544, 778899, 998877]) == 8\n    assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1001, 2002, 3003]) == 12\n    assert candidate(nums = [10001, 20002, 30003, 40004, 50005, 111111, 222222, 333333, 444444, 555555]) == 10\n    assert candidate(nums = [999, 998, 997, 996, 995, 994]) == 11\n    assert candidate(nums = [987654, 456789, 876543, 345678, 765432, 234567]) == 6\n    assert candidate(nums = [987654, 456789, 123, 321, 111, 222, 333]) == 7\n    assert candidate(nums = [111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999]) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 27\n    assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == 9\n    assert candidate(nums = [101010, 202020, 303030, 404040, 505050]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 18\n    assert candidate(nums = [100001, 200002, 300003, 400004, 500005, 600006, 700007, 800008, 900009]) == 9\n    assert candidate(nums = [123, 321, 456, 654, 789, 987, 111, 222, 333, 444, 555, 666]) == 12\n    assert candidate(nums = [123, 321, 120, 210, 102, 201, 213, 312, 132, 321]) == 12\n    assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007]) == 7\n    assert candidate(nums = [987654, 876543, 765432, 654321, 543210]) == 10\n    assert candidate(nums = [1001, 2002, 3003, 4004, 5005]) == 5\n    assert candidate(nums = [1, 12, 123, 1234, 12345]) == 9\n    assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000]) == 7\n    assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707, 808, 909, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 24\n    assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 9\n    assert candidate(nums = [999999, 111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888]) == 9\n    assert candidate(nums = [123, 231, 312, 132, 213, 321]) == 6\n    assert candidate(nums = [123, 321, 456, 654, 789, 987, 101, 202, 303]) == 9\n    assert candidate(nums = [123, 321, 120, 210, 102, 201, 132, 231, 312, 321, 123, 213]) == 12\n    assert candidate(nums = [100000, 20000, 3000, 400, 50]) == 10\n    assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == 9\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 18\n    assert candidate(nums = [987654, 876543, 765432, 654321, 543210, 432109, 321098]) == 14\n    assert candidate(nums = [123456, 234567, 345678, 456789, 567890]) == 10\n    assert candidate(nums = [12345, 54321, 11223, 32211, 11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999]) == 13\n    assert candidate(nums = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876]) == 18\n    assert candidate(nums = [123, 321, 132, 213, 231, 312, 456, 654, 465, 546, 564, 645]) == 12\n    assert candidate(nums = [987654, 456789, 111222, 222111, 333444]) == 6\n    assert candidate(nums = [12, 21, 13, 31, 14, 41, 15, 51, 16, 61, 17, 71, 18, 81, 19, 91]) == 16\n    assert candidate(nums = [100200, 200100, 101010, 110110, 202020, 220220, 303030, 330330, 404040]) == 18\n    assert candidate(nums = [123, 321, 213, 132, 312, 231]) == 6\n    assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 123, 321, 132, 213, 231, 312]) == 15\n    assert candidate(nums = [12345, 54321, 11111, 22222, 33333]) == 5\n    assert candidate(nums = [101, 110, 202, 220, 303, 330]) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 28\n    assert candidate(nums = [123456, 654321, 111111, 222222, 333333]) == 5\n    assert candidate(nums = [123321, 234432, 345543, 456654, 567765]) == 5\n    assert candidate(nums = [1001, 2002, 3003, 4004, 5005]) == 5\n    assert candidate(nums = [123456, 654321, 111222, 222111, 1001]) == 5\n    assert candidate(nums = [123456, 654321, 112233, 332211, 987654]) == 6\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 202, 303, 404, 505, 606, 707, 808, 909, 110, 210, 310, 410, 510]) == 27\n    assert candidate(nums = [1234, 4321, 1122, 2211, 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == 13\n    assert candidate(nums = [100000, 200000, 300000, 400000, 500000]) == 10\n    assert candidate(nums = [100, 101, 102, 103, 104, 105]) == 11\n    assert candidate(nums = [10101, 20202, 30303, 40404, 50505, 11111, 22222, 33333, 44444, 55555]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n    assert candidate(nums = [9, 99, 999, 9999, 99999, 999999]) == 6\n    assert candidate(nums = [987654, 456789, 876543, 345678]) == 4\n    assert candidate(nums = [12345, 54321, 11122, 22111, 33344, 44333, 55556, 65555, 76543, 34567]) == 10\n    assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000]) == 7\n    assert candidate(nums = [100000, 100001, 100010, 100100, 101000]) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 28\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 2000, 3000]) == 21\n    assert candidate(nums = [111111, 222222, 333333, 444444, 555555]) == 5\n    assert candidate(nums = [999999, 888888, 777777, 666666, 555555]) == 5\n    assert candidate(nums = [111222, 222333, 333444, 444555, 555666]) == 10\n    assert candidate(nums = [123, 321, 213, 132, 312, 231, 456, 654, 546, 465, 645, 564]) == 12\n    assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 9\n    assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 1001, 2002, 3003, 4004, 5005]) == 14\n    assert candidate(nums = [987654, 876543, 765432, 654321, 543210]) == 10\n    assert candidate(nums = [123456, 654321, 111222, 222111]) == 4\n    assert candidate(nums = [100021, 123456, 789012, 321654, 210987]) == 8\n    assert candidate(nums = [123456, 654321, 111111, 222222, 333333, 444444]) == 6\n    assert candidate(nums = [987654, 456789, 987653, 356789, 987652, 256789, 987651, 156789, 987643]) == 10\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000]) == 10\n    assert candidate(nums = [101010, 202020, 303030, 404040, 505050]) == 10\n    assert candidate(nums = [100001, 200002, 300003, 400004, 500005]) == 5\n    assert candidate(nums = [123456, 654321, 112233, 332211, 445566]) == 6\n    assert candidate(nums = [123456, 654321, 111222, 222111, 101010]) == 6\n    assert candidate(nums = [12345, 54321, 11122, 22111, 33344, 44333, 55566, 66555, 77788, 88777]) == 10\n    assert candidate(nums = [100000, 200000, 300000, 400000, 500000]) == 10\n    assert candidate(nums = [10001, 10010, 10100, 11000, 10001]) == 7\n    assert candidate(nums = [12, 21, 101, 110, 1001, 1010, 1100, 2002, 2020, 2200]) == 13\n    assert candidate(nums = [100, 200, 300, 400, 500, 101, 202, 303, 404, 505]) == 15\n    assert candidate(nums = [111111, 222222, 333333, 444444, 555555]) == 5\n    assert candidate(nums = [1234, 4321, 1122, 2211, 1331, 1133, 2442, 2244, 4224, 4422]) == 11\n    assert candidate(nums = [9, 98, 987, 9876, 98765]) == 9\n", "comparison": "exact"}, "public_tests": ["[1,13,10,12,31]", "[2,2,2]"], "hints": ["What data structure allows us to insert numbers and find the number of distinct numbers in it?", "Try using a set, insert all the numbers and their reverse into it, and return its size."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countDistinctIntegers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:56+00:00", "tests_total": 103, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "hash-table", "math", "counting"]}, "language": "python", "interface": {"raw_signature": "def countDistinctIntegers(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countDistinctIntegers", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2443, "task_id": "sum-of-number-and-its-reverse", "difficulty": "Medium", "problem_description": "Given a non-negative integer num, return true if num can be expressed as the sum of any non-negative integer and its reverse, or false otherwise.\n\nExample 1:\n\nInput: num = 443\nOutput: true\nExplanation: 172 + 271 = 443 so we return true.\n\nExample 2:\n\nInput: num = 63\nOutput: false\nExplanation: 63 cannot be expressed as the sum of a non-negative integer and its reverse so we return false.\n\nExample 3:\n\nInput: num = 181\nOutput: true\nExplanation: 140 + 041 = 181 so we return true. Note that when a number is reversed, there may be leading zeros.\n\nConstraints:\n\n- 0 <= num <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(num = 443) == True\n    assert candidate(num = 181) == True\n    assert candidate(num = 99999) == False\n    assert candidate(num = 1001) == True\n    assert candidate(num = 0) == True\n    assert candidate(num = 63) == False\n    assert candidate(num = 1000) == False\n    assert candidate(num = 121) == True\n    assert candidate(num = 100) == False\n    assert candidate(num = 123) == False\n    assert candidate(num = 100000) == False\n    assert candidate(num = 696) == False\n    assert candidate(num = 1101) == False\n    assert candidate(num = 999) == False\n    assert candidate(num = 67876) == True\n    assert candidate(num = 727) == True\n    assert candidate(num = 454) == False\n    assert candidate(num = 6789) == False\n    assert candidate(num = 929) == True\n    assert candidate(num = 1202) == False\n    assert candidate(num = 767) == True\n    assert candidate(num = 646) == True\n    assert candidate(num = 1230) == False\n    assert candidate(num = 67890) == False\n    assert candidate(num = 808) == True\n    assert candidate(num = 131) == False\n    assert candidate(num = 303) == True\n    assert candidate(num = 535) == False\n    assert candidate(num = 12345) == False\n    assert candidate(num = 606) == True\n    assert candidate(num = 12321) == False\n    assert candidate(num = 252) == False\n    assert candidate(num = 474) == False\n    assert candidate(num = 343) == True\n    assert candidate(num = 434) == False\n    assert candidate(num = 868) == True\n    assert candidate(num = 56789) == False\n    assert candidate(num = 171) == False\n    assert candidate(num = 797) == False\n    assert candidate(num = 22222) == True\n    assert candidate(num = 101) == True\n    assert candidate(num = 8008) == True\n    assert candidate(num = 86420) == False\n    assert candidate(num = 50005) == True\n    assert candidate(num = 666) == True\n    assert candidate(num = 939) == False\n    assert candidate(num = 585) == True\n    assert candidate(num = 2002) == True\n    assert candidate(num = 393) == False\n    assert candidate(num = 222) == True\n    assert candidate(num = 98765) == False\n    assert candidate(num = 151) == False\n    assert candidate(num = 99009) == False\n    assert candidate(num = 11) == True\n    assert candidate(num = 959) == False\n    assert candidate(num = 5050) == False\n    assert candidate(num = 8228) == True\n    assert candidate(num = 414) == False\n    assert candidate(num = 67676) == True\n    assert candidate(num = 898) == False\n    assert candidate(num = 292) == False\n    assert candidate(num = 878) == False\n    assert candidate(num = 1331) == True\n    assert candidate(num = 89898) == True\n    assert candidate(num = 141) == True\n    assert candidate(num = 80708) == False\n    assert candidate(num = 191) == False\n    assert candidate(num = 55555) == False\n    assert candidate(num = 282) == True\n    assert candidate(num = 575) == False\n    assert candidate(num = 919) == False\n    assert candidate(num = 848) == True\n    assert candidate(num = 6006) == True\n    assert candidate(num = 828) == True\n    assert candidate(num = 262) == True\n    assert candidate(num = 272) == False\n    assert candidate(num = 353) == False\n    assert candidate(num = 818) == False\n    assert candidate(num = 525) == True\n    assert candidate(num = 9) == False\n    assert candidate(num = 979) == False\n    assert candidate(num = 424) == True\n    assert candidate(num = 99990) == False\n    assert candidate(num = 616) == False\n    assert candidate(num = 707) == True\n    assert candidate(num = 66666) == True\n    assert candidate(num = 595) == False\n    assert candidate(num = 88888) == True\n    assert candidate(num = 1221) == True\n    assert candidate(num = 323) == True\n    assert candidate(num = 555) == False\n    assert candidate(num = 383) == True\n    assert candidate(num = 888) == True\n    assert candidate(num = 757) == False\n    assert candidate(num = 636) == False\n    assert candidate(num = 313) == False\n    assert candidate(num = 464) == True\n    assert candidate(num = 494) == False\n    assert candidate(num = 717) == False\n    assert candidate(num = 7007) == True\n    assert candidate(num = 686) == True\n    assert candidate(num = 9009) == True\n    assert candidate(num = 60006) == True\n    assert candidate(num = 20202) == True\n    assert candidate(num = 24680) == False\n    assert candidate(num = 737) == False\n    assert candidate(num = 8888) == True\n    assert candidate(num = 1) == False\n    assert candidate(num = 1010) == True\n    assert candidate(num = 545) == True\n    assert candidate(num = 656) == False\n    assert candidate(num = 909) == True\n    assert candidate(num = 565) == True\n    assert candidate(num = 232) == False\n    assert candidate(num = 54321) == False\n    assert candidate(num = 98789) == False\n    assert candidate(num = 45454) == True\n    assert candidate(num = 50505) == False\n    assert candidate(num = 11111) == False\n    assert candidate(num = 90000) == False\n    assert candidate(num = 45654) == True\n    assert candidate(num = 78987) == False\n    assert candidate(num = 676) == False\n    assert candidate(num = 505) == True\n    assert candidate(num = 363) == True\n    assert candidate(num = 949) == True\n    assert candidate(num = 1020) == False\n    assert candidate(num = 838) == False\n    assert candidate(num = 161) == True\n    assert candidate(num = 33333) == False\n    assert candidate(num = 626) == True\n    assert candidate(num = 444) == True\n    assert candidate(num = 13579) == False\n    assert candidate(num = 787) == True\n    assert candidate(num = 202) == True\n    assert candidate(num = 75309) == False\n    assert candidate(num = 373) == False\n    assert candidate(num = 333) == False\n    assert candidate(num = 22) == True\n    assert candidate(num = 50000) == False\n    assert candidate(num = 404) == True\n    assert candidate(num = 13531) == False\n    assert candidate(num = 989) == True\n    assert candidate(num = 2022) == False\n    assert candidate(num = 10101) == False\n    assert candidate(num = 858) == False\n    assert candidate(num = 111) == False\n    assert candidate(num = 484) == True\n    assert candidate(num = 515) == False\n    assert candidate(num = 242) == True\n    assert candidate(num = 50050) == False\n    assert candidate(num = 777) == False\n    assert candidate(num = 54545) == False\n    assert candidate(num = 969) == True\n    assert candidate(num = 747) == True\n    assert candidate(num = 5005) == True\n    assert candidate(num = 9999) == True\n    assert candidate(num = 212) == False\n    assert candidate(num = 10000) == False\n", "comparison": "exact"}, "public_tests": ["443", "63", "181"], "hints": ["The constraints are small enough that we can check every number.", "To reverse a number, first convert it to a string. Then, create a new string that is the reverse of the first one. Finally, convert the new string back into a number."], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().sumOfNumberAndReverse", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:52:58+00:00", "tests_total": 177, "tests_dropped": 18, "flags": [], "topic_tags": ["math", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def sumOfNumberAndReverse(self, num: int) -> bool:", "container": "Solution", "callable": "sumOfNumberAndReverse", "parameters": [{"name": "num", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2444, "task_id": "count-subarrays-with-fixed-bounds", "difficulty": "Hard", "problem_description": "You are given an integer array nums and two integers minK and maxK.\n\nA fixed-bound subarray of nums is a subarray that satisfies the following conditions:\n\n- The minimum value in the subarray is equal to minK.\n- The maximum value in the subarray is equal to maxK.\n\nReturn the number of fixed-bound subarrays.\n\nA subarray is a contiguous part of an array.\n\nExample 1:\n\nInput: nums = [1,3,5,2,7,5], minK = 1, maxK = 5\nOutput: 2\nExplanation: The fixed-bound subarrays are [1,3,5] and [1,3,5,2].\n\nExample 2:\n\nInput: nums = [1,1,1,1], minK = 1, maxK = 1\nOutput: 10\nExplanation: Every subarray of nums is a fixed-bound subarray. There are 10 possible subarrays.\n\nConstraints:\n\n- 2 <= nums.length <= 10^5\n- 1 <= nums[i], minK, maxK <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],minK = 3,maxK = 7) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],minK = 3,maxK = 7) == 1\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 5],minK = 2,maxK = 4) == 4\n    assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],minK = 3,maxK = 7) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],minK = 1,maxK = 10) == 1\n    assert candidate(nums = [2, 4, 3, 2, 4, 6],minK = 2,maxK = 4) == 8\n    assert candidate(nums = [10, 9, 8, 7, 6],minK = 6,maxK = 10) == 1\n    assert candidate(nums = [1, 2, 3, 2, 1],minK = 1,maxK = 3) == 5\n    assert candidate(nums = [10, 20, 30, 40, 50],minK = 10,maxK = 50) == 1\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],minK = 2,maxK = 5) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5],minK = 2,maxK = 4) == 1\n    assert candidate(nums = [1, 3, 5, 2, 7, 5],minK = 1,maxK = 5) == 2\n    assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],minK = 6,maxK = 6) == 55\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],minK = 1,maxK = 5) == 4\n    assert candidate(nums = [5, 5, 5, 5, 5],minK = 5,maxK = 5) == 15\n    assert candidate(nums = [5, 4, 3, 2, 1],minK = 2,maxK = 4) == 1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],minK = 5,maxK = 5) == 55\n    assert candidate(nums = [1, 1, 1, 1],minK = 1,maxK = 1) == 10\n    assert candidate(nums = [2, 3, 5, 1, 5, 7, 5],minK = 1,maxK = 5) == 7\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],minK = 2,maxK = 9) == 1\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],minK = 2,maxK = 8) == 1\n    assert candidate(nums = [2, 1, 5, 1, 3, 5, 4, 2],minK = 1,maxK = 5) == 20\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],minK = 5,maxK = 20) == 1\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],minK = 1,maxK = 5) == 108\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],minK = 2,maxK = 2) == 210\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],minK = 2,maxK = 9) == 3\n    assert candidate(nums = [6, 2, 5, 3, 4, 2, 3, 2, 2, 3, 5, 4, 3, 2, 1],minK = 2,maxK = 5) == 47\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],minK = 2,maxK = 2) == 120\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1],minK = 1,maxK = 3) == 39\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],minK = 7,maxK = 7) == 120\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10],minK = 1,maxK = 10) == 38\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],minK = 3,maxK = 12) == 1\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 5, 6, 7, 8],minK = 3,maxK = 5) == 3\n    assert candidate(nums = [10, 7, 5, 3, 2, 2, 5, 7, 10],minK = 2,maxK = 7) == 8\n    assert candidate(nums = [3, 1, 5, 4, 2, 5, 1, 3, 4],minK = 1,maxK = 5) == 26\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],minK = 3,maxK = 3) == 210\n    assert candidate(nums = [7, 9, 5, 6, 3, 1, 8, 4, 2, 5],minK = 3,maxK = 7) == 0\n    assert candidate(nums = [7, 8, 9, 10, 7, 8, 9, 10, 7, 8, 9, 10, 7, 8, 9, 10, 7, 8, 9, 10, 7, 8, 9, 10],minK = 7,maxK = 10) == 246\n    assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1],minK = 1,maxK = 8) == 225\n    assert candidate(nums = [5, 3, 3, 3, 1, 4, 5, 5, 2, 5],minK = 1,maxK = 5) == 22\n    assert candidate(nums = [5, 3, 4, 5, 3, 5, 3, 4, 5, 3],minK = 3,maxK = 5) == 41\n    assert candidate(nums = [1, 5, 3, 5, 2, 3, 5, 1, 2, 5],minK = 1,maxK = 5) == 28\n    assert candidate(nums = [6, 4, 5, 1, 2, 3, 1, 5, 4, 6, 1, 2, 3, 1, 5, 4, 6, 1, 2, 3, 1, 5, 4, 6],minK = 1,maxK = 5) == 36\n    assert candidate(nums = [1, 3, 2, 5, 4, 6, 5, 3, 2, 1, 4, 5, 6, 7, 8, 9],minK = 2,maxK = 8) == 0\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],minK = 5,maxK = 10) == 2\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1],minK = 1,maxK = 3) == 20\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],minK = 10,maxK = 15) == 1\n    assert candidate(nums = [7, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],minK = 1,maxK = 7) == 9\n    assert candidate(nums = [10, 20, 10, 20, 30, 10, 20, 10],minK = 10,maxK = 20) == 9\n    assert candidate(nums = [1, 5, 4, 5, 1, 1, 5, 2, 1, 3, 4, 5],minK = 1,maxK = 5) == 53\n    assert candidate(nums = [7, 3, 3, 5, 7, 3, 5, 7, 3, 5],minK = 3,maxK = 7) == 38\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minK = 1,maxK = 1) == 210\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],minK = 4,maxK = 12) == 1\n    assert candidate(nums = [1, 2, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1],minK = 2,maxK = 4) == 2\n    assert candidate(nums = [5, 4, 5, 3, 5, 4, 5, 2, 5, 4, 5, 3, 5, 4, 5, 1, 5, 4, 5, 3],minK = 1,maxK = 5) == 79\n    assert candidate(nums = [1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1],minK = 1,maxK = 3) == 103\n    assert candidate(nums = [5, 3, 1, 4, 5, 2, 3, 4, 5, 2, 1, 4, 5, 3, 2, 1, 5],minK = 1,maxK = 5) == 100\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7],minK = 2,maxK = 6) == 9\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],minK = 2,maxK = 5) == 2\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],minK = 1,maxK = 10) == 303\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8],minK = 5,maxK = 8) == 2\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],minK = 1,maxK = 10) == 102\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],minK = 8,maxK = 8) == 210\n    assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7],minK = 3,maxK = 6) == 2\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1],minK = 1,maxK = 10) == 21\n    assert candidate(nums = [1, 5, 3, 5, 2, 3, 1, 5, 2],minK = 1,maxK = 5) == 23\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],minK = 2,maxK = 4) == 4\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],minK = 3,maxK = 7) == 2\n    assert candidate(nums = [5, 5, 3, 5, 2, 3, 3, 5, 3, 3, 5, 3, 2, 5, 5, 3, 3, 5, 5, 5],minK = 2,maxK = 5) == 139\n    assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],minK = 1,maxK = 5) == 154\n    assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],minK = 1,maxK = 5) == 106\n    assert candidate(nums = [1, 3, 5, 3, 1, 5, 3, 1, 5, 3, 1, 5, 3, 1, 5, 3, 1, 5, 3, 1],minK = 1,maxK = 5) == 175\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],minK = 6,maxK = 24) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],minK = 10,maxK = 150) == 1\n    assert candidate(nums = [7, 8, 9, 10, 7, 8, 9, 10, 7, 8],minK = 7,maxK = 10) == 34\n    assert candidate(nums = [7, 3, 5, 1, 5, 2, 5, 5, 2, 5, 1, 5, 3, 7],minK = 1,maxK = 7) == 21\n    assert candidate(nums = [2, 1, 3, 3, 2, 3, 1, 2, 3, 2, 1, 2, 3],minK = 1,maxK = 3) == 63\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],minK = 1,maxK = 5) == 312\n    assert candidate(nums = [1, 3, 1, 3, 5, 1, 3, 5, 2, 5, 3, 2, 3, 1, 2, 3, 5, 1, 3, 5, 2, 5],minK = 1,maxK = 5) == 181\n    assert candidate(nums = [100, 200, 100, 300, 200, 100, 300, 200, 100],minK = 100,maxK = 300) == 29\n    assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 9, 7, 5, 3, 1, 2, 4, 6, 8],minK = 3,maxK = 9) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5],minK = 2,maxK = 5) == 9\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],minK = 3,maxK = 8) == 1\n    assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6],minK = 5,maxK = 6) == 190\n    assert candidate(nums = [2, 4, 2, 1, 5, 4, 2, 3, 5, 1],minK = 1,maxK = 5) == 29\n    assert candidate(nums = [8, 7, 6, 7, 8, 9, 10, 9, 8, 7, 6, 7, 8, 9],minK = 6,maxK = 9) == 10\n    assert candidate(nums = [3, 6, 3, 7, 3, 5, 3, 4, 3, 3],minK = 3,maxK = 7) == 27\n    assert candidate(nums = [5, 1, 3, 5, 7, 5, 3, 1, 5],minK = 1,maxK = 5) == 8\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],minK = 1,maxK = 2) == 45\n    assert candidate(nums = [5, 1, 3, 5, 1, 3, 5, 1, 3, 5, 1, 3, 5, 1, 3, 5],minK = 1,maxK = 5) == 110\n    assert candidate(nums = [1, 5, 3, 5, 3, 5, 3, 5, 3, 1],minK = 1,maxK = 5) == 16\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],minK = 3,maxK = 7) == 1\n    assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],minK = 6,maxK = 6) == 55\n    assert candidate(nums = [2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4],minK = 2,maxK = 4) == 120\n    assert candidate(nums = [1000000, 999999, 1000000, 999999, 1000000, 999999, 1000000],minK = 999999,maxK = 1000000) == 21\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],minK = 5,maxK = 10) == 4\n    assert candidate(nums = [2, 1, 5, 3, 5, 1, 5, 2, 5, 1, 5, 3, 2, 1],minK = 1,maxK = 5) == 79\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],minK = 3,maxK = 8) == 2\n    assert candidate(nums = [2, 1, 3, 4, 5, 1, 5, 2],minK = 1,maxK = 5) == 19\n    assert candidate(nums = [3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 5, 5, 5, 5],minK = 1,maxK = 5) == 48\n    assert candidate(nums = [1, 3, 2, 5, 4, 6, 5, 4, 3, 2, 1, 3, 5, 2, 4, 6, 5, 4, 3, 2, 1],minK = 2,maxK = 5) == 10\n    assert candidate(nums = [5, 3, 1, 3, 1, 5, 3, 1, 3, 1, 5, 3, 1, 3, 1],minK = 1,maxK = 5) == 84\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],minK = 5,maxK = 10) == 3\n    assert candidate(nums = [1, 2, 2, 3, 4, 3, 5, 2, 3, 4, 5, 3, 4, 5, 3, 4, 2, 3, 4, 5, 3, 4, 2, 5, 3, 4, 5],minK = 2,maxK = 5) == 256\n    assert candidate(nums = [6, 4, 5, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],minK = 2,maxK = 5) == 4\n    assert candidate(nums = [5, 1, 2, 3, 4, 5, 6, 7, 8, 9],minK = 5,maxK = 9) == 1\n    assert candidate(nums = [3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4],minK = 1,maxK = 4) == 75\n    assert candidate(nums = [2, 1, 5, 3, 4, 2, 1, 5, 3, 4, 2, 1, 5, 3, 4],minK = 1,maxK = 5) == 83\n    assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 1, 5, 2, 5, 3, 5, 4, 5, 1, 5, 2],minK = 1,maxK = 5) == 147\n    assert candidate(nums = [1, 5, 3, 4, 2, 1, 5, 4, 3, 2],minK = 2,maxK = 5) == 2\n    assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1],minK = 1,maxK = 5) == 51\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],minK = 3,maxK = 7) == 4\n    assert candidate(nums = [1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000],minK = 1,maxK = 1000000) == 66\n    assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1],minK = 1,maxK = 4) == 46\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4],minK = 2,maxK = 4) == 8\n", "comparison": "exact"}, "public_tests": ["[1,3,5,2,7,5]\n1\n5", "[1,1,1,1]\n1\n1"], "hints": ["Can you solve the problem if all the numbers in the array were between minK and maxK inclusive?", "Think of the inclusion-exclusion principle.", "Divide the array into multiple subarrays such that each number in each subarray is between minK and maxK inclusive, solve the previous problem for each subarray, and sum all the answers."], "metadata": {"canonical_parameter_names": ["nums", "minK", "maxK"], "leetcode_dataset_entry_point": "Solution().countSubarrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:00+00:00", "tests_total": 116, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "queue", "sliding-window", "monotonic-queue"]}, "language": "python", "interface": {"raw_signature": "def countSubarrays(self, nums: list[int], minK: int, maxK: int) -> int:", "container": "Solution", "callable": "countSubarrays", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "minK", "type": "int"}, {"name": "maxK", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2446, "task_id": "determine-if-two-events-have-conflict", "difficulty": "Easy", "problem_description": "You are given two arrays of strings that represent two inclusive events that happened on the same day, event1 and event2, where:\n\n- event1 = [startTime_1, endTime_1] and\n- event2 = [startTime_2, endTime_2].\n\nEvent times are valid 24 hours format in the form of HH:MM.\n\nA conflict happens when two events have some non-empty intersection (i.e., some moment is common to both events).\n\nReturn true if there is a conflict between two events. Otherwise, return false.\n\nExample 1:\n\nInput: event1 = [\"01:15\",\"02:00\"], event2 = [\"02:00\",\"03:00\"]\nOutput: true\nExplanation: The two events intersect at time 2:00.\n\nExample 2:\n\nInput: event1 = [\"01:00\",\"02:00\"], event2 = [\"01:20\",\"03:00\"]\nOutput: true\nExplanation: The two events intersect starting from 01:20 to 02:00.\n\nExample 3:\n\nInput: event1 = [\"10:00\",\"11:00\"], event2 = [\"14:00\",\"15:00\"]\nOutput: false\nExplanation: The two events do not intersect.\n\nConstraints:\n\n- event1.length == event2.length == 2\n- event1[i].length == event2[i].length == 5\n- startTime_1 <= endTime_1\n- startTime_2 <= endTime_2\n- All the event times follow the HH:MM format.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(event1 = ['10:00', '11:00'],event2 = ['14:00', '15:00']) == False\n    assert candidate(event1 = ['00:00', '23:59'],event2 = ['12:00', '12:01']) == True\n    assert candidate(event1 = ['00:00', '23:59'],event2 = ['12:00', '12:00']) == True\n    assert candidate(event1 = ['00:00', '23:59'],event2 = ['12:00', '12:30']) == True\n    assert candidate(event1 = ['01:15', '02:00'],event2 = ['02:00', '03:00']) == True\n    assert candidate(event1 = ['09:30', '10:30'],event2 = ['10:00', '11:00']) == True\n    assert candidate(event1 = ['05:45', '06:45'],event2 = ['06:45', '07:45']) == True\n    assert candidate(event1 = ['08:00', '09:00'],event2 = ['07:00', '08:30']) == True\n    assert candidate(event1 = ['23:59', '23:59'],event2 = ['23:59', '23:59']) == True\n    assert candidate(event1 = ['13:00', '15:00'],event2 = ['14:00', '16:00']) == True\n    assert candidate(event1 = ['12:00', '12:30'],event2 = ['12:15', '12:45']) == True\n    assert candidate(event1 = ['01:00', '02:00'],event2 = ['01:20', '03:00']) == True\n    assert candidate(event1 = ['13:00', '14:00'],event2 = ['14:00', '15:00']) == True\n    assert candidate(event1 = ['09:00', '09:30'],event2 = ['09:30', '10:00']) == True\n    assert candidate(event1 = ['16:00', '17:00'],event2 = ['16:30', '17:30']) == True\n    assert candidate(event1 = ['12:00', '13:00'],event2 = ['12:30', '13:30']) == True\n    assert candidate(event1 = ['13:30', '15:30'],event2 = ['14:00', '16:00']) == True\n    assert candidate(event1 = ['08:00', '09:00'],event2 = ['09:00', '10:00']) == True\n    assert candidate(event1 = ['12:00', '13:00'],event2 = ['13:00', '14:00']) == True\n    assert candidate(event1 = ['00:01', '23:59'],event2 = ['12:00', '12:01']) == True\n    assert candidate(event1 = ['12:00', '12:00'],event2 = ['12:00', '12:00']) == True\n    assert candidate(event1 = ['22:00', '23:00'],event2 = ['21:30', '22:30']) == True\n    assert candidate(event1 = ['00:00', '23:59'],event2 = ['01:00', '02:00']) == True\n    assert candidate(event1 = ['00:00', '23:59'],event2 = ['12:00', '13:00']) == True\n    assert candidate(event1 = ['05:30', '06:00'],event2 = ['05:45', '06:15']) == True\n    assert candidate(event1 = ['01:00', '02:00'],event2 = ['00:59', '01:01']) == True\n    assert candidate(event1 = ['08:00', '09:00'],event2 = ['08:00', '08:30']) == True\n    assert candidate(event1 = ['23:55', '00:10'],event2 = ['23:45', '00:05']) == False\n    assert candidate(event1 = ['09:00', '17:00'],event2 = ['08:30', '09:30']) == True\n    assert candidate(event1 = ['14:00', '16:00'],event2 = ['15:30', '17:00']) == True\n    assert candidate(event1 = ['15:00', '16:00'],event2 = ['14:00', '15:30']) == True\n    assert candidate(event1 = ['14:00', '15:00'],event2 = ['13:00', '14:00']) == True\n    assert candidate(event1 = ['23:59', '00:01'],event2 = ['00:00', '00:01']) == False\n    assert candidate(event1 = ['00:00', '11:59'],event2 = ['12:00', '23:59']) == False\n    assert candidate(event1 = ['09:45', '10:45'],event2 = ['10:30', '11:30']) == True\n    assert candidate(event1 = ['05:00', '07:00'],event2 = ['06:00', '06:59']) == True\n    assert candidate(event1 = ['23:59', '23:59'],event2 = ['23:59', '00:00']) == False\n    assert candidate(event1 = ['08:00', '09:00'],event2 = ['08:00', '08:59']) == True\n    assert candidate(event1 = ['07:30', '08:00'],event2 = ['07:45', '08:15']) == True\n    assert candidate(event1 = ['09:00', '18:00'],event2 = ['17:59', '18:01']) == True\n    assert candidate(event1 = ['06:00', '07:00'],event2 = ['06:00', '06:59']) == True\n    assert candidate(event1 = ['00:01', '00:59'],event2 = ['00:30', '01:00']) == True\n    assert candidate(event1 = ['23:30', '00:30'],event2 = ['23:00', '23:59']) == False\n    assert candidate(event1 = ['09:30', '10:15'],event2 = ['10:00', '10:45']) == True\n    assert candidate(event1 = ['13:00', '14:00'],event2 = ['13:45', '14:45']) == True\n    assert candidate(event1 = ['11:00', '13:00'],event2 = ['12:30', '14:00']) == True\n    assert candidate(event1 = ['14:30', '15:30'],event2 = ['15:00', '16:00']) == True\n    assert candidate(event1 = ['20:00', '21:00'],event2 = ['19:00', '20:00']) == True\n    assert candidate(event1 = ['11:00', '12:00'],event2 = ['09:00', '10:59']) == False\n    assert candidate(event1 = ['11:59', '23:59'],event2 = ['23:59', '00:00']) == False\n    assert candidate(event1 = ['09:00', '09:00'],event2 = ['09:00', '09:00']) == True\n    assert candidate(event1 = ['08:30', '09:45'],event2 = ['09:30', '10:30']) == True\n    assert candidate(event1 = ['07:15', '07:45'],event2 = ['07:45', '08:15']) == True\n    assert candidate(event1 = ['09:30', '10:30'],event2 = ['10:00', '10:00']) == True\n    assert candidate(event1 = ['00:00', '00:01'],event2 = ['00:00', '00:02']) == True\n    assert candidate(event1 = ['18:30', '19:00'],event2 = ['19:00', '19:30']) == True\n    assert candidate(event1 = ['14:45', '15:15'],event2 = ['15:15', '15:45']) == True\n    assert candidate(event1 = ['17:45', '18:15'],event2 = ['18:15', '18:45']) == True\n    assert candidate(event1 = ['03:00', '04:00'],event2 = ['02:30', '03:30']) == True\n    assert candidate(event1 = ['01:00', '02:00'],event2 = ['23:59', '01:30']) == False\n    assert candidate(event1 = ['18:00', '19:00'],event2 = ['17:30', '18:00']) == True\n    assert candidate(event1 = ['08:30', '09:30'],event2 = ['09:00', '09:15']) == True\n    assert candidate(event1 = ['08:30', '09:30'],event2 = ['09:00', '09:30']) == True\n    assert candidate(event1 = ['08:00', '09:00'],event2 = ['07:59', '08:01']) == True\n    assert candidate(event1 = ['14:00', '15:00'],event2 = ['13:59', '14:01']) == True\n    assert candidate(event1 = ['11:45', '12:15'],event2 = ['12:15', '12:45']) == True\n    assert candidate(event1 = ['05:30', '06:30'],event2 = ['06:20', '07:20']) == True\n    assert candidate(event1 = ['00:00', '24:00'],event2 = ['00:00', '24:00']) == True\n    assert candidate(event1 = ['13:30', '14:30'],event2 = ['14:30', '15:30']) == True\n    assert candidate(event1 = ['08:45', '09:45'],event2 = ['09:45', '10:45']) == True\n    assert candidate(event1 = ['13:45', '14:45'],event2 = ['14:45', '15:45']) == True\n    assert candidate(event1 = ['00:00', '23:59'],event2 = ['12:30', '13:30']) == True\n    assert candidate(event1 = ['13:15', '14:45'],event2 = ['14:00', '15:30']) == True\n    assert candidate(event1 = ['09:00', '17:00'],event2 = ['10:00', '15:00']) == True\n    assert candidate(event1 = ['06:00', '06:59'],event2 = ['07:00', '08:00']) == False\n    assert candidate(event1 = ['22:00', '22:59'],event2 = ['22:59', '23:59']) == True\n    assert candidate(event1 = ['11:00', '13:00'],event2 = ['12:00', '14:00']) == True\n    assert candidate(event1 = ['17:00', '18:00'],event2 = ['16:30', '17:00']) == True\n    assert candidate(event1 = ['03:00', '04:00'],event2 = ['03:59', '04:01']) == True\n    assert candidate(event1 = ['06:00', '07:00'],event2 = ['05:59', '06:01']) == True\n    assert candidate(event1 = ['23:55', '23:59'],event2 = ['23:56', '00:05']) == False\n    assert candidate(event1 = ['23:45', '23:59'],event2 = ['23:50', '00:10']) == False\n    assert candidate(event1 = ['15:30', '16:30'],event2 = ['15:00', '15:30']) == True\n    assert candidate(event1 = ['09:00', '17:00'],event2 = ['17:00', '18:00']) == True\n    assert candidate(event1 = ['11:00', '11:01'],event2 = ['11:00', '11:01']) == True\n    assert candidate(event1 = ['09:00', '17:00'],event2 = ['12:00', '13:00']) == True\n    assert candidate(event1 = ['11:00', '11:30'],event2 = ['11:30', '12:00']) == True\n    assert candidate(event1 = ['05:30', '06:00'],event2 = ['06:00', '06:30']) == True\n    assert candidate(event1 = ['05:30', '06:30'],event2 = ['06:29', '07:30']) == True\n    assert candidate(event1 = ['09:30', '10:30'],event2 = ['10:00', '10:15']) == True\n    assert candidate(event1 = ['00:00', '23:59'],event2 = ['00:00', '23:59']) == True\n    assert candidate(event1 = ['11:45', '12:45'],event2 = ['11:30', '11:45']) == True\n    assert candidate(event1 = ['15:30', '15:30'],event2 = ['15:30', '15:30']) == True\n    assert candidate(event1 = ['12:00', '13:00'],event2 = ['11:00', '12:59']) == True\n    assert candidate(event1 = ['14:00', '15:00'],event2 = ['15:00', '16:00']) == True\n    assert candidate(event1 = ['21:00', '22:00'],event2 = ['20:00', '21:00']) == True\n    assert candidate(event1 = ['19:00', '20:00'],event2 = ['20:00', '21:00']) == True\n    assert candidate(event1 = ['08:30', '09:15'],event2 = ['09:15', '10:00']) == True\n    assert candidate(event1 = ['06:00', '07:00'],event2 = ['07:00', '08:00']) == True\n    assert candidate(event1 = ['18:00', '19:00'],event2 = ['17:30', '18:30']) == True\n    assert candidate(event1 = ['01:00', '02:00'],event2 = ['02:01', '03:00']) == False\n    assert candidate(event1 = ['09:00', '10:00'],event2 = ['10:00', '11:00']) == True\n    assert candidate(event1 = ['00:00', '12:00'],event2 = ['12:00', '23:59']) == True\n    assert candidate(event1 = ['23:59', '00:01'],event2 = ['23:58', '00:00']) == False\n    assert candidate(event1 = ['00:01', '23:59'],event2 = ['23:59', '00:01']) == True\n    assert candidate(event1 = ['10:00', '10:30'],event2 = ['09:59', '10:01']) == True\n    assert candidate(event1 = ['00:00', '00:01'],event2 = ['00:01', '00:02']) == True\n    assert candidate(event1 = ['11:55', '12:05'],event2 = ['12:00', '12:10']) == True\n    assert candidate(event1 = ['12:34', '12:34'],event2 = ['12:34', '12:34']) == True\n", "comparison": "exact"}, "public_tests": ["[\"01:15\",\"02:00\"]\n[\"02:00\",\"03:00\"]", "[\"01:00\",\"02:00\"]\n[\"01:20\",\"03:00\"]", "[\"10:00\",\"11:00\"]\n[\"14:00\",\"15:00\"]"], "hints": ["Parse time format to some integer interval first", "How would you determine if two intervals overlap?"], "metadata": {"canonical_parameter_names": ["event1", "event2"], "leetcode_dataset_entry_point": "Solution().haveConflict", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:05+00:00", "tests_total": 109, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "string"]}, "language": "python", "interface": {"raw_signature": "def haveConflict(self, event1: list[str], event2: list[str]) -> bool:", "container": "Solution", "callable": "haveConflict", "parameters": [{"name": "event1", "type": "list[str]"}, {"name": "event2", "type": "list[str]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2447, "task_id": "number-of-subarrays-with-gcd-equal-to-k", "difficulty": "Medium", "problem_description": "Given an integer array nums and an integer k, return the number of subarrays of nums where the greatest common divisor of the subarray's elements is k.\n\nA subarray is a contiguous non-empty sequence of elements within an array.\n\nThe greatest common divisor of an array is the largest integer that evenly divides all the array elements.\n\nExample 1:\n\nInput: nums = [9,3,1,2,6,3], k = 3\nOutput: 4\nExplanation: The subarrays of nums where 3 is the greatest common divisor of all the subarray's elements are:\n- [9,3,1,2,6,3]\n- [9,3,1,2,6,3]\n- [9,3,1,2,6,3]\n- [9,3,1,2,6,3]\n\nExample 2:\n\nInput: nums = [4], k = 7\nOutput: 0\nExplanation: There are no subarrays of nums where 7 is the greatest common divisor of all the subarray's elements.\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 1 <= nums[i], k <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 11\n    assert candidate(nums = [7, 14, 21, 28, 35],k = 7) == 11\n    assert candidate(nums = [5, 10, 15, 20, 25],k = 5) == 11\n    assert candidate(nums = [9, 3, 1, 2, 6, 3],k = 3) == 4\n    assert candidate(nums = [2, 4, 6, 8, 10],k = 2) == 11\n    assert candidate(nums = [3, 9, 27, 81, 243],k = 3) == 5\n    assert candidate(nums = [11, 22, 33, 44, 55],k = 11) == 11\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 11\n    assert candidate(nums = [4],k = 7) == 0\n    assert candidate(nums = [3, 6, 9, 12, 15],k = 3) == 11\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40],k = 5) == 29\n    assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909],k = 101) == 37\n    assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],k = 101) == 46\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45],k = 5) == 37\n    assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39],k = 3) == 45\n    assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160],k = 8) == 191\n    assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72],k = 8) == 37\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 13) == 46\n    assert candidate(nums = [15, 45, 75, 105, 135, 165, 195, 225],k = 15) == 29\n    assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310, 341, 372, 403, 434, 465, 496, 527, 558, 589, 620],k = 31) == 191\n    assert candidate(nums = [15, 30, 45, 60, 75, 90],k = 15) == 16\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 13) == 46\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 5151\n    assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1110, 1221, 1332, 1443, 1554, 1665, 1776, 1887, 1998, 2109, 2220],k = 111) == 191\n    assert candidate(nums = [60, 120, 180, 240, 300],k = 60) == 11\n    assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072],k = 256) == 10\n    assert candidate(nums = [5, 15, 25, 35, 45, 55],k = 5) == 16\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],k = 2) == 301\n    assert candidate(nums = [54, 108, 162, 216, 270, 324, 378, 432, 486, 540, 594, 648, 702, 756, 810, 864, 918, 972, 1026, 1080],k = 54) == 191\n    assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 100) == 55\n    assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31],k = 1) == 45\n    assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153],k = 17) == 37\n    assert candidate(nums = [101, 202, 303, 404, 505, 606],k = 101) == 16\n    assert candidate(nums = [44, 88, 132, 176, 220, 264, 308, 352, 396, 440, 484, 528, 572, 616, 660, 704, 748, 792, 836, 880, 924, 968, 1012, 1056, 1100],k = 44) == 301\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104],k = 13) == 29\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 46\n    assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],k = 8) == 10\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 3) == 191\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49],k = 7) == 22\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 46\n    assert candidate(nums = [60, 120, 180, 240, 300],k = 60) == 11\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 1) == 300\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 7) == 46\n    assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294, 315, 336, 357, 378, 399, 420],k = 21) == 191\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 191\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 1) == 10\n    assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],k = 8) == 13\n    assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108],k = 12) == 37\n    assert candidate(nums = [15, 25, 35, 45, 55, 65],k = 5) == 15\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75],k = 5) == 29\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 2) == 46\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 3) == 106\n    assert candidate(nums = [987, 654, 321, 987, 654, 321, 987, 654, 321],k = 3) == 36\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121],k = 11) == 56\n    assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170],k = 17) == 46\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 2) == 106\n    assert candidate(nums = [81, 54, 27, 9, 3, 1],k = 3) == 5\n    assert candidate(nums = [36, 72, 108, 144, 180, 216, 252, 288, 324, 360],k = 36) == 46\n    assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540],k = 60) == 37\n    assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],k = 15) == 46\n    assert candidate(nums = [72, 96, 120, 144, 168, 192, 216, 240, 264, 288, 312, 336, 360, 384, 408],k = 24) == 105\n    assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 5) == 45\n    assert candidate(nums = [45, 90, 135, 180, 225, 270, 315, 360, 405, 450],k = 45) == 46\n    assert candidate(nums = [7, 14, 28, 56, 112],k = 7) == 5\n    assert candidate(nums = [77, 154, 231, 308, 385, 462, 539, 616, 693, 770, 847, 924, 1001, 1078, 1155, 1232, 1309, 1386, 1463, 1540],k = 77) == 191\n    assert candidate(nums = [36, 72, 108, 144, 180, 216, 252, 288, 324, 360],k = 36) == 46\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 46\n    assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],k = 21) == 46\n    assert candidate(nums = [123456789, 987654321, 111222333, 222333444, 333444555],k = 9) == 7\n    assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149],k = 1) == 45\n    assert candidate(nums = [6, 12, 18, 24, 30],k = 6) == 11\n    assert candidate(nums = [8, 12, 16, 20, 24, 28, 32],k = 4) == 21\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000],k = 1000) == 11\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 191\n    assert candidate(nums = [48, 64, 80, 96, 112, 128, 144, 160, 176, 192],k = 16) == 45\n    assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],k = 21) == 46\n    assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500],k = 25) == 191\n    assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170],k = 17) == 46\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 11) == 46\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 9) == 46\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 100) == 191\n    assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420],k = 42) == 46\n    assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024],k = 8) == 8\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 191\n    assert candidate(nums = [72, 48, 12, 18, 6, 120],k = 6) == 13\n    assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000],k = 1000000) == 11\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 191\n    assert candidate(nums = [7, 14, 28, 56, 112, 224],k = 7) == 6\n    assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336],k = 7) == 12\n    assert candidate(nums = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330, 363, 396, 429, 462, 495],k = 33) == 106\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000],k = 125000000) == 4\n    assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024],k = 8) == 8\n    assert candidate(nums = [12, 15, 21, 33, 48],k = 3) == 10\n    assert candidate(nums = [99, 198, 297, 396, 495, 594, 693, 792],k = 99) == 29\n    assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340],k = 17) == 191\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135],k = 9) == 106\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91],k = 13) == 22\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],k = 7) == 106\n    assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462],k = 42) == 56\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108],k = 9) == 67\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 2) == 1\n    assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48],k = 6) == 29\n    assert candidate(nums = [20, 40, 60, 80, 100, 120, 140],k = 20) == 22\n    assert candidate(nums = [18, 27, 36, 45, 54, 63, 72, 81, 90],k = 9) == 36\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 3) == 46\n    assert candidate(nums = [100, 200, 400, 800, 1600, 3200],k = 100) == 6\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 1) == 15\n    assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],k = 15) == 46\n    assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600],k = 60) == 46\n    assert candidate(nums = [101, 202, 303, 404, 505, 606, 707],k = 101) == 22\n    assert candidate(nums = [48, 64, 80, 96, 112, 128, 144, 160, 176, 192],k = 16) == 45\n    assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294, 315, 336, 357, 378, 399, 420],k = 21) == 191\n    assert candidate(nums = [21, 14, 42, 84, 28, 56, 112],k = 14) == 9\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 3) == 46\n    assert candidate(nums = [81, 27, 9, 3, 1],k = 1) == 5\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 2) == 46\n    assert candidate(nums = [100, 150, 200, 250, 300, 350],k = 50) == 15\n    assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60],k = 6) == 46\n    assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255],k = 17) == 106\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000],k = 62500000) == 5\n    assert candidate(nums = [123, 246, 369, 492, 615, 738, 861, 984, 1107, 1230, 1353, 1476, 1599, 1722, 1845, 1968, 2091, 2214, 2337, 2460],k = 123) == 191\n    assert candidate(nums = [999999937, 999999937, 999999937, 999999937, 999999937, 999999937, 999999937, 999999937, 999999937, 999999937],k = 999999937) == 55\n    assert candidate(nums = [81, 27, 9, 3, 1, 243, 729],k = 3) == 4\n", "comparison": "exact"}, "public_tests": ["[9,3,1,2,6,3]\n3", "[4]\n7"], "hints": ["The constraints on nums.length are small. It is possible to check every subarray.", "To calculate GCD, you can use a built-in function or the Euclidean Algorithm."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().subarrayGCD", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:07+00:00", "tests_total": 124, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "math", "number-theory"]}, "language": "python", "interface": {"raw_signature": "def subarrayGCD(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "subarrayGCD", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2448, "task_id": "minimum-cost-to-make-array-equal", "difficulty": "Hard", "problem_description": "You are given two 0-indexed arrays nums and cost consisting each of n positive integers.\n\nYou can do the following operation any number of times:\n\n- Increase or decrease any element of the array nums by 1.\n\nThe cost of doing one operation on the i^th element is cost[i].\n\nReturn the minimum total cost such that all the elements of the array nums become equal.\n\nExample 1:\n\nInput: nums = [1,3,5,2], cost = [2,3,1,14]\nOutput: 8\nExplanation: We can make all the elements equal to 2 in the following way:\n- Increase the 0^th element one time. The cost is 2.\n- Decrease the 1^st element one time. The cost is 3.\n- Decrease the 2^nd element three times. The cost is 1 + 1 + 1 = 3.\nThe total cost is 2 + 3 + 3 = 8.\nIt can be shown that we cannot make the array equal with a smaller cost.\n\nExample 2:\n\nInput: nums = [2,2,2,2,2], cost = [4,2,8,1,3]\nOutput: 0\nExplanation: All the elements are already equal, so no operations are needed.\n\nConstraints:\n\n- n == nums.length == cost.length\n- 1 <= n <= 10^5\n- 1 <= nums[i], cost[i] <= 10^6\n- Test cases are generated in a way that the output doesn't exceed 2^53-1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [6, 1, 3, 9, 3],cost = [2, 1, 2, 1, 2]) == 14\n    assert candidate(nums = [1, 3, 5, 2],cost = [2, 3, 1, 14]) == 8\n    assert candidate(nums = [2, 2, 2, 2, 2],cost = [4, 2, 8, 1, 3]) == 0\n    assert candidate(nums = [6, 1, 9],cost = [2, 5, 7]) == 46\n    assert candidate(nums = [1, 2, 3],cost = [1, 2, 3]) == 4\n    assert candidate(nums = [10, 1, 10],cost = [1, 100, 1]) == 18\n    assert candidate(nums = [6, 1, 9, 8, 2],cost = [4, 2, 8, 1, 3]) == 48\n    assert candidate(nums = [100000, 100000],cost = [1000000, 1000000]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5],cost = [10, 10, 10, 10, 10]) == 0\n    assert candidate(nums = [1, 2, 3],cost = [1, 1, 1]) == 2\n    assert candidate(nums = [10, 5, 15],cost = [1, 10, 1]) == 15\n    assert candidate(nums = [1, 2, 3],cost = [9, 3, 5]) == 13\n    assert candidate(nums = [100000, 1000000],cost = [100, 1]) == 900000\n    assert candidate(nums = [1000000, 1000000, 1000000, 1000000],cost = [1000000, 1000000, 1000000, 1000000]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n    assert candidate(nums = [100, 200, 300, 400, 500],cost = [5, 4, 3, 2, 1]) == 1500\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 0\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [5, 3, 8, 6, 2, 7],cost = [100, 200, 300, 400, 500, 600]) == 3900\n    assert candidate(nums = [9, 1, 4, 7, 3],cost = [100, 10, 1000, 10000, 100000]) == 41620\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 82\n    assert candidate(nums = [5, 3, 8, 1, 9],cost = [10, 20, 30, 40, 50]) == 460\n    assert candidate(nums = [5, 4, 3, 2, 1],cost = [1, 2, 3, 4, 5]) == 15\n    assert candidate(nums = [5, 5, 5, 5, 5],cost = [1000000, 1000000, 1000000, 1000000, 1000000]) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 250\n    assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995],cost = [1, 2, 3, 4, 5, 6]) == 26\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],cost = [3, 2, 1, 1, 2, 3, 3, 2, 1]) == 12\n    assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 112\n    assert candidate(nums = [1, 5, 10, 15, 20],cost = [5, 1, 10, 1, 5]) == 105\n    assert candidate(nums = [1, 2, 3, 4, 5],cost = [1, 1, 1, 1, 1000000]) == 10\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000],cost = [5, 5, 5, 5, 5]) == 30000\n    assert candidate(nums = [1, 5, 7, 9, 11],cost = [1, 10, 100, 1000, 10000]) == 2470\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 29\n    assert candidate(nums = [1, 1, 1, 1, 1],cost = [1000000, 1000000, 1000000, 1000000, 1000000]) == 0\n    assert candidate(nums = [50000, 50000, 50000, 50000, 50000],cost = [1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 25\n    assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],cost = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000]) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],cost = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == 49999750\n    assert candidate(nums = [9, 1, 4, 6, 2],cost = [5, 3, 8, 6, 7]) == 60\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],cost = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 390\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 112000\n    assert candidate(nums = [500000, 500000, 500000, 500000, 500000],cost = [1, 2, 3, 4, 5]) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9],cost = [1, 2, 3, 4, 5]) == 30\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],cost = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 5600\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 102\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000],cost = [999, 888, 777, 666, 555]) == 4662000\n    assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],cost = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 11200\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 50\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 12\n    assert candidate(nums = [999999, 1000000, 999998],cost = [10, 1, 1]) == 2\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 112\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums = [100, 150, 200, 250, 300],cost = [1, 2, 3, 4, 5]) == 750\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 5],cost = [1, 1, 1, 1, 1, 1, 1]) == 8\n    assert candidate(nums = [50, 40, 30, 20, 10],cost = [1, 2, 3, 4, 5]) == 150\n    assert candidate(nums = [10, 20, 30, 40, 50],cost = [1, 2, 3, 4, 5]) == 150\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 112\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n    assert candidate(nums = [5, 4, 3, 2, 1],cost = [1, 2, 3, 4, 5]) == 15\n    assert candidate(nums = [3, 1, 2],cost = [5, 10, 15]) == 15\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 200\n    assert candidate(nums = [1, 2, 2, 3, 4, 5],cost = [1, 1000, 1000, 100, 1, 1]) == 106\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 2500\n    assert candidate(nums = [5, 3, 8, 6, 7],cost = [2, 5, 3, 7, 4]) == 27\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1120\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 112000\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 50\n    assert candidate(nums = [1, 3, 5, 2, 4],cost = [2, 3, 1, 14, 5]) == 18\n    assert candidate(nums = [9, 1, 5, 3, 7, 6],cost = [10, 1, 5, 2, 8, 3]) == 47\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 2767\n    assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 25\n    assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],cost = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 5\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],cost = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 840\n    assert candidate(nums = [123456, 123456, 123456, 123456],cost = [100000, 200000, 300000, 400000]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5],cost = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5]) == 40\n    assert candidate(nums = [1, 100000, 50000, 75000, 25000],cost = [1000, 1, 100, 10, 100]) == 8349789\n    assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000]) == 45\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 720\n    assert candidate(nums = [1, 1000000, 500000],cost = [1000000, 1, 1]) == 1499998\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1120\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1120\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],cost = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 840\n    assert candidate(nums = [7, 7, 7, 7, 7, 7],cost = [1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],cost = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 101009989899\n    assert candidate(nums = [10, 10, 10, 10, 10, 10],cost = [1, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 50\n    assert candidate(nums = [100, 200, 300, 400, 500],cost = [10, 20, 30, 40, 50]) == 15000\n    assert candidate(nums = [100000, 50000, 25000, 12500, 6250],cost = [1, 2, 4, 8, 16]) == 306250\n    assert candidate(nums = [5, 7, 3, 10, 8],cost = [1, 5, 7, 2, 6]) == 42\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11200\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 50\n    assert candidate(nums = [1000000, 1, 1000000, 1, 1000000],cost = [1, 1000000, 1, 1000000, 1]) == 2999997\n    assert candidate(nums = [5, 3, 8, 10, 1],cost = [1, 2, 3, 4, 5]) == 53\n    assert candidate(nums = [123456, 654321, 111111, 222222, 333333],cost = [1000, 2000, 3000, 4000, 5000]) == 1851852000\n    assert candidate(nums = [10, 20, 30, 40, 50],cost = [10, 20, 30, 40, 50]) == 1500\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 448\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 112\n    assert candidate(nums = [1, 5, 9, 13, 17],cost = [10, 20, 30, 40, 50]) == 600\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cost = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],cost = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n    assert candidate(nums = [1, 1000000],cost = [100000, 1]) == 999999\n    assert candidate(nums = [1, 10, 100, 1000, 10000],cost = [10000, 1000, 100, 10, 1]) == 38889\n", "comparison": "exact"}, "public_tests": ["[1,3,5,2]\n[2,3,1,14]", "[2,2,2,2,2]\n[4,2,8,1,3]"], "hints": ["Changing the elements into one of the numbers already existing in the array nums is optimal.", "Try finding the cost of changing the array into each element, and return the minimum value."], "metadata": {"canonical_parameter_names": ["nums", "cost"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:10+00:00", "tests_total": 109, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "binary-search", "greedy", "sorting", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minCost(self, nums: list[int], cost: list[int]) -> int:", "container": "Solution", "callable": "minCost", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "cost", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2449, "task_id": "minimum-number-of-operations-to-make-arrays-similar", "difficulty": "Hard", "problem_description": "You are given two positive integer arrays nums and target, of the same length.\n\nIn one operation, you can choose any two distinct indices i and j where 0 <= i, j < nums.length and:\n\n- set nums[i] = nums[i] + 2 and\n- set nums[j] = nums[j] - 2.\n\nTwo arrays are considered to be similar if the frequency of each element is the same.\n\nReturn the minimum number of operations required to make nums similar to target. The test cases are generated such that nums can always be similar to target.\n\nExample 1:\n\nInput: nums = [8,12,6], target = [2,14,10]\nOutput: 2\nExplanation: It is possible to make nums similar to target in two operations:\n- Choose i = 0 and j = 2, nums = [10,12,4].\n- Choose i = 1 and j = 2, nums = [10,14,2].\nIt can be shown that 2 is the minimum number of operations needed.\n\nExample 2:\n\nInput: nums = [1,2,5], target = [4,1,3]\nOutput: 1\nExplanation: We can make nums similar to target in one operation:\n- Choose i = 1 and j = 2, nums = [1,4,3].\n\nExample 3:\n\nInput: nums = [1,1,1,1,1], target = [1,1,1,1,1]\nOutput: 0\nExplanation: The array nums is already similiar to target.\n\nConstraints:\n\n- n == nums.length == target.length\n- 1 <= n <= 10^5\n- 1 <= nums[i], target[i] <= 10^6\n- It is possible to make nums similar to target.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [3, 3, 3, 3],target = [1, 5, 1, 5]) == 2\n    assert candidate(nums = [1, 1, 1, 1, 1],target = [1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [3, 3, 3, 3],target = [5, 1, 5, 1]) == 2\n    assert candidate(nums = [100000, 50000, 10000],target = [10000, 50000, 100000]) == 0\n    assert candidate(nums = [1000000, 500000, 250000],target = [500000, 250000, 125000]) == 218750\n    assert candidate(nums = [4, 6, 8],target = [2, 6, 10]) == 1\n    assert candidate(nums = [8, 12, 6],target = [2, 14, 10]) == 2\n    assert candidate(nums = [1000000, 500000, 250000],target = [125000, 375000, 875000]) == 93750\n    assert candidate(nums = [4, 6, 8],target = [2, 4, 6]) == 1\n    assert candidate(nums = [1, 2, 5],target = [4, 1, 3]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50],target = [5, 15, 25, 35, 45]) == 6\n    assert candidate(nums = [1, 3, 5, 7, 9],target = [2, 4, 6, 8, 10]) == 1\n    assert candidate(nums = [2, 4, 6, 8],target = [8, 6, 4, 2]) == 0\n    assert candidate(nums = [2, 6, 10, 14, 18],target = [4, 8, 12, 16, 20]) == 2\n    assert candidate(nums = [1000000, 500000, 250000, 125000, 62500],target = [62500, 125000, 250000, 500000, 1000000]) == 0\n    assert candidate(nums = [100, 200, 300, 400, 500],target = [150, 250, 350, 450, 550]) == 62\n    assert candidate(nums = [10, 20, 30, 40, 50, 60],target = [5, 15, 25, 35, 45, 55]) == 7\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]) == 12\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],target = [500, 1500, 2500, 3500, 4500, 5500, 6500, 7500, 8500, 9500]) == 1250\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums = [3, 7, 11, 15, 19, 23],target = [5, 9, 13, 17, 21, 25]) == 3\n    assert candidate(nums = [9, 11, 13, 15, 17, 19, 21, 23],target = [7, 13, 19, 25, 31, 37, 43, 49]) == 25\n    assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],target = [1010, 909, 808, 707, 606, 505, 404, 303, 202, 101]) == 0\n    assert candidate(nums = [11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = [9, 11, 13, 15, 17, 19, 21, 23, 25, 27]) == 5\n    assert candidate(nums = [101, 202, 303, 404, 505],target = [103, 204, 305, 406, 507]) == 2\n    assert candidate(nums = [1000000, 999998, 999996, 999994, 999992],target = [999999, 999997, 999995, 999993, 999991]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 12\n    assert candidate(nums = [3, 7, 11, 13, 17],target = [5, 9, 15, 19, 23]) == 5\n    assert candidate(nums = [2, 4, 6, 8, 10],target = [1, 3, 5, 7, 9]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 12\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n    assert candidate(nums = [5, 12, 18, 24, 30, 36],target = [3, 15, 21, 27, 33, 39]) == 13\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700],target = [50, 150, 250, 350, 450, 550, 650]) == 87\n    assert candidate(nums = [9, 7, 5, 3, 1],target = [2, 4, 6, 8, 10]) == 1\n    assert candidate(nums = [100000, 200000, 300000, 400000, 500000],target = [50000, 150000, 250000, 350000, 450000]) == 62500\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == 20\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38],target = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == 5\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = [1, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 2\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = [99, 199, 299, 399, 499, 599, 699, 799, 899, 999]) == 2\n    assert candidate(nums = [1, 5, 9, 13, 17, 21],target = [3, 7, 11, 15, 19, 23]) == 3\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],target = [1, 9, 17, 25, 33, 41, 49, 57, 65, 73]) == 58\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],target = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63]) == 45\n    assert candidate(nums = [2, 4, 6, 8, 10, 12],target = [1, 5, 7, 9, 11, 13]) == 1\n    assert candidate(nums = [100, 200, 300, 400, 500],target = [98, 198, 298, 398, 498]) == 2\n    assert candidate(nums = [11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = [10, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 2\n    assert candidate(nums = [11, 21, 31, 41, 51, 61],target = [9, 19, 29, 39, 49, 59]) == 3\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],target = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38]) == 2\n    assert candidate(nums = [2, 4, 6, 8, 10],target = [1, 3, 5, 7, 9]) == 1\n    assert candidate(nums = [8, 16, 24, 32, 40, 48],target = [14, 22, 30, 38, 46, 54]) == 9\n    assert candidate(nums = [1, 3, 5, 7, 9, 11],target = [2, 4, 6, 8, 10, 12]) == 1\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27],target = [5, 8, 11, 14, 17, 20, 23, 26, 29]) == 4\n    assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1563],target = [1562, 3125, 6250, 12500, 25000, 50000, 100000]) == 49218\n    assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22],target = [3, 6, 9, 12, 15, 18, 21, 24]) == 4\n    assert candidate(nums = [2, 4, 6, 8, 10, 12],target = [1, 3, 5, 7, 9, 11]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],target = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums = [1000000, 999998, 999996, 999994, 999992, 999990, 999988, 999986, 999984, 999982],target = [999999, 999997, 999995, 999993, 999991, 999989, 999987, 999985, 999983, 999981]) == 2\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n    assert candidate(nums = [99, 97, 95, 93, 91, 89, 87],target = [101, 99, 97, 95, 93, 91, 89]) == 3\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 12\n    assert candidate(nums = [5, 5, 5, 5, 5, 10, 10, 10, 10, 10],target = [10, 10, 10, 10, 10, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],target = [2, 4, 6, 8, 10, 12, 14, 16]) == 2\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],target = [100001, 100003, 100005, 100007, 100009, 100011, 100013, 100015, 100017, 100019]) == 36\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],target = [2, 4, 6, 8, 10, 12, 14]) == 1\n    assert candidate(nums = [2, 4, 6, 8, 10],target = [10, 8, 6, 4, 2]) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145]) == 18\n    assert candidate(nums = [2, 6, 18, 34, 50],target = [1, 5, 17, 33, 49]) == 1\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],target = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550, 1650, 1750, 1850, 1950]) == 250\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],target = [3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73]) == 7\n    assert candidate(nums = [1, 1, 3, 3, 5, 5, 7, 7],target = [2, 2, 4, 4, 6, 6, 8, 8]) == 2\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],target = [3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73, 78, 83, 88, 93, 98]) == 10\n    assert candidate(nums = [1000, 2000, 3000, 4000, 5000],target = [1500, 2500, 3500, 4500, 5500]) == 625\n    assert candidate(nums = [9, 7, 5, 3, 1],target = [10, 8, 6, 4, 2]) == 1\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 3\n    assert candidate(nums = [11, 17, 23, 29, 31],target = [13, 19, 25, 27, 37]) == 3\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],target = [31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 95\n    assert candidate(nums = [3, 5, 7, 9, 11, 13, 15],target = [2, 4, 6, 8, 10, 12, 14]) == 1\n    assert candidate(nums = [100, 200, 300, 400, 500, 600],target = [150, 250, 350, 450, 550, 650]) == 75\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99],target = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 53\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99],target = [9, 19, 29, 39, 49, 59, 69, 79, 89]) == 53\n    assert candidate(nums = [99, 97, 95, 93, 91, 89, 87, 85, 83, 81],target = [101, 103, 105, 107, 109, 111, 113, 115, 117, 119]) == 50\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],target = [2, 4, 6, 8, 10, 12, 14, 16]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 3\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = [4, 9, 14, 19, 24, 29, 34, 39, 44, 49]) == 12\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n    assert candidate(nums = [4, 8, 12, 16, 20, 24, 28],target = [2, 6, 10, 14, 18, 22, 26]) == 3\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],target = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125]) == 15\n    assert candidate(nums = [5, 10, 15, 20, 25, 30],target = [1, 6, 11, 16, 21, 26]) == 6\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63],target = [15, 24, 33, 42, 51, 60, 69]) == 10\n    assert candidate(nums = [3, 6, 9, 12, 15, 18],target = [2, 7, 10, 13, 16, 19]) == 5\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],target = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78]) == 5\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 3\n    assert candidate(nums = [3, 5, 7, 9],target = [1, 7, 11, 13]) == 3\n    assert candidate(nums = [100, 200, 300, 400, 500],target = [50, 150, 250, 350, 450]) == 62\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 2\n    assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],target = [1, 3, 7, 15, 30, 61, 122, 244, 488, 976, 1953, 3906, 7812, 15625, 31250, 62500, 125000, 250000, 500000, 1000000]) == 0\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == 4\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 0\n    assert candidate(nums = [2, 3, 5, 7, 11, 13],target = [1, 4, 6, 8, 10, 12]) == 6\n", "comparison": "exact"}, "public_tests": ["[8,12,6]\n[2,14,10]", "[1,2,5]\n[4,1,3]", "[1,1,1,1,1]\n[1,1,1,1,1]"], "hints": ["Solve for even and odd numbers separately.", "Greedily match smallest even element from nums to smallest even element from target, then similarly next smallest element and so on.", "Similarly, match odd elements too."], "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().makeSimilar", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:12+00:00", "tests_total": 107, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def makeSimilar(self, nums: list[int], target: list[int]) -> int:", "container": "Solution", "callable": "makeSimilar", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "target", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2451, "task_id": "odd-string-difference", "difficulty": "Easy", "problem_description": "You are given an array of equal-length strings words. Assume that the length of each string is n.\n\nEach string words[i] can be converted into a difference integer array difference[i] of length n - 1 where difference[i][j] = words[i][j+1] - words[i][j] where 0 <= j <= n - 2. Note that the difference between two letters is the difference between their positions in the alphabet i.e. the position of 'a' is 0, 'b' is 1, and 'z' is 25.\n\n- For example, for the string \"acb\", the difference integer array is [2 - 0, 1 - 2] = [2, -1].\n\nAll the strings in words have the same difference integer array, except one. You should find that string.\n\nReturn the string in words that has different difference integer array.\n\nExample 1:\n\nInput: words = [\"adc\",\"wzy\",\"abc\"]\nOutput: \"abc\"\nExplanation:\n- The difference integer array of \"adc\" is [3 - 0, 2 - 3] = [3, -1].\n- The difference integer array of \"wzy\" is [25 - 22, 24 - 25]= [3, -1].\n- The difference integer array of \"abc\" is [1 - 0, 2 - 1] = [1, 1].\nThe odd array out is [1, 1], so we return the corresponding string, \"abc\".\n\nExample 2:\n\nInput: words = [\"aaa\",\"bob\",\"ccc\",\"ddd\"]\nOutput: \"bob\"\nExplanation: All the integer arrays are [0, 0] except for \"bob\", which corresponds to [13, -13].\n\nConstraints:\n\n- 3 <= words.length <= 100\n- n == words[i].length\n- 2 <= n <= 20\n- words[i] consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(words = ['adc', 'wzy', 'abc']) == \"abc\"\n    assert candidate(words = ['zzz', 'zyx', 'zwy', 'zvx']) == \"zzz\"\n    assert candidate(words = ['zzz', 'zyz', 'zxz', 'wyz']) == \"zzz\"\n    assert candidate(words = ['aaa', 'bob', 'ccc', 'ddd']) == \"bob\"\n    assert candidate(words = ['aab', 'aac', 'aad', 'abe']) == \"aab\"\n    assert candidate(words = ['xyz', 'abc', 'uvw', 'aaa']) == \"aaa\"\n    assert candidate(words = ['aaa', 'aaa', 'aab', 'aaa']) == \"aab\"\n    assert candidate(words = ['zzz', 'aaa', 'zzz', 'aaa', 'zzz', 'aab']) == \"aab\"\n    assert candidate(words = ['xyz', 'uvw', 'rst', 'qpo']) == \"qpo\"\n    assert candidate(words = ['aab', 'aac', 'aba', 'aaa']) == \"aab\"\n    assert candidate(words = ['qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'cba', 'bac']) == \"yza\"\n    assert candidate(words = ['qrst', 'qrsu', 'rstv', 'rstw']) == \"qrst\"\n    assert candidate(words = ['qrst', 'qrst', 'qrst', 'qrsu', 'qrst']) == \"qrsu\"\n    assert candidate(words = ['abc', 'bcd', 'cde', 'ade']) == \"ade\"\n    assert candidate(words = ['aab', 'aac', 'aba', 'aaa', 'aab', 'aac', 'aba', 'aac', 'aba', 'aab', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba', 'aac', 'aba']) == \"aaa\"\n    assert candidate(words = ['abc', 'bcd', 'cde', 'bce']) == \"bce\"\n    assert candidate(words = ['qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza']) == \"yza\"\n    assert candidate(words = ['abc', 'bde', 'cef', 'dfg', 'efh', 'fij', 'gjk', 'hkl', 'ilm', 'jmn', 'kno', 'lop', 'mqr', 'nrs', 'ots', 'puv', 'qvw', 'rxy', 'syz', 'tza', 'uab', 'vbc', 'wcd', 'xey', 'yfz', 'zga']) == \"abc\"\n    assert candidate(words = ['mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'abc', 'bcd', 'cde']) == \"yza\"\n    assert candidate(words = ['uvw', 'vwx', 'wxy', 'vxz', 'wyz']) == \"vxz\"\n    assert candidate(words = ['xyz', 'wxy', 'vwx', 'uvw', 'tuv', 'stu', 'rst', 'qrs', 'pqr', 'opq', 'nop', 'mno', 'lnm', 'klj', 'ijk', 'hgf', 'fed', 'edc', 'dcb', 'cba', 'bca', 'cab', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'bac']) == \"lnm\"\n    assert candidate(words = ['pqr', 'qrs', 'rst', 'uvw', 'vwx', 'wxy', 'xyz', 'xya']) == \"xya\"\n    assert candidate(words = ['abcdefg', 'abcdefh', 'abcdefi', 'abcdefj', 'abcdefg']) == \"abcdefh\"\n    assert candidate(words = ['aaa', 'abb', 'acc', 'add', 'aee', 'aff', 'agg', 'aeh', 'aei', 'aej', 'aek', 'ael', 'aem', 'aen', 'aeo', 'aep', 'aeq', 'aer', 'aes', 'aet', 'aeu', 'aev', 'aew', 'aex', 'aey', 'aez', 'afa', 'afb', 'afc', 'afd', 'afe', 'aff', 'afg', 'afh']) == \"aaa\"\n    assert candidate(words = ['xyz', 'xza', 'ywb', 'ywa']) == \"xyz\"\n    assert candidate(words = ['zzz', 'zzy', 'zzx', 'zzw', 'zzv']) == \"zzz\"\n    assert candidate(words = ['mnop', 'nqpo', 'opqr', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwz', 'vwxy', 'wxza', 'xyzb', 'yzca', 'zcab', 'cabc', 'abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrt', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwz', 'vwxy', 'wxza', 'xyzb', 'yzca', 'zcab', 'cabc', 'abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno']) == \"nqpo\"\n    assert candidate(words = ['abc', 'bcd', 'cde', 'def', 'geh', 'hif', 'iji', 'jik']) == \"geh\"\n    assert candidate(words = ['qwert', 'wertr', 'ertty', 'rtyui', 'tyuio']) == \"qwert\"\n    assert candidate(words = ['aaa', 'aab', 'aac', 'aad', 'zaa']) == \"aaa\"\n    assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzza']) == \"zzzzzzzzza\"\n    assert candidate(words = ['zzz', 'zyz', 'xyx', 'wxw', 'vuq', 'tsr']) == \"zzz\"\n    assert candidate(words = ['mnop', 'mnoq', 'mnop', 'mnoo', 'mnop']) == \"mnoq\"\n    assert candidate(words = ['mno', 'nop', 'opo', 'npp', 'mqq']) == \"opo\"\n    assert candidate(words = ['aaa', 'aba', 'aca', 'ada', 'aea', 'afa', 'aga', 'aha']) == \"aaa\"\n    assert candidate(words = ['mnopqr', 'mnopqs', 'mnopqt', 'mnopqu', 'mnopqv']) == \"mnopqr\"\n    assert candidate(words = ['qwe', 'rft', 'sgh', 'tij', 'ukl', 'vmo']) == \"qwe\"\n    assert candidate(words = ['abcdef', 'abcefg', 'abcdgg', 'abcdef', 'abcdeg']) == \"abcefg\"\n    assert candidate(words = ['abz', 'bca', 'cab', 'bac', 'acb', 'baa', 'aaa', 'aab']) == \"abz\"\n    assert candidate(words = ['abz', 'bca', 'cab', 'abc']) == \"abz\"\n    assert candidate(words = ['aaa', 'aab', 'aac', 'aad', 'aae', 'aaf', 'aag', 'aah', 'aai', 'aaj', 'aak', 'aal', 'aam', 'aan', 'aao', 'aap', 'aaq', 'aar', 'aas', 'aat', 'aau', 'aav', 'aaw', 'aax', 'aay', 'aaz', 'abb', 'abc']) == \"aaa\"\n    assert candidate(words = ['aab', 'aac', 'aab', 'aac', 'aab', 'aac', 'aad', 'aac']) == \"aad\"\n    assert candidate(words = ['zzz', 'zyz', 'zyx', 'zzx', 'zyw']) == \"zzz\"\n    assert candidate(words = ['uvw', 'uvx', 'uwy', 'uxz']) == \"uvw\"\n    assert candidate(words = ['mnop', 'nqpr', 'opqs', 'pqrt']) == \"mnop\"\n    assert candidate(words = ['zzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzza']) == \"zzzzzzzzzzzzzzzzzzza\"\n    assert candidate(words = ['xyz', 'yza', 'zab', 'xba', 'xza']) == \"xyz\"\n    assert candidate(words = ['abc', 'bcd', 'cde', 'def', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza']) == \"yza\"\n    assert candidate(words = ['mnop', 'mnoq', 'mnop', 'mnop']) == \"mnoq\"\n    assert candidate(words = ['pqr', 'qrs', 'rst', 'qst', 'qrt']) == \"qst\"\n    assert candidate(words = ['aaa', 'aba', 'aca', 'ada', 'aea']) == \"aaa\"\n    assert candidate(words = ['aaa', 'aab', 'aba', 'aca', 'baa']) == \"aaa\"\n    assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'aefghi']) == \"aefghi\"\n    assert candidate(words = ['xyz', 'yza', 'zab', 'abc']) == \"yza\"\n    assert candidate(words = ['xyz', 'xwv', 'xut', 'xsr']) == \"xyz\"\n    assert candidate(words = ['uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'aaa', 'aab', 'aac', 'aad', 'abe', 'acd']) == \"aaa\"\n    assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij', 'fghijk', 'ghijkl', 'hijklm', 'ijklmn', 'jklmno', 'klmnop', 'lmnopq', 'mnopqr', 'nopqrs', 'opqrst', 'pqrstu', 'qrstuv', 'rstuvw', 'stuvwx', 'tuvwxy', 'uvwxyx', 'vwxyxw', 'wxyxwy', 'xyxwyx', 'yxwyxy']) == \"uvwxyx\"\n    assert candidate(words = ['aaaab', 'aaaba', 'aabaa', 'abaaa', 'baaaa']) == \"aaaab\"\n    assert candidate(words = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'aaa', 'aab', 'aac', 'aad', 'abe']) == \"yza\"\n    assert candidate(words = ['zzz', 'zzy', 'zyz', 'yzz', 'zyx', 'yxz', 'xzy', 'xyz', 'yxw', 'xyw', 'xwy', 'ywx', 'wxy', 'wyz', 'xzy', 'xyz', 'xwy', 'ywx', 'wxy', 'wyz', 'xzy', 'xyz', 'xwy', 'ywx']) == \"zzz\"\n    assert candidate(words = ['mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyx', 'yzy', 'zzz', 'yzy', 'xyx', 'vwx', 'uvw', 'tuv', 'stu', 'qrs', 'pqr', 'opq', 'nop', 'mno', 'zyz', 'zzz']) == \"zyz\"\n    assert candidate(words = ['zzz', 'aaa', 'aab', 'aac', 'aad']) == \"aab\"\n    assert candidate(words = ['xyz', 'yza', 'zab', 'cab', 'bcd']) == \"yza\"\n    assert candidate(words = ['pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'aba', 'bab', 'bba', 'aab', 'aaa', 'aab', 'aba', 'abb', 'abc']) == \"yza\"\n    assert candidate(words = ['zzz', 'yyy', 'xxz', 'xxy']) == \"xxz\"\n    assert candidate(words = ['xyz', 'xza', 'xya', 'xwa']) == \"xyz\"\n    assert candidate(words = ['ghi', 'hij', 'ijk', 'jkl', 'gij']) == \"gij\"\n    assert candidate(words = ['pqr', 'qrs', 'rst', 'str']) == \"str\"\n    assert candidate(words = ['zxy', 'zyx', 'yxz', 'yzy']) == \"zxy\"\n    assert candidate(words = ['abcd', 'abce', 'abcf', 'abcd', 'abcg']) == \"abce\"\n    assert candidate(words = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab', 'cab', 'bca', 'abc', 'bca', 'cab', 'bac', 'acb', 'baa', 'aaa', 'aab', 'aac', 'aad', 'aba', 'abb', 'abc', 'aca', 'acb', 'acc']) == \"yza\"\n    assert candidate(words = ['apple', 'applf', 'applg', 'applh']) == \"apple\"\n    assert candidate(words = ['zzz', 'yyz', 'xxz', 'wwz', 'vvz', 'uuz', 'ttz', 'ssz', 'rrz', 'qqz', 'ppz', 'opo', 'ono', 'nnm', 'nml', 'nkl', 'nlj', 'nik', 'ihj', 'igh', 'ifh', 'ieh', 'idh', 'ich', 'ibh', 'iah', 'azg', 'azy', 'ayx', 'axw', 'avv', 'auu', 'att', 'ass', 'arr', 'aqq', 'app', 'aoo', 'ano', 'aml', 'akl', 'ajk', 'aik', 'aih', 'aig', 'aif', 'aie', 'aid', 'aic', 'abh', 'aag', 'aaf', 'aae', 'aad', 'aac', 'aab']) == \"zzz\"\n    assert candidate(words = ['qwe', 'rty', 'uio', 'pas', 'qdf']) == \"qwe\"\n    assert candidate(words = ['aab', 'aac', 'aad', 'abe', 'bbf', 'ccg', 'ddd']) == \"aab\"\n", "comparison": "exact"}, "public_tests": ["[\"adc\",\"wzy\",\"abc\"]", "[\"aaa\",\"bob\",\"ccc\",\"ddd\"]"], "hints": ["Find the difference integer array for each string.", "Compare them to find the odd one out."], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().oddString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:17+00:00", "tests_total": 80, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def oddString(self, words: list[str]) -> str:", "container": "Solution", "callable": "oddString", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2452, "task_id": "words-within-two-edits-of-dictionary", "difficulty": "Medium", "problem_description": "You are given two string arrays, queries and dictionary. All words in each array comprise of lowercase English letters and have the same length.\n\nIn one edit you can take a word from queries, and change any letter in it to any other letter. Find all words from queries that, after a maximum of two edits, equal some word from dictionary.\n\nReturn a list of all words from queries, that match with some word from dictionary after a maximum of two edits. Return the words in the same order they appear in queries.\n\nExample 1:\n\nInput: queries = [\"word\",\"note\",\"ants\",\"wood\"], dictionary = [\"wood\",\"joke\",\"moat\"]\nOutput: [\"word\",\"note\",\"wood\"]\nExplanation:\n- Changing the 'r' in \"word\" to 'o' allows it to equal the dictionary word \"wood\".\n- Changing the 'n' to 'j' and the 't' to 'k' in \"note\" changes it to \"joke\".\n- It would take more than 2 edits for \"ants\" to equal a dictionary word.\n- \"wood\" can remain unchanged (0 edits) and match the corresponding dictionary word.\nThus, we return [\"word\",\"note\",\"wood\"].\n\nExample 2:\n\nInput: queries = [\"yes\"], dictionary = [\"not\"]\nOutput: []\nExplanation:\nApplying any two edits to \"yes\" cannot make it equal to \"not\". Thus, we return an empty array.\n\nConstraints:\n\n- 1 <= queries.length, dictionary.length <= 100\n- n == queries[i].length == dictionary[j].length\n- 1 <= n <= 100\n- All queries[i] and dictionary[j] are composed of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(queries = ['test', 'text', 'sett'],dictionary = ['test', 'text', 'sett', 'best']) == ['test', 'text', 'sett']\n    assert candidate(queries = ['abc', 'bcd', 'cde'],dictionary = ['xyz', 'zyx', 'abc']) == ['abc']\n    assert candidate(queries = ['apple', 'apply'],dictionary = ['appla', 'apple', 'apply']) == ['apple', 'apply']\n    assert candidate(queries = ['test', 'text', 'sett'],dictionary = ['text', 'test', 'sett', 'best']) == ['test', 'text', 'sett']\n    assert candidate(queries = ['hello', 'world'],dictionary = ['hallo', 'wurld', 'holdo']) == ['hello', 'world']\n    assert candidate(queries = ['word', 'note', 'ants', 'wood'],dictionary = ['wood', 'joke', 'moat']) == ['word', 'note', 'wood']\n    assert candidate(queries = ['test', 'sett', 'best'],dictionary = ['rest', 'test', 'best']) == ['test', 'sett', 'best']\n    assert candidate(queries = ['abcd', 'abce', 'abcf'],dictionary = ['abef', 'abcf', 'abcd']) == ['abcd', 'abce', 'abcf']\n    assert candidate(queries = ['apple', 'apply', 'spoil'],dictionary = ['appla', 'appie', 'spoil']) == ['apple', 'apply', 'spoil']\n    assert candidate(queries = ['hello', 'world'],dictionary = ['hallo', 'werld']) == ['hello', 'world']\n    assert candidate(queries = ['apple', 'apply', 'happy'],dictionary = ['pally', 'apple', 'happy']) == ['apple', 'apply', 'happy']\n    assert candidate(queries = ['test', 'text', 'sett'],dictionary = ['best', 'text', 'west']) == ['test', 'text', 'sett']\n    assert candidate(queries = ['apple', 'apply'],dictionary = ['spale', 'spaly']) == ['apple', 'apply']\n    assert candidate(queries = ['aabb', 'abab', 'baba'],dictionary = ['aaaa', 'bbbb', 'abab']) == ['aabb', 'abab', 'baba']\n    assert candidate(queries = ['yes'],dictionary = ['not']) == []\n    assert candidate(queries = ['test'],dictionary = ['tast', 'test', 'sett']) == ['test']\n    assert candidate(queries = ['banana', 'bananb', 'bananc'],dictionary = ['banana', 'bananb', 'bananc', 'banand']) == ['banana', 'bananb', 'bananc']\n    assert candidate(queries = ['abcdefgh', 'abcdefgh'],dictionary = ['abcdefgh', 'abcdefgh', 'abcdefgh']) == ['abcdefgh', 'abcdefgh']\n    assert candidate(queries = ['abcdefghij', 'klmnopqrst'],dictionary = ['abcdeffhij', 'klmnopqrts', 'abcdefghij']) == ['abcdefghij', 'klmnopqrst']\n    assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr'],dictionary = ['abcdeg', 'ghijkm', 'mnopqs']) == ['abcdef', 'ghijkl', 'mnopqr']\n    assert candidate(queries = ['abcd', 'abce', 'abcf'],dictionary = ['abcf', 'abcg', 'abcd', 'abch']) == ['abcd', 'abce', 'abcf']\n    assert candidate(queries = ['abcdefghij', 'jihgfedcba'],dictionary = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'jihgfedcba', 'abcdefghij']) == ['abcdefghij', 'jihgfedcba']\n    assert candidate(queries = ['abcd', 'abdc', 'acbd', 'acdb'],dictionary = ['abcd', 'abdc', 'acbd', 'acdb', 'dcba', 'bdca']) == ['abcd', 'abdc', 'acbd', 'acdb']\n    assert candidate(queries = ['abcdefghij', 'abcdefghij', 'abcdefghij'],dictionary = ['abcdefghij', 'abcdefghik', 'abcdefghil', 'abcdefghim', 'abcdefghin']) == ['abcdefghij', 'abcdefghij', 'abcdefghij']\n    assert candidate(queries = ['abcdef', 'ghijkl'],dictionary = ['abchef', 'ghijkl', 'abcdeg', 'ghijkl', 'abcfeg']) == ['abcdef', 'ghijkl']\n    assert candidate(queries = ['abcdefghij', 'jihgfedcba'],dictionary = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'jihgfedcba']) == ['abcdefghij', 'jihgfedcba']\n    assert candidate(queries = ['abcdefghij', 'jihgfedcba'],dictionary = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'abcdefghij']) == ['abcdefghij', 'jihgfedcba']\n    assert candidate(queries = ['abcdefgh', 'abceghij', 'abcdefij'],dictionary = ['abcdefgh', 'abceghij', 'abcdefij', 'abcdefgj']) == ['abcdefgh', 'abceghij', 'abcdefij']\n    assert candidate(queries = ['abcde', 'edcba', 'bacde'],dictionary = ['abcde', 'edcba', 'bacde', 'cabed', 'abcde', 'edcba', 'bacde', 'cabed']) == ['abcde', 'edcba', 'bacde']\n    assert candidate(queries = ['abcdef', 'ghijkl'],dictionary = ['abcgef', 'ghikjl', 'abcdef']) == ['abcdef', 'ghijkl']\n    assert candidate(queries = ['abcd', 'abce', 'abcf'],dictionary = ['abcf', 'abce', 'abcc']) == ['abcd', 'abce', 'abcf']\n    assert candidate(queries = ['python', 'pyhton', 'pythpn'],dictionary = ['python', 'pyhton', 'pythpn', 'pythun']) == ['python', 'pyhton', 'pythpn']\n    assert candidate(queries = ['cat', 'bat', 'rat'],dictionary = ['cap', 'bap', 'rap', 'tap']) == ['cat', 'bat', 'rat']\n    assert candidate(queries = ['abcdefghij', 'klmnopqrst'],dictionary = ['abcdefghij', 'klmnopqrts', 'abcdefghik', 'klmnopqrst', 'abcdefghim']) == ['abcdefghij', 'klmnopqrst']\n    assert candidate(queries = ['kitten', 'sitten', 'bitten'],dictionary = ['sitten', 'kitten', 'biting', 'bitten']) == ['kitten', 'sitten', 'bitten']\n    assert candidate(queries = ['test', 'tast', 'rest'],dictionary = ['best', 'rest', 'tast', 'test']) == ['test', 'tast', 'rest']\n    assert candidate(queries = ['transform', 'transforn', 'tranformt'],dictionary = ['transfarm', 'transform', 'transfurm']) == ['transform', 'transforn']\n    assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx'],dictionary = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx']) == ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx']\n    assert candidate(queries = ['abcdefghij', 'abcdefghik', 'abcdefghil'],dictionary = ['abcdefghio', 'abcdefghij', 'abcdefghim']) == ['abcdefghij', 'abcdefghik', 'abcdefghil']\n    assert candidate(queries = ['apple', 'apply', 'pally'],dictionary = ['appel', 'abble', 'appie']) == ['apple', 'apply']\n    assert candidate(queries = ['zzzzzz', 'yyyyyy', 'xxxxxx'],dictionary = ['zzzzzz', 'yyyyyy', 'xxxxxx', 'wwwwww', 'vvvvvv', 'uuuuuu', 'tttttt']) == ['zzzzzz', 'yyyyyy', 'xxxxxx']\n    assert candidate(queries = ['apple', 'apply', 'pally'],dictionary = ['appla', 'appli', 'apple', 'pally', 'polly']) == ['apple', 'apply', 'pally']\n    assert candidate(queries = ['apple', 'apply', 'appla'],dictionary = ['apple', 'apply', 'appel', 'appla']) == ['apple', 'apply', 'appla']\n    assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],dictionary = ['abcdeg', 'ghijkm', 'mnopqs', 'stuvwx', 'yzabcd']) == ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd']\n    assert candidate(queries = ['abcdefgh', 'hgfedcba', 'abcdefgh'],dictionary = ['abcdefgh', 'hgfedcba', 'zyxwvuts', 'qrstuvwx']) == ['abcdefgh', 'hgfedcba', 'abcdefgh']\n    assert candidate(queries = ['abcdefghij', 'abcdefghij', 'abcdefghij'],dictionary = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij']) == ['abcdefghij', 'abcdefghij', 'abcdefghij']\n    assert candidate(queries = ['abcde', 'fghij', 'klmno'],dictionary = ['abxde', 'fghij', 'klmnp']) == ['abcde', 'fghij', 'klmno']\n    assert candidate(queries = ['apple', 'apply', 'appla'],dictionary = ['appel', 'apply', 'ample']) == ['apple', 'apply', 'appla']\n    assert candidate(queries = ['abcdefgh', 'abcdefgh', 'abcdefgh'],dictionary = ['abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh']) == ['abcdefgh', 'abcdefgh', 'abcdefgh']\n    assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr'],dictionary = ['abcdeg', 'ghikjl', 'mnopqg']) == ['abcdef', 'ghijkl', 'mnopqr']\n    assert candidate(queries = ['abcdef', 'abcdeg', 'abcdeh'],dictionary = ['abcdef', 'abcdeg', 'abcdeh', 'abcdei']) == ['abcdef', 'abcdeg', 'abcdeh']\n    assert candidate(queries = ['aabbcc', 'ddeeff', 'gghhii'],dictionary = ['aabbcc', 'ddeeff', 'gghhij']) == ['aabbcc', 'ddeeff', 'gghhii']\n    assert candidate(queries = ['abcdefgh', 'hgfedcba'],dictionary = ['abcdefgh', 'hgfedcba', 'abcdefgh']) == ['abcdefgh', 'hgfedcba']\n    assert candidate(queries = ['cat', 'dog', 'rat'],dictionary = ['bat', 'bag', 'rat', 'tag']) == ['cat', 'dog', 'rat']\n    assert candidate(queries = ['abcdef', 'ghijkl'],dictionary = ['fedcba', 'lkjihg', 'abcdeg', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd']) == ['abcdef', 'ghijkl']\n    assert candidate(queries = ['aaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc'],dictionary = ['aaaaaaaaaa', 'aaaaaaaabb', 'aaaaaaabbb', 'aaaaaabbbb', 'aaaaabbbbb', 'aaaabbbbbb', 'aabbbbbbbb', 'abbbbbbbbb', 'bbbbbbbbbb']) == ['aaaaaaaaaa', 'bbbbbbbbbb']\n    assert candidate(queries = ['abcdefghij', 'abcdefghik'],dictionary = ['abcdefghix', 'abcdefghiy', 'abcdefghij']) == ['abcdefghij', 'abcdefghik']\n    assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr'],dictionary = ['abcdej', 'ghijkl', 'mnopqr', 'mnopqs', 'mnopqt']) == ['abcdef', 'ghijkl', 'mnopqr']\n    assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr'],dictionary = ['abcdef', 'ghijkl', 'mnopqt']) == ['abcdef', 'ghijkl', 'mnopqr']\n    assert candidate(queries = ['abcdefg', 'hijklmn', 'opqrstu'],dictionary = ['abcdefg', 'hijklmn', 'opqrsuv']) == ['abcdefg', 'hijklmn', 'opqrstu']\n    assert candidate(queries = ['abcdefgh', 'abcdefgh'],dictionary = ['abcdwxyz', 'abcdefgz', 'abcdefgh']) == ['abcdefgh', 'abcdefgh']\n    assert candidate(queries = ['qwerty', 'asdfgh', 'zxcvbn'],dictionary = ['qwerty', 'qwertr', 'asdwgh', 'zxcvbn', 'qwertx']) == ['qwerty', 'asdfgh', 'zxcvbn']\n    assert candidate(queries = ['aaaaaa', 'bbbbbb', 'cccccc'],dictionary = ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd', 'eeeeee', 'ffffff']) == ['aaaaaa', 'bbbbbb', 'cccccc']\n    assert candidate(queries = ['abcdefghij', 'jihgfedcba', 'abcdefghij'],dictionary = ['abcdefghij', 'jihgfedcba', 'abcdefghji', 'jihgfedcbj', 'abcdefghii', 'jihgfedcbi']) == ['abcdefghij', 'jihgfedcba', 'abcdefghij']\n    assert candidate(queries = ['abcdefgh', 'abcdefgh'],dictionary = ['abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh']) == ['abcdefgh', 'abcdefgh']\n    assert candidate(queries = ['algorithm', 'alorithgm', 'alohrithm'],dictionary = ['algorithm', 'alorithgm', 'alohrithm', 'aloritrhm']) == ['algorithm', 'alorithgm', 'alohrithm']\n    assert candidate(queries = ['compiler', 'comipler', 'comipler'],dictionary = ['compiler', 'comipler', 'compilir', 'comiplir']) == ['compiler', 'comipler', 'comipler']\n    assert candidate(queries = ['zzzzz', 'yyyyy', 'xxxxx'],dictionary = ['zzzzz', 'xyzyx', 'zxyxz']) == ['zzzzz']\n    assert candidate(queries = ['zxywvutsrqponmlkjihgfedcba'],dictionary = ['zyxwvutsrqponmlkjihgfedcba', 'zxywvutsrqponmlkjihgfedcbb']) == ['zxywvutsrqponmlkjihgfedcba']\n    assert candidate(queries = ['apple', 'apply', 'ample'],dictionary = ['ample', 'appli', 'appel']) == ['apple', 'apply', 'ample']\n    assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],dictionary = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd']) == ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd']\n    assert candidate(queries = ['aaaaaa', 'bbbbbb', 'cccccc'],dictionary = ['aabbaa', 'bbccbb', 'ccddcc']) == ['aaaaaa', 'bbbbbb', 'cccccc']\n    assert candidate(queries = ['abcdefghij', 'abcdefghij', 'abcdefghij'],dictionary = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij']) == ['abcdefghij', 'abcdefghij', 'abcdefghij']\n", "comparison": "exact"}, "public_tests": ["[\"word\",\"note\",\"ants\",\"wood\"]\n[\"wood\",\"joke\",\"moat\"]", "[\"yes\"]\n[\"not\"]"], "hints": ["Try brute-forcing the problem.", "For each word in queries, try comparing to each word in dictionary.", "If there is a maximum of two edit differences, the word should be present in answer."], "metadata": {"canonical_parameter_names": ["queries", "dictionary"], "leetcode_dataset_entry_point": "Solution().twoEditWords", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:19+00:00", "tests_total": 114, "tests_dropped": 41, "flags": [], "topic_tags": ["array", "string", "trie"]}, "language": "python", "interface": {"raw_signature": "def twoEditWords(self, queries: list[str], dictionary: list[str]) -> list[str]:", "container": "Solution", "callable": "twoEditWords", "parameters": [{"name": "queries", "type": "list[str]"}, {"name": "dictionary", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2453, "task_id": "destroy-sequential-targets", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums consisting of positive integers, representing targets on a number line. You are also given an integer space.\n\nYou have a machine which can destroy targets. Seeding the machine with some nums[i] allows it to destroy all targets with values that can be represented as nums[i] + c * space, where c is any non-negative integer. You want to destroy the maximum number of targets in nums.\n\nReturn the minimum value of nums[i] you can seed the machine with to destroy the maximum number of targets.\n\nExample 1:\n\nInput: nums = [3,7,8,1,1,5], space = 2\nOutput: 1\nExplanation: If we seed the machine with nums[3], then we destroy all targets equal to 1,3,5,7,9,...\nIn this case, we would destroy 5 total targets (all except for nums[2]).\nIt is impossible to destroy more than 5 targets, so we return nums[3].\n\nExample 2:\n\nInput: nums = [1,3,5,2,4,6], space = 2\nOutput: 1\nExplanation: Seeding the machine with nums[0], or nums[3] destroys 3 targets.\nIt is not possible to destroy more than 3 targets.\nSince nums[0] is the minimal integer that can destroy 3 targets, we return 1.\n\nExample 3:\n\nInput: nums = [6,2,5], space = 100\nOutput: 2\nExplanation: Whatever initial seed we select, we can only destroy 1 target. The minimal seed is nums[1].\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^9\n- 1 <= space <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1000000000],space = 1000000000) == 1000000000\n    assert candidate(nums = [1, 3, 5, 2, 4, 6],space = 2) == 1\n    assert candidate(nums = [6, 2, 5],space = 100) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 1) == 1\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 1) == 1\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21],space = 3) == 3\n    assert candidate(nums = [7, 14, 21, 28, 35],space = 7) == 7\n    assert candidate(nums = [10, 20, 30, 40, 50],space = 10) == 10\n    assert candidate(nums = [9, 19, 29, 39, 49],space = 10) == 9\n    assert candidate(nums = [3, 7, 8, 1, 1, 5],space = 2) == 1\n    assert candidate(nums = [7, 14, 21, 28, 35, 42],space = 7) == 7\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],space = 3) == 1\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99],space = 11) == 11\n    assert candidate(nums = [9, 18, 27, 36, 45],space = 9) == 9\n    assert candidate(nums = [1, 1, 1, 1, 1],space = 1) == 1\n    assert candidate(nums = [5, 10, 15, 20, 25, 30],space = 5) == 5\n    assert candidate(nums = [1000000000, 1000000000, 1000000000],space = 1) == 1000000000\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],space = 2) == 2\n    assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],space = 1) == 1\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],space = 7) == 7\n    assert candidate(nums = [100, 103, 106, 109, 112, 115, 118, 121, 124, 127, 130, 133, 136, 139, 142, 145, 148, 151, 154, 157, 160, 163, 166, 169, 172, 175, 178, 181, 184, 187, 190],space = 3) == 100\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],space = 4) == 1\n    assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147],space = 3) == 3\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175],space = 7) == 7\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],space = 2) == 2\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],space = 10) == 5\n    assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],space = 4) == 4\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],space = 4) == 1\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],space = 7) == 7\n    assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100, 109, 118, 127],space = 9) == 1\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],space = 100) == 100\n    assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310, 341, 372, 403, 434, 465, 496, 527, 558, 589, 620],space = 31) == 31\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 1) == 1\n    assert candidate(nums = [2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 102, 112, 122, 132, 142, 152, 162, 172, 182, 192],space = 10) == 2\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],space = 3) == 3\n    assert candidate(nums = [2, 102, 202, 302, 402, 502, 602, 702, 802, 902, 1002, 1102, 1202, 1302, 1402, 1502, 1602, 1702, 1802, 1902],space = 100) == 2\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536],space = 1) == 1\n    assert candidate(nums = [1, 101, 201, 301, 401, 501, 601, 701, 801, 901],space = 100) == 1\n    assert candidate(nums = [3, 13, 23, 33, 43, 53, 63, 73, 83, 93],space = 10) == 3\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],space = 100) == 100\n    assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150],space = 15) == 15\n    assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],space = 2) == 2\n    assert candidate(nums = [5, 25, 45, 65, 85, 105, 125, 145, 165, 185, 205, 225, 245, 265, 285],space = 20) == 5\n    assert candidate(nums = [99, 198, 297, 396, 495, 594, 693, 792, 891, 990, 1089, 1188, 1287, 1386, 1485, 1584, 1683, 1782, 1881, 1980],space = 99) == 99\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 1) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],space = 10) == 10\n    assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],space = 8) == 8\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],space = 10) == 10\n    assert candidate(nums = [1, 101, 201, 301, 401, 501, 601, 701, 801, 901, 1001, 1101, 1201, 1301, 1401],space = 100) == 1\n    assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300],space = 15) == 15\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],space = 2) == 2\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],space = 4) == 2\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],space = 2) == 1\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],space = 1) == 3\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],space = 2) == 2\n    assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000],space = 1000000) == 1000000\n    assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907],space = 3) == 3\n    assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91],space = 9) == 1\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90],space = 3) == 3\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],space = 7) == 7\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],space = 4) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 2) == 1\n    assert candidate(nums = [1, 101, 201, 301, 401, 501, 601, 701, 801, 901, 1001, 1101, 1201, 1301, 1401, 1501, 1601, 1701, 1801, 1901],space = 100) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],space = 10) == 10\n    assert candidate(nums = [123456789, 246913578, 370370370, 493827161, 617283952, 740740740, 864256331, 987654321],space = 123456789) == 123456789\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],space = 10) == 10\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 1) == 1\n    assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999],space = 111111111) == 111111111\n    assert candidate(nums = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96],space = 5) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],space = 2) == 1\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994],space = 1) == 999999994\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195],space = 13) == 13\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],space = 2) == 2\n    assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117, 123, 129, 135, 141, 147],space = 6) == 3\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],space = 100) == 100\n    assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111],space = 111111111) == 111111111\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175],space = 7) == 7\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],space = 2) == 1\n    assert candidate(nums = [2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 102, 112, 122, 132, 142, 152, 162, 172, 182, 192, 202],space = 10) == 2\n    assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59],space = 6) == 5\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],space = 5) == 1\n    assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515],space = 101) == 101\n    assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100],space = 9) == 1\n    assert candidate(nums = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115],space = 6) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],space = 1) == 1\n    assert candidate(nums = [2, 12, 22, 32, 42, 52, 62, 72, 82, 92],space = 10) == 2\n    assert candidate(nums = [123456789, 246913578, 369270367, 492627156, 615943945],space = 123456789) == 123456789\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],space = 2) == 2\n    assert candidate(nums = [10, 19, 28, 37, 46, 55, 64],space = 9) == 10\n    assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88, 91],space = 3) == 1\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],space = 3) == 3\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],space = 2) == 1\n    assert candidate(nums = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91],space = 10) == 1\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],space = 3) == 3\n    assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],space = 12) == 12\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],space = 10) == 10\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],space = 2) == 2\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],space = 2) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],space = 10) == 10\n    assert candidate(nums = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191],space = 10) == 1\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],space = 13) == 13\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],space = 2) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],space = 10) == 10\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],space = 5) == 5\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],space = 1) == 1\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],space = 100) == 100\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],space = 10) == 5\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],space = 10) == 5\n    assert candidate(nums = [6, 18, 30, 42, 54, 66, 78, 90, 102, 114],space = 12) == 6\n    assert candidate(nums = [5, 11, 17, 23, 29, 35, 41],space = 6) == 5\n    assert candidate(nums = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],space = 2) == 12\n    assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],space = 4) == 3\n    assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63],space = 6) == 3\n    assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],space = 2) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],space = 1) == 1\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165],space = 11) == 11\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],space = 10) == 5\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],space = 10) == 5\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],space = 5) == 5\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],space = 3) == 999999996\n    assert candidate(nums = [5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86, 89, 92, 95],space = 3) == 5\n    assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000],space = 125000000) == 125000000\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],space = 11) == 11\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],space = 7) == 7\n", "comparison": "exact"}, "public_tests": ["[3,7,8,1,1,5]\n2", "[1,3,5,2,4,6]\n2", "[6,2,5]\n100"], "hints": ["Keep track of nums[i] modulo k.", "Iterate over nums in sorted order."], "metadata": {"canonical_parameter_names": ["nums", "space"], "leetcode_dataset_entry_point": "Solution().destroyTargets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:21+00:00", "tests_total": 127, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "hash-table", "counting"]}, "language": "python", "interface": {"raw_signature": "def destroyTargets(self, nums: list[int], space: int) -> int:", "container": "Solution", "callable": "destroyTargets", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "space", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2454, "task_id": "next-greater-element-iv", "difficulty": "Hard", "problem_description": "You are given a 0-indexed array of non-negative integers nums. For each integer in nums, you must find its respective second greater integer.\n\nThe second greater integer of nums[i] is nums[j] such that:\n\n- j > i\n- nums[j] > nums[i]\n- There exists exactly one index k such that nums[k] > nums[i] and i < k < j.\n\nIf there is no such nums[j], the second greater integer is considered to be -1.\n\n- For example, in the array [1, 2, 4, 3], the second greater integer of 1 is 4, 2 is 3, and that of 3 and 4 is -1.\n\nReturn an integer array answer, where answer[i] is the second greater integer of nums[i].\n\nExample 1:\n\nInput: nums = [2,4,0,9,6]\nOutput: [9,6,6,-1,-1]\nExplanation:\n0th index: 4 is the first integer greater than 2, and 9 is the second integer greater than 2, to the right of 2.\n1st index: 9 is the first, and 6 is the second integer greater than 4, to the right of 4.\n2nd index: 9 is the first, and 6 is the second integer greater than 0, to the right of 0.\n3rd index: There is no integer greater than 9 to its right, so the second greater integer is considered to be -1.\n4th index: There is no integer greater than 6 to its right, so the second greater integer is considered to be -1.\nThus, we return [9,6,6,-1,-1].\n\nExample 2:\n\nInput: nums = [3,3]\nOutput: [-1,-1]\nExplanation:\nWe return [-1,-1] since neither integer has any integer greater than it.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == [2, 5, 3, 6, 4, 7, 5, -1, -1, -1]\n    assert candidate(nums = [1, 3, 2, 4, 5]) == [2, 5, 5, -1, -1]\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1000000000, 0, 1000000000, 0, 1000000000]) == [-1, 1000000000, -1, -1, -1]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 7, 8, 5]) == [2, 5, 5, 6, 7, 7, 8, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [3, 4, 5, 6, 7, 8, 9, 10, -1, -1]\n    assert candidate(nums = [1, 5, 2, 4, 3]) == [2, -1, 3, -1, -1]\n    assert candidate(nums = [7, 1, 5, 2, 6, 3, 4, 8, 9]) == [9, 2, 8, 3, 9, 8, 9, -1, -1]\n    assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8]) == [2, 7, 3, 8, 4, -1, -1, -1]\n    assert candidate(nums = [3, 3]) == [-1, -1]\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [2, 3, 4, 5, 6, 7, 8, 9, -1, -1]\n    assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 0]) == [2, 5, 5, 6, 7, 8, 9, -1, -1, -1]\n    assert candidate(nums = [0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5]) == [3, 4, 5, -1, -1]\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [1, -1, 1, -1, 1, -1, 1, -1, -1, -1]\n    assert candidate(nums = [1, 1, 1, 1, 1]) == [-1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 4, 3]) == [4, 3, -1, -1]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [5, 6, 3, 2, 7, 8]) == [7, 8, 8, 8, -1, -1]\n    assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == [2, 5, 5, 6, 7, 8, 9, 10, -1, -1]\n    assert candidate(nums = [5, 4, 3, 2, 1]) == [-1, -1, -1, -1, -1]\n    assert candidate(nums = [2, 4, 0, 9, 6]) == [9, 6, 6, -1, -1]\n    assert candidate(nums = [5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [5, 3, 1, 2, 4]) == [-1, -1, 4, -1, -1]\n    assert candidate(nums = [10, 10, 10, 10, 10]) == [-1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1]\n    assert candidate(nums = [2, 1, 5, 6, 2, 3, 1, 4, 2, 3]) == [6, 6, -1, -1, 4, -1, 2, -1, -1, -1]\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 14, 12, 13, 15, 0]) == [2, 14, 3, 14, 4, 14, 5, 14, 11, 14, 12, -1, 15, -1, -1, -1]\n    assert candidate(nums = [3, 2, 1, 0, 4, 5, 6, 7, 8, 9]) == [5, 5, 5, 5, 6, 7, 8, 9, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == [3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1]\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10, 14]) == [2, 7, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12, 8, 13, 9, 14, 10, -1, -1, -1]\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 3, 9, 3, 7, 5, 1, 8, 2, 8, 4, 8, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1]) == [5, 5, 9, 9, 6, -1, 5, 7, 7, 9, 7, -1, 8, -1, 4, 8, 4, 9, 6, 7, 4, 7, 7, 7, 7, 9, 9, 9, 8, -1, 8, 8, 8, 9, 9, 7, 7, -1, 8, 9, 7, -1, 5, 8, 8, 2, 9, 4, 9, 6, 9, 7, 4, 7, 7, 7, 7, 9, 9, 9, 8, -1, 8, 8, 8, -1, -1, 7, 7, -1, -1, -1]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1]) == [2, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1, -1]\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 2, 3, 4, 5, 6, 7, 8, 9, 9, -1, 2, 3, 4, 5, 6, 7, 8, 9, 9, -1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [-1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, -1, -1, -1]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [-1, -1, 8, 8, 8, 8, 8, 8, 8, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == [2, 5, 3, 6, 4, 7, 5, 8, 6, 9, 7, 10, 8, -1, -1, -1]\n    assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == [-1, 5, -1, 5, -1, 5, -1, 5, -1, 5, -1, 5, -1, 5, -1, 5, -1, 5, -1, 5, -1, 5, -1, 5, -1, 5, -1, -1, -1, -1]\n    assert candidate(nums = [1, 5, 3, 9, 2, 8, 7, 10, 6, 11]) == [3, 8, 8, 11, 7, 11, 11, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1]\n    assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == [2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, -1, -1]\n    assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60]) == [30, 40, 20, 50, 30, 60, 40, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0, 1]) == [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, -1, -1, -1, -1]\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 5, 3, 4, 2, 7, 6, 8]) == [3, 6, 7, 6, 6, -1, -1, -1]\n    assert candidate(nums = [3, 4, 2, 3, 5, 1, 6, 0, 7, 8, 9]) == [5, 6, 5, 6, 7, 7, 8, 8, 9, -1, -1]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [2, 2, 3, 3, 4, 4, 5, 5, -1, -1]\n    assert candidate(nums = [5, 2, 6, 1, 3, 4, 7, 8, 0, 9]) == [7, 3, 8, 4, 7, 8, 9, -1, -1, -1]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, -1, -1]\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == [2, 12, 3, 12, 4, 12, 5, 12, 11, 12, 13, 14, 15, -1, -1]\n    assert candidate(nums = [2, 1, 3, 4, 2, 3, 4, 1, 5, 6]) == [4, 4, 4, 6, 4, 5, 6, 6, -1, -1]\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 5, 6, 7, 8]) == [3, 3, 4, 4, 3, 4, 4, 6, 5, 4, 5, 6, 6, 8, 7, 6, 7, 8, -1, -1]\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == [5, 5, 9, 9, 6, -1, 5, 7, 7, 9, 7, -1, 8, -1, 4, 8, 4, -1, -1, -1]\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [2, -1, 2, -1, 2, -1, 2, -1, -1, -1]\n    assert candidate(nums = [1, 5, 3, 7, 10, 8, 6, 9, 2, 4]) == [3, 10, 10, 8, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 2, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13, 14, 15]) == [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 14, 15, -1, -1]\n    assert candidate(nums = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == [1, -1, 2, -1, 3, -1, 4, -1, -1, -1]\n    assert candidate(nums = [1, 3, 2, 5, 4, 8, 7, 11, 10, 9, 13, 12, 6, 14, 15, 16, 17, 18, 19, 20]) == [2, 4, 4, 7, 7, 10, 10, 12, 12, 12, 15, 15, 15, 16, 17, 18, 19, 20, -1, -1]\n    assert candidate(nums = [1, 5, 3, 2, 4, 7, 6, 8]) == [3, 6, 7, 7, 6, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 8, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == [8, 8, 8, 8, 8, 8, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1]\n    assert candidate(nums = [2, 2, 1, 1, 3, 3, 4, 4, 5, 5]) == [3, 3, 3, 3, 4, 4, 5, 5, -1, -1]\n    assert candidate(nums = [0, 1, 1, 2, 2, 3, 3, 4, 4, 5]) == [1, 2, 2, 3, 3, 4, 4, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 3, 2, 6, 5, 4, 9, 8, 7, 10]) == [2, 5, 5, 8, 8, 8, -1, -1, -1, -1]\n    assert candidate(nums = [8, 1, 5, 2, 6, 3, 7, 4, 9, 0]) == [-1, 2, 7, 3, 9, 4, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 8, -1, -1, 9, 8, 7, 6, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == [3, 3, -1, 3, 3, -1, 3, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [3, 4, 5, 6, 7, 8, 9, -1, -1, -1]\n    assert candidate(nums = [1, 3, 2, 4, 7, 6, 5, 9, 8, 10]) == [2, 7, 7, 6, 8, 8, 8, -1, -1, -1]\n    assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [8, 1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12]) == [10, 2, 7, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12, 8, -1, -1, -1]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [-1, -1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1]\n    assert candidate(nums = [1, 2, 2, 2, 3, 2, 2, 2, 4, 2, 2, 2, 2, 5, 2, 2, 2, 2, 2, 6]) == [2, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1]\n    assert candidate(nums = [0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == [1, 3, 3, 5, 5, 7, 7, 9, 9, -1, -1]\n    assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [-1, 2, -1, 2, -1, 2, -1, -1, -1, -1]\n    assert candidate(nums = [1, 3, 2, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [2, 4, 4, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1]\n    assert candidate(nums = [5, 1, 4, 3, 2, 7, 8, 6, 9, 10]) == [8, 3, 8, 8, 8, 9, 10, 10, -1, -1]\n    assert candidate(nums = [3, 5, 4, 7, 6, 8, 10, 9, 11, 12, 13, 14, 15, 16, 17]) == [4, 6, 6, 10, 10, 9, 12, 12, 13, 14, 15, 16, 17, -1, -1]\n    assert candidate(nums = [1, 5, 3, 2, 4, 8, 6, 7, 9, 0]) == [3, 6, 8, 8, 6, -1, 9, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1]) == [3, 4, 5, 5, 5, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [2, -1, 3, -1, 4, -1, 5, -1, -1, -1]\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [3, 1, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == [4, 5, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, -1, -1]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [9, 0, 9, 0, 9, 0, 9, 0, 9, 0]) == [-1, 9, -1, 9, -1, 9, -1, -1, -1, -1]\n    assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1]) == [6, 6, -1, 9, 4, -1, -1, -1, -1]\n    assert candidate(nums = [8, 1, 5, 3, 7, 10, 2, 6, 9, 4]) == [9, 3, 10, 10, 9, -1, 9, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, 3, 4, 5, -1, -1]\n    assert candidate(nums = [2, 1, 5, 6, 0, 3, 4, 9, 8, 7]) == [6, 6, 9, 8, 4, 9, 8, -1, -1, -1]\n    assert candidate(nums = [1, 3, 2, 5, 4, 6, 7, 8, 10, 9]) == [2, 4, 4, 7, 7, 8, 10, 9, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [3, 4, 5, 6, 7, 8, 9, 10, 10, -1, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 91, 82, 73, 64, 55, 46, 37, 28, 19, 10]) == [30, 40, 50, 60, 70, 80, 90, 100, 91, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == [30, 40, 50, 60, 70, 80, 90, 100, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [2, 1, 5, 6, 2, 3, 1, 8]) == [6, 6, 8, -1, 8, -1, -1, -1]\n    assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == [-1, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1]\n    assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 32, 33, 34, 35]) == [32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 35, -1, -1]\n    assert candidate(nums = [3, 5, 2, 6, 1, 7, 4, 8, 0, 9]) == [6, 7, 7, 8, 4, 9, 9, -1, -1, -1]\n    assert candidate(nums = [5, 1, 4, 1, 3, 1, 2, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [-1, 3, -1, 2, -1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [-1, 10, 9, 9, 9, 9, 9, 9, 9, 9, -1, -1, 9, 9, 9, 9, 9, 9, 9, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 2, 1, 3, 4, 4, 3, 5, 6, 6, 5, 7, 8, 8, 7, 9]) == [2, 4, 4, 4, 4, 6, 6, 6, 6, 8, 8, 8, 8, -1, -1, -1, -1]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, -1, -1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1]\n    assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == [3, 4, 2, 5, 3, 6, 4, -1, -1, -1]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [2, -1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, 2, -1, -1, -1]\n    assert candidate(nums = [0, 10, 2, 9, 4, 8, 6, 7, 5, 3, 1]) == [2, -1, 4, -1, 6, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [3, 4, 5, 6, 7, 8, 9, 9, -1, 8, 8, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [100, 200, 101, 201, 102, 202, 103, 203, 104, 204]) == [101, 202, 102, 203, 103, 204, 104, -1, -1, -1]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10]) == [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, -1, -1, -1, -1]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [5, 3, 2, 4, 6, 1, 7, 8, 9, 10, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [7, 6, 6, 7, 8, 8, 9, 10, 11, 12, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, -1, -1]\n    assert candidate(nums = [50, 24, 54, 32, 54, 68, 27, 89, 10, 70, 29, 33, 63, 96, 99, 78, 76, 65, 84, 88]) == [54, 32, 89, 68, 89, 70, 70, 99, 29, 99, 63, 96, 99, -1, -1, 88, 88, 88, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == [3, 4, 4, -1, -1, 4, 3, 4, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == [3, 4, 5, 6, 7, 8, 9, 10, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == [-1, 3, 2, -1, 3, 2, -1, 3, 2, -1, 3, 2, -1, 3, 2, -1, -1, 2, -1, -1, -1]\n    assert candidate(nums = [1, 5, 2, 10, 11, 9, 3, 4, 6, 7, 8]) == [2, 11, 11, -1, -1, -1, 6, 7, 8, -1, -1]\n    assert candidate(nums = [0, 11, 7, 12, 13, 14, 6, 15, 16, 17, 8, 18, 19, 9, 10, 5, 20, 21, 22, 1]) == [7, 13, 13, 14, 15, 16, 16, 17, 18, 19, 19, 20, 21, 20, 21, 21, 22, -1, -1, -1]\n    assert candidate(nums = [1, 10, 8, 7, 6, 5, 4, 3, 2, 1]) == [8, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [10, 20, 30, 25, 40, 35, 50]) == [30, 25, 35, 35, -1, -1, -1]\n    assert candidate(nums = [1, 2, 4, 3]) == [4, 3, -1, -1]\n    assert candidate(nums = [1, 2, 3, 2, 1]) == [3, -1, -1, -1, -1]\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995]) == [-1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 10, 11, 1, 2, 10, 11, 1]) == [11, 11, -1, 10, 11, -1, -1, -1]\n    assert candidate(nums = [5, 3, 4, 2, 1]) == [-1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 100, 80, 60, 40, 20]) == [80, -1, -1, -1, -1, -1]\n    assert candidate(nums = [3, 2, 1]) == [-1, -1, -1]\n    assert candidate(nums = [1, 5, 2, 5, 4, 7, 3, 6]) == [2, 6, 4, 6, 6, -1, -1, -1]\n    assert candidate(nums = [5, 1, 4, 3, 6, 7, 8]) == [7, 3, 7, 7, 8, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9]) == [3, 4, 5, 6, 7, 8, 10, 9, -1, -1]\n    assert candidate(nums = [100, 50, 25, 12, 6, 3, 1]) == [-1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 10, 11, 12, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 10, 3, 4, 18, 5, 6]) == [3, -1, 18, 5, -1, -1, -1]\n    assert candidate(nums = [5, 1, 4, 2, 3]) == [-1, 2, -1, -1, -1]\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1]\n    assert candidate(nums = [1]) == [-1]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5]) == [-1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [8, 2, 4, 6, 7, 5, 3, 9, 1]) == [-1, 6, 7, 9, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 5, 2, 6, 3, 7, 4]) == [2, 7, 3, -1, 4, -1, -1]\n    assert candidate(nums = [1, 3, 2, 4, 5, 6, 7]) == [2, 5, 5, 6, 7, -1, -1]\n    assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8]) == [2, 7, 3, 8, 4, -1, -1, -1]\n    assert candidate(nums = [0, 1, 2, 3, 4, 5]) == [2, 3, 4, 5, -1, -1]\n    assert candidate(nums = [1, 5, 2, 4, 3, 6, 7, 8, 9, 10]) == [2, 7, 3, 7, 7, 8, 9, 10, -1, -1]\n    assert candidate(nums = [1, 2, 0, 3, 0, 4, 0, 5, 0, 6]) == [3, 4, 4, 5, 5, 6, 6, -1, -1, -1]\n    assert candidate(nums = [5, 8, 1, 2, 10, 6, 9, 7, 3, 4]) == [10, 9, 10, 6, -1, 7, -1, -1, -1, -1]\n    assert candidate(nums = [2, 1]) == [-1, -1]\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [100, 100, 100]) == [-1, -1, -1]\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == [-1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 3, 2, 4, 6, 5]) == [2, 6, 6, 5, -1, -1]\n    assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666]) == [-1, -1, -1, -1, -1]\n    assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [8, 1, 2, 4, 6, 7, 1, 5]) == [-1, 4, 6, 7, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 4, 3, 5, 6, 7, 8, 9, 10]) == [4, 3, 6, 6, 7, 8, 9, 10, -1, -1]\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0]) == [1, -1, 1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == [3, 3, -1, 3, 3, -1, 3, -1, -1]\n    assert candidate(nums = [5, 4, 3, 2, 1, 0]) == [-1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5]) == [3, 4, 5, -1, -1]\n    assert candidate(nums = [10, 1, 1, 6, 1, 4, 1, 2, 1, 1, 1, 9, 1, 4, 1, 1, 1, 1, 1, 1]) == [-1, 4, 4, -1, 2, -1, 9, 4, 4, 4, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [5, 3, 1, 2, 4]) == [-1, -1, 4, -1, -1]\n    assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10, 14]) == [2, 7, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12, 8, 13, 9, 14, 10, -1, -1, -1]\n    assert candidate(nums = [8, 5, 12, 9, 16, 15]) == [9, 9, 15, 15, -1, -1]\n    assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 10]) == [2, 5, 5, 7, 6, 9, 9, 10, -1, -1]\n    assert candidate(nums = [3, 3]) == [-1, -1]\n    assert candidate(nums = [5, 8, 4, 5, 3, 5, 10, 15]) == [10, 15, 5, 15, 10, 15, -1, -1]\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == [-1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [8, 1, 5, 2, 6, 3, 7, 4]) == [-1, 2, 7, 3, -1, 4, -1, -1]\n    assert candidate(nums = [7, 1, 5, 2, 6, 4, 3]) == [-1, 2, -1, 4, -1, -1, -1]\n    assert candidate(nums = [10, 20, 10, 30, 20, 40]) == [30, 40, 20, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3]) == [3, -1, -1]\n    assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6]) == [2, 7, 3, 8, 4, 9, 5, -1, 6, -1, -1]\n    assert candidate(nums = [10, 3, 11, 1, 15, 9]) == [15, 15, -1, 9, -1, -1]\n    assert candidate(nums = [1, 10, 8, 9, 10, 11, 5, 3, 12, 0]) == [8, 12, 10, 11, 12, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 3, 2, 4, 5]) == [2, 5, 5, -1, -1]\n    assert candidate(nums = [10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 10, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9]) == [2, 7, 3, 8, 4, 9, 5, -1, -1, -1]\n    assert candidate(nums = [0, 1, 2, 3, 4, 5]) == [2, 3, 4, 5, -1, -1]\n    assert candidate(nums = [5, 6, 7, 8, 9, 10]) == [7, 8, 9, 10, -1, -1]\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [2, 3, 4, 5, 6, 7, 8, 9, -1, -1]\n    assert candidate(nums = [0, 1, 2, 0, 3, 0, 4]) == [2, 3, 4, 4, -1, -1, -1]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2]) == [-1, -1]\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == [3, 3, -1, -1, 3, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 4, 7, 8]) == [2, 5, 5, 6, 7, 4, 8, 8, -1, -1]\n    assert candidate(nums = [10, 4, 3, 5, 7, 2, 8, 6, 1]) == [-1, 7, 7, 8, -1, 6, -1, -1, -1]\n    assert candidate(nums = [10, 5, 1, 6, 2, 7, 3, 8, 4, 9]) == [-1, 7, 2, 8, 3, 9, 4, -1, -1, -1]\n    assert candidate(nums = [10, 5, 15, 2, 18]) == [18, 18, -1, -1, -1]\n    assert candidate(nums = [1, 2, 0, 3, 0, 4, 0, 5, 0]) == [3, 4, 4, 5, 5, -1, -1, -1, -1]\n    assert candidate(nums = [1, 5, 2, 3, 4, 6, 7, 8, 9, 10]) == [2, 7, 4, 6, 7, 8, 9, 10, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == [3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 2, 1, 4, 5]) == [3, 4, 5, 5, 5, -1, -1]\n    assert candidate(nums = [5, 2, 6, 4, 7]) == [7, 4, -1, -1, -1]\n    assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 4, 3, 2, 1, 2, 3, 4]) == [2, 5, 3, 6, 6, -1, -1, -1, -1, 4, 3, 4, -1, -1]\n    assert candidate(nums = [1, 3, 2, 4, 5, 3, 2, 1]) == [2, 5, 5, -1, -1, -1, -1, -1]\n    assert candidate(nums = [5, 1, 2, 3, 4, 0]) == [-1, 3, 4, -1, -1, -1]\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1]) == [1, -1, 1, -1, 1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 0, 3, 0, 4, 0, 5]) == [3, 4, 4, 5, 5, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == [3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1]\n    assert candidate(nums = [10, 20, 15, 30, 25, 40, 35, 50, 45, 60]) == [15, 25, 25, 35, 35, 45, 45, -1, -1, -1]\n    assert candidate(nums = [1, 2, 0, 4, 3, 5, 6, 7, 8, 9]) == [4, 3, 3, 6, 6, 7, 8, 9, -1, -1]\n    assert candidate(nums = [5, 4, 3, 2, 1]) == [-1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == [3, 3, 4, 4, 5, 5, -1, -1, -1, -1]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [3, 4, 5, 6, 7, 8, 9, 10, -1, -1]\n    assert candidate(nums = [8, 1, 5, 2, 7]) == [-1, 2, -1, -1, -1]\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1]) == [2, -1, 2, -1, -1, -1, -1]\n    assert candidate(nums = [2, 4, 0, 9, 6]) == [9, 6, 6, -1, -1]\n", "comparison": "exact"}, "public_tests": ["[2,4,0,9,6]", "[3,3]"], "hints": ["Move forward in nums and store the value in a non-increasing stack for the first greater value.", "Move the value in the stack to an ordered data structure for the second greater value.", "Move value from the ordered data structure for the answer."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().secondGreaterElement", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:24+00:00", "tests_total": 224, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "binary-search", "stack", "sorting", "heap-priority-queue", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def secondGreaterElement(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "secondGreaterElement", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2455, "task_id": "average-value-of-even-numbers-that-are-divisible-by-three", "difficulty": "Easy", "problem_description": "Given an integer array nums of positive integers, return the average value of all even integers that are divisible by 3.\n\nNote that the average of n elements is the sum of the n elements divided by n and rounded down to the nearest integer.\n\nExample 1:\n\nInput: nums = [1,3,6,10,12,15]\nOutput: 9\nExplanation: 6 and 12 are even numbers that are divisible by 3. (6 + 12) / 2 = 9.\n\nExample 2:\n\nInput: nums = [1,2,4,7,10]\nOutput: 0\nExplanation: There is no single number that satisfies the requirement, so return 0.\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 1 <= nums[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 18\n    assert candidate(nums = [3, 9, 15, 21, 27, 33]) == 0\n    assert candidate(nums = [2, 4, 6, 8, 10, 12]) == 9\n    assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80]) == 42\n    assert candidate(nums = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300]) == 165\n    assert candidate(nums = [2, 6, 18, 24, 30]) == 19\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n    assert candidate(nums = [4, 8, 16, 20, 24, 28]) == 24\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 18\n    assert candidate(nums = [30, 60, 90, 120, 150, 180]) == 105\n    assert candidate(nums = [1, 5, 7, 11, 13, 17]) == 0\n    assert candidate(nums = [1, 3, 6, 10, 12, 15]) == 9\n    assert candidate(nums = [1, 5, 7, 11, 13, 17, 19, 23, 25, 29]) == 0\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 54\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 0\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 12\n    assert candidate(nums = [3, 9, 15, 21, 27]) == 0\n    assert candidate(nums = [2, 6, 12, 18, 24, 30]) == 18\n    assert candidate(nums = [36, 72, 108, 144, 180]) == 108\n    assert candidate(nums = [2, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114]) == 60\n    assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == 990\n    assert candidate(nums = [1, 2, 4, 7, 10]) == 0\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 0\n    assert candidate(nums = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330]) == 198\n    assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == 33\n    assert candidate(nums = [1, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 0\n    assert candidate(nums = [1, 5, 7, 11, 13, 17, 19]) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 12\n    assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == 24\n    assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57]) == 0\n    assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960, 959, 958, 957, 956, 955, 954, 953, 952, 951, 950, 949, 948, 947, 946, 945, 944, 943, 942, 941, 940, 939, 938, 937, 936, 935, 934, 933, 932, 931, 930]) == 963\n    assert candidate(nums = [300, 306, 312, 318, 324, 330, 336, 342, 348, 354, 360, 366, 372, 378, 384, 390]) == 345\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 600\n    assert candidate(nums = [6, 18, 30, 42, 54, 66, 78, 90, 102, 114]) == 60\n    assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550]) == 300\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 51\n    assert candidate(nums = [100, 102, 104, 105, 106, 108, 110, 111, 112, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130]) == 114\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 18\n    assert candidate(nums = [6, 36, 72, 108, 144, 180, 216, 252, 288, 324, 360, 396, 432, 468, 504]) == 252\n    assert candidate(nums = [2, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 33\n    assert candidate(nums = [150, 162, 174, 186, 198, 210, 222, 234, 246, 258, 270, 282, 294, 306, 318, 330, 342, 354, 366, 378]) == 264\n    assert candidate(nums = [18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150]) == 84\n    assert candidate(nums = [24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252]) == 138\n    assert candidate(nums = [150, 210, 270, 330, 390, 450, 510, 570, 630, 690, 750, 810, 870, 930, 990]) == 570\n    assert candidate(nums = [8, 14, 18, 20, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90]) == 54\n    assert candidate(nums = [2, 3, 5, 6, 9, 10, 12, 15, 18, 21, 24, 27, 30]) == 18\n    assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120]) == 63\n    assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 900, 960]) == 510\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 18\n    assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000]) == 525\n    assert candidate(nums = [100, 102, 104, 105, 108, 110, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180]) == 141\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 0\n    assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 33\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 18\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]) == 27\n    assert candidate(nums = [102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 204, 210, 216, 222, 228, 234, 240]) == 171\n    assert candidate(nums = [300, 303, 306, 309, 312, 315, 318, 321, 324, 327, 330, 333, 336, 339, 342, 345, 348, 351, 354, 357]) == 327\n    assert candidate(nums = [102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198]) == 150\n    assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117, 123, 129, 135, 141, 147, 153, 159, 165, 171, 177, 183, 189, 195, 201, 207, 213, 219, 225, 231, 237, 243, 249, 255, 261, 267, 273, 279, 285, 291, 297, 303, 309, 315, 321, 327, 333, 339, 345, 351, 357, 363, 369, 375, 381, 387, 393, 399]) == 0\n    assert candidate(nums = [600, 600, 600, 600, 600, 600, 600, 600, 600, 600]) == 600\n    assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98]) == 48\n    assert candidate(nums = [18, 36, 54, 72, 90, 108, 126, 144, 162, 180, 198, 216, 234, 252, 270, 288, 306, 324, 342, 360]) == 189\n    assert candidate(nums = [300, 303, 306, 309, 312, 315, 318, 321, 324, 327, 330, 333, 336, 339, 342, 345, 348, 351, 354, 357, 360, 363, 366, 369, 372]) == 336\n    assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150]) == 78\n    assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == 990\n    assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99]) == 0\n    assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96]) == 51\n    assert candidate(nums = [36, 72, 108, 144, 180, 216, 252, 288, 324, 360]) == 198\n    assert candidate(nums = [101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159]) == 0\n    assert candidate(nums = [24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 204, 210]) == 117\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 21\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 21\n    assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970]) == 984\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 33\n    assert candidate(nums = [600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638]) == 618\n    assert candidate(nums = [123, 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180]) == 153\n    assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 990\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 33\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 18\n    assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240]) == 132\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150]) == 78\n    assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180]) == 93\n    assert candidate(nums = [36, 72, 108, 144, 180, 216, 252, 288, 324, 360]) == 198\n    assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57]) == 0\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99]) == 51\n    assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96]) == 51\n    assert candidate(nums = [45, 90, 135, 180, 225, 270, 315, 360, 405, 450, 495, 540, 585, 630, 675, 720, 765, 810, 855, 900]) == 495\n    assert candidate(nums = [300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338]) == 318\n    assert candidate(nums = [6, 18, 30, 42, 54, 66, 78, 90, 102, 114, 126, 138, 150, 162, 174, 186, 198, 210, 222, 234, 246, 258, 270]) == 138\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 12\n    assert candidate(nums = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330, 363, 396, 429, 462, 495, 528, 561, 594, 627, 660]) == 363\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, 189, 192, 195, 198, 201, 204, 207, 210]) == 108\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]) == 27\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]) == 51\n    assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120]) == 63\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 48\n    assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 100]) == 48\n    assert candidate(nums = [27, 54, 81, 108, 135, 162, 189, 216, 243, 270, 297, 324, 351, 378, 405, 432, 459, 486, 513, 540]) == 297\n    assert candidate(nums = [3, 5, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 60\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 0\n    assert candidate(nums = [996, 998, 1000, 999, 993, 990, 987, 984, 981, 978, 975, 972, 969, 966, 963, 960, 957, 954, 951, 948]) == 972\n    assert candidate(nums = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510, 540, 570, 600]) == 315\n    assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == 0\n    assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117, 123, 129, 135, 141, 147]) == 0\n    assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336, 348, 360, 372, 384, 396, 408, 420, 432, 444, 456, 468, 480, 492, 504, 516, 528, 540, 552, 564, 576, 588, 600, 612, 624, 636, 648, 660, 672, 684, 696, 708, 720, 732, 744, 756, 768, 780, 792, 804, 816, 828, 840, 852, 864, 876, 888, 900, 912, 924, 936, 948, 960, 972, 984, 996]) == 504\n    assert candidate(nums = [100, 102, 104, 105, 108, 110, 112, 114, 117, 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, 150]) == 126\n    assert candidate(nums = [6, 18, 30, 42, 54, 66, 78, 90, 102, 114, 126, 138, 150, 162, 174, 186, 198, 210, 222, 234, 246, 258, 270, 282, 294, 300, 306, 312, 318, 324, 330]) == 181\n    assert candidate(nums = [200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238]) == 219\n    assert candidate(nums = [999, 996, 993, 990, 987, 984, 981, 978, 975, 972, 969, 966, 963, 960, 957, 954, 951, 948, 945, 942, 939, 936, 933, 930, 927, 924, 921, 918, 915, 912, 909, 906, 903, 900, 897, 894, 891, 888, 885, 882, 879, 876, 873, 870, 867, 864, 861, 858, 855, 852, 849, 846, 843, 840, 837, 834, 831, 828, 825, 822, 819, 816, 813, 810, 807, 804, 801, 798, 795, 792, 789, 786, 783, 780, 777, 774, 771, 768, 765, 762, 759, 756, 753, 750, 747, 744, 741, 738, 735, 732, 729, 726, 723, 720, 717, 714, 711, 708, 705, 702, 699, 696, 693, 690, 687, 684, 681, 678, 675, 672, 669, 666, 663, 660, 657, 654, 651, 648, 645, 642, 639, 636, 633, 630, 627, 624, 621, 618, 615, 612, 609, 606, 603, 600]) == 798\n    assert candidate(nums = [999, 998, 996, 994, 992, 990, 988, 986, 984, 982, 980, 978, 976, 974, 972, 970, 968, 966, 964, 962, 960, 958, 956, 954, 952, 950, 948, 946, 944, 942, 940, 938, 936, 934, 932, 930, 928, 926, 924, 922, 920, 918, 916, 914, 912, 910, 908, 906, 904, 902, 900, 898, 896, 894, 892, 890, 888, 886, 884, 882, 880, 878, 876, 874, 872, 870, 868, 866, 864, 862, 860]) == 930\n", "comparison": "exact"}, "public_tests": ["[1,3,6,10,12,15]", "[1,2,4,7,10]"], "hints": ["What is the property of a number if it is divisible by both 2 and 3 at the same time?", "It is equivalent to finding all the numbers that are divisible by 6."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().averageValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:26+00:00", "tests_total": 124, "tests_dropped": 12, "flags": [], "topic_tags": ["array", "math"]}, "language": "python", "interface": {"raw_signature": "def averageValue(self, nums: list[int]) -> int:", "container": "Solution", "callable": "averageValue", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2456, "task_id": "most-popular-video-creator", "difficulty": "Medium", "problem_description": "You are given two string arrays creators and ids, and an integer array views, all of length n. The i^th video on a platform was created by creators[i], has an id of ids[i], and has views[i] views.\n\nThe popularity of a creator is the sum of the number of views on all of the creator's videos. Find the creator with the highest popularity and the id of their most viewed video.\n\n- If multiple creators have the highest popularity, find all of them.\n- If multiple videos have the highest view count for a creator, find the lexicographically smallest id.\n\nNote: It is possible for different videos to have the same id, meaning that ids do not uniquely identify a video. For example, two videos with the same ID are considered as distinct videos with their own viewcount.\n\nReturn a 2D array of strings answer where answer[i] = [creators_i, id_i] means that creators_i has the highest popularity and id_i is the id of their most popular video. The answer can be returned in any order.\n\nExample 1:\n\nInput: creators = [\"alice\",\"bob\",\"alice\",\"chris\"], ids = [\"one\",\"two\",\"three\",\"four\"], views = [5,10,5,4]\nOutput: [[\"alice\",\"one\"],[\"bob\",\"two\"]]\nExplanation:\nThe popularity of alice is 5 + 5 = 10.\nThe popularity of bob is 10.\nThe popularity of chris is 4.\nalice and bob are the most popular creators.\nFor bob, the video with the highest view count is \"two\".\nFor alice, the videos with the highest view count are \"one\" and \"three\". Since \"one\" is lexicographically smaller than \"three\", it is included in the answer.\n\nExample 2:\n\nInput: creators = [\"alice\",\"alice\",\"alice\"], ids = [\"a\",\"b\",\"c\"], views = [1,2,2]\nOutput: [[\"alice\",\"b\"]]\nExplanation:\nThe videos with id \"b\" and \"c\" have the highest view count.\nSince \"b\" is lexicographically smaller than \"c\", it is included in the answer.\n\nConstraints:\n\n- n == creators.length == ids.length == views.length\n- 1 <= n <= 10^5\n- 1 <= creators[i].length, ids[i].length <= 5\n- creators[i] and ids[i] consist only of lowercase English letters.\n- 0 <= views[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n    \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n    if isinstance(result, list) and isinstance(expected, list):\n        return sorted(result, key=repr) == sorted(expected, key=repr)\n    return result == expected\n\n\ndef check(candidate):\n    assert answers_match(candidate(creators=['eve', 'eve', 'eve', 'eve'], ids=['a', 'a', 'b', 'b'], views=[10, 20, 20, 10]), [['eve', 'a']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'chris'], ids=['one', 'two', 'three', 'four'], views=[5, 10, 5, 4]), [['alice', 'one'], ['bob', 'two']])\n    assert answers_match(candidate(creators=['john', 'john', 'john'], ids=['x', 'y', 'x'], views=[10, 10, 10]), [['john', 'x']])\n    assert answers_match(candidate(creators=['alice', 'alice', 'alice'], ids=['a', 'b', 'c'], views=[1, 2, 2]), [['alice', 'b']])\n    assert answers_match(candidate(creators=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'], ids=['id', 'id', 'id', 'id', 'id', 'id', 'id', 'id', 'id', 'id'], views=[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]), [['a', 'id']])\n    assert answers_match(candidate(creators=['frank', 'frank', 'frank', 'frank', 'frank', 'frank'], ids=['one', 'two', 'three', 'four', 'five', 'six'], views=[1000, 1000, 1000, 1000, 1000, 1000]), [['frank', 'five']])\n    assert answers_match(candidate(creators=['alice', 'alice', 'alice', 'bob', 'bob', 'bob'], ids=['x', 'y', 'z', 'x', 'y', 'z'], views=[10, 20, 30, 30, 20, 10]), [['alice', 'z'], ['bob', 'x']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'chris', 'alice'], ids=['one', 'two', 'three', 'four', 'five'], views=[5, 10, 5, 4, 15]), [['alice', 'five']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'bob', 'alice', 'bob', 'alice'], ids=['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu'], views=[10, 20, 10, 20, 30, 40, 50]), [['alice', 'stu']])\n    assert answers_match(candidate(creators=['dave', 'eve', 'eve', 'eve', 'dave'], ids=['x', 'y', 'z', 'y', 'x'], views=[30, 20, 30, 40, 10]), [['eve', 'y']])\n    assert answers_match(candidate(creators=['alice', 'alice', 'alice', 'alice', 'alice'], ids=['z', 'y', 'x', 'w', 'v'], views=[5, 5, 5, 5, 5]), [['alice', 'v']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'bob', 'alice', 'bob'], ids=['one', 'two', 'three', 'four', 'five', 'six'], views=[5, 15, 10, 10, 5, 5]), [['bob', 'two']])\n    assert answers_match(candidate(creators=['karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen'], ids=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], views=[100, 200, 100, 200, 100, 200, 100, 200]), [['karen', 'b']])\n    assert answers_match(candidate(creators=['mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike'], ids=['one', 'two', 'three', 'four', 'five', 'six', 'seven'], views=[10, 20, 30, 40, 50, 60, 70]), [['mike', 'seven']])\n    assert answers_match(candidate(creators=['eve', 'eve', 'eve', 'eve', 'eve'], ids=['a', 'b', 'c', 'd', 'e'], views=[10, 20, 10, 10, 20]), [['eve', 'b']])\n    assert answers_match(candidate(creators=['a', 'b', 'a', 'b', 'a', 'b'], ids=['aaa', 'bbb', 'aaa', 'bbb', 'aaa', 'bbb'], views=[1, 2, 3, 4, 5, 6]), [['b', 'bbb']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'chris', 'bob'], ids=['one', 'two', 'three', 'four', 'five'], views=[5, 15, 5, 4, 15]), [['bob', 'five']])\n    assert answers_match(candidate(creators=['anna', 'anna', 'anna', 'anna', 'anna', 'anna'], ids=['x', 'y', 'z', 'x', 'y', 'z'], views=[10, 20, 30, 40, 50, 60]), [['anna', 'z']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'chris', 'bob', 'alice', 'chris', 'eve', 'eve', 'eve'], ids=['one', 'two', 'three', 'four', 'two', 'six', 'seven', 'eight', 'nine', 'ten'], views=[5, 10, 5, 4, 10, 15, 1, 20, 20, 5]), [['eve', 'eight']])\n    assert answers_match(candidate(creators=['frank', 'frank', 'frank', 'frank', 'frank'], ids=['a', 'b', 'a', 'c', 'b'], views=[100, 200, 300, 100, 200]), [['frank', 'a']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'chris', 'bob', 'alice'], ids=['one', 'two', 'three', 'four', 'two', 'six'], views=[5, 10, 5, 4, 10, 15]), [['alice', 'six']])\n    assert answers_match(candidate(creators=['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'], ids=['a', 'b', 'c', 'd', 'e', 'f', 'g'], views=[10, 10, 10, 10, 10, 10, 10]), [['eve', 'a']])\n    assert answers_match(candidate(creators=['alice', 'alice', 'alice', 'alice', 'alice'], ids=['a', 'a', 'b', 'b', 'c'], views=[10, 10, 20, 20, 30]), [['alice', 'c']])\n    assert answers_match(candidate(creators=['eve', 'eve', 'eve', 'eve', 'eve', 'eve'], ids=['aaa', 'aab', 'aac', 'aad', 'aae', 'aaf'], views=[10, 10, 10, 10, 10, 10]), [['eve', 'aaa']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'bob', 'alice', 'bob'], ids=['a', 'b', 'a', 'b', 'a', 'b'], views=[10, 15, 10, 20, 10, 25]), [['bob', 'b']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'bob', 'alice', 'bob'], ids=['a', 'a', 'b', 'b', 'c', 'c'], views=[10, 20, 30, 40, 50, 60]), [['bob', 'c']])\n    assert answers_match(candidate(creators=['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c'], ids=['m', 'n', 'o', 'p', 'q', 'r', 's', 't'], views=[100, 200, 150, 300, 400, 400, 500, 600]), [['b', 'q'], ['c', 't']])\n    assert answers_match(candidate(creators=['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'], ids=['m', 'n', 'm', 'n', 'm', 'n'], views=[10, 20, 10, 20, 10, 20]), [['ivan', 'n']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'chris', 'chris', 'bob'], ids=['one', 'two', 'three', 'four', 'five', 'six'], views=[5, 10, 5, 4, 3, 15]), [['bob', 'six']])\n    assert answers_match(candidate(creators=['alice', 'alice', 'alice', 'alice', 'alice', 'alice'], ids=['a', 'b', 'c', 'd', 'e', 'f'], views=[100000, 99999, 99998, 99997, 99996, 99995]), [['alice', 'a']])\n    assert answers_match(candidate(creators=['nina', 'nina', 'nina', 'nina', 'nina', 'nina', 'nina'], ids=['a', 'a', 'b', 'b', 'c', 'c', 'd'], views=[10, 20, 30, 20, 30, 40, 50]), [['nina', 'd']])\n    assert answers_match(candidate(creators=['dave', 'eve', 'frank', 'dave', 'eve', 'frank'], ids=['alpha', 'beta', 'gamma', 'alpha', 'beta', 'gamma'], views=[10, 20, 10, 5, 25, 15]), [['eve', 'beta']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'chris', 'alice'], ids=['one', 'two', 'three', 'four', 'five'], views=[5, 10, 15, 4, 10]), [['alice', 'three']])\n    assert answers_match(candidate(creators=['isaac', 'jack', 'isaac', 'jack', 'isaac', 'jack'], ids=['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff'], views=[1, 2, 1, 2, 1, 2]), [['jack', 'bbb']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'chris', 'bob', 'alice', 'chris'], ids=['one', 'two', 'three', 'four', 'two', 'six', 'seven'], views=[5, 10, 5, 4, 10, 15, 1]), [['alice', 'six']])\n    assert answers_match(candidate(creators=['tom', 'jerry', 'spike', 'tom', 'jerry', 'spike'], ids=['q', 'w', 'e', 'r', 't', 'y'], views=[100, 200, 150, 100, 200, 150]), [['jerry', 't']])\n    assert answers_match(candidate(creators=['karen', 'karen', 'karen', 'karen', 'karen', 'karen'], ids=['a', 'b', 'c', 'd', 'e', 'f'], views=[1, 2, 3, 4, 5, 6]), [['karen', 'f']])\n    assert answers_match(candidate(creators=['anna', 'anna', 'anna', 'anna'], ids=['aaa', 'bbb', 'aaa', 'bbb'], views=[50, 50, 50, 50]), [['anna', 'aaa']])\n    assert answers_match(candidate(creators=['leo', 'leo', 'leo', 'leo', 'leo'], ids=['z', 'y', 'x', 'w', 'v'], views=[1000, 1000, 1000, 1000, 1000]), [['leo', 'v']])\n    assert answers_match(candidate(creators=['nina', 'nina', 'nina', 'nina', 'nina', 'nina', 'nina', 'nina', 'nina', 'nina'], ids=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'], views=[10, 20, 10, 20, 10, 20, 10, 20, 10, 20]), [['nina', 'b']])\n    assert answers_match(candidate(creators=['anna', 'anna', 'anna', 'anna'], ids=['aaa', 'aab', 'aac', 'aad'], views=[5, 5, 5, 5]), [['anna', 'aaa']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'bob', 'alice', 'bob'], ids=['a', 'a', 'b', 'b', 'c', 'c'], views=[10, 20, 20, 10, 30, 30]), [['alice', 'c'], ['bob', 'c']])\n    assert answers_match(candidate(creators=['alice', 'alice', 'bob', 'bob', 'alice', 'bob'], ids=['a', 'b', 'c', 'd', 'e', 'f'], views=[10, 20, 30, 30, 40, 10]), [['alice', 'e'], ['bob', 'c']])\n    assert answers_match(candidate(creators=['dave', 'dave', 'dave', 'dave'], ids=['aaa', 'aab', 'aac', 'aad'], views=[1000, 1000, 1000, 1000]), [['dave', 'aaa']])\n    assert answers_match(candidate(creators=['alice', 'alice', 'bob', 'bob', 'bob'], ids=['abc', 'def', 'ghi', 'jkl', 'mno'], views=[50, 50, 60, 60, 60]), [['bob', 'ghi']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'bob', 'alice', 'chris'], ids=['a', 'b', 'c', 'a', 'd'], views=[10, 20, 20, 30, 5]), [['alice', 'a'], ['bob', 'b']])\n    assert answers_match(candidate(creators=['eve', 'eve', 'eve', 'eve', 'eve', 'eve'], ids=['a', 'b', 'c', 'd', 'e', 'f'], views=[5, 10, 15, 20, 25, 30]), [['eve', 'f']])\n    assert answers_match(candidate(creators=['karen', 'leo', 'mike', 'leo', 'karen', 'mike'], ids=['a', 'b', 'c', 'd', 'e', 'f'], views=[30, 40, 30, 40, 30, 40]), [['leo', 'b']])\n    assert answers_match(candidate(creators=['eve', 'eve', 'eve', 'eve', 'eve'], ids=['x', 'y', 'z', 'x', 'y'], views=[10, 20, 30, 10, 20]), [['eve', 'z']])\n    assert answers_match(candidate(creators=['jane', 'jane', 'jane', 'jane', 'jane', 'jane'], ids=['one', 'two', 'three', 'four', 'five', 'six'], views=[10, 10, 10, 10, 10, 10]), [['jane', 'five']])\n    assert answers_match(candidate(creators=['dave', 'eve', 'frank', 'dave', 'eve', 'frank'], ids=['m', 'n', 'o', 'p', 'q', 'r'], views=[100, 200, 150, 250, 175, 225]), [['eve', 'n'], ['frank', 'r']])\n    assert answers_match(candidate(creators=['eve', 'eve', 'eve', 'eve', 'eve'], ids=['x', 'y', 'z', 'x', 'y'], views=[10, 20, 10, 20, 10]), [['eve', 'x']])\n    assert answers_match(candidate(creators=['anna', 'anna', 'anna', 'bob', 'bob'], ids=['a', 'b', 'c', 'a', 'b'], views=[100, 100, 150, 200, 200]), [['bob', 'a']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'bob', 'alice'], ids=['x', 'y', 'z', 'x', 'y'], views=[10, 20, 10, 20, 30]), [['alice', 'y']])\n    assert answers_match(candidate(creators=['alice', 'bob', 'alice', 'bob', 'alice', 'bob', 'alice', 'bob'], ids=['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], views=[1, 2, 3, 4, 5, 6, 7, 8]), [['bob', 'a']])\n    assert answers_match(candidate(creators=['mike', 'mike', 'mike', 'mike', 'mike', 'mike'], ids=['same', 'same', 'same', 'same', 'same', 'same'], views=[5, 5, 5, 5, 5, 5]), [['mike', 'same']])\n    assert answers_match(candidate(creators=['x', 'y', 'z', 'x', 'y', 'z'], ids=['a', 'b', 'c', 'a', 'b', 'c'], views=[10, 10, 10, 20, 20, 20]), [['x', 'a'], ['y', 'b'], ['z', 'c']])\n    assert answers_match(candidate(creators=['peter', 'quinn', 'peter', 'quinn', 'peter', 'quinn'], ids=['zero', 'one', 'zero', 'one', 'zero', 'one'], views=[500, 600, 700, 800, 900, 1000]), [['quinn', 'one']])\n    assert answers_match(candidate(creators=['anna', 'anna', 'anna', 'anna', 'anna'], ids=['z', 'y', 'x', 'w', 'v'], views=[5, 5, 5, 5, 5]), [['anna', 'v']])\n    assert answers_match(candidate(creators=['z', 'z', 'z', 'y', 'y', 'y', 'x', 'x', 'x'], ids=['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c'], views=[100, 200, 150, 300, 400, 400, 500, 600, 650]), [['x', 'c']])\n", "comparison": "unordered"}, "public_tests": ["[\"alice\",\"bob\",\"alice\",\"chris\"]\n[\"one\",\"two\",\"three\",\"four\"]\n[5,10,5,4]", "[\"alice\",\"alice\",\"alice\"]\n[\"a\",\"b\",\"c\"]\n[1,2,2]"], "hints": ["Use a hash table to store and categorize videos based on their creator.", "For each creator, iterate through all their videos and use three variables to keep track of their popularity, their most popular video, and the id of their most popular video."], "metadata": {"canonical_parameter_names": ["creators", "ids", "views"], "leetcode_dataset_entry_point": "Solution().mostPopularCreator", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:29+00:00", "tests_total": 102, "tests_dropped": 42, "flags": ["any_order"], "topic_tags": ["array", "hash-table", "string", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def mostPopularCreator(self, creators: list[str], ids: list[str], views: list[int]) -> list[list[str]]:", "container": "Solution", "callable": "mostPopularCreator", "parameters": [{"name": "creators", "type": "list[str]"}, {"name": "ids", "type": "list[str]"}, {"name": "views", "type": "list[int]"}], "return_type": "list[list[str]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2457, "task_id": "minimum-addition-to-make-integer-beautiful", "difficulty": "Medium", "problem_description": "You are given two positive integers n and target.\n\nAn integer is considered beautiful if the sum of its digits is less than or equal to target.\n\nReturn the minimum non-negative integer x such that n + x is beautiful. The input will be generated such that it is always possible to make n beautiful.\n\nExample 1:\n\nInput: n = 16, target = 6\nOutput: 4\nExplanation: Initially n is 16 and its digit sum is 1 + 6 = 7. After adding 4, n becomes 20 and digit sum becomes 2 + 0 = 2. It can be shown that we can not make n beautiful with adding non-negative integer less than 4.\n\nExample 2:\n\nInput: n = 467, target = 6\nOutput: 33\nExplanation: Initially n is 467 and its digit sum is 4 + 6 + 7 = 17. After adding 33, n becomes 500 and digit sum becomes 5 + 0 + 0 = 5. It can be shown that we can not make n beautiful with adding non-negative integer less than 33.\n\nExample 3:\n\nInput: n = 1, target = 1\nOutput: 0\nExplanation: Initially n is 1 and its digit sum is 1, which is already smaller than or equal to target.\n\nConstraints:\n\n- 1 <= n <= 10^12\n- 1 <= target <= 150\n- The input will be generated such that it is always possible to make n beautiful.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 1000000000000,target = 1) == 0\n    assert candidate(n = 1,target = 1) == 0\n    assert candidate(n = 99999,target = 5) == 1\n    assert candidate(n = 8888,target = 32) == 0\n    assert candidate(n = 888888888,target = 24) == 1111112\n    assert candidate(n = 467,target = 6) == 33\n    assert candidate(n = 123456789,target = 30) == 11\n    assert candidate(n = 123456789,target = 10) == 543211\n    assert candidate(n = 999,target = 27) == 0\n    assert candidate(n = 56789,target = 25) == 11\n    assert candidate(n = 123,target = 6) == 0\n    assert candidate(n = 1000000000,target = 1) == 0\n    assert candidate(n = 999,target = 15) == 1\n    assert candidate(n = 123456789,target = 20) == 3211\n    assert candidate(n = 999999999,target = 10) == 1\n    assert candidate(n = 1001,target = 1) == 8999\n    assert candidate(n = 999999999999,target = 1) == 1\n    assert candidate(n = 16,target = 6) == 4\n    assert candidate(n = 111111111,target = 9) == 0\n    assert candidate(n = 100000000000,target = 1) == 0\n    assert candidate(n = 88888888888,target = 10) == 1111111112\n    assert candidate(n = 987654321098,target = 50) == 2\n    assert candidate(n = 100,target = 1) == 0\n    assert candidate(n = 888888888888,target = 24) == 1111111112\n    assert candidate(n = 101010101010,target = 15) == 0\n    assert candidate(n = 234567890123,target = 30) == 109877\n    assert candidate(n = 666666666666,target = 42) == 333334\n    assert candidate(n = 1234567890,target = 15) == 432110\n    assert candidate(n = 54321,target = 15) == 0\n    assert candidate(n = 1234567890,target = 18) == 32110\n    assert candidate(n = 555555555,target = 15) == 4444445\n    assert candidate(n = 888888888888,target = 60) == 11112\n    assert candidate(n = 1999999999,target = 10) == 1\n    assert candidate(n = 567890123456,target = 75) == 0\n    assert candidate(n = 9876543210,target = 30) == 3456790\n    assert candidate(n = 9876543210,target = 50) == 0\n    assert candidate(n = 999999999,target = 1) == 1\n    assert candidate(n = 987654321098,target = 27) == 345678902\n    assert candidate(n = 500000000000,target = 5) == 0\n    assert candidate(n = 987654321,target = 10) == 12345679\n    assert candidate(n = 999999999999,target = 10) == 1\n    assert candidate(n = 888888888888,target = 35) == 11111112\n    assert candidate(n = 876543210,target = 10) == 23456790\n    assert candidate(n = 999,target = 2) == 1\n    assert candidate(n = 99999999999,target = 9) == 1\n    assert candidate(n = 999999999,target = 45) == 1\n    assert candidate(n = 598765432109,target = 30) == 34567891\n    assert candidate(n = 123456789012,target = 45) == 988\n    assert candidate(n = 987654321,target = 20) == 2345679\n    assert candidate(n = 54321,target = 8) == 5679\n    assert candidate(n = 100100100100,target = 3) == 899900\n    assert candidate(n = 888888888,target = 7) == 111111112\n    assert candidate(n = 4321,target = 4) == 5679\n    assert candidate(n = 999999999999,target = 2) == 1\n    assert candidate(n = 599599599,target = 25) == 400401\n    assert candidate(n = 567890123456,target = 30) == 9876544\n    assert candidate(n = 54321,target = 5) == 45679\n    assert candidate(n = 5000000000,target = 5) == 0\n    assert candidate(n = 99998,target = 4) == 2\n    assert candidate(n = 888888888,target = 15) == 11111112\n    assert candidate(n = 888888888,target = 10) == 11111112\n    assert candidate(n = 1,target = 2) == 0\n    assert candidate(n = 111111111111,target = 12) == 0\n    assert candidate(n = 222222222222,target = 24) == 0\n    assert candidate(n = 987654321,target = 25) == 345679\n    assert candidate(n = 333333333333,target = 30) == 667\n", "comparison": "exact"}, "public_tests": ["16\n6", "467\n6", "1\n1"], "hints": ["Think about each digit independently.", "Turn the rightmost non-zero digit to zero until the digit sum is greater than target."], "metadata": {"canonical_parameter_names": ["n", "target"], "leetcode_dataset_entry_point": "Solution().makeIntegerBeautiful", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:31+00:00", "tests_total": 103, "tests_dropped": 37, "flags": [], "topic_tags": ["math", "greedy"]}, "language": "python", "interface": {"raw_signature": "def makeIntegerBeautiful(self, n: int, target: int) -> int:", "container": "Solution", "callable": "makeIntegerBeautiful", "parameters": [{"name": "n", "type": "int"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2460, "task_id": "apply-operations-to-an-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed array nums of size n consisting of non-negative integers.\n\nYou need to apply n - 1 operations to this array where, in the i^th operation (0-indexed), you will apply the following on the i^th element of nums:\n\n- If nums[i] == nums[i + 1], then multiply nums[i] by 2 and set nums[i + 1] to 0. Otherwise, you skip this operation.\n\nAfter performing all the operations, shift all the 0's to the end of the array.\n\n- For example, the array [1,0,2,0,0,1] after shifting all its 0's to the end, is [1,2,1,0,0,0].\n\nReturn the resulting array.\n\nNote that the operations are applied sequentially, not all at once.\n\nExample 1:\n\nInput: nums = [1,2,2,1,1,0]\nOutput: [1,4,2,0,0,0]\nExplanation: We do the following operations:\n- i = 0: nums[0] and nums[1] are not equal, so we skip this operation.\n- i = 1: nums[1] and nums[2] are equal, we multiply nums[1] by 2 and change nums[2] to 0. The array becomes [1,4,0,1,1,0].\n- i = 2: nums[2] and nums[3] are not equal, so we skip this operation.\n- i = 3: nums[3] and nums[4] are equal, we multiply nums[3] by 2 and change nums[4] to 0. The array becomes [1,4,0,2,0,0].\n- i = 4: nums[4] and nums[5] are equal, we multiply nums[4] by 2 and change nums[5] to 0. The array becomes [1,4,0,2,0,0].\nAfter that, we shift the 0's to the end, which gives the array [1,4,2,0,0,0].\n\nExample 2:\n\nInput: nums = [0,1]\nOutput: [1,0]\nExplanation: No operation can be applied, we just shift the 0 to the end.\n\nConstraints:\n\n- 2 <= nums.length <= 2000\n- 0 <= nums[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [6, 5, 4, 3, 2, 1]) == [6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1, 2, 3, 2, 3, 2]) == [1, 2, 3, 2, 3, 2]\n    assert candidate(nums = [2, 2, 0, 0, 1, 1, 1]) == [4, 2, 1, 0, 0, 0, 0]\n    assert candidate(nums = [10, 10, 0, 0, 10, 10, 10]) == [20, 20, 10, 0, 0, 0, 0]\n    assert candidate(nums = [1, 3, 3, 3, 2, 2, 1]) == [1, 6, 3, 4, 1, 0, 0]\n    assert candidate(nums = [1, 2, 3, 2, 1, 2]) == [1, 2, 3, 2, 1, 2]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]\n    assert candidate(nums = [10, 10, 0, 0, 10, 10, 0, 0, 10, 10]) == [20, 20, 20, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 3, 3, 3, 2, 2, 1, 1, 0, 0]) == [1, 6, 3, 4, 2, 0, 0, 0, 0, 0]\n    assert candidate(nums = [0, 1]) == [1, 0]\n    assert candidate(nums = [0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n    assert candidate(nums = [2, 2, 2, 2, 2, 2]) == [4, 4, 4, 0, 0, 0]\n    assert candidate(nums = [1, 0, 1, 0, 1, 0]) == [1, 1, 1, 0, 0, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6]) == [1, 2, 3, 4, 5, 6]\n    assert candidate(nums = [10, 10, 20, 20, 30, 30]) == [20, 40, 60, 0, 0, 0]\n    assert candidate(nums = [0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1000, 1000, 0, 0, 1000, 1000]) == [2000, 2000, 0, 0, 0, 0]\n    assert candidate(nums = [1, 0, 2, 0, 0, 1]) == [1, 2, 1, 0, 0, 0]\n    assert candidate(nums = [1, 1, 0, 0, 1, 1]) == [2, 2, 0, 0, 0, 0]\n    assert candidate(nums = [5, 5, 5, 5, 5, 5]) == [10, 10, 10, 0, 0, 0]\n    assert candidate(nums = [5, 5, 5, 5, 0, 0, 0, 0, 0, 0]) == [10, 10, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 2, 2, 1, 1, 0]) == [1, 4, 2, 0, 0, 0]\n    assert candidate(nums = [6, 6, 5, 5, 4, 4]) == [12, 10, 8, 0, 0, 0]\n    assert candidate(nums = [2, 2, 0, 0, 1, 1]) == [4, 2, 0, 0, 0, 0]\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == [1, 4, 6, 8, 10, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1]) == [2, 2, 2, 0, 0, 0]\n    assert candidate(nums = [0, 2, 2, 0, 0, 3, 3, 0, 0, 4, 4]) == [4, 6, 8, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [2, 2, 2, 2, 2]) == [4, 4, 2, 0, 0]\n    assert candidate(nums = [2, 2, 0, 0, 2, 2]) == [4, 4, 0, 0, 0, 0]\n    assert candidate(nums = [10, 10, 10, 10, 10, 10, 0, 0, 0]) == [20, 20, 20, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]\n    assert candidate(nums = [10, 10, 10, 10, 10, 0, 0, 0, 0, 0]) == [20, 20, 10, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == [2, 4, 4, 6, 6, 3, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [100, 0, 100, 0, 100, 0, 100, 0, 100, 0]) == [100, 100, 100, 100, 100, 0, 0, 0, 0, 0]\n    assert candidate(nums = [10, 20, 20, 10, 10, 20, 20]) == [10, 40, 20, 40, 0, 0, 0]\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]\n    assert candidate(nums = [999, 999, 0, 999, 999, 999, 0, 0, 999, 999, 999]) == [1998, 1998, 999, 1998, 999, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [6, 6, 0, 6, 0, 6, 0, 6, 6, 6, 0, 6, 6, 0]) == [12, 6, 6, 12, 6, 12, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 2, 2, 1, 3, 3, 2, 2, 1, 1]) == [1, 4, 1, 6, 4, 2, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0]) == [2, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [500, 500, 1000, 1000, 500, 500, 0, 0, 0, 0]) == [1000, 2000, 1000, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0]) == [1, 1, 1, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [5, 0, 5, 5, 0, 0, 5, 5, 5, 0]) == [5, 10, 10, 5, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == [20, 40, 60, 80, 100, 0, 0, 0, 0, 0]\n    assert candidate(nums = [2, 2, 0, 0, 2, 2, 0, 0, 2, 2]) == [4, 4, 4, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 4, 3, 2, 1]\n    assert candidate(nums = [1000, 1000, 999, 999, 888, 888, 777, 777]) == [2000, 1998, 1776, 1554, 0, 0, 0, 0]\n    assert candidate(nums = [2, 2, 0, 2, 2, 0, 2, 2, 0, 2]) == [4, 4, 4, 2, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [1, 4, 6, 3, 8, 8, 0, 0, 0, 0]\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 2, 3, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 2, 6, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [3, 3, 3, 0, 3, 3, 0, 0, 3, 3, 3, 0]) == [6, 3, 6, 6, 3, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == [2, 1, 4, 2, 6, 3, 0, 0, 0]\n    assert candidate(nums = [0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 0, 0, 0, 0, 0]\n    assert candidate(nums = [5, 5, 5, 2, 2, 2, 2, 2, 5, 5]) == [10, 5, 4, 4, 2, 10, 0, 0, 0, 0]\n    assert candidate(nums = [6, 6, 6, 6, 0, 0, 0, 0, 6, 6]) == [12, 12, 12, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == [2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [3, 3, 3, 0, 3, 3, 0, 0, 3, 3, 3, 0, 3, 0, 3]) == [6, 3, 6, 6, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == [2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == [2000, 2000, 2000, 2000, 2000, 0, 0, 0, 0, 0]\n    assert candidate(nums = [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [2, 4, 6, 8, 10, 0, 0, 0, 0, 0]\n    assert candidate(nums = [9, 10, 9, 10, 9, 10, 9, 10, 9, 10]) == [9, 10, 9, 10, 9, 10, 9, 10, 9, 10]\n    assert candidate(nums = [999, 0, 999, 0, 999, 0, 999, 0, 999, 0]) == [999, 999, 999, 999, 999, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2]) == [4, 2, 4, 2, 4, 2, 0, 0, 0, 0, 0]\n    assert candidate(nums = [10, 0, 10, 10, 0, 10, 0, 10, 10, 10]) == [10, 20, 10, 20, 10, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n    assert candidate(nums = [1, 2, 2, 1, 1, 0, 0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0]) == [1, 4, 2, 2, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == [1, 2, 3, 2, 1, 2, 3, 2, 1]\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [18, 18, 18, 18, 18, 0, 0, 0, 0, 0]\n    assert candidate(nums = [5, 5, 0, 0, 5, 5, 5, 0]) == [10, 10, 5, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1]) == [2, 2, 2, 0, 0, 0, 0, 0]\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]\n    assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0]) == [1, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 2, 2, 4, 4, 8, 8, 16, 16, 32]) == [1, 4, 8, 16, 32, 32, 0, 0, 0, 0]\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n    assert candidate(nums = [3, 0, 3, 3, 0, 0, 3, 3, 0, 3]) == [3, 6, 6, 3, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == [1, 2, 3, 4, 5, 0, 0, 0, 0, 0]\n    assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == [2, 2, 1, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5]) == [1, 2, 3, 4, 5, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == [2000, 2000, 2000, 2000, 0, 0, 0, 0]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n    assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 0, 1, 0]) == [1, 1, 1, 1, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1000, 1000, 0, 0, 1000, 1000, 1000, 0, 0, 1000]) == [2000, 2000, 1000, 1000, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0]\n    assert candidate(nums = [5, 5, 0, 0, 5, 5, 0, 0, 5, 5]) == [10, 10, 10, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == [2, 2, 2, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0, 0, 0, 0]) == [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0, 0, 0, 0]\n    assert candidate(nums = [9, 9, 0, 0, 9, 0, 9, 9, 9, 0, 9, 9, 0, 9, 9, 9, 0, 9, 9, 9]) == [18, 9, 18, 9, 18, 18, 9, 18, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 2, 2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1]) == [1, 4, 2, 2, 1, 4, 2, 2, 4, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == [1, 1, 1, 1, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40]) == [20, 40, 60, 80, 0, 0, 0, 0]\n    assert candidate(nums = [0, 1, 1, 2, 2, 0, 3, 3, 0, 4, 4, 0]) == [2, 4, 6, 8, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 0, 0, 0]) == [2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [7, 0, 7, 0, 7, 0, 7, 0, 7, 0]) == [7, 7, 7, 7, 7, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [10, 0, 10, 0, 10, 0, 10, 0, 10]) == [10, 10, 10, 10, 10, 0, 0, 0, 0]\n    assert candidate(nums = [5, 5, 5, 0, 5, 5, 0, 0, 5, 5]) == [10, 5, 10, 10, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [5, 5, 5, 5, 0, 0, 5, 5, 5, 5]) == [10, 10, 10, 10, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [8, 8, 8, 0, 8, 8, 0, 8, 8, 8]) == [16, 8, 16, 16, 8, 0, 0, 0, 0, 0]\n    assert candidate(nums = [7, 7, 7, 7, 0, 0, 0, 0, 7, 7]) == [14, 14, 14, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [2, 2, 2, 2, 2, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n    assert candidate(nums = [100, 200, 200, 100, 100, 200, 200, 100]) == [100, 400, 200, 400, 100, 0, 0, 0]\n    assert candidate(nums = [5, 5, 0, 5, 5, 5, 0, 0, 5, 5]) == [10, 10, 5, 10, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == [2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1000, 1000, 0, 500, 500, 0, 250, 250, 0]) == [2000, 1000, 500, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == [2, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4]) == [2, 4, 2, 6, 8, 8, 0, 0, 0, 0, 0]\n", "comparison": "exact"}, "public_tests": ["[1,2,2,1,1,0]", "[0,1]"], "hints": ["Iterate over the array and simulate the described process."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().applyOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:38+00:00", "tests_total": 123, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "two-pointers", "simulation"]}, "language": "python", "interface": {"raw_signature": "def applyOperations(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "applyOperations", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2461, "task_id": "maximum-sum-of-distinct-subarrays-with-length-k", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer k. Find the maximum subarray sum of all the subarrays of nums that meet the following conditions:\n\n- The length of the subarray is k, and\n- All the elements of the subarray are distinct.\n\nReturn the maximum subarray sum of all the subarrays that meet the conditions. If no subarray meets the conditions, return 0.\n\nA subarray is a contiguous non-empty sequence of elements within an array.\n\nExample 1:\n\nInput: nums = [1,5,4,2,9,9,9], k = 3\nOutput: 15\nExplanation: The subarrays of nums with length 3 are:\n- [1,5,4] which meets the requirements and has a sum of 10.\n- [5,4,2] which meets the requirements and has a sum of 11.\n- [4,2,9] which meets the requirements and has a sum of 15.\n- [2,9,9] which does not meet the requirements because the element 9 is repeated.\n- [9,9,9] which does not meet the requirements because the element 9 is repeated.\nWe return 15 because it is the maximum subarray sum of all the subarrays that meet the conditions\n\nExample 2:\n\nInput: nums = [4,4,4], k = 3\nOutput: 0\nExplanation: The subarrays of nums with length 3 are:\n- [4,4,4] which does not meet the requirements because the element 4 is repeated.\nWe return 0 because no subarrays meet the conditions.\n\nConstraints:\n\n- 1 <= k <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [1, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 40\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 5\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 6\n    assert candidate(nums = [1, 2, 2, 1, 3, 4, 5, 6],k = 4) == 18\n    assert candidate(nums = [1, 2, 2, 3, 4, 5],k = 4) == 14\n    assert candidate(nums = [1, 2, 2, 1, 3, 4, 5, 6, 7, 8],k = 4) == 26\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 40\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 3) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 1) == 50\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == 9\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1],k = 6) == 45\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 5) == 150\n    assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9],k = 4) == 30\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 40\n    assert candidate(nums = [1, 5, 4, 2, 9, 9, 9],k = 3) == 15\n    assert candidate(nums = [4, 4, 4],k = 3) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n    assert candidate(nums = [100000, 100000, 100000, 100000, 100000],k = 3) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 4) == 140\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 34\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],k = 5) == 450\n    assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11],k = 5) == 0\n    assert candidate(nums = [5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2],k = 5) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7],k = 8) == 44\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],k = 6) == 27\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 7) == 0\n    assert candidate(nums = [1, 2, 3, 2, 4, 5, 6, 5, 7, 8, 9],k = 4) == 29\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 300\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 30) == 465\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 155\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 0\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 5) == 499990\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 0\n    assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 15) == 0\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n    assert candidate(nums = [3, 1, 2, 3, 4, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 155\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 15) == 1200\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 40\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 4) == 22\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 8) == 442\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 50) == 0\n    assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 3) == 0\n    assert candidate(nums = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 7) == 0\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5],k = 10) == 5500\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 345\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 20\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 9) == 45\n    assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],k = 5) == 499990\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 2) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 65\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 210\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8],k = 5) == 35\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 155\n    assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n    assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11],k = 5) == 0\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 6\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 5) == 0\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35],k = 20) == 510\n    assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 155\n    assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11],k = 6) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],k = 5) == 45\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 35\n    assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 6, 5, 4, 7, 8, 9, 8, 7, 10, 11, 12, 11, 10],k = 7) == 0\n    assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 34\n    assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5],k = 5) == 15\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 11) == 0\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 5) == 35\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 5) == 6500\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == 0\n    assert candidate(nums = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],k = 8) == 84\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 10) == 255\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == 105\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 90\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 84\n    assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 4) == 0\n    assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 550\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 15) == 270\n    assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 5, 5, 5, 5],k = 4) == 0\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 45\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 155\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],k = 3) == 0\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 4000\n    assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 10) == 0\n    assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 40\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == 0\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 9, 10],k = 5) == 35\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 55\n    assert candidate(nums = [3, 3, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 6) == 57\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n    assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 15],k = 4) == 54\n", "comparison": "exact"}, "public_tests": ["[1,5,4,2,9,9,9]\n3", "[4,4,4]\n3"], "hints": ["Which elements change when moving from the subarray of size k that ends at index i to the subarray of size k that ends at index i + 1?", "Only two elements change, the element at i + 1 is added into the subarray, and the element at i - k + 1 gets removed from the subarray.", "Iterate through each subarray of size k and keep track of the sum of the subarray and the frequency of each element."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumSubarraySum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:41+00:00", "tests_total": 102, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "hash-table", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def maximumSubarraySum(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "maximumSubarraySum", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2462, "task_id": "total-cost-to-hire-k-workers", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array costs where costs[i] is the cost of hiring the i^th worker.\n\nYou are also given two integers k and candidates. We want to hire exactly k workers according to the following rules:\n\n- You will run k sessions and hire exactly one worker in each session.\n- In each hiring session, choose the worker with the lowest cost from either the first candidates workers or the last candidates workers. Break the tie by the smallest index.\n  - For example, if costs = [3,2,7,7,1,2] and candidates = 2, then in the first hiring session, we will choose the 4^th worker because they have the lowest cost [3,2,7,7,1,2].\n  - In the second hiring session, we will choose 1^st worker because they have the same lowest cost as 4^th worker but they have the smallest index [3,2,7,7,2]. Please note that the indexing may be changed in the process.\n- If there are fewer than candidates workers remaining, choose the worker with the lowest cost among them. Break the tie by the smallest index.\n- A worker can only be chosen once.\n\nReturn the total cost to hire exactly k workers.\n\nExample 1:\n\nInput: costs = [17,12,10,2,7,2,11,20,8], k = 3, candidates = 4\nOutput: 11\nExplanation: We hire 3 workers in total. The total cost is initially 0.\n- In the first hiring round we choose the worker from [17,12,10,2,7,2,11,20,8]. The lowest cost is 2, and we break the tie by the smallest index, which is 3. The total cost = 0 + 2 = 2.\n- In the second hiring round we choose the worker from [17,12,10,7,2,11,20,8]. The lowest cost is 2 (index 4). The total cost = 2 + 2 = 4.\n- In the third hiring round we choose the worker from [17,12,10,7,11,20,8]. The lowest cost is 7 (index 3). The total cost = 4 + 7 = 11. Notice that the worker with index 3 was common in the first and last four workers.\nThe total hiring cost is 11.\n\nExample 2:\n\nInput: costs = [1,2,4,1], k = 3, candidates = 3\nOutput: 4\nExplanation: We hire 3 workers in total. The total cost is initially 0.\n- In the first hiring round we choose the worker from [1,2,4,1]. The lowest cost is 1, and we break the tie by the smallest index, which is 0. The total cost = 0 + 1 = 1. Notice that workers with index 1 and 2 are common in the first and last 3 workers.\n- In the second hiring round we choose the worker from [2,4,1]. The lowest cost is 1 (index 2). The total cost = 1 + 1 = 2.\n- In the third hiring round there are less than three candidates. We choose the worker from the remaining workers [2,4]. The lowest cost is 2 (index 0). The total cost = 2 + 2 = 4.\nThe total hiring cost is 4.\n\nConstraints:\n\n- 1 <= costs.length <= 10^5\n- 1 <= costs[i] <= 10^5\n- 1 <= k, candidates <= costs.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(costs = [10, 10, 10, 10, 10],k = 4,candidates = 2) == 40\n    assert candidate(costs = [10, 10, 10, 10, 10],k = 5,candidates = 5) == 50\n    assert candidate(costs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5,candidates = 5) == 10\n    assert candidate(costs = [5, 4, 3, 2, 1],k = 5,candidates = 1) == 15\n    assert candidate(costs = [5, 4, 3, 2, 1],k = 3,candidates = 1) == 6\n    assert candidate(costs = [5, 5, 5, 5],k = 2,candidates = 2) == 10\n    assert candidate(costs = [10, 20, 30, 40, 50],k = 5,candidates = 5) == 150\n    assert candidate(costs = [17, 12, 10, 2, 7, 2, 11, 20, 8],k = 3,candidates = 4) == 11\n    assert candidate(costs = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 10,candidates = 10) == 90\n    assert candidate(costs = [3, 2, 7, 7, 1, 2],k = 2,candidates = 2) == 3\n    assert candidate(costs = [10, 20, 30, 40, 50],k = 2,candidates = 3) == 30\n    assert candidate(costs = [1, 2, 4, 1],k = 3,candidates = 3) == 4\n    assert candidate(costs = [10, 20, 30, 40, 50],k = 3,candidates = 1) == 60\n    assert candidate(costs = [5, 4, 3, 2, 1],k = 2,candidates = 1) == 3\n    assert candidate(costs = [25, 15, 30, 20, 10],k = 4,candidates = 2) == 70\n    assert candidate(costs = [31, 25, 72, 79, 74],k = 3,candidates = 2) == 128\n    assert candidate(costs = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5,candidates = 3) == 150\n    assert candidate(costs = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 7,candidates = 3) == 280\n    assert candidate(costs = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9,candidates = 4) == 45\n    assert candidate(costs = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20],k = 15,candidates = 15) == 300\n    assert candidate(costs = [50, 20, 30, 40, 10, 60, 70, 80, 90, 100],k = 6,candidates = 4) == 210\n    assert candidate(costs = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10,candidates = 4) == 55\n    assert candidate(costs = [1, 3, 2, 4, 5, 7, 6, 8, 10, 9, 11, 13, 12, 14, 15],k = 8,candidates = 4) == 36\n    assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,candidates = 3) == 5\n    assert candidate(costs = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15,candidates = 6) == 80\n    assert candidate(costs = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 10,candidates = 3) == 955\n    assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,candidates = 6) == 55\n    assert candidate(costs = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15,candidates = 8) == 120\n    assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10,candidates = 5) == 31\n    assert candidate(costs = [10, 20, 30, 15, 25, 5, 40, 35, 2, 1],k = 5,candidates = 3) == 33\n    assert candidate(costs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10,candidates = 2) == 55\n    assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,candidates = 5) == 10\n    assert candidate(costs = [9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9],k = 10,candidates = 5) == 26\n    assert candidate(costs = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 7,candidates = 3) == 28\n    assert candidate(costs = [50, 20, 30, 10, 40, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10,candidates = 4) == 550\n    assert candidate(costs = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 10,candidates = 5) == 110\n    assert candidate(costs = [5, 3, 8, 6, 2, 7, 4, 1, 10, 15, 20, 25, 30],k = 8,candidates = 4) == 36\n    assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 6,candidates = 5) == 210\n    assert candidate(costs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 7,candidates = 8) == 2800\n    assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10,candidates = 5) == 55\n    assert candidate(costs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,candidates = 10) == 55\n    assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7,candidates = 4) == 280\n    assert candidate(costs = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10],k = 15,candidates = 7) == 255\n    assert candidate(costs = [5, 3, 8, 6, 2, 7, 4, 1],k = 4,candidates = 4) == 10\n    assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15,candidates = 4) == 120\n    assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250],k = 15,candidates = 10) == 1200\n    assert candidate(costs = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7,candidates = 5) == 280\n    assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5,candidates = 3) == 150\n    assert candidate(costs = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 7,candidates = 5) == 280\n    assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5,candidates = 3) == 150\n    assert candidate(costs = [2, 1, 3, 4, 5, 6, 7, 8, 9],k = 5,candidates = 2) == 15\n    assert candidate(costs = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],k = 8,candidates = 5) == 19\n    assert candidate(costs = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 5,candidates = 2) == 15000\n    assert candidate(costs = [50, 40, 30, 20, 10, 1, 2, 3, 4, 5],k = 5,candidates = 2) == 15\n    assert candidate(costs = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10,candidates = 6) == 550\n    assert candidate(costs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 20,candidates = 10) == 400\n    assert candidate(costs = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 5,candidates = 2) == 150000\n    assert candidate(costs = [30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165],k = 10,candidates = 5) == 305\n    assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,candidates = 5) == 55\n    assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,candidates = 1) == 10\n    assert candidate(costs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5,candidates = 2) == 50\n    assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7,candidates = 6) == 280\n    assert candidate(costs = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15,candidates = 7) == 205\n    assert candidate(costs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10,candidates = 5) == 100\n    assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10,candidates = 5) == 55\n    assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7,candidates = 5) == 280\n    assert candidate(costs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8,candidates = 5) == 36\n    assert candidate(costs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 10,candidates = 6) == 110\n    assert candidate(costs = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 12],k = 6,candidates = 4) == 21\n    assert candidate(costs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5,candidates = 2) == 50\n    assert candidate(costs = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 10,candidates = 1) == 5500\n    assert candidate(costs = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5,candidates = 2) == 150\n    assert candidate(costs = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5,candidates = 5) == 15\n    assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5,candidates = 3) == 150\n    assert candidate(costs = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 5,candidates = 2) == 18\n    assert candidate(costs = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 10,candidates = 5) == 550000\n    assert candidate(costs = [5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2],k = 10,candidates = 5) == 23\n    assert candidate(costs = [5, 1, 4, 2, 3],k = 3,candidates = 1) == 9\n    assert candidate(costs = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10,candidates = 5) == 55\n    assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,candidates = 5) == 55\n    assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,candidates = 5) == 10\n    assert candidate(costs = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15,candidates = 6) == 120\n    assert candidate(costs = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 10,candidates = 10) == 1000\n    assert candidate(costs = [5, 3, 8, 6, 2, 7, 4, 1],k = 4,candidates = 2) == 10\n    assert candidate(costs = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 7,candidates = 4) == 700\n    assert candidate(costs = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],k = 8,candidates = 4) == 19\n    assert candidate(costs = [10, 5, 15, 20, 25, 30, 35, 40, 45, 50],k = 5,candidates = 3) == 75\n    assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 25,candidates = 5) == 325\n    assert candidate(costs = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3,candidates = 2) == 6\n    assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,candidates = 2) == 10\n    assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 15,candidates = 10) == 120\n    assert candidate(costs = [50, 40, 30, 20, 10, 10, 20, 30, 40, 50],k = 5,candidates = 5) == 90\n    assert candidate(costs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5,candidates = 3) == 1500\n    assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15,candidates = 5) == 15\n    assert candidate(costs = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5,candidates = 4) == 150\n    assert candidate(costs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 10,candidates = 5) == 275\n    assert candidate(costs = [1, 3, 2, 4, 5, 7, 6, 9, 8, 10, 12, 11, 14, 13, 15, 17, 16, 19, 18, 20],k = 10,candidates = 5) == 55\n", "comparison": "exact"}, "public_tests": ["[17,12,10,2,7,2,11,20,8]\n3\n4", "[1,2,4,1]\n3\n3"], "hints": ["Maintain two minheaps: one for the left and one for the right.", "Compare the top element from two heaps and remove the appropriate one.", "Add a new element to the heap and maintain its size as k."], "metadata": {"canonical_parameter_names": ["costs", "k", "candidates"], "leetcode_dataset_entry_point": "Solution().totalCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:43+00:00", "tests_total": 99, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "two-pointers", "heap-priority-queue", "simulation"]}, "language": "python", "interface": {"raw_signature": "def totalCost(self, costs: list[int], k: int, candidates: int) -> int:", "container": "Solution", "callable": "totalCost", "parameters": [{"name": "costs", "type": "list[int]"}, {"name": "k", "type": "int"}, {"name": "candidates", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2463, "task_id": "minimum-total-distance-traveled", "difficulty": "Hard", "problem_description": "There are some robots and factories on the X-axis. You are given an integer array robot where robot[i] is the position of the i^th robot. You are also given a 2D integer array factory where factory[j] = [position_j, limit_j] indicates that position_j is the position of the j^th factory and that the j^th factory can repair at most limit_j robots.\n\nThe positions of each robot are unique. The positions of each factory are also unique. Note that a robot can be in the same position as a factory initially.\n\nAll the robots are initially broken; they keep moving in one direction. The direction could be the negative or the positive direction of the X-axis. When a robot reaches a factory that did not reach its limit, the factory repairs the robot, and it stops moving.\n\nAt any moment, you can set the initial direction of moving for some robot. Your target is to minimize the total distance traveled by all the robots.\n\nReturn the minimum total distance traveled by all the robots. The test cases are generated such that all the robots can be repaired.\n\nNote that\n\n- All robots move at the same speed.\n- If two robots move in the same direction, they will never collide.\n- If two robots move in opposite directions and they meet at some point, they do not collide. They cross each other.\n- If a robot passes by a factory that reached its limits, it crosses it as if it does not exist.\n- If the robot moved from a position x to a position y, the distance it moved is |y - x|.\n\nExample 1:\n\nInput: robot = [0,4,6], factory = [[2,2],[6,2]]\nOutput: 4\nExplanation: As shown in the figure:\n- The first robot at position 0 moves in the positive direction. It will be repaired at the first factory.\n- The second robot at position 4 moves in the negative direction. It will be repaired at the first factory.\n- The third robot at position 6 will be repaired at the second factory. It does not need to move.\nThe limit of the first factory is 2, and it fixed 2 robots.\nThe limit of the second factory is 2, and it fixed 1 robot.\nThe total distance is |2 - 0| + |2 - 4| + |6 - 6| = 4. It can be shown that we cannot achieve a better total distance than 4.\n\nExample 2:\n\nInput: robot = [1,-1], factory = [[-2,1],[2,1]]\nOutput: 2\nExplanation: As shown in the figure:\n- The first robot at position 1 moves in the positive direction. It will be repaired at the second factory.\n- The second robot at position -1 moves in the negative direction. It will be repaired at the first factory.\nThe limit of the first factory is 1, and it fixed 1 robot.\nThe limit of the second factory is 1, and it fixed 1 robot.\nThe total distance is |2 - 1| + |(-2) - (-1)| = 2. It can be shown that we cannot achieve a better total distance than 2.\n\nConstraints:\n\n- 1 <= robot.length, factory.length <= 100\n- factory[j].length == 2\n- -10^9 <= robot[i], position_j <= 10^9\n- 0 <= limit_j <= robot.length\n- The input will be generated such that it is always possible to repair every robot.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(robot = [5, 1, 3],factory = [[2, 3]]) == 5\n    assert candidate(robot = [5, 5, 5, 5],factory = [[5, 4]]) == 0\n    assert candidate(robot = [-3, 0, 3],factory = [[-2, 1], [2, 1], [5, 2]]) == 5\n    assert candidate(robot = [-1, -3, 2, 4, 5],factory = [[-2, 1], [2, 2], [6, 2]]) == 7\n    assert candidate(robot = [-5, -2, 0, 2, 5],factory = [[-3, 2], [1, 3]]) == 9\n    assert candidate(robot = [5, 8, 15],factory = [[10, 2], [16, 1]]) == 8\n    assert candidate(robot = [10, 20, 30, 40],factory = [[5, 2], [15, 2], [25, 2]]) == 30\n    assert candidate(robot = [-10, 0, 10],factory = [[-5, 1], [0, 2], [5, 1]]) == 10\n    assert candidate(robot = [5, 2, -5],factory = [[-2, 2], [2, 2]]) == 6\n    assert candidate(robot = [10, -10, 0],factory = [[0, 3]]) == 20\n    assert candidate(robot = [0, 4, 6],factory = [[2, 2], [6, 2]]) == 4\n    assert candidate(robot = [3, 7, 12, 15],factory = [[2, 3], [10, 2]]) == 13\n    assert candidate(robot = [-3, 0, 3],factory = [[-2, 1], [2, 2]]) == 4\n    assert candidate(robot = [1, -1],factory = [[-2, 1], [2, 1]]) == 2\n    assert candidate(robot = [-20, -10, 0, 10, 20],factory = [[-15, 2], [0, 1], [15, 2]]) == 20\n    assert candidate(robot = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],factory = [[-5, 2], [-15, 2], [-25, 2], [-35, 2], [-45, 2], [-55, 2], [-65, 2], [-75, 2], [-85, 2], [-95, 2]]) == 50\n    assert candidate(robot = [-15, -10, -5, 0, 5, 10, 15],factory = [[-12, 2], [-7, 2], [-2, 2], [3, 2], [8, 2], [13, 2]]) == 15\n    assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[5, 3], [10, 4], [15, 3]]) == 45\n    assert candidate(robot = [-1, -2, -3, -4, -5],factory = [[-10, 3], [0, 2], [10, 1]]) == 21\n    assert candidate(robot = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],factory = [[5, 3], [15, 3], [25, 3], [35, 3], [45, 3], [55, 3], [65, 3], [75, 3], [85, 3], [95, 3], [105, 3], [115, 3], [125, 3], [135, 3]]) == 75\n    assert candidate(robot = [0, 2, 4, 6, 8, 10],factory = [[1, 1], [3, 1], [5, 1], [7, 1], [9, 1], [11, 1]]) == 6\n    assert candidate(robot = [100, 200, 300, 400, 500],factory = [[50, 1], [150, 2], [250, 2], [350, 2], [450, 1], [550, 1]]) == 250\n    assert candidate(robot = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],factory = [[0, 2], [6, 3], [12, 3], [18, 2]]) == 16\n    assert candidate(robot = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],factory = [[0, 5], [5, 5]]) == 20\n    assert candidate(robot = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],factory = [[-3, 3], [0, 4], [3, 3]]) == 12\n    assert candidate(robot = [-5, 0, 5, 10, 15, 20, 25, 30, 35, 40],factory = [[-10, 2], [5, 3], [20, 3], [35, 2]]) == 50\n    assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[0, 3], [5, 4], [10, 3]]) == 13\n    assert candidate(robot = [-100, -50, 0, 50, 100],factory = [[-75, 2], [-25, 1], [25, 1], [75, 2]]) == 125\n    assert candidate(robot = [10, 20, 30, 40, 50, 60, 70, 80, 90],factory = [[0, 3], [10, 3], [20, 3], [30, 3], [40, 3], [50, 3], [60, 3], [70, 3], [80, 3], [90, 3]]) == 0\n    assert candidate(robot = [-2, -1, 0, 1, 2, 3, 4],factory = [[-3, 2], [0, 3], [3, 2]]) == 7\n    assert candidate(robot = [-10, -5, 0, 5, 10, 15, 20],factory = [[-20, 1], [-10, 2], [0, 3], [10, 2], [20, 1]]) == 15\n    assert candidate(robot = [-100, -50, 0, 50, 100],factory = [[-75, 2], [0, 2], [75, 2]]) == 100\n    assert candidate(robot = [-100, -50, 0, 50, 100, 150],factory = [[-75, 3], [25, 2], [125, 2]]) == 150\n    assert candidate(robot = [-100, -50, 0, 50, 100, 150, 200],factory = [[-75, 2], [-25, 2], [25, 2], [75, 2], [125, 2], [175, 2]]) == 175\n    assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],factory = [[0, 5], [5, 5], [10, 5], [15, 5]]) == 60\n    assert candidate(robot = [-20, -10, 0, 10, 20],factory = [[-15, 1], [-5, 2], [5, 3], [15, 1]]) == 25\n    assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9],factory = [[2, 3], [5, 3], [8, 3]]) == 6\n    assert candidate(robot = [-20, -10, 0, 10, 20],factory = [[-15, 2], [0, 3], [15, 2]]) == 20\n    assert candidate(robot = [100, 200, 300, 400, 500],factory = [[50, 2], [150, 1], [250, 2], [350, 1], [450, 1]]) == 250\n    assert candidate(robot = [1, 3, 5, 7, 9, 11],factory = [[2, 2], [6, 2], [10, 2]]) == 6\n    assert candidate(robot = [1, 3, 5, 7, 9],factory = [[2, 2], [4, 2], [6, 2], [8, 2], [10, 1]]) == 5\n    assert candidate(robot = [10, 20, 30, 40, 50, 60],factory = [[15, 2], [35, 2], [55, 2]]) == 30\n    assert candidate(robot = [-20, -10, 0, 10, 20],factory = [[-15, 2], [-5, 3], [5, 2], [15, 1]]) == 25\n    assert candidate(robot = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],factory = [[0, 10]]) == 10\n    assert candidate(robot = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10],factory = [[-105, 2], [-95, 2], [-85, 2], [-75, 2], [-65, 2], [-55, 2], [-45, 2], [-35, 2], [-25, 2], [-15, 2]]) == 50\n    assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[0, 10]]) == 55\n    assert candidate(robot = [10, 20, 30, 40],factory = [[15, 2], [25, 2], [35, 2]]) == 20\n    assert candidate(robot = [-10, -5, 0, 5, 10, 15, 20],factory = [[-7, 2], [-2, 2], [3, 2], [8, 2]]) == 35\n    assert candidate(robot = [-20, -10, 0, 10, 20],factory = [[-15, 2], [0, 3], [15, 1]]) == 25\n    assert candidate(robot = [-20, -15, -10, -5, 0, 5, 10, 15, 20],factory = [[-15, 2], [-10, 2], [-5, 2], [0, 2], [5, 2], [10, 2], [15, 2]]) == 10\n    assert candidate(robot = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],factory = [[-6, 3], [0, 5], [6, 3]]) == 18\n    assert candidate(robot = [-5, -3, -1, 1, 3, 5],factory = [[-10, 1], [-5, 2], [0, 3], [5, 2], [10, 1]]) == 6\n    assert candidate(robot = [1, 3, 5, 7, 9],factory = [[0, 2], [4, 2], [8, 2]]) == 5\n    assert candidate(robot = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],factory = [[3, 3], [9, 3], [15, 3], [21, 3]]) == 25\n    assert candidate(robot = [10, 10, 10, 10],factory = [[10, 1], [10, 1], [10, 1], [10, 1]]) == 0\n    assert candidate(robot = [1, 4, 7, 10, 13, 16, 19, 22, 25],factory = [[3, 3], [9, 3], [15, 3], [21, 3]]) == 16\n    assert candidate(robot = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],factory = [[5, 2], [15, 2], [25, 2], [35, 2], [45, 2], [55, 2], [65, 2], [75, 2], [85, 2], [95, 2]]) == 50\n    assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[0, 2], [5, 3], [10, 5]]) == 16\n    assert candidate(robot = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],factory = [[150, 3], [500, 4], [850, 3]]) == 900\n    assert candidate(robot = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],factory = [[-5, 5], [0, 5], [5, 5]]) == 25\n    assert candidate(robot = [-5, 0, 5, 10, 15, 20],factory = [[-10, 1], [0, 3], [10, 2], [20, 1]]) == 15\n    assert candidate(robot = [-50, -25, 0, 25, 50],factory = [[-75, 3], [0, 2], [75, 1]]) == 125\n    assert candidate(robot = [-10, -5, 0, 5, 10],factory = [[-15, 2], [-10, 1], [0, 3], [10, 2], [15, 1]]) == 10\n    assert candidate(robot = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],factory = [[0, 5], [5, 5], [10, 5], [15, 5]]) == 40\n    assert candidate(robot = [-100, -200, -300, -400, -500],factory = [[-50, 2], [-150, 1], [-250, 2], [-350, 1], [-450, 1]]) == 250\n    assert candidate(robot = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10],factory = [[-95, 2], [-85, 2], [-75, 2], [-65, 2], [-55, 2], [-45, 2], [-35, 2], [-25, 2], [-15, 2], [-5, 2]]) == 50\n    assert candidate(robot = [-100, -50, 0, 50, 100],factory = [[-75, 2], [-25, 2], [25, 2], [75, 1]]) == 125\n    assert candidate(robot = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],factory = [[-10, 6], [0, 5]]) == 60\n    assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[0, 5], [10, 5]]) == 25\n    assert candidate(robot = [-10, -5, 0, 5, 10, 15, 20, 25],factory = [[-15, 2], [0, 3], [15, 3], [25, 1]]) == 25\n    assert candidate(robot = [100, 200, 300, 400, 500],factory = [[50, 1], [150, 2], [250, 2], [350, 1], [450, 1]]) == 250\n    assert candidate(robot = [-10, -5, 0, 5, 10, 15],factory = [[-8, 2], [2, 3], [12, 2]]) == 15\n    assert candidate(robot = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],factory = [[-5, 5], [5, 5]]) == 50\n    assert candidate(robot = [0, 10, 20, 30, 40, 50, 60],factory = [[5, 3], [15, 3], [25, 3], [35, 3], [45, 3]]) == 45\n    assert candidate(robot = [-1, 0, 1],factory = [[-2, 1], [2, 1], [0, 1]]) == 2\n    assert candidate(robot = [-9, -6, -3, 0, 3, 6, 9],factory = [[-8, 2], [-2, 2], [2, 2], [8, 1]]) == 12\n    assert candidate(robot = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],factory = [[0, 5], [10, 5], [20, 5]]) == 26\n    assert candidate(robot = [0, 10, 20, 30, 40, 50, 60],factory = [[5, 1], [15, 2], [25, 2], [35, 1], [45, 2], [55, 1]]) == 35\n    assert candidate(robot = [-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[-4, 3], [2, 4], [7, 3], [11, 3]]) == 22\n    assert candidate(robot = [-1, -2, -3, -4, -5],factory = [[-3, 3], [0, 2]]) == 6\n    assert candidate(robot = [0, 2, 4, 6, 8, 10, 12],factory = [[1, 2], [5, 2], [9, 2], [13, 1]]) == 7\n    assert candidate(robot = [100, 200, 300, 400, 500],factory = [[50, 1], [150, 1], [250, 1], [350, 1], [450, 1]]) == 250\n    assert candidate(robot = [-5, -3, -1, 1, 3, 5],factory = [[-10, 1], [-6, 2], [-2, 2], [2, 2], [6, 1]]) == 6\n    assert candidate(robot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],factory = [[5, 5], [15, 5]]) == 45\n    assert candidate(robot = [-20, -10, 0, 10, 20],factory = [[-25, 2], [-15, 3], [-5, 2], [5, 3], [15, 2], [25, 1]]) == 25\n    assert candidate(robot = [-50, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50],factory = [[-60, 3], [-40, 4], [-20, 4], [0, 4], [20, 4], [40, 3]]) == 60\n    assert candidate(robot = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],factory = [[0, 2], [4, 2], [8, 2], [12, 2], [16, 2]]) == 20\n    assert candidate(robot = [1, 3, 5, 7, 9],factory = [[0, 3], [6, 2], [12, 1]]) == 9\n    assert candidate(robot = [-100, -50, 0, 50, 100],factory = [[-150, 2], [-100, 2], [-50, 2], [0, 2], [50, 2], [100, 2], [150, 2]]) == 0\n    assert candidate(robot = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],factory = [[0, 2], [5, 2], [10, 2], [15, 2], [20, 2]]) == 14\n", "comparison": "exact"}, "public_tests": ["[0,4,6]\n[[2,2],[6,2]]", "[1,-1]\n[[-2,1],[2,1]]"], "hints": ["Sort robots and factories by their positions.", "After sorting, notice that each factory should repair some subsegment of robots.", "Find the minimum total distance to repair first i robots with first j factories."], "metadata": {"canonical_parameter_names": ["robot", "factory"], "leetcode_dataset_entry_point": "Solution().minimumTotalDistance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:45+00:00", "tests_total": 100, "tests_dropped": 10, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "dynamic-programming", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minimumTotalDistance(self, robot: list[int], factory: list[list[int]]) -> int:", "container": "Solution", "callable": "minimumTotalDistance", "parameters": [{"name": "robot", "type": "list[int]"}, {"name": "factory", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2465, "task_id": "number-of-distinct-averages", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums of even length.\n\nAs long as nums is not empty, you must repetitively:\n\n- Find the minimum number in nums and remove it.\n- Find the maximum number in nums and remove it.\n- Calculate the average of the two removed numbers.\n\nThe average of two numbers a and b is (a + b) / 2.\n\n- For example, the average of 2 and 3 is (2 + 3) / 2 = 2.5.\n\nReturn the number of distinct averages calculated using the above process.\n\nNote that when there is a tie for a minimum or maximum number, any can be removed.\n\nExample 1:\n\nInput: nums = [4,1,4,0,3,5]\nOutput: 2\nExplanation:\n1. Remove 0 and 5, and the average is (0 + 5) / 2 = 2.5. Now, nums = [4,1,4,3].\n2. Remove 1 and 4. The average is (1 + 4) / 2 = 2.5, and nums = [4,3].\n3. Remove 3 and 4, and the average is (3 + 4) / 2 = 3.5.\nSince there are 2 distinct numbers among 2.5, 2.5, and 3.5, we return 2.\n\nExample 2:\n\nInput: nums = [1,100]\nOutput: 1\nExplanation:\nThere is only one average to be calculated after removing 1 and 100, so we return 1.\n\nConstraints:\n\n- 2 <= nums.length <= 100\n- nums.length is even.\n- 0 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 1\n    assert candidate(nums = [50, 50, 50, 50]) == 1\n    assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0]) == 1\n    assert candidate(nums = [1, 2, 3, 4]) == 1\n    assert candidate(nums = [0, 100, 50, 50, 25, 75]) == 1\n    assert candidate(nums = [1, 100]) == 1\n    assert candidate(nums = [4, 1, 4, 0, 3, 5]) == 2\n    assert candidate(nums = [5, 5, 5, 5]) == 1\n    assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6]) == 1\n    assert candidate(nums = [99, 1, 98, 2, 97, 3]) == 1\n    assert candidate(nums = [0, 0, 0, 0]) == 1\n    assert candidate(nums = [0, 0, 0, 0, 0, 0]) == 1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5]) == 1\n    assert candidate(nums = [6, 6, 6, 6, 6, 6]) == 1\n    assert candidate(nums = [99, 1, 98, 2, 97, 3, 96, 4]) == 1\n    assert candidate(nums = [1, 3, 2, 4, 6, 5]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == 1\n    assert candidate(nums = [100, 0, 50, 50, 25, 75, 20, 80]) == 1\n    assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2]) == 1\n    assert candidate(nums = [0, 100, 50, 50]) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 1\n    assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 1\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50]) == 1\n    assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 1\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93]) == 1\n    assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6]) == 6\n    assert candidate(nums = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94, 6]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 1\n    assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97]) == 1\n    assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 1\n    assert candidate(nums = [25, 75, 20, 80, 15, 85, 10, 90, 5, 95]) == 1\n    assert candidate(nums = [33, 33, 33, 67, 67, 67]) == 1\n    assert candidate(nums = [12, 34, 56, 78, 90, 24, 46, 68]) == 1\n    assert candidate(nums = [0, 100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93]) == 1\n    assert candidate(nums = [1, 1, 1, 99, 99, 99, 2, 2, 2, 98, 98, 98]) == 1\n    assert candidate(nums = [0, 1, 2, 99, 98, 97, 96, 95]) == 2\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 1\n    assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5]) == 1\n    assert candidate(nums = [1, 99, 2, 98, 3, 97, 4, 96, 5, 95]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 100, 100, 100, 100]) == 1\n    assert candidate(nums = [23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n    assert candidate(nums = [88, 92, 77, 65, 99, 100, 42, 33, 21, 11, 55, 66, 78, 89, 90, 91]) == 7\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 1\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 1\n    assert candidate(nums = [5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == 1\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 1\n    assert candidate(nums = [1, 2, 3, 3, 2, 1, 4, 5, 5, 4, 6, 7, 7, 6, 8, 9, 9, 8]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 1\n    assert candidate(nums = [40, 20, 60, 80, 100, 0, 50, 30, 90, 70]) == 2\n    assert candidate(nums = [100, 0, 100, 0, 100, 0, 100, 0]) == 1\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 1\n    assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10]) == 2\n    assert candidate(nums = [50, 40, 30, 20, 10, 0, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 15, 35, 55, 75]) == 4\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 1\n    assert candidate(nums = [100, 0, 50, 50, 25, 75, 20, 80]) == 1\n    assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 1\n    assert candidate(nums = [23, 45, 12, 67, 89, 34, 56, 78, 90, 10]) == 2\n    assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 1\n    assert candidate(nums = [99, 88, 77, 66, 55, 44, 33, 22, 11, 0]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 1\n    assert candidate(nums = [2, 3, 1, 4, 6, 5, 8, 7]) == 1\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n    assert candidate(nums = [8, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 1\n    assert candidate(nums = [1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10, 90]) == 1\n    assert candidate(nums = [50, 40, 30, 20, 10, 0, 100, 90, 80, 70, 60, 55]) == 2\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n    assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92]) == 1\n    assert candidate(nums = [50, 1, 50, 2, 50, 3, 50, 4]) == 4\n    assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n    assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 1\n    assert candidate(nums = [1, 99, 2, 98, 3, 97, 4, 96]) == 1\n    assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 1\n    assert candidate(nums = [99, 1, 98, 2, 97, 3, 96, 4]) == 1\n    assert candidate(nums = [9, 2, 5, 7, 3, 8, 10, 1]) == 2\n    assert candidate(nums = [1, 1, 1, 1, 100, 100, 100, 100, 50, 50, 50, 50]) == 2\n    assert candidate(nums = [49, 51, 24, 76, 38, 62, 19, 81, 9, 90]) == 2\n    assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 1\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 1\n    assert candidate(nums = [0, 100, 50, 51, 49, 52, 48, 53, 47, 54]) == 2\n    assert candidate(nums = [50, 40, 30, 20, 10, 0, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 3\n    assert candidate(nums = [25, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 27, 28, 28, 28, 28]) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n    assert candidate(nums = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10]) == 1\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89]) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 30]) == 2\n    assert candidate(nums = [50, 20, 30, 10, 40, 60, 80, 70]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 1\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10]) == 1\n    assert candidate(nums = [100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0]) == 1\n    assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 1\n    assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 1\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 1\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80]) == 1\n", "comparison": "exact"}, "public_tests": ["[4,1,4,0,3,5]", "[1,100]"], "hints": ["Try sorting the array.", "Store the averages being calculated, and find the distinct ones."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().distinctAverages", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:50+00:00", "tests_total": 113, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "hash-table", "two-pointers", "sorting"]}, "language": "python", "interface": {"raw_signature": "def distinctAverages(self, nums: list[int]) -> int:", "container": "Solution", "callable": "distinctAverages", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2466, "task_id": "count-ways-to-build-good-strings", "difficulty": "Medium", "problem_description": "Given the integers zero, one, low, and high, we can construct a string by starting with an empty string, and then at each step perform either of the following:\n\n- Append the character '0' zero times.\n- Append the character '1' one times.\n\nThis can be performed any number of times.\n\nA good string is a string constructed by the above process having a length between low and high (inclusive).\n\nReturn the number of different good strings that can be constructed satisfying these properties. Since the answer can be large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: low = 3, high = 3, zero = 1, one = 1\nOutput: 8\nExplanation:\nOne possible valid good string is \"011\".\nIt can be constructed as follows: \"\" -> \"0\" -> \"01\" -> \"011\".\nAll binary strings from \"000\" to \"111\" are good strings in this example.\n\nExample 2:\n\nInput: low = 2, high = 3, zero = 1, one = 2\nOutput: 5\nExplanation: The good strings are \"00\", \"11\", \"000\", \"110\", and \"011\".\n\nConstraints:\n\n- 1 <= low <= high <= 10^5\n- 1 <= zero, one <= low\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(low = 5,high = 7,zero = 1,one = 1) == 224\n    assert candidate(low = 100,high = 200,zero = 10,one = 20) == 28513\n    assert candidate(low = 5,high = 10,zero = 2,one = 4) == 16\n    assert candidate(low = 10,high = 15,zero = 3,one = 2) == 93\n    assert candidate(low = 5,high = 5,zero = 2,one = 3) == 2\n    assert candidate(low = 5,high = 10,zero = 3,one = 4) == 8\n    assert candidate(low = 1,high = 5,zero = 1,one = 1) == 62\n    assert candidate(low = 5,high = 5,zero = 2,one = 2) == 0\n    assert candidate(low = 4,high = 6,zero = 2,one = 2) == 12\n    assert candidate(low = 4,high = 4,zero = 2,one = 2) == 4\n    assert candidate(low = 2,high = 3,zero = 1,one = 2) == 5\n    assert candidate(low = 3,high = 7,zero = 3,one = 3) == 6\n    assert candidate(low = 50000,high = 50000,zero = 5000,one = 5000) == 1024\n    assert candidate(low = 7,high = 9,zero = 3,one = 2) == 12\n    assert candidate(low = 50,high = 100,zero = 5,one = 7) == 177635\n    assert candidate(low = 4,high = 6,zero = 2,one = 3) == 5\n    assert candidate(low = 6,high = 10,zero = 2,one = 3) == 21\n    assert candidate(low = 20,high = 25,zero = 5,one = 6) == 17\n    assert candidate(low = 10,high = 15,zero = 2,one = 2) == 224\n    assert candidate(low = 10,high = 100,zero = 5,one = 7) == 178096\n    assert candidate(low = 4,high = 8,zero = 2,one = 2) == 28\n    assert candidate(low = 6,high = 10,zero = 3,one = 4) == 8\n    assert candidate(low = 5,high = 10,zero = 2,one = 3) == 23\n    assert candidate(low = 20,high = 30,zero = 3,one = 5) == 283\n    assert candidate(low = 3,high = 9,zero = 2,one = 2) == 28\n    assert candidate(low = 1,high = 10,zero = 1,one = 1) == 2046\n    assert candidate(low = 10,high = 15,zero = 3,one = 4) == 23\n    assert candidate(low = 10,high = 15,zero = 5,one = 6) == 5\n    assert candidate(low = 10,high = 15,zero = 4,one = 5) == 9\n    assert candidate(low = 5,high = 7,zero = 2,one = 3) == 7\n    assert candidate(low = 10,high = 15,zero = 2,one = 3) == 93\n    assert candidate(low = 10,high = 10,zero = 3,one = 4) == 3\n    assert candidate(low = 10,high = 15,zero = 1,one = 1) == 64512\n    assert candidate(low = 10,high = 10,zero = 5,one = 5) == 4\n    assert candidate(low = 50,high = 100,zero = 10,one = 15) == 444\n    assert candidate(low = 3,high = 3,zero = 1,one = 1) == 8\n    assert candidate(low = 10,high = 15,zero = 5,one = 5) == 12\n    assert candidate(low = 6,high = 8,zero = 4,one = 5) == 1\n    assert candidate(low = 1,high = 4,zero = 1,one = 1) == 30\n    assert candidate(low = 1,high = 100,zero = 1,one = 1) == 952742561\n", "comparison": "exact"}, "public_tests": ["3\n3\n1\n1", "2\n3\n1\n2"], "hints": ["Calculate the number of good strings with length less or equal to some constant x.", "Apply dynamic programming using the group size of consecutive zeros and ones."], "metadata": {"canonical_parameter_names": ["low", "high", "zero", "one"], "leetcode_dataset_entry_point": "Solution().countGoodStrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:52+00:00", "tests_total": 45, "tests_dropped": 5, "flags": [], "topic_tags": ["dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def countGoodStrings(self, low: int, high: int, zero: int, one: int) -> int:", "container": "Solution", "callable": "countGoodStrings", "parameters": [{"name": "low", "type": "int"}, {"name": "high", "type": "int"}, {"name": "zero", "type": "int"}, {"name": "one", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2467, "task_id": "most-profitable-path-in-a-tree", "difficulty": "Medium", "problem_description": "There is an undirected tree with n nodes labeled from 0 to n - 1, rooted at node 0. You are given a 2D integer array edges of length n - 1 where edges[i] = [a_i, b_i] indicates that there is an edge between nodes a_i and b_i in the tree.\n\nAt every node i, there is a gate. You are also given an array of even integers amount, where amount[i] represents:\n\n- the price needed to open the gate at node i, if amount[i] is negative, or,\n- the cash reward obtained on opening the gate at node i, otherwise.\n\nThe game goes on as follows:\n\n- Initially, Alice is at node 0 and Bob is at node bob.\n- At every second, Alice and Bob each move to an adjacent node. Alice moves towards some leaf node, while Bob moves towards node 0.\n- For every node along their path, Alice and Bob either spend money to open the gate at that node, or accept the reward. Note that:\n  - If the gate is already open, no price will be required, nor will there be any cash reward.\n  - If Alice and Bob reach the node simultaneously, they share the price/reward for opening the gate there. In other words, if the price to open the gate is c, then both Alice and Bob pay c / 2 each. Similarly, if the reward at the gate is c, both of them receive c / 2 each.\n- If Alice reaches a leaf node, she stops moving. Similarly, if Bob reaches node 0, he stops moving. Note that these events are independent of each other.\n\nReturn the maximum net income Alice can have if she travels towards the optimal leaf node.\n\nExample 1:\n\nInput: edges = [[0,1],[1,2],[1,3],[3,4]], bob = 3, amount = [-2,4,2,-4,6]\nOutput: 6\nExplanation:\nThe above diagram represents the given tree. The game goes as follows:\n- Alice is initially on node 0, Bob on node 3. They open the gates of their respective nodes.\n  Alice's net income is now -2.\n- Both Alice and Bob move to node 1.\n  Since they reach here simultaneously, they open the gate together and share the reward.\n  Alice's net income becomes -2 + (4 / 2) = 0.\n- Alice moves on to node 3. Since Bob already opened its gate, Alice's income remains unchanged.\n  Bob moves on to node 0, and stops moving.\n- Alice moves on to node 4 and opens the gate there. Her net income becomes 0 + 6 = 6.\nNow, neither Alice nor Bob can make any further moves, and the game ends.\nIt is not possible for Alice to get a higher net income.\n\nExample 2:\n\nInput: edges = [[0,1]], bob = 1, amount = [-7280,2350]\nOutput: -7280\nExplanation:\nAlice follows the path 0->1 whereas Bob follows the path 1->0.\nThus, Alice opens the gate at node 0 only. Hence, her net income is -7280.\n\nConstraints:\n\n- 2 <= n <= 10^5\n- edges.length == n - 1\n- edges[i].length == 2\n- 0 <= a_i, b_i < n\n- a_i != b_i\n- edges represents a valid tree.\n- 1 <= bob < n\n- amount.length == n\n- amount[i] is an even integer in the range [-10^4, 10^4].\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],bob = 3,amount = [10, 10, 10, 10, 10, 10, 10]) == 30\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],bob = 5,amount = [100, -50, -25, 200, -300, 150]) == 250\n    assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],bob = 7,amount = [100, 200, -300, 400, -500, 600, -700, 800]) == 400\n    assert candidate(edges = [[0, 1], [1, 2], [2, 3]],bob = 2,amount = [1, 2, 3, 4]) == 6\n    assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],bob = 5,amount = [-10, -10, -10, -10, -10, -10]) == -30\n    assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],bob = 4,amount = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 130\n    assert candidate(edges = [[0, 1], [1, 2], [2, 3], [2, 4], [4, 5]],bob = 5,amount = [1, 2, 3, 4, 5, 6]) == 8\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],bob = 4,amount = [-1, -2, -3, -4, -5, -6, -7]) == -2\n    assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],bob = 8,amount = [-5, -5, -5, -5, -5, -5, -5, -5, -5, -5]) == -8\n    assert candidate(edges = [[0, 1], [1, 2], [1, 3], [3, 4]],bob = 3,amount = [-2, 4, 2, -4, 6]) == 6\n    assert candidate(edges = [[0, 1]],bob = 1,amount = [-7280, 2350]) == -7280\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],bob = 5,amount = [-5, 2, -3, 4, -1, 6, -7]) == 1\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22]],bob = 16,amount = [-100, 200, -300, 400, -500, 600, -700, 800, -900, 1000, -1100, 1200, -1300, 1400, -1500, 1600, -1700, 1800, -1900, 2000, -2100, 2200, -2300]) == 2600\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],bob = 7,amount = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11]) == -3\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],bob = 7,amount = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11]) == 6\n    assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]],bob = 5,amount = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120, 130, -140]) == -20\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]],bob = 7,amount = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13]) == -3\n    assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [5, 17], [6, 18], [6, 19], [6, 20]],bob = 18,amount = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000, 1100]) == 1100\n    assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]],bob = 18,amount = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22]) == -5\n    assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27], [13, 28], [13, 29]],bob = 29,amount = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120, 130, -140, 150, -160, 170, -180, 190, -200, 210, -220, 230, -240, 250, -260, 270, -280, 290, -300]) == 380\n    assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]],bob = 15,amount = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300, -1400, 1500, -1600, 1700, -1800, 1900, -2000, 2100, -2200, 2300, -2400, 2500, -2600, 2700, -2800, 2900, -3000]) == -1100\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]],bob = 9,amount = [-10, -20, -30, 15, 25, -5, -15, 5, 20, -35, 40, -45, 50]) == 10\n    assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27], [13, 28], [13, 29]],bob = 26,amount = [-10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120, 130, -140, 150, -160, 170, -180, -190, -200, 210, -220, 230, -240, -250, -260, -270, -280, -290, -300]) == 360\n    assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11]],bob = 11,amount = [-5, 3, -7, 2, 4, -10, 6, -8, -9, 12, -15, 14]) == 10\n    assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],bob = 18,amount = [-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000]) == -5000\n    assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31]],bob = 31,amount = [5, -10, 15, -20, 25, -30, 35, -40, 45, -50, 55, -60, 65, -70, 75, -80, 85, -90, 95, -100, 105, -110, 115, -120, 125, -130, 135, -140, 145, -150, 155, -160]) == 200\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],bob = 13,amount = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15]) == 14\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],bob = 7,amount = [100, -50, 25, -10, 20, -15, 5, -5, -2, -3, -7]) == 130\n    assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17]],bob = 12,amount = [1000, -500, 250, -100, 200, -150, 50, -50, 20, -10, 20, -15, 5, -5, 2, -1, -3, 7]) == 1302\n    assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]],bob = 14,amount = [-50, 50, -40, 40, -30, 30, -20, 20, -10, 10, 0, -10, 10, -20, 20, -30]) == 20\n    assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]],bob = 12,amount = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 47\n    assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]],bob = 18,amount = [10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120, -130, -140, -150, -160, -170, -180, -190, -200]) == 150\n    assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]],bob = 12,amount = [100, -50, 30, -20, 25, -40, 15, 60, -60, 45, -35, 20, -80, 70, 90, -100]) == 190\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],bob = 10,amount = [-10, 15, 20, -25, 30, -35, 40, -45, 50, -55, 60, -65, 70, -75, 80]) == 130\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]],bob = 11,amount = [10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120, -130]) == 150\n    assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21]],bob = 15,amount = [-10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120, 130, -140, 150, -160, 170, -180, 190, -200, 210, -220]) == 310\n    assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11]],bob = 10,amount = [10, -2, -3, -4, -5, 6, 7, -8, -9, -10, 12, -11]) == 11\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13]],bob = 11,amount = [-100, 50, -25, 10, -20, 15, -5, 2, -1, -3, 7, -8, 9, -12]) == -38\n    assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]],bob = 12,amount = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130]) == -40\n", "comparison": "exact"}, "public_tests": ["[[0,1],[1,2],[1,3],[3,4]]\n3\n[-2,4,2,-4,6]", "[[0,1]]\n1\n[-7280,2350]"], "hints": ["Bob travels along a fixed path (from node “bob” to node 0).", "Calculate Alice’s distance to each node via DFS.", "We can calculate Alice’s score along a path ending at some node easily using Hints 1 and 2."], "metadata": {"canonical_parameter_names": ["edges", "bob", "amount"], "leetcode_dataset_entry_point": "Solution().mostProfitablePath", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:54+00:00", "tests_total": 50, "tests_dropped": 11, "flags": ["has_images"], "topic_tags": ["array", "tree", "depth-first-search", "breadth-first-search", "graph"]}, "language": "python", "interface": {"raw_signature": "def mostProfitablePath(self, edges: list[list[int]], bob: int, amount: list[int]) -> int:", "container": "Solution", "callable": "mostProfitablePath", "parameters": [{"name": "edges", "type": "list[list[int]]"}, {"name": "bob", "type": "int"}, {"name": "amount", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2468, "task_id": "split-message-based-on-limit", "difficulty": "Hard", "problem_description": "You are given a string, message, and a positive integer, limit.\n\nYou must split message into one or more parts based on limit. Each resulting part should have the suffix \"\", where \"b\" is to be replaced with the total number of parts and \"a\" is to be replaced with the index of the part, starting from 1 and going up to b. Additionally, the length of each resulting part (including its suffix) should be equal to limit, except for the last part whose length can be at most limit.\n\nThe resulting parts should be formed such that when their suffixes are removed and they are all concatenated in order, they should be equal to message. Also, the result should contain as few parts as possible.\n\nReturn the parts message would be split into as an array of strings. If it is impossible to split message as required, return an empty array.\n\nExample 1:\n\nInput: message = \"this is really a very awesome message\", limit = 9\nOutput: [\"thi<1/14>\",\"s i<2/14>\",\"s r<3/14>\",\"eal<4/14>\",\"ly <5/14>\",\"a v<6/14>\",\"ery<7/14>\",\" aw<8/14>\",\"eso<9/14>\",\"me<10/14>\",\" m<11/14>\",\"es<12/14>\",\"sa<13/14>\",\"ge<14/14>\"]\nExplanation:\nThe first 9 parts take 3 characters each from the beginning of message.\nThe next 5 parts take 2 characters each to finish splitting message.\nIn this example, each part, including the last, has length 9.\nIt can be shown it is not possible to split message into less than 14 parts.\n\nExample 2:\n\nInput: message = \"short message\", limit = 15\nOutput: [\"short mess<1/2>\",\"age<2/2>\"]\nExplanation:\nUnder the given constraints, the string can be split into two parts:\n- The first part comprises of the first 10 characters, and has a length 15.\n- The next part comprises of the last 3 characters, and has a length 8.\n\nConstraints:\n\n- 1 <= message.length <= 10^4\n- message consists only of lowercase English letters and ' '.\n- 1 <= limit <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(message = \"abcdefghij\",limit = 3) == []\n    assert candidate(message = \"abc\",limit = 5) == []\n    assert candidate(message = \"short message\",limit = 15) == ['short mess<1/2>', 'age<2/2>']\n    assert candidate(message = \"hello world\",limit = 10) == ['hello<1/3>', ' worl<2/3>', 'd<3/3>']\n    assert candidate(message = \"abcd efgh ijkl mnop qrst uvwx yz\",limit = 10) == ['abcd <1/7>', 'efgh <2/7>', 'ijkl <3/7>', 'mnop <4/7>', 'qrst <5/7>', 'uvwx <6/7>', 'yz<7/7>']\n    assert candidate(message = \"a\",limit = 5) == []\n    assert candidate(message = \"a quick brown fox jumps over the lazy dog\",limit = 10) == ['a qui<1/9>', 'ck br<2/9>', 'own f<3/9>', 'ox ju<4/9>', 'mps o<5/9>', 'ver t<6/9>', 'he la<7/9>', 'zy do<8/9>', 'g<9/9>']\n    assert candidate(message = \"abcdefghij\",limit = 7) == ['ab<1/5>', 'cd<2/5>', 'ef<3/5>', 'gh<4/5>', 'ij<5/5>']\n    assert candidate(message = \"python programming is fun\",limit = 20) == ['python programm<1/2>', 'ing is fun<2/2>']\n    assert candidate(message = \"this is really a very awesome message\",limit = 9) == ['thi<1/14>', 's i<2/14>', 's r<3/14>', 'eal<4/14>', 'ly <5/14>', 'a v<6/14>', 'ery<7/14>', ' aw<8/14>', 'eso<9/14>', 'me<10/14>', ' m<11/14>', 'es<12/14>', 'sa<13/14>', 'ge<14/14>']\n    assert candidate(message = \"ab\",limit = 5) == []\n    assert candidate(message = \"a quick brown fox jumps over the lazy dog\",limit = 5) == []\n    assert candidate(message = \"hello world\",limit = 20) == ['hello world<1/1>']\n    assert candidate(message = \"abcdefghijabcdefghijabcdefghij\",limit = 12) == ['abcdefg<1/5>', 'hijabcd<2/5>', 'efghija<3/5>', 'bcdefgh<4/5>', 'ij<5/5>']\n    assert candidate(message = \"abcdefg\",limit = 3) == []\n    assert candidate(message = \"one two three four five six seven eight nine ten\",limit = 12) == ['one two<1/7>', ' three <2/7>', 'four fi<3/7>', 've six <4/7>', 'seven e<5/7>', 'ight ni<6/7>', 'ne ten<7/7>']\n    assert candidate(message = \"abcdefghijabcdefghij\",limit = 10) == ['abcde<1/4>', 'fghij<2/4>', 'abcde<3/4>', 'fghij<4/4>']\n    assert candidate(message = \"abcd\",limit = 5) == []\n    assert candidate(message = \"anotherlongermessageforcomplextesting\",limit = 18) == ['anotherlonger<1/3>', 'messageforcom<2/3>', 'plextesting<3/3>']\n    assert candidate(message = \"testing testing testing testing testing testing testing testing testing testing\",limit = 20) == ['testing testing<1/6>', ' testing testin<2/6>', 'g testing testi<3/6>', 'ng testing test<4/6>', 'ing testing tes<5/6>', 'ting<6/6>']\n    assert candidate(message = \"abcd efgh ijkl mnop qrst uvwx yz\",limit = 8) == ['ab<1/23>', 'cd<2/23>', ' e<3/23>', 'fg<4/23>', 'h <5/23>', 'ij<6/23>', 'kl<7/23>', ' m<8/23>', 'no<9/23>', 'p<10/23>', ' <11/23>', 'q<12/23>', 'r<13/23>', 's<14/23>', 't<15/23>', ' <16/23>', 'u<17/23>', 'v<18/23>', 'w<19/23>', 'x<20/23>', ' <21/23>', 'y<22/23>', 'z<23/23>']\n    assert candidate(message = \"one two three four five six seven eight nine ten\",limit = 5) == []\n    assert candidate(message = \"shortmessage\",limit = 20) == ['shortmessage<1/1>']\n    assert candidate(message = \"split this into as few parts as possible\",limit = 21) == ['split this into <1/3>', 'as few parts as <2/3>', 'possible<3/3>']\n    assert candidate(message = \"repeated repeated repeated repeated repeated repeated repeated repeated\",limit = 25) == ['repeated repeated re<1/4>', 'peated repeated repe<2/4>', 'ated repeated repeat<3/4>', 'ed repeated<4/4>']\n    assert candidate(message = \"this is a very long message that needs to be split into multiple parts to fit the limit\",limit = 10) == ['this<1/26>', ' is <2/26>', 'a ve<3/26>', 'ry l<4/26>', 'ong <5/26>', 'mess<6/26>', 'age <7/26>', 'that<8/26>', ' nee<9/26>', 'ds <10/26>', 'to <11/26>', 'be <12/26>', 'spl<13/26>', 'it <14/26>', 'int<15/26>', 'o m<16/26>', 'ult<17/26>', 'ipl<18/26>', 'e p<19/26>', 'art<20/26>', 's t<21/26>', 'o f<22/26>', 'it <23/26>', 'the<24/26>', ' li<25/26>', 'mit<26/26>']\n    assert candidate(message = \"this is a repeated message this is a repeated message this is a repeated message\",limit = 15) == ['this is a <1/8>', 'repeated m<2/8>', 'essage thi<3/8>', 's is a rep<4/8>', 'eated mess<5/8>', 'age this i<6/8>', 's a repeat<7/8>', 'ed message<8/8>']\n    assert candidate(message = \"spaces          between          words\",limit = 20) == ['spaces         <1/3>', ' between       <2/3>', '   words<3/3>']\n    assert candidate(message = \"boundary boundary boundary boundary boundary boundary boundary boundary boundary boundary boundary boundary\",limit = 30) == ['boundary boundary boundar<1/5>', 'y boundary boundary bound<2/5>', 'ary boundary boundary bou<3/5>', 'ndary boundary boundary b<4/5>', 'oundary<5/5>']\n    assert candidate(message = \"singleword\",limit = 12) == ['singlew<1/2>', 'ord<2/2>']\n    assert candidate(message = \"a quick brown fox jumps over the lazy dog a quick brown fox jumps over the lazy dog\",limit = 15) == ['a quick br<1/9>', 'own fox ju<2/9>', 'mps over t<3/9>', 'he lazy do<4/9>', 'g a quick <5/9>', 'brown fox <6/9>', 'jumps over<7/9>', ' the lazy <8/9>', 'dog<9/9>']\n    assert candidate(message = \"one two three four five six seven eight nine ten eleven twelve thirteen\",limit = 11) == ['one t<1/16>', 'wo th<2/16>', 'ree f<3/16>', 'our f<4/16>', 'ive s<5/16>', 'ix se<6/16>', 'ven e<7/16>', 'ight <8/16>', 'nine <9/16>', 'ten <10/16>', 'elev<11/16>', 'en t<12/16>', 'welv<13/16>', 'e th<14/16>', 'irte<15/16>', 'en<16/16>']\n    assert candidate(message = \"a\",limit = 1) == []\n    assert candidate(message = \"singlewordwithoutspaces\",limit = 25) == ['singlewordwithoutspa<1/2>', 'ces<2/2>']\n    assert candidate(message = \"abcdefghijklmnopqrstuvwxyz\",limit = 5) == []\n    assert candidate(message = \"one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty\",limit = 22) == ['one two three fou<1/8>', 'r five six seven <2/8>', 'eight nine ten el<3/8>', 'even twelve thirt<4/8>', 'een fourteen fift<5/8>', 'een sixteen seven<6/8>', 'teen eighteen nin<7/8>', 'eteen twenty<8/8>']\n    assert candidate(message = \"a very very very very very very very very very very very long message that needs to be split into multiple parts\",limit = 18) == ['a very very v<1/9>', 'ery very very<2/9>', ' very very ve<3/9>', 'ry very very <4/9>', 'very long mes<5/9>', 'sage that nee<6/9>', 'ds to be spli<7/9>', 't into multip<8/9>', 'le parts<9/9>']\n    assert candidate(message = \"hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello\",limit = 5) == []\n    assert candidate(message = \"veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylongmessage\",limit = 25) == ['veryveryveryveryvery<1/6>', 'veryveryveryveryvery<2/6>', 'veryveryveryveryvery<3/6>', 'veryveryveryveryvery<4/6>', 'veryveryveryveryvery<5/6>', 'longmessage<6/6>']\n    assert candidate(message = \"samecharssamecharssamecharssamecharssamecharssamechars\",limit = 10) == ['same<1/15>', 'char<2/15>', 'ssam<3/15>', 'echa<4/15>', 'rssa<5/15>', 'mech<6/15>', 'arss<7/15>', 'amec<8/15>', 'hars<9/15>', 'sam<10/15>', 'ech<11/15>', 'ars<12/15>', 'sam<13/15>', 'ech<14/15>', 'ars<15/15>']\n    assert candidate(message = \"short\",limit = 5) == []\n    assert candidate(message = \"manywordsbutnospacesmanywordsbutnospacesmanywordsbutnospacesmanywordsbutnospaces\",limit = 20) == ['manywordsbutnos<1/6>', 'pacesmanywordsb<2/6>', 'utnospacesmanyw<3/6>', 'ordsbutnospaces<4/6>', 'manywordsbutnos<5/6>', 'paces<6/6>']\n    assert candidate(message = \"this message has a very specific requirement for splitting\",limit = 18) == ['this message <1/5>', 'has a very sp<2/5>', 'ecific requir<3/5>', 'ement for spl<4/5>', 'itting<5/5>']\n    assert candidate(message = \"the quick brown fox jumps over the lazy dog the quick brown fox jumps over the lazy dog the quick brown fox jumps over the lazy dog\",limit = 25) == ['the quick brown fox <1/7>', 'jumps over the lazy <2/7>', 'dog the quick brown <3/7>', 'fox jumps over the l<4/7>', 'azy dog the quick br<5/7>', 'own fox jumps over t<6/7>', 'he lazy dog<7/7>']\n    assert candidate(message = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",limit = 4) == []\n    assert candidate(message = \"short\",limit = 10) == ['short<1/1>']\n    assert candidate(message = \"single\",limit = 6) == ['s<1/6>', 'i<2/6>', 'n<3/6>', 'g<4/6>', 'l<5/6>', 'e<6/6>']\n    assert candidate(message = \"singlewordwithoutspaces\",limit = 10) == ['singl<1/5>', 'eword<2/5>', 'witho<3/5>', 'utspa<4/5>', 'ces<5/5>']\n    assert candidate(message = \"a quick brown fox jumps over the lazy dog\",limit = 12) == ['a quick<1/6>', ' brown <2/6>', 'fox jum<3/6>', 'ps over<4/6>', ' the la<5/6>', 'zy dog<6/6>']\n    assert candidate(message = \"one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty\",limit = 20) == ['one two three f<1/9>', 'our five six se<2/9>', 'ven eight nine <3/9>', 'ten eleven twel<4/9>', 've thirteen fou<5/9>', 'rteen fifteen s<6/9>', 'ixteen seventee<7/9>', 'n eighteen nine<8/9>', 'teen twenty<9/9>']\n    assert candidate(message = \"boundary boundary boundary boundary boundary boundary boundary boundary boundary\",limit = 20) == ['boundary bounda<1/6>', 'ry boundary bou<2/6>', 'ndary boundary <3/6>', 'boundary bounda<4/6>', 'ry boundary bou<5/6>', 'ndary<6/6>']\n    assert candidate(message = \"boundaryboundaryboundaryboundaryboundaryboundaryboundaryboundaryboundaryboundaryboundaryboundaryboundaryboundaryboundary\",limit = 30) == ['boundaryboundaryboundaryb<1/5>', 'oundaryboundaryboundarybo<2/5>', 'undaryboundaryboundarybou<3/5>', 'ndaryboundaryboundaryboun<4/5>', 'daryboundaryboundary<5/5>']\n    assert candidate(message = \"repeated repeated repeated repeated repeated repeated repeated repeated\",limit = 12) == ['repeat<1/13>', 'ed rep<2/13>', 'eated <3/13>', 'repeat<4/13>', 'ed rep<5/13>', 'eated <6/13>', 'repeat<7/13>', 'ed rep<8/13>', 'eated <9/13>', 'repea<10/13>', 'ted r<11/13>', 'epeat<12/13>', 'ed<13/13>']\n    assert candidate(message = \"this is a very long message that needs to be split into several parts to meet the limit constraint\",limit = 15) == ['this is a<1/12>', ' very lon<2/12>', 'g message<3/12>', ' that nee<4/12>', 'ds to be <5/12>', 'split int<6/12>', 'o several<7/12>', ' parts to<8/12>', ' meet the<9/12>', ' limit c<10/12>', 'onstrain<11/12>', 't<12/12>']\n    assert candidate(message = \"a quick brown fox jumps over the lazy dog\",limit = 11) == ['a quic<1/7>', 'k brow<2/7>', 'n fox <3/7>', 'jumps <4/7>', 'over t<5/7>', 'he laz<6/7>', 'y dog<7/7>']\n    assert candidate(message = \"a quick brown fox jumps over the lazy dog\",limit = 15) == ['a quick br<1/5>', 'own fox ju<2/5>', 'mps over t<3/5>', 'he lazy do<4/5>', 'g<5/5>']\n    assert candidate(message = \"shortmsg\",limit = 12) == ['shortms<1/2>', 'g<2/2>']\n    assert candidate(message = \"this is another test case with a longer message that needs to be split into multiple parts to see how the function handles it\",limit = 18) == ['this is anot<1/11>', 'her test cas<2/11>', 'e with a lon<3/11>', 'ger message <4/11>', 'that needs t<5/11>', 'o be split i<6/11>', 'nto multiple<7/11>', ' parts to se<8/11>', 'e how the fu<9/11>', 'nction hand<10/11>', 'les it<11/11>']\n    assert candidate(message = \"a\",limit = 3) == []\n    assert candidate(message = \"spaces    in    the    message    should    be    handled    correctly\",limit = 15) == ['spaces    <1/7>', 'in    the <2/7>', '   message<3/7>', '    should<4/7>', '    be    <5/7>', 'handled   <6/7>', ' correctly<7/7>']\n    assert candidate(message = \"splitting this message into parts is challenging\",limit = 15) == ['splitting <1/5>', 'this messa<2/5>', 'ge into pa<3/5>', 'rts is cha<4/5>', 'llenging<5/5>']\n    assert candidate(message = \"another example with a bit more text to ensure the splitting algorithm works correctly\",limit = 20) == ['another example<1/6>', ' with a bit mor<2/6>', 'e text to ensur<3/6>', 'e the splitting<4/6>', ' algorithm work<5/6>', 's correctly<6/6>']\n    assert candidate(message = \"this is a very very very very very very very very very very very very very very very very very very very very very very very very very very very long message indeed\",limit = 20) == ['this is a very<1/12>', ' very very ver<2/12>', 'y very very ve<3/12>', 'ry very very v<4/12>', 'ery very very <5/12>', 'very very very<6/12>', ' very very ver<7/12>', 'y very very ve<8/12>', 'ry very very v<9/12>', 'ery very very<10/12>', ' very long me<11/12>', 'ssage indeed<12/12>']\n    assert candidate(message = \"edgecase\",limit = 8) == ['edg<1/3>', 'eca<2/3>', 'se<3/3>']\n    assert candidate(message = \"this is a test to see if the solution can handle edge cases\",limit = 23) == ['this is a test to <1/4>', 'see if the solutio<2/4>', 'n can handle edge <3/4>', 'cases<4/4>']\n    assert candidate(message = \"a very long message that needs to be split into many parts to test the solution thoroughly\",limit = 12) == ['a very<1/17>', ' long <2/17>', 'messag<3/17>', 'e that<4/17>', ' needs<5/17>', ' to be<6/17>', ' split<7/17>', ' into <8/17>', 'many p<9/17>', 'arts <10/17>', 'to te<11/17>', 'st th<12/17>', 'e sol<13/17>', 'ution<14/17>', ' thor<15/17>', 'oughl<16/17>', 'y<17/17>']\n    assert candidate(message = \"this is a very very long message that needs to be split into multiple parts to fit the limit\",limit = 15) == ['this is a<1/11>', ' very ver<2/11>', 'y long me<3/11>', 'ssage tha<4/11>', 't needs t<5/11>', 'o be spli<6/11>', 't into mu<7/11>', 'ltiple pa<8/11>', 'rts to fi<9/11>', 't the li<10/11>', 'mit<11/11>']\n    assert candidate(message = \"short\",limit = 100) == ['short<1/1>']\n    assert candidate(message = \"this is an extremely long message that needs to be split into several parts to fit the given limit\",limit = 12) == ['this i<1/18>', 's an e<2/18>', 'xtreme<3/18>', 'ly lon<4/18>', 'g mess<5/18>', 'age th<6/18>', 'at nee<7/18>', 'ds to <8/18>', 'be spl<9/18>', 'it in<10/18>', 'to se<11/18>', 'veral<12/18>', ' part<13/18>', 's to <14/18>', 'fit t<15/18>', 'he gi<16/18>', 'ven l<17/18>', 'imit<18/18>']\n", "comparison": "exact"}, "public_tests": ["\"this is really a very awesome message\"\n9", "\"short message\"\n15"], "hints": ["Could you solve the problem if you knew how many digits the total number of parts has?", "Try all possible lengths of the total number of parts, and see if the string can be split such that the total number of parts has that length.", "Binary search can be used for each part length to find the precise number of parts needed."], "metadata": {"canonical_parameter_names": ["message", "limit"], "leetcode_dataset_entry_point": "Solution().splitMessage", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:57+00:00", "tests_total": 81, "tests_dropped": 12, "flags": [], "topic_tags": ["string", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def splitMessage(self, message: str, limit: int) -> list[str]:", "container": "Solution", "callable": "splitMessage", "parameters": [{"name": "message", "type": "str"}, {"name": "limit", "type": "int"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2469, "task_id": "convert-the-temperature", "difficulty": "Easy", "problem_description": "You are given a non-negative floating point number rounded to two decimal places celsius, that denotes the temperature in Celsius.\n\nYou should convert Celsius into Kelvin and Fahrenheit and return it as an array ans = [kelvin, fahrenheit].\n\nReturn the array ans. Answers within 10^-5 of the actual answer will be accepted.\n\nNote that:\n\n- Kelvin = Celsius + 273.15\n- Fahrenheit = Celsius * 1.80 + 32.00\n\nExample 1:\n\nInput: celsius = 36.50\nOutput: [309.65000,97.70000]\nExplanation: Temperature at 36.50 Celsius converted in Kelvin is 309.65 and converted in Fahrenheit is 97.70.\n\nExample 2:\n\nInput: celsius = 122.11\nOutput: [395.26000,251.79800]\nExplanation: Temperature at 122.11 Celsius converted in Kelvin is 395.26 and converted in Fahrenheit is 251.798.\n\nConstraints:\n\n- 0 <= celsius <= 1000\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n    \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n    import math\n    if isinstance(result, list) and isinstance(expected, list):\n        return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n    numbers = (int, float)\n    if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n        return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n    return result == expected\n\n\ndef check(candidate):\n    assert answers_match(candidate(celsius=122.11), [395.26, 251.798])\n    assert answers_match(candidate(celsius=1000.0), [1273.15, 1832.0])\n    assert answers_match(candidate(celsius=0.0), [273.15, 32.0])\n    assert answers_match(candidate(celsius=500.0), [773.15, 932.0])\n    assert answers_match(candidate(celsius=100.0), [373.15, 212.0])\n    assert answers_match(candidate(celsius=500.75), [773.9, 933.35])\n    assert answers_match(candidate(celsius=36.5), [309.65, 97.7])\n    assert answers_match(candidate(celsius=25.0), [298.15, 77.0])\n    assert answers_match(candidate(celsius=273.15), [546.3, 523.67])\n    assert answers_match(candidate(celsius=42.876543), [316.02654299999995, 109.1777774])\n    assert answers_match(candidate(celsius=12.34), [285.48999999999995, 54.212])\n    assert answers_match(candidate(celsius=37.0), [310.15, 98.60000000000001])\n    assert answers_match(candidate(celsius=25.55555), [298.70554999999996, 77.99999])\n    assert answers_match(candidate(celsius=150.75), [423.9, 303.35])\n    assert answers_match(candidate(celsius=234.56), [507.71, 454.208])\n    assert answers_match(candidate(celsius=750.5), [1023.65, 1382.9])\n    assert answers_match(candidate(celsius=77.77777), [350.92777, 171.999986])\n    assert answers_match(candidate(celsius=456.78), [729.93, 854.204])\n    assert answers_match(candidate(celsius=750.25), [1023.4, 1382.45])\n    assert answers_match(candidate(celsius=999.0), [1272.15, 1830.2])\n    assert answers_match(candidate(celsius=499.99), [773.14, 931.9820000000001])\n    assert answers_match(candidate(celsius=60.0), [333.15, 140.0])\n    assert answers_match(candidate(celsius=23.45), [296.59999999999997, 74.21000000000001])\n    assert answers_match(candidate(celsius=450.0), [723.15, 842.0])\n    assert answers_match(candidate(celsius=150.67), [423.81999999999994, 303.20599999999996])\n    assert answers_match(candidate(celsius=1.0), [274.15, 33.8])\n    assert answers_match(candidate(celsius=500.01), [773.16, 932.018])\n    assert answers_match(candidate(celsius=800.25), [1073.4, 1472.45])\n    assert answers_match(candidate(celsius=550.89), [824.04, 1023.602])\n    assert answers_match(candidate(celsius=999.99), [1273.1399999999999, 1831.982])\n    assert answers_match(candidate(celsius=1.23456), [274.38455999999996, 34.222208])\n    assert answers_match(candidate(celsius=0.99), [274.14, 33.782])\n    assert answers_match(candidate(celsius=678.9), [952.05, 1254.02])\n    assert answers_match(candidate(celsius=300.12), [573.27, 572.216])\n    assert answers_match(candidate(celsius=0.01), [273.15999999999997, 32.018])\n    assert answers_match(candidate(celsius=777.77), [1050.92, 1431.986])\n    assert answers_match(candidate(celsius=89.67), [362.82, 193.406])\n    assert answers_match(candidate(celsius=150.0), [423.15, 302.0])\n", "comparison": "float"}, "public_tests": ["36.50", "122.11"], "hints": ["Implement formulas that are given in the statement."], "metadata": {"canonical_parameter_names": ["celsius"], "leetcode_dataset_entry_point": "Solution().convertTemperature", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:53:59+00:00", "tests_total": 39, "tests_dropped": 1, "flags": ["decimal_answer"], "topic_tags": ["math"]}, "language": "python", "interface": {"raw_signature": "def convertTemperature(self, celsius: float) -> list[float]:", "container": "Solution", "callable": "convertTemperature", "parameters": [{"name": "celsius", "type": "float"}], "return_type": "list[float]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2470, "task_id": "number-of-subarrays-with-lcm-equal-to-k", "difficulty": "Medium", "problem_description": "Given an integer array nums and an integer k, return the number of subarrays of nums where the least common multiple of the subarray's elements is k.\n\nA subarray is a contiguous non-empty sequence of elements within an array.\n\nThe least common multiple of an array is the smallest positive integer that is divisible by all the array elements.\n\nExample 1:\n\nInput: nums = [3,6,2,7,1], k = 6\nOutput: 4\nExplanation: The subarrays of nums where 6 is the least common multiple of all the subarray's elements are:\n- [3,6,2,7,1]\n- [3,6,2,7,1]\n- [3,6,2,7,1]\n- [3,6,2,7,1]\n\nExample 2:\n\nInput: nums = [3], k = 2\nOutput: 0\nExplanation: There are no subarrays of nums where 2 is the least common multiple of all the subarray's elements.\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 1 <= nums[i], k <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [7, 7, 7, 7, 7],k = 7) == 15\n    assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 15\n    assert candidate(nums = [7, 3, 9, 12, 15],k = 60) == 1\n    assert candidate(nums = [3, 6, 2, 7, 1],k = 6) == 4\n    assert candidate(nums = [100, 100, 100],k = 100) == 6\n    assert candidate(nums = [7, 7, 7, 7],k = 7) == 10\n    assert candidate(nums = [10, 5, 6, 20, 12],k = 60) == 7\n    assert candidate(nums = [5, 10, 15, 20, 25],k = 60) == 3\n    assert candidate(nums = [5, 10, 15],k = 30) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50],k = 100) == 0\n    assert candidate(nums = [1, 1, 1, 1, 1],k = 1) == 15\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 60) == 3\n    assert candidate(nums = [3],k = 2) == 0\n    assert candidate(nums = [2, 4, 6, 8, 10],k = 20) == 0\n    assert candidate(nums = [2, 4, 8, 16],k = 16) == 4\n    assert candidate(nums = [6, 12, 18, 24],k = 72) == 3\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 12) == 3\n    assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 1\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 1\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 312) == 0\n    assert candidate(nums = [8, 16, 32, 64, 128, 256, 512],k = 512) == 7\n    assert candidate(nums = [5, 10, 15, 20, 25],k = 150) == 0\n    assert candidate(nums = [3, 6, 9, 12, 15, 18, 21],k = 18) == 3\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 120) == 7\n    assert candidate(nums = [13, 13, 13, 13, 13, 13, 13],k = 13) == 28\n    assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230],k = 46) == 2\n    assert candidate(nums = [3, 9, 27, 81, 243],k = 243) == 5\n    assert candidate(nums = [11, 22, 33, 44, 55],k = 132) == 3\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 78) == 3\n    assert candidate(nums = [4, 8, 16, 32, 64, 128],k = 128) == 6\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40],k = 420) == 0\n    assert candidate(nums = [100, 200, 300, 400, 500],k = 200) == 2\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 540) == 7\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 420) == 0\n    assert candidate(nums = [3, 9, 27, 81, 243],k = 81) == 4\n    assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 55\n    assert candidate(nums = [7, 14, 21, 28, 35],k = 42) == 2\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 60) == 7\n    assert candidate(nums = [6, 12, 18, 24, 30],k = 360) == 3\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 110) == 1\n    assert candidate(nums = [7, 14, 28, 42, 56],k = 168) == 4\n    assert candidate(nums = [30, 60, 90, 120, 150],k = 150) == 1\n    assert candidate(nums = [6, 12, 3, 18, 9],k = 36) == 4\n    assert candidate(nums = [10, 15, 30, 60, 120, 240],k = 120) == 5\n    assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 5) == 21\n    assert candidate(nums = [4, 6, 12, 15, 30, 60],k = 60) == 12\n    assert candidate(nums = [4, 8, 12, 16, 20],k = 480) == 0\n    assert candidate(nums = [5, 15, 25, 35, 45],k = 525) == 2\n    assert candidate(nums = [5, 10, 20, 40, 80, 160, 320, 640],k = 640) == 8\n    assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],k = 42) == 2\n    assert candidate(nums = [3, 5, 15, 45, 60, 90],k = 90) == 1\n    assert candidate(nums = [9, 18, 27, 36, 45],k = 54) == 2\n    assert candidate(nums = [7, 14, 28, 56, 112],k = 112) == 5\n    assert candidate(nums = [7, 14, 21, 28, 35],k = 14) == 2\n    assert candidate(nums = [2, 4, 6, 8, 12],k = 24) == 7\n    assert candidate(nums = [5, 10, 15, 20, 25],k = 60) == 3\n    assert candidate(nums = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290],k = 29) == 1\n    assert candidate(nums = [4, 8, 12, 16, 20],k = 240) == 3\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 24) == 3\n    assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190],k = 380) == 1\n    assert candidate(nums = [7, 14, 28, 49, 98],k = 196) == 6\n    assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170],k = 34) == 2\n    assert candidate(nums = [21, 28, 35, 42, 49, 56, 63, 70],k = 42) == 1\n    assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 420) == 7\n    assert candidate(nums = [7, 14, 28, 56, 112],k = 56) == 4\n    assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 1\n    assert candidate(nums = [6, 9, 12, 15, 18],k = 180) == 5\n    assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 90) == 1\n    assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 660) == 7\n    assert candidate(nums = [7, 14, 21, 28, 35],k = 420) == 3\n    assert candidate(nums = [25, 50, 75, 100, 125],k = 250) == 0\n    assert candidate(nums = [6, 12, 18, 24, 30],k = 36) == 2\n    assert candidate(nums = [6, 12, 18, 24, 30],k = 360) == 3\n    assert candidate(nums = [2, 4, 6, 8, 12],k = 12) == 3\n    assert candidate(nums = [4, 8, 12, 16, 20],k = 240) == 3\n    assert candidate(nums = [2, 4, 6, 8, 12, 24],k = 24) == 13\n    assert candidate(nums = [12, 15, 20, 25, 30],k = 300) == 5\n    assert candidate(nums = [100, 150, 200, 250, 300],k = 300) == 2\n    assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117],k = 312) == 0\n    assert candidate(nums = [2, 4, 6, 8, 10, 12],k = 12) == 3\n    assert candidate(nums = [9, 18, 27, 36, 45],k = 54) == 2\n    assert candidate(nums = [21, 35, 105, 210, 315, 420, 630],k = 630) == 5\n    assert candidate(nums = [6, 8, 12, 24, 36],k = 24) == 7\n    assert candidate(nums = [3, 9, 27, 81],k = 81) == 4\n    assert candidate(nums = [13, 26, 39, 52, 65],k = 780) == 3\n    assert candidate(nums = [3, 5, 15, 25, 75],k = 75) == 8\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 30) == 1\n    assert candidate(nums = [17, 34, 51, 68, 85],k = 102) == 2\n    assert candidate(nums = [8, 16, 24, 32, 40],k = 480) == 3\n    assert candidate(nums = [8, 12, 16, 24, 32],k = 48) == 5\n    assert candidate(nums = [5, 10, 15, 20, 25],k = 100) == 1\n    assert candidate(nums = [3, 9, 27, 81, 243, 729],k = 729) == 6\n    assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600],k = 60) == 1\n    assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],k = 840) == 0\n    assert candidate(nums = [8, 12, 24, 36, 48, 60, 72],k = 72) == 4\n    assert candidate(nums = [12, 15, 20, 25, 30],k = 600) == 0\n    assert candidate(nums = [4, 8, 12, 16, 20],k = 24) == 2\n    assert candidate(nums = [9, 18, 27, 36, 45, 54],k = 54) == 3\n    assert candidate(nums = [100, 200, 300, 400, 500],k = 100) == 1\n    assert candidate(nums = [37, 74, 111, 148, 185, 222, 259, 296, 333, 370],k = 370) == 1\n    assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310],k = 62) == 2\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 105) == 0\n    assert candidate(nums = [12, 15, 20, 25, 30],k = 60) == 3\n    assert candidate(nums = [7, 14, 28, 56, 112],k = 112) == 5\n    assert candidate(nums = [7, 14, 28, 35, 42],k = 42) == 1\n", "comparison": "exact"}, "public_tests": ["[3,6,2,7,1]\n6", "[3]\n2"], "hints": ["The constraints on nums.length are small. It is possible to check every subarray.", "To calculate LCM, you can use a built-in function or the formula lcm(a, b) = a * b / gcd(a, b).", "As you calculate the LCM of more numbers, it can only become greater. Once it becomes greater than k, you know that any larger subarrays containing all the current elements will not work."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().subarrayLCM", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:01+00:00", "tests_total": 128, "tests_dropped": 23, "flags": [], "topic_tags": ["array", "math", "number-theory"]}, "language": "python", "interface": {"raw_signature": "def subarrayLCM(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "subarrayLCM", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2472, "task_id": "maximum-number-of-non-overlapping-palindrome-substrings", "difficulty": "Hard", "problem_description": "You are given a string s and a positive integer k.\n\nSelect a set of non-overlapping substrings from the string s that satisfy the following conditions:\n\n- The length of each substring is at least k.\n- Each substring is a palindrome.\n\nReturn the maximum number of substrings in an optimal selection.\n\nA substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: s = \"abaccdbbd\", k = 3\nOutput: 2\nExplanation: We can select the substrings underlined in s = \"abaccdbbd\". Both \"aba\" and \"dbbd\" are palindromes and have a length of at least k = 3.\nIt can be shown that we cannot find a selection with more than two valid substrings.\n\nExample 2:\n\nInput: s = \"adbcda\", k = 2\nOutput: 0\nExplanation: There is no palindrome substring of length at least 2 in the string.\n\nConstraints:\n\n- 1 <= k <= s.length <= 2000\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"racecar\",k = 2) == 1\n    assert candidate(s = \"mnoonm\",k = 2) == 1\n    assert candidate(s = \"zzzzzz\",k = 1) == 6\n    assert candidate(s = \"abcde\",k = 3) == 0\n    assert candidate(s = \"abcdeedcba\",k = 2) == 1\n    assert candidate(s = \"zz\",k = 1) == 2\n    assert candidate(s = \"adbcda\",k = 2) == 0\n    assert candidate(s = \"abcde\",k = 1) == 5\n    assert candidate(s = \"aaaaa\",k = 2) == 2\n    assert candidate(s = \"racecar\",k = 3) == 1\n    assert candidate(s = \"abbaeaeabba\",k = 3) == 3\n    assert candidate(s = \"abbaabba\",k = 3) == 2\n    assert candidate(s = \"noonhighnoon\",k = 4) == 2\n    assert candidate(s = \"abacdfgdcaba\",k = 3) == 2\n    assert candidate(s = \"aaaa\",k = 2) == 2\n    assert candidate(s = \"a\",k = 1) == 1\n    assert candidate(s = \"abcdedcba\",k = 5) == 1\n    assert candidate(s = \"racecarannakayak\",k = 3) == 3\n    assert candidate(s = \"abcba\",k = 5) == 1\n    assert candidate(s = \"abaccdbbd\",k = 3) == 2\n    assert candidate(s = \"abbaeae\",k = 2) == 2\n    assert candidate(s = \"z\",k = 1) == 1\n    assert candidate(s = \"aaabaaaabaaaa\",k = 5) == 2\n    assert candidate(s = \"levellevellevel\",k = 5) == 3\n    assert candidate(s = \"abcabcabcabc\",k = 3) == 0\n    assert candidate(s = \"ababababa\",k = 3) == 3\n    assert candidate(s = \"abcbaabccba\",k = 3) == 2\n    assert candidate(s = \"level\",k = 5) == 1\n    assert candidate(s = \"xyxxyxyxyx\",k = 1) == 10\n    assert candidate(s = \"aabbaaabbbaaaa\",k = 2) == 6\n    assert candidate(s = \"ababababababab\",k = 2) == 4\n    assert candidate(s = \"rotorreferredder\",k = 4) == 3\n    assert candidate(s = \"popopopopopop\",k = 3) == 4\n    assert candidate(s = \"abaaaaba\",k = 4) == 1\n    assert candidate(s = \"xyxzyzyzyxzyx\",k = 3) == 3\n    assert candidate(s = \"madamimadam\",k = 2) == 3\n    assert candidate(s = \"aaaaaaaaaaaaaaaaaa\",k = 10) == 1\n    assert candidate(s = \"abbaabbaabba\",k = 4) == 3\n    assert candidate(s = \"aabbccddeeff\",k = 2) == 6\n    assert candidate(s = \"rotor\",k = 5) == 1\n    assert candidate(s = \"abcddcbaabcddcba\",k = 6) == 2\n    assert candidate(s = \"palindromemordnilap\",k = 6) == 1\n    assert candidate(s = \"aabbccddeeefffggghhhiii\",k = 4) == 0\n    assert candidate(s = \"xyxzyzyzxzyxzyx\",k = 3) == 3\n    assert candidate(s = \"aaaaaaaabaaaa\",k = 5) == 2\n    assert candidate(s = \"levelracecaraabba\",k = 4) == 3\n    assert candidate(s = \"racecarannakayak\",k = 5) == 2\n    assert candidate(s = \"abccbaabccba\",k = 3) == 2\n    assert candidate(s = \"abcabcabcabcabcabcabc\",k = 3) == 0\n    assert candidate(s = \"abcdedcbaedcbba\",k = 5) == 1\n    assert candidate(s = \"noonnoonnoon\",k = 3) == 3\n    assert candidate(s = \"abbaaccddccaaabbbcccdd\",k = 3) == 5\n    assert candidate(s = \"abcbabcba\",k = 5) == 1\n    assert candidate(s = \"aabbabbaaabbabba\",k = 4) == 3\n    assert candidate(s = \"abbaaccddccbaabba\",k = 3) == 3\n    assert candidate(s = \"abbaacccbaaabbcc\",k = 3) == 3\n    assert candidate(s = \"civiccivic\",k = 4) == 2\n    assert candidate(s = \"aaabaaaacaaaaaa\",k = 3) == 4\n    assert candidate(s = \"abracadabra\",k = 3) == 1\n    assert candidate(s = \"abcdcbaabcdcba\",k = 5) == 2\n    assert candidate(s = \"xyzyzyzyzyzyzyzy\",k = 2) == 5\n    assert candidate(s = \"madamracecarlevel\",k = 5) == 3\n    assert candidate(s = \"xyxzyzyzyzxzyzyx\",k = 3) == 5\n    assert candidate(s = \"bananaabacaxxx\",k = 3) == 3\n    assert candidate(s = \"noonnoonnoon\",k = 4) == 3\n    assert candidate(s = \"abcdefghij\",k = 3) == 0\n    assert candidate(s = \"zzzzyyyyxxxx\",k = 4) == 3\n    assert candidate(s = \"aaaabbbbccccdddd\",k = 4) == 4\n    assert candidate(s = \"civicracecardeified\",k = 3) == 3\n    assert candidate(s = \"aabbccddeeffgg\",k = 2) == 7\n    assert candidate(s = \"madamimadam\",k = 5) == 2\n    assert candidate(s = \"aaaabaaaabaaaaabaaabaaa\",k = 2) == 9\n    assert candidate(s = \"racecar\",k = 6) == 1\n    assert candidate(s = \"xyxxyxyxyxyx\",k = 2) == 4\n    assert candidate(s = \"abcbabcba\",k = 3) == 2\n    assert candidate(s = \"abcabcabcabc\",k = 1) == 12\n    assert candidate(s = \"abcdefgfedcba\",k = 7) == 1\n    assert candidate(s = \"mamadadadadammadam\",k = 3) == 5\n    assert candidate(s = \"madamimadam\",k = 3) == 3\n    assert candidate(s = \"babaddabba\",k = 3) == 2\n    assert candidate(s = \"aabbabaaaabbabaab\",k = 3) == 4\n    assert candidate(s = \"babbbabbbab\",k = 3) == 3\n    assert candidate(s = \"aabaaaabbbaaa\",k = 3) == 4\n    assert candidate(s = \"aabbaabbaaabbbaabbaab\",k = 3) == 4\n    assert candidate(s = \"abccbaabc\",k = 4) == 1\n    assert candidate(s = \"abracadabra\",k = 5) == 0\n    assert candidate(s = \"abbaabbaabba\",k = 2) == 5\n    assert candidate(s = \"aaaaaabbbbbbaaaaaabbbbb\",k = 5) == 4\n    assert candidate(s = \"abcbaabababaabcba\",k = 3) == 4\n    assert candidate(s = \"abcabcabc\",k = 2) == 0\n    assert candidate(s = \"abccbaabcabcabcabcba\",k = 5) == 2\n    assert candidate(s = \"abccbaabcba\",k = 5) == 2\n    assert candidate(s = \"mississippi\",k = 3) == 2\n    assert candidate(s = \"abbaabbabbaabb\",k = 2) == 6\n    assert candidate(s = \"abcdefedcba\",k = 5) == 1\n    assert candidate(s = \"abcdefghihgfedcba\",k = 7) == 1\n    assert candidate(s = \"noonmoonnoonmoon\",k = 4) == 2\n    assert candidate(s = \"abcdefedcbafedcbabcdef\",k = 5) == 2\n    assert candidate(s = \"abbaabba\",k = 2) == 3\n    assert candidate(s = \"deeeeinedede\",k = 4) == 2\n    assert candidate(s = \"abcdedcba\",k = 4) == 1\n    assert candidate(s = \"aabbccddeeeffgg\",k = 2) == 7\n    assert candidate(s = \"abcdedcbaabacdfgdcaba\",k = 5) == 1\n    assert candidate(s = \"zzzzyyyxxxwwvvuuttssrrqqppoonnmmlkkjjiihhggffeeddccbbaaa\",k = 4) == 1\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 2) == 26\n    assert candidate(s = \"aaaaabbbaaaaa\",k = 4) == 3\n    assert candidate(s = \"abacabadabacaba\",k = 4) == 2\n    assert candidate(s = \"madamimadam\",k = 4) == 2\n", "comparison": "exact"}, "public_tests": ["\"abaccdbbd\"\n3", "\"adbcda\"\n2"], "hints": ["Try to use dynamic programming to solve the problem.", "let dp[i] be the answer for the prefix s[0…i].", "The final answer to the problem will be dp[n-1]. How do you compute this dp?"], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().maxPalindromes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:06+00:00", "tests_total": 109, "tests_dropped": 1, "flags": [], "topic_tags": ["two-pointers", "string", "dynamic-programming", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maxPalindromes(self, s: str, k: int) -> int:", "container": "Solution", "callable": "maxPalindromes", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2475, "task_id": "number-of-unequal-triplets-in-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed array of positive integers nums. Find the number of triplets (i, j, k) that meet the following conditions:\n\n- 0 <= i < j < k < nums.length\n- nums[i], nums[j], and nums[k] are pairwise distinct.\n  - In other words, nums[i] != nums[j], nums[i] != nums[k], and nums[j] != nums[k].\n\nReturn the number of triplets that meet the conditions.\n\nExample 1:\n\nInput: nums = [4,4,2,4,3]\nOutput: 3\nExplanation: The following triplets meet the conditions:\n- (0, 2, 4) because 4 != 2 != 3\n- (1, 2, 4) because 4 != 2 != 3\n- (2, 3, 4) because 2 != 4 != 3\nSince there are 3 triplets, we return 3.\nNote that (2, 0, 4) is not a valid triplet because 2 > 0.\n\nExample 2:\n\nInput: nums = [1,1,1,1,1]\nOutput: 0\nExplanation: No triplets meet the conditions so we return 0.\n\nConstraints:\n\n- 3 <= nums.length <= 100\n- 1 <= nums[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 20\n    assert candidate(nums = [1, 2, 2, 3, 4]) == 7\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7]) == 96\n    assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n    assert candidate(nums = [1, 2, 3]) == 1\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [10, 20, 30, 40, 50]) == 10\n    assert candidate(nums = [1, 2, 3, 4, 5]) == 10\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 120\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 120\n    assert candidate(nums = [4, 4, 2, 4, 3]) == 3\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13]) == 35\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 120\n    assert candidate(nums = [999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 4495\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 1140\n    assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60]) == 88\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 960\n    assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9]) == 3584\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 19600\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 15000\n    assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 252\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 225\n    assert candidate(nums = [5, 1, 4, 1, 2, 1, 5, 2, 5, 4, 5, 2, 1, 4, 2, 1, 5, 4, 2, 1, 5, 4, 2, 1, 4, 2, 1, 5, 4, 2]) == 1680\n    assert candidate(nums = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300]) == 64\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 960\n    assert candidate(nums = [1, 2, 3, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == 253\n    assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 455\n    assert candidate(nums = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9]) == 125\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 1331\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 960\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3]) == 243\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 80\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 2912\n    assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 2940\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1140\n    assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 84\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 960\n    assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 80\n    assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 64\n    assert candidate(nums = [7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 960\n    assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1, 19, 1, 20, 1, 21, 1, 22, 1, 23, 1, 24, 1, 25, 1, 26, 1, 27, 1, 28, 1, 29, 1, 30, 1, 31, 1, 32, 1, 33, 1, 34, 1, 35, 1, 36, 1, 37, 1, 38, 1, 39, 1, 40, 1, 41, 1, 42, 1, 43, 1, 44, 1, 45, 1, 46, 1, 47, 1, 48, 1, 49, 1, 50]) == 76048\n    assert candidate(nums = [5, 5, 5, 1, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 118\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 455\n    assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 88\n    assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 640\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 3, 4, 6, 7, 8, 9, 10]) == 444\n    assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 161700\n    assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 11, 12]) == 820\n    assert candidate(nums = [2, 1, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 343\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 120\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 1140\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1140\n    assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 80\n    assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10]) == 2530\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [100, 200, 100, 200, 300, 400, 500, 300, 200, 100]) == 68\n    assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n    assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == 4060\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 4060\n    assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 50\n    assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 0\n    assert candidate(nums = [50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57]) == 448\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1140\n    assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 2300\n    assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500]) == 390\n    assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7]) == 96\n    assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 455\n    assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 270\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1140\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 455\n    assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 0\n", "comparison": "exact"}, "public_tests": ["[4,4,2,4,3]", "[1,1,1,1,1]"], "hints": ["The constraints are very small. Can we try every triplet?", "Yes, we can. Use three loops to iterate through all the possible triplets, ensuring the condition i < j < k holds."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().unequalTriplets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:10+00:00", "tests_total": 74, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "hash-table", "sorting"]}, "language": "python", "interface": {"raw_signature": "def unequalTriplets(self, nums: list[int]) -> int:", "container": "Solution", "callable": "unequalTriplets", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2477, "task_id": "minimum-fuel-cost-to-report-to-the-capital", "difficulty": "Medium", "problem_description": "There is a tree (i.e., a connected, undirected graph with no cycles) structure country network consisting of n cities numbered from 0 to n - 1 and exactly n - 1 roads. The capital city is city 0. You are given a 2D integer array roads where roads[i] = [a_i, b_i] denotes that there exists a bidirectional road connecting cities a_i and b_i.\n\nThere is a meeting for the representatives of each city. The meeting is in the capital city.\n\nThere is a car in each city. You are given an integer seats that indicates the number of seats in each car.\n\nA representative can use the car in their city to travel or change the car and ride with another representative. The cost of traveling between two cities is one liter of fuel.\n\nReturn the minimum number of liters of fuel to reach the capital city.\n\nExample 1:\n\nInput: roads = [[0,1],[0,2],[0,3]], seats = 5\nOutput: 3\nExplanation:\n- Representative_1 goes directly to the capital with 1 liter of fuel.\n- Representative_2 goes directly to the capital with 1 liter of fuel.\n- Representative_3 goes directly to the capital with 1 liter of fuel.\nIt costs 3 liters of fuel at minimum.\nIt can be proven that 3 is the minimum number of liters of fuel needed.\n\nExample 2:\n\nInput: roads = [[3,1],[3,2],[1,0],[0,4],[0,5],[4,6]], seats = 2\nOutput: 7\nExplanation:\n- Representative_2 goes directly to city 3 with 1 liter of fuel.\n- Representative_2 and representative_3 go together to city 1 with 1 liter of fuel.\n- Representative_2 and representative_3 go together to the capital with 1 liter of fuel.\n- Representative_1 goes directly to the capital with 1 liter of fuel.\n- Representative_5 goes directly to the capital with 1 liter of fuel.\n- Representative_6 goes directly to city 4 with 1 liter of fuel.\n- Representative_4 and representative_6 go together to the capital with 1 liter of fuel.\nIt costs 7 liters of fuel at minimum.\nIt can be proven that 7 is the minimum number of liters of fuel needed.\n\nExample 3:\n\nInput: roads = [], seats = 1\nOutput: 0\nExplanation: No representatives need to travel to the capital city.\n\nConstraints:\n\n- 1 <= n <= 10^5\n- roads.length == n - 1\n- roads[i].length == 2\n- 0 <= a_i, b_i < n\n- a_i != b_i\n- roads represents a valid tree.\n- 1 <= seats <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],seats = 4) == 6\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3]],seats = 5) == 3\n    assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4]],seats = 3) == 5\n    assert candidate(roads = [],seats = 1) == 0\n    assert candidate(roads = [[3, 1], [3, 2], [1, 0], [0, 4], [0, 5], [4, 6]],seats = 2) == 7\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26]],seats = 8) == 28\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [6, 8], [6, 9]],seats = 3) == 11\n    assert candidate(roads = [[0, 1], [0, 2], [2, 3], [2, 4], [4, 5], [4, 6], [6, 7], [6, 8], [8, 9], [8, 10], [10, 11]],seats = 2) == 21\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13]],seats = 4) == 15\n    assert candidate(roads = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23]],seats = 6) == 31\n    assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]],seats = 5) == 34\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],seats = 10) == 9\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30], [15, 31], [15, 32], [16, 33], [16, 34], [17, 35], [17, 36], [18, 37], [18, 38], [19, 39], [19, 40]],seats = 5) == 53\n    assert candidate(roads = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35], [18, 36], [18, 37], [19, 38], [19, 39]],seats = 12) == 45\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],seats = 3) == 12\n    assert candidate(roads = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7], [6, 8], [6, 9], [7, 10], [7, 11]],seats = 4) == 16\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [9, 22], [10, 23], [10, 24], [10, 25], [11, 26], [11, 27], [11, 28], [12, 29], [12, 30], [12, 31], [13, 32], [13, 33], [13, 34], [14, 35], [14, 36], [15, 37], [15, 38], [16, 39], [16, 40]],seats = 2) == 84\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],seats = 3) == 12\n    assert candidate(roads = [[0, 1], [1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [9, 22], [10, 23], [10, 24], [10, 25], [11, 26], [11, 27], [11, 28], [12, 29], [12, 30], [12, 31]],seats = 3) == 53\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12]],seats = 7) == 12\n    assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],seats = 5) == 13\n    assert candidate(roads = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],seats = 4) == 8\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],seats = 4) == 11\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24]],seats = 6) == 29\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 19], [14, 20], [15, 21], [16, 22], [17, 23], [18, 24], [19, 25], [20, 26], [21, 27], [22, 28], [23, 29], [24, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36]],seats = 8) == 42\n    assert candidate(roads = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7]],seats = 3) == 10\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],seats = 5) == 16\n    assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],seats = 4) == 32\n    assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],seats = 4) == 15\n    assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],seats = 6) == 11\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],seats = 2) == 12\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],seats = 5) == 11\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [4, 14], [5, 15], [5, 16], [5, 17]],seats = 10) == 18\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30], [15, 31], [15, 32], [16, 33], [16, 34], [17, 35], [17, 36], [18, 37], [18, 38], [19, 39], [19, 40]],seats = 9) == 44\n    assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 10], [10, 11], [11, 12], [12, 13], [13, 14]],seats = 3) == 25\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 19], [14, 20], [15, 21], [16, 22], [17, 23], [18, 24], [19, 25], [20, 26], [21, 27], [22, 28], [23, 29], [24, 30]],seats = 7) == 33\n    assert candidate(roads = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31]],seats = 8) == 36\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [7, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [10, 26], [11, 27], [11, 28], [12, 29], [12, 30]],seats = 8) == 33\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26]],seats = 7) == 29\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26]],seats = 6) == 32\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [8, 22], [8, 23], [9, 24], [9, 25], [9, 26], [10, 27], [10, 28], [10, 29]],seats = 10) == 31\n    assert candidate(roads = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [6, 7], [7, 8]],seats = 4) == 10\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15]],seats = 4) == 18\n    assert candidate(roads = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [7, 10], [7, 11], [8, 12], [8, 13], [9, 14], [9, 15]],seats = 6) == 18\n    assert candidate(roads = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6]],seats = 3) == 8\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [9, 22], [10, 23], [10, 24], [11, 25], [11, 26], [12, 27], [12, 28]],seats = 6) == 32\n    assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],seats = 5) == 11\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [5, 16], [5, 17], [5, 18], [6, 19], [6, 20], [6, 21], [7, 22], [7, 23], [7, 24], [8, 25], [8, 26], [8, 27], [9, 28], [9, 29], [9, 30]],seats = 9) == 32\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17]],seats = 5) == 19\n    assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],seats = 2) == 25\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7], [5, 8], [6, 9], [6, 10]],seats = 5) == 11\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27], [13, 28], [13, 29], [14, 30], [14, 31], [15, 32], [15, 33]],seats = 9) == 35\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13]],seats = 5) == 14\n    assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]],seats = 2) == 225\n    assert candidate(roads = [[0, 1], [1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [10, 24], [11, 25], [11, 26]],seats = 6) == 33\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24]],seats = 7) == 27\n    assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],seats = 7) == 36\n    assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],seats = 2) == 30\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [9, 22], [10, 23], [10, 24], [10, 25], [11, 26], [11, 27], [11, 28], [12, 29], [12, 30], [12, 31], [13, 32], [13, 33], [13, 34], [14, 35], [14, 36], [15, 37], [15, 38], [16, 39], [16, 40], [17, 41], [17, 42], [18, 43], [18, 44], [19, 45], [19, 46], [20, 47], [20, 48], [21, 49], [21, 50], [22, 51], [22, 52], [23, 53], [23, 54], [23, 55], [24, 56], [24, 57], [25, 58], [25, 59]],seats = 4) == 88\n    assert candidate(roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],seats = 6) == 16\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [5, 16], [5, 17], [5, 18], [6, 19], [6, 20], [6, 21]],seats = 8) == 22\n    assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],seats = 6) == 24\n    assert candidate(roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17]],seats = 4) == 19\n    assert candidate(roads = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19]],seats = 5) == 26\n    assert candidate(roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],seats = 2) == 64\n", "comparison": "exact"}, "public_tests": ["[[0,1],[0,2],[0,3]]\n5", "[[3,1],[3,2],[1,0],[0,4],[0,5],[4,6]]\n2", "[]\n1"], "hints": ["Can you record the size of each subtree?", "If n people meet on the same node, what is the minimum number of cars needed?"], "metadata": {"canonical_parameter_names": ["roads", "seats"], "leetcode_dataset_entry_point": "Solution().minimumFuelCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:16+00:00", "tests_total": 65, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["tree", "depth-first-search", "breadth-first-search", "graph"]}, "language": "python", "interface": {"raw_signature": "def minimumFuelCost(self, roads: list[list[int]], seats: int) -> int:", "container": "Solution", "callable": "minimumFuelCost", "parameters": [{"name": "roads", "type": "list[list[int]]"}, {"name": "seats", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2478, "task_id": "number-of-beautiful-partitions", "difficulty": "Hard", "problem_description": "You are given a string s that consists of the digits '1' to '9' and two integers k and minLength.\n\nA partition of s is called beautiful if:\n\n- s is partitioned into k non-intersecting substrings.\n- Each substring has a length of at least minLength.\n- Each substring starts with a prime digit and ends with a non-prime digit. Prime digits are '2', '3', '5', and '7', and the rest of the digits are non-prime.\n\nReturn the number of beautiful partitions of s. Since the answer may be very large, return it modulo 10^9 + 7.\n\nA substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: s = \"23542185131\", k = 3, minLength = 2\nOutput: 3\nExplanation: There exists three ways to create a beautiful partition:\n\"2354 | 218 | 5131\"\n\"2354 | 21851 | 31\"\n\"2354218 | 51 | 31\"\n\nExample 2:\n\nInput: s = \"23542185131\", k = 3, minLength = 3\nOutput: 1\nExplanation: There exists one way to create a beautiful partition: \"2354 | 218 | 5131\".\n\nExample 3:\n\nInput: s = \"3312958\", k = 3, minLength = 1\nOutput: 1\nExplanation: There exists one way to create a beautiful partition: \"331 | 29 | 58\".\n\nConstraints:\n\n- 1 <= k, minLength <= s.length <= 1000\n- s consists of the digits '1' to '9'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"52372938462673572\",k = 4,minLength = 2) == 0\n    assert candidate(s = \"33333\",k = 1,minLength = 1) == 0\n    assert candidate(s = \"23542185131\",k = 3,minLength = 3) == 1\n    assert candidate(s = \"3312958\",k = 3,minLength = 1) == 1\n    assert candidate(s = \"253179\",k = 2,minLength = 1) == 1\n    assert candidate(s = \"72531\",k = 1,minLength = 5) == 1\n    assert candidate(s = \"357291\",k = 2,minLength = 2) == 0\n    assert candidate(s = \"22354\",k = 1,minLength = 1) == 1\n    assert candidate(s = \"23542185131\",k = 3,minLength = 2) == 3\n    assert candidate(s = \"77777\",k = 5,minLength = 1) == 0\n    assert candidate(s = \"75319\",k = 1,minLength = 5) == 1\n    assert candidate(s = \"22222\",k = 5,minLength = 1) == 0\n    assert candidate(s = \"2375193\",k = 2,minLength = 2) == 0\n    assert candidate(s = \"3572935729\",k = 5,minLength = 2) == 0\n    assert candidate(s = \"23751\",k = 2,minLength = 1) == 0\n    assert candidate(s = \"2222222222\",k = 5,minLength = 1) == 0\n    assert candidate(s = \"2233445566778899\",k = 2,minLength = 4) == 2\n    assert candidate(s = \"7223357\",k = 2,minLength = 1) == 0\n    assert candidate(s = \"23759237592375923759\",k = 5,minLength = 4) == 0\n    assert candidate(s = \"35757575757575\",k = 7,minLength = 1) == 0\n    assert candidate(s = \"2354218513197531\",k = 4,minLength = 3) == 2\n    assert candidate(s = \"317317317317317317317317317317\",k = 8,minLength = 2) == 0\n    assert candidate(s = \"353535353535353535353535\",k = 10,minLength = 2) == 0\n    assert candidate(s = \"2357235723572357235723572357\",k = 10,minLength = 2) == 0\n    assert candidate(s = \"23572357235723572357235723572357235723\",k = 10,minLength = 4) == 0\n    assert candidate(s = \"235423542354\",k = 3,minLength = 2) == 1\n    assert candidate(s = \"373737373737373737373737\",k = 10,minLength = 2) == 0\n    assert candidate(s = \"2354218513123542185131\",k = 5,minLength = 2) == 35\n    assert candidate(s = \"75319284628462846284\",k = 4,minLength = 3) == 4\n    assert candidate(s = \"331295833129583312958331295833129583312958\",k = 10,minLength = 3) == 110\n    assert candidate(s = \"77777777777777777777777777777777777777\",k = 5,minLength = 1) == 0\n    assert candidate(s = \"235711317113\",k = 3,minLength = 3) == 0\n    assert candidate(s = \"23542185131\",k = 5,minLength = 1) == 0\n    assert candidate(s = \"2233335555777711112222333355557777\",k = 6,minLength = 2) == 0\n    assert candidate(s = \"2333353333533337333313333\",k = 7,minLength = 2) == 0\n    assert candidate(s = \"23572357235723572357235723572357235723\",k = 15,minLength = 5) == 0\n    assert candidate(s = \"235723572357235723572357235723572357\",k = 15,minLength = 2) == 0\n    assert candidate(s = \"23547186918691869\",k = 4,minLength = 2) == 0\n    assert candidate(s = \"331295897531\",k = 4,minLength = 1) == 1\n    assert candidate(s = \"22222222222222222222\",k = 10,minLength = 2) == 0\n    assert candidate(s = \"7777777777777777777777777777\",k = 8,minLength = 3) == 0\n    assert candidate(s = \"235723572357\",k = 6,minLength = 2) == 0\n    assert candidate(s = \"235235235235235235\",k = 7,minLength = 3) == 0\n    assert candidate(s = \"733733733733733733733733\",k = 10,minLength = 2) == 0\n    assert candidate(s = \"2375913759231\",k = 4,minLength = 2) == 0\n    assert candidate(s = \"222333444555666777888999\",k = 3,minLength = 3) == 1\n    assert candidate(s = \"735235235235235235\",k = 7,minLength = 2) == 0\n    assert candidate(s = \"252525252525252525252525\",k = 10,minLength = 2) == 0\n    assert candidate(s = \"223542185131223542185131223542185131\",k = 9,minLength = 3) == 1\n    assert candidate(s = \"732519753189273189\",k = 4,minLength = 3) == 0\n    assert candidate(s = \"233757537537537537537\",k = 8,minLength = 3) == 0\n    assert candidate(s = \"22222222222222222222222222222222222222\",k = 15,minLength = 1) == 0\n    assert candidate(s = \"222333555777111222333\",k = 7,minLength = 2) == 0\n    assert candidate(s = \"735218513735218513735218513735\",k = 7,minLength = 3) == 0\n    assert candidate(s = \"272727272727\",k = 6,minLength = 1) == 0\n    assert candidate(s = \"23572357235723572357\",k = 5,minLength = 2) == 0\n    assert candidate(s = \"222333555777111\",k = 4,minLength = 3) == 0\n    assert candidate(s = \"37537537537537\",k = 6,minLength = 3) == 0\n    assert candidate(s = \"22335577112233557711\",k = 6,minLength = 2) == 0\n    assert candidate(s = \"2573197319731973197319\",k = 9,minLength = 2) == 0\n    assert candidate(s = \"2354218513171925235729\",k = 6,minLength = 3) == 0\n    assert candidate(s = \"232323232323232323232323\",k = 10,minLength = 2) == 0\n    assert candidate(s = \"222333555777111222333555777111\",k = 4,minLength = 3) == 0\n    assert candidate(s = \"753197531975319753\",k = 10,minLength = 2) == 0\n    assert candidate(s = \"33333333333333333333333333333333333333\",k = 10,minLength = 1) == 0\n    assert candidate(s = \"2323232323232323\",k = 8,minLength = 2) == 0\n    assert candidate(s = \"33333333333333\",k = 5,minLength = 2) == 0\n    assert candidate(s = \"33129583312958331295833129583312958331\",k = 10,minLength = 3) == 15\n    assert candidate(s = \"373737373737\",k = 6,minLength = 1) == 0\n    assert candidate(s = \"2233557711886644\",k = 6,minLength = 1) == 0\n    assert candidate(s = \"235476918235476918235476918\",k = 6,minLength = 3) == 1\n    assert candidate(s = \"333222111777555333222111\",k = 9,minLength = 2) == 0\n    assert candidate(s = \"29292929292929\",k = 3,minLength = 3) == 3\n    assert candidate(s = \"7235719753197532\",k = 5,minLength = 2) == 0\n    assert candidate(s = \"35235235235235235235235235235\",k = 10,minLength = 3) == 0\n    assert candidate(s = \"333555777222444666888999\",k = 5,minLength = 2) == 0\n    assert candidate(s = \"373737373737373737\",k = 5,minLength = 3) == 0\n    assert candidate(s = \"222333555777111222333555777111\",k = 6,minLength = 3) == 0\n    assert candidate(s = \"23572357235723\",k = 1,minLength = 1) == 0\n    assert candidate(s = \"23571113171923293137414347\",k = 10,minLength = 2) == 0\n    assert candidate(s = \"22222222222222\",k = 2,minLength = 5) == 0\n    assert candidate(s = \"23751937519375193\",k = 5,minLength = 2) == 0\n    assert candidate(s = \"235421851312354218513123542185\",k = 6,minLength = 4) == 0\n    assert candidate(s = \"22222222222222222222222222222222222222\",k = 20,minLength = 1) == 0\n    assert candidate(s = \"27272727272727272727272727272\",k = 8,minLength = 2) == 0\n    assert candidate(s = \"2222222222222222222222222222\",k = 12,minLength = 1) == 0\n    assert candidate(s = \"753753753753753753753753753753753753753753\",k = 15,minLength = 5) == 0\n    assert candidate(s = \"235421851312354218513123542185131\",k = 6,minLength = 2) == 462\n    assert candidate(s = \"52373197357537325\",k = 5,minLength = 1) == 0\n    assert candidate(s = \"23232323232323232323232323\",k = 10,minLength = 2) == 0\n    assert candidate(s = \"222333555777222333555777222333555777\",k = 6,minLength = 4) == 0\n    assert candidate(s = \"23542185131973\",k = 4,minLength = 2) == 0\n    assert candidate(s = \"375375375375\",k = 5,minLength = 2) == 0\n    assert candidate(s = \"75319753197531975319753197531975\",k = 8,minLength = 4) == 0\n    assert candidate(s = \"3257113257113257113257\",k = 10,minLength = 2) == 0\n    assert candidate(s = \"223355771199\",k = 6,minLength = 2) == 0\n    assert candidate(s = \"375375375375375375375375375375\",k = 7,minLength = 4) == 0\n    assert candidate(s = \"23572357235723\",k = 2,minLength = 5) == 0\n    assert candidate(s = \"2354218513123542185131\",k = 6,minLength = 2) == 21\n    assert candidate(s = \"23572357235723572357235723572357235723\",k = 15,minLength = 3) == 0\n    assert candidate(s = \"3572535725357\",k = 5,minLength = 1) == 0\n    assert candidate(s = \"2357135713571357\",k = 7,minLength = 2) == 0\n    assert candidate(s = \"22223333555577772222\",k = 4,minLength = 5) == 0\n    assert candidate(s = \"53725372537253725372537253725372\",k = 10,minLength = 3) == 0\n    assert candidate(s = \"257357257357\",k = 4,minLength = 2) == 0\n    assert candidate(s = \"2197531975319753\",k = 8,minLength = 3) == 0\n    assert candidate(s = \"2357235723572357\",k = 1,minLength = 15) == 0\n    assert candidate(s = \"23542185131719\",k = 5,minLength = 2) == 1\n    assert candidate(s = \"57575757575757575757575757575\",k = 6,minLength = 4) == 0\n    assert candidate(s = \"22335577223355772233\",k = 6,minLength = 1) == 0\n    assert candidate(s = \"2357235723572357235723572357\",k = 7,minLength = 5) == 0\n    assert candidate(s = \"37531975319753197537531975319753\",k = 12,minLength = 2) == 0\n    assert candidate(s = \"25252525252525\",k = 5,minLength = 2) == 0\n    assert candidate(s = \"21212121212121\",k = 3,minLength = 2) == 15\n    assert candidate(s = \"2357198462357\",k = 4,minLength = 2) == 0\n    assert candidate(s = \"235723572357235723572357\",k = 10,minLength = 2) == 0\n    assert candidate(s = \"23232323232323232323232323232323\",k = 10,minLength = 2) == 0\n", "comparison": "exact"}, "public_tests": ["\"23542185131\"\n3\n2", "\"23542185131\"\n3\n3", "\"3312958\"\n3\n1"], "hints": ["Try using a greedy approach where you take as many digits as possible from the left of the string for each partition.", "You can also use a dynamic programming approach, let an array dp where dp[i] is the solution of the problem for the prefix of the string ending at index i, the answer of the problem will be dp[n-1]. What are the transitions of this dp?"], "metadata": {"canonical_parameter_names": ["s", "k", "minLength"], "leetcode_dataset_entry_point": "Solution().beautifulPartitions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:18+00:00", "tests_total": 117, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def beautifulPartitions(self, s: str, k: int, minLength: int) -> int:", "container": "Solution", "callable": "beautifulPartitions", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}, {"name": "minLength", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2481, "task_id": "minimum-cuts-to-divide-a-circle", "difficulty": "Easy", "problem_description": "A valid cut in a circle can be:\n\n- A cut that is represented by a straight line that touches two points on the edge of the circle and passes through its center, or\n- A cut that is represented by a straight line that touches one point on the edge of the circle and its center.\n\nSome valid and invalid cuts are shown in the figures below.\n\nGiven the integer n, return the minimum number of cuts needed to divide a circle into n equal slices.\n\nExample 1:\n\nInput: n = 4\nOutput: 2\nExplanation:\nThe above figure shows how cutting the circle twice through the middle divides it into 4 equal slices.\n\nExample 2:\n\nInput: n = 3\nOutput: 3\nExplanation:\nAt least 3 cuts are needed to divide the circle into 3 equal slices.\nIt can be shown that less than 3 cuts cannot result in 3 slices of equal size and shape.\nAlso note that the first cut will not divide the circle into distinct parts.\n\nConstraints:\n\n- 1 <= n <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 3) == 3\n    assert candidate(n = 100) == 50\n    assert candidate(n = 4) == 2\n    assert candidate(n = 99) == 99\n    assert candidate(n = 17) == 17\n    assert candidate(n = 2) == 1\n    assert candidate(n = 1) == 0\n    assert candidate(n = 50) == 25\n    assert candidate(n = 7) == 7\n    assert candidate(n = 10) == 5\n    assert candidate(n = 5) == 5\n    assert candidate(n = 97) == 97\n    assert candidate(n = 61) == 61\n    assert candidate(n = 49) == 49\n    assert candidate(n = 12) == 6\n    assert candidate(n = 21) == 21\n    assert candidate(n = 60) == 30\n    assert candidate(n = 30) == 15\n    assert candidate(n = 40) == 20\n    assert candidate(n = 64) == 32\n    assert candidate(n = 33) == 33\n    assert candidate(n = 37) == 37\n    assert candidate(n = 16) == 8\n    assert candidate(n = 23) == 23\n    assert candidate(n = 73) == 73\n    assert candidate(n = 42) == 21\n    assert candidate(n = 90) == 45\n    assert candidate(n = 8) == 4\n    assert candidate(n = 79) == 79\n    assert candidate(n = 89) == 89\n    assert candidate(n = 75) == 75\n    assert candidate(n = 32) == 16\n    assert candidate(n = 20) == 10\n    assert candidate(n = 19) == 19\n    assert candidate(n = 91) == 91\n    assert candidate(n = 81) == 81\n    assert candidate(n = 11) == 11\n    assert candidate(n = 15) == 15\n    assert candidate(n = 85) == 85\n    assert candidate(n = 41) == 41\n    assert candidate(n = 9) == 9\n    assert candidate(n = 6) == 3\n    assert candidate(n = 13) == 13\n    assert candidate(n = 25) == 25\n", "comparison": "exact"}, "public_tests": ["4", "3"], "hints": ["Think about odd and even values separately.", "When will we not have to cut the circle at all?"], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().numberOfCuts", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:23+00:00", "tests_total": 44, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["math", "geometry"]}, "language": "python", "interface": {"raw_signature": "def numberOfCuts(self, n: int) -> int:", "container": "Solution", "callable": "numberOfCuts", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2482, "task_id": "difference-between-ones-and-zeros-in-row-and-column", "difficulty": "Medium", "problem_description": "You are given a 0-indexed m x n binary matrix grid.\n\nA 0-indexed m x n difference matrix diff is created with the following procedure:\n\n- Let the number of ones in the i^th row be onesRow_i.\n- Let the number of ones in the j^th column be onesCol_j.\n- Let the number of zeros in the i^th row be zerosRow_i.\n- Let the number of zeros in the j^th column be zerosCol_j.\n- diff[i][j] = onesRow_i + onesCol_j - zerosRow_i - zerosCol_j\n\nReturn the difference matrix diff.\n\nExample 1:\n\nInput: grid = [[0,1,1],[1,0,1],[0,0,1]]\nOutput: [[0,0,4],[0,0,4],[-2,-2,2]]\nExplanation:\n- diff[0][0] = onesRow_0 + onesCol_0 - zerosRow_0 - zerosCol_0 = 2 + 1 - 1 - 2 = 0\n- diff[0][1] = onesRow_0 + onesCol_1 - zerosRow_0 - zerosCol_1 = 2 + 1 - 1 - 2 = 0\n- diff[0][2] = onesRow_0 + onesCol_2 - zerosRow_0 - zerosCol_2 = 2 + 3 - 1 - 0 = 4\n- diff[1][0] = onesRow_1 + onesCol_0 - zerosRow_1 - zerosCol_0 = 2 + 1 - 1 - 2 = 0\n- diff[1][1] = onesRow_1 + onesCol_1 - zerosRow_1 - zerosCol_1 = 2 + 1 - 1 - 2 = 0\n- diff[1][2] = onesRow_1 + onesCol_2 - zerosRow_1 - zerosCol_2 = 2 + 3 - 1 - 0 = 4\n- diff[2][0] = onesRow_2 + onesCol_0 - zerosRow_2 - zerosCol_0 = 1 + 1 - 2 - 2 = -2\n- diff[2][1] = onesRow_2 + onesCol_1 - zerosRow_2 - zerosCol_1 = 1 + 1 - 2 - 2 = -2\n- diff[2][2] = onesRow_2 + onesCol_2 - zerosRow_2 - zerosCol_2 = 1 + 3 - 2 - 0 = 2\n\nExample 2:\n\nInput: grid = [[1,1,1],[1,1,1]]\nOutput: [[5,5,5],[5,5,5]]\nExplanation:\n- diff[0][0] = onesRow_0 + onesCol_0 - zerosRow_0 - zerosCol_0 = 3 + 2 - 0 - 0 = 5\n- diff[0][1] = onesRow_0 + onesCol_1 - zerosRow_0 - zerosCol_1 = 3 + 2 - 0 - 0 = 5\n- diff[0][2] = onesRow_0 + onesCol_2 - zerosRow_0 - zerosCol_2 = 3 + 2 - 0 - 0 = 5\n- diff[1][0] = onesRow_1 + onesCol_0 - zerosRow_1 - zerosCol_0 = 3 + 2 - 0 - 0 = 5\n- diff[1][1] = onesRow_1 + onesCol_1 - zerosRow_1 - zerosCol_1 = 3 + 2 - 0 - 0 = 5\n- diff[1][2] = onesRow_1 + onesCol_2 - zerosRow_1 - zerosCol_2 = 3 + 2 - 0 - 0 = 5\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 10^5\n- 1 <= m * n <= 10^5\n- grid[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 0, 1, 0]]) == [[1, -1, 1, -1], [1, -1, 1, -1], [1, -1, 1, -1]]\n    assert candidate(grid = [[0, 1, 1], [1, 0, 1], [0, 0, 1]]) == [[0, 0, 4], [0, 0, 4], [-2, -2, 2]]\n    assert candidate(grid = [[1, 0], [0, 1]]) == [[0, 0], [0, 0]]\n    assert candidate(grid = [[1]]) == [[2]]\n    assert candidate(grid = [[0]]) == [[-2]]\n    assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 0, 0]]) == [[1, 1, -1, -1], [1, 1, -1, -1], [1, 1, -1, -1]]\n    assert candidate(grid = [[1, 1, 1], [1, 1, 1]]) == [[5, 5, 5], [5, 5, 5]]\n    assert candidate(grid = [[0, 0, 0], [0, 0, 0]]) == [[-5, -5, -5], [-5, -5, -5]]\n    assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]\n    assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == [[-2, -2, -4, -2, -2], [-2, -2, -4, -2, -2], [-4, -4, -6, -4, -4], [-2, -2, -4, -2, -2], [-2, -2, -4, -2, -2]]\n    assert candidate(grid = [[1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 0, 0]]) == [[2, 2, 2, 0, 0], [0, 0, 0, -2, -2], [2, 2, 2, 0, 0], [0, 0, 0, -2, -2], [2, 2, 2, 0, 0]]\n    assert candidate(grid = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 0], [0, 0, 0, 1, 1], [1, 1, 1, 0, 0], [0, 0, 1, 1, 1]]) == [[-2, -2, 0, 0, -2], [-2, -2, 0, 0, -2], [-2, -2, 0, 0, -2], [0, 0, 2, 2, 0], [0, 0, 2, 2, 0]]\n    assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == [[8, 4, 4, 8], [4, 0, 0, 4], [4, 0, 0, 4], [8, 4, 4, 8]]\n    assert candidate(grid = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == [[-5, -5, -5, -5, -5], [5, 5, 5, 5, 5], [-1, -1, -1, -1, -1], [1, 1, 1, 1, 1]]\n    assert candidate(grid = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]\n    assert candidate(grid = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == [[6, 4, 6, 4, 6], [-4, -6, -4, -6, -4], [2, 0, 2, 0, 2], [0, -2, 0, -2, 0], [2, 0, 2, 0, 2]]\n    assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]\n    assert candidate(grid = [[0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0]]) == [[-6, -6, -6, 0, 0, 0, -6, -6, -6], [-6, -6, -6, 0, 0, 0, -6, -6, -6], [-6, -6, -6, 0, 0, 0, -6, -6, -6], [0, 0, 0, 6, 6, 6, 0, 0, 0], [0, 0, 0, 6, 6, 6, 0, 0, 0], [0, 0, 0, 6, 6, 6, 0, 0, 0], [-6, -6, -6, 0, 0, 0, -6, -6, -6], [-6, -6, -6, 0, 0, 0, -6, -6, -6], [-6, -6, -6, 0, 0, 0, -6, -6, -6]]\n    assert candidate(grid = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == [[-5, -5, -5, -5, -5], [5, 5, 5, 5, 5], [-5, -5, -5, -5, -5], [5, 5, 5, 5, 5]]\n    assert candidate(grid = [[1, 0, 0, 1], [1, 1, 0, 0], [0, 0, 1, 1], [0, 1, 1, 0]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n    assert candidate(grid = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 1, 1, 0], [0, 1, 0, 1, 1]]) == [[-1, -1, -1, 1, -1], [1, 1, 1, 3, 1], [1, 1, 1, 3, 1], [1, 1, 1, 3, 1]]\n    assert candidate(grid = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 0, 0, 0], [1, 1, 1, 1]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [-4, -4, -4, -4], [4, 4, 4, 4]]\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[-10, -10, -10, -10, -10, -10], [-10, -10, -10, -10, -10, -10], [-10, -10, -10, -10, -10, -10], [-10, -10, -10, -10, -10, -10]]\n    assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == [[2, 2, 2, 2, 2, 2], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [-2, -2, -2, -2, -2, -2], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]\n    assert candidate(grid = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n    assert candidate(grid = [[1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]\n    assert candidate(grid = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0]]) == [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == [[10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10]]\n    assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == [[1, -1, 1, -1], [1, -1, 1, -1], [1, -1, 1, -1], [1, -1, 1, -1], [1, -1, 1, -1]]\n    assert candidate(grid = [[1, 1, 0, 0, 0], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == [[-1, -1, -1, -1, -1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [-1, -1, -1, -1, -1]]\n    assert candidate(grid = [[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 1]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n    assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == [[-12, -4, -8, -8, -4, -12], [-4, 4, 0, 0, 4, -4], [-8, 0, -4, -4, 0, -8], [-8, 0, -4, -4, 0, -8], [-4, 4, 0, 0, 4, -4], [-12, -4, -8, -8, -4, -12]]\n    assert candidate(grid = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 0, 1, 1], [1, 1, 0, 0]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n    assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == [[-2, 0, -2, 0, -2], [0, 2, 0, 2, 0], [-2, 0, -2, 0, -2]]\n    assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1], [0, 1, 0]]) == [[1, 1, 1], [-1, -1, -1], [1, 1, 1], [-1, -1, -1]]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == [[10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10]]\n    assert candidate(grid = [[1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]]) == [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]\n    assert candidate(grid = [[1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1]]) == [[2, 2, 2, 2, 2], [0, 0, 0, 0, 0], [2, 2, 2, 2, 2], [0, 0, 0, 0, 0], [6, 6, 6, 6, 6]]\n    assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 0, 0], [0, 0, 1, 1]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n    assert candidate(grid = [[0, 1, 0, 1, 1], [1, 0, 1, 0, 0], [0, 0, 0, 1, 1], [1, 1, 1, 0, 0]]) == [[1, 1, 1, 1, 1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [1, 1, 1, 1, 1]]\n    assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == [[-7, -7, -7, -7], [-7, -7, -7, -7], [-7, -7, -7, -7]]\n    assert candidate(grid = [[1, 1, 0, 0, 1], [1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [0, 0, 0, 1, 1], [1, 1, 1, 0, 0]]) == [[2, 2, 2, 0, 2], [2, 2, 2, 0, 2], [2, 2, 2, 0, 2], [0, 0, 0, -2, 0], [2, 2, 2, 0, 2]]\n    assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == [[1, 1, 1, 1, 1], [-1, -1, -1, -1, -1], [1, 1, 1, 1, 1], [-1, -1, -1, -1, -1]]\n    assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == [[-9, -9, -9, -9, -9], [-9, -9, -9, -9, -9], [-9, -9, -9, -9, -9], [-9, -9, -9, -9, -9]]\n    assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == [[1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1]]\n    assert candidate(grid = [[0, 0, 1, 1], [1, 0, 0, 1], [1, 1, 0, 0]]) == [[1, -1, -1, 1], [1, -1, -1, 1], [1, -1, -1, 1]]\n    assert candidate(grid = [[0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [0, 0, 0, 0, 0]]) == [[0, 0, 0, 0, 0], [-2, -2, -2, -2, -2], [-2, -2, -2, -2, -2], [0, 0, 0, 0, 0], [-6, -6, -6, -6, -6]]\n    assert candidate(grid = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]) == [[5, 5, 5, 5, 5], [-5, -5, -5, -5, -5], [5, 5, 5, 5, 5], [-5, -5, -5, -5, -5]]\n    assert candidate(grid = [[0, 0, 0, 1], [1, 1, 1, 0], [0, 1, 0, 1]]) == [[-3, -1, -3, -1], [1, 3, 1, 3], [-1, 1, -1, 1]]\n    assert candidate(grid = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == [[-4, -4, -4, -4], [-4, -4, -4, -4], [-4, -4, -4, -4], [-4, -4, -4, -4]]\n    assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n    assert candidate(grid = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == [[-1, -1, -1, -1, -1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [-1, -1, -1, -1, -1]]\n    assert candidate(grid = [[1, 1, 0, 0, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 1, 0], [1, 0, 0, 1, 1]]) == [[2, 0, 0, 2, 2], [2, 0, 0, 2, 2], [0, -2, -2, 0, 0], [0, -2, -2, 0, 0], [2, 0, 0, 2, 2]]\n    assert candidate(grid = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n    assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1, 0], [1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1, 0]]) == [[-3, 1, 1, -3, 1, 1, -3], [-1, 3, 3, -1, 3, 3, -1], [-1, 3, 3, -1, 3, 3, -1], [-3, 1, 1, -3, 1, 1, -3], [-1, 3, 3, -1, 3, 3, -1], [-1, 3, 3, -1, 3, 3, -1]]\n    assert candidate(grid = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == [[-1, 1, -1, 1], [-1, 1, -1, 1], [-1, 1, -1, 1]]\n    assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n    assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0], [1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0]]) == [[-1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1]]\n    assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]\n    assert candidate(grid = [[1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == [[1, 1, 1, 1, 1], [-1, -1, -1, -1, -1], [1, 1, 1, 1, 1], [-1, -1, -1, -1, -1]]\n    assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [1, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 1]]) == [[-4, -4, -6, -6, -4, -4], [-4, -4, -6, -6, -4, -4], [-6, -6, -8, -8, -6, -6], [-6, -6, -8, -8, -6, -6], [-4, -4, -6, -6, -4, -4], [-4, -4, -6, -6, -4, -4]]\n    assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == [[8, 8, 8, 8], [8, 8, 8, 8], [8, 8, 8, 8], [8, 8, 8, 8]]\n    assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == [[2, 0, 2, 0, 2], [0, -2, 0, -2, 0], [2, 0, 2, 0, 2]]\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]]\n    assert candidate(grid = [[0, 0, 1, 1, 0], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 1, 0, 1]]) == [[-2, -2, 0, 0, -2], [-2, -2, 0, 0, -2], [0, 0, 2, 2, 0], [-2, -2, 0, 0, -2], [0, 0, 2, 2, 0]]\n    assert candidate(grid = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 0, 0, 1], [1, 1, 1, 1]]) == [[0, 0, 0, 2], [0, 0, 0, 2], [-2, -2, -2, 0], [4, 4, 4, 6]]\n    assert candidate(grid = [[1, 0, 1, 1, 0], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 1, 0, 1]]) == [[2, 0, 2, 2, 0], [0, -2, 0, 0, -2], [2, 0, 2, 2, 0], [0, -2, 0, 0, -2], [2, 0, 2, 2, 0]]\n", "comparison": "exact"}, "public_tests": ["[[0,1,1],[1,0,1],[0,0,1]]", "[[1,1,1],[1,1,1]]"], "hints": ["You need to reuse information about a row or a column many times. Try storing it to avoid computing it multiple times.", "Use an array to store the number of 1’s in each row and another array to store the number of 1’s in each column. Once you know the number of 1’s in each row or column, you can also easily calculate the number of 0’s."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().onesMinusZeros", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:25+00:00", "tests_total": 67, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "matrix", "simulation"]}, "language": "python", "interface": {"raw_signature": "def onesMinusZeros(self, grid: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "onesMinusZeros", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2483, "task_id": "minimum-penalty-for-a-shop", "difficulty": "Medium", "problem_description": "You are given the customer visit log of a shop represented by a 0-indexed string customers consisting only of characters 'N' and 'Y':\n\n- if the i^th character is 'Y', it means that customers come at the i^th hour\n- whereas 'N' indicates that no customers come at the i^th hour.\n\nIf the shop closes at the j^th hour (0 <= j <= n), the penalty is calculated as follows:\n\n- For every hour when the shop is open and no customers come, the penalty increases by 1.\n- For every hour when the shop is closed and customers come, the penalty increases by 1.\n\nReturn the earliest hour at which the shop must be closed to incur a minimum penalty.\n\nNote that if a shop closes at the j^th hour, it means the shop is closed at the hour j.\n\nExample 1:\n\nInput: customers = \"YYNY\"\nOutput: 2\nExplanation:\n- Closing the shop at the 0^th hour incurs in 1+1+0+1 = 3 penalty.\n- Closing the shop at the 1^st hour incurs in 0+1+0+1 = 2 penalty.\n- Closing the shop at the 2^nd hour incurs in 0+0+0+1 = 1 penalty.\n- Closing the shop at the 3^rd hour incurs in 0+0+1+1 = 2 penalty.\n- Closing the shop at the 4^th hour incurs in 0+0+1+0 = 1 penalty.\nClosing the shop at 2^nd or 4^th hour gives a minimum penalty. Since 2 is earlier, the optimal closing time is 2.\n\nExample 2:\n\nInput: customers = \"NNNNN\"\nOutput: 0\nExplanation: It is best to close the shop at the 0^th hour as no customers arrive.\n\nExample 3:\n\nInput: customers = \"YYYY\"\nOutput: 4\nExplanation: It is best to close the shop at the 4^th hour as customers arrive at each hour.\n\nConstraints:\n\n- 1 <= customers.length <= 10^5\n- customers consists only of characters 'Y' and 'N'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(customers = \"YNYNYN\") == 1\n    assert candidate(customers = \"YNNYNYYNYN\") == 1\n    assert candidate(customers = \"NNYNNYNNYNNYNN\") == 0\n    assert candidate(customers = \"YYYYNNYYYYNNYYYYNNYYYYNNNN\") == 22\n    assert candidate(customers = \"YNYYYYYYNY\") == 8\n    assert candidate(customers = \"YNYYYYNNYY\") == 6\n    assert candidate(customers = \"NYYNNYNY\") == 3\n    assert candidate(customers = \"YNYNNYNYYN\") == 1\n    assert candidate(customers = \"NYYYYYNNNYYYYYYYYYYNNNNN\") == 19\n    assert candidate(customers = \"YNYNYNYNYN\") == 1\n    assert candidate(customers = \"YNYNYNYNYNYN\") == 1\n    assert candidate(customers = \"NNNNN\") == 0\n    assert candidate(customers = \"YYYYYYYYYY\") == 10\n    assert candidate(customers = \"YYYYYYYYYYYY\") == 12\n    assert candidate(customers = \"NNNNNNNNNNNN\") == 0\n    assert candidate(customers = \"NNYNNYNYN\") == 0\n    assert candidate(customers = \"NYNNNNNNYN\") == 0\n    assert candidate(customers = \"NNNNNNNNNN\") == 0\n    assert candidate(customers = \"YYNY\") == 2\n    assert candidate(customers = \"YYYYNNNNYYYY\") == 4\n    assert candidate(customers = \"NYYNNYNYNNY\") == 3\n    assert candidate(customers = \"NYNYNYNYNYNY\") == 0\n    assert candidate(customers = \"NYNYNYNYNY\") == 0\n    assert candidate(customers = \"YYYY\") == 4\n    assert candidate(customers = \"YNYYYYYYNYYN\") == 11\n    assert candidate(customers = \"YNNYYNYY\") == 8\n    assert candidate(customers = \"YYYYYNNNNNYYYYYY\") == 16\n    assert candidate(customers = \"YNNYNYY\") == 1\n    assert candidate(customers = \"NNNNNNNNNNNNNNNN\") == 0\n    assert candidate(customers = \"YYYYNNYNNYNNYNNY\") == 4\n    assert candidate(customers = \"NNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYY\") == 46\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNN\") == 48\n    assert candidate(customers = \"NYNYNYNYNYNYNYNYNYNY\") == 0\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYYYYYYYYYYYYY\") == 20\n    assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYYYYYYY\") == 0\n    assert candidate(customers = \"NYNYNYNYNNYNNYNN\") == 0\n    assert candidate(customers = \"YYYYYYNNNNNNYYYYYYNNNNNNYYYYYYNNNNNNYYYYYYNNNNNNYYYYYYNNNNNNYYYYYY\") == 6\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNNNNNNNN\") == 94\n    assert candidate(customers = \"YNYYYYYYYYNYNYYYYYYYYNYNYYYYYYYYNYNYYYYYYYYNYNYYYYYYYY\") == 54\n    assert candidate(customers = \"YYNNYNYNYNYNYNYNYNYN\") == 2\n    assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n    assert candidate(customers = \"NYNNYYNYNNYYNYNNYYNY\") == 0\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 94\n    assert candidate(customers = \"YYYYNNYYYNYYNNYYNNYYNYNNYYNYNYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNYNYNYNNYYNNYYNNYYNNYYNYNYNYNNYYNNYYNNYYNNYYNYNYNY\") == 12\n    assert candidate(customers = \"YYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNN\") == 2\n    assert candidate(customers = \"YYYYYNNNNNYYYYYNNNNNYYYYYNNNNNYYYYYNNNNN\") == 5\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNN\") == 94\n    assert candidate(customers = \"NYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNY\") == 0\n    assert candidate(customers = \"YNNYNYYNYYNNYNNYNYYN\") == 10\n    assert candidate(customers = \"YYYYYNNYYYYNNYYY\") == 16\n    assert candidate(customers = \"YYNNYYNNYYNNYY\") == 2\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 92\n    assert candidate(customers = \"NYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 94\n    assert candidate(customers = \"YYYYYYYYYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYYYYYYYYY\") == 10\n    assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n    assert candidate(customers = \"YYNYYNYNYYNNYY\") == 10\n    assert candidate(customers = \"NYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYY\") == 0\n    assert candidate(customers = \"YYYYYYYYYYYYYYYY\") == 16\n    assert candidate(customers = \"NYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNY\") == 78\n    assert candidate(customers = \"NYNYNYNYNYNYNYNY\") == 0\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 88\n    assert candidate(customers = \"YNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNY\") == 1\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNN\") == 94\n    assert candidate(customers = \"YYYYNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNY\") == 4\n    assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n    assert candidate(customers = \"YYYYNNNNYYYYNNNN\") == 4\n    assert candidate(customers = \"YYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYY\") == 41\n    assert candidate(customers = \"YNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYN\") == 1\n    assert candidate(customers = \"NYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYY\") == 3\n    assert candidate(customers = \"NNNNNYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 94\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYY\") == 20\n    assert candidate(customers = \"YYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYY\") == 2\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNNNNNN\") == 94\n    assert candidate(customers = \"NYNYNNYNYNYNYNNYNYNNYNYNYNNYNYNNYNYNNYNY\") == 0\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 64\n    assert candidate(customers = \"NYNYNYNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNY\") == 0\n    assert candidate(customers = \"NYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNNYYYN\") == 41\n    assert candidate(customers = \"NYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYN\") == 93\n    assert candidate(customers = \"NYNNYNYNNYNYNNYNYNNYNYNNYNYNNYNYNNYNYNNYNYNNYNYNNYNYNNYN\") == 0\n    assert candidate(customers = \"NNNNNNNNYYYYYYYY\") == 0\n    assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNN\") == 0\n    assert candidate(customers = \"NNYNNYNNYNNYNNYY\") == 0\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNN\") == 52\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 44\n    assert candidate(customers = \"NYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNNNNNNNNNNNNNNNNNN\") == 0\n    assert candidate(customers = \"NNYYNNNNYYNNYYYYNYYY\") == 20\n    assert candidate(customers = \"NYNNYNYYNNYNYYNNYNYYNNYNYYNNYNYYNNYNYYNN\") == 0\n    assert candidate(customers = \"NNNNNNYYYYYYNNNNNNYYYYYYNNNNNNYYYYYYNNNNNNYYYYYYNNNNNNYYYYYYNNNNNN\") == 0\n    assert candidate(customers = \"YNNYYNYYNNYYNYYNNYYNYYNNYYNYYNNYYNYYNNYYNYYNN\") == 43\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNN\") == 94\n    assert candidate(customers = \"NNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNN\") == 0\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 104\n    assert candidate(customers = \"YYYYYNNNNNNNNNNN\") == 5\n    assert candidate(customers = \"YYYYYNNYNYNYNYNN\") == 5\n    assert candidate(customers = \"YNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNY\") == 1\n    assert candidate(customers = \"NNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNN\") == 0\n    assert candidate(customers = \"YYYYYYYYYYNNNNNNNN\") == 10\n    assert candidate(customers = \"YYYYYYNNNNNNYYYYYYNNNNNNYYYYYYNNNNNNYYYYYY\") == 6\n    assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n    assert candidate(customers = \"YYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNNY\") == 2\n    assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYYYYYYYYYYYYYYYYYYY\") == 0\n    assert candidate(customers = \"YYYYNNYYYNYYYYNNYYYNYYYYNNYYYNYYYYNNYYYNYYYYNNYYYNYYYY\") == 54\n    assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n    assert candidate(customers = \"YYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNNYYNYNN\") == 2\n    assert candidate(customers = \"YYYYNNNNNNNNNNNNNNNNNNNNYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 108\n    assert candidate(customers = \"YYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYYYYY\") == 96\n    assert candidate(customers = \"NYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNY\") == 0\n    assert candidate(customers = \"YNYNYNYNYNYNYNYN\") == 1\n    assert candidate(customers = \"NYNYYNNYNYNYYNNYNYNY\") == 5\n    assert candidate(customers = \"NNYNYNYNYNYNYNYN\") == 0\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 54\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNN\") == 94\n    assert candidate(customers = \"YYNNYYYYYYNNYYYYYYNNYYYYYYNNYYYYYYNNYYYYYY\") == 42\n    assert candidate(customers = \"NYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNY\") == 39\n    assert candidate(customers = \"NNNNNYYYYYYYNNNN\") == 12\n    assert candidate(customers = \"YYYYYNNNNYYYYYYYYYNNNNNNNYYYYYYYYYNNNNNYYY\") == 34\n    assert candidate(customers = \"YYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNN\") == 10\n    assert candidate(customers = \"YNNNNYNNYNYNYNYNNYNNYNNYNYNNYNNYNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNYNNY\") == 1\n    assert candidate(customers = \"YYNYNYNYNYNNYNNY\") == 2\n    assert candidate(customers = \"NYYYYYYYYYNNNNNNNNNN\") == 10\n    assert candidate(customers = \"NNNNNNYYYYYYYYYYYYYY\") == 20\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNNNNNNNNNN\") == 94\n    assert candidate(customers = \"NNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYYNNNNYYYY\") == 0\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 40\n    assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNN\") == 94\n    assert candidate(customers = \"YYNNYYNNYYNN\") == 2\n    assert candidate(customers = \"NNYNYNYNYNYNYNNY\") == 0\n    assert candidate(customers = \"YNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYN\") == 1\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNN\") == 94\n    assert candidate(customers = \"YNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNY\") == 1\n    assert candidate(customers = \"YYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNN\") == 10\n    assert candidate(customers = \"NYYYYYYYYYYYNN\") == 12\n    assert candidate(customers = \"NNYYYYNNYYYYNNYYYYNNYYYYNNYYYYNNYYYYNNYYYY\") == 42\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNNNN\") == 94\n    assert candidate(customers = \"YNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYN\") == 1\n    assert candidate(customers = \"NNNNYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 24\n    assert candidate(customers = \"YNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNY\") == 1\n    assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n    assert candidate(customers = \"YYYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYY\") == 4\n    assert candidate(customers = \"NYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNYNY\") == 0\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNN\") == 88\n    assert candidate(customers = \"YYYNYYNYYYNYYNNYYYYNYYYYNYNYNYYYYYYYYYYYYNNNYNYNYYNNYNN\") == 41\n    assert candidate(customers = \"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\") == 70\n    assert candidate(customers = \"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\") == 0\n    assert candidate(customers = \"NNNNNNNNNYYYYYYYYYYNNNNNNNNNYYYYYYYYYYNNNNNNNNNYYYYYYYYYYNNNNNNNNNYYYYYYYYYY\") == 76\n    assert candidate(customers = \"YYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYYNNYY\") == 2\n    assert candidate(customers = \"NYNNNYNNNYNNNY\") == 0\n    assert candidate(customers = \"NYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNYYNNYY\") == 39\n    assert candidate(customers = \"NNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNNYYYYYYYYYYNNNNNNNNNN\") == 0\n    assert candidate(customers = \"YYYYYYYYYYNNNNNNNNNN\") == 10\n    assert candidate(customers = \"NYNYNYNYNYNYNYNYNYNYNYNNNNNNNNNNNNNNNNNNNNNNNNYYYYYYYYYYYYYYYYYYYY\") == 0\n", "comparison": "exact"}, "public_tests": ["\"YYNY\"", "\"NNNNN\"", "\"YYYY\""], "hints": ["At any index, the penalty is the sum of prefix count of ‘N’ and suffix count of ‘Y’.", "Enumerate all indices and find the minimum such value."], "metadata": {"canonical_parameter_names": ["customers"], "leetcode_dataset_entry_point": "Solution().bestClosingTime", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:27+00:00", "tests_total": 152, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def bestClosingTime(self, customers: str) -> int:", "container": "Solution", "callable": "bestClosingTime", "parameters": [{"name": "customers", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2484, "task_id": "count-palindromic-subsequences", "difficulty": "Hard", "problem_description": "Given a string of digits s, return the number of palindromic subsequences of s having length 5. Since the answer may be very large, return it modulo 10^9 + 7.\n\nNote:\n\n- A string is palindromic if it reads the same forward and backward.\n- A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n\nExample 1:\n\nInput: s = \"103301\"\nOutput: 2\nExplanation:\nThere are 6 possible subsequences of length 5: \"10330\",\"10331\",\"10301\",\"10301\",\"13301\",\"03301\".\nTwo of them (both equal to \"10301\") are palindromic.\n\nExample 2:\n\nInput: s = \"0000000\"\nOutput: 21\nExplanation: All 21 subsequences are \"00000\", which is palindromic.\n\nExample 3:\n\nInput: s = \"9999900000\"\nOutput: 2\nExplanation: The only two palindromic subsequences are \"99999\" and \"00000\".\n\nConstraints:\n\n- 1 <= s.length <= 10^4\n- s consists of digits.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"100100100\") == 34\n    assert candidate(s = \"9876543210\") == 0\n    assert candidate(s = \"54321012345\") == 30\n    assert candidate(s = \"12345678900987654321\") == 240\n    assert candidate(s = \"00000000000000000000\") == 15504\n    assert candidate(s = \"122112211\") == 33\n    assert candidate(s = \"1234567890\") == 0\n    assert candidate(s = \"123454321\") == 14\n    assert candidate(s = \"0000000\") == 21\n    assert candidate(s = \"103301\") == 2\n    assert candidate(s = \"98765432100123456789\") == 240\n    assert candidate(s = \"1234321234321\") == 109\n    assert candidate(s = \"1111111111\") == 252\n    assert candidate(s = \"0123456789\") == 0\n    assert candidate(s = \"012343210\") == 14\n    assert candidate(s = \"1232123212\") == 39\n    assert candidate(s = \"1001001001\") == 80\n    assert candidate(s = \"5555555555\") == 252\n    assert candidate(s = \"1010101010\") == 68\n    assert candidate(s = \"1221221221\") == 80\n    assert candidate(s = \"1234567890987654321\") == 204\n    assert candidate(s = \"0101010101\") == 68\n    assert candidate(s = \"1212121212\") == 68\n    assert candidate(s = \"9999900000\") == 2\n    assert candidate(s = \"000000111111000000\") == 2868\n    assert candidate(s = \"123454321123454321\") == 364\n    assert candidate(s = \"1234567898765432123456789876543212345678987654321\") == 24502\n    assert candidate(s = \"22233322233322233322\") == 3990\n    assert candidate(s = \"54321098765432109876543210987654321054321\") == 7758\n    assert candidate(s = \"1122334455667788998877665544332211\") == 5056\n    assert candidate(s = \"98765432112345678998765432100\") == 672\n    assert candidate(s = \"89098098098098098098\") == 1848\n    assert candidate(s = \"12345678901234567890123456789012345678901234567890\") == 18100\n    assert candidate(s = \"1232123212321232123212321\") == 7180\n    assert candidate(s = \"12345543211234554321\") == 580\n    assert candidate(s = \"12345123451234512345123451234512345\") == 12425\n    assert candidate(s = \"10101010101010101010101010\") == 16588\n    assert candidate(s = \"987654321012345678909876543210123456789\") == 5433\n    assert candidate(s = \"90123456789012345678901234567890123456789\") == 6346\n    assert candidate(s = \"010101010101010101\") == 2184\n    assert candidate(s = \"098765432109876543210987654321098765432109876543210\") == 21210\n    assert candidate(s = \"1234567898765432121234567898765432121\") == 5455\n    assert candidate(s = \"112233445544332211\") == 576\n    assert candidate(s = \"987654321000123456789\") == 285\n    assert candidate(s = \"987654321000000000000000000000000000000009876543210\") == 281976\n    assert candidate(s = \"987654321098765432109876543210987654321098765432109876543210\") == 49200\n    assert candidate(s = \"1122334455443322112233445544332211\") == 12024\n    assert candidate(s = \"0000011111222223333344444555554444433333222221111100000\") == 138761\n    assert candidate(s = \"987654321123456789876543210011223344556677889987654321\") == 31546\n    assert candidate(s = \"98765432101234567898\") == 253\n    assert candidate(s = \"10101010101010101010101\") == 8701\n    assert candidate(s = \"5555555555555555555555555555555555555555\") == 658008\n    assert candidate(s = \"01020304050607080901\") == 918\n    assert candidate(s = \"123456789098765432101234567890\") == 978\n    assert candidate(s = \"123456789000000000987654321\") == 1374\n    assert candidate(s = \"1234567890123456789012345678901234567890\") == 5040\n    assert candidate(s = \"000111222333444555444333222111000\") == 9840\n    assert candidate(s = \"999888777666555444333222111000\") == 0\n    assert candidate(s = \"99999000001111122222333334444455555444443333322222111110000099999\") == 237888\n    assert candidate(s = \"11223344556677889900998877665544332211\") == 7266\n    assert candidate(s = \"111111111111111111111111111111111111111111111111111\") == 2349060\n    assert candidate(s = \"00000100001000010000100000\") == 37118\n    assert candidate(s = \"111000111000111000111000111000111\") == 61584\n    assert candidate(s = \"99999888887777766666555554444433333222221111100000\") == 10\n    assert candidate(s = \"9876543210012345678998765432100123456789\") == 5910\n    assert candidate(s = \"1234567898765432112345678987654321\") == 3320\n    assert candidate(s = \"12211221122112211\") == 1574\n    assert candidate(s = \"543210000012345\") == 121\n    assert candidate(s = \"12211221122112211221\") == 3916\n    assert candidate(s = \"67890098766789009876\") == 580\n    assert candidate(s = \"9876543210987654321098765432109876543210\") == 5040\n    assert candidate(s = \"1111100000111110000011111000001111100000\") == 146008\n    assert candidate(s = \"98765432101234567899876543210123456789\") == 4794\n    assert candidate(s = \"00000111110000011111\") == 2004\n    assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010\") == 3501456\n    assert candidate(s = \"111222333222111222333\") == 1470\n    assert candidate(s = \"00000000001111111111000000000\") == 38880\n    assert candidate(s = \"111110000000000000000000000000000000000000000000000\") == 1370755\n    assert candidate(s = \"123456789876543210123456789\") == 624\n    assert candidate(s = \"1234543216789876123454321\") == 942\n    assert candidate(s = \"9876543210012345678998765432100123456789987654321\") == 17193\n    assert candidate(s = \"11001100110011001100\") == 3656\n    assert candidate(s = \"11100011100011100011\") == 3990\n    assert candidate(s = \"99999000009999900000\") == 2004\n    assert candidate(s = \"10010010010010010010\") == 4535\n    assert candidate(s = \"11112222333322221111\") == 2736\n    assert candidate(s = \"1232112321123211232112321123211232112321\") == 85128\n    assert candidate(s = \"987654321987654321987654321\") == 576\n    assert candidate(s = \"121212121212121212121212121212121212121212121212\") == 429088\n    assert candidate(s = \"12345678909876543211234567890987654321\") == 4794\n    assert candidate(s = \"1221122112211\") == 331\n    assert candidate(s = \"99999888887777766666\") == 4\n    assert candidate(s = \"123456789012345678901234567890123456789012345678901234567890\") == 49200\n    assert candidate(s = \"111222333444555444333222111\") == 4974\n    assert candidate(s = \"123454321123454321123454321\") == 3470\n    assert candidate(s = \"0123456789876543210123456789876543210\") == 4385\n    assert candidate(s = \"99999999999999999\") == 6188\n    assert candidate(s = \"567899876567899876\") == 324\n    assert candidate(s = \"000111222333444555666777888999888777666555444333222111000\") == 58374\n    assert candidate(s = \"001122334455667788990000000000000000000000000000\") == 149310\n    assert candidate(s = \"555555555555555555555555555\") == 80730\n    assert candidate(s = \"1232123212321232123212321232123212321232\") == 91158\n    assert candidate(s = \"543210123456789876543210\") == 399\n    assert candidate(s = \"123211232112321123211232112321\") == 18456\n    assert candidate(s = \"123456789098765432101234567890987654321\") == 5433\n    assert candidate(s = \"90909090909090909090\") == 3936\n    assert candidate(s = \"000011110000111100001111\") == 8368\n    assert candidate(s = \"12345678909876543210\") == 204\n    assert candidate(s = \"10101010101010101010101010101010101010101\") == 189202\n    assert candidate(s = \"123456789098765432121234567890\") == 995\n    assert candidate(s = \"987654321012345678987654321\") == 624\n    assert candidate(s = \"10101010101010101\") == 1652\n    assert candidate(s = \"0000000000111111111122222222223333333333\") == 1008\n    assert candidate(s = \"11223344556677889998877665544332211\") == 5544\n    assert candidate(s = \"55555555555555555555\") == 15504\n    assert candidate(s = \"123456789987654321123456789\") == 672\n    assert candidate(s = \"123321123321123321\") == 946\n    assert candidate(s = \"10101010101010101010101010101010\") == 50624\n    assert candidate(s = \"1001001001001001001001001\") == 15330\n    assert candidate(s = \"01234567899876543210\") == 240\n    assert candidate(s = \"123456789876543210000000000000000000\") == 11768\n    assert candidate(s = \"1111222233334444555566667777888899990000\") == 0\n    assert candidate(s = \"12345678987654321012345678987654321\") == 3568\n    assert candidate(s = \"54321234554321234554\") == 698\n    assert candidate(s = \"999999000000999999000000999999000000999999\") == 227796\n    assert candidate(s = \"12345678900987654321001234567890\") == 1528\n    assert candidate(s = \"90807060505060708090\") == 1254\n    assert candidate(s = \"123454321123454321123454321123454321\") == 16368\n    assert candidate(s = \"0123456789876543210123456789\") == 688\n    assert candidate(s = \"98765432101020304050607080908070605040302010\") == 33248\n    assert candidate(s = \"12345432112345432112\") == 698\n    assert candidate(s = \"1001001001001001001001001001001001001001001001001\") == 564020\n    assert candidate(s = \"00112233445566778899\") == 0\n    assert candidate(s = \"987654321000000000000000000000000000123456789\") == 108195\n    assert candidate(s = \"34554334554334554334\") == 1720\n    assert candidate(s = \"100000000000000000000000000000000000000001\") == 667888\n    assert candidate(s = \"1234567890098765432112345678900987654321\") == 5910\n    assert candidate(s = \"01010101010101010101\") == 3936\n    assert candidate(s = \"12345678900987654321000123456789\") == 1645\n    assert candidate(s = \"00000111112222233333444445555566666777778888899999\") == 10\n    assert candidate(s = \"010101010101010\") == 819\n    assert candidate(s = \"10101010101010101010\") == 3936\n    assert candidate(s = \"12345678901234567890123456789012345678901234567890123456789\") == 46090\n    assert candidate(s = \"9876543210012345678909876543210\") == 1230\n    assert candidate(s = \"54321098765432109876543210987654321\") == 2925\n    assert candidate(s = \"000000000000000000000000000000000000000000000000001\") == 2118760\n    assert candidate(s = \"111222333444555666777888999000999888777666555444333222111\") == 58374\n    assert candidate(s = \"0123456789876543210\") == 204\n    assert candidate(s = \"20202020202020202020\") == 3936\n", "comparison": "exact"}, "public_tests": ["\"103301\"", "\"0000000\"", "\"9999900000\""], "hints": ["There are 100 possibilities for the first two characters of the palindrome.", "Iterate over all characters, letting the current character be the center of the palindrome."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().countPalindromes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:30+00:00", "tests_total": 149, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def countPalindromes(self, s: str) -> int:", "container": "Solution", "callable": "countPalindromes", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2485, "task_id": "find-the-pivot-integer", "difficulty": "Easy", "problem_description": "Given a positive integer n, find the pivot integer x such that:\n\n- The sum of all elements between 1 and x inclusively equals the sum of all elements between x and n inclusively.\n\nReturn the pivot integer x. If no such integer exists, return -1. It is guaranteed that there will be at most one pivot index for the given input.\n\nExample 1:\n\nInput: n = 8\nOutput: 6\nExplanation: 6 is the pivot integer since: 1 + 2 + 3 + 4 + 5 + 6 = 6 + 7 + 8 = 21.\n\nExample 2:\n\nInput: n = 1\nOutput: 1\nExplanation: 1 is the pivot integer since: 1 = 1.\n\nExample 3:\n\nInput: n = 4\nOutput: -1\nExplanation: It can be proved that no such integer exist.\n\nConstraints:\n\n- 1 <= n <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 8) == 6\n    assert candidate(n = 3) == -1\n    assert candidate(n = 4) == -1\n    assert candidate(n = 1) == 1\n    assert candidate(n = 1000) == -1\n    assert candidate(n = 10) == -1\n    assert candidate(n = 625) == -1\n    assert candidate(n = 576) == -1\n    assert candidate(n = 729) == -1\n    assert candidate(n = 144) == -1\n    assert candidate(n = 49) == 35\n    assert candidate(n = 12) == -1\n    assert candidate(n = 900) == -1\n    assert candidate(n = 324) == -1\n    assert candidate(n = 100) == -1\n    assert candidate(n = 50) == -1\n    assert candidate(n = 5) == -1\n    assert candidate(n = 841) == -1\n    assert candidate(n = 289) == -1\n    assert candidate(n = 550) == -1\n    assert candidate(n = 99) == -1\n    assert candidate(n = 64) == -1\n    assert candidate(n = 17) == -1\n    assert candidate(n = 484) == -1\n    assert candidate(n = 2) == -1\n    assert candidate(n = 225) == -1\n    assert candidate(n = 784) == -1\n    assert candidate(n = 250) == -1\n    assert candidate(n = 999) == -1\n    assert candidate(n = 35) == -1\n    assert candidate(n = 169) == -1\n    assert candidate(n = 75) == -1\n    assert candidate(n = 256) == -1\n    assert candidate(n = 36) == -1\n    assert candidate(n = 529) == -1\n    assert candidate(n = 20) == -1\n    assert candidate(n = 676) == -1\n    assert candidate(n = 81) == -1\n    assert candidate(n = 48) == -1\n    assert candidate(n = 325) == -1\n    assert candidate(n = 15) == -1\n    assert candidate(n = 441) == -1\n    assert candidate(n = 961) == -1\n    assert candidate(n = 400) == -1\n    assert candidate(n = 196) == -1\n    assert candidate(n = 9) == -1\n    assert candidate(n = 121) == -1\n    assert candidate(n = 361) == -1\n    assert candidate(n = 700) == -1\n    assert candidate(n = 500) == -1\n    assert candidate(n = 7) == -1\n    assert candidate(n = 25) == -1\n", "comparison": "exact"}, "public_tests": ["8", "1", "4"], "hints": ["Can you use brute force to check every number from 1 to n if any of them is the pivot integer?", "If you know the sum of [1: pivot], how can you efficiently calculate the sum of the other parts?"], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().pivotInteger", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:32+00:00", "tests_total": 52, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def pivotInteger(self, n: int) -> int:", "container": "Solution", "callable": "pivotInteger", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2486, "task_id": "append-characters-to-string-to-make-subsequence", "difficulty": "Medium", "problem_description": "You are given two strings s and t consisting of only lowercase English letters.\n\nReturn the minimum number of characters that need to be appended to the end of s so that t becomes a subsequence of s.\n\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n\nExample 1:\n\nInput: s = \"coaching\", t = \"coding\"\nOutput: 4\nExplanation: Append the characters \"ding\" to the end of s so that s = \"coachingding\".\nNow, t is a subsequence of s (\"coachingding\").\nIt can be shown that appending any 3 characters to the end of s will never make t a subsequence.\n\nExample 2:\n\nInput: s = \"abcde\", t = \"a\"\nOutput: 0\nExplanation: t is already a subsequence of s (\"abcde\").\n\nExample 3:\n\nInput: s = \"z\", t = \"abcde\"\nOutput: 5\nExplanation: Append the characters \"abcde\" to the end of s so that s = \"zabcde\".\nNow, t is a subsequence of s (\"zabcde\").\nIt can be shown that appending any 4 characters to the end of s will never make t a subsequence.\n\nConstraints:\n\n- 1 <= s.length, t.length <= 10^5\n- s and t consist only of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(s = \"abcdefgh\",t = \"ghijkl\") == 4\n    assert candidate(s = \"ababab\",t = \"bbba\") == 1\n    assert candidate(s = \"abcd\",t = \"xyz\") == 3\n    assert candidate(s = \"aaaa\",t = \"a\") == 0\n    assert candidate(s = \"abcd\",t = \"dbca\") == 3\n    assert candidate(s = \"aabbcc\",t = \"abc\") == 0\n    assert candidate(s = \"aaaaa\",t = \"a\") == 0\n    assert candidate(s = \"abcd\",t = \"abcde\") == 1\n    assert candidate(s = \"ababab\",t = \"bbbb\") == 1\n    assert candidate(s = \"ab\",t = \"abc\") == 1\n    assert candidate(s = \"abcdefgh\",t = \"efghij\") == 2\n    assert candidate(s = \"hello\",t = \"oleh\") == 3\n    assert candidate(s = \"abcde\",t = \"a\") == 0\n    assert candidate(s = \"abcd\",t = \"abdc\") == 1\n    assert candidate(s = \"abcd\",t = \"abcd\") == 0\n    assert candidate(s = \"z\",t = \"abcde\") == 5\n    assert candidate(s = \"abcabc\",t = \"abc\") == 0\n    assert candidate(s = \"hello\",t = \"ole\") == 2\n    assert candidate(s = \"abcdefgh\",t = \"efgh\") == 0\n    assert candidate(s = \"a\",t = \"b\") == 1\n    assert candidate(s = \"coaching\",t = \"coding\") == 4\n    assert candidate(s = \"xyz\",t = \"xyza\") == 1\n    assert candidate(s = \"xyz\",t = \"xyz\") == 0\n    assert candidate(s = \"abcd\",t = \"efgh\") == 4\n    assert candidate(s = \"aaaa\",t = \"aa\") == 0\n    assert candidate(s = \"complex\",t = \"cmpx\") == 0\n    assert candidate(s = \"abcabcabcabcabcabc\",t = \"abcabcabcabcabcd\") == 1\n    assert candidate(s = \"thisisaverylongstring\",t = \"thisstring\") == 0\n    assert candidate(s = \"hellothere\",t = \"lohere\") == 0\n    assert candidate(s = \"ababababab\",t = \"bababa\") == 0\n    assert candidate(s = \"xyzxyzxyzxyzxyz\",t = \"xyzyzyzyzyzyzyz\") == 4\n    assert candidate(s = \"abcdabcdabcd\",t = \"dcba\") == 1\n    assert candidate(s = \"abcabcabcabc\",t = \"abacaba\") == 0\n    assert candidate(s = \"thefastbrownfoxjumpsoverthelazydog\",t = \"quickbrownfox\") == 13\n    assert candidate(s = \"abcdefghijk\",t = \"acegik\") == 0\n    assert candidate(s = \"abcde\",t = \"cbad\") == 3\n    assert candidate(s = \"abracadabra\",t = \"bracadabr\") == 0\n    assert candidate(s = \"longstringwithvariouscharacters\",t = \"string\") == 0\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 24\n    assert candidate(s = \"sequence\",t = \"subsequence\") == 9\n    assert candidate(s = \"abcabcabcabc\",t = \"cccc\") == 0\n    assert candidate(s = \"longerstring\",t = \"string\") == 0\n    assert candidate(s = \"aaaabbbbcccc\",t = \"abcabc\") == 3\n    assert candidate(s = \"abcdef\",t = \"fghijk\") == 5\n    assert candidate(s = \"abcdef\",t = \"defghijk\") == 5\n    assert candidate(s = \"abcdexyz\",t = \"dezy\") == 1\n    assert candidate(s = \"xyzxyzxyz\",t = \"zyxzyxzyx\") == 5\n    assert candidate(s = \"abababababababab\",t = \"abab\") == 0\n    assert candidate(s = \"kglvkyeavnnrdq\",t = \"lky\") == 0\n    assert candidate(s = \"abcabcabcabc\",t = \"abcdabcdabcd\") == 9\n    assert candidate(s = \"abcdefghij\",t = \"hijjiklmn\") == 6\n    assert candidate(s = \"overlaplaplap\",t = \"laplaplaplap\") == 3\n    assert candidate(s = \"xyxyxyxyxy\",t = \"xyyx\") == 0\n    assert candidate(s = \"hello\",t = \"heoo\") == 1\n    assert candidate(s = \"abcde\",t = \"edcba\") == 4\n    assert candidate(s = \"randomstring\",t = \"stringrandom\") == 6\n    assert candidate(s = \"mississippi\",t = \"pis\") == 1\n    assert candidate(s = \"abcdabcdabcd\",t = \"abcabcabc\") == 0\n    assert candidate(s = \"sequencealignment\",t = \"seqaln\") == 0\n    assert candidate(s = \"testtesttest\",t = \"testset\") == 0\n    assert candidate(s = \"mississippi\",t = \"pippi\") == 3\n    assert candidate(s = \"mississippi\",t = \"issip\") == 0\n    assert candidate(s = \"sequencealignment\",t = \"quencal\") == 0\n    assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\") == 9\n    assert candidate(s = \"programming\",t = \"gram\") == 0\n    assert candidate(s = \"abcdef\",t = \"fedcba\") == 5\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"xyzuvw\") == 3\n    assert candidate(s = \"abacabadabacaba\",t = \"abcd\") == 0\n    assert candidate(s = \"mississippi\",t = \"issi\") == 0\n    assert candidate(s = \"aaaaabbbbbcccccdddddeeeee\",t = \"abcde\") == 0\n    assert candidate(s = \"longstringwithrandomcharacters\",t = \"lgrmc\") == 0\n    assert candidate(s = \"zzzzzzzzzz\",t = \"abcdefghij\") == 10\n    assert candidate(s = \"patternmatching\",t = \"ternat\") == 0\n    assert candidate(s = \"aabbaabbccddeeff\",t = \"abcdeff\") == 0\n    assert candidate(s = \"abcde\",t = \"abcdeabcde\") == 5\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"abcdefghijklmnopqrstuvwxyz\") == 0\n    assert candidate(s = \"uniquecharacters\",t = \"charactersunique\") == 6\n    assert candidate(s = \"programming\",t = \"progmin\") == 0\n    assert candidate(s = \"subsequence\",t = \"subs\") == 0\n    assert candidate(s = \"hellothere\",t = \"othertimes\") == 5\n    assert candidate(s = \"aaaaaa\",t = \"aabbcc\") == 4\n    assert candidate(s = \"abcde\",t = \"efghij\") == 5\n    assert candidate(s = \"mississippi\",t = \"isip\") == 0\n    assert candidate(s = \"abcdefabcdef\",t = \"fedcbafedcba\") == 10\n    assert candidate(s = \"longerstringwithcharacters\",t = \"stringcharacters\") == 0\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n    assert candidate(s = \"short\",t = \"longerstring\") == 12\n    assert candidate(s = \"abcabcabcabcabc\",t = \"abcabcabc\") == 0\n    assert candidate(s = \"abababababababab\",t = \"zzzzyyyyxxxxwwwwvvvvuuuuttttrrrrqqqqpppplllloooonnnnmmmkkkkjjjjiiiihhhhhggggggfffffeeeeeddddccccbbbbbaaaa\") == 105\n    assert candidate(s = \"overlappingcharacters\",t = \"lap\") == 0\n    assert candidate(s = \"sequence\",t = \"quen\") == 0\n    assert candidate(s = \"abcdefghij\",t = \"zzzzzzzzzz\") == 10\n    assert candidate(s = \"aaaaabbbbb\",t = \"abababab\") == 6\n    assert candidate(s = \"abcdefgh\",t = \"ihgfedcba\") == 9\n    assert candidate(s = \"thisisaverylongstring\",t = \"isaverylong\") == 0\n    assert candidate(s = \"programming\",t = \"gramming\") == 0\n    assert candidate(s = \"longeststring\",t = \"tiny\") == 1\n    assert candidate(s = \"xyz\",t = \"zyxzyxzyx\") == 8\n    assert candidate(s = \"abcdeabcdeabcde\",t = \"abcdee\") == 0\n    assert candidate(s = \"abracadabra\",t = \"acadabra\") == 0\n    assert candidate(s = \"mississippi\",t = \"ppip\") == 1\n    assert candidate(s = \"onetwothreefourfive\",t = \"owhfv\") == 0\n    assert candidate(s = \"aaaaaa\",t = \"bbbbb\") == 5\n    assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzzyyxwwvvuutsrrqppoonnmlkkjjiihhggffeeddccbbaa\") == 45\n    assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",t = \"aaaaaaaaaaaaaaaaaaaaaaaaaaab\") == 1\n    assert candidate(s = \"abcdefghij\",t = \"hijjiklm\") == 5\n    assert candidate(s = \"example\",t = \"ample\") == 0\n    assert candidate(s = \"hello\",t = \"lelo\") == 3\n    assert candidate(s = \"abcabcabcabc\",t = \"abcabcabcabcabcabc\") == 6\n    assert candidate(s = \"characters\",t = \"char\") == 0\n    assert candidate(s = \"aaaabbbbcccc\",t = \"abc\") == 0\n    assert candidate(s = \"aaaaaaaaaa\",t = \"aaaabbbbcccc\") == 8\n    assert candidate(s = \"xyzuvw\",t = \"abcdefghijklmnopqrstuvwxyz\") == 26\n    assert candidate(s = \"xyz\",t = \"wxyzyxwxyzyx\") == 12\n    assert candidate(s = \"abcabcabcabcabc\",t = \"abcbcabcbcabcbca\") == 3\n    assert candidate(s = \"randomstring\",t = \"random\") == 0\n    assert candidate(s = \"abcdefghiklmnopqrstuvwxyz\",t = \"mnopqrstuvwxyz\") == 0\n    assert candidate(s = \"aabacadaea\",t = \"abcde\") == 0\n    assert candidate(s = \"aaaaaa\",t = \"aaaaaab\") == 1\n    assert candidate(s = \"sequence\",t = \"seq\") == 0\n    assert candidate(s = \"repeatedcharactersrepeatedcharacters\",t = \"characterscharacterscharacters\") == 10\n    assert candidate(s = \"abcdefghij\",t = \"hijjijk\") == 4\n    assert candidate(s = \"abacabadabacaba\",t = \"abcabcabc\") == 1\n    assert candidate(s = \"xyzabc\",t = \"uvwabc\") == 6\n    assert candidate(s = \"alibabacloud\",t = \"aliloud\") == 0\n    assert candidate(s = \"aaaabbbbcccc\",t = \"bbcccaaa\") == 3\n    assert candidate(s = \"aaaaabbbbbcccc\",t = \"abcabc\") == 3\n    assert candidate(s = \"hello\",t = \"olelh\") == 4\n    assert candidate(s = \"abcdefg\",t = \"agh\") == 1\n    assert candidate(s = \"abcdefghijkllkjihgfedcba\",t = \"abcdefghijkllkjihgfedcba\") == 0\n    assert candidate(s = \"overlappingoverlapping\",t = \"lapover\") == 0\n    assert candidate(s = \"abcabcabcabcabc\",t = \"aabbaabbaabbaabb\") == 9\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n    assert candidate(s = \"xyzzyxzyxzyz\",t = \"xyzxyz\") == 0\n    assert candidate(s = \"hellotherehellothere\",t = \"helloothere\") == 0\n    assert candidate(s = \"abcdefghij\",t = \"hijjikl\") == 4\n    assert candidate(s = \"abacabadabacaba\",t = \"badaba\") == 0\n    assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxxyyyzzz\",t = \"zzzyyxxwwvvuuuttrrssqqppoonnmmlkkjjiihhgggfffeeeddccbbaaa\") == 54\n    assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvut\") == 6\n    assert candidate(s = \"abcdefghij\",t = \"hijjik\") == 3\n    assert candidate(s = \"aabbccddeeffgg\",t = \"abcdefg\") == 0\n    assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",t = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\") == 10\n    assert candidate(s = \"abcdefghij\",t = \"acegik\") == 1\n    assert candidate(s = \"racecar\",t = \"racecar\") == 0\n    assert candidate(s = \"abracadabra\",t = \"abcde\") == 1\n    assert candidate(s = \"abcdefghij\",t = \"abcdefghij\") == 0\n", "comparison": "exact"}, "public_tests": ["\"coaching\"\n\"coding\"", "\"abcde\"\n\"a\"", "\"z\"\n\"abcde\""], "hints": ["Find the longest prefix of t that is a subsequence of s.", "Use two variables to keep track of your location in s and t. If the characters match, increment both variables. Otherwise, only increment the variable for s.", "The remaining characters in t must be appended to the end of s."], "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().appendCharacters", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:34+00:00", "tests_total": 153, "tests_dropped": 7, "flags": [], "topic_tags": ["two-pointers", "string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def appendCharacters(self, s: str, t: str) -> int:", "container": "Solution", "callable": "appendCharacters", "parameters": [{"name": "s", "type": "str"}, {"name": "t", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2488, "task_id": "count-subarrays-with-median-k", "difficulty": "Hard", "problem_description": "You are given an array nums of size n consisting of distinct integers from 1 to n and a positive integer k.\n\nReturn the number of non-empty subarrays in nums that have a median equal to k.\n\nNote:\n\n- The median of an array is the middle element after sorting the array in ascending order. If the array is of even length, the median is the left middle element.\n  - For example, the median of [2,3,1,4] is 2, and the median of [8,4,3,5,1] is 4.\n- A subarray is a contiguous part of an array.\n\nExample 1:\n\nInput: nums = [3,2,1,4,5], k = 4\nOutput: 3\nExplanation: The subarrays that have a median equal to 4 are: [4], [4,5] and [1,4,5].\n\nExample 2:\n\nInput: nums = [2,3,1], k = 3\nOutput: 1\nExplanation: [3] is the only subarray that has a median equal to 3.\n\nConstraints:\n\n- n == nums.length\n- 1 <= n <= 10^5\n- 1 <= nums[i], k <= n\n- The integers in nums are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [2, 3, 1],k = 3) == 1\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 10\n    assert candidate(nums = [5, 1, 4, 3, 2],k = 3) == 6\n    assert candidate(nums = [1, 2, 3, 4, 5, 6],k = 4) == 5\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == 9\n    assert candidate(nums = [3, 2, 1, 4, 5],k = 4) == 3\n    assert candidate(nums = [7, 5, 3, 1, 2, 4, 6],k = 4) == 4\n    assert candidate(nums = [5, 4, 3, 2, 1],k = 3) == 5\n    assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 5) == 13\n    assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4],k = 5) == 4\n    assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 30\n    assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 21\n    assert candidate(nums = [8, 6, 4, 2, 1, 3, 5, 7, 9],k = 5) == 6\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n    assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 9, 10],k = 5) == 7\n    assert candidate(nums = [1, 3, 2, 6, 5, 4, 8, 7, 9],k = 5) == 12\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 27) == 47\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 30\n    assert candidate(nums = [5, 2, 8, 3, 9, 4, 10, 1, 6, 7],k = 5) == 6\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 11\n    assert candidate(nums = [4, 3, 2, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 25) == 50\n    assert candidate(nums = [15, 20, 10, 25, 5, 1, 6, 11, 16, 21, 26, 30, 3, 8, 13, 18, 23, 28, 2, 7, 12, 17, 22, 27, 29, 4, 9, 14, 19, 24],k = 15) == 17\n    assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16, 21, 30, 22, 29, 23, 28, 24, 27, 25, 26, 31, 40, 32, 39, 33, 38, 34, 37, 35, 36, 41, 50, 42, 49, 43, 48, 44, 47, 45, 46],k = 25) == 54\n    assert candidate(nums = [5, 10, 4, 3, 8, 7, 9, 2, 6, 1],k = 5) == 7\n    assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 2, 6, 10, 14, 18, 22, 26, 30, 3, 7, 11, 15, 19, 23, 27, 28, 4, 8, 12, 16, 20, 24],k = 15) == 87\n    assert candidate(nums = [4, 1, 5, 3, 2, 7, 6, 8, 9, 10],k = 5) == 7\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 20\n    assert candidate(nums = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],k = 5) == 14\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 13) == 25\n    assert candidate(nums = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9],k = 5) == 3\n    assert candidate(nums = [25, 20, 15, 10, 5, 1, 6, 11, 16, 21, 26, 30, 3, 8, 13, 18, 23, 28, 2, 7, 12, 17, 22, 27, 29, 4, 9, 14, 19, 24],k = 15) == 24\n    assert candidate(nums = [3, 1, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20],k = 10) == 21\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 11) == 19\n    assert candidate(nums = [4, 1, 5, 3, 2, 6, 8, 7, 9, 10],k = 5) == 7\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 25) == 11\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n    assert candidate(nums = [5, 1, 3, 2, 4, 8, 6, 7, 9, 10],k = 6) == 10\n    assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 5) == 13\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 11\n    assert candidate(nums = [1, 13, 5, 7, 9, 11, 2, 4, 6, 8, 10, 12, 14, 15, 16, 17, 18, 19, 20, 3],k = 10) == 24\n    assert candidate(nums = [5, 1, 4, 2, 3, 8, 6, 7, 10, 9],k = 5) == 3\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 11) == 19\n    assert candidate(nums = [5, 3, 1, 2, 4, 6, 7, 8, 9, 10],k = 6) == 9\n    assert candidate(nums = [5, 1, 9, 3, 7, 8, 2, 6, 4, 10],k = 5) == 8\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 15) == 44\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 20\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == 7\n    assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == 7\n    assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 15\n    assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6, 10],k = 7) == 4\n    assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 12) == 17\n    assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4],k = 5) == 3\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 15\n    assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 6, 4, 10],k = 5) == 7\n    assert candidate(nums = [1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8],k = 8) == 15\n    assert candidate(nums = [12, 14, 10, 15, 13, 11, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 9\n    assert candidate(nums = [1, 11, 5, 9, 7, 2, 6, 3, 8, 10, 4],k = 6) == 25\n    assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == 9\n    assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n    assert candidate(nums = [3, 6, 1, 8, 5, 2, 9, 4, 7],k = 5) == 19\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 28\n    assert candidate(nums = [3, 1, 4, 2, 5],k = 3) == 3\n    assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 15\n    assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 11) == 25\n    assert candidate(nums = [42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 25) == 35\n    assert candidate(nums = [2, 1, 5, 3, 4, 6, 7, 8, 9, 10],k = 5) == 7\n    assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6, 10],k = 5) == 6\n", "comparison": "exact"}, "public_tests": ["[3,2,1,4,5]\n4", "[2,3,1]\n3"], "hints": ["Consider changing the numbers that are strictly greater than k in the array to 1, the numbers that are strictly smaller than k to -1, and k to 0.", "After the change, what property does a subarray with median k have in the new array?", "An array with median k should have a sum equal to either 0 or 1 in the new array and should contain the element k. How do you count such subarrays?"], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countSubarrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:39+00:00", "tests_total": 79, "tests_dropped": 12, "flags": [], "topic_tags": ["array", "hash-table", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def countSubarrays(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "countSubarrays", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2490, "task_id": "circular-sentence", "difficulty": "Easy", "problem_description": "A sentence is a list of words that are separated by a single space with no leading or trailing spaces.\n\n- For example, \"Hello World\", \"HELLO\", \"hello world hello world\" are all sentences.\n\nWords consist of only uppercase and lowercase English letters. Uppercase and lowercase English letters are considered different.\n\nA sentence is circular if:\n\n- The last character of each word in the sentence is equal to the first character of its next word.\n- The last character of the last word is equal to the first character of the first word.\n\nFor example, \"leetcode exercises sound delightful\", \"eetcode\", \"leetcode eats soul\" are all circular sentences. However, \"Leetcode is cool\", \"happy Leetcode\", \"Leetcode\" and \"I like Leetcode\" are not circular sentences.\n\nGiven a string sentence, return true if it is circular. Otherwise, return false.\n\nExample 1:\n\nInput: sentence = \"leetcode exercises sound delightful\"\nOutput: true\nExplanation: The words in sentence are [\"leetcode\", \"exercises\", \"sound\", \"delightful\"].\n- leetcode's last character is equal to exercises's first character.\n- exercises's last character is equal to sound's first character.\n- sound's last character is equal to delightful's first character.\n- delightful's last character is equal to leetcode's first character.\nThe sentence is circular.\n\nExample 2:\n\nInput: sentence = \"eetcode\"\nOutput: true\nExplanation: The words in sentence are [\"eetcode\"].\n- eetcode's last character is equal to eetcode's first character.\nThe sentence is circular.\n\nExample 3:\n\nInput: sentence = \"Leetcode is cool\"\nOutput: false\nExplanation: The words in sentence are [\"Leetcode\", \"is\", \"cool\"].\n- Leetcode's last character is not equal to is's first character.\nThe sentence is not circular.\n\nConstraints:\n\n- 1 <= sentence.length <= 500\n- sentence consist of only lowercase and uppercase English letters and spaces.\n- The words in sentence are separated by a single space.\n- There are no leading or trailing spaces.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(sentence = \"sentence ence sent\") == False\n    assert candidate(sentence = \"hello olleh\") == True\n    assert candidate(sentence = \"Aa Aa\") == False\n    assert candidate(sentence = \"ab ba\") == True\n    assert candidate(sentence = \"a\") == True\n    assert candidate(sentence = \"Leetcode is cool\") == False\n    assert candidate(sentence = \"b\") == True\n    assert candidate(sentence = \"A aA A\") == False\n    assert candidate(sentence = \"abcd dcba\") == True\n    assert candidate(sentence = \"circular rular circul\") == False\n    assert candidate(sentence = \"Zz zZ\") == True\n    assert candidate(sentence = \"abc cba\") == True\n    assert candidate(sentence = \"a a a a\") == True\n    assert candidate(sentence = \"example ample exa\") == False\n    assert candidate(sentence = \"A a A\") == False\n    assert candidate(sentence = \"Zz\") == False\n    assert candidate(sentence = \"eetcode\") == True\n    assert candidate(sentence = \"abc cab bca\") == True\n    assert candidate(sentence = \"abc bca cab\") == False\n    assert candidate(sentence = \"B ba B\") == False\n    assert candidate(sentence = \"leetcode exercises sound delightful\") == True\n    assert candidate(sentence = \"b b b\") == True\n    assert candidate(sentence = \"a b c a\") == False\n    assert candidate(sentence = \"A a\") == False\n    assert candidate(sentence = \"test tset\") == True\n    assert candidate(sentence = \"aba\") == True\n    assert candidate(sentence = \"mnopqr stuvwx yzab cd efgh ijklm nopqr\") == False\n    assert candidate(sentence = \"world dlrow\") == True\n    assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyz zabcdefghijklmnopqrstuvwxy\") == False\n    assert candidate(sentence = \"No lemon no melon\") == False\n    assert candidate(sentence = \"Anna\") == False\n    assert candidate(sentence = \"Able was I ere I saw Elba Able\") == False\n    assert candidate(sentence = \"Was it a car or a cat I saw saw I tac a ro rac a si taW taW\") == False\n    assert candidate(sentence = \"Madam In Eden Im Adam\") == False\n    assert candidate(sentence = \"Circular logic confuses brains sourcing smiles\") == False\n    assert candidate(sentence = \"Rotation noitator tor\") == False\n    assert candidate(sentence = \"noon moon moon\") == False\n    assert candidate(sentence = \"peep peep\") == True\n    assert candidate(sentence = \"b aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa aaaaaaaaa aaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa b\") == False\n    assert candidate(sentence = \"Noon neons number nicely\") == False\n    assert candidate(sentence = \"Madam madam madam\") == False\n    assert candidate(sentence = \"refer level civic civic civic level refer\") == False\n    assert candidate(sentence = \"xyyx xxyy\") == False\n    assert candidate(sentence = \"kayak kayak kayak kayak\") == True\n    assert candidate(sentence = \"rotor racecar level deed civic\") == False\n    assert candidate(sentence = \"stats tacocat stats\") == False\n    assert candidate(sentence = \"racecar civic madam\") == False\n    assert candidate(sentence = \"Step on no pets no step on no pets\") == False\n    assert candidate(sentence = \"Able was I I saw Elba Elba saw I I was Able\") == False\n    assert candidate(sentence = \"tacocat\") == True\n    assert candidate(sentence = \"a quick brown fox jumps over lazy a\") == False\n    assert candidate(sentence = \"zoo online one nice Easter egg\") == False\n    assert candidate(sentence = \"Word dOrw\") == False\n    assert candidate(sentence = \"deed deed\") == True\n    assert candidate(sentence = \"daemon daemon\") == False\n    assert candidate(sentence = \"Palindrome emordnilaP\") == True\n    assert candidate(sentence = \"madam racecar civic\") == False\n    assert candidate(sentence = \"Circular arular ci\") == False\n    assert candidate(sentence = \"Madam adaM\") == False\n    assert candidate(sentence = \"A Santa at NASA\") == False\n    assert candidate(sentence = \"sun sets slowly on nosy wonks\") == False\n    assert candidate(sentence = \"madam racecar level deed civic kayak rotor\") == False\n    assert candidate(sentence = \"abcde edcba\") == True\n    assert candidate(sentence = \"Nested edset n\") == False\n    assert candidate(sentence = \"kayak kayak\") == True\n    assert candidate(sentence = \"Nurses run Nurses\") == False\n    assert candidate(sentence = \"Programming gnostic stem ngram minnow winnow now\") == False\n    assert candidate(sentence = \"rotor rotor\") == True\n    assert candidate(sentence = \"redivider\") == True\n    assert candidate(sentence = \"racecar civic level deed\") == False\n    assert candidate(sentence = \"Abba aaaa aa a\") == False\n    assert candidate(sentence = \"xylophone elephant monkey keen\") == False\n    assert candidate(sentence = \"xyzzyx\") == True\n    assert candidate(sentence = \"circularloop loop\") == False\n    assert candidate(sentence = \"Alaska Kansas suck slyly yelling nasty nasty yaks yak salty knapsack sacks sacks sky kayak kayak kayak\") == False\n    assert candidate(sentence = \"x y z x\") == False\n    assert candidate(sentence = \"programming is simply programming\") == False\n    assert candidate(sentence = \"zoo omega meal alpha\") == False\n    assert candidate(sentence = \"Loop opLo\") == False\n    assert candidate(sentence = \"Startling lightning bugs ignited giants\") == False\n    assert candidate(sentence = \"xylophone one love evolution nation\") == False\n    assert candidate(sentence = \"deed deed deed\") == True\n    assert candidate(sentence = \"Palindrome emordnilaP laP\") == False\n    assert candidate(sentence = \"noon odd level civic civic civic level odd noon\") == False\n    assert candidate(sentence = \"Was it a car or a cat I saw Was\") == False\n    assert candidate(sentence = \"Reflection noitcifilr\") == False\n    assert candidate(sentence = \"ab ba ac ca\") == True\n    assert candidate(sentence = \"racecar racecar\") == True\n    assert candidate(sentence = \"abracadabra arachnophobia\") == True\n    assert candidate(sentence = \"repaper repaper repaper\") == True\n    assert candidate(sentence = \"Complex xs w x\") == False\n    assert candidate(sentence = \"abcd defg ghij jkla\") == True\n    assert candidate(sentence = \"Interstellar rstellar inter\") == False\n    assert candidate(sentence = \"reviled devil level deed vile derevered\") == False\n    assert candidate(sentence = \"Fascinating ideas inspire amazing minds\") == False\n    assert candidate(sentence = \"Alphabet tebahpla A\") == False\n    assert candidate(sentence = \"Unique new weird weed nude euqinu\") == False\n    assert candidate(sentence = \"Wow wow\") == False\n    assert candidate(sentence = \"tortoise einstein noodles stein snot not ossetia\") == False\n    assert candidate(sentence = \"rotor kayak rotor\") == False\n    assert candidate(sentence = \"kayak kayak kayak kayak kayak\") == True\n    assert candidate(sentence = \"zebra apple orange night eagle\") == False\n    assert candidate(sentence = \"Zebra apple orange elephant\") == False\n    assert candidate(sentence = \"redder redder\") == True\n    assert candidate(sentence = \"No lemon no melon no lemon no melon\") == False\n    assert candidate(sentence = \"xylophone elephant monkey keen noodle leet teex\") == False\n    assert candidate(sentence = \"Anna civic radar level rotor\") == False\n    assert candidate(sentence = \"zoo omega anna apple\") == False\n    assert candidate(sentence = \"Detartrated dater dated\") == False\n    assert candidate(sentence = \"xylophone excellent noodles seen\") == False\n    assert candidate(sentence = \"Madam madam\") == False\n    assert candidate(sentence = \"level level\") == True\n    assert candidate(sentence = \"abracadabra aracnidae earthworms mammals sloths\") == False\n    assert candidate(sentence = \"level level level level\") == True\n    assert candidate(sentence = \"Wow wow wow\") == False\n    assert candidate(sentence = \"palindrome emordnilap\") == True\n    assert candidate(sentence = \"Was it a car or a cat I saw seen saw I tac a ro rac a ti saw\") == False\n    assert candidate(sentence = \"a aa aaa aaaa\") == True\n    assert candidate(sentence = \"xylophone objective elegant elegant not\") == False\n    assert candidate(sentence = \"b b b b b\") == True\n    assert candidate(sentence = \"XYlophone emotion motion nation\") == False\n    assert candidate(sentence = \"Zoos own cozy zones\") == False\n    assert candidate(sentence = \"deified deified deified deified\") == True\n    assert candidate(sentence = \"Was it a car or a cat I saw\") == False\n    assert candidate(sentence = \"Zebra apple apple orange onion nginx\") == False\n    assert candidate(sentence = \"cycle ycle c\") == False\n    assert candidate(sentence = \"Wow\") == False\n    assert candidate(sentence = \"Programming gamifies lessons yielding successes\") == False\n    assert candidate(sentence = \"Rhythms mesmerize symphonies\") == False\n    assert candidate(sentence = \"Madam Ada\") == False\n    assert candidate(sentence = \"Madam Arora teaches malayalam Madam\") == False\n    assert candidate(sentence = \"Rotator taro Rotator\") == False\n    assert candidate(sentence = \"a a a a a a a a a a a a\") == True\n    assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == True\n    assert candidate(sentence = \"Civic civic\") == False\n    assert candidate(sentence = \"repaper deed deed deed deed deed deed deed deed deed deed deed deed deed deed deed deed deed deed deed deed\") == False\n    assert candidate(sentence = \"kayak civic deed level odd noon\") == False\n    assert candidate(sentence = \"Madam Arora teaches malayalam\") == False\n    assert candidate(sentence = \"noon odd level deed civic kayak\") == False\n    assert candidate(sentence = \"giraffe elephant noodle leet teex xxyy\") == False\n    assert candidate(sentence = \"Echo Charlie Hotel Hotel Echo\") == False\n    assert candidate(sentence = \"racecar madam rotator\") == False\n    assert candidate(sentence = \"a b c d e f g h i j k l m n o p q r s t u v w x y z a\") == False\n    assert candidate(sentence = \"solo ollas solar lassos\") == False\n    assert candidate(sentence = \"madamrefer\") == False\n    assert candidate(sentence = \"civic racecar level madam deed rotator redivider\") == False\n    assert candidate(sentence = \"Tactocat civic\") == False\n    assert candidate(sentence = \"Xylophones yield xenial xylophiles\") == False\n    assert candidate(sentence = \"civic deed level civic civic\") == False\n    assert candidate(sentence = \"Underground neutergnu\") == False\n    assert candidate(sentence = \"rotor\") == True\n    assert candidate(sentence = \"racecar\") == True\n    assert candidate(sentence = \"singleword\") == False\n    assert candidate(sentence = \"zoo ooz zoo\") == False\n    assert candidate(sentence = \"redder redivider redivider\") == True\n    assert candidate(sentence = \"xylophone one phone nova ava axolotl talontax\") == False\n    assert candidate(sentence = \"ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az\") == False\n    assert candidate(sentence = \"kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak kayak\") == True\n    assert candidate(sentence = \"a aa aaaa a\") == True\n    assert candidate(sentence = \"Mushroom nrooms moss stamper reaper\") == False\n    assert candidate(sentence = \"daemon nomad\") == True\n    assert candidate(sentence = \"AbCd DeFg GhIj JkLa\") == False\n    assert candidate(sentence = \"level deed deed level\") == False\n    assert candidate(sentence = \"Stressed desserts\") == False\n    assert candidate(sentence = \"stats stats\") == True\n    assert candidate(sentence = \"A Santa at NASA A\") == False\n    assert candidate(sentence = \"civic madam racecar\") == False\n    assert candidate(sentence = \"repaper repaper\") == True\n    assert candidate(sentence = \"Palindrome emordnilaP el\") == False\n    assert candidate(sentence = \"Able was I I saw Elba\") == False\n    assert candidate(sentence = \"Programming ngRams Make sense\") == False\n    assert candidate(sentence = \"Mimi\") == False\n    assert candidate(sentence = \"rotor rotor rotor\") == True\n    assert candidate(sentence = \"rotor rotor rotor rotor\") == True\n    assert candidate(sentence = \"rotator rotator\") == True\n    assert candidate(sentence = \"No lemon no melon No\") == False\n    assert candidate(sentence = \"Step on no pets\") == False\n    assert candidate(sentence = \"A Santa at NASA at a Santa A\") == False\n    assert candidate(sentence = \"Was it a car or a cat I saw saw I tac a ro rac a si taW\") == False\n    assert candidate(sentence = \"a aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa aaaaaaaaa aaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa a\") == True\n    assert candidate(sentence = \"redivider deified civic level rotator deed madam racecar\") == False\n    assert candidate(sentence = \"a aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa aaaaaaaaa aaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa\") == True\n    assert candidate(sentence = \"level level level\") == True\n    assert candidate(sentence = \"deified deified\") == True\n    assert candidate(sentence = \"Circular larriuC\") == False\n    assert candidate(sentence = \"Symmetry try sym\") == False\n    assert candidate(sentence = \"redivider redivider\") == True\n    assert candidate(sentence = \"banana apple orange emitter\") == False\n    assert candidate(sentence = \"reviled devil\") == False\n    assert candidate(sentence = \"abracadabra arachnid did deep peeled Elba bar\") == False\n    assert candidate(sentence = \"civic deed civic deed\") == False\n    assert candidate(sentence = \"Wow kayak wow wow wow wow wow\") == False\n    assert candidate(sentence = \"Anna annA\") == True\n    assert candidate(sentence = \"Never odd or even\") == False\n    assert candidate(sentence = \"Nurses run\") == False\n    assert candidate(sentence = \"aaaaa aaaaa aaaaa\") == True\n    assert candidate(sentence = \"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z A\") == False\n    assert candidate(sentence = \"Zebra apple orchid night eagle\") == False\n    assert candidate(sentence = \"repaid diaper\") == True\n    assert candidate(sentence = \"Abc bcd def efg gfa\") == False\n    assert candidate(sentence = \"Abc cba abc\") == False\n    assert candidate(sentence = \"a a a a a a a a a a\") == True\n    assert candidate(sentence = \"banana apple orange nice East West\") == False\n    assert candidate(sentence = \"Python nohtyP\") == True\n    assert candidate(sentence = \"Palindrome emordnilaP ndromePal\") == False\n    assert candidate(sentence = \"a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a\") == True\n    assert candidate(sentence = \"Cycle elc yc\") == False\n    assert candidate(sentence = \"algorithm nom alg\") == False\n    assert candidate(sentence = \"Anna annA annA\") == False\n    assert candidate(sentence = \"Twisted tales weave intricate stories\") == False\n    assert candidate(sentence = \"civic civic civic\") == True\n    assert candidate(sentence = \"Rotor rotor\") == False\n    assert candidate(sentence = \"Zoology yggdrasill lloisgoy zoo\") == False\n    assert candidate(sentence = \"coding ngoding going on\") == False\n    assert candidate(sentence = \"repaid repaid\") == False\n    assert candidate(sentence = \"Data analytics sscientist teach harsh\") == False\n    assert candidate(sentence = \"AB BA CA\") == False\n    assert candidate(sentence = \"Mamad Madam Damda\") == False\n    assert candidate(sentence = \"abacabadabacaba\") == True\n", "comparison": "exact"}, "public_tests": ["\"leetcode exercises sound delightful\"", "\"eetcode\"", "\"Leetcode is cool\""], "hints": ["Check the character before the empty space and the character after the empty space.", "Check the first character and the last character of the sentence."], "metadata": {"canonical_parameter_names": ["sentence"], "leetcode_dataset_entry_point": "Solution().isCircularSentence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:44+00:00", "tests_total": 220, "tests_dropped": 1, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def isCircularSentence(self, sentence: str) -> bool:", "container": "Solution", "callable": "isCircularSentence", "parameters": [{"name": "sentence", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2491, "task_id": "divide-players-into-teams-of-equal-skill", "difficulty": "Medium", "problem_description": "You are given a positive integer array skill of even length n where skill[i] denotes the skill of the i^th player. Divide the players into n / 2 teams of size 2 such that the total skill of each team is equal.\n\nThe chemistry of a team is equal to the product of the skills of the players on that team.\n\nReturn the sum of the chemistry of all the teams, or return -1 if there is no way to divide the players into teams such that the total skill of each team is equal.\n\nExample 1:\n\nInput: skill = [3,2,5,1,3,4]\nOutput: 22\nExplanation:\nDivide the players into the following teams: (1, 5), (2, 4), (3, 3), where each team has a total skill of 6.\nThe sum of the chemistry of all the teams is: 1 * 5 + 2 * 4 + 3 * 3 = 5 + 8 + 9 = 22.\n\nExample 2:\n\nInput: skill = [3,4]\nOutput: 12\nExplanation:\nThe two players form a team with a total skill of 7.\nThe chemistry of the team is 3 * 4 = 12.\n\nExample 3:\n\nInput: skill = [1,1,2,3]\nOutput: -1\nExplanation:\nThere is no way to divide the players into teams such that the total skill of each team is equal.\n\nConstraints:\n\n- 2 <= skill.length <= 10^5\n- skill.length is even.\n- 1 <= skill[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(skill = [1, 1000, 1, 1000, 1, 1000, 1, 1000]) == 4000\n    assert candidate(skill = [1, 1, 2, 2, 3, 3, 4, 4]) == 20\n    assert candidate(skill = [1, 1, 2, 3]) == -1\n    assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8]) == 60\n    assert candidate(skill = [5, 5, 5, 5, 5, 5]) == 75\n    assert candidate(skill = [15, 15, 15, 15, 15, 15, 15, 15]) == 900\n    assert candidate(skill = [3, 4]) == 12\n    assert candidate(skill = [2, 3, 3, 2, 2, 3]) == 18\n    assert candidate(skill = [4, 4, 4, 4]) == 32\n    assert candidate(skill = [3, 2, 5, 1, 3, 4]) == 22\n    assert candidate(skill = [10, 10, 10, 10]) == 200\n    assert candidate(skill = [1000, 1000, 1, 1, 2, 2]) == -1\n    assert candidate(skill = [1, 2, 3, 4, 5, 6]) == 28\n    assert candidate(skill = [1, 2, 3, 3, 2, 1]) == 10\n    assert candidate(skill = [1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 4000\n    assert candidate(skill = [10, 20, 30, 40, 50, 60]) == 2800\n    assert candidate(skill = [500, 500, 500, 500, 500, 500, 500, 500]) == 1000000\n    assert candidate(skill = [1, 3, 5, 7, 9, 11]) == 73\n    assert candidate(skill = [1000, 1, 999, 2, 500, 501]) == 253498\n    assert candidate(skill = [500, 500, 1, 999, 2, 998, 3, 997]) == 255986\n    assert candidate(skill = [1, 2, 3, 6, 4, 5]) == 28\n    assert candidate(skill = [250, 750, 500, 500, 750, 250, 500, 500]) == 875000\n    assert candidate(skill = [1, 1, 1, 1, 1, 1, 1, 1]) == 4\n    assert candidate(skill = [1, 1000, 500, 500, 250, 750, 100, 900]) == -1\n    assert candidate(skill = [100, 100, 200, 200, 300, 300, 400, 400, 500, 500]) == 350000\n    assert candidate(skill = [1, 999, 2, 998, 3, 997, 4, 996, 5, 995, 6, 994, 7, 993, 8, 992, 9, 991, 10, 990]) == 54615\n    assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 182\n    assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 18200\n    assert candidate(skill = [1, 999, 3, 997, 5, 995, 7, 993, 9, 991, 11, 989, 13, 987, 15, 985]) == 63320\n    assert candidate(skill = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 512\n    assert candidate(skill = [200, 300, 200, 300, 200, 300, 200, 300]) == 240000\n    assert candidate(skill = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 728\n    assert candidate(skill = [333, 667, 333, 667, 333, 667, 333, 667, 333, 667, 333, 667, 333, 667, 333, 667]) == 1776888\n    assert candidate(skill = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n    assert candidate(skill = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 252\n    assert candidate(skill = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996]) == 14960\n    assert candidate(skill = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6]) == 20909\n    assert candidate(skill = [10, 1, 5, 15, 7, 3, 9, 11]) == -1\n    assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 11000\n    assert candidate(skill = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == 1512\n    assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 40800\n    assert candidate(skill = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 216\n    assert candidate(skill = [2, 8, 3, 7, 4, 6, 5, 5]) == 86\n    assert candidate(skill = [333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348]) == 927352\n    assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 182\n    assert candidate(skill = [23, 42, 31, 57, 5, 19, 6, 49, 12, 35, 29, 10, 50, 40, 21, 33]) == -1\n    assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80]) == 6000\n    assert candidate(skill = [10, 20, 30, 40, 50, 60, 10, 20, 30, 40, 50, 60]) == 5600\n    assert candidate(skill = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 5000\n    assert candidate(skill = [8, 1, 8, 1, 8, 1, 8, 1]) == 32\n    assert candidate(skill = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200]) == -1\n    assert candidate(skill = [250, 250, 500, 500, 750, 750, 1000, 1000]) == 1250000\n    assert candidate(skill = [300, 700, 200, 800, 100, 900, 400, 600, 500, 500]) == 950000\n    assert candidate(skill = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 1250000\n    assert candidate(skill = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 200\n    assert candidate(skill = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 441\n    assert candidate(skill = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 20000\n    assert candidate(skill = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 6000\n    assert candidate(skill = [123, 321, 213, 312, 132, 231, 213, 132]) == -1\n    assert candidate(skill = [6, 3, 9, 2, 8, 4, 5, 7, 1, 10, 11, 12, 13, 14, 15, 16]) == 408\n    assert candidate(skill = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 3080\n    assert candidate(skill = [8, 6, 4, 2, 10, 12, 14, 16, 18, 20]) == 440\n    assert candidate(skill = [1, 1000, 2, 999, 3, 998, 4, 997]) == 9980\n    assert candidate(skill = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == 84\n    assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 18200\n    assert candidate(skill = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 110\n    assert candidate(skill = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == 84\n    assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 770\n    assert candidate(skill = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 1500000\n    assert candidate(skill = [499, 501, 498, 502, 497, 503, 496, 504]) == 999970\n    assert candidate(skill = [1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16]) == 408\n    assert candidate(skill = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == 5994\n    assert candidate(skill = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == 7992\n    assert candidate(skill = [5, 1, 4, 3, 2, 6]) == 28\n    assert candidate(skill = [333, 333, 333, 333, 334, 334, 334, 334]) == 444888\n    assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 770\n    assert candidate(skill = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250]) == 500000\n    assert candidate(skill = [10, 10, 10, 10, 10, 10, 10, 10]) == 400\n    assert candidate(skill = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 510\n    assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 77000\n    assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 11000\n    assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 408\n    assert candidate(skill = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 384\n    assert candidate(skill = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 335\n    assert candidate(skill = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == 14985\n    assert candidate(skill = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992, 8, 991, 9, 990, 10]) == 54615\n    assert candidate(skill = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 150\n    assert candidate(skill = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250]) == 375000\n    assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 280\n    assert candidate(skill = [1, 999, 2, 998, 3, 997, 4, 996, 5, 995]) == 14945\n    assert candidate(skill = [100, 200, 300, 400, 100, 200, 300, 400, 500, 600, 500, 600]) == 560000\n    assert candidate(skill = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 110\n    assert candidate(skill = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 490\n    assert candidate(skill = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 2000000\n    assert candidate(skill = [15, 16, 15, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 1820\n    assert candidate(skill = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 600\n    assert candidate(skill = [100, 200, 300, 400, 500, 600, 700, 800]) == 600000\n    assert candidate(skill = [999, 1, 999, 1, 999, 1, 999, 1]) == 3996\n    assert candidate(skill = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 110\n    assert candidate(skill = [600, 400, 600, 400, 600, 400, 600, 400, 600, 400, 600, 400]) == 1440000\n    assert candidate(skill = [1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000]) == 5000\n    assert candidate(skill = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 150\n    assert candidate(skill = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 288\n    assert candidate(skill = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 8000\n    assert candidate(skill = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 220\n    assert candidate(skill = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n    assert candidate(skill = [1, 9, 1, 9, 1, 9, 1, 9]) == 36\n    assert candidate(skill = [300, 700, 200, 800, 400, 600, 100, 900, 500, 500, 400, 600]) == 1190000\n    assert candidate(skill = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 335\n    assert candidate(skill = [150, 250, 150, 250, 150, 250, 150, 250, 150, 250]) == 187500\n    assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 22000\n    assert candidate(skill = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 200\n    assert candidate(skill = [1000, 1, 999, 2, 998, 3, 997, 4]) == 9980\n    assert candidate(skill = [8, 1, 5, 3, 4, 7, 2, 6, 9, 10, 12, 11]) == 182\n    assert candidate(skill = [10, 1, 10, 1, 10, 1, 10, 1]) == 40\n    assert candidate(skill = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 125\n    assert candidate(skill = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 40800\n    assert candidate(skill = [5, 5, 5, 5, 5, 5, 5, 5]) == 100\n    assert candidate(skill = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 20000\n    assert candidate(skill = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 40\n    assert candidate(skill = [250, 750, 250, 750, 250, 750, 250, 750, 250, 750, 250, 750, 250, 750, 250, 750]) == 1500000\n", "comparison": "exact"}, "public_tests": ["[3,2,5,1,3,4]", "[3,4]", "[1,1,2,3]"], "hints": ["Try sorting the skill array.", "It is always optimal to pair the weakest available player with the strongest available player."], "metadata": {"canonical_parameter_names": ["skill"], "leetcode_dataset_entry_point": "Solution().dividePlayers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:46+00:00", "tests_total": 122, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "two-pointers", "sorting"]}, "language": "python", "interface": {"raw_signature": "def dividePlayers(self, skill: list[int]) -> int:", "container": "Solution", "callable": "dividePlayers", "parameters": [{"name": "skill", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2492, "task_id": "minimum-score-of-a-path-between-two-cities", "difficulty": "Medium", "problem_description": "You are given a positive integer n representing n cities numbered from 1 to n. You are also given a 2D array roads where roads[i] = [a_i, b_i, distance_i] indicates that there is a bidirectional road between cities a_i and b_i with a distance equal to distance_i. The cities graph is not necessarily connected.\n\nThe score of a path between two cities is defined as the minimum distance of a road in this path.\n\nReturn the minimum possible score of a path between cities 1 and n.\n\nNote:\n\n- A path is a sequence of roads between two cities.\n- It is allowed for a path to contain the same road multiple times, and you can visit cities 1 and n multiple times along the path.\n- The test cases are generated such that there is at least one path between 1 and n.\n\nExample 1:\n\nInput: n = 4, roads = [[1,2,9],[2,3,6],[2,4,5],[1,4,7]]\nOutput: 5\nExplanation: The path from city 1 to 4 with the minimum score is: 1 -> 2 -> 4. The score of this path is min(9,5) = 5.\nIt can be shown that no other path has less score.\n\nExample 2:\n\nInput: n = 4, roads = [[1,2,2],[1,3,4],[3,4,7]]\nOutput: 2\nExplanation: The path from city 1 to 4 with the minimum score is: 1 -> 2 -> 1 -> 3 -> 4. The score of this path is min(2,2,4,7) = 2.\n\nConstraints:\n\n- 2 <= n <= 10^5\n- 1 <= roads.length <= 10^5\n- roads[i].length == 3\n- 1 <= a_i, b_i <= n\n- a_i != b_i\n- 1 <= distance_i <= 10^4\n- There are no repeated edges.\n- There is at least one path between 1 and n.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 5,roads = [[1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [1, 5, 30]]) == 10\n    assert candidate(n = 6,roads = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5]]) == 1\n    assert candidate(n = 4,roads = [[1, 2, 2], [1, 3, 4], [3, 4, 7]]) == 2\n    assert candidate(n = 5,roads = [[1, 2, 10], [2, 3, 5], [3, 4, 2], [4, 5, 1]]) == 1\n    assert candidate(n = 3,roads = [[1, 2, 5], [2, 3, 10], [1, 3, 7]]) == 5\n    assert candidate(n = 6,roads = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [1, 6, 1]]) == 1\n    assert candidate(n = 3,roads = [[1, 2, 1], [2, 3, 2], [1, 3, 3]]) == 1\n    assert candidate(n = 4,roads = [[1, 2, 9], [2, 3, 6], [2, 4, 5], [1, 4, 7]]) == 5\n    assert candidate(n = 3,roads = [[1, 2, 3], [2, 3, 1]]) == 1\n    assert candidate(n = 5,roads = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 1], [1, 5, 2]]) == 1\n    assert candidate(n = 6,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [1, 6, 60]]) == 10\n    assert candidate(n = 9,roads = [[1, 2, 2], [2, 3, 4], [3, 4, 6], [4, 5, 8], [5, 6, 10], [6, 7, 12], [7, 8, 14], [8, 9, 16], [1, 9, 18], [2, 8, 20], [3, 7, 22], [4, 6, 24], [5, 9, 26], [1, 5, 28], [2, 6, 30], [3, 9, 32], [1, 7, 34], [2, 9, 36], [1, 4, 38], [1, 3, 40], [1, 6, 42]]) == 2\n    assert candidate(n = 7,roads = [[1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1], [6, 7, 6], [7, 1, 7], [2, 5, 8], [3, 6, 9]]) == 1\n    assert candidate(n = 9,roads = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [1, 3, 2], [3, 5, 3], [5, 7, 4], [7, 9, 5]]) == 1\n    assert candidate(n = 15,roads = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900], [10, 11, 1000], [11, 12, 1100], [12, 13, 1200], [13, 14, 1300], [14, 15, 1400], [1, 15, 50]]) == 50\n    assert candidate(n = 10,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [1, 5, 15], [5, 9, 25]]) == 10\n    assert candidate(n = 7,roads = [[1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [1, 3, 5], [3, 5, 5], [5, 7, 5], [1, 4, 5], [4, 6, 5], [2, 4, 5], [3, 6, 5], [1, 6, 5], [2, 5, 5], [3, 7, 5]]) == 5\n    assert candidate(n = 20,roads = [[1, 2, 20], [1, 3, 19], [2, 3, 18], [2, 4, 17], [3, 5, 16], [4, 5, 15], [5, 6, 14], [6, 7, 13], [7, 8, 12], [8, 9, 11], [9, 10, 10], [10, 11, 9], [11, 12, 8], [12, 13, 7], [13, 14, 6], [14, 15, 5], [15, 16, 4], [16, 17, 3], [17, 18, 2], [18, 19, 1], [19, 20, 20]]) == 1\n    assert candidate(n = 10,roads = [[1, 2, 10], [1, 3, 5], [2, 4, 1], [2, 5, 8], [3, 6, 3], [4, 7, 2], [5, 8, 4], [6, 9, 6], [7, 10, 7], [8, 10, 9], [1, 10, 12]]) == 1\n    assert candidate(n = 6,roads = [[1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 1, 1], [2, 6, 10]]) == 1\n    assert candidate(n = 12,roads = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12], [11, 12, 13], [1, 12, 1], [2, 10, 2], [4, 11, 3]]) == 1\n    assert candidate(n = 15,roads = [[1, 2, 2], [2, 3, 4], [3, 4, 5], [4, 5, 1], [1, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [9, 10, 7], [10, 11, 8], [11, 12, 9], [12, 13, 10], [13, 14, 11], [14, 15, 12]]) == 1\n    assert candidate(n = 8,roads = [[1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 1, 9], [1, 3, 10], [2, 4, 11], [3, 5, 12], [4, 6, 13], [5, 7, 14], [6, 8, 15], [1, 4, 16], [2, 5, 17], [3, 6, 18], [4, 7, 19], [5, 8, 20], [1, 5, 21], [2, 6, 22], [3, 7, 23], [4, 8, 24]]) == 2\n    assert candidate(n = 15,roads = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [1, 15, 15]]) == 1\n    assert candidate(n = 8,roads = [[1, 2, 100], [2, 3, 101], [3, 4, 102], [4, 5, 103], [5, 6, 104], [6, 7, 105], [7, 8, 106], [8, 1, 1], [2, 8, 200], [3, 7, 300]]) == 1\n    assert candidate(n = 8,roads = [[1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1], [6, 7, 6], [7, 8, 7], [1, 8, 10], [2, 7, 8], [3, 6, 9], [4, 5, 11]]) == 1\n    assert candidate(n = 6,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [1, 6, 5]]) == 5\n    assert candidate(n = 6,roads = [[1, 3, 10], [1, 4, 20], [3, 4, 15], [4, 6, 30], [6, 5, 25], [5, 2, 5]]) == 5\n    assert candidate(n = 7,roads = [[1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [1, 7, 5], [1, 3, 5], [3, 5, 5], [5, 7, 5]]) == 5\n    assert candidate(n = 8,roads = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 1, 800], [1, 4, 150], [2, 5, 250], [3, 6, 350], [4, 7, 450], [5, 8, 550], [6, 1, 650], [7, 2, 750], [8, 3, 850]]) == 100\n    assert candidate(n = 10,roads = [[1, 2, 5], [2, 3, 3], [3, 4, 7], [4, 5, 2], [5, 6, 6], [6, 7, 8], [7, 8, 4], [8, 9, 9], [9, 10, 1], [1, 10, 11], [2, 4, 12], [3, 5, 13], [4, 6, 14], [5, 7, 15], [6, 8, 16], [7, 9, 17], [8, 10, 18], [9, 1, 19], [10, 2, 20]]) == 1\n    assert candidate(n = 5,roads = [[1, 2, 1000], [2, 3, 999], [3, 4, 998], [4, 5, 997], [1, 3, 996], [2, 4, 995], [3, 5, 994], [1, 4, 993], [2, 5, 992], [1, 5, 991]]) == 991\n    assert candidate(n = 7,roads = [[1, 2, 2], [2, 3, 5], [3, 4, 7], [4, 5, 3], [5, 6, 8], [6, 7, 1], [1, 7, 6], [2, 6, 4], [3, 5, 9], [1, 5, 10]]) == 1\n    assert candidate(n = 15,roads = [[1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1], [6, 7, 5], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [1, 15, 20]]) == 1\n    assert candidate(n = 8,roads = [[1, 2, 50], [2, 3, 40], [3, 4, 30], [4, 5, 20], [5, 6, 10], [6, 7, 5], [7, 8, 1], [8, 1, 30], [2, 4, 25], [4, 6, 15], [6, 8, 5]]) == 1\n    assert candidate(n = 10,roads = [[1, 2, 5], [1, 3, 2], [2, 4, 3], [3, 4, 1], [4, 5, 6], [5, 6, 4], [6, 7, 9], [7, 8, 8], [8, 9, 7], [9, 10, 10]]) == 1\n    assert candidate(n = 10,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [1, 5, 15], [2, 6, 25], [3, 7, 35], [4, 8, 45]]) == 10\n    assert candidate(n = 8,roads = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 1, 8], [1, 3, 9], [2, 4, 10], [3, 5, 11], [4, 6, 12], [5, 7, 13], [6, 8, 14]]) == 1\n    assert candidate(n = 9,roads = [[1, 2, 15], [1, 4, 10], [2, 3, 5], [2, 5, 3], [3, 6, 7], [4, 5, 2], [4, 7, 6], [5, 8, 4], [6, 9, 8], [7, 8, 1], [8, 9, 9]]) == 1\n    assert candidate(n = 6,roads = [[1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1], [1, 6, 6], [1, 3, 7], [2, 4, 8], [3, 5, 9]]) == 1\n    assert candidate(n = 7,roads = [[1, 2, 7], [1, 3, 15], [2, 3, 6], [2, 4, 9], [3, 5, 12], [4, 5, 10], [4, 6, 11], [5, 6, 8], [5, 7, 3], [6, 7, 2]]) == 2\n    assert candidate(n = 7,roads = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [1, 7, 7], [2, 4, 8], [3, 5, 9]]) == 1\n    assert candidate(n = 7,roads = [[1, 2, 5], [2, 3, 4], [3, 4, 6], [4, 5, 3], [5, 6, 2], [6, 7, 8], [1, 7, 7]]) == 2\n    assert candidate(n = 20,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120], [13, 14, 130], [14, 15, 140], [15, 16, 150], [16, 17, 160], [17, 18, 170], [18, 19, 180], [19, 20, 190], [1, 20, 5]]) == 5\n    assert candidate(n = 6,roads = [[1, 2, 5], [2, 3, 2], [3, 4, 8], [4, 5, 3], [5, 6, 1], [1, 6, 4]]) == 1\n    assert candidate(n = 9,roads = [[1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 1, 1], [1, 3, 10], [2, 4, 11], [3, 5, 12], [4, 6, 13], [5, 7, 14], [6, 8, 15], [7, 9, 16], [8, 1, 17], [9, 2, 18]]) == 1\n    assert candidate(n = 10,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [1, 10, 5]]) == 5\n    assert candidate(n = 6,roads = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [1, 6, 150], [1, 4, 250], [3, 6, 350], [2, 5, 450]]) == 100\n    assert candidate(n = 8,roads = [[1, 2, 6], [2, 3, 3], [3, 4, 9], [4, 5, 4], [5, 6, 5], [6, 7, 2], [7, 8, 7], [8, 1, 8]]) == 2\n    assert candidate(n = 10,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [1, 10, 1]]) == 1\n    assert candidate(n = 10,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90]]) == 10\n    assert candidate(n = 12,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [1, 12, 5]]) == 5\n    assert candidate(n = 6,roads = [[1, 2, 5], [2, 3, 3], [3, 4, 7], [4, 5, 2], [5, 6, 4], [6, 1, 6], [1, 3, 10], [2, 4, 1], [3, 5, 8], [4, 6, 9], [5, 1, 7], [6, 2, 11]]) == 1\n    assert candidate(n = 15,roads = [[1, 2, 10], [2, 3, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8], [6, 7, 9], [7, 8, 1], [8, 9, 2], [9, 10, 3], [10, 11, 4], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 1, 15]]) == 1\n    assert candidate(n = 7,roads = [[1, 2, 4], [2, 3, 3], [3, 4, 2], [4, 5, 1], [5, 6, 1], [6, 7, 2], [1, 7, 5], [2, 7, 6], [3, 7, 7]]) == 1\n    assert candidate(n = 12,roads = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 1, 12], [1, 3, 3], [3, 5, 5], [5, 7, 7], [7, 9, 9], [9, 11, 11], [2, 4, 4], [4, 6, 6], [6, 8, 8], [8, 10, 10], [10, 12, 12]]) == 1\n    assert candidate(n = 6,roads = [[1, 2, 100], [1, 3, 200], [2, 4, 300], [3, 5, 400], [4, 5, 500], [5, 6, 600], [2, 6, 700], [1, 4, 800], [3, 6, 900]]) == 100\n    assert candidate(n = 15,roads = [[1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 15, 75], [15, 1, 80], [1, 3, 85], [3, 5, 90], [5, 7, 95], [7, 9, 100], [9, 11, 105], [11, 13, 110], [13, 15, 115], [2, 4, 120], [4, 6, 125], [6, 8, 130], [8, 10, 135], [10, 12, 140], [12, 14, 145], [14, 2, 150], [1, 4, 155], [4, 7, 160], [7, 10, 165], [10, 13, 170], [13, 1, 175], [2, 5, 180], [5, 8, 185], [8, 11, 190], [11, 14, 195], [14, 1, 200]]) == 10\n    assert candidate(n = 10,roads = [[1, 2, 10], [1, 3, 9], [2, 4, 8], [2, 5, 7], [3, 5, 6], [4, 6, 5], [5, 6, 4], [6, 7, 3], [7, 8, 2], [8, 9, 1], [9, 10, 1]]) == 1\n    assert candidate(n = 8,roads = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [1, 8, 80], [2, 5, 90], [3, 6, 100], [4, 7, 110]]) == 10\n    assert candidate(n = 10,roads = [[1, 2, 9], [2, 3, 6], [3, 4, 5], [4, 5, 7], [5, 6, 8], [6, 7, 4], [7, 8, 2], [8, 9, 1], [9, 10, 3], [10, 1, 10]]) == 1\n    assert candidate(n = 20,roads = [[1, 2, 20], [2, 3, 19], [3, 4, 18], [4, 5, 17], [5, 6, 16], [6, 7, 15], [7, 8, 14], [8, 9, 13], [9, 10, 12], [10, 11, 11], [11, 12, 10], [12, 13, 9], [13, 14, 8], [14, 15, 7], [15, 16, 6], [16, 17, 5], [17, 18, 4], [18, 19, 3], [19, 20, 2], [20, 1, 1]]) == 1\n    assert candidate(n = 8,roads = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 1], [5, 6, 2], [6, 7, 6], [7, 8, 5], [8, 1, 7]]) == 1\n    assert candidate(n = 20,roads = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900], [10, 11, 1000], [11, 12, 1100], [12, 13, 1200], [13, 14, 1300], [14, 15, 1400], [15, 16, 1500], [16, 17, 1600], [17, 18, 1700], [18, 19, 1800], [19, 20, 1900], [20, 1, 2000], [1, 3, 2100], [3, 5, 2200], [5, 7, 2300], [7, 9, 2400], [9, 11, 2500], [11, 13, 2600], [13, 15, 2700], [15, 17, 2800], [17, 19, 2900], [19, 1, 3000], [2, 4, 3100], [4, 6, 3200], [6, 8, 3300], [8, 10, 3400], [10, 12, 3500], [12, 14, 3600], [14, 16, 3700], [16, 18, 3800], [18, 20, 3900], [1, 4, 4000], [4, 7, 4100], [7, 10, 4200], [10, 13, 4300], [13, 16, 4400], [16, 19, 4500], [19, 2, 4600], [2, 5, 4700], [5, 8, 4800], [8, 11, 4900], [11, 14, 5000], [14, 17, 5100], [17, 20, 5200], [20, 1, 5300]]) == 100\n    assert candidate(n = 15,roads = [[1, 2, 15], [2, 3, 14], [3, 4, 13], [4, 5, 12], [5, 6, 11], [6, 7, 10], [7, 8, 9], [8, 9, 8], [9, 10, 7], [10, 11, 6], [11, 12, 5], [12, 13, 4], [13, 14, 3], [14, 15, 2], [1, 15, 1], [2, 14, 16], [3, 13, 17], [4, 12, 18], [5, 11, 19], [6, 10, 20], [7, 9, 21]]) == 1\n", "comparison": "exact"}, "public_tests": ["4\n[[1,2,9],[2,3,6],[2,4,5],[1,4,7]]", "4\n[[1,2,2],[1,3,4],[3,4,7]]"], "hints": ["Can you solve the problem if the whole graph is connected?", "Notice that if the graph is connected, you can always use any edge of the graph in your path.", "How to solve the general problem in a similar way? Remove all the nodes that are not connected to 1 and n, then apply the previous solution in the new graph."], "metadata": {"canonical_parameter_names": ["n", "roads"], "leetcode_dataset_entry_point": "Solution().minScore", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:48+00:00", "tests_total": 65, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["depth-first-search", "breadth-first-search", "union-find", "graph"]}, "language": "python", "interface": {"raw_signature": "def minScore(self, n: int, roads: list[list[int]]) -> int:", "container": "Solution", "callable": "minScore", "parameters": [{"name": "n", "type": "int"}, {"name": "roads", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2493, "task_id": "divide-nodes-into-the-maximum-number-of-groups", "difficulty": "Hard", "problem_description": "You are given a positive integer n representing the number of nodes in an undirected graph. The nodes are labeled from 1 to n.\n\nYou are also given a 2D integer array edges, where edges[i] = [a_i,b_i] indicates that there is a bidirectional edge between nodes a_i and b_i. Notice that the given graph may be disconnected.\n\nDivide the nodes of the graph into m groups (1-indexed) such that:\n\n- Each node in the graph belongs to exactly one group.\n- For every pair of nodes in the graph that are connected by an edge [a_i,b_i], if a_i belongs to the group with index x, and b_i belongs to the group with index y, then |y - x| = 1.\n\nReturn the maximum number of groups (i.e., maximum m) into which you can divide the nodes. Return -1 if it is impossible to group the nodes with the given conditions.\n\nExample 1:\n\nInput: n = 6, edges = [[1,2],[1,4],[1,5],[2,6],[2,3],[4,6]]\nOutput: 4\nExplanation: As shown in the image we:\n- Add node 5 to the first group.\n- Add node 1 to the second group.\n- Add nodes 2 and 4 to the third group.\n- Add nodes 3 and 6 to the fourth group.\nWe can see that every edge is satisfied.\nIt can be shown that that if we create a fifth group and move any node from the third or fourth group to it, at least on of the edges will not be satisfied.\n\nExample 2:\n\nInput: n = 3, edges = [[1,2],[2,3],[3,1]]\nOutput: -1\nExplanation: If we add node 1 to the first group, node 2 to the second group, and node 3 to the third group to satisfy the first two edges, we can see that the third edge will not be satisfied.\nIt can be shown that no grouping is possible.\n\nConstraints:\n\n- 1 <= n <= 500\n- 1 <= edges.length <= 10^4\n- edges[i].length == 2\n- 1 <= a_i, b_i <= n\n- a_i != b_i\n- There is at most one edge between any pair of vertices.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 1], [4, 5]]) == -1\n    assert candidate(n = 4,edges = [[1, 2], [3, 4]]) == 4\n    assert candidate(n = 6,edges = [[1, 2], [1, 4], [1, 5], [2, 6], [2, 3], [4, 6]]) == 4\n    assert candidate(n = 3,edges = [[1, 2], [2, 3], [3, 1]]) == -1\n    assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 5\n    assert candidate(n = 7,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 7\n    assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == -1\n    assert candidate(n = 4,edges = [[1, 2]]) == 4\n    assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 3\n    assert candidate(n = 7,edges = [[1, 2], [2, 3], [4, 5], [5, 6], [6, 7]]) == 7\n    assert candidate(n = 4,edges = [[1, 2], [2, 3]]) == 4\n    assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [1, 5]]) == 3\n    assert candidate(n = 5,edges = [[1, 2], [3, 4]]) == 5\n    assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10]]) == -1\n    assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [1, 10]]) == 8\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [1, 6], [10, 11]]) == -1\n    assert candidate(n = 50,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21], [26, 27], [27, 28], [28, 29], [29, 30], [30, 26], [31, 32], [32, 33], [33, 34], [34, 35], [35, 31], [36, 37], [37, 38], [38, 39], [39, 40], [40, 36], [41, 42], [42, 43], [43, 44], [44, 45], [45, 41], [46, 47], [47, 48], [48, 49], [49, 50], [50, 46]]) == -1\n    assert candidate(n = 18,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 1], [1, 10], [10, 18]]) == -1\n    assert candidate(n = 16,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16]]) == 16\n    assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21]]) == -1\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7], [13, 14], [14, 15], [15, 13]]) == -1\n    assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25]]) == 25\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [1, 15]]) == -1\n    assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21], [26, 27], [27, 28], [28, 29], [29, 30], [30, 26], [1, 6], [11, 16], [21, 26]]) == -1\n    assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 8], [8, 5], [1, 5], [2, 6], [3, 7], [4, 8]]) == 4\n    assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n    assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12]]) == 12\n    assert candidate(n = 16,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 16\n    assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]) == 11\n    assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]) == 7\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 15\n    assert candidate(n = 6,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]]) == -1\n    assert candidate(n = 8,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 5], [5, 6], [6, 7], [7, 8]]) == -1\n    assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n    assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16]]) == -1\n    assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21], [26, 27], [27, 28], [28, 29], [29, 30], [30, 26]]) == -1\n    assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 6\n    assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == 30\n    assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 1], [8, 2]]) == 6\n    assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == 10\n    assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 6]]) == -1\n    assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [1, 9], [2, 8], [3, 7], [4, 6]]) == -1\n    assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 20\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 13], [13, 10], [14, 15], [15, 14]]) == -1\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 6], [13, 14], [14, 15]]) == -1\n    assert candidate(n = 10,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 10\n    assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7]]) == 8\n    assert candidate(n = 20,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 20\n    assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 1]]) == 7\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [11, 12], [12, 13], [13, 14], [14, 15], [1, 11], [5, 15]]) == 11\n    assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12]]) == 6\n    assert candidate(n = 10,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [2, 3], [4, 5], [6, 7], [8, 9]]) == 10\n    assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 12]]) == 7\n    assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]]) == 4\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11]]) == -1\n    assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10]]) == 8\n    assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7]]) == -1\n    assert candidate(n = 40,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21], [26, 27], [27, 28], [28, 29], [29, 30], [30, 26], [31, 32], [32, 33], [33, 34], [34, 35], [35, 31], [36, 37], [37, 38], [38, 39], [39, 40], [40, 36]]) == -1\n    assert candidate(n = 16,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 1]]) == 9\n    assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10]]) == 6\n    assert candidate(n = 18,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 13], [13, 10], [14, 15], [15, 16], [16, 17], [17, 14], [18, 1]]) == -1\n    assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8]]) == -1\n    assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1]]) == -1\n    assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [1, 15]]) == 12\n    assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [1, 6], [11, 16]]) == -1\n    assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15]]) == 8\n    assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7], [13, 14], [14, 15], [15, 16], [16, 13], [17, 18], [18, 19], [19, 20], [20, 17]]) == 14\n    assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1], [1, 11], [10, 18], [15, 25]]) == -1\n    assert candidate(n = 22,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 1]]) == 12\n    assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [1, 12]]) == 7\n    assert candidate(n = 18,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18]]) == 18\n    assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12]]) == 11\n    assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21], [26, 27], [27, 28], [28, 29], [29, 30], [30, 26]]) == -1\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 6]]) == -1\n    assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 9\n    assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 11]]) == -1\n    assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]) == 5\n    assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 6\n    assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5]]) == -1\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [1, 4], [2, 5], [3, 6], [7, 10], [8, 11], [9, 12]]) == -1\n    assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 1]]) == 16\n    assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 2]]) == 8\n    assert candidate(n = 18,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [1, 18]]) == 10\n", "comparison": "exact"}, "public_tests": ["6\n[[1,2],[1,4],[1,5],[2,6],[2,3],[4,6]]", "3\n[[1,2],[2,3],[3,1]]"], "hints": ["If the graph is not bipartite, it is not possible to group the nodes.", "Notice that we can solve the problem for each connected component independently, and the final answer will be just the sum of the maximum number of groups in each component.", "Finally, to solve the problem for each connected component, we can notice that if for some node v we fix its position to be in the leftmost group, then we can also evaluate the position of every other node. That position is the depth of the node in a bfs tree after rooting at node v."], "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().magnificentSets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:50+00:00", "tests_total": 83, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["depth-first-search", "breadth-first-search", "union-find", "graph"]}, "language": "python", "interface": {"raw_signature": "def magnificentSets(self, n: int, edges: list[list[int]]) -> int:", "container": "Solution", "callable": "magnificentSets", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2496, "task_id": "maximum-value-of-a-string-in-an-array", "difficulty": "Easy", "problem_description": "The value of an alphanumeric string can be defined as:\n\n- The numeric representation of the string in base 10, if it comprises of digits only.\n- The length of the string, otherwise.\n\nGiven an array strs of alphanumeric strings, return the maximum value of any string in strs.\n\nExample 1:\n\nInput: strs = [\"alic3\",\"bob\",\"3\",\"4\",\"00000\"]\nOutput: 5\nExplanation:\n- \"alic3\" consists of both letters and digits, so its value is its length, i.e. 5.\n- \"bob\" consists only of letters, so its value is also its length, i.e. 3.\n- \"3\" consists only of digits, so its value is its numeric equivalent, i.e. 3.\n- \"4\" also consists only of digits, so its value is 4.\n- \"00000\" consists only of digits, so its value is 0.\nHence, the maximum value is 5, of \"alic3\".\n\nExample 2:\n\nInput: strs = [\"1\",\"01\",\"001\",\"0001\"]\nOutput: 1\nExplanation:\nEach string in the array has value 1. Hence, we return 1.\n\nConstraints:\n\n- 1 <= strs.length <= 100\n- 1 <= strs[i].length <= 9\n- strs[i] consists of only lowercase English letters and digits.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(strs = ['xyz', 'xyzz', 'xyzzz', 'xyzzzz']) == 6\n    assert candidate(strs = ['a1', 'b2', 'c3', '1a', '2b', '3c']) == 2\n    assert candidate(strs = ['abc', '123', 'a1b2c3', '000']) == 123\n    assert candidate(strs = ['123456789', '987654321', '111111111', '222222222', '333333333']) == 987654321\n    assert candidate(strs = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 1\n    assert candidate(strs = ['alic3', 'bob', '3', '4', '00000']) == 5\n    assert candidate(strs = ['abc', '123', 'abcd', '4567', '89']) == 4567\n    assert candidate(strs = ['a', 'b', 'c', '1', '2', '3', '10', '11', '12']) == 12\n    assert candidate(strs = ['987654321', 'abcdefg', 'hijklmn', '000000000']) == 987654321\n    assert candidate(strs = ['987', '654', '321', '0', 'abcdefg']) == 987\n    assert candidate(strs = ['1', '01', '001', '0001']) == 1\n    assert candidate(strs = ['abc', '123', 'a1b2', '11111', 'zzzzz']) == 11111\n    assert candidate(strs = ['hello', 'world', 'python', 'code']) == 6\n    assert candidate(strs = ['111', '222', '333', '4444']) == 4444\n    assert candidate(strs = ['000', '0000', '00000', '000000', '0000000']) == 0\n    assert candidate(strs = ['98765', '4321', '11111', '222']) == 98765\n    assert candidate(strs = ['abc', '123', 'def456', '7890']) == 7890\n    assert candidate(strs = ['abc', '123', 'a1b2c3', '111111111']) == 111111111\n    assert candidate(strs = ['a', 'b', 'c', 'd']) == 1\n    assert candidate(strs = ['99999', '88888', '77777', '66666', '55555', '44444', '33333', '22222', '11111', '00000']) == 99999\n    assert candidate(strs = ['1', '01', '001', '0001', '00001', '000001', '0000001', '00000001', '000000001']) == 1\n    assert candidate(strs = ['123', '456', '789', 'abc', 'def', 'ghi', '1', '2', '3', '4', '5', '6', '7', '8', '9']) == 789\n    assert candidate(strs = ['987654321', '123456789', 'abcdefghi', 'jklmnopqr', '000000000', '111111111', '222222222']) == 987654321\n    assert candidate(strs = ['a1b2c3d4e', '111111111', 'fgh', '5678', 'ijklmno']) == 111111111\n    assert candidate(strs = ['987', '654', '321', '000', '00', '0', 'abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yz123']) == 987\n    assert candidate(strs = ['abc', 'defg', 'hijkl', 'mnopqr', 'stuvwx', 'yz123', '456789', '000000000']) == 456789\n    assert candidate(strs = ['0', '00', '000', '0000', '00000', '1', '01', '001', '0001']) == 1\n    assert candidate(strs = ['a1', 'b2', 'c3', 'd4', 'e5', 'f6', 'g7', 'h8', 'i9', 'j10', 'k11', 'l12', 'm13', 'n14', 'o15']) == 3\n    assert candidate(strs = ['abcdefg', 'hijklmn', '0000000', '1234567', '890', 'opqrstu', 'vwxyz', '98765', '43210', '00001']) == 1234567\n    assert candidate(strs = ['123abc', '456def', '789ghi', '0', '1', '2', '3', '4', '5']) == 6\n    assert candidate(strs = ['a1', 'b2', 'c3', 'd4', 'e5', 'f6', 'g7', 'h8', 'i9', 'j0']) == 2\n    assert candidate(strs = ['a1', 'b2', 'c3', 'd4', 'e5', 'f6', 'g7', 'h8', 'i9', 'j0', 'a1b2', 'c3d4', 'e5f6', 'g7h8', 'i9j0']) == 4\n    assert candidate(strs = ['a1', 'b2', 'c3', 'd4', 'e5', 'f6', 'g7', 'h8', 'i9', 'j0']) == 2\n    assert candidate(strs = ['a', '1', 'ab', '12', 'abc', '123', 'abcd', '1234', 'abcde', '12345']) == 12345\n    assert candidate(strs = ['abc123', '456', 'def', '7890', 'ghi789']) == 7890\n    assert candidate(strs = ['123', 'abc1', '234', 'bcd2', '345', 'cde3', '456', 'def4', '567', 'efg5']) == 567\n    assert candidate(strs = ['abc123', 'def', 'ghi', '4567', '89', '0', 'abcdefg', 'hijklmn']) == 4567\n    assert candidate(strs = ['abc123', '123abc', 'abc1', 'a1b2c3', '123456789']) == 123456789\n    assert candidate(strs = ['123abc', '456def', '789ghi', 'abc123def', '456ghi789', '000abc123', '123456789', 'abcdef000']) == 123456789\n    assert candidate(strs = ['a1', 'b2', 'c3', '1a', '2b', '3c', '10a', '20b', '30c']) == 3\n    assert candidate(strs = ['abc123', 'def456', 'ghi789', 'jkl012', 'mno345', 'pqr678', 'stu901', 'vwx234', 'yz567', '0abc', '1def', '2ghi', '3jkl', '4mno', '5pqr', '6stu', '7vwx', '8yz', '9abc']) == 6\n    assert candidate(strs = ['00001', '00002', '00003', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']) == 10\n    assert candidate(strs = ['zzzzz', '00000', '11111', '22222', '33333', '44444']) == 44444\n    assert candidate(strs = ['abcdefg', 'hijklmn', 'opqrstu', 'vwxyz', '0123456', '7890123', '4567890', '1234567', '8901234', '5678901']) == 8901234\n    assert candidate(strs = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yz', '123456', '789012', '345678', '901234', '567890']) == 901234\n    assert candidate(strs = ['1a', '2b', '3c', '4d', '5e', '6f', '7g', '8h', '9i', '0j']) == 2\n    assert candidate(strs = ['0', '00', '000', '0000', '00000', '000000', '0000000', '00000000', '1', '2', '3', '4', '5', '6', '7', '8', '9']) == 9\n    assert candidate(strs = ['00000000', '00000001', '00000010', '00000100', '00001000', '00010000', '00100000', '01000000', '10000000']) == 10000000\n    assert candidate(strs = ['1234567', 'abcdefg', '7654321', 'gfedcba', '123abc', 'abc123', 'abc123abc', '123abc123', 'abc', '123', '1', 'a', '000', '999']) == 7654321\n    assert candidate(strs = ['abcde123', '123abcde', 'abcd1234', '1234abcd', '11111111', '22222222', '33333333', '44444444', '55555555', '66666666', '77777777', '88888888', '99999999', '00000000']) == 99999999\n    assert candidate(strs = ['00001', '00010', '00100', '01000', '10000', 'abcde', 'fghij', 'klmno', 'pqrst']) == 10000\n    assert candidate(strs = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yz01', '2345', '6789', '0000', '1111', '2222', '3333', '4444', '5555', '6666', '7777', '8888', '9999']) == 9999\n    assert candidate(strs = ['abc123', 'def', 'ghi456', '789', '012345678']) == 12345678\n    assert candidate(strs = ['a1b', 'b2c', 'c3d', 'd4e', 'e5f', 'f6g', 'g7h', 'h8i', 'i9j', 'j0a', '1a2', '2b3', '3c4', '4d5', '5e6', '6f7', '7g8', '8h9', '9i0', '0j1']) == 3\n    assert candidate(strs = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']) == 1\n    assert candidate(strs = ['123', 'abc', '456', 'def', '789', 'ghi', '12', 'ab', '34', 'cd', '56', 'ef', '78', 'gh', '90', 'ij']) == 789\n    assert candidate(strs = ['abc123', 'def456', '789', 'ghi', '012', 'jklmno789']) == 789\n    assert candidate(strs = ['abcd123', 'efgh456', 'ijkl789', 'mnop000', 'qrst111', 'uvwx222', 'yz333', '444abc', '555def', '666ghi']) == 7\n    assert candidate(strs = ['zzzzz', '99999', 'abcd', '00000', '123456789']) == 123456789\n    assert candidate(strs = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi']) == 9\n    assert candidate(strs = ['zzzz', 'aaaa', '123456789', 'abcdefghi', '000000000', '987654321']) == 987654321\n    assert candidate(strs = ['987654321', 'abcdefghi', '123abc', '0', 'mnopqrstu']) == 987654321\n    assert candidate(strs = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == 30\n    assert candidate(strs = ['999', '888', '777', '666', '555', '444', '333', '222', '111', '000']) == 999\n    assert candidate(strs = ['abc1', 'def2', 'ghi3', '4', '5', '6', '7', '8', '9', '000000000', 'zzzzzzzzz', '111111111', '222222222', '333333333', '444444444', '555555555', '666666666', '777777777', '888888888', '999999999']) == 999999999\n    assert candidate(strs = ['123abc456', 'abc123def', '456def123', 'abcdef', '123456', '654321', 'abcdefg', 'hijklmn', 'opqrstu', '456789', '012345', '6543210', '0000000', '9999999', 'abcdef1', '1abcdef', 'a1b2c3d', 'd3c2b1a', '123456789', '987654321']) == 987654321\n    assert candidate(strs = ['abcd', '1234', 'efgh', '5678', 'ijkl', '9012', 'mnop', '3456', 'qrst', '7890']) == 9012\n    assert candidate(strs = ['abc123', 'def456', 'ghi789', '123456', '123456789']) == 123456789\n    assert candidate(strs = ['zzz', '999', 'zzz999', '999zzz', 'zzz99', '99zzz', 'zz99', '99zz', 'z9', '9z', 'z', '9', '000000', '111111']) == 111111\n    assert candidate(strs = ['123abc', 'abc123', '12345', '54321', 'abcde']) == 54321\n    assert candidate(strs = ['abcdefg', 'hijklmn', 'opqrstu', 'vwxyz01', '2345678', '000000000', '123456789']) == 123456789\n    assert candidate(strs = ['0', '00', '000', '0000', '00000', '000000', '0000000', '00000000', '1', '10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000']) == 100000000\n    assert candidate(strs = ['12345', '1234a', '54321', 'a1b2c3', '000000001']) == 54321\n    assert candidate(strs = ['a1b2c3', '123abc', 'abc123', '007', '0x123', '999999', '123456789', 'abcdefghi']) == 123456789\n    assert candidate(strs = ['abc123', '123abc', 'abc', '123', '000123', '123000']) == 123000\n    assert candidate(strs = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', '11111', '22222', '33333', '44444', '55555']) == 55555\n    assert candidate(strs = ['abcdef', '1', '0000001', '234567', 'ghijklm', '00000', 'nopqr', '00000000', '98765']) == 234567\n    assert candidate(strs = ['xyz', '123', '456', '789', '000', '111', 'abc123', 'def456', 'ghi789']) == 789\n    assert candidate(strs = ['a1b2c3', 'd4e5f6', 'g7h8i9', 'j0k1l2', 'm3n4o5', 'p6q7r8', 's9t0u1', 'v2w3x4', 'y5z6a7', 'b8c9d0']) == 6\n    assert candidate(strs = ['a1b2c3', 'd4e5f6', 'g7h8i9', '01234', '56789', 'abcdefg', 'hijklmn', 'opqrstu', 'vwxyz01', '23456789']) == 23456789\n    assert candidate(strs = ['a1', 'b2', 'c3', 'd4', 'e5', 'f6', 'g7', 'h8', 'i9', '10', '11', '12', '13', '14', '15']) == 15\n    assert candidate(strs = ['zzz', 'yyy', 'xxx', 'www', 'vvv', 'uuu', 'ttt', 'sss', 'rrr', 'qqq', 'ppp', 'ooo', 'nnn', 'mmm', 'lll', 'kkk', 'jjj', 'iii', 'hhh', 'ggg', 'fff', 'eee', 'ddd', 'ccc', 'bbb', 'aaa', '123456789', '987654321']) == 987654321\n    assert candidate(strs = ['a1b2c3', '1a2b3c', 'abc123', '123abc', 'abc', '123', 'a1b2', '1a2b', 'ab12', '12ab', 'a1', '1a', 'a', '1']) == 123\n    assert candidate(strs = ['0', '00', '000', '0000', '00000', '000000', '0000000', '00000000', '000000000']) == 0\n    assert candidate(strs = ['abc', '123', '456', 'def', '789', 'ghi', '012', '345', '678', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz1']) == 789\n    assert candidate(strs = ['abcdef', 'ghijkl', 'mnopqr', '123456', '789012', '321098', 'abcdefg', 'hijklmn', 'opqrstu', '456789', '012345', '654321']) == 789012\n    assert candidate(strs = ['1234', '4321', '1111', '2222', '3333', '0000', '999', '8888', '77777', '666666']) == 666666\n    assert candidate(strs = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '10', '20', '30', '40', '50']) == 50\n    assert candidate(strs = ['a1b2c3', '1a2b3c', 'abc12', '12abc', 'a1b2', '1a2b', 'abc1', '1abc', 'a1', '1a', 'a', '1']) == 6\n    assert candidate(strs = ['zzz', 'zzz9', 'zzz99', '9zzz', '99zzz', '999zz', 'zzz999', 'zzz9999', 'zzz99999']) == 8\n    assert candidate(strs = ['zzzzzzzz', 'aaaaaaaa', '11111111', '22222222', '33333333', '44444444', '55555555', '66666666', '77777777', '88888888', '99999999', '12345678', '87654321', 'abcd1234', '4321dcba']) == 99999999\n    assert candidate(strs = ['1a', '2b', '3c', '4d', '5e', '6f', '7g', '8h', '9i', '0j', '001', '002', '003', '004', '005', '006', '007', '008', '009', '000']) == 9\n    assert candidate(strs = ['abc123', '123abc', 'abc', '123', '000000000', '999999999']) == 999999999\n    assert candidate(strs = ['000000001', '00000002', '00000003', 'abcde', 'fghij', 'klmno', '6789', '987654321', '000000000']) == 987654321\n    assert candidate(strs = ['0000000', '0000001', '0000002', '0000003', '0000004', '0000005', '0000006', '0000007', '0000008', '0000009']) == 9\n    assert candidate(strs = ['a1b2c3', 'd4e5f6', 'g7h8i9', '10', '11', '12', '13', '14', '15']) == 15\n    assert candidate(strs = ['a1b2c3', 'd4e5f6', 'g7h8i9', '00000', '987654321', '111111111']) == 987654321\n    assert candidate(strs = ['00123', '000045', '0000067', '123', '4567', '89012']) == 89012\n", "comparison": "exact"}, "public_tests": ["[\"alic3\",\"bob\",\"3\",\"4\",\"00000\"]", "[\"1\",\"01\",\"001\",\"0001\"]"], "hints": ["For strings comprising only of digits, convert them into integers.", "For all other strings, calculate their length."], "metadata": {"canonical_parameter_names": ["strs"], "leetcode_dataset_entry_point": "Solution().maximumValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:55+00:00", "tests_total": 109, "tests_dropped": 11, "flags": [], "topic_tags": ["array", "string"]}, "language": "python", "interface": {"raw_signature": "def maximumValue(self, strs: list[str]) -> int:", "container": "Solution", "callable": "maximumValue", "parameters": [{"name": "strs", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2497, "task_id": "maximum-star-sum-of-a-graph", "difficulty": "Medium", "problem_description": "There is an undirected graph consisting of n nodes numbered from 0 to n - 1. You are given a 0-indexed integer array vals of length n where vals[i] denotes the value of the i^th node.\n\nYou are also given a 2D integer array edges where edges[i] = [a_i, b_i] denotes that there exists an undirected edge connecting nodes a_i and b_i.\n\nA star graph is a subgraph of the given graph having a center node containing 0 or more neighbors. In other words, it is a subset of edges of the given graph such that there exists a common node for all edges.\n\nThe image below shows star graphs with 3 and 4 neighbors respectively, centered at the blue node.\n\nThe star sum is the sum of the values of all the nodes present in the star graph.\n\nGiven an integer k, return the maximum star sum of a star graph containing at most k edges.\n\nExample 1:\n\nInput: vals = [1,2,3,4,10,-10,-20], edges = [[0,1],[1,2],[1,3],[3,4],[3,5],[3,6]], k = 2\nOutput: 16\nExplanation: The above diagram represents the input graph.\nThe star graph with the maximum star sum is denoted by blue. It is centered at 3 and includes its neighbors 1 and 4.\nIt can be shown it is not possible to get a star graph with a sum greater than 16.\n\nExample 2:\n\nInput: vals = [-5], edges = [], k = 0\nOutput: -5\nExplanation: There is only one possible star graph, which is node 0 itself.\nHence, we return -5.\n\nConstraints:\n\n- n == vals.length\n- 1 <= n <= 10^5\n- -10^4 <= vals[i] <= 10^4\n- 0 <= edges.length <= min(n * (n - 1) / 2, 10^5)\n- edges[i].length == 2\n- 0 <= a_i, b_i <= n - 1\n- a_i != b_i\n- 0 <= k <= n - 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(vals = [5, -2, 3, 1],edges = [[0, 1], [0, 2], [0, 3]],k = 3) == 9\n    assert candidate(vals = [1, 2, 3],edges = [[0, 1], [1, 2]],k = 0) == 3\n    assert candidate(vals = [1, 2, 3, 4, 10, -10, -20],edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [3, 6]],k = 2) == 16\n    assert candidate(vals = [100, 200, 300, 400, 500],edges = [[0, 1], [1, 2], [2, 3], [3, 4]],k = 4) == 1200\n    assert candidate(vals = [-5],edges = [],k = 0) == -5\n    assert candidate(vals = [5, 6, 7, 8, 9],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],k = 3) == 29\n    assert candidate(vals = [1, 2, 3],edges = [[0, 1], [1, 2]],k = 0) == 3\n    assert candidate(vals = [1, 3, -2, 5],edges = [[0, 1], [1, 2], [2, 3]],k = 1) == 5\n    assert candidate(vals = [1, -1, 1, -1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4]],k = 1) == 1\n    assert candidate(vals = [-1, -2, -3, -4, -5],edges = [[0, 1], [1, 2], [2, 3], [3, 4]],k = 2) == -1\n    assert candidate(vals = [1, 2, 3],edges = [[0, 1], [1, 2]],k = 1) == 5\n    assert candidate(vals = [5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3]],k = 3) == 15\n    assert candidate(vals = [100, -200, 300, 400, -500],edges = [[0, 1], [1, 2], [2, 3], [3, 4]],k = 1) == 700\n    assert candidate(vals = [10, -10, 20, -20, 30, -30],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 2) == 30\n    assert candidate(vals = [5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 0]],k = 3) == 15\n    assert candidate(vals = [-10, -20, -30, -40],edges = [[0, 1], [1, 2], [2, 3]],k = 1) == -10\n    assert candidate(vals = [5, 5, 5, 5, 5],edges = [[0, 1], [0, 2], [0, 3], [0, 4]],k = 3) == 20\n    assert candidate(vals = [10, -1, 2, 3, -4],edges = [[0, 1], [0, 2], [0, 3], [0, 4]],k = 2) == 15\n    assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 5) == 3\n    assert candidate(vals = [10, 20, 30, -40, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2]],k = 3) == 110\n    assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 0]],k = 5) == 350\n    assert candidate(vals = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 3) == -1\n    assert candidate(vals = [100, 200, 300, 400, 500, 600],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 2) == 1500\n    assert candidate(vals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]],k = 4) == 0\n    assert candidate(vals = [100, 200, 300, 400, 500],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [2, 3], [3, 4]],k = 4) == 1500\n    assert candidate(vals = [5, -1, 3, 9, 2, -6, 7],edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 6]],k = 3) == 13\n    assert candidate(vals = [100, -50, 20, -10, 5],edges = [[0, 1], [0, 2], [0, 3], [0, 4]],k = 3) == 125\n    assert candidate(vals = [-5, -3, -10, -4, -1],edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 4]],k = 2) == -1\n    assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 5) == 3\n    assert candidate(vals = [-10, 20, -30, 40, -50, 60],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]],k = 4) == 70\n    assert candidate(vals = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2]],k = 3) == 140\n    assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 5) == 270\n    assert candidate(vals = [5, -1, 3, 7, 9, -2],edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 4], [4, 5]],k = 3) == 19\n    assert candidate(vals = [10, 20, 30, 40, 50],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]],k = 2) == 120\n    assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 5) == 6\n    assert candidate(vals = [-10, -20, -30, -40, -50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]],k = 2) == -10\n    assert candidate(vals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],k = 5) == 0\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],k = 7) == 42\n    assert candidate(vals = [5, -3, 8, 0, 2],edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4]],k = 3) == 13\n    assert candidate(vals = [5, 1, 3, 7, 9, 2, 8, 6],edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]],k = 3) == 20\n    assert candidate(vals = [10, 20, 30, 40, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3], [2, 4]],k = 2) == 120\n    assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],k = 5) == 3\n    assert candidate(vals = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 3) == -10\n    assert candidate(vals = [-10, -20, -30, -40, -50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]],k = 4) == -10\n    assert candidate(vals = [5, 15, 25, 35, 45, 55],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]],k = 4) == 135\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],k = 3) == 24\n    assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],k = 2) == 210\n    assert candidate(vals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 2) == 0\n    assert candidate(vals = [10000, -10000, 5000, -5000, 2500, -2500],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 3) == 10000\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 4) == 35\n    assert candidate(vals = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 2], [1, 3], [4, 6], [5, 7], [8, 0], [9, 1], [2, 4], [3, 5], [6, 8], [7, 9]],k = 3) == 12\n    assert candidate(vals = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 3) == 2700\n    assert candidate(vals = [100, -50, 20, -30, 60, 10],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 4], [3, 5]],k = 3) == 180\n    assert candidate(vals = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],k = 3) == -10\n    assert candidate(vals = [5, -5, 15, -15, 25, -25],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]],k = 4) == 25\n    assert candidate(vals = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000, 6000, -6000, 7000, -7000, 8000, -8000, 9000, -9000, 10000, -10000],edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [12, 14], [13, 15], [16, 18], [17, 19]],k = 4) == 19000\n    assert candidate(vals = [100, 200, 300, 400, 500, 600, 700, 800, 900],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],k = 5) == 2400\n    assert candidate(vals = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 9) == 50\n    assert candidate(vals = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],edges = [],k = 3) == -1\n    assert candidate(vals = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 5) == 50\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 5) == 41\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [4, 9]],k = 4) == 21\n    assert candidate(vals = [-10, 20, 30, -40, 50, -60],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]],k = 4) == 50\n    assert candidate(vals = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [4, 5]],k = 3) == 130\n    assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [],k = 4) == 100\n    assert candidate(vals = [100, -100, 200, -200, 300, -300],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 3], [1, 4], [2, 5]],k = 4) == 500\n    assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],k = 10) == 3\n    assert candidate(vals = [1, -1, 1, -1, 1, -1, 1, -1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0]],k = 3) == 2\n    assert candidate(vals = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000],edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]],k = 1) == 5000\n    assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]],k = 2) == 270\n    assert candidate(vals = [-10, -20, -30, -40, -50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [1, 3], [2, 4]],k = 3) == -10\n    assert candidate(vals = [5, -1, 2, 4, 6, -3],edges = [[0, 1], [0, 2], [0, 3], [1, 2], [2, 3], [3, 4], [4, 5]],k = 3) == 17\n    assert candidate(vals = [100, 200, 300, 400, 500],edges = [[0, 1], [1, 2], [2, 3], [3, 4]],k = 0) == 500\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],k = 0) == 10\n    assert candidate(vals = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 0], [9, 1]],k = 4) == 12\n    assert candidate(vals = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 3) == -1\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]],k = 7) == 42\n    assert candidate(vals = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],k = 6) == 24\n    assert candidate(vals = [-10, -20, -30, -40, -50, -60],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 0) == -10\n    assert candidate(vals = [10000, -10000, 5000, -5000, 2500, -2500, 1250, -1250, 625, -625],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 4) == 10000\n    assert candidate(vals = [-1000, -2000, -3000, -4000, -5000],edges = [[0, 1], [1, 2], [2, 3], [3, 4]],k = 3) == -1000\n    assert candidate(vals = [-10, 20, 30, -40, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 2], [1, 3]],k = 2) == 50\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 9]],k = 2) == 21\n    assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 3) == 270\n    assert candidate(vals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 5) == 0\n    assert candidate(vals = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]],k = 4) == 25\n    assert candidate(vals = [10, 20, 30, 40, 50],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3]],k = 3) == 140\n    assert candidate(vals = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]],k = 5) == 12\n    assert candidate(vals = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 4) == 5\n    assert candidate(vals = [10, -10, 20, -20, 30, -30, 40, -40],edges = [[0, 1], [2, 3], [4, 5], [6, 7], [0, 2], [1, 3], [4, 6], [5, 7]],k = 2) == 70\n    assert candidate(vals = [10, -5, 20, 0, 15],edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4]],k = 3) == 35\n    assert candidate(vals = [50, 30, 10, -10, -30, -50, -70, 90, 110],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [1, 3], [2, 4], [5, 7]],k = 6) == 250\n    assert candidate(vals = [5, 15, 25, 35, 45, 55, 65],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 6], [0, 3], [1, 4], [2, 5]],k = 5) == 190\n    assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 7], [7, 8], [8, 9]],k = 5) == 320\n    assert candidate(vals = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],edges = [],k = 2) == -1\n    assert candidate(vals = [5, 10, 15, 20, 25, 30],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]],k = 2) == 75\n    assert candidate(vals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 3) == 0\n    assert candidate(vals = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [],k = 5) == 10\n    assert candidate(vals = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 5) == 5000\n    assert candidate(vals = [-10000, 10000, -9000, 9000, -8000, 8000, -7000, 7000, -6000, 6000],edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],k = 2) == 10000\n    assert candidate(vals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],k = 5) == 310\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,10,-10,-20]\n[[0,1],[1,2],[1,3],[3,4],[3,5],[3,6]]\n2", "[-5]\n[]\n0"], "hints": ["A star graph doesn’t necessarily include all of its neighbors.", "For each node, sort its neighbors in descending order and take k max valued neighbors."], "metadata": {"canonical_parameter_names": ["vals", "edges", "k"], "leetcode_dataset_entry_point": "Solution().maxStarSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:54:58+00:00", "tests_total": 107, "tests_dropped": 6, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "greedy", "graph", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def maxStarSum(self, vals: list[int], edges: list[list[int]], k: int) -> int:", "container": "Solution", "callable": "maxStarSum", "parameters": [{"name": "vals", "type": "list[int]"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2498, "task_id": "frog-jump-ii", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array stones sorted in strictly increasing order representing the positions of stones in a river.\n\nA frog, initially on the first stone, wants to travel to the last stone and then return to the first stone. However, it can jump to any stone at most once.\n\nThe length of a jump is the absolute difference between the position of the stone the frog is currently on and the position of the stone to which the frog jumps.\n\n- More formally, if the frog is at stones[i] and is jumping to stones[j], the length of the jump is |stones[i] - stones[j]|.\n\nThe cost of a path is the maximum length of a jump among all jumps in the path.\n\nReturn the minimum cost of a path for the frog.\n\nExample 1:\n\nInput: stones = [0,2,5,6,7]\nOutput: 5\nExplanation: The above figure represents one of the optimal paths the frog can take.\nThe cost of this path is 5, which is the maximum length of a jump.\nSince it is not possible to achieve a cost of less than 5, we return it.\n\nExample 2:\n\nInput: stones = [0,3,9]\nOutput: 9\nExplanation:\nThe frog can jump directly to the last stone and come back to the first stone.\nIn this case, the length of each jump will be 9. The cost for the path will be max(9, 9) = 9.\nIt can be shown that this is the minimum achievable cost.\n\nConstraints:\n\n- 2 <= stones.length <= 10^5\n- 0 <= stones[i] <= 10^9\n- stones[0] == 0\n- stones is sorted in a strictly increasing order.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(stones = [0, 10, 15, 20, 25]) == 15\n    assert candidate(stones = [0, 1, 2, 3, 4, 5]) == 2\n    assert candidate(stones = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n    assert candidate(stones = [0, 2, 5, 6, 7]) == 5\n    assert candidate(stones = [0, 1, 3, 6, 10, 15]) == 9\n    assert candidate(stones = [0, 5, 10, 15, 20, 25, 30]) == 10\n    assert candidate(stones = [0, 3, 9]) == 9\n    assert candidate(stones = [0, 10, 15, 25, 30]) == 15\n    assert candidate(stones = [0, 10, 20, 30, 40]) == 20\n    assert candidate(stones = [0, 1, 3, 5, 7, 9]) == 4\n    assert candidate(stones = [0, 1, 3, 5, 10]) == 7\n    assert candidate(stones = [0, 100, 200, 300, 400]) == 200\n    assert candidate(stones = [0, 9, 20, 33, 48, 65, 84, 105, 128, 153, 180, 209, 240, 273, 308, 345, 384, 425, 468, 513, 560, 609, 660, 713, 768, 825]) == 112\n    assert candidate(stones = [0, 5, 14, 27, 44, 65, 90, 121, 158, 201, 250]) == 92\n    assert candidate(stones = [0, 1, 4, 10, 22, 46, 94, 190, 382, 766, 1534, 3070, 6142, 12286]) == 9216\n    assert candidate(stones = [0, 11, 24, 39, 56, 75, 96, 119, 144, 171, 200, 231, 264, 300, 339, 380, 423, 468, 515, 564, 615, 668, 723, 780, 840, 903, 968, 1035, 1104, 1175]) == 140\n    assert candidate(stones = [0, 3, 8, 16, 28, 44, 63, 85, 110, 138, 169, 203, 240, 279, 321]) == 81\n    assert candidate(stones = [0, 1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56, 67, 79, 92, 106, 121, 137, 154, 172, 191, 211, 232, 254, 277, 301, 326, 352, 379]) == 53\n    assert candidate(stones = [0, 100, 250, 450, 700, 1000, 1350, 1750, 2200, 2700]) == 950\n    assert candidate(stones = [0, 10, 25, 45, 70, 100, 140, 185, 240, 305, 380, 470, 575, 695, 830, 980]) == 285\n    assert candidate(stones = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 6144\n    assert candidate(stones = [0, 5, 15, 30, 50, 75, 105, 140, 180, 225]) == 85\n    assert candidate(stones = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383]) == 12288\n    assert candidate(stones = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]) == 17\n    assert candidate(stones = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 6144\n    assert candidate(stones = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420, 462, 506, 552, 600]) == 94\n    assert candidate(stones = [0, 1, 4, 10, 19, 31, 46, 64, 85, 109, 136]) == 51\n    assert candidate(stones = [0, 5, 12, 22, 35, 51, 70, 92, 117, 145, 176, 210, 247, 287, 330]) == 83\n    assert candidate(stones = [0, 2, 4, 7, 11, 16, 22]) == 11\n    assert candidate(stones = [0, 10, 15, 25, 35, 50, 75, 110, 150, 200, 260, 330, 410, 500, 600, 710, 830, 960, 1100, 1250, 1410, 1580, 1760, 1950, 2150, 2360, 2580, 2810, 3050, 3300, 3560, 3830, 4110, 4400, 4700, 5010, 5330, 5660, 6000, 6350, 6710, 7080, 7460, 7850, 8250, 8660, 9080, 9510, 9950, 10400, 10860, 11330, 11810, 12300, 12800, 13310, 13830, 14360, 14900, 15450, 16010, 16580, 17160, 17750, 18350, 18960, 19580, 20210, 20850, 21500, 22160, 22830, 23510, 24200, 24900, 25610, 26330, 27060, 27800, 28550, 29310, 30080, 30860, 31650, 32450, 33260, 34080, 34910, 35750, 36600, 37460, 38330, 39210, 40100, 41000, 41910, 42830, 43760, 44700, 45650, 46610, 47580, 48560, 49550, 50550, 51560, 52580, 53610, 54650, 55700, 56760, 57830, 58910, 60000]) == 2170\n    assert candidate(stones = [0, 1, 5, 14, 29, 50, 81, 122, 173, 234, 305, 386, 477, 578, 689, 810, 941, 1082, 1233, 1394, 1565, 1746, 1937, 2148, 2379, 2620, 2871, 3132, 3403, 3684, 3975, 4276, 4587, 4908, 5239, 5580, 5931, 6292, 6663, 7044, 7435, 7836, 8247, 8668, 9099, 9540, 9991, 10452, 10923, 11404, 11895, 12406, 12937, 13488, 14059, 14640, 15231, 15832, 16443, 17064, 17695, 18336, 18987, 19648, 20320]) == 1333\n    assert candidate(stones = [0, 4, 9, 16, 25, 36, 49, 64, 81, 100]) == 36\n    assert candidate(stones = [0, 3, 9, 18, 30, 45, 63, 84, 108, 135, 165, 198, 234, 273, 315, 360, 408, 459, 513, 570]) == 111\n    assert candidate(stones = [0, 3, 7, 12, 20, 30, 45, 65, 90]) == 45\n    assert candidate(stones = [0, 2, 7, 15, 26, 39, 54, 71, 90, 111, 134, 159]) == 48\n    assert candidate(stones = [0, 3, 8, 15, 24, 35, 48, 63, 80, 99, 120, 143, 168, 195, 224]) == 56\n    assert candidate(stones = [0, 5, 10, 20, 35, 55, 80, 110, 145, 185, 230, 280, 335, 395, 460, 530, 605, 685, 770, 860, 955, 1055, 1160, 1270, 1385, 1505, 1630, 1760, 1895, 2035]) == 275\n    assert candidate(stones = [0, 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000, 1331, 1728, 2197, 2744, 3375, 4096]) == 1352\n    assert candidate(stones = [0, 5, 14, 27, 42, 60, 81, 105]) == 45\n    assert candidate(stones = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500]) == 200\n    assert candidate(stones = [0, 8, 18, 30, 44, 60, 78, 98, 120, 144, 170, 198, 228, 260, 294, 330, 368, 408, 450, 494, 540]) == 90\n    assert candidate(stones = [0, 3, 8, 15, 25, 38, 54, 73]) == 35\n    assert candidate(stones = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380]) == 74\n    assert candidate(stones = [0, 5, 12, 20, 28, 36, 45, 55, 66, 78, 90]) == 24\n    assert candidate(stones = [0, 10, 30, 60, 100, 150, 210, 280, 360, 450, 550, 660, 780, 910, 1050, 1200]) == 290\n    assert candidate(stones = [0, 6, 14, 24, 36, 50, 66, 84, 104, 126, 150, 176, 204, 234, 266, 300, 336]) == 70\n    assert candidate(stones = [0, 2, 5, 9, 14, 20, 27, 35, 44, 54, 65]) == 21\n    assert candidate(stones = [0, 2, 8, 12, 15, 20, 25, 30]) == 10\n    assert candidate(stones = [0, 1, 5, 14, 28, 47, 71, 100, 134, 173, 217, 266, 320, 379, 443, 512, 586, 665, 749, 834, 922, 1015, 1113, 1216]) == 201\n    assert candidate(stones = [0, 2, 5, 8, 13, 21, 28, 35, 40]) == 15\n    assert candidate(stones = [0, 2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90]) == 25\n    assert candidate(stones = [0, 1, 5, 11, 19, 29, 41, 55, 71, 89, 109, 131, 155, 181, 209, 239, 271, 305, 341, 379, 419, 461, 505, 551, 600, 651, 704, 759, 817, 877, 940, 1005, 1072, 1141, 1212, 1285, 1360, 1437, 1516, 1597, 1680, 1765, 1852, 1941, 2032, 2125, 2220, 2317, 2416, 2517, 2620, 2725, 2832, 2941, 3052, 3165, 3280, 3400, 3523, 3648, 3775, 3904, 4035, 4168, 4303, 4440, 4580, 4722, 4867, 5014, 5163, 5314, 5467, 5622, 5779, 5938, 6099, 6262, 6427, 6594, 6763, 6934, 7107, 7282, 7459, 7638, 7819, 8002, 8187, 8374, 8563, 8754, 8947, 9142, 9339, 9538, 9739, 9942]) == 404\n    assert candidate(stones = [0, 3, 7, 13, 21, 31, 43, 57, 73, 91, 111, 133, 157, 183, 211, 241, 273, 307, 343, 381, 421, 463, 507, 553, 601]) == 94\n    assert candidate(stones = [0, 2, 5, 9, 14, 20, 27, 35, 44]) == 17\n    assert candidate(stones = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 19\n    assert candidate(stones = [0, 3, 8, 15, 24, 35, 48, 63, 80, 99, 120, 143, 168, 195, 224, 255, 288, 323, 360, 400]) == 77\n    assert candidate(stones = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156]) == 46\n    assert candidate(stones = [0, 1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56, 67, 79, 92, 106, 121, 137, 154, 172]) == 35\n    assert candidate(stones = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 384\n    assert candidate(stones = [0, 10, 30, 60, 100, 150, 210, 280, 360, 450, 550, 660, 780, 910, 1050]) == 270\n    assert candidate(stones = [0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == 100\n    assert candidate(stones = [0, 5, 15, 30, 50, 75, 105, 140, 180, 225, 275, 330, 390, 455, 525]) == 135\n    assert candidate(stones = [0, 10, 25, 40, 55, 70, 85, 100, 120, 140, 160, 180, 200]) == 40\n    assert candidate(stones = [0, 10, 25, 45, 70, 100, 135, 175, 220, 270, 325]) == 105\n    assert candidate(stones = [0, 5, 11, 18, 26, 35, 45, 56, 68, 81, 95, 110, 126, 143, 161, 180, 200]) == 39\n    assert candidate(stones = [0, 1, 3, 7, 13, 21, 31, 43, 57, 73, 91, 111, 133, 157, 183, 211, 241, 273, 307, 343, 381]) == 74\n    assert candidate(stones = [0, 1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56, 67, 79, 92, 106, 121, 137, 154, 172, 191, 211, 232, 254, 277, 301, 326, 352, 379, 407, 436, 466, 497, 529, 562, 596, 631, 667, 704, 742, 781, 821, 862, 904, 947, 991, 1036, 1082, 1129, 1177, 1226, 1276, 1327, 1379, 1432, 1486, 1541, 1597, 1654, 1712, 1771, 1831, 1892, 1954, 2017, 2081, 2146, 2212, 2279, 2347, 2416, 2486, 2557, 2629, 2702, 2776, 2851, 2927, 3004, 3082, 3161, 3241, 3322, 3404, 3487, 3571, 3656, 3742, 3829, 3917, 4006, 4096, 4187, 4279, 4372, 4466, 4561, 4657, 4754, 4852, 4951, 5051]) == 199\n    assert candidate(stones = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 39\n    assert candidate(stones = [0, 2, 7, 17, 32, 52, 77, 107, 142, 182, 227, 277, 332, 392]) == 115\n    assert candidate(stones = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380]) == 74\n    assert candidate(stones = [0, 2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90, 104]) == 27\n    assert candidate(stones = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]) == 17\n    assert candidate(stones = [0, 1, 5, 14, 29, 49, 74, 104, 139, 179, 218]) == 79\n    assert candidate(stones = [0, 5, 15, 30, 50, 75, 105, 140, 180, 225, 275, 330, 390]) == 115\n    assert candidate(stones = [0, 1, 4, 10, 20, 35, 56, 84, 120, 165, 220, 286, 364, 455, 560, 680, 816, 969, 1140, 1330]) == 361\n    assert candidate(stones = [0, 7, 16, 27, 40, 55, 72, 91, 112, 135, 160, 187, 216, 247, 280, 315, 352, 391, 432, 475]) == 84\n    assert candidate(stones = [0, 10, 21, 33, 46, 60, 75, 91, 108, 126, 145, 165, 186, 208, 231, 255, 280, 306, 333, 361, 390, 420, 451, 483, 516]) == 65\n    assert candidate(stones = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528]) == 63\n    assert candidate(stones = [0, 1, 4, 10, 19, 31, 46, 64, 85, 109, 136, 166, 200]) == 64\n    assert candidate(stones = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 76\n    assert candidate(stones = [0, 1, 4, 10, 15, 23, 30, 35]) == 15\n    assert candidate(stones = [0, 1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56, 67, 79, 92, 106, 121, 137, 154, 172, 191, 211, 232, 254, 277, 301, 326, 352, 379, 407, 436, 466, 497, 529, 562, 596, 631, 667, 704, 742, 781, 821, 862, 904, 947, 991]) == 87\n    assert candidate(stones = [0, 10, 25, 45, 70, 100, 135, 175, 220, 270]) == 95\n    assert candidate(stones = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 6\n    assert candidate(stones = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420, 462, 506, 552, 600]) == 94\n    assert candidate(stones = [0, 3, 7, 14, 22, 31, 40, 50, 60, 70]) == 20\n    assert candidate(stones = [0, 1, 4, 8, 15, 23, 36, 55, 89, 144]) == 89\n    assert candidate(stones = [0, 5, 13, 24, 37, 52, 69, 88, 109, 132, 157, 184, 213, 244, 277, 312, 349, 388, 429]) == 80\n    assert candidate(stones = [0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368]) == 28657\n    assert candidate(stones = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420]) == 78\n    assert candidate(stones = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190]) == 37\n    assert candidate(stones = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024]) == 124\n    assert candidate(stones = [0, 2, 6, 14, 25, 40, 58, 79, 103, 130, 160, 193, 230, 270, 315]) == 85\n    assert candidate(stones = [0, 1, 4, 9, 16, 25, 36, 49, 64]) == 28\n    assert candidate(stones = [0, 2, 5, 7, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 10\n    assert candidate(stones = [0, 1, 3, 6, 10, 15, 21, 28]) == 13\n    assert candidate(stones = [0, 1, 5, 14, 29, 49, 74, 104, 139, 179, 218, 258, 300, 344, 391, 441, 494, 550, 610, 674, 742, 815, 893, 976]) == 161\n    assert candidate(stones = [0, 5, 15, 30, 50, 75, 105, 140, 180]) == 75\n    assert candidate(stones = [0, 2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90, 104, 119, 135, 152, 170, 189, 209, 230, 252, 275, 299, 324, 350, 377, 405, 434, 464, 495]) == 61\n    assert candidate(stones = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144]) == 44\n    assert candidate(stones = [0, 5, 11, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 20\n    assert candidate(stones = [0, 3, 8, 14, 21, 29, 38, 48, 59, 71, 84, 98]) == 27\n    assert candidate(stones = [0, 10, 22, 36, 52, 70, 90, 112, 136, 162, 190, 220, 252, 286]) == 66\n", "comparison": "exact"}, "public_tests": ["[0,2,5,6,7]", "[0,3,9]"], "hints": ["One of the optimal strategies will be to jump to every stone.", "Skipping just one stone in every forward jump and jumping to those skipped stones in backward jump can minimize the maximum jump."], "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().maxJump", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:00+00:00", "tests_total": 106, "tests_dropped": 3, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maxJump(self, stones: list[int]) -> int:", "container": "Solution", "callable": "maxJump", "parameters": [{"name": "stones", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2499, "task_id": "minimum-total-cost-to-make-arrays-unequal", "difficulty": "Hard", "problem_description": "You are given two 0-indexed integer arrays nums1 and nums2, of equal length n.\n\nIn one operation, you can swap the values of any two indices of nums1. The cost of this operation is the sum of the indices.\n\nFind the minimum total cost of performing the given operation any number of times such that nums1[i] != nums2[i] for all 0 <= i <= n - 1 after performing all the operations.\n\nReturn the minimum total cost such that nums1 and nums2 satisfy the above condition. In case it is not possible, return -1.\n\nExample 1:\n\nInput: nums1 = [1,2,3,4,5], nums2 = [1,2,3,4,5]\nOutput: 10\nExplanation:\nOne of the ways we can perform the operations is:\n- Swap values at indices 0 and 3, incurring cost = 0 + 3 = 3. Now, nums1 = [4,2,3,1,5]\n- Swap values at indices 1 and 2, incurring cost = 1 + 2 = 3. Now, nums1 = [4,3,2,1,5].\n- Swap values at indices 0 and 4, incurring cost = 0 + 4 = 4. Now, nums1 =[5,3,2,1,4].\nWe can see that for each index i, nums1[i] != nums2[i]. The cost required here is 10.\nNote that there are other ways to swap values, but it can be proven that it is not possible to obtain a cost less than 10.\n\nExample 2:\n\nInput: nums1 = [2,2,2,1,3], nums2 = [1,2,2,3,3]\nOutput: 10\nExplanation:\nOne of the ways we can perform the operations is:\n- Swap values at indices 2 and 3, incurring cost = 2 + 3 = 5. Now, nums1 = [2,2,1,2,3].\n- Swap values at indices 1 and 4, incurring cost = 1 + 4 = 5. Now, nums1 = [2,3,1,2,2].\nThe total cost needed here is 10, which is the minimum possible.\n\nExample 3:\n\nInput: nums1 = [1,2,2], nums2 = [1,2,2]\nOutput: -1\nExplanation:\nIt can be shown that it is not possible to satisfy the given conditions irrespective of the number of operations we perform.\nHence, we return -1.\n\nConstraints:\n\n- n == nums1.length == nums2.length\n- 1 <= n <= 10^5\n- 1 <= nums1[i], nums2[i] <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums1 = [1, 2, 2],nums2 = [1, 2, 2]) == -1\n    assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2]) == 0\n    assert candidate(nums1 = [1, 2],nums2 = [2, 1]) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 2, 3, 4, 5]) == -1\n    assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == -1\n    assert candidate(nums1 = [1, 1, 1, 2, 2, 2],nums2 = [1, 1, 1, 2, 2, 2]) == 15\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [1, 1, 2, 2, 3, 3]) == 15\n    assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1]) == 1\n    assert candidate(nums1 = [1, 1, 1, 1],nums2 = [2, 2, 2, 2]) == 0\n    assert candidate(nums1 = [5, 1, 3, 2, 4],nums2 = [4, 2, 1, 3, 5]) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 2\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n    assert candidate(nums1 = [5, 3, 2, 4, 1],nums2 = [5, 4, 1, 3, 2]) == 1\n    assert candidate(nums1 = [1, 1, 2, 2],nums2 = [2, 2, 1, 1]) == 0\n    assert candidate(nums1 = [1, 1, 2, 2, 3],nums2 = [1, 1, 2, 2, 3]) == 10\n    assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5]) == 10\n    assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 2\n    assert candidate(nums1 = [1, 2, 3],nums2 = [3, 1, 2]) == 0\n    assert candidate(nums1 = [5, 3, 3, 2, 1],nums2 = [5, 4, 4, 1, 2]) == 1\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums1 = [1],nums2 = [1]) == -1\n    assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1]) == -1\n    assert candidate(nums1 = [2, 2, 2, 1, 3],nums2 = [1, 2, 2, 3, 3]) == 10\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [1, 2, 1, 2, 3, 4, 3, 4, 5, 6]) == 22\n    assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n    assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums2 = [2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 10]) == 18\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n    assert candidate(nums1 = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3],nums2 = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 19\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n    assert candidate(nums1 = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4],nums2 = [1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6]) == 15\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n    assert candidate(nums1 = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],nums2 = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 9]) == 36\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 105\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 105\n    assert candidate(nums1 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3]) == 44\n    assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3],nums2 = [2, 2, 2, 1, 1, 1, 3, 3, 3]) == 24\n    assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],nums2 = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5]) == 40\n    assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 4, 4]) == 41\n    assert candidate(nums1 = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n    assert candidate(nums1 = [2, 3, 4, 5, 6, 1],nums2 = [6, 1, 2, 3, 4, 5]) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 1, 9]) == 28\n    assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],nums2 = [2, 3, 3, 4, 4, 5, 5, 6, 6, 7]) == 0\n    assert candidate(nums1 = [1, 3, 2, 5, 4, 6, 7, 8, 9, 10],nums2 = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == 35\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 105\n    assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 101\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 0\n    assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n    assert candidate(nums1 = [5, 1, 3, 2, 4, 6, 7, 8, 9, 10],nums2 = [10, 5, 4, 3, 2, 1, 8, 7, 6, 9]) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n    assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 2]) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == 0\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6]) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 9\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n    assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4],nums2 = [1, 3, 3, 2, 2, 5, 5]) == 1\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n    assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],nums2 = [6, 2, 1, 3, 3, 4, 4, 5, 5, 1]) == 34\n    assert candidate(nums1 = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n    assert candidate(nums1 = [7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7]) == 3\n    assert candidate(nums1 = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 9\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [1, 2, 1, 2, 3, 4, 3, 4, 5, 6]) == 22\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 45\n    assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n    assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],nums2 = [6, 2, 2, 6, 6, 2, 2, 6, 6, 2, 2]) == 6\n    assert candidate(nums1 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 66\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 10\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n    assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == -1\n    assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n    assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],nums2 = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 12\n    assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4],nums2 = [4, 4, 4, 3, 3, 3, 2, 2, 2, 1]) == 0\n    assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 20\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 10\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [2, 2, 1, 1, 4, 4, 3, 3, 5, 5]) == 18\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 0\n    assert candidate(nums1 = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 42\n    assert candidate(nums1 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == -1\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == -1\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],nums2 = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3],nums2 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3]) == 45\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 190\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 45\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9]) == 28\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 0\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n    assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],nums2 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == 45\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 9\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == -1\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 36\n    assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n    assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 0\n    assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n    assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n    assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == 90\n    assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5]\n[1,2,3,4,5]", "[2,2,2,1,3]\n[1,2,2,3,3]", "[1,2,2]\n[1,2,2]"], "hints": ["How can we check which indices of nums1 will be considered for swapping? How to minimize the number of such operations?", "It can be seen that greedily swapping values of indices where nums1[i] == nums2[i] is the most optimal choice. How many values cannot be swapped this way?", "Find which indices we will swap these remaining values with, and if there are enough such indices."], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minimumTotalCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:03+00:00", "tests_total": 118, "tests_dropped": 12, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "counting"]}, "language": "python", "interface": {"raw_signature": "def minimumTotalCost(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "minimumTotalCost", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2500, "task_id": "delete-greatest-value-in-each-row", "difficulty": "Easy", "problem_description": "You are given an m x n matrix grid consisting of positive integers.\n\nPerform the following operation until grid becomes empty:\n\n- Delete the element with the greatest value from each row. If multiple such elements exist, delete any of them.\n- Add the maximum of deleted elements to the answer.\n\nNote that the number of columns decreases by one after each operation.\n\nReturn the answer after performing the operations described above.\n\nExample 1:\n\nInput: grid = [[1,2,4],[3,3,1]]\nOutput: 8\nExplanation: The diagram above shows the removed values in each step.\n- In the first operation, we remove 4 from the first row and 3 from the second row (notice that, there are two cells with value 3 and we can remove any of them). We add 4 to the answer.\n- In the second operation, we remove 2 from the first row and 3 from the second row. We add 3 to the answer.\n- In the third operation, we remove 1 from the first row and 1 from the second row. We add 1 to the answer.\nThe final answer = 4 + 3 + 1 = 8.\n\nExample 2:\n\nInput: grid = [[10]]\nOutput: 10\nExplanation: The diagram above shows the removed values in each step.\n- In the first operation, we remove 10 from the first row. We add 10 to the answer.\nThe final answer = 10.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 50\n- 1 <= grid[i][j] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 3\n    assert candidate(grid = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == 24\n    assert candidate(grid = [[5, 1, 3], [4, 2, 6], [7, 8, 9]]) == 24\n    assert candidate(grid = [[5, 1, 3], [9, 3, 5], [7, 6, 2]]) == 18\n    assert candidate(grid = [[10]]) == 10\n    assert candidate(grid = [[1, 2, 4], [3, 3, 1]]) == 8\n    assert candidate(grid = [[5, 3], [9, 7], [2, 6]]) == 16\n    assert candidate(grid = [[1, 3, 5, 7], [2, 4, 6, 8]]) == 20\n    assert candidate(grid = [[5, 3], [9, 7]]) == 16\n    assert candidate(grid = [[1, 3, 5, 7], [10, 8, 6, 4]]) == 28\n    assert candidate(grid = [[1, 2], [3, 4], [5, 6]]) == 11\n    assert candidate(grid = [[2, 2, 2], [2, 2, 2], [2, 2, 2]]) == 6\n    assert candidate(grid = [[100, 100], [100, 100], [100, 100]]) == 200\n    assert candidate(grid = [[1, 3, 5], [2, 4, 6], [3, 6, 9], [4, 8, 12]]) == 24\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]]) == 51\n    assert candidate(grid = [[50, 49, 48, 47], [46, 45, 44, 43], [42, 41, 40, 39], [38, 37, 36, 35]]) == 194\n    assert candidate(grid = [[45, 23, 67, 89, 12], [90, 34, 56, 78, 10], [11, 13, 15, 17, 19], [21, 22, 24, 25, 26]]) == 279\n    assert candidate(grid = [[4, 8, 12, 16, 20], [3, 7, 11, 15, 19], [2, 6, 10, 14, 18], [1, 5, 9, 13, 17]]) == 60\n    assert candidate(grid = [[23, 34, 45, 56], [12, 23, 34, 45], [56, 67, 78, 89], [90, 10, 20, 30]]) == 291\n    assert candidate(grid = [[7, 8, 9], [4, 5, 6], [1, 2, 3], [7, 8, 9], [4, 5, 6], [1, 2, 3]]) == 24\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 4, 6, 8, 10, 1, 3, 5, 7, 9], [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]]) == 165\n    assert candidate(grid = [[1, 3, 5, 7, 9], [10, 8, 6, 4, 2], [11, 13, 15, 17, 19], [20, 18, 16, 14, 12]]) == 80\n    assert candidate(grid = [[50, 45, 40], [35, 30, 25], [20, 15, 10], [5, 10, 15], [20, 25, 30]]) == 135\n    assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [60, 70, 80, 90, 100], [100, 90, 80, 70, 60]]) == 400\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 55\n    assert candidate(grid = [[100, 99, 98, 97, 96], [95, 94, 93, 92, 91], [90, 89, 88, 87, 86]]) == 490\n    assert candidate(grid = [[24, 17, 56, 38, 45], [89, 21, 37, 62, 11], [48, 93, 71, 19, 81], [25, 76, 53, 90, 32]]) == 318\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 6, 2, 5, 3, 4]]) == 21\n    assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [25, 75, 25, 75, 25], [75, 25, 75, 25, 75]]) == 275\n    assert candidate(grid = [[4, 2, 9, 1], [8, 5, 6, 7], [3, 11, 12, 10]]) == 38\n    assert candidate(grid = [[20, 5, 15], [10, 10, 30], [40, 25, 5]]) == 75\n    assert candidate(grid = [[23, 54, 76], [34, 56, 23], [89, 12, 45], [56, 78, 90]]) == 224\n    assert candidate(grid = [[45, 12, 67, 34], [89, 23, 56, 78], [90, 45, 34, 12], [78, 90, 45, 67]]) == 280\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 42\n    assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 5, 2, 4, 3], [3, 4, 5, 1, 2]]) == 15\n    assert candidate(grid = [[100, 90, 80], [70, 60, 50], [40, 30, 20], [10, 5, 1]]) == 270\n    assert candidate(grid = [[7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7], [2, 1, 3, 4, 6, 5, 7], [3, 4, 5, 6, 7, 1, 2]]) == 28\n    assert candidate(grid = [[3, 3, 3, 3, 3, 3], [2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1], [6, 6, 6, 6, 6, 6]]) == 36\n    assert candidate(grid = [[9, 7, 5, 3], [8, 6, 4, 2], [7, 5, 3, 1]]) == 24\n    assert candidate(grid = [[45, 55, 65], [35, 45, 55], [25, 35, 45], [15, 25, 35]]) == 165\n    assert candidate(grid = [[4, 1, 7], [8, 2, 6], [3, 9, 5], [5, 3, 8]]) == 18\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 65\n    assert candidate(grid = [[23, 34, 45, 56], [56, 45, 34, 23], [23, 45, 56, 34], [34, 56, 23, 45]]) == 158\n    assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [10, 8, 6, 4, 2], [9, 7, 5, 3, 1]]) == 30\n    assert candidate(grid = [[1, 5, 3], [2, 8, 7], [4, 6, 9], [11, 13, 12]]) == 36\n    assert candidate(grid = [[15, 25, 35, 45, 55, 65, 75, 85, 95], [95, 85, 75, 65, 55, 45, 35, 25, 15], [10, 20, 30, 40, 50, 60, 70, 80, 90]]) == 495\n    assert candidate(grid = [[1, 100, 1], [100, 1, 100], [1, 100, 1], [100, 1, 100]]) == 201\n    assert candidate(grid = [[50, 49, 48], [47, 46, 45], [44, 43, 42], [41, 40, 39]]) == 147\n    assert candidate(grid = [[3, 1, 2], [6, 5, 4], [9, 8, 7], [12, 11, 10]]) == 33\n    assert candidate(grid = [[50, 40, 30], [40, 30, 20], [30, 20, 10], [20, 10, 5]]) == 120\n    assert candidate(grid = [[10], [20], [30], [40], [50], [60]]) == 60\n    assert candidate(grid = [[42, 24, 36, 18, 72], [54, 12, 60, 84, 30], [90, 45, 15, 75, 60]]) == 288\n    assert candidate(grid = [[100, 99, 98, 97], [96, 95, 94, 93], [92, 91, 90, 89], [88, 87, 86, 85]]) == 394\n    assert candidate(grid = [[100, 90, 80], [70, 60, 50], [40, 30, 20], [10, 20, 30]]) == 270\n    assert candidate(grid = [[9, 1, 5, 3], [4, 8, 2, 7], [6, 10, 1, 12]]) == 30\n    assert candidate(grid = [[25, 15, 35, 5], [10, 45, 55, 20], [50, 30, 60, 40]]) == 180\n    assert candidate(grid = [[100, 99, 98, 97, 96], [95, 94, 93, 92, 91], [90, 89, 88, 87, 86]]) == 490\n    assert candidate(grid = [[99, 98, 97, 96], [95, 94, 93, 92], [91, 90, 89, 88]]) == 390\n    assert candidate(grid = [[10, 20, 30], [15, 25, 35], [20, 30, 40], [25, 35, 45]]) == 105\n    assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [10, 9, 8, 7, 6]]) == 40\n    assert candidate(grid = [[1, 99, 2, 98], [3, 97, 4, 96], [5, 95, 6, 94], [7, 93, 8, 92]]) == 212\n    assert candidate(grid = [[100, 99, 98], [97, 96, 95], [94, 93, 92], [91, 90, 89]]) == 297\n    assert candidate(grid = [[5, 1, 9, 2], [8, 6, 3, 7], [4, 10, 1, 11]]) == 30\n    assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 45\n    assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 39\n    assert candidate(grid = [[100, 50, 25, 10], [90, 60, 40, 30], [80, 70, 35, 15], [75, 65, 55, 45]]) == 270\n    assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [60, 70, 80, 90, 100]]) == 400\n    assert candidate(grid = [[9, 5, 1, 7], [8, 4, 2, 6], [3, 11, 10, 12]]) == 36\n    assert candidate(grid = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6]]) == 11\n    assert candidate(grid = [[47, 83, 29], [91, 7, 36], [42, 54, 67], [22, 88, 15]]) == 187\n    assert candidate(grid = [[99, 98, 97], [96, 95, 94], [93, 92, 91], [90, 89, 88], [87, 86, 85]]) == 294\n    assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [5, 1, 2, 3, 4]]) == 15\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]]) == 55\n    assert candidate(grid = [[100, 1, 2, 3], [3, 2, 1, 100], [100, 100, 1, 1], [1, 100, 100, 100]]) == 301\n    assert candidate(grid = [[7, 5, 3, 1], [8, 6, 4, 2], [9, 7, 5, 3], [10, 8, 6, 4]]) == 28\n    assert candidate(grid = [[15, 20, 25, 30], [10, 15, 20, 25], [5, 10, 15, 20], [1, 5, 10, 15]]) == 90\n    assert candidate(grid = [[7, 3, 5, 9], [1, 4, 8, 2], [6, 10, 12, 11]]) == 39\n    assert candidate(grid = [[15, 14, 13, 12, 11], [10, 9, 8, 7, 6], [5, 4, 3, 2, 1]]) == 65\n    assert candidate(grid = [[100, 1, 2, 3, 4], [99, 5, 6, 7, 8], [98, 9, 10, 11, 12], [97, 13, 14, 15, 16]]) == 158\n    assert candidate(grid = [[42, 23, 65, 12, 34], [56, 78, 90, 23, 45], [89, 12, 34, 56, 78]]) == 292\n    assert candidate(grid = [[10, 15, 5, 20], [12, 18, 8, 6], [7, 11, 13, 19]]) == 53\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [7, 8, 9, 10, 11, 12], [12, 11, 10, 9, 8, 7]]) == 57\n    assert candidate(grid = [[42, 42, 42, 42], [42, 42, 42, 42], [42, 42, 42, 42], [42, 42, 42, 42]]) == 168\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 3, 5, 2, 4, 6], [6, 4, 2, 5, 3, 1]]) == 21\n    assert candidate(grid = [[100, 1, 2, 3], [4, 100, 5, 6], [7, 8, 100, 9], [10, 11, 12, 100]]) == 133\n    assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 30, 50, 20, 40], [20, 40, 10, 50, 30]]) == 150\n    assert candidate(grid = [[33, 54, 21, 45], [11, 99, 32, 16], [82, 76, 41, 53], [65, 29, 37, 44]]) == 269\n", "comparison": "exact"}, "public_tests": ["[[1,2,4],[3,3,1]]", "[[10]]"], "hints": ["Iterate from the first to the last row and if there exist some unmarked cells, take a maximum from them and mark that cell as visited.", "Add a maximum of newly marked cells to answer and repeat that operation until the whole matrix becomes marked."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().deleteGreatestValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:05+00:00", "tests_total": 93, "tests_dropped": 6, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "sorting", "heap-priority-queue", "matrix", "simulation"]}, "language": "python", "interface": {"raw_signature": "def deleteGreatestValue(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "deleteGreatestValue", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2501, "task_id": "longest-square-streak-in-an-array", "difficulty": "Medium", "problem_description": "You are given an integer array nums. A subsequence of nums is called a square streak if:\n\n- The length of the subsequence is at least 2, and\n- after sorting the subsequence, each element (except the first element) is the square of the previous number.\n\nReturn the length of the longest square streak in nums, or return -1 if there is no square streak.\n\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n\nExample 1:\n\nInput: nums = [4,3,6,16,8,2]\nOutput: 3\nExplanation: Choose the subsequence [4,16,2]. After sorting it, it becomes [2,4,16].\n- 4 = 2 * 2.\n- 16 = 4 * 4.\nTherefore, [4,16,2] is a square streak.\nIt can be shown that every subsequence of length 4 is not a square streak.\n\nExample 2:\n\nInput: nums = [2,3,5,6,7]\nOutput: -1\nExplanation: There is no square streak in nums so return -1.\n\nConstraints:\n\n- 2 <= nums.length <= 10^5\n- 2 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(nums = [4, 16, 256, 65536]) == 4\n    assert candidate(nums = [6, 36, 1296, 46656]) == 3\n    assert candidate(nums = [2, 3, 5, 6, 7]) == -1\n    assert candidate(nums = [4, 16, 256, 65536, 2]) == 5\n    assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n    assert candidate(nums = [10, 20, 30, 40, 50]) == -1\n    assert candidate(nums = [2, 4, 16, 256, 65536]) == 5\n    assert candidate(nums = [4, 3, 6, 16, 8, 2]) == 3\n    assert candidate(nums = [1024, 32, 2, 4, 16, 64, 256]) == 4\n    assert candidate(nums = [4, 16, 64, 256, 1024, 4096]) == 3\n    assert candidate(nums = [3, 9, 27, 81, 243, 729]) == 3\n    assert candidate(nums = [2, 8, 16, 256, 65536]) == 3\n    assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 16, 25, 36, 49, 64, 81, 100]) == 3\n    assert candidate(nums = [10, 100, 1000, 10000, 100000]) == 3\n    assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125]) == 3\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]) == -1\n    assert candidate(nums = [2, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2\n    assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 4\n    assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 5\n    assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 4\n    assert candidate(nums = [2, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 3\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == -1\n    assert candidate(nums = [4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024]) == 3\n    assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317]) == -1\n", "comparison": "exact"}, "public_tests": ["[4,3,6,16,8,2]", "[2,3,5,6,7]"], "hints": ["With the constraints, the length of the longest square streak possible is 5.", "Store the elements of nums in a set to quickly check if it exists."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().longestSquareStreak", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:07+00:00", "tests_total": 132, "tests_dropped": 108, "flags": [], "topic_tags": ["array", "hash-table", "binary-search", "dynamic-programming", "sorting"]}, "language": "python", "interface": {"raw_signature": "def longestSquareStreak(self, nums: list[int]) -> int:", "container": "Solution", "callable": "longestSquareStreak", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2503, "task_id": "maximum-number-of-points-from-grid-queries", "difficulty": "Hard", "problem_description": "You are given an m x n integer matrix grid and an array queries of size k.\n\nFind an array answer of size k such that for each integer queries[i] you start in the top left cell of the matrix and repeat the following process:\n\n- If queries[i] is strictly greater than the value of the current cell that you are in, then you get one point if it is your first time visiting this cell, and you can move to any adjacent cell in all 4 directions: up, down, left, and right.\n- Otherwise, you do not get any points, and you end this process.\n\nAfter the process, answer[i] is the maximum number of points you can get. Note that for each query you are allowed to visit the same cell multiple times.\n\nReturn the resulting array answer.\n\nExample 1:\n\nInput: grid = [[1,2,3],[2,5,7],[3,5,1]], queries = [5,6,2]\nOutput: [5,8,1]\nExplanation: The diagrams above show which cells we visit to get points for each query.\n\nExample 2:\n\nInput: grid = [[5,2,1],[1,1,2]], queries = [3]\nOutput: [0]\nExplanation: We can not get any points because the value of the top left cell is already greater than or equal to 3.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 2 <= m, n <= 1000\n- 4 <= m * n <= 10^5\n- k == queries.length\n- 1 <= k <= 10^4\n- 1 <= grid[i][j], queries[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],queries = [2, 3]) == [9, 9]\n    assert candidate(grid = [[1, 2, 3], [2, 5, 7], [3, 5, 1]],queries = [5, 6, 2]) == [5, 8, 1]\n    assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],queries = [1, 2, 3]) == [0, 9, 9]\n    assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],queries = [15, 25, 35, 45, 55, 65, 75, 85, 95]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n    assert candidate(grid = [[3, 3, 3], [3, 3, 3], [3, 3, 3]],queries = [2, 4, 6]) == [0, 9, 9]\n    assert candidate(grid = [[1, 10], [10, 1]],queries = [5, 15]) == [1, 4]\n    assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],queries = [4, 5, 6]) == [0, 0, 9]\n    assert candidate(grid = [[4, 5, 6], [7, 8, 9], [10, 11, 12]],queries = [10, 15, 20]) == [6, 9, 9]\n    assert candidate(grid = [[5, 2, 1], [1, 1, 2]],queries = [3]) == [0]\n    assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],queries = [1, 2, 3]) == [0, 16, 16]\n    assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],queries = [15, 45, 75]) == [1, 4, 7]\n    assert candidate(grid = [[4, 4, 4], [4, 4, 4], [4, 4, 4]],queries = [4]) == [0]\n    assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],queries = [2, 2, 2]) == [12, 12, 12]\n    assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],queries = [15, 35, 65, 95]) == [1, 3, 6, 9]\n    assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],queries = [2]) == [9]\n    assert candidate(grid = [[1000000, 1000000], [1000000, 1000000]],queries = [1000000, 999999]) == [0, 0]\n    assert candidate(grid = [[1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20]],queries = [10, 15, 20]) == [9, 14, 19]\n    assert candidate(grid = [[100000, 1, 100000, 1, 100000], [1, 100000, 1, 100000, 1], [100000, 1, 100000, 1, 100000], [1, 100000, 1, 100000, 1], [100000, 1, 100000, 1, 100000]],queries = [1, 100000, 100001]) == [0, 0, 25]\n    assert candidate(grid = [[1000000, 1000000, 1000000], [1000000, 1, 1000000], [1000000, 1000000, 1000000]],queries = [1000000, 999999]) == [0, 0]\n    assert candidate(grid = [[9, 8, 7, 6], [2, 1, 3, 4], [5, 10, 11, 12], [13, 14, 15, 16]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15]\n    assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2, 1, 9], [7, 6, 5, 4, 3, 2, 1, 9, 8], [6, 5, 4, 3, 2, 1, 9, 8, 7], [5, 4, 3, 2, 1, 9, 8, 7, 6], [4, 3, 2, 1, 9, 8, 7, 6, 5], [3, 2, 1, 9, 8, 7, 6, 5, 4], [2, 1, 9, 8, 7, 6, 5, 4, 3], [1, 9, 8, 7, 6, 5, 4, 3, 2]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90]) == [0, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],queries = [1, 5, 10, 15, 20, 25, 30]) == [0, 4, 9, 14, 19, 24, 29]\n    assert candidate(grid = [[1, 2, 3], [2, 5, 7], [3, 5, 1], [1, 2, 3], [2, 5, 7]],queries = [5, 6, 2, 8, 10]) == [10, 13, 1, 15, 15]\n    assert candidate(grid = [[5, 5, 5, 5], [5, 1, 1, 5], [5, 1, 1, 5], [5, 5, 5, 5]],queries = [1, 2, 3, 4, 5, 6]) == [0, 0, 0, 0, 0, 16]\n    assert candidate(grid = [[1, 3, 1, 3, 1], [3, 1, 3, 1, 3], [1, 3, 1, 3, 1], [3, 1, 3, 1, 3], [1, 3, 1, 3, 1]],queries = [2, 4, 6]) == [1, 25, 25]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [4, 9, 14, 19, 24, 29, 34, 39, 44, 49]\n    assert candidate(grid = [[50, 40, 30, 20, 10], [51, 41, 31, 21, 11], [52, 42, 32, 22, 12], [53, 43, 33, 23, 13], [54, 44, 34, 24, 14]],queries = [25, 35, 45, 55]) == [0, 0, 0, 25]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]],queries = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [14, 24, 34, 44, 50, 50, 50, 50, 50, 50]\n    assert candidate(grid = [[2, 1, 3, 1, 2], [1, 2, 1, 2, 1], [3, 1, 2, 1, 3], [1, 2, 1, 2, 1], [2, 1, 3, 1, 2]],queries = [1, 2, 3, 4]) == [0, 0, 21, 25]\n    assert candidate(grid = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60], [65, 70, 75, 80]],queries = [25, 50, 75, 100]) == [4, 9, 14, 16]\n    assert candidate(grid = [[9, 8, 7], [6, 5, 4], [3, 2, 1]],queries = [5, 10, 15]) == [0, 9, 9]\n    assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]],queries = [1, 5, 10, 15, 20, 25]) == [0, 4, 9, 14, 19, 24]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]],queries = [3, 4, 5, 6]) == [2, 3, 16, 20]\n    assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2], [2, 1, 1, 1, 1, 1, 2], [2, 1, 2, 2, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 2, 2, 1, 2], [2, 1, 1, 1, 1, 1, 2], [2, 2, 2, 2, 2, 2, 2]],queries = [1, 2, 3]) == [0, 0, 49]\n    assert candidate(grid = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 3, 6, 9, 12, 14, 15, 15, 15]\n    assert candidate(grid = [[1, 3, 1, 4, 2], [3, 2, 4, 1, 3], [1, 4, 2, 3, 1], [2, 3, 1, 2, 4]],queries = [5, 3, 6, 2]) == [20, 1, 20, 1]\n    assert candidate(grid = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 3, 6, 9, 12, 15, 18, 21, 24, 27]\n    assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]],queries = [1, 3, 5, 7, 9]) == [0, 3, 10, 19, 24]\n    assert candidate(grid = [[10, 10, 10, 10, 10], [10, 9, 9, 9, 10], [10, 9, 8, 9, 10], [10, 9, 9, 9, 10], [10, 10, 10, 10, 10]],queries = [10, 9, 8, 7]) == [0, 0, 0, 0]\n    assert candidate(grid = [[5, 6, 7, 8], [4, 3, 2, 1], [12, 13, 14, 15], [9, 10, 11, 16]],queries = [3, 5, 7, 9, 11, 13, 15, 17]) == [0, 0, 6, 8, 8, 12, 14, 16]\n    assert candidate(grid = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [6, 16, 26, 36, 46], [11, 21, 31, 41, 51]],queries = [10, 20, 30, 40, 50, 60]) == [0, 8, 13, 18, 23, 25]\n    assert candidate(grid = [[5, 2, 1, 4, 3, 2, 1], [4, 3, 2, 1, 4, 3, 2], [3, 2, 1, 2, 3, 2, 1], [2, 1, 2, 3, 2, 1, 2], [1, 2, 3, 2, 1, 2, 3]],queries = [3, 4, 5, 6]) == [0, 0, 0, 35]\n    assert candidate(grid = [[9, 9, 9, 9, 9], [9, 1, 2, 3, 9], [9, 4, 5, 6, 9], [9, 7, 8, 9, 9], [9, 9, 9, 9, 9]],queries = [1, 5, 10]) == [0, 0, 25]\n    assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50]],queries = [25, 35, 45, 55]) == [2, 15, 20, 25]\n    assert candidate(grid = [[7, 7, 7, 7, 7], [7, 7, 7, 7, 7], [7, 7, 7, 7, 7], [7, 7, 7, 7, 7], [7, 7, 7, 7, 7]],queries = [6, 7, 8]) == [0, 0, 25]\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]],queries = [1, 2, 3, 4]) == [0, 16, 24, 25]\n    assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [25, 24, 22, 19, 15, 10, 6, 3, 1, 0]\n    assert candidate(grid = [[7, 7, 7, 7], [7, 7, 7, 7], [7, 7, 7, 7], [7, 7, 7, 7]],queries = [5, 6, 8]) == [0, 0, 16]\n    assert candidate(grid = [[9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2], [5, 4, 3, 2, 1]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [25, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n    assert candidate(grid = [[1, 1, 1], [1, 10, 1], [1, 1, 1]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 5, 4, 3, 1], [1, 2, 3, 4, 5, 6, 7, 6, 3, 1], [1, 2, 3, 4, 5, 6, 7, 8, 3, 1], [1, 2, 3, 4, 5, 6, 7, 6, 5, 1], [1, 2, 3, 4, 3, 2, 3, 4, 5, 1]],queries = [2, 3, 5, 7, 8, 10]) == [28, 47, 81, 96, 99, 100]\n    assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [2, 3, 4, 5, 1], [6, 7, 8, 9, 10]],queries = [1, 3, 5, 7, 9, 11]) == [0, 2, 4, 12, 16, 20]\n    assert candidate(grid = [[2, 3, 2], [3, 2, 3], [2, 3, 2], [3, 2, 3], [2, 3, 2]],queries = [2, 3, 4, 5, 6, 7]) == [0, 1, 15, 15, 15, 15]\n    assert candidate(grid = [[3, 3, 3, 3], [3, 1, 1, 3], [3, 1, 1, 3], [3, 3, 3, 3]],queries = [1, 2, 4, 5]) == [0, 0, 16, 16]\n    assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]],queries = [10, 5, 1, 15]) == [25, 10, 0, 25]\n    assert candidate(grid = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]],queries = [1, 2, 3, 4, 5, 6, 7, 8]) == [0, 1, 3, 6, 9, 12, 14, 15]\n    assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],queries = [10, 15, 20]) == [9, 14, 15]\n    assert candidate(grid = [[1000000, 999999], [999998, 1000000], [999997, 999996]],queries = [1000000, 999999, 999998, 999997]) == [0, 0, 0, 0]\n    assert candidate(grid = [[5, 4, 3, 2, 1], [6, 5, 4, 3, 2], [7, 6, 5, 4, 3], [8, 7, 6, 5, 4], [9, 8, 7, 6, 5]],queries = [5, 10, 15, 20]) == [0, 25, 25, 25]\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],queries = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [25, 0, 25, 0, 25, 0, 25, 0, 25, 0, 25, 0, 25, 0, 25, 0]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],queries = [1, 2, 3]) == [0, 30, 30]\n    assert candidate(grid = [[5, 1, 2, 3, 4], [4, 5, 6, 7, 8], [3, 4, 5, 6, 7], [2, 3, 4, 5, 6], [1, 2, 3, 4, 5]],queries = [6, 5, 4, 3, 2, 1]) == [19, 0, 0, 0, 0, 0]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 1], [1, 2, 3, 4, 5, 5, 5, 5, 5, 4, 3, 2, 1, 1, 1], [1, 2, 3, 4, 5, 6, 6, 6, 5, 4, 3, 2, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 1, 1], [1, 2, 3, 4, 5, 6, 6, 6, 5, 4, 3, 2, 1, 1, 1], [1, 2, 3, 4, 5, 5, 5, 5, 5, 4, 3, 2, 1, 1, 1], [1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 1, 1], [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],queries = [1, 2, 3, 4, 5, 6, 7]) == [0, 69, 111, 145, 170, 186, 194]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],queries = [5, 10, 15]) == [4, 27, 30]\n    assert candidate(grid = [[1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1]],queries = [1, 2, 3]) == [0, 1, 36]\n    assert candidate(grid = [[1, 3, 2, 4, 3], [2, 4, 3, 5, 4], [3, 5, 4, 6, 5], [4, 6, 5, 7, 6], [5, 7, 6, 8, 7]],queries = [2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 6, 12, 17, 21, 24, 25]\n    assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10]],queries = [6, 10, 15, 20]) == [10, 18, 20, 20]\n    assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16]],queries = [5, 10, 15, 20]) == [4, 9, 14, 19]\n    assert candidate(grid = [[1, 3, 1, 4, 1], [2, 2, 4, 2, 4], [3, 5, 3, 5, 3], [4, 4, 5, 4, 4], [1, 1, 1, 1, 1]],queries = [2, 5, 7, 10]) == [1, 22, 25, 25]\n    assert candidate(grid = [[1, 2, 3], [2, 1, 2], [3, 2, 1], [2, 1, 2], [1, 2, 3]],queries = [2, 3, 4]) == [1, 12, 15]\n    assert candidate(grid = [[5, 2, 1, 2, 5], [1, 5, 2, 5, 1], [2, 1, 5, 1, 2], [5, 2, 1, 2, 5]],queries = [3, 4, 6, 7]) == [0, 0, 20, 20]\n    assert candidate(grid = [[1, 5, 3, 8, 7], [2, 6, 4, 9, 8], [3, 7, 5, 10, 9], [4, 8, 6, 11, 10], [5, 9, 7, 12, 11]],queries = [1, 4, 7, 10, 13]) == [0, 3, 11, 20, 25]\n    assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]],queries = [5, 15, 25, 30]) == [4, 14, 24, 25]\n    assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9]],queries = [6, 12, 18]) == [13, 25, 25]\n    assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]],queries = [2, 3, 4]) == [16, 24, 25]\n    assert candidate(grid = [[1, 3, 1, 3, 1], [3, 1, 3, 1, 3], [1, 3, 1, 3, 1], [3, 1, 3, 1, 3], [1, 3, 1, 3, 1]],queries = [2, 4, 6, 8, 10]) == [1, 25, 25, 25, 25]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]],queries = [2, 3, 4]) == [20, 32, 36]\n    assert candidate(grid = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]],queries = [2, 4, 6, 8, 10]) == [1, 12, 16, 16, 16]\n    assert candidate(grid = [[1, 3, 5, 7], [2, 4, 6, 8], [3, 5, 7, 9], [4, 6, 8, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 4, 6, 8, 10, 12, 14, 15]\n    assert candidate(grid = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]],queries = [2, 4, 6, 8]) == [1, 6, 11, 12]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],queries = [15, 25, 35]) == [14, 24, 30]\n    assert candidate(grid = [[5, 3, 8, 6], [3, 4, 1, 5], [6, 1, 4, 3], [8, 5, 3, 7]],queries = [4, 6, 8, 10]) == [0, 11, 14, 16]\n    assert candidate(grid = [[3, 3, 3, 3, 3], [3, 2, 2, 2, 3], [3, 2, 1, 2, 3], [3, 2, 2, 2, 3], [3, 3, 3, 3, 3]],queries = [1, 2, 3, 4]) == [0, 0, 0, 25]\n    assert candidate(grid = [[1, 1, 1, 1000], [1, 1, 1000, 1], [1, 1000, 1, 1], [1000, 1, 1, 1]],queries = [500, 1001]) == [6, 16]\n    assert candidate(grid = [[1, 10, 100], [10, 100, 1000], [100, 1000, 10000]],queries = [500, 50, 5]) == [6, 3, 1]\n    assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 1, 2, 4, 6, 9, 11, 14, 16, 19, 21, 23, 24, 25, 25]\n    assert candidate(grid = [[100, 99, 98, 97, 96], [95, 94, 93, 92, 91], [90, 89, 88, 87, 86], [85, 84, 83, 82, 81], [80, 79, 78, 77, 76]],queries = [90, 80, 70]) == [0, 0, 0]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]],queries = [1, 2, 3, 4, 5]) == [0, 10, 20, 30, 40]\n    assert candidate(grid = [[1, 10, 3, 10, 5], [10, 9, 8, 7, 10], [6, 10, 2, 10, 4], [10, 10, 10, 10, 10], [5, 10, 7, 10, 9]],queries = [1, 5, 10, 15]) == [0, 1, 1, 25]\n    assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9]],queries = [5, 10, 15]) == [10, 23, 25]\n    assert candidate(grid = [[1000000, 999999, 999998], [999997, 999996, 999995], [999994, 999993, 999992]],queries = [999999, 999998, 999997, 999996, 999995, 999994]) == [0, 0, 0, 0, 0, 0]\n    assert candidate(grid = [[3, 2, 2, 3], [3, 1, 1, 3], [3, 2, 2, 3], [3, 3, 3, 3]],queries = [2, 4, 6, 8]) == [0, 16, 16, 16]\n    assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],queries = [1, 2, 3]) == [0, 40, 40]\n    assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]],queries = [5, 15, 25, 35]) == [4, 14, 24, 34]\n    assert candidate(grid = [[3, 1, 4, 1, 5, 9], [2, 6, 5, 3, 5, 9], [5, 8, 9, 7, 9, 3], [2, 8, 8, 4, 1, 9]],queries = [10, 20, 30, 40, 50]) == [24, 24, 24, 24, 24]\n", "comparison": "exact"}, "public_tests": ["[[1,2,3],[2,5,7],[3,5,1]]\n[5,6,2]", "[[5,2,1],[1,1,2]]\n[3]"], "hints": ["The queries are all given to you beforehand so you can answer them in any order you want.", "Sort the queries knowing their original order to be able to build the answer array.", "Run a BFS on the graph and answer the queries in increasing order."], "metadata": {"canonical_parameter_names": ["grid", "queries"], "leetcode_dataset_entry_point": "Solution().maxPoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:11+00:00", "tests_total": 103, "tests_dropped": 8, "flags": ["has_images"], "topic_tags": ["array", "two-pointers", "breadth-first-search", "union-find", "sorting", "heap-priority-queue", "matrix"]}, "language": "python", "interface": {"raw_signature": "def maxPoints(self, grid: list[list[int]], queries: list[int]) -> list[int]:", "container": "Solution", "callable": "maxPoints", "parameters": [{"name": "grid", "type": "list[list[int]]"}, {"name": "queries", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2506, "task_id": "count-pairs-of-similar-strings", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string array words.\n\nTwo strings are similar if they consist of the same characters.\n\n- For example, \"abca\" and \"cba\" are similar since both consist of characters 'a', 'b', and 'c'.\n- However, \"abacba\" and \"bcfd\" are not similar since they do not consist of the same characters.\n\nReturn the number of pairs (i, j) such that 0 <= i < j <= word.length - 1 and the two strings words[i] and words[j] are similar.\n\nExample 1:\n\nInput: words = [\"aba\",\"aabb\",\"abcd\",\"bac\",\"aabc\"]\nOutput: 2\nExplanation: There are 2 pairs that satisfy the conditions:\n- i = 0 and j = 1 : both words[0] and words[1] only consist of characters 'a' and 'b'.\n- i = 3 and j = 4 : both words[3] and words[4] only consist of characters 'a', 'b', and 'c'.\n\nExample 2:\n\nInput: words = [\"aabb\",\"ab\",\"ba\"]\nOutput: 3\nExplanation: There are 3 pairs that satisfy the conditions:\n- i = 0 and j = 1 : both words[0] and words[1] only consist of characters 'a' and 'b'.\n- i = 0 and j = 2 : both words[0] and words[2] only consist of characters 'a' and 'b'.\n- i = 1 and j = 2 : both words[1] and words[2] only consist of characters 'a' and 'b'.\n\nExample 3:\n\nInput: words = [\"nba\",\"cba\",\"dba\"]\nOutput: 0\nExplanation: Since there does not exist any pair that satisfies the conditions, we return 0.\n\nConstraints:\n\n- 1 <= words.length <= 100\n- 1 <= words[i].length <= 100\n- words[i] consist of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(words = ['aabbcc', 'abc', 'ab', 'a', 'b', 'c']) == 1\n    assert candidate(words = ['aaa', 'bbb', 'ccc', 'aab', 'aba', 'baa']) == 3\n    assert candidate(words = ['aabbcc', 'abc', 'aabb', 'aaabbbcc', 'abcabc']) == 6\n    assert candidate(words = ['a', 'b', 'c', 'd', 'e']) == 0\n    assert candidate(words = ['aaa', 'bbb', 'ccc', 'abc', 'abc']) == 1\n    assert candidate(words = ['abcd', 'bcad', 'cabd', 'dabc']) == 6\n    assert candidate(words = ['nba', 'cba', 'dba']) == 0\n    assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']) == 15\n    assert candidate(words = ['abcd', 'dcba', 'abdc', 'badc']) == 6\n    assert candidate(words = ['aabb', 'ab', 'ba']) == 3\n    assert candidate(words = ['abc', 'def', 'ghi', 'jkl']) == 0\n    assert candidate(words = ['aa', 'bb', 'cc', 'abc', 'cba', 'bca']) == 3\n    assert candidate(words = ['a', 'b', 'c', 'd']) == 0\n    assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 0\n    assert candidate(words = ['abc', 'abc', 'abc', 'abc']) == 6\n    assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd']) == 10\n    assert candidate(words = ['aaa', 'bbb', 'ccc', 'aaa']) == 1\n    assert candidate(words = ['abc', 'def', 'ghi']) == 0\n    assert candidate(words = ['aba', 'aabb', 'abcd', 'bac', 'aabc']) == 2\n    assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno']) == 0\n    assert candidate(words = ['ab', 'ba', 'ab', 'ba', 'ab', 'ba']) == 15\n    assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'aabbcc', 'bbaacc', 'ccbaab', 'aabbbc']) == 45\n    assert candidate(words = ['abcde', 'edcba', 'abc', 'bca', 'cab', 'deabc']) == 6\n    assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba']) == 6\n    assert candidate(words = ['aabbcc', 'abcabc', 'bcaabc', 'cababc', 'bcabac']) == 10\n    assert candidate(words = ['aabbccddeeff', 'ffeeddccbbaa', 'abcdef', 'fedcba', 'efabcd', 'fedcba', 'abcdefg', 'gfedcba', 'hijklm', 'mlkjih']) == 17\n    assert candidate(words = ['aabbcc', 'bbaacc', 'ccaabb', 'aabbc', 'bbaac', 'ccaab', 'aaabb', 'aabbb', 'abbbb', 'bbbbb']) == 18\n    assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']) == 0\n    assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh', 'iiii', 'jjjj']) == 0\n    assert candidate(words = ['abcdefg', 'gfedcba', 'ghijklm', 'mlkjihg', 'nopqrst', 'tsrqpon', 'vwxyz', 'zyxwv', 'abcdabcd', 'efghijkl', 'mnopqrstuvw', 'xyzzyxwv', 'utsrqponmlkjihgfedcba']) == 6\n    assert candidate(words = ['hello', 'olleh', 'world', 'dlrow', 'python', 'nohtyp', 'java', 'avaj', 'algorithm', 'mhtirogla', 'data', 'tatad', 'structure', 'erutcurts', 'example', 'elpmaxe', 'test', 'tset', 'code', 'edoc', 'challenge', 'egnellahc', 'interview', 'weivretni']) == 12\n    assert candidate(words = ['xyzxyzxyz', 'zyxzyxzyx', 'yzxyzxyz', 'zyxyzxyz', 'xzyzxzyx', 'xyzzyxzyx', 'zyxzyxzyx', 'xyzzyxzyx', 'xzyzxzyx', 'xyzxyzxyz']) == 45\n    assert candidate(words = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'aaaaa', 'bbbbb']) == 2\n    assert candidate(words = ['abcd', 'abce', 'abcf', 'abdg', 'abdh', 'abei', 'abdj', 'abcd', 'abcd']) == 3\n    assert candidate(words = ['aabbcc', 'abc', 'ab', 'a', 'b', 'c', 'abcde', 'edcba', 'fghij', 'jihgf', 'mnopq', 'qpomn']) == 4\n    assert candidate(words = ['abcd', 'dcba', 'cdab', 'bacd', 'cabd', 'abcd', 'acdb', 'bdac', 'bcda', 'dabc', 'adcb', 'cdba', 'bacd', 'abcd', 'bcad']) == 105\n    assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'abcd', 'abcd', 'dcba', 'dcba', 'abcd']) == 45\n    assert candidate(words = ['xyz', 'zyx', 'abc', 'cab', 'bac', 'xyz', 'zyx']) == 9\n    assert candidate(words = ['aaaa', 'aabb', 'abab', 'abba', 'baba', 'bbaa', 'baab', 'abab', 'aabb', 'abba']) == 36\n    assert candidate(words = ['abc', 'bca', 'cab', 'xyz', 'zyx', 'yzx']) == 6\n    assert candidate(words = ['ab', 'ba', 'ac', 'ca', 'ad', 'da', 'bc', 'cb', 'bd', 'db', 'cd', 'dc']) == 6\n    assert candidate(words = ['abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij']) == 0\n    assert candidate(words = ['xyz', 'zyx', 'yzx', 'xzy', 'yxz', 'zxy', 'xyzz', 'yzzx', 'zzxy', 'zzzx', 'zxzy', 'xzyz']) == 55\n    assert candidate(words = ['unique', 'ueinque', 'qneuie', 'neiqueu', 'ienquue', 'enuiqueu', 'qieuenu', 'euniqeu', 'ueinqeu', 'neuiqeu', 'uieqneu', 'niuqueeu', 'eiunqueu', 'iuqeenu', 'qieuenu', 'euniqeu', 'ueinqeu', 'neuiqeu', 'uieqneu', 'niuqueeu', 'eiunqueu', 'iuqeenu', 'qieuenu', 'euniqeu', 'ueinqeu', 'neuiqeu', 'uieqneu', 'niuqueeu', 'eiunqueu', 'iuqeenu', 'qieuenu', 'euniqeu', 'ueinqeu', 'neuiqeu', 'uieqneu', 'niuqueeu', 'eiunqueu', 'iuqeenu', 'qieuenu', 'euniqeu', 'ueinqeu', 'neuiqeu', 'uieqneu', 'niuqueeu', 'eiunqueu', 'iuqeenu', 'qieuenu', 'euniqeu', 'ueinqeu', 'neuiqeu', 'uieqneu', 'niuqueeu', 'eiunqueu', 'iuqeenu']) == 1431\n    assert candidate(words = ['aaa', 'aa', 'a', 'b', 'bb', 'bbb', 'bbbb', 'bbbbb']) == 13\n    assert candidate(words = ['abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba']) == 276\n    assert candidate(words = ['pqrst', 'rstqp', 'qrstp', 'srtpq', 'tsrqp', 'tspqr', 'pqrst', 'rstqp', 'qrstp', 'srtpq', 'tsrqp', 'tspqr']) == 66\n    assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca']) == 45\n    assert candidate(words = ['abc', 'abd', 'abe', 'abf', 'abg', 'abh', 'abi', 'abj', 'abk', 'abl', 'abm', 'abn', 'abo', 'abp', 'abq', 'abr', 'abs', 'abt', 'abu', 'abv', 'abw', 'abx', 'aby', 'abz']) == 0\n    assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba']) == 15\n    assert candidate(words = ['xyz', 'zyx', 'zyx', 'xyz', 'yxxz', 'zyxz', 'xzyz', 'yxzz', 'zxzy', 'zyzz', 'zzzy', 'zyyz', 'zyzx', 'xzyz', 'zzyx', 'zyxz', 'zyzx', 'zyxz', 'zyzx', 'zyxz', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx', 'zyzx']) == 744\n    assert candidate(words = ['abcdefg', 'gfedcba', 'hijklmn', 'nmkljih', 'opqrstu', 'utsrqpo', 'vwxyz', 'zyxwv', 'abcdefg', 'gfedcba', 'hijklmn', 'nmkljih', 'opqrstu', 'utsrqpo', 'vwxyz', 'zyxwv']) == 24\n    assert candidate(words = ['abc', 'bca', 'cab', 'xyz', 'zyx', 'yxz']) == 6\n    assert candidate(words = ['abacabadabacaba', 'bacbacbacbacbac', 'cabacabacabacab', 'abcabcabcabcabc', 'bcbcbcbcbcbcb', 'cbcbcbcbcbcbc']) == 4\n    assert candidate(words = ['aaa', 'bbb', 'ccc', 'abc', 'bca', 'cab', 'abc', 'bca', 'cab']) == 15\n    assert candidate(words = ['aaaa', 'aaab', 'aaba', 'abaa', 'baaa', 'bbaa', 'bbba', 'bbbb']) == 15\n    assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'mnopqrstuvwxyzabcdefghijkl']) == 3\n    assert candidate(words = ['abcd', 'abce', 'abcf', 'abdg', 'abdh', 'abdi', 'abdj', 'abcd']) == 1\n    assert candidate(words = ['aabbcc', 'abcabc', 'bcaabc', 'cababc', 'aabbcc', 'bbaacc', 'ccbaab']) == 21\n    assert candidate(words = ['xyz', 'zyx', 'yxz', 'zxy', 'xzy', 'yzx']) == 15\n    assert candidate(words = ['xyz', 'zyx', 'yxz', 'xzy', 'yzx', 'zxy', 'abc', 'bca', 'cab', 'aaa', 'bbb', 'ccc', 'aba', 'bab', 'aab', 'abb', 'baa', 'bba', 'abb', 'aab', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == 55\n    assert candidate(words = ['xyz', 'zyx', 'yzx', 'xzy', 'yxz', 'zxy', 'zyxw', 'wxyz']) == 16\n    assert candidate(words = ['mnop', 'mnopqr', 'mnopqrs', 'mnopqrst', 'mnopqrstuv', 'mnopqrstuvw', 'mnopqrstuvwx', 'mnopqrstuvwxy', 'mnopqrstuvwxyz']) == 0\n    assert candidate(words = ['abcabc', 'bcabc', 'cabc', 'abc', 'bca', 'cab', 'aabbcc', 'bbccaa', 'ccaabb']) == 36\n    assert candidate(words = ['abcde', 'edcba', 'bcdea', 'deabc', 'cdeab']) == 10\n    assert candidate(words = ['abcdef', 'fedcba', 'ghijkl', 'lkjhgf', 'mnopqr', 'rqponm', 'stuvwx', 'xwvuts', 'yz', 'zy']) == 4\n    assert candidate(words = ['pqr', 'qrp', 'prq', 'rpq', 'rqp', 'pqr', 'abc', 'cab', 'bac', 'abcde', 'edcba', 'fghij', 'jihgf', 'mnopq', 'qpomn']) == 21\n    assert candidate(words = ['abc', 'abcd', 'abce', 'abcf', 'abcg', 'abch', 'abci', 'abcj', 'abck', 'abcl', 'abcm', 'abcn', 'abco', 'abcp', 'abcq', 'abcr', 'abcs', 'abct', 'abcu', 'abcv', 'abcw', 'abcx', 'abcy', 'abcz']) == 0\n    assert candidate(words = ['ab', 'ba', 'ac', 'ca', 'ad', 'da', 'bc', 'cb', 'bd', 'db', 'cd', 'dc', 'abcd', 'dcba', 'cdab', 'bacd', 'cabd', 'acbd', 'cadb', 'abcd', 'dcba', 'cdab', 'bacd', 'cabd', 'acbd', 'cadb']) == 97\n    assert candidate(words = ['abcabcabc', 'bcbcbcbc', 'cacacac', 'abababab', 'babababa', 'acacacac', 'abcabcabc', 'bcbcbcbc', 'cacacac', 'abababab']) == 8\n    assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'zyx']) == 0\n    assert candidate(words = ['abcdabcdabcdabcdabcdabcdabcdabcd', 'bcadbcadbcadbcadbcadbcadbcadbcad', 'cdabcdabcdabcdabcdabcdabcdabcdabc', 'dcbadcbadcbadcbadcbadcbadcbadcba', 'abcdabcdabcdabcdabcdabcdabcdabcde']) == 6\n    assert candidate(words = ['apple', 'pale', 'pplea', 'elppa', 'ppale', 'pleap']) == 15\n    assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh', 'iiii', 'jjjj']) == 0\n    assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba']) == 276\n    assert candidate(words = ['mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq', 'mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq', 'mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq']) == 153\n    assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']) == 0\n    assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'uvw', 'rst', 'qpo', 'nml', 'kji', 'fed', 'cba', 'zyx', 'wvu', 'tsr', 'pon', 'mlk', 'jih', 'gf', 'de', 'abc']) == 6\n    assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']) == 0\n    assert candidate(words = ['aaa', 'bbb', 'ccc', 'abc', 'bca', 'cab', 'aab', 'aba', 'baa', 'bbc', 'bcb', 'cbb', 'acc', 'cac', 'cca']) == 12\n    assert candidate(words = ['abcdef', 'fedcba', 'bcdefa', 'defabc', 'efabcd', 'fabcde', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'uvw', 'rst', 'qpo', 'nml', 'kji', 'fed', 'cba', 'zyx', 'wvu', 'tsr', 'pon', 'mlk', 'jih', 'gf', 'de', 'abc']) == 21\n    assert candidate(words = ['abcde', 'edcba', 'fghij', 'jihgf', 'abcde', 'edcba']) == 7\n    assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz']) == 45\n    assert candidate(words = ['aabbcc', 'abcabc', 'ababab', 'acacac', 'bcbcbc', 'bacbac', 'cabcab', 'abcabcabc', 'xyzxyzxyz', 'zyxzyxzyx']) == 11\n    assert candidate(words = ['abcdefg', 'gfedcba', 'fedcbag', 'bagfedc', 'abcdefg', 'gfedcba', 'fedcbag', 'bagfedc', 'abcdefg', 'gfedcba']) == 45\n    assert candidate(words = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'jihgfedcba', 'abcdefghij', 'jihgfedcba']) == 15\n    assert candidate(words = ['abcdef', 'fedcba', 'defabc', 'cabfed', 'bcadef', 'fedcba', 'abcdef', 'abcdef']) == 28\n    assert candidate(words = ['abcde', 'edcba', 'cdeab', 'decba', 'bacde', 'ecbad', 'abcd', 'dcba', 'abc', 'bca', 'cab', 'acb', 'bac', 'cba', 'a', 'b', 'c', 'd', 'e']) == 31\n    assert candidate(words = ['aabbcc', 'aabbc', 'aabc', 'abc', 'ab', 'a', 'b', 'bb', 'bbb', 'bbbb', 'bbbbb', 'bbbbb', 'bbbb', 'bbb', 'bb', 'b']) == 51\n    assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same']) == 3403\n    assert candidate(words = ['ab', 'ac', 'ad', 'ae', 'af', 'ag', 'ah', 'ai', 'aj', 'ak', 'al', 'am', 'an', 'ao', 'ap', 'aq', 'ar', 'as', 'at', 'au', 'av', 'aw', 'ax', 'ay', 'az']) == 0\n    assert candidate(words = ['xyz', 'yzx', 'zxy', 'zyx', 'yxz', 'xzy', 'abc', 'cab', 'bca']) == 18\n    assert candidate(words = ['abc', 'abcabc', 'abcabcabc', 'abcabcabcabc', 'abcabcabcabcabc', 'abcabcabcabcabcabc', 'abcabcabcabcabcabcabc', 'abcabcabcabcabcabcabcabc']) == 28\n    assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']) == 26\n    assert candidate(words = ['test', 'sett', 'stet', 'tset', 'ttes', 'etts', 'etst', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste', 'stte', 'ttse', 'tste']) == 3828\n    assert candidate(words = ['ab', 'ba', 'ac', 'ca', 'ad', 'da', 'bc', 'cb', 'bd', 'db', 'cd', 'dc', 'abcd', 'dcba', 'cdab', 'bacd', 'cabd', 'abcd', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'ab', 'ba', 'ac', 'ca', 'ad', 'da', 'bc', 'cb', 'bd', 'db', 'cd', 'dc', 'abcd', 'dcba', 'cdab', 'bacd', 'cabd', 'abcd']) == 117\n    assert candidate(words = ['aaaa', 'aaab', 'aaba', 'aabb', 'abaa', 'abab', 'abba', 'abbb', 'baaa', 'baab', 'baba', 'babb', 'bbaa', 'bbab', 'bbba', 'bbbb']) == 91\n    assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'aabbcc', 'ddeeff', 'gghhiijj', 'kkllmm', 'nnoopp', 'qqrrss', 'ttuuvv', 'wwxxyy', 'zz', 'aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj', 'kkk', 'lll', 'mmm', 'nnn', 'ooo', 'ppp', 'qqq', 'rrr', 'sss', 'ttt', 'uuu', 'vvv', 'www', 'xxx', 'yyy', 'zzz']) == 3\n    assert candidate(words = ['aabbcc', 'bbaacc', 'ccbbaa', 'aabbcc', 'bbaacc', 'ccbbaa', 'aabbbc', 'bbaacc', 'ccbbaa', 'aabbbc', 'bbaacc', 'ccbbaa']) == 66\n    assert candidate(words = ['hello', 'olleh', 'ohell', 'loleh', 'ehlol', 'llohe', 'world', 'dlrow', 'owrld', 'rldwo', 'ldwor', 'dworld', 'wolrd', 'orldw', 'lrwod', 'rwdol', 'dlorw', 'lorwd', 'rowdl', 'owrld', 'dlrow', 'world', 'dlrow', 'owrld', 'rldwo', 'ldwor', 'dworld', 'wolrd', 'orldw', 'lrwod', 'rwdol', 'dlorw', 'lorwd', 'rowdl', 'owrld', 'dlrow', 'world', 'dlrow', 'owrld', 'rldwo', 'ldwor', 'dworld', 'wolrd', 'orldw', 'lrwod', 'rwdol', 'dlorw', 'lorwd', 'rowdl', 'owrld']) == 961\n", "comparison": "exact"}, "public_tests": ["[\"aba\",\"aabb\",\"abcd\",\"bac\",\"aabc\"]", "[\"aabb\",\"ab\",\"ba\"]", "[\"nba\",\"cba\",\"dba\"]"], "hints": ["How can you check if two strings are similar?", "Use a hashSet to store the character of each string."], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().similarPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:15+00:00", "tests_total": 101, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "string", "bit-manipulation", "counting"]}, "language": "python", "interface": {"raw_signature": "def similarPairs(self, words: list[str]) -> int:", "container": "Solution", "callable": "similarPairs", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2507, "task_id": "smallest-value-after-replacing-with-sum-of-prime-factors", "difficulty": "Medium", "problem_description": "You are given a positive integer n.\n\nContinuously replace n with the sum of its prime factors.\n\n- Note that if a prime factor divides n multiple times, it should be included in the sum as many times as it divides n.\n\nReturn the smallest value n will take on.\n\nExample 1:\n\nInput: n = 15\nOutput: 5\nExplanation: Initially, n = 15.\n15 = 3 * 5, so replace n with 3 + 5 = 8.\n8 = 2 * 2 * 2, so replace n with 2 + 2 + 2 = 6.\n6 = 2 * 3, so replace n with 2 + 3 = 5.\n5 is the smallest value n will take on.\n\nExample 2:\n\nInput: n = 3\nOutput: 3\nExplanation: Initially, n = 3.\n3 is the smallest value n will take on.\n\nConstraints:\n\n- 2 <= n <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 3) == 3\n    assert candidate(n = 15) == 5\n    assert candidate(n = 100) == 5\n    assert candidate(n = 44) == 5\n    assert candidate(n = 28) == 11\n    assert candidate(n = 97) == 97\n    assert candidate(n = 99999) == 31\n    assert candidate(n = 729) == 5\n    assert candidate(n = 12345) == 5\n    assert candidate(n = 49) == 5\n    assert candidate(n = 104) == 19\n    assert candidate(n = 841) == 31\n    assert candidate(n = 1009) == 1009\n    assert candidate(n = 60) == 7\n    assert candidate(n = 6857) == 6857\n    assert candidate(n = 72) == 7\n    assert candidate(n = 13195) == 11\n    assert candidate(n = 225) == 5\n    assert candidate(n = 720) == 19\n    assert candidate(n = 128) == 5\n    assert candidate(n = 1024) == 5\n    assert candidate(n = 100000) == 7\n    assert candidate(n = 789) == 11\n    assert candidate(n = 2048) == 13\n    assert candidate(n = 999) == 7\n    assert candidate(n = 2310) == 11\n    assert candidate(n = 65536) == 7\n    assert candidate(n = 169) == 5\n    assert candidate(n = 256) == 5\n    assert candidate(n = 77) == 5\n    assert candidate(n = 81) == 7\n    assert candidate(n = 97531) == 67\n    assert candidate(n = 99998) == 5\n    assert candidate(n = 1234) == 619\n    assert candidate(n = 3125) == 7\n    assert candidate(n = 8898) == 7\n    assert candidate(n = 121) == 13\n    assert candidate(n = 500) == 19\n    assert candidate(n = 54321) == 5\n    assert candidate(n = 84) == 5\n", "comparison": "exact"}, "public_tests": ["15", "3"], "hints": ["Every time you replace n, it will become smaller until it is a prime number, where it will keep the same value each time you replace it.", "n decreases logarithmically, allowing you to simulate the process.", "To find the prime factors, iterate through all numbers less than n from least to greatest and find the maximum number of times each number divides n."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().smallestValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:18+00:00", "tests_total": 45, "tests_dropped": 5, "flags": [], "topic_tags": ["math", "simulation", "number-theory", "prime-factorization", "primality-test", "sieve-theory", "prime-number-sieve"]}, "language": "python", "interface": {"raw_signature": "def smallestValue(self, n: int) -> int:", "container": "Solution", "callable": "smallestValue", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2508, "task_id": "add-edges-to-make-degrees-of-all-nodes-even", "difficulty": "Hard", "problem_description": "There is an undirected graph consisting of n nodes numbered from 1 to n. You are given the integer n and a 2D array edges where edges[i] = [a_i, b_i] indicates that there is an edge between nodes a_i and b_i. The graph can be disconnected.\n\nYou can add at most two additional edges (possibly none) to this graph so that there are no repeated edges and no self-loops.\n\nReturn true if it is possible to make the degree of each node in the graph even, otherwise return false.\n\nThe degree of a node is the number of edges connected to it.\n\nExample 1:\n\nInput: n = 5, edges = [[1,2],[2,3],[3,4],[4,2],[1,4],[2,5]]\nOutput: true\nExplanation: The above diagram shows a valid way of adding an edge.\nEvery node in the resulting graph is connected to an even number of edges.\n\nExample 2:\n\nInput: n = 4, edges = [[1,2],[3,4]]\nOutput: true\nExplanation: The above diagram shows a valid way of adding two edges.\n\nExample 3:\n\nInput: n = 4, edges = [[1,2],[1,3],[1,4]]\nOutput: false\nExplanation: It is not possible to obtain a valid graph with adding at most 2 edges.\n\nConstraints:\n\n- 3 <= n <= 10^5\n- 2 <= edges.length <= 10^5\n- edges[i].length == 2\n- 1 <= a_i, b_i <= n\n- a_i != b_i\n- There are no repeated edges.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 4,edges = [[1, 2], [1, 3], [1, 4]]) == False\n    assert candidate(n = 7,edges = [[1, 2], [3, 4], [5, 6], [6, 7]]) == False\n    assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == True\n    assert candidate(n = 4,edges = [[1, 2], [3, 4]]) == True\n    assert candidate(n = 6,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == True\n    assert candidate(n = 8,edges = [[1, 2], [3, 4], [5, 6], [7, 8]]) == False\n    assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 2], [1, 4], [2, 5]]) == True\n    assert candidate(n = 7,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == True\n    assert candidate(n = 8,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 3], [5, 7]]) == True\n    assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == True\n    assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10]]) == True\n    assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 3], [4, 6], [7, 9]]) == False\n    assert candidate(n = 14,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [1, 5], [2, 6], [3, 7], [4, 8], [9, 11], [10, 12], [13, 1]]) == False\n    assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [4, 6]]) == True\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 13], [13, 14], [14, 10], [15, 1]]) == True\n    assert candidate(n = 13,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 1], [2, 13], [4, 13], [6, 13], [8, 13], [10, 13], [12, 13]]) == False\n    assert candidate(n = 11,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 7], [8, 9], [10, 11]]) == True\n    assert candidate(n = 7,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 7], [7, 4], [1, 4], [2, 5], [3, 6]]) == False\n    assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == True\n    assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 9], [1, 9], [2, 10], [3, 11], [4, 12], [5, 13], [6, 14], [7, 15], [8, 9]]) == False\n    assert candidate(n = 14,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [6, 14], [7, 14]]) == False\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]) == True\n    assert candidate(n = 10,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [1, 3], [2, 4], [5, 7], [6, 8], [7, 9], [8, 10]]) == True\n    assert candidate(n = 14,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == True\n    assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21]]) == True\n    assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [7, 9], [8, 9], [1, 4], [2, 5], [3, 6]]) == False\n    assert candidate(n = 13,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [7, 13], [8, 9], [10, 11], [12, 13]]) == True\n    assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]) == True\n    assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == True\n    assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [1, 9], [2, 4], [3, 5], [6, 8]]) == False\n    assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [3, 7], [4, 7], [5, 6]]) == True\n    assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]) == True\n    assert candidate(n = 13,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [1, 3], [2, 4], [5, 7], [6, 8], [9, 11], [10, 12]]) == False\n    assert candidate(n = 14,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 11], [1, 12], [2, 13], [3, 14], [4, 6], [5, 7]]) == False\n    assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == True\n    assert candidate(n = 13,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [10, 11], [11, 12], [12, 13], [13, 9], [1, 9], [2, 10], [3, 11], [4, 12], [5, 13], [6, 9], [7, 10], [8, 11]]) == True\n    assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20]]) == False\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 13], [13, 10], [14, 15], [15, 14]]) == True\n    assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10]]) == True\n    assert candidate(n = 10,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == False\n    assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == False\n    assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [1, 5], [2, 6], [3, 7], [4, 8], [9, 12]]) == False\n    assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 4], [5, 8]]) == True\n    assert candidate(n = 11,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == True\n    assert candidate(n = 20,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == False\n    assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 1]]) == True\n    assert candidate(n = 11,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [1, 11]]) == True\n    assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == True\n    assert candidate(n = 14,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 6]]) == True\n    assert candidate(n = 11,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 1]]) == True\n    assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8]]) == True\n    assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [1, 8]]) == True\n    assert candidate(n = 11,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [1, 11], [2, 5], [3, 7], [4, 8]]) == False\n    assert candidate(n = 18,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18]]) == False\n    assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1], [1, 3], [5, 7]]) == True\n    assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == True\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11]]) == True\n    assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == False\n    assert candidate(n = 16,edges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [1, 3], [1, 5], [1, 7], [1, 9], [1, 11], [1, 13], [1, 15]]) == False\n    assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 6]]) == True\n    assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6]]) == True\n    assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10]]) == True\n    assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 4], [2, 5], [3, 6]]) == False\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13]]) == True\n    assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 8]]) == True\n    assert candidate(n = 16,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 1]]) == True\n    assert candidate(n = 9,edges = [[1, 2], [3, 4], [5, 6], [7, 8]]) == False\n    assert candidate(n = 14,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 1]]) == True\n    assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 4], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [1, 16], [2, 17], [3, 18], [4, 19], [5, 20]]) == False\n    assert candidate(n = 7,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 5]]) == True\n    assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [9, 10]]) == False\n    assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1], [1, 3], [2, 4], [5, 7], [6, 8]]) == False\n    assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8]]) == True\n    assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 5], [2, 6], [3, 4], [7, 10]]) == False\n    assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]) == True\n    assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == True\n    assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == True\n    assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 12], [12, 9]]) == True\n    assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 3], [3, 5], [5, 7], [7, 9]]) == True\n    assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == True\n    assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 6], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 10]]) == True\n    assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [1, 4], [2, 5], [3, 6]]) == False\n", "comparison": "exact"}, "public_tests": ["5\n[[1,2],[2,3],[3,4],[4,2],[1,4],[2,5]]", "4\n[[1,2],[3,4]]", "4\n[[1,2],[1,3],[1,4]]"], "hints": ["Notice that each edge that we add changes the degree of exactly 2 nodes.", "The number of nodes with an odd degree in the original graph should be either 0, 2, or 4. Try to work on each of these cases."], "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().isPossible", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:20+00:00", "tests_total": 82, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["hash-table", "graph"]}, "language": "python", "interface": {"raw_signature": "def isPossible(self, n: int, edges: list[list[int]]) -> bool:", "container": "Solution", "callable": "isPossible", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2509, "task_id": "cycle-length-queries-in-a-tree", "difficulty": "Hard", "problem_description": "You are given an integer n. There is a complete binary tree with 2^n - 1 nodes. The root of that tree is the node with the value 1, and every node with a value val in the range [1, 2^{n - 1} - 1] has two children where:\n\n- The left node has the value 2 * val, and\n- The right node has the value 2 * val + 1.\n\nYou are also given a 2D integer array queries of length m, where queries[i] = [a_i, b_i]. For each query, solve the following problem:\n\n1. Add an edge between the nodes with values a_i and b_i.\n2. Find the length of the cycle in the graph.\n3. Remove the added edge between nodes with values a_i and b_i.\n\nNote that:\n\n- A cycle is a path that starts and ends at the same node, and each edge in the path is visited only once.\n- The length of a cycle is the number of edges visited in the cycle.\n- There could be multiple edges between two nodes in the tree after adding the edge of the query.\n\nReturn an array answer of length m where answer[i] is the answer to the i^th query.\n\nExample 1:\n\nInput: n = 3, queries = [[5,3],[4,7],[2,3]]\nOutput: [4,5,3]\nExplanation: The diagrams above show the tree of 2^3 - 1 nodes. Nodes colored in red describe the nodes in the cycle after adding the edge.\n- After adding the edge between nodes 3 and 5, the graph contains a cycle of nodes [5,2,1,3]. Thus answer to the first query is 4. We delete the added edge and process the next query.\n- After adding the edge between nodes 4 and 7, the graph contains a cycle of nodes [4,2,1,3,7]. Thus answer to the second query is 5. We delete the added edge and process the next query.\n- After adding the edge between nodes 2 and 3, the graph contains a cycle of nodes [2,1,3]. Thus answer to the third query is 3. We delete the added edge.\n\nExample 2:\n\nInput: n = 2, queries = [[1,2]]\nOutput: [2]\nExplanation: The diagram above shows the tree of 2^2 - 1 nodes. Nodes colored in red describe the nodes in the cycle after adding the edge.\n- After adding the edge between nodes 1 and 2, the graph contains a cycle of nodes [2,1]. Thus answer for the first query is 2. We delete the added edge.\n\nConstraints:\n\n- 2 <= n <= 30\n- m == queries.length\n- 1 <= m <= 10^5\n- queries[i].length == 2\n- 1 <= a_i, b_i <= 2^n - 1\n- a_i != b_i\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(n = 5,queries = [[31, 15], [10, 18], [9, 20]]) == [2, 6, 6]\n    assert candidate(n = 3,queries = [[5, 3], [4, 7], [2, 3]]) == [4, 5, 3]\n    assert candidate(n = 5,queries = [[15, 7], [10, 14], [3, 12]]) == [2, 7, 3]\n    assert candidate(n = 30,queries = [[1073741823, 1], [536870912, 2], [268435456, 4]]) == [30, 29, 27]\n    assert candidate(n = 4,queries = [[8, 4], [7, 3], [1, 14]]) == [2, 2, 4]\n    assert candidate(n = 4,queries = [[1, 15], [14, 2], [12, 10], [6, 3]]) == [4, 5, 7, 2]\n    assert candidate(n = 2,queries = [[1, 2]]) == [2]\n    assert candidate(n = 5,queries = [[3, 15], [16, 7], [8, 9]]) == [3, 7, 3]\n    assert candidate(n = 6,queries = [[32, 1], [16, 15], [8, 7], [4, 3], [2, 1]]) == [6, 8, 6, 4, 2]\n    assert candidate(n = 4,queries = [[8, 4], [6, 10], [5, 9]]) == [2, 6, 4]\n    assert candidate(n = 19,queries = [[262144, 524287], [131072, 262143], [65536, 131071], [32768, 65535], [16384, 32767], [8192, 16383], [4096, 8191], [2048, 4095], [1024, 2047], [512, 1023], [256, 511], [128, 255], [64, 127], [32, 63], [16, 31], [8, 15], [4, 7], [2, 3]]) == [37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3]\n    assert candidate(n = 10,queries = [[511, 1], [256, 2], [128, 4], [64, 8], [32, 16], [16, 32], [8, 64], [4, 128], [2, 256], [1, 511], [511, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1], [511, 510], [510, 509], [509, 508], [508, 507], [507, 506], [506, 505]]) == [9, 8, 6, 4, 2, 2, 4, 6, 8, 9, 17, 2, 2, 2, 2, 2, 2, 2, 2, 3, 5, 3, 7, 3, 5]\n    assert candidate(n = 18,queries = [[131071, 1], [65536, 2], [32768, 4], [16384, 8], [8192, 16], [4096, 32], [2048, 64], [1024, 128], [512, 256], [256, 512], [128, 1024], [64, 2048], [32, 4096], [16, 8192], [8, 16384], [4, 32768], [2, 65536], [1, 131071]]) == [17, 16, 14, 12, 10, 8, 6, 4, 2, 2, 4, 6, 8, 10, 12, 14, 16, 17]\n    assert candidate(n = 15,queries = [[32767, 16384], [8192, 4096], [2048, 1024], [512, 256], [128, 64]]) == [29, 2, 2, 2, 2]\n    assert candidate(n = 22,queries = [[4194303, 2097152], [2097151, 1048576], [1048575, 524288], [524287, 262144], [262143, 131072], [131071, 65536], [65535, 32768], [32767, 16384], [16383, 8192]]) == [43, 41, 39, 37, 35, 33, 31, 29, 27]\n    assert candidate(n = 25,queries = [[33554431, 16777216], [16777216, 8388608], [8388608, 4194304], [4194304, 2097152], [2097152, 1048576], [1048576, 524288], [524288, 262144], [262144, 131072], [131072, 65536], [65536, 32768], [32768, 16384], [16384, 8192], [8192, 4096], [4096, 2048], [2048, 1024], [1024, 512], [512, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1]]) == [49, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n    assert candidate(n = 20,queries = [[1048575, 524288], [524287, 262144], [262143, 131072], [131071, 65536], [65535, 32768]]) == [39, 37, 35, 33, 31]\n    assert candidate(n = 15,queries = [[16383, 1], [8192, 3], [4096, 7], [2048, 15], [1024, 31]]) == [14, 15, 15, 15, 15]\n    assert candidate(n = 12,queries = [[4095, 1], [2047, 2], [1023, 4], [511, 8], [255, 16], [127, 32], [63, 64], [31, 128], [15, 256], [7, 512], [3, 1024], [1, 2048], [4094, 4095], [2046, 2047], [1022, 1023], [510, 511], [254, 255], [126, 127], [62, 63], [30, 31], [14, 15], [6, 7], [2, 3], [1, 2], [4093, 1], [2045, 2], [1021, 4], [509, 8], [253, 16], [125, 32], [61, 64], [30, 128], [14, 256], [6, 512], [2, 1024], [1, 2048]]) == [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 10, 12]\n    assert candidate(n = 15,queries = [[16384, 32767], [8192, 16383], [4096, 8191], [2048, 4095], [1024, 2047], [512, 1023]]) == [29, 27, 25, 23, 21, 19]\n    assert candidate(n = 10,queries = [[511, 256], [1023, 512], [768, 384], [255, 128], [127, 64]]) == [17, 19, 2, 15, 13]\n    assert candidate(n = 10,queries = [[1023, 511], [511, 255], [255, 127], [127, 63], [63, 31], [31, 15], [15, 7], [7, 3], [3, 1]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n    assert candidate(n = 10,queries = [[512, 1], [256, 2], [128, 4], [64, 8], [32, 16], [16, 32], [8, 64], [4, 128], [2, 256], [1, 512]]) == [10, 8, 6, 4, 2, 2, 4, 6, 8, 10]\n    assert candidate(n = 12,queries = [[4095, 2048], [2048, 1024], [1024, 512], [512, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1], [4095, 2047], [2047, 2046], [2046, 2045], [2045, 2044], [2044, 2043], [2043, 2042], [2042, 2041], [2041, 2040], [2040, 2039], [2039, 2038], [2038, 2037], [2037, 2036], [2036, 2035], [2035, 2034], [2034, 2033], [2033, 2032], [2032, 2031]]) == [23, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 5, 3, 7, 3, 5, 3, 9, 3, 5, 3, 7, 3, 5, 3, 11]\n    assert candidate(n = 15,queries = [[16383, 1], [8191, 2], [4095, 4], [2047, 8], [1023, 16], [511, 32], [255, 64], [127, 128], [63, 256], [31, 512], [15, 1024], [7, 2048], [3, 4096], [1, 8192], [16382, 16383], [8190, 8191], [4094, 4095], [2046, 2047], [1022, 1023], [510, 511], [254, 255], [126, 127], [62, 63], [30, 31], [14, 15], [6, 7], [2, 3], [1, 2]]) == [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]\n    assert candidate(n = 20,queries = [[1048575, 1], [524288, 2], [262144, 4], [131072, 8], [65536, 16], [32768, 32], [16384, 64], [8192, 128], [4096, 256], [2048, 512]]) == [20, 19, 17, 15, 13, 11, 9, 7, 5, 3]\n    assert candidate(n = 17,queries = [[65535, 32768], [16384, 8192], [4096, 2048], [1024, 512], [256, 128], [64, 32], [16, 8], [4, 2], [2, 1], [65535, 1], [32768, 2], [16384, 4], [8192, 8], [4096, 16], [2048, 32], [1024, 64], [512, 128]]) == [31, 2, 2, 2, 2, 2, 2, 2, 2, 16, 15, 13, 11, 9, 7, 5, 3]\n    assert candidate(n = 12,queries = [[4095, 1], [2048, 3], [1024, 7], [512, 15], [256, 31], [128, 63], [64, 127], [32, 255], [16, 511], [8, 1023], [4, 2047], [2, 4095]]) == [12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]\n    assert candidate(n = 27,queries = [[134217727, 67108864], [67108863, 33554432], [33554431, 16777216], [16777215, 8388608], [8388607, 4194304], [4194303, 2097152], [2097151, 1048576], [1048575, 524288], [524287, 262144], [262143, 131072], [131071, 65536], [65535, 32768], [32767, 16384], [16383, 8192], [8191, 4096], [4095, 2048], [2047, 1024], [1023, 512], [511, 256], [255, 128], [127, 64], [63, 32], [31, 16], [15, 8], [7, 4], [3, 2], [1, 2]]) == [53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 2]\n    assert candidate(n = 25,queries = [[16777215, 8388608], [4194304, 2097152], [2097152, 1048576], [1048576, 524288], [524288, 262144], [262144, 131072], [131072, 65536], [65536, 32768], [32768, 16384], [16384, 8192]]) == [47, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n    assert candidate(n = 18,queries = [[131071, 65536], [32768, 16384], [8192, 4096], [2048, 1024], [512, 256], [128, 64], [32, 16], [8, 4], [2, 1], [131071, 1], [65536, 2], [32768, 4], [16384, 8]]) == [33, 2, 2, 2, 2, 2, 2, 2, 2, 17, 16, 14, 12]\n    assert candidate(n = 25,queries = [[33554431, 16777216], [16777215, 8388608], [8388607, 4194304], [4194303, 2097152], [2097151, 1048576]]) == [49, 47, 45, 43, 41]\n    assert candidate(n = 10,queries = [[511, 256], [128, 64], [32, 16], [8, 4], [4, 2], [2, 1], [128, 1], [256, 32], [511, 64]]) == [17, 2, 2, 2, 2, 2, 8, 4, 15]\n    assert candidate(n = 25,queries = [[33554431, 16777216], [8388608, 4194304], [2097152, 1048576], [524288, 262144], [131072, 65536]]) == [49, 2, 2, 2, 2]\n    assert candidate(n = 20,queries = [[524287, 262144], [131072, 65536], [32768, 16384], [8192, 4096], [2048, 1024], [512, 256], [128, 64], [32, 16], [8, 4]]) == [37, 2, 2, 2, 2, 2, 2, 2, 2]\n    assert candidate(n = 25,queries = [[16777216, 8388608], [8388608, 4194304], [4194304, 2097152], [2097152, 1048576], [1048576, 524288]]) == [2, 2, 2, 2, 2]\n    assert candidate(n = 20,queries = [[1048575, 1], [524288, 2], [262144, 4], [131072, 8], [65536, 16]]) == [20, 19, 17, 15, 13]\n    assert candidate(n = 18,queries = [[262143, 131072], [131071, 65536], [65535, 32768], [32767, 16384], [16383, 8192], [8191, 4096], [4095, 2048], [2047, 1024], [1023, 512]]) == [35, 33, 31, 29, 27, 25, 23, 21, 19]\n    assert candidate(n = 18,queries = [[131072, 262143], [65536, 131071], [32768, 65535], [16384, 32767], [8192, 16383], [4096, 8191], [2048, 4095], [1024, 2047]]) == [35, 33, 31, 29, 27, 25, 23, 21]\n    assert candidate(n = 25,queries = [[33554431, 16777216], [16777215, 8388608], [8388607, 4194304], [4194303, 2097152], [2097151, 1048576]]) == [49, 47, 45, 43, 41]\n    assert candidate(n = 18,queries = [[262143, 1], [131072, 3], [65536, 7], [32768, 15], [16384, 31], [8192, 63], [4096, 127], [2048, 255], [1024, 511], [512, 1023], [256, 2047], [128, 4095], [64, 8191], [32, 16383], [16, 32767], [8, 65535], [4, 131071], [2, 262143]]) == [18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n    assert candidate(n = 15,queries = [[16383, 16384], [8192, 12287], [4096, 6143], [2048, 8192], [1024, 4096]]) == [28, 25, 23, 3, 3]\n    assert candidate(n = 22,queries = [[2097152, 4194303], [1048576, 2097151], [524288, 1048575], [262144, 524287], [131072, 262143], [65536, 131071], [32768, 65535], [16384, 32767]]) == [43, 41, 39, 37, 35, 33, 31, 29]\n    assert candidate(n = 25,queries = [[33554431, 1], [16777216, 2], [8388608, 4], [4194304, 8], [2097152, 16], [1048576, 32], [524288, 64], [262144, 128], [131072, 256], [65536, 512], [32768, 1024], [16384, 2048], [8192, 4096], [4096, 8192], [2048, 16384], [1024, 32768], [512, 65536], [256, 131072], [128, 262144], [64, 524288], [32, 1048576], [16, 2097152], [8, 4194304], [4, 8388608], [2, 16777216]]) == [25, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]\n    assert candidate(n = 20,queries = [[524288, 1048575], [262144, 524287], [131072, 262143], [65536, 131071], [32768, 65535]]) == [39, 37, 35, 33, 31]\n    assert candidate(n = 16,queries = [[65535, 32768], [32767, 16384], [16383, 8192], [8191, 4096], [4095, 2048], [2047, 1024], [1023, 512], [511, 256], [255, 128], [127, 64], [63, 32], [31, 16], [15, 8], [7, 4], [3, 2], [1, 2]]) == [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 2]\n    assert candidate(n = 15,queries = [[16383, 8192], [4096, 2048], [1024, 512], [256, 128], [64, 32], [16, 8], [4, 2], [2, 1]]) == [27, 2, 2, 2, 2, 2, 2, 2]\n    assert candidate(n = 12,queries = [[2048, 4095], [1024, 2047], [512, 1023], [256, 511], [128, 255], [64, 127], [32, 63], [16, 31], [8, 15], [4, 7]]) == [23, 21, 19, 17, 15, 13, 11, 9, 7, 5]\n    assert candidate(n = 10,queries = [[511, 256], [255, 128], [127, 64], [63, 32], [31, 16], [15, 8], [7, 4], [3, 2], [1, 2]]) == [17, 15, 13, 11, 9, 7, 5, 3, 2]\n    assert candidate(n = 10,queries = [[512, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n    assert candidate(n = 20,queries = [[524288, 1048575], [262144, 524287], [131072, 262143], [65536, 131071], [32768, 65535], [16384, 32767]]) == [39, 37, 35, 33, 31, 29]\n", "comparison": "exact"}, "public_tests": ["3\n[[5,3],[4,7],[2,3]]", "2\n[[1,2]]"], "hints": ["Find the distance between nodes “a” and “b”.", "distance(a, b) = depth(a) + depth(b) - 2 * depth(LCA(a, b)). Where depth(a) denotes depth from root to node “a” and LCA(a, b) denotes the lowest common ancestor of nodes “a” and “b”.", "To find LCA(a, b), iterate over all ancestors of node “a” and check if it is the ancestor of node “b” too. If so, take the one with maximum depth."], "metadata": {"canonical_parameter_names": ["n", "queries"], "leetcode_dataset_entry_point": "Solution().cycleLengthQueries", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:23+00:00", "tests_total": 70, "tests_dropped": 19, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "tree", "binary-tree", "binary-lifting", "lowest-common-ancestor"]}, "language": "python", "interface": {"raw_signature": "def cycleLengthQueries(self, n: int, queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "cycleLengthQueries", "parameters": [{"name": "n", "type": "int"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}
+{"question_id": 2511, "task_id": "maximum-enemy-forts-that-can-be-captured", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array forts of length n representing the positions of several forts. forts[i] can be -1, 0, or 1 where:\n\n- -1 represents there is no fort at the i^th position.\n- 0 indicates there is an enemy fort at the i^th position.\n- 1 indicates the fort at the i^th the position is under your command.\n\nNow you have decided to move your army from one of your forts at position i to an empty position j such that:\n\n- 0 <= i, j <= n - 1\n- The army travels over enemy forts only. Formally, for all k where min(i,j) < k < max(i,j), forts[k] == 0.\n\nWhile moving the army, all the enemy forts that come in the way are captured.\n\nReturn the maximum number of enemy forts that can be captured. In case it is impossible to move your army, or you do not have any fort under your command, return 0.\n\nExample 1:\n\nInput: forts = [1,0,0,-1,0,0,0,0,1]\nOutput: 4\nExplanation:\n- Moving the army from position 0 to position 3 captures 2 enemy forts, at 1 and 2.\n- Moving the army from position 8 to position 3 captures 4 enemy forts.\nSince 4 is the maximum number of enemy forts that can be captured, we return 4.\n\nExample 2:\n\nInput: forts = [0,0,1,-1]\nOutput: 0\nExplanation: Since no enemy fort can be captured, 0 is returned.\n\nConstraints:\n\n- 1 <= forts.length <= 1000\n- -1 <= forts[i] <= 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n    assert candidate(forts = [1, 0, 1, 0, -1, 0, 1]) == 1\n    assert candidate(forts = [-1, 0, 0, 0, 0, 1]) == 4\n    assert candidate(forts = [0, 0, 0, 0, 0, 0, 0]) == 0\n    assert candidate(forts = [-1, 0, 0, 1, 0, 0, -1]) == 2\n    assert candidate(forts = [1, -1]) == 0\n    assert candidate(forts = [0, 0, 0, 0, 0]) == 0\n    assert candidate(forts = [-1]) == 0\n    assert candidate(forts = [0]) == 0\n    assert candidate(forts = [1, 0, -1, 0, 1, 0, -1]) == 1\n    assert candidate(forts = [0, 0, 0, 0]) == 0\n    assert candidate(forts = [0, 1, 0, -1, 0]) == 1\n    assert candidate(forts = [1, -1, 1, -1, 1, -1]) == 0\n    assert candidate(forts = [-1, 1, -1, 1, -1, 1]) == 0\n    assert candidate(forts = [0, 0, 1, -1]) == 0\n    assert candidate(forts = [0, 1, 0, -1, 0, 1, 0]) == 1\n    assert candidate(forts = [1, 1, 1, -1, -1, -1, 1]) == 0\n    assert candidate(forts = [-1, 0, -1, 0, 1, 0, 1]) == 1\n    assert candidate(forts = [1, 0, 0, 0, 0, -1]) == 4\n    assert candidate(forts = [1, 0, 1, 0, -1, 0, -1]) == 1\n    assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 1]) == 6\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, -1]) == 6\n    assert candidate(forts = [1, 0, 0, -1, 0, 0, 0, 0, 1]) == 4\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, -1]) == 5\n    assert candidate(forts = [-1, 0, 0, 0, 0, 0, 1]) == 5\n    assert candidate(forts = [1]) == 0\n    assert candidate(forts = [1, 1, -1, -1, 1, 1]) == 0\n    assert candidate(forts = [-1, 0, -1, 0, 1, 0, -1]) == 1\n    assert candidate(forts = [1, -1, 1, -1, 1]) == 0\n    assert candidate(forts = [-1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, -1]) == 1\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n    assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, 0, -1]) == 3\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 43\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 13\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 43\n    assert candidate(forts = [-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1]) == 3\n    assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, -1]) == 4\n    assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1]) == 5\n    assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 2\n    assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 5\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1]) == 43\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 29\n    assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n    assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1]) == 5\n    assert candidate(forts = [-1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 5\n    assert candidate(forts = [-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 0, 1]) == 4\n    assert candidate(forts = [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 50\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 71\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 1]) == 7\n    assert candidate(forts = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == 1\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 43\n    assert candidate(forts = [-1, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 1, 0]) == 4\n    assert candidate(forts = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]) == 7\n    assert candidate(forts = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1]) == 8\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 1, -1]) == 4\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 43\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1]) == 6\n    assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 1]) == 2\n    assert candidate(forts = [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 8\n    assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 77\n    assert candidate(forts = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 5\n    assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n    assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 5\n    assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1]) == 3\n    assert candidate(forts = [1, 0, 0, -1, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, -1]) == 4\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, -1, 0, 0, 1, 0, 0, -1, 0, 0, 1, 0, 0, -1]) == 2\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1]) == 5\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1]) == 10\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 10\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 56\n    assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n    assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 12\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1]) == 2\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n    assert candidate(forts = [1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1]) == 5\n    assert candidate(forts = [0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1]) == 5\n", "comparison": "exact"}, "public_tests": ["[1,0,0,-1,0,0,0,0,1]", "[0,0,1,-1]"], "hints": ["For each fort under your command, check if you can move the army from here.", "If yes, find the closest empty positions satisfying all criteria.", "How can two-pointers be used to solve this problem optimally?"], "metadata": {"canonical_parameter_names": ["forts"], "leetcode_dataset_entry_point": "Solution().captureForts", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:27+00:00", "tests_total": 100, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "two-pointers"]}, "language": "python", "interface": {"raw_signature": "def captureForts(self, forts: list[int]) -> int:", "container": "Solution", "callable": "captureForts", "parameters": [{"name": "forts", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}